diff -Nru a/CREDITS b/CREDITS
--- a/CREDITS	2004-12-24 13:37:02 -08:00
+++ b/CREDITS	2004-12-24 13:37:02 -08:00
@@ -46,13 +46,11 @@
 S: United Kingdom
 
 N: Werner Almesberger
-E: werner.almesberger@epfl.ch
+E: werner@almesberger.net
+W: http://www.almesberger.net/
 D: dosfs, LILO, some fd features, ATM, various other hacks here and there
-S: Ecole Polytechnique Federale de Lausanne
-S: DSC ICA
-S: INN (Ecublens)
-S: CH-1015 Lausanne
-S: Switzerland
+S: Buenos Aires
+S: Argentina
 
 N: Tim Alpaerts
 E: tim_alpaerts@toyota-motor-europe.com
@@ -497,6 +495,14 @@
 D: REINER SCT cyberJack pinpad/e-com USB chipcard reader driver
 S: Germany
 
+N: Adrian Bunk
+E: bunk@stusta.de
+P: 1024D/4F12B400  B29C E71E FE19 6755 5C8A  84D4 99FC EA98 4F12 B400
+D: misc kernel hacking and testing
+S: Grasmeierstrasse 11
+S: 80805 Muenchen
+S: Germany
+
 N: Ray Burr
 E: ryb@nightmare.com
 D: Original author of Amiga FFS filesystem
@@ -2764,7 +2770,7 @@
 E: luca.risolia@studio.unibo.it
 P: 1024D/FCE635A4 88E8 F32F 7244 68BA 3958  5D40 99DA 5D2A FCE6 35A4
 D: V4L driver for W996[87]CF JPEG USB Dual Mode Camera Chips
-D: V4L2 driver for SN9C10[12] PC Camera Controllers
+D: V4L2 driver for SN9C10x PC Camera Controllers
 S: Via Liberta' 41/A
 S: Osio Sotto, 24046, Bergamo
 S: Italy
diff -Nru a/Documentation/00-INDEX b/Documentation/00-INDEX
--- a/Documentation/00-INDEX	2004-12-24 13:36:31 -08:00
+++ b/Documentation/00-INDEX	2004-12-24 13:36:31 -08:00
@@ -20,6 +20,8 @@
 	- list of changes that break older software packages.
 CodingStyle
 	- how the boss likes the C code in the kernel to look.
+DMA-API.txt
+	- DMA API, pci_ API & extensions for non-consistent memory machines.
 DMA-mapping.txt
 	- info for PCI drivers using DMA portably across all platforms.
 DocBook/
@@ -30,8 +32,12 @@
 	- info on Linux Intelligent Platform Management Interface (IPMI) Driver.
 IRQ-affinity.txt
 	- how to select which CPU(s) handle which interrupt events on SMP.
+ManagementStyle
+	- how to (attempt to) manage kernel hackers.
 MSI-HOWTO.txt
 	- the Message Signaled Interrupts (MSI) Driver Guide HOWTO and FAQ.
+RCU/
+	- directory with info on RCU (read-copy update).
 README.DAC960
 	- info on Mylex DAC960/DAC1100 PCI RAID Controller Driver for Linux.
 README.moxa
@@ -46,8 +52,6 @@
 	- how to change your VGA cursor from a blinking underscore.
 arm/
 	- directory with info about Linux on the ARM architecture.
-as-iosched.txt
-	- info on anticipatory IO scheduler.
 basic_profiling.txt
 	- basic instructions for those who wants to profile Linux kernel.
 binfmt_misc.txt
@@ -60,20 +64,24 @@
 	- info, major/minor #'s for Compaq's SMART Array Controllers.
 cdrom/
 	- directory with information on the CD-ROM drivers that Linux has.
+cli-sti-removal.txt
+	- cli()/sti() removal guide.
 computone.txt
 	- info on Computone Intelliport II/Plus Multiport Serial Driver.
 cpqarray.txt
 	- info on using Compaq's SMART2 Intelligent Disk Array Controllers.
-cpufreq/
+cpu-freq/
 	- info on CPU frequency and voltage scaling.
 cris/
 	- directory with info about Linux on CRIS architecture.
+crypto/
+	- directory with info on the Crypto API.
 debugging-modules.txt
 	- some notes on debugging modules after Linux 2.6.3.
+device-mapper/
+	- directory with info on Device Mapper.
 devices.txt
 	- plain ASCII listing of all the nodes in /dev/ with major minor #'s.
-digiboard.txt
-	- info on the Digiboard PC/X{i,e,eve} multiport boards.
 digiepca.txt
 	- info on Digi Intl. {PC,PCI,EISA}Xx and Xem series cards.
 dnotify.txt
@@ -92,6 +100,8 @@
 	- directory with info on the frame buffer graphics abstraction layer.
 filesystems/
 	- directory with info on the various filesystems that Linux supports.
+firmware_class/
+	- request_firmware() hotplug interface info.
 floppy.txt
 	- notes and driver options for the floppy disk driver.
 ftape.txt
@@ -100,10 +110,14 @@
 	- info on using the Hayes ESP serial driver.
 highuid.txt
 	- notes on the change from 16 bit to 32 bit user/group IDs.
+hpet.txt
+	- High Precision Event Timer Driver for Linux.
 hw_random.txt
 	- info on Linux support for random number generator in i8xx chipsets.
 i2c/
 	- directory with info about the I2C bus/protocol (2 wire, kHz speed).
+i2o/
+	- directory with info about the Linux I2O subsystem.
 i386/
 	- directory with info about Linux on Intel 32 bit architecture.
 ia64/
@@ -114,6 +128,8 @@
 	- how to use the RAM disk as an initial/temporary root filesystem.
 input/
 	- info on Linux input device support.
+io_ordering.txt
+	- info on ordering I/O writes to memory-mapped addresses.
 ioctl-number.txt
 	- how to implement and register device/driver ioctl calls.
 iostats.txt
@@ -134,6 +150,8 @@
 	- summary listing of command line / boot prompt args for the kernel.
 kobject.txt
 	- info of the kobject infrastructure of the Linux kernel.
+laptop-mode.txt
+	- How to conserve battery power using laptop-mode.
 ldm.txt
 	- a brief description of LDM (Windows Dynamic Disks).
 locks.txt
@@ -158,8 +176,8 @@
 	- directory with info about Linux on MIPS architecture.
 mkdev.cciss
 	- script to make /dev entries for SMART controllers (see cciss.txt).
-mkdev.ida
-	- script to make /dev entries for Intelligent Disk Array Controllers.
+mono.txt
+	- how to execute Mono-based .NET binaries with the help of BINFMT_MISC.
 moxa-smartio
 	- info on installing/using Moxa multiport serial driver.
 mtrr.txt
@@ -172,6 +190,8 @@
 	- short guide on setting up a diskless box with NFS root filesystem.
 nmi_watchdog.txt
 	- info on NMI watchdog for SMP systems.
+numastat.txt
+	- info on how to read Numa policy hit/miss statistics in sysfs.
 oops-tracing.txt
 	- how to decode those nasty internal kernel error dump messages.
 paride.txt
@@ -199,17 +219,25 @@
 riscom8.txt
 	- notes on using the RISCom/8 multi-port serial driver.
 rocket.txt
-	- info on installing/using the Comtrol RocketPort multiport serial driver.
+	- info on the Comtrol RocketPort multiport serial driver.
 rpc-cache.txt
 	- introduction to the caching mechanisms in the sunrpc layer.
 rtc.txt
 	- notes on how to use the Real Time Clock (aka CMOS clock) driver.
 s390/
 	- directory with info on using Linux on the IBM S390.
+sched-coding.txt
+	- reference for various scheduler-related methods in the O(1) scheduler.
 sched-design.txt
 	- goals, design and implementation of the Linux O(1) scheduler.
+sched-domains.txt
+	- information on scheduling domains.
+sched-stats.txt
+	- information on schedstats (Linux Scheduler Statistics).
 scsi/
 	- directory with info on Linux scsi support.
+serial/
+	- directory with info on the low level serial API.
 serial-console.txt
 	- how to set up Linux with a serial line console as the default.
 sgi-visws.txt
@@ -242,14 +270,24 @@
 	- info on the magic SysRq key.
 telephony/
 	- directory with info on telephony (e.g. voice over IP) support.
+time_interpolators.txt
+	- info on time interpolators.
+tipar.txt
+	- information about Parallel link cable for Texas Instruments handhelds.
+tty.txt
+	- guide to the locking policies of the tty layer.
 unicode.txt
 	- info on the Unicode character/font mapping used in Linux.
+uml/
+	- directory with infomation about User Mode Linux.
 usb/
 	- directory with info regarding the Universal Serial Bus.
 video4linux/
 	- directory with info regarding video/TV/radio cards and linux.
 vm/
 	- directory with info on the Linux vm code.
+voyager.txt
+	- guide to running Linux on the Voyager architecture.
 watchdog/
 	- how to auto-reboot Linux if it has "fallen and can't get up". ;-)
 x86_64/
diff -Nru a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
--- a/Documentation/DMA-API.txt	2004-12-24 13:36:56 -08:00
+++ b/Documentation/DMA-API.txt	2004-12-24 13:36:56 -08:00
@@ -160,7 +160,7 @@
 Checks to see if the mask is possible and updates the device
 parameters if it is.
 
-Returns: 1 if successful and 0 if not
+Returns: 0 if successful and a negative error if not.
 
 u64
 dma_get_required_mask(struct device *dev)
diff -Nru a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
--- a/Documentation/DocBook/Makefile	2004-12-24 13:36:49 -08:00
+++ b/Documentation/DocBook/Makefile	2004-12-24 13:36:49 -08:00
@@ -8,10 +8,10 @@
 
 DOCBOOKS := wanbook.sgml z8530book.sgml mcabook.sgml videobook.sgml \
 	    kernel-hacking.sgml kernel-locking.sgml via-audio.sgml \
-	    mousedrivers.sgml deviceiobook.sgml procfs-guide.sgml \
-	    tulip-user.sgml writing_usb_driver.sgml scsidrivers.sgml \
-	    sis900.sgml kernel-api.sgml journal-api.sgml lsm.sgml usb.sgml \
-	    gadget.sgml libata.sgml
+	    deviceiobook.sgml procfs-guide.sgml tulip-user.sgml \
+	    writing_usb_driver.sgml scsidrivers.sgml sis900.sgml \
+	    kernel-api.sgml journal-api.sgml lsm.sgml usb.sgml \
+	    gadget.sgml libata.sgml mtdnand.sgml librs.sgml
 
 ###
 # The build process is as follows (targets):
@@ -58,14 +58,14 @@
 # The following rules are used to generate the .sgml documentation
 # required to generate the final targets. (ps, pdf, html).
 quiet_cmd_docproc = DOCPROC $@
-      cmd_docproc = $(DOCPROC) doc $< >$@
+      cmd_docproc = SRCTREE=$(srctree)/ $(DOCPROC) doc $< >$@
 define rule_docproc
 	set -e;								\
         $(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))';) 	\
         $(cmd_$(1)); 							\
         ( 								\
           echo 'cmd_$@ := $(cmd_$(1))'; 				\
-          echo $@: `$(DOCPROC) depend $<`; 				\
+          echo $@: `SRCTREE=$(srctree) $(DOCPROC) depend $<`; 		\
         ) > $(dir $@).$(notdir $@).cmd
 endef
 
@@ -129,6 +129,9 @@
 # Rule to generate man files - output is placed in the man subdirectory
 
 %.9:	%.sgml
+ifneq ($(KBUILD_SRC),)
+	$(Q)mkdir -p $(objtree)/Documentation/DocBook/man
+endif
 	$(SPLITMAN) $< $(objtree)/Documentation/DocBook/man "$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)"
 	$(MAKEMAN) convert $(objtree)/Documentation/DocBook/man $<
 
diff -Nru a/Documentation/DocBook/deviceiobook.tmpl b/Documentation/DocBook/deviceiobook.tmpl
--- a/Documentation/DocBook/deviceiobook.tmpl	2004-12-24 13:36:48 -08:00
+++ b/Documentation/DocBook/deviceiobook.tmpl	2004-12-24 13:36:48 -08:00
@@ -147,8 +147,7 @@
 	compiler is not permitted to reorder the I/O sequence. When the 
 	ordering can be compiler optimised, you can use <function>
 	__readb</function> and friends to indicate the relaxed ordering. Use 
-	this with care. The <function>rmb</function> provides a read memory 
-	barrier. The <function>wmb</function> provides a write memory barrier.
+	this with care.
       </para>
 
       <para>
@@ -159,19 +158,113 @@
 	asynchronously. A driver author must issue a read from the same
 	device to ensure that writes have occurred in the specific cases the
 	author cares. This kind of property cannot be hidden from driver
-	writers in the API.
+	writers in the API.  In some cases, the read used to flush the device
+	may be expected to fail (if the card is resetting, for example).  In
+	that case, the read should be done from config space, which is
+	guaranteed to soft-fail if the card doesn't respond.
+      </para>
+
+      <para>
+	The following is an example of flushing a write to a device when
+	the driver would like to ensure the write's effects are visible prior
+	to continuing execution.
+      </para>
+
+<programlisting>
+static inline void
+qla1280_disable_intrs(struct scsi_qla_host *ha)
+{
+	struct device_reg *reg;
+
+	reg = ha->iobase;
+	/* disable risc and host interrupts */
+	WRT_REG_WORD(&amp;reg->ictrl, 0);
+	/*
+	 * The following read will ensure that the above write
+	 * has been received by the device before we return from this
+	 * function.
+	 */
+	RD_REG_WORD(&amp;reg->ictrl);
+	ha->flags.ints_enabled = 0;
+}
+</programlisting>
+
+      <para>
+	In addition to write posting, on some large multiprocessing systems
+	(e.g. SGI Challenge, Origin and Altix machines) posted writes won't
+	be strongly ordered coming from different CPUs.  Thus it's important
+	to properly protect parts of your driver that do memory-mapped writes
+	with locks and use the <function>mmiowb</function> to make sure they
+	arrive in the order intended.  Issuing a regular <function>readX
+	</function> will also ensure write ordering, but should only be used
+	when the driver has to be sure that the write has actually arrived
+	at the device (not that it's simply ordered with respect to other
+	writes), since a full <function>readX</function> is a relatively
+	expensive operation.
+      </para>
+
+      <para>
+	Generally, one should use <function>mmiowb</function> prior to
+	releasing a spinlock that protects regions using <function>writeb
+	</function> or similar functions that aren't surrounded by <function>
+	readb</function> calls, which will ensure ordering and flushing.  The
+	following pseudocode illustrates what might occur if write ordering
+	isn't guaranteed via <function>mmiowb</function> or one of the
+	<function>readX</function> functions.
+      </para>
+
+<programlisting>
+CPU A:  spin_lock_irqsave(&amp;dev_lock, flags)
+CPU A:  ...
+CPU A:  writel(newval, ring_ptr);
+CPU A:  spin_unlock_irqrestore(&amp;dev_lock, flags)
+        ...
+CPU B:  spin_lock_irqsave(&amp;dev_lock, flags)
+CPU B:  writel(newval2, ring_ptr);
+CPU B:  ...
+CPU B:  spin_unlock_irqrestore(&amp;dev_lock, flags)
+</programlisting>
+
+      <para>
+	In the case above, newval2 could be written to ring_ptr before
+	newval.  Fixing it is easy though:
+      </para>
+
+<programlisting>
+CPU A:  spin_lock_irqsave(&amp;dev_lock, flags)
+CPU A:  ...
+CPU A:  writel(newval, ring_ptr);
+CPU A:  mmiowb(); /* ensure no other writes beat us to the device */
+CPU A:  spin_unlock_irqrestore(&amp;dev_lock, flags)
+        ...
+CPU B:  spin_lock_irqsave(&amp;dev_lock, flags)
+CPU B:  writel(newval2, ring_ptr);
+CPU B:  ...
+CPU B:  mmiowb();
+CPU B:  spin_unlock_irqrestore(&amp;dev_lock, flags)
+</programlisting>
+
+      <para>
+	See tg3.c for a real world example of how to use <function>mmiowb
+	</function>
       </para>
 
       <para>
 	PCI ordering rules also guarantee that PIO read responses arrive
-	after any outstanding DMA writes on that bus, since for some devices
+	after any outstanding DMA writes from that bus, since for some devices
 	the result of a <function>readb</function> call may signal to the
 	driver that a DMA transaction is complete.  In many cases, however,
 	the driver may want to indicate that the next
 	<function>readb</function> call has no relation to any previous DMA
 	writes performed by the device.  The driver can use
 	<function>readb_relaxed</function> for these cases, although only
-	some platforms will honor the relaxed semantics.
+	some platforms will honor the relaxed semantics.  Using the relaxed
+	read functions will provide significant performance benefits on
+	platforms that support it.  The qla2xxx driver provides examples
+	of how to use <function>readX_relaxed</function>.  In many cases,
+	a majority of the driver's <function>readX</function> calls can
+	safely be converted to <function>readX_relaxed</function> calls, since
+	only a few will indicate or depend on DMA completion.
       </para>
     </sect1>
 
diff -Nru a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
--- a/Documentation/DocBook/kernel-api.tmpl	2004-12-24 13:36:16 -08:00
+++ b/Documentation/DocBook/kernel-api.tmpl	2004-12-24 13:36:16 -08:00
@@ -133,6 +133,11 @@
      <sect1><title>Socket Filter</title>
 !Enet/core/filter.c
      </sect1>
+     <sect1><title>Generic Network Statistics</title>
+!Iinclude/linux/gen_stats.h
+!Enet/core/gen_stats.c
+!Enet/core/gen_estimator.c
+     </sect1>
   </chapter>
 
   <chapter id="netdev">
diff -Nru a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
--- a/Documentation/DocBook/kernel-hacking.tmpl	2004-12-24 13:36:55 -08:00
+++ b/Documentation/DocBook/kernel-hacking.tmpl	2004-12-24 13:36:55 -08:00
@@ -888,7 +888,7 @@
    The second class of atomic operations is atomic bit operations on a
    <type>long</type>, defined in
 
-   <filename class="headerfile">include/asm/bitops.h</filename>.  These
+   <filename class="headerfile">include/linux/bitops.h</filename>.  These
    operations generally take a pointer to the bit pattern, and a bit
    number: 0 is the least significant bit.
    <function>set_bit()</function>, <function>clear_bit()</function>
diff -Nru a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
--- a/Documentation/DocBook/libata.tmpl	2004-12-24 13:36:48 -08:00
+++ b/Documentation/DocBook/libata.tmpl	2004-12-24 13:36:48 -08:00
@@ -61,6 +61,196 @@
   </para>
   </chapter>
 
+  <chapter id="libataDriverApi">
+     <title>libata Driver API</title>
+     <sect1>
+        <title>struct ata_port_operations</title>
+
+	<programlisting>
+void (*port_disable) (struct ata_port *);
+	</programlisting>
+
+	<para>
+	Called from ata_bus_probe() and ata_bus_reset() error paths,
+	as well as when unregistering from the SCSI module (rmmod, hot
+	unplug).
+	</para>
+
+	<programlisting>
+void (*dev_config) (struct ata_port *, struct ata_device *);
+	</programlisting>
+
+	<para>
+	Called after IDENTIFY [PACKET] DEVICE is issued to each device
+	found.  Typically used to apply device-specific fixups prior to
+	issue of SET FEATURES - XFER MODE, and prior to operation.
+	</para>
+
+	<programlisting>
+void (*set_piomode) (struct ata_port *, struct ata_device *);
+void (*set_dmamode) (struct ata_port *, struct ata_device *);
+void (*post_set_mode) (struct ata_port *ap);
+	</programlisting>
+
+	<para>
+	Hooks called prior to the issue of SET FEATURES - XFER MODE
+	command.  dev->pio_mode is guaranteed to be valid when
+	->set_piomode() is called, and dev->dma_mode is guaranteed to be
+	valid when ->set_dmamode() is called.  ->post_set_mode() is
+	called unconditionally, after the SET FEATURES - XFER MODE
+	command completes successfully.
+	</para>
+
+	<para>
+	->set_piomode() is always called (if present), but
+	->set_dma_mode() is only called if DMA is possible.
+	</para>
+
+	<programlisting>
+void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf);
+void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
+	</programlisting>
+
+	<para>
+	->tf_load() is called to load the given taskfile into hardware
+	registers / DMA buffers.  ->tf_read() is called to read the
+	hardware registers / DMA buffers, to obtain the current set of
+	taskfile register values.
+	</para>
+
+	<programlisting>
+void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);
+	</programlisting>
+
+	<para>
+	causes an ATA command, previously loaded with
+	->tf_load(), to be initiated in hardware.
+	</para>
+
+	<programlisting>
+u8   (*check_status)(struct ata_port *ap);
+void (*dev_select)(struct ata_port *ap, unsigned int device);
+	</programlisting>
+
+	<para>
+	Reads the Status ATA shadow register from hardware.  On some
+	hardware, this has the side effect of clearing the interrupt
+	condition.
+	</para>
+
+	<programlisting>
+void (*dev_select)(struct ata_port *ap, unsigned int device);
+	</programlisting>
+
+	<para>
+	Issues the low-level hardware command(s) that causes one of N
+	hardware devices to be considered 'selected' (active and
+	available for use) on the ATA bus.
+	</para>
+
+	<programlisting>
+void (*phy_reset) (struct ata_port *ap);
+	</programlisting>
+
+	<para>
+	The very first step in the probe phase.  Actions vary depending
+	on the bus type, typically.  After waking up the device and probing
+	for device presence (PATA and SATA), typically a soft reset
+	(SRST) will be performed.  Drivers typically use the helper
+	functions ata_bus_reset() or sata_phy_reset() for this hook.
+	</para>
+
+	<programlisting>
+void (*bmdma_setup) (struct ata_queued_cmd *qc);
+void (*bmdma_start) (struct ata_queued_cmd *qc);
+	</programlisting>
+
+	<para>
+	When setting up an IDE BMDMA transaction, these hooks arm
+	(->bmdma_setup) and fire (->bmdma_start) the hardware's DMA
+	engine.
+	</para>
+
+	<programlisting>
+void (*qc_prep) (struct ata_queued_cmd *qc);
+int (*qc_issue) (struct ata_queued_cmd *qc);
+	</programlisting>
+
+	<para>
+	Higher-level hooks, these two hooks can potentially supercede
+	several of the above taskfile/DMA engine hooks.  ->qc_prep is
+	called after the buffers have been DMA-mapped, and is typically
+	used to populate the hardware's DMA scatter-gather table.
+	Most drivers use the standard ata_qc_prep() helper function, but
+	more advanced drivers roll their own.
+	</para>
+	<para>
+	->qc_issue is used to make a command active, once the hardware
+	and S/G tables have been prepared.  IDE BMDMA drivers use the
+	helper function ata_qc_issue_prot() for taskfile protocol-based
+	dispatch.  More advanced drivers roll their own ->qc_issue
+	implementation, using this as the "issue new ATA command to
+	hardware" hook.
+	</para>
+
+	<programlisting>
+void (*eng_timeout) (struct ata_port *ap);
+	</programlisting>
+
+	<para>
+	This is a high level error handling function, called from the
+	error handling thread, when a command times out.
+	</para>
+
+	<programlisting>
+irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);
+void (*irq_clear) (struct ata_port *);
+	</programlisting>
+
+	<para>
+	->irq_handler is the interrupt handling routine registered with
+	the system, by libata.  ->irq_clear is called during probe just
+	before the interrupt handler is registered, to be sure hardware
+	is quiet.
+	</para>
+
+	<programlisting>
+u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
+void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
+                   u32 val);
+	</programlisting>
+
+	<para>
+	Read and write standard SATA phy registers.  Currently only used
+	if ->phy_reset hook called the sata_phy_reset() helper function.
+	</para>
+
+	<programlisting>
+int (*port_start) (struct ata_port *ap);
+void (*port_stop) (struct ata_port *ap);
+void (*host_stop) (struct ata_host_set *host_set);
+	</programlisting>
+
+	<para>
+	->port_start() is called just after the data structures for each
+	port are initialized.  Typically this is used to alloc per-port
+	DMA buffers / tables / rings, enable DMA engines, and similar
+	tasks.  
+	</para>
+	<para>
+	->host_stop() is called when the rmmod or hot unplug process
+	begins.  The hook must stop all hardware interrupts, DMA
+	engines, etc.
+	</para>
+	<para>
+	->port_stop() is called after ->host_stop().  It's sole function
+	is to release DMA/memory resources, now that they are no longer
+	actively being used.
+	</para>
+
+     </sect1>
+  </chapter>
+
   <chapter id="libataExt">
      <title>libata Library</title>
 !Edrivers/scsi/libata-core.c
@@ -83,7 +273,7 @@
   </chapter>
 
   <chapter id="SILInt">
-     <title>ata_sil Internals</title>
+     <title>sata_sil Internals</title>
 !Idrivers/scsi/sata_sil.c
   </chapter>
 
diff -Nru a/Documentation/DocBook/librs.tmpl b/Documentation/DocBook/librs.tmpl
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/DocBook/librs.tmpl	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,287 @@
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN"[]>
+
+<book id="Reed-Solomon-Library-Guide">
+ <bookinfo>
+  <title>Reed-Solomon Library Programming Interface</title>
+  
+  <authorgroup>
+   <author>
+    <firstname>Thomas</firstname>
+    <surname>Gleixner</surname>
+    <affiliation>
+     <address>
+      <email>tglx@linutronix.de</email>
+     </address>
+    </affiliation>
+   </author>
+  </authorgroup>
+
+  <copyright>
+   <year>2004</year>
+   <holder>Thomas Gleixner</holder>
+  </copyright>
+
+  <legalnotice>
+   <para>
+     This documentation 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.
+   </para>
+      
+   <para>
+     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.
+   </para>
+      
+   <para>
+     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
+   </para>
+      
+   <para>
+     For more details see the file COPYING in the source
+     distribution of Linux.
+   </para>
+  </legalnotice>
+ </bookinfo>
+
+<toc></toc>
+
+  <chapter id="intro">
+      <title>Introduction</title>
+  <para>
+  	The generic Reed-Solomon Library provides encoding, decoding
+	and error correction functions.
+  </para>
+  <para>
+  	Reed-Solomon codes are used in communication and storage
+	applications to ensure data integrity. 
+  </para>
+  <para>
+  	This documentation is provided for developers who want to utilize
+	the functions provided by the library.
+  </para>
+  </chapter>
+  
+  <chapter id="bugs">
+     <title>Known Bugs And Assumptions</title>
+  <para>
+	None.	
+  </para>
+  </chapter>
+
+  <chapter id="usage">
+     	<title>Usage</title>
+	<para>
+		This chapter provides examples how to use the library.
+	</para>
+	<sect1>
+		<title>Initializing</title>
+		<para>
+			The init function init_rs returns a pointer to a
+			rs decoder structure, which holds the necessary
+			information for encoding, decoding and error correction
+			with the given polynomial. It either uses an existing
+			matching decoder or creates a new one. On creation all
+			the lookup tables for fast en/decoding are created.
+			The function may take a while, so make sure not to 
+			call it in critical code paths.
+		</para>
+		<programlisting>
+/* the Reed Solomon control structure */
+static struct rs_control *rs_decoder;
+
+/* Symbolsize is 10 (bits)
+ * Primitve polynomial is x^10+x^3+1
+ * first consecutive root is 0
+ * primitve element to generate roots = 1
+ * generator polinomial degree (number of roots) = 6
+ */
+rs_decoder = init_rs (10, 0x409, 0, 1, 6);
+		</programlisting>
+	</sect1>
+	<sect1>
+		<title>Encoding</title>
+		<para>
+			The encoder calculates the Reed-Solomon code over
+			the given data length and stores the result in 
+			the parity buffer. Note that the parity buffer must
+			be initialized before calling the encoder.
+		</para>
+		<para>
+			The expanded data can be inverted on the fly by
+			providing a non zero inversion mask. The expanded data is
+			XOR'ed with the mask. This is used e.g. for FLASH
+			ECC, where the all 0xFF is inverted to an all 0x00.
+			The Reed-Solomon code for all 0x00 is all 0x00. The
+			code is inverted before storing to FLASH so it is 0xFF
+			too. This prevent's that reading from an erased FLASH
+			results in ECC errors.
+		</para>
+		<para>
+			The databytes are expanded to the given symbol size
+			on the fly. There is no support for encoding continuous
+			bitstreams with a symbol size != 8 at the moment. If
+			it is necessary it should be not a big deal to implement
+			such functionality.
+		</para>
+		<programlisting>
+/* Parity buffer. Size = number of roots */
+uint16_t par[6];
+/* Initialize the parity buffer */
+memset(par, 0, sizeof(par));
+/* Encode 512 byte in data8. Store parity in buffer par */
+encode_rs8 (rs_decoder, data8, 512, par, 0);
+		</programlisting>
+	</sect1>
+	<sect1>
+		<title>Decoding</title>
+		<para>
+			The decoder calculates the syndrome over
+			the given data length and the received parity symbols
+			and corrects errors in the data.
+		</para>
+		<para>
+			If a syndrome is available from a hardware decoder
+			then the syndrome calculation is skipped.
+		</para>
+		<para>
+			The correction of the data buffer can be suppressed
+			by providing a correction pattern buffer and an error
+			location buffer to the decoder. The decoder stores the
+			calculated error location and the correction bitmask
+			in the given buffers. This is useful for hardware
+			decoders which use a weird bit ordering scheme.
+		</para>
+		<para>
+			The databytes are expanded to the given symbol size
+			on the fly. There is no support for decoding continuous
+			bitstreams with a symbolsize != 8 at the moment. If
+			it is necessary it should be not a big deal to implement
+			such functionality.
+		</para>
+		
+		<sect2>
+		<title>
+			Decoding with syndrome calculation, direct data correction
+		</title>
+		<programlisting>
+/* Parity buffer. Size = number of roots */
+uint16_t par[6];
+uint8_t  data[512];
+int numerr;
+/* Receive data */
+.....
+/* Receive parity */
+.....
+/* Decode 512 byte in data8.*/
+numerr = decode_rs8 (rs_decoder, data8, par, 512, NULL, 0, NULL, 0, NULL);
+		</programlisting>
+		</sect2>
+
+		<sect2>
+		<title>
+			Decoding with syndrome given by hardware decoder, direct data correction
+		</title>
+		<programlisting>
+/* Parity buffer. Size = number of roots */
+uint16_t par[6], syn[6];
+uint8_t  data[512];
+int numerr;
+/* Receive data */
+.....
+/* Receive parity */
+.....
+/* Get syndrome from hardware decoder */
+.....
+/* Decode 512 byte in data8.*/
+numerr = decode_rs8 (rs_decoder, data8, par, 512, syn, 0, NULL, 0, NULL);
+		</programlisting>
+		</sect2>
+
+		<sect2>
+		<title>
+			Decoding with syndrome given by hardware decoder, no direct data correction.
+		</title>
+		<para>
+			Note: It's not necessary to give data and received parity to the decoder.
+		</para>
+		<programlisting>
+/* Parity buffer. Size = number of roots */
+uint16_t par[6], syn[6], corr[8];
+uint8_t  data[512];
+int numerr, errpos[8];
+/* Receive data */
+.....
+/* Receive parity */
+.....
+/* Get syndrome from hardware decoder */
+.....
+/* Decode 512 byte in data8.*/
+numerr = decode_rs8 (rs_decoder, NULL, NULL, 512, syn, 0, errpos, 0, corr);
+for (i = 0; i < numerr; i++) {
+	do_error_correction_in_your_buffer(errpos[i], corr[i]);
+}
+		</programlisting>
+		</sect2>
+	</sect1>
+	<sect1>
+		<title>Cleanup</title>
+		<para>
+			The function free_rs frees the allocated resources,
+			if the caller is the last user of the decoder.
+		</para>
+		<programlisting>
+/* Release resources */
+free_rs(rs_decoder);
+		</programlisting>
+	</sect1>
+
+  </chapter>
+	
+  <chapter id="structs">
+     <title>Structures</title>
+     <para>
+     This chapter contains the autogenerated documentation of the structures which are
+     used in the Reed-Solomon Library and are relevant for a developer.
+     </para>
+!Iinclude/linux/rslib.h
+  </chapter>
+
+  <chapter id="pubfunctions">
+     <title>Public Functions Provided</title>
+     <para>
+     This chapter contains the autogenerated documentation of the Reed-Solomon functions
+     which are exported.
+     </para>
+!Elib/reed_solomon/reed_solomon.c
+  </chapter>
+  
+  <chapter id="credits">
+     <title>Credits</title>
+	<para>
+		The library code for encoding and decoding was written by Phil Karn.
+	</para>
+	<programlisting>
+		Copyright 2002, Phil Karn, KA9Q
+ 		May be used under the terms of the GNU General Public License (GPL)
+	</programlisting>
+	<para>
+		The wrapper functions and interfaces are written by Thomas Gleixner
+	</para>
+	<para>
+		Many users have provided bugfixes, improvements and helping hands for testing.
+		Thanks a lot.
+	</para>
+	<para>
+		The following people have contributed to this document:
+	</para>
+	<para>
+		Thomas Gleixner<email>tglx@linutronix.de</email>
+	</para>
+  </chapter>
+</book>
diff -Nru a/Documentation/DocBook/mousedrivers.tmpl b/Documentation/DocBook/mousedrivers.tmpl
--- a/Documentation/DocBook/mousedrivers.tmpl	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1022 +0,0 @@
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN"[]>
-
-<book id="MouseGuide">
- <bookinfo>
-  <title>Mouse Drivers</title>
-  
-  <authorgroup>
-   <author>
-    <firstname>Alan</firstname>
-    <surname>Cox</surname>
-    <affiliation>
-     <address>
-      <email>alan@redhat.com</email>
-     </address>
-    </affiliation>
-   </author>
-  </authorgroup>
-
-  <copyright>
-   <year>2000</year>
-   <holder>Alan Cox</holder>
-  </copyright>
-
-  <legalnotice>
-   <para>
-     This documentation 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.
-   </para>
-      
-   <para>
-     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.
-   </para>
-      
-   <para>
-     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
-   </para>
-      
-   <para>
-     For more details see the file COPYING in the source
-     distribution of Linux.
-   </para>
-  </legalnotice>
- </bookinfo>
-
- <toc></toc>
-
- <chapter id="intro">
-  <title>Introduction</title>
-  <note>
-   <title>Earlier publication</title>
-    <para>
-      Parts of this document first appeared in Linux Magazine under a
-      ninety day exclusivity.
-   </para>
-  </note> 
-
-  <para>
-    Mice are conceptually one of the simplest device interfaces in the 
-    Linux operating system. Not all mice are handled by the kernel. 
-    Instead there is a two layer abstraction.
-  </para>
-
-  <para>
-    The kernel mouse drivers and userspace drivers for the serial mice are
-    all managed by a system daemon called <application>gpm</application> 
-    - the general purpose mouse driver. <application>gpm</application> 
-    handles cutting and pasting on the text consoles. It provides a 
-    general library for mouse-aware applications and it handles the 
-    sharing of mouse services with the 
-    <application>X Window System</application> user interface.
-  </para>
-  <para>
-    Sometimes a mouse speaks a sufficiently convoluted protocol that the
-    protocol is handled by <application>Gpm</application> itself. Most 
-    of the mouse drivers follow a common interface called the bus mouse 
-    protocol.
-  </para>
-  <para>
-    Each read from a bus mouse interface device returns a block of data. 
-    The first three bytes of each read are defined as follows: 
-
-   <table frame="all">
-    <title>Mouse Data Encoding</title>
-    <tgroup cols="2" align="left">
-     <tbody>
-      <row>
-       <entry>Byte 0</entry>
-       <entry>0x80 + the buttons currently down.</entry>
-      </row>
-      <row>
-       <entry>Byte 1</entry>
-       <entry>A signed value for the shift in X position</entry>
-      </row>
-      <row>
-       <entry>Byte 2</entry>
-       <entry>A signed value for the shift in Y position</entry>
-      </row>
-     </tbody>
-    </tgroup>
-   </table>
-
-    An application can choose to read more than 3 bytes. The rest of the 
-    bytes will be zero, or may optionally return some additional 
-    device-specific information.
-  </para>
-  <para>
-    The position values are truncated if they exceed the 8bit range (that
-    is -127 &lt;= delta &lt;= 127). While the value -128 does fit into a 
-    byte is not allowed.
-  </para>
-  <para>
-    The <mousebutton>buttons</mousebutton> are numbered left to right as 
-    0, 1, 2, 3.. and each button sets the relevant bit. So a user pressing 
-    the left and right button of a three button mouse will set bits 0 and 2.
-  </para>
-  <para>
-    All mice are required to support the <function>poll</function> 
-    operation. Indeed pretty much every user of a mouse device uses 
-    <function>poll</function> to wait for mouse events to occur.
-  </para>
-  <para>
-    Finally the mice support asynchronous I/O. This is a topic we have not 
-    yet covered but which I will explain after looking at a simple mouse 
-    driver.
-  </para>
- </chapter>
-
- <chapter id="driver">
-  <title>A simple mouse driver</title>
-  <para>
-    First we will need the set up functions for our mouse device. To keep 
-    this simple our imaginary mouse device has three I/O ports fixed at I/O 
-    address 0x300 and always lives on interrupt 5.  The ports will be the X 
-    position, the Y position and the buttons in that order.
-  </para>
-
-  <programlisting>
-#define OURMOUSE_BASE        0x300
-
-static struct miscdevice our_mouse = {
-        OURMOUSE_MINOR, "ourmouse", &amp;our_mouse_fops
-};
-
-__init ourmouse_init(void)
-{
-
-        if (request_region(OURMOUSE_BASE, 3, "ourmouse") < 0) {
-		printk(KERN_ERR "ourmouse: request_region failed.\n");
-                return -ENODEV;
-	}
-
-        if (misc_register(&amp;our_mouse) < 0) {
-		printk(KERN_ERR "ourmouse: cannot register misc device.\n");
-		release_region(OURMOUSE_BASE, 3);
-		return -EBUSY;
-	}
-
-        return 0;
-}
-  </programlisting>
-
-  <para>
-    The <structname>miscdevice</structname> is new here. Linux normally 
-    parcels devices out by major number, and each device has 256 units. 
-    For things like mice this is extremely wasteful so a device exists 
-    which is used to accumulate all the odd individual devices that 
-    computers tend to have.
-  </para>
-  <para>
-    Minor numbers in this space are allocated by a central source, although 
-    you can look in the kernel <filename>Documentation/devices.txt</filename>
-    file and pick a free one for development use. This kernel file also 
-    carries instructions for registering a device. This may change over time 
-    so it is a good idea to obtain a current copy of this file first.
-  </para>
-  <para>
-    Our code then is fairly simple. We reserve our I/O address space with
-    request_region, checking to make sure that it succeeded (i.e. the
-    space wasn't reserved by anyone else). 
-  </para>
-  <para>
-    Then we ask the misc driver to allocate our minor device number. We also
-    hand it our name (which is used in 
-    <filename class="directory">/proc/misc</filename>) and a set of file 
-    operations that are to be used. The file operations work exactly like the 
-    file operations you would register for a normal character device. The misc 
-    device itself is simply acting as a redirector for requests.
-    Since misc_register can fail, it is important to check for failure
-    and act accordingly (which in the case of a mouse driver is to abort,
-    since you can't use the mouse without a working device node).
-  </para>
-  <para>
-    Next, in order to be able to use and test our code we need to add some 
-    module code to support it. This too is fairly simple:
-  </para>
-  <programlisting>
-#ifdef MODULE
-
-int init_module(void)
-{
-        if(ourmouse_init()&lt;0)
-                return -ENODEV:
-        return 0;
-}
-
-void cleanup_module(void)
-{
-        misc_deregister(&amp;our_mouse);
-        free_region(OURMOUSE_BASE, 3);
-}
-
-
-#endif
-  </programlisting>
-
-  <para>
-    The module code provides the normal two functions. The 
-    <function>init_module</function> function is called when the module is 
-    loaded. In our case it simply calls the initialising function we wrote 
-    and returns an error if this fails. This ensures the module will only 
-    be loaded if it was successfully set up.
-  </para>
-  <para>
-    The <function>cleanup_module</function> function is called when the 
-    module is unloaded. We give the miscellaneous device entry back, and 
-    then free our I/O resources. If we didn't free the I/O resources then 
-    the next time the module loaded it would think someone else had its I/O 
-    space.
-  </para>
-  <para>
-    Once the <function>misc_deregister</function> has been called any 
-    attempts to open the mouse device will fail with the error  
-    <errorcode>ENODEV</errorcode> (<errorname>No such device</errorname>).
-  </para>
-  <para>
-    Next we need to fill in our file operations. A mouse doesn't need many 
-    of these. We need to provide open, release, read and poll. That makes 
-    for a nice simple structure:
-  </para>
-
-  <programlisting>
-struct file_operations our_mouse_fops = {
-        owner: THIS_MODULE,            /* Automatic usage management */
-        read:  read_mouse,             /* You can read a mouse */
-        write: write_mouse,            /* This won't do a lot */
-        poll:  poll_mouse,             /* Poll */
-        open:  open_mouse,             /* Called on open */
-        release: close_mouse,          /* Called on close */
-};
-  </programlisting>
-
-  <para>
-    There is nothing particularly special needed here. We provide functions 
-    for all the relevant or required operations and little else. There is 
-    nothing stopping us providing an ioctl function for this mouse. Indeed 
-    if you have a configurable mouse it may be very appropriate to provide 
-    configuration interfaces via ioctl calls.
-  </para>
-  <para>
-    The syntax we use is not standard C as such. GCC provides the ability
-    to initialise fields by name, and this generally makes the method table
-    much easier to read than counting through NULL pointers and remembering
-    the order by hand.
-  </para>
-  <para>
-    The owner field is used to manage the locking of module load an
-    unloading. It is obviously important that a module is not unloaded while
-    in use. When your device is opened the module specified by "owner" is 
-    locked. When it is finally released the module is unlocked.
-  </para>
-  <para>
-    The open and close routines need to manage enabling and disabling the 
-    interrupts for the mouse as well as stopping the mouse being unloaded
-    when it is no longer required. 
-  </para>
-
-  <programlisting>
-static int mouse_users = 0;                /* User count */
-static int mouse_dx = 0;                   /* Position changes */
-static int mouse_dy = 0;
-static int mouse_event = 0;                /* Mouse has moved */
-
-static int open_mouse(struct inode *inode, struct file *file)
-{
-        if(mouse_users++)
-                return 0;
-
-        if(request_irq(mouse_intr, OURMOUSE_IRQ, 0, "ourmouse", NULL))
-        {
-                mouse_users--;
-                return -EBUSY;
-        }
-        mouse_dx = 0;
-        mouse_dy = 0;
-        mouse_event = 0;
-        mouse_buttons = 0;
-	return 0;
-}
-  </programlisting>
-  <para>
-    The open function has to do a small amount of housework. We keep a count 
-    of the number of times the mouse is open. This is because we do not want 
-    to request the interrupt multiple times. If the mouse has at least one 
-    user then it is set up and we simply add to the user count and return
-    <returnvalue>0</returnvalue> for success.
-  </para>
-  <para>
-    We grab the interrupt and thus start mouse interrupts. If the interrupt 
-    has been borrowed by some other driver then <function>request_irq</function>
-    will fail and we will return an error. If we were capable of sharing an 
-    interrupt line we would specify <constant>SA_SHIRQ</constant> instead of 
-    <constant>zero</constant>. Provided that everyone claiming an interrupt 
-    sets this flag, they get to share the line. <hardware>PCI</hardware> can 
-    share interrupts, <hardware>ISA</hardware> normally however cannot. 
-  </para>
-  <para>
-    We do the housekeeping. We make the current mouse position the starting
-    point for accumulated changes and declare that nothing has happened
-    since the mouse driver was opened.
-  </para>
-  <para>
-    The release function needs to unwind all these:
-  </para>
-  <programlisting>
-static int close_mouse(struct inode *inode, struct file *file)
-{
-        if(--mouse_users)
-                return 0;
-        free_irq(OURMOUSE_IRQ, NULL);
-        return 0;
-}
-  </programlisting>
-  <para>
-    We count off a user and provided that there are still other users need 
-    take no further action. The last person closing the mouse causes us to 
-    free up the interrupt. This stops interrupts from the mouse from using 
-    our CPU time, and ensures that the mouse can now be unloaded.
-  </para>
-  <para>
-    We can fill in the write handler at this point as the write function for 
-    our mouse simply declines to allow writes:
-  </para>
-
-  <programlisting>
-static ssize_t write_mouse(struct file *file, const char *buffer, size_t
-                                count, loff_t *ppos)
-{
-        return -EINVAL;
-}
-  </programlisting>
-
-  <para>
-    This is pretty much self-explanatory. Whenever you write you get told 
-    it was an invalid function.
-  </para>
-  <para>
-    To make the poll and read functions work we have to consider how we 
-    handle the mouse interrupt. 
-  </para>
-
-  <programlisting>
-static struct wait_queue *mouse_wait;
-static spinlock_t mouse_lock = SPIN_LOCK_UNLOCKED;
-
-static void ourmouse_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-        char delta_x;
-        char delta_y;
-        unsigned char new_buttons;
-
-        delta_x = inb(OURMOUSE_BASE);
-        delta_y = inb(OURMOUSE_BASE+1);
-        new_buttons = inb(OURMOUSE_BASE+2);
-
-        if(delta_x || delta_y || new_buttons != mouse_buttons)
-        {
-                /* Something happened */
-
-                spin_lock(&amp;mouse_lock);
-                mouse_event = 1;
-                mouse_dx += delta_x;
-                mouse_dy += delta_y;
-                mouse_buttons = new_buttons;
-                spin_unlock(&amp;mouse_lock);
-                
-                wake_up_interruptible(&amp;mouse_wait);
-        }
-}
-  </programlisting>
-
-  <para>
-    The interrupt handler reads the mouse status. The next thing we do is 
-    to check whether something has changed. If the mouse was smart it would
-    only interrupt us if something had changed, but let's assume our mouse 
-    is stupid as most mice actually tend to be. 
-  </para>
-  <para>
-    If the mouse has changed we need to update the status variables. What we
-    don't want is the mouse functions reading these variables to read them
-    during a change. We add a spinlock that protects these variables while we
-    play with them.
-  </para>
-  <para>
-    If a change has occurred we also need to wake sleeping processes, so we 
-    add a wakeup call and a <structname>wait_queue</structname> to use when 
-    we wish to await a mouse event.
-  </para>
-  <para>
-    Now we have the wait queue we can implement the poll function for the 
-    mouse relatively easily:
-  </para>
-
-  <programlisting>
-static unsigned int mouse_poll(struct file *file, poll_table *wait)
-{
-        poll_wait(file, &amp;mouse_wait, wait);
-        if(mouse_event)
-                return POLLIN | POLLRDNORM;
-        return 0;
-}
-  </programlisting>
-
-  <para>
-    This is fairly standard poll code. First we add the wait queue to the 
-    list of queues we want to monitor for an event. Secondly we check if an 
-    event has occurred. We only have one kind of event - the 
-    <varname>mouse_event</varname> flag tells us that something happened. 
-    We know that this something can only be mouse data. We return the flags 
-    indicating input and normal reading will succeed.
-  </para>
-  <para>
-    You may be wondering what happens if the function returns saying 'no 
-    event yet'. In this case the wake up from the wait queue we added to 
-    the poll table will cause the function to be called again. Eventually 
-    we will be woken up and have an event ready. At this point the 
-    <function>poll</function> call will exit back to the user.
-  </para>
-  <para>
-    After the poll completes the user will want to read the data. We now 
-    need to think about how our <function>mouse_read</function> function 
-    will work:
-  </para>
-  <programlisting>
-static ssize_t mouse_read(struct file *file, char *buffer, 
-                size_t count, loff_t *pos)
-{
-        int dx, dy;
-        unsigned char button;
-        unsigned long flags;
-        int n;
-
-        if(count&lt;3)
-                return -EINVAL;
-
-        /*
-          *        Wait for an event
-         */
-
-        while(!mouse_event)
-        {
-                if(file-&gt;f_flags&amp;O_NDELAY)
-                        return -EAGAIN;
-                interruptible_sleep_on(&amp;mouse_wait);
-                if(signal_pending(current))
-                        return -ERESTARTSYS;
-        }
-  </programlisting>
-
-  <para>
-    We start by validating that the user is reading enough data. We could 
-    handle partial reads if we wanted but it isn't terribly useful and the 
-    mouse drivers don't bother to try.
-  </para>
-  <para>
-    Next we wait for an event to occur. The loop is fairly standard event
-    waiting in Linux. Having checked that the event has not yet occurred, we
-    then check if an event is pending and if not we need to sleep. 
-  </para>
-  <para>
-    A user process can set the <constant>O_NDELAY</constant> flag on a file 
-    to indicate that it wishes to be told immediately if no event is 
-    pending. We check this and give the appropriate error if so. 
-  </para>
-  <para>
-    Next we sleep until the mouse or a signal awakens us. A signal will 
-    awaken us as we have used <function>wakeup_interruptible</function>. 
-    This is important as it means a user can kill processes waiting for 
-    the mouse - clearly a desirable property. If we are interrupted we 
-    exit the call and the kernel will then process signals and maybe 
-    restart the call again - from the beginning.
-  </para>
-  <para>
-    This code contains a classic Linux bug. All will be revealed later in this
-    article as well as explanations for how to avoid it.
-  </para>
-  <programlisting>
-        /* Grab the event */
-
-        spinlock_irqsave(&amp;mouse_lock, flags);
-
-        dx = mouse_dx;
-        dy = mouse_dy;
-        button = mouse_buttons;
-
-        if(dx&lt;=-127)
-                dx=-127;
-        if(dx&gt;=127)
-                dx=127;
-        if(dy&lt;=-127)
-                dy=-127;
-        if(dy&gt;=127)
-                dy=127;
-
-        mouse_dx -= dx;
-        mouse_dy -= dy;
-        
-        if(mouse_dx == 0 &amp;&amp; mouse_dy == 0)
-                mouse_event = 0;
-
-        spin_unlock_irqrestore(&amp;mouse_lock, flags);
-  </programlisting>
-  <para>
-    This is the next stage. Having established that there is an event 
-    going, we capture it. To be sure that the event is not being updated 
-    as we capture it we also take the spinlock and thus prevent parallel 
-    updates. Note here we use <function>spinlock_irqsave</function>. We 
-    need to disable interrupts on the local processor otherwise bad things 
-    will happen.
-  </para>
-  <para>
-    What will occur is that we take the spinlock. While we hold the lock 
-    an interrupt will occur. At this point our interrupt handler will try 
-    and take the spinlock. It will sit in a loop waiting for the read 
-    routine to release the lock. However because we are sitting in a loop 
-    in the interrupt handler we will never release the lock. The machine 
-    hangs and the user gets upset.
-  </para>
-  <para>
-    By blocking the interrupt on this processor we ensure that the lock 
-    holder will always give the lock back without deadlocking.
-  </para>
-  <para>
-    There is a little cleverness in the reporting mechanism too. We can 
-    only report a move of 127 per read. We don't however want to lose 
-    information by throwing away further movement. Instead we keep 
-    returning as much information as possible. Each time we return a 
-    report we remove the amount from the pending movement in 
-    <varname>mouse_dx</varname> and <varname>mouse_dy</varname>. Eventually 
-    when these counts hit zero we clear the <varname>mouse_event</varname>
-    flag as there is nothing else left to report.
-  </para>
-
-  <programlisting>
-        if(put_user(button|0x80, buffer))
-                return -EFAULT;
-        if(put_user((char)dx, buffer+1))
-                return -EFAULT;
-        if(put_user((char)dy, buffer+2))
-                return -EFAULT;
-
-        for(n=3; n < count; n++)
-                if(put_user(0x00, buffer+n))
-                        return -EFAULT;
-
-        return count;
-}
-  </programlisting>
-
-  <para>
-    Finally we must put the results in the user supplied buffer. We cannot 
-    do this while holding the lock as a write to user memory may sleep. 
-    For example the user memory may be residing on disk at this instant. 
-    Thus we did our computation beforehand and now copy the data. Each 
-    <function>put_user call</function> is filling in one byte of the buffer. 
-    If it returns an error we inform the program that it passed us an 
-    invalid buffer and abort.
-  </para>
-  <para>
-    Having written the data we blank the rest of the buffer that was read 
-    and report the read as being successful.
-  </para>
- </chapter>
-
- <chapter id="debugging">
-  <title>Debugging the mouse driver</title>
-
-  <para>
-    We now have an almost perfectly usable mouse driver. If you were to 
-    actually try and use it however you would eventually find a couple of 
-    problems with it. A few programs will also not work with as it does not 
-    yet support asynchronous I/O.
-  </para>
-  <para>
-    First let us look at the bugs. The most obvious one isn't really a driver
-    bug but a failure to consider the consequences. Imagine you bumped the 
-    mouse hard by accident and sent it skittering across the desk. The mouse 
-    interrupt routine will add up all that movement and report it in steps of 
-    127 until it has reported all of it. Clearly there is a point beyond 
-    which mouse movement isn't worth reporting. We need to add this as a 
-    limit to the interrupt handler:
-  </para>
-
-  <programlisting>
-static void ourmouse_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-        char delta_x;
-        char delta_y;
-        unsigned char new_buttons;
-
-        delta_x = inb(OURMOUSE_BASE);
-        delta_y = inb(OURMOUSE_BASE+1);
-        new_buttons = inb(OURMOUSE_BASE+2);
-
-        if(delta_x || delta_y || new_buttons != mouse_buttons)
-        {
-                /* Something happened */
-
-                spin_lock(&amp;mouse_lock);
-                mouse_event = 1;
-                mouse_dx += delta_x;
-                mouse_dy += delta_y;
-
-                if(mouse_dx &lt; -4096)
-                        mouse_dx = -4096;
-                if(mouse_dx &gt; 4096)
-                        mouse_dx = 4096;
-
-                if(mouse_dy &lt; -4096)
-                        mouse_dy = -4096;
-                if(mouse_dy &gt; 4096)
-                        mouse_dy = 4096;
-
-                mouse_buttons = new_buttons;
-                spin_unlock(&amp;mouse_lock);
-                
-                wake_up_interruptible(&amp;mouse_wait);
-        }
-}
-  </programlisting>
-
-  <para>
-    By adding these checks we limit the range of accumulated movement to
-    something sensible. 
-  </para>
-  <para>
-    The second bug is a bit more subtle, and that is perhaps why this is 
-    such a common mistake. Remember, I said the waiting loop for the read 
-    handler had a bug in it. Think about what happens when we execute:
-  </para>
-
-  <programlisting>
-        while(!mouse_event)
-        {
-  </programlisting>
-
-  <para>
-    and an interrupt occurs at this point here. This causes a mouse movement
-    and wakes up the queue. 
-  </para>
-
-  <programlisting>
-                interruptible_sleep_on(&amp;mouse_wait);
-  </programlisting>
-
-  <para>
-    Now we sleep on the queue. We missed the wake up and the application 
-    will not see an event until the next mouse event occurs. This will 
-    lead to just the odd instance when a mouse button gets delayed. The 
-    consequences to the user will probably be almost undetectable with a 
-    mouse driver. With other drivers this bug could be a lot more severe.
-  </para>
-  <para>
-    There are two ways to solve this. The first is to disable interrupts 
-    during the testing and the sleep. This works because when a task sleeps 
-    it ceases to disable interrupts, and when it resumes it disables them 
-    again. Our code thus becomes:
-  </para>
-
-  <programlisting>
-        save_flags(flags);
-        cli();
-
-        while(!mouse_event)
-        {
-                if(file-&gt;f_flags&amp;O_NDELAY)
-                {
-                        restore_flags(flags);
-                        return -EAGAIN;
-                }
-                interruptible_sleep_on(&amp;mouse_wait);
-                if(signal_pending(current))
-                {
-                        restore_flags(flags);
-                        return -ERESTARTSYS;
-                }
-        }
-        restore_flags(flags);
-  </programlisting>
-
-  <para>
-    This is the sledgehammer approach. It works but it means we spend a 
-    lot more time turning interrupts on and off. It also affects 
-    interrupts globally and has bad properties on multiprocessor machines 
-    where turning interrupts off globally is not a simple operation, but 
-    instead involves kicking each processor, waiting for them to disable 
-    interrupts and reply.
-  </para>
-  <para>
-    The real problem is the race between the event testing and the sleeping. 
-    We can avoid that by using the scheduling functions more directly. 
-    Indeed this is the way they generally should be used for an interrupt.
-  </para>
-
-  <programlisting>
-        struct wait_queue wait = { current, NULL };
-
-        add_wait_queue(&amp;mouse_wait, &amp;wait);
-        set_current_state(TASK_INTERRUPTIBLE);
-        
-        while(!mouse_event)
-        {
-                if(file-&gt;f_flags&amp;O_NDELAY)
-                {
-                        remove_wait_queue(&amp;mouse_wait, &amp;wait);
-                        set_current_state(TASK_RUNNING);
-                        return -EWOULDBLOCK;
-                }
-                if(signal_pending(current))
-                {
-                        remove_wait_queue(&amp;mouse_wait, &amp;wait);
-                        current-&gt;state = TASK_RUNNING;
-                        return -ERESTARTSYS;
-                }
-                schedule();
-                set_current_state(TASK_INTERRUPTIBLE);
-        }
-        
-        remove_wait_wait(&amp;mouse_wait, &amp;wait);
-        set_current_state(TASK_RUNNING);
-  </programlisting>
-
-  <para>
-    At first sight this probably looks like deep magic. To understand how 
-    this works you need to understand how scheduling and events work on 
-    Linux. Having a good grasp of this is one of the keys to writing clean 
-    efficient device drivers.
-  </para>
-  <para>
-    <function>add_wait_queue</function> does what its name suggests. It adds 
-    an entry to the <varname>mouse_wait</varname> list. The entry in this 
-    case is the entry for our current process (<varname>current</varname>
-    is the current task pointer). 
-  </para>
-  <para>
-    So we start by adding an entry for ourself onto the 
-    <varname>mouse_wait</varname> list. This does not put us to sleep 
-    however. We are merely tagged onto the list. 
-  </para>
-  <para>
-    Next we set our status to <constant>TASK_INTERRUPTIBLE</constant>. Again 
-    this does not mean we are now asleep. This flag says what should happen 
-    next time the process sleeps. <constant>TASK_INTERRUPTIBLE</constant> says 
-    that the process should not be rescheduled. It will run from now until it 
-    sleeps and then will need to be woken up.
-  </para>
-  <para>
-    The <function>wakeup_interruptible</function> call in the interrupt 
-    handler can now be explained in more detail. This function is also very 
-    simple. It goes along the list of processes on the queue it is given and 
-    any that are marked as <constant>TASK_INTERRUPTIBLE</constant> it changes 
-    to <constant>TASK_RUNNING</constant> and tells the kernel that new 
-    processes are runnable.
-  </para>
-  <para>
-    Behind all the wrappers in the original code what is happening is this
-  </para>
-
-  <procedure>
-   <step>
-    <para>
-      We add ourself to the mouse wait queue
-    </para>
-   </step>
-   <step>
-    <para>
-      We mark ourself as sleeping
-    </para>
-   </step>
-   <step>
-    <para>
-      We ask the kernel to schedule tasks again
-    </para>
-   </step>
-   <step>
-    <para>
-      The kernel sees we are asleep and schedules someone else.
-    </para>
-   </step>
-   <step>
-    <para>
-      The mouse interrupt sets our state to <constant>TASK_RUNNING</constant> 
-      and makes a note that the kernel should reschedule tasks
-    </para>
-   </step>
-   <step>
-    <para>
-      The kernel sees we are running again and continues our execution
-    </para>
-   </step>
-  </procedure>
-  <para>
-    This is why the apparent magic works. Because we mark ourself as
-    <constant>TASK_INTERRUPTIBLE</constant> and as we add ourselves 
-    to the queue before we check if there are events pending, the race 
-    condition is removed.
-  </para>
-  <para>
-    Now if an interrupt occurs after we check the queue status and before 
-    we call the <function>schedule</function> function in order to sleep, 
-    things work out. Instead of missing an event, we are set back to 
-    <constant>TASK_RUNNING</constant> by the mouse interrupt. We still call 
-    <function>schedule</function> but it will continue running our task. 
-    We go back around the loop and this time there may be an event.
-  </para>
-  <para>
-    There will not always be an event. Thus we set ourselves back to
-    <constant>TASK_INTERRUPTIBLE</constant> before resuming the loop. 
-    Another process doing a read may already have cleared the event flag, 
-    and if so we will need to go back to sleep again. Eventually we will 
-    get our event and escape.
-  </para>
-  <para>
-    Finally when we exit the loop we remove ourselves from the 
-    <varname>mouse_wait</varname> queue as we are no longer interested
-    in mouse events, and we set ourself back to 
-    <constant>TASK_RUNNABLE</constant> as we do not wish to go to sleep 
-    again just yet.
-  </para>
-  <note>
-   <title>Note</title> 
-   <para>
-     This isn't an easy topic. Don't be afraid to reread the description a 
-     few times and also look at other device drivers to see how it works. 
-     Finally if you can't grasp it just yet, you can use the code as 
-     boilerplate to write other drivers and trust me instead.
-   </para>
-  </note>
- </chapter>
-
- <chapter id="asyncio">
-  <title>Asynchronous I/O</title>
-  <para>
-    This leaves the missing feature - Asynchronous I/O. Normally UNIX 
-    programs use the <function>poll</function> call (or its variant form 
-    <function>select</function>) to wait for an event to occur on one of 
-    multiple input or output devices. This model works well for most tasks 
-    but because <function>poll</function> and <function>select</function> 
-    wait for an event isn't suitable for tasks that are also continually 
-    doing computation work. Such programs really want the kernel to kick 
-    them when something happens rather than watch for events.
-  </para>
-  <para>
-    Poll is akin to having a row of lights in front of you. You can see at a
-    glance which ones if any are lit. You cannot however get anything useful
-    done while watching them. Asynchronous I/O uses signals which work more 
-    like a door bell. Instead of you watching, it tells you that something 
-    is up.
-  </para>
-  <para>
-    Asynchronous I/O sends the signal SIGIO to a user process when the I/O 
-    events occur. In this case that means when people move the mouse. The 
-    SIGIO signal causes the user process to jump to its signal handler and 
-    execute code in that handler before returning to whatever was going on 
-    previously. It is the application equivalent of an interrupt handler.
-  </para>
-  <para>
-    Most of the code needed for this operation is common to all its users. 
-    The kernel provides a simple set of functions for managing asynchronous 
-    I/O.
-  </para>
-  <para>
-    Our first job is to allow users to set asynchronous I/O on file handles. 
-    To do that we need to add a new function to the file operations table for 
-    our mouse:
-  </para>
-
-  <programlisting>
-struct file_operations our_mouse_fops = {
-        owner: THIS_MODULE
-        read:  read_mouse,      /* You can read a mouse */
-        write: write_mouse,     /* This won't do a lot */
-        poll:  poll_mouse,      /* Poll */
-        open:  open_mouse,      /* Called on open */
-        release: close_mouse,   /* Called on close */
-        fasync: fasync_mouse,   /* Asynchronous I/O */
-};
-  </programlisting>
-
-  <para>
-    Once we have installed this entry the kernel knows we support 
-    asynchronous I/O and will allow all the relevant operations on the 
-    device. Whenever a user adds or removes asynchronous I/O notification 
-    on a file handle it calls our <function>fasync_mouse</function> routine 
-    we just added. This routine uses the helper functions to keep the queue 
-    of handles up to date:
-  </para>
-
-  <programlisting>
-static struct fasync_struct *mouse_fasync = NULL;
-
-static int fasync_mouse(int fd, struct file *filp, int on)
-{
-         int retval = fasync_helper(fd, filp, on, &amp;mouse_fasync);
-
-         if (retval &lt; 0)
-                 return retval;
-        return 0;
-}
-  </programlisting>
-
-  <para>
-    The fasync helper adds and deletes entries by managing the supplied 
-    list. We also need to remove entries from this list when the file is 
-    closed. This requires we add one line to our close function:
-  </para>
-
-  <programlisting>
-static int close_mouse(struct inode *inode, struct file *file)
-{
-        fasync_mouse(-1, file, 0)
-        if(--mouse_users)
-                return 0;
-        free_irq(OURMOUSE_IRQ, NULL);
-        return 0;
-}
-  </programlisting>
-
-  <para>
-    When we close the file we now call our own fasync handler as if the 
-    user had requested that this file cease to be used for asynchronous 
-    I/O. This rather neatly cleans up any loose ends. We certainly don't 
-    wait to deliver a signal for a file that no longer exists.
-  </para>
-  <para>
-    At this point the mouse driver supports all the asynchronous I/O 
-    operations, and applications using them will not error. They won't 
-    however work yet. We need to actually send the signals. Again the 
-    kernel provides a function for handling this.
-  </para>
-  <para>
-    We update our interrupt handler a little:
-  </para>
-
-  <programlisting>
-static void ourmouse_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-        char delta_x;
-        char delta_y;
-        unsigned char new_buttons;
-
-        delta_x = inb(OURMOUSE_BASE);
-        delta_y = inb(OURMOUSE_BASE+1);
-        new_buttons = inb(OURMOUSE_BASE+2);
-
-        if(delta_x || delta_y || new_buttons != mouse_buttons)
-        {
-                /* Something happened */
-
-                spin_lock(&amp;mouse_lock);
-                mouse_event = 1;
-                mouse_dx += delta_x;
-                mouse_dy += delta_y;
-
-                if(mouse_dx &lt; -4096)
-                        mouse_dx = -4096;
-                if(mouse_dx &gt; 4096)
-                        mouse_dx = 4096;
-
-                if(mouse_dy &lt; -4096)
-                        mouse_dy = -4096;
-                if(mouse_dy &gt; 4096)
-                        mouse_dy = 4096;
-
-                mouse_buttons = new_buttons;
-                spin_unlock(&amp;mouse_lock);
-
-                /* Now we do asynchronous I/O */
-                kill_fasync(&amp;mouse_fasync, SIGIO); 
-                
-                wake_up_interruptible(&amp;mouse_wait);
-        }
-}
-  </programlisting>
-
-  <para>
-    The new code simply calls the <function>kill_fasync</function> routine
-    provided by the kernel if the queue is non-empty. This sends the 
-    required signal (SIGIO in this case) to the process each file handle 
-    says should be informed about the exciting new mouse movement that 
-    just happened.
-  </para>
-  <para>
-    With this in place and the bugs in the original version fixed, you now 
-    have a fully functional mouse driver using the bus mouse protocol. It 
-    will work with the <application>X window system</application>, will work 
-    with <application>GPM</application> and should work with every other 
-    application you need. <application>Doom</application> is of course the 
-    ideal way to test your new mouse driver is functioning properly. Be sure 
-    to test it thoroughly.
-  </para>
- </chapter>
-</book>
-
diff -Nru a/Documentation/DocBook/mtdnand.tmpl b/Documentation/DocBook/mtdnand.tmpl
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/DocBook/mtdnand.tmpl	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1318 @@
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN"[]>
+
+<book id="MTD-NAND-Guide">
+ <bookinfo>
+  <title>MTD NAND Driver Programming Interface</title>
+  
+  <authorgroup>
+   <author>
+    <firstname>Thomas</firstname>
+    <surname>Gleixner</surname>
+    <affiliation>
+     <address>
+      <email>tglx@linutronix.de</email>
+     </address>
+    </affiliation>
+   </author>
+  </authorgroup>
+
+  <copyright>
+   <year>2004</year>
+   <holder>Thomas Gleixner</holder>
+  </copyright>
+
+  <legalnotice>
+   <para>
+     This documentation 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.
+   </para>
+      
+   <para>
+     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.
+   </para>
+      
+   <para>
+     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
+   </para>
+      
+   <para>
+     For more details see the file COPYING in the source
+     distribution of Linux.
+   </para>
+  </legalnotice>
+ </bookinfo>
+
+<toc></toc>
+
+  <chapter id="intro">
+      <title>Introduction</title>
+  <para>
+  	The generic NAND driver supports almost all NAND and AG-AND based
+	chips and connects them to the Memory Technology Devices (MTD)
+	subsystem of the Linux Kernel.
+  </para>
+  <para>
+  	This documentation is provided for developers who want to implement
+	board drivers or filesystem drivers suitable for NAND devices.
+  </para>
+  </chapter>
+  
+  <chapter id="bugs">
+     <title>Known Bugs And Assumptions</title>
+  <para>
+	None.	
+  </para>
+  </chapter>
+
+  <chapter id="dochints">
+     <title>Documentation hints</title>
+     <para>
+     The function and structure docs are autogenerated. Each function and 
+     struct member has a short description which is marked with an [XXX] identifier.
+     The following chapters explain the meaning of those identifiers.
+     </para>
+     <sect1>   
+	<title>Function identifiers [XXX]</title>
+     	<para>
+	The functions are marked with [XXX] identifiers in the short
+	comment. The identifiers explain the usage and scope of the
+	functions. Following identifiers are used:
+     	</para>
+	<itemizedlist>
+		<listitem><para>
+	  	[MTD Interface]</para><para>
+		These functions provide the interface to the MTD kernel API. 
+		They are not replacable and provide functionality
+		which is complete hardware independent.
+		</para></listitem>
+		<listitem><para>
+	  	[NAND Interface]</para><para>
+		These functions are exported and provide the interface to the NAND kernel API. 
+		</para></listitem>
+		<listitem><para>
+	  	[GENERIC]</para><para>
+		Generic functions are not replacable and provide functionality
+		which is complete hardware independent.
+		</para></listitem>
+		<listitem><para>
+	  	[DEFAULT]</para><para>
+		Default functions provide hardware related functionality which is suitable
+		for most of the implementations. These functions can be replaced by the
+		board driver if neccecary. Those functions are called via pointers in the
+		NAND chip description structure. The board driver can set the functions which
+		should be replaced by board dependend functions before calling nand_scan().
+		If the function pointer is NULL on entry to nand_scan() then the pointer
+		is set to the default function which is suitable for the detected chip type.
+		</para></listitem>
+	</itemizedlist>
+     </sect1>
+     <sect1>   
+	<title>Struct member identifiers [XXX]</title>
+     	<para>
+	The struct members are marked with [XXX] identifiers in the 
+	comment. The identifiers explain the usage and scope of the
+	members. Following identifiers are used:
+     	</para>
+	<itemizedlist>
+		<listitem><para>
+	  	[INTERN]</para><para>
+		These members are for NAND driver internal use only and must not be
+		modified. Most of these values are calculated from the chip geometry
+		information which is evaluated during nand_scan().
+		</para></listitem>
+		<listitem><para>
+	  	[REPLACEABLE]</para><para>
+		Replaceable members hold hardware related functions which can be 
+		provided by the board driver. The board driver can set the functions which
+		should be replaced by board dependend functions before calling nand_scan().
+		If the function pointer is NULL on entry to nand_scan() then the pointer
+		is set to the default function which is suitable for the detected chip type.
+		</para></listitem>
+		<listitem><para>
+	  	[BOARDSPECIFIC]</para><para>
+		Board specific members hold hardware related information which must
+		be provided by the board driver. The board driver must set the function
+		pointers and datafields before calling nand_scan().
+		</para></listitem>
+		<listitem><para>
+	  	[OPTIONAL]</para><para>
+		Optional members can hold information relevant for the board driver. The
+		generic NAND driver code does not use this information.
+		</para></listitem>
+	</itemizedlist>
+     </sect1>
+  </chapter>   
+
+  <chapter id="basicboarddriver">
+     	<title>Basic board driver</title>
+	<para>
+		For most boards it will be sufficient to provide just the
+		basic functions and fill out some really board dependend
+		members in the nand chip description structure.
+		See drivers/mtd/nand/skeleton for reference.
+	</para>
+	<sect1>
+		<title>Basic defines</title>
+		<para>
+			At least you have to provide a mtd structure and
+			a storage for the ioremap'ed chip address.
+			You can allocate the mtd structure using kmalloc
+			or you can allocate it statically.
+			In case of static allocation you have to allocate
+			a nand_chip structure too.
+		</para>
+		<para>
+			Kmalloc based example
+		</para>
+		<programlisting>
+static struct mtd_info *board_mtd;
+static unsigned long baseaddr;
+		</programlisting>
+		<para>
+			Static example
+		</para>
+		<programlisting>
+static struct mtd_info board_mtd;
+static struct nand_chip board_chip;
+static unsigned long baseaddr;
+		</programlisting>
+	</sect1>
+	<sect1>
+		<title>Partition defines</title>
+		<para>
+			If you want to divide your device into parititions, then
+			enable the configuration switch CONFIG_MTD_PARITIONS and define
+			a paritioning scheme suitable to your board.
+		</para>
+		<programlisting>
+#define NUM_PARTITIONS 2
+static struct mtd_partition partition_info[] = {
+	{ .name = "Flash partition 1",
+	  .offset =  0,
+	  .size =    8 * 1024 * 1024 },
+	{ .name = "Flash partition 2",
+	  .offset =  MTDPART_OFS_NEXT,
+	  .size =    MTDPART_SIZ_FULL },
+};
+		</programlisting>
+	</sect1>
+	<sect1>
+		<title>Hardware control function</title>
+		<para>
+			The hardware control function provides access to the 
+			control pins of the NAND chip(s). 
+			The access can be done by GPIO pins or by address lines.
+			If you use address lines, make sure that the timing
+			requirements are met.
+		</para>
+		<para>
+			<emphasis>GPIO based example</emphasis>
+		</para>
+		<programlisting>
+static void board_hwcontrol(struct mtd_info *mtd, int cmd)
+{
+	switch(cmd){
+		case NAND_CTL_SETCLE: /* Set CLE pin high */ break;
+		case NAND_CTL_CLRCLE: /* Set CLE pin low */ break;
+		case NAND_CTL_SETALE: /* Set ALE pin high */ break;
+		case NAND_CTL_CLRALE: /* Set ALE pin low */ break;
+		case NAND_CTL_SETNCE: /* Set nCE pin low */ break;
+		case NAND_CTL_CLRNCE: /* Set nCE pin high */ break;
+	}
+}
+		</programlisting>
+		<para>
+			<emphasis>Address lines based example.</emphasis> It's assumed that the
+			nCE pin is driven by a chip select decoder.
+		</para>
+		<programlisting>
+static void board_hwcontrol(struct mtd_info *mtd, int cmd)
+{
+	struct nand_chip *this = (struct nand_chip *) mtd->priv;
+	switch(cmd){
+		case NAND_CTL_SETCLE: this->IO_ADDR_W |= CLE_ADRR_BIT;  break;
+		case NAND_CTL_CLRCLE: this->IO_ADDR_W &= ~CLE_ADRR_BIT; break;
+		case NAND_CTL_SETALE: this->IO_ADDR_W |= ALE_ADRR_BIT;  break;
+		case NAND_CTL_CLRALE: this->IO_ADDR_W &= ~ALE_ADRR_BIT; break;
+	}
+}
+		</programlisting>
+	</sect1>
+	<sect1>
+		<title>Device ready function</title>
+		<para>
+			If the hardware interface has the ready busy pin of the NAND chip connected to a
+			GPIO or other accesible I/O pin, this function is used to read back the state of the
+			pin. The function has no arguments and should return 0, if the device is busy (R/B pin 
+			is low) and 1, if the device is ready (R/B pin is high).
+			If the hardware interface does not give access to the ready busy pin, then
+			the function must not be defined and the function pointer this->dev_ready is set to NULL.		
+		</para>
+	</sect1>
+	<sect1>
+		<title>Init function</title>
+		<para>
+			The init function allocates memory and sets up all the board
+			specific parameters and function pointers. When everything
+			is set up nand_scan() is called. This function tries to
+			detect and identify then chip. If a chip is found all the
+			internal data fields are initialized accordingly.
+			The structure(s) have to be zeroed out first and then filled with the neccecary 
+			information about the device.
+		</para>
+		<programlisting>
+int __init board_init (void)
+{
+	struct nand_chip *this;
+	int err = 0;
+
+	/* Allocate memory for MTD device structure and private data */
+	board_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), GFP_KERNEL);
+	if (!board_mtd) {
+		printk ("Unable to allocate NAND MTD device structure.\n");
+		err = -ENOMEM;
+		goto out;
+	}
+
+	/* Initialize structures */
+	memset ((char *) board_mtd, 0, sizeof(struct mtd_info) + sizeof(struct nand_chip));
+
+	/* map physical adress */
+	baseaddr = (unsigned long)ioremap(CHIP_PHYSICAL_ADDRESS, 1024);
+	if(!baseaddr){
+		printk("Ioremap to access NAND chip failed\n");
+		err = -EIO;
+		goto out_mtd;
+	}
+
+	/* Get pointer to private data */
+	this = (struct nand_chip *) ();
+	/* Link the private data with the MTD structure */
+	board_mtd->priv = this;
+
+	/* Set address of NAND IO lines */
+	this->IO_ADDR_R = baseaddr;
+	this->IO_ADDR_W = baseaddr;
+	/* Reference hardware control function */
+	this->hwcontrol = board_hwcontrol;
+	/* Set command delay time, see datasheet for correct value */
+	this->chip_delay = CHIP_DEPENDEND_COMMAND_DELAY;
+	/* Assign the device ready function, if available */
+	this->dev_ready = board_dev_ready;
+	this->eccmode = NAND_ECC_SOFT;
+
+	/* Scan to find existance of the device */
+	if (nand_scan (board_mtd, 1)) {
+		err = -ENXIO;
+		goto out_ior;
+	}
+	
+	add_mtd_partitions(board_mtd, partition_info, NUM_PARTITIONS);
+	goto out;
+
+out_ior:
+	iounmap((void *)baseaddr);
+out_mtd:
+	kfree (board_mtd);
+out:
+	return err;
+}
+module_init(board_init);
+		</programlisting>
+	</sect1>
+	<sect1>
+		<title>Exit function</title>
+		<para>
+			The exit function is only neccecary if the driver is
+			compiled as a module. It releases all resources which
+			are held by the chip driver and unregisters the partitions
+			in the MTD layer.
+		</para>
+		<programlisting>
+#ifdef MODULE
+static void __exit board_cleanup (void)
+{
+	/* Release resources, unregister device */
+	nand_release (board_mtd);
+
+	/* unmap physical adress */
+	iounmap((void *)baseaddr);
+	
+	/* Free the MTD device structure */
+	kfree (board_mtd);
+}
+module_exit(board_cleanup);
+#endif
+		</programlisting>
+	</sect1>
+  </chapter>
+
+  <chapter id="boarddriversadvanced">
+     	<title>Advanced board driver functions</title>
+	<para>
+		This chapter describes the advanced functionality of the NAND
+		driver. For a list of functions which can be overridden by the board
+		driver see the documentation of the nand_chip structure.
+	</para>
+	<sect1>
+		<title>Multiple chip control</title>
+		<para>
+			The nand driver can control chip arrays. Therefor the
+			board driver must provide an own select_chip function. This
+			function must (de)select the requested chip.
+			The function pointer in the nand_chip structure must
+			be set before calling nand_scan(). The maxchip parameter
+			of nand_scan() defines the maximum number of chips to
+			scan for. Make sure that the select_chip function can
+			handle the requested number of chips.
+		</para>
+		<para>
+			The nand driver concatenates the chips to one virtual
+			chip and provides this virtual chip to the MTD layer.
+		</para>
+		<para>
+			<emphasis>Note: The driver can only handle linear chip arrays
+			of equally sized chips. There is no support for
+			parallel arrays which extend the buswidth.</emphasis>
+		</para>
+		<para>
+			<emphasis>GPIO based example</emphasis>
+		</para>
+		<programlisting>
+static void board_select_chip (struct mtd_info *mtd, int chip)
+{
+	/* Deselect all chips, set all nCE pins high */
+	GPIO(BOARD_NAND_NCE) |= 0xff;	
+	if (chip >= 0)
+		GPIO(BOARD_NAND_NCE) &= ~ (1 << chip);	
+}
+		</programlisting>
+		<para>
+			<emphasis>Address lines based example.</emphasis>
+			Its assumed that the nCE pins are connected to an
+			address decoder.
+		</para>
+		<programlisting>
+static void board_select_chip (struct mtd_info *mtd, int chip)
+{
+	struct nand_chip *this = (struct nand_chip *) mtd->priv;
+	
+	/* Deselect all chips */
+	this->IO_ADDR_R &= ~BOARD_NAND_ADDR_MASK;
+	this->IO_ADDR_W &= ~BOARD_NAND_ADDR_MASK;
+	switch (chip) {
+	case 0:
+		this->IO_ADDR_R |= BOARD_NAND_ADDR_CHIP0;
+		this->IO_ADDR_W |= BOARD_NAND_ADDR_CHIP0;
+		break;
+	....	
+	case n:
+		this->IO_ADDR_R |= BOARD_NAND_ADDR_CHIPn;
+		this->IO_ADDR_W |= BOARD_NAND_ADDR_CHIPn;
+		break;
+	}	
+}
+		</programlisting>
+	</sect1>
+	<sect1>
+		<title>Hardware ECC support</title>
+		<sect2>
+			<title>Functions and constants</title>
+			<para>
+				The nand driver supports three different types of
+				hardware ECC.
+				<itemizedlist>
+				<listitem><para>NAND_ECC_HW3_256</para><para>
+				Hardware ECC generator providing 3 bytes ECC per
+				256 byte.
+				</para>	</listitem>
+				<listitem><para>NAND_ECC_HW3_512</para><para>
+				Hardware ECC generator providing 3 bytes ECC per
+				512 byte.
+				</para>	</listitem>
+				<listitem><para>NAND_ECC_HW6_512</para><para>
+				Hardware ECC generator providing 6 bytes ECC per
+				512 byte.
+				</para>	</listitem>
+				<listitem><para>NAND_ECC_HW8_512</para><para>
+				Hardware ECC generator providing 6 bytes ECC per
+				512 byte.
+				</para>	</listitem>
+				</itemizedlist>
+				If your hardware generator has a different functionality
+				add it at the appropriate place in nand_base.c
+			</para>
+			<para>
+				The board driver must provide following functions:
+				<itemizedlist>
+				<listitem><para>enable_hwecc</para><para>
+				This function is called before reading / writing to
+				the chip. Reset or initialize the hardware generator
+				in this function. The function is called with an
+				argument which let you distinguish between read 
+				and write operations.
+				</para>	</listitem>
+				<listitem><para>calculate_ecc</para><para>
+				This function is called after read / write from / to
+				the chip. Transfer the ECC from the hardware to
+				the buffer. If the option NAND_HWECC_SYNDROME is set
+				then the function is only called on write. See below.
+				</para>	</listitem>
+				<listitem><para>correct_data</para><para>
+				In case of an ECC error this function is called for
+				error detection and correction. Return 1 respectively 2
+				in case the error can be corrected. If the error is
+				not correctable return -1. If your hardware generator
+				matches the default algorithm of the nand_ecc software
+				generator then use the correction function provided
+				by nand_ecc instead of implementing duplicated code.
+				</para>	</listitem>
+				</itemizedlist>
+			</para>
+		</sect2>
+		<sect2>
+		<title>Hardware ECC with syndrome calculation</title>
+			<para>
+				Many hardware ECC implementations provide Reed-Solomon
+				codes and calculate an error syndrome on read. The syndrome
+				must be converted to a standard Reed-Solomon syndrome
+				before calling the error correction code in the generic
+				Reed-Solomon library.
+			</para>
+			<para>
+				The ECC bytes must be placed immidiately after the data
+				bytes in order to make the syndrome generator work. This
+				is contrary to the usual layout used by software ECC. The
+				seperation of data and out of band area is not longer
+				possible. The nand driver code handles this layout and
+				the remaining free bytes in the oob area are managed by 
+				the autoplacement code. Provide a matching oob-layout
+				in this case. See rts_from4.c and diskonchip.c for 
+				implementation reference. In those cases we must also
+				use bad block tables on FLASH, because the ECC layout is
+				interferring with the bad block marker positions.
+				See bad block table support for details.
+			</para>
+		</sect2>
+	</sect1>
+	<sect1>
+		<title>Bad block table support</title>
+		<para>
+			Most NAND chips mark the bad blocks at a defined
+			position in the spare area. Those blocks must 
+			not be erased under any circumstances as the bad 
+			block information would be lost.
+			It is possible to check the bad block mark each
+			time when the blocks are accessed by reading the
+			spare area of the first page in the block. This
+			is time consuming so a bad block table is used.
+		</para>
+		<para>
+			The nand driver supports various types of bad block
+			tables.
+			<itemizedlist>
+			<listitem><para>Per device</para><para>
+			The bad block table contains all bad block information
+			of the device which can consist of multiple chips.
+			</para>	</listitem>
+			<listitem><para>Per chip</para><para>
+			A bad block table is used per chip and contains the
+			bad block information for this particular chip.
+			</para>	</listitem>
+			<listitem><para>Fixed offset</para><para>
+			The bad block table is located at a fixed offset
+			in the chip (device). This applies to various
+			DiskOnChip devices.
+			</para>	</listitem>
+			<listitem><para>Automatic placed</para><para>
+			The bad block table is automatically placed and
+			detected either at the end or at the beginning
+			of a chip (device)
+			</para>	</listitem>
+			<listitem><para>Mirrored tables</para><para>
+			The bad block table is mirrored on the chip (device) to
+			allow updates of the bad block table without data loss.
+			</para>	</listitem>
+			</itemizedlist>
+		</para>
+		<para>	
+			nand_scan() calls the function nand_default_bbt(). 
+			nand_default_bbt() selects appropriate default
+			bad block table desriptors depending on the chip information
+			which was retrieved by nand_scan().
+		</para>
+		<para>
+			The standard policy is scanning the device for bad 
+			blocks and build a ram based bad block table which
+			allows faster access than always checking the
+			bad block information on the flash chip itself.
+		</para>
+		<sect2>
+			<title>Flash based tables</title>
+			<para>
+				It may be desired or neccecary to keep a bad block table in FLASH. 
+				For AG-AND chips this is mandatory, as they have no factory marked
+				bad blocks. They have factory marked good blocks. The marker pattern
+				is erased when the block is erased to be reused. So in case of
+				powerloss before writing the pattern back to the chip this block 
+				would be lost and added to the bad blocks. Therefor we scan the 
+				chip(s) when we detect them the first time for good blocks and 
+				store this information in a bad block table before erasing any 
+				of the blocks.
+			</para>
+			<para>
+				The blocks in which the tables are stored are procteted against
+				accidental access by marking them bad in the memory bad block
+				table. The bad block table managment functions are allowed
+				to circumvernt this protection.
+			</para>
+			<para>
+				The simplest way to activate the FLASH based bad block table support 
+				is to set the option NAND_USE_FLASH_BBT in the option field of
+				the nand chip structure before calling nand_scan(). For AG-AND
+				chips is this done by default.
+				This activates the default FLASH based bad block table functionality 
+				of the NAND driver. The default bad block table options are
+				<itemizedlist>
+				<listitem><para>Store bad block table per chip</para></listitem>
+				<listitem><para>Use 2 bits per block</para></listitem>
+				<listitem><para>Automatic placement at the end of the chip</para></listitem>
+				<listitem><para>Use mirrored tables with version numbers</para></listitem>
+				<listitem><para>Reserve 4 blocks at the end of the chip</para></listitem>
+				</itemizedlist>
+			</para>
+		</sect2>
+		<sect2>
+			<title>User defined tables</title>
+			<para>
+				User defined tables are created by filling out a 
+				nand_bbt_descr structure and storing the pointer in the
+				nand_chip structure member bbt_td before calling nand_scan(). 
+				If a mirror table is neccecary a second structure must be
+				created and a pointer to this structure must be stored
+				in bbt_md inside the nand_chip structure. If the bbt_md 
+				member is set to NULL then only the main table is used
+				and no scan for the mirrored table is performed.
+			</para>
+			<para>
+				The most important field in the nand_bbt_descr structure
+				is the options field. The options define most of the 
+				table properties. Use the predefined constants from
+				nand.h to define the options.
+				<itemizedlist>
+				<listitem><para>Number of bits per block</para>
+				<para>The supported number of bits is 1, 2, 4, 8.</para></listitem>
+				<listitem><para>Table per chip</para>
+				<para>Setting the constant NAND_BBT_PERCHIP selects that
+				a bad block table is managed for each chip in a chip array.
+				If this option is not set then a per device bad block table
+				is used.</para></listitem>
+				<listitem><para>Table location is absolute</para>
+				<para>Use the option constant NAND_BBT_ABSPAGE and
+				define the absolute page number where the bad block
+				table starts in the field pages. If you have selected bad block
+				tables per chip and you have a multi chip array then the start page
+				must be given for each chip in the chip array. Note: there is no scan
+				for a table ident pattern performed, so the fields 
+				pattern, veroffs, offs, len can be left uninitialized</para></listitem>
+				<listitem><para>Table location is automatically detected</para>
+				<para>The table can either be located in the first or the last good
+				blocks of the chip (device). Set NAND_BBT_LASTBLOCK to place
+				the bad block table at the end of the chip (device). The
+				bad block tables are marked and identified by a pattern which
+				is stored in the spare area of the first page in the block which
+				holds the bad block table. Store a pointer to the pattern  
+				in the pattern field. Further the length of the pattern has to be 
+				stored in len and the offset in the spare area must be given
+				in the offs member of the nand_bbt_descr stucture. For mirrored
+				bad block tables different patterns are mandatory.</para></listitem>
+				<listitem><para>Table creation</para>
+				<para>Set the option NAND_BBT_CREATE to enable the table creation
+				if no table can be found during the scan. Usually this is done only 
+				once if a new chip is found. </para></listitem>
+				<listitem><para>Table write support</para>
+				<para>Set the option NAND_BBT_WRITE to enable the table write support.
+				This allows the update of the bad block table(s) in case a block has
+				to be marked bad due to wear. The MTD interface function block_markbad
+				is calling the update function of the bad block table. If the write
+				support is enabled then the table is updated on FLASH.</para>
+				<para>
+				Note: Write support should only be enabled for mirrored tables with
+				version control.
+				</para></listitem>
+				<listitem><para>Table version control</para>
+				<para>Set the option NAND_BBT_VERSION to enable the table version control.
+				It's highly recommended to enable this for mirrored tables with write
+				support. It makes sure that the risk of loosing the bad block
+				table information is reduced to the loss of the information about the
+				one worn out block which should be marked bad. The version is stored in
+				4 consecutive bytes in the spare area of the device. The position of
+				the version number is defined by the member veroffs in the bad block table
+				descriptor.</para></listitem>
+				<listitem><para>Save block contents on write</para>
+				<para>
+				In case that the block which holds the bad block table does contain
+				other useful information, set the option NAND_BBT_SAVECONTENT. When
+				the bad block table is written then the whole block is read the bad
+				block table is updated and the block is erased and everything is 
+				written back. If this option is not set only the bad block table
+				is written and everything else in the block is ignored and erased.
+				</para></listitem>
+				<listitem><para>Number of reserved blocks</para>
+				<para>
+				For automatic placement some blocks must be reserved for
+				bad block table storage. The number of reserved blocks is defined 
+				in the maxblocks member of the babd block table description structure.
+				Reserving 4 blocks for mirrored tables should be a reasonable number. 
+				This also limits the number of blocks which are scanned for the bad
+				block table ident pattern.
+				</para></listitem>
+				</itemizedlist>
+			</para>
+		</sect2>
+	</sect1>
+	<sect1>
+		<title>Spare area (auto)placement</title>
+		<para>
+			The nand driver implements different possibilities for
+			placement of filesystem data in the spare area, 
+			<itemizedlist>
+			<listitem><para>Placement defined by fs driver</para></listitem>
+			<listitem><para>Automatic placement</para></listitem>
+			</itemizedlist>
+			The default placement function is automatic placement. The
+			nand driver has built in default placement schemes for the
+			various chiptypes. If due to hardware ECC functionality the
+			default placement does not fit then the board driver can
+			provide a own placement scheme.
+		</para>
+		<para>
+			File system drivers can provide a own placement scheme which
+			is used instead of the default placement scheme.
+		</para>
+		<para>
+			Placement schemes are defined by a nand_oobinfo structure
+	     		<programlisting>
+struct nand_oobinfo {
+	int	useecc;
+	int	eccbytes;
+	int	eccpos[24];
+	int	oobfree[8][2];
+};
+	     		</programlisting>
+			<itemizedlist>
+			<listitem><para>useecc</para><para>
+				The useecc member controls the ecc and placement function. The header
+				file include/mtd/mtd-abi.h contains constants to select ecc and
+				placement. MTD_NANDECC_OFF switches off the ecc complete. This is
+				not recommended and available for testing and diagnosis only.
+				MTD_NANDECC_PLACE selects caller defined placement, MTD_NANDECC_AUTOPLACE
+				selects automatic placement.
+			</para></listitem>
+			<listitem><para>eccbytes</para><para>
+				The eccbytes member defines the number of ecc bytes per page.
+			</para></listitem>
+			<listitem><para>eccpos</para><para>
+				The eccpos array holds the byte offsets in the spare area where
+				the ecc codes are placed.
+			</para></listitem>
+			<listitem><para>oobfree</para><para>
+				The oobfree array defines the areas in the spare area which can be
+				used for automatic placement. The information is given in the format
+				{offset, size}. offset defines the start of the usable area, size the
+				length in bytes. More than one area can be defined. The list is terminated
+				by an {0, 0} entry.
+			</para></listitem>
+			</itemizedlist>
+		</para>
+		<sect2>
+			<title>Placement defined by fs driver</title>
+			<para>
+				The calling function provides a pointer to a nand_oobinfo
+				structure which defines the ecc placement. For writes the
+				caller must provide a spare area buffer along with the
+				data buffer. The spare area buffer size is (number of pages) *
+				(size of spare area). For reads the buffer size is
+				(number of pages) * ((size of spare area) + (number of ecc
+				steps per page) * sizeof (int)). The driver stores the
+				result of the ecc check for each tuple in the spare buffer.
+				The storage sequence is 
+			</para>
+			<para>
+				&lt;spare data page 0&gt;&lt;ecc result 0&gt;...&lt;ecc result n&gt;
+			</para>
+			<para>
+				...
+			</para>
+			<para>
+				&lt;spare data page n&gt;&lt;ecc result 0&gt;...&lt;ecc result n&gt;
+			</para>
+			<para>
+				This is a legacy mode used by YAFFS1.
+			</para>
+			<para>
+				If the spare area buffer is NULL then only the ECC placement is
+				done according to the given scheme in the nand_oobinfo structure.
+			</para>
+		</sect2>
+		<sect2>
+			<title>Automatic placement</title>
+			<para>
+				Automatic placement uses the built in defaults to place the
+				ecc bytes in the spare area. If filesystem data have to be stored /
+				read into the spare area then the calling function must provide a
+				buffer. The buffer size per page is determined by the oobfree array in
+				the nand_oobinfo structure.
+			</para>
+			<para>
+				If the spare area buffer is NULL then only the ECC placement is
+				done according to the default builtin scheme.
+			</para>
+		</sect2>
+		<sect2>
+			<title>User space placement selection</title>
+		<para>
+			All non ecc functions like mtd->read and mtd->write use an internal 
+			structure, which can be set by an ioctl. This structure is preset 
+			to the autoplacement default.
+	     		<programlisting>
+	ioctl (fd, MEMSETOOBSEL, oobsel);
+	     		</programlisting>
+			oobsel is a pointer to a user supplied structure of type
+			nand_oobconfig. The contents of this structure must match the 
+			criteria of the filesystem, which will be used. See an example in utils/nandwrite.c.
+		</para>
+		</sect2>
+	</sect1>	
+	<sect1>
+		<title>Spare area autoplacement default schemes</title>
+		<sect2>
+			<title>256 byte pagesize</title>
+<informaltable><tgroup cols="3"><tbody>
+<row>
+<entry>Offset</entry>
+<entry>Content</entry>
+<entry>Comment</entry>
+</row>
+<row>
+<entry>0x00</entry>
+<entry>ECC byte 0</entry>
+<entry>Error correction code byte 0</entry>
+</row>
+<row>
+<entry>0x01</entry>
+<entry>ECC byte 1</entry>
+<entry>Error correction code byte 1</entry>
+</row>
+<row>
+<entry>0x02</entry>
+<entry>ECC byte 2</entry>
+<entry>Error correction code byte 2</entry>
+</row>
+<row>
+<entry>0x03</entry>
+<entry>Autoplace 0</entry>
+<entry></entry>
+</row>
+<row>
+<entry>0x04</entry>
+<entry>Autoplace 1</entry>
+<entry></entry>
+</row>
+<row>
+<entry>0x05</entry>
+<entry>Bad block marker</entry>
+<entry>If any bit in this byte is zero, then this block is bad.
+This applies only to the first page in a block. In the remaining
+pages this byte is reserved</entry>
+</row>
+<row>
+<entry>0x06</entry>
+<entry>Autoplace 2</entry>
+<entry></entry>
+</row>
+<row>
+<entry>0x07</entry>
+<entry>Autoplace 3</entry>
+<entry></entry>
+</row>
+</tbody></tgroup></informaltable>
+		</sect2>
+		<sect2>
+			<title>512 byte pagesize</title>
+<informaltable><tgroup cols="3"><tbody>
+<row>
+<entry>Offset</entry>
+<entry>Content</entry>
+<entry>Comment</entry>
+</row>
+<row>
+<entry>0x00</entry>
+<entry>ECC byte 0</entry>
+<entry>Error correction code byte 0 of the lower 256 Byte data in
+this page</entry>
+</row>
+<row>
+<entry>0x01</entry>
+<entry>ECC byte 1</entry>
+<entry>Error correction code byte 1 of the lower 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x02</entry>
+<entry>ECC byte 2</entry>
+<entry>Error correction code byte 2 of the lower 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x03</entry>
+<entry>ECC byte 3</entry>
+<entry>Error correction code byte 0 of the upper 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x04</entry>
+<entry>reserved</entry>
+<entry>reserved</entry>
+</row>
+<row>
+<entry>0x05</entry>
+<entry>Bad block marker</entry>
+<entry>If any bit in this byte is zero, then this block is bad.
+This applies only to the first page in a block. In the remaining
+pages this byte is reserved</entry>
+</row>
+<row>
+<entry>0x06</entry>
+<entry>ECC byte 4</entry>
+<entry>Error correction code byte 1 of the upper 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x07</entry>
+<entry>ECC byte 5</entry>
+<entry>Error correction code byte 2 of the upper 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x08 - 0x0F</entry>
+<entry>Autoplace 0 - 7</entry>
+<entry></entry>
+</row>
+</tbody></tgroup></informaltable>
+		</sect2>
+		<sect2>
+			<title>2048 byte pagesize</title>
+<informaltable><tgroup cols="3"><tbody>
+<row>
+<entry>Offset</entry>
+<entry>Content</entry>
+<entry>Comment</entry>
+</row>
+<row>
+<entry>0x00</entry>
+<entry>Bad block marker</entry>
+<entry>If any bit in this byte is zero, then this block is bad.
+This applies only to the first page in a block. In the remaining
+pages this byte is reserved</entry>
+</row>
+<row>
+<entry>0x01</entry>
+<entry>Reserved</entry>
+<entry>Reserved</entry>
+</row>
+<row>
+<entry>0x02-0x27</entry>
+<entry>Autoplace 0 - 37</entry>
+<entry></entry>
+</row>
+<row>
+<entry>0x28</entry>
+<entry>ECC byte 0</entry>
+<entry>Error correction code byte 0 of the first 256 Byte data in
+this page</entry>
+</row>
+<row>
+<entry>0x29</entry>
+<entry>ECC byte 1</entry>
+<entry>Error correction code byte 1 of the first 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x2A</entry>
+<entry>ECC byte 2</entry>
+<entry>Error correction code byte 2 of the first 256 Bytes data in
+this page</entry>
+</row>
+<row>
+<entry>0x2B</entry>
+<entry>ECC byte 3</entry>
+<entry>Error correction code byte 0 of the second 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x2C</entry>
+<entry>ECC byte 4</entry>
+<entry>Error correction code byte 1 of the second 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x2D</entry>
+<entry>ECC byte 5</entry>
+<entry>Error correction code byte 2 of the second 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x2E</entry>
+<entry>ECC byte 6</entry>
+<entry>Error correction code byte 0 of the third 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x2F</entry>
+<entry>ECC byte 7</entry>
+<entry>Error correction code byte 1 of the third 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x30</entry>
+<entry>ECC byte 8</entry>
+<entry>Error correction code byte 2 of the third 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x31</entry>
+<entry>ECC byte 9</entry>
+<entry>Error correction code byte 0 of the fourth 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x32</entry>
+<entry>ECC byte 10</entry>
+<entry>Error correction code byte 1 of the fourth 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x33</entry>
+<entry>ECC byte 11</entry>
+<entry>Error correction code byte 2 of the fourth 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x34</entry>
+<entry>ECC byte 12</entry>
+<entry>Error correction code byte 0 of the fifth 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x35</entry>
+<entry>ECC byte 13</entry>
+<entry>Error correction code byte 1 of the fifth 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x36</entry>
+<entry>ECC byte 14</entry>
+<entry>Error correction code byte 2 of the fifth 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x37</entry>
+<entry>ECC byte 15</entry>
+<entry>Error correction code byte 0 of the sixt 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x38</entry>
+<entry>ECC byte 16</entry>
+<entry>Error correction code byte 1 of the sixt 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x39</entry>
+<entry>ECC byte 17</entry>
+<entry>Error correction code byte 2 of the sixt 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x3A</entry>
+<entry>ECC byte 18</entry>
+<entry>Error correction code byte 0 of the seventh 256 Bytes of
+data in this page</entry>
+</row>
+<row>
+<entry>0x3B</entry>
+<entry>ECC byte 19</entry>
+<entry>Error correction code byte 1 of the seventh 256 Bytes of
+data in this page</entry>
+</row>
+<row>
+<entry>0x3C</entry>
+<entry>ECC byte 20</entry>
+<entry>Error correction code byte 2 of the seventh 256 Bytes of
+data in this page</entry>
+</row>
+<row>
+<entry>0x3D</entry>
+<entry>ECC byte 21</entry>
+<entry>Error correction code byte 0 of the eigth 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x3E</entry>
+<entry>ECC byte 22</entry>
+<entry>Error correction code byte 1 of the eigth 256 Bytes of data
+in this page</entry>
+</row>
+<row>
+<entry>0x3F</entry>
+<entry>ECC byte 23</entry>
+<entry>Error correction code byte 2 of the eigth 256 Bytes of data
+in this page</entry>
+</row>
+</tbody></tgroup></informaltable>
+		</sect2>
+     	</sect1>
+  </chapter>
+
+  <chapter id="filesystems">
+     	<title>Filesystem support</title>
+	<para>
+		The NAND driver provides all neccecary functions for a
+		filesystem via the MTD interface.
+	</para>
+	<para>
+		Filesystems must be aware of the NAND pecularities and
+		restrictions. One major restrictions of NAND Flash is, that you cannot 
+		write as often as you want to a page. The consecutive writes to a page, 
+		before erasing it again, are restricted to 1-3 writes, depending on the 
+		manufacturers specifications. This applies similar to the spare area. 
+	</para>
+	<para>
+		Therefor NAND aware filesystems must either write in page size chunks
+		or hold a writebuffer to collect smaller writes until they sum up to 
+		pagesize. Available NAND aware filesystems: JFFS2, YAFFS. 		
+	</para>
+	<para>
+		The spare area usage to store filesystem data is controlled by
+		the spare area placement functionality which is described in one
+		of the earlier chapters.
+	</para>
+  </chapter>	
+  <chapter id="tools">
+     	<title>Tools</title>
+	<para>
+		The MTD project provides a couple of helpful tools to handle NAND Flash.
+		<itemizedlist>
+		<listitem><para>flasherase, flasheraseall: Erase and format FLASH partitions</para></listitem>
+		<listitem><para>nandwrite: write filesystem images to NAND FLASH</para></listitem>
+		<listitem><para>nanddump: dump the contents of a NAND FLASH partitions</para></listitem>
+		</itemizedlist>
+	</para>
+	<para>
+		These tools are aware of the NAND restrictions. Please use those tools
+		instead of complaining about errors which are caused by non NAND aware
+		access methods.
+	</para>
+  </chapter>	
+
+  <chapter id="defines">
+     <title>Constants</title>
+     <para>
+     This chapter describes the constants which might be relevant for a driver developer.
+     </para>
+     <sect1>   
+	<title>Chip option constants</title>
+     	<sect2>   
+		<title>Constants for chip id table</title>
+     		<para>
+		These constants are defined in nand.h. They are ored together to describe
+		the chip functionality.
+     		<programlisting>
+/* Chip can not auto increment pages */
+#define NAND_NO_AUTOINCR	0x00000001
+/* Buswitdh is 16 bit */
+#define NAND_BUSWIDTH_16	0x00000002
+/* Device supports partial programming without padding */
+#define NAND_NO_PADDING		0x00000004
+/* Chip has cache program function */
+#define NAND_CACHEPRG		0x00000008
+/* Chip has copy back function */
+#define NAND_COPYBACK		0x00000010
+/* AND Chip which has 4 banks and a confusing page / block 
+ * assignment. See Renesas datasheet for further information */
+#define NAND_IS_AND		0x00000020
+/* Chip has a array of 4 pages which can be read without
+ * additional ready /busy waits */
+#define NAND_4PAGE_ARRAY	0x00000040 
+		</programlisting>
+     		</para>
+     	</sect2>
+     	<sect2>   
+		<title>Constants for runtime options</title>
+     		<para>
+		These constants are defined in nand.h. They are ored together to describe
+		the functionality.
+     		<programlisting>
+/* Use a flash based bad block table. This option is parsed by the
+ * default bad block table function (nand_default_bbt). */
+#define NAND_USE_FLASH_BBT	0x00010000
+/* The hw ecc generator provides a syndrome instead a ecc value on read 
+ * This can only work if we have the ecc bytes directly behind the 
+ * data bytes. Applies for DOC and AG-AND Renesas HW Reed Solomon generators */
+#define NAND_HWECC_SYNDROME	0x00020000
+		</programlisting>
+     		</para>
+     	</sect2>
+     </sect1>	
+
+     <sect1>   
+	<title>ECC selection constants</title>
+	<para>
+	Use these constants to select the ECC algorithm.
+  	<programlisting>
+/* No ECC. Usage is not recommended ! */
+#define NAND_ECC_NONE		0
+/* Software ECC 3 byte ECC per 256 Byte data */
+#define NAND_ECC_SOFT		1
+/* Hardware ECC 3 byte ECC per 256 Byte data */
+#define NAND_ECC_HW3_256	2
+/* Hardware ECC 3 byte ECC per 512 Byte data */
+#define NAND_ECC_HW3_512	3
+/* Hardware ECC 6 byte ECC per 512 Byte data */
+#define NAND_ECC_HW6_512	4
+/* Hardware ECC 6 byte ECC per 512 Byte data */
+#define NAND_ECC_HW8_512	6
+	</programlisting>
+	</para>
+     </sect1>	
+
+     <sect1>   
+	<title>Hardware control related constants</title>
+	<para>
+	These constants describe the requested hardware access function when
+	the boardspecific hardware control function is called
+  	<programlisting>
+/* Select the chip by setting nCE to low */
+#define NAND_CTL_SETNCE 	1
+/* Deselect the chip by setting nCE to high */
+#define NAND_CTL_CLRNCE		2
+/* Select the command latch by setting CLE to high */
+#define NAND_CTL_SETCLE		3
+/* Deselect the command latch by setting CLE to low */
+#define NAND_CTL_CLRCLE		4
+/* Select the address latch by setting ALE to high */
+#define NAND_CTL_SETALE		5
+/* Deselect the address latch by setting ALE to low */
+#define NAND_CTL_CLRALE		6
+/* Set write protection by setting WP to high. Not used! */
+#define NAND_CTL_SETWP		7
+/* Clear write protection by setting WP to low. Not used! */
+#define NAND_CTL_CLRWP		8
+	</programlisting>
+	</para>
+     </sect1>	
+
+     <sect1>   
+	<title>Bad block table related constants</title>
+	<para>
+	These constants describe the options used for bad block
+	table descriptors.
+  	<programlisting>
+/* Options for the bad block table descriptors */
+
+/* The number of bits used per block in the bbt on the device */
+#define NAND_BBT_NRBITS_MSK	0x0000000F
+#define NAND_BBT_1BIT		0x00000001
+#define NAND_BBT_2BIT		0x00000002
+#define NAND_BBT_4BIT		0x00000004
+#define NAND_BBT_8BIT		0x00000008
+/* The bad block table is in the last good block of the device */
+#define	NAND_BBT_LASTBLOCK	0x00000010
+/* The bbt is at the given page, else we must scan for the bbt */
+#define NAND_BBT_ABSPAGE	0x00000020
+/* The bbt is at the given page, else we must scan for the bbt */
+#define NAND_BBT_SEARCH		0x00000040
+/* bbt is stored per chip on multichip devices */
+#define NAND_BBT_PERCHIP	0x00000080
+/* bbt has a version counter at offset veroffs */
+#define NAND_BBT_VERSION	0x00000100
+/* Create a bbt if none axists */
+#define NAND_BBT_CREATE		0x00000200
+/* Search good / bad pattern through all pages of a block */
+#define NAND_BBT_SCANALLPAGES	0x00000400
+/* Scan block empty during good / bad block scan */
+#define NAND_BBT_SCANEMPTY	0x00000800
+/* Write bbt if neccecary */
+#define NAND_BBT_WRITE		0x00001000
+/* Read and write back block contents when writing bbt */
+#define NAND_BBT_SAVECONTENT	0x00002000
+	</programlisting>
+	</para>
+     </sect1>	
+
+  </chapter>
+  	
+  <chapter id="structs">
+     <title>Structures</title>
+     <para>
+     This chapter contains the autogenerated documentation of the structures which are
+     used in the NAND driver and might be relevant for a driver developer. Each  
+     struct member has a short description which is marked with an [XXX] identifier.
+     See the chapter "Documentation hints" for an explanation.
+     </para>
+!Iinclude/linux/mtd/nand.h
+  </chapter>
+
+  <chapter id="pubfunctions">
+     <title>Public Functions Provided</title>
+     <para>
+     This chapter contains the autogenerated documentation of the NAND kernel API functions
+      which are exported. Each function has a short description which is marked with an [XXX] identifier.
+     See the chapter "Documentation hints" for an explanation.
+     </para>
+!Edrivers/mtd/nand/nand_base.c
+!Edrivers/mtd/nand/nand_bbt.c
+!Edrivers/mtd/nand/nand_ecc.c
+  </chapter>
+  
+  <chapter id="intfunctions">
+     <title>Internal Functions Provided</title>
+     <para>
+     This chapter contains the autogenerated documentation of the NAND driver internal functions.
+     Each function has a short description which is marked with an [XXX] identifier.
+     See the chapter "Documentation hints" for an explanation.
+     The functions marked with [DEFAULT] might be relevant for a board driver developer.
+     </para>
+!Idrivers/mtd/nand/nand_base.c
+!Idrivers/mtd/nand/nand_bbt.c
+!Idrivers/mtd/nand/nand_ecc.c
+  </chapter>
+
+  <chapter id="credits">
+     <title>Credits</title>
+	<para>
+		The following people have contributed to the NAND driver:
+		<orderedlist>
+			<listitem><para>Steven J. Hill<email>sjhill@realitydiluted.com</email></para></listitem>
+			<listitem><para>David Woodhouse<email>dwmw2@infradead.org</email></para></listitem>
+			<listitem><para>Thomas Gleixner<email>tglx@linutronix.de</email></para></listitem>
+		</orderedlist>
+		A lot of users have provided bugfixes, improvements and helping hands for testing.
+		Thanks a lot.
+	</para>
+	<para>
+		The following people have contributed to this document:
+		<orderedlist>
+			<listitem><para>Thomas Gleixner<email>tglx@linutronix.de</email></para></listitem>
+		</orderedlist>
+	</para>
+  </chapter>
+</book>
diff -Nru a/Documentation/DocBook/procfs-guide.tmpl b/Documentation/DocBook/procfs-guide.tmpl
--- a/Documentation/DocBook/procfs-guide.tmpl	2004-12-24 13:37:02 -08:00
+++ b/Documentation/DocBook/procfs-guide.tmpl	2004-12-24 13:37:02 -08:00
@@ -100,8 +100,8 @@
     <para>
       I'd like to thank Jeff Garzik
       <email>jgarzik@pobox.com</email> and Alexander Viro
-      <email>viro@math.psu.edu</email> for their input, Tim Waugh
-      <email>twaugh@redhat.com</email> for his <ulink
+      <email>viro@parcelfarce.linux.theplanet.co.uk</email> for their input,
+      Tim Waugh <email>twaugh@redhat.com</email> for his <ulink
       url="http://people.redhat.com/twaugh/docbook/selfdocbook/">Selfdocbook</ulink>,
       and Marc Joosen <email>marcj@historia.et.tudelft.nl</email> for
       proofreading.
diff -Nru a/Documentation/DocBook/videobook.tmpl b/Documentation/DocBook/videobook.tmpl
--- a/Documentation/DocBook/videobook.tmpl	2004-12-24 13:37:32 -08:00
+++ b/Documentation/DocBook/videobook.tmpl	2004-12-24 13:37:32 -08:00
@@ -731,13 +731,14 @@
 
 static int io = -1;
 
+#endif
 
 MODULE_AUTHOR("Alan Cox");
 MODULE_DESCRIPTION("A driver for an imaginary radio card.");
-MODULE_PARM(io, "i");
+module_param(io, int, 0444);
 MODULE_PARM_DESC(io, "I/O address of the card.");
 
-int init_module(void)
+static int __init init(void)
 {
         if(io==-1)
         {
@@ -748,25 +749,26 @@
         return myradio_init(NULL);
 }
 
-void cleanup_module(void)
+static void __exit cleanup(void)
 {
         video_unregister_device(&amp;my_radio);
         release_region(io, MY_IO_SIZE);
 }
 
-#endif
+module_init(init);
+module_exit(cleanup);
 
   </programlisting>
   <para>
         In this example we set the IO base by default if the driver is compiled into
-        the kernel where you cannot pass a parameter. For the module we require the
+        the kernel: you can still set it using "my_radio.irq" if this file is called <filename>my_radio.c</filename>. For the module we require the
         user sets the parameter. We set io to a nonsense port (-1) so that we can
         tell if the user supplied an io parameter or not.
   </para>
   <para>
         We use MODULE_ defines to give an author for the card driver and a
         description. We also use them to declare that io is an integer and it is the
-        address of the card.
+        address of the card, and can be read by anyone from sysfs.
   </para>
   <para>
         The clean-up routine unregisters the video_device we registered, and frees
diff -Nru a/Documentation/IO-mapping.txt b/Documentation/IO-mapping.txt
--- a/Documentation/IO-mapping.txt	2004-12-24 13:36:47 -08:00
+++ b/Documentation/IO-mapping.txt	2004-12-24 13:36:47 -08:00
@@ -119,9 +119,10 @@
 So why do we care about the physical address at all? We do need the physical
 address in some cases, it's just not very often in normal code.  The physical
 address is needed if you use memory mappings, for example, because the
-"remap_page_range()" mm function wants the physical address of the memory to
-be remapped (the memory management layer doesn't know about devices outside
-the CPU, so it shouldn't need to know about "bus addresses" etc). 
+"remap_pfn_range()" mm function wants the physical address of the memory to
+be remapped as measured in units of pages, a.k.a. the pfn (the memory
+management layer doesn't know about devices outside the CPU, so it
+shouldn't need to know about "bus addresses" etc).
 
 NOTE NOTE NOTE! The above is only one part of the whole equation. The above
 only talks about "real memory", that is, CPU memory (RAM). 
diff -Nru a/Documentation/RCU/listRCU.txt b/Documentation/RCU/listRCU.txt
--- a/Documentation/RCU/listRCU.txt	2004-12-24 13:36:31 -08:00
+++ b/Documentation/RCU/listRCU.txt	2004-12-24 13:36:31 -08:00
@@ -82,7 +82,7 @@
 		list_for_each_entry(e, list, list) {
 			if (!audit_compare_rule(rule, &e->rule)) {
 				list_del(&e->list);
-				call_rcu(&e->rcu, audit_free_rule, e);
+				write_unlock(&auditsc_lock);
 				return 0;
 			}
 		}
diff -Nru a/Documentation/arm/Booting b/Documentation/arm/Booting
--- a/Documentation/arm/Booting	2004-12-24 13:37:03 -08:00
+++ b/Documentation/arm/Booting	2004-12-24 13:37:03 -08:00
@@ -118,6 +118,10 @@
 
 In either case, the following conditions must be met:
 
+- Quiesce all DMA capable devicess so that memory does not get
+  corrupted by bogus network packets or disk data. This will save
+  you many hours of debug.
+
 - CPU register settings
   r0 = 0,
   r1 = machine type number discovered in (3) above.
diff -Nru a/Documentation/arm/IXP2000 b/Documentation/arm/IXP2000
--- a/Documentation/arm/IXP2000	2004-12-24 13:37:18 -08:00
+++ b/Documentation/arm/IXP2000	2004-12-24 13:37:18 -08:00
@@ -18,7 +18,7 @@
 
 2. Linux Support
 
-Linux currently supports the following features on the IXP2000 NPUS:
+Linux currently supports the following features on the IXP2000 NPUs:
 
 - On-chip serial
 - PCI
@@ -30,10 +30,10 @@
 components of the chip are accessed via Intel's closed source SDK. 
 Please contact Intel directly on issues with using those. There is
 also a mailing list run by some folks at Princeton University that might
-be of helpful:  https://lists.cs.princeton.edu/mailman/listinfo/ixp2xxx
+be of help:  https://lists.cs.princeton.edu/mailman/listinfo/ixp2xxx
 
 WHATEVER YOU DO, DO NOT POST EMAIL TO THE LINUX-ARM OR LINUX-ARM-KERNEL
-MAILINNG LISTS REGARDING THE INTEL SDK.
+MAILING LISTS REGARDING THE INTEL SDK.
 
 3. Supported Platforms
 
@@ -47,12 +47,12 @@
 
 - The IXP2000 platforms ususally have rather complex PCI bus topologies
   with large memory space requirements. In addition, b/c of the way the
-  Intel SDK is designed, devices are enumerated in a vert specific
+  Intel SDK is designed, devices are enumerated in a very specific
   way. B/c of this this, we use "pci=firmware" option in the kernel
   command line so that we do not re-enumerate the bus.
 
 - IXDP2x01 systems have variable clock tick rates that we cannot determine 
-  via HW registers. The "ixdp2x01_clk=XXX" cmd line options allows you
+  via HW registers. The "ixdp2x01_clk=XXX" cmd line options allow you
   to pass the clock rate to the board port.
 
 5. Thanks
diff -Nru a/Documentation/arm/IXP4xx b/Documentation/arm/IXP4xx
--- a/Documentation/arm/IXP4xx	2004-12-24 13:36:17 -08:00
+++ b/Documentation/arm/IXP4xx	2004-12-24 13:36:17 -08:00
@@ -122,6 +122,15 @@
    also known as the Richfield board. It contains 4 PCI slots, 16MB
    of flash, two 10/100 ports and one ADSL port.
 
+Intel IXDPG425 Development Platform
+
+   This is basically and ADI Coyote board with a NEC EHCI controller
+   added. One issue with this board is that the mini-PCI slots only
+   have the 3.3v line connected, so you can't use a PCI to mini-PCI
+   adapter with an E100 card. So to NFS root you need to use either
+   the CSR or a WiFi card and a ramdisk that BOOTPs and then does
+   a pivot_root to NFS.
+
 Motorola PrPMC1100 Processor Mezanine Card
 http://www.fountainsys.com/datasheet/PrPMC1100.pdf
 
@@ -152,4 +161,4 @@
 
 -------------------------------------------------------------------------
 
-Last Update: 5/13/2004
+Last Update: 11/16/2004
diff -Nru a/Documentation/arm/README b/Documentation/arm/README
--- a/Documentation/arm/README	2004-12-24 13:37:43 -08:00
+++ b/Documentation/arm/README	2004-12-24 13:37:43 -08:00
@@ -163,9 +163,9 @@
 
     <http://www.arm.linux.org.uk/developer/machines/>
 
-Kernel entry (head-armv.S)
+Kernel entry (head.S)
 --------------------------
-  The initial entry into the kernel is via head-armv.S, which uses machine
+  The initial entry into the kernel is via head.S, which uses machine
   independent code.  The machine is selected by the value of 'r1' on
   entry, which must be kept unique.
 
diff -Nru a/Documentation/arm/Samsung-S3C24XX/EB2410ITX.txt b/Documentation/arm/Samsung-S3C24XX/EB2410ITX.txt
--- a/Documentation/arm/Samsung-S3C24XX/EB2410ITX.txt	2004-12-24 13:37:32 -08:00
+++ b/Documentation/arm/Samsung-S3C24XX/EB2410ITX.txt	2004-12-24 13:37:32 -08:00
@@ -15,7 +15,7 @@
 -------------
 
   To set the default configuration, use `make bast_defconfig` which
-  supports the commonly used features of this board
+  supports the commonly used features of this board.
 
 
 Support
@@ -23,15 +23,23 @@
 
   Official support information can be found on the Simtec Electronics
   website, at the product page http://www.simtec.co.uk/products/EB2410ITX/
-  and http://www.simtec.co.uk/products/EB2410ITX/resources.html
+
+  Useful links:
+
+    - Resources Page http://www.simtec.co.uk/products/EB2410ITX/resources.html
+
+    - Board FAQ at http://www.simtec.co.uk/products/EB2410ITX/faq.html
+
+    - Bootloader info http://www.simtec.co.uk/products/SWABLE/resources.html
+      and FAQ http://www.simtec.co.uk/products/SWABLE/faq.html
 
 
 MTD
 ---
 
-  The NAND and NOR onboard are currently supported in the linux-mtd cvs,
-  and are awaiting merge in the mainline. see the linux-mtd project at
-  http://www.linux-mtd.infradead.org/ for more information.
+  The NAND and NOR support has been merged from the linux-mtd project.
+  Any prolbems, see http://www.linux-mtd.infradead.org/ for more
+  information or up-to-date versions of linux-mtd.
 
 
 IDE
@@ -39,6 +47,12 @@
 
   Both onboard IDE ports are supported, however there is no support for
   changing speed of devices, PIO Mode 4 capable drives should be used.
+
+
+Maintainers
+-----------
+
+  This board is maintained by Simtec Electronics.
 
 
 (c) 2004 Ben Dooks, Simtec Electronics
diff -Nru a/Documentation/arm/Samsung-S3C24XX/Overview.txt b/Documentation/arm/Samsung-S3C24XX/Overview.txt
--- a/Documentation/arm/Samsung-S3C24XX/Overview.txt	2004-12-24 13:37:31 -08:00
+++ b/Documentation/arm/Samsung-S3C24XX/Overview.txt	2004-12-24 13:37:31 -08:00
@@ -48,9 +48,9 @@
 NAND
 ----
 
-  The current kernels do not have direct support for the NAND
-  controller, the latest linux-mtd CVS has support for this.
-  See http://www.linux-mtd.infradead.org/
+  The current kernels now have support for the s3c2410 NAND
+  controller. If there are any problems the latest linux-mtd
+  CVS can be found from http://www.linux-mtd.infradead.org/
 
 
 Serial
@@ -84,12 +84,21 @@
 Port Contributors
 -----------------
 
-  Ben Dooks
+  Ben Dooks (BJD)
   Vincent Sanders
   Herbert Potzl
-  Arnaud Patard
+  Arnaud Patard (RTP)
   Roc Wu
+  Klaus Fetscher
+  Dimitry Andric
 
+Document Changes
+----------------
+
+  05 Sep 2004 - BJD - Added Document Changes section
+  05 Sep 2004 - BJD - Added Klaus Fetscher to list of contributors
+  25 Oct 2004 - BJD - Added Dimitry Andric to list of contributors
+  25 Oct 2004 - BJD - Updated the MTD from the 2.6.9 merge
 
 Document Author
 ---------------
diff -Nru a/Documentation/arm/Samsung-S3C24XX/Suspend.txt b/Documentation/arm/Samsung-S3C24XX/Suspend.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/arm/Samsung-S3C24XX/Suspend.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,106 @@
+			S3C24XX Suspend Support
+			=======================
+
+
+Introduction
+------------
+
+  The S3C2410 supports a low-power suspend mode, where the SDRAM is kept
+  in Self-Refresh mode, and all but the essential peripheral blocks are
+  powered down. For more information on how this works, please look
+  at the S3C2410 datasheets from Samsung.
+
+
+Requirements
+------------
+
+  1) A bootloader that can support the necessary resume operation
+
+  2) Support for at least 1 source for resume
+
+  3) CONFIG_PM enabled in the kernel
+
+  4) Any peripherals that are going to be powered down at the same
+     time require suspend/resume support.
+
+
+Resuming
+--------
+
+  The S3C2410 user manual defines the process of sending the CPU to
+  sleep and how it resumes. The default behaviour of the Linux code
+  is to set the GSTATUS3 register to the physical address of the
+  code to resume Linux operation.
+
+  GSTATUS4 is currently left alone by the sleep code, and is free to
+  use for any other purposes (for example, the EB2410ITX uses this to
+  save memory configuration in).
+
+
+Machine Support
+---------------
+
+  The machine specific functions must call the s3c2410_pm_init() function
+  to say that its bootloader is capable of resuming. This can be as
+  simple as adding the following to the machine's definition:
+
+  INITMACHINE(s3c2410_pm_init)
+
+  A board can do its own setup before calling s3c2410_pm_init, if it
+  needs to setup anything else for power management support.
+
+  There is currently no support for over-riding the default method of
+  saving the resume address, if your board requires it, then contact
+  the maintainer and discuss what is required.
+
+  Note, the original method of adding an late_initcall() is wrong,
+  and will end up initialising all compiled machines' pm init!
+
+
+Debugging
+---------
+
+  There are several important things to remember when using PM suspend:
+
+  1) The uart drivers will disable the clocks to the UART blocks when
+     suspending, which means that use of printascii() or similar direct
+     access to the UARTs will cause the debug to stop.
+
+  2) Whilst the pm code itself will attempt to re-enable the UART clocks,
+     care should be taken that any external clock sources that the UARTs
+     rely on are still enabled at that point.
+
+
+Configuration
+-------------
+
+  The S3C2410 specific configuration in `System Type` defines various
+  aspects of how the S3C2410 suspend and resume support is configured
+
+  `S3C2410 PM Suspend debug`
+
+    This option prints messages to the serial console before and after
+    the actual suspend, giving detailed information on what is
+    happening
+
+
+  `S3C2410 PM Suspend Memory CRC`
+
+    Allows the entire memory to be checksummed before and after the
+    suspend to see if there has been any corruption of the contents.
+
+    This support requires the CRC32 function to be enabled.
+
+
+  `S3C2410 PM Suspend CRC Chunksize (KiB)`
+
+    Defines the size of memory each CRC chunk covers. A smaller value
+    will mean that the CRC data block will take more memory, but will
+    identify any faults with better precision
+
+
+Document Author
+---------------
+
+Ben Dooks, (c) 2004 Simtec Electronics
+
diff -Nru a/Documentation/arm/Sharp-LH/IOBarrier b/Documentation/arm/Sharp-LH/IOBarrier
--- a/Documentation/arm/Sharp-LH/IOBarrier	2004-12-24 13:36:30 -08:00
+++ b/Documentation/arm/Sharp-LH/IOBarrier	2004-12-24 13:36:30 -08:00
@@ -5,7 +5,7 @@
 the signals that control access to some peripherals, most notably the
 SMC91C9111 ethernet controller, are not properly handled.
 
-The symptom is that back to back IO with the peripheral returns
+The symptom is that some back to back IO with the peripheral returns
 unreliable data.  With the SMC chip, you'll see errors about the bank
 register being 'screwed'.
 
@@ -13,20 +13,33 @@
 for every memory access.  It is driven through the CPLD from the CS7
 line of the CPU's static memory controller which is optimized to
 eliminate unnecessary transitions.  Yet, the SMC requires a transition
-for every access.  The Sharp website has more information on the
-effect of this power conservation feature on peripheral interfacing.
+for every write access.  The Sharp website has more information about
+the effect this power-conserving feature has on peripheral
+interfacing.
 
-The solution is to follow every access to the SMC chip with an access
-to another memory region that will force the CPU to release the chip
-select line.  Note that it is important to guarantee that the access
-will force the CPU off-chip.  We map a page of SDRAM as if it were an
-uncacheable IO device and read from it after every SMC IO operation.
+The solution is to follow every write access to the SMC chip with an
+access to another memory region that will force the CPU to release the
+chip select line.  It is important to guarantee that this access
+forces the CPU off-chip.  We map a page of SDRAM as if it were an
+uncacheable IO device and read from it after every SMC IO write
+operation.
 
   SMC IO
   BARRIER IO
 
-You might be tempted to believe that we must access another device
+Only this sequence is important.  It does not matter that there is no
+BARRIER IO before the access to the SMC chip because the AEN latch
+only needs occurs after the SMC IO write cycle.  The routines that
+implement this work-around make an additional concession which is to
+disable interrupts during the IO sequence.  Other hardware devices
+(the LogicPD CPLD) have registers in the same the physical memory
+region as the SMC chip.  An interrupt might allow an access to one of
+those registers while SMC IO is being performed.
+
+You might be tempted to think that we have to access another device
 attached to the static memory controller, but the empirical evidence
 indicates that this is not so.  Mapping 0x00000000 (flash) and
 0xc0000000 (SDRAM) appear to have the same effect.  Using SDRAM seems
-to be faster.
+to be faster.  Choosing to access an undecoded memory region is not
+desirable as there is no way to know how that chip select will be used
+in the future.
diff -Nru a/Documentation/block/as-iosched.txt b/Documentation/block/as-iosched.txt
--- a/Documentation/block/as-iosched.txt	2004-12-24 13:36:31 -08:00
+++ b/Documentation/block/as-iosched.txt	2004-12-24 13:36:31 -08:00
@@ -132,7 +132,7 @@
 Tuning the anticipatory IO scheduler
 ------------------------------------
 When using 'as', the anticipatory IO scheduler there are 5 parameters under
-/sys/block/*/iosched/. All are units of milliseconds.
+/sys/block/*/queue/iosched/. All are units of milliseconds.
 
 The parameters are:
 * read_expire
diff -Nru a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt
--- a/Documentation/block/biodoc.txt	2004-12-24 13:37:04 -08:00
+++ b/Documentation/block/biodoc.txt	2004-12-24 13:37:04 -08:00
@@ -1172,8 +1172,7 @@
 while (IDE for example)), where the CPU is doing the actual data
 transfer a virtual mapping is needed. If the driver supports highmem I/O,
 (Sec 1.1, (ii) ) it needs to use __bio_kmap_atomic and bio_kmap_irq to
-temporarily map a bio into the virtual address space. See how IDE handles
-this with ide_map_buffer.
+temporarily map a bio into the virtual address space.
 
 
 8. Prior/Related/Impacted patches
diff -Nru a/Documentation/block/deadline-iosched.txt b/Documentation/block/deadline-iosched.txt
--- a/Documentation/block/deadline-iosched.txt	2004-12-24 13:37:01 -08:00
+++ b/Documentation/block/deadline-iosched.txt	2004-12-24 13:37:01 -08:00
@@ -9,7 +9,7 @@
 tunables control how the io scheduler works. You can find these entries
 in:
 
-/sys/block/<device>/iosched
+/sys/block/<device>/queue/iosched
 
 assuming that you have sysfs mounted on /sys. If you don't have sysfs mounted,
 you can do so by typing:
diff -Nru a/Documentation/cdrom/00-INDEX b/Documentation/cdrom/00-INDEX
--- a/Documentation/cdrom/00-INDEX	2004-12-24 13:36:49 -08:00
+++ b/Documentation/cdrom/00-INDEX	2004-12-24 13:36:49 -08:00
@@ -22,6 +22,8 @@
 	- info on improved Mitsumi CD-ROM driver.
 optcd
 	- info on the Optics Storage 8000 AT CD-ROM driver
+packet-writing.txt
+	- Info on the CDRW packet writing module
 sbpcd
 	- info on the SoundBlaster/Panasonic CD-ROM interface driver.
 sjcd
diff -Nru a/Documentation/cdrom/packet-writing.txt b/Documentation/cdrom/packet-writing.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/cdrom/packet-writing.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,86 @@
+Getting started quick
+---------------------
+
+- Select packet support in the block device section and UDF support in
+  the file system section.
+
+- Compile and install kernel and modules, reboot.
+
+- You need the udftools package (pktsetup, mkudffs, cdrwtool).
+  Download from http://sourceforge.net/projects/linux-udf/
+
+- Grab a new CD-RW disc and format it (assuming CD-RW is hdc, substitute
+  as appropriate):
+	# cdrwtool -d /dev/hdc -q
+
+- Setup your writer
+	# pktsetup dev_name /dev/hdc
+
+- Now you can mount /dev/pktcdvd/dev_name and copy files to it. Enjoy!
+	# mount /dev/pktcdvd/dev_name /cdrom -t udf -o rw,noatime
+
+
+Packet writing for DVD-RW media
+-------------------------------
+
+DVD-RW discs can be written to much like CD-RW discs if they are in
+the so called "restricted overwrite" mode. To put a disc in restricted
+overwrite mode, run:
+
+	# dvd+rw-format /dev/hdc
+
+You can then use the disc the same way you would use a CD-RW disc:
+
+	# pktsetup dev_name /dev/hdc
+	# mount /dev/pktcdvd/dev_name /cdrom -t udf -o rw,noatime
+
+
+Packet writing for DVD+RW media
+-------------------------------
+
+According to the DVD+RW specification, a drive supporting DVD+RW discs
+shall implement "true random writes with 2KB granularity", which means
+that it should be possible to put any filesystem with a block size >=
+2KB on such a disc. For example, it should be possible to do:
+
+	# mkudffs /dev/hdc
+	# mount /dev/hdc /cdrom -t udf -o rw,noatime
+
+However, some drives don't follow the specification and expect the
+host to perform aligned writes at 32KB boundaries. Other drives do
+follow the specification, but suffer bad performance problems if the
+writes are not 32KB aligned.
+
+Both problems can be solved by using the pktcdvd driver, which always
+generates aligned writes.
+
+	# pktsetup dev_name /dev/hdc
+	# mkudffs /dev/pktcdvd/dev_name
+	# mount /dev/pktcdvd/dev_name /cdrom -t udf -o rw,noatime
+
+
+Notes
+-----
+
+- CD-RW media can usually not be overwritten more than about 1000
+  times, so to avoid unnecessary wear on the media, you should always
+  use the noatime mount option.
+
+- Defect management (ie automatic remapping of bad sectors) has not
+  been implemented yet, so you are likely to get at least some
+  filesystem corruption if the disc wears out.
+
+- Since the pktcdvd driver makes the disc appear as a regular block
+  device with a 2KB block size, you can put any filesystem you like on
+  the disc. For example, run:
+
+	# /sbin/mke2fs /dev/pktcdvd/dev_name
+
+  to create an ext2 filesystem on the disc.
+
+
+Links
+-----
+
+See http://fy.chalmers.se/~appro/linux/DVD+RW/ for more information
+about DVD writing.
diff -Nru a/Documentation/computone.txt b/Documentation/computone.txt
--- a/Documentation/computone.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/computone.txt	2004-12-24 13:37:18 -08:00
@@ -1,3 +1,13 @@
+NOTE: This is an unmaintained driver.  It is not guaranteed to work due to
+changes made in the tty layer in 2.6.  If you wish to take over maintenance of
+this driver, contact Michael Warfield <mhw@wittsend.com>.
+
+Changelog:
+----------
+11-01-2001:	Original Document
+
+10-29-2004:	Minor misspelling & format fix, update status of driver.
+		James Nelson <james4765@gmail.com>
 
 Computone Intelliport II/Plus Multiport Serial Driver
 -----------------------------------------------------
@@ -146,7 +156,7 @@
 ip2.c are used. If you are autoloading the driver module with kerneld or
 kmod the base addresses and interrupt number must also be set in ip2.c
 and recompile or just insert and options line in /etc/modprobe.conf or both.
-The options line is equivalent to the command line and takes precidence over 
+The options line is equivalent to the command line and takes precedence over
 what is in ip2.c. 
 
 /etc/modprobe.conf sample:
@@ -166,7 +176,8 @@
 
 
 Note:	Both io and irq should be updated to reflect YOUR system.  An "io"
-	address of 1 or 2 indicates a PCI or EISA card in the board table.		The PCI or EISA irq will be assigned automatically.
+	address of 1 or 2 indicates a PCI or EISA card in the board table.
+	The PCI or EISA irq will be assigned automatically.
 
 Specifying an invalid or in-use irq will default the driver into
 running in polled mode for that card.  If all irq entries are 0 then
diff -Nru a/Documentation/cpqarray.txt b/Documentation/cpqarray.txt
--- a/Documentation/cpqarray.txt	2004-12-24 13:36:55 -08:00
+++ b/Documentation/cpqarray.txt	2004-12-24 13:36:55 -08:00
@@ -26,31 +26,13 @@
 	* IDA-2
 	* IAES
 
-Installing:
------------
-
-You need to build a new kernel to use this device, even if you want to
-use a loadable module.  
-
-Apply the patch to a 2.2.x kernel:
-
-# cd linux
-# patch -p1 <smart2.patch
-
-Then build a new kernel and turn on Compaq SMART2 Disk Array support.
-Create device nodes for the diskarray device:
-
-# mkdev.ida [ctlrs]
-
-Where ctlrs is the number of controllers you have (defaults to 1 if not
-specified).
 
 EISA Controllers:
 -----------------
 
 If you want to use an EISA controller you'll have to supply some
-insmod/lilo parameters.  If the driver is compiled into the kernel, must
-give it the controller's IO port address at boot time (it is no longer
+modprobe/lilo parameters.  If the driver is compiled into the kernel, must
+give it the controller's IO port address at boot time (it is not
 necessary to specify the IRQ).  For example, if you had two SMART-2/E
 controllers, in EISA slots 1 and 2 you'd give it a boot argument like
 this:
@@ -59,29 +41,27 @@
 
 If you were loading the driver as a module, you'd give load it like this:
 
-	insmod cpqarray.o eisa=0x1000,0x2000
+	modprobe cpqarray eisa=0x1000,0x2000
 
 You can use EISA and PCI adapters at the same time.
 
-Booting:
---------
-
-You'll need to use a modified lilo if you want to boot from a disk array.
-Its simply a version of lilo with some code added to tell it how to
-understand Compaq diskarray devices.
 
 Device Naming:
 --------------
 
-You need some entries in /dev for the ida device.  The mkdev.ida script
-can make device nodes for you automatically.  Currently the device setup
-is as follows:
+You need some entries in /dev for the ida device.  MAKEDEV in the /dev
+directory can make device nodes for you automatically.  The device setup is
+as follows:
 
 Major numbers:
 	72	ida0
 	73	ida1
 	74	ida2
-	etc...
+	75	ida3
+	76	ida4
+	77	ida5
+	78	ida6
+	79	ida7
 
 Minor numbers:
         b7 b6 b5 b4 b3 b2 b1 b0
@@ -91,7 +71,7 @@
              |
              +-------------------- Logical Volume number
 
-The suggested device naming scheme is:
+The device naming scheme is:
 /dev/ida/c0d0		Controller 0, disk 0, whole device
 /dev/ida/c0d0p1		Controller 0, disk 0, partition 1
 /dev/ida/c0d0p2		Controller 0, disk 0, partition 2
@@ -101,3 +81,13 @@
 /dev/ida/c1d1p1		Controller 1, disk 1, partition 1
 /dev/ida/c1d1p2		Controller 1, disk 1, partition 2
 /dev/ida/c1d1p3		Controller 1, disk 1, partition 3
+
+
+Changelog:
+==========
+
+10-28-2004 :	General cleanup, syntax fixes for in-kernel driver version.
+		James Nelson <james4765@gmail.com>
+
+
+1999 :		Original Document
diff -Nru a/Documentation/cpu-freq/cpufreq-nforce2.txt b/Documentation/cpu-freq/cpufreq-nforce2.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/cpu-freq/cpufreq-nforce2.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,19 @@
+
+The cpufreq-nforce2 driver changes the FSB on nVidia nForce2 plattforms.
+
+This works better than on other plattforms, because the FSB of the CPU
+can be controlled independently from the PCI/AGP clock.
+
+The module has two options:
+
+	fid: 	 multiplier * 10 (for example 8.5 = 85)
+	min_fsb: minimum FSB
+
+If not set, fid is calculated from the current CPU speed and the FSB.
+min_fsb defaults to FSB at boot time - 50 MHz.
+
+IMPORTANT: The available range is limited downwards!
+           Also the minimum available FSB can differ, for systems 
+           booting with 200 MHz, 150 should always work.
+
+
diff -Nru a/Documentation/cpu-freq/user-guide.txt b/Documentation/cpu-freq/user-guide.txt
--- a/Documentation/cpu-freq/user-guide.txt	2004-12-24 13:36:18 -08:00
+++ b/Documentation/cpu-freq/user-guide.txt	2004-12-24 13:36:18 -08:00
@@ -65,6 +65,7 @@
 Intel Pentium M (Centrino)
 National Semiconductors Geode GX
 Transmeta Crusoe
+Transmeta Efficeon
 VIA Cyrix 3 / C3
 various processors on some ACPI 2.0-compatible systems [*]
 
diff -Nru a/Documentation/crypto/api-intro.txt b/Documentation/crypto/api-intro.txt
--- a/Documentation/crypto/api-intro.txt	2004-12-24 13:37:02 -08:00
+++ b/Documentation/crypto/api-intro.txt	2004-12-24 13:37:02 -08:00
@@ -231,6 +231,9 @@
   Aaron Grothe
   Jean-Luc Cooke
 
+Anubis algorithm contributors:
+  Aaron Grothe
+
 Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
 
 Please send any credits updates or corrections to:
diff -Nru a/Documentation/devices.txt b/Documentation/devices.txt
--- a/Documentation/devices.txt	2004-12-24 13:36:47 -08:00
+++ b/Documentation/devices.txt	2004-12-24 13:36:47 -08:00
@@ -2546,12 +2546,7 @@
 		  0 = /dev/usb/lp0	First USB printer
 		    ...
 		 15 = /dev/usb/lp15	16th USB printer
-		 16 = /dev/usb/mouse0	First USB mouse
-		    ...
-		 31 = /dev/usb/mouse15	16th USB mouse
-		 32 = /dev/usb/ez0	First USB firmware loader
-		    ...
-		 47 = /dev/usb/ez15	16th USB firmware loader
+		 32 = /dev/usb/mdc800	MDC800 USB camera
 		 48 = /dev/usb/scanner0	First USB scanner
 		    ...
 		 63 = /dev/usb/scanner15 16th USB scanner
@@ -2559,6 +2554,22 @@
 		 65 = /dev/usb/usblcd	USBLCD Interface (info@usblcd.de)
 		 66 = /dev/usb/cpad0	Synaptics cPad (mouse/LCD)
 
+		 96 = /dev/usb/hiddev0	1st USB HID device
+		    ...
+		111 = /dev/usb/hiddev15	16th USB HID device
+		112 = /dev/usb/auer0	1st auerswald ISDN device
+		    ...
+		127 = /dev/usb/auer15	16th auerswald ISDN device
+		128 = /dev/usb/brlvgr0	First Braille Voyager device
+		    ...
+		131 = /dev/usb/brlvgr3	Fourth Braille Voyager device
+		144 = /dev/usb/lcd	USB LCD device
+		160 = /dev/usb/legousbtower0	1st USB Legotower device
+		    ...
+		175 = /dev/usb/legousbtower15	16th USB Legotower device
+		240 = /dev/usb/dabusb0	First daubusb device
+		    ...
+		243 = /dev/usb/dabusb3	Fourth dabusb device
 
 181 char	Conrad Electronic parallel port radio clocks
 		  0 = /dev/pcfclock0	First Conrad radio clock
@@ -2747,6 +2758,10 @@
 		 43 = /dev/ttySMX2		Motorola i.MX - port 2
 		 44 = /dev/ttyMM0		Marvell MPSC - port 0
 		 45 = /dev/ttyMM1		Marvell MPSC - port 1
+		 46 = /dev/ttyCPM0		PPC CPM (SCC or SMC) - port 0
+		    ...
+		 49 = /dev/ttyCPM5		PPC CPM (SCC or SMC) - port 5
+
 
 205 char	Low-density serial ports (alternate device)
 		  0 = /dev/culu0		Callout device for ttyLU0
@@ -2775,6 +2790,9 @@
 		 41 = /dev/ttySMX0		Callout device for ttySMX0
 		 42 = /dev/ttySMX1		Callout device for ttySMX1
 		 43 = /dev/ttySMX2		Callout device for ttySMX2
+		 46 = /dev/cucpm0		Callout device for ttyCPM0
+		    ...
+		 49 = /dev/cucpm5		Callout device for ttyCPM5
 
 206 char	OnStream SC-x0 tape devices
 		  0 = /dev/osst0		First OnStream SCSI tape, mode 0
diff -Nru a/Documentation/digiboard.txt b/Documentation/digiboard.txt
--- a/Documentation/digiboard.txt	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,272 +0,0 @@
-The Linux Digiboard Driver
---------------------------
-
-The Digiboard Driver for Linux supports the following boards:
-
- DigiBoard PC/Xi, PC/Xe, PC/Xeve(which is the newer, smaller Xe with
- a 8K window which is also known as PC/Xe(8K) and has no memory/irq
- switches) You can use up to 4 cards with this driver and it should work
- on other architectures than intel also.
-
-A version of this driver has been taken by Digiboard to make a driver
-software package which supports also PC/Xem cards and newer PCI cards
-but it doesn't support the old PC/Xi cards and it isn't yet ported to
-linux-2.1.x and may not be usable on other architectures than intel now.
-It is available from ftp.digi.com/ftp.digiboard.com. You can write me if
-you need an patch for this driver.
-
-Bernhard Kaindl (bkaindl@netway.at)  6. April 1997.
-
-Configuring the Driver
-----------------------
-
-The driver can be built direct into the kernel or as a module.
-The pcxx driver can be configured using the command line feature while
-loading the kernel with LILO or LOADLIN or, if built as a module,
-with arguments to insmod and modprobe or with parameters in
-/etc/modprobe.conf for modprobe and kerneld.
-
-After configuring the driver you need to create the device special files
-as described in "Device file creation:" below and set the appropriate
-permissions for your application.
-
-As Module
----------
-
-modprobe pcxx io=<io> \
-  membase=<membase> \
-  memsize=<memsize> \
-  numports=<numports>  \
-  altpin=<altpin> \
-  verbose=<verbose>
-
-or, if several cards are installed
-
-modprobe pcxx io=<io-1>,<io-2>,... \
-  membase=<membase-1>,<membase-2>,... \
-  memsize=<memsize-1>,<memsize-2>,... \
-  numports=<numports-1>,<numports-2>,... \
-  altpin=<altpin-1>,<altpin-2>,... \
-  verbose=<verbose>
-
-where <io-N> is the io address of the Nth card and <membase-N> is the
-memory base address of the Nth card, etc.
-
-The parameters can be specified in any order. For example, the numports
-parameter can precede the membase parameter, or vice versa. If several
-cards are installed the ordering within the comma separated parameter
-lists must be consistent, of course.
-
-io       - I/O port address of that card.
-membase  - Memory start address of that card.
-memsize  - Memory size of that card, in kilobytes. If given, this value
-           is compared against the card to verify configuration and
-           hinder the driver from using a misconfigured card. If the parameter
-           does not match the board it is disabled with a memory size error.
-numports - Number of ports on this card. This is the number of devices to
-           assign to this card or reserve if disabled.
-altpin   - 1: swap DCD and DSR for 8-pin RJ-45 with modems.
-	   0: don't swap DCD and DSR.
-           other values count as 1.
-verbose  - 1: give nice verbose output during initialisation of the driver,
-              possibly helpful during board configuration.
-           0: normal terse output.
-
-Only the parameters which differ from the defaults need to be specified.
-If the io= parameter is not given, the default config is used. This is
-
-  io=0x200 membase=0xD0000 numports=16 altpin=0
-
-Only applicable parameters need be specified. For example to configure
-2 boards, first one at 0x200 with 8 ports, rest defaults, second one at
-0x120, memory at 0xD80000, altpin enabled, rest defaults, you can do this
-by using these parameters:
-
-  modprobe pcxx io=0x200,0x120 numports=8,8 membase=,0xD80000 altpin=,1
-
-To disable a temporary unusable board without changing the mapping of the
-devices following that board, you can empty the io-value for that board:
-
-  modprobe pcxx io=,0x120 numports=8,8 membase=,0xD80000 altpin=,1
-
-The remaining board still uses ttyD8-ttyD15 and cud8-cud15.
-
-Example line for /etc/modprobe.conf for use with kerneld and as default
-parameters for modprobe:
-
-options pcxx           io=0x200 numports=8
-
-For kmod to work you will likely need to add these two lines to your
-/etc/modprobe.conf:
-
-alias char-major-22    pcxx
-alias char-major-23    pcxx
-
-
-Boot-time configuration when linked into the kernel
----------------------------------------------------
-
-Per board to be configured, pass a digi= command-line parameter to the
-kernel using lilo or loadlin. It consists of a string of comma separated
-identifiers or integers.  The 6 values in order are:
-
-Card status:      Enable      - use that board
-		  Disable     - don't actually use that board.
-
-Card type:        PC/Xi       - the old ones with 64/128/256/512K RAM.
-		  PC/Xe       - PC/Xe(old ones with 64k mem range).
-		  PC/Xeve     - PC/Xe(new ones with 8k mem range).
-
-Note: This is for documentation only, the type is detected from the board.
-
-Altpin setting:   Enable      - swap DCD and DSR for 8-pin RJ-45 with modems.
-		  Disable     - don't swap DCD and DSR.
-
-Number of ports:  1 ... 16    - Number of ports on this card. This is the
-				number of devices to assign to this card.
-
-I/O port address: eg. 200     - I/O Port address where the card is configured.
-
-Memory base addr: eg. 80000   - Memory address where the board's memory starts.
-
-This is an example for a line which you can insert into you lilo.conf:
-
-   append="digi=Enable,PC/Xi,Disable,4,120,D0000"
-
-there is an alternate form, in which you must use decimal values only:
-
-   append="digi=1,0,0,16,512,851968"
-
-If you don't give a digi= command line, the compiled-in defaults of
-board 1: io=0x200, membase=0xd0000, altpin=off and numports=16 are used.
-
-If you have the resources (io&mem) free for use, configure your board to
-these settings and you should be set up fine even if yours has not got 16 
-ports.
-
-
-Sources of Information
-----------------------
-
-Please contact digi directly digilnux@dgii.com. Forward any information of
-general interest to me so that I can include it on the webpage.
-
-Web page: http://lameter.com/digi
-
-Christoph Lameter (christoph@lameter.com) Aug 14, 2000.
-
-Device file creation
---------------------
-
-Currently the Linux MAKEDEV command does not support generating the Digiboard
-Devices. 
-
-The /dev/cud devices behave like the /dev/cua devices
-and the ttyD devices are like the /dev/ttyS devices.
-
-Use the following script to generate the devices:
-
------------------- mkdigidev begin
-#!/bin/sh
-#
-# Script to create Digiboard Devices
-# Christoph Lameter, April 16, 1996
-#
-# Usage:
-# mkdigidev [<number of devices>]
-# 
-
-DIGI_MAJOR=23
-DIGICU_MAJOR=22
-
-BOARDS=$1
-
-if [ "$BOARDS" = "" ]; then
-BOARDS=1
-fi
-
-boardnum=0
-while [ $boardnum -lt $BOARDS ];
-do
-  for c in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15;
-  do
-	name=`expr $boardnum \* 16 + $c`
-	mknod /dev/cud$name c $DIGICU_MAJOR $name
-	mknod /dev/ttyD$name c $DIGI_MAJOR $name
-  done
-  boardnum=`expr $boardnum + 1`
-done
------------------- mkdigidev end
-
-or apply the following patch to /dev/MAKEDEV and do a 
-sh /dev/MAKEDEV digi
-
------ MAKEDEV Patch
---- /dev/MAKEDEV	Sun Aug 13 15:48:23 1995
-+++ MAKEDEV	Tue Apr 16 17:53:27 1996
-@@ -120,7 +120,7 @@
- 	while [ $# -ne 0 ]
- 	do
- 		case "$1" in
--			mem|tty|ttyp|cua|cub)	;;
-+			mem|tty|ttyp|cua|cub|cud)	;;
- 			hd)	echo hda hdb hdc hdd ;;
- 			xd)	echo xda xdb ;;
- 			fd)	echo fd0 fd1 ;;
-@@ -140,6 +140,7 @@
- 			dcf)		echo dcf ;;
- 			pcmcia)	;; # taken care of by its own driver
- 			ttyC)	echo cyclades ;;
-+			ttyD)	echo digi ;;
- 			*)	echo "$0: don't know what \"$1\" is" >&2 ;;
- 		esac
- 		shift
-@@ -208,6 +209,15 @@
- 		do
- 			makedev ttyC$i c $major1 `expr 32 + $i` $tty
- 			makedev cub$i c $major2 `expr 32 + $i` $dialout
-+		done
-+		;;
-+	digi)
-+		major1=`Major ttyD` || continue
-+		major2=`Major cud` || continue
-+		for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-+		do
-+			makedev ttyD$i c $major1 `expr 32 + $i` $tty
-+			makedev cud$i c $major2 `expr 32 + $i` $dialout
- 		done
- 		;;
- 	par[0-2])
------ End Makedev patch
-
------------------------------------------------------------------------------
-
-Changes v1.5.5:
-
-The ability to use the kernel's command line to pass in the configuration for 
-boards.  Using LILO's APPEND command, a string of comma separated identifiers 
-or integers can be used.  The 6 values in order are:
-
-   Enable/Disable this card,
-   Type of card: PC/Xi(0), PC/Xe(1), PC/Xeve(2), PC/Xem(3)
-   Enable/Disable alternate pin arrangement,
-   Number of ports on this card,
-   I/O Port where card is configured (in HEX if using string identifiers),
-   Base of memory window (in HEX if using string identifiers), 
-
-Samples:
-   append="digi=E,PC/Xi,D,16,200,D0000"
-   append="digi=1,0,0,16,512,(whatever D0000 is in base 10 :)
-
-Drivers' minor device numbers are conserved. This means that instead of
-each board getting a block of 16 minors pre-assigned, it gets however
-many it should, with the next card following directly behind it.  A
-system with 4 2-port PC/Xi boards will use minor numbers 0-7.
-This conserves some memory, and removes a few hard coded constants.
-
-NOTE!! NOTE!! NOTE!!
-The definition of PC/Xem as a valid board type is the BEGINNING of support
-for this device.  The driver does not currently recognise the board, nor
-does it want to initialize it.  At least not the EISA version.
-
-Mike McLagan <mike.mclagan@linux.org> 5, April 1996.
diff -Nru a/Documentation/digiepca.txt b/Documentation/digiepca.txt
--- a/Documentation/digiepca.txt	2004-12-24 13:36:17 -08:00
+++ b/Documentation/digiepca.txt	2004-12-24 13:36:17 -08:00
@@ -1,3 +1,11 @@
+NOTE:  This driver is obsolete.  Digi provides a 2.6 driver (dgdm) at
+http://www.digi.com for PCI cards.  They no longer maintain this driver,
+and have no 2.6 driver for ISA cards.
+
+This driver requires a number of user-space tools.  They can be aquired from
+http://www.digi.com, but only works with 2.4 kernels.
+
+
 The Digi Intl. epca driver. 
 ----------------------------
 The Digi Intl. epca driver for Linux supports the following boards:
@@ -64,9 +72,6 @@
 this driver REQUIRES that digiDload be executed prior to it being used. 
 Failure to do this will result in an ENODEV error.
 
-The latest version of the tool package is available at:
-ftp://ftp.dgii.com/drivers/linux/released/async/
-
 Documentation:
 --------------
 Complete documentation for this product may be found in the tool package. 
@@ -74,14 +79,8 @@
 Sources of information and support:
 -----------------------------------
 Digi Intl. support site for this product:
--> digilnux@dgii.com 
 
-Related information and information concerning other drivers supporting 
-Digi Intl. products:
-
--> FTP: ftp://dgii.com
--> Webpage: http://www.dgii.com
--> Webpage: http://lameter.com/digi
+->  http://www.digi.com
 
 Acknowledgments:
 ----------------
@@ -90,3 +89,10 @@
 1994,1995 Troy De Jongh.  Many thanks to Christoph Lameter 
 (christoph@lameter.com) and Mike McLagan (mike.mclagan@linux.org) who authored 
 and contributed to the original document. 
+
+Changelog:
+----------
+10-29-04:	Update status of driver, remove dead links in document
+		James Nelson <james4765@gmail.com>
+
+2000 (?)	Original Document
diff -Nru a/Documentation/dnotify.txt b/Documentation/dnotify.txt
--- a/Documentation/dnotify.txt	2004-12-24 13:36:57 -08:00
+++ b/Documentation/dnotify.txt	2004-12-24 13:36:57 -08:00
@@ -54,6 +54,12 @@
 Also, files that are unlinked, will still cause notifications in the
 last directory that they were linked to.
 
+Configuration
+-------------
+
+Dnotify is controlled via the CONFIG_DNOTIFY configuration option.  When
+disabled, fcntl(fd, F_NOTIFY, ...) will return -EINVAL.
+
 Example
 -------
 
diff -Nru a/Documentation/dvb/README.dibusb b/Documentation/dvb/README.dibusb
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/dvb/README.dibusb	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,247 @@
+Documentation for dib3000mb frontend driver and dibusb device driver
+====================================================================
+
+Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de),
+
+dibusb and dib3000mb/mc drivers based on GPL code, which has
+
+Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+
+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, version 2.
+
+
+Supported devices USB1.1
+========================
+
+Produced and reselled by Twinhan:
+---------------------------------
+- TwinhanDTV USB-Ter DVB-T Device (VP7041)
+	http://www.twinhan.com/product_terrestrial_3.asp
+
+- TwinhanDTV Magic Box (VP7041e)
+	http://www.twinhan.com/product_terrestrial_4.asp
+
+- HAMA DVB-T USB device
+	http://www.hama.de/portal/articleId*110620/action*2598
+
+- CTS Portable (Chinese Television System)
+	http://www.2cts.tv/ctsportable/
+
+- Unknown USB DVB-T device with vendor ID Hyper-Paltek
+
+
+Produced and reselled by KWorld:
+--------------------------------
+- KWorld V-Stream XPERT DTV DVB-T USB
+	http://www.kworld.com.tw/en/product/DVBT-USB/DVBT-USB.html
+
+- JetWay DTV DVB-T USB
+	http://www.jetway.com.tw/evisn/product/lcd-tv/DVT-USB/dtv-usb.htm
+
+- ADSTech Instant TV DVB-T USB
+	http://www.adstech.com/products/PTV-333/intro/PTV-333_intro.asp?pid=PTV-333
+
+
+Others:
+-------
+- Ultima Electronic/Artec T1 USB TVBOX (AN2135 and AN2235)
+	http://82.161.246.249/products-tvbox.html
+
+- Compro Videomate DVB-U2000 - DVB-T USB
+	http://www.comprousa.com/products/vmu2000.htm
+
+- Grandtec USB DVB-T
+	http://www.grand.com.tw/
+
+- Avermedia AverTV DVBT USB
+	http://www.avermedia.com/
+
+- DiBcom USB DVB-T reference device (non-public)
+
+
+Supported devices USB2.0
+========================
+- Twinhan MagicBox II
+	http://www.twinhan.com/product_terrestrial_7.asp
+
+- Yakumo DVB-T mobile
+	http://www.yakumo.de/produkte/index.php?pid=1&ag=DVB-T
+
+- DiBcom USB2.0 DVB-T reference device (non-public)
+
+
+0. NEWS:
+  2004-12-06 - possibility for demod i2c-address probing
+             - new usb IDs (Compro,Artec)
+  2004-11-23 - merged changes from DiB3000MC_ver2.1
+             - revised the debugging
+             - possibility to deliver the complete TS for USB2.0
+  2004-11-21 - first working version of the dib3000mc/p frontend driver.
+  2004-11-12 - added additional remote control keys. Thanks to Uwe Hanke.
+  2004-11-07 - added remote control support. Thanks to David Matthews.
+  2004-11-05 - added support for a new devices (Grandtec/Avermedia/Artec)
+             - merged my changes (for dib3000mb/dibusb) to the FE_REFACTORING, because it became HEAD
+             - moved transfer control (pid filter, fifo control) from usb driver to frontend, it seems
+               better settled there (added xfer_ops-struct)
+             - created a common files for frontends (mc/p/mb)
+  2004-09-28 - added support for a new device (Unkown, vendor ID is Hyper-Paltek)
+  2004-09-20 - added support for a new device (Compro DVB-U2000), thanks
+               to Amaury Demol for reporting
+             - changed usb TS transfer method (several urbs, stopping transfer 
+               before setting a new pid)
+  2004-09-13 - added support for a new device (Artec T1 USB TVBOX), thanks
+               to Christian Motschke for reporting
+  2004-09-05 - released the dibusb device and dib3000mb-frontend driver
+
+  (old news for vp7041.c)
+  2004-07-15 - found out, by accident, that the device has a TUA6010XS for
+               PLL
+  2004-07-12 - figured out, that the driver should also work with the
+               CTS Portable (Chinese Television System)
+  2004-07-08 - firmware-extraction-2.422-problem solved, driver is now working
+               properly with firmware extracted from 2.422
+			 - #if for 2.6.4 (dvb), compile issue
+			 - changed firmware handling, see vp7041.txt sec 1.1
+  2004-07-02 - some tuner modifications, v0.1, cleanups, first public
+  2004-06-28 - now using the dvb_dmx_swfilter_packets, everything
+               runs fine now
+  2004-06-27 - able to watch and switching channels (pre-alpha)
+             - no section filtering yet
+  2004-06-06 - first TS received, but kernel oops :/
+  2004-05-14 - firmware loader is working
+  2004-05-11 - start writing the driver
+
+1. How to use?
+NOTE: This driver was developed using Linux 2.6.6.,
+it is working with 2.6.7, 2.6.8.1, 2.6.9 .
+
+Linux 2.4.x support is not planned, but patches are very welcome.
+
+NOTE: I'm using Debian testing, so the following explaination (especially
+the hotplug-path) needn't match your system, but probably it will :).
+
+1.1. Firmware
+
+The USB driver needs to download a firmware to start working.
+
+You can either use "get_dvb_firmware dibusb" to download the firmware or you
+can get it directly via
+
+for USB1.1 (AN2135)
+http://linuxtv.org/cgi-bin/cvsweb.cgi/dvb-kernel/firmware/dvb-dibusb-5.0.0.11.fw?rev=1.1&content-type=text/plain
+
+for USB1.1 (AN2235) (a few Artec T1 devices)
+http://linuxtv.org/cgi-bin/cvsweb.cgi/dvb-kernel/firmware/dvb-dibusb-an2235-1.fw?rev=1.1&content-type=text/plain
+
+for USB2.0 (FX2)
+http://linuxtv.org/cgi-bin/cvsweb.cgi/dvb-kernel/firmware/dvb-dibusb-6.0.0.5.fw?rev=1.1&content-type=text/plain
+
+1.2. Compiling
+
+Since the driver is in the linux kernel, activating the driver in
+your favorite config-environment should sufficient. I recommend
+to compile the driver as module. Hotplug does the rest.
+
+1.3. Loading the drivers
+
+Hotplug is able to load the driver, when it is needed (because you plugged
+in the device).
+
+If you want to enable debug output, you have to load the driver manually and
+from withing the dvb-kernel cvs repository.
+
+first have a look, which debug level are available:
+
+modinfo dib3000mb
+modinfo dvb-dibusb
+
+modprobe dib3000mb debug=<level>
+modprobe dvb-dibusb debug=<level>
+
+should do the trick.
+
+When the driver is loaded successfully, the firmware file was in
+the right place and the device is connected, the "Power"-LED should be
+turned on.
+
+At this point you should be able to start a dvb-capable application. For myself
+I used mplayer, dvbscan, tzap and kaxtv, they are working. Using the device
+as a slave device in vdr, was not working for me. Some work has to be done
+(patches and comments are very welcome).
+
+2. Known problems and bugs
+
+TODO:
+- signal-quality and strength calculations
+
+2.1. Adding support for devices 
+
+It is not possible to determine the range of devices based on the DiBcom
+reference designs. This is because the reference design of DiBcom can be sold
+to thirds, without telling DiBcom (so done with the Twinhan VP7041 and
+the HAMA device).
+
+When you think you have a device like this and the driver does not recognizes it,
+please send the ****load*.inf and the ****cap*.inf of the Windows driver to me.
+
+Sometimes the Vendor or Product ID is identical to the ones of Twinhan, even
+though it is not a Twinhan device (e.g. HAMA), then please send me the name
+of the device. I will add it to this list in order to make this clear to
+others.
+
+If you are familar with C you can also add the VID and PID of the device to
+the dvb-dibusb.h-file and create a patch and send it over to me or to 
+the linux-dvb mailing list, _after_ you have tried compiling and modprobing
+it.
+
+2.2. USB1.1 Bandwidth limitation
+
+Most of the current supported devices are USB1.1 and thus they have a
+maximum bandwidth of about 5-6 MBit/s when connected to a USB2.0 hub.
+This is not enough for receiving the complete transport stream of a
+DVB-T channel (which can be about 16 MBit/s). Normally this is not a
+problem, if you only want to watch TV, but watching a channel while
+recording another channel on the same frequency simply does not work.
+This applies to all USB1.1 DVB-T devices.
+
+A special problem of the dibusb for the USB1.1 is, that the USB control
+IC has a problem with write accesses while having MPEG2-streaming
+enabled. When you set another pid while receiving MPEG2-TS it happens, that
+the stream is disturbed and probably data is lost (results in distortions of
+the video or strange beeps within the audio stream). DiBcom is preparing a
+firmware especially for Linux which perhaps solves the problem.
+
+Especially VDR users are victoms of this bug. VDR frequently requests new PIDs
+due the automatic scanning (introduced in 1.3.x, afaik) and epg-scan. Disabling
+these features is maybe a solution. Additionally this behaviour of VDR exceeds
+the USB1.1 bandwidth.
+
+2.3. Comments
+
+Patches, comments and suggestions are very very welcome
+
+3. Acknowledgements
+	Amaury Demol (ademol@dibcom.fr) and Francois Kanounnikoff from DiBcom for
+	providing specs, code and help, on which the dvb-dibusb and dib3000mb are
+	based.
+
+   David Matthews for identifying a new device type (Artec T1 with AN2235)
+    and for extending dibusb with remote control event handling. Thank you.
+
+   Alex Woods for frequently answering question about usb and dvb
+    stuff, a big thank you
+
+   Bernd Wagner for helping with huge bug reports and discussions.
+
+   Some guys on the linux-dvb mailing list for encouraging me
+
+   Peter Schildmann >peter.schildmann-nospam-at-web.de< for his
+    user-level firmware loader, which saves a lot of time
+    (when writing the vp7041 driver)
+
+   Ulf Hermenau for helping me out with traditional chinese.
+
+   André Smoktun and Christian Frömmel for supporting me with
+    hardware and listening to my problems very patient
diff -Nru a/Documentation/dvb/avermedia.txt b/Documentation/dvb/avermedia.txt
--- a/Documentation/dvb/avermedia.txt	2004-12-24 13:37:01 -08:00
+++ b/Documentation/dvb/avermedia.txt	2004-12-24 13:37:01 -08:00
@@ -6,7 +6,6 @@
    Assumptions and Introduction
    The Avermedia DVB-T
    Getting the card going
-   Getting the Firmware
    Receiving DVB-T in Australia
    Known Limitations
    Further Update
@@ -149,28 +148,9 @@
    to start accessing the card with utilities such as scan, tzap,
    dvbstream etc.
 
-   The  current version of the frontend module sp887x.o, contains
-   no firmware drivers?, so the first time you open it with a DVB
-   utility  the driver will try to download some initial firmware
-   to  the card. You will need to download this firmware from the
-   web,  or  copy  it from an installation of the Windows drivers
-   that probably came with your card, before you can use it.
-
-   The  default  Linux  filesystem  location for this firmware is
-   /usr/lib/hotplug/firmware/sc_main.mc .
-     _________________________________________________________
-
-Getting the Firmware
-
-   As the firmware for the card is no longer contained within the
-   driver,  it  is  necessary  to  extract  it  from  the windows
-   drivers.
-
-   The  Windows  drivers  for the Avermedia DVB-T can be obtained
-   from: http://babyurl.com/H3U970 and you can get an application
-   to extract the firmware from:
-   http://www.kyz.uklinux.net/cabextract.php.
-     _________________________________________________________
+   The frontend module sp887x.o, requires an external   firmware.
+   Please use  the  command "get_dvb_firmware sp887x" to download
+   it. Then copy it to /usr/lib/hotplug/firmware.
 
 Receiving DVB-T in Australia
 
diff -Nru a/Documentation/dvb/cards.txt b/Documentation/dvb/cards.txt
--- a/Documentation/dvb/cards.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/dvb/cards.txt	2004-12-24 13:37:18 -08:00
@@ -38,6 +38,7 @@
                		  Comtech DVBT-6k07 (SP5730 PLL)
                		  (NxtWave Communications NXT6000 demodulator)
    - sp887x		: Microtune 7202D
+   - dib3000mb	: DiBcom 3000-MB demodulator
   DVB-S/C/T:
    - dst		: TwinHan DST Frontend
 
@@ -49,7 +50,7 @@
   - "budget" cards (i.e. without hardware MPEG decoder):
     - Technotrend Budget / Hauppauge WinTV-Nova PCI Cards
     - SATELCO Multimedia PCI
-    - KNC1 DVB-S
+    - KNC1 DVB-S, Typhoon DVB-S, Terratec Cinergy 1200 DVB-S (no CI support)
     - Typhoon DVB-S budget
     - Fujitsu-Siemens Activy DVB-S budget card
 
@@ -65,5 +66,20 @@
 o Technotrend / Hauppauge DVB USB devices:
   - Nova USB
   - DEC 2000-T, 3000-S, 2540-T
+
+o DiBcom DVB-T USB based devices:
+  - Twinhan VisionPlus VisionDTV USB-Ter DVB-T Device
+  - HAMA DVB-T USB device
+  - CTS Portable (Chinese Television System)
+  - KWorld V-Stream XPERT DTV DVB-T USB
+  - JetWay DTV DVB-T USB
+  - ADSTech Instant TV DVB-T USB
+  - Ultima Electronic/Artec T1 USB TVBOX (AN2135 and AN2235)
+  - Compro Videomate DVB-U2000 - DVB-T USB
+  - Grandtec USB DVB-T
+  - Avermedia AverTV DVBT USB
+  - DiBcom USB DVB-T reference device (non-public)
+  - Yakumo DVB-T mobile USB2.0
+  - DiBcom USB2.0 DVB-T reference device (non-public)
 
 o Experimental support for the analog module of the Siemens DVB-C PCI card
diff -Nru a/Documentation/dvb/contributors.txt b/Documentation/dvb/contributors.txt
--- a/Documentation/dvb/contributors.txt	2004-12-24 13:36:31 -08:00
+++ b/Documentation/dvb/contributors.txt	2004-12-24 13:36:31 -08:00
@@ -69,6 +69,8 @@
 Kenneth Aafløy <ke-aa@frisurf.no>
   for adding support for Typhoon DVB-S budget card
 
+Ernst Peinlich <e.peinlich@inode.at>
+  for tuning/DiSEqC support for the DEC 3000-s
 
 (If you think you should be in this list, but you are not, drop a
  line to the DVB mailing list)
diff -Nru a/Documentation/dvb/firmware.txt b/Documentation/dvb/firmware.txt
--- a/Documentation/dvb/firmware.txt	2004-12-24 13:37:44 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,120 +0,0 @@
-Some DVB cards and many newer frontends require proprietary,
-binary-only firmware.
-
-The DVB drivers will be converted to use the request_firmware()
-hotplug interface (see Documentation/firmware_class/).
-(CONFIG_FW_LOADER)
-
-The firmware can be loaded automatically via the hotplug manager
-or manually with the steps described below.
-
-Currently the drivers still use various different methods
-to load their firmwares, so here's just a short list of the
-current state:
-
-- dvb-ttpci: driver uses firmware hotplug interface
-- ttusb-budget: firmware is compiled in (dvb-ttusb-dspbootcode.h)
-- sp887x: firmware is compiled in (sp887x_firm.h)
-- alps_tdlb7: firmware is loaded from path specified by
-		"mcfile" module parameter; the binary must be
-		extracted from the Windows driver (Sc_main.mc).
-- tda1004x: firmware is loaded from path specified in
-		DVB_TDA1004X_FIRMWARE_FILE kernel config
-		variable (default /usr/lib/hotplug/firmware/tda1004x.bin); the
-		firmware binary must be extracted from the windows
-		driver
-- ttusb-dec: see "ttusb-dec.txt" for details
-
-1) Automatic firmware loading
-
-You need to install recent hotplug scripts if your distribution did not do it
-for you already, especially the  /etc/hotplug/firmware.agent.
-http://linux-hotplug.sourceforge.net/ (Call /sbin/hotplug without arguments
-to find out if the firmware agent is installed.)
-
-The firmware.agent script expects firmware binaries in
-/usr/lib/hotplug/firmware/. To avoid naming and versioning
-conflicts we propose the following naming scheme:
-
-  /usr/lib/hotplug/firmware/dvb-{driver}-{ver}.fw	for MPEG decoders etc.
-  /usr/lib/hotplug/firmware/dvb-fe-{driver}-{ver}.fw	for frontends
-
-  {driver} name is the basename of the driver kernel module (e.g. dvb-ttpci)
-  {ver} is a version number/name that should change only when the
-  driver/firmware internal API changes (so users are free to install the
-  latest firmware compatible with the driver).
-
-2) Manually loading the firmware into a driver
-   (currently only the dvb-ttpci / av7110 driver supports this)
-   
-Step a) Mount sysfs-filesystem.
-
-Sysfs provides a means to export kernel data structures, their attributes,
-and the linkages between them to userspace. 
-
-For detailed informations have a look at Documentation/filesystems/sysfs.txt 
-All you need to know at the moment is that firmware loading only works through
-sysfs.
-
-> mkdir /sys
-> mount -t sysfs sysfs /sys
-
-Step b) Exploring the firmware loading facilities
-
-Firmware_class support is located in
-/sys/class/firmware
-
-> dir /sys/class/firmware
-
-The "timeout" values specifies the amount of time that is waited before the
-firmware upload  process is cancelled. The default values is 10 seconds. If
-you use a hotplug script for the firmware upload, this is sufficient. If
-you want to upload the firmware by hand, however, this might be too fast.
-
-> echo "180" > /sys/class/firmware/timeout
-
-Step c) Getting a usable firmware file for the dvb-ttpci driver/av7110 card.
-
-You can download the firmware files from
-http://linuxtv.org/download/dvb/
-
-Please note that in case of the dvb-ttpci driver this is *not* the "Root"
-file you probably know from the 2.4 DVB releases driver.
-
-The ttpci-firmware utility from linuxtv.org CVS can be used to
-convert Dpram and Root files into a usable firmware image.
-See dvb-kerrnel/scripts/ in http://linuxtv.org/cvs/.
-
-> wget http://www.linuxtv.org/download/dvb/dvb-ttpci-01.fw
-gets you the version 01 of the firmware fot the ttpci driver.
-
-Step d) Loading the dvb-ttpci driver and loading the firmware
-
-"modprobe" will take care that every needed module will be loaded
-automatically (except the frontend driver)
-
-> modprobe dvb-ttpci
-
-The "modprobe" process will hang until
-a) you upload the firmware or
-b) the timeout occurs.
-
-Change to another terminal and have a look at 
-
-> dir /sys/class/firmware/
-
-total 0
-drwxr-xr-x    2 root     root            0 Jul 29 11:00 0000:03:05.0
--rw-r--r--    1 root     root            0 Jul 29 10:41 timeout
-
-"0000:03:05.0" is the id for my dvb-c card. It depends on the pci slot,
-so it changes if you plug the card to different slots.
-
-You can upload the firmware like that:
-
-> export DEVDIR=/sys/class/firmware/0000\:03\:05.0
-> echo 1 > $DEVDIR/loading
-> cat dvb-ttpci-01.fw > $DEVDIR/data
-> echo 0 > $DEVDIR/loading
-
-That's it. The driver should be up and running now.
diff -Nru a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/dvb/get_dvb_firmware	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,339 @@
+#!/usr/bin/perl
+#     DVB firmware extractor
+#
+#     (c) 2004 Andrew de Quincey
+#
+#     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.
+
+use File::Temp qw/ tempdir /;
+use IO::Handle;
+
+@components = ( "sp8870", "sp887x", "tda10045", "tda10046", "av7110", "dec2000t", "dec2540t", "dec3000s", "vp7041", "dibusb" );
+
+# Check args
+syntax() if (scalar(@ARGV) != 1);
+$cid = $ARGV[0];
+
+# Do it!
+for($i=0; $i < scalar(@components); $i++) {
+    if ($cid eq $components[$i]) {
+	$outfile = eval($cid);
+	die $@ if $@;
+	print STDERR "Firmware $outfile extracted successfully. Now copy it to either /lib/firmware or /usr/lib/hotplug/firmware/ (depending on your hotplug version).\n";
+	exit(0);
+    }
+}
+
+# If we get here, it wasn't found
+print STDERR "Unknown component \"$cid\"\n";
+syntax();
+
+
+
+
+# ---------------------------------------------------------------
+# Firmware-specific extraction subroutines
+
+sub sp8870 {
+    my $sourcefile = "tt_Premium_217g.zip";
+    my $url = "http://www.technotrend.de/new/217g/$sourcefile";
+    my $hash = "53970ec17a538945a6d8cb608a7b3899";
+    my $outfile = "dvb-fe-sp8870.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    verify("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $hash);
+    copy("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $outfile);
+
+    $outfile;
+}
+
+sub sp887x {
+    my $sourcefile = "Dvbt1.3.57.6.zip";
+    my $url = "http://www.avermedia.com/software/$sourcefile";
+    my $cabfile = "DVBT Net  Ver1.3.57.6/disk1/data1.cab";
+    my $hash = "237938d53a7f834c05c42b894ca68ac3";
+    my $outfile = "dvb-fe-sp887x.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+    checkunshield();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    unshield("$tmpdir/$cabfile", $tmpdir);
+    verify("$tmpdir/sc_main.mc", $hash);
+    copy("$tmpdir/sc_main.mc", $outfile);
+
+    $outfile;
+}
+
+sub tda10045 {
+    my $sourcefile = "tt_budget_217g.zip";
+    my $url = "http://www.technotrend.de/new/217g/$sourcefile";
+    my $hash = "2105fd5bf37842fbcdfa4bfd58f3594a";
+    my $outfile = "dvb-fe-tda10045.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x37ef9, 30555, "$tmpdir/fwtmp");
+    verify("$tmpdir/fwtmp", $hash);
+    copy("$tmpdir/fwtmp", $outfile);
+
+    $outfile;
+}
+
+sub tda10046 {
+    my $sourcefile = "tt_budget_217g.zip";
+    my $url = "http://www.technotrend.de/new/217g/$sourcefile";
+    my $hash = "a25b579e37109af60f4a36c37893957c";
+    my $outfile = "dvb-fe-tda10046.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x3f731, 24479, "$tmpdir/fwtmp");
+    verify("$tmpdir/fwtmp", $hash);
+    copy("$tmpdir/fwtmp", $outfile);
+
+    $outfile;
+}
+
+sub av7110 {
+    my $sourcefile = "dvb-ttpci-01.fw-261c";
+    my $url = "http://www.linuxtv.org/download/dvb/firmware/$sourcefile";
+    my $hash = "7b263de6b0b92d2347319c65adc7d4fb";
+    my $outfile = "dvb-ttpci-01.fw";
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    verify($sourcefile, $hash);
+    copy($sourcefile, $outfile);
+
+    $outfile;
+}
+
+sub dec2000t {
+    my $sourcefile = "dec217g.exe";
+    my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
+    my $hash = "bd86f458cee4a8f0a8ce2d20c66215a9";
+    my $outfile = "dvb-ttusb-dec-2000t.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $hash);
+    copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $outfile);
+
+    $outfile;
+}
+
+sub dec2540t {
+    my $sourcefile = "dec217g.exe";
+    my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
+    my $hash = "53e58f4f5b5c2930beee74a7681fed92";
+    my $outfile = "dvb-ttusb-dec-2540t.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $hash);
+    copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $outfile);
+
+    $outfile;
+}
+
+sub dec3000s {
+    my $sourcefile = "dec217g.exe";
+    my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
+    my $hash = "b013ececea83f4d6d8d2a29ac7c1b448";
+    my $outfile = "dvb-ttusb-dec-3000s.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $hash);
+    copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile);
+
+    $outfile;
+}
+
+sub vp7041 {
+    my $sourcefile = "2.422.zip";
+    my $url = "http://www.twinhan.com/files/driver/USB-Ter/$sourcefile";
+    my $hash = "e88c9372d1f66609a3e7b072c53fbcfe";
+    my $outfile = "dvb-vp7041-2.422.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 12503, 3036, "$tmpdir/fwtmp1");
+    extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 2207, 10274, "$tmpdir/fwtmp2");
+
+    my $CMD = "\000\001\000\222\177\000";
+    my $PAD = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000";
+    my ($FW);
+    open $FW, ">$tmpdir/fwtmp3";
+    print $FW "$CMD\001$PAD";
+    print $FW "$CMD\001$PAD";
+    appendfile($FW, "$tmpdir/fwtmp1");
+    print $FW "$CMD\000$PAD";
+    print $FW "$CMD\001$PAD";
+    appendfile($FW, "$tmpdir/fwtmp2");
+    print $FW "$CMD\001$PAD";
+    print $FW "$CMD\000$PAD";
+    close($FW);
+
+    verify("$tmpdir/fwtmp3", $hash);
+    copy("$tmpdir/fwtmp3", $outfile);
+
+    $outfile;
+}
+
+sub dibusb {
+	my $url = "http://linuxtv.org/cgi-bin/cvsweb.cgi/dvb-kernel/firmware/dvb-dibusb-5.0.0.11.fw?rev=1.1&content-type=text/plain";
+	my $outfile = "dvb-dibusb-5.0.0.11.fw";
+	my $hash = "fa490295a527360ca16dcdf3224ca243";
+
+	checkstandard();
+
+	wgetfile($outfile, $url);
+	verify($outfile,$hash);
+
+	$outfile;
+}
+
+# ---------------------------------------------------------------
+# Utilities
+
+sub checkstandard {
+    if (system("which unzip > /dev/null 2>&1")) {
+	die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n";
+    }
+    if (system("which md5sum > /dev/null 2>&1")) {
+	die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n";
+    }
+    if (system("which wget > /dev/null 2>&1")) {
+	die "This firmware requires the wget command - see http://wget.sunsite.dk/\n";
+    }
+}
+
+sub checkunshield {
+    if (system("which unshield > /dev/null 2>&1")) {
+	die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n";
+    }
+}
+
+sub wgetfile {
+    my ($sourcefile, $url) = @_;
+
+    if (! -f $sourcefile) {
+	system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware";
+    }
+}
+
+sub unzip {
+    my ($sourcefile, $todir) = @_;
+
+    $status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" );
+    if ((($status >> 8) > 2) || (($status & 0xff) != 0)) {
+	die ("unzip failed - unable to extract firmware");
+    }
+}
+
+sub unshield {
+    my ($sourcefile, $todir) = @_;
+
+    system("unshield -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware");
+}
+
+sub verify {
+    my ($filename, $hash) = @_;
+    my ($testhash);
+
+    open(CMD, "md5sum \"$filename\"|");
+    $testhash = <CMD>;
+    $testhash =~ /([a-zA-Z0-9]*)/;
+    $testhash = $1;
+    close CMD;
+    die "Hash of extracted file does not match!\n" if ($testhash ne $hash);
+}
+
+sub copy {
+    my ($from, $to) = @_;
+
+    system("cp -f \"$from\" \"$to\"") and die ("cp failed");
+}
+
+sub extract {
+    my ($infile, $offset, $length, $outfile) = @_;
+    my ($chunklength, $buf, $rcount);
+
+    open INFILE, "<$infile";
+    open OUTFILE, ">$outfile";
+    sysseek(INFILE, $offset, SEEK_SET);
+    while($length > 0) {
+	# Calc chunk size
+	$chunklength = 2048;
+	$chunklength = $length if ($chunklength > $length);
+
+	$rcount = sysread(INFILE, $buf, $chunklength);
+	die "Ran out of data\n" if ($rcount != $chunklength);
+	syswrite(OUTFILE, $buf);
+	$length -= $rcount;
+    }
+    close INFILE;
+    close OUTFILE;
+}
+
+sub appendfile {
+    my ($FH, $infile) = @_;
+    my ($buf);
+
+    open INFILE, "<$infile";
+    while(1) {
+	$rcount = sysread(INFILE, $buf, 2048);
+	last if ($rcount == 0);
+	print $FH $buf;
+    }
+    close(INFILE);
+}
+
+sub syntax() {
+    print STDERR "syntax: get_dvb_firmware <component>\n";
+    print STDERR "Supported components:\n";
+    for($i=0; $i < scalar(@components); $i++) {
+	print STDERR "\t" . $components[$i] . "\n";
+    }
+    exit(1);
+}
diff -Nru a/Documentation/dvb/readme.txt b/Documentation/dvb/readme.txt
--- a/Documentation/dvb/readme.txt	2004-12-24 13:36:18 -08:00
+++ b/Documentation/dvb/readme.txt	2004-12-24 13:36:18 -08:00
@@ -28,9 +28,9 @@
 "faq.txt"
 contains frequently asked questions and their answers.
 
-"firmware.txt" 
-contains informations for required external firmware
-files and where to get them.
+"get_dvb_firmware"
+script to download and extract firmware for those devices
+that require it.
 
 "ttusb-dec.txt"
 contains detailed informations about the
@@ -40,5 +40,12 @@
 contains detailed installation instructions for the
 various bt8xx based "budget" DVB cards
 (Nebula, Pinnacle PCTV, Twinhan DST)
+
+"README.dibusb"
+contains detailed information about adapters
+based on DiBcom reference design.
+
+"udev.txt"
+how to get DVB and udev up and running.
 
 Good luck and have fun!
diff -Nru a/Documentation/dvb/ttusb-dec.txt b/Documentation/dvb/ttusb-dec.txt
--- a/Documentation/dvb/ttusb-dec.txt	2004-12-24 13:37:32 -08:00
+++ b/Documentation/dvb/ttusb-dec.txt	2004-12-24 13:37:32 -08:00
@@ -6,6 +6,8 @@
 
 Supported:
 	DEC2000-t
+	DEC2450-t
+	DEC3000-s
 	Linux Kernels 2.4 and 2.6
 	Video Streaming
 	Audio Streaming
@@ -13,52 +15,30 @@
 	Channel Zapping
 	Hotplug firmware loader under 2.6 kernels
 
-In Progress:
-	DEC2540-t
-	DEC3000-s
-
 To Do:
 	Tuner status information
 	DVB network interface
 	Streaming video PC->DEC
+	Conax support for 2450-t
 
 Getting the Firmware
 --------------------
-The firmware can be found in the software update zip files on this page:
-http://www.hauppauge.de/sw_dec.htm
-
-The firmwares are named as follows:
-DEC2000-t:	STB_PC_T.bin
-DEC2540-t:	STB_PC_X.bin
-DEC3000-s:	STB_PC_S.bin
-
-Note that firmwares since version 2.16 beta2 for the DEC2000-t give the device
-the USB ID of the DEC3000-s.  The driver copes with this.
-
-Instructions follow for retrieving version 2.16 of the firmware:
-
-wget http://hauppauge.lightpath.net/de/dec216.exe
-unzip -j dec216.exe software/OEM/STB/App/Boot/STB_PC_T.bin
-unzip -j dec216.exe software/OEM/STB/App/Boot/STB_PC_X.bin
-unzip -j dec216.exe software/OEM/STB/App/Boot/STB_PC_S.bin
+To download the firmware, use the following commands:
+"get_dvb_firmware dec2000t"
+"get_dvb_firmware dec2540t"
+"get_dvb_firmware dec3000s"
 
 
 Compilation Notes for 2.4 kernels
 ---------------------------------
 For 2.4 kernels the firmware for the DECs is compiled into the driver itself.
-The firmwares are expected to be in the build-2.4 directory at compilation
-time.
 
-mv STB_PC_T.bin build-2.4/dvb-ttusb-dec-2000t.fw
-mv STB_PC_X.bin build-2.4/dvb-ttusb-dec-2540t.fw
-mv STB_PC_S.bin build-2.4/dvb-ttusb-dec-3000s.fw
+Copy the three files downloaded above into the build-2.4 directory.
 
 
 Hotplug Firmware Loading for 2.6 kernels
 ----------------------------------------
 For 2.6 kernels the firmware is loaded at the point that the driver module is
-loaded.  See Documentation/dvb/firmware.txt for more information.
+loaded.  See linux/Documentation/dvb/firmware.txt for more information.
 
-mv STB_PC_T.bin /usr/lib/hotplug/firmware/dvb-ttusb-dec-2000t.fw
-mv STB_PC_X.bin /usr/lib/hotplug/firmware/dvb-ttusb-dec-2540t.fw
-mv STB_PC_S.bin /usr/lib/hotplug/firmware/dvb-ttusb-dec-3000s.fw
+Copy the three files downloaded above into the /usr/lib/hotplug/firmware directory.
diff -Nru a/Documentation/dvb/udev.txt b/Documentation/dvb/udev.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/dvb/udev.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,46 @@
+The DVB subsystem currently registers to the sysfs subsystem using the
+"class_simple" interface.
+
+This means that only the basic informations like module loading parameters
+are presented through sysfs. Other things that might be interesting are
+currently *not* available.
+
+Nevertheless it's now possible to add proper udev rules so that the
+DVB device nodes are created automatically.
+
+We assume that you have udev already up and running and that have been
+creating the DVB device nodes manually up to now due to the missing sysfs
+support.
+
+0. Don't forget to disable your current method of creating the
+device nodes manually.
+
+1. Unfortunately, you'll need a helper script to transform the kernel
+sysfs device name into the well known dvb adapter / device naming scheme.
+The script should be called "dvb.sh" and should be placed into a script
+dir where udev can execute it, most likely /etc/udev/scripts/
+
+So, create a new file /etc/udev/scripts/dvb.sh and add the following:
+------------------------------schnipp------------------------------------------------
+#!/bin/sh
+/bin/echo $1 | /bin/sed -e 's,dvb\([0-9]\)\.\([^0-9]*\)\([0-9]\),dvb/adapter\1/\2\3,'
+------------------------------schnipp------------------------------------------------
+
+Don't forget to make the script executable with "chmod".
+
+1. You need to create a proper udev rule that will create the device nodes
+like you know them. All real distributions out there scan the /etc/udev/rules.d
+directory for rule files. The main udev configuration file /etc/udev/udev.conf
+will tell you the directory where the rules are, most likely it's /etc/udev/rules.d/
+
+Create a new rule file in that directory called "dvb.rule" and add the following line:
+------------------------------schnipp------------------------------------------------
+KERNEL="dvb*", PROGRAM="/etc/udev/scripts/dvb.sh %k", NAME="%c"
+------------------------------schnipp------------------------------------------------
+
+If you want more control over the device nodes (for example a special group membership)
+have a look at "man udev".
+
+For every device that registers to the sysfs subsystem with a "dvb" prefix,
+the helper script /etc/udev/scripts/dvb.sh is invoked, which will then
+create the proper device node in your /dev/ directory.
diff -Nru a/Documentation/fb/matroxfb.txt b/Documentation/fb/matroxfb.txt
--- a/Documentation/fb/matroxfb.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/fb/matroxfb.txt	2004-12-24 13:37:18 -08:00
@@ -223,6 +223,13 @@
 	   selects who is source of display clocks, whether G400, or panel.
 	   Default value is now read back from hardware - so you should specify
 	   this value only if you are also using `init' parameter.
+outputs:XYZ - set mapping between CRTC and outputs. Each letter can have value
+           of 0 (for no CRTC), 1 (CRTC1) or 2 (CRTC2), and first letter corresponds
+	   to primary analog output, second letter to the secondary analog output
+	   and third letter to the DVI output. Default setting is 100 for
+	   cards below G400 or G400 without DFP, 101 for G400 with DFP, and
+	   111 for G450 and G550. You can set mapping only on first card,
+	   use matroxset for setting up other devices.
 vesa:X   - selects startup videomode. X is number from 0 to 0x1FF, see table
            above for detailed explanation. Default is 640x480x8bpp if driver
 	   has 8bpp support. Otherwise first available of 640x350x4bpp,
diff -Nru a/Documentation/fb/vesafb.txt b/Documentation/fb/vesafb.txt
--- a/Documentation/fb/vesafb.txt	2004-12-24 13:37:03 -08:00
+++ b/Documentation/fb/vesafb.txt	2004-12-24 13:37:03 -08:00
@@ -146,10 +146,15 @@
 
 mtrr	setup memory type range registers for the vesafb framebuffer.
 
-vram:n	remap 'n' MiB of video RAM. If 0 or not specified, remap memory
+vremap:n
+        remap 'n' MiB of video RAM. If 0 or not specified, remap memory
 	according to video mode. (2.5.66 patch/idea by Antonino Daplas
 	reversed to give override possibility (allocate more fb memory
 	than the kernel would) to 2.4 by tmb@iki.fi)
+
+vtotal:n
+        if the video BIOS of your card incorrectly determines the total
+        amount of video RAM, use this option to override the BIOS (in MiB).
 
 Have fun!
 
diff -Nru a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
--- a/Documentation/filesystems/Locking	2004-12-24 13:37:19 -08:00
+++ b/Documentation/filesystems/Locking	2004-12-24 13:37:19 -08:00
@@ -295,13 +295,19 @@
 prototypes:
 	int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
 	void (*fl_notify)(struct file_lock *);  /* unblock callback */
+	void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
+	void (*fl_release_private)(struct file_lock *);
+	void (*fl_break)(struct file_lock *); /* break_lease callback */
 
 locking rules:
 			BKL	may block
 fl_compare_owner:	yes	no
 fl_notify:		yes	no
+fl_copy_lock:		yes	no
+fl_release_private:	yes	yes
+fl_break:		yes	no
 
-	Currently only NLM provides instances of this class. None of the
+	Currently only NFSD and NLM provide instances of this class. None of the
 them block. If you have out-of-tree instances - please, show up. Locking
 in that area will change.
 --------------------------- buffer_head -----------------------------------
@@ -311,8 +317,8 @@
 locking rules:
 	called from interrupts. In other words, extreme care is needed here.
 bh is locked, but that's all warranties we have here. Currently only RAID1,
-highmem and fs/buffer.c are providing these. Block devices call this method
-upon the IO completion.
+highmem, fs/buffer.c, and fs/ntfs/aops.c are providing these. Block devices
+call this method upon the IO completion.
 
 --------------------------- block_device_operations -----------------------
 prototypes:
diff -Nru a/Documentation/filesystems/devfs/ChangeLog b/Documentation/filesystems/devfs/ChangeLog
--- a/Documentation/filesystems/devfs/ChangeLog	2004-12-24 13:36:19 -08:00
+++ b/Documentation/filesystems/devfs/ChangeLog	2004-12-24 13:36:19 -08:00
@@ -1632,7 +1632,7 @@
 - Fixed bugs in handling symlinks: could leak or cause Oops
 
 - Cleaned up directory handling by separating fops
-  Thanks to Alexander Viro <viro@math.psu.edu>
+  Thanks to Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
 ===============================================================================
 Changes for patch v178
 
diff -Nru a/Documentation/filesystems/devfs/README b/Documentation/filesystems/devfs/README
--- a/Documentation/filesystems/devfs/README	2004-12-24 13:36:48 -08:00
+++ b/Documentation/filesystems/devfs/README	2004-12-24 13:36:48 -08:00
@@ -1349,47 +1349,6 @@
 point to the kernel-supplied names.
 
 
-SCSI Host Probing Issues
-
-Devfs allows you to identify SCSI discs based in part on SCSI host
-numbers. If you have only one SCSI host (card) in your computer, then
-clearly it will be given host number 0. Life is not always that easy
-is you have multiple SCSI hosts. Unfortunately, it can sometimes be
-difficult to guess what the probing order of SCSI hosts is. You need
-to know the probe order before you can use device names. To make this
-easy, there is a kernel boot parameter called "scsihosts". This allows
-you to specify the probe order for different types of SCSI hosts. The
-syntax of this parameter is:
-
-scsihosts=<name_1>:<name_2>:<name_3>:...:<name_n>
-
-where <name_1>,<name_2>,...,<name_n> are the names
-of drivers used in the /proc filesystem. For example:
-
-    scsihosts=aha1542:ppa:aha1542::ncr53c7xx
-
-
-means that devices connected to
-
-- first aha1542 controller   - will be /dev/scsi/host0/bus#/target#/lun#
-- first parallel port ZIP    - will be /dev/scsi/host1/bus#/target#/lun#
-- second aha1542 controller  - will be /dev/scsi/host2/bus#/target#/lun#
-- first NCR53C7xx controller - will be /dev/scsi/host4/bus#/target#/lun#
-- any extra controller       - will be /dev/scsi/host5/bus#/target#/lun#,
-                                       /dev/scsi/host6/bus#/target#/lun#, etc
-- if any of above controllers will not be found - the reserved names will
-  not be used by any other device.
-- /dev/scsi/host3/bus#/target#/lun# names will never be used
-
-
-You can use ',' instead of ':' as the separator character if you
-wish. I have used the devfsd naming scheme
-here.
-
-Note that this scheme does not address the SCSI host order if you have
-multiple cards of the same type (such as NCR53c8xx). In this case you
-need to use the driver-specific boot parameters to control this.
-
 -----------------------------------------------------------------------------
 
 
@@ -1951,12 +1910,6 @@
 
 
 Douglas Gilbert has written another useful document at
-
-http://www.torque.net/scsi/scsihosts.html which
-discusses the scsihosts= boot option
-
-
-Douglas Gilbert has written yet another useful document at
 
 http://www.torque.net/scsi/SCSI-2.4-HOWTO/ which
 discusses the Linux SCSI subsystem in 2.4.
diff -Nru a/Documentation/filesystems/ext2.txt b/Documentation/filesystems/ext2.txt
--- a/Documentation/filesystems/ext2.txt	2004-12-24 13:36:31 -08:00
+++ b/Documentation/filesystems/ext2.txt	2004-12-24 13:36:31 -08:00
@@ -11,56 +11,52 @@
 Options
 =======
 
-When mounting an ext2 filesystem, the following options are accepted.
-Defaults are marked with (*).
+Most defaults are determined by the filesystem superblock, and can be
+set using tune2fs(8). Kernel-determined defaults are indicated by (*).
 
 bsddf			(*)	Makes `df' act like BSD.
 minixdf				Makes `df' act like Minix.
 
-barrier=1			This enables/disables barriers. barrier=0 disables it,
-				barrier=1 enables it.
-
-orlov			(*)	This enables the new Orlov block allocator. It's
-				enabled by default.
-
-oldalloc			This disables the Orlov block allocator and
-				enables the old block allocator. Orlov should
-				have better performance, we'd like to get some
-				feedback  if it's the contrary for you.
-
-user_xattr		(*)	Enables POSIX Extended Attributes. It's enabled by
-				default, however you need to confifure its support
-				(CONFIG_EXT2_FS_XATTR). This is neccesary if you want
-				to use POSIX Acces Control Lists support. You can visit
-				http://acl.bestbits.at to know more about POSIX Extended
-				attributes.
-
-nouser_xattr			Disables POSIX Extended Attributes.
-
-acl			(*)	Enables POSIX Access Control Lists support. This is
-				enabled by default, however you need to configure
-				its support (CONFIG_EXT2_FS_POSIX_ACL). If you want
-				to know more about ACLs visit http://acl.bestbits.at
-
-noacl				This option disables POSIX Access Control List support.
-
+check				Check block and inode bitmaps at mount time
+				(requires CONFIG_EXT2_CHECK).
 check=none, nocheck	(*)	Don't do extra checking of bitmaps on mount
 				(check=normal and check=strict options removed)
 
 debug				Extra debugging information is sent to the
 				kernel syslog.  Useful for developers.
 
-errors=continue		(*)	Keep going on a filesystem error.
+errors=continue			Keep going on a filesystem error.
 errors=remount-ro		Remount the filesystem read-only on an error.
 errors=panic			Panic and halt the machine if an error occurs.
 
 grpid, bsdgroups		Give objects the same group ID as their parent.
-nogrpid, sysvgroups	(*)	New objects have the group ID of their creator.
+nogrpid, sysvgroups		New objects have the group ID of their creator.
+
+nouid32				Use 16-bit UIDs and GIDs.
+
+oldalloc			Enable the old block allocator. Orlov should
+				have better performance, we'd like to get some
+				feedback if it's the contrary for you.
+orlov			(*)	Use the Orlov block allocator.
+				(See http://lwn.net/Articles/14633/ and
+				http://lwn.net/Articles/14446/.)
 
 resuid=n			The user ID which may use the reserved blocks.
-resgid=n			The group ID which may use the reserved blocks. 
+resgid=n			The group ID which may use the reserved blocks.
 
 sb=n				Use alternate superblock at this location.
+
+user_xattr			Enable "user." POSIX Extended Attributes
+				(requires CONFIG_EXT2_FS_XATTR).
+				See also http://acl.bestbits.at
+nouser_xattr			Don't support "user." extended attributes.
+
+acl				Enable POSIX Access Control Lists support
+				(requires CONFIG_EXT2_FS_POSIX_ACL).
+				See also http://acl.bestbits.at
+noacl				Don't support POSIX ACLs.
+
+nobh				Do not attach buffer_heads to file pagecache.
 
 grpquota,noquota,quota,usrquota	Quota options are silently ignored by ext2.
 
diff -Nru a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt
--- a/Documentation/filesystems/ntfs.txt	2004-12-24 13:36:55 -08:00
+++ b/Documentation/filesystems/ntfs.txt	2004-12-24 13:36:55 -08:00
@@ -10,8 +10,10 @@
 - Features
 - Supported mount options
 - Known bugs and (mis-)features
-- Using Software RAID with NTFS
-- Limitiations when using the MD driver
+- Using NTFS volume and stripe sets
+  - The Device-Mapper driver
+  - The Software RAID / MD driver
+  - Limitiations when using the MD driver
 - ChangeLog
 
 
@@ -199,11 +201,161 @@
 list at sourceforge: linux-ntfs-dev@lists.sourceforge.net
 
 
-Using Software RAID with NTFS
-=============================
+Using NTFS volume and stripe sets
+=================================
 
-For support of volume and stripe sets, use the kernel's Software RAID / MD
-driver and set up your /etc/raidtab appropriately (see man 5 raidtab).
+For support of volume and stripe sets, you can either use the kernel's
+Device-Mapper driver or the kernel's Software RAID / MD driver.  The former is
+the recommended one to use for linear raid.  But the latter is required for
+raid level 5.  For striping and mirroring, either driver should work fine.
+
+
+The Device-Mapper driver
+------------------------
+
+You will need to create a table of the components of the volume/stripe set and
+how they fit together and load this into the kernel using the dmsetup utility
+(see man 8 dmsetup).
+
+Linear volume sets, i.e. linear raid, has been tested and works fine.  Even
+though untested, there is no reason why stripe sets, i.e. raid level 0, and
+mirrors, i.e. raid level 1 should not work, too.  Stripes with parity, i.e.
+raid level 5, unfortunately cannot work yet because the current version of the
+Device-Mapper driver does not support raid level 5.  You may be able to use the
+Software RAID / MD driver for raid level 5, see the next section for details.
+
+To create the table describing your volume you will need to know each of its
+components and their sizes in sectors, i.e. multiples of 512-byte blocks.
+
+For NT4 fault tolerant volumes you can obtain the sizes using fdisk.  So for
+example if one of your partitions is /dev/hda2 you would do:
+
+$ fdisk -ul /dev/hda
+
+Disk /dev/hda: 81.9 GB, 81964302336 bytes
+255 heads, 63 sectors/track, 9964 cylinders, total 160086528 sectors
+Units = sectors of 1 * 512 = 512 bytes
+
+   Device Boot      Start         End      Blocks   Id  System
+   /dev/hda1   *          63     4209029     2104483+  83  Linux
+   /dev/hda2         4209030    37768814    16779892+  86  NTFS
+   /dev/hda3        37768815    46170809     4200997+  83  Linux
+
+And you would know that /dev/hda2 has a size of 37768814 - 4209030 + 1 =
+33559785 sectors.
+
+For Win2k and later dynamic disks, you can for example use the ldminfo utility
+which is part of the Linux LDM tools (the latest version at the time of
+writing is linux-ldm-0.0.8.tar.bz2).  You can download it from:
+	http://linux-ntfs.sourceforge.net/downloads.html
+Simply extract the downloaded archive (tar xvjf linux-ldm-0.0.8.tar.bz2), go
+into it (cd linux-ldm-0.0.8) and change to the test directory (cd test).  You
+will find the precompiled (i386) ldminfo utility there.  NOTE: You will not be
+able to compile this yourself easily so use the binary version!
+
+Then you would use ldminfo in dump mode to obtain the necessary information:
+
+$ ./ldminfo --dump /dev/hda
+
+This would dump the LDM database found on /dev/hda which describes all of your
+dynamic disks and all the volumes on them.  At the bottom you will see the
+VOLUME DEFINITIONS section which is all you really need.  You may need to look
+further above to determine which of the disks in the volume definitions is
+which device in Linux.  Hint: Run ldminfo on each of your dynamic disks and
+look at the Disk Id close to the top of the output for each (the PRIVATE HEADER
+section).  You can then find these Disk Ids in the VBLK DATABASE section in the
+<Disk> components where you will get the LDM Name for the disk that is found in
+the VOLUME DEFINITIONS section.
+
+Note you will also need to enable the LDM driver in the Linux kernel.  If your
+distribution did not enable it, you will need to recompile the kernel with it
+enabled.  This will create the LDM partitions on each device at boot time.  You
+would then use those devices (for /dev/hda they would be /dev/hda1, 2, 3, etc)
+in the Device-Mapper table.
+
+You can also bypass using the LDM driver by using the main device (e.g.
+/dev/hda) and then using the offsets of the LDM partitions into this device as
+the "Start sector of device" when creating the table.  Once again ldminfo would
+give you the correct information to do this.
+
+Assuming you know all your devices and their sizes things are easy.
+
+For a linear raid the table would look like this (note all values are in
+512-byte sectors):
+
+--- cut here ---
+# Offset into	Size of this	Raid type	Device		Start sector
+# volume	device						of device
+0		1028161		linear		/dev/hda1	0
+1028161		3903762		linear		/dev/hdb2	0
+4931923		2103211		linear		/dev/hdc1	0
+--- cut here ---
+
+For a striped volume, i.e. raid level 0, you will need to know the chunk size
+you used when creating the volume.  Windows uses 64kiB as the default, so it
+will probably be this unless you changes the defaults when creating the array.
+
+For a raid level 0 the table would look like this (note all values are in
+512-byte sectors):
+
+--- cut here ---
+# Offset   Size	    Raid     Number   Chunk  1st        Start	2nd	  Start
+# into     of the   type     of	      size   Device	in	Device	  in
+# volume   volume	     stripes			device		  device
+0	   2056320  striped  2	      128    /dev/hda1	0	/dev/hdb1 0
+--- cut here ---
+
+If there are more than two devices, just add each of them to the end of the
+line.
+
+Finally, for a mirrored volume, i.e. raid level 1, the table would look like
+this (note all values are in 512-byte sectors):
+
+--- cut here ---
+# Ofs Size   Raid   Log  Number Region Should Number Source  Start Taget  Start
+# in  of the type   type of log size   sync?  of     Device  in    Device in
+# vol volume		 params		     mirrors	     Device	  Device
+0    2056320 mirror core 2	16     nosync 2	   /dev/hda1 0   /dev/hdb1 0
+--- cut here ---
+
+If you are mirroring to multiple devices you can specify further targets at the
+end of the line.
+
+Note the "Should sync?" parameter "nosync" means that the two mirrors are
+already in sync which will be the case on a clean shutdown of Windows.  If the
+mirrors are not clean, you can specify the "sync" option instead of "nosync"
+and the Device-Mapper driver will then copy the entirey of the "Source Device"
+to the "Target Device" or if you specified multipled target devices to all of
+them.
+
+Once you have your table, save it in a file somewhere (e.g. /etc/ntfsvolume1),
+and hand it over to dmsetup to work with, like so:
+
+$ dmsetup create myvolume1 /etc/ntfsvolume1
+
+You can obviously replace "myvolume1" with whatever name you like.
+
+If it all worked, you will now have the device /dev/device-mapper/myvolume1
+which you can then just use as an argument to the mount command as usual to
+mount the ntfs volume.  For example:
+
+$ mount -t ntfs -o ro /dev/device-mapper/myvolume1 /mnt/myvol1
+
+(You need to create the directory /mnt/myvol1 first and of course you can use
+anything you like instead of /mnt/myvol1 as long as it is an existing
+directory.)
+
+It is advisable to do the mount read-only to see if the volume has been setup
+correctly to avoid the possibility of causing damage to the data on the ntfs
+volume.
+
+
+The Software RAID / MD driver
+-----------------------------
+
+An alternative to using the Device-Mapper driver is to use the kernel's
+Software RAID / MD driver.  For which you need to set up your /etc/raidtab
+appropriately (see man 5 raidtab).
 
 Linear volume sets, i.e. linear raid, as well as stripe sets, i.e. raid level
 0, have been tested and work fine (though see section "Limitiations when using
@@ -258,8 +410,8 @@
 ntfs volume.
 
 
-Limitiations when using the MD driver
-=====================================
+Limitiations when using the Software RAID / MD driver
+-----------------------------------------------------
 
 Using the md driver will not work properly if any of your NTFS partitions have
 an odd number of sectors.  This is especially important for linear raid as all
@@ -271,12 +423,24 @@
 So when using linear raid, make sure that all your partitions have an even
 number of sectors BEFORE attempting to use it.  You have been warned!
 
+Even better is to simply use the Device-Mapper for linear raid and then you do
+not have this problem with odd numbers of sectors.
+
 
 ChangeLog
 =========
 
 Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
 
+2.1.22:
+	- Improve handling of ntfs volumes with errors.
+	- Fix various bugs and race conditions.
+2.1.21:
+	- Fix several race conditions and various other bugs.
+	- Many internal cleanups, code reorganization, optimizations, and mft
+	  and index record writing code rewritten to fit in with the changes.
+	- Update Documentation/filesystems/ntfs.txt with instructions on how to
+	  use the Device-Mapper driver with NTFS ftdisk/LDM raid.
 2.1.20:
 	- Fix two stupid bugs introduced in 2.1.18 release.
 2.1.19:
diff -Nru a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
--- a/Documentation/filesystems/proc.txt	2004-12-24 13:36:31 -08:00
+++ b/Documentation/filesystems/proc.txt	2004-12-24 13:36:31 -08:00
@@ -350,22 +350,6 @@
 ZONE_DMA, 4 chunks of 2^1*PAGE_SIZE in ZONE_DMA, 101 chunks of 2^4*PAGE_SIZE 
 available in ZONE_NORMAL, etc... 
 
-
-1.3 IDE devices in /proc/ide
-----------------------------
-
-The subdirectory /proc/ide contains information about all IDE devices of which
-the kernel  is  aware.  There is one subdirectory for each IDE controller, the
-file drivers  and a link for each IDE device, pointing to the device directory
-in the controller specific subtree.
-
-The file  drivers  contains general information about the drivers used for the
-IDE devices:
-
-  > cat /proc/ide/drivers 
-  ide-cdrom version 4.53 
-  ide-disk version 1.08 
-
 ..............................................................................
 
 meminfo:
@@ -394,9 +378,9 @@
 Writeback:           0 kB
 Mapped:         280372 kB
 Slab:           684068 kB
-Committed_AS:  1576424 kB
+CommitLimit:   7669796 kB
+Committed_AS:   100056 kB
 PageTables:      24448 kB
-ReverseMaps:   1080904
 VmallocTotal:   112216 kB
 VmallocUsed:       428 kB
 VmallocChunk:   111088 kB
@@ -434,26 +418,54 @@
    Writeback: Memory which is actively being written back to the disk
       Mapped: files which have been mmaped, such as libraries
               Slab: in-kernel data structures cache
-Committed_AS: An estimate of how much RAM you would need to make a
-              99.99% guarantee that there never is OOM (out of memory)
-              for this workload. Normally the kernel will overcommit
-              memory. That means, say you do a 1GB malloc, nothing
-              happens, really. Only when you start USING that malloc
-              memory you will get real memory on demand, and just as
-              much as you use. So you sort of take a mortgage and hope
-              the bank doesn't go bust. Other cases might include when
-              you mmap a file that's shared only when you write to it
-              and you get a private copy of that data. While it normally
-              is shared between processes. The Committed_AS is a
-              guesstimate of how much RAM/swap you would need
-              worst-case.
+ CommitLimit: Based on the overcommit ratio ('vm.overcommit_ratio'),
+              this is the total amount of  memory currently available to
+              be allocated on the system. This limit is only adhered to
+              if strict overcommit accounting is enabled (mode 2 in
+              'vm.overcommit_memory').
+              The CommitLimit is calculated with the following formula:
+              CommitLimit = ('vm.overcommit_ratio' * Physical RAM) + Swap
+              For example, on a system with 1G of physical RAM and 7G
+              of swap with a `vm.overcommit_ratio` of 30 it would
+              yield a CommitLimit of 7.3G.
+              For more details, see the memory overcommit documentation
+              in vm/overcommit-accounting.
+Committed_AS: The amount of memory presently allocated on the system.
+              The committed memory is a sum of all of the memory which
+              has been allocated by processes, even if it has not been
+              "used" by them as of yet. A process which malloc()'s 1G
+              of memory, but only touches 300M of it will only show up
+              as using 300M of memory even if it has the address space
+              allocated for the entire 1G. This 1G is memory which has
+              been "committed" to by the VM and can be used at any time
+              by the allocating application. With strict overcommit
+              enabled on the system (mode 2 in 'vm.overcommit_memory'),
+              allocations which would exceed the CommitLimit (detailed
+              above) will not be permitted. This is useful if one needs
+              to guarantee that processes will not fail due to lack of
+              memory once that memory has been successfully allocated.
   PageTables: amount of memory dedicated to the lowest level of page
               tables.
- ReverseMaps: number of reverse mappings performed
 VmallocTotal: total size of vmalloc memory area
  VmallocUsed: amount of vmalloc area which is used
 VmallocChunk: largest contigious block of vmalloc area which is free
 
+
+1.3 IDE devices in /proc/ide
+----------------------------
+
+The subdirectory /proc/ide contains information about all IDE devices of which
+the kernel  is  aware.  There is one subdirectory for each IDE controller, the
+file drivers  and a link for each IDE device, pointing to the device directory
+in the controller specific subtree.
+
+The file  drivers  contains general information about the drivers used for the
+IDE devices:
+
+  > cat /proc/ide/drivers
+  ide-cdrom version 4.53
+  ide-disk version 1.08
+
 More detailed  information  can  be  found  in  the  controller  specific
 subdirectories. These  are  named  ide0,  ide1  and  so  on.  Each  of  these
 directories contains the files shown in table 1-4.
@@ -1268,6 +1280,14 @@
 
 block_dump enables block I/O debugging when set to a nonzero value. More
 information on block I/O debugging is in Documentation/laptop-mode.txt.
+
+swap_token_timeout
+------------------
+
+This file contains valid hold time of swap out protection token. The Linux
+VM has token based thrashing control mechanism and uses the token to prevent
+unnecessary page faults in thrashing situation. The unit of the value is
+second. The value would be useful to tune thrashing behavior.
 
 2.5 /proc/sys/dev - Device specific parameters
 ----------------------------------------------
diff -Nru a/Documentation/filesystems/ufs.txt b/Documentation/filesystems/ufs.txt
--- a/Documentation/filesystems/ufs.txt	2004-12-24 13:37:03 -08:00
+++ b/Documentation/filesystems/ufs.txt	2004-12-24 13:37:03 -08:00
@@ -15,13 +15,15 @@
 	ufs manually by mount option ufstype. Possible values are:
 
 	old	old format of ufs
-		default value, supported os read-only
+		default value, supported as read-only
 
 	44bsd	used in FreeBSD, NetBSD, OpenBSD
-		supported os read-write
+		supported as read-write
+
+	ufs2    used in FreeBSD 5.x
+		supported as read-only
 
-       ufs2    used in FreeBSD 5.x
-               supported os read-only
+	5xbsd	synonym for ufs2
 
 	sun	used in SunOS (Solaris)
 		supported as read-write
@@ -29,6 +31,9 @@
 	sunx86	used in SunOS for Intel (Solarisx86)
 		supported as read-write
 
+	hp	used in HP-UX
+		supported as read-only
+
 	nextstep
 		used in NextStep
 		supported as read-only
@@ -46,7 +51,7 @@
 =================
 
 There is still bug in reallocation of fragment, in file fs/ufs/balloc.c, 
-line 364. But it seem working on current buffer cache configuration.
+line 364. But it seems working on current buffer cache configuration.
 
 
 BUG REPORTS
diff -Nru a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
--- a/Documentation/filesystems/vfs.txt	2004-12-24 13:37:01 -08:00
+++ b/Documentation/filesystems/vfs.txt	2004-12-24 13:37:01 -08:00
@@ -44,7 +44,7 @@
 The VFS implements the open(2), stat(2), chmod(2) and similar system
 calls. The pathname argument is used by the VFS to search through the
 directory entry cache (dentry cache or "dcache"). This provides a very
-fast lookup mechanism to translate a pathname (filename) into a
+fast look-up mechanism to translate a pathname (filename) into a
 specific dentry.
 
 An individual dentry usually has a pointer to an inode. Inodes are the
@@ -64,7 +64,7 @@
 creating dentries along the way, and then loading the inode. This is
 done by looking up the inode.
 
-To lookup an inode (usually read from disc) requires that the VFS
+To look up an inode (usually read from disc) requires that the VFS
 calls the lookup() method of the parent directory inode. This method
 is installed by the specific filesystem implementation that the inode
 lives in. There will be more on this later.
@@ -286,7 +286,7 @@
 	dentry). Here you will probably call d_instantiate() with the
 	dentry and the newly created inode
 
-  lookup: called when the VFS needs to lookup an inode in a parent
+  lookup: called when the VFS needs to look up an inode in a parent
 	directory. The name to look for is found in the dentry. This
 	method must call d_add() to insert the found inode into the
 	dentry. The "i_count" field in the inode structure should be
@@ -405,7 +405,10 @@
 patch).
 
 
-struct dentry_operations                                              <section>
+Directory Entry Cache (dcache)                                        <section>
+------------------------------
+
+struct dentry_operations
 ========================
 
 This describes how a filesystem can overload the standard dentry
@@ -425,7 +428,7 @@
 };
 
   d_revalidate: called when the VFS needs to revalidate a dentry. This
-	is called whenever a name lookup finds a dentry in the
+	is called whenever a name look-up finds a dentry in the
 	dcache. Most filesystems leave this as NULL, because all their
 	dentries in the dcache are valid
 
@@ -448,6 +451,9 @@
 of child dentries. Child dentries are basically like files in a
 directory.
 
+Directory Entry Cache APIs
+--------------------------
+
 There are a number of functions defined which permit a filesystem to
 manipulate dentries:
 
@@ -482,3 +488,184 @@
 	pointer is NULL, the dentry is called a "negative
 	dentry". This function is commonly called when an inode is
 	created for an existing negative dentry
+
+  d_lookup: look up a dentry given its parent and path name component
+	It looks up the child of that given name from the dcache
+	hash table. If it is found, the reference count is incremented
+	and the dentry is returned. The caller must use d_put()
+	to free the dentry when it finishes using it.
+
+
+RCU-based dcache locking model
+------------------------------
+
+On many workloads, the most common operation on dcache is
+to look up a dentry, given a parent dentry and the name
+of the child. Typically, for every open(), stat() etc.,
+the dentry corresponding to the pathname will be looked
+up by walking the tree starting with the first component
+of the pathname and using that dentry along with the next
+component to look up the next level and so on. Since it
+is a frequent operation for workloads like multiuser
+environments and webservers, it is important to optimize
+this path.
+
+Prior to 2.5.10, dcache_lock was acquired in d_lookup and thus
+in every component during path look-up. Since 2.5.10 onwards,
+fastwalk algorithm changed this by holding the dcache_lock
+at the beginning and walking as many cached path component
+dentries as possible. This signficantly decreases the number
+of acquisition of dcache_lock. However it also increases the
+lock hold time signficantly and affects performance in large
+SMP machines. Since 2.5.62 kernel, dcache has been using
+a new locking model that uses RCU to make dcache look-up
+lock-free.
+
+The current dcache locking model is not very different from the existing
+dcache locking model. Prior to 2.5.62 kernel, dcache_lock
+protected the hash chain, d_child, d_alias, d_lru lists as well
+as d_inode and several other things like mount look-up. RCU-based
+changes affect only the way the hash chain is protected. For everything
+else the dcache_lock must be taken for both traversing as well as
+updating. The hash chain updations too take the dcache_lock.
+The significant change is the way d_lookup traverses the hash chain,
+it doesn't acquire the dcache_lock for this and rely on RCU to
+ensure that the dentry has not been *freed*.
+
+
+Dcache locking details
+----------------------
+For many multi-user workloads, open() and stat() on files are
+very frequently occurring operations. Both involve walking
+of path names to find the dentry corresponding to the
+concerned file. In 2.4 kernel, dcache_lock was held
+during look-up of each path component. Contention and
+cacheline bouncing of this global lock caused significant
+scalability problems. With the introduction of RCU
+in linux kernel, this was worked around by making
+the look-up of path components during path walking lock-free.
+
+
+Safe lock-free look-up of dcache hash table
+===========================================
+
+Dcache is a complex data structure with the hash table entries
+also linked together in other lists. In 2.4 kernel, dcache_lock
+protected all the lists. We applied RCU only on hash chain
+walking. The rest of the lists are still protected by dcache_lock.
+Some of the important changes are :
+
+1. The deletion from hash chain is done using hlist_del_rcu() macro which
+   doesn't initialize next pointer of the deleted dentry and this
+   allows us to walk safely lock-free while a deletion is happening.
+
+2. Insertion of a dentry into the hash table is done using
+   hlist_add_head_rcu() which take care of ordering the writes -
+   the writes to the dentry must be visible before the dentry
+   is inserted. This works in conjuction with hlist_for_each_rcu()
+   while walking the hash chain. The only requirement is that
+   all initialization to the dentry must be done before hlist_add_head_rcu()
+   since we don't have dcache_lock protection while traversing
+   the hash chain. This isn't different from the existing code.
+
+3. The dentry looked up without holding dcache_lock by cannot be
+   returned for walking if it is unhashed. It then may have a NULL
+   d_inode or other bogosity since RCU doesn't protect the other
+   fields in the dentry. We therefore use a flag DCACHE_UNHASHED to
+   indicate unhashed  dentries and use this in conjunction with a
+   per-dentry lock (d_lock). Once looked up without the dcache_lock,
+   we acquire the per-dentry lock (d_lock) and check if the
+   dentry is unhashed. If so, the look-up is failed. If not, the
+   reference count of the dentry is increased and the dentry is returned.
+
+4. Once a dentry is looked up, it must be ensured during the path
+   walk for that component it doesn't go away. In pre-2.5.10 code,
+   this was done holding a reference to the dentry. dcache_rcu does
+   the same.  In some sense, dcache_rcu path walking looks like
+   the pre-2.5.10 version.
+
+5. All dentry hash chain updations must take the dcache_lock as well as
+   the per-dentry lock in that order. dput() does this to ensure
+   that a dentry that has just been looked up in another CPU
+   doesn't get deleted before dget() can be done on it.
+
+6. There are several ways to do reference counting of RCU protected
+   objects. One such example is in ipv4 route cache where
+   deferred freeing (using call_rcu()) is done as soon as
+   the reference count goes to zero. This cannot be done in
+   the case of dentries because tearing down of dentries
+   require blocking (dentry_iput()) which isn't supported from
+   RCU callbacks. Instead, tearing down of dentries happen
+   synchronously in dput(), but actual freeing happens later
+   when RCU grace period is over. This allows safe lock-free
+   walking of the hash chains, but a matched dentry may have
+   been partially torn down. The checking of DCACHE_UNHASHED
+   flag with d_lock held detects such dentries and prevents
+   them from being returned from look-up.
+
+
+Maintaining POSIX rename semantics
+==================================
+
+Since look-up of dentries is lock-free, it can race against
+a concurrent rename operation. For example, during rename
+of file A to B, look-up of either A or B must succeed.
+So, if look-up of B happens after A has been removed from the
+hash chain but not added to the new hash chain, it may fail.
+Also, a comparison while the name is being written concurrently
+by a rename may result in false positive matches violating
+rename semantics.  Issues related to race with rename are
+handled as described below :
+
+1. Look-up can be done in two ways - d_lookup() which is safe
+   from simultaneous renames and __d_lookup() which is not.
+   If __d_lookup() fails, it must be followed up by a d_lookup()
+   to correctly determine whether a dentry is in the hash table
+   or not. d_lookup() protects look-ups using a sequence
+   lock (rename_lock).
+
+2. The name associated with a dentry (d_name) may be changed if
+   a rename is allowed to happen simultaneously. To avoid memcmp()
+   in __d_lookup() go out of bounds due to a rename and false
+   positive comparison, the name comparison is done while holding the
+   per-dentry lock. This prevents concurrent renames during this
+   operation.
+
+3. Hash table walking during look-up may move to a different bucket as
+   the current dentry is moved to a different bucket due to rename.
+   But we use hlists in dcache hash table and they are null-terminated.
+   So, even if a dentry moves to a different bucket, hash chain
+   walk will terminate. [with a list_head list, it may not since
+   termination is when the list_head in the original bucket is reached].
+   Since we redo the d_parent check and compare name while holding
+   d_lock, lock-free look-up will not race against d_move().
+
+4. There can be a theoritical race when a dentry keeps coming back
+   to original bucket due to double moves. Due to this look-up may
+   consider that it has never moved and can end up in a infinite loop.
+   But this is not any worse that theoritical livelocks we already
+   have in the kernel.
+
+
+Important guidelines for filesystem developers related to dcache_rcu
+====================================================================
+
+1. Existing dcache interfaces (pre-2.5.62) exported to filesystem
+   don't change. Only dcache internal implementation changes. However
+   filesystems *must not* delete from the dentry hash chains directly
+   using the list macros like allowed earlier. They must use dcache
+   APIs like d_drop() or __d_drop() depending on the situation.
+
+2. d_flags is now protected by a per-dentry lock (d_lock). All
+   access to d_flags must be protected by it.
+
+3. For a hashed dentry, checking of d_count needs to be protected
+   by d_lock.
+
+
+Papers and other documentation on dcache locking
+================================================
+
+1. Scaling dcache with RCU (http://linuxjournal.com/article.php?sid=7124).
+
+2. http://lse.sourceforge.net/locking/dcache/dcache.html
diff -Nru a/Documentation/floppy.txt b/Documentation/floppy.txt
--- a/Documentation/floppy.txt	2004-12-24 13:36:48 -08:00
+++ b/Documentation/floppy.txt	2004-12-24 13:36:48 -08:00
@@ -13,15 +13,20 @@
  The floppy driver is configured using the 'floppy=' option in
 lilo. This option can be typed at the boot prompt, or entered in the
 lilo configuration file.
- Example: If your kernel is called linux-2.2.13, type the following line
+
+ Example: If your kernel is called linux-2.6.9, type the following line
 at the lilo boot prompt (if you have a thinkpad):
- linux-2.2.13 floppy=thinkpad
+
+ linux-2.6.9 floppy=thinkpad
+
 You may also enter the following line in /etc/lilo.conf, in the description
-of linux-2.2.13:
+of linux-2.6.9:
+
  append = "floppy=thinkpad"
 
  Several floppy related options may be given, example:
- linux-2.2.13 floppy=daring floppy=two_fdc
+
+ linux-2.6.9 floppy=daring floppy=two_fdc
  append = "floppy=daring floppy=two_fdc"
 
  If you give options both in the lilo config file and on the boot
@@ -29,17 +34,25 @@
 prompt options coming last. That's why there are also options to
 restore the default behavior.
 
+
+Module configuration options
+============================
+
  If you use the floppy driver as a module, use the following syntax:
- insmod floppy <options>
+modprobe floppy <options>
 
 Example:
- insmod floppy daring two_fdc
+ modprobe floppy omnibook messages
+
+ If you need certain options enabled every time you load the floppy driver,
+you can put:
+
+ options floppy omnibook messages
 
- Some versions of insmod are buggy in one way or another. If you have
-any problems (options not being passed correctly, segfaults during
-insmod), first check whether there is a more recent version.
+in /etc/modprobe.conf.
 
- The floppy related options include:
+
+ The floppy driver related options are:
 
  floppy=asus_pci
 	Sets the bit mask to allow only units 0 and 1. (default)
@@ -99,7 +112,7 @@
 	master arbitration error" messages from your Ethernet card (or
 	from other devices) while accessing the floppy.
 
- floppy=fifo
+ floppy=usefifo
 	Enables the FIFO. (default)
 
  floppy=<threshold>,fifo_depth
@@ -110,6 +123,7 @@
 	lower, the interrupt latency should be lower too (faster
 	processor). The benefit of a lower threshold is less
 	interrupts.
+
 	To tune the fifo threshold, switch on over/underrun messages
 	using 'floppycontrol --messages'. Then access a floppy
 	disk. If you get a huge amount of "Over/Underrun - retrying"
@@ -120,6 +134,7 @@
 	fifo values without rebooting the machine for each test. Note
 	that you need to do 'floppycontrol --messages' every time you
 	re-insert the module.
+
 	Usually, tuning the fifo threshold should not be needed, as
 	the default (0xa) is reasonable.
 
@@ -128,6 +143,7 @@
 	you have more than two floppy drives (only two can be
 	described in the physical CMOS), or if your BIOS uses
 	non-standard CMOS types. The CMOS types are:
+
 		0 - Use the value of the physical CMOS
 		1 - 5 1/4 DD
 		2 - 5 1/4 HD
@@ -136,6 +152,7 @@
 		5 - 3 1/2 ED
 		6 - 3 1/2 ED
 	       16 - unknown or not installed
+
 	(Note: there are two valid types for ED drives. This is because 5 was
 	initially chosen to represent floppy *tapes*, and 6 for ED drives.
 	AMI ignored this, and used 5 for ED drives. That's why the floppy
@@ -188,7 +205,6 @@
 	   in some more extreme cases."
 
 
-
 Supporting utilities and additional documentation:
 ==================================================
 
@@ -219,3 +235,11 @@
  Be sure to read the FAQ before mailing/posting any bug reports!
 
  Alain
+
+Changelog
+=========
+
+10-30-2004 :	Cleanup, updating, add reference to module configuration.
+		James Nelson <james4765@gmail.com>
+
+6-3-2000 :	Original Document
diff -Nru a/Documentation/ftape.txt b/Documentation/ftape.txt
--- a/Documentation/ftape.txt	2004-12-24 13:36:17 -08:00
+++ b/Documentation/ftape.txt	2004-12-24 13:36:17 -08:00
@@ -2,26 +2,21 @@
 =====
 
 This file describes some issues involved when using the "ftape"
-floppy tape device driver that comes with the Linux kernel. This
-document deals with ftape-3.04 and later. Please read the section
-"Changes" for the most striking differences between version 3.04 and
-2.08; the latter was the version of ftape delivered with the kernel
-until kernel version 2.0.30 and 2.1.57. ftape-3.x developed as the
-re-unification of ftape-2.x and zftape. zftape was developed in
-parallel with the stock ftape-2.x driver sharing the same hardware
-support but providing an enhanced file system interface. zftape also
-provided user transparent block-wise on-the-fly compression (regard it
-as a feature or bug of zftape).
+floppy tape device driver that comes with the Linux kernel.
 
 ftape has a home page at
 
-http://www-math.math.rwth-aachen.de/~LBFM/claus/ftape
+http://ftape.dot-heine.de/
 
 which contains further information about ftape. Please cross check
 this WWW address against the address given (if any) in the MAINTAINERS
 file located in the top level directory of the Linux kernel source
 tree.
 
+NOTE: This is an unmaintained set of drivers, and it is not guaranteed to work.
+If you are interested in taking over maintenance, contact Claus-Justus Heine
+<ch@dot-heine.de>, the former maintainer.
+
 Contents
 ========
 
@@ -31,9 +26,8 @@
    1. Goal
    2. I/O Block Size
    3. Write Access when not at EOD (End Of Data) or BOT (Begin Of Tape)
-   4. MTBSF - backspace over file mark and position at its EOT side
-   5. Formatting
-   6. Interchanging cartridges with other operating systems
+   4. Formatting
+   5. Interchanging cartridges with other operating systems
 
 B. Debugging Output
    1. Introduction
@@ -58,7 +52,7 @@
 versions of ftape and useful links to related topics can be found at
 the ftape home page at
 
-http://www-math.math.rwth-aachen.de/~LBFM/claus/ftape
+http://ftape.dot-heine.de/
 
 *******************************************************************************
 
@@ -70,7 +64,7 @@
    The goal of all that incompatibilities was to give ftape an interface
    that resembles the interface provided by SCSI tape drives as close
    as possible. Thus any Unix backup program that is known to work
-   with SCSI tape drives should also work with ftape-3.04 and above.
+   with SCSI tape drives should also work.
 
    The concept of a fixed block size for read/write transfers is
    rather unrelated to this SCSI tape compatibility at the file system
@@ -81,14 +75,8 @@
 
 2. I/O Block Size
    ~~~~~~~~~~~~~~
-   The probably most striking difference between ftape-2.x and
-   ftape-3.x with the zftape file system interface is the concept of a
-   fixed block size: data must be written to or read from the tape in
-   multiples of a fixed block size. The block size defaults to 10k
-   which is the default block size of GNU tar. While this is quite
-   usual for SCSI tapes (block size of 32k?) and the QIC-150 driver
-   `./drivers/char/tpqic02.c' ftape-2.x allowed data to be written in
-   arbitrary portions to the tape.
+   The block size defaults to 10k which is the default block size of
+   GNU tar.
 
    The block size can be tuned either during kernel configuration or
    at runtime with the MTIOCTOP ioctl using the MTSETBLK operation
@@ -109,53 +97,41 @@
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    zftape (the file system interface of ftape-3.x) denies write access
    to the tape cartridge when it isn't positioned either at BOT or
-   EOD. This inconvenience has been introduced as it was reported that
-   the former behavior of ftape-2.x which allowed write access at
-   arbitrary locations already has caused data loss with some backup
-   programs.
-
-4. MTBSF - backspace over file mark and position at its EOT side
-   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-   ftape-2.x didn't handle the MTBSF tape operation correctly. A MTBSF
-   call (i.e. "mt -f /dev/nqft0 bsf #COUNT") should space over #COUNT
-   file marks and then position at the EOT tape side of the file
-   mark. This has to be taken literally, i.e. "mt -f /dev/nqft0 bsf 1"
-   should simply position at the start of the current volume.
+   EOD.
 
-5. Formatting
+4. Formatting
    ~~~~~~~~~~
-   ftape-3.x DOES support formatting of floppy tape cartridges. You
-   need the `ftformat' program that is shipped with the modules version
-   of ftape-3.x. Please get the latest version of ftape from
+   ftape DOES support formatting of floppy tape cartridges. You need the
+   `ftformat' program that is shipped with the modules version of ftape.
+   Please get the latest version of ftape from
 
    ftp://sunsite.unc.edu/pub/Linux/kernel/tapes
 
    or from the ftape home page at
 
-   http://www-math.math.rwth-aachen.de/~LBFM/claus/ftape
+   http://ftape.dot-heine.de/
 
    `ftformat' is contained in the `./contrib/' subdirectory of that
    separate ftape package.
 
-6. Interchanging cartridges with other operating systems
+5. Interchanging cartridges with other operating systems
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
    The internal emulation of Unix tape device file marks has changed
-   completely. ftape-3.x now uses the volume table segment as specified
+   completely. ftape now uses the volume table segment as specified
    by the QIC-40/80/3010/3020/113 standards to emulate file marks. As
    a consequence there is limited support to interchange cartridges
    with other operating systems.
 
    To be more precise: ftape will detect volumes written by other OS's
    programs and other OS's programs will detect volumes written by
-   ftape-3.x.
+   ftape.
 
    However, it isn't possible to extract the data dumped to the tape
-   by some MSDOG program with ftape-3.x. This exceeds the scope of a
+   by some MSDOS program with ftape. This exceeds the scope of a
    kernel device driver. If you need such functionality, then go ahead
-   and write a user space utility that is able to do
-   that. ftape-3.x/zftape already provides all kernel level support
-   necessary to do that.
+   and write a user space utility that is able to do that. ftape already
+   provides all kernel level support necessary to do that.
 
 *******************************************************************************
 
@@ -200,7 +176,7 @@
 
    ii) trim the debugging output at module load time with
 
-       insmod ftape.o ft_tracing=#DBGLVL
+       modprobe ftape ft_tracing=#DBGLVL
 
        Of course, this applies only if you have configured ftape to be
        compiled as a module.
@@ -240,7 +216,7 @@
 2. Module load time parameters
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Module parameters can be specified either directly when invoking
-   the program 'insmod' at the shell prompt:
+   the program 'modprobe' at the shell prompt:
 
    modprobe ftape ft_tracing=4
 
@@ -277,6 +253,12 @@
 	line documentation provided during that kernel configuration
 	process.
 
+	ft_probe_fc10 is set to a non-zero value if you wish for ftape to
+	probe for a Colorado FC-10 or FC-20 controller.
+
+	ft_mach2 is set to a non-zero value if you wish for ftape to probe
+	for a Mountain MACH-2 controller.
+
         module                 |  kernel command line
         -----------------------|----------------------
         ft_fdc_base=BASE       |  ftape=BASE,ioport
@@ -316,10 +298,10 @@
    page to query for the most recent documentation, related work and
    development versions of ftape.
 
+   Changelog:
+   ==========
+
+~1996:		Original Document
 
- LocalWords:  ftape Linux zftape http www rwth aachen LBFM claus EOD config
- LocalWords:  datarate LocalWords BOT MTBSF EOT HOWTO QIC tpqic menuconfig
- LocalWords:  MTIOCTOP MTSETBLK mt dev qft setblk BLKSZ bsf zftape's xconfig
- LocalWords:  nqft ftformat ftp sunsite unc edu contrib ft MSDOG fdc
- LocalWords:  dma setdensity DBGLVL insmod lilo LI nux ader conf txt
- LocalWords:  modprobe IRQ BOOL ioport irq fc mach THR
+10-24-2004:	General cleanup and updating, noting additional module options.
+		James Nelson <james4765@gmail.com>
diff -Nru a/Documentation/hw_random.txt b/Documentation/hw_random.txt
--- a/Documentation/hw_random.txt	2004-12-24 13:37:01 -08:00
+++ b/Documentation/hw_random.txt	2004-12-24 13:37:01 -08:00
@@ -67,72 +67,3 @@
 
 	Special thanks to Matt Sottek.  I did the "guts", he
 	did the "brains" and all the testing.
-
-Change history:
-
-	Version 1.0.0:
-	* Merge Intel, AMD, VIA RNG drivers into one.
-	  Further changelog in BitKeeper.
-
-	Version 0.9.8:
-	* Support other i8xx chipsets by adding 82801E detection
-	* 82801DB detection is the same as for 82801CA.
-
-	Version 0.9.7:
-	* Support other i8xx chipsets too (by adding 82801BA(M) and
-	  82801CA(M) detection)
-
-	Version 0.9.6:
-	* Internal driver cleanups, prep for 1.0.0 release.
-
-	Version 0.9.5:
-	* Rip out entropy injection via timer.  It never ever worked,
-	  and a better solution (rngd) is now available.
-
-	Version 0.9.4:
-	* Fix: Remove request_mem_region
-	* Fix: Horrible bugs in FIPS calculation and test execution
-
-	Version 0.9.3:
-	* Clean up rng_read a bit.
-	* Update i810_rng driver Web site URL.
-	* Increase default timer interval to 4 samples per second.
-	* Abort if mem region is not available.
-	* BSS zero-initialization cleanup.
-	* Call misc_register() from rng_init_one.
-	* Fix O_NONBLOCK to occur before we schedule.
-
-	Version 0.9.2:
-	* Simplify open blocking logic
-
-	Version 0.9.1:
-	* Support i815 chipsets too (Matt Sottek)
-	* Fix reference counting when statically compiled (prumpf)
-	* Rewrite rng_dev_read (prumpf)
-	* Make module races less likely (prumpf)
-	* Small miscellaneous bug fixes (prumpf)
-	* Use pci table for PCI id list
-
-	Version 0.9.0:
-	* Don't register a pci_driver, because we are really
-	  using PCI bridge vendor/device ids, and someone
-	  may want to register a driver for the bridge. (bug fix)
-	* Don't let the usage count go negative (bug fix)
-	* Clean up spinlocks (bug fix)
-	* Enable PCI device, if necessary (bug fix)
-	* iounmap on module unload (bug fix)
-	* If RNG chrdev is already in use when open(2) is called,
-	  sleep until it is available.
-	* Remove redundant globals rng_allocated, rng_use_count
-	* Convert numeric globals to unsigned
-	* Module unload cleanup
-
-	Version 0.6.2:
-	* Clean up spinlocks.  Since we don't have any interrupts
-	  to worry about, but we do have a timer to worry about,
-	  we use spin_lock_bh everywhere except the timer function
-	  itself.
-	* Fix module load/unload.
-	* Fix timer function and h/w enable/disable logic
-	* New timer interval sysctl
-	* Clean up sysctl names
diff -Nru a/Documentation/i2c/dev-interface b/Documentation/i2c/dev-interface
--- a/Documentation/i2c/dev-interface	2004-12-24 13:36:18 -08:00
+++ b/Documentation/i2c/dev-interface	2004-12-24 13:36:18 -08:00
@@ -3,7 +3,7 @@
 the /dev interface. You need to load module i2c-dev for this.
 
 Each registered i2c adapter gets a number, counting from 0. You can
-examine /proc/bus/i2c to see what number corresponds to which adapter.
+examine /sys/class/i2c-dev/ to see what number corresponds to which adapter.
 I2C device files are character device files with major device number 89
 and a minor device number corresponding to the number assigned as 
 explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ..., 
@@ -19,7 +19,7 @@
 knows about i2c, there is not much choice.
 
 Now, you have to decide which adapter you want to access. You should
-inspect /proc/bus/i2c to decide this. Adapter numbers are assigned
+inspect /sys/class/i2c-dev/ to decide this. Adapter numbers are assigned
 somewhat dynamically, so you can not even assume /dev/i2c-0 is the
 first adapter.
 
diff -Nru a/Documentation/i2c/i2c-stub b/Documentation/i2c/i2c-stub
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/i2c/i2c-stub	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,33 @@
+MODULE: i2c-stub
+
+DESCRIPTION:
+
+This module is a very simple fake I2C/SMBus driver.  It implements three
+types of SMBus commands: write quick, (r/w) byte data, and (r/w) word data.
+
+No hardware is needed nor associated with this module.  It will accept write
+quick commands to all addresses; it will respond to the other commands (also
+to all addresses) by reading from or writing to an array in memory.  It will
+also spam the kernel logs for every command it handles.
+
+The typical use-case is like this:
+	1. load this module
+	2. use i2cset (from lm_sensors project) to pre-load some data
+	3. load the target sensors chip driver module
+	4. observe its behavior in the kernel log
+
+CAVEATS:
+
+There are independent arrays for byte/data and word/data commands.  Depending
+on if/how a target driver mixes them, you'll need to be careful.
+
+If your target driver polls some byte or word waiting for it to change, the
+stub could lock it up.  Use i2cset to unlock it.
+
+If the hardware for your driver has banked registers (e.g. Winbond sensors
+chips) this module will not work well - although it could be extended to
+support that pretty easily.
+
+If you spam it hard enough, printk can be lossy.  This module really wants
+something like relayfs.
+
diff -Nru a/Documentation/i2c/sysfs-interface b/Documentation/i2c/sysfs-interface
--- a/Documentation/i2c/sysfs-interface	2004-12-24 13:36:19 -08:00
+++ b/Documentation/i2c/sysfs-interface	2004-12-24 13:36:19 -08:00
@@ -135,17 +135,43 @@
 		Note that this is actually an internal clock divisor, which
 		affects the measurable speed range, not the read value.
 
-fan[1-3]_pwm	Pulse width modulation fan control.
+*******
+* PWM *
+*******
+
+pwm[1-3]	Pulse width modulation fan control.
 		Integer value in the range 0 to 255
 		Read/Write
 		255 is max or 100%.
 
-fan[1-3]_pwm_enable
+pwm[1-3]_enable
 		Switch PWM on and off.
 		Not always present even if fan*_pwm is.
 		0 to turn off
-		1 to turn on
+		1 to turn on in manual mode
+		2 to turn on in automatic mode
 		Read/Write
+
+pwm[1-*]_auto_channels_temp
+		Select which temperature channels affect this PWM output in
+		auto mode. Bitfield, 1 is temp1, 2 is temp2, 4 is temp3 etc...
+		Which values are possible depend on the chip used.
+
+pwm[1-*]_auto_point[1-*]_pwm
+pwm[1-*]_auto_point[1-*]_temp
+pwm[1-*]_auto_point[1-*]_temp_hyst
+		Define the PWM vs temperature curve. Number of trip points is
+		chip-dependent. Use this for chips which associate trip points
+		to PWM output channels.
+
+OR
+
+temp[1-*]_auto_point[1-*]_pwm
+temp[1-*]_auto_point[1-*]_temp
+temp[1-*]_auto_point[1-*]_temp_hyst
+		Define the PWM vs temperature curve. Number of trip points is
+		chip-dependent. Use this for chips which associate trip points
+		to temperature channels.
 
 
 ****************
diff -Nru a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
--- a/Documentation/i2c/writing-clients	2004-12-24 13:36:31 -08:00
+++ b/Documentation/i2c/writing-clients	2004-12-24 13:36:31 -08:00
@@ -24,22 +24,24 @@
 routines, a client structure specific information like the actual I2C
 address.
 
-  static struct i2c_driver foo_driver = {
-    .owner          = THIS_MODULE,
-    .name           = "Foo version 2.3 driver",
-    .id             = I2C_DRIVERID_FOO, /* usually from i2c-id.h */
-    .flags          = I2C_DF_NOTIFY,
-    .attach_adapter = &foo_attach_adapter,
-    .detach_client  = &foo_detach_client,
-    .command        = &foo_command /* may be NULL */
-  }
+static struct i2c_driver foo_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "Foo version 2.3 driver",
+	.id		= I2C_DRIVERID_FOO, /* from i2c-id.h, optional */
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= &foo_attach_adapter,
+	.detach_client	= &foo_detach_client,
+	.command	= &foo_command /* may be NULL */
+}
  
 The name can be chosen freely, and may be upto 40 characters long. Please
 use something descriptive here.
 
-The id should be a unique ID. The range 0xf000 to 0xffff is reserved for
-local use, and you can use one of those until you start distributing the
-driver. Before you do that, contact the i2c authors to get your own ID(s).
+If used, the id should be a unique ID. The range 0xf000 to 0xffff is
+reserved for local use, and you can use one of those until you start
+distributing the driver, at which time you should contact the i2c authors
+to get your own ID(s). Note that most of the time you don't need an ID
+at all so you can just omit it.
 
 Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This
 means that your driver will be notified when new adapters are found.
@@ -569,7 +571,7 @@
      have to be cleaned up! */
   static int __initdata foo_initialized = 0;
 
-  int __init foo_init(void)
+  static int __init foo_init(void)
   {
     int res;
     printk("foo version %s (%s)\n",FOO_VERSION,FOO_DATE);
@@ -583,41 +585,27 @@
     return 0;
   }
 
-  int __init foo_cleanup(void)
+  void foo_cleanup(void)
   {
-    int res;
     if (foo_initialized == 1) {
       if ((res = i2c_del_driver(&foo_driver))) {
         printk("foo: Driver registration failed, module not removed.\n");
-        return res;
+        return;
       }
       foo_initialized --;
     }
-    return 0;
   }
 
-  #ifdef MODULE
-
   /* Substitute your own name and email address */
   MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"
   MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices");
 
-  int init_module(void)
-  {
-    return foo_init();
-  }
-
-  int cleanup_module(void)
-  {
-    return foo_cleanup();
-  }
-
-  #endif /* def MODULE */
+  module_init(foo_init);
+  module_exit(foo_cleanup);
 
 Note that some functions are marked by `__init', and some data structures
-by `__init_data'. If this driver is compiled as part of the kernel (instead
-of as a module), those functions and structures can be removed after
-kernel booting is completed.
+by `__init_data'.  Hose functions and structures can be removed after
+kernel booting (or module loading) is completed.
 
 Command function
 ================
@@ -688,13 +676,25 @@
   extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
   extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
                                        u8 command, u16 value);
-  extern s32 i2c_smbus_process_call(struct i2c_client * client,
-                                    u8 command, u16 value);
-  extern s32 i2c_smbus_read_block_data(struct i2c_client * client,
-                                       u8 command, u8 *values);
   extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
                                         u8 command, u8 length,
                                         u8 *values);
+
+These ones were removed in Linux 2.6.10 because they had no users, but could
+be added back later if needed:
+
+  extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
+                                           u8 command, u8 *values);
+  extern s32 i2c_smbus_read_block_data(struct i2c_client * client,
+                                       u8 command, u8 *values);
+  extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
+                                            u8 command, u8 length,
+                                            u8 *values);
+  extern s32 i2c_smbus_process_call(struct i2c_client * client,
+                                    u8 command, u16 value);
+  extern s32 i2c_smbus_block_process_call(struct i2c_client *client,
+                                          u8 command, u8 length,
+                                          u8 *values)
 
 All these transactions return -1 on failure. The 'write' transactions 
 return 0 on success; the 'read' transactions return the read value, except 
diff -Nru a/Documentation/i386/zero-page.txt b/Documentation/i386/zero-page.txt
--- a/Documentation/i386/zero-page.txt	2004-12-24 13:36:47 -08:00
+++ b/Documentation/i386/zero-page.txt	2004-12-24 13:36:47 -08:00
@@ -28,7 +28,8 @@
 
  0xa0	16 bytes	System description table truncated to 16 bytes.
 			( struct sys_desc_table_struct )
- 0xb0 - 0x1c3		Free. Add more parameters here if you really need them.
+ 0xb0 - 0x13f		Free. Add more parameters here if you really need them.
+ 0x140- 0x1be		EDID_INFO Video mode setup
 
 0x1c4	unsigned long	EFI system table pointer
 0x1c8	unsigned long	EFI memory descriptor size
diff -Nru a/Documentation/ia64/serial.txt b/Documentation/ia64/serial.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/ia64/serial.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,144 @@
+SERIAL DEVICE NAMING
+
+    As of 2.6.10, serial devices on ia64 are named based on the
+    order of ACPI and PCI enumeration.  The first device in the
+    ACPI namespace (if any) becomes /dev/ttyS0, the second becomes
+    /dev/ttyS1, etc., and PCI devices are named sequentially
+    starting after the ACPI devices.
+
+    Prior to 2.6.10, there were confusing exceptions to this:
+
+	- Firmware on some machines (mostly from HP) provides an HCDP
+	  table[1] that tells the kernel about devices that can be used
+	  as a serial console.  If the user specified "console=ttyS0"
+	  or the EFI ConOut path contained only UART devices, the
+	  kernel registered the device described by the HCDP as
+	  /dev/ttyS0.
+
+	- If there was no HCDP, we assumed there were UARTs at the
+	  legacy COM port addresses (I/O ports 0x3f8 and 0x2f8), so
+	  the kernel registered those as /dev/ttyS0 and /dev/ttyS1.
+
+    Any additional ACPI or PCI devices were registered sequentially
+    after /dev/ttyS0 as they were discovered.
+
+    With an HCDP, device names changed depending on EFI configuration
+    and "console=" arguments.  Without an HCDP, device names didn't
+    change, but we registered devices that might not really exist.
+
+    For example, an HP rx1600 with a single built-in serial port
+    (described in the ACPI namespace) plus an MP[2] (a PCI device) has
+    these ports:
+
+                                  pre-2.6.10      pre-2.6.10
+                    MMIO         (EFI console    (EFI console
+                   address        on builtin)     on MP port)    2.6.10
+                  ==========      ==========      ==========     ======
+      builtin     0xff5e0000        ttyS0           ttyS1         ttyS0
+      MP UPS      0xf8031000        ttyS1           ttyS2         ttyS1
+      MP Console  0xf8030000        ttyS2           ttyS0         ttyS2
+      MP 2        0xf8030010        ttyS3           ttyS3         ttyS3
+      MP 3        0xf8030038        ttyS4           ttyS4         ttyS4
+
+CONSOLE SELECTION
+
+    EFI knows what your console devices are, but it doesn't tell the
+    kernel quite enough to actually locate them.  The DIG64 HCDP
+    table[1] does tell the kernel where potential serial console
+    devices are, but not all firmware supplies it.  Also, EFI supports
+    multiple simultaneous consoles and doesn't tell the kernel which
+    should be the "primary" one.
+
+    So how do you tell Linux which console device to use?
+
+	- If your firmware supplies the HCDP, it is simplest to
+	  configure EFI with a single device (either a UART or a VGA
+	  card) as the console.  Then you don't need to tell Linux
+	  anything; the kernel will automatically use the EFI console.
+
+	  (This works only in 2.6.6 or later; prior to that you had
+	  to specify "console=ttyS0" to get a serial console.)
+
+	- Without an HCDP, Linux defaults to a VGA console unless you
+	  specify a "console=" argument.
+
+    NOTE: Don't assume that a serial console device will be /dev/ttyS0.
+    It might be ttyS1, ttyS2, etc.  Make sure you have the appropriate
+    entries in /etc/inittab (for getty) and /etc/securetty (to allow
+    root login).
+
+EARLY SERIAL CONSOLE
+
+    The kernel can't start using a serial console until it knows where
+    the device lives.  Normally this happens when the driver enumerates
+    all the serial devices, which can happen a minute or more after the
+    kernel starts booting.
+
+    2.6.10 and later kernels have an "early uart" driver that works
+    very early in the boot process.  The kernel will automatically use
+    this if the user supplies an argument like "console=uart,io,0x3f8",
+    or if the EFI console path contains only a UART device and the
+    firmware supplies an HCDP.
+
+TROUBLESHOOTING SERIAL CONSOLE PROBLEMS
+
+    No kernel output after elilo prints "Uncompressing Linux... done":
+
+	- You specified "console=ttyS0" but Linux changed the device
+	  to which ttyS0 refers.  Configure exactly one EFI console
+	  device[3] and remove the "console=" option.
+
+	- The EFI console path contains both a VGA device and a UART.
+	  EFI and elilo use both, but Linux defaults to VGA.  Remove
+	  the VGA device from the EFI console path[3].
+
+	- Multiple UARTs selected as EFI console devices.  EFI and
+	  elilo use all selected devices, but Linux uses only one.
+	  Make sure only one UART is selected in the EFI console
+	  path[3].
+
+	- You're connected to an HP MP port[2] but have a non-MP UART
+	  selected as EFI console device.  EFI uses the MP as a
+	  console device even when it isn't explicitly selected.
+	  Either move the console cable to the non-MP UART, or change
+	  the EFI console path[3] to the MP UART.
+
+    Long pause (60+ seconds) between "Uncompressing Linux... done" and
+    start of kernel output:
+
+	- No early console because you used "console=ttyS<n>".  Remove
+	  the "console=" option if your firmware supplies an HCDP.
+
+	- If you don't have an HCDP, the kernel doesn't know where
+	  your console lives until the driver discovers serial
+	  devices.  Use "console=uart, io,0x3f8" (or appropriate
+	  address for your machine).
+
+    Kernel and init script output works fine, but no "login:" prompt:
+
+	- Add getty entry to /etc/inittab for console tty.  Look for
+	  the "Adding console on ttyS<n>" message that tells you which
+	  device is the console.
+
+    "login:" prompt, but can't login as root:
+
+	- Add entry to /etc/securetty for console tty.
+
+
+
+[1] http://www.dig64.org/specifications/DIG64_PCDPv20.pdf
+    The table was originally defined as the "HCDP" for "Headless
+    Console/Debug Port."  The current version is the "PCDP" for
+    "Primary Console and Debug Port Devices."
+
+[2] The HP MP (management processor) is a PCI device that provides
+    several UARTs.  One of the UARTs is often used as a console; the
+    EFI Boot Manager identifies it as "Acpi(HWP0002,700)/Pci(...)/Uart".
+    The external connection is usually a 25-pin connector, and a
+    special dongle converts that to three 9-pin connectors, one of
+    which is labelled "Console."
+
+[3] EFI console devices are configured using the EFI Boot Manager
+    "Boot option maintenance" menu.  You may have to interrupt the
+    boot sequence to use this menu, and you will have to reset the
+    box after changing console configuration.
diff -Nru a/Documentation/ibm-acpi.txt b/Documentation/ibm-acpi.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/ibm-acpi.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,474 @@
+		    IBM ThinkPad ACPI Extras Driver
+
+                            Version 0.8
+                          8 November 2004
+
+               Borislav Deianov <borislav@users.sf.net>
+		      http://ibm-acpi.sf.net/
+
+
+This is a Linux ACPI driver for the IBM ThinkPad laptops. It aims to
+support various features of these laptops which are accessible through
+the ACPI framework but not otherwise supported by the generic Linux
+ACPI drivers.
+
+
+Status
+------
+
+The features currently supported are the following (see below for
+detailed description):
+
+	- Fn key combinations
+	- Bluetooth enable and disable
+	- video output switching, expansion control	
+	- ThinkLight on and off
+	- limited docking and undocking
+	- UltraBay eject
+	- Experimental: CMOS control
+	- Experimental: LED control
+	- Experimental: ACPI sounds
+
+A compatibility table by model and feature is maintained on the web
+site, http://ibm-acpi.sf.net/. I appreciate any success or failure
+reports, especially if they add to or correct the compatibility table.
+Please include the following information in your report:
+
+	- ThinkPad model name
+	- a copy of your DSDT, from /proc/acpi/dsdt
+	- which driver features work and which don't
+	- the observed behavior of non-working features
+
+Any other comments or patches are also more than welcome.
+
+
+Installation
+------------
+
+If you are compiling this driver as included in the Linux kernel
+sources, simply enable the CONFIG_ACPI_IBM option (Power Management /
+ACPI / IBM ThinkPad Laptop Extras). The rest of this section describes
+how to install this driver when downloaded from the web site.
+
+First, you need to get a kernel with ACPI support up and running.
+Please refer to http://acpi.sourceforge.net/ for help with this
+step. How successful you will be depends a lot on you ThinkPad model,
+the kernel you are using and any additional patches applied. The
+kernel provided with your distribution may not be good enough. I
+needed to compile a 2.6.7 kernel with the 20040715 ACPI patch to get
+ACPI working reliably on my ThinkPad X40. Old ThinkPad models may not
+be supported at all.
+
+Assuming you have the basic ACPI support working (e.g. you can see the
+/proc/acpi directory), follow the following steps to install this
+driver:
+
+	- unpack the archive:
+
+		tar xzvf ibm-acpi-x.y.tar.gz; cd ibm-acpi-x.y
+
+	- compile the driver:
+
+		make
+
+	- install the module in your kernel modules directory:
+
+		make install
+
+	- load the module:
+
+		modprobe ibm_acpi
+
+After loading the module, check the "dmesg" output for any error messages.
+
+
+Features
+--------
+
+The driver creates the /proc/acpi/ibm directory. There is a file under
+that directory for each feature described below. Note that while the
+driver is still in the alpha stage, the exact proc file format and
+commands supported by the various features is guaranteed to change
+frequently.
+
+Driver Version -- /proc/acpi/ibm/driver
+--------------------------------------
+
+The driver name and version. No commands can be written to this file.
+
+Hot Keys -- /proc/acpi/ibm/hotkey
+---------------------------------
+
+Without this driver, only the Fn-F4 key (sleep button) generates an
+ACPI event. With the driver loaded, the hotkey feature enabled and the
+mask set (see below), the various hot keys generate ACPI events in the
+following format:
+
+	ibm/hotkey HKEY 00000080 0000xxxx
+
+The last four digits vary depending on the key combination pressed.
+All labeled Fn-Fx key combinations generate distinct events. In
+addition, the lid microswitch and some docking station buttons may
+also generate such events.
+
+The following commands can be written to this file:
+
+	echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
+	echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
+	echo 0xffff > /proc/acpi/ibm/hotkey -- enable all possible hot keys
+	echo 0x0000 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
+	... any other 4-hex-digit mask ...
+	echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
+
+The bit mask allows some control over which hot keys generate ACPI
+events. Not all bits in the mask can be modified. Not all bits that
+can be modified do anything. Not all hot keys can be individually
+controlled by the mask. Most recent ThinkPad models honor the
+following bits (assuming the hot keys feature has been enabled):
+
+	key	bit	behavior when set	behavior when unset
+
+	Fn-F3			always generates ACPI event
+	Fn-F4			always generates ACPI event
+	Fn-F5	0010	generate ACPI event	enable/disable Bluetooth
+	Fn-F7	0040	generate ACPI event	switch LCD and external display
+	Fn-F8	0080	generate ACPI event	expand screen or none
+	Fn-F9	0100	generate ACPI event	none
+	Fn-F12			always generates ACPI event
+
+Some models do not support all of the above. For example, the T30 does
+not support Fn-F5 and Fn-F9. Other models do not support the mask at
+all. On those models, hot keys cannot be controlled individually.
+
+Note that enabling ACPI events for some keys prevents their default
+behavior. For example, if events for Fn-F5 are enabled, that key will
+no longer enable/disable Bluetooth by itself. This can still be done
+from an acpid handler for the ibm/hotkey event.
+
+Note also that not all Fn key combinations are supported through
+ACPI. For example, on the X40, the brightness, volume and "Access IBM"
+buttons do not generate ACPI events even with this driver. They *can*
+be used through the "ThinkPad Buttons" utility, see
+http://www.nongnu.org/tpb/
+
+Bluetooth -- /proc/acpi/ibm/bluetooth
+-------------------------------------
+
+This feature shows the presence and current state of a Bluetooth
+device. If Bluetooth is installed, the following commands can be used:
+
+	echo enable > /proc/acpi/ibm/bluetooth
+	echo disable > /proc/acpi/ibm/bluetooth
+
+Video output control -- /proc/acpi/ibm/video
+--------------------------------------------
+
+This feature allows control over the devices used for video output -
+LCD, CRT or DVI (if available). The following commands are available:
+
+	echo lcd_enable > /proc/acpi/ibm/video
+	echo lcd_disable > /proc/acpi/ibm/video
+	echo crt_enable > /proc/acpi/ibm/video
+	echo crt_disable > /proc/acpi/ibm/video
+	echo dvi_enable > /proc/acpi/ibm/video
+	echo dvi_disable > /proc/acpi/ibm/video
+	echo auto_enable > /proc/acpi/ibm/video
+	echo auto_disable > /proc/acpi/ibm/video
+	echo expand_toggle > /proc/acpi/ibm/video
+	echo video_switch > /proc/acpi/ibm/video
+
+Each video output device can be enabled or disabled individually.
+Reading /proc/acpi/ibm/video shows the status of each device.
+
+Automatic video switching can be enabled or disabled.  When automatic
+video switching is enabled, certain events (e.g. opening the lid,
+docking or undocking) cause the video output device to change
+automatically. While this can be useful, it also causes flickering
+and, on the X40, video corruption. By disabling automatic switching,
+the flickering or video corruption can be avoided.
+
+The video_switch command cycles through the available video outputs
+(it sumulates the behavior of Fn-F7).
+
+Video expansion can be toggled through this feature. This controls
+whether the display is expanded to fill the entire LCD screen when a
+mode with less than full resolution is used. Note that the current
+video expansion status cannot be determined through this feature.
+
+Note that on many models (particularly those using Radeon graphics
+chips) the X driver configures the video card in a way which prevents
+Fn-F7 from working. This also disables the video output switching
+features of this driver, as it uses the same ACPI methods as
+Fn-F7. Video switching on the console should still work.
+
+ThinkLight control -- /proc/acpi/ibm/light
+------------------------------------------
+
+The current status of the ThinkLight can be found in this file. A few
+models which do not make the status available will show it as
+"unknown". The available commands are:
+
+	echo on  > /proc/acpi/ibm/light
+	echo off > /proc/acpi/ibm/light
+
+Docking / Undocking -- /proc/acpi/ibm/dock
+------------------------------------------
+
+Docking and undocking (e.g. with the X4 UltraBase) requires some
+actions to be taken by the operating system to safely make or break
+the electrical connections with the dock.
+
+The docking feature of this driver generates the following ACPI events:
+
+	ibm/dock GDCK 00000003 00000001 -- eject request
+	ibm/dock GDCK 00000003 00000002 -- undocked
+	ibm/dock GDCK 00000000 00000003 -- docked
+
+NOTE: These events will only be generated if the laptop was docked
+when originally booted. This is due to the current lack of support for
+hot plugging of devices in the Linux ACPI framework. If the laptop was
+booted while not in the dock, the following message is shown in the
+logs: "ibm_acpi: dock device not present". No dock-related events are
+generated but the dock and undock commands described below still
+work. They can be executed manually or triggered by Fn key
+combinations (see the example acpid configuration files included in
+the driver tarball package available on the web site).
+
+When the eject request button on the dock is pressed, the first event
+above is generated. The handler for this event should issue the
+following command:
+
+	echo undock > /proc/acpi/ibm/dock
+
+After the LED on the dock goes off, it is safe to eject the laptop.
+Note: if you pressed this key by mistake, go ahead and eject the
+laptop, then dock it back in. Otherwise, the dock may not function as
+expected.
+
+When the laptop is docked, the third event above is generated. The
+handler for this event should issue the following command to fully
+enable the dock:
+
+	echo dock > /proc/acpi/ibm/dock
+
+The contents of the /proc/acpi/ibm/dock file shows the current status
+of the dock, as provided by the ACPI framework.
+
+The docking support in this driver does not take care of enabling or
+disabling any other devices you may have attached to the dock. For
+example, a CD drive plugged into the UltraBase needs to be disabled or
+enabled separately. See the provided example acpid configuration files
+for how this can be accomplished.
+
+There is no support yet for PCI devices that may be attached to a
+docking station, e.g. in the ThinkPad Dock II. The driver currently
+does not recognize, enable or disable such devices. This means that
+the only docking stations currently supported are the X-series
+UltraBase docks and "dumb" port replicators like the Mini Dock (the
+latter don't need any ACPI support, actually).
+
+UltraBay Eject -- /proc/acpi/ibm/bay
+------------------------------------
+
+Inserting or ejecting an UltraBay device requires some actions to be
+taken by the operating system to safely make or break the electrical
+connections with the device.
+
+This feature generates the following ACPI events:
+
+	ibm/bay MSTR 00000003 00000000 -- eject request
+	ibm/bay MSTR 00000001 00000000 -- eject lever inserted
+
+NOTE: These events will only be generated if the UltraBay was present
+when the laptop was originally booted (on the X series, the UltraBay
+is in the dock, so it may not be present if the laptop was undocked).
+This is due to the current lack of support for hot plugging of devices
+in the Linux ACPI framework. If the laptop was booted without the
+UltraBay, the following message is shown in the logs: "ibm_acpi: bay
+device not present". No bay-related events are generated but the eject
+command described below still works. It can be executed manually or
+triggered by a hot key combination.
+
+Sliding the eject lever generates the first event shown above. The
+handler for this event should take whatever actions are necessary to
+shut down the device in the UltraBay (e.g. call idectl), then issue
+the following command:
+
+	echo eject > /proc/acpi/ibm/bay
+
+After the LED on the UltraBay goes off, it is safe to pull out the
+device.
+
+When the eject lever is inserted, the second event above is
+generated. The handler for this event should take whatever actions are
+necessary to enable the UltraBay device (e.g. call idectl).
+
+The contents of the /proc/acpi/ibm/bay file shows the current status
+of the UltraBay, as provided by the ACPI framework.
+
+Experimental Features
+---------------------
+
+The following features are marked experimental because using them
+involves guessing the correct values of some parameters. Guessing
+incorrectly may have undesirable effects like crashing your
+ThinkPad. USE THESE WITH CAUTION! To activate them, you'll need to
+supply the experimental=1 parameter when loading the module.
+
+Experimental: CMOS control - /proc/acpi/ibm/cmos
+------------------------------------------------
+
+This feature is used internally by the ACPI firmware to control the
+ThinkLight on most newer ThinkPad models. It appears that it can also
+control LCD brightness, sounds volume and more, but only on some
+models.
+
+The commands are non-negative integer numbers:
+
+	echo 0 >/proc/acpi/ibm/cmos
+	echo 1 >/proc/acpi/ibm/cmos
+	echo 2 >/proc/acpi/ibm/cmos
+	...
+
+The range of numbers which are used internally by various models is 0
+to 21, but it's possible that numbers outside this range have
+interesting behavior. Here is the behavior on the X40 (tpb is the
+ThinkPad Buttons utility):
+
+	0 - no effect but tpb reports "Volume down"
+	1 - no effect but tpb reports "Volume up"
+	2 - no effect but tpb reports "Mute on"
+	3 - simulate pressing the "Access IBM" button
+	4 - LCD brightness up
+	5 - LCD brightness down
+	11 - toggle screen expansion
+	12 - ThinkLight on
+	13 - ThinkLight off
+	14 - no effect but tpb reports ThinkLight status change
+
+If you try this feature, please send me a report similar to the
+above. On models which allow control of LCD brightness or sound
+volume, I'd like to provide this functionality in an user-friendly
+way, but first I need a way to identify the models which this is
+possible.
+
+Experimental: LED control - /proc/acpi/ibm/LED
+----------------------------------------------
+
+Some of the LED indicators can be controlled through this feature. The
+available commands are:
+
+	echo <led number> on >/proc/acpi/ibm/led
+	echo <led number> off >/proc/acpi/ibm/led
+	echo <led number> blink >/proc/acpi/ibm/led
+
+The <led number> parameter is a non-negative integer. The range of LED
+numbers used internally by various models is 0 to 7 but it's possible
+that numbers outside this range are also valid. Here is the mapping on
+the X40:
+
+	0 - power
+	1 - battery (orange)
+	2 - battery (green)
+	3 - UltraBase
+	4 - UltraBay
+	7 - standby
+
+All of the above can be turned on and off and can be made to blink.
+
+If you try this feature, please send me a report similar to the
+above. I'd like to provide this functionality in an user-friendly way,
+but first I need to identify the which numbers correspond to which
+LEDs on various models.
+
+Experimental: ACPI sounds - /proc/acpi/ibm/beep
+-----------------------------------------------
+
+The BEEP method is used internally by the ACPI firmware to provide
+audible alerts in various situtation. This feature allows the same
+sounds to be triggered manually.
+
+The commands are non-negative integer numbers:
+
+	echo 0 >/proc/acpi/ibm/beep
+	echo 1 >/proc/acpi/ibm/beep
+	echo 2 >/proc/acpi/ibm/beep
+	...
+
+The range of numbers which are used internally by various models is 0
+to 17, but it's possible that numbers outside this range are also
+valid. Here is the behavior on the X40:
+
+	2 - two beeps, pause, third beep
+	3 - single beep
+	4 - "unable"	
+	5 - single beep
+	6 - "AC/DC"
+	7 - high-pitched beep
+	9 - three short beeps
+	10 - very long beep
+	12 - low-pitched beep
+
+(I've only been able to identify a couple of them).
+
+If you try this feature, please send me a report similar to the
+above. I'd like to provide this functionality in an user-friendly way,
+but first I need to identify the which numbers correspond to which
+sounds on various models.
+
+
+Multiple Command, Module Parameters
+-----------------------------------
+
+Multiple commands can be written to the proc files in one shot by
+separating them with commas, for example:
+
+	echo enable,0xffff > /proc/acpi/ibm/hotkey
+	echo lcd_disable,crt_enable > /proc/acpi/ibm/video
+
+Commands can also be specified when loading the ibm_acpi module, for
+example:
+
+	modprobe ibm_acpi hotkey=enable,0xffff video=auto_disable
+
+
+Example Configuration
+---------------------
+
+The ACPI support in the kernel is intended to be used in conjunction
+with a user-space daemon, acpid. The configuration files for this
+daemon control what actions are taken in response to various ACPI
+events. An example set of configuration files are included in the
+config/ directory of the tarball package available on the web
+site. Note that these are provided for illustration purposes only and
+may need to be adapted to your particular setup.
+
+The following utility scripts are used by the example action
+scripts (included with ibm-acpi for completeness):
+
+	/usr/local/sbin/idectl -- from the hdparm source distribution,
+		see http://www.ibiblio.org/pub/Linux/system/hardware
+	/usr/local/sbin/laptop_mode -- from the Linux kernel source
+		distribution, see Documentation/laptop-mode.txt
+	/sbin/service -- comes with Redhat/Fedora distributions
+
+Toan T Nguyen <ntt@control.uchicago.edu> has written a SuSE powersave
+script for the X20, included in config/usr/sbin/ibm_hotkeys_X20
+
+Henrik Brix Andersen <brix@gentoo.org> has written a Gentoo ACPI event
+handler script for the X31. You can get the latest version from
+http://dev.gentoo.org/~brix/files/x31.sh
+
+David Schweikert <dws@ee.eth.ch> has written an alternative blank.sh
+script which works on Debian systems, included in
+configs/etc/acpi/actions/blank-debian.sh
+
+
+TODO
+----
+
+I'd like to implement the following features but haven't yet found the
+time and/or I don't yet know how to implement them:
+
+- UltraBay floppy drive support
+
diff -Nru a/Documentation/ide.txt b/Documentation/ide.txt
--- a/Documentation/ide.txt	2004-12-24 13:37:01 -08:00
+++ b/Documentation/ide.txt	2004-12-24 13:37:01 -08:00
@@ -248,13 +248,6 @@
  			  allowing ide-floppy, ide-tape, and ide-cdrom|writers
  			  to use ide-scsi emulation on a device specific option.
 
- "hdx=stroke"		: Should you have a system w/ an AWARD Bios and your
-			  drives are larger than 32GB and it will not boot,
-			  one is required to perform a few OEM operations first.
-			  The option is called "stroke" because it allows one
-			  to "soft clip" the drive to work around a barrier
-			  limit.
-
  "idebus=xx"		: inform IDE driver of VESA/PCI bus speed in MHz,
 			  where "xx" is between 20 and 66 inclusive,
 			  used when tuning chipset PIO modes.
@@ -304,7 +297,7 @@
 
  "ide=reverse"		: formerly called to pci sub-system, but now local.
 
-The following are valid ONLY on ide0 (except dc4030), which usually corresponds
+The following are valid ONLY on ide0, which usually corresponds
 to the first ATA interface found on the particular host, and the defaults for
 the base,ctl ports must not be altered.
 
@@ -315,7 +308,7 @@
  "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
+
  "ide=doubler"		: probe/support IDE doublers on Amiga
 
 There may be more options than shown -- use the source, Luke!
diff -Nru a/Documentation/ioctl/cdrom.txt b/Documentation/ioctl/cdrom.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/ioctl/cdrom.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,966 @@
+		Summary of CDROM ioctl calls.
+		============================
+
+		Edward A. Falk <efalk@google.com>
+
+		November, 2004
+
+This document attempts to describe the ioctl(2) calls supported by
+the CDROM layer.  These are by-and-large implemented (as of Linux 2.6)
+in drivers/cdrom/cdrom.c and drivers/block/scsi_ioctl.c
+
+ioctl values are listed in <linux/cdrom.h>.  As of this writing, they
+are as follows:
+
+	CDROMPAUSE		Pause Audio Operation
+	CDROMRESUME		Resume paused Audio Operation
+	CDROMPLAYMSF		Play Audio MSF (struct cdrom_msf)
+	CDROMPLAYTRKIND		Play Audio Track/index (struct cdrom_ti)
+	CDROMREADTOCHDR		Read TOC header (struct cdrom_tochdr)
+	CDROMREADTOCENTRY	Read TOC entry (struct cdrom_tocentry)
+	CDROMSTOP		Stop the cdrom drive
+	CDROMSTART		Start the cdrom drive
+	CDROMEJECT		Ejects the cdrom media
+	CDROMVOLCTRL		Control output volume (struct cdrom_volctrl)
+	CDROMSUBCHNL		Read subchannel data (struct cdrom_subchnl)
+	CDROMREADMODE2		Read CDROM mode 2 data (2336 Bytes)
+					   (struct cdrom_read)
+	CDROMREADMODE1		Read CDROM mode 1 data (2048 Bytes)
+					   (struct cdrom_read)
+	CDROMREADAUDIO		(struct cdrom_read_audio)
+	CDROMEJECT_SW		enable(1)/disable(0) auto-ejecting
+	CDROMMULTISESSION	Obtain the start-of-last-session
+				  address of multi session disks
+				  (struct cdrom_multisession)
+	CDROM_GET_MCN		Obtain the "Universal Product Code"
+				   if available (struct cdrom_mcn)
+	CDROM_GET_UPC		Deprecated, use CDROM_GET_MCN instead.
+	CDROMRESET		hard-reset the drive
+	CDROMVOLREAD		Get the drive's volume setting
+					  (struct cdrom_volctrl)
+	CDROMREADRAW		read data in raw mode (2352 Bytes)
+					   (struct cdrom_read)
+	CDROMREADCOOKED		read data in cooked mode
+	CDROMSEEK		seek msf address
+	CDROMPLAYBLK		scsi-cd only, (struct cdrom_blk)
+	CDROMREADALL		read all 2646 bytes
+	CDROMGETSPINDOWN	return 4-bit spindown value
+	CDROMSETSPINDOWN	set 4-bit spindown value
+	CDROMCLOSETRAY		pendant of CDROMEJECT
+	CDROM_SET_OPTIONS	Set behavior options
+	CDROM_CLEAR_OPTIONS	Clear behavior options
+	CDROM_SELECT_SPEED	Set the CD-ROM speed
+	CDROM_SELECT_DISC	Select disc (for juke-boxes)
+	CDROM_MEDIA_CHANGED	Check is media changed
+	CDROM_DRIVE_STATUS	Get tray position, etc.
+	CDROM_DISC_STATUS	Get disc type, etc.
+	CDROM_CHANGER_NSLOTS	Get number of slots
+	CDROM_LOCKDOOR		lock or unlock door
+	CDROM_DEBUG		Turn debug messages on/off
+	CDROM_GET_CAPABILITY	get capabilities
+	CDROMAUDIOBUFSIZ	set the audio buffer size
+	DVD_READ_STRUCT		Read structure
+	DVD_WRITE_STRUCT	Write structure
+	DVD_AUTH		Authentication
+	CDROM_SEND_PACKET	send a packet to the drive
+	CDROM_NEXT_WRITABLE	get next writable block
+	CDROM_LAST_WRITTEN	get last block written on disc
+
+
+The information that follows was determined from reading kernel source
+code.  It is likely that some corrections will be made over time.
+
+
+
+
+
+
+
+General:
+
+	Unless otherwise specified, all ioctl calls return 0 on success
+	and -1 with errno set to an appropriate value on error.  (Some
+	ioctls return non-negative data values.)
+
+	Unless otherwise specified, all ioctl calls return -1 and set
+	errno to EFAULT on a failed attempt to copy data to or from user
+	address space.
+
+	Individual drivers may return error codes not listed here.
+
+	Unless otherwise specified, all data structures and constants
+	are defined in <linux/cdrom.h>
+
+
+
+
+CDROMPAUSE			Pause Audio Operation
+
+	usage:
+
+	  ioctl(fd, CDROMPAUSE, 0);
+
+	inputs:		none
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+
+CDROMRESUME			Resume paused Audio Operation
+
+	usage:
+
+	  ioctl(fd, CDROMRESUME, 0);
+
+	inputs:		none
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+
+CDROMPLAYMSF			Play Audio MSF (struct cdrom_msf)
+
+	usage:
+
+	  struct cdrom_msf msf;
+	  ioctl(fd, CDROMPLAYMSF, &msf);
+
+	inputs:
+	  cdrom_msf structure, describing a segment of music to play
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+	notes:
+	  MSF stands for minutes-seconds-frames
+	  LBA stands for logical block address
+
+	  Segment is described as start and end times, where each time
+	  is described as minutes:seconds:frames.  A frame is 1/75 of
+	  a second.
+
+
+CDROMPLAYTRKIND			Play Audio Track/index (struct cdrom_ti)
+
+	usage:
+
+	  struct cdrom_ti ti;
+	  ioctl(fd, CDROMPLAYTRKIND, &ti);
+
+	inputs:
+	  cdrom_ti structure, describing a segment of music to play
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+	notes:
+	  Segment is described as start and end times, where each time
+	  is described as a track and an index.
+
+
+
+CDROMREADTOCHDR			Read TOC header (struct cdrom_tochdr)
+
+	usage:
+
+	  cdrom_tochdr header;
+	  ioctl(fd, CDROMREADTOCHDR, &header);
+
+	inputs:
+	  cdrom_tochdr structure
+
+	outputs:
+	  cdrom_tochdr structure
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+
+
+CDROMREADTOCENTRY		Read TOC entry (struct cdrom_tocentry)
+
+	usage:
+
+	  struct cdrom_tocentry entry;
+	  ioctl(fd, CDROMREADTOCENTRY, &entry);
+
+	inputs:
+	  cdrom_tocentry structure
+
+	outputs:
+	  cdrom_tocentry structure
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+	  EINVAL	entry.cdte_format not CDROM_MSF or CDROM_LBA
+	  EINVAL	requested track out of bounds
+	  EIO		I/O error reading TOC
+
+	notes:
+	  TOC stands for Table Of Contents
+	  MSF stands for minutes-seconds-frames
+	  LBA stands for logical block address
+
+
+
+CDROMSTOP			Stop the cdrom drive
+
+	usage:
+
+	  ioctl(fd, CDROMSTOP, 0);
+
+	inputs:		none
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+	notes:
+	  Exact interpretation of this ioctl depends on the device,
+	  but most seem to spin the drive down.
+
+
+CDROMSTART			Start the cdrom drive
+
+	usage:
+
+	  ioctl(fd, CDROMSTART, 0);
+
+	inputs:		none
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+	notes:
+	  Exact interpretation of this ioctl depends on the device,
+	  but most seem to spin the drive up and/or close the tray.
+	  Other devices ignore the ioctl completely.
+
+
+CDROMEJECT			Ejects the cdrom media
+
+	usage:
+
+	  ioctl(fd, CDROMEJECT, 0);
+
+	inputs:		none
+
+	outputs:	none
+
+	error returns:
+	  ENOSYS	cd drive not capable of ejecting
+	  EBUSY		other processes are accessing drive, or door is locked
+
+	notes:
+	  See CDROM_LOCKDOOR, below.
+
+
+
+CDROMCLOSETRAY			pendant of CDROMEJECT
+
+	usage:
+
+	  ioctl(fd, CDROMEJECT, 0);
+
+	inputs:		none
+
+	outputs:	none
+
+	error returns:
+	  ENOSYS	cd drive not capable of ejecting
+	  EBUSY		other processes are accessing drive, or door is locked
+
+	notes:
+	  See CDROM_LOCKDOOR, below.
+
+
+
+CDROMVOLCTRL			Control output volume (struct cdrom_volctrl)
+
+	usage:
+
+	  struct cdrom_volctrl volume;
+	  ioctl(fd, CDROMVOLCTRL, &volume);
+
+	inputs:
+	  cdrom_volctrl structure containing volumes for up to 4
+	  channels.
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+
+
+CDROMVOLREAD			Get the drive's volume setting
+					  (struct cdrom_volctrl)
+
+	usage:
+
+	  struct cdrom_volctrl volume;
+	  ioctl(fd, CDROMVOLREAD, &volume);
+
+	inputs:		none
+
+	outputs:
+	  The current volume settings.
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+
+
+
+CDROMSUBCHNL			Read subchannel data (struct cdrom_subchnl)
+
+	usage:
+
+	  struct cdrom_subchnl q;
+	  ioctl(fd, CDROMSUBCHNL, &q);
+
+	inputs:
+	  cdrom_subchnl structure
+
+	outputs:
+	  cdrom_subchnl structure
+
+	error return:
+	  ENOSYS	cd drive not audio-capable.
+	  EINVAL	format not CDROM_MSF or CDROM_LBA
+
+	notes:
+	  Format is converted to CDROM_MSF on return
+
+
+
+CDROMREADRAW			read data in raw mode (2352 Bytes)
+					   (struct cdrom_read)
+
+	usage:
+
+	  union {
+	    struct cdrom_msf msf;		/* input */
+	    char buffer[CD_FRAMESIZE_RAW];	/* return */
+	  } arg;
+	  ioctl(fd, CDROMREADRAW, &arg);
+
+	inputs:
+	  cdrom_msf structure indicating an address to read.
+	  Only the start values are significant.
+
+	outputs:
+	  Data written to address provided by user.
+
+	error return:
+	  EINVAL	address less than 0, or msf less than 0:2:0
+	  ENOMEM	out of memory
+
+	notes:
+	  As of 2.6.8.1, comments in <linux/cdrom.h> indicate that this
+	  ioctl accepts a cdrom_read structure, but actual source code
+	  reads a cdrom_msf structure and writes a buffer of data to
+	  the same address.
+
+	  MSF values are converted to LBA values via this formula:
+
+	    lba = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;
+
+
+
+
+CDROMREADMODE1			Read CDROM mode 1 data (2048 Bytes)
+					   (struct cdrom_read)
+
+	notes:
+	  Identical to CDROMREADRAW except that block size is
+	  CD_FRAMESIZE (2048) bytes
+
+
+
+CDROMREADMODE2			Read CDROM mode 2 data (2336 Bytes)
+					   (struct cdrom_read)
+
+	notes:
+	  Identical to CDROMREADRAW except that block size is
+	  CD_FRAMESIZE_RAW0 (2336) bytes
+
+
+
+CDROMREADAUDIO			(struct cdrom_read_audio)
+
+	usage:
+
+	  struct cdrom_read_audio ra;
+	  ioctl(fd, CDROMREADAUDIO, &ra);
+
+	inputs:
+	  cdrom_read_audio structure containing read start
+	  point and length
+
+	outputs:
+	  audio data, returned to buffer indicated by ra
+
+	error return:
+	  EINVAL	format not CDROM_MSF or CDROM_LBA
+	  EINVAL	nframes not in range [1 75]
+	  ENXIO		drive has no queue (probably means invalid fd)
+	  ENOMEM	out of memory
+
+
+CDROMEJECT_SW			enable(1)/disable(0) auto-ejecting
+
+	usage:
+
+	  int val;
+	  ioctl(fd, CDROMEJECT_SW, val);
+
+	inputs:
+	  Flag specifying auto-eject flag.
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	Drive is not capable of ejecting.
+	  EBUSY		Door is locked
+
+
+
+
+CDROMMULTISESSION		Obtain the start-of-last-session
+				  address of multi session disks
+				  (struct cdrom_multisession)
+	usage:
+
+	  struct cdrom_multisession ms_info;
+	  ioctl(fd, CDROMMULTISESSION, &ms_info);
+
+	inputs:
+	  cdrom_multisession structure containing desired
+	  format.
+
+	outputs:
+	  cdrom_multisession structure is filled with last_session
+	  information.
+
+	error return:
+	  EINVAL	format not CDROM_MSF or CDROM_LBA
+
+
+CDROM_GET_MCN			Obtain the "Universal Product Code"
+				   if available (struct cdrom_mcn)
+
+	usage:
+
+	  struct cdrom_mcn mcn;
+	  ioctl(fd, CDROM_GET_MCN, &mcn);
+
+	inputs:		none
+
+	outputs:
+	  Universal Product Code
+
+	error return:
+	  ENOSYS	Drive is not capable of reading MCN data.
+
+	notes:
+	  Source code comments state:
+
+	    The following function is implemented, although very few
+	    audio discs give Universal Product Code information, which
+	    should just be the Medium Catalog Number on the box.  Note,
+	    that the way the code is written on the CD is /not/ uniform
+	    across all discs!
+
+
+
+
+CDROM_GET_UPC			CDROM_GET_MCN  (deprecated)
+
+	Not implemented, as of 2.6.8.1
+
+
+
+CDROMRESET			hard-reset the drive
+
+	usage:
+
+	  ioctl(fd, CDROMRESET, 0);
+
+	inputs:		none
+
+	outputs:	none
+
+	error return:
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  ENOSYS	Drive is not capable of resetting.
+
+
+
+
+CDROMREADCOOKED			read data in cooked mode
+
+	usage:
+
+	  u8 buffer[CD_FRAMESIZE]
+	  ioctl(fd, CDROMREADCOOKED, buffer);
+
+	inputs:		none
+
+	outputs:
+	  2048 bytes of data, "cooked" mode.
+
+	notes:
+	  Not implemented on all drives.
+
+
+
+
+CDROMREADALL			read all 2646 bytes
+
+	Same as CDROMREADCOOKED, but reads 2646 bytes.
+
+
+
+CDROMSEEK			seek msf address
+
+	usage:
+
+	  struct cdrom_msf msf;
+	  ioctl(fd, CDROMSEEK, &msf);
+
+	inputs:
+	  MSF address to seek to.
+
+	outputs:	none
+
+
+
+CDROMPLAYBLK			scsi-cd only, (struct cdrom_blk)
+
+	usage:
+
+	  struct cdrom_blk blk;
+	  ioctl(fd, CDROMPLAYBLK, &blk);
+
+	inputs:
+	  Region to play
+
+	outputs:	none
+
+
+
+CDROMGETSPINDOWN
+
+	usage:
+
+	  char spindown;
+	  ioctl(fd, CDROMGETSPINDOWN, &spindown);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current 4-bit spindown value.
+
+
+
+
+CDROMSETSPINDOWN
+
+	usage:
+
+	  char spindown
+	  ioctl(fd, CDROMSETSPINDOWN, &spindown);
+
+	inputs:
+	  4-bit value used to control spindown (TODO: more detail here)
+
+	outputs:	none
+
+
+
+
+
+CDROM_SET_OPTIONS		Set behavior options
+
+	usage:
+
+	  int options;
+	  ioctl(fd, CDROM_SET_OPTIONS, options);
+
+	inputs:
+	  New values for drive options.  The logical 'or' of:
+	    CDO_AUTO_CLOSE	close tray on first open(2)
+	    CDO_AUTO_EJECT	open tray on last release
+	    CDO_USE_FFLAGS	use O_NONBLOCK information on open
+	    CDO_LOCK		lock tray on open files
+	    CDO_CHECK_TYPE	check type on open for data
+
+	outputs:
+	  Returns the resulting options settings in the
+	  ioctl return value.  Returns -1 on error.
+
+	error return:
+	  ENOSYS	selected option(s) not supported by drive.
+
+
+
+
+CDROM_CLEAR_OPTIONS		Clear behavior options
+
+	Same as CDROM_SET_OPTIONS, except that selected options are
+	turned off.
+
+
+
+CDROM_SELECT_SPEED		Set the CD-ROM speed
+
+	usage:
+
+	  int speed;
+	  ioctl(fd, CDROM_SELECT_SPEED, speed);
+
+	inputs:
+	  New drive speed.
+
+	outputs:	none
+
+	error return:
+	  ENOSYS	speed selection not supported by drive.
+
+
+
+CDROM_SELECT_DISC		Select disc (for juke-boxes)
+
+	usage:
+
+	  int disk;
+	  ioctl(fd, CDROM_SELECT_DISC, disk);
+
+	inputs:
+	  Disk to load into drive.
+
+	outputs:	none
+
+	error return:
+	  EINVAL	Disk number beyond capacity of drive
+
+
+
+CDROM_MEDIA_CHANGED		Check is media changed
+
+	usage:
+
+	  int slot;
+	  ioctl(fd, CDROM_MEDIA_CHANGED, slot);
+
+	inputs:
+	  Slot number to be tested, always zero except for jukeboxes.
+	  May also be special values CDSL_NONE or CDSL_CURRENT
+
+	outputs:
+	  Ioctl return value is 0 or 1 depending on whether the media
+	  has been changed, or -1 on error.
+
+	error returns:
+	  ENOSYS	Drive can't detect media change
+	  EINVAL	Slot number beyond capacity of drive
+	  ENOMEM	Out of memory
+
+
+
+CDROM_DRIVE_STATUS		Get tray position, etc.
+
+	usage:
+
+	  int slot;
+	  ioctl(fd, CDROM_DRIVE_STATUS, slot);
+
+	inputs:
+	  Slot number to be tested, always zero except for jukeboxes.
+	  May also be special values CDSL_NONE or CDSL_CURRENT
+
+	outputs:
+	  Ioctl return value will be one of the following values
+	  from <linux/cdrom.h>:
+
+	    CDS_NO_INFO		Information not available.
+	    CDS_NO_DISC
+	    CDS_TRAY_OPEN
+	    CDS_DRIVE_NOT_READY
+	    CDS_DISC_OK
+	    -1			error
+
+	error returns:
+	  ENOSYS	Drive can't detect drive status
+	  EINVAL	Slot number beyond capacity of drive
+	  ENOMEM	Out of memory
+
+
+
+
+CDROM_DISC_STATUS		Get disc type, etc.
+
+	usage:
+
+	  ioctl(fd, CDROM_DISC_STATUS, 0);
+
+	inputs:		none
+
+	outputs:
+	  Ioctl return value will be one of the following values
+	  from <linux/cdrom.h>:
+	    CDS_NO_INFO
+	    CDS_AUDIO
+	    CDS_MIXED
+	    CDS_XA_2_2
+	    CDS_XA_2_1
+	    CDS_DATA_1
+
+	error returns:	none at present
+
+	notes:
+	  Source code comments state:
+
+	    Ok, this is where problems start.  The current interface for
+	    the CDROM_DISC_STATUS ioctl is flawed.  It makes the false
+	    assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc.
+	    Unfortunatly, while this is often the case, it is also
+	    very common for CDs to have some tracks with data, and some
+	    tracks with audio.	Just because I feel like it, I declare
+	    the following to be the best way to cope.  If the CD has
+	    ANY data tracks on it, it will be returned as a data CD.
+	    If it has any XA tracks, I will return it as that.	Now I
+	    could simplify this interface by combining these returns with
+	    the above, but this more clearly demonstrates the problem
+	    with the current interface.  Too bad this wasn't designed
+	    to use bitmasks...	       -Erik
+
+	    Well, now we have the option CDS_MIXED: a mixed-type CD.
+	    User level programmers might feel the ioctl is not very
+	    useful.
+			---david
+
+
+
+
+CDROM_CHANGER_NSLOTS		Get number of slots
+
+	usage:
+
+	  ioctl(fd, CDROM_CHANGER_NSLOTS, 0);
+
+	inputs:		none
+
+	outputs:
+	  The ioctl return value will be the number of slots in a
+	  CD changer.  Typically 1 for non-multi-disk devices.
+
+	error returns:	none
+
+
+
+CDROM_LOCKDOOR			lock or unlock door
+
+	usage:
+
+	  int lock;
+	  ioctl(fd, CDROM_LOCKDOOR, lock);
+
+	inputs:
+	  Door lock flag, 1=lock, 0=unlock
+
+	outputs:	none
+
+	error returns:
+	  EDRIVE_CANT_DO_THIS	Door lock function not supported.
+	  EBUSY			Attempt to unlock when multiple users
+	  			have the drive open and not CAP_SYS_ADMIN
+
+	notes:
+	  As of 2.6.8.1, the lock flag is a global lock, meaning that
+	  all CD drives will be locked or unlocked together.  This is
+	  probably a bug.
+
+	  The EDRIVE_CANT_DO_THIS value is defined in <linux/cdrom.h>
+	  and is currently (2.6.8.1) the same as EOPNOTSUPP
+
+
+
+CDROM_DEBUG			Turn debug messages on/off
+
+	usage:
+
+	  int debug;
+	  ioctl(fd, CDROM_DEBUG, debug);
+
+	inputs:
+	  Cdrom debug flag, 0=disable, 1=enable
+
+	outputs:
+	  The ioctl return value will be the new debug flag.
+
+	error return:
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+
+
+
+CDROM_GET_CAPABILITY		get capabilities
+
+	usage:
+
+	  ioctl(fd, CDROM_GET_CAPABILITY, 0);
+
+	inputs:		none
+
+	outputs:
+	  The ioctl return value is the current device capability
+	  flags.  See CDC_CLOSE_TRAY, CDC_OPEN_TRAY, etc.
+
+
+
+CDROMAUDIOBUFSIZ		set the audio buffer size
+
+	usage:
+
+	  int arg;
+	  ioctl(fd, CDROMAUDIOBUFSIZ, val);
+
+	inputs:
+	  New audio buffer size
+
+	outputs:
+	  The ioctl return value is the new audio buffer size, or -1
+	  on error.
+
+	error return:
+	  ENOSYS	Not supported by this driver.
+
+	notes:
+	  Not supported by all drivers.
+
+
+
+DVD_READ_STRUCT			Read structure
+
+	usage:
+
+	  dvd_struct s;
+	  ioctl(fd, DVD_READ_STRUCT, &s);
+
+	inputs:
+	  dvd_struct structure, containing:
+	    type		specifies the information desired, one of
+	    			DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT,
+				DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA,
+				DVD_STRUCT_MANUFACT
+	    physical.layer_num	desired layer, indexed from 0
+	    copyright.layer_num	desired layer, indexed from 0
+	    disckey.agid
+
+	outputs:
+	  dvd_struct structure, containing:
+	    physical		for type == DVD_STRUCT_PHYSICAL
+	    copyright		for type == DVD_STRUCT_COPYRIGHT
+	    disckey.value	for type == DVD_STRUCT_DISCKEY
+	    bca.{len,value}	for type == DVD_STRUCT_BCA
+	    manufact.{len,valu}	for type == DVD_STRUCT_MANUFACT
+
+	error returns:
+	  EINVAL	physical.layer_num exceeds number of layers
+	  EIO		Recieved invalid response from drive
+
+
+
+DVD_WRITE_STRUCT		Write structure
+
+	Not implemented, as of 2.6.8.1
+
+
+
+DVD_AUTH			Authentication
+
+	usage:
+
+	  dvd_authinfo ai;
+	  ioctl(fd, DVD_AUTH, &ai);
+
+	inputs:
+	  dvd_authinfo structure.  See <linux/cdrom.h>
+
+	outputs:
+	  dvd_authinfo structure.
+
+	error return:
+	  ENOTTY	ai.type not recognized.
+
+
+
+CDROM_SEND_PACKET		send a packet to the drive
+
+	usage:
+
+	  struct cdrom_generic_command cgc;
+	  ioctl(fd, CDROM_SEND_PACKET, &cgc);
+
+	inputs:
+	  cdrom_generic_command structure containing the packet to send.
+
+	outputs:	none
+	  cdrom_generic_command structure containing results.
+
+	error return:
+	  EIO		command failed.
+	  EPERM		Operation not permitted, either because a
+			write command was attempted on a drive which
+			is opened read-only, or because the command
+			requires CAP_SYS_RAWIO
+	  EINVAL	cgc.data_direction not set
+
+
+
+CDROM_NEXT_WRITABLE		get next writable block
+
+	usage:
+
+	  long next;
+	  ioctl(fd, CDROM_NEXT_WRITABLE, &next);
+
+	inputs:		none
+
+	outputs:
+	  The next writable block.
+
+	notes:
+	  If the device does not support this ioctl directly, the
+	  ioctl will return CDROM_LAST_WRITTEN + 7.
+
+
+
+CDROM_LAST_WRITTEN		get last block written on disc
+
+	usage:
+
+	  long last;
+	  ioctl(fd, CDROM_LAST_WRITTEN, &last);
+
+	inputs:		none
+
+	outputs:
+	  The last block written on disc
+
+	notes:
+	  If the device does not support this ioctl directly, the
+	  result is derived from the disc's table of contents.  If the
+	  table of contents can't be read, this ioctl returns an
+	  error.
diff -Nru a/Documentation/ioctl/hdio.txt b/Documentation/ioctl/hdio.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/ioctl/hdio.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,965 @@
+		Summary of HDIO_ ioctl calls.
+		============================
+
+		Edward A. Falk <efalk@google.com>
+
+		November, 2004
+
+This document attempts to describe the ioctl(2) calls supported by
+the HD/IDE layer.  These are by-and-large implemented (as of Linux 2.6)
+in drivers/ide/ide.c and drivers/block/scsi_ioctl.c
+
+ioctl values are listed in <linux/hdreg.h>.  As of this writing, they
+are as follows:
+
+    ioctls that pass argument pointers to user space:
+
+	HDIO_GETGEO		get device geometry
+	HDIO_GET_UNMASKINTR	get current unmask setting
+	HDIO_GET_MULTCOUNT	get current IDE blockmode setting
+	HDIO_GET_QDMA		get use-qdma flag
+	HDIO_SET_XFER		set transfer rate via proc
+	HDIO_OBSOLETE_IDENTITY	OBSOLETE, DO NOT USE
+	HDIO_GET_KEEPSETTINGS	get keep-settings-on-reset flag
+	HDIO_GET_32BIT		get current io_32bit setting
+	HDIO_GET_NOWERR		get ignore-write-error flag
+	HDIO_GET_DMA		get use-dma flag
+	HDIO_GET_NICE		get nice flags
+	HDIO_GET_IDENTITY	get IDE identification info
+	HDIO_GET_WCACHE		get write cache mode on|off
+	HDIO_GET_ACOUSTIC	get acoustic value
+	HDIO_GET_ADDRESS	get sector addressing mode
+	HDIO_GET_BUSSTATE	get the bus state of the hwif
+	HDIO_TRISTATE_HWIF	execute a channel tristate
+	HDIO_DRIVE_RESET	execute a device reset
+	HDIO_DRIVE_TASKFILE	execute raw taskfile
+	HDIO_DRIVE_TASK		execute task and special drive command
+	HDIO_DRIVE_CMD		execute a special drive command
+	HDIO_DRIVE_CMD_AEB	HDIO_DRIVE_TASK
+
+    ioctls that pass non-pointer values:
+
+	HDIO_SET_MULTCOUNT	change IDE blockmode
+	HDIO_SET_UNMASKINTR	permit other irqs during I/O
+	HDIO_SET_KEEPSETTINGS	keep ioctl settings on reset
+	HDIO_SET_32BIT		change io_32bit flags
+	HDIO_SET_NOWERR		change ignore-write-error flag
+	HDIO_SET_DMA		change use-dma flag
+	HDIO_SET_PIO_MODE	reconfig interface to new speed
+	HDIO_SCAN_HWIF		register and (re)scan interface
+	HDIO_SET_NICE		set nice flags
+	HDIO_UNREGISTER_HWIF	unregister interface
+	HDIO_SET_WCACHE		change write cache enable-disable
+	HDIO_SET_ACOUSTIC	change acoustic behavior
+	HDIO_SET_BUSSTATE	set the bus state of the hwif
+	HDIO_SET_QDMA		change use-qdma flag
+	HDIO_SET_ADDRESS	change lba addressing modes
+
+	HDIO_SET_IDE_SCSI	Set scsi emulation mode on/off
+	HDIO_SET_SCSI_IDE	not implemented yet
+
+
+The information that follows was determined from reading kernel source
+code.  It is likely that some corrections will be made over time.
+
+
+
+
+
+
+
+General:
+
+	Unless otherwise specified, all ioctl calls return 0 on success
+	and -1 with errno set to an appropriate value on error.
+
+	Unless otherwise specified, all ioctl calls return -1 and set
+	errno to EFAULT on a failed attempt to copy data to or from user
+	address space.
+
+	Unless otherwise specified, all data structures and constants
+	are defined in <linux/hdreg.h>
+
+
+
+HDIO_GETGEO			get device geometry
+
+	usage:
+
+	  struct hd_geometry geom;
+	  ioctl(fd, HDIO_GETGEO, &geom);
+
+
+	inputs:		none
+
+	outputs:
+
+	  hd_geometry structure containing:
+
+	    heads	number of heads
+	    sectors	number of sectors/track
+	    cylinders	number of cylinders, mod 65536
+	    start	starting sector of this partition.
+
+
+	error returns:
+	  EINVAL	if the device is not a disk drive or floppy drive,
+	  		or if the user passes a null pointer
+
+
+	notes:
+
+	  Not particularly useful with modern disk drives, whose geometry
+	  is a polite fiction anyway.  Modern drives are addressed
+	  purely by sector number nowadays (lba addressing), and the
+	  drive geometry is an abstraction which is actually subject
+	  to change.  Currently (as of Nov 2004), the geometry values
+	  are the "bios" values -- presumably the values the drive had
+	  when Linux first booted.
+
+	  In addition, the cylinders field of the hd_geometry is an
+	  unsigned short, meaning that on most architectures, this
+	  ioctl will not return a meaningful value on drives with more
+	  than 65535 tracks.
+
+	  The start field is unsigned long, meaning that it will not
+	  contain a meaningful value for disks over 219 Gb in size.
+
+
+
+
+HDIO_GET_UNMASKINTR		get current unmask setting
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_UNMASKINTR, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the drive's current unmask setting
+
+
+
+HDIO_SET_UNMASKINTR		permit other irqs during I/O
+
+	usage:
+
+	  unsigned long val;
+	  ioctl(fd, HDIO_SET_UNMASKINTR, val);
+
+	inputs:
+	  New value for unmask flag
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 1]
+	  EBUSY		Controller busy
+
+
+
+
+HDIO_GET_MULTCOUNT		get current IDE blockmode setting
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_MULTCOUNT, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current IDE block mode setting.  This
+	  controls how many sectors the drive will transfer per
+	  interrupt.
+
+
+
+HDIO_SET_MULTCOUNT		change IDE blockmode
+
+	usage:
+
+	  int val;
+	  ioctl(fd, HDIO_SET_MULTCOUNT, val);
+
+	inputs:
+	  New value for IDE block mode setting.  This controls how many
+	  sectors the drive will transfer per interrupt.
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range supported by disk.
+	  EBUSY		Controller busy or blockmode already set.
+	  EIO		Drive did not accept new block mode.
+
+	notes:
+
+	  Source code comments read:
+
+	    This is tightly woven into the driver->do_special can not
+	    touch.  DON'T do it again until a total personality rewrite
+	    is committed.
+
+	  If blockmode has already been set, this ioctl will fail with
+	  EBUSY
+
+
+
+HDIO_GET_QDMA			get use-qdma flag
+
+	Not implemented, as of 2.6.8.1
+
+
+
+HDIO_SET_XFER			set transfer rate via proc
+
+	Not implemented, as of 2.6.8.1
+
+
+
+HDIO_OBSOLETE_IDENTITY		OBSOLETE, DO NOT USE
+
+	Same as HDIO_GET_IDENTITY (see below), except that it only
+	returns the first 142 bytes of drive identity information.
+
+
+
+HDIO_GET_IDENTITY		get IDE identification info
+
+	usage:
+
+	  unsigned char identity[512];
+	  ioctl(fd, HDIO_GET_IDENTITY, identity);
+
+	inputs:		none
+
+	outputs:
+
+	  ATA drive identity information.  For full description, see
+	  the IDENTIFY DEVICE and IDENTIFY PACKET DEVICE commands in
+	  the ATA specification.
+
+	error returns:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  ENOMSG	IDENTIFY DEVICE information not available
+
+	notes:
+
+	  Returns information that was obtained when the drive was
+	  probed.  Some of this information is subject to change, and
+	  this ioctl does not re-probe the drive to update the
+	  information.
+
+	  This information is also available from /proc/ide/hdX/identify
+
+
+
+HDIO_GET_KEEPSETTINGS		get keep-settings-on-reset flag
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_KEEPSETTINGS, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current "keep settings" flag
+
+	notes:
+
+	  When set, indicates that kernel should restore settings
+	  after a drive reset.
+
+
+
+HDIO_SET_KEEPSETTINGS		keep ioctl settings on reset
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_SET_KEEPSETTINGS, val);
+
+	inputs:
+	  New value for keep_settings flag
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 1]
+	  EBUSY		Controller busy
+
+
+
+HDIO_GET_32BIT			get current io_32bit setting
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_32BIT, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current io_32bit setting
+
+	notes:
+
+	  0=16-bit, 1=32-bit, 2,3 = 32bit+sync
+
+
+
+HDIO_GET_NOWERR			get ignore-write-error flag
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_NOWERR, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current ignore-write-error flag
+
+
+
+HDIO_GET_DMA			get use-dma flag
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_DMA, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current use-dma flag
+
+
+
+HDIO_GET_NICE			get nice flags
+
+	usage:
+
+	  long nice;
+	  ioctl(fd, HDIO_GET_NICE, &nice);
+
+	inputs:		none
+
+	outputs:
+
+	  The drive's "nice" values.
+
+	notes:
+
+	  Per-drive flags which determine when the system will give more
+	  bandwidth to other devices sharing the same IDE bus.
+	  See <linux/hdreg.h>, near symbol IDE_NICE_DSC_OVERLAP.
+
+
+
+
+HDIO_SET_NICE			set nice flags
+
+	usage:
+
+	  unsigned long nice;
+	  ...
+	  ioctl(fd, HDIO_SET_NICE, nice);
+
+	inputs:
+	  bitmask of nice flags.
+
+	outputs:	none
+
+	error returns:
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EPERM		Flags other than DSC_OVERLAP and NICE_1 set.
+	  EPERM		DSC_OVERLAP specified but not supported by drive
+
+	notes:
+
+	  This ioctl sets the DSC_OVERLAP and NICE_1 flags from values
+	  provided by the user.
+
+	  Nice flags are listed in <linux/hdreg.h>, starting with
+	  IDE_NICE_DSC_OVERLAP.  These values represent shifts.
+
+
+
+
+
+HDIO_GET_WCACHE			get write cache mode on|off
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_WCACHE, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current write cache mode
+
+
+
+HDIO_GET_ACOUSTIC		get acoustic value
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_ACOUSTIC, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current acoustic settings
+
+	notes:
+
+	  See HDIO_SET_ACOUSTIC
+
+
+
+HDIO_GET_ADDRESS
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_GET_ADDRESS, &val);
+
+	inputs:		none
+
+	outputs:
+	  The value of the current addressing mode:
+	    0 = 28-bit
+	    1 = 48-bit
+	    2 = 48-bit doing 28-bit
+	    3 = 64-bit
+
+
+
+HDIO_GET_BUSSTATE		get the bus state of the hwif
+
+	usage:
+
+	  long state;
+	  ioctl(fd, HDIO_SCAN_HWIF, &state);
+
+	inputs:		none
+
+	outputs:
+	  Current power state of the IDE bus.  One of BUSSTATE_OFF,
+	  BUSSTATE_ON, or BUSSTATE_TRISTATE
+
+	error returns:
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+
+
+
+
+HDIO_SET_BUSSTATE		set the bus state of the hwif
+
+	usage:
+
+	  int state;
+	  ...
+	  ioctl(fd, HDIO_SCAN_HWIF, state);
+
+	inputs:
+	  Desired IDE power state.  One of BUSSTATE_OFF, BUSSTATE_ON,
+	  or BUSSTATE_TRISTATE
+
+	outputs:	none
+
+	error returns:
+	  EACCES	Access denied:  requires CAP_SYS_RAWIO
+	  EOPNOTSUPP	Hardware interface does not support bus power control
+
+
+
+
+HDIO_TRISTATE_HWIF		execute a channel tristate
+
+	Not implemented, as of 2.6.8.1.  See HDIO_SET_BUSSTATE
+
+
+
+HDIO_DRIVE_RESET		execute a device reset
+
+	usage:
+
+	  int args[3]
+	  ...
+	  ioctl(fd, HDIO_DRIVE_RESET, args);
+
+	inputs:		none
+
+	outputs:	none
+
+	error returns:
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+
+	notes:
+
+	  Abort any current command, prevent anything else from being
+	  queued, execute a reset on the device, and issue BLKRRPART
+	  ioctl on the block device.
+
+	  Executes an ATAPI soft reset if applicable, otherwise
+	  executes an ATA soft reset on the controller.
+
+
+
+HDIO_DRIVE_TASKFILE		execute raw taskfile
+
+	Note:  If you don't have a copy of the ANSI ATA specification
+	handy, you should probably ignore this ioctl.
+
+	Execute an ATA disk command directly by writing the "taskfile"
+	registers of the drive.  Requires ADMIN and RAWIO access
+	privileges.
+
+	usage:
+
+	  struct {
+	    ide_task_request_t req_task;
+	    u8 outbuf[OUTPUT_SIZE];
+	    u8 inbuf[INPUT_SIZE];
+	  } task;
+	  memset(&task.req_task, 0, sizeof(task.req_task));
+	  task.req_task.out_size = sizeof(task.outbuf);
+	  task.req_task.in_size = sizeof(task.inbuf);
+	  ...
+	  ioctl(fd, HDIO_DRIVE_TASKFILE, &task);
+	  ...
+
+	inputs:
+
+	  (See below for details on memory area passed to ioctl.)
+
+	  io_ports[8]	values to be written to taskfile registers
+	  hob_ports[8]	high-order bytes, for extended commands.
+	  out_flags	flags indicating which registers are valid
+	  in_flags	flags indicating which registers should be returned
+	  data_phase	see below
+	  req_cmd	command type to be executed
+	  out_size	size of output buffer
+	  outbuf	buffer of data to be transmitted to disk
+	  inbuf		buffer of data to be received from disk (see [1])
+
+	outputs:
+
+	  io_ports[]	values returned in the taskfile registers
+	  hob_ports[]	high-order bytes, for extended commands.
+	  out_flags	flags indicating which registers are valid (see [2])
+	  in_flags	flags indicating which registers should be returned
+	  outbuf	buffer of data to be transmitted to disk (see [1])
+	  inbuf		buffer of data to be received from disk
+
+	error returns:
+	  EACCES	CAP_SYS_ADMIN or CAP_SYS_RAWIO privilege not set.
+	  ENOMSG	Device is not a disk drive.
+	  ENOMEM	Unable to allocate memory for task
+	  EFAULT	req_cmd == TASKFILE_IN_OUT (not implemented as of 2.6.8)
+	  EPERM		req_cmd == TASKFILE_MULTI_OUT and drive
+	  		multi-count not yet set.
+
+
+	notes:
+
+	  [1] Currently (2.6.8), both the input and output buffers are
+	  copied from the user and written back to the user, even when
+	  not used.  This may be a bug.
+
+	  [2] The out_flags and in_flags are returned to the user after
+	  the ioctl completes.	Currently (2.6.8) these are the same
+	  as the input values, unchanged.  In the future, they may have
+	  more significance.
+
+	  Extreme caution should be used with using this ioctl.  A
+	  mistake can easily corrupt data or hang the system.
+
+	  The argument to the ioctl is a pointer to a region of memory
+	  containing a ide_task_request_t structure, followed by an
+	  optional buffer of data to be transmitted to the drive,
+	  followed by an optional buffer to receive data from the drive.
+
+	  Command is passed to the disk drive via the ide_task_request_t
+	  structure, which contains these fields:
+
+	    io_ports[8]		values for the taskfile registers
+	    hob_ports[8]	high-order bytes, for extended commands
+	    out_flags		flags indicating which entries in the
+	    			io_ports[] and hob_ports[] arrays
+				contain valid values.  Type ide_reg_valid_t.
+	    in_flags		flags indicating which entries in the
+	    			io_ports[] and hob_ports[] arrays
+				are expected to contain valid values
+				on return.
+	    data_phase		See below
+	    req_cmd		Command type, see below
+	    out_size		output (user->drive) buffer size, bytes
+	    in_size		input (drive->user) buffer size, bytes
+
+	  This ioctl does not necessarily respect all flags in the
+	  out_flags and in_flags values -- some taskfile registers
+	  may be written or read even if not requested in the flags.
+	  Unused fields of io_ports[] and hob_ports[] should be set
+	  to zero.
+
+	  The data_phase field describes the data transfer to be
+	  performed.  Value is one of:
+
+	    TASKFILE_IN
+	    TASKFILE_MULTI_IN
+	    TASKFILE_OUT
+	    TASKFILE_MULTI_OUT
+	    TASKFILE_IN_OUT
+	    TASKFILE_IN_DMA
+	    TASKFILE_IN_DMAQ
+	    TASKFILE_OUT_DMA
+	    TASKFILE_OUT_DMAQ
+	    TASKFILE_P_IN
+	    TASKFILE_P_IN_DMA
+	    TASKFILE_P_IN_DMAQ
+	    TASKFILE_P_OUT
+	    TASKFILE_P_OUT_DMA
+	    TASKFILE_P_OUT_DMAQ
+
+	  The req_cmd field classifies the command type.  It may be
+	  one of:
+
+	    IDE_DRIVE_TASK_NO_DATA
+	    IDE_DRIVE_TASK_SET_XFER
+	    IDE_DRIVE_TASK_IN
+	    IDE_DRIVE_TASK_OUT
+	    IDE_DRIVE_TASK_RAW_WRITE
+
+
+
+
+
+
+HDIO_DRIVE_CMD			execute a special drive command
+
+	Note:  If you don't have a copy of the ANSI ATA specification
+	handy, you should probably ignore this ioctl.
+
+	usage:
+
+	  u8 args[4+XFER_SIZE];
+	  ...
+	  ioctl(fd, HDIO_DRIVE_CMD, args);
+
+	inputs:
+
+	  Taskfile register values:
+	    args[0]	COMMAND
+	    args[1]	SECTOR
+	    args[2]	FEATURE
+	    args[3]	NSECTOR
+
+	outputs:
+
+	  args[] buffer is filled with register values followed by any
+	  data returned by the disk.
+	    args[0]	status
+	    args[1]	error
+	    args[2]	NSECTOR
+	    args[3]	undefined
+	    args[4+]	NSECTOR * 512 bytes of data returned by the command.
+
+	error returns:
+	  EACCES	Access denied:  requires CAP_SYS_RAWIO
+	  ENOMEM	Unable to allocate memory for task
+
+	notes:
+
+	  Taskfile registers IDE_LCYL, IDE_HCYL, and IDE_SELECT are
+	  set to zero before executing the command.
+
+
+
+HDIO_DRIVE_TASK			execute task and special drive command
+
+	Note:  If you don't have a copy of the ANSI ATA specification
+	handy, you should probably ignore this ioctl.
+
+	usage:
+
+	  u8 args[7];
+	  ...
+	  ioctl(fd, HDIO_DRIVE_TASK, args);
+
+	inputs:
+
+	  Taskfile register values:
+	    args[0]	COMMAND
+	    args[1]	FEATURE
+	    args[2]	NSECTOR
+	    args[3]	SECTOR
+	    args[4]	LCYL
+	    args[5]	HCYL
+	    args[6]	SELECT
+
+	outputs:
+
+	  Taskfile register values:
+	    args[0]	status
+	    args[1]	error
+	    args[2]	NSECTOR
+	    args[3]	SECTOR
+	    args[4]	LCYL
+	    args[5]	HCYL
+	    args[6]	SELECT
+
+	error returns:
+	  EACCES	Access denied:  requires CAP_SYS_RAWIO
+	  ENOMEM	Unable to allocate memory for task
+
+
+
+
+HDIO_DRIVE_CMD_AEB		HDIO_DRIVE_TASK
+
+	Not implemented, as of 2.6.8.1
+
+
+
+HDIO_SET_32BIT			change io_32bit flags
+
+	usage:
+
+	  int val;
+	  ioctl(fd, HDIO_SET_32BIT, val);
+
+	inputs:
+	  New value for io_32bit flag
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 3]
+	  EBUSY		Controller busy
+
+
+
+
+HDIO_SET_NOWERR			change ignore-write-error flag
+
+	usage:
+
+	  int val;
+	  ioctl(fd, HDIO_SET_NOWERR, val);
+
+	inputs:
+	  New value for ignore-write-error flag.  Used for ignoring
+	  WRERR_STAT
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 1]
+	  EBUSY		Controller busy
+
+
+
+HDIO_SET_DMA			change use-dma flag
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_SET_DMA, val);
+
+	inputs:
+	  New value for use-dma flag
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 1]
+	  EBUSY		Controller busy
+
+
+
+HDIO_SET_PIO_MODE		reconfig interface to new speed
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_SET_PIO_MODE, val);
+
+	inputs:
+	  New interface speed.
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 255]
+	  EBUSY		Controller busy
+
+
+
+HDIO_SCAN_HWIF			register and (re)scan interface
+
+	usage:
+
+	  int args[3]
+	  ...
+	  ioctl(fd, HDIO_SCAN_HWIF, args);
+
+	inputs:
+	  args[0]	io address to probe
+	  args[1]	control address to probe
+	  args[2]	irq number
+
+	outputs:	none
+
+	error returns:
+	  EACCES	Access denied:  requires CAP_SYS_RAWIO
+	  EIO		Probe failed.
+
+	notes:
+
+	  This ioctl initializes the addresses and irq for a disk
+	  controller, probes for drives, and creates /proc/ide
+	  interfaces as appropiate.
+
+
+
+HDIO_UNREGISTER_HWIF		unregister interface
+
+	usage:
+
+	  int index;
+	  ioctl(fd, HDIO_UNREGISTER_HWIF, index);
+
+	inputs:
+	  index		index of hardware interface to unregister
+
+	outputs:	none
+
+	error returns:
+	  EACCES	Access denied:  requires CAP_SYS_RAWIO
+
+	notes:
+
+	  This ioctl removes a hardware interface from the kernel.
+
+	  Currently (2.6.8) this ioctl silently fails if any drive on
+	  the interface is busy.
+
+
+
+HDIO_SET_WCACHE			change write cache enable-disable
+
+	usage:
+
+	  int val;
+	  ioctl(fd, HDIO_SET_WCACHE, val);
+
+	inputs:
+	  New value for write cache enable
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 1]
+	  EBUSY		Controller busy
+
+
+
+HDIO_SET_ACOUSTIC		change acoustic behavior
+
+	usage:
+
+	  int val;
+	  ioctl(fd, HDIO_SET_ACOUSTIC, val);
+
+	inputs:
+	  New value for drive acoustic settings
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 254]
+	  EBUSY		Controller busy
+
+
+
+HDIO_SET_QDMA			change use-qdma flag
+
+	Not implemented, as of 2.6.8.1
+
+
+
+HDIO_SET_ADDRESS		change lba addressing modes
+
+	usage:
+
+	  int val;
+	  ioctl(fd, HDIO_SET_ADDRESS, val);
+
+	inputs:
+	  New value for addressing mode
+	    0 = 28-bit
+	    1 = 48-bit
+	    2 = 48-bit doing 28-bit
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 2]
+	  EBUSY		Controller busy
+	  EIO		Drive does not support lba48 mode.
+
+
+HDIO_SET_IDE_SCSI
+
+	usage:
+
+	  long val;
+	  ioctl(fd, HDIO_SET_IDE_SCSI, val);
+
+	inputs:
+	  New value for scsi emulation mode (?)
+
+	outputs:	none
+
+	error return:
+	  EINVAL	(bdev != bdev->bd_contains) (not sure what this means)
+	  EACCES	Access denied:  requires CAP_SYS_ADMIN
+	  EINVAL	value out of range [0 1]
+	  EBUSY		Controller busy
+
+
+
+HDIO_SET_SCSI_IDE
+
+	Not implemented, as of 2.6.8.1
+
+
diff -Nru a/Documentation/isdn/README.eicon b/Documentation/isdn/README.eicon
--- a/Documentation/isdn/README.eicon	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,118 +0,0 @@
-$Id: README.eicon,v 1.10.6.1 2001/02/19 10:04:59 armin Exp $
-
-(c) 1999,2000 Armin Schindler (mac@melware.de)
-(c) 1999,2000 Cytronics & Melware (info@melware.de)
-
-This document describes the eicon driver for the
-Eicon active ISDN cards.
-
-It is meant to be used with isdn4linux, an ISDN link-level module 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-
-
-Supported Cards
-===============
-
-Old ISA type
-------------
-- S-Card ISA
-- SX-Card ISA
-- SXn-Card ISA
-- SCOM-Card ISA
-- Quadro-Card ISA
-- S2M-Card ISA
-
-DIVA Server family
-------------------
-- DIVA Server BRI/PCI 2M
-- DIVA Server PRI/PCI 2M (9M 23M 30M)
-- DIVA Server 4BRI/PCI
-	supported functions of onboard DSPs:
-	- analog modem
-	- fax group 2/3 (Fax Class 2 commands)
-	- DTMF detection
-
-
-ISDN D-Channel Protocols
-------------------------
-
-- ETSI (Euro-DSS1) 
-- 1TR6 (German ISDN) *not testet*
-- other protocols exist for the range of DIVA Server cards,
-  but they are not fully testet yet.
-
-
-You can load the module simply by using the insmod or modprobe function :
-
-  insmod eicon [id=driverid] [membase=<membase>] [irq=<irq>]
-
-
-The module will automatically probe the PCI-cards. If the id-option
-is omitted, the driver will assume 'eicon0' for the first pci card and
-increases the digit with each further card. With a given driver-id
-the module appends a number starting with '0'.
-
-For ISA-cards you have to specify membase, irq and id. If id or
-membase is missing/invalid, the driver will not be loaded except
-PCI-cards were found. Additional ISA-cards and irq/membase changes
-can be done with the eiconctrl utility.
-
-After loading the module, you have to download the protocol and
-dsp-code by using the eiconctrl utility of isdn4k-utils.
-
-
-Example for loading and starting a BRI card with E-DSS1 Protocol.
-
-	eiconctrl [-d DriverId] load etsi
-
-Example for a BRI card with E-DSS1 Protocol with PtP configuration.
-
-	eiconctrl [-d DriverId] load etsi -n -t1 -s1
-
-
-Example for loading and starting a PRI card with E-DSS1 Protocol.
-
-	eiconctrl [-d DriverId] load etsi -s2 -n
-
-
-Details about using the eiconctrl utility are in 'man eiconctrl'
-or will be printed by starting eiconctrl without any parameters.
-
-ISDNLOG:
-With eicon driver version 1.77 or newer and the eiconctrl utility
-of version 1.1 or better, you can use the isdnlog user program
-with your DIVA Server BRI card.
-Just use "eiconctrl isdnlog on" and the driver will generate
-the necessary D-Channel traces for isdnlog.
-
-
-
-Thanks to 
-	Deutsche Mailbox Saar-Lor-Lux GmbH
-	for sponsoring and testing fax
-	capabilities with Diva Server cards.
-
-
-Any reports about bugs, errors and even wishes are welcome.
-
-
-Have fun !
-
-Armin Schindler
-mac@melware.de
-http://www.melware.de
-
diff -Nru a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
--- a/Documentation/kbuild/makefiles.txt	2004-12-24 13:37:04 -08:00
+++ b/Documentation/kbuild/makefiles.txt	2004-12-24 13:37:04 -08:00
@@ -6,7 +6,7 @@
 
 	=== 1 Overview
 	=== 2 Who does what
-	=== 3 The kbuild Makefiles
+	=== 3 The kbuild files
 	   --- 3.1 Goal definitions
 	   --- 3.2 Built-in object goals - obj-y
 	   --- 3.3 Loadable module goals - obj-m
@@ -101,11 +101,14 @@
 This document is aimed towards normal developers and arch developers.
 
 
-=== 3 The kbuild Makefiles
+=== 3 The kbuild files
 
 Most Makefiles within the kernel are kbuild Makefiles that use the
 kbuild infrastructure. This chapter introduce the syntax used in the
 kbuild makefiles.
+The preferred name for the kbuild files is 'Kbuild' but 'Makefile' will
+continue to be supported. All new developmen is expected to use the
+Kbuild filename.
 
 Section 3.1 "Goal definitions" is a quick intro, further chapters provide
 more details, with real examples.
@@ -707,15 +710,17 @@
 	probe supported options:
 
 		#arch/i386/Makefile
-		check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc \
-		            /dev/null\ > /dev/null 2>&1; then echo "$(1)"; \
-		            else echo "$(2)"; fi)
-		cflags-$(CONFIG_MCYRIXIII) += $(call check_gcc,\
-		                                     -march=c3,-march=i486)
 
-		CFLAGS += $(cflags-y)
+		...
+		cflags-$(CONFIG_MPENTIUMII)     += $(call cc-option,\
+						-march=pentium2,-march=i686)
+		...
+		# Disable unit-at-a-time mode ...
+		CFLAGS += $(call cc-option,-fno-unit-at-a-time)
+		...
+
 
-	The above examples both utilise the trick that a config option expands
+	The first examples utilises the trick that a config option expands
 	to 'y' when selected.
 
     CFLAGS_KERNEL	$(CC) options specific for built-in
@@ -997,6 +1002,21 @@
 	option. When $(biarch) equals to y the expanded variables $(aflags-y)
 	and $(cflags-y) will be assigned the values -a32 and -m32.
 
+    cc-option-align
+	gcc version >= 3.0 shifted type of options used to speify
+	alignment of functions, loops etc. $(cc-option-align) whrn used
+	as prefix to the align options will select the right prefix:
+	gcc < 3.00
+		cc-option-align = -malign
+	gcc >= 3.00
+		cc-option-align = -falign
+	
+	Example:
+		CFLAGS += $(cc-option-align)-functions=4
+
+	In the above example the option -falign-functions=4 is used for
+	gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
+	
     cc-version
 	cc-version return a numerical version of the $(CC) compiler version.
 	The format is <major><minor> where both are two digits. So for example
diff -Nru a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
--- a/Documentation/kbuild/modules.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/kbuild/modules.txt	2004-12-24 13:37:18 -08:00
@@ -1,68 +1,419 @@
-For now this is a raw copy from the old Documentation/kbuild/modules.txt,
-which was removed in 2.6.0-test5.
-The information herein is correct but not complete.
-
-Installing modules in a non-standard location
----------------------------------------------
-When the modules needs to be installed under another directory
-the INSTALL_MOD_PATH can be used to prefix "/lib/modules" as seen
-in the following example:
-
-make INSTALL_MOD_PATH=/frodo modules_install
-
-This will install the modules in the directory /frodo/lib/modules.
-/frodo can be a NFS mounted filesystem on another machine, allowing
-out-of-the-box support for installation on remote machines.
-
-
-Compiling modules outside the official kernel
----------------------------------------------
-
-Often modules are developed outside the official kernel.  To keep up
-with changes in the build system the most portable way to compile a
-module outside the kernel is to use the kernel build system,
-kbuild. Use the following command-line:
-
-make -C path/to/kernel/src M=$PWD modules
-
-This requires that a makefile exits made in accordance to
-Documentation/kbuild/makefiles.txt. Read that file for more details on
-the build system.
-
-The following is a short summary of how to write your Makefile to get
-you up and running fast. Assuming your module will be called
-yourmodule.ko, your code should be in yourmodule.c and your Makefile
-should include
-
-obj-m := yourmodule.o
-
-If the code for your module is in multiple files that need to be
-linked, you need to tell the build system which files to compile. In
-the case of multiple files, none of these files can be named
-yourmodule.c because doing so would cause a problem with the linking
-step. Assuming your code exists in file1.c, file2.c, and file3.c and
-you want to build yourmodule.ko from them, your Makefile should
-include
-
-obj-m := yourmodule.o
-yourmodule-objs := file1.o file2.o file3.o
-
-Now for a final example to put it all together. Assuming the
-KERNEL_SOURCE environment variable is set to the directory where you
-compiled the kernel, a simple Makefile that builds yourmodule.ko as
-described above would look like
-
-# Tells the build system to build yourmodule.ko.
-obj-m := yourmodule.o
-
-# Tells the build system to build these object files and link them as
-# yourmodule.o, before building yourmodule.ko. This line can be left
-# out if all the code for your module is in one file, yourmodule.c. If
-# you are using multiple files, none of these files can be named
-# yourmodule.c.
-yourmodule-objs := file1.o file2.o file3.o
-
-# Invokes the kernel build system to come back to the current
-# directory and build yourmodule.ko.
-default:
-	make -C ${KERNEL_SOURCE} M=`pwd` modules
+
+In this document you will find information about:
+- how to build external modules
+- how to make your module use kbuild infrastructure
+- how kbuild will install a kernel
+- how to install modules in a non-standard location
+
+=== Table of Contents
+
+	=== 1 Introduction
+	=== 2 How to build external modules
+	   --- 2.1 Building external modules
+	   --- 2.2 Available targets
+	   --- 2.3 Available options
+	   --- 2.4 Preparing the kernel tree for module build
+	=== 3. Example commands
+	=== 4. Creating a kbuild file for an external module
+	=== 5. Include files
+	   --- 5.1 How to include files from the kernel include dir
+	   --- 5.2 External modules using an include/ dir
+	=== 6. Module installation
+	   --- 6.1 INSTALL_MOD_PATH
+	   --- 6.2 INSTALL_MOD_DIR
+	=== 7. Module versioning
+	=== 8. Tips & Tricks
+	   --- 8.1 Testing for CONFIG_FOO_BAR
+
+
+
+=== 1. Introduction
+
+kbuild includes functionality for building modules both
+within the kernel source tree and outside the kernel source tree.
+The latter is usually referred to as external modules and is used
+both during development and for modules that are not planned to be
+included in the kernel tree.
+
+What is covered within this file is mainly information to authors
+of modules. The author of an external modules should supply
+a makefile that hides most of the complexity so one only has to type
+'make' to buld the module. A complete example will be present in
+chapter ¤. Creating a kbuild file for an external module".
+
+
+=== 2. How to build external modules
+
+kbuild offers functionality to build external modules, with the
+prerequisite that there is a pre-built kernel available with full source.
+A subset of the targets available when building the kernel is available
+when building an external module.
+
+--- 2.1 Building external modules
+
+	Use the following command to build an external module:
+
+		make -C <path-to-kernel> M=`pwd`
+
+	For the running kernel use:
+		make -C /lib/modules/`uname -r`/build M=`pwd`
+
+	For the above command to succeed the kernel must have been built with
+	modules enabled.
+
+	To install the modules that were just built:
+
+		make -C <path-to-kernel> M=`pwd` modules_install
+
+	More complex examples later, the above should get you going.
+
+--- 2.2 Available targets
+
+	$KDIR refers to path to kernel source top-level directory
+
+	make -C $KDIR M=`pwd`
+		Will build the module(s) located in current directory.
+		All output files will be located in the same directory
+		as the module source.
+		No attempts are made to update the kernel source, and it is
+		a precondition that a successful make has been executed
+		for the kernel.
+
+	make -C $KDIR M=`pwd` modules
+		The modules target is implied when no target is given.
+		Same functionality as if no target was specified.
+		See description above.
+
+	make -C $KDIR M=$PWD modules_install
+		Install the external module(s).
+		Installation default is in /lib/modules/<kernel-version>/extra,
+		but may be prefixed with INSTALL_MOD_PATH - see separate chater.
+
+	make -C $KDIR M=$PWD clean
+		Remove all generated files for the module - the kernel
+		source directory is not moddified.
+
+	make -C $KDIR M=`pwd` help
+		help will list the available target when building external
+		modules.
+
+--- 2.3 Available options:
+
+	$KDIR refer to path to kernel src
+
+	make -C $KDIR
+		Used to specify where to find the kernel source.
+		'$KDIR' represent the directory where the kernel source is.
+		Make will actually change directory to the specified directory
+		when executed but change back when finished.
+
+	make -C $KDIR M=`pwd`
+		M= is used to tell kbuild that an external module is
+		being built.
+		The option given to M= is the directory where the external
+		module (kbuild file) is located.
+		When an external module is being built only a subset of the
+		usual targets are available.
+
+	make -C $KDIR SUBDIRS=`pwd`
+		Same as M=. The SUBDIRS= syntax is kept for backwards
+		compatibility.
+
+--- 2.4 Preparing the kernel tree for module build
+
+	To make sure the kernel contains the information required to
+	build external modules the target 'modules_prepare' must be used.
+	'module_prepare' solely exists as a simple way to prepare
+	a kernel for building external modules.
+	Note: modules_prepare will not build Module.symvers even if
+	      CONFIG_MODULEVERSIONING is set.
+	      Therefore a full kernel build needs to be executed to make
+	      module versioning work.
+
+
+=== 3. Example commands
+
+This example shows the actual commands to be executed when building
+an external module for the currently running kernel.
+In the example below the distribution is supposed to use the
+facility to locate output files for a kernel compile in a different
+directory than the kernel source - but the examples will also work
+when the source and the output files are mixed in the same directory.
+
+# Kernel source
+/lib/modules/<kernel-version>/source -> /usr/src/linux-<version>
+
+# Output from kernel compile
+/lib/modules/<kernel-version>/build -> /usr/src/linux-<version>-up
+
+Change to the directory where the kbuild file is located and execute
+the following commands to build the module:
+
+	cd /home/user/src/module
+	make -C /usr/src/`uname -r`/source            \
+	        O=/lib/modules/`uname-r`/build        \
+	        M=`pwd`
+
+Then to install the module use the following command:
+
+	make -C /usr/src/`uname -r`/source            \
+	        O=/lib/modules/`uname-r`/build        \
+	        M=`pwd`                               \
+		modules_install
+
+If one looks closely you will see that this is the same commands as
+listed before - with the directories spelled out.
+
+The above are rather long commands, and the following chapter
+lists a few tricks to make it all easier.
+
+
+=== 4. Creating a kbuild file for an external module
+
+kbuild is the build system for the kernel, and external modules
+must use kbuild to stay compatible with changes in the build system
+and to pick up the right flags to gcc etc.
+
+The kbuild file used as input shall follow the syntax described
+in Documentation/kbuild/makefiles.txt. This chapter will introduce a few
+more tricks to be used when dealing with external modules.
+
+In the following a Makefile will be created for a module with the
+following files:
+	8123_if.c
+	8123_if.h
+	8123_pci.c
+	8123_bin.o_shipped	<= Binary blob
+
+--- 4.1 Shared Makefile for module and kernel
+
+	An external module always includes a wrapper Makefile supporting
+	building the module using 'make' with no arguments.
+	The Makefile provided will most likely include additional
+	functionality such as test targets etc. and this part shall
+	be filtered away from kbuild since it may impact kbuild if
+	name clashes occurs.
+
+	Example 1:
+		--> filename: Makefile
+		ifneq ($(KERNELRELEASE),)
+		# kbuild part of makefile
+		obj-m  := 8123.o
+		8123-y := 8123_if.o 8123_pci.o 8123_bin.o
+
+		else
+		# Normal Makefile
+
+		KERNELDIR := /lib/modules/`uname -r`/build
+		all::
+			$(MAKE) -C $KERNELDIR M=`pwd` $@
+
+		# Module specific targets
+		genbin:
+			echo "X" > 8123_bini.o_shipped
+
+		endif
+
+	In example 1 the check for KERNELRELEASE is used to separate
+	the two parts of the Makefile. kbuild will only see the two
+	assignments whereas make will see everything except the two
+	kbuild assignments.
+
+	In recent versions of the kernel, kbuild will look for a file named
+	Kbuild and as second option look for a file named Makefile.
+	Utilising the Kbuild file makes us split up the Makefile in example 1
+	into two files as shown in example 2:
+
+	Example 2:
+		--> filename: Kbuild
+		obj-m  := 8123.o
+		8123-y := 8123_if.o 8123_pci.o 8123_bin.o
+
+		--> filename: Makefile
+		KERNELDIR := /lib/modules/`uname -r`/build
+		all::
+			$(MAKE) -C $KERNELDIR M=`pwd` $@
+
+		# Module specific targets
+		genbin:
+			echo "X" > 8123_bin_shipped
+
+
+	In example 2 we are down to two fairly simple files and for simple
+	files as used in this example the split is questionable. But some
+	external modules use Makefiles of several hundred lines and here it
+	really pays off to separate the kbuild part from the rest.
+	Example 3 shows a backward compatible version.
+
+	Example 3:
+		--> filename: Kbuild
+		obj-m  := 8123.o
+		8123-y := 8123_if.o 8123_pci.o 8123_bin.o
+
+		--> filename: Makefile
+		ifneq ($(KERNELRELEASE),)
+		include Kbuild
+		else
+		# Normal Makefile
+
+		KERNELDIR := /lib/modules/`uname -r`/build
+		all::
+			$(MAKE) -C $KERNELDIR M=`pwd` $@
+
+		# Module specific targets
+		genbin:
+			echo "X" > 8123_bin_shipped
+
+		endif
+
+		The trick here is to include the Kbuild file from Makefile so
+		if an older version of kbuild picks up the Makefile the Kbuild
+		file will be included.
+
+--- 4.2 Binary blobs included in a module
+
+	Some external modules needs to include a .o as a blob. kbuild
+	has support for this, but requires the blob file to be named
+	<filename>_shipped. In our example the blob is named
+	8123_bin.o_shipped and when the kbuild rules kick in the file
+	8123_bin.o is created as a simple copy off the 8213_bin.o_shipped file
+	with the _shipped part stripped of the filename.
+	This allows the 8123_bin.o filename to be used in the assignment to
+	the module.
+
+	Example 4:
+		obj-m  := 8123.o
+		8123-y := 8123_if.o 8123_pci.o 8123_bin.o
+
+	In example 4 there is no distinction between the ordinary .c/.h files
+	and the binary file. But kbuild will pick up different rules to create
+	the .o file.
+
+
+=== 5. Include files
+
+Include files are a necessity when a .c file uses something from another .c
+files (not strictly in the sense of .c but if good programming practice is
+used). Any module that consist of more than one .c file will have a .h file
+for one of the .c files. 
+- If the .h file only describes a module internal interface then the .h file
+  shall be placed in the same directory as the .c files.
+- If the .h files describe an interface used by other parts of the kernel
+  located in different directories, the .h files shall be located in
+  include/linux/ or other include/ directories as appropriate.
+
+One exception for this rule is larger subsystems that have their own directory
+under include/ such as include/scsi. Another exception is arch-specific
+.h files which are located under include/asm-$(ARCH)/*.
+
+External modules have a tendency to locate include files in a separate include/
+directory and therefore needs to deal with this in their kbuild file.
+
+--- 5.1 How to include files from the kernel include dir
+
+	When a module needs to include a file from include/linux/ then one
+	just uses:
+
+		#include <linux/modules.h>
+
+	kbuild will make sure to add options to gcc so the relevant
+	directories are searched.
+	Likewise for .h files placed in the same directory as the .c file.
+
+		#include "8123_if.h"
+
+	will do the job.
+
+--- 5.2 External modules using an include/ dir
+
+	External modules often locate their .h files in a separate include/
+	directory although this is not usual kernel style. When an external
+	module uses an include/ dir then kbuild needs to be told so.
+	The trick here is to use either EXTRA_CFLAGS (take effect for all .c
+	files) or CFLAGS_$F.o (take effect only for a single file).
+
+	In our example if we move 8123_if.h to a subdirectory named include/
+	the resulting Kbuild file would look like:
+
+		--> filename: Kbuild
+		obj-m  := 8123.o
+
+		EXTRA_CFLAGS := -Iinclude
+		8123-y := 8123_if.o 8123_pci.o 8123_bin.o
+
+	Note that in the assingment there is no space between -I and the path.
+	This is a kbuild limitation and no space must be present.
+
+
+=== 6. Module installation
+
+Modules which are included in the kernel is installed in the directory:
+
+	/lib/modules/$(KERNELRELEASE)/kernel
+
+External modules are installed in the directory:
+
+	/lib/modules/$(KERNELRELEASE)/extra
+
+--- 6.1 INSTALL_MOD_PATH
+
+	Above are the default directories, but as always some level of
+	customization is possible. One can prefix the path using the variable
+	INSTALL_MOD_PATH:
+
+		$ make INSTALL_MOD_PATH=/frodo modules_install
+		=> Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel
+
+	INSTALL_MOD_PATH may be set as an ordinary shell variable or as in the
+	example above be specified on the commandline when calling make.
+	INSTALL_MOD_PATH has effect both when installing modules included in
+	the kernel as well as when installing external modules.
+
+--- 6.2 INSTALL_MOD_DIR
+
+	When installing external modules they are default installed in a
+	directory under /lib/modules/$(KERNELRELEASE)/extra, but one may wish
+	to locate modules for a specific functionality in a separate
+	directory. For this purpose one can use INSTALL_MOD_DIR to specify an
+	alternative name than 'extra'.
+
+		$ make INSTALL_MOD_DIR=gandalf -C KERNELDIR \
+			M=`pwd` modules_install
+		=> Install dir: /lib/modules/$(KERNELRELEASE)/gandalf
+
+
+=== 7. Module versioning
+
+Module versioning are enabled by the CONFIG_MODVERSIONS tag.
+
+Module versioning is used as a simple ABI consistency check. The Module
+versioning creates a CRC value of the full prototype for an exported symbol and
+when a module is loaded/used then the CRC values contained in the kernel are
+compared with similar values in the module. If they are not equal then the
+kernel refuses to load the module.
+
+During a kernel build a file named Module.symvers will be generated. This
+file includes the symbol version of all symbols within the kernel. If the 
+Module.symvers file is saved from the last full kernel compile one does not
+have to do a full kernel compile to build a module version's compatible module.
+
+=== 8. Tips & Tricks
+
+--- 8.1 Testing for CONFIG_FOO_BAR
+
+	Modules often needs to check for certain CONFIG_ options to decide if
+	a specific feature shall be included in the module. When kbuild is used
+	this is done by referencing the CONFIG_ variable directly.
+
+		#fs/ext2/Makefile
+		obj-$(CONFIG_EXT2_FS) += ext2.o
+
+		ext2-y := balloc.o bitmap.o dir.o
+		ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o
+
+	External modules have traditionally used grep to check for specific
+	CONFIG_ settings directly in .config. This usage is broken.
+	As introduced before external modules shall use kbuild when building
+	and therefore can use the same methods as in-kernel modules when testing
+	for CONFIG_ definitions.
+
diff -Nru a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
--- a/Documentation/kernel-parameters.txt	2004-12-24 13:37:43 -08:00
+++ b/Documentation/kernel-parameters.txt	2004-12-24 13:37:43 -08:00
@@ -53,6 +53,7 @@
 	NFS	Appropriate NFS support is enabled.
 	OSS	OSS sound support is enabled.
 	PARIDE	The ParIDE subsystem is enabled.
+	PARISC	The PA-RISC architecture is enabled.
 	PCI	PCI bus support is enabled.
 	PCMCIA	The PCMCIA subsystem is enabled.
 	PNP	Plug & Play support is enabled.
@@ -311,8 +312,24 @@
 	condev=		[HW,S390] console device
 	conmode=
  
-	console=	[KNL] Output console
-			Console device and comm spec (speed, control, parity).
+	console=	[KNL] Output console device and options.
+
+		tty<n>	Use the virtual console device <n>.
+
+		ttyS<n>[,options]
+			Use the specified serial port.  The options are of
+			the form "bbbbpn", where "bbbb" is the baud rate,
+			"p" is parity ("n", "o", or "e"), and "n" is bits.
+			Default is "9600n8".
+
+			See also Documentation/serial-console.txt.
+
+		uart,io,<addr>[,options]
+		uart,mmio,<addr>[,options]
+			Start an early, polled-mode console on the 8250/16550
+			UART at the specified I/O port or MMIO address,
+			switching to the matching ttyS device later.  The
+			options are the same as for ttyS, above.
 
 	cpcihp_generic=	[HW,PCI] Generic port I/O CompactPCI driver
 			Format: <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
@@ -394,7 +411,7 @@
 	eicon=		[HW,ISDN] 
 			Format: <id>,<membase>,<irq>
 
-	eisa_irq_edge=	[PARISC]
+	eisa_irq_edge=	[PARISC,HW]
 			See header of drivers/parisc/eisa.c.
 
 	elanfreq=	[IA-32]
@@ -403,7 +420,8 @@
 
 	elevator=	[IOSCHED]
 			Format: {"as"|"cfq"|"deadline"|"noop"}
-			See Documentation/as-iosched.txt for details
+			See Documentation/block/as-iosched.txt
+			and Documentation/block/deadline-iosched.txt for details.
 
 	es1370=		[HW,OSS]
 			Format: <lineout>[,<micbias>]
@@ -488,16 +506,26 @@
 
 	i810=		[HW,DRM]
 
+	i8k.force	[HW] Activate i8k driver even if SMM BIOS signature
+			does not match list of supported models.
+	i8k.power_status
+			[HW] Report power status in /proc/i8k
+			(disabled by default)
+	i8k.restricted	[HW] Allow controlling fans only if SYS_ADMIN
+			capability is set.
+
 	ibmmcascsi=	[HW,MCA,SCSI] IBM MicroChannel SCSI adapter
 			See Documentation/mca.txt.
 
 	icn=		[HW,ISDN]
 			Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]]
 
+	ide=		[HW] (E)IDE subsystem
+			Format: ide=nodma or ide=doubler or ide=reverse
+			See Documentation/ide.txt.
+
 	ide?=		[HW] (E)IDE subsystem
-			Config (iomem/irq), tuning or debugging
-			(serialize,reset,no{dma,tune,probe}) or chipset
-			specific parameters.
+			Format: ide?=noprobe or chipset specific parameters.
 			See Documentation/ide.txt.
 	
 	idebus=		[HW] (E)IDE subsystem - VLB/PCI bus speed
@@ -643,9 +671,10 @@
 	maxcpus=	[SMP] Maximum number of processors that	an SMP kernel
 			should make use of
 
-	max_scsi_luns=	[SCSI]
+	max_luns=	[SCSI] Maximum number of LUNs to probe
+			Should be between 1 and 2^32-1.
 
-	max_scsi_report_luns=
+	max_report_luns=
 			[SCSI] Maximum number of LUNs received
 			Should be between 1 and 16384.
 
@@ -670,6 +699,9 @@
 	mem=nn[KMG]	[KNL,BOOT] Force usage of a specific amount of memory
 			Amount of memory to be used when the kernel is not able
 			to see the whole system memory or for test.
+			[IA-32] Use together with memmap= to avoid physical
+			address space collisions. Without memmap= PCI devices
+			could be placed at addresses belonging to unused RAM.
 
 	mem=nopentium	[BUGS=IA-32] Disable usage of 4MB pages for kernel
 			memory.
@@ -692,7 +724,7 @@
 			[KNL,ACPI] Mark specific memory as reserved.
 			Region of memory to be used, from ss to ss+nn.
 
-	meye=		[HW] Set MotionEye Camera parameters
+	meye.*=		[HW] Set MotionEye Camera parameters
 			See Documentation/video4linux/meye.txt.
 
 	mga=		[HW,DRM]
@@ -754,8 +786,8 @@
 
 	noalign		[KNL,ARM] 
  
-	noapic		[SMP,APIC] Tells the kernel not to make use of any
-			APIC that may be present on the system.
+	noapic		[SMP,APIC] Tells the kernel to not make use of any
+			IOAPICs that may be present in the system.
 
 	noasync		[HW,M68K] Disables async and sync negotiation for
 			all devices.
@@ -769,14 +801,12 @@
 
 	noexec		[IA-64]
 
-	noexec		[i386]
+	noexec		[i386, x86_64]
 			noexec=on: enable non-executable mappings (default)
 			noexec=off: disable nn-executable mappings
 
 	nofxsr		[BUGS=IA-32]
 
-	nohighio	[BUGS=IA-32] Disable highmem block I/O.
-
 	nohlt		[BUGS=ARM]
  
 	no-hlt		[BUGS=IA-32] Tells the kernel that the hlt
@@ -857,6 +887,16 @@
 					order they are specified on the command
 					line, starting with parport0.
 
+	parport_init_mode=
+			[HW,PPT]	Configure VIA parallel port to
+					operate in specific mode. This is
+					necessary on Pegasos computer where
+					firmware has no options for setting up
+					parallel port mode and sets it to
+					spp. Currently this function knows
+					686a and 8231 chips.
+			Format: [spp|ps2|epp|ecp|ecpepp]
+
 	pas2=		[HW,OSS]
 			Format: <io>,<irq>,<dma>,<dma16>,<sb_io>,<sb_irq>,<sb_dma>,<sb_dma16>
  
@@ -912,6 +952,10 @@
 					enabled.
 		noacpi			[IA-32] Do not use ACPI for IRQ routing
 					or for PCI scanning.
+		routeirq		Do IRQ routing for all PCI devices.
+					This is normally done in pci_enable_device(),
+					so this option is a temporary workaround
+					for broken drivers that don't call it.
 
 		firmware		[ARM] Do not re-enumerate the bus but
 					instead just use the configuration
@@ -925,6 +969,11 @@
 	pd.		[PARIDE]
 			See Documentation/paride.txt.
 
+	pdcchassis=	[PARISC,HW] Disable/Enable PDC Chassis Status codes at
+			boot time.
+			Format: { 0 | 1 }
+			See arch/parisc/kernel/pdc_chassis.c
+
 	pf.		[PARIDE]
 			See Documentation/paride.txt.
 
@@ -960,6 +1009,10 @@
 			(param: profile step/bucket size as a power of 2 for
 				statistical time based profiling)
 
+	processor.max_cstate=   [HW, ACPI]
+			Limit processor to maximum C-state
+			max_cstate=9 overrides any DMI blacklist limit.
+
 	prompt_ramdisk=	[RAM] List of RAM disks to prompt for floppy disk
 			before loading.
 			See Documentation/ramdisk.txt.
@@ -1001,10 +1054,6 @@
 			New name for the ramdisk parameter.
 			See Documentation/ramdisk.txt.
 
-	ramdisk_start=	[RAM] Starting block of RAM disk image (so you can
-			place it after the kernel image on a boot floppy).
-			See Documentation/ramdisk.txt.
-
 	reboot=		[BUGS=IA-32,BUGS=ARM,BUGS=IA-64] Rebooting mode
 			Format: <reboot_mode>[,<reboot_mode2>[,...]]
 			See arch/*/kernel/reboot.c.
@@ -1060,8 +1109,6 @@
 
 	scsi_logging=	[SCSI]
 
-	scsihosts=	[SCSI]
-
 	serialnumber	[BUGS=IA-32]
 
 	sf16fm=		[HW] SF16FMI radio driver for Linux
@@ -1219,17 +1266,12 @@
 	sonycd535=	[HW,CD]
 			Format: <io>[,<irq>]
 
-	sonypi=		[HW] Sony Programmable I/O Control Device driver
-			Format: <minor>,<verbose>,<fnkeyinit>,<camera>,<compat>,<nojogdial>
+	sonypi.*=	[HW] Sony Programmable I/O Control Device driver
+			See Documentation/sonypi.txt
 
 	specialix=	[HW,SERIAL] Specialix multi-serial port adapter
 			See Documentation/specialix.txt.
 
-	speedstep_coppermine=
-			[HW,IA-32] Take CPU in your notebook as SpeedStep-capable
-			See comment before function speedstep_setup() in
-			arch/i386/kernel/cpu/cpufreq/speedstep.c.
-
 	spia_io_base=	[HW,MTD]
 	spia_fio_base=
 	spia_pedr=
@@ -1244,7 +1286,7 @@
 	st0x=		[HW,SCSI]
 			See header of drivers/scsi/seagate.c.
 
-	sti=		[HW]
+	sti=		[PARISC,HW]
 			Format: <num>
 			Set the STI (builtin display/keyboard on the HP-PARISC
 			machines) console (graphic card) which should be used
@@ -1311,6 +1353,8 @@
 
 	uart6850=	[HW,OSS]
 			Format: <io>,<irq>
+
+	usb-handoff	[HW] Enable early USB BIOS -> OS handoff
  
 	video=		[FB] Frame buffer configuration
 			See Documentation/fb/modedb.txt.
diff -Nru a/Documentation/keys.txt b/Documentation/keys.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/keys.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,836 @@
+			 ============================
+			 KERNEL KEY RETENTION SERVICE
+			 ============================
+
+This service allows cryptographic keys, authentication tokens, cross-domain
+user mappings, and similar to be cached in the kernel for the use of
+filesystems other kernel services.
+
+Keyrings are permitted; these are a special type of key that can hold links to
+other keys. Processes each have three standard keyring subscriptions that a
+kernel service can search for relevant keys.
+
+The key service can be configured on by enabling:
+
+	"Security options"/"Enable access key retention support" (CONFIG_KEYS)
+
+This document has the following sections:
+
+	- Key overview
+	- Key service overview
+	- Key access permissions
+	- New procfs files
+	- Userspace system call interface
+	- Kernel services
+	- Defining a key type
+	- Request-key callback service
+	- Key access filesystem
+
+
+============
+KEY OVERVIEW
+============
+
+In this context, keys represent units of cryptographic data, authentication
+tokens, keyrings, etc.. These are represented in the kernel by struct key.
+
+Each key has a number of attributes:
+
+	- A serial number.
+	- A type.
+	- A description (for matching a key in a search).
+	- Access control information.
+	- An expiry time.
+	- A payload.
+	- State.
+
+
+ (*) Each key is issued a serial number of type key_serial_t that is unique
+     for the lifetime of that key. All serial numbers are positive non-zero
+     32-bit integers.
+
+     Userspace programs can use a key's serial numbers as a way to gain access
+     to it, subject to permission checking.
+
+ (*) Each key is of a defined "type". Types must be registered inside the
+     kernel by a kernel service (such as a filesystem) before keys of that
+     type can be added or used. Userspace programs cannot define new types
+     directly.
+
+     Key types are represented in the kernel by struct key_type. This defines
+     a number of operations that can be performed on a key of that type.
+
+     Should a type be removed from the system, all the keys of that type will
+     be invalidated.
+
+ (*) Each key has a description. This should be a printable string. The key
+     type provides an operation to perform a match between the description on
+     a key and a criterion string.
+
+ (*) Each key has an owner user ID, a group ID and a permissions mask. These
+     are used to control what a process may do to a key from userspace, and
+     whether a kernel service will be able to find the key.
+
+ (*) Each key can be set to expire at a specific time by the key type's
+     instantiation function. Keys can also be immortal.
+
+ (*) Each key can have a payload. This is a quantity of data that represent
+     the actual "key". In the case of a keyring, this is a list of keys to
+     which the keyring links; in the case of a user-defined key, it's an
+     arbitrary blob of data.
+
+     Having a payload is not required; and the payload can, in fact, just be a
+     value stored in the struct key itself.
+
+     When a key is instantiated, the key type's instantiation function is
+     called with a blob of data, and that then creates the key's payload in
+     some way.
+
+     Similarly, when userspace wants to read back the contents of the key, if
+     permitted, another key type operation will be called to convert the key's
+     attached payload back into a blob of data.
+
+ (*) Each key can be in one of a number of basic states:
+
+     (*) Uninstantiated. The key exists, but does not have any data
+	 attached. Keys being requested from userspace will be in this state.
+
+     (*) Instantiated. This is the normal state. The key is fully formed, and
+	 has data attached.
+
+     (*) Negative. This is a relatively short-lived state. The key acts as a
+	 note saying that a previous call out to userspace failed, and acts as
+	 a throttle on key lookups. A negative key can be updated to a normal
+	 state.
+
+     (*) Expired. Keys can have lifetimes set. If their lifetime is exceeded,
+	 they traverse to this state. An expired key can be updated back to a
+	 normal state.
+
+     (*) Revoked. A key is put in this state by userspace action. It can't be
+	 found or operated upon (apart from by unlinking it).
+
+     (*) Dead. The key's type was unregistered, and so the key is now useless.
+
+
+====================
+KEY SERVICE OVERVIEW
+====================
+
+The key service provides a number of features besides keys:
+
+ (*) The key service defines two special key types:
+
+     (+) "keyring"
+
+	 Keyrings are special keys that contain a list of other keys. Keyring
+	 lists can be modified using various system calls. Keyrings should not
+	 be given a payload when created.
+
+     (+) "user"
+
+	 A key of this type has a description and a payload that are arbitrary
+	 blobs of data. These can be created, updated and read by userspace,
+	 and aren't intended for use by kernel services.
+
+ (*) Each process subscribes to three keyrings: a thread-specific keyring, a
+     process-specific keyring, and a session-specific keyring.
+
+     The thread-specific keyring is discarded from the child when any sort of
+     clone, fork, vfork or execve occurs. A new keyring is created only when
+     required.
+
+     The process-specific keyring is replaced with an empty one in the child
+     on clone, fork, vfork unless CLONE_THREAD is supplied, in which case it
+     is shared. execve also discards the process's process keyring and creates
+     a new one.
+
+     The session-specific keyring is persistent across clone, fork, vfork and
+     execve, even when the latter executes a set-UID or set-GID binary. A
+     process can, however, replace its current session keyring with a new one
+     by using PR_JOIN_SESSION_KEYRING. It is permitted to request an anonymous
+     new one, or to attempt to create or join one of a specific name.
+
+     The ownership of the thread and process-specific keyrings changes when
+     the real UID and GID of the thread changes.
+
+ (*) Each user ID resident in the system holds two special keyrings: a user
+     specific keyring and a default user session keyring. The default session
+     keyring is initialised with a link to the user-specific keyring.
+
+     When a process changes its real UID, if it used to have no session key, it
+     will be subscribed to the default session key for the new UID.
+
+     If a process attempts to access its session key when it doesn't have one,
+     it will be subscribed to the default for its current UID.
+
+ (*) Each user has two quotas against which the keys they own are tracked. One
+     limits the total number of keys and keyrings, the other limits the total
+     amount of description and payload space that can be consumed.
+
+     The user can view information on this and other statistics through procfs
+     files.
+
+     Process-specific and thread-specific keyrings are not counted towards a
+     user's quota.
+
+     If a system call that modifies a key or keyring in some way would put the
+     user over quota, the operation is refused and error EDQUOT is returned.
+
+ (*) There's a system call interface by which userspace programs can create
+     and manipulate keys and keyrings.
+
+ (*) There's a kernel interface by which services can register types and
+     search for keys.
+
+ (*) There's a way for the a search done from the kernel to call back to
+     userspace to request a key that can't be found in a process's keyrings.
+
+ (*) An optional filesystem is available through which the key database can be
+     viewed and manipulated.
+
+
+======================
+KEY ACCESS PERMISSIONS
+======================
+
+Keys have an owner user ID, a group access ID, and a permissions mask. The
+mask has up to eight bits each for user, group and other access. Only five of
+each set of eight bits are defined. These permissions granted are:
+
+ (*) View
+
+     This permits a key or keyring's attributes to be viewed - including key
+     type and description.
+
+ (*) Read
+
+     This permits a key's payload to be viewed or a keyring's list of linked
+     keys.
+
+ (*) Write
+
+     This permits a key's payload to be instantiated or updated, or it allows
+     a link to be added to or removed from a keyring.
+
+ (*) Search
+
+     This permits keyrings to be searched and keys to be found. Searches can
+     only recurse into nested keyrings that have search permission set.
+
+ (*) Link
+
+     This permits a key or keyring to be linked to. To create a link from a
+     keyring to a key, a process must have Write permission on the keyring and
+     Link permission on the key.
+
+For changing the ownership, group ID or permissions mask, being the owner of
+the key or having the sysadmin capability is sufficient.
+
+
+================
+NEW PROCFS FILES
+================
+
+Two files have been added to procfs by which an administrator can find out
+about the status of the key service:
+
+ (*) /proc/keys
+
+     This lists all the keys on the system, giving information about their
+     type, description and permissions. The payload of the key is not
+     available this way:
+
+	SERIAL   FLAGS  USAGE EXPY PERM   UID   GID   TYPE      DESCRIPTION: SUMMARY
+	00000001 I-----    39 perm 1f0000     0     0 keyring   _uid_ses.0: 1/4
+	00000002 I-----     2 perm 1f0000     0     0 keyring   _uid.0: empty
+	00000007 I-----     1 perm 1f0000     0     0 keyring   _pid.1: empty
+	0000018d I-----     1 perm 1f0000     0     0 keyring   _pid.412: empty
+	000004d2 I--Q--     1 perm 1f0000    32    -1 keyring   _uid.32: 1/4
+	000004d3 I--Q--     3 perm 1f0000    32    -1 keyring   _uid_ses.32: empty
+	00000892 I--QU-     1 perm 1f0000     0     0 user      metal:copper: 0
+	00000893 I--Q-N     1  35s 1f0000     0     0 user      metal:silver: 0
+	00000894 I--Q--     1  10h 1f0000     0     0 user      metal:gold: 0
+
+     The flags are:
+
+	I	Instantiated
+	R	Revoked
+	D	Dead
+	Q	Contributes to user's quota
+	U	Under contruction by callback to userspace
+	N	Negative key
+
+     This file must be enabled at kernel configuration time as it allows anyone
+     to list the keys database.
+
+ (*) /proc/key-users
+
+     This file lists the tracking data for each user that has at least one key
+     on the system. Such data includes quota information and statistics:
+
+	[root@andromeda root]# cat /proc/key-users
+	0:     46 45/45 1/100 13/10000
+	29:     2 2/2 2/100 40/10000
+	32:     2 2/2 2/100 40/10000
+	38:     2 2/2 2/100 40/10000
+
+     The format of each line is
+	<UID>:			User ID to which this applies
+	<usage>			Structure refcount
+	<inst>/<keys>		Total number of keys and number instantiated
+	<keys>/<max>		Key count quota
+	<bytes>/<max>		Key size quota
+
+
+===============================
+USERSPACE SYSTEM CALL INTERFACE
+===============================
+
+Userspace can manipulate keys directly through three new syscalls: add_key,
+request_key and keyctl. The latter provides a number of functions for
+manipulating keys.
+
+When referring to a key directly, userspace programs should use the key's
+serial number (a positive 32-bit integer). However, there are some special
+values available for referring to special keys and keyrings that relate to the
+process making the call:
+
+	CONSTANT			VALUE	KEY REFERENCED
+	==============================	======	===========================
+	KEY_SPEC_THREAD_KEYRING		-1	thread-specific keyring
+	KEY_SPEC_PROCESS_KEYRING	-2	process-specific keyring
+	KEY_SPEC_SESSION_KEYRING	-3	session-specific keyring
+	KEY_SPEC_USER_KEYRING		-4	UID-specific keyring
+	KEY_SPEC_USER_SESSION_KEYRING	-5	UID-session keyring
+	KEY_SPEC_GROUP_KEYRING		-6	GID-specific keyring
+
+
+The main syscalls are:
+
+ (*) Create a new key of given type, description and payload and add it to the
+     nominated keyring:
+
+	key_serial_t add_key(const char *type, const char *desc,
+			     const void *payload, size_t plen,
+			     key_serial_t keyring);
+
+     If a key of the same type and description as that proposed already exists
+     in the keyring, this will try to update it with the given payload, or it
+     will return error EEXIST if that function is not supported by the key
+     type. The process must also have permission to write to the key to be
+     able to update it. The new key will have all user permissions granted and
+     no group or third party permissions.
+
+     Otherwise, this will attempt to create a new key of the specified type
+     and description, and to instantiate it with the supplied payload and
+     attach it to the keyring. In this case, an error will be generated if the
+     process does not have permission to write to the keyring.
+
+     The payload is optional, and the pointer can be NULL if not required by
+     the type. The payload is plen in size, and plen can be zero for an empty
+     payload.
+
+     A new keyring can be generated by setting type "keyring", the keyring
+     name as the description (or NULL) and setting the payload to NULL.
+
+     User defined keys can be created by specifying type "user". It is
+     recommended that a user defined key's description by prefixed with a type
+     ID and a colon, such as "krb5tgt:" for a Kerberos 5 ticket granting
+     ticket.
+
+     Any other type must have been registered with the kernel in advance by a
+     kernel service such as a filesystem.
+
+     The ID of the new or updated key is returned if successful.
+
+
+ (*) Search the process's keyrings for a key, potentially calling out to
+     userspace to create it.
+
+	key_serial_t request_key(const char *type, const char *description,
+				 const char *callout_info,
+				 key_serial_t dest_keyring);
+
+     This function searches all the process's keyrings in the order thread,
+     process, session for a matching key. This works very much like
+     KEYCTL_SEARCH, including the optional attachment of the discovered key to
+     a keyring.
+
+     If a key cannot be found, and if callout_info is not NULL, then
+     /sbin/request-key will be invoked in an attempt to obtain a key. The
+     callout_info string will be passed as an argument to the program.
+
+
+The keyctl syscall functions are:
+
+ (*) Map a special key ID to a real key ID for this process:
+
+	key_serial_t keyctl(KEYCTL_GET_KEYRING_ID, key_serial_t id,
+			    int create);
+
+     The special key specified by "id" is looked up (with the key being
+     created if necessary) and the ID of the key or keyring thus found is
+     returned if it exists.
+
+     If the key does not yet exist, the key will be created if "create" is
+     non-zero; and the error ENOKEY will be returned if "create" is zero.
+
+
+ (*) Replace the session keyring this process subscribes to with a new one:
+
+	key_serial_t keyctl(KEYCTL_JOIN_SESSION_KEYRING, const char *name);
+
+     If name is NULL, an anonymous keyring is created attached to the process
+     as its session keyring, displacing the old session keyring.
+
+     If name is not NULL, if a keyring of that name exists, the process
+     attempts to attach it as the session keyring, returning an error if that
+     is not permitted; otherwise a new keyring of that name is created and
+     attached as the session keyring.
+
+     To attach to a named keyring, the keyring must have search permission for
+     the process's ownership.
+
+     The ID of the new session keyring is returned if successful.
+
+
+ (*) Update the specified key:
+
+	long keyctl(KEYCTL_UPDATE, key_serial_t key, const void *payload,
+		    size_t plen);
+
+     This will try to update the specified key with the given payload, or it
+     will return error EOPNOTSUPP if that function is not supported by the key
+     type. The process must also have permission to write to the key to be
+     able to update it.
+
+     The payload is of length plen, and may be absent or empty as for
+     add_key().
+
+
+ (*) Revoke a key:
+
+	long keyctl(KEYCTL_REVOKE, key_serial_t key);
+
+     This makes a key unavailable for further operations. Further attempts to
+     use the key will be met with error EKEYREVOKED, and the key will no longer
+     be findable.
+
+
+ (*) Change the ownership of a key:
+
+	long keyctl(KEYCTL_CHOWN, key_serial_t key, uid_t uid, gid_t gid);
+
+     This function permits a key's owner and group ID to be changed. Either
+     one of uid or gid can be set to -1 to suppress that change.
+
+     Only the superuser can change a key's owner to something other than the
+     key's current owner. Similarly, only the superuser can change a key's
+     group ID to something other than the calling process's group ID or one of
+     its group list members.
+
+
+ (*) Change the permissions mask on a key:
+
+	long keyctl(KEYCTL_SETPERM, key_serial_t key, key_perm_t perm);
+
+     This function permits the owner of a key or the superuser to change the
+     permissions mask on a key.
+
+     Only bits the available bits are permitted; if any other bits are set,
+     error EINVAL will be returned.
+
+
+ (*) Describe a key:
+
+	long keyctl(KEYCTL_DESCRIBE, key_serial_t key, char *buffer,
+		    size_t buflen);
+
+     This function returns a summary of the key's attributes (but not its
+     payload data) as a string in the buffer provided.
+
+     Unless there's an error, it always returns the amount of data it could
+     produce, even if that's too big for the buffer, but it won't copy more
+     than requested to userspace. If the buffer pointer is NULL then no copy
+     will take place.
+
+     A process must have view permission on the key for this function to be
+     successful.
+
+     If successful, a string is placed in the buffer in the following format:
+
+	<type>;<uid>;<gid>;<perm>;<description>
+
+     Where type and description are strings, uid and gid are decimal, and perm
+     is hexadecimal. A NUL character is included at the end of the string if
+     the buffer is sufficiently big.
+
+     This can be parsed with
+
+	sscanf(buffer, "%[^;];%d;%d;%o;%s", type, &uid, &gid, &mode, desc);
+
+
+ (*) Clear out a keyring:
+
+	long keyctl(KEYCTL_CLEAR, key_serial_t keyring);
+
+     This function clears the list of keys attached to a keyring. The calling
+     process must have write permission on the keyring, and it must be a
+     keyring (or else error ENOTDIR will result).
+
+
+ (*) Link a key into a keyring:
+
+	long keyctl(KEYCTL_LINK, key_serial_t keyring, key_serial_t key);
+
+     This function creates a link from the keyring to the key. The process
+     must have write permission on the keyring and must have link permission
+     on the key.
+
+     Should the keyring not be a keyring, error ENOTDIR will result; and if
+     the keyring is full, error ENFILE will result.
+
+     The link procedure checks the nesting of the keyrings, returning ELOOP if
+     it appears to deep or EDEADLK if the link would introduce a cycle.
+
+
+ (*) Unlink a key or keyring from another keyring:
+
+	long keyctl(KEYCTL_UNLINK, key_serial_t keyring, key_serial_t key);
+
+     This function looks through the keyring for the first link to the
+     specified key, and removes it if found. Subsequent links to that key are
+     ignored. The process must have write permission on the keyring.
+
+     If the keyring is not a keyring, error ENOTDIR will result; and if the
+     key is not present, error ENOENT will be the result.
+
+
+ (*) Search a keyring tree for a key:
+
+	key_serial_t keyctl(KEYCTL_SEARCH, key_serial_t keyring,
+			    const char *type, const char *description,
+			    key_serial_t dest_keyring);
+
+     This searches the keyring tree headed by the specified keyring until a
+     key is found that matches the type and description criteria. Each keyring
+     is checked for keys before recursion into its children occurs.
+
+     The process must have search permission on the top level keyring, or else
+     error EACCES will result. Only keyrings that the process has search
+     permission on will be recursed into, and only keys and keyrings for which
+     a process has search permission can be matched. If the specified keyring
+     is not a keyring, ENOTDIR will result.
+
+     If the search succeeds, the function will attempt to link the found key
+     into the destination keyring if one is supplied (non-zero ID). All the
+     constraints applicable to KEYCTL_LINK apply in this case too.
+
+     Error ENOKEY, EKEYREVOKED or EKEYEXPIRED will be returned if the search
+     fails. On success, the resulting key ID will be returned.
+
+
+ (*) Read the payload data from a key:
+
+	key_serial_t keyctl(KEYCTL_READ, key_serial_t keyring, char *buffer,
+			    size_t buflen);
+
+     This function attempts to read the payload data from the specified key
+     into the buffer. The process must have read permission on the key to
+     succeed.
+
+     The returned data will be processed for presentation by the key type. For
+     instance, a keyring will return an array of key_serial_t entries
+     representing the IDs of all the keys to which it is subscribed. The user
+     defined key type will return its data as is. If a key type does not
+     implement this function, error EOPNOTSUPP will result.
+
+     As much of the data as can be fitted into the buffer will be copied to
+     userspace if the buffer pointer is not NULL.
+
+     On a successful return, the function will always return the amount of
+     data available rather than the amount copied.
+
+
+ (*) Instantiate a partially constructed key.
+
+	key_serial_t keyctl(KEYCTL_INSTANTIATE, key_serial_t key,
+			    const void *payload, size_t plen,
+			    key_serial_t keyring);
+
+     If the kernel calls back to userspace to complete the instantiation of a
+     key, userspace should use this call to supply data for the key before the
+     invoked process returns, or else the key will be marked negative
+     automatically.
+
+     The process must have write access on the key to be able to instantiate
+     it, and the key must be uninstantiated.
+
+     If a keyring is specified (non-zero), the key will also be linked into
+     that keyring, however all the constraints applying in KEYCTL_LINK apply
+     in this case too.
+
+     The payload and plen arguments describe the payload data as for add_key().
+
+
+ (*) Negatively instantiate a partially constructed key.
+
+	key_serial_t keyctl(KEYCTL_NEGATE, key_serial_t key,
+			    unsigned timeout, key_serial_t keyring);
+
+     If the kernel calls back to userspace to complete the instantiation of a
+     key, userspace should use this call mark the key as negative before the
+     invoked process returns if it is unable to fulfil the request.
+
+     The process must have write access on the key to be able to instantiate
+     it, and the key must be uninstantiated.
+
+     If a keyring is specified (non-zero), the key will also be linked into
+     that keyring, however all the constraints applying in KEYCTL_LINK apply
+     in this case too.
+
+
+===============
+KERNEL SERVICES
+===============
+
+The kernel services for key managment are fairly simple to deal with. They can
+be broken down into two areas: keys and key types.
+
+Dealing with keys is fairly straightforward. Firstly, the kernel service
+registers its type, then it searches for a key of that type. It should retain
+the key as long as it has need of it, and then it should release it. For a
+filesystem or device file, a search would probably be performed during the
+open call, and the key released upon close. How to deal with conflicting keys
+due to two different users opening the same file is left to the filesystem
+author to solve.
+
+When accessing a key's payload data, the key->lock should be at least read
+locked, or else the data may be changed by update during the access.
+
+(*) To search for a key, call:
+
+	struct key *request_key(const struct key_type *type,
+				const char *description,
+				const char *callout_string);
+
+    This is used to request a key or keyring with a description that matches
+    the description specified according to the key type's match function. This
+    permits approximate matching to occur. If callout_string is not NULL, then
+    /sbin/request-key will be invoked in an attempt to obtain the key from
+    userspace. In that case, callout_string will be passed as an argument to
+    the program.
+
+    Should the function fail error ENOKEY, EKEYEXPIRED or EKEYREVOKED will be
+    returned.
+
+
+(*) When it is no longer required, the key should be released using:
+
+	void key_put(struct key *key);
+
+    This can be called from interrupt context. If CONFIG_KEYS is not set then
+    the argument will not be parsed.
+
+
+(*) Extra references can be made to a key by calling the following function:
+
+	struct key *key_get(struct key *key);
+
+    These need to be disposed of by calling key_put() when they've been
+    finished with. The key pointer passed in will be returned. If the pointer
+    is NULL or CONFIG_KEYS is not set then the key will not be dereferenced and
+    no increment will take place.
+
+
+(*) A key's serial number can be obtained by calling:
+
+	key_serial_t key_serial(struct key *key);
+
+    If key is NULL or if CONFIG_KEYS is not set then 0 will be returned (in the
+    latter case without parsing the argument).
+
+
+(*) If a keyring was found in the search, this can be further searched by:
+
+	struct key *keyring_search(struct key *keyring,
+				   const struct key_type *type,
+				   const char *description)
+
+    This searches the keyring tree specified for a matching key. Error ENOKEY
+    is returned upon failure. If successful, the returned key will need to be
+    released.
+
+
+(*) To check the validity of a key, this function can be called:
+
+	int validate_key(struct key *key);
+
+    This checks that the key in question hasn't expired or and hasn't been
+    revoked. Should the key be invalid, error EKEYEXPIRED or EKEYREVOKED will
+    be returned. If the key is NULL or if CONFIG_KEYS is not set then 0 will be
+    returned (in the latter case without parsing the argument).
+
+
+(*) To register a key type, the following function should be called:
+
+	int register_key_type(struct key_type *type);
+
+    This will return error EEXIST if a type of the same name is already
+    present.
+
+
+(*) To unregister a key type, call:
+
+	void unregister_key_type(struct key_type *type);
+
+
+===================
+DEFINING A KEY TYPE
+===================
+
+A kernel service may want to define its own key type. For instance, an AFS
+filesystem might want to define a Kerberos 5 ticket key type. To do this, it
+author fills in a struct key_type and registers it with the system.
+
+The structure has a number of fields, some of which are mandatory:
+
+ (*) const char *name
+
+     The name of the key type. This is used to translate a key type name
+     supplied by userspace into a pointer to the structure.
+
+
+ (*) size_t def_datalen
+
+     This is optional - it supplies the default payload data length as
+     contributed to the quota. If the key type's payload is always or almost
+     always the same size, then this is a more efficient way to do things.
+
+     The data length (and quota) on a particular key can always be changed
+     during instantiation or update by calling:
+
+	int key_payload_reserve(struct key *key, size_t datalen);
+
+     With the revised data length. Error EDQUOT will be returned if this is
+     not viable.
+
+
+ (*) int (*instantiate)(struct key *key, const void *data, size_t datalen);
+
+     This method is called to attach a payload to a key during
+     construction. The payload attached need not bear any relation to the data
+     passed to this function.
+
+     If the amount of data attached to the key differs from the size in
+     keytype->def_datalen, then key_payload_reserve() should be called.
+
+
+ (*) int (*duplicate)(struct key *key, const struct key *source);
+
+     If this type of key can be duplicated, then this method should be
+     provided. It is called to copy the payload attached to the source into
+     the new key. The data length on the new key will have been updated and
+     the quota adjusted already.
+
+     The source key will be locked against change on the source->sem, so it is
+     safe to sleep here.
+
+
+ (*) int (*update)(struct key *key, const void *data, size_t datalen);
+
+     If this type of key can be updated, then this method should be
+     provided. It is called to update a key's payload from the blob of data
+     provided.
+
+     key_payload_reserve() should be called if the data length might change
+     before any changes are actually made. Note that if this succeeds, the
+     type is committed to changing the key because it's already been altered,
+     so all memory allocation must be done first.
+
+     The key will be locked against other changers on key->sem, so it is safe
+     to sleep here.
+
+     key_payload_reserve() should be called with the key->lock write locked,
+     and the changes to the key's attached payload should be made before the
+     key is locked.
+
+
+ (*) int (*match)(const struct key *key, const void *desc);
+
+     This method is called to match a key against a description. It should
+     return non-zero if the two match, zero if they don't.
+
+
+ (*) void (*destroy)(struct key *key);
+
+     This method is optional. It is called to discard the payload data on a
+     key when it is being destroyed.
+
+
+ (*) void (*describe)(const struct key *key, struct seq_file *p);
+
+     This method is optional. It is called during /proc/keys reading to
+     summarise a key in text form.
+
+
+ (*) long (*read)(const struct key *key, char __user *buffer, size_t buflen);
+
+     This method is optional. It is called by KEYCTL_READ to translate the
+     key's payload into something a blob of data for userspace to deal
+     with. Ideally, the blob should be in the same format as that passed in to
+     the instantiate and update methods.
+
+     If successful, the blob size that could be produced should be returned
+     rather than the size copied.
+
+
+============================
+REQUEST-KEY CALLBACK SERVICE
+============================
+
+To create a new key, the kernel will attempt to execute the following command
+line:
+
+	/sbin/request-key create <key> <uid> <gid> \
+		<threadring> <processring> <sessionring> <callout_info>
+
+<key> is the key being constructed, and the three keyrings are the process
+keyrings from the process that caused the search to be issued. These are
+included for two reasons:
+
+  (1) There may be an authentication token in one of the keyrings that is
+      required to obtain the key, eg: a Kerberos Ticket-Granting Ticket.
+
+  (2) The new key should probably be cached in one of these rings.
+
+This program should set it UID and GID to those specified before attempting to
+access any more keys. It may then look around for a user specific process to
+hand the request off to (perhaps a path held in placed in another key by, for
+example, the KDE desktop manager).
+
+The program (or whatever it calls) should finish construction of the key by
+calling KEYCTL_INSTANTIATE, which also permits it to cache the key in one of
+the keyrings (probably the session ring) before returning. Alternatively, the
+key can be marked as negative with KEYCTL_NEGATE; this also permits the key to
+be cached in one of the keyrings.
+
+If it returns with the key remaining in the unconstructed state, the key will
+be marked as being negative, it will be added to the session keyring, and an
+error will be returned to the key requestor.
+
+Supplementary information may be provided from whoever or whatever invoked
+this service. This will be passed as the <callout_info> parameter. If no such
+information was made available, then "-" will be passed as this parameter
+instead.
+
+
+Similarly, the kernel may attempt to update an expired or a soon to expire key
+by executing:
+
+	/sbin/request-key update <key> <uid> <gid> \
+		<threadring> <processring> <sessionring>
+
+In this case, the program isn't required to actually attach the key to a ring;
+the rings are provided for reference.
diff -Nru a/Documentation/md.txt b/Documentation/md.txt
--- a/Documentation/md.txt	2004-12-24 13:37:01 -08:00
+++ b/Documentation/md.txt	2004-12-24 13:37:01 -08:00
@@ -45,7 +45,8 @@
 When md is compiled into the kernel (not as module), partitions of
 type 0xfd are scanned and automatically assembled into RAID arrays.
 This autodetection may be suppressed with the kernel parameter
-"raid=noautodetect".
+"raid=noautodetect".  As of kernel 2.6.9, only drives with a type 0
+superblock can be autodetected and run at boot time.
 
 The kernel parameter "raid=partitionable" (or "raid=part") means
 that all auto-detected arrays are assembled as partitionable.
@@ -55,13 +56,13 @@
 ------------------
 
 The md driver can support a variety of different superblock formats.
-(It doesn't yet, but it can)
+Currently, it supports superblock formats "0.90.0" and the "md-1" format
+introduced in the 2.5 development series.
 
-The kernel does *NOT* autodetect which format superblock is being
-used. It must be told.
+The kernel will autodetect which format superblock is being used.
 
 Superblock format '0' is treated differently to others for legacy
-reasons.
+reasons - it is the original superblock format.
 
 
 General Rules - apply for all superblock formats
@@ -69,6 +70,7 @@
 
 An array is 'created' by writing appropriate superblocks to all
 devices.
+
 It is 'assembled' by associating each of these devices with an
 particular md virtual device.  Once it is completely assembled, it can
 be accessed.
@@ -76,10 +78,10 @@
 An array should be created by a user-space tool.  This will write
 superblocks to all devices.  It will usually mark the array as
 'unclean', or with some devices missing so that the kernel md driver
-can create approrpriate redundancy (copying in raid1, parity
+can create appropriate redundancy (copying in raid1, parity
 calculation in raid4/5).
 
-When an array is assembled, it is first initialised with the
+When an array is assembled, it is first initialized with the
 SET_ARRAY_INFO ioctl.  This contains, in particular, a major and minor
 version number.  The major version number selects which superblock
 format is to be used.  The minor number might be used to tune handling
@@ -101,15 +103,16 @@
 
 
 Specific Rules that apply to format-0 super block arrays, and
-       arrays with no superblock (non-persistant).
+       arrays with no superblock (non-persistent).
 -------------------------------------------------------------
 
 An array can be 'created' by describing the array (level, chunksize
 etc) in a SET_ARRAY_INFO ioctl.  This must has major_version==0 and
 raid_disks != 0.
-Then uninitialised devices can be added with ADD_NEW_DISK.  The
+
+Then uninitialized devices can be added with ADD_NEW_DISK.  The
 structure passed to ADD_NEW_DISK must specify the state of the device
 and it's role in the array.
 
-One started with RUN_ARRAY, uninitialised spares can be added with
+Once started with RUN_ARRAY, uninitialized spares can be added with
 HOT_ADD_DISK.
diff -Nru a/Documentation/memory.txt b/Documentation/memory.txt
--- a/Documentation/memory.txt	2004-12-24 13:37:33 -08:00
+++ b/Documentation/memory.txt	2004-12-24 13:37:33 -08:00
@@ -21,6 +21,8 @@
 All of these problems can be addressed with the "mem=XXXM" boot option
 (where XXX is the size of RAM to use in megabytes).  
 It can also tell Linux to use less memory than is actually installed.
+If you use "mem=" on a machine with PCI, consider using "memmap=" to avoid
+physical address space collisions.
 
 See the documentation of your boot loader (LILO, loadlin, etc.) about
 how to pass options to the kernel.
@@ -44,7 +46,9 @@
 	* Disabling the cache from the BIOS.
 
 	* Try passing the "mem=4M" option to the kernel to limit
-	  Linux to using a very small amount of memory.
+	  Linux to using a very small amount of memory. Use "memmap="-option
+	  together with "mem=" on systems with PCI to avoid physical address
+	  space collisions.
 
 
 Other tricks:
diff -Nru a/Documentation/mkdev.ida b/Documentation/mkdev.ida
--- a/Documentation/mkdev.ida	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,40 +0,0 @@
-#!/bin/sh
-# Script to create device nodes for SMART array controllers
-# Usage:
-#	mkdev.ida [num controllers] [num log volumes] [num partitions]
-#
-# With no arguments, the script assumes 1 controller, 16 logical volumes,
-# and 16 partitions/volume, which is adequate for most configurations.
-#
-# If you had 5 controllers and were planning on no more than 4 logical volumes
-# each, using a maximum of 8 partitions per volume, you could say:
-#
-# mkdev.ida 5 4 8
-#
-# Of course, this has no real benefit over "mkdev.ida 5" except that it
-# doesn't create so many device nodes in /dev/ida.
-
-NR_CTLR=${1-1}
-NR_VOL=${2-16}
-NR_PART=${3-16}
-
-if [ ! -d /dev/ida ]; then
-	mkdir -p /dev/ida
-fi
-
-C=0; while [ $C -lt $NR_CTLR ]; do
-	MAJ=`expr $C + 72`
-	D=0; while [ $D -lt $NR_VOL ]; do
-		P=0; while [ $P -lt $NR_PART ]; do
-			MIN=`expr $D \* 16 + $P`
-			if [ $P -eq 0 ]; then
-				mknod /dev/ida/c${C}d${D} b $MAJ $MIN
-			else
-				mknod /dev/ida/c${C}d${D}p${P} b $MAJ $MIN
-			fi
-			P=`expr $P + 1`
-		done
-		D=`expr $D + 1`
-	done
-	C=`expr $C + 1`
-done
diff -Nru a/Documentation/networking/e100.txt b/Documentation/networking/e100.txt
--- a/Documentation/networking/e100.txt	2004-12-24 13:37:19 -08:00
+++ b/Documentation/networking/e100.txt	2004-12-24 13:37:19 -08:00
@@ -1,14 +1,16 @@
 Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters
 ==============================================================
 
-March 15, 2004
+September 13, 2004
 
 
 Contents
 ========
 
 - In This Release
-- Supported Adapters
+- Identifying Your Adapter
+- Driver Configuration Parameters
+- Additional Configurations
 - Support
 
 
@@ -16,26 +18,140 @@
 ===============
 
 This file describes the Linux* Base Driver for the Intel(R) PRO/100 Family of
-Adapters, version 3.x.x.  This driver includes support for Itanium(TM)-based 
-systems.
+Adapters, version 3.2.x.  This driver includes support for Itanium(TM)2 and
+EM64T systems.
 
 
-Supported Adapters
-==================
-
-To verify that your adapter is supported, find the board ID number on the 
-adapter. Look for a label that has a barcode and a number in the format 
-A12345-001. Match this to the list of numbers above.
+Identifying Your Adapter
+========================
 
 For more information on how to identify your adapter, go to the Adapter & 
 Driver ID Guide at:
 
   http://support.intel.com/support/network/adapter/pro100/21397.htm
 
-For the latest Intel PRO/100 network driver for Linux, see:
+For the latest Intel network drivers for Linux, refer to the following 
+website. In the search field, enter your adapter name or type, or use the 
+networking link on the left to search for your adapter:
 
   http://downloadfinder.intel.com/scripts-df/support_intel.asp
 
+Driver Configuration Parameters
+===============================
+
+The default value for each parameter is generally the recommended setting,
+unless otherwise noted.
+
+Rx Descriptors: Number of receive descriptors. A receive descriptor is a data 
+   structure that describes a receive buffer and its attributes to the network 
+   controller. The data in the descriptor is used by the controller to write 
+   data from the controller to host memory. In the 3.0.x driver the valid
+   range for this parameter is 64-256. The default value is 64. This parameter 
+   can be changed using the command 
+ 
+   ethtool -G eth? rx n, where n is the number of desired rx descriptors.
+
+Tx Descriptors: Number of transmit descriptors. A transmit descriptor is a
+   data structure that describes a transmit buffer and its attributes to the
+   network controller. The data in the descriptor is used by the controller to 
+   read data from the host memory to the controller. In the 3.0.x driver the 
+   valid range for this parameter is 64-256. The default value is 64. This 
+   parameter can be changed using the command 
+
+   ethtool -G eth? tx n, where n is the number of desired tx descriptors.
+
+Speed/Duplex: The driver auto-negotiates the link speed and duplex settings by 
+   default. Ethtool can be used as follows to force speed/duplex. 
+
+   ethtool -s eth?  autoneg off speed {10|100} duplex {full|half}
+
+   NOTE: setting the speed/duplex to incorrect values will cause the link to
+   fail.
+
+Event Log Message Level:  The driver uses the message level flag to log events 
+   to syslog. The message level can be set at driver load time. It can also be 
+   set using the command
+
+   ethtool -s eth? msglvl n
+
+Additional Configurations
+=========================
+
+  Configuring the Driver on Different Distributions
+  -------------------------------------------------
+
+  Configuring a network driver to load properly when the system is started is 
+  distribution dependent. Typically, the configuration process involves adding 
+  an alias line to /etc/modules.conf as well as editing other system startup 
+  scripts and/or configuration files.  Many popular Linux distributions ship 
+  with tools to make these changes for you. To learn the proper way to 
+  configure a network device for your system, refer to your distribution 
+  documentation. If during this process you are asked for the driver or module 
+  name, the name for the Linux Base Driver for the Intel PRO/100 Family of 
+  Adapters is e100.
+
+  As an example, if you install the e100 driver for two PRO/100 adapters 
+  (eth0 and eth1), add the following to modules.conf:
+
+       alias eth0 e100
+       alias eth1 e100
+
+  Viewing Link Messages
+  ---------------------
+  In order to see link messages and other Intel driver information on your 
+  console, you must set the dmesg level up to six. This can be done by 
+  entering the following on the command line before loading the e100 driver: 
+
+       dmesg -n 8
+
+  If you wish to see all messages issued by the driver, including debug 
+  messages, set the dmesg level to eight.
+
+  NOTE: This setting is not saved across reboots.
+
+  Ethtool
+  -------
+
+  The driver utilizes the ethtool interface for driver configuration and
+  diagnostics, as well as displaying statistical information.  Ethtool
+  version 1.6 or later is required for this functionality.
+
+  The latest release of ethtool can be found at:
+  http://sf.net/projects/gkernel.  
+
+  After ethtool is installed, ethtool-copy.h must be copied and renamed to
+  ethtool.h in your kernel source tree at <linux_kernel_src>/include/linux.  
+  Backup the original ethtool.h as needed before copying.  The driver then 
+  must be recompiled in order to take advantage of the latest ethtool 
+  features.
+
+  NOTE: This driver uses mii support from the kernel. As a result, when 
+  there is no link, ethtool will report speed/duplex to be 10/half.
+
+  NOTE: Ethtool 1.6 only supports a limited set of ethtool options. Support 
+  for a more complete ethtool feature set can be enabled by upgrading 
+  ethtool to ethtool-1.8.1. 
+
+  Enabling Wake on LAN* (WoL)
+  ---------------------------
+  WoL is provided through the Ethtool* utility. Ethtool is included with Red 
+  Hat* 8.0. For other Linux distributions, download and install Ethtool from 
+  the following website: http://sourceforge.net/projects/gkernel. 
+
+  For instructions on enabling WoL with Ethtool, refer to the Ethtool man
+  page.
+
+  WoL will be enabled on the system during the next shut down or reboot. For
+  this driver version, in order to enable WoL, the e100 driver must be 
+  loaded when shutting down or rebooting the system.
+
+  NAPI
+  ----
+
+  NAPI (Rx polling mode) is supported in the e100 driver. NAPI is enabled
+  or disabled based on the configuration of the kernel. 
+
+  See www.cyberus.ca/~hadi/usenix-paper.tgz for more information on NAPI.
 
 Support
 =======
diff -Nru a/Documentation/networking/e1000.txt b/Documentation/networking/e1000.txt
--- a/Documentation/networking/e1000.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/networking/e1000.txt	2004-12-24 13:37:18 -08:00
@@ -1,14 +1,14 @@
 Linux* Base Driver for the Intel(R) PRO/1000 Family of Adapters
 ===============================================================
 
-January 8, 2003
+September 13, 2004
 
 
 Contents
 ========
 
 - In This Release
-- Supported Adapters
+- Identifying Your Adapter
 - Command Line Parameters
 - Speed and Duplex Configuration
 - Additional Configurations
@@ -20,63 +20,29 @@
 ===============
 
 This file describes the Linux* Base Driver for the Intel(R) PRO/1000 Family
-of Adapters, version 5.0.x.  This driver includes support for 
-Itanium(TM)-based systems.
+of Adapters, version 5.x.x.  This driver includes support for Itanium(TM)2 
+and EM64T systems.
 
+For questions related to hardware requirements, refer to the documentation 
+supplied with your Intel PRO/1000 adapter. All hardware requirements listed 
+apply to use with Linux.
 
 Native VLANs are now available with supported kernels.
 
-
-Supported Adapters
-==================
-
-The following Intel network adapters are compatible with the drivers in this 
-release:
-
-   Controller  Adapter Name                         Board IDs
-   ----------  ------------                         ---------
-
-   82542       PRO/1000 Gigabit Server Adapter      700262-xxx, 717037-xxx
-
-   82543       PRO/1000 F Server Adapter            738640-xxx, A38888-xxx
-
-   82543       PRO/1000 T Server Adapter            A19845-xxx, A33948-xxx
-
-   82544       PRO/1000 XT Server Adapter           A51580-xxx
-
-   82544       PRO/1000 XF Server Adapter           A50484-xxx
-
-   82544       PRO/1000 T Desktop Adapter           A62947-xxx
-
-   82540       PRO/1000 MT Desktop Adapter          A78408-xxx
-   82541                                            C91016-xxx
-
-   82545       PRO/1000 MT Server Adapter           A92165-xxx
-
-   82546       PRO/1000 MT Dual Port Server Adapter A92111-xxx
-
-   82545       PRO/1000 MF Server Adapter           A91622-xxx
-
-   82545       PRO/1000 MF Server Adapter(LX)       A91624-xxx
-
-   82546       PRO/1000 MF Dual Port Server Adapter A91620-xxx
-
-
-
-To verify your Intel adapter is supported, find the board ID number on the 
-adapter. Look for a label that has a barcode and a number in the format  
-A12345-001. Match this to the list of numbers above.
+Identifying Your Adapter
+========================
 
 For more information on how to identify your adapter, go to the Adapter & 
 Driver ID Guide at:
 
     http://support.intel.com/support/network/adapter/pro100/21397.htm
 
-For the latest Intel network drivers for Linux, refer to the following
+For the latest Intel network drivers for Linux, refer to the following 
+website. In the search field, enter your adapter name or type, or use the 
+networking link on the left to search for your adapter:
 
     http://downloadfinder.intel.com/scripts-df/support_intel.asp
 
-
 Command Line Parameters
 =======================
 
@@ -92,27 +58,39 @@
 
      insmod e1000 TxDescriptors=80,128
 
-loads the e1000 driver with 80 TX resources for the first adapter and 128 TX 
-resources for the second adapter.
+loads the e1000 driver with 80 TX descriptors for the first adapter and 128 TX 
+descriptors for the second adapter.
 
 The default value for each parameter is generally the recommended setting,
-unless otherwise noted.
-
-For more information about the AutoNeg, Duplex, and Speed parameters, see the
-"Speed and Duplex Configuration" section in this document.
+unless otherwise noted. Also, if the driver is statically built into the
+kernel, the driver is loaded with the default values for all the parameters.
+Ethtool can be used to change some of the parameters at runtime.
+
+    NOTES: For more information about the AutoNeg, Duplex, and Speed
+           parameters, see the "Speed and Duplex Configuration" section in 
+           this document.
+
+           For more information about the InterruptThrottleRate, RxIntDelay, 
+           TxIntDelay, RxAbsIntDelay, and TxAbsIntDelay parameters, see the 
+           application note at:
+           http://www.intel.com/design/network/applnots/ap450.htm
 
+           A descriptor describes a data buffer and attributes related to the 
+           data buffer. This information is accessed by the hardware.
 
 AutoNeg (adapters using copper connections only)
 Valid Range: 0x01-0x0F, 0x20-0x2F
 Default Value: 0x2F
     This parameter is a bit mask that specifies which speed and duplex
     settings the board advertises. When this parameter is used, the Speed and
-    Duplex parameters must not be specified.  
+    Duplex parameters must not be specified.
+    NOTE: Refer to the Speed and Duplex section of this readme for more 
+          information on the AutoNeg parameter.  
 
 Duplex (adapters using copper connections only)
 Valid Range: 0-2 (0=auto-negotiate, 1=half, 2=full)
 Default Value: 0
-    Defines the direction in which data is allowed to flow. Can by either one 
+    Defines the direction in which data is allowed to flow. Can be either one 
     or two-directional. If both Duplex and the link partner are set to auto-
     negotiate, the board auto-detects the correct duplex. If the link partner
     is forced (either full or half), Duplex defaults to half-duplex.
@@ -125,22 +103,46 @@
 
 InterruptThrottleRate
 Valid Range: 100-100000 (0=off, 1=dynamic)
-Default Value: 1
+Default Value: 8000
     This value represents the maximum number of interrupts per second the 
     controller generates. InterruptThrottleRate is another setting used in 
     interrupt moderation. Dynamic mode uses a heuristic algorithm to adjust 
     InterruptThrottleRate based on the current traffic load.
+Un-supported Adapters: InterruptThrottleRate is NOT supported by 82542, 82543
+    or 82544-based adapters.
 
     NOTE: InterruptThrottleRate takes precedence over the TxAbsIntDelay and 
           RxAbsIntDelay parameters. In other words, minimizing the receive 
           and/or transmit absolute delays does not force the controller to 
           generate more interrupts than what the Interrupt Throttle Rate 
           allows.
+    CAUTION: If you are using the Intel PRO/1000 CT Network Connection 
+             (controller 82547), setting InterruptThrottleRate to a value 
+             greater than 75,000, may hang (stop transmitting) adapters under 
+             certain network conditions. If this occurs a NETDEV WATCHDOG 
+             message is logged in the system event log. In addition, the 
+             controller is automatically reset, restoring the network 
+             connection. To eliminate the potential for the hang, ensure 
+             that InterruptThrottleRate is set no greater than 75,000 and is 
+             not set to 0.
+    NOTE: When e1000 is loaded with default settings and multiple adapters are 
+          in use simultaneously, the CPU utilization may increase non-linearly. 
+          In order to limit the CPU utilization without impacting the overall 
+          throughput, we recommend that you load the driver as follows:
+
+              insmod e1000.o InterruptThrottleRate=3000,3000,3000
+
+          This sets the InterruptThrottleRate to 3000 interrupts/sec for the 
+          first, second, and third instances of the driver. The range of 2000 to 
+          3000 interrupts per second works on a majority of systems and is a 
+          good starting point, but the optimal value will be platform-specific. 
+          If CPU utilization is not a concern, use RX_POLLING (NAPI) and default 
+          driver settings.
 
 RxDescriptors
 Valid Range: 80-256 for 82542 and 82543-based adapters
-             80-4096 for 82540, 82544, 82545, and 82546-based adapters
-Default Value: 80
+             80-4096 for all other supported adapters
+Default Value: 256
     This value is the number of receive descriptors allocated by the driver. 
     Increasing this value allows the driver to buffer more incoming packets. 
     Each descriptor is 16 bytes.  A receive buffer is also allocated for each
@@ -149,6 +151,9 @@
 
     NOTE: MTU designates the frame size. It only needs to be set for Jumbo 
           Frames.
+    NOTE: Depending on the available system resources, the request for a
+    higher number of receive descriptors may be denied.  In this case,
+    use a lower number.
 
 RxIntDelay
 Valid Range: 0-65535 (0=off)
@@ -168,11 +173,11 @@
              restoring the network connection. To eliminate the potential for
              the hang ensure that RxIntDelay is set to 0.
 
-RxAbsIntDelay (82540, 82545, and 82546-based adapters only)
+RxAbsIntDelay (82540, 82545 and later adapters only)
 Valid Range: 0-65535 (0=off)
 Default Value: 128
     This value, in units of 1.024 microseconds, limits the delay in which a 
-    transmit interrupt is generated. Useful only if RxIntDelay is non-zero, 
+    receive interrupt is generated. Useful only if RxIntDelay is non-zero, 
     this value ensures that an interrupt is generated after the initial 
     packet is received within the set amount of time.  Proper tuning,
     along with RxIntDelay, may improve traffic throughput in specific network
@@ -188,12 +193,16 @@
 
 TxDescriptors
 Valid Range: 80-256 for 82542 and 82543-based adapters
-             80-4096 for 82540, 82544, 82545, and 82546-based adapters
+             80-4096 for all other supported adapters
 Default Value: 256
     This value is the number of transmit descriptors allocated by the driver.
     Increasing this value allows the driver to queue more transmits. Each 
     descriptor is 16 bytes.
 
+    NOTE: Depending on the available system resources, the request for a
+    higher number of transmit descriptors may be denied.  In this case,
+    use a lower number.
+
 TxIntDelay
 Valid Range: 0-65535 (0=off)
 Default Value: 64
@@ -203,7 +212,7 @@
     system is reporting dropped transmits, this value may be set too high
     causing the driver to run out of available transmit descriptors.
 
-TxAbsIntDelay (82540, 82545, and 82546-based adapters only)
+TxAbsIntDelay (82540, 82545 and later adapters only)
 Valid Range: 0-65535 (0=off)
 Default Value: 64
     This value, in units of 1.024 microseconds, limits the delay in which a 
@@ -219,7 +228,6 @@
     A value of '1' indicates that the driver should enable IP checksum
     offload for received packets (both UDP and TCP) to the adapter hardware.
 
-
 Speed and Duplex Configuration
 ==============================
 
@@ -251,6 +259,10 @@
 Speed (Mbps)   N/A    N/A    1000    N/A     100    100    10      10
 Duplex                       Full            Full   Half   Full    Half
 
+For example to limit the negotiated speed/duplex on the interface to 10 Mbps 
+Half or Full duplex, set AutoNeg to 0x02: 
+    insmod e1000 AutoNeg=0x02
+
 Note that setting AutoNeg does not guarantee that the board will link at the 
 highest specified speed or duplex mode, but the board will link at the 
 highest possible speed/duplex of the link partner IF the link partner is also
@@ -261,6 +273,38 @@
 Additional Configurations
 =========================
 
+  Configuring the Driver on Different Distributions
+  -------------------------------------------------
+
+  Configuring a network driver to load properly when the system is started is
+  distribution dependent. Typically, the configuration process involves adding
+  an alias line to /etc/modules.conf as well as editing other system startup 
+  scripts and/or configuration files. Many popular Linux distributions ship 
+  with tools to make these changes for you. To learn the proper way to 
+  configure a network device for your system, refer to your distribution 
+  documentation. If during this process you are asked for the driver or module 
+  name, the name for the Linux Base Driver for the Intel PRO/1000 Family of 
+  Adapters is e1000.
+
+  As an example, if you install the e1000 driver for two PRO/1000 adapters 
+  (eth0 and eth1) and set the speed and duplex to 10full and 100half, add the 
+  following to modules.conf:
+
+       alias eth0 e1000
+       alias eth1 e1000
+       options e1000 Speed=10,100 Duplex=2,1
+
+  Viewing Link Messages
+  ---------------------
+
+  Link messages will not be displayed to the console if the distribution is 
+  restricting system messages. In order to see network driver link messages on 
+  your console, set dmesg to eight by entering the following:
+
+       dmesg -n 8
+
+  NOTE: This setting is not saved across reboots.
+
   Jumbo Frames
   ------------
 
@@ -278,6 +322,51 @@
   10 or 100 Mbps may result in poor performance or loss of link.
 
 
+  NOTE: MTU designates the frame size. To enable Jumbo Frames, increase the
+  MTU size on the interface beyond 1500.
+
+  Ethtool
+  -------
+
+  The driver utilizes the ethtool interface for driver configuration and
+  diagnostics, as well as displaying statistical information.  Ethtool
+  version 1.6 or later is required for this functionality.
+
+  The latest release of ethtool can be found from
+  http://sf.net/projects/gkernel.  After ethtool is installed,
+  ethtool-copy.h must be copied and renamed to ethtool.h in your kernel
+  source tree at <linux_kernel_src>/include/linux.  Backup the original
+  ethtool.h as needed before copying.  The driver then must be recompiled
+  in order to take advantage of the latest ethtool features.
+
+  NOTE: Ethtool 1.6 only supports a limited set of ethtool options. Support 
+  for a more complete ethtool feature set can be enabled by upgrading 
+  ethtool to ethtool-1.8.1. 
+
+  Enabling Wake on LAN* (WoL)
+  ---------------------------
+
+  WoL is configured through the Ethtool* utility. Ethtool is included with
+  all versions of Red Hat after Red Hat 7.2. For other Linux distributions, 
+  download and install Ethtool from the following website: 
+  http://sourceforge.net/projects/gkernel.
+
+  For instructions on enabling WoL with Ethtool, refer to the website listed 
+  above.
+
+  WoL will be enabled on the system during the next shut down or reboot. 
+  For this driver version, in order to enable WoL, the e1000 driver must be 
+  loaded when shutting down or rebooting the system.
+
+  NAPI
+  ----
+
+  NAPI (Rx polling mode) is supported in the e1000 driver. NAPI is enabled
+  or disabled based on the configuration of the kernel. 
+
+  See www.cyberus.ca/~hadi/usenix-paper.tgz for more information on NAPI.
+
+
 Known Issues
 ============
 
@@ -285,9 +374,9 @@
   -------------------------------
 
   Memory allocation failures have been observed on Linux systems with 64 MB 
-  of RAM or less that are running Jumbo Frames. If you are using Jumbo 
-  Frames, your system may require more than the advertised minimum 
-  requirement of 64 MB of system memory.
+  of RAM or less that are running Jumbo Frames. If you are using Jumbo Frames,
+  your system may require more than the advertised minimum requirement of 64 MB
+  of system memory.
 
 
 Support
diff -Nru a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
--- a/Documentation/networking/ip-sysctl.txt	2004-12-24 13:36:48 -08:00
+++ b/Documentation/networking/ip-sysctl.txt	2004-12-24 13:36:48 -08:00
@@ -355,6 +355,12 @@
 	conections.
 	Default: 7
 
+tcp_tso_win_divisor - INTEGER
+       This allows control over what percentage of the congestion window
+       can be consumed by a single TSO frame.
+       The setting of this parameter is a choice between burstiness and
+       building larger TSO frames.
+       Default: 8
 
 tcp_frto - BOOLEAN
 	Enables F-RTO, an enhanced recovery algorithm for TCP retransmission
diff -Nru a/Documentation/networking/ixgb.txt b/Documentation/networking/ixgb.txt
--- a/Documentation/networking/ixgb.txt	2004-12-24 13:37:02 -08:00
+++ b/Documentation/networking/ixgb.txt	2004-12-24 13:37:02 -08:00
@@ -1,14 +1,14 @@
 Linux* Base Driver for the Intel(R) PRO/10GbE Family of Adapters
 ================================================================
 
-January 06, 2003
+September 13, 2004
 
 
 Contents
 ========
 
 - In This Release
-- Supported Adapters
+- Identifying Your Adapter
 - Command Line Parameters
 - Improving Performance
 - Support
@@ -18,36 +18,23 @@
 ===============
 
 This file describes the Linux* Base Driver for the Intel(R) PRO/10GbE Family 
-of Adapters, version 1.0.x. This driver is intended for 2.4.x kernels; it is 
-known to build properly on 2.4.x kernels through 2.4.18. Intel focused 
-testing on Intel architectures running kernels 2.4.18. This driver includes 
-support for Itanium(TM)-based systems.
+of Adapters, version 1.0.x.  This driver includes support for Itanium(TM)2 and
+EM64T systems.
 
 For questions related to hardware requirements, refer to the documentation 
 supplied with your Intel PRO/10GbE adapter. All hardware requirements listed 
 apply to use with Linux.
 
-
-Supported Adapters
-==================
-
-The following Intel network adapters are compatible with the drivers in this 
-release:
-
-   Controller  Adapter Name                           Board IDs
-   ----------  ------------                           ---------
-
-   82597EX     Intel(R) PRO/10GbE LR Server Adapter   A82505-xxx
-
+Identifying Your Adapter
+========================
 
 To verify your Intel adapter is supported, find the board ID number on the 
 adapter. Look for a label that has a barcode and a number in the format  
-A12345-001. Match this to the list of numbers above.
+A12345-001. 
 
-For more information on how to identify your adapter, go to the Adapter & 
-Driver ID Guide at:
+Use the above information and the Adapter & Driver ID Guide at:
 
-    http://support.intel.com/support/network/adapter/pro100/21397.htm
+  http://support.intel.com/support/network/adapter/pro100/21397.htm
 
 For the latest Intel network drivers for Linux, go to:
 
@@ -72,8 +59,9 @@
 resources for the second adapter.
 
 The default value for each parameter is generally the recommended setting,
-unless otherwise noted.
-
+unless otherwise noted. Also, if the driver is statically built into the
+kernel, the driver is loaded with the default values for all the parameters.
+Ethtool can be used to change some of the parameters at runtime.
 
 FlowControl
 Valid Range: 0-3 (0=none, 1=Rx only, 2=Tx only, 3=Rx&Tx)
@@ -124,7 +112,6 @@
     A value of '1' indicates that the driver should enable IP checksum
     offload for transmitted packets (both UDP and TCP) to the adapter 
     hardware.
-
 
 Improving Performance
 =====================
diff -Nru a/Documentation/networking/proc_net_tcp.txt b/Documentation/networking/proc_net_tcp.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/networking/proc_net_tcp.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,47 @@
+This document describes the interfaces /proc/net/tcp and /proc/net/tcp6.
+
+These /proc interfaces provide information about currently active TCP 
+connections, and are implemented by tcp_get_info() in net/ipv4/tcp_ipv4.c and
+tcp6_get_info() in net/ipv6/tcp_ipv6.c, respectively.
+
+It will first list all listening TCP sockets, and next list all established
+TCP connections. A typical entry of /proc/net/tcp would look like this (split 
+up into 3 parts because of the length of the line):
+
+   46: 010310AC:9C4C 030310AC:1770 01 
+   |      |      |      |      |   |--> connection state
+   |      |      |      |      |------> remote TCP port number
+   |      |      |      |-------------> remote IPv4 address
+   |      |      |--------------------> local TCP port number
+   |      |---------------------------> local IPv4 address
+   |----------------------------------> number of entry
+
+   00000150:00000000 01:00000019 00000000  
+      |        |     |     |       |--> number of unrecovered RTO timeouts
+      |        |     |     |----------> number of jiffies until timer expires
+      |        |     |----------------> timer_active (see below)
+      |        |----------------------> receive-queue
+      |-------------------------------> transmit-queue
+
+   1000        0 54165785 4 cd1e6040 25 4 27 3 -1
+    |          |    |     |    |     |  | |  | |--> slow start size threshold, 
+    |          |    |     |    |     |  | |  |      or -1 if the treshold
+    |          |    |     |    |     |  | |  |      is >= 0xFFFF
+    |          |    |     |    |     |  | |  |----> sending congestion window
+    |          |    |     |    |     |  | |-------> (ack.quick<<1)|ack.pingpong
+    |          |    |     |    |     |  |---------> Predicted tick of soft clock
+    |          |    |     |    |     |              (delayed ACK control data)
+    |          |    |     |    |     |------------> retransmit timeout
+    |          |    |     |    |------------------> location of socket in memory
+    |          |    |     |-----------------------> socket reference count
+    |          |    |-----------------------------> inode
+    |          |----------------------------------> unanswered 0-window probes
+    |---------------------------------------------> uid
+
+timer_active:
+  0  no timer is pending
+  1  retransmit-timer is pending
+  2  another timer (e.g. delayed ack or keepalive) is pending
+  3  this is a socket in TIME_WAIT state. Not all fields will contain 
+     data (or even exist)
+  4  zero window probe timer is pending
diff -Nru a/Documentation/nmi_watchdog.txt b/Documentation/nmi_watchdog.txt
--- a/Documentation/nmi_watchdog.txt	2004-12-24 13:36:31 -08:00
+++ b/Documentation/nmi_watchdog.txt	2004-12-24 13:36:31 -08:00
@@ -54,6 +54,20 @@
 cannot even accept NMI interrupts, or the crash has made the kernel
 unable to print messages.
 
+Be aware that when using local APIC, the frequency of NMI interrupts
+it generates, depends on the system load. The local APIC NMI watchdog,
+lacking a better source, uses the "cycles unhalted" event. As you may
+guess it doesn't tick when the CPU is in the halted state (which happens
+when the system is idle), but if your system locks up on anything but the
+"hlt" processor instruction, the watchdog will trigger very soon as the
+"cycles unhalted" event will happen every clock tick. If it locks up on
+"hlt", then you are out of luck -- the event will not happen at all and the
+watchdog won't trigger. This is a shortcoming of the local APIC watchdog
+-- unfortunately there is no "clock ticks" event that would work all the
+time. The I/O APIC watchdog is driven externally and has no such shortcoming.  
+But its NMI frequency is much higher, resulting in a more significant hit
+to the overall system performance.
+
 NOTE: starting with 2.4.2-ac18 the NMI-oopser is disabled by default,
 you have to enable it with a boot time parameter.  Prior to 2.4.2-ac18
 the NMI-oopser is enabled unconditionally on x86 SMP boxes.
diff -Nru a/Documentation/parisc/registers b/Documentation/parisc/registers
--- a/Documentation/parisc/registers	2004-12-24 13:36:56 -08:00
+++ b/Documentation/parisc/registers	2004-12-24 13:36:56 -08:00
@@ -35,8 +35,8 @@
 SR0				temporary space register
 SR4-SR7 			set to 0
 SR1				temporary space register
-SR2				unused
-SR3				used for userspace accesses (current process)*
+SR2				kernel should not clobber this
+SR3				used for userspace accesses (current process)
 
 	Space Registers (user mode)
 
@@ -78,13 +78,8 @@
 TOC enable bit			1
 
 =========================================================================
-Info from John Marvin:
-
-From: "John Marvin" <jsm@udlkern.fc.hp.com>
-To: randolf@tausq.org
-Subject: Re: parisc asm questions
-
-[...]
+Register usage notes, originally from John Marvin, with some additional
+notes from Randolph Chung.
 
 For the general registers:
 
@@ -111,9 +106,10 @@
 	don't care about the values that were passed in anymore.
 
     r28,r29: are ret0 and ret1. They are what you pass return values
-	in. r28 is the primary return. I'm not sure I remember
-	under what circumstances stuff is returned in r29 (millicode
-	perhaps).
+	in. r28 is the primary return. When returning small structures
+	r29 may also be used to pass data back to the caller.
+
+    r30: stack pointer
 
     r31: the ble instruction puts the return pointer in here.
 
@@ -122,7 +118,4 @@
     general purpose registers. r27 is the data pointer, and is
     used to make references to global variables easier. r30 is
     the stack pointer.
-
-John
-
 
diff -Nru a/Documentation/pci.txt b/Documentation/pci.txt
--- a/Documentation/pci.txt	2004-12-24 13:36:48 -08:00
+++ b/Documentation/pci.txt	2004-12-24 13:36:48 -08:00
@@ -141,26 +141,24 @@
 Searching by vendor and device ID:
 
 	struct pci_dev *dev = NULL;
-	while (dev = pci_find_device(VENDOR_ID, DEVICE_ID, dev))
+	while (dev = pci_get_device(VENDOR_ID, DEVICE_ID, dev))
 		configure_device(dev);
 
 Searching by class ID (iterate in a similar way):
 
-	pci_find_class(CLASS_ID, dev)
+	pci_get_class(CLASS_ID, dev)
 
 Searching by both vendor/device and subsystem vendor/device ID:
 
-	pci_find_subsys(VENDOR_ID, DEVICE_ID, SUBSYS_VENDOR_ID, SUBSYS_DEVICE_ID, dev).
+	pci_get_subsys(VENDOR_ID, DEVICE_ID, SUBSYS_VENDOR_ID, SUBSYS_DEVICE_ID, dev).
 
    You can use the constant PCI_ANY_ID as a wildcard replacement for
 VENDOR_ID or DEVICE_ID.  This allows searching for any device from a
 specific vendor, for example.
 
-Note that these functions are not hotplug-safe.  Their hotplug-safe
-replacements are pci_get_device(), pci_get_class() and pci_get_subsys().
-They increment the reference count on the pci_dev that they return.
-You must eventually (possibly at module unload) decrement the reference
-count on these devices by calling pci_dev_put().
+   These functions are hotplug-safe. They increment the reference count on
+the pci_dev that they return. You must eventually (possibly at module unload)
+decrement the reference count on these devices by calling pci_dev_put().
 
 
 3. Enabling and disabling devices
@@ -275,11 +273,12 @@
 				devices just return NULL.
 pcibios_(read|write)_*		Superseded by their pci_(read|write)_*
 				counterparts.
-pcibios_find_*			Superseded by their pci_find_* counterparts.
-pci_for_each_dev()		Superseded by pci_find_device()
+pcibios_find_*			Superseded by their pci_get_* counterparts.
+pci_for_each_dev()		Superseded by pci_get_device()
 pci_for_each_dev_reverse()	Superseded by pci_find_device_reverse()
 pci_for_each_bus()		Superseded by pci_find_next_bus()
 pci_find_device()		Superseded by pci_get_device()
 pci_find_subsys()		Superseded by pci_get_subsys()
-pcibios_find_class()		Superseded by pci_find_class()
+pcibios_find_class()		Superseded by pci_get_class()
+pci_find_class()		Superseded by pci_get_class()
 pci_(read|write)_*_nodev()	Superseded by pci_bus_(read|write)_*()
diff -Nru a/Documentation/pm.txt b/Documentation/pm.txt
--- a/Documentation/pm.txt	2004-12-24 13:36:31 -08:00
+++ b/Documentation/pm.txt	2004-12-24 13:36:31 -08:00
@@ -36,8 +36,8 @@
   apmd:   http://worldvisions.ca/~apenwarr/apmd/
   acpid:  http://acpid.sf.net/
 
-Driver Interface
-----------------
+Driver Interface -- OBSOLETE, DO NOT USE!
+----------------*************************
 If you are writing a new driver or maintaining an old driver, it
 should include power management support.  Without power management
 support, a single driver may prevent a system with power management
@@ -262,8 +262,8 @@
 
 ACPI Development mailing list: acpi-devel@lists.sourceforge.net
 
-System Interface
-----------------
+System Interface -- OBSOLETE, DO NOT USE!
+----------------*************************
 If you are providing new power management support to Linux (ie.
 adding support for something like APM or ACPI), you should
 communicate with drivers through the existing generic power
diff -Nru a/Documentation/power/kernel_threads.txt b/Documentation/power/kernel_threads.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/power/kernel_threads.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,41 @@
+KERNEL THREADS
+
+
+Freezer
+
+Upon entering a suspended state the system will freeze all
+tasks. This is done by delivering pseudosignals. This affects
+kernel threads, too. To successfully freeze a kernel thread
+the thread has to check for the pseudosignal and enter the
+refrigerator. Code to do this looks like this:
+
+	do {
+		hub_events();
+		wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
+	} while (!signal_pending(current));
+
+from drivers/usb/core/hub.c::hub_thread()
+
+
+The Unfreezable
+
+Some kernel threads however, must not be frozen. The kernel must
+be able to finish pending IO operations and later on be able to
+write the memory image to disk. Kernel threads needed to do IO
+must stay awake. Such threads must mark themselves unfreezable
+like this:
+
+	/*
+	 * This thread doesn't need any user-level access,
+	 * so get rid of all our resources.
+	 */
+	daemonize("usb-storage");
+
+	current->flags |= PF_NOFREEZE;
+
+from drivers/usb/storage/usb.c::usb_stor_control_thread()
+
+Such drivers are themselves responsible for staying quiet during
+the actual snapshotting.
diff -Nru a/Documentation/power/pci.txt b/Documentation/power/pci.txt
--- a/Documentation/power/pci.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/power/pci.txt	2004-12-24 13:37:18 -08:00
@@ -5,6 +5,7 @@
 An overview of the concepts and the related functions in the Linux kernel
 
 Patrick Mochel <mochel@transmeta.com>
+(and others)
 
 ---------------------------------------------------------------------------
 
@@ -31,10 +32,15 @@
 the higher the number, the longer the latency is for the device to return to 
 an operational state (D0).
 
+There are actually two D3 states.  When someone talks about D3, they usually
+mean D3hot, which corresponds to an ACPI D2 state (power is reduced, the
+device may lose some context).  But they may also mean D3cold, which is an
+ACPI D3 state (power is fully off, all state was discarded); or both.
+
 Bus power management is not covered in this version of this document.
 
-Note that all PCI devices support D0 and D3 by default, regardless of whether or
-not they implement any of the PCI PM spec.
+Note that all PCI devices support D0 and D3cold by default, regardless of
+whether or not they implement any of the PCI PM spec.
 
 The possible state transitions that a device can undergo are:
 
@@ -204,15 +210,16 @@
 	dev->driver->suspend(dev,state);
 
 A driver uses this function to actually transition the device into a low power
-state. This may include disabling I/O, memory and bus-mastering, as well as
-physically transitioning the device to a lower power state.
+state. This should include disabling I/O, IRQs, and bus-mastering, as well as
+physically transitioning the device to a lower power state; it may also include
+calls to pci_enable_wake().
 
 Bus mastering may be disabled by doing:
 
 pci_disable_device(dev);
 
 For devices that support the PCI PM Spec, this may be used to set the device's
-power state:
+power state to match the suspend() parameter:
 
 pci_set_power_state(dev,state);
 
@@ -223,7 +230,7 @@
 obviate the need for some operations.
 
 The driver should update the current_state field in its pci_dev structure in
-this function.
+this function, except for PM-capable devices when pci_set_power_state is used.
 
 resume
 ------
@@ -237,16 +244,28 @@
 transition the device to the D0 state. 
 
 The driver is responsible for reenabling any features of the device that had
-been disabled during previous suspend calls and restoring all state that was
-saved in previous save_state calls.
+been disabled during previous suspend calls, such as IRQs and bus mastering,
+as well as calling pci_restore_state().
+
+If the device is currently in D3, it may need to be reinitialized in resume().
 
-If the device is currently in D3, it must be completely reinitialized, as it
-must be assumed that the device has lost all of its context (even that of its
-PCI config space). For almost all current drivers, this means that the
-initialization code that the driver does at boot must be separated out and
-called again from the resume callback. Note that some values for the device may
-not have to be probed for this time around if they are saved before entering the
-low power state.
+  * Some types of devices, like bus controllers, will preserve context in D3hot
+    (using Vcc power).  Their drivers will often want to avoid re-initializing
+    them after re-entering D0 (perhaps to avoid resetting downstream devices).
+
+  * Other kinds of devices in D3hot will discard device context as part of a
+    soft reset when re-entering the D0 state.
+    
+  * Devices resuming from D3cold always go through a power-on reset.  Some
+    device context can also be preserved using Vaux power.
+
+  * Some systems hide D3cold resume paths from drivers.  For example, on PCs
+    the resume path for suspend-to-disk often runs BIOS powerup code, which
+    will sometimes re-initialize the device.
+
+To handle resets during D3 to D0 transitions, it may be convenient to share
+device initialization code between probe() and resume().  Device parameters
+can also be saved before the driver suspends into D3, avoiding re-probe.
 
 If the device supports the PCI PM Spec, it can use this to physically transition
 the device to D0:
@@ -263,7 +282,7 @@
 ensure correct (and speedy) operation.
 
 The driver should update the current_state field in its pci_dev structure in
-this function.
+this function, except for PM-capable devices when pci_set_power_state is used.
 
 
 enable_wake
diff -Nru a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
--- a/Documentation/power/swsusp.txt	2004-12-24 13:36:16 -08:00
+++ b/Documentation/power/swsusp.txt	2004-12-24 13:36:16 -08:00
@@ -15,10 +15,18 @@
  * If you change kernel command line between suspend and resume...
  *			        ...prepare for nasty fsck or worse.
  *
- * (*) pm interface support is needed to make it safe.
+ * (*) suspend/resume support is needed to make it safe.
 
 You need to append resume=/dev/your_swap_partition to kernel command
-line. Then you suspend by echo 4 > /proc/acpi/sleep.
+line. Then you suspend by
+
+echo shutdown > /sys/power/disk; echo disk > /sys/power/state
+
+. If you feel ACPI works pretty well on your system, you might try
+
+echo platform > /sys/power/disk; echo disk > /sys/power/state
+
+
 
 Article about goals and implementation of Software Suspend for Linux
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -32,42 +40,24 @@
 to standby mode. Later resuming the machine the saved state is loaded back to
 ram and the machine can continue its work. It has two real benefits. First we
 save ourselves the time machine goes down and later boots up, energy costs
-real high when running from batteries. The other gain is that we don't have to
+are real high when running from batteries. The other gain is that we don't have to
 interrupt our programs so processes that are calculating something for a long
 time shouldn't need to be written interruptible.
 
-Using the code
-
-You have two ways to use this code. The first one is is with a patched
-SysVinit (my patch is against 2.76 and available at my home page). You
-might call 'swsusp' or 'shutdown -z <time>'. Next way is to echo 4 >
-/proc/acpi/sleep.
-
-Either way it saves the state of the machine into active swaps and then
-reboots.  You must explicitly specify the swap partition to resume from with
+swsusp saves the state of the machine into active swaps and then reboots or
+powerdowns.  You must explicitly specify the swap partition to resume from with
 ``resume='' kernel option. If signature is found it loads and restores saved
 state. If the option ``noresume'' is specified as a boot parameter, it skips
 the resuming.
 
-In the meantime while the system is suspended you should not touch any of the
-hardware!
-
-About the code
+In the meantime while the system is suspended you should not add/remove any
+of the hardware, write to the filesystems, etc.
 
-Things to implement
-- We should only make a copy of data related to kernel segment, since any
-  process data won't be changed.
-- Should make more sanity checks. Or are these enough?
+Sleep states summary
+====================
 
-Not so important ideas for implementing
-
-- If a real time process is running then don't suspend the machine.
-- Support for adding/removing hardware while suspended?
-- We should not free pages at the beginning so aggressively, most of them
-  go there anyway..
-
-Sleep states summary (thanx, Ducrot)
-====================================
+There are three different interfaces you can use, /proc/acpi should
+work like this:
 
 In a really perfect world:
 echo 1 > /proc/acpi/sleep       # for standby
@@ -79,7 +69,6 @@
 and perhaps
 echo 4b > /proc/acpi/sleep      # for suspend to disk via s4bios
 
-
 Frequently Asked Questions
 ==========================
 
@@ -123,21 +112,7 @@
 
 Q: Does linux support ACPI S4?
 
-A: No.
-
-When swsusp was created, ACPI was not too widespread, so we tried to
-avoid using ACPI-specific stuff. ACPI also is/was notoriously
-buggy. These days swsusp works on APM-only i386 machines and even
-without any power managment at all. Some versions also work on PPC.
-
-That means that machine does not enter S4 on suspend-to-disk, but
-simply enters S5. That has few advantages, you can for example boot
-windows on next boot, and return to your Linux session later. You
-could even have few different Linuxes on your box (not sharing any
-partitions), and switch between them.
-
-It also has disadvantages. On HP nx5000, if you unplug power cord
-while machine is suspended-to-disk, Linux will fail to notice that.
+A: Yes. That's what echo platform > /sys/power/disk does.
 
 Q: My machine doesn't work with ACPI. How can I use swsusp than ?
 
@@ -162,6 +137,8 @@
     return 0;
 }
 
+Also /sys/ interface should be still present.
+
 Q: What is 'suspend2'?
 
 A: suspend2 is 'Software Suspend 2', a forked implementation of
@@ -175,16 +152,21 @@
 website, and not to the Linux Kernel Mailing List. We are working
 toward merging suspend2 into the mainline kernel.
 
-Q: Kernel thread must voluntarily freeze itself (call 'refrigerator'). But
-I found some kernel threads don't do it, and they don't freeze, and
+Q: A kernel thread must voluntarily freeze itself (call 'refrigerator').
+I found some kernel threads that don't do it, and they don't freeze
 so the system can't sleep. Is this a known behavior?
 
-A: All such kernel threads need to be fixed, one by one. Select place
-where it is safe to be frozen (no kernel semaphores should be held at
-that point and it must be safe to sleep there), and add:
+A: All such kernel threads need to be fixed, one by one. Select the
+place where the thread is safe to be frozen (no kernel semaphores
+should be held at that point and it must be safe to sleep there), and
+add:
 
             if (current->flags & PF_FREEZE)
                     refrigerator(PF_FREEZE);
+
+If the thread is needed for writing the image to storage, you should
+instead set the PF_NOFREEZE process flag when creating the thread.
+
 
 Q: What is the difference between between "platform", "shutdown" and
 "firmware" in /sys/power/disk?
diff -Nru a/Documentation/power/video.txt b/Documentation/power/video.txt
--- a/Documentation/power/video.txt	2004-12-24 13:36:56 -08:00
+++ b/Documentation/power/video.txt	2004-12-24 13:36:56 -08:00
@@ -17,14 +17,17 @@
 
 * systems where video state is preserved over S3. (Athlon HP Omnibook xe3s)
 
-* systems that initialize video card into vga text mode and where BIOS
-  works well enough to be able to set video mode. Use
-  acpi_sleep=s3_mode on these. (Toshiba 4030cdt)
-
 * systems where it is possible to call video bios during S3
   resume. Unfortunately, it is not correct to call video BIOS at that
   point, but it happens to work on some machines. Use
   acpi_sleep=s3_bios (Athlon64 desktop system)
+
+* systems that initialize video card into vga text mode and where BIOS
+  works well enough to be able to set video mode. Use
+  acpi_sleep=s3_mode on these. (Toshiba 4030cdt)
+
+* on some systems s3_bios kicks video into text mode, and
+  acpi_sleep=s3_bios,s3_mode is needed (Toshiba Satellite P10-554)
 
 * radeon systems, where X can soft-boot your video card. You'll need
   patched X, and plain text console (no vesafb or radeonfb), see
diff -Nru a/Documentation/power/video_extension.txt b/Documentation/power/video_extension.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/power/video_extension.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,34 @@
+This driver implement the ACPI Extensions For Display Adapters
+for integrated graphics devices on motherboard, as specified in
+ACPI 2.0 Specification, Appendix B, allowing to perform some basic
+control like defining the video POST device, retrieving EDID information
+or to setup a video output, etc.  Note that this is an ref. implementation only.
+It may or may not work for your integrated video device.
+
+Interfaces exposed to userland through /proc/acpi/video:
+
+VGA/info : display the supported video bus device capability like ,Video ROM, CRT/LCD/TV.
+VGA/ROM :  Used to get a copy of the display devices' ROM data (up to 4k).
+VGA/POST_info : Used to determine what options are implemented.
+VGA/POST : Used to get/set POST device.
+VGA/DOS : Used to get/set ownership of output switching:
+	Please refer ACPI spec B.4.1 _DOS
+VGA/CRT : CRT output
+VGA/LCD : LCD output
+VGA/TV : TV output 
+VGA/*/brightness : Used to get/set brightness of output device
+
+Notify event through /proc/acpi/event:
+
+#define ACPI_VIDEO_NOTIFY_SWITCH        0x80
+#define ACPI_VIDEO_NOTIFY_PROBE         0x81
+#define ACPI_VIDEO_NOTIFY_CYCLE         0x82
+#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT   0x83
+#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT   0x84
+
+#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS      0x82
+#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS        0x83
+#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS        0x84
+#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS       0x85
+#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF           0x86
+
diff -Nru a/Documentation/prio_tree.txt b/Documentation/prio_tree.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/prio_tree.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,107 @@
+The prio_tree.c code indexes vmas using 3 different indexes:
+	* heap_index  = vm_pgoff + vm_size_in_pages : end_vm_pgoff
+	* radix_index = vm_pgoff : start_vm_pgoff
+	* size_index = vm_size_in_pages
+
+A regular radix-priority-search-tree indexes vmas using only heap_index and
+radix_index. The conditions for indexing are:
+	* ->heap_index >= ->left->heap_index &&
+		->heap_index >= ->right->heap_index
+	* if (->heap_index == ->left->heap_index)
+		then ->radix_index < ->left->radix_index;
+	* if (->heap_index == ->right->heap_index)
+		then ->radix_index < ->right->radix_index;
+	* nodes are hashed to left or right subtree using radix_index
+	  similar to a pure binary radix tree.
+
+A regular radix-priority-search-tree helps to store and query
+intervals (vmas). However, a regular radix-priority-search-tree is only
+suitable for storing vmas with different radix indices (vm_pgoff).
+
+Therefore, the prio_tree.c extends the regular radix-priority-search-tree
+to handle many vmas with the same vm_pgoff. Such vmas are handled in
+2 different ways: 1) All vmas with the same radix _and_ heap indices are
+linked using vm_set.list, 2) if there are many vmas with the same radix
+index, but different heap indices and if the regular radix-priority-search
+tree cannot index them all, we build an overflow-sub-tree that indexes such
+vmas using heap and size indices instead of heap and radix indices. For
+example, in the figure below some vmas with vm_pgoff = 0 (zero) are
+indexed by regular radix-priority-search-tree whereas others are pushed
+into an overflow-subtree. Note that all vmas in an overflow-sub-tree have
+the same vm_pgoff (radix_index) and if necessary we build different
+overflow-sub-trees to handle each possible radix_index. For example,
+in figure we have 3 overflow-sub-trees corresponding to radix indices
+0, 2, and 4.
+
+In the final tree the first few (prio_tree_root->index_bits) levels
+are indexed using heap and radix indices whereas the overflow-sub-trees below
+those levels (i.e. levels prio_tree_root->index_bits + 1 and higher) are
+indexed using heap and size indices. In overflow-sub-trees the size_index
+is used for hashing the nodes to appropriate places.
+
+Now, an example prio_tree:
+
+  vmas are represented [radix_index, size_index, heap_index]
+                 i.e., [start_vm_pgoff, vm_size_in_pages, end_vm_pgoff]
+
+level  prio_tree_root->index_bits = 3
+-----
+												_
+  0			 				[0,7,7]					 |
+  							/     \					 |
+				      ------------------       ------------			 |     Regular
+  				     /					   \			 |  radix priority
+  1		 		[1,6,7]					  [4,3,7]		 |   search tree
+  				/     \					  /     \		 |
+			 -------       -----			    ------       -----		 |  heap-and-radix
+			/		    \			   /		      \		 |      indexed
+  2		    [0,6,6]	 	   [2,5,7]		[5,2,7]		    [6,1,7]	 |
+		    /     \		   /     \		/     \		    /     \	 |
+  3		[0,5,5]	[1,5,6]		[2,4,6]	[3,4,7]	    [4,2,6] [5,1,6]	[6,0,6]	[7,0,7]	 |
+		   /			   /		       /		   		_
+                  /		          /		      /					_
+  4	      [0,4,4]		      [2,3,5]		   [4,1,5]				 |
+  		 /			 /		      /					 |
+  5	     [0,3,3]		     [2,2,4]		  [4,0,4]				 |  Overflow-sub-trees
+  		/			/							 |
+  6	    [0,2,2]		    [2,1,3]							 |    heap-and-size
+  	       /		       /							 |       indexed
+  7	   [0,1,1]		   [2,0,2]							 |
+  	      /											 |
+  8	  [0,0,0]										 |
+  												_
+
+Note that we use prio_tree_root->index_bits to optimize the height
+of the heap-and-radix indexed tree. Since prio_tree_root->index_bits is
+set according to the maximum end_vm_pgoff mapped, we are sure that all
+bits (in vm_pgoff) above prio_tree_root->index_bits are 0 (zero). Therefore,
+we only use the first prio_tree_root->index_bits as radix_index.
+Whenever index_bits is increased in prio_tree_expand, we shuffle the tree
+to make sure that the first prio_tree_root->index_bits levels of the tree
+is indexed properly using heap and radix indices.
+
+We do not optimize the height of overflow-sub-trees using index_bits.
+The reason is: there can be many such overflow-sub-trees and all of
+them have to be suffled whenever the index_bits increases. This may involve
+walking the whole prio_tree in prio_tree_insert->prio_tree_expand code
+path which is not desirable. Hence, we do not optimize the height of the
+heap-and-size indexed overflow-sub-trees using prio_tree->index_bits.
+Instead the overflow sub-trees are indexed using full BITS_PER_LONG bits
+of size_index. This may lead to skewed sub-trees because most of the
+higher significant bits of the size_index are likely to be be 0 (zero). In
+the example above, all 3 overflow-sub-trees are skewed. This may marginally
+affect the performance. However, processes rarely map many vmas with the
+same start_vm_pgoff but different end_vm_pgoffs. Therefore, we normally
+do not require overflow-sub-trees to index all vmas.
+
+From the above discussion it is clear that the maximum height of
+a prio_tree can be prio_tree_root->index_bits + BITS_PER_LONG.
+However, in most of the common cases we do not need overflow-sub-trees,
+so the tree height in the common cases will be prio_tree_root->index_bits.
+
+It is fair to mention here that the prio_tree_root->index_bits
+is increased on demand, however, the index_bits is not decreased when
+vmas are removed from the prio_tree. That's tricky to do. Hence, it's
+left as a home work problem.
+
+
diff -Nru a/Documentation/ramdisk.txt b/Documentation/ramdisk.txt
--- a/Documentation/ramdisk.txt	2004-12-24 13:36:17 -08:00
+++ b/Documentation/ramdisk.txt	2004-12-24 13:36:17 -08:00
@@ -5,115 +5,66 @@
 
 	1) Overview
 	2) Kernel Command Line Parameters
-	3) Using "rdev -r" With New Kernels
+	3) Using "rdev -r"
 	4) An Example of Creating a Compressed RAM Disk 
 
 
 1) Overview
 -----------
 
-As of kernel v1.3.48, the RAM disk driver was substantially changed.
-
-The older versions would grab a chunk of memory off the top before
-handing the remainder to the kernel at boot time. Thus a size parameter
-had to be specified via "ramdisk=1440" or "rdev -r /dev/fd0 1440" so
-that the driver knew how much memory to grab.
-
-Now the RAM disk dynamically grows as more space is required. It does
-this by using RAM from the buffer cache. The driver marks the buffers
-it is using with a new "BH_Protected" flag so that the kernel does 
-not try to reuse them later. This means that the old size parameter
-is no longer used, new command line parameters exist, and the behavior
-of the "rdev -r" or "ramsize" (usually a symbolic link to "rdev")
-command has changed.
-
-Also, the new RAM disk supports up to 16 RAM disks out of the box, and can
-be reconfigured in rd.c to support up to 255 RAM disks.  To use multiple
-RAM disk support with your system, run 'mknod /dev/ramX b 1 X' and chmod
-(to change its permissions) it to your liking.  The default /dev/ram(disk)
-uses minor #1, so start with ram2 and go from there.
-
-The old "ramdisk=<ram_size>" has been changed to "ramdisk_size=<ram_size>"
-to make it clearer.  The original "ramdisk=<ram_size>" has been kept around
-for compatibility reasons, but it will probably be removed in 2.1.x.
+The RAM disk driver is a way to use main system memory as a block device.  It
+is required for initrd, an initial filesystem used if you need to load modules
+in order to access the root filesystem (see Documentation/initrd.txt).  It can
+also be used for a temporary filesystem for crypto work, since the contents
+are erased on reboot.
+
+The RAM disk dynamically grows as more space is required. It does this by using
+RAM from the buffer cache. The driver marks the buffers it is using as dirty
+so that the VM subsystem does not try to reclaim them later.
+
+Also, the RAM disk supports up to 16 RAM disks out of the box, and can
+be reconfigured to support up to 255 RAM disks - change "#define NUM_RAMDISKS"
+in drivers/block/rd.c.  To use RAM disk support with your system, run
+'./MAKEDEV ram' from the /dev directory.  RAM disks are all major number 1, and
+start with minor number 0 for /dev/ram0, etc.  If used, modern kernels use
+/dev/ram0 for an initrd.
+
+The old "ramdisk=<ram_size>" has been changed to "ramdisk_size=<ram_size>" to
+make it clearer.  The original "ramdisk=<ram_size>" has been kept around for
+compatibility reasons, but it may be removed in the future.
 
 The new RAM disk also has the ability to load compressed RAM disk images,
 allowing one to squeeze more programs onto an average installation or 
 rescue floppy disk.
 
-Notes: You may have "/dev/ram" or "/dev/ramdisk" or both. They are
-equivalent from the standpoint of this document. Also, the new RAM disk
-is a config option. When running "make config", make sure you enable
-RAM disk support for the kernel with which you intend to use the RAM disk.
-
 
 2) Kernel Command Line Parameters
 ---------------------------------
 
-	ramdisk_start=NNN
-	=================
-
-To allow a kernel image to reside on a floppy disk along with a compressed
-RAM disk image, the "ramdisk_start=<offset>" command was added. The kernel
-can't be included into the compressed RAM disk filesystem image, because
-it needs to be stored starting at block zero so that the BIOS can load the 
-boot sector and then the kernel can bootstrap itself to get going.
-
-Note: If you are using an uncompressed RAM disk image, then the kernel can
-be a part of the filesystem image that is being loaded into the RAM disk,
-and the floppy can be booted with LILO, or the two can be separate as
-is done for the compressed images.
-
-If you are using a two-disk boot/root setup (kernel on #1, RAM disk image
-on #2) then the RAM disk would start at block zero, and an offset of
-zero would be used. Since this is the default value, you would not need
-to actually use the command at all.
-
-If instead, you have a "zImage" of about 350 kB, and a "fs_image.gz" of
-say about 1 MB, and you want them both on the same disk, then you
-would use an offset. If you stored the "fs_image.gz" onto the floppy
-starting at an offset of 400 kB, you would use "ramdisk_start=400".
-
-
-	load_ramdisk=N
-	==============
-
-This parameter tells the kernel whether it is to try to load a
-RAM disk image or not. Specifying "load_ramdisk=1" will tell the
-kernel to load a floppy into the RAM disk. The default value is
-zero, meaning that the kernel should not try to load a RAM disk.
-
-
-	prompt_ramdisk=N
-	================
-
-This parameter tells the kernel whether or not to give you a prompt
-asking you to insert the floppy containing the RAM disk image. In
-a single floppy configuration the RAM disk image is on the same floppy
-as the kernel that just finished loading/booting and so a prompt
-is not needed. In this case one can use "prompt_ramdisk=0". In a
-two floppy configuration, you will need the chance to switch disks,
-and thus "prompt_ramdisk=1" can be used. Since this is the default 
-value, it doesn't really need to be specified.
-
 	ramdisk_size=N
 	==============
 
 This parameter tells the RAM disk driver to set up RAM disks of N k size.  The
-default is 4096 (4 MB). 
+default is 4096 (4 MB) (8192 (8 MB) on S390).
+
+	ramdisk_blocksize=N
+	===================
 
-3) Using "rdev -r" With New Kernels
------------------------------------
+This parameter tells the RAM disk driver how many bytes to use per block.  The
+default is 512.
 
-The usage of the word (two bytes) that "rdev -r" sets in the kernel image
-has changed. The low 11 bits (0 -> 10) specify an offset (in 1 k blocks) 
-of up to 2 MB (2^11) of where to find the RAM disk (this used to be the 
-size). Bit 14 indicates that a RAM disk is to be loaded, and bit 15
-indicates whether a prompt/wait sequence is to be given before trying
-to read the RAM disk. Since the RAM disk dynamically grows as data is
-being written into it, a size field is no longer required. Bits 11
-to 13 are not currently used and may as well be zero. These numbers
-are no magical secrets, as seen below:
+
+3) Using "rdev -r"
+------------------
+
+The usage of the word (two bytes) that "rdev -r" sets in the kernel image is
+as follows. The low 11 bits (0 -> 10) specify an offset (in 1 k blocks) of up
+to 2 MB (2^11) of where to find the RAM disk (this used to be the size). Bit
+14 indicates that a RAM disk is to be loaded, and bit 15 indicates whether a
+prompt/wait sequence is to be given before trying to read the RAM disk. Since
+the RAM disk dynamically grows as data is being written into it, a size field
+is not required. Bits 11 to 13 are not currently used and may as well be zero.
+These numbers are no magical secrets, as seen below:
 
 ./arch/i386/kernel/setup.c:#define RAMDISK_IMAGE_START_MASK     0x07FF
 ./arch/i386/kernel/setup.c:#define RAMDISK_PROMPT_FLAG          0x8000
@@ -152,10 +103,10 @@
 To create a RAM disk image, you will need a spare block device to
 construct it on. This can be the RAM disk device itself, or an
 unused disk partition (such as an unmounted swap partition). For this 
-example, we will use the RAM disk device, "/dev/ram".
+example, we will use the RAM disk device, "/dev/ram0".
 
 Note: This technique should not be done on a machine with less than 8 MB
-of RAM. If using a spare disk partition instead of /dev/ram, then this
+of RAM. If using a spare disk partition instead of /dev/ram0, then this
 restriction does not apply.
 
 a) Decide on the RAM disk size that you want. Say 2 MB for this example.
@@ -164,11 +115,11 @@
    area (esp. for disks) so that maximal compression is achieved for
    the unused blocks of the image that you are about to create.
 
-	dd if=/dev/zero of=/dev/ram bs=1k count=2048
+	dd if=/dev/zero of=/dev/ram0 bs=1k count=2048
 
 b) Make a filesystem on it. Say ext2fs for this example.
 
-	mke2fs -vm0 /dev/ram 2048
+	mke2fs -vm0 /dev/ram0 2048
 
 c) Mount it, copy the files you want to it (eg: /etc/* /dev/* ...)
    and unmount it again.
@@ -177,7 +128,7 @@
    will be approximately 50% of the space used by the files. Unused
    space on the RAM disk will compress to almost nothing.
 
-	dd if=/dev/ram bs=1k count=2048 | gzip -v9 > /tmp/ram_image.gz
+	dd if=/dev/ram0 bs=1k count=2048 | gzip -v9 > /tmp/ram_image.gz
 
 e) Put the kernel onto the floppy
 
@@ -203,4 +154,14 @@
 users may wish to combine steps (d) and (f) by using a pipe.
 
 --------------------------------------------------------------------------
-						Paul Gortmaker 12/95	
+						Paul Gortmaker 12/95
+
+Changelog:
+----------
+
+10-22-04 :	Updated to reflect changes in command line options, remove
+		obsolete references, general cleanup.
+		James Nelson (james4765@gmail.com)
+
+
+12-95 :		Original Document
diff -Nru a/Documentation/rocket.txt b/Documentation/rocket.txt
--- a/Documentation/rocket.txt	2004-12-24 13:36:55 -08:00
+++ b/Documentation/rocket.txt	2004-12-24 13:36:55 -08:00
@@ -20,8 +20,27 @@
 into them.  Installations instructions for the external module
 are in the included README and HW_INSTALL files.
 
-RocketPort ISA and RocketModem II PCI boards are also supported by this
-driver, but must use the external module driver for configuration reasons.  
+RocketPort ISA and RocketModem II PCI boards currently are only supported by
+this driver in module form.
+
+The RocketPort ISA board requires I/O ports to be configured by the DIP
+switches on the board.  See the section "ISA Rocketport Boards" below for
+information on how to set the DIP switches.
+
+You pass the I/O port to the driver using the following module parameters:
+
+board1 :	I/O port for the first ISA board
+board2 :	I/O port for the second ISA board
+board3 :	I/O port for the third ISA board
+board4 :	I/O port for the fourth ISA board
+
+There is a set of utilities and scripts provided with the external driver
+( downloadable from http://www.comtrol.com ) that ease the configuration and
+setup of the ISA cards.
+
+The RocketModem II PCI boards require firmware to be loaded into the card
+before it will function.  The driver has only been tested as a module for this
+board.
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
@@ -55,9 +74,92 @@
 >mknod /dev/ttyR1 c 46 1
 >mknod /dev/ttyR2 c 46 2  
 
-The Linux script MAKEDEV will create the first 16 ttyRx device names (nodes) for you:
+The Linux script MAKEDEV will create the first 16 ttyRx device names (nodes)
+for you:
 
 >/dev/MAKEDEV ttyR
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
+ISA Rocketport Boards
+---------------------
+
+You must assign and configure the I/O addresses used by the ISA Rocketport
+card before installing and using it.  This is done by setting a set of DIP
+switches on the Rocketport board.
+
+
+SETTING THE I/O ADDRESS
+-----------------------
+
+Before installing RocketPort(R) or RocketPort RA boards, you must find
+a range of I/O addresses for it to use. The first RocketPort card
+requires a 68-byte contiguous block of I/O addresses, starting at one
+of the following: 0x100h, 0x140h, 0x180h, 0x200h, 0x240h, 0x280h,
+0x300h, 0x340h, 0x380h.  This I/O address must be reflected in the DIP
+switiches of *all* of the Rocketport cards.
+
+The second, third, and fourth RocketPort cards require a 64-byte
+contiguous block of I/O addresses, starting at one of the following
+I/O addresses: 0x100h, 0x140h, 0x180h, 0x1C0h, 0x200h, 0x240h, 0x280h,
+0x2C0h, 0x300h, 0x340h, 0x380h, 0x3C0h.  The I/O address used by the
+second, third, and fourth Rocketport cards (if present) are set via
+software control.  The DIP switch settings for the I/O address must be
+set to the value of the first Rocketport cards.
+
+In order to destinguish each of the card from the others, each card
+must have a unique board ID set on the dip switches.  The first
+Rocketport board must be set with the DIP switches corresponding to
+the first board, the second board must be set with the DIP switches
+corresponding to the second board, etc.  IMPORTANT: The board ID is
+the only place where the DIP switch settings should differ between the
+various Rocketport boards in a system.
+
+The I/O address range used by any of the RocketPort cards must not
+conflict with any other cards in the system, including other
+RocketPort cards.  Below, you will find a list of commonly used I/O
+address ranges which may be in use by other devices in your system.
+On a Linux system, "cat /proc/ioports" will also be helpful in
+identifying what I/O addresses are being used by devics on your
+system.
+
+Remember, the FIRST RocketPort uses 68 I/O addresses.  So, if you set it
+for 0x100, it will occupy 0x100 to 0x143.  This would mean that you
+CAN NOT set the second, third or fourth board for address 0x140 since
+the first 4 bytes of that range are used by the first board.  You would
+need to set the second, third, or fourth board to one of the next available
+blocks such as 0x180.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
+RocketPort and RocketPort RA SW1 Settings:
+
+          +-------------------------------+
+          | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
+          +-------+-------+---------------+
+          | Unused| Card  | I/O Port Block|
+          +-------------------------------+
+
+DIP Switches                             DIP Switches
+7    8                                   6    5
+===================                      ===================
+On   On   UNUSED, MUST BE ON.            On   On   First Card    <==== Default
+                                         On   Off  Second Card
+                                         Off  On   Third Card
+                                         Off  Off  Fourth Card
+
+DIP Switches         I/O Address Range
+4    3    2    1     Used by the First Card
+=====================================
+On   Off  On   Off   100-143
+On   Off  Off  On    140-183
+On   Off  Off  Off   180-1C3       <==== Default
+Off  On   On   Off   200-243
+Off  On   Off  On    240-283
+Off  On   Off  Off   280-2C3
+Off  Off  On   Off   300-343
+Off  Off  Off  On    340-383
+Off  Off  Off  Off   380-3C3
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
diff -Nru a/Documentation/s390/monreader.txt b/Documentation/s390/monreader.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/s390/monreader.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,197 @@
+
+Date  : 2004-Nov-26
+Author: Gerald Schaefer (geraldsc@de.ibm.com)
+
+
+             Linux API for read access to z/VM Monitor Records
+             =================================================
+
+
+Description
+===========
+This item delivers a new Linux API in the form of a misc char device that is
+useable from user space and allows read access to the z/VM Monitor Records
+collected by the *MONITOR System Service of z/VM.
+
+
+User Requirements
+=================
+The z/VM guest on which you want to access this API needs to be configured in
+order to allow IUCV connections to the *MONITOR service, i.e. it needs the
+IUCV *MONITOR statement in its user entry. If the monitor DCSS to be used is
+restricted (likely), you also need the NAMESAVE <DCSS NAME> statement.
+This item will use the IUCV device driver to access the z/VM services, so you
+need a kernel with IUCV support. You also need z/VM version 4.4 or 5.1.
+
+There are two options for being able to load the monitor DCSS (examples assume
+that the monitor DCSS begins at 144 MB and ends at 152 MB). You can query the
+location of the monitor DCSS with the Class E privileged CP command Q NSS MAP
+(the values BEGPAG and ENDPAG are given in units of 4K pages).
+
+See also "CP Command and Utility Reference" (SC24-6081-00) for more information
+on the DEF STOR and Q NSS MAP commands, as well as "Saved Segments Planning
+and Administration" (SC24-6116-00) for more information on DCSSes.
+
+1st option:
+-----------
+You can use the CP command DEF STOR CONFIG to define a "memory hole" in your
+guest virtual storage around the address range of the DCSS.
+
+Example: DEF STOR CONFIG 0.140M 200M.200M
+
+This defines two blocks of storage, the first is 140MB in size an begins at
+address 0MB, the second is 200MB in size and begins at address 200MB,
+resulting in a total storage of 340MB. Note that the first block should
+always start at 0 and be at least 64MB in size.
+
+2nd option:
+-----------
+Your guest virtual storage has to end below the starting address of the DCSS
+and you have to specify the "mem=" kernel parameter in your parmfile with a
+value greater than the ending address of the DCSS.
+
+Example: DEF STOR 140M
+
+This defines 140MB storage size for your guest, the parameter "mem=160M" is
+added to the parmfile.
+
+
+User Interface
+==============
+The char device is implemented as a kernel module named "monreader",
+which can be loaded via the modprobe command, or it can be compiled into the
+kernel instead. There is one optional module (or kernel) parameter, "mondcss",
+to specify the name of the monitor DCSS. If the module is compiled into the
+kernel, the kernel parameter "monreader.mondcss=<DCSS NAME>" can be specified
+in the parmfile.
+
+The default name for the DCSS is "MONDCSS" if none is specified. In case that
+there are other users already connected to the *MONITOR service (e.g.
+Performance Toolkit), the monitor DCSS is already defined and you have to use
+the same DCSS. The CP command Q MONITOR (Class E privileged) shows the name
+of the monitor DCSS, if already defined, and the users connected to the
+*MONITOR service.
+Refer to the "z/VM Performance" book (SC24-6109-00) on how to create a monitor
+DCSS if your z/VM doesn't have one already, you need Class E privileges to
+define and save a DCSS.
+
+Example:
+--------
+modprobe monreader mondcss=MYDCSS
+
+This loads the module and sets the DCSS name to "MYDCSS".
+
+NOTE:
+-----
+This API provides no interface to control the *MONITOR service, e.g. specifiy
+which data should be collected. This can be done by the CP command MONITOR
+(Class E privileged), see "CP Command and Utility Reference".
+
+Device nodes with udev:
+-----------------------
+After loading the module, a char device will be created along with the device
+node /<udev directory>/monreader.
+
+Device nodes without udev:
+--------------------------
+If your distribution does not support udev, a device node will not be created
+automatically and you have to create it manually after loading the module.
+Therefore you need to know the major and minor numbers of the device. These
+numbers can be found in /sys/class/misc/monreader/dev.
+Typing cat /sys/class/misc/monreader/dev will give an output of the form
+<major>:<minor>. The device node can be created via the mknod command, enter
+mknod <name> c <major> <minor>, where <name> is the name of the device node
+to be created.
+
+Example:
+--------
+# modprobe monreader
+# cat /sys/class/misc/monreader/dev
+10:63
+# mknod /dev/monreader c 10 63
+
+This loads the module with the default monitor DCSS (MONDCSS) and creates a
+device node.
+
+File operations:
+----------------
+The following file operations are supported: open, release, read, poll.
+There are two alternative methods for reading: either non-blocking read in
+conjunction with polling, or blocking read without polling. IOCTLs are not
+supported.
+
+Read:
+-----
+Reading from the device provides a 12 Byte monitor control element (MCE),
+followed by a set of one or more contiguous monitor records (similar to the
+output of the CMS utility MONWRITE without the 4K control blocks). The MCE
+contains information on the type of the following record set (sample/event
+data), the monitor domains contained within it and the start and end address
+of the record set in the monitor DCSS. The start and end address can be used
+to determine the size of the record set, the end address is the address of the
+last byte of data. The start address is needed to handle "end-of-frame" records
+correctly (domain 1, record 13), i.e. it can be used to determine the record
+start offset relative to a 4K page (frame) boundary.
+
+See "Appendix A: *MONITOR" in the "z/VM Performance" document for a description
+of the monitor control element layout. The layout of the monitor records can
+be found here (z/VM 5.1): http://www.vm.ibm.com/pubs/mon510/index.html
+
+The layout of the data stream provided by the monreader device is as follows:
+...
+<0 byte read>
+<first MCE>              \
+<first set of records>    |
+...                       |- data set
+<last MCE>                |
+<last set of records>    /
+<0 byte read>
+...
+
+There may be more than one combination of MCE and corresponding record set
+within one data set and the end of each data set is indicated by a successful
+read with a return value of 0 (0 byte read).
+Any received data must be considered invalid until a complete set was
+read successfully, including the closing 0 byte read. Therefore you should
+always read the complete set into a buffer before processing the data.
+
+The maximum size of a data set can be as large as the size of the
+monitor DCSS, so design the buffer adequately or use dynamic memory allocation.
+The size of the monitor DCSS will be printed into syslog after loading the
+module. You can also use the (Class E privileged) CP command Q NSS MAP to
+list all available segments and information about them.
+
+As with most char devices, error conditions are indicated by returning a
+negative value for the number of bytes read. In this case, the errno variable
+indicates the error condition:
+
+EIO: reply failed, read data is invalid and the application
+     should discard the data read since the last successful read with 0 size.
+EFAULT: copy_to_user failed, read data is invalid and the application should
+        discard the data read since the last successful read with 0 size.
+EAGAIN: occurs on a non-blocking read if there is no data available at the
+        moment. There is no data missing or corrupted, just try again or rather
+        use polling for non-blocking reads.
+EOVERFLOW: message limit reached, the data read since the last successful
+           read with 0 size is valid but subsequent records may be missing.
+
+In the last case (EOVERFLOW) there may be missing data, in the first two cases
+(EIO, EFAULT) there will be missing data. It's up to the application if it will
+continue reading subsequent data or rather exit.
+
+Open:
+-----
+Only one user is allowed to open the char device. If it is already in use, the
+open function will fail (return a negative value) and set errno to EBUSY.
+The open function may also fail if an IUCV connection to the *MONITOR service
+cannot be established. In this case errno will be set to EIO and an error
+message with an IPUSER SEVER code will be printed into syslog. The IPUSER SEVER
+codes are described in the "z/VM Performance" book, Appendix A.
+
+NOTE:
+-----
+As soon as the device is opened, incoming messages will be accepted and they
+will account for the message limit, i.e. opening the device without reading
+from it will provoke the "message limit reached" error (EOVERFLOW error code)
+eventually.
+
diff -Nru a/Documentation/s390/s390dbf.txt b/Documentation/s390/s390dbf.txt
--- a/Documentation/s390/s390dbf.txt	2004-12-24 13:37:02 -08:00
+++ b/Documentation/s390/s390dbf.txt	2004-12-24 13:37:02 -08:00
@@ -78,6 +78,23 @@
 
 > echo "-" > /proc/s390dbf/dasd/level
 
+It is also possible to deactivate the debug feature globally for every
+debug log. You can change the behavior using  2 sysctl parameters in
+/proc/sys/s390dbf:
+There are currently 2 possible triggers, which stop the  debug feature
+globally. The first possbility is to use the "debug_active" sysctl. If
+set to 1 the debug feature is running. If "debug_active" is set to 0 the
+debug feature is turned off.
+The second trigger which stops the debug feature is an kernel oops.
+That prevents the debug feature from overwriting debug information that
+happened before the oops. After an oops you can reactivate the debug feature
+by piping 1 to /proc/sys/s390dbf/debug_active. Nevertheless, its not
+suggested to use an oopsed kernel in an production environment.
+If you want to disallow the deactivation of the debug feature, you can use
+the "debug_stoppable" sysctl. If you set "debug_stoppable" to 0 the debug
+feature cannot be stopped. If the debug feature is already stopped, it
+will stay deactivated.
+
 Kernel Interfaces:
 ------------------
 
@@ -115,6 +132,17 @@
 Return Value:  none 
 
 Description:   Sets new actual debug level if new_level is valid. 
+
+---------------------------------------------------------------------------
++void debug_stop_all(void);
+
+Parameter:     none
+
+Return Value:  none
+
+Description:   stops the debug feature if stopping is allowed. Currently
+               used in case of a kernel oops.
+
 ---------------------------------------------------------------------------
 debug_entry_t* debug_event (debug_info_t* id, int level, void* data, 
                             int length);
@@ -271,12 +299,12 @@
  * hex_ascii- + raw-view Example
  */
 
-#include <linux/module.h>
+#include <linux/init.h>
 #include <asm/debug.h>
 
 static debug_info_t* debug_info;
 
-int init_module(void)
+static int init(void)
 {
     /* register 4 debug areas with one page each and 4 byte data field */
 
@@ -291,23 +319,26 @@
     return 0;
 }
 
-void cleanup_module(void)
+static void cleanup(void)
 {
     debug_unregister (debug_info);
 }
 
+module_init(init);
+module_exit(cleanup);
+
 ---------------------------------------------------------------------------
 
 /*
  * sprintf-view Example
  */
 
-#include <linux/module.h>
+#include <linux/init.h>
 #include <asm/debug.h>
 
 static debug_info_t* debug_info;
 
-int init_module(void)
+static int init(void)
 {
     /* register 4 debug areas with one page each and data field for */
     /* format string pointer + 2 varargs (= 3 * sizeof(long))       */
@@ -321,11 +352,14 @@
     return 0;
 }
 
-void cleanup_module(void)
+static void cleanup(void)
 {
     debug_unregister (debug_info);
 }
 
+module_init(init);
+module_exit(cleanup);
+
 
 
 ProcFS Interface
@@ -376,6 +410,15 @@
 
 2. Flush all debug areas:
 > echo "-" > /proc/s390dbf/dasd/flush
+
+Stooping the debug feature
+--------------------------
+Example:
+
+1. Check if stopping is allowed
+> cat /proc/sys/s390dbf/debug_stoppable
+2. Stop debug feature
+> echo 0 > /proc/sys/s390dbf/debug_active
 
 lcrash Interface
 ----------------
diff -Nru a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid
--- a/Documentation/scsi/ChangeLog.megaraid	2004-12-24 13:37:29 -08:00
+++ b/Documentation/scsi/ChangeLog.megaraid	2004-12-24 13:37:29 -08:00
@@ -1,3 +1,27 @@
+Release Date	: Thu Dec  9 19:02:14 EST 2004 - Sreenivas Bagalkote <sreenib@lsil.com>
+
+Current Version	: 2.20.4.1 (scsi module), 2.20.2.3 (cmm module)
+Older Version	: 2.20.4.1 (scsi module), 2.20.2.2 (cmm module)
+
+i.	Fix a bug in kioc's dma buffer deallocation
+
+Release Date	: Thu Nov  4 18:24:56 EST 2004 - Sreenivas Bagalkote <sreenib@lsil.com>
+
+Current Version	: 2.20.4.1 (scsi module), 2.20.2.2 (cmm module)
+Older Version	: 2.20.4.0 (scsi module), 2.20.2.1 (cmm module)
+
+i.	Handle IOCTL cmd timeouts more properly.
+
+ii.	pci_dma_sync_{sg,single}_for_cpu was introduced into megaraid_mbox
+	incorrectly (instead of _for_device). Changed to appropriate
+	pci_dma_sync_{sg,single}_for_device.
+
+Release Date	: Wed Oct 06 11:15:29 EDT 2004 - Sreenivas Bagalkote <sreenib@lsil.com>
+Current Version	: 2.20.4.0 (scsi module), 2.20.2.1 (cmm module)
+Older Version	: 2.20.4.0 (scsi module), 2.20.2.0 (cmm module)
+
+i.	Remove CONFIG_COMPAT around register_ioctl32_conversion
+
 Release Date	: Mon Sep 27 22:15:07 EDT 2004 - Atul Mukker <atulm@lsil.com>
 Current Version	: 2.20.4.0 (scsi module), 2.20.2.0 (cmm module)
 Older Version	: 2.20.3.1 (scsi module), 2.20.2.0 (cmm module)
diff -Nru a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt
--- a/Documentation/scsi/scsi_mid_low_api.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/scsi/scsi_mid_low_api.txt	2004-12-24 13:37:18 -08:00
@@ -8,11 +8,11 @@
 SCSI lower level drivers. Lower level drivers (LLDs) are variously called 
 host bus adapter (HBA) drivers and host drivers (HD). A "host" in this
 context is a bridge between a computer IO bus (e.g. PCI or ISA) and a
-single SCSI initiator device on a SCSI transport. An "initiator" device
-(SCSI terminology) sends SCSI commands to "target" SCSI devices (e.g.
-disks). There can be many LLDs in a running system, but only one per
-hardware type. Most LLDs can control one or more SCSI HBAs. Some HBAs 
-contain multiple hosts.
+single SCSI initiator port on a SCSI transport. An "initiator" port
+(SCSI terminology, see SAM-3 at http://www.t10.org) sends SCSI commands
+to "target" SCSI ports (e.g. disks). There can be many LLDs in a running
+system, but only one per hardware type. Most LLDs can control one or more
+SCSI HBAs. Some HBAs contain multiple hosts.
 
 In some cases the SCSI transport is an external bus that already has
 its own subsystem in Linux (e.g. USB and ieee1394). In such cases the
@@ -370,6 +370,7 @@
 names all start with "scsi_".
 
 Summary:
+   scsi_activate_tcq - turn on tag command queueing
    scsi_add_device - creates new scsi device (lu) instance
    scsi_add_host - perform sysfs registration and SCSI bus scan.
    scsi_add_timer - (re-)start timer on a SCSI command.
@@ -377,6 +378,7 @@
    scsi_assign_lock - replace default host_lock with given lock
    scsi_bios_ptable - return copy of block device's partition table
    scsi_block_requests - prevent further commands being queued to given host
+   scsi_deactivate_tcq - turn off tag command queueing
    scsi_delete_timer - cancel timer on a SCSI command.
    scsi_host_alloc - return a new scsi_host instance whose refcount==1
    scsi_host_get - increments Scsi_Host instance's refcount
@@ -397,6 +399,24 @@
 Details:
 
 /**
+ * scsi_activate_tcq - turn on tag command queueing ("ordered" task attribute)
+ * @sdev:       device to turn on TCQ for
+ * @depth:      queue depth
+ *
+ *      Returns nothing
+ *
+ *      Might block: no
+ *
+ *      Notes: Eventually, it is hoped depth would be the maximum depth
+ *      the device could cope with and the real queue depth
+ *      would be adjustable from 0 to depth.
+ *
+ *      Defined (inline) in: include/scsi/scsi_tcq.h
+ **/
+void scsi_activate_tcq(struct scsi_device *sdev, int depth)
+
+
+/**
  * scsi_add_device - creates new scsi device (lu) instance
  * @shost:   pointer to scsi host instance
  * @channel: channel number (rarely other than 0)
@@ -462,10 +482,10 @@
 
 
 /**
- * scsi_adjust_queue_depth - change the queue depth on a SCSI device
+ * scsi_adjust_queue_depth - allow LLD to change queue depth on a SCSI device
  * @sdev:       pointer to SCSI device to change queue depth on
  * @tagged:     0 - no tagged queuing
- *              MSG_SIMPLE_TAG - simple (unordered) tagged queuing
+ *              MSG_SIMPLE_TAG - simple tagged queuing
  *              MSG_ORDERED_TAG - ordered tagged queuing
  * @tags        Number of tags allowed if tagged queuing enabled,
  *              or number of commands the LLD can queue up
@@ -479,7 +499,7 @@
  *      LLD. [Specifically during and after slave_configure() and prior to
  *      slave_destroy().] Can safely be invoked from interrupt code. Actual
  *      queue depth change may be delayed until the next command is being
- *      processed.
+ *      processed. See also scsi_activate_tcq() and scsi_deactivate_tcq().
  *
  *      Defined in: drivers/scsi/scsi.c [see source code for more notes]
  *
@@ -535,6 +555,20 @@
 
 
 /**
+ * scsi_deactivate_tcq - turn off tag command queueing
+ * @sdev:       device to turn off TCQ for
+ * @depth:      queue depth (stored in sdev)
+ *
+ *      Returns nothing
+ *
+ *      Might block: no
+ *
+ *      Defined (inline) in: include/scsi/scsi_tcq.h
+ **/
+void scsi_deactivate_tcq(struct scsi_device *sdev, int depth)
+
+
+/**
  * scsi_delete_timer - cancel timer on a SCSI command.
  * @scmd:    pointer to scsi command instance
  *
@@ -1323,9 +1357,7 @@
 initialized from the driver's struct scsi_host_template instance. Members
 of interest:
     host_no      - system wide unique number that is used for identifying
-                   this host. Issued in ascending order from 0 (and the
-                   positioning can be influenced by the scsihosts
-                   kernel boot (or module) parameter)
+                   this host. Issued in ascending order from 0.
     can_queue    - must be greater than 0; do not send more than can_queue
                    commands to the adapter.
     this_id      - scsi id of host (scsi initiator) or -1 if not known
@@ -1511,4 +1543,4 @@
 
 Douglas Gilbert
 dgilbert at interlog dot com
-25th August 2004
+21st September 2004
diff -Nru a/Documentation/scsi/sym53c8xx_2.txt b/Documentation/scsi/sym53c8xx_2.txt
--- a/Documentation/scsi/sym53c8xx_2.txt	2004-12-24 13:36:18 -08:00
+++ b/Documentation/scsi/sym53c8xx_2.txt	2004-12-24 13:36:18 -08:00
@@ -4,7 +4,9 @@
 21 Rue Carnot
 95170 DEUIL LA BARRE - FRANCE
 
-Decembre 28 2000
+Updated by Matthew Wilcox <matthew@wil.cx>
+
+2004-10-09
 ===============================================================================
 
 1.  Introduction
@@ -29,26 +31,20 @@
 10. Boot setup commands
       10.1 Syntax
       10.2 Available arguments
-             10.2.1  Master parity checking
-             10.2.2  Scsi parity checking
-             10.2.3  Default number of tagged commands
-             10.2.4  Default synchronous period factor
-             10.2.5  Verbosity level
-             10.2.6  Debug mode
-             10.2.7  Burst max
-             10.2.8  LED support
-             10.2.9  Max wide
-             10.2.10 Differential mode
-             10.2.11 IRQ mode
-             10.2.12 Reverse probe
-             10.2.13 Fix up PCI configuration space
-             10.2.14 Serial NVRAM
-             10.2.15 Check SCSI BUS 
-             10.2.16 Exclude a host from being attached
-             10.2.17 Suggest a default SCSI id for hosts
-      10.3 PCI configuration fix-up boot option
-      10.4 Serial NVRAM support boot option
-      10.5 SCSI BUS checking boot option
+             10.2.1  Default number of tagged commands
+             10.2.2  Burst max
+             10.2.3  LED support
+             10.2.4  Differential mode
+             10.2.5  IRQ mode
+             10.2.6  Check SCSI BUS 
+             10.2.7  Suggest a default SCSI id for hosts
+             10.2.8  Verbosity level
+             10.2.9  Debug mode
+             10.2.10 Settle delay
+             10.2.11 Serial NVRAM
+             10.2.12 Exclude a host from being attached
+      10.3 Converting from old options
+      10.4 SCSI BUS checking boot option
 11. SCSI problem troubleshooting
       15.1 Problem tracking
       15.2 Understanding hardware error reports
@@ -94,6 +90,9 @@
       Write a glue code for Linux.
           Gerard Roudier
 
+2004: Remove FreeBSD compatibility code.  Remove support for versions of
+      Linux before 2.6.  Start using Linux facilities.
+
 This README file addresses the Linux version of the driver. Under FreeBSD, 
 the driver documentation is the sym.8 man page.
 
@@ -279,11 +278,10 @@
 6. Parity checking
 
 The driver supports SCSI parity checking and PCI bus master parity
-checking. These features must be enabled in order to ensure safe data
-transfers. However, some flawed devices or mother boards will have
-problems with parity. You can disable either PCI parity or SCSI parity 
-checking by entering appropriate options from the boot command line.
-(See 10: Boot setup commands).
+checking.  These features must be enabled in order to ensure safe
+data transfers.  Some flawed devices or mother boards may have problems
+with parity.  The options to defeat parity checking have been removed
+from the driver.
 
 7. Profiling information
 
@@ -428,77 +426,90 @@
 
 10.1 Syntax
 
-Setup commands can be passed to the driver either at boot time or as a 
-string variable using 'insmod'.
-
-A boot setup command for this driver begins with the driver name "sym53c8xx=".
-The kernel syntax parser then expects an optionnal list of integers separated 
-with comma followed by an optional list of  comma-separated strings.
+Setup commands can be passed to the driver either at boot time or as
+parameters to modprobe, as described in Documentation/kernel-parameters.txt
 
 Example of boot setup command under lilo prompt:
 
-lilo: linux root=/dev/sda2 sym53c8xx=tags:4,sync:10,debug:0x200
+lilo: linux root=/dev/sda2 sym53c8xx.cmd_per_lun=4 sym53c8xx.sync=10 sym53c8xx.debug=0x200
 
 - enable tagged commands, up to 4 tagged commands queued.
 - set synchronous negotiation speed to 10 Mega-transfers / second.
 - set DEBUG_NEGO flag.
 
-Since comma seems not to be allowed when defining a string variable using  
-'insmod', the driver also accepts <space> as option separator. 
-The following command will install driver module with the same options as 
-above.
+The following command will install the driver module with the same
+options as above.
 
-    insmod sym53c8xx.o sym53c8xx="tags:4 sync:10 debug:0x200"
-
-The integer list of arguments is discarded by the driver. 
-
-Each string argument must be specified as "keyword:value". Only lower-case 
-characters and digits are allowed.
+    modprobe sym53c8xx cmd_per_lun=4 sync=10 debug=0x200"
 
 10.2 Available arguments
 
-10.2.1  Master parity checking
-        mpar:y     enabled
-        mpar:n     disabled
-
-10.2.2  Scsi parity checking
-        spar:y     enabled
-        spar:n     disabled
-
-10.2.3  Default number of tagged commands
-        tags:0     (or tags:1 ) tagged command queuing disabled
-        tags:#tags (#tags  > 1) tagged command queuing enabled
+10.2.1  Default number of tagged commands
+        cmd_per_lun=0 (or cmd_per_lun=1) tagged command queuing disabled
+        cmd_per_lun=#tags (#tags > 1) tagged command queuing enabled
   #tags will be truncated to the max queued commands configuration parameter.
-  This option also allows to specify a command queue depth for each device 
-  that support tagged command queueing.
+
+10.2.2  Detailed control of tagged commands
+  This option allows you to specify a command queue depth for each device 
+  that supports tagged command queueing.
   Example:
-      sym53c8xx=tags:10/t2t3q16-t5q24/t1u2q32
-               will set devices queue depth as follow:
+      tag_ctrl=10/t2t3q16-t5q24/t1u2q32
+  will set devices queue depth as follow:
       - controller #0 target #2 and target #3                  -> 16 commands,
       - controller #0 target #5                                -> 24 commands,
       - controller #1 target #1 logical unit #2                -> 32 commands,
       - all other logical units (all targets, all controllers) -> 10 commands.
 
-10.2.4  Default synchronous period factor
-        sync:255     disabled (asynchronous transfer mode)
-        sync:#factor
-  #factor =  9     Ultra-3 SCSI 80 Mega-transfers / second (Wide only)
-  #factor = 10     Ultra-2 SCSI 40 Mega-transfers / second
-  #factor = 11     Ultra-2 SCSI 33 Mega-transfers / second
-  #factor < 25     Ultra   SCSI 20 Mega-transfers / second
-  #factor < 50     Fast    SCSI-2
-
-  In all cases, the driver will use the minimum transfer period supported by 
-  controllers according to SYM53C8XX chip type.
-
-10.2.5  Verbosity level
-        verb:0     minimal
-        verb:1     normal
-        verb:2     too much
-
-10.2.6 Debug mode
-        debug:0	 clear debug flags
-        debug:#x   set debug flags
+10.2.3 Burst max
+        burst=0    burst disabled
+        burst=255  get burst length from initial IO register settings.
+        burst=#x   burst enabled (1<<#x burst transfers max)
+  #x is an integer value which is log base 2 of the burst transfers max.
+  By default the driver uses the maximum value supported by the chip.
+
+10.2.4 LED support
+        led=1      enable  LED support
+        led=0      disable LED support
+  Do not enable LED support if your scsi board does not use SDMS BIOS.
+  (See 'Configuration parameters')
+
+10.2.4 Differential mode
+        diff=0	never set up diff mode
+        diff=1	set up diff mode if BIOS set it
+        diff=2	always set up diff mode
+        diff=3	set diff mode if GPIO3 is not set
+
+10.2.5 IRQ mode
+        irqm=0     always open drain
+        irqm=1     same as initial settings (assumed BIOS settings)
+        irqm=2     always totem pole
+
+10.2.6 Check SCSI BUS 
+        buschk=<option bits>
+
+    Available option bits:
+        0x0:   No check.
+        0x1:   Check and do not attach the controller on error.  
+        0x2:   Check and just warn on error.
+
+10.2.7 Suggest a default SCSI id for hosts
+        hostid=255	no id suggested.
+        hostid=#x   (0 < x < 7) x suggested for hosts SCSI id.
+
+    If a host SCSI id is available from the NVRAM, the driver will ignore 
+    any value suggested as boot option. Otherwise, if a suggested value 
+    different from 255 has been supplied, it will use it. Otherwise, it will 
+    try to deduce the value previously set in the hardware and use value 
+    7 if the hardware value is zero.
+
+10.2.8  Verbosity level
+        verb=0     minimal
+        verb=1     normal
+        verb=2     too much
+
+10.2.9 Debug mode
+        debug=0	 clear debug flags
+        debug=#x   set debug flags
   #x is an integer value combining the following power-of-2 values:
   DEBUG_ALLOC       0x1
   DEBUG_PHASE       0x2
@@ -517,55 +528,17 @@
   You can play safely with DEBUG_NEGO. However, some of these flags may 
   generate bunches of syslog messages. 
 
-10.2.7 Burst max
-        burst:0    burst disabled
-        burst:255  get burst length from initial IO register settings.
-        burst:#x   burst enabled (1<<#x burst transfers max)
-  #x is an integer value which is log base 2 of the burst transfers max.
-  By default the driver uses the maximum value supported by the chip.
-
-10.2.8 LED support
-        led:1      enable  LED support
-        led:0      disable LED support
-  Donnot enable LED support if your scsi board does not use SDMS BIOS.
-  (See 'Configuration parameters')
-
-10.2.9 Max wide
-        wide:1      wide scsi enabled
-        wide:0      wide scsi disabled
-  Some scsi boards use a 875 (ultra wide) and only supply narrow connectors.
-  If you have connected a wide device with a 50 pins to 68 pins cable 
-  converter, any accepted wide negotiation will break further data transfers.
-  In such a case, using "wide:0" in the bootup command will be helpfull. 
-
-10.2.10 Differential mode
-        diff:0	never set up diff mode
-        diff:1	set up diff mode if BIOS set it
-        diff:2	always set up diff mode
-        diff:3	set diff mode if GPIO3 is not set
-
-10.2.11 IRQ mode
-        irqm:0     always open drain
-        irqm:1     same as initial settings (assumed BIOS settings)
-        irqm:2     always totem pole
-
-10.2.12 Reverse probe
-        revprob:n   probe chip ids from the PCI configuration in this order:
-                    810, 815, 825, 860, 875, 885, 875A, 895, 896, 895A,
-                    1510D, 1010-33, 1010-66.
-        revprob:y   probe chip ids in the reverse order.
-
-10.2.13 Fix up PCI configuration space
-        pcifix:<option bits>
+10.2.10 Settle delay
+        settle=n	delay for n seconds
 
-    Available option bits:
-        0x0:   No attempt to fix PCI configuration space registers values.
-        0x1:   Set PCI cache-line size register if not set.
-        0x2:   Set write and invalidate bit in PCI command register.
-
-10.2.14 Serial NVRAM
-        nvram:n     do not look for serial NVRAM
-        nvram:y     test controllers for onboard serial NVRAM
+  After a bus reset, the driver will delay for n seconds before talking
+  to any device on the bus.  The default is 3 seconds and safe mode will
+  default it to 10.
+
+10.2.11 Serial NVRAM
+	NB: option not currently implemented.
+        nvram=n     do not look for serial NVRAM
+        nvram=y     test controllers for onboard serial NVRAM
         (alternate binary form)
         nvram=<bits options>
         0x01   look for NVRAM  (equivalent to nvram=y)
@@ -574,105 +547,28 @@
         0x08   ignore NVRAM "Scan at boot time" parameter for all devices
         0x80   also attach controllers set to OFF in the NVRAM (sym53c8xx only)
 
-10.2.15 Check SCSI BUS 
-        buschk:<option bits>
-
-    Available option bits:
-        0x0:   No check.
-        0x1:   Check and do not attach the controller on error.  
-        0x2:   Check and just warn on error.
-
-10.2.16 Exclude a host from being attached
-        excl=<io_address>
+10.2.12 Exclude a host from being attached
+        excl=<io_address>,...
 
     Prevent host at a given io address from being attached.
-    For example 'sym53c8xx=excl:0xb400,excl:0xc000' indicate to the 
+    For example 'excl=0xb400,0xc000' indicate to the 
     driver not to attach hosts at address 0xb400 and 0xc000.
 
-10.2.17 Suggest a default SCSI id for hosts
-        hostid:255	no id suggested.
-        hostid:#x   (0 < x < 7) x suggested for hosts SCSI id.
-
-    If a host SCSI id is available from the NVRAM, the driver will ignore 
-    any value suggested as boot option. Otherwise, if a suggested value 
-    different from 255 has been supplied, it will use it. Otherwise, it will 
-    try to deduce the value previously set in the hardware and use value 
-    7 if the hardware value is zero.
-
-10.3 PCI configuration fix-up boot option
-
-pcifix:<option bits>
+10.3 Converting from old style options
 
-Available option bits:
-    0x1:     Set PCI cache-line size register if not set.
-    0x2:     Set write and invalidate bit in PCI command register.
+Previously, the sym2 driver accepted arguments of the form
+	sym53c8xx=tags:4,sync:10,debug:0x200
 
-Use 'pcifix:3' in order to allow the driver to fix both PCI features.
+As a result of the new module parameters, this is no longer available.
+Most of the options have remained the same, but tags has split into
+cmd_per_lun and tag_ctrl for its two different purposes.  The sample above
+would be specified as:
+	modprobe sym53c8xx cmd_per_lun=4 sync=10 debug=0x200
 
-Recent SYMBIOS 53C8XX scsi processors are able to use PCI read multiple 
-and PCI write and invalidate commands. These features require the 
-cache line size register to be properly set in the PCI configuration 
-space of the chips. On the other hand, chips will use PCI write and 
-invalidate commands only if the corresponding bit is set to 1 in the 
-PCI command register.
+or on the kernel boot line as:
+	sym53c8xx.cmd_per_lun=4 sym53c8xx.sync=10 sym53c8xx.debug=0x200
 
-Not all PCI bioses set the PCI cache line register and the PCI write and 
-invalidate bit in the PCI configuration space of 53C8XX chips.
-Optimized PCI accesses may be broken for some PCI/memory controllers or 
-make problems with some PCI boards.
-
-10.4 Serial NVRAM support boot option
-
-nvram:n     do not look for serial NVRAM
-nvram:y     test controllers for onboard serial NVRAM
-
-This option can also been entered as an hexadecimal value that allows 
-to control what information the driver will get from the NVRAM and what 
-information it will ignore.
-For details see '17. Serial NVRAM support'.
-
-When this option is enabled, the driver tries to detect all boards using 
-a Serial NVRAM. This memory is used to hold user set up parameters.
-
-The parameters the driver is able to get from the NVRAM depend on the 
-data format used, as follow:
-
-                                 Tekram format      Symbios format
-General and host parameters
-    Boot order                         N                   Y
-    Host SCSI ID                       Y                   Y
-    SCSI parity checking               Y                   Y
-    Verbose boot messages              N                   Y
-SCSI devices parameters
-    Synchronous transfer speed         Y                   Y
-    Wide 16 / Narrow                   Y                   Y
-    Tagged Command Queuing enabled     Y                   Y
-    Disconnections enabled             Y                   Y
-    Scan at boot time                  N                   Y
-
-In order to speed up the system boot, for each device configured without 
-the "scan at boot time" option, the driver forces an error on the 
-first TEST UNIT READY command received for this device.
-
-Some SDMS BIOS revisions seem to be unable to boot cleanly with very fast 
-hard disks. In such a situation you cannot configure the NVRAM with 
-optimized parameters value.
-
-The 'nvram' boot option can be entered in hexadecimal form in order 
-to ignore some options configured in the NVRAM, as follow:
-
-nvram=<bits options>
-      0x01   look for NVRAM  (equivalent to nvram=y)
-      0x02   ignore NVRAM "Synchronous negotiation" parameters for all devices
-      0x04   ignore NVRAM "Wide negotiation"  parameter for all devices
-      0x08   ignore NVRAM "Scan at boot time" parameter for all devices
-      0x80   also attach controllers set to OFF in the NVRAM (sym53c8xx only)
-
-Option 0x80 is disabled by default.
-Result is that, by default (option not set), the sym53c8xx driver will not 
-attach controllers set to OFF in the NVRAM.
-
-10.5 SCSI BUS checking boot option.
+10.4 SCSI BUS checking boot option.
 
 When this option is set to a non-zero value, the driver checks SCSI lines 
 logic state, 100 micro-seconds after having asserted the SCSI RESET line.
@@ -805,14 +701,8 @@
 host adaptor and it's attached drives.
 
 The Symbios NVRAM also holds data on the boot order of host adaptors in a
-system with more than one host adaptor. This enables the order of scanning
-the cards for drives to be changed from the default used during host adaptor
-detection.
-
-This can be done to a limited extent at the moment using "reverse probe" but
-this only changes the order of detection of different types of cards. The
-NVRAM boot order settings can do this as well as change the order the same
-types of cards are scanned in, something "reverse probe" cannot do.
+system with more than one host adaptor.  This information is no longer used
+as it's fundamentally incompatible with the hotplug PCI model.
 
 Tekram boards using Symbios chips, DC390W/F/U, which have NVRAM are detected
 and this is used to distinguish between Symbios compatible and Tekram host 
@@ -823,6 +713,26 @@
 "diff" support. ("led pin" support for Symbios compatible cards can remain
 enabled when using Tekram cards. It does nothing useful for Tekram host
 adaptors but does not cause problems either.)
+
+The parameters the driver is able to get from the NVRAM depend on the 
+data format used, as follow:
+
+                                 Tekram format      Symbios format
+General and host parameters
+    Boot order                         N                   Y
+    Host SCSI ID                       Y                   Y
+    SCSI parity checking               Y                   Y
+    Verbose boot messages              N                   Y
+SCSI devices parameters
+    Synchronous transfer speed         Y                   Y
+    Wide 16 / Narrow                   Y                   Y
+    Tagged Command Queuing enabled     Y                   Y
+    Disconnections enabled             Y                   Y
+    Scan at boot time                  N                   Y
+
+In order to speed up the system boot, for each device configured without 
+the "scan at boot time" option, the driver forces an error on the 
+first TEST UNIT READY command received for this device.
 
 
 17.2 Symbios NVRAM layout
diff -Nru a/Documentation/seclvl.txt b/Documentation/seclvl.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/seclvl.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,97 @@
+BSD Secure Levels Linux Security Module
+Michael A. Halcrow <mike@halcrow.us>
+
+
+Introduction
+
+Under the BSD Secure Levels security model, sets of policies are
+associated with levels. Levels range from -1 to 2, with -1 being the
+weakest and 2 being the strongest. These security policies are
+enforced at the kernel level, so not even the superuser is able to
+disable or circumvent them. This hardens the machine against attackers
+who gain root access to the system.
+
+
+Levels and Policies
+
+Level -1 (Permanently Insecure):
+ - Cannot increase the secure level
+
+Level 0 (Insecure):
+ - Cannot ptrace the init process
+
+Level 1 (Default):
+ - /dev/mem and /dev/kmem are read-only
+ - IMMUTABLE and APPEND extended attributes, if set, may not be unset
+ - Cannot load or unload kernel modules
+ - Cannot write directly to a mounted block device
+ - Cannot perform raw I/O operations
+ - Cannot perform network administrative tasks
+ - Cannot setuid any file
+
+Level 2 (Secure):
+ - Cannot decrement the system time
+ - Cannot write to any block device, whether mounted or not
+ - Cannot unmount any mounted filesystems
+
+
+Compilation
+
+To compile the BSD Secure Levels LSM, seclvl.ko, enable the
+SECURITY_SECLVL configuration option.  This is found under Security
+options -> BSD Secure Levels in the kernel configuration menu.
+
+
+Basic Usage
+
+Once the machine is in a running state, with all the necessary modules
+loaded and all the filesystems mounted, you can load the seclvl.ko
+module:
+
+# insmod seclvl.ko
+
+The module defaults to secure level 1, except when compiled directly
+into the kernel, in which case it defaults to secure level 0. To raise
+the secure level to 2, the administrator writes ``2'' to the
+seclvl/seclvl file under the sysfs mount point (assumed to be /sys in
+these examples):
+
+# echo -n "2" > /sys/seclvl/seclvl
+
+Alternatively, you can initialize the module at secure level 2 with
+the initlvl module parameter:
+
+# insmod seclvl.ko initlvl=2
+
+At this point, it is impossible to remove the module or reduce the
+secure level.  If the administrator wishes to have the option of doing
+so, he must provide a module parameter, sha1_passwd, that specifies
+the SHA1 hash of the password that can be used to reduce the secure
+level to 0.
+
+To generate this SHA1 hash, the administrator can use OpenSSL:
+
+# echo -n "boogabooga" | openssl sha1
+abeda4e0f33defa51741217592bf595efb8d289c
+
+In order to use password-instigated secure level reduction, the SHA1
+crypto module must be loaded or compiled into the kernel:
+
+# insmod sha1.ko
+
+The administrator can then insmod the seclvl module, including the
+SHA1 hash of the password:
+
+# insmod seclvl.ko
+         sha1_passwd=abeda4e0f33defa51741217592bf595efb8d289c
+
+To reduce the secure level, write the password to seclvl/passwd under
+your sysfs mount point:
+
+# echo -n "boogabooga" > /sys/seclvl/passwd
+
+The September 2004 edition of Sys Admin Magazine has an article about
+the BSD Secure Levels LSM.  I encourage you to refer to that article
+for a more in-depth treatment of this security module:
+
+http://www.samag.com/documents/s=9304/sam0409a/0409a.htm
diff -Nru a/Documentation/sonypi.txt b/Documentation/sonypi.txt
--- a/Documentation/sonypi.txt	2004-12-24 13:36:17 -08:00
+++ b/Documentation/sonypi.txt	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,6 @@
 Sony Programmable I/O Control Device Driver Readme
 --------------------------------------------------
-	Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
+	Copyright (C) 2001-2004 Stelian Pop <stelian@popies.net>
 	Copyright (C) 2001-2002 Alcôve <www.alcove.com>
 	Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
 	Copyright (C) 2001 Junichi Morita <jun1m@mars.dti.ne.jp>
@@ -23,16 +23,18 @@
 
 Those events (see linux/sonypi.h) can be polled using the character device node
 /dev/sonypi (major 10, minor auto allocated or specified as a option).
-
 A simple daemon which translates the jogdial movements into mouse wheel events
 can be downloaded at: <http://popies.net/sonypi/>
 
+Another option to intercept the events is to get them directly through the
+input layer.
+
 This driver supports also some ioctl commands for setting the LCD screen
-brightness and querying the batteries charge information (some more 
+brightness and querying the batteries charge information (some more
 commands may be added in the future).
 
 This driver can also be used to set the camera controls on Picturebook series
-(brightness, contrast etc), and is used by the video4linux driver for the 
+(brightness, contrast etc), and is used by the video4linux driver for the
 Motion Eye camera.
 
 Please note that this driver was created by reverse engineering the Windows
@@ -42,15 +44,12 @@
 Driver options:
 ---------------
 
-Several options can be passed to the sonypi driver, either by adding them
-to /etc/modprobe.conf file, when the driver is compiled as a module or by
-adding the following to the kernel command line (in your bootloader):
-
-	sonypi=minor[,verbose[,fnkeyinit[,camera[,compat[,mask[,useinput]]]]]]
+Several options can be passed to the sonypi driver using the standard
+module argument syntax (<param>=<value> when passing the option to the
+module or sonypi.<param>=<value> on the kernel boot line when sonypi is
+statically linked into the kernel). Those options are:
 
-where:
-
-	minor: 		minor number of the misc device /dev/sonypi, 
+	minor: 		minor number of the misc device /dev/sonypi,
 			default is -1 (automatic allocation, see /proc/misc
 			or kernel logs)
 
@@ -62,14 +61,14 @@
 			get enabled unless you set this parameter to 1.
 			Do not use this option unless it's actually necessary,
 			some Vaio models don't deal well with this option.
-			This option is available only if the kernel is 
+			This option is available only if the kernel is
 			compiled without ACPI support (since it conflicts
-			with it and it shouldn't be required anyway if 
+			with it and it shouldn't be required anyway if
 			ACPI is already enabled).
 
-	verbose:	set to 1 to print unknown events received from the 
+	verbose:	set to 1 to print unknown events received from the
 			sonypi device.
-			set to 2 to print all events received from the 
+			set to 2 to print all events received from the
 			sonypi device.
 
 	compat:		uses some compatibility code for enabling the sonypi
@@ -78,14 +77,15 @@
 			add this option and report to the author.
 
 	mask:		event mask telling the driver what events will be
-			reported to the user. This parameter is required for some 
-			Vaio models where the hardware reuses values used in 
-			other Vaio models (like the FX series who does not
-			have a jogdial but reuses the jogdial events for
+			reported to the user. This parameter is required for
+			some Vaio models where the hardware reuses values
+			used in other Vaio models (like the FX series who does
+			not have a jogdial but reuses the jogdial events for
 			programmable keys events). The default event mask is
-			set to 0xffffffff, meaning that all possible events will be
-			tried. You can use the following bits to construct
-			your own event mask (from drivers/char/sonypi.h):
+			set to 0xffffffff, meaning that all possible events
+			will be tried. You can use the following bits to
+			construct your own event mask (from
+			drivers/char/sonypi.h):
 				SONYPI_JOGGER_MASK 		0x0001
 				SONYPI_CAPTURE_MASK 		0x0002
 				SONYPI_FNKEY_MASK 		0x0004
@@ -100,10 +100,10 @@
 				SONYPI_MEMORYSTICK_MASK		0x0800
 				SONYPI_BATTERY_MASK		0x1000
 
-	useinput:	if set (which is the default) jogdial events are
-			forwarded to the input subsystem as mouse wheel
-			events.
-			
+	useinput:	if set (which is the default) two input devices are
+			created, one which interprets the jogdial events as
+			mouse events, the other one which acts like a
+			keyboard reporting the pressing of the special keys.
 
 Module use:
 -----------
@@ -126,17 +126,17 @@
 	  external monitor on/off. There is no workaround yet, since this
 	  driver disables all APM management for those keys, by enabling the
 	  ACPI management (and the ACPI core stuff is not complete yet). If
-	  you have one of those laptops with working Fn keys and want to 
+	  you have one of those laptops with working Fn keys and want to
 	  continue to use them, don't use this driver.
 
 	- some users reported that the laptop speed is lower (dhrystone
 	  tested) when using the driver with the fnkeyinit parameter. I cannot
 	  reproduce it on my laptop and not all users have this problem.
-	  This happens because the fnkeyinit parameter enables the ACPI 
-	  mode (but without additional ACPI control, like processor 
+	  This happens because the fnkeyinit parameter enables the ACPI
+	  mode (but without additional ACPI control, like processor
 	  speed handling etc). Use ACPI instead of APM if it works on your
 	  laptop.
-	
+
 	- since all development was done by reverse engineering, there is
 	  _absolutely no guarantee_ that this driver will not crash your
 	  laptop. Permanently.
diff -Nru a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
--- a/Documentation/sound/alsa/ALSA-Configuration.txt	2004-12-24 13:36:18 -08:00
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt	2004-12-24 13:36:18 -08:00
@@ -661,8 +661,6 @@
 			* ALi m5455
 
     ac97_clock	  - AC'97 codec clock base (0 = auto-detect)
-    joystick      - Enable joystick (default off)
-    mpu_port      - MPU401 port # (0 = disabled, 0x330,0x300)
     ac97_quirk    - AC'97 workaround for strange hardware (-1 = default)
                     -1 = default, don't override
                      0 = disable
@@ -670,6 +668,7 @@
                      2 = swap headphone and master controls
                      3 = for AD1985, turn on OMS bit and use headphone
                      4 = for ALC65x, turn on the jack sense mode
+                     5 = inverted EAPD implementation
     buggy_irq      - Enable workaround for buggy interrupts on some
                      motherboards (default off)
 
@@ -679,8 +678,9 @@
     if you still encounter too fast playback, specify the clock
     explicitly via the module option "ac97_clock=41194".
 
-    The joystick and MPU-401 are supported only certain hardwares.
-    MPU401 is experimental,  It doesn't work perfectly.
+    Joystick/MIDI ports are not supported by this driver.  If your
+    motherboard has these devices, use the ns558 or snd-mpu401
+    modules, respectively.
 
     The ac97_quirk option is used to enable/override the workaround
     for specific devices.  Some hardware have swapped output pins
@@ -809,6 +809,7 @@
     buffer_top       - specify buffer top address
     use_cache        - 0 or 1 (disabled by default)
     vaio_hack        - alias buffer_top=0x25a800
+    reset_workaround - enable AC97 RESET workaround for some laptops
 
     Module supports autoprobe and multiple chips (max 8).
 
@@ -833,6 +834,11 @@
     other drivers, e.g. snd-cs4232 or snd-opl3sa2.  Some has ISA-PnP
     but some doesn't have ISA PnP.  You'll need to speicfy isapnp=0
     and proper hardware parameters in the case without ISA PnP.
+
+    Note: some laptops need a workaround for AC97 RESET.  For the
+    known hardware like Dell Latitude LS and Sony PCG-F305, this
+    workaround is enabled automatically.  For other laptops with a
+    hard freeze, you can try reset_workaround=1 option.
 
     Note: This driver is really crappy.  It's a porting from the
     OSS driver, which is a result of black-magic reverse engineering.
diff -Nru a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
--- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl	2004-12-24 13:36:32 -08:00
+++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl	2004-12-24 13:36:32 -08:00
@@ -1479,7 +1479,7 @@
   struct snd_mychip {
           ....
           unsigned long iobase_phys;
-          unsigned long iobase_virt;
+          void __iomem *iobase_virt;
   };
 ]]>
           </programlisting>
@@ -1495,8 +1495,7 @@
           return err;
   }
   chip->iobase_phys = pci_resource_start(pci, 0);
-  chip->iobase_virt = (unsigned long)
-                      ioremap_nocache(chip->iobase_phys,
+  chip->iobase_virt = ioremap_nocache(chip->iobase_phys,
                                       pci_resource_len(pci, 0));
 ]]>
           </programlisting>
@@ -1511,7 +1510,7 @@
   {
           ....
           if (chip->iobase_virt)
-                  iounmap((void *)chip->iobase_virt);
+                  iounmap(chip->iobase_virt);
           ....
           pci_release_regions(chip->pci);
           ....
@@ -4060,8 +4059,8 @@
       <para>
         Also, there is a function to change the sample rate (of a
         certain register such as
-        <constant>AC97_PCM_FRONT_DAC_RATE</constant>) when VRA is
-        supported by the codec:
+        <constant>AC97_PCM_FRONT_DAC_RATE</constant>) when VRA or
+        DRA is supported by the codec:
         <function>snd_ac97_set_rate()</function>. 
 
         <informalexample>
@@ -4341,7 +4340,39 @@
       </para>
 
       <para>
-        If this function returns successfully with 0, then create a
+        When the accessing to the hardware requires special method
+        instead of the standard I/O access, you can create opl3 instance
+        separately with <function>snd_opl3_new()</function>.
+
+        <informalexample>
+          <programlisting>
+<![CDATA[
+  opl3_t *opl3;
+  snd_opl3_new(card, OPL3_HW_OPL3_XXX, &opl3);
+]]>
+          </programlisting>
+        </informalexample>
+      </para>
+
+      <para>
+	Then set <structfield>command</structfield>,
+	<structfield>private_data</structfield> and
+	<structfield>private_free</structfield> for the private
+	access function, the private data and the destructor.
+	The l_port and r_port are not necessarily set.  Only the
+	command must be set properly.  You can retrieve the data
+	from opl3-&gt;private_data field.
+      </para>
+
+      <para>
+	After creating the opl3 instance via <function>snd_opl3_new()</function>,
+	call <function>snd_opl3_init()</function> to initialize the chip to the
+	proper state.  Note that <function>snd_opl3_create()</function> always
+	calls it internally.
+      </para>
+
+      <para>
+        If the opl3 instance is created successfully, then create a
         hwdep device for this opl3. 
 
         <informalexample>
diff -Nru a/Documentation/sound/alsa/Joystick.txt b/Documentation/sound/alsa/Joystick.txt
--- a/Documentation/sound/alsa/Joystick.txt	2004-12-24 13:36:55 -08:00
+++ b/Documentation/sound/alsa/Joystick.txt	2004-12-24 13:36:55 -08:00
@@ -49,17 +49,15 @@
     cs46xx	N/A		N/A
     es1938	N/A		N/A
     es1968	joystick	0 = disable (default), 1 = enable
-    intel8x0(*1)joystick	0 = disable (default), 1 = enable
     sonicvibes	N/A		N/A
     trident	N/A		N/A
-    via82xx(*2)	joystick	0 = disable (default), 1 = enable
+    via82xx(*1)	joystick	0 = disable (default), 1 = enable
     ymfpci	joystick_port	0 = disable (default), 1 = auto-detect,
-                                manual: 0x201, 0x202, 0x204, 0x205(*3)
+                                manual: 0x201, 0x202, 0x204, 0x205(*2)
     ---------------------------------------------------------------------------
 
-    *1)  not all chips support joystick
-    *2)  VIA686A/B only
-    *3)  With YMF744/754 chips, the port address can be chosen arbitrarily
+    *1)  VIA686A/B only
+    *2)  With YMF744/754 chips, the port address can be chosen arbitrarily
 
 The following drivers don't support gameport natively, but there are
 additional modules.  Load the corresponding module to add the gameport
diff -Nru a/Documentation/sound/oss/ChangeLog.awe b/Documentation/sound/oss/ChangeLog.awe
--- a/Documentation/sound/oss/ChangeLog.awe	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,230 +0,0 @@
-ver.0.4.3p4
-	- Bug fix for invalid memory detection when initialized twice
-	- Add sample sharing function - works together with awesfx-0.4.3p3
-	- Add AWE_PROBE_DATA for probing sample id
-
-ver.0.4.3p3
-	- Replace memset to MEMSET (for FreeBSD)
-	- Add PAN_EXCHANGE switch
-
-ver.0.4.3p2
-	- MIDI emulation device is added
-	- Controls volume and filter targets
-	- Include chorus/reverb/equalizer values in MISC_MODE
-
-ver.0.4.3p1
-	- Change the volume calculation method
-	- Support for Tom Lees' PnP driver (v0.3)
-
-ver.0.4.2d
-	- Support for OSS/Free 3.8 on 2.0 kernels.
-	- Support for Linux PnP driver
-	- Support for module (for recent 2.1 kernels and RH5.0)
-	- Support for FreeBSD-3.0 system
-
-ver.0.4.2c
-	- Add a mode to enable drum channel toggle via bank number
-	  change.
-
-ver.0.4.2b
-	- Clear voice position after note on
-	- Change nrvoices according to the current playing mode
-
-ver.0.4.2a
-	- Fix a bug in pitch calculation with scale parameter
-	- Change default chorus & reverb modes
-
-ver.0.4.2
-	- Use indirect voice allocation mode; used as default mode
-	- Add preset mapping
-	- Free buffers when resetting samples
-	- Set default preset/bank/drumset as variable
-	- Fix a bug in exclusive note-off
-	- Add channel reset control macro
-	- Change modwheel sensitivity as variable
-	- Add lock option in open_patch
-	- Add channel priority mode macro, and disable it as default
-	- Add unset effect macro
-	- Add user defined chorus/reverb modes
-	- Do not initialize effect parameters when allocating voices
-	- Accept realtime filter-Q parameter change
-	- Check value range of set/add effects
-	- Change drum flags automatically when receiving bank #128
-
-ver.0.4.1	development versions
-
-ver.0.4.0c
-	- Fix kernel oops when setting AWE_FX_ATTEN
-
-ver.0.4.0b
-	- Do not kill_note in start_note when velocity is zero
-
-ver.0.4.0a
-	- Fix a bug in channel pressure effects
-
-ver.0.4.0
-	- Support dynamic buffer allocation
-	- Add functions to open/close/unload a patch
-	- Change from pointer to integer index in voice/sample lists
-	- Support for Linux/Alpha-AXP
-	- Fix for FreeBSD
-	- Add sostenuto control
-	- Add midi channel priority
-	- Fix a bug in all notes off control
-	- Use AWE_DEFAULT_MEMSIZE always if defined
-	- Fix a bug in awe_reset causes seg fault when no DRAM onboard
-	- Use awe_mem_start variable instead of constant
-
-ver.0.3.3c
-	- Fix IOCTL_TO_USER for OSS-3.8 (on Linux-2.1.25)
-	- Fix i/o macros for mixer controls
-
-ver.0.3.3b
-	- Fix version number in awe_version.h
-	- Fix a small bug in noteoff/release all
-
-ver.0.3.3a
-	- Fix all notes/sounds off
-	- Add layer effect control
-	- Add misc mode controls; realtime pan, version number, etc.
-	- Move gus bank control in misc mode control
-	- Modify awe_operations for OSS3.8b5
-	- Fix installation script
-
-ver.0.3.3
-	- Add bass/treble control in Emu8000 chip
-	- Add mixer device
-	- Fix sustain on to value 127
-
-ver.0.3.2
-	- Refuse linux-2.0.0 at installation
-	- Move awe_voice.h to /usr/include/linux
-
-ver.0.3.1b (not released)
-	- Rewrite chorus/reverb mode change functions
-	- Rewrite awe_detect & awe_check_dram routines
-
-ver.0.3.1a
-	- Fix a bug to reset voice counter in awe_reset
-	- Fix voice balance on GUS mode
-	- Make symlink on /usr/include/asm in install script
-
-ver.0.3.1
-	- Remove zero size arrays from awe_voice.h
-	- Fix init_fm routine
-	- Remove all samples except primary samples in REMOVE_LAST_SAMPLES
-
-ver.0.3.0a
-	- Add AWE_NOTEOFF_ALL control
-	- Remove AWE_INIT_ATTEN control
-
-ver.0.3.0
-	- Fix decay time table
-	- Add exclusive sounds mode
-	- Add capability to get current status
-
-ver.0.2.99e
-	- Add #ifdef for all sounds/notes off controls.
-	- Fix bugs on searching the default drumset/preset.
-	- Fix usslite patch to modify the default Config.in.
-
-ver.0.2.99d
-	- Fix bugs of attack/hold parameters
-	- Fix attack & decay time table
-
-ver.0.2.99c
-	- Change volume control messages (main & expression volume)
-	  to accesspt normal MIDI parameters in channel mode.
-	- Use channel mode in SEQ2 controls.
-
-ver.0.2.99b
-	- #ifdef patch manager functions (for OSS-3.7)
-
-ver.0.2.99a
-	- Fix sustain bug
-
-ver.0.2.99 (0.3 beta)
-	- Support multiple instruments
-
-ver.0.2.0c
-	- Add copyright notice
-	- FreeBSD 2.2-ALPHA integration
-
-ver.0.2.0b
-	- Remove buffered reading appended in v0.2.0a
-	- Remove SMAxW register check on writing
-	- Support Linux 2.1.x kernel
-	- Rewrite installation script
-
-ver.0.2.0a
-	- Define SEQUENCER_C for tuning.h for FreeBSD system
-	- Improvement of sample loading speed
-	- Fix installation script
-	- Add PnP driver functions for ISA PnP driver support
-
-ver.0.2.0
-	- Includes FreeBSD port
-	- Can load GUS compatible patches
-	- Change values of hardware control parameters for compatibility
-	  with GUS driver
-	- Accept 8bit or unsigned wave data
-	- Accept no blank loop data
-	- Add sample mode flags in sample_info
-
-ver.0.1.6
-	- Add voice effects control
-	- Fix awe_voice.h for word alignment
-
-ver.0.1.5c
-	- Fix FM(OPL) playback problem
-
-ver.0.1.5b
-	- Fix pitch calculation for fixed midi key
-
-ver.0.1.5a
-	- Fix bugs in removing samples from linked list.
-
-ver.0.1.5
-	- Add checksum verification for sample uploading
-	  (not compatible from older sample_info structure)
-	- Fix sample offset pointers to (actual value - 1)
-	- Add sequencer command to initialize awe32
-
-ver.0.1.4c
-	- Fix card detection and memory check function to avoid system crash
-	  at booting
-
-ver.0.1.4b
-	- Add release sustain mode
-	- Initialize FM each time after loading samples
-
-ver.0.1.4a
-	- Fix AWE card detection code
-	- Correct FM initialize position 
-	- Add non-releasing mode on voice info
-
-ver.0.1.4
-	- Add AWE card and DRAM detection codes
-	- Add FM initialization code
-	- Modify volume control
-	- Remove linear volume mode
-	- Change memory management; not using malloc dynamically
-	- Add remove-samples command
-	- Use internal id implicitly at loading samples
-
-ver.0.1.3
-	- Fix a bug on patch uploading to RAM
-
-ver.0.1.2
-	- Divide to separated packages
-	- Fix disagreed macro conditions
-	- Fix unresolved function bugs
-	- Integrate VoxWare and USS-Lite driver source (awe_voice.c)
-	  and remove awe_card.c
-
-ver.0.1.1
-	- Fix wrong sample numbers in sbktext
-	- Fix txt2sfx bug
-	- Fix pan parameter calculation
-	- Append USS-Lite/Linux2.0 driver
-
diff -Nru a/Documentation/sound/oss/ChangeLog.multisound b/Documentation/sound/oss/ChangeLog.multisound
--- a/Documentation/sound/oss/ChangeLog.multisound	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,213 +0,0 @@
-1998-12-04  Andrew T. Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.8.2.2
-
-	* Add msndreset program to shell archive.
-
-1998-11-11  Andrew T. Veliath  <andrewv@usa.net>
-
-	* msnd_pinnacle.c (mixer_ioctl): Add a mixer ioctl for
-	SOUND_MIXER_PRIVATE1 which does a full reset on the card.
-	(mixer_set): Move line in recording source to input monitor, aux
-	input level added, some mixer fixes.
-
-1998-09-10  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.8.2
-
-	* Add SNDCTL_DSP_GETOSPACE and SNDCTL_DSP_GETISPACE ioctls.
-
-1998-09-09  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.8.1
-	
-	* msnd_pinnacle.c: Fix resetting of default audio parameters. Turn
-	flush code from dsp_halt into dsp_write_flush, and use that for
-	SNDCTL_DSP_SYNC.
-
-1998-09-07  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.8.0
-
-	* Provide separate signal parameters for play and record.
-	
-	* Cleanups to locking and interrupt handling, change default
-	fifosize to 128kB.
-
-	* Update version to 0.7.15
-
-	* Interprocess full-duplex support (ie `cat /dev/dsp > /dev/dsp').
-
-	* More mutex sections for read and write fifos (read + write locks
-	added).
-
-1998-09-05  Andrew Veliath  <andrewtv@usa.net>
-
-	* msnd_pinnacle.c: (chk_send_dsp_cmd) Do full DSP reset upon DSP
-	timeout (when not in interrupt; maintains mixer settings).  Fixes
-	to flushing and IRQ ref counting. Rewrote queuing for smoother
-	playback and fixed initial playback cutoff problem.
-
-1998-09-03  Andrew Veliath  <andrewtv@usa.net>
-
-	* Replaced packed structure accesses with standard C equivalents.
-
-1998-09-01  Andrew Veliath  <andrewtv@usa.net>
-
-	* msnd_pinnacle.c: Add non-PnP configuration to driver code, which
-	  will facilitate compiled-in operation.
-
-1998-08-29  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.7.6
-	
-	* msnd_pinnacle.c (dsp_ioctl): Add DSP_GETFMTS, change SAMPLESIZE
-	  to DSP_SETFMT.
-
-	* Update version to 0.7.5
-	
-	* Create pinnaclecfg.c and turn MultiSound doc into a shell
-	  archive with pinnaclecfg.c included.  pinnaclecfg.c can
-	  now fully configure the card in non-PnP mode, including the
-	  joystick and IDE controller.  Also add an isapnp conf
-	  example.
-
-	* Reduce DSP reset timeout from 20000 to 100
-
-1998-08-06  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.7.2
-	
-	* After A/D calibration, do an explicit set to the line input,
-	  rather than using set_recsrc
-
-1998-07-20  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.7.1
-
-	* Add more OSS ioctls
-	
-1998-07-19  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update doc file
-	
-	* Bring back DIGITAL1 with digital parameter to msnd_pinnacle.c
-	  and CONFIG_MSNDPIN_DIGITAL.  I'm not sure this actually works,
-	  since I find audio playback goes into a very speeded mode of
-	  operation, however it might be due to a lack of a digital
-	  source, which I don't have to test.
-
-1998-07-18  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.7.0
-
-	* Can now compile with Alan Cox' 2.0.34-modular-sound patch (so
-	  now it requires >= 2.1.106 or 2.0.34-ms) (note for 2.0.34-ms it
-	  is in the Experimental section)
-
-	* More modularization, consolidation, also some MIDI hooks
-	  installed for future MIDI modules
-
-	* Write flush
-
-	* Change default speed, channels, bit size to OSS/Free defaults
-
-1998-06-02  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.5b
-
-	* Fix version detection
-	
-	* Remove underflow and overflow resets (delay was too long)
-
-	* Replace spinlocked bitops with atomic bit ops
-
-1998-05-27  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.5a
-	
-	* Better recovery from underflow or overflow conditions
-	
-	* Fix a deadlock condition with one thread reading and the other
-	  writing
-
-1998-05-26  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.5
-	
-	* Separate reset queue functions for play and record
-
-	* Add delays in dsp_halt
-
-1998-05-24  Andrew Veliath  <andrewtv@usa.net>
-
-	* Add a check for Linux >= 2.1.95
-	
-	* Remove DIGITAL1 input until I figure out how to make it work
-	
-	* Add HAVE_DSPCODEH which when not defined will load firmware from
-	  files using mod_firmware_load, then release memory after they
-	  are uploaded (requires reorganized OSS).
-
-1998-05-22  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.4c
-
-	* Hopefully fix the mixer volume problem
-
-1998-05-19  Andrew Veliath  <andrewtv@usa.net>
-
-	* Add __initfuncs and __initdatas to reduce resident code size
-
-	* Move bunch of code around, remove some protos
-
-	* Integrate preliminary changes for Alan Cox's OSS reorganization
-	  for non-OSS drivers to coexist with OSS devices on the same
-	  major.  To compile standalone, must now define STANDALONE.
-
-1998-05-16  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.4b
-	
-	* Integrated older card support into a unified driver, tested on a
-	  MultiSound Classic c/o Kendrick Vargas.
-
-1998-05-15  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.4
-	
-	* Fix read/write return values
-
-1998-05-13  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.3
-
-	* Stop play gracefully
-
-	* Add busy flag
-	
-	* Add major and calibrate_signal module parameters
-	
-	* Add ADC calibration
-
-	* Add some OSS compatibility ioctls
-
-	* Add mixer record selection
-	
-	* Add O_NONBLOCK support, separate read/write wait queues
-
-	* Add sample bit size ioctl, expanded sample rate ioctl
-
-	* Playback suspension now resumes
-
-	* Use signal_pending after interruptible_sleep_on
-	
-	* Add recording, change ints to bit flags
-
-1998-05-11  Andrew Veliath  <andrewtv@usa.net>
-
-	* Update version to 0.2
-
-	* Add preliminary playback support
-
-	* Use new Turtle Beach DSP code
\ No newline at end of file
diff -Nru a/Documentation/sound/oss/README.modules b/Documentation/sound/oss/README.modules
--- a/Documentation/sound/oss/README.modules	2004-12-24 13:37:19 -08:00
+++ b/Documentation/sound/oss/README.modules	2004-12-24 13:37:19 -08:00
@@ -59,8 +59,9 @@
 uart401.o # Used by sb, maybe other cards
 
  Whichever card you have, try feeding it the options that would be the
-default if you were making the driver wired, not as modules. You can look
-at the init_module() code for the card to see what args are expected.
+default if you were making the driver wired, not as modules. You can
+look at function referred to by module_init() for the card to see what
+args are expected.
 
  Note that at present there is no way to configure the io, irq and other
 parameters for the modular drivers as one does for the wired drivers.. One
diff -Nru a/Documentation/stable_api_nonsense.txt b/Documentation/stable_api_nonsense.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/stable_api_nonsense.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,193 @@
+The Linux Kernel Driver Interface
+(all of your questions answered and then some)
+
+Greg Kroah-Hartman <greg@kroah.com>
+
+This is being written to try to explain why Linux does not have a binary
+kernel interface, nor does it have a stable kernel interface.  Please
+realize that this article describes the _in kernel_ interfaces, not the
+kernel to userspace interfaces.  The kernel to userspace interface is
+the one that application programs use, the syscall interface.  That
+interface is _very_ stable over time, and will not break.  I have old
+programs that were built on a pre 0.9something kernel that still works
+just fine on the latest 2.6 kernel release.  This interface is the one
+that users and application programmers can count on being stable.
+
+
+Executive Summary
+-----------------
+You think you want a stable kernel interface, but you really do not, and
+you don't even know it.  What you want is a stable running driver, and
+you get that only if your driver is in the main kernel tree.  You also
+get lots of other good benefits if your driver is in the main kernel
+tree, all of which has made Linux into such a strong, stable, and mature
+operating system which is the reason you are using it in the first
+place.
+
+
+Intro
+-----
+
+It's only the odd person who wants to write a kernel driver that needs
+to worry about the in-kernel interfaces changing.  For the majority of
+the world, they neither see this interface, nor do they care about it at
+all.
+
+First off, I'm not going to address _any_ legal issues about closed
+source, hidden source, binary blobs, source wrappers, or any other term
+that describes kernel drivers that do not have their source code
+released under the GPL.  Please consult a lawyer if you have any legal
+questions, I'm a programmer and hence, I'm just going to be describing
+the technical issues here (not to make light of the legal issues, they
+are real, and you do need to be aware of them at all times.)
+
+So, there are two main topics here, binary kernel interfaces and stable
+kernel source interfaces.  They both depend on each other, but we will
+discuss the binary stuff first to get it out of the way.
+
+
+Binary Kernel Interface
+-----------------------
+Assuming that we had a stable kernel source interface for the kernel, a
+binary interface would naturally happen too, right?  Wrong.  Please
+consider the following facts about the Linux kernel:
+  - Depending on the version of the C compiler you use, different kernel
+    data structures will contain different alignment of structures, and
+    possibly include different functions in different ways (putting
+    functions inline or not.)  The individual function organization
+    isn't that important, but the different data structure padding is
+    very important.
+  - Depending on what kernel build options you select, a wide range of
+    different things can be assumed by the kernel:
+      - different structures can contain different fields
+      - Some functions may not be implemented at all, (i.e. some locks
+	compile away to nothing for non-SMP builds.)
+      - Parameter passing of variables from function to function can be
+	done in different ways (the CONFIG_REGPARM option controls
+	this.)
+      - Memory within the kernel can be aligned in different ways,
+	depending on the build options.
+  - Linux runs on a wide range of different processor architectures.
+    There is no way that binary drivers from one architecture will run
+    on another architecture properly.
+
+Now a number of these issues can be addressed by simply compiling your
+module for the exact specific kernel configuration, using the same exact
+C compiler that the kernel was built with.  This is sufficient if you
+want to provide a module for a specific release version of a specific
+Linux distribution.  But multiply that single build by the number of
+different Linux distributions and the number of different supported
+releases of the Linux distribution and you quickly have a nightmare of
+different build options on different releases.  Also realize that each
+Linux distribution release contains a number of different kernels, all
+tuned to different hardware types (different processor types and
+different options), so for even a single release you will need to create
+multiple versions of your module.
+
+Trust me, you will go insane over time if you try to support this kind
+of release, I learned this the hard way a long time ago...
+
+
+Stable Kernel Source Interfaces
+-------------------------------
+
+This is a much more "volatile" topic if you talk to people who try to
+keep a Linux kernel driver that is not in the main kernel tree up to
+date over time.
+
+Linux kernel development is continuous and at a rapid pace, never
+stopping to slow down.  As such, the kernel developers find bugs in
+current interfaces, or figure out a better way to do things.  If they do
+that, they then fix the current interfaces to work better.  When they do
+so, function names may change, structures may grow or shrink, and
+function parameters may be reworked.  If this happens, all of the
+instances of where this interface is used within the kernel are fixed up
+at the same time, ensuring that everything continues to work properly.
+
+As a specific examples of this, the in-kernel USB interfaces have
+undergone at least three different reworks over the lifetime of this
+subsystem.  These reworks were done to address a number of different
+issues:
+  - A change from a synchronous model of data streams to an asynchronous
+    one.  This reduced the complexity of a number of drivers and
+    increased the throughput of all USB drivers such that we are now
+    running almost all USB devices at their maximum speed possible.
+  - A change was made in the way data packets were allocated from the
+    USB core by USB drivers so that all drivers now needed to provide
+    more information to the USB core to fix a number of documented
+    deadlocks.
+
+This is in stark contrast to a number of closed source operating systems
+which have had to maintain their older USB interfaces over time.  This
+provides the ability for new developers to accidentally use the old
+interfaces and do things in improper ways, causing the stability of the
+operating system to suffer.
+
+In both of these instances, all developers agreed that these were
+important changes that needed to be made, and they were made, with
+relatively little pain.  If Linux had to ensure that it preserve a
+stable source interface, a new interface would have been created, and
+the older, broken one would have had to be maintained over time, leading
+to extra work for the USB developers.  Since all Linux USB developers do
+their work on their own time, asking programmers to do extra work for no
+gain, for free, is not a possibility.
+
+Security issues are also a very important for Linux.  When a
+security issue is found, it is fixed in a very short amount of time.  A
+number of times this has caused internal kernel interfaces to be
+reworked to prevent the security problem from occurring.  When this
+happens, all drivers that use the interfaces were also fixed at the
+same time, ensuring that the security problem was fixed and could not
+come back at some future time accidentally.  If the internal interfaces
+were not allowed to change, fixing this kind of security problem and
+insuring that it could not happen again would not be possible.
+
+Kernel interfaces are cleaned up over time.  If there is no one using a
+current interface, it is deleted.  This ensures that the kernel remains
+as small as possible, and that all potential interfaces are tested as
+well as they can be (unused interfaces are pretty much impossible to
+test for validity.)
+
+
+What to do
+----------
+
+So, if you have a Linux kernel driver that is not in the main kernel
+tree, what are you, a developer, supposed to do?  Releasing a binary
+driver for every different kernel version for every distribution is a
+nightmare, and trying to keep up with an ever changing kernel interface
+is also a rough job.
+
+Simple, get your kernel driver into the main kernel tree (remember we
+are talking about GPL released drivers here, if your code doesn't fall
+under this category, good luck, you are on your own here, you leech
+<insert link to leech comment from Andrew and Linus here>.)  If your
+driver is in the tree, and a kernel interface changes, it will be fixed
+up by the person who did the kernel change in the first place.  This
+ensures that your driver is always buildable, and works over time, with
+very little effort on your part.
+
+The very good side affects of having your driver in the main kernel tree
+are:
+  - The quality of the driver will rise as the maintenance costs (to the
+    original developer) will decrease.
+  - Other developers will add features to your driver.
+  - Other people will find and fix bugs in your driver.
+  - Other people will find tuning opportunities in your driver.
+  - Other people will update the driver for you when external interface
+    changes require it.
+  - The driver automatically gets shipped in all Linux distributions
+    without having to ask the distros to add it.
+    
+As Linux supports a larger number of different devices "out of the box"
+than any other operating system, and it supports these devices on more
+different processor architectures than any other operating system, this
+proven type of development model must be doing something right :)
+
+
+
+------
+
+Thanks to Randy Dunlap, Andrew Morton, David Brownell, Hanna Linder,
+Robert Love, and Nishanth Aravamudan for their review and comments on
+early drafts of this paper.
diff -Nru a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt
--- a/Documentation/sysctl/vm.txt	2004-12-24 13:37:04 -08:00
+++ b/Documentation/sysctl/vm.txt	2004-12-24 13:37:04 -08:00
@@ -31,7 +31,7 @@
 
 dirty_ratio, dirty_background_ratio, dirty_expire_centisecs,
 dirty_writeback_centisecs, vfs_cache_pressure, laptop_mode,
-block_dump:
+block_dump, swap_token_timeout:
 
 See Documentation/filesystems/proc.txt
 
diff -Nru a/Documentation/time_interpolators.txt b/Documentation/time_interpolators.txt
--- a/Documentation/time_interpolators.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/time_interpolators.txt	2004-12-24 13:37:18 -08:00
@@ -9,32 +9,33 @@
 settimeofday under Linux. The time interpolator provides both if an arch
 defines CONFIG_TIME_INTERPOLATION. The arch still must set up timer tick
 operations and call the necessary functions to advance the clock.
+
 With the time interpolator a standardized interface exists for time
-interpolation between ticks which also allows the determination
-of time in a hardware independent way. The provided logic is highly scalable
+interpolation between ticks. The provided logic is highly scalable
 and has been tested in SMP situations of up to 512 CPUs.
 
 If CONFIG_TIME_INTERPOLATION is defined then the architecture specific code
-(or the device drivers - like HPET) must register time interpolators.
+(or the device drivers - like HPET) may register time interpolators.
 These are typically defined in the following way:
 
-static struct time_interpolator my_interpolator;
+static struct time_interpolator my_interpolator {
+	.frequency = MY_FREQUENCY,
+	.source = TIME_SOURCE_MMIO32,
+	.shift = 8,		/* scaling for higher accuracy */
+	.drift = -1,		/* Unknown drift */
+	.jitter = 0		/* time source is stable */
+};
 
 void time_init(void)
 {
 	....
 	/* Initialization of the timer *.
-	my_interpolator.frequency = MY_FREQUENCY;
-	my_interpolator.source = TIME_SOURCE_MMIO32;
 	my_interpolator.address = &my_timer;
-	my_interpolator.shift = 32;		/* increase accuracy of scaling */
-	my_interpolator.drift = -1;		/* Unknown */
-	my_interpolator.jitter = 0;		/* A stable time source */
 	register_time_interpolator(&my_interpolator);
 	....
 }
 
-For more details see include/linux/timex.h.
+For more details see include/linux/timex.h and kernel/timer.c.
 
-Christoph Lameter <christoph@lameter.com>, September 8, 2004
+Christoph Lameter <christoph@lameter.com>, October 31, 2004
 
diff -Nru a/Documentation/tipar.txt b/Documentation/tipar.txt
--- a/Documentation/tipar.txt	2004-12-24 13:36:16 -08:00
+++ b/Documentation/tipar.txt	2004-12-24 13:36:16 -08:00
@@ -4,7 +4,7 @@
 
 
 Author: Romain Lievin
-Homepage: http://lpg.ticalc.org/prj_dev
+Homepage: http://lpg.ticalc.org/prj_tidev/index.html
 
 
 INTRODUCTION:
@@ -12,31 +12,30 @@
 This is a driver for the very common home-made parallel link cable, a cable 
 designed for connecting TI8x/9x graphing calculators (handhelds) to a computer
 or workstation (Alpha, Sparc). Given that driver is built on parport, the 
-parallel port abstraction layer, this driver is independent of the platform.
+parallel port abstraction layer, this driver is architecture-independent.
 
 It can also be used with another device plugged on the same port (such as a
-ZIP drive). I have a 100MB ZIP and both of them work fine !
+ZIP drive). I have a 100MB ZIP and both of them work fine!
 
 If you need more information, please visit the 'TI drivers' homepage at the URL
 above.
 
 WHAT YOU NEED:
 
-A TI calculator of course and a program capable to communicate with your 
-calculator.
-TiLP will work for sure (since I am his developer !). yal92 may be able to use
+A TI calculator and a program capable of communicating with your calculator.
+
+TiLP will work for sure (since I am its developer!). yal92 may be able to use
 it by changing tidev for tipar (may require some hacking...).
 
 HOW TO USE IT:
 
 You must have first compiled parport support (CONFIG_PARPORT_DEV): either 
 compiled in your kernel, either as a module. 
-This driver supports the new device hierarchy (devfs).
 
-Next, (as root) from your appropriate modules directory (lib/modules/2.5.XX):
+Next, (as root):
 
        modprobe parport
-       insmod tipar.o
+       modprobe tipar
 
 If it is not already there (it usually is), create the device:
 
@@ -47,14 +46,14 @@
 You will have to set permissions on this device to allow you to read/write
 from it:
 
-       chmod 666 /dev/tipar?
+       chmod 666 /dev/tipar[0..2]
        
 Now you are ready to run a linking program such as TiLP. Be sure to configure 
 it properly (RTFM).
        
 MODULE PARAMETERS:
 
-  You can set these with:  insmod tipar NAME=VALUE
+  You can set these with:  modprobe tipar NAME=VALUE
   There is currently no way to set these on a per-cable basis.
 
   NAME: timeout
@@ -66,11 +65,12 @@
   NAME: delay
   TYPE: integer
   DEFAULT: 10
-  DESC: Inter-bit delay in micro-seconds. An lower value gives an higher data 
+  DESC: Inter-bit delay in micro-seconds. A lower value gives an higher data
 	rate but makes transmission less reliable.
 
 These parameters can be changed at run time by any program via ioctl(2) calls 
-as listed in ./include/linux/ticable.h
+as listed in ./include/linux/ticable.h.
+
 Rather than write 50 pages describing the ioctl() and so on, it is
 perhaps more useful you look at ticables library (dev_link.c) that demonstrates
 how to use them, and demonstrates the features of the driver. This is
diff -Nru a/Documentation/tty.txt b/Documentation/tty.txt
--- a/Documentation/tty.txt	2004-12-24 13:37:33 -08:00
+++ b/Documentation/tty.txt	2004-12-24 13:37:33 -08:00
@@ -49,10 +49,9 @@
 			discipline for this tty will occur until it
 			completes successfully. Can sleep.
 
-write()		-	A process is writing data from user space
-			through the line discipline. Multiple write calls
-			are serialized by the tty layer for the ldisc. May
-			sleep.
+write()		-	A process is writing data through the line
+			discipline.  Multiple write calls are serialized
+			by the tty layer for the ldisc.  May sleep. 
 
 flush_buffer()	-	May be called at any point between open and close.
 
diff -Nru a/Documentation/usb/error-codes.txt b/Documentation/usb/error-codes.txt
--- a/Documentation/usb/error-codes.txt	2004-12-24 13:36:17 -08:00
+++ b/Documentation/usb/error-codes.txt	2004-12-24 13:36:17 -08:00
@@ -1,11 +1,12 @@
-Revised: 2002-Feb-09.
+Revised: 2004-Oct-21
 
 This is the documentation of (hopefully) all possible error codes (and
 their interpretation) that can be returned from usbcore.
 
 Some of them are returned by the Host Controller Drivers (HCDs), which
 device drivers only see through usbcore.  As a rule, all the HCDs should
-behave the same except for transfer speed dependent behaviors.
+behave the same except for transfer speed dependent behaviors and the
+way certain faults are reported.
 
 
 **************************************************************************
@@ -26,29 +27,35 @@
 		of urb.  (treat as a host controller bug.)
 
 -EINVAL		a) Invalid transfer type specified (or not supported)
-		b) Invalid interrupt interval (0<=n<256)
-		c) more than one interrupt packet requested
+		b) Invalid or unsupported periodic transfer interval
+		c) ISO: attempted to change transfer interval
 		d) ISO: number_of_packets is < 0
+		e) various other cases
 
 -EAGAIN		a) specified ISO start frame too early
 		b) (using ISO-ASAP) too much scheduled for the future
 		   wait some time and try again.
 
--EFBIG		too much ISO frames requested (currently uhci>900)
+-EFBIG		Host controller driver can't schedule that many ISO frames.
 
 -EPIPE		Specified endpoint is stalled.  For non-control endpoints,
 		reset this status with usb_clear_halt().
 
--EMSGSIZE	endpoint message size is zero, do interface/alternate setting
+-EMSGSIZE	(a) endpoint maxpacket size is zero; it is not usable
+		    in the current interface altsetting.
+		(b) ISO packet is biger than endpoint maxpacket
+		(c) requested data transfer size is invalid (negative)
 
--ENOSPC		The host controller's bandwidth is already consumed and
-		this request would push it past its allowed limit.
+-ENOSPC		This request would overcommit the usb bandwidth reserved
+		for periodic transfers (interrupt, isochronous).
 
--ESHUTDOWN	The host controller has been disabled due to some
+-ESHUTDOWN	The device or host controller has been disabled due to some
 		problem that could not be worked around.
 
 -EPERM		Submission failed because urb->reject was set.
 
+-EHOSTUNREACH	URB was rejected because the device is suspended.
+
 
 **************************************************************************
 *                   Error codes returned by in urb->status               *
@@ -71,14 +78,14 @@
 -EINPROGRESS		URB still pending, no results yet
 			(That is, if drivers see this it's a bug.)
 
--EPROTO (*)		a) bitstuff error
+-EPROTO (*, **)		a) bitstuff error
 			b) no response packet received within the
 			   prescribed bus turn-around time
 			c) unknown USB error 
 
--EILSEQ (*)		CRC mismatch
+-EILSEQ (*, **)		CRC mismatch
 
--EPIPE			Endpoint stalled.  For non-control endpoints,
+-EPIPE (**)		Endpoint stalled.  For non-control endpoints,
 			reset this status with usb_clear_halt().
 
 -ECOMM			During an IN transfer, the host controller
@@ -97,7 +104,7 @@
 			specified buffer, and URB_SHORT_NOT_OK was set in
 			urb->transfer_flags.
 
--ETIMEDOUT		transfer timed out, NAK
+-ETIMEDOUT (**)		transfer timed out, NAK
 
 -ENODEV			Device was removed.  Often preceded by a burst of
 			other errors, since the hub driver does't detect
@@ -110,12 +117,18 @@
 
 -ECONNRESET		URB was asynchronously unlinked by usb_unlink_urb
 
--ESHUTDOWN		The host controller has been disabled due to some
-			problem that could not be worked around.
+-ESHUTDOWN		The device or host controller has been disabled due
+			to some problem that could not be worked around,
+			such as a physical disconnect.
 
 
 (*) Error codes like -EPROTO, -EILSEQ and -EOVERFLOW normally indicate
 hardware problems such as bad devices (including firmware) or cables.
+
+(**) This is also one of several codes that different kinds of host
+controller use to to indicate a transfer has failed because of device
+disconnect.  In the interval before the hub driver starts disconnect
+processing, devices may receive such fault reports for every request.
 
 
 
diff -Nru a/Documentation/usb/gadget_serial.txt b/Documentation/usb/gadget_serial.txt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/Documentation/usb/gadget_serial.txt	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,332 @@
+
+                 Linux Gadget Serial Driver v2.0
+                           11/20/2004
+
+
+License and 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.
+
+This document and the the gadget serial driver itself are
+Copyright (C) 2004 by Al Borchers (alborchers@steinerpoint.com).
+
+If you have questions, problems, or suggestions for this driver
+please contact Al Borchers at alborchers@steinerpoint.com.
+
+
+Prerequisites
+-------------
+Versions of the gadget serial driver are available for the
+2.4 Linux kernels, but this document assumes you are using
+version 2.0 or later of the gadget serial driver in a 2.6
+Linux kernel.
+
+This document assumes that you are familiar with Linux and
+Windows and know how to configure and build Linux kernels, run
+standard utilities, use minicom and HyperTerminal, and work with
+USB and serial devices.  It also assumes you configure the Linux
+gadget and usb drivers as modules.
+
+
+Overview
+--------
+The gadget serial driver is a Linux USB gadget driver, a USB device
+side driver.  It runs on a Linux system that has USB device side
+hardware; for example, a PDA, an embedded Linux system, or a PC
+with a USB development card.
+
+The gadget serial driver talks over USB to either a CDC ACM driver
+or a generic USB serial driver running on a host PC.
+
+   Host
+   --------------------------------------
+  | Host-Side   CDC ACM       USB Host   |
+  | Operating |   or        | Controller |   USB
+  | System    | Generic USB | Driver     |--------
+  | (Linux or | Serial      | and        |        |
+  | Windows)    Driver        USB Stack  |        |
+   --------------------------------------         |
+                                                  |
+                                                  |
+                                                  |
+   Gadget                                         |
+   --------------------------------------         |
+  | Gadget                   USB Periph. |        |
+  | Device-Side |  Gadget  | Controller  |        |
+  | Linux       |  Serial  | Driver      |--------
+  | Operating   |  Driver  | and         |
+  | System                   USB Stack   |
+   --------------------------------------
+
+On the device-side Linux system, the gadget serial driver looks
+like a serial device.
+
+On the host-side system, the gadget serial device looks like a
+CDC ACM compliant class device or a simple vendor specific device
+with bulk in and bulk out endpoints, and it is treated similarly
+to other serial devices.
+
+The host side driver can potentially be any ACM compliant driver
+or any driver that can talk to a device with a simple bulk in/out
+interface.  Gadget serial has been tested with the Linux ACM driver,
+the Windows usbser.sys ACM driver, and the Linux USB generic serial
+driver.
+
+With the gadget serial driver and the host side ACM or generic
+serial driver running, you should be able to communicate between
+the host and the gadget side systems as if they were connected by a
+serial cable.
+
+The gadget serial driver only provides simple unreliable data
+communication.  It does not yet handle flow control or many other
+features of normal serial devices.
+
+
+Installing the Gadget Serial Driver
+-----------------------------------
+To use the gadget serial driver you must configure the Linux gadget
+side kernel for "Support for USB Gadgets", for a "USB Peripheral
+Controller" (for example, net2280), and for the "Serial Gadget"
+driver.  All this are listed under "USB Gadget Support" when
+configuring the kernel.  Then rebuild and install the kernel or
+modules.
+
+The gadget serial driver uses major number 127, for now.  So you
+will need to create a device node for it, like this:
+
+  mknod /dev/ttygserial c 127 0
+
+You only need to do this once.
+
+Then you must load the gadget serial driver.  To load it as an
+ACM device, do this:
+
+  modprobe g_serial use_acm=1
+
+To load it as a vendor specific bulk in/out device, do this:
+
+  modprobe g_serial
+
+This will also automatically load the underlying gadget peripheral
+controller driver.  This must be done each time you reboot the gadget
+side Linux system.  You can add this to the start up scripts, if
+desired.
+
+If gadget serial is loaded as an ACM device you will want to use
+either the Windows or Linux ACM driver on the host side.  If gadget
+serial is loaded as a bulk in/out device, you will want to use the
+Linux generic serial driver on the host side.  Follow the appropriate
+instructions below to install the host side driver.
+
+
+Installing the Windows Host ACM Driver
+--------------------------------------
+To use the Windows ACM driver you must have the files "gserial.inf"
+and "usbser.sys" together in a folder on the Windows machine.
+
+The "gserial.inf" file is given here.
+
+-------------------- CUT HERE --------------------
+[Version]
+Signature="$Windows NT$"
+Class=Ports
+ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
+Provider=%LINUX%
+DriverVer=08/17/2004,0.0.2.0
+; Copyright (C) 2004 Al Borchers (alborchers@steinerpoint.com)
+
+[Manufacturer]
+%LINUX%=GSerialDeviceList
+
+[GSerialDeviceList]
+%GSERIAL%=GSerialInstall, USB\VID_0525&PID_A4A7
+
+[DestinationDirs]
+DefaultDestDir=10,System32\Drivers
+
+[GSerialInstall]
+CopyFiles=GSerialCopyFiles
+AddReg=GSerialAddReg
+
+[GSerialCopyFiles]
+usbser.sys
+
+[GSerialAddReg]
+HKR,,DevLoader,,*ntkern
+HKR,,NTMPDriver,,usbser.sys
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
+
+[GSerialInstall.Services]
+AddService = usbser,0x0002,GSerialService
+
+[GSerialService]
+DisplayName = %GSERIAL_DISPLAY_NAME%
+ServiceType = 1                  ; SERVICE_KERNEL_DRIVER
+StartType = 3                    ; SERVICE_DEMAND_START
+ErrorControl = 1                 ; SERVICE_ERROR_NORMAL
+ServiceBinary = %10%\System32\Drivers\usbser.sys
+LoadOrderGroup = Base
+
+[Strings]
+LINUX = "Linux"
+GSERIAL = "Gadget Serial"
+GSERIAL_DISPLAY_NAME = "USB Gadget Serial Driver"
+-------------------- CUT HERE --------------------
+
+The "usbser.sys" file comes with various versions of Windows.
+For example, it can be found on Windows XP typically in
+
+  C:\WINDOWS\Driver Cache\i386\driver.cab
+
+Or it can be found on the Windows 98SE CD in the "win98" folder
+in the "DRIVER11.CAB" through "DRIVER20.CAB" cab files.  You will
+need the DOS "expand" program, the Cygwin "cabextract" program, or
+a similar program to unpack these cab files and extract "usbser.sys".
+
+For example, to extract "usbser.sys" into the current directory
+on Windows XP, open a DOS window and run a command like
+
+  expand C:\WINDOWS\Driver~1\i386\driver.cab -F:usbser.sys .
+
+(Thanks to Nishant Kamat for pointing out this DOS command.)
+
+When the gadget serial driver is loaded and the USB device connected
+to the Windows host with a USB cable, Windows should recognize the
+gadget serial device and ask for a driver.  Tell Windows to find the
+driver in the folder that contains "gserial.inf" and "usbser.sys".
+
+For example, on Windows XP, when the gadget serial device is first
+plugged in, the "Found New Hardware Wizard" starts up.  Select
+"Install from a list or specific location (Advanced)", then on
+the next screen select "Include this location in the search" and
+enter the path or browse to the folder containing "gserial.inf" and
+"usbser.sys".  Windows will complain that the Gadget Serial driver
+has not passed Windows Logo testing, but select "Continue anyway"
+and finish the driver installation.
+
+On Windows XP, in the "Device Manager" (under "Control Panel",
+"System", "Hardware") expand the "Ports (COM & LPT)" entry and you
+should see "Gadget Serial" listed as the driver for one of the COM
+ports.
+
+To uninstall the Windows XP driver for "Gadget Serial", right click
+on the "Gadget Serial" entry in the "Device Manager" and select
+"Uninstall".
+
+
+Installing the Linux Host ACM Driver
+------------------------------------
+To use the Linux ACM driver you must configure the Linux host side
+kernel for "Support for Host-side USB" and for "USB Modem (CDC ACM)
+support".
+
+Once the gadget serial driver is loaded and the USB device connected
+to the Linux host with a USB cable, the host system should recognize
+the gadget serial device.  For example, the command
+
+  cat /proc/bus/usb/devices
+
+should show something like this:
+
+T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  5 Spd=480 MxCh= 0
+D:  Ver= 2.00 Cls=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
+P:  Vendor=0525 ProdID=a4a7 Rev= 2.01
+S:  Manufacturer=Linux 2.6.8.1 with net2280
+S:  Product=Gadget Serial
+S:  SerialNumber=0
+C:* #Ifs= 2 Cfg#= 2 Atr=c0 MxPwr=  2mA
+I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=01 Driver=acm
+E:  Ad=83(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
+I:  If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=acm
+E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
+E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
+
+If the host side Linux system is configured properly, the ACM driver
+should be loaded automatically.  The command "lsmod" should show the
+"acm" module is loaded.
+
+
+Installing the Linux Host Generic USB Serial Driver
+---------------------------------------------------
+To use the Linux generic USB serial driver you must configure the
+Linux host side kernel for "Support for Host-side USB", for "USB
+Serial Converter support", and for the "USB Generic Serial Driver".
+
+Once the gadget serial driver is loaded and the USB device connected
+to the Linux host with a USB cable, the host system should recognize
+the gadget serial device.  For example, the command
+
+  cat /proc/bus/usb/devices
+
+should show something like this:
+
+T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  6 Spd=480 MxCh= 0
+D:  Ver= 2.00 Cls=ff(vend.) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
+P:  Vendor=0525 ProdID=a4a6 Rev= 2.01
+S:  Manufacturer=Linux 2.6.8.1 with net2280
+S:  Product=Gadget Serial
+S:  SerialNumber=0
+C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  2mA
+I:  If#= 0 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=serial
+E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
+E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
+
+You must explicitly load the usbserial driver with parameters to
+configure it to recognize the gadget serial device, like this:
+
+  modprobe usbserial vendor=0x0525 product=0xA4A6
+
+If everything is working, usbserial will print a message in the
+system log saying something like "Gadget Serial converter now
+attached to ttyUSB0".
+
+
+Testing with Minicom or HyperTerminal
+-------------------------------------
+Once the gadget serial driver and the host driver are both installed,
+and a USB cable connects the gadget device to the host, you should
+be able to communicate over USB between the gadget and host systems.
+You can use minicom or HyperTerminal to try this out.
+
+On the gadget side run "minicom -s" to configure a new minicom
+session.  Under "Serial port setup" set "/dev/ttygserial" as the
+"Serial Device".  Set baud rate, data bits, parity, and stop bits,
+to 9600, 8, none, and 1--these settings mostly do not matter.
+Under "Modem and dialing" erase all the modem and dialing strings.
+
+On a Linux host running the ACM driver, configure minicom similarly
+but use "/dev/ttyACM0" as the "Serial Device".  (If you have other
+ACM devices connected, change the device name appropriately.)
+
+On a Linux host running the USB generic serial driver, configure
+minicom similarly, but use "/dev/ttyUSB0" as the "Serial Device".
+(If you have other USB serial devices connected, change the device
+name appropriately.)
+
+On a Windows host configure a new HyperTerminal session to use the
+COM port assigned to Gadget Serial.  The "Port Settings" will be
+set automatically when HyperTerminal connects to the gadget serial
+device, so you can leave them set to the default values--these
+settings mostly do not matter.
+
+With minicom configured and running on the gadget side and with
+minicom or HyperTerminal configured and running on the host side,
+you should be able to send data back and forth between the gadget
+side and host side systems.  Anything you type on the terminal
+window on the gadget side should appear in the terminal window on
+the host side and vice versa.
+
+
diff -Nru a/Documentation/usb/silverlink.txt b/Documentation/usb/silverlink.txt
--- a/Documentation/usb/silverlink.txt	2004-12-24 13:36:47 -08:00
+++ b/Documentation/usb/silverlink.txt	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------
 Readme for Linux device driver for the Texas Instruments SilverLink cable
+and direct USB cable provided by some TI's handhelds.
 -------------------------------------------------------------------------
 
 Author: Romain Liévin & Julien Blache
@@ -9,7 +10,8 @@
 
 This is a driver for the TI-GRAPH LINK USB (aka SilverLink) cable, a cable 
 designed by TI for connecting their TI8x/9x calculators to a computer 
-(PC or Mac usually).
+(PC or Mac usually). It has been extended to support the USB port offered by
+some latest TI handhelds (TI84+ and TI89 Titanium).
 
 If you need more information, please visit the 'SilverLink drivers' homepage 
 at the above URL.
@@ -73,4 +75,4 @@
 CREDITS:
 
 The code is based on dabusb.c, printer.c and scanner.c !
-The driver has been developed independently of Texas Instruments.
+The driver has been developed independently of Texas Instruments Inc.
diff -Nru a/Documentation/usb/sn9c102.txt b/Documentation/usb/sn9c102.txt
--- a/Documentation/usb/sn9c102.txt	2004-12-24 13:37:18 -08:00
+++ b/Documentation/usb/sn9c102.txt	2004-12-24 13:37:18 -08:00
@@ -1,7 +1,7 @@
 
-                        SN9C10[12] PC Camera Controllers
+                         SN9C10x PC Camera Controllers
                                 Driver for Linux
-                        ================================
+                         =============================
 
                                - Documentation -
 
@@ -9,28 +9,32 @@
 Index
 =====
 1.  Copyright
-2.  License
-3.  Overview
-4.  Module dependencies
-5.  Module loading
-6.  Module parameters
-7.  Optional device control through "sysfs"
-8.  Supported devices
-9.  How to add support for new image sensors
-10. Notes for V4L2 application developers
-11. Contact information
-12. Credits
+2.  Disclaimer
+3.  License
+4.  Overview
+5.  Driver installation
+6.  Module loading
+7.  Module parameters
+8.  Optional device control through "sysfs"
+9.  Supported devices
+10. How to add support for new image sensors
+11. Notes for V4L2 application developers
+12. Contact information
+13. Credits
 
 
 1. Copyright
 ============
 Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>
 
+
+2. Disclaimer
+=============
 SONiX is a trademark of SONiX Technology Company Limited, inc.
-This driver is not sponsored or developed by SONiX.
+This software is not sponsored or developed by SONiX.
 
 
-2. License
+3. License
 ==========
 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
@@ -47,28 +51,52 @@
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 
-3. Overview
+4. Overview
 ===========
-This driver attempts to support the video streaming capabilities of the devices
-mounting the SONiX SN9C101 or SONiX SN9C102 PC Camera Controllers.
+This driver attempts to support the video and audio streaming capabilities of
+the devices mounting the SONiX SN9C101, SN9C102 and SN9C103 (or SUI-102) PC
+Camera Controllers.
 
-- It's worth to note that SONiX has never collaborated with me during the
-development of this project, despite of several requests for enough detailed
+It's worth to note that SONiX has never collaborated with the author during the
+development of this project, despite several requests for enough detailed
 specifications of the register tables, compression engine and video data format
-of the above chips -
-
-Up to 64 cameras can be handled at the same time. They can be connected and
-disconnected from the host many times without turning off the computer, if
-your system supports the hotplug facility.
+of the above chips.
 
 The driver relies on the Video4Linux2 and USB core modules. It has been
 designed to run properly on SMP systems as well.
 
-The latest version of the SN9C10[12] driver can be found at the following URL:
-http://go.lamarinapunto.com/
+The latest version of the SN9C10x driver can be found at the following URL:
+http://www.linux-projects.org/
+
+Some of the features of the driver are:
+
+- full compliance with the Video4Linux2 API (see also "Notes for V4L2
+  application developers" paragraph);
+- available mmap or read/poll methods for video streaming through isochronous
+  data transfers;
+- automatic detection of image sensor;
+- support for any window resolutions and optional panning within the maximum
+  pixel area of image sensor;
+- image downscaling with arbitrary scaling factors from 1, 2 and 4 in both
+  directions (see "Notes for V4L2 application developers" paragraph);
+- two different video formats for uncompressed or compressed data (see also
+  "Notes for V4L2 application developers" paragraph);
+- full support for the capabilities of many of the possible image sensors that
+  can be connected to the SN9C10x bridges, including, for istance, red, green,
+  blue and global gain adjustments and exposure (see "Supported devices"
+  paragraph for details);
+- use of default color settings for sunlight conditions;
+- dynamic I/O interface for both SN9C10x and image sensor control (see
+  "Optional device control through 'sysfs'" paragraph);
+- dynamic driver control thanks to various module parameters (see "Module
+  parameters" paragraph);
+- up to 64 cameras can be handled at the same time; they can be connected and
+  disconnected from the host many times without turning off the computer, if
+  your system supports hotplugging;
+- no known bugs.
 
 
-4. Module dependencies
+5. Module dependencies
 ======================
 For it to work properly, the driver needs kernel support for Video4Linux and
 USB.
@@ -100,7 +128,7 @@
 	CONFIG_USB_SN9C102=m
 
 
-5. Module loading
+6. Module loading
 =================
 To use the driver, it is necessary to load the "sn9c102" module into memory
 after every other module required: "videodev", "usbcore" and, depending on
@@ -108,7 +136,6 @@
 
 Loading can be done as shown below:
 
-	[root@localhost home]# modprobe usbcore
 	[root@localhost home]# modprobe sn9c102
 
 At this point the devices should be recognized. You can invoke "dmesg" to
@@ -117,17 +144,17 @@
 	[user@localhost home]$ dmesg
 
 
-6. Module parameters
+7. Module parameters
 ====================
 Module parameters are listed below:
 -------------------------------------------------------------------------------
 Name:           video_nr
-Type:           int array (min = 0, max = 32)
+Type:           int array (min = 0, max = 64)
 Syntax:         <-1|n[,...]> 
 Description:    Specify V4L2 minor mode number:
                 -1 = use next available
                  n = use minor number n
-                You can specify up to 32 cameras this way.
+                You can specify up to 64 cameras this way.
                 For example:
                 video_nr=-1,2,-1 would assign minor number 2 to the second
                 recognized camera and use auto for the first one and for every
@@ -143,24 +170,29 @@
                 2 = significant informations
                 3 = more verbose messages
                 Level 3 is useful for testing only, when only one device
-                is used.
+                is used. It also shows some more informations about the
+                hardware being detected. This parameter can be changed at
+                runtime thanks to the /sys filesystem.
 Default:        2
 -------------------------------------------------------------------------------
 
 
-7. Optional device control through "sysfs"
+8. Optional device control through "sysfs"
 ==========================================
-It is possible to read and write both the SN9C10[12] and the image sensor
+It is possible to read and write both the SN9C10x and the image sensor
 registers by using the "sysfs" filesystem interface.
 
-Every time a supported device is recognized, a read-only file named "green" is
+Every time a supported device is recognized, a write-only file named "green" is
 created in the /sys/class/video4linux/videoX directory. You can set the green
 channel's gain by writing the desired value to it. The value may range from 0
-to 15.
+to 15 for SN9C101 or SN9C102 bridges, from 0 to 127 for SN9C103 bridges.
+Similarly, only for SN9C103 controllers, blue and red gain control files are
+available in the same directory, for which accepted values may range from 0 to
+127.
 
 There are other four entries in the directory above for each registered camera:
 "reg", "val", "i2c_reg" and "i2c_val". The first two files control the
-SN9C10[12] bridge, while the other two control the sensor chip. "reg" and
+SN9C10x bridge, while the other two control the sensor chip. "reg" and
 "i2c_reg" hold the values of the current register index where the following
 reading/writing operations are addressed at through "val" and "i2c_val". Their
 use is not intended for end-users, unless you know what you are doing. Note
@@ -169,48 +201,77 @@
 root before writing to them.
 
 As an example, suppose we were to want to read the value contained in the
-register number 1 of the sensor register table - which usually is the product
+register number 1 of the sensor register table - which is usually the product
 identifier - of the camera registered as "/dev/video0":
 
 	[root@localhost #] cd /sys/class/video4linux/video0
 	[root@localhost #] echo 1 > i2c_reg
 	[root@localhost #] cat i2c_val
 
-Now let's set the green gain's register of the SN9C10[12] chip to 2:
+Note that "cat" will fail if sensor registers cannot be read.
+
+Now let's set the green gain's register of the SN9C101 or SN9C102 chips to 2:
 
 	[root@localhost #] echo 0x11 > reg
 	[root@localhost #] echo 2 > val
 
-Note that the SN9C10[12] always returns 0 when some of its registers are read.
+Note that the SN9C10x always returns 0 when some of its registers are read.
 To avoid race conditions, all the I/O accesses to the files are serialized.
 
 
-8. Supported devices
+9. Supported devices
 ====================
-- I won't mention any of the names of the companies as well as their products
-here. They have never collaborated with me, so no advertising -
+None of the names of the companies as well as their products will be mentioned
+here. They have never collaborated with the author, so no advertising.
 
 From the point of view of a driver, what unambiguously identify a device are
 its vendor and product USB identifiers. Below is a list of known identifiers of
-devices mounting the SN9C10[12] PC camera controllers:
+devices mounting the SN9C10x PC camera controllers:
 
 Vendor ID  Product ID
 ---------  ----------
-0xc45      0x6001
-0xc45      0x6005
-0xc45      0x6009
-0xc45      0x600d
-0xc45      0x6024
-0xc45      0x6025
-0xc45      0x6028
-0xc45      0x6029
-0xc45      0x602a
-0xc45      0x602c
-0xc45      0x6030
-
-The list above does NOT imply that all those devices work with this driver: up
-until now only the ones that mount the following image sensors are supported.
-Kernel messages will always tell you whether this is the case:
+0x0c45     0x6001
+0x0c45     0x6005
+0x0c45     0x6009
+0x0c45     0x600d
+0x0c45     0x6024
+0x0c45     0x6025
+0x0c45     0x6028
+0x0c45     0x6029
+0x0c45     0x602a
+0x0c45     0x602b
+0x0c45     0x602c
+0x0c45     0x6030
+0x0c45     0x6080
+0x0c45     0x6082
+0x0c45     0x6083
+0x0c45     0x6088
+0x0c45     0x608a
+0x0c45     0x608b
+0x0c45     0x608c
+0x0c45     0x608e
+0x0c45     0x608f
+0x0c45     0x60a0
+0x0c45     0x60a2
+0x0c45     0x60a3
+0x0c45     0x60a8
+0x0c45     0x60aa
+0x0c45     0x60ab
+0x0c45     0x60ac
+0x0c45     0x60ae
+0x0c45     0x60af
+0x0c45     0x60b0
+0x0c45     0x60b2
+0x0c45     0x60b3
+0x0c45     0x60b8
+0x0c45     0x60ba
+0x0c45     0x60bb
+0x0c45     0x60bc
+0x0c45     0x60be
+
+The list above does not imply that all those devices work with this driver: up
+until now only the ones that mount the following image sensors are supported;
+kernel messages will always tell you whether this is the case:
 
 Model       Manufacturer
 -----       ------------
@@ -219,30 +280,33 @@
 TAS5110C1B  Taiwan Advanced Sensor Corporation
 TAS5130D1B  Taiwan Advanced Sensor Corporation
 
+All the available control settings of each image sensor are supported through
+the V4L2 interface.
+
 If you think your camera is based on the above hardware and is not actually
 listed in the above table, you may try to add the specific USB VendorID and
 ProductID identifiers to the sn9c102_id_table[] in the file "sn9c102_sensor.h";
 then compile, load the module again and look at the kernel output.
-If this works, please send an email to me reporting the kernel messages, so
-that I will add a new entry in the list of supported devices.
+If this works, please send an email to the author reporting the kernel
+messages, so that a new entry in the list of supported devices can be added.
 
 Donations of new models for further testing and support would be much
-appreciated. I won't add official support for hardware that I don't actually
-have.
+appreciated. Non-available hardware won't be supported by the author of this
+driver.
 
 
-9. How to add support for new image sensors
-===========================================
+10. How to add support for new image sensors
+============================================
 It should be easy to write code for new sensors by using the small API that I
 have created for this purpose, which is present in "sn9c102_sensor.h"
 (documentation is included there). As an example, have a look at the code in
 "sn9c102_pas106b.c", which uses the mentioned interface.
 
-At the moment, not yet supported image sensors are: HV7131[D|E1] (VGA),
-MI03 (VGA), OV7620 (VGA).
+At the moment, possible unsupported image sensors are: HV7131x series (VGA),
+MI03x series (VGA), OV7620 (VGA), OV7630 (VGA), CIS-VF10 (VGA).
 
 
-10. Notes for V4L2 application developers
+11. Notes for V4L2 application developers
 =========================================
 This driver follows the V4L2 API specifications. In particular, it enforces two
 rules:
@@ -254,18 +318,29 @@
 - previously mapped buffer memory must always be unmapped before calling any
 of the "VIDIOC_S_CROP", "VIDIOC_TRY_FMT" and "VIDIOC_S_FMT" ioctl's. The same
 number of buffers as before will be allocated again to match the size of the
-new video frames, so you have to map them again before any I/O attempts.
+new video frames, so you have to map the buffers again before any I/O attempts
+on them.
 
 Consistently with the hardware limits, this driver also supports image
 downscaling with arbitrary scaling factors from 1, 2 and 4 in both directions.
-However the V4L2 API specifications don't correctly define how the scaling
-factor can be choosen arbitrarily by the "negotiation" of the "source" and
+However, the V4L2 API specifications don't correctly define how the scaling
+factor can be chosen arbitrarily by the "negotiation" of the "source" and
 "target" rectangles. To work around this flaw, we have added the convention
 that, during the negotiation, whenever the "VIDIOC_S_CROP" ioctl is issued, the
 scaling factor is restored to 1.
 
+This driver supports two different video formats: the first one is the "8-bit
+Sequential Bayer" format and can be used to obtain uncompressed video data
+from the device through the current I/O method, while the second one provides
+"raw" compressed video data (without the initial and final frame headers). The
+compression quality may vary from 0 to 1 and can be selected or queried thanks
+to the VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2 ioctl's. For maximum
+flexibility, the default active video format depends on how the image sensor
+being used is initialized (as described in the documentation of the API for the
+image sensors supplied by this driver).
+
 
-11. Contact information
+12. Contact information
 =======================
 I may be contacted by e-mail at <luca.risolia@studio.unibo.it>.
 
@@ -274,7 +349,7 @@
 is: '88E8 F32F 7244 68BA 3958  5D40 99DA 5D2A FCE6 35A4'.
 
 
-12. Credits
+13. Credits
 ===========
 I would thank the following persons:
 
diff -Nru a/Documentation/usb/usb-serial.txt b/Documentation/usb/usb-serial.txt
--- a/Documentation/usb/usb-serial.txt	2004-12-24 13:36:18 -08:00
+++ b/Documentation/usb/usb-serial.txt	2004-12-24 13:36:18 -08:00
@@ -211,6 +211,62 @@
   azummo@towertech.it
 
 
+Cypress M8 CY4601 Family Serial Driver
+
+  This driver was in most part developed by Neil "koyama" Whelchel.  It
+  has been improved since that previous form to support dynamic serial
+  line settings and improved line handling.  The driver is for the most
+  part stable and has been tested on an smp machine. (dual p2)
+
+    Chipsets supported under CY4601 family:
+	
+		CY7C63723, CY7C63742, CY7C63743, CY7C64013
+
+    Devices supported:
+
+		-DeLorme's USB Earthmate (SiRF Star II lp arch)
+		-Cypress HID->COM RS232 adapter
+	
+		Note: Cypress Semiconductor claims no affiliation with the
+			the hid->com device.
+
+	Most devices using chipsets under the CY4601 family should
+     work with the driver.  As long as they stay true to the CY4601
+     usbserial specification.
+
+    Technical notes:
+
+        The Earthmate starts out at 4800 8N1 by default... the driver will
+	upon start init to this setting.  usbserial core provides the rest
+	of the termios settings, along with some custom termios so that the
+	output is in proper format and parsable.
+	
+	The device can be put into sirf mode by issuing NMEA command:
+		$PSRF100,<protocol>,<baud>,<databits>,<stopbits>,<parity>*CHECKSUM
+		$PSRF100,0,9600,8,1,0*0C
+
+		It should then be sufficient to change the port termios to match this
+		to begin communicating.
+
+	As far as I can tell it supports pretty much every sirf command as
+	documented online available with firmware 2.31, with some unknown
+	message ids.
+
+	The hid->com adapter can run at a maximum baud of 115200bps.  Please note
+	that the device has trouble or is incapable of raising line voltage properly.
+	It will be fine with null modem links, as long as you do not try to link two
+	together without hacking the adapter to set the line high.
+
+	The driver is smp safe.  Performance with the driver is rather low when using
+	it for transfering files.  This is being worked on, but I would be willing to
+	accept patches.  An urb queue or packet buffer would likely fit the bill here.
+
+	If you have any questions, problems, patches, feature requests, etc. you can
+	contact me here via email:
+					dignome@gmail.com
+		(your problems/patches can alternately be submitted to usb-devel)
+
+
 Digi AccelePort Driver
 
   This driver supports the Digi AccelePort USB 2 and 4 devices, 2 port
diff -Nru a/Documentation/usb/w9968cf.txt b/Documentation/usb/w9968cf.txt
--- a/Documentation/usb/w9968cf.txt	2004-12-24 13:37:02 -08:00
+++ b/Documentation/usb/w9968cf.txt	2004-12-24 13:37:02 -08:00
@@ -8,26 +8,30 @@
 
 Index
 =====
-1. Copyright
-2. License
-3. Overview
-4. Supported devices
-5. Module dependencies
-6. Module loading
-7. Module paramaters
-8. Contact information
-9. Credits
+1.  Copyright
+2.  Disclaimer
+3.  License
+4.  Overview
+5.  Supported devices
+6.  Module dependencies
+7.  Module loading
+8.  Module paramaters
+9.  Contact information
+10. Credits
 
 
 1. Copyright
 ============
 Copyright (C) 2002-2004 by Luca Risolia <luca.risolia@studio.unibo.it>
 
+
+2. Disclaimer
+=============
 Winbond is a trademark of Winbond Electronics Corporation.
-This driver is not sponsored or developed by Winbond.
+This software is not sponsored or developed by Winbond.
 
 
-2. License
+3. License
 ==========
 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
@@ -44,7 +48,7 @@
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 
-3. Overview
+4. Overview
 ===========
 This driver supports the video streaming capabilities of the devices mounting
 Winbond W9967CF and Winbond W9968CF JPEG USB Dual Mode Camera Chips. OV681
@@ -57,7 +61,7 @@
 every time an application tries to open a recognized device, "w9968cf" checks
 the presence of the "w9968cf-vpp" module and loads it automatically by default.
 
-Please keep in mind that official kernels do NOT include the second module for
+Please keep in mind that official kernels do not include the second module for
 performance purposes. However it is always recommended to download and install
 the latest and complete release of the driver, replacing the existing one, if
 present: it will be still even possible not to load the "w9968cf-vpp" module at
@@ -65,7 +69,7 @@
 the official Linux 2.4 kernels is the writeable /proc filesystem interface.
 
 The latest and full-featured version of the W996[87]CF driver can be found at:
-http://go.lamarinapunto.com/ . Please refer to the documentation included in
+http://www.linux-projects.org. Please refer to the documentation included in
 that package, if you are going to use it.
 
 Up to 32 cameras can be handled at the same time. They can be connected and
@@ -83,7 +87,7 @@
 compiled with the automatic module loading option).
 
 
-4. Supported devices
+5. Supported devices
 ====================
 At the moment, known W996[87]CF and OV681 based devices are:
 - Aroma Digi Pen VGA Dual Mode ADG-5000 (unknown image sensor)
@@ -99,11 +103,9 @@
 
 If you know any other W996[87]CF or OV681 based cameras, please contact me.
 
-The list above does NOT imply that all those devices work with this driver: up
+The list above does not imply that all those devices work with this driver: up
 until now only webcams that have an image sensor supported by the "ovcamchip"
-module work. 
-For a list of supported image sensors, please visit the author's homepage on
-this module: http://alpha.dyndns.org/ov511/
+module work. Kernel messages will always tell you whether this is case.
 
 Possible external microcontrollers of those webcams are not supported: this
 means that still images cannot be downloaded from the device memory.
@@ -113,7 +115,7 @@
 additional testing and full support, would be much appreciated.
 
 
-5. Module dependencies
+6. Module dependencies
 ======================
 For it to work properly, the driver needs kernel support for Video4Linux, USB
 and I2C, and the "ovcamchip" module for the image sensor. Make sure you are not
@@ -157,7 +159,7 @@
 	CONFIG_USB_W9968CF=m
 
 
-6. Module loading
+7. Module loading
 =================
 To use the driver, it is necessary to load the "w9968cf" module into memory
 after every other module required.
@@ -166,6 +168,7 @@
 
 	[root@localhost home]# modprobe usbcore
 	[root@localhost home]# modprobe i2c-core
+	[root@localhost home]# modprobe videodev
 	[root@localhost home]# modprobe w9968cf
 
 At this point the pertinent devices should be recognized: "dmesg" can be used
@@ -181,7 +184,7 @@
 	[root@locahost home]# modinfo w9968cf
 
 
-7. Module parameters
+8. Module parameters
 ====================
 Module parameters are listed below:
 -------------------------------------------------------------------------------
@@ -452,7 +455,7 @@
 -------------------------------------------------------------------------------
 
 
-8. Contact information
+9. Contact information
 ======================
 I may be contacted by e-mail at <luca.risolia@studio.unibo.it>.
 
@@ -461,7 +464,7 @@
 is: '88E8 F32F 7244 68BA 3958  5D40 99DA 5D2A FCE6 35A4'.
 
 
-9. Credits
+10. Credits
 ==========
 The development would not have proceed much further without having looked at
 the source code of other drivers and without the help of several persons; in
diff -Nru a/Documentation/video4linux/meye.txt b/Documentation/video4linux/meye.txt
--- a/Documentation/video4linux/meye.txt	2004-12-24 13:37:04 -08:00
+++ b/Documentation/video4linux/meye.txt	2004-12-24 13:37:04 -08:00
@@ -1,12 +1,12 @@
 Vaio Picturebook Motion Eye Camera Driver Readme
 ------------------------------------------------
-	Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
+	Copyright (C) 2001-2004 Stelian Pop <stelian@popies.net>
 	Copyright (C) 2001-2002 Alcôve <www.alcove.com>
 	Copyright (C) 2000 Andrew Tridgell <tridge@samba.org>
 
 This driver enable the use of video4linux compatible applications with the
-Motion Eye camera. This driver requires the "Sony Vaio Programmable I/O 
-Control Device" driver (which can be found in the "Character drivers" 
+Motion Eye camera. This driver requires the "Sony Vaio Programmable I/O
+Control Device" driver (which can be found in the "Character drivers"
 section of the kernel configuration utility) to be compiled and installed
 (using its "camera=1" parameter).
 
@@ -24,7 +24,7 @@
 The first version was connected directly on the video bus of the Neomagic
 video card and is unsupported.
 
-The second one, made by Kawasaki Steel is fully supported by this 
+The second one, made by Kawasaki Steel is fully supported by this
 driver (PCI vendor/device is 0x136b/0xff01)
 
 The third one, present in recent (more or less last year) Picturebooks
@@ -41,13 +41,12 @@
 Driver options:
 ---------------
 
-Several options can be passed to the meye driver, either by adding them
-to /etc/modprobe.conf file, when the driver is compiled as a module, or
-by adding the following to the kernel command line (in your bootloader):
+Several options can be passed to the meye driver using the standard
+module argument syntax (<param>=<value> when passing the option to the
+module or meye.<param>=<value> on the kernel boot line when meye is
+statically linked into the kernel). Those options are:
 
-	meye=gbuffers[,gbufsize[,video_nr]]
-
-where:
+	forcev4l1:	force use of V4L1 API instead of V4L2
 
 	gbuffers:	number of capture buffers, default is 2 (32 max)
 
@@ -81,8 +80,9 @@
 Private API:
 ------------
 
-	The driver supports frame grabbing with the video4linux API, so
-	all video4linux tools (like xawtv) should work with this driver.
+	The driver supports frame grabbing with the video4linux API
+	(either v4l1 or v4l2), so all video4linux tools (like xawtv)
+	should work with this driver.
 
 	Besides the video4linux interface, the driver has a private interface
 	for accessing the Motion Eye extended parameters (camera sharpness,
@@ -116,7 +116,7 @@
 	MEYEIOC_STILLJCAPT
 		Takes a snapshot in an uncompressed or compressed jpeg format.
 		This ioctl blocks until the snapshot is done and returns (for
-		jpeg snapshot) the size of the image. The image data is 
+		jpeg snapshot) the size of the image. The image data is
 		available from the first mmap'ed buffer.
 
 	Look at the 'motioneye' application code for an actual example.
@@ -124,13 +124,7 @@
 Bugs / Todo:
 ------------
 
-	- overlay output is not supported (although the camera is capable of).
-	  	(it should not be too hard to to it, provided we found how...)
-		
-	- mjpeg hardware playback doesn't work (depends on overlay...)
-
-	- rewrite the driver to use some common video4linux API for snapshot
-	  and mjpeg capture. Unfortunately, video4linux1 does not permit it,
-	  the BUZ API seems to be targeted to TV cards only. The video4linux 2
-	  API may be an option, if it goes into the kernel (maybe 2.5 
-	  material ?).
+	- the driver could be much cleaned up by removing the v4l1 support.
+	  However, this means all v4l1-only applications will stop working.
+
+	- 'motioneye' still uses the meye private v4l1 API extensions.
diff -Nru a/Documentation/vm/overcommit-accounting b/Documentation/vm/overcommit-accounting
--- a/Documentation/vm/overcommit-accounting	2004-12-24 13:37:43 -08:00
+++ b/Documentation/vm/overcommit-accounting	2004-12-24 13:37:43 -08:00
@@ -22,6 +22,9 @@
 
 The overcommit percentage is set via `vm.overcommit_ratio'.
 
+The current overcommit limit and amount committed are viewable in
+/proc/meminfo as CommitLimit and Committed_AS respectively.
+
 Gotchas
 -------
 
diff -Nru a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
--- a/Documentation/x86_64/boot-options.txt	2004-12-24 13:37:30 -08:00
+++ b/Documentation/x86_64/boot-options.txt	2004-12-24 13:37:30 -08:00
@@ -87,22 +87,8 @@
 
   noexec=on|off
 
-  on      Enable
+  on      Enable(default)
   off     Disable
-  noforce (default) Don't enable by default for heap/stack/data,
-          but allow PROT_EXEC to be effective
-
-  noexec32=opt{,opt}
-
-  Control the no exec default for 32bit processes.
-  Requires noexec=on or noexec=noforce to be effective.
-
-  Valid options:
-     all,on    Heap,stack,data is non executable.
-     off       (default) Heap,stack,data is executable
-     stack     Stack is non executable, heap/data is.
-     force     Don't imply PROT_EXEC for PROT_READ
-     compat    (default) Imply PROT_EXEC for PROT_READ
 
 SMP
 
diff -Nru a/MAINTAINERS b/MAINTAINERS
--- a/MAINTAINERS	2004-12-24 13:37:00 -08:00
+++ b/MAINTAINERS	2004-12-24 13:37:00 -08:00
@@ -287,6 +287,12 @@
 M:	linux@treblig.org
 S:	Maintained
 
+ARM/PLEB SUPPORT
+P:	Peter Chubb
+M:	pleb@gelato.unsw.edu.au
+W:	http://www.disy.cse.unsw.edu.au/Hardware/PLEB
+S:	Maintained
+
 ARM/PT DIGITAL BOARD PORT
 P:	Stefan Eletzhofer
 M:	stefan.eletzhofer@eletztrick.de
@@ -531,10 +537,9 @@
 COMPUTONE INTELLIPORT MULTIPORT CARD
 P:	Michael H. Warfield
 M:	Michael H. Warfield <mhw@wittsend.com>
-W:	http://www.computone.com/
 W:	http://www.wittsend.com/computone.html
 L:	linux-computone@lazuli.wittsend.com
-S:	Supported
+S:	Orphaned
 
 COSA/SRP SYNC SERIAL DRIVER
 P:	Jan "Yenya" Kasprzak
@@ -559,8 +564,8 @@
 S:     Orphan
 
 CRIS PORT
-P:	Bjorn Wesen
-M:	bjornw@axis.com
+P:	Mikael Starvik
+M:	starvik@axis.com
 L:	dev-etrax@axis.com
 W:	http://developer.axis.com
 S:	Maintained
@@ -670,7 +675,7 @@
 M:	Eng.Linux@digi.com
 L:	Eng.Linux@digi.com
 W:	http://www.digi.com
-S:	Maintained
+S:	Orphaned
 
 DIGI RIGHTSWITCH NETWORK DRIVER
 P:	Rick Richardson
@@ -683,7 +688,7 @@
 M:	christoph@lameter.com
 W:	http://www.digi.com
 L:	digilnux@digi.com
-S:	Orphaned
+S:	Obsolete
 
 DIRECTORY NOTIFICATION
 P:	Stephen Rothwell
@@ -806,7 +811,7 @@
 
 EXT3 FILE SYSTEM
 P:	Stephen Tweedie, Andrew Morton
-M:	sct@redhat.com, akpm@digeo.com, adilger@clusterfs.com
+M:	sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com
 L:	ext3-users@redhat.com
 S:	Maintained
 
@@ -818,11 +823,11 @@
 S:	Supported
 
 FRAMEBUFFER LAYER
-P:	James Simmons, Geert Uytterhoeven	
-M:	jsimmons@infradead.org, geert@linux-m68k.org	
+P:	Antonino Daplas
+M:	adaplas@pol.net
 L:	linux-fbdev-devel@lists.sourceforge.net	
 W:	http://linux-fbdev.sourceforge.net/
-S:	Supported
+S:	Maintained
 
 FILE LOCKING (flock() and fcntl()/lockf())
 P:	Matthew Wilcox
@@ -832,7 +837,7 @@
 
 FILESYSTEMS (VFS and infrastructure)
 P:	Alexander Viro
-M:	viro@math.psu.edu
+M:	viro@parcelfarce.linux.theplanet.co.uk
 S:	Maintained
 
 FIRMWARE LOADER (request_firmware)
@@ -858,11 +863,9 @@
 S:	Maintained
 
 FTAPE/QIC-117
-P:	Claus-Justus Heine
-M:	claus@momo.math.rwth-aachen.de
 L:	linux-tape@vger.kernel.org
-W:	http://www-math.math.rwth-aachen.de/~LBFM/claus/ftape/
-S:	Maintained
+W:	http://sourceforge.net/projects/ftape
+S:	Orphan
 
 FUTURE DOMAIN TMC-16x0 SCSI DRIVER (16-bit)
 P:	Rik Faith
@@ -947,7 +950,7 @@
 
 HPUSBSCSI
 P:	Oliver Neukum
-M:	drivers@neukum.org
+M:	oliver@neukum.name
 S:	Maintained
 
 I2C AND SENSORS DRIVERS
@@ -1112,8 +1115,8 @@
 M:	john.ronciak@intel.com
 P:	Ganesh Venkatesan
 M:	ganesh.venkatesan@intel.com
-P:	Scott Feldman
-M:	scott.feldman@intel.com
+P:	Jesse Brandeburg
+M:	jesse.brandeburg@intel.com
 W:	http://sourceforge.net/projects/e1000/
 S:	Supported
 
@@ -1250,6 +1253,12 @@
 W:	http://www.cse.unsw.edu.au/~neilb/patches/linux-devel/
 S:	Maintained
 
+KERNEL EVENT LAYER (KOBJECT_UEVENT)
+P:	Robert Love
+M:	rml@novell.com
+L:	linux-kernel@vger.kernel.org
+S:	Maintained
+
 LANMEDIA WAN CARD DRIVER
 P:	Andrew Stanley-Jones
 M:	asj@lanmedia.com
@@ -1291,14 +1300,14 @@
 P:	Paul Mackerras
 M:	paulus@samba.org
 W:	http://www.penguinppc.org/
-L:	linuxppc-dev@lists.linuxppc.org
+L:	linuxppc-dev@ozlabs.org
 S:	Supported
 
 LINUX FOR POWER MACINTOSH
 P:	Benjamin Herrenschmidt
 M:	benh@kernel.crashing.org
 W:	http://www.penguinppc.org/
-L:	linuxppc-dev@lists.linuxppc.org
+L:	linuxppc-dev@ozlabs.org
 S:	Maintained
 
 LINUX FOR POWERPC EMBEDDED MPC52XX
@@ -1314,21 +1323,21 @@
 P:	Matt Porter
 M:	mporter@kernel.crashing.org
 W:	http://www.penguinppc.org/
-L:	linuxppc-embedded@lists.linuxppc.org
+L:	linuxppc-embedded@ozlabs.org
 S:	Maintained
 
 LINUX FOR POWERPC EMBEDDED PPC8XX AND BOOT CODE
 P:	Tom Rini
 M:	trini@kernel.crashing.org
 W:	http://www.penguinppc.org/
-L:	linuxppc-embedded@lists.linuxppc.org
+L:	linuxppc-embedded@ozlabs.org
 S:	Maintained
 
 LINUX FOR POWERPC EMBEDDED PPC85XX
 P:     Kumar Gala
 M:     kumar.gala@freescale.com
 W:     http://www.penguinppc.org/
-L:     linuxppc-embedded@lists.linuxppc.org
+L:     linuxppc-embedded@ozlabs.org
 S:     Maintained
 
 LLC (802.2)
@@ -1344,7 +1353,7 @@
 M:	anton@samba.org
 M:	anton@au.ibm.com
 W:	http://linuxppc64.org
-L:	linuxppc64-dev@lists.linuxppc.org
+L:	linuxppc64-dev@ozlabs.org
 S:	Supported
 
 LINUX SECURITY MODULE (LSM) FRAMEWORK
@@ -1437,7 +1446,7 @@
 
 MICROTEK X6 SCANNER
 P:	Oliver Neukum
-M:	drivers@neukum.org
+M:	oliver@neukum.name
 S:	Maintained
 
 MIPS
@@ -1448,11 +1457,8 @@
 S:	Maintained
 
 MISCELLANEOUS MCA-SUPPORT
-P:	David Weinehall
-M:	Project MCA Team <mcalinux@acc.umu.se>
-M:	David Weinehall <tao@acc.umu.se>
-W:	http://www.acc.umu.se/~tao/
-W:	http://www.acc.umu.se/~mcalinux/
+P:	James Bottomley
+M:	jejb@steeleye.com
 L:	linux-kernel@vger.kernel.org
 S:	Maintained
 
@@ -1529,7 +1535,7 @@
 
 NETWORK DEVICE DRIVERS
 P:	Andrew Morton
-M:	akpm@digeo.com
+M:	akpm@osdl.org
 P:	Jeff Garzik
 M:	jgarzik@pobox.com
 L:	linux-net@vger.kernel.org
@@ -1725,6 +1731,12 @@
 L:	linux-net@vger.kernel.org
 S:	Maintained
 
+PHRAM MTD DRIVER
+P:	Jörn Engel
+M:	joern@wh.fh-wedel.de
+L:	linux-mtd@lists.infradead.org
+S:	Maintained
+
 POSIX CLOCKS and TIMERS
 P:	George Anzinger
 M:	george@mvista.com
@@ -1760,6 +1772,13 @@
 W:	ftp://ftp.kernel.org/pub/linux/kernel/people/rml/preempt-kernel
 S:	Supported
 
+PRISM54 WIRELESS DRIVER
+P:	Prism54 Development Team
+M:	prism54-private@prism54.org
+L:	netdev@oss.sgi.com
+W:	http://prism54.org
+S:	Maintained
+
 PROMISE DC4030 CACHING DISK CONTROLLER DRIVER
 P:	Peter Denison
 M:	promise@pnd-pc.demon.co.uk
@@ -2206,8 +2225,8 @@
 S:	Maintained
 
 USB ACM DRIVER
-P:	Vojtech Pavlik
-M:	vojtech@suse.cz
+P:	Oliver Neukum
+M:	oliver@neukum.name
 L:	linux-usb-users@lists.sourceforge.net
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Maintained
@@ -2250,7 +2269,7 @@
 
 USB KAWASAKI LSI DRIVER
 P:	Oliver Neukum
-M:	drivers@neukum.org
+M:	oliver@neukum.name
 L:	linux-usb-users@lists.sourceforge.net
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Maintained
@@ -2332,6 +2351,15 @@
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Maintained
 
+USB SERIAL CYPRESS M8 DRIVER
+P:	Lonnie Mendez
+M:	dignome@gmail.com
+L:	linux-usb-users@lists.sourceforge.net
+L:	linux-usb-devel@lists.sourceforge.net
+S:	Maintained
+W:	http://geocities.com/i0xox0i
+W:	http://firstlight.net/cvs
+
 USB SERIAL CYBERJACK PINPAD/E-COM DRIVER
 L:	linux-usb-users@lists.sourceforge.net
 L:	linux-usb-devel@lists.sourceforge.net
@@ -2367,11 +2395,11 @@
 W:	http://www.connecttech.com
 S:	Supported
 
-USB SN9C10[12] DRIVER
+USB SN9C10x DRIVER
 P:	Luca Risolia
 M:	luca.risolia@studio.unibo.it
 L:	linux-usb-devel@lists.sourceforge.net
-W:	http://go.lamarinapunto.com
+W:	http://www.linux-projects.org
 S:	Maintained
 
 USB SUBSYSTEM
@@ -2399,7 +2427,7 @@
 P:	Luca Risolia
 M:	luca.risolia@studio.unibo.it
 L:	linux-usb-devel@lists.sourceforge.net
-W:	http://go.lamarinapunto.com
+W:	http://www.linux-projects.org
 S:	Maintained
 
 USER-MODE LINUX
@@ -2465,6 +2493,13 @@
 P:	Evgeniy Polyakov
 M:	johnpol@2ka.mipt.ru
 L:	sensors@stimpy.netroedge.com
+S:	Maintained
+
+W83L51xD SD/MMC CARD INTERFACE DRIVER
+P:	Pierre Ossman
+M:	drzeus-wbsd@drzeus.cx
+L:	wbsd-devel@list.drzeus.cx
+W:	http://projects.drzeus.cx/wbsd
 S:	Maintained
 
 W83L785TS HARDWARE MONITOR DRIVER
diff -Nru a/Makefile b/Makefile
--- a/Makefile	2004-12-24 13:37:01 -08:00
+++ b/Makefile	2004-12-24 13:37:01 -08:00
@@ -1,8 +1,8 @@
 VERSION = 2
 PATCHLEVEL = 6
-SUBLEVEL = 9
+SUBLEVEL = 10
 EXTRAVERSION =
-NAME=Zonked Quokka
+NAME=Woozy Numbat
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
@@ -156,8 +156,8 @@
 endif
 
 LOCALVERSION = $(subst $(space),, \
-	       $(shell cat /dev/null $(localversion-files)) \
-	       $(subst ",,$(CONFIG_LOCALVERSION)))
+	       $(shell cat /dev/null $(localversion-files:%~=)) \
+	       $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(LOCALVERSION)
 
@@ -295,6 +295,11 @@
 cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
                 > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
 
+# cc-option-align
+# Prefix align with either -falign or -malign
+cc-option-align = $(subst -functions=0,,\
+	$(call cc-option,-falign-functions=0,-malign-functions=0))
+
 # cc-version
 # Usage gcc-ver := $(call cc-version $(CC))
 cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
@@ -379,6 +384,18 @@
 scripts_basic:
 	$(Q)$(MAKE) $(build)=scripts/basic
 
+.PHONY: outputmakefile
+# outputmakefile generate a Makefile to be placed in output directory, if
+# using a seperate output directory. This allows convinient use
+# of make in output directory
+outputmakefile:
+	$(Q)if /usr/bin/env test ! $(srctree) -ef $(objtree); then \
+	$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile              \
+	    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)         \
+	    > $(objtree)/Makefile;                                 \
+	    echo '  GEN    $(objtree)/Makefile';                   \
+	fi
+
 # To make sure we do not include .config for any of the *config targets
 # catch them early, and hand them over to scripts/kconfig/Makefile
 # It is allowed to specify more targets when calling make, including
@@ -423,9 +440,15 @@
 # *config targets only - make sure prerequisites are updated, and descend
 # in scripts/kconfig to make the *config target
 
-config: scripts_basic FORCE
+# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
+# KBUILD_DEFCONFIG may point out an alternative default configuration
+# used for 'make defconfig'
+include $(srctree)/arch/$(ARCH)/Makefile
+export KBUILD_DEFCONFIG
+
+config: scripts_basic outputmakefile FORCE
 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
-%config: scripts_basic FORCE
+%config: scripts_basic outputmakefile FORCE
 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
 
 else
@@ -486,7 +509,16 @@
 CFLAGS		+= -O2
 endif
 
-ifndef CONFIG_FRAME_POINTER
+#Add align options if CONFIG_CC_* is not equal to 0
+add-align = $(if $(filter-out 0,$($(1))),$(cc-option-align)$(2)=$($(1)))
+CFLAGS		+= $(call add-align,CONFIG_CC_ALIGN_FUNCTIONS,-functions)
+CFLAGS		+= $(call add-align,CONFIG_CC_ALIGN_LABELS,-labels)
+CFLAGS		+= $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops)
+CFLAGS		+= $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps)
+
+ifdef CONFIG_FRAME_POINTER
+CFLAGS		+= -fno-omit-frame-pointer
+else
 CFLAGS		+= -fomit-frame-pointer
 endif
 
@@ -494,11 +526,11 @@
 CFLAGS		+= -g
 endif
 
+include $(srctree)/arch/$(ARCH)/Makefile
+
 # warn about C99 declaration after statement
 CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
 
-include $(srctree)/arch/$(ARCH)/Makefile
-
 # Default kernel image to build when no specific target is given.
 # KBUILD_IMAGE may be overruled on the commandline or
 # set in the environment
@@ -711,22 +743,12 @@
 
 .PHONY: prepare-all prepare prepare0 prepare1 prepare2
 
-# prepare 2 generate Makefile to be placed in output directory, if
-# using a seperate output directory. This allows convinient use
-# of make in output directory
-prepare2:
-	$(Q)if /usr/bin/env test ! $(srctree) -ef $(objtree); then \
-	$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile              \
-	    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)         \
-	    > $(objtree)/Makefile;                                 \
-	fi
-
-# prepare1 is used to check if we are building in a separate output directory,
+# prepare2 is used to check if we are building in a separate output directory,
 # and if so do:
 # 1) Check that make has not been executed in the kernel src $(srctree)
 # 2) Create the include2 directory, used for the second asm symlink
 
-prepare1: prepare2
+prepare2:
 ifneq ($(KBUILD_SRC),)
 	@echo '  Using $(srctree) as source for kernel'
 	$(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \
@@ -737,6 +759,9 @@
 	$(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
 	$(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
 endif
+
+# prepare1 creates a makefile if using a separate output directory
+prepare1: prepare2 outputmakefile
 
 prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
 ifneq ($(KBUILD_MODULES),)
diff -Nru a/arch/alpha/Makefile b/arch/alpha/Makefile
--- a/arch/alpha/Makefile	2004-12-24 13:37:00 -08:00
+++ b/arch/alpha/Makefile	2004-12-24 13:37:00 -08:00
@@ -11,7 +11,7 @@
 NM := $(NM) -B
 
 LDFLAGS_vmlinux	:= -static -N #-relax
-CHECKFLAGS	+= -D__alpha__
+CHECKFLAGS	+= -D__alpha__ -m64
 cflags-y	:= -pipe -mno-fp-regs -ffixed-8
 
 # Determine if we can use the BWX instructions with GAS.
diff -Nru a/arch/alpha/boot/bootloader.lds b/arch/alpha/boot/bootloader.lds
--- a/arch/alpha/boot/bootloader.lds	2004-12-24 13:37:18 -08:00
+++ b/arch/alpha/boot/bootloader.lds	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,6 @@
 OUTPUT_FORMAT("elf64-alpha")
 ENTRY(__start)
+printk = srm_printk;
 SECTIONS
 {
   . = 0x20000000;
diff -Nru a/arch/alpha/boot/bootp.c b/arch/alpha/boot/bootp.c
--- a/arch/alpha/boot/bootp.c	2004-12-24 13:37:19 -08:00
+++ b/arch/alpha/boot/bootp.c	2004-12-24 13:37:19 -08:00
@@ -26,6 +26,8 @@
 	struct pcb_struct * pcb_va, struct pcb_struct * pcb_pa,
 	unsigned long *vptb);
 
+extern void move_stack(unsigned long new_stack);
+
 struct hwrpb_struct *hwrpb = INIT_HWRPB;
 static struct pcb_struct pcb_va[1];
 
@@ -118,12 +120,10 @@
 runkernel(void)
 {
 	__asm__ __volatile__(
-		"bis %1,%1,$30\n\t"
 		"bis %0,%0,$27\n\t"
 		"jmp ($27)"
 		: /* no outputs: it doesn't even return */
-		: "r" (START_ADDR),
-		  "r" (PAGE_SIZE + INIT_STACK));
+		: "r" (START_ADDR));
 }
 
 extern char _end;
@@ -147,9 +147,7 @@
 	 */
 	static long nbytes;
 	static char envval[256] __attribute__((aligned(8)));
-#ifdef INITRD_IMAGE_SIZE
 	static unsigned long initrd_start;
-#endif
 
 	srm_printk("Linux/AXP bootp loader for Linux " UTS_RELEASE "\n");
 	if (INIT_HWRPB->pagesize != 8192) {
@@ -164,12 +162,19 @@
 	}
 	pal_init();
 
-#ifdef INITRD_IMAGE_SIZE
 	/* The initrd must be page-aligned.  See below for the 
 	   cause of the magic number 5.  */
-	initrd_start = ((START_ADDR + 5*KERNEL_SIZE) | (PAGE_SIZE-1)) + 1;
+	initrd_start = ((START_ADDR + 5*KERNEL_SIZE + PAGE_SIZE) |
+			(PAGE_SIZE-1)) + 1;
+#ifdef INITRD_IMAGE_SIZE
 	srm_printk("Initrd positioned at %#lx\n", initrd_start);
 #endif
+
+	/*
+	 * Move the stack to a safe place to ensure it won't be
+	 * overwritten by kernel image.
+	 */
+	move_stack(initrd_start - PAGE_SIZE);
 
 	nbytes = callback_getenv(ENV_BOOTED_OSFLAGS, envval, sizeof(envval));
 	if (nbytes < 0 || nbytes >= sizeof(envval)) {
diff -Nru a/arch/alpha/boot/bootpz.c b/arch/alpha/boot/bootpz.c
--- a/arch/alpha/boot/bootpz.c	2004-12-24 13:36:17 -08:00
+++ b/arch/alpha/boot/bootpz.c	2004-12-24 13:36:17 -08:00
@@ -41,9 +41,6 @@
 #undef DEBUG_ADDRESSES
 #undef DEBUG_LAST_STEPS
 
-#define DEBUG_SP(x) \
-    {register long sp asm("30"); srm_printk("%s (sp=%lx)\n", x, sp);}
-
 extern unsigned long switch_to_osf_pal(unsigned long nr,
 	struct pcb_struct * pcb_va, struct pcb_struct * pcb_pa,
 	unsigned long *vptb);
@@ -51,6 +48,8 @@
 extern int decompress_kernel(void* destination, void *source,
 			     size_t ksize, size_t kzsize);
 
+extern void move_stack(unsigned long new_stack);
+
 struct hwrpb_struct *hwrpb = INIT_HWRPB;
 static struct pcb_struct pcb_va[1];
 
@@ -163,12 +162,10 @@
 runkernel(void)
 {
 	__asm__ __volatile__(
-		"bis %1,%1,$30\n\t"
 		"bis %0,%0,$27\n\t"
 		"jmp ($27)"
 		: /* no outputs: it doesn't even return */
-		: "r" (START_ADDR),
-		  "r" (PAGE_SIZE + INIT_STACK));
+		: "r" (START_ADDR));
 }
 
 /* Must record the SP (it is virtual) on entry, so we can make sure
@@ -253,7 +250,9 @@
    for "bootmem" anyway.
 */
 #define K_COPY_IMAGE_START	NEXT_PAGE(K_KERNEL_IMAGE_END)
-#define K_INITRD_START		NEXT_PAGE(K_COPY_IMAGE_START + KERNEL_SIZE)
+/* Reserve one page below INITRD for the new stack. */
+#define K_INITRD_START \
+    NEXT_PAGE(K_COPY_IMAGE_START + KERNEL_SIZE + PAGE_SIZE)
 #define K_COPY_IMAGE_END \
     (K_INITRD_START + REAL_INITRD_SIZE + MALLOC_AREA_SIZE)
 #define K_COPY_IMAGE_SIZE \
@@ -419,8 +418,7 @@
 		   initrd_image_start,
 		   INITRD_IMAGE_SIZE);
 #endif
-	memcpy((void *)initrd_image_start,
-	       (void *)V_INITRD_START,
+	memcpy((void *)initrd_image_start, (void *)V_INITRD_START,
 	       INITRD_IMAGE_SIZE);
 
 #endif /* INITRD_IMAGE_SIZE */
@@ -436,9 +434,14 @@
 			   K_KERNEL_IMAGE_START,
 			   (unsigned)KERNEL_SIZE);
 #endif
+		/*
+		 * Move the stack to a safe place to ensure it won't be
+		 * overwritten by kernel image.
+		 */
+		move_stack(initrd_image_start - PAGE_SIZE);
+
 		memcpy((void *)K_KERNEL_IMAGE_START,
-		       (void *)uncompressed_image_start,
-		       KERNEL_SIZE);
+		       (void *)uncompressed_image_start, KERNEL_SIZE);
 	}
 	
 	/* Clear the zero page, then move the argument list in. */
diff -Nru a/arch/alpha/boot/head.S b/arch/alpha/boot/head.S
--- a/arch/alpha/boot/head.S	2004-12-24 13:37:19 -08:00
+++ b/arch/alpha/boot/head.S	2004-12-24 13:37:19 -08:00
@@ -100,3 +100,24 @@
 	.prologue 0
 	call_pal PAL_halt
 	.end halt
+
+/* $16 - new stack page */
+	.align 3
+	.globl	move_stack
+	.ent	move_stack
+move_stack:
+	.prologue 0
+	lda	$0, 0x1fff($31)
+	and	$0, $30, $1			/* Stack offset */
+	or	$1, $16, $16			/* New stack pointer */
+	mov	$30, $1
+	mov	$16, $2
+1:	ldq	$3, 0($1)			/* Move the stack */
+	addq	$1, 8, $1
+	stq	$3, 0($2)
+	and	$0, $1, $4
+	addq	$2, 8, $2
+	bne	$4, 1b
+	mov	$16, $30
+	ret	($26)
+	.end move_stack
diff -Nru a/arch/alpha/boot/misc.c b/arch/alpha/boot/misc.c
--- a/arch/alpha/boot/misc.c	2004-12-24 13:36:48 -08:00
+++ b/arch/alpha/boot/misc.c	2004-12-24 13:36:48 -08:00
@@ -205,15 +205,3 @@
 /*	puts(" done, booting the kernel.\n"); */
 	return output_ptr;
 }
-
-/* dummy-up printk */
-asmlinkage int printk(const char *fmt, ...)
-{
-        va_list args;
-	long ret;
-
-        va_start(args, fmt);
-        ret = srm_printk(fmt, args);
-        va_end(args);
-	return ret;
-}
diff -Nru a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c
--- a/arch/alpha/kernel/alpha_ksyms.c	2004-12-24 13:36:18 -08:00
+++ b/arch/alpha/kernel/alpha_ksyms.c	2004-12-24 13:36:18 -08:00
@@ -185,7 +185,7 @@
 EXPORT_SYMBOL(smp_num_cpus);
 EXPORT_SYMBOL(smp_call_function);
 EXPORT_SYMBOL(smp_call_function_on_cpu);
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
 #ifdef CONFIG_DEBUG_SPINLOCK
 EXPORT_SYMBOL(_raw_spin_unlock);
 EXPORT_SYMBOL(debug_spin_lock);
diff -Nru a/arch/alpha/kernel/console.c b/arch/alpha/kernel/console.c
--- a/arch/alpha/kernel/console.c	2004-12-24 13:37:33 -08:00
+++ b/arch/alpha/kernel/console.c	2004-12-24 13:37:33 -08:00
@@ -47,7 +47,7 @@
 
 	if (!sel_func) sel_func = (void *)default_vga_hose_select;
 
-	for(dev=NULL; (dev=pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, dev));) {
+	for(dev=NULL; (dev=pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, dev));) {
 		if (!hose) hose = dev->sysdata;
 		else hose = sel_func(hose, dev->sysdata);
 	}
diff -Nru a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c
--- a/arch/alpha/kernel/irq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/alpha/kernel/irq.c	2004-12-24 13:37:18 -08:00
@@ -26,10 +26,10 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/profile.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 /*
diff -Nru a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
--- a/arch/alpha/kernel/pci.c	2004-12-24 13:36:17 -08:00
+++ b/arch/alpha/kernel/pci.c	2004-12-24 13:36:17 -08:00
@@ -227,7 +227,7 @@
 	tmp->next = srm_saved_configs;
 	tmp->dev = dev;
 
-	pci_save_state(dev, tmp->regs);
+	pci_save_state(dev);
 
 	srm_saved_configs = tmp;
 }
@@ -243,7 +243,7 @@
 
 	/* Restore SRM config. */
 	for (tmp = srm_saved_configs; tmp; tmp = tmp->next) {
-		pci_restore_state(tmp->dev, tmp->regs);
+		pci_restore_state(tmp->dev);
 	}
 }
 #endif
@@ -280,7 +280,6 @@
 	/* Propagate hose info into the subordinate devices.  */
 
 	struct pci_controller *hose = bus->sysdata;
-	struct list_head *ln;
 	struct pci_dev *dev = bus->self;
 
 	if (!dev) {
@@ -304,9 +303,7 @@
  		pcibios_fixup_device_resources(dev, bus);
 	} 
 
-	for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
-		struct pci_dev *dev = pci_dev_b(ln);
-
+	list_for_each_entry(dev, &bus->devices, bus_list) {
 		pdev_save_srm_config(dev);
 		if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
 			pcibios_fixup_device_resources(dev, bus);
@@ -403,11 +400,10 @@
 static void __init
 pcibios_claim_one_bus(struct pci_bus *b)
 {
-	struct list_head *ld;
+	struct pci_dev *dev;
 	struct pci_bus *child_bus;
 
-	for (ld = b->devices.next; ld != &b->devices; ld = ld->next) {
-		struct pci_dev *dev = pci_dev_b(ld);
+	list_for_each_entry(dev, &b->devices, bus_list) {
 		int i;
 
 		for (i = 0; i < PCI_NUM_RESOURCES; i++) {
@@ -426,12 +422,10 @@
 static void __init
 pcibios_claim_console_setup(void)
 {
-	struct list_head *lb;
+	struct pci_bus *b;
 
-	for(lb = pci_root_buses.next; lb != &pci_root_buses; lb = lb->next) {
-		struct pci_bus *b = pci_bus_b(lb);
+	list_for_each_entry(b, &pci_root_buses, node)
 		pcibios_claim_one_bus(b);
-	}
 }
 
 void __init
diff -Nru a/arch/alpha/kernel/pci_impl.h b/arch/alpha/kernel/pci_impl.h
--- a/arch/alpha/kernel/pci_impl.h	2004-12-24 13:37:19 -08:00
+++ b/arch/alpha/kernel/pci_impl.h	2004-12-24 13:37:19 -08:00
@@ -166,7 +166,6 @@
 {
 	struct pdev_srm_saved_conf *next;
 	struct pci_dev *dev;
-	u32 regs[16];
 };
 
 extern void pci_restore_srm_config(void);
diff -Nru a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c
--- a/arch/alpha/kernel/ptrace.c	2004-12-24 13:37:19 -08:00
+++ b/arch/alpha/kernel/ptrace.c	2004-12-24 13:37:19 -08:00
@@ -355,7 +355,7 @@
 	 */
 	case PTRACE_KILL:
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)
+		if (child->exit_state == EXIT_ZOMBIE)
 			break;
 		child->exit_code = SIGKILL;
 		/* make sure single-step breakpoint is gone. */
diff -Nru a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c
--- a/arch/alpha/kernel/signal.c	2004-12-24 13:36:49 -08:00
+++ b/arch/alpha/kernel/signal.c	2004-12-24 13:36:49 -08:00
@@ -19,8 +19,8 @@
 #include <linux/stddef.h>
 #include <linux/tty.h>
 #include <linux/binfmts.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/sigcontext.h>
 #include <asm/ucontext.h>
diff -Nru a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
--- a/arch/alpha/kernel/smp.c	2004-12-24 13:36:31 -08:00
+++ b/arch/alpha/kernel/smp.c	2004-12-24 13:36:31 -08:00
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/cache.h>
 #include <linux/profile.h>
+#include <linux/bitops.h>
 
 #include <asm/hwrpb.h>
 #include <asm/ptrace.h>
@@ -33,7 +34,6 @@
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/mmu_context.h>
diff -Nru a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
--- a/arch/alpha/kernel/srmcons.c	2004-12-24 13:37:19 -08:00
+++ b/arch/alpha/kernel/srmcons.c	2004-12-24 13:37:19 -08:00
@@ -132,39 +132,10 @@
 }
 
 static int
-srmcons_write(struct tty_struct *tty, int from_user,
+srmcons_write(struct tty_struct *tty,
 	      const unsigned char *buf, int count)
 {
 	unsigned long flags;
-
-	if (from_user) {
-		char tmp[512];
-		int ret = 0;
-		size_t c;
-
-		while ((c = count) > 0) {
-			if (c > sizeof(tmp))
-				c = sizeof(tmp);
-			
-			c -= copy_from_user(tmp, (const char __user *) buf, c);
-
-			if (!c) { 
-				printk("%s: EFAULT (count %d)\n",
-				       __FUNCTION__, count);
-				return -EFAULT;
-			}
-
-			spin_lock_irqsave(&srmcons_callback_lock, flags);
-			srmcons_do_write(tty, tmp, c);
-			spin_unlock_irqrestore(&srmcons_callback_lock, flags);
-
-			buf += c;
-			count -= c;
-			ret += c;
-		}
-
-		return ret;
-	}
 
 	spin_lock_irqsave(&srmcons_callback_lock, flags);
 	srmcons_do_write(tty, (const char *) buf, count);
diff -Nru a/arch/alpha/kernel/sys_alcor.c b/arch/alpha/kernel/sys_alcor.c
--- a/arch/alpha/kernel/sys_alcor.c	2004-12-24 13:37:29 -08:00
+++ b/arch/alpha/kernel/sys_alcor.c	2004-12-24 13:37:29 -08:00
@@ -16,12 +16,12 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/reboot.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/dma.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/irq.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_cabriolet.c b/arch/alpha/kernel/sys_cabriolet.c
--- a/arch/alpha/kernel/sys_cabriolet.c	2004-12-24 13:36:31 -08:00
+++ b/arch/alpha/kernel/sys_cabriolet.c	2004-12-24 13:36:31 -08:00
@@ -16,12 +16,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_dp264.c b/arch/alpha/kernel/sys_dp264.c
--- a/arch/alpha/kernel/sys_dp264.c	2004-12-24 13:36:19 -08:00
+++ b/arch/alpha/kernel/sys_dp264.c	2004-12-24 13:36:19 -08:00
@@ -19,12 +19,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_eb64p.c b/arch/alpha/kernel/sys_eb64p.c
--- a/arch/alpha/kernel/sys_eb64p.c	2004-12-24 13:37:43 -08:00
+++ b/arch/alpha/kernel/sys_eb64p.c	2004-12-24 13:37:43 -08:00
@@ -15,12 +15,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_eiger.c b/arch/alpha/kernel/sys_eiger.c
--- a/arch/alpha/kernel/sys_eiger.c	2004-12-24 13:36:18 -08:00
+++ b/arch/alpha/kernel/sys_eiger.c	2004-12-24 13:36:18 -08:00
@@ -15,12 +15,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pci.h>
diff -Nru a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c
--- a/arch/alpha/kernel/sys_marvel.c	2004-12-24 13:37:18 -08:00
+++ b/arch/alpha/kernel/sys_marvel.c	2004-12-24 13:37:18 -08:00
@@ -10,12 +10,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_mikasa.c b/arch/alpha/kernel/sys_mikasa.c
--- a/arch/alpha/kernel/sys_mikasa.c	2004-12-24 13:37:04 -08:00
+++ b/arch/alpha/kernel/sys_mikasa.c	2004-12-24 13:37:04 -08:00
@@ -15,12 +15,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
--- a/arch/alpha/kernel/sys_nautilus.c	2004-12-24 13:36:47 -08:00
+++ b/arch/alpha/kernel/sys_nautilus.c	2004-12-24 13:36:47 -08:00
@@ -32,12 +32,12 @@
 #include <linux/init.h>
 #include <linux/reboot.h>
 #include <linux/bootmem.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pci.h>
diff -Nru a/arch/alpha/kernel/sys_noritake.c b/arch/alpha/kernel/sys_noritake.c
--- a/arch/alpha/kernel/sys_noritake.c	2004-12-24 13:36:31 -08:00
+++ b/arch/alpha/kernel/sys_noritake.c	2004-12-24 13:36:31 -08:00
@@ -16,12 +16,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_rx164.c b/arch/alpha/kernel/sys_rx164.c
--- a/arch/alpha/kernel/sys_rx164.c	2004-12-24 13:36:16 -08:00
+++ b/arch/alpha/kernel/sys_rx164.c	2004-12-24 13:36:16 -08:00
@@ -14,12 +14,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_sx164.c b/arch/alpha/kernel/sys_sx164.c
--- a/arch/alpha/kernel/sys_sx164.c	2004-12-24 13:36:48 -08:00
+++ b/arch/alpha/kernel/sys_sx164.c	2004-12-24 13:36:48 -08:00
@@ -14,12 +14,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_titan.c b/arch/alpha/kernel/sys_titan.c
--- a/arch/alpha/kernel/sys_titan.c	2004-12-24 13:37:19 -08:00
+++ b/arch/alpha/kernel/sys_titan.c	2004-12-24 13:37:19 -08:00
@@ -19,12 +19,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/sys_wildfire.c b/arch/alpha/kernel/sys_wildfire.c
--- a/arch/alpha/kernel/sys_wildfire.c	2004-12-24 13:36:48 -08:00
+++ b/arch/alpha/kernel/sys_wildfire.c	2004-12-24 13:36:48 -08:00
@@ -12,12 +12,12 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
--- a/arch/alpha/kernel/time.c	2004-12-24 13:36:55 -08:00
+++ b/arch/alpha/kernel/time.c	2004-12-24 13:36:55 -08:00
@@ -138,6 +138,9 @@
 
 	while (nticks > 0) {
 		do_timer(regs);
+#ifndef CONFIG_SMP
+		update_process_times(user_mode(regs));
+#endif
 		nticks--;
 	}
 
diff -Nru a/arch/alpha/lib/csum_partial_copy.c b/arch/alpha/lib/csum_partial_copy.c
--- a/arch/alpha/lib/csum_partial_copy.c	2004-12-24 13:36:49 -08:00
+++ b/arch/alpha/lib/csum_partial_copy.c	2004-12-24 13:36:49 -08:00
@@ -251,7 +251,8 @@
  * look at this too closely, you'll go blind.
  */
 static inline unsigned long
-csum_partial_cfu_unaligned(const unsigned long * src, unsigned long * dst,
+csum_partial_cfu_unaligned(const unsigned long __user * src,
+			   unsigned long * dst,
 			   unsigned long soff, unsigned long doff,
 			   long len, unsigned long checksum,
 			   unsigned long partial_dest,
@@ -383,7 +384,8 @@
 }
 
 unsigned int
-csum_partial_copy_nocheck(const char *src, char *dst, int len, unsigned int sum)
+csum_partial_copy_nocheck(const char __user *src, char *dst, int len,
+			  unsigned int sum)
 {
 	return do_csum_partial_copy_from_user(src, dst, len, sum, NULL);
 }
diff -Nru a/arch/alpha/lib/dec_and_lock.c b/arch/alpha/lib/dec_and_lock.c
--- a/arch/alpha/lib/dec_and_lock.c	2004-12-24 13:36:31 -08:00
+++ b/arch/alpha/lib/dec_and_lock.c	2004-12-24 13:36:31 -08:00
@@ -9,10 +9,10 @@
 #include <asm/atomic.h>
 
   asm (".text					\n\
-	.global atomic_dec_and_lock		\n\
-	.ent atomic_dec_and_lock		\n\
+	.global _atomic_dec_and_lock		\n\
+	.ent _atomic_dec_and_lock		\n\
 	.align	4				\n\
-atomic_dec_and_lock:				\n\
+_atomic_dec_and_lock:				\n\
 	.prologue 0				\n\
 1:	ldl_l	$1, 0($16)			\n\
 	subl	$1, 1, $1			\n\
@@ -28,7 +28,7 @@
 	.subsection 2				\n\
 4:	br	1b				\n\
 	.previous				\n\
-	.end atomic_dec_and_lock");
+	.end _atomic_dec_and_lock");
 
 static int __attribute_used__
 atomic_dec_and_lock_1(atomic_t *atomic, spinlock_t *lock)
diff -Nru a/arch/arm/Kconfig b/arch/arm/Kconfig
--- a/arch/arm/Kconfig	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/Kconfig	2004-12-24 13:36:55 -08:00
@@ -83,6 +83,8 @@
 
 config ARCH_CO285
 	bool "Co-EBSA285"
+	select FOOTBRIDGE
+	select FOOTBRIDGE_ADDIN
 
 config ARCH_EBSA110
 	bool "EBSA-110"
@@ -101,6 +103,7 @@
 
 config ARCH_FOOTBRIDGE
 	bool "FootBridge"
+	select FOOTBRIDGE
 
 config ARCH_INTEGRATOR
 	bool "Integrator"
@@ -159,10 +162,10 @@
 config ARCH_OMAP
 	bool "TI OMAP"
 
-config ARCH_VERSATILE_PB
-	bool "Versatile PB"
+config ARCH_VERSATILE
+	bool "Versatile"
 	help
-	  This enables support for ARM Ltd Versatile PB board.
+	  This enables support for ARM Ltd Versatile board.
 
 config ARCH_IMX
 	bool "IMX"
@@ -202,6 +205,8 @@
 
 source "arch/arm/mach-h720x/Kconfig"
 
+source "arch/arm/mach-versatile/Kconfig"
+
 # Definitions to make life easier
 config ARCH_ACORN
 	bool
@@ -214,28 +219,6 @@
 	default y
 
 #####################################################################
-# Footbridge support
-config FOOTBRIDGE
-	bool
-	depends on ARCH_CO285 || ARCH_FOOTBRIDGE
-	default y
-
-config FOOTBRIDGE_HOST
-	bool
-	depends on ARCH_CATS || ARCH_EBSA285_HOST || ARCH_NETWINDER || ARCH_PERSONAL_SERVER
-	default y
-
-config FOOTBRIDGE_ADDIN
-	bool
-	depends on ARCH_CO285 || ARCH_EBSA285_ADDIN
-	default y
-
-config ARCH_EBSA285
-	bool
-	depends on ARCH_EBSA285_HOST || ARCH_EBSA285_ADDIN
-	default y
-
-#####################################################################
 # SA1111 support
 config SA1111
 	bool
@@ -306,9 +289,14 @@
 	depends on ARCH_INTEGRATOR
 	default y
 
+config ICST307
+	bool
+	depends on ARCH_VERSATILE
+	default y
+
 config ARM_AMBA
 	bool
-	depends on ARCH_INTEGRATOR || ARCH_VERSATILE_PB
+	depends on ARCH_INTEGRATOR || ARCH_VERSATILE
 	default y
 
 config ISA
@@ -329,58 +317,98 @@
 
 config FIQ
 	bool
-	depends on ARCH_ACORN || ARCH_L7200 || ARCH_LH7A400
+	depends on ARCH_ACORN || ARCH_L7200
 	default y
 
 # Compressed boot loader in ROM.  Yes, we really want to ask about
 # TEXT and BSS so we preserve their values in the config files.
-config ZBOOT_ROM
-	bool "Compressed boot loader in ROM/flash"
-	help
-	  Say Y here if you intend to execute your compressed kernel image (zImage)
-	  directly from ROM or flash.  If unsure, say N.
-
 config ZBOOT_ROM_TEXT
 	hex "Compressed ROM boot loader base address"
 	default "0"
 	help
-	  The base address for zImage.  Unless you have special requirements, you
-	  should not change this value.
+	  The physical address at which the ROM-able zImage is to be
+	  placed in the target.  Platforms which normally make use of
+	  ROM-able zImage formats normally set this to a suitable
+	  value in their defconfig file.
+
+	  If ZBOOT_ROM is not enabled, this has no effect.
 
 config ZBOOT_ROM_BSS
 	hex "Compressed ROM boot loader BSS address"
 	default "0"
 	help
-	  The base address of 64KiB of read/write memory, which must be available
-	  while the decompressor is running.  Unless you have special requirements,
-	  you should not change this value.
-
-config CPU_FREQ
-	bool "Support CPU clock change (EXPERIMENTAL)"
-	depends on (ARCH_SA1100 || ARCH_INTEGRATOR) && EXPERIMENTAL
-	help
-	  CPU clock scaling allows you to change the clock speed of the
-	  running CPU on the fly. This is a nice method to save battery power,
-	  because the lower the clock speed, the less power the CPU
-	  consumes. Note that this driver doesn't automatically change the CPU
-	  clock speed, you need some userland tools (which still have to be
-	  written) to implement the policy. If you don't understand what this
-	  is all about, it's safe to say 'N'.
+	  The base address of 64KiB of read/write memory in the target
+	  for the ROM-able zImage, which must be available while the
+	  decompressor is running.  Platforms which normally make use of
+	  ROM-able zImage formats normally set this to a suitable
+	  value in their defconfig file.
+
+	  If ZBOOT_ROM is not enabled, this has no effect.
+
+config ZBOOT_ROM
+	bool "Compressed boot loader in ROM/flash"
+	depends on ZBOOT_ROM_TEXT != ZBOOT_ROM_BSS
+	help
+	  Say Y here if you intend to execute your compressed kernel image
+	  (zImage) directly from ROM or flash.  If unsure, say N.
+
+config XIP_KERNEL
+	bool "Kernel Execute-In-Place from ROM"
+	depends on !ZBOOT_ROM
+	help
+	  Execute-In-Place allows the kernel to run from non-volatile storage
+	  directly addressable by the CPU, such as NOR flash. This saves RAM
+	  space since the text section of the kernel is not loaded from flash
+	  to RAM.  Read-write sections, such as the data section and stack,
+	  are still copied to RAM.  The XIP kernel is not compressed since
+	  it has to run directly from flash, so it will take more space to
+	  store it.  The flash address used to link the kernel object files,
+	  and for storing it, is configuration dependent. Therefore, if you
+	  say Y here, you must know the proper physical address where to
+	  store the kernel image depending on your own flash memory usage.
+
+	  Also note that the make target becomes "make xipImage" rather than
+	  "make zImage" or "make Image".  The final kernel binary to put in
+	  ROM memory will be arch/arm/boot/xipImage.
+
+	  If unsure, say N.
+
+config XIP_PHYS_ADDR
+	hex "XIP Kernel Physical Location"
+	depends on XIP_KERNEL
+	default "0x00080000"
+	help
+	  This is the physical address in your flash memory the kernel will
+	  be linked for and stored to.  This address is dependent on your
+	  own flash usage.
+
+	  Please note that, if you're using MTD, you must use a flash chip
+	  that is NOT handled by MTD or the flash will be turned into non
+	  data mode for status and query purposes which will instantaneously
+	  crash the kernel.
+
+	  MTD can however be used with a XIP kernel on the same flash chip
+	  but only if the flash memory supports multiple partitions in
+	  hardware, like with the Intel K3 flash parts, and only if the
+	  kernel is not stored within the firrst hardware partition of the
+	  chip.
+
+	  In any case, make sure that MTD support is configured out for
+	  the first attempt.
 
+if (ARCH_SA1100 || ARCH_INTEGRATOR)
 
-# CPUfreq on SA11x0 is special -- it _needs_ the userspace governor
+source "drivers/cpufreq/Kconfig"
 
 config CPU_FREQ_SA1100
 	bool
-	depends on CPU_FREQ && SA1100_LART
+	depends on CPU_FREQ && (SA1100_LART || SA1100_PLEB)
 	default y
-	select CPU_FREQ_24_API if SYSCTL
 
 config CPU_FREQ_SA1110
 	bool
 	depends on CPU_FREQ && (SA1100_ASSABET || SA1100_CERF || SA1100_PT_SYSTEM3)
 	default y
-	select CPU_FREQ_24_API if SYSCTL
 
 config CPU_FREQ_INTEGRATOR
 	tristate "CPUfreq driver for ARM Integrator CPUs"
@@ -393,10 +421,6 @@
 
 	  If in doubt, say Y.
 
-if (CPU_FREQ_INTEGRATOR) || (CPU_FREQ_SA1110) || (CPU_FREQ_SA1100)
-
-source "drivers/cpufreq/Kconfig"
-
 endif
 
 source "drivers/pci/Kconfig"
@@ -572,7 +596,7 @@
 
 config LEDS
 	bool "Timer and CPU usage LEDs"
-	depends on ARCH_NETWINDER || ARCH_EBSA110 || ARCH_EBSA285 || ARCH_SHARK || ARCH_CO285 || ARCH_SA1100 || ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_PXA_IDP || ARCH_INTEGRATOR || ARCH_CDB89712 || ARCH_P720T || ARCH_OMAP || ARCH_VERSATILE_PB || ARCH_IMX
+	depends on ARCH_NETWINDER || ARCH_EBSA110 || ARCH_EBSA285 || ARCH_SHARK || ARCH_CO285 || ARCH_SA1100 || ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_PXA_IDP || ARCH_INTEGRATOR || ARCH_CDB89712 || ARCH_P720T || ARCH_OMAP || ARCH_VERSATILE || ARCH_IMX
 	help
 	  If you say Y here, the LEDs on your machine will be used
 	  to provide useful information about your current system status.
@@ -585,8 +609,8 @@
 	  system, but the driver will do nothing.
 
 config LEDS_TIMER
-	bool "Timer LED" if LEDS && (ARCH_NETWINDER || ARCH_EBSA285 || ARCH_SHARK || MACH_MAINSTONE || ARCH_CO285 || ARCH_SA1100 || ARCH_LUBBOCK || ARCH_PXA_IDP || ARCH_INTEGRATOR || ARCH_P720T || ARCH_VERSATILE_PB || ARCH_IMX)
-	depends on ARCH_NETWINDER || ARCH_EBSA110 || ARCH_EBSA285 || ARCH_SHARK || ARCH_CO285 || ARCH_SA1100 || ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_PXA_IDP || ARCH_INTEGRATOR || ARCH_CDB89712 || ARCH_P720T || ARCH_OMAP || ARCH_VERSATILE_PB || ARCH_IMX
+	bool "Timer LED" if LEDS && (ARCH_NETWINDER || ARCH_EBSA285 || ARCH_SHARK || MACH_MAINSTONE || ARCH_CO285 || ARCH_SA1100 || ARCH_LUBBOCK || ARCH_PXA_IDP || ARCH_INTEGRATOR || ARCH_P720T || ARCH_VERSATILE || ARCH_IMX)
+	depends on ARCH_NETWINDER || ARCH_EBSA110 || ARCH_EBSA285 || ARCH_SHARK || ARCH_CO285 || ARCH_SA1100 || ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_PXA_IDP || ARCH_INTEGRATOR || ARCH_CDB89712 || ARCH_P720T || ARCH_OMAP || ARCH_VERSATILE || ARCH_IMX
 	default y if ARCH_EBSA110
 	help
 	  If you say Y here, one of the system LEDs (the green one on the
@@ -601,7 +625,7 @@
 
 config LEDS_CPU
 	bool "CPU usage LED"
-	depends on LEDS && (ARCH_NETWINDER || ARCH_EBSA285 || ARCH_SHARK || ARCH_CO285 || ARCH_SA1100 || ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_PXA_IDP || ARCH_INTEGRATOR || ARCH_P720T || ARCH_VERSATILE_PB || ARCH_IMX)
+	depends on LEDS && (ARCH_NETWINDER || ARCH_EBSA285 || ARCH_SHARK || ARCH_CO285 || ARCH_SA1100 || ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_PXA_IDP || ARCH_INTEGRATOR || ARCH_P720T || ARCH_VERSATILE || ARCH_IMX)
 	help
 	  If you say Y here, the red LED will be used to give a good real
 	  time indication of CPU usage, by lighting whenever the idle task
diff -Nru a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
--- a/arch/arm/Kconfig.debug	2004-12-24 13:37:43 -08:00
+++ b/arch/arm/Kconfig.debug	2004-12-24 13:37:43 -08:00
@@ -104,12 +104,15 @@
 	  before it is used.
 
 config DEBUG_S3C2410_UART
-	depends on DEBUG_LL && ARCH_S3C2410
+	depends on ARCH_S3C2410
 	int "S3C2410 UART to use for low-level debug"
 	default "0"
 	help
 	  Choice for UART for kernel low-level using S3C2410 UARTS,
 	  should be between zero and two. The port must have been
 	  initalised by the boot-loader before use.
+
+	  The uncompressor code port configuration is now handled
+	  by CONFIG_S3C2410_LOWLEVEL_UART_PORT.
 
 endmenu
diff -Nru a/arch/arm/Makefile b/arch/arm/Makefile
--- a/arch/arm/Makefile	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/Makefile	2004-12-24 13:36:47 -08:00
@@ -13,6 +13,10 @@
 GZFLAGS		:=-9
 #CFLAGS		+=-pipe
 
+# Do not use arch/arm/defconfig - it's always outdated.
+# Select a platform tht is kept up-to-date
+KBUILD_DEFCONFIG := versatile_defconfig
+
 ifeq ($(CONFIG_FRAME_POINTER),y)
 CFLAGS		+=-fno-omit-frame-pointer -mapcs -mno-sched-prolog
 endif
@@ -54,14 +58,13 @@
 tune-$(CONFIG_CPU_V6)		:=-mtune=strongarm
 
 # Need -Uarm for gcc < 3.x
-CFLAGS		+=-mapcs-32 $(arch-y) $(tune-y) $(call cc-option,-malignment-traps,-mshort-load-bytes) -msoft-float -Uarm
-AFLAGS		+=-mapcs-32 $(arch-y) $(tune-y) -msoft-float
+CFLAGS_ABI	:=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
+CFLAGS		+=$(CFLAGS_ABI) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
+AFLAGS		+=$(CFLAGS_ABI) $(arch-y) $(tune-y) -msoft-float
 
 CHECKFLAGS	+= -D__arm__
 
 #Default value
-DATAADDR	:= .
-
 head-y		:= arch/arm/kernel/head.o arch/arm/kernel/init_task.o
 textaddr-y	:= 0xC0008000
 
@@ -93,7 +96,7 @@
  machine-$(CONFIG_ARCH_OMAP)	   := omap
  machine-$(CONFIG_ARCH_S3C2410)	   := s3c2410
  machine-$(CONFIG_ARCH_LH7A40X)	   := lh7a40x
- machine-$(CONFIG_ARCH_VERSATILE_PB) := versatile
+ machine-$(CONFIG_ARCH_VERSATILE)  := versatile
  machine-$(CONFIG_ARCH_IMX)	   := imx
  machine-$(CONFIG_ARCH_H720X)	   := h720x
 
@@ -105,12 +108,27 @@
 endif
 
 TEXTADDR := $(textaddr-y)
+ifeq ($(CONFIG_XIP_KERNEL),y)
+  DATAADDR := $(TEXTADDR)
+  xipaddr-$(CONFIG_ARCH_CO285) := 0x5f000000
+  xipaddr-y ?= 0xbf000000
+  # Replace phys addr with virt addr while keeping offset from base.
+  TEXTADDR := $(shell echo $(CONFIG_XIP_PHYS_ADDR) $(xipaddr-y) | \
+                      awk --non-decimal-data '/[:xdigit:]/ \
+                          { printf("0x%x\n", and($$1, 0x000fffff) + $$2) }' )
+endif
+
 ifeq ($(incdir-y),)
 incdir-y := $(machine-y)
 endif
 INCDIR   := arch-$(incdir-y)
+ifneq ($(machine-y),)
+MACHINE  := arch/arm/mach-$(machine-y)/
+else
+MACHINE  :=
+endif
   
-export	TEXTADDR GZFLAGS
+export	TEXTADDR DATAADDR GZFLAGS
 
 # Do we have FASTFPE?
 FASTFPE		:=arch/arm/fastfpe
@@ -120,9 +138,7 @@
 
 # If we have a machine-specific directory, then include it in the build.
 core-y				+= arch/arm/kernel/ arch/arm/mm/ arch/arm/common/
-ifneq ($(machine-y),)
-core-y				+= arch/arm/mach-$(machine-y)/
-endif
+core-y				+= $(MACHINE)
 core-$(CONFIG_FPE_NWFPE)	+= arch/arm/nwfpe/
 core-$(CONFIG_FPE_FASTFPE)	+= $(FASTFPE_OBJ)
 core-$(CONFIG_VFP)		+= arch/arm/vfp/
@@ -134,7 +150,11 @@
 libs-y				+= arch/arm/lib/
 
 # Default target when executing plain make
+ifeq ($(CONFIG_XIP_KERNEL),y)
+all: xipImage
+else
 all: zImage
+endif
 
 boot := arch/arm/boot
 
@@ -161,11 +181,11 @@
 # Convert bzImage to zImage
 bzImage: zImage
 
-zImage Image bootpImage uImage: vmlinux
-	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
+zImage Image xipImage bootpImage uImage: vmlinux
+	$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
 
 zinstall install: vmlinux
-	$(Q)$(MAKE) $(build)=$(boot) $@
+	$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@
 
 CLEAN_FILES += include/asm-arm/constants.h* include/asm-arm/mach-types.h \
 	       include/asm-arm/arch include/asm-arm/.arch
@@ -175,8 +195,8 @@
 	$(Q)$(MAKE) $(clean)=$(boot)
 
 # My testing targets (bypasses dependencies)
-bp:;	$(Q)$(MAKE) $(build)=$(boot) $(boot)/bootpImage
-i zi:;	$(Q)$(MAKE) $(build)=$(boot) $@
+bp:;	$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/bootpImage
+i zi:;	$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@
 
 arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
 				   include/asm-arm/.arch
@@ -187,6 +207,7 @@
 define archhelp
   echo  '* zImage        - Compressed kernel image (arch/$(ARCH)/boot/zImage)'
   echo  '  Image         - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
+  echo  '* xipImage      - XIP kernel image, if configured (arch/$(ARCH)/boot/xipImage)'
   echo  '  bootpImage    - Combined zImage and initial RAM disk' 
   echo  '                  (supply initrd image via make variable INITRD=<path>)'
   echo  '  install       - Install uncompressed kernel'
diff -Nru a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
--- a/arch/arm/boot/Makefile	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/boot/Makefile	2004-12-24 13:36:18 -08:00
@@ -10,76 +10,38 @@
 
 MKIMAGE         := $(srctree)/scripts/mkuboot.sh
 
+ifneq ($(MACHINE),)
+include $(srctree)/$(MACHINE)/Makefile.boot
+endif
+
 # Note: the following conditions must always be true:
 #   ZRELADDR == virt_to_phys(TEXTADDR)
-#   PARAMS_PHYS must be with 4MB of ZRELADDR
+#   PARAMS_PHYS must be within 4MB of ZRELADDR
 #   INITRD_PHYS must be in RAM
-
-   zreladdr-$(CONFIG_ARCH_RPC)		:= 0x10008000
-params_phys-$(CONFIG_ARCH_RPC)		:= 0x10000100
-initrd_phys-$(CONFIG_ARCH_RPC)		:= 0x18000000
-   zreladdr-$(CONFIG_ARCH_CLPS7500)	:= 0x10008000
-   zreladdr-$(CONFIG_ARCH_CLPS7500)	:= 0x10008000
-   zreladdr-$(CONFIG_ARCH_EBSA110)	:= 0x00008000
-params_phys-$(CONFIG_ARCH_EBSA110)	:= 0x00000400
-initrd_phys-$(CONFIG_ARCH_EBSA110)	:= 0x00800000
-  ztextaddr-$(CONFIG_ARCH_SHARK)	:= 0x08508000
-   zreladdr-$(CONFIG_ARCH_SHARK)	:= 0x08008000
-   zreladdr-$(CONFIG_FOOTBRIDGE)	:= 0x00008000
-params_phys-$(CONFIG_FOOTBRIDGE)	:= 0x00000100
-initrd_phys-$(CONFIG_FOOTBRIDGE)	:= 0x00800000
-   zreladdr-$(CONFIG_ARCH_INTEGRATOR)	:= 0x00008000
-params_phys-$(CONFIG_ARCH_INTEGRATOR)	:= 0x00000100
-initrd_phys-$(CONFIG_ARCH_INTEGRATOR)	:= 0x00800000
-   zreladdr-$(CONFIG_ARCH_CAMELOT)	:= 0x00008000
-   zreladdr-$(CONFIG_ARCH_NEXUSPCI)	:= 0x40008000
-   zreladdr-$(CONFIG_ARCH_L7200)	:= 0xf0008000
-# The standard locations for stuff on CLPS711x type processors
-   zreladdr-$(CONFIG_ARCH_CLPS711X)	:= 0xc0028000 
-params_phys-$(CONFIG_ARCH_CLPS711X)	:= 0xc0000100
-# Should probably have some agreement on these...
-initrd_phys-$(CONFIG_ARCH_P720T)	:= 0xc0400000
-initrd_phys-$(CONFIG_ARCH_CDB89712)	:= 0x00700000
-   zreladdr-$(CONFIG_ARCH_SA1100)	:= 0xc0008000
-ifeq ($(CONFIG_ARCH_SA1100),y)
-   zreladdr-$(CONFIG_SA1111)		:= 0xc0208000
-endif
-params_phys-$(CONFIG_ARCH_SA1100)	:= 0xc0000100
-initrd_phys-$(CONFIG_ARCH_SA1100)	:= 0xc0800000
-   zreladdr-$(CONFIG_ARCH_PXA)		:= 0xa0008000
-   zreladdr-$(CONFIG_ARCH_MX1ADS)	:= 0x08008000
-   zreladdr-$(CONFIG_ARCH_IOP3XX)	:= 0xa0008000
-params_phys-$(CONFIG_ARCH_IOP3XX)	:= 0xa0000100
-initrd_phys-$(CONFIG_ARCH_IOP3XX)   	:= 0xa0800000
-ifeq ($(CONFIG_ARCH_IOP331),y)
-   zreladdr-$(CONFIG_ARCH_IOP3XX)      	:= 0x00008000
-params_phys-$(CONFIG_ARCH_IOP3XX)      	:= 0x00000100
-initrd_phys-$(CONFIG_ARCH_IOP3XX)      	:= 0x00800000
-endif
-   zreladdr-$(CONFIG_ARCH_IXP4XX)	:= 0x00008000
-params-phys-$(CONFIG_ARCH_IXP4XX)	:= 0x00000100
-   zreladdr-$(CONFIG_ARCH_IXP2000)	:= 0x00008000
-params-phys-$(CONFIG_ARCH_IXP2000)	:= 0x00000100
-   zreladdr-$(CONFIG_ARCH_OMAP)		:= 0x10008000
-params_phys-$(CONFIG_ARCH_OMAP)		:= 0x10000100
-initrd_phys-$(CONFIG_ARCH_OMAP)		:= 0x10800000
-   zreladdr-$(CONFIG_ARCH_LH7A40X)	:= 0xc0008000
-params_phys-$(CONFIG_ARCH_LH7A40X)	:= 0xc0000100
-initrd_phys-$(CONFIG_ARCH_LH7A40X)	:= 0xc4000000
-   zreladdr-$(CONFIG_ARCH_S3C2410)	:= 0x30008000
-params_phys-$(CONFIG_ARCH_S3C2410)	:= 0x30000100
-   zreladdr-$(CONFIG_ARCH_VERSATILE_PB)	:= 0x00008000
-params_phys-$(CONFIG_ARCH_VERSATILE_PB)	:= 0x00000100
-initrd_phys-$(CONFIG_ARCH_VERSATILE_PB)	:= 0x00800000
-   zreladdr-$(CONFIG_ARCH_H720X)	:= 0x40008000
-
 ZRELADDR    := $(zreladdr-y)
 PARAMS_PHYS := $(params_phys-y)
 INITRD_PHYS := $(initrd_phys-y)
 
 export ZRELADDR INITRD_PHYS PARAMS_PHYS
 
-targets := Image zImage bootpImage uImage
+targets := Image zImage xipImage bootpImage uImage
+
+ifeq ($(CONFIG_XIP_KERNEL),y)
+
+$(obj)/xipImage: vmlinux FORCE
+	$(call if_changed,objcopy)
+	@echo '  Kernel: $@ is ready (physical address: $(CONFIG_XIP_PHYS_ADDR))'
+
+$(obj)/Image $(obj)/zImage: FORCE
+	@echo 'Kernel configured for XIP (CONFIG_XIP_KERNEL=y)'
+	@echo 'Only the xipImage target is available in this case'
+	@false
+
+else
+
+$(obj)/xipImage: FORCE
+	@echo 'Kernel not configured for XIP (CONFIG_XIP_KERNEL!=y)'
+	@false
 
 $(obj)/Image: vmlinux FORCE
 	$(call if_changed,objcopy)
@@ -91,6 +53,8 @@
 $(obj)/zImage:	$(obj)/compressed/vmlinux FORCE
 	$(call if_changed,objcopy)
 	@echo '  Kernel: $@ is ready'
+
+endif
 
 quiet_cmd_uimage = UIMAGE  $@
       cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A arm -O linux -T kernel \
diff -Nru a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
--- a/arch/arm/boot/compressed/Makefile	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/boot/compressed/Makefile	2004-12-24 13:36:18 -08:00
@@ -40,9 +40,6 @@
 
 ifeq ($(CONFIG_ARCH_SA1100),y)
 OBJS		+= head-sa1100.o
-ifeq ($(CONFIG_SA1100_NANOENGINE),y)
-  OBJS += hw-bse.o
-endif
 endif
 
 ifeq ($(CONFIG_CPU_XSCALE),y)
diff -Nru a/arch/arm/boot/compressed/head-sa1100.S b/arch/arm/boot/compressed/head-sa1100.S
--- a/arch/arm/boot/compressed/head-sa1100.S	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/boot/compressed/head-sa1100.S	2004-12-24 13:36:18 -08:00
@@ -16,47 +16,13 @@
 __SA1100_start:
 
 		@ Preserve r8/r7 i.e. kernel entry values
-
-#if defined(CONFIG_SA1100_GRAPHICSCLIENT) && !defined(CONFIG_ANGELBOOT)
-		mov	r7, #MACH_TYPE_GRAPHICSCLIENT
-		mov	r8, #0
-#endif
-#if defined(CONFIG_SA1100_GRAPHICSMASTER) && !defined(CONFIG_ANGELBOOT)
-		mov	r7, #MACH_TYPE_GRAPHICSMASTER
-		mov	r8, #0
-#endif
-#if defined(CONFIG_SA1100_ADSBITSY) && !defined(CONFIG_ANGELBOOT)
-		mov	r7, #MACH_TYPE_ADSBITSY
-		mov	r8, #0
-#endif
-
 #ifdef CONFIG_SA1100_COLLIE
 		mov	r7, #MACH_TYPE_COLLIE
 #endif
-#ifdef CONFIG_SA1100_PFS168
-		@ REVISIT_PFS168: Temporary until firmware updated to use assigned machine number
-		mov	r7, #MACH_TYPE_PFS168
-#endif
 #ifdef CONFIG_SA1100_SIMPAD
 		@ UNTIL we've something like an open bootldr
-		mov	r7, #MACH_TYPE_SIMPAD @should be 87
-#endif
-
-#ifdef CONFIG_SA1100_VICTOR
-		teq	r7, #MACH_TYPE_VICTOR
-		bne	10f
-
-		@ Copy cmdline to 0xc0000000
-		mov	r1, #0xc0000000
-		cmp	r0, #0
-		moveq	r2, #0
-1:		ldrneb	r2, [r0], #1
-		cmpne	r2, #0
-		strb	r2, [r1], #1
-		bne	1b
-10:
+		mov	r7, #MACH_TYPE_SIMPAD	@should be 87
 #endif
-
 		mrc	p15, 0, r0, c1, c0, 0	@ read control reg
 		ands	r0, r0, #0x0d
 		beq	99f
diff -Nru a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
--- a/arch/arm/boot/compressed/head.S	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/boot/compressed/head.S	2004-12-24 13:37:19 -08:00
@@ -117,6 +117,14 @@
 		.macro	writeb, rb
 		str	\rb, [r3, #0]
 		.endm
+#elif defined(CONFIG_ARCH_S3C2410)
+			.macro loadsp, rb
+		mov	\rb, #0x50000000
+		add	\rb, \rb, #0x4000 * CONFIG_S3C2410_LOWLEVEL_UART_PORT
+		.endm
+		.macro	writeb, rb
+		strb	\rb, [r3, #0x20]
+		.endm
 #else
 #error no serial architecture defined
 #endif
diff -Nru a/arch/arm/boot/compressed/hw-bse.c b/arch/arm/boot/compressed/hw-bse.c
--- a/arch/arm/boot/compressed/hw-bse.c	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,74 +0,0 @@
-/*
- * Bright Star Engineering Inc.
- *
- * code for readng parameters from the
- * parameter blocks of the boot block
- * flash memory
- *
- */
-
-static int strcmp(const char *s1, const char *s2)
-{
-  while (*s1 != '\0' && *s1 == *s2)
-    {
-      s1++;
-      s2++;
-    }
-
-  return (*(unsigned char *) s1) - (*(unsigned char *) s2);
-}
-
-struct pblk_t {
-  char type;
-  unsigned short size;
-};
-
-static char *bse_getflashparam(char *name) {
-  unsigned int esize;
-  char *q,*r;
-  unsigned char *p,*e;
-  struct pblk_t *thepb = (struct pblk_t *) 0x00004000;
-  struct pblk_t *altpb = (struct pblk_t *) 0x00006000;  
-  if (thepb->type&1) {
-    if (altpb->type&1) {
-      /* no valid param block */ 
-      return (char*)0;
-    } else {
-      /* altpb is valid */
-      struct pblk_t *tmp;
-      tmp = thepb;
-      thepb = altpb;
-      altpb = tmp;
-    }
-  }
-  p = (char*)thepb + sizeof(struct pblk_t);
-  e = p + thepb->size; 
-  while (p < e) {
-    q = p;
-    esize = *p;
-    if (esize == 0xFF) break;
-    if (esize == 0) break;
-    if (esize > 127) {
-      esize = (esize&0x7F)<<8 | p[1];
-      q++;
-    }
-    q++;
-    r=q;
-    if (*r && ((name == 0) || (!strcmp(name,r)))) {
-      while (*q++) ;
-      return q;
-    }
-    p+=esize;
-  }
-  return (char*)0;
-}
-
-void bse_setup(void) {
-  /* extract the linux cmdline from flash */
-  char *name=bse_getflashparam("linuxboot");
-  char *x = (char *)0xc0000100;
-  if (name) { 
-    while (*name) *x++=*name++;
-  }
-  *x=0;
-}
diff -Nru a/arch/arm/common/Makefile b/arch/arm/common/Makefile
--- a/arch/arm/common/Makefile	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/common/Makefile	2004-12-24 13:36:48 -08:00
@@ -2,8 +2,10 @@
 # Makefile for the linux kernel.
 #
 
+obj-y				+= rtctime.o
 obj-$(CONFIG_ARM_AMBA)		+= amba.o
 obj-$(CONFIG_ICST525)		+= icst525.o
+obj-$(CONFIG_ICST307)		+= icst307.o
 obj-$(CONFIG_SA1111)		+= sa1111.o
 obj-$(CONFIG_PCI_HOST_VIA82C505) += via82c505.o
 obj-$(CONFIG_DMABOUNCE)		+= dmabounce.o
diff -Nru a/arch/arm/common/amba.c b/arch/arm/common/amba.c
--- a/arch/arm/common/amba.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/common/amba.c	2004-12-24 13:36:48 -08:00
@@ -194,7 +194,7 @@
 int amba_device_register(struct amba_device *dev, struct resource *parent)
 {
 	u32 pid, cid;
-	void *tmp;
+	void __iomem *tmp;
 	int i, ret;
 
 	dev->dev.release = amba_device_release;
diff -Nru a/arch/arm/common/icst307.c b/arch/arm/common/icst307.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/common/icst307.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,161 @@
+/*
+ *  linux/arch/arm/common/icst307.c
+ *
+ *  Copyright (C) 2003 Deep Blue Solutions, Ltd, 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 version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Support functions for calculating clocks/divisors for the ICST307
+ *  clock generators.  See http://www.icst.com/ for more information
+ *  on these devices.
+ *
+ *  This is an almost identical implementation to the ICST525 clock generator.
+ *  The s2div and idx2s files are different
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include <asm/hardware/icst307.h>
+
+/*
+ * Divisors for each OD setting.
+ */
+static unsigned char s2div[8] = { 10, 2, 8, 4, 5, 7, 3, 6 };
+
+unsigned long icst307_khz(const struct icst307_params *p, struct icst307_vco vco)
+{
+	return p->ref * 2 * (vco.v + 8) / ((vco.r + 2) * s2div[vco.s]);
+}
+
+EXPORT_SYMBOL(icst307_khz);
+
+/*
+ * Ascending divisor S values.
+ */
+static unsigned char idx2s[8] = { 1, 6, 3, 4, 7, 5, 2, 0 };
+
+struct icst307_vco
+icst307_khz_to_vco(const struct icst307_params *p, unsigned long freq)
+{
+	struct icst307_vco vco = { .s = 1, .v = p->vd_max, .r = p->rd_max };
+	unsigned long f;
+	unsigned int i = 0, rd, best = (unsigned int)-1;
+
+	/*
+	 * First, find the PLL output divisor such
+	 * that the PLL output is within spec.
+	 */
+	do {
+		f = freq * s2div[idx2s[i]];
+
+		/*
+		 * f must be between 6MHz and 200MHz (3.3 or 5V)
+		 */
+		if (f > 6000 && f <= p->vco_max)
+			break;
+	} while (i < ARRAY_SIZE(idx2s));
+
+	if (i > ARRAY_SIZE(idx2s))
+		return vco;
+
+	vco.s = idx2s[i];
+
+	/*
+	 * Now find the closest divisor combination
+	 * which gives a PLL output of 'f'.
+	 */
+	for (rd = p->rd_min; rd <= p->rd_max; rd++) {
+		unsigned long fref_div, f_pll;
+		unsigned int vd;
+		int f_diff;
+
+		fref_div = (2 * p->ref) / rd;
+
+		vd = (f + fref_div / 2) / fref_div;
+		if (vd < p->vd_min || vd > p->vd_max)
+			continue;
+
+		f_pll = fref_div * vd;
+		f_diff = f_pll - f;
+		if (f_diff < 0)
+			f_diff = -f_diff;
+
+		if ((unsigned)f_diff < best) {
+			vco.v = vd - 8;
+			vco.r = rd - 2;
+			if (f_diff == 0)
+				break;
+			best = f_diff;
+		}
+	}
+
+	return vco;
+}
+
+EXPORT_SYMBOL(icst307_khz_to_vco);
+
+struct icst307_vco
+icst307_ps_to_vco(const struct icst307_params *p, unsigned long period)
+{
+	struct icst307_vco vco = { .s = 1, .v = p->vd_max, .r = p->rd_max };
+	unsigned long f, ps;
+	unsigned int i = 0, rd, best = (unsigned int)-1;
+
+	ps = 1000000000UL / p->vco_max;
+
+	/*
+	 * First, find the PLL output divisor such
+	 * that the PLL output is within spec.
+	 */
+	do {
+		f = period / s2div[idx2s[i]];
+
+		/*
+		 * f must be between 6MHz and 200MHz (3.3 or 5V)
+		 */
+		if (f >= ps && f < 1000000000UL / 6000 + 1)
+			break;
+	} while (i < ARRAY_SIZE(idx2s));
+
+	if (i > ARRAY_SIZE(idx2s))
+		return vco;
+
+	vco.s = idx2s[i];
+
+	ps = 500000000UL / p->ref;
+
+	/*
+	 * Now find the closest divisor combination
+	 * which gives a PLL output of 'f'.
+	 */
+	for (rd = p->rd_min; rd <= p->rd_max; rd++) {
+		unsigned long f_in_div, f_pll;
+		unsigned int vd;
+		int f_diff;
+
+		f_in_div = ps * rd;
+
+		vd = (f_in_div + f / 2) / f;
+		if (vd < p->vd_min || vd > p->vd_max)
+			continue;
+
+		f_pll = (f_in_div + vd / 2) / vd;
+		f_diff = f_pll - f;
+		if (f_diff < 0)
+			f_diff = -f_diff;
+
+		if ((unsigned)f_diff < best) {
+			vco.v = vd - 8;
+			vco.r = rd - 2;
+			if (f_diff == 0)
+				break;
+			best = f_diff;
+		}
+	}
+
+	return vco;
+}
+
+EXPORT_SYMBOL(icst307_ps_to_vco);
diff -Nru a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
--- a/arch/arm/common/locomo.c	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/common/locomo.c	2004-12-24 13:36:16 -08:00
@@ -609,17 +609,15 @@
 static int locomo_probe(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
-	struct resource *mem = NULL, *irq = NULL;
-	int i;
+	struct resource *mem;
+	int irq;
 
-	for (i = 0; i < pdev->num_resources; i++) {
-		if (pdev->resource[i].flags & IORESOURCE_MEM)
-			mem = &pdev->resource[i];
-		if (pdev->resource[i].flags & IORESOURCE_IRQ)
-			irq = &pdev->resource[i];
-	}
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!mem)
+		return -EINVAL;
+	irq = platform_get_irq(pdev, 0);
 
-	return __locomo_probe(dev, mem, irq ? irq->start : NO_IRQ);
+	return __locomo_probe(dev, mem, irq);
 }
 
 static int locomo_remove(struct device *dev)
@@ -629,9 +627,6 @@
 	if (lchip) {
 		__locomo_remove(lchip);
 		dev_set_drvdata(dev, NULL);
-
-		kfree(dev->saved_state);
-		dev->saved_state = NULL;
 	}
 
 	return 0;
@@ -756,7 +751,7 @@
 
 MODULE_DESCRIPTION("Sharp LoCoMo core driver");
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("John Lenz <jelenz@students.wisc.edu>");
+MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");
 
 EXPORT_SYMBOL(locomo_driver_register);
 EXPORT_SYMBOL(locomo_driver_unregister);
diff -Nru a/arch/arm/common/rtctime.c b/arch/arm/common/rtctime.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/common/rtctime.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,502 @@
+/*
+ *  linux/arch/arm/common/rtctime.c
+ *
+ *  Copyright (C) 2003 Deep Blue Solutions Ltd.
+ *  Based on sa1100-rtc.c, Nils Faerber, CIH, Nicolas Pitre.
+ *  Based on rtc.c by Paul Gortmaker
+ *
+ * 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/module.h>
+#include <linux/kernel.h>
+#include <linux/time.h>
+#include <linux/rtc.h>
+#include <linux/poll.h>
+#include <linux/proc_fs.h>
+#include <linux/miscdevice.h>
+#include <linux/spinlock.h>
+#include <linux/device.h>
+
+#include <asm/rtc.h>
+#include <asm/semaphore.h>
+
+static DECLARE_WAIT_QUEUE_HEAD(rtc_wait);
+static struct fasync_struct *rtc_async_queue;
+
+/*
+ * rtc_lock protects rtc_irq_data
+ */
+static spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
+static unsigned long rtc_irq_data;
+
+/*
+ * rtc_sem protects rtc_inuse and rtc_ops
+ */
+static DECLARE_MUTEX(rtc_sem);
+static unsigned long rtc_inuse;
+static struct rtc_ops *rtc_ops;
+
+#define rtc_epoch 1900UL
+
+static const unsigned char days_in_month[] = {
+	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+};
+
+#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
+#define LEAP_YEAR(year) ((!(year % 4) && (year % 100)) || !(year % 400))
+
+static int month_days(unsigned int month, unsigned int year)
+{
+	return days_in_month[month] + (LEAP_YEAR(year) && month == 1);
+}
+
+/*
+ * Convert seconds since 01-01-1970 00:00:00 to Gregorian date.
+ */
+void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
+{
+	int days, month, year;
+
+	days = time / 86400;
+	time -= days * 86400;
+
+	tm->tm_wday = (days + 4) % 7;
+
+	year = 1970 + days / 365;
+	days -= (year - 1970) * 365
+	        + LEAPS_THRU_END_OF(year - 1)
+	        - LEAPS_THRU_END_OF(1970 - 1);
+	if (days < 0) {
+		year -= 1;
+		days += 365 + LEAP_YEAR(year);
+	}
+	tm->tm_year = year - 1900;
+	tm->tm_yday = days + 1;
+
+	for (month = 0; month < 11; month++) {
+		int newdays;
+
+		newdays = days - month_days(month, year);
+		if (newdays < 0)
+			break;
+		days = newdays;
+	}
+	tm->tm_mon = month;
+	tm->tm_mday = days + 1;
+
+	tm->tm_hour = time / 3600;
+	time -= tm->tm_hour * 3600;
+	tm->tm_min = time / 60;
+	tm->tm_sec = time - tm->tm_min * 60;
+}
+EXPORT_SYMBOL(rtc_time_to_tm);
+
+/*
+ * Convert Gregorian date to seconds since 01-01-1970 00:00:00.
+ */
+int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time)
+{
+	unsigned int yrs = tm->tm_year + 1900;
+
+	*time = 0;
+
+	if (yrs < 1970 ||
+	    tm->tm_mon >= 12 ||
+	    tm->tm_mday < 1 ||
+	    tm->tm_mday > month_days(tm->tm_mon, yrs) ||
+	    tm->tm_hour >= 24 ||
+	    tm->tm_min >= 60 ||
+	    tm->tm_sec >= 60)
+		return -EINVAL;
+
+	*time = mktime(yrs, tm->tm_mon + 1, tm->tm_mday,
+		       tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+	return 0;
+}
+EXPORT_SYMBOL(rtc_tm_to_time);
+
+/*
+ * Calculate the next alarm time given the requested alarm time mask
+ * and the current time.
+ *
+ * FIXME: for now, we just copy the alarm time because we're lazy (and
+ * is therefore buggy - setting a 10am alarm at 8pm will not result in
+ * the alarm triggering.)
+ */
+void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm)
+{
+	next->tm_year = now->tm_year;
+	next->tm_mon = now->tm_mon;
+	next->tm_mday = now->tm_mday;
+	next->tm_hour = alrm->tm_hour;
+	next->tm_min = alrm->tm_min;
+	next->tm_sec = alrm->tm_sec;
+}
+
+static inline void rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm)
+{
+	memset(tm, 0, sizeof(struct rtc_time));
+	ops->read_time(tm);
+}
+
+static inline int rtc_set_time(struct rtc_ops *ops, struct rtc_time *tm)
+{
+	return ops->set_time(tm);
+}
+
+static inline int rtc_read_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm)
+{
+	int ret = -EINVAL;
+	if (ops->read_alarm) {
+		memset(alrm, 0, sizeof(struct rtc_wkalrm));
+		ops->read_alarm(alrm);
+		ret = 0;
+	}
+	return ret;
+}
+
+static inline int rtc_set_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm)
+{
+	int ret = -EINVAL;
+	if (ops->set_alarm)
+		ret = ops->set_alarm(alrm);
+	return ret;
+}
+
+void rtc_update(unsigned long num, unsigned long events)
+{
+	spin_lock(&rtc_lock);
+	rtc_irq_data = (rtc_irq_data + (num << 8)) | events;
+	spin_unlock(&rtc_lock);
+
+	wake_up_interruptible(&rtc_wait);
+	kill_fasync(&rtc_async_queue, SIGIO, POLL_IN);
+}
+EXPORT_SYMBOL(rtc_update);
+
+
+static ssize_t
+rtc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+{
+	DECLARE_WAITQUEUE(wait, current);
+	unsigned long data;
+	ssize_t ret;
+
+	if (count < sizeof(unsigned long))
+		return -EINVAL;
+
+	add_wait_queue(&rtc_wait, &wait);
+	do {
+		__set_current_state(TASK_INTERRUPTIBLE);
+
+		spin_lock_irq(&rtc_lock);
+		data = rtc_irq_data;
+		rtc_irq_data = 0;
+		spin_unlock_irq(&rtc_lock);
+
+		if (data != 0) {
+			ret = 0;
+			break;
+		}
+		if (file->f_flags & O_NONBLOCK) {
+			ret = -EAGAIN;
+			break;
+		}
+		if (signal_pending(current)) {
+			ret = -ERESTARTSYS;
+			break;
+		}
+		schedule();
+	} while (1);
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&rtc_wait, &wait);
+
+	if (ret == 0) {
+		ret = put_user(data, (unsigned long __user *)buf);
+		if (ret == 0)
+			ret = sizeof(unsigned long);
+	}
+	return ret;
+}
+
+static unsigned int rtc_poll(struct file *file, poll_table *wait)
+{
+	unsigned long data;
+
+	poll_wait(file, &rtc_wait, wait);
+
+	spin_lock_irq(&rtc_lock);
+	data = rtc_irq_data;
+	spin_unlock_irq(&rtc_lock);
+
+	return data != 0 ? POLLIN | POLLRDNORM : 0;
+}
+
+static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+		     unsigned long arg)
+{
+	struct rtc_ops *ops = file->private_data;
+	struct rtc_time tm;
+	struct rtc_wkalrm alrm;
+	void __user *uarg = (void __user *)arg;
+	int ret = -EINVAL;
+
+	switch (cmd) {
+	case RTC_ALM_READ:
+		ret = rtc_read_alarm(ops, &alrm);
+		if (ret)
+			break;
+		ret = copy_to_user(uarg, &alrm.time, sizeof(tm));
+		if (ret)
+			ret = -EFAULT;
+		break;
+
+	case RTC_ALM_SET:
+		ret = copy_from_user(&alrm.time, uarg, sizeof(tm));
+		if (ret) {
+			ret = -EFAULT;
+			break;
+		}
+		alrm.enabled = 0;
+		alrm.pending = 0;
+		alrm.time.tm_mday = -1;
+		alrm.time.tm_mon = -1;
+		alrm.time.tm_year = -1;
+		alrm.time.tm_wday = -1;
+		alrm.time.tm_yday = -1;
+		alrm.time.tm_isdst = -1;
+		ret = rtc_set_alarm(ops, &alrm);
+		break;
+
+	case RTC_RD_TIME:
+		rtc_read_time(ops, &tm);
+		ret = copy_to_user(uarg, &tm, sizeof(tm));
+		if (ret)
+			ret = -EFAULT;
+		break;
+
+	case RTC_SET_TIME:
+		if (!capable(CAP_SYS_TIME)) {
+			ret = -EACCES;
+			break;
+		}
+		ret = copy_from_user(&tm, uarg, sizeof(tm));
+		if (ret) {
+			ret = -EFAULT;
+			break;
+		}
+		ret = rtc_set_time(ops, &tm);
+		break;
+
+	case RTC_EPOCH_SET:
+#ifndef rtc_epoch
+		/*
+		 * There were no RTC clocks before 1900.
+		 */
+		if (arg < 1900) {
+			ret = -EINVAL;
+			break;
+		}
+		if (!capable(CAP_SYS_TIME)) {
+			ret = -EACCES;
+			break;
+		}
+		rtc_epoch = arg;
+		ret = 0;
+#endif
+		break;
+
+	case RTC_EPOCH_READ:
+		ret = put_user(rtc_epoch, (unsigned long __user *)uarg);
+		break;
+
+	case RTC_WKALM_SET:
+		ret = copy_from_user(&alrm, uarg, sizeof(alrm));
+		if (ret) {
+			ret = -EFAULT;
+			break;
+		}
+		ret = rtc_set_alarm(ops, &alrm);
+		break;
+
+	case RTC_WKALM_RD:
+		ret = rtc_read_alarm(ops, &alrm);
+		if (ret)
+			break;
+		ret = copy_to_user(uarg, &alrm, sizeof(alrm));
+		if (ret)
+			ret = -EFAULT;
+		break;
+
+	default:
+		if (ops->ioctl)
+			ret = ops->ioctl(cmd, arg);
+		break;
+	}
+	return ret;
+}
+
+static int rtc_open(struct inode *inode, struct file *file)
+{
+	int ret;
+
+	down(&rtc_sem);
+
+	if (rtc_inuse) {
+		ret = -EBUSY;
+	} else if (!rtc_ops || !try_module_get(rtc_ops->owner)) {
+		ret = -ENODEV;
+	} else {
+		file->private_data = rtc_ops;
+
+		ret = rtc_ops->open ? rtc_ops->open() : 0;
+		if (ret == 0) {
+			spin_lock_irq(&rtc_lock);
+			rtc_irq_data = 0;
+			spin_unlock_irq(&rtc_lock);
+
+			rtc_inuse = 1;
+		}
+	}
+	up(&rtc_sem);
+
+	return ret;
+}
+
+static int rtc_release(struct inode *inode, struct file *file)
+{
+	struct rtc_ops *ops = file->private_data;
+
+	if (ops->release)
+		ops->release();
+
+	spin_lock_irq(&rtc_lock);
+	rtc_irq_data = 0;
+	spin_unlock_irq(&rtc_lock);
+
+	module_put(rtc_ops->owner);
+	rtc_inuse = 0;
+
+	return 0;
+}
+
+static int rtc_fasync(int fd, struct file *file, int on)
+{
+	return fasync_helper(fd, file, on, &rtc_async_queue);
+}
+
+static struct file_operations rtc_fops = {
+	.owner		= THIS_MODULE,
+	.llseek		= no_llseek,
+	.read		= rtc_read,
+	.poll		= rtc_poll,
+	.ioctl		= rtc_ioctl,
+	.open		= rtc_open,
+	.release	= rtc_release,
+	.fasync		= rtc_fasync,
+};
+
+static struct miscdevice rtc_miscdev = {
+	.minor		= RTC_MINOR,
+	.name		= "rtc",
+	.fops		= &rtc_fops,
+};
+
+
+static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+	struct rtc_ops *ops = data;
+	struct rtc_wkalrm alrm;
+	struct rtc_time tm;
+	char *p = page;
+	int len;
+
+	rtc_read_time(ops, &tm);
+
+	p += sprintf(p,
+		"rtc_time\t: %02d:%02d:%02d\n"
+		"rtc_date\t: %04d-%02d-%02d\n"
+		"rtc_epoch\t: %04lu\n",
+		tm.tm_hour, tm.tm_min, tm.tm_sec,
+		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+		rtc_epoch);
+
+	if (rtc_read_alarm(ops, &alrm) == 0) {
+		p += sprintf(p, "alrm_time\t: ");
+		if ((unsigned int)alrm.time.tm_hour <= 24)
+			p += sprintf(p, "%02d:", alrm.time.tm_hour);
+		else
+			p += sprintf(p, "**:");
+		if ((unsigned int)alrm.time.tm_min <= 59)
+			p += sprintf(p, "%02d:", alrm.time.tm_min);
+		else
+			p += sprintf(p, "**:");
+		if ((unsigned int)alrm.time.tm_sec <= 59)
+			p += sprintf(p, "%02d\n", alrm.time.tm_sec);
+		else
+			p += sprintf(p, "**\n");
+
+		p += sprintf(p, "alrm_date\t: ");
+		if ((unsigned int)alrm.time.tm_year <= 200)
+			p += sprintf(p, "%04d-", alrm.time.tm_year + 1900);
+		else
+			p += sprintf(p, "****-");
+		if ((unsigned int)alrm.time.tm_mon <= 11)
+			p += sprintf(p, "%02d-", alrm.time.tm_mon + 1);
+		else
+			p += sprintf(p, "**-");
+		if ((unsigned int)alrm.time.tm_mday <= 31)
+			p += sprintf(p, "%02d\n", alrm.time.tm_mday);
+		else
+			p += sprintf(p, "**\n");
+		p += sprintf(p, "alrm_wakeup\t: %s\n",
+			     alrm.enabled ? "yes" : "no");
+		p += sprintf(p, "alrm_pending\t: %s\n",
+			     alrm.pending ? "yes" : "no");
+	}
+
+	if (ops->proc)
+		p += ops->proc(p);
+
+	len = (p - page) - off;
+	if (len < 0)
+		len = 0;
+	*eof = len <= count;
+	*start = page + off;
+
+	return len;
+}
+
+int register_rtc(struct rtc_ops *ops)
+{
+	int ret = -EBUSY;
+
+	down(&rtc_sem);
+	if (rtc_ops == NULL) {
+		rtc_ops = ops;
+
+		ret = misc_register(&rtc_miscdev);
+		if (ret == 0)
+			create_proc_read_entry("driver/rtc", 0, NULL,
+					       rtc_read_proc, ops);
+	}
+	up(&rtc_sem);
+
+	return ret;
+}
+EXPORT_SYMBOL(register_rtc);
+
+void unregister_rtc(struct rtc_ops *rtc)
+{
+	down(&rtc_sem);
+	if (rtc == rtc_ops) {
+		remove_proc_entry("driver/rtc", NULL);
+		misc_deregister(&rtc_miscdev);
+		rtc_ops = NULL;
+	}
+	up(&rtc_sem);
+}
+EXPORT_SYMBOL(unregister_rtc);
diff -Nru a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
--- a/arch/arm/common/sa1111.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/common/sa1111.c	2004-12-24 13:37:19 -08:00
@@ -797,6 +797,8 @@
 	unsigned int	wakeen1;
 };
 
+#ifdef	CONFIG_PM
+
 static int sa1111_suspend(struct device *dev, u32 state, u32 level)
 {
 	struct sa1111 *sachip = dev_get_drvdata(dev);
@@ -808,11 +810,10 @@
 	if (level != SUSPEND_DISABLE)
 		return 0;
 
-	dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
-	if (!dev->saved_state)
+	save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
+	if (!save)
 		return -ENOMEM;
-
-	save = (struct sa1111_save_data *)dev->saved_state;
+	dev->power.saved_state = save;
 
 	spin_lock_irqsave(&sachip->lock, flags);
 
@@ -870,7 +871,7 @@
 	if (level != RESUME_ENABLE)
 		return 0;
 
-	save = (struct sa1111_save_data *)dev->saved_state;
+	save = (struct sa1111_save_data *)dev->power.saved_state;
 	if (!save)
 		return 0;
 
@@ -915,12 +916,18 @@
 
 	spin_unlock_irqrestore(&sachip->lock, flags);
 
-	dev->saved_state = NULL;
+	dev->power.saved_state = NULL;
 	kfree(save);
 
 	return 0;
 }
 
+#else	/* !CONFIG_PM */
+#define sa1111_resume	NULL
+#define sa1111_suspend	NULL
+#endif	/* !CONFIG_PM */
+
+
 static int sa1111_probe(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -943,8 +950,10 @@
 		__sa1111_remove(sachip);
 		dev_set_drvdata(dev, NULL);
 
-		kfree(dev->saved_state);
-		dev->saved_state = NULL;
+#ifdef CONFIG_PM
+		kfree(dev->power.saved_state);
+		dev->power.saved_state = NULL;
+#endif
 	}
 
 	return 0;
diff -Nru a/arch/arm/common/time-acorn.c b/arch/arm/common/time-acorn.c
--- a/arch/arm/common/time-acorn.c	2004-12-24 13:37:31 -08:00
+++ b/arch/arm/common/time-acorn.c	2004-12-24 13:37:31 -08:00
@@ -15,6 +15,7 @@
  */
 #include <linux/timex.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
 
 #include <asm/hardware.h>
 #include <asm/io.h>
@@ -22,7 +23,7 @@
 
 #include <asm/mach/time.h>
 
-static unsigned long ioctime_gettimeoffset(void)
+unsigned long ioc_timer_gettimeoffset(void)
 {
 	unsigned int count1, count2, status;
 	long offset;
@@ -62,6 +63,34 @@
 	ioc_writeb(LATCH & 255, IOC_T0LTCHL);
 	ioc_writeb(LATCH >> 8, IOC_T0LTCHH);
 	ioc_writeb(0, IOC_T0GO);
+}
 
-	gettimeoffset = ioctime_gettimeoffset;
+static irqreturn_t
+ioc_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	write_seqlock(&xtime_lock);
+	timer_tick(regs);
+	write_sequnlock(&xtime_lock);
+	return IRQ_HANDLED;
 }
+
+static struct irqaction ioc_timer_irq = {
+	.name		= "timer",
+	.flags		= SA_INTERRUPT,
+	.handler	= ioc_timer_interrupt
+};
+
+/*
+ * Set up timer interrupt.
+ */
+static void __init ioc_timer_init(void)
+{
+	ioctime_init();
+	setup_irq(IRQ_TIMER, &ioc_timer_irq);
+}
+
+struct sys_timer ioc_timer = {
+	.init		= ioc_timer_init,
+	.offset		= ioc_timer_gettimeoffset,
+};
+
diff -Nru a/arch/arm/configs/adsbitsy_defconfig b/arch/arm/configs/adsbitsy_defconfig
--- a/arch/arm/configs/adsbitsy_defconfig	2004-12-24 13:37:02 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,661 +0,0 @@
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-CONFIG_SA1100_ADSBITSY=y
-CONFIG_SA1111=y
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-# CONFIG_CPU_BIG_ENDIAN is not set
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=y
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_APM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="ip=off mem=32M root=/dev/ram ramdisk=8192 initrd=0xc0800000,4M"
-# CONFIG_PFS168_CMDLINE is not set
-# CONFIG_LEDS is not set
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-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=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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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_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_ACENIC_OMIT_TIGON_I is not set
-# CONFIG_MYRI_SBUS 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=y
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-CONFIG_INPUT=y
-# CONFIG_INPUT_KEYBDEV is not set
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=640
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=480
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=38400
-# CONFIG_SERIAL_8250 is not set
-# CONFIG_SERIAL_8250_CONSOLE is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-CONFIG_UCB1200=y
-CONFIG_TOUCHSCREEN_UCB1200=y
-CONFIG_AUDIO_UCB1200=y
-CONFIG_ADC_UCB1200=y
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-# CONFIG_PFS168_DTMF is not set
-# CONFIG_PFS168_MISC 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
-# 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_SA1100_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
-
-#
-# PCMCIA character devices
-#
-
-#
-# 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=y
-# CONFIG_MSDOS_FS is not set
-# CONFIG_UMSDOS_FS is not set
-CONFIG_VFAT_FS=y
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
-CONFIG_CRAMFS=y
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# 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_DEBUG 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_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=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_E1355 is not set
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-# CONFIG_FONT_8x8 is not set
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB=y
-# CONFIG_USB_DEBUG is not set
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-CONFIG_USB_OHCI=y
-CONFIG_USB_OHCI_NOPCI=y
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_STORAGE is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-# CONFIG_USB_HID is not set
-# CONFIG_USB_KBD is not set
-CONFIG_USB_MOUSE=y
-# CONFIG_USB_WACOM is not set
-# 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_IBMCAM is not set
-# CONFIG_USB_OV511 is not set
-# CONFIG_USB_PWC is not set
-# CONFIG_USB_SE401 is not set
-# CONFIG_USB_DSBR is not set
-# CONFIG_USB_DABUSB is not set
-# 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_USBNET is not set
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-# CONFIG_USB_RIO500 is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-# CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_NO_PGT_CACHE is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/bast_defconfig b/arch/arm/configs/bast_defconfig
--- a/arch/arm/configs/bast_defconfig	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/configs/bast_defconfig	2004-12-24 13:36:48 -08:00
@@ -1,31 +1,35 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Mon Nov 15 15:32:48 2004
 #
 CONFIG_ARM=y
 CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
 # CONFIG_CLEAN_COMPILE is not set
-CONFIG_STANDALONE=y
 CONFIG_BROKEN=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 # CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=17
+CONFIG_LOG_BUF_SHIFT=16
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
@@ -33,11 +37,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,6 +52,7 @@
 # CONFIG_MODULE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -60,6 +67,7 @@
 # CONFIG_ARCH_INTEGRATOR is not set
 # CONFIG_ARCH_IOP3XX is not set
 # CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
 # CONFIG_ARCH_L7200 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
@@ -68,15 +76,28 @@
 # CONFIG_ARCH_SHARK is not set
 # CONFIG_ARCH_LH7A40X is not set
 # CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_H720X is not set
 
 #
-# S3C2410 Implementations
+# S3C24XX Implementations
 #
 CONFIG_ARCH_BAST=y
 # CONFIG_ARCH_H1940 is not set
 # CONFIG_ARCH_SMDK2410 is not set
 CONFIG_MACH_VR1000=y
+# CONFIG_MACH_RX3715 is not set
+CONFIG_CPU_S3C2410=y
+
+#
+# S3C2410 Setup
+#
+CONFIG_S3C2410_DMA=y
+# CONFIG_S3C2410_DMA_DEBUG is not set
+# CONFIG_S3C2410_PM_DEBUG is not set
+# CONFIG_S3C2410_PM_CHECK is not set
+CONFIG_S3C2410_LOWLEVEL_UART_PORT=0
 
 #
 # Processor Type
@@ -86,6 +107,7 @@
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
 CONFIG_CPU_CACHE_V4WT=y
+CONFIG_CPU_CACHE_VIVT=y
 CONFIG_CPU_COPY_V4WB=y
 CONFIG_CPU_TLB_V4WBI=y
 
@@ -103,14 +125,14 @@
 # CONFIG_ZBOOT_ROM is not set
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_XIP_KERNEL is not set
 
 #
 # At least one math emulation must be selected
 #
 CONFIG_FPE_NWFPE=y
-CONFIG_FPE_NWFPE_XP=y
+# CONFIG_FPE_NWFPE_XP is not set
 # CONFIG_FPE_FASTFPE is not set
-# CONFIG_VFP is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_AOUT=y
 # CONFIG_BINFMT_MISC is not set
@@ -118,13 +140,13 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_DEBUG_DRIVER is not set
-# CONFIG_PM is not set
+CONFIG_PM=y
 # CONFIG_PREEMPT is not set
+CONFIG_APM=y
 # CONFIG_ARTHUR is not set
-CONFIG_S3C2410_DMA=y
-# CONFIG_S3C2410_DMA_DEBUG is not set
 CONFIG_CMDLINE="root=/dev/hda1 ro init=/bin/bash console=ttySAC0"
 CONFIG_ALIGNMENT_TRAP=y
 
@@ -132,10 +154,7 @@
 # Parallel port support
 #
 CONFIG_PARPORT=y
-CONFIG_PARPORT_PC=y
-CONFIG_PARPORT_PC_CML1=y
-CONFIG_PARPORT_PC_FIFO=y
-CONFIG_PARPORT_PC_SUPERIO=y
+# CONFIG_PARPORT_PC is not set
 # CONFIG_PARPORT_ARC is not set
 CONFIG_PARPORT_OTHER=y
 CONFIG_PARPORT_1284=y
@@ -145,8 +164,13 @@
 #
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_PARTITIONS is not set
+CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
 
 #
 # User Modules And Translation Layers
@@ -161,12 +185,23 @@
 # RAM/ROM/Flash chip drivers
 #
 CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_JEDECPROBE=y
 CONFIG_MTD_GEN_PROBE=y
 # CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+CONFIG_MTD_MAP_BANK_WIDTH_16=y
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
 CONFIG_MTD_CFI_INTELEXT=y
 # CONFIG_MTD_CFI_AMDSTD is not set
 # CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_ABSENT is not set
@@ -179,11 +214,15 @@
 # CONFIG_MTD_PHYSMAP is not set
 # CONFIG_MTD_ARM_INTEGRATOR is not set
 # CONFIG_MTD_EDB7312 is not set
+# CONFIG_MTD_IMPA7 is not set
+CONFIG_MTD_BAST=y
+CONFIG_MTD_BAST_MAXSIZE=4
 
 #
 # Self-contained MTD device drivers
 #
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
 # CONFIG_MTD_BLKMTD is not set
 
@@ -197,7 +236,13 @@
 #
 # NAND Flash Device Drivers
 #
-# CONFIG_MTD_NAND is not set
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_IDS=y
+CONFIG_MTD_NAND_S3C2410=y
+# CONFIG_MTD_NAND_S3C2410_DEBUG is not set
+# CONFIG_MTD_NAND_S3C2410_HWECC is not set
+# CONFIG_MTD_NAND_DISKONCHIP is not set
 
 #
 # Plug and Play support
@@ -214,6 +259,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # Multi-device support (RAID and LVM)
@@ -246,6 +301,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -265,7 +323,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -338,13 +395,13 @@
 CONFIG_BLK_DEV_IDETAPE=m
 CONFIG_BLK_DEV_IDEFLOPPY=m
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
 #
 CONFIG_IDE_GENERIC=y
 # CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDE_BAST=y
 # CONFIG_BLK_DEV_IDEDMA is not set
 # CONFIG_IDEDMA_AUTO is not set
 # CONFIG_BLK_DEV_HD is not set
@@ -395,16 +452,16 @@
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
 CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
 #
 CONFIG_INPUT_KEYBOARD=y
-# CONFIG_KEYBOARD_ATKBD is not set
+CONFIG_KEYBOARD_ATKBD=y
 # CONFIG_KEYBOARD_SUNKBD is not set
 # CONFIG_KEYBOARD_LKKBD is not set
 # CONFIG_KEYBOARD_XTKBD is not set
@@ -431,8 +488,6 @@
 # CONFIG_DIGI 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_SYNCLINKMP is not set
 # CONFIG_N_HDLC is not set
 # CONFIG_RISCOM8 is not set
@@ -459,7 +514,7 @@
 #
 CONFIG_SERIAL_S3C2410=y
 CONFIG_SERIAL_S3C2410_CONSOLE=y
-# CONFIG_SERIAL_BAST_SIO is not set
+CONFIG_SERIAL_BAST_SIO=y
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
@@ -469,7 +524,6 @@
 # CONFIG_LP_CONSOLE is not set
 CONFIG_PPDEV=y
 # CONFIG_TIPAR is not set
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -479,18 +533,23 @@
 #
 # Watchdog Cards
 #
-# CONFIG_WATCHDOG is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_S3C2410_WATCHDOG=y
 # CONFIG_NVRAM is not set
-CONFIG_RTC=y
+# CONFIG_RTC is not set
+CONFIG_S3C2410_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
 # CONFIG_RAW_DRIVER is not set
 
@@ -505,35 +564,42 @@
 #
 CONFIG_I2C_ALGOBIT=m
 # CONFIG_I2C_ALGOPCF is not set
+# CONFIG_I2C_ALGOPCA is not set
 
 #
 # I2C Hardware Bus support
 #
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
 # CONFIG_I2C_ISA is not set
 # CONFIG_I2C_PARPORT is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_SCx200_ACB is not set
+CONFIG_I2C_S3C2410=y
+# CONFIG_I2C_STUB is not set
+# CONFIG_I2C_PCA_ISA is not set
 
 #
 # Hardware Sensors Chip support
 #
 CONFIG_I2C_SENSOR=m
 # CONFIG_SENSORS_ADM1021 is not set
+# CONFIG_SENSORS_ADM1025 is not set
+# CONFIG_SENSORS_ADM1031 is not set
 # CONFIG_SENSORS_ASB100 is not set
 # CONFIG_SENSORS_DS1621 is not set
 # CONFIG_SENSORS_FSCHER is not set
 # CONFIG_SENSORS_GL518SM is not set
 # CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM63 is not set
 CONFIG_SENSORS_LM75=m
+# CONFIG_SENSORS_LM77 is not set
 CONFIG_SENSORS_LM78=m
 # CONFIG_SENSORS_LM80 is not set
 # CONFIG_SENSORS_LM83 is not set
 CONFIG_SENSORS_LM85=m
+# CONFIG_SENSORS_LM87 is not set
 # CONFIG_SENSORS_LM90 is not set
 # CONFIG_SENSORS_MAX1619 is not set
-# CONFIG_SENSORS_VIA686A is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_W83781D is not set
 # CONFIG_SENSORS_W83L785TS is not set
 # CONFIG_SENSORS_W83627HF is not set
@@ -578,6 +644,7 @@
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -621,9 +688,14 @@
 # CONFIG_EFS_FS is not set
 CONFIG_JFFS_FS=y
 CONFIG_JFFS_FS_VERBOSE=0
+# CONFIG_JFFS_PROC_FS is not set
 CONFIG_JFFS2_FS=y
 CONFIG_JFFS2_FS_DEBUG=0
 # CONFIG_JFFS2_FS_NAND is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -644,6 +716,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -654,13 +727,7 @@
 # Partition Types
 #
 CONFIG_PARTITION_ADVANCED=y
-CONFIG_ACORN_PARTITION=y
-CONFIG_ACORN_PARTITION_CUMANA=y
-CONFIG_ACORN_PARTITION_EESOX=y
-CONFIG_ACORN_PARTITION_ICS=y
-CONFIG_ACORN_PARTITION_ADFS=y
-CONFIG_ACORN_PARTITION_POWERTEC=y
-CONFIG_ACORN_PARTITION_RISCIX=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
@@ -729,13 +796,14 @@
 # Graphics support
 #
 CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
 # CONFIG_FB_VIRTUAL is not set
 
 #
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 # CONFIG_FRAMEBUFFER_CONSOLE is not set
 
@@ -756,6 +824,9 @@
 #
 # USB support
 #
+# CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -763,17 +834,24 @@
 # CONFIG_USB_GADGET is not set
 
 #
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
 # Kernel hacking
 #
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
 CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
+# CONFIG_DEBUG_KOBJECT is not set
 # CONFIG_DEBUG_BUGVERBOSE is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_FRAME_POINTER=y
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
@@ -783,6 +861,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/arm/configs/brutus_defconfig b/arch/arm/configs/brutus_defconfig
--- a/arch/arm/configs/brutus_defconfig	2004-12-24 13:37:04 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,296 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_SBUS is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-CONFIG_SA1100_BRUTUS=y
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_THINCLIENT is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-CONFIG_ANGELBOOT=y
-# CONFIG_SA1100_FREQUENCY_SCALE is not set
-# CONFIG_SA1100_VOLTAGE_SCALE is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-CONFIG_CPU_32v4=y
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_PC_KEYMAP=y
-
-#
-# General setup
-#
-# CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-# CONFIG_NET is not set
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_NWFPE=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="mem=4M@0xc0000000 mem=4M@0xc8000000 mem=4M@0xd0000000 mem=4M@0xd8000000 keepinitrd root=/dev/ram ramdisk=8192 initrd=0xd8000000,3M"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_LVM is not set
-# CONFIG_BLK_DEV_MD is not set
-# CONFIG_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_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_BLK_DEV_FLASH is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE 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_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-# CONFIG_TOUCHSCREEN_UCB1200 is not set
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# 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=32
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
-
-#
-# Joysticks
-#
-# CONFIG_JOYSTICK is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_INTEL_RNG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-
-#
-# Video For Linux
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-
-#
-# File systems
-#
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS 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 is not set
-# 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_DEBUG 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
-# CONFIG_NCPFS_NLS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_NLS is not set
-
-#
-# Console drivers
-#
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-# CONFIG_FONT_8x16 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_LL is not set
diff -Nru a/arch/arm/configs/empeg_defconfig b/arch/arm/configs/empeg_defconfig
--- a/arch/arm/configs/empeg_defconfig	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,264 +0,0 @@
-#
-#
-# Example empeg-car kernel configuration file.
-#
-CONFIG_ARM=y
-
-#
-# System and processor type
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_FOOTBRIDGE is not set
-CONFIG_ARCH_SA1100=y
-CONFIG_CPU_SA1100=y
-# CONFIG_SA1100_BRUTUS is not set
-CONFIG_SA1100_EMPEG=y
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_EMPEG_HENRY is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_ARM2 is not set
-# CONFIG_CPU_ARM3 is not set
-# CONFIG_CPU_ARM6 is not set
-# CONFIG_CPU_ARM7 is not set
-CONFIG_CPU_SA110=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_ALIGNMENT_TRAP is not set
-# CONFIG_TEXT_SECTIONS is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODVERSIONS=y
-# CONFIG_KMOD is not set
-
-#
-# General setup
-#
-CONFIG_NET=y
-# CONFIG_SYSVIPC is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-# CONFIG_SYSCTL is not set
-CONFIG_NWFPE=y
-CONFIG_BINFMT_AOUT=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_ARTHUR is not set
-# CONFIG_PARPORT is not set
-CONFIG_CMDLINE="mem=4M@0xc0000000 mem=4M@0xc8000000 root=/dev/hda1 initrd=0xd00b0000,320K"
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_IDE=y
-# CONFIG_BLK_DEV_HD_IDE is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_MD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_BLK_DEV_XD is not set
-CONFIG_PARIDE_PARPORT=y
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_UNIX98_PTYS is not set
-# CONFIG_MOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-CONFIG_EMPEG_IR=y
-CONFIG_EMPEG_USB=y
-
-#
-# Video For Linux
-#
-CONFIG_VIDEO_DEV=y
-# CONFIG_RADIO_RTRACK is not set
-# CONFIG_RADIO_RTRACK2 is not set
-# CONFIG_RADIO_AZTECH is not set
-# CONFIG_RADIO_CADET is not set
-# CONFIG_RADIO_MIROPCM20 is not set
-# CONFIG_RADIO_GEMTEK is not set
-CONFIG_RADIO_EMPEG=y
-# CONFIG_VIDEO_BT848 is not set
-# CONFIG_VIDEO_PMS is not set
-# CONFIG_VIDEO_SAA5249 is not set
-# CONFIG_RADIO_SF16FMI is not set
-# CONFIG_RADIO_TYPHOON is not set
-# CONFIG_RADIO_ZOLTRIX is not set
-
-#
-# Joystick support
-#
-# CONFIG_JOYSTICK is not set
-# CONFIG_DTLK is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK is not set
-# CONFIG_FIREWALL is not set
-# CONFIG_FILTER is not set
-# CONFIG_UNIX is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-# CONFIG_IP_PNP is not set
-# CONFIG_IP_ROUTER is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_ALIAS is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_RARP is not set
-# CONFIG_SKB_LARGE is not set
-# CONFIG_IPV6 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_LLC is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-# CONFIG_CPU_IS_SLOW is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA subsystem support
-#
-# CONFIG_IRDA is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_NET_ETHERNET is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_DLCI is not set
-CONFIG_PPP=y
-# CONFIG_SLIP is not set
-# CONFIG_NET_RADIO is not set
-# CONFIG_TR is not set
-# CONFIG_SHAPER is not set
-# CONFIG_HOSTESS_SV11 is not set
-# CONFIG_COSA is not set
-# CONFIG_RCPCI is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# Filesystems
-#
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_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_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-# CONFIG_CODA_FS is not set
-# CONFIG_NFS_FS is not set
-# CONFIG_NFSD is not set
-# CONFIG_SUNRPC is not set
-# CONFIG_LOCKD is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_NCP_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_NLS is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_USER_BACKTRACE=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_LL is not set
diff -Nru a/arch/arm/configs/ep80219_defconfig b/arch/arm/configs/ep80219_defconfig
--- a/arch/arm/configs/ep80219_defconfig	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/configs/ep80219_defconfig	2004-12-24 13:36:47 -08:00
@@ -1,10 +1,13 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3
+# Wed Dec 15 17:03:41 2004
 #
 CONFIG_ARM=y
 CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
@@ -16,6 +19,7 @@
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +29,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,6 +52,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -59,6 +67,7 @@
 # CONFIG_ARCH_INTEGRATOR is not set
 CONFIG_ARCH_IOP3XX=y
 # CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
 # CONFIG_ARCH_L7200 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
@@ -67,7 +76,9 @@
 # CONFIG_ARCH_SHARK is not set
 # CONFIG_ARCH_LH7A40X is not set
 # CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_H720X is not set
 
 #
 # IOP3xx Implementation Options
@@ -94,6 +105,7 @@
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
+CONFIG_CPU_CACHE_VIVT=y
 CONFIG_CPU_TLB_V4WBI=y
 CONFIG_CPU_MINICACHE=y
 
@@ -110,6 +122,7 @@
 # CONFIG_ZBOOT_ROM is not set
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_XIP_KERNEL is not set
 # CONFIG_PCI_LEGACY_PROC is not set
 CONFIG_PCI_NAMES=y
 
@@ -119,7 +132,6 @@
 CONFIG_FPE_NWFPE=y
 # CONFIG_FPE_NWFPE_XP is not set
 # CONFIG_FPE_FASTFPE is not set
-# CONFIG_VFP is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_AOUT=y
 # CONFIG_BINFMT_MISC is not set
@@ -148,8 +160,8 @@
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_REDBOOT_PARTS=y
-# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
-# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+CONFIG_MTD_REDBOOT_PARTS_READONLY=y
 # CONFIG_MTD_CMDLINE_PARTS is not set
 # CONFIG_MTD_AFS_PARTS is not set
 
@@ -191,7 +203,10 @@
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=0xf0000000
+CONFIG_MTD_PHYSMAP_LEN=0x00800000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
 # CONFIG_MTD_ARM_INTEGRATOR is not set
 # CONFIG_MTD_EDB7312 is not set
 
@@ -232,8 +247,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=8192
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # Multi-device support (RAID and LVM)
@@ -243,9 +269,11 @@
 # CONFIG_MD_LINEAR is not set
 CONFIG_MD_RAID0=y
 CONFIG_MD_RAID1=y
+# CONFIG_MD_RAID10 is not set
 CONFIG_MD_RAID5=y
 # CONFIG_MD_RAID6 is not set
 # CONFIG_MD_MULTIPATH is not set
+# CONFIG_MD_FAULTY is not set
 CONFIG_BLK_DEV_DM=y
 # CONFIG_DM_CRYPT is not set
 # CONFIG_DM_SNAPSHOT is not set
@@ -280,6 +308,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -299,7 +330,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -362,7 +392,6 @@
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -375,6 +404,7 @@
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 # CONFIG_TIGON3 is not set
 
 #
@@ -449,7 +479,8 @@
 # CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_AIC79XX is not set
 # CONFIG_SCSI_DPT_I2O is not set
-# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
 # CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_BUSLOGIC is not set
 # CONFIG_SCSI_DMX3191D is not set
@@ -458,6 +489,7 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR is not set
@@ -519,7 +551,6 @@
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
 # CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
 
 #
 # Input Device Drivers
@@ -554,7 +585,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -567,7 +597,6 @@
 # CONFIG_WATCHDOG is not set
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
@@ -575,7 +604,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
@@ -590,6 +618,7 @@
 #
 # CONFIG_I2C_ALGOBIT is not set
 # CONFIG_I2C_ALGOPCF is not set
+# CONFIG_I2C_ALGOPCA is not set
 
 #
 # I2C Hardware Bus support
@@ -612,9 +641,11 @@
 # CONFIG_I2C_SIS5595 is not set
 # CONFIG_I2C_SIS630 is not set
 # CONFIG_I2C_SIS96X is not set
+# CONFIG_I2C_STUB is not set
 # CONFIG_I2C_VIA is not set
 # CONFIG_I2C_VIAPRO is not set
 # CONFIG_I2C_VOODOO3 is not set
+# CONFIG_I2C_PCA_ISA is not set
 
 #
 # Hardware Sensors Chip support
@@ -622,20 +653,25 @@
 # CONFIG_I2C_SENSOR is not set
 # CONFIG_SENSORS_ADM1021 is not set
 # CONFIG_SENSORS_ADM1025 is not set
+# CONFIG_SENSORS_ADM1026 is not set
 # CONFIG_SENSORS_ADM1031 is not set
 # CONFIG_SENSORS_ASB100 is not set
 # CONFIG_SENSORS_DS1621 is not set
 # CONFIG_SENSORS_FSCHER is not set
 # CONFIG_SENSORS_GL518SM is not set
 # CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM63 is not set
 # CONFIG_SENSORS_LM75 is not set
 # CONFIG_SENSORS_LM77 is not set
 # CONFIG_SENSORS_LM78 is not set
 # CONFIG_SENSORS_LM80 is not set
 # CONFIG_SENSORS_LM83 is not set
 # CONFIG_SENSORS_LM85 is not set
+# CONFIG_SENSORS_LM87 is not set
 # CONFIG_SENSORS_LM90 is not set
 # CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_VIA686A is not set
 # CONFIG_SENSORS_W83781D is not set
 # CONFIG_SENSORS_W83L785TS is not set
@@ -685,6 +721,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -709,6 +746,7 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -754,6 +792,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -799,7 +838,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -815,6 +853,12 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
 
 #
 # USB Gadget Support
@@ -822,16 +866,22 @@
 # CONFIG_USB_GADGET is not set
 
 #
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
+# CONFIG_DEBUG_INFO is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/arm/configs/flexanet_defconfig b/arch/arm/configs/flexanet_defconfig
--- a/arch/arm/configs/flexanet_defconfig	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,895 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-# CONFIG_GENERIC_BUST_SPINLOCK is not set
-# CONFIG_GENERIC_ISA_DMA is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_ADSBITSY is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_H3600 is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-CONFIG_SA1100_FLEXANET=y
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHANNON is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-CONFIG_SA1100_USB=y
-CONFIG_SA1100_USB_NETLINK=y
-# CONFIG_SA1100_USB_CHAR is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_AUTCPU12 is not set
-# CONFIG_ARCH_CDB89712 is not set
-# CONFIG_ARCH_CLEP7312 is not set
-# CONFIG_ARCH_EDB7211 is not set
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_EP7211 is not set
-# CONFIG_ARCH_EP7212 is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM922T is not set
-# CONFIG_CPU_ARM926T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-# CONFIG_ARM_THUMB is not set
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-CONFIG_ISA=y
-# CONFIG_ISA_DMA is not set
-CONFIG_CPU_FREQ=y
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_I82092 is not set
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=y
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-
-#
-# At least one math emulation must be selected
-#
-CONFIG_FPE_NWFPE=y
-CONFIG_FPE_FASTFPE=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_PM=y
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="mem=64M root=/dev/ram initrd=0xc0800000,3M"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-CONFIG_MTD_REDBOOT_PARTS=y
-# CONFIG_MTD_BOOTLDR_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-# CONFIG_MTD_CHAR is not set
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-CONFIG_MTD_CFI_ADV_OPTIONS=y
-CONFIG_MTD_CFI_NOSWAP=y
-# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_GEOMETRY is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-# CONFIG_MTD_AMDSTD is not set
-# CONFIG_MTD_SHARP is not set
-# CONFIG_MTD_JEDEC is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-# CONFIG_MTD_CDB89712 is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-# CONFIG_MTD_PCI is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD 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
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-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_MD_MULTIPATH 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=y
-# 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_VLAN_8021Q 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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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_ARM_AM79C961A is not set
-# 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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRAMCA is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=y
-# 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_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=y
-# CONFIG_STRIP is not set
-# CONFIG_WAVELAN is not set
-# CONFIG_ARLAN is not set
-# CONFIG_AIRONET4500 is not set
-# CONFIG_AIRONET4500_NONCS is not set
-# CONFIG_AIRONET4500_PROC is not set
-# CONFIG_AIRO is not set
-CONFIG_HERMES=m
-
-#
-# Wireless Pcmcia cards support
-#
-CONFIG_PCMCIA_HERMES=m
-# CONFIG_AIRO_CS is not set
-CONFIG_NET_WIRELESS=y
-
-#
-# 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=y
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-#
-# 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN 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
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_UART00 is not set
-# CONFIG_SERIAL_UART00_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=57600
-# CONFIG_SERIAL_8250 is not set
-# CONFIG_SERIAL_8250_CONSOLE is not set
-# CONFIG_SERIAL_8250_EXTENDED is not set
-# CONFIG_SERIAL_8250_MANY_PORTS is not set
-# CONFIG_SERIAL_8250_SHARE_IRQ is not set
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_MULTIPORT is not set
-# CONFIG_SERIAL_8250_HUB6 is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# L3 serial bus support
-#
-# CONFIG_L3 is not set
-# CONFIG_L3_ALGOBIT is not set
-# CONFIG_L3_BIT_SA1100_GPIO is not set
-
-#
-# Other L3 adapters
-#
-# CONFIG_L3_SA1111 is not set
-# CONFIG_BIT_SA1100_GPIO 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_SA1100_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
-
-#
-# PCMCIA character devices
-#
-
-#
-# 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_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=y
-CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_CRAMFS is not set
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# CONFIG_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG 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
-# CONFIG_ZISOFS_FS is not set
-# CONFIG_ZLIB_FS_INFLATE 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 is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_SMB_NLS is not set
-# CONFIG_NLS is not set
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
-# CONFIG_FBCON_FONTS is not set
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-
-#
-# Sound
-#
-CONFIG_SOUND=y
-# 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
-# CONFIG_SOUND_ES1371 is not set
-# CONFIG_SOUND_ESSSOLO1 is not set
-# 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
-# CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_VIA82CXXX is not set
-# CONFIG_MIDI_VIA82CXXX is not set
-# CONFIG_SOUND_SA1100 is not set
-# CONFIG_SOUND_UDA1341 is not set
-# CONFIG_SOUND_ASSABET_UDA1341 is not set
-# CONFIG_SOUND_H3600_UDA1341 is not set
-# CONFIG_SOUND_PANGOLIN_UDA1341 is not set
-# CONFIG_SOUND_SA1111_UDA1341 is not set
-# CONFIG_SOUND_SA1100SSP is not set
-# CONFIG_SOUND_OSS is not set
-# CONFIG_SOUND_WAVEARTIST is not set
-# CONFIG_SOUND_TVMIXER is not set
-
-#
-# Multimedia Capabilities Port drivers
-#
-# CONFIG_MCP is not set
-# CONFIG_MCP_SA1100 is not set
-# CONFIG_MCP_UCB1200 is not set
-# CONFIG_MCP_UCB1200_AUDIO is not set
-# CONFIG_MCP_UCB1200_TS 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
-# CONFIG_USB_OHCI_SA1111 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_ISD200 is not set
-# CONFIG_USB_STORAGE_DPCM is not set
-# CONFIG_USB_STORAGE_HP8200e is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT 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
-#
-
-#
-# USB Network adaptors
-#
-# 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_IR 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_USA28XA is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XB 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_XIRCOM is not set
-# CONFIG_USB_SERIAL_OMNINET is not set
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_RIO500 is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_NO_PGT_CACHE is not set
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_BUGVERBOSE is not set
-# CONFIG_DEBUG_ERRORS is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/freebird_defconfig b/arch/arm/configs/freebird_defconfig
--- a/arch/arm/configs/freebird_defconfig	2004-12-24 13:36:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,614 +0,0 @@
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-CONFIG_SA1100_FREEBIRD=y
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_PFS168 is not set
-CONFIG_SA1100_FREEBIRD_OLD=y
-# CONFIG_SA1100_FREEBIRD_NEW is not set
-CONFIG_SA1100_FL=y
-CONFIG_SA1100_USB=m
-CONFIG_SA1100_USB_NETLINK=m
-CONFIG_SA1100_USB_CHAR=m
-# CONFIG_SA1100_FREQUENCY_SCALE is not set
-# CONFIG_SA1100_VOLTAGE_SCALE is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-# CONFIG_ANGELBOOT is not set
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=y
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_FPE_NWFPE is not set
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=m
-CONFIG_BINFMT_ELF=y
-CONFIG_BINFMT_MISC=m
-CONFIG_PM=y
-CONFIG_APM=y
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="mem=32M root=/dev/ram initrd=0xc0800000,3M"
-# CONFIG_PFS168_CMDLINE is not set
-# CONFIG_LEDS is not set
-CONFIG_ALIGNMENT_TRAP=y
-# CONFIG_UCB1200 is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_DOC1000 is not set
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_MTDRAM is not set
-CONFIG_MTD_CFI=y
-# 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_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_SBC_MEDIAGX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-# CONFIG_MTD_CSTM_CFI_JEDEC is not set
-# CONFIG_MTD_JEDEC is not set
-# CONFIG_MTD_MIXMEM is not set
-# CONFIG_MTD_OCTAGON is not set
-# CONFIG_MTD_VMAX is not set
-# CONFIG_MTD_NAND is not set
-# CONFIG_MTD_NAND_SPIA is not set
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=m
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-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=y
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# 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_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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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 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=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-CONFIG_PPP_BSDCOMP=m
-# CONFIG_PPPOE 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-CONFIG_IRDA=m
-# CONFIG_IRLAN is not set
-# CONFIG_IRNET is not set
-# CONFIG_IRCOMM is not set
-# CONFIG_IRDA_ULTRA is not set
-# CONFIG_IRDA_OPTIONS is not set
-
-#
-# Infrared-port device drivers
-#
-CONFIG_IRTTY_SIR=m
-# CONFIG_IRPORT_SIR is not set
-# CONFIG_NSC_FIR is not set
-# CONFIG_WINBOND_FIR is not set
-# CONFIG_TOSHIBA_FIR is not set
-# CONFIG_SMC_IRCC_FIR is not set
-CONFIG_SA1100_FIR=m
-# CONFIG_DONGLE is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=m
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=9600
-# CONFIG_TOUCHSCREEN_UCB1200 is not set
-# CONFIG_TOUCHSCREEN_BITSY is not set
-CONFIG_FB_TS_BT=y
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-# CONFIG_PFS168_DTMF is not set
-# CONFIG_PFS168_MISC is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
-
-#
-# Joysticks
-#
-# CONFIG_JOYSTICK is not set
-# 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_SA1100_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
-# CONFIG_PCMCIA_SERIAL 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_JFFS2_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_DEBUG 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 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_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
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_SUN12x22 is not set
-# CONFIG_FONT_6x11 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-CONFIG_SOUND=y
-CONFIG_SOUND_UDA1341=y
-# CONFIG_SOUND_UDA1341_GSM is not set
-# CONFIG_SOUND_SA1100_SSP is not set
-# CONFIG_SOUND_CMPCI is not set
-# CONFIG_SOUND_EMU10K1 is not set
-# CONFIG_SOUND_FUSION is not set
-# CONFIG_SOUND_CS4281 is not set
-# CONFIG_SOUND_ES1370 is not set
-# CONFIG_SOUND_ES1371 is not set
-# CONFIG_SOUND_ESSSOLO1 is not set
-# CONFIG_SOUND_MAESTRO is not set
-# CONFIG_SOUND_MAESTRO3 is not set
-# CONFIG_SOUND_ICH is not set
-# CONFIG_SOUND_SONICVIBES is not set
-# CONFIG_SOUND_TRIDENT is not set
-# CONFIG_SOUND_MSNDCLAS is not set
-# CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_VIA82CXXX is not set
-# CONFIG_SOUND_OSS is not set
-# CONFIG_SOUND_TVMIXER is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_NO_PGT_CACHE is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/freebird_new_defconfig b/arch/arm/configs/freebird_new_defconfig
--- a/arch/arm/configs/freebird_new_defconfig	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,634 +0,0 @@
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-CONFIG_SA1100_FREEBIRD=y
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_FREEBIRD_OLD is not set
-CONFIG_SA1100_FREEBIRD_NEW=y
-CONFIG_SA1100_FL=m
-CONFIG_SA1100_USB=m
-CONFIG_SA1100_USB_NETLINK=m
-CONFIG_SA1100_USB_CHAR=m
-CONFIG_SA1100_FREQUENCY_SCALE=y
-# CONFIG_SA1100_VOLTAGE_SCALE is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-# CONFIG_ANGELBOOT is not set
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=m
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_FPE_NWFPE is not set
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_PM=y
-CONFIG_APM=y
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="noinitrd console=ttySA0 init=/linuxrc root=/dev/mtdblock4 mem=32m"
-# CONFIG_PFS168_CMDLINE is not set
-# CONFIG_LEDS is not set
-CONFIG_ALIGNMENT_TRAP=y
-# CONFIG_UCB1200 is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_DOC1000 is not set
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_MTDRAM is not set
-CONFIG_MTD_CFI=y
-# 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_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_SBC_MEDIAGX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-# CONFIG_MTD_CSTM_CFI_JEDEC is not set
-# CONFIG_MTD_JEDEC is not set
-# CONFIG_MTD_MIXMEM is not set
-# CONFIG_MTD_OCTAGON is not set
-# CONFIG_MTD_VMAX is not set
-# CONFIG_MTD_NAND is not set
-# CONFIG_MTD_NAND_SPIA is not set
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=m
-# 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=y
-CONFIG_RTNETLINK=y
-# CONFIG_NETLINK_DEV is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG 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 is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-
-#
-#   IP: Netfilter Configuration
-#
-# CONFIG_IP_NF_CONNTRACK is not set
-# CONFIG_IP_NF_QUEUE is not set
-# CONFIG_IP_NF_IPTABLES is not set
-# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
-# CONFIG_IP_NF_COMPAT_IPFWADM 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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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_ETHERTAP is not set
-# CONFIG_NET_SB1000 is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-# CONFIG_NET_ETHERNET 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=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-CONFIG_PPP_BSDCOMP=m
-# CONFIG_PPPOE 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-CONFIG_IRDA=m
-# CONFIG_IRLAN is not set
-# CONFIG_IRNET is not set
-# CONFIG_IRCOMM is not set
-# CONFIG_IRDA_ULTRA is not set
-# CONFIG_IRDA_OPTIONS is not set
-
-#
-# Infrared-port device drivers
-#
-# CONFIG_IRTTY_SIR is not set
-# CONFIG_IRPORT_SIR is not set
-# CONFIG_NSC_FIR is not set
-# CONFIG_WINBOND_FIR is not set
-# CONFIG_TOSHIBA_FIR is not set
-# CONFIG_SMC_IRCC_FIR is not set
-CONFIG_SA1100_FIR=m
-# CONFIG_DONGLE is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=m
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=m
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=m
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-CONFIG_SERIAL=m
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=9600
-# CONFIG_TOUCHSCREEN_UCB1200 is not set
-# CONFIG_TOUCHSCREEN_BITSY is not set
-CONFIG_FB_TS_BT=y
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-# CONFIG_PFS168_DTMF is not set
-# CONFIG_PFS168_MISC is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
-
-#
-# Joysticks
-#
-# CONFIG_JOYSTICK is not set
-# 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_SA1100_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
-CONFIG_PCMCIA_SERIAL=m
-
-#
-# PCMCIA character device support
-#
-CONFIG_PCMCIA_SERIAL_CS=m
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# File systems
-#
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=m
-# 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=m
-CONFIG_JFFS_FS_VERBOSE=0
-# CONFIG_JFFS2_FS is not set
-CONFIG_CRAMFS=y
-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_DEBUG 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=m
-# 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=m
-# 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=m
-CONFIG_LOCKD=m
-# 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
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_SUN12x22 is not set
-# CONFIG_FONT_6x11 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-CONFIG_SOUND=y
-CONFIG_SOUND_UDA1341=y
-# CONFIG_SOUND_UDA1341_GSM is not set
-# CONFIG_SOUND_SA1100_SSP is not set
-# CONFIG_SOUND_CMPCI is not set
-# CONFIG_SOUND_EMU10K1 is not set
-# CONFIG_SOUND_FUSION is not set
-# CONFIG_SOUND_CS4281 is not set
-# CONFIG_SOUND_ES1370 is not set
-# CONFIG_SOUND_ES1371 is not set
-# CONFIG_SOUND_ESSSOLO1 is not set
-# CONFIG_SOUND_MAESTRO is not set
-# CONFIG_SOUND_MAESTRO3 is not set
-# CONFIG_SOUND_ICH is not set
-# CONFIG_SOUND_SONICVIBES is not set
-# CONFIG_SOUND_TRIDENT is not set
-# CONFIG_SOUND_MSNDCLAS is not set
-# CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_VIA82CXXX is not set
-# CONFIG_SOUND_OSS is not set
-# CONFIG_SOUND_TVMIXER is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-# CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_INFO is not set
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_NO_PGT_CACHE is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/graphicsclient_defconfig b/arch/arm/configs/graphicsclient_defconfig
--- a/arch/arm/configs/graphicsclient_defconfig	2004-12-24 13:37:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,729 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-CONFIG_SA1100_GRAPHICSCLIENT=y
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-# CONFIG_SA1100_ADSBITSY is not set
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-# CONFIG_CPU_BIG_ENDIAN is not set
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=y
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_APM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="ip=off mem=16M@0xc0000000 mem=16M@0xc8000000 root=/dev/ram initrd=0xc0800000,4M"
-# CONFIG_PFS168_CMDLINE is not set
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_BOOTLDR_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# 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=800000
-CONFIG_MTD_PHYSMAP_LEN=1000000
-CONFIG_MTD_PHYSMAP_BUSWIDTH=4
-# CONFIG_MTD_SUN_UFLASH is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_TQM8XXL is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_NETSC520 is not set
-# CONFIG_MTD_SBC_GXX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_SA1100_REDBOOT_PARTITIONS is not set
-# CONFIG_MTD_SA1100_BOOTLDR_PARTITIONS is not set
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 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_ARM_INTEGRATOR is not set
-# CONFIG_MTD_SOLUTIONENGINE 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
-# CONFIG_MTD_L440GX is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_LART is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD 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
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-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=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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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_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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRAMCA is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=y
-# 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_ACENIC_OMIT_TIGON_I is not set
-# CONFIG_MYRI_SBUS 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=y
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=38400
-# CONFIG_SERIAL_8250 is not set
-# CONFIG_SERIAL_8250_CONSOLE is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-CONFIG_UCB1200=y
-CONFIG_TOUCHSCREEN_UCB1200=y
-CONFIG_AUDIO_UCB1200=y
-CONFIG_ADC_UCB1200=y
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-# CONFIG_PFS168_DTMF is not set
-# CONFIG_PFS168_MISC 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_SA1100_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
-
-#
-# PCMCIA character devices
-#
-
-#
-# 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=y
-# CONFIG_MSDOS_FS is not set
-# CONFIG_UMSDOS_FS is not set
-CONFIG_VFAT_FS=y
-# CONFIG_EFS_FS is not set
-CONFIG_JFFS_FS=y
-CONFIG_JFFS_FS_VERBOSE=0
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-CONFIG_CRAMFS=y
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# 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_DEBUG 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_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=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_E1355 is not set
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-# CONFIG_FONT_8x8 is not set
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_NO_PGT_CACHE is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/graphicsmaster_defconfig b/arch/arm/configs/graphicsmaster_defconfig
--- a/arch/arm/configs/graphicsmaster_defconfig	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,742 +0,0 @@
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-CONFIG_SA1100_GRAPHICSMASTER=y
-# CONFIG_SA1100_ADSBITSY is not set
-CONFIG_SA1111=y
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-# CONFIG_CPU_BIG_ENDIAN is not set
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=y
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_APM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="ip=off mem=16M@0xc0000000 mem=16M@0xc8000000 root=/dev/ram initrd=0xc0800000,4M"
-# CONFIG_PFS168_CMDLINE is not set
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_BOOTLDR_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# 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=800000
-CONFIG_MTD_PHYSMAP_LEN=1000000
-CONFIG_MTD_PHYSMAP_BUSWIDTH=4
-# CONFIG_MTD_SUN_UFLASH is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_TQM8XXL is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_NETSC520 is not set
-# CONFIG_MTD_SBC_GXX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_SA1100_REDBOOT_PARTITIONS is not set
-# CONFIG_MTD_SA1100_BOOTLDR_PARTITIONS is not set
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 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_ARM_INTEGRATOR is not set
-# CONFIG_MTD_SOLUTIONENGINE 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
-# CONFIG_MTD_L440GX is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_LART is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-# 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
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-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=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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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_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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRAMCA is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=y
-# 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_ACENIC_OMIT_TIGON_I is not set
-# CONFIG_MYRI_SBUS 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=y
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-CONFIG_INPUT=y
-# CONFIG_INPUT_KEYBDEV is not set
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=640
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=480
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=38400
-# CONFIG_SERIAL_8250 is not set
-# CONFIG_SERIAL_8250_CONSOLE is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-CONFIG_UCB1200=y
-CONFIG_TOUCHSCREEN_UCB1200=y
-CONFIG_AUDIO_UCB1200=y
-CONFIG_ADC_UCB1200=y
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-# CONFIG_PFS168_DTMF is not set
-# CONFIG_PFS168_MISC 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
-# 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_SA1100_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
-
-#
-# PCMCIA character devices
-#
-
-#
-# 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=y
-# CONFIG_MSDOS_FS is not set
-# CONFIG_UMSDOS_FS is not set
-CONFIG_VFAT_FS=y
-# CONFIG_EFS_FS is not set
-CONFIG_JFFS_FS=y
-CONFIG_JFFS_FS_VERBOSE=0
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-CONFIG_CRAMFS=y
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# 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_DEBUG 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_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=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_E1355 is not set
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-# CONFIG_FONT_8x8 is not set
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB=y
-# CONFIG_USB_DEBUG is not set
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-CONFIG_USB_OHCI=y
-CONFIG_USB_OHCI_NOPCI=y
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_STORAGE is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-# CONFIG_USB_HID is not set
-# CONFIG_USB_KBD is not set
-CONFIG_USB_MOUSE=y
-# CONFIG_USB_WACOM is not set
-# 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_IBMCAM is not set
-# CONFIG_USB_OV511 is not set
-# CONFIG_USB_PWC is not set
-# CONFIG_USB_SE401 is not set
-# CONFIG_USB_DSBR is not set
-# CONFIG_USB_DABUSB is not set
-# 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_USBNET is not set
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-# CONFIG_USB_RIO500 is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_NO_PGT_CACHE is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/huw_webpanel_defconfig b/arch/arm/configs/huw_webpanel_defconfig
--- a/arch/arm/configs/huw_webpanel_defconfig	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,434 +0,0 @@
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Footbridge Implementations
-#
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-CONFIG_SA1100_HUW_WEBPANEL=y
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_FREQUENCY_SCALE is not set
-# CONFIG_SA1100_VOLTAGE_SCALE is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-CONFIG_CPU_32v4=y
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-# CONFIG_ANGELBOOT is not set
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-# CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_NWFPE=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="keepinitrd mem=32480K root=/dev/ram initrd=0xc0800000,8M"
-# CONFIG_LEDS is not set
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_DOC1000 is not set
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_MTDRAM is not set
-CONFIG_MTD_CFI=y
-CONFIG_MTD_CFI_GEOMETRY=y
-# CONFIG_MTD_CFI_B1 is not set
-# CONFIG_MTD_CFI_B2 is not set
-CONFIG_MTD_CFI_B4=y
-# CONFIG_MTD_CFI_I1 is not set
-CONFIG_MTD_CFI_I2=y
-# CONFIG_MTD_CFI_I4 is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_SHARP is not set
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SBC_MEDIAGX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_JEDEC is not set
-# CONFIG_MTD_MIXMEM is not set
-# CONFIG_MTD_OCTAGON is not set
-# CONFIG_MTD_VMAX is not set
-# CONFIG_MTD_NAND is not set
-# CONFIG_MTD_NAND_SPIA is not set
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_BLK_DEV_FLASH 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 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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network device support
-#
-# CONFIG_NETDEVICES is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=115200
-CONFIG_TOUCHSCREEN_UCB1200=y
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# CONFIG_PROFILER is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
-
-#
-# Joysticks
-#
-# CONFIG_JOYSTICK is not set
-# 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_SA1100_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_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=y
-# CONFIG_RAMFS is not set
-# 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_DEBUG 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=y
-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_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_MOUNT_SUBDIR is not set
-# CONFIG_NCPFS_NDS_DOMAINS 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_NLS is not set
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-# CONFIG_FONT_8x16 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_DEBUG_LL is not set
diff -Nru a/arch/arm/configs/integrator_defconfig b/arch/arm/configs/integrator_defconfig
--- a/arch/arm/configs/integrator_defconfig	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/configs/integrator_defconfig	2004-12-24 13:36:18 -08:00
@@ -1,139 +1,167 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3
+# Mon Dec 20 16:08:21 2004
 #
 CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
+CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
 #
 CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
 
 #
 # System Type
 #
-# CONFIG_ARCH_ARCA5K is not set
 # CONFIG_ARCH_CLPS7500 is not set
+# CONFIG_ARCH_CLPS711X is not set
 # CONFIG_ARCH_CO285 is not set
 # CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_CAMELOT is not set
 # CONFIG_ARCH_FOOTBRIDGE is not set
 CONFIG_ARCH_INTEGRATOR=y
+# CONFIG_ARCH_IOP3XX is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
 # CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_S3C2410 is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_LH7A40X is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_H720X is not set
 
 #
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
+# Integrator Options
+#
+CONFIG_ARCH_INTEGRATOR_AP=y
+# CONFIG_ARCH_INTEGRATOR_CP is not set
+# CONFIG_INTEGRATOR_IMPD1 is not set
 
 #
 # Processor Type
 #
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
+CONFIG_CPU_32=y
 CONFIG_CPU_ARM720T=y
 CONFIG_CPU_ARM920T=y
-CONFIG_CPU_ARM920_CPU_IDLE=y
-CONFIG_CPU_ARM920_I_CACHE_ON=y
-CONFIG_CPU_ARM920_D_CACHE_ON=y
-# CONFIG_CPU_ARM920_WRITETHROUGH is not set
+# CONFIG_CPU_ARM926T is not set
 # CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-# CONFIG_CPU_SA1100 is not set
-# CONFIG_DISCONTIGMEM is not set
+# CONFIG_CPU_ARM1022 is not set
+# CONFIG_CPU_ARM1026 is not set
+# CONFIG_CPU_V6 is not set
+CONFIG_CPU_32v4=y
+CONFIG_CPU_ABRT_EV4T=y
+CONFIG_CPU_ABRT_LV4T=y
+CONFIG_CPU_CACHE_V4=y
+CONFIG_CPU_CACHE_V4WT=y
+CONFIG_CPU_CACHE_VIVT=y
+CONFIG_CPU_COPY_V4WT=y
+CONFIG_CPU_COPY_V4WB=y
+CONFIG_CPU_TLB_V4WT=y
+CONFIG_CPU_TLB_V4WBI=y
+
+#
+# Processor Features
+#
+CONFIG_ARM_THUMB=y
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
 
 #
 # General setup
 #
-CONFIG_PCI_INTEGRATOR=y
 CONFIG_PCI=y
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_CPU_CLOCK=y
+CONFIG_ICST525=y
+CONFIG_ARM_AMBA=y
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_XIP_KERNEL is not set
+CONFIG_CPU_FREQ=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+# CONFIG_CPU_FREQ_PROC_INTF is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=y
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+# CONFIG_CPU_FREQ_24_API is not set
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_INTEGRATOR=y
+CONFIG_PCI_LEGACY_PROC=y
 CONFIG_PCI_NAMES=y
-# CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_FPE_NWFPE is not set
-CONFIG_FPE_FASTFPE=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
+
+#
+# At least one math emulation must be selected
+#
+CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
+# CONFIG_FPE_FASTFPE is not set
 CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
 CONFIG_PM=y
+# CONFIG_PREEMPT is not set
+# CONFIG_APM is not set
 # CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="root=1f03 mem=32M"
+CONFIG_CMDLINE="console=ttyAM0,38400n8 root=/dev/nfs ip=bootp mem=32M"
 CONFIG_LEDS=y
 CONFIG_LEDS_TIMER=y
 CONFIG_LEDS_CPU=y
@@ -150,8 +178,9 @@
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
 CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_CONCAT is not set
 # CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_BOOTLDR_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_AFS_PARTS=y
 
 #
@@ -161,259 +190,264 @@
 CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
 # CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
 
 #
 # RAM/ROM/Flash chip drivers
 #
 CONFIG_MTD_CFI=y
-# CONFIG_MTD_CFI_VIRTUAL_ER is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
 CONFIG_MTD_CFI_ADV_OPTIONS=y
 CONFIG_MTD_CFI_NOSWAP=y
 # CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
 # CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_LART_BIT_SWAP is not set
 # CONFIG_MTD_CFI_GEOMETRY is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 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_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
-# CONFIG_MTD_JEDEC is not set
+# CONFIG_MTD_ABSENT is not set
 
 #
 # Mapping drivers for chip access
 #
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
 # CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_SUN_UFLASH is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_NETSC520 is not set
-# CONFIG_MTD_SBC_GXX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-# CONFIG_MTD_SA1100 is not set
-# CONFIG_MTD_SA1100_REDBOOT_PARTITIONS is not set
-# CONFIG_MTD_SA1100_BOOTLDR_PARTITIONS is not set
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 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_ARMFLASH=y
+# CONFIG_MTD_ARM_INTEGRATOR is not set
+# CONFIG_MTD_EDB7312 is not set
 
 #
 # Self-contained MTD device drivers
 #
 # CONFIG_MTD_PMC551 is not set
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLKMTD 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
+# CONFIG_MTD_DOC2001PLUS is not set
 
 #
 # NAND Flash Device Drivers
 #
 # CONFIG_MTD_NAND is not set
-# CONFIG_MTD_NAND_SPIA is not set
 
 #
-# Plug and Play configuration
+# Plug and Play support
 #
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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_UMEM is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
 CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=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 support
+#
+CONFIG_NET=y
 
 #
 # Networking options
 #
 CONFIG_PACKET=y
 CONFIG_PACKET_MMAP=y
-CONFIG_NETLINK=y
-# CONFIG_RTNETLINK is not set
 # CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_FILTER is not set
 CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
 CONFIG_INET=y
 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_DHCP=y
 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_INET_ECN=y
+# CONFIG_ARPD is not set
 # CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
-# CONFIG_KHTTPD is not set
-# CONFIG_ATM is not set
+# CONFIG_NETFILTER is not set
 
 #
-#  
+# SCTP Configuration (EXPERIMENTAL)
 #
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 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_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
 #
 # CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
 
 #
-# Network device support
+# Network testing
 #
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
 
 #
 # 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_ETHERTAP is not set
-# CONFIG_NET_SB1000 is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_HAPPYMEAL 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_SMC91X is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
 # CONFIG_HP100 is not set
-# CONFIG_NET_ISA is not set
 CONFIG_NET_PCI=y
 # CONFIG_PCNET32 is not set
+# CONFIG_AMD8111_ETH 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_B44 is not set
+# CONFIG_FORCEDETH is not set
 # CONFIG_DGRS is not set
-# CONFIG_DM9102 is not set
-CONFIG_EEPRO100=y
-CONFIG_EEPRO100_PM=y
-# CONFIG_LNE390 is not set
+# CONFIG_EEPRO100 is not set
+CONFIG_E100=y
+# CONFIG_E100_NAPI 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_8139CP 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_NET_POCKET is not set
 
 #
 # Ethernet (1000 Mbit)
 #
 # CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 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
+# CONFIG_VIA_VELOCITY is not set
+# CONFIG_TIGON3 is not set
 
 #
-# Wireless LAN (non-hamradio)
+# Ethernet (10000 Mbit)
 #
-# CONFIG_NET_RADIO is not set
+# CONFIG_IXGB is not set
+# CONFIG_S2IO 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
+# Wireless LAN (non-hamradio)
 #
-# CONFIG_HAMRADIO is not set
+# CONFIG_NET_RADIO is not set
 
 #
-# IrDA (infrared) support
+# Wan interfaces
 #
-# CONFIG_IRDA is not set
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
-# ATA/IDE/MFM/RLL support
+# SCSI device support
 #
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
+# CONFIG_SCSI is not set
 
 #
-# SCSI support
+# Fusion MPT device support
 #
-# CONFIG_SCSI is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -424,11 +458,6 @@
 # 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
 
 #
 # ISDN subsystem
@@ -436,62 +465,85 @@
 # CONFIG_ISDN is not set
 
 #
-# Input core support
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
 #
-# CONFIG_INPUT is not set
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_AMBAKMI is not set
+# CONFIG_SERIO_PCIPS2 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
 
 #
 # Character devices
 #
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
+CONFIG_HW_CONSOLE=y
 # CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_SA1100 is not set
-# CONFIG_SERIAL_SA1100_CONSOLE is not set
-CONFIG_SERIAL_AMBA=y
-CONFIG_SERIAL_AMBA_CONSOLE=y
-CONFIG_SERIAL_INTEGRATOR=y
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
 
 #
-# I2C support
+# Serial drivers
 #
-# CONFIG_I2C is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
-# Mice
+# Non-8250 serial port support
 #
-# 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
+CONFIG_SERIAL_AMBA_PL010=y
+CONFIG_SERIAL_AMBA_PL010_CONSOLE=y
+# CONFIG_SERIAL_AMBA_PL011 is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
 
 #
-# Input core support is needed for joysticks
+# IPMI
 #
-# CONFIG_QIC02_TAPE is not set
+# CONFIG_IPMI_HANDLER 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
@@ -501,9 +553,13 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
 # CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
 
 #
 # Multimedia devices
@@ -511,75 +567,100 @@
 # CONFIG_VIDEO_DEV is not set
 
 #
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
 # File systems
 #
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=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
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
 # 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_HFSPLUS_FS is not set
+# CONFIG_BEFS_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_JFFS2_FS=y
 CONFIG_JFFS2_FS_DEBUG=0
-# 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=y
+# CONFIG_JFFS2_FS_NAND is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_CRAMFS=y
 # CONFIG_VXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG 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=y
-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_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
 CONFIG_NFSD=y
 CONFIG_NFSD_V3=y
-CONFIG_SUNRPC=y
+# CONFIG_NFSD_V4 is not set
+# CONFIG_NFSD_TCP is not set
+CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
+# CONFIG_CIFS 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
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
 
 #
 # Partition Types
@@ -590,51 +671,70 @@
 # 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_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 is not set
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
-# CONFIG_SMB_NLS is not set
+# CONFIG_EFI_PARTITION is not set
+
+#
+# Native Language Support
+#
 # CONFIG_NLS is not set
 
 #
-# Console drivers
+# Profiling support
 #
-CONFIG_KMI_KEYB=y
-CONFIG_KMI_MOUSE=y
-CONFIG_PC_KEYMAP=y
-CONFIG_VGA_CONSOLE=y
-CONFIG_FB=y
+# CONFIG_PROFILING is not set
 
 #
-# Frame-buffer support
+# Graphics support
 #
 CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_RIVA is not set
-# CONFIG_FB_CLGEN is not set
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_CIRRUS is not set
 # CONFIG_FB_PM2 is not set
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
+# CONFIG_FB_ARMCLCD is not set
 # CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_SA1100 is not set
-# CONFIG_FB_E1355 is not set
-# CONFIG_FB_MATROX is not set
-# CONFIG_FB_ATY is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+# CONFIG_FB_RIVA is not set
+CONFIG_FB_MATROX=y
+CONFIG_FB_MATROX_MILLENIUM=y
+CONFIG_FB_MATROX_MYSTIQUE=y
+CONFIG_FB_MATROX_G450=y
+CONFIG_FB_MATROX_G100=y
+CONFIG_FB_MATROX_MULTIHEAD=y
+# CONFIG_FB_RADEON_OLD is not set
+# CONFIG_FB_RADEON is not set
 # CONFIG_FB_ATY128 is not set
-# CONFIG_FB_3DFX is not set
+# CONFIG_FB_ATY is not set
+# CONFIG_FB_SAVAGE is not set
 # CONFIG_FB_SIS is not set
+# CONFIG_FB_NEOMAGIC is not set
+# CONFIG_FB_KYRO is not set
+# CONFIG_FB_3DFX is not set
+# CONFIG_FB_VOODOO1 is not set
+# CONFIG_FB_TRIDENT is not set
 # CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_SUN12x22 is not set
-# CONFIG_FONT_6x11 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE is not set
+
+#
+# Logo configuration
+#
+# CONFIG_LOGO is not set
 
 #
 # Sound
@@ -642,19 +742,63 @@
 # CONFIG_SOUND is not set
 
 #
+# Misc devices
+#
+
+#
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
 
 #
 # Kernel hacking
 #
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
 CONFIG_FRAME_POINTER=y
+# CONFIG_DEBUG_USER is not set
+# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
+# CONFIG_DEBUG_LL is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/arm/configs/iq31244_defconfig b/arch/arm/configs/iq31244_defconfig
--- a/arch/arm/configs/iq31244_defconfig	2004-12-24 13:37:32 -08:00
+++ b/arch/arm/configs/iq31244_defconfig	2004-12-24 13:37:32 -08:00
@@ -1,10 +1,13 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3
+# Wed Dec 15 16:58:36 2004
 #
 CONFIG_ARM=y
 CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
@@ -16,6 +19,7 @@
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +29,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,6 +52,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -59,6 +67,7 @@
 # CONFIG_ARCH_INTEGRATOR is not set
 CONFIG_ARCH_IOP3XX=y
 # CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
 # CONFIG_ARCH_L7200 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
@@ -67,7 +76,9 @@
 # CONFIG_ARCH_SHARK is not set
 # CONFIG_ARCH_LH7A40X is not set
 # CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_H720X is not set
 
 #
 # IOP3xx Implementation Options
@@ -94,6 +105,7 @@
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
+CONFIG_CPU_CACHE_VIVT=y
 CONFIG_CPU_TLB_V4WBI=y
 CONFIG_CPU_MINICACHE=y
 
@@ -110,6 +122,7 @@
 # CONFIG_ZBOOT_ROM is not set
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_XIP_KERNEL is not set
 # CONFIG_PCI_LEGACY_PROC is not set
 CONFIG_PCI_NAMES=y
 
@@ -119,7 +132,6 @@
 CONFIG_FPE_NWFPE=y
 # CONFIG_FPE_NWFPE_XP is not set
 # CONFIG_FPE_FASTFPE is not set
-# CONFIG_VFP is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_AOUT=y
 # CONFIG_BINFMT_MISC is not set
@@ -148,8 +160,8 @@
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_REDBOOT_PARTS=y
-# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
-# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+CONFIG_MTD_REDBOOT_PARTS_READONLY=y
 # CONFIG_MTD_CMDLINE_PARTS is not set
 # CONFIG_MTD_AFS_PARTS is not set
 
@@ -191,7 +203,10 @@
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=0xf0000000
+CONFIG_MTD_PHYSMAP_LEN=0x00800000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
 # CONFIG_MTD_ARM_INTEGRATOR is not set
 # CONFIG_MTD_EDB7312 is not set
 
@@ -232,8 +247,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=8192
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # Multi-device support (RAID and LVM)
@@ -243,9 +269,11 @@
 # CONFIG_MD_LINEAR is not set
 CONFIG_MD_RAID0=y
 CONFIG_MD_RAID1=y
+# CONFIG_MD_RAID10 is not set
 CONFIG_MD_RAID5=y
 # CONFIG_MD_RAID6 is not set
 # CONFIG_MD_MULTIPATH is not set
+# CONFIG_MD_FAULTY is not set
 CONFIG_BLK_DEV_DM=y
 # CONFIG_DM_CRYPT is not set
 # CONFIG_DM_SNAPSHOT is not set
@@ -280,6 +308,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -299,7 +330,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -418,7 +448,8 @@
 # CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_AIC79XX is not set
 # CONFIG_SCSI_DPT_I2O is not set
-# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
 # CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_BUSLOGIC is not set
 # CONFIG_SCSI_DMX3191D is not set
@@ -427,6 +458,7 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR is not set
@@ -488,7 +520,6 @@
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
 # CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
 
 #
 # Input Device Drivers
@@ -523,7 +554,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -536,7 +566,6 @@
 # CONFIG_WATCHDOG is not set
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
@@ -544,7 +573,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
@@ -559,6 +587,7 @@
 #
 # CONFIG_I2C_ALGOBIT is not set
 # CONFIG_I2C_ALGOPCF is not set
+# CONFIG_I2C_ALGOPCA is not set
 
 #
 # I2C Hardware Bus support
@@ -581,9 +610,11 @@
 # CONFIG_I2C_SIS5595 is not set
 # CONFIG_I2C_SIS630 is not set
 # CONFIG_I2C_SIS96X is not set
+# CONFIG_I2C_STUB is not set
 # CONFIG_I2C_VIA is not set
 # CONFIG_I2C_VIAPRO is not set
 # CONFIG_I2C_VOODOO3 is not set
+# CONFIG_I2C_PCA_ISA is not set
 
 #
 # Hardware Sensors Chip support
@@ -591,20 +622,25 @@
 # CONFIG_I2C_SENSOR is not set
 # CONFIG_SENSORS_ADM1021 is not set
 # CONFIG_SENSORS_ADM1025 is not set
+# CONFIG_SENSORS_ADM1026 is not set
 # CONFIG_SENSORS_ADM1031 is not set
 # CONFIG_SENSORS_ASB100 is not set
 # CONFIG_SENSORS_DS1621 is not set
 # CONFIG_SENSORS_FSCHER is not set
 # CONFIG_SENSORS_GL518SM is not set
 # CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM63 is not set
 # CONFIG_SENSORS_LM75 is not set
 # CONFIG_SENSORS_LM77 is not set
 # CONFIG_SENSORS_LM78 is not set
 # CONFIG_SENSORS_LM80 is not set
 # CONFIG_SENSORS_LM83 is not set
 # CONFIG_SENSORS_LM85 is not set
+# CONFIG_SENSORS_LM87 is not set
 # CONFIG_SENSORS_LM90 is not set
 # CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_VIA686A is not set
 # CONFIG_SENSORS_W83781D is not set
 # CONFIG_SENSORS_W83L785TS is not set
@@ -654,6 +690,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -678,6 +715,7 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -723,6 +761,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -768,7 +807,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -784,6 +822,12 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
 
 #
 # USB Gadget Support
@@ -791,16 +835,22 @@
 # CONFIG_USB_GADGET is not set
 
 #
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
+# CONFIG_DEBUG_INFO is not set
 CONFIG_FRAME_POINTER=y
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/arm/configs/iq80321_defconfig b/arch/arm/configs/iq80321_defconfig
--- a/arch/arm/configs/iq80321_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/configs/iq80321_defconfig	2004-12-24 13:36:31 -08:00
@@ -1,10 +1,13 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3
+# Wed Dec 15 16:48:43 2004
 #
 CONFIG_ARM=y
 CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
@@ -16,6 +19,7 @@
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +29,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,6 +52,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -59,6 +67,7 @@
 # CONFIG_ARCH_INTEGRATOR is not set
 CONFIG_ARCH_IOP3XX=y
 # CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
 # CONFIG_ARCH_L7200 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
@@ -67,7 +76,9 @@
 # CONFIG_ARCH_SHARK is not set
 # CONFIG_ARCH_LH7A40X is not set
 # CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_H720X is not set
 
 #
 # IOP3xx Implementation Options
@@ -94,6 +105,7 @@
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
+CONFIG_CPU_CACHE_VIVT=y
 CONFIG_CPU_TLB_V4WBI=y
 CONFIG_CPU_MINICACHE=y
 
@@ -110,6 +122,7 @@
 # CONFIG_ZBOOT_ROM is not set
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_XIP_KERNEL is not set
 # CONFIG_PCI_LEGACY_PROC is not set
 CONFIG_PCI_NAMES=y
 
@@ -119,7 +132,6 @@
 CONFIG_FPE_NWFPE=y
 # CONFIG_FPE_NWFPE_XP is not set
 # CONFIG_FPE_FASTFPE is not set
-# CONFIG_VFP is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_AOUT=y
 # CONFIG_BINFMT_MISC is not set
@@ -148,8 +160,8 @@
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_REDBOOT_PARTS=y
-# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
-# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+CONFIG_MTD_REDBOOT_PARTS_READONLY=y
 # CONFIG_MTD_CMDLINE_PARTS is not set
 # CONFIG_MTD_AFS_PARTS is not set
 
@@ -191,7 +203,10 @@
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=0xf0000000
+CONFIG_MTD_PHYSMAP_LEN=0x00800000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=1
 # CONFIG_MTD_ARM_INTEGRATOR is not set
 # CONFIG_MTD_EDB7312 is not set
 
@@ -232,8 +247,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=8192
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # Multi-device support (RAID and LVM)
@@ -268,6 +294,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -287,7 +316,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -413,7 +441,6 @@
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
 # CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
 
 #
 # Input Device Drivers
@@ -448,7 +475,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -461,7 +487,6 @@
 # CONFIG_WATCHDOG is not set
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
@@ -469,7 +494,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
@@ -510,6 +534,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -534,6 +559,7 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -579,6 +605,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -624,7 +651,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -640,6 +666,12 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
 
 #
 # USB Gadget Support
@@ -647,16 +679,22 @@
 # CONFIG_USB_GADGET is not set
 
 #
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
+# CONFIG_DEBUG_INFO is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/arm/configs/iq80331_defconfig b/arch/arm/configs/iq80331_defconfig
--- a/arch/arm/configs/iq80331_defconfig	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/configs/iq80331_defconfig	2004-12-24 13:36:16 -08:00
@@ -1,10 +1,13 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3
+# Wed Dec 15 16:43:39 2004
 #
 CONFIG_ARM=y
 CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
@@ -16,6 +19,7 @@
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,6 +29,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
@@ -32,11 +37,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,6 +53,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -60,6 +68,7 @@
 # CONFIG_ARCH_INTEGRATOR is not set
 CONFIG_ARCH_IOP3XX=y
 # CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
 # CONFIG_ARCH_L7200 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
@@ -68,7 +77,9 @@
 # CONFIG_ARCH_SHARK is not set
 # CONFIG_ARCH_LH7A40X is not set
 # CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_H720X is not set
 
 #
 # IOP3xx Implementation Options
@@ -94,6 +105,7 @@
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
+CONFIG_CPU_CACHE_VIVT=y
 CONFIG_CPU_TLB_V4WBI=y
 CONFIG_CPU_MINICACHE=y
 
@@ -110,6 +122,7 @@
 # CONFIG_ZBOOT_ROM is not set
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_XIP_KERNEL is not set
 # CONFIG_PCI_LEGACY_PROC is not set
 CONFIG_PCI_NAMES=y
 
@@ -119,7 +132,6 @@
 CONFIG_FPE_NWFPE=y
 # CONFIG_FPE_NWFPE_XP is not set
 # CONFIG_FPE_FASTFPE is not set
-# CONFIG_VFP is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_AOUT=y
 # CONFIG_BINFMT_MISC is not set
@@ -149,8 +161,8 @@
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_REDBOOT_PARTS=y
-# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
-# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+CONFIG_MTD_REDBOOT_PARTS_READONLY=y
 # CONFIG_MTD_CMDLINE_PARTS is not set
 # CONFIG_MTD_AFS_PARTS is not set
 
@@ -196,7 +208,10 @@
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=0xc0000000
+CONFIG_MTD_PHYSMAP_LEN=0x00800000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=1
 # CONFIG_MTD_ARM_INTEGRATOR is not set
 # CONFIG_MTD_EDB7312 is not set
 
@@ -237,8 +252,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=8192
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # Multi-device support (RAID and LVM)
@@ -248,9 +274,11 @@
 CONFIG_MD_LINEAR=y
 CONFIG_MD_RAID0=y
 CONFIG_MD_RAID1=y
+# CONFIG_MD_RAID10 is not set
 CONFIG_MD_RAID5=y
 # CONFIG_MD_RAID6 is not set
 # CONFIG_MD_MULTIPATH is not set
+# CONFIG_MD_FAULTY is not set
 CONFIG_BLK_DEV_DM=y
 # CONFIG_DM_CRYPT is not set
 # CONFIG_DM_SNAPSHOT is not set
@@ -285,6 +313,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -304,7 +335,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -423,7 +453,8 @@
 # CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_AIC79XX is not set
 # CONFIG_SCSI_DPT_I2O is not set
-# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
 # CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_BUSLOGIC is not set
 # CONFIG_SCSI_DMX3191D is not set
@@ -432,6 +463,7 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR is not set
@@ -493,7 +525,6 @@
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
 # CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
 
 #
 # Input Device Drivers
@@ -528,7 +559,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -541,7 +571,6 @@
 # CONFIG_WATCHDOG is not set
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
@@ -549,7 +578,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
@@ -590,6 +618,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -614,6 +643,7 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -653,6 +683,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -698,7 +729,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -714,6 +744,12 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
 
 #
 # USB Gadget Support
@@ -721,23 +757,31 @@
 # CONFIG_USB_GADGET is not set
 
 #
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
 # Kernel hacking
 #
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
 CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
+# CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+CONFIG_FRAME_POINTER=y
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/arm/configs/pangolin_defconfig b/arch/arm/configs/pangolin_defconfig
--- a/arch/arm/configs/pangolin_defconfig	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,739 +0,0 @@
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-CONFIG_SA1100_PANGOLIN=y
-CONFIG_SA1100_PANGOLIN_PCMCIA_IDE=y
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-# CONFIG_CPU_BIG_ENDIAN is not set
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=y
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_FPE_NWFPE is not set
-CONFIG_FPE_FASTFPE=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_APM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="keepinitrd mem=128M root=/dev/ram initrd=0xc0800000,3M"
-# CONFIG_PFS168_CMDLINE is not set
-# CONFIG_LEDS is not set
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_BOOTLDR_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-CONFIG_MTD_CFI_ADV_OPTIONS=y
-CONFIG_MTD_CFI_NOSWAP=y
-# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
-CONFIG_MTD_CFI_GEOMETRY=y
-# CONFIG_MTD_CFI_B1 is not set
-# CONFIG_MTD_CFI_B2 is not set
-CONFIG_MTD_CFI_B4=y
-# CONFIG_MTD_CFI_I1 is not set
-# CONFIG_MTD_CFI_I2 is not set
-CONFIG_MTD_CFI_I4=y
-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 is not set
-# CONFIG_MTD_SUN_UFLASH is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_TQM8XXL is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_NETSC520 is not set
-# CONFIG_MTD_SBC_GXX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_SA1100_REDBOOT_PARTITIONS is not set
-# CONFIG_MTD_SA1100_BOOTLDR_PARTITIONS is not set
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 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_ARM_INTEGRATOR is not set
-# CONFIG_MTD_SOLUTIONENGINE 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
-# CONFIG_MTD_L440GX is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_LART is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-# 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
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=y
-CONFIG_BLK_DEV_RAM_SIZE=16384
-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=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 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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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_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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRAMCA is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=y
-# 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_ACENIC_OMIT_TIGON_I is not set
-# CONFIG_MYRI_SBUS 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=y
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-CONFIG_NET_PCMCIA_RADIO=y
-# CONFIG_PCMCIA_RAYCS is not set
-# CONFIG_PCMCIA_NETWAVE is not set
-# CONFIG_PCMCIA_WAVELAN is not set
-# CONFIG_AIRONET4500_CS is not set
-CONFIG_PCMCIA_WVLAN=y
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=m
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=m
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=m
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_PANGOLIN is not set
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=115200
-# CONFIG_SERIAL_8250 is not set
-# CONFIG_SERIAL_8250_CONSOLE is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-# CONFIG_UCB1200 is not set
-# CONFIG_TOUCHSCREEN_UCB1200 is not set
-# CONFIG_AUDIO_UCB1200 is not set
-# CONFIG_ADC_UCB1200 is not set
-# CONFIG_TOUCHSCREEN_BITSY is not set
-CONFIG_PROFILER=y
-# CONFIG_PFS168_SPI is not set
-# CONFIG_PFS168_DTMF is not set
-# CONFIG_PFS168_MISC 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
-# 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_SA1100_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
-
-#
-# PCMCIA character devices
-#
-
-#
-# 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=y
-CONFIG_MSDOS_FS=y
-# CONFIG_UMSDOS_FS is not set
-CONFIG_VFAT_FS=y
-# CONFIG_EFS_FS is not set
-CONFIG_JFFS_FS=y
-CONFIG_JFFS_FS_VERBOSE=0
-# CONFIG_JFFS2_FS is not set
-CONFIG_CRAMFS=y
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# 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_DEBUG 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_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_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=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-CONFIG_NLS_CODEPAGE_950=y
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_SA1100 is not set
-CONFIG_FB_MQ200=y
-# CONFIG_FB_E1355 is not set
-# CONFIG_FB_VIRTUAL is not set
-CONFIG_FBCON_ADVANCED=y
-# CONFIG_FBCON_MFB is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-# CONFIG_FBCON_CFB24 is not set
-# CONFIG_FBCON_CFB32 is not set
-# CONFIG_FBCON_AFB is not set
-# CONFIG_FBCON_ILBM is not set
-# CONFIG_FBCON_IPLAN2P2 is not set
-# CONFIG_FBCON_IPLAN2P4 is not set
-# CONFIG_FBCON_IPLAN2P8 is not set
-# CONFIG_FBCON_MAC is not set
-# CONFIG_FBCON_VGA_PLANES is not set
-# CONFIG_FBCON_VGA is not set
-# CONFIG_FBCON_HGA is not set
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-# CONFIG_FONT_8x16 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-CONFIG_SOUND=y
-# CONFIG_SOUND_ASSABET_UDA1341 is not set
-CONFIG_SOUND_PANGOLIN_UDA1341=y
-# CONFIG_SOUND_BITSY_UDA1341 is not set
-# CONFIG_SOUND_SA1111_UDA1341 is not set
-# CONFIG_SOUND_SA1100SSP is not set
-# CONFIG_SOUND_CMPCI is not set
-# CONFIG_SOUND_EMU10K1 is not set
-# CONFIG_SOUND_FUSION is not set
-# CONFIG_SOUND_CS4281 is not set
-# CONFIG_SOUND_ES1370 is not set
-# CONFIG_SOUND_ES1371 is not set
-# CONFIG_SOUND_ESSSOLO1 is not set
-# CONFIG_SOUND_MAESTRO is not set
-# CONFIG_SOUND_MAESTRO3 is not set
-# CONFIG_SOUND_ICH is not set
-# CONFIG_SOUND_SONICVIBES is not set
-# CONFIG_SOUND_TRIDENT is not set
-# CONFIG_SOUND_MSNDCLAS is not set
-# CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_VIA82CXXX is not set
-# CONFIG_MIDI_VIA82CXXX is not set
-# CONFIG_SOUND_OSS is not set
-# CONFIG_SOUND_TVMIXER is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_NO_PGT_CACHE is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/pfs168_mqtft_defconfig b/arch/arm/configs/pfs168_mqtft_defconfig
--- a/arch/arm/configs/pfs168_mqtft_defconfig	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,778 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-CONFIG_SA1100_PFS168=y
-CONFIG_SA1111=y
-CONFIG_SA1100_USB=m
-CONFIG_SA1100_USB_NETLINK=m
-CONFIG_SA1100_USB_CHAR=m
-CONFIG_SA1100_FREQUENCY_SCALE=m
-# CONFIG_SA1100_VOLTAGE_SCALE is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-
-#
-# Please ensure that you have read the help on the next option
-#
-# CONFIG_ANGELBOOT is not set
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=m
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="root=/dev/nfs mem=16M"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-CONFIG_UCB1200=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG 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
-
-#
-# RAM/ROM Device Drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_MTDRAM is not set
-
-#
-# Linearly Mapped Flash Device Drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_CFI_GEOMETRY 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_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_SBC_MEDIAGX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_CSTM_CFI_JEDEC is not set
-# CONFIG_MTD_JEDEC is not set
-# CONFIG_MTD_MIXMEM is not set
-# CONFIG_MTD_OCTAGON is not set
-# CONFIG_MTD_VMAX is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-# CONFIG_MTD_NAND_SPIA is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=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_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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=y
-# 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
-
-#
-# 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=m
-CONFIG_PPP_SYNC_TTY=m
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-# CONFIG_PPPOE 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-CONFIG_PCMCIA_SMC91C92=m
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-CONFIG_IRDA=m
-
-#
-# IrDA protocols
-#
-CONFIG_IRLAN=m
-CONFIG_IRNET=m
-CONFIG_IRCOMM=m
-CONFIG_IRDA_ULTRA=y
-# CONFIG_IRDA_OPTIONS is not set
-
-#
-# Infrared-port device drivers
-#
-
-#
-# SIR device drivers
-#
-CONFIG_IRTTY_SIR=m
-CONFIG_IRPORT_SIR=m
-
-#
-# FIR device drivers
-#
-# CONFIG_NSC_FIR is not set
-# CONFIG_WINBOND_FIR is not set
-# CONFIG_TOSHIBA_FIR is not set
-# CONFIG_SMC_IRCC_FIR is not set
-CONFIG_SA1100_FIR=m
-
-#
-# Dongle support
-#
-# CONFIG_DONGLE is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=m
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=m
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=m
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-CONFIG_INPUT=y
-CONFIG_INPUT_KEYBDEV=y
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-CONFIG_SERIAL=y
-# CONFIG_SERIAL_CONSOLE is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=115200
-CONFIG_TOUCHSCREEN_UCB1200=y
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-CONFIG_PFS168_DTMF=y
-CONFIG_PFS168_MISC=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ASSABET is not set
-CONFIG_I2C_PFS168=y
-# CONFIG_I2C_ALGOPCF is not set
-CONFIG_I2C_CHARDEV=y
-CONFIG_I2C_SENSORS=y
-CONFIG_I2C_EEPROM=y
-CONFIG_I2C_EEPROM=y
-CONFIG_I2C_M41T11=y
-CONFIG_I2C_X9221=y
-CONFIG_I2C_PCF8574=y
-
-#
-# 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_SA1100_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
-CONFIG_PCMCIA_SERIAL=m
-
-#
-# PCMCIA character device support
-#
-# CONFIG_PCMCIA_SERIAL_CS 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=y
-CONFIG_JFFS_FS_VERBOSE=0
-# CONFIG_JFFS2_FS is not set
-# CONFIG_CRAMFS 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_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG 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 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
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_SA1100 is not set
-CONFIG_FB_MQ200=y
-# CONFIG_PFS168_MQVGA is not set
-CONFIG_PFS168_MQTFT=y
-# CONFIG_FB_VIRTUAL is not set
-CONFIG_FBCON_ADVANCED=y
-# CONFIG_FBCON_MFB is not set
-# CONFIG_FBCON_CFB2 is not set
-# CONFIG_FBCON_CFB4 is not set
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_CFB24=y
-CONFIG_FBCON_CFB32=y
-# CONFIG_FBCON_AFB is not set
-# CONFIG_FBCON_ILBM is not set
-# CONFIG_FBCON_IPLAN2P2 is not set
-# CONFIG_FBCON_IPLAN2P4 is not set
-# CONFIG_FBCON_IPLAN2P8 is not set
-# CONFIG_FBCON_MAC is not set
-# CONFIG_FBCON_VGA_PLANES is not set
-# CONFIG_FBCON_VGA is not set
-# CONFIG_FBCON_HGA is not set
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-# CONFIG_FONT_8x16 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB=m
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-
-#
-# USB Controllers
-#
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-CONFIG_USB_OHCI=m
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_STORAGE is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-
-#
-# USB Human Interface Devices (HID)
-#
-CONFIG_USB_HID=m
-CONFIG_USB_KBD=m
-CONFIG_USB_MOUSE=m
-# CONFIG_USB_WACOM is not set
-
-#
-# 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
-
-#
-# USB Multimedia devices
-#
-# CONFIG_USB_IBMCAM is not set
-# CONFIG_USB_OV511 is not set
-# CONFIG_USB_DSBR is not set
-# CONFIG_USB_DABUSB is not set
-
-#
-# USB Network adaptors
-#
-# CONFIG_USB_PLUSB is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_NET1080 is not set
-
-#
-# USB port drivers
-#
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-
-#
-# USB misc drivers
-#
-# CONFIG_USB_RIO500 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
diff -Nru a/arch/arm/configs/pfs168_mqvga_defconfig b/arch/arm/configs/pfs168_mqvga_defconfig
--- a/arch/arm/configs/pfs168_mqvga_defconfig	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,778 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-CONFIG_SA1100_PFS168=y
-CONFIG_SA1111=y
-CONFIG_SA1100_USB=m
-CONFIG_SA1100_USB_NETLINK=m
-CONFIG_SA1100_USB_CHAR=m
-CONFIG_SA1100_FREQUENCY_SCALE=m
-# CONFIG_SA1100_VOLTAGE_SCALE is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-
-#
-# Please ensure that you have read the help on the next option
-#
-# CONFIG_ANGELBOOT is not set
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=m
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="root=/dev/nfs mem=16M"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-CONFIG_UCB1200=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG 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
-
-#
-# RAM/ROM Device Drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_MTDRAM is not set
-
-#
-# Linearly Mapped Flash Device Drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_CFI_GEOMETRY 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_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_SBC_MEDIAGX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_CSTM_CFI_JEDEC is not set
-# CONFIG_MTD_JEDEC is not set
-# CONFIG_MTD_MIXMEM is not set
-# CONFIG_MTD_OCTAGON is not set
-# CONFIG_MTD_VMAX is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-# CONFIG_MTD_NAND_SPIA is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=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_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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=y
-# 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
-
-#
-# 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=m
-CONFIG_PPP_SYNC_TTY=m
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-# CONFIG_PPPOE 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-CONFIG_PCMCIA_SMC91C92=m
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-CONFIG_IRDA=m
-
-#
-# IrDA protocols
-#
-CONFIG_IRLAN=m
-CONFIG_IRNET=m
-CONFIG_IRCOMM=m
-CONFIG_IRDA_ULTRA=y
-# CONFIG_IRDA_OPTIONS is not set
-
-#
-# Infrared-port device drivers
-#
-
-#
-# SIR device drivers
-#
-CONFIG_IRTTY_SIR=m
-CONFIG_IRPORT_SIR=m
-
-#
-# FIR device drivers
-#
-# CONFIG_NSC_FIR is not set
-# CONFIG_WINBOND_FIR is not set
-# CONFIG_TOSHIBA_FIR is not set
-# CONFIG_SMC_IRCC_FIR is not set
-CONFIG_SA1100_FIR=m
-
-#
-# Dongle support
-#
-# CONFIG_DONGLE is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=m
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=m
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=m
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-CONFIG_INPUT=y
-CONFIG_INPUT_KEYBDEV=y
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-CONFIG_SERIAL=y
-# CONFIG_SERIAL_CONSOLE is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=115200
-CONFIG_TOUCHSCREEN_UCB1200=y
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-CONFIG_PFS168_DTMF=y
-CONFIG_PFS168_MISC=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ASSABET is not set
-CONFIG_I2C_PFS168=y
-# CONFIG_I2C_ALGOPCF is not set
-CONFIG_I2C_CHARDEV=y
-CONFIG_I2C_SENSORS=y
-CONFIG_I2C_EEPROM=y
-CONFIG_I2C_EEPROM=y
-CONFIG_I2C_M41T11=y
-CONFIG_I2C_X9221=y
-CONFIG_I2C_PCF8574=y
-
-#
-# 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_SA1100_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
-CONFIG_PCMCIA_SERIAL=m
-
-#
-# PCMCIA character device support
-#
-# CONFIG_PCMCIA_SERIAL_CS 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=y
-CONFIG_JFFS_FS_VERBOSE=0
-# CONFIG_JFFS2_FS is not set
-# CONFIG_CRAMFS 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_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG 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 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
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_SA1100 is not set
-CONFIG_FB_MQ200=y
-CONFIG_PFS168_MQVGA=y
-# CONFIG_PFS168_MQTFT is not set
-# CONFIG_FB_VIRTUAL is not set
-CONFIG_FBCON_ADVANCED=y
-# CONFIG_FBCON_MFB is not set
-# CONFIG_FBCON_CFB2 is not set
-# CONFIG_FBCON_CFB4 is not set
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_CFB24=y
-CONFIG_FBCON_CFB32=y
-# CONFIG_FBCON_AFB is not set
-# CONFIG_FBCON_ILBM is not set
-# CONFIG_FBCON_IPLAN2P2 is not set
-# CONFIG_FBCON_IPLAN2P4 is not set
-# CONFIG_FBCON_IPLAN2P8 is not set
-# CONFIG_FBCON_MAC is not set
-# CONFIG_FBCON_VGA_PLANES is not set
-# CONFIG_FBCON_VGA is not set
-# CONFIG_FBCON_HGA is not set
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-# CONFIG_FONT_8x16 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB=m
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-
-#
-# USB Controllers
-#
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-CONFIG_USB_OHCI=m
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_STORAGE is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-
-#
-# USB Human Interface Devices (HID)
-#
-CONFIG_USB_HID=m
-CONFIG_USB_KBD=m
-CONFIG_USB_MOUSE=m
-# CONFIG_USB_WACOM is not set
-
-#
-# 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
-
-#
-# USB Multimedia devices
-#
-# CONFIG_USB_IBMCAM is not set
-# CONFIG_USB_OV511 is not set
-# CONFIG_USB_DSBR is not set
-# CONFIG_USB_DABUSB is not set
-
-#
-# USB Network adaptors
-#
-# CONFIG_USB_PLUSB is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_NET1080 is not set
-
-#
-# USB port drivers
-#
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-
-#
-# USB misc drivers
-#
-# CONFIG_USB_RIO500 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
diff -Nru a/arch/arm/configs/pfs168_sastn_defconfig b/arch/arm/configs/pfs168_sastn_defconfig
--- a/arch/arm/configs/pfs168_sastn_defconfig	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,770 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-CONFIG_SA1100_PFS168=y
-CONFIG_SA1111=y
-CONFIG_SA1100_USB=m
-CONFIG_SA1100_USB_NETLINK=m
-CONFIG_SA1100_USB_CHAR=m
-CONFIG_SA1100_FREQUENCY_SCALE=m
-# CONFIG_SA1100_VOLTAGE_SCALE is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-
-#
-# Please ensure that you have read the help on the next option
-#
-# CONFIG_ANGELBOOT is not set
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=m
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="root=/dev/nfs mem=16M"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-CONFIG_UCB1200=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG 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
-
-#
-# RAM/ROM Device Drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_MTDRAM is not set
-
-#
-# Linearly Mapped Flash Device Drivers
-#
-CONFIG_MTD_CFI=y
-# 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_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_SBC_MEDIAGX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-# CONFIG_MTD_CSTM_CFI_JEDEC is not set
-# CONFIG_MTD_JEDEC is not set
-# CONFIG_MTD_MIXMEM is not set
-# CONFIG_MTD_OCTAGON is not set
-# CONFIG_MTD_VMAX is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-# CONFIG_MTD_NAND_SPIA is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=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_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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=y
-# 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
-
-#
-# 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=m
-CONFIG_PPP_SYNC_TTY=m
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-# CONFIG_PPPOE 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-CONFIG_PCMCIA_SMC91C92=m
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-CONFIG_IRDA=m
-
-#
-# IrDA protocols
-#
-CONFIG_IRLAN=m
-CONFIG_IRNET=m
-CONFIG_IRCOMM=m
-CONFIG_IRDA_ULTRA=y
-# CONFIG_IRDA_OPTIONS is not set
-
-#
-# Infrared-port device drivers
-#
-
-#
-# SIR device drivers
-#
-CONFIG_IRTTY_SIR=m
-CONFIG_IRPORT_SIR=m
-
-#
-# FIR device drivers
-#
-# CONFIG_NSC_FIR is not set
-# CONFIG_WINBOND_FIR is not set
-# CONFIG_TOSHIBA_FIR is not set
-# CONFIG_SMC_IRCC_FIR is not set
-CONFIG_SA1100_FIR=m
-
-#
-# Dongle support
-#
-# CONFIG_DONGLE is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=m
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=m
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=m
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-CONFIG_INPUT=y
-CONFIG_INPUT_KEYBDEV=y
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-CONFIG_SERIAL=y
-# CONFIG_SERIAL_CONSOLE is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=115200
-CONFIG_TOUCHSCREEN_UCB1200=y
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-CONFIG_PFS168_DTMF=y
-CONFIG_PFS168_MISC=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ASSABET is not set
-# CONFIG_I2C_ALGOPCF is not set
-CONFIG_I2C_CHARDEV=y
-
-#
-# 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_SA1100_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
-
-#
-# PCMCIA character devices
-#
-# CONFIG_PCMCIA_SERIAL_CS 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=y
-CONFIG_JFFS_FS_VERBOSE=0
-# CONFIG_JFFS2_FS is not set
-# CONFIG_CRAMFS 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_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG 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 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
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_VIRTUAL is not set
-CONFIG_FBCON_ADVANCED=y
-# CONFIG_FBCON_MFB is not set
-# CONFIG_FBCON_CFB2 is not set
-# CONFIG_FBCON_CFB4 is not set
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_CFB24=y
-CONFIG_FBCON_CFB32=y
-# CONFIG_FBCON_AFB is not set
-# CONFIG_FBCON_ILBM is not set
-# CONFIG_FBCON_IPLAN2P2 is not set
-# CONFIG_FBCON_IPLAN2P4 is not set
-# CONFIG_FBCON_IPLAN2P8 is not set
-# CONFIG_FBCON_MAC is not set
-# CONFIG_FBCON_VGA_PLANES is not set
-# CONFIG_FBCON_VGA is not set
-# CONFIG_FBCON_HGA is not set
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-# CONFIG_FONT_8x16 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB=m
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-
-#
-# USB Controllers
-#
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-CONFIG_USB_OHCI=m
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_STORAGE is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-
-#
-# USB Human Interface Devices (HID)
-#
-CONFIG_USB_HID=m
-CONFIG_USB_KBD=m
-CONFIG_USB_MOUSE=m
-# CONFIG_USB_WACOM is not set
-
-#
-# 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
-
-#
-# USB Multimedia devices
-#
-# CONFIG_USB_IBMCAM is not set
-# CONFIG_USB_OV511 is not set
-# CONFIG_USB_DSBR is not set
-# CONFIG_USB_DABUSB is not set
-
-#
-# USB Network adaptors
-#
-# CONFIG_USB_PLUSB is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_NET1080 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
-
-#
-# USB misc drivers
-#
-# CONFIG_USB_RIO500 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/pfs168_satft_defconfig b/arch/arm/configs/pfs168_satft_defconfig
--- a/arch/arm/configs/pfs168_satft_defconfig	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,778 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-CONFIG_SA1100_PFS168=y
-CONFIG_SA1111=y
-CONFIG_SA1100_USB=m
-CONFIG_SA1100_USB_NETLINK=m
-CONFIG_SA1100_USB_CHAR=m
-CONFIG_SA1100_FREQUENCY_SCALE=m
-# CONFIG_SA1100_VOLTAGE_SCALE is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-
-#
-# Please ensure that you have read the help on the next option
-#
-# CONFIG_ANGELBOOT is not set
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=m
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="root=/dev/nfs mem=16M"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-CONFIG_UCB1200=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG 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
-
-#
-# RAM/ROM Device Drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_MTDRAM is not set
-
-#
-# Linearly Mapped Flash Device Drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_CFI_GEOMETRY 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_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_SBC_MEDIAGX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_CSTM_CFI_JEDEC is not set
-# CONFIG_MTD_JEDEC is not set
-# CONFIG_MTD_MIXMEM is not set
-# CONFIG_MTD_OCTAGON is not set
-# CONFIG_MTD_VMAX is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-# CONFIG_MTD_NAND_SPIA is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=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_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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=y
-# 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
-
-#
-# 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=m
-CONFIG_PPP_SYNC_TTY=m
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-# CONFIG_PPPOE 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-CONFIG_PCMCIA_SMC91C92=m
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-CONFIG_IRDA=m
-
-#
-# IrDA protocols
-#
-CONFIG_IRLAN=m
-CONFIG_IRNET=m
-CONFIG_IRCOMM=m
-CONFIG_IRDA_ULTRA=y
-# CONFIG_IRDA_OPTIONS is not set
-
-#
-# Infrared-port device drivers
-#
-
-#
-# SIR device drivers
-#
-CONFIG_IRTTY_SIR=m
-CONFIG_IRPORT_SIR=m
-
-#
-# FIR device drivers
-#
-# CONFIG_NSC_FIR is not set
-# CONFIG_WINBOND_FIR is not set
-# CONFIG_TOSHIBA_FIR is not set
-# CONFIG_SMC_IRCC_FIR is not set
-CONFIG_SA1100_FIR=m
-
-#
-# Dongle support
-#
-# CONFIG_DONGLE is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=m
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=m
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=m
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-CONFIG_INPUT=y
-CONFIG_INPUT_KEYBDEV=y
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-CONFIG_SERIAL=y
-# CONFIG_SERIAL_CONSOLE is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=115200
-CONFIG_TOUCHSCREEN_UCB1200=y
-# CONFIG_TOUCHSCREEN_BITSY is not set
-# CONFIG_PROFILER is not set
-# CONFIG_PFS168_SPI is not set
-CONFIG_PFS168_DTMF=y
-CONFIG_PFS168_MISC=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ASSABET is not set
-CONFIG_I2C_PFS168=y
-# CONFIG_I2C_ALGOPCF is not set
-CONFIG_I2C_CHARDEV=y
-CONFIG_I2C_SENSORS=y
-CONFIG_I2C_EEPROM=y
-CONFIG_I2C_EEPROM=y
-CONFIG_I2C_M41T11=y
-CONFIG_I2C_X9221=y
-CONFIG_I2C_PCF8574=y
-
-#
-# 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_SA1100_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
-CONFIG_PCMCIA_SERIAL=m
-
-#
-# PCMCIA character device support
-#
-# CONFIG_PCMCIA_SERIAL_CS 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=y
-CONFIG_JFFS_FS_VERBOSE=0
-# CONFIG_JFFS2_FS is not set
-# CONFIG_CRAMFS 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_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG 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 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
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-# CONFIG_FB_CYBER2000 is not set
-CONFIG_FB_SA1100=y
-# CONFIG_PFS168_SASTN is not set
-CONFIG_PFS168_SATFT=y
-# CONFIG_FB_MQ200 is not set
-# CONFIG_FB_VIRTUAL is not set
-CONFIG_FBCON_ADVANCED=y
-# CONFIG_FBCON_MFB is not set
-# CONFIG_FBCON_CFB2 is not set
-# CONFIG_FBCON_CFB4 is not set
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_CFB24=y
-CONFIG_FBCON_CFB32=y
-# CONFIG_FBCON_AFB is not set
-# CONFIG_FBCON_ILBM is not set
-# CONFIG_FBCON_IPLAN2P2 is not set
-# CONFIG_FBCON_IPLAN2P4 is not set
-# CONFIG_FBCON_IPLAN2P8 is not set
-# CONFIG_FBCON_MAC is not set
-# CONFIG_FBCON_VGA_PLANES is not set
-# CONFIG_FBCON_VGA is not set
-# CONFIG_FBCON_HGA is not set
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-# CONFIG_FONT_8x16 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB=m
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-
-#
-# USB Controllers
-#
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-CONFIG_USB_OHCI=m
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_STORAGE is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-
-#
-# USB Human Interface Devices (HID)
-#
-CONFIG_USB_HID=m
-CONFIG_USB_KBD=m
-CONFIG_USB_MOUSE=m
-# CONFIG_USB_WACOM is not set
-
-#
-# 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
-
-#
-# USB Multimedia devices
-#
-# CONFIG_USB_IBMCAM is not set
-# CONFIG_USB_OV511 is not set
-# CONFIG_USB_DSBR is not set
-# CONFIG_USB_DABUSB is not set
-
-#
-# USB Network adaptors
-#
-# CONFIG_USB_PLUSB is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_NET1080 is not set
-
-#
-# USB port drivers
-#
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-
-#
-# USB misc drivers
-#
-# CONFIG_USB_RIO500 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
diff -Nru a/arch/arm/configs/pleb_defconfig b/arch/arm/configs/pleb_defconfig
--- a/arch/arm/configs/pleb_defconfig	2004-12-24 13:37:03 -08:00
+++ b/arch/arm/configs/pleb_defconfig	2004-12-24 13:37:44 -08:00
@@ -1,132 +1,159 @@
 #
-# Automatically generated by make menuconfig: don't edit
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Wed Nov 24 15:12:32 2004
 #
 CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
+CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+# CONFIG_KOBJECT_UEVENT is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_SHMEM is not set
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_TINY_SHMEM=y
 
 #
 # Loadable module support
 #
 CONFIG_MODULES=y
+# CONFIG_MODULE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
 # System Type
 #
-# CONFIG_ARCH_ARCA5K is not set
 # CONFIG_ARCH_CLPS7500 is not set
+# CONFIG_ARCH_CLPS711X is not set
 # CONFIG_ARCH_CO285 is not set
 # CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_CAMELOT is not set
 # CONFIG_ARCH_FOOTBRIDGE is not set
 # CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_IOP3XX is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
 CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
+# CONFIG_ARCH_S3C2410 is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_LH7A40X is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_H720X is not set
 
 #
 # SA11x0 Implementations
 #
 # CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_BRUTUS is not set
 # CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_BITSY is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
+# CONFIG_SA1100_COLLIE is not set
+# CONFIG_SA1100_H3100 is not set
+# CONFIG_SA1100_H3600 is not set
+# CONFIG_SA1100_H3800 is not set
+# CONFIG_SA1100_BADGE4 is not set
 # CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
+# CONFIG_SA1100_HACKKIT is not set
 # CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
 CONFIG_SA1100_PLEB=y
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
+# CONFIG_SA1100_SHANNON is not set
+# CONFIG_SA1100_SIMPAD is not set
+# CONFIG_SA1100_SSP is not set
 # CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
 
 #
-# CLPS711X/EP721X Implementations
+# Processor Type
 #
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
 CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
 CONFIG_CPU_SA1100=y
-CONFIG_DISCONTIGMEM=y
-# CONFIG_CPU_BIG_ENDIAN is not set
+CONFIG_CPU_32v4=y
+CONFIG_CPU_ABRT_EV4=y
+CONFIG_CPU_CACHE_V4WB=y
+CONFIG_CPU_CACHE_VIVT=y
+CONFIG_CPU_TLB_V4WB=y
+CONFIG_CPU_MINICACHE=y
+
+#
+# Processor Features
+#
 
 #
 # General setup
 #
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_ISA=y
+# CONFIG_ZBOOT_ROM is not set
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_XIP_KERNEL is not set
 CONFIG_CPU_FREQ=y
-# CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+# CONFIG_CPU_FREQ_PROC_INTF is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_SA1100=y
+
+#
+# At least one math emulation must be selected
+#
 CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
 # CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
 CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
 # CONFIG_PM is not set
-# CONFIG_APM is not set
+# CONFIG_PREEMPT is not set
 # CONFIG_ARTHUR is not set
 CONFIG_CMDLINE="console=ttySA0,9600 mem=16M@0xc0000000 mem=16M@0xc8000000 root=/dev/ram initrd=0xc0400000,4M"
-# CONFIG_PFS168_CMDLINE is not set
 # CONFIG_LEDS is not set
 CONFIG_ALIGNMENT_TRAP=y
 
@@ -138,56 +165,73 @@
 #
 # Memory Technology Devices (MTD)
 #
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
 
 #
 # RAM/ROM/Flash chip drivers
 #
-# CONFIG_MTD_CFI is not set
-# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 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_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
-# CONFIG_MTD_JEDEC is not set
+# CONFIG_MTD_ABSENT is not set
 
 #
 # Mapping drivers for chip access
 #
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
 # CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_SUN_UFLASH is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_PNC2000 is not set
-# CONFIG_MTD_RPXLITE is not set
-# CONFIG_MTD_SC520CDP is not set
-# CONFIG_MTD_NETSC520 is not set
-# CONFIG_MTD_SBC_GXX is not set
-# CONFIG_MTD_ELAN_104NC is not set
-# CONFIG_MTD_SA1100 is not set
-# CONFIG_MTD_SA1100_REDBOOT_PARTITIONS is not set
-# CONFIG_MTD_SA1100_BOOTLDR_PARTITIONS is not set
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 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_ARM_INTEGRATOR 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
+CONFIG_MTD_SA1100=y
+# CONFIG_MTD_EDB7312 is not set
 
 #
 # Self-contained MTD device drivers
 #
-# CONFIG_MTD_PMC551 is not set
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_DOC1000 is not set
+# CONFIG_MTD_BLKMTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
 # CONFIG_MTD_DOC2000 is not set
 # CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
+# CONFIG_MTD_DOC2001PLUS is not set
 
 #
 # NAND Flash Device Drivers
@@ -195,155 +239,175 @@
 # CONFIG_MTD_NAND is not set
 
 #
-# Plug and Play configuration
+# Plug and Play support
 #
 # CONFIG_PNP is not set
-# CONFIG_ISAPNP 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_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ 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 support
+#
+CONFIG_NET=y
 
 #
 # Networking options
 #
-CONFIG_PACKET=m
+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_NETLINK_DEV is not set
 CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
 # 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_INET_ECN=y
+# CONFIG_ARPD is not set
 CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_IP_TCPDIAG is not set
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
-# CONFIG_KHTTPD is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
 # CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 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_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
 #
 # CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
 
 #
-# Network device support
+# Network testing
 #
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
 
 #
 # ARCnet devices
 #
 # CONFIG_ARCNET is not set
-CONFIG_DUMMY=m
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
-# CONFIG_NET_ETHERNET is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+CONFIG_SMC91X=y
+# 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_ACENIC_OMIT_TIGON_I is not set
-# CONFIG_MYRI_SBUS 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)
+# Ethernet (10000 Mbit)
 #
-# 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
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
 
 #
 # Wan interfaces
 #
 # CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
-# Amateur Radio support
+# ATA/ATAPI/MFM/RLL support
 #
-# CONFIG_HAMRADIO is not set
+# CONFIG_IDE is not set
 
 #
-# IrDA (infrared) support
+# SCSI device support
 #
-# CONFIG_IRDA is not set
+# CONFIG_SCSI is not set
 
 #
-# ATA/IDE/MFM/RLL support
+# Fusion MPT device support
 #
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
 
 #
-# SCSI support
+# IEEE 1394 (FireWire) 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
 
 #
 # ISDN subsystem
@@ -351,77 +415,71 @@
 # CONFIG_ISDN is not set
 
 #
-# Input core support
+# Input device support
 #
 # CONFIG_INPUT is not set
 
 #
+# Userland interfaces
+#
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+# CONFIG_SERIO is not set
+
+#
+# Input Device Drivers
+#
+
+#
 # 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_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-# CONFIG_SERIAL_SA1100_OLD is not set
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=9600
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-# CONFIG_UCB1200 is not set
-# CONFIG_TOUCHSCREEN_UCB1200 is not set
-# CONFIG_AUDIO_UCB1200 is not set
-# CONFIG_ADC_UCB1200 is not set
-# CONFIG_TOUCHSCREEN_BITSY is not set
-CONFIG_PROFILER=y
-# CONFIG_PFS168_SPI is not set
-# CONFIG_PFS168_DTMF is not set
-# CONFIG_PFS168_MISC is not set
 
 #
-# I2C support
+# Serial drivers
 #
-# CONFIG_I2C is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
-# Mice
+# Non-8250 serial port support
 #
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
+CONFIG_SERIAL_SA1100=y
+CONFIG_SERIAL_SA1100_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
 
 #
-# Joysticks
+# IPMI
 #
-# CONFIG_JOYSTICK is not set
-# CONFIG_QIC02_TAPE is not set
+# CONFIG_IPMI_HANDLER 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_SA1100_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
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
 
 #
 # Multimedia devices
@@ -429,80 +487,155 @@
 # CONFIG_VIDEO_DEV is not set
 
 #
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
 # File systems
 #
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+# CONFIG_DNOTIFY 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
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
 # 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_HFSPLUS_FS is not set
+# CONFIG_BEFS_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_JFFS2_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_DEBUG 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_NFS_FS is not set
-# CONFIG_NFS_V3 is not set
-# CONFIG_ROOT_NFS is not set
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V4 is not set
+CONFIG_NFS_DIRECTIO=y
 # CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-# CONFIG_SUNRPC is not set
-# CONFIG_LOCKD is not set
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=m
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
+# CONFIG_CIFS 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
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_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
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
 
 #
 # Sound
@@ -510,24 +643,57 @@
 # CONFIG_SOUND is not set
 
 #
+# Misc devices
+#
+
+#
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
-# Bluetooth support
+# USB Gadget Support
 #
-# CONFIG_BT is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
 
 #
 # Kernel hacking
 #
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
+CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+CONFIG_FRAME_POINTER=y
+# CONFIG_DEBUG_USER is not set
+# CONFIG_DEBUG_WAITQ is not set
+# CONFIG_DEBUG_ERRORS is not set
+# CONFIG_DEBUG_LL is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
diff -Nru a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
--- a/arch/arm/configs/s3c2410_defconfig	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/configs/s3c2410_defconfig	2004-12-24 13:36:47 -08:00
@@ -1,10 +1,13 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Mon Nov 15 15:29:42 2004
 #
 CONFIG_ARM=y
 CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
@@ -17,6 +20,7 @@
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,6 +29,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=16
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
@@ -32,11 +37,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,6 +52,7 @@
 # CONFIG_MODULE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -59,6 +67,7 @@
 # CONFIG_ARCH_INTEGRATOR is not set
 # CONFIG_ARCH_IOP3XX is not set
 # CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
 # CONFIG_ARCH_L7200 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
@@ -67,21 +76,29 @@
 # CONFIG_ARCH_SHARK is not set
 # CONFIG_ARCH_LH7A40X is not set
 # CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_H720X is not set
 
 #
-# S3C2410 Implementations
+# S3C24XX Implementations
 #
 CONFIG_ARCH_BAST=y
 CONFIG_ARCH_H1940=y
 CONFIG_ARCH_SMDK2410=y
 CONFIG_MACH_VR1000=y
+CONFIG_MACH_RX3715=y
+CONFIG_CPU_S3C2410=y
+CONFIG_CPU_S3C2440=y
 
 #
 # S3C2410 Setup
 #
 CONFIG_S3C2410_DMA=y
 # CONFIG_S3C2410_DMA_DEBUG is not set
+# CONFIG_S3C2410_PM_DEBUG is not set
+# CONFIG_S3C2410_PM_CHECK is not set
+CONFIG_S3C2410_LOWLEVEL_UART_PORT=0
 
 #
 # Processor Type
@@ -91,6 +108,7 @@
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
 CONFIG_CPU_CACHE_V4WT=y
+CONFIG_CPU_CACHE_VIVT=y
 CONFIG_CPU_COPY_V4WB=y
 CONFIG_CPU_TLB_V4WBI=y
 
@@ -108,14 +126,14 @@
 # CONFIG_ZBOOT_ROM is not set
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_XIP_KERNEL is not set
 
 #
 # At least one math emulation must be selected
 #
 CONFIG_FPE_NWFPE=y
-CONFIG_FPE_NWFPE_XP=y
+# CONFIG_FPE_NWFPE_XP is not set
 # CONFIG_FPE_FASTFPE is not set
-# CONFIG_VFP is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_AOUT=y
 # CONFIG_BINFMT_MISC is not set
@@ -126,8 +144,9 @@
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_DEBUG_DRIVER is not set
-# CONFIG_PM is not set
+CONFIG_PM=y
 # CONFIG_PREEMPT is not set
+CONFIG_APM=y
 # CONFIG_ARTHUR is not set
 CONFIG_CMDLINE="root=/dev/hda1 ro init=/bin/bash console=ttySAC0"
 CONFIG_ALIGNMENT_TRAP=y
@@ -136,10 +155,7 @@
 # Parallel port support
 #
 CONFIG_PARPORT=y
-CONFIG_PARPORT_PC=y
-CONFIG_PARPORT_PC_CML1=y
-CONFIG_PARPORT_PC_FIFO=y
-CONFIG_PARPORT_PC_SUPERIO=y
+# CONFIG_PARPORT_PC is not set
 # CONFIG_PARPORT_ARC is not set
 CONFIG_PARPORT_OTHER=y
 CONFIG_PARPORT_1284=y
@@ -149,8 +165,13 @@
 #
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_PARTITIONS is not set
+CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
 
 #
 # User Modules And Translation Layers
@@ -165,14 +186,14 @@
 # RAM/ROM/Flash chip drivers
 #
 CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_JEDECPROBE=y
 CONFIG_MTD_GEN_PROBE=y
 # CONFIG_MTD_CFI_ADV_OPTIONS is not set
 CONFIG_MTD_MAP_BANK_WIDTH_1=y
 CONFIG_MTD_MAP_BANK_WIDTH_2=y
 CONFIG_MTD_MAP_BANK_WIDTH_4=y
 # CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+CONFIG_MTD_MAP_BANK_WIDTH_16=y
 # CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
 CONFIG_MTD_CFI_I1=y
 CONFIG_MTD_CFI_I2=y
@@ -194,6 +215,9 @@
 # CONFIG_MTD_PHYSMAP is not set
 # CONFIG_MTD_ARM_INTEGRATOR is not set
 # CONFIG_MTD_EDB7312 is not set
+# CONFIG_MTD_IMPA7 is not set
+CONFIG_MTD_BAST=y
+CONFIG_MTD_BAST_MAXSIZE=4
 
 #
 # Self-contained MTD device drivers
@@ -213,7 +237,13 @@
 #
 # NAND Flash Device Drivers
 #
-# CONFIG_MTD_NAND is not set
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_IDS=y
+CONFIG_MTD_NAND_S3C2410=y
+# CONFIG_MTD_NAND_S3C2410_DEBUG is not set
+# CONFIG_MTD_NAND_S3C2410_HWECC is not set
+# CONFIG_MTD_NAND_DISKONCHIP is not set
 
 #
 # Plug and Play support
@@ -230,6 +260,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # Multi-device support (RAID and LVM)
@@ -262,6 +302,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -281,7 +324,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -354,13 +396,13 @@
 CONFIG_BLK_DEV_IDETAPE=m
 CONFIG_BLK_DEV_IDEFLOPPY=m
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
 #
 CONFIG_IDE_GENERIC=y
 # CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDE_BAST=y
 # CONFIG_BLK_DEV_IDEDMA is not set
 # CONFIG_IDEDMA_AUTO is not set
 # CONFIG_BLK_DEV_HD is not set
@@ -411,10 +453,10 @@
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
 CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -483,7 +525,6 @@
 # CONFIG_LP_CONSOLE is not set
 CONFIG_PPDEV=y
 # CONFIG_TIPAR is not set
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -493,16 +534,23 @@
 #
 # Watchdog Cards
 #
-# CONFIG_WATCHDOG is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_S3C2410_WATCHDOG=y
 # CONFIG_NVRAM is not set
-CONFIG_RTC=y
+# CONFIG_RTC is not set
+CONFIG_S3C2410_RTC=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
@@ -517,16 +565,17 @@
 #
 CONFIG_I2C_ALGOBIT=m
 # CONFIG_I2C_ALGOPCF is not set
+# CONFIG_I2C_ALGOPCA is not set
 
 #
 # I2C Hardware Bus support
 #
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
 # CONFIG_I2C_ISA is not set
 # CONFIG_I2C_PARPORT is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_SCx200_ACB is not set
+CONFIG_I2C_S3C2410=y
+# CONFIG_I2C_STUB is not set
+# CONFIG_I2C_PCA_ISA is not set
 
 #
 # Hardware Sensors Chip support
@@ -540,14 +589,18 @@
 # CONFIG_SENSORS_FSCHER is not set
 # CONFIG_SENSORS_GL518SM is not set
 # CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM63 is not set
 CONFIG_SENSORS_LM75=m
 # CONFIG_SENSORS_LM77 is not set
 CONFIG_SENSORS_LM78=m
 # CONFIG_SENSORS_LM80 is not set
 # CONFIG_SENSORS_LM83 is not set
 CONFIG_SENSORS_LM85=m
+# CONFIG_SENSORS_LM87 is not set
 # CONFIG_SENSORS_LM90 is not set
 # CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_W83781D is not set
 # CONFIG_SENSORS_W83L785TS is not set
 # CONFIG_SENSORS_W83627HF is not set
@@ -592,6 +645,7 @@
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -663,6 +717,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -742,13 +797,14 @@
 # Graphics support
 #
 CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
 # CONFIG_FB_VIRTUAL is not set
 
 #
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 # CONFIG_FRAMEBUFFER_CONSOLE is not set
 
@@ -769,6 +825,9 @@
 #
 # USB support
 #
+# CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -776,17 +835,24 @@
 # CONFIG_USB_GADGET is not set
 
 #
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
 # Kernel hacking
 #
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
 CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
+# CONFIG_DEBUG_KOBJECT is not set
 # CONFIG_DEBUG_BUGVERBOSE is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_FRAME_POINTER=y
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_WAITQ is not set
 # CONFIG_DEBUG_ERRORS is not set
 CONFIG_DEBUG_LL=y
 # CONFIG_DEBUG_ICEDCC is not set
@@ -796,6 +862,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/arm/configs/sherman_defconfig b/arch/arm/configs/sherman_defconfig
--- a/arch/arm/configs/sherman_defconfig	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,215 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-
-#
-# System and processor type
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_FOOTBRIDGE is not set
-CONFIG_ARCH_SA1100=y
-CONFIG_CPU_SA1100=y
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_EMPEG is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_VICTOR is not set
-CONFIG_SA1100_SHERMAN=y
-# CONFIG_VICTOR_BOARD1 is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_ARM2 is not set
-# CONFIG_CPU_ARM3 is not set
-# CONFIG_CPU_ARM6 is not set
-# CONFIG_CPU_ARM7 is not set
-CONFIG_CPU_SA110=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_ALIGNMENT_TRAP=y
-# CONFIG_TEXT_SECTIONS is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# General setup
-#
-CONFIG_ZBOOT_ROM=y
-CONFIG_ZBOOT_ROM_TEXT=0x00050000
-CONFIG_ZBOOT_ROM_BSS=0xc0200000
-# CONFIG_NET is not set
-# CONFIG_SYSVIPC is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-# CONFIG_SYSCTL is not set
-CONFIG_NWFPE=y
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_ARTHUR is not set
-# CONFIG_PARPORT is not set
-CONFIG_CMDLINE="mem=64M@0xc0000000 mem=64M@0xc8000000 root=/dev/mtdblock2"
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_IDE is not set
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_IDEDISK is not set
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_IDE_CHIPSETS is not set
-
-#
-# Additional Block Devices
-#
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_MD is not set
-CONFIG_BLK_DEV_RAM=y
-# CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_PARIDE_PARPORT is not set
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_FLASH=y
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_UNIX98_PTYS is not set
-# CONFIG_MOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-
-#
-# Video For Linux
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Joystick support
-#
-# CONFIG_JOYSTICK is not set
-# CONFIG_DTLK is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# Filesystems
-#
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_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_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG is not set
-# CONFIG_NTFS_RW is not set
-# CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ACORN_PARTITION is not set
-CONFIG_NLS=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-# CONFIG_MAGIC_SYSRQ is not set
-CONFIG_DEBUG_LL=y
diff -Nru a/arch/arm/configs/simpad_defconfig b/arch/arm/configs/simpad_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/configs/simpad_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,896 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.9-rc2
+# Thu Sep 16 15:42:43 2004
+#
+CONFIG_ARM=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_IOMAP=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="oe1"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_HOTPLUG=y
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SHMEM=y
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+# CONFIG_MODULE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+CONFIG_KMOD=y
+
+#
+# System Type
+#
+# CONFIG_ARCH_CLPS7500 is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_CO285 is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_CAMELOT is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_IOP3XX is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_RPC is not set
+CONFIG_ARCH_SA1100=y
+# CONFIG_ARCH_S3C2410 is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_LH7A40X is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_ARCH_VERSATILE_PB is not set
+# CONFIG_ARCH_IMX is not set
+
+#
+# SA11x0 Implementations
+#
+# CONFIG_SA1100_ASSABET is not set
+# CONFIG_SA1100_ADSBITSY is not set
+# CONFIG_SA1100_BRUTUS is not set
+# CONFIG_SA1100_CERF is not set
+# CONFIG_SA1100_COLLIE is not set
+# CONFIG_SA1100_H3100 is not set
+# CONFIG_SA1100_H3600 is not set
+# CONFIG_SA1100_H3800 is not set
+# CONFIG_SA1100_EXTENEX1 is not set
+# CONFIG_SA1100_FLEXANET is not set
+# CONFIG_SA1100_FREEBIRD is not set
+# CONFIG_SA1100_GRAPHICSCLIENT is not set
+# CONFIG_SA1100_GRAPHICSMASTER is not set
+# CONFIG_SA1100_BADGE4 is not set
+# CONFIG_SA1100_JORNADA720 is not set
+# CONFIG_SA1100_HACKKIT is not set
+# CONFIG_SA1100_HUW_WEBPANEL is not set
+# CONFIG_SA1100_ITSY is not set
+# CONFIG_SA1100_LART is not set
+# CONFIG_SA1100_NANOENGINE is not set
+# CONFIG_SA1100_OMNIMETER is not set
+# CONFIG_SA1100_PANGOLIN is not set
+# CONFIG_SA1100_PLEB is not set
+# CONFIG_SA1100_PT_SYSTEM3 is not set
+# CONFIG_SA1100_SHANNON is not set
+# CONFIG_SA1100_SHERMAN is not set
+CONFIG_SA1100_SIMPAD=y
+# CONFIG_SA1100_PFS168 is not set
+# CONFIG_SA1100_VICTOR is not set
+# CONFIG_SA1100_XP860 is not set
+# CONFIG_SA1100_YOPY is not set
+# CONFIG_SA1100_STORK is not set
+# CONFIG_SA1100_SSP is not set
+# CONFIG_SA1100_USB is not set
+
+#
+# Processor Type
+#
+CONFIG_CPU_32=y
+CONFIG_CPU_SA1100=y
+CONFIG_CPU_32v4=y
+CONFIG_CPU_ABRT_EV4=y
+CONFIG_CPU_CACHE_V4WB=y
+CONFIG_CPU_TLB_V4WB=y
+CONFIG_CPU_MINICACHE=y
+
+#
+# Processor Features
+#
+
+#
+# General setup
+#
+CONFIG_DISCONTIGMEM=y
+CONFIG_ISA=y
+# CONFIG_ZBOOT_ROM is not set
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_CPU_FREQ is not set
+
+#
+# PCMCIA/CardBus support
+#
+CONFIG_PCMCIA=y
+# CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_I82365 is not set
+# CONFIG_TCIC is not set
+CONFIG_PCMCIA_SA1100=y
+
+#
+# At least one math emulation must be selected
+#
+CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
+# CONFIG_FPE_FASTFPE is not set
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_MISC=m
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=m
+# CONFIG_DEBUG_DRIVER is not set
+CONFIG_PM=y
+CONFIG_PREEMPT=y
+CONFIG_APM=y
+# CONFIG_ARTHUR is not set
+CONFIG_CMDLINE="mtdparts=sa1100:512k(boot),1m(kernel),-(root) console=ttySA0 root=1f02 noinitrd mem=64M jffs2_orphaned_inodes=delete rootfstype=jffs2"
+CONFIG_LEDS=y
+CONFIG_LEDS_TIMER=y
+# CONFIG_LEDS_CPU is not set
+CONFIG_ALIGNMENT_TRAP=y
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_CONCAT=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+CONFIG_MTD_JEDECPROBE=y
+CONFIG_MTD_GEN_PROBE=y
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+CONFIG_MTD_CFI_GEOMETRY=y
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+# CONFIG_MTD_CFI_I2 is not set
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+CONFIG_MTD_RAM=y
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_ARM_INTEGRATOR is not set
+CONFIG_MTD_SA1100=y
+# CONFIG_MTD_EDB7312 is not set
+# CONFIG_MTD_IMPA7 is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLKMTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+
+#
+# Plug and Play support
+#
+# CONFIG_PNP is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+CONFIG_BLK_DEV_LOOP=m
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_SIZE=8192
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+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_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
+CONFIG_IRLAN=m
+CONFIG_IRNET=m
+CONFIG_IRCOMM=m
+# CONFIG_IRDA_ULTRA is not set
+
+#
+# IrDA options
+#
+# CONFIG_IRDA_CACHE_LAST_LSAP is not set
+# CONFIG_IRDA_FAST_RR is not set
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+CONFIG_IRTTY_SIR=m
+
+#
+# Dongle support
+#
+# CONFIG_DONGLE is not set
+
+#
+# Old SIR device drivers
+#
+CONFIG_IRPORT_SIR=m
+
+#
+# Old Serial dongle support
+#
+# CONFIG_DONGLE_OLD is not set
+
+#
+# FIR device drivers
+#
+# CONFIG_NSC_FIR is not set
+# CONFIG_WINBOND_FIR is not set
+# CONFIG_SMC_IRCC_FIR is not set
+# CONFIG_ALI_FIR is not set
+CONFIG_SA1100_FIR=m
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+# CONFIG_BT_HIDP is not set
+
+#
+# Bluetooth device drivers
+#
+# CONFIG_BT_HCIUART is not set
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+# CONFIG_BT_HCIVHCI is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=y
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_SMC91X 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_AC3200 is not set
+# CONFIG_APRICOT is not set
+# CONFIG_CS89x0 is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+CONFIG_NET_RADIO=y
+
+#
+# Obsolete Wireless cards support (pre-802.11)
+#
+# CONFIG_STRIP is not set
+# CONFIG_ARLAN is not set
+# CONFIG_WAVELAN is not set
+CONFIG_PCMCIA_WAVELAN=m
+# CONFIG_PCMCIA_NETWAVE is not set
+
+#
+# Wireless 802.11 Frequency Hopping cards support
+#
+# CONFIG_PCMCIA_RAYCS is not set
+
+#
+# Wireless 802.11b ISA/PCI cards support
+#
+# CONFIG_HERMES is not set
+# CONFIG_ATMEL is not set
+
+#
+# Wireless 802.11b Pcmcia/Cardbus cards support
+#
+CONFIG_AIRO_CS=m
+# CONFIG_PCMCIA_WL3501 is not set
+CONFIG_NET_WIRELESS=y
+
+#
+# PCMCIA network device support
+#
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+# CONFIG_PCMCIA_FMVJ18X is not set
+CONFIG_PCMCIA_PCNET=m
+# CONFIG_PCMCIA_NMCLAN is not set
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+# CONFIG_PCMCIA_AXNET is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=800
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=600
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_TSDEV=y
+CONFIG_INPUT_TSDEV_SCREEN_X=800
+CONFIG_INPUT_TSDEV_SCREEN_Y=600
+CONFIG_INPUT_EVDEV=m
+CONFIG_INPUT_EVBUG=y
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_CT82C710=m
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_SA1100=y
+CONFIG_SERIAL_SA1100_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=m
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_JBD=m
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=m
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+CONFIG_REISERFS_PROC_INFO=y
+# CONFIG_REISERFS_FS_XATTR is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+# CONFIG_TMPFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_JFFS_FS=m
+CONFIG_JFFS_FS_VERBOSE=0
+# CONFIG_JFFS_PROC_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+# CONFIG_JFFS2_FS_NAND is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+# CONFIG_NFSD is not set
+# CONFIG_ROOT_NFS is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+# CONFIG_SMB_NLS_DEFAULT is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+CONFIG_NLS_CODEPAGE_850=y
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+CONFIG_NLS_ISO8859_15=y
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_SA1100 is not set
+CONFIG_FB_MQ200=y
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+# CONFIG_MDA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+
+#
+# Sound
+#
+CONFIG_SOUND=y
+
+#
+# Advanced Linux Sound Architecture
+#
+# CONFIG_SND is not set
+
+#
+# Open Sound System
+#
+# CONFIG_SOUND_PRIME is not set
+
+#
+# Misc devices
+#
+
+#
+# USB support
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+CONFIG_FRAME_POINTER=y
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_WAITQ is not set
+CONFIG_DEBUG_ERRORS=y
+CONFIG_DEBUG_LL=y
+# CONFIG_DEBUG_ICEDCC is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/arm/configs/stork_defconfig b/arch/arm/configs/stork_defconfig
--- a/arch/arm/configs/stork_defconfig	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,961 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-# CONFIG_GENERIC_BUST_SPINLOCK is not set
-# CONFIG_GENERIC_ISA_DMA is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# System Type
-#
-# CONFIG_ARCH_ADIFCC is not set
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP310 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_ADSBITSY is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_H3100 is not set
-CONFIG_SA1100_H3600=y
-# CONFIG_SA1100_H3800 is not set
-CONFIG_SA1100_H3XXX=y
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-# CONFIG_SA1100_BADGE4 is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_PT_SYSTEM3 is not set
-# CONFIG_SA1100_SHANNON is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-CONFIG_SA1100_USB=m
-CONFIG_SA1100_USB_NETLINK=m
-# CONFIG_SA1100_USB_CHAR is not set
-CONFIG_H3600_SLEEVE=m
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_AUTCPU12 is not set
-# CONFIG_ARCH_CDB89712 is not set
-# CONFIG_ARCH_CLEP7312 is not set
-# CONFIG_ARCH_EDB7211 is not set
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_FORTUNET is not set
-# CONFIG_ARCH_EP7211 is not set
-# CONFIG_ARCH_EP7212 is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM922T is not set
-# CONFIG_CPU_ARM926T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-# CONFIG_XSCALE_PMU is not set
-# CONFIG_ARM_THUMB is not set
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-CONFIG_ISA=y
-# CONFIG_ISA_DMA is not set
-# CONFIG_FIQ is not set
-CONFIG_CPU_FREQ=y
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-CONFIG_PCMCIA_PROBE=y
-# CONFIG_I82092 is not set
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=m
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-
-#
-# At least one math emulation must be selected
-#
-CONFIG_FPE_NWFPE=m
-CONFIG_FPE_FASTFPE=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_PM=y
-# CONFIG_APM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="N"
-# CONFIG_LEDS is not set
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-CONFIG_MTD_REDBOOT_PARTS=y
-CONFIG_MTD_BOOTLDR_PARTS=y
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-CONFIG_MTD_CFI_ADV_OPTIONS=y
-CONFIG_MTD_CFI_NOSWAP=y
-# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_GEOMETRY is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-# CONFIG_MTD_AMDSTD is not set
-# CONFIG_MTD_SHARP is not set
-# CONFIG_MTD_JEDEC is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-# CONFIG_MTD_CDB89712 is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-# CONFIG_MTD_EPXA10DB is not set
-# CONFIG_MTD_PCI is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD 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
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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_CISS_SCSI_TAPE 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 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_MD_MULTIPATH is not set
-# CONFIG_BLK_DEV_LVM is not set
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_NETLINK=y
-CONFIG_RTNETLINK=y
-# CONFIG_NETLINK_DEV 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 is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE 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
-# CONFIG_KHTTPD is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q 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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-# CONFIG_NET_ETHERNET 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=m
-# CONFIG_PPP_MULTILINK is not set
-# CONFIG_PPP_FILTER is not set
-CONFIG_PPP_ASYNC=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-CONFIG_PPP_BSDCOMP=m
-# CONFIG_PPPOE is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-CONFIG_NET_RADIO=y
-# CONFIG_STRIP is not set
-CONFIG_WAVELAN=m
-# CONFIG_ARLAN is not set
-# CONFIG_AIRONET4500 is not set
-# CONFIG_AIRONET4500_NONCS is not set
-# CONFIG_AIRONET4500_PROC is not set
-# CONFIG_AIRO is not set
-CONFIG_HERMES=m
-
-#
-# Wireless Pcmcia cards support
-#
-CONFIG_PCMCIA_HERMES=m
-# CONFIG_AIRO_CS is not set
-CONFIG_NET_WIRELESS=y
-
-#
-# 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-CONFIG_PCMCIA_XIRC2PS=m
-# CONFIG_PCMCIA_AXNET is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=m
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=m
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=m
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-CONFIG_BLK_DEV_IDECD=m
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-#
-# 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN 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
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-CONFIG_SERIAL=y
-CONFIG_SERIAL_CONSOLE=y
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_UART00 is not set
-# CONFIG_SERIAL_UART00_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=115200
-CONFIG_SERIAL_8250=m
-# CONFIG_SERIAL_8250_CONSOLE is not set
-# CONFIG_ATOMWIDE_SERIAL is not set
-# CONFIG_DUALSP_SERIAL is not set
-# CONFIG_SERIAL_8250_EXTENDED is not set
-# CONFIG_SERIAL_8250_MANY_PORTS is not set
-# CONFIG_SERIAL_8250_SHARE_IRQ is not set
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_MULTIPORT is not set
-# CONFIG_SERIAL_8250_RSA is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# L3 serial bus support
-#
-CONFIG_L3=y
-CONFIG_L3_ALGOBIT=y
-CONFIG_L3_BIT_SA1100_GPIO=y
-
-#
-# Other L3 adapters
-#
-# CONFIG_L3_SA1111 is not set
-CONFIG_BIT_SA1100_GPIO=y
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-CONFIG_MOUSE=m
-# CONFIG_PSMOUSE is not set
-# CONFIG_82C710_MOUSE is not set
-# CONFIG_PC110_PAD 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_SA1100_RTC=m
-# 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
-
-#
-# PCMCIA character devices
-#
-# CONFIG_PCMCIA_SERIAL_CS 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_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_JBD_DEBUG 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_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-CONFIG_CRAMFS=y
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# CONFIG_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG is not set
-# CONFIG_NTFS_RW is not set
-# CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# 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=y
-# CONFIG_ROOT_NFS is not set
-CONFIG_NFSD=m
-CONFIG_NFSD_V3=y
-CONFIG_SUNRPC=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=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
-# CONFIG_ZISOFS_FS is not set
-CONFIG_ZLIB_FS_INFLATE=y
-
-#
-# 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 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_VIRTUAL is not set
-CONFIG_FBCON_ADVANCED=y
-# CONFIG_FBCON_MFB is not set
-# CONFIG_FBCON_CFB2 is not set
-# CONFIG_FBCON_CFB4 is not set
-# CONFIG_FBCON_CFB8 is not set
-CONFIG_FBCON_CFB16=y
-# CONFIG_FBCON_CFB24 is not set
-# CONFIG_FBCON_CFB32 is not set
-# CONFIG_FBCON_AFB is not set
-# CONFIG_FBCON_ILBM is not set
-# CONFIG_FBCON_IPLAN2P2 is not set
-# CONFIG_FBCON_IPLAN2P4 is not set
-# CONFIG_FBCON_IPLAN2P8 is not set
-# CONFIG_FBCON_MAC is not set
-# CONFIG_FBCON_VGA_PLANES is not set
-# CONFIG_FBCON_VGA is not set
-# CONFIG_FBCON_HGA is not set
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-CONFIG_SOUND=y
-# 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
-# CONFIG_SOUND_ES1371 is not set
-# CONFIG_SOUND_ESSSOLO1 is not set
-# 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
-# CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_VIA82CXXX is not set
-# CONFIG_MIDI_VIA82CXXX is not set
-CONFIG_SOUND_SA1100=y
-CONFIG_SOUND_UDA1341=m
-# CONFIG_SOUND_ASSABET_UDA1341 is not set
-CONFIG_SOUND_H3600_UDA1341=m
-# CONFIG_SOUND_PANGOLIN_UDA1341 is not set
-# CONFIG_SOUND_SA1111_UDA1341 is not set
-# CONFIG_SOUND_SA1100SSP is not set
-# CONFIG_SOUND_OSS is not set
-# CONFIG_SOUND_WAVEARTIST is not set
-# CONFIG_SOUND_TVMIXER is not set
-
-#
-# Multimedia Capabilities Port drivers
-#
-# CONFIG_MCP is not set
-# CONFIG_MCP_SA1100 is not set
-# CONFIG_MCP_UCB1200 is not set
-# CONFIG_MCP_UCB1200_AUDIO is not set
-# CONFIG_MCP_UCB1200_TS is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Host Controller Drivers
-#
-# CONFIG_USB_EHCI_HCD is not set
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-# CONFIG_USB_OHCI is not set
-# CONFIG_USB_OHCI_SA1111 is not set
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-
-#
-#   SCSI support is needed for USB Storage
-#
-# 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_ISD200 is not set
-# CONFIG_USB_STORAGE_DPCM is not set
-# CONFIG_USB_STORAGE_HP8200e is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT 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
-#
-
-#
-# USB Network adaptors
-#
-# 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_IPAQ is not set
-# CONFIG_USB_SERIAL_IR 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_USA28XA is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XB 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_KLSI is not set
-# CONFIG_USB_SERIAL_PL2303 is not set
-# CONFIG_USB_SERIAL_CYBERJACK is not set
-# CONFIG_USB_SERIAL_XIRCOM is not set
-# CONFIG_USB_SERIAL_OMNINET is not set
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_AUERSWALD is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-# CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_NO_PGT_CACHE is not set
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
-# CONFIG_DEBUG_BUGVERBOSE is not set
-# CONFIG_DEBUG_ERRORS is not set
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
diff -Nru a/arch/arm/configs/system3_defconfig b/arch/arm/configs/system3_defconfig
--- a/arch/arm/configs/system3_defconfig	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,962 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-# CONFIG_GENERIC_BUST_SPINLOCK is not set
-# CONFIG_GENERIC_ISA_DMA is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Archimedes/A5000 Implementations (select only ONE)
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_ADSBITSY is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_H3600 is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHANNON is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-CONFIG_SA1100_PT_SYSTEM3=y
-CONFIG_SA1111=y
-CONFIG_FORCE_MAX_ZONEORDER=9
-CONFIG_SA1100_USB=m
-CONFIG_SA1100_USB_NETLINK=m
-CONFIG_SA1100_USB_CHAR=m
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_AUTCPU12 is not set
-# CONFIG_ARCH_CDB89712 is not set
-# CONFIG_ARCH_CLEP7312 is not set
-# CONFIG_ARCH_EDB7211 is not set
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_EP7211 is not set
-# CONFIG_ARCH_EP7212 is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM922T is not set
-# CONFIG_CPU_ARM926T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-# CONFIG_ARM_THUMB is not set
-CONFIG_DISCONTIGMEM=y
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-CONFIG_ISA=y
-# CONFIG_ISA_DMA is not set
-CONFIG_CPU_FREQ=y
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_I82092 is not set
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=m
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-
-#
-# At least one math emulation must be selected
-#
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_PM=y
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="noinitrd root=/dev/mtdblock3"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-CONFIG_MTD_REDBOOT_PARTS=m
-CONFIG_MTD_BOOTLDR_PARTS=m
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-# CONFIG_MTD_CHAR is not set
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-# CONFIG_MTD_AMDSTD is not set
-# CONFIG_MTD_SHARP is not set
-# CONFIG_MTD_JEDEC is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-# CONFIG_MTD_CDB89712 is not set
-CONFIG_MTD_SA1100=y
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-# CONFIG_MTD_PCI is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD 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
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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=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_MD_MULTIPATH 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 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_VLAN_8021Q 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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-CONFIG_DUMMY=m
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_ARM_AM79C961A is not set
-# 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=y
-# CONFIG_WD80x3 is not set
-# CONFIG_ULTRAMCA is not set
-# CONFIG_ULTRA is not set
-# CONFIG_ULTRA32 is not set
-CONFIG_SMC9194=m
-# 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_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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-CONFIG_PCMCIA_SMC91C92=m
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-# CONFIG_NET_PCMCIA_RADIO is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-CONFIG_IRDA=m
-
-#
-# IrDA protocols
-#
-CONFIG_IRLAN=m
-# CONFIG_IRNET is not set
-CONFIG_IRCOMM=m
-# CONFIG_IRDA_ULTRA is not set
-# CONFIG_IRDA_OPTIONS is not set
-
-#
-# Infrared-port device drivers
-#
-
-#
-# SIR device drivers
-#
-CONFIG_IRTTY_SIR=m
-CONFIG_IRPORT_SIR=m
-
-#
-# Dongle support
-#
-# CONFIG_DONGLE is not set
-
-#
-# FIR device drivers
-#
-# CONFIG_USB_IRDA is not set
-# CONFIG_NSC_FIR is not set
-# CONFIG_WINBOND_FIR is not set
-# CONFIG_TOSHIBA_FIR is not set
-# CONFIG_SMC_IRCC_FIR is not set
-# CONFIG_ALI_FIR is not set
-# CONFIG_VLSI_FIR is not set
-CONFIG_SA1100_FIR=m
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-#
-# 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-CONFIG_INPUT=y
-CONFIG_INPUT_KEYBDEV=y
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-# CONFIG_VT_CONSOLE is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_UART00 is not set
-# CONFIG_SERIAL_UART00_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SA1100_DEFAULT_BAUDRATE=38400
-CONFIG_SERIAL_8250=m
-# CONFIG_SERIAL_8250_CONSOLE is not set
-# CONFIG_SERIAL_8250_EXTENDED is not set
-# CONFIG_SERIAL_8250_MANY_PORTS is not set
-# CONFIG_SERIAL_8250_SHARE_IRQ is not set
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_MULTIPORT is not set
-# CONFIG_SERIAL_8250_HUB6 is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# L3 serial bus support
-#
-# CONFIG_L3 is not set
-# CONFIG_L3_ALGOBIT is not set
-# CONFIG_L3_BIT_SA1100_GPIO is not set
-
-#
-# Other L3 adapters
-#
-# CONFIG_L3_SA1111 is not set
-# CONFIG_BIT_SA1100_GPIO is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
-
-#
-# Joysticks
-#
-# CONFIG_INPUT_GAMEPORT is not set
-# CONFIG_INPUT_NS558 is not set
-# CONFIG_INPUT_LIGHTNING is not set
-# CONFIG_INPUT_PCIGAME is not set
-# CONFIG_INPUT_CS461X is not set
-# CONFIG_INPUT_EMU10K1 is not set
-# CONFIG_INPUT_SERIO is not set
-# CONFIG_INPUT_SERPORT is not set
-
-#
-# Joysticks
-#
-# CONFIG_INPUT_ANALOG is not set
-# CONFIG_INPUT_A3D is not set
-# CONFIG_INPUT_ADI is not set
-# CONFIG_INPUT_COBRA is not set
-# CONFIG_INPUT_GF2K is not set
-# CONFIG_INPUT_GRIP is not set
-# CONFIG_INPUT_INTERACT is not set
-# CONFIG_INPUT_TMDC is not set
-# CONFIG_INPUT_SIDEWINDER is not set
-# CONFIG_INPUT_IFORCE_USB is not set
-# CONFIG_INPUT_IFORCE_232 is not set
-# CONFIG_INPUT_WARRIOR is not set
-# CONFIG_INPUT_MAGELLAN is not set
-# CONFIG_INPUT_SPACEORB is not set
-# CONFIG_INPUT_SPACEBALL is not set
-# CONFIG_INPUT_STINGER is not set
-# CONFIG_INPUT_DB9 is not set
-# CONFIG_INPUT_GAMECON is not set
-# CONFIG_INPUT_TURBOGRAFX is not set
-# 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_SA1100_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
-
-#
-# PCMCIA character devices
-#
-CONFIG_PCMCIA_SERIAL_CS=m
-
-#
-# 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_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
-# 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=y
-CONFIG_JFFS2_FS_DEBUG=0
-# 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_ZISOFS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG 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 is not set
-# 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
-# CONFIG_ZISOFS_FS is not set
-# CONFIG_ZLIB_FS_INFLATE 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 is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_SMB_NLS is not set
-CONFIG_NLS=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-CONFIG_NLS_CODEPAGE_437=y
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Console drivers
-#
-CONFIG_PC_KEYMAP=y
-# CONFIG_VGA_CONSOLE is not set
-
-#
-# Frame-buffer support
-#
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_ACORN is not set
-# CONFIG_FB_CLPS711X is not set
-CONFIG_FB_SA1100=y
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB2=y
-CONFIG_FBCON_CFB4=y
-CONFIG_FBCON_CFB8=y
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_FONTWIDTH8_ONLY=y
-CONFIG_FBCON_FONTS=y
-CONFIG_FONT_8x8=y
-# CONFIG_FONT_8x16 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# Multimedia Capabilities Port drivers
-#
-# CONFIG_MCP is not set
-# CONFIG_MCP_SA1100 is not set
-# CONFIG_MCP_UCB1200 is not set
-# CONFIG_MCP_UCB1200_AUDIO is not set
-# CONFIG_MCP_UCB1200_TS is not set
-
-#
-# USB support
-#
-CONFIG_USB=m
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-# CONFIG_USB_LONG_TIMEOUT is not set
-
-#
-# USB Controllers
-#
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-# CONFIG_USB_OHCI is not set
-CONFIG_USB_OHCI_SA1111=m
-
-#
-# 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_ISD200 is not set
-# CONFIG_USB_STORAGE_DPCM is not set
-# CONFIG_USB_STORAGE_HP8200e is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT is not set
-# CONFIG_USB_ACM is not set
-CONFIG_USB_PRINTER=m
-
-#
-# USB Human Interface Devices (HID)
-#
-CONFIG_USB_HID=m
-CONFIG_USB_HIDDEV=y
-CONFIG_USB_KBD=m
-CONFIG_USB_MOUSE=m
-# CONFIG_USB_WACOM is not set
-
-#
-# 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
-#
-
-#
-# USB Network adaptors
-#
-# 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=m
-
-#
-# 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_IR 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_USA28XA is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XB 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_XIRCOM is not set
-# CONFIG_USB_SERIAL_OMNINET is not set
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_RIO500 is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_KERNEL=y
-CONFIG_DEBUG_SLAB=y
-CONFIG_MAGIC_SYSRQ=y
-CONFIG_DEBUG_SPINLOCK=y
-CONFIG_DEBUG_WAITQ=y
-CONFIG_DEBUG_BUGVERBOSE=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff -Nru a/arch/arm/configs/trizeps_defconfig b/arch/arm/configs/trizeps_defconfig
--- a/arch/arm/configs/trizeps_defconfig	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,843 +0,0 @@
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-# CONFIG_GENERIC_BUST_SPINLOCK is not set
-# CONFIG_GENERIC_ISA_DMA is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# System Type
-#
-# CONFIG_ARCH_ADIFCC is not set
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_PXA is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP310 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-CONFIG_ARCH_SA1100=y
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_AUTCPU12 is not set
-# CONFIG_ARCH_CDB89712 is not set
-# CONFIG_ARCH_CEIVA is not set
-# CONFIG_ARCH_CLEP7312 is not set
-# CONFIG_ARCH_EDB7211 is not set
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_FORTUNET is not set
-# CONFIG_ARCH_EP7211 is not set
-# CONFIG_ARCH_EP7212 is not set
-
-#
-# Epxa10db
-#
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# IOP310 Implementation Options
-#
-# CONFIG_ARCH_IQ80310 is not set
-# CONFIG_IOP310_AAU is not set
-# CONFIG_IOP310_DMA is not set
-# CONFIG_IOP310_MU is not set
-# CONFIG_IOP310_PMON is not set
-
-#
-# Intel PXA250/210 Implementations
-#
-# CONFIG_ARCH_LUBBOCK is not set
-# CONFIG_ARCH_PXA_IDP is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_ADSBITSY is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_H3100 is not set
-# CONFIG_SA1100_H3600 is not set
-# CONFIG_SA1100_H3800 is not set
-# CONFIG_SA1100_H3XXX is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-# CONFIG_SA1100_BADGE4 is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_PT_SYSTEM3 is not set
-# CONFIG_SA1100_SHANNON is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-CONFIG_SA1100_TRIZEPS=y
-CONFIG_TRIZEPS_MFTB2=y
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_STORK is not set
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
-# CONFIG_H3600_SLEEVE is not set
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-# CONFIG_SA1111 is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM922T is not set
-# CONFIG_CPU_ARM926T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-CONFIG_CPU_SA1100=y
-# CONFIG_CPU_XSCALE is not set
-# CONFIG_CPU_32v3 is not set
-CONFIG_CPU_32v4=y
-# CONFIG_CPU_32v5 is not set
-# CONFIG_ARM_THUMB is not set
-
-#
-# General setup
-#
-CONFIG_DISCONTIGMEM=y
-# CONFIG_PCI is not set
-CONFIG_ISA=y
-# CONFIG_ISA_DMA is not set
-# CONFIG_FIQ is not set
-# CONFIG_ZBOOT_ROM is not set
-CONFIG_ZBOOT_ROM_TEXT=0
-CONFIG_ZBOOT_ROM_BSS=0
-# CONFIG_CPU_FREQ is not set
-# CONFIG_CPU_FREQ_24_API is not set
-# CONFIG_CPU_FREQ_26_API is not set
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_I82092 is not set
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_CLPS6700 is not set
-CONFIG_PCMCIA_SA1100=m
-# CONFIG_PCMCIA_SA1111 is not set
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_APM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="keepinitrd mem=16M root=/dev/hda2 1"
-# CONFIG_LEDS is not set
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=m
-CONFIG_MTD_CONCAT=m
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
-CONFIG_MTD_AFS_PARTS=m
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-# CONFIG_MTD_AMDSTD is not set
-# CONFIG_MTD_SHARP is not set
-# CONFIG_MTD_JEDEC is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-# CONFIG_MTD_CDB89712 is not set
-CONFIG_MTD_SA1100=m
-# CONFIG_MTD_2PARTS_IPAQ is not set
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-# CONFIG_MTD_EPXA10DB is not set
-# CONFIG_MTD_FORTUNET is not set
-# CONFIG_MTD_AUTCPU12 is not set
-# CONFIG_MTD_EDB7312 is not set
-# CONFIG_MTD_IMPA7 is not set
-# CONFIG_MTD_CEIVA is not set
-# CONFIG_MTD_PCI is not set
-# CONFIG_MTD_PCMCIA is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-# 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
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_PNP_NAMES is not set
-# CONFIG_PNP_DEBUG is not set
-# CONFIG_ISAPNP is not set
-# CONFIG_PNPBIOS 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_CISS_SCSI_TAPE is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM 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_MD_MULTIPATH is not set
-# CONFIG_BLK_DEV_LVM is not set
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV 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 is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE 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
-
-#
-#    SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_DEV_APPLETALK is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-# CONFIG_NET_ETHERNET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_E1000_NAPI 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_TIGON3 is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PLIP is not set
-CONFIG_PPP=m
-# CONFIG_PPP_MULTILINK is not set
-# CONFIG_PPP_FILTER is not set
-CONFIG_PPP_ASYNC=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-CONFIG_PPP_BSDCOMP=m
-# CONFIG_PPPOE is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-CONFIG_NET_RADIO=y
-# CONFIG_STRIP is not set
-# CONFIG_ARLAN is not set
-# CONFIG_AIRONET4500 is not set
-# CONFIG_AIRONET4500_NONCS is not set
-# CONFIG_AIRONET4500_PROC is not set
-# CONFIG_WAVELAN is not set
-# CONFIG_AIRO is not set
-# CONFIG_HERMES is not set
-# CONFIG_PCMCIA_NETWAVE is not set
-# CONFIG_PCMCIA_WAVELAN is not set
-# CONFIG_PCMCIA_HERMES is not set
-CONFIG_AIRO_CS=m
-CONFIG_NET_WIRELESS=y
-
-#
-# 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
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-# CONFIG_ARCNET_COM20020_CS is not set
-# CONFIG_PCMCIA_IBMTR is not set
-CONFIG_NET_PCMCIA_RADIO=y
-# CONFIG_PCMCIA_RAYCS is not set
-# CONFIG_AIRONET4500_CS is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-# CONFIG_BLK_DEV_HD_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_IDEDISK_STROKE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
-# CONFIG_BLK_DEV_ISAPNP is not set
-# CONFIG_BLK_DEV_IDE_ICSIDE is not set
-# CONFIG_BLK_DEV_IDEDMA_ICS is not set
-# CONFIG_IDEDMA_ICS_AUTO is not set
-# CONFIG_BLK_DEV_IDEDMA is not set
-# CONFIG_BLK_DEV_IDE_RAPIDE is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_IDEDMA_AUTO 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_TSLIBDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_GAMEPORT_NS558 is not set
-# CONFIG_GAMEPORT_L4 is not set
-# CONFIG_GAMEPORT_EMU10K1 is not set
-# CONFIG_GAMEPORT_VORTEX is not set
-# CONFIG_GAMEPORT_FM801 is not set
-# CONFIG_GAMEPORT_CS461x is not set
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PARKBD is not set
-# CONFIG_SERIO_RPCKBD is not set
-# CONFIG_SERIO_AMBAKMI is not set
-# CONFIG_SERIO_SA1111 is not set
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_KEYBOARD_ATKBD is not set
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_MOUSE_PS2 is not set
-# CONFIG_MOUSE_SERIAL is not set
-# CONFIG_MOUSE_INPORT is not set
-# CONFIG_MOUSE_LOGIBM is not set
-# CONFIG_MOUSE_PC110PAD is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_JOYSTICK_ANALOG is not set
-# CONFIG_JOYSTICK_A3D is not set
-# CONFIG_JOYSTICK_ADI is not set
-# CONFIG_JOYSTICK_COBRA is not set
-# CONFIG_JOYSTICK_GF2K is not set
-# CONFIG_JOYSTICK_GRIP is not set
-# CONFIG_JOYSTICK_GRIP_MP is not set
-# CONFIG_JOYSTICK_GUILLEMOT is not set
-# CONFIG_JOYSTICK_INTERACT is not set
-# CONFIG_JOYSTICK_SIDEWINDER is not set
-# CONFIG_JOYSTICK_TMDC is not set
-# CONFIG_JOYSTICK_IFORCE is not set
-# CONFIG_JOYSTICK_WARRIOR is not set
-# CONFIG_JOYSTICK_MAGELLAN is not set
-# CONFIG_JOYSTICK_SPACEORB is not set
-# CONFIG_JOYSTICK_SPACEBALL is not set
-# CONFIG_JOYSTICK_STINGER is not set
-# CONFIG_JOYSTICK_TWIDDLER is not set
-# CONFIG_JOYSTICK_DB9 is not set
-# CONFIG_JOYSTICK_GAMECON is not set
-# CONFIG_JOYSTICK_TURBOGRAFX is not set
-# CONFIG_INPUT_JOYDUMP is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_TOUCHSCREEN_GUNZE is not set
-# CONFIG_INPUT_MISC is not set
-# CONFIG_INPUT_PCSPKR is not set
-# CONFIG_INPUT_UINPUT is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-# CONFIG_SERIAL_8250_CONSOLE is not set
-# CONFIG_SERIAL_8250_CS is not set
-# CONFIG_SERIAL_8250_EXTENDED is not set
-# CONFIG_SERIAL_8250_MANY_PORTS is not set
-# CONFIG_SERIAL_8250_SHARE_IRQ is not set
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_MULTIPORT is not set
-# CONFIG_SERIAL_8250_RSA is not set
-# CONFIG_SERIAL_ACORN is not set
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X_OLD_NAME is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_UART00 is not set
-# CONFIG_SERIAL_UART00_CONSOLE is not set
-CONFIG_SERIAL_SA1100=y
-CONFIG_SERIAL_SA1100_CONSOLE=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_UNIX98_PTYS is not set
-
-#
-# I2C support
-#
-CONFIG_I2C=m
-CONFIG_I2C_ALGOBIT=m
-# CONFIG_SCx200_I2C is not set
-# CONFIG_SCx200_ACB is not set
-# CONFIG_I2C_BIT_SA1100_GPIO is not set
-# CONFIG_I2C_ALGOPCF is not set
-CONFIG_I2C_CHARDEV=m
-CONFIG_I2C_PROC=m
-
-#
-# L3 serial bus support
-#
-# CONFIG_L3 is not set
-# CONFIG_L3_ALGOBIT is not set
-# CONFIG_L3_BIT_SA1100_GPIO is not set
-# CONFIG_BIT_SA1100_GPIO is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_SA1100_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
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_SCx200_GPIO is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# File systems
-#
-# CONFIG_QUOTA is not set
-# CONFIG_QFMT_V1 is not set
-# CONFIG_QFMT_V2 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_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=y
-# CONFIG_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_JFS_DEBUG is not set
-# CONFIG_JFS_STATISTICS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG 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
-# CONFIG_XFS_FS is not set
-# CONFIG_XFS_RT is not set
-# CONFIG_XFS_QUOTA 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_NFS_V4 is not set
-# CONFIG_ROOT_NFS is not set
-# CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_V4 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_SUNRPC=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-# CONFIG_CIFS is not set
-# 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
-# CONFIG_AFS_FS is not set
-# CONFIG_ZISOFS_FS 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 is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-# CONFIG_SMB_NLS is not set
-# CONFIG_NLS is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# Multimedia Capabilities Port drivers
-#
-# CONFIG_MCP is not set
-# CONFIG_MCP_SA1100 is not set
-# CONFIG_MCP_UCB1200 is not set
-# CONFIG_MCP_UCB1200_AUDIO is not set
-# CONFIG_MCP_UCB1200_TS is not set
-
-#
-# Console Switches
-#
-# CONFIG_SWITCHES is not set
-# CONFIG_SWITCHES_SA1100 is not set
-# CONFIG_SWITCHES_UCB1X00 is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_NO_FRAME_POINTER is not set
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-CONFIG_DEBUG_ERRORS=y
-# CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
-
-#
-# Security options
-#
-CONFIG_SECURITY_CAPABILITIES=y
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-CONFIG_ZLIB_INFLATE=m
-CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/arm/configs/versatile_defconfig b/arch/arm/configs/versatile_defconfig
--- a/arch/arm/configs/versatile_defconfig	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/configs/versatile_defconfig	2004-12-24 13:36:48 -08:00
@@ -65,7 +65,7 @@
 # CONFIG_ARCH_SHARK is not set
 # CONFIG_ARCH_S3C2410 is not set
 # CONFIG_ARCH_OMAP is not set
-CONFIG_ARCH_VERSATILE_PB=y
+CONFIG_ARCH_VERSATILE=y
 
 #
 # CLPS711X/EP721X Implementations
@@ -110,6 +110,12 @@
 #
 
 #
+# Versatile platform type
+#
+CONFIG_ARCH_VERSATILE_PB=y
+# CONFIG_MACH_VERSATILE_AB is not set
+
+#
 # Processor Type
 #
 CONFIG_CPU_32=y
@@ -144,8 +150,8 @@
 #
 # At least one math emulation must be selected
 #
-# CONFIG_FPE_NWFPE is not set
-CONFIG_FPE_FASTFPE=y
+CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
diff -Nru a/arch/arm/defconfig b/arch/arm/defconfig
--- a/arch/arm/defconfig	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,510 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-# CONFIG_MODULES is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-CONFIG_ARCH_INTEGRATOR=y
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_CLPS711X is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-
-#
-# Footbridge Implementations
-#
-
-#
-# SA11x0 Implementations
-#
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-
-#
-# Processor Type
-#
-CONFIG_CPU_32v4=y
-CONFIG_CPU_ARM720=y
-CONFIG_CPU_ARM920=y
-CONFIG_CPU_ARM920_CPU_IDLE=y
-CONFIG_CPU_ARM920_I_CACHE_ON=y
-CONFIG_CPU_ARM920_D_CACHE_ON=y
-# CONFIG_CPU_ARM920_WRITETHROUGH is not set
-# CONFIG_DISCONTIGMEM is not set
-
-#
-# General setup
-#
-# CONFIG_ANGELBOOT is not set
-CONFIG_PCI_INTEGRATOR=y
-CONFIG_PCI=y
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-CONFIG_PCI_NAMES=y
-# CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_NWFPE=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="root=1f04 mem=32M"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DOC1000 is not set
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_MTDRAM is not set
-
-#
-# MTD drivers for mapped chips
-#
-CONFIG_MTD_CFI=y
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_JEDEC is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_PHYSMAP is not set
-
-#
-# 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_VMAX is not set
-
-#
-# User modules and translation layers for MTD devices
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-CONFIG_MTD_ARM=y
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP 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
-
-#
-# 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_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_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED 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=y
-# CONFIG_LNE390 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_RTL8129 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_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
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 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
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT 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_SERIAL_AMBA=y
-CONFIG_SERIAL_INTEGRATOR=y
-CONFIG_SERIAL_AMBA_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=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_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 is not set
-# 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_DEBUG 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=y
-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=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_MOUNT_SUBDIR is not set
-# CONFIG_NCPFS_NDS_DOMAINS 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 is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_NLS is not set
-
-#
-# Console drivers
-#
-CONFIG_KMI_KEYB=y
-CONFIG_PC_KEYMAP=y
-CONFIG_VGA_CONSOLE=y
-# CONFIG_FB is not set
-
-#
-# Frame-buffer support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-CONFIG_MAGIC_SYSRQ=y
-CONFIG_DEBUG_LL=y
diff -Nru a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
--- a/arch/arm/kernel/Makefile	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/kernel/Makefile	2004-12-24 13:37:19 -08:00
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-AFLAGS_head.o := -DTEXTADDR=$(TEXTADDR)
+AFLAGS_head.o := -DTEXTADDR=$(TEXTADDR) -DDATAADDR=$(DATAADDR)
 
 # Object file lists.
 
diff -Nru a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
--- a/arch/arm/kernel/armksyms.c	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/kernel/armksyms.c	2004-12-24 13:36:47 -08:00
@@ -60,7 +60,8 @@
 EXPORT_SYMBOL(__backtrace);
 
 	/* platform dependent support */
-EXPORT_SYMBOL(udelay);
+EXPORT_SYMBOL(__udelay);
+EXPORT_SYMBOL(__const_udelay);
 
 	/* networking */
 EXPORT_SYMBOL(csum_partial);
@@ -149,6 +150,8 @@
 EXPORT_SYMBOL(_test_and_change_bit_le);
 EXPORT_SYMBOL(_find_first_zero_bit_le);
 EXPORT_SYMBOL(_find_next_zero_bit_le);
+EXPORT_SYMBOL(_find_first_bit_le);
+EXPORT_SYMBOL(_find_next_bit_le);
 
 #ifdef __ARMEB__
 EXPORT_SYMBOL(_set_bit_be);
@@ -159,6 +162,8 @@
 EXPORT_SYMBOL(_test_and_change_bit_be);
 EXPORT_SYMBOL(_find_first_zero_bit_be);
 EXPORT_SYMBOL(_find_next_zero_bit_be);
+EXPORT_SYMBOL(_find_first_bit_be);
+EXPORT_SYMBOL(_find_next_bit_be);
 #endif
 
 	/* syscalls */
diff -Nru a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
--- a/arch/arm/kernel/asm-offsets.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/kernel/asm-offsets.c	2004-12-24 13:36:18 -08:00
@@ -14,6 +14,7 @@
 #include <linux/mm.h>
 #include <asm/mach/arch.h>
 #include <asm/thread_info.h>
+#include <asm/memory.h>
 
 /*
  * Make sure that the compiler and target are compatible.
@@ -72,6 +73,7 @@
   DEFINE(VM_EXEC,	       	VM_EXEC);
   BLANK();
   DEFINE(PAGE_SZ,	       	PAGE_SIZE);
+  DEFINE(VIRT_OFFSET,	       	PAGE_OFFSET);
   BLANK();
   DEFINE(SYS_ERROR0,		0x9f0000);
   BLANK();
diff -Nru a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
--- a/arch/arm/kernel/bios32.c	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/kernel/bios32.c	2004-12-24 13:36:47 -08:00
@@ -574,13 +574,13 @@
 
 		if (!use_firmware) {
 			/*
-		 	 * Size the bridge windows.
-		 	 */
+			 * Size the bridge windows.
+			 */
 			pci_bus_size_bridges(bus);
 
 			/*
-		 	 * Assign resources.
-		 	 */
+			 * Assign resources.
+			 */
 			pci_bus_assign_resources(bus);
 		}
 
@@ -681,7 +681,7 @@
 	if (mmap_state == pci_mmap_io) {
 		return -EINVAL;
 	} else {
-		phys = root->mem_offset + (vma->vm_pgoff << PAGE_SHIFT);
+		phys = vma->vm_pgoff + (root->mem_offset >> PAGE_SHIFT);
 	}
 
 	/*
@@ -690,7 +690,7 @@
 	vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO;
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
-	if (remap_page_range(vma, vma->vm_start, phys,
+	if (remap_pfn_range(vma, vma->vm_start, phys,
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot))
 		return -EAGAIN;
diff -Nru a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S
--- a/arch/arm/kernel/debug.S	2004-12-24 13:36:34 -08:00
+++ b/arch/arm/kernel/debug.S	2004-12-24 13:36:34 -08:00
@@ -538,6 +538,9 @@
 #elif defined(CONFIG_ARCH_S3C2410)
 #include <asm/arch/map.h>
 #include <asm/arch/regs-serial.h>
+#include <asm/arch/regs-gpio.h>
+#define S3C2410_UART1_OFF (0x4000)
+#define SHIFT_2440TXF (14-9)
 
 		.macro addruart, rx
 		mrc	p15, 0, \rx, c1, c0
@@ -559,7 +562,17 @@
 		beq	1001f				@
 		@ FIFO enabled...
 1003:
+		mrc	p15, 0, \rd, c1, c0
+		tst	\rd, #1
+		addeq	\rd, \rx, #(S3C2410_PA_GPIO - S3C2410_PA_UART)
+		addne	\rd, \rx, #(S3C2410_VA_GPIO - S3C2410_VA_UART)
+		bic	\rd, \rd, #0xff000
+		ldr	\rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
+		and	\rd, \rd, #0x00ff0000
+		teq	\rd, #0x00440000		@ is it 2440?
+
 		ldr	\rd, [ \rx, # S3C2410_UFSTAT ]
+		moveq	\rd, \rd, lsr #SHIFT_2440TXF
 		tst	\rd, #S3C2410_UFSTAT_TXFULL
 		bne	1003b
 		b	1002f
@@ -580,8 +593,19 @@
 		beq	1001f				@
 		@ FIFO enabled...
 1003:
+		mrc	p15, 0, \rd, c1, c0
+		tst	\rd, #1
+		addeq	\rd, \rx, #(S3C2410_PA_GPIO - S3C2410_PA_UART)
+		addne	\rd, \rx, #(S3C2410_VA_GPIO - S3C2410_VA_UART)
+		bic	\rd, \rd, #0xff000
+		ldr	\rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
+		and	\rd, \rd, #0x00ff0000
+		teq	\rd, #0x00440000		@ is it 2440?
+
 		ldr	\rd, [ \rx, # S3C2410_UFSTAT ]
-		ands	\rd, \rd, #15<<S3C2410_UFSTAT_TXSHIFT
+		andne	\rd, \rd, #S3C2410_UFSTAT_TXMASK
+		andeq	\rd, \rd, #S3C2440_UFSTAT_TXMASK
+		teq	\rd, #0
 		bne	1003b
 		b	1002f
 
@@ -623,7 +647,7 @@
 		.endm
 
 
-#elif defined(CONFIG_ARCH_VERSATILE_PB)
+#elif defined(CONFIG_ARCH_VERSATILE)
 
 #include <asm/hardware/amba_serial.h>
 
diff -Nru a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
--- a/arch/arm/kernel/ecard.c	2004-12-24 13:37:44 -08:00
+++ b/arch/arm/kernel/ecard.c	2004-12-24 13:37:44 -08:00
@@ -503,27 +503,33 @@
 	}
 }
 
-static void
-ecard_dump_irq_state(ecard_t *ec)
+static void ecard_dump_irq_state(void)
 {
-	printk("  %d: %sclaimed, ",
-	       ec->slot_no,
-	       ec->claimed ? "" : "not ");
-
-	if (ec->ops && ec->ops->irqpending &&
-	    ec->ops != &ecard_default_ops)
-		printk("irq %spending\n",
-		       ec->ops->irqpending(ec) ? "" : "not ");
-	else
-		printk("irqaddr %p, mask = %02X, status = %02X\n",
-		       ec->irqaddr, ec->irqmask, *ec->irqaddr);
+	ecard_t *ec;
+
+	printk("Expansion card IRQ state:\n");
+
+	for (ec = cards; ec; ec = ec->next) {
+		if (ec->slot_no == 8)
+			continue;
+
+		printk("  %d: %sclaimed, ",
+		       ec->slot_no, ec->claimed ? "" : "not ");
+
+		if (ec->ops && ec->ops->irqpending &&
+		    ec->ops != &ecard_default_ops)
+			printk("irq %spending\n",
+			       ec->ops->irqpending(ec) ? "" : "not ");
+		else
+			printk("irqaddr %p, mask = %02X, status = %02X\n",
+			       ec->irqaddr, ec->irqmask, *ec->irqaddr);
+	}
 }
 
 static void ecard_check_lockup(struct irqdesc *desc)
 {
 	static unsigned long last;
 	static int lockup;
-	ecard_t *ec;
 
 	/*
 	 * If the timer interrupt has not run since the last million
@@ -541,11 +547,7 @@
 			       "disabling all expansion card interrupts\n");
 
 			desc->chip->mask(IRQ_EXPANSIONCARD);
-
-			printk("Expansion card IRQ state:\n");
-
-			for (ec = cards; ec; ec = ec->next)
-				ecard_dump_irq_state(ec);
+			ecard_dump_irq_state();
 		}
 	} else
 		lockup = 0;
@@ -557,6 +559,7 @@
 	if (!last || time_after(jiffies, last + 5*HZ)) {
 		last = jiffies;
 		printk(KERN_WARNING "Unrecognised interrupt from backplane\n");
+		ecard_dump_irq_state();
 	}
 }
 
diff -Nru a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
--- a/arch/arm/kernel/entry-armv.S	2004-12-24 13:36:33 -08:00
+++ b/arch/arm/kernel/entry-armv.S	2004-12-24 13:36:33 -08:00
@@ -464,7 +464,7 @@
 		.macro	irq_prio_table
 		.endm
 
-#elif defined(CONFIG_ARCH_VERSATILE_PB)
+#elif defined(CONFIG_ARCH_VERSATILE)
 
 		.macro	disable_fiq
 		.endm
@@ -1657,6 +1657,8 @@
 ENTRY(__trap_init)
 		stmfd	sp!, {r4 - r6, lr}
 
+		mov	r0, #0xff000000
+		orr	r0, r0, #0x00ff0000		@ high vectors position
 		adr	r1, .LCvectors			@ set up the vectors
 		ldmia	r1, {r1, r2, r3, r4, r5, r6, ip, lr}
 		stmia	r0, {r1, r2, r3, r4, r5, r6, ip, lr}
diff -Nru a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
--- a/arch/arm/kernel/fiq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/kernel/fiq.c	2004-12-24 13:37:18 -08:00
@@ -46,32 +46,16 @@
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
-#define FIQ_VECTOR (vectors_base() + 0x1c)
-
 static unsigned long no_fiq_insn;
 
-static inline void unprotect_page_0(void)
-{
-	modify_domain(DOMAIN_USER, DOMAIN_MANAGER);
-}
-
-static inline void protect_page_0(void)
-{
-	modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
-}
-
 /* Default reacquire function
  * - we always relinquish FIQ control
  * - we always reacquire FIQ control
  */
 static int fiq_def_op(void *ref, int relinquish)
 {
-	if (!relinquish) {
-		unprotect_page_0();
-		*(unsigned long *)FIQ_VECTOR = no_fiq_insn;
-		protect_page_0();
-		flush_icache_range(FIQ_VECTOR, FIQ_VECTOR + 4);
-	}
+	if (!relinquish)
+		set_fiq_handler(&no_fiq_insn, sizeof(no_fiq_insn));
 
 	return 0;
 }
@@ -93,12 +77,10 @@
 
 void set_fiq_handler(void *start, unsigned int length)
 {
-	unprotect_page_0();
-
-	memcpy((void *)FIQ_VECTOR, start, length);
-
-	protect_page_0();
-	flush_icache_range(FIQ_VECTOR, FIQ_VECTOR + length);
+	memcpy((void *)0xffff001c, start, length);
+	flush_icache_range(0xffff001c, 0xffff001c + length);
+	if (!vectors_high())
+		flush_icache_range(0x1c, 0x1c + length);
 }
 
 /*
@@ -198,6 +180,5 @@
 
 void __init init_FIQ(void)
 {
-	no_fiq_insn = *(unsigned long *)FIQ_VECTOR;
-	set_fs(get_fs());
+	no_fiq_insn = *(unsigned long *)0xffff001c;
 }
diff -Nru a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
--- a/arch/arm/kernel/head.S	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/kernel/head.S	2004-12-24 13:36:16 -08:00
@@ -1,5 +1,5 @@
 /*
- *  linux/arch/arm/kernel/head-armv.S
+ *  linux/arch/arm/kernel/head.S
  *
  *  Copyright (C) 1994-2002 Russell King
  *
@@ -19,17 +19,16 @@
 #include <asm/ptrace.h>
 #include <asm/constants.h>
 
+#ifndef CONFIG_XIP_KERNEL
 /*
  * We place the page tables 16K below TEXTADDR.  Therefore, we must make sure
  * that TEXTADDR is correctly set.  Currently, we expect the least significant
  * 16 bits to be 0x8000, but we could probably relax this restriction to
- * TEXTADDR > PAGE_OFFSET + 0x4000
+ * TEXTADDR >= PAGE_OFFSET + 0x4000
  *
  * Note that swapper_pg_dir is the virtual address of the page tables, and
  * pgtbl gives us a position-independent reference to these tables.  We can
  * do this because stext == TEXTADDR
- *
- * swapper_pg_dir, pgtbl and krnladr are all closely related.
  */
 #if (TEXTADDR & 0xffff) != 0x8000
 #error TEXTADDR must start at 0xXXXX8000
@@ -38,19 +37,35 @@
 	.globl	swapper_pg_dir
 	.equ	swapper_pg_dir, TEXTADDR - 0x4000
 
-	.macro	pgtbl, reg
-	adr	\reg, stext
-	sub	\reg, \reg, #0x4000
+	.macro	pgtbl, rd, phys
+	adr	\rd, stext
+	sub	\rd, \rd, #0x4000
 	.endm
-
+#else
 /*
- * Since the page table is closely related to the kernel start address, we
- * can convert the page table base address to the base address of the section
- * containing both.
+ * XIP Kernel:
+ *
+ * We place the page tables 16K below DATAADDR.  Therefore, we must make sure
+ * that DATAADDR is correctly set.  Currently, we expect the least significant
+ * 16 bits to be 0x8000, but we could probably relax this restriction to
+ * DATAADDR >= PAGE_OFFSET + 0x4000
+ *
+ * Note that pgtbl is meant to return the physical address of swapper_pg_dir.
+ * We can't make it relative to the kernel position in this case since
+ * the kernel can physically be anywhere.
  */
-	.macro	krnladr, rd, pgtable
-	bic	\rd, \pgtable, #0x000ff000
+#if (DATAADDR & 0xffff) != 0x8000
+#error DATAADDR must start at 0xXXXX8000
+#endif
+
+	.globl	swapper_pg_dir
+	.equ	swapper_pg_dir, DATAADDR - 0x4000
+
+	.macro	pgtbl, rd, phys
+	ldr	\rd, =((DATAADDR - 0x4000) - VIRT_OFFSET)
+	add	\rd, \rd, \phys
 	.endm
+#endif
 
 /*
  * Kernel startup entry point.
@@ -99,6 +114,8 @@
 	.type	__switch_data, %object
 __switch_data:
 	.long	__mmap_switched
+	.long	__data_loc			@ r2
+	.long	__data_start			@ r3
 	.long	__bss_start			@ r4
 	.long	_end				@ r5
 	.long	processor_id			@ r6
@@ -136,12 +153,20 @@
  */
 	.align	5
 __mmap_switched:
-	adr	r3, __switch_data + 4
-	ldmia	r3, {r4, r5, r6, r7, r8, sp}
+	adr	r2, __switch_data + 4
+	ldmia	r2, {r2, r3, r4, r5, r6, r7, r8, sp}
+
+	cmp	r2, r3				@ Copy data segment if needed
+1:	cmpne	r3, r4
+	ldrne	fp, [r2], #4
+	strne	fp, [r3], #4
+	bne	1b
+
 	mov	fp, #0				@ Clear BSS (and zero fp)
 1:	cmp	r4, r5
 	strcc	fp, [r4],#4
 	bcc	1b
+
 	str	r9, [r6]			@ Save processor ID
 	str	r1, [r7]			@ Save machine type
 	bic	r2, r0, #2			@ Clear 'A' bit
@@ -156,16 +181,13 @@
  * amount which are required to get the kernel running, which
  * generally means mapping in the kernel code.
  *
- * We only map in 4MB of RAM, which should be sufficient in
- * all cases.
- *
  * r5 = physical address of start of RAM
  * r6 = physical IO address
  * r7 = byte offset into page tables for IO
  * r8 = page table flags
  */
 __create_page_tables:
-	pgtbl	r4				@ page table address
+	pgtbl	r4, r5				@ page table address
 
 	/*
 	 * Clear the 16K level 1 swapper page table
@@ -183,28 +205,50 @@
 	/*
 	 * Create identity mapping for first MB of kernel to
 	 * cater for the MMU enable.  This identity mapping
-	 * will be removed by paging_init()
+	 * will be removed by paging_init().  We use our current program
+	 * counter to determine corresponding section base address.
 	 */
-	krnladr	r2, r4				@ start of kernel
-	add	r3, r8, r2			@ flags + kernel base
-	str	r3, [r4, r2, lsr #18]		@ identity mapping
+	mov	r2, pc, lsr #20			@ start of kernel section
+	add	r3, r8, r2, lsl #20		@ flags + kernel base
+	str	r3, [r4, r2, lsl #2]		@ identity mapping
 
 	/*
 	 * Now setup the pagetables for our kernel direct
 	 * mapped region.  We round TEXTADDR down to the
-	 * nearest megabyte boundary.
+	 * nearest megabyte boundary.  It is assumed that
+	 * the kernel fits within 4 contigous 1MB sections.
 	 */
-	add	r0, r4, #(TEXTADDR & 0xff000000) >> 18 @ start of kernel
-	bic	r2, r3, #0x00f00000
-	str	r2, [r0]			@ PAGE_OFFSET + 0MB
-	add	r0, r0, #(TEXTADDR & 0x00f00000) >> 18
-	str	r3, [r0], #4			@ KERNEL + 0MB
+	add	r0, r4,  #(TEXTADDR & 0xff000000) >> 18	@ start of kernel
+	str	r3, [r0, #(TEXTADDR & 0x00f00000) >> 18]!
 	add	r3, r3, #1 << 20
-	str	r3, [r0], #4			@ KERNEL + 1MB
+	str	r3, [r0, #4]!			@ KERNEL + 1MB
 	add	r3, r3, #1 << 20
-	str	r3, [r0], #4			@ KERNEL + 2MB
+	str	r3, [r0, #4]!			@ KERNEL + 2MB
 	add	r3, r3, #1 << 20
-	str	r3, [r0], #4			@ KERNEL + 3MB
+	str	r3, [r0, #4]			@ KERNEL + 3MB
+
+	/*
+	 * Then map first 1MB of ram in case it contains our boot params.
+	 */
+	add	r0, r4, #VIRT_OFFSET >> 18
+	add	r2, r5, r8
+	str	r2, [r0]
+
+#ifdef CONFIG_XIP_KERNEL
+	/*
+	 * Map some ram to cover our .data and .bss areas.
+	 * Mapping 3MB should be plenty.
+	 */
+	sub	r3, r4, r5
+	mov	r3, r3, lsr #20
+	add	r0, r0, r3, lsl #2
+	add	r2, r2, r3, lsl #20
+	str	r2, [r0], #4
+	add	r2, r2, #(1 << 20)
+	str	r2, [r0], #4
+	add	r2, r2, #(1 << 20)
+	str	r2, [r0]
+#endif
 
 	bic	r8, r8, #0x0c			@ turn off cacheable
 						@ and bufferable bits
@@ -255,6 +299,7 @@
 	str	r3, [r0]
 #endif
 	mov	pc, lr
+	.ltorg
 
 
 
diff -Nru a/arch/arm/kernel/io.c b/arch/arm/kernel/io.c
--- a/arch/arm/kernel/io.c	2004-12-24 13:36:34 -08:00
+++ b/arch/arm/kernel/io.c	2004-12-24 13:36:34 -08:00
@@ -7,7 +7,7 @@
  * Copy data from IO memory space to "real" memory space.
  * This needs to be optimized.
  */
-void _memcpy_fromio(void *to, unsigned long from, size_t count)
+void _memcpy_fromio(void *to, void __iomem *from, size_t count)
 {
 	unsigned char *t = to;
 	while (count) {
@@ -22,7 +22,7 @@
  * Copy data from "real" memory space to IO memory space.
  * This needs to be optimized.
  */
-void _memcpy_toio(unsigned long to, const void *from, size_t count)
+void _memcpy_toio(void __iomem *to, const void *from, size_t count)
 {
 	const unsigned char *f = from;
 	while (count) {
@@ -37,7 +37,7 @@
  * "memset" on IO memory space.
  * This needs to be optimized.
  */
-void _memset_io(unsigned long dst, int c, size_t count)
+void _memset_io(void __iomem *dst, int c, size_t count)
 {
 	while (count) {
 		count--;
diff -Nru a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
--- a/arch/arm/kernel/irq.c	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/kernel/irq.c	2004-12-24 13:36:16 -08:00
@@ -86,7 +86,7 @@
 };
 
 /**
- *	disable_irq - disable an irq and wait for completion
+ *	disable_irq_nosync - disable an irq without waiting
  *	@irq: Interrupt to disable
  *
  *	Disable the selected interrupt line.  Enables and disables
@@ -94,7 +94,7 @@
  *
  *	This function may be called from IRQ context.
  */
-void disable_irq(unsigned int irq)
+void disable_irq_nosync(unsigned int irq)
 {
 	struct irqdesc *desc = irq_desc + irq;
 	unsigned long flags;
@@ -104,6 +104,28 @@
 	list_del_init(&desc->pend);
 	spin_unlock_irqrestore(&irq_controller_lock, flags);
 }
+EXPORT_SYMBOL(disable_irq_nosync);
+
+/**
+ *	disable_irq - disable an irq and wait for completion
+ *	@irq: Interrupt to disable
+ *
+ *	Disable the selected interrupt line.  Enables and disables
+ *	are nested.  This functions waits for any pending IRQ
+ *	handlers for this interrupt to complete before returning.
+ *	If you use this function while holding a resource the IRQ
+ *	handler may need you will deadlock.
+ *
+ *	This function may be called - with care - from IRQ context.
+ */
+void disable_irq(unsigned int irq)
+{
+	struct irqdesc *desc = irq_desc + irq;
+
+	disable_irq_nosync(irq);
+	if (desc->action)
+		synchronize_irq(irq);
+}
 EXPORT_SYMBOL(disable_irq);
 
 /**
@@ -175,17 +197,30 @@
 
 int show_interrupts(struct seq_file *p, void *v)
 {
-	int i = *(loff_t *) v;
+	int i = *(loff_t *) v, cpu;
 	struct irqaction * action;
 	unsigned long flags;
 
+	if (i == 0) {
+		char cpuname[12];
+
+		seq_printf(p, "    ");
+		for_each_present_cpu(cpu) {
+			sprintf(cpuname, "CPU%d", cpu);
+			seq_printf(p, " %10s", cpuname);
+		}
+		seq_putc(p, '\n');
+	}
+
 	if (i < NR_IRQS) {
 		spin_lock_irqsave(&irq_controller_lock, flags);
 	    	action = irq_desc[i].action;
 		if (!action)
 			goto unlock;
 
-		seq_printf(p, "%3d: %10u ", i, kstat_irqs(i));
+		seq_printf(p, "%3d: ", i);
+		for_each_present_cpu(cpu)
+			seq_printf(p, "%10u ", kstat_cpu(cpu).irqs[i]);
 		seq_printf(p, "  %s", action->name);
 		for (action = action->next; action; action = action->next)
 			seq_printf(p, ", %s", action->name);
@@ -341,7 +376,6 @@
 
 	do {
 		struct irqaction *action;
-		int ret;
 
 		action = desc->action;
 		if (!action)
@@ -352,9 +386,7 @@
 			desc->chip->unmask(irq);
 		}
 
-		ret = __do_irq(irq, action, regs);
-		if (ret != IRQ_HANDLED)
-			report_bad_irq(irq, regs, desc, ret);
+		__do_irq(irq, action, regs);
 	} while (desc->pending && !desc->disable_depth);
 
 	desc->running = 0;
diff -Nru a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
--- a/arch/arm/kernel/module.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/kernel/module.c	2004-12-24 13:36:17 -08:00
@@ -9,6 +9,7 @@
  *
  * Module allocation method suggested by Andi Kleen.
  */
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/elf.h>
@@ -18,6 +19,18 @@
 #include <linux/string.h>
 
 #include <asm/pgtable.h>
+
+#ifdef CONFIG_XIP_KERNEL
+/*
+ * The XIP kernel text is mapped in the module area for modules and
+ * some other stuff to work without any indirect relocations.
+ * MODULE_START is redefined here and not in asm/memory.h to avoid
+ * recompiling the whole kernel when CONFIG_XIP_KERNEL is turned on/off.
+ */
+extern void _etext;
+#undef MODULE_START
+#define MODULE_START	(((unsigned long)&_etext + ~PGDIR_MASK) & PGDIR_MASK)
+#endif
 
 void *module_alloc(unsigned long size)
 {
diff -Nru a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
--- a/arch/arm/kernel/process.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/kernel/process.c	2004-12-24 13:37:19 -08:00
@@ -97,6 +97,8 @@
  */
 void cpu_idle(void)
 {
+	local_fiq_enable();
+
 	/* endless idle loop with no priority at all */
 	while (1) {
 		void (*idle)(void) = pm_idle;
diff -Nru a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
--- a/arch/arm/kernel/ptrace.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/kernel/ptrace.c	2004-12-24 13:36:18 -08:00
@@ -677,7 +677,7 @@
 			/* make sure single-step breakpoint is gone. */
 			child->ptrace &= ~PT_SINGLESTEP;
 			ptrace_cancel_bpt(child);
-			if (child->state != TASK_ZOMBIE) {
+			if (child->exit_state != EXIT_ZOMBIE) {
 				child->exit_code = SIGKILL;
 				wake_up_process(child);
 			}
diff -Nru a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
--- a/arch/arm/kernel/setup.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/kernel/setup.c	2004-12-24 13:36:55 -08:00
@@ -59,7 +59,7 @@
 extern void squash_mem_tags(struct tag *tag);
 extern void reboot_setup(char *str);
 extern int root_mountflags;
-extern int _stext, _text, _etext, _edata, _end;
+extern void _stext, _text, _etext, __data_start, _edata, _end;
 
 unsigned int processor_id;
 unsigned int __machine_arch_type;
@@ -113,7 +113,7 @@
  */
 static struct resource mem_res[] = {
 	{ "Video RAM",   0,     0,     IORESOURCE_MEM			},
-	{ "Kernel code", 0,     0,     IORESOURCE_MEM			},
+	{ "Kernel text", 0,     0,     IORESOURCE_MEM			},
 	{ "Kernel data", 0,     0,     IORESOURCE_MEM			}
 };
 
@@ -132,21 +132,21 @@
 #define lp2 io_res[2]
 
 static const char *cache_types[16] = {
-	"VIVT write-through",
-	"VIVT write-back",
-	"VIVT write-back",
+	"write-through",
+	"write-back",
+	"write-back",
 	"undefined 3",
 	"undefined 4",
 	"undefined 5",
-	"VIVT write-back",
-	"VIVT write-back",
+	"write-back",
+	"write-back",
 	"undefined 8",
 	"undefined 9",
 	"undefined 10",
 	"undefined 11",
 	"undefined 12",
 	"undefined 13",
-	"VIPT write-back",
+	"write-back",
 	"undefined 15",
 };
 
@@ -236,7 +236,8 @@
 	unsigned int info = read_cpuid(CPUID_CACHETYPE);
 
 	if (info != processor_id) {
-		printk("CPU: D %s cache\n", cache_types[CACHE_TYPE(info)]);
+		printk("CPU: D %s %s cache\n", cache_is_vivt() ? "VIVT" : "VIPT",
+		       cache_types[CACHE_TYPE(info)]);
 		if (CACHE_S(info)) {
 			dump_cache("CPU: I cache", CACHE_ISIZE(info));
 			dump_cache("CPU: D cache", CACHE_DSIZE(info));
@@ -255,7 +256,7 @@
 	} else if ((processor_id & 0x0000f000) == 0x00007000) {
 		cpu_arch = (processor_id & (1 << 23)) ? CPU_ARCH_ARMv4T : CPU_ARCH_ARMv3;
 	} else {
-		cpu_arch = (processor_id >> 16) & 15;
+		cpu_arch = (processor_id >> 16) & 7;
 		if (cpu_arch)
 			cpu_arch += CPU_ARCH_ARMv3;
 	}
@@ -447,10 +448,10 @@
 	struct resource *res;
 	int i;
 
-	kernel_code.start  = __virt_to_phys(init_mm.start_code);
-	kernel_code.end    = __virt_to_phys(init_mm.end_code - 1);
-	kernel_data.start  = __virt_to_phys(init_mm.end_code);
-	kernel_data.end    = __virt_to_phys(init_mm.brk - 1);
+	kernel_code.start   = virt_to_phys(&_text);
+	kernel_code.end     = virt_to_phys(&_etext - 1);
+	kernel_data.start   = virt_to_phys(&__data_start);
+	kernel_data.end     = virt_to_phys(&_end - 1);
 
 	for (i = 0; i < mi->nr_banks; i++) {
 		unsigned long virt_start, virt_end;
@@ -726,7 +727,7 @@
 	 * Set up various architecture-specific pointers
 	 */
 	init_arch_irq = mdesc->init_irq;
-	init_arch_time = mdesc->init_time;
+	system_timer = mdesc->timer;
 	init_machine = mdesc->init_machine;
 
 #ifdef CONFIG_VT
diff -Nru a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
--- a/arch/arm/kernel/signal.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/kernel/signal.c	2004-12-24 13:36:17 -08:00
@@ -126,25 +126,6 @@
 	return ret;
 }
 
-/*
- * Do a signal return; undo the signal stack.
- */
-struct sigframe
-{
-	struct sigcontext sc;
-	unsigned long extramask[_NSIG_WORDS-1];
-	unsigned long retcode;
-};
-
-struct rt_sigframe
-{
-	struct siginfo __user *pinfo;
-	void __user *puc;
-	struct siginfo info;
-	struct ucontext uc;
-	unsigned long retcode;
-};
-
 #ifdef CONFIG_IWMMXT
 
 /* iwmmxt_area is 0x98 bytes long, preceeded by 8 bytes of signature */
@@ -152,8 +133,15 @@
 #define IWMMXT_MAGIC0		0x12ef842a
 #define IWMMXT_MAGIC1		0x1c07ca71
 
-static int page_present(struct mm_struct *mm, unsigned long addr, int wr)
+struct iwmmxt_sigframe {
+	unsigned long	magic0;
+	unsigned long	magic1;
+	unsigned long	storage[0x98/4];
+};
+
+static int page_present(struct mm_struct *mm, void __user *uptr, int wr)
 {
+	unsigned long addr = (unsigned long)uptr;
 	pgd_t *pgd = pgd_offset(mm, addr);
 	if (pgd_present(*pgd)) {
 		pmd_t *pmd = pmd_offset(pgd, addr);
@@ -165,49 +153,66 @@
 	return 0;
 }
 
-static int
-preserve_iwmmxt_context(void *iwmmxt_save_area)
+static int copy_locked(void __user *uptr, void *kptr, size_t size, int write,
+		       void (*copyfn)(void *, void __user *))
+{
+	unsigned char v, __user *userptr = uptr;
+	int err = 0;
+
+	do {
+		struct mm_struct *mm;
+
+		if (write) {
+			__put_user_error(0, userptr, err);
+			__put_user_error(0, userptr + size - 1, err);
+		} else {
+			__get_user_error(v, userptr, err);
+			__get_user_error(v, userptr + size - 1, err);
+		}
+
+		if (err)
+			break;
+
+		mm = current->mm;
+		spin_lock(&mm->page_table_lock);
+		if (page_present(mm, userptr, write) &&
+		    page_present(mm, userptr + size - 1, write)) {
+		    	copyfn(kptr, uptr);
+		} else
+			err = 1;
+		spin_unlock(&mm->page_table_lock);
+	} while (err);
+
+	return err;
+}
+
+static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame)
 {
 	int err = 0;
 
 	/* the iWMMXt context must be 64 bit aligned */
-	long *iwmmxt_storage = (long *)(((long)iwmmxt_save_area + 4) & ~7);
+	WARN_ON((unsigned long)frame & 7);
+
+	__put_user_error(IWMMXT_MAGIC0, &frame->magic0, err);
+	__put_user_error(IWMMXT_MAGIC1, &frame->magic1, err);
 
-again:
-	__put_user_error(IWMMXT_MAGIC0, iwmmxt_storage+0, err);
-	__put_user_error(IWMMXT_MAGIC1, iwmmxt_storage+1, err);
 	/*
 	 * iwmmxt_task_copy() doesn't check user permissions.
 	 * Let's do a dummy write on the upper boundary to ensure
 	 * access to user mem is OK all way up.
 	 */
-	__put_user_error(0, iwmmxt_storage+IWMMXT_STORAGE_SIZE/4-1, err);
-	if (!err) {
-		/* Let's make sure the user mapping won't disappear under us */
-		struct mm_struct *mm = current->mm;
-		unsigned long addr = (unsigned long)iwmmxt_storage;
-		spin_lock(&mm->page_table_lock);
-		if ( !page_present(mm, addr, 1) ||
-		     !page_present(mm, addr+IWMMXT_STORAGE_SIZE-1, 1) ) {
-			/* our user area has gone before grabbing the lock */
-			spin_unlock(&mm->page_table_lock);
-			goto again;
-		}
-		iwmmxt_task_copy(current_thread_info(), iwmmxt_storage+2);
-		spin_unlock(&mm->page_table_lock);
-		return 0;
-	}
+	err |= copy_locked(&frame->storage, current_thread_info(),
+			   sizeof(frame->storage), 1, iwmmxt_task_copy);
 	return err;
 }
 
-static int
-restore_iwmmxt_context(void *iwmmxt_save_area)
+static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame)
 {
+	unsigned long magic0, magic1;
 	int err = 0;
-	long *iwmmxt_storage, magic0, magic1, dummy;
 
 	/* the iWMMXt context is 64 bit aligned */
-	iwmmxt_storage = (long *)(((long)iwmmxt_save_area + 4) & ~7);
+	WARN_ON((unsigned long)frame & 7);
 
 	/*
 	 * Validate iWMMXt context signature.
@@ -215,32 +220,51 @@
 	 * Let's do a dummy write on the upper boundary to ensure
 	 * access to user mem is OK all way up.
 	 */
-again:
-	__get_user_error(magic0, iwmmxt_storage+0, err);
-	__get_user_error(magic1, iwmmxt_storage+1, err);
-	if (!err && magic0 == IWMMXT_MAGIC0 && magic1 == IWMMXT_MAGIC1 &&
-	    !__get_user(dummy, iwmmxt_storage+IWMMXT_STORAGE_SIZE/4-1)) {
-		/* Let's make sure the user mapping won't disappear under us */
-		struct mm_struct *mm = current->mm;
-		unsigned long addr = (unsigned long)iwmmxt_storage;
-		spin_lock(&mm->page_table_lock);
-		if ( !page_present(mm, addr, 0) ||
-		     !page_present(mm, addr+IWMMXT_STORAGE_SIZE-1, 0) ) {
-			/* our user area has gone before grabbing the lock */
-			spin_unlock(&mm->page_table_lock);
-			goto again;
-		}
-		iwmmxt_task_restore(current_thread_info(), iwmmxt_storage+2);
-		spin_unlock(&mm->page_table_lock);
-		return 0;
-	}
-	return -1;
+	__get_user_error(magic0, &frame->magic0, err);
+	__get_user_error(magic1, &frame->magic1, err);
+	if (!err && magic0 == IWMMXT_MAGIC0 && magic1 == IWMMXT_MAGIC1)
+		err = copy_locked(&frame->storage, current_thread_info(),
+				  sizeof(frame->storage), 0, iwmmxt_task_restore);
+	return err;
 }
 
 #endif
 
+/*
+ * Auxiliary signal frame.  This saves stuff like FP state.
+ * The layout of this structure is not part of the user ABI.
+ */
+struct aux_sigframe {
+#ifdef CONFIG_IWMMXT
+	struct iwmmxt_sigframe	iwmmxt;
+#endif
+#ifdef CONFIG_VFP
+	union vfp_state		vfp;
+#endif
+};
+
+/*
+ * Do a signal return; undo the signal stack.  These are aligned to 64-bit.
+ */
+struct sigframe {
+	struct sigcontext sc;
+	unsigned long extramask[_NSIG_WORDS-1];
+	unsigned long retcode;
+	struct aux_sigframe aux __attribute__((aligned(8)));
+};
+
+struct rt_sigframe {
+	struct siginfo __user *pinfo;
+	void __user *puc;
+	struct siginfo info;
+	struct ucontext uc;
+	unsigned long retcode;
+	struct aux_sigframe aux __attribute__((aligned(8)));
+};
+
 static int
-restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
+restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
+		   struct aux_sigframe __user *aux)
 {
 	int err = 0;
 
@@ -264,6 +288,15 @@
 
 	err |= !valid_user_regs(regs);
 
+#ifdef CONFIG_IWMMXT
+	if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
+		err |= restore_iwmmxt_context(&aux->iwmmxt);
+#endif
+#ifdef CONFIG_VFP
+//	if (err == 0)
+//		err |= vfp_restore_state(&aux->vfp);
+#endif
+
 	return err;
 }
 
@@ -299,13 +332,8 @@
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
-	if (restore_sigcontext(regs, &frame->sc))
-		goto badframe;
-
-#ifdef CONFIG_IWMMXT
-	if (test_thread_flag(TIF_USING_IWMMXT) && restore_iwmmxt_context(frame+1))
+	if (restore_sigcontext(regs, &frame->sc, &frame->aux))
 		goto badframe;
-#endif
 
 	/* Send SIGTRAP if we're single-stepping */
 	if (current->ptrace & PT_SINGLESTEP) {
@@ -349,17 +377,12 @@
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
-	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
+	if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &frame->aux))
 		goto badframe;
 
 	if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->ARM_sp) == -EFAULT)
 		goto badframe;
 
-#ifdef CONFIG_IWMMXT
-	if (test_thread_flag(TIF_USING_IWMMXT) && restore_iwmmxt_context(frame+1))
-		goto badframe;
-#endif
-
 	/* Send SIGTRAP if we're single-stepping */
 	if (current->ptrace & PT_SINGLESTEP) {
 		ptrace_cancel_bpt(current);
@@ -374,7 +397,7 @@
 }
 
 static int
-setup_sigcontext(struct sigcontext __user *sc, /*struct _fpstate *fpstate,*/
+setup_sigcontext(struct sigcontext __user *sc, struct aux_sigframe __user *aux,
 		 struct pt_regs *regs, unsigned long mask)
 {
 	int err = 0;
@@ -402,6 +425,15 @@
 	__put_user_error(current->thread.address, &sc->fault_address, err);
 	__put_user_error(mask, &sc->oldmask, err);
 
+#ifdef CONFIG_IWMMXT
+	if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
+		err |= preserve_iwmmxt_context(&aux->iwmmxt);
+#endif
+#ifdef CONFIG_VFP
+//	if (err == 0)
+//		err |= vfp_save_state(&aux->vfp);
+#endif
+
 	return err;
 }
 
@@ -411,11 +443,6 @@
 	unsigned long sp = regs->ARM_sp;
 	void __user *frame;
 
-#ifdef CONFIG_IWMMXT
-	if (test_thread_flag(TIF_USING_IWMMXT))
-		framesize = (framesize + 4 + IWMMXT_STORAGE_SIZE) & ~7;
-#endif
-
 	/*
 	 * This is the X/Open sanctioned signal stack switching.
 	 */
@@ -505,18 +532,13 @@
 	if (!frame)
 		return 1;
 
-	err |= setup_sigcontext(&frame->sc, /*&frame->fpstate,*/ regs, set->sig[0]);
+	err |= setup_sigcontext(&frame->sc, &frame->aux, regs, set->sig[0]);
 
 	if (_NSIG_WORDS > 1) {
 		err |= __copy_to_user(frame->extramask, &set->sig[1],
 				      sizeof(frame->extramask));
 	}
 
-#ifdef CONFIG_IWMMXT
-	if (test_thread_flag(TIF_USING_IWMMXT))
-		err |= preserve_iwmmxt_context(frame+1);
-#endif
-
 	if (err == 0)
 		err = setup_return(regs, ka, &frame->retcode, frame, usig);
 
@@ -547,14 +569,9 @@
 	stack.ss_size = current->sas_ss_size;
 	err |= __copy_to_user(&frame->uc.uc_stack, &stack, sizeof(stack));
 
-	err |= setup_sigcontext(&frame->uc.uc_mcontext, /*&frame->fpstate,*/
+	err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->aux,
 				regs, set->sig[0]);
 	err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
-
-#ifdef CONFIG_IWMMXT
-	if (test_thread_flag(TIF_USING_IWMMXT))
-		err |= preserve_iwmmxt_context(frame+1);
-#endif
 
 	if (err == 0)
 		err = setup_return(regs, ka, &frame->retcode, frame, usig);
diff -Nru a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
--- a/arch/arm/kernel/sys_arm.c	2004-12-24 13:36:30 -08:00
+++ b/arch/arm/kernel/sys_arm.c	2004-12-24 13:36:30 -08:00
@@ -51,6 +51,13 @@
 	return error;
 }
 
+/*
+ * This is the lowest virtual address we can permit any user space
+ * mapping to be mapped at.  This is particularly important for
+ * non-high vector CPUs.
+ */
+#define MIN_MAP_ADDR	(PAGE_SIZE)
+
 /* common code for old and new mmaps */
 inline long do_mmap2(
 	unsigned long addr, unsigned long len,
@@ -62,11 +69,7 @@
 
 	flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
 
-	/*
-	 * If we are doing a fixed mapping, and address < PAGE_SIZE,
-	 * then deny it.
-	 */
-	if (flags & MAP_FIXED && addr < PAGE_SIZE && vectors_base() == 0)
+	if (flags & MAP_FIXED && addr < MIN_MAP_ADDR)
 		goto out;
 
 	error = -EBADF;
@@ -119,12 +122,7 @@
 {
 	unsigned long ret = -EINVAL;
 
-	/*
-	 * If we are doing a fixed mapping, and address < PAGE_SIZE,
-	 * then deny it.
-	 */
-	if (flags & MREMAP_FIXED && new_addr < PAGE_SIZE &&
-	    vectors_base() == 0)
+	if (flags & MREMAP_FIXED && new_addr < MIN_MAP_ADDR)
 		goto out;
 
 	down_write(&current->mm->mmap_sem);
diff -Nru a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
--- a/arch/arm/kernel/time.c	2004-12-24 13:37:02 -08:00
+++ b/arch/arm/kernel/time.c	2004-12-24 13:37:02 -08:00
@@ -40,6 +40,11 @@
 
 EXPORT_SYMBOL(jiffies_64);
 
+/*
+ * Our system timer.
+ */
+struct sys_timer *system_timer;
+
 extern unsigned long wall_jiffies;
 
 /* this needs a better home */
@@ -78,12 +83,6 @@
 }
 
 /*
- * hook for getting the time offset.  Note that it is
- * always called with interrupts disabled.
- */
-unsigned long (*gettimeoffset)(void) = dummy_gettimeoffset;
-
-/*
  * Scheduler clock - returns current time in nanosec units.
  * This is the default implementation.  Sub-architecture
  * implementations can override this.
@@ -247,7 +246,7 @@
 
 	do {
 		seq = read_seqbegin_irqsave(&xtime_lock, flags);
-		usec = gettimeoffset();
+		usec = system_timer->offset();
 
 		lost = jiffies - wall_jiffies;
 		if (lost)
@@ -284,7 +283,7 @@
 	 * wall time.  Discover what correction gettimeofday() would have
 	 * done, and then undo it!
 	 */
-	nsec -= gettimeoffset() * NSEC_PER_USEC;
+	nsec -= system_timer->offset() * NSEC_PER_USEC;
 	nsec -= (jiffies - wall_jiffies) * TICK_NSEC;
 
 	wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
@@ -337,18 +336,67 @@
 }
 EXPORT_SYMBOL(restore_time_delta);
 
+/*
+ * Kernel system timer support.
+ */
 void timer_tick(struct pt_regs *regs)
 {
 	profile_tick(CPU_PROFILING, regs);
 	do_leds();
 	do_set_rtc();
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
+}
+
+#ifdef CONFIG_PM
+static int timer_suspend(struct sys_device *dev, u32 state)
+{
+	struct sys_timer *timer = container_of(dev, struct sys_timer, dev);
+
+	if (timer->suspend != NULL)
+		timer->suspend();
+
+	return 0;
+}
+
+static int timer_resume(struct sys_device *dev)
+{
+	struct sys_timer *timer = container_of(dev, struct sys_timer, dev);
+
+	if (timer->resume != NULL)
+		timer->resume();
+
+	return 0;
+}
+#else
+#define timer_suspend NULL
+#define timer_resume NULL
+#endif
+
+static struct sysdev_class timer_sysclass = {
+	set_kset_name("timer"),
+	.suspend	= timer_suspend,
+	.resume		= timer_resume,
+};
+
+static int __init timer_init_sysfs(void)
+{
+	int ret = sysdev_class_register(&timer_sysclass);
+	if (ret == 0) {
+		system_timer->dev.cls = &timer_sysclass;
+		ret = sysdev_register(&system_timer->dev);
+	}
+	return ret;
 }
 
-void (*init_arch_time)(void);
+device_initcall(timer_init_sysfs);
 
 void __init time_init(void)
 {
-	init_arch_time();
+	if (system_timer->offset == NULL)
+		system_timer->offset = dummy_gettimeoffset;
+	system_timer->init();
 }
 
diff -Nru a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
--- a/arch/arm/kernel/traps.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/kernel/traps.c	2004-12-24 13:36:48 -08:00
@@ -328,20 +328,11 @@
  */
 asmlinkage void bad_mode(struct pt_regs *regs, int reason, int proc_mode)
 {
-	unsigned int vectors = vectors_base();
-
 	console_verbose();
 
 	printk(KERN_CRIT "Bad mode in %s handler detected: mode %s\n",
 		handler[reason], processor_modes[proc_mode]);
 
-	/*
-	 * Dump out the vectors and stub routines.  Maybe a better solution
-	 * would be to dump them out only if we detect that they are corrupted.
-	 */
-	dump_mem(KERN_CRIT "Vectors: ", vectors, vectors + 0x40);
-	dump_mem(KERN_CRIT "Stubs: ", vectors + 0x200, vectors + 0x4b8);
-
 	die("Oops - bad mode", regs, 0);
 	local_irq_disable();
 	panic("bad mode");
@@ -537,7 +528,7 @@
 
 void __readwrite_bug(const char *fn)
 {
-	printk("%s called, but not implemented", fn);
+	printk("%s called, but not implemented\n", fn);
 	BUG();
 }
 EXPORT_SYMBOL(__readwrite_bug);
@@ -575,13 +566,9 @@
 
 void __init trap_init(void)
 {
-	extern void __trap_init(unsigned long);
-	unsigned long base = vectors_base();
+	extern void __trap_init(void);
 
-	__trap_init(base);
-	flush_icache_range(base, base + PAGE_SIZE);
-	if (base != 0)
-		printk(KERN_DEBUG "Relocating machine vectors to 0x%08lx\n",
-			base);
+	__trap_init();
+	flush_icache_range(0xffff0000, 0xffff0000 + PAGE_SIZE);
 	modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
 }
diff -Nru a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
--- a/arch/arm/kernel/vmlinux.lds.S	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/kernel/vmlinux.lds.S	2004-12-24 13:36:47 -08:00
@@ -4,6 +4,7 @@
  */
 
 #include <asm-generic/vmlinux.lds.h>
+#include <linux/config.h>
 	
 OUTPUT_ARCH(arm)
 ENTRY(stext)
@@ -17,7 +18,6 @@
 	. = TEXTADDR;
 	.init : {			/* Init code and data		*/
 		_stext = .;
-		__init_begin = .;
 			_sinittext = .;
 			*(.init.text)
 			_einittext = .;
@@ -30,7 +30,6 @@
 		__tagtable_begin = .;
 			*(.taglist)
 		__tagtable_end = .;
-			*(.init.data)
 		. = ALIGN(16);
 		__setup_start = .;
 			*(.init.setup)
@@ -57,8 +56,16 @@
 		__initramfs_start = .;
 			usr/built-in.o(.init.ramfs)
 		__initramfs_end = .;
+		. = ALIGN(64);
+		__per_cpu_start = .;
+			*(.data.percpu)
+		__per_cpu_end = .;
+#ifndef CONFIG_XIP_KERNEL
+		__init_begin = _stext;
+		*(.init.data)
 		. = ALIGN(4096);
 		__init_end = .;
+#endif
 	}
 
 	/DISCARD/ : {			/* Exit code and data		*/
@@ -79,8 +86,6 @@
 			*(.glue_7)
 			*(.glue_7t)
 		*(.got)			/* Global offset table		*/
-
-		_etext = .;		/* End of text section		*/
 	}
 
 	. = ALIGN(16);
@@ -92,15 +97,33 @@
 
 	RODATA
 
+	_etext = .;			/* End of text and rodata section */
+
+#ifdef CONFIG_XIP_KERNEL
+	__data_loc = ALIGN(4);		/* location in binary */
+	. = DATAADDR;
+#else
 	. = ALIGN(8192);
+	__data_loc = .;
+#endif
+
+	.data : AT(__data_loc) {
+		__data_start = .;	/* address in memory */
 
-	.data : {
 		/*
 		 * first, the init task union, aligned
 		 * to an 8192 byte boundary.
 		 */
 		*(.init.task)
 
+#ifdef CONFIG_XIP_KERNEL
+		. = ALIGN(4096);
+		__init_begin = .;
+		*(.init.data)
+		. = ALIGN(4096);
+		__init_end = .;
+#endif
+
 		. = ALIGN(4096);
 		__nosave_begin = .;
 		*(.data.nosave)
@@ -126,7 +149,7 @@
 		__bss_start = .;	/* BSS				*/
 		*(.bss)
 		*(COMMON)
-		_end = . ;
+		_end = .;
 	}
 					/* Stabs debugging sections.	*/
 	.stab 0 : { *(.stab) }
diff -Nru a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
--- a/arch/arm/lib/Makefile	2004-12-24 13:37:01 -08:00
+++ b/arch/arm/lib/Makefile	2004-12-24 13:37:01 -08:00
@@ -12,12 +12,12 @@
 		   testclearbit.o testsetbit.o uaccess.o getuser.o    \
 		   putuser.o ashldi3.o ashrdi3.o lshrdi3.o muldi3.o   \
 		   ucmpdi2.o udivdi3.o lib1funcs.o div64.o	      \
-		   io-readsb.o io-writesb.o io-writesl.o
+		   io-readsb.o io-writesb.o io-readsl.o io-writesl.o
 
 ifeq ($(CONFIG_CPU_32v3),y)
-  lib-y	+= io-readsw-armv3.o io-writesw-armv3.o io-readsl-armv3.o
+  lib-y	+= io-readsw-armv3.o io-writesw-armv3.o
 else
-  lib-y	+= io-readsw-armv4.o io-writesw-armv4.o io-readsl-armv4.o
+  lib-y	+= io-readsw-armv4.o io-writesw-armv4.o
 endif
 
 lib-$(CONFIG_ARCH_RPC)		+= ecard.o io-acorn.o floppydma.o
diff -Nru a/arch/arm/lib/csumpartial.S b/arch/arm/lib/csumpartial.S
--- a/arch/arm/lib/csumpartial.S	2004-12-24 13:37:33 -08:00
+++ b/arch/arm/lib/csumpartial.S	2004-12-24 13:37:33 -08:00
@@ -73,8 +73,7 @@
 .done:		adc	r0, sum, #0		@ collect up the last carry
 		ldr	td0, [sp], #4
 		tst	td0, #1			@ check buffer alignment
-		movne	td0, r0, lsl #8		@ rotate checksum by 8 bits
-		orrne	r0, td0, r0, lsr #24
+		movne	r0, r0, ror #8		@ rotate checksum by 8 bits
 		ldr	pc, [sp], #4		@ return
 
 .not_aligned:	tst	buf, #1			@ odd address
diff -Nru a/arch/arm/lib/csumpartialcopygeneric.S b/arch/arm/lib/csumpartialcopygeneric.S
--- a/arch/arm/lib/csumpartialcopygeneric.S	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/lib/csumpartialcopygeneric.S	2004-12-24 13:36:18 -08:00
@@ -160,8 +160,7 @@
 .done:		adc	r0, sum, #0
 		ldr	sum, [sp, #0]		@ dst
 		tst	sum, #1
-		movne	sum, r0, lsl #8
-		orrne	r0, sum, r0, lsr #24
+		movne	r0, r0, ror #8
 		load_regs	ea
 
 .src_not_aligned:
diff -Nru a/arch/arm/lib/delay.S b/arch/arm/lib/delay.S
--- a/arch/arm/lib/delay.S	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/lib/delay.S	2004-12-24 13:36:49 -08:00
@@ -16,15 +16,16 @@
 /*
  * 0 <= r0 <= 2000
  */
-ENTRY(udelay)
+ENTRY(__udelay)
 		mov	r2,     #0x6800
 		orr	r2, r2, #0x00db
-		mul	r1, r0, r2
+		mul	r0, r2, r0
+ENTRY(__const_udelay)				@ 0 <= r0 <= 0x01ffffff
 		ldr	r2, LC0
-		ldr	r2, [r2]
-		mov	r1, r1, lsr #11
-		mov	r2, r2, lsr #11
-		mul	r0, r1, r2
+		ldr	r2, [r2]		@ max = 0x0fffffff
+		mov	r0, r0, lsr #11		@ max = 0x00003fff
+		mov	r2, r2, lsr #11		@ max = 0x0003ffff
+		mul	r0, r2, r0		@ max = 2^32-1
 		movs	r0, r0, lsr #6
 		RETINSTR(moveq,pc,lr)
 
diff -Nru a/arch/arm/lib/getuser.S b/arch/arm/lib/getuser.S
--- a/arch/arm/lib/getuser.S	2004-12-24 13:37:34 -08:00
+++ b/arch/arm/lib/getuser.S	2004-12-24 13:37:34 -08:00
@@ -17,7 +17,7 @@
  *
  * Inputs:	r0 contains the address
  * Outputs:	r0 is the error code
- *		r1, r2 contains the zero-extended value
+ *		r2, r3 contains the zero-extended value
  *		lr corrupted
  *
  * No other registers must be altered.  (see include/asm-arm/uaccess.h
@@ -32,39 +32,39 @@
 
 	.global	__get_user_1
 __get_user_1:
-1:	ldrbt	r1, [r0]
+1:	ldrbt	r2, [r0]
 	mov	r0, #0
 	mov	pc, lr
 
 	.global	__get_user_2
 __get_user_2:
-2:	ldrbt	r1, [r0], #1
-3:	ldrbt	r2, [r0]
+2:	ldrbt	r2, [r0], #1
+3:	ldrbt	r3, [r0]
 #ifndef __ARMEB__
-	orr	r1, r1, r2, lsl #8
+	orr	r2, r2, r3, lsl #8
 #else
-	orr	r1, r2, r1, lsl #8
+	orr	r2, r3, r2, lsl #8
 #endif
 	mov	r0, #0
 	mov	pc, lr
 
 	.global	__get_user_4
 __get_user_4:
-4:	ldrt	r1, [r0]
+4:	ldrt	r2, [r0]
 	mov	r0, #0
 	mov	pc, lr
 
 	.global	__get_user_8
 __get_user_8:
-5:	ldrt	r1, [r0], #4
-6:	ldrt	r2, [r0]
+5:	ldrt	r2, [r0], #4
+6:	ldrt	r3, [r0]
 	mov	r0, #0
 	mov	pc, lr
 
 __get_user_bad_8:
-	mov	r2, #0
+	mov	r3, #0
 __get_user_bad:
-	mov	r1, #0
+	mov	r2, #0
 	mov	r0, #-EFAULT
 	mov	pc, lr
 
diff -Nru a/arch/arm/lib/io-readsl-armv3.S b/arch/arm/lib/io-readsl-armv3.S
--- a/arch/arm/lib/io-readsl-armv3.S	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,78 +0,0 @@
-/*
- *  linux/arch/arm/lib/io-readsl-armv3.S
- *
- *  Copyright (C) 1995-2000 Russell King
- *
- * 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/linkage.h>
-#include <asm/assembler.h>
-#include <asm/hardware.h>
-
-/*
- * Note that some reads can be aligned on half-word boundaries.
- */
-ENTRY(__raw_readsl)
-		teq	r2, #0		@ do we have to check for the zero len?
-		moveq	pc, lr
-		ands	ip, r1, #3
-		bne	2f
-
-1:		ldr	r3, [r0]
-		str	r3, [r1], #4
-		subs	r2, r2, #1
-		bne	1b
-		mov	pc, lr
-
-2:		cmp	ip, #2
-		ldr	ip, [r0]
-		blt	4f
-		bgt	6f
-
-		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-3:		subs	r2, r2, #1
-		ldrne	r3, [r0]
-		orrne	ip, ip, r3, lsl #16
-		strne	ip, [r1], #4
-		movne	ip, r3, lsr #16
-		bne	3b
-		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-		strb	ip, [r1], #1
-		mov	pc, lr
-
-4:		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-5:		subs	r2, r2, #1
-		ldrne	r3, [r0]
-		orrne	ip, ip, r3, lsl #8
-		strne	ip, [r1], #4
-		movne	ip, r3, lsr #24
-		bne	5b
-		strb	ip, [r1], #1
-		mov	pc, lr
-
-6:		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-7:		subs	r2, r2, #1
-		ldrne	r3, [r0]
-		orrne	ip, ip, r3, lsl #24
-		strne	ip, [r1], #4
-		movne	ip, r3, lsr #8
-		bne	7b
-		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-		strb	ip, [r1], #1
-		mov	pc, lr
-
diff -Nru a/arch/arm/lib/io-readsl-armv4.S b/arch/arm/lib/io-readsl-armv4.S
--- a/arch/arm/lib/io-readsl-armv4.S	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,132 +0,0 @@
-/*
- *  linux/arch/arm/lib/io-readsl-armv4.S
- *
- *  Copyright (C) 1995-2000 Russell King
- *
- * 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/linkage.h>
-#include <asm/assembler.h>
-
-/*
- * Note that some reads can be aligned on half-word boundaries.
- */
-ENTRY(__raw_readsl)
-		teq	r2, #0		@ do we have to check for the zero len?
-		moveq	pc, lr
-		ands	ip, r1, #3
-		bne	2f
-
-		subs	r2, r2, #4
-		bmi	1001f
-		stmfd	sp!, {r4, lr}
-1000:		ldr	r3, [r0, #0]
-		ldr	r4, [r0, #0]
-		ldr	ip, [r0, #0]
-		ldr	lr, [r0, #0]
-		subs	r2, r2, #4
-		stmia	r1!, {r3, r4, ip, lr}
-		bpl	1000b
-		ldmfd	sp!, {r4, lr}
-1001:		tst	r2, #2
-		ldrne	r3, [r0, #0]
-		ldrne	ip, [r0, #0]
-		stmneia	r1!, {r3, ip}
-		tst	r2, #1
-		ldrne	r3, [r0, #0]
-		strne	r3, [r1, #0]
-		mov	pc, lr
-
-2:		cmp	ip, #2
-		ldr	ip, [r0]
-		blt	4f
-		bgt	6f
-
-#ifndef	__ARMEB__
-
-		/* little endian code */
-
-		strh	ip, [r1], #2
-		mov	ip, ip, lsr #16
-3:		subs	r2, r2, #1
-		ldrne	r3, [r0]
-		orrne	ip, ip, r3, lsl #16
-		strne	ip, [r1], #4
-		movne	ip, r3, lsr #16
-		bne	3b
-		strh	ip, [r1], #2
-		mov	pc, lr
-
-4:		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-		strh	ip, [r1], #2
-		mov	ip, ip, lsr #16
-5:		subs	r2, r2, #1
-		ldrne	r3, [r0]
-		orrne	ip, ip, r3, lsl #8
-		strne	ip, [r1], #4
-		movne	ip, r3, lsr #24
-		bne	5b
-		strb	ip, [r1], #1
-		mov	pc, lr
-
-6:		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
-7:		subs	r2, r2, #1
-		ldrne	r3, [r0]
-		orrne	ip, ip, r3, lsl #24
-		strne	ip, [r1], #4
-		movne	ip, r3, lsr #8
-		bne	7b
-		strh	ip, [r1], #2
-		mov	ip, ip, lsr #16
-		strb	ip, [r1]
-		mov	pc, lr
-
-#else
-
-		/* big endian code */
-
-
-		mov	r3, ip, lsr #16
-		strh	r3, [r1], #2
-3:		mov	r3, ip, lsl #16
-		subs	r2, r2, #1
-		ldrne	ip, [r0]
-		orrne	r3, r3, ip, lsr #16
-		strne	r3, [r1], #4
-		bne	3b
- 		strh	ip, [r1], #2
- 		mov	pc, lr
-
-4:		mov	r3, ip, lsr #24
-		strb	r3, [r1], #1
-		mov	r3, ip, lsr #8
-		strh	r3, [r1], #2
-5:		mov	r3, ip, lsl #24
-		subs	r2, r2, #1
-		ldrne	ip, [r0]
-		orrne	r3, r3, ip, lsr #8
-		strne	r3, [r1], #4
-		bne	5b
-		strb	ip, [r1], #1
-		mov	pc, lr
-
-6:		mov	r3, ip, lsr #24
-		strb	r3, [r1], #1
-7:		mov	r3, ip, lsl #8
-		subs	r2, r2, #1
-		ldrne	ip, [r0]
-		orrne	r3, r3, ip, lsr #24
-		strne	r3, [r1], #4
-		bne	7b
-		mov	r3, ip, lsr #8
-		strh	r3, [r1], #2
-		strb	ip, [r1], #1
-		mov	pc, lr
-
-#endif
-
-
diff -Nru a/arch/arm/lib/io-readsl.S b/arch/arm/lib/io-readsl.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/lib/io-readsl.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,78 @@
+/*
+ *  linux/arch/arm/lib/io-readsl.S
+ *
+ *  Copyright (C) 1995-2000 Russell King
+ *
+ * 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/linkage.h>
+#include <asm/assembler.h>
+
+ENTRY(__raw_readsl)
+		teq	r2, #0		@ do we have to check for the zero len?
+		moveq	pc, lr
+		ands	ip, r1, #3
+		bne	3f
+
+		subs	r2, r2, #4
+		bmi	2f
+		stmfd	sp!, {r4, lr}
+1:		ldr	r3, [r0, #0]
+		ldr	r4, [r0, #0]
+		ldr	ip, [r0, #0]
+		ldr	lr, [r0, #0]
+		subs	r2, r2, #4
+		stmia	r1!, {r3, r4, ip, lr}
+		bpl	1b
+		ldmfd	sp!, {r4, lr}
+2:		movs	r2, r2, lsl #31
+		ldrcs	r3, [r0, #0]
+		ldrcs	ip, [r0, #0]
+		stmcsia	r1!, {r3, ip}
+		ldrne	r3, [r0, #0]
+		strne	r3, [r1, #0]
+		mov	pc, lr
+
+3:		ldr	r3, [r0]
+		cmp	ip, #2
+		mov	ip, r3, get_byte_0
+		strb	ip, [r1], #1
+		bgt	6f
+		mov	ip, r3, get_byte_1
+		strb	ip, [r1], #1
+		beq	5f
+		mov	ip, r3, get_byte_2
+		strb	ip, [r1], #1
+
+4:		subs	r2, r2, #1
+		mov	ip, r3, pull #24
+		ldrne	r3, [r0]
+		orrne	ip, ip, r3, push #8
+		strne	ip, [r1], #4
+		bne	4b
+		b	8f
+
+5:		subs	r2, r2, #1
+		mov	ip, r3, pull #16
+		ldrne	r3, [r0]
+		orrne	ip, ip, r3, push #16
+		strne	ip, [r1], #4
+		bne	5b
+		b	7f
+
+6:		subs	r2, r2, #1
+		mov	ip, r3, pull #8
+		ldrne	r3, [r0]
+		orrne	ip, ip, r3, push #24
+		strne	ip, [r1], #4
+		bne	6b
+
+		mov	r3, ip, get_byte_2
+		strb	r3, [r1, #2]
+7:		mov	r3, ip, get_byte_1
+		strb	r3, [r1, #1]
+8:		mov	r3, ip, get_byte_0
+		strb	r3, [r1, #0]
+		mov	pc, lr
diff -Nru a/arch/arm/lib/io-writesl.S b/arch/arm/lib/io-writesl.S
--- a/arch/arm/lib/io-writesl.S	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/lib/io-writesl.S	2004-12-24 13:36:16 -08:00
@@ -9,53 +9,58 @@
  */
 #include <linux/linkage.h>
 #include <asm/assembler.h>
-#include <asm/hardware.h>
 
 ENTRY(__raw_writesl)
 		teq	r2, #0		@ do we have to check for the zero len?
 		moveq	pc, lr
 		ands	ip, r1, #3
-		bne	2f
+		bne	3f
 
-		tst	r2, #1
-		ldrne	r3, [r1], #4
-		strne	r3, [r0, #0]
-1:		subs	r2, r2, #2
-		ldrcs	r3, [r1], #4
-		ldrcs	ip, [r1], #4
+		subs	r2, r2, #4
+		bmi	2f
+		stmfd	sp!, {r4, lr}
+1:		ldmia	r1!, {r3, r4, ip, lr}
+		subs	r2, r2, #4
+		str	r3, [r0, #0]
+		str	r4, [r0, #0]
+		str	ip, [r0, #0]
+		str	lr, [r0, #0]
+		bpl	1b
+		ldmfd	sp!, {r4, lr}
+2:		movs	r2, r2, lsl #31
+		ldmcsia	r1!, {r3, ip}
 		strcs	r3, [r0, #0]
+		ldrne	r3, [r1, #0]
 		strcs	ip, [r0, #0]
-		bcs	1b
+		strne	r3, [r0, #0]
 		mov	pc, lr
 
-2:		bic	r1, r1, #3
-		cmp	ip, #2
+3:		bic	r1, r1, #3
 		ldr	r3, [r1], #4
-		bgt	4f
+		cmp	ip, #2
 		blt	5f
+		bgt	6f
 
-3:		mov	ip, r3, lsr #16
+4:		mov	ip, r3, pull #16
 		ldr	r3, [r1], #4
 		subs	r2, r2, #1
-		orr	ip, ip, r3, lsl #16
-		str	ip, [r0, #0]
-		bne	3b
+		orr	ip, ip, r3, push #16
+		str	ip, [r0]
+		bne	4b
 		mov	pc, lr
 
-4:		mov	ip, r3, lsr #24
+5:		mov	ip, r3, pull #8
 		ldr	r3, [r1], #4
 		subs	r2, r2, #1
-		orr	ip, ip, r3, lsl #8
-		str	ip, [r0, #0]
-		bne	4b
+		orr	ip, ip, r3, push #24
+		str	ip, [r0]
+		bne	5b
 		mov	pc, lr
 
-5:		mov	ip, r3, lsr #8
+6:		mov	ip, r3, pull #24
 		ldr	r3, [r1], #4
 		subs	r2, r2, #1
-		orr	ip, ip, r3, lsl #24
-		str	ip, [r0, #0]
-		bne	5b
+		orr	ip, ip, r3, push #8
+		str	ip, [r0]
+		bne	6b
 		mov	pc, lr
-
-
diff -Nru a/arch/arm/lib/longlong.h b/arch/arm/lib/longlong.h
--- a/arch/arm/lib/longlong.h	2004-12-24 13:36:19 -08:00
+++ b/arch/arm/lib/longlong.h	2004-12-24 13:36:19 -08:00
@@ -161,7 +161,6 @@
 #define UDIV_NEEDS_NORMALIZATION 1
 #define udiv_qrnnd __udiv_qrnnd_c
 
-extern const UQItype __clz_tab[];
 #define count_leading_zeros(count, x) \
   do {									\
     USItype __xr = (x);							\
diff -Nru a/arch/arm/lib/putuser.S b/arch/arm/lib/putuser.S
--- a/arch/arm/lib/putuser.S	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/lib/putuser.S	2004-12-24 13:37:19 -08:00
@@ -16,7 +16,7 @@
  * __put_user_X
  *
  * Inputs:	r0 contains the address
- *		r1, r2 contains the value
+ *		r2, r3 contains the value
  * Outputs:	r0 is the error code
  *		lr corrupted
  *
@@ -32,33 +32,33 @@
 
 	.global	__put_user_1
 __put_user_1:
-1:	strbt	r1, [r0]
+1:	strbt	r2, [r0]
 	mov	r0, #0
 	mov	pc, lr
 
 	.global	__put_user_2
 __put_user_2:
-	mov	ip, r1, lsr #8
+	mov	ip, r2, lsr #8
 #ifndef __ARMEB__
-2:	strbt	r1, [r0], #1
+2:	strbt	r2, [r0], #1
 3:	strbt	ip, [r0]
 #else
 2:	strbt	ip, [r0], #1
-3:	strbt	r1, [r0]
+3:	strbt	r2, [r0]
 #endif
 	mov	r0, #0
 	mov	pc, lr
 
 	.global	__put_user_4
 __put_user_4:
-4:	strt	r1, [r0]
+4:	strt	r2, [r0]
 	mov	r0, #0
 	mov	pc, lr
 
 	.global	__put_user_8
 __put_user_8:
-5:	strt	r1, [r0], #4
-6:	strt	r2, [r0]
+5:	strt	r2, [r0], #4
+6:	strt	r3, [r0]
 	mov	r0, #0
 	mov	pc, lr
 
diff -Nru a/arch/arm/mach-clps711x/Makefile.boot b/arch/arm/mach-clps711x/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-clps711x/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,7 @@
+# The standard locations for stuff on CLPS711x type processors
+   zreladdr-y				:= 0xc0028000 
+params_phys-y				:= 0xc0000100
+# Should probably have some agreement on these...
+initrd_phys-$(CONFIG_ARCH_P720T)	:= 0xc0400000
+initrd_phys-$(CONFIG_ARCH_CDB89712)	:= 0x00700000
+
diff -Nru a/arch/arm/mach-clps711x/autcpu12.c b/arch/arm/mach-clps711x/autcpu12.c
--- a/arch/arm/mach-clps711x/autcpu12.c	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/mach-clps711x/autcpu12.c	2004-12-24 13:36:31 -08:00
@@ -35,9 +35,7 @@
 #include <asm/mach/map.h>
 #include <asm/arch/autcpu12.h>
 
-extern void clps711x_map_io(void);
-extern void clps711x_init_irq(void);
-extern void clps711x_init_time(void);
+#include "common.h"
 
 /*
  * The on-chip registers are given a size of 1MB so that a section can
@@ -66,6 +64,6 @@
 	BOOT_PARAMS(0xc0020000)
 	MAPIO(autcpu12_map_io)
 	INITIRQ(clps711x_init_irq)
-	INITTIME(clps711x_init_time)
+	.timer		= &clps711x_timer,
 MACHINE_END
 
diff -Nru a/arch/arm/mach-clps711x/cdb89712.c b/arch/arm/mach-clps711x/cdb89712.c
--- a/arch/arm/mach-clps711x/cdb89712.c	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/mach-clps711x/cdb89712.c	2004-12-24 13:36:16 -08:00
@@ -32,9 +32,7 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
-extern void clps711x_init_irq(void);
-extern void clps711x_map_io(void);
-extern void clps711x_init_time(void);
+#include "common.h"
 
 /*
  * Map the CS89712 Ethernet port.  That should be moved to the
@@ -56,13 +54,5 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(cdb89712_map_io)
 	INITIRQ(clps711x_init_irq)
-	INITTIME(clps711x_init_time)
+	.timer		= &clps711x_timer,
 MACHINE_END
-
-static int cdb89712_hw_init(void)
-{
-	return 0;
-}
-
-__initcall(cdb89712_hw_init);
-
diff -Nru a/arch/arm/mach-clps711x/ceiva.c b/arch/arm/mach-clps711x/ceiva.c
--- a/arch/arm/mach-clps711x/ceiva.c	2004-12-24 13:36:30 -08:00
+++ b/arch/arm/mach-clps711x/ceiva.c	2004-12-24 13:36:30 -08:00
@@ -34,8 +34,7 @@
 
 #include <asm/mach/map.h>
 
-extern void clps711x_init_irq(void);
-extern void clps711x_init_time(void);
+#include "common.h"
 
 static struct map_desc ceiva_io_desc[] __initdata = {
  /* virtual, physical, length, type */
@@ -59,5 +58,5 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(ceiva_map_io)
 	INITIRQ(clps711x_init_irq)
-	INITTIME(clps711x_init_time)
+	.timer		= &clps711x_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-clps711x/clep7312.c b/arch/arm/mach-clps711x/clep7312.c
--- a/arch/arm/mach-clps711x/clep7312.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-clps711x/clep7312.c	2004-12-24 13:36:55 -08:00
@@ -23,9 +23,7 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
-extern void clps711x_init_irq(void);
-extern void clps711x_map_io(void); 
-extern void clps711x_init_time(void);
+#include "common.h"
 
 static void __init
 fixup_clep7312(struct machine_desc *desc, struct tag *tags,
@@ -45,6 +43,6 @@
 	FIXUP(fixup_clep7312)
 	MAPIO(clps711x_map_io)
 	INITIRQ(clps711x_init_irq)
-	INITTIME(clps711x_init_time)
+	.timer		= &clps711x_timer,
 MACHINE_END
 
diff -Nru a/arch/arm/mach-clps711x/common.h b/arch/arm/mach-clps711x/common.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-clps711x/common.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,11 @@
+/*
+ * linux/arch/arm/mach-clps711x/common.h
+ *
+ * Common bits.
+ */
+
+struct sys_timer;
+
+extern void clps711x_map_io(void);
+extern void clps711x_init_irq(void);
+extern struct sys_timer clps711x_timer;
diff -Nru a/arch/arm/mach-clps711x/edb7211-arch.c b/arch/arm/mach-clps711x/edb7211-arch.c
--- a/arch/arm/mach-clps711x/edb7211-arch.c	2004-12-24 13:37:02 -08:00
+++ b/arch/arm/mach-clps711x/edb7211-arch.c	2004-12-24 13:37:02 -08:00
@@ -25,9 +25,9 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
-extern void clps711x_init_irq(void);
+#include "common.h"
+
 extern void edb7211_map_io(void);
-extern void clps711x_init_time(void);
 
 static void __init
 fixup_edb7211(struct machine_desc *desc, struct tag *tags,
@@ -57,5 +57,5 @@
 	FIXUP(fixup_edb7211)
 	MAPIO(edb7211_map_io)
 	INITIRQ(clps711x_init_irq)
-	INITTIME(clps711x_init_time)
+	.timer		= &clps711x_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-clps711x/fortunet.c b/arch/arm/mach-clps711x/fortunet.c
--- a/arch/arm/mach-clps711x/fortunet.c	2004-12-24 13:37:00 -08:00
+++ b/arch/arm/mach-clps711x/fortunet.c	2004-12-24 13:37:00 -08:00
@@ -31,9 +31,7 @@
 
 #include <asm/mach/arch.h>
 
-extern void clps711x_map_io(void);
-extern void clps711x_init_irq(void);
-extern void clps711x_init_time(void);
+#include "common.h"
 
 struct meminfo memmap = {
 	.nr_banks	= 1,
@@ -83,5 +81,5 @@
 	FIXUP(fortunet_fixup)
 	MAPIO(clps711x_map_io)
 	INITIRQ(clps711x_init_irq)
-	INITTIME(clps711x_init_time)
+	.timer		= &clps711x_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c
--- a/arch/arm/mach-clps711x/p720t.c	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/mach-clps711x/p720t.c	2004-12-24 13:36:49 -08:00
@@ -34,9 +34,7 @@
 #include <asm/mach/map.h>
 #include <asm/arch/syspld.h>
 
-extern void clps711x_init_irq(void);
-extern void clps711x_map_io(void);
-extern void clps711x_init_time(void);
+#include "common.h"
 
 /*
  * Map the P720T system PLD.  It occupies two address spaces:
@@ -87,7 +85,7 @@
 	FIXUP(fixup_p720t)
 	MAPIO(p720t_map_io)
 	INITIRQ(clps711x_init_irq)
-	INITTIME(clps711x_init_time)
+	.timer		= &clps711x_timer,
 MACHINE_END
 
 static int p720t_hw_init(void)
diff -Nru a/arch/arm/mach-clps711x/time.c b/arch/arm/mach-clps711x/time.c
--- a/arch/arm/mach-clps711x/time.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-clps711x/time.c	2004-12-24 13:36:18 -08:00
@@ -49,7 +49,9 @@
 static irqreturn_t
 p720t_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
 	timer_tick(regs);
+	write_sequnlock(&xtime_lock);
 	return IRQ_HANDLED;
 }
 
@@ -59,7 +61,7 @@
 	.handler	= p720t_timer_interrupt
 };
 
-void __init clps711x_init_time(void)
+static void __init clps711x_timer_init(void)
 {
 	struct timespec tv;
 	unsigned int syscon;
@@ -71,9 +73,13 @@
 	clps_writel(LATCH-1, TC2D); /* 512kHz / 100Hz - 1 */
 
 	setup_irq(IRQ_TC2OI, &clps711x_timer_irq);
-	gettimeoffset = clps711x_gettimeoffset;
 
 	tv.tv_nsec = 0;
 	tv.tv_sec = clps_readl(RTCDR);
 	do_settimeofday(&tv);
 }
+
+struct sys_timer clps711x_timer = {
+	.init		= clps711x_timer_init,
+	.offset		= clps711x_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-clps7500/Makefile.boot b/arch/arm/mach-clps7500/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-clps7500/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2 @@
+   zreladdr-y	:= 0x10008000
+
diff -Nru a/arch/arm/mach-clps7500/core.c b/arch/arm/mach-clps7500/core.c
--- a/arch/arm/mach-clps7500/core.c	2004-12-24 13:36:59 -08:00
+++ b/arch/arm/mach-clps7500/core.c	2004-12-24 13:36:59 -08:00
@@ -12,6 +12,7 @@
 #include <linux/list.h>
 #include <linux/sched.h>
 #include <linux/init.h>
+#include <linux/serial_8250.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -267,10 +268,13 @@
 }
 
 extern void ioctime_init(void);
+extern unsigned long ioc_timer_gettimeoffset(void);
 
 static irqreturn_t
 clps7500_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
+
 	timer_tick(regs);
 
 	/* Why not using do_leds interface?? */
@@ -283,6 +287,9 @@
 			*((volatile unsigned int *)LED_ADDRESS) = state;
 		}
 	}
+
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -295,18 +302,72 @@
 /*
  * Set up timer interrupt.
  */
-void __init clps7500_init_time(void)
+static void __init clps7500_timer_init(void)
 {
 	ioctime_init();
 
 	setup_irq(IRQ_TIMER, &clps7500_timer_irq);
 }
 
+static struct clps7500_timer = {
+	.init		= clps7500_timer_init,
+	.offset		= ioc_timer_gettimeoffset,
+};
+
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.mapbase	= 0x03010fe0,
+		.irq		= 10,
+		.uartclk	= 1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_MEM,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SKIP_TEST,
+	},
+	{
+		.mapbase	= 0x03010be0,
+		.irq		= 0,
+		.uartclk	= 1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_MEM,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SKIP_TEST,
+	},
+	{
+		.iobase		= ISASLOT_IO + 0x2e8,
+		.irq		= 41,
+		.uartclk	= 1843200,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.iobase		= ISASLOT_IO + 0x3e8,
+		.irq		= 40,
+		.uartclk	= 1843200,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= 0,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
+static int __init clps7500_init(void)
+{
+	return platform_register_device(&serial_device);
+}
+
 MACHINE_START(CLPS7500, "CL-PS7500")
 	MAINTAINER("Philip Blundell")
 	BOOT_MEM(0x10000000, 0x03000000, 0xe0000000)
 	MAPIO(clps7500_map_io)
 	INITIRQ(clps7500_init_irq)
-	INITTIME(clps7500_init_time)
+	.timer		= &clps7500_timer,
 MACHINE_END
 
diff -Nru a/arch/arm/mach-ebsa110/Makefile.boot b/arch/arm/mach-ebsa110/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-ebsa110/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,4 @@
+   zreladdr-y	:= 0x00008000
+params_phys-y	:= 0x00000400
+initrd_phys-y	:= 0x00800000
+
diff -Nru a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c
--- a/arch/arm/mach-ebsa110/core.c	2004-12-24 13:37:43 -08:00
+++ b/arch/arm/mach-ebsa110/core.c	2004-12-24 13:37:43 -08:00
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
+#include <linux/serial_8250.h>
 #include <linux/init.h>
 
 #include <asm/hardware.h>
@@ -151,6 +152,8 @@
 {
 	u32 count;
 
+	write_seqlock(&xtime_lock);
+
 	/* latch and read timer 1 */
 	__raw_writeb(0x40, PIT_CTRL);
 	count = __raw_readb(PIT_T1);
@@ -163,6 +166,8 @@
 
 	timer_tick(regs);
 
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -175,7 +180,7 @@
 /*
  * Set up timer interrupt.
  */
-static void __init ebsa110_init_time(void)
+static void __init ebsa110_timer_init(void)
 {
 	/*
 	 * Timer 1, mode 2, LSB/MSB
@@ -184,11 +189,49 @@
 	__raw_writeb(COUNT & 0xff, PIT_T1);
 	__raw_writeb(COUNT >> 8, PIT_T1);
 
-	gettimeoffset = ebsa110_gettimeoffset;
-
 	setup_irq(IRQ_EBSA110_TIMER0, &ebsa110_timer_irq);
 }
 
+static struct sys_timer ebsa110_timer = {
+	.init		= ebsa110_timer_init,
+	.offset		= ebsa110_gettimeoffset,
+};
+
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.iobase		= 0x3f8,
+		.irq		= 1,
+		.uartclk	= 1843200,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.iobase		= 0x2f8,
+		.irq		= 2,
+		.uartclk	= 1843200,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= 0,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
+static int __init ebsa110_init(void)
+{
+	return platform_device_register(&serial_device);
+}
+
+arch_initcall(ebsa110_init);
+
 MACHINE_START(EBSA110, "EBSA110")
 	MAINTAINER("Russell King")
 	BOOT_MEM(0x00000000, 0xe0000000, 0xe0000000)
@@ -198,5 +241,5 @@
 	SOFT_REBOOT
 	MAPIO(ebsa110_map_io)
 	INITIRQ(ebsa110_init_irq)
-	INITTIME(ebsa110_init_time)
+	.timer		= &ebsa110_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-ebsa110/io.c b/arch/arm/mach-ebsa110/io.c
--- a/arch/arm/mach-ebsa110/io.c	2004-12-24 13:37:43 -08:00
+++ b/arch/arm/mach-ebsa110/io.c	2004-12-24 13:37:43 -08:00
@@ -27,9 +27,9 @@
 #include <asm/io.h>
 #include <asm/page.h>
 
-static u32 __isamem_convert_addr(void *addr)
+static void __iomem *__isamem_convert_addr(void __iomem *addr)
 {
-	u32 ret, a = (u32) addr;
+	u32 ret, a = (u32 __force) addr;
 
 	/*
 	 * The PCMCIA controller is wired up as follows:
@@ -53,41 +53,43 @@
 	ret += 0xe8000000;
 
 	if ((a & 0x20000) == (a & 0x40000) >> 1)
-		return ret;
+		return (void __iomem *)ret;
 
 	BUG();
-	return 0;
+	return NULL;
 }
 
 /*
  * read[bwl] and write[bwl]
  */
-u8 __readb(void *addr)
+u8 __readb(void __iomem *addr)
 {
-	u32 ret, a = __isamem_convert_addr(addr);
+	void __iomem *a = __isamem_convert_addr(addr);
+	u32 ret;
 
-	if ((int)addr & 1)
+	if ((unsigned long)addr & 1)
 		ret = __raw_readl(a);
 	else
 		ret = __raw_readb(a);
 	return ret;
 }
 
-u16 __readw(void *addr)
+u16 __readw(void __iomem *addr)
 {
-	u32 a = __isamem_convert_addr(addr);
+	void __iomem *a = __isamem_convert_addr(addr);
 
-	if ((int)addr & 1)
+	if ((unsigned long)addr & 1)
 		BUG();
 
 	return __raw_readw(a);
 }
 
-u32 __readl(void *addr)
+u32 __readl(void __iomem *addr)
 {
-	u32 ret, a = __isamem_convert_addr(addr);
+	void __iomem *a = __isamem_convert_addr(addr);
+	u32 ret;
 
-	if ((int)addr & 3)
+	if ((unsigned long)addr & 3)
 		BUG();
 
 	ret = __raw_readw(a);
@@ -99,31 +101,31 @@
 EXPORT_SYMBOL(__readw);
 EXPORT_SYMBOL(__readl);
 
-void __writeb(u8 val, void *addr)
+void __writeb(u8 val, void __iomem *addr)
 {
-	u32 a = __isamem_convert_addr(addr);
+	void __iomem *a = __isamem_convert_addr(addr);
 
-	if ((int)addr & 1)
+	if ((unsigned long)addr & 1)
 		__raw_writel(val, a);
 	else
 		__raw_writeb(val, a);
 }
 
-void __writew(u16 val, void *addr)
+void __writew(u16 val, void __iomem *addr)
 {
-	u32 a = __isamem_convert_addr(addr);
+	void __iomem *a = __isamem_convert_addr(addr);
 
-	if ((int)addr & 1)
+	if ((unsigned long)addr & 1)
 		BUG();
 
 	__raw_writew(val, a);
 }
 
-void __writel(u32 val, void *addr)
+void __writel(u32 val, void __iomem *addr)
 {
-	u32 a = __isamem_convert_addr(addr);
+	void __iomem *a = __isamem_convert_addr(addr);
 
-	if ((int)addr & 3)
+	if ((unsigned long)addr & 3)
 		BUG();
 
 	__raw_writew(val, a);
@@ -153,7 +155,7 @@
 	if (SUPERIO_PORT(port))
 		ret = __raw_readb(ISAIO_BASE + (port << 2));
 	else {
-		u32 a = ISAIO_BASE + ((port & ~1) << 1);
+		void __iomem *a = ISAIO_BASE + ((port & ~1) << 1);
 
 		/*
 		 * Shame nothing else does
@@ -180,7 +182,7 @@
 	if (SUPERIO_PORT(port))
 		ret = __raw_readb(ISAIO_BASE + (port << 2));
 	else {
-		u32 a = ISAIO_BASE + ((port & ~1) << 1);
+		void __iomem *a = ISAIO_BASE + ((port & ~1) << 1);
 
 		/*
 		 * Shame nothing else does
@@ -200,7 +202,7 @@
 	if (SUPERIO_PORT(port))
 		ret = __raw_readw(ISAIO_BASE + (port << 2));
 	else {
-		u32 a = ISAIO_BASE + ((port & ~1) << 1);
+		void __iomem *a = ISAIO_BASE + ((port & ~1) << 1);
 
 		/*
 		 * Shame nothing else does
@@ -218,7 +220,7 @@
  */
 u32 __inl(unsigned int port)
 {
-	u32 a;
+	void __iomem *a;
 
 	if (SUPERIO_PORT(port) || port & 3)
 		BUG();
@@ -241,7 +243,7 @@
 	if (SUPERIO_PORT(port))
 		__raw_writeb(val, ISAIO_BASE + (port << 2));
 	else {
-		u32 a = ISAIO_BASE + ((port & ~1) << 1);
+		void __iomem *a = ISAIO_BASE + ((port & ~1) << 1);
 
 		/*
 		 * Shame nothing else does
@@ -261,7 +263,7 @@
 	if (SUPERIO_PORT(port))
 		__raw_writeb(val, ISAIO_BASE + (port << 2));
 	else {
-		u32 a = ISAIO_BASE + ((port & ~1) << 1);
+		void __iomem *a = ISAIO_BASE + ((port & ~1) << 1);
 
 		/*
 		 * Shame nothing else does
diff -Nru a/arch/arm/mach-epxa10db/Makefile.boot b/arch/arm/mach-epxa10db/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-epxa10db/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2 @@
+   zreladdr-y	:= 0x00008000
+
diff -Nru a/arch/arm/mach-epxa10db/arch.c b/arch/arm/mach-epxa10db/arch.c
--- a/arch/arm/mach-epxa10db/arch.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-epxa10db/arch.c	2004-12-24 13:36:55 -08:00
@@ -20,6 +20,7 @@
  */
 #include <linux/types.h>
 #include <linux/init.h>
+#include <linux/serial_8250.h>
 
 #include <asm/hardware.h>
 #include <asm/setup.h>
@@ -27,15 +28,45 @@
 
 #include <asm/mach/arch.h>
 
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.iobase		= 0x3f8,
+		.irq		= IRQ_UARTINT0,
+#error FIXME
+		.uartclk	= 0,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.iobase		= 0x2f8,
+		.irq		= IRQ_UARTINT1,
+#error FIXME
+		.uartclk	= 0,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= 0,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
 extern void epxa10db_map_io(void);
 extern void epxa10db_init_irq(void);
-extern void epxa10db_init_time(void);
+extern struct sys_timer epxa10db_timer;
 
 MACHINE_START(CAMELOT, "Altera Epxa10db")
 	MAINTAINER("Altera Corporation")
 	BOOT_MEM(0x00000000, 0x7fffc000, 0xffffc000)
 	MAPIO(epxa10db_map_io)
 	INITIRQ(epxa10db_init_irq)
-	INITTIME(epxa10db_init_time)
+	.timer		= &epxa10db_timer,
 MACHINE_END
 
diff -Nru a/arch/arm/mach-epxa10db/time.c b/arch/arm/mach-epxa10db/time.c
--- a/arch/arm/mach-epxa10db/time.c	2004-12-24 13:36:30 -08:00
+++ b/arch/arm/mach-epxa10db/time.c	2004-12-24 13:36:30 -08:00
@@ -43,11 +43,13 @@
 static irqreturn_t
 epxa10db_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
 
 	// ...clear the interrupt
 	*TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))|=TIMER0_CR_CI_MSK;
 
 	timer_tick(regs);
+	write_sequnlock(&xtime_lock);
 
 	return IRQ_HANDLED;
 }
@@ -61,7 +63,7 @@
 /*
  * Set up timer interrupt, and return the current time in seconds.
  */
-void __init epxa10db_init_time(void)
+static void __init epxa10db_timer_init(void)
 {
 	/* Start the timer */
 	*TIMER0_LIMIT(IO_ADDRESS(EXC_TIMER00_BASE))=(unsigned int)(EXC_AHB2_CLK_FREQUENCY/200);
@@ -71,3 +73,6 @@
 	setup_irq(IRQ_TIMER0, &epxa10db_timer_irq);
 }
 
+struct sys_timer epxa10db_timer = {
+	.init		= epxa10db_timer_init,
+};
diff -Nru a/arch/arm/mach-footbridge/Kconfig b/arch/arm/mach-footbridge/Kconfig
--- a/arch/arm/mach-footbridge/Kconfig	2004-12-24 13:37:29 -08:00
+++ b/arch/arm/mach-footbridge/Kconfig	2004-12-24 13:37:29 -08:00
@@ -4,6 +4,7 @@
 
 config ARCH_CATS
 	bool "CATS"
+	select FOOTBRIDGE_HOST
 	help
 	  Say Y here if you intend to run this kernel on the CATS.
 
@@ -11,6 +12,7 @@
 
 config ARCH_PERSONAL_SERVER
 	bool "Compaq Personal Server"
+	select FOOTBRIDGE_HOST
 	---help---
 	  Say Y here if you intend to run this kernel on the Compaq
 	  Personal Server.
@@ -28,6 +30,8 @@
 
 config ARCH_EBSA285_ADDIN
 	bool "EBSA285 (addin mode)"
+	select ARCH_EBSA285
+	select FOOTBRIDGE_ADDIN
 	help
 	  Say Y here if you intend to run this kernel on the EBSA285 card
 	  in addin mode.
@@ -36,6 +40,8 @@
 
 config ARCH_EBSA285_HOST
 	bool "EBSA285 (host mode)"
+	select ARCH_EBSA285
+	select FOOTBRIDGE_HOST
 	help
 	  Say Y here if you intend to run this kernel on the EBSA285 card
 	  in host ("central function") mode.
@@ -44,6 +50,7 @@
 
 config ARCH_NETWINDER
 	bool "NetWinder"
+	select FOOTBRIDGE_HOST
 	help
 	  Say Y here if you intend to run this kernel on the Rebel.COM
 	  NetWinder.  Information about this machine can be found at:
@@ -53,5 +60,21 @@
 	  Saying N will reduce the size of the Footbridge kernel.
 
 endmenu
+
+# Footbridge support
+config FOOTBRIDGE
+	bool
+
+# Footbridge in host mode
+config FOOTBRIDGE_HOST
+	bool
+
+# Footbridge in addin mode
+config FOOTBRIDGE_ADDIN
+	bool
+
+# EBSA285 board in either host or addin mode
+config ARCH_EBSA285
+	bool
 
 endif
diff -Nru a/arch/arm/mach-footbridge/Makefile b/arch/arm/mach-footbridge/Makefile
--- a/arch/arm/mach-footbridge/Makefile	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/mach-footbridge/Makefile	2004-12-24 13:36:49 -08:00
@@ -4,13 +4,13 @@
 
 # Object file lists.
 
-obj-y			:= arch.o dc21285.o dma.o irq.o isa-irq.o mm.o time.o
+obj-y			:= common.o dc21285.o dma.o isa-irq.o time.o
 obj-m			:=
 obj-n			:=
 obj-			:=
 
 pci-$(CONFIG_ARCH_CATS) += cats-pci.o
-pci-$(CONFIG_ARCH_EBSA285) += ebsa285-pci.o
+pci-$(CONFIG_ARCH_EBSA285_HOST) += ebsa285-pci.o
 pci-$(CONFIG_ARCH_NETWINDER) += netwinder-pci.o
 pci-$(CONFIG_ARCH_PERSONAL_SERVER) += personal-pci.o
 
@@ -18,8 +18,13 @@
 leds-$(CONFIG_ARCH_EBSA285) += ebsa285-leds.o
 leds-$(CONFIG_ARCH_NETWINDER) += netwinder-leds.o
 
-obj-$(CONFIG_ARCH_CATS) += cats-hw.o
-obj-$(CONFIG_ARCH_NETWINDER) += netwinder-hw.o
+obj-$(CONFIG_ARCH_CATS) += cats-hw.o isa-timer.o
+obj-$(CONFIG_ARCH_CO285) += co285.o dc21285-timer.o
+obj-$(CONFIG_ARCH_EBSA285) += ebsa285.o dc21285-timer.o
+obj-$(CONFIG_ARCH_NETWINDER) += netwinder-hw.o isa-timer.o
+obj-$(CONFIG_ARCH_PERSONAL_SERVER) += personal.o dc21285-timer.o
 
 obj-$(CONFIG_PCI)	+=$(pci-y)
 obj-$(CONFIG_LEDS)	+=$(leds-y)
+
+obj-$(CONFIG_ISA)	+= isa.o
diff -Nru a/arch/arm/mach-footbridge/Makefile.boot b/arch/arm/mach-footbridge/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,4 @@
+   zreladdr-y	:= 0x00008000
+params_phys-y	:= 0x00000100
+initrd_phys-y	:= 0x00800000
+
diff -Nru a/arch/arm/mach-footbridge/arch.c b/arch/arm/mach-footbridge/arch.c
--- a/arch/arm/mach-footbridge/arch.c	2004-12-24 13:36:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,149 +0,0 @@
-/*
- * linux/arch/arm/mach-footbridge/arch.c
- *
- * Architecture specific fixups.  This is where any
- * parameters in the params struct are fixed up, or
- * any additional architecture specific information
- * is pulled from the params struct.
- */
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/delay.h>
-#include <linux/pm.h>
-#include <linux/init.h>
-
-#include <asm/hardware/dec21285.h>
-#include <asm/elf.h>
-#include <asm/setup.h>
-#include <asm/mach-types.h>
-
-#include <asm/mach/arch.h>
-
-extern void footbridge_map_io(void);
-extern void footbridge_init_irq(void);
-extern void footbridge_init_time(void);
-
-unsigned int mem_fclk_21285 = 50000000;
-
-EXPORT_SYMBOL(mem_fclk_21285);
-
-static int __init parse_tag_memclk(const struct tag *tag)
-{
-	mem_fclk_21285 = tag->u.memclk.fmemclk;
-	return 0;
-}
-
-__tagtable(ATAG_MEMCLK, parse_tag_memclk);
-
-#ifdef CONFIG_ARCH_EBSA285
-MACHINE_START(EBSA285, "EBSA285")
-	MAINTAINER("Russell King")
-	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0xfe000000)
-	BOOT_PARAMS(0x00000100)
-	VIDEO(0x000a0000, 0x000bffff)
-	MAPIO(footbridge_map_io)
-	INITIRQ(footbridge_init_irq)
-	INITTIME(footbridge_init_time)
-MACHINE_END
-#endif
-
-#ifdef CONFIG_ARCH_NETWINDER
-/*
- * Older NeTTroms either do not provide a parameters
- * page, or they don't supply correct information in
- * the parameter page.
- */
-static void __init
-fixup_netwinder(struct machine_desc *desc, struct tag *tags,
-		char **cmdline, struct meminfo *mi)
-{
-#ifdef CONFIG_ISAPNP
-	extern int isapnp_disable;
-
-	/*
-	 * We must not use the kernels ISAPnP code
-	 * on the NetWinder - it will reset the settings
-	 * for the WaveArtist chip and render it inoperable.
-	 */
-	isapnp_disable = 1;
-#endif
-}
-
-MACHINE_START(NETWINDER, "Rebel-NetWinder")
-	MAINTAINER("Russell King/Rebel.com")
-	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0xfe000000)
-	BOOT_PARAMS(0x00000100)
-	VIDEO(0x000a0000, 0x000bffff)
-	DISABLE_PARPORT(0)
-	DISABLE_PARPORT(2)
-	FIXUP(fixup_netwinder)
-	MAPIO(footbridge_map_io)
-	INITIRQ(footbridge_init_irq)
-	INITTIME(footbridge_init_time)
-MACHINE_END
-#endif
-
-#ifdef CONFIG_ARCH_CATS
-/*
- * CATS uses soft-reboot by default, since
- * hard reboots fail on early boards.
- */
-static void __init
-fixup_cats(struct machine_desc *desc, struct tag *tags,
-	   char **cmdline, struct meminfo *mi)
-{
-	ORIG_VIDEO_LINES  = 25;
-	ORIG_VIDEO_POINTS = 16;
-	ORIG_Y = 24;
-}
-
-MACHINE_START(CATS, "Chalice-CATS")
-	MAINTAINER("Philip Blundell")
-	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0xfe000000)
-	BOOT_PARAMS(0x00000100)
-	SOFT_REBOOT
-	FIXUP(fixup_cats)
-	MAPIO(footbridge_map_io)
-	INITIRQ(footbridge_init_irq)
-	INITTIME(footbridge_init_time)
-MACHINE_END
-#endif
-
-#ifdef CONFIG_ARCH_CO285
-
-static void __init
-fixup_coebsa285(struct machine_desc *desc, struct tag *tags,
-		char **cmdline, struct meminfo *mi)
-{
-	extern unsigned long boot_memory_end;
-	extern char boot_command_line[];
-
-	mi->nr_banks      = 1;
-	mi->bank[0].start = PHYS_OFFSET;
-	mi->bank[0].size  = boot_memory_end;
-	mi->bank[0].node  = 0;
-
-	*cmdline = boot_command_line;
-}
-
-MACHINE_START(CO285, "co-EBSA285")
-	MAINTAINER("Mark van Doesburg")
-	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0x7cf00000)
-	FIXUP(fixup_coebsa285)
-	MAPIO(footbridge_map_io)
-	INITIRQ(footbridge_init_irq)
-	INITTIME(footbridge_init_time)
-MACHINE_END
-#endif
-
-#ifdef CONFIG_ARCH_PERSONAL_SERVER
-MACHINE_START(PERSONAL_SERVER, "Compaq-PersonalServer")
-	MAINTAINER("Jamey Hicks / George France")
-	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0xfe000000)
-	BOOT_PARAMS(0x00000100)
-	MAPIO(footbridge_map_io)
-	INITIRQ(footbridge_init_irq)
-	INITTIME(footbridge_init_time)
-MACHINE_END
-#endif
diff -Nru a/arch/arm/mach-footbridge/cats-hw.c b/arch/arm/mach-footbridge/cats-hw.c
--- a/arch/arm/mach-footbridge/cats-hw.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-footbridge/cats-hw.c	2004-12-24 13:36:48 -08:00
@@ -9,8 +9,14 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 
+#include <asm/hardware/dec21285.h>
 #include <asm/io.h>
 #include <asm/mach-types.h>
+#include <asm/setup.h>
+
+#include <asm/mach/arch.h>
+
+#include "common.h"
 
 #define CFG_PORT	0x370
 #define INDEX_PORT	(CFG_PORT)
@@ -62,3 +68,27 @@
 }
 
 __initcall(cats_hw_init);
+
+/*
+ * CATS uses soft-reboot by default, since
+ * hard reboots fail on early boards.
+ */
+static void __init
+fixup_cats(struct machine_desc *desc, struct tag *tags,
+	   char **cmdline, struct meminfo *mi)
+{
+	ORIG_VIDEO_LINES  = 25;
+	ORIG_VIDEO_POINTS = 16;
+	ORIG_Y = 24;
+}
+
+MACHINE_START(CATS, "Chalice-CATS")
+	MAINTAINER("Philip Blundell")
+	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0xfe000000)
+	BOOT_PARAMS(0x00000100)
+	SOFT_REBOOT
+	FIXUP(fixup_cats)
+	MAPIO(footbridge_map_io)
+	INITIRQ(footbridge_init_irq)
+	.timer		= &isa_timer,
+MACHINE_END
diff -Nru a/arch/arm/mach-footbridge/co285.c b/arch/arm/mach-footbridge/co285.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/co285.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,38 @@
+/*
+ * linux/arch/arm/mach-footbridge/co285.c
+ *
+ * CO285 machine fixup
+ */
+#include <linux/init.h>
+
+#include <asm/hardware/dec21285.h>
+#include <asm/mach-types.h>
+
+#include <asm/mach/arch.h>
+
+#include "common.h"
+
+static void __init
+fixup_coebsa285(struct machine_desc *desc, struct tag *tags,
+		char **cmdline, struct meminfo *mi)
+{
+	extern unsigned long boot_memory_end;
+	extern char boot_command_line[];
+
+	mi->nr_banks      = 1;
+	mi->bank[0].start = PHYS_OFFSET;
+	mi->bank[0].size  = boot_memory_end;
+	mi->bank[0].node  = 0;
+
+	*cmdline = boot_command_line;
+}
+
+MACHINE_START(CO285, "co-EBSA285")
+	MAINTAINER("Mark van Doesburg")
+	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0x7cf00000)
+	FIXUP(fixup_coebsa285)
+	MAPIO(footbridge_map_io)
+	INITIRQ(footbridge_init_irq)
+	.timer		= &footbridge_timer,
+MACHINE_END
+
diff -Nru a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/common.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,205 @@
+/*
+ *  linux/arch/arm/mach-footbridge/common.c
+ *
+ *  Copyright (C) 1998-2000 Russell King, Dave Gilbert.
+ *
+ * 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/types.h>
+#include <linux/mm.h>
+#include <linux/ioport.h>
+#include <linux/list.h>
+#include <linux/init.h>
+ 
+#include <asm/pgtable.h>
+#include <asm/page.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <asm/setup.h>
+#include <asm/hardware/dec21285.h>
+
+#include <asm/mach/irq.h>
+#include <asm/mach/map.h>
+
+#include "common.h"
+
+extern void __init isa_init_irq(unsigned int irq);
+
+unsigned int mem_fclk_21285 = 50000000;
+
+EXPORT_SYMBOL(mem_fclk_21285);
+
+static int __init parse_tag_memclk(const struct tag *tag)
+{
+	mem_fclk_21285 = tag->u.memclk.fmemclk;
+	return 0;
+}
+
+__tagtable(ATAG_MEMCLK, parse_tag_memclk);
+
+/*
+ * Footbridge IRQ translation table
+ *  Converts from our IRQ numbers into FootBridge masks
+ */
+static const int fb_irq_mask[] = {
+	IRQ_MASK_UART_RX,	/*  0 */
+	IRQ_MASK_UART_TX,	/*  1 */
+	IRQ_MASK_TIMER1,	/*  2 */
+	IRQ_MASK_TIMER2,	/*  3 */
+	IRQ_MASK_TIMER3,	/*  4 */
+	IRQ_MASK_IN0,		/*  5 */
+	IRQ_MASK_IN1,		/*  6 */
+	IRQ_MASK_IN2,		/*  7 */
+	IRQ_MASK_IN3,		/*  8 */
+	IRQ_MASK_DOORBELLHOST,	/*  9 */
+	IRQ_MASK_DMA1,		/* 10 */
+	IRQ_MASK_DMA2,		/* 11 */
+	IRQ_MASK_PCI,		/* 12 */
+	IRQ_MASK_SDRAMPARITY,	/* 13 */
+	IRQ_MASK_I2OINPOST,	/* 14 */
+	IRQ_MASK_PCI_ABORT,	/* 15 */
+	IRQ_MASK_PCI_SERR,	/* 16 */
+	IRQ_MASK_DISCARD_TIMER,	/* 17 */
+	IRQ_MASK_PCI_DPERR,	/* 18 */
+	IRQ_MASK_PCI_PERR,	/* 19 */
+};
+
+static void fb_mask_irq(unsigned int irq)
+{
+	*CSR_IRQ_DISABLE = fb_irq_mask[_DC21285_INR(irq)];
+}
+
+static void fb_unmask_irq(unsigned int irq)
+{
+	*CSR_IRQ_ENABLE = fb_irq_mask[_DC21285_INR(irq)];
+}
+
+static struct irqchip fb_chip = {
+	.ack	= fb_mask_irq,
+	.mask	= fb_mask_irq,
+	.unmask = fb_unmask_irq,
+};
+
+static void __init __fb_init_irq(void)
+{
+	unsigned int irq;
+
+	/*
+	 * setup DC21285 IRQs
+	 */
+	*CSR_IRQ_DISABLE = -1;
+	*CSR_FIQ_DISABLE = -1;
+
+	for (irq = _DC21285_IRQ(0); irq < _DC21285_IRQ(20); irq++) {
+		set_irq_chip(irq, &fb_chip);
+		set_irq_handler(irq, do_level_IRQ);
+		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
+	}
+}
+
+void __init footbridge_init_irq(void)
+{
+	__fb_init_irq();
+
+	if (!footbridge_cfn_mode())
+		return;
+
+	if (machine_is_ebsa285())
+		/* The following is dependent on which slot
+		 * you plug the Southbridge card into.  We
+		 * currently assume that you plug it into
+		 * the right-hand most slot.
+		 */
+		isa_init_irq(IRQ_PCI);
+
+	if (machine_is_cats())
+		isa_init_irq(IRQ_IN2);
+
+	if (machine_is_netwinder())
+		isa_init_irq(IRQ_IN3);
+}
+
+/*
+ * Common mapping for all systems.  Note that the outbound write flush is
+ * commented out since there is a "No Fix" problem with it.  Not mapping
+ * it means that we have extra bullet protection on our feet.
+ */
+static struct map_desc fb_common_io_desc[] __initdata = {
+ { ARMCSR_BASE,	 DC21285_ARMCSR_BASE,	    ARMCSR_SIZE,  MT_DEVICE },
+ { XBUS_BASE,    0x40000000,		    XBUS_SIZE,    MT_DEVICE }
+};
+
+/*
+ * The mapping when the footbridge is in host mode.  We don't map any of
+ * this when we are in add-in mode.
+ */
+static struct map_desc ebsa285_host_io_desc[] __initdata = {
+#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_FOOTBRIDGE_HOST)
+ { PCIMEM_BASE,  DC21285_PCI_MEM,	    PCIMEM_SIZE,  MT_DEVICE },
+ { PCICFG0_BASE, DC21285_PCI_TYPE_0_CONFIG, PCICFG0_SIZE, MT_DEVICE },
+ { PCICFG1_BASE, DC21285_PCI_TYPE_1_CONFIG, PCICFG1_SIZE, MT_DEVICE },
+ { PCIIACK_BASE, DC21285_PCI_IACK,	    PCIIACK_SIZE, MT_DEVICE },
+ { PCIO_BASE,    DC21285_PCI_IO,	    PCIO_SIZE,	  MT_DEVICE }
+#endif
+};
+
+/*
+ * The CO-ebsa285 mapping.
+ */
+static struct map_desc co285_io_desc[] __initdata = {
+#ifdef CONFIG_ARCH_CO285
+ { PCIO_BASE,	 DC21285_PCI_IO,	    PCIO_SIZE,    MT_DEVICE },
+ { PCIMEM_BASE,	 DC21285_PCI_MEM,	    PCIMEM_SIZE,  MT_DEVICE }
+#endif
+};
+
+void __init footbridge_map_io(void)
+{
+	/*
+	 * Set up the common mapping first; we need this to
+	 * determine whether we're in host mode or not.
+	 */
+	iotable_init(fb_common_io_desc, ARRAY_SIZE(fb_common_io_desc));
+
+	/*
+	 * Now, work out what we've got to map in addition on this
+	 * platform.
+	 */
+	if (machine_is_co285())
+		iotable_init(co285_io_desc, ARRAY_SIZE(co285_io_desc));
+	if (footbridge_cfn_mode())
+		iotable_init(ebsa285_host_io_desc, ARRAY_SIZE(ebsa285_host_io_desc));
+}
+
+#ifdef CONFIG_FOOTBRIDGE_ADDIN
+
+/*
+ * These two functions convert virtual addresses to PCI addresses and PCI
+ * addresses to virtual addresses.  Note that it is only legal to use these
+ * on memory obtained via get_zeroed_page or kmalloc.
+ */
+unsigned long __virt_to_bus(unsigned long res)
+{
+	WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
+
+	return (res - PAGE_OFFSET) + (*CSR_PCISDRAMBASE & 0xfffffff0);
+}
+EXPORT_SYMBOL(__virt_to_bus);
+
+unsigned long __bus_to_virt(unsigned long res)
+{
+	res -= (*CSR_PCISDRAMBASE & 0xfffffff0);
+	res += PAGE_OFFSET;
+
+	WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
+
+	return res;
+}
+EXPORT_SYMBOL(__bus_to_virt);
+
+#endif
diff -Nru a/arch/arm/mach-footbridge/common.h b/arch/arm/mach-footbridge/common.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/common.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,9 @@
+
+extern struct sys_timer footbridge_timer;
+extern struct sys_timer isa_timer;
+
+extern void isa_rtc_init(void);
+
+extern void footbridge_map_io(void);
+extern void footbridge_init_irq(void);
+
diff -Nru a/arch/arm/mach-footbridge/dc21285-timer.c b/arch/arm/mach-footbridge/dc21285-timer.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/dc21285-timer.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,68 @@
+/*
+ *  linux/arch/arm/mach-footbridge/dc21285-timer.c
+ *
+ *  Copyright (C) 1998 Russell King.
+ *  Copyright (C) 1998 Phil Blundell
+ */
+#include <linux/init.h>
+#include <linux/interrupt.h>
+
+#include <asm/irq.h>
+
+#include <asm/hardware/dec21285.h>
+#include <asm/mach/time.h>
+
+#include "common.h"
+
+/*
+ * Footbridge timer 1 support.
+ */
+static unsigned long timer1_latch;
+
+static unsigned long timer1_gettimeoffset (void)
+{
+	unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
+
+	return ((tick_nsec / 1000) * value) / timer1_latch;
+}
+
+static irqreturn_t
+timer1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	write_seqlock(&xtime_lock);
+
+	*CSR_TIMER1_CLR = 0;
+
+	timer_tick(regs);
+
+	write_sequnlock(&xtime_lock);
+
+	return IRQ_HANDLED;
+}
+
+static struct irqaction footbridge_timer_irq = {
+	.name		= "Timer1 timer tick",
+	.handler	= timer1_interrupt,
+	.flags		= SA_INTERRUPT,
+};
+
+/*
+ * Set up timer interrupt.
+ */
+static void __init footbridge_timer_init(void)
+{
+	isa_rtc_init();
+
+	timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
+
+	*CSR_TIMER1_CLR  = 0;
+	*CSR_TIMER1_LOAD = timer1_latch;
+	*CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
+
+	setup_irq(IRQ_TIMER1, &footbridge_timer_irq);
+}
+
+struct sys_timer footbridge_timer = {
+	.init		= footbridge_timer_init,
+	.offset		= timer1_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-footbridge/ebsa285.c b/arch/arm/mach-footbridge/ebsa285.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/ebsa285.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,24 @@
+/*
+ * linux/arch/arm/mach-footbridge/ebsa285.c
+ *
+ * EBSA285 machine fixup
+ */
+#include <linux/init.h>
+
+#include <asm/hardware/dec21285.h>
+#include <asm/mach-types.h>
+
+#include <asm/mach/arch.h>
+
+#include "common.h"
+
+MACHINE_START(EBSA285, "EBSA285")
+	MAINTAINER("Russell King")
+	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0xfe000000)
+	BOOT_PARAMS(0x00000100)
+	VIDEO(0x000a0000, 0x000bffff)
+	MAPIO(footbridge_map_io)
+	INITIRQ(footbridge_init_irq)
+	.timer		= &footbridge_timer,
+MACHINE_END
+
diff -Nru a/arch/arm/mach-footbridge/irq.c b/arch/arm/mach-footbridge/irq.c
--- a/arch/arm/mach-footbridge/irq.c	2004-12-24 13:37:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,111 +0,0 @@
-/*
- *  linux/arch/arm/mach-footbridge/irq.c
- *
- *  Copyright (C) 1996-2000 Russell King
- *
- * 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.
- *
- *  Changelog:
- *   22-Aug-1998 RMK	Restructured IRQ routines
- *   03-Sep-1998 PJB	Merged CATS support
- *   20-Jan-1998 RMK	Started merge of EBSA286, CATS and NetWinder
- *   26-Jan-1999 PJB	Don't use IACK on CATS
- *   16-Mar-1999 RMK	Added autodetect of ISA PICs
- */
-#include <linux/ioport.h>
-#include <linux/list.h>
-#include <linux/init.h>
-
-#include <asm/mach/irq.h>
-
-#include <asm/hardware.h>
-#include <asm/hardware/dec21285.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-#include <asm/mach-types.h>
-
-extern void __init isa_init_irq(unsigned int irq);
-
-/*
- * Footbridge IRQ translation table
- *  Converts from our IRQ numbers into FootBridge masks
- */
-static const int fb_irq_mask[] = {
-	IRQ_MASK_UART_RX,	/*  0 */
-	IRQ_MASK_UART_TX,	/*  1 */
-	IRQ_MASK_TIMER1,	/*  2 */
-	IRQ_MASK_TIMER2,	/*  3 */
-	IRQ_MASK_TIMER3,	/*  4 */
-	IRQ_MASK_IN0,		/*  5 */
-	IRQ_MASK_IN1,		/*  6 */
-	IRQ_MASK_IN2,		/*  7 */
-	IRQ_MASK_IN3,		/*  8 */
-	IRQ_MASK_DOORBELLHOST,	/*  9 */
-	IRQ_MASK_DMA1,		/* 10 */
-	IRQ_MASK_DMA2,		/* 11 */
-	IRQ_MASK_PCI,		/* 12 */
-	IRQ_MASK_SDRAMPARITY,	/* 13 */
-	IRQ_MASK_I2OINPOST,	/* 14 */
-	IRQ_MASK_PCI_ABORT,	/* 15 */
-	IRQ_MASK_PCI_SERR,	/* 16 */
-	IRQ_MASK_DISCARD_TIMER,	/* 17 */
-	IRQ_MASK_PCI_DPERR,	/* 18 */
-	IRQ_MASK_PCI_PERR,	/* 19 */
-};
-
-static void fb_mask_irq(unsigned int irq)
-{
-	*CSR_IRQ_DISABLE = fb_irq_mask[_DC21285_INR(irq)];
-}
-
-static void fb_unmask_irq(unsigned int irq)
-{
-	*CSR_IRQ_ENABLE = fb_irq_mask[_DC21285_INR(irq)];
-}
-
-static struct irqchip fb_chip = {
-	.ack	= fb_mask_irq,
-	.mask	= fb_mask_irq,
-	.unmask = fb_unmask_irq,
-};
-
-static void __init __fb_init_irq(void)
-{
-	unsigned int irq;
-
-	/*
-	 * setup DC21285 IRQs
-	 */
-	*CSR_IRQ_DISABLE = -1;
-	*CSR_FIQ_DISABLE = -1;
-
-	for (irq = _DC21285_IRQ(0); irq < _DC21285_IRQ(20); irq++) {
-		set_irq_chip(irq, &fb_chip);
-		set_irq_handler(irq, do_level_IRQ);
-		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
-	}
-}
-
-void __init footbridge_init_irq(void)
-{
-	__fb_init_irq();
-
-	if (!footbridge_cfn_mode())
-		return;
-
-	if (machine_is_ebsa285())
-		/* The following is dependent on which slot
-		 * you plug the Southbridge card into.  We
-		 * currently assume that you plug it into
-		 * the right-hand most slot.
-		 */
-		isa_init_irq(IRQ_PCI);
-
-	if (machine_is_cats())
-		isa_init_irq(IRQ_IN2);
-
-	if (machine_is_netwinder())
-		isa_init_irq(IRQ_IN3);
-}
diff -Nru a/arch/arm/mach-footbridge/isa-timer.c b/arch/arm/mach-footbridge/isa-timer.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/isa-timer.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,94 @@
+/*
+ *  linux/arch/arm/mach-footbridge/isa-timer.c
+ *
+ *  Copyright (C) 1998 Russell King.
+ *  Copyright (C) 1998 Phil Blundell
+ */
+#include <linux/init.h>
+#include <linux/interrupt.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+
+#include <asm/mach/time.h>
+
+#include "common.h"
+
+/*
+ * ISA timer tick support
+ */
+#define mSEC_10_from_14 ((14318180 + 100) / 200)
+
+static unsigned long isa_gettimeoffset(void)
+{
+	int count;
+
+	static int count_p = (mSEC_10_from_14/6);    /* for the first call after boot */
+	static unsigned long jiffies_p = 0;
+
+	/*
+	 * cache volatile jiffies temporarily; we have IRQs turned off. 
+	 */
+	unsigned long jiffies_t;
+
+	/* timer count may underflow right here */
+	outb_p(0x00, 0x43);	/* latch the count ASAP */
+
+	count = inb_p(0x40);	/* read the latched count */
+
+	/*
+	 * We do this guaranteed double memory access instead of a _p 
+	 * postfix in the previous port access. Wheee, hackady hack
+	 */
+ 	jiffies_t = jiffies;
+
+	count |= inb_p(0x40) << 8;
+
+	/* Detect timer underflows.  If we haven't had a timer tick since 
+	   the last time we were called, and time is apparently going
+	   backwards, the counter must have wrapped during this routine. */
+	if ((jiffies_t == jiffies_p) && (count > count_p))
+		count -= (mSEC_10_from_14/6);
+	else
+		jiffies_p = jiffies_t;
+
+	count_p = count;
+
+	count = (((mSEC_10_from_14/6)-1) - count) * (tick_nsec / 1000);
+	count = (count + (mSEC_10_from_14/6)/2) / (mSEC_10_from_14/6);
+
+	return count;
+}
+
+static irqreturn_t
+isa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	write_seqlock(&xtime_lock);
+	timer_tick(regs);
+	write_sequnlock(&xtime_lock);
+	return IRQ_HANDLED;
+}
+
+static struct irqaction isa_timer_irq = {
+	.name		= "ISA timer tick",
+	.handler	= isa_timer_interrupt,
+	.flags		= SA_INTERRUPT,
+};
+
+static void __init isa_timer_init(void)
+{
+	isa_rtc_init();
+
+	/* enable PIT timer */
+	/* set for periodic (4) and LSB/MSB write (0x30) */
+	outb(0x34, 0x43);
+	outb((mSEC_10_from_14/6) & 0xFF, 0x40);
+	outb((mSEC_10_from_14/6) >> 8, 0x40);
+
+	setup_irq(IRQ_ISA_TIMER, &isa_timer_irq);
+}
+
+struct sys_timer isa_timer = {
+	.init		= isa_timer_init,
+	.offset		= isa_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-footbridge/isa.c b/arch/arm/mach-footbridge/isa.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/isa.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,48 @@
+/*
+ *  linux/arch/arm/mach-footbridge/isa.c
+ *
+ *  Copyright (C) 2004 Russell King.
+ *
+ * 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/init.h>
+#include <linux/serial_8250.h>
+
+#include <asm/irq.h>
+
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.iobase		= 0x3f8,
+		.irq		= IRQ_ISA_UART,
+		.uartclk	= 1843200,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.iobase		= 0x2f8,
+		.irq		= IRQ_ISA_UART2,
+		.uartclk	= 1843200,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= 0,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
+static int __init footbridge_isa_init(void)
+{
+	return platform_device_register(&serial_device);
+}
+
+arch_initcall(footbridge_isa_init);
diff -Nru a/arch/arm/mach-footbridge/mm.c b/arch/arm/mach-footbridge/mm.c
--- a/arch/arm/mach-footbridge/mm.c	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,103 +0,0 @@
-/*
- *  linux/arch/arm/mach-footbridge/mm.c
- *
- *  Copyright (C) 1998-2000 Russell King, Dave Gilbert.
- *
- * 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.
- *
- *  Extra MM routines for the EBSA285 architecture
- */
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
- 
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/io.h>
-#include <asm/hardware/dec21285.h>
-#include <asm/mach-types.h>
-
-#include <asm/mach/map.h>
-
-/*
- * Common mapping for all systems.  Note that the outbound write flush is
- * commented out since there is a "No Fix" problem with it.  Not mapping
- * it means that we have extra bullet protection on our feet.
- */
-static struct map_desc fb_common_io_desc[] __initdata = {
- { ARMCSR_BASE,	 DC21285_ARMCSR_BASE,	    ARMCSR_SIZE,  MT_DEVICE },
- { XBUS_BASE,    0x40000000,		    XBUS_SIZE,    MT_DEVICE }
-};
-
-/*
- * The mapping when the footbridge is in host mode.  We don't map any of
- * this when we are in add-in mode.
- */
-static struct map_desc ebsa285_host_io_desc[] __initdata = {
-#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_FOOTBRIDGE_HOST)
- { PCIMEM_BASE,  DC21285_PCI_MEM,	    PCIMEM_SIZE,  MT_DEVICE },
- { PCICFG0_BASE, DC21285_PCI_TYPE_0_CONFIG, PCICFG0_SIZE, MT_DEVICE },
- { PCICFG1_BASE, DC21285_PCI_TYPE_1_CONFIG, PCICFG1_SIZE, MT_DEVICE },
- { PCIIACK_BASE, DC21285_PCI_IACK,	    PCIIACK_SIZE, MT_DEVICE },
- { PCIO_BASE,    DC21285_PCI_IO,	    PCIO_SIZE,	  MT_DEVICE }
-#endif
-};
-
-/*
- * The CO-ebsa285 mapping.
- */
-static struct map_desc co285_io_desc[] __initdata = {
-#ifdef CONFIG_ARCH_CO285
- { PCIO_BASE,	 DC21285_PCI_IO,	    PCIO_SIZE,    MT_DEVICE },
- { PCIMEM_BASE,	 DC21285_PCI_MEM,	    PCIMEM_SIZE,  MT_DEVICE }
-#endif
-};
-
-void __init footbridge_map_io(void)
-{
-	/*
-	 * Set up the common mapping first; we need this to
-	 * determine whether we're in host mode or not.
-	 */
-	iotable_init(fb_common_io_desc, ARRAY_SIZE(fb_common_io_desc));
-
-	/*
-	 * Now, work out what we've got to map in addition on this
-	 * platform.
-	 */
-	if (machine_is_co285())
-		iotable_init(co285_io_desc, ARRAY_SIZE(co285_io_desc));
-	if (footbridge_cfn_mode())
-		iotable_init(ebsa285_host_io_desc, ARRAY_SIZE(ebsa285_host_io_desc));
-}
-
-#ifdef CONFIG_FOOTBRIDGE_ADDIN
-
-/*
- * These two functions convert virtual addresses to PCI addresses and PCI
- * addresses to virtual addresses.  Note that it is only legal to use these
- * on memory obtained via get_zeroed_page or kmalloc.
- */
-unsigned long __virt_to_bus(unsigned long res)
-{
-	WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
-
-	return (res - PAGE_OFFSET) + (*CSR_PCISDRAMBASE & 0xfffffff0);
-}
-EXPORT_SYMBOL(__virt_to_bus);
-
-unsigned long __bus_to_virt(unsigned long res)
-{
-	res -= (*CSR_PCISDRAMBASE & 0xfffffff0);
-	res += PAGE_OFFSET;
-
-	WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
-
-	return res;
-}
-EXPORT_SYMBOL(__bus_to_virt);
-
-#endif
diff -Nru a/arch/arm/mach-footbridge/netwinder-hw.c b/arch/arm/mach-footbridge/netwinder-hw.c
--- a/arch/arm/mach-footbridge/netwinder-hw.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-footbridge/netwinder-hw.c	2004-12-24 13:36:18 -08:00
@@ -12,9 +12,15 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 
+#include <asm/hardware/dec21285.h>
 #include <asm/io.h>
 #include <asm/leds.h>
 #include <asm/mach-types.h>
+#include <asm/setup.h>
+
+#include <asm/mach/arch.h>
+
+#include "common.h"
 
 #define IRDA_IO_BASE		0x180
 #define GP1_IO_BASE		0x338
@@ -52,7 +58,7 @@
 	outb(reg, 0x370);
 	outb(val >> 8, 0x371);
 	outb(reg + 1, 0x370);
-	outb(val, 0x371);
+	outb(val & 255, 0x371);
 }
 
 #define wb977_device_select(dev)	wb977_wb(0x07, dev)
@@ -482,7 +488,7 @@
 	WRITE_RWA(7, 0);
 
 	dprintk("WaveArtist base: ");
-	WRITE_RWA(0x61, base);
+	WRITE_RWA(0x61, base & 255);
 	i = inb(0x203);
 
 	WRITE_RWA(0x60, base >> 8);
@@ -504,7 +510,7 @@
 	WRITE_RWA(7, 1);
 
 	dprintk("SoundBlaster base: ");
-	WRITE_RWA(0x61, sb_base);
+	WRITE_RWA(0x61, sb_base & 255);
 	i = inb(0x203);
 
 	WRITE_RWA(0x60, sb_base >> 8);
@@ -519,7 +525,7 @@
 	dprintk("%d (%d)\n", inb(0x203), dma);
 
 	dprintk("AdLib base: ");
-	WRITE_RWA(0x63, al_base);
+	WRITE_RWA(0x63, al_base & 255);
 	i = inb(0x203);
 
 	WRITE_RWA(0x62, al_base >> 8);
@@ -618,3 +624,37 @@
 }
 
 __initcall(nw_hw_init);
+
+/*
+ * Older NeTTroms either do not provide a parameters
+ * page, or they don't supply correct information in
+ * the parameter page.
+ */
+static void __init
+fixup_netwinder(struct machine_desc *desc, struct tag *tags,
+		char **cmdline, struct meminfo *mi)
+{
+#ifdef CONFIG_ISAPNP
+	extern int isapnp_disable;
+
+	/*
+	 * We must not use the kernels ISAPnP code
+	 * on the NetWinder - it will reset the settings
+	 * for the WaveArtist chip and render it inoperable.
+	 */
+	isapnp_disable = 1;
+#endif
+}
+
+MACHINE_START(NETWINDER, "Rebel-NetWinder")
+	MAINTAINER("Russell King/Rebel.com")
+	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0xfe000000)
+	BOOT_PARAMS(0x00000100)
+	VIDEO(0x000a0000, 0x000bffff)
+	DISABLE_PARPORT(0)
+	DISABLE_PARPORT(2)
+	FIXUP(fixup_netwinder)
+	MAPIO(footbridge_map_io)
+	INITIRQ(footbridge_init_irq)
+	.timer		= &isa_timer,
+MACHINE_END
diff -Nru a/arch/arm/mach-footbridge/personal.c b/arch/arm/mach-footbridge/personal.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-footbridge/personal.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,23 @@
+/*
+ * linux/arch/arm/mach-footbridge/personal.c
+ *
+ * Personal server (Skiff) machine fixup
+ */
+#include <linux/init.h>
+
+#include <asm/hardware/dec21285.h>
+#include <asm/mach-types.h>
+
+#include <asm/mach/arch.h>
+
+#include "common.h"
+
+MACHINE_START(PERSONAL_SERVER, "Compaq-PersonalServer")
+	MAINTAINER("Jamey Hicks / George France")
+	BOOT_MEM(0x00000000, DC21285_ARMCSR_BASE, 0xfe000000)
+	BOOT_PARAMS(0x00000100)
+	MAPIO(footbridge_map_io)
+	INITIRQ(footbridge_init_irq)
+	.timer		= &footbridge_timer,
+MACHINE_END
+
diff -Nru a/arch/arm/mach-footbridge/time.c b/arch/arm/mach-footbridge/time.c
--- a/arch/arm/mach-footbridge/time.c	2004-12-24 13:37:43 -08:00
+++ b/arch/arm/mach-footbridge/time.c	2004-12-24 13:37:43 -08:00
@@ -19,75 +19,18 @@
 
 #include <linux/timex.h>
 #include <linux/init.h>
-#include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/mc146818rtc.h>
 #include <linux/bcd.h>
 
-#include <asm/hardware/dec21285.h>
-
 #include <asm/hardware.h>
-#include <asm/irq.h>
-#include <asm/leds.h>
-#include <asm/mach-types.h>
 #include <asm/io.h>
-#include <asm/hardware/clps7111.h>
 
 #include <asm/mach/time.h>
+#include "common.h"
 
 static int rtc_base;
 
-#define mSEC_10_from_14 ((14318180 + 100) / 200)
-
-static unsigned long isa_gettimeoffset(void)
-{
-	int count;
-
-	static int count_p = (mSEC_10_from_14/6);    /* for the first call after boot */
-	static unsigned long jiffies_p = 0;
-
-	/*
-	 * cache volatile jiffies temporarily; we have IRQs turned off. 
-	 */
-	unsigned long jiffies_t;
-
-	/* timer count may underflow right here */
-	outb_p(0x00, 0x43);	/* latch the count ASAP */
-
-	count = inb_p(0x40);	/* read the latched count */
-
-	/*
-	 * We do this guaranteed double memory access instead of a _p 
-	 * postfix in the previous port access. Wheee, hackady hack
-	 */
- 	jiffies_t = jiffies;
-
-	count |= inb_p(0x40) << 8;
-
-	/* Detect timer underflows.  If we haven't had a timer tick since 
-	   the last time we were called, and time is apparently going
-	   backwards, the counter must have wrapped during this routine. */
-	if ((jiffies_t == jiffies_p) && (count > count_p))
-		count -= (mSEC_10_from_14/6);
-	else
-		jiffies_p = jiffies_t;
-
-	count_p = count;
-
-	count = (((mSEC_10_from_14/6)-1) - count) * (tick_nsec / 1000);
-	count = (count + (mSEC_10_from_14/6)/2) / (mSEC_10_from_14/6);
-
-	return count;
-}
-
-static irqreturn_t
-isa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-	timer_tick(regs);
-
-	return IRQ_HANDLED;
-}
-
 static unsigned long __init get_isa_cmos_time(void)
 {
 	unsigned int year, mon, day, hour, min, sec;
@@ -133,8 +76,7 @@
 	return mktime(year, mon, day, hour, min, sec);
 }
 
-static int
-set_isa_cmos_time(void)
+static int set_isa_cmos_time(void)
 {
 	int retval = 0;
 	int real_seconds, real_minutes, cmos_minutes;
@@ -186,34 +128,7 @@
 	return retval;
 }
 
-
-static unsigned long timer1_latch;
-
-static unsigned long timer1_gettimeoffset (void)
-{
-	unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
-
-	return ((tick_nsec / 1000) * value) / timer1_latch;
-}
-
-static irqreturn_t
-timer1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-	*CSR_TIMER1_CLR = 0;
-
-	timer_tick(regs);
-
-	return IRQ_HANDLED;
-}
-
-static struct irqaction footbridge_timer_irq = {
-	.flags	= SA_INTERRUPT
-};
-
-/*
- * Set up timer interrupt.
- */
-void __init footbridge_init_time(void)
+void __init isa_rtc_init(void)
 {
 	if (machine_is_co285() ||
 	    machine_is_personal_server())
@@ -261,36 +176,5 @@
 			set_rtc = set_isa_cmos_time;
 		} else
 			rtc_base = 0;
-	}
-
-	if (machine_is_ebsa285() ||
-	    machine_is_co285() ||
-	    machine_is_personal_server()) {
-		gettimeoffset = timer1_gettimeoffset;
-
-		timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
-
-		*CSR_TIMER1_CLR  = 0;
-		*CSR_TIMER1_LOAD = timer1_latch;
-		*CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
-
-		footbridge_timer_irq.name = "Timer1 Timer Tick";
-		footbridge_timer_irq.handler = timer1_interrupt;
-		
-		setup_irq(IRQ_TIMER1, &footbridge_timer_irq);
-
-	} else {
-		/* enable PIT timer */
-		/* set for periodic (4) and LSB/MSB write (0x30) */
-		outb(0x34, 0x43);
-		outb((mSEC_10_from_14/6) & 0xFF, 0x40);
-		outb((mSEC_10_from_14/6) >> 8, 0x40);
-
-		gettimeoffset = isa_gettimeoffset;
-
-		footbridge_timer_irq.name = "ISA Timer Tick";
-		footbridge_timer_irq.handler = isa_timer_interrupt;
-		
-		setup_irq(IRQ_ISA_TIMER, &footbridge_timer_irq);
 	}
 }
diff -Nru a/arch/arm/mach-h720x/Kconfig b/arch/arm/mach-h720x/Kconfig
--- a/arch/arm/mach-h720x/Kconfig	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/mach-h720x/Kconfig	2004-12-24 13:36:16 -08:00
@@ -1,3 +1,5 @@
+if ARCH_H720X
+
 menu "h720x Implementations"
 
 config ARCH_H7201
@@ -25,3 +27,5 @@
 	bool
 	help
 	  Select code specific to h7202 variants
+
+endif
diff -Nru a/arch/arm/mach-h720x/Makefile.boot b/arch/arm/mach-h720x/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-h720x/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2 @@
+   zreladdr-$(CONFIG_ARCH_H720X)	:= 0x40008000
+
diff -Nru a/arch/arm/mach-h720x/common.h b/arch/arm/mach-h720x/common.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-h720x/common.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,29 @@
+/*
+ * linux/arch/arm/mach-h720x/common.h
+ *
+ * Copyright (C) 2003 Thomas Gleixner <tglx@linutronix.de>
+ *               2003 Robert Schwebel <r.schwebel@pengutronix.de>
+ *               2004 Sascha Hauer    <s.hauer@pengutronix.de>
+ *
+ * Architecture specific stuff for Hynix GMS30C7201 development board
+ *
+ * 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.
+ *
+ */
+
+extern unsigned long h720x_gettimeoffset(void);
+extern void __init h720x_init_irq (void);
+extern void __init h720x_map_io(void);
+
+#ifdef CONFIG_ARCH_H7202
+extern struct sys_timer h7202_timer;
+extern void __init init_hw_h7202(void);
+extern void __init h7202_init_irq (void);
+extern void __init h7202_init_time(void);
+#endif
+
+#ifdef CONFIG_ARCH_H7201
+extern struct sys_timer h7201_timer;
+#endif
diff -Nru a/arch/arm/mach-h720x/cpu-h7201.c b/arch/arm/mach-h720x/cpu-h7201.c
--- a/arch/arm/mach-h720x/cpu-h7201.c	2004-12-24 13:36:19 -08:00
+++ b/arch/arm/mach-h720x/cpu-h7201.c	2004-12-24 13:36:19 -08:00
@@ -22,18 +22,20 @@
 #include <asm/arch/irqs.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
-
-extern unsigned long h720x_gettimeoffset(void);
-extern void __init h720x_init_irq (void);
-
+#include "common.h"
 /*
  * Timer interrupt handler
  */
 static irqreturn_t
 h7201_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
+
 	CPU_REG (TIMER_VIRT, TIMER_TOPSTAT);
 	timer_tick(regs);
+
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -48,8 +50,6 @@
  */
 void __init h7201_init_time(void)
 {
-	gettimeoffset = h720x_gettimeoffset;
-
 	CPU_REG (TIMER_VIRT, TM0_PERIOD) = LATCH;
 	CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_RESET;
 	CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_REPEAT | TM_START;
@@ -57,3 +57,8 @@
 
 	setup_irq(IRQ_TIMER0, &h7201_timer_irq);
 }
+
+struct sys_timer h7201_timer = {
+	.init		= h7201_init_time,
+	.offset		= h720x_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-h720x/cpu-h7202.c b/arch/arm/mach-h720x/cpu-h7202.c
--- a/arch/arm/mach-h720x/cpu-h7202.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-h720x/cpu-h7202.c	2004-12-24 13:36:55 -08:00
@@ -23,6 +23,8 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 #include <linux/device.h>
+#include <linux/serial_8250.h>
+#include "common.h"
 
 static struct resource h7202ps2_resources[] = {
 	[0] = {
@@ -44,13 +46,55 @@
 	.resource	= h7202ps2_resources,
 };
 
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.membase	= SERIAL0_BASE,
+		.irq		= IRQ_UART0,
+		.uartclk	= 2*1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_MEM,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.membase	= SERIAL1_BASE,
+		.irq		= IRQ_UART1,
+		.uartclk	= 2*1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_MEM,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.membase	= SERIAL2_BASE,
+		.irq		= IRQ_UART2,
+		.uartclk	= 2*1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_MEM,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.membase	= SERIAL3_BASE,
+		.irq		= IRQ_UART3,
+		.uartclk	= 2*1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_MEM,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= 0,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
 static struct platform_device *devices[] __initdata = {
 	&h7202ps2_device,
+	&serial_device,
 };
 
-extern unsigned long h720x_gettimeoffset(void);
-extern void __init h720x_init_irq (void);
-
 /* Although we have two interrupt lines for the timers, we only have one
  * status register which clears all pending timer interrupts on reading. So
  * we have to handle all timer interrupts in one place.
@@ -64,7 +108,9 @@
 	mask = CPU_REG (TIMER_VIRT, TIMER_TOPSTAT);
 
 	if ( mask & TSTAT_T0INT ) {
+		write_seqlock(&xtime_lock);
 		timer_tick(regs);
+		write_sequnlock(&xtime_lock);
 		if( mask == TSTAT_T0INT )
 			return;
 	}
@@ -128,8 +174,6 @@
  */
 void __init h7202_init_time(void)
 {
-	gettimeoffset = h720x_gettimeoffset;
-
 	CPU_REG (TIMER_VIRT, TM0_PERIOD) = LATCH;
 	CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_RESET;
 	CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_REPEAT | TM_START;
@@ -137,6 +181,11 @@
 
 	setup_irq(IRQ_TIMER0, &h7202_timer_irq);
 }
+
+struct sys_timer h7202_timer = {
+	.init		= h7202_init_time,
+	.offset		= h720x_gettimeoffset,
+};
 
 void __init h7202_init_irq (void)
 {
diff -Nru a/arch/arm/mach-h720x/h7201-eval.c b/arch/arm/mach-h720x/h7201-eval.c
--- a/arch/arm/mach-h720x/h7201-eval.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-h720x/h7201-eval.c	2004-12-24 13:36:55 -08:00
@@ -27,10 +27,7 @@
 #include <asm/pgtable.h>
 #include <asm/mach/arch.h>
 #include <asm/hardware.h>
-
-extern void h720x_init_irq (void);
-extern void h7201_init_time(void);
-extern void __init h720x_map_io(void);
+#include "common.h"
 
 MACHINE_START(H7201, "Hynix GMS30C7201")
 	MAINTAINER("Robert Schwebel, Pengutronix")
@@ -38,5 +35,5 @@
 	BOOT_PARAMS(0xc0001000)
 	MAPIO(h720x_map_io)
 	INITIRQ(h720x_init_irq)
-	INITTIME(h7201_init_time)
+	.timer = &h7201_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-h720x/h7202-eval.c b/arch/arm/mach-h720x/h7202-eval.c
--- a/arch/arm/mach-h720x/h7202-eval.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-h720x/h7202-eval.c	2004-12-24 13:36:17 -08:00
@@ -27,11 +27,7 @@
 #include <asm/pgtable.h>
 #include <asm/mach/arch.h>
 #include <asm/hardware.h>
-
-extern void __init init_hw_h7202(void);
-extern void __init h7202_init_irq (void);
-extern void __init h7202_init_time(void);
-extern void __init h720x_map_io(void);
+#include "common.h"
 
 static struct resource cirrus_resources[] = {
 	[0] = {
@@ -80,6 +76,6 @@
 	BOOT_PARAMS(0x40000100)
 	MAPIO(h720x_map_io)
 	INITIRQ(h7202_init_irq)
-	INITTIME(h7202_init_time)
+	.timer = &h7202_timer,
 	INIT_MACHINE(init_eval_h7202)
 MACHINE_END
diff -Nru a/arch/arm/mach-imx/Makefile.boot b/arch/arm/mach-imx/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-imx/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2 @@
+    zreladdr-$(CONFIG_ARCH_MX1ADS)	:= 0x08008000
+
diff -Nru a/arch/arm/mach-imx/generic.h b/arch/arm/mach-imx/generic.h
--- a/arch/arm/mach-imx/generic.h	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-imx/generic.h	2004-12-24 13:36:55 -08:00
@@ -11,4 +11,6 @@
 
 extern void __init imx_map_io(void);
 extern void __init imx_init_irq(void);
-extern void __init imx_init_time(void);
+
+struct sys_timer;
+extern struct sys_timer imx_timer;
diff -Nru a/arch/arm/mach-imx/mx1ads.c b/arch/arm/mach-imx/mx1ads.c
--- a/arch/arm/mach-imx/mx1ads.c	2004-12-24 13:37:29 -08:00
+++ b/arch/arm/mach-imx/mx1ads.c	2004-12-24 13:37:29 -08:00
@@ -83,6 +83,6 @@
 	BOOT_PARAMS(0x08000100)
 	MAPIO(mx1ads_map_io)
 	INITIRQ(imx_init_irq)
-	INITTIME(imx_init_time)
+	.timer		= &imx_timer,
 	INIT_MACHINE(mx1ads_init)
 MACHINE_END
diff -Nru a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
--- a/arch/arm/mach-imx/time.c	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/mach-imx/time.c	2004-12-24 13:36:47 -08:00
@@ -28,8 +28,7 @@
  * Returns number of us since last clock interrupt.  Note that interrupts
  * will have been disabled by do_gettimeoffset()
  */
-static unsigned long
-imx_gettimeoffset(void)
+static unsigned long imx_gettimeoffset(void)
 {
 	unsigned long ticks;
 
@@ -59,11 +58,15 @@
 static irqreturn_t
 imx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
+
 	/* clear the interrupt */
 	if (IMX_TSTAT(TIMER_BASE))
 		IMX_TSTAT(TIMER_BASE) = 0;
 
 	timer_tick(regs);
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -76,8 +79,7 @@
 /*
  * Set up timer interrupt, and return the current time in seconds.
  */
-void __init
-imx_init_time(void)
+static void __init imx_timer_init(void)
 {
 	/*
 	 * Initialise to a known state (all timers off, and timing reset)
@@ -91,5 +93,9 @@
 	 * Make irqs happen for the system timer
 	 */
 	setup_irq(TIM1_INT, &imx_timer_irq);
-	gettimeoffset = imx_gettimeoffset;
 }
+
+struct sys_timer imx_timer = {
+	.init		= imx_timer_init,
+	.offset		= imx_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-integrator/Makefile.boot b/arch/arm/mach-integrator/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-integrator/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,4 @@
+   zreladdr-y	:= 0x00008000
+params_phys-y	:= 0x00000100
+initrd_phys-y	:= 0x00800000
+
diff -Nru a/arch/arm/mach-integrator/common.h b/arch/arm/mach-integrator/common.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-integrator/common.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2 @@
+extern void integrator_time_init(unsigned long, unsigned int);
+extern unsigned long integrator_gettimeoffset(void);
diff -Nru a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
--- a/arch/arm/mach-integrator/core.c	2004-12-24 13:37:02 -08:00
+++ b/arch/arm/mach-integrator/core.c	2004-12-24 13:37:02 -08:00
@@ -24,6 +24,8 @@
 #include <asm/leds.h>
 #include <asm/mach/time.h>
 
+#include "common.h"
+
 static struct amba_device rtc_device = {
 	.dev		= {
 		.bus_id	= "mb:15",
@@ -163,15 +165,13 @@
 	unsigned long TimerClear;
 } TimerStruct_t;
 
-extern unsigned long (*gettimeoffset)(void);
-
 static unsigned long timer_reload;
 
 /*
  * Returns number of ms since last clock interrupt.  Note that interrupts
  * will have been disabled by do_gettimeoffset()
  */
-static unsigned long integrator_gettimeoffset(void)
+unsigned long integrator_gettimeoffset(void)
 {
 	volatile TimerStruct_t *timer1 = (TimerStruct_t *)TIMER1_VA_BASE;
 	unsigned long ticks1, ticks2, status;
@@ -214,11 +214,15 @@
 {
 	volatile TimerStruct_t *timer1 = (volatile TimerStruct_t *)TIMER1_VA_BASE;
 
+	write_seqlock(&xtime_lock);
+
 	// ...clear the interrupt
 	timer1->TimerClear = 1;
 
 	timer_tick(regs);
 
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -264,5 +268,4 @@
 	 * Make irqs happen for the system timer
 	 */
 	setup_irq(IRQ_TIMERINT1, &integrator_timer_irq);
-	gettimeoffset = integrator_gettimeoffset;
 }
diff -Nru a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
--- a/arch/arm/mach-integrator/integrator_ap.c	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/mach-integrator/integrator_ap.c	2004-12-24 13:37:18 -08:00
@@ -40,7 +40,9 @@
 #include <asm/mach/flash.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
+#include <asm/mach/time.h>
 
+#include "common.h"
 
 /* 
  * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
@@ -281,17 +283,22 @@
 	}
 }
 
-static void ap_time_init(void)
+static void __init ap_init_timer(void)
 {
 	integrator_time_init(1000000 * TICKS_PER_uSEC / HZ, 0);
 }
 
+static struct sys_timer ap_timer = {
+	.init		= ap_init_timer,
+	.offset		= integrator_gettimeoffset,
+};
+
 MACHINE_START(INTEGRATOR, "ARM-Integrator")
 	MAINTAINER("ARM Ltd/Deep Blue Solutions Ltd")
 	BOOT_MEM(0x00000000, 0x16000000, 0xf1600000)
 	BOOT_PARAMS(0x00000100)
 	MAPIO(ap_map_io)
 	INITIRQ(ap_init_irq)
-	INITTIME(ap_time_init)
+	.timer		= &ap_timer,
 	INIT_MACHINE(ap_init)
 MACHINE_END
diff -Nru a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
--- a/arch/arm/mach-integrator/integrator_cp.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/mach-integrator/integrator_cp.c	2004-12-24 13:37:19 -08:00
@@ -35,7 +35,9 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/mmc.h>
 #include <asm/mach/map.h>
+#include <asm/mach/time.h>
 
+#include "common.h"
 #include "clock.h"
 
 #define INTCP_PA_MMC_BASE		0x1c000000
@@ -496,17 +498,22 @@
 
 #define TIMER_CTRL_IE	(1 << 5)			/* Interrupt Enable */
 
-static void __init intcp_init_time(void)
+static void __init intcp_timer_init(void)
 {
 	integrator_time_init(1000000 / HZ, TIMER_CTRL_IE);
 }
 
+static struct sys_timer cp_timer = {
+	.init		= intcp_timer_init,
+	.offset		= integrator_gettimeoffset,
+};
+
 MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
 	MAINTAINER("ARM Ltd/Deep Blue Solutions Ltd")
 	BOOT_MEM(0x00000000, 0x16000000, 0xf1600000)
 	BOOT_PARAMS(0x00000100)
 	MAPIO(intcp_map_io)
 	INITIRQ(intcp_init_irq)
-	INITTIME(intcp_init_time)
+	.timer		= &cp_timer,
 	INIT_MACHINE(intcp_init)
 MACHINE_END
diff -Nru a/arch/arm/mach-iop3xx/Makefile b/arch/arm/mach-iop3xx/Makefile
--- a/arch/arm/mach-iop3xx/Makefile	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/mach-iop3xx/Makefile	2004-12-24 13:37:19 -08:00
@@ -10,7 +10,7 @@
 obj-n			:=
 obj-			:=
 
-obj-$(CONFIG_ARCH_IOP321)  += iop321-setup.o iop321-irq.o iop321-pci.o iop321-mm.o iop321-time.o
+obj-$(CONFIG_ARCH_IOP321)  += iop321-setup.o iop321-irq.o iop321-pci.o iop321-time.o
 
 obj-$(CONFIG_ARCH_IOP331)  += iop331-setup.o iop331-irq.o iop331-pci.o iop331-time.o
 
diff -Nru a/arch/arm/mach-iop3xx/Makefile.boot b/arch/arm/mach-iop3xx/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-iop3xx/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,9 @@
+   zreladdr-y	:= 0xa0008000
+params_phys-y	:= 0xa0000100
+initrd_phys-y	:= 0xa0800000
+ifeq ($(CONFIG_ARCH_IOP331),y)
+   zreladdr-y	:= 0x00008000
+params_phys-y	:= 0x00000100
+initrd_phys-y	:= 0x00800000
+endif
+
diff -Nru a/arch/arm/mach-iop3xx/arch.c b/arch/arm/mach-iop3xx/arch.c
--- a/arch/arm/mach-iop3xx/arch.c	2004-12-24 13:36:57 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,50 +0,0 @@
-/*
- * linux/arch/arm/mach-iop3xx/arch.c
- *
- * Author: Nicolas Pitre <nico@cam.org>
- * Copyright (C) 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 version 2 as
- * published by the Free Software Foundation.
- *
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/major.h>
-#include <linux/fs.h>
-
-#include <asm/setup.h>
-#include <asm/system.h>
-#include <asm/memory.h>
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-
-#ifdef CONFIG_ARCH_IQ80331
-extern void iq80331_map_io(void);
-extern void iop331_init_irq(void);
-extern void iop331_init_time(void);
-#endif
-
-#ifdef CONFIG_ARCH_IQ80331
-static void __init
-fixup_iop331(struct machine_desc *desc, struct tag *tags,
-	      char **cmdline, struct meminfo *mi)
-{
-}
-#endif
-
-#if defined(CONFIG_ARCH_IQ80331)
-MACHINE_START(IQ80331, "Intel IQ80331")
-	MAINTAINER("Intel Corp.")
-	BOOT_MEM(PHYS_OFFSET, 0xfff01000, 0xfffff000) // virtual, physical
-//	BOOT_MEM(PHYS_OFFSET, IQ80331_UART0_VIRT, IQ80331_UART0_PHYS)
-	MAPIO(iq80331_map_io)
-	INITIRQ(iop331_init_irq)
-	INITTIME(iop331_init_time)
-	BOOT_PARAMS(0x0100)
-MACHINE_END
-#else
-#error No machine descriptor defined for this IOP3xx implementation
-#endif
diff -Nru a/arch/arm/mach-iop3xx/common.c b/arch/arm/mach-iop3xx/common.c
--- a/arch/arm/mach-iop3xx/common.c	2004-12-24 13:36:30 -08:00
+++ b/arch/arm/mach-iop3xx/common.c	2004-12-24 13:36:30 -08:00
@@ -28,7 +28,6 @@
  * Default power-off for EP80219
  */
 #include <asm/mach-types.h>
-#include <asm/hardware.h>
 
 static inline void ep80219_send_to_pic(__u8 c) {
 }
diff -Nru a/arch/arm/mach-iop3xx/iop321-mm.c b/arch/arm/mach-iop3xx/iop321-mm.c
--- a/arch/arm/mach-iop3xx/iop321-mm.c	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,43 +0,0 @@
-/*
- * linux/arch/arm/mach-iop3xx/mm.c
- *
- * Low level memory initialization for IOP321 based systems
- *
- * Author: Rory Bolt <rorybolt@pacbell.net>
- * Copyright (C) 2002 Rory Bolt
- *
- * 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/mm.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-#include <asm/mach/map.h>
-#include <asm/mach-types.h>
-
-
-/*
- * Standard IO mapping for all IOP321 based systems
- */
-static struct map_desc iop321_std_desc[] __initdata = {
- /* virtual     physical      length      type */
-
- /* mem mapped registers */
- { IOP321_VIRT_MEM_BASE,  IOP321_PHY_MEM_BASE,   0x00002000,  MT_DEVICE },
-
- /* PCI IO space */
- { 0xfe000000,  0x90000000,   0x00020000,  MT_DEVICE }
-};
-
-void __init iop321_map_io(void)
-{
-	iotable_init(iop321_std_desc, ARRAY_SIZE(iop321_std_desc));
-}
diff -Nru a/arch/arm/mach-iop3xx/iop321-setup.c b/arch/arm/mach-iop3xx/iop321-setup.c
--- a/arch/arm/mach-iop3xx/iop321-setup.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-iop3xx/iop321-setup.c	2004-12-24 13:36:55 -08:00
@@ -9,11 +9,21 @@
  * published by the Free Software Foundation.
  *
  */
+#include <linux/mm.h>
+#include <linux/init.h>
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/major.h>
 #include <linux/fs.h>
+#include <linux/device.h>
+#include <linux/serial.h>
+#include <linux/tty.h>
+#include <linux/serial_core.h>
 
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/page.h>
+#include <asm/mach/map.h>
 #include <asm/setup.h>
 #include <asm/system.h>
 #include <asm/memory.h>
@@ -21,41 +31,80 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+#define IOP321_UART_XTAL 1843200
+
+/*
+ * Standard IO mapping for all IOP321 based systems
+ */
+static struct map_desc iop321_std_desc[] __initdata = {
+ /* virtual     physical      length      type */
+
+ /* mem mapped registers */
+ { IOP321_VIRT_MEM_BASE,  IOP321_PHY_MEM_BASE,   0x00002000,  MT_DEVICE },
+
+ /* PCI IO space */
+ { 0xfe000000,  0x90000000,   0x00020000,  MT_DEVICE }
+};
+
+#ifdef CONFIG_ARCH_IQ80321
+#define UARTBASE IQ80321_UART
+#define IRQ_UART IRQ_IQ80321_UART
+#endif
+
+#ifdef CONFIG_ARCH_IQ31244
+#define UARTBASE IQ31244_UART
+#define IRQ_UART IRQ_IQ31244_UART
+#endif
+
+static struct uart_port iop321_serial_ports[] = {
+	{
+		.membase	= (char*)(UARTBASE),
+		.mapbase	= (UARTBASE),
+		.irq		= IRQ_UART,
+		.flags		= UPF_SKIP_TEST,
+		.iotype		= UPIO_MEM,
+		.regshift	= 0,
+		.uartclk	= IOP321_UART_XTAL,
+		.line		= 0,
+		.type		= PORT_16550A,
+		.fifosize	= 16
+	}
+};
+
+void __init iop321_map_io(void)
+{
+	iotable_init(iop321_std_desc, ARRAY_SIZE(iop321_std_desc));
+	early_serial_setup(&iop321_serial_ports[0]);
+}
+
 #ifdef CONFIG_ARCH_IQ80321
 extern void iq80321_map_io(void);
-extern void iop321_init_irq(void);
+extern struct sys_timer iop321_timer;
 extern void iop321_init_time(void);
 #endif
 
 #ifdef CONFIG_ARCH_IQ31244
 extern void iq31244_map_io(void);
-extern void iop321_init_irq(void);
+extern struct sys_timer iop321_timer;
 extern void iop321_init_time(void);
 #endif
 
-static void __init
-fixup_iop321(struct machine_desc *desc, struct tag *tags,
-	      char **cmdline, struct meminfo *mi)
-{
-}
-
 #if defined(CONFIG_ARCH_IQ80321)
 MACHINE_START(IQ80321, "Intel IQ80321")
 	MAINTAINER("Intel Corporation")
-	BOOT_MEM(PHYS_OFFSET, IQ80321_UART, 0xfe800000)
-	FIXUP(fixup_iop321)
+	BOOT_MEM(PHYS_OFFSET, IQ80321_UART, IQ80321_UART)
 	MAPIO(iq80321_map_io)
 	INITIRQ(iop321_init_irq)
-	INITTIME(iop321_init_time)
+	.timer		= &iop321_timer,
     BOOT_PARAMS(0xa0000100)
 MACHINE_END
 #elif defined(CONFIG_ARCH_IQ31244)
-    MACHINE_START(IQ31244, "Intel IQ31244")
+MACHINE_START(IQ31244, "Intel IQ31244")
     MAINTAINER("Intel Corp.")
     BOOT_MEM(PHYS_OFFSET, IQ31244_UART, IQ31244_UART)
     MAPIO(iq31244_map_io)
     INITIRQ(iop321_init_irq)
-	INITTIME(iop321_init_time)
+	.timer		= &iop321_timer,
     BOOT_PARAMS(0xa0000100)
 MACHINE_END
 #else
diff -Nru a/arch/arm/mach-iop3xx/iop321-time.c b/arch/arm/mach-iop3xx/iop321-time.c
--- a/arch/arm/mach-iop3xx/iop321-time.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/mach-iop3xx/iop321-time.c	2004-12-24 13:37:19 -08:00
@@ -29,11 +29,9 @@
 
 #define IOP321_TIME_SYNC 0
 
-static unsigned long iop321_latch;
-
 static inline unsigned long get_elapsed(void)
 {
-	return iop321_latch - *IOP321_TU_TCR0;
+	return LATCH - *IOP321_TU_TCR0;
 }
 
 static unsigned long iop321_gettimeoffset(void)
@@ -55,14 +53,14 @@
 	asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr2));
 
 	if(tisr1 & 1)
-		elapsed += iop321_latch;
+		elapsed += LATCH;
 	else if (tisr2 & 1)
-		elapsed = iop321_latch + get_elapsed();
+		elapsed = LATCH + get_elapsed();
 
 	/*
 	 * Now convert them to usec.
 	 */
-	usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / iop321_latch;
+	usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / LATCH;
 
 	return usec;
 }
@@ -71,35 +69,16 @@
 iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	u32 tisr;
-#ifdef IOP321_TIME_SYNC
-	u32 passed;
-#define TM_THRESH (iop321_latch*2)
-#endif
 
-	asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr));
+	write_seqlock(&xtime_lock);
 
+	asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr));
 	tisr |= 1;
-
 	asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr));
 
-#ifdef IOP321_TIME_SYNC
-	passed = 0xffffffff - *IOP321_TU_TCR1;
+	timer_tick(regs);
 
-	do
-	{
-		do_timer(regs);
-		if(passed < TM_THRESH)
-			break;
-		if(passed > iop321_latch)
-			passed -= iop321_latch;
-		else
-			passed = 0;
-	} while(1);
-
-	asm volatile("mcr p6, 0, %0, c3, c1, 0" : : "r" (0xffffffff));
-#else
-	do_timer(regs);
-#endif
+	write_sequnlock(&xtime_lock);
 
 	return IRQ_HANDLED;
 }
@@ -110,32 +89,21 @@
 	.flags		= SA_INTERRUPT
 };
 
-extern int setup_arm_irq(int, struct irqaction*);
-
-void __init iop321_init_time(void)
+static void __init iop321_timer_init(void)
 {
 	u32 timer_ctl;
 
-	iop321_latch = (CLOCK_TICK_RATE + HZ / 2) / HZ;
-	gettimeoffset = iop321_gettimeoffset;
 	setup_irq(IRQ_IOP321_TIMER0, &iop321_timer_irq);
 
 	timer_ctl = IOP321_TMR_EN | IOP321_TMR_PRIVILEGED | IOP321_TMR_RELOAD |
 			IOP321_TMR_RATIO_1_1;
 
-	asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (iop321_latch));
+	asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (LATCH));
 
 	asm volatile("mcr p6, 0, %0, c0, c1, 0"	: : "r" (timer_ctl));
-
-#ifdef IOP321_TIME_SYNC
-        /* Setup second timer */
-        /* setup counter */
-        timer_ctl = IOP321_TMR_EN | IOP321_TMR_PRIVILEGED |
-                        IOP321_TMR_RATIO_1_1;
-        asm volatile("mcr p6, 0, %0, c3, c1, 0" : : "r" (0xffffffff));
-        /* setup control */
-        asm volatile("mcr p6, 0, %0, c1, c1, 0" : : "r" (timer_ctl));
-#endif
 }
 
-
+struct sys_timer iop321_timer = {
+	.init		= &iop321_timer_init,
+	.offset		= iop321_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-iop3xx/iop331-mm.c b/arch/arm/mach-iop3xx/iop331-mm.c
--- a/arch/arm/mach-iop3xx/iop331-mm.c	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,43 +0,0 @@
-/*
- * linux/arch/arm/mach-iop3xx/mm.c
- *
- * Low level memory initialization for IOP331 based systems
- *
- * Author: Dave Jiang <dave.jiang@intel.com>
- * Copyright (C) 2003 Intel Corp.
- *
- * 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/mm.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-#include <asm/mach/map.h>
-#include <asm/mach-types.h>
-
-
-/*
- * Standard IO mapping for all IOP331 based systems
- */
-static struct map_desc iop331_std_desc[] __initdata = {
- /* virtual     physical      length      type */
-
- /* mem mapped registers */
- { IOP331_VIRT_MEM_BASE,  IOP331_PHYS_MEM_BASE,   0x00002000,  MT_DEVICE },
-
- /* PCI IO space */
- { 0xfe000000,  0x90000000,   0x00020000,  MT_DEVICE }
-};
-
-void __init iop331_map_io(void)
-{
-	iotable_init(iop331_std_desc, ARRAY_SIZE(iop331_std_desc));
-}
diff -Nru a/arch/arm/mach-iop3xx/iop331-setup.c b/arch/arm/mach-iop3xx/iop331-setup.c
--- a/arch/arm/mach-iop3xx/iop331-setup.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/mach-iop3xx/iop331-setup.c	2004-12-24 13:37:19 -08:00
@@ -12,7 +12,6 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/config.h>
-#include <linux/init.h>
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/device.h>
@@ -81,7 +80,7 @@
 
 #ifdef CONFIG_ARCH_IQ80331
 extern void iop331_init_irq(void);
-extern void iop331_init_time(void);
+extern struct sys_timer iop331_timer;
 extern void iq80331_map_io(void);
 #endif
 
@@ -92,7 +91,7 @@
     //BOOT_MEM(PHYS_OFFSET, IQ80331_UART0_VIRT, IQ80331_UART0_PHYS)
     MAPIO(iq80331_map_io)
     INITIRQ(iop331_init_irq)
-    INITTIME(iop331_init_time)
+    .timer		= &iop331_timer,
     BOOT_PARAMS(0x0100)
 MACHINE_END
 #else
diff -Nru a/arch/arm/mach-iop3xx/iop331-time.c b/arch/arm/mach-iop3xx/iop331-time.c
--- a/arch/arm/mach-iop3xx/iop331-time.c	2004-12-24 13:37:43 -08:00
+++ b/arch/arm/mach-iop3xx/iop331-time.c	2004-12-24 13:37:43 -08:00
@@ -27,13 +27,9 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 
-#undef IOP331_TIME_SYNC
-
-static unsigned long iop331_latch;
-
 static inline unsigned long get_elapsed(void)
 {
-	return iop331_latch - *IOP331_TU_TCR0;
+	return LATCH - *IOP331_TU_TCR0;
 }
 
 static unsigned long iop331_gettimeoffset(void)
@@ -55,14 +51,14 @@
 	asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr2));
 
 	if(tisr1 & 1)
-		elapsed += iop331_latch;
+		elapsed += LATCH;
 	else if (tisr2 & 1)
-		elapsed = iop331_latch + get_elapsed();
+		elapsed = LATCH + get_elapsed();
 
 	/*
 	 * Now convert them to usec.
 	 */
-	usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / iop331_latch;
+	usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / LATCH;
 
 	return usec;
 }
@@ -71,36 +67,16 @@
 iop331_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	u32 tisr;
-#ifdef IOP331_TIME_SYNC
-	u32 passed;
-#define TM_THRESH (iop331_latch*2)
-#endif
 
-	asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr));
+	write_seqlock(&xtime_lock);
 
+	asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr));
 	tisr |= 1;
-
 	asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr));
 
-#ifdef IOP331_TIME_SYNC
-	passed = 0xffffffff - *IOP331_TU_TCR1;
-
-	do
-	{
-		do_timer(regs);
-		if(passed < TM_THRESH)
-			break;
-		if(passed > iop331_latch)
-			passed -= iop331_latch;
-		else
-			passed = 0;
-	} while(1);
-
-	asm volatile("mcr p6, 0, %0, c3, c1, 0" : : "r" (0xffffffff));
-#else
-	do_timer(regs);
-#endif
+	timer_tick(regs);
 
+	write_sequnlock(&xtime_lock);
 	return IRQ_HANDLED;
 }
 
@@ -110,32 +86,22 @@
 	.flags		= SA_INTERRUPT
 };
 
-extern int setup_arm_irq(int, struct irqaction*);
-
-void __init iop331_init_time(void)
+static void __init iop331_timer_init(void)
 {
 	u32 timer_ctl;
 
-	iop331_latch = (CLOCK_TICK_RATE + HZ / 2) / HZ;
-	gettimeoffset = iop331_gettimeoffset;
 	setup_irq(IRQ_IOP331_TIMER0, &iop331_timer_irq);
 
 	timer_ctl = IOP331_TMR_EN | IOP331_TMR_PRIVILEGED | IOP331_TMR_RELOAD |
 			IOP331_TMR_RATIO_1_1;
 
-	asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (iop331_latch));
+	asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (LATCH));
 
 	asm volatile("mcr p6, 0, %0, c0, c1, 0"	: : "r" (timer_ctl));
 
-#ifdef IOP331_TIME_SYNC
-        /* Setup second timer */
-        /* setup counter */
-        timer_ctl = IOP331_TMR_EN | IOP331_TMR_PRIVILEGED |
-                        IOP331_TMR_RATIO_1_1;
-        asm volatile("mcr p6, 0, %0, c3, c1, 0" : : "r" (0xffffffff));
-        /* setup control */
-        asm volatile("mcr p6, 0, %0, c1, c1, 0" : : "r" (timer_ctl));
-#endif
 }
 
-
+struct sys_timer iop331_timer = {
+	.init		= iop331_timer_init,
+	.offset		= iop331_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-iop3xx/mm-321.c b/arch/arm/mach-iop3xx/mm-321.c
--- a/arch/arm/mach-iop3xx/mm-321.c	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,63 +0,0 @@
-/*
- * linux/arch/arm/mach-iop3xx/mm.c
- *
- * Low level memory initialization for IOP321 based systems
- *
- * Author: Rory Bolt <rorybolt@pacbell.net>
- * Copyright (C) 2002 Rory Bolt
- *
- * 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/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-#include <asm/mach/map.h>
-
-
-/*
- * Standard IO mapping for all IOP321 based systems
- */
-static struct map_desc iop80321_std_desc[] __initdata = {
- /* virtual     physical      length      type */
-
- /* mem mapped registers */
- { IOP321_VIRT_MEM_BASE,  IOP321_PHY_MEM_BASE,   0x00002000,  MT_DEVICE },
-
- /* PCI IO space */
- { 0xfe000000,  0x90000000,   0x00020000,  MT_DEVICE }
-};
-
-void __init iop321_map_io(void)
-{
-	iotable_init(iop80321_std_desc, ARRAY_SIZE(iop80321_std_desc));
-}
-
-/*
- * IQ80321 specific IO mappings
- *
- * We use RedBoot's setup for the onboard devices.
- */
-#ifdef CONFIG_ARCH_IQ80321
-static struct map_desc iq80321_io_desc[] __initdata = {
- /* virtual     physical      length        type */
-
- /* on-board devices */
- { 0xfe800000,  IQ80321_UART1,   0x00100000,   MT_DEVICE }
-};
-
-void __init iq80321_map_io(void)
-{
-	iop321_map_io();
-
-	iotable_init(iq80321_io_desc, ARRAY_SIZE(iq80321_io_desc));
-}
-#endif // CONFIG_ARCH_IQ80321
diff -Nru a/arch/arm/mach-ixp2000/Makefile.boot b/arch/arm/mach-ixp2000/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-ixp2000/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,3 @@
+   zreladdr-y	:= 0x00008000
+params_phys-y	:= 0x00000100
+
diff -Nru a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
--- a/arch/arm/mach-ixp2000/core.c	2004-12-24 13:37:29 -08:00
+++ b/arch/arm/mach-ixp2000/core.c	2004-12-24 13:37:29 -08:00
@@ -9,7 +9,7 @@
  *
  * Based on work Copyright (C) 2002-2003 Intel Corporation
  * 
- * This file is licensed under  the terms of the GNU General Public 
+ * This file is licensed under the terms of the GNU General Public
  * License version 2. This program is licensed "as is" without any 
  * warranty of any kind, whether express or implied.
  */
@@ -33,10 +33,8 @@
 #include <asm/mach-types.h>
 #include <asm/irq.h>
 #include <asm/system.h>
-#include <asm/hardware.h>
 #include <asm/tlbflush.h>
 #include <asm/pgtable.h>
-#include <asm/mach-types.h>
 
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
@@ -170,7 +168,7 @@
 static unsigned ticks_per_jiffy;
 static unsigned ticks_per_usec;
 
-static unsigned long ixp2000_gettimeoffset (void)
+unsigned long ixp2000_gettimeoffset (void)
 {
 	unsigned long elapsed;
 
@@ -182,11 +180,15 @@
 
 static int ixp2000_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
+
 	/* clear timer 1 */
 	ixp2000_reg_write(IXP2000_T1_CLR, 1);
 	
 	timer_tick(regs);
 
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -198,8 +200,6 @@
 
 void __init ixp2000_init_time(unsigned long tick_rate)
 {
-	gettimeoffset = ixp2000_gettimeoffset;
-
 	ixp2000_reg_write(IXP2000_T1_CLR, 0);
 	ixp2000_reg_write(IXP2000_T2_CLR, 0);
 
@@ -309,41 +309,6 @@
 	.unmask	= ixp2000_pci_irq_unmask
 };
 
-/*
- * Error interrupts. These are used extensively by the microengine drivers
- */
-static void ixp2000_err_irq_handler(unsigned int irq, struct irqdesc *desc,  struct pt_regs *regs)
-{
-	int i;
-	unsigned long status = *IXP2000_IRQ_ERR_STATUS;
-
-
-	for (i = 0; i <= 12; i++) {
-		if (status & (1 << i)) {
-			desc = irq_desc + IRQ_IXP2000_DRAM0_MIN_ERR + i;
-			desc->handle(IRQ_IXP2000_DRAM0_MIN_ERR + i, desc, regs);
-		}
-	}
-}
-
-static void ixp2000_err_irq_mask(unsigned int irq)
-{
-	ixp2000_reg_write(IXP2000_IRQ_ERR_ENABLE_CLR,
-			(1 << (irq - IRQ_IXP2000_DRAM0_MIN_ERR)));
-}
-
-static void ixp2000_err_irq_unmask(unsigned int irq)
-{
-	ixp2000_reg_write(IXP2000_IRQ_ERR_ENABLE_SET,
-			(1 << (irq - IRQ_IXP2000_DRAM0_MIN_ERR)));
-}
-
-static struct irqchip ixp2000_err_irq_chip = {
-	.ack	= ixp2000_err_irq_mask,
-	.mask	= ixp2000_err_irq_mask,
-	.unmask	= ixp2000_err_irq_unmask
-};
-
 static void ixp2000_irq_mask(unsigned int irq)
 {
 	ixp2000_reg_write(IXP2000_IRQ_ENABLE_CLR, (1 << irq));
@@ -387,7 +352,7 @@
 	 * we mark the reserved IRQs as invalid. This makes
 	 * our mask/unmask code much simpler.
 	 */
-	for (irq = IRQ_IXP2000_SWI; irq <= IRQ_IXP2000_THDB3; irq++) {
+	for (irq = IRQ_IXP2000_SOFT_INT; irq <= IRQ_IXP2000_THDB3; irq++) {
 		if((1 << irq) & IXP2000_VALID_IRQ_MASK) {
 			set_irq_chip(irq, &ixp2000_irq_chip);
 			set_irq_handler(irq, do_level_IRQ);
@@ -409,18 +374,11 @@
 	/*
 	 * Enable PCI irq
 	 */
-	*(IXP2000_IRQ_ENABLE_SET) = (1 << IRQ_IXP2000_PCI);
+	ixp2000_reg_write(IXP2000_IRQ_ENABLE_SET, (1 << IRQ_IXP2000_PCI));
 	for (irq = IRQ_IXP2000_PCIA; irq <= IRQ_IXP2000_PCIB; irq++) {
 		set_irq_chip(irq, &ixp2000_pci_irq_chip);
 		set_irq_handler(irq, do_level_IRQ);
 		set_irq_flags(irq, IRQF_VALID);
 	}
-
-	for (irq = IRQ_IXP2000_DRAM0_MIN_ERR; irq <= IRQ_IXP2000_SP_INT; irq++) {
-		set_irq_chip(irq, &ixp2000_err_irq_chip);
-		set_irq_handler(irq, do_level_IRQ);
-		set_irq_flags(irq, IRQF_VALID);
-	}       
-	set_irq_chained_handler(IRQ_IXP2000_ERRSUM, ixp2000_err_irq_handler);
 }
 
diff -Nru a/arch/arm/mach-ixp2000/enp2611.c b/arch/arm/mach-ixp2000/enp2611.c
--- a/arch/arm/mach-ixp2000/enp2611.c	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/mach-ixp2000/enp2611.c	2004-12-24 13:36:47 -08:00
@@ -26,9 +26,6 @@
 #include <linux/interrupt.h>
 #include <linux/bitops.h>
 #include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/mm.h>
-#include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
@@ -55,11 +52,16 @@
 /*************************************************************************
  * ENP-2611 timer tick configuration
  *************************************************************************/
-static void __init enp2611_init_time(void)
+static void __init enp2611_timer_init(void)
 {
 	ixp2000_init_time(50 * 1000 * 1000);
 }
 
+static struct enp2611_timer = {
+	.init		= enp2611_timer_init,
+	.offset		= ixp2000_gettimeoffset,
+};
+
 
 /*************************************************************************
  * ENP-2611 PCI
@@ -202,7 +204,7 @@
 	BOOT_PARAMS(0x00000100)
 	MAPIO(ixp2000_map_io)
 	INITIRQ(ixp2000_init_irq)
-	INITTIME(enp2611_init_time)
+	.timer		= &enp2611_timer,
 	INIT_MACHINE(enp2611_init_machine)
 MACHINE_END
 #endif
diff -Nru a/arch/arm/mach-ixp2000/ixdp2400.c b/arch/arm/mach-ixp2000/ixdp2400.c
--- a/arch/arm/mach-ixp2000/ixdp2400.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-ixp2000/ixdp2400.c	2004-12-24 13:36:48 -08:00
@@ -23,9 +23,6 @@
 #include <linux/device.h>
 #include <linux/bitops.h>
 #include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/mm.h>
-#include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
@@ -48,7 +45,7 @@
 /*************************************************************************
  * IXDP2400 timer tick
  *************************************************************************/
-static void __init ixdp2400_init_time(void)
+static void __init ixdp2400_timer_init(void)
 {
 	int numerator, denominator;
 	int denom_array[] = {2, 4, 8, 16, 1, 2, 4, 8};
@@ -59,6 +56,11 @@
 	ixp2000_init_time(((3125000 * numerator) / (denominator)) / 2);
 }
 
+static struct timer ixdp2400_timer = {
+	.init		= ixdp2400_timer_init,
+	.offset		= ixp2000_gettimeoffset,
+};
+
 /*************************************************************************
  * IXDP2400 PCI
  *************************************************************************/
@@ -171,7 +173,7 @@
 	BOOT_PARAMS(0x00000100)
 	MAPIO(ixdp2x00_map_io)
 	INITIRQ(ixdp2400_init_irq)
-	INITTIME(ixdp2400_init_time)
+	.timer		= &ixdp2400_timer,
 	INIT_MACHINE(ixdp2x00_init_machine)
 MACHINE_END
 
diff -Nru a/arch/arm/mach-ixp2000/ixdp2800.c b/arch/arm/mach-ixp2000/ixdp2800.c
--- a/arch/arm/mach-ixp2000/ixdp2800.c	2004-12-24 13:37:00 -08:00
+++ b/arch/arm/mach-ixp2000/ixdp2800.c	2004-12-24 13:37:00 -08:00
@@ -23,9 +23,6 @@
 #include <linux/device.h>
 #include <linux/bitops.h>
 #include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/mm.h>
-#include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
@@ -55,11 +52,16 @@
  * IXDP2800 timer tick
  *************************************************************************/
 
-static void __init ixdp2800_init_time(void)
+static void __init ixdp2800_timer_init(void)
 {
 	ixp2000_init_time(50000000);
 }
 
+static struct sys_timer ixdp2800_timer = {
+	.init		= ixdp2800_timer_init,
+	.offset		= ixp2000_gettimeoffset,
+};
+
 /*************************************************************************
  * IXDP2800 PCI
  *************************************************************************/
@@ -172,7 +174,7 @@
 	BOOT_PARAMS(0x00000100)
 	MAPIO(ixdp2x00_map_io)
 	INITIRQ(ixdp2800_init_irq)
-	INITTIME(ixdp2800_init_time)
+	.timer		= &ixdp2800_timer,
 	INIT_MACHINE(ixdp2x00_init_machine)
 MACHINE_END
 
diff -Nru a/arch/arm/mach-ixp2000/ixdp2x00.c b/arch/arm/mach-ixp2000/ixdp2x00.c
--- a/arch/arm/mach-ixp2000/ixdp2x00.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-ixp2000/ixdp2x00.c	2004-12-24 13:36:17 -08:00
@@ -23,9 +23,6 @@
 #include <linux/device.h>
 #include <linux/bitops.h>
 #include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/mm.h>
-#include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
@@ -197,7 +194,7 @@
  * Linux is a common design in telecom systems. The problem is that instead 
  * of all the devices being controlled by a single host, different
  * devices are controlles by different NPUs on the same bus, leading to
- * multiple hosts on the bus.i The exact bus layout looks like:
+ * multiple hosts on the bus. The exact bus layout looks like:
  *
  *                   Bus 0
  *    Master NPU <-------------------+-------------------> Slave NPU
@@ -213,9 +210,9 @@
  *             ... Dev    PMC       Media     Eth0   Eth1 ...
  *
  * The master controlls all but Eth1, which is controlled by the
- * slave. What this measn is that the both the master and the slave
+ * slave. What this means is that the both the master and the slave
  * have to scan the bus, but only one of them can enumerate the bus.
- * In addition, after the bus is scaned, each kernel must remove
+ * In addition, after the bus is scanned, each kernel must remove
  * the device(s) it does not control from the PCI dev list otherwise
  * a driver on each NPU will try to manage it and we will have horrible
  * conflicts. Oh..and the slave NPU needs to see the master NPU
diff -Nru a/arch/arm/mach-ixp2000/ixdp2x01.c b/arch/arm/mach-ixp2000/ixdp2x01.c
--- a/arch/arm/mach-ixp2000/ixdp2x01.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-ixp2000/ixdp2x01.c	2004-12-24 13:36:17 -08:00
@@ -23,9 +23,6 @@
 #include <linux/interrupt.h>
 #include <linux/bitops.h>
 #include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/mm.h>
-#include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
@@ -54,12 +51,14 @@
  *************************************************************************/
 static void ixdp2x01_irq_mask(unsigned int irq)
 {
-	*IXDP2X01_INT_MASK_SET_REG = IXP2000_BOARD_IRQ_MASK(irq);
+	ixp2000_reg_write(IXDP2X01_INT_MASK_SET_REG,
+				IXP2000_BOARD_IRQ_MASK(irq));
 }
 
 static void ixdp2x01_irq_unmask(unsigned int irq)
 {
-	*IXDP2X01_INT_MASK_CLR_REG = IXP2000_BOARD_IRQ_MASK(irq);
+	ixp2000_reg_write(IXDP2X01_INT_MASK_CLR_REG,
+				IXP2000_BOARD_IRQ_MASK(irq));
 }
 
 static u32 valid_irq_mask;
@@ -114,8 +113,8 @@
 		valid_irq_mask = IXDP2801_VALID_IRQ_MASK;
 
 	/* Mask all interrupts from CPLD, disable simulation */
-	*IXDP2X01_INT_MASK_SET_REG = 0xffffffff;
-	*IXDP2X01_INT_SIM_REG = 0;
+	ixp2000_reg_write(IXDP2X01_INT_MASK_SET_REG, 0xffffffff);
+	ixp2000_reg_write(IXDP2X01_INT_SIM_REG, 0);
 
 	for (irq = NR_IXP2000_IRQS; irq < NR_IXDP2X01_IRQS; irq++) {
 		if (irq & valid_irq_mask) {
@@ -193,7 +192,7 @@
 
 __setup("ixdp2x01_clock=", ixdp2x01_clock_setup);
 
-static void __init ixdp2x01_init_time(void)
+static void __init ixdp2x01_timer_init(void)
 {
 	if (!ixdp2x01_clock)
 		ixdp2x01_clock = 50000000;
@@ -201,6 +200,11 @@
 	ixp2000_init_time(ixdp2x01_clock);
 }
 
+static struct sys_timer ixdp2x01_timer = {
+	.init		= ixdp2x01_timer_init,
+	.offset		= ixp2000_gettimeoffset,
+};
+
 /*************************************************************************
  * IXDP2x01 PCI
  *************************************************************************/
@@ -312,8 +316,8 @@
 
 static unsigned long ixdp2x01_flash_bank_setup(unsigned long ofs)
 {
-	*IXDP2X01_CPLD_FLASH_REG = 
-		((ofs >> IXDP2X01_FLASH_WINDOW_BITS) | IXDP2X01_CPLD_FLASH_INTERN);
+	ixp2000_reg_write(IXDP2X01_CPLD_FLASH_REG,
+		((ofs >> IXDP2X01_FLASH_WINDOW_BITS) | IXDP2X01_CPLD_FLASH_INTERN));
 	return (ofs & IXDP2X01_FLASH_WINDOW_MASK);
 }
 
@@ -338,14 +342,29 @@
 	.resource	= &ixdp2x01_flash_resource,
 };
 
+static struct ixp2000_i2c_pins ixdp2x01_i2c_gpio_pins = {
+	.sda_pin	= IXDP2X01_GPIO_SDA,
+	.scl_pin	= IXDP2X01_GPIO_SCL,
+};
+
+static struct platform_device ixdp2x01_i2c_controller = {
+	.name		= "IXP2000-I2C",
+	.id		= 0,
+	.dev		= {
+		.platform_data = &ixdp2x01_i2c_gpio_pins,
+	},
+	.num_resources	= 0
+};
+
 static struct platform_device *ixdp2x01_devices[] __initdata = {
-	&ixdp2x01_flash
+	&ixdp2x01_flash,
+	&ixdp2x01_i2c_controller
 };
 
 static void __init ixdp2x01_init_machine(void)
 {
-	*IXDP2X01_CPLD_FLASH_REG = 
-		(IXDP2X01_CPLD_FLASH_BANK_MASK | IXDP2X01_CPLD_FLASH_INTERN);
+	ixp2000_reg_write(IXDP2X01_CPLD_FLASH_REG,
+		(IXDP2X01_CPLD_FLASH_BANK_MASK | IXDP2X01_CPLD_FLASH_INTERN));
 	
 	ixdp2x01_flash_data.nr_banks =
 		((*IXDP2X01_CPLD_FLASH_REG & IXDP2X01_CPLD_FLASH_BANK_MASK) + 1);
@@ -361,7 +380,7 @@
 	BOOT_PARAMS(0x00000100)
 	MAPIO(ixdp2x01_map_io)
 	INITIRQ(ixdp2x01_init_irq)
-	INITTIME(ixdp2x01_init_time)
+	.timer		= &ixdp2x01_timer,
 	INIT_MACHINE(ixdp2x01_init_machine)
 MACHINE_END
 #endif
@@ -373,7 +392,7 @@
 	BOOT_PARAMS(0x00000100)
 	MAPIO(ixdp2x01_map_io)
 	INITIRQ(ixdp2x01_init_irq)
-	INITTIME(ixdp2x01_init_time)
+	.timer		= &ixdp2x01_timer,
 	INIT_MACHINE(ixdp2x01_init_machine)
 MACHINE_END
 #endif
diff -Nru a/arch/arm/mach-ixp2000/pci.c b/arch/arm/mach-ixp2000/pci.c
--- a/arch/arm/mach-ixp2000/pci.c	2004-12-24 13:36:59 -08:00
+++ b/arch/arm/mach-ixp2000/pci.c	2004-12-24 13:36:59 -08:00
@@ -148,13 +148,13 @@
 	cli();
 	temp = *(IXP2000_PCI_CONTROL);
 	if (temp & ((1 << 8) | (1 << 5))) {
-		*(IXP2000_PCI_CONTROL) = temp;
+		ixp2000_reg_write(IXP2000_PCI_CONTROL, temp);
 	}
 
 	temp = *(IXP2000_PCI_CMDSTAT);
 	if (temp & (1 << 29)) {
 		while (temp & (1 << 29)) {	
-			*(IXP2000_PCI_CMDSTAT) = temp;
+			ixp2000_reg_write(IXP2000_PCI_CMDSTAT, temp);
 			temp = *(IXP2000_PCI_CMDSTAT);
 		}
 	}
@@ -178,13 +178,13 @@
 	cli();
 	temp = *(IXP2000_PCI_CONTROL);
 	if (temp & ((1 << 8) | (1 << 5))) {	
-		*(IXP2000_PCI_CONTROL) = temp;
+		ixp2000_reg_write(IXP2000_PCI_CONTROL, temp);
 	}
 
 	temp = *(IXP2000_PCI_CMDSTAT);
 	if (temp & (1 << 29)) {
 		while (temp & (1 << 29)) {
-			*(IXP2000_PCI_CMDSTAT) = temp;
+			ixp2000_reg_write(IXP2000_PCI_CMDSTAT, temp);
 			temp = *(IXP2000_PCI_CMDSTAT);
 		}
 	}
diff -Nru a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig
--- a/arch/arm/mach-ixp4xx/Kconfig	2004-12-24 13:36:19 -08:00
+++ b/arch/arm/mach-ixp4xx/Kconfig	2004-12-24 13:36:19 -08:00
@@ -29,6 +29,13 @@
 	  IXDP425 Development Platform (Also known as Richfield).  
 	  For more information on this platform, see Documentation/arm/IXP4xx.
 
+config MACH_IXDPG425
+	bool "IXDPG425"
+	help
+	  Say 'Y' here if you want your kernel to support Intel's
+	  IXDPG425 Development Platform (Also known as Montajade).
+	  For more information on this platform, see Documentation/arm/IXP4xx.
+
 #
 # IXCDP1100 is the exact same HW as IXDP425, but with a different machine 
 # number from the bootloader due to marketing monkeys, so we just enable it 
diff -Nru a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile
--- a/arch/arm/mach-ixp4xx/Makefile	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-ixp4xx/Makefile	2004-12-24 13:36:18 -08:00
@@ -5,6 +5,7 @@
 obj-y	+= common.o common-pci.o 
 
 obj-$(CONFIG_ARCH_IXDP4XX)	+= ixdp425-pci.o ixdp425-setup.o
+obj-$(CONFIG_MACH_IXDPG425)	+= ixdpg425-pci.o coyote-setup.o
 obj-$(CONFIG_ARCH_ADI_COYOTE)	+= coyote-pci.o coyote-setup.o
 obj-$(CONFIG_ARCH_PRPMC1100)	+= prpmc1100-pci.o prpmc1100-setup.o
 
diff -Nru a/arch/arm/mach-ixp4xx/Makefile.boot b/arch/arm/mach-ixp4xx/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-ixp4xx/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,3 @@
+   zreladdr-y	:= 0x00008000
+params_phys-y	:= 0x00000100
+
diff -Nru a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
--- a/arch/arm/mach-ixp4xx/common-pci.c	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/mach-ixp4xx/common-pci.c	2004-12-24 13:37:18 -08:00
@@ -33,7 +33,6 @@
 #include <asm/system.h>
 #include <asm/mach/pci.h>
 #include <asm/hardware.h>
-#include <asm/sizes.h>
 
 
 /*
@@ -239,9 +238,10 @@
 	return 0xffffffff;
 }
 
-static int read_config(u8 bus_num, u16 devfn, int where, int size, u32 *value)
+static int ixp4xx_pci_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
 {
 	u32 n, byte_enables, addr, data;
+	u8 bus_num = bus->number;
 
 	pr_debug("read_config from %d size %d dev %d:%d:%d\n", where, size,
 		bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn));
@@ -261,9 +261,10 @@
 	return PCIBIOS_SUCCESSFUL;
 }
 
-static int write_config(u8 bus_num, u16 devfn, int where, int size, u32 value)
+static int ixp4xx_pci_write_config(struct pci_bus *bus,  unsigned int devfn, int where, int size, u32 value)
 {
 	u32 n, byte_enables, addr, data;
+	u8 bus_num = bus->number;
 
 	pr_debug("write_config_byte %#x to %d size %d dev %d:%d:%d\n", value, where,
 		size, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn));
@@ -281,30 +282,10 @@
 	return PCIBIOS_SUCCESSFUL;
 }
 
-/*
- *	Generalized PCI config access functions.
- */
-static int ixp4xx_read_config(struct pci_bus *bus, unsigned int devfn,
-	int where, int size, u32 *value)
-{
-	if (bus->number && !PCI_SLOT(devfn))
-		return local_read_config(where, size, value);
-	return read_config(bus->number, devfn, where, size, value);
-}
-
-static int ixp4xx_write_config(struct pci_bus *bus, unsigned int devfn,
-	int where, int size, u32 value)
-{
-	if (bus->number && !PCI_SLOT(devfn))
-		return local_write_config(where, size, value);
-	return write_config(bus->number, devfn, where, size, value);
-}
-
 struct pci_ops ixp4xx_ops = {
-	.read =  ixp4xx_read_config,
-	.write = ixp4xx_write_config,
+	.read =  ixp4xx_pci_read_config,
+	.write = ixp4xx_pci_write_config,
 };
-
 
 /*
  * PCI abort handler
diff -Nru a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
--- a/arch/arm/mach-ixp4xx/common.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-ixp4xx/common.c	2004-12-24 13:36:55 -08:00
@@ -221,16 +221,20 @@
 
 static irqreturn_t ixp4xx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
+
 	/* Clear Pending Interrupt by writing '1' to it */
 	*IXP4XX_OSST = IXP4XX_OSST_TIMER_1_PEND;
 
 	/*
 	 * Catch up with the real idea of time
 	 */
-	do {	
+	while ((*IXP4XX_OSTS - last_jiffy_time) > LATCH) {
 		timer_tick(regs);
 		last_jiffy_time += LATCH;
-	} while((*IXP4XX_OSTS - last_jiffy_time) > LATCH);
+	}
+
+	write_sequnlock(&xtime_lock);
 
 	return IRQ_HANDLED;
 }
@@ -241,10 +245,8 @@
 	.handler	= ixp4xx_timer_interrupt
 };
 
-void __init ixp4xx_init_time(void)
+static void __init ixp4xx_timer_init(void)
 {
-	gettimeoffset = ixp4xx_gettimeoffset;
-
 	/* Clear Pending Interrupt by writing '1' to it */
 	*IXP4XX_OSST = IXP4XX_OSST_TIMER_1_PEND;
 
@@ -259,4 +261,7 @@
 	setup_irq(IRQ_IXP4XX_TIMER1, &ixp4xx_timer_irq);
 }
 
-
+struct sys_timer ixp4xx_timer = {
+	.init		= ixp4xx_timer_init,
+	.offset		= ixp4xx_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-ixp4xx/coyote-setup.c b/arch/arm/mach-ixp4xx/coyote-setup.c
--- a/arch/arm/mach-ixp4xx/coyote-setup.c	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/mach-ixp4xx/coyote-setup.c	2004-12-24 13:36:31 -08:00
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-ixp4xx/coyote-setup.c
  *
- * ADI Engineering Coyote board-setup 
+ * Board setup for ADI Engineering and IXDGP425 boards
  *
  * Copyright (C) 2003-2004 MontaVista Software, Inc.
  *
@@ -30,7 +30,7 @@
 #endif
 
 /*
- * Only one serial port is connected on the Coyote.
+ * Only one serial port is connected on the Coyote & IXDPG425
  */
 static struct uart_port coyote_serial_port = {
 	.membase	= (char*)(IXP4XX_UART2_BASE_VIRT + REG_OFFSET),
@@ -47,6 +47,13 @@
 
 void __init coyote_map_io(void)
 {
+	if (machine_is_ixdpg425()) {
+		coyote_serial_port.membase =
+			(char*)(IXP4XX_UART1_BASE_VIRT + REG_OFFSET);
+		coyote_serial_port.mapbase = IXP4XX_UART1_BASE_PHYS;
+		coyote_serial_port.irq = IRQ_IXP4XX_UART1;
+	}
+
 	early_serial_setup(&coyote_serial_port);
 
 	ixp4xx_map_io();
@@ -79,17 +86,39 @@
 
 static void __init coyote_init(void)
 {
+	*IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
+	*IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
+
 	platform_add_devices(&coyote_devices, ARRAY_SIZE(coyote_devices));
 }
 
-MACHINE_START(ADI_COYOTE, "ADI Engineering IXP4XX Coyote Development Platform")
+#ifdef CONFIG_ARCH_ADI_COYOTE
+MACHINE_START(ADI_COYOTE, "ADI Engineering Coyote")
         MAINTAINER("MontaVista Software, Inc.")
         BOOT_MEM(PHYS_OFFSET, IXP4XX_PERIPHERAL_BASE_PHYS,
                 IXP4XX_PERIPHERAL_BASE_VIRT)
         MAPIO(coyote_map_io)
         INITIRQ(ixp4xx_init_irq)
-	INITTIME(ixp4xx_init_time)
+	.timer		= &ixp4xx_timer,
         BOOT_PARAMS(0x0100)
 	INIT_MACHINE(coyote_init)
 MACHINE_END
+#endif
+
+/*
+ * IXDPG425 is identical to Coyote except for which serial port
+ * is connected.
+ */
+#ifdef CONFIG_MACH_IXDPG425
+MACHINE_START(IXDPG425, "Intel IXDPG425")
+        MAINTAINER("MontaVista Software, Inc.")
+        BOOT_MEM(PHYS_OFFSET, IXP4XX_PERIPHERAL_BASE_PHYS,
+                IXP4XX_PERIPHERAL_BASE_VIRT)
+        MAPIO(coyote_map_io)
+        INITIRQ(ixp4xx_init_irq)
+	.timer		= &ixp4xx_timer,
+        BOOT_PARAMS(0x0100)
+	INIT_MACHINE(coyote_init)
+MACHINE_END
+#endif
 
diff -Nru a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c	2004-12-24 13:36:49 -08:00
@@ -117,7 +117,7 @@
 		IXP4XX_PERIPHERAL_BASE_VIRT)
 	MAPIO(ixdp425_map_io)
 	INITIRQ(ixp4xx_init_irq)
-	INITTIME(ixp4xx_init_time)
+	.timer		= &ixp4xx_timer,
 	BOOT_PARAMS(0x0100)
 	INIT_MACHINE(ixdp425_init)
 MACHINE_END
@@ -128,7 +128,7 @@
 		IXP4XX_PERIPHERAL_BASE_VIRT)
 	MAPIO(ixdp425_map_io)
 	INITIRQ(ixp4xx_init_irq)
-	INITTIME(ixp4xx_init_time)
+	.timer		= &ixp4xx_timer,
 	BOOT_PARAMS(0x0100)
 	INIT_MACHINE(ixdp425_init)
 MACHINE_END
@@ -146,7 +146,7 @@
 		IXP4XX_PERIPHERAL_BASE_VIRT)
 	MAPIO(ixdp425_map_io)
 	INITIRQ(ixp4xx_init_irq)
-	INITTIME(ixp4xx_init_time)
+	.timer		= &ixp4xx_timer,
 	BOOT_PARAMS(0x0100)
 	INIT_MACHINE(ixdp425_init)
 MACHINE_END
diff -Nru a/arch/arm/mach-ixp4xx/ixdpg425-pci.c b/arch/arm/mach-ixp4xx/ixdpg425-pci.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-ixp4xx/ixdpg425-pci.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,65 @@
+/*
+ * arch/arch/mach-ixp4xx/ixdpg425-pci.c
+ *
+ * PCI setup routines for Intel IXDPG425 Platform
+ *
+ * Copyright (C) 2004 MontaVista Softwrae, Inc.
+ *
+ * Maintainer: Deepak Saxena <dsaxena@plexity.net>
+ *
+ * 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/pci.h>
+#include <linux/init.h>
+
+#include <asm/mach-types.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+
+#include <asm/mach/pci.h>
+
+extern void ixp4xx_pci_preinit(void);
+extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
+extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
+
+void __init ixdpg425_pci_preinit(void)
+{
+	gpio_line_config(6, IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
+	gpio_line_config(7, IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
+
+	gpio_line_isr_clear(6);
+	gpio_line_isr_clear(7);
+
+	ixp4xx_pci_preinit();
+}
+
+static int __init ixdpg425_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+	if (slot == 12 || slot == 13)
+		return IRQ_IXP4XX_GPIO7;
+	else if (slot == 14)
+		return IRQ_IXP4XX_GPIO6;
+	else return -1;
+}
+
+struct hw_pci ixdpg425_pci __initdata = {
+	.nr_controllers = 1,
+	.preinit =        ixdpg425_pci_preinit,
+	.swizzle =        pci_std_swizzle,
+	.setup =          ixp4xx_setup,
+	.scan =           ixp4xx_scan_bus,
+	.map_irq =        ixdpg425_map_irq,
+};
+
+int __init ixdpg425_pci_init(void)
+{
+	if (machine_is_ixdpg425())
+		pci_common_init(&ixdpg425_pci);
+	return 0;
+}
+
+subsys_initcall(ixdpg425_pci_init);
diff -Nru a/arch/arm/mach-ixp4xx/prpmc1100-setup.c b/arch/arm/mach-ixp4xx/prpmc1100-setup.c
--- a/arch/arm/mach-ixp4xx/prpmc1100-setup.c	2004-12-24 13:36:30 -08:00
+++ b/arch/arm/mach-ixp4xx/prpmc1100-setup.c	2004-12-24 13:36:30 -08:00
@@ -88,7 +88,7 @@
                 IXP4XX_PERIPHERAL_BASE_VIRT)
         MAPIO(prpmc1100_map_io)
         INITIRQ(ixp4xx_init_irq)
-	INITTIME(ixp4xx_init_time)
+	.timer		= &ixp4xx_timer,
         BOOT_PARAMS(0x0100)
 	INIT_MACHINE(prpmc1100_init)
 MACHINE_END
diff -Nru a/arch/arm/mach-l7200/Makefile.boot b/arch/arm/mach-l7200/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-l7200/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2 @@
+   zreladdr-y	:= 0xf0008000
+
diff -Nru a/arch/arm/mach-lh7a40x/Makefile.boot b/arch/arm/mach-lh7a40x/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-lh7a40x/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,4 @@
+   zreladdr-y	:= 0xc0008000
+params_phys-y	:= 0xc0000100
+initrd_phys-y	:= 0xc4000000
+
diff -Nru a/arch/arm/mach-lh7a40x/arch-kev7a400.c b/arch/arm/mach-lh7a40x/arch-kev7a400.c
--- a/arch/arm/mach-lh7a40x/arch-kev7a400.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-lh7a40x/arch-kev7a400.c	2004-12-24 13:36:17 -08:00
@@ -11,21 +11,19 @@
 #include <linux/tty.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/interrupt.h>
 
 #include <asm/hardware.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
-#include <asm/hardware.h>	/* io_p2v() */
 #include <asm/irq.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 
-#include <linux/interrupt.h>
+#include "common.h"
 
       /* This function calls the board specific IRQ initialization function. */
-extern void lh7a400_init_irq (void);
-extern void lh7a40x_init_time (void);
 
 static struct map_desc kev7a400_io_desc[] __initdata = {
 	{ IO_VIRT,    IO_PHYS,    IO_SIZE,    MT_DEVICE },
@@ -109,5 +107,5 @@
 	BOOT_PARAMS (0xc0000100)
 	MAPIO (kev7a400_map_io)
 	INITIRQ (lh7a400_init_irq)
-	INITTIME (lh7a40x_init_time)
+	.timer		= &lh7a40x_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
--- a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c	2004-12-24 13:36:18 -08:00
@@ -11,17 +11,17 @@
 #include <linux/tty.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/interrupt.h>
 
 #include <asm/hardware.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
-#include <asm/hardware.h>	/* io_p2v() */
 #include <asm/irq.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 
-#include <linux/interrupt.h>
+#include "common.h"
 
 static struct resource smc91x_resources[] = {
 	[0] = {
@@ -261,16 +261,13 @@
 
 #ifdef CONFIG_MACH_LPD7A400
 
-extern void lh7a400_init_irq (void);
-extern void lh7a40x_init_time (void);
-
 MACHINE_START (LPD7A400, "Logic Product Development LPD7A400-10")
 	MAINTAINER ("Marc Singer")
 	BOOT_MEM (0xc0000000, 0x80000000, io_p2v (0x80000000))
 	BOOT_PARAMS (0xc0000100)
 	MAPIO (lpd7a400_map_io)
 	INITIRQ (lh7a400_init_irq)
-	INITTIME (lh7a40x_init_time)
+	.timer		= &lh7a40x_timer,
 	INIT_MACHINE (lpd7a40x_init)
 MACHINE_END
 
@@ -278,16 +275,13 @@
 
 #ifdef CONFIG_MACH_LPD7A404
 
-extern void lh7a404_init_irq (void);
-extern void lh7a40x_init_time (void);
-
 MACHINE_START (LPD7A404, "Logic Product Development LPD7A404-10")
 	MAINTAINER ("Marc Singer")
 	BOOT_MEM (0xc0000000, 0x80000000, io_p2v (0x80000000))
 	BOOT_PARAMS (0xc0000100)
 	MAPIO (lpd7a400_map_io)
 	INITIRQ (lh7a404_init_irq)
-	INITTIME (lh7a40x_init_time)
+	.timer		= &lh7a40x_timer,
 	INIT_MACHINE (lpd7a40x_init)
 MACHINE_END
 
diff -Nru a/arch/arm/mach-lh7a40x/common.h b/arch/arm/mach-lh7a40x/common.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-lh7a40x/common.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,14 @@
+/* arch/arm/mach-lh7a40x/common.h
+ *
+ *  Copyright (C) 2004 Marc Singer
+ *
+ *  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.
+ *
+ */
+
+extern struct sys_timer lh7a40x_timer;
+
+extern void lh7a400_init_irq (void);
+extern void lh7a404_init_irq (void);
diff -Nru a/arch/arm/mach-lh7a40x/time.c b/arch/arm/mach-lh7a40x/time.c
--- a/arch/arm/mach-lh7a40x/time.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-lh7a40x/time.c	2004-12-24 13:36:55 -08:00
@@ -20,6 +20,7 @@
 #include <asm/leds.h>
 
 #include <asm/mach/time.h>
+#include "common.h"
 
 #if HZ < 100
 # define TIMER_CONTROL	TIMER_CONTROL2
@@ -40,9 +41,13 @@
 static irqreturn_t
 lh7a40x_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
+
 	TIMER_EOI = 0;
 	timer_tick(regs);
 
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -52,7 +57,7 @@
 	.handler	= lh7a40x_timer_interrupt
 };
 
-void __init lh7a40x_init_time(void)
+static void __init lh7a40x_timer_init(void)
 {
 				/* Stop/disable all timers */
 	TIMER_CONTROL1 = 0;
@@ -65,3 +70,6 @@
 	TIMER_CONTROL = TIMER_MODE;
 }
 
+struct sys_timer lh7a40x_timer = {
+	.init		= &lh7a40x_timer_init,
+};
diff -Nru a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
--- a/arch/arm/mach-omap/Kconfig	2004-12-24 13:36:19 -08:00
+++ b/arch/arm/mach-omap/Kconfig	2004-12-24 13:36:19 -08:00
@@ -5,58 +5,56 @@
 comment "OMAP Core Type"
 
 config ARCH_OMAP730
+	depends on ARCH_OMAP
 	bool "OMAP730 Based System"
-	select CPU_ARM926T
+	select ARCH_OMAP_OTG
 
 config ARCH_OMAP1510
+	depends on ARCH_OMAP
 	default y
 	bool "OMAP1510 Based System"
-	select CPU_ARM925T
-	select CPU_DCACHE_WRITETHROUGH
 
-config ARCH_OMAP1610
-	bool "OMAP1610 Based System"
-	select CPU_ARM926T
-
-config ARCH_OMAP5912
-	bool "OMAP5912 Based System"
-	select CPU_ARM926T
+config ARCH_OMAP16XX
+	depends on ARCH_OMAP
+	bool "OMAP16XX Based System"
+	select ARCH_OMAP_OTG
+
+config ARCH_OMAP_OTG
+	bool
 
 comment "OMAP Board Type"
 
 config MACH_OMAP_INNOVATOR
 	bool "TI Innovator"
-	default y
-	depends on ARCH_OMAP1510 || ARCH_OMAP1610
+	depends on ARCH_OMAP1510 || ARCH_OMAP16XX
 	help
           TI OMAP 1510 or 1610 Innovator board support. Say Y here if you
           have such a board.
 
 config MACH_OMAP_H2
 	bool "TI H2 Support"
-	depends on ARCH_OMAP1610
-        select MACH_OMAP_INNOVATOR
+	depends on ARCH_OMAP16XX
     	help
-	  TI OMAP 1610 H2 board support. Say Y here if you have such
+	  TI OMAP 1610/1611B H2 board support. Say Y here if you have such
 	  a board.
 
 config MACH_OMAP_H3
 	bool "TI H3 Support"
-	depends on ARCH_OMAP1610
+	depends on ARCH_OMAP16XX
     	help
-	  TI OMAP 1610 H3 board support. Say Y here if you have such
+	  TI OMAP 1710 H3 board support. Say Y here if you have such
 	  a board.
 
 config MACH_OMAP_H4
 	bool "TI H4 Support"
-	depends on ARCH_OMAP1610
+	depends on ARCH_OMAP16XX
     	help
 	  TI OMAP 1610 H4 board support. Say Y here if you have such
 	  a board.
 
 config MACH_OMAP_OSK
 	bool "TI OSK Support"
-	depends on ARCH_OMAP5912
+	depends on ARCH_OMAP16XX
     	help
 	  TI OMAP 5912 OSK (OMAP Starter Kit) board support. Say Y here
           if you have such a board.
@@ -64,19 +62,16 @@
 config MACH_OMAP_PERSEUS2
 	bool "TI Perseus2"
 	depends on ARCH_OMAP730
-	select LEDS
-	select LEDS_TIMER
-	select LEDS_CPU
     	help
 	  Support for TI OMAP 730 Perseus2 board. Say Y here if you have such
 	  a board.
 
 config MACH_OMAP_GENERIC
 	bool "Generic OMAP board"
-	depends on ARCH_OMAP1510 || ARCH_OMAP1610
+	depends on ARCH_OMAP1510 || ARCH_OMAP16XX
 	help
-          Support for generic OMAP-1510 or 1610 board with no
-          FPGA. Can be used as template for porting Linux to
+          Support for generic OMAP-1510, 1610 or 1710 board with
+          no FPGA. Can be used as template for porting Linux to
           custom OMAP boards. Say Y here if you have a custom
           board.
 
@@ -84,6 +79,7 @@
 
 #config OMAP_BOOT_TAG
 #	bool "OMAP bootloader information passing"
+#        depends on ARCH_OMAP
 #        default n
 #        help
 #          Say Y, if you have a bootloader which passes information
@@ -91,6 +87,7 @@
 
 config OMAP_MUX
 	bool "OMAP multiplexing support"
+        depends on ARCH_OMAP
 	default y
         help
           Pin multiplexing support for OMAP boards. If your bootloader
@@ -106,8 +103,18 @@
           This is useful if you want to find out the correct values of the
           multiplexing registers.
 
+config OMAP_MUX_WARNINGS
+	bool "Warn about pins the bootloader didn't set up"
+        depends on OMAP_MUX
+        default y
+        help
+	  Choose Y here to warn whenever driver initialization logic needs
+	  to change the pin multiplexing setup.  When there are no warnings
+	  printed, it's safe to deselect OMAP_MUX for your product.
+
 choice
 	prompt "Low-level debug console UART"
+	depends on ARCH_OMAP
 	default OMAP_LL_DEBUG_UART1
 
 config OMAP_LL_DEBUG_UART1
@@ -129,7 +136,7 @@
 
 config OMAP_ARM_192MHZ
 	bool "OMAP ARM 192 MHz CPU"
-	depends on ARCH_OMAP1610 || ARCH_OMAP5912
+	depends on ARCH_OMAP16XX
 	help
           Enable 192MHz clock for OMAP CPU. If unsure, say N.
 
@@ -141,26 +148,26 @@
 
 config OMAP_ARM_168MHZ
 	bool "OMAP ARM 168 MHz CPU"
-	depends on ARCH_OMAP1510 || ARCH_OMAP1610 || ARCH_OMAP730 || ARCH_OMAP5912
+	depends on ARCH_OMAP1510 || ARCH_OMAP16XX || ARCH_OMAP730
 	help
           Enable 168MHz clock for OMAP CPU. If unsure, say N.
 
 config OMAP_ARM_120MHZ
 	bool "OMAP ARM 120 MHz CPU"
-	depends on ARCH_OMAP1510 || ARCH_OMAP1610 || ARCH_OMAP730
+	depends on ARCH_OMAP1510 || ARCH_OMAP16XX || ARCH_OMAP730
 	help
           Enable 120MHz clock for OMAP CPU. If unsure, say N.
 
 config OMAP_ARM_60MHZ
 	bool "OMAP ARM 60 MHz CPU"
-	depends on ARCH_OMAP1510 || ARCH_OMAP1610 || ARCH_OMAP730
+	depends on ARCH_OMAP1510 || ARCH_OMAP16XX || ARCH_OMAP730
         default y
 	help
           Enable 60MHz clock for OMAP CPU. If unsure, say Y.
 
 config OMAP_ARM_30MHZ
 	bool "OMAP ARM 30 MHz CPU"
-	depends on ARCH_OMAP1510 || ARCH_OMAP1610 || ARCH_OMAP730
+	depends on ARCH_OMAP1510 || ARCH_OMAP16XX || ARCH_OMAP730
 	help
           Enable 30MHz clock for OMAP CPU. If unsure, say N.
 
diff -Nru a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile
--- a/arch/arm/mach-omap/Makefile	2004-12-24 13:36:19 -08:00
+++ b/arch/arm/mach-omap/Makefile	2004-12-24 13:36:19 -08:00
@@ -3,7 +3,7 @@
 #
 
 # Common support
-obj-y := common.o time.o irq.o dma.o clocks.o mux.o gpio.o mcbsp.o
+obj-y := common.o time.o irq.o dma.o clock.o mux.o gpio.o mcbsp.o usb.o
 obj-m :=
 obj-n :=
 obj-  :=
@@ -18,9 +18,7 @@
 obj-$(CONFIG_MACH_OMAP_H3) += board-h3.o
 
 # OCPI interconnect support for 1710, 1610 and 5912
-obj-$(CONFIG_ARCH_OMAP1710) += ocpi.o
-obj-$(CONFIG_ARCH_OMAP1610) += ocpi.o
-obj-$(CONFIG_ARCH_OMAP5912) += ocpi.o
+obj-$(CONFIG_ARCH_OMAP16XX) += ocpi.o
 
 # LEDs support
 led-$(CONFIG_MACH_OMAP_H2) += leds-h2p2-debug.o
diff -Nru a/arch/arm/mach-omap/Makefile.boot b/arch/arm/mach-omap/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-omap/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,4 @@
+   zreladdr-y		:= 0x10008000
+params_phys-y		:= 0x10000100
+initrd_phys-y		:= 0x10800000
+
diff -Nru a/arch/arm/mach-omap/board-generic.c b/arch/arm/mach-omap/board-generic.c
--- a/arch/arm/mach-omap/board-generic.c	2004-12-24 13:37:01 -08:00
+++ b/arch/arm/mach-omap/board-generic.c	2004-12-24 13:37:01 -08:00
@@ -22,44 +22,21 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
-#include <asm/arch/clocks.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/usb.h>
 #include <asm/arch/board.h>
+#include <asm/arch/serial.h>
 
 #include "common.h"
 
-extern void __init omap_init_time(void);
+static int __initdata generic_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
 
 static void __init omap_generic_init_irq(void)
 {
 	omap_init_irq();
 }
 
-/*
- * Muxes the serial ports on
- */
-#ifdef CONFIG_ARCH_OMAP1510
-static void __init omap_early_serial_init(void)
-{
-#ifdef CONFIG_OMAP_LL_DEBUG_UART1
-	omap_cfg_reg(UART1_TX);
-	omap_cfg_reg(UART1_RTS);
-#endif
-
-#ifdef CONFIG_OMAP_LL_DEBUG_UART2
-	omap_cfg_reg(UART2_TX);
-	omap_cfg_reg(UART2_RTS);
-#endif
-
-#ifdef CONFIG_OMAP_LL_DEBUG_UART1
-	omap_cfg_reg(UART3_TX);
-	omap_cfg_reg(UART3_RX);
-#endif
-}
-#endif
-
 /* assume no Mini-AB port */
 
 #ifdef CONFIG_ARCH_OMAP1510
@@ -71,7 +48,7 @@
 };
 #endif
 
-#ifdef CONFIG_ARCH_OMAP1610
+#if defined(CONFIG_ARCH_OMAP16XX)
 static struct omap_usb_config generic1610_usb_config __initdata = {
 	.register_host	= 1,
 	.register_dev	= 1,
@@ -93,17 +70,17 @@
 	 */
 #ifdef CONFIG_ARCH_OMAP1510
 	if (cpu_is_omap1510()) {
-		omap_early_serial_init();
 		generic_config[0].data = &generic1510_usb_config;
 	}
 #endif
-#ifdef CONFIG_ARCH_OMAP1610
+#if defined(CONFIG_ARCH_OMAP16XX)
 	if (!cpu_is_omap1510()) {
 		generic_config[0].data = &generic1610_usb_config;
 	}
 #endif
 	omap_board_config = generic_config;
 	omap_board_config_size = ARRAY_SIZE(generic_config);
+	omap_serial_init(generic_serial_ports);
 }
 
 static void __init omap_generic_map_io(void)
@@ -118,5 +95,5 @@
 	MAPIO(omap_generic_map_io)
 	INITIRQ(omap_generic_init_irq)
 	INIT_MACHINE(omap_generic_init)
-	INITTIME(omap_init_time)
+	.timer		= &omap_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-omap/board-h2.c b/arch/arm/mach-omap/board-h2.c
--- a/arch/arm/mach-omap/board-h2.c	2004-12-24 13:37:43 -08:00
+++ b/arch/arm/mach-omap/board-h2.c	2004-12-24 13:37:43 -08:00
@@ -32,16 +32,11 @@
 #include <asm/arch/clocks.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/usb.h>
+#include <asm/arch/serial.h>
 
 #include "common.h"
 
-extern void __init omap_init_time(void);
-
-static struct map_desc h2_io_desc[] __initdata = {
-{ OMAP1610_ETHR_BASE, OMAP1610_ETHR_START, OMAP1610_ETHR_SIZE,MT_DEVICE },
-{ OMAP1610_NOR_FLASH_BASE, OMAP1610_NOR_FLASH_START, OMAP1610_NOR_FLASH_SIZE,
-	MT_DEVICE },
-};
+static int __initdata h2_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
 
 static struct resource h2_smc91x_resources[] = {
 	[0] = {
@@ -80,15 +75,22 @@
 	.hmc_mode	= 19,	// 0:host(off) 1:dev|otg 2:disabled
 	// .hmc_mode	= 21,	// 0:host(off) 1:dev(loopback) 2:host(loopback)
 #elif	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
-	/* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
+	/* needs OTG cable, or NONSTANDARD (B-to-MiniB) */
 	.hmc_mode	= 20,	// 1:dev|otg(off) 1:host 2:disabled
 #endif
 
 	.pins[1]	= 3,
 };
 
+static struct omap_mmc_config h2_mmc_config __initdata = {
+	.mmc_blocks		= 1,
+	.mmc1_power_pin		= -1,	/* tps65010 gpio3 */
+	.mmc1_switch_pin	= OMAP_MPUIO(1),
+};
+
 static struct omap_board_config_kernel h2_config[] = {
 	{ OMAP_TAG_USB,           &h2_usb_config },
+	{ OMAP_TAG_MMC,           &h2_mmc_config },
 };
 
 static void __init h2_init(void)
@@ -101,7 +103,7 @@
 static void __init h2_map_io(void)
 {
 	omap_map_io();
-	iotable_init(h2_io_desc, ARRAY_SIZE(h2_io_desc));
+	omap_serial_init(h2_serial_ports);
 }
 
 MACHINE_START(OMAP_H2, "TI-H2")
@@ -111,5 +113,5 @@
 	MAPIO(h2_map_io)
 	INITIRQ(h2_init_irq)
 	INIT_MACHINE(h2_init)
-	INITTIME(omap_init_time)
+	.timer		= &omap_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-omap/board-h3.c b/arch/arm/mach-omap/board-h3.c
--- a/arch/arm/mach-omap/board-h3.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-omap/board-h3.c	2004-12-24 13:36:17 -08:00
@@ -30,15 +30,17 @@
 #include <asm/arch/irqs.h>
 #include <asm/arch/gpio.h>
 #include <asm/mach-types.h>
-#include "common.h"
+#include <asm/arch/serial.h>
 
-extern void __init omap_init_time(void);
+#include "common.h"
 
 void h3_init_irq(void)
 {
 	omap_init_irq();
 }
 
+static int __initdata h3_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
+
 static struct resource smc91x_resources[] = {
 	[0] = {
 		.start	= OMAP1710_ETHR_START,		/* Physical */
@@ -68,15 +70,10 @@
 	(void) platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
-static struct map_desc h3_io_desc[] __initdata = {
-{ OMAP1710_ETHR_BASE,  OMAP1710_ETHR_START,  OMAP1710_ETHR_SIZE,  MT_DEVICE },
-{ OMAP_NOR_FLASH_BASE, OMAP_NOR_FLASH_START, OMAP_NOR_FLASH_SIZE, MT_DEVICE },
-};
-
 static void __init h3_map_io(void)
 {
 	omap_map_io();
-	iotable_init(h3_io_desc, ARRAY_SIZE(h3_io_desc));
+	omap_serial_init(h3_serial_ports);
 }
 
 MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
@@ -86,5 +83,5 @@
 	MAPIO(h3_map_io)
 	INITIRQ(h3_init_irq)
 	INIT_MACHINE(h3_init)
-	INITTIME(omap_init_time)
+	.timer		= &omap_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-omap/board-innovator.c b/arch/arm/mach-omap/board-innovator.c
--- a/arch/arm/mach-omap/board-innovator.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-omap/board-innovator.c	2004-12-24 13:36:17 -08:00
@@ -30,11 +30,10 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/fpga.h>
 #include <asm/arch/usb.h>
+#include <asm/arch/serial.h>
 
 #include "common.h"
 
-extern void __init omap_init_time(void);
-
 #ifdef CONFIG_ARCH_OMAP1510
 
 extern int omap_gpio_init(void);
@@ -45,6 +44,8 @@
 	MT_DEVICE },
 };
 
+static int __initdata innovator_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
+
 static struct resource innovator1510_smc91x_resources[] = {
 	[0] = {
 		.start	= OMAP1510_FPGA_ETHR_START,	/* Physical */
@@ -71,18 +72,12 @@
 
 #endif /* CONFIG_ARCH_OMAP1510 */
 
-#ifdef CONFIG_ARCH_OMAP1610
-
-static struct map_desc innovator1610_io_desc[] __initdata = {
-{ OMAP1610_ETHR_BASE, OMAP1610_ETHR_START, OMAP1610_ETHR_SIZE,MT_DEVICE },
-{ OMAP1610_NOR_FLASH_BASE, OMAP1610_NOR_FLASH_START, OMAP1610_NOR_FLASH_SIZE,
-	MT_DEVICE },
-};
+#ifdef CONFIG_ARCH_OMAP16XX
 
 static struct resource innovator1610_smc91x_resources[] = {
 	[0] = {
-		.start	= OMAP1610_ETHR_START,		/* Physical */
-		.end	= OMAP1610_ETHR_START + SZ_4K,
+		.start	= INNOVATOR1610_ETHR_START,		/* Physical */
+		.end	= INNOVATOR1610_ETHR_START + SZ_4K,
 		.flags	= IORESOURCE_MEM,
 	},
 	[1] = {
@@ -103,7 +98,7 @@
 	&innovator1610_smc91x_device,
 };
 
-#endif /* CONFIG_ARCH_OMAP1610 */
+#endif /* CONFIG_ARCH_OMAP16XX */
 
 void innovator_init_irq(void)
 {
@@ -118,16 +113,19 @@
 
 #ifdef CONFIG_ARCH_OMAP1510
 static struct omap_usb_config innovator1510_usb_config __initdata = {
-	/* has usb host and device, but no Mini-AB port */
+	/* for bundled non-standard host and peripheral cables */
+	.hmc_mode	= 4,
+
 	.register_host	= 1,
+	.pins[1]	= 6,
+	.pins[2]	= 6,		/* Conflicts with UART2 */
+
 	.register_dev	= 1,
-	/* Assume bad Innovator wiring; Use internal host only with custom cable */
-	.hmc_mode	= 16,
 	.pins[0]	= 2,
 };
 #endif
 
-#ifdef CONFIG_ARCH_OMAP1610
+#ifdef CONFIG_ARCH_OMAP16XX
 static struct omap_usb_config h2_usb_config __initdata = {
 	/* usb1 has a Mini-AB port and external isp1301 transceiver */
 	.otg		= 2,
@@ -155,7 +153,7 @@
 		platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
 	}
 #endif
-#ifdef CONFIG_ARCH_OMAP1610
+#ifdef CONFIG_ARCH_OMAP16XX
 	if (!cpu_is_omap1510()) {
 		platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
 	}
@@ -165,7 +163,7 @@
 	if (cpu_is_omap1510())
 		innovator_config[0].data = &innovator1510_usb_config;
 #endif
-#ifdef CONFIG_ARCH_OMAP1610
+#ifdef CONFIG_ARCH_OMAP16XX
 	if (cpu_is_omap1610())
 		innovator_config[0].data = &h2_usb_config;
 #endif
@@ -189,11 +187,7 @@
 		       fpga_read(OMAP1510_FPGA_BOARD_REV));
 	}
 #endif
-#ifdef CONFIG_ARCH_OMAP1610
-	if (!cpu_is_omap1510()) {
-		iotable_init(innovator1610_io_desc, ARRAY_SIZE(innovator1610_io_desc));
-	}
-#endif
+	omap_serial_init(innovator_serial_ports);
 }
 
 MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
@@ -203,5 +197,5 @@
 	MAPIO(innovator_map_io)
 	INITIRQ(innovator_init_irq)
 	INIT_MACHINE(innovator_init)
-	INITTIME(omap_init_time)
+	.timer		= &omap_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-omap/board-osk.c b/arch/arm/mach-omap/board-osk.c
--- a/arch/arm/mach-omap/board-osk.c	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/mach-omap/board-osk.c	2004-12-24 13:37:18 -08:00
@@ -38,17 +38,18 @@
 #include <asm/arch/clocks.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/fpga.h>
+#include <asm/arch/usb.h>
+#include <asm/arch/serial.h>
 
 #include "common.h"
 
-extern void __init omap_init_time(void);
-
 static struct map_desc osk5912_io_desc[] __initdata = {
-{ OMAP_OSK_ETHR_BASE, OMAP_OSK_ETHR_START, OMAP_OSK_ETHR_SIZE,MT_DEVICE },
 { OMAP_OSK_NOR_FLASH_BASE, OMAP_OSK_NOR_FLASH_START, OMAP_OSK_NOR_FLASH_SIZE,
 	MT_DEVICE },
 };
 
+static int __initdata osk_serial_ports[OMAP_MAX_NR_PORTS] = {1, 0, 0};
+
 static struct resource osk5912_smc91x_resources[] = {
 	[0] = {
 		.start	= OMAP_OSK_ETHR_START,		/* Physical */
@@ -78,16 +79,29 @@
 	omap_init_irq();
 }
 
+static struct omap_usb_config osk_usb_config __initdata = {
+	/* has usb host and device, but no Mini-AB port */
+	.register_host	= 1,
+	.hmc_mode	= 16,
+	.pins[0]	= 2,
+};
+
+static struct omap_board_config_kernel osk_config[] = {
+	{ OMAP_TAG_USB,           &osk_usb_config },
+};
+
 static void __init osk_init(void)
 {
         platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
+	omap_board_config = osk_config;
+	omap_board_config_size = ARRAY_SIZE(osk_config);
 }
 
 static void __init osk_map_io(void)
 {
 	omap_map_io();
 	iotable_init(osk5912_io_desc, ARRAY_SIZE(osk5912_io_desc));
-
+	omap_serial_init(osk_serial_ports);
 }
 
 MACHINE_START(OMAP_OSK, "TI-OSK")
@@ -97,5 +111,5 @@
 	MAPIO(osk_map_io)
 	INITIRQ(osk_init_irq)
 	INIT_MACHINE(osk_init)
-	INITTIME(omap_init_time)
+	.timer		= &omap_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-omap/board-perseus2.c b/arch/arm/mach-omap/board-perseus2.c
--- a/arch/arm/mach-omap/board-perseus2.c	2004-12-24 13:37:03 -08:00
+++ b/arch/arm/mach-omap/board-perseus2.c	2004-12-24 13:37:03 -08:00
@@ -24,11 +24,10 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/fpga.h>
+#include <asm/arch/serial.h>
 
 #include "common.h"
 
-extern void __init omap_init_time(void);
-
 void omap_perseus2_init_irq(void)
 {
 	omap_init_irq();
@@ -47,6 +46,8 @@
 	},
 };
 
+static int __initdata p2_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 0};
+
 static struct platform_device smc91x_device = {
 	.name		= "smc91x",
 	.id		= 0,
@@ -106,6 +107,7 @@
 	 * It is used as the Ethernet controller interrupt
 	 */
 	omap_writel(omap_readl(OMAP730_IO_CONF_9) & 0x1FFFFFFF, OMAP730_IO_CONF_9);
+	omap_serial_init(p2_serial_ports);
 }
 
 MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
@@ -115,5 +117,5 @@
 	MAPIO(omap_perseus2_map_io)
 	INITIRQ(omap_perseus2_init_irq)
 	INIT_MACHINE(omap_perseus2_init)
-	INITTIME(omap_init_time)
+	.timer		= &omap_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-omap/clock.c b/arch/arm/mach-omap/clock.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-omap/clock.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,955 @@
+/*
+ *  linux/arch/arm/mach-omap/clock.c
+ *
+ *  Copyright (C) 2004 Nokia corporation
+ *  Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.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.
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+
+#include <asm/semaphore.h>
+#include <asm/hardware/clock.h>
+#include <asm/arch/board.h>
+
+#include "clock.h"
+
+static LIST_HEAD(clocks);
+static DECLARE_MUTEX(clocks_sem);
+static spinlock_t clockfw_lock = SPIN_LOCK_UNLOCKED;
+static void propagate_rate(struct clk *  clk);
+/* MPU virtual clock functions */
+static int select_table_rate(unsigned long rate);
+static long round_to_table_rate(unsigned long rate);
+void clk_setdpll(__u16, __u16);
+
+struct mpu_rate rate_table[] = {
+	/* MPU MHz, xtal MHz, dpll1 MHz, CKCTL, DPLL_CTL
+	 * armdiv, dspdiv, dspmmu, tcdiv, perdiv, lcddiv
+	 */
+#if defined(CONFIG_OMAP_ARM_216MHZ) && defined(CONFIG_ARCH_OMAP16XX)
+	{ 216000000, 12000000, 216000000, 0x050d, 0x2910 }, /* 1/1/2/2/2/8 */
+#endif
+#if defined(CONFIG_OMAP_ARM_195MHZ) && defined(CONFIG_ARCH_OMAP730)
+	{ 195000000, 13000000, 195000000, 0x050e, 0x2790 }, /* 1/1/2/2/4/8 */
+#endif
+#if defined(CONFIG_OMAP_ARM_192MHZ) && defined(CONFIG_ARCH_OMAP16XX)
+	{ 192000000, 19200000, 192000000, 0x050f, 0x2510 }, /* 1/1/2/2/8/8 */
+	{ 192000000, 12000000, 192000000, 0x050f, 0x2810 }, /* 1/1/2/2/8/8 */
+	{  96000000, 12000000, 192000000, 0x055f, 0x2810 }, /* 2/2/2/2/8/8 */
+	{  48000000, 12000000, 192000000, 0x0ccf, 0x2810 }, /* 4/4/4/4/8/8 */
+	{  24000000, 12000000, 192000000, 0x0fff, 0x2810 }, /* 8/8/8/8/8/8 */
+#endif
+#if defined(CONFIG_OMAP_ARM_182MHZ) && defined(CONFIG_ARCH_OMAP730)
+	{ 182000000, 13000000, 182000000, 0x050e, 0x2710 }, /* 1/1/2/2/4/8 */
+#endif
+#if defined(CONFIG_OMAP_ARM_168MHZ)
+	{ 168000000, 12000000, 168000000, 0x010f, 0x2710 }, /* 1/1/1/2/8/8 */
+#endif
+#if defined(CONFIG_OMAP_ARM_120MHZ)
+	{ 120000000, 12000000, 120000000, 0x010a, 0x2510 }, /* 1/1/1/2/4/4 */
+#endif
+#if defined(CONFIG_OMAP_ARM_96MHZ)
+	{  96000000, 12000000,  96000000, 0x0005, 0x2410 }, /* 1/1/1/1/2/2 */
+#endif
+#if defined(CONFIG_OMAP_ARM_60MHZ)
+	{  60000000, 12000000,  60000000, 0x0005, 0x2290 }, /* 1/1/1/1/2/2 */
+#endif
+#if defined(CONFIG_OMAP_ARM_30MHZ)
+	{  30000000, 12000000,  60000000, 0x0555, 0x2290 }, /* 2/2/2/2/2/2 */
+#endif
+	{ 0, 0, 0, 0, 0 },
+};
+
+
+static void ckctl_recalc(struct clk *  clk)
+{
+	int dsor;
+
+	/* Calculate divisor encoded as 2-bit exponent */
+	dsor = 1 << (3 & (omap_readw(ARM_CKCTL) >> clk->rate_offset));
+	if (unlikely(clk->rate == clk->parent->rate / dsor))
+		return; /* No change, quick exit */
+	clk->rate = clk->parent->rate / dsor;
+
+	if (unlikely(clk->flags & RATE_PROPAGATES))
+		propagate_rate(clk);
+}
+
+
+static void followparent_recalc(struct clk *  clk)
+{
+	clk->rate = clk->parent->rate;
+}
+
+
+static void watchdog_recalc(struct clk *  clk)
+{
+	clk->rate = clk->parent->rate / 14;
+}
+
+
+static struct clk ck_ref = {
+	.name		= "ck_ref",
+	.rate		= 12000000,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  ALWAYS_ENABLED,
+};
+
+static struct clk ck_dpll1 = {
+	.name		= "ck_dpll1",
+	.parent		= &ck_ref,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_PROPAGATES | ALWAYS_ENABLED,
+};
+
+static struct clk ck_dpll1out = {
+	.name		= "ck_dpll1out",
+	.parent		= &ck_dpll1,
+	.flags		= CLOCK_IN_OMAP16XX,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_CKOUT_ARM,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk arm_ck = {
+	.name		= "arm_ck",
+	.parent		= &ck_dpll1,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_CKCTL | RATE_PROPAGATES | ALWAYS_ENABLED,
+	.rate_offset	= CKCTL_ARMDIV_OFFSET,
+	.recalc		= &ckctl_recalc,
+};
+
+static struct clk armper_ck = {
+	.name		= "armper_ck",
+	.parent		= &ck_dpll1,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_CKCTL,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_PERCK,
+	.rate_offset	= CKCTL_PERDIV_OFFSET,
+	.recalc		= &ckctl_recalc,
+};
+
+static struct clk arm_gpio_ck = {
+	.name		= "arm_gpio_ck",
+	.parent		= &ck_dpll1,
+	.flags		= CLOCK_IN_OMAP1510,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_GPIOCK,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk armxor_ck = {
+	.name		= "armxor_ck",
+	.parent		= &ck_ref,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_XORPCK,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk armtim_ck = {
+	.name		= "armtim_ck",
+	.parent		= &ck_ref,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_TIMCK,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk armwdt_ck = {
+	.name		= "armwdt_ck",
+	.parent		= &ck_ref,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_WDTCK,
+	.recalc		= &watchdog_recalc,
+};
+
+static struct clk arminth_ck1610 = {
+	.name		= "arminth_ck",
+	.parent		= &arm_ck,
+	.flags		= CLOCK_IN_OMAP16XX,
+	.recalc		= &followparent_recalc,
+	/* Note: On 1610/1710 frequency can be divided by 2 by programming
+	 * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
+	 *
+	 * 1510 version is in TC clocks.
+	 */
+};
+
+static struct clk dsp_ck = {
+	.name		= "dsp_ck",
+	.parent		= &ck_dpll1,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_CKCTL,
+	.enable_reg	= ARM_CKCTL,
+	.enable_bit	= EN_DSPCK,
+	.rate_offset	= CKCTL_DSPDIV_OFFSET,
+	.recalc		= &ckctl_recalc,
+};
+
+static struct clk dspmmu_ck = {
+	.name		= "dspmmu_ck",
+	.parent		= &ck_dpll1,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_CKCTL | ALWAYS_ENABLED,
+	.rate_offset	= CKCTL_DSPMMUDIV_OFFSET,
+	.recalc		= &ckctl_recalc,
+};
+
+static struct clk tc_ck = {
+	.name		= "tc_ck",
+	.parent		= &ck_dpll1,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_CKCTL | RATE_PROPAGATES | ALWAYS_ENABLED,
+	.rate_offset	= CKCTL_TCDIV_OFFSET,
+	.recalc		= &ckctl_recalc,
+};
+
+static struct clk arminth_ck1510 = {
+	.name		= "arminth_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP1510,
+	.recalc		= &followparent_recalc,
+	/* Note: On 1510 frequency follows TC_CK
+	 *
+	 * 1610/1710 version is in MPU clocks.
+	 */
+};
+
+static struct clk tipb_ck = {
+	.name		= "tibp_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP1510,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk l3_ocpi_ck = {
+	.name		= "l3_ocpi_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP16XX,
+	.enable_reg	= ARM_IDLECT3,
+	.enable_bit	= EN_OCPI_CK,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk tc1_ck = {
+	.name		= "tc1_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP16XX,
+	.enable_reg	= ARM_IDLECT3,
+	.enable_bit	= EN_TC1_CK,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk tc2_ck = {
+	.name		= "tc2_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP16XX,
+	.enable_reg	= ARM_IDLECT3,
+	.enable_bit	= EN_TC2_CK,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk dma_ck = {
+	.name		= "dma_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk dma_lcdfree_ck = {
+	.name		= "dma_lcdfree_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP16XX,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk api_ck = {
+	.name		= "api_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_APICK,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk lb_ck = {
+	.name		= "lb_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP1510,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_LBCK,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk rhea1_ck = {
+	.name		= "rhea1_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP16XX,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk rhea2_ck = {
+	.name		= "rhea2_ck",
+	.parent		= &tc_ck,
+	.flags		= CLOCK_IN_OMAP16XX,
+	.recalc		= &followparent_recalc,
+};
+
+static struct clk lcd_ck = {
+	.name		= "lcd_ck",
+	.parent		= &ck_dpll1,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_CKCTL,
+	.enable_reg	= ARM_IDLECT2,
+	.enable_bit	= EN_LCDCK,
+	.rate_offset	= CKCTL_LCDDIV_OFFSET,
+	.recalc		= &ckctl_recalc,
+};
+
+static struct clk uart1_ck = {
+	.name		= "uart1_ck",
+	/* Direct from ULPD, no parent */
+	.rate		= 48000000,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_FIXED | ENABLE_REG_32BIT,
+	.enable_reg	= MOD_CONF_CTRL_0,
+	.enable_bit	= 29,
+	/* (Only on 1510)
+	 * The "enable bit" actually chooses between 48MHz and 12MHz.
+	 */
+};
+
+static struct clk uart2_ck = {
+	.name		= "uart2_ck",
+	/* Direct from ULPD, no parent */
+	.rate		= 48000000,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_FIXED | ENABLE_REG_32BIT,
+	.enable_reg	= MOD_CONF_CTRL_0,
+	.enable_bit	= 30,
+	/* (1510/1610/1710)
+	 * The "enable bit" actually chooses between 48MHz and 12MHz/32kHz.
+	 */
+};
+
+static struct clk uart3_ck = {
+	.name		= "uart3_ck",
+	/* Direct from ULPD, no parent */
+	.rate		= 48000000,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_FIXED | ENABLE_REG_32BIT,
+	.enable_reg	= MOD_CONF_CTRL_0,
+	.enable_bit	= 31,
+	/* (Only on 1510)
+	 * The "enable bit" actually chooses between 48MHz and 12MHz.
+	 */
+};
+
+static struct clk usb_ck1610 = {
+	.name		= "usb_ck",
+	/* Direct from ULPD, no parent */
+	.rate		= 48000000,
+	.flags		= CLOCK_IN_OMAP16XX |
+			  RATE_FIXED | ENABLE_REG_32BIT,
+	.enable_reg	= ULPD_CLOCK_CTRL,
+	.enable_bit	= USB_MCLK_EN,
+};
+
+static struct clk usb_ck1510 = {
+	.name		= "usb_ck",
+	/* Direct from ULPD, no parent */
+	.rate		= 48000000,
+	.flags		= CLOCK_IN_OMAP1510 | RATE_FIXED,
+};
+
+static struct clk usb_hhc_ck = {
+	.name		= "usb_hhc_ck",
+	/* Direct from ULPD, no parent */
+	.rate		= 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_FIXED | ENABLE_REG_32BIT,
+	.enable_reg	= MOD_CONF_CTRL_0,
+	.enable_bit	= USB_HOST_HHC_UHOST_EN,
+};
+
+/* To be done --
+static struct clk mclk = {
+	.name		= "mclk",
+};
+
+static struct clk bclk = {
+	.name		= "bclk",
+};
+-- to be done */
+
+static struct clk mmc1_ck = {
+	.name		= "mmc1_ck",
+	/* Functional clock is direct from ULPD, interface clock is ARMPER */
+	.parent		= &armper_ck,
+	.rate		= 48000000,
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  RATE_FIXED | ENABLE_REG_32BIT,
+	.enable_reg	= MOD_CONF_CTRL_0,
+	.enable_bit	= 23,
+};
+
+static struct clk mmc2_ck = {
+	.name		= "mmc2_ck",
+	/* Functional clock is direct from ULPD, interface clock is ARMPER */
+	.parent		= &armper_ck,
+	.rate		= 48000000,
+	.flags		= CLOCK_IN_OMAP16XX |
+			  RATE_FIXED | ENABLE_REG_32BIT,
+	.enable_reg	= MOD_CONF_CTRL_0,
+	.enable_bit	= 20,
+};
+
+static struct clk virtual_ck_mpu = {
+	.name		= "mpu",
+	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
+			  VIRTUAL_CLOCK | ALWAYS_ENABLED,
+	.parent		= &arm_ck, /* Is smarter alias for */
+	.recalc		= &followparent_recalc,
+	.set_rate	= &select_table_rate,
+	.round_rate	= &round_to_table_rate,
+};
+
+
+static struct clk *  onchip_clks[] = {
+	/* non-ULPD clocks */
+	&ck_ref,
+	&ck_dpll1,
+	/* CK_GEN1 clocks */
+	&ck_dpll1out,
+	&arm_ck,
+	&armper_ck,
+	&arm_gpio_ck,
+	&armxor_ck,
+	&armtim_ck,
+	&armwdt_ck,
+	&arminth_ck1510,
+	&arminth_ck1610,
+	/* CK_GEN2 clocks */
+	&dsp_ck,
+	&dspmmu_ck,
+	/* CK_GEN3 clocks */
+	&tc_ck,
+	&tipb_ck,
+	&l3_ocpi_ck,
+	&tc1_ck,
+	&tc2_ck,
+	&dma_ck,
+	&dma_lcdfree_ck,
+	&api_ck,
+	&lb_ck,
+	&rhea1_ck,
+	&rhea2_ck,
+	&lcd_ck,
+	/* ULPD clocks */
+	&uart1_ck,
+	&uart2_ck,
+	&uart3_ck,
+	&usb_ck1510,
+	&usb_ck1610,
+	&usb_hhc_ck,
+	/* To be done --
+	&mclk,
+	&bclk,
+	-- to be done */
+	&mmc1_ck,
+	&mmc2_ck,
+	/* Virtual clocks */
+	&virtual_ck_mpu,
+};
+
+struct clk *clk_get(struct device *dev, const char *id)
+{
+	struct clk *p, *clk = ERR_PTR(-ENOENT);
+
+	down(&clocks_sem);
+	list_for_each_entry(p, &clocks, node) {
+		if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
+			clk = p;
+			break;
+		}
+	}
+	up(&clocks_sem);
+
+	return clk;
+}
+EXPORT_SYMBOL(clk_get);
+
+
+void clk_put(struct clk *clk)
+{
+	if (clk && !IS_ERR(clk))
+		module_put(clk->owner);
+}
+EXPORT_SYMBOL(clk_put);
+
+
+int __clk_enable(struct clk *clk)
+{
+	__u16 regval16;
+	__u32 regval32;
+
+	if (clk->flags & ALWAYS_ENABLED)
+		return 0;
+
+	if (unlikely(clk->enable_reg == 0)) {
+		printk(KERN_ERR "clock.c: Enable for %s without enable code\n",
+		       clk->name);
+		return 0;
+	}
+
+	if (clk->flags & ENABLE_REG_32BIT) {
+		regval32 = omap_readl(clk->enable_reg);
+		regval32 |= (1 << clk->enable_bit);
+		omap_writel(regval32, clk->enable_reg);
+	} else {
+		regval16 = omap_readw(clk->enable_reg);
+		regval16 |= (1 << clk->enable_bit);
+		omap_writew(regval16, clk->enable_reg);
+	}
+
+	return 0;
+}
+
+
+void __clk_disable(struct clk *clk)
+{
+	__u16 regval16;
+	__u32 regval32;
+
+	if (clk->enable_reg == 0)
+		return;
+
+	if (clk->flags & ENABLE_REG_32BIT) {
+		regval32 = omap_readl(clk->enable_reg);
+		regval32 &= ~(1 << clk->enable_bit);
+		omap_writel(regval32, clk->enable_reg);
+	} else {
+		regval16 = omap_readw(clk->enable_reg);
+		regval16 &= ~(1 << clk->enable_bit);
+		omap_writew(regval16, clk->enable_reg);
+	}
+}
+
+
+void __clk_unuse(struct clk *clk)
+{
+	if (clk->usecount > 0 && !(--clk->usecount)) {
+		__clk_disable(clk);
+		if (likely(clk->parent))
+			__clk_unuse(clk->parent);
+	}
+}
+
+
+int __clk_use(struct clk *clk)
+{
+	int ret = 0;
+	if (clk->usecount++ == 0) {
+		if (likely(clk->parent))
+			ret = __clk_use(clk->parent);
+
+		if (unlikely(ret != 0)) {
+			clk->usecount--;
+			return ret;
+		}
+
+		ret = __clk_enable(clk);
+
+		if (unlikely(ret != 0) && clk->parent) {
+			__clk_unuse(clk->parent);
+			clk->usecount--;
+		}
+	}
+
+	return ret;
+}
+
+
+int clk_enable(struct clk *clk)
+{
+	unsigned long flags;
+	int ret;
+
+	spin_lock_irqsave(&clockfw_lock, flags);
+	ret = __clk_enable(clk);
+	spin_unlock_irqrestore(&clockfw_lock, flags);
+	return ret;
+}
+EXPORT_SYMBOL(clk_enable);
+
+
+void clk_disable(struct clk *clk)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&clockfw_lock, flags);
+	__clk_disable(clk);
+	spin_unlock_irqrestore(&clockfw_lock, flags);
+}
+EXPORT_SYMBOL(clk_disable);
+
+
+int clk_use(struct clk *clk)
+{
+	unsigned long flags;
+	int ret = 0;
+
+	spin_lock_irqsave(&clockfw_lock, flags);
+	ret = __clk_use(clk);
+	spin_unlock_irqrestore(&clockfw_lock, flags);
+	return ret;
+}
+EXPORT_SYMBOL(clk_use);
+
+
+void clk_unuse(struct clk *clk)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&clockfw_lock, flags);
+	__clk_unuse(clk);
+	spin_unlock_irqrestore(&clockfw_lock, flags);
+}
+EXPORT_SYMBOL(clk_unuse);
+
+
+unsigned long clk_get_rate(struct clk *clk)
+{
+	return clk->rate;
+}
+EXPORT_SYMBOL(clk_get_rate);
+
+
+static __u16 verify_ckctl_value(__u16 newval)
+{
+	/* This function checks for following limitations set
+	 * by the hardware (all conditions must be true):
+	 * DSPMMU_CK == DSP_CK  or  DSPMMU_CK == DSP_CK/2
+	 * ARM_CK >= TC_CK
+	 * DSP_CK >= TC_CK
+	 * DSPMMU_CK >= TC_CK
+	 *
+	 * In addition following rules are enforced:
+	 * LCD_CK <= TC_CK
+	 * ARMPER_CK <= TC_CK
+	 *
+	 * However, maximum frequencies are not checked for!
+	 */
+	__u8 per_exp;
+	__u8 lcd_exp;
+	__u8 arm_exp;
+	__u8 dsp_exp;
+	__u8 tc_exp;
+	__u8 dspmmu_exp;
+
+	per_exp = (newval >> CKCTL_PERDIV_OFFSET) & 3;
+	lcd_exp = (newval >> CKCTL_LCDDIV_OFFSET) & 3;
+	arm_exp = (newval >> CKCTL_ARMDIV_OFFSET) & 3;
+	dsp_exp = (newval >> CKCTL_DSPDIV_OFFSET) & 3;
+	tc_exp = (newval >> CKCTL_TCDIV_OFFSET) & 3;
+	dspmmu_exp = (newval >> CKCTL_DSPMMUDIV_OFFSET) & 3;
+
+	if (dspmmu_exp < dsp_exp)
+		dspmmu_exp = dsp_exp;
+	if (dspmmu_exp > dsp_exp+1)
+		dspmmu_exp = dsp_exp+1;
+	if (tc_exp < arm_exp)
+		tc_exp = arm_exp;
+	if (tc_exp < dspmmu_exp)
+		tc_exp = dspmmu_exp;
+	if (tc_exp > lcd_exp)
+		lcd_exp = tc_exp;
+	if (tc_exp > per_exp)
+		per_exp = tc_exp;
+
+	newval &= 0xf000;
+	newval |= per_exp << CKCTL_PERDIV_OFFSET;
+	newval |= lcd_exp << CKCTL_LCDDIV_OFFSET;
+	newval |= arm_exp << CKCTL_ARMDIV_OFFSET;
+	newval |= dsp_exp << CKCTL_DSPDIV_OFFSET;
+	newval |= tc_exp << CKCTL_TCDIV_OFFSET;
+	newval |= dspmmu_exp << CKCTL_DSPMMUDIV_OFFSET;
+
+	return newval;
+}
+
+
+static int calc_dsor_exp(struct clk *clk, unsigned long rate)
+{
+	/* Note: If target frequency is too low, this function will return 4,
+	 * which is invalid value. Caller must check for this value and act
+	 * accordingly.
+	 *
+	 * Note: This function does not check for following limitations set
+	 * by the hardware (all conditions must be true):
+	 * DSPMMU_CK == DSP_CK  or  DSPMMU_CK == DSP_CK/2
+	 * ARM_CK >= TC_CK
+	 * DSP_CK >= TC_CK
+	 * DSPMMU_CK >= TC_CK
+	 */
+	unsigned long realrate;
+	struct clk *  parent;
+	unsigned  dsor_exp;
+
+	if (unlikely(!(clk->flags & RATE_CKCTL)))
+		return -EINVAL;
+
+	parent = clk->parent;
+	if (unlikely(parent == 0))
+		return -EIO;
+
+	realrate = parent->rate;
+	for (dsor_exp=0; dsor_exp<4; dsor_exp++) {
+		if (realrate <= rate)
+			break;
+
+		realrate /= 2;
+	}
+
+	return dsor_exp;
+}
+
+long clk_round_rate(struct clk *clk, unsigned long rate)
+{
+	int dsor_exp;
+
+	if (clk->flags & RATE_FIXED)
+		return clk->rate;
+
+	if (clk->flags & RATE_CKCTL) {
+		dsor_exp = calc_dsor_exp(clk, rate);
+		if (dsor_exp < 0)
+			return dsor_exp;
+		if (dsor_exp > 3)
+			dsor_exp = 3;
+		return clk->parent->rate / (1 << dsor_exp);
+	}
+
+	if(clk->round_rate != 0)
+		return clk->round_rate(rate);
+
+	return clk->rate;
+}
+EXPORT_SYMBOL(clk_round_rate);
+
+
+static void propagate_rate(struct clk *  clk)
+{
+	struct clk **  clkp;
+
+	for (clkp = onchip_clks; clkp < onchip_clks+ARRAY_SIZE(onchip_clks); clkp++) {
+		if (likely((*clkp)->parent != clk)) continue;
+		if (likely((*clkp)->recalc))
+			(*clkp)->recalc(*clkp);
+	}
+}
+
+
+static int select_table_rate(unsigned long rate)
+{
+	/* Find the highest supported frequency <= rate and switch to it */
+	struct mpu_rate *  ptr;
+
+	for (ptr = rate_table; ptr->rate; ptr++) {
+		if (ptr->xtal != ck_ref.rate)
+			continue;
+
+		/* DPLL1 cannot be reprogrammed without risking system crash */
+		if (likely(ck_dpll1.rate!=0) && ptr->pll_rate != ck_dpll1.rate)
+			continue;
+
+		/* Can check only after xtal frequency check */
+		if (ptr->rate <= rate)
+			break;
+	}
+
+	if (!ptr->rate)
+		return -EINVAL;
+
+	if (unlikely(ck_dpll1.rate == 0)) {
+		omap_writew(ptr->dpllctl_val, DPLL_CTL);
+		ck_dpll1.rate = ptr->pll_rate;
+	}
+	omap_writew(ptr->ckctl_val, ARM_CKCTL);
+	propagate_rate(&ck_dpll1);
+	return 0;
+}
+
+
+static long round_to_table_rate(unsigned long rate)
+{
+	/* Find the highest supported frequency <= rate */
+	struct mpu_rate *  ptr;
+	long  highest_rate;
+
+	highest_rate = -EINVAL;
+
+	for (ptr = rate_table; ptr->rate; ptr++) {
+		if (ptr->xtal != ck_ref.rate)
+			continue;
+
+		highest_rate = ptr->rate;
+
+		/* Can check only after xtal frequency check */
+		if (ptr->rate <= rate)
+			break;
+	}
+
+	return highest_rate;
+}
+
+
+int clk_set_rate(struct clk *clk, unsigned long rate)
+{
+	int  ret = -EINVAL;
+	int  dsor_exp;
+	__u16  regval;
+	unsigned long  flags;
+
+	if (clk->flags & RATE_CKCTL) {
+		dsor_exp = calc_dsor_exp(clk, rate);
+		if (dsor_exp > 3)
+			dsor_exp = -EINVAL;
+		if (dsor_exp < 0)
+			return dsor_exp;
+
+		spin_lock_irqsave(&clockfw_lock, flags);
+		regval = omap_readw(ARM_CKCTL);
+		regval &= ~(3 << clk->rate_offset);
+		regval |= dsor_exp << clk->rate_offset;
+		regval = verify_ckctl_value(regval);
+		omap_writew(regval, ARM_CKCTL);
+		clk->rate = clk->parent->rate / (1 << dsor_exp);
+		spin_unlock_irqrestore(&clockfw_lock, flags);
+		ret = 0;
+	} else if(clk->set_rate != 0) {
+		spin_lock_irqsave(&clockfw_lock, flags);
+		ret = clk->set_rate(rate);
+		spin_unlock_irqrestore(&clockfw_lock, flags);
+	}
+
+	if (unlikely(ret == 0 && (clk->flags & RATE_PROPAGATES)))
+		propagate_rate(clk);
+
+	return ret;
+}
+EXPORT_SYMBOL(clk_set_rate);
+
+
+int clk_register(struct clk *clk)
+{
+	down(&clocks_sem);
+	list_add(&clk->node, &clocks);
+	up(&clocks_sem);
+	return 0;
+}
+EXPORT_SYMBOL(clk_register);
+
+void clk_unregister(struct clk *clk)
+{
+	down(&clocks_sem);
+	list_del(&clk->node);
+	up(&clocks_sem);
+}
+EXPORT_SYMBOL(clk_unregister);
+
+
+
+int __init clk_init(void)
+{
+	struct clk **  clkp;
+	const struct omap_clock_config *info;
+	int crystal_type = 0; /* Default 12 MHz */
+
+	for (clkp = onchip_clks; clkp < onchip_clks+ARRAY_SIZE(onchip_clks); clkp++) {
+		if (((*clkp)->flags &CLOCK_IN_OMAP1510) && cpu_is_omap1510()) {
+			clk_register(*clkp);
+			continue;
+		}
+
+		if (((*clkp)->flags &CLOCK_IN_OMAP16XX) && cpu_is_omap16xx()) {
+			clk_register(*clkp);
+			continue;
+		}
+	}
+
+	info = omap_get_config(OMAP_TAG_CLOCK, struct omap_clock_config);
+	if (info != NULL) {
+		if (!cpu_is_omap1510())
+			crystal_type = info->system_clock_type;
+	}
+
+#if defined(CONFIG_ARCH_OMAP730)
+	ck_ref.rate = 13000000;
+#elif defined(CONFIG_ARCH_OMAP16XX)
+	if (crystal_type == 2)
+		ck_ref.rate = 19200000;
+#endif
+
+	/* We want to be in syncronous scalable mode */
+	omap_writew(0x1000, ARM_SYSST);
+
+	/* Find the highest supported frequency and enable it */
+	if (select_table_rate(~0)) {
+		printk(KERN_ERR "System frequencies not set. Check your config.\n");
+		/* Guess sane values (60MHz) */
+		omap_writew(0x2290, DPLL_CTL);
+		omap_writew(0x1005, ARM_CKCTL);
+		ck_dpll1.rate = 60000000;
+		propagate_rate(&ck_dpll1);
+		printk(KERN_INFO "Clocking rate (xtal/DPLL1/MPU): %ld/%ld/%ld\n",
+		       ck_ref.rate, ck_dpll1.rate, arm_ck.rate);
+	}
+
+	/* Cache rates for clocks connected to ck_ref (not dpll1) */
+	propagate_rate(&ck_ref);
+
+#ifdef CONFIG_MACH_OMAP_PERSEUS2
+	/* Select slicer output as OMAP input clock */
+	omap_writew(omap_readw(OMAP730_PCC_UPLD_CTRL) & ~0x1, OMAP730_PCC_UPLD_CTRL);
+#endif
+
+	/* Turn off DSP and ARM_TIMXO. Make sure ARM_INTHCK is not divided */
+	omap_writew(omap_readw(ARM_CKCTL) & 0x0fff, ARM_CKCTL);
+
+	/* Put DSP/MPUI into reset until needed */
+	omap_writew(0, ARM_RSTCT1);
+	omap_writew(1, ARM_RSTCT2);
+	omap_writew(0x400, ARM_IDLECT1);
+
+	/*
+	 * According to OMAP5910 Erratum SYS_DMA_1, bit DMACK_REQ (bit 8)
+	 * of the ARM_IDLECT2 register must be set to zero. The power-on
+	 * default value of this bit is one.
+	 */
+	omap_writew(0x0000, ARM_IDLECT2);	/* Turn LCD clock off also */
+
+	/*
+	 * Only enable those clocks we will need, let the drivers
+	 * enable other clocks as necessary
+	 */
+	clk_use(&armper_ck);
+	clk_use(&armxor_ck);
+	clk_use(&armtim_ck);
+
+	if (cpu_is_omap1510())
+		clk_enable(&arm_gpio_ck);
+
+	return 0;
+}
diff -Nru a/arch/arm/mach-omap/clock.h b/arch/arm/mach-omap/clock.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-omap/clock.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,106 @@
+/*
+ *  linux/arch/arm/mach-omap/clock.h
+ *
+ *  Copyright (C) 2004 Nokia corporation
+ *  Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
+ *  Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
+ *
+ * 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.
+ */
+
+#ifndef __ARCH_ARM_OMAP_CLOCK_H
+#define __ARCH_ARM_OMAP_CLOCK_H
+
+struct module;
+
+struct clk {
+	struct list_head	node;
+	struct module		*owner;
+	const char		*name;
+	struct clk		*parent;
+	unsigned long		rate;
+	__s8			usecount;
+	__u8			flags;
+	__u32			enable_reg;
+	__u8			enable_bit;
+	__u8			rate_offset;
+	void			(*recalc)(struct clk *);
+	int			(*set_rate)(unsigned long);
+	long			(*round_rate)(unsigned long);
+};
+
+
+struct mpu_rate {
+	unsigned long		rate;
+	unsigned long		xtal;
+	unsigned long		pll_rate;
+	__u16			ckctl_val;
+	__u16			dpllctl_val;
+};
+
+
+/* Clock flags */
+#define RATE_CKCTL		1
+#define RATE_FIXED		2
+#define RATE_PROPAGATES		4
+#define VIRTUAL_CLOCK		8
+#define ALWAYS_ENABLED		16
+#define ENABLE_REG_32BIT	32
+#define CLOCK_IN_OMAP16XX	64
+#define CLOCK_IN_OMAP1510	128
+
+/* ARM_CKCTL bit shifts */
+#define CKCTL_PERDIV_OFFSET	0
+#define CKCTL_LCDDIV_OFFSET	2
+#define CKCTL_ARMDIV_OFFSET	4
+#define CKCTL_DSPDIV_OFFSET	6
+#define CKCTL_TCDIV_OFFSET	8
+#define CKCTL_DSPMMUDIV_OFFSET	10
+/*#define ARM_TIMXO		12*/
+#define EN_DSPCK		13
+/*#define ARM_INTHCK_SEL	14*/ /* Divide-by-2 for mpu inth_ck */
+
+/* ARM_IDLECT1 bit shifts */
+/*#define IDLWDT_ARM	0*/
+/*#define IDLXORP_ARM	1*/
+/*#define IDLPER_ARM	2*/
+/*#define IDLLCD_ARM	3*/
+/*#define IDLLB_ARM	4*/
+/*#define IDLHSAB_ARM	5*/
+/*#define IDLIF_ARM	6*/
+/*#define IDLDPLL_ARM	7*/
+/*#define IDLAPI_ARM	8*/
+/*#define IDLTIM_ARM	9*/
+/*#define SETARM_IDLE	11*/
+
+/* ARM_IDLECT2 bit shifts */
+#define EN_WDTCK	0
+#define EN_XORPCK	1
+#define EN_PERCK	2
+#define EN_LCDCK	3
+#define EN_LBCK		4 /* Not on 1610/1710 */
+/*#define EN_HSABCK	5*/
+#define EN_APICK	6
+#define EN_TIMCK	7
+#define DMACK_REQ	8
+#define EN_GPIOCK	9 /* Not on 1610/1710 */
+/*#define EN_LBFREECK	10*/
+#define EN_CKOUT_ARM	11
+
+/* ARM_IDLECT3 bit shifts */
+#define EN_OCPI_CK	0
+#define EN_TC1_CK	2
+#define EN_TC2_CK	4
+
+/* Various register defines for clock controls scattered around OMAP chip */
+#define USB_MCLK_EN		4	/* In ULPD_CLKC_CTRL */
+#define USB_HOST_HHC_UHOST_EN	9	/* In MOD_CONF_CTRL_0 */
+
+
+int clk_register(struct clk *clk);
+void clk_unregister(struct clk *clk);
+int clk_init(void);
+
+#endif
diff -Nru a/arch/arm/mach-omap/clocks.c b/arch/arm/mach-omap/clocks.c
--- a/arch/arm/mach-omap/clocks.c	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,705 +0,0 @@
-/*
- * Clock interface for OMAP
- *
- * Copyright (C) 2001 RidgeRun, Inc
- * Written by Gordon McNutt <gmcnutt@ridgerun.com>
- * Updated 2004 for Linux 2.6 by Tony Lindgren <tony@atomide.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/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/spinlock.h>
-#include <asm/errno.h>
-#include <asm/io.h>
-#include <asm/arch/clocks.h>
-#include <asm/arch/board.h>
-
-extern void start_mputimer1(unsigned long load_val);
-
-/* Input clock in MHz */
-static unsigned int source_clock = 12;
-
-/*
- * We use one spinlock for all clock registers for now. We may want to
- * change this to be clock register specific later on. Before we can do
- * that, we need to map out the shared clock registers.
- */
-static spinlock_t clock_lock = SPIN_LOCK_UNLOCKED;
-
-typedef struct {
-	char		*name;
-	__u8		flags;
-	ck_t		parent;
-	unsigned long	rate_reg;	/* Clock rate register */
-	unsigned long	enbl_reg;	/* Enable register */
-	unsigned long	idle_reg;	/* Idle register */
-	unsigned long	slct_reg;	/* Select register */
-	__s8		rate_shift;	/* Clock rate bit shift */
-	__s8		enbl_shift;	/* Clock enable bit shift */
-	__s8		idle_shift;	/* Clock idle bit shift */
-	__s8		slct_shift;	/* Clock select bit shift */
-} ck_info_t;
-
-#define CK_NAME(ck)		ck_info_table[ck].name
-#define CK_FLAGS(ck)		ck_info_table[ck].flags
-#define CK_PARENT(ck)		ck_info_table[ck].parent
-#define CK_RATE_REG(ck)		ck_info_table[ck].rate_reg
-#define CK_ENABLE_REG(ck)	ck_info_table[ck].enbl_reg
-#define CK_IDLE_REG(ck)		ck_info_table[ck].idle_reg
-#define CK_SELECT_REG(ck)	ck_info_table[ck].slct_reg
-#define CK_RATE_SHIFT(ck)	ck_info_table[ck].rate_shift
-#define CK_ENABLE_SHIFT(ck)	ck_info_table[ck].enbl_shift
-#define CK_IDLE_SHIFT(ck)	ck_info_table[ck].idle_shift
-#define CK_SELECT_SHIFT(ck)	ck_info_table[ck].slct_shift
-#define CK_CAN_CHANGE_RATE(cl)	(CK_FLAGS(ck) & CK_RATEF)
-#define CK_CAN_DISABLE(cl)	(CK_FLAGS(ck) & CK_ENABLEF)
-#define CK_CAN_IDLE(cl)		(CK_FLAGS(ck) & CK_IDLEF)
-#define CK_CAN_SWITCH(cl)	(CK_FLAGS(ck) & CK_SELECTF)
-
-static ck_info_t ck_info_table[] = {
-	{
-		.name		= "clkin",
-		.flags		= 0,
-		.parent		= OMAP_CLKIN,
-	}, {
-		.name		= "ck_gen1",
-		.flags		= CK_RATEF | CK_IDLEF,
-		.rate_reg	= DPLL_CTL,
-		.idle_reg	= ARM_IDLECT1,
-		.idle_shift	= IDLDPLL_ARM,
-		.parent		= OMAP_CLKIN,
-	}, {
-		.name		= "ck_gen2",
-		.flags		= 0,
-		.parent		= OMAP_CK_GEN1,
-	}, {
-		.name		= "ck_gen3",
-		.flags		= 0,
-		.parent		= OMAP_CK_GEN1,
-	}, {
-		.name		= "tc_ck",
-		.flags		= CK_RATEF | CK_IDLEF,
-		.parent		= OMAP_CK_GEN3,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[TCDIV(9:8)] */
-		.idle_reg	= ARM_IDLECT1,
-		.rate_shift	= TCDIV,
-		.idle_shift	= IDLIF_ARM
-	}, {
-		.name		= "arm_ck",
-		.flags		= CK_IDLEF | CK_RATEF,
-		.parent		= OMAP_CK_GEN1,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[ARMDIV(5:4)] */
-		.idle_reg	= ARM_IDLECT1,
-		.rate_shift	= ARMDIV,
-		.idle_shift	= SETARM_IDLE,
-	}, {
-		.name		= "mpuper_ck",
-		.flags		= CK_RATEF | CK_IDLEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN1,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[PERDIV(1:0)] */
-		.enbl_reg	= ARM_IDLECT2,
-		.idle_reg	= ARM_IDLECT1,
-		.rate_shift	= PERDIV,
-		.enbl_shift	= EN_PERCK,
-		.idle_shift	= IDLPER_ARM
-	}, {
-		.name		= "arm_gpio_ck",
-		.flags		= CK_ENABLEF,
-		.parent		= OMAP_CK_GEN1,
-		.enbl_reg	= ARM_IDLECT2,
-		.enbl_shift	= EN_GPIOCK
-	}, {
-		.name		= "mpuxor_ck",
-		.flags		= CK_ENABLEF | CK_IDLEF,
-		.parent		= OMAP_CLKIN,
-		.idle_reg	= ARM_IDLECT1,
-		.enbl_reg	= ARM_IDLECT2,
-		.idle_shift	= IDLXORP_ARM,
-		.enbl_shift	= EN_XORPCK
-	}, {
-		.name		= "mputim_ck",
-		.flags		= CK_IDLEF | CK_ENABLEF | CK_SELECTF,
-		.parent		= OMAP_CLKIN,
-		.idle_reg	= ARM_IDLECT1,
-		.enbl_reg	= ARM_IDLECT2,
-		.slct_reg	= ARM_CKCTL,
-		.idle_shift	= IDLTIM_ARM,
-		.enbl_shift	= EN_TIMCK,
-		.slct_shift	= ARM_TIMXO
-	}, {
-		.name		= "mpuwd_ck",
-		.flags		= CK_IDLEF | CK_ENABLEF,
-		.parent		= OMAP_CLKIN,
-		.idle_reg	= ARM_IDLECT1,
-		.enbl_reg	= ARM_IDLECT2,
-		.idle_shift	= IDLWDT_ARM,
-		.enbl_shift	= EN_WDTCK,
-	}, {
-		.name		= "dsp_ck",
-		.flags		= CK_RATEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN2,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[DSPDIV(7:6)] */
-		.enbl_reg	= ARM_CKCTL,
-		.rate_shift	= DSPDIV,
-		.enbl_shift	= EN_DSPCK,
-	}, {
-		.name		= "dspmmu_ck",
-		.flags		= CK_RATEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN2,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[DSPMMUDIV(11:10)] */
-		.enbl_reg	= ARM_CKCTL,
-		.rate_shift	= DSPMMUDIV,
-		.enbl_shift	= EN_DSPCK,
-	}, {
-		.name		= "dma_ck",
-		.flags		= CK_RATEF | CK_IDLEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN3,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[TCDIV(9:8)] */
-		.idle_reg	= ARM_IDLECT1,
-		.enbl_reg	= ARM_IDLECT2,
-		.rate_shift	= TCDIV,
-		.idle_shift	= IDLIF_ARM,
-		.enbl_shift	= DMACK_REQ
-	}, {
-		.name		= "api_ck",
-		.flags		= CK_RATEF | CK_IDLEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN3,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[TCDIV(9:8)] */
-		.idle_reg	= ARM_IDLECT1,
-		.enbl_reg	= ARM_IDLECT2,
-		.rate_shift	= TCDIV,
-		.idle_shift	= IDLAPI_ARM,
-		.enbl_shift	= EN_APICK,
-	}, {
-		.name		= "hsab_ck",
-		.flags		= CK_RATEF | CK_IDLEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN3,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[TCDIV(9:8)] */
-		.idle_reg	= ARM_IDLECT1,
-		.enbl_reg	= ARM_IDLECT2,
-		.rate_shift	= TCDIV,
-		.idle_shift	= IDLHSAB_ARM,
-		.enbl_shift	= EN_HSABCK,
-	}, {
-		.name		= "lbfree_ck",
-		.flags		= CK_RATEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN3,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[TCDIV(9:8)] */
-		.enbl_reg	= ARM_IDLECT2,
-		.rate_shift	= TCDIV,
-		.enbl_shift	= EN_LBFREECK,
-	}, {
-		.name		= "lb_ck",
-		.flags		= CK_RATEF | CK_IDLEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN3,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[TCDIV(9:8)] */
-		.idle_reg	= ARM_IDLECT1,
-		.enbl_reg	= ARM_IDLECT2,
-		.rate_shift	= TCDIV,
-		.idle_shift	= IDLLB_ARM,
-		.enbl_shift	= EN_LBCK,
-	}, {
-		.name		= "lcd_ck",
-		.flags		= CK_RATEF | CK_IDLEF | CK_ENABLEF,
-		.parent		= OMAP_CK_GEN3,
-		.rate_reg	= ARM_CKCTL,	/* ARM_CKCTL[LCDDIV(3:2)] */
-		.idle_reg	= ARM_IDLECT1,
-		.enbl_reg	= ARM_IDLECT2,
-		.rate_shift	= LCDDIV,
-		.idle_shift	= IDLLCD_ARM,
-		.enbl_shift	= EN_LCDCK,
-	},
-};
-
-/*****************************************************************************/
-
-#define CK_IN_RANGE(ck)		(!((ck < OMAP_CK_MIN) || (ck > OMAP_CK_MAX)))
-
-int ck_auto_unclock = 1;
-int ck_debug = 0;
-
-#define CK_MAX_PLL_FREQ		OMAP_CK_MAX_RATE
-static __u32 ck_valid_table[CK_MAX_PLL_FREQ / 32 + 1];
-static __u8 ck_lookup_table[CK_MAX_PLL_FREQ];
-
-int
-ck_set_input(ck_t ck, ck_t input)
-{
-	int ret = 0, shift;
-	unsigned short reg;
-	unsigned long flags;
-
-	if (!CK_IN_RANGE(ck) || !CK_CAN_SWITCH(ck)) {
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	reg = omap_readw(CK_SELECT_REG(ck));
-	shift = CK_SELECT_SHIFT(ck);
-
-	spin_lock_irqsave(&clock_lock, flags);
-	if (input == OMAP_CLKIN) {
-		reg &= ~(1 << shift);
-		omap_writew(reg, CK_SELECT_REG(ck));
-		goto exit;
-	} else if (input == CK_PARENT(ck)) {
-		reg |= (1 << shift);
-		omap_writew(reg, CK_SELECT_REG(ck));
-		goto exit;
-	}
-
-	ret = -EINVAL;
- exit:
-	spin_unlock_irqrestore(&clock_lock, flags);
-	return ret;
-}
-
-int
-ck_get_input(ck_t ck, ck_t * input)
-{
-	int ret = -EINVAL;
-	unsigned long flags;
-
-	if (!CK_IN_RANGE(ck))
-		goto exit;
-
-	ret = 0;
-
-	spin_lock_irqsave(&clock_lock, flags);
-	if (CK_CAN_SWITCH(ck)) {
-		int shift;
-		unsigned short reg;
-
-		reg = omap_readw(CK_SELECT_REG(ck));
-		shift = CK_SELECT_SHIFT(ck);
-		if (reg & (1 << shift)) {
-			*input = CK_PARENT(ck);
-			goto exit;
-		}
-	}
-
-	*input = OMAP_CLKIN;
-
- exit:
-	spin_unlock_irqrestore(&clock_lock, flags);
-	return ret;
-}
-
-static int
-__ck_set_pll_rate(ck_t ck, int rate)
-{
-	unsigned short pll;
-	unsigned long flags;
-
-	if ((rate < 0) || (rate > CK_MAX_PLL_FREQ))
-		return -EINVAL;
-
-	/* Scan downward for the closest matching frequency */
-	while (rate && !test_bit(rate, (unsigned long *)&ck_valid_table))
-		rate--;
-
-	if (!rate) {
-		printk(KERN_ERR "%s: couldn't find a matching rate\n",
-			__FUNCTION__);
-		return -EINVAL;
-	}
-
-	spin_lock_irqsave(&clock_lock, flags);
-	pll = omap_readw(CK_RATE_REG(ck));
-
-	/* Clear the rate bits */
-	pll &= ~(0x1f << 5);
-
-	/* Set the rate bits */
-	pll |= (ck_lookup_table[rate - 1] << 5);
-
-	omap_writew(pll, CK_RATE_REG(ck));
-
-	spin_unlock_irqrestore(&clock_lock, flags);
-
-	return 0;
-}
-
-static int
-__ck_set_clkm_rate(ck_t ck, int rate)
-{
-	int shift, prate, div, ret;
-	unsigned short reg;
-	unsigned long flags;
-
-	spin_lock_irqsave(&clock_lock, flags);
-
-	/*
-	 * We can only set this clock's value to a fraction of its
-	 * parent's value. The interface says I'll round down when necessary.
-	 * So first let's get the parent's current rate.
-	 */
-	prate = ck_get_rate(CK_PARENT(ck));
-
-	/*
-	 * Let's just start with the highest fraction and keep searching
-	 * down through available rates until we find one less than or equal
-	 * to the desired rate.
-	 */
-	for (div = 0; div < 4; div++) {
-		if (prate <= rate)
-			break;
-		prate = prate / 2;
-	}
-
-	/*
-	 * Oops. Looks like the caller wants a rate lower than we can support.
-	 */
-	if (div == 5) {
-		printk(KERN_ERR "%s: %d is too low\n",
-			__FUNCTION__, rate);
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	/*
-	 * One more detail: if this clock supports more than one parent, then
-	 * we're going to automatically switch over to the parent which runs
-	 * through the divisor. For omap this is not ambiguous because for all
-	 * such clocks one choice is always OMAP_CLKIN (which doesn't run
-	 * through the divisor) and the other is whatever I encoded as
-	 * CK_PARENT. Note that I wait until we get this far because I don't
-	 * want to switch the input until we're sure this is going to work.
-	 */
-	if (CK_CAN_SWITCH(ck))
-		if ((ret = ck_set_input(ck, CK_PARENT(ck))) < 0) {
-			BUG();
-			goto exit;
-		}
-
-	/*
-	 * At last, we can set the divisor. Clear the old rate bits and
-	 * set the new ones.
-	 */
-	reg = omap_readw(CK_RATE_REG(ck));
-	shift = CK_RATE_SHIFT(ck);
-	reg &= ~(3 << shift);
-	reg |= (div << shift);
-	omap_writew(reg, CK_RATE_REG(ck));
-
-	/* And return the new (actual, after rounding down) rate. */
-	ret = prate;
-
- exit:
-	spin_unlock_irqrestore(&clock_lock, flags);
-	return ret;
-}
-
-int
-ck_set_rate(ck_t ck, int rate)
-{
-	int ret = -EINVAL;
-
-	if (!CK_IN_RANGE(ck) || !CK_CAN_CHANGE_RATE(ck))
-		goto exit;
-
-	switch (ck) {
-
-	default:
-		ret = __ck_set_clkm_rate(ck, rate);
-		break;
-
-	case OMAP_CK_GEN1:
-		ret = __ck_set_pll_rate(ck, rate);
-		break;
-
-	};
-
- exit:
-	return ret;
-}
-
-static int
-__ck_get_pll_rate(ck_t ck)
-{
-	int m, d;
-
-	unsigned short pll = omap_readw(CK_RATE_REG(ck));
-
-	m = (pll & (0x1f << 7)) >> 7;
-	m = m ? m : 1;
-	d = (pll & (3 << 5)) >> 5;
-	d++;
-
-	return ((source_clock * m) / d);
-}
-
-static int
-__ck_get_clkm_rate(ck_t ck)
-{
-	static int bits2div[] = { 1, 2, 4, 8 };
-	int in, bits, reg, shift;
-
-	reg = omap_readw(CK_RATE_REG(ck));
-	shift = CK_RATE_SHIFT(ck);
-
-	in = ck_get_rate(CK_PARENT(ck));
-	bits = (reg & (3 << shift)) >> shift;
-
-	return (in / bits2div[bits]);
-}
-
-int
-ck_get_rate(ck_t ck)
-{
-	int ret = 0;
-	ck_t parent;
-
-	if (!CK_IN_RANGE(ck)) {
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	switch (ck) {
-
-	case OMAP_CK_GEN1:
-		ret = __ck_get_pll_rate(ck);
-		break;
-
-	case OMAP_CLKIN:
-		ret = source_clock;
-		break;
-
-	case OMAP_MPUXOR_CK:
-	case OMAP_CK_GEN2:
-	case OMAP_CK_GEN3:
-	case OMAP_ARM_GPIO_CK:
-		ret = ck_get_rate(CK_PARENT(ck));
-		break;
-
-	case OMAP_ARM_CK:
-	case OMAP_MPUPER_CK:
-	case OMAP_DSP_CK:
-	case OMAP_DSPMMU_CK:
-	case OMAP_LCD_CK:
-	case OMAP_TC_CK:
-	case OMAP_DMA_CK:
-	case OMAP_API_CK:
-	case OMAP_HSAB_CK:
-	case OMAP_LBFREE_CK:
-	case OMAP_LB_CK:
-		ret = __ck_get_clkm_rate(ck);
-		break;
-
-	case OMAP_MPUTIM_CK:
-		ck_get_input(ck, &parent);
-		ret = ck_get_rate(parent);
-		break;
-
-	case OMAP_MPUWD_CK:
-		/* Note that this evaluates to zero if source_clock is 12MHz. */
-		ret = source_clock / 14;
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
- exit:
-	return ret;
-}
-
-int
-ck_enable(ck_t ck)
-{
-	unsigned short reg;
-	int ret = -EINVAL, shift;
-	unsigned long flags;
-
-	if (!CK_IN_RANGE(ck))
-		goto exit;
-
-	if (ck_debug)
-		printk(KERN_DEBUG "%s: %s\n", __FUNCTION__, CK_NAME(ck));
-
-	ret = 0;
-
-	if (!CK_CAN_DISABLE(ck))
-		/* Then it must be on... */
-		goto exit;
-
-	spin_lock_irqsave(&clock_lock, flags);
-	reg = omap_readw(CK_ENABLE_REG(ck));
-	shift = CK_ENABLE_SHIFT(ck);
-	reg |= (1 << shift);
-	omap_writew(reg, CK_ENABLE_REG(ck));
-	spin_unlock_irqrestore(&clock_lock, flags);
-
- exit:
-	return ret;
-}
-
-int
-ck_disable(ck_t ck)
-{
-	unsigned short reg;
-	int ret = -EINVAL, shift;
-	unsigned long flags;
-
-	if (!CK_IN_RANGE(ck))
-		goto exit;
-
-	if (ck_debug)
-		printk(KERN_DEBUG "%s: %s\n", __FUNCTION__, CK_NAME(ck));
-
-	if (!CK_CAN_DISABLE(ck))
-		goto exit;
-
-	ret = 0;
-
-	if (ck == OMAP_CLKIN)
-		return -EINVAL;
-
-	spin_lock_irqsave(&clock_lock, flags);
-	reg = omap_readw(CK_ENABLE_REG(ck));
-	shift = CK_ENABLE_SHIFT(ck);
-	reg &= ~(1 << shift);
-	omap_writew(reg, CK_ENABLE_REG(ck));
-	spin_unlock_irqrestore(&clock_lock, flags);
-
- exit:
-	return ret;
-}
-
-int ck_valid_rate(int rate)
-{
-	return test_bit(rate, (unsigned long *)&ck_valid_table);
-}
-
-static void
-__ck_make_lookup_table(void)
-{
-	__u8 m, d;
-
-	memset(ck_valid_table, 0, sizeof (ck_valid_table));
-
-	for (m = 1; m < 32; m++)
-		for (d = 1; d < 5; d++) {
-
-			int rate = ((source_clock * m) / (d));
-
-			if (rate > CK_MAX_PLL_FREQ)
-				continue;
-			if (test_bit(rate, (unsigned long *)&ck_valid_table))
-				continue;
-			set_bit(rate, (unsigned long *)&ck_valid_table);
-			ck_lookup_table[rate - 1] = (m << 2) | (d - 1);
-		}
-}
-
-int __init
-init_ck(void)
-{
-	const struct omap_clock_config *info;
-	int crystal_type = 0; /* Default 12 MHz */
-
-	__ck_make_lookup_table();
-	info = omap_get_config(OMAP_TAG_CLOCK, struct omap_clock_config);
-	if (info != NULL) {
-		if (!cpu_is_omap1510())
-			crystal_type = info->system_clock_type;
-	}
-
-	/* We want to be in syncronous scalable mode */
-	omap_writew(0x1000, ARM_SYSST);
-#if defined(CONFIG_OMAP_ARM_30MHZ)
-	omap_writew(0x1555, ARM_CKCTL);
-	omap_writew(0x2290, DPLL_CTL);
-#elif defined(CONFIG_OMAP_ARM_60MHZ)
-	omap_writew(0x1005, ARM_CKCTL);
-	omap_writew(0x2290, DPLL_CTL);
-#elif defined(CONFIG_OMAP_ARM_96MHZ)
-	omap_writew(0x1005, ARM_CKCTL);
-	omap_writew(0x2410, DPLL_CTL);
-#elif defined(CONFIG_OMAP_ARM_120MHZ)
-	omap_writew(0x110a, ARM_CKCTL);
-	omap_writew(0x2510, DPLL_CTL);
-#elif defined(CONFIG_OMAP_ARM_168MHZ)
-	omap_writew(0x110f, ARM_CKCTL);
-	omap_writew(0x2710, DPLL_CTL);
-#elif defined(CONFIG_OMAP_ARM_182MHZ) && defined(CONFIG_ARCH_OMAP730)
-	omap_writew(0x250E, ARM_CKCTL);
-	omap_writew(0x2710, DPLL_CTL);
-#elif defined(CONFIG_OMAP_ARM_192MHZ) && (defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP5912) \
-					  || defined(CONFIG_ARCH_OMAP1710))
-	omap_writew(0x150f, ARM_CKCTL);
-	if (crystal_type == 2) {
-		source_clock = 13;	/* MHz */
-		omap_writew(0x2510, DPLL_CTL);
-	} else
-		omap_writew(0x2810, DPLL_CTL);
-#elif defined(CONFIG_OMAP_ARM_195MHZ) && defined(CONFIG_ARCH_OMAP730)
-	omap_writew(0x250E, ARM_CKCTL);
-	omap_writew(0x2790, DPLL_CTL);
-#else
-#error "OMAP MHZ not set, please run make xconfig"
-#endif
-
-#ifdef CONFIG_MACH_OMAP_PERSEUS2
-	/* Select slicer output as OMAP input clock */
-	omap_writew(omap_readw(OMAP730_PCC_UPLD_CTRL) & ~0x1, OMAP730_PCC_UPLD_CTRL);
-#endif
-
-	/* Turn off some other junk the bootloader might have turned on */
-
-	/* Turn off DSP, ARM_INTHCK, ARM_TIMXO */
-	omap_writew(omap_readw(ARM_CKCTL) & 0x0fff, ARM_CKCTL);
-
-	/* Put DSP/MPUI into reset until needed */
-	omap_writew(0, ARM_RSTCT1);
-	omap_writew(1, ARM_RSTCT2);
-	omap_writew(0x400, ARM_IDLECT1);
-
-	/*
-	 * According to OMAP5910 Erratum SYS_DMA_1, bit DMACK_REQ (bit 8)
-	 * of the ARM_IDLECT2 register must be set to zero. The power-on
-	 * default value of this bit is one.
-	 */
-	omap_writew(0x0000, ARM_IDLECT2);	/* Turn LCD clock off also */
-
-	/*
-	 * Only enable those clocks we will need, let the drivers
-	 * enable other clocks as necessary
-	 */
-	ck_enable(OMAP_MPUPER_CK);
-	ck_enable(OMAP_ARM_GPIO_CK);
-	ck_enable(OMAP_MPUXOR_CK);
-	//ck_set_rate(OMAP_MPUTIM_CK, OMAP_CLKIN);
-	ck_enable(OMAP_MPUTIM_CK);
-	start_mputimer1(0xffffffff);
-
-	return 0;
-}
-
-
-EXPORT_SYMBOL(ck_get_rate);
-EXPORT_SYMBOL(ck_set_rate);
-EXPORT_SYMBOL(ck_enable);
-EXPORT_SYMBOL(ck_disable);
diff -Nru a/arch/arm/mach-omap/common.c b/arch/arm/mach-omap/common.c
--- a/arch/arm/mach-omap/common.c	2004-12-24 13:37:29 -08:00
+++ b/arch/arm/mach-omap/common.c	2004-12-24 13:37:29 -08:00
@@ -14,65 +14,195 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/console.h>
+#include <linux/serial.h>
+#include <linux/tty.h>
+#include <linux/serial_8250.h>
+#include <linux/serial_reg.h>
 
 #include <asm/hardware.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
 #include <asm/mach/map.h>
-#include <asm/arch/clocks.h>
-#include <asm/arch/board.h>
+#include <asm/hardware/clock.h>
 #include <asm/io.h>
+#include <asm/mach-types.h>
+
+#include <asm/arch/board.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/fpga.h>
+#include <asm/arch/serial.h>
+
+
+#include "clock.h"
+
+#define DEBUG 1
+
+struct omap_id {
+	u16	jtag_id;	/* Used to determine OMAP type */
+	u8	die_rev;	/* Processor revision */
+	u32	omap_id;	/* OMAP revision */
+	u32	type;		/* Cpu id bits [31:08], cpu class bits [07:00] */
+};
+
+/* Register values to detect the OMAP version */
+static struct omap_id omap_ids[] __initdata = {
+	{ .jtag_id = 0x355f, .die_rev = 0x0, .omap_id = 0x03320000, .type = 0x07300100},
+	{ .jtag_id = 0xb55f, .die_rev = 0x0, .omap_id = 0x03320000, .type = 0x07300300},
+	{ .jtag_id = 0xb470, .die_rev = 0x0, .omap_id = 0x03310100, .type = 0x15100000},
+	{ .jtag_id = 0xb576, .die_rev = 0x0, .omap_id = 0x03320000, .type = 0x16100000},
+	{ .jtag_id = 0xb576, .die_rev = 0x2, .omap_id = 0x03320100, .type = 0x16110000},
+	{ .jtag_id = 0xb576, .die_rev = 0x3, .omap_id = 0x03320100, .type = 0x16100c00},
+	{ .jtag_id = 0xb576, .die_rev = 0x0, .omap_id = 0x03320200, .type = 0x16100d00},
+	{ .jtag_id = 0xb613, .die_rev = 0x0, .omap_id = 0x03320300, .type = 0x1610ef00},
+	{ .jtag_id = 0xb613, .die_rev = 0x0, .omap_id = 0x03320300, .type = 0x1610ef00},
+	{ .jtag_id = 0xb576, .die_rev = 0x1, .omap_id = 0x03320100, .type = 0x16110000},
+	{ .jtag_id = 0xb58c, .die_rev = 0x2, .omap_id = 0x03320200, .type = 0x16110b00},
+	{ .jtag_id = 0xb58c, .die_rev = 0x3, .omap_id = 0x03320200, .type = 0x16110c00},
+	{ .jtag_id = 0xb65f, .die_rev = 0x0, .omap_id = 0x03320400, .type = 0x16212300},
+	{ .jtag_id = 0xb65f, .die_rev = 0x1, .omap_id = 0x03320400, .type = 0x16212300},
+	{ .jtag_id = 0xb65f, .die_rev = 0x1, .omap_id = 0x03320500, .type = 0x16212300},
+	{ .jtag_id = 0xb5f7, .die_rev = 0x0, .omap_id = 0x03330000, .type = 0x17100000},
+	{ .jtag_id = 0xb5f7, .die_rev = 0x1, .omap_id = 0x03330100, .type = 0x17100000},
+	{ .jtag_id = 0xb5f7, .die_rev = 0x2, .omap_id = 0x03330100, .type = 0x17100000},
+};
 
 /*
- * ----------------------------------------------------------------------------
- * OMAP revision check
- *
- * Since we use the cpu_is_omapnnnn() macros, there's a chance that a board
- * switches to an updated core. We want to print out the OMAP revision early.
- *
- * We use the system_serial registers for the revision information so we
- * can see it in /proc/cpuinfo.
- *
- * If the OMAP detection gets more complicated, we may want to expand this
- * to store the OMAP version and replace the current cpu_is_omapnnnn() macros.
- *
- * ----------------------------------------------------------------------------
+ * Get OMAP type from PROD_ID.
+ * 1710 has the PROD_ID in bits 15:00, not in 16:01 as documented in TRM.
+ * 1510 PROD_ID is empty, and 1610 PROD_ID does not make sense.
+ * Undocumented register in TEST BLOCK is used as fallback; This seems to
+ * work on 1510, 1610 & 1710. The official way hopefully will work in future
+ * processors.
+ */
+static u16 __init omap_get_jtag_id(void)
+{
+	u32 prod_id, omap_id;
+
+	prod_id = omap_readl(OMAP_PRODUCTION_ID_1);
+	omap_id = omap_readl(OMAP32_ID_1);
+
+	/* Check for unusable OMAP_PRODUCTION_ID_1 on 1611B/5912 and 730 */
+	if (((prod_id >> 20) == 0) || (prod_id == omap_id))
+		prod_id = 0;
+	else
+		prod_id &= 0xffff;
+
+	if (prod_id)
+		return prod_id;
+
+	/* Use OMAP32_ID_1 as fallback */
+	prod_id = ((omap_id >> 12) & 0xffff);
+
+	return prod_id;
+}
+
+/*
+ * Get OMAP revision from DIE_REV.
+ * Early 1710 processors may have broken OMAP_DIE_ID, it contains PROD_ID.
+ * Undocumented register in the TEST BLOCK is used as fallback.
+ * REVISIT: This does not seem to work on 1510
  */
+static u8 __init omap_get_die_rev(void)
+{
+	u32 die_rev;
+
+	die_rev = omap_readl(OMAP_DIE_ID_1);
+
+	/* Check for broken OMAP_DIE_ID on early 1710 */
+	if (((die_rev >> 12) & 0xffff) == omap_get_jtag_id())
+		die_rev = 0;
+
+	die_rev = (die_rev >> 17) & 0xf;
+	if (die_rev)
+		return die_rev;
+
+	die_rev = (omap_readl(OMAP32_ID_1) >> 28) & 0xf;
+
+	return die_rev;
+}
+
 static void __init omap_check_revision(void)
 {
-	system_serial_high = omap_readl(OMAP_ID_BASE);
-	system_serial_low = OMAP_ID_REG;
-	system_rev = (OMAP_ID_REG >> ID_SHIFT) & ID_MASK;
-
-	printk("OMAP revision: %d.%d (0x%08x) id: 0x%08x detected as OMAP-",
-	       (system_serial_high >> 20) & 0xf,
-	       (system_serial_high >> 16) & 0xf,
-	       system_serial_high, system_serial_low);
-
-	switch (system_rev) {
-	case OMAP_ID_730:
-		printk("730\n");
-		system_rev = 0x730;
-		break;
-	case OMAP_ID_1510:
-		printk("1510\n");
-		system_rev = 0x1510;
+	int i;
+	u16 jtag_id;
+	u8 die_rev;
+	u32 omap_id;
+	u8 cpu_type;
+
+	jtag_id = omap_get_jtag_id();
+	die_rev = omap_get_die_rev();
+	omap_id = omap_readl(OMAP32_ID_0);
+
+#ifdef DEBUG
+	printk("OMAP_DIE_ID_0: 0x%08x\n", omap_readl(OMAP_DIE_ID_0));
+	printk("OMAP_DIE_ID_1: 0x%08x DIE_REV: %i\n",
+		omap_readl(OMAP_DIE_ID_1),
+	       (omap_readl(OMAP_DIE_ID_1) >> 17) & 0xf);
+	printk("OMAP_PRODUCTION_ID_0: 0x%08x\n", omap_readl(OMAP_PRODUCTION_ID_0));
+	printk("OMAP_PRODUCTION_ID_1: 0x%08x JTAG_ID: 0x%04x\n",
+		omap_readl(OMAP_PRODUCTION_ID_1),
+		omap_readl(OMAP_PRODUCTION_ID_1) & 0xffff);
+	printk("OMAP32_ID_0: 0x%08x\n", omap_readl(OMAP32_ID_0));
+	printk("OMAP32_ID_1: 0x%08x\n", omap_readl(OMAP32_ID_1));
+	printk("JTAG_ID: 0x%04x DIE_REV: %i\n", jtag_id, die_rev);
+#endif
+
+	system_serial_high = omap_readl(OMAP_DIE_ID_0);
+	system_serial_low = omap_readl(OMAP_DIE_ID_1);
+
+	/* First check only the major version in a safe way */
+	for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
+		if (jtag_id == (omap_ids[i].jtag_id)) {
+			system_rev = omap_ids[i].type;
+			break;
+		}
+	}
+
+	/* Check if we can find the die revision */
+	for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
+		if (jtag_id == omap_ids[i].jtag_id && die_rev == omap_ids[i].die_rev) {
+			system_rev = omap_ids[i].type;
+			break;
+		}
+	}
+
+	/* Finally check also the omap_id */
+	for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
+		if (jtag_id == omap_ids[i].jtag_id
+		    && die_rev == omap_ids[i].die_rev
+		    && omap_id == omap_ids[i].omap_id) {
+			system_rev = omap_ids[i].type;
+			break;
+		}
+	}
+
+	/* Add the cpu class info (7xx, 15xx, 16xx, 24xx) */
+	cpu_type = system_rev >> 24;
+
+	switch (cpu_type) {
+	case 0x07:
+		system_rev |= 0x07;
 		break;
-	case OMAP_ID_1610:
-		printk("1610\n");
-		system_rev = 0x1610;
+	case 0x15:
+		system_rev |= 0x15;
 		break;
-	case OMAP_ID_1710:
-		printk("1710\n");
-		system_rev = 0x1710;
+	case 0x16:
+	case 0x17:
+		system_rev |= 0x16;
 		break;
-	case OMAP_ID_5912:
-		printk("5912/1611B\n");
-		system_rev = 0x5912;
+	case 0x24:
+		system_rev |= 0x24;
 		break;
 	default:
-		printk("unknown, please add support!\n");
+		printk("Unknown OMAP cpu type: 0x%02x\n", cpu_type);
 	}
+
+	printk("OMAP%04x", system_rev >> 16);
+	if ((system_rev >> 8) & 0xff)
+		printk("%x", (system_rev >> 8) & 0xff);
+	printk(" revision %i handled as %02xxx id: %08x%08x\n",
+	       die_rev, system_rev & 0xff, system_serial_low,
+	       system_serial_high);
 }
 
 /*
@@ -104,25 +234,23 @@
 };
 #endif
 
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710)
+#if defined(CONFIG_ARCH_OMAP16XX)
 static struct map_desc omap1610_io_desc[] __initdata = {
- { OMAP1610_DSP_BASE,    OMAP1610_DSP_START,    OMAP1610_DSP_SIZE,    MT_DEVICE },
- { OMAP1610_DSPREG_BASE, OMAP1610_DSPREG_START, OMAP1610_DSPREG_SIZE, MT_DEVICE },
- { OMAP1610_SRAM_BASE,   OMAP1610_SRAM_START,   OMAP1610_SRAM_SIZE,   MT_DEVICE }
+ { OMAP16XX_DSP_BASE,    OMAP16XX_DSP_START,    OMAP16XX_DSP_SIZE,    MT_DEVICE },
+ { OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_START, OMAP16XX_DSPREG_SIZE, MT_DEVICE },
+ { OMAP16XX_SRAM_BASE,   OMAP16XX_SRAM_START,   OMAP1610_SRAM_SIZE,   MT_DEVICE }
 };
-#endif
 
-#ifdef CONFIG_ARCH_OMAP5912
 static struct map_desc omap5912_io_desc[] __initdata = {
- { OMAP5912_DSP_BASE,    OMAP5912_DSP_START,    OMAP5912_DSP_SIZE,    MT_DEVICE },
- { OMAP5912_DSPREG_BASE, OMAP5912_DSPREG_START, OMAP5912_DSPREG_SIZE, MT_DEVICE },
+ { OMAP16XX_DSP_BASE,    OMAP16XX_DSP_START,    OMAP16XX_DSP_SIZE,    MT_DEVICE },
+ { OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_START, OMAP16XX_DSPREG_SIZE, MT_DEVICE },
 /*
  * The OMAP5912 has 250kByte internal SRAM. Because the mapping is baseed on page
  * size (4kByte), it seems that the last 2kByte (=0x800) of the 250kByte are not mapped.
  * Add additional 2kByte (0x800) so that the last page is mapped and the last 2kByte
  * can be used.
  */
- { OMAP5912_SRAM_BASE,   OMAP5912_SRAM_START,   OMAP5912_SRAM_SIZE + 0x800,   MT_DEVICE }
+ { OMAP16XX_SRAM_BASE,   OMAP16XX_SRAM_START,   OMAP5912_SRAM_SIZE + 0x800,   MT_DEVICE }
 };
 #endif
 
@@ -137,6 +265,9 @@
 	iotable_init(omap_io_desc, ARRAY_SIZE(omap_io_desc));
 	omap_check_revision();
 
+	/* clear BM to canonicalize CS0 (not CS3) at 0000:0000 */
+	omap_writel(omap_readl(EMIFS_CONFIG) & 0x0d, EMIFS_CONFIG);
+
 #ifdef CONFIG_ARCH_OMAP730
 	if (cpu_is_omap730()) {
 		iotable_init(omap730_io_desc, ARRAY_SIZE(omap730_io_desc));
@@ -147,12 +278,10 @@
 		iotable_init(omap1510_io_desc, ARRAY_SIZE(omap1510_io_desc));
 	}
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710)
+#if defined(CONFIG_ARCH_OMAP16XX)
 	if (cpu_is_omap1610() || cpu_is_omap1710()) {
 		iotable_init(omap1610_io_desc, ARRAY_SIZE(omap1610_io_desc));
 	}
-#endif
-#ifdef CONFIG_ARCH_OMAP5912
 	if (cpu_is_omap5912()) {
 		iotable_init(omap5912_io_desc, ARRAY_SIZE(omap5912_io_desc));
 	}
@@ -166,7 +295,7 @@
 
 	/* Must init clocks early to assure that timer interrupt works
 	 */
-	init_ck();
+	clk_init();
 }
 
 /*
@@ -178,26 +307,173 @@
 		_omap_map_io();
 }
 
+static inline unsigned int omap_serial_in(struct plat_serial8250_port *up, 
+					  int offset)
+{
+	offset <<= up->regshift;
+	return (unsigned int)__raw_readb(up->membase + offset);
+}
+
+static inline void omap_serial_outp(struct plat_serial8250_port *p, int offset, 
+				    int value)
+{
+	offset <<= p->regshift;
+	__raw_writeb(value, p->membase + offset);
+}
+
+/*
+ * Internal UARTs need to be initialized for the 8250 autoconfig to work
+ * properly.
+ */
+static void __init omap_serial_reset(struct plat_serial8250_port *p)
+{
+	omap_serial_outp(p, UART_OMAP_MDR1, 0x07); /* disable UART */
+	omap_serial_outp(p, UART_OMAP_MDR1, 0x00); /* enable UART */
+
+	if (!cpu_is_omap1510()) {
+		omap_serial_outp(p, UART_OMAP_SYSC, 0x01);
+		while (!(omap_serial_in(p, UART_OMAP_SYSC) & 0x01));
+	}
+}
+
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.membase	= (char*)IO_ADDRESS(OMAP_UART1_BASE),
+		.mapbase	= (unsigned long)OMAP_UART1_BASE,
+		.irq		= INT_UART1,
+		.flags		= UPF_BOOT_AUTOCONF,
+		.iotype		= UPIO_MEM,
+		.regshift	= 2,
+		.uartclk	= OMAP16XX_BASE_BAUD * 16,
+	},
+	{
+		.membase	= (char*)IO_ADDRESS(OMAP_UART2_BASE),
+		.mapbase	= (unsigned long)OMAP_UART2_BASE,
+		.irq		= INT_UART2,
+		.flags		= UPF_BOOT_AUTOCONF,
+		.iotype		= UPIO_MEM,
+		.regshift	= 2,
+		.uartclk	= OMAP16XX_BASE_BAUD * 16,
+	},
+	{
+		.membase	= (char*)IO_ADDRESS(OMAP_UART3_BASE),
+		.mapbase	= (unsigned long)OMAP_UART3_BASE,
+		.irq		= INT_UART3,
+		.flags		= UPF_BOOT_AUTOCONF,
+		.iotype		= UPIO_MEM,
+		.regshift	= 2,
+		.uartclk	= OMAP16XX_BASE_BAUD * 16,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= 0,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
+/*
+ * Note that on Innovator-1510 UART2 pins conflict with USB2.
+ * By default UART2 does not work on Innovator-1510 if you have
+ * USB OHCI enabled. To use UART2, you must disable USB2 first.
+ */
+void __init omap_serial_init(int ports[OMAP_MAX_NR_PORTS])
+{
+	int i;
+
+	if (cpu_is_omap730()) {
+		serial_platform_data[0].regshift = 0;
+		serial_platform_data[1].regshift = 0;
+		serial_platform_data[0].irq = INT_730_UART_MODEM_1;
+		serial_platform_data[1].irq = INT_730_UART_MODEM_IRDA_2;
+	}
+
+	if (cpu_is_omap1510()) {
+		serial_platform_data[0].uartclk = OMAP1510_BASE_BAUD * 16;
+		serial_platform_data[1].uartclk = OMAP1510_BASE_BAUD * 16;
+		serial_platform_data[2].uartclk = OMAP1510_BASE_BAUD * 16;
+	}
+
+	for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
+		unsigned char reg;
+
+		if (ports[i] == 0) {
+			serial_platform_data[i].membase = 0;
+			serial_platform_data[i].mapbase = 0;
+			continue;
+		}
+
+		switch (i) {
+		case 0:
+			if (cpu_is_omap1510()) {
+				omap_cfg_reg(UART1_TX);
+				omap_cfg_reg(UART1_RTS);
+				if (machine_is_omap_innovator()) {
+					reg = fpga_read(OMAP1510_FPGA_POWER);
+					reg |= OMAP1510_FPGA_PCR_COM1_EN;
+					fpga_write(reg, OMAP1510_FPGA_POWER);
+					udelay(10);
+				}
+			}
+			break;
+		case 1:
+			if (cpu_is_omap1510()) {
+				omap_cfg_reg(UART2_TX);
+				omap_cfg_reg(UART2_RTS);
+				if (machine_is_omap_innovator()) {
+					reg = fpga_read(OMAP1510_FPGA_POWER);
+					reg |= OMAP1510_FPGA_PCR_COM2_EN;
+					fpga_write(reg, OMAP1510_FPGA_POWER);
+					udelay(10);
+				}
+			}
+			break;
+		case 2:
+			if (cpu_is_omap1510()) {
+				omap_cfg_reg(UART3_TX);
+				omap_cfg_reg(UART3_RX);
+			}
+			break;
+		}
+		omap_serial_reset(&serial_platform_data[i]);
+	}
+}
+
+static int __init omap_init(void)
+{
+	return platform_device_register(&serial_device);
+}
+arch_initcall(omap_init);
+
+#define NO_LENGTH_CHECK 0xffffffff
+
 extern int omap_bootloader_tag_len;
 extern u8 omap_bootloader_tag[];
 
 struct omap_board_config_kernel *omap_board_config;
 int omap_board_config_size = 0;
 
-const void *__omap_get_config(u16 tag, size_t len)
+static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
 {
-	struct omap_board_config_entry *info = NULL;
 	struct omap_board_config_kernel *kinfo = NULL;
 	int i;
 
 #ifdef CONFIG_OMAP_BOOT_TAG
+	struct omap_board_config_entry *info = NULL;
+
 	if (omap_bootloader_tag_len > 4)
 		info = (struct omap_board_config_entry *) omap_bootloader_tag;
 	while (info != NULL) {
 		u8 *next;
 
-		if (info->tag == tag)
-			break;
+		if (info->tag == tag) {
+			if (skip == 0)
+				break;
+			skip--;
+		}
 
 		next = (u8 *) info + sizeof(*info) + info->len;
 		if (next >= omap_bootloader_tag + omap_bootloader_tag_len)
@@ -208,11 +484,13 @@
 	if (info != NULL) {
 		/* Check the length as a lame attempt to check for
 		 * binary inconsistancy. */
-		if (info->len != len) {
+		if (len != NO_LENGTH_CHECK && info->len != len) {
 			printk(KERN_ERR "OMAP peripheral config: Length mismatch with tag %x (want %d, got %d)\n",
 			       tag, len, info->len);
 			return NULL;
 		}
+		if (len_out != NULL)
+			*len_out = info->len;
 		return info->data;
 	}
 #endif
@@ -228,7 +506,18 @@
 		return NULL;
 	return kinfo->data;
 }
+
+const void *__omap_get_config(u16 tag, size_t len, int nr)
+{
+        return get_config(tag, len, nr, NULL);
+}
 EXPORT_SYMBOL(__omap_get_config);
+
+const void *omap_get_var_config(u16 tag, size_t *len)
+{
+        return get_config(tag, NO_LENGTH_CHECK, 0, len);
+}
+EXPORT_SYMBOL(omap_get_var_config);
 
 static int __init omap_add_serial_console(void)
 {
diff -Nru a/arch/arm/mach-omap/common.h b/arch/arm/mach-omap/common.h
--- a/arch/arm/mach-omap/common.h	2004-12-24 13:36:56 -08:00
+++ b/arch/arm/mach-omap/common.h	2004-12-24 13:36:56 -08:00
@@ -27,8 +27,10 @@
 #ifndef __ARCH_ARM_MACH_OMAP_COMMON_H
 #define __ARCH_ARM_MACH_OMAP_COMMON_H
 
+struct sys_timer;
+
 extern void omap_map_io(void);
+extern struct sys_timer omap_timer;
+extern void omap_serial_init(int ports[]);
 
 #endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
-
-
diff -Nru a/arch/arm/mach-omap/dma.c b/arch/arm/mach-omap/dma.c
--- a/arch/arm/mach-omap/dma.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/mach-omap/dma.c	2004-12-24 13:37:19 -08:00
@@ -4,6 +4,8 @@
  * Copyright (C) 2003 Nokia Corporation
  * Author: Juha Yrjölä <juha.yrjola@nokia.com>
  * DMA channel linking for 1610 by Samuel Ortiz <samuel.ortiz@nokia.com>
+ * Graphics DMA and LCD DMA graphics tranformations
+ * by Imre Deak <imre.deak@nokia.com>
  *
  * Support functions for the OMAP internal DMA channels.
  *
@@ -26,6 +28,8 @@
 #include <asm/dma.h>
 #include <asm/io.h>
 
+#include <asm/arch/tc.h>
+
 #define OMAP_DMA_ACTIVE		0x01
 
 #define OMAP_DMA_CCR_EN		(1 << 7)
@@ -87,6 +91,34 @@
 		omap_writew(0, lch_base + i);
 }
 
+void omap_set_dma_priority(int dst_port, int priority)
+{
+	unsigned long reg;
+	u32 l;
+
+	switch (dst_port) {
+	case OMAP_DMA_PORT_OCP_T1:	/* FFFECC00 */
+		reg = OMAP_TC_OCPT1_PRIOR;
+		break;
+	case OMAP_DMA_PORT_OCP_T2:	/* FFFECCD0 */
+		reg = OMAP_TC_OCPT2_PRIOR;
+		break;
+	case OMAP_DMA_PORT_EMIFF:	/* FFFECC08 */
+		reg = OMAP_TC_EMIFF_PRIOR;
+		break;
+	case OMAP_DMA_PORT_EMIFS:	/* FFFECC04 */
+		reg = OMAP_TC_EMIFS_PRIOR;
+		break;
+	default:
+		BUG();
+		return;
+	}
+	l = omap_readl(reg);
+	l &= ~(0xf << 8);
+	l |= (priority & 0xf) << 8;
+	omap_writel(l, reg);
+}
+
 void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,
 				  int frame_count, int sync_mode)
 {
@@ -113,51 +145,38 @@
 	omap_writew(frame_count, OMAP_DMA_CFN(lch));
 
 }
-void omap_set_dma_constant_fill(int lch, u32 color)
+void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
 {
 	u16 w;
 
-#ifdef CONFIG_DEBUG_KERNEL
-	if (omap_dma_in_1510_mode()) {
-		printk(KERN_ERR "OMAP DMA constant fill not available in 1510 mode.");
-		BUG();
-		return;
-	}
-#endif
-	w = omap_readw(OMAP_DMA_CCR2(lch)) & ~0x03;
-	w |= 0x01;
-	omap_writew(w, OMAP_DMA_CCR2(lch));
-
-	omap_writew((u16)color, OMAP_DMA_COLOR_L(lch));
-	omap_writew((u16)(color >> 16), OMAP_DMA_COLOR_U(lch));
-
-	w = omap_readw(OMAP_DMA_LCH_CTRL(lch)) & ~0x0f;
-	w |= 1;		/* Channel type G */
-	omap_writew(w, OMAP_DMA_LCH_CTRL(lch));
-}
-
-void omap_set_dma_transparent_copy(int lch, u32 color)
-{
-	u16 w;
+	BUG_ON(omap_dma_in_1510_mode());
 
-#ifdef CONFIG_DEBUG_KERNEL
-	if (omap_dma_in_1510_mode()) {
-		printk(KERN_ERR "OMAP DMA transparent copy not available in 1510 mode.");
+	w = omap_readw(OMAP_DMA_CCR2(lch)) & ~0x03;
+	switch (mode) {
+	case OMAP_DMA_CONSTANT_FILL:
+		w |= 0x01;
+		break;
+	case OMAP_DMA_TRANSPARENT_COPY:
+		w |= 0x02;
+		break;
+	case OMAP_DMA_COLOR_DIS:
+		break;
+	default:
 		BUG();
 	}
-#endif
-	w = omap_readw(OMAP_DMA_CCR2(lch)) & ~0x03;
-	w |= 0x02;
 	omap_writew(w, OMAP_DMA_CCR2(lch));
 
-	omap_writew((u16)color, OMAP_DMA_COLOR_L(lch));
-	omap_writew((u16)(color >> 16), OMAP_DMA_COLOR_U(lch));
-
 	w = omap_readw(OMAP_DMA_LCH_CTRL(lch)) & ~0x0f;
-	w |= 1;		/* Channel type G */
+	/* Default is channel type 2D */
+	if (mode) {
+		omap_writew((u16)color, OMAP_DMA_COLOR_L(lch));
+		omap_writew((u16)(color >> 16), OMAP_DMA_COLOR_U(lch));
+		w |= 1;		/* Channel type G */
+	}
 	omap_writew(w, OMAP_DMA_LCH_CTRL(lch));
 }
 
+
 void omap_set_dma_src_params(int lch, int src_port, int src_amode,
 			     unsigned long src_start)
 {
@@ -192,22 +211,24 @@
 	omap_writew(w, OMAP_DMA_CSDP(lch));
 }
 
-void omap_set_dma_src_burst_mode(int lch, int burst_mode)
+void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
 {
 	u16 w;
 
 	w = omap_readw(OMAP_DMA_CSDP(lch)) & ~(0x03 << 7);
 	switch (burst_mode) {
+	case OMAP_DMA_DATA_BURST_DIS:
+		break;
 	case OMAP_DMA_DATA_BURST_4:
 		w |= (0x01 << 7);
 		break;
 	case OMAP_DMA_DATA_BURST_8:
-		w |= (0x03 << 7);
-		break;
+		/* not supported by current hardware
+		 * w |= (0x03 << 7);
+		 * fall through
+		 */
 	default:
-		printk(KERN_ERR "Invalid DMA burst mode\n");
 		BUG();
-		return;
 	}
 	omap_writew(w, OMAP_DMA_CSDP(lch));
 }
@@ -246,12 +267,14 @@
 	omap_writew(w, OMAP_DMA_CSDP(lch));
 }
 
-void omap_set_dma_dest_burst_mode(int lch, int burst_mode)
+void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
 {
 	u16 w;
 
 	w = omap_readw(OMAP_DMA_CSDP(lch)) & ~(0x03 << 14);
 	switch (burst_mode) {
+	case OMAP_DMA_DATA_BURST_DIS:
+		break;
 	case OMAP_DMA_DATA_BURST_4:
 		w |= (0x01 << 14);
 		break;
@@ -474,7 +497,7 @@
 	chan->data = data;
 	chan->enabled_irqs = OMAP_DMA_TOUT_IRQ | OMAP_DMA_DROP_IRQ | OMAP_DMA_BLOCK_IRQ;
 
-	if (cpu_is_omap1610() || cpu_is_omap5912() || cpu_is_omap730() || cpu_is_omap1710()) {
+	if (cpu_is_omap16xx() || cpu_is_omap730()) {
 		/* If the sync device is set, configure it dynamically. */
 		if (dev_id != 0) {
 			set_gdma_dev(free_ch + 1, dev_id);
@@ -571,8 +594,15 @@
 	void (* callback)(u16 status, void *data);
 	void *cb_data;
 
+	int active;
 	unsigned long addr, size;
 	int rotate, data_type, xres, yres;
+	int vxres;
+	int mirror;
+	int xscale, yscale;
+	int ext_ctrl;
+	int src_port;
+	int single_transfer;
 } lcd_dma;
 
 void omap_set_lcd_dma_b1(unsigned long addr, u16 fb_xres, u16 fb_yres,
@@ -584,14 +614,70 @@
 	lcd_dma.yres = fb_yres;
 }
 
+void omap_set_lcd_dma_src_port(int port)
+{
+	lcd_dma.src_port = port;
+}
+
+void omap_set_lcd_dma_ext_controller(int external)
+{
+	lcd_dma.ext_ctrl = external;
+}
+
+void omap_set_lcd_dma_single_transfer(int single)
+{
+	lcd_dma.single_transfer = single;
+}
+
+
+void omap_set_lcd_dma_b1_rotation(int rotate)
+{
+	if (omap_dma_in_1510_mode()) {
+		printk(KERN_ERR "DMA rotation is not supported in 1510 mode\n");
+		BUG();
+		return;
+	}
+	lcd_dma.rotate = rotate;
+}
+
+void omap_set_lcd_dma_b1_mirror(int mirror)
+{
+	if (omap_dma_in_1510_mode()) {
+		printk(KERN_ERR "DMA mirror is not supported in 1510 mode\n");
+		BUG();
+	}
+	lcd_dma.mirror = mirror;
+}
+
+void omap_set_lcd_dma_b1_vxres(unsigned long vxres)
+{
+	if (omap_dma_in_1510_mode()) {
+		printk(KERN_ERR "DMA virtual resulotion is not supported "
+				"in 1510 mode\n");
+		BUG();
+	}
+	lcd_dma.vxres = vxres;
+}
+
+void omap_set_lcd_dma_b1_scale(unsigned int xscale, unsigned int yscale)
+{
+	if (omap_dma_in_1510_mode()) {
+		printk(KERN_ERR "DMA scale is not supported in 1510 mode\n");
+		BUG();
+	}
+	lcd_dma.xscale = xscale;
+	lcd_dma.yscale = yscale;
+}
+
 static void set_b1_regs(void)
 {
 	unsigned long top, bottom;
 	int es;
-	u16 w, en, fn;
-	s16 ei;
-	s32 fi;
-	u32 l;
+	u16 w;
+	unsigned long en, fn;
+	long ei, fi;
+	unsigned long vxres;
+	unsigned int xscale, yscale;
 
 	switch (lcd_dma.data_type) {
 	case OMAP_DMA_DATA_TYPE_S8:
@@ -608,25 +694,81 @@
 		return;
 	}
 
-	if (lcd_dma.rotate == 0) {
-		top = lcd_dma.addr;
-		bottom = lcd_dma.addr + (lcd_dma.xres * lcd_dma.yres - 1) * es;
-		/* 1510 DMA requires the bottom address to be 2 more than the
-		 * actual last memory access location. */
-		if (omap_dma_in_1510_mode() &&
-		    lcd_dma.data_type == OMAP_DMA_DATA_TYPE_S32)
-			bottom += 2;
+	vxres = lcd_dma.vxres ? lcd_dma.vxres : lcd_dma.xres;
+	xscale = lcd_dma.xscale ? lcd_dma.xscale : 1;
+	yscale = lcd_dma.yscale ? lcd_dma.yscale : 1;
+	BUG_ON(vxres < lcd_dma.xres);
+#define PIXADDR(x,y) (lcd_dma.addr + ((y) * vxres * yscale + (x) * xscale) * es)
+#define PIXSTEP(sx, sy, dx, dy) (PIXADDR(dx, dy) - PIXADDR(sx, sy) - es + 1)
+	switch (lcd_dma.rotate) {
+	case 0:
+		if (!lcd_dma.mirror) {
+			top = PIXADDR(0, 0);
+			bottom = PIXADDR(lcd_dma.xres - 1, lcd_dma.yres - 1);
+			/* 1510 DMA requires the bottom address to be 2 more
+			 * than the actual last memory access location. */
+			if (omap_dma_in_1510_mode() &&
+			    lcd_dma.data_type == OMAP_DMA_DATA_TYPE_S32)
+				bottom += 2;
+			ei = PIXSTEP(0, 0, 1, 0);
+			fi = PIXSTEP(lcd_dma.xres - 1, 0, 0, 1);
+		} else {
+			top = PIXADDR(lcd_dma.xres - 1, 0);
+			bottom = PIXADDR(0, lcd_dma.yres - 1);
+			ei = PIXSTEP(1, 0, 0, 0);
+			fi = PIXSTEP(0, 0, lcd_dma.xres - 1, 1);
+		}
 		en = lcd_dma.xres;
 		fn = lcd_dma.yres;
-		ei = 0;
-		fi = 0;
-	} else {
-		top = lcd_dma.addr + (lcd_dma.xres - 1) * es;
-		bottom = lcd_dma.addr + (lcd_dma.yres - 1) * lcd_dma.xres * es;
+		break;
+	case 90:
+		if (!lcd_dma.mirror) {
+			top = PIXADDR(0, lcd_dma.yres - 1);
+			bottom = PIXADDR(lcd_dma.xres - 1, 0);
+			ei = PIXSTEP(0, 1, 0, 0);
+			fi = PIXSTEP(0, 0, 1, lcd_dma.yres - 1);
+		} else {
+			top = PIXADDR(lcd_dma.xres - 1, lcd_dma.yres - 1);
+			bottom = PIXADDR(0, 0);
+			ei = PIXSTEP(0, 1, 0, 0);
+			fi = PIXSTEP(1, 0, 0, lcd_dma.yres - 1);
+		}
+		en = lcd_dma.yres;
+		fn = lcd_dma.xres;
+		break;
+	case 180:
+		if (!lcd_dma.mirror) {
+			top = PIXADDR(lcd_dma.xres - 1, lcd_dma.yres - 1);
+			bottom = PIXADDR(0, 0);
+			ei = PIXSTEP(1, 0, 0, 0);
+			fi = PIXSTEP(0, 1, lcd_dma.xres - 1, 0);
+		} else {
+			top = PIXADDR(0, lcd_dma.yres - 1);
+			bottom = PIXADDR(lcd_dma.xres - 1, 0);
+			ei = PIXSTEP(0, 0, 1, 0);
+			fi = PIXSTEP(lcd_dma.xres - 1, 1, 0, 0);
+		}
+		en = lcd_dma.xres;
+		fn = lcd_dma.yres;
+		break;
+	case 270:
+		if (!lcd_dma.mirror) {
+			top = PIXADDR(lcd_dma.xres - 1, 0);
+			bottom = PIXADDR(0, lcd_dma.yres - 1);
+			ei = PIXSTEP(0, 0, 0, 1);
+			fi = PIXSTEP(1, lcd_dma.yres - 1, 0, 0);
+		} else {
+			top = PIXADDR(0, 0);
+			bottom = PIXADDR(lcd_dma.xres - 1, lcd_dma.yres - 1);
+			ei = PIXSTEP(0, 0, 0, 1);
+			fi = PIXSTEP(0, lcd_dma.yres - 1, 1, 0);
+		}
 		en = lcd_dma.yres;
 		fn = lcd_dma.xres;
-		ei = (lcd_dma.xres - 1) * es + 1;
-		fi = -(lcd_dma.xres * (lcd_dma.yres - 1) + 2) * 2 + 1;
+		break;
+	default:
+		BUG();
+		return;	/* Supress warning about uninitialized vars */
 	}
 
 	if (omap_dma_in_1510_mode()) {
@@ -652,33 +794,50 @@
 	w |= lcd_dma.data_type;
 	omap_writew(w, OMAP1610_DMA_LCD_CSDP);
 
-	if (!lcd_dma.rotate)
-		return;
+	w = omap_readw(OMAP1610_DMA_LCD_CTRL);
+	/* Always set the source port as SDRAM for now*/
+	w &= ~(0x03 << 6);
+	if (lcd_dma.ext_ctrl)
+		w |= 1 << 8;
+	else
+		w &= ~(1 << 8);
+	if (lcd_dma.callback != NULL)
+		w |= 1 << 1;            /* Block interrupt enable */
+	else
+		w &= ~(1 << 1);
+	omap_writew(w, OMAP1610_DMA_LCD_CTRL);
 
-	/* Rotation stuff */
-	l = omap_readw(OMAP1610_DMA_LCD_CSDP);
-	/* Disable burst access */
-	l &= ~(0x03 << 7);
-	omap_writew(l, OMAP1610_DMA_LCD_CSDP);
+	if (!(lcd_dma.rotate || lcd_dma.mirror ||
+	      lcd_dma.vxres || lcd_dma.xscale || lcd_dma.yscale))
+		return;
 
-	l = omap_readw(OMAP1610_DMA_LCD_CCR);
+	w = omap_readw(OMAP1610_DMA_LCD_CCR);
 	/* Set the double-indexed addressing mode */
-	l |= (0x03 << 12);
-	omap_writew(l, OMAP1610_DMA_LCD_CCR);
+	w |= (0x03 << 12);
+	omap_writew(w, OMAP1610_DMA_LCD_CCR);
 
 	omap_writew(ei, OMAP1610_DMA_LCD_SRC_EI_B1);
 	omap_writew(fi >> 16, OMAP1610_DMA_LCD_SRC_FI_B1_U);
 	omap_writew(fi, OMAP1610_DMA_LCD_SRC_FI_B1_L);
 }
 
-void omap_set_lcd_dma_b1_rotation(int rotate)
+static irqreturn_t lcd_dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
-	if (omap_dma_in_1510_mode()) {
-		printk(KERN_ERR "DMA rotation is not supported in 1510 mode\n");
-		BUG();
-		return;
-	}
-	lcd_dma.rotate = rotate;
+	u16 w;
+
+	w = omap_readw(OMAP1610_DMA_LCD_CTRL);
+	if (unlikely(!(w & (1 << 3)))) {
+		printk(KERN_WARNING "Spurious LCD DMA IRQ\n");
+		return IRQ_NONE;
+	}
+	/* Ack the IRQ */
+	w |= (1 << 3);
+	omap_writew(w, OMAP1610_DMA_LCD_CTRL);
+	lcd_dma.active = 0;
+	if (lcd_dma.callback != NULL)
+		lcd_dma.callback(w, lcd_dma.cb_data);
+
+	return IRQ_HANDLED;
 }
 
 int omap_request_lcd_dma(void (* callback)(u16 status, void *data),
@@ -695,6 +854,15 @@
 	spin_unlock_irq(&lcd_dma.lock);
 	lcd_dma.callback = callback;
 	lcd_dma.cb_data = data;
+	lcd_dma.active = 0;
+	lcd_dma.single_transfer = 0;
+	lcd_dma.rotate = 0;
+	lcd_dma.vxres = 0;
+	lcd_dma.mirror = 0;
+	lcd_dma.xscale = 0;
+	lcd_dma.yscale = 0;
+	lcd_dma.ext_ctrl = 0;
+	lcd_dma.src_port = 0;
 
 	return 0;
 }
@@ -714,23 +882,53 @@
 	spin_unlock(&lcd_dma.lock);
 }
 
-void omap_start_lcd_dma(void)
+void omap_enable_lcd_dma(void)
 {
+	u16 w;
+
+	/* Set the Enable bit only if an external controller is
+	 * connected. Otherwise the OMAP internal controller will
+	 * start the transfer when it gets enabled.
+	 */
+	if (enable_1510_mode || !lcd_dma.ext_ctrl)
+		return;
+	w = omap_readw(OMAP1610_DMA_LCD_CCR);
+	w |= 1 << 7;
+	omap_writew(w, OMAP1610_DMA_LCD_CCR);
+	lcd_dma.active = 1;
+}
+
+void omap_setup_lcd_dma(void)
+{
+	BUG_ON(lcd_dma.active);
 	if (!enable_1510_mode) {
 		/* Set some reasonable defaults */
+		omap_writew(0x5440, OMAP1610_DMA_LCD_CCR);
 		omap_writew(0x9102, OMAP1610_DMA_LCD_CSDP);
 		omap_writew(0x0004, OMAP1610_DMA_LCD_LCH_CTRL);
-		omap_writew(0x5740, OMAP1610_DMA_LCD_CCR);
 	}
 	set_b1_regs();
-	if (!enable_1510_mode)
-		omap_writew(omap_readw(OMAP1610_DMA_LCD_CCR) | 1, OMAP1610_DMA_LCD_CCR);
+	if (!enable_1510_mode) {
+		u16 w;
+
+		w = omap_readw(OMAP1610_DMA_LCD_CCR);
+		/* If DMA was already active set the end_prog bit to have
+		 * the programmed register set loaded into the active
+		 * register set.
+		 */
+		w |= 1 << 11;		/* End_prog */
+		if (!lcd_dma.single_transfer)
+	        	w |= (3 << 8);	/* Auto_init, repeat */
+		omap_writew(w, OMAP1610_DMA_LCD_CCR);
+	}
 }
 
 void omap_stop_lcd_dma(void)
 {
-	if (!enable_1510_mode)
-		omap_writew(omap_readw(OMAP1610_DMA_LCD_CCR) & ~1, OMAP1610_DMA_LCD_CCR);
+	lcd_dma.active = 0;
+	if (!enable_1510_mode && lcd_dma.ext_ctrl)
+		omap_writew(omap_readw(OMAP1610_DMA_LCD_CCR) & ~(1 << 7),
+			    OMAP1610_DMA_LCD_CCR);
 }
 
 static int __init omap_init_dma(void)
@@ -741,7 +939,7 @@
 		printk(KERN_INFO "DMA support for OMAP1510 initialized\n");
 		dma_chan_count = 9;
 		enable_1510_mode = 1;
-	} else if (cpu_is_omap1610() || cpu_is_omap5912() || cpu_is_omap730() || cpu_is_omap1710()) {
+	} else if (cpu_is_omap16xx() || cpu_is_omap730()) {
 		printk(KERN_INFO "OMAP DMA hardware version %d\n",
 		       omap_readw(OMAP_DMA_HW_ID));
 		printk(KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n",
@@ -756,7 +954,7 @@
 			w = omap_readw(OMAP_DMA_GSCR);
 			w |= 1 << 3;
 			omap_writew(w, OMAP_DMA_GSCR);
-			dma_chan_count = OMAP_LOGICAL_DMA_CH_COUNT;
+			dma_chan_count = 16;
 		} else
 			dma_chan_count = 9;
 	} else {
@@ -790,11 +988,21 @@
 			return r;
 		}
 	}
-
+	r = request_irq(INT_DMA_LCD, lcd_dma_irq_handler, 0, "LCD DMA", NULL);
+	if (r != 0) {
+		int i;
+
+		printk(KERN_ERR "unable to request IRQ for LCD DMA (error %d)\n", r);
+		for (i = 0; i < dma_chan_count; i++)
+			free_irq(dma_irq[i], (void *) (i + 1));
+		return r;
+	}
 	return 0;
 }
 arch_initcall(omap_init_dma);
 
+
+EXPORT_SYMBOL(omap_set_dma_priority);
 EXPORT_SYMBOL(omap_request_dma);
 EXPORT_SYMBOL(omap_free_dma);
 EXPORT_SYMBOL(omap_start_dma);
@@ -803,8 +1011,7 @@
 EXPORT_SYMBOL(omap_disable_dma_irq);
 
 EXPORT_SYMBOL(omap_set_dma_transfer_params);
-EXPORT_SYMBOL(omap_set_dma_constant_fill);
-EXPORT_SYMBOL(omap_set_dma_transparent_copy);
+EXPORT_SYMBOL(omap_set_dma_color_mode);
 
 EXPORT_SYMBOL(omap_set_dma_src_params);
 EXPORT_SYMBOL(omap_set_dma_src_index);
@@ -821,7 +1028,14 @@
 
 EXPORT_SYMBOL(omap_request_lcd_dma);
 EXPORT_SYMBOL(omap_free_lcd_dma);
-EXPORT_SYMBOL(omap_start_lcd_dma);
+EXPORT_SYMBOL(omap_enable_lcd_dma);
+EXPORT_SYMBOL(omap_setup_lcd_dma);
 EXPORT_SYMBOL(omap_stop_lcd_dma);
 EXPORT_SYMBOL(omap_set_lcd_dma_b1);
+EXPORT_SYMBOL(omap_set_lcd_dma_single_transfer);
+EXPORT_SYMBOL(omap_set_lcd_dma_ext_controller);
 EXPORT_SYMBOL(omap_set_lcd_dma_b1_rotation);
+EXPORT_SYMBOL(omap_set_lcd_dma_b1_vxres);
+EXPORT_SYMBOL(omap_set_lcd_dma_b1_scale);
+EXPORT_SYMBOL(omap_set_lcd_dma_b1_mirror);
+
diff -Nru a/arch/arm/mach-omap/gpio.c b/arch/arm/mach-omap/gpio.c
--- a/arch/arm/mach-omap/gpio.c	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/mach-omap/gpio.c	2004-12-24 13:36:49 -08:00
@@ -94,7 +94,7 @@
 #define METHOD_GPIO_1610	2
 #define METHOD_GPIO_730		3
 
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
+#if defined(CONFIG_ARCH_OMAP16XX)
 static struct gpio_bank gpio_bank_1610[5] = {
 	{ OMAP_MPUIO_BASE,     INT_MPUIO,	    IH_MPUIO_BASE,     METHOD_MPUIO},
 	{ OMAP1610_GPIO1_BASE, INT_GPIO_BANK1,	    IH_GPIO_BASE,      METHOD_GPIO_1610 },
@@ -135,8 +135,8 @@
 		return &gpio_bank[1];
 	}
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
-	if (cpu_is_omap1610() || cpu_is_omap1710() || cpu_is_omap5912()) {
+#if defined(CONFIG_ARCH_OMAP16XX)
+	if (cpu_is_omap16xx()) {
 		if (OMAP_GPIO_IS_MPUIO(gpio))
 			return &gpio_bank[0];
 		return &gpio_bank[1 + (gpio >> 4)];
@@ -172,8 +172,8 @@
 	if (cpu_is_omap1510() && gpio < 16)
 		return 0;
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
-	if ((cpu_is_omap1610() || cpu_is_omap1710() || cpu_is_omap5912()) && gpio < 64)
+#if defined(CONFIG_ARCH_OMAP16XX)
+	if ((cpu_is_omap16xx()) && gpio < 64)
 		return 0;
 #endif
 #ifdef CONFIG_ARCH_OMAP730
@@ -554,7 +554,7 @@
 	if (bank->method == METHOD_GPIO_1510)
 		isr_reg = bank->base + OMAP1510_GPIO_INT_STATUS;
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
+#if defined(CONFIG_ARCH_OMAP16XX)
 	if (bank->method == METHOD_GPIO_1610)
 		isr_reg = bank->base + OMAP1610_GPIO_IRQSTATUS1;
 #endif
@@ -588,7 +588,7 @@
 	if (bank->method == METHOD_GPIO_1510)
 		__raw_writew(1 << (gpio & 0x0f), bank->base + OMAP1510_GPIO_INT_STATUS);
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
+#if defined(CONFIG_ARCH_OMAP16XX)
 	if (bank->method == METHOD_GPIO_1610)
 		__raw_writew(1 << (gpio & 0x0f), bank->base + OMAP1610_GPIO_IRQSTATUS1);
 #endif
@@ -668,8 +668,8 @@
 		gpio_bank = gpio_bank_1510;
 	}
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
-	if (cpu_is_omap1610() || cpu_is_omap1710() || cpu_is_omap5912()) {
+#if defined(CONFIG_ARCH_OMAP16XX)
+	if (cpu_is_omap16xx()) {
 		int rev;
 
 		gpio_bank_count = 5;
@@ -702,7 +702,7 @@
 			__raw_writew(0x0000, bank->base + OMAP1510_GPIO_INT_STATUS);
 		}
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
+#if defined(CONFIG_ARCH_OMAP16XX)
 		if (bank->method == METHOD_GPIO_1610) {
 			__raw_writew(0x0000, bank->base + OMAP1610_GPIO_IRQENABLE1);
 			__raw_writew(0xffff, bank->base + OMAP1610_GPIO_IRQSTATUS1);
@@ -722,7 +722,7 @@
 				set_irq_chip(j, &mpuio_irq_chip);
 			else
 				set_irq_chip(j, &gpio_irq_chip);
-			set_irq_handler(j, do_level_IRQ);
+			set_irq_handler(j, do_edge_IRQ);
 			set_irq_flags(j, IRQF_VALID);
 		}
 		set_irq_chained_handler(bank->irq, gpio_irq_handler);
diff -Nru a/arch/arm/mach-omap/irq.c b/arch/arm/mach-omap/irq.c
--- a/arch/arm/mach-omap/irq.c	2004-12-24 13:36:19 -08:00
+++ b/arch/arm/mach-omap/irq.c	2004-12-24 13:36:19 -08:00
@@ -140,12 +140,11 @@
 };
 #endif
 
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP5912) \
-				  || defined(CONFIG_ARCH_OMAP1710)
+#if defined(CONFIG_ARCH_OMAP16XX)
 
 static struct omap_irq_bank omap1610_irq_banks[] = {
 	{ .base_reg = OMAP_IH1_BASE, 		.trigger_map = 0xb3fefe8f },
-	{ .base_reg = OMAP_IH2_BASE, 		.trigger_map = 0xfffff7ff },
+	{ .base_reg = OMAP_IH2_BASE, 		.trigger_map = 0xfdb7c1fd },
 	{ .base_reg = OMAP_IH2_BASE + 0x100,	.trigger_map = 0xfffff7ff },
 	{ .base_reg = OMAP_IH2_BASE + 0x200,	.trigger_map = 0xffffffff },
 };
@@ -173,9 +172,8 @@
 		irq_bank_count = ARRAY_SIZE(omap1510_irq_banks);
 	}
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP5912) \
-				  || defined(CONFIG_ARCH_OMAP1710)
-	if (cpu_is_omap1610() || cpu_is_omap5912() || cpu_is_omap1710()) {
+#if defined(CONFIG_ARCH_OMAP16XX)
+	if (cpu_is_omap16xx()) {
 		irq_banks = omap1610_irq_banks;
 		irq_bank_count = ARRAY_SIZE(omap1610_irq_banks);
 	}
diff -Nru a/arch/arm/mach-omap/mcbsp.c b/arch/arm/mach-omap/mcbsp.c
--- a/arch/arm/mach-omap/mcbsp.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-omap/mcbsp.c	2004-12-24 13:36:55 -08:00
@@ -18,6 +18,7 @@
 #include <linux/wait.h>
 #include <linux/completion.h>
 #include <linux/interrupt.h>
+#include <linux/err.h>
 
 #include <asm/delay.h>
 #include <asm/io.h>
@@ -28,6 +29,8 @@
 #include <asm/arch/irqs.h>
 #include <asm/arch/mcbsp.h>
 
+#include <asm/hardware/clock.h>
+
 #ifdef CONFIG_MCBSP_DEBUG
 #define DBG(x...)	printk(x)
 #else
@@ -61,6 +64,8 @@
 };
 
 static struct omap_mcbsp mcbsp[OMAP_MAX_MCBSP_COUNT];
+static struct clk *mcbsp_dsp_ck = 0;
+static struct clk *mcbsp_api_ck = 0;
 
 
 static void omap_mcbsp_dump_reg(u8 id)
@@ -153,8 +158,8 @@
 	OMAP_MCBSP_WRITE(io_base, XCR1, config->xcr1);
 	OMAP_MCBSP_WRITE(io_base, SRGR2, config->srgr2);
 	OMAP_MCBSP_WRITE(io_base, SRGR1, config->srgr1);
-	OMAP_MCBSP_WRITE(io_base, SRGR2, config->mcr2);
-	OMAP_MCBSP_WRITE(io_base, SRGR1, config->mcr1);
+	OMAP_MCBSP_WRITE(io_base, MCR2, config->mcr2);
+	OMAP_MCBSP_WRITE(io_base, MCR1, config->mcr1);
 	OMAP_MCBSP_WRITE(io_base, PCR0, config->pcr0);
 }
 
@@ -181,6 +186,7 @@
 	return -1;
 }
 
+#define EN_XORPCK		1
 #define DSP_RSTCT2              0xe1008014
 
 static void omap_mcbsp_dsp_request(void)
@@ -188,10 +194,8 @@
 	if (cpu_is_omap1510() || cpu_is_omap1610() || cpu_is_omap1710()) {
 		omap_writew((omap_readw(ARM_RSTCT1) | (1 << 1) | (1 << 2)),
 			    ARM_RSTCT1);
-		omap_writew((omap_readw(ARM_CKCTL) | 1 << EN_DSPCK),
-			    ARM_CKCTL);
-		omap_writew((omap_readw(ARM_IDLECT2) | (1 << EN_APICK)),
-			    ARM_IDLECT2);
+		clk_enable(mcbsp_dsp_ck);
+		clk_enable(mcbsp_api_ck);
 
 		/* enable 12MHz clock to mcbsp 1 & 3 */
 		__raw_writew(__raw_readw(DSP_IDLECT2) | (1 << EN_XORPCK),
@@ -588,7 +592,7 @@
 };
 #endif
 
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710)
+#if defined(CONFIG_ARCH_OMAP16XX)
 static const struct omap_mcbsp_info mcbsp_1610[] = {
 	[0] = { .virt_base = OMAP1610_MCBSP1_BASE,
 		.dma_rx_sync = OMAP_DMA_MCBSP1_RX,
@@ -614,6 +618,18 @@
 	static const struct omap_mcbsp_info *mcbsp_info;
 
 	printk("Initializing OMAP McBSP system\n");
+
+	mcbsp_dsp_ck = clk_get(0, "dsp_ck");
+	if (IS_ERR(mcbsp_dsp_ck)) {
+		printk(KERN_ERR "mcbsp: could not acquire dsp_ck handle.\n");
+		return PTR_ERR(mcbsp_dsp_ck);
+	}
+	mcbsp_api_ck = clk_get(0, "api_ck");
+	if (IS_ERR(mcbsp_dsp_ck)) {
+		printk(KERN_ERR "mcbsp: could not acquire api_ck handle.\n");
+		return PTR_ERR(mcbsp_api_ck);
+	}
+
 #ifdef CONFIG_ARCH_OMAP730
 	if (cpu_is_omap730()) {
 		mcbsp_info = mcbsp_730;
@@ -626,7 +642,7 @@
 		mcbsp_count = ARRAY_SIZE(mcbsp_1510);
 	}
 #endif
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710)
+#if defined(CONFIG_ARCH_OMAP16XX)
 	if (cpu_is_omap1610() || cpu_is_omap1710()) {
 		mcbsp_info = mcbsp_1610;
 		mcbsp_count = ARRAY_SIZE(mcbsp_1610);
diff -Nru a/arch/arm/mach-omap/mux.c b/arch/arm/mach-omap/mux.c
--- a/arch/arm/mach-omap/mux.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/mach-omap/mux.c	2004-12-24 13:37:19 -08:00
@@ -32,18 +32,26 @@
 #define __MUX_C__
 #include <asm/arch/mux.h>
 
+#ifdef CONFIG_OMAP_MUX
+
 /*
  * Sets the Omap MUX and PULL_DWN registers based on the table
  */
-int omap_cfg_reg(const reg_cfg_t reg_cfg)
+int __init_or_module
+omap_cfg_reg(const reg_cfg_t reg_cfg)
 {
-#ifdef CONFIG_OMAP_MUX
 	static spinlock_t mux_spin_lock = SPIN_LOCK_UNLOCKED;
 
 	unsigned long flags;
 	reg_cfg_set *cfg;
 	unsigned int reg_orig = 0, reg = 0, pu_pd_orig = 0, pu_pd = 0,
 		pull_orig = 0, pull = 0;
+	unsigned int mask, warn = 0;
+
+	if (reg_cfg > ARRAY_SIZE(reg_cfg_table)) {
+		printk(KERN_ERR "MUX: reg_cfg %d\n", reg_cfg);
+		return -EINVAL;
+	}
 
 	cfg = &reg_cfg_table[reg_cfg];
 
@@ -56,12 +64,20 @@
 
 	/* Check the mux register in question */
 	if (cfg->mux_reg) {
+		unsigned	tmp1, tmp2;
+
 		reg_orig = omap_readl(cfg->mux_reg);
 
 		/* The mux registers always seem to be 3 bits long */
-		reg = reg_orig & ~(0x7 << cfg->mask_offset);
+		mask = (0x7 << cfg->mask_offset);
+		tmp1 = reg_orig & mask;
+		reg = reg_orig & ~mask;
+
+		tmp2 = (cfg->mask << cfg->mask_offset);
+		reg |= tmp2;
 
-		reg |= (cfg->mask << cfg->mask_offset);
+		if (tmp1 != tmp2)
+			warn = 1;
 
 		omap_writel(reg, cfg->mux_reg);
 	}
@@ -70,12 +86,18 @@
 	if (!cpu_is_omap1510()) {
 		if (cfg->pu_pd_reg && cfg->pull_val) {
 			pu_pd_orig = omap_readl(cfg->pu_pd_reg);
+			mask = 1 << cfg->pull_bit;
+
 			if (cfg->pu_pd_val) {
+				if (!(pu_pd_orig & mask))
+					warn = 1;
 				/* Use pull up */
-				pu_pd = pu_pd_orig | (1 << cfg->pull_bit);
+				pu_pd = pu_pd_orig | mask;
 			} else {
+				if (pu_pd_orig & mask)
+					warn = 1;
 				/* Use pull down */
-				pu_pd = pu_pd_orig & ~(1 << cfg->pull_bit);
+				pu_pd = pu_pd_orig & ~mask;
 			}
 			omap_writel(pu_pd, cfg->pu_pd_reg);
 		}
@@ -84,21 +106,32 @@
 	/* Check for an associated pull down register */
 	if (cfg->pull_reg) {
 		pull_orig = omap_readl(cfg->pull_reg);
+		mask = 1 << cfg->pull_bit;
 
 		if (cfg->pull_val) {
+			if (pull_orig & mask)
+				warn = 1;
 			/* Low bit = pull enabled */
-			pull = pull_orig & ~(1 << cfg->pull_bit);
+			pull = pull_orig & ~mask;
 		} else {
+			if (!(pull_orig & mask))
+				warn = 1;
 			/* High bit = pull disabled */
-			pull = pull_orig | (1 << cfg->pull_bit);
+			pull = pull_orig | mask;
 		}
 
 		omap_writel(pull, cfg->pull_reg);
 	}
 
+	if (warn) {
+#ifdef CONFIG_OMAP_MUX_WARNINGS
+		printk(KERN_WARNING "MUX: initialized %s\n", cfg->name);
+#endif
+	}
+
 #ifdef CONFIG_OMAP_MUX_DEBUG
-	if (cfg->debug) {
-		printk("Omap: Setting register %s\n", cfg->name);
+	if (cfg->debug || warn) {
+		printk("MUX: Setting register %s\n", cfg->name);
 		printk("      %s (0x%08x) = 0x%08x -> 0x%08x\n",
 		       cfg->mux_reg_name, cfg->mux_reg, reg_orig, reg);
 
@@ -118,8 +151,13 @@
 
 	spin_unlock_irqrestore(&mux_spin_lock, flags);
 
-#endif
+#ifdef CONFIG_OMAP_MUX_ERRORS
+	return warn ? -ETXTBSY : 0;
+#else
 	return 0;
+#endif
 }
 
 EXPORT_SYMBOL(omap_cfg_reg);
+
+#endif	/* CONFIG_OMAP_MUX */
diff -Nru a/arch/arm/mach-omap/ocpi.c b/arch/arm/mach-omap/ocpi.c
--- a/arch/arm/mach-omap/ocpi.c	2004-12-24 13:37:29 -08:00
+++ b/arch/arm/mach-omap/ocpi.c	2004-12-24 13:37:29 -08:00
@@ -59,20 +59,12 @@
 
 	/* Make sure there's clock for OCPI */
 
-#if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710)
+#if defined(CONFIG_ARCH_OMAP16XX)
         if (cpu_is_omap1610() || cpu_is_omap1710()) {
-		val = omap_readl(OMAP1610_ARM_IDLECT3);
+		val = omap_readl(OMAP16XX_ARM_IDLECT3);
 		val |= EN_OCPI_CK;
 		val &= ~IDLOCPI_ARM;
-		omap_writel(val, OMAP1610_ARM_IDLECT3);
-        }
-#endif
-#ifdef CONFIG_ARCH_OMAP5912
-        if (cpu_is_omap5912()) {
-		val = omap_readl(OMAP5912_ARM_IDLECT3);
-		val |= EN_OCPI_CK;
-		val &= ~IDLOCPI_ARM;
-		omap_writel(val, OMAP5912_ARM_IDLECT3);
+		omap_writel(val, OMAP16XX_ARM_IDLECT3);
         }
 #endif
 	/* Enable access for OHCI in OCPI */
diff -Nru a/arch/arm/mach-omap/pm.c b/arch/arm/mach-omap/pm.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-omap/pm.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,621 @@
+/*
+ * linux/arch/arm/mach-omap/pm.c
+ *
+ * OMAP Power Management Routines
+ *
+ * Original code for the SA11x0:
+ * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
+ *
+ * Modified for the PXA250 by Nicolas Pitre:
+ * Copyright (c) 2002 Monta Vista Software, Inc.
+ *
+ * Modified for the OMAP1510 by David Singleton:
+ * Copyright (c) 2002 Monta Vista Software, Inc.
+ *
+ * Cleanup 2004 for OMAP1510/1610 by Dirk Behme <dirk.behme@de.bosch.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/pm.h>
+#include <linux/sched.h>
+#include <linux/proc_fs.h>
+#include <linux/pm.h>
+
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <asm/arch/omap16xx.h>
+#include <asm/arch/pm.h>
+#include <asm/arch/mux.h>
+#include <asm/arch/tps65010.h>
+
+#include "clock.h"
+
+static unsigned int arm_sleep_save[ARM_SLEEP_SAVE_SIZE];
+static unsigned short ulpd_sleep_save[ULPD_SLEEP_SAVE_SIZE];
+static unsigned int mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_SIZE];
+static unsigned int mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_SIZE];
+
+/*
+ * Let's power down on idle, but only if we are really
+ * idle, because once we start down the path of
+ * going idle we continue to do idle even if we get
+ * a clock tick interrupt . .
+ */
+void omap_pm_idle(void)
+{
+	int (*func_ptr)(void) = 0;
+	unsigned int mask32 = 0;
+
+	/*
+	 * If the DSP is being used let's just idle the CPU, the overhead
+	 * to wake up from Big Sleep is big, milliseconds versus micro
+	 * seconds for wait for interrupt.
+	 */
+
+	local_irq_disable();
+	local_fiq_disable();
+	if (need_resched()) {
+		local_fiq_enable();
+		local_irq_enable();
+		return;
+	}
+	mask32 = omap_readl(ARM_SYSST);
+	local_fiq_enable();
+	local_irq_enable();
+	if ((mask32 & DSP_IDLE) == 0) {
+		__asm__ volatile ("mcr	p15, 0, r0, c7, c0, 4");
+	} else {
+
+		if (cpu_is_omap1510()) {
+			func_ptr = (void *)(OMAP1510_SRAM_IDLE_SUSPEND);
+		} else if (cpu_is_omap1610() || cpu_is_omap1710()) {
+			func_ptr = (void *)(OMAP1610_SRAM_IDLE_SUSPEND);
+		} else if (cpu_is_omap5912()) {
+			func_ptr = (void *)(OMAP5912_SRAM_IDLE_SUSPEND);
+		}
+
+		func_ptr();
+	}
+}
+
+/*
+ * Configuration of the wakeup event is board specific. For the
+ * moment we put it into this helper function. Later it may move
+ * to board specific files.
+ */
+static void omap_pm_wakeup_setup(void)
+{
+	/*
+	 * Enable ARM XOR clock and release peripheral from reset by
+	 * writing 1 to PER_EN bit in ARM_RSTCT2, this is required
+	 * for UART configuration to use UART2 to wake up.
+	 */
+
+	omap_writel(omap_readl(ARM_IDLECT2) | ENABLE_XORCLK, ARM_IDLECT2);
+	omap_writel(omap_readl(ARM_RSTCT2) | PER_EN, ARM_RSTCT2);
+	omap_writew(MODEM_32K_EN, ULPD_CLOCK_CTRL);
+
+	/*
+	 * Turn off all interrupts except L1-2nd level cascade,
+	 * and the L2 wakeup interrupts: keypad and UART2.
+	 */
+
+	omap_writel(~IRQ_LEVEL2, OMAP_IH1_MIR);
+
+	if (cpu_is_omap1510()) {
+		omap_writel(~(IRQ_UART2 | IRQ_KEYBOARD),  OMAP_IH2_MIR);
+	}
+
+	if (cpu_is_omap16xx()) {
+		omap_writel(~(IRQ_UART2 | IRQ_KEYBOARD), OMAP_IH2_0_MIR);
+
+		omap_writel(~0x0, OMAP_IH2_1_MIR);
+		omap_writel(~0x0, OMAP_IH2_2_MIR);
+		omap_writel(~0x0, OMAP_IH2_3_MIR);
+	}
+
+	/*  New IRQ agreement */
+ 	omap_writel(1, OMAP_IH1_CONTROL);
+
+	/* external PULL to down, bit 22 = 0 */
+	omap_writel(omap_readl(PULL_DWN_CTRL_2) & ~(1<<22), PULL_DWN_CTRL_2);
+}
+
+void omap_pm_suspend(void)
+{
+	unsigned int mask32 = 0;
+	unsigned long arg0 = 0, arg1 = 0;
+	int (*func_ptr)(unsigned short, unsigned short) = 0;
+	unsigned short save_dsp_idlect2;
+
+	printk("PM: OMAP%x is entering deep sleep now ...\n", system_rev);
+
+	if (machine_is_omap_osk()) {
+		/* Stop LED1 (D9) blink */
+		tps65010_set_led(LED1, OFF);
+	}
+
+	/*
+	 * Step 1: turn off interrupts
+	 */
+
+	local_irq_disable();
+	local_fiq_disable();
+
+	/*
+	 * Step 2: save registers
+	 *
+	 * The omap is a strange/beautiful device. The caches, memory
+	 * and register state are preserved across power saves.
+	 * We have to save and restore very little register state to
+	 * idle the omap.
+         *
+ 	 * Save interrupt, MPUI, ARM and UPLD control registers.
+	 */
+
+	if (cpu_is_omap1510()) {
+		MPUI1510_SAVE(OMAP_IH1_MIR);
+		MPUI1510_SAVE(OMAP_IH2_MIR);
+		MPUI1510_SAVE(MPUI_CTRL);
+		MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
+		MPUI1510_SAVE(MPUI_DSP_API_CONFIG);
+		MPUI1510_SAVE(EMIFS_CONFIG);
+		MPUI1510_SAVE(EMIFF_SDRAM_CONFIG);
+	} else if (cpu_is_omap16xx()) {
+		MPUI1610_SAVE(OMAP_IH1_MIR);
+		MPUI1610_SAVE(OMAP_IH2_0_MIR);
+		MPUI1610_SAVE(OMAP_IH2_1_MIR);
+		MPUI1610_SAVE(OMAP_IH2_2_MIR);
+		MPUI1610_SAVE(OMAP_IH2_3_MIR);
+		MPUI1610_SAVE(MPUI_CTRL);
+		MPUI1610_SAVE(MPUI_DSP_BOOT_CONFIG);
+		MPUI1610_SAVE(MPUI_DSP_API_CONFIG);
+		MPUI1610_SAVE(EMIFS_CONFIG);
+		MPUI1610_SAVE(EMIFF_SDRAM_CONFIG);
+	}
+
+	ARM_SAVE(ARM_CKCTL);
+	ARM_SAVE(ARM_IDLECT1);
+	ARM_SAVE(ARM_IDLECT2);
+	ARM_SAVE(ARM_EWUPCT);
+	ARM_SAVE(ARM_RSTCT1);
+	ARM_SAVE(ARM_RSTCT2);
+	ARM_SAVE(ARM_SYSST);
+	ULPD_SAVE(ULPD_CLOCK_CTRL);
+	ULPD_SAVE(ULPD_STATUS_REQ);
+
+	/*
+	 * Step 3: LOW_PWR signal enabling
+	 *
+	 * Allow the LOW_PWR signal to be visible on MPUIO5 ball.
+	 */
+	if (cpu_is_omap1510()) {
+		/* POWER_CTRL_REG = 0x1 (LOW_POWER is available) */
+		omap_writew(omap_readw(ULPD_POWER_CTRL) |
+			    OMAP1510_ULPD_LOW_POWER_REQ, ULPD_POWER_CTRL);
+	} else if (cpu_is_omap16xx()) {
+		/* POWER_CTRL_REG = 0x1 (LOW_POWER is available) */
+		omap_writew(omap_readw(ULPD_POWER_CTRL) |
+			    OMAP1610_ULPD_LOW_POWER_REQ, ULPD_POWER_CTRL);
+	}
+
+	/* configure LOW_PWR pin */
+	omap_cfg_reg(T20_1610_LOW_PWR);
+
+	/*
+	 * Step 4: OMAP DSP Shutdown
+	 */
+
+	/* Set DSP_RST = 1 and DSP_EN = 0, put DSP block into reset */
+	omap_writel((omap_readl(ARM_RSTCT1) | DSP_RST) & ~DSP_ENABLE,
+		    ARM_RSTCT1);
+
+	/* Set DSP boot mode to DSP-IDLE, DSP_BOOT_MODE = 0x2 */
+        omap_writel(DSP_IDLE_MODE, MPUI_DSP_BOOT_CONFIG);
+
+	/* Set EN_DSPCK = 0, stop DSP block clock */
+	omap_writel(omap_readl(ARM_CKCTL) & ~DSP_CLOCK_ENABLE, ARM_CKCTL);
+
+	/* Stop any DSP domain clocks */
+	omap_writel(omap_readl(ARM_IDLECT2) | (1<<EN_APICK), ARM_IDLECT2);
+	save_dsp_idlect2 = __raw_readw(DSP_IDLECT2);
+	__raw_writew(0, DSP_IDLECT2);
+
+	/*
+	 * Step 5: Wakeup Event Setup
+	 */
+
+	omap_pm_wakeup_setup();
+
+	/*
+	 * Step 6a: ARM and Traffic controller shutdown
+	 *
+	 * Step 6 starts here with clock and watchdog disable
+	 */
+
+	/* stop clocks */
+	mask32 = omap_readl(ARM_IDLECT2);
+	mask32 &= ~(1<<EN_WDTCK);  /* bit 0 -> 0 (WDT clock) */
+	mask32 |=  (1<<EN_XORPCK); /* bit 1 -> 1 (XORPCK clock) */
+	mask32 &= ~(1<<EN_PERCK);  /* bit 2 -> 0 (MPUPER_CK clock) */
+	mask32 &= ~(1<<EN_LCDCK);  /* bit 3 -> 0 (LCDC clock) */
+	mask32 &= ~(1<<EN_LBCK);   /* bit 4 -> 0 (local bus clock) */
+	mask32 |=  (1<<EN_APICK);  /* bit 6 -> 1 (MPUI clock) */
+	mask32 &= ~(1<<EN_TIMCK);  /* bit 7 -> 0 (MPU timer clock) */
+	mask32 &= ~(1<<DMACK_REQ); /* bit 8 -> 0 (DMAC clock) */
+	mask32 &= ~(1<<EN_GPIOCK); /* bit 9 -> 0 (GPIO clock) */
+	omap_writel(mask32, ARM_IDLECT2);
+
+	/* disable ARM watchdog */
+	omap_writel(0x00F5, OMAP_WDT_TIMER_MODE);
+	omap_writel(0x00A0, OMAP_WDT_TIMER_MODE);
+
+	/*
+	 * Step 6b: ARM and Traffic controller shutdown
+	 *
+	 * Step 6 continues here. Prepare jump to power management
+	 * assembly code in internal SRAM.
+	 *
+	 * Since the omap_cpu_suspend routine has been copied to
+	 * SRAM, we'll do an indirect procedure call to it and pass the
+	 * contents of arm_idlect1 and arm_idlect2 so it can restore
+	 * them when it wakes up and it will return.
+	 */
+
+	arg0 = arm_sleep_save[ARM_SLEEP_SAVE_ARM_IDLECT1];
+	arg1 = arm_sleep_save[ARM_SLEEP_SAVE_ARM_IDLECT2];
+
+	if (cpu_is_omap1510()) {
+		func_ptr = (void *)(OMAP1510_SRAM_API_SUSPEND);
+	} else if (cpu_is_omap1610() || cpu_is_omap1710()) {
+		func_ptr = (void *)(OMAP1610_SRAM_API_SUSPEND);
+	} else if (cpu_is_omap5912()) {
+		func_ptr = (void *)(OMAP5912_SRAM_API_SUSPEND);
+	}
+
+	/*
+	 * Step 6c: ARM and Traffic controller shutdown
+	 *
+	 * Jump to assembly code. The processor will stay there
+ 	 * until wake up.
+	 */
+
+        func_ptr(arg0, arg1);
+
+	/*
+	 * If we are here, processor is woken up!
+	 */
+
+	if (cpu_is_omap1510()) {
+		/* POWER_CTRL_REG = 0x0 (LOW_POWER is disabled) */
+		omap_writew(omap_readw(ULPD_POWER_CTRL) &
+			    ~OMAP1510_ULPD_LOW_POWER_REQ, ULPD_POWER_CTRL);
+	} else if (cpu_is_omap16xx()) {
+		/* POWER_CTRL_REG = 0x0 (LOW_POWER is disabled) */
+		omap_writew(omap_readw(ULPD_POWER_CTRL) &
+			    ~OMAP1610_ULPD_LOW_POWER_REQ, ULPD_POWER_CTRL);
+	}
+
+
+	/* Restore DSP clocks */
+	omap_writel(omap_readl(ARM_IDLECT2) | (1<<EN_APICK), ARM_IDLECT2);
+	__raw_writew(save_dsp_idlect2, DSP_IDLECT2);
+	ARM_RESTORE(ARM_IDLECT2);
+
+	/*
+	 * Restore ARM state, except ARM_IDLECT1/2 which omap_cpu_suspend did
+	 */
+
+	ARM_RESTORE(ARM_CKCTL);
+	ARM_RESTORE(ARM_EWUPCT);
+	ARM_RESTORE(ARM_RSTCT1);
+	ARM_RESTORE(ARM_RSTCT2);
+	ARM_RESTORE(ARM_SYSST);
+	ULPD_RESTORE(ULPD_CLOCK_CTRL);
+	ULPD_RESTORE(ULPD_STATUS_REQ);
+
+	if (cpu_is_omap1510()) {
+		MPUI1510_RESTORE(MPUI_CTRL);
+		MPUI1510_RESTORE(MPUI_DSP_BOOT_CONFIG);
+		MPUI1510_RESTORE(MPUI_DSP_API_CONFIG);
+		MPUI1510_RESTORE(EMIFS_CONFIG);
+		MPUI1510_RESTORE(EMIFF_SDRAM_CONFIG);
+		MPUI1510_RESTORE(OMAP_IH1_MIR);
+		MPUI1510_RESTORE(OMAP_IH2_MIR);
+	} else if (cpu_is_omap16xx()) {
+		MPUI1610_RESTORE(MPUI_CTRL);
+		MPUI1610_RESTORE(MPUI_DSP_BOOT_CONFIG);
+		MPUI1610_RESTORE(MPUI_DSP_API_CONFIG);
+		MPUI1610_RESTORE(EMIFS_CONFIG);
+		MPUI1610_RESTORE(EMIFF_SDRAM_CONFIG);
+
+		MPUI1610_RESTORE(OMAP_IH1_MIR);
+		MPUI1610_RESTORE(OMAP_IH2_0_MIR);
+		MPUI1610_RESTORE(OMAP_IH2_1_MIR);
+		MPUI1610_RESTORE(OMAP_IH2_2_MIR);
+		MPUI1610_RESTORE(OMAP_IH2_3_MIR);
+	}
+
+	/*
+	 * Reenable interrupts
+	 */
+
+	local_irq_enable();
+	local_fiq_enable();
+
+	printk("PM: OMAP%x is re-starting from deep sleep...\n", system_rev);
+
+	if (machine_is_omap_osk()) {
+		/* Let LED1 (D9) blink again */
+		tps65010_set_led(LED1, BLINK);
+	}
+}
+
+#if defined(DEBUG) && defined(CONFIG_PROC_FS)
+static int g_read_completed;
+
+/*
+ * Read system PM registers for debugging
+ */
+static int omap_pm_read_proc(
+	char *page_buffer,
+	char **my_first_byte,
+	off_t virtual_start,
+	int length,
+	int *eof,
+	void *data)
+{
+	int my_buffer_offset = 0;
+	char * const my_base = page_buffer;
+
+	ARM_SAVE(ARM_CKCTL);
+	ARM_SAVE(ARM_IDLECT1);
+	ARM_SAVE(ARM_IDLECT2);
+	ARM_SAVE(ARM_EWUPCT);
+	ARM_SAVE(ARM_RSTCT1);
+	ARM_SAVE(ARM_RSTCT2);
+	ARM_SAVE(ARM_SYSST);
+
+	ULPD_SAVE(ULPD_IT_STATUS);
+	ULPD_SAVE(ULPD_CLOCK_CTRL);
+	ULPD_SAVE(ULPD_SOFT_REQ);
+	ULPD_SAVE(ULPD_STATUS_REQ);
+	ULPD_SAVE(ULPD_DPLL_CTRL);
+	ULPD_SAVE(ULPD_POWER_CTRL);
+
+	if (cpu_is_omap1510()) {
+		MPUI1510_SAVE(MPUI_CTRL);
+		MPUI1510_SAVE(MPUI_DSP_STATUS);
+		MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
+		MPUI1510_SAVE(MPUI_DSP_API_CONFIG);
+		MPUI1510_SAVE(EMIFF_SDRAM_CONFIG);
+		MPUI1510_SAVE(EMIFS_CONFIG);
+	} else if (cpu_is_omap16xx()) {
+		MPUI1610_SAVE(MPUI_CTRL);
+		MPUI1610_SAVE(MPUI_DSP_STATUS);
+		MPUI1610_SAVE(MPUI_DSP_BOOT_CONFIG);
+		MPUI1610_SAVE(MPUI_DSP_API_CONFIG);
+		MPUI1610_SAVE(EMIFF_SDRAM_CONFIG);
+		MPUI1610_SAVE(EMIFS_CONFIG);
+	}
+
+	if (virtual_start == 0) {
+		g_read_completed = 0;
+
+		my_buffer_offset += sprintf(my_base + my_buffer_offset,
+		   "ARM_CKCTL_REG:            0x%-8x     \n"
+		   "ARM_IDLECT1_REG:          0x%-8x     \n"
+		   "ARM_IDLECT2_REG:          0x%-8x     \n"
+		   "ARM_EWUPCT_REG:           0x%-8x     \n"
+		   "ARM_RSTCT1_REG:           0x%-8x     \n"
+		   "ARM_RSTCT2_REG:           0x%-8x     \n"
+		   "ARM_SYSST_REG:            0x%-8x     \n"
+		   "ULPD_IT_STATUS_REG:       0x%-4x     \n"
+		   "ULPD_CLOCK_CTRL_REG:      0x%-4x     \n"
+		   "ULPD_SOFT_REQ_REG:        0x%-4x     \n"
+		   "ULPD_DPLL_CTRL_REG:       0x%-4x     \n"
+		   "ULPD_STATUS_REQ_REG:      0x%-4x     \n"
+		   "ULPD_POWER_CTRL_REG:      0x%-4x     \n",
+		   ARM_SHOW(ARM_CKCTL),
+		   ARM_SHOW(ARM_IDLECT1),
+		   ARM_SHOW(ARM_IDLECT2),
+		   ARM_SHOW(ARM_EWUPCT),
+		   ARM_SHOW(ARM_RSTCT1),
+		   ARM_SHOW(ARM_RSTCT2),
+		   ARM_SHOW(ARM_SYSST),
+		   ULPD_SHOW(ULPD_IT_STATUS),
+		   ULPD_SHOW(ULPD_CLOCK_CTRL),
+		   ULPD_SHOW(ULPD_SOFT_REQ),
+		   ULPD_SHOW(ULPD_DPLL_CTRL),
+		   ULPD_SHOW(ULPD_STATUS_REQ),
+		   ULPD_SHOW(ULPD_POWER_CTRL));
+
+		if (cpu_is_omap1510()) {
+			my_buffer_offset += sprintf(my_base + my_buffer_offset,
+			   "MPUI1510_CTRL_REG             0x%-8x \n"
+			   "MPUI1510_DSP_STATUS_REG:      0x%-8x \n"
+			   "MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
+		   	   "MPUI1510_DSP_API_CONFIG_REG:  0x%-8x \n"
+		   	   "MPUI1510_SDRAM_CONFIG_REG:    0x%-8x \n"
+		   	   "MPUI1510_EMIFS_CONFIG_REG:    0x%-8x \n",
+		   	   MPUI1510_SHOW(MPUI_CTRL),
+		   	   MPUI1510_SHOW(MPUI_DSP_STATUS),
+		   	   MPUI1510_SHOW(MPUI_DSP_BOOT_CONFIG),
+		   	   MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
+		   	   MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
+		   	   MPUI1510_SHOW(EMIFS_CONFIG));
+		} else if (cpu_is_omap16xx()) {
+			my_buffer_offset += sprintf(my_base + my_buffer_offset,
+			   "MPUI1610_CTRL_REG             0x%-8x \n"
+			   "MPUI1610_DSP_STATUS_REG:      0x%-8x \n"
+			   "MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
+		   	   "MPUI1610_DSP_API_CONFIG_REG:  0x%-8x \n"
+		   	   "MPUI1610_SDRAM_CONFIG_REG:    0x%-8x \n"
+		   	   "MPUI1610_EMIFS_CONFIG_REG:    0x%-8x \n",
+		   	   MPUI1610_SHOW(MPUI_CTRL),
+		   	   MPUI1610_SHOW(MPUI_DSP_STATUS),
+		   	   MPUI1610_SHOW(MPUI_DSP_BOOT_CONFIG),
+		   	   MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
+		   	   MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
+		   	   MPUI1610_SHOW(EMIFS_CONFIG));
+		}
+
+		g_read_completed++;
+	} else if (g_read_completed >= 1) {
+		 *eof = 1;
+		 return 0;
+	}
+	g_read_completed++;
+
+	*my_first_byte = page_buffer;
+	return  my_buffer_offset;
+}
+
+static void omap_pm_init_proc(void)
+{
+	struct proc_dir_entry *entry;
+
+	entry = create_proc_read_entry("driver/omap_pm",
+				       S_IWUSR | S_IRUGO, NULL,
+				       omap_pm_read_proc, 0);
+}
+
+#endif /* DEBUG && CONFIG_PROC_FS */
+
+/*
+ *	omap_pm_prepare - Do preliminary suspend work.
+ *	@state:		suspend state we're entering.
+ *
+ */
+//#include <asm/arch/hardware.h>
+
+static int omap_pm_prepare(u32 state)
+{
+	int error = 0;
+
+	switch (state)
+	{
+	case PM_SUSPEND_STANDBY:
+	case PM_SUSPEND_MEM:
+		break;
+
+	case PM_SUSPEND_DISK:
+		return -ENOTSUPP;
+
+	default:
+		return -EINVAL;
+	}
+
+	return error;
+}
+
+
+/*
+ *	omap_pm_enter - Actually enter a sleep state.
+ *	@state:		State we're entering.
+ *
+ */
+
+static int omap_pm_enter(u32 state)
+{
+	switch (state)
+	{
+	case PM_SUSPEND_STANDBY:
+	case PM_SUSPEND_MEM:
+		omap_pm_suspend();
+		break;
+
+	case PM_SUSPEND_DISK:
+		return -ENOTSUPP;
+
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+
+/**
+ *	omap_pm_finish - Finish up suspend sequence.
+ *	@state:		State we're coming out of.
+ *
+ *	This is called after we wake back up (or if entering the sleep state
+ *	failed).
+ */
+
+static int omap_pm_finish(u32 state)
+{
+	return 0;
+}
+
+
+struct pm_ops omap_pm_ops ={
+	.pm_disk_mode = 0,
+        .prepare        = omap_pm_prepare,
+        .enter          = omap_pm_enter,
+        .finish         = omap_pm_finish,
+};
+
+static int __init omap_pm_init(void)
+{
+	printk("Power Management for TI OMAP.\n");
+	pm_idle = omap_pm_idle;
+	/*
+	 * We copy the assembler sleep/wakeup routines to SRAM.
+	 * These routines need to be in SRAM as that's the only
+	 * memory the MPU can see when it wakes up.
+	 */
+
+#ifdef	CONFIG_ARCH_OMAP1510
+	if (cpu_is_omap1510()) {
+		memcpy((void *)OMAP1510_SRAM_IDLE_SUSPEND,
+		       omap1510_idle_loop_suspend,
+		       omap1510_idle_loop_suspend_sz);
+		memcpy((void *)OMAP1510_SRAM_API_SUSPEND, omap1510_cpu_suspend,
+		       omap1510_cpu_suspend_sz);
+	} else
+#endif
+	if (cpu_is_omap1610() || cpu_is_omap1710()) {
+		memcpy((void *)OMAP1610_SRAM_IDLE_SUSPEND,
+		       omap1610_idle_loop_suspend,
+		       omap1610_idle_loop_suspend_sz);
+		memcpy((void *)OMAP1610_SRAM_API_SUSPEND, omap1610_cpu_suspend,
+		       omap1610_cpu_suspend_sz);
+	} else if (cpu_is_omap5912()) {
+		memcpy((void *)OMAP5912_SRAM_IDLE_SUSPEND,
+		       omap1610_idle_loop_suspend,
+		       omap1610_idle_loop_suspend_sz);
+		memcpy((void *)OMAP5912_SRAM_API_SUSPEND, omap1610_cpu_suspend,
+		       omap1610_cpu_suspend_sz);
+	}
+
+	pm_set_ops(&omap_pm_ops);
+
+#if defined(DEBUG) && defined(CONFIG_PROC_FS)
+	omap_pm_init_proc();
+#endif
+
+	return 0;
+}
+__initcall(omap_pm_init);
+
diff -Nru a/arch/arm/mach-omap/sleep.S b/arch/arm/mach-omap/sleep.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-omap/sleep.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,314 @@
+/*
+ * linux/arch/arm/mach-omap/sleep.S
+ *
+ * Low-level OMAP1510/1610 sleep/wakeUp support
+ *
+ * Initial SA1110 code:
+ * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
+ *
+ * Adapted for PXA by Nicolas Pitre:
+ * Copyright (c) 2002 Monta Vista Software, Inc.
+ *
+ * Support for OMAP1510/1610 by Dirk Behme <dirk.behme@de.bosch.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/linkage.h>
+#include <asm/assembler.h>
+#include <asm/arch/io.h>
+#include <asm/arch/pm.h>
+
+		.text
+
+/*
+ * Forces OMAP into idle state
+ *
+ * omapXXXX_idle_loop_suspend()
+ *
+ * Note: This code get's copied to internal SRAM at boot. When the OMAP
+ *	 wakes up it continues execution at the point it went to sleep.
+ *
+ * Note: Because of slightly different configuration values we have
+ *       processor specific functions here.
+ */
+
+#ifdef CONFIG_ARCH_OMAP1510
+ENTRY(omap1510_idle_loop_suspend)
+
+	stmfd	sp!, {r0 - r12, lr}		@ save registers on stack
+
+	@ load base address of ARM_IDLECT1 and ARM_IDLECT2
+	mov	r4, #CLKGEN_REG_ASM_BASE & 0xff000000
+	orr	r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
+	orr	r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
+
+	@ turn off clock domains
+	@ get ARM_IDLECT2 into r2
+	ldrh	r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+	mov	r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff
+ 	orr	r5,r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff00
+	strh	r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+
+	@ request ARM idle
+	@ get ARM_IDLECT1 into r1
+	ldrh	r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+	orr	r3, r1, #OMAP1510_IDLE_LOOP_REQUEST & 0xffff
+	strh	r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+
+	mov	r5, #IDLE_WAIT_CYCLES & 0xff
+	orr     r5, r5, #IDLE_WAIT_CYCLES & 0xff00
+l_1510:	subs	r5, r5, #1
+	bne	l_1510
+/*
+ * Let's wait for the next clock tick to wake us up.
+ */
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c0, 4		@ wait for interrupt
+/*
+ * omap1510_idle_loop_suspend()'s resume point.
+ *
+ * It will just start executing here, so we'll restore stuff from the
+ * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
+ */
+
+	@ restore ARM_IDLECT1 and ARM_IDLECT2 and return
+	@ r1 has ARM_IDLECT1 and r2 still has ARM_IDLECT2
+	strh	r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+	strh	r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+
+	ldmfd   sp!, {r0 - r12, pc}     @ restore regs and return
+
+ENTRY(omap1510_idle_loop_suspend_sz)
+	.word	. - omap1510_idle_loop_suspend
+#endif /* CONFIG_ARCH_OMAP1510 */
+
+#if defined(CONFIG_ARCH_OMAP16XX)
+ENTRY(omap1610_idle_loop_suspend)
+
+	stmfd	sp!, {r0 - r12, lr}		@ save registers on stack
+
+	@ load base address of ARM_IDLECT1 and ARM_IDLECT2
+	mov	r4, #CLKGEN_REG_ASM_BASE & 0xff000000
+	orr	r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
+	orr	r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
+
+	@ turn off clock domains
+	@ get ARM_IDLECT2 into r2
+	ldrh	r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+	mov	r5, #OMAP1610_IDLE_CLOCK_DOMAINS & 0xff
+ 	orr	r5,r5, #OMAP1610_IDLE_CLOCK_DOMAINS & 0xff00
+	strh	r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+
+	@ request ARM idle
+	@ get ARM_IDLECT1 into r1
+	ldrh	r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+	orr	r3, r1, #OMAP1610_IDLE_LOOP_REQUEST & 0xffff
+	strh	r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+
+	mov	r5, #IDLE_WAIT_CYCLES & 0xff
+	orr     r5, r5, #IDLE_WAIT_CYCLES & 0xff00
+l_1610:	subs	r5, r5, #1
+	bne	l_1610
+/*
+ * Let's wait for the next clock tick to wake us up.
+ */
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c0, 4		@ wait for interrupt
+/*
+ * omap1610_idle_loop_suspend()'s resume point.
+ *
+ * It will just start executing here, so we'll restore stuff from the
+ * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
+ */
+
+	@ restore ARM_IDLECT1 and ARM_IDLECT2 and return
+	@ r1 has ARM_IDLECT1 and r2 still has ARM_IDLECT2
+	strh	r2, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+	strh	r1, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+
+	ldmfd   sp!, {r0 - r12, pc}     @ restore regs and return
+
+ENTRY(omap1610_idle_loop_suspend_sz)
+	.word	. - omap1610_idle_loop_suspend
+#endif /* CONFIG_ARCH_OMAP16XX */
+
+/*
+ * Forces OMAP into deep sleep state
+ *
+ * omapXXXX_cpu_suspend()
+ *
+ * The values of the registers ARM_IDLECT1 and ARM_IDLECT2 are passed
+ * as arg0 and arg1 from caller. arg0 is stored in register r0 and arg1
+ * in register r1.
+ *
+ * Note: This code get's copied to internal SRAM at boot. When the OMAP
+ *	 wakes up it continues execution at the point it went to sleep.
+ *
+ * Note: Because of errata work arounds we have processor specific functions
+ *       here. They are mostly the same, but slightly different.
+ *
+ */
+
+#ifdef CONFIG_ARCH_OMAP1510
+ENTRY(omap1510_cpu_suspend)
+
+	@ save registers on stack
+	stmfd	sp!, {r0 - r12, lr}
+
+	@ load base address of Traffic Controller
+	mov	r4, #TCMIF_ASM_BASE & 0xff000000
+	orr	r4, r4, #TCMIF_ASM_BASE & 0x00ff0000
+	orr	r4, r4, #TCMIF_ASM_BASE & 0x0000ff00
+
+	@ work around errata of OMAP1510 PDE bit for TC shut down
+	@ clear PDE bit
+	ldr	r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
+	bic	r5, r5, #PDE_BIT & 0xff
+	str	r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
+
+	@ set PWD_EN bit
+	and	r5, r5, #PWD_EN_BIT & 0xff
+	str	r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
+
+	@ prepare to put SDRAM into self-refresh manually
+	ldr	r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
+	orr	r5, r5, #SELF_REFRESH_MODE & 0xff000000
+	orr	r5, r5, #SELF_REFRESH_MODE & 0x000000ff
+	str	r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
+
+	@ prepare to put EMIFS to Sleep
+	ldr	r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
+	orr	r5, r5, #IDLE_EMIFS_REQUEST & 0xff
+	str	r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
+
+	@ load base address of ARM_IDLECT1 and ARM_IDLECT2
+	mov	r4, #CLKGEN_REG_ASM_BASE & 0xff000000
+	orr	r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
+	orr	r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
+
+	@ turn off clock domains
+	mov	r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff
+ 	orr	r5,r5, #OMAP1510_IDLE_CLOCK_DOMAINS & 0xff00
+	strh	r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+
+	@ request ARM idle
+	mov	r3, #OMAP1510_DEEP_SLEEP_REQUEST & 0xff
+	orr	r3, r3, #OMAP1510_DEEP_SLEEP_REQUEST & 0xff00
+	strh	r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+
+	mov	r5, #IDLE_WAIT_CYCLES & 0xff
+	orr     r5, r5, #IDLE_WAIT_CYCLES & 0xff00
+l_1510_2:
+	subs	r5, r5, #1
+	bne	l_1510_2
+/*
+ * Let's wait for the next wake up event to wake us up. r0 can't be
+ * used here because r0 holds ARM_IDLECT1
+ */
+	mov	r2, #0
+	mcr	p15, 0, r2, c7, c0, 4		@ wait for interrupt
+/*
+ * omap1510_cpu_suspend()'s resume point.
+ *
+ * It will just start executing here, so we'll restore stuff from the
+ * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
+ */
+	strh	r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+	strh	r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+
+	@ restore regs and return
+	ldmfd   sp!, {r0 - r12, pc}
+
+ENTRY(omap1510_cpu_suspend_sz)
+	.word	. - omap1510_cpu_suspend
+#endif /* CONFIG_ARCH_OMAP1510 */
+
+#if defined(CONFIG_ARCH_OMAP16XX)
+ENTRY(omap1610_cpu_suspend)
+
+	@ save registers on stack
+	stmfd	sp!, {r0 - r12, lr}
+
+	@ load base address of Traffic Controller
+	mov	r4, #TCMIF_ASM_BASE & 0xff000000
+	orr	r4, r4, #TCMIF_ASM_BASE & 0x00ff0000
+	orr	r4, r4, #TCMIF_ASM_BASE & 0x0000ff00
+
+	@ prepare to put SDRAM into self-refresh manually
+	ldr	r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
+	orr	r5, r5, #SELF_REFRESH_MODE & 0xff000000
+	orr	r5, r5, #SELF_REFRESH_MODE & 0x000000ff
+	str	r5, [r4, #EMIFF_SDRAM_CONFIG_ASM_OFFSET & 0xff]
+
+	@ prepare to put EMIFS to Sleep
+	ldr	r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
+	orr	r5, r5, #IDLE_EMIFS_REQUEST & 0xff
+	str	r5, [r4, #EMIFS_CONFIG_ASM_OFFSET & 0xff]
+
+	@ load base address of ARM_IDLECT1 and ARM_IDLECT2
+	mov	r4, #CLKGEN_REG_ASM_BASE & 0xff000000
+	orr	r4, r4, #CLKGEN_REG_ASM_BASE & 0x00ff0000
+	orr	r4, r4, #CLKGEN_REG_ASM_BASE & 0x0000ff00
+
+	@ turn off clock domains
+	mov	r5, #OMAP1610_IDLE_CLOCK_DOMAINS & 0xff
+ 	orr	r5,r5, #OMAP1610_IDLE_CLOCK_DOMAINS & 0xff00
+	strh	r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+
+	@ work around errata of OMAP1610/5912. Enable (!) peripheral
+	@ clock to let the chip go into deep sleep
+	ldrh	r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+ 	orr	r5,r5, #EN_PERCK_BIT & 0xff
+	strh	r5, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+
+	@ request ARM idle
+	mov	r3, #OMAP1610_DEEP_SLEEP_REQUEST & 0xff
+	orr	r3, r3, #OMAP1610_DEEP_SLEEP_REQUEST & 0xff00
+	strh	r3, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+
+	mov	r5, #IDLE_WAIT_CYCLES & 0xff
+	orr     r5, r5, #IDLE_WAIT_CYCLES & 0xff00
+l_1610_2:
+	subs	r5, r5, #1
+	bne	l_1610_2
+/*
+ * Let's wait for the next wake up event to wake us up. r0 can't be
+ * used here because r0 holds ARM_IDLECT1
+ */
+	mov	r2, #0
+	mcr	p15, 0, r2, c7, c0, 4		@ wait for interrupt
+/*
+ * omap1610_cpu_suspend()'s resume point.
+ *
+ * It will just start executing here, so we'll restore stuff from the
+ * stack, reset the ARM_IDLECT1 and ARM_IDLECT2.
+ */
+	strh	r1, [r4, #ARM_IDLECT2_ASM_OFFSET & 0xff]
+	strh	r0, [r4, #ARM_IDLECT1_ASM_OFFSET & 0xff]
+
+	@ restore regs and return
+	ldmfd   sp!, {r0 - r12, pc}
+
+ENTRY(omap1610_cpu_suspend_sz)
+	.word	. - omap1610_cpu_suspend
+#endif /* CONFIG_ARCH_OMAP16XX */
diff -Nru a/arch/arm/mach-omap/time.c b/arch/arm/mach-omap/time.c
--- a/arch/arm/mach-omap/time.c	2004-12-24 13:36:57 -08:00
+++ b/arch/arm/mach-omap/time.c	2004-12-24 13:36:57 -08:00
@@ -1,8 +1,14 @@
 /*
- * arch/arm/mach-omap/time.c
+ * linux/arch/arm/mach-omap/time.c
  *
- * OMAP Timer Tick 
+ * OMAP Timers
  *
+ * Copyright (C) 2004 Nokia Corporation
+ * Partial timer rewrite and additional VST timer support by
+ * Tony Lindgen <tony@atomide.com> and
+ * Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
+ *
+ * MPU timer code based on the older MPU timer code for OMAP
  * Copyright (C) 2000 RidgeRun, Inc.
  * Author: Greg Lonnon <glonnon@ridgerun.com>
  *
@@ -33,6 +39,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
+#include <linux/spinlock.h>
 
 #include <asm/system.h>
 #include <asm/hardware.h>
@@ -41,177 +48,135 @@
 #include <asm/irq.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
-#include <asm/arch/clocks.h>
-
-#ifndef __instrument
-#define __instrument
-#define __noinstrument __attribute__ ((no_instrument_function))
-#endif
 
-typedef struct {
-	u32 cntl;     /* CNTL_TIMER, R/W */
-	u32 load_tim; /* LOAD_TIM,   W */
-	u32 read_tim; /* READ_TIM,   R */
-} mputimer_regs_t;
-
-#define mputimer_base(n) \
-    ((volatile mputimer_regs_t*)IO_ADDRESS(OMAP_MPUTIMER_BASE + \
-				 (n)*OMAP_MPUTIMER_OFFSET))
-
-static inline unsigned long timer32k_read(int reg) {
-	unsigned long val;
-	val = omap_readw(reg + OMAP_32kHz_TIMER_BASE);
-	return val;
-}
-static inline void timer32k_write(int reg,int val) {
-	omap_writew(val, reg + OMAP_32kHz_TIMER_BASE);
-}
+struct sys_timer omap_timer;
 
 /*
- * How long is the timer interval? 100 HZ, right...
- * IRQ rate = (TVR + 1) / 32768 seconds
- * TVR = 32768 * IRQ_RATE -1
- * IRQ_RATE =  1/100
- * TVR = 326
- */
-#define TIMER32k_PERIOD 326
-//#define TIMER32k_PERIOD 0x7ff
-
-static inline void start_timer32k(void) {
-	timer32k_write(TIMER32k_CR,
-		       TIMER32k_TSS | TIMER32k_TRB |
-		       TIMER32k_INT | TIMER32k_ARL);
-}
+ * ---------------------------------------------------------------------------
+ * MPU timer
+ * ---------------------------------------------------------------------------
+ */
+#define OMAP_MPU_TIMER1_BASE		(0xfffec500)
+#define OMAP_MPU_TIMER2_BASE		(0xfffec600)
+#define OMAP_MPU_TIMER3_BASE		(0xfffec700)
+#define OMAP_MPU_TIMER_BASE		OMAP_MPU_TIMER1_BASE
+#define OMAP_MPU_TIMER_OFFSET		0x100
+
+#define MPU_TIMER_FREE			(1 << 6)
+#define MPU_TIMER_CLOCK_ENABLE		(1 << 5)
+#define MPU_TIMER_AR			(1 << 1)
+#define MPU_TIMER_ST			(1 << 0)
 
-#ifdef CONFIG_MACH_OMAP_PERSEUS2
 /*
- * After programming PTV with 0 and setting the MPUTIM_CLOCK_ENABLE
- * (external clock enable)  bit, the timer count rate is 6.5 MHz (13
- * MHZ input/2). !! The divider by 2 is undocumented !!
+ * MPU_TICKS_PER_SEC must be an even number, otherwise machinecycles_to_usecs
+ * will break. On P2, the timer count rate is 6.5 MHz after programming PTV
+ * with 0. This divides the 13MHz input by 2, and is undocumented.
  */
-#define MPUTICKS_PER_SEC (13000000/2)
-#else
-/*
- * After programming PTV with 0, the timer count rate is 6 MHz.
- * WARNING! this must be an even number, or machinecycles_to_usecs
- * below will break.
+#ifdef CONFIG_MACH_OMAP_PERSEUS2
+/* REVISIT: This ifdef construct should be replaced by a query to clock
+ * framework to see if timer base frequency is 12.0, 13.0 or 19.2 MHz.
  */
-#define MPUTICKS_PER_SEC  (12000000/2)
+#define MPU_TICKS_PER_SEC		(13000000 / 2)
+#else
+#define MPU_TICKS_PER_SEC		(12000000 / 2)
 #endif
 
-static int mputimer_started[3] = {0,0,0};
+#define MPU_TIMER_TICK_PERIOD		((MPU_TICKS_PER_SEC / HZ) - 1)
 
-static inline void __noinstrument start_mputimer(int n,
-						 unsigned long load_val)
-{
-	volatile mputimer_regs_t* timer = mputimer_base(n);
-
-	mputimer_started[n] = 0;
-	timer->cntl = MPUTIM_CLOCK_ENABLE;
-	udelay(1);
-
-	timer->load_tim = load_val;
-        udelay(1);
-	timer->cntl = (MPUTIM_CLOCK_ENABLE | MPUTIM_AR | MPUTIM_ST);
-	mputimer_started[n] = 1;
-}
+typedef struct {
+	u32 cntl;			/* CNTL_TIMER, R/W */
+	u32 load_tim;			/* LOAD_TIM,   W */
+	u32 read_tim;			/* READ_TIM,   R */
+} omap_mpu_timer_regs_t;
 
-static inline unsigned long __noinstrument
-read_mputimer(int n)
-{
-	volatile mputimer_regs_t* timer = mputimer_base(n);
-	return (mputimer_started[n] ? timer->read_tim : 0);
-}
+#define omap_mpu_timer_base(n)						\
+((volatile omap_mpu_timer_regs_t*)IO_ADDRESS(OMAP_MPU_TIMER_BASE +	\
+				 (n)*OMAP_MPU_TIMER_OFFSET))
 
-void __noinstrument start_mputimer1(unsigned long load_val)
-{
-	start_mputimer(0, load_val);
-}
-void __noinstrument start_mputimer2(unsigned long load_val)
+static inline unsigned long omap_mpu_timer_read(int nr)
 {
-	start_mputimer(1, load_val);
-}
-void __noinstrument start_mputimer3(unsigned long load_val)
-{
-	start_mputimer(2, load_val);
+	volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
+	return timer->read_tim;
 }
 
-unsigned long __noinstrument read_mputimer1(void)
-{
-	return read_mputimer(0);
-}
-unsigned long __noinstrument read_mputimer2(void)
-{
-	return read_mputimer(1);
-}
-unsigned long __noinstrument read_mputimer3(void)
+static inline void omap_mpu_timer_start(int nr, unsigned long load_val)
 {
-	return read_mputimer(2);
-}
+	volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
 
-unsigned long __noinstrument do_getmachinecycles(void)
-{
-	return 0 - read_mputimer(0);
+	timer->cntl = MPU_TIMER_CLOCK_ENABLE;
+	udelay(1);
+	timer->load_tim = load_val;
+        udelay(1);
+	timer->cntl = (MPU_TIMER_CLOCK_ENABLE | MPU_TIMER_AR | MPU_TIMER_ST);
 }
 
-unsigned long __noinstrument machinecycles_to_usecs(unsigned long mputicks)
+unsigned long omap_mpu_timer_ticks_to_usecs(unsigned long nr_ticks)
 {
 	/* Round up to nearest usec */
-	return ((mputicks * 1000) / (MPUTICKS_PER_SEC / 2 / 1000) + 1) >> 1;
+	return ((nr_ticks * 1000) / (MPU_TICKS_PER_SEC / 2 / 1000) + 1) >> 1;
 }
 
 /*
- * This marks the time of the last system timer interrupt
- * that was *processed by the ISR* (timer 2).
+ * Last processed system timer interrupt
  */
-static unsigned long systimer_mark;
+static unsigned long omap_mpu_timer_last = 0;
 
-static unsigned long omap_gettimeoffset(void)
+/*
+ * Returns elapsed usecs since last system timer interrupt
+ */
+static unsigned long omap_mpu_timer_gettimeoffset(void)
 {
-	/* Return elapsed usecs since last system timer ISR */
-	return machinecycles_to_usecs(do_getmachinecycles() - systimer_mark);
+	unsigned long now = 0 - omap_mpu_timer_read(0);
+	unsigned long elapsed = now - omap_mpu_timer_last;
+
+	return omap_mpu_timer_ticks_to_usecs(elapsed);
 }
 
-static irqreturn_t
-omap_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+/*
+ * Elapsed time between interrupts is calculated using timer0.
+ * Latency during the interrupt is calculated using timer1.
+ * Both timer0 and timer1 are counting at 6MHz (P2 6.5MHz).
+ */
+static irqreturn_t omap_mpu_timer_interrupt(int irq, void *dev_id,
+					struct pt_regs *regs)
 {
-	unsigned long now, ilatency;
-
-	/*
-	 * Mark the time at which the timer interrupt ocurred using
-	 * timer1. We need to remove interrupt latency, which we can
-	 * retrieve from the current system timer2 counter. Both the
-	 * offset timer1 and the system timer2 are counting at 6MHz,
-	 * so we're ok.
-	 */
-	now = 0 - read_mputimer1();
-	ilatency = MPUTICKS_PER_SEC / 100 - read_mputimer2();
-	systimer_mark = now - ilatency;
+	unsigned long now, latency;
 
+	write_seqlock(&xtime_lock);
+	now = 0 - omap_mpu_timer_read(0);
+	latency = MPU_TICKS_PER_SEC / HZ - omap_mpu_timer_read(1);
+	omap_mpu_timer_last = now - latency;
 	timer_tick(regs);
+	write_sequnlock(&xtime_lock);
 
 	return IRQ_HANDLED;
 }
 
-static struct irqaction omap_timer_irq = {
-	.name		= "OMAP Timer Tick",
+static struct irqaction omap_mpu_timer_irq = {
+	.name		= "mpu timer",
 	.flags		= SA_INTERRUPT,
-	.handler	= omap_timer_interrupt
+	.handler	= omap_mpu_timer_interrupt
 };
 
-void __init omap_init_time(void)
+static __init void omap_init_mpu_timer(void)
 {
-	/* Since we don't call request_irq, we must init the structure */
-	gettimeoffset = omap_gettimeoffset;
+	omap_timer.offset = omap_mpu_timer_gettimeoffset;
+	setup_irq(INT_TIMER2, &omap_mpu_timer_irq);
+	omap_mpu_timer_start(0, 0xffffffff);
+	omap_mpu_timer_start(1, MPU_TIMER_TICK_PERIOD);
+}
 
-#ifdef OMAP1510_USE_32KHZ_TIMER
-	timer32k_write(TIMER32k_CR, 0x0);
-	timer32k_write(TIMER32k_TVR,TIMER32k_PERIOD);
-	setup_irq(INT_OS_32kHz_TIMER, &omap_timer_irq);
-	start_timer32k();
-#else
-	setup_irq(INT_TIMER2, &omap_timer_irq);
-	start_mputimer2(MPUTICKS_PER_SEC / 100 - 1);
-#endif
+/*
+ * ---------------------------------------------------------------------------
+ * Timer initialization
+ * ---------------------------------------------------------------------------
+ */
+void __init omap_timer_init(void)
+{
+	omap_init_mpu_timer();
 }
 
+struct sys_timer omap_timer = {
+	.init		= omap_timer_init,
+	.offset		= NULL,		/* Initialized later */
+};
diff -Nru a/arch/arm/mach-omap/usb.c b/arch/arm/mach-omap/usb.c
--- a/arch/arm/mach-omap/usb.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/mach-omap/usb.c	2004-12-24 13:37:19 -08:00
@@ -48,8 +48,10 @@
  */
 
 /* TESTED ON:
- *  - 1611B H2 (with usb1 mini-AB)
- *  - 1510 Innovator with built-in transceiver (custom cable feeding 5V VBUS)
+ *  - 1611B H2 (with usb1 mini-AB) using standard Mini-B or OTG cables
+ *  - 1510 Innovator UDC with bundled usb0 cable
+ *  - 1510 Innovator OHCI with bundled usb1/usb2 cable
+ *  - 1510 Innovator OHCI with custom usb0 cable, feeding 5V VBUS
  *  - 1710 custom development board using alternate pin group
  */
 
@@ -92,7 +94,10 @@
 	u32	syscon1 = 0;
 
 	if (nwires == 0) {
-		USB_TRANSCEIVER_CTRL_REG &= ~(1 << 3);
+		if (!cpu_is_omap15xx()) {
+			/* pulldown D+/D- */
+			USB_TRANSCEIVER_CTRL_REG &= ~(3 << 1);
+		}
 		return 0;
 	}
 
@@ -101,36 +106,30 @@
 	 * USB0_VP and USB0_VM are always set on 1510, there's no muxing
 	 * available for them.
 	 */
-	if (nwires >= 2 && !cpu_is_omap1510()) {
+	if (nwires >= 2 && !cpu_is_omap15xx()) {
 		omap_cfg_reg(AA9_USB0_VP);
 		omap_cfg_reg(R9_USB0_VM);
 	}
+	if (is_device)
+		omap_cfg_reg(W4_USB_PUEN);
 
 	/* internal transceiver */
 	if (nwires == 2) {
-		if (cpu_is_omap1510()) {
-			/* This works for OHCI on 1510-Innovator, nothing to mux */
+		if (cpu_is_omap15xx()) {
+			/* This works for OHCI on 1510-Innovator */
 			return 0;
 		}
 
-#if 0
 		/* NOTE:  host OR device mode for now, no OTG */
-		USB_TRANSCEIVER_CTRL_REG &= ~(3 << 4);
+		USB_TRANSCEIVER_CTRL_REG &= ~(7 << 4);
 		if (is_device) {
-			omap_cfg_reg(W4_USB_PUEN);
 			omap_cfg_reg(R18_1510_USB_GPIO0);
 			// omap_cfg_reg(USB0_VBUS);
-			// omap_cfg_reg(USB0_PUEN);
 			// USB_TRANSCEIVER_CTRL_REG.CONF_USB0_PORT_R = 7
-			// when USB0_PUEN is needed
 		} else /* host mode needs D+ and D- pulldowns */
 			USB_TRANSCEIVER_CTRL_REG &= ~(3 << 1);
+
 		return 3 << 16;
-#else
-		/* FIXME: 1610 needs to return the right value here */
-		printk(KERN_ERR "usb0 internal transceiver, nyet\n");
-		return 0;
-#endif
 	}
 
 	/* alternate pin config, external transceiver */
@@ -170,7 +169,7 @@
 {
 	u32	syscon1 = 0;
 
-	if (nwires != 6)
+	if (nwires != 6 && !cpu_is_omap15xx())
 		USB_TRANSCEIVER_CTRL_REG &= ~CONF_USB1_UNI_R;
 	if (nwires == 0)
 		return 0;
@@ -178,11 +177,11 @@
 	/* external transceiver */
 	omap_cfg_reg(USB1_TXD);
 	omap_cfg_reg(USB1_TXEN);
-	if (cpu_is_omap1510()) {
+	if (cpu_is_omap15xx()) {
 		omap_cfg_reg(USB1_SEO);
 		omap_cfg_reg(USB1_SPEED);
 		// SUSP
-	} else if (cpu_is_omap1610() || cpu_is_omap5912() || cpu_is_omap1710()) {
+	} else if (cpu_is_omap16xx()) {
 		omap_cfg_reg(W13_1610_USB1_SE0);
 		omap_cfg_reg(R13_1610_USB1_SPEED);
 		// SUSP
@@ -203,7 +202,8 @@
 		syscon1 = 3;
 		omap_cfg_reg(USB1_VP);
 		omap_cfg_reg(USB1_VM);
-		USB_TRANSCEIVER_CTRL_REG |= CONF_USB1_UNI_R;
+		if (!cpu_is_omap15xx())
+			USB_TRANSCEIVER_CTRL_REG |= CONF_USB1_UNI_R;
 		break;
 	default:
 		printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
@@ -216,31 +216,32 @@
 {
 	u32	syscon1 = 0;
 
-	if (alt_pingroup)
+	if (alt_pingroup || nwires == 0)
 		return 0;
-	if (nwires != 6)
+	if (nwires != 6 && !cpu_is_omap15xx())
 		USB_TRANSCEIVER_CTRL_REG &= ~CONF_USB2_UNI_R;
 	if (nwires == 0)
 		return 0;
 
 	/* external transceiver */
-	if (cpu_is_omap1510()) {
+	if (cpu_is_omap15xx()) {
 		omap_cfg_reg(USB2_TXD);
 		omap_cfg_reg(USB2_TXEN);
 		omap_cfg_reg(USB2_SEO);
 		if (nwires != 3)
 			omap_cfg_reg(USB2_RCV);
-	} else if (cpu_is_omap1610() || cpu_is_omap5912() || cpu_is_omap1710()) {
+		/* there is no USB2_SPEED */
+	} else if (cpu_is_omap16xx()) {
 		omap_cfg_reg(V6_USB2_TXD);
 		omap_cfg_reg(W9_USB2_TXEN);
 		omap_cfg_reg(W5_USB2_SE0);
 		if (nwires != 3)
 			omap_cfg_reg(Y5_USB2_RCV);
+		// FIXME omap_cfg_reg(USB2_SPEED);
 	} else {
 		pr_debug("usb unrecognized\n");
 	}
 	// omap_cfg_reg(USB2_SUSP);
-	// FIXME omap_cfg_reg(USB2_SPEED);
 
 	switch (nwires) {
 	case 3:
@@ -251,14 +252,14 @@
 		break;
 	case 6:
 		syscon1 = 3;
-		if (cpu_is_omap1510()) {
+		if (cpu_is_omap15xx()) {
 			omap_cfg_reg(USB2_VP);
 			omap_cfg_reg(USB2_VM);
 		} else {
 			omap_cfg_reg(AA9_USB2_VP);
 			omap_cfg_reg(R9_USB2_VM);
+			USB_TRANSCEIVER_CTRL_REG |= CONF_USB2_UNI_R;
 		}
-		USB_TRANSCEIVER_CTRL_REG |= CONF_USB2_UNI_R;
 		break;
 	default:
 		printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
@@ -337,7 +338,7 @@
 	.dev = {
 		.release		= usb_release,
 		.dma_mask		= &ohci_dmamask,
-		.coherent_dma_mask	= 0x0fffffff,
+		.coherent_dma_mask	= 0xffffffff,
 	},
 	.num_resources	= ARRAY_SIZE(ohci_resources),
 	.resource		= ohci_resources,
@@ -375,7 +376,11 @@
 
 // FIXME correct answer depends on hmc_mode,
 // as does any nonzero value for config->otg port number
+#ifdef	CONFIG_USB_GADGET_OMAP
+#define	is_usb0_device(config)	1
+#else
 #define	is_usb0_device(config)	0
+#endif
 
 /*-------------------------------------------------------------------------*/
 
@@ -420,7 +425,7 @@
 	if (alt_pingroup)
 		printk(", usb2 alt %d wires", config->pins[2]);
 	else if (config->pins[0])
-		printk(", usb0 %d wires%s", config->pins[2],
+		printk(", usb0 %d wires%s", config->pins[0],
 			is_usb0_device(config) ? " (dev)" : "");
 	if (config->pins[1])
 		printk(", usb1 %d wires", config->pins[1]);
@@ -477,6 +482,19 @@
 
 #ifdef	CONFIG_ARCH_OMAP1510
 
+#define ULPD_SOFT_REQ_REG	__REG16(ULPD_SOFT_REQ)
+#define SOFT_UDC_REQ		(1 << 4)
+#define SOFT_DPLL_REQ		(1 << 0)
+
+#define ULPD_DPLL_CTRL_REG	__REG16(ULPD_DPLL_CTRL)
+#define DPLL_IOB		(1 << 13)
+#define DPLL_PLL_ENABLE		(1 << 4)
+#define DPLL_LOCK		(1 << 0)
+
+#define ULPD_APLL_CTRL_REG	__REG16(ULPD_APLL_CTRL)
+#define APLL_NDPLL_SWITCH	(1 << 0)
+
+
 static void __init omap_1510_usb_init(struct omap_usb_config *config)
 {
 	int status;
@@ -490,16 +508,43 @@
 	val |= (config->hmc_mode << 1);
 	omap_writel(val, MOD_CONF_CTRL_0);
 
-	// FIXME this has a UDC controller too
+	printk("USB: hmc %d", config->hmc_mode);
+	if (config->pins[0])
+		printk(", usb0 %d wires%s", config->pins[0],
+			is_usb0_device(config) ? " (dev)" : "");
+	if (config->pins[1])
+		printk(", usb1 %d wires", config->pins[1]);
+	if (config->pins[2])
+		printk(", usb2 %d wires", config->pins[2]);
+	printk("\n");
+
+	/* use DPLL for 48 MHz function clock */
+	pr_debug("APLL %04x DPLL %04x REQ %04x\n", ULPD_APLL_CTRL_REG,
+			ULPD_DPLL_CTRL_REG, ULPD_SOFT_REQ_REG);
+	ULPD_APLL_CTRL_REG &= ~APLL_NDPLL_SWITCH;
+	ULPD_DPLL_CTRL_REG |= DPLL_IOB | DPLL_PLL_ENABLE;
+	ULPD_SOFT_REQ_REG |= SOFT_UDC_REQ | SOFT_DPLL_REQ;
+	while (!(ULPD_DPLL_CTRL_REG & DPLL_LOCK))
+		cpu_relax();
+
+#ifdef	CONFIG_USB_GADGET_OMAP
+	if (config->register_dev) {
+		udc_device.dev.platform_data = config;
+		status = platform_device_register(&udc_device);
+		if (status)
+			pr_debug("can't register UDC device, %d\n", status);
+		/* udc driver gates 48MHz by D+ pullup */
+	}
+#endif
 
 #if	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
-	if (config->otg || config->register_host) {
+	if (config->register_host) {
 		ohci_device.dev.platform_data = config;
 		status = platform_device_register(&ohci_device);
 		if (status)
 			pr_debug("can't register OHCI device, %d\n", status);
+		/* hcd explicitly gates 48MHz */
 	}
-	// FIXME completely untested ...
 #endif
 
 }
@@ -524,12 +569,9 @@
 	}
 	platform_data = *config;
 
-	if (cpu_is_omap730()
-			|| cpu_is_omap1610()
-			|| cpu_is_omap1710()
-			|| cpu_is_omap5912())
+	if (cpu_is_omap730() || cpu_is_omap16xx())
 		omap_otg_init(&platform_data);
-	else if (cpu_is_omap1510())
+	else if (cpu_is_omap15xx())
 		omap_1510_usb_init(&platform_data);
 	else {
 		printk(KERN_ERR "USB: No init for your chip yet\n");
diff -Nru a/arch/arm/mach-pxa/Makefile.boot b/arch/arm/mach-pxa/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-pxa/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2 @@
+   zreladdr-y	:= 0xa0008000
+
diff -Nru a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
--- a/arch/arm/mach-pxa/generic.c	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/mach-pxa/generic.c	2004-12-24 13:36:31 -08:00
@@ -49,6 +49,10 @@
 	int gafr;
 
 	local_irq_save(flags);
+	if (gpio_mode & GPIO_DFLT_LOW)
+		GPCR(gpio) = GPIO_bit(gpio);
+	else if (gpio_mode & GPIO_DFLT_HIGH)
+		GPSR(gpio) = GPIO_bit(gpio);
 	if (gpio_mode & GPIO_MD_MASK_DIR)
 		GPDR(gpio) |= GPIO_bit(gpio);
 	else
@@ -134,7 +138,6 @@
 {
 	pxamci_device.dev.platform_data = info;
 }
-EXPORT_SYMBOL(pxa_set_mci_info);
 
 
 static struct pxa2xx_udc_mach_info pxa_udc_info;
@@ -143,7 +146,6 @@
 {
 	memcpy(&pxa_udc_info, info, sizeof *info);
 }
-EXPORT_SYMBOL(pxa_set_udc_info);
 
 static struct resource pxa2xx_udc_resources[] = {
 	[0] = {
@@ -177,7 +179,6 @@
 {
 	memcpy(&pxa_fb_info,hard_pxa_fb_info,sizeof(struct pxafb_mach_info));
 }
-EXPORT_SYMBOL(set_pxa_fb_info);
 
 static struct resource pxafb_resources[] = {
 	[0] = {
diff -Nru a/arch/arm/mach-pxa/generic.h b/arch/arm/mach-pxa/generic.h
--- a/arch/arm/mach-pxa/generic.h	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/mach-pxa/generic.h	2004-12-24 13:37:18 -08:00
@@ -9,9 +9,11 @@
  * published by the Free Software Foundation.
  */
 
+struct sys_timer;
+
+extern struct sys_timer pxa_timer;
 extern void __init pxa_map_io(void);
 extern void __init pxa_init_irq(void);
-extern void __init pxa_init_time(void);
 
 extern unsigned int get_clk_frequency_khz(int info);
 
diff -Nru a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
--- a/arch/arm/mach-pxa/idp.c	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/mach-pxa/idp.c	2004-12-24 13:36:16 -08:00
@@ -119,6 +119,6 @@
 	BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
 	MAPIO(idp_map_io)
 	INITIRQ(idp_init_irq)
-	INITTIME(pxa_init_time)
+	.timer		= &pxa_timer,
 	INIT_MACHINE(idp_init)
 MACHINE_END
diff -Nru a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
--- a/arch/arm/mach-pxa/lubbock.c	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/mach-pxa/lubbock.c	2004-12-24 13:36:47 -08:00
@@ -33,11 +33,14 @@
 #include <asm/arch/lubbock.h>
 #include <asm/arch/udc.h>
 #include <asm/arch/pxafb.h>
+#include <asm/arch/mmc.h>
 #include <asm/hardware/sa1111.h>
 
 #include "generic.h"
 
 
+#define LUB_MISC_WR		__LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
+
 void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
 {
 	unsigned long flags;
@@ -181,10 +184,25 @@
 	.lccr3		= LCCR3_PCP | LCCR3_Acb(255),
 };
 
+static int lubbock_mci_init(struct device *dev, irqreturn_t (*lubbock_detect_int)(int, void *, struct pt_regs *), void *data)
+{
+	/* setup GPIO for PXA25x MMC controller	*/
+	pxa_gpio_mode(GPIO6_MMCCLK_MD);
+	pxa_gpio_mode(GPIO8_MMCCS0_MD);
+
+	return 0;
+}
+
+static struct pxamci_platform_data lubbock_mci_platform_data = {
+	.ocr_mask	= MMC_VDD_32_33|MMC_VDD_33_34,
+	.init 		= lubbock_mci_init,
+};
+
 static void __init lubbock_init(void)
 {
 	pxa_set_udc_info(&udc_info);
 	set_pxa_fb_info(&sharp_lm8v31);
+	pxa_set_mci_info(&lubbock_mci_platform_data);
 	(void) platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
@@ -221,6 +239,6 @@
 	BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
 	MAPIO(lubbock_map_io)
 	INITIRQ(lubbock_init_irq)
-	INITTIME(pxa_init_time)
+	.timer		= &pxa_timer,
 	INIT_MACHINE(lubbock_init)
 MACHINE_END
diff -Nru a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
--- a/arch/arm/mach-pxa/mainstone.c	2004-12-24 13:37:31 -08:00
+++ b/arch/arm/mach-pxa/mainstone.c	2004-12-24 13:37:31 -08:00
@@ -34,6 +34,7 @@
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/mainstone.h>
 #include <asm/arch/pxafb.h>
+#include <asm/arch/mmc.h>
 
 #include "generic.h"
 
@@ -170,6 +171,61 @@
 	.pxafb_backlight_power	= mainstone_backlight_power,
 };
 
+static int mainstone_mci_init(struct device *dev, irqreturn_t (*mstone_detect_int)(int, void *, struct pt_regs *), void *data)
+{
+	int err;
+
+	/*
+	 * setup GPIO for PXA27x MMC controller
+	 */
+	pxa_gpio_mode(GPIO32_MMCCLK_MD);
+	pxa_gpio_mode(GPIO112_MMCCMD_MD);
+	pxa_gpio_mode(GPIO92_MMCDAT0_MD);
+	pxa_gpio_mode(GPIO109_MMCDAT1_MD);
+	pxa_gpio_mode(GPIO110_MMCDAT2_MD);
+	pxa_gpio_mode(GPIO111_MMCDAT3_MD);
+
+	/* make sure SD/Memory Stick multiplexer's signals
+	 * are routed to MMC controller
+	 */
+	MST_MSCWR1 &= ~MST_MSCWR1_MS_SEL;
+
+	err = request_irq(MAINSTONE_MMC_IRQ, mstone_detect_int, SA_INTERRUPT,
+			     "MMC card detect", data);
+	if (err) {
+		printk(KERN_ERR "mainstone_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+static void mainstone_mci_setpower(struct device *dev, unsigned int vdd)
+{
+	struct pxamci_platform_data* p_d = dev->platform_data;
+
+	if (( 1 << vdd) & p_d->ocr_mask) {
+		printk(KERN_DEBUG "%s: on\n", __FUNCTION__);
+		MST_MSCWR1 |= MST_MSCWR1_MMC_ON;
+		MST_MSCWR1 &= ~MST_MSCWR1_MS_SEL;
+	} else {
+		printk(KERN_DEBUG "%s: off\n", __FUNCTION__);
+		MST_MSCWR1 &= ~MST_MSCWR1_MMC_ON;
+	}
+}
+
+static void mainstone_mci_exit(struct device *dev, void *data)
+{
+	free_irq(MAINSTONE_MMC_IRQ, data);
+}
+
+static struct pxamci_platform_data mainstone_mci_platform_data = {
+	.ocr_mask	= MMC_VDD_32_33|MMC_VDD_33_34,
+	.init 		= mainstone_mci_init,
+	.setpower 	= mainstone_mci_setpower,
+	.exit		= mainstone_mci_exit,
+};
+
 static void __init mainstone_init(void)
 {
 	platform_device_register(&smc91x_device);
@@ -180,6 +236,8 @@
 		set_pxa_fb_info(&toshiba_ltm04c380k);
 	else
 		set_pxa_fb_info(&toshiba_ltm035a776c);
+
+	pxa_set_mci_info(&mainstone_mci_platform_data);
 }
 
 
@@ -198,6 +256,6 @@
 	BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
 	MAPIO(mainstone_map_io)
 	INITIRQ(mainstone_init_irq)
-	INITTIME(pxa_init_time)
+	.timer		= &pxa_timer,
 	INIT_MACHINE(mainstone_init)
 MACHINE_END
diff -Nru a/arch/arm/mach-pxa/pm.c b/arch/arm/mach-pxa/pm.c
--- a/arch/arm/mach-pxa/pm.c	2004-12-24 13:37:00 -08:00
+++ b/arch/arm/mach-pxa/pm.c	2004-12-24 13:37:00 -08:00
@@ -47,9 +47,6 @@
  */
 enum {	SLEEP_SAVE_START = 0,
 
-	SLEEP_SAVE_OIER,
-	SLEEP_SAVE_OSMR0, SLEEP_SAVE_OSMR1, SLEEP_SAVE_OSMR2, SLEEP_SAVE_OSMR3,
-
 	SLEEP_SAVE_GPLR0, SLEEP_SAVE_GPLR1, SLEEP_SAVE_GPLR2,
 	SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2,
 	SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2,
@@ -66,7 +63,7 @@
 };
 
 
-static int pxa_pm_enter(u32 state)
+static int pxa_pm_enter(suspend_state_t state)
 {
 	unsigned long sleep_save[SLEEP_SAVE_SIZE];
 	unsigned long checksum = 0;
@@ -81,13 +78,6 @@
 	rtc.tv_nsec = 0;
 	save_time_delta(&delta, &rtc);
 
-	/* save vital registers */
-	SAVE(OSMR0);
-	SAVE(OSMR1);
-	SAVE(OSMR2);
-	SAVE(OSMR3);
-	SAVE(OIER);
-
 	SAVE(GPLR0); SAVE(GPLR1); SAVE(GPLR2);
 	SAVE(GPDR0); SAVE(GPDR1); SAVE(GPDR2);
 	SAVE(GRER0); SAVE(GRER1); SAVE(GRER2);
@@ -148,15 +138,6 @@
 
 	PSSR = PSSR_RDH | PSSR_PH;
 
-	RESTORE(OSMR0);
-	RESTORE(OSMR1);
-	RESTORE(OSMR2);
-	RESTORE(OSMR3);
-	RESTORE(OIER);
-
-	/* OSMR0 is the system timer: make sure OSCR is sufficiently behind */
-	OSCR = OSMR0 - LATCH;
-
 	RESTORE(CKEN);
 
 	ICLR = 0;
@@ -182,7 +163,7 @@
 /*
  * Called after processes are frozen, but before we shut down devices.
  */
-static int pxa_pm_prepare(u32 state)
+static int pxa_pm_prepare(suspend_state_t state)
 {
 	return 0;
 }
@@ -190,7 +171,7 @@
 /*
  * Called after devices are re-setup, but before processes are thawed.
  */
-static int pxa_pm_finish(u32 state)
+static int pxa_pm_finish(suspend_state_t state)
 {
 	return 0;
 }
diff -Nru a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
--- a/arch/arm/mach-pxa/pxa27x.c	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/mach-pxa/pxa27x.c	2004-12-24 13:36:49 -08:00
@@ -14,11 +14,13 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <asm/arch/pxa-regs.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/device.h>
 
 #include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/arch/pxa-regs.h>
 
 #include "generic.h"
 
@@ -117,3 +119,45 @@
 EXPORT_SYMBOL(get_clk_frequency_khz);
 EXPORT_SYMBOL(get_memclk_frequency_10khz);
 EXPORT_SYMBOL(get_lcdclk_frequency_10khz);
+
+
+/*
+ * device registration specific to PXA27x.
+ */
+
+static u64 pxa27x_dmamask = 0xffffffffUL;
+
+static struct resource pxa27x_ohci_resources[] = {
+	[0] = {
+		.start  = 0x4C000000,
+		.end    = 0x4C00ff6f,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = IRQ_USBH1,
+		.end    = IRQ_USBH1,
+		.flags  = IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device ohci_device = {
+	.name		= "pxa27x-ohci",
+	.id		= -1,
+	.dev		= {
+		.dma_mask = &pxa27x_dmamask,
+		.coherent_dma_mask = 0xffffffff,
+	},
+	.num_resources  = ARRAY_SIZE(pxa27x_ohci_resources),
+	.resource       = pxa27x_ohci_resources,
+};
+
+static struct platform_device *devices[] __initdata = {
+	&ohci_device,
+};
+
+static int __init pxa27x_init(void)
+{
+	return platform_add_devices(devices, ARRAY_SIZE(devices));
+}
+
+subsys_initcall(pxa27x_init);
diff -Nru a/arch/arm/mach-pxa/ssp.c b/arch/arm/mach-pxa/ssp.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-pxa/ssp.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,319 @@
+/*
+ *  linux/arch/arm/mach-pxa/ssp.c
+ *
+ *  based on linux/arch/arm/mach-sa1100/ssp.c by Russell King
+ *
+ *  Copyright (C) 2003 Russell King.
+ *  Copyright (C) 2003 Wolfson Microelectronics PLC
+ *
+ * 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.
+ *
+ *  PXA2xx SSP driver.  This provides the generic core for simple
+ *  IO-based SSP applications and allows easy port setup for DMA access.
+ *
+ *  Author: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ *
+ *  Revision history:
+ *   22nd Aug 2003 Initial version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
+#include <asm/arch/ssp.h>
+#include <asm/arch/pxa-regs.h>
+
+static irqreturn_t ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct ssp_dev *dev = (struct ssp_dev*) dev_id;
+	unsigned int status = SSSR_P(dev->port);
+
+	SSSR_P(dev->port) = status; /* clear status bits */
+
+	if (status & SSSR_ROR)
+		printk(KERN_WARNING "SSP(%d): receiver overrun\n", dev->port);
+
+	if (status & SSSR_TUR)
+		printk(KERN_WARNING "SSP(%d): transmitter underrun\n", dev->port);
+
+	if (status & SSSR_BCE)
+		printk(KERN_WARNING "SSP(%d): bit count error\n", dev->port);
+
+	return IRQ_HANDLED;
+}
+
+/**
+ * ssp_write_word - write a word to the SSP port
+ * @data: 32-bit, MSB justified data to write.
+ *
+ * Wait for a free entry in the SSP transmit FIFO, and write a data
+ * word to the SSP port.
+ *
+ * The caller is expected to perform the necessary locking.
+ *
+ * Returns:
+ *   %-ETIMEDOUT	timeout occurred (for future)
+ *   0			success
+ */
+int ssp_write_word(struct ssp_dev *dev, u32 data)
+{
+	while (!(SSSR_P(dev->port) & SSSR_TNF))
+		cpu_relax();
+
+	SSDR_P(dev->port) = data;
+
+	return 0;
+}
+
+/**
+ * ssp_read_word - read a word from the SSP port
+ *
+ * Wait for a data word in the SSP receive FIFO, and return the
+ * received data.  Data is LSB justified.
+ *
+ * Note: Currently, if data is not expected to be received, this
+ * function will wait for ever.
+ *
+ * The caller is expected to perform the necessary locking.
+ *
+ * Returns:
+ *   %-ETIMEDOUT	timeout occurred (for future)
+ *   32-bit data	success
+ */
+int ssp_read_word(struct ssp_dev *dev)
+{
+	while (!(SSSR_P(dev->port) & SSSR_RNE))
+		cpu_relax();
+
+	return SSDR_P(dev->port);
+}
+
+/**
+ * ssp_flush - flush the transmit and receive FIFOs
+ *
+ * Wait for the SSP to idle, and ensure that the receive FIFO
+ * is empty.
+ *
+ * The caller is expected to perform the necessary locking.
+ */
+void ssp_flush(struct ssp_dev *dev)
+{
+	do {
+		while (SSSR_P(dev->port) & SSSR_RNE) {
+			(void) SSDR_P(dev->port);
+		}
+	} while (SSSR_P(dev->port) & SSSR_BSY);
+}
+
+/**
+ * ssp_enable - enable the SSP port
+ *
+ * Turn on the SSP port.
+ */
+void ssp_enable(struct ssp_dev *dev)
+{
+	SSCR0_P(dev->port) |= SSCR0_SSE;
+}
+
+/**
+ * ssp_disable - shut down the SSP port
+ *
+ * Turn off the SSP port, optionally powering it down.
+ */
+void ssp_disable(struct ssp_dev *dev)
+{
+	SSCR0_P(dev->port) &= ~SSCR0_SSE;
+}
+
+/**
+ * ssp_save_state - save the SSP configuration
+ * @ssp: pointer to structure to save SSP configuration
+ *
+ * Save the configured SSP state for suspend.
+ */
+void ssp_save_state(struct ssp_dev *dev, struct ssp_state *ssp)
+{
+	ssp->cr0 = SSCR0_P(dev->port);
+	ssp->cr1 = SSCR1_P(dev->port);
+	ssp->to = SSTO_P(dev->port);
+	ssp->psp = SSPSP_P(dev->port);
+
+	SSCR0_P(dev->port) &= ~SSCR0_SSE;
+}
+
+/**
+ * ssp_restore_state - restore a previously saved SSP configuration
+ * @ssp: pointer to configuration saved by ssp_save_state
+ *
+ * Restore the SSP configuration saved previously by ssp_save_state.
+ */
+void ssp_restore_state(struct ssp_dev *dev, struct ssp_state *ssp)
+{
+	SSSR_P(dev->port) = SSSR_ROR | SSSR_TUR | SSSR_BCE;
+
+	SSCR0_P(dev->port) = ssp->cr0 & ~SSCR0_SSE;
+	SSCR1_P(dev->port) = ssp->cr1;
+	SSTO_P(dev->port) = ssp->to;
+	SSPSP_P(dev->port) = ssp->psp;
+
+	SSCR0_P(dev->port) = ssp->cr0;
+}
+
+/**
+ * ssp_init - setup the SSP port
+ *
+ * initialise and claim resources for the SSP port.
+ *
+ * Returns:
+ *   %-ENODEV	if the SSP port is unavailable
+ *   %-EBUSY	if the resources are already in use
+ *   %0		on success
+ */
+int ssp_init(struct ssp_dev *dev, u32 port, u32 mode, u32 flags, u32 psp_flags,
+						u32 speed)
+{
+	int ret, irq;
+
+	if (!request_mem_region(__PREG(SSCR0_P(port)), 0x2c, "SSP")) {
+		return -EBUSY;
+	}
+
+	switch (port) {
+		case 1:
+			irq = IRQ_SSP;
+			break;
+#if defined (CONFIG_PXA27x)
+		case 2:
+			irq = IRQ_SSP2;
+			break;
+		case 3:
+			irq = IRQ_SSP3;
+			break;
+#else
+		case 2:
+			irq = IRQ_NSSP;
+			break;
+		case 3:
+			irq = IRQ_ASSP;
+			break;
+#endif
+		default:
+			return -ENODEV;
+	}
+
+	dev->port = port;
+	dev->mode = mode;
+	dev->flags = flags;
+	dev->psp_flags = psp_flags;
+	dev->speed = speed;
+
+	/* set up port type, speed, port settings */
+	SSCR0_P(dev->port) = (dev->speed | dev->mode);
+	SSCR1_P(dev->port) = dev->flags;
+	SSPSP_P(dev->port) = dev->psp_flags;
+
+	ret = request_irq(irq, ssp_interrupt, 0, "SSP", dev);
+	if (ret)
+		goto out_region;
+
+	/* turn on SSP port clock */
+	switch (dev->port) {
+#if defined (CONFIG_PXA27x)
+		case 1:
+			pxa_set_cken(CKEN23_SSP1, 1);
+			break;
+		case 2:
+			pxa_set_cken(CKEN3_SSP2, 1);
+			break;
+		case 3:
+			pxa_set_cken(CKEN4_SSP3, 1);
+			break;
+#else
+		case 1:
+			pxa_set_cken(CKEN3_SSP, 1);
+			break;
+		case 2:
+			pxa_set_cken(CKEN9_NSSP, 1);
+			break;
+		case 3:
+			pxa_set_cken(CKEN10_ASSP, 1);
+			break;
+#endif
+	}
+
+	return 0;
+
+out_region:
+	release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c);
+	return ret;
+}
+
+/**
+ * ssp_exit - undo the effects of ssp_init
+ *
+ * release and free resources for the SSP port.
+ */
+void ssp_exit(struct ssp_dev *dev)
+{
+	int irq;
+
+	SSCR0_P(dev->port) &= ~SSCR0_SSE;
+
+	/* find irq, save power and turn off SSP port clock */
+	switch (dev->port) {
+#if defined (CONFIG_PXA27x)
+		case 1:
+			irq = IRQ_SSP;
+			pxa_set_cken(CKEN23_SSP1, 0);
+			break;
+		case 2:
+			irq = IRQ_SSP2;
+			pxa_set_cken(CKEN3_SSP2, 0);
+			break;
+		case 3:
+			irq = IRQ_SSP3;
+			pxa_set_cken(CKEN4_SSP3, 0);
+			break;
+#else
+		case 1:
+			irq = IRQ_SSP;
+			pxa_set_cken(CKEN3_SSP, 0);
+			break;
+		case 2:
+			irq = IRQ_NSSP;
+			pxa_set_cken(CKEN9_NSSP, 0);
+			break;
+		case 3:
+			irq = IRQ_ASSP;
+			pxa_set_cken(CKEN10_ASSP, 0);
+			break;
+#endif
+		default:
+			printk(KERN_WARNING "SSP: tried to close invalid port\n");
+			return;
+	}
+
+	free_irq(irq, dev);
+	release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c);
+}
+
+EXPORT_SYMBOL(ssp_write_word);
+EXPORT_SYMBOL(ssp_read_word);
+EXPORT_SYMBOL(ssp_flush);
+EXPORT_SYMBOL(ssp_enable);
+EXPORT_SYMBOL(ssp_disable);
+EXPORT_SYMBOL(ssp_save_state);
+EXPORT_SYMBOL(ssp_restore_state);
+EXPORT_SYMBOL(ssp_init);
+EXPORT_SYMBOL(ssp_exit);
diff -Nru a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
--- a/arch/arm/mach-pxa/time.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-pxa/time.c	2004-12-24 13:36:48 -08:00
@@ -75,6 +75,8 @@
 {
 	int next_match;
 
+	write_seqlock(&xtime_lock);
+
 	/* Loop until we get ahead of the free running timer.
 	 * This ensures an exact clock tick count and time accuracy.
 	 * IRQs are disabled inside the loop to ensure coherence between
@@ -96,6 +98,8 @@
 		next_match = (OSMR0 += LATCH);
 	} while( (signed long)(next_match - OSCR) <= 8 );
 
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -105,11 +109,10 @@
 	.handler	= pxa_timer_interrupt
 };
 
-void __init pxa_init_time(void)
+static void __init pxa_timer_init(void)
 {
 	struct timespec tv;
 
-	gettimeoffset = pxa_gettimeoffset;
 	set_rtc = pxa_set_rtc;
 
 	tv.tv_nsec = 0;
@@ -123,3 +126,39 @@
 	OSCR = 0;		/* initialize free-running timer, force first match */
 }
 
+#ifdef CONFIG_PM
+static unsigned long osmr[4], oier;
+
+static void pxa_timer_suspend(void)
+{
+	osmr[0] = OSMR0;
+	osmr[1] = OSMR1;
+	osmr[2] = OSMR2;
+	osmr[3] = OSMR3;
+	oier = OIER;
+}
+
+static void pxa_timer_resume(void)
+{
+	OSMR0 = osmr[0];
+	OSMR1 = osmr[1];
+	OSMR2 = osmr[2];
+	OSMR3 = osmr[3];
+	OIER = oier;
+
+	/*
+	 * OSMR0 is the system timer: make sure OSCR is sufficiently behind
+	 */
+	OSCR = OSMR0 - LATCH;
+}
+#else
+#define pxa_timer_suspend NULL
+#define pxa_timer_resume NULL
+#endif
+
+struct sys_timer pxa_timer = {
+	.init		= pxa_timer_init,
+	.suspend	= pxa_timer_suspend,
+	.resume		= pxa_timer_resume,
+	.offset		= pxa_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-rpc/Makefile.boot b/arch/arm/mach-rpc/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-rpc/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,4 @@
+   zreladdr-y	:= 0x10008000
+params_phys-y	:= 0x10000100
+initrd_phys-y	:= 0x18000000
+
diff -Nru a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
--- a/arch/arm/mach-rpc/riscpc.c	2004-12-24 13:37:01 -08:00
+++ b/arch/arm/mach-rpc/riscpc.c	2004-12-24 13:37:01 -08:00
@@ -15,7 +15,8 @@
 #include <linux/pm.h>
 #include <linux/init.h>
 #include <linux/sched.h>
-#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/serial_8250.h>
 
 #include <asm/elf.h>
 #include <asm/io.h>
@@ -66,11 +67,11 @@
 
 static struct map_desc rpc_io_desc[] __initdata = {
  { SCREEN_BASE,	SCREEN_START,	2*1048576, MT_DEVICE }, /* VRAM		*/
- { IO_BASE,	IO_START,	IO_SIZE	 , MT_DEVICE }, /* IO space		*/
+ { IO_BASE,	IO_START,	IO_SIZE	 , MT_DEVICE }, /* IO space	*/
  { EASI_BASE,	EASI_START,	EASI_SIZE, MT_DEVICE }  /* EASI space	*/
 };
 
-void __init rpc_map_io(void)
+static void __init rpc_map_io(void)
 {
 	iotable_init(rpc_io_desc, ARRAY_SIZE(rpc_io_desc));
 
@@ -85,31 +86,87 @@
 	elf_hwcap &= ~HWCAP_HALF;
 }
 
-static irqreturn_t
-rpc_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-	timer_tick(regs);
+static struct resource acornfb_resources[] = {
+	{	/* VIDC */
+		.start		= 0x03400000,
+		.end		= 0x035fffff,
+		.flags		= IORESOURCE_MEM,
+	}, {
+		.start		= IRQ_VSYNCPULSE,
+		.end		= IRQ_VSYNCPULSE,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
 
-	return IRQ_HANDLED;
-}
+static struct platform_device acornfb_device = {
+	.name			= "acornfb",
+	.id			= -1,
+	.dev			= {
+		.coherent_dma_mask = 0xffffffff,
+	},
+	.num_resources		= ARRAY_SIZE(acornfb_resources),
+	.resource		= acornfb_resources,
+};
 
-static struct irqaction rpc_timer_irq = {
-	.name		= "RiscPC Timer Tick",
-	.flags		= SA_INTERRUPT,
-	.handler	= rpc_timer_interrupt
+static struct resource iomd_resources[] = {
+	{
+		.start		= 0x03200000,
+		.end		= 0x0320ffff,
+		.flags		= IORESOURCE_MEM,
+	},
 };
 
-/*
- * Set up timer interrupt.
- */
-void __init rpc_init_time(void)
-{
-	extern void ioctime_init(void);
-	ioctime_init();
+static struct platform_device iomd_device = {
+	.name			= "iomd",
+	.id			= -1,
+	.num_resources		= ARRAY_SIZE(iomd_resources),
+	.resource		= iomd_resources,
+};
+
+static struct platform_device kbd_device = {
+	.name			= "kart",
+	.id			= -1,
+	.dev			= {
+		.parent 	= &iomd_device.dev,
+	},
+};
 
-	setup_irq(IRQ_TIMER, &rpc_timer_irq);
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.mapbase	= 0x03010fe0,
+		.irq		= 10,
+		.uartclk	= 1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_MEM,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SKIP_TEST,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= 0,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
+static struct platform_device *devs[] __initdata = {
+	&iomd_device,
+	&kbd_device,
+	&serial_device,
+	&acornfb_device,
+};
+
+static int __init rpc_init(void)
+{
+	return platform_add_devices(devs, ARRAY_SIZE(devs));
 }
 
+arch_initcall(rpc_init);
+
+extern struct sys_timer ioc_timer;
+
 MACHINE_START(RISCPC, "Acorn-RiscPC")
 	MAINTAINER("Russell King")
 	BOOT_MEM(0x10000000, 0x03000000, 0xe0000000)
@@ -118,5 +175,5 @@
 	DISABLE_PARPORT(1)
 	MAPIO(rpc_map_io)
 	INITIRQ(rpc_init_irq)
-	INITTIME(rpc_init_time)
+	.timer		= &ioc_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
--- a/arch/arm/mach-s3c2410/Kconfig	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-s3c2410/Kconfig	2004-12-24 13:36:48 -08:00
@@ -35,6 +35,15 @@
 	  This linux port is currently being maintained by Simtec, on behalf
 	  of Thorcom. Any queries, please contact Thorcom first.
 
+config MACH_RX3715
+	bool "HP iPAQ rx3715"
+	select CPU_S3C2440
+	help
+	  Say Y here if you are using the HP iPAQ rx3715.
+
+	  See http://www.handhelds.org/projects/rx3715.html for more
+	  information on this project
+
 endmenu
 
 config CPU_S3C2410
@@ -71,5 +80,44 @@
 	  amount of time, as well as using an significant percantage of
 	  the CPU time doing so.
 
+
+config S3C2410_PM_DEBUG
+	bool "S3C2410 PM Suspend debug"
+	depends on ARCH_S3C2410 && PM
+	help
+	  Say Y here if you want verbose debugging from the PM Suspend and
+	  Resume code. See `Documentation/arm/Samsing-S3C24XX/Suspend.txt`
+	  for more information.
+
+config S3C2410_PM_CHECK
+	bool "S3C2410 PM Suspend Memory CRC"
+	depends on ARCH_S3C2410 && PM && CRC32
+	help
+ 	  Enable the PM code's memory area checksum over sleep. This option
+	  will generate CRCs of all blocks of memory, and store them before
+	  going to sleep. The blocks are then checked on resume for any
+	  errors.
+
+config S3C2410_PM_CHECK_CHUNKSIZE
+	int "S3C2410 PM Suspend CRC Chunksize (KiB)"
+	depends on ARCH_S3C2410 && PM && S3C2410_PM_CHECK
+	default 64
+	help
+	  Set the chunksize in Kilobytes of the CRC for checking memory
+	  corruption over suspend and resume. A smaller value will mean that
+	  the CRC data block will take more memory, but wil identify any
+	  faults with better precision.
+
+config S3C2410_LOWLEVEL_UART_PORT
+	int "S3C2410 UART to use for low-level messages"
+	default 0
+	help
+	  Choice of which UART port to use for the low-level messages,
+	  such as the `Uncompressing...` at start time. The value of
+	  this configuration should be between zero and two. The port
+	  must have been initalised by the boot-loader before use.
+
+	  Note, this does not affect the port used by the debug messages,
+	  which is a seperate configuration.
 
 endif
diff -Nru a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
--- a/arch/arm/mach-s3c2410/Makefile	2004-12-24 13:36:19 -08:00
+++ b/arch/arm/mach-s3c2410/Makefile	2004-12-24 13:36:19 -08:00
@@ -15,6 +15,10 @@
 obj-$(CONFIG_CPU_S3C2410)  += s3c2410.o
 obj-$(CONFIG_S3C2410_DMA)  += dma.o
 
+# Power Management support
+
+obj-$(CONFIG_PM)	   += pm.o sleep.o
+
 # S3C2440 support
 
 obj-$(CONFIG_CPU_S3C2440)  += s3c2440.o s3c2440-dsc.o
@@ -25,4 +29,4 @@
 obj-$(CONFIG_ARCH_H1940)	+= mach-h1940.o
 obj-$(CONFIG_ARCH_SMDK2410)	+= mach-smdk2410.o
 obj-$(CONFIG_MACH_VR1000)	+= mach-vr1000.o usb-simtec.o
-
+obj-$(CONFIG_MACH_RX3715)	+= mach-rx3715.o
diff -Nru a/arch/arm/mach-s3c2410/Makefile.boot b/arch/arm/mach-s3c2410/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-s3c2410/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,3 @@
+   zreladdr-y	:= 0x30008000
+params_phys-y	:= 0x30000100
+
diff -Nru a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
--- a/arch/arm/mach-s3c2410/clock.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-s3c2410/clock.c	2004-12-24 13:36:18 -08:00
@@ -32,6 +32,7 @@
 #include <linux/list.h>
 #include <linux/errno.h>
 #include <linux/err.h>
+#include <linux/device.h>
 
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
@@ -46,6 +47,12 @@
 
 #include "clock.h"
 
+/* clock information */
+
+unsigned long s3c24xx_xtal = 12*1000*1000;	/* default 12MHz */
+unsigned long s3c24xx_fclk;
+unsigned long s3c24xx_hclk;
+unsigned long s3c24xx_pclk;
 
 static LIST_HEAD(clocks);
 static DECLARE_MUTEX(clocks_sem);
@@ -53,7 +60,7 @@
 
 /* old functions */
 
-void s3c2410_clk_enable(unsigned int clocks, unsigned int enable)
+void inline s3c2410_clk_enable(unsigned int clocks, unsigned int enable)
 {
 	unsigned long clkcon;
 	unsigned long flags;
@@ -66,11 +73,26 @@
 	if (enable)
 		clkcon |= clocks;
 
+	/* ensure none of the special function bits set */
+	clkcon &= ~(S3C2410_CLKCON_IDLE|S3C2410_CLKCON_POWER);
+
 	__raw_writel(clkcon, S3C2410_CLKCON);
 
 	local_irq_restore(flags);
 }
 
+/* enable and disable calls for use with the clk struct */
+
+static int clk_null_enable(struct clk *clk, int enable)
+{
+	return 0;
+}
+
+int s3c2410_clkcon_enable(struct clk *clk, int enable)
+{
+	s3c2410_clk_enable(clk->ctrlbit, enable);
+	return 0;
+}
 
 /* Clock API calls */
 
@@ -78,17 +100,35 @@
 {
 	struct clk *p;
 	struct clk *clk = ERR_PTR(-ENOENT);
+	int idno;
+
+	idno = (dev == NULL) ? -1 : to_platform_device(dev)->id;
 
 	down(&clocks_sem);
+
 	list_for_each_entry(p, &clocks, list) {
-		if (strcmp(id, p->name) == 0 &&
+		if (p->id == idno &&
+		    strcmp(id, p->name) == 0 &&
 		    try_module_get(p->owner)) {
 			clk = p;
 			break;
 		}
 	}
-	up(&clocks_sem);
 
+	/* check for the case where a device was supplied, but the
+	 * clock that was being searched for is not device specific */
+
+	if (IS_ERR(clk)) {
+		list_for_each_entry(p, &clocks, list) {
+			if (p->id == -1 && strcmp(id, p->name) == 0 &&
+			    try_module_get(p->owner)) {
+				clk = p;
+				break;
+			}
+		}
+	}
+
+	up(&clocks_sem);
 	return clk;
 }
 
@@ -99,15 +139,16 @@
 
 int clk_enable(struct clk *clk)
 {
-	if (clk->ctrlbit != 0)
-		s3c2410_clk_enable(clk->ctrlbit, 1);
+	if (IS_ERR(clk))
+		return -EINVAL;
 
-	return 0;
+	return (clk->enable)(clk, 1);
 }
 
 void clk_disable(struct clk *clk)
 {
-	s3c2410_clk_enable(clk->ctrlbit, 0);
+	if (!IS_ERR(clk))
+		(clk->enable)(clk, 0);
 }
 
 
@@ -125,8 +166,14 @@
 
 unsigned long clk_get_rate(struct clk *clk)
 {
-	if (clk->parent != NULL)
-		return clk->parent->rate;
+	if (IS_ERR(clk))
+		return 0;
+
+	if (clk->rate != 0)
+		return clk->rate;
+
+	while (clk->parent != NULL && clk->rate == 0)
+		clk = clk->parent;
 
 	return clk->rate;
 }
@@ -160,90 +207,151 @@
 /* base clocks */
 
 static struct clk clk_f = {
-	.name          = "fclk",
-	.rate          = 0,
-	.parent        = NULL,
-	.ctrlbit       = 0
+	.name		= "fclk",
+	.id		= -1,
+	.rate		= 0,
+	.parent		= NULL,
+	.ctrlbit	= 0,
 };
 
 static struct clk clk_h = {
-	.name          = "hclk",
-	.rate          = 0,
-	.parent        = NULL,
-	.ctrlbit       = 0
+	.name		= "hclk",
+	.id		= -1,
+	.rate		= 0,
+	.parent		= NULL,
+	.ctrlbit	= 0,
 };
 
 static struct clk clk_p = {
-	.name          = "pclk",
-	.rate          = 0,
-	.parent        = NULL,
-	.ctrlbit       = 0
+	.name		= "pclk",
+	.id		= -1,
+	.rate		= 0,
+	.parent		= NULL,
+	.ctrlbit	= 0,
+};
+
+/* clocks that could be registered by external code */
+
+struct clk s3c24xx_dclk0 = {
+	.name		= "dclk0",
+	.id		= -1,
+};
+
+struct clk s3c24xx_dclk1 = {
+	.name		= "dclk1",
+	.id		= -1,
 };
 
+struct clk s3c24xx_clkout0 = {
+	.name		= "clkout0",
+	.id		= -1,
+};
+
+struct clk s3c24xx_clkout1 = {
+	.name		= "clkout1",
+	.id		= -1,
+};
+
+struct clk s3c24xx_uclk = {
+	.name		= "uclk",
+	.id		= -1,
+};
+
+
 /* clock definitions */
 
 static struct clk init_clocks[] = {
 	{ .name    = "nand",
+	  .id	   = -1,
 	  .parent  = &clk_h,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_NAND
 	},
 	{ .name    = "lcd",
+	  .id	   = -1,
 	  .parent  = &clk_h,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_LCDC
 	},
 	{ .name    = "usb-host",
+	  .id	   = -1,
 	  .parent  = &clk_h,
-	  .ctrlbit =   S3C2410_CLKCON_USBH
+	  .enable  = s3c2410_clkcon_enable,
+	  .ctrlbit = S3C2410_CLKCON_USBH
 	},
 	{ .name    = "usb-device",
+	  .id	   = -1,
 	  .parent  = &clk_h,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_USBD
 	},
 	{ .name    = "timers",
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_PWMT
 	},
 	{ .name    = "sdi",
+	  .id	   = -1,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_SDI
 	},
-	{ .name    = "uart0",
+	{ .name    = "uart",
+	  .id	   = 0,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_UART0
 	},
-	{ .name    = "uart1",
+	{ .name    = "uart",
+	  .id	   = 1,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_UART1
 	},
-	{ .name    = "uart2",
+	{ .name    = "uart",
+	  .id	   = 2,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_UART2
 	},
 	{ .name    = "gpio",
+	  .id	   = -1,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_GPIO
 	},
 	{ .name    = "rtc",
+	  .id	   = -1,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_RTC
 	},
 	{ .name    = "adc",
+	  .id	   = -1,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_ADC
 	},
 	{ .name    = "i2c",
+	  .id	   = -1,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_IIC
 	},
 	{ .name    = "iis",
+	  .id	   = -1,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_IIS
 	},
 	{ .name    = "spi",
+	  .id	   = -1,
 	  .parent  = &clk_p,
+	  .enable  = s3c2410_clkcon_enable,
 	  .ctrlbit = S3C2410_CLKCON_SPI
 	},
 	{ .name    = "watchdog",
+	  .id	   = -1,
 	  .parent  = &clk_p,
 	  .ctrlbit = 0
 	}
@@ -256,6 +364,9 @@
 	clk->owner = THIS_MODULE;
 	atomic_set(&clk->used, 0);
 
+	if (clk->enable == NULL)
+		clk->enable = clk_null_enable;
+
 	/* add to the list of available clocks */
 
 	down(&clocks_sem);
@@ -267,7 +378,7 @@
 
 /* initalise all the clocks */
 
-static int __init s3c2410_init_clocks(void)
+int __init s3c2410_init_clocks(void)
 {
 	struct clk *clkp = init_clocks;
 	int ptr;
@@ -277,12 +388,29 @@
 
 	/* initialise the main system clocks */
 
-	clk_h.rate = s3c2410_hclk;
-	clk_p.rate = s3c2410_pclk;
-	clk_f.rate = s3c2410_fclk;
+	clk_h.rate = s3c24xx_hclk;
+	clk_p.rate = s3c24xx_pclk;
+	clk_f.rate = s3c24xx_fclk;
+
+	/* it looks like just setting the register here is not good
+	 * enough, and causes the odd hang at initial boot time, so
+	 * do all of them indivdually.
+	 *
+	 * I think disabling the LCD clock if the LCD is active is
+	 * very dangerous, and therefore the bootloader should be
+	 * careful to not enable the LCD clock if it is not needed.
+	 *
+	 * and of course, this looks neater
+	 */
+
+	s3c2410_clk_enable(S3C2410_CLKCON_NAND, 0);
+	s3c2410_clk_enable(S3C2410_CLKCON_USBH, 0);
+	s3c2410_clk_enable(S3C2410_CLKCON_USBD, 0);
+	s3c2410_clk_enable(S3C2410_CLKCON_ADC, 0);
+	s3c2410_clk_enable(S3C2410_CLKCON_IIC, 0);
+	s3c2410_clk_enable(S3C2410_CLKCON_SPI, 0);
 
-	/* set the enabled clocks to a minimal (known) state */
-	__raw_writel(S3C2410_CLKCON_PWMT | S3C2410_CLKCON_UART0 | S3C2410_CLKCON_UART1 | S3C2410_CLKCON_UART2 | S3C2410_CLKCON_GPIO | S3C2410_CLKCON_RTC, S3C2410_CLKCON);
+	/* assume uart clocks are correctly setup */
 
 	/* register our clocks */
 
@@ -306,5 +434,4 @@
 	return 0;
 }
 
-arch_initcall(s3c2410_init_clocks);
 
diff -Nru a/arch/arm/mach-s3c2410/clock.h b/arch/arm/mach-s3c2410/clock.h
--- a/arch/arm/mach-s3c2410/clock.h	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-s3c2410/clock.h	2004-12-24 13:36:55 -08:00
@@ -2,7 +2,7 @@
  * linux/arch/arm/mach-s3c2410/clock.h
  *
  * Copyright (c) 2004 Simtec Electronics
- * Written by Ben Dooks, <ben@simtec.co.uk>
+ *	Written by Ben Dooks, <ben@simtec.co.uk>
  *
  * 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
@@ -14,7 +14,34 @@
 	struct module        *owner;
 	struct clk           *parent;
 	const char           *name;
+	int		      id;
 	atomic_t              used;
 	unsigned long         rate;
 	unsigned long         ctrlbit;
+	int		    (*enable)(struct clk *, int enable);
 };
+
+/* other clocks which may be registered by board support */
+
+extern struct clk s3c24xx_dclk0;
+extern struct clk s3c24xx_dclk1;
+extern struct clk s3c24xx_clkout0;
+extern struct clk s3c24xx_clkout1;
+extern struct clk s3c24xx_uclk;
+
+/* processor clock settings, in Hz */
+
+extern unsigned long s3c24xx_xtal;
+extern unsigned long s3c24xx_pclk;
+extern unsigned long s3c24xx_hclk;
+extern unsigned long s3c24xx_fclk;
+
+/* exports for arch/arm/mach-s3c2410
+ *
+ * Please DO NOT use these outside of arch/arm/mach-s3c2410
+*/
+
+extern int s3c2410_clkcon_enable(struct clk *clk, int enable);
+extern int s3c2410_register_clock(struct clk *clk);
+extern int s3c2410_init_clocks(void);
+
diff -Nru a/arch/arm/mach-s3c2410/cpu.c b/arch/arm/mach-s3c2410/cpu.c
--- a/arch/arm/mach-s3c2410/cpu.c	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/mach-s3c2410/cpu.c	2004-12-24 13:36:49 -08:00
@@ -38,6 +38,7 @@
 #include <asm/arch/regs-gpio.h>
 
 #include "cpu.h"
+#include "clock.h"
 #include "s3c2410.h"
 #include "s3c2440.h"
 
@@ -65,7 +66,7 @@
 		.name   = name_s3c2410
 	},
 	{
-		.idcode	= 0x3241002,
+		.idcode	= 0x32410002,
 		.idmask = 0xffffffff,
 		.map_io = s3c2410_map_io,
 		.init   = s3c2410_init,
@@ -104,7 +105,7 @@
 	int count;
 
 	tab = cpu_ids;
-	for (count = 0; count < ARRAY_SIZE(cpu_ids); count++) {
+	for (count = 0; count < ARRAY_SIZE(cpu_ids); count++, tab++) {
 		if ((idcode & tab->idmask) == tab->idcode)
 			return tab;
 	}
@@ -112,6 +113,26 @@
 	return NULL;
 }
 
+/* board information */
+
+static struct s3c24xx_board *board;
+
+void s3c24xx_set_board(struct s3c24xx_board *b)
+{
+	int i;
+
+	board = b;
+
+	if (b->clocks_count != 0) {
+		struct clk **ptr = b->clocks;;
+
+		for (i = b->clocks_count; i > 0; i--, ptr++)
+			s3c2410_register_clock(*ptr);
+	}
+}
+
+/* cpu information */
+
 static struct cpu_table *cpu;
 
 void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
@@ -141,12 +162,35 @@
 
 static int __init s3c_arch_init(void)
 {
+	int ret;
+
 	// do the correct init for cpu
 
 	if (cpu == NULL)
 		panic("s3c_arch_init: NULL cpu\n");
 
-	return (cpu->init)();
+	ret = (cpu->init)();
+	if (ret != 0)
+		return ret;
+
+	if (board != NULL) {
+		struct platform_device **ptr = board->devices;
+		int i;
+
+		for (i = 0; i < board->devices_count; i++, ptr++) {
+			ret = platform_device_register(*ptr);
+
+			if (ret) {
+				printk(KERN_ERR "s3c24xx: failed to add board device %s (%d) @%p\n", (*ptr)->name, ret, *ptr);
+			}
+		}
+
+		/* mask any error, we may not need all these board
+		 * devices */
+		ret = 0;
+	}
+
+	return ret;
 }
 
 arch_initcall(s3c_arch_init);
diff -Nru a/arch/arm/mach-s3c2410/cpu.h b/arch/arm/mach-s3c2410/cpu.h
--- a/arch/arm/mach-s3c2410/cpu.h	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-s3c2410/cpu.h	2004-12-24 13:36:18 -08:00
@@ -11,6 +11,7 @@
  *
  * Modifications:
  *     24-Aug-2004 BJD  Start of generic S3C24XX support
+ *     18-Oct-2004 BJD  Moved board struct into this file
 */
 
 #define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE }
@@ -38,4 +39,21 @@
 #endif
 
 extern void s3c24xx_init_io(struct map_desc *mach_desc, int size);
+
+/* the board structure is used at first initialsation time
+ * to get info such as the devices to register for this
+ * board. This is done because platfrom_add_devices() cannot
+ * be called from the map_io entry.
+*/
+
+struct s3c24xx_board {
+	struct platform_device  **devices;
+	unsigned int              devices_count;
+
+	struct clk		**clocks;
+	unsigned int		  clocks_count;
+};
+
+extern void s3c24xx_set_board(struct s3c24xx_board *board);
+
 
diff -Nru a/arch/arm/mach-s3c2410/devs.c b/arch/arm/mach-s3c2410/devs.c
--- a/arch/arm/mach-s3c2410/devs.c	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/mach-s3c2410/devs.c	2004-12-24 13:36:31 -08:00
@@ -32,7 +32,13 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
+#include <asm/arch/regs-serial.h>
+
 #include "devs.h"
+
+/* Serial port registrations */
+
+struct platform_device *s3c24xx_uart_devs[3];
 
 /* USB Host Controller */
 
diff -Nru a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c2410/dma.c
--- a/arch/arm/mach-s3c2410/dma.c	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/mach-s3c2410/dma.c	2004-12-24 13:36:31 -08:00
@@ -1,7 +1,7 @@
 /* linux/arch/arm/mach-bast/dma.c
  *
  * (c) 2003,2004 Simtec Electronics
- * Ben Dooks <ben@simtec.co.uk>
+ *	Ben Dooks <ben@simtec.co.uk>
  *
  * S3C2410 DMA core
  *
@@ -12,6 +12,9 @@
  * published by the Free Software Foundation.
  *
  * Changelog:
+ *  18-Nov-2004 BJD  Removed error for loading onto stopped channel
+ *  10-Nov-2004 BJD  Ensure all external symbols exported for modules
+ *  10-Nov-2004 BJD  Use sys_device and sysdev_class for power management
  *  08-Aug-2004 BJD  Apply rmk's suggestions
  *  21-Jul-2004 BJD  Ported to linux 2.6
  *  12-Jul-2004 BJD  Finished re-write and change of API
@@ -38,6 +41,7 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/sysdev.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
@@ -52,7 +56,7 @@
 #include <asm/arch/map.h>
 
 /* io map for dma */
-static void *dma_base;
+static void __iomem *dma_base;
 
 /* dma channel state information */
 s3c2410_dma_chan_t s3c2410_chans[S3C2410_DMA_CHANNELS];
@@ -490,10 +494,6 @@
 	} else if (chan->state == S3C2410_DMA_IDLE) {
 		if (chan->flags & S3C2410_DMAF_AUTOSTART) {
 			s3c2410_dma_ctrl(chan->number, S3C2410_DMAOP_START);
-		} else {
-			printk(KERN_DEBUG "dma%d: cannot load onto stopped channel'n", chan->number);
-			local_irq_restore(flags);
-			return -EINVAL;
 		}
 	}
 
@@ -501,6 +501,8 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(s3c2410_dma_enqueue);
+
 static inline void
 s3c2410_dma_freebuf(s3c2410_dma_buf_t *buf)
 {
@@ -648,6 +650,9 @@
 
 			break;
 
+		case S3C2410_DMALOAD_1LOADED_1RUNNING:
+			goto no_load;
+
 		default:
 			printk(KERN_ERR "dma%d: unknown load_state in irq, %d\n",
 			       chan->number, chan->load_state);
@@ -668,6 +673,7 @@
 		}
 	}
 
+ no_load:
 	return IRQ_HANDLED;
 }
 
@@ -736,6 +742,8 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(s3c2410_dma_request);
+
 /* s3c2410_dma_free
  *
  * release the given channel back to the system, will stop and flush
@@ -780,6 +788,8 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(s3c2410_dma_free);
+
 static int s3c2410_dma_dostop(s3c2410_dma_chan_t *chan)
 {
 	unsigned long tmp;
@@ -886,6 +896,7 @@
 	return -ENOENT;      /* unknown, don't bother */
 }
 
+EXPORT_SYMBOL(s3c2410_dma_ctrl);
 
 /* DMA configuration for each channel
  *
@@ -941,6 +952,7 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(s3c2410_dma_config);
 
 int s3c2410_dma_setflags(dmach_t channel, unsigned int flags)
 {
@@ -955,6 +967,9 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(s3c2410_dma_setflags);
+
+
 /* do we need to protect the settings of the fields from
  * irq?
 */
@@ -972,6 +987,8 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(s3c2410_dma_set_opfn);
+
 int s3c2410_dma_set_buffdone_fn(dmach_t channel, s3c2410_dma_cbfn_t rtn)
 {
 	s3c2410_dma_chan_t *chan = &s3c2410_chans[channel];
@@ -985,6 +1002,8 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn);
+
 /* s3c2410_dma_devconfig
  *
  * configure the dma source/destination hardware type and address
@@ -1042,12 +1061,57 @@
 	return -EINVAL;
 }
 
+EXPORT_SYMBOL(s3c2410_dma_devconfig);
+
+/* system device class */
+
+#ifdef CONFIG_PM
+
+static int s3c2410_dma_suspend(struct sys_device *dev, u32 state)
+{
+	s3c2410_dma_chan_t *cp = container_of(dev, s3c2410_dma_chan_t, dev);
+
+	printk(KERN_DEBUG "suspending dma channel %d\n", cp->number);
+
+	if (dma_rdreg(cp, S3C2410_DMA_DMASKTRIG) & S3C2410_DMASKTRIG_ON) {
+		/* the dma channel is still working, which is probably
+		 * a bad thing to do over suspend/resume. We stop the
+		 * channel and assume that the client is either going to
+		 * retry after resume, or that it is broken.
+		 */
+
+		printk(KERN_INFO "dma: stopping channel %d due to suspend\n",
+		       cp->number);
+
+		s3c2410_dma_dostop(cp);
+	}
+
+	return 0;
+}
+
+static int s3c2410_dma_resume(struct sys_device *dev)
+{
+	return 0;
+}
+
+#else
+#define s3c2410_dma_suspend NULL
+#define s3c2410_dma_resume  NULL
+#endif /* CONFIG_PM */
+
+static struct sysdev_class dma_sysclass = {
+	set_kset_name("s3c24xx-dma"),
+	.suspend	= s3c2410_dma_suspend,
+	.resume		= s3c2410_dma_resume,
+};
+
 /* initialisation code */
 
 static int __init s3c2410_init_dma(void)
 {
-	int channel;
 	s3c2410_dma_chan_t *cp;
+	int channel;
+	int ret;
 
 	printk("S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics\n");
 
@@ -1057,6 +1121,12 @@
 		return -ENOMEM;
 	}
 
+	ret = sysdev_class_register(&dma_sysclass);
+	if (ret != 0) {
+		printk(KERN_ERR "dma sysclass registration failed\n");
+		goto err;
+	}
+
 	for (channel = 0; channel < S3C2410_DMA_CHANNELS; channel++) {
 		cp = &s3c2410_chans[channel];
 
@@ -1065,7 +1135,7 @@
 		/* dma channel irqs are in order.. */
 		cp->number = channel;
 		cp->irq    = channel + IRQ_DMA0;
-		cp->regs   = (unsigned long)dma_base + (channel*0x40);
+		cp->regs   = dma_base + (channel*0x40);
 
 		/* point current stats somewhere */
 		cp->stats  = &cp->stats_store;
@@ -1075,11 +1145,22 @@
 
 		cp->load_timeout = 1<<18;
 
-		printk("DMA channel %d at %08lx, irq %d\n",
+		/* register system device */
+
+		cp->dev.cls = &dma_sysclass;
+		cp->dev.id  = channel;
+		ret = sysdev_register(&cp->dev);
+
+		printk("DMA channel %d at %p, irq %d\n",
 		       cp->number, cp->regs, cp->irq);
 	}
 
 	return 0;
+
+ err:
+	iounmap(dma_base);
+	dma_base = NULL;
+	return ret;
 }
 
 __initcall(s3c2410_init_dma);
diff -Nru a/arch/arm/mach-s3c2410/gpio.c b/arch/arm/mach-s3c2410/gpio.c
--- a/arch/arm/mach-s3c2410/gpio.c	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/mach-s3c2410/gpio.c	2004-12-24 13:37:18 -08:00
@@ -28,6 +28,7 @@
  *	01-Oct-2004  BJD  Fixed mask bug in pullup() call
  *	01-Oct-2004  BJD  Added getirq() to turn pin into irqno
  *	04-Oct-2004  BJD  Added irq filter controls for GPIO
+ *	05-Nov-2004  BJD  EXPORT_SYMBOL() added for all code
  */
 
 
@@ -66,6 +67,8 @@
 	local_irq_restore(flags);
 }
 
+EXPORT_SYMBOL(s3c2410_gpio_cfgpin);
+
 unsigned int s3c2410_gpio_getcfg(unsigned int pin)
 {
 	unsigned long base = S3C2410_GPIO_BASE(pin);
@@ -80,6 +83,8 @@
 	return __raw_readl(base) & mask;
 }
 
+EXPORT_SYMBOL(s3c2410_gpio_getcfg);
+
 void s3c2410_gpio_pullup(unsigned int pin, unsigned int to)
 {
 	unsigned long base = S3C2410_GPIO_BASE(pin);
@@ -100,6 +105,8 @@
 	local_irq_restore(flags);
 }
 
+EXPORT_SYMBOL(s3c2410_gpio_pullup);
+
 void s3c2410_gpio_setpin(unsigned int pin, unsigned int to)
 {
 	unsigned long base = S3C2410_GPIO_BASE(pin);
@@ -117,6 +124,8 @@
 	local_irq_restore(flags);
 }
 
+EXPORT_SYMBOL(s3c2410_gpio_setpin);
+
 unsigned int s3c2410_gpio_getpin(unsigned int pin)
 {
 	unsigned long base = S3C2410_GPIO_BASE(pin);
@@ -125,6 +134,8 @@
 	return __raw_readl(base + 0x04) & (1<< offs);
 }
 
+EXPORT_SYMBOL(s3c2410_gpio_getpin);
+
 unsigned int s3c2410_modify_misccr(unsigned int clear, unsigned int change)
 {
 	unsigned long flags;
@@ -140,6 +151,8 @@
 	return misccr;
 }
 
+EXPORT_SYMBOL(s3c2410_modify_misccr);
+
 int s3c2410_gpio_getirq(unsigned int pin)
 {
 	if (pin < S3C2410_GPF0 || pin > S3C2410_GPG15_EINT23)
@@ -157,6 +170,8 @@
 	return (pin - S3C2410_GPG0) + IRQ_EINT8;
 }
 
+EXPORT_SYMBOL(s3c2410_gpio_getirq);
+
 int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on,
 			   unsigned int config)
 {
@@ -192,3 +207,5 @@
 
 	return 0;
 }
+
+EXPORT_SYMBOL(s3c2410_gpio_irqfilter);
diff -Nru a/arch/arm/mach-s3c2410/irq.c b/arch/arm/mach-s3c2410/irq.c
--- a/arch/arm/mach-s3c2410/irq.c	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/mach-s3c2410/irq.c	2004-12-24 13:36:47 -08:00
@@ -33,9 +33,14 @@
  *
  *   05-Oct-2004  Ben Dooks <ben@simtec.co.uk>
  *		  Tidy up KF's patch and sort out new release
+ *
+ *   05-Oct-2004  Ben Dooks <ben@simtec.co.uk>
+ *		  Add support for power management controls
+ *
+ *   04-Nov-2004  Ben Dooks
+ *		  Fix standard IRQ wake for EINT0..4 and RTC
 */
 
-
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
@@ -52,10 +57,73 @@
 #include <asm/arch/regs-irq.h>
 #include <asm/arch/regs-gpio.h>
 
+#include "pm.h"
 
 #define irqdbf(x...)
 #define irqdbf2(x...)
 
+#define EXTINT_OFF (IRQ_EINT4 - 4)
+
+/* wakeup irq control */
+
+#ifdef CONFIG_PM
+
+/* state for IRQs over sleep */
+
+/* default is to allow for EINT0..EINT15, and IRQ_RTC as wakeup sources
+ *
+ * set bit to 1 in allow bitfield to enable the wakeup settings on it
+*/
+
+unsigned long s3c_irqwake_intallow	= 1L << (IRQ_RTC - IRQ_EINT0) | 0xfL;
+unsigned long s3c_irqwake_intmask	= 0xffffffffL;
+unsigned long s3c_irqwake_eintallow	= 0x0000fff0L;
+unsigned long s3c_irqwake_eintmask	= 0xffffffffL;
+
+static int
+s3c_irq_wake(unsigned int irqno, unsigned int state)
+{
+	unsigned long irqbit = 1 << (irqno - IRQ_EINT0);
+
+	if (!(s3c_irqwake_intallow & irqbit))
+		return -ENOENT;
+
+	printk(KERN_INFO "wake %s for irq %d\n",
+	       state ? "enabled" : "disabled", irqno);
+
+	if (!state)
+		s3c_irqwake_intmask |= irqbit;
+	else
+		s3c_irqwake_intmask &= ~irqbit;
+
+	return 0;
+}
+
+static int
+s3c_irqext_wake(unsigned int irqno, unsigned int state)
+{
+	unsigned long bit = 1L << (irqno - EXTINT_OFF);
+
+	if (!(s3c_irqwake_eintallow & bit))
+		return -ENOENT;
+
+	printk(KERN_INFO "wake %s for irq %d\n",
+	       state ? "enabled" : "disabled", irqno);
+
+	if (!state)
+		s3c_irqwake_eintmask |= bit;
+	else
+		s3c_irqwake_eintmask &= ~bit;
+
+	return 0;
+}
+
+#else
+#define s3c_irqext_wake NULL
+#define s3c_irq_wake NULL
+#endif
+
+
 static void
 s3c_irq_mask(unsigned int irqno)
 {
@@ -109,21 +177,21 @@
 static struct irqchip s3c_irq_level_chip = {
 	.ack	   = s3c_irq_maskack,
 	.mask	   = s3c_irq_mask,
-	.unmask	   = s3c_irq_unmask
+	.unmask	   = s3c_irq_unmask,
+	.wake	   = s3c_irq_wake
 };
 
 static struct irqchip s3c_irq_chip = {
 	.ack	   = s3c_irq_ack,
 	.mask	   = s3c_irq_mask,
-	.unmask	   = s3c_irq_unmask
+	.unmask	   = s3c_irq_unmask,
+	.wake	   = s3c_irq_wake
 };
 
 /* S3C2410_EINTMASK
  * S3C2410_EINTPEND
  */
 
-#define EXTINT_OFF (IRQ_EINT4 - 4)
-
 static void
 s3c_irqext_mask(unsigned int irqno)
 {
@@ -276,14 +344,16 @@
 	.mask	    = s3c_irqext_mask,
 	.unmask	    = s3c_irqext_unmask,
 	.ack	    = s3c_irqext_ack,
-	.type	    = s3c_irqext_type
+	.type	    = s3c_irqext_type,
+	.wake	    = s3c_irqext_wake
 };
 
 static struct irqchip s3c_irq_eint0t4 = {
 	.ack	   = s3c_irq_ack,
 	.mask	   = s3c_irq_mask,
 	.unmask	   = s3c_irq_unmask,
-	.type	   = s3c_irqext_type
+	.wake	   = s3c_irq_wake,
+	.type	   = s3c_irqext_type,
 };
 
 /* mask values for the parent registers for each of the interrupt types */
diff -Nru a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
--- a/arch/arm/mach-s3c2410/mach-bast.c	2004-12-24 13:36:56 -08:00
+++ b/arch/arm/mach-s3c2410/mach-bast.c	2004-12-24 13:36:56 -08:00
@@ -18,6 +18,8 @@
  *     05-Sep-2003 BJD  Moved to v2.6 kernel
  *     06-Jan-2003 BJD  Updates for <arch/map.h>
  *     18-Jan-2003 BJD  Added serial port configuration
+ *     05-Oct-2004 BJD  Power management code
+ *     04-Nov-2004 BJD  Updated serial port clocks
 */
 
 #include <linux/kernel.h>
@@ -33,6 +35,7 @@
 #include <asm/mach/irq.h>
 
 #include <asm/arch/bast-map.h>
+#include <asm/arch/bast-irq.h>
 
 #include <asm/hardware.h>
 #include <asm/io.h>
@@ -41,11 +44,17 @@
 
 //#include <asm/debug-ll.h>
 #include <asm/arch/regs-serial.h>
+#include <asm/arch/regs-gpio.h>
+#include <asm/arch/regs-mem.h>
 
 #include "s3c2410.h"
+#include "clock.h"
 #include "devs.h"
 #include "cpu.h"
 #include "usb-simtec.h"
+#include "pm.h"
+
+#define COPYRIGHT ", (c) 2004 Simtec Electronics"
 
 /* macros for virtual address mods for the io space entries */
 #define VA_C5(item) ((item) + BAST_VAM_CS5)
@@ -146,35 +155,50 @@
 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
 
-/* base baud rate for all our UARTs */
-static unsigned long bast_serial_clock = 24*1000*1000;
+static struct s3c24xx_uart_clksrc bast_serial_clocks[] = {
+	[0] = {
+		.name		= "uclk",
+		.divisor	= 1,
+		.min_baud	= 0,
+		.max_baud	= 0,
+	},
+	[1] = {
+		.name		= "pclk",
+		.divisor	= 1,
+		.min_baud	= 0,
+		.max_baud	= 0.
+	}
+};
+
 
 static struct s3c2410_uartcfg bast_uartcfgs[] = {
 	[0] = {
 		.hwport	     = 0,
 		.flags	     = 0,
-		.clock	     = &bast_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
+		.clocks	     = bast_serial_clocks,
+		.clocks_size = ARRAY_SIZE(bast_serial_clocks)
 	},
 	[1] = {
 		.hwport	     = 1,
 		.flags	     = 0,
-
-		.clock	     = &bast_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
+		.clocks	     = bast_serial_clocks,
+		.clocks_size = ARRAY_SIZE(bast_serial_clocks)
 	},
 	/* port 2 is not actually used */
 	[2] = {
 		.hwport	     = 2,
 		.flags	     = 0,
-		.clock	     = &bast_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
+		.clocks	     = bast_serial_clocks,
+		.clocks_size = ARRAY_SIZE(bast_serial_clocks)
 	}
 };
 
@@ -207,16 +231,39 @@
 	&bast_device_nor
 };
 
-static struct s3c2410_board bast_board __initdata = {
+static struct clk *bast_clocks[] = {
+	&s3c24xx_dclk0,
+	&s3c24xx_dclk1,
+	&s3c24xx_clkout0,
+	&s3c24xx_clkout1,
+	&s3c24xx_uclk,
+};
+
+static struct s3c24xx_board bast_board __initdata = {
 	.devices       = bast_devices,
-	.devices_count = ARRAY_SIZE(bast_devices)
+	.devices_count = ARRAY_SIZE(bast_devices),
+	.clocks	       = bast_clocks,
+	.clocks_count  = ARRAY_SIZE(bast_clocks)
 };
 
 void __init bast_map_io(void)
 {
+	/* initialise the clocks */
+
+	s3c24xx_dclk0.parent = NULL;
+	s3c24xx_dclk0.rate   = 12*1000*1000;
+
+	s3c24xx_dclk1.parent = NULL;
+	s3c24xx_dclk1.rate   = 24*1000*1000;
+
+	s3c24xx_clkout0.parent  = &s3c24xx_dclk0;
+	s3c24xx_clkout1.parent  = &s3c24xx_dclk1;
+
+	s3c24xx_uclk.parent  = &s3c24xx_clkout1;
+
 	s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
 	s3c2410_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
-	s3c2410_set_board(&bast_board);
+	s3c24xx_set_board(&bast_board);
 	usb_simtec_init();
 }
 
@@ -225,16 +272,39 @@
 	s3c2410_init_irq();
 }
 
-void __init bast_init_time(void)
+#ifdef CONFIG_PM
+
+/* bast_init_machine
+ *
+ * enable the power management functions for the EB2410ITX
+*/
+
+static __init void bast_init_machine(void)
 {
-	s3c2410_init_time();
+	unsigned long gstatus4;
+
+	printk(KERN_INFO "BAST Power Manangement" COPYRIGHT "\n");
+
+	gstatus4  = (__raw_readl(S3C2410_BANKCON7) & 0x3) << 30;
+	gstatus4 |= (__raw_readl(S3C2410_BANKCON6) & 0x3) << 28;
+	gstatus4 |= (__raw_readl(S3C2410_BANKSIZE) & S3C2410_BANKSIZE_MASK);
+
+	__raw_writel(gstatus4, S3C2410_GSTATUS4);
+
+	s3c2410_pm_init();
 }
 
+#else
+#define bast_init_machine NULL
+#endif
+
+
 MACHINE_START(BAST, "Simtec-BAST")
      MAINTAINER("Ben Dooks <ben@simtec.co.uk>")
      BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART)
      BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
      MAPIO(bast_map_io)
      INITIRQ(bast_init_irq)
-     INITTIME(bast_init_time)
+	.init_machine	= bast_init_machine,
+     .timer		= &s3c2410_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
--- a/arch/arm/mach-s3c2410/mach-h1940.c	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/mach-s3c2410/mach-h1940.c	2004-12-24 13:37:18 -08:00
@@ -18,6 +18,8 @@
  *     17-Feb-2003 BJD  Copied to mach-ipaq.c
  *     21-Aug-2004 BJD  Added struct s3c2410_board
  *     04-Sep-2004 BJD  Changed uart init, renamed ipaq_ -> h1940_
+ *     18-Oct-2004 BJD  Updated new board structure name
+ *     04-Nov-2004 BJD  Change for new serial clock
 */
 
 #include <linux/kernel.h>
@@ -40,7 +42,10 @@
 //#include <asm/debug-ll.h>
 #include <asm/arch/regs-serial.h>
 
+#include <linux/serial_core.h>
+
 #include "s3c2410.h"
+#include "clock.h"
 #include "devs.h"
 #include "cpu.h"
 
@@ -56,7 +61,6 @@
 	[0] = {
 		.hwport	     = 0,
 		.flags	     = 0,
-		.clock	     = &s3c2410_pclk,
 		.ucon	     = 0x3c5,
 		.ulcon	     = 0x03,
 		.ufcon	     = 0x51,
@@ -64,7 +68,6 @@
 	[1] = {
 		.hwport	     = 1,
 		.flags	     = 0,
-		.clock	     = &s3c2410_pclk,
 		.ucon	     = 0x245,
 		.ulcon	     = 0x03,
 		.ufcon	     = 0x00,
@@ -73,7 +76,7 @@
 	[2] = {
 		.hwport	     = 2,
 		.flags	     = 0,
-		.clock	     = &s3c2410_pclk,
+		.uart_flags  = UPF_CONS_FLOW,
 		.ucon	     = 0x3c5,
 		.ulcon	     = 0x43,
 		.ufcon	     = 0x51,
@@ -91,7 +94,7 @@
 	&s3c_device_iis,
 };
 
-static struct s3c2410_board h1940_board __initdata = {
+static struct s3c24xx_board h1940_board __initdata = {
 	.devices       = h1940_devices,
 	.devices_count = ARRAY_SIZE(h1940_devices)
 };
@@ -100,7 +103,7 @@
 {
 	s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
 	s3c2410_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
-	s3c2410_set_board(&h1940_board);
+	s3c24xx_set_board(&h1940_board);
 }
 
 void __init h1940_init_irq(void)
@@ -109,16 +112,11 @@
 
 }
 
-void __init h1940_init_time(void)
-{
-	s3c2410_init_time();
-}
-
 MACHINE_START(H1940, "IPAQ-H1940")
      MAINTAINER("Ben Dooks <ben@fluff.org>")
      BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART)
      BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
      MAPIO(h1940_map_io)
      INITIRQ(h1940_init_irq)
-     INITTIME(h1940_init_time)
+     .timer		= &s3c2410_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-s3c2410/mach-rx3715.c b/arch/arm/mach-s3c2410/mach-rx3715.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-s3c2410/mach-rx3715.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,124 @@
+/* linux/arch/arm/mach-s3c2410/mach-rx3715.c
+ *
+ * Copyright (c) 2003,2004 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
+ *
+ * http://www.handhelds.org/projects/rx3715.html
+ *
+ * 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.
+ *
+ * Modifications:
+ *	16-Sep-2004 BJD Copied from mach-h1940.c
+ *	25-Oct-2004 BJD Updates for 2.6.10-rc1
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/init.h>
+#include <linux/tty.h>
+#include <linux/console.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+
+#include <asm/hardware.h>
+#include <asm/hardware/iomd.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+
+#include <asm/arch/regs-serial.h>
+#include <asm/arch/regs-gpio.h>
+
+#include "s3c2410.h"
+#include "s3c2440.h"
+#include "clock.h"
+#include "devs.h"
+#include "cpu.h"
+#include "pm.h"
+
+static struct map_desc rx3715_iodesc[] __initdata = {
+	/* dump ISA space somewhere unused */
+
+	{ S3C2410_VA_ISA_WORD, S3C2410_CS3, SZ_16M, MT_DEVICE },
+	{ S3C2410_VA_ISA_BYTE, S3C2410_CS3, SZ_16M, MT_DEVICE },
+};
+
+static struct s3c2410_uartcfg rx3715_uartcfgs[] = {
+	[0] = {
+		.hwport	     = 0,
+		.flags	     = 0,
+		.ucon	     = 0x3c5,
+		.ulcon	     = 0x03,
+		.ufcon	     = 0x51,
+	},
+	[1] = {
+		.hwport	     = 1,
+		.flags	     = 0,
+		.ucon	     = 0x3c5,
+		.ulcon	     = 0x03,
+		.ufcon	     = 0x00,
+	},
+	/* IR port */
+	[2] = {
+		.hwport	     = 2,
+		.uart_flags  = UPF_CONS_FLOW,
+		.ucon	     = 0x3c5,
+		.ulcon	     = 0x43,
+		.ufcon	     = 0x51,
+	}
+};
+
+static struct platform_device *rx3715_devices[] __initdata = {
+	&s3c_device_usb,
+	&s3c_device_lcd,
+	&s3c_device_wdt,
+	&s3c_device_i2c,
+	&s3c_device_iis,
+};
+
+static struct s3c24xx_board rx3715_board __initdata = {
+	.devices       = rx3715_devices,
+	.devices_count = ARRAY_SIZE(rx3715_devices)
+};
+
+void __init rx3715_map_io(void)
+{
+	s3c24xx_xtal = 16934000;
+
+	s3c24xx_init_io(rx3715_iodesc, ARRAY_SIZE(rx3715_iodesc));
+	s3c2440_init_uarts(rx3715_uartcfgs, ARRAY_SIZE(rx3715_uartcfgs));
+	s3c24xx_set_board(&rx3715_board);
+}
+
+void __init rx3715_init_irq(void)
+{
+	s3c2410_init_irq();
+}
+
+#ifdef CONFIG_PM
+static void __init rx3715_init_machine(void)
+{
+	s3c2410_pm_init();
+}
+#else
+#define rx3715_init_machine NULL
+#endif
+
+MACHINE_START(RX3715, "IPAQ-RX3715")
+     MAINTAINER("Ben Dooks <ben@fluff.org>")
+     BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART)
+     BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
+     MAPIO(rx3715_map_io)
+     INITIRQ(rx3715_init_irq)
+     INIT_MACHINE(rx3715_init_machine)
+     .timer		= &s3c2410_timer,
+MACHINE_END
diff -Nru a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c
--- a/arch/arm/mach-s3c2410/mach-smdk2410.c	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/mach-s3c2410/mach-smdk2410.c	2004-12-24 13:36:49 -08:00
@@ -58,14 +58,10 @@
 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
 
-/* base baud rate for all our UARTs */
-static unsigned long smdk2410_serial_clock = 24*1000*1000;
-
 static struct s3c2410_uartcfg smdk2410_uartcfgs[] = {
 	[0] = {
 		.hwport	     = 0,
 		.flags	     = 0,
-		.clock	     = &smdk2410_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
@@ -73,7 +69,6 @@
 	[1] = {
 		.hwport	     = 1,
 		.flags	     = 0,
-		.clock	     = &smdk2410_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
@@ -81,7 +76,6 @@
 	[2] = {
 		.hwport	     = 2,
 		.flags	     = 0,
-		.clock	     = &smdk2410_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
@@ -96,7 +90,7 @@
 	&s3c_device_iis,
 };
 
-static struct s3c2410_board smdk2410_board __initdata = {
+static struct s3c24xx_board smdk2410_board __initdata = {
 	.devices       = smdk2410_devices,
 	.devices_count = ARRAY_SIZE(smdk2410_devices)
 };
@@ -105,7 +99,7 @@
 {
 	s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
 	s3c2410_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
-	s3c2410_set_board(&smdk2410_board);
+	s3c24xx_set_board(&smdk2410_board);
 }
 
 void __init smdk2410_init_irq(void)
@@ -113,11 +107,6 @@
 	s3c2410_init_irq();
 }
 
-void __init smdk2410_init_time(void)
-{
-	s3c2410_init_time();
-}
-
 MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch
 				    * to SMDK2410 */
      MAINTAINER("Jonas Dietsche")
@@ -125,7 +114,7 @@
      BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
      MAPIO(smdk2410_map_io)
      INITIRQ(smdk2410_init_irq)
-     INITTIME(smdk2410_init_time)
+     .timer		= &s3c2410_timer,
 MACHINE_END
 
 
diff -Nru a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c2410/mach-vr1000.c
--- a/arch/arm/mach-s3c2410/mach-vr1000.c	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/mach-s3c2410/mach-vr1000.c	2004-12-24 13:37:18 -08:00
@@ -16,6 +16,8 @@
  *     21-Aug-2004 BJD  Added struct s3c2410_board
  *     06-Aug-2004 BJD  Fixed call to time initialisation
  *     05-Apr-2004 BJD  Copied to make mach-vr1000.c
+ *     18-Oct-2004 BJD  Updated board struct
+ *     04-Nov-2004 BJD  Clock and serial configuration update
 */
 
 #include <linux/kernel.h>
@@ -41,6 +43,7 @@
 #include <asm/arch/regs-serial.h>
 
 #include "s3c2410.h"
+#include "clock.h"
 #include "devs.h"
 #include "cpu.h"
 #include "usb-simtec.h"
@@ -112,34 +115,52 @@
 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
 
-/* base baud rate for all our UARTs */
-static unsigned long vr1000_serial_clock = 3692307;
+/* uart clock source(s) */
+
+static struct s3c24xx_uart_clksrc vr1000_serial_clocks[] = {
+	[0] = {
+		.name		= "uclk",
+		.divisor	= 1,
+		.min_baud	= 0,
+		.max_baud	= 0,
+	},
+	[1] = {
+		.name		= "pclk",
+		.divisor	= 1,
+		.min_baud	= 0,
+		.max_baud	= 0.
+	}
+};
 
 static struct s3c2410_uartcfg vr1000_uartcfgs[] = {
 	[0] = {
 		.hwport	     = 0,
 		.flags	     = 0,
-		.clock	     = &vr1000_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
+		.clocks	     = vr1000_serial_clocks,
+		.clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
 	},
 	[1] = {
 		.hwport	     = 1,
 		.flags	     = 0,
-		.clock	     = &vr1000_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
+		.clocks	     = vr1000_serial_clocks,
+		.clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
 	},
 	/* port 2 is not actually used */
 	[2] = {
 		.hwport	     = 2,
 		.flags	     = 0,
-		.clock	     = &vr1000_serial_clock,
 		.ucon	     = UCON,
 		.ulcon	     = ULCON,
 		.ufcon	     = UFCON,
+		.clocks	     = vr1000_serial_clocks,
+		.clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
+
 	}
 };
 
@@ -151,17 +172,40 @@
 	&s3c_device_iis,
 };
 
-static struct s3c2410_board vr1000_board __initdata = {
+static struct clk *vr1000_clocks[] = {
+	&s3c24xx_dclk0,
+	&s3c24xx_dclk1,
+	&s3c24xx_clkout0,
+	&s3c24xx_clkout1,
+	&s3c24xx_uclk,
+};
+
+static struct s3c24xx_board vr1000_board __initdata = {
 	.devices       = vr1000_devices,
-	.devices_count = ARRAY_SIZE(vr1000_devices)
+	.devices_count = ARRAY_SIZE(vr1000_devices),
+	.clocks	       = vr1000_clocks,
+	.clocks_count  = ARRAY_SIZE(vr1000_clocks),
 };
 
 
 void __init vr1000_map_io(void)
 {
+	/* initialise clock sources */
+
+	s3c24xx_dclk0.parent = NULL;
+	s3c24xx_dclk0.rate   = 12*1000*1000;
+
+	s3c24xx_dclk1.parent = NULL;
+	s3c24xx_dclk1.rate   = 3692307;
+
+	s3c24xx_clkout0.parent  = &s3c24xx_dclk0;
+	s3c24xx_clkout1.parent  = &s3c24xx_dclk1;
+
+	s3c24xx_uclk.parent  = &s3c24xx_clkout1;
+
 	s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
 	s3c2410_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
-	s3c2410_set_board(&vr1000_board);
+	s3c24xx_set_board(&vr1000_board);
 	usb_simtec_init();
 }
 
@@ -170,16 +214,11 @@
 	s3c2410_init_irq();
 }
 
-void __init vr1000_init_time(void)
-{
-	s3c2410_init_time();
-}
-
 MACHINE_START(VR1000, "Thorcom-VR1000")
      MAINTAINER("Ben Dooks <ben@simtec.co.uk>")
      BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART)
      BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
      MAPIO(vr1000_map_io)
      INITIRQ(vr1000_init_irq)
-     INITTIME(vr1000_init_time)
+     .timer		= &s3c2410_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-s3c2410/pm.c b/arch/arm/mach-s3c2410/pm.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-s3c2410/pm.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,667 @@
+/* linux/arch/arm/mach-s3c2410/pm.c
+ *
+ * Copyright (c) 2004 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C2410 Power Manager (Suspend-To-RAM) support
+ *
+ * See Documentation/arm/Samsung-S3C24XX/Suspend.txt for more information
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (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
+ *
+ * Parts based on arch/arm/mach-pxa/pm.c
+ *
+ * Thanks to Dimitry Andric for debugging
+*/
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/suspend.h>
+#include <linux/errno.h>
+#include <linux/time.h>
+#include <linux/interrupt.h>
+#include <linux/crc32.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+
+#include <asm/arch/regs-serial.h>
+#include <asm/arch/regs-clock.h>
+#include <asm/arch/regs-gpio.h>
+#include <asm/arch/regs-mem.h>
+#include <asm/arch/regs-irq.h>
+
+#include <asm/mach/time.h>
+
+#include "pm.h"
+
+/* for external use */
+
+unsigned long s3c_pm_flags;
+
+/* cache functions from arch/arm/mm/proc-arm920.S */
+
+extern void arm920_flush_kern_cache_all(void);
+
+#define PFX "s3c24xx-pm: "
+
+static struct sleep_save core_save[] = {
+	SAVE_ITEM(S3C2410_LOCKTIME),
+	SAVE_ITEM(S3C2410_CLKCON),
+
+	/* we restore the timings here, with the proviso that the board
+	 * brings the system up in an slower, or equal frequency setting
+	 * to the original system.
+	 *
+	 * if we cannot guarantee this, then things are going to go very
+	 * wrong here, as we modify the refresh and both pll settings.
+	 */
+
+	SAVE_ITEM(S3C2410_BWSCON),
+	SAVE_ITEM(S3C2410_BANKCON0),
+	SAVE_ITEM(S3C2410_BANKCON1),
+	SAVE_ITEM(S3C2410_BANKCON2),
+	SAVE_ITEM(S3C2410_BANKCON3),
+	SAVE_ITEM(S3C2410_BANKCON4),
+	SAVE_ITEM(S3C2410_BANKCON5),
+
+	SAVE_ITEM(S3C2410_CLKDIVN),
+	SAVE_ITEM(S3C2410_MPLLCON),
+	SAVE_ITEM(S3C2410_UPLLCON),
+	SAVE_ITEM(S3C2410_CLKSLOW),
+	SAVE_ITEM(S3C2410_REFRESH),
+};
+
+/* this lot should be really saved by the IRQ code */
+static struct sleep_save irq_save[] = {
+	SAVE_ITEM(S3C2410_EXTINT0),
+	SAVE_ITEM(S3C2410_EXTINT1),
+	SAVE_ITEM(S3C2410_EXTINT2),
+	SAVE_ITEM(S3C2410_EINFLT0),
+	SAVE_ITEM(S3C2410_EINFLT1),
+	SAVE_ITEM(S3C2410_EINFLT2),
+	SAVE_ITEM(S3C2410_EINFLT3),
+	SAVE_ITEM(S3C2410_EINTMASK),
+	SAVE_ITEM(S3C2410_INTMSK)
+};
+
+static struct sleep_save gpio_save[] = {
+	SAVE_ITEM(S3C2410_GPACON),
+	SAVE_ITEM(S3C2410_GPADAT),
+
+	SAVE_ITEM(S3C2410_GPBCON),
+	SAVE_ITEM(S3C2410_GPBDAT),
+	SAVE_ITEM(S3C2410_GPBUP),
+
+	SAVE_ITEM(S3C2410_GPCCON),
+	SAVE_ITEM(S3C2410_GPCDAT),
+	SAVE_ITEM(S3C2410_GPCUP),
+
+	SAVE_ITEM(S3C2410_GPDCON),
+	SAVE_ITEM(S3C2410_GPDDAT),
+	SAVE_ITEM(S3C2410_GPDUP),
+
+	SAVE_ITEM(S3C2410_GPECON),
+	SAVE_ITEM(S3C2410_GPEDAT),
+	SAVE_ITEM(S3C2410_GPEUP),
+
+	SAVE_ITEM(S3C2410_GPFCON),
+	SAVE_ITEM(S3C2410_GPFDAT),
+	SAVE_ITEM(S3C2410_GPFUP),
+
+	SAVE_ITEM(S3C2410_GPGCON),
+	SAVE_ITEM(S3C2410_GPGDAT),
+	SAVE_ITEM(S3C2410_GPGUP),
+
+	SAVE_ITEM(S3C2410_GPHCON),
+	SAVE_ITEM(S3C2410_GPHDAT),
+	SAVE_ITEM(S3C2410_GPHUP),
+
+	SAVE_ITEM(S3C2410_DCLKCON),
+};
+
+#ifdef CONFIG_S3C2410_PM_DEBUG
+
+#define SAVE_UART(va) \
+	SAVE_ITEM((va) + S3C2410_ULCON), \
+	SAVE_ITEM((va) + S3C2410_UCON), \
+	SAVE_ITEM((va) + S3C2410_UFCON), \
+	SAVE_ITEM((va) + S3C2410_UMCON), \
+	SAVE_ITEM((va) + S3C2410_UBRDIV)
+
+static struct sleep_save uart_save[] = {
+	SAVE_UART(S3C2410_VA_UART0),
+	SAVE_UART(S3C2410_VA_UART1),
+	SAVE_UART(S3C2410_VA_UART2),
+};
+
+/* debug
+ *
+ * we send the debug to printascii() to allow it to be seen if the
+ * system never wakes up from the sleep
+*/
+
+extern void printascii(const char *);
+
+static void pm_dbg(const char *fmt, ...)
+{
+	va_list va;
+	char buff[256];
+
+	va_start(va, fmt);
+	vsprintf(buff, fmt, va);
+	va_end(va);
+
+	printascii(buff);
+}
+
+static void s3c2410_pm_debug_init(void)
+{
+	unsigned long tmp = __raw_readl(S3C2410_CLKCON);
+
+	/* re-start uart clocks */
+	tmp |= S3C2410_CLKCON_UART0;
+	tmp |= S3C2410_CLKCON_UART1;
+	tmp |= S3C2410_CLKCON_UART2;
+
+	__raw_writel(tmp, S3C2410_CLKCON);
+	udelay(10);
+}
+
+#define DBG(fmt...) pm_dbg(fmt)
+#else
+#define DBG(fmt...) printk(KERN_DEBUG fmt)
+
+#define s3c2410_pm_debug_init() do { } while(0)
+
+static struct sleep_save uart_save[] = {};
+#endif
+
+#if defined(CONFIG_S3C2410_PM_CHECK) && CONFIG_S3C2410_PM_CHECK_CHUNKSIZE != 0
+
+/* suspend checking code...
+ *
+ * this next area does a set of crc checks over all the installed
+ * memory, so the system can verify if the resume was ok.
+ *
+ * CONFIG_S3C2410_PM_CHECK_CHUNKSIZE defines the block-size for the CRC,
+ * increasing it will mean that the area corrupted will be less easy to spot,
+ * and reducing the size will cause the CRC save area to grow
+*/
+
+#define CHECK_CHUNKSIZE (CONFIG_S3C2410_PM_CHECK_CHUNKSIZE * 1024)
+
+static u32 crc_size;	/* size needed for the crc block */
+static u32 *crcs;	/* allocated over suspend/resume */
+
+typedef u32 *(run_fn_t)(struct resource *ptr, u32 *arg);
+
+/* s3c2410_pm_run_res
+ *
+ * go thorugh the given resource list, and look for system ram
+*/
+
+static void s3c2410_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg)
+{
+	while (ptr != NULL) {
+		if (ptr->child != NULL)
+			s3c2410_pm_run_res(ptr->child, fn, arg);
+
+		if ((ptr->flags & IORESOURCE_MEM) &&
+		    strcmp(ptr->name, "System RAM") == 0) {
+			DBG("Found system RAM at %08lx..%08lx\n",
+			    ptr->start, ptr->end);
+			arg = (fn)(ptr, arg);
+		}
+
+		ptr = ptr->sibling;
+	}
+}
+
+static void s3c2410_pm_run_sysram(run_fn_t fn, u32 *arg)
+{
+	s3c2410_pm_run_res(&iomem_resource, fn, arg);
+}
+
+static u32 *s3c2410_pm_countram(struct resource *res, u32 *val)
+{
+	u32 size = (u32)(res->end - res->start)+1;
+
+	size += CHECK_CHUNKSIZE-1;
+	size /= CHECK_CHUNKSIZE;
+
+	DBG("Area %08lx..%08lx, %d blocks\n", res->start, res->end, size);
+
+	*val += size * sizeof(u32);
+	return val;
+}
+
+/* s3c2410_pm_prepare_check
+ *
+ * prepare the necessary information for creating the CRCs. This
+ * must be done before the final save, as it will require memory
+ * allocating, and thus touching bits of the kernel we do not
+ * know about.
+*/
+
+static void s3c2410_pm_check_prepare(void)
+{
+	crc_size = 0;
+
+	s3c2410_pm_run_sysram(s3c2410_pm_countram, &crc_size);
+
+	DBG("s3c2410_pm_prepare_check: %u checks needed\n", crc_size);
+
+	crcs = kmalloc(crc_size+4, GFP_KERNEL);
+	if (crcs == NULL)
+		printk(KERN_ERR "Cannot allocated CRC save area\n");
+}
+
+static u32 *s3c2410_pm_makecheck(struct resource *res, u32 *val)
+{
+	unsigned long addr, left;
+
+	for (addr = res->start; addr < res->end;
+	     addr += CHECK_CHUNKSIZE) {
+		left = res->end - addr;
+
+		if (left > CHECK_CHUNKSIZE)
+			left = CHECK_CHUNKSIZE;
+
+		*val = crc32_le(~0, phys_to_virt(addr), left);
+		val++;
+	}
+
+	return val;
+}
+
+/* s3c2410_pm_check_store
+ *
+ * compute the CRC values for the memory blocks before the final
+ * sleep.
+*/
+
+static void s3c2410_pm_check_store(void)
+{
+	if (crcs != NULL)
+		s3c2410_pm_run_sysram(s3c2410_pm_makecheck, crcs);
+}
+
+/* in_region
+ *
+ * return TRUE if the area defined by ptr..ptr+size contatins the
+ * what..what+whatsz
+*/
+
+static inline int in_region(void *ptr, int size, void *what, size_t whatsz)
+{
+	if ((what+whatsz) < ptr)
+		return 0;
+
+	if (what > (ptr+size))
+		return 0;
+
+	return 1;
+}
+
+static u32 *s3c2410_pm_runcheck(struct resource *res, u32 *val)
+{
+	void *save_at = phys_to_virt(s3c2410_sleep_save_phys);
+	unsigned long addr;
+	unsigned long left;
+	void *ptr;
+	u32 calc;
+
+	for (addr = res->start; addr < res->end;
+	     addr += CHECK_CHUNKSIZE) {
+		left = res->end - addr;
+
+		if (left > CHECK_CHUNKSIZE)
+			left = CHECK_CHUNKSIZE;
+
+		ptr = phys_to_virt(addr);
+
+		if (in_region(ptr, left, crcs, crc_size)) {
+			DBG("skipping %08lx, has crc block in\n", addr);
+			goto skip_check;
+		}
+
+		if (in_region(ptr, left, save_at, 32*4 )) {
+			DBG("skipping %08lx, has save block in\n", addr);
+			goto skip_check;
+		}
+
+		/* calculate and check the checksum */
+
+		calc = crc32_le(~0, ptr, left);
+		if (calc != *val) {
+			printk(KERN_ERR PFX "Restore CRC error at "
+			       "%08lx (%08x vs %08x)\n", addr, calc, *val);
+
+			DBG("Restore CRC error at %08lx (%08x vs %08x)\n",
+			    addr, calc, *val);
+		}
+
+	skip_check:
+		val++;
+	}
+
+	return val;
+}
+
+/* s3c2410_pm_check_restore
+ *
+ * check the CRCs after the restore event and free the memory used
+ * to hold them
+*/
+
+static void s3c2410_pm_check_restore(void)
+{
+	if (crcs != NULL) {
+		s3c2410_pm_run_sysram(s3c2410_pm_runcheck, crcs);
+		kfree(crcs);
+		crcs = NULL;
+	}
+}
+
+#else
+
+#define s3c2410_pm_check_prepare() do { } while(0)
+#define s3c2410_pm_check_restore() do { } while(0)
+#define s3c2410_pm_check_store()   do { } while(0)
+#endif
+
+/* helper functions to save and restore register state */
+
+void s3c2410_pm_do_save(struct sleep_save *ptr, int count)
+{
+	for (; count > 0; count--, ptr++) {
+		ptr->val = __raw_readl(ptr->reg);
+		DBG("saved %08lx value %08lx\n", ptr->reg, ptr->val);
+	}
+}
+
+/* s3c2410_pm_do_restore
+ *
+ * restore the system from the given list of saved registers
+ *
+ * Note, we do not use DBG() in here, as the system may not have
+ * restore the UARTs state yet
+*/
+
+void s3c2410_pm_do_restore(struct sleep_save *ptr, int count)
+{
+	for (; count > 0; count--, ptr++) {
+		printk(KERN_DEBUG "restore %08lx (restore %08lx, was %08x)\n",
+		       ptr->reg, ptr->val, __raw_readl(ptr->reg));
+
+		__raw_writel(ptr->val, ptr->reg);
+	}
+}
+
+/* s3c2410_pm_do_restore_core
+ *
+ * similar to s3c2410_pm_do_restore_core
+ *
+ * WARNING: Do not put any debug in here that may effect memory or use
+ * peripherals, as things may be changing!
+*/
+
+static void s3c2410_pm_do_restore_core(struct sleep_save *ptr, int count)
+{
+	for (; count > 0; count--, ptr++) {
+		__raw_writel(ptr->val, ptr->reg);
+	}
+}
+
+/* s3c2410_pm_show_resume_irqs
+ *
+ * print any IRQs asserted at resume time (ie, we woke from)
+*/
+
+static void s3c2410_pm_show_resume_irqs(int start, unsigned long which,
+					unsigned long mask)
+{
+	int i;
+
+	which &= ~mask;
+
+	for (i = 0; i <= 31; i++) {
+		if ((which) & (1L<<i)) {
+			DBG("IRQ %d asserted at resume\n", start+i);
+		}
+	}
+}
+
+/* s3c2410_pm_check_resume_pin
+ *
+ * check to see if the pin is configured correctly for sleep mode, and
+ * make any necessary adjustments if it is not
+*/
+
+static void s3c2410_pm_check_resume_pin(unsigned int pin, unsigned int irqoffs)
+{
+	unsigned long irqstate;
+	unsigned long pinstate;
+	int irq = s3c2410_gpio_getirq(pin);
+
+	if (irqoffs < 4)
+		irqstate = s3c_irqwake_intmask & (1L<<irqoffs);
+	else
+		irqstate = s3c_irqwake_eintmask & (1L<<irqoffs);
+
+	pinstate = s3c2410_gpio_getcfg(pin);
+	pinstate >>= S3C2410_GPIO_OFFSET(pin)*2;
+
+	if (!irqstate) {
+		if (pinstate == 0x02)
+			DBG("Leaving IRQ %d (pin %d) enabled\n", irq, pin);
+	} else {
+		if (pinstate == 0x02) {
+			DBG("Disabling IRQ %d (pin %d)\n", irq, pin);
+			s3c2410_gpio_cfgpin(pin, 0x00);
+		}
+	}
+}
+
+/* s3c2410_pm_configure_extint
+ *
+ * configure all external interrupt pins
+*/
+
+static void s3c2410_pm_configure_extint(void)
+{
+	int pin;
+
+	/* for each of the external interrupts (EINT0..EINT15) we
+	 * need to check wether it is an external interrupt source,
+	 * and then configure it as an input if it is not
+	*/
+
+	for (pin = S3C2410_GPF0; pin <= S3C2410_GPF7; pin++) {
+		s3c2410_pm_check_resume_pin(pin, pin - S3C2410_GPF0);
+	}
+
+	for (pin = S3C2410_GPG0; pin <= S3C2410_GPG7; pin++) {
+		s3c2410_pm_check_resume_pin(pin, (pin - S3C2410_GPG0)+8);
+	}
+}
+
+#define any_allowed(mask, allow) (((mask) & (allow)) != (allow))
+
+/* s3c2410_pm_enter
+ *
+ * central control for sleep/resume process
+*/
+
+static int s3c2410_pm_enter(suspend_state_t state)
+{
+	unsigned long regs_save[16];
+	unsigned long tmp;
+
+	/* ensure the debug is initialised (if enabled) */
+
+	s3c2410_pm_debug_init();
+
+	DBG("s3c2410_pm_enter(%d)\n", state);
+
+	if (state != PM_SUSPEND_MEM) {
+		printk(KERN_ERR PFX "error: only PM_SUSPEND_MEM supported\n");
+		return -EINVAL;
+	}
+
+	/* check if we have anything to wake-up with... bad things seem
+	 * to happen if you suspend with no wakeup (system will often
+	 * require a full power-cycle)
+	*/
+
+	if (!any_allowed(s3c_irqwake_intmask, s3c_irqwake_intallow) &&
+	    !any_allowed(s3c_irqwake_eintmask, s3c_irqwake_eintallow)) {
+		printk(KERN_ERR PFX "No sources enabled for wake-up!\n");
+		printk(KERN_ERR PFX "Aborting sleep\n");
+		return -EINVAL;
+	}
+
+	/* prepare check area if configured */
+
+	s3c2410_pm_check_prepare();
+
+	/* store the physical address of the register recovery block */
+
+	s3c2410_sleep_save_phys = virt_to_phys(regs_save);
+
+	DBG("s3c2410_sleep_save_phys=0x%08lx\n", s3c2410_sleep_save_phys);
+
+	/* ensure at least GESTATUS3 has the resume address */
+
+	__raw_writel(virt_to_phys(s3c2410_cpu_resume), S3C2410_GSTATUS3);
+
+	DBG("GSTATUS3 0x%08x\n", __raw_readl(S3C2410_GSTATUS3));
+	DBG("GSTATUS4 0x%08x\n", __raw_readl(S3C2410_GSTATUS4));
+
+	/* save all necessary core registers not covered by the drivers */
+
+	s3c2410_pm_do_save(gpio_save, ARRAY_SIZE(gpio_save));
+	s3c2410_pm_do_save(irq_save, ARRAY_SIZE(irq_save));
+	s3c2410_pm_do_save(core_save, ARRAY_SIZE(core_save));
+	s3c2410_pm_do_save(uart_save, ARRAY_SIZE(uart_save));
+
+	/* set the irq configuration for wake */
+
+	s3c2410_pm_configure_extint();
+
+	DBG("sleep: irq wakeup masks: %08lx,%08lx\n",
+	    s3c_irqwake_intmask, s3c_irqwake_eintmask);
+
+	__raw_writel(s3c_irqwake_intmask, S3C2410_INTMSK);
+	__raw_writel(s3c_irqwake_eintmask, S3C2410_EINTMASK);
+
+	/* ack any outstanding external interrupts before we go to sleep */
+
+	__raw_writel(__raw_readl(S3C2410_EINTPEND), S3C2410_EINTPEND);
+
+	/* flush cache back to ram */
+
+	arm920_flush_kern_cache_all();
+
+	s3c2410_pm_check_store();
+
+	// need to make some form of time-delta
+
+	/* send the cpu to sleep... */
+
+	__raw_writel(0x00, S3C2410_CLKCON);  /* turn off clocks over sleep */
+
+	s3c2410_cpu_suspend(regs_save);
+
+	/* unset the return-from-sleep flag, to ensure reset */
+
+	tmp = __raw_readl(S3C2410_GSTATUS2);
+	tmp &= S3C2410_GSTATUS2_OFFRESET;
+	__raw_writel(tmp, S3C2410_GSTATUS2);
+
+	/* restore the system state */
+
+	s3c2410_pm_do_restore_core(core_save, ARRAY_SIZE(core_save));
+	s3c2410_pm_do_restore(gpio_save, ARRAY_SIZE(gpio_save));
+	s3c2410_pm_do_restore(irq_save, ARRAY_SIZE(irq_save));
+	s3c2410_pm_do_restore(uart_save, ARRAY_SIZE(uart_save));
+
+	s3c2410_pm_debug_init();
+
+	/* check what irq (if any) restored the system */
+
+	DBG("post sleep: IRQs 0x%08x, 0x%08x\n",
+	    __raw_readl(S3C2410_SRCPND),
+	    __raw_readl(S3C2410_EINTPEND));
+
+	s3c2410_pm_show_resume_irqs(IRQ_EINT0, __raw_readl(S3C2410_SRCPND),
+				    s3c_irqwake_intmask);
+
+	s3c2410_pm_show_resume_irqs(IRQ_EINT4-4, __raw_readl(S3C2410_EINTPEND),
+				    s3c_irqwake_eintmask);
+
+	DBG("post sleep, preparing to return\n");
+
+	s3c2410_pm_check_restore();
+
+	/* ok, let's return from sleep */
+
+	DBG("S3C2410 PM Resume (post-restore)\n");
+	return 0;
+}
+
+/*
+ * Called after processes are frozen, but before we shut down devices.
+ */
+static int s3c2410_pm_prepare(suspend_state_t state)
+{
+	return 0;
+}
+
+/*
+ * Called after devices are re-setup, but before processes are thawed.
+ */
+static int s3c2410_pm_finish(suspend_state_t state)
+{
+	return 0;
+}
+
+/*
+ * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
+ */
+static struct pm_ops s3c2410_pm_ops = {
+	.pm_disk_mode	= PM_DISK_FIRMWARE,
+	.prepare	= s3c2410_pm_prepare,
+	.enter		= s3c2410_pm_enter,
+	.finish		= s3c2410_pm_finish,
+};
+
+/* s3c2410_pm_init
+ *
+ * Attach the power management functions. This should be called
+ * from the board specific initialisation if the board supports
+ * it.
+*/
+
+int __init s3c2410_pm_init(void)
+{
+	printk("S3C2410 Power Management, (c) 2004 Simtec Electronics\n");
+
+	pm_set_ops(&s3c2410_pm_ops);
+	return 0;
+}
diff -Nru a/arch/arm/mach-s3c2410/pm.h b/arch/arm/mach-s3c2410/pm.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-s3c2410/pm.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,59 @@
+/* linux/arch/arm/mach-s3c2410/pm.h
+ *
+ * Copyright (c) 2004 Simtec Electronics
+ *	Written by Ben Dooks, <ben@simtec.co.uk>
+ *
+ * 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.
+*/
+
+/* s3c2410_pm_init
+ *
+ * called from board at initialisation time to setup the power
+ * management
+*/
+
+#ifdef CONFIG_PM
+
+extern __init int s3c2410_pm_init(void);
+
+#else
+
+static inline int s3c2410_pm_init(void)
+{
+	return 0;
+}
+#endif
+
+/* configuration for the IRQ mask over sleep */
+extern unsigned long s3c_irqwake_intmask;
+extern unsigned long s3c_irqwake_eintmask;
+
+/* IRQ masks for IRQs allowed to go to sleep (see irq.c) */
+extern unsigned long s3c_irqwake_intallow;
+extern unsigned long s3c_irqwake_eintallow;
+
+/* Flags for PM Control */
+
+extern unsigned long s3c_pm_flags;
+
+/* from sleep.S */
+
+extern void s3c2410_cpu_suspend(unsigned long *saveblk);
+extern void s3c2410_cpu_resume(void);
+
+extern unsigned long s3c2410_sleep_save_phys;
+
+/* sleep save info */
+
+struct sleep_save {
+	unsigned long	reg;
+	unsigned long	val;
+};
+
+#define SAVE_ITEM(x) \
+	{ .reg = (x) }
+
+extern void s3c2410_pm_do_save(struct sleep_save *ptr, int count);
+extern void s3c2410_pm_do_restore(struct sleep_save *ptr, int count);
diff -Nru a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c
--- a/arch/arm/mach-s3c2410/s3c2410.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm/mach-s3c2410/s3c2410.c	2004-12-24 13:36:55 -08:00
@@ -1,7 +1,7 @@
 /* linux/arch/arm/mach-s3c2410/s3c2410.c
  *
  * Copyright (c) 2003,2004 Simtec Electronics
- * Ben Dooks <ben@simtec.co.uk>
+ *	Ben Dooks <ben@simtec.co.uk>
  *
  * http://www.simtec.co.uk/products/EB2410ITX/
  *
@@ -15,6 +15,8 @@
  *     05-Sep-2003 BJD  Moved to kernel v2.6
  *     18-Jan-2004 BJD  Added serial port configuration
  *     21-Aug-2004 BJD  Added new struct s3c2410_board handler
+ *     28-Sep-2004 BJD  Updates for new serial port bits
+ *     04-Nov-2004 BJD  Updated UART configuration process
 */
 
 #include <linux/kernel.h>
@@ -38,18 +40,11 @@
 
 #include "s3c2410.h"
 #include "cpu.h"
+#include "clock.h"
 
 int s3c2410_clock_tick_rate = 12*1000*1000;  /* current timers at 12MHz */
 
-/* serial port setup */
-
-struct s3c2410_uartcfg *s3c2410_uartcfgs;
-
-/* clock info */
-
-unsigned long s3c2410_fclk;
-unsigned long s3c2410_hclk;
-unsigned long s3c2410_pclk;
+/* Initial IO mappings */
 
 static struct map_desc s3c2410_iodesc[] __initdata = {
 	IODESC_ENT(USBHOST),
@@ -131,6 +126,37 @@
 	&s3c_uart2
 };
 
+/* store our uart devices for the serial driver console */
+struct platform_device *s3c2410_uart_devices[3];
+
+static int s3c2410_uart_count = 0;
+
+/* uart registration process */
+
+void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
+{
+	struct platform_device *platdev;
+	int uart;
+
+	for (uart = 0; uart < no; uart++, cfg++) {
+		platdev = uart_devices[cfg->hwport];
+
+		s3c24xx_uart_devs[uart] = platdev;
+		platdev->dev.platform_data = cfg;
+	}
+
+	s3c2410_uart_count = uart;
+}
+
+/* s3c2410_map_io
+ *
+ * register the standard cpu IO areas, and any passed in from the
+ * machine specific initialisation.
+ *
+ * this function also sets the initial clock frequencies from the
+ * settings passed in
+*/
+
 void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size)
 {
 	unsigned long tmp;
@@ -140,63 +166,35 @@
 	iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
 	iotable_init(mach_desc, mach_size);
 
-	printk("machine_initted %p,%d\n", mach_desc, mach_size);
-
 	/* now we've got our machine bits initialised, work out what
 	 * clocks we've got */
 
-	s3c2410_fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), 12*MHZ);
+	s3c24xx_fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON),
+				       s3c24xx_xtal);
 
 	tmp = __raw_readl(S3C2410_CLKDIVN);
-	//printk("tmp=%08x, fclk=%d\n", tmp, s3c2410_fclk);
 
 	/* work out clock scalings */
 
-	s3c2410_hclk = s3c2410_fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
-	s3c2410_pclk = s3c2410_hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
+	s3c24xx_hclk = s3c24xx_fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
+	s3c24xx_pclk = s3c24xx_hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
 
 	/* print brieft summary of clocks, etc */
 
 	printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
-	       print_mhz(s3c2410_fclk), print_mhz(s3c2410_hclk),
-	       print_mhz(s3c2410_pclk));
-}
+	       print_mhz(s3c24xx_fclk), print_mhz(s3c24xx_hclk),
+	       print_mhz(s3c24xx_pclk));
 
-static struct s3c2410_board *board;
+	/* initialise the clocks here, to allow other things like the
+	 * console to use them
+	 */
 
-void s3c2410_set_board(struct s3c2410_board *b)
-{
-	board = b;
-}
-
-void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
-{
-	s3c2410_uartcfgs = cfg;
+	s3c2410_init_clocks();
 }
 
 int __init s3c2410_init(void)
 {
-	int ret;
-
 	printk("S3C2410: Initialising architecture\n");
 
-	ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices));
-	if (ret)
-		return ret;
-
-	if (board != NULL) {
-		if (board->devices != NULL) {
-			ret = platform_add_devices(board->devices,
-						   board->devices_count);
-
-			if (ret) {
-				printk(KERN_ERR "s3c2410: failed to add board devices (%d)\n", ret);
-			}
-		}
-
-		/* not adding board devices may not be fatal */
-		ret = 0;
-	}
-
-	return ret;
+	return platform_add_devices(s3c24xx_uart_devs, s3c2410_uart_count);
 }
diff -Nru a/arch/arm/mach-s3c2410/s3c2410.h b/arch/arm/mach-s3c2410/s3c2410.h
--- a/arch/arm/mach-s3c2410/s3c2410.h	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-s3c2410/s3c2410.h	2004-12-24 13:36:48 -08:00
@@ -13,26 +13,18 @@
  *     18-Aug-2004 BJD  Created initial version
  *     20-Aug-2004 BJD  Added s3c2410_board struct
  *     04-Sep-2004 BJD  Added s3c2410_init_uarts() call
+ *     17-Oct-2004 BJD  Moved board out to cpu
 */
 
-extern void s3c2410_map_io(struct map_desc *, int count);
-
-extern void s3c2410_init_irq(void);
+struct s3c2410_uartcfg;
 
-extern void s3c2410_init_time(void);
+extern void s3c2410_map_io(struct map_desc *, int count);
 
-/* the board structure is used at first initialsation time
- * to get info such as the devices to register for this
- * board. This is done because platfrom_add_devices() cannot
- * be called from the map_io entry.
- *
-*/
+extern void s3c2410_init_uarts(struct s3c2410_uartcfg *, int no);
 
-struct s3c2410_board {
-	struct platform_device  **devices;
-	unsigned int              devices_count;
-};
+extern void s3c2410_init_irq(void);
 
-extern void s3c2410_set_board(struct s3c2410_board *board);
+struct sys_timer;
+extern struct sys_timer s3c2410_timer;
 
 extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no);
diff -Nru a/arch/arm/mach-s3c2410/s3c2440-dsc.c b/arch/arm/mach-s3c2410/s3c2440-dsc.c
--- a/arch/arm/mach-s3c2410/s3c2440-dsc.c	2004-12-24 13:37:19 -08:00
+++ b/arch/arm/mach-s3c2410/s3c2440-dsc.c	2004-12-24 13:37:19 -08:00
@@ -11,15 +11,14 @@
  *
  * Modifications:
  *     29-Aug-2004 BJD  Start of drive-strength control
+ *     09-Nov-2004 BJD  Added symbol export
 */
 
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
-#include <linux/list.h>
-#include <linux/timer.h>
 #include <linux/init.h>
-#include <linux/device.h>
+#include <linux/module.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -55,3 +54,5 @@
 	local_irq_restore(flags);
 	return 0;
 }
+
+EXPORT_SYMBOL(s3c2440_set_dsc);
diff -Nru a/arch/arm/mach-s3c2410/s3c2440.c b/arch/arm/mach-s3c2410/s3c2440.c
--- a/arch/arm/mach-s3c2410/s3c2440.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-s3c2410/s3c2440.c	2004-12-24 13:36:17 -08:00
@@ -10,7 +10,12 @@
  * published by the Free Software Foundation.
  *
  * Modifications:
- *     24-Aug-2004 BJD  Start of s3c2440 support
+ *	24-Aug-2004 BJD  Start of s3c2440 support
+ *	12-Oct-2004 BJD	 Moved clock info out to clock.c
+ *	01-Nov-2004 BJD  Fixed clock build code
+ *	09-Nov-2004 BJD  Added sysdev for power management
+ *	04-Nov-2004 BJD  New serial registration
+ *	15-Nov-2004 BJD  Rename the i2c device for the s3c2440
 */
 
 #include <linux/kernel.h>
@@ -20,6 +25,7 @@
 #include <linux/timer.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/sysdev.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -28,24 +34,25 @@
 #include <asm/hardware.h>
 #include <asm/io.h>
 #include <asm/irq.h>
+#include <asm/hardware/clock.h>
 
 #include <asm/arch/regs-clock.h>
 #include <asm/arch/regs-serial.h>
+#include <asm/arch/regs-gpio.h>
+#include <asm/arch/regs-gpioj.h>
+#include <asm/arch/regs-dsc.h>
 
 #include "s3c2440.h"
+#include "clock.h"
+#include "devs.h"
 #include "cpu.h"
+#include "pm.h"
 
 int s3c2440_clock_tick_rate = 12*1000*1000;  /* current timers at 12MHz */
 
 /* clock info */
-
-unsigned long s3c2440_baseclk = 12*1000*1000;  /* assume base is 12MHz */
 unsigned long s3c2440_hdiv;
 
-unsigned long s3c2440_fclk;
-unsigned long s3c2440_hclk;
-unsigned long s3c2440_pclk;
-
 static struct map_desc s3c2440_iodesc[] __initdata = {
 	IODESC_ENT(USBHOST),
 	IODESC_ENT(CLKPWR),
@@ -124,9 +131,79 @@
 	&s3c_uart2
 };
 
+/* uart initialisation */
+
+static int __initdata s3c2440_uart_count;
+
+void __init s3c2440_init_uarts(struct s3c2410_uartcfg *cfg, int no)
+{
+	struct platform_device *platdev;
+	int uart;
+
+	for (uart = 0; uart < no; uart++, cfg++) {
+		platdev = uart_devices[cfg->hwport];
+
+		s3c24xx_uart_devs[uart] = platdev;
+		platdev->dev.platform_data = cfg;
+	}
+
+	s3c2440_uart_count = uart;
+}
+
+/* s3c2440 specific clock sources */
+
+static struct clk s3c2440_clk_cam = {
+	.name		= "camera",
+	.enable		= s3c2410_clkcon_enable,
+	.ctrlbit	= S3C2440_CLKCON_CAMERA
+};
+
+static struct clk s3c2440_clk_ac97 = {
+	.name		= "ac97",
+	.enable		= s3c2410_clkcon_enable,
+	.ctrlbit	= S3C2440_CLKCON_CAMERA
+};
+
+#ifdef CONFIG_PM
+
+struct sleep_save s3c2440_sleep[] = {
+	SAVE_ITEM(S3C2440_DSC0),
+	SAVE_ITEM(S3C2440_DSC1),
+	SAVE_ITEM(S3C2440_GPJDAT),
+	SAVE_ITEM(S3C2440_GPJCON),
+	SAVE_ITEM(S3C2440_GPJUP)
+};
+
+static int s3c2440_suspend(struct sys_device *dev, u32 state)
+{
+	s3c2410_pm_do_save(s3c2440_sleep, ARRAY_SIZE(s3c2440_sleep));
+	return 0;
+}
+
+static int s3c2440_resume(struct sys_device *dev)
+{
+	s3c2410_pm_do_restore(s3c2440_sleep, ARRAY_SIZE(s3c2440_sleep));
+	return 0;
+}
+
+#else
+#define s3c2440_suspend NULL
+#define s3c2440_resume  NULL
+#endif
+
+static struct sysdev_class s3c2440_sysclass = {
+	set_kset_name("s3c2440-core"),
+	.suspend	= s3c2440_suspend,
+	.resume		= s3c2440_resume
+};
+
+static struct sys_device s3c2440_sysdev = {
+	.cls		= &s3c2440_sysclass,
+};
+
 void __init s3c2440_map_io(struct map_desc *mach_desc, int size)
 {
-	unsigned long tmp;
+	unsigned long clkdiv;
 	unsigned long camdiv;
 
 	/* register our io-tables */
@@ -137,15 +214,15 @@
 	/* now we've got our machine bits initialised, work out what
 	 * clocks we've got */
 
-	s3c2440_fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON),
-				       s3c2440_baseclk);
+	s3c24xx_fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON),
+				       s3c24xx_xtal) * 2;
 
-	tmp = __raw_readl(S3C2410_CLKDIVN);
+	clkdiv = __raw_readl(S3C2410_CLKDIVN);
 	camdiv = __raw_readl(S3C2440_CAMDIVN);
 
 	/* work out clock scalings */
 
-	switch (tmp & S3C2440_CLKDIVN_HDIVN_MASK) {
+	switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {
 	case S3C2440_CLKDIVN_HDIVN_1:
 		s3c2440_hdiv = 1;
 		break;
@@ -159,21 +236,40 @@
 		break;
 
 	case S3C2440_CLKDIVN_HDIVN_3_6:
-		s3c2440_hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 6 : 3;
+		s3c2440_hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
 		break;
 	}
 
-	s3c2440_hclk = s3c2440_fclk / s3c2440_hdiv;
-	s3c2440_pclk = s3c2440_hclk / ((tmp & S3C2440_CLKDIVN_PDIVN) ? 2 : 1);
+	s3c24xx_hclk = s3c24xx_fclk / s3c2440_hdiv;
+	s3c24xx_pclk = s3c24xx_hclk / ((clkdiv & S3C2440_CLKDIVN_PDIVN)? 2:1);
 
 	/* print brieft summary of clocks, etc */
 
 	printk("S3C2440: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
-	       print_mhz(s3c2440_fclk), print_mhz(s3c2440_hclk),
-	       print_mhz(s3c2440_pclk));
-}
+	       print_mhz(s3c24xx_fclk), print_mhz(s3c24xx_hclk),
+	       print_mhz(s3c24xx_pclk));
 
+	/* initialise the clocks here, to allow other things like the
+	 * console to use them, and to add new ones after the initialisation
+	 */
 
+	s3c2410_init_clocks();
+
+	/* add s3c2440 specific clocks */
+
+	s3c2440_clk_cam.parent = clk_get(NULL, "hclk");
+	s3c2440_clk_ac97.parent = clk_get(NULL, "pclk");
+
+	s3c2410_register_clock(&s3c2440_clk_ac97);
+	s3c2410_register_clock(&s3c2440_clk_cam);
+
+	clk_disable(&s3c2440_clk_ac97);
+	clk_disable(&s3c2440_clk_cam);
+
+	/* rename any peripherals used differing from the s3c2410 */
+
+	s3c_device_i2c.name = "s3c2440-i2c";
+}
 
 int __init s3c2440_init(void)
 {
@@ -181,12 +277,15 @@
 
 	printk("S3C2440: Initialising architecture\n");
 
-	ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices));
-	if (ret)
-		return ret;
+	ret = sysdev_class_register(&s3c2440_sysclass);
+	if (ret == 0)
+		ret = sysdev_register(&s3c2440_sysdev);
 
-	// todo: board specific inits?
+	if (ret != 0)
+		printk(KERN_ERR "failed to register sysdev for s3c2440\n");
+
+	if (ret == 0)
+		ret = platform_add_devices(s3c24xx_uart_devs, s3c2440_uart_count);
 
 	return ret;
 }
-
diff -Nru a/arch/arm/mach-s3c2410/s3c2440.h b/arch/arm/mach-s3c2410/s3c2440.h
--- a/arch/arm/mach-s3c2410/s3c2440.h	2004-12-24 13:37:01 -08:00
+++ b/arch/arm/mach-s3c2410/s3c2440.h	2004-12-24 13:37:01 -08:00
@@ -10,9 +10,14 @@
  * published by the Free Software Foundation.
  *
  * Modifications:
- *     24-Aug-2004 BJD  Start of S3C2440 CPU support
+ *	24-Aug-2004 BJD  Start of S3C2440 CPU support
+ *	04-Nov-2004 BJD  Added s3c2440_init_uarts()
 */
 
+struct s3c2410_uartcfg;
+
 extern void s3c2440_init_irq(void);
 
 extern void s3c2440_init_time(void);
+
+extern void s3c2440_init_uarts(struct s3c2410_uartcfg *cfg, int no);
diff -Nru a/arch/arm/mach-s3c2410/sleep.S b/arch/arm/mach-s3c2410/sleep.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-s3c2410/sleep.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,180 @@
+/* linux/arch/arm/mach-s3c2410/sleep.S
+ *
+ * Copyright (c) 2004 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C2410 Power Manager (Suspend-To-RAM) support
+ *
+ * Based on PXA/SA1100 sleep code by:
+ *	Nicolas Pitre, (c) 2002 Monta Vista Software Inc
+ *	Cliff Brake, (c) 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include <linux/config.h>
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <asm/hardware.h>
+#include <asm/arch/map.h>
+
+#include <asm/arch/regs-gpio.h>
+#include <asm/arch/regs-clock.h>
+#include <asm/arch/regs-mem.h>
+#include <asm/arch/regs-serial.h>
+
+/* CONFIG_DEBUG_RESUME is dangerous if your bootloader does not
+ * reset the UART configuration, only enable if you really need this!
+*/
+//#define CONFIG_DEBUG_RESUME
+
+	.text
+
+	/* s3c2410_cpu_suspend
+	 *
+	 * put the cpu into sleep mode
+	 *
+	 * entry:
+	 *	r0 = sleep save block
+	*/
+
+ENTRY(s3c2410_cpu_suspend)
+	stmfd	sp!, { r4 - r12, lr }
+
+	@@ store co-processor registers
+
+	mrc	p15, 0, r4, c15, c1, 0	@ CP access register
+	mrc	p15, 0, r5, c13, c0, 0	@ PID
+	mrc	p15, 0, r6, c3, c0, 0	@ Domain ID
+	mrc	p15, 0, r7, c2, c0, 0	@ translation table base address
+	mrc	p15, 0, r8, c2, c0, 0	@ auxiliary control register
+	mrc	p15, 0, r9, c1, c0, 0	@ control register
+
+	stmia	r0, { r4 - r13 }
+
+	@@ flush the caches to ensure everything is back out to
+	@@ SDRAM before the core powers down
+
+	bl	arm920_flush_kern_cache_all
+
+	@@ prepare cpu to sleep
+
+	ldr	r4, =S3C2410_REFRESH
+	ldr	r5, =S3C2410_MISCCR
+	ldr	r6, =S3C2410_CLKCON
+	ldr	r7, [ r4 ]		@ get REFRESH (and ensure in TLB)
+	ldr	r8, [ r5 ]		@ get MISCCR (and ensure in TLB)
+	ldr	r9, [ r6 ]		@ get CLKCON (and ensure in TLB)
+
+	orr	r7, r7, #S3C2410_REFRESH_SELF	@ SDRAM sleep command
+	orr	r8, r8, #S3C2410_MISCCR_SDSLEEP @ SDRAM power-down signals
+	orr	r9, r9, #S3C2410_CLKCON_POWER	@ power down command
+
+	teq	pc, #0			@ first as a trial-run to load cache
+	bl	s3c2410_do_sleep
+	teq	r0, r0			@ now do it for real
+	b	s3c2410_do_sleep	@
+
+	@@ align next bit of code to cache line
+	.align	8
+s3c2410_do_sleep:
+	streq	r7, [ r4 ]			@ SDRAM sleep command
+	streq	r8, [ r5 ]			@ SDRAM power-down config
+	streq	r9, [ r6 ]			@ CPU sleep
+1:	beq	1b
+	mov	pc, r14
+
+	@@ return to the caller, after having the MMU
+	@@ turned on, this restores the last bits from the
+	@@ stack
+resume_with_mmu:
+	ldmfd	sp!, { r4 - r12, pc }
+
+	.ltorg
+
+	@@ the next bits sit in the .data segment, even though they
+	@@ happen to be code... the s3c2410_sleep_save_phys needs to be
+	@@ accessed by the resume code before it can restore the MMU.
+	@@ This means that the variable has to be close enough for the
+	@@ code to read it... since the .text segment needs to be RO,
+	@@ the data segment can be the only place to put this code.
+
+	.data
+
+	.global	s3c2410_sleep_save_phys
+s3c2410_sleep_save_phys:
+	.word	0
+
+	/* s3c2410_cpu_resume
+	 *
+	 * resume code entry for bootloader to call
+	 *
+	 * we must put this code here in the data segment as we have no
+	 * other way of restoring the stack pointer after sleep, and we
+	 * must not write to the code segment (code is read-only)
+	*/
+
+ENTRY(s3c2410_cpu_resume)
+	mov	r0, #PSR_I_BIT | PSR_F_BIT | MODE_SVC
+	msr	cpsr_c, r0
+
+	@@ load UART to allow us to print the two characters for
+	@@ resume debug
+
+	mov	r2, #S3C2410_PA_UART & 0xff000000
+	orr	r2, r2, #S3C2410_PA_UART & 0xff000
+
+#if 0
+	/* SMDK2440 LED set */
+	mov	r14, #S3C2410_PA_GPIO
+	ldr	r12, [ r14, #0x54 ]
+	bic	r12, r12, #3<<4
+	orr	r12, r12, #1<<7
+	str	r12, [ r14, #0x54 ]
+#endif
+
+#ifdef CONFIG_DEBUG_RESUME
+	mov	r3, #'L'
+	strb	r3, [ r2, #S3C2410_UTXH ]
+1001:
+	ldrb	r14, [ r3, #S3C2410_UTRSTAT ]
+	tst	r14, #S3C2410_UTRSTAT_TXE
+	beq	1001b
+#endif /* CONFIG_DEBUG_RESUME */
+
+	mov	r1, #0
+	mcr	p15, 0, r1, c8, c7, 0		@@ invalidate I & D TLBs
+	mcr	p15, 0, r1, c7, c7, 0		@@ invalidate I & D caches
+
+	ldr	r0, s3c2410_sleep_save_phys	@ address of restore block
+	ldmia	r0, { r4 - r13 }
+
+	mcr	p15, 0, r4, c15, c1, 0		@ CP access register
+	mcr	p15, 0, r5, c13, c0, 0		@ PID
+	mcr	p15, 0, r6, c3, c0, 0		@ Domain ID
+	mcr	p15, 0, r7, c2, c0, 0		@ translation table base
+	mcr	p15, 0, r8, c1, c1, 0		@ auxilliary control
+
+#ifdef CONFIG_DEBUG_RESUME
+	mov	r3, #'R'
+	strb	r3, [ r2, #S3C2410_UTXH ]
+#endif
+
+	ldr	r2, =resume_with_mmu
+	mcr	p15, 0, r9, c1, c0, 0		@ turn on MMU, etc
+	nop					@ second-to-last before mmu
+	mov	pc, r2				@ go back to virtual address
+
+	.ltorg
diff -Nru a/arch/arm/mach-s3c2410/time.c b/arch/arm/mach-s3c2410/time.c
--- a/arch/arm/mach-s3c2410/time.c	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/mach-s3c2410/time.c	2004-12-24 13:36:47 -08:00
@@ -1,7 +1,7 @@
-/* linux/include/asm-arm/arch-s3c2410/time.h
+/* linux/arch/arm/mach-s3c2410/time.c
  *
- *  Copyright (C) 2003 Simtec Electronics <linux@simtec.co.uk>
- *    Ben Dooks, <ben@simtec.co.uk>
+ * Copyright (C) 2003,2004 Simtec Electronics
+ *	Ben Dooks, <ben@simtec.co.uk>
  *
  * 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
@@ -34,13 +34,52 @@
 #include <asm/arch/regs-irq.h>
 #include <asm/mach/time.h>
 
+#include "clock.h"
+
 static unsigned long timer_startval;
-static unsigned long timer_ticks_usec;
+static unsigned long timer_usec_ticks;
 
+#define TIMER_USEC_SHIFT 16
 
-/* with an 12MHz clock, we get 12 ticks per-usec
- */
+/* we use the shifted arithmetic to work out the ratio of timer ticks
+ * to usecs, as often the peripheral clock is not a nice even multiple
+ * of 1MHz.
+ *
+ * shift of 14 and 15 are too low for the 12MHz, 16 seems to be ok
+ * for the current HZ value of 200 without producing overflows.
+ *
+ * Original patch by Dimitry Andric, updated by Ben Dooks
+*/
+
+
+/* timer_mask_usec_ticks
+ *
+ * given a clock and divisor, make the value to pass into timer_ticks_to_usec
+ * to scale the ticks into usecs
+*/
+
+static inline unsigned long
+timer_mask_usec_ticks(unsigned long scaler, unsigned long pclk)
+{
+	unsigned long den = pclk / 1000;
 
+	return ((1000 << TIMER_USEC_SHIFT) * scaler + (den >> 1)) / den;
+}
+
+/* timer_ticks_to_usec
+ *
+ * convert timer ticks to usec.
+*/
+
+static inline unsigned long timer_ticks_to_usec(unsigned long ticks)
+{
+	unsigned long res;
+
+	res = ticks * timer_usec_ticks;
+	res += 1 << (TIMER_USEC_SHIFT - 4);	/* round up slightly */
+
+	return res >> TIMER_USEC_SHIFT;
+}
 
 /***
  * Returns microsecond  since last clock interrupt.  Note that interrupts
@@ -53,31 +92,31 @@
 static unsigned long s3c2410_gettimeoffset (void)
 {
 	unsigned long tdone;
-	unsigned long usec;
 	unsigned long irqpend;
+	unsigned long tval;
 
 	/* work out how many ticks have gone since last timer interrupt */
 
-	tdone = timer_startval - __raw_readl(S3C2410_TCNTO(4));
+        tval =  __raw_readl(S3C2410_TCNTO(4));
+	tdone = timer_startval - tval;
 
 	/* check to see if there is an interrupt pending */
 
 	irqpend = __raw_readl(S3C2410_SRCPND);
 	if (irqpend & SRCPND_TIMER4) {
 		/* re-read the timer, and try and fix up for the missed
-		 * interrupt */
+		 * interrupt. Note, the interrupt may go off before the
+		 * timer has re-loaded from wrapping.
+		 */
 
-		tdone = timer_startval - __raw_readl(S3C2410_TCNTO(4));
-		tdone += 1<<16;
-	}
-
-	/* currently, tcnt is in 12MHz units, but this may change
-	 * for non-bast machines...
-	 */
+		tval =  __raw_readl(S3C2410_TCNTO(4));
+		tdone = timer_startval - tval;
 
-	usec = tdone / timer_ticks_usec;
+		if (tval != 0)
+			tdone += timer_startval;
+	}
 
-	return usec;
+	return timer_ticks_to_usec(tdone);
 }
 
 
@@ -87,13 +126,14 @@
 static irqreturn_t
 s3c2410_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
 	timer_tick(regs);
-
+	write_sequnlock(&xtime_lock);
 	return IRQ_HANDLED;
 }
 
 static struct irqaction s3c2410_timer_irq = {
-	.name		= "S32410 Timer Tick",
+	.name		= "S3C2410 Timer Tick",
 	.flags		= SA_INTERRUPT,
 	.handler	= s3c2410_timer_interrupt
 };
@@ -104,15 +144,13 @@
  * Currently we only use timer4, as it is the only timer which has no
  * other function that can be exploited externally
  */
-void __init s3c2410_init_time (void)
+static void s3c2410_timer_setup (void)
 {
 	unsigned long tcon;
 	unsigned long tcnt;
 	unsigned long tcfg1;
 	unsigned long tcfg0;
 
-	gettimeoffset = s3c2410_gettimeoffset;
-
 	tcnt = 0xffff;  /* default value for tcnt */
 
 	/* read the current timer configuration bits */
@@ -124,23 +162,25 @@
 	/* configure the system for whichever machine is in use */
 
 	if (machine_is_bast() || machine_is_vr1000()) {
-		timer_ticks_usec = 12;	      /* timer is at 12MHz */
-		tcnt = (timer_ticks_usec * (1000*1000)) / HZ;
-	}
+		/* timer is at 12MHz, scaler is 1 */
+		timer_usec_ticks = timer_mask_usec_ticks(1, 12000000);
+		tcnt = 12000000 / HZ;
+
+		tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK;
+		tcfg1 |= S3C2410_TCFG1_MUX4_TCLK1;
+	} else {
+		/* for the h1940 (and others), we use the pclk from the core
+		 * to generate the timer values. since values around 50 to
+		 * 70MHz are not values we can directly generate the timer
+		 * value from, we need to pre-scale and divide before using it.
+		 *
+		 * for instance, using 50.7MHz and dividing by 6 gives 8.45MHz
+		 * (8.45 ticks per usec)
+		 */
+
+		/* this is used as default if no other timer can be found */
 
-	/* for the h1940, we use the pclk from the core to generate
-	 * the timer values. since 67.5MHz is not a value we can directly
-	 * generate the timer value from, we need to pre-scale and
-	 * divied before using it.
-	 *
-	 * overall divsior to get 200Hz is 337500
-	 *   we can fit tcnt if we pre-scale by 6, producing a tick rate
-	 *   of 11.25MHz, and a tcnt of 56250.
-	 */
-
-	if (machine_is_h1940() || machine_is_smdk2410() ) {
-		timer_ticks_usec = s3c2410_pclk / (1000*1000);
-		timer_ticks_usec /= 6;
+		timer_usec_ticks = timer_mask_usec_ticks(6, s3c24xx_pclk);
 
 		tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK;
 		tcfg1 |= S3C2410_TCFG1_MUX4_DIV2;
@@ -148,12 +188,15 @@
 		tcfg0 &= ~S3C2410_TCFG_PRESCALER1_MASK;
 		tcfg0 |= ((6 - 1) / 2) << S3C2410_TCFG_PRESCALER1_SHIFT;
 
-		tcnt = (s3c2410_pclk / 6) / HZ;
+		tcnt = (s3c24xx_pclk / 6) / HZ;
 	}
 
+	/* timers reload after counting zero, so reduce the count by 1 */
 
-	printk("setup_timer tcon=%08lx, tcnt %04lx, tcfg %08lx,%08lx\n",
-	       tcon, tcnt, tcfg0, tcfg1);
+	tcnt--;
+
+	printk("timer tcon=%08lx, tcnt %04lx, tcfg %08lx,%08lx, usec %08lx\n",
+	       tcon, tcnt, tcfg0, tcfg1, timer_usec_ticks);
 
 	/* check to see if timer is within 16bit range... */
 	if (tcnt > 0xffff) {
@@ -177,13 +220,20 @@
 	__raw_writel(tcnt, S3C2410_TCNTB(4));
 	__raw_writel(tcnt, S3C2410_TCMPB(4));
 
-	setup_irq(IRQ_TIMER4, &s3c2410_timer_irq);
-
 	/* start the timer running */
 	tcon |= S3C2410_TCON_T4START;
 	tcon &= ~S3C2410_TCON_T4MANUALUPD;
 	__raw_writel(tcon, S3C2410_TCON);
 }
 
+static void __init s3c2410_timer_init (void)
+{
+	s3c2410_timer_setup();
+	setup_irq(IRQ_TIMER4, &s3c2410_timer_irq);
+}
 
-
+struct sys_timer s3c2410_timer = {
+	.init		= s3c2410_timer_init,
+	.offset		= s3c2410_gettimeoffset,
+	.resume		= s3c2410_timer_setup
+};
diff -Nru a/arch/arm/mach-s3c2410/usb-simtec.c b/arch/arm/mach-s3c2410/usb-simtec.c
--- a/arch/arm/mach-s3c2410/usb-simtec.c	2004-12-24 13:37:01 -08:00
+++ b/arch/arm/mach-s3c2410/usb-simtec.c	2004-12-24 13:37:01 -08:00
@@ -13,6 +13,7 @@
  *
  * Modifications:
  *	14-Sep-2004 BJD  Created
+ *	18-Oct-2004 BJD  Cleanups, and added code to report OC cleared
 */
 
 #define DEBUG
@@ -51,10 +52,8 @@
 {
 	pr_debug("usb_simtec_powercontrol(%d,%d)\n", port, to);
 
-	if (port == 1) {
+	if (port == 1)
 		s3c2410_gpio_setpin(S3C2410_GPB4, to ? 0:1);
-		pr_debug("GPBDAT now %08x\n", __raw_readl(S3C2410_GPBDAT));
-	}
 }
 
 static irqreturn_t
@@ -67,6 +66,7 @@
 		s3c2410_report_oc(info, 3);
 	} else {
 		pr_debug("usb_simtec: over-current irq (oc cleared)\n");
+		s3c2410_report_oc(info, 0);
 	}
 
 	return IRQ_HANDLED;
@@ -77,16 +77,15 @@
 	int ret;
 
 	if (on) {
-		pr_debug("claiming usb overccurent\n");
 		ret = request_irq(IRQ_USBOC, usb_simtec_ocirq, SA_INTERRUPT,
-				  "usb-oc", info);
+				  "USB Over-current", info);
 		if (ret != 0) {
 			printk(KERN_ERR "failed to request usb oc irq\n");
 		}
 
 		set_irq_type(IRQ_USBOC, IRQT_BOTHEDGE);
 	} else {
-		free_irq(IRQ_USBOC, NULL);
+		free_irq(IRQ_USBOC, info);
 	}
 }
 
@@ -110,14 +109,5 @@
 
 	s3c2410_gpio_cfgpin(S3C2410_GPB4, S3C2410_GPB4_OUTP);
 	s3c2410_gpio_setpin(S3C2410_GPB4, 1);
-
-	pr_debug("GPB: CON=%08x, DAT=%08x\n",
-		 __raw_readl(S3C2410_GPBCON), __raw_readl(S3C2410_GPBDAT));
-
-	if (0) {
-		s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST,
-				      S3C2410_MISCCR_USBDEV);
-	}
-
 	return 0;
 }
diff -Nru a/arch/arm/mach-sa1100/Kconfig b/arch/arm/mach-sa1100/Kconfig
--- a/arch/arm/mach-sa1100/Kconfig	2004-12-24 13:37:34 -08:00
+++ b/arch/arm/mach-sa1100/Kconfig	2004-12-24 13:37:34 -08:00
@@ -16,21 +16,6 @@
 	  Microprocessor Development Board (Assabet)  with the SA-1111
 	  Development Board (Nepon).
 
-config SA1100_ADSBITSY
-	bool "ADS Bitsy"
-	help
-	  Say Y here if you are using Applied Data Systems Intel(R)
-	  StrongARM(R) 1110 based Bitsy, 3 x 5 inches in size, Compaq - IPAQ -
-	  like platform. See
-	  <http://www.applieddata.net/products_bitsySpec.asp> for more
-	  information.
-
-config SA1100_BRUTUS
-	bool "Brutus"
-	help
-	  Say Y here if you are using the Intel(R) StrongARM(R) SA-1100
-	  Microprocessor Development Board (also known as the Brutus).
-
 config SA1100_CERF
 	bool "CerfBoard"
 	help
@@ -98,44 +83,6 @@
 	depends on SA1100_H3100 || SA1100_H3600 || SA1100_H3800
 	default y
 
-#dep_bool '  Consus' CONFIG_SA1100_CONSUS $CONFIG_ARCH_SA1100
-#dep_bool '  Empeg' CONFIG_SA1100_EMPEG $CONFIG_ARCH_SA1100
-config SA1100_EXTENEX1
-	bool "Extenex HandHeld Theater (Squashtail)"
-
-config SA1100_EXTENEX1_16MB
-	bool "Support 16 MB of DRAM (not just 8)"
-	depends on SA1100_EXTENEX1
-
-config SA1100_FLEXANET
-	bool "FlexaNet"
-	help
-	  Say Y here if you intend to run this kernel on the FlexaNet
-	  handheld instruments. Information about this machine can be
-	  found at: <http://www.flexanet.com/>.
-
-config SA1100_FREEBIRD
-	bool "FreeBird-v1.1"
-	help
-	  Support the FreeBird board used in Coventive embedded products.  See
-	  Documentation/arm/SA1100/Freebird for more.
-
-config SA1100_GRAPHICSCLIENT
-	bool "GraphicsClient Plus"
-	help
-	  Say Y here if you are using an Applied Data Systems Intel(R)
-	  StrongARM(R) SA-1100 based Graphics Client SBC.  See
-	  <http://www.flatpanels.com/> for information on this system.
-
-config SA1100_GRAPHICSMASTER
-	bool "GraphicsMaster"
-	help
-	  Say Y here if you are using an Applied Data Systems Intel(R)
-	  StrongARM(R) SA-1100 based Graphics Master SBC with SA-1111
-	  StrongARM companion chip.  See
-	  <http://www.applieddata.net/products_masterSpec.asp> for information
-	  on this system.
-
 config SA1100_BADGE4
 	bool "HP Labs BadgePAD 4"
 	help
@@ -155,21 +102,6 @@
 	  Say Y here to support the HackKit Core CPU Board
 	  <http://hackkit.eletztrick.de>;
 
-config SA1100_HUW_WEBPANEL
-	bool "HuW WebPanel"
-	help
-	  Say Y here to support the HuW Webpanel produced by Hoeft & Wessel
-	  AG.  English-language website is at
-	  <http://www.hoeft-wessel.de/en.htm>; credits and build instructions
-	  at Documentation/arm/SA1100/HUW_WEBPANEL.
-
-config SA1100_ITSY
-	bool "Itsy"
-	help
-	  Say Y here if you are using the Compaq Itsy experimental pocket
-	  computer. See <http://research.compaq.com/wrl/projects/itsy/> for
-	  more information.
-
 config SA1100_LART
 	bool "LART"
 	help
@@ -177,47 +109,14 @@
 	  (also known as the LART).  See <http://www.lart.tudelft.nl/> for
 	  information on the LART.
 
-config SA1100_NANOENGINE
-	bool "nanoEngine"
-	help
-	  The nanoEngine is a StrongARM 1110-based single board computer
-	  from Bright Star Engineering. More information is available at:
-	  <http://www.brightstareng.com/arm/nanoeng.htm>.
-
-	  Say Y if configuring for a nanoEngine.
-	  Say N otherwise.
-
-config SA1100_OMNIMETER
-	bool "OmniMeter"
-	help
-	  Say Y here if you are using the inhand electronics OmniMeter.  See
-	  <http://www.inhandelectronics.com/omnimeter.asp> for details.
-
-config SA1100_PANGOLIN
-	bool "Pangolin"
-	help
-	  Pangolin is a StrongARM 1110-based evaluation platform produced
-	  by Dialogue Technology.  It has EISA slots for ease of configuration
-	  with SDRAM/Flash memory card, USB/Serial/Audio card, Compact Flash
-	  card, and TFT-LCD card.
-
-	  Say Y if configuring for a Pangolin.
-	  Say N otherwise.
-
 config SA1100_PLEB
 	bool "PLEB"
 	help
-	  Say Y here if you are using a Portable Linux Embedded Board
-	  (also known as PLEB). See <http://www.cse.unsw.edu.au/~pleb/>
+	  Say Y here if you are using version 1 of the Portable Linux
+	  Embedded Board (also known as PLEB).
+	  See <http://www.disy.cse.unsw.edu.au/Hardware/PLEB/>
 	  for more information.
 
-config SA1100_PT_SYSTEM3
-	bool "PT System 3"
-	help
-	  Say Y here if you intend to build a kernel suitable to run on
-	  a Pruftechnik Digital Board. For more information see
-	  <http://www.pruftechnik.com/>
-
 config SA1100_SHANNON
 	bool "Shannon"
 	help
@@ -226,15 +125,6 @@
 	  platform with a 640x480 LCD, touchscreen, CIR keyboard, PCMCIA slots,
 	  and a telco interface.
 
-config SA1100_SHERMAN
-	bool "Sherman"
-	help
-	  Say Y here to support the Blazie Engineering `Sherman' StrongARM
-	  1110-based SBC, used primarily in assistance products for the
-	  visually impaired.  The company is now Freedom Scientific, with
-	  a website at <http://www.freedomscientific.com/>. The Sherman
-	  product, however, appears to have been discontinued.
-
 config SA1100_SIMPAD
 	bool "Simpad"
 	help
@@ -245,53 +135,6 @@
 	  like CL4 in additional it has a PCMCIA-Slot. For more information
 	  visit <http://www.my-siemens.com/> or <http://www.siemens.ch/>.
 
-config SA1100_PFS168
-	bool "Tulsa"
-	help
-	  The Radisys Corp. PFS-168 (aka Tulsa) is an Intel® StrongArm® SA-1110 based
-	  computer which includes the SA-1111 Microprocessor Companion Chip and other
-	  custom I/O designed to add connectivity and multimedia features for vending
-	  and business machine applications. Say Y here if you require support for
-	  this target.
-
-config SA1100_VICTOR
-	bool "Victor"
-	help
-	  Say Y here if you are using a Visu Aide Intel(R) StrongARM(R)
-	  SA-1100 based Victor Digital Talking Book Reader.  See
-	  <http://www.visuaide.com/products.html> for information on
-	  this system.
-
-config SA1100_XP860
-	bool "XP860"
-	help
-	  :: Config help missing ::
-	  :: 06 August 2002 ::
-
-config SA1100_YOPY
-	bool "Yopy"
-	help
-	  Say Y here to support the Yopy PDA.  Product information at
-	  <http://www.yopy.com/>.  See Documentation/arm/SA1100/Yopy
-	  for more.
-
-config SA1100_STORK
-	bool "Stork"
-	help
-	  Say Y here if you intend to run this kernel on the Stork
-	  handheld computer.
-
-#config SA1100_TRIZEPS
-#	bool "Trizeps"
-#	help
-#	  :: write me ::
-
-#config TRIZEPS_MFTB2
-#	bool "MFTB2"
-#	depends on SA1100_TRIZEPS
-#	help
-#	  :: write me ::
-
 config SA1100_SSP
 	tristate "Generic PIO SSP"
 	help
@@ -299,17 +142,6 @@
 	  This isn't for audio support, but for attached sensors and
 	  other devices, eg for BadgePAD 4 sensor support, or Jornada
 	  720 touchscreen support.
-
-config SA1100_USB
-	tristate "SA1100 USB function support"
-
-config SA1100_USB_NETLINK
-	tristate "Support for SA11x0 USB network link function"
-	depends on SA1100_USB
-
-config SA1100_USB_CHAR
-	tristate "Support for SA11x0 USB character device emulation"
-	depends on SA1100_USB
 
 config H3600_SLEEVE
 	tristate "Compaq iPAQ Handheld sleeve support"
diff -Nru a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile
--- a/arch/arm/mach-sa1100/Makefile	2004-12-24 13:37:33 -08:00
+++ b/arch/arm/mach-sa1100/Makefile	2004-12-24 13:37:33 -08:00
@@ -13,9 +13,6 @@
 obj-$(CONFIG_CPU_FREQ_SA1110)		+= cpu-sa1110.o
 
 # Specific board support
-obj-$(CONFIG_SA1100_ADSBITSY)		+= adsbitsy.o
-led-$(CONFIG_SA1100_ADSBITSY)		+= leds-adsbitsy.o
-
 obj-$(CONFIG_SA1100_ASSABET)		+= assabet.o
 led-$(CONFIG_SA1100_ASSABET)		+= leds-assabet.o
 obj-$(CONFIG_ASSABET_NEPONSET)		+= neponset.o
@@ -23,68 +20,27 @@
 obj-$(CONFIG_SA1100_BADGE4)		+= badge4.o
 led-$(CONFIG_SA1100_BADGE4)		+= leds-badge4.o
 
-obj-$(CONFIG_SA1100_BRUTUS)		+= brutus.o
-led-$(CONFIG_SA1100_BRUTUS)		+= leds-brutus.o
-
 obj-$(CONFIG_SA1100_CERF)		+= cerf.o
 led-$(CONFIG_SA1100_CERF)		+= leds-cerf.o
 
 obj-$(CONFIG_SA1100_COLLIE)		+= collie.o
 
-obj-$(CONFIG_SA1100_EMPEG)		+= empeg.o
-
-obj-$(CONFIG_SA1100_FLEXANET)		+= flexanet.o
-led-$(CONFIG_SA1100_FLEXANET)		+= leds-flexanet.o
-
-obj-$(CONFIG_SA1100_FREEBIRD)		+= freebird.o
-obj-$(CONFIG_SA1100_GRAPHICSCLIENT)	+= graphicsclient.o
-led-$(CONFIG_SA1100_GRAPHICSCLIENT)	+= leds-graphicsclient.o
-
-obj-$(CONFIG_SA1100_GRAPHICSMASTER)	+= graphicsmaster.o
-led-$(CONFIG_SA1100_GRAPHICSMASTER)	+= leds-graphicsmaster.o
-
 obj-$(CONFIG_SA1100_H3600)		+= h3600.o
 
 obj-$(CONFIG_SA1100_HACKKIT)		+= hackkit.o
 led-$(CONFIG_SA1100_HACKKIT)		+= leds-hackkit.o
 
-obj-$(CONFIG_SA1100_HUW_WEBPANEL)	+= huw_webpanel.o
-
-obj-$(CONFIG_SA1100_ITSY)		+= itsy.o
-
 obj-$(CONFIG_SA1100_JORNADA720)		+= jornada720.o
 
 obj-$(CONFIG_SA1100_LART)		+= lart.o
 led-$(CONFIG_SA1100_LART)		+= leds-lart.o
 
-obj-$(CONFIG_SA1100_NANOENGINE)		+= nanoengine.o
-
-obj-$(CONFIG_SA1100_OMNIMETER)		+= omnimeter.o
-
-obj-$(CONFIG_SA1100_PANGOLIN)		+= pangolin.o
-
-obj-$(CONFIG_SA1100_PFS168)		+= pfs168.o
-led-$(CONFIG_SA1100_PFS168)		+= leds-pfs168.o
-
 obj-$(CONFIG_SA1100_PLEB)		+= pleb.o
 
-obj-$(CONFIG_SA1100_PT_SYSTEM3)		+= system3.o
-led-$(CONFIG_SA1100_PT_SYSTEM3)		+= leds-system3.o
-
 obj-$(CONFIG_SA1100_SHANNON)		+= shannon.o
 
-obj-$(CONFIG_SA1100_SHERMAN)		+= sherman.o
-
 obj-$(CONFIG_SA1100_SIMPAD)		+= simpad.o
-led-$(CONFIG_SA1100_SIMPAD)		+= leds-simpad.o  
-
-obj-$(CONFIG_SA1100_STORK)		+= stork.o
-
-obj-$(CONFIG_SA1100_TRIZEPS)		+= trizeps.o
-
-obj-$(CONFIG_SA1100_XP860)		+= xp860.o
-
-obj-$(CONFIG_SA1100_YOPY)		+= yopy.o
+led-$(CONFIG_SA1100_SIMPAD)		+= leds-simpad.o
 
 # LEDs support
 obj-$(CONFIG_LEDS) += $(led-y)
diff -Nru a/arch/arm/mach-sa1100/Makefile.boot b/arch/arm/mach-sa1100/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-sa1100/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,7 @@
+   zreladdr-y	:= 0xc0008000
+ifeq ($(CONFIG_ARCH_SA1100),y)
+   zreladdr-$(CONFIG_SA1111)		:= 0xc0208000
+endif
+params_phys-y	:= 0xc0000100
+initrd_phys-y	:= 0xc0800000
+
diff -Nru a/arch/arm/mach-sa1100/adsbitsy.c b/arch/arm/mach-sa1100/adsbitsy.c
--- a/arch/arm/mach-sa1100/adsbitsy.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,151 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/adsbitsy.c
- *
- * Author: Woojung Huh
- *
- * Pieces specific to the ADS Bitsy
- *
- * 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/kernel.h>
-#include <linux/init.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-#include <linux/serial_core.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/setup.h>
-#include <asm/irq.h>
-
-#include <asm/mach/irq.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static struct resource sa1111_resources[] = {
-	[0] = {
-		.start		= 0x18000000,
-		.end		= 0x18001fff,
-		.flags		= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start		= IRQ_GPIO0,
-		.end		= IRQ_GPIO0,
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-
-static u64 sa1111_dmamask = 0xffffffffUL;
-
-static struct platform_device sa1111_device = {
-	.name		= "sa1111",
-	.id		= 0,
-	.dev		= {
-		.dma_mask = &sa1111_dmamask,
-		.coherent_dma_mask = 0xffffffff,
-	},
-	.num_resources	= ARRAY_SIZE(sa1111_resources),
-	.resource	= sa1111_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-	&sa1111_device,
-};
-
-static int __init adsbitsy_init(void)
-{
-	int ret;
-
-	if (!machine_is_adsbitsy())
-		return -ENODEV;
-
-	/*
-	 * Ensure that the memory bus request/grant signals are setup,
-	 * and the grant is held in its inactive state
-	 */
-	sa1110_mb_disable();
-
-	/*
-	 * Reset SA1111
-	 */
-	GPCR |= GPIO_GPIO26;
-	udelay(1000);
-	GPSR |= GPIO_GPIO26;
-
-	/*
-	 * Probe for SA1111.
-	 */
-	ret = platform_add_devices(devices, ARRAY_SIZE(devices));
-	if (ret < 0)
-		return ret;
-
-	/*
-	 * Enable PWM control for LCD
-	 */
-	sa1111_enable_device(SKPCR_PWMCLKEN);
-	SKPWM0 = 0x7F;				// VEE
-	SKPEN0 = 1;
-	SKPWM1 = 0x01;				// Backlight
-	SKPEN1 = 1;
-
-	return 0;
-}
-
-arch_initcall(adsbitsy_init);
-
-static void __init adsbitsy_init_irq(void)
-{
-	/* First the standard SA1100 IRQs */
-	sa1100_init_irq();
-}
-
-static struct map_desc adsbitsy_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf4000000, 0x18000000, 0x00800000, MT_DEVICE }  /* SA1111 */
-};
-
-static int adsbitsy_uart_open(struct uart_port *port, struct uart_info *info)
-{
-	if (port->mapbase == _Ser1UTCR0) {
-		Ser1SDCR0 |= SDCR0_UART;
-#error Fixme	// Set RTS High (should be done in the set_mctrl fn)
-		GPCR = GPIO_GPIO15;
-	} else if (port->mapbase == _Ser2UTCR0) {
-		Ser2UTCR4 = Ser2HSCR0 = 0;
-#error Fixme	// Set RTS High (should be done in the set_mctrl fn)
-		GPCR = GPIO_GPIO17;
-	} else if (port->mapbase == _Ser2UTCR0) {
-#error Fixme	// Set RTS High (should be done in the set_mctrl fn)
-		GPCR = GPIO_GPIO19;
-	}
-	return 0;
-}
-
-static struct sa1100_port_fns adsbitsy_port_fns __initdata = {
-	.open	= adsbitsy_uart_open,
-};
-
-static void __init adsbitsy_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(adsbitsy_io_desc, ARRAY_SIZE(adsbitsy_io_desc));
-
-	sa1100_register_uart_fns(&adsbitsy_port_fns);
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-	sa1100_register_uart(2, 2);
-	GPDR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19;
-	GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO16 | GPIO_GPIO18);
-}
-
-MACHINE_START(ADSBITSY, "ADS Bitsy")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(adsbitsy_map_io)
-	INITIRQ(adsbitsy_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
--- a/arch/arm/mach-sa1100/assabet.c	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-sa1100/assabet.c	2004-12-24 13:36:17 -08:00
@@ -9,16 +9,17 @@
  * 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/init.h>
 #include <linux/kernel.h>
-#include <linux/tty.h>
 #include <linux/module.h>
-#include <linux/mm.h>
 #include <linux/errno.h>
+#include <linux/ioport.h>
 #include <linux/serial_core.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 #include <linux/delay.h>
+#include <linux/mm.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -29,6 +30,8 @@
 #include <asm/tlbflush.h>
 
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
+#include <asm/mach/irda.h>
 #include <asm/mach/map.h>
 #include <asm/mach/serial_sa1100.h>
 #include <asm/arch/assabet.h>
@@ -92,6 +95,109 @@
 		ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
 }
 
+
+/*
+ * Assabet flash support code.
+ */
+
+#ifdef ASSABET_REV_4
+/*
+ * Phase 4 Assabet has two 28F160B3 flash parts in bank 0:
+ */
+static struct mtd_partition assabet_partitions[] = {
+	{
+		.name		= "bootloader",
+		.size		= 0x00020000,
+		.offset		= 0,
+		.mask_flags	= MTD_WRITEABLE,
+	}, {
+		.name		= "bootloader params",
+		.size		= 0x00020000,
+		.offset		= MTDPART_OFS_APPEND,
+		.mask_flags	= MTD_WRITEABLE,
+	}, {
+		.name		= "jffs",
+		.size		= MTDPART_SIZ_FULL,
+		.offset		= MTDPART_OFS_APPEND,
+	}
+};
+#else
+/*
+ * Phase 5 Assabet has two 28F128J3A flash parts in bank 0:
+ */
+static struct mtd_partition assabet_partitions[] = {
+	{
+		.name		= "bootloader",
+		.size		= 0x00040000,
+		.offset		= 0,
+		.mask_flags	= MTD_WRITEABLE,
+	}, {
+		.name		= "bootloader params",
+		.size		= 0x00040000,
+		.offset		= MTDPART_OFS_APPEND,
+		.mask_flags	= MTD_WRITEABLE,
+	}, {
+		.name		= "jffs",
+		.size		= MTDPART_SIZ_FULL,
+		.offset		= MTDPART_OFS_APPEND,
+	}
+};
+#endif
+
+static struct flash_platform_data assabet_flash_data = {
+	.map_name	= "cfi_probe",
+	.parts		= assabet_partitions,
+	.nr_parts	= ARRAY_SIZE(assabet_partitions),
+};
+
+static struct resource assabet_flash_resources[] = {
+	{
+		.start	= SA1100_CS0_PHYS,
+		.end	= SA1100_CS0_PHYS + SZ_32M - 1,
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.start	= SA1100_CS1_PHYS,
+		.end	= SA1100_CS1_PHYS + SZ_32M - 1,
+		.flags	= IORESOURCE_MEM,
+	}
+};
+
+
+/*
+ * Assabet IrDA support code.
+ */
+
+static int assabet_irda_set_power(struct device *dev, unsigned int state)
+{
+	static unsigned int bcr_state[4] = {
+		ASSABET_BCR_IRDA_MD0,
+		ASSABET_BCR_IRDA_MD1|ASSABET_BCR_IRDA_MD0,
+		ASSABET_BCR_IRDA_MD1,
+		0
+	};
+
+	if (state < 4) {
+		state = bcr_state[state];
+		ASSABET_BCR_clear(state ^ (ASSABET_BCR_IRDA_MD1|
+					   ASSABET_BCR_IRDA_MD0));
+		ASSABET_BCR_set(state);
+	}
+	return 0;
+}
+
+static void assabet_irda_set_speed(struct device *dev, unsigned int speed)
+{
+	if (speed < 4000000)
+		ASSABET_BCR_clear(ASSABET_BCR_IRDA_FSEL);
+	else
+		ASSABET_BCR_set(ASSABET_BCR_IRDA_FSEL);
+}
+
+static struct irda_platform_data assabet_irda_data = {
+	.set_power	= assabet_irda_set_power,
+	.set_speed	= assabet_irda_set_speed,
+};
+
 static void __init assabet_init(void)
 {
 	/*
@@ -136,6 +242,10 @@
 			"hasn't been configured in the kernel\n" );
 #endif
 	}
+
+	sa11x0_set_flash_data(&assabet_flash_data, assabet_flash_resources,
+			      ARRAY_SIZE(assabet_flash_resources));
+	sa11x0_set_irda_data(&assabet_irda_data);
 }
 
 /*
@@ -324,6 +434,6 @@
 	FIXUP(fixup_assabet)
 	MAPIO(assabet_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-	INIT_MACHINE(assabet_init)
+	.timer		= &sa1100_timer,
+	.init_machine	= assabet_init,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c
--- a/arch/arm/mach-sa1100/badge4.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-sa1100/badge4.c	2004-12-24 13:36:18 -08:00
@@ -19,6 +19,8 @@
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/tty.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 #include <linux/errno.h>
 
 #include <asm/hardware.h>
@@ -27,6 +29,7 @@
 #include <asm/arch/irqs.h>
 
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/hardware/sa1111.h>
 #include <asm/mach/serial_sa1100.h>
@@ -80,6 +83,45 @@
 }
 
 
+/*
+ * 1 x Intel 28F320C3 Advanced+ Boot Block Flash (32 Mi bit)
+ *   Eight 4 KiW Parameter Bottom Blocks (64 KiB)
+ *   Sixty-three 32 KiW Main Blocks (4032 Ki b)
+ *
+ * <or>
+ *
+ * 1 x Intel 28F640C3 Advanced+ Boot Block Flash (64 Mi bit)
+ *   Eight 4 KiW Parameter Bottom Blocks (64 KiB)
+ *   One-hundred-twenty-seven 32 KiW Main Blocks (8128 Ki b)
+ */
+static struct mtd_partition badge4_partitions[] = {
+        {
+                .name           = "BLOB boot loader",
+                .offset         = 0,
+                .size           = 0x0000A000
+        }, {
+                .name           = "params",
+                .offset         = MTDPART_OFS_APPEND,
+                .size           = 0x00006000
+        }, {
+                .name           = "root",
+                .offset         = MTDPART_OFS_APPEND,
+                .size           = MTDPART_SIZ_FULL
+        }
+};
+
+static struct flash_platform_data badge4_flash_data = {
+	.map_name	= "cfi_probe",
+	.parts		= badge4_partitions,
+	.nr_parts	= ARRAY_SIZE(badge4_partitions),
+};
+
+static struct resource badge4_flash_resource = {
+	.start		= SA1100_CS0_PHYS,
+	.end		= SA1100_CS0_PHYS + SZ_64M - 1,
+	.flags		= IORESOURCE_MEM,
+};
+
 static int five_v_on __initdata = 0;
 
 static int __init five_v_on_setup(char *ignore)
@@ -170,6 +212,9 @@
 	/* maybe turn on 5v0 from the start */
 	badge4_set_5V(BADGE4_5V_INITIALLY, five_v_on);
 
+	sa11x0_set_flash_data(badge4_flash_data, badge4_flash_resources,
+			      ARRAY_SIZE(badge4_flash_resources);
+
 	return 0;
 }
 
@@ -245,5 +290,5 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(badge4_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/brutus.c b/arch/arm/mach-sa1100/brutus.c
--- a/arch/arm/mach-sa1100/brutus.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,41 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/brutus.c
- *
- * Author: Nicolas Pitre
- *
- * 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/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static void __init brutus_map_io(void)
-{
-	sa1100_map_io();
-
-	sa1100_register_uart(0, 1);
-	sa1100_register_uart(1, 3);
-	GAFR |= (GPIO_UART_TXD | GPIO_UART_RXD);
-	GPDR |= GPIO_UART_TXD;
-	GPDR &= ~GPIO_UART_RXD;
-	PPAR |= PPAR_UPR;
-}
-
-MACHINE_START(BRUTUS, "Intel Brutus (SA1100 eval board)")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(brutus_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c
--- a/arch/arm/mach-sa1100/cerf.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-sa1100/cerf.c	2004-12-24 13:36:48 -08:00
@@ -15,6 +15,8 @@
 #include <linux/kernel.h>
 #include <linux/tty.h>
 #include <linux/device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 
 #include <asm/irq.h>
 #include <asm/hardware.h>
@@ -22,6 +24,7 @@
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/serial_sa1100.h>
 
@@ -47,6 +50,48 @@
 	&cerfuart2_device,
 };
 
+#ifdef CONFIG_SA1100_CERF_FLASH_32MB
+#  define CERF_FLASH_SIZE	0x02000000
+#elif defined CONFIG_SA1100_CERF_FLASH_16MB
+#  define CERF_FLASH_SIZE	0x01000000
+#elif defined CONFIG_SA1100_CERF_FLASH_8MB
+#  define CERF_FLASH_SIZE	0x00800000
+#else
+#  error "Undefined flash size for CERF"
+#endif
+
+static struct mtd_partition cerf_partitions[] = {
+	{
+		.name		= "Bootloader",
+		.size		= 0x00020000,
+		.offset		= 0x00000000,
+	}, {
+		.name		= "Params",
+		.size		= 0x00040000,
+		.offset		= 0x00020000,
+	}, {
+		.name		= "Kernel",
+		.size		= 0x00100000,
+		.offset		= 0x00060000,
+	}, {
+		.name		= "Filesystem",
+		.size		= CERF_FLASH_SIZE-0x00160000,
+		.offset		= 0x00160000,
+	}
+};
+
+static struct flash_platform_data cerf_flash_data = {
+	.map_name	= "cfi_probe",
+	.parts		= cerf_partitions,
+	.nr_parts	= ARRAY_SIZE(cerf_partitions),
+};
+
+static struct resource cerf_flash_resource = {
+	.start		= SA1100_CS0_PHYS,
+	.end		= SA1100_CS0_PHYS + SZ_32M - 1,
+	.flags		= IORESOURCE_MEM,
+};
+
 static void __init cerf_init_irq(void)
 {
 	sa1100_init_irq();
@@ -71,26 +116,17 @@
 	GPDR |= CERF_GPIO_CF_RESET;
 }
 
-static int __init cerf_init(void)
+static void __init cerf_init(void)
 {
-	int ret;
-
-	if (!machine_is_cerf())
-		return -ENODEV;
-
-	ret = platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices));
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices));
+	sa11x0_set_flash_data(&cerf_flash_data, &cerf_flash_resource, 1);
 }
 
-arch_initcall(cerf_init);
-
 MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube")
 	MAINTAINER("support@intrinsyc.com")
 	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
 	MAPIO(cerf_map_io)
 	INITIRQ(cerf_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
+	.init_machine	= cerf_init,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
--- a/arch/arm/mach-sa1100/collie.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-sa1100/collie.c	2004-12-24 13:36:48 -08:00
@@ -22,6 +22,8 @@
 #include <linux/tty.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 #include <linux/timer.h>
 
 #include <asm/hardware.h>
@@ -31,6 +33,7 @@
 #include <asm/arch/collie.h>
 
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/serial_sa1100.h>
 
@@ -89,6 +92,48 @@
 	&locomo_device,
 };
 
+static struct mtd_partition collie_partitions[] = {
+	{
+		.name		= "bootloader",
+		.offset 	= 0,
+		.size		= 0x000C0000,
+		.mask_flags	= MTD_WRITEABLE
+	}, {
+		.name		= "kernel",
+		.offset 	= MTDPART_OFS_APPEND,
+		.size		= 0x00100000,
+	}, {
+		.name		= "rootfs",
+		.offset 	= MTDPART_OFS_APPEND,
+		.size		= 0x00e20000,
+	}
+};
+
+static void collie_set_vpp(int vpp)
+{
+	COLLIE_SCP_REG_GPCR |= COLLIE_SCP_VPEN;
+	if (vpp) {
+		COLLIE_SCP_REG_GPWR |= COLLIE_SCP_VPEN;
+	} else {
+		COLLIE_SCP_REG_GPWR &= ~COLLIE_SCP_VPEN;
+	}
+}
+
+static struct flash_platform_data collie_flash_data = {
+	.map_name	= "cfi_probe",
+	.set_vpp	= collie_set_vpp,
+	.parts		= collie_partitions,
+	.nr_parts	= ARRAY_SIZE(collie_partitions),
+};
+
+static struct resource collie_flash_resources[] = {
+	{
+		.start	= SA1100_CS0_PHYS,
+		.end	= SA1100_CS0_PHYS + SZ_32M - 1,
+		.flags	= IORESOURCE_MEM,
+	}
+};
+
 static void __init collie_init(void)
 {
 	int ret = 0;
@@ -121,6 +166,9 @@
 	if (ret) {
 		printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
 	}
+
+	sa11x0_set_flash_data(&collie_flash_data, collie_flash_resources,
+			      ARRAY_SIZE(collie_flash_resources));
 }
 
 static struct map_desc collie_io_desc[] __initdata = {
@@ -140,6 +188,6 @@
 	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
 	MAPIO(collie_map_io)
 	INITIRQ(sa1100_init_irq)
-	INIT_MACHINE(collie_init)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
+	.init_machine	= collie_init,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/empeg.c b/arch/arm/mach-sa1100/empeg.c
--- a/arch/arm/mach-sa1100/empeg.c	2004-12-24 13:37:02 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,39 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/empeg.c
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static struct map_desc empeg_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { EMPEG_FLASHBASE, 0x00000000, 0x00200000, MT_DEVICE } /* Flash */
-};
-
-static void __init empeg_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(empeg_io_desc, ARRAY_SIZE(empeg_io_desc));
-
-	sa1100_register_uart(0, 1);
-	sa1100_register_uart(1, 3);
-	sa1100_register_uart(2, 2);
-	Ser1SDCR0 |= SDCR0_UART;
-}
-
-MACHINE_START(EMPEG, "empeg MP3 Car Audio Player")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(empeg_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/flexanet.c b/arch/arm/mach-sa1100/flexanet.c
--- a/arch/arm/mach-sa1100/flexanet.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,188 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/flexanet.c
- *
- * Author: Jordi Colomer <jco@ict.es>
- *
- * This file contains all FlexaNet-specific tweaks.
- *
- * 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/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-#include <linux/serial_core.h>
-
-#include "generic.h"
-
-
-unsigned long flexanet_BCR = FHH_BCR_POWERUP;
-
-EXPORT_SYMBOL(flexanet_BCR);
-
-/* physical addresses */
-#define _RCNR        0x90010004
-#define _GPLR        0x90040000
-#define _Ser4SSCR0   0x80070060
-
-/*
- * Get the modem-control register of the UARTs
- *
- */
-static int flexanet_get_mctrl(struct uart_port *port)
-{
-	int            stat = 0;
-	unsigned long  bsr;
-
-	/* only DSR and CTS are implemented in UART1 & 3 */
-	if (port->membase == (void *)&Ser1UTCR0)
-	{
-		bsr = FHH_BSR;
-
-		if ((bsr & FHH_BSR_DSR1) != 0)
-			stat |= TIOCM_DSR;
-		if ((bsr & FHH_BSR_CTS1) != 0)
-			stat |= TIOCM_CTS;
-	}
-	else if (port->membase == (void *)&Ser3UTCR0)
-	{
-		bsr = FHH_BSR;
-
-		if ((bsr & FHH_BSR_DSR3) != 0)
-			stat |= TIOCM_DSR;
-		if ((bsr & FHH_BSR_CTS3) != 0)
-			stat |= TIOCM_CTS;
-	}
-
-	return stat;
-}
-
-/*
- * Set the modem-control register of the UARTs
- *
- */
-static void flexanet_set_mctrl(struct uart_port *port, u_int mctrl)
-{
-	unsigned long	flags;
-
-	/* only the RTS signal is implemented in UART1 & 3 */
-	if (port->membase == (void *)&Ser1UTCR0)
-	{
-		local_irq_save(flags);
-
-		if (mctrl & TIOCM_RTS)
-			flexanet_BCR |= FHH_BCR_RTS1;
-		else
-			flexanet_BCR &= ~FHH_BCR_RTS1;
-
-		FHH_BCR = flexanet_BCR;
-		local_irq_restore(flags);
-	}
-	else if (port->membase == (void *)&Ser3UTCR0)
-	{
-		local_irq_save(flags);
-
-		if (mctrl & TIOCM_RTS)
-			flexanet_BCR |= FHH_BCR_RTS3;
-		else
-			flexanet_BCR &= ~FHH_BCR_RTS3;
-
-		FHH_BCR = flexanet_BCR;
-		local_irq_restore(flags);
-	}
-}
-
-/*
- * machine-specific serial port functions
- *
- * get_mctrl : set state of modem control lines
- * set_mctrl : set the modem control lines
- * pm        : power-management. Turn device on/off.
- *
- */
-static struct sa1100_port_fns	flexanet_port_fns __initdata =
-{
-	set_mctrl : flexanet_set_mctrl,
-	get_mctrl : flexanet_get_mctrl,
-	pm        : NULL,
-};
-
-
-/*
- * Initialization and serial port mapping
- *
- */
-
-static int flexanet_serial_init(void)
-{
-	/* register low-level functions */
-	sa1100_register_uart_fns(&flexanet_port_fns);
-
-	/* UART port number mapping */
-	sa1100_register_uart(0, 1); /* RS232 */
-	sa1100_register_uart(1, 3); /* Radio */
-
-	/* Select UART function in Serial port 1 */
-	Ser1SDCR0 |= SDCR0_UART;
-
-	return 0;
-}
-
-
-static struct map_desc flexanet_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x10000000, 0x00001000, MT_DEVICE }, /* Board Control Register */
-  { 0xf1000000, 0x18000000, 0x01000000, MT_DEVICE }, /* Ethernet controller */
-  { 0xD0000000, 0x40000000, 0x01000000, MT_DEVICE }, /* Instrument boards */
-  { 0xD8000000, 0x48000000, 0x01000000, MT_DEVICE }  /* External peripherals */
-};
-
-static void __init flexanet_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(flexanet_io_desc, ARRAY_SIZE(flexanet_io_desc));
-	flexanet_serial_init();
-
-	/* wakeup source is GPIO-0 only */
-	PWER = PWER_GPIO0;
-
-	/* GPIOs set to zero during sleep */
-	PGSR = 0;
-
-	/*
-	 * stop the 3.68 MHz oscillator and float control busses
-	 * during sleep, since peripherals are powered off.
-	 */
-	PCFR = PCFR_OPDE | PCFR_FP | PCFR_FS;
-
-	/* deassert the GUI reset */
-	FLEXANET_BCR_set(FHH_BCR_GUI_NRST);
-
-	/*
-	 * Set IRQ edges
-	 */
-	set_GPIO_IRQ_edge(GPIO_GUI_IRQ, GPIO_RISING_EDGE);
-}
-
-
-MACHINE_START(FLEXANET, "FlexaNet")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	BOOT_PARAMS(0xc0000100)
-	MAPIO(flexanet_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
-
diff -Nru a/arch/arm/mach-sa1100/freebird.c b/arch/arm/mach-sa1100/freebird.c
--- a/arch/arm/mach-sa1100/freebird.c	2004-12-24 13:36:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,81 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/freebird.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-
-unsigned long BCR_value = BCR_DB1110;
-EXPORT_SYMBOL(BCR_value);
-
-static void freebird_backlight_power(int on)
-{
-#error FIXME
-	if (on) {
-		BCR_set(BCR_FREEBIRD_LCD_PWR | BCR_FREEBIRD_LCD_DISP);
-		/* Turn on backlight, Chester */
-		BCR_set(BCR_FREEBIRD_LCD_BACKLIGHT);
-	} else {
-		BCR_clear(BCR_FREEBIRD_LCD_PWR | BCR_FREEBIRD_LCD_DISP
-			  /* | BCR_FREEBIRD_LCD_BACKLIGHT */);
-	}
-}
-
-static void freebird_lcd_power(int on)
-{
-}
-
-static int __init freebird_init(void)
-{
-	if (machine_is_freebird()) {
-		sa1100fb_backlight_power = freebird_backlight_power;
-		sa1100fb_lcd_power = freebird_lcd_power;
-	}
-	return 0;
-}
-
-arch_initcall(freebird_init);
-
-static struct map_desc freebird_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x12000000, 0x00100000, MT_DEVICE }, /* Board Control Register */
-  { 0xf2000000, 0x19000000, 0x00100000, MT_DEVICE }
-};
-
-static void __init freebird_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(freebird_io_desc, ARRAY_SIZE(freebird_io_desc));
-
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-
-	/* Set up sleep mode registers */
-	PWER = 0x1;
-	PGSR = 0x0;
-	PCFR = PCFR_OPDE | PCFR_FP | PCFR_FS;
-}
-
-MACHINE_START(FREEBIRD, "Freebird-HPC-1.1")
-	BOOT_MEM(0xc0000000,0x80000000, 0xf8000000)
-#ifdef CONFIG_SA1100_FREEBIRD_NEW
-	BOOT_PARAMS(0xc0000100)
-#endif
-	MAPIO(freebird_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
--- a/arch/arm/mach-sa1100/generic.c	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/mach-sa1100/generic.c	2004-12-24 13:36:31 -08:00
@@ -161,7 +161,7 @@
 
 static struct platform_device sa11x0udc_device = {
 	.name		= "sa11x0-udc",
-	.id		= 0,
+	.id		= -1,
 	.dev		= {
 		.dma_mask = &sa11x0udc_dma_mask,
 		.coherent_dma_mask = 0xffffffff,
@@ -212,7 +212,7 @@
 
 static struct platform_device sa11x0mcp_device = {
 	.name		= "sa11x0-mcp",
-	.id		= 0,
+	.id		= -1,
 	.dev = {
 		.dma_mask = &sa11x0mcp_dma_mask,
 		.coherent_dma_mask = 0xffffffff,
@@ -233,7 +233,7 @@
 
 static struct platform_device sa11x0ssp_device = {
 	.name		= "sa11x0-ssp",
-	.id		= 0,
+	.id		= -1,
 	.dev = {
 		.dma_mask = &sa11x0ssp_dma_mask,
 		.coherent_dma_mask = 0xffffffff,
@@ -257,7 +257,7 @@
 
 static struct platform_device sa11x0fb_device = {
 	.name		= "sa11x0-fb",
-	.id		= 0,
+	.id		= -1,
 	.dev = {
 		.coherent_dma_mask = 0xffffffff,
 	},
@@ -267,9 +267,54 @@
 
 static struct platform_device sa11x0pcmcia_device = {
 	.name		= "sa11x0-pcmcia",
-	.id		= 0,
+	.id		= -1,
 };
 
+static struct platform_device sa11x0mtd_device = {
+	.name		= "flash",
+	.id		= -1,
+};
+
+void sa11x0_set_flash_data(struct flash_platform_data *flash,
+			   struct resource *res, int nr)
+{
+	sa11x0mtd_device.dev.platform_data = flash;
+	sa11x0mtd_device.resource = res;
+	sa11x0mtd_device.num_resources = nr;
+}
+
+static struct resource sa11x0ir_resources[] = {
+	{
+		.start	= __PREG(Ser2UTCR0),
+		.end	= __PREG(Ser2UTCR0) + 0x24 - 1,
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.start	= __PREG(Ser2HSCR0),
+		.end	= __PREG(Ser2HSCR0) + 0x1c - 1,
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.start	= __PREG(Ser2HSCR2),
+		.end	= __PREG(Ser2HSCR2) + 0x04 - 1,
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.start	= IRQ_Ser2ICP,
+		.end	= IRQ_Ser2ICP,
+		.flags	= IORESOURCE_IRQ,
+	}
+};
+
+static struct platform_device sa11x0ir_device = {
+	.name		= "sa11x0-ir",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(sa11x0ir_resources),
+	.resource	= sa11x0ir_resources,
+};
+
+void sa11x0_set_irda_data(struct irda_platform_data *irda)
+{
+	sa11x0ir_device.dev.platform_data = irda;
+}
+
 static struct platform_device *sa11x0_devices[] __initdata = {
 	&sa11x0udc_device,
 	&sa11x0uart1_device,
@@ -278,11 +323,15 @@
 	&sa11x0ssp_device,
 	&sa11x0pcmcia_device,
 	&sa11x0fb_device,
+	&sa11x0mtd_device,
 };
 
 static int __init sa1100_init(void)
 {
 	pm_power_off = sa1100_power_off;
+
+	if (sa11x0ir_device.dev.platform_data)
+		platform_device_register(&sa11x0ir_device);
 
 	return platform_add_devices(sa11x0_devices, ARRAY_SIZE(sa11x0_devices));
 }
diff -Nru a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
--- a/arch/arm/mach-sa1100/generic.h	2004-12-24 13:37:01 -08:00
+++ b/arch/arm/mach-sa1100/generic.h	2004-12-24 13:37:01 -08:00
@@ -4,9 +4,11 @@
  * Author: Nicolas Pitre
  */
 
+struct sys_timer;
+
+extern struct sys_timer sa1100_timer;
 extern void __init sa1100_map_io(void);
 extern void __init sa1100_init_irq(void);
-extern void __init sa1100_init_time(void);
 
 #define SET_BANK(__nr,__start,__size) \
 	mi->bank[__nr].start = (__start), \
@@ -25,3 +27,12 @@
 extern int sa11x0_verify_speed(struct cpufreq_policy *policy);
 extern unsigned int sa11x0_getspeed(unsigned int cpu);
 extern unsigned int sa11x0_ppcr_to_freq(unsigned int idx);
+
+struct flash_platform_data;
+struct resource;
+
+extern void sa11x0_set_flash_data(struct flash_platform_data *flash,
+				  struct resource *res, int nr);
+
+struct irda_platform_data;
+void sa11x0_set_irda_data(struct irda_platform_data *irda);
diff -Nru a/arch/arm/mach-sa1100/graphicsclient.c b/arch/arm/mach-sa1100/graphicsclient.c
--- a/arch/arm/mach-sa1100/graphicsclient.c	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,202 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/graphicsclient.c
- *
- * Author: Nicolas Pitre
- *
- * Pieces specific to the GraphicsClient board
- *
- * 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/kernel.h>
-#include <linux/init.h>
-#include <linux/ptrace.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-#include <asm/irq.h>
-
-#include <asm/mach/irq.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-#include <linux/serial_core.h>
-
-#include "generic.h"
-
-
-/*
- * Handlers for GraphicsClient's external IRQ logic
- */
-
-static void
-gc_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
-{
-	unsigned int mask;
-
-	while ((mask = ADS_INT_ST1 | (ADS_INT_ST2 << 8))) {
-		/* clear the parent IRQ */
-		GEDR = GPIO_GPIO0;
-
-		irq = ADS_EXT_IRQ(0);
-		desc = irq_desc + irq;
-
-		do {
-			if (mask & 1)
-				desc->handle(irq, desc, regs);
-			mask >>= 1;
-			irq++;
-			desc++;
-		} while (mask);
-	}
-}
-
-static void gc_mask_irq1(unsigned int irq)
-{
-	int mask = (1 << (irq - ADS_EXT_IRQ(0)));
-	ADS_INT_EN1 &= ~mask;
-	ADS_INT_ST1 = mask;
-}
-
-static void gc_unmask_irq1(unsigned int irq)
-{
-	ADS_INT_EN1 |= (1 << (irq - ADS_EXT_IRQ(0)));
-}
-
-static struct irqchip gc_irq1_chip = {
-	.ack	= gc_mask_irq1,
-	.mask	= gc_mask_irq1,
-	.unmask = gc_unmask_irq1,
-};
-
-static void gc_mask_irq2(unsigned int irq)
-{
-	int mask = (1 << (irq - ADS_EXT_IRQ(8)));
-	ADS_INT_EN2 &= ~mask;
-	ADS_INT_ST2 = mask;
-}
-
-static void gc_unmask_irq2(unsigned int irq)
-{
-	ADS_INT_EN2 |= (1 << (irq - ADS_EXT_IRQ(8)));
-}
-
-static struct irqchip gc_irq2_chip = {
-	.ack	= gc_mask_irq2,
-	.mask	= gc_mask_irq2,
-	.unmask = gc_unmask_irq2,
-};
-
-static void __init graphicsclient_init_irq(void)
-{
-	unsigned int irq;
-
-	/* First the standard SA1100 IRQs */
-	sa1100_init_irq();
-
-	/* disable all IRQs */
-	ADS_INT_EN1 = 0;
-	ADS_INT_EN2 = 0;
-
-	/* clear all IRQs */
-	ADS_INT_ST1 = 0xff;
-	ADS_INT_ST2 = 0xff;
-
-	for (irq = ADS_EXT_IRQ(0); irq <= ADS_EXT_IRQ(7); irq++) {
-		set_irq_chip(irq, &gc_irq1_chip);
-		set_irq_handler(irq, do_level_IRQ);
-		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
-	}
-	for (irq = ADS_EXT_IRQ(8); irq <= ADS_EXT_IRQ(15); irq++) {
-		set_irq_chip(irq, &gc_irq2_chip);
-		set_irq_handler(irq, do_level_IRQ);
-		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
-	}
-	set_irq_type(IRQ_GPIO0, IRQT_FALLING);
-	set_irq_chained_handler(IRQ_GPIO0, gc_irq_handler);
-}
-
-
-static struct map_desc graphicsclient_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x10000000, 0x00400000, MT_DEVICE }, /* CPLD */
-  { 0xf1000000, 0x18000000, 0x00400000, MT_DEVICE }  /* CAN */
-};
-
-static u_int graphicsclient_get_mctrl(struct uart_port *port)
-{
-	u_int result = TIOCM_CD | TIOCM_DSR;
-
-	if (port->mapbase == _Ser1UTCR0) {
-		if (!(GPLR & GPIO_GC_UART0_CTS))
-			result |= TIOCM_CTS;
-	} else if (port->mapbase == _Ser2UTCR0) {
-		if (!(GPLR & GPIO_GC_UART1_CTS))
-			result |= TIOCM_CTS;
-	} else if (port->mapbase == _Ser3UTCR0) {
-		if (!(GPLR & GPIO_GC_UART2_CTS))
-			result |= TIOCM_CTS;
-	} else {
-		result = TIOCM_CTS;
-	}
-
-	return result;
-}
-
-static void graphicsclient_set_mctrl(struct uart_port *port, u_int mctrl)
-{
-	if (port->mapbase == _Ser1UTCR0) {
-		if (mctrl & TIOCM_RTS)
-			GPCR = GPIO_GC_UART0_RTS;
-		else
-			GPSR = GPIO_GC_UART0_RTS;
-	} else if (port->mapbase == _Ser2UTCR0) {
-		if (mctrl & TIOCM_RTS)
-			GPCR = GPIO_GC_UART1_RTS;
-		else
-			GPSR = GPIO_GC_UART1_RTS;
-	} else if (port->mapbase == _Ser3UTCR0) {
-		if (mctrl & TIOCM_RTS)
-			GPCR = GPIO_GC_UART2_RTS;
-		else
-			GPSR = GPIO_GC_UART2_RTS;
-	}
-}
-
-static void
-graphicsclient_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
-{
-	if (!state) {
-		/* make serial ports work ... */
-		Ser2UTCR4 = 0;
-		Ser2HSCR0 = 0; 
-		Ser1SDCR0 |= SDCR0_UART;
-	}
-}
-
-static struct sa1100_port_fns graphicsclient_port_fns __initdata = {
-	.get_mctrl	= graphicsclient_get_mctrl,
-	.set_mctrl	= graphicsclient_set_mctrl,
-	.pm		= graphicsclient_uart_pm,
-};
-
-static void __init graphicsclient_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(graphicsclient_io_desc, ARRAY_SIZE(graphicsclient_io_desc));
-
-	sa1100_register_uart_fns(&graphicsclient_port_fns);
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-	sa1100_register_uart(2, 2);
-	GPDR |= GPIO_GC_UART0_RTS | GPIO_GC_UART1_RTS | GPIO_GC_UART2_RTS;
-	GPDR &= ~(GPIO_GC_UART0_CTS | GPIO_GC_UART1_RTS | GPIO_GC_UART2_RTS);
-}
-
-MACHINE_START(GRAPHICSCLIENT, "ADS GraphicsClient")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(graphicsclient_map_io)
-	INITIRQ(graphicsclient_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/graphicsmaster.c b/arch/arm/mach-sa1100/graphicsmaster.c
--- a/arch/arm/mach-sa1100/graphicsmaster.c	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,291 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/graphicsmaster.c
- *
- * Pieces specific to the GraphicsMaster board
- *
- * 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/kernel.h>
-#include <linux/init.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/setup.h>
-#include <asm/irq.h>
-
-#include <asm/mach/irq.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static struct resource sa1111_resources[] = {
-	[0] = {
-		.start		= 0x18000000,
-		.end		= 0x18001fff,
-		.flags		= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start		= ADS_EXT_IRQ(0),
-		.end		= ADS_EXT_IRQ(0),
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-
-static u64 sa1111_dmamask = 0xffffffffUL;
-
-static struct platform_device sa1111_device = {
-	.name		= "sa1111",
-	.id		= 0,
-	.dev		= {
-		.dma_mask = &sa1111_dmamask,
-		.coherent_dma_mask = 0xffffffff,
-	},
-	.num_resources	= ARRAY_SIZE(sa1111_resources),
-	.resource	= sa1111_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-	&sa1111_device,
-};
-
-static int __init graphicsmaster_init(void)
-{
-	int ret;
-
-	if (!machine_is_graphicsmaster())
-		return -ENODEV;
-
-	/*
-	 * Ensure that the memory bus request/grant signals are setup,
-	 * and the grant is held in its inactive state
-	 */
-	sa1110_mb_disable();
-
-	/*
-	 * Probe for SA1111.
-	 */
-	ret = platform_add_devices(devices, ARRAY_SIZE(devices));
-	if (ret < 0)
-		return ret;
-
-	/*
-	 * Enable PWM control for LCD
-	 */
-	sa1111_enable_device(SKPCR_PWMCLKEN);
-	SKPWM0 = 0x7F;				// VEE
-	SKPEN0 = 1;
-	SKPWM1 = 0x01;				// Backlight
-	SKPEN1 = 1;
-
-	return 0;
-}
-
-arch_initcall(graphicsmaster_init);
-
-/*
- * Handlers for GraphicsMaster's external IRQ logic
- */
-
-static void
-gm_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
-{
-	unsigned int mask;
-
-	while ((mask = ADS_INT_ST1 | (ADS_INT_ST2 << 8))) {
-		/* clear the parent IRQ */
-		GEDR = GPIO_GPIO0;
-
-		irq = ADS_EXT_IRQ(0);
-		desc = irq_desc + irq;
-
-		do {
-			if (mask & 1)
-				desc->handle(irq, desc, regs);
-			mask >>= 1;
-			irq++;
-			desc++;
-		} while (mask);
-	}
-}
-
-static void gm_mask_irq1(unsigned int irq)
-{
-	int mask = (1 << (irq - ADS_EXT_IRQ(0)));
-	ADS_INT_EN1 &= ~mask;
-	ADS_INT_ST1 = mask;
-}
-
-static void gm_unmask_irq1(unsigned int irq)
-{
-	ADS_INT_EN1 |= (1 << (irq - ADS_EXT_IRQ(0)));
-}
-
-static struct irqchip gm_irq1_chip = {
-	.ack	= gm_mask_irq1,
-	.mask	= gm_mask_irq1,
-	.unmask = gm_unmask_irq1,
-};
-
-static void gm_mask_irq2(unsigned int irq)
-{
-	int mask = (1 << (irq - ADS_EXT_IRQ(8)));
-	ADS_INT_EN2 &= ~mask;
-	ADS_INT_ST2 = mask;
-}
-
-static void gm_unmask_irq2(unsigned int irq)
-{
-	ADS_INT_EN2 |= (1 << (irq - ADS_EXT_IRQ(8)));
-}
-
-static struct irqchip gm_irq2_chip = {
-	.ack	= gm_mask_irq2,
-	.mask	= gm_mask_irq2,
-	.unmask = gm_unmask_irq2,
-};
-
-static void __init graphicsmaster_init_irq(void)
-{
-	unsigned int irq;
-
-	/* First the standard SA1100 IRQs */
-	sa1100_init_irq();
-
-	/* disable all IRQs */
-	ADS_INT_EN1 = 0;
-	ADS_INT_EN2 = 0;
-
-	/* clear all IRQs */
-	ADS_INT_ST1 = 0xff;
-	ADS_INT_ST2 = 0xff;
-
-	for (irq = ADS_EXT_IRQ(0); irq <= ADS_EXT_IRQ(7); irq++) {
-		set_irq_chip(irq, &gm_irq1_chip);
-		set_irq_handler(irq, do_level_IRQ);
-		set_irq_flags(irq, IRQF_PROBE | IRQF_VALID);
-	}
-	for (irq = ADS_EXT_IRQ(8); irq <= ADS_EXT_IRQ(15); irq++) {
-		set_irq_chip(irq, &gm_irq2_chip);
-		set_irq_handler(irq, do_level_IRQ);
-		set_irq_flags(irq, IRQF_PROBE | IRQF_VALID);
-	}
-	set_irq_type(IRQ_GPIO0, IRQT_FALLING);
-	set_irq_chained_handler(IRQ_GPIO0, gm_irq_handler);
-}
-
-
-static struct map_desc graphicsmaster_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x10000000, 0x00400000, MT_DEVICE }, /* CPLD */
-  { 0xf1000000, 0x40000000, 0x00400000, MT_DEVICE }, /* CAN */
-  { 0xf4000000, 0x18000000, 0x00800000, MT_DEVICE }  /* SA-1111 */
-};
-
-#error Old code.  Someone needs to decide what to do about this.
-#if 0
-static int graphicsmaster_uart_open(struct uart_port *port, struct uart_info *info)
-{
-	int	ret = 0;
-
-	if (port->mapbase == _Ser1UTCR0) {
-		Ser1SDCR0 |= SDCR0_UART;
-		/* Set RTS Output */
-		GPSR = GPIO_GPIO15;
-	}
-	else if (port->mapbase == _Ser2UTCR0) {
-		Ser2UTCR4 = Ser2HSCR0 = 0;
-		/* Set RTS Output */
-		GPSR = GPIO_GPIO17;
-	}
-	else if (port->mapbase == _Ser3UTCR0) {
-	        /* Set RTS Output */
-		GPSR = GPIO_GPIO19;
-	}
-	return ret;
-}
-#endif
-
-static u_int graphicsmaster_get_mctrl(struct uart_port *port)
-{
-	u_int result = TIOCM_CD | TIOCM_DSR;
-
-	if (port->mapbase == _Ser1UTCR0) {
-		if (!(GPLR & GPIO_GPIO14))
-			result |= TIOCM_CTS;
-	} else if (port->mapbase == _Ser2UTCR0) {
-		if (!(GPLR & GPIO_GPIO16))
-			result |= TIOCM_CTS;
-	} else if (port->mapbase == _Ser3UTCR0) {
-		if (!(GPLR & GPIO_GPIO17))
-			result |= TIOCM_CTS;
-	} else {
-		result = TIOCM_CTS;
-	}
-
-	return result;
-}
-
-static void graphicsmaster_set_mctrl(struct uart_port *port, u_int mctrl)
-{
-	if (port->mapbase == _Ser1UTCR0) {
-		if (mctrl & TIOCM_RTS)
-			GPCR = GPIO_GPIO15;
-		else
-			GPSR = GPIO_GPIO15;
-	} else if (port->mapbase == _Ser2UTCR0) {
-		if (mctrl & TIOCM_RTS)
-			GPCR = GPIO_GPIO17;
-		else
-			GPSR = GPIO_GPIO17;
-	} else if (port->mapbase == _Ser3UTCR0) {
-		if (mctrl & TIOCM_RTS)
-			GPCR = GPIO_GPIO19;
-		else
-			GPSR = GPIO_GPIO19;
-	}
-}
-
-static void
-graphicsmaster_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
-{
-	if (!state) {
-		/* make serial ports work ... */
-		Ser2UTCR4 = 0;
-		Ser2HSCR0 = 0; 
-		Ser1SDCR0 |= SDCR0_UART;
-	}
-}
-
-static struct sa1100_port_fns graphicsmaster_port_fns __initdata = {
-	.get_mctrl	= graphicsmaster_get_mctrl,
-	.set_mctrl	= graphicsmaster_set_mctrl,
-	.pm		= graphicsmaster_uart_pm,
-};
-
-static void __init graphicsmaster_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(graphicsmaster_io_desc, ARRAY_SIZE(graphicsmaster_io_desc));
-
-	sa1100_register_uart_fns(&graphicsmaster_port_fns);
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-	sa1100_register_uart(2, 2);
-
-	/* set GPDR now */
-	GPDR |= GPIO_GPIO15 | GPIO_GPIO17 | GPIO_GPIO19;
-       	GPDR &= ~(GPIO_GPIO14 | GPIO_GPIO16 | GPIO_GPIO18);
-}
-
-MACHINE_START(GRAPHICSMASTER, "ADS GraphicsMaster")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(graphicsmaster_map_io)
-	INITIRQ(graphicsmaster_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
--- a/arch/arm/mach-sa1100/h3600.c	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/mach-sa1100/h3600.c	2004-12-24 13:36:31 -08:00
@@ -25,6 +25,9 @@
 #include <linux/kernel.h>
 #include <linux/tty.h>
 #include <linux/pm.h>
+#include <linux/device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 #include <linux/serial_core.h>
 
 #include <asm/irq.h>
@@ -34,6 +37,8 @@
 
 #include <asm/mach/irq.h>
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
+#include <asm/mach/irda.h>
 #include <asm/mach/map.h>
 #include <asm/mach/serial_sa1100.h>
 
@@ -52,6 +57,99 @@
 struct ipaq_model_ops ipaq_model_ops;
 EXPORT_SYMBOL(ipaq_model_ops);
 
+static struct mtd_partition h3xxx_partitions[] = {
+	{
+		.name		= "H3XXX boot firmware",
+		.size		= 0x00040000,
+		.offset		= 0,
+		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
+	}, {
+#ifdef CONFIG_MTD_2PARTS_IPAQ
+		.name		= "H3XXX root jffs2",
+		.size		= MTDPART_SIZ_FULL,
+		.offset		= 0x00040000,
+#else
+		.name		= "H3XXX kernel",
+		.size		= 0x00080000,
+		.offset		= 0x00040000,
+	}, {
+		.name		= "H3XXX params",
+		.size		= 0x00040000,
+		.offset		= 0x000C0000,
+	}, {
+#ifdef CONFIG_JFFS2_FS
+		.name		= "H3XXX root jffs2",
+		.size		= MTDPART_SIZ_FULL,
+		.offset		= 0x00100000,
+#else
+		.name		= "H3XXX initrd",
+		.size		= 0x00100000,
+		.offset		= 0x00100000,
+	}, {
+		.name		= "H3XXX root cramfs",
+		.size		= 0x00300000,
+		.offset		= 0x00200000,
+	}, {
+		.name		= "H3XXX usr cramfs",
+		.size		= 0x00800000,
+		.offset		= 0x00500000,
+	}, {
+		.name		= "H3XXX usr local",
+		.size		= MTDPART_SIZ_FULL,
+		.offset		= 0x00d00000,
+#endif
+#endif
+	}
+};
+
+static void h3xxx_set_vpp(int vpp)
+{
+	assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp);
+}
+
+static struct flash_platform_data h3xxx_flash_data = {
+	.map_name	= "cfi_probe",
+	.set_vpp	= h3xxx_set_vpp,
+	.parts		= h3xxx_partitions,
+	.nr_parts	= ARRAY_SIZE(h3xxx_partitions),
+};
+
+static struct resource h3xxx_flash_resource = {
+	.start		= SA1100_CS0_PHYS,
+	.end		= SA1100_CS0_PHYS + SZ_32M - 1,
+	.flags		= IORESOURCE_MEM,
+};
+
+/*
+ * This turns the IRDA power on or off on the Compaq H3600
+ */
+static int h3600_irda_set_power(struct device *dev, unsigned int state)
+{
+	assign_h3600_egpio( IPAQ_EGPIO_IR_ON, state );
+
+	return 0;
+}
+
+static void h3600_irda_set_speed(struct device *dev, int speed)
+{
+	if (speed < 4000000) {
+		clr_h3600_egpio(IPAQ_EGPIO_IR_FSEL);
+	} else {
+		set_h3600_egpio(IPAQ_EGPIO_IR_FSEL);
+	}
+}
+
+static struct irda_platform_data h3600_irda_data = {
+	.set_power	= h3600_irda_set_power,
+	.set_speed	= h3600_irda_set_speed,
+};
+
+static void h3xxx_mach_init(void)
+{
+	sa11x0_set_flash_data(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
+	sa11x0_set_irda_data(&h3600_irda_data);
+}
+
 /*
  * low-level UART features
  */
@@ -286,7 +384,8 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(h3100_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
+	.init_machine	= h3xxx_mach_init,
 MACHINE_END
 
 #endif /* CONFIG_SA1100_H3100 */
@@ -401,7 +500,8 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(h3600_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
+	.init_machine	= h3xxx_mach_init,
 MACHINE_END
 
 #endif /* CONFIG_SA1100_H3600 */
@@ -785,7 +885,8 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(h3800_map_io)
 	INITIRQ(h3800_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
+	.init_machine	= h3xxx_mach_init,
 MACHINE_END
 
 #endif /* CONFIG_SA1100_H3800 */
diff -Nru a/arch/arm/mach-sa1100/hackkit.c b/arch/arm/mach-sa1100/hackkit.c
--- a/arch/arm/mach-sa1100/hackkit.c	2004-12-24 13:37:32 -08:00
+++ b/arch/arm/mach-sa1100/hackkit.c	2004-12-24 13:37:32 -08:00
@@ -19,6 +19,8 @@
 #include <linux/errno.h>
 #include <linux/cpufreq.h>
 #include <linux/serial_core.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -28,6 +30,7 @@
 #include <asm/irq.h>
 
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/serial_sa1100.h>
@@ -39,8 +42,6 @@
  */
 
 /* init funcs */
-static int __init hackkit_init(void);
-static void __init hackkit_init_irq(void);
 static void __init hackkit_map_io(void);
 
 static u_int hackkit_get_mctrl(struct uart_port *port);
@@ -83,11 +84,6 @@
 	Ser1SDCR0 |= SDCR0_SUS;
 }
 
-static void __init hackkit_init_irq(void)
-{
-	/* none used yet */
-}
-
 /**
  *	hackkit_uart_pm - powermgmt callback function for system 3 UART
  *	@port: uart port structure
@@ -144,35 +140,61 @@
 	return ret;
 }
 
-static int __init hackkit_init(void)
-{
-	int ret = 0;
-
-	if ( !machine_is_hackkit() ) {
-		ret = -EINVAL;
-		goto DONE;
+static struct mtd_partition hackkit_partitions[] = {
+	{
+		.name		= "BLOB",
+		.size		= 0x00040000,
+		.offset		= 0x00000000,
+		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
+	}, {
+		.name		= "config",
+		.size		= 0x00040000,
+		.offset		= MTDPART_OFS_APPEND,
+	}, {
+		.name		= "kernel",
+		.size		= 0x00100000,
+		.offset		= MTDPART_OFS_APPEND,
+	}, {
+		.name		= "initrd",
+		.size		= 0x00180000,
+		.offset		= MTDPART_OFS_APPEND,
+	}, {
+		.name		= "rootfs",
+		.size		= 0x700000,
+		.offset		= MTDPART_OFS_APPEND,
+	}, {
+		.name		= "data",
+		.size		= MTDPART_SIZ_FULL,
+		.offset		= MTDPART_OFS_APPEND,
 	}
+};
+
+static struct flash_platform_data hackkit_flash_data = {
+	.map_name	= "cfi_probe",
+	.parts		= hackkit_partitions,
+	.nr_parts	= ARRAY_SIZE(hackkit_partitions),
+};
 
-	hackkit_init_irq();
+static struct resource hackkit_flash_resource = {
+	.start		= SA1100_CS0_PHYS,
+	.end		= SA1100_CS0_PHYS + SZ_32M,
+	.flags		= IORESOURCE_MEM,
+};
 
-	ret = 0;
-DONE:
-	return ret;
+static void __init hackkit_init(void)
+{
+	sa11x0_set_flash_data(&hackkit_flash_data, &hackkit_flash_resource, 1);
 }
 
 /**********************************************************************
  *  Exported Functions
  */
 
-/**********************************************************************
- *  kernel magic macros
- */
-arch_initcall(hackkit_init);
-
 MACHINE_START(HACKKIT, "HackKit Cpu Board")
 	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(hackkit_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
+	.init_machine	= hackkit_init,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/huw_webpanel.c b/arch/arm/mach-sa1100/huw_webpanel.c
--- a/arch/arm/mach-sa1100/huw_webpanel.c	2004-12-24 13:37:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,85 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/huw_webpanel.c
- *
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-
-unsigned long BCR_value;
-EXPORT_SYMBOL(BCR_value);
-
-static void huw_lcd_power(int on)
-{
-	if (on)
-		BCR_clear(BCR_TFT_NPWR);
-	else
-		BCR_set(BCR_TFT_NPWR);
-}
-
-static void huw_backlight_power(int on)
-{
-#error FIXME
-	if (on) {
-		BCR_set(BCR_CCFL_POW | BCR_PWM_BACKLIGHT);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_task(200 * HZ / 1000);
-		BCR_set(BCR_TFT_ENA);
-	}
-}
-
-static int __init init_huw_cs3(void)
-{
-	// here we can place some initcode
-	// BCR_value = 0x1045bf70; //*((volatile unsigned long*)0xf1fffff0);
-	if (machine_is_huw_webpanel()) {
-		sa1100fb_lcd_power = huw_lcd_power;
-		sa1100fb_backlight_power = huw_backlight_power;
-	}
-
-	return 0;
-}
-
-arch_initcall(init_huw_cs3);
-
-
-/**
-   memory information (JOR):
-   32 MByte - 256KByte bootloader (init at boot time) - 32 kByte save area
-   area size = 288 kByte (0x48000 Bytes)
-**/
-static struct map_desc huw_webpanel_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0xc1fb8000, 0x00048000, MT_DEVICE }, /* Parameter */
-  { 0xf1000000, 0x18000000, 0x00100000, MT_DEVICE }  /* Paules CS3, write only */
-};
-
-static void __init huw_webpanel_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(huw_webpanel_io_desc, ARRAY_SIZE(huw_webpanel_io_desc));
-
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-}
-
-
-MACHINE_START(HUW_WEBPANEL, "HuW-Webpanel")
-	MAINTAINER("Roman Jordan")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(huw_webpanel_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/itsy.c b/arch/arm/mach-sa1100/itsy.c
--- a/arch/arm/mach-sa1100/itsy.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,41 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/itsy.c
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-/* BRADFIXME The egpio addresses aren't verifiably correct. (i.e. they're most
-   likely wrong. */
-static struct map_desc itsy_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x49000000, 0x01000000, MT_DEVICE } /* EGPIO 0 */
-};
-
-static void __init itsy_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(itsy_io_desc, ARRAY_SIZE(itsy_io_desc));
-
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-	sa1100_register_uart(2, 2);
-}
-
-MACHINE_START(ITSY, "Compaq Itsy")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	BOOT_PARAMS(0xc0000100)
-	MAPIO(itsy_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c
--- a/arch/arm/mach-sa1100/jornada720.c	2004-12-24 13:37:34 -08:00
+++ b/arch/arm/mach-sa1100/jornada720.c	2004-12-24 13:37:34 -08:00
@@ -101,5 +101,5 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(jornada720_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/lart.c b/arch/arm/mach-sa1100/lart.c
--- a/arch/arm/mach-sa1100/lart.c	2004-12-24 13:37:30 -08:00
+++ b/arch/arm/mach-sa1100/lart.c	2004-12-24 13:37:30 -08:00
@@ -17,6 +17,8 @@
 #include "generic.h"
 
 
+#warning "include/asm/arch-sa1100/ide.h needs fixing for lart"
+
 static struct map_desc lart_io_desc[] __initdata = {
  /* virtual     physical    length      type */
   { 0xe8000000, 0x00000000, 0x00400000, MT_DEVICE }, /* main flash memory */
@@ -43,5 +45,5 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(lart_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/leds-adsbitsy.c b/arch/arm/mach-sa1100/leds-adsbitsy.c
--- a/arch/arm/mach-sa1100/leds-adsbitsy.c	2004-12-24 13:36:34 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,96 +0,0 @@
-/*
- *  linux/arch/arm/mach-sa1100/leds-adsbitsy.c
- *
- * ADS Bitsy LED
- * 7/25/01 Woojung Huh
- */
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-
-#include "leds.h"
-
-
-#define LED_STATE_ENABLED	1
-#define LED_STATE_CLAIMED	2
-
-static unsigned int led_state;
-static unsigned int hw_led_state;
-
-#define LED_TIMER       GPIO_GPIO20  /* green heartbeat */
-
-#define LED_MASK		(LED_TIMER)
-
-void adsbitsy_leds_event(led_event_t evt)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	switch (evt) {
-	case led_start:
-		hw_led_state = 0;        /* gc leds are positive logic */
-		led_state = LED_STATE_ENABLED;
-		break;
-
-	case led_stop:
-		led_state &= ~LED_STATE_ENABLED;
-		break;
-
-	case led_claim:
-		led_state |= LED_STATE_CLAIMED;
-		hw_led_state = LED_MASK;
-		break;
-
-	case led_release:
-		led_state &= ~LED_STATE_CLAIMED;
-		hw_led_state = LED_MASK;
-		break;
-
-#ifdef CONFIG_LEDS_TIMER
-	case led_timer:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state ^= LED_TIMER;
-		break;
-#endif
-
-#ifdef CONFIG_LEDS_CPU
-	case led_idle_start:
-		break;
-
-	case led_idle_end:
-		break;
-#endif
-
-	case led_green_on:
-		break;
-
-	case led_green_off:
-		break;
-
-	case led_amber_on:
-		break;
-
-	case led_amber_off:
-		break;
-
-	case led_red_on:
-		break;
-
-	case led_red_off:
-		break;
-
-	default:
-		break;
-	}
-
-	if  (led_state & LED_STATE_ENABLED) {
-		GPSR = hw_led_state;
-		GPCR = hw_led_state ^ LED_MASK;
-	}
-
-	local_irq_restore(flags);
-}
diff -Nru a/arch/arm/mach-sa1100/leds-brutus.c b/arch/arm/mach-sa1100/leds-brutus.c
--- a/arch/arm/mach-sa1100/leds-brutus.c	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,111 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/leds-brutus.c
- *
- * Copyright (C) 2000 Nicolas Pitre
- *
- * Brutus uses the LEDs as follows:
- *   - D3 (Green, GPIO9) - toggles state every 50 timer interrupts
- *   - D17 (Red, GPIO20) - on if system is not idle
- *   - D4 (Green, GPIO8) - misc function
- */
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-
-#include "leds.h"
-
-
-#define LED_STATE_ENABLED	1
-#define LED_STATE_CLAIMED	2
-
-static unsigned int led_state;
-static unsigned int hw_led_state;
-
-#define LED_D3		GPIO_GPIO(9)
-#define LED_D4		GPIO_GPIO(8)
-#define LED_D17		GPIO_GPIO(20)
-#define LED_MASK	(LED_D3|LED_D4|LED_D17)
-
-void brutus_leds_event(led_event_t evt)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	switch (evt) {
-	case led_start:
-		hw_led_state = LED_MASK;
-		led_state = LED_STATE_ENABLED;
-		break;
-
-	case led_stop:
-		led_state &= ~LED_STATE_ENABLED;
-		break;
-
-	case led_claim:
-		led_state |= LED_STATE_CLAIMED;
-		hw_led_state = LED_MASK;
-		break;
-
-	case led_release:
-		led_state &= ~LED_STATE_CLAIMED;
-		hw_led_state = LED_MASK;
-		break;
-
-#ifdef CONFIG_LEDS_TIMER
-	case led_timer:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state ^= LED_D3;
-		break;
-#endif
-
-#ifdef CONFIG_LEDS_CPU
-	case led_idle_start:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state |= LED_D17;
-		break;
-
-	case led_idle_end:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state &= ~LED_D17;
-		break;
-#endif
-
-	case led_green_on:
-		hw_led_state &= ~LED_D4;
-		break;
-
-	case led_green_off:
-		hw_led_state |= LED_D4;
-		break;
-
-	case led_amber_on:
-		break;
-
-	case led_amber_off:
-		break;
-
-	case led_red_on:
-		if (led_state & LED_STATE_CLAIMED)
-			hw_led_state &= ~LED_D17;
-		break;
-
-	case led_red_off:
-		if (led_state & LED_STATE_CLAIMED)
-			hw_led_state |= LED_D17;
-		break;
-
-	default:
-		break;
-	}
-
-	if  (led_state & LED_STATE_ENABLED) {
-		GPSR = hw_led_state;
-		GPCR = hw_led_state ^ LED_MASK;
-	}
-
-	local_irq_restore(flags);
-}
diff -Nru a/arch/arm/mach-sa1100/leds-flexanet.c b/arch/arm/mach-sa1100/leds-flexanet.c
--- a/arch/arm/mach-sa1100/leds-flexanet.c	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,129 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/leds-flexanet.c
- *
- * by Jordi Colomer <jco@ict.es>
- *
- * Flexanet LEDs
- *
- *   - Red   - toggles state every 50 timer interrupts (Heartbeat)
- *   - Green - on if system is not idle (CPU load)
- */
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-
-#include "leds.h"
-
-
-#define LED_STATE_ENABLED	1
-#define LED_STATE_CLAIMED	2
-
-static unsigned int led_state;
-static unsigned int hw_led_bcr;
-static unsigned int hw_led_gpio;
-
-
-void flexanet_leds_event(led_event_t evt)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	switch (evt) {
-	case led_start:
-		/* start using LEDs and enable its hardware */
-		hw_led_bcr = FHH_BCR_LED_GREEN;
-		hw_led_gpio = GPIO_LED_RED;
-		led_state = LED_STATE_ENABLED;
-		break;
-
-	case led_stop:
-		/* disable LED h/w */
-		led_state &= ~LED_STATE_ENABLED;
-		break;
-
-	case led_claim:
-		/* select LEDs for direct access */
-		led_state |= LED_STATE_CLAIMED;
-		hw_led_bcr = 0;
-		hw_led_gpio = 0;
-		break;
-
-	case led_release:
-		/* release LEDs from direct access */
-		led_state &= ~LED_STATE_CLAIMED;
-		hw_led_bcr = 0;
-		hw_led_gpio = 0;
-		break;
-
-#ifdef CONFIG_LEDS_TIMER
-	case led_timer:
-		/* toggle heartbeat LED */
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_gpio ^= GPIO_LED_RED;
-		break;
-#endif
-
-#ifdef CONFIG_LEDS_CPU
-	case led_idle_start:
-		/* turn off CPU load LED */
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_bcr &= ~FHH_BCR_LED_GREEN;
-		break;
-
-	case led_idle_end:
-		/* turn on CPU load LED */
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_bcr |= FHH_BCR_LED_GREEN;
-		break;
-#endif
-
-	case led_halted:
-		break;
-
-
-	/* direct LED access (must be previously claimed) */
-	case led_green_on:
-		if (led_state & LED_STATE_CLAIMED)
-			hw_led_bcr |= FHH_BCR_LED_GREEN;
-		break;
-
-	case led_green_off:
-		if (led_state & LED_STATE_CLAIMED)
-			hw_led_bcr &= ~FHH_BCR_LED_GREEN;
-		break;
-
-	case led_amber_on:
-		break;
-
-	case led_amber_off:
-		break;
-
-	case led_red_on:
-		if (led_state & LED_STATE_CLAIMED)
-			hw_led_gpio |= GPIO_LED_RED;
-		break;
-
-	case led_red_off:
-		if (led_state & LED_STATE_CLAIMED)
-			hw_led_gpio &= ~GPIO_LED_RED;
-		break;
-
-	default:
-		break;
-	}
-
-	if  (led_state & LED_STATE_ENABLED)
-	{
-		/* update LEDs */
-		FHH_BCR = flexanet_BCR = (flexanet_BCR & ~FHH_BCR_LED_GREEN) | hw_led_bcr;
-		GPSR = hw_led_gpio;
-		GPCR = hw_led_gpio ^ GPIO_LED_RED;
-	}
-
-	local_irq_restore(flags);
-}
-
diff -Nru a/arch/arm/mach-sa1100/leds-graphicsclient.c b/arch/arm/mach-sa1100/leds-graphicsclient.c
--- a/arch/arm/mach-sa1100/leds-graphicsclient.c	2004-12-24 13:36:56 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,104 +0,0 @@
-/*
- *  linux/arch/arm/mach-sa1100/leds-graphicsclient.c
- *
- * GraphicsClient Plus LEDs support
- * Woojung Huh, Feb 13, 2001
- */
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-
-#include "leds.h"
-
-
-#define LED_STATE_ENABLED	1
-#define LED_STATE_CLAIMED	2
-
-static unsigned int led_state;
-static unsigned int hw_led_state;
-
-#define LED_TIMER       ADS_LED0  /* green heartbeat */
-#define LED_USER        ADS_LED1  /* amber, boots to on */
-#define LED_IDLE        ADS_LED2  /* red has the idle led, if any */
-
-#define LED_MASK	(ADS_LED0|ADS_LED1|ADS_LED2)
-
-void graphicsclient_leds_event(led_event_t evt)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	switch (evt) {
-	case led_start:
-		hw_led_state = 0;        /* gc leds are positive logic */
-		led_state = LED_STATE_ENABLED;
-		break;
-
-	case led_stop:
-		led_state &= ~LED_STATE_ENABLED;
-		break;
-
-	case led_claim:
-		led_state |= LED_STATE_CLAIMED;
-		hw_led_state = LED_MASK;
-		break;
-
-	case led_release:
-		led_state &= ~LED_STATE_CLAIMED;
-		hw_led_state = LED_MASK;
-		break;
-
-#ifdef CONFIG_LEDS_TIMER
-	case led_timer:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state ^= LED_TIMER;
-		break;
-#endif
-
-#ifdef CONFIG_LEDS_CPU
-	case led_idle_start:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state &= ~LED_IDLE;
-		break;
-
-	case led_idle_end:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state |= LED_IDLE;
-		break;
-#endif
-
-	case led_green_on:
-		break;
-
-	case led_green_off:
-		break;
-
-	case led_amber_on:
-		hw_led_state |= LED_USER;
-		break;
-
-	case led_amber_off:
-		hw_led_state &= ~LED_USER;
-		break;
-
-	case led_red_on:
-		break;
-
-	case led_red_off:
-		break;
-
-	default:
-		break;
-	}
-
-	if  (led_state & LED_STATE_ENABLED) {
-		GPSR = hw_led_state;
-		GPCR = hw_led_state ^ LED_MASK;
-	}
-
-	local_irq_restore(flags);
-}
diff -Nru a/arch/arm/mach-sa1100/leds-graphicsmaster.c b/arch/arm/mach-sa1100/leds-graphicsmaster.c
--- a/arch/arm/mach-sa1100/leds-graphicsmaster.c	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,104 +0,0 @@
-/*
- *  linux/arch/arm/mach-sa1100/leds-graphicsmaster.c
- *
- * GraphicsClient Plus LEDs support
- * Woojung Huh, Feb 13, 2001
- */
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-
-#include "leds.h"
-
-
-#define LED_STATE_ENABLED	1
-#define LED_STATE_CLAIMED	2
-
-static unsigned int led_state;
-static unsigned int hw_led_state;
-
-#define LED_TIMER       ADS_LED0  /* green heartbeat */
-#define LED_USER        ADS_LED1  /* amber, boots to on */
-#define LED_IDLE        ADS_LED2  /* red has the idle led, if any */
-
-#define LED_MASK	(ADS_LED0|ADS_LED1|ADS_LED2)
-
-void graphicsmaster_leds_event(led_event_t evt)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	switch (evt) {
-	case led_start:
-		hw_led_state = 0;        /* gc leds are positive logic */
-		led_state = LED_STATE_ENABLED;
-		break;
-
-	case led_stop:
-		led_state &= ~LED_STATE_ENABLED;
-		break;
-
-	case led_claim:
-		led_state |= LED_STATE_CLAIMED;
-		hw_led_state = LED_MASK;
-		break;
-
-	case led_release:
-		led_state &= ~LED_STATE_CLAIMED;
-		hw_led_state = LED_MASK;
-		break;
-
-#ifdef CONFIG_LEDS_TIMER
-	case led_timer:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state ^= LED_TIMER;
-		break;
-#endif
-
-#ifdef CONFIG_LEDS_CPU
-	case led_idle_start:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state &= ~LED_IDLE;
-		break;
-
-	case led_idle_end:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state |= LED_IDLE;
-		break;
-#endif
-
-	case led_green_on:
-		break;
-
-	case led_green_off:
-		break;
-
-	case led_amber_on:
-		hw_led_state |= LED_USER;
-		break;
-
-	case led_amber_off:
-		hw_led_state &= ~LED_USER;
-		break;
-
-	case led_red_on:
-		break;
-
-	case led_red_off:
-		break;
-
-	default:
-		break;
-	}
-
-	if  (led_state & LED_STATE_ENABLED) {
-		GPSR = hw_led_state;
-		GPCR = hw_led_state ^ LED_MASK;
-	}
-
-	local_irq_restore(flags);
-}
diff -Nru a/arch/arm/mach-sa1100/leds-pfs168.c b/arch/arm/mach-sa1100/leds-pfs168.c
--- a/arch/arm/mach-sa1100/leds-pfs168.c	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,99 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/leds-pfs168.c
- *
- * Author: George Davis <davis_g@mvista.com>
- */
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-
-#include "leds.h"
-
-
-#define LED_STATE_ENABLED	1
-#define LED_STATE_CLAIMED	2
-
-static unsigned int led_state;
-static unsigned int hw_led_state;
-
-#define	LED_GREEN	(1)
-#define	LED_MASK	(1)
-
-void pfs168_leds_event(led_event_t evt)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	switch (evt) {
-	case led_start:
-		hw_led_state = LED_GREEN;
-		led_state = LED_STATE_ENABLED;
-		break;
-
-	case led_stop:
-		led_state &= ~LED_STATE_ENABLED;
-		break;
-
-	case led_claim:
-		led_state |= LED_STATE_CLAIMED;
-		hw_led_state = LED_GREEN;
-		break;
-
-	case led_release:
-		led_state &= ~LED_STATE_CLAIMED;
-		hw_led_state = LED_GREEN;
-		break;
-
-#ifdef CONFIG_LEDS_TIMER
-	case led_timer:
-		if (!(led_state & LED_STATE_CLAIMED))
-			hw_led_state ^= LED_GREEN;
-		break;
-#endif
-
-#ifdef CONFIG_LEDS_CPU
-	case led_idle_start:
-		break;
-
-	case led_idle_end:
-		break;
-#endif
-
-	case led_halted:
-		break;
-
-	case led_green_on:
-		if (led_state & LED_STATE_CLAIMED)
-			hw_led_state |= LED_GREEN;
-		break;
-
-	case led_green_off:
-		if (led_state & LED_STATE_CLAIMED)
-			hw_led_state &= ~LED_GREEN;
-		break;
-
-	case led_amber_on:
-		break;
-
-	case led_amber_off:
-		break;
-
-	case led_red_on:
-		break;
-
-	case led_red_off:
-		break;
-
-	default:
-		break;
-	}
-
-	if  (led_state & LED_STATE_ENABLED)
-		PFS168_SYSLED = (PFS168_SYSLED & ~LED_MASK) | hw_led_state;
-
-	local_irq_restore(flags);
-}
diff -Nru a/arch/arm/mach-sa1100/leds-simpad.c b/arch/arm/mach-sa1100/leds-simpad.c
--- a/arch/arm/mach-sa1100/leds-simpad.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-sa1100/leds-simpad.c	2004-12-24 13:36:48 -08:00
@@ -28,11 +28,7 @@
 
 void simpad_leds_event(led_event_t evt)
 {
-	unsigned long flags;
-
-	//local_irq_save(flags);
-
-	switch (evt) 
+	switch (evt)
 	{
 	case led_start:
 	        hw_led_state = LED_GREEN;
@@ -101,6 +97,5 @@
 		set_cs3_bit(LED2_ON);
 	else 
 	        clear_cs3_bit(LED2_ON);
-	//local_irq_restore(flags);
 }
 
diff -Nru a/arch/arm/mach-sa1100/leds-system3.c b/arch/arm/mach-sa1100/leds-system3.c
--- a/arch/arm/mach-sa1100/leds-system3.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,48 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/leds-system3.c
- *
- * Copyright (C) 2001 Stefan Eletzhofer <stefan.eletzhofer@gmx.de>
- *
- * Original (leds-footbridge.c) by Russell King
- *
- * $Id: leds-system3.c,v 1.1.6.1 2001/12/04 15:19:26 seletz Exp $
- *
- * 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.
- *
- * $Log: leds-system3.c,v $
- * Revision 1.1.6.1  2001/12/04 15:19:26  seletz
- * - merged from linux_2_4_13_ac5_rmk2
- *
- * Revision 1.1.4.2  2001/11/19 17:58:53  seletz
- * - cleanup
- *
- * Revision 1.1.4.1  2001/11/16 13:49:54  seletz
- * - dummy LED support for PT Digital Board
- *
- * Revision 1.1.2.1  2001/10/15 16:03:39  seletz
- * - dummy function
- *
- *
- */
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-
-#include "leds.h"
-
-
-#define LED_STATE_ENABLED	1
-#define LED_STATE_CLAIMED	2
-
-static unsigned int led_state;
-static unsigned int hw_led_state;
-
-void system3_leds_event(led_event_t evt)
-{
-
-	/* TODO: support LEDs */
-}
diff -Nru a/arch/arm/mach-sa1100/nanoengine.c b/arch/arm/mach-sa1100/nanoengine.c
--- a/arch/arm/mach-sa1100/nanoengine.c	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,53 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/nanoengine.c
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static void __init
-fixup_nanoengine(struct machine_desc *desc, struct tag *tags,
-		 char **cmdline, struct meminfo *mi)
-{
-	/* Get command line parameters passed from the loader (if any) */
-	if (*((char*)0xc0000100))
-		*cmdline = ((char *)0xc0000100);
-}
-
-static struct map_desc nanoengine_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x10000000, 0x00100000, MT_DEVICE }, /* System Registers */
-  { 0xf1000000, 0x18A00000, 0x00100000, MT_DEVICE }  /* Internal PCI Config Space */
-};
-
-static void __init nanoengine_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(nanoengine_io_desc, ARRAY_SIZE(nanoengine_io_desc));
-
-	sa1100_register_uart(0, 1);
-	sa1100_register_uart(1, 2);
-	sa1100_register_uart(2, 3);
-	Ser1SDCR0 |= SDCR0_UART;
-	/* disable IRDA -- UART2 is used as a normal serial port */
-	Ser2UTCR4=0;
-	Ser2HSCR0 = 0;
-}
-
-MACHINE_START(NANOENGINE, "BSE nanoEngine")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	FIXUP(fixup_nanoengine)
-	MAPIO(nanoengine_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
--- a/arch/arm/mach-sa1100/neponset.c	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/mach-sa1100/neponset.c	2004-12-24 13:36:49 -08:00
@@ -173,6 +173,8 @@
 	return 0;
 }
 
+#ifdef CONFIG_PM
+
 /*
  * LDM power management.
  */
@@ -184,12 +186,12 @@
 	if (level == SUSPEND_SAVE_STATE ||
 	    level == SUSPEND_DISABLE ||
 	    level == SUSPEND_POWER_DOWN) {
-		if (!dev->saved_state)
-			dev->saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
-		if (!dev->saved_state)
+		if (!dev->power.saved_state)
+			dev->power.saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
+		if (!dev->power.saved_state)
 			return -ENOMEM;
 
-		*(unsigned int *)dev->saved_state = NCR_0;
+		*(unsigned int *)dev->power.saved_state = NCR_0;
 	}
 
 	return 0;
@@ -198,15 +200,20 @@
 static int neponset_resume(struct device *dev, u32 level)
 {
 	if (level == RESUME_RESTORE_STATE || level == RESUME_ENABLE) {
-		if (dev->saved_state) {
-			NCR_0 = *(unsigned int *)dev->saved_state;
-			kfree(dev->saved_state);
-			dev->saved_state = NULL;
+		if (dev->power.saved_state) {
+			NCR_0 = *(unsigned int *)dev->power.saved_state;
+			kfree(dev->power.saved_state);
+			dev->power.saved_state = NULL;
 		}
 	}
 
 	return 0;
 }
+
+#else
+#define	neponset_suspend	NULL
+#define	neponset_resume	NULL
+#endif
 
 static struct device_driver neponset_device_driver = {
 	.name		= "neponset",
diff -Nru a/arch/arm/mach-sa1100/omnimeter.c b/arch/arm/mach-sa1100/omnimeter.c
--- a/arch/arm/mach-sa1100/omnimeter.c	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,63 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/omnimeter.c
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static void omnimeter_backlight_power(int on)
-{
-	if (on)
-		LEDBacklightOn();
-	else
-		LEDBacklightOff();
-}
-
-static void omnimeter_lcd_power(int on)
-{
-	if (on)
-		LCDPowerOn();
-}
-
-static int __init omnimeter_init(void)
-{
-	if (machine_is_omnimeter()) {
-		sa1100fb_backlight_power = omnimeter_backlight_power;
-		sa1100fb_lcd_power = omnimeter_lcd_power;
-	}
-	return 0;
-}
-
-arch_initcall(omnimeter_init);
-
-static struct map_desc omnimeter_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xd2000000, 0x10000000, 0x02000000, MT_DEVICE } /* TS */
-};
-
-static void __init omnimeter_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(omnimeter_io_desc, ARRAY_SIZE(omnimeter_io_desc));
-
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-}
-
-MACHINE_START(OMNIMETER, "OmniMeter")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(omnimeter_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/pangolin.c b/arch/arm/mach-sa1100/pangolin.c
--- a/arch/arm/mach-sa1100/pangolin.c	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,44 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/pangolin.c
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static struct map_desc pangolin_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf2800000, 0x4b800000, 0x00800000, MT_DEVICE } /* MQ200 */
-};
-
-static void __init pangolin_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(pangolin_io_desc, ARRAY_SIZE(pangolin_io_desc));
-
-	sa1100_register_uart(0, 1);
-	sa1100_register_uart(1, 3);
-	Ser1SDCR0 |= SDCR0_UART;
-
-	/* set some GPDR bits while it's safe */
-	GPDR |= GPIO_PCMCIA_RESET;
-#ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
-	GPDR |= GPIO_PCMCIA_BUS_ON;
-#endif
-}
-
-MACHINE_START(PANGOLIN, "Dialogue-Pangolin")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(pangolin_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/pfs168.c b/arch/arm/mach-sa1100/pfs168.c
--- a/arch/arm/mach-sa1100/pfs168.c	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,116 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/pfs168.c
- */
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/device.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static struct resource sa1111_resources[] = {
-	[0] = {
-		.start		= 0x40000000,
-		.end		= 0x40001fff,
-		.flags		= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start		= IRQ_GPIO25,
-		.end		= IRQ_GPIO25,
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-
-static u64 sa1111_dmamask = 0xffffffffUL;
-
-static struct platform_device sa1111_device = {
-	.name		= "sa1111",
-	.id		= 0,
-	.dev		= {
-		.dma_mask = &sa1111_dmamask,
-		.coherent_dma_mask = 0xffffffff,
-	},
-	.num_resources	= ARRAY_SIZE(sa1111_resources),
-	.resource	= sa1111_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-	&sa1111_device,
-};
-
-static int __init pfs168_init(void)
-{
-	int ret;
-
-	if (!machine_is_pfs168())
-		return -ENODEV;
-
-	/*
-	 * Ensure that the memory bus request/grant signals are setup,
-	 * and the grant is held in its inactive state
-	 */
-	sa1110_mb_disable();
-
-	return platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-arch_initcall(pfs168_init);
-
-
-static void __init pfs168_init_irq(void)
-{
-	sa1100_init_irq();
-
-	/*
-	 * Need to register these as rising edge interrupts
-	 * for standard 16550 serial driver support.
-	 */
-	set_GPIO_IRQ_edge(GPIO_GPIO(19), GPIO_RISING_EDGE);
-	set_GPIO_IRQ_edge(GPIO_GPIO(20), GPIO_RISING_EDGE);
-	set_GPIO_IRQ_edge(GPIO_GPIO(25), GPIO_RISING_EDGE);
-	set_GPIO_IRQ_edge(GPIO_UCB1300_IRQ, GPIO_RISING_EDGE);
-}
-
-static struct map_desc pfs168_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x10000000, 0x00001000, MT_DEVICE }, /* 16C752 DUART port A (COM5) */
-  { 0xf0001000, 0x10800000, 0x00001000, MT_DEVICE }, /* 16C752 DUART port B (COM6) */
-  { 0xf0002000, 0x11000000, 0x00001000, MT_DEVICE }, /* COM1 RTS control (SYSC1RTS) */
-  { 0xf0003000, 0x11400000, 0x00001000, MT_DEVICE }, /* Status LED control (SYSLED) */
-  { 0xf0004000, 0x11800000, 0x00001000, MT_DEVICE }, /* DTMF code read (SYSDTMF) */
-  { 0xf0005000, 0x11c00000, 0x00001000, MT_DEVICE }, /* LCD configure, enable (SYSLCDDE) */
-  { 0xf0006000, 0x12000000, 0x00001000, MT_DEVICE }, /* COM1 DSR and motion sense (SYSC1DSR) */
-  { 0xf0007000, 0x12800000, 0x00001000, MT_DEVICE }, /* COM3 xmit enable (SYSC3TEN) */
-  { 0xf0008000, 0x13000000, 0x00001000, MT_DEVICE }, /* Control register A (SYSCTLA) */
-  { 0xf0009000, 0x13800000, 0x00001000, MT_DEVICE }, /* Control register B (SYSCTLB) */
-  { 0xf000a000, 0x18000000, 0x00001000, MT_DEVICE }, /* SMC91C96 */
-  { 0xf2800000, 0x4b800000, 0x00800000, MT_DEVICE }, /* MQ200 */
-  { 0xf4000000, 0x40000000, 0x00100000, MT_DEVICE }  /* SA-1111 */
-};
-
-static void __init pfs168_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(pfs168_io_desc, ARRAY_SIZE(pfs168_io_desc));
-
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-}
-
-MACHINE_START(PFS168, "Tulsa")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	BOOT_PARAMS(0xc0000100)
-	MAPIO(pfs168_map_io)
-	INITIRQ(pfs168_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c
--- a/arch/arm/mach-sa1100/pleb.c	2004-12-24 13:36:32 -08:00
+++ b/arch/arm/mach-sa1100/pleb.c	2004-12-24 13:37:44 -08:00
@@ -5,31 +5,150 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/tty.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+
+#include <linux/mtd/partitions.h>
 
 #include <asm/hardware.h>
+#include <asm/io.h>
 #include <asm/setup.h>
+#include <asm/mach-types.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
+#include <asm/mach/flash.h>
 #include <asm/mach/serial_sa1100.h>
+#include <asm/arch/irqs.h>
 
 #include "generic.h"
 
+
+/*
+ * Ethernet IRQ mappings
+ */
+
+#define PLEB_ETH0_P		(0x20000300)	/* Ethernet 0 in PCMCIA0 IO */
+#define PLEB_ETH0_V		(0xf6000300)
+
+#define GPIO_ETH0_IRQ		GPIO_GPIO(21)
+#define GPIO_ETH0_EN		GPIO_GPIO(26)
+
+#define IRQ_GPIO_ETH0_IRQ	IRQ_GPIO21
+
+static struct resource smc91x_resources[] = {
+	[0] = {
+		.start	=  PLEB_ETH0_P,
+		.end	=  PLEB_ETH0_P | 0x03ffffff,
+		.flags	= IORESOURCE_MEM,
+	},
+#if 0 /* Autoprobe instead, to get rising/falling edge characteristic right */
+	[1] = {
+		.start	= IRQ_GPIO_ETH0_IRQ,
+		.end	= IRQ_GPIO_ETH0_IRQ,
+		.flags	= IORESOURCE_IRQ,
+	},
+#endif
+};
+
+
+static struct platform_device smc91x_device = {
+	.name		= "smc91x",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(smc91x_resources),
+	.resource	= smc91x_resources,
+};
+
+static struct platform_device *devices[] __initdata = {
+	&smc91x_device,
+};
+
+
+/*
+ * Pleb's memory map
+ * has flash memory (typically 4 or 8 meg) selected by
+ * the two SA1100 lowest chip select outputs.
+ */
+static struct resource pleb_flash_resources[] = {
+	[0] = {
+		.start = SA1100_CS0_PHYS,
+		.end   = SA1100_CS0_PHYS + SZ_8M - 1,
+		.flags = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start = SA1100_CS1_PHYS,
+		.end   = SA1100_CS1_PHYS + SZ_8M - 1,
+		.flags = IORESOURCE_MEM,
+	}
+};
+
+
+static struct mtd_partition pleb_partitions[] = {
+	{
+		.name		= "blob",
+		.offset 	= 0,
+		.size		= 0x00020000,
+	}, {
+		.name		= "kernel",
+		.offset 	= MTDPART_OFS_APPEND,
+		.size		= 0x000e0000,
+	}, {
+		.name		= "rootfs",
+		.offset 	= MTDPART_OFS_APPEND,
+		.size		= 0x00300000,
+	}
+};
+
+
+static struct flash_platform_data pleb_flash_data = {
+	.map_name = "cfi_probe",
+	.parts = pleb_partitions,
+	.nr_parts = ARRAY_SIZE(pleb_partitions),
+};
+
+
+static void __init pleb_init(void)
+{
+	sa11x0_set_flash_data(&pleb_flash_data, pleb_flash_resources,
+			      ARRAY_SIZE(pleb_flash_resources));
+
+
+	platform_add_devices(devices, ARRAY_SIZE(devices));
+}
+
+
 static void __init pleb_map_io(void)
 {
 	sa1100_map_io();
 
 	sa1100_register_uart(0, 3);
         sa1100_register_uart(1, 1);
+
         GAFR |= (GPIO_UART_TXD | GPIO_UART_RXD);
         GPDR |= GPIO_UART_TXD;
         GPDR &= ~GPIO_UART_RXD;
         PPAR |= PPAR_UPR;
+
+	/*
+	 * Fix expansion memory timing for network card
+	 */
+	MECR = ((2<<10) | (2<<5) | (2<<0));
+
+	/*
+	 * Enable the SMC ethernet controller
+	 */
+	GPDR |= GPIO_ETH0_EN;	/* set to output */
+	GPCR  = GPIO_ETH0_EN;	/* clear MCLK (enable smc) */
+
+	GPDR &= ~GPIO_ETH0_IRQ;
+
+	set_irq_type(GPIO_ETH0_IRQ, IRQT_FALLING);
 }
 
 MACHINE_START(PLEB, "PLEB")
 	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
 	MAPIO(pleb_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
+	.init_machine   = pleb_init,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c
--- a/arch/arm/mach-sa1100/pm.c	2004-12-24 13:36:31 -08:00
+++ b/arch/arm/mach-sa1100/pm.c	2004-12-24 13:36:31 -08:00
@@ -45,9 +45,6 @@
  */
 enum {	SLEEP_SAVE_SP = 0,
 
-	SLEEP_SAVE_OIER,
-	SLEEP_SAVE_OSMR0, SLEEP_SAVE_OSMR1, SLEEP_SAVE_OSMR2, SLEEP_SAVE_OSMR3,
-
 	SLEEP_SAVE_GPDR, SLEEP_SAVE_GAFR,
 	SLEEP_SAVE_PPDR, SLEEP_SAVE_PPSR, SLEEP_SAVE_PPAR, SLEEP_SAVE_PSDR,
 
@@ -57,7 +54,7 @@
 };
 
 
-static int sa11x0_pm_enter(u32 state)
+static int sa11x0_pm_enter(suspend_state_t state)
 {
 	unsigned long gpio, sleep_save[SLEEP_SAVE_SIZE];
 	struct timespec delta, rtc;
@@ -72,12 +69,6 @@
 	gpio = GPLR;
 
 	/* save vital registers */
-	SAVE(OSMR0);
-	SAVE(OSMR1);
-	SAVE(OSMR2);
-	SAVE(OSMR3);
-	SAVE(OIER);
-
 	SAVE(GPDR);
 	SAVE(GAFR);
 
@@ -129,15 +120,6 @@
 	 */
 	PSSR = PSSR_PH;
 
-	RESTORE(OSMR0);
-	RESTORE(OSMR1);
-	RESTORE(OSMR2);
-	RESTORE(OSMR3);
-	RESTORE(OIER);
-
-	/* OSMR0 is the system timer: make sure OSCR is sufficiently behind */
-	OSCR = OSMR0 - LATCH;
-
 	/* restore current time */
 	rtc.tv_sec = RCNR;
 	restore_time_delta(&delta, &rtc);
@@ -153,7 +135,7 @@
 /*
  * Called after processes are frozen, but before we shut down devices.
  */
-static int sa11x0_pm_prepare(u32 state)
+static int sa11x0_pm_prepare(suspend_state_t state)
 {
 	return 0;
 }
@@ -161,7 +143,7 @@
 /*
  * Called after devices are re-setup, but before processes are thawed.
  */
-static int sa11x0_pm_finish(u32 state)
+static int sa11x0_pm_finish(suspend_state_t state)
 {
 	return 0;
 }
diff -Nru a/arch/arm/mach-sa1100/shannon.c b/arch/arm/mach-sa1100/shannon.c
--- a/arch/arm/mach-sa1100/shannon.c	2004-12-24 13:37:43 -08:00
+++ b/arch/arm/mach-sa1100/shannon.c	2004-12-24 13:37:43 -08:00
@@ -5,18 +5,55 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/tty.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 
 #include <asm/hardware.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
 
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/serial_sa1100.h>
 #include <asm/arch/shannon.h>
 
 #include "generic.h"
 
+static struct mtd_partition shannon_partitions[] = {
+	{
+		.name		= "BLOB boot loader",
+		.offset		= 0,
+		.size		= 0x20000
+	},
+	{
+		.name		= "kernel",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= 0xe0000
+	},
+	{ 
+		.name		= "initrd",
+		.offset		= MTDPART_OFS_APPEND,	
+		.size		= MTDPART_SIZ_FULL
+	}
+};
+
+static struct flash_platform_data shannon_flash_data = {
+	.map_name	= "cfi_probe",
+	.parts		= shannon_partitions,
+	.nr_parts	= ARRAY_SIZE(shannon_partitions),
+};
+
+static struct resource shannon_flash_resource = {
+	.start		= SA1100_CS0_PHYS,
+	.end		= SA1100_CS0_PHYS + SZ_4M - 1,
+	.flags		= IORESOURCE_MEM,
+};
+
+static void __init shannon_init(void)
+{
+	sa11x0_set_flash_data(&shannon_flash_data, shannon_flash_resource, 1);
+}
 
 static void __init shannon_map_io(void)
 {
@@ -41,5 +78,6 @@
 	BOOT_PARAMS(0xc0000100)
 	MAPIO(shannon_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
+	.init_machine	= shannon_init,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/sherman.c b/arch/arm/mach-sa1100/sherman.c
--- a/arch/arm/mach-sa1100/sherman.c	2004-12-24 13:36:56 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,31 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/sherman.c
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-static void __init sherman_map_io(void)
-{
-	sa1100_map_io();
-
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-}
-
-MACHINE_START(SHERMAN, "Blazie Engineering Sherman")
-        BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-        MAPIO(sherman_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c
--- a/arch/arm/mach-sa1100/simpad.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-sa1100/simpad.c	2004-12-24 13:36:18 -08:00
@@ -10,6 +10,9 @@
 #include <linux/proc_fs.h>
 #include <linux/string.h> 
 #include <linux/pm.h>
+#include <linux/device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 
 #include <asm/irq.h>
 #include <asm/hardware.h>
@@ -17,10 +20,10 @@
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/serial_sa1100.h>
 #include <asm/arch/simpad.h>
-#include <asm/arch/registry.h>
 
 #include <linux/serial_core.h>
 #include <linux/ioport.h>
@@ -83,6 +86,45 @@
 	.pm	   = simpad_uart_pm,
 };
 
+
+static struct mtd_partition simpad_partitions[] = {
+	{
+		.name       = "SIMpad boot firmware",
+		.size       = 0x00080000,
+		.offset     = 0,
+		.mask_flags = MTD_WRITEABLE,
+	}, {
+		.name       = "SIMpad kernel",
+		.size       = 0x0010000,
+		.offset     = MTDPART_OFS_APPEND,
+	}, {
+		.name       = "SIMpad root jffs2",
+		.size       = MTDPART_SIZ_FULL,
+		.offset     = MTDPART_OFS_APPEND,
+	}
+};
+
+static struct flash_platform_data simpad_flash_data = {
+	.map_name    = "cfi_probe",
+	.parts       = simpad_partitions,
+	.nr_parts    = ARRAY_SIZE(simpad_partitions),
+};
+
+
+static struct resource simpad_flash_resources [] = {
+	{
+		.start     = SA1100_CS0_PHYS,
+		.end       = SA1100_CS0_PHYS + SZ_16M -1,
+		.flags     = IORESOURCE_MEM,
+	}, {
+		.start     = SA1100_CS1_PHYS,
+		.end       = SA1100_CS1_PHYS + SZ_16M -1,
+		.flags     = IORESOURCE_MEM,
+	}
+};
+
+
+
 static void __init simpad_map_io(void)
 {
 	sa1100_map_io();
@@ -113,85 +155,10 @@
 	PCFR = 0;
 	PSDR = 0;
 
-
+	sa11x0_set_flash_data(&simpad_flash_data, simpad_flash_resources,
+			      ARRAY_SIZE(simpad_flash_resources));
 }
 
-#ifdef CONFIG_PROC_FS
-
-static char* name[]={
-  "VCC_5V_EN",
-  "VCC_3V_EN",
-  "EN1",
-  "EN0",
-  "DISPLAY_ON",
-  "PCMCIA_BUFF_DIS",
-  "MQ_RESET",
-  "PCMCIA_RESET",
-  "DECT_POWER_ON",
-  "IRDA_SD",
-  "RS232_ON",
-  "SD_MEDIAQ",
-  "LED2_ON",
-  "IRDA_MODE",
-  "ENABLE_5V",
-  "RESET_SIMCARD"
-};
-
-static int proc_cs3_read(char *page, char **start, off_t off,
-			  int count, int *eof, void *data)
-{
-	char *p = page;
-	int len, i;
-        
-	p += sprintf(p, "Chipselect3 : %x\n", (uint)cs3_shadow);
-	for (i = 0; i <= 15; i++) {
-		if(cs3_shadow & (1<<i)) {
-			p += sprintf(p, "%s\t: TRUE \n",name[i]);
-		} else
-			p += sprintf(p, "%s\t: FALSE \n",name[i]);
-	}
-	len = (p - page) - off;
-	if (len < 0)
-		len = 0;
- 
-	*eof = (len <= count) ? 1 : 0;
-	*start = page + off;
- 
-	return len;
-}
-
-static int proc_cs3_write(struct file * file, const char * buffer,
-			  size_t count, loff_t *ppos)
-{
-        unsigned long newRegValue;
-	char *endp;
-
-        newRegValue = simple_strtoul(buffer,&endp,0);
-	set_cs3( newRegValue );
-        return (count+endp-buffer);
-}
-
-#endif
- 
-static int __init cs3_init(void)
-{
-
-#ifdef CONFIG_PROC_FS
-	struct proc_dir_entry *proc_cs3 = create_proc_entry("CS3", 0, 0);
-	if (proc_cs3)
-	{
-		proc_cs3->read_proc = proc_cs3_read;
-		proc_cs3->write_proc = (void*)proc_cs3_write;
-	}
-#endif
-
-
-
-	return 0;
-}
- 
-arch_initcall(cs3_init);
-
 static void simpad_power_off(void)
 {
 	local_irq_disable(); // was cli
@@ -216,9 +183,31 @@
 
 }
 
+
+/*
+ * MediaQ Video Device
+ */
+static struct platform_device simpad_mq200fb = {
+	.name = "simpad-mq200",
+	.id   = 0,
+};
+
+static struct platform_device *devices[] __initdata = {
+	&simpad_mq200fb
+};
+
+
+
 static int __init simpad_init(void)
 {
-	set_power_off_handler( simpad_power_off );
+	int ret;
+
+	pm_power_off = simpad_power_off;
+
+	ret = platform_add_devices(devices, ARRAY_SIZE(devices));
+	if(ret)
+		printk(KERN_WARNING "simpad: Unable to register mq200 framebuffer device");
+
 	return 0;
 }
 
@@ -226,10 +215,10 @@
 
 
 MACHINE_START(SIMPAD, "Simpad")
-	MAINTAINER("Juergen Messerer")
+	MAINTAINER("Holger Freyther")
 	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
         BOOT_PARAMS(0xc0000100)
 	MAPIO(simpad_map_io)
 	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
+	.timer		= &sa1100_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/sleep.S b/arch/arm/mach-sa1100/sleep.S
--- a/arch/arm/mach-sa1100/sleep.S	2004-12-24 13:37:44 -08:00
+++ b/arch/arm/mach-sa1100/sleep.S	2004-12-24 13:37:44 -08:00
@@ -70,12 +70,12 @@
 	@ delay 90us and set CPU PLL to lowest speed
 	@ fixes resume problem on high speed SA1110
 	mov	r0, #90
-	bl	udelay
+	bl	__udelay
 	ldr	r0, =PPCR
 	mov	r1, #0
 	str	r1, [r0]
 	mov	r0, #90
-	bl	udelay
+	bl	__udelay
 
 	/*
 	 * SA1110 SDRAM controller workaround.  register values:
diff -Nru a/arch/arm/mach-sa1100/stork.c b/arch/arm/mach-sa1100/stork.c
--- a/arch/arm/mach-sa1100/stork.c	2004-12-24 13:37:02 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,348 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/stork.c
- *
- *     Copyright (C) 2001 Ken Gordon
- *
- * 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/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-#include <linux/delay.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-#include <asm/keyboard.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-#include <linux/serial_core.h>
-
-#include "generic.h"
-
-
-#define STORK_VM_BASE_CS1 0xf0000000		/* where we get mapped (virtual) */
-#define STORK_VM_OFF_CS1 0x08000000             /* where we started mapping (physical) */
-#define STORK_VM_ADJUST_CS1 (STORK_VM_BASE_CS1-STORK_VM_OFF_CS1) /* add to the phys to get virt */
-
-#define STORK_VM_BASE_CS2 0xf1000000		/* where we get mapped (virtual) */
-#define STORK_VM_OFF_CS2  0x10000000             /* where we started mapping (physical) */
-#define STORK_VM_ADJUST_CS2 (STORK_VM_BASE_CS2-STORK_VM_OFF_CS2) /* add to the phys to get virt */
-
-static int debug = 0;
-
-static int storkLatchA = 0;
-static int storkLatchB = 0;
-static int storkLCDCPLD[4] = { 0, 0, 0, 0};
-
-int
-storkSetLatchA(int bits)
-{
-    int ret = storkLatchA;
-    volatile unsigned int *latch = (unsigned int *)(STORK_LATCH_A_ADDR+STORK_VM_ADJUST_CS1);
-
-    storkLatchA |= bits;
-    *latch = storkLatchA;
-    return ret;
-}
-
-int
-storkClearLatchA(int bits)
-{
-    int ret = storkLatchA;
-    volatile unsigned int *latch = (unsigned int *)(STORK_LATCH_A_ADDR+STORK_VM_ADJUST_CS1);
-
-    storkLatchA &= ~bits;
-    *latch = storkLatchA;
-    return ret;
-}
-
-int
-storkSetLCDCPLD(int which, int bits)
-{
-    int ret = storkLCDCPLD[which];
-    volatile unsigned int *latch = (unsigned int *)(STORK_LCDCPLD_BASE_ADDR+STORK_VM_ADJUST_CS2 + 0x20*which);
-
-    storkLCDCPLD[which] |= bits;
-    *latch = storkLCDCPLD[which];
-    return ret;
-}
-
-
-/* NB we don't shadow these 'cos there is no relation between the data written and the data read */
-/* ie the read registers are read only and the write registers write only */
-
-int
-storkGetLCDCPLD(int which)
-{
-    volatile unsigned int *latch = (unsigned int *)(STORK_LCDCPLD_BASE_ADDR+STORK_VM_ADJUST_CS2 + 0x20*which);
-    return *latch;
-}
-
-int
-storkClearLCDCPLD(int which, int bits)
-{
-    int ret = storkLCDCPLD[which];
-    volatile unsigned int *latch = (unsigned int *)(STORK_LCDCPLD_BASE_ADDR+STORK_VM_ADJUST_CS2 + 0x20*which);
-
-    storkLCDCPLD[which] &= ~bits;
-    *latch = storkLCDCPLD[which];
-    return ret;
-}
-
-int
-storkSetLatchB(int bits)
-{
-    int ret = storkLatchB;
-    char buf[100];
-
-    volatile unsigned int *latch = (unsigned int *)(STORK_LATCH_B_ADDR+STORK_VM_ADJUST_CS1);
-    sprintf(buf, "%s: bits %04x\n", __FUNCTION__, bits);
-    if (debug) printk(buf);
-
-    storkLatchB |= bits;
-    *latch = storkLatchB;
-    return ret;
-}
-
-int
-storkClearLatchB(int bits)
-{
-    int ret = storkLatchB;
-    char buf[100];
-
-    volatile unsigned int *latch = (unsigned int *)(STORK_LATCH_B_ADDR+STORK_VM_ADJUST_CS1);
-    sprintf(buf, "%s: bits %04x\n", __FUNCTION__, bits);
-    if (debug) printk(buf);
-
-    storkLatchB &= ~bits;
-    *latch = storkLatchB;
-    return ret;
-}
-
-void
-storkSetGPIO(int bits)
-{
-    char buf[100];
-
-    sprintf(buf, "%s: bits %04x\n", __FUNCTION__, bits);
-    if (debug) printk(buf);
-    GPSR = bits;
-}
-
-void
-storkClearGPIO(int bits)
-{
-    char buf[100];
-
-    sprintf(buf, "%s: bits %04x\n", __FUNCTION__, bits);
-    if (debug) printk(buf);
-    GPCR = bits;
-}
-
-int
-storkGetGPIO()
-{
-    char buf[100];
-
-    int bits = GPLR;
-
-    sprintf(buf, "%s: bits %04x\n", __FUNCTION__, bits);
-    if (debug) printk(buf);
-
-    return bits;
-}
-
-/* this will return the current state of the hardware ANDED with the given bits
-   so NE => at least one bit was set, but maybe not all of them! */
-
-int
-storkTestGPIO(int bits)
-{
-    int val = storkGetGPIO();
-    char buf[100];
-
-    sprintf(buf, "%s: bits %04x val %04x\n", __FUNCTION__, bits, val);
-    if (debug) printk(buf);
-
-    return (val & bits);
-}
-
-/* NB the touch screen and the d to a use the same data and clock out pins */
-
-static void storkClockTS(void)
-{
-    storkSetLatchB(STORK_TOUCH_SCREEN_DCLK);
-    udelay(10);			 /* hmm wait 200ns (min) - ok this ought to be udelay(1) but that doesn't get */
-				 /* consistent values so I'm using 10 (urgh) */
-    storkClearLatchB(STORK_TOUCH_SCREEN_DCLK);
-    udelay(10);
-}
-
-
-int				/* there is always a 12 bit read after the write! */
-storkClockByteToTS(int byte)
-{
-    int timeout = 10000;   /* stuff is meant to happen in 60ns */
-    int bit;
-    int result = 0;
-
-    if (debug) printk("storkClockByteToTS: %02x\n", byte);
-
-    storkClearLatchB(STORK_TOUCH_SCREEN_CS);  /* slect touch screen */
-
-    while (timeout-- > 0)
-        if (storkTestGPIO(GPIO_STORK_TOUCH_SCREEN_BUSY) == 0)
-            break;
-
-    if (timeout < 0) {
-        printk("storkClockBitToTS: GPIO_STORK_TOUCH_SCREEN_BUSY didn't go low!\n\r");
-/* ignore error for now        return; */
-    }
-
-/* clock out the given byte */
-
-    for (bit = 0x80; bit > 0; bit = bit >> 1) {
-
-        if ((bit & byte) == 0)
-            storkClearLatchB(STORK_TOUCH_SCREEN_DIN);
-        else
-            storkSetLatchB(STORK_TOUCH_SCREEN_DIN);
-
-        storkClockTS();
-    }
-
-    storkClockTS();  /* will be busy for at a clock  (at least) */
-
-    for (timeout = 10000; timeout >= 0; timeout--)
-        if (storkTestGPIO(GPIO_STORK_TOUCH_SCREEN_BUSY) == 0)
-            break;
-
-    if (timeout < 0) {
-        printk("storkClockBitToTS: 2nd GPIO_STORK_TOUCH_SCREEN_BUSY didn't go low!\n\r");
-/* ignore error for now        return; */
-    }
-
-/* clock in the result */
-
-    for (bit = 0x0800; bit > 0; bit = bit >> 1) {
-
-        if (storkTestGPIO(GPIO_STORK_TOUCH_SCREEN_DATA))
-            result |= bit;
-
-        storkClockTS();
-    }
-
-    storkSetLatchB(STORK_TOUCH_SCREEN_CS);  /* unselect touch screen */
-
-    return result;
-}
-
-void
-storkClockShortToDtoA(int word)
-{
-    int bit;
-
-    storkClearLatchB(STORK_DA_CS);  /* select D to A */
-
-/* clock out the given byte */
-
-    for (bit = 0x8000; bit > 0; bit = bit >> 1) {
-
-        if ((bit & word) == 0)
-            storkClearLatchB(STORK_TOUCH_SCREEN_DIN);
-        else
-            storkSetLatchB(STORK_TOUCH_SCREEN_DIN);
-
-        storkClockTS();
-    }
-
-    storkSetLatchB(STORK_DA_CS);  /* unselect D to A */
-
-/* set DTOA#_LOAD low then high (min 20ns) to transfer value to D to A */
-    storkClearLatchB(STORK_DA_LD);
-    storkSetLatchB(STORK_DA_LD);
-}
-
-
-
-void
-storkInitTSandDtoA(void)
-{
-    storkClearLatchB(STORK_TOUCH_SCREEN_DCLK | STORK_TOUCH_SCREEN_DIN);
-    storkSetLatchB(STORK_TOUCH_SCREEN_CS | STORK_DA_CS | STORK_DA_LD);
-    storkClockByteToTS(0xE2);	 	/* turn on the reference */
-    storkClockShortToDtoA(0x8D00);	/* turn on the contrast */
-    storkClockShortToDtoA(0x0A00);	/* turn on the brightness */
-}
-
-static void stork_lcd_power(int on)
-{
-	if (on) {
-		storkSetLCDCPLD(0, 1);
-		storkSetLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON);
-	} else {
-		storkSetLCDCPLD(0, 0);
-		storkClearLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON);
-	}
-}
-
-struct map_desc stork_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { STORK_VM_BASE_CS1, STORK_VM_OFF_CS1, 0x01000000, MT_DEVICE }, /* EGPIO 0 */
-  { 0xf1000000, 0x10000000, 0x02800000, MT_DEVICE }, /* static memory bank 2 */
-  { 0xf3800000, 0x40000000, 0x00800000, MT_DEVICE }  /* static memory bank 4 */
-};
-
-int __init
-stork_map_io(void)
-{
-    sa1100_map_io();
-    iotable_init(stork_io_desc, ARRAY_SIZE(stork_io_desc));
-
-    sa1100_register_uart(0, 1);	/* com port */
-    sa1100_register_uart(1, 2);
-    sa1100_register_uart(2, 3);
-
-    printk("Stork driver initing latches\r\n");
-
-    storkClearLatchB(STORK_RED_LED);	/* let's have the red LED on please */
-    storkSetLatchB(STORK_YELLOW_LED);
-    storkSetLatchB(STORK_GREEN_LED);
-    storkSetLatchA(STORK_BATTERY_CHARGER_ON);
-    storkSetLatchA(STORK_LCD_5V_POWER_ON);
-    storkSetLatchA(STORK_LCD_3V3_POWER_ON);
-
-    storkInitTSandDtoA();
-
-    sa1100fb_lcd_power = stork_lcd_power;
-
-    return 0;
-}
-
-
-MACHINE_START(STORK, "Stork Technologies prototype")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	BOOT_PARAMS(0xc0000100)
-	MAPIO(stork_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
-
-
-EXPORT_SYMBOL(storkTestGPIO);
-EXPORT_SYMBOL(storkSetGPIO);
-EXPORT_SYMBOL(storkClearGPIO);
-EXPORT_SYMBOL(storkSetLatchA);
-EXPORT_SYMBOL(storkClearLatchA);
-EXPORT_SYMBOL(storkSetLatchB);
-EXPORT_SYMBOL(storkClearLatchB);
-EXPORT_SYMBOL(storkClockByteToTS);
-EXPORT_SYMBOL(storkClockShortToDtoA);
-EXPORT_SYMBOL(storkGetLCDCPLD);
-EXPORT_SYMBOL(storkSetLCDCPLD);
diff -Nru a/arch/arm/mach-sa1100/system3.c b/arch/arm/mach-sa1100/system3.c
--- a/arch/arm/mach-sa1100/system3.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,474 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/system3.c
- *
- * Copyright (C) 2001 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
- *
- * $Id: system3.c,v 1.1.6.1 2001/12/04 17:28:06 seletz Exp $
- *
- * This file contains all PT Sytsem 3 tweaks. Based on original work from
- * Nicolas Pitre's assabet fixes
- *
- * 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.
- *
- * $Log: system3.c,v $
- * Revision 1.1.6.1  2001/12/04 17:28:06  seletz
- * - merged from previous branch
- *
- * Revision 1.1.4.3  2001/12/04 15:16:31  seletz
- * - merged from linux_2_4_13_ac5_rmk2
- *
- * Revision 1.1.4.2  2001/11/19 17:18:57  seletz
- * - more code cleanups
- *
- * Revision 1.1.4.1  2001/11/16 13:52:05  seletz
- * - PT Digital Board Support Code
- *
- * Revision 1.1.2.2  2001/11/05 16:46:18  seletz
- * - cleanups
- *
- * Revision 1.1.2.1  2001/10/15 16:00:43  seletz
- * - first revision working with new board
- *
- *
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/cpufreq.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/setup.h>
-#include <asm/irq.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/irq.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include <linux/serial_core.h>
-
-#include "generic.h"
-#include <asm/hardware/sa1111.h>
-
-#define DEBUG 1
-
-#ifdef DEBUG
-#	define DPRINTK( x, args... )	printk( "%s: line %d: "x, __FUNCTION__, __LINE__, ## args  );
-#else
-#	define DPRINTK( x, args... )	/* nix */
-#endif
-
-/**********************************************************************
- *  prototypes
- */
-
-/* init funcs */
-static int __init system3_init(void);
-static void __init system3_init_irq(void);
-static void __init system3_map_io(void);
-
-static u_int system3_get_mctrl(struct uart_port *port);
-static void system3_set_mctrl(struct uart_port *port, u_int mctrl);
-static void system3_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
-static int sdram_notifier(struct notifier_block *nb, unsigned long event, void *data);
-
-static void system3_lcd_power(int on);
-static void system3_backlight_power(int on);
-
-
-/**********************************************************************
- *  global data
- */
-
-/**********************************************************************
- *  static data
- */
-
-static struct map_desc system3_io_desc[] __initdata = {
- /* virtual     physical        length      type */
-  { 0xf3000000, PT_CPLD_BASE,   0x00100000, MT_DEVICE }, /* System Registers */
-  { 0xf4000000, PT_SA1111_BASE, 0x00100000, MT_DEVICE }  /* SA-1111 */
-};
-
-static struct sa1100_port_fns system3_port_fns __initdata = {
-	.set_mctrl	= system3_set_mctrl,
-	.get_mctrl	= system3_get_mctrl,
-	.pm		= system3_uart_pm,
-};
-
-static struct notifier_block system3_clkchg_block = {
-	.notifier_call	= sdram_notifier,
-};
-
-/**********************************************************************
- *  Static functions
- */
-
-static void __init system3_map_io(void)
-{
-	DPRINTK( "%s\n", "START" );
-	sa1100_map_io();
-	iotable_init(system3_io_desc, ARRAY_SIZE(system3_io_desc));
-
-	sa1100_register_uart_fns(&system3_port_fns);
-	sa1100_register_uart(0, 1);	/* com port */
-	sa1100_register_uart(1, 2);
-	sa1100_register_uart(2, 3);	/* radio module */
-
-	Ser1SDCR0 |= SDCR0_SUS;
-}
-
-
-/*********************************************************************
- * Install IRQ handler
- */
-static void
-system3_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
-{
-	u_char irr;
-
-	//DPRINTK( "irq=%d, desc=%p, regs=%p\n", irq, desc, regs );
-
-	while (1) {
-		struct irqdesc *d;
-
-		/*
-		 * Acknowledge the parent IRQ.
-		 */
-		desc->chip->ack(irq);
-
-		/*
-		 * Read the interrupt reason register.  Let's have all
-		 * active IRQ bits high.  Note: there is a typo in the
-		 * Neponset user's guide for the SA1111 IRR level.
-		 */
-		//irr = PT_IRQSR & (PT_IRR_LAN | PT_IRR_SA1111);
-		irr = PT_IRQSR & (PT_IRR_SA1111);
-
-		/* SMC IRQ is low-active, so "switch" bit over */
-		//irr ^= (PT_IRR_LAN);
-
-		//DPRINTK( "irr=0x%02x\n", irr );
-
-		if ((irr & (PT_IRR_LAN | PT_IRR_SA1111)) == 0)
-			break;
-
-		/*
-		 * Since there is no individual mask, we have to
-		 * mask the parent IRQ.  This is safe, since we'll
-		 * recheck the register for any pending IRQs.
-		 */
-		if (irr & (PT_IRR_LAN)) {
-			desc->chip->mask(irq);
-
-			if (irr & PT_IRR_LAN) {
-				//DPRINTK( "SMC9196, irq=%d\n", IRQ_SYSTEM3_SMC9196 );
-				d = irq_desc + IRQ_SYSTEM3_SMC9196;
-				d->handle(IRQ_SYSTEM3_SMC9196, d, regs);
-			}
-
-#if 0 /* no SSP yet on system 4 */
-			if (irr & IRR_USAR) {
-				d = irq_desc + IRQ_NEPONSET_USAR;
-				d->handle(IRQ_NEPONSET_USAR, d, regs);
-			}
-#endif
-
-			desc->chip->unmask(irq);
-		}
-
-		if (irr & PT_IRR_SA1111) {
-			//DPRINTK( "SA1111, irq=%d\n", IRQ_SYSTEM3_SA1111 );
-			d = irq_desc + IRQ_SYSTEM3_SA1111;
-			d->handle(IRQ_SYSTEM3_SA1111, d, regs);
-		}
-	}
-}
-
-static void __init system3_init_irq(void)
-{
-	/*
-	 * Install handler for GPIO25.
-	 */
-	set_irq_type(IRQ_GPIO25, IRQT_RISING);
-	set_irq_chained_handler(IRQ_GPIO25, system3_irq_handler);
-
-	/*
-	 * install eth irq
-	 */
-	set_irq_handler(IRQ_SYSTEM3_SMC9196, do_simple_IRQ);
-	set_irq_flags(IRQ_SYSTEM3_SMC9196, IRQF_VALID | IRQF_PROBE);
-}
-
-/**********************************************************************
- * On system 3 limit cpu frequency to 206 Mhz
- */
-static int sdram_notifier(struct notifier_block *nb, unsigned long event,
-		void *data)
-{
-	struct cpufreq_policy *policy = data;
-	switch (event) {
-		case CPUFREQ_ADJUST:
-		case CPUFREQ_INCOMPATIBLE:
-			cpufreq_verify_within_limits(policy, 147500, 206000);
-			break;
-		case CPUFREQ_NOTIFY:
-			if ((policy->min < 147500) || 
-			    (policy->max > 206000))
-				panic("cpufreq failed to limit the speed\n");
-			break;
-	}
-	return 0;
-}
-
-/**
- *	system3_uart_pm - powermgmt callback function for system 3 UART
- *	@port: uart port structure
- *	@state: pm state
- *	@oldstate: old pm state
- *
- */
-static void system3_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
-{
-	/* TODO: switch on/off uart in powersave mode */
-}
-
-/*
- * Note! this can be called from IRQ context.
- * FIXME: Handle PT Digital Board CTRL regs irq-safe.
- *
- * NB: system3 uses COM_RTS and COM_DTR for both UART1 (com port)
- * and UART3 (radio module).  We only handle them for UART1 here.
- */
-static void system3_set_mctrl(struct uart_port *port, u_int mctrl)
-{
-	if (port->mapbase == _Ser1UTCR0) {
-		u_int set = 0, clear = 0;
-
-		if (mctrl & TIOCM_RTS)
-			set |= PT_CTRL2_RS1_RTS;
-		else
-			clear |= PT_CTRL2_RS1_RTS;
-
-		if (mctrl & TIOCM_DTR)
-			set |= PT_CTRL2_RS1_DTR;
-		else
-			clear |= PT_CTRL2_RS1_DTR;
-
-		PTCTRL2_clear(clear);
-		PTCTRL2_set(set);
-	}
-}
-
-static u_int system3_get_mctrl(struct uart_port *port)
-{
-	u_int ret = 0;
-	u_int irqsr = PT_IRQSR;
-
-	/* need 2 reads to read current value */
-	irqsr = PT_IRQSR;
-
-	/* TODO: check IRQ source register for modem/com
-	 status lines and set them correctly. */
-
-	ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
-
-	return ret;
-}
-
-/**
- *	system3_lcd_backlight_on - switch system 3 lcd backlight on
- *
- */
-int system3_lcd_backlight_on( void )
-{
-	PTCTRL0_set( PT_CTRL0_LCD_BL );
-	return 0;
-}
-
-/**
- *	system3_lcd_backlight_off - switch system 3 lcd backlight off
- *
- */
-static void system3_lcd_backlight_off(void)
-{
-	PTCTRL0_clear( PT_CTRL0_LCD_BL );
-}
-
-/**
- *	system3_lcd_on - switch system 3 lcd on
- *
- */
-static void system3_lcd_on(void)
-{
-	DPRINTK( "%s\n", "START" );
-	PTCTRL0_set( PT_CTRL0_LCD_EN );
-
-	/* brightness / contrast */
-	sa1111_enable_device(SKPCR_PWMCLKEN);
-	PB_DDR = 0xFFFFFFFF;
-	SKPEN0 = 1;
-	SKPEN1 = 1;
-}
-
-/**
- *	system3_lcd_off - switch system 3 lcd off
- *
- */
-static void system3_lcd_off(void)
-{
-	DPRINTK( "%s\n", "START" );
-	PTCTRL0_clear( PT_CTRL0_LCD_EN );
-	SKPEN0 = 0;
-	SKPEN1 = 0;
-	sa1111_disable_device(SKPCR_PWMCLKEN);
-}
-
-/**
- *	system3_lcd_contrast - set system 3 contrast
- *	@value:		the new contrast
- *
- */
-static void system3_lcd_contrast(unsigned char value)
-{
-	DPRINTK( "value=0x%02x\n", value );
-	SYS3LCDCONTR = value;
-}
-
-/**
- *	system3_lcd_brightness - set system 3 brightness
- *	@value:		the new brightness
- *
- */
-static void system3_lcd_brightness(unsigned char value)
-{
-	DPRINTK( "value=0x%02x\n", value );
-	SYS3LCDBRIGHT = value;
-}
-
-static void system3_lcd_power(int on)
-{
-	if (on) {
-		system3_lcd_on();
-	} else {
-		system3_lcd_off();
-	}
-}
-
-static void system3_backlight_power(int on)
-{
-	if (on) {
-		system3_lcd_backlight_on();
-		system3_lcd_contrast(0x95);
-		system3_lcd_brightness(240);
-	} else {
-		system3_lcd_backlight_off();
-	}
-}
-
-static struct resource sa1111_resources[] = {
-	[0] = {
-		.start		= PT_SA1111_BASE,
-		.end		= PT_SA1111_BASE + 0x00001fff,
-		.flags		= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start		= IRQ_SYSTEM3_SA1111,
-		.end		= IRQ_SYSTEM3_SA1111,
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-
-static u64 sa1111_dmamask = 0xffffffffUL;
-
-static struct platform_device sa1111_device = {
-	.name		= "sa1111",
-	.id		= 0,
-	.dev		= {
-		.dma_mask = &sa1111_dmamask,
-		.coherent_dma_mask = 0xffffffff,
-	},
-	.num_resources	= ARRAY_SIZE(sa1111_resources),
-	.resource	= sa1111_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-	&sa1111_device,
-};
-
-static int __init system3_init(void)
-{
-	int ret = 0;
-	DPRINTK( "%s\n", "START" );
-
-	if ( !machine_is_pt_system3() ) {
-		ret = -EINVAL;
-		goto DONE;
-	}
-
-	sa1100fb_lcd_power = system3_lcd_power;
-	sa1100fb_backlight_power = system3_backlight_power;
-
-	/* init control register */
-	PT_CTRL0 = PT_CTRL0_INIT;
-	PT_CTRL1 = 0x02;
-	PT_CTRL2 = 0x00;
-	DPRINTK( "CTRL[0]=0x%02x\n", PT_CTRL0 );
-	DPRINTK( "CTRL[1]=0x%02x\n", PT_CTRL1 );
-	DPRINTK( "CTRL[2]=0x%02x\n", PT_CTRL2 );
-
-	/*
-	 * Ensure that the memory bus request/grant signals are setup,
-	 * and the grant is held in its inactive state.
-	 */
-	sa1110_mb_disable();
-
-	system3_init_irq();
-
-	/*
-	 * Probe for a SA1111.
-	 */
-	ret = platform_add_devices(devices, ARRAY_SIZE(devices));
-	if (ret < 0) {
-		printk( KERN_WARNING"PT Digital Board: no SA1111 found!\n" );
-		goto DONE;
-	}
-
-#ifdef CONFIG_CPU_FREQ
-	ret = cpufreq_register_notifier(&system3_clkchg_block);
-	if ( ret != 0 ) {
-		printk( KERN_WARNING"PT Digital Board: could not register clock scale callback\n" );
-		goto DONE;
-	}
-#endif
-
-
-	ret = 0;
-DONE:
-	DPRINTK( "ret=%d\n", ret );
-	return ret;
-}
-
-/**********************************************************************
- *  Exported Functions
- */
-
-/**********************************************************************
- *  kernel magic macros
- */
-arch_initcall(system3_init);
-
-MACHINE_START(PT_SYSTEM3, "PT System 3")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	BOOT_PARAMS(0xc0000100)
-	MAPIO(system3_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
--- a/arch/arm/mach-sa1100/time.c	2004-12-24 13:37:33 -08:00
+++ b/arch/arm/mach-sa1100/time.c	2004-12-24 13:37:33 -08:00
@@ -84,12 +84,16 @@
 {
 	unsigned int next_match;
 
+	write_seqlock(&xtime_lock);
+
 	do {
 		timer_tick(regs);
 		OSSR = OSSR_M0;  /* Clear match on timer 0 */
 		next_match = (OSMR0 += LATCH);
 	} while ((signed long)(next_match - OSCR) <= 0);
 
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -99,11 +103,10 @@
 	.handler	= sa1100_timer_interrupt
 };
 
-void __init sa1100_init_time(void)
+static void __init sa1100_timer_init(void)
 {
 	struct timespec tv;
 
-	gettimeoffset = sa1100_gettimeoffset;
 	set_rtc = sa1100_set_rtc;
 
 	tv.tv_nsec = 0;
@@ -117,3 +120,40 @@
 	OSCR = 0;		/* initialize free-running timer, force first match */
 }
 
+#ifdef CONFIG_PM
+unsigned long osmr[4], oier;
+
+static void sa1100_timer_suspend(void)
+{
+	osmr[0] = OSMR0;
+	osmr[1] = OSMR1;
+	osmr[2] = OSMR2;
+	osmr[3] = OSMR3;
+	oier = OIER;
+}
+
+static void sa1100_timer_resume(void)
+{
+	OSSR = 0x0f;
+	OSMR0 = osmr[0];
+	OSMR1 = osmr[1];
+	OSMR2 = osmr[2];
+	OSMR3 = osmr[3];
+	OIER = oier;
+
+	/*
+	 * OSMR0 is the system timer: make sure OSCR is sufficiently behind
+	 */
+	OSCR = OSMR0 - LATCH;
+}
+#else
+#define sa1100_timer_suspend NULL
+#define sa1100_timer_resume NULL
+#endif
+
+struct sys_timer sa1100_timer = {
+	.init		= sa1100_timer_init,
+	.suspend	= sa1100_timer_suspend,
+	.resume		= sa1100_timer_resume,
+	.offset		= sa1100_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-sa1100/trizeps.c b/arch/arm/mach-sa1100/trizeps.c
--- a/arch/arm/mach-sa1100/trizeps.c	2004-12-24 13:37:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,232 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/trizeps.c
- *
- * Authors:
- * Andreas Hofer <ho@dsa-ac.de>,
- * Peter Lueg <pl@dsa-ac.de>,
- * Guennadi Liakhovetski <gl@dsa-ac.de>
- *
- * This file contains all Trizeps-specific tweaks.
- *
- * 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/init.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/tty.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/pm.h>
-
-#include <asm/mach-types.h>
-#include <asm/hardware.h>
-#include <asm/arch/trizeps.h>
-#include <asm/setup.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/irq.h>
-#include <asm/mach/serial_sa1100.h>
-#include <linux/serial_core.h>
-#include <linux/serial_reg.h>
-#include <asm/arch/serial.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/arch/irqs.h>
-
-#include "generic.h"
-
-#undef DEBUG_TRIZEPS
-#ifdef DEBUG_TRIZEPS
-#define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ## args)
-#else
-#define DPRINTK( x... )
-#endif
-
-static struct tri_uart_cts_data_t tri_uart_cts_data[] = {
-	{ TRIZEPS_GPIO_UART1_CTS, 0, NULL, NULL,"int. UART1 cts" },
-	{ TRIZEPS_GPIO_UART2_CTS, 0, NULL, NULL,"int. UART2 cts" },
-	{ TRIZEPS_GPIO_UART3_CTS, 0, NULL, NULL,"int. UART3 cts" }
-};
-
-static void trizeps_cts_intr(int irq, void *dev_id, struct pt_regs *regs)
-{
-	struct tri_uart_cts_data_t * uart_data = (struct tri_uart_cts_data_t *)dev_id;
-	int cts = (!(GPLR & uart_data->cts_gpio));
-
-	/* NOTE: I suppose that we will not get any interrupts
-	   if the GPIO is not changed, so maybe
-	   the cts_prev_state can be removed ... */
-	if (cts != uart_data->cts_prev_state) {
-
-		uart_data->cts_prev_state = cts;
-		uart_handle_cts_change(uart_data->port, cts);
-		DPRINTK("(IRQ %d) changed (cts=%d) stop=%d\n",
-			irq, cts, uart_data->info->tty->hw_stopped);
-	}
-}
-
-static int
-trizeps_register_cts_intr(int gpio,
-			  int irq,
-			  struct tri_uart_cts_data_t *uart_data)
-{
-	int ret = 0;
-
-	if(irq != NO_IRQ)
-	{
-		set_irq_type(irq, IRQT_BOTHEDGE);
-
-		ret = request_irq(irq, trizeps_cts_intr,
-				  SA_INTERRUPT, uart_data->name, uart_data);
-		if (ret)
-			printk(KERN_ERR "uart_open: failed to register CTS irq (%d)\n", ret);
-	}
-	return ret;
-}
-
-static void trizeps_set_mctrl(struct uart_port *port, u_int mctrl)
-{
-	if (port->mapbase == _Ser1UTCR0)
-	{
-		/**** ttySA1  ****/
-		if (mctrl & TIOCM_RTS)
-			GPCR |= TRIZEPS_GPIO_UART1_RTS;
-		else
-			GPSR |= TRIZEPS_GPIO_UART1_RTS;
-
-		DPRINTK("2 ttySA%d Set RTS %s\n",port->line,
-			mctrl & TIOCM_RTS ? "low" : "high");
-
-	}
-	else if (port->mapbase == _Ser3UTCR0)
-	{
-		/**** ttySA0  ****/
-	}
-	else
-	{
-		/**** ttySA2  ****/
-	}
-}
-
-static u_int trizeps_get_mctrl(struct uart_port *port)
-{
-	int result = TIOCM_CD | TIOCM_DSR;
-
-	if (port->mapbase == _Ser1UTCR0)
-	{
-		if (!(GPLR & TRIZEPS_GPIO_UART1_CTS))
-			result |= TIOCM_CTS;
-	}
-	else if (port->mapbase == _Ser2UTCR0)
-	{
-		result |= TIOCM_CTS;
-	}
-	else if (port->mapbase == _Ser3UTCR0)
-	{
-		result |= TIOCM_CTS;
-	}
-	else
-	{
-		result = TIOCM_CTS;
-	}
-
-	DPRINTK(" ttySA%d %s%s%s\n",port->line,
-		result & TIOCM_CD  ? "CD "  : "",
-		result & TIOCM_CTS ? "CTS " : "",
-		result & TIOCM_DSR ? "DSR " : "");
-
-	return result;
-}
-
-static struct sa1100_port_fns trizeps_port_fns __initdata = {
-	.set_mctrl =	trizeps_set_mctrl,
-	.get_mctrl =	trizeps_get_mctrl,
-};
-
-static void trizeps_power_off(void)
-{
-	printk("trizeps power off\n");
-	mdelay(100);
-	cli();
-	/* disable internal oscillator, float CS lines */
-	PCFR = (PCFR_OPDE | PCFR_FP | PCFR_FS);
-	/* enable wake-up on GPIO0 (Assabet...) */
-	PWER = GFER = GRER = 1;
-	/*
-	 * set scratchpad to zero, just in case it is used as a
-	 * restart address by the bootloader.
-	 */
-	PSPR = 0;
-
-	/*
-	 *  Power off
-	 *  -> disconnect AKku
-	 */
-	TRIZEPS_BCR_set(TRIZEPS_BCR0, TRIZEPS_MFT_OFF);
-
-	/*
-	 * if power supply no Akku
-	 * -> enter sleep mode
-	 */
-	PMCR = PMCR_SF;
-}
-
-static int __init trizeps_init(void)
-{
-	if (!machine_is_trizeps())
-		return -EINVAL;
-
-	DPRINTK(" \n");
-	pm_power_off = trizeps_power_off;
-
-	// Init UART2 for IrDA
-//	PPDR |= PPC_TXD2;           // Set TXD2 as output
-	Ser2UTCR4 = UTCR4_HSE;      // enable HSE
-	Ser2HSCR0 = 0;
-	Ser2HSSR0 = HSSR0_EIF | HSSR0_TUR | HSSR0_RAB | HSSR0_FRE;
-
-	/* Init MECR */
-	MECR = 0x00060006;
-
-	/* Set up external serial IRQs */
-	GAFR &= ~(GPIO_GPIO16 | GPIO_GPIO17);  // no alternate function
-	GPDR &= ~(GPIO_GPIO16 | GPIO_GPIO17);  // Set to Input
-	set_irq_type(IRQ_GPIO16, IRQT_RISING);
-	set_irq_type(IRQ_GPIO17, IRQT_RISING);
-
-	return 0;
-}
-
-__initcall(trizeps_init);
-
-static struct map_desc trizeps_io_desc[] __initdata = {
-	/* virtual	physical	length	type */
-	{ 0xF0000000l, 0x30000000l, 0x00800000l, MT_DEVICE },
-	{ 0xF2000000l, 0x38000000l, 0x00800000l, MT_DEVICE },
-};
-
-static void __init trizeps_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(trizeps_io_desc, ARRAY_SIZE(trizeps_io_desc));
-
-	sa1100_register_uart_fns(&trizeps_port_fns);
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-	sa1100_register_uart(2, 2);
-}
-
-MACHINE_START(TRIZEPS, "TRIZEPS")
-	MAINTAINER("DSA")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(trizeps_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/xp860.c b/arch/arm/mach-sa1100/xp860.c
--- a/arch/arm/mach-sa1100/xp860.c	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,93 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/xp860.c
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/pm.h>
-#include <linux/tty.h>
-#include <linux/ioport.h>
-
-#include <asm/hardware.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-#include <asm/hardware/sa1111.h>
-
-#include "generic.h"
-
-
-static void xp860_power_off(void)
-{
-	local_irq_disable();
-	GPDR |= GPIO_GPIO20;
-	GPSR = GPIO_GPIO20;
-	mdelay(1000);
-	GPCR = GPIO_GPIO20;
-	while(1);
-}
-
-static struct resource sa1111_resources[] = {
-	[0] = {
-		.start		= 0x40000000,
-		.end		= 0x40001fff,
-		.flags		= IORESOURCE_MEM,
-	},
-};
-
-static u64 sa1111_dmamask = 0xffffffffUL;
-
-static struct platform_device sa1111_device = {
-	.name		= "sa1111",
-	.id		= 0,
-	.dev		= {
-		.dma_mask = &sa1111_dmamask,
-		.coherent_dma_mask = 0xffffffff,
-	},
-	.num_resources	= ARRAY_SIZE(sa1111_resources),
-	.resource	= sa1111_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-	&sa1111_device,
-};
-
-/*
- * Note: I replaced the sa1111_init() without the full SA1111 initialisation
- * because this machine doesn't appear to use the DMA features.  If this is
- * wrong, please look at neponset.c to fix it properly.
- */
-static int __init xp860_init(void)
-{
-	pm_power_off = xp860_power_off;
-
-	return platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-arch_initcall(xp860_init);
-
-static struct map_desc xp860_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x10000000, 0x00100000, MT_DEVICE }, /* SCSI */
-  { 0xf1000000, 0x18000000, 0x00100000, MT_DEVICE }, /* LAN */
-  { 0xf4000000, 0x40000000, 0x00800000, MT_DEVICE }  /* SA-1111 */
-};
-
-static void __init xp860_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(xp860_io_desc, ARRAY_SIZE(xp860_io_desc));
-
-	sa1100_register_uart(0, 3);
-	sa1100_register_uart(1, 1);
-}
-
-MACHINE_START(XP860, "XP860")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	MAPIO(xp860_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-sa1100/yopy.c b/arch/arm/mach-sa1100/yopy.c
--- a/arch/arm/mach-sa1100/yopy.c	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,95 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/yopy.c
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/setup.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include "generic.h"
-
-
-static spinlock_t egpio_lock = SPIN_LOCK_UNLOCKED;
-
-static unsigned long yopy_egpio =
-	GPIO_MASK(GPIO_CF_RESET) |
-	GPIO_MASK(GPIO_CLKDIV_CLR1) | GPIO_MASK(GPIO_CLKDIV_CLR2) |
-	GPIO_MASK(GPIO_SPEAKER_MUTE) | GPIO_MASK(GPIO_AUDIO_OPAMP_POWER);
-
-int yopy_gpio_test(unsigned int gpio)
-{
-	return ((yopy_egpio & (1 << gpio)) != 0);
-}
-
-void yopy_gpio_set(unsigned int gpio, int level)
-{
-	unsigned long flags, mask;
-
-	mask = 1 << gpio;
-
-	spin_lock_irqsave(&egpio_lock, flags);
-
-	if (level)
-		yopy_egpio |= mask;
-	else
-		yopy_egpio &= ~mask;
-	YOPY_EGPIO = yopy_egpio;
-
-	spin_unlock_irqrestore(&egpio_lock, flags);
-}
-
-EXPORT_SYMBOL(yopy_gpio_test);
-EXPORT_SYMBOL(yopy_gpio_set);
-
-static int __init yopy_hw_init(void)
-{
-	if (machine_is_yopy()) {
-		YOPY_EGPIO = yopy_egpio;
-
-		/* Enable Output */
-		PPDR |= PPC_L_BIAS;
-		PSDR &= ~PPC_L_BIAS;
-		PPSR |= PPC_L_BIAS;
-
-		YOPY_EGPIO = yopy_egpio;
-	}
-
-	return 0;
-}
-
-arch_initcall(yopy_hw_init);
-
-
-static struct map_desc yopy_io_desc[] __initdata = {
- /* virtual     physical    length      type */
-  { 0xf0000000, 0x48000000, 0x00300000, MT_DEVICE }, /* LCD */
-  { 0xf1000000, 0x10000000, 0x00100000, MT_DEVICE }  /* EGPIO */
-};
-
-static void __init yopy_map_io(void)
-{
-	sa1100_map_io();
-	iotable_init(yopy_io_desc, ARRAY_SIZE(yopy_io_desc));
-
-	sa1100_register_uart(0, 3);
-
-	set_GPIO_IRQ_edge(GPIO_UCB1200_IRQ, GPIO_RISING_EDGE);
-}
-
-
-MACHINE_START(YOPY, "Yopy")
-	MAINTAINER("G.Mate, Inc.")
-	BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-	BOOT_PARAMS(0xc0000100)
-	MAPIO(yopy_map_io)
-	INITIRQ(sa1100_init_irq)
-	INITTIME(sa1100_init_time)
-MACHINE_END
diff -Nru a/arch/arm/mach-shark/Makefile.boot b/arch/arm/mach-shark/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-shark/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2 @@
+   zreladdr-y	:= 0x08008000
+
diff -Nru a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c
--- a/arch/arm/mach-shark/core.c	2004-12-24 13:37:02 -08:00
+++ b/arch/arm/mach-shark/core.c	2004-12-24 13:37:02 -08:00
@@ -7,6 +7,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
+#include <linux/serial_8250.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -18,6 +19,46 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.iobase		= 0x3f8,
+		.irq		= 4,
+		.uartclk	= 1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.iobase		= 0x2f8,
+		.irq		= 3,
+		.uartclk	= 1843200,
+		.regshift	= 2,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= 0,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
+static int __init shark_init(void)
+{
+	int ret;
+
+	if (machine_is_shark())
+		ret = platform_device_register(&serial_device);
+
+	return ret;
+}
+
+arch_initcall(shark_init);
+
 extern void shark_init_irq(void);
 
 static struct map_desc shark_io_desc[] __initdata = {
@@ -35,8 +76,9 @@
 static irqreturn_t
 shark_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
+	write_seqlock(&xtime_lock);
 	timer_tick(regs);
-
+	write_sequnlock(&xtime_lock);
 	return IRQ_HANDLED;
 }
 
@@ -49,7 +91,7 @@
 /*
  * Set up timer interrupt, and return the current time in seconds.
  */
-void __init shark_init_time(void)
+static void __init shark_timer_init(void)
 {
         unsigned long flags;
 
@@ -60,6 +102,9 @@
 	setup_irq(IRQ_TIMER, &shark_timer_irq);
 }
 
+static struct sys_timer shark_timer = {
+	.init		= shark_timer_init,
+};
 
 MACHINE_START(SHARK, "Shark")
 	MAINTAINER("Alexander Schulz")
@@ -67,5 +112,5 @@
 	BOOT_PARAMS(0x08003000)
 	MAPIO(shark_map_io)
 	INITIRQ(shark_init_irq)
-	INITTIME(shark_init_time)
+	.timer		= &shark_timer,
 MACHINE_END
diff -Nru a/arch/arm/mach-versatile/Kconfig b/arch/arm/mach-versatile/Kconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-versatile/Kconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,16 @@
+menu "Versatile platform type"
+	depends on ARCH_VERSATILE
+
+config ARCH_VERSATILE_PB
+	bool "Support Versatile/PB platform"
+	default y
+	help
+	  Include support for the ARM(R) Versatile/PB platform.
+
+config MACH_VERSATILE_AB
+	bool "Support Versatile/AB platform"
+	default n
+	help
+	  Include support for the ARM(R) Versatile/AP platform.
+
+endmenu
diff -Nru a/arch/arm/mach-versatile/Makefile b/arch/arm/mach-versatile/Makefile
--- a/arch/arm/mach-versatile/Makefile	2004-12-24 13:36:17 -08:00
+++ b/arch/arm/mach-versatile/Makefile	2004-12-24 13:36:17 -08:00
@@ -3,3 +3,5 @@
 #
 
 obj-y					:= core.o clock.o
+obj-$(CONFIG_ARCH_VERSATILE_PB)		+= versatile_pb.o
+obj-$(CONFIG_MACH_VERSATILE_AB)		+= versatile_ab.o
diff -Nru a/arch/arm/mach-versatile/Makefile.boot b/arch/arm/mach-versatile/Makefile.boot
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-versatile/Makefile.boot	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,4 @@
+   zreladdr-y	:= 0x00008000
+params_phys-y	:= 0x00000100
+initrd_phys-y	:= 0x00800000
+
diff -Nru a/arch/arm/mach-versatile/clock.c b/arch/arm/mach-versatile/clock.c
--- a/arch/arm/mach-versatile/clock.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mach-versatile/clock.c	2004-12-24 13:36:18 -08:00
@@ -16,7 +16,7 @@
 
 #include <asm/semaphore.h>
 #include <asm/hardware/clock.h>
-#include <asm/hardware/icst525.h>
+#include <asm/hardware/icst307.h>
 
 #include "clock.h"
 
@@ -83,12 +83,12 @@
 int clk_set_rate(struct clk *clk, unsigned long rate)
 {
 	int ret = -EIO;
-#if 0 // Not yet
+
 	if (clk->setvco) {
-		struct icst525_vco vco;
+		struct icst307_vco vco;
 
-		vco = icst525_khz_to_vco(clk->params, rate / 1000);
-		clk->rate = icst525_khz(clk->params, vco) * 1000;
+		vco = icst307_khz_to_vco(clk->params, rate / 1000);
+		clk->rate = icst307_khz(clk->params, vco) * 1000;
 
 		printk("Clock %s: setting VCO reg params: S=%d R=%d V=%d\n",
 			clk->name, vco.s, vco.r, vco.v);
@@ -96,7 +96,6 @@
 		clk->setvco(clk, vco);
 		ret = 0;
 	}
-#endif
 	return ret;
 }
 EXPORT_SYMBOL(clk_set_rate);
diff -Nru a/arch/arm/mach-versatile/clock.h b/arch/arm/mach-versatile/clock.h
--- a/arch/arm/mach-versatile/clock.h	2004-12-24 13:36:56 -08:00
+++ b/arch/arm/mach-versatile/clock.h	2004-12-24 13:36:56 -08:00
@@ -9,16 +9,16 @@
  * published by the Free Software Foundation.
  */
 struct module;
-struct icst525_params;
+struct icst307_params;
 
 struct clk {
 	struct list_head	node;
 	unsigned long		rate;
 	struct module		*owner;
 	const char		*name;
-	const struct icst525_params *params;
+	const struct icst307_params *params;
 	void			*data;
-	void			(*setvco)(struct clk *, struct icst525_vco vco);
+	void			(*setvco)(struct clk *, struct icst307_vco vco);
 };
 
 int clk_register(struct clk *clk);
diff -Nru a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
--- a/arch/arm/mach-versatile/core.c	2004-12-24 13:36:48 -08:00
+++ b/arch/arm/mach-versatile/core.c	2004-12-24 13:36:48 -08:00
@@ -33,15 +33,17 @@
 #include <asm/mach-types.h>
 #include <asm/hardware/amba.h>
 #include <asm/hardware/amba_clcd.h>
+#include <asm/hardware/icst307.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
-#ifdef CONFIG_MMC
 #include <asm/mach/mmc.h>
-#endif
+
+#include "core.h"
+#include "clock.h"
 
 /*
  * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
@@ -111,19 +113,17 @@
 
 #if 1
 #define IRQ_MMCI0A	IRQ_VICSOURCE22
-#define IRQ_MMCI1A	IRQ_VICSOURCE23
 #define IRQ_AACI	IRQ_VICSOURCE24
 #define IRQ_ETH		IRQ_VICSOURCE25
 #define PIC_MASK	0xFFD00000
 #else
 #define IRQ_MMCI0A	IRQ_SIC_MMCI0A
-#define IRQ_MMCI1A	IRQ_SIC_MMCI1A
 #define IRQ_AACI	IRQ_SIC_AACI
 #define IRQ_ETH		IRQ_SIC_ETH
 #define PIC_MASK	0
 #endif
 
-static void __init versatile_init_irq(void)
+void __init versatile_init_irq(void)
 {
 	unsigned int i, value;
 
@@ -189,6 +189,10 @@
  { IO_ADDRESS(VERSATILE_SIC_BASE),   VERSATILE_SIC_BASE,   SZ_4K,      MT_DEVICE },
  { IO_ADDRESS(VERSATILE_VIC_BASE),   VERSATILE_VIC_BASE,   SZ_4K,      MT_DEVICE },
  { IO_ADDRESS(VERSATILE_SCTL_BASE),  VERSATILE_SCTL_BASE,  SZ_4K * 9,  MT_DEVICE },
+#ifdef CONFIG_MACH_VERSATILE_AB
+ { IO_ADDRESS(VERSATILE_GPIO0_BASE), VERSATILE_GPIO0_BASE, SZ_4K,      MT_DEVICE },
+ { IO_ADDRESS(VERSATILE_IB2_BASE),   VERSATILE_IB2_BASE,   SZ_64M,     MT_DEVICE },
+#endif
 #ifdef CONFIG_DEBUG_LL
  { IO_ADDRESS(VERSATILE_UART0_BASE), VERSATILE_UART0_BASE, SZ_4K,      MT_DEVICE },
 #endif
@@ -200,7 +204,7 @@
 #endif
 };
 
-static void __init versatile_map_io(void)
+void __init versatile_map_io(void)
 {
 	iotable_init(versatile_io_desc, ARRAY_SIZE(versatile_io_desc));
 }
@@ -208,7 +212,7 @@
 #define VERSATILE_REFCOUNTER	(IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET)
 
 /*
- * This is the VersatilePB sched_clock implementation.  This has
+ * This is the Versatile sched_clock implementation.  This has
  * a resolution of 41.7ns, and a maximum value of about 179s.
  */
 unsigned long long sched_clock(void)
@@ -302,8 +306,7 @@
 
 #define VERSATILE_SYSMCI	(IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET)
 
-#ifdef CONFIG_MMC
-static unsigned int mmc_status(struct device *dev)
+unsigned int mmc_status(struct device *dev)
 {
 	struct amba_device *adev = container_of(dev, struct amba_device, dev);
 	u32 mask;
@@ -321,20 +324,50 @@
 	.status		= mmc_status,
 };
 
-static struct mmc_platform_data mmc1_plat_data = {
-	.ocr_mask	= MMC_VDD_32_33|MMC_VDD_33_34,
-	.status		= mmc_status,
-};
+/*
+ * Clock handling
+ */
+static const struct icst307_params versatile_oscvco_params = {
+	.ref		= 24000,
+	.vco_max	= 200000,
+	.vd_min		= 4 + 8,
+	.vd_max		= 511 + 8,
+	.rd_min		= 1 + 2,
+	.rd_max		= 127 + 2,
+};
+
+static void versatile_oscvco_set(struct clk *clk, struct icst307_vco vco)
+{
+	unsigned long sys_lock = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET;
+#if defined(CONFIG_ARCH_VERSATILE_PB)
+	unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET;
+#elif defined(CONFIG_MACH_VERSATILE_AB)
+	unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET;
 #endif
+	u32 val;
+
+	val = readl(sys_osc) & ~0x7ffff;
+	val |= vco.v | (vco.r << 9) | (vco.s << 16);
+
+	writel(0xa05f, sys_lock);
+	writel(val, sys_osc);
+	writel(0, sys_lock);
+}
+
+static struct clk versatile_clcd_clk = {
+	.name	= "CLCDCLK",
+	.params	= &versatile_oscvco_params,
+	.setvco = versatile_oscvco_set,
+};
 
 /*
  * CLCD support.
  */
 #define SYS_CLCD_MODE_MASK	(3 << 0)
-#define SYS_CLCD_MODE_5551	(0 << 0)
-#define SYS_CLCD_MODE_565	(1 << 0)
-#define SYS_CLCD_MODE_888	(2 << 0)
-#define SYS_CLCD_MODE_LT	(3 << 0)
+#define SYS_CLCD_MODE_888	(0 << 0)
+#define SYS_CLCD_MODE_5551	(1 << 0)
+#define SYS_CLCD_MODE_565_RLSB	(2 << 0)
+#define SYS_CLCD_MODE_565_BLSB	(3 << 0)
 #define SYS_CLCD_NLCDIOON	(1 << 2)
 #define SYS_CLCD_VDDPOSSWITCH	(1 << 3)
 #define SYS_CLCD_PWR3V5SWITCH	(1 << 4)
@@ -342,6 +375,7 @@
 #define SYS_CLCD_ID_SANYO_3_8	(0x00 << 8)
 #define SYS_CLCD_ID_UNKNOWN_8_4	(0x01 << 8)
 #define SYS_CLCD_ID_EPSON_2_2	(0x02 << 8)
+#define SYS_CLCD_ID_SANYO_2_5	(0x07 << 8)
 #define SYS_CLCD_ID_VGA		(0x1f << 8)
 
 static struct clcd_panel vga = {
@@ -390,6 +424,29 @@
 	.bpp		= 16,
 };
 
+static struct clcd_panel sanyo_2_5_in = {
+	.mode		= {
+		.name		= "Sanyo QVGA Portrait",
+		.refresh	= 116,
+		.xres		= 240,
+		.yres		= 320,
+		.pixclock	= 100000,
+		.left_margin	= 20,
+		.right_margin	= 10,
+		.upper_margin	= 2,
+		.lower_margin	= 2,
+		.hsync_len	= 10,
+		.vsync_len	= 2,
+		.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+		.vmode		= FB_VMODE_NONINTERLACED,
+	},
+	.width		= -1,
+	.height		= -1,
+	.tim2		= TIM2_IVS | TIM2_IHS | TIM2_IPC,
+	.cntl		= CNTL_LCDTFT | CNTL_LCDVCOMP(1),
+	.bpp		= 16,
+};
+
 static struct clcd_panel epson_2_2_in = {
 	.mode		= {
 		.name		= "Epson QCIF",
@@ -428,6 +485,8 @@
 	val = readl(sys_clcd) & SYS_CLCD_ID_MASK;
 	if (val == SYS_CLCD_ID_SANYO_3_8)
 		panel = &sanyo_3_8_in;
+	else if (val == SYS_CLCD_ID_SANYO_2_5)
+		panel = &sanyo_2_5_in;
 	else if (val == SYS_CLCD_ID_EPSON_2_2)
 		panel = &epson_2_2_in;
 	else if (val == SYS_CLCD_ID_VGA)
@@ -435,9 +494,10 @@
 	else {
 		printk(KERN_ERR "CLCD: unknown LCD panel ID 0x%08x, using VGA\n",
 			val);
+		panel = &vga;
 	}
 
-	return &vga;
+	return panel;
 }
 
 /*
@@ -451,6 +511,20 @@
 	val = readl(sys_clcd);
 	val &= ~SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
 	writel(val, sys_clcd);
+
+#ifdef CONFIG_MACH_VERSATILE_AB
+	/*
+	 * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off
+	 */
+	if (fb->panel == &sanyo_2_5_in) {
+		unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL);
+		unsigned long ctrl;
+
+		ctrl = readl(versatile_ib2_ctrl);
+		ctrl &= ~0x01;
+		writel(ctrl, versatile_ib2_ctrl);
+	}
+#endif
 }
 
 /*
@@ -466,19 +540,10 @@
 
 	switch (fb->fb.var.green.length) {
 	case 5:
-#if 0
-		/*
-		 * For some undocumented reason, we need to select 565 mode
-		 * even when using 555 with VGA.  Maybe this is only true
-		 * for the VGA output and needs to be done for LCD panels?
-		 * I can't get an explaination from the people who should
-		 * know.
-		 */
 		val |= SYS_CLCD_MODE_5551;
 		break;
-#endif
 	case 6:
-		val |= SYS_CLCD_MODE_565;
+		val |= SYS_CLCD_MODE_565_BLSB;
 		break;
 	case 8:
 		val |= SYS_CLCD_MODE_888;
@@ -495,6 +560,20 @@
 	 */
 	val |= SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
 	writel(val, sys_clcd);
+
+#ifdef CONFIG_MACH_VERSATILE_AB
+	/*
+	 * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on
+	 */
+	if (fb->panel == &sanyo_2_5_in) {
+		unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL);
+		unsigned long ctrl;
+
+		ctrl = readl(versatile_ib2_ctrl);
+		ctrl |= 0x01;
+		writel(ctrl, versatile_ib2_ctrl);
+	}
+#endif
 }
 
 static unsigned long framesize = SZ_1M;
@@ -525,7 +604,7 @@
 }
 
 static struct clcd_board clcd_plat_data = {
-	.name		= "Versatile PB",
+	.name		= "Versatile",
 	.check		= clcdfb_check,
 	.decode		= clcdfb_decode,
 	.disable	= versatile_clcd_disable,
@@ -534,23 +613,6 @@
 	.remove		= versatile_clcd_remove,
 };
 
-#define AMBA_DEVICE(name,busid,base,plat)			\
-static struct amba_device name##_device = {			\
-	.dev		= {					\
-		.coherent_dma_mask = ~0,			\
-		.bus_id	= busid,				\
-		.platform_data = plat,				\
-	},							\
-	.res		= {					\
-		.start	= VERSATILE_##base##_BASE,		\
-		.end	= (VERSATILE_##base##_BASE) + SZ_4K - 1,\
-		.flags	= IORESOURCE_MEM,			\
-	},							\
-	.dma_mask	= ~0,					\
-	.irq		= base##_IRQ,				\
-	/* .dma		= base##_DMA,*/				\
-}
-
 #define AACI_IRQ	{ IRQ_AACI, NO_IRQ }
 #define AACI_DMA	{ 0x80, 0x81 }
 #define MMCI0_IRQ	{ IRQ_MMCI0A,IRQ_SIC_MMCI0B }
@@ -559,12 +621,6 @@
 #define KMI0_DMA	{ 0, 0 }
 #define KMI1_IRQ	{ IRQ_SIC_KMI1, NO_IRQ }
 #define KMI1_DMA	{ 0, 0 }
-#define UART3_IRQ	{ IRQ_SIC_UART3, NO_IRQ }
-#define UART3_DMA	{ 0x86, 0x87 }
-#define SCI1_IRQ	{ IRQ_SIC_SCI3, NO_IRQ }
-#define SCI1_DMA	{ 0x88, 0x89 }
-#define MMCI1_IRQ	{ IRQ_MMCI1A, IRQ_SIC_MMCI1B }
-#define MMCI1_DMA	{ 0x85, 0 }
 
 /*
  * These devices are connected directly to the multi-layer AHB switch
@@ -589,10 +645,6 @@
 #define GPIO0_DMA	{ 0, 0 }
 #define GPIO1_IRQ	{ IRQ_GPIOINT1, NO_IRQ }
 #define GPIO1_DMA	{ 0, 0 }
-#define GPIO2_IRQ	{ IRQ_GPIOINT2, NO_IRQ }
-#define GPIO2_DMA	{ 0, 0 }
-#define GPIO3_IRQ	{ IRQ_GPIOINT3, NO_IRQ }
-#define GPIO3_DMA	{ 0, 0 }
 #define RTC_IRQ		{ IRQ_RTCINT, NO_IRQ }
 #define RTC_DMA		{ 0, 0 }
 
@@ -612,16 +664,9 @@
 
 /* FPGA Primecells */
 AMBA_DEVICE(aaci,  "fpga:04", AACI,     NULL);
-#ifdef CONFIG_MMC
 AMBA_DEVICE(mmc0,  "fpga:05", MMCI0,    &mmc0_plat_data);
-#endif
 AMBA_DEVICE(kmi0,  "fpga:06", KMI0,     NULL);
 AMBA_DEVICE(kmi1,  "fpga:07", KMI1,     NULL);
-AMBA_DEVICE(uart3, "fpga:09", UART3,    NULL);
-AMBA_DEVICE(sci1,  "fpga:0a", SCI1,     NULL);
-#ifdef CONFIG_MMC
-AMBA_DEVICE(mmc1,  "fpga:0b", MMCI1,    &mmc1_plat_data);
-#endif
 
 /* DevChip Primecells */
 AMBA_DEVICE(smc,   "dev:00",  SMC,      NULL);
@@ -632,8 +677,6 @@
 AMBA_DEVICE(wdog,  "dev:e1",  WATCHDOG, NULL);
 AMBA_DEVICE(gpio0, "dev:e4",  GPIO0,    NULL);
 AMBA_DEVICE(gpio1, "dev:e5",  GPIO1,    NULL);
-AMBA_DEVICE(gpio2, "dev:e6",  GPIO2,    NULL);
-AMBA_DEVICE(gpio3, "dev:e7",  GPIO3,    NULL);
 AMBA_DEVICE(rtc,   "dev:e8",  RTC,      NULL);
 AMBA_DEVICE(sci0,  "dev:f0",  SCI,      NULL);
 AMBA_DEVICE(uart0, "dev:f1",  UART0,    NULL);
@@ -646,7 +689,6 @@
 	&uart0_device,
 	&uart1_device,
 	&uart2_device,
-	&uart3_device,
 	&smc_device,
 	&mpmc_device,
 	&clcd_device,
@@ -654,23 +696,16 @@
 	&wdog_device,
 	&gpio0_device,
 	&gpio1_device,
-	&gpio2_device,
-	&gpio3_device,
 	&rtc_device,
 	&sci0_device,
 	&ssp0_device,
 	&aaci_device,
-#ifdef CONFIG_MMC
 	&mmc0_device,
-#endif
 	&kmi0_device,
 	&kmi1_device,
-	&sci1_device,
-#ifdef CONFIG_MMC
-	&mmc1_device,
-#endif
 };
 
+#ifdef CONFIG_LEDS
 #define VA_LEDS_BASE (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET)
 
 static void versatile_leds_event(led_event_t ledevt)
@@ -705,11 +740,14 @@
 	writel(val, VA_LEDS_BASE);
 	local_irq_restore(flags);
 }
+#endif	/* CONFIG_LEDS */
 
-static void __init versatile_init(void)
+void __init versatile_init(void)
 {
 	int i;
 
+	clk_register(&versatile_clcd_clk);
+
 	platform_device_register(&versatile_flash_device);
 	platform_device_register(&smc91x_device);
 
@@ -718,7 +756,9 @@
 		amba_device_register(d, &iomem_resource);
 	}
 
+#ifdef CONFIG_LEDS
 	leds_event = versatile_leds_event;
+#endif
 }
 
 /*
@@ -760,8 +800,6 @@
 	unsigned long TimerClear;
 } TimerStruct_t;
 
-extern unsigned long (*gettimeoffset)(void);
-
 /*
  * Returns number of ms since last clock interrupt.  Note that interrupts
  * will have been disabled by do_gettimeoffset()
@@ -810,11 +848,15 @@
 {
 	volatile TimerStruct_t *timer0 = (volatile TimerStruct_t *)TIMER0_VA_BASE;
 
+	write_seqlock(&xtime_lock);
+
 	// ...clear the interrupt
 	timer0->TimerClear = 1;
 
 	timer_tick(regs);
 
+	write_sequnlock(&xtime_lock);
+
 	return IRQ_HANDLED;
 }
 
@@ -827,7 +869,7 @@
 /*
  * Set up timer interrupt, and return the current time in seconds.
  */
-void __init versatile_init_time(void)
+static void __init versatile_timer_init(void)
 {
 	volatile TimerStruct_t *timer0 = (volatile TimerStruct_t *)TIMER0_VA_BASE;
 	volatile TimerStruct_t *timer1 = (volatile TimerStruct_t *)TIMER1_VA_BASE;
@@ -859,15 +901,9 @@
 	 * Make irqs happen for the system timer
 	 */
 	setup_irq(IRQ_TIMERINT0_1, &versatile_timer_irq);
-	gettimeoffset = versatile_gettimeoffset;
 }
 
-MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
-	MAINTAINER("ARM Ltd/Deep Blue Solutions Ltd")
-	BOOT_MEM(0x00000000, 0x101f1000, 0xf11f1000)
-	BOOT_PARAMS(0x00000100)
-	MAPIO(versatile_map_io)
-	INITIRQ(versatile_init_irq)
-	INITTIME(versatile_init_time)
-	INIT_MACHINE(versatile_init)
-MACHINE_END
+struct sys_timer versatile_timer = {
+	.init		= versatile_timer_init,
+	.offset		= versatile_gettimeoffset,
+};
diff -Nru a/arch/arm/mach-versatile/core.h b/arch/arm/mach-versatile/core.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-versatile/core.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,50 @@
+/*
+ *  linux/arch/arm/mach-versatile/core.h
+ *
+ *  Copyright (C) 2004 ARM Limited
+ *  Copyright (C) 2000 Deep Blue Solutions Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __ASM_ARCH_VERSATILE_H
+#define __ASM_ARCH_VERSATILE_H
+
+#include <asm/hardware/amba.h>
+
+extern void __init versatile_init(void);
+extern void __init versatile_init_irq(void);
+extern void __init versatile_map_io(void);
+extern struct sys_timer versatile_timer;
+extern unsigned int mmc_status(struct device *dev);
+
+#define AMBA_DEVICE(name,busid,base,plat)			\
+static struct amba_device name##_device = {			\
+	.dev		= {					\
+		.coherent_dma_mask = ~0,			\
+		.bus_id	= busid,				\
+		.platform_data = plat,				\
+	},							\
+	.res		= {					\
+		.start	= VERSATILE_##base##_BASE,		\
+		.end	= (VERSATILE_##base##_BASE) + SZ_4K - 1,\
+		.flags	= IORESOURCE_MEM,			\
+	},							\
+	.dma_mask	= ~0,					\
+	.irq		= base##_IRQ,				\
+	/* .dma		= base##_DMA,*/				\
+}
+
+#endif
diff -Nru a/arch/arm/mach-versatile/versatile_ab.c b/arch/arm/mach-versatile/versatile_ab.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-versatile/versatile_ab.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,45 @@
+/*
+ *  linux/arch/arm/mach-versatile/versatile_ab.c
+ *
+ *  Copyright (C) 2004 ARM Limited
+ *  Copyright (C) 2000 Deep Blue Solutions Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/sysdev.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+#include <asm/hardware/amba.h>
+
+#include <asm/mach/arch.h>
+
+#include "core.h"
+
+MACHINE_START(VERSATILE_AB, "ARM-Versatile AB")
+	MAINTAINER("ARM Ltd/Deep Blue Solutions Ltd")
+	BOOT_MEM(0x00000000, 0x101f1000, 0xf11f1000)
+	BOOT_PARAMS(0x00000100)
+	MAPIO(versatile_map_io)
+	INITIRQ(versatile_init_irq)
+	.timer		= &versatile_timer,
+	INIT_MACHINE(versatile_init)
+MACHINE_END
diff -Nru a/arch/arm/mach-versatile/versatile_pb.c b/arch/arm/mach-versatile/versatile_pb.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/arm/mach-versatile/versatile_pb.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,109 @@
+/*
+ *  linux/arch/arm/mach-versatile/versatile_pb.c
+ *
+ *  Copyright (C) 2004 ARM Limited
+ *  Copyright (C) 2000 Deep Blue Solutions Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/sysdev.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+#include <asm/hardware/amba.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/mmc.h>
+
+#include "core.h"
+
+#if 1
+#define IRQ_MMCI1A	IRQ_VICSOURCE23
+#else
+#define IRQ_MMCI1A	IRQ_SIC_MMCI1A
+#endif
+
+static struct mmc_platform_data mmc1_plat_data = {
+	.ocr_mask	= MMC_VDD_32_33|MMC_VDD_33_34,
+	.status		= mmc_status,
+};
+
+#define UART3_IRQ	{ IRQ_SIC_UART3, NO_IRQ }
+#define UART3_DMA	{ 0x86, 0x87 }
+#define SCI1_IRQ	{ IRQ_SIC_SCI3, NO_IRQ }
+#define SCI1_DMA	{ 0x88, 0x89 }
+#define MMCI1_IRQ	{ IRQ_MMCI1A, IRQ_SIC_MMCI1B }
+#define MMCI1_DMA	{ 0x85, 0 }
+
+/*
+ * These devices are connected via the core APB bridge
+ */
+#define GPIO2_IRQ	{ IRQ_GPIOINT2, NO_IRQ }
+#define GPIO2_DMA	{ 0, 0 }
+#define GPIO3_IRQ	{ IRQ_GPIOINT3, NO_IRQ }
+#define GPIO3_DMA	{ 0, 0 }
+
+/*
+ * These devices are connected via the DMA APB bridge
+ */
+
+/* FPGA Primecells */
+AMBA_DEVICE(uart3, "fpga:09", UART3,    NULL);
+AMBA_DEVICE(sci1,  "fpga:0a", SCI1,     NULL);
+AMBA_DEVICE(mmc1,  "fpga:0b", MMCI1,    &mmc1_plat_data);
+
+/* DevChip Primecells */
+AMBA_DEVICE(gpio2, "dev:e6",  GPIO2,    NULL);
+AMBA_DEVICE(gpio3, "dev:e7",  GPIO3,    NULL);
+
+static struct amba_device *amba_devs[] __initdata = {
+	&uart3_device,
+	&gpio2_device,
+	&gpio3_device,
+	&sci1_device,
+	&mmc1_device,
+};
+
+static int __init versatile_pb_init(void)
+{
+	int i;
+
+	if (machine_is_versatile_pb()) {
+		for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
+			struct amba_device *d = amba_devs[i];
+			amba_device_register(d, &iomem_resource);
+		}
+	}
+
+	return 0;
+}
+
+arch_initcall(versatile_pb_init);
+
+MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
+	MAINTAINER("ARM Ltd/Deep Blue Solutions Ltd")
+	BOOT_MEM(0x00000000, 0x101f1000, 0xf11f1000)
+	BOOT_PARAMS(0x00000100)
+	MAPIO(versatile_map_io)
+	INITIRQ(versatile_init_irq)
+	.timer		= &versatile_timer,
+	INIT_MACHINE(versatile_init)
+MACHINE_END
diff -Nru a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
--- a/arch/arm/mm/Kconfig	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/mm/Kconfig	2004-12-24 13:36:47 -08:00
@@ -14,6 +14,7 @@
 	depends on ARCH_RPC
 	select CPU_32v3
 	select CPU_CACHE_V3
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V3
 	select CPU_TLB_V3
 	help
@@ -29,6 +30,7 @@
 	default y if ARCH_CLPS7500
 	select CPU_32v3
 	select CPU_CACHE_V3
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V3
 	select CPU_TLB_V3
 	help
@@ -47,6 +49,7 @@
 	select CPU_32v4
 	select CPU_ABRT_LV4T
 	select CPU_CACHE_V4
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WT
 	select CPU_TLB_V4WT
 	help
@@ -64,6 +67,7 @@
 	select CPU_32v4
 	select CPU_ABRT_EV4T
 	select CPU_CACHE_V4WT
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB
 	select CPU_TLB_V4WBI
 	help
@@ -84,6 +88,7 @@
 	select CPU_32v4
 	select CPU_ABRT_EV4T
 	select CPU_CACHE_V4WT
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB
 	select CPU_TLB_V4WBI
 	help
@@ -102,6 +107,7 @@
 	select CPU_32v4
 	select CPU_ABRT_EV4T
 	select CPU_CACHE_V4WT
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB
 	select CPU_TLB_V4WBI
  	help
@@ -115,10 +121,11 @@
 # ARM926T
 config CPU_ARM926T
 	bool "Support ARM926T processor" if ARCH_INTEGRATOR
-	depends on ARCH_INTEGRATOR || ARCH_VERSATILE_PB || ARCH_OMAP730 || ARCH_OMAP1610 || ARCH_OMAP5912
-	default y if ARCH_VERSATILE_PB
+	depends on ARCH_INTEGRATOR || ARCH_VERSATILE_PB || MACH_VERSATILE_AB || ARCH_OMAP730 || ARCH_OMAP1610 || ARCH_OMAP5912
+	default y if ARCH_VERSATILE_PB || MACH_VERSATILE_AB
 	select CPU_32v5
 	select CPU_ABRT_EV5TJ
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB
 	select CPU_TLB_V4WBI
 	help
@@ -136,6 +143,7 @@
 	select CPU_32v5
 	select CPU_ABRT_EV4T
 	select CPU_CACHE_V4WT
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB
 	select CPU_TLB_V4WBI
 	help
@@ -152,6 +160,7 @@
 	select CPU_32v5
 	select CPU_ABRT_EV4T
 	select CPU_CACHE_V4WT
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB
 	select CPU_TLB_V4WBI
 	depends on n
@@ -162,6 +171,7 @@
 	depends on ARCH_INTEGRATOR
 	select CPU_32v5
 	select CPU_ABRT_EV4T
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB # can probably do better
 	select CPU_TLB_V4WBI
 	help
@@ -178,6 +188,7 @@
 	depends on ARCH_INTEGRATOR
 	select CPU_32v5
 	select CPU_ABRT_EV5T # But need Jazelle, but EV5TJ ignores bit 10
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB # can probably do better
 	select CPU_TLB_V4WBI
 	help
@@ -195,6 +206,7 @@
 	select CPU_32v4 if !ARCH_RPC
 	select CPU_ABRT_EV4
 	select CPU_CACHE_V4WB
+	select CPU_CACHE_VIVT
 	select CPU_COPY_V4WB
 	select CPU_TLB_V4WB
 	help
@@ -214,6 +226,7 @@
 	select CPU_32v4
 	select CPU_ABRT_EV4
 	select CPU_CACHE_V4WB
+	select CPU_CACHE_VIVT
 	select CPU_TLB_V4WB
 	select CPU_MINICACHE
 
@@ -224,6 +237,7 @@
 	default y
 	select CPU_32v5
 	select CPU_ABRT_EV5T
+	select CPU_CACHE_VIVT
 	select CPU_TLB_V4WBI
 	select CPU_MINICACHE
 
@@ -234,6 +248,7 @@
 	select CPU_32v6
 	select CPU_ABRT_EV6
 	select CPU_CACHE_V6
+	select CPU_CACHE_VIPT
 	select CPU_COPY_V6
 	select CPU_TLB_V6
 
@@ -284,6 +299,12 @@
 	bool
 
 config CPU_CACHE_V6
+	bool
+
+config CPU_CACHE_VIVT
+	bool
+
+config CPU_CACHE_VIPT
 	bool
 
 # The copy-page model
diff -Nru a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
--- a/arch/arm/mm/copypage-v6.c	2004-12-24 13:36:47 -08:00
+++ b/arch/arm/mm/copypage-v6.c	2004-12-24 13:36:47 -08:00
@@ -15,6 +15,7 @@
 #include <asm/pgtable.h>
 #include <asm/shmparam.h>
 #include <asm/tlbflush.h>
+#include <asm/cacheflush.h>
 
 #if SHMLBA > 16384
 #error FIX ME
diff -Nru a/arch/arm/mm/init.c b/arch/arm/mm/init.c
--- a/arch/arm/mm/init.c	2004-12-24 13:36:18 -08:00
+++ b/arch/arm/mm/init.c	2004-12-24 13:36:18 -08:00
@@ -30,7 +30,7 @@
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
-extern char _stext, _text, _etext, _end, __init_begin, __init_end;
+extern void _stext, _text, _etext, __data_start, _end, __init_begin, __init_end;
 extern unsigned long phys_initrd_start;
 extern unsigned long phys_initrd_size;
 
@@ -282,7 +282,11 @@
 	 * Register the kernel text and data with bootmem.
 	 * Note that this can only be in node 0.
 	 */
+#ifdef CONFIG_XIP_KERNEL
+	reserve_bootmem_node(pgdat, __pa(&__data_start), &_end - &__data_start);
+#else
 	reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext);
+#endif
 
 	/*
 	 * Reserve the page tables.  These are already in use,
@@ -540,7 +544,7 @@
 	int i, node;
 
 	codepages = &_etext - &_text;
-	datapages = &_end - &_etext;
+	datapages = &_end - &__data_start;
 	initpages = &__init_end - &__init_begin;
 
 #ifndef CONFIG_DISCONTIGMEM
diff -Nru a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
--- a/arch/arm/mm/ioremap.c	2004-12-24 13:37:00 -08:00
+++ b/arch/arm/mm/ioremap.c	2004-12-24 13:37:00 -08:00
@@ -130,7 +130,7 @@
  * 'flags' are the extra L_PTE_ flags that you want to specify for this
  * mapping.  See include/asm-arm/proc-armv/pgtable.h for more information.
  */
-void *
+void __iomem *
 __ioremap(unsigned long phys_addr, size_t size, unsigned long flags,
 	  unsigned long align)
 {
@@ -161,11 +161,11 @@
 		vfree(addr);
 		return NULL;
 	}
-	return (void *) (offset + (char *)addr);
+	return (void __iomem *) (offset + (char *)addr);
 }
 EXPORT_SYMBOL(__ioremap);
 
-void __iounmap(void *addr)
+void __iounmap(void __iomem *addr)
 {
 	vfree((void *) (PAGE_MASK & (unsigned long) addr));
 }
diff -Nru a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
--- a/arch/arm/mm/mm-armv.c	2004-12-24 13:37:01 -08:00
+++ b/arch/arm/mm/mm-armv.c	2004-12-24 13:37:01 -08:00
@@ -158,7 +158,7 @@
 
 	init_pgd = pgd_offset_k(0);
 
-	if (vectors_base() == 0) {
+	if (!vectors_high()) {
 		/*
 		 * This lock is here just to satisfy pmd_alloc and pte_lock
 		 */
@@ -317,15 +317,25 @@
 		.prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE,
 		.domain    = DOMAIN_KERNEL,
 	},
-	[MT_VECTORS] = {
+	[MT_LOW_VECTORS] = {
 		.prot_pte  = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
 				L_PTE_EXEC,
 		.prot_l1   = PMD_TYPE_TABLE,
 		.domain    = DOMAIN_USER,
 	},
+	[MT_HIGH_VECTORS] = {
+		.prot_pte  = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
+				L_PTE_USER | L_PTE_EXEC,
+		.prot_l1   = PMD_TYPE_TABLE,
+		.domain    = DOMAIN_USER,
+	},
 	[MT_MEMORY] = {
 		.prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
 		.domain    = DOMAIN_KERNEL,
+	},
+	[MT_ROM] = {
+		.prot_sect = PMD_TYPE_SECT,
+		.domain    = DOMAIN_KERNEL,
 	}
 };
 
@@ -353,12 +363,12 @@
 	}
 
 	if (cpu_arch <= CPU_ARCH_ARMv5) {
-		mem_types[MT_DEVICE].prot_l1       |= PMD_BIT4;
-		mem_types[MT_DEVICE].prot_sect     |= PMD_BIT4;
-		mem_types[MT_CACHECLEAN].prot_sect |= PMD_BIT4;
-		mem_types[MT_MINICLEAN].prot_sect  |= PMD_BIT4;
-		mem_types[MT_VECTORS].prot_l1      |= PMD_BIT4;
-		mem_types[MT_MEMORY].prot_sect     |= PMD_BIT4;
+		for (i = 0; i < ARRAY_SIZE(mem_types); i++) {
+			if (mem_types[i].prot_l1)
+				mem_types[i].prot_l1 |= PMD_BIT4;
+			if (mem_types[i].prot_sect)
+				mem_types[i].prot_sect |= PMD_BIT4;
+		}
 	}
 
 	/*
@@ -370,6 +380,7 @@
 		 * kernel memory mapping.
 		 */
 		mem_types[MT_MEMORY].prot_sect &= ~PMD_BIT4;
+		mem_types[MT_ROM].prot_sect &= ~PMD_BIT4;
 		/*
 		 * Mark cache clean areas read only from SVC mode
 		 * and no access from userspace.
@@ -381,14 +392,18 @@
 	cp = &cache_policies[cachepolicy];
 
 	if (cpu_arch >= CPU_ARCH_ARMv5) {
-		mem_types[MT_VECTORS].prot_pte |= cp->pte & PTE_CACHEABLE;
+		mem_types[MT_LOW_VECTORS].prot_pte |= cp->pte & PTE_CACHEABLE;
+		mem_types[MT_HIGH_VECTORS].prot_pte |= cp->pte & PTE_CACHEABLE;
 	} else {
-		mem_types[MT_VECTORS].prot_pte |= cp->pte;
+		mem_types[MT_LOW_VECTORS].prot_pte |= cp->pte;
+		mem_types[MT_HIGH_VECTORS].prot_pte |= cp->pte;
 		mem_types[MT_MINICLEAN].prot_sect &= ~PMD_SECT_TEX(1);
 	}
 
-	mem_types[MT_VECTORS].prot_l1 |= ecc_mask;
+	mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
+	mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
 	mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
+	mem_types[MT_ROM].prot_sect |= cp->pmd;
 
 	for (i = 0; i < 16; i++) {
 		unsigned long v = pgprot_val(protection_map[i]);
@@ -413,6 +428,8 @@
 		ecc_mask ? "en" : "dis", cp->policy);
 }
 
+#define vectors_base()	(vectors_high() ? 0xffff0000 : 0)
+
 /*
  * Create the page directory entries and any necessary
  * page tables for the mapping specified by `md'.  We
@@ -426,14 +443,14 @@
 	pgprot_t prot_pte;
 	long off;
 
-	if (md->virtual != vectors_base() && md->virtual < PAGE_OFFSET) {
+	if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) {
 		printk(KERN_WARNING "BUG: not creating mapping for "
 		       "0x%08lx at 0x%08lx in user region\n",
 		       md->physical, md->virtual);
 		return;
 	}
 
-	if (md->type == MT_DEVICE &&
+	if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
 	    md->virtual >= PAGE_OFFSET && md->virtual < VMALLOC_END) {
 		printk(KERN_WARNING "BUG: mapping for 0x%08lx at 0x%08lx "
 		       "overlaps vmalloc space\n",
@@ -508,6 +525,8 @@
 	}
 }
 
+extern void _stext, _etext;
+
 /*
  * Setup initial mappings.  We use the page we allocated for zero page to hold
  * the mappings, which will get overwritten by the vectors in traps_init().
@@ -523,6 +542,14 @@
 
 	init_maps = p = alloc_bootmem_low_pages(PAGE_SIZE);
 
+#ifdef CONFIG_XIP_KERNEL
+	p->physical   = CONFIG_XIP_PHYS_ADDR & PMD_MASK;
+	p->virtual    = (unsigned long)&_stext & PMD_MASK;
+	p->length     = ((unsigned long)&_etext - p->virtual + ~PMD_MASK) & PMD_MASK;
+	p->type       = MT_ROM;
+	p ++;
+#endif
+
 	for (i = 0; i < mi->nr_banks; i++) {
 		if (mi->bank[i].size == 0)
 			continue;
@@ -570,15 +597,21 @@
 	} while (address != 0);
 
 	/*
-	 * Create a mapping for the machine vectors at virtual address 0
-	 * or 0xffff0000.  We should always try the high mapping.
+	 * Create a mapping for the machine vectors at the high-vectors
+	 * location (0xffff0000).  If we aren't using high-vectors, also
+	 * create a mapping at the low-vectors virtual address.
 	 */
 	init_maps->physical   = virt_to_phys(init_maps);
-	init_maps->virtual    = vectors_base();
+	init_maps->virtual    = 0xffff0000;
 	init_maps->length     = PAGE_SIZE;
-	init_maps->type       = MT_VECTORS;
-
+	init_maps->type       = MT_HIGH_VECTORS;
 	create_mapping(init_maps);
+
+	if (!vectors_high()) {
+		init_maps->virtual = 0;
+		init_maps->type = MT_LOW_VECTORS;
+		create_mapping(init_maps);
+	}
 
 	flush_cache_all();
 	flush_tlb_all();
diff -Nru a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
--- a/arch/arm/mm/proc-arm720.S	2004-12-24 13:37:01 -08:00
+++ b/arch/arm/mm/proc-arm720.S	2004-12-24 13:37:01 -08:00
@@ -138,7 +138,7 @@
 		bic	r0, r0, #0x0e00			@ ..V. ..RS BLDP WCAM
 		orr	r0, r0, #0x0100			@ .... .... .111 .... (old)
 		orr	r0, r0, #0x003d			@ .... ..01 ..11 1101 (new)
-		mov	pc, lr				@ __ret (head-armv.S)
+		mov	pc, lr				@ __ret (head.S)
 		.size	__arm710_setup, . - __arm710_setup
 
 		.type	__arm720_setup, #function
@@ -153,7 +153,7 @@
 		bic	r0, r0, #0x0e00			@ ..V. ..RS BLDP WCAM
 		orr	r0, r0, #0x2100			@ .... .... .111 .... (old)
 		orr	r0, r0, #0x003d			@ ..1. ..01 ..11 1101 (new)
-		mov	pc, lr				@ __ret (head-armv.S)
+		mov	pc, lr				@ __ret (head.S)
 		.size	__arm720_setup, . - __arm720_setup
 
 		__INITDATA
diff -Nru a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
--- a/arch/arm/mm/proc-v6.S	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/mm/proc-v6.S	2004-12-24 13:36:16 -08:00
@@ -201,6 +201,11 @@
 	mov	r10, #0x1f			@ domains 0, 1 = manager
 	mcr	p15, 0, r10, c3, c0, 0		@ load domain access register
 	mrc	p15, 0, r0, c1, c0, 0		@ read control register
+#ifdef CONFIG_VFP
+	mrc	p15, 0, r10, c1, c0, 2
+	orr	r10, r10, #(3 << 20)
+	mcr	p15, 0, r10, c1, c0, 2		@ Enable full access to VFP
+#endif
 	ldr	r10, cr1_clear			@ get mask for bits to clear
 	bic	r0, r0, r10			@ clear bits them
 	ldr	r10, cr1_set			@ get mask for bits to set
@@ -250,8 +255,8 @@
 	 */
 	.type	__v6_proc_info, #object
 __v6_proc_info:
-	.long	0x00070000
-	.long	0x00ff0000
+	.long	0x0007b000
+	.long	0x0007f000
 	.long	0x00000c0e
 	b	__v6_setup
 	.long	cpu_arch_name
diff -Nru a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
--- a/arch/arm/mm/proc-xscale.S	2004-12-24 13:37:18 -08:00
+++ b/arch/arm/mm/proc-xscale.S	2004-12-24 13:37:18 -08:00
@@ -679,6 +679,11 @@
 	.asciz	"XScale-IXP42x Family"
 	.size	cpu_ixp42x_name, . - cpu_ixp42x_name
 
+	.type	cpu_ixp46x_name, #object
+cpu_ixp46x_name:
+	.asciz	"XScale-IXP46x Family"
+	.size	cpu_ixp46x_name, . - cpu_ixp46x_name
+
 	.type	cpu_ixp2400_name, #object
 cpu_ixp2400_name:
 	.asciz	"XScale-IXP2400"
@@ -830,6 +835,22 @@
 	.long	xscale_mc_user_fns
 	.long	xscale_cache_fns
 	.size   __ixp42x_proc_info, . - __ixp42x_proc_info                
+
+	.type	__ixp46x_proc_info, #object
+__ixp46x_proc_info:
+	.long   0x69054200
+	.long   0xffffff00
+	.long   0x00000c0e
+	b       __xscale_setup
+	.long   cpu_arch_name
+	.long   cpu_elf_name
+	.long   HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
+	.long   cpu_ixp46x_name
+	.long   xscale_processor_functions
+	.long	v4wbi_tlb_fns
+	.long	xscale_mc_user_fns
+	.long	xscale_cache_fns
+	.size   __ixp46x_proc_info, . - __ixp46x_proc_info
 
 	.type	__pxa255_proc_info,#object
 __pxa255_proc_info:
diff -Nru a/arch/arm/nwfpe/double_cpdo.c b/arch/arm/nwfpe/double_cpdo.c
--- a/arch/arm/nwfpe/double_cpdo.c	2004-12-24 13:36:16 -08:00
+++ b/arch/arm/nwfpe/double_cpdo.c	2004-12-24 13:36:16 -08:00
@@ -75,7 +75,11 @@
 	union float64_components u;
 
 	u.f64 = rFm;
+#ifdef __ARMEB__
+	u.i[0] ^= 0x80000000;
+#else
 	u.i[1] ^= 0x80000000;
+#endif
 
 	return u.f64;
 }
@@ -85,7 +89,11 @@
 	union float64_components u;
 
 	u.f64 = rFm;
+#ifdef __ARMEB__
+	u.i[0] &= 0x7fffffff;
+#else
 	u.i[1] &= 0x7fffffff;
+#endif
 
 	return u.f64;
 }
diff -Nru a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
--- a/arch/arm/tools/mach-types	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/tools/mach-types	2004-12-24 13:36:49 -08:00
@@ -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 Sep 30 15:23:21 2004
+# Last update: Sun Nov 7 13:20:41 2004
 #
 # machine_is_xxx	CONFIG_xxxx		MACH_TYPE_xxx		number
 #
@@ -595,8 +595,8 @@
 xaeniax			MACH_XAENIAX		XAENIAX			585
 somn4250		MACH_SOMN4250		SOMN4250		586
 pleb2			MACH_PLEB2		PLEB2			587
-cwl			MACH_CWL		CWL			588
-gd			MACH_GD			GD			589
+cornwallis		MACH_CORNWALLIS		CORNWALLIS		588
+gurney_drv		MACH_GURNEY_DRV		GURNEY_DRV		589
 chaffee			MACH_CHAFFEE		CHAFFEE			590
 rms101			MACH_RMS101		RMS101			591
 rx3715			MACH_RX3715		RX3715			592
@@ -615,3 +615,22 @@
 tomtomgo		MACH_TOMTOMGO		TOMTOMGO		605
 versatile_ab		MACH_VERSATILE_AB	VERSATILE_AB		606
 edb9307			MACH_EDB9307		EDB9307			607
+sg565			MACH_SG565		SG565			608
+lpd79524		MACH_LPD79524		LPD79524		609
+lpd79525		MACH_LPD79525		LPD79525		610
+rms100			MACH_RMS100		RMS100			611
+kb9200			MACH_KB9200		KB9200			612
+sx1			MACH_SX1		SX1			613
+hms39c7092		MACH_HMS39C7092		HMS39C7092		614
+armadillo		MACH_ARMADILLO		ARMADILLO		615
+ipcu			MACH_IPCU		IPCU			616
+loox720			MACH_LOOX720		LOOX720			617
+ixdp465			MACH_IXDP465		IXDP465			618
+ixdp2351		MACH_IXDP2351		IXDP2351		619
+adsvix			MACH_ADSVIX		ADSVIX			620
+dm270			MACH_DM270		DM270			621
+socltplus		MACH_SOCLTPLUS		SOCLTPLUS		622
+ecia			MACH_ECIA		ECIA			623
+cm4008			MACH_CM4008		CM4008			624
+p2001			MACH_P2001		P2001			625
+twister			MACH_TWISTER		TWISTER			626
diff -Nru a/arch/arm/vfp/vfp.h b/arch/arm/vfp/vfp.h
--- a/arch/arm/vfp/vfp.h	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/vfp/vfp.h	2004-12-24 13:36:49 -08:00
@@ -249,6 +249,12 @@
 	u64	significand;
 };
 
+/*
+ * VFP_REG_ZERO is a special register number for vfp_get_double
+ * which returns (double)0.0.  This is useful for the compare with
+ * zero instructions.
+ */
+#define VFP_REG_ZERO	16
 extern u64 vfp_get_double(unsigned int reg);
 extern void vfp_put_double(unsigned int reg, u64 val);
 
@@ -331,3 +337,8 @@
 extern void vfp_put_sys(unsigned int reg, u32 val);
 
 u32 vfp_estimate_sqrt_significand(u32 exponent, u32 significand);
+
+/*
+ * A special flag to tell the normalisation code not to normalise.
+ */
+#define VFP_NAN_FLAG	0x100
diff -Nru a/arch/arm/vfp/vfpdouble.c b/arch/arm/vfp/vfpdouble.c
--- a/arch/arm/vfp/vfpdouble.c	2004-12-24 13:36:49 -08:00
+++ b/arch/arm/vfp/vfpdouble.c	2004-12-24 13:36:49 -08:00
@@ -31,7 +31,7 @@
  * ===========================================================================
  */
 #include <linux/kernel.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/ptrace.h>
 #include <asm/vfp.h>
 
@@ -195,7 +195,7 @@
 			 dd, d, exceptions);
 		vfp_put_double(dd, d);
 	}
-	return exceptions;
+	return exceptions & ~VFP_NAN_FLAG;
 }
 
 /*
@@ -240,7 +240,7 @@
 	/*
 	 * If one was a signalling NAN, raise invalid operation.
 	 */
-	return tn == VFP_SNAN || tm == VFP_SNAN ? FPSCR_IOC : 0x100;
+	return tn == VFP_SNAN || tm == VFP_SNAN ? FPSCR_IOC : VFP_NAN_FLAG;
 }
 
 /*
@@ -427,12 +427,12 @@
 
 static u32 vfp_double_fcmpz(int dd, int unused, int dm, u32 fpscr)
 {
-	return vfp_compare(dd, 0, -1, fpscr);
+	return vfp_compare(dd, 0, VFP_REG_ZERO, fpscr);
 }
 
 static u32 vfp_double_fcmpez(int dd, int unused, int dm, u32 fpscr)
 {
-	return vfp_compare(dd, 1, -1, fpscr);
+	return vfp_compare(dd, 1, VFP_REG_ZERO, fpscr);
 }
 
 static u32 vfp_double_fcvts(int sd, int unused, int dm, u32 fpscr)
diff -Nru a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
--- a/arch/arm/vfp/vfphw.S	2004-12-24 13:36:30 -08:00
+++ b/arch/arm/vfp/vfphw.S	2004-12-24 13:36:30 -08:00
@@ -199,6 +199,11 @@
 	mov	pc, lr
 	.endr
 
+	@ virtual register 16 for compare with zero
+	mov	r0, #0
+	mov	r1, #0
+	mov	pc, lr
+
 	.globl	vfp_put_double
 vfp_put_double:
 	mov	r0, r0, lsr #1
diff -Nru a/arch/arm/vfp/vfpsingle.c b/arch/arm/vfp/vfpsingle.c
--- a/arch/arm/vfp/vfpsingle.c	2004-12-24 13:37:32 -08:00
+++ b/arch/arm/vfp/vfpsingle.c	2004-12-24 13:37:32 -08:00
@@ -31,7 +31,7 @@
  * ===========================================================================
  */
 #include <linux/kernel.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/ptrace.h>
 #include <asm/vfp.h>
 
@@ -201,7 +201,7 @@
 		vfp_put_float(sd, d);
 	}
 
-	return exceptions;
+	return exceptions & ~VFP_NAN_FLAG;
 }
 
 /*
@@ -246,7 +246,7 @@
 	/*
 	 * If one was a signalling NAN, raise invalid operation.
 	 */
-	return tn == VFP_SNAN || tm == VFP_SNAN ? FPSCR_IOC : 0x100;
+	return tn == VFP_SNAN || tm == VFP_SNAN ? FPSCR_IOC : VFP_NAN_FLAG;
 }
 
 
diff -Nru a/arch/arm26/kernel/ptrace.c b/arch/arm26/kernel/ptrace.c
--- a/arch/arm26/kernel/ptrace.c	2004-12-24 13:36:55 -08:00
+++ b/arch/arm26/kernel/ptrace.c	2004-12-24 13:36:55 -08:00
@@ -614,7 +614,7 @@
 			/* make sure single-step breakpoint is gone. */
 			child->ptrace &= ~PT_SINGLESTEP;
 			ptrace_cancel_bpt(child);
-			if (child->state != TASK_ZOMBIE) {
+			if (child->exit_state != EXIT_ZOMBIE) {
 				child->exit_code = SIGKILL;
 				wake_up_process(child);
 			}
diff -Nru a/arch/arm26/kernel/time.c b/arch/arm26/kernel/time.c
--- a/arch/arm26/kernel/time.c	2004-12-24 13:37:01 -08:00
+++ b/arch/arm26/kernel/time.c	2004-12-24 13:37:01 -08:00
@@ -166,6 +166,9 @@
 static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
         do_set_rtc(); //FIME - EVERY timer IRQ?
         profile_tick(CPU_PROFILING, regs);
 	return IRQ_HANDLED; //FIXME - is this right?
diff -Nru a/arch/arm26/machine/dma.c b/arch/arm26/machine/dma.c
--- a/arch/arm26/machine/dma.c	2004-12-24 13:37:02 -08:00
+++ b/arch/arm26/machine/dma.c	2004-12-24 13:37:02 -08:00
@@ -47,7 +47,7 @@
 			&fdc1772_dma_read_end - &fdc1772_dma_read);
 		fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
 		enable_fiq(FIQ_FLOPPYDATA);
-		loacl_irq_restore(flags);
+		local_irq_restore(flags);
 	   }
 	   break;
 
diff -Nru a/arch/arm26/machine/small_page.c b/arch/arm26/machine/small_page.c
--- a/arch/arm26/machine/small_page.c	2004-12-24 13:36:16 -08:00
+++ b/arch/arm26/machine/small_page.c	2004-12-24 13:36:16 -08:00
@@ -24,8 +24,8 @@
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/smp.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/pgtable.h>
 
 #define PEDANTIC
diff -Nru a/arch/cris/Kconfig.debug b/arch/cris/Kconfig.debug
--- a/arch/cris/Kconfig.debug	2004-12-24 13:37:43 -08:00
+++ b/arch/cris/Kconfig.debug	2004-12-24 13:37:43 -08:00
@@ -1,15 +1,11 @@
 menu "Kernel hacking"
 
-source "lib/Kconfig.debug"
-
 #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC
-config PROFILE
+config PROFILING
 	bool "Kernel profiling support"
 
-config PROFILE_SHIFT
-	int "Profile shift count"
-	depends on PROFILE
-	default "2"
+config SYSTEM_PROFILER
+        bool "System profiling support"
 
 config ETRAX_KGDB
 	bool "Use kernel GDB debugger"
@@ -24,5 +20,22 @@
 	  This should connect you to your booted kernel (or boot it now if you
 	  didn't before).  The kernel halts when it boots, waiting for gdb if
 	  this option is turned on!
+
+
+config DEBUG_INFO
+        bool "Compile the kernel with debug info"
+        help
+          If you say Y here the resulting kernel image will include
+          debugging info resulting in a larger kernel image.
+          Say Y here only if you plan to use gdb to debug the kernel.
+          If you don't debug the kernel, you can say N.
+
+config FRAME_POINTER
+        bool "Compile the kernel with frame pointers"
+        help
+          If you say Y here the resulting kernel image will be slightly larger
+          and slower, but it will give very useful debugging information.
+          If you don't debug the kernel, you can say N, but we may not be able
+          to solve problems without frame pointers.
 
 endmenu
diff -Nru a/arch/cris/Makefile b/arch/cris/Makefile
--- a/arch/cris/Makefile	2004-12-24 13:36:48 -08:00
+++ b/arch/cris/Makefile	2004-12-24 13:36:48 -08:00
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.20 2004/05/14 14:35:58 orjanf Exp $
+# $Id: Makefile,v 1.23 2004/10/19 13:07:34 starvik Exp $
 # cris/Makefile
 #
 # This file is included by the global makefile so that you can add your own
@@ -80,7 +80,7 @@
 archmrproper:
 archclean:
 	$(Q)$(MAKE) $(clean)=arch/$(ARCH)/boot
-	rm -f timage vmlinux.bin cramfs.img
+	rm -f timage vmlinux.bin decompress.bin rescue.bin cramfs.img
 	rm -rf $(LD_SCRIPT).tmp
 
 prepare: arch/$(ARCH)/.links include/asm-$(ARCH)/.arch \
diff -Nru a/arch/cris/arch-v10/drivers/Kconfig b/arch/cris/arch-v10/drivers/Kconfig
--- a/arch/cris/arch-v10/drivers/Kconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/cris/arch-v10/drivers/Kconfig	2004-12-24 13:36:31 -08:00
@@ -549,44 +549,17 @@
 
 config ETRAX_IDE
 	bool "ATA/IDE support"
+	select IDE
+	select BLK_DEV_IDE
+	select BLK_DEV_IDEDISK
+	select BLK_DEV_IDECD
+	select BLK_DEV_IDEDMA
+	select DMA_NONPCI
 	help
 	  Enable this to get support for ATA/IDE.
 	  You can't use parallell ports or SCSI ports
 	  at the same time.
 
-# here we should add the CONFIG_'s necessary to enable the basic
-# general ide drivers so the common case does not need to go
-# into that config submenu. enable disk and CD support. others
-# need to go fiddle in the submenu..
-config IDE
-	tristate
-	depends on ETRAX_IDE
-	default y
-
-config BLK_DEV_IDE
-	tristate
-	depends on ETRAX_IDE
-	default y
-
-config BLK_DEV_IDEDISK
-	tristate
-	depends on ETRAX_IDE
-	default y
-
-config BLK_DEV_IDECD
-	tristate
-	depends on ETRAX_IDE
-	default y
-
-config BLK_DEV_IDEDMA
-	bool
-	depends on ETRAX_IDE
-	default y
-
-config DMA_NONPCI
-	bool
-	depends on ETRAX_IDE
-	default y
 
 config ETRAX_IDE_DELAY
 	int "Delay for drives to regain consciousness"
diff -Nru a/arch/cris/arch-v10/drivers/Makefile b/arch/cris/arch-v10/drivers/Makefile
--- a/arch/cris/arch-v10/drivers/Makefile	2004-12-24 13:36:16 -08:00
+++ b/arch/cris/arch-v10/drivers/Makefile	2004-12-24 13:36:16 -08:00
@@ -2,15 +2,11 @@
 # Makefile for Etrax-specific drivers
 #
 
-obj-$(CONFIG_ETRAX_ETHERNET)            += ethernet.o
-obj-$(CONFIG_ETRAX_SERIAL)              += serial.o
 obj-$(CONFIG_ETRAX_AXISFLASHMAP)        += axisflashmap.o
 obj-$(CONFIG_ETRAX_I2C) 	        += i2c.o
 obj-$(CONFIG_ETRAX_I2C_EEPROM)          += eeprom.o
 obj-$(CONFIG_ETRAX_GPIO) 	        += gpio.o
 obj-$(CONFIG_ETRAX_DS1302)              += ds1302.o
 obj-$(CONFIG_ETRAX_PCF8563)		+= pcf8563.o
-obj-$(CONFIG_ETRAX_IDE)                 += ide.o
-obj-$(CONFIG_ETRAX_USB_HOST)            += usb-host.o
 
 
diff -Nru a/arch/cris/arch-v10/drivers/axisflashmap.c b/arch/cris/arch-v10/drivers/axisflashmap.c
--- a/arch/cris/arch-v10/drivers/axisflashmap.c	2004-12-24 13:37:17 -08:00
+++ b/arch/cris/arch-v10/drivers/axisflashmap.c	2004-12-24 13:37:17 -08:00
@@ -11,6 +11,9 @@
  * partition split defined below.
  *
  * $Log: axisflashmap.c,v $
+ * Revision 1.10  2004/08/16 12:37:22  starvik
+ * Merge of Linux 2.6.8
+ *
  * Revision 1.8  2004/05/14 07:58:03  starvik
  * Merge of changes from 2.4
  *
@@ -153,6 +156,14 @@
 #define FLASH_CACHED_ADDR    KSEG_F
 #endif
 
+#if CONFIG_ETRAX_FLASH_BUSWIDTH==1
+#define flash_data __u8
+#elif CONFIG_ETRAX_FLASH_BUSWIDTH==2
+#define flash_data __u16
+#elif CONFIG_ETRAX_FLASH_BUSWIDTH==4
+#define flash_data __u16
+#endif
+
 /* From head.S */
 extern unsigned long romfs_start, romfs_length, romfs_in_flash;
 
@@ -161,19 +172,11 @@
 
 /* Map driver functions. */
 
-static __u8 flash_read8(struct map_info *map, unsigned long ofs)
-{
-	return *(__u8 *)(map->map_priv_1 + ofs);
-}
-
-static __u16 flash_read16(struct map_info *map, unsigned long ofs)
+static map_word flash_read(struct map_info *map, unsigned long ofs)
 {
-	return *(__u16 *)(map->map_priv_1 + ofs);
-}
-
-static __u32 flash_read32(struct map_info *map, unsigned long ofs)
-{
-	return *(volatile unsigned int *)(map->map_priv_1 + ofs);
+	map_word tmp;
+	tmp.x[0] = *(flash_data *)(map->map_priv_1 + ofs);
+	return tmp;
 }
 
 static void flash_copy_from(struct map_info *map, void *to,
@@ -182,19 +185,9 @@
 	memcpy(to, (void *)(map->map_priv_1 + from), len);
 }
 
-static void flash_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
-	*(__u8 *)(map->map_priv_1 + adr) = d;
-}
-
-static void flash_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
-	*(__u16 *)(map->map_priv_1 + adr) = d;
-}
-
-static void flash_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void flash_write(struct map_info *map, map_word d, unsigned long adr)
 {
-	*(__u32 *)(map->map_priv_1 + adr) = d;
+	*(flash_data *)(map->map_priv_1 + adr) = (flash_data)d.x[0];
 }
 
 /*
@@ -215,14 +208,10 @@
 static struct map_info map_cse0 = {
 	.name = "cse0",
 	.size = MEM_CSE0_SIZE,
-	.buswidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
-	.read8 = flash_read8,
-	.read16 = flash_read16,
-	.read32 = flash_read32,
+	.bankwidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
+	.read = flash_read,
 	.copy_from = flash_copy_from,
-	.write8 = flash_write8,
-	.write16 = flash_write16,
-	.write32 = flash_write32,
+	.write = flash_write,
 	.map_priv_1 = FLASH_UNCACHED_ADDR
 };
 
@@ -235,14 +224,10 @@
 static struct map_info map_cse1 = {
 	.name = "cse1",
 	.size = MEM_CSE1_SIZE,
-	.buswidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
-	.read8 = flash_read8,
-	.read16 = flash_read16,
-	.read32 = flash_read32,
+	.bankwidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
+	.read = flash_read,
 	.copy_from = flash_copy_from,
-	.write8 = flash_write8,
-	.write16 = flash_write16,
-	.write32 = flash_write32,
+	.write = flash_write,
 	.map_priv_1 = FLASH_UNCACHED_ADDR + MEM_CSE0_SIZE
 };
 
diff -Nru a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
--- a/arch/cris/arch-v10/drivers/ds1302.c	2004-12-24 13:37:19 -08:00
+++ b/arch/cris/arch-v10/drivers/ds1302.c	2004-12-24 13:37:19 -08:00
@@ -7,6 +7,9 @@
 *! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init
 *!
 *! $Log: ds1302.c,v $
+*! Revision 1.14  2004/08/24 06:48:43  starvik
+*! Whitespace cleanup
+*!
 *! Revision 1.13  2004/05/28 09:26:59  starvik
 *! Modified I2C initialization to work in 2.6.
 *!
@@ -123,7 +126,7 @@
 *!
 *! (C) Copyright 1999, 2000, 2001  Axis Communications AB, LUND, SWEDEN
 *!
-*! $Id: ds1302.c,v 1.13 2004/05/28 09:26:59 starvik Exp $
+*! $Id: ds1302.c,v 1.14 2004/08/24 06:48:43 starvik Exp $
 *!
 *!***************************************************************************/
 
diff -Nru a/arch/cris/arch-v10/drivers/ethernet.c b/arch/cris/arch-v10/drivers/ethernet.c
--- a/arch/cris/arch-v10/drivers/ethernet.c	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1789 +0,0 @@
-/* $Id: ethernet.c,v 1.22 2004/05/14 07:58:03 starvik Exp $
- *
- * e100net.c: A network driver for the ETRAX 100LX network controller.
- *
- * Copyright (c) 1998-2002 Axis Communications AB.
- *
- * The outline of this driver comes from skeleton.c.
- *
- * $Log: ethernet.c,v $
- * Revision 1.22  2004/05/14 07:58:03  starvik
- * Merge of changes from 2.4
- *
- * Revision 1.20  2004/03/11 11:38:40  starvik
- * Merge of Linux 2.6.4
- *
- * Revision 1.18  2003/12/03 13:45:46  starvik
- * Use hardware pad for short packets to prevent information leakage.
- *
- * Revision 1.17  2003/07/04 08:27:37  starvik
- * Merge of Linux 2.5.74
- *
- * Revision 1.16  2003/04/24 08:28:22  starvik
- * New LED behaviour: LED off when no link
- *
- * Revision 1.15  2003/04/09 05:20:47  starvik
- * Merge of Linux 2.5.67
- *
- * Revision 1.13  2003/03/06 16:11:01  henriken
- * Off by one error in group address register setting.
- *
- * Revision 1.12  2003/02/27 17:24:19  starvik
- * Corrected Rev to Revision
- *
- * Revision 1.11  2003/01/24 09:53:21  starvik
- * Oops. Initialize GA to 0, not to 1
- *
- * Revision 1.10  2003/01/24 09:50:55  starvik
- * Initialize GA_0 and GA_1 to 0 to avoid matching of unwanted packets
- *
- * Revision 1.9  2002/12/13 07:40:58  starvik
- * Added basic ethtool interface
- * Handled out of memory when allocating new buffers
- *
- * Revision 1.8  2002/12/11 13:13:57  starvik
- * Added arch/ to v10 specific includes
- * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
- *
- * Revision 1.7  2002/11/26 09:41:42  starvik
- * Added e100_set_config (standard interface to set media type)
- * Added protection against preemptive scheduling
- * Added standard MII ioctls
- *
- * Revision 1.6  2002/11/21 07:18:18  starvik
- * Timers must be initialized in 2.5.48
- *
- * Revision 1.5  2002/11/20 11:56:11  starvik
- * Merge of Linux 2.5.48
- *
- * Revision 1.4  2002/11/18 07:26:46  starvik
- * Linux 2.5 port of latest Linux 2.4 ethernet driver
- *
- * Revision 1.33  2002/10/02 20:16:17  hp
- * SETF, SETS: Use underscored IO_x_ macros rather than incorrect token concatenation
- *
- * Revision 1.32  2002/09/16 06:05:58  starvik
- * Align memory returned by dev_alloc_skb
- * Moved handling of sent packets to interrupt to avoid reference counting problem
- *
- * Revision 1.31  2002/09/10 13:28:23  larsv
- * Return -EINVAL for unknown ioctls to avoid confusing tools that tests
- * for supported functionality by issuing special ioctls, i.e. wireless
- * extensions.
- *
- * Revision 1.30  2002/05/07 18:50:08  johana
- * Correct spelling in comments.
- *
- * Revision 1.29  2002/05/06 05:38:49  starvik
- * Performance improvements:
- *    Large packets are not copied (breakpoint set to 256 bytes)
- *    The cache bug workaround is delayed until half of the receive list
- *      has been used
- *    Added transmit list
- *    Transmit interrupts are only enabled when transmit queue is full
- *
- * Revision 1.28.2.1  2002/04/30 08:15:51  starvik
- * Performance improvements:
- *   Large packets are not copied (breakpoint set to 256 bytes)
- *   The cache bug workaround is delayed until half of the receive list
- *     has been used.
- *   Added transmit list
- *   Transmit interrupts are only enabled when transmit queue is full
- *
- * Revision 1.28  2002/04/22 11:47:21  johana
- * Fix according to 2.4.19-pre7. time_after/time_before and
- * missing end of comment.
- * The patch has a typo for ethernet.c in e100_clear_network_leds(),
- *  that is fixed here.
- *
- * Revision 1.27  2002/04/12 11:55:11  bjornw
- * Added TODO
- *
- * Revision 1.26  2002/03/15 17:11:02  bjornw
- * Use prepare_rx_descriptor after the CPU has touched the receiving descs
- *
- * Revision 1.25  2002/03/08 13:07:53  bjornw
- * Unnecessary spinlock removed
- *
- * Revision 1.24  2002/02/20 12:57:43  fredriks
- * Replaced MIN() with min().
- *
- * Revision 1.23  2002/02/20 10:58:14  fredriks
- * Strip the Ethernet checksum (4 bytes) before forwarding a frame to upper layers.
- *
- * Revision 1.22  2002/01/30 07:48:22  matsfg
- * Initiate R_NETWORK_TR_CTRL
- *
- * Revision 1.21  2001/11/23 11:54:49  starvik
- * Added IFF_PROMISC and IFF_ALLMULTI handling in set_multicast_list
- * Removed compiler warnings
- *
- * Revision 1.20  2001/11/12 19:26:00  pkj
- * * Corrected e100_negotiate() to not assign half to current_duplex when
- *   it was supposed to compare them...
- * * Cleaned up failure handling in e100_open().
- * * Fixed compiler warnings.
- *
- * Revision 1.19  2001/11/09 07:43:09  starvik
- * Added full duplex support
- * Added ioctl to set speed and duplex
- * Clear LED timer only runs when LED is lit
- *
- * Revision 1.18  2001/10/03 14:40:43  jonashg
- * Update rx_bytes counter.
- *
- * Revision 1.17  2001/06/11 12:43:46  olof
- * Modified defines for network LED behavior
- *
- * Revision 1.16  2001/05/30 06:12:46  markusl
- * TxDesc.next should not be set to NULL
- *
- * Revision 1.15  2001/05/29 10:27:04  markusl
- * Updated after review remarks:
- * +Use IO_EXTRACT
- * +Handle underrun
- *
- * Revision 1.14  2001/05/29 09:20:14  jonashg
- * Use driver name on printk output so one can tell which driver that complains.
- *
- * Revision 1.13  2001/05/09 12:35:59  johana
- * Use DMA_NBR and IRQ_NBR defines from dma.h and irq.h
- *
- * Revision 1.12  2001/04/05 11:43:11  tobiasa
- * Check dev before panic.
- *
- * Revision 1.11  2001/04/04 11:21:05  markusl
- * Updated according to review remarks
- *
- * Revision 1.10  2001/03/26 16:03:06  bjornw
- * Needs linux/config.h
- *
- * Revision 1.9  2001/03/19 14:47:48  pkj
- * * Make sure there is always a pause after the network LEDs are
- *   changed so they will not look constantly lit during heavy traffic.
- * * Always use HZ when setting times relative to jiffies.
- * * Use LED_NETWORK_SET() when setting the network LEDs.
- *
- * Revision 1.8  2001/02/27 13:52:48  bjornw
- * malloc.h -> slab.h
- *
- * Revision 1.7  2001/02/23 13:46:38  bjornw
- * Spellling check
- *
- * Revision 1.6  2001/01/26 15:21:04  starvik
- * Don't disable interrupts while reading MDIO registers (MDIO is slow)
- * Corrected promiscuous mode
- * Improved deallocation of IRQs ("ifconfig eth0 down" now works)
- *
- * Revision 1.5  2000/11/29 17:22:22  bjornw
- * Get rid of the udword types legacy stuff
- *
- * Revision 1.4  2000/11/22 16:36:09  bjornw
- * Please marketing by using the correct case when spelling Etrax.
- *
- * Revision 1.3  2000/11/21 16:43:04  bjornw
- * Minor short->int change
- *
- * Revision 1.2  2000/11/08 14:27:57  bjornw
- * 2.4 port
- *
- * Revision 1.1  2000/11/06 13:56:00  bjornw
- * Verbatim copy of the 1.24 version of e100net.c from elinux
- *
- * Revision 1.24  2000/10/04 15:55:23  bjornw
- * * Use virt_to_phys etc. for DMA addresses
- * * Removed bogus CHECKSUM_UNNECESSARY
- *
- *
- */
-
-#include <linux/config.h>
-
-#include <linux/module.h>
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-#include <linux/in.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/spinlock.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-
-#include <linux/if.h>
-#include <linux/mii.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/ethtool.h>
-
-#include <asm/arch/svinto.h>/* DMA and register descriptions */
-#include <asm/io.h>         /* LED_* I/O functions */
-#include <asm/irq.h>
-#include <asm/dma.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
-#include <asm/ethernet.h>
-#include <asm/cache.h>
-
-//#define ETHDEBUG
-#define D(x)
-
-/*
- * The name of the card. Is used for messages and in the requests for
- * io regions, irqs and dma channels
- */
-
-static const char* cardname = "ETRAX 100LX built-in ethernet controller";
-
-/* A default ethernet address. Highlevel SW will set the real one later */
-
-static struct sockaddr default_mac = {
-	0,
-	{ 0x00, 0x40, 0x8C, 0xCD, 0x00, 0x00 }
-};
-
-/* Information that need to be kept for each board. */
-struct net_local {
-	struct net_device_stats stats;
-
-	/* Tx control lock.  This protects the transmit buffer ring
-	 * state along with the "tx full" state of the driver.  This
-	 * means all netif_queue flow control actions are protected
-	 * by this lock as well.
-	 */
-	spinlock_t lock;
-};
-
-typedef struct etrax_eth_descr
-{
-	etrax_dma_descr descr;
-	struct sk_buff* skb;
-} etrax_eth_descr;
-
-/* Some transceivers requires special handling */
-struct transceiver_ops
-{
-	unsigned int oui;
-	void (*check_speed)(void);
-	void (*check_duplex)(void);
-};
-
-struct transceiver_ops* transceiver;
-
-/* Duplex settings */
-enum duplex
-{
-	half,
-	full,
-	autoneg
-};
-
-/* Dma descriptors etc. */
-
-#define MAX_MEDIA_DATA_SIZE 1518
-
-#define MIN_PACKET_LEN      46
-#define ETHER_HEAD_LEN      14
-
-/* 
-** MDIO constants.
-*/
-#define MDIO_BASE_STATUS_REG                0x1
-#define MDIO_BASE_CONTROL_REG               0x0
-#define MDIO_PHY_ID_HIGH_REG                0x2
-#define MDIO_PHY_ID_LOW_REG                 0x3
-#define MDIO_BC_NEGOTIATE                0x0200
-#define MDIO_BC_FULL_DUPLEX_MASK         0x0100
-#define MDIO_BC_AUTO_NEG_MASK            0x1000
-#define MDIO_BC_SPEED_SELECT_MASK        0x2000
-#define MDIO_STATUS_100_FD               0x4000
-#define MDIO_STATUS_100_HD               0x2000
-#define MDIO_STATUS_10_FD                0x1000
-#define MDIO_STATUS_10_HD                0x0800
-#define MDIO_STATUS_SPEED_DUPLEX_MASK	 0x7800
-#define MDIO_ADVERTISMENT_REG               0x4
-#define MDIO_ADVERT_100_FD                0x100
-#define MDIO_ADVERT_100_HD                0x080
-#define MDIO_ADVERT_10_FD                 0x040
-#define MDIO_ADVERT_10_HD                 0x020
-#define MDIO_LINK_UP_MASK                   0x4
-#define MDIO_START                          0x1
-#define MDIO_READ                           0x2
-#define MDIO_WRITE                          0x1
-#define MDIO_PREAMBLE              0xfffffffful
-
-/* Broadcom specific */
-#define MDIO_AUX_CTRL_STATUS_REG           0x18
-#define MDIO_BC_FULL_DUPLEX_IND             0x1
-#define MDIO_BC_SPEED                       0x2
-
-/* TDK specific */
-#define MDIO_TDK_DIAGNOSTIC_REG              18
-#define MDIO_TDK_DIAGNOSTIC_RATE          0x400
-#define MDIO_TDK_DIAGNOSTIC_DPLX          0x800
-
-/* Network flash constants */
-#define NET_FLASH_TIME                  (HZ/50) /* 20 ms */
-#define NET_FLASH_PAUSE                (HZ/100) /* 10 ms */
-#define NET_LINK_UP_CHECK_INTERVAL       (2*HZ) /* 2 s   */
-#define NET_DUPLEX_CHECK_INTERVAL        (2*HZ) /* 2 s   */
-
-#define NO_NETWORK_ACTIVITY 0
-#define NETWORK_ACTIVITY    1
-
-#define NBR_OF_RX_DESC     64
-#define NBR_OF_TX_DESC     256
-
-/* Large packets are sent directly to upper layers while small packets are */
-/* copied (to reduce memory waste). The following constant decides the breakpoint */
-#define RX_COPYBREAK 256
-
-/* Due to a chip bug we need to flush the cache when descriptors are returned */
-/* to the DMA. To decrease performance impact we return descriptors in chunks. */
-/* The following constant determines the number of descriptors to return. */
-#define RX_QUEUE_THRESHOLD  NBR_OF_RX_DESC/2
-
-#define GET_BIT(bit,val)   (((val) >> (bit)) & 0x01)
-
-/* Define some macros to access ETRAX 100 registers */
-#define SETF(var, reg, field, val) var = (var & ~IO_MASK_(reg##_, field##_)) | \
-					  IO_FIELD_(reg##_, field##_, val)
-#define SETS(var, reg, field, val) var = (var & ~IO_MASK_(reg##_, field##_)) | \
-					  IO_STATE_(reg##_, field##_, _##val)
-
-static etrax_eth_descr *myNextRxDesc;  /* Points to the next descriptor to
-                                          to be processed */
-static etrax_eth_descr *myLastRxDesc;  /* The last processed descriptor */
-static etrax_eth_descr *myPrevRxDesc;  /* The descriptor right before myNextRxDesc */
-
-static etrax_eth_descr RxDescList[NBR_OF_RX_DESC] __attribute__ ((aligned(32)));
-
-static etrax_eth_descr* myFirstTxDesc; /* First packet not yet sent */
-static etrax_eth_descr* myLastTxDesc;  /* End of send queue */
-static etrax_eth_descr* myNextTxDesc;  /* Next descriptor to use */
-static etrax_eth_descr TxDescList[NBR_OF_TX_DESC] __attribute__ ((aligned(32)));
-
-static unsigned int network_rec_config_shadow = 0;
-static unsigned int mdio_phy_addr; /* Transciever address */
-
-static unsigned int network_tr_ctrl_shadow = 0;
-
-/* Network speed indication. */
-static struct timer_list speed_timer = TIMER_INITIALIZER(NULL, 0, 0);
-static struct timer_list clear_led_timer = TIMER_INITIALIZER(NULL, 0, 0);
-static int current_speed; /* Speed read from transceiver */
-static int current_speed_selection; /* Speed selected by user */
-static unsigned long led_next_time;
-static int led_active;
-static int rx_queue_len;
-
-/* Duplex */
-static struct timer_list duplex_timer = TIMER_INITIALIZER(NULL, 0, 0);
-static int full_duplex;
-static enum duplex current_duplex;
-
-/* Index to functions, as function prototypes. */
-
-static int etrax_ethernet_init(void);
-
-static int e100_open(struct net_device *dev);
-static int e100_set_mac_address(struct net_device *dev, void *addr);
-static int e100_send_packet(struct sk_buff *skb, struct net_device *dev);
-static irqreturn_t e100rxtx_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-static irqreturn_t e100nw_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-static void e100_rx(struct net_device *dev);
-static int e100_close(struct net_device *dev);
-static int e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
-static int e100_ethtool_ioctl(struct net_device* dev, struct ifreq *ifr);
-static int e100_set_config(struct net_device* dev, struct ifmap* map);
-static void e100_tx_timeout(struct net_device *dev);
-static struct net_device_stats *e100_get_stats(struct net_device *dev);
-static void set_multicast_list(struct net_device *dev);
-static void e100_hardware_send_packet(char *buf, int length);
-static void update_rx_stats(struct net_device_stats *);
-static void update_tx_stats(struct net_device_stats *);
-static int e100_probe_transceiver(void);
-
-static void e100_check_speed(unsigned long dummy);
-static void e100_set_speed(unsigned long speed);
-static void e100_check_duplex(unsigned long dummy);
-static void e100_set_duplex(enum duplex);
-static void e100_negotiate(void);
-
-static unsigned short e100_get_mdio_reg(unsigned char reg_num);
-static void e100_set_mdio_reg(unsigned char reg, unsigned short data);
-static void e100_send_mdio_cmd(unsigned short cmd, int write_cmd);
-static void e100_send_mdio_bit(unsigned char bit);
-static unsigned char e100_receive_mdio_bit(void);
-static void e100_reset_transceiver(void);
-
-static void e100_clear_network_leds(unsigned long dummy);
-static void e100_set_network_leds(int active);
-
-static void broadcom_check_speed(void);
-static void broadcom_check_duplex(void);
-static void tdk_check_speed(void);
-static void tdk_check_duplex(void);
-static void generic_check_speed(void);
-static void generic_check_duplex(void);
-
-struct transceiver_ops transceivers[] =
-{
-	{0x1018, broadcom_check_speed, broadcom_check_duplex},  /* Broadcom */
-	{0xC039, tdk_check_speed, tdk_check_duplex},            /* TDK 2120 */
-	{0x039C, tdk_check_speed, tdk_check_duplex},            /* TDK 2120C */
-	{0x0000, generic_check_speed, generic_check_duplex}     /* Generic, must be last */
-};
-
-#define tx_done(dev) (*R_DMA_CH0_CMD == 0)
-
-/*
- * Check for a network adaptor of this type, and return '0' if one exists.
- * If dev->base_addr == 0, probe all likely locations.
- * If dev->base_addr == 1, always return failure.
- * If dev->base_addr == 2, allocate space for the device and return success
- * (detachable devices only).
- */
-
-static int __init
-etrax_ethernet_init(void)
-{
-	struct net_device *dev;
-	int i, err;
-
-	printk(KERN_INFO
-	       "ETRAX 100LX 10/100MBit ethernet v2.0 (c) 2000-2003 Axis Communications AB\n");
-
-	dev = alloc_etherdev(sizeof(struct net_local));
-	if (!dev)
-		return -ENOMEM;
-
-	dev->base_addr = (unsigned int)R_NETWORK_SA_0; /* just to have something to show */	
-
-	/* now setup our etrax specific stuff */
-
-	dev->irq = NETWORK_DMA_RX_IRQ_NBR; /* we really use DMATX as well... */
-	dev->dma = NETWORK_RX_DMA_NBR;
-
-	/* fill in our handlers so the network layer can talk to us in the future */
-
-	dev->open               = e100_open;
-	dev->hard_start_xmit    = e100_send_packet;
-	dev->stop               = e100_close;
-	dev->get_stats          = e100_get_stats;
-	dev->set_multicast_list = set_multicast_list;
-	dev->set_mac_address    = e100_set_mac_address;
-	dev->do_ioctl           = e100_ioctl;
-	dev->set_config		= e100_set_config;
-	dev->tx_timeout         = e100_tx_timeout;
-
-	/* Initialise the list of Etrax DMA-descriptors */
-
-	/* Initialise receive descriptors */
-
-	for (i = 0; i < NBR_OF_RX_DESC; i++) {
-		/* Allocate two extra cachelines to make sure that buffer used by DMA
-		 * does not share cacheline with any other data (to avoid cache bug)
-		 */
-		RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
-		RxDescList[i].descr.ctrl   = 0;
-		RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE;
-		RxDescList[i].descr.next   = virt_to_phys(&RxDescList[i + 1]);
-		RxDescList[i].descr.buf    = L1_CACHE_ALIGN(virt_to_phys(RxDescList[i].skb->data));
-		RxDescList[i].descr.status = 0;
-		RxDescList[i].descr.hw_len = 0;             
-		prepare_rx_descriptor(&RxDescList[i].descr);
-	}
-
-	RxDescList[NBR_OF_RX_DESC - 1].descr.ctrl   = d_eol;
-	RxDescList[NBR_OF_RX_DESC - 1].descr.next   = virt_to_phys(&RxDescList[0]);
-	rx_queue_len = 0;
-
-	/* Initialize transmit descriptors */
-	for (i = 0; i < NBR_OF_TX_DESC; i++) {
-		TxDescList[i].descr.ctrl   = 0;
-		TxDescList[i].descr.sw_len = 0;
-		TxDescList[i].descr.next   = virt_to_phys(&TxDescList[i + 1].descr);
-		TxDescList[i].descr.buf    = 0;
-		TxDescList[i].descr.status = 0;
-		TxDescList[i].descr.hw_len = 0;
-		TxDescList[i].skb = 0;
-	}
-
-	TxDescList[NBR_OF_TX_DESC - 1].descr.ctrl   = d_eol;
-	TxDescList[NBR_OF_TX_DESC - 1].descr.next   = virt_to_phys(&TxDescList[0].descr);
-        
-	/* Initialise initial pointers */
-
-	myNextRxDesc  = &RxDescList[0];
-	myLastRxDesc  = &RxDescList[NBR_OF_RX_DESC - 1];
-	myPrevRxDesc  = &RxDescList[NBR_OF_RX_DESC - 1];
-	myFirstTxDesc = &TxDescList[0];
-	myNextTxDesc  = &TxDescList[0];
-	myLastTxDesc  = &TxDescList[NBR_OF_TX_DESC - 1];
-
-	/* Register device */
-	err = register_netdev(dev);
-	if (err) {
-		free_netdev(dev);
-		return err;
-	}
-
-	/* set the default MAC address */
-
-	e100_set_mac_address(dev, &default_mac);
-
-	/* Initialize speed indicator stuff. */
-
-	current_speed = 10;
-	current_speed_selection = 0; /* Auto */
-	speed_timer.expires = jiffies + NET_LINK_UP_CHECK_INTERVAL;
-	speed_timer.function = e100_check_speed;
-        
-	clear_led_timer.function = e100_clear_network_leds;
-        
-	full_duplex = 0;
-	current_duplex = autoneg;
-	duplex_timer.expires = jiffies + NET_DUPLEX_CHECK_INTERVAL;		
-	duplex_timer.function = e100_check_duplex;
-
-	/* Initialize group address registers to make sure that no */
-	/* unwanted addresses are matched */
-	*R_NETWORK_GA_0 = 0x00000000;
-	*R_NETWORK_GA_1 = 0x00000000;
-	return 0;
-}
-
-/* set MAC address of the interface. called from the core after a
- * SIOCSIFADDR ioctl, and from the bootup above.
- */
-
-static int
-e100_set_mac_address(struct net_device *dev, void *p)
-{
-	struct net_local *np = (struct net_local *)dev->priv;
-	struct sockaddr *addr = p;
-	int i;
-
-	spin_lock(&np->lock); /* preemption protection */
-
-	/* remember it */
-
-	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
-
-	/* Write it to the hardware.
-	 * Note the way the address is wrapped:
-	 * *R_NETWORK_SA_0 = a0_0 | (a0_1 << 8) | (a0_2 << 16) | (a0_3 << 24);
-	 * *R_NETWORK_SA_1 = a0_4 | (a0_5 << 8);
-	 */
-	
-	*R_NETWORK_SA_0 = dev->dev_addr[0] | (dev->dev_addr[1] << 8) |
-		(dev->dev_addr[2] << 16) | (dev->dev_addr[3] << 24);
-	*R_NETWORK_SA_1 = dev->dev_addr[4] | (dev->dev_addr[5] << 8);
-	*R_NETWORK_SA_2 = 0;
-
-	/* show it in the log as well */
-
-	printk(KERN_INFO "%s: changed MAC to ", dev->name);
-
-	for (i = 0; i < 5; i++)
-		printk("%02X:", dev->dev_addr[i]);
-
-	printk("%02X\n", dev->dev_addr[i]);
-
-	spin_unlock(&np->lock);
-
-	return 0;
-}
-
-/*
- * Open/initialize the board. This is called (in the current kernel)
- * sometime after booting when the 'ifconfig' program is run.
- *
- * This routine should set everything up anew at each open, even
- * registers that "should" only need to be set once at boot, so that
- * there is non-reboot way to recover if something goes wrong.
- */
-
-static int
-e100_open(struct net_device *dev)
-{
-	unsigned long flags;
-
-	/* enable the MDIO output pin */
-
-	*R_NETWORK_MGM_CTRL = IO_STATE(R_NETWORK_MGM_CTRL, mdoe, enable);
-
-	*R_IRQ_MASK0_CLR =
-		IO_STATE(R_IRQ_MASK0_CLR, overrun, clr) |
-		IO_STATE(R_IRQ_MASK0_CLR, underrun, clr) |
-		IO_STATE(R_IRQ_MASK0_CLR, excessive_col, clr);
-	
-	/* clear dma0 and 1 eop and descr irq masks */
-	*R_IRQ_MASK2_CLR =
-		IO_STATE(R_IRQ_MASK2_CLR, dma0_descr, clr) |
-		IO_STATE(R_IRQ_MASK2_CLR, dma0_eop, clr) |
-		IO_STATE(R_IRQ_MASK2_CLR, dma1_descr, clr) |
-		IO_STATE(R_IRQ_MASK2_CLR, dma1_eop, clr);
-
-	/* Reset and wait for the DMA channels */
-
-	RESET_DMA(NETWORK_TX_DMA_NBR);
-	RESET_DMA(NETWORK_RX_DMA_NBR);
-	WAIT_DMA(NETWORK_TX_DMA_NBR);
-	WAIT_DMA(NETWORK_RX_DMA_NBR);
-
-	/* Initialise the etrax network controller */
-
-	/* allocate the irq corresponding to the receiving DMA */
-
-	if (request_irq(NETWORK_DMA_RX_IRQ_NBR, e100rxtx_interrupt, 0,
-			cardname, (void *)dev)) {
-		goto grace_exit0;
-	}
-
-	/* allocate the irq corresponding to the transmitting DMA */
-
-	if (request_irq(NETWORK_DMA_TX_IRQ_NBR, e100rxtx_interrupt, 0,
-			cardname, (void *)dev)) {
-		goto grace_exit1;
-	}
-
-	/* allocate the irq corresponding to the network errors etc */
-
-	if (request_irq(NETWORK_STATUS_IRQ_NBR, e100nw_interrupt, 0,
-			cardname, (void *)dev)) {
-		goto grace_exit2;
-	}
-
-	/* give the HW an idea of what MAC address we want */
-
-	*R_NETWORK_SA_0 = dev->dev_addr[0] | (dev->dev_addr[1] << 8) |
-		(dev->dev_addr[2] << 16) | (dev->dev_addr[3] << 24);
-	*R_NETWORK_SA_1 = dev->dev_addr[4] | (dev->dev_addr[5] << 8);
-	*R_NETWORK_SA_2 = 0;
-
-#if 0
-	/* use promiscuous mode for testing */
-	*R_NETWORK_GA_0 = 0xffffffff;
-	*R_NETWORK_GA_1 = 0xffffffff;
-
-	*R_NETWORK_REC_CONFIG = 0xd; /* broadcast rec, individ. rec, ma0 enabled */
-#else
-	SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, broadcast, receive);
-	SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, ma0, enable);
-	SETF(network_rec_config_shadow, R_NETWORK_REC_CONFIG, duplex, full_duplex);
-	*R_NETWORK_REC_CONFIG = network_rec_config_shadow;
-#endif
-
-	*R_NETWORK_GEN_CONFIG =
-		IO_STATE(R_NETWORK_GEN_CONFIG, phy,    mii_clk) |
-		IO_STATE(R_NETWORK_GEN_CONFIG, enable, on);
-
-	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, clr);
-	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, delay, none);
-	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, cancel, dont);
-	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, cd, enable);
-	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, retry, enable);
-	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, pad, enable);
-	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, crc, enable);
-	*R_NETWORK_TR_CTRL = network_tr_ctrl_shadow;
-
-	save_flags(flags);
-	cli();
-
-	/* enable the irq's for ethernet DMA */
-
-	*R_IRQ_MASK2_SET =
-		IO_STATE(R_IRQ_MASK2_SET, dma0_eop, set) |
-		IO_STATE(R_IRQ_MASK2_SET, dma1_eop, set);
-
-	*R_IRQ_MASK0_SET =
-		IO_STATE(R_IRQ_MASK0_SET, overrun,       set) |
-		IO_STATE(R_IRQ_MASK0_SET, underrun,      set) |
-		IO_STATE(R_IRQ_MASK0_SET, excessive_col, set);
-
-	/* make sure the irqs are cleared */
-
-	*R_DMA_CH0_CLR_INTR = IO_STATE(R_DMA_CH0_CLR_INTR, clr_eop, do);
-	*R_DMA_CH1_CLR_INTR = IO_STATE(R_DMA_CH1_CLR_INTR, clr_eop, do);
-
-	/* make sure the rec and transmit error counters are cleared */
-
-	(void)*R_REC_COUNTERS;  /* dummy read */
-	(void)*R_TR_COUNTERS;   /* dummy read */
-
-	/* start the receiving DMA channel so we can receive packets from now on */
-
-	*R_DMA_CH1_FIRST = virt_to_phys(myNextRxDesc);
-	*R_DMA_CH1_CMD = IO_STATE(R_DMA_CH1_CMD, cmd, start);
-
-	/* Set up transmit DMA channel so it can be restarted later */
-        
-	*R_DMA_CH0_FIRST = 0;
-	*R_DMA_CH0_DESCR = virt_to_phys(myLastTxDesc);
-
-	restore_flags(flags);
-	
-	/* Probe for transceiver */
-	if (e100_probe_transceiver())
-		goto grace_exit3;
-
-	/* Start duplex/speed timers */
-	add_timer(&speed_timer);
-	add_timer(&duplex_timer);
-
-	/* We are now ready to accept transmit requeusts from
-	 * the queueing layer of the networking.
-	 */
-	netif_start_queue(dev);
-
-	return 0;
-
-grace_exit3:
-	free_irq(NETWORK_STATUS_IRQ_NBR, (void *)dev);
-grace_exit2:
-	free_irq(NETWORK_DMA_TX_IRQ_NBR, (void *)dev);
-grace_exit1:
-	free_irq(NETWORK_DMA_RX_IRQ_NBR, (void *)dev);
-grace_exit0:
-	return -EAGAIN;
-}
-
-
-static void
-generic_check_speed(void)
-{
-	unsigned long data;
-	data = e100_get_mdio_reg(MDIO_ADVERTISMENT_REG);
-	if ((data & MDIO_ADVERT_100_FD) ||
-	    (data & MDIO_ADVERT_100_HD))
-		current_speed = 100;
-	else
-		current_speed = 10;
-}
-
-static void
-tdk_check_speed(void)
-{
-	unsigned long data;
-	data = e100_get_mdio_reg(MDIO_TDK_DIAGNOSTIC_REG);
-	current_speed = (data & MDIO_TDK_DIAGNOSTIC_RATE ? 100 : 10);
-}
-
-static void
-broadcom_check_speed(void)
-{
-	unsigned long data;
-	data = e100_get_mdio_reg(MDIO_AUX_CTRL_STATUS_REG);
-	current_speed = (data & MDIO_BC_SPEED ? 100 : 10);
-}
-
-static void
-e100_check_speed(unsigned long dummy)
-{
-	static int led_initiated = 0;
-	unsigned long data;
-	int old_speed = current_speed;
-
-	data = e100_get_mdio_reg(MDIO_BASE_STATUS_REG);
-	if (!(data & MDIO_LINK_UP_MASK)) {
-		current_speed = 0;
-	} else {
-		transceiver->check_speed();
-	}
-	
-	if ((old_speed != current_speed) || !led_initiated) {
-		led_initiated = 1;
-		e100_set_network_leds(NO_NETWORK_ACTIVITY);
-	}
-
-	/* Reinitialize the timer. */
-	speed_timer.expires = jiffies + NET_LINK_UP_CHECK_INTERVAL;
-	add_timer(&speed_timer);
-}
-
-static void
-e100_negotiate(void)
-{
-	unsigned short data = e100_get_mdio_reg(MDIO_ADVERTISMENT_REG);
-
-	/* Discard old speed and duplex settings */
-	data &= ~(MDIO_ADVERT_100_HD | MDIO_ADVERT_100_FD | 
-	          MDIO_ADVERT_10_FD | MDIO_ADVERT_10_HD);
-  
-	switch (current_speed_selection) {
-		case 10 :
-			if (current_duplex == full)
-				data |= MDIO_ADVERT_10_FD;
-			else if (current_duplex == half)
-				data |= MDIO_ADVERT_10_HD;
-			else
-				data |= MDIO_ADVERT_10_HD |  MDIO_ADVERT_10_FD;
-			break;
-
-		case 100 :
-			 if (current_duplex == full)
-				data |= MDIO_ADVERT_100_FD;
-			else if (current_duplex == half)
-				data |= MDIO_ADVERT_100_HD;
-			else
-				data |= MDIO_ADVERT_100_HD |  MDIO_ADVERT_100_FD;
-			break;
-
-		case 0 : /* Auto */
-			 if (current_duplex == full)
-				data |= MDIO_ADVERT_100_FD | MDIO_ADVERT_10_FD;
-			else if (current_duplex == half)
-				data |= MDIO_ADVERT_100_HD | MDIO_ADVERT_10_HD;
-			else
-				data |= MDIO_ADVERT_100_HD | MDIO_ADVERT_100_FD | MDIO_ADVERT_10_FD | MDIO_ADVERT_10_HD;
-			break;
-
-		default : /* assume autoneg speed and duplex */
-			data |= MDIO_ADVERT_100_HD | MDIO_ADVERT_100_FD | 
-			        MDIO_ADVERT_10_FD | MDIO_ADVERT_10_HD;
-	}
-
-	e100_set_mdio_reg(MDIO_ADVERTISMENT_REG, data);
-
-	/* Renegotiate with link partner */
-	data = e100_get_mdio_reg(MDIO_BASE_CONTROL_REG);
-	data |= MDIO_BC_NEGOTIATE;
-
-	e100_set_mdio_reg(MDIO_BASE_CONTROL_REG, data);
-}
-
-static void
-e100_set_speed(unsigned long speed)
-{
-	if (speed != current_speed_selection) {
-		current_speed_selection = speed;
-		e100_negotiate();
-	}
-}
-
-static void
-e100_check_duplex(unsigned long dummy)
-{
-	int old_duplex = full_duplex;
-	transceiver->check_duplex();
-	if (old_duplex != full_duplex) {
-		/* Duplex changed */
-		SETF(network_rec_config_shadow, R_NETWORK_REC_CONFIG, duplex, full_duplex);
-		*R_NETWORK_REC_CONFIG = network_rec_config_shadow;
-	}
-
-	/* Reinitialize the timer. */
-	duplex_timer.expires = jiffies + NET_DUPLEX_CHECK_INTERVAL;
-	add_timer(&duplex_timer);
-}
-
-static void
-generic_check_duplex(void)
-{
-	unsigned long data;
-	data = e100_get_mdio_reg(MDIO_ADVERTISMENT_REG);
-	if ((data & MDIO_ADVERT_100_FD) ||
-	    (data & MDIO_ADVERT_10_FD))
-		full_duplex = 1;
-	else
-		full_duplex = 0;
-}
-
-static void
-tdk_check_duplex(void)
-{
-	unsigned long data;
-	data = e100_get_mdio_reg(MDIO_TDK_DIAGNOSTIC_REG);
-	full_duplex = (data & MDIO_TDK_DIAGNOSTIC_DPLX) ? 1 : 0;
-}
-
-static void
-broadcom_check_duplex(void)
-{
-	unsigned long data;
-	data = e100_get_mdio_reg(MDIO_AUX_CTRL_STATUS_REG);
-	full_duplex = (data & MDIO_BC_FULL_DUPLEX_IND) ? 1 : 0;
-}
-
-static void 
-e100_set_duplex(enum duplex new_duplex)
-{
-	if (new_duplex != current_duplex) {
-		current_duplex = new_duplex;
-		e100_negotiate();
-	}
-}
-
-static int
-e100_probe_transceiver(void)
-{
-	unsigned int phyid_high;
-	unsigned int phyid_low;
-	unsigned int oui;
-	struct transceiver_ops* ops = NULL;
-
-	/* Probe MDIO physical address */
-	for (mdio_phy_addr = 0; mdio_phy_addr <= 31; mdio_phy_addr++) {
-		if (e100_get_mdio_reg(MDIO_BASE_STATUS_REG) != 0xffff)
-			break;
-	}
-	if (mdio_phy_addr == 32)
-		 return -ENODEV;
-
-	/* Get manufacturer */
-	phyid_high = e100_get_mdio_reg(MDIO_PHY_ID_HIGH_REG);
-	phyid_low = e100_get_mdio_reg(MDIO_PHY_ID_LOW_REG);
-	oui = (phyid_high << 6) | (phyid_low >> 10);
-
-	for (ops = &transceivers[0]; ops->oui; ops++) {
-		if (ops->oui == oui)
-			break;
-	}
-	transceiver = ops;
-
-	return 0;
-}
-
-static unsigned short
-e100_get_mdio_reg(unsigned char reg_num)
-{
-	unsigned short cmd;    /* Data to be sent on MDIO port */
-	unsigned short data;   /* Data read from MDIO */
-	int bitCounter;
-	
-	/* Start of frame, OP Code, Physical Address, Register Address */
-	cmd = (MDIO_START << 14) | (MDIO_READ << 12) | (mdio_phy_addr << 7) |
-		(reg_num << 2);
-	
-	e100_send_mdio_cmd(cmd, 0);
-	
-	data = 0;
-	
-	/* Data... */
-	for (bitCounter=15; bitCounter>=0 ; bitCounter--) {
-		data |= (e100_receive_mdio_bit() << bitCounter);
-	}
-
-	return data;
-}
-
-static void
-e100_set_mdio_reg(unsigned char reg, unsigned short data)
-{
-	int bitCounter;
-	unsigned short cmd;
-
-	cmd = (MDIO_START << 14) | (MDIO_WRITE << 12) | (mdio_phy_addr << 7) |
-	      (reg << 2);
-
-	e100_send_mdio_cmd(cmd, 1);
-
-	/* Data... */
-	for (bitCounter=15; bitCounter>=0 ; bitCounter--) {
-		e100_send_mdio_bit(GET_BIT(bitCounter, data));
-	}
-
-}
-
-static void
-e100_send_mdio_cmd(unsigned short cmd, int write_cmd)
-{
-	int bitCounter;
-	unsigned char data = 0x2;
-	
-	/* Preamble */
-	for (bitCounter = 31; bitCounter>= 0; bitCounter--)
-		e100_send_mdio_bit(GET_BIT(bitCounter, MDIO_PREAMBLE));
-
-	for (bitCounter = 15; bitCounter >= 2; bitCounter--)
-		e100_send_mdio_bit(GET_BIT(bitCounter, cmd));
-
-	/* Turnaround */
-	for (bitCounter = 1; bitCounter >= 0 ; bitCounter--)
-		if (write_cmd)
-			e100_send_mdio_bit(GET_BIT(bitCounter, data));
-		else
-			e100_receive_mdio_bit();
-}
-
-static void
-e100_send_mdio_bit(unsigned char bit)
-{
-	*R_NETWORK_MGM_CTRL =
-		IO_STATE(R_NETWORK_MGM_CTRL, mdoe, enable) |
-		IO_FIELD(R_NETWORK_MGM_CTRL, mdio, bit);
-	udelay(1);
-	*R_NETWORK_MGM_CTRL =
-		IO_STATE(R_NETWORK_MGM_CTRL, mdoe, enable) |
-		IO_MASK(R_NETWORK_MGM_CTRL, mdck) |
-		IO_FIELD(R_NETWORK_MGM_CTRL, mdio, bit);
-	udelay(1);
-}
-
-static unsigned char
-e100_receive_mdio_bit()
-{
-	unsigned char bit;
-	*R_NETWORK_MGM_CTRL = 0;
-	bit = IO_EXTRACT(R_NETWORK_STAT, mdio, *R_NETWORK_STAT);
-	udelay(1);
-	*R_NETWORK_MGM_CTRL = IO_MASK(R_NETWORK_MGM_CTRL, mdck);
-	udelay(1);
-	return bit;
-}
-
-static void 
-e100_reset_transceiver(void)
-{
-	unsigned short cmd;
-	unsigned short data;
-	int bitCounter;
-
-	data = e100_get_mdio_reg(MDIO_BASE_CONTROL_REG);
-
-	cmd = (MDIO_START << 14) | (MDIO_WRITE << 12) | (mdio_phy_addr << 7) | (MDIO_BASE_CONTROL_REG << 2);
-
-	e100_send_mdio_cmd(cmd, 1);
-	
-	data |= 0x8000;
-	
-	for (bitCounter = 15; bitCounter >= 0 ; bitCounter--) {
-		e100_send_mdio_bit(GET_BIT(bitCounter, data));
-	}
-}
-
-/* Called by upper layers if they decide it took too long to complete
- * sending a packet - we need to reset and stuff.
- */
-
-static void
-e100_tx_timeout(struct net_device *dev)
-{
-	struct net_local *np = (struct net_local *)dev->priv;
-	unsigned long flags;
-
-	spin_lock_irqsave(&np->lock, flags);
-
-	printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
-	       tx_done(dev) ? "IRQ problem" : "network cable problem");
-	
-	/* remember we got an error */
-	
-	np->stats.tx_errors++; 
-	
-	/* reset the TX DMA in case it has hung on something */
-	
-	RESET_DMA(NETWORK_TX_DMA_NBR);
-	WAIT_DMA(NETWORK_TX_DMA_NBR);
-	
-	/* Reset the transceiver. */
-	
-	e100_reset_transceiver();
-	
-	/* and get rid of the packets that never got an interrupt */
-	while (myFirstTxDesc != myNextTxDesc)
-	{
-		dev_kfree_skb(myFirstTxDesc->skb);
-		myFirstTxDesc->skb = 0;
-		myFirstTxDesc = phys_to_virt(myFirstTxDesc->descr.next);
-	}
-
-	/* Set up transmit DMA channel so it can be restarted later */
-	*R_DMA_CH0_FIRST = 0;
-	*R_DMA_CH0_DESCR = virt_to_phys(myLastTxDesc);	
-
-	/* tell the upper layers we're ok again */
-	
-	netif_wake_queue(dev);
-	spin_unlock_irqrestore(&np->lock, flags);
-}
-
-
-/* This will only be invoked if the driver is _not_ in XOFF state.
- * What this means is that we need not check it, and that this
- * invariant will hold if we make sure that the netif_*_queue()
- * calls are done at the proper times.
- */
-
-static int
-e100_send_packet(struct sk_buff *skb, struct net_device *dev)
-{
-	struct net_local *np = (struct net_local *)dev->priv;
-	unsigned char *buf = skb->data;
-	unsigned long flags;
-	
-#ifdef ETHDEBUG
-	printk("send packet len %d\n", length);
-#endif
-	spin_lock_irqsave(&np->lock, flags);  /* protect from tx_interrupt and ourself */
-
-	myNextTxDesc->skb = skb;
-
-	dev->trans_start = jiffies;
-	
-	e100_hardware_send_packet(buf, skb->len);
-
-	myNextTxDesc = phys_to_virt(myNextTxDesc->descr.next);
-
-	/* Stop queue if full */
-	if (myNextTxDesc == myFirstTxDesc) {
-		netif_stop_queue(dev);
-	}
-
-	spin_unlock_irqrestore(&np->lock, flags);
-
-	return 0;
-}
-
-/*
- * The typical workload of the driver:
- *   Handle the network interface interrupts.
- */
-
-static irqreturn_t
-e100rxtx_interrupt(int irq, void *dev_id, struct pt_regs * regs)
-{
-	struct net_device *dev = (struct net_device *)dev_id;
-	struct net_local *np = (struct net_local *)dev->priv;
-	unsigned long irqbits = *R_IRQ_MASK2_RD;
- 
-	/* Disable RX/TX IRQs to avoid reentrancy */
-	*R_IRQ_MASK2_CLR =
-	  IO_STATE(R_IRQ_MASK2_CLR, dma0_eop, clr) |
-	  IO_STATE(R_IRQ_MASK2_CLR, dma1_eop, clr);
-
-	/* Handle received packets */
-	if (irqbits & IO_STATE(R_IRQ_MASK2_RD, dma1_eop, active)) {
-		/* acknowledge the eop interrupt */
-
-		*R_DMA_CH1_CLR_INTR = IO_STATE(R_DMA_CH1_CLR_INTR, clr_eop, do);
-
-		/* check if one or more complete packets were indeed received */
-
-		while (*R_DMA_CH1_FIRST != virt_to_phys(myNextRxDesc)) {
-			/* Take out the buffer and give it to the OS, then
-			 * allocate a new buffer to put a packet in.
-			 */
-			e100_rx(dev);
-			((struct net_local *)dev->priv)->stats.rx_packets++;
-			/* restart/continue on the channel, for safety */
-			*R_DMA_CH1_CMD = IO_STATE(R_DMA_CH1_CMD, cmd, restart);
-			/* clear dma channel 1 eop/descr irq bits */
-			*R_DMA_CH1_CLR_INTR =
-				IO_STATE(R_DMA_CH1_CLR_INTR, clr_eop, do) |
-				IO_STATE(R_DMA_CH1_CLR_INTR, clr_descr, do);
-			
-			/* now, we might have gotten another packet
-			   so we have to loop back and check if so */
-		}
-	}
-
-	/* Report any packets that have been sent */
-	while (myFirstTxDesc != phys_to_virt(*R_DMA_CH0_FIRST) &&
-	       myFirstTxDesc != myNextTxDesc)
-	{
-		np->stats.tx_bytes += myFirstTxDesc->skb->len;
-		np->stats.tx_packets++;
-
-		/* dma is ready with the transmission of the data in tx_skb, so now
-		   we can release the skb memory */
-		dev_kfree_skb_irq(myFirstTxDesc->skb);
-		myFirstTxDesc->skb = 0;
-		myFirstTxDesc = phys_to_virt(myFirstTxDesc->descr.next);
-	}
-
-	if (irqbits & IO_STATE(R_IRQ_MASK2_RD, dma0_eop, active)) {
-		/* acknowledge the eop interrupt and wake up queue */
-		*R_DMA_CH0_CLR_INTR = IO_STATE(R_DMA_CH0_CLR_INTR, clr_eop, do);
-		netif_wake_queue(dev);
-	}
-
-	/* Enable RX/TX IRQs again */
-	*R_IRQ_MASK2_SET =
-	  IO_STATE(R_IRQ_MASK2_SET, dma0_eop, set) |
-	  IO_STATE(R_IRQ_MASK2_SET, dma1_eop, set);
-
-	return IRQ_HANDLED;
-}
-
-static irqreturn_t
-e100nw_interrupt(int irq, void *dev_id, struct pt_regs * regs)
-{
-	struct net_device *dev = (struct net_device *)dev_id;
-	struct net_local *np = (struct net_local *)dev->priv;
-	unsigned long irqbits = *R_IRQ_MASK0_RD;
-
-	/* check for underrun irq */
-	if (irqbits & IO_STATE(R_IRQ_MASK0_RD, underrun, active)) { 
-		SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, clr);
-		*R_NETWORK_TR_CTRL = network_tr_ctrl_shadow;
-		SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, nop);
-		np->stats.tx_errors++;
-		D(printk("ethernet receiver underrun!\n"));
-	}
-
-	/* check for overrun irq */
-	if (irqbits & IO_STATE(R_IRQ_MASK0_RD, overrun, active)) { 
-		update_rx_stats(&np->stats); /* this will ack the irq */
-		D(printk("ethernet receiver overrun!\n"));
-	}
-	/* check for excessive collision irq */
-	if (irqbits & IO_STATE(R_IRQ_MASK0_RD, excessive_col, active)) { 
-		SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, clr);
-		*R_NETWORK_TR_CTRL = network_tr_ctrl_shadow;
-		SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, nop);
-		*R_NETWORK_TR_CTRL = IO_STATE(R_NETWORK_TR_CTRL, clr_error, clr);
-		np->stats.tx_errors++;
-		D(printk("ethernet excessive collisions!\n"));
-	}
-	return IRQ_HANDLED;
-}
-
-/* We have a good packet(s), get it/them out of the buffers. */
-static void
-e100_rx(struct net_device *dev)
-{
-	struct sk_buff *skb;
-	int length = 0;
-	struct net_local *np = (struct net_local *)dev->priv;
-	unsigned char *skb_data_ptr;
-#ifdef ETHDEBUG
-	int i;
-#endif
-
-	if (!led_active && time_after(jiffies, led_next_time)) {
-		/* light the network leds depending on the current speed. */
-		e100_set_network_leds(NETWORK_ACTIVITY);
-
-		/* Set the earliest time we may clear the LED */
-		led_next_time = jiffies + NET_FLASH_TIME;
-		led_active = 1;
-		mod_timer(&clear_led_timer, jiffies + HZ/10);
-	}
-
-	length = myNextRxDesc->descr.hw_len - 4;
-	((struct net_local *)dev->priv)->stats.rx_bytes += length;
-
-#ifdef ETHDEBUG
-	printk("Got a packet of length %d:\n", length);
-	/* dump the first bytes in the packet */
-	skb_data_ptr = (unsigned char *)phys_to_virt(myNextRxDesc->descr.buf);
-	for (i = 0; i < 8; i++) {
-		printk("%d: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", i * 8,
-		       skb_data_ptr[0],skb_data_ptr[1],skb_data_ptr[2],skb_data_ptr[3],
-		       skb_data_ptr[4],skb_data_ptr[5],skb_data_ptr[6],skb_data_ptr[7]);
-		skb_data_ptr += 8;
-	}
-#endif
-
-	if (length < RX_COPYBREAK) {
-		/* Small packet, copy data */
-		skb = dev_alloc_skb(length - ETHER_HEAD_LEN);
-		if (!skb) {
-			np->stats.rx_errors++;
-			printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
-			return;
-		}
-
-		skb_put(skb, length - ETHER_HEAD_LEN);        /* allocate room for the packet body */
-		skb_data_ptr = skb_push(skb, ETHER_HEAD_LEN); /* allocate room for the header */
-
-#ifdef ETHDEBUG
-		printk("head = 0x%x, data = 0x%x, tail = 0x%x, end = 0x%x\n",
-		  skb->head, skb->data, skb->tail, skb->end);
-		printk("copying packet to 0x%x.\n", skb_data_ptr);
-#endif
-          
-		memcpy(skb_data_ptr, phys_to_virt(myNextRxDesc->descr.buf), length);
-	}
-	else {
-		/* Large packet, send directly to upper layers and allocate new 
-		 * memory (aligned to cache line boundary to avoid bug).
-		 * Before sending the skb to upper layers we must make sure that 
-		 * skb->data points to the aligned start of the packet. 
-		 */
-		int align;  
-		struct sk_buff *new_skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
-		if (!new_skb) {
-			np->stats.rx_errors++;
-			printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
-			return;
-		}
-		skb = myNextRxDesc->skb;
-		align = (int)phys_to_virt(myNextRxDesc->descr.buf) - (int)skb->data;	
-		skb_put(skb, length + align); 
-		skb_pull(skb, align); /* Remove alignment bytes */
-		myNextRxDesc->skb = new_skb;
-		myNextRxDesc->descr.buf = L1_CACHE_ALIGN(virt_to_phys(myNextRxDesc->skb->data));
-	}
-
-	skb->dev = dev;
-	skb->protocol = eth_type_trans(skb, dev);
-
-	/* Send the packet to the upper layers */
-	netif_rx(skb);
-
-	/* Prepare for next packet */
-	myNextRxDesc->descr.status = 0;
-	myPrevRxDesc = myNextRxDesc;
-	myNextRxDesc = phys_to_virt(myNextRxDesc->descr.next);
-
-	rx_queue_len++;
-
-	/* Check if descriptors should be returned */
-	if (rx_queue_len == RX_QUEUE_THRESHOLD) {
-		flush_etrax_cache();
-		myPrevRxDesc->descr.ctrl |= d_eol;
-		myLastRxDesc->descr.ctrl &= ~d_eol;
-		myLastRxDesc = myPrevRxDesc;
-		rx_queue_len = 0;
-	}
-}
-
-/* The inverse routine to net_open(). */
-static int
-e100_close(struct net_device *dev)
-{
-	struct net_local *np = (struct net_local *)dev->priv;
-
-	printk(KERN_INFO "Closing %s.\n", dev->name);
-
-	netif_stop_queue(dev);
-
-	*R_IRQ_MASK0_CLR =
-		IO_STATE(R_IRQ_MASK0_CLR, overrun, clr) |
-		IO_STATE(R_IRQ_MASK0_CLR, underrun, clr) |
-		IO_STATE(R_IRQ_MASK0_CLR, excessive_col, clr);
-	
-	*R_IRQ_MASK2_CLR =
-		IO_STATE(R_IRQ_MASK2_CLR, dma0_descr, clr) |
-		IO_STATE(R_IRQ_MASK2_CLR, dma0_eop, clr) |
-		IO_STATE(R_IRQ_MASK2_CLR, dma1_descr, clr) |
-		IO_STATE(R_IRQ_MASK2_CLR, dma1_eop, clr);
-
-	/* Stop the receiver and the transmitter */
-
-	RESET_DMA(NETWORK_TX_DMA_NBR);
-	RESET_DMA(NETWORK_RX_DMA_NBR);
-
-	/* Flush the Tx and disable Rx here. */
-
-	free_irq(NETWORK_DMA_RX_IRQ_NBR, (void *)dev);
-	free_irq(NETWORK_DMA_TX_IRQ_NBR, (void *)dev);
-	free_irq(NETWORK_STATUS_IRQ_NBR, (void *)dev);
-
-	/* Update the statistics here. */
-
-	update_rx_stats(&np->stats);
-	update_tx_stats(&np->stats);
-
-	/* Stop speed/duplex timers */
-	del_timer(&speed_timer);
-	del_timer(&duplex_timer);
-
-	return 0;
-}
-
-static int
-e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
-	struct mii_ioctl_data *data = if_mii(ifr);
-	struct net_local *np = netdev_priv(dev);
-
-	spin_lock(&np->lock); /* Preempt protection */
-	switch (cmd) {
-		case SIOCETHTOOL:
-			return e100_ethtool_ioctl(dev,ifr);
-		case SIOCGMIIPHY: /* Get PHY address */
-			data->phy_id = mdio_phy_addr;
-			break;
-		case SIOCGMIIREG: /* Read MII register */
-			data->val_out = e100_get_mdio_reg(data->reg_num);
-			break;
-		case SIOCSMIIREG: /* Write MII register */
-			e100_set_mdio_reg(data->reg_num, data->val_in);
-			break;
-		/* The ioctls below should be considered obsolete but are */
-		/* still present for compatability with old scripts/apps  */	
-		case SET_ETH_SPEED_10:                  /* 10 Mbps */
-			e100_set_speed(10);
-			break;
-		case SET_ETH_SPEED_100:                /* 100 Mbps */
-			e100_set_speed(100);
-			break;
-		case SET_ETH_SPEED_AUTO:              /* Auto negotiate speed */
-			e100_set_speed(0);
-			break;
-		case SET_ETH_DUPLEX_HALF:              /* Half duplex. */
-			e100_set_duplex(half);
-			break;
-		case SET_ETH_DUPLEX_FULL:              /* Full duplex. */
-			e100_set_duplex(full);
-			break;
-		case SET_ETH_DUPLEX_AUTO:             /* Autonegotiate duplex*/
-			e100_set_duplex(autoneg);
-			break;
-		default:
-			return -EINVAL;
-	}
-	spin_unlock(&np->lock);
-	return 0;
-}
-
-static int
-e100_ethtool_ioctl(struct net_device *dev, struct ifreq *ifr)
-{
-	struct ethtool_cmd ecmd;
-
-	if (copy_from_user(&ecmd, ifr->ifr_data, sizeof (ecmd)))
-		return -EFAULT;
-
-	switch (ecmd.cmd) {
-		case ETHTOOL_GSET:
-		{
-			memset((void *) &ecmd, 0, sizeof (ecmd));
-			ecmd.supported = 
-			  SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII |
-			  SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | 
-			  SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full;
-			ecmd.port = PORT_TP;
-			ecmd.transceiver = XCVR_EXTERNAL;
-			ecmd.phy_address = mdio_phy_addr;
-			ecmd.speed = current_speed;
-			ecmd.duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
-			ecmd.advertising = ADVERTISED_TP;
-			if (current_duplex == autoneg && current_speed_selection == 0)
-				ecmd.advertising |= ADVERTISED_Autoneg;
-			else {
-				ecmd.advertising |= 
-				  ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
-				  ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
-				if (current_speed_selection == 10)
-					ecmd.advertising &= ~(ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full);
-				else if (current_speed_selection == 100)
-					ecmd.advertising &= ~(ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full);
-				if (current_duplex == half)
-					ecmd.advertising &= ~(ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Full);
-				else if (current_duplex == full)
-					ecmd.advertising &= ~(ADVERTISED_10baseT_Half | ADVERTISED_100baseT_Half);
-			}
-			ecmd.autoneg = AUTONEG_ENABLE;
-			if (copy_to_user(ifr->ifr_data, &ecmd, sizeof (ecmd)))
-				return -EFAULT;
-		}
-		break;
-		case ETHTOOL_SSET:
-		{
-			if (!capable(CAP_NET_ADMIN)) {
-				return -EPERM;
-			}
-			if (ecmd.autoneg == AUTONEG_ENABLE) {
-				e100_set_duplex(autoneg);
-				e100_set_speed(0);
-			} else {
-				e100_set_duplex(ecmd.duplex == DUPLEX_HALF ? half : full);
-				e100_set_speed(ecmd.speed == SPEED_10 ? 10: 100);
-			}
-		}
-		break;
-		case ETHTOOL_GDRVINFO:
-		{
-			struct ethtool_drvinfo info;
-			memset((void *) &info, 0, sizeof (info));
-			strncpy(info.driver, "ETRAX 100LX", sizeof(info.driver) - 1);
-			strncpy(info.version, "$Revision: 1.22 $", sizeof(info.version) - 1);
-			strncpy(info.fw_version, "N/A", sizeof(info.fw_version) - 1);
-			strncpy(info.bus_info, "N/A", sizeof(info.bus_info) - 1);
-			info.regdump_len = 0;
-			info.eedump_len = 0;
-			info.testinfo_len = 0;
-			if (copy_to_user(ifr->ifr_data, &info, sizeof (info)))
-				return -EFAULT;
-		}
-		break;
-		case ETHTOOL_NWAY_RST:
-			if (current_duplex == autoneg && current_speed_selection == 0)
-				e100_negotiate();
-		break;
-		default:
-			return -EOPNOTSUPP;
-		break;
-	}
-	return 0;
-}
-
-static int
-e100_set_config(struct net_device *dev, struct ifmap *map)
-{
-	struct net_local *np = (struct net_local *)dev->priv;
-	spin_lock(&np->lock); /* Preempt protection */
-	
-	switch(map->port) {
-		case IF_PORT_UNKNOWN:
-			/* Use autoneg */
-			e100_set_speed(0);
-			e100_set_duplex(autoneg);
-			break;
-		case IF_PORT_10BASET:
-			e100_set_speed(10);
-			e100_set_duplex(autoneg);
-			break;
-		case IF_PORT_100BASET:
-		case IF_PORT_100BASETX:
-			e100_set_speed(100);
-			e100_set_duplex(autoneg);
-			break;
-		case IF_PORT_100BASEFX:
-		case IF_PORT_10BASE2:
-		case IF_PORT_AUI:
-			spin_unlock(&np->lock);
-			return -EOPNOTSUPP;
-			break;
-		default:
-			printk(KERN_ERR "%s: Invalid media selected", dev->name);
-			spin_unlock(&np->lock);
-			return -EINVAL;
-	}
-	spin_unlock(&np->lock);
-	return 0;
-}
-
-static void
-update_rx_stats(struct net_device_stats *es)
-{
-	unsigned long r = *R_REC_COUNTERS;
-	/* update stats relevant to reception errors */
-	es->rx_fifo_errors += IO_EXTRACT(R_REC_COUNTERS, congestion, r);
-	es->rx_crc_errors += IO_EXTRACT(R_REC_COUNTERS, crc_error, r);
-	es->rx_frame_errors += IO_EXTRACT(R_REC_COUNTERS, alignment_error, r);
-	es->rx_length_errors += IO_EXTRACT(R_REC_COUNTERS, oversize, r);
-}
-
-static void
-update_tx_stats(struct net_device_stats *es)
-{
-	unsigned long r = *R_TR_COUNTERS;
-	/* update stats relevant to transmission errors */
-	es->collisions +=
-		IO_EXTRACT(R_TR_COUNTERS, single_col, r) +
-		IO_EXTRACT(R_TR_COUNTERS, multiple_col, r);
-	es->tx_errors += IO_EXTRACT(R_TR_COUNTERS, deferred, r);
-}
-
-/*
- * Get the current statistics.
- * This may be called with the card open or closed.
- */
-static struct net_device_stats *
-e100_get_stats(struct net_device *dev)
-{
-	struct net_local *lp = (struct net_local *)dev->priv;
-	unsigned long flags;
-	spin_lock_irqsave(&lp->lock, flags);
-
-	update_rx_stats(&lp->stats);
-	update_tx_stats(&lp->stats);
-	
-	spin_unlock_irqrestore(&lp->lock, flags);
-	return &lp->stats;
-}
-
-/*
- * Set or clear the multicast filter for this adaptor.
- * num_addrs == -1	Promiscuous mode, receive all packets
- * num_addrs == 0	Normal mode, clear multicast list
- * num_addrs > 0	Multicast mode, receive normal and MC packets,
- *			and do best-effort filtering.
- */
-static void
-set_multicast_list(struct net_device *dev)
-{
-	struct net_local *lp = (struct net_local *)dev->priv;
-	int num_addr = dev->mc_count;
-	unsigned long int lo_bits;
-	unsigned long int hi_bits;
-	spin_lock(&lp->lock);
-	if (dev->flags & IFF_PROMISC)
-	{
-		/* promiscuous mode */
-		lo_bits = 0xfffffffful;
-		hi_bits = 0xfffffffful;
-
-		/* Enable individual receive */
-		SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, receive);
-		*R_NETWORK_REC_CONFIG = network_rec_config_shadow;
-	} else if (dev->flags & IFF_ALLMULTI) {
-		/* enable all multicasts */
-		lo_bits = 0xfffffffful;
-		hi_bits = 0xfffffffful;
-
-		/* Disable individual receive */
-		SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, discard);
-		*R_NETWORK_REC_CONFIG =  network_rec_config_shadow;
-	} else if (num_addr == 0) {
-		/* Normal, clear the mc list */
-		lo_bits = 0x00000000ul;
-		hi_bits = 0x00000000ul;
-
-		/* Disable individual receive */
-		SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, discard);
-		*R_NETWORK_REC_CONFIG =  network_rec_config_shadow;
-	} else {
-		/* MC mode, receive normal and MC packets */
-		char hash_ix;
-		struct dev_mc_list *dmi = dev->mc_list;
-		int i;
-		char *baddr;
-		lo_bits = 0x00000000ul;
-		hi_bits = 0x00000000ul;
-		for (i=0; i<num_addr; i++) {
-			/* Calculate the hash index for the GA registers */
-			
-			hash_ix = 0;
-			baddr = dmi->dmi_addr;
-			hash_ix ^= (*baddr) & 0x3f;
-			hash_ix ^= ((*baddr) >> 6) & 0x03;
-			++baddr;
-			hash_ix ^= ((*baddr) << 2) & 0x03c;
-			hash_ix ^= ((*baddr) >> 4) & 0xf;
-			++baddr;
-			hash_ix ^= ((*baddr) << 4) & 0x30;
-			hash_ix ^= ((*baddr) >> 2) & 0x3f;
-			++baddr;
-			hash_ix ^= (*baddr) & 0x3f;
-			hash_ix ^= ((*baddr) >> 6) & 0x03;
-			++baddr;
-			hash_ix ^= ((*baddr) << 2) & 0x03c;
-			hash_ix ^= ((*baddr) >> 4) & 0xf;
-			++baddr;
-			hash_ix ^= ((*baddr) << 4) & 0x30;
-			hash_ix ^= ((*baddr) >> 2) & 0x3f;
-			
-			hash_ix &= 0x3f;
-			
-			if (hash_ix >= 32) {
-				hi_bits |= (1 << (hash_ix-32));
-			}
-			else {
-				lo_bits |= (1 << hash_ix);
-			}
-			dmi = dmi->next;
-		}
-		/* Disable individual receive */
-		SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, discard);
-		*R_NETWORK_REC_CONFIG = network_rec_config_shadow;
-	}
-	*R_NETWORK_GA_0 = lo_bits;
-	*R_NETWORK_GA_1 = hi_bits;
-	spin_unlock(&lp->lock);
-}
-
-void
-e100_hardware_send_packet(char *buf, int length)
-{
-	D(printk("e100 send pack, buf 0x%x len %d\n", buf, length));
-
-	if (!led_active && time_after(jiffies, led_next_time)) {
-		/* light the network leds depending on the current speed. */
-		e100_set_network_leds(NETWORK_ACTIVITY);
-
-		/* Set the earliest time we may clear the LED */
-		led_next_time = jiffies + NET_FLASH_TIME;
-		led_active = 1;
-		mod_timer(&clear_led_timer, jiffies + HZ/10);
-	}
-
-	/* configure the tx dma descriptor */
-	myNextTxDesc->descr.sw_len = length;
-	myNextTxDesc->descr.ctrl = d_eop | d_eol | d_wait;
-	myNextTxDesc->descr.buf = virt_to_phys(buf);
-
-        /* Move end of list */
-        myLastTxDesc->descr.ctrl &= ~d_eol;
-        myLastTxDesc = myNextTxDesc;
-
-	/* Restart DMA channel */
-	*R_DMA_CH0_CMD = IO_STATE(R_DMA_CH0_CMD, cmd, restart);
-}
-
-static void
-e100_clear_network_leds(unsigned long dummy)
-{
-	if (led_active && time_after(jiffies, led_next_time)) {
-		e100_set_network_leds(NO_NETWORK_ACTIVITY);
-
-		/* Set the earliest time we may set the LED */
-		led_next_time = jiffies + NET_FLASH_PAUSE;
-		led_active = 0;
-	}
-}
-
-static void
-e100_set_network_leds(int active)
-{
-#if defined(CONFIG_ETRAX_NETWORK_LED_ON_WHEN_LINK)
-	int light_leds = (active == NO_NETWORK_ACTIVITY);
-#elif defined(CONFIG_ETRAX_NETWORK_LED_ON_WHEN_ACTIVITY)
-	int light_leds = (active == NETWORK_ACTIVITY);
-#else
-#error "Define either CONFIG_ETRAX_NETWORK_LED_ON_WHEN_LINK or CONFIG_ETRAX_NETWORK_LED_ON_WHEN_ACTIVITY"
-#endif
-
-	if (!current_speed) {
-		/* Make LED red, link is down */
-#if defined(CONFIG_ETRAX_NETWORK_RED_ON_NO_CONNECTION)
-		LED_NETWORK_SET(LED_RED);
-#else
-		LED_NETWORK_SET(LED_OFF);
-#endif
-	}
-	else if (light_leds) {
-		if (current_speed == 10) {
-			LED_NETWORK_SET(LED_ORANGE);
-		} else {
-			LED_NETWORK_SET(LED_GREEN);
-		}
-	}
-	else {
-		LED_NETWORK_SET(LED_OFF);
-	}
-}
-
-static int
-etrax_init_module(void)
-{
-	return etrax_ethernet_init();
-}
-
-static int __init
-e100_boot_setup(char* str)
-{
-	struct sockaddr sa = {0};
-	int i;
-
-	/* Parse the colon separated Ethernet station address */
-	for (i = 0; i <  ETH_ALEN; i++) {
-		unsigned int tmp;
-		if (sscanf(str + 3*i, "%2x", &tmp) != 1) {
-			printk(KERN_WARNING "Malformed station address");
-			return 0;
-		}
-		sa.sa_data[i] = (char)tmp;
-	}
-
-	default_mac = sa;
-	return 1;
-}
-
-__setup("etrax100_eth=", e100_boot_setup);
-
-module_init(etrax_init_module);
diff -Nru a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
--- a/arch/cris/arch-v10/drivers/gpio.c	2004-12-24 13:36:16 -08:00
+++ b/arch/cris/arch-v10/drivers/gpio.c	2004-12-24 13:36:16 -08:00
@@ -1,4 +1,4 @@
-/* $Id: gpio.c,v 1.11 2004/05/14 07:58:03 starvik Exp $
+/* $Id: gpio.c,v 1.12 2004/08/24 07:19:59 starvik Exp $
  *
  * Etrax general port I/O device
  *
@@ -9,6 +9,9 @@
  *             Johan Adolfsson  (read/set directions, write, port G)
  *
  * $Log: gpio.c,v $
+ * Revision 1.12  2004/08/24 07:19:59  starvik
+ * Whitespace cleanup
+ *
  * Revision 1.11  2004/05/14 07:58:03  starvik
  * Merge of changes from 2.4
  *
diff -Nru a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c
--- a/arch/cris/arch-v10/drivers/i2c.c	2004-12-24 13:36:17 -08:00
+++ b/arch/cris/arch-v10/drivers/i2c.c	2004-12-24 13:36:17 -08:00
@@ -12,6 +12,12 @@
 *!                                 don't use PB_I2C if DS1302 uses same bits,
 *!                                 use PB.
 *! $Log: i2c.c,v $
+*! Revision 1.9  2004/08/24 06:49:14  starvik
+*! Whitespace cleanup
+*!
+*! Revision 1.8  2004/06/08 08:48:26  starvik
+*! Removed unused code
+*!
 *! Revision 1.7  2004/05/28 09:26:59  starvik
 *! Modified I2C initialization to work in 2.6.
 *!
@@ -69,7 +75,7 @@
 *! (C) Copyright 1999-2002 Axis Communications AB, LUND, SWEDEN
 *!
 *!***************************************************************************/
-/* $Id: i2c.c,v 1.7 2004/05/28 09:26:59 starvik Exp $ */
+/* $Id: i2c.c,v 1.9 2004/08/24 06:49:14 starvik Exp $ */
 
 /****************** INCLUDE FILES SECTION ***********************************/
 
@@ -110,14 +116,6 @@
 #define I2C_DATA_HIGH 1
 #define I2C_DATA_LOW 0
 
-#if 0
-/* TODO: fix this so the CONFIG_ETRAX_I2C_USES... is set in Config.in instead */
-#if defined(CONFIG_DS1302) && (CONFIG_DS1302_SDABIT==0) && \
-           (CONFIG_DS1302_SCLBIT == 1)
-#define CONFIG_ETRAX_I2C_USES_PB_NOT_PB_I2C
-#endif
-#endif
-
 #ifdef CONFIG_ETRAX_I2C_USES_PB_NOT_PB_I2C
 /* Use PB and not PB_I2C */
 #ifndef CONFIG_ETRAX_I2C_DATA_PORT
@@ -441,7 +439,7 @@
 	 */
 	i2c_data(I2C_DATA_HIGH);
 	i2c_delay(CLOCK_LOW_TIME);
-	
+
 	i2c_dir_in();
 }
 
diff -Nru a/arch/cris/arch-v10/drivers/ide.c b/arch/cris/arch-v10/drivers/ide.c
--- a/arch/cris/arch-v10/drivers/ide.c	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,945 +0,0 @@
-/* $Id: ide.c,v 1.1 2004/01/22 08:22:58 starvik Exp $
- *
- * Etrax specific IDE functions, like init and PIO-mode setting etc.
- * Almost the entire ide.c is used for the rest of the Etrax ATA driver.
- * Copyright (c) 2000-2004 Axis Communications AB
- *
- * Authors:    Bjorn Wesen        (initial version)
- *             Mikael Starvik     (pio setup stuff, Linux 2.6 port)
- */
-
-/* Regarding DMA:
- *
- * There are two forms of DMA - "DMA handshaking" between the interface and the drive,
- * and DMA between the memory and the interface. We can ALWAYS use the latter, since it's
- * something built-in in the Etrax. However only some drives support the DMA-mode handshaking
- * on the ATA-bus. The normal PC driver and Triton interface disables memory-if DMA when the
- * device can't do DMA handshaking for some stupid reason. We don't need to do that.
- */
-
-#undef REALLY_SLOW_IO           /* most systems can safely undef this */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-#include <linux/ide.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/arch/svinto.h>
-#include <asm/dma.h>
-
-/* number of Etrax DMA descriptors */
-#define MAX_DMA_DESCRS 64
-
-/* number of times to retry busy-flags when reading/writing IDE-registers
- * this can't be too high because a hung harddisk might cause the watchdog
- * to trigger (sometimes INB and OUTB are called with irq's disabled)
- */
-
-#define IDE_REGISTER_TIMEOUT 300
-
-#ifdef CONFIG_ETRAX_IDE_CSE1_16_RESET
-/* address where the memory-mapped IDE reset bit lives, if used */
-static volatile unsigned long *reset_addr;
-#endif
-
-static int e100_read_command = 0;
-
-#define LOWDB(x)
-#define D(x)
-
-void
-etrax100_ide_outw(unsigned short data, ide_ioreg_t reg) {
-	int timeleft;
-	LOWDB(printk("ow: data 0x%x, reg 0x%x\n", data, reg));
-
-	/* note the lack of handling any timeouts. we stop waiting, but we don't
-	 * really notify anybody.
-	 */
-
-	timeleft = IDE_REGISTER_TIMEOUT;
-	/* wait for busy flag */
-	while(timeleft && (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)))
-		timeleft--;
-
-	/*
-	 * Fall through at a timeout, so the ongoing command will be
-	 * aborted by the write below, which is expected to be a dummy
-	 * command to the command register.  This happens when a faulty
-	 * drive times out on a command.  See comment on timeout in
-	 * INB.
-	 */
-	if(!timeleft)
-		printk("ATA timeout reg 0x%lx := 0x%x\n", reg, data);
-
-	*R_ATA_CTRL_DATA = reg | data; /* write data to the drive's register */
-
-	timeleft = IDE_REGISTER_TIMEOUT;
-	/* wait for transmitter ready */
-	while(timeleft && !(*R_ATA_STATUS_DATA &
-			    IO_MASK(R_ATA_STATUS_DATA, tr_rdy)))
-		timeleft--;
-}
-
-void
-etrax100_ide_outb(unsigned char data, ide_ioreg_t reg)
-{
-	etrax100_ide_outw(data, reg);
-}
-
-void
-etrax100_ide_outbsync(ide_drive_t *drive, u8 addr, unsigned long port)
-{
-	etrax100_ide_outw(addr, port);
-}
-
-unsigned short
-etrax100_ide_inw(ide_ioreg_t reg) {
-	int status;
-	int timeleft;
-
-	timeleft = IDE_REGISTER_TIMEOUT;
-	/* wait for busy flag */
-	while(timeleft && (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)))
-		timeleft--;
-
-	if(!timeleft) {
-		/*
-		 * If we're asked to read the status register, like for
-		 * example when a command does not complete for an
-		 * extended time, but the ATA interface is stuck in a
-		 * busy state at the *ETRAX* ATA interface level (as has
-		 * happened repeatedly with at least one bad disk), then
-		 * the best thing to do is to pretend that we read
-		 * "busy" in the status register, so the IDE driver will
-		 * time-out, abort the ongoing command and perform a
-		 * reset sequence.  Note that the subsequent OUT_BYTE
-		 * call will also timeout on busy, but as long as the
-		 * write is still performed, everything will be fine.
-		 */
-		if ((reg & IO_MASK (R_ATA_CTRL_DATA, addr))
-		    == IO_FIELD (R_ATA_CTRL_DATA, addr, IDE_STATUS_OFFSET))
-			return BUSY_STAT;
-		else
-			/* For other rare cases we assume 0 is good enough.  */
-			return 0;
-	}
-
-	*R_ATA_CTRL_DATA = reg | IO_STATE(R_ATA_CTRL_DATA, rw, read); /* read data */
-
-	timeleft = IDE_REGISTER_TIMEOUT;
-	/* wait for available */
-	while(timeleft && !((status = *R_ATA_STATUS_DATA) &
-			    IO_MASK(R_ATA_STATUS_DATA, dav)))
-		timeleft--;
-
-	if(!timeleft)
-		return 0;
-
-	LOWDB(printk("inb: 0x%x from reg 0x%x\n", status & 0xff, reg));
-
-        return (unsigned short)status;
-}
-
-unsigned char
-etrax100_ide_inb(ide_ioreg_t reg)
-{
-	return (unsigned char)etrax100_ide_inw(reg);
-}
-
-/* PIO timing (in R_ATA_CONFIG)
- *
- *                        _____________________________
- * ADDRESS :     ________/
- *
- *                            _______________
- * DIOR    :     ____________/               \__________
- *
- *                               _______________
- * DATA    :     XXXXXXXXXXXXXXXX_______________XXXXXXXX
- *
- *
- * DIOR is unbuffered while address and data is buffered.
- * This creates two problems:
- * 1. The DIOR pulse is to early (because it is unbuffered)
- * 2. The rise time of DIOR is long
- *
- * There are at least three different plausible solutions
- * 1. Use a pad capable of larger currents in Etrax
- * 2. Use an external buffer
- * 3. Make the strobe pulse longer
- *
- * Some of the strobe timings below are modified to compensate
- * for this. This implies a slight performance decrease.
- *
- * THIS SHOULD NEVER BE CHANGED!
- *
- * TODO: Is this true for the latest LX boards still ?
- */
-
-#define ATA_DMA2_STROBE  4
-#define ATA_DMA2_HOLD    0
-#define ATA_DMA1_STROBE  4
-#define ATA_DMA1_HOLD    1
-#define ATA_DMA0_STROBE 12
-#define ATA_DMA0_HOLD    9
-#define ATA_PIO4_SETUP   1
-#define ATA_PIO4_STROBE  5
-#define ATA_PIO4_HOLD    0
-#define ATA_PIO3_SETUP   1
-#define ATA_PIO3_STROBE  5
-#define ATA_PIO3_HOLD    1
-#define ATA_PIO2_SETUP   1
-#define ATA_PIO2_STROBE  6
-#define ATA_PIO2_HOLD    2
-#define ATA_PIO1_SETUP   2
-#define ATA_PIO1_STROBE 11
-#define ATA_PIO1_HOLD    4
-#define ATA_PIO0_SETUP   4
-#define ATA_PIO0_STROBE 19
-#define ATA_PIO0_HOLD    4
-
-static int e100_dma_check (ide_drive_t *drive);
-static int e100_dma_begin (ide_drive_t *drive);
-static int e100_dma_end (ide_drive_t *drive);
-static int e100_dma_read (ide_drive_t *drive);
-static int e100_dma_write (ide_drive_t *drive);
-static void e100_ide_input_data (ide_drive_t *drive, void *, unsigned int);
-static void e100_ide_output_data (ide_drive_t *drive, void *, unsigned int);
-static void e100_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int);
-static void e100_atapi_output_bytes(ide_drive_t *drive, void *, unsigned int);
-static int e100_dma_off (ide_drive_t *drive);
-static int e100_dma_verbose (ide_drive_t *drive);
-
-
-/*
- * good_dma_drives() lists the model names (from "hdparm -i")
- * of drives which do not support mword2 DMA but which are
- * known to work fine with this interface under Linux.
- */
-
-const char *good_dma_drives[] = {"Micropolis 2112A",
-				 "CONNER CTMA 4000",
-				 "CONNER CTT8000-A",
-				 NULL};
-
-static void tune_e100_ide(ide_drive_t *drive, byte pio)
-{
-	pio = 4;
-	/* pio = ide_get_best_pio_mode(drive, pio, 4, NULL); */
-
-	/* set pio mode! */
-
-	switch(pio) {
-		case 0:
-			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO0_SETUP ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO0_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO0_HOLD ) );
-			break;
-		case 1:
-			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO1_SETUP ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO1_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO1_HOLD ) );
-			break;
-		case 2:
-			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO2_SETUP ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO2_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO2_HOLD ) );
-			break;
-		case 3:
-			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO3_SETUP ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO3_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO3_HOLD ) );
-			break;
-		case 4:
-			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO4_SETUP ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO4_STROBE ) |
-					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO4_HOLD ) );
-			break;
-	}
-}
-
-void __init
-init_e100_ide (void)
-{
-	volatile unsigned int dummy;
-	int h;
-
-	printk("ide: ETRAX 100LX built-in ATA DMA controller\n");
-
-	/* first fill in some stuff in the ide_hwifs fields */
-
-	for(h = 0; h < MAX_HWIFS; h++) {
-		ide_hwif_t *hwif = &ide_hwifs[h];
-		hwif->mmio = 2;
-		hwif->chipset = ide_etrax100;
-		hwif->tuneproc = &tune_e100_ide;
-                hwif->ata_input_data = &e100_ide_input_data;
-                hwif->ata_output_data = &e100_ide_output_data;
-                hwif->atapi_input_bytes = &e100_atapi_input_bytes;
-                hwif->atapi_output_bytes = &e100_atapi_output_bytes;
-                hwif->ide_dma_check = &e100_dma_check;
-                hwif->ide_dma_end = &e100_dma_end;
-		hwif->ide_dma_write = &e100_dma_write;
-		hwif->ide_dma_read = &e100_dma_read;
-		hwif->ide_dma_begin = &e100_dma_begin;
-		hwif->OUTB = &etrax100_ide_outb;
-		hwif->OUTW = &etrax100_ide_outw;
-		hwif->OUTBSYNC = &etrax100_ide_outbsync;
-		hwif->INB = &etrax100_ide_inb;
-		hwif->INW = &etrax100_ide_inw;
-		hwif->ide_dma_off_quietly = &e100_dma_off;
-		hwif->ide_dma_verbose = &e100_dma_verbose;
-		hwif->sg_table =
-		  kmalloc(sizeof(struct scatterlist) * PRD_ENTRIES, GFP_KERNEL);
-	}
-
-	/* actually reset and configure the etrax100 ide/ata interface */
-
-	*R_ATA_CTRL_DATA = 0;
-	*R_ATA_TRANSFER_CNT = 0;
-	*R_ATA_CONFIG = 0;
-
-	genconfig_shadow = (genconfig_shadow &
-			    ~IO_MASK(R_GEN_CONFIG, dma2) &
-			    ~IO_MASK(R_GEN_CONFIG, dma3) &
-			    ~IO_MASK(R_GEN_CONFIG, ata)) |
-		( IO_STATE( R_GEN_CONFIG, dma3, ata    ) |
-		  IO_STATE( R_GEN_CONFIG, dma2, ata    ) |
-		  IO_STATE( R_GEN_CONFIG, ata,  select ) );
-
-	*R_GEN_CONFIG = genconfig_shadow;
-
-        /* pull the chosen /reset-line low */
-
-#ifdef CONFIG_ETRAX_IDE_G27_RESET
-        REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 27, 0);
-#endif
-#ifdef CONFIG_ETRAX_IDE_CSE1_16_RESET
-        REG_SHADOW_SET(port_cse1_addr, port_cse1_shadow, 16, 0);
-#endif
-#ifdef CONFIG_ETRAX_IDE_CSP0_8_RESET
-        REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, 8, 0);
-#endif
-#ifdef CONFIG_ETRAX_IDE_PB7_RESET
-	port_pb_dir_shadow = port_pb_dir_shadow |
-		IO_STATE(R_PORT_PB_DIR, dir7, output);
-	*R_PORT_PB_DIR = port_pb_dir_shadow;
-	REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 7, 1);
-#endif
-
-	/* wait some */
-
-	udelay(25);
-
-	/* de-assert bus-reset */
-
-#ifdef CONFIG_ETRAX_IDE_CSE1_16_RESET
-	REG_SHADOW_SET(port_cse1_addr, port_cse1_shadow, 16, 1);
-#endif
-#ifdef CONFIG_ETRAX_IDE_CSP0_8_RESET
-	REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, 8, 1);
-#endif
-#ifdef CONFIG_ETRAX_IDE_G27_RESET
-	REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 27, 1);
-#endif
-
-	/* make a dummy read to set the ata controller in a proper state */
-	dummy = *R_ATA_STATUS_DATA;
-
-	*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
-			  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
-			  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
-			  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO4_SETUP ) |
-			  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO4_STROBE ) |
-			  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO4_HOLD ) );
-
-	*R_ATA_CTRL_DATA = ( IO_STATE( R_ATA_CTRL_DATA, rw,   read) |
-			     IO_FIELD( R_ATA_CTRL_DATA, addr, 1   ) );
-
-	while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)); /* wait for busy flag*/
-
-	*R_IRQ_MASK0_SET = ( IO_STATE( R_IRQ_MASK0_SET, ata_irq0, set ) |
-			     IO_STATE( R_IRQ_MASK0_SET, ata_irq1, set ) |
-			     IO_STATE( R_IRQ_MASK0_SET, ata_irq2, set ) |
-			     IO_STATE( R_IRQ_MASK0_SET, ata_irq3, set ) );
-
-	printk("ide: waiting %d seconds for drives to regain consciousness\n",
-	       CONFIG_ETRAX_IDE_DELAY);
-
-	h = jiffies + (CONFIG_ETRAX_IDE_DELAY * HZ);
-	while(time_before(jiffies, h)) /* nothing */ ;
-
-	/* reset the dma channels we will use */
-
-	RESET_DMA(ATA_TX_DMA_NBR);
-	RESET_DMA(ATA_RX_DMA_NBR);
-	WAIT_DMA(ATA_TX_DMA_NBR);
-	WAIT_DMA(ATA_RX_DMA_NBR);
-
-}
-
-static int e100_dma_off (ide_drive_t *drive)
-{
-	return 0;
-}
-
-static int e100_dma_verbose (ide_drive_t *drive)
-{
-	printk(", DMA(mode 2)");
-	return 0;
-}
-
-static etrax_dma_descr mydescr;
-
-/*
- * The following routines are mainly used by the ATAPI drivers.
- *
- * These routines will round up any request for an odd number of bytes,
- * so if an odd bytecount is specified, be sure that there's at least one
- * extra byte allocated for the buffer.
- */
-static void
-e100_atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
-{
-	ide_ioreg_t data_reg = IDE_DATA_REG;
-
-	D(printk("atapi_input_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
-		 data_reg, buffer, bytecount));
-
-	if(bytecount & 1) {
-		printk("warning, odd bytecount in cdrom_in_bytes = %d.\n", bytecount);
-		bytecount++; /* to round off */
-	}
-
-	/* make sure the DMA channel is available */
-	RESET_DMA(ATA_RX_DMA_NBR);
-	WAIT_DMA(ATA_RX_DMA_NBR);
-
-	/* setup DMA descriptor */
-
-	mydescr.sw_len = bytecount;
-	mydescr.ctrl   = d_eol;
-	mydescr.buf    = virt_to_phys(buffer);
-
-	/* start the dma channel */
-
-	*R_DMA_CH3_FIRST = virt_to_phys(&mydescr);
-	*R_DMA_CH3_CMD   = IO_STATE(R_DMA_CH3_CMD, cmd, start);
-
-	/* initiate a multi word dma read using PIO handshaking */
-
-	*R_ATA_TRANSFER_CNT = IO_FIELD(R_ATA_TRANSFER_CNT, count, bytecount >> 1);
-
-	*R_ATA_CTRL_DATA = data_reg |
-		IO_STATE(R_ATA_CTRL_DATA, rw,       read) |
-		IO_STATE(R_ATA_CTRL_DATA, src_dst,  dma) |
-		IO_STATE(R_ATA_CTRL_DATA, handsh,   pio) |
-		IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
-		IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
-	/* wait for completion */
-
-	LED_DISK_READ(1);
-	WAIT_DMA(ATA_RX_DMA_NBR);
-	LED_DISK_READ(0);
-
-#if 0
-        /* old polled transfer code
-	 * this should be moved into a new function that can do polled
-	 * transfers if DMA is not available
-	 */
-
-        /* initiate a multi word read */
-
-        *R_ATA_TRANSFER_CNT = wcount << 1;
-
-        *R_ATA_CTRL_DATA = data_reg |
-                IO_STATE(R_ATA_CTRL_DATA, rw,       read) |
-                IO_STATE(R_ATA_CTRL_DATA, src_dst,  register) |
-                IO_STATE(R_ATA_CTRL_DATA, handsh,   pio) |
-                IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
-                IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
-        /* svinto has a latency until the busy bit actually is set */
-
-        nop(); nop();
-        nop(); nop();
-        nop(); nop();
-        nop(); nop();
-        nop(); nop();
-
-        /* unit should be busy during multi transfer */
-        while((status = *R_ATA_STATUS_DATA) & IO_MASK(R_ATA_STATUS_DATA, busy)) {
-                while(!(status & IO_MASK(R_ATA_STATUS_DATA, dav)))
-                        status = *R_ATA_STATUS_DATA;
-                *ptr++ = (unsigned short)(status & 0xffff);
-        }
-#endif
-}
-
-static void
-e100_atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
-{
-	ide_ioreg_t data_reg = IDE_DATA_REG;
-
-	D(printk("atapi_output_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
-		 data_reg, buffer, bytecount));
-
-	if(bytecount & 1) {
-		printk("odd bytecount %d in atapi_out_bytes!\n", bytecount);
-		bytecount++;
-	}
-
-	/* make sure the DMA channel is available */
-	RESET_DMA(ATA_TX_DMA_NBR);
-	WAIT_DMA(ATA_TX_DMA_NBR);
-
-	/* setup DMA descriptor */
-
-	mydescr.sw_len = bytecount;
-	mydescr.ctrl   = d_eol;
-	mydescr.buf    = virt_to_phys(buffer);
-
-	/* start the dma channel */
-
-	*R_DMA_CH2_FIRST = virt_to_phys(&mydescr);
-	*R_DMA_CH2_CMD   = IO_STATE(R_DMA_CH2_CMD, cmd, start);
-
-	/* initiate a multi word dma write using PIO handshaking */
-
-	*R_ATA_TRANSFER_CNT = IO_FIELD(R_ATA_TRANSFER_CNT, count, bytecount >> 1);
-
-	*R_ATA_CTRL_DATA = data_reg |
-		IO_STATE(R_ATA_CTRL_DATA, rw,       write) |
-		IO_STATE(R_ATA_CTRL_DATA, src_dst,  dma) |
-		IO_STATE(R_ATA_CTRL_DATA, handsh,   pio) |
-		IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
-		IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
-	/* wait for completion */
-
-	LED_DISK_WRITE(1);
-	WAIT_DMA(ATA_TX_DMA_NBR);
-	LED_DISK_WRITE(0);
-
-#if 0
-        /* old polled write code - see comment in input_bytes */
-
-	/* wait for busy flag */
-        while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy));
-
-        /* initiate a multi word write */
-
-        *R_ATA_TRANSFER_CNT = bytecount >> 1;
-
-        ctrl = data_reg |
-                IO_STATE(R_ATA_CTRL_DATA, rw,       write) |
-                IO_STATE(R_ATA_CTRL_DATA, src_dst,  register) |
-                IO_STATE(R_ATA_CTRL_DATA, handsh,   pio) |
-                IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
-                IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
-        LED_DISK_WRITE(1);
-
-        /* Etrax will set busy = 1 until the multi pio transfer has finished
-         * and tr_rdy = 1 after each successful word transfer.
-         * When the last byte has been transferred Etrax will first set tr_tdy = 1
-         * and then busy = 0 (not in the same cycle). If we read busy before it
-         * has been set to 0 we will think that we should transfer more bytes
-         * and then tr_rdy would be 0 forever. This is solved by checking busy
-         * in the inner loop.
-         */
-
-        do {
-                *R_ATA_CTRL_DATA = ctrl | *ptr++;
-                while(!(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, tr_rdy)) &&
-                      (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)));
-        } while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy));
-
-        LED_DISK_WRITE(0);
-#endif
-
-}
-
-/*
- * This is used for most PIO data transfers *from* the IDE interface
- */
-static void
-e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
-{
-	e100_atapi_input_bytes(drive, buffer, wcount << 2);
-}
-
-/*
- * This is used for most PIO data transfers *to* the IDE interface
- */
-static void
-e100_ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
-{
-	e100_atapi_output_bytes(drive, buffer, wcount << 2);
-}
-
-/* we only have one DMA channel on the chip for ATA, so we can keep these statically */
-static etrax_dma_descr ata_descrs[MAX_DMA_DESCRS];
-static unsigned int ata_tot_size;
-
-/*
- * e100_ide_build_dmatable() prepares a dma request.
- * Returns 0 if all went okay, returns 1 otherwise.
- */
-static int e100_ide_build_dmatable (ide_drive_t *drive)
-{
-	ide_hwif_t *hwif = HWIF(drive);
-	struct scatterlist* sg;
-	struct request *rq  = HWGROUP(drive)->rq;
-	unsigned long size, addr;
-	unsigned int count = 0;
-	int i = 0;
-
-	sg = hwif->sg_table;
-
-	ata_tot_size = 0;
-
-	if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) {
-		u8 *virt_addr = rq->buffer;
-		int sector_count = rq->nr_sectors;
-		memset(&sg[0], 0, sizeof(*sg));
-		sg[0].page = virt_to_page(virt_addr);
-		sg[0].offset = offset_in_page(virt_addr);
-		sg[0].length =  sector_count  * SECTOR_SIZE;
-		hwif->sg_nents = i = 1;
-	}
-	else
-	{
-		hwif->sg_nents = i = blk_rq_map_sg(drive->queue, rq, hwif->sg_table);
-	}
-
-
-	while(i) {
-		/*
-		 * Determine addr and size of next buffer area.  We assume that
-		 * individual virtual buffers are always composed linearly in
-		 * physical memory.  For example, we assume that any 8kB buffer
-		 * is always composed of two adjacent physical 4kB pages rather
-		 * than two possibly non-adjacent physical 4kB pages.
-		 */
-		/* group sequential buffers into one large buffer */
-		addr = page_to_phys(sg->page) + sg->offset;
-		size = sg_dma_len(sg);
-		while (sg++, --i) {
-			if ((addr + size) != page_to_phys(sg->page) + sg->offset)
-				break;
-			size += sg_dma_len(sg);
-		}
-
-		/* did we run out of descriptors? */
-
-		if(count >= MAX_DMA_DESCRS) {
-			printk("%s: too few DMA descriptors\n", drive->name);
-			return 1;
-		}
-
-		/* however, this case is more difficult - R_ATA_TRANSFER_CNT cannot be more
-		   than 65536 words per transfer, so in that case we need to either
-		   1) use a DMA interrupt to re-trigger R_ATA_TRANSFER_CNT and continue with
-		      the descriptors, or
-		   2) simply do the request here, and get dma_intr to only ide_end_request on
-		      those blocks that were actually set-up for transfer.
-		*/
-
-		if(ata_tot_size + size > 131072) {
-			printk("too large total ATA DMA request, %d + %d!\n", ata_tot_size, (int)size);
-			return 1;
-		}
-
-		/* If size > 65536 it has to be splitted into new descriptors. Since we don't handle
-                   size > 131072 only one split is necessary */
-
-		if(size > 65536) {
- 		        /* ok we want to do IO at addr, size bytes. set up a new descriptor entry */
-                        ata_descrs[count].sw_len = 0;  /* 0 means 65536, this is a 16-bit field */
-                        ata_descrs[count].ctrl = 0;
-                        ata_descrs[count].buf = addr;
-                        ata_descrs[count].next = virt_to_phys(&ata_descrs[count + 1]);
-                        count++;
-                        ata_tot_size += 65536;
-                        /* size and addr should refere to not handled data */
-                        size -= 65536;
-                        addr += 65536;
-                }
-		/* ok we want to do IO at addr, size bytes. set up a new descriptor entry */
-                if(size == 65536) {
-			ata_descrs[count].sw_len = 0;  /* 0 means 65536, this is a 16-bit field */
-                } else {
-			ata_descrs[count].sw_len = size;
-                }
-		ata_descrs[count].ctrl = 0;
-		ata_descrs[count].buf = addr;
-		ata_descrs[count].next = virt_to_phys(&ata_descrs[count + 1]);
-		count++;
-		ata_tot_size += size;
-	}
-
-	if (count) {
-		/* set the end-of-list flag on the last descriptor */
-		ata_descrs[count - 1].ctrl |= d_eol;
-		/* return and say all is ok */
-		return 0;
-	}
-
-	printk("%s: empty DMA table?\n", drive->name);
-	return 1;	/* let the PIO routines handle this weirdness */
-}
-
-static int config_drive_for_dma (ide_drive_t *drive)
-{
-        const char **list;
-        struct hd_driveid *id = drive->id;
-
-        if (id && (id->capability & 1)) {
-                /* Enable DMA on any drive that supports mword2 DMA */
-                if ((id->field_valid & 2) && (id->dma_mword & 0x404) == 0x404) {
-                        drive->using_dma = 1;
-                        return 0;               /* DMA enabled */
-                }
-
-                /* Consult the list of known "good" drives */
-                list = good_dma_drives;
-                while (*list) {
-                        if (!strcmp(*list++,id->model)) {
-                                drive->using_dma = 1;
-                                return 0;       /* DMA enabled */
-                        }
-                }
-        }
-        return 1;       /* DMA not enabled */
-}
-
-/*
- * etrax_dma_intr() is the handler for disk read/write DMA interrupts
- */
-static ide_startstop_t etrax_dma_intr (ide_drive_t *drive)
-{
-	int i, dma_stat;
-	byte stat;
-
-	LED_DISK_READ(0);
-	LED_DISK_WRITE(0);
-
-	dma_stat = HWIF(drive)->ide_dma_end(drive);
-	stat = HWIF(drive)->INB(IDE_STATUS_REG);		/* get drive status */
-	if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
-		if (!dma_stat) {
-			struct request *rq;
-			rq = HWGROUP(drive)->rq;
-			for (i = rq->nr_sectors; i > 0;) {
-				i -= rq->current_nr_sectors;
-				DRIVER(drive)->end_request(drive, 1, rq->nr_sectors);
-			}
-			return ide_stopped;
-		}
-		printk("%s: bad DMA status\n", drive->name);
-	}
-	return DRIVER(drive)->error(drive, "dma_intr", stat);
-}
-
-/*
- * Functions below initiates/aborts DMA read/write operations on a drive.
- *
- * The caller is assumed to have selected the drive and programmed the drive's
- * sector address using CHS or LBA.  All that remains is to prepare for DMA
- * and then issue the actual read/write DMA/PIO command to the drive.
- *
- * For ATAPI devices, we just prepare for DMA and return. The caller should
- * then issue the packet command to the drive and call us again with
- * ide_dma_begin afterwards.
- *
- * Returns 0 if all went well.
- * Returns 1 if DMA read/write could not be started, in which case
- * the caller should revert to PIO for the current request.
- */
-
-static int e100_dma_check(ide_drive_t *drive)
-{
-	return config_drive_for_dma (drive);
-}
-
-static int e100_dma_end(ide_drive_t *drive)
-{
-	/* TODO: check if something went wrong with the DMA */
-	return 0;
-}
-
-static int e100_start_dma(ide_drive_t *drive, int atapi, int reading)
-{
-	if(reading) {
-
-		RESET_DMA(ATA_RX_DMA_NBR); /* sometimes the DMA channel get stuck so we need to do this */
-		WAIT_DMA(ATA_RX_DMA_NBR);
-
-		/* set up the Etrax DMA descriptors */
-
-		if(e100_ide_build_dmatable (drive))
-			return 1;
-
-		if(!atapi) {
-			/* set the irq handler which will finish the request when DMA is done */
-
-			ide_set_handler(drive, &etrax_dma_intr, WAIT_CMD, NULL);
-
-			/* issue cmd to drive */
-                        if ((HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASKFILE) &&
-			    (drive->addressing == 1)) {
-				ide_task_t *args = HWGROUP(drive)->rq->special;
-				etrax100_ide_outb(args->tfRegister[IDE_COMMAND_OFFSET], IDE_COMMAND_REG);
-			} else if (drive->addressing) {
-				etrax100_ide_outb(WIN_READDMA_EXT, IDE_COMMAND_REG);
-			} else {
-				etrax100_ide_outb(WIN_READDMA, IDE_COMMAND_REG);
-			}
-		}
-
-		/* begin DMA */
-
-		/* need to do this before RX DMA due to a chip bug
-		 * it is enough to just flush the part of the cache that
-		 * corresponds to the buffers we start, but since HD transfers
-		 * usually are more than 8 kB, it is easier to optimize for the
-		 * normal case and just flush the entire cache. its the only
-		 * way to be sure! (OB movie quote)
-		 */
-		flush_etrax_cache();
-		*R_DMA_CH3_FIRST = virt_to_phys(ata_descrs);
-		*R_DMA_CH3_CMD   = IO_STATE(R_DMA_CH3_CMD, cmd, start);
-
-		/* initiate a multi word dma read using DMA handshaking */
-
-		*R_ATA_TRANSFER_CNT =
-			IO_FIELD(R_ATA_TRANSFER_CNT, count, ata_tot_size >> 1);
-
-		*R_ATA_CTRL_DATA =
-			IO_FIELD(R_ATA_CTRL_DATA, data, IDE_DATA_REG) |
-			IO_STATE(R_ATA_CTRL_DATA, rw,       read) |
-			IO_STATE(R_ATA_CTRL_DATA, src_dst,  dma)  |
-			IO_STATE(R_ATA_CTRL_DATA, handsh,   dma)  |
-			IO_STATE(R_ATA_CTRL_DATA, multi,    on)   |
-			IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
-		LED_DISK_READ(1);
-
-		D(printk("dma read of %d bytes.\n", ata_tot_size));
-
-	} else {
-		/* writing */
-
-		RESET_DMA(ATA_TX_DMA_NBR); /* sometimes the DMA channel get stuck so we need to do this */
-		WAIT_DMA(ATA_TX_DMA_NBR);
-
-		/* set up the Etrax DMA descriptors */
-
-		if(e100_ide_build_dmatable (drive))
-			return 1;
-
-		if(!atapi) {
-			/* set the irq handler which will finish the request when DMA is done */
-
-			ide_set_handler(drive, &etrax_dma_intr, WAIT_CMD, NULL);
-
-			/* issue cmd to drive */
-			if ((HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASKFILE) &&
-			    (drive->addressing == 1)) {
-				ide_task_t *args = HWGROUP(drive)->rq->special;
-				etrax100_ide_outb(args->tfRegister[IDE_COMMAND_OFFSET], IDE_COMMAND_REG);
-			} else if (drive->addressing) {
-				etrax100_ide_outb(WIN_WRITEDMA_EXT, IDE_COMMAND_REG);
-			} else {
-				etrax100_ide_outb(WIN_WRITEDMA, IDE_COMMAND_REG);
-			}
-		}
-
-		/* begin DMA */
-
-		*R_DMA_CH2_FIRST = virt_to_phys(ata_descrs);
-		*R_DMA_CH2_CMD   = IO_STATE(R_DMA_CH2_CMD, cmd, start);
-
-		/* initiate a multi word dma write using DMA handshaking */
-
-		*R_ATA_TRANSFER_CNT =
-			IO_FIELD(R_ATA_TRANSFER_CNT, count, ata_tot_size >> 1);
-
-		*R_ATA_CTRL_DATA =
-			IO_FIELD(R_ATA_CTRL_DATA, data,     IDE_DATA_REG) |
-			IO_STATE(R_ATA_CTRL_DATA, rw,       write) |
-			IO_STATE(R_ATA_CTRL_DATA, src_dst,  dma) |
-			IO_STATE(R_ATA_CTRL_DATA, handsh,   dma) |
-			IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
-			IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
-		LED_DISK_WRITE(1);
-
-		D(printk("dma write of %d bytes.\n", ata_tot_size));
-	}
-	return 0;
-}
-
-static int e100_dma_write(ide_drive_t *drive)
-{
-	e100_read_command = 0;
-	/* ATAPI-devices (not disks) first call ide_dma_read/write to set the direction
-	 * then they call ide_dma_begin after they have issued the appropriate drive command
-	 * themselves to actually start the chipset DMA. so we just return here if we're
-	 * not a diskdrive.
-	 */
-	if (drive->media != ide_disk)
-                return 0;
-	return e100_start_dma(drive, 0, 0);
-}
-
-static int e100_dma_read(ide_drive_t *drive)
-{
-	e100_read_command = 1;
-	/* ATAPI-devices (not disks) first call ide_dma_read/write to set the direction
-	 * then they call ide_dma_begin after they have issued the appropriate drive command
-	 * themselves to actually start the chipset DMA. so we just return here if we're
-	 * not a diskdrive.
-	 */
-	if (drive->media != ide_disk)
-                return 0;
-	return e100_start_dma(drive, 0, 1);
-}
-
-static int e100_dma_begin(ide_drive_t *drive)
-{
-	/* begin DMA, used by ATAPI devices which want to issue the
-	 * appropriate IDE command themselves.
-	 *
-	 * they have already called ide_dma_read/write to set the
-	 * static reading flag, now they call ide_dma_begin to do
-	 * the real stuff. we tell our code below not to issue
-	 * any IDE commands itself and jump into it.
-	 */
-	 return e100_start_dma(drive, 1, e100_read_command);
-}
diff -Nru a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
--- a/arch/cris/arch-v10/drivers/pcf8563.c	2004-12-24 13:36:35 -08:00
+++ b/arch/cris/arch-v10/drivers/pcf8563.c	2004-12-24 13:36:35 -08:00
@@ -15,7 +15,7 @@
  *
  * Author: Tobias Anderberg <tobiasa@axis.com>.
  *
- * $Id: pcf8563.c,v 1.4 2004/05/28 09:26:59 starvik Exp $
+ * $Id: pcf8563.c,v 1.8 2004/08/24 06:42:51 starvik Exp $
  */
 
 #include <linux/config.h>
@@ -40,7 +40,7 @@
 #define PCF8563_MAJOR 121		/* Local major number. */
 #define DEVICE_NAME "rtc"		/* Name which is registered in /proc/devices. */
 #define PCF8563_NAME "PCF8563"
-#define DRIVER_VERSION "$Revision: 1.4 $"
+#define DRIVER_VERSION "$Revision: 1.8 $"
 
 /* I2C bus slave registers. */
 #define RTC_I2C_READ		0xa3
diff -Nru a/arch/cris/arch-v10/drivers/serial.c b/arch/cris/arch-v10/drivers/serial.c
--- a/arch/cris/arch-v10/drivers/serial.c	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,5042 +0,0 @@
-/* $Id: serial.c,v 1.20 2004/05/24 12:00:20 starvik Exp $
- *
- * Serial port driver for the ETRAX 100LX chip
- *
- *    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003  Axis Communications AB
- *
- *    Many, many authors. Based once upon a time on serial.c for 16x50.
- *
- * $Log: serial.c,v $
- * Revision 1.20  2004/05/24 12:00:20  starvik
- * Big merge of stuff from Linux 2.4 (e.g. manual mode for the serial port).
- *
- * Revision 1.19  2004/05/17 13:12:15  starvik
- * Kernel console hook
- * Big merge from Linux 2.4 still pending.
- *
- * Revision 1.18  2003/10/28 07:18:30  starvik
- * Compiles with debug info
- *
- * Revision 1.17  2003/07/04 08:27:37  starvik
- * Merge of Linux 2.5.74
- *
- * Revision 1.16  2003/06/13 10:05:19  johana
- * Help the user to avoid trouble by:
- * Forcing mixed mode for status/control lines if not all pins are used.
- *
- * Revision 1.15  2003/06/13 09:43:01  johana
- * Merged in the following changes from os/linux/arch/cris/drivers/serial.c
- * + some minor changes to reduce diff.
- *
- * Revision 1.49  2003/05/30 11:31:54  johana
- * Merged in change-branch--serial9bit that adds CMSPAR support for sticky
- * parity (mark/space)
- *
- * Revision 1.48  2003/05/30 11:03:57  johana
- * Implemented rs_send_xchar() by disabling the DMA and writing manually.
- * Added e100_disable_txdma_channel() and e100_enable_txdma_channel().
- * Fixed rs_throttle() and rs_unthrottle() to properly call rs_send_xchar
- * instead of setting info->x_char and check the CRTSCTS flag before
- * controlling the rts pin.
- *
- * Revision 1.14  2003/04/09 08:12:44  pkj
- * Corrected typo changes made upstream.
- *
- * Revision 1.13  2003/04/09 05:20:47  starvik
- * Merge of Linux 2.5.67
- *
- * Revision 1.11  2003/01/22 06:48:37  starvik
- * Fixed warnings issued by GCC 3.2.1
- *
- * Revision 1.9  2002/12/13 09:07:47  starvik
- * Alert user that RX_TIMEOUT_TICKS==0 doesn't work
- *
- * Revision 1.8  2002/12/11 13:13:57  starvik
- * Added arch/ to v10 specific includes
- * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
- *
- * Revision 1.7  2002/12/06 07:13:57  starvik
- * Corrected work queue stuff
- * Removed CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST
- *
- * Revision 1.6  2002/11/21 07:17:46  starvik
- * Change static inline to extern inline where otherwise outlined with gcc-3.2
- *
- * Revision 1.5  2002/11/14 15:59:49  starvik
- * Linux 2.5 port of the latest serial driver from 2.4. The work queue stuff
- * probably doesn't work yet.
- *
- * Revision 1.42  2002/11/05 09:08:47  johana
- * Better implementation of rs_stop() and rs_start() that uses the XOFF
- * register to start/stop transmission.
- * change_speed() also initilises XOFF register correctly so that
- * auto_xoff is enabled when IXON flag is set by user.
- * This gives fast XOFF response times.
- *
- * Revision 1.41  2002/11/04 18:40:57  johana
- * Implemented rs_stop() and rs_start().
- * Simple tests using hwtestserial indicates that this should be enough
- * to make it work.
- *
- * Revision 1.40  2002/10/14 05:33:18  starvik
- * RS-485 uses fast timers even if SERIAL_FAST_TIMER is disabled
- *
- * Revision 1.39  2002/09/30 21:00:57  johana
- * Support for CONFIG_ETRAX_SERx_DTR_RI_DSR_CD_MIXED where the status and
- * control pins can be mixed between PA and PB.
- * If no serial port uses MIXED old solution is used
- * (saves a few bytes and cycles).
- * control_pins struct uses masks instead of bit numbers.
- * Corrected dummy values and polarity in line_info() so
- * /proc/tty/driver/serial is now correct.
- * (the E100_xxx_GET() macros is really active low - perhaps not obvious)
- *
- * Revision 1.38  2002/08/23 11:01:36  starvik
- * Check that serial port is enabled in all interrupt handlers to avoid
- * restarts of DMA channels not assigned to serial ports
- *
- * Revision 1.37  2002/08/13 13:02:37  bjornw
- * Removed some warnings because of unused code
- *
- * Revision 1.36  2002/08/08 12:50:01  starvik
- * Serial interrupt is shared with synchronous serial port driver
- *
- * Revision 1.35  2002/06/03 10:40:49  starvik
- * Increased RS-485 RTS toggle timer to 2 characters
- *
- * Revision 1.34  2002/05/28 18:59:36  johana
- * Whitespace and comment fixing to be more like etrax100ser.c 1.71.
- *
- * Revision 1.33  2002/05/28 17:55:43  johana
- * RS-485 uses FAST_TIMER if enabled, and starts a short (one char time)
- * timer from tranismit_chars (interrupt context).
- * The timer toggles RTS in interrupt context when expired giving minimum
- * latencies.
- *
- * Revision 1.32  2002/05/22 13:58:00  johana
- * Renamed rs_write() to raw_write() and made it inline.
- * New rs_write() handles RS-485 if configured and enabled
- * (moved code from e100_write_rs485()).
- * RS-485 ioctl's uses copy_from_user() instead of verify_area().
- *
- * Revision 1.31  2002/04/22 11:20:03  johana
- * Updated copyright years.
- *
- * Revision 1.30  2002/04/22 09:39:12  johana
- * RS-485 support compiles.
- *
- * Revision 1.29  2002/01/14 16:10:01  pkj
- * Allocate the receive buffers dynamically. The static 4kB buffer was
- * too small for the peaks. This means that we can get rid of the extra
- * buffer and the copying to it. It also means we require less memory
- * under normal operations, but can use more when needed (there is a
- * cap at 64kB for safety reasons). If there is no memory available
- * we panic(), and die a horrible death...
- *
- * Revision 1.28  2001/12/18 15:04:53  johana
- * Cleaned up write_rs485() - now it works correctly without padding extra
- * char.
- * Added sane default initialisation of rs485.
- * Added #ifdef around dummy variables.
- *
- * Revision 1.27  2001/11/29 17:00:41  pkj
- * 2kB seems to be too small a buffer when using 921600 bps,
- * so increase it to 4kB (this was already done for the elinux
- * version of the serial driver).
- *
- * Revision 1.26  2001/11/19 14:20:41  pkj
- * Minor changes to comments and unused code.
- *
- * Revision 1.25  2001/11/12 20:03:43  pkj
- * Fixed compiler warnings.
- *
- * Revision 1.24  2001/11/12 15:10:05  pkj
- * Total redesign of the receiving part of the serial driver.
- * Uses eight chained descriptors to write to a 4kB buffer.
- * This data is then serialised into a 2kB buffer. From there it
- * is copied into the TTY's flip buffers when they become available.
- * A lot of copying, and the sizes of the buffers might need to be
- * tweaked, but all in all it should work better than the previous
- * version, without the need to modify the TTY code in any way.
- * Also note that erroneous bytes are now correctly marked in the
- * flag buffers (instead of always marking the first byte).
- *
- * Revision 1.23  2001/10/30 17:53:26  pkj
- * * Set info->uses_dma to 0 when a port is closed.
- * * Mark the timer1 interrupt as a fast one (SA_INTERRUPT).
- * * Call start_flush_timer() in start_receive() if
- *   CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST is defined.
- *
- * Revision 1.22  2001/10/30 17:44:03  pkj
- * Use %lu for received and transmitted counters in line_info().
- *
- * Revision 1.21  2001/10/30 17:40:34  pkj
- * Clean-up. The only change to functionality is that
- * CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS(=5) is used instead of
- * MAX_FLUSH_TIME(=8).
- *
- * Revision 1.20  2001/10/30 15:24:49  johana
- * Added char_time stuff from 2.0 driver.
- *
- * Revision 1.19  2001/10/30 15:23:03  johana
- * Merged with 1.13.2 branch + fixed indentation
- * and changed CONFIG_ETRAX100_XYS to CONFIG_ETRAX_XYZ
- *
- * Revision 1.18  2001/09/24 09:27:22  pkj
- * Completed ext_baud_table[] in cflag_to_baud() and cflag_to_etrax_baud().
- *
- * Revision 1.17  2001/08/24 11:32:49  ronny
- * More fixes for the CONFIG_ETRAX_SERIAL_PORT0 define.
- *
- * Revision 1.16  2001/08/24 07:56:22  ronny
- * Added config ifdefs around ser0 irq requests.
- *
- * Revision 1.15  2001/08/16 09:10:31  bjarne
- * serial.c - corrected the initialization of rs_table, the wrong defines
- *            where used.
- *            Corrected a test in timed_flush_handler.
- *            Changed configured to enabled.
- * serial.h - Changed configured to enabled.
- *
- * Revision 1.14  2001/08/15 07:31:23  bjarne
- * Introduced two new members to the e100_serial struct.
- * configured - Will be set to 1 if the port has been configured in .config
- * uses_dma   - Should be set to 1 if the port uses DMA. Currently it is set 
- *              to 1
- *              when a port is opened. This is used to limit the DMA interrupt
- *              routines to only manipulate DMA channels actually used by the
- *              serial driver.
- *
- * Revision 1.13.2.2  2001/10/17 13:57:13  starvik
- * Receiver was broken by the break fixes
- *
- * Revision 1.13.2.1  2001/07/20 13:57:39  ronny
- * Merge with new stuff from etrax100ser.c. Works but haven't checked stuff
- * like break handling.
- *
- * Revision 1.13  2001/05/09 12:40:31  johana
- * Use DMA_NBR and IRQ_NBR defines from dma.h and irq.h
- *
- * Revision 1.12  2001/04/19 12:23:07  bjornw
- * CONFIG_RS485 -> CONFIG_ETRAX_RS485
- *
- * Revision 1.11  2001/04/05 14:29:48  markusl
- * Updated according to review remarks i.e.
- * -Use correct types in port structure to avoid compiler warnings
- * -Try to use IO_* macros whenever possible
- * -Open should never return -EBUSY
- *
- * Revision 1.10  2001/03/05 13:14:07  bjornw
- * Another spelling fix
- *
- * Revision 1.9  2001/02/23 13:46:38  bjornw
- * Spellling check
- *
- * Revision 1.8  2001/01/23 14:56:35  markusl
- * Made use of ser1 optional
- * Needed by USB
- *
- * Revision 1.7  2001/01/19 16:14:48  perf
- * Added kernel options for serial ports 234.
- * Changed option names from CONFIG_ETRAX100_XYZ to CONFIG_ETRAX_XYZ.
- *
- * Revision 1.6  2000/11/22 16:36:09  bjornw
- * Please marketing by using the correct case when spelling Etrax.
- *
- * Revision 1.5  2000/11/21 16:43:37  bjornw
- * Fixed so it compiles under CONFIG_SVINTO_SIM
- *
- * Revision 1.4  2000/11/15 17:34:12  bjornw
- * Added a timeout timer for flushing input channels. The interrupt-based
- * fast flush system should be easy to merge with this later (works the same
- * way, only with an irq instead of a system timer_list)
- *
- * Revision 1.3  2000/11/13 17:19:57  bjornw
- * * Incredibly, this almost complete rewrite of serial.c worked (at least
- *   for output) the first time.
- *
- *   Items worth noticing:
- *
- *      No Etrax100 port 1 workarounds (does only compile on 2.4 anyway now)
- *      RS485 is not ported (why can't it be done in userspace as on x86 ?)
- *      Statistics done through async_icount - if any more stats are needed,
- *      that's the place to put them or in an arch-dep version of it.
- *      timeout_interrupt and the other fast timeout stuff not ported yet
- *      There be dragons in this 3k+ line driver
- *
- * Revision 1.2  2000/11/10 16:50:28  bjornw
- * First shot at a 2.4 port, does not compile totally yet
- *
- * Revision 1.1  2000/11/10 16:47:32  bjornw
- * Added verbatim copy of rev 1.49 etrax100ser.c from elinux
- *
- * Revision 1.49  2000/10/30 15:47:14  tobiasa
- * Changed version number.
- *
- * Revision 1.48  2000/10/25 11:02:43  johana
- * Changed %ul to %lu in printf's
- *
- * Revision 1.47  2000/10/18 15:06:53  pkj
- * Compile correctly with CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST and
- * CONFIG_ETRAX_SERIAL_PROC_ENTRY together.
- * Some clean-up of the /proc/serial file.
- *
- * Revision 1.46  2000/10/16 12:59:40  johana
- * Added CONFIG_ETRAX_SERIAL_PROC_ENTRY for statistics and debug info.
- *
- * Revision 1.45  2000/10/13 17:10:59  pkj
- * Do not flush DMAs while flipping TTY buffers.
- *
- * Revision 1.44  2000/10/13 16:34:29  pkj
- * Added a delay in ser_interrupt() for 2.3ms when an error is detected.
- * We do not know why this delay is required yet, but without it the
- * irmaflash program does not work (this was the program that needed
- * the ser_interrupt() to be needed in the first place). This should not
- * affect normal use of the serial ports.
- *
- * Revision 1.43  2000/10/13 16:30:44  pkj
- * New version of the fast flush of serial buffers code. This time
- * it is localized to the serial driver and uses a fast timer to
- * do the work.
- *
- * Revision 1.42  2000/10/13 14:54:26  bennyo
- * Fix for switching RTS when using rs485
- *
- * Revision 1.41  2000/10/12 11:43:44  pkj
- * Cleaned up a number of comments.
- *
- * Revision 1.40  2000/10/10 11:58:39  johana
- * Made RS485 support generic for all ports.
- * Toggle rts in interrupt if no delay wanted.
- * WARNING: No true transmitter empty check??
- * Set d_wait bit when sending data so interrupt is delayed until
- * fifo flushed. (Fix tcdrain() problem)
- *
- * Revision 1.39  2000/10/04 16:08:02  bjornw
- * * Use virt_to_phys etc. for DMA addresses
- * * Removed CONFIG_FLUSH_DMA_FAST hacks
- * * Indentation fix
- *
- * Revision 1.38  2000/10/02 12:27:10  mattias
- * * added variable used when using fast flush on serial dma.
- *   (CONFIG_FLUSH_DMA_FAST)
- *
- * Revision 1.37  2000/09/27 09:44:24  pkj
- * Uncomment definition of SERIAL_HANDLE_EARLY_ERRORS.
- *
- * Revision 1.36  2000/09/20 13:12:52  johana
- * Support for CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS:
- *   Number of timer ticks between flush of receive fifo (1 tick = 10ms).
- *   Try 0-3 for low latency applications. Approx 5 for high load
- *   applications (e.g. PPP). Maybe this should be more adaptive some day...
- *
- * Revision 1.35  2000/09/20 10:36:08  johana
- * Typo in get_lsr_info()
- *
- * Revision 1.34  2000/09/20 10:29:59  johana
- * Let rs_chars_in_buffer() check fifo content as well.
- * get_lsr_info() might work now (not tested).
- * Easier to change the port to debug.
- *
- * Revision 1.33  2000/09/13 07:52:11  torbjore
- * Support RS485
- *
- * Revision 1.32  2000/08/31 14:45:37  bjornw
- * After sending a break we need to reset the transmit DMA channel
- *
- * Revision 1.31  2000/06/21 12:13:29  johana
- * Fixed wait for all chars sent when closing port.
- * (Used to always take 1 second!)
- * Added shadows for directions of status/ctrl signals.
- *
- * Revision 1.30  2000/05/29 16:27:55  bjornw
- * Simulator ifdef moved a bit
- *
- * Revision 1.29  2000/05/09 09:40:30  mattias
- * * Added description of dma registers used in timeout_interrupt
- * * Removed old code
- *
- * Revision 1.28  2000/05/08 16:38:58  mattias
- * * Bugfix for flushing fifo in timeout_interrupt
- *   Problem occurs when bluetooth stack waits for a small number of bytes
- *   containing an event acknowledging free buffers in bluetooth HW
- *   As before, data was stuck in fifo until more data came on uart and
- *   flushed it up to the stack.
- *
- * Revision 1.27  2000/05/02 09:52:28  jonasd
- * Added fix for peculiar etrax behaviour when eop is forced on an empty
- * fifo. This is used when flashing the IRMA chip. Disabled by default.
- *
- * Revision 1.26  2000/03/29 15:32:02  bjornw
- * 2.0.34 updates
- *
- * Revision 1.25  2000/02/16 16:59:36  bjornw
- * * Receive DMA directly into the flip-buffer, eliminating an intermediary
- *   receive buffer and a memcpy. Will avoid some overruns.
- * * Error message on debug port if an overrun or flip buffer overrun occurs.
- * * Just use the first byte in the flag flip buffer for errors.
- * * Check for timeout on the serial ports only each 5/100 s, not 1/100.
- *
- * Revision 1.24  2000/02/09 18:02:28  bjornw
- * * Clear serial errors (overrun, framing, parity) correctly. Before, the
- *   receiver would get stuck if an error occurred and we did not restart
- *   the input DMA.
- * * Cosmetics (indentation, some code made into inlines)
- * * Some more debug options
- * * Actually shut down the serial port (DMA irq, DMA reset, receiver stop)
- *   when the last open is closed. Corresponding fixes in startup().
- * * rs_close() "tx FIFO wait" code moved into right place, bug & -> && fixed
- *   and make a special case out of port 1 (R_DMA_CHx_STATUS is broken for that)
- * * e100_disable_rx/enable_rx just disables/enables the receiver, not RTS
- *
- * Revision 1.23  2000/01/24 17:46:19  johana
- * Wait for flush of DMA/FIFO when closing port.
- *
- * Revision 1.22  2000/01/20 18:10:23  johana
- * Added TIOCMGET ioctl to return modem status.
- * Implemented modem status/control that works with the extra signals
- * (DTR, DSR, RI,CD) as well.
- * 3 different modes supported:
- * ser0 on PB (Bundy), ser1 on PB (Lisa) and ser2 on PA (Bundy)
- * Fixed DEF_TX value that caused the serial transmitter pin (txd) to go to 0 when
- * closing the last filehandle, NASTY!.
- * Added break generation, not tested though!
- * Use SA_SHIRQ when request_irq() for ser2 and ser3 (shared with) par0 and par1.
- * You can't use them at the same time (yet..), but you can hopefully switch
- * between ser2/par0, ser3/par1 with the same kernel config.
- * Replaced some magic constants with defines
- *
- *
- */
-
-static char *serial_version = "$Revision: 1.20 $";
-
-#include <linux/config.h>
-#include <linux/version.h>
-
-#include <linux/types.h>
-#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/mm.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <asm/uaccess.h>
-#include <linux/kernel.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/system.h>
-#include <asm/segment.h>
-#include <asm/bitops.h>
-#include <linux/delay.h>
-
-#include <asm/arch/svinto.h>
-
-/* non-arch dependent serial structures are in linux/serial.h */
-#include <linux/serial.h>
-/* while we keep our own stuff (struct e100_serial) in a local .h file */
-#include "serial.h"
-#include <asm/fasttimer.h>
-
-#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
-#ifndef CONFIG_ETRAX_FAST_TIMER
-#error "Enable FAST_TIMER to use SERIAL_FAST_TIMER"
-#endif
-#endif
-
-#if defined(CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS) && \
-           (CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS == 0)
-#error "RX_TIMEOUT_TICKS == 0 not allowed, use 1"
-#endif
-
-#if defined(CONFIG_ETRAX_RS485_ON_PA) && defined(CONFIG_ETRAX_RS485_ON_PORT_G)
-#error "Disable either CONFIG_ETRAX_RS485_ON_PA or CONFIG_ETRAX_RS485_ON_PORT_G"
-#endif
-
-/*
- * All of the compatibilty code so we can compile serial.c against
- * older kernels is hidden in serial_compat.h
- */
-#if defined(LOCAL_HEADERS)
-#include "serial_compat.h"
-#endif
-
-#define _INLINE_ inline
-
-struct tty_driver *serial_driver;
-
-/* serial subtype definitions */
-#ifndef SERIAL_TYPE_NORMAL
-#define SERIAL_TYPE_NORMAL	1
-#endif
-
-/* number of characters left in xmit buffer before we ask for more */
-#define WAKEUP_CHARS 256
-
-//#define SERIAL_DEBUG_INTR
-//#define SERIAL_DEBUG_OPEN 
-//#define SERIAL_DEBUG_FLOW
-//#define SERIAL_DEBUG_DATA
-//#define SERIAL_DEBUG_THROTTLE
-//#define SERIAL_DEBUG_IO  /* Debug for Extra control and status pins */
-//#define SERIAL_DEBUG_LINE 0 /* What serport we want to debug */
-
-/* Enable this to use serial interrupts to handle when you
-   expect the first received event on the serial port to
-   be an error, break or similar. Used to be able to flash IRMA
-   from eLinux */
-#define SERIAL_HANDLE_EARLY_ERRORS
-
-/* Defined and used in n_tty.c, but we need it here as well */
-#define TTY_THRESHOLD_THROTTLE 128
-
-/* Due to buffersizes and threshold values, our SERIAL_DESCR_BUF_SIZE
- * must not be to high or flow control won't work if we leave it to the tty
- * layer so we have our own throttling in flush_to_flip
- * TTY_FLIPBUF_SIZE=512,
- * TTY_THRESHOLD_THROTTLE/UNTHROTTLE=128
- * BUF_SIZE can't be > 128
- */
-/* Currently 16 descriptors x 128 bytes = 2048 bytes */
-#define SERIAL_DESCR_BUF_SIZE 256
-
-#define SERIAL_PRESCALE_BASE 3125000 /* 3.125MHz */
-#define DEF_BAUD_BASE SERIAL_PRESCALE_BASE
-
-/* We don't want to load the system with massive fast timer interrupt
- * on high baudrates so limit it to 250 us (4kHz) */
-#define MIN_FLUSH_TIME_USEC 250
-
-/* Add an x here to log a lot of timer stuff */
-#define TIMERD(x)
-/* Debug details of interrupt handling */
-#define DINTR1(x)  /* irq on/off, errors */
-#define DINTR2(x)    /* tx and rx */
-/* Debug flip buffer stuff */
-#define DFLIP(x)
-/* Debug flow control and overview of data flow */
-#define DFLOW(x)
-#define DBAUD(x)
-#define DLOG_INT_TRIG(x)
-
-//#define DEBUG_LOG_INCLUDED
-#ifndef DEBUG_LOG_INCLUDED
-#define DEBUG_LOG(line, string, value)
-#else
-struct debug_log_info
-{
-	unsigned long time;
-	unsigned long timer_data;
-//  int line;
-	const char *string;
-	int value;
-};
-#define DEBUG_LOG_SIZE 4096
-
-struct debug_log_info debug_log[DEBUG_LOG_SIZE];
-int debug_log_pos = 0;
-
-#define DEBUG_LOG(_line, _string, _value) do { \
-  if ((_line) == SERIAL_DEBUG_LINE) {\
-    debug_log_func(_line, _string, _value); \
-  }\
-}while(0)
-
-void debug_log_func(int line, const char *string, int value)
-{
-	if (debug_log_pos < DEBUG_LOG_SIZE) {
-		debug_log[debug_log_pos].time = jiffies;
-		debug_log[debug_log_pos].timer_data = *R_TIMER_DATA;
-//    debug_log[debug_log_pos].line = line;
-		debug_log[debug_log_pos].string = string;
-		debug_log[debug_log_pos].value = value;
-		debug_log_pos++;
-	}
-	/*printk(string, value);*/
-}
-#endif
-
-#ifndef CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS
-/* Default number of timer ticks before flushing rx fifo 
- * When using "little data, low latency applications: use 0
- * When using "much data applications (PPP)" use ~5
- */
-#define CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS 5 
-#endif
-
-unsigned long timer_data_to_ns(unsigned long timer_data);
-
-static void change_speed(struct e100_serial *info);
-static void rs_throttle(struct tty_struct * tty);
-static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
-static int rs_write(struct tty_struct * tty, int from_user,
-                    const unsigned char *buf, int count);
-extern _INLINE_ int rs_raw_write(struct tty_struct * tty, int from_user,
-                            const unsigned char *buf, int count);
-#ifdef CONFIG_ETRAX_RS485
-static int e100_write_rs485(struct tty_struct * tty, int from_user,
-                            const unsigned char *buf, int count);
-#endif
-static int get_lsr_info(struct e100_serial * info, unsigned int *value);
-
-
-#define DEF_BAUD 115200   /* 115.2 kbit/s */
-#define STD_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-#define DEF_RX 0x20  /* or SERIAL_CTRL_W >> 8 */
-/* Default value of tx_ctrl register: has txd(bit 7)=1 (idle) as default */
-#define DEF_TX 0x80  /* or SERIAL_CTRL_B */
-
-/* offsets from R_SERIALx_CTRL */
-
-#define REG_DATA 0
-#define REG_DATA_STATUS32 0 /* this is the 32 bit register R_SERIALx_READ */
-#define REG_TR_DATA 0
-#define REG_STATUS 1
-#define REG_TR_CTRL 1
-#define REG_REC_CTRL 2
-#define REG_BAUD 3
-#define REG_XOFF 4  /* this is a 32 bit register */
-
-/* The bitfields are the same for all serial ports */
-#define SER_RXD_MASK         IO_MASK(R_SERIAL0_STATUS, rxd)
-#define SER_DATA_AVAIL_MASK  IO_MASK(R_SERIAL0_STATUS, data_avail)
-#define SER_FRAMING_ERR_MASK IO_MASK(R_SERIAL0_STATUS, framing_err)
-#define SER_PAR_ERR_MASK     IO_MASK(R_SERIAL0_STATUS, par_err)
-#define SER_OVERRUN_MASK     IO_MASK(R_SERIAL0_STATUS, overrun)
-
-#define SER_ERROR_MASK (SER_OVERRUN_MASK | SER_PAR_ERR_MASK | SER_FRAMING_ERR_MASK)
-
-/* Values for info->errorcode */
-#define ERRCODE_SET_BREAK    (TTY_BREAK)
-#define ERRCODE_INSERT        0x100
-#define ERRCODE_INSERT_BREAK (ERRCODE_INSERT | TTY_BREAK)
-
-#define FORCE_EOP(info)  *R_SET_EOP = 1U << info->iseteop;
-
-/*
- * General note regarding the use of IO_* macros in this file: 
- *
- * We will use the bits defined for DMA channel 6 when using various
- * IO_* macros (e.g. IO_STATE, IO_MASK, IO_EXTRACT) and _assume_ they are
- * the same for all channels (which of course they are).
- *
- * We will also use the bits defined for serial port 0 when writing commands
- * to the different ports, as these bits too are the same for all ports.
- */
-
-
-/* Mask for the irqs possibly enabled in R_IRQ_MASK1_RD etc. */
-static const unsigned long e100_ser_int_mask = 0
-#ifdef CONFIG_ETRAX_SERIAL_PORT0
-| IO_MASK(R_IRQ_MASK1_RD, ser0_data) | IO_MASK(R_IRQ_MASK1_RD, ser0_ready)
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT1
-| IO_MASK(R_IRQ_MASK1_RD, ser1_data) | IO_MASK(R_IRQ_MASK1_RD, ser1_ready)
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT2
-| IO_MASK(R_IRQ_MASK1_RD, ser2_data) | IO_MASK(R_IRQ_MASK1_RD, ser2_ready)
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT3
-| IO_MASK(R_IRQ_MASK1_RD, ser3_data) | IO_MASK(R_IRQ_MASK1_RD, ser3_ready)
-#endif
-;
-unsigned long r_alt_ser_baudrate_shadow = 0;
-
-/* this is the data for the four serial ports in the etrax100 */
-/*  DMA2(ser2), DMA4(ser3), DMA6(ser0) or DMA8(ser1) */
-/* R_DMA_CHx_CLR_INTR, R_DMA_CHx_FIRST, R_DMA_CHx_CMD */
-
-static struct e100_serial rs_table[] = {
-	{ .baud        = DEF_BAUD,
-	  .port        = (unsigned char *)R_SERIAL0_CTRL,
-	  .irq         = 1U << 12, /* uses DMA 6 and 7 */
-	  .oclrintradr = R_DMA_CH6_CLR_INTR,
-	  .ofirstadr   = R_DMA_CH6_FIRST,
-	  .ocmdadr     = R_DMA_CH6_CMD,
-	  .ostatusadr  = R_DMA_CH6_STATUS,
-	  .iclrintradr = R_DMA_CH7_CLR_INTR,
-	  .ifirstadr   = R_DMA_CH7_FIRST,
-	  .icmdadr     = R_DMA_CH7_CMD,
-	  .idescradr   = R_DMA_CH7_DESCR,
-	  .flags       = STD_FLAGS,
-	  .rx_ctrl     = DEF_RX,
-	  .tx_ctrl     = DEF_TX,
-	  .iseteop     = 2,
-#ifdef CONFIG_ETRAX_SERIAL_PORT0
-          .enabled  = 1,
-#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA6_OUT
-	  .dma_out_enabled = 1,
-#else
-	  .dma_out_enabled = 0,
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA7_IN
-	  .dma_in_enabled = 1,
-#else
-	  .dma_in_enabled = 0
-#endif
-#else
-          .enabled  = 0,
-	  .dma_out_enabled = 0,
-	  .dma_in_enabled = 0
-#endif
-
-},  /* ttyS0 */
-#ifndef CONFIG_SVINTO_SIM
-	{ .baud        = DEF_BAUD,
-	  .port        = (unsigned char *)R_SERIAL1_CTRL,
-	  .irq         = 1U << 16, /* uses DMA 8 and 9 */
-	  .oclrintradr = R_DMA_CH8_CLR_INTR,
-	  .ofirstadr   = R_DMA_CH8_FIRST,
-	  .ocmdadr     = R_DMA_CH8_CMD,
-	  .ostatusadr  = R_DMA_CH8_STATUS,
-	  .iclrintradr = R_DMA_CH9_CLR_INTR,
-	  .ifirstadr   = R_DMA_CH9_FIRST,
-	  .icmdadr     = R_DMA_CH9_CMD,
-	  .idescradr   = R_DMA_CH9_DESCR,
-	  .flags       = STD_FLAGS,
-	  .rx_ctrl     = DEF_RX,
-	  .tx_ctrl     = DEF_TX,
-	  .iseteop     = 3,
-#ifdef CONFIG_ETRAX_SERIAL_PORT1
-          .enabled  = 1,
-#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA8_OUT
-	  .dma_out_enabled = 1,
-#else
-	  .dma_out_enabled = 0,
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA9_IN
-	  .dma_in_enabled = 1,
-#else
-	  .dma_in_enabled = 0
-#endif
-#else
-          .enabled  = 0,
-	  .dma_out_enabled = 0,
-	  .dma_in_enabled = 0
-#endif
-},  /* ttyS1 */
-
-	{ .baud        = DEF_BAUD,
-	  .port        = (unsigned char *)R_SERIAL2_CTRL,
-	  .irq         = 1U << 4,  /* uses DMA 2 and 3 */
-	  .oclrintradr = R_DMA_CH2_CLR_INTR,
-	  .ofirstadr   = R_DMA_CH2_FIRST,
-	  .ocmdadr     = R_DMA_CH2_CMD,
-	  .ostatusadr  = R_DMA_CH2_STATUS,
-	  .iclrintradr = R_DMA_CH3_CLR_INTR,
-	  .ifirstadr   = R_DMA_CH3_FIRST,
-	  .icmdadr     = R_DMA_CH3_CMD,
-	  .idescradr   = R_DMA_CH3_DESCR,
-	  .flags       = STD_FLAGS,
-	  .rx_ctrl     = DEF_RX,
-	  .tx_ctrl     = DEF_TX,
-	  .iseteop     = 0,
-#ifdef CONFIG_ETRAX_SERIAL_PORT2
-          .enabled  = 1,
-#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA2_OUT
-	  .dma_out_enabled = 1,
-#else
-	  .dma_out_enabled = 0,
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA3_IN
-	  .dma_in_enabled = 1,
-#else
-	  .dma_in_enabled = 0
-#endif
-#else
-          .enabled  = 0,
-	  .dma_out_enabled = 0,
-	  .dma_in_enabled = 0
-#endif
- },  /* ttyS2 */
-
-	{ .baud        = DEF_BAUD,
-	  .port        = (unsigned char *)R_SERIAL3_CTRL,
-	  .irq         = 1U << 8,  /* uses DMA 4 and 5 */
-	  .oclrintradr = R_DMA_CH4_CLR_INTR,
-	  .ofirstadr   = R_DMA_CH4_FIRST,
-	  .ocmdadr     = R_DMA_CH4_CMD,
-	  .ostatusadr  = R_DMA_CH4_STATUS,
-	  .iclrintradr = R_DMA_CH5_CLR_INTR,
-	  .ifirstadr   = R_DMA_CH5_FIRST,
-	  .icmdadr     = R_DMA_CH5_CMD,
-	  .idescradr   = R_DMA_CH5_DESCR,
-	  .flags       = STD_FLAGS,
-	  .rx_ctrl     = DEF_RX,
-	  .tx_ctrl     = DEF_TX,
-	  .iseteop     = 1,
-#ifdef CONFIG_ETRAX_SERIAL_PORT3
-          .enabled  = 1,
-#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA4_OUT
-	  .dma_out_enabled = 1,
-#else
-	  .dma_out_enabled = 0,
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA5_IN
-	  .dma_in_enabled = 1,
-#else
-	  .dma_in_enabled = 0
-#endif
-#else
-          .enabled  = 0,
-	  .dma_out_enabled = 0,
-	  .dma_in_enabled = 0
-#endif
- }   /* ttyS3 */
-#endif
-};
-
-
-#define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial))
-
-static struct termios *serial_termios[NR_PORTS];
-static struct termios *serial_termios_locked[NR_PORTS];
-#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
-static struct fast_timer fast_timers[NR_PORTS];
-#endif
-
-#ifdef CONFIG_ETRAX_SERIAL_PROC_ENTRY
-#define PROCSTAT(x) x
-struct ser_statistics_type {
-	int overrun_cnt;
-	int early_errors_cnt;
-	int ser_ints_ok_cnt;
-	int errors_cnt;
-	unsigned long int processing_flip;
-	unsigned long processing_flip_still_room;
-	unsigned long int timeout_flush_cnt;
-	int rx_dma_ints;
-	int tx_dma_ints;
-	int rx_tot;
-	int tx_tot;
-};
-
-static struct ser_statistics_type ser_stat[NR_PORTS];
-
-#else
-
-#define PROCSTAT(x)
-
-#endif /* CONFIG_ETRAX_SERIAL_PROC_ENTRY */
-
-/* RS-485 */
-#if defined(CONFIG_ETRAX_RS485)
-#ifdef CONFIG_ETRAX_FAST_TIMER
-static struct fast_timer fast_timers_rs485[NR_PORTS];
-#endif
-#if defined(CONFIG_ETRAX_RS485_ON_PA)
-static int rs485_pa_bit = CONFIG_ETRAX_RS485_ON_PA_BIT;
-#endif
-#if defined(CONFIG_ETRAX_RS485_ON_PORT_G)
-static int rs485_port_g_bit = CONFIG_ETRAX_RS485_ON_PORT_G_BIT;
-#endif
-#endif
-
-/* Info and macros needed for each ports extra control/status signals. */
-#define E100_STRUCT_PORT(line, pinname) \
- ((CONFIG_ETRAX_SER##line##_##pinname##_ON_PA_BIT >= 0)? \
-		(R_PORT_PA_DATA): ( \
- (CONFIG_ETRAX_SER##line##_##pinname##_ON_PB_BIT >= 0)? \
-		(R_PORT_PB_DATA):&dummy_ser[line]))
-
-#define E100_STRUCT_SHADOW(line, pinname) \
- ((CONFIG_ETRAX_SER##line##_##pinname##_ON_PA_BIT >= 0)? \
-		(&port_pa_data_shadow): ( \
- (CONFIG_ETRAX_SER##line##_##pinname##_ON_PB_BIT >= 0)? \
-		(&port_pb_data_shadow):&dummy_ser[line]))
-#define E100_STRUCT_MASK(line, pinname) \
- ((CONFIG_ETRAX_SER##line##_##pinname##_ON_PA_BIT >= 0)? \
-		(1<<CONFIG_ETRAX_SER##line##_##pinname##_ON_PA_BIT): ( \
- (CONFIG_ETRAX_SER##line##_##pinname##_ON_PB_BIT >= 0)? \
-		(1<<CONFIG_ETRAX_SER##line##_##pinname##_ON_PB_BIT):DUMMY_##pinname##_MASK))
-
-#define DUMMY_DTR_MASK 1
-#define DUMMY_RI_MASK  2
-#define DUMMY_DSR_MASK 4
-#define DUMMY_CD_MASK  8
-static unsigned char dummy_ser[NR_PORTS] = {0xFF, 0xFF, 0xFF,0xFF};
-
-/* If not all status pins are used or disabled, use mixed mode */
-#ifdef CONFIG_ETRAX_SERIAL_PORT0
-
-#define SER0_PA_BITSUM (CONFIG_ETRAX_SER0_DTR_ON_PA_BIT+CONFIG_ETRAX_SER0_RI_ON_PA_BIT+CONFIG_ETRAX_SER0_DSR_ON_PA_BIT+CONFIG_ETRAX_SER0_CD_ON_PA_BIT)
-
-#if SER0_PA_BITSUM != -4
-#  if CONFIG_ETRAX_SER0_DTR_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#   endif
-# if CONFIG_ETRAX_SER0_RI_ON_PA_BIT == -1
-#   ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
-#     define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
-#   endif
-#  endif
-#  if CONFIG_ETRAX_SER0_DSR_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#  if CONFIG_ETRAX_SER0_CD_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#endif
-
-#define SER0_PB_BITSUM (CONFIG_ETRAX_SER0_DTR_ON_PB_BIT+CONFIG_ETRAX_SER0_RI_ON_PB_BIT+CONFIG_ETRAX_SER0_DSR_ON_PB_BIT+CONFIG_ETRAX_SER0_CD_ON_PB_BIT)
-
-#if SER0_PB_BITSUM != -4
-#  if CONFIG_ETRAX_SER0_DTR_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#   endif
-# if CONFIG_ETRAX_SER0_RI_ON_PB_BIT == -1
-#   ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
-#     define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
-#   endif
-#  endif
-#  if CONFIG_ETRAX_SER0_DSR_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#  if CONFIG_ETRAX_SER0_CD_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#endif
-
-#endif /* PORT0 */
-
-
-#ifdef CONFIG_ETRAX_SERIAL_PORT1
-
-#define SER1_PA_BITSUM (CONFIG_ETRAX_SER1_DTR_ON_PA_BIT+CONFIG_ETRAX_SER1_RI_ON_PA_BIT+CONFIG_ETRAX_SER1_DSR_ON_PA_BIT+CONFIG_ETRAX_SER1_CD_ON_PA_BIT)
-
-#if SER1_PA_BITSUM != -4
-#  if CONFIG_ETRAX_SER1_DTR_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#   endif
-# if CONFIG_ETRAX_SER1_RI_ON_PA_BIT == -1
-#   ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
-#     define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
-#   endif
-#  endif
-#  if CONFIG_ETRAX_SER1_DSR_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#  if CONFIG_ETRAX_SER1_CD_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#endif
-
-#define SER1_PB_BITSUM (CONFIG_ETRAX_SER1_DTR_ON_PB_BIT+CONFIG_ETRAX_SER1_RI_ON_PB_BIT+CONFIG_ETRAX_SER1_DSR_ON_PB_BIT+CONFIG_ETRAX_SER1_CD_ON_PB_BIT)
-
-#if SER1_PB_BITSUM != -4
-#  if CONFIG_ETRAX_SER1_DTR_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#   endif
-# if CONFIG_ETRAX_SER1_RI_ON_PB_BIT == -1
-#   ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
-#     define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
-#   endif
-#  endif
-#  if CONFIG_ETRAX_SER1_DSR_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#  if CONFIG_ETRAX_SER1_CD_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#endif
-
-#endif /* PORT1 */
-
-#ifdef CONFIG_ETRAX_SERIAL_PORT2
-
-#define SER2_PA_BITSUM (CONFIG_ETRAX_SER2_DTR_ON_PA_BIT+CONFIG_ETRAX_SER2_RI_ON_PA_BIT+CONFIG_ETRAX_SER2_DSR_ON_PA_BIT+CONFIG_ETRAX_SER2_CD_ON_PA_BIT)
-
-#if SER2_PA_BITSUM != -4
-#  if CONFIG_ETRAX_SER2_DTR_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#   endif
-# if CONFIG_ETRAX_SER2_RI_ON_PA_BIT == -1
-#   ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
-#     define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
-#   endif
-#  endif
-#  if CONFIG_ETRAX_SER2_DSR_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#  if CONFIG_ETRAX_SER2_CD_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#endif
-
-#define SER2_PB_BITSUM (CONFIG_ETRAX_SER2_DTR_ON_PB_BIT+CONFIG_ETRAX_SER2_RI_ON_PB_BIT+CONFIG_ETRAX_SER2_DSR_ON_PB_BIT+CONFIG_ETRAX_SER2_CD_ON_PB_BIT)
-
-#if SER2_PB_BITSUM != -4
-#  if CONFIG_ETRAX_SER2_DTR_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#   endif
-# if CONFIG_ETRAX_SER2_RI_ON_PB_BIT == -1
-#   ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
-#     define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
-#   endif
-#  endif
-#  if CONFIG_ETRAX_SER2_DSR_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#  if CONFIG_ETRAX_SER2_CD_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#endif
-
-#endif /* PORT2 */
-
-#ifdef CONFIG_ETRAX_SERIAL_PORT3
-
-#define SER3_PA_BITSUM (CONFIG_ETRAX_SER3_DTR_ON_PA_BIT+CONFIG_ETRAX_SER3_RI_ON_PA_BIT+CONFIG_ETRAX_SER3_DSR_ON_PA_BIT+CONFIG_ETRAX_SER3_CD_ON_PA_BIT)
-
-#if SER3_PA_BITSUM != -4
-#  if CONFIG_ETRAX_SER3_DTR_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#   endif
-# if CONFIG_ETRAX_SER3_RI_ON_PA_BIT == -1
-#   ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
-#     define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
-#   endif
-#  endif
-#  if CONFIG_ETRAX_SER3_DSR_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#  if CONFIG_ETRAX_SER3_CD_ON_PA_BIT == -1
-#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#endif
-
-#define SER3_PB_BITSUM (CONFIG_ETRAX_SER3_DTR_ON_PB_BIT+CONFIG_ETRAX_SER3_RI_ON_PB_BIT+CONFIG_ETRAX_SER3_DSR_ON_PB_BIT+CONFIG_ETRAX_SER3_CD_ON_PB_BIT)
-
-#if SER3_PB_BITSUM != -4
-#  if CONFIG_ETRAX_SER3_DTR_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#   endif
-# if CONFIG_ETRAX_SER3_RI_ON_PB_BIT == -1
-#   ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
-#     define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
-#   endif
-#  endif
-#  if CONFIG_ETRAX_SER3_DSR_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#  if CONFIG_ETRAX_SER3_CD_ON_PB_BIT == -1
-#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
-#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
-#    endif
-#  endif
-#endif
-
-#endif /* PORT3 */
-
-
-#if defined(CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED) || \
-    defined(CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED) || \
-    defined(CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED) || \
-    defined(CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED)
-#define CONFIG_ETRAX_SERX_DTR_RI_DSR_CD_MIXED
-#endif
-
-#ifdef CONFIG_ETRAX_SERX_DTR_RI_DSR_CD_MIXED
-/* The pins can be mixed on PA and PB */
-#define CONTROL_PINS_PORT_NOT_USED(line) \
-  &dummy_ser[line], &dummy_ser[line], \
-  &dummy_ser[line], &dummy_ser[line], \
-  &dummy_ser[line], &dummy_ser[line], \
-  &dummy_ser[line], &dummy_ser[line], \
-  DUMMY_DTR_MASK, DUMMY_RI_MASK, DUMMY_DSR_MASK, DUMMY_CD_MASK
-    
-
-struct control_pins
-{
-	volatile unsigned char *dtr_port;
-	unsigned char          *dtr_shadow;
-	volatile unsigned char *ri_port;
-	unsigned char          *ri_shadow;
-	volatile unsigned char *dsr_port;
-	unsigned char          *dsr_shadow;
-	volatile unsigned char *cd_port;
-	unsigned char          *cd_shadow;
-
-	unsigned char dtr_mask;
-	unsigned char ri_mask;
-	unsigned char dsr_mask;
-	unsigned char cd_mask;
-};
-
-static const struct control_pins e100_modem_pins[NR_PORTS] = 
-{
-	/* Ser 0 */
-	{
-#ifdef CONFIG_ETRAX_SERIAL_PORT0
-	E100_STRUCT_PORT(0,DTR), E100_STRUCT_SHADOW(0,DTR),
-	E100_STRUCT_PORT(0,RI),  E100_STRUCT_SHADOW(0,RI),
-	E100_STRUCT_PORT(0,DSR), E100_STRUCT_SHADOW(0,DSR),
-	E100_STRUCT_PORT(0,CD),  E100_STRUCT_SHADOW(0,CD),
-	E100_STRUCT_MASK(0,DTR),
-	E100_STRUCT_MASK(0,RI),
-	E100_STRUCT_MASK(0,DSR),
-	E100_STRUCT_MASK(0,CD)
-#else
-	CONTROL_PINS_PORT_NOT_USED(0)
-#endif	
-	},
-
-	/* Ser 1 */
-	{
-#ifdef CONFIG_ETRAX_SERIAL_PORT1	  
-	E100_STRUCT_PORT(1,DTR), E100_STRUCT_SHADOW(1,DTR),
-	E100_STRUCT_PORT(1,RI),  E100_STRUCT_SHADOW(1,RI),
-	E100_STRUCT_PORT(1,DSR), E100_STRUCT_SHADOW(1,DSR),
-	E100_STRUCT_PORT(1,CD),  E100_STRUCT_SHADOW(1,CD),
-	E100_STRUCT_MASK(1,DTR),
-	E100_STRUCT_MASK(1,RI),
-	E100_STRUCT_MASK(1,DSR),
-	E100_STRUCT_MASK(1,CD)
-#else
-	CONTROL_PINS_PORT_NOT_USED(1)
-#endif		
-	},
-
-	/* Ser 2 */
-	{
-#ifdef CONFIG_ETRAX_SERIAL_PORT2	  
-	E100_STRUCT_PORT(2,DTR), E100_STRUCT_SHADOW(2,DTR),
-	E100_STRUCT_PORT(2,RI),  E100_STRUCT_SHADOW(2,RI),
-	E100_STRUCT_PORT(2,DSR), E100_STRUCT_SHADOW(2,DSR),
-	E100_STRUCT_PORT(2,CD),  E100_STRUCT_SHADOW(2,CD),
-	E100_STRUCT_MASK(2,DTR),
-	E100_STRUCT_MASK(2,RI),
-	E100_STRUCT_MASK(2,DSR),
-	E100_STRUCT_MASK(2,CD)
-#else
-	CONTROL_PINS_PORT_NOT_USED(2)
-#endif		
-	},
-
-	/* Ser 3 */
-	{
-#ifdef CONFIG_ETRAX_SERIAL_PORT3	  
-	E100_STRUCT_PORT(3,DTR), E100_STRUCT_SHADOW(3,DTR),
-	E100_STRUCT_PORT(3,RI),  E100_STRUCT_SHADOW(3,RI),
-	E100_STRUCT_PORT(3,DSR), E100_STRUCT_SHADOW(3,DSR),
-	E100_STRUCT_PORT(3,CD),  E100_STRUCT_SHADOW(3,CD),
-	E100_STRUCT_MASK(3,DTR),
-	E100_STRUCT_MASK(3,RI),
-	E100_STRUCT_MASK(3,DSR),
-	E100_STRUCT_MASK(3,CD)
-#else
-	CONTROL_PINS_PORT_NOT_USED(3)
-#endif		
-	}
-};
-#else  /* CONFIG_ETRAX_SERX_DTR_RI_DSR_CD_MIXED */
-
-/* All pins are on either PA or PB for each serial port */
-#define CONTROL_PINS_PORT_NOT_USED(line) \
-  &dummy_ser[line], &dummy_ser[line], \
-  DUMMY_DTR_MASK, DUMMY_RI_MASK, DUMMY_DSR_MASK, DUMMY_CD_MASK
-    
-
-struct control_pins
-{
-	volatile unsigned char *port;
-	unsigned char          *shadow;
-
-	unsigned char dtr_mask;
-	unsigned char ri_mask;
-	unsigned char dsr_mask;
-	unsigned char cd_mask;
-};
-
-#define dtr_port port
-#define dtr_shadow shadow
-#define ri_port port
-#define ri_shadow shadow
-#define dsr_port port
-#define dsr_shadow shadow
-#define cd_port port
-#define cd_shadow shadow
-
-static const struct control_pins e100_modem_pins[NR_PORTS] = 
-{
-	/* Ser 0 */
-	{
-#ifdef CONFIG_ETRAX_SERIAL_PORT0
-	E100_STRUCT_PORT(0,DTR), E100_STRUCT_SHADOW(0,DTR),
-	E100_STRUCT_MASK(0,DTR),
-	E100_STRUCT_MASK(0,RI),
-	E100_STRUCT_MASK(0,DSR),
-	E100_STRUCT_MASK(0,CD)
-#else
-	CONTROL_PINS_PORT_NOT_USED(0)
-#endif	
-	},
-
-	/* Ser 1 */
-	{
-#ifdef CONFIG_ETRAX_SERIAL_PORT1	  
-	E100_STRUCT_PORT(1,DTR), E100_STRUCT_SHADOW(1,DTR),
-	E100_STRUCT_MASK(1,DTR),
-	E100_STRUCT_MASK(1,RI),
-	E100_STRUCT_MASK(1,DSR),
-	E100_STRUCT_MASK(1,CD)
-#else
-	CONTROL_PINS_PORT_NOT_USED(1)
-#endif		
-	},
-
-	/* Ser 2 */
-	{
-#ifdef CONFIG_ETRAX_SERIAL_PORT2	  
-	E100_STRUCT_PORT(2,DTR), E100_STRUCT_SHADOW(2,DTR),
-	E100_STRUCT_MASK(2,DTR),
-	E100_STRUCT_MASK(2,RI),
-	E100_STRUCT_MASK(2,DSR),
-	E100_STRUCT_MASK(2,CD)
-#else
-	CONTROL_PINS_PORT_NOT_USED(2)
-#endif		
-	},
-
-	/* Ser 3 */
-	{
-#ifdef CONFIG_ETRAX_SERIAL_PORT3	  
-	E100_STRUCT_PORT(3,DTR), E100_STRUCT_SHADOW(3,DTR),
-	E100_STRUCT_MASK(3,DTR),
-	E100_STRUCT_MASK(3,RI),
-	E100_STRUCT_MASK(3,DSR),
-	E100_STRUCT_MASK(3,CD)
-#else
-	CONTROL_PINS_PORT_NOT_USED(3)
-#endif		
-	}
-};
-#endif /* !CONFIG_ETRAX_SERX_DTR_RI_DSR_CD_MIXED */
-
-#define E100_RTS_MASK 0x20
-#define E100_CTS_MASK 0x40
-
-/* All serial port signals are active low:
- * active   = 0 -> 3.3V to RS-232 driver -> -12V on RS-232 level
- * inactive = 1 -> 0V   to RS-232 driver -> +12V on RS-232 level
- *
- * These macros returns the pin value: 0=0V, >=1 = 3.3V on ETRAX chip
- */
-
-/* Output */
-#define E100_RTS_GET(info) ((info)->rx_ctrl & E100_RTS_MASK)
-/* Input */
-#define E100_CTS_GET(info) ((info)->port[REG_STATUS] & E100_CTS_MASK)
-
-/* These are typically PA or PB and 0 means 0V, 1 means 3.3V */
-/* Is an output */
-#define E100_DTR_GET(info) ((*e100_modem_pins[(info)->line].dtr_shadow) & e100_modem_pins[(info)->line].dtr_mask)
-
-/* Normally inputs */
-#define E100_RI_GET(info) ((*e100_modem_pins[(info)->line].ri_port) & e100_modem_pins[(info)->line].ri_mask)
-#define E100_CD_GET(info) ((*e100_modem_pins[(info)->line].cd_port) & e100_modem_pins[(info)->line].cd_mask)
-
-/* Input */
-#define E100_DSR_GET(info) ((*e100_modem_pins[(info)->line].dsr_port) & e100_modem_pins[(info)->line].dsr_mask)
-
-
-/*
- * tmp_buf is used as a temporary buffer by serial_write.  We need to
- * lock it in case the memcpy_fromfs 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
-
-/* Calculate the chartime depending on baudrate, numbor of bits etc. */
-static void update_char_time(struct e100_serial * info)
-{
-	tcflag_t cflags = info->tty->termios->c_cflag;
-	int bits;
-
-	/* calc. number of bits / data byte */
-	/* databits + startbit and 1 stopbit */
-	if ((cflags & CSIZE) == CS7)
-		bits = 9;
-	else
-		bits = 10;  
-
-	if (cflags & CSTOPB)     /* 2 stopbits ? */
-		bits++;
-
-	if (cflags & PARENB)     /* parity bit ? */
-		bits++;
-
-	/* calc timeout */
-	info->char_time_usec = ((bits * 1000000) / info->baud) + 1;
-	info->flush_time_usec = 4*info->char_time_usec;
-	if (info->flush_time_usec < MIN_FLUSH_TIME_USEC)
-		info->flush_time_usec = MIN_FLUSH_TIME_USEC;
-
-}
-
-/*
- * This function maps from the Bxxxx defines in asm/termbits.h into real
- * baud rates.
- */
-
-static int 
-cflag_to_baud(unsigned int cflag)
-{
-	static int baud_table[] = {
-		0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
-		4800, 9600, 19200, 38400 };
-
-	static int ext_baud_table[] = {
-		0, 57600, 115200, 230400, 460800, 921600, 1843200, 6250000,
-                0, 0, 0, 0, 0, 0, 0, 0 };
-
-	if (cflag & CBAUDEX)
-		return ext_baud_table[(cflag & CBAUD) & ~CBAUDEX];
-	else 
-		return baud_table[cflag & CBAUD];
-}
-
-/* and this maps to an etrax100 hardware baud constant */
-
-static unsigned char 
-cflag_to_etrax_baud(unsigned int cflag)
-{
-	char retval;
-
-	static char baud_table[] = {
-		-1, -1, -1, -1, -1, -1, -1, 0, 1, 2, -1, 3, 4, 5, 6, 7 };
-
-	static char ext_baud_table[] = {
-		-1, 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1 };
-
-	if (cflag & CBAUDEX)
-		retval = ext_baud_table[(cflag & CBAUD) & ~CBAUDEX];
-	else 
-		retval = baud_table[cflag & CBAUD];
-
-	if (retval < 0) {
-		printk(KERN_WARNING "serdriver tried setting invalid baud rate, flags %x.\n", cflag);
-		retval = 5; /* choose default 9600 instead */
-	}
-
-	return retval | (retval << 4); /* choose same for both TX and RX */
-}
-
-
-/* Various static support functions */
-
-/* Functions to set or clear DTR/RTS on the requested line */
-/* It is complicated by the fact that RTS is a serial port register, while
- * DTR might not be implemented in the HW at all, and if it is, it can be on
- * any general port.
- */
-
-
-static inline void 
-e100_dtr(struct e100_serial *info, int set)
-{
-#ifndef CONFIG_SVINTO_SIM
-	unsigned char mask = e100_modem_pins[info->line].dtr_mask;
-
-#ifdef SERIAL_DEBUG_IO  
-	printk("ser%i dtr %i mask: 0x%02X\n", info->line, set, mask);
-	printk("ser%i shadow before 0x%02X get: %i\n", 
-	       info->line, *e100_modem_pins[info->line].dtr_shadow,
-	       E100_DTR_GET(info));
-#endif
-	/* DTR is active low */
-	{
-		unsigned long flags;
-
-		save_flags(flags);
-		cli();
-		*e100_modem_pins[info->line].dtr_shadow &= ~mask;
-		*e100_modem_pins[info->line].dtr_shadow |= (set ? 0 : mask); 
-		*e100_modem_pins[info->line].dtr_port = *e100_modem_pins[info->line].dtr_shadow;
-		restore_flags(flags);
-	}
-	
-#ifdef SERIAL_DEBUG_IO
-	printk("ser%i shadow after 0x%02X get: %i\n", 
-	       info->line, *e100_modem_pins[info->line].dtr_shadow, 
-	       E100_DTR_GET(info));
-#endif
-#endif
-}
-
-/* set = 0 means 3.3V on the pin, bitvalue: 0=active, 1=inactive  
- *                                          0=0V    , 1=3.3V
- */
-static inline void 
-e100_rts(struct e100_serial *info, int set)
-{
-#ifndef CONFIG_SVINTO_SIM
-	unsigned long flags;
-	save_flags(flags);
-	cli();
-	info->rx_ctrl &= ~E100_RTS_MASK;
-	info->rx_ctrl |= (set ? 0 : E100_RTS_MASK);  /* RTS is active low */
-	info->port[REG_REC_CTRL] = info->rx_ctrl;
-	restore_flags(flags);
-#ifdef SERIAL_DEBUG_IO  
-	printk("ser%i rts %i\n", info->line, set);
-#endif
-#endif
-}
-
-
-/* If this behaves as a modem, RI and CD is an output */
-static inline void 
-e100_ri_out(struct e100_serial *info, int set)
-{
-#ifndef CONFIG_SVINTO_SIM
-	/* RI is active low */
-	{
-		unsigned char mask = e100_modem_pins[info->line].ri_mask;
-		unsigned long flags;
-
-		save_flags(flags);
-		cli();
-		*e100_modem_pins[info->line].ri_shadow &= ~mask;
-		*e100_modem_pins[info->line].ri_shadow |= (set ? 0 : mask); 
-		*e100_modem_pins[info->line].ri_port = *e100_modem_pins[info->line].ri_shadow;
-		restore_flags(flags);
-	}
-#endif
-}
-static inline void 
-e100_cd_out(struct e100_serial *info, int set)
-{
-#ifndef CONFIG_SVINTO_SIM
-	/* CD is active low */
-	{
-		unsigned char mask = e100_modem_pins[info->line].cd_mask;
-		unsigned long flags;
-
-		save_flags(flags);
-		cli();
-		*e100_modem_pins[info->line].cd_shadow &= ~mask;
-		*e100_modem_pins[info->line].cd_shadow |= (set ? 0 : mask); 
-		*e100_modem_pins[info->line].cd_port = *e100_modem_pins[info->line].cd_shadow;
-		restore_flags(flags);
-	}
-#endif
-}
-
-static inline void
-e100_disable_rx(struct e100_serial *info)
-{
-#ifndef CONFIG_SVINTO_SIM
-	/* disable the receiver */
-	info->port[REG_REC_CTRL] =
-		(info->rx_ctrl &= ~IO_MASK(R_SERIAL0_REC_CTRL, rec_enable));
-#endif
-}
-
-static inline void 
-e100_enable_rx(struct e100_serial *info)
-{
-#ifndef CONFIG_SVINTO_SIM
-	/* enable the receiver */
-	info->port[REG_REC_CTRL] =
-		(info->rx_ctrl |= IO_MASK(R_SERIAL0_REC_CTRL, rec_enable));
-#endif
-}
-
-/* the rx DMA uses both the dma_descr and the dma_eop interrupts */
-
-static inline void
-e100_disable_rxdma_irq(struct e100_serial *info) 
-{
-#ifdef SERIAL_DEBUG_INTR
-	printk("rxdma_irq(%d): 0\n",info->line);
-#endif
-	DINTR1(DEBUG_LOG(info->line,"IRQ disable_rxdma_irq %i\n", info->line));
-	*R_IRQ_MASK2_CLR = (info->irq << 2) | (info->irq << 3);
-}
-
-static inline void
-e100_enable_rxdma_irq(struct e100_serial *info) 
-{
-#ifdef SERIAL_DEBUG_INTR
-	printk("rxdma_irq(%d): 1\n",info->line);
-#endif
-	DINTR1(DEBUG_LOG(info->line,"IRQ enable_rxdma_irq %i\n", info->line));
-	*R_IRQ_MASK2_SET = (info->irq << 2) | (info->irq << 3);
-}
-
-/* the tx DMA uses only dma_descr interrupt */
-
-static _INLINE_ void
-e100_disable_txdma_irq(struct e100_serial *info) 
-{
-#ifdef SERIAL_DEBUG_INTR
-	printk("txdma_irq(%d): 0\n",info->line);
-#endif
-	DINTR1(DEBUG_LOG(info->line,"IRQ disable_txdma_irq %i\n", info->line));
-	*R_IRQ_MASK2_CLR = info->irq;
-}
-
-static _INLINE_ void
-e100_enable_txdma_irq(struct e100_serial *info) 
-{
-#ifdef SERIAL_DEBUG_INTR
-	printk("txdma_irq(%d): 1\n",info->line);
-#endif
-	DINTR1(DEBUG_LOG(info->line,"IRQ enable_txdma_irq %i\n", info->line));
-	*R_IRQ_MASK2_SET = info->irq;
-}
-
-static _INLINE_ void
-e100_disable_txdma_channel(struct e100_serial *info)
-{
-	unsigned long flags;
-  
-	/* Disable output DMA channel for the serial port in question
-	 * ( set to something other then serialX)
-	 */
-	save_flags(flags);
-	cli();
-	DFLOW(DEBUG_LOG(info->line, "disable_txdma_channel %i\n", info->line));
-	if (info->line == 0) {
-		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma6)) ==
-		    IO_STATE(R_GEN_CONFIG, dma6, serial0)) {
-			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma6);
-			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma6, unused);
-		}
-	} else if (info->line == 1) {
-		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma8)) ==
-		    IO_STATE(R_GEN_CONFIG, dma8, serial1)) {
-			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma8);
-			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma8, usb);
-		}
-	} else if (info->line == 2) {
-		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma2)) ==
-		    IO_STATE(R_GEN_CONFIG, dma2, serial2)) {
-			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma2);
-			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma2, par0);
-		}
-	} else if (info->line == 3) {
-		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma4)) ==
-		    IO_STATE(R_GEN_CONFIG, dma4, serial3)) {
-			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma4);
-			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma4, par1);
-		}
-	}
-	*R_GEN_CONFIG = genconfig_shadow;
-	restore_flags(flags);
-}
-
-
-static _INLINE_ void
-e100_enable_txdma_channel(struct e100_serial *info)
-{
-	unsigned long flags;
-  
-	save_flags(flags);
-	cli();
-	DFLOW(DEBUG_LOG(info->line, "enable_txdma_channel %i\n", info->line));
-	/* Enable output DMA channel for the serial port in question */
-	if (info->line == 0) {
-		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma6);
-		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma6, serial0);
-	} else if (info->line == 1) {
-		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma8);
-		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma8, serial1);
-	} else if (info->line == 2) {
-		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma2);
-		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma2, serial2);
-	} else if (info->line == 3) {
-		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma4);
-		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma4, serial3);
-	}
-	*R_GEN_CONFIG = genconfig_shadow;
-	restore_flags(flags);
-}
-
-static _INLINE_ void
-e100_disable_rxdma_channel(struct e100_serial *info)
-{
-	unsigned long flags;
-
-	/* Disable input DMA channel for the serial port in question
-	 * ( set to something other then serialX)
-	 */
-	save_flags(flags);
-	cli();
-	if (info->line == 0) {
-		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma7)) ==
-		    IO_STATE(R_GEN_CONFIG, dma7, serial0)) {
-			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma7);
-			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma7, unused);
-		}
-	} else if (info->line == 1) {
-		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma9)) ==
-		    IO_STATE(R_GEN_CONFIG, dma9, serial1)) {
-			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma9);
-			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma9, usb);
-		}
-	} else if (info->line == 2) {
-		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma3)) ==
-		    IO_STATE(R_GEN_CONFIG, dma3, serial2)) {
-			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma3);
-			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma3, par0);
-		}
-	} else if (info->line == 3) {
-		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma5)) ==
-		    IO_STATE(R_GEN_CONFIG, dma5, serial3)) {
-			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma5);
-			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma5, par1);
-		}
-	}
-	*R_GEN_CONFIG = genconfig_shadow;
-	restore_flags(flags);
-}
-
-
-static _INLINE_ void
-e100_enable_rxdma_channel(struct e100_serial *info)
-{
-	unsigned long flags;
-
-	save_flags(flags);
-	cli();
-	/* Enable input DMA channel for the serial port in question */
-	if (info->line == 0) {
-		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma7);
-		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma7, serial0);
-	} else if (info->line == 1) {
-		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma9);
-		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma9, serial1);
-	} else if (info->line == 2) {
-		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma3);
-		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma3, serial2);
-	} else if (info->line == 3) {
-		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma5);
-		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma5, serial3);
-	}
-	*R_GEN_CONFIG = genconfig_shadow;
-	restore_flags(flags);
-}
-
-#ifdef SERIAL_HANDLE_EARLY_ERRORS
-/* in order to detect and fix errors on the first byte
-   we have to use the serial interrupts as well. */
-
-static inline void
-e100_disable_serial_data_irq(struct e100_serial *info) 
-{
-#ifdef SERIAL_DEBUG_INTR
-	printk("ser_irq(%d): 0\n",info->line);
-#endif
-	DINTR1(DEBUG_LOG(info->line,"IRQ disable data_irq %i\n", info->line));
-	*R_IRQ_MASK1_CLR = (1U << (8+2*info->line));
-}
-
-static inline void
-e100_enable_serial_data_irq(struct e100_serial *info) 
-{
-#ifdef SERIAL_DEBUG_INTR
-	printk("ser_irq(%d): 1\n",info->line);
-	printk("**** %d = %d\n",
-	       (8+2*info->line),
-	       (1U << (8+2*info->line)));
-#endif
-	DINTR1(DEBUG_LOG(info->line,"IRQ enable data_irq %i\n", info->line));
-	*R_IRQ_MASK1_SET = (1U << (8+2*info->line));
-}
-#endif
-
-static inline void
-e100_disable_serial_tx_ready_irq(struct e100_serial *info)
-{
-#ifdef SERIAL_DEBUG_INTR
-	printk("ser_tx_irq(%d): 0\n",info->line);
-#endif
-	DINTR1(DEBUG_LOG(info->line,"IRQ disable ready_irq %i\n", info->line));
-	*R_IRQ_MASK1_CLR = (1U << (8+1+2*info->line));
-}
-
-static inline void
-e100_enable_serial_tx_ready_irq(struct e100_serial *info)
-{
-#ifdef SERIAL_DEBUG_INTR
-	printk("ser_tx_irq(%d): 1\n",info->line);
-	printk("**** %d = %d\n",
-	       (8+1+2*info->line),
-	       (1U << (8+1+2*info->line)));
-#endif
-	DINTR2(DEBUG_LOG(info->line,"IRQ enable ready_irq %i\n", info->line));
-	*R_IRQ_MASK1_SET = (1U << (8+1+2*info->line));
-}
-
-static inline void e100_enable_rx_irq(struct e100_serial *info)
-{
-	if (info->uses_dma_in)
-		e100_enable_rxdma_irq(info);
-	else
-		e100_enable_serial_data_irq(info);
-}
-static inline void e100_disable_rx_irq(struct e100_serial *info)
-{
-	if (info->uses_dma_in)
-		e100_disable_rxdma_irq(info);
-	else
-		e100_disable_serial_data_irq(info);
-}
-
-#if defined(CONFIG_ETRAX_RS485)
-/* Enable RS-485 mode on selected port. This is UGLY. */
-static int
-e100_enable_rs485(struct tty_struct *tty,struct rs485_control *r)
-{
-	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
-
-#if defined(CONFIG_ETRAX_RS485_ON_PA)	
-	*R_PORT_PA_DATA = port_pa_data_shadow |= (1 << rs485_pa_bit);
-#endif
-#if defined(CONFIG_ETRAX_RS485_ON_PORT_G)
-	REG_SHADOW_SET(R_PORT_G_DATA,  port_g_data_shadow,
-		       rs485_port_g_bit, 1);
-#endif
-#if defined(CONFIG_ETRAX_RS485_LTC1387)
-	REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
-		       CONFIG_ETRAX_RS485_LTC1387_DXEN_PORT_G_BIT, 1);
-	REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
-		       CONFIG_ETRAX_RS485_LTC1387_RXEN_PORT_G_BIT, 1);
-#endif
-
-	info->rs485.rts_on_send = 0x01 & r->rts_on_send;
-	info->rs485.rts_after_sent = 0x01 & r->rts_after_sent;
-	if (r->delay_rts_before_send >= 1000)
-		info->rs485.delay_rts_before_send = 1000;
-	else
-		info->rs485.delay_rts_before_send = r->delay_rts_before_send;
-	info->rs485.enabled = r->enabled;
-/*	printk("rts: on send = %i, after = %i, enabled = %i",
-		    info->rs485.rts_on_send,
-		    info->rs485.rts_after_sent,
-		    info->rs485.enabled
-	);
-*/		
-	return 0;
-}
-
-static int
-e100_write_rs485(struct tty_struct *tty, int from_user,
-                 const unsigned char *buf, int count)
-{
-	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
-	int old_enabled = info->rs485.enabled;
-
-	/* rs485 is always implicitly enabled if we're using the ioctl() 
-	 * but it doesn't have to be set in the rs485_control
-	 * (to be backward compatible with old apps)
-	 * So we store, set and restore it.
-	 */
-	info->rs485.enabled = 1;
-	/* rs_write now deals with RS485 if enabled */
-	count = rs_write(tty, from_user, buf, count);
-	info->rs485.enabled = old_enabled;
-	return count;
-}
-
-#ifdef CONFIG_ETRAX_FAST_TIMER
-/* Timer function to toggle RTS when using FAST_TIMER */
-static void rs485_toggle_rts_timer_function(unsigned long data)
-{
-	struct e100_serial *info = (struct e100_serial *)data;
-
-	fast_timers_rs485[info->line].function = NULL;
-	e100_rts(info, info->rs485.rts_after_sent);
-#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
-	e100_enable_rx(info);
-	e100_enable_rx_irq(info);
-#endif
-}
-#endif
-#endif /* CONFIG_ETRAX_RS485 */
-
-/*
- * ------------------------------------------------------------
- * rs_stop() and rs_start()
- *
- * This routines are called before setting or resetting tty->stopped.
- * They enable or disable transmitter using the XOFF registers, as necessary.
- * ------------------------------------------------------------
- */
-
-static void 
-rs_stop(struct tty_struct *tty)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-	if (info) {
-		unsigned long flags;
-		unsigned long xoff;
-
-		save_flags(flags); cli();
-		DFLOW(DEBUG_LOG(info->line, "XOFF rs_stop xmit %i\n",
-				CIRC_CNT(info->xmit.head,
-					 info->xmit.tail,SERIAL_XMIT_SIZE)));
-
-		xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->tty));
-		xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, stop);
-		if (tty->termios->c_iflag & IXON ) {
-			xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
-		}
-	
-		*((unsigned long *)&info->port[REG_XOFF]) = xoff;
-		restore_flags(flags);
-	}
-}
-
-static void 
-rs_start(struct tty_struct *tty)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-	if (info) {
-		unsigned long flags;
-		unsigned long xoff;
-
-		save_flags(flags); cli();
-		DFLOW(DEBUG_LOG(info->line, "XOFF rs_start xmit %i\n",
-				CIRC_CNT(info->xmit.head,
-					 info->xmit.tail,SERIAL_XMIT_SIZE)));
-		xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(tty));
-		xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
-		if (tty->termios->c_iflag & IXON ) {
-			xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
-		}
-	
-		*((unsigned long *)&info->port[REG_XOFF]) = xoff;
-		if (!info->uses_dma_out &&
-		    info->xmit.head != info->xmit.tail && info->xmit.buf)
-			e100_enable_serial_tx_ready_irq(info);
-		
-		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 e100_serial *info,
-				    int event)
-{
-	if (info->event & (1 << event))
-		return;
-	info->event |= 1 << event;
-	schedule_work(&info->work);
-}
-
-/* The output DMA channel is free - use it to send as many chars as possible
- * NOTES:
- *   We don't pay attention to info->x_char, which means if the TTY wants to
- *   use XON/XOFF it will set info->x_char but we won't send any X char!
- * 
- *   To implement this, we'd just start a DMA send of 1 byte pointing at a
- *   buffer containing the X char, and skip updating xmit. We'd also have to
- *   check if the last sent char was the X char when we enter this function
- *   the next time, to avoid updating xmit with the sent X value.
- */
-
-static void 
-transmit_chars_dma(struct e100_serial *info)
-{
-	unsigned int c, sentl;
-	struct etrax_dma_descr *descr;
-
-#ifdef CONFIG_SVINTO_SIM
-	/* This will output too little if tail is not 0 always since
-	 * we don't reloop to send the other part. Anyway this SHOULD be a
-	 * no-op - transmit_chars_dma would never really be called during sim
-	 * since rs_write does not write into the xmit buffer then.
-	 */
-	if (info->xmit.tail)
-		printk("Error in serial.c:transmit_chars-dma(), tail!=0\n");
-	if (info->xmit.head != info->xmit.tail) {
-		SIMCOUT(info->xmit.buf + info->xmit.tail,
-			CIRC_CNT(info->xmit.head,
-				 info->xmit.tail,
-				 SERIAL_XMIT_SIZE));
-		info->xmit.head = info->xmit.tail;  /* move back head */
-		info->tr_running = 0;
-	}
-	return;
-#endif
-	/* acknowledge both dma_descr and dma_eop irq in R_DMA_CHx_CLR_INTR */
-	*info->oclrintradr =
-		IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
-		IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
-
-#ifdef SERIAL_DEBUG_INTR
-	if (info->line == SERIAL_DEBUG_LINE)
-		printk("tc\n");
-#endif
-	if (!info->tr_running) {
-		/* weirdo... we shouldn't get here! */
-		printk(KERN_WARNING "Achtung: transmit_chars_dma with !tr_running\n");
-		return;
-	}
-
-	descr = &info->tr_descr;
-
-	/* first get the amount of bytes sent during the last DMA transfer,
-	   and update xmit accordingly */
-
-	/* if the stop bit was not set, all data has been sent */
-	if (!(descr->status & d_stop)) {
-		sentl = descr->sw_len;
-	} else 
-		/* otherwise we find the amount of data sent here */
-		sentl = descr->hw_len;
-
-	DFLOW(DEBUG_LOG(info->line, "TX %i done\n", sentl));
-
-	/* update stats */
-	info->icount.tx += sentl;
-
-	/* update xmit buffer */
-	info->xmit.tail = (info->xmit.tail + sentl) & (SERIAL_XMIT_SIZE - 1);
-
-	/* if there is only a few chars left in the buf, wake up the blocked
-	   write if any */
-	if (CIRC_CNT(info->xmit.head,
-		     info->xmit.tail,
-		     SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
-		rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
-
-	/* find out the largest amount of consecutive bytes we want to send now */
-
-	c = CIRC_CNT_TO_END(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
-
-	/* Don't send all in one DMA transfer - divide it so we wake up
-	 * application before all is sent
-	 */
-
-	if (c >= 4*WAKEUP_CHARS)
-		c = c/2;
-
-	if (c <= 0) {
-		/* our job here is done, don't schedule any new DMA transfer */
-		info->tr_running = 0;
-
-#if defined(CONFIG_ETRAX_RS485) && defined(CONFIG_ETRAX_FAST_TIMER)
-		if (info->rs485.enabled) {
-			/* Set a short timer to toggle RTS */
-			start_one_shot_timer(&fast_timers_rs485[info->line],
-			                     rs485_toggle_rts_timer_function,
-			                     (unsigned long)info,
-			                     info->char_time_usec*2,
-			                     "RS-485");
-		}
-#endif /* RS485 */
-		return;
-	}
-
-	/* ok we can schedule a dma send of c chars starting at info->xmit.tail */
-	/* set up the descriptor correctly for output */
-	DFLOW(DEBUG_LOG(info->line, "TX %i\n", c));
-	descr->ctrl = d_int | d_eol | d_wait; /* Wait needed for tty_wait_until_sent() */
-	descr->sw_len = c;
-	descr->buf = virt_to_phys(info->xmit.buf + info->xmit.tail);
-	descr->status = 0;
-
-	*info->ofirstadr = virt_to_phys(descr); /* write to R_DMAx_FIRST */
-	*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, start);
-	
-	/* DMA is now running (hopefully) */
-} /* transmit_chars_dma */
-
-static void 
-start_transmit(struct e100_serial *info)
-{
-#if 0
-	if (info->line == SERIAL_DEBUG_LINE)
-		printk("x\n");
-#endif
-
-	info->tr_descr.sw_len = 0;
-	info->tr_descr.hw_len = 0;
-	info->tr_descr.status = 0;
-	info->tr_running = 1;
-	if (info->uses_dma_out)
-		transmit_chars_dma(info);
-	else
-		e100_enable_serial_tx_ready_irq(info);
-} /* start_transmit */
-
-#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
-static int serial_fast_timer_started = 0;
-static int serial_fast_timer_expired = 0;
-static void flush_timeout_function(unsigned long data);
-#define START_FLUSH_FAST_TIMER_TIME(info, string, usec) {\
-  unsigned long timer_flags; \
-  save_flags(timer_flags); \
-  cli(); \
-  if (fast_timers[info->line].function == NULL) { \
-    serial_fast_timer_started++; \
-    TIMERD(DEBUG_LOG(info->line, "start_timer %i ", info->line)); \
-    TIMERD(DEBUG_LOG(info->line, "num started: %i\n", serial_fast_timer_started)); \
-    start_one_shot_timer(&fast_timers[info->line], \
-                         flush_timeout_function, \
-                         (unsigned long)info, \
-                         (usec), \
-                         string); \
-  } \
-  else { \
-    TIMERD(DEBUG_LOG(info->line, "timer %i already running\n", info->line)); \
-  } \
-  restore_flags(timer_flags); \
-}
-#define START_FLUSH_FAST_TIMER(info, string) START_FLUSH_FAST_TIMER_TIME(info, string, info->flush_time_usec)
-
-#else
-#define START_FLUSH_FAST_TIMER_TIME(info, string, usec)
-#define START_FLUSH_FAST_TIMER(info, string)
-#endif
-
-static struct etrax_recv_buffer *
-alloc_recv_buffer(unsigned int size)
-{
-	struct etrax_recv_buffer *buffer;
-
-	if (!(buffer = kmalloc(sizeof *buffer + size, GFP_ATOMIC)))
-		return NULL;
-
-	buffer->next = NULL;
-	buffer->length = 0;
-	buffer->error = TTY_NORMAL;
-
-	return buffer;
-}
-
-static void
-append_recv_buffer(struct e100_serial *info, struct etrax_recv_buffer *buffer)
-{
-	unsigned long flags;
-
-	save_flags(flags);
-	cli();
-
-	if (!info->first_recv_buffer)
-		info->first_recv_buffer = buffer;
-	else
-		info->last_recv_buffer->next = buffer;
-
-	info->last_recv_buffer = buffer;
-
-	info->recv_cnt += buffer->length;
-	if (info->recv_cnt > info->max_recv_cnt)
-		info->max_recv_cnt = info->recv_cnt;
-
-	restore_flags(flags);
-}
-
-static int
-add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char flag)
-{
-	struct etrax_recv_buffer *buffer;
-	if (info->uses_dma_in) {
-		if (!(buffer = alloc_recv_buffer(4)))
-			return 0;
-
-		buffer->length = 1;
-		buffer->error = flag;
-		buffer->buffer[0] = data;
-	
-		append_recv_buffer(info, buffer);
-
-		info->icount.rx++;
-	} else {
-		struct tty_struct *tty = info->tty;
-		*tty->flip.char_buf_ptr = data;
-		*tty->flip.flag_buf_ptr = flag;
-		tty->flip.flag_buf_ptr++;
-		tty->flip.char_buf_ptr++;
-		tty->flip.count++;
-		info->icount.rx++;
-	}
-
-	return 1;
-}
-
-extern _INLINE_ unsigned int
-handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsigned int recvl)
-{
-	struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer;
-
-	if (info->recv_cnt + recvl > 65536) {
-		printk(KERN_CRIT
-		       "%s: Too much pending incoming serial data! Dropping %u bytes.\n", __FUNCTION__, recvl);
-		return 0;
-	}
-
-	buffer->length = recvl;
-
-	if (info->errorcode == ERRCODE_SET_BREAK)
-		buffer->error = TTY_BREAK;
-	info->errorcode = 0;
-
-	append_recv_buffer(info, buffer);
-
-	if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE)))
-		panic("%s: Failed to allocate memory for receive buffer!\n", __FUNCTION__);
-
-	descr->buf = virt_to_phys(buffer->buffer);
-	
-	return recvl;
-}
-
-static _INLINE_ unsigned int
-handle_all_descr_data(struct e100_serial *info)
-{
-	struct etrax_dma_descr *descr;
-	unsigned int recvl;
-	unsigned int ret = 0;
-
-	while (1)
-	{
-		descr = &info->rec_descr[info->cur_rec_descr];
-
-		if (descr == phys_to_virt(*info->idescradr))
-			break;
-
-		if (++info->cur_rec_descr == SERIAL_RECV_DESCRIPTORS)
-			info->cur_rec_descr = 0;
-	
-		/* find out how many bytes were read */
-
-		/* if the eop bit was not set, all data has been received */
-		if (!(descr->status & d_eop)) {
-			recvl = descr->sw_len;
-		} else {
-			/* otherwise we find the amount of data received here */
-			recvl = descr->hw_len;
-		}
-
-		/* Reset the status information */
-		descr->status = 0;
-
-		DFLOW(  DEBUG_LOG(info->line, "RX %lu\n", recvl);
-			if (info->tty->stopped) {
-				unsigned char *buf = phys_to_virt(descr->buf);
-				DEBUG_LOG(info->line, "rx 0x%02X\n", buf[0]);
-				DEBUG_LOG(info->line, "rx 0x%02X\n", buf[1]);
-				DEBUG_LOG(info->line, "rx 0x%02X\n", buf[2]);
-			}
-			);
-
-		/* update stats */
-		info->icount.rx += recvl;
-
-		ret += handle_descr_data(info, descr, recvl);
-	}
-
-	return ret;
-}
-
-static _INLINE_ void 
-receive_chars_dma(struct e100_serial *info)
-{
-	struct tty_struct *tty;
-	unsigned char rstat;
-
-#ifdef CONFIG_SVINTO_SIM
-	/* No receive in the simulator.  Will probably be when the rest of
-	 * the serial interface works, and this piece will just be removed.
-	 */
-	return;
-#endif
-
-	/* Acknowledge both dma_descr and dma_eop irq in R_DMA_CHx_CLR_INTR */
-	*info->iclrintradr =
-		IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
-		IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
-
-	tty = info->tty;
-	if (!tty) /* Something wrong... */
-		return;
-
-#ifdef SERIAL_HANDLE_EARLY_ERRORS
-	if (info->uses_dma_in)
-		e100_enable_serial_data_irq(info);
-#endif	
-
-	if (info->errorcode == ERRCODE_INSERT_BREAK)
-		add_char_and_flag(info, '\0', TTY_BREAK);
-
-	handle_all_descr_data(info);
-
-	/* Read the status register to detect errors */
-	rstat = info->port[REG_STATUS];
-	if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
-		DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat));
-	}
-
-	if (rstat & SER_ERROR_MASK) {
-		/* If we got an error, we must reset it by reading the
-		 * data_in field
-		 */
-		unsigned char data = info->port[REG_DATA];
-
-		PROCSTAT(ser_stat[info->line].errors_cnt++);
-		DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n",
-			  ((rstat & SER_ERROR_MASK) << 8) | data);
-
-		if (rstat & SER_PAR_ERR_MASK)
-			add_char_and_flag(info, data, TTY_PARITY);
-		else if (rstat & SER_OVERRUN_MASK)
-			add_char_and_flag(info, data, TTY_OVERRUN);
-		else if (rstat & SER_FRAMING_ERR_MASK)
-			add_char_and_flag(info, data, TTY_FRAME);
-	}
-
-	START_FLUSH_FAST_TIMER(info, "receive_chars");
-
-	/* Restart the receiving DMA */
-	*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart);
-}
-
-static _INLINE_ int
-start_recv_dma(struct e100_serial *info)
-{
-	struct etrax_dma_descr *descr = info->rec_descr;
-	struct etrax_recv_buffer *buffer;
-        int i;
-
-	/* Set up the receiving descriptors */
-	for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++) {
-		if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE)))
-			panic("%s: Failed to allocate memory for receive buffer!\n", __FUNCTION__);
-
-		descr[i].ctrl = d_int;
-		descr[i].buf = virt_to_phys(buffer->buffer);
-		descr[i].sw_len = SERIAL_DESCR_BUF_SIZE;
-		descr[i].hw_len = 0;
-		descr[i].status = 0;
-		descr[i].next = virt_to_phys(&descr[i+1]);
-	}
-
-	/* Link the last descriptor to the first */
-	descr[i-1].next = virt_to_phys(&descr[0]);
-
-	/* Start with the first descriptor in the list */
-	info->cur_rec_descr = 0;
-
-	/* Start the DMA */
-	*info->ifirstadr = virt_to_phys(&descr[info->cur_rec_descr]);
-	*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, start);
-
-	/* Input DMA should be running now */
-	return 1;
-}
-
-static void 
-start_receive(struct e100_serial *info)
-{
-#ifdef CONFIG_SVINTO_SIM
-	/* No receive in the simulator.  Will probably be when the rest of
-	 * the serial interface works, and this piece will just be removed.
-	 */
-	return;
-#endif
-	info->tty->flip.count = 0;
-	if (info->uses_dma_in) {
-		/* reset the input dma channel to be sure it works */
-
-		*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
-		while (IO_EXTRACT(R_DMA_CH6_CMD, cmd, *info->icmdadr) ==
-		       IO_STATE_VALUE(R_DMA_CH6_CMD, cmd, reset));
-
-		start_recv_dma(info);
-	}
-}
-
-
-static _INLINE_ void 
-status_handle(struct e100_serial *info, unsigned short status)
-{
-}
-
-/* the bits in the MASK2 register are laid out like this:
-   DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR
-   where I is the input channel and O is the output channel for the port.
-   info->irq is the bit number for the DMAO_DESCR so to check the others we
-   shift info->irq to the left.
-*/
-
-/* dma output channel interrupt handler
-   this interrupt is called from DMA2(ser2), DMA4(ser3), DMA6(ser0) or
-   DMA8(ser1) when they have finished a descriptor with the intr flag set.
-*/
-
-static irqreturn_t
-tr_interrupt(int irq, void *dev_id, struct pt_regs * regs)
-{
-	struct e100_serial *info;
-	unsigned long ireg;
-	int i;
-	int handled = 0;
-        
-#ifdef CONFIG_SVINTO_SIM
-	/* No receive in the simulator.  Will probably be when the rest of
-	 * the serial interface works, and this piece will just be removed.
-	 */
-	{
-		const char *s = "What? tr_interrupt in simulator??\n";
-		SIMCOUT(s,strlen(s));
-	}
-	return IRQ_HANDLED;
-#endif
-	
-	/* find out the line that caused this irq and get it from rs_table */
-	
-	ireg = *R_IRQ_MASK2_RD;  /* get the active irq bits for the dma channels */
-	
-	for (i = 0; i < NR_PORTS; i++) {
-		info = rs_table + i;
-		if (!info->enabled || !info->uses_dma_out)
-			continue; 
-		/* check for dma_descr (don't need to check for dma_eop in output dma for serial */
-		if (ireg & info->irq) {  
-			handled = 1;
-			/* we can send a new dma bunch. make it so. */
-			DINTR2(DEBUG_LOG(info->line, "tr_interrupt %i\n", i));
-			/* Read jiffies_usec first, 
-			 * we want this time to be as late as possible
-			 */
- 			PROCSTAT(ser_stat[info->line].tx_dma_ints++);
-			info->last_tx_active_usec = GET_JIFFIES_USEC();
-			info->last_tx_active = jiffies;
-			transmit_chars_dma(info);
-		}
-		
-		/* FIXME: here we should really check for a change in the
-		   status lines and if so call status_handle(info) */
-	}
-	return IRQ_RETVAL(handled);
-} /* tr_interrupt */
-
-/* dma input channel interrupt handler */
-
-static irqreturn_t
-rec_interrupt(int irq, void *dev_id, struct pt_regs * regs)
-{
-	struct e100_serial *info;
-	unsigned long ireg;
-	int i;
-	int handled = 0;
-
-#ifdef CONFIG_SVINTO_SIM
-	/* No receive in the simulator.  Will probably be when the rest of
-	 * the serial interface works, and this piece will just be removed.
-	 */
-	{
-		const char *s = "What? rec_interrupt in simulator??\n";
-		SIMCOUT(s,strlen(s));
-	}
-	return IRQ_HANDLED;
-#endif
-	
-	/* find out the line that caused this irq and get it from rs_table */
-	
-	ireg = *R_IRQ_MASK2_RD;  /* get the active irq bits for the dma channels */
-	
-	for (i = 0; i < NR_PORTS; i++) {
-		info = rs_table + i;
-		if (!info->enabled || !info->uses_dma_in)
-			continue; 
-		/* check for both dma_eop and dma_descr for the input dma channel */
-		if (ireg & ((info->irq << 2) | (info->irq << 3))) {
-			handled = 1; 
-			/* we have received something */
-			receive_chars_dma(info);
-		}
-		
-		/* FIXME: here we should really check for a change in the
-		   status lines and if so call status_handle(info) */
-	}
-	return IRQ_RETVAL(handled);
-} /* rec_interrupt */
-
-static _INLINE_ int
-force_eop_if_needed(struct e100_serial *info)
-{
-	/* We check data_avail bit to determine if data has 
-	 * arrived since last time
-	 */ 
-	unsigned char rstat = info->port[REG_STATUS];
-
-	/* error or datavail? */
-	if (rstat & SER_ERROR_MASK) { 
-		/* Some error has occurred. If there has been valid data, an
-		 * EOP interrupt will be made automatically. If no data, the
-		 * normal ser_interrupt should be enabled and handle it.
-		 * So do nothing!
-		 */
-		DEBUG_LOG(info->line, "timeout err: rstat 0x%03X\n",
-		          rstat | (info->line << 8));
-		return 0;
-	}
-
-	if (rstat & SER_DATA_AVAIL_MASK) { 
-		/* Ok data, no error, count it */
-		TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n",
-		          rstat | (info->line << 8)));
-		/* Read data to clear status flags */
-		(void)info->port[REG_DATA];
-
-		info->forced_eop = 0;
-		START_FLUSH_FAST_TIMER(info, "magic");
-		return 0;
-	}
-
-	/* hit the timeout, force an EOP for the input
-	 * dma channel if we haven't already
-	 */
-	if (!info->forced_eop) {
-		info->forced_eop = 1;
-		PROCSTAT(ser_stat[info->line].timeout_flush_cnt++);
-		TIMERD(DEBUG_LOG(info->line, "timeout EOP %i\n", info->line));
-		FORCE_EOP(info);
-	}
-
-	return 1;
-}
-
-extern _INLINE_ void
-flush_to_flip_buffer(struct e100_serial *info)
-{
-	struct tty_struct *tty;
-	struct etrax_recv_buffer *buffer;
-	unsigned int length;
-	unsigned long flags;
-	int max_flip_size;
-
-	if (!info->first_recv_buffer)
-		return;
-
-	save_flags(flags);
-	cli();
-
-	if (!(tty = info->tty)) {
-		restore_flags(flags);
-		return;
-	}
-
-	length = tty->flip.count;
-	/* Don't flip more than the ldisc has room for.
-	 * The return value from ldisc.receive_room(tty) - might not be up to
-	 * date, the previous flip of up to TTY_FLIPBUF_SIZE might be on the
-	 * processed and not accounted for yet.
-	 * Since we use DMA, 1 SERIAL_DESCR_BUF_SIZE could be on the way.
-	 * Lets buffer data here and let flow control take care of it.
-	 * Since we normally flip large chunks, the ldisc don't react
-	 * with throttle until too late if we flip to much.
-	 */
-	max_flip_size = tty->ldisc.receive_room(tty);
-	if (max_flip_size < 0)
-		max_flip_size = 0;
-	if (max_flip_size <= (TTY_FLIPBUF_SIZE +         /* Maybe not accounted for */
-			      length + info->recv_cnt +  /* We have this queued */
-			      2*SERIAL_DESCR_BUF_SIZE +    /* This could be on the way */
-			      TTY_THRESHOLD_THROTTLE)) { /* Some slack */
-		/* check TTY_THROTTLED first so it indicates our state */
-		if (!test_and_set_bit(TTY_THROTTLED, &tty->flags)) {
-			DFLOW(DEBUG_LOG(info->line,"flush_to_flip throttles room %lu\n", max_flip_size));
-			rs_throttle(tty);
-		}
-#if 0
-		else if (max_flip_size <= (TTY_FLIPBUF_SIZE +         /* Maybe not accounted for */
-					   length + info->recv_cnt +  /* We have this queued */
-					   SERIAL_DESCR_BUF_SIZE +    /* This could be on the way */
-					   TTY_THRESHOLD_THROTTLE)) { /* Some slack */
-			DFLOW(DEBUG_LOG(info->line,"flush_to_flip throttles again! %lu\n", max_flip_size));
-			rs_throttle(tty);
-		}
-#endif
-	}
-
-	if (max_flip_size > TTY_FLIPBUF_SIZE)
-		max_flip_size = TTY_FLIPBUF_SIZE;
-
-	while ((buffer = info->first_recv_buffer) && length < max_flip_size) {
-		unsigned int count = buffer->length;
-
-		if (length + count > max_flip_size)
-			count = max_flip_size - length;
-
-		memcpy(tty->flip.char_buf_ptr + length, buffer->buffer, count);
-		memset(tty->flip.flag_buf_ptr + length, TTY_NORMAL, count);
-		tty->flip.flag_buf_ptr[length] = buffer->error;
-
-		length += count;
-		info->recv_cnt -= count;
-		DFLIP(DEBUG_LOG(info->line,"flip: %i\n", length));
-
-		if (count == buffer->length) {
-			info->first_recv_buffer = buffer->next;
-			kfree(buffer);
-		} else {
-			buffer->length -= count;
-			memmove(buffer->buffer, buffer->buffer + count, buffer->length);
-			buffer->error = TTY_NORMAL;
-		}
-	}
-
-	if (!info->first_recv_buffer)
-		info->last_recv_buffer = NULL;
-
-	tty->flip.count = length;
-	DFLIP(if (tty->ldisc.chars_in_buffer(tty) > 3500) {
-		DEBUG_LOG(info->line, "ldisc %lu\n",
-			  tty->ldisc.chars_in_buffer(tty));
-		DEBUG_LOG(info->line, "flip.count %lu\n",
-			  tty->flip.count);
-	      }
-	      );
-	restore_flags(flags);
-
-	DFLIP(
-	  if (1) {
-
-		  if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
-			  DEBUG_LOG(info->line, "*** TTY_DONT_FLIP set flip.count %i ***\n", tty->flip.count);
-			  DEBUG_LOG(info->line, "*** recv_cnt %i\n", info->recv_cnt);
-		  } else {
-		  }
-		  DEBUG_LOG(info->line, "*** rxtot %i\n", info->icount.rx);
-		  DEBUG_LOG(info->line, "ldisc %lu\n", tty->ldisc.chars_in_buffer(tty));
-		  DEBUG_LOG(info->line, "room  %lu\n", tty->ldisc.receive_room(tty));
-	  }
-
-	);
-
-	/* this includes a check for low-latency */
-	tty_flip_buffer_push(tty);
-}
-
-static _INLINE_ void
-check_flush_timeout(struct e100_serial *info)
-{
-	/* Flip what we've got (if we can) */
-	flush_to_flip_buffer(info);
-
-	/* We might need to flip later, but not to fast
-	 * since the system is busy processing input... */
-	if (info->first_recv_buffer)
-		START_FLUSH_FAST_TIMER_TIME(info, "flip", 2000);
-
-	/* Force eop last, since data might have come while we're processing
-	 * and if we started the slow timer above, we won't start a fast
-	 * below.
-	 */
-	force_eop_if_needed(info);
-}
-
-#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
-static void flush_timeout_function(unsigned long data)
-{
-	struct e100_serial *info = (struct e100_serial *)data;
-
-	fast_timers[info->line].function = NULL;
-	serial_fast_timer_expired++;
-	TIMERD(DEBUG_LOG(info->line, "flush_timout %i ", info->line));
-	TIMERD(DEBUG_LOG(info->line, "num expired: %i\n", serial_fast_timer_expired));
-	check_flush_timeout(info);
-}
-
-#else
-
-/* dma fifo/buffer timeout handler
-   forces an end-of-packet for the dma input channel if no chars 
-   have been received for CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS/100 s.
-*/
-
-static struct timer_list flush_timer;
-
-static void 
-timed_flush_handler(unsigned long ptr)
-{
-	struct e100_serial *info;
-	int i;
-
-#ifdef CONFIG_SVINTO_SIM
-	return;
-#endif
-	
-	for (i = 0; i < NR_PORTS; i++) {
-		info = rs_table + i;
-		if (info->uses_dma_in)
-			check_flush_timeout(info);
-	}
-
-	/* restart flush timer */
-	mod_timer(&flush_timer, jiffies + CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS);
-}
-#endif
-
-#ifdef SERIAL_HANDLE_EARLY_ERRORS
-
-/* If there is an error (ie break) when the DMA is running and
- * there are no bytes in the fifo the DMA is stopped and we get no
- * eop interrupt. Thus we have to monitor the first bytes on a DMA
- * transfer, and if it is without error we can turn the serial
- * interrupts off.
- */
-
-/*
-BREAK handling on ETRAX 100:
-ETRAX will generate interrupt although there is no stop bit between the
-characters.
-
-Depending on how long the break sequence is, the end of the breaksequence
-will look differently:
-| indicates start/end of a character.
-
-B= Break character (0x00) with framing error.
-E= Error byte with parity error received after B characters.
-F= "Faked" valid byte received immediately after B characters.
-V= Valid byte
-
-1.
-    B          BL         ___________________________ V
-.._|__________|__________|                           |valid data |
-
-Multiple frame errors with data == 0x00 (B),
-the timing matches up "perfectly" so no extra ending char is detected.
-The RXD pin is 1 in the last interrupt, in that case
-we set info->errorcode = ERRCODE_INSERT_BREAK, but we can't really
-know if another byte will come and this really is case 2. below 
-(e.g F=0xFF or 0xFE)
-If RXD pin is 0 we can expect another character (see 2. below).
-
-
-2.
-
-    B          B          E or F__________________..__ V
-.._|__________|__________|______    |                 |valid data
-                          "valid" or 
-                          parity error
-
-Multiple frame errors with data == 0x00 (B),
-but the part of the break trigs is interpreted as a start bit (and possibly
-some 0 bits followed by a number of 1 bits and a stop bit).
-Depending on parity settings etc. this last character can be either
-a fake "valid" char (F) or have a parity error (E).
-
-If the character is valid it will be put in the buffer,
-we set info->errorcode = ERRCODE_SET_BREAK so the receive interrupt
-will set the flags so the tty will handle it,
-if it's an error byte it will not be put in the buffer
-and we set info->errorcode = ERRCODE_INSERT_BREAK.
-
-To distinguish a V byte in 1. from an F byte in 2. we keep a timestamp
-of the last faulty char (B) and compares it with the current time:
-If the time elapsed time is less then 2*char_time_usec we will assume
-it's a faked F char and not a Valid char and set 
-info->errorcode = ERRCODE_SET_BREAK. 
-
-Flaws in the above solution:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-We use the timer to distinguish a F character from a V character,
-if a V character is to close after the break we might make the wrong decision.
-
-TODO: The break will be delayed until an F or V character is received.
-
-*/
-
-extern _INLINE_
-struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
-{
-	unsigned long data_read;
-	struct tty_struct *tty = info->tty;
-
-	if (!tty) {
-		printk("!NO TTY!\n");
-		return info;
-	}
-	if (tty->flip.count >= TTY_FLIPBUF_SIZE - TTY_THRESHOLD_THROTTLE) {
-		/* check TTY_THROTTLED first so it indicates our state */
-		if (!test_and_set_bit(TTY_THROTTLED, &tty->flags)) {
-			DFLOW(DEBUG_LOG(info->line, "rs_throttle flip.count: %i\n", tty->flip.count));
-			rs_throttle(tty);
-		}
-	}
-	if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-		DEBUG_LOG(info->line, "force FLIP! %i\n", tty->flip.count);
-		tty->flip.work.func((void *) tty);
-		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-			DEBUG_LOG(info->line, "FLIP FULL! %i\n", tty->flip.count);
-			return info;		/* if TTY_DONT_FLIP is set */
-		}
-	}
-	/* Read data and status at the same time */
-	data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]);
-more_data:
-	if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) {
-		DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
-	}
-	DINTR2(DEBUG_LOG(info->line, "ser_rx   %c\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read)));
-
-	if (data_read & ( IO_MASK(R_SERIAL0_READ, framing_err) |
-			  IO_MASK(R_SERIAL0_READ, par_err) |
-			  IO_MASK(R_SERIAL0_READ, overrun) )) {
-		/* An error */
-		info->last_rx_active_usec = GET_JIFFIES_USEC();
-		info->last_rx_active = jiffies;
-		DINTR1(DEBUG_LOG(info->line, "ser_rx err stat_data %04X\n", data_read));
-		DLOG_INT_TRIG(
-		if (!log_int_trig1_pos) {
-			log_int_trig1_pos = log_int_pos;
-			log_int(rdpc(), 0, 0);
-		}
-		);
-
-
-		if ( ((data_read & IO_MASK(R_SERIAL0_READ, data_in)) == 0) &&
-		     (data_read & IO_MASK(R_SERIAL0_READ, framing_err)) ) {
-			/* Most likely a break, but we get interrupts over and
-			 * over again.
-			 */
-
-			if (!info->break_detected_cnt) {
-				DEBUG_LOG(info->line, "#BRK start\n", 0);
-			}
-			if (data_read & IO_MASK(R_SERIAL0_READ, rxd)) {
-				/* The RX pin is high now, so the break
-				 * must be over, but....
-				 * we can't really know if we will get another
-				 * last byte ending the break or not.
-				 * And we don't know if the byte (if any) will
-				 * have an error or look valid.
-				 */
-				DEBUG_LOG(info->line, "# BL BRK\n", 0);
-				info->errorcode = ERRCODE_INSERT_BREAK;
-			}
-			info->break_detected_cnt++;
-		} else {
-			/* The error does not look like a break, but could be
-			 * the end of one
-			 */
-			if (info->break_detected_cnt) {
-				DEBUG_LOG(info->line, "EBRK %i\n", info->break_detected_cnt);
-				info->errorcode = ERRCODE_INSERT_BREAK;
-			} else {
-				if (info->errorcode == ERRCODE_INSERT_BREAK) {
-					info->icount.brk++;
-					*tty->flip.char_buf_ptr = 0;
-					*tty->flip.flag_buf_ptr = TTY_BREAK;
-					tty->flip.flag_buf_ptr++;
-					tty->flip.char_buf_ptr++;
-					tty->flip.count++;
-					info->icount.rx++;
-				}
-				*tty->flip.char_buf_ptr = IO_EXTRACT(R_SERIAL0_READ, data_in, data_read);
-
-				if (data_read & IO_MASK(R_SERIAL0_READ, par_err)) {
-					info->icount.parity++;
-					*tty->flip.flag_buf_ptr = TTY_PARITY;
-				} else if (data_read & IO_MASK(R_SERIAL0_READ, overrun)) {
-					info->icount.overrun++;
-					*tty->flip.flag_buf_ptr = TTY_OVERRUN;
-				} else if (data_read & IO_MASK(R_SERIAL0_READ, framing_err)) {
-					info->icount.frame++;
-					*tty->flip.flag_buf_ptr = TTY_FRAME;
-				}
-				info->errorcode = 0;
-			}
-			info->break_detected_cnt = 0;
-		}
-	} else if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) {
-		/* No error */
-		DLOG_INT_TRIG(
-		if (!log_int_trig1_pos) {
-			if (log_int_pos >= log_int_size) {
-				log_int_pos = 0;
-			}
-			log_int_trig0_pos = log_int_pos;
-			log_int(rdpc(), 0, 0);
-		}
-		);
-		*tty->flip.char_buf_ptr = IO_EXTRACT(R_SERIAL0_READ, data_in, data_read);
-		*tty->flip.flag_buf_ptr = 0;
-	} else {
-		DEBUG_LOG(info->line, "ser_rx int but no data_avail  %08lX\n", data_read);
-	}
-
-
-	tty->flip.flag_buf_ptr++;
-	tty->flip.char_buf_ptr++;
-	tty->flip.count++;
-	info->icount.rx++;
-	data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]);
-	if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) {
-		DEBUG_LOG(info->line, "ser_rx   %c in loop\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read));
-		goto more_data;
-	}
-
-	tty_flip_buffer_push(info->tty);
-	return info;
-}
-
-extern _INLINE_
-struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
-{
-	unsigned char rstat;
-
-#ifdef SERIAL_DEBUG_INTR
-	printk("Interrupt from serport %d\n", i);
-#endif
-/*	DEBUG_LOG(info->line, "ser_interrupt stat %03X\n", rstat | (i << 8)); */
-	if (!info->uses_dma_in) {
-		return handle_ser_rx_interrupt_no_dma(info);
-	}
-	/* DMA is used */
-	rstat = info->port[REG_STATUS];
-	if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
-		DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
-	}
-
-	if (rstat & SER_ERROR_MASK) {
-		unsigned char data;
-
-		info->last_rx_active_usec = GET_JIFFIES_USEC();
-		info->last_rx_active = jiffies;
-		/* If we got an error, we must reset it by reading the
-		 * data_in field
-		 */
-		data = info->port[REG_DATA];
-		DINTR1(DEBUG_LOG(info->line, "ser_rx!  %c\n", data));
-		DINTR1(DEBUG_LOG(info->line, "ser_rx err stat %02X\n", rstat));
-		if (!data && (rstat & SER_FRAMING_ERR_MASK)) {
-			/* Most likely a break, but we get interrupts over and
-			 * over again.
-			 */
-
-			if (!info->break_detected_cnt) {
-				DEBUG_LOG(info->line, "#BRK start\n", 0);
-			}
-			if (rstat & SER_RXD_MASK) {
-				/* The RX pin is high now, so the break
-				 * must be over, but....
-				 * we can't really know if we will get another
-				 * last byte ending the break or not. 
-				 * And we don't know if the byte (if any) will 
-				 * have an error or look valid.
-				 */
-				DEBUG_LOG(info->line, "# BL BRK\n", 0);
-				info->errorcode = ERRCODE_INSERT_BREAK;
-			}
-			info->break_detected_cnt++;
-		} else {
-			/* The error does not look like a break, but could be
-			 * the end of one
-			 */
-			if (info->break_detected_cnt) {
-				DEBUG_LOG(info->line, "EBRK %i\n", info->break_detected_cnt);
-				info->errorcode = ERRCODE_INSERT_BREAK;
-			} else {
-				if (info->errorcode == ERRCODE_INSERT_BREAK) {
-					info->icount.brk++;
-					add_char_and_flag(info, '\0', TTY_BREAK);
-				}
-
-				if (rstat & SER_PAR_ERR_MASK) {
-					info->icount.parity++;
-					add_char_and_flag(info, data, TTY_PARITY);
-				} else if (rstat & SER_OVERRUN_MASK) {
-					info->icount.overrun++;
-					add_char_and_flag(info, data, TTY_OVERRUN);
-				} else if (rstat & SER_FRAMING_ERR_MASK) {
-					info->icount.frame++;
-					add_char_and_flag(info, data, TTY_FRAME);
-				}
-
-				info->errorcode = 0;
-			}
-			info->break_detected_cnt = 0;
-			DEBUG_LOG(info->line, "#iERR s d %04X\n",
-			          ((rstat & SER_ERROR_MASK) << 8) | data);
-		}
-		PROCSTAT(ser_stat[info->line].early_errors_cnt++);
-	} else { /* It was a valid byte, now let the DMA do the rest */
-		unsigned long curr_time_u = GET_JIFFIES_USEC();
-		unsigned long curr_time = jiffies;
-		
-		if (info->break_detected_cnt) {
-			/* Detect if this character is a new valid char or the
-			 * last char in a break sequence: If LSBits are 0 and
-			 * MSBits are high AND the time is close to the
-			 * previous interrupt we should discard it.
-			 */
-			long elapsed_usec = 
-			  (curr_time - info->last_rx_active) * (1000000/HZ) + 
-			  curr_time_u - info->last_rx_active_usec;
-			if (elapsed_usec < 2*info->char_time_usec) {
-				DEBUG_LOG(info->line, "FBRK %i\n", info->line);
-				/* Report as BREAK (error) and let
-				 * receive_chars_dma() handle it
-				 */
-				info->errorcode = ERRCODE_SET_BREAK;
-			} else {
-				DEBUG_LOG(info->line, "Not end of BRK (V)%i\n", info->line);
-			}
-			DEBUG_LOG(info->line, "num brk %i\n", info->break_detected_cnt);
-		}
-
-#ifdef SERIAL_DEBUG_INTR
-		printk("** OK, disabling ser_interrupts\n");
-#endif
-		e100_disable_serial_data_irq(info);
-		DINTR2(DEBUG_LOG(info->line, "ser_rx OK %d\n", info->line));
-		info->break_detected_cnt = 0;
-
-		PROCSTAT(ser_stat[info->line].ser_ints_ok_cnt++);
-	}
-	/* Restarting the DMA never hurts */
-	*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart);
-	START_FLUSH_FAST_TIMER(info, "ser_int");
-	return info;
-} /* handle_ser_rx_interrupt */
-
-extern _INLINE_ void handle_ser_tx_interrupt(struct e100_serial *info)
-{
-	unsigned long flags;
-
-	if (info->x_char) {
-		unsigned char rstat;
-		DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char));
-		save_flags(flags); cli();
-		rstat = info->port[REG_STATUS];
-		DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
-
-		info->port[REG_TR_DATA] = info->x_char;
-		info->icount.tx++;
-		info->x_char = 0;
-		/* We must enable since it is disabled in ser_interrupt */
-		e100_enable_serial_tx_ready_irq(info);
-		restore_flags(flags);
-		return;
-	}
-	if (info->uses_dma_out) {
-		unsigned char rstat;
-		int i;
-		/* We only use normal tx interrupt when sending x_char */
-		DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0));
-		save_flags(flags); cli();
-		rstat = info->port[REG_STATUS];
-		DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
-		e100_disable_serial_tx_ready_irq(info);
-		if (info->tty->stopped)
-			rs_stop(info->tty);
-		/* Enable the DMA channel and tell it to continue */
-		e100_enable_txdma_channel(info);
-		/* Wait 12 cycles before doing the DMA command */
-		for(i = 6;  i > 0; i--)
-			nop();
-
-		*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, continue);
-		restore_flags(flags);
-		return;
-	}
-	/* Normal char-by-char interrupt */
-	if (info->xmit.head == info->xmit.tail
-	    || info->tty->stopped
-	    || info->tty->hw_stopped) {
-		DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n", info->tty->stopped));
-		e100_disable_serial_tx_ready_irq(info);
-		info->tr_running = 0;
-		return;
-	}
-	DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail]));
-	/* Send a byte, rs485 timing is critical so turn of ints */
-	save_flags(flags); cli();
-	info->port[REG_TR_DATA] = info->xmit.buf[info->xmit.tail];
-	info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1);
-	info->icount.tx++;
-	if (info->xmit.head == info->xmit.tail) {
-#if defined(CONFIG_ETRAX_RS485) && defined(CONFIG_ETRAX_FAST_TIMER)
-		if (info->rs485.enabled) {
-			/* Set a short timer to toggle RTS */
-			start_one_shot_timer(&fast_timers_rs485[info->line],
-			                     rs485_toggle_rts_timer_function,
-			                     (unsigned long)info,
-			                     info->char_time_usec*2,
-			                     "RS-485");
-		}
-#endif /* RS485 */
-		info->last_tx_active_usec = GET_JIFFIES_USEC();
-		info->last_tx_active = jiffies;
-		e100_disable_serial_tx_ready_irq(info);
-		info->tr_running = 0;
-		DFLOW(DEBUG_LOG(info->line, "tx_int: stop2\n", 0));
-	} else {
-		/* We must enable since it is disabled in ser_interrupt */
-		e100_enable_serial_tx_ready_irq(info);
-	}
-	restore_flags(flags);
-
-	if (CIRC_CNT(info->xmit.head,
-		     info->xmit.tail,
-		     SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
-		rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
-
-} /* handle_ser_tx_interrupt */
-
-/* result of time measurements:
- * RX duration 54-60 us when doing something, otherwise 6-9 us
- * ser_int duration: just sending: 8-15 us normally, up to 73 us
- */
-static irqreturn_t
-ser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-	static volatile int tx_started = 0;
-	struct e100_serial *info;
-	int i;
-	unsigned long flags;
-	unsigned long irq_mask1_rd;
-	unsigned long data_mask = (1 << (8+2*0)); /* ser0 data_avail */
-	int handled = 0;
-	static volatile unsigned long reentered_ready_mask = 0;
-
-	save_flags(flags); cli();
-	irq_mask1_rd = *R_IRQ_MASK1_RD;
-	/* First handle all rx interrupts with ints disabled */
-	info = rs_table;
-	irq_mask1_rd &= e100_ser_int_mask;
-	for (i = 0; i < NR_PORTS; i++) {
-		/* Which line caused the data irq? */
-		if (irq_mask1_rd & data_mask) {
-			handled = 1;
-			handle_ser_rx_interrupt(info);
-		}
-		info += 1;
-		data_mask <<= 2;
-	}
-	/* Handle tx interrupts with interrupts enabled so we
-	 * can take care of new data interrupts while transmitting
-	 * We protect the tx part with the tx_started flag.
-	 * We disable the tr_ready interrupts we are about to handle and
-	 * unblock the serial interrupt so new serial interrupts may come.
-	 *
-	 * If we get a new interrupt:
-	 *  - it migth be due to synchronous serial ports.
-	 *  - serial irq will be blocked by general irq handler.
-	 *  - async data will be handled above (sync will be ignored).
-	 *  - tx_started flag will prevent us from trying to send again and
-	 *    we will exit fast - no need to unblock serial irq.
-	 *  - Next (sync) serial interrupt handler will be runned with
-	 *    disabled interrupt due to restore_flags() at end of function,
-	 *    so sync handler will not be preempted or reentered.
-	 */
-	if (!tx_started) {
-		unsigned long ready_mask;
-		unsigned long
-		tx_started = 1;
-		/* Only the tr_ready interrupts left */
-		irq_mask1_rd &= (IO_MASK(R_IRQ_MASK1_RD, ser0_ready) |
-				 IO_MASK(R_IRQ_MASK1_RD, ser1_ready) |
-				 IO_MASK(R_IRQ_MASK1_RD, ser2_ready) |
-				 IO_MASK(R_IRQ_MASK1_RD, ser3_ready));
-		while (irq_mask1_rd) {
-			/* Disable those we are about to handle */
-			*R_IRQ_MASK1_CLR = irq_mask1_rd;
-			/* Unblock the serial interrupt */
-			*R_VECT_MASK_SET = IO_STATE(R_VECT_MASK_SET, serial, set);
-
-			sti();
-			ready_mask = (1 << (8+1+2*0)); /* ser0 tr_ready */
-			info = rs_table;
-			for (i = 0; i < NR_PORTS; i++) {
-				/* Which line caused the ready irq? */
-				if (irq_mask1_rd & ready_mask) {
-					handled = 1;
-					handle_ser_tx_interrupt(info);
-				}
-				info += 1;
-				ready_mask <<= 2;
-			}
-			/* handle_ser_tx_interrupt enables tr_ready interrupts */
-			cli();
-			/* Handle reentered TX interrupt */
-			irq_mask1_rd = reentered_ready_mask;
-		}
-		cli();
-		tx_started = 0;
-	} else {
-		unsigned long ready_mask;
-		ready_mask = irq_mask1_rd & (IO_MASK(R_IRQ_MASK1_RD, ser0_ready) |
-					     IO_MASK(R_IRQ_MASK1_RD, ser1_ready) |
-					     IO_MASK(R_IRQ_MASK1_RD, ser2_ready) |
-					     IO_MASK(R_IRQ_MASK1_RD, ser3_ready));
-		if (ready_mask) {
-			reentered_ready_mask |= ready_mask;
-			/* Disable those we are about to handle */
-			*R_IRQ_MASK1_CLR = ready_mask;
-			DFLOW(DEBUG_LOG(SERIAL_DEBUG_LINE, "ser_int reentered with TX %X\n", ready_mask));
-		}
-	}
-
-	restore_flags(flags);
-	return IRQ_RETVAL(handled);
-} /* ser_interrupt */
-#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_softint(void *private_)
-{
-	struct e100_serial	*info = (struct e100_serial *) 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);
-	}
-}
-
-static int 
-startup(struct e100_serial * info)
-{
-	unsigned long flags;
-	unsigned long xmit_page;
-	int i;
-
-	xmit_page = get_zeroed_page(GFP_KERNEL);
-	if (!xmit_page)
-		return -ENOMEM;
-
-	save_flags(flags); 
-	cli();
-
-	/* if it was already initialized, skip this */
-
-	if (info->flags & ASYNC_INITIALIZED) {
-		restore_flags(flags);
-		free_page(xmit_page);
-		return 0;
-	}
-
-	if (info->xmit.buf)
-		free_page(xmit_page);
-	else
-		info->xmit.buf = (unsigned char *) xmit_page;
-
-#ifdef SERIAL_DEBUG_OPEN
-	printk("starting up ttyS%d (xmit_buf 0x%p)...\n", info->line, info->xmit.buf);
-#endif
-
-#ifdef CONFIG_SVINTO_SIM
-	/* Bits and pieces collected from below.  Better to have them
-	   in one ifdef:ed clause than to mix in a lot of ifdefs,
-	   right? */
-	if (info->tty)
-		clear_bit(TTY_IO_ERROR, &info->tty->flags);
-
-	info->xmit.head = info->xmit.tail = 0;
-	info->first_recv_buffer = info->last_recv_buffer = NULL;
-	info->recv_cnt = info->max_recv_cnt = 0;
-
-	for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++)
-		info->rec_descr[i].buf = NULL;
-
-	/* No real action in the simulator, but may set info important
-	   to ioctl. */
-	change_speed(info);
-#else
-
-	/*
-	 * Clear the FIFO buffers and disable them
-	 * (they will be reenabled in change_speed())
-	 */
-
-	/*
-	 * Reset the DMA channels and make sure their interrupts are cleared
-	 */
-
-	if (info->dma_in_enabled) {
-		info->uses_dma_in = 1;
-		e100_enable_rxdma_channel(info);
-
-		*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
-
-		/* Wait until reset cycle is complete */
-		while (IO_EXTRACT(R_DMA_CH6_CMD, cmd, *info->icmdadr) ==
-		       IO_STATE_VALUE(R_DMA_CH6_CMD, cmd, reset));
-
-		/* Make sure the irqs are cleared */
-		*info->iclrintradr =
-			IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
-			IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
-	} else {
-		e100_disable_rxdma_channel(info);
-	}
-
-	if (info->dma_out_enabled) {
-		info->uses_dma_out = 1;
-		e100_enable_txdma_channel(info);
-		*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
-
-		while (IO_EXTRACT(R_DMA_CH6_CMD, cmd, *info->ocmdadr) ==
-		       IO_STATE_VALUE(R_DMA_CH6_CMD, cmd, reset));
-
-		/* Make sure the irqs are cleared */
-		*info->oclrintradr =
-			IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
-			IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
-	} else {
-		e100_disable_txdma_channel(info);
-	}
-
-	if (info->tty)
-		clear_bit(TTY_IO_ERROR, &info->tty->flags);
-
-	info->xmit.head = info->xmit.tail = 0;
-	info->first_recv_buffer = info->last_recv_buffer = NULL;
-	info->recv_cnt = info->max_recv_cnt = 0;
-	
-	for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++)
-		info->rec_descr[i].buf = 0;
-
-	/*
-	 * and set the speed and other flags of the serial port
-	 * this will start the rx/tx as well
-	 */
-#ifdef SERIAL_HANDLE_EARLY_ERRORS
-	e100_enable_serial_data_irq(info);
-#endif	
-	change_speed(info);
-
-	/* dummy read to reset any serial errors */
-
-	(void)info->port[REG_DATA];
-
-	/* enable the interrupts */
-	if (info->uses_dma_out)
-		e100_enable_txdma_irq(info);
-
-	e100_enable_rx_irq(info);
-
-	info->tr_running = 0; /* to be sure we don't lock up the transmitter */
-
-	/* setup the dma input descriptor and start dma */
-	
-	start_receive(info);
-	
-	/* for safety, make sure the descriptors last result is 0 bytes written */
-	
-	info->tr_descr.sw_len = 0;
-	info->tr_descr.hw_len = 0;
-	info->tr_descr.status = 0;
-
-	/* enable RTS/DTR last */
-
-	e100_rts(info, 1);
-	e100_dtr(info, 1);
-		
-#endif /* CONFIG_SVINTO_SIM */
-	
-	info->flags |= ASYNC_INITIALIZED;
-	
-	restore_flags(flags);
-	return 0;
-}
-
-/*
- * 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 e100_serial * info)
-{
-	unsigned long flags;
-	struct etrax_dma_descr *descr = info->rec_descr;
-	struct etrax_recv_buffer *buffer;
-	int i;
-
-#ifndef CONFIG_SVINTO_SIM	
-	/* shut down the transmitter and receiver */
-	DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line));
-	e100_disable_rx(info);
-	info->port[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40);
-
-	/* disable interrupts, reset dma channels */
-	if (info->uses_dma_in) {
-		e100_disable_rxdma_irq(info);
-		*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
-		info->uses_dma_in = 0;
-	} else {
-		e100_disable_serial_data_irq(info);
-	}
-
-	if (info->uses_dma_out) {
-		e100_disable_txdma_irq(info);
-		info->tr_running = 0;
-		*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
-		info->uses_dma_out = 0;
-	} else {
-		e100_disable_serial_tx_ready_irq(info);
-		info->tr_running = 0;
-	}
-
-#endif /* CONFIG_SVINTO_SIM */
-
-	if (!(info->flags & ASYNC_INITIALIZED))
-		return;
-	
-#ifdef SERIAL_DEBUG_OPEN
-	printk("Shutting down serial port %d (irq %d)....\n", info->line,
-	       info->irq);
-#endif
-	
-	save_flags(flags);
-	cli(); /* Disable interrupts */
-	
-	if (info->xmit.buf) {
-		free_page((unsigned long)info->xmit.buf);
-		info->xmit.buf = NULL;
-	}
-
-	for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++)
-		if (descr[i].buf) {
-			buffer = phys_to_virt(descr[i].buf) - sizeof *buffer;
-			kfree(buffer);
-			descr[i].buf = 0;
-		}
-
-	if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
-		/* hang up DTR and RTS if HUPCL is enabled */
-		e100_dtr(info, 0);
-		e100_rts(info, 0); /* could check CRTSCTS before doing this */
-	}
-
-	if (info->tty)
-		set_bit(TTY_IO_ERROR, &info->tty->flags);
-	
-	info->flags &= ~ASYNC_INITIALIZED;
-	restore_flags(flags);
-}
-
-
-/* change baud rate and other assorted parameters */
-
-static void 
-change_speed(struct e100_serial *info)
-{
-	unsigned int cflag;
-	unsigned long xoff;
-	unsigned long flags;
-	/* first some safety checks */
-	
-	if (!info->tty || !info->tty->termios)
-		return;
-	if (!info->port)
-		return;
-	
-	cflag = info->tty->termios->c_cflag;
-
-	/* possibly, the tx/rx should be disabled first to do this safely */
-	
-	/* change baud-rate and write it to the hardware */
-	if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) {
-		/* Special baudrate */
-		u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */
-		unsigned long alt_source =
-				IO_STATE(R_ALT_SER_BAUDRATE, ser0_rec, normal) |
-				IO_STATE(R_ALT_SER_BAUDRATE, ser0_tr, normal);
-		/* R_ALT_SER_BAUDRATE selects the source */
-		DBAUD(printk("Custom baudrate: baud_base/divisor %lu/%i\n",
-		       (unsigned long)info->baud_base, info->custom_divisor));
-		if (info->baud_base == SERIAL_PRESCALE_BASE) {
-			/* 0, 2-65535 (0=65536) */
-			u16 divisor = info->custom_divisor;
-			/* R_SERIAL_PRESCALE (upper 16 bits of R_CLOCK_PRESCALE) */
-			/* baudrate is 3.125MHz/custom_divisor */
-			alt_source =
-				IO_STATE(R_ALT_SER_BAUDRATE, ser0_rec, prescale) |
-				IO_STATE(R_ALT_SER_BAUDRATE, ser0_tr, prescale);
-			alt_source = 0x11;
-			DBAUD(printk("Writing SERIAL_PRESCALE: divisor %i\n", divisor));
-			*R_SERIAL_PRESCALE = divisor;
-			info->baud = SERIAL_PRESCALE_BASE/divisor;
-		}
-#ifdef CONFIG_ETRAX_EXTERN_PB6CLK_ENABLED
-		else if ((info->baud_base==CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8 &&
-			  info->custom_divisor == 1) ||
-			 (info->baud_base==CONFIG_ETRAX_EXTERN_PB6CLK_FREQ &&
-			  info->custom_divisor == 8)) {
-				/* ext_clk selected */
-				alt_source =
-					IO_STATE(R_ALT_SER_BAUDRATE, ser0_rec, extern) |
-					IO_STATE(R_ALT_SER_BAUDRATE, ser0_tr, extern);
-				DBAUD(printk("using external baudrate: %lu\n", CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8));
-				info->baud = CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8;
-			}
-		}
-#endif
-		else
-		{
-			/* Bad baudbase, we don't support using timer0
-			 * for baudrate.
-			 */
-			printk(KERN_WARNING "Bad baud_base/custom_divisor: %lu/%i\n",
-			       (unsigned long)info->baud_base, info->custom_divisor);
-		}
-		r_alt_ser_baudrate_shadow &= ~mask;
-		r_alt_ser_baudrate_shadow |= (alt_source << (info->line*8));
-		*R_ALT_SER_BAUDRATE = r_alt_ser_baudrate_shadow;
-	} else {
-		/* Normal baudrate */
-		/* Make sure we use normal baudrate */
-		u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */
-		unsigned long alt_source =
-			IO_STATE(R_ALT_SER_BAUDRATE, ser0_rec, normal) |
-			IO_STATE(R_ALT_SER_BAUDRATE, ser0_tr, normal);
-		r_alt_ser_baudrate_shadow &= ~mask;
-		r_alt_ser_baudrate_shadow |= (alt_source << (info->line*8));
-#ifndef CONFIG_SVINTO_SIM
-		*R_ALT_SER_BAUDRATE = r_alt_ser_baudrate_shadow;
-#endif /* CONFIG_SVINTO_SIM */
-
-		info->baud = cflag_to_baud(cflag);
-#ifndef CONFIG_SVINTO_SIM
-		info->port[REG_BAUD] = cflag_to_etrax_baud(cflag);
-#endif /* CONFIG_SVINTO_SIM */
-	}
-	
-#ifndef CONFIG_SVINTO_SIM
-	/* start with default settings and then fill in changes */
-	save_flags(flags);
-	cli();
-	/* 8 bit, no/even parity */
-	info->rx_ctrl &= ~(IO_MASK(R_SERIAL0_REC_CTRL, rec_bitnr) |
-			   IO_MASK(R_SERIAL0_REC_CTRL, rec_par_en) |
-			   IO_MASK(R_SERIAL0_REC_CTRL, rec_par));
-
-	/* 8 bit, no/even parity, 1 stop bit, no cts */
-	info->tx_ctrl &= ~(IO_MASK(R_SERIAL0_TR_CTRL, tr_bitnr) |
-			   IO_MASK(R_SERIAL0_TR_CTRL, tr_par_en) |
-			   IO_MASK(R_SERIAL0_TR_CTRL, tr_par) |
-			   IO_MASK(R_SERIAL0_TR_CTRL, stop_bits) |
-			   IO_MASK(R_SERIAL0_TR_CTRL, auto_cts));
-	
-	if ((cflag & CSIZE) == CS7) {
-		/* set 7 bit mode */
-		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_bitnr, tr_7bit);
-		info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_bitnr, rec_7bit);
-	}
-	
-	if (cflag & CSTOPB) {
-		/* set 2 stop bit mode */
-		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, stop_bits, two_bits);
-	}	  
-	
-	if (cflag & PARENB) {
-		/* enable parity */
-		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_par_en, enable);
-		info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_par_en, enable);
-	}
-	
-	if (cflag & CMSPAR) {
-		/* enable stick parity, PARODD mean Mark which matches ETRAX */
-		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_stick_par, stick);
-		info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_stick_par, stick);
-	}
-	if (cflag & PARODD) {
-		/* set odd parity (or Mark if CMSPAR) */
-		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_par, odd);
-		info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_par, odd);
-	}
-	
-	if (cflag & CRTSCTS) {
-		/* enable automatic CTS handling */
-		DFLOW(DEBUG_LOG(info->line, "FLOW auto_cts enabled\n", 0));
-		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, auto_cts, active);
-	}
-	
-	/* make sure the tx and rx are enabled */
-	
-	info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_enable, enable);
-	info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_enable, enable);
-
-	/* actually write the control regs to the hardware */
-	
-	info->port[REG_TR_CTRL] = info->tx_ctrl;
-	info->port[REG_REC_CTRL] = info->rx_ctrl;
-	xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->tty));
-	xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
-	if (info->tty->termios->c_iflag & IXON ) {
-		DFLOW(DEBUG_LOG(info->line, "FLOW XOFF enabled 0x%02X\n", STOP_CHAR(info->tty)));
-		xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
-	}
-	
-	*((unsigned long *)&info->port[REG_XOFF]) = xoff;
-	restore_flags(flags);
-#endif /* !CONFIG_SVINTO_SIM */
-
-	update_char_time(info);
-
-} /* change_speed */
-
-/* start transmitting chars NOW */
-
-static void 
-rs_flush_chars(struct tty_struct *tty)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-	unsigned long flags;
-
-	if (info->tr_running ||
-	    info->xmit.head == info->xmit.tail ||
-	    tty->stopped ||
-	    tty->hw_stopped ||
-	    !info->xmit.buf)
-		return;
-
-#ifdef SERIAL_DEBUG_FLOW
-	printk("rs_flush_chars\n");
-#endif
-	
-	/* this protection might not exactly be necessary here */
-	
-	save_flags(flags);
-	cli();
-	start_transmit(info);
-	restore_flags(flags);
-}
-
-extern _INLINE_ int
-rs_raw_write(struct tty_struct * tty, int from_user,
-	  const unsigned char *buf, int count)
-{
-	int	c, ret = 0;
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-	unsigned long flags;
-	
-	/* first some sanity checks */
-	
-	if (!tty || !info->xmit.buf || !tmp_buf)
-		return 0;
-	
-#ifdef SERIAL_DEBUG_DATA
-	if (info->line == SERIAL_DEBUG_LINE)
-		printk("rs_raw_write (%d), status %d\n",
-		       count, info->port[REG_STATUS]);
-#endif
-
-#ifdef CONFIG_SVINTO_SIM
-	/* Really simple.  The output is here and now. */
-	SIMCOUT(buf, count);
-	return count;
-#endif
-	save_flags(flags);
-	DFLOW(DEBUG_LOG(info->line, "write count %i ", count));
-	DFLOW(DEBUG_LOG(info->line, "ldisc %i\n", tty->ldisc.chars_in_buffer(tty)));
-
-	
-	/* the cli/restore_flags pairs below are needed because the
-	 * DMA interrupt handler moves the info->xmit values. the memcpy
-	 * needs to be in the critical region unfortunately, because we
-	 * need to read xmit values, memcpy, write xmit values in one
-	 * atomic operation... this could perhaps be avoided by more clever
-	 * design.
-	 */
-	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);
-	}
-	
-	/* enable transmitter if not running, unless the tty is stopped
-	 * this does not need IRQ protection since if tr_running == 0
-	 * the IRQ's are not running anyway for this port.
-	 */
-	DFLOW(DEBUG_LOG(info->line, "write ret %i\n", ret));
-	
-	if (info->xmit.head != info->xmit.tail &&
-	    !tty->stopped &&
-	    !tty->hw_stopped &&
-	    !info->tr_running) {
-		start_transmit(info);
-	}
- 	
-	return ret;
-} /* raw_raw_write() */
-
-static int 
-rs_write(struct tty_struct * tty, int from_user,
-	 const unsigned char *buf, int count)
-{
-#if defined(CONFIG_ETRAX_RS485)
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-
-	if (info->rs485.enabled)
-	{
-		/* If we are in RS-485 mode, we need to toggle RTS and disable
-		 * the receiver before initiating a DMA transfer
-		 */
-#ifdef CONFIG_ETRAX_FAST_TIMER
-		/* Abort any started timer */
-		fast_timers_rs485[info->line].function = NULL;
-		del_fast_timer(&fast_timers_rs485[info->line]);
-#endif
-		e100_rts(info, info->rs485.rts_on_send);
-#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
-		e100_disable_rx(info);
-		e100_enable_rx_irq(info);
-#endif
-
-		if (info->rs485.delay_rts_before_send > 0) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout((info->rs485.delay_rts_before_send * HZ)/1000);
-		}
-	}
-#endif /* CONFIG_ETRAX_RS485 */
-
-	count = rs_raw_write(tty, from_user, buf, count);
-
-#if defined(CONFIG_ETRAX_RS485)
-	if (info->rs485.enabled)
-	{
-		unsigned int val;
-		/* If we are in RS-485 mode the following has to be done:
-		 * wait until DMA is ready
-		 * wait on transmit shift register
-		 * toggle RTS
-		 * enable the receiver
-		 */	
-
-		/* Sleep until all sent */
-		tty_wait_until_sent(tty, 0);
-#ifdef CONFIG_ETRAX_FAST_TIMER
-		/* Now sleep a little more so that shift register is empty */
-		schedule_usleep(info->char_time_usec * 2);
-#endif
-		/* wait on transmit shift register */
-		do{
-			get_lsr_info(info, &val);
-		}while (!(val & TIOCSER_TEMT));
-
-		e100_rts(info, info->rs485.rts_after_sent);
-	
-#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
-		e100_enable_rx(info);
-		e100_enable_rxdma_irq(info);
-#endif
-	}
-#endif /* CONFIG_ETRAX_RS485 */
-
-	return count;
-} /* rs_write */
-
-
-/* how much space is available in the xmit buffer? */
-
-static int 
-rs_write_room(struct tty_struct *tty)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-	
-	return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
-}
-
-/* How many chars are in the xmit buffer?
- * This does not include any chars in the transmitter FIFO.
- * Use wait_until_sent for waiting for FIFO drain.
- */
-
-static int 
-rs_chars_in_buffer(struct tty_struct *tty)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-
-	return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
-}
-
-/* discard everything in the xmit buffer */
-
-static void 
-rs_flush_buffer(struct tty_struct *tty)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-	unsigned long flags;
-	
-	save_flags(flags);
-	cli();
-	info->xmit.head = info->xmit.tail = 0;
-	restore_flags(flags);
-
-	wake_up_interruptible(&tty->write_wait);
-
-	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
- *
- * Since we use DMA we don't check for info->x_char in transmit_chars_dma(),
- * but we do it in handle_ser_tx_interrupt().
- * We disable DMA channel and enable tx ready interrupt and write the
- * character when possible.
- */
-static void rs_send_xchar(struct tty_struct *tty, char ch)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-	unsigned long flags;
-	save_flags(flags); cli();
-	if (info->uses_dma_out) {
-		/* Put the DMA on hold and disable the channel */
-		*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, hold);
-		while (IO_EXTRACT(R_DMA_CH6_CMD, cmd, *info->ocmdadr) !=
-		       IO_STATE_VALUE(R_DMA_CH6_CMD, cmd, hold));
-		e100_disable_txdma_channel(info);
-	}
-
-	/* Must make sure transmitter is not stopped before we can transmit */
-	if (tty->stopped)
-		rs_start(tty);
-
-	/* Enable manual transmit interrupt and send from there */
-	DFLOW(DEBUG_LOG(info->line, "rs_send_xchar 0x%02X\n", ch));
-	info->x_char = ch;
-	e100_enable_serial_tx_ready_irq(info);
-	restore_flags(flags);
-}
-
-/*
- * ------------------------------------------------------------
- * 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 e100_serial *info = (struct e100_serial *)tty->driver_data;
-#ifdef SERIAL_DEBUG_THROTTLE
-	char	buf[64];
-
-	printk("throttle %s: %lu....\n", tty_name(tty, buf),
-	       (unsigned long)tty->ldisc.chars_in_buffer(tty));
-#endif
-	DFLOW(DEBUG_LOG(info->line,"rs_throttle %lu\n", tty->ldisc.chars_in_buffer(tty)));
-
-	/* Do RTS before XOFF since XOFF might take some time */
-	if (tty->termios->c_cflag & CRTSCTS) {
-		/* Turn off RTS line */
-		e100_rts(info, 0);
-	}
-	if (I_IXOFF(tty))
-		rs_send_xchar(tty, STOP_CHAR(tty));
-
-}
-
-static void 
-rs_unthrottle(struct tty_struct * tty)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-#ifdef SERIAL_DEBUG_THROTTLE
-	char	buf[64];
-
-	printk("unthrottle %s: %lu....\n", tty_name(tty, buf),
-	       (unsigned long)tty->ldisc.chars_in_buffer(tty));
-#endif
-	DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc %d\n", tty->ldisc.chars_in_buffer(tty)));
-	DFLOW(DEBUG_LOG(info->line,"rs_unthrottle flip.count: %i\n", tty->flip.count));
-	/* Do RTS before XOFF since XOFF might take some time */
-	if (tty->termios->c_cflag & CRTSCTS) {
-		/* Assert RTS line  */
-		e100_rts(info, 1);
-	}
-
-	if (I_IXOFF(tty)) {
-		if (info->x_char)
-			info->x_char = 0;
-		else
-			rs_send_xchar(tty, START_CHAR(tty));
-	}
-
-}
-
-/*
- * ------------------------------------------------------------
- * rs_ioctl() and friends
- * ------------------------------------------------------------
- */
-
-static int 
-get_serial_info(struct e100_serial * info,
-		struct serial_struct * retinfo)
-{
-	struct serial_struct tmp;
-	
-	/* this is all probably wrong, there are a lot of fields
-	 * here that we don't have in e100_serial and maybe we
-	 * should set them to something else than 0.
-	 */
-
-	if (!retinfo)
-		return -EFAULT;
-	memset(&tmp, 0, sizeof(tmp));
-	tmp.type = info->type;
-	tmp.line = info->line;
-	tmp.port = (int)info->port;
-	tmp.irq = info->irq;
-	tmp.flags = info->flags;
-	tmp.baud_base = info->baud_base;
-	tmp.close_delay = info->close_delay;
-	tmp.closing_wait = info->closing_wait;
-	tmp.custom_divisor = info->custom_divisor;
-	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
-		return -EFAULT;
-	return 0;
-}
-
-static int
-set_serial_info(struct e100_serial *info,
-		struct serial_struct *new_info)
-{
-	struct serial_struct new_serial;
-	struct e100_serial old_info;
-	int retval = 0;
-
-	if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
-		return -EFAULT;
-
-	old_info = *info;
-	
-	if (!capable(CAP_SYS_ADMIN)) {
-		if ((new_serial.type != info->type) ||
-		    (new_serial.close_delay != info->close_delay) ||
-		    ((new_serial.flags & ~ASYNC_USR_MASK) !=
-		     (info->flags & ~ASYNC_USR_MASK)))
-			return -EPERM;
-		info->flags = ((info->flags & ~ASYNC_USR_MASK) |
-			       (new_serial.flags & ASYNC_USR_MASK));
-		goto check_and_exit;
-	}
-	
-	if (info->count > 1)
-		return -EBUSY;
-	
-	/*
-	 * 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->flags = ((info->flags & ~ASYNC_FLAGS) |
-		       (new_serial.flags & ASYNC_FLAGS));
-	info->custom_divisor = new_serial.custom_divisor;
-	info->type = new_serial.type;
-	info->close_delay = new_serial.close_delay;
-	info->closing_wait = new_serial.closing_wait;
-	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
-
- check_and_exit:
-	if (info->flags & ASYNC_INITIALIZED) {
-		change_speed(info);
-	} 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 e100_serial * info, unsigned int *value)
-{
-	unsigned int result = TIOCSER_TEMT;
-#ifndef CONFIG_SVINTO_SIM
-	unsigned long curr_time = jiffies;
-	unsigned long curr_time_usec = GET_JIFFIES_USEC();
-	unsigned long elapsed_usec = 
-		(curr_time - info->last_tx_active) * 1000000/HZ + 
-		curr_time_usec - info->last_tx_active_usec;
-
-	if (info->xmit.head != info->xmit.tail || 
-	    elapsed_usec < 2*info->char_time_usec) {
-		result = 0;
-	}
-#endif
-
-	if (copy_to_user(value, &result, sizeof(int)))
-		return -EFAULT;
-	return 0;
-}
-
-#ifdef SERIAL_DEBUG_IO 
-struct state_str
-{
-	int state;
-	const char *str;
-};
-
-const struct state_str control_state_str[] = {
-	{TIOCM_DTR, "DTR" },
-	{TIOCM_RTS, "RTS"},
-	{TIOCM_ST, "ST?" },
-	{TIOCM_SR, "SR?" },
-	{TIOCM_CTS, "CTS" },
-	{TIOCM_CD, "CD" },
-	{TIOCM_RI, "RI" },
-	{TIOCM_DSR, "DSR" },
-	{0, NULL }
-};
-
-char *get_control_state_str(int MLines, char *s)
-{
-	int i = 0;
-
-	s[0]='\0';
-	while (control_state_str[i].str != NULL) {
-		if (MLines & control_state_str[i].state) {
-			if (s[0] != '\0') {
-				strcat(s, ", ");
-			}
-			strcat(s, control_state_str[i].str);
-		}
-		i++;
-	}
-	return s;
-}
-#endif
-
-static int 
-get_modem_info(struct e100_serial * info, unsigned int *value)
-{
-	unsigned int result;
-	/* Polarity isn't verified */
-#if 0 /*def SERIAL_DEBUG_IO  */
-
-	printk("get_modem_info: RTS: %i DTR: %i CD: %i RI: %i DSR: %i CTS: %i\n",
-	       E100_RTS_GET(info),
-	       E100_DTR_GET(info),
-	       E100_CD_GET(info),
-	       E100_RI_GET(info),
-	       E100_DSR_GET(info),
-	       E100_CTS_GET(info));
-#endif
-
-	result =  
-		(!E100_RTS_GET(info) ? TIOCM_RTS : 0)
-		| (!E100_DTR_GET(info) ? TIOCM_DTR : 0)
-		| (!E100_RI_GET(info) ? TIOCM_RNG : 0)
-		| (!E100_DSR_GET(info) ? TIOCM_DSR : 0)
-		| (!E100_CD_GET(info) ? TIOCM_CAR : 0)
-		| (!E100_CTS_GET(info) ? TIOCM_CTS : 0);
-
-#ifdef SERIAL_DEBUG_IO 
-	printk("e100ser: modem state: %i 0x%08X\n", result, result);
-	{
-		char s[100];
-		
-		get_control_state_str(result, s);
-		printk("state: %s\n", s);
-	}
-#endif  
-	if (copy_to_user(value, &result, sizeof(int)))
-		return -EFAULT;
-	return 0;
-}
-
-
-static int
-set_modem_info(struct e100_serial * info, unsigned int cmd,
-	       unsigned int *value)
-{
-	unsigned int arg;
-
-	if (copy_from_user(&arg, value, sizeof(int)))
-		return -EFAULT;
-
-	switch (cmd) {
-	case TIOCMBIS: 
-		if (arg & TIOCM_RTS) {
-			e100_rts(info, 1);
-		}
-		if (arg & TIOCM_DTR) {
-			e100_dtr(info, 1);
-		}
-		/* Handle FEMALE behaviour */
-		if (arg & TIOCM_RI) {
-			e100_ri_out(info, 1);
-		}
-		if (arg & TIOCM_CD) {
-			e100_cd_out(info, 1);
-		}
-		break;
-	case TIOCMBIC:
-		if (arg & TIOCM_RTS) {
-			e100_rts(info, 0);
-		}
-		if (arg & TIOCM_DTR) {
-			e100_dtr(info, 0);
-		}
-		/* Handle FEMALE behaviour */
-		if (arg & TIOCM_RI) {
-			e100_ri_out(info, 0);
-		}
-		if (arg & TIOCM_CD) {
-			e100_cd_out(info, 0);
-		}
-		break;
-	case TIOCMSET:
-		e100_rts(info, arg & TIOCM_RTS);
-		e100_dtr(info, arg & TIOCM_DTR);
-		/* Handle FEMALE behaviour */
-		e100_ri_out(info, arg & TIOCM_RI);
-		e100_cd_out(info, arg & TIOCM_CD);
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-
-static void 
-rs_break(struct tty_struct *tty, int break_state)
-{
-	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
-	unsigned long flags;
-
-	if (!info->port)
-		return;
-	
-	save_flags(flags);
-	cli();
-	if (break_state == -1) {
-		/* Go to manual mode and set the txd pin to 0 */
-		info->tx_ctrl &= 0x3F; /* Clear bit 7 (txd) and 6 (tr_enable) */
-	} else {
-		info->tx_ctrl |= (0x80 | 0x40); /* Set bit 7 (txd) and 6 (tr_enable) */
-	}
-	info->port[REG_TR_CTRL] = info->tx_ctrl;
-	restore_flags(flags);
-}
-
-static int 
-rs_ioctl(struct tty_struct *tty, struct file * file,
-	 unsigned int cmd, unsigned long arg)
-{
-	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
-	
-	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 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 TIOCSERGETLSR: /* Get line status register */
-			return get_lsr_info(info, (unsigned int *) arg);
-
-		case TIOCSERGSTRUCT:
-			if (copy_to_user((struct e100_serial *) arg,
-					 info, sizeof(struct e100_serial)))
-				return -EFAULT;
-			return 0;
-
-#if defined(CONFIG_ETRAX_RS485)
-		case TIOCSERSETRS485:
-		{
-			struct rs485_control rs485ctrl;
-			if (copy_from_user(&rs485ctrl, (struct rs485_control*)arg, sizeof(rs485ctrl)))
-				return -EFAULT;
-
-			return e100_enable_rs485(tty, &rs485ctrl);
-		}
-
-		case TIOCSERWRRS485:
-		{
-			struct rs485_write rs485wr;
-			if (copy_from_user(&rs485wr, (struct rs485_write*)arg, sizeof(rs485wr)))
-				return -EFAULT;
-
-			return e100_write_rs485(tty, 1, rs485wr.outc, rs485wr.outc_size);
-		}
-#endif
-			
-		default:
-			return -ENOIOCTLCMD;
-	}
-	return 0;
-}
-
-static void 
-rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
-{
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-
-	if (tty->termios->c_cflag == old_termios->c_cflag)
-		return;
-
-	change_speed(info);
-
-	/* Handle turning off CRTSCTS */
-	if ((old_termios->c_cflag & CRTSCTS) &&
-	    !(tty->termios->c_cflag & CRTSCTS)) {
-		tty->hw_stopped = 0;
-		rs_start(tty);
-	}
-	
-}
-
-/* In debugport.c - register a console write function that uses the normal
- * serial driver
- */
-typedef int (*debugport_write_function)(int i, const char *buf, unsigned int len);
-
-extern debugport_write_function debug_write_function;
-
-static int rs_debug_write_function(int i, const char *buf, unsigned int len)
-{
-	int cnt;
-        struct tty_struct *tty;
-        static int recurse_cnt = 0;
-
-        tty = rs_table[i].tty;
-        if (tty)  {
-		unsigned long flags;
-		if (recurse_cnt > 5) /* We skip this debug output */
-			return 1;
-
-		local_irq_save(flags);
-		recurse_cnt++;
-                do {
-                        cnt = rs_write(tty, 0, buf, len);
-                        if (cnt >= 0) {
-                                buf += cnt;
-                                len -= cnt;
-                        } else
-                                len = cnt;
-                } while(len > 0);
-		recurse_cnt--;
-		local_irq_restore(flags);
-                return 1;
-        }
-        return 0;
-}
-
-/*
- * ------------------------------------------------------------
- * 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
- * S 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 e100_serial * info = (struct e100_serial *)tty->driver_data;
-	unsigned long flags;
-
-	if (!info)
-		return;
-  
-	/* interrupts are disabled for this entire function */
-  
-	save_flags(flags); 
-	cli();
-  
-	if (tty_hung_up_p(filp)) {
-		restore_flags(flags);
-		return;
-	}
-  
-#ifdef SERIAL_DEBUG_OPEN
-	printk("[%d] rs_close ttyS%d, count = %d\n", current->pid, 
-	       info->line, info->count);
-#endif
-	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(KERN_CRIT
-		       "rs_close: bad serial port count; tty->count is 1, "
-		       "info->count is %d\n", info->count);
-		info->count = 1;
-	}
-	if (--info->count < 0) {
-		printk(KERN_CRIT "rs_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 |= ASYNC_CLOSING;
-	/*
-	 * Save the termios structure, since this port may have
-	 * separate termios for callout and dialin.
-	 */
-	if (info->flags & ASYNC_NORMAL_ACTIVE)
-		info->normal_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 serial receiver and the DMA receive interrupt.
-	 */
-#ifdef SERIAL_HANDLE_EARLY_ERRORS 
-	e100_disable_serial_data_irq(info);
-#endif
-
-#ifndef CONFIG_SVINTO_SIM
-	e100_disable_rx(info);
-	e100_disable_rx_irq(info);
-
-	if (info->flags & ASYNC_INITIALIZED) {
-		/*
-		 * Before we drop DTR, make sure the UART transmitter
-		 * has completely drained; this is especially
-		 * important as we have a transmit FIFO!
-		 */
-		rs_wait_until_sent(tty, HZ);
-	}
-#endif
-
-	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_CLOSING);
-	wake_up_interruptible(&info->close_wait);
-	restore_flags(flags);
-
-	/* port closed */
-
-#if defined(CONFIG_ETRAX_RS485)
-	if (info->rs485.enabled) {
-		info->rs485.enabled = 0;
-#if defined(CONFIG_ETRAX_RS485_ON_PA)
-		*R_PORT_PA_DATA = port_pa_data_shadow &= ~(1 << rs485_pa_bit);
-#endif
-#if defined(CONFIG_ETRAX_RS485_ON_PORT_G)
-		REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
-			       rs485_port_g_bit, 0);
-#endif
-#if defined(CONFIG_ETRAX_RS485_LTC1387)
-		REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
-			       CONFIG_ETRAX_RS485_LTC1387_DXEN_PORT_G_BIT, 0);
-		REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
-			       CONFIG_ETRAX_RS485_LTC1387_RXEN_PORT_G_BIT, 0);
-#endif
-	}
-#endif
-}
-
-/*
- * rs_wait_until_sent() --- wait until the transmitter is empty
- */
-static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
-{
-	unsigned long orig_jiffies;
-	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
-	unsigned long curr_time = jiffies;
-	unsigned long curr_time_usec = GET_JIFFIES_USEC();
-	long elapsed_usec = 
-		(curr_time - info->last_tx_active) * (1000000/HZ) + 
-		curr_time_usec - info->last_tx_active_usec;
-
-	/*
-	 * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO
-	 * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k)
-	 */
-	orig_jiffies = jiffies;
-	while (info->xmit.head != info->xmit.tail || /* More in send queue */
-	       (*info->ostatusadr & 0x007f) ||  /* more in FIFO */
-	       (elapsed_usec < 2*info->char_time_usec)) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
-		if (signal_pending(current))
-			break;
-		if (timeout && time_after(jiffies, orig_jiffies + timeout))
-			break;
-		curr_time = jiffies;
-		curr_time_usec = GET_JIFFIES_USEC();
-		elapsed_usec = 
-			(curr_time - info->last_tx_active) * (1000000/HZ) + 
-			curr_time_usec - info->last_tx_active_usec;
-	}
-	set_current_state(TASK_RUNNING);
-}
-
-/*
- * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
- */
-void 
-rs_hangup(struct tty_struct *tty)
-{
-	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
-	
-	rs_flush_buffer(tty);
-	shutdown(info);
-	info->event = 0;
-	info->count = 0;
-	info->flags &= ~ASYNC_NORMAL_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 e100_serial *info)
-{
-	DECLARE_WAITQUEUE(wait, current);
-	unsigned long	flags;
-	int		retval;
-	int		do_clocal = 0, extra_count = 0;
-	
-	/*
-	 * 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
-		if (info->flags & ASYNC_HUP_NOTIFY)
-			return -EAGAIN;
-		else
-			return -ERESTARTSYS;
-#else
-		return -EAGAIN;
-#endif
-	}
-	
-	/*
-	 * 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))) {
-		info->flags |= ASYNC_NORMAL_ACTIVE;
-		return 0;
-	}
-	
-	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
-	 * 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",
-	       info->line, info->count);
-#endif
-	save_flags(flags); 
-	cli();
-	if (!tty_hung_up_p(filp)) {
-		extra_count++;
-		info->count--;
-	}
-	restore_flags(flags);
-	info->blocked_open++;
-	while (1) {
-		save_flags(flags);
-		cli();
-		/* assert RTS and DTR */
-		e100_rts(info, 1);
-		e100_dtr(info, 1);
-		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_CLOSING) && do_clocal)
-			/* && (do_clocal || DCD_IS_ASSERTED) */
-			break;
-		if (signal_pending(current)) {
-			retval = -ERESTARTSYS;
-			break;
-		}
-#ifdef SERIAL_DEBUG_OPEN
-		printk("block_til_ready blocking: ttyS%d, count = %d\n",
-		       info->line, info->count);
-#endif
-		schedule();
-	}
-	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&info->open_wait, &wait);
-	if (extra_count)
-		info->count++;
-	info->blocked_open--;
-#ifdef SERIAL_DEBUG_OPEN
-	printk("block_til_ready after blocking: ttyS%d, count = %d\n",
-	       info->line, info->count);
-#endif
-	if (retval)
-		return retval;
-	info->flags |= ASYNC_NORMAL_ACTIVE;
-	return 0;
-}	
-
-/*
- * This routine is called whenever a serial port is opened. 
- * It performs the serial-specific initialization for the tty structure.
- */
-static int 
-rs_open(struct tty_struct *tty, struct file * filp)
-{
-	struct e100_serial	*info;
-	int 			retval, line;
-	unsigned long           page;
-
-	/* find which port we want to open */
-
-	line = tty->index;
-  
-	if (line < 0 || line >= NR_PORTS)
-		return -ENODEV;
-
-	/* find the corresponding e100_serial struct in the table */
-	info = rs_table + line;
-
-	/* don't allow the opening of ports that are not enabled in the HW config */
-	if (!info->enabled)
-		return -ENODEV; 
-  
-#ifdef SERIAL_DEBUG_OPEN
-        printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name,
- 	       info->count);
-#endif
-
-	info->count++;
-	tty->driver_data = info;
-	info->tty = tty;
-
-	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
-
-	if (!tmp_buf) {
-		page = get_zeroed_page(GFP_KERNEL);
-		if (!page) {
-			return -ENOMEM;
-		}
-		if (tmp_buf)
-			free_page(page);
-		else
-			tmp_buf = (unsigned char *) page;
-	}
-
-	/*
-	 * If the port is in 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);
-#ifdef SERIAL_DO_RESTART
-		return ((info->flags & ASYNC_HUP_NOTIFY) ?
-			-EAGAIN : -ERESTARTSYS);
-#else
-		return -EAGAIN;
-#endif
-	}
-
-	/*
-	 * Start up the serial port
-	 */
-
-	retval = startup(info);
-	if (retval)
-		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
-		return retval;
-	}
-
-	if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
-		*tty->termios = info->normal_termios;
-		change_speed(info);
-	}
-
-#ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open ttyS%d successful...\n", info->line);
-#endif
-	DLOG_INT_TRIG( log_int_pos = 0);
-
-	DFLIP(	if (info->line == SERIAL_DEBUG_LINE) {
-			info->icount.rx = 0;
-		} );
-
-	return 0;
-}
-
-/*
- * /proc fs routines....
- */
-
-extern _INLINE_ int line_info(char *buf, struct e100_serial *info)
-{
-	char	stat_buf[30];
-	int	ret;
-	unsigned long tmp;
-
-	ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d",
-		      info->line, (unsigned long)info->port, info->irq);
-
-	if (!info->port || (info->type == PORT_UNKNOWN)) {
-		ret += sprintf(buf+ret, "\n");
-		return ret;
-	}
-
-	stat_buf[0] = 0;
-	stat_buf[1] = 0;
-	if (!E100_RTS_GET(info))
-		strcat(stat_buf, "|RTS");
-	if (!E100_CTS_GET(info))
-		strcat(stat_buf, "|CTS");
-	if (!E100_DTR_GET(info))
-		strcat(stat_buf, "|DTR");
-	if (!E100_DSR_GET(info))
-		strcat(stat_buf, "|DSR");
-	if (!E100_CD_GET(info))
-		strcat(stat_buf, "|CD");
-	if (!E100_RI_GET(info))
-		strcat(stat_buf, "|RI");
-
-	ret += sprintf(buf+ret, " baud:%d", info->baud);
-
-	ret += sprintf(buf+ret, " tx:%lu rx:%lu",
-		       (unsigned long)info->icount.tx,
-		       (unsigned long)info->icount.rx);
-	tmp = CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
-	if (tmp) {
-		ret += sprintf(buf+ret, " tx_pend:%lu/%lu",
-			       (unsigned long)tmp,
-			       (unsigned long)SERIAL_XMIT_SIZE);
-	}
-
-	ret += sprintf(buf+ret, " rx_pend:%lu/%lu",
-		       (unsigned long)info->recv_cnt,
-		       (unsigned long)info->max_recv_cnt);
-
-#if 1
-	if (info->tty) {
-
-		if (info->tty->stopped)
-			ret += sprintf(buf+ret, " stopped:%i",
-				       (int)info->tty->stopped);
-		if (info->tty->hw_stopped)
-			ret += sprintf(buf+ret, " hw_stopped:%i",
-				       (int)info->tty->hw_stopped);
-	}
-
-	{
-		unsigned char rstat = info->port[REG_STATUS];
-		if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) )
-			ret += sprintf(buf+ret, " xoff_detect:1");
-	}
-
-#endif
-
-
-
-
-	if (info->icount.frame)
-		ret += sprintf(buf+ret, " fe:%lu",
-			       (unsigned long)info->icount.frame);
-	
-	if (info->icount.parity)
-		ret += sprintf(buf+ret, " pe:%lu",
-			       (unsigned long)info->icount.parity);
-	
-	if (info->icount.brk)
-		ret += sprintf(buf+ret, " brk:%lu",
-			       (unsigned long)info->icount.brk);	
-
-	if (info->icount.overrun)
-		ret += sprintf(buf+ret, " oe:%lu",
-			       (unsigned long)info->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\n",
-		       serial_version);
-	for (i = 0; i < NR_PORTS && len < 4000; i++) {
-		if (!rs_table[i].enabled) 
-			continue; 
-		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;
-		}
-	}
-#ifdef DEBUG_LOG_INCLUDED
-	for (i = 0; i < debug_log_pos; i++) {
-		len += sprintf(page + len, "%-4i %lu.%lu ", i, debug_log[i].time, timer_data_to_ns(debug_log[i].timer_data));
-		len += sprintf(page + len, debug_log[i].string, debug_log[i].value);
-		if (len+begin > off+count)
-			goto done;
-		if (len+begin < off) {
-			begin += len;
-			len = 0;
-		}
-	}
-	len += sprintf(page + len, "debug_log %i/%i  %li bytes\n",
-		       i, DEBUG_LOG_SIZE, begin+len);
-	debug_log_pos = 0;
-#endif
-
-	*eof = 1;
-done:
-	if (off >= len+begin)
-		return 0;
-	*start = page + (off-begin);
-	return ((count < begin+len-off) ? count : begin+len-off);
-}
-
-/* Finally, routines used to initialize the serial driver. */
-
-static void 
-show_serial_version(void)
-{
-	printk(KERN_INFO
-	       "ETRAX 100LX serial-driver %s, (c) 2000-2004 Axis Communications AB\r\n",
-	       &serial_version[11]); /* "$Revision: x.yy" */
-}
-
-/* rs_init inits the driver at boot (using the module_init chain) */
-
-static struct tty_operations rs_ops = {
-	.open = rs_open,
-	.close = rs_close,
-	.write = rs_write,
-	.flush_chars = rs_flush_chars,
-	.write_room = rs_write_room,
-	.chars_in_buffer = rs_chars_in_buffer,
-	.flush_buffer = rs_flush_buffer,
-	.ioctl = rs_ioctl,
-	.throttle = rs_throttle,	
-        .unthrottle = rs_unthrottle,
-	.set_termios = rs_set_termios,
-	.stop = rs_stop,
-	.start = rs_start,
-	.hangup = rs_hangup,
-	.break_ctl = rs_break,
-	.send_xchar = rs_send_xchar,
-	.wait_until_sent = rs_wait_until_sent,
-	.read_proc = rs_read_proc,
-};
-
-static int __init
-rs_init(void)
-{
-	int i;
-	struct e100_serial *info;
-	struct tty_driver *driver = alloc_tty_driver(NR_PORTS);
-
-	if (!driver)
-		return -ENOMEM;
-
-	show_serial_version();
-
-	/* Setup the timed flush handler system */
-
-#if !defined(CONFIG_ETRAX_SERIAL_FAST_TIMER)
-	init_timer(&flush_timer);
-	flush_timer.function = timed_flush_handler;
-	mod_timer(&flush_timer, jiffies + CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS);
-#endif
-
-	/* Initialize the tty_driver structure */
-  
-	driver->driver_name = "serial";
-	driver->name = "ttyS";
-	driver->major = TTY_MAJOR;
-	driver->minor_start = 64;
-	driver->type = TTY_DRIVER_TYPE_SERIAL;
-	driver->subtype = SERIAL_TYPE_NORMAL;
-	driver->init_termios = tty_std_termios;
-	driver->init_termios.c_cflag =
-		B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */
-	driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
-	driver->termios = serial_termios;
-	driver->termios_locked = serial_termios_locked;
-
-	tty_set_operations(driver, &rs_ops);
-        serial_driver = driver;
-	if (tty_register_driver(driver))
-		panic("Couldn't register serial driver\n");
-	/* do some initializing for the separate ports */
-  
-	for (i = 0, info = rs_table; i < NR_PORTS; i++,info++) {
-		info->uses_dma_in = 0;
-		info->uses_dma_out = 0;
-		info->line = i;
-		info->tty = 0;
-		info->type = PORT_ETRAX;
-		info->tr_running = 0;
-		info->forced_eop = 0;
-		info->baud_base = DEF_BAUD_BASE;
-		info->custom_divisor = 0;
-		info->flags = 0;
-		info->close_delay = 5*HZ/10;
-		info->closing_wait = 30*HZ;
-		info->x_char = 0;
-		info->event = 0;
-		info->count = 0;
-		info->blocked_open = 0;
-		info->normal_termios = driver->init_termios;
-		init_waitqueue_head(&info->open_wait);
-		init_waitqueue_head(&info->close_wait);
-		info->xmit.buf = NULL;
-		info->xmit.tail = info->xmit.head = 0;
-		info->first_recv_buffer = info->last_recv_buffer = NULL;
-		info->recv_cnt = info->max_recv_cnt = 0;
-		info->last_tx_active_usec = 0;
-		info->last_tx_active = 0;
-
-#if defined(CONFIG_ETRAX_RS485)
-		/* Set sane defaults */
-		info->rs485.rts_on_send = 0;
-		info->rs485.rts_after_sent = 1;
-		info->rs485.delay_rts_before_send = 0;
-		info->rs485.enabled = 0;
-#endif
-		INIT_WORK(&info->work, do_softint, info);
-
-		if (info->enabled) {
-			printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n",
-			       serial_driver->name, info->line, (unsigned int)info->port);
-		}
-	}
-#ifdef CONFIG_ETRAX_FAST_TIMER
-#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
-	memset(fast_timers, 0, sizeof(fast_timers));
-#endif
-#ifdef CONFIG_ETRAX_RS485
-	memset(fast_timers_rs485, 0, sizeof(fast_timers_rs485));
-#endif
-	fast_timer_init();
-#endif
-
-#ifndef CONFIG_SVINTO_SIM
-	/* Not needed in simulator.  May only complicate stuff. */
-	/* hook the irq's for DMA channel 6 and 7, serial output and input, and some more... */
-
-	if (request_irq(SERIAL_IRQ_NBR, ser_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial ", NULL))
-		panic("irq8");
-
-#ifdef CONFIG_ETRAX_SERIAL_PORT0
-#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA6_OUT
-	if (request_irq(SER0_DMA_TX_IRQ_NBR, tr_interrupt, SA_INTERRUPT, "serial 0 dma tr", NULL))
-		panic("irq22");
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA7_IN
-	if (request_irq(SER0_DMA_RX_IRQ_NBR, rec_interrupt, SA_INTERRUPT, "serial 0 dma rec", NULL))
-		panic("irq23");
-#endif
-#endif
-
-#ifdef CONFIG_ETRAX_SERIAL_PORT1
-#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA8_OUT
-	if (request_irq(SER1_DMA_TX_IRQ_NBR, tr_interrupt, SA_INTERRUPT, "serial 1 dma tr", NULL))
-		panic("irq24");
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA9_IN
-	if (request_irq(SER1_DMA_RX_IRQ_NBR, rec_interrupt, SA_INTERRUPT, "serial 1 dma rec", NULL))
-		panic("irq25");
-#endif
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT2
-	/* DMA Shared with par0 (and SCSI0 and ATA) */
-#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA2_OUT
-	if (request_irq(SER2_DMA_TX_IRQ_NBR, tr_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial 2 dma tr", NULL))
-		panic("irq18");
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA3_IN
-	if (request_irq(SER2_DMA_RX_IRQ_NBR, rec_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial 2 dma rec", NULL))
-		panic("irq19");
-#endif
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT3
-	/* DMA Shared with par1 (and SCSI1 and Extern DMA 0) */
-#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA4_OUT
-	if (request_irq(SER3_DMA_TX_IRQ_NBR, tr_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial 3 dma tr", NULL))
-		panic("irq20");
-#endif
-#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA5_IN
-	if (request_irq(SER3_DMA_RX_IRQ_NBR, rec_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial 3 dma rec", NULL))
-		panic("irq21");
-#endif
-#endif
-
-#ifdef CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST
-	if (request_irq(TIMER1_IRQ_NBR, timeout_interrupt, SA_SHIRQ | SA_INTERRUPT,
-		       "fast serial dma timeout", NULL)) {
-		printk(KERN_CRIT "err: timer1 irq\n");
-	}
-#endif
-#endif /* CONFIG_SVINTO_SIM */
-	debug_write_function = rs_debug_write_function;
-	return 0;
-}
-
-/* this makes sure that rs_init is called during kernel boot */
-
-module_init(rs_init);
-
-/*
- * register_serial and unregister_serial allows for serial ports to be
- * configured at run-time, to support PCMCIA modems.
- */
-int 
-register_serial(struct serial_struct *req)
-{
-	return -1;
-}
-
-void unregister_serial(int line)
-{
-}
diff -Nru a/arch/cris/arch-v10/drivers/serial.h b/arch/cris/arch-v10/drivers/serial.h
--- a/arch/cris/arch-v10/drivers/serial.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,137 +0,0 @@
-/*
- * serial.h: Arch-dep definitions for the Etrax100 serial driver.
- *
- * Copyright (C) 1998, 1999, 2000 Axis Communications AB
- */
-
-#ifndef _ETRAX_SERIAL_H
-#define _ETRAX_SERIAL_H
-
-#include <linux/config.h>
-#include <linux/circ_buf.h>
-#include <asm/termios.h>
-
-/* Software state per channel */
-
-#ifdef __KERNEL__
-/*
- * This is our internal structure for each serial port's state.
- * 
- * Many fields are paralleled by the structure used by the serial_struct
- * structure.
- *
- * For definitions of the flags field, see tty.h
- */
-
-#define SERIAL_RECV_DESCRIPTORS 8
-
-struct etrax_recv_buffer {
-	struct etrax_recv_buffer *next;
-	unsigned short length;
-	unsigned char error;
-	unsigned char pad;
-
-	unsigned char buffer[0];
-};
-
-struct e100_serial {
-	int			baud;
-	volatile u8		*port; /* R_SERIALx_CTRL */
-	u32			irq;  /* bitnr in R_IRQ_MASK2 for dmaX_descr */
-
-	/* Output registers */
-	volatile u8		*oclrintradr; /* adr to R_DMA_CHx_CLR_INTR */
-	volatile u32		*ofirstadr;   /* adr to R_DMA_CHx_FIRST */
-	volatile u8		*ocmdadr;     /* adr to R_DMA_CHx_CMD */
-	const volatile u8	*ostatusadr;  /* adr to R_DMA_CHx_STATUS */
-
-	/* Input registers */
-	volatile u8		*iclrintradr; /* adr to R_DMA_CHx_CLR_INTR */
-	volatile u32		*ifirstadr;   /* adr to R_DMA_CHx_FIRST */
-	volatile u8		*icmdadr;     /* adr to R_DMA_CHx_CMD */
-	volatile u32		*idescradr;   /* adr to R_DMA_CHx_DESCR */
-
-	int			flags;	/* defined in tty.h */
-
-	u8			rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */
-	u8			tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */
-	u8			iseteop; /* bit number for R_SET_EOP for the input dma */
-	int			enabled; /* Set to 1 if the port is enabled in HW config */
-
-	u8		dma_out_enabled:1; /* Set to 1 if DMA should be used */
-	u8		dma_in_enabled:1;  /* Set to 1 if DMA should be used */
-
-	/* end of fields defined in rs_table[] in .c-file */
-	u8		uses_dma_in;  /* Set to 1 if DMA is used */
-	u8		uses_dma_out; /* Set to 1 if DMA is used */
-	u8		forced_eop;   /* a fifo eop has been forced */
-	int			baud_base;     /* For special baudrates */
-	int			custom_divisor; /* For special baudrates */
-	struct etrax_dma_descr	tr_descr;
-	struct etrax_dma_descr	rec_descr[SERIAL_RECV_DESCRIPTORS];
-	int			cur_rec_descr;
-
-	volatile int		tr_running; /* 1 if output is running */
-
-	struct tty_struct	*tty;
-	int			read_status_mask;
-	int			ignore_status_mask;
-	int			x_char;	/* xon/xoff character */
-	int			close_delay;
-	unsigned short		closing_wait;
-	unsigned short		closing_wait2;
-	unsigned long		event;
-	unsigned long		last_active;
-	int			line;
-	int			type;  /* PORT_ETRAX */
-	int			count;	    /* # of fd on device */
-	int			blocked_open; /* # of blocked opens */
-	struct circ_buf		xmit;
-	struct etrax_recv_buffer *first_recv_buffer;
-	struct etrax_recv_buffer *last_recv_buffer;
-	unsigned int		recv_cnt;
-	unsigned int		max_recv_cnt;
-
-	struct work_struct	work;
-	struct async_icount	icount;   /* error-statistics etc.*/
-	struct termios		normal_termios;
-	struct termios		callout_termios;
-#ifdef DECLARE_WAITQUEUE
-	wait_queue_head_t	open_wait;
-	wait_queue_head_t	close_wait;
-#else
-	struct wait_queue	*open_wait;
-	struct wait_queue	*close_wait;
-#endif  
-
-	unsigned long		char_time_usec;       /* The time for 1 char, in usecs */
-	unsigned long		flush_time_usec;      /* How often we should flush */
-	unsigned long		last_tx_active_usec;  /* Last tx usec in the jiffies */
-	unsigned long		last_tx_active;       /* Last tx time in jiffies */
-	unsigned long		last_rx_active_usec;  /* Last rx usec in the jiffies */
-	unsigned long		last_rx_active;       /* Last rx time in jiffies */
-
-	int			break_detected_cnt;
-	int			errorcode;
-
-#ifdef CONFIG_ETRAX_RS485
-	struct rs485_control	rs485;  /* RS-485 support */
-#endif
-};
-
-/* this PORT is not in the standard serial.h. it's not actually used for
- * anything since we only have one type of async serial-port anyway in this
- * system.
- */
-
-#define PORT_ETRAX 1
-
-/*
- * Events are used to schedule things to happen at timer-interrupt
- * time, instead of at rs interrupt time.
- */
-#define RS_EVENT_WRITE_WAKEUP	0
-
-#endif /* __KERNEL__ */
-
-#endif /* !_ETRAX_SERIAL_H */
diff -Nru a/arch/cris/arch-v10/kernel/Makefile b/arch/cris/arch-v10/kernel/Makefile
--- a/arch/cris/arch-v10/kernel/Makefile	2004-12-24 13:36:16 -08:00
+++ b/arch/cris/arch-v10/kernel/Makefile	2004-12-24 13:36:16 -08:00
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.4 2003/07/04 12:57:13 tobiasa Exp $
+# $Id: Makefile,v 1.5 2004/06/02 08:24:38 starvik Exp $
 #
 # Makefile for the linux kernel.
 #
@@ -11,6 +11,7 @@
 
 obj-$(CONFIG_ETRAX_KGDB) += kgdb.o
 obj-$(CONFIG_ETRAX_FAST_TIMER) += fasttimer.o
+obj-$(CONFIG_MODULES)    += crisksyms.o
 
 clean:
 
diff -Nru a/arch/cris/arch-v10/kernel/crisksyms.c b/arch/cris/arch-v10/kernel/crisksyms.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/cris/arch-v10/kernel/crisksyms.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,17 @@
+#include <linux/config.h>
+#include <linux/module.h>
+#include <asm/io.h>
+#include <asm/arch/svinto.h>
+
+/* Export shadow registers for the CPU I/O pins */
+EXPORT_SYMBOL(genconfig_shadow);
+EXPORT_SYMBOL(port_pa_data_shadow);
+EXPORT_SYMBOL(port_pa_dir_shadow);
+EXPORT_SYMBOL(port_pb_data_shadow);
+EXPORT_SYMBOL(port_pb_dir_shadow);
+EXPORT_SYMBOL(port_pb_config_shadow);
+EXPORT_SYMBOL(port_g_data_shadow);
+
+/* Cache flush functions */
+EXPORT_SYMBOL(flush_etrax_cache);
+EXPORT_SYMBOL(prepare_rx_descriptor);
diff -Nru a/arch/cris/arch-v10/kernel/debugport.c b/arch/cris/arch-v10/kernel/debugport.c
--- a/arch/cris/arch-v10/kernel/debugport.c	2004-12-24 13:36:17 -08:00
+++ b/arch/cris/arch-v10/kernel/debugport.c	2004-12-24 13:36:17 -08:00
@@ -12,6 +12,21 @@
  *    init_etrax_debug()
  *
  * $Log: debugport.c,v $
+ * Revision 1.19  2004/10/21 07:26:16  starvik
+ * Made it possible to specify console settings on kernel command line.
+ *
+ * Revision 1.18  2004/10/19 13:07:37  starvik
+ * Merge of Linux 2.6.9
+ *
+ * Revision 1.17  2004/09/29 10:33:46  starvik
+ * Resolved a dealock when printing debug from kernel.
+ *
+ * Revision 1.16  2004/08/24 06:12:19  starvik
+ * Whitespace cleanup
+ *
+ * Revision 1.15  2004/08/16 12:37:19  starvik
+ * Merge of Linux 2.6.8
+ *
  * Revision 1.14  2004/05/17 13:11:29  starvik
  * Disable DMA until real serial driver is up
  *
@@ -73,111 +88,275 @@
 #include <asm/arch/svinto.h>
 #include <asm/io.h>             /* Get SIMCOUT. */
 
-/* Which serial-port is our debug port ? */
+struct dbg_port
+{
+  unsigned int index;
+  const volatile unsigned* read;
+  volatile char* write;
+  volatile unsigned* xoff;
+  volatile char* baud;
+  volatile char* tr_ctrl;
+  volatile char* rec_ctrl;
+  unsigned long irq;
+  unsigned int started;
+  unsigned long baudrate;
+  unsigned char parity;
+  unsigned int bits;
+};
 
-#if defined(CONFIG_ETRAX_DEBUG_PORT0) || defined(CONFIG_ETRAX_DEBUG_PORT_NULL)
-#define DEBUG_PORT_IDX 0
-#define DEBUG_OCMD R_DMA_CH6_CMD
-#define DEBUG_FIRST R_DMA_CH6_FIRST
-#define DEBUG_OCLRINT R_DMA_CH6_CLR_INTR
-#define DEBUG_STATUS R_DMA_CH6_STATUS
-#define DEBUG_READ R_SERIAL0_READ
-#define DEBUG_WRITE R_SERIAL0_TR_DATA
-#define DEBUG_TR_CTRL R_SERIAL0_TR_CTRL
-#define DEBUG_REC_CTRL R_SERIAL0_REC_CTRL
-#define DEBUG_IRQ IO_STATE(R_IRQ_MASK1_SET, ser0_data, set)
-#define DEBUG_DMA_IRQ_CLR IO_STATE(R_IRQ_MASK2_CLR, dma6_descr, clr)
-#endif
+struct dbg_port ports[]=
+{
+  {
+    0,
+    R_SERIAL0_READ,
+    R_SERIAL0_TR_DATA,
+    R_SERIAL0_XOFF,
+    R_SERIAL0_BAUD,
+    R_SERIAL0_TR_CTRL,
+    R_SERIAL0_REC_CTRL,
+    IO_STATE(R_IRQ_MASK1_SET, ser0_data, set)
+  },
+  {
+    1,
+    R_SERIAL1_READ,
+    R_SERIAL1_TR_DATA,
+    R_SERIAL1_XOFF,
+    R_SERIAL1_BAUD,
+    R_SERIAL1_TR_CTRL,
+    R_SERIAL1_REC_CTRL,
+    IO_STATE(R_IRQ_MASK1_SET, ser1_data, set)
+  },
+  {
+    2,
+    R_SERIAL2_READ,
+    R_SERIAL2_TR_DATA,
+    R_SERIAL2_XOFF,
+    R_SERIAL2_BAUD,
+    R_SERIAL2_TR_CTRL,
+    R_SERIAL2_REC_CTRL,
+    IO_STATE(R_IRQ_MASK1_SET, ser2_data, set)
+  },
+  {
+    3,
+    R_SERIAL3_READ,
+    R_SERIAL3_TR_DATA,
+    R_SERIAL3_XOFF,
+    R_SERIAL3_BAUD,
+    R_SERIAL3_TR_CTRL,
+    R_SERIAL3_REC_CTRL,
+    IO_STATE(R_IRQ_MASK1_SET, ser3_data, set)
+  }
+};
 
-#ifdef CONFIG_ETRAX_DEBUG_PORT1
-#define DEBUG_PORT_IDX 1
-#define DEBUG_OCMD R_DMA_CH8_CMD
-#define DEBUG_FIRST R_DMA_CH8_FIRST
-#define DEBUG_OCLRINT R_DMA_CH8_CLR_INTR
-#define DEBUG_STATUS R_DMA_CH8_STATUS
-#define DEBUG_READ R_SERIAL1_READ
-#define DEBUG_WRITE R_SERIAL1_TR_DATA
-#define DEBUG_TR_CTRL R_SERIAL1_TR_CTRL
-#define DEBUG_REC_CTRL R_SERIAL1_REC_CTRL
-#define DEBUG_IRQ IO_STATE(R_IRQ_MASK1_SET, ser1_data, set)
-#define DEBUG_DMA_IRQ_CLR IO_STATE(R_IRQ_MASK2_CLR, dma8_descr, clr)
-#endif
+static struct tty_driver *serial_driver;
 
-#ifdef CONFIG_ETRAX_DEBUG_PORT2
-#define DEBUG_PORT_IDX 2
-#define DEBUG_OCMD R_DMA_CH2_CMD
-#define DEBUG_FIRST R_DMA_CH2_FIRST
-#define DEBUG_OCLRINT R_DMA_CH2_CLR_INTR
-#define DEBUG_STATUS R_DMA_CH2_STATUS
-#define DEBUG_READ R_SERIAL2_READ
-#define DEBUG_WRITE R_SERIAL2_TR_DATA
-#define DEBUG_TR_CTRL R_SERIAL2_TR_CTRL
-#define DEBUG_REC_CTRL R_SERIAL2_REC_CTRL
-#define DEBUG_IRQ IO_STATE(R_IRQ_MASK1_SET, ser2_data, set)
-#define DEBUG_DMA_IRQ_CLR IO_STATE(R_IRQ_MASK2_CLR, dma2_descr, clr)
+struct dbg_port* port =
+#if defined(CONFIG_ETRAX_DEBUG_PORT0)
+  &ports[0];
+#elif defined(CONFIG_ETRAX_DEBUG_PORT1)
+  &ports[1];
+#elif defined(CONFIG_ETRAX_DEBUG_PORT2)
+  &ports[2];
+#elif defined(CONFIG_ETRAX_DEBUG_PORT3)
+  &ports[3];
+#else
+  NULL;
 #endif
+/* Used by serial.c to register a debug_write_function so that the normal
+ * serial driver is used for kernel debug output
+ */
+typedef int (*debugport_write_function)(int i, const char *buf, unsigned int len);
 
-#ifdef CONFIG_ETRAX_DEBUG_PORT3
-#define DEBUG_PORT_IDX 3
-#define DEBUG_OCMD R_DMA_CH4_CMD
-#define DEBUG_FIRST R_DMA_CH4_FIRST
-#define DEBUG_OCLRINT R_DMA_CH4_CLR_INTR
-#define DEBUG_STATUS R_DMA_CH4_STATUS
-#define DEBUG_READ R_SERIAL3_READ
-#define DEBUG_WRITE R_SERIAL3_TR_DATA
-#define DEBUG_TR_CTRL R_SERIAL3_TR_CTRL
-#define DEBUG_REC_CTRL R_SERIAL3_REC_CTRL
-#define DEBUG_IRQ IO_STATE(R_IRQ_MASK1_SET, ser3_data, set)
-#define DEBUG_DMA_IRQ_CLR IO_STATE(R_IRQ_MASK2_CLR, dma4_descr, clr)
-#endif
+debugport_write_function debug_write_function = NULL;
 
-#define MIN_SIZE 32 /* Size that triggers the FIFO to flush characters to interface */
+static void
+start_port(void)
+{
+	unsigned long rec_ctrl = 0;
+	unsigned long tr_ctrl = 0;
 
-static struct tty_driver *serial_driver;
+	if (!port)
+		return;
 
-typedef int (*debugport_write_function)(int i, const char *buf, unsigned int len);
+	if (port->started)
+		return;
+	port->started = 1;
+
+	if (port->index == 0)
+	{
+		genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, dma6);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma6, unused);
+	}
+	else if (port->index == 1)
+	{
+		genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, dma8);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma8, usb);
+	}
+	else if (port->index == 2)
+	{
+		genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, dma2);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma2, par0);
+		genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, dma3);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma3, par0);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, ser2, select);
+	}
+	else
+	{
+		genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, dma4);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma4, par1);
+		genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, dma5);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma5, par1);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, ser3, select);
+	}
 
-debugport_write_function debug_write_function = NULL;
+	*R_GEN_CONFIG = genconfig_shadow;
+
+	*port->xoff =
+		IO_STATE(R_SERIAL0_XOFF, tx_stop, enable) |
+		IO_STATE(R_SERIAL0_XOFF, auto_xoff, disable) |
+		IO_FIELD(R_SERIAL0_XOFF, xoff_char, 0);
+
+	switch (port->baudrate)
+	{
+	case 0:
+	case 115200:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c115k2Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c115k2Hz);
+		break;
+	case 1200:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c1200Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c1200Hz);
+		break;
+	case 2400:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c2400Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c2400Hz);
+		break;
+	case 4800:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c4800Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c4800Hz);
+		break;
+	case 9600:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c9600Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c9600Hz);
+		  break;
+	case 19200:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c19k2Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c19k2Hz);
+		 break;
+	case 38400:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c38k4Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c38k4Hz);
+		break;
+	case 57600:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c57k6Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c57k6Hz);
+		break;
+	default:
+		*port->baud =
+		  IO_STATE(R_SERIAL0_BAUD, tr_baud, c115k2Hz) |
+		  IO_STATE(R_SERIAL0_BAUD, rec_baud, c115k2Hz);
+		  break;
+        }
+
+	if (port->parity == 'E') {
+		rec_ctrl =
+		  IO_STATE(R_SERIAL0_REC_CTRL, rec_par, even) |
+		  IO_STATE(R_SERIAL0_REC_CTRL, rec_par_en, enable);
+		tr_ctrl =
+		  IO_STATE(R_SERIAL0_TR_CTRL, tr_par, even) |
+		  IO_STATE(R_SERIAL0_TR_CTRL, tr_par_en, enable);
+	} else if (port->parity == 'O') {
+		rec_ctrl =
+		  IO_STATE(R_SERIAL0_REC_CTRL, rec_par, odd) |
+		  IO_STATE(R_SERIAL0_REC_CTRL, rec_par_en, enable);
+		tr_ctrl =
+		  IO_STATE(R_SERIAL0_TR_CTRL, tr_par, odd) |
+		  IO_STATE(R_SERIAL0_TR_CTRL, tr_par_en, enable);
+	} else {
+		rec_ctrl =
+		  IO_STATE(R_SERIAL0_REC_CTRL, rec_par, even) |
+		  IO_STATE(R_SERIAL0_REC_CTRL, rec_par_en, disable);
+		tr_ctrl =
+		  IO_STATE(R_SERIAL0_TR_CTRL, tr_par, even) |
+		  IO_STATE(R_SERIAL0_TR_CTRL, tr_par_en, disable);
+	}
+
+	if (port->bits == 7)
+	{
+		rec_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_bitnr, rec_7bit);
+		tr_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_bitnr, tr_7bit);
+	}
+	else
+	{
+		rec_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_bitnr, rec_8bit);
+		tr_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_bitnr, tr_8bit);
+	}
+
+	*port->rec_ctrl =
+		IO_STATE(R_SERIAL0_REC_CTRL, dma_err, stop) |
+		IO_STATE(R_SERIAL0_REC_CTRL, rec_enable, enable) |
+		IO_STATE(R_SERIAL0_REC_CTRL, rts_, active) |
+		IO_STATE(R_SERIAL0_REC_CTRL, sampling, middle) |
+		IO_STATE(R_SERIAL0_REC_CTRL, rec_stick_par, normal) |
+		rec_ctrl;
+
+	*port->tr_ctrl =
+		IO_FIELD(R_SERIAL0_TR_CTRL, txd, 0) |
+		IO_STATE(R_SERIAL0_TR_CTRL, tr_enable, enable) |
+		IO_STATE(R_SERIAL0_TR_CTRL, auto_cts, disabled) |
+		IO_STATE(R_SERIAL0_TR_CTRL, stop_bits, one_bit) |
+		IO_STATE(R_SERIAL0_TR_CTRL, tr_stick_par, normal) |
+		tr_ctrl;
+}
 
 static void
 console_write_direct(struct console *co, const char *buf, unsigned int len)
 {
 	int i;
+	unsigned long flags;
+	local_irq_save(flags);
 	/* Send data */
 	for (i = 0; i < len; i++) {
 		/* Wait until transmitter is ready and send.*/
-		while(!(*DEBUG_READ & IO_MASK(R_SERIAL0_READ, tr_ready)));
-                *DEBUG_WRITE = buf[i];
+		while (!(*port->read & IO_MASK(R_SERIAL0_READ, tr_ready)))
+			;
+		*port->write = buf[i];
 	}
+	local_irq_restore(flags);
 }
 
-static void 
+static void
 console_write(struct console *co, const char *buf, unsigned int len)
 {
-	unsigned long flags;
-#ifdef CONFIG_ETRAX_DEBUG_PORT_NULL
-        /* no debug printout at all */
-        return;
-#endif
+	if (!port)
+		return;
 
 #ifdef CONFIG_SVINTO_SIM
 	/* no use to simulate the serial debug output */
-	SIMCOUT(buf,len);
+	SIMCOUT(buf, len);
 	return;
 #endif
 
+	start_port();
+
 #ifdef CONFIG_ETRAX_KGDB
 	/* kgdb needs to output debug info using the gdb protocol */
 	putDebugString(buf, len);
 	return;
 #endif
 
-	local_irq_save(flags);
 	if (debug_write_function)
-		if (debug_write_function(co->index, buf, len))
-			return;
-	console_write_direct(co, buf, len);
-	local_irq_restore(flags);
+		debug_write_function(co->index, buf, len);
+	else
+		console_write_direct(co, buf, len);
 }
 
 /* legacy function */
@@ -194,10 +373,10 @@
 getDebugChar(void)
 {
 	unsigned long readval;
-	
+
 	do {
-		readval = *DEBUG_READ;
-	} while(!(readval & IO_MASK(R_SERIAL0_READ, data_avail)));
+		readval = *port->read;
+	} while (!(readval & IO_MASK(R_SERIAL0_READ, data_avail)));
 
 	return (readval & IO_MASK(R_SERIAL0_READ, data_in));
 }
@@ -207,9 +386,9 @@
 void
 putDebugChar(int val)
 {
-	while(!(*DEBUG_READ & IO_MASK(R_SERIAL0_READ, tr_ready))) ;
-;
-	*DEBUG_WRITE = val;
+	while (!(*port->read & IO_MASK(R_SERIAL0_READ, tr_ready)))
+		;
+	*port->write = val;
 }
 
 /* Enable irq for receiving chars on the debug port, used by kgdb */
@@ -217,68 +396,127 @@
 void
 enableDebugIRQ(void)
 {
-	*R_IRQ_MASK1_SET = DEBUG_IRQ;
+	*R_IRQ_MASK1_SET = port->irq;
 	/* use R_VECT_MASK directly, since we really bypass Linux normal
 	 * IRQ handling in kgdb anyway, we don't need to use enable_irq
 	 */
 	*R_VECT_MASK_SET = IO_STATE(R_VECT_MASK_SET, serial, set);
 
-	*DEBUG_REC_CTRL = IO_STATE(R_SERIAL0_REC_CTRL, rec_enable, enable);
+	*port->rec_ctrl = IO_STATE(R_SERIAL0_REC_CTRL, rec_enable, enable);
 }
 
 static struct tty_driver*
-console_device(struct console *c, int *index)
+etrax_console_device(struct console* co, int *index)
 {
-	*index = c->index;
 	return serial_driver;
 }
 
-static int __init 
+static int __init
 console_setup(struct console *co, char *options)
 {
-        return 0;
+	char* s;
+
+	if (options) {
+		port = &ports[co->index];
+		port->baudrate = 115200;
+                port->parity = 'N';
+                port->bits = 8;
+		port->baudrate = simple_strtoul(options, NULL, 10);
+		s = options;
+		while(*s >= '0' && *s <= '9')
+			s++;
+		if (*s) port->parity = *s++;
+		if (*s) port->bits   = *s++ - '0';
+		port->started = 0;
+		start_port();
+	}
+	return 0;
 }
 
 static struct console sercons = {
-	.name    = "ttyS",
-	.write   = console_write,
-	.read    = NULL,
-	.device  = console_device,
-	.unblank = NULL,
-	.setup   = console_setup,
-	.flags   = CON_PRINTBUFFER,
-	.index   = DEBUG_PORT_IDX,
-	.cflag   = 0,
-	.next    = NULL
+	name : "ttyS",
+	write: console_write,
+	read : NULL,
+	device : etrax_console_device,
+	unblank : NULL,
+	setup : console_setup,
+	flags : CON_PRINTBUFFER,
+	index : -1,
+	cflag : 0,
+	next : NULL
+};
+static struct console sercons0 = {
+	name : "ttyS",
+	write: console_write,
+	read : NULL,
+	device : etrax_console_device,
+	unblank : NULL,
+	setup : console_setup,
+	flags : CON_PRINTBUFFER,
+	index : 0,
+	cflag : 0,
+	next : NULL
 };
 
+static struct console sercons1 = {
+	name : "ttyS",
+	write: console_write,
+	read : NULL,
+	device : etrax_console_device,
+	unblank : NULL,
+	setup : console_setup,
+	flags : CON_PRINTBUFFER,
+	index : 1,
+	cflag : 0,
+	next : NULL
+};
+static struct console sercons2 = {
+	name : "ttyS",
+	write: console_write,
+	read : NULL,
+	device : etrax_console_device,
+	unblank : NULL,
+	setup : console_setup,
+	flags : CON_PRINTBUFFER,
+	index : 2,
+	cflag : 0,
+	next : NULL
+};
+static struct console sercons3 = {
+	name : "ttyS",
+	write: console_write,
+	read : NULL,
+	device : etrax_console_device,
+	unblank : NULL,
+	setup : console_setup,
+	flags : CON_PRINTBUFFER,
+	index : 3,
+	cflag : 0,
+	next : NULL
+};
 /*
  *      Register console (for printk's etc)
  */
 
-void __init 
+int __init
 init_etrax_debug(void)
 {
-#ifdef CONFIG_ETRAX_DEBUG_PORT_NULL
-	return;
-#endif
-
-#if DEBUG_PORT_IDX == 0
-	genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma6);
-	genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma6, unused);
-#elif DEBUG_PORT_IDX == 1
-	genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma8);
-	genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma8, usb);
-#elif DEBUG_PORT_IDX == 2
-	genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma2);
-	genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma2, par0);
-#elif DEBUG_PORT_IDX == 3
-	genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma4);
-	genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma4, par1);
-#endif
-	*R_GEN_CONFIG = genconfig_shadow;
+	static int first = 1;
 
-	register_console(&sercons);
+	if (!first) {
+		if (!port) {
+			register_console(&sercons0);
+			register_console(&sercons1);
+			register_console(&sercons2);
+			register_console(&sercons3);
+			unregister_console(&sercons);
+		}
+		return 0;
+	}
+	first = 0;
+	if (port)
+		register_console(&sercons);
+	return 0;
 }
 
 int __init
@@ -289,3 +527,5 @@
 		return -ENOMEM;
 	return 0;
 }
+
+__initcall(init_etrax_debug);
diff -Nru a/arch/cris/arch-v10/kernel/entry.S b/arch/cris/arch-v10/kernel/entry.S
--- a/arch/cris/arch-v10/kernel/entry.S	2004-12-24 13:36:48 -08:00
+++ b/arch/cris/arch-v10/kernel/entry.S	2004-12-24 13:36:48 -08:00
@@ -1,4 +1,4 @@
-/* $Id: entry.S,v 1.18 2004/05/11 12:28:25 starvik Exp $
+/* $Id: entry.S,v 1.23 2004/10/19 13:07:37 starvik Exp $
  *
  *  linux/arch/cris/entry.S
  *
@@ -7,6 +7,23 @@
  *  Authors:	Bjorn Wesen (bjornw@axis.com)
  *
  *  $Log: entry.S,v $
+ *  Revision 1.23  2004/10/19 13:07:37  starvik
+ *  Merge of Linux 2.6.9
+ *
+ *  Revision 1.22  2004/06/21 10:29:55  starvik
+ *  Merge of Linux 2.6.7
+ *
+ *  Revision 1.21  2004/06/09 05:30:27  starvik
+ *  Clean up multiple interrupt handling.
+ *    Prevent interrupts from interrupting each other.
+ *    Handle all active interrupts.
+ *
+ *  Revision 1.20  2004/06/08 08:55:32  starvik
+ *  Removed unused code
+ *
+ *  Revision 1.19  2004/06/04 11:56:15  starvik
+ *  Implemented page table lookup for refills in assembler for improved performance.
+ *
  *  Revision 1.18  2004/05/11 12:28:25  starvik
  *  Merge of Linux 2.6.6
  *
@@ -238,7 +255,9 @@
 #include <asm/errno.h>
 #include <asm/thread_info.h>
 #include <asm/arch/offset.h>
-		
+#include <asm/page.h>
+#include <asm/pgtable.h>
+
 	;; functions exported from this file
 	
 	.globl system_call
@@ -539,11 +558,63 @@
 	;; It needs to stack the CPU status and overall is different
 	;; from the other interrupt handlers.
 
-mmu_bus_fault:	
-	sbfs	[$sp=$sp-16]	; push the internal CPU status
+mmu_bus_fault:
+	;; For refills we try to do a quick page table lookup. If it is
+	;; a real fault we let the mm subsystem handle it.
+
 	;; the first longword in the sbfs frame was the interrupted PC
 	;; which fits nicely with the "IRP" slot in pt_regs normally used to
-	;; contain the return address. used by Oops to print kernel errors..
+	;; contain the return address. used by Oops to print kernel errors.
+	sbfs	[$sp=$sp-16]	; push the internal CPU status
+	push	$dccr
+	di
+	subq	2*4, $sp
+	movem	$r1, [$sp]
+	move.d  [R_MMU_CAUSE], $r1
+	;; ETRAX 100LX TR89 bugfix: if the second half of an unaligned
+	;; write causes a MMU-fault, it will not be restarted correctly.
+	;; This could happen if a write crosses a page-boundary and the
+	;; second page is not yet COW'ed or even loaded. The workaround
+	;; is to clear the unaligned bit in the CPU status record, so
+	;; that the CPU will rerun both the first and second halves of
+	;; the instruction. This will not have any sideeffects unless
+	;; the first half goes to any device or memory that can't be
+	;; written twice, and which is mapped through the MMU.
+	;;
+	;; We only need to do this for writes.
+	btstq	8, $r1		   ; Write access?
+	bpl	1f
+	nop
+	move.d	[$sp+16], $r0	   ; Clear unaligned bit in csrinstr
+	and.d	~(1<<5), $r0
+	move.d	$r0, [$sp+16]
+1:	btstq	12, $r1		   ; Refill?
+	bpl	2f
+	lsrq	PMD_SHIFT, $r1     ; Get PMD index into PGD (bit 24-31)
+	move.d  [current_pgd], $r0 ; PGD for the current process
+	move.d	[$r0+$r1.d], $r0   ; Get PMD
+	beq	2f
+	nop
+	and.w	PAGE_MASK, $r0	   ; Remove PMD flags
+	move.d  [R_MMU_CAUSE], $r1
+	lsrq	PAGE_SHIFT, $r1
+	and.d	0x7ff, $r1         ; Get PTE index into PMD (bit 13-24)
+	move.d	[$r0+$r1.d], $r1   ; Get PTE
+	beq	2f
+	nop
+	;; Store in TLB
+	move.d  $r1, [R_TLB_LO]
+	;; Return
+	movem	[$sp+], $r1
+	pop	$dccr
+	rbf	[$sp+]		; return by popping the CPU status
+
+2:	; PMD or PTE missing, let the mm subsystem fix it up.
+	movem	[$sp+], $r1
+	pop	$dccr
+
+	; Ok, not that easy, pass it on to the mm subsystem
+	; The MMU status record is now on the stack
 	push	$srp		; make a stackframe similar to pt_regs
 	push	$dccr
 	push	$mof
@@ -556,7 +627,7 @@
 
 	move.d	$sp, $r10	; pt_regs argument to handle_mmu_bus_fault
 		
-	jsr	handle_mmu_bus_fault  ; in arch/cris/mm/fault.c
+	jsr	handle_mmu_bus_fault  ; in arch/cris/arch-v10/mm/fault.c
 
 	;; now we need to return through the normal path, we cannot just
 	;; do the RBFexit since we might have killed off the running
@@ -569,48 +640,20 @@
 	nop
 		
 	;; special handlers for breakpoint and NMI
-#if 0			
 hwbreakpoint:
 	push	$dccr
 	di
 	push	$r10
 	push	$r11
-	push	$r12
-	push	$r13
-	clearf	b
-	move	$brp,$r11
-	move.d	[hw_bp_msg],$r10
-	jsr	printk
-	setf	b
-	pop	$r13
-	pop	$r12
-	pop	$r11
-	pop	$r10
-	pop	$dccr
-	retb
-	nop
-#else
-hwbreakpoint:
-	push	$dccr
-	di
-#if 1
-	push	$r10
-	push	$r11
 	move.d	[hw_bp_trig_ptr],$r10
-	move.d	[$r10],$r11
-	cmp.d	42,$r11
-	beq	1f
-	nop
 	move	$brp,$r11
 	move.d	$r11,[$r10+]
 	move.d	$r10,[hw_bp_trig_ptr]
 1:	pop	$r11
 	pop	$r10
-#endif
 	pop	$dccr
 	retb
 	nop
-#endif
 	
 IRQ1_interrupt:
 
@@ -719,29 +762,23 @@
 	push	$r10		; push orig_r10
 	clear.d [$sp=$sp-4]	; frametype == 0, normal frame
 	
-	move.d	irq_shortcuts + 8, $r1
 	moveq	2, $r2		; first bit we care about is the timer0 irq
 	move.d	[R_VECT_MASK_RD], $r0; read the irq bits that triggered the multiple irq
+	move.d	$r0, [R_VECT_MASK_CLR] ; Block all active IRQs
 1:	
 	btst	$r2, $r0	; check for the irq given by bit r2
-	bmi	_do_shortcut	; actually do the shortcut
-	nop
+	bpl	2f
+	move.d  $r2, $r10	; First argument to do_IRQ
+	move.d  $sp, $r11	; second argument to do_IRQ
+	jsr	do_IRQ
+2:
 	addq	1, $r2		; next vector bit
-	addq	4, $r1		; next vector
 	cmp.b	32, $r2
 	bne	1b	; process all irq's up to and including number 31
-	nop
-	
-	;; strange, we didn't get any set vector bits.. oh well, just return
+	moveq	0, $r9  ; make ret_from_intr realise we came from an ir
 	
-	ba	_Rexit
-	nop
-
-_do_shortcut:
-	test.d	[$r1]
-	beq	_Rexit
-	nop
-	jump	[$r1]		; jump to the irq handlers shortcut
+	move.d	$r0, [R_VECT_MASK_SET] ;  Unblock all the IRQs
+	jump    ret_from_intr
 
 do_sigtrap:
 	;; 
@@ -1079,7 +1116,9 @@
 	.long sys_mq_timedreceive	/* 280 */
 	.long sys_mq_notify
 	.long sys_mq_getsetattr
-		
+	.long sys_ni_syscall		/* reserved for kexec */
+	.long sys_waitid
+
         /*
          * NOTE!! This doesn't have to be exact - we just have
          * to make sure we have _enough_ of the "sys_ni_syscall"
diff -Nru a/arch/cris/arch-v10/kernel/irq.c b/arch/cris/arch-v10/kernel/irq.c
--- a/arch/cris/arch-v10/kernel/irq.c	2004-12-24 13:36:49 -08:00
+++ b/arch/cris/arch-v10/kernel/irq.c	2004-12-24 13:36:49 -08:00
@@ -1,4 +1,4 @@
-/* $Id: irq.c,v 1.1 2002/12/11 15:42:02 starvik Exp $
+/* $Id: irq.c,v 1.2 2004/06/09 05:30:27 starvik Exp $
  *
  *	linux/arch/cris/kernel/irq.c
  *
@@ -23,12 +23,8 @@
  */
 
 void
-set_int_vector(int n, irqvectptr addr, irqvectptr saddr)
+set_int_vector(int n, irqvectptr addr)
 {
-	/* remember the shortcut entry point, after the prologue */
-
-	irq_shortcuts[n] = saddr;
-
 	etrax_irv->v[n + 0x20] = (irqvectptr)addr;
 }
 
@@ -106,17 +102,6 @@
 	IRQ31_interrupt
 };
 
-static void (*sinterrupt[NR_IRQS])(void) = {
-	NULL, NULL, sIRQ2_interrupt, sIRQ3_interrupt,
-	sIRQ4_interrupt, sIRQ5_interrupt, sIRQ6_interrupt, sIRQ7_interrupt,
-	sIRQ8_interrupt, sIRQ9_interrupt, sIRQ10_interrupt, sIRQ11_interrupt,
-	sIRQ12_interrupt, sIRQ13_interrupt, NULL, NULL,	
-	sIRQ16_interrupt, sIRQ17_interrupt, sIRQ18_interrupt, sIRQ19_interrupt,	
-	sIRQ20_interrupt, sIRQ21_interrupt, sIRQ22_interrupt, sIRQ23_interrupt,	
-	sIRQ24_interrupt, sIRQ25_interrupt, NULL, NULL, NULL, NULL, NULL,
-	sIRQ31_interrupt
-};
-
 static void (*bad_interrupt[NR_IRQS])(void) = {
         NULL, NULL,
 	NULL, bad_IRQ3_interrupt,
@@ -137,12 +122,12 @@
 
 void arch_setup_irq(int irq)
 {
-  set_int_vector(irq, interrupt[irq], sinterrupt[irq]);
+  set_int_vector(irq, interrupt[irq]);
 }
 
 void arch_free_irq(int irq)
 {
-  set_int_vector(irq, bad_interrupt[irq], 0);
+  set_int_vector(irq, bad_interrupt[irq]);
 }
 
 void weird_irq(void);
@@ -187,20 +172,20 @@
         
 	/* set all etrax irq's to the bad handlers */
 	for (i = 2; i < NR_IRQS; i++)
-		set_int_vector(i, bad_interrupt[i], 0);
+		set_int_vector(i, bad_interrupt[i]);
         
 	/* except IRQ 15 which is the multiple-IRQ handler on Etrax100 */
 
-	set_int_vector(15, multiple_interrupt, 0);
+	set_int_vector(15, multiple_interrupt);
 	
 	/* 0 and 1 which are special breakpoint/NMI traps */
 
-	set_int_vector(0, hwbreakpoint, 0);
-	set_int_vector(1, IRQ1_interrupt, 0);
+	set_int_vector(0, hwbreakpoint);
+	set_int_vector(1, IRQ1_interrupt);
 
 	/* and irq 14 which is the mmu bus fault handler */
 
-	set_int_vector(14, mmu_bus_fault, 0);
+	set_int_vector(14, mmu_bus_fault);
 
 	/* setup the system-call trap, which is reached by BREAK 13 */
 
diff -Nru a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
--- a/arch/cris/arch-v10/kernel/kgdb.c	2004-12-24 13:37:19 -08:00
+++ b/arch/cris/arch-v10/kernel/kgdb.c	2004-12-24 13:37:19 -08:00
@@ -18,6 +18,9 @@
 *! Jul 21 1999  Bjorn Wesen     eLinux port
 *!
 *! $Log: kgdb.c,v $
+*! Revision 1.5  2004/10/07 13:59:08  starvik
+*! Corrected call to set_int_vector
+*!
 *! Revision 1.4  2003/04/09 05:20:44  starvik
 *! Merge of Linux 2.5.67
 *!
@@ -68,7 +71,7 @@
 *!
 *!---------------------------------------------------------------------------
 *!
-*! $Id: kgdb.c,v 1.4 2003/04/09 05:20:44 starvik Exp $
+*! $Id: kgdb.c,v 1.5 2004/10/07 13:59:08 starvik Exp $
 *!
 *! (C) Copyright 1999, Axis Communications AB, LUND, SWEDEN
 *!
@@ -1557,7 +1560,7 @@
 	/* could initialize debug port as well but it's done in head.S already... */
 
         /* breakpoint handler is now set in irq.c */
-	set_int_vector(8, kgdb_handle_serial, 0);
+	set_int_vector(8, kgdb_handle_serial);
 	
 	enableDebugIRQ();
 }
diff -Nru a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c
--- a/arch/cris/arch-v10/kernel/process.c	2004-12-24 13:37:00 -08:00
+++ b/arch/cris/arch-v10/kernel/process.c	2004-12-24 13:37:00 -08:00
@@ -1,4 +1,4 @@
-/* $Id: process.c,v 1.6 2004/05/11 12:28:25 starvik Exp $
+/* $Id: process.c,v 1.9 2004/10/19 13:07:37 starvik Exp $
  * 
  *  linux/arch/cris/kernel/process.c
  *
@@ -34,6 +34,15 @@
 #endif
 }
 
+/*
+ * Free current thread data structures etc..
+ */
+
+void exit_thread(void)
+{
+	/* Nothing needs to be done.  */
+}
+
 /* if the watchdog is enabled, we can simply disable interrupts and go
  * into an eternal loop, and the watchdog will reset the CPU after 0.1s
  * if on the other hand the watchdog wasn't enabled, we just enable it and wait
@@ -123,7 +132,7 @@
 	*childregs = *regs;  /* struct copy of pt_regs */
         
         p->set_child_tid = p->clear_child_tid = NULL;
-	
+
         childregs->r10 = 0;  /* child returns 0 after a fork/clone */
 	
 	/* put the switch stack right below the pt_regs */
@@ -214,13 +223,6 @@
 	return error;
 }
 
-/*
- * These bracket the sleeping functions..
- */
-
-#define first_sched	((unsigned long)__sched_text_start)
-#define last_sched	((unsigned long)__sched_text_end)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 #if 0
@@ -241,8 +243,8 @@
                 if (ebp < stack_page || ebp > 8184+stack_page)
                         return 0;
                 eip = *(unsigned long *) (ebp+4);
-                if (eip < first_sched || eip >= last_sched)
-                        return eip;
+		if (!in_sched_functions(eip))
+			return eip;
                 ebp = *(unsigned long *) ebp;
         } while (count++ < 16);
 #endif
diff -Nru a/arch/cris/arch-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c
--- a/arch/cris/arch-v10/kernel/ptrace.c	2004-12-24 13:37:29 -08:00
+++ b/arch/cris/arch-v10/kernel/ptrace.c	2004-12-24 13:37:29 -08:00
@@ -23,8 +23,37 @@
  */
 #define DCCR_MASK 0x0000001f     /* XNZVC */
 
-extern inline long get_reg(struct task_struct *, unsigned int);
-extern inline long put_reg(struct task_struct *, unsigned int, unsigned long);
+/*
+ * Get contents of register REGNO in task TASK.
+ */
+inline long get_reg(struct task_struct *task, unsigned int regno)
+{
+	/* USP is a special case, it's not in the pt_regs struct but
+	 * in the tasks thread struct
+	 */
+
+	if (regno == PT_USP)
+		return task->thread.usp;
+	else if (regno < PT_MAX)
+		return ((unsigned long *)user_regs(task->thread_info))[regno];
+	else
+		return 0;
+}
+
+/*
+ * Write contents of register REGNO in task TASK.
+ */
+inline int put_reg(struct task_struct *task, unsigned int regno,
+			  unsigned long data)
+{
+	if (regno == PT_USP)
+		task->thread.usp = data;
+	else if (regno < PT_MAX)
+		((unsigned long *)user_regs(task->thread_info))[regno] = data;
+	else
+		return -1;
+	return 0;
+}
 
 /*
  * Called by kernel/ptrace.c when detaching.
@@ -50,6 +79,7 @@
 {
 	struct task_struct *child;
 	int ret;
+	unsigned long __user *datap = (unsigned long __user *)data;
 
 	lock_kernel();
 	ret = -EPERM;
@@ -102,7 +132,7 @@
 			if (copied != sizeof(tmp))
 				break;
 			
-			ret = put_user(tmp,(unsigned long *) data);
+			ret = put_user(tmp,datap);
 			break;
 		}
 
@@ -115,7 +145,7 @@
 				break;
 
 			tmp = get_reg(child, addr >> 2);
-			ret = put_user(tmp, (unsigned long *)data);
+			ret = put_user(tmp, datap);
 			break;
 		}
 		
@@ -213,7 +243,7 @@
 			for (i = 0; i <= PT_MAX; i++) {
 				tmp = get_reg(child, i);
 				
-				if (put_user(tmp, (unsigned long *) data)) {
+				if (put_user(tmp, datap)) {
 					ret = -EFAULT;
 					goto out_tsk;
 				}
@@ -231,7 +261,7 @@
 			unsigned long tmp;
 			
 			for (i = 0; i <= PT_MAX; i++) {
-				if (get_user(tmp, (unsigned long *) data)) {
+				if (get_user(tmp, datap)) {
 					ret = -EFAULT;
 					goto out_tsk;
 				}
diff -Nru a/arch/cris/arch-v10/kernel/signal.c b/arch/cris/arch-v10/kernel/signal.c
--- a/arch/cris/arch-v10/kernel/signal.c	2004-12-24 13:36:17 -08:00
+++ b/arch/cris/arch-v10/kernel/signal.c	2004-12-24 13:36:17 -08:00
@@ -264,7 +264,6 @@
 {
 	struct rt_sigframe __user *frame = (struct rt_sigframe *)rdusp();
 	sigset_t set;
-	stack_t st;
 
         /*
          * Since we stacked the signal on a dword boundary,
@@ -288,11 +287,8 @@
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
 		goto badframe;
 
-	if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
+	if (do_sigaltstack(&frame->uc.uc_stack, NULL, rdusp()) == -EFAULT)
 		goto badframe;
-	/* It is more difficult to avoid calling this function than to
-	   call it and ignore errors.  */
-	do_sigaltstack(&st, NULL, rdusp());
 
 	return regs->r10;
 
@@ -388,9 +384,9 @@
 		/* trampoline - the desired return ip is the retcode itself */
 		return_ip = (unsigned long)&frame->retcode;
 		/* This is movu.w __NR_sigreturn, r9; break 13; */
-		err |= __put_user(0x9c5f,         (short *)(frame->retcode+0));
-		err |= __put_user(__NR_sigreturn, (short *)(frame->retcode+2));
-		err |= __put_user(0xe93d,         (short *)(frame->retcode+4));
+		err |= __put_user(0x9c5f,         (short __user*)(frame->retcode+0));
+		err |= __put_user(__NR_sigreturn, (short __user*)(frame->retcode+2));
+		err |= __put_user(0xe93d,         (short __user*)(frame->retcode+4));
 	}
 
 	if (err)
@@ -448,9 +444,9 @@
 		/* trampoline - the desired return ip is the retcode itself */
 		return_ip = (unsigned long)&frame->retcode;
 		/* This is movu.w __NR_rt_sigreturn, r9; break 13; */
-		err |= __put_user(0x9c5f,            (short *)(frame->retcode+0));
-		err |= __put_user(__NR_rt_sigreturn, (short *)(frame->retcode+2));
-		err |= __put_user(0xe93d,            (short *)(frame->retcode+4));
+		err |= __put_user(0x9c5f,            (short __user*)(frame->retcode+0));
+		err |= __put_user(__NR_rt_sigreturn, (short __user*)(frame->retcode+2));
+		err |= __put_user(0xe93d,            (short __user*)(frame->retcode+4));
 	}
 
 	if (err)
@@ -482,10 +478,9 @@
 
 extern inline void
 handle_signal(int canrestart, unsigned long sig,
-	      siginfo_t *info, sigset_t *oldset, struct pt_regs * regs)
+	      siginfo_t *info, struct k_sigaction *ka,
+              sigset_t *oldset, struct pt_regs * regs)
 {
-	struct k_sigaction *ka = &current->sighand->action[sig-1];
-
 	/* Are we from a system call? */
 	if (canrestart) {
 		/* If so, check system call restarting.. */
@@ -547,6 +542,7 @@
 {
 	siginfo_t info;
 	int signr;
+        struct k_sigaction ka;
 
 	/*
 	 * We want the common case to go fast, which
@@ -560,10 +556,10 @@
 	if (!oldset)
 		oldset = &current->blocked;
 
-	signr = get_signal_to_deliver(&info, regs, NULL);
+	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
 	if (signr > 0) {
 		/* Whee!  Actually deliver the signal.  */
-		handle_signal(canrestart, signr, &info, oldset, regs);
+		handle_signal(canrestart, signr, &info, &ka, oldset, regs);
 		return 1;
 	}
 
diff -Nru a/arch/cris/arch-v10/kernel/time.c b/arch/cris/arch-v10/kernel/time.c
--- a/arch/cris/arch-v10/kernel/time.c	2004-12-24 13:37:02 -08:00
+++ b/arch/cris/arch-v10/kernel/time.c	2004-12-24 13:37:02 -08:00
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.3 2004/06/01 05:38:42 starvik Exp $
+/* $Id: time.c,v 1.5 2004/09/29 06:12:46 starvik Exp $
  *
  *  linux/arch/cris/arch-v10/kernel/time.c
  *
@@ -200,6 +200,8 @@
 
 //static unsigned short myjiff; /* used by our debug routine print_timestamp */
 
+extern void cris_do_profile(struct pt_regs *regs);
+
 static inline irqreturn_t
 timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
@@ -228,6 +230,8 @@
 
 	do_timer(regs);
 	
+        cris_do_profile(regs); /* Save profiling information */
+
 	/*
 	 * If we have an externally synchronized Linux clock, then update
 	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
diff -Nru a/arch/cris/arch-v10/mm/fault.c b/arch/cris/arch-v10/mm/fault.c
--- a/arch/cris/arch-v10/mm/fault.c	2004-12-24 13:37:29 -08:00
+++ b/arch/cris/arch-v10/mm/fault.c	2004-12-24 13:37:29 -08:00
@@ -40,23 +40,25 @@
 handle_mmu_bus_fault(struct pt_regs *regs)
 {
 	int cause;
-#ifdef DEBUG
 	int select;
+#ifdef DEBUG
 	int index;
 	int page_id;
 	int acc, inv;
 #endif
-	int miss, we, writeac;
+	pgd_t* pgd = (pgd_t*)current_pgd;
 	pmd_t *pmd;
 	pte_t pte;
+	int miss, we, writeac;
 	unsigned long address;
+	unsigned long flags;
 
 	cause = *R_MMU_CAUSE;
 
 	address = cause & PAGE_MASK; /* get faulting address */
+	select = *R_TLB_SELECT;
 
 #ifdef DEBUG
-	select = *R_TLB_SELECT;
 	page_id = IO_EXTRACT(R_MMU_CAUSE,  page_id,   cause);
 	acc     = IO_EXTRACT(R_MMU_CAUSE,  acc_excp,  cause);
 	inv     = IO_EXTRACT(R_MMU_CAUSE,  inv_excp,  cause);  
@@ -66,85 +68,31 @@
 	we      = IO_EXTRACT(R_MMU_CAUSE,  we_excp,   cause);
 	writeac = IO_EXTRACT(R_MMU_CAUSE,  wr_rd,     cause);
 
-	/* ETRAX 100LX TR89 bugfix: if the second half of an unaligned
-	 * write causes a MMU-fault, it will not be restarted correctly.
-	 * This could happen if a write crosses a page-boundary and the
-	 * second page is not yet COW'ed or even loaded. The workaround
-	 * is to clear the unaligned bit in the CPU status record, so 
-	 * that the CPU will rerun both the first and second halves of
-	 * the instruction. This will not have any sideeffects unless
-	 * the first half goes to any device or memory that can't be
-	 * written twice, and which is mapped through the MMU.
-	 *
-	 * We only need to do this for writes.
-	 */
-
-	if(writeac)
-		regs->csrinstr &= ~(1 << 5);
-	
 	D(printk("bus_fault from IRP 0x%lx: addr 0x%lx, miss %d, inv %d, we %d, acc %d, dx %d pid %d\n",
 		 regs->irp, address, miss, inv, we, acc, index, page_id));
 
-	/* for a miss, we need to reload the TLB entry */
-
-	if (miss) {
-		/* see if the pte exists at all
-		 * refer through current_pgd, dont use mm->pgd
-		 */
-
-		pmd = (pmd_t *)(current_pgd + pgd_index(address));
-		if (pmd_none(*pmd)) {
-			do_page_fault(address, regs, 0, writeac);
-			return;
-		}
-		if (pmd_bad(*pmd)) {
-			printk("bad pgdir entry 0x%lx at 0x%p\n", *(unsigned long*)pmd, pmd);
-			pmd_clear(pmd);
-			return;
-		}
-		pte = *pte_offset_kernel(pmd, address);
-		if (!pte_present(pte)) {
-			do_page_fault(address, regs, 0, writeac);
-			return;
-		}
-
-#ifdef DEBUG
-		printk(" found pte %lx pg %p ", pte_val(pte), pte_page(pte));
-		if (pte_val(pte) & _PAGE_SILENT_WRITE)
-			printk("Silent-W ");
-		if (pte_val(pte) & _PAGE_KERNEL)
-			printk("Kernel ");
-		if (pte_val(pte) & _PAGE_SILENT_READ)
-			printk("Silent-R ");
-		if (pte_val(pte) & _PAGE_GLOBAL)
-			printk("Global ");
-		if (pte_val(pte) & _PAGE_PRESENT)
-			printk("Present ");
-		if (pte_val(pte) & _PAGE_ACCESSED)
-			printk("Accessed ");
-		if (pte_val(pte) & _PAGE_MODIFIED)
-			printk("Modified ");
-		if (pte_val(pte) & _PAGE_READ)
-			printk("Readable ");
-		if (pte_val(pte) & _PAGE_WRITE)
-			printk("Writeable ");
-		printk("\n");
-#endif
-
-		/* load up the chosen TLB entry
-		 * this assumes the pte format is the same as the TLB_LO layout.
-		 *
-		 * the write to R_TLB_LO also writes the vpn and page_id fields from
-		 * R_MMU_CAUSE, which we in this case obviously want to keep
-		 */
-
-		*R_TLB_LO = pte_val(pte);
-
-		return;
-	}
-
 	/* leave it to the MM system fault handler */
-	do_page_fault(address, regs, 1, we);
+	if (miss)
+		do_page_fault(address, regs, 0, writeac);
+        else
+		do_page_fault(address, regs, 1, we);
+
+        /* Reload TLB with new entry to avoid an extra miss exception.
+	 * do_page_fault may have flushed the TLB so we have to restore
+	 * the MMU registers.
+	 */
+	local_save_flags(flags);
+	local_irq_disable();
+	pmd = (pmd_t *)(pgd + pgd_index(address));
+	if (pmd_none(*pmd))
+		return;
+	pte = *pte_offset_kernel(pmd, address);
+	if (!pte_present(pte))
+		return;
+	*R_TLB_SELECT = select;
+	*R_TLB_HI = cause;
+	*R_TLB_LO = pte_val(pte);
+	local_irq_restore(flags);
 }
 
 /* Called from arch/cris/mm/fault.c to find fixup code. */
diff -Nru a/arch/cris/arch-v10/mm/tlb.c b/arch/cris/arch-v10/mm/tlb.c
--- a/arch/cris/arch-v10/mm/tlb.c	2004-12-24 13:37:30 -08:00
+++ b/arch/cris/arch-v10/mm/tlb.c	2004-12-24 13:37:30 -08:00
@@ -65,7 +65,7 @@
 flush_tlb_mm(struct mm_struct *mm)
 {
 	int i;
-	int page_id = mm->context;
+	int page_id = mm->context.page_id;
 	unsigned long flags;
 
 	D(printk("tlb: flush mm context %d (%p)\n", page_id, mm));
@@ -103,7 +103,7 @@
 	       unsigned long addr)
 {
 	struct mm_struct *mm = vma->vm_mm;
-	int page_id = mm->context;
+	int page_id = mm->context.page_id;
 	int i;
 	unsigned long flags;
 
@@ -147,7 +147,7 @@
 		unsigned long end)
 {
 	struct mm_struct *mm = vma->vm_mm;
-	int page_id = mm->context;
+	int page_id = mm->context.page_id;
 	int i;
 	unsigned long flags;
 
@@ -208,6 +208,18 @@
 }
 #endif
 
+/*
+ * Initialize the context related info for a new mm_struct
+ * instance.
+ */
+
+int
+init_new_context(struct task_struct *tsk, struct mm_struct *mm)
+{
+	mm->context.page_id = NO_CONTEXT;
+	return 0;
+}
+
 /* called in schedule() just before actually doing the switch_to */
 
 void 
@@ -231,6 +243,6 @@
 	
 	D(printk("switching mmu_context to %d (%p)\n", next->context, next));
 
-	*R_MMU_CONTEXT = IO_FIELD(R_MMU_CONTEXT, page_id, next->context);
+	*R_MMU_CONTEXT = IO_FIELD(R_MMU_CONTEXT, page_id, next->context.page_id);
 }
 
diff -Nru a/arch/cris/arch-v10/vmlinux.lds.S b/arch/cris/arch-v10/vmlinux.lds.S
--- a/arch/cris/arch-v10/vmlinux.lds.S	2004-12-24 13:36:48 -08:00
+++ b/arch/cris/arch-v10/vmlinux.lds.S	2004-12-24 13:36:48 -08:00
@@ -26,6 +26,7 @@
 	.text : {
 		*(.text)
 		SCHED_TEXT
+		LOCK_TEXT
 		*(.fixup)
 		*(.text.__*)
 	}
diff -Nru a/arch/cris/kernel/irq.c b/arch/cris/kernel/irq.c
--- a/arch/cris/kernel/irq.c	2004-12-24 13:37:30 -08:00
+++ b/arch/cris/kernel/irq.c	2004-12-24 13:37:30 -08:00
@@ -36,9 +36,9 @@
 #include <linux/init.h>
 #include <linux/seq_file.h>
 #include <linux/errno.h>
+#include <linux/bitops.h>
 
 #include <asm/io.h>
-#include <asm/bitops.h>
 
 /* Defined in arch specific irq.c */
 extern void arch_setup_irq(int irq);
diff -Nru a/arch/h8300/kernel/ptrace.c b/arch/h8300/kernel/ptrace.c
--- a/arch/h8300/kernel/ptrace.c	2004-12-24 13:36:32 -08:00
+++ b/arch/h8300/kernel/ptrace.c	2004-12-24 13:36:32 -08:00
@@ -192,7 +192,7 @@
 		case PTRACE_KILL: {
 
 			ret = 0;
-			if (child->state == TASK_ZOMBIE) /* already dead */
+			if (child->exit_state == EXIT_ZOMBIE) /* already dead */
 				break;
 			child->exit_code = SIGKILL;
 			h8300_disable_trace(child);
diff -Nru a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
--- a/arch/h8300/kernel/setup.c	2004-12-24 13:36:18 -08:00
+++ b/arch/h8300/kernel/setup.c	2004-12-24 13:36:18 -08:00
@@ -218,7 +218,7 @@
 		   "BogoMips:\t%lu.%02lu\n"
 		   "Calibration:\t%lu loops\n",
 	           cpu,mode,
-		   clockfreq/100,clockfreq%100,
+		   clockfreq/1000,clockfreq%1000,
 		   (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
 		   (loops_per_jiffy*HZ));
 
diff -Nru a/arch/h8300/kernel/signal.c b/arch/h8300/kernel/signal.c
--- a/arch/h8300/kernel/signal.c	2004-12-24 13:36:49 -08:00
+++ b/arch/h8300/kernel/signal.c	2004-12-24 13:36:49 -08:00
@@ -38,6 +38,7 @@
 #include <linux/personality.h>
 #include <linux/tty.h>
 #include <linux/binfmts.h>
+#include <linux/suspend.h>
 
 #include <asm/setup.h>
 #include <asm/uaccess.h>
@@ -47,7 +48,7 @@
 
 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
 
-asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs);
+asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset);
 
 /*
  * Atomically swap in the new signal mask, and wait for a signal.
@@ -68,7 +69,7 @@
 	while (1) {
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();
-		if (do_signal(&saveset, regs))
+		if (do_signal(regs, &saveset))
 			return -EINTR;
 	}
 }
@@ -98,7 +99,7 @@
 	while (1) {
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();
-		if (do_signal(&saveset, regs))
+		if (do_signal(regs, &saveset))
 			return -EINTR;
 	}
 }
@@ -161,6 +162,7 @@
 	unsigned char retcode[8];
 	unsigned long extramask[_NSIG_WORDS-1];
 	struct sigcontext sc;
+	int sig;
 } __attribute__((aligned(2),packed));
 
 struct rt_sigframe
@@ -172,73 +174,44 @@
 #endif
 	long dummy_pc;
 	char *pretcode;
+	struct siginfo *pinfo;
+	void *puc;
 	unsigned char retcode[8];
 	struct siginfo info;
 	struct ucontext uc;
+	int sig;
 } __attribute__((aligned(2),packed));
 
 static inline int
-restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc, void *fp,
+restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc,
 		   int *pd0)
 {
-	struct sigcontext context;
 	int err = 0;
-
-	/* get previous context */
-	if (copy_from_user(&context, usc, sizeof(context)))
-		goto badframe;
-	
-	/* restore passed registers */
-	regs->er1 = context.sc_er1;
-	regs->er2 = context.sc_er2;
-	regs->er3 = context.sc_er3;
-	regs->er5 = context.sc_er5;
-	regs->ccr = (regs->ccr & 0x10)|(context.sc_ccr & 0xef);
-	regs->pc = context.sc_pc;
+	unsigned int ccr;
+	unsigned int usp;
+	unsigned int er0;
+
+	/* Always make any pending restarted system calls return -EINTR */
+	current_thread_info()->restart_block.fn = do_no_restart_syscall;
+
+#define COPY(r) err |= __get_user(regs->r, &usc->sc_##r)    /* restore passed registers */
+	COPY(er1);
+	COPY(er2);
+	COPY(er3);
+	COPY(er5);
+	COPY(pc);
+	ccr = regs->ccr & 0x10;
+	COPY(ccr);
+#undef COPY
+	regs->ccr &= 0xef;
+	regs->ccr |= ccr;
 	regs->orig_er0 = -1;		/* disable syscall checks */
-	wrusp(context.sc_usp);
-
-	*pd0 = context.sc_er0;
-	return err;
-
-badframe:
-	return 1;
-}
-
-static inline int
-rt_restore_ucontext(struct pt_regs *regs, struct ucontext *uc, int *pd0)
-{
-	int temp;
-	greg_t *gregs = uc->uc_mcontext.gregs;
-	unsigned long usp;
-	int err;
-
-	err = __get_user(temp, &uc->uc_mcontext.version);
-	if (temp != MCONTEXT_VERSION)
-		goto badframe;
-	/* restore passed registers */
-	err |= __get_user(regs->er0, &gregs[0]);
-	err |= __get_user(regs->er1, &gregs[1]);
-	err |= __get_user(regs->er2, &gregs[2]);
-	err |= __get_user(regs->er3, &gregs[3]);
-	err |= __get_user(regs->er4, &gregs[4]);
-	err |= __get_user(regs->er5, &gregs[5]);
-	err |= __get_user(regs->er6, &gregs[6]);
-	err |= __get_user(usp, &gregs[7]);
+	err |= __get_user(usp, &usc->sc_usp);
 	wrusp(usp);
-	err |= __get_user(regs->pc, &gregs[8]);
-	err |= __get_user(temp, &gregs[9]);
-	regs->ccr = (regs->ccr & 0x10) | (temp & 0xef);
-	regs->orig_er0 = -1;		/* disable syscall checks */
 
-	if (do_sigaltstack(&uc->uc_stack, NULL, usp) == -EFAULT)
-		goto badframe;
-
-	*pd0 = regs->er0;
+	err |= __get_user(er0, &usc->sc_er0);
+	*pd0 = er0;
 	return err;
-
-badframe:
-	return 1;
 }
 
 asmlinkage int do_sigreturn(unsigned long __unused,...)
@@ -263,7 +236,7 @@
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 	
-	if (restore_sigcontext(regs, &frame->sc, frame + 1, &er0))
+	if (restore_sigcontext(regs, &frame->sc, &er0))
 		goto badframe;
 	return er0;
 
@@ -291,8 +264,12 @@
 	recalc_sigpending();
 	spin_lock_irq(&current->sighand->siglock);
 	
-	if (rt_restore_ucontext(regs, &frame->uc, &er0))
+	if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &er0))
+		goto badframe;
+
+	if (do_sigaltstack(&frame->uc.uc_stack, NULL, usp) == -EFAULT)
 		goto badframe;
+
 	return er0;
 
 badframe:
@@ -300,36 +277,23 @@
 	return 0;
 }
 
-static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
+static int setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
 			     unsigned long mask)
 {
-	sc->sc_mask = mask;
-	sc->sc_usp = rdusp();
-	sc->sc_er0 = regs->er0;
-	sc->sc_er1 = regs->er1;
-	sc->sc_er2 = regs->er2;
-	sc->sc_er3 = regs->er3;
-	sc->sc_er5 = regs->er5;
-	sc->sc_ccr = regs->ccr;
-	sc->sc_pc = regs->pc;
-}
-
-static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)
-{
-	greg_t *gregs = uc->uc_mcontext.gregs;
 	int err = 0;
 
-	err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version);
-	err |= __put_user(regs->er0, &gregs[0]);
-	err |= __put_user(regs->er1, &gregs[1]);
-	err |= __put_user(regs->er2, &gregs[2]);
-	err |= __put_user(regs->er3, &gregs[3]);
-	err |= __put_user(regs->er4, &gregs[4]);
-	err |= __put_user(regs->er5, &gregs[5]);
-	err |= __put_user(regs->er6, &gregs[6]);
-	err |= __put_user(rdusp(), &gregs[7]);
-	err |= __put_user(regs->pc, &gregs[8]);
-	err |= __put_user(regs->ccr, &gregs[9]);
+	err |= __put_user(regs->er0, &sc->sc_er0);
+	err |= __put_user(regs->er1, &sc->sc_er1);
+	err |= __put_user(regs->er2, &sc->sc_er2);
+	err |= __put_user(regs->er3, &sc->sc_er3);
+	err |= __put_user(regs->er4, &sc->sc_er4);
+	err |= __put_user(regs->er5, &sc->sc_er5);
+	err |= __put_user(regs->er6, &sc->sc_er6);
+	err |= __put_user(rdusp(),   &sc->sc_usp);
+	err |= __put_user(regs->pc,  &sc->sc_pc);
+	err |= __put_user(regs->ccr, &sc->sc_ccr);
+	err |= __put_user(mask,      &sc->sc_mask);
+
 	return err;
 }
 
@@ -353,26 +317,48 @@
 			 sigset_t *set, struct pt_regs *regs)
 {
 	struct sigframe *frame;
-	struct sigcontext context;
 	int err = 0;
+	int usig;
+	unsigned char *ret;
 
 	frame = get_sigframe(ka, regs, sizeof(*frame));
 
-	if (_NSIG_WORDS > 1)
+	if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
+		goto give_sigsegv;
+
+	usig = current_thread_info()->exec_domain
+		&& current_thread_info()->exec_domain->signal_invmap
+		&& sig < 32
+		? current_thread_info()->exec_domain->signal_invmap[sig]
+		: sig;
+
+	err |= __put_user(usig, &frame->sig);
+	if (err)
+		goto give_sigsegv;
+
+	err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
+	if (err)
+		goto give_sigsegv;
+
+	if (_NSIG_WORDS > 1) {
 		err |= copy_to_user(frame->extramask, &set->sig[1],
 				    sizeof(frame->extramask));
+		if (err)
+			goto give_sigsegv;
+	}
 
-	setup_sigcontext(&context, regs, set->sig[0]);
-	err |= copy_to_user (&frame->sc, &context, sizeof(context));
+	ret = frame->retcode;
+	if (ka->sa.sa_flags & SA_RESTORER)
+		ret = (unsigned char *)(ka->sa.sa_restorer);
+	else {
+		/* sub.l er0,er0; mov.b #__NR_sigreturn,r0l; trapa #0 */
+		err != __put_user(0x1a80f800 + (__NR_sigreturn & 0xff),
+				  (unsigned long *)(frame->retcode + 0));
+		err |= __put_user(0x5700, (unsigned short *)(frame->retcode + 4));
+	}
 
 	/* Set up to return from userspace.  */
-	err |= __put_user(frame->retcode, &frame->pretcode);
-
-	/* sub.l er0,er0; mov.b #__NR_sigreturn,r0l; trapa #0 */
-	err != __put_user(0x1a80f800 + (__NR_sigreturn & 0xff),
-			(unsigned long *)(frame->retcode + 0));
-	err |= __put_user(0x5700, (unsigned short *)(frame->retcode + 4));
-
+	err |= __put_user(ret, &frame->pretcode);
 
 	if (err)
 		goto give_sigsegv;
@@ -399,10 +385,29 @@
 {
 	struct rt_sigframe *frame;
 	int err = 0;
+	int usig;
+	unsigned char *ret;
 
 	frame = get_sigframe(ka, regs, sizeof(*frame));
 
+	if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
+		goto give_sigsegv;
+
+	usig = current_thread_info()->exec_domain
+		&& current_thread_info()->exec_domain->signal_invmap
+		&& sig < 32
+		? current_thread_info()->exec_domain->signal_invmap[sig]
+		: sig;
+
+	err |= __put_user(usig, &frame->sig);
+	if (err)
+		goto give_sigsegv;
+
+	err |= __put_user(&frame->info, &frame->pinfo);
+	err |= __put_user(&frame->uc, &frame->puc);
 	err |= copy_siginfo_to_user(&frame->info, info);
+	if (err)
+		goto give_sigsegv;
 
 	/* Create the ucontext.  */
 	err |= __put_user(0, &frame->uc.uc_flags);
@@ -412,16 +417,22 @@
 	err |= __put_user(sas_ss_flags(rdusp()),
 			  &frame->uc.uc_stack.ss_flags);
 	err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
-	err |= rt_setup_ucontext(&frame->uc, regs);
+	err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]);
 	err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set));
+	if (err)
+		goto give_sigsegv;
 
 	/* Set up to return from userspace.  */
-	err |= __put_user(frame->retcode, &frame->pretcode);
-
-	/* sub.l er0,er0; mov.b #__NR_rt_sigreturn,r0l; trapa #0 */
-	err != __put_user(0x1a80f800 + (__NR_rt_sigreturn & 0xff),
-			(long *)(frame->retcode + 0));
-	err |= __put_user(0x5700, (short *)(frame->retcode + 4));
+	ret = frame->retcode;
+	if (ka->sa.sa_flags & SA_RESTORER)
+		ret = (unsigned char *)(ka->sa.sa_restorer);
+	else {
+		/* sub.l er0,er0; mov.b #__NR_sigreturn,r0l; trapa #0 */
+		err != __put_user(0x1a80f800 + (__NR_sigreturn & 0xff),
+				  (unsigned long *)(frame->retcode + 0));
+		err |= __put_user(0x5700, (unsigned short *)(frame->retcode + 4));
+	}
+	err |= __put_user(ret, &frame->pretcode);
 
 	if (err)
 		goto give_sigsegv;
@@ -444,41 +455,32 @@
 	force_sigsegv(sig, current);
 }
 
-static inline void
-handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
-{
-	switch (regs->er0) {
-	case -ERESTARTNOHAND:
-		if (!has_handler)
-			goto do_restart;
-		regs->er0 = -EINTR;
-		break;
-
-	case -ERESTARTSYS:
-		if (has_handler && !(ka->sa.sa_flags & SA_RESTART)) {
-			regs->er0 = -EINTR;
-			break;
-		}
-	/* fallthrough */
-	case -ERESTARTNOINTR:
-	do_restart:
-		regs->er0 = regs->orig_er0;
-		regs->pc -= 2;
-		break;
-	}
-}
-
 /*
  * OK, we're invoking a handler
  */
 static void
-handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
-	      sigset_t *oldset, struct pt_regs *regs)
+handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
+	      sigset_t *oldset,	struct pt_regs * regs)
 {
 	/* are we from a system call? */
-	if (regs->orig_er0 >= 0)
-		/* If so, check system call restarting.. */
-		handle_restart(regs, ka, 1);
+	if (regs->orig_er0 >= 0) {
+		switch (regs->er0) {
+		        case -ERESTART_RESTARTBLOCK:
+			case -ERESTARTNOHAND:
+				regs->er0 = -EINTR;
+				break;
+
+			case -ERESTARTSYS:
+				if (!(ka->sa.sa_flags & SA_RESTART)) {
+					regs->er0 = -EINTR;
+					break;
+				}
+			/* fallthrough */
+			case -ERESTARTNOINTR:
+				regs->er0 = regs->orig_er0;
+				regs->pc -= 2;
+		}
+	}
 
 	/* set up the stack frame */
 	if (ka->sa.sa_flags & SA_SIGINFO)
@@ -486,9 +488,6 @@
 	else
 		setup_frame(sig, ka, oldset, regs);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
-
 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
@@ -502,137 +501,52 @@
  * Note that 'init' is a special process: it doesn't get signals it doesn't
  * want to handle. Thus you cannot kill init even with a SIGKILL even by
  * mistake.
- *
- * Note that we go through the signals twice: once to check the signals
- * that the kernel can handle, and then we build all the user-level signal
- * handling stack-frames in one go after that.
  */
-asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs)
+asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset)
 {
 	siginfo_t info;
-	struct k_sigaction *ka;
+	int signr;
+	struct k_sigaction ka;
+
+	/*
+	 * We want the common case to go fast, which
+	 * is why we may in certain cases get here from
+	 * kernel mode. Just return without doing anything
+	 * if so.
+	 */
+	if ((regs->ccr & 0x10))
+		return 1;
+
+	if (current->flags & PF_FREEZE) {
+		refrigerator(0);
+		goto no_signal;
+	}
 
 	current->thread.esp0 = (unsigned long) regs;
 
 	if (!oldset)
 		oldset = &current->blocked;
 
-	for (;;) {
-		int signr;
-
-		signr = get_signal_to_deliver(&info, regs, NULL);
-
-		if (!signr)
-			break;
-
-		if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
-			current->exit_code = signr;
-			current->state = TASK_STOPPED;
-
-			/* Did we come from a system call? */
-			if (regs->orig_er0 >= 0) {
-				/* Restart the system call the same way as
-				   if the process were not traced.  */
-				struct k_sigaction *ka =
-					&current->sighand->action[signr-1];
-				int has_handler =
-					(ka->sa.sa_handler != SIG_IGN &&
-					 ka->sa.sa_handler != SIG_DFL);
-				handle_restart(regs, ka, has_handler);
-			}
-			notify_parent(current, SIGCHLD);
-			schedule();
-
-			/* We're back.  Did the debugger cancel the sig?  */
-			if (!(signr = current->exit_code)) {
-			discard_frame:
-			    continue;
-			}
-			current->exit_code = 0;
-
-			/* The debugger continued.  Ignore SIGSTOP.  */
-			if (signr == SIGSTOP)
-				goto discard_frame;
-
-			/* Update the siginfo structure.  Is this good?  */
-			if (signr != info.si_signo) {
-				info.si_signo = signr;
-				info.si_errno = 0;
-				info.si_code = SI_USER;
-				info.si_pid = current->parent->pid;
-				info.si_uid = current->parent->uid;
-			}
-
-			/* If the (new) signal is now blocked, requeue it.  */
-			if (sigismember(&current->blocked, signr)) {
-				send_sig_info(signr, &info, current);
-				continue;
-			}
-		}
-
-		ka = &current->sighand->action[signr-1];
-		if (ka->sa.sa_handler == SIG_IGN) {
-			if (signr != SIGCHLD)
-				continue;
-			/* Check for SIGCHLD: it's special.  */
-			while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0)
-				/* nothing */;
-			continue;
-		}
-
-		if (ka->sa.sa_handler == SIG_DFL) {
-			int exit_code = signr;
-
-			if (current->pid == 1)
-				continue;
-
-			switch (signr) {
-			case SIGCONT: case SIGCHLD:
-			case SIGWINCH: case SIGURG:
-				continue;
-
-			case SIGTSTP: case SIGTTIN: case SIGTTOU:
-				if (is_orphaned_pgrp(process_group(current)))
-					continue;
-				/* FALLTHRU */
-
-			case SIGSTOP: {
-				struct sighand_struct *sig;
-				current->state = TASK_STOPPED;
-				current->exit_code = signr;
-                                sig = current->parent->sighand;
-                                if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags 
-& SA_NOCLDSTOP))
-                                        notify_parent(current, SIGCHLD);
-				schedule();
-				continue;
-			}
-
-			case SIGQUIT: case SIGILL: case SIGTRAP:
-			case SIGIOT: case SIGFPE: case SIGSEGV:
-			case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ:
-				if (do_coredump(signr, exit_code, regs))
-					exit_code |= 0x80;
-				/* FALLTHRU */
-
-			default:
-				sigaddset(&current->pending.signal, signr);
-				recalc_sigpending();
-				current->flags |= PF_SIGNALED;
-				do_exit(exit_code);
-				/* NOTREACHED */
-			}
-		}
-
+	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
+	if (signr > 0) {
 		/* Whee!  Actually deliver the signal.  */
-		handle_signal(signr, ka, &info, oldset, regs);
+		handle_signal(signr, &info, &ka, oldset, regs);
 		return 1;
 	}
-
+ no_signal:
 	/* Did we come from a system call? */
-	if (regs->orig_er0 >= 0)
+	if (regs->orig_er0 >= 0) {
 		/* Restart the system call - no handlers present */
-		handle_restart(regs, NULL, 0);
-
+		if (regs->er0 == -ERESTARTNOHAND ||
+		    regs->er0 == -ERESTARTSYS ||
+		    regs->er0 == -ERESTARTNOINTR) {
+			regs->er0 = regs->orig_er0;
+			regs->pc -= 2;
+		}
+		if (regs->er0 == -ERESTART_RESTARTBLOCK){
+			regs->er0 = __NR_restart_syscall;
+			regs->pc -= 2;
+		}
+	}
 	return 0;
 }
diff -Nru a/arch/h8300/kernel/time.c b/arch/h8300/kernel/time.c
--- a/arch/h8300/kernel/time.c	2004-12-24 13:36:34 -08:00
+++ b/arch/h8300/kernel/time.c	2004-12-24 13:36:34 -08:00
@@ -46,6 +46,9 @@
 	platform_timer_eoi();
 
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	profile_tick(CPU_PROFILING, regs);
 }
 
diff -Nru a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S
--- a/arch/h8300/kernel/vmlinux.lds.S	2004-12-24 13:37:00 -08:00
+++ b/arch/h8300/kernel/vmlinux.lds.S	2004-12-24 13:37:00 -08:00
@@ -1,60 +1,48 @@
 #define VMLINUX_SYMBOL(_sym_) _##_sym_
 #include <asm-generic/vmlinux.lds.h>
-#include <asm/thread_info.h>
 #include <linux/config.h>
 
+/* target memory map */
 #ifdef CONFIG_H8300H_GENERIC
-#ifdef CONFIG_ROMKERNEL
-#include "../platform/h8300h/generic/rom.ld"
-#endif
-#ifdef CONFIG_RAMKERNEL
-#include "../platform/h8300h/generic/ram.ld"
-#endif
+#define ROMTOP  0x000000
+#define ROMSIZE 0x400000
+#define RAMTOP  0x400000
+#define RAMSIZE 0x400000
 #endif
 
 #ifdef CONFIG_H8300H_AKI3068NET
-#ifdef CONFIG_ROMKERNEL
-#include "../platform/h8300h/aki3068net/rom.ld"
-#endif
-#ifdef CONFIG_RAMKERNEL
-#include "../platform/h8300h/aki3068net/ram.ld"
-#endif
+#define ROMTOP  0x000000
+#define ROMSIZE 0x080000
+#define RAMTOP  0x400000
+#define RAMSIZE 0x200000
 #endif
 
 #ifdef CONFIG_H8300H_H8MAX
-#ifdef CONFIG_ROMKERNEL
-#include "../platform/h8300h/h8max/rom.ld"
-#endif
-#ifdef CONFIG_RAMKERNEL
-#include "../platform/h8300h/h8max/ram.ld"
-#endif
+#define ROMTOP  0x000000
+#define ROMSIZE 0x080000
+#define RAMTOP  0x400000
+#define RAMSIZE 0x200000
 #endif
 
 #ifdef CONFIG_H8300H_SIM
-#ifdef CONFIG_ROMKERNEL
-#include "../platform/h8300h/generic/rom.ld"
-#endif
-#ifdef CONFIG_RAMKERNEL
-#include "../platform/h8300h/generic/ram.ld"
-#endif
+#define ROMTOP  0x000000
+#define ROMSIZE 0x400000
+#define RAMTOP  0x400000
+#define RAMSIZE 0x400000
 #endif
 
 #ifdef CONFIG_H8S_SIM
-#ifdef CONFIG_ROMKERNEL
-#include "../platform/h8s/generic/rom.ld"
-#endif
-#ifdef CONFIG_RAMKERNEL
-#include "../platform/h8s/generic/ram.ld"
-#endif
+#define ROMTOP  0x000000
+#define ROMSIZE 0x400000
+#define RAMTOP  0x400000
+#define RAMSIZE 0x800000
 #endif
 
 #ifdef CONFIG_H8S_EDOSK2674
-#ifdef CONFIG_ROMKERNEL
-#include "../platform/h8s/edosk2674/rom.ld"
-#endif
-#ifdef CONFIG_RAMKERNEL
-#include "../platform/h8s/edosk2674/ram.ld"
-#endif
+#define ROMTOP  0x000000
+#define ROMSIZE 0x400000
+#define RAMTOP  0x400000
+#define RAMSIZE 0x800000
 #endif
 
 #if defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)
@@ -63,71 +51,51 @@
 
 _jiffies = _jiffies_64 + 4;
 
+ENTRY(__start)
+
 SECTIONS
 {
 #if defined(CONFIG_ROMKERNEL)
+	. = ROMTOP; 
 	.vectors :
 	{
 	__vector = . ;
 		*(.vectors*)
-	} > vector
-#endif
-#if defined(CONFIG_RAMKERNEL)
-	.bootvec :
+	}
+#else
+	. = RAMTOP; 
+	.bootvec :	
 	{
 		*(.bootvec)
-	} > ram
+	}
 #endif
         .text :
 	{
 #if defined(CONFIG_ROMKERNEL)
-		*(.int_redirect)
+	*(.int_redirect)
 #endif
 	__stext = . ;
         	*(.text)
 	SCHED_TEXT
-	. = ALIGN(0x4) ;
-		*(.exit.text)
-		*(.text.*)
-	. = ALIGN(0x4) ;
-		*(.exitcall.exit)
-	. = ALIGN(0x4) ;
-		*(.kstrtab)
-	. = ALIGN(0x4) ;
-		*(.rodata*)
+	LOCK_TEXT
+	__etext = . ;
 	. = ALIGN(16);          /* Exception table              */
 	___start___ex_table = .;
 		*(__ex_table)
 	___stop___ex_table = .;
+	}
 
-        ___start___ksymtab = .;  /* Kernel symbol table          */
-		 *(__ksymtab)
-	___stop___ksymtab = .;
-
-	___start___ksymtab_gpl = .;	/* Kernel symbol table: GPL-only symbols */
-
-	*(__ksymtab_gpl)
-	___stop___ksymtab_gpl = .;
-
-	___start___kcrctab = .;	/* Kernel symbol table: Normal symbols */
-	*(__kcrctab)
-	___stop___kcrctab = .;
-
-	___start___kcrctab_gpl = .;	/* Kernel symbol table: GPL-only symbols */
-	*(__kcrctab_gpl)
-	___stop___kcrctab_gpl = .;
-
-	*(__ksymtab_strings)	/* Kernel symbol table: strings */
-
-	. = ALIGN(0x4) ;
-	__etext = . ;
+	RODATA
 #if defined(CONFIG_ROMKERNEL)
-	} > rom
+	SECURITY_INIT
 #endif
-#if defined(CONFIG_RAMKERNEL)
-	} > ram
+	ROEND = .; 
+#if defined(CONFIG_ROMKERNEL)
+	. = RAMTOP;
+	.data :	AT(ROEND)
+#else
+	.data :	
 #endif
-	.data : AT( ADDR(.text)+SIZEOF(.text))
 	{
 	__sdata = . ;
 	___data_start = . ;
@@ -162,6 +130,8 @@
 	___con_initcall_start = .;
 		*(.con_initcall.init)
 	___con_initcall_end = .;
+		*(.exit.text)
+		*(.exit.data)
 		. = ALIGN(4);
 	___initramfs_start = .;
   		*(.init.ramfs)
@@ -169,14 +139,11 @@
 	. = ALIGN(0x4) ;
 	___init_end = .;
 	__edata = . ;
-	} > ram
-	__begin_data = LOADADDR(.data) ;
-#if defined(CONFIG_ROMKERNEL)
-	.erom :
-	{
-	__erom = . ;
-	} > erom
+	}
+#if defined(CONFIG_RAMKERNEL)
+	SECURITY_INIT
 #endif
+	__begin_data = LOADADDR(.data);
         .bss : 
         {
 	. = ALIGN(0x4) ;
@@ -188,15 +155,18 @@
 	__ebss = . ;
 	__end = . ;
 	__ramstart = .;
-	} > ram
+	}
+	/DISCARD/ : {
+		*(.exitcall.exit)
+	}
         .romfs :	
 	{
 		*(.romfs*)
-	} > ram
+	}
+	. = RAMTOP+RAMSIZE;
         .dummy :
         {
 	COMMAND_START = . - 0x200 ;
 	__ramend = . ;
-	} > eram
+	}
 }
-
diff -Nru a/arch/h8300/platform/h8300h/aki3068net/ram.ld b/arch/h8300/platform/h8300h/aki3068net/ram.ld
--- a/arch/h8300/platform/h8300h/aki3068net/ram.ld	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,11 +0,0 @@
-/* AE-3068 (aka. aki3068net) RAM */
-
-OUTPUT_ARCH(h8300h)
-ENTRY("__start")
-
-MEMORY 
-	{
-	ram    : ORIGIN = 0x400000, LENGTH = 0x600000-0x400000
-	eram   : ORIGIN = 0x600000, LENGTH = 0
-        iram   : ORIGIN = 0xffbf20, LENGTH = 0x4000
-	}
diff -Nru a/arch/h8300/platform/h8300h/entry.S b/arch/h8300/platform/h8300h/entry.S
--- a/arch/h8300/platform/h8300h/entry.S	2004-12-24 13:36:47 -08:00
+++ b/arch/h8300/platform/h8300h/entry.S	2004-12-24 13:36:47 -08:00
@@ -247,9 +247,9 @@
 	mov.l	@(TI_FLAGS:16,er4),er1
 	btst	#TIF_NEED_RESCHED,r1l
 	bne	SYMBOL_NAME(reschedule):16
-	mov.l	sp,er1
-	subs	#4,er1			/* adjust retpc */
-	mov.l	er2,er0
+	mov.l	sp,er0
+	subs	#4,er0			/* adjust retpc */
+	mov.l	er2,er1
 	jsr	@SYMBOL_NAME(do_signal)
 #if defined(CONFIG_PREEMPT)
 	bra	done:8			/* userspace thoru */
diff -Nru a/arch/h8300/platform/h8300h/generic/ram.ld b/arch/h8300/platform/h8300h/generic/ram.ld
--- a/arch/h8300/platform/h8300h/generic/ram.ld	2004-12-24 13:36:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,11 +0,0 @@
-/* Generic RAM */
-
-OUTPUT_ARCH(h8300h)
-ENTRY("__start")
-
-MEMORY 
-	{
-	ram    : ORIGIN = 0x400000, LENGTH = 0x200000
-	eram   : ORIGIN = 0x600000, LENGTH = 0
-        iram   : ORIGIN = 0xffbf20, LENGTH = 0x4000
-	}
diff -Nru a/arch/h8300/platform/h8300h/generic/rom.ld b/arch/h8300/platform/h8300h/generic/rom.ld
--- a/arch/h8300/platform/h8300h/generic/rom.ld	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,12 +0,0 @@
-OUTPUT_ARCH(h8300h)
-ENTRY("__start")
-
-MEMORY 
-	{
-	vector : ORIGIN = 0x000000, LENGTH = 0x000100
-	rom    : ORIGIN = 0x000100, LENGTH = 0x200000-0x000100
-	erom   : ORIGIN = 0x200000, LENGTH = 0
-	ram    : ORIGIN = 0x200000, LENGTH = 0x400000
-	eram   : ORIGIN = 0x600000, LENGTH = 0
-	}
-
diff -Nru a/arch/h8300/platform/h8300h/h8max/ram.ld b/arch/h8300/platform/h8300h/h8max/ram.ld
--- a/arch/h8300/platform/h8300h/h8max/ram.ld	2004-12-24 13:37:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,11 +0,0 @@
-/* H8MAX RAM */
-
-OUTPUT_ARCH(h8300h)
-ENTRY("__start")
-
-MEMORY 
-	{
-	ram    : ORIGIN = 0x400000, LENGTH = 0x600000-0x400000
-	eram   : ORIGIN = 0x600000, LENGTH = 0
-        iram   : ORIGIN = 0xfffd20, LENGTH = 0x100
-	}
diff -Nru a/arch/h8300/platform/h8s/edosk2674/crt0_rom.S b/arch/h8300/platform/h8s/edosk2674/crt0_rom.S
--- a/arch/h8300/platform/h8s/edosk2674/crt0_rom.S	2004-12-24 13:36:55 -08:00
+++ b/arch/h8300/platform/h8s/edosk2674/crt0_rom.S	2004-12-24 13:36:55 -08:00
@@ -181,7 +181,7 @@
 	.long	__start
 	.long	__start
 vector	=	2
-	.rept	126-1
+	.rept	126
 	.long	_interrupt_redirect_table+vector*4
 vector	=	vector + 1
 	.endr
diff -Nru a/arch/h8300/platform/h8s/edosk2674/ram.ld b/arch/h8300/platform/h8s/edosk2674/ram.ld
--- a/arch/h8300/platform/h8s/edosk2674/ram.ld	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,10 +0,0 @@
-/* EDOSK-2674R RAM */
-
-OUTPUT_ARCH(h8300s)
-ENTRY("__start")
-
-MEMORY 
-	{
-	ram    : ORIGIN = 0x400000, LENGTH = 0xc00000-0x400000
-	eram   : ORIGIN = 0xc00000, LENGTH = 0
-	}
diff -Nru a/arch/h8300/platform/h8s/edosk2674/rom.ld b/arch/h8300/platform/h8s/edosk2674/rom.ld
--- a/arch/h8300/platform/h8s/edosk2674/rom.ld	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,11 +0,0 @@
-OUTPUT_ARCH(h8300s)
-ENTRY("__start")
-
-MEMORY 
-	{
-	vector : ORIGIN = 0x000000, LENGTH = 0x000200
-	rom    : ORIGIN = 0x000200, LENGTH = 0x100000-0x000200
-	erom   : ORIGIN = 0x100000, LENGTH = 0
-	ram    : ORIGIN = 0x400000, LENGTH = 0xc00000-0x400000
-	eram   : ORIGIN = 0xc00000, LENGTH = 0
-	}
diff -Nru a/arch/h8300/platform/h8s/entry.S b/arch/h8300/platform/h8s/entry.S
--- a/arch/h8300/platform/h8s/entry.S	2004-12-24 13:37:18 -08:00
+++ b/arch/h8300/platform/h8s/entry.S	2004-12-24 13:37:18 -08:00
@@ -244,9 +244,9 @@
 	mov.l	@(TI_FLAGS:16,er4),er1
 	btst	#TIF_NEED_RESCHED,r1l
 	bne	SYMBOL_NAME(reschedule):16
-	mov.l	sp,er1
-	subs	#4,er1			/* adjust retpc */
-	mov.l	er2,er0
+	mov.l	sp,er0
+	subs	#4,er0			/* adjust retpc */
+	mov.l	er2,er1
 	jsr	@SYMBOL_NAME(do_signal)
 #if defined(CONFIG_PREEMPT)
 	bra	done:8			/* userspace thoru */
diff -Nru a/arch/h8300/platform/h8s/generic/ram.ld b/arch/h8300/platform/h8s/generic/ram.ld
--- a/arch/h8300/platform/h8s/generic/ram.ld	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,8 +0,0 @@
-OUTPUT_ARCH(h8300s)
-ENTRY("__start")
-
-MEMORY 
-	{
-	ram    : ORIGIN = 0x400000, LENGTH = 0x200000
-	eram   : ORIGIN = 0x600000, LENGTH = 0
-	}
diff -Nru a/arch/h8300/platform/h8s/generic/rom.ld b/arch/h8300/platform/h8s/generic/rom.ld
--- a/arch/h8300/platform/h8s/generic/rom.ld	2004-12-24 13:37:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,11 +0,0 @@
-OUTPUT_ARCH(h8300s)
-ENTRY("__start")
-
-MEMORY 
-	{
-	vector : ORIGIN = 0x000000, LENGTH = 0x000200
-	rom    : ORIGIN = 0x000200, LENGTH = 0x200000-0x000200
-	erom   : ORIGIN = 0x200000, LENGTH = 0
-	ram    : ORIGIN = 0x200000, LENGTH = 0x400000
-	eram   : ORIGIN = 0x600000, LENGTH = 0
-	}
diff -Nru a/arch/i386/Kconfig b/arch/i386/Kconfig
--- a/arch/i386/Kconfig	2004-12-24 13:36:19 -08:00
+++ b/arch/i386/Kconfig	2004-12-24 13:36:19 -08:00
@@ -179,6 +179,7 @@
 	  - "K6" for the AMD K6, K6-II and K6-III (aka K6-3D).
 	  - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird).
 	  - "Crusoe" for the Transmeta Crusoe series.
+	  - "Efficeon" for the Transmeta Efficeon series.
 	  - "Winchip-C6" for original IDT Winchip.
 	  - "Winchip-2" for IDT Winchip 2.
 	  - "Winchip-2A" for IDT Winchips with 3dNow! capabilities.
@@ -199,7 +200,7 @@
 	bool "586/K5/5x86/6x86/6x86MX"
 	help
 	  Select this for an 586 or 686 series processor such as the AMD K5,
-	  the Intel 5x86 or 6x86, or the Intel 6x86MX.  This choice does not
+	  the Cyrix 5x86, 6x86 and 6x86MX.  This choice does not
 	  assume the RDTSC (Read Time Stamp Counter) instruction.
 
 config M586TSC
@@ -281,6 +282,11 @@
 	  like a 586 with TSC, and sets some GCC optimization flags (like a
 	  Pentium Pro with no alignment requirements).
 
+config MEFFICEON
+	bool "Efficeon"
+	help
+	  Select this for a Transmeta Efficeon processor.
+
 config MWINCHIPC6
 	bool "Winchip-C6"
 	help
@@ -354,7 +360,7 @@
 	int
 	default "7" if MPENTIUM4 || X86_GENERIC
 	default "4" if X86_ELAN || M486 || M386
-	default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2
+	default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2
 	default "6" if MK7 || MK8 || MPENTIUMM
 
 config RWSEM_GENERIC_SPINLOCK
@@ -404,17 +410,17 @@
 
 config X86_GOOD_APIC
 	bool
-	depends on MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8
+	depends on MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8 || MEFFICEON
 	default y
 
 config X86_INTEL_USERCOPY
 	bool
-	depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7
+	depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON
 	default y
 
 config X86_USE_PPRO_CHECKSUM
 	bool
-	depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2
+	depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MEFFICEON
 	default y
 
 config X86_USE_3DNOW
@@ -549,7 +555,7 @@
 
 config X86_TSC
 	bool
-	depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ
+	depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ
 	default y
 
 config X86_MCE
@@ -584,7 +590,7 @@
 
 config X86_MCE_P4THERMAL
 	bool "check for P4 thermal throttling interrupt."
-	depends on X86_MCE && (X86_UP_APIC || SMP)
+	depends on X86_MCE && (X86_UP_APIC || SMP) && !X86_VISWS
 	help
 	  Enabling this feature will cause a message to be printed when the P4
 	  enters thermal throttling.
@@ -879,7 +885,7 @@
 source "drivers/acpi/Kconfig"
 
 menu "APM (Advanced Power Management) BIOS Support"
-depends on PM
+depends on PM && !X86_VISWS
 
 config APM
 	tristate "APM (Advanced Power Management) BIOS support"
@@ -1193,6 +1199,17 @@
 source "crypto/Kconfig"
 
 source "lib/Kconfig"
+
+#
+# Use the generic interrupt handling code in kernel/irq/:
+#
+config GENERIC_HARDIRQS
+	bool
+	default y
+
+config GENERIC_IRQ_PROBE
+	bool
+	default y
 
 config X86_SMP
 	bool
diff -Nru a/arch/i386/Kconfig.debug b/arch/i386/Kconfig.debug
--- a/arch/i386/Kconfig.debug	2004-12-24 13:36:49 -08:00
+++ b/arch/i386/Kconfig.debug	2004-12-24 13:36:49 -08:00
@@ -55,18 +55,6 @@
 	  on the VM subsystem for higher order allocations. This option
 	  will also use IRQ stacks to compensate for the reduced stackspace.
 
-config SCHEDSTATS
-	bool "Collect scheduler statistics"
-	depends on DEBUG_KERNEL && PROC_FS
-	help
-	  If you say Y here, additional code will be inserted into the
-	  scheduler and related routines to collect statistics about
-	  scheduler behavior and provide them in /proc/schedstat.  These
-	  stats may be useful for both tuning and debugging the scheduler
-	  If you aren't debugging the scheduler or trying to tune a specific
-	  application, you can say N to avoid the very slight overhead
-	  this adds.
-
 config X86_FIND_SMP_CONFIG
 	bool
 	depends on X86_LOCAL_APIC || X86_VOYAGER
diff -Nru a/arch/i386/Makefile b/arch/i386/Makefile
--- a/arch/i386/Makefile	2004-12-24 13:36:47 -08:00
+++ b/arch/i386/Makefile	2004-12-24 13:36:47 -08:00
@@ -25,23 +25,24 @@
 # prevent gcc from keeping the stack 16 byte aligned
 CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
 
-align := $(subst -functions=0,,$(call cc-option,-falign-functions=0,-malign-functions=0))
+align := $(cc-option-align)
 cflags-$(CONFIG_M386)		+= -march=i386
 cflags-$(CONFIG_M486)		+= -march=i486
 cflags-$(CONFIG_M586)		+= -march=i586
 cflags-$(CONFIG_M586TSC)	+= -march=i586
 cflags-$(CONFIG_M586MMX)	+= $(call cc-option,-march=pentium-mmx,-march=i586)
 cflags-$(CONFIG_M686)		+= -march=i686
-cflags-$(CONFIG_MPENTIUMII)	+= $(call cc-option,-march=pentium2,-march=i686)
-cflags-$(CONFIG_MPENTIUMIII)	+= $(call cc-option,-march=pentium3,-march=i686)
-cflags-$(CONFIG_MPENTIUMM)	+= $(call cc-option,-march=pentium3,-march=i686)
-cflags-$(CONFIG_MPENTIUM4)	+= $(call cc-option,-march=pentium4,-march=i686)
+cflags-$(CONFIG_MPENTIUMII)	+= -march=i686 $(call cc-option,-mtune=pentium2)
+cflags-$(CONFIG_MPENTIUMIII)	+= -march=i686 $(call cc-option,-mtune=pentium3)
+cflags-$(CONFIG_MPENTIUMM)	+= -march=i686 $(call cc-option,-mtune=pentium3)
+cflags-$(CONFIG_MPENTIUM4)	+= -march=i686 $(call cc-option,-mtune=pentium4)
 cflags-$(CONFIG_MK6)		+= -march=k6
 # Please note, that patches that add -march=athlon-xp and friends are pointless.
 # They make zero difference whatsosever to performance at this time.
 cflags-$(CONFIG_MK7)		+= $(call cc-option,-march=athlon,-march=i686 $(align)-functions=4)
 cflags-$(CONFIG_MK8)		+= $(call cc-option,-march=k8,$(call cc-option,-march=athlon,-march=i686 $(align)-functions=4))
 cflags-$(CONFIG_MCRUSOE)	+= -march=i686 $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
+cflags-$(CONFIG_MEFFICEON)	+= -march=i686 $(call cc-option,-mtune=pentium3) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
 cflags-$(CONFIG_MWINCHIPC6)	+= $(call cc-option,-march=winchip-c6,-march=i586)
 cflags-$(CONFIG_MWINCHIP2)	+= $(call cc-option,-march=winchip2,-march=i586)
 cflags-$(CONFIG_MWINCHIP3D)	+= $(call cc-option,-march=winchip2,-march=i586)
diff -Nru a/arch/i386/boot/video.S b/arch/i386/boot/video.S
--- a/arch/i386/boot/video.S	2004-12-24 13:37:43 -08:00
+++ b/arch/i386/boot/video.S	2004-12-24 13:37:43 -08:00
@@ -1936,7 +1936,7 @@
 
 	movl	$0x13131313, %eax		# memset block with 0x13
 	movw    $32, %cx
-	movw	$0x440, %di
+	movw	$0x140, %di
 	cld
 	rep 
 	stosl  
@@ -1945,7 +1945,7 @@
 	movw	$0x01, %bx
 	movw	$0x00, %cx
 	movw    $0x01, %dx
-	movw	$0x440, %di
+	movw	$0x140, %di
 	int	$0x10	
 
 	popw	%di				# restore all registers        
diff -Nru a/arch/i386/crypto/aes-i586-asm.S b/arch/i386/crypto/aes-i586-asm.S
--- a/arch/i386/crypto/aes-i586-asm.S	2004-12-24 13:37:00 -08:00
+++ b/arch/i386/crypto/aes-i586-asm.S	2004-12-24 13:37:00 -08:00
@@ -61,7 +61,6 @@
 #define r3  edx
 #define r4  esi
 #define r5  edi
-#define r6  ebp
 
 #define eaxl  al
 #define eaxh  ah
@@ -84,60 +83,63 @@
 // output registers r0, r1, r4 or r5.  
 
 // Parameters:
+// table table base address
 //   %1  out_state[0]
 //   %2  out_state[1]
 //   %3  out_state[2]
 //   %4  out_state[3]
-//   %5  table base address
-//   %6  input register for the round (destroyed)
-//   %7  scratch register for the round
-
-#define do_col(a1, a2, a3, a4, a5, a6, a7)	\
-	movzx   %l(a6),%a7;			\
-	xor     a5(,%a7,4),%a1;			\
-	movzx   %h(a6),%a7;			\
-	shr     $16,%a6;			\
-	xor     a5+tlen(,%a7,4),%a2;		\
-	movzx   %l(a6),%a7;			\
-	movzx   %h(a6),%a6;			\
-	xor     a5+2*tlen(,%a7,4),%a3;		\
-	xor     a5+3*tlen(,%a6,4),%a4;
+//   idx input register for the round (destroyed)
+//   tmp scratch register for the round
+// sched key schedule
+
+#define do_col(table, a1,a2,a3,a4, idx, tmp)	\
+	movzx   %l(idx),%tmp;			\
+	xor     table(,%tmp,4),%a1;		\
+	movzx   %h(idx),%tmp;			\
+	shr     $16,%idx;			\
+	xor     table+tlen(,%tmp,4),%a2;	\
+	movzx   %l(idx),%tmp;			\
+	movzx   %h(idx),%idx;			\
+	xor     table+2*tlen(,%tmp,4),%a3;	\
+	xor     table+3*tlen(,%idx,4),%a4;
 
 // initialise output registers from the key schedule
-
-#define do_fcol(a1, a2, a3, a4, a5, a6, a7, a8)	\
-	mov     0 a8,%a1;			\
-	movzx   %l(a6),%a7;			\
-	mov     12 a8,%a2;			\
-	xor     a5(,%a7,4),%a1;			\
-	mov     4 a8,%a4;			\
-	movzx   %h(a6),%a7;			\
-	shr     $16,%a6;			\
-	xor     a5+tlen(,%a7,4),%a2;		\
-	movzx   %l(a6),%a7;			\
-	movzx   %h(a6),%a6;			\
-	xor     a5+3*tlen(,%a6,4),%a4;		\
-	mov     %a3,%a6;			\
-	mov     8 a8,%a3;			\
-	xor     a5+2*tlen(,%a7,4),%a3;
+// NB1: original value of a3 is in idx on exit
+// NB2: original values of a1,a2,a4 aren't used
+#define do_fcol(table, a1,a2,a3,a4, idx, tmp, sched) \
+	mov     0 sched,%a1;			\
+	movzx   %l(idx),%tmp;			\
+	mov     12 sched,%a2;			\
+	xor     table(,%tmp,4),%a1;		\
+	mov     4 sched,%a4;			\
+	movzx   %h(idx),%tmp;			\
+	shr     $16,%idx;			\
+	xor     table+tlen(,%tmp,4),%a2;	\
+	movzx   %l(idx),%tmp;			\
+	movzx   %h(idx),%idx;			\
+	xor     table+3*tlen(,%idx,4),%a4;	\
+	mov     %a3,%idx;			\
+	mov     8 sched,%a3;			\
+	xor     table+2*tlen(,%tmp,4),%a3;
 
 // initialise output registers from the key schedule
-
-#define do_icol(a1, a2, a3, a4, a5, a6, a7, a8)	\
-	mov     0 a8,%a1;			\
-	movzx   %l(a6),%a7;			\
-	mov     4 a8,%a2;			\
-	xor     a5(,%a7,4),%a1;			\
-	mov     12 a8,%a4;			\
-	movzx   %h(a6),%a7;			\
-	shr     $16,%a6;			\
-	xor     a5+tlen(,%a7,4),%a2;		\
-	movzx   %l(a6),%a7;			\
-	movzx   %h(a6),%a6;			\
-	xor     a5+3*tlen(,%a6,4),%a4;		\
-	mov     %a3,%a6;			\
-	mov     8 a8,%a3;			\
-	xor     a5+2*tlen(,%a7,4),%a3;
+// NB1: original value of a3 is in idx on exit
+// NB2: original values of a1,a2,a4 aren't used
+#define do_icol(table, a1,a2,a3,a4, idx, tmp, sched) \
+	mov     0 sched,%a1;			\
+	movzx   %l(idx),%tmp;			\
+	mov     4 sched,%a2;			\
+	xor     table(,%tmp,4),%a1;		\
+	mov     12 sched,%a4;			\
+	movzx   %h(idx),%tmp;			\
+	shr     $16,%idx;			\
+	xor     table+tlen(,%tmp,4),%a2;	\
+	movzx   %l(idx),%tmp;			\
+	movzx   %h(idx),%idx;			\
+	xor     table+3*tlen(,%idx,4),%a4;	\
+	mov     %a3,%idx;			\
+	mov     8 sched,%a3;			\
+	xor     table+2*tlen(,%tmp,4),%a3;
 
 
 // original Gladman had conditional saves to MMX regs.
@@ -147,44 +149,75 @@
 #define restore(a1, a2)		\
 	mov     4*a2(%esp),%a1
 
-// This macro performs a forward encryption cycle. It is entered with
-// the first previous round column values in r0, r1, r4 and r5 and
-// exits with the final values in the same registers, using the MMX
-// registers mm0-mm1 or the stack for temporary storage
-
-// mov current column values into the MMX registers
-#define fwd_rnd(arg, table)					\
-	/* mov current column values into the MMX registers */	\
-	mov     %r0,%r2;					\
-	save   (0,r1);						\
-	save   (1,r5);						\
-								\
-	/* compute new column values */				\
-	do_fcol(r0,r5,r4,r1,table, r2,r3, arg);			\
-	do_col (r4,r1,r0,r5,table, r2,r3);			\
-	restore(r2,0);						\
-	do_col (r1,r0,r5,r4,table, r2,r3);			\
-	restore(r2,1);						\
-	do_col (r5,r4,r1,r0,table, r2,r3);
-
-// This macro performs an inverse encryption cycle. It is entered with
-// the first previous round column values in r0, r1, r4 and r5 and
-// exits with the final values in the same registers, using the MMX
-// registers mm0-mm1 or the stack for temporary storage
-
-#define inv_rnd(arg, table)					\
-	/* mov current column values into the MMX registers */	\
-	mov     %r0,%r2;					\
-	save    (0,r1);						\
-	save    (1,r5);						\
-								\
-	/* compute new column values */				\
-	do_icol(r0,r1,r4,r5, table, r2,r3, arg);		\
-	do_col (r4,r5,r0,r1, table, r2,r3);			\
-	restore(r2,0);						\
-	do_col (r1,r4,r5,r0, table, r2,r3);			\
-	restore(r2,1);						\
-	do_col (r5,r0,r1,r4, table, r2,r3);
+// These macros perform a forward encryption cycle. They are entered with
+// the first previous round column values in r0,r1,r4,r5 and
+// exit with the final values in the same registers, using stack
+// for temporary storage.
+
+// round column values
+// on entry: r0,r1,r4,r5
+// on exit:  r2,r1,r4,r5
+#define fwd_rnd1(arg, table)						\
+	save   (0,r1);							\
+	save   (1,r5);							\
+									\
+	/* compute new column values */					\
+	do_fcol(table, r2,r5,r4,r1, r0,r3, arg);	/* idx=r0 */	\
+	do_col (table, r4,r1,r2,r5, r0,r3);		/* idx=r4 */	\
+	restore(r0,0);							\
+	do_col (table, r1,r2,r5,r4, r0,r3);		/* idx=r1 */	\
+	restore(r0,1);							\
+	do_col (table, r5,r4,r1,r2, r0,r3);		/* idx=r5 */
+
+// round column values
+// on entry: r2,r1,r4,r5
+// on exit:  r0,r1,r4,r5
+#define fwd_rnd2(arg, table)						\
+	save   (0,r1);							\
+	save   (1,r5);							\
+									\
+	/* compute new column values */					\
+	do_fcol(table, r0,r5,r4,r1, r2,r3, arg);	/* idx=r2 */	\
+	do_col (table, r4,r1,r0,r5, r2,r3);		/* idx=r4 */	\
+	restore(r2,0);							\
+	do_col (table, r1,r0,r5,r4, r2,r3);		/* idx=r1 */	\
+	restore(r2,1);							\
+	do_col (table, r5,r4,r1,r0, r2,r3);		/* idx=r5 */
+
+// These macros performs an inverse encryption cycle. They are entered with
+// the first previous round column values in r0,r1,r4,r5 and
+// exit with the final values in the same registers, using stack
+// for temporary storage
+
+// round column values
+// on entry: r0,r1,r4,r5
+// on exit:  r2,r1,r4,r5
+#define inv_rnd1(arg, table)						\
+	save    (0,r1);							\
+	save    (1,r5);							\
+									\
+	/* compute new column values */					\
+	do_icol(table, r2,r1,r4,r5, r0,r3, arg);	/* idx=r0 */	\
+	do_col (table, r4,r5,r2,r1, r0,r3);		/* idx=r4 */	\
+	restore(r0,0);							\
+	do_col (table, r1,r4,r5,r2, r0,r3);		/* idx=r1 */	\
+	restore(r0,1);							\
+	do_col (table, r5,r2,r1,r4, r0,r3);		/* idx=r5 */
+
+// round column values
+// on entry: r2,r1,r4,r5
+// on exit:  r0,r1,r4,r5
+#define inv_rnd2(arg, table)						\
+	save    (0,r1);							\
+	save    (1,r5);							\
+									\
+	/* compute new column values */					\
+	do_icol(table, r0,r1,r4,r5, r2,r3, arg);	/* idx=r2 */	\
+	do_col (table, r4,r5,r0,r1, r2,r3);		/* idx=r4 */	\
+	restore(r2,0);							\
+	do_col (table, r1,r4,r5,r0, r2,r3);		/* idx=r1 */	\
+	restore(r2,1);							\
+	do_col (table, r5,r0,r1,r4, r2,r3);		/* idx=r5 */
 
 // AES (Rijndael) Encryption Subroutine
 
@@ -198,7 +231,6 @@
 aes_enc_blk:
 	push    %ebp
 	mov     ctx(%esp),%ebp      // pointer to context
-	xor     %eax,%eax
 
 // CAUTION: the order and the values used in these assigns 
 // rely on the register mappings
@@ -208,7 +240,9 @@
 	push    %esi
 	mov     nrnd(%ebp),%r3   // number of rounds
 	push    %edi
-	lea     ekey(%ebp),%r6   // key pointer
+#if ekey != 0
+	lea     ekey(%ebp),%ebp  // key pointer
+#endif
 
 // input four columns and xor in first round key
 
@@ -216,47 +250,47 @@
 	mov     4(%r2),%r1
 	mov     8(%r2),%r4
 	mov     12(%r2),%r5
-	xor     (%r6),%r0
-	xor     4(%r6),%r1
-	xor     8(%r6),%r4
-	xor     12(%r6),%r5
+	xor     (%ebp),%r0
+	xor     4(%ebp),%r1
+	xor     8(%ebp),%r4
+	xor     12(%ebp),%r5
 
 	sub     $8,%esp           // space for register saves on stack
-	add     $16,%r6           // increment to next round key   
+	add     $16,%ebp          // increment to next round key
 	sub     $10,%r3          
 	je      4f              // 10 rounds for 128-bit key
-	add     $32,%r6
+	add     $32,%ebp
 	sub     $2,%r3
 	je      3f              // 12 rounds for 128-bit key
-	add     $32,%r6
+	add     $32,%ebp
 
-2:	fwd_rnd( -64(%r6) ,ft_tab)	// 14 rounds for 128-bit key
-	fwd_rnd( -48(%r6) ,ft_tab)
-3:	fwd_rnd( -32(%r6) ,ft_tab)	// 12 rounds for 128-bit key
-	fwd_rnd( -16(%r6) ,ft_tab)
-4:	fwd_rnd(    (%r6) ,ft_tab)	// 10 rounds for 128-bit key
-	fwd_rnd( +16(%r6) ,ft_tab)
-	fwd_rnd( +32(%r6) ,ft_tab)
-	fwd_rnd( +48(%r6) ,ft_tab)
-	fwd_rnd( +64(%r6) ,ft_tab)
-	fwd_rnd( +80(%r6) ,ft_tab)
-	fwd_rnd( +96(%r6) ,ft_tab)
-	fwd_rnd(+112(%r6) ,ft_tab)
-	fwd_rnd(+128(%r6) ,ft_tab)
-	fwd_rnd(+144(%r6) ,fl_tab)	// last round uses a different table
+2:	fwd_rnd1( -64(%ebp) ,ft_tab)	// 14 rounds for 128-bit key
+	fwd_rnd2( -48(%ebp) ,ft_tab)
+3:	fwd_rnd1( -32(%ebp) ,ft_tab)	// 12 rounds for 128-bit key
+	fwd_rnd2( -16(%ebp) ,ft_tab)
+4:	fwd_rnd1(    (%ebp) ,ft_tab)	// 10 rounds for 128-bit key
+	fwd_rnd2( +16(%ebp) ,ft_tab)
+	fwd_rnd1( +32(%ebp) ,ft_tab)
+	fwd_rnd2( +48(%ebp) ,ft_tab)
+	fwd_rnd1( +64(%ebp) ,ft_tab)
+	fwd_rnd2( +80(%ebp) ,ft_tab)
+	fwd_rnd1( +96(%ebp) ,ft_tab)
+	fwd_rnd2(+112(%ebp) ,ft_tab)
+	fwd_rnd1(+128(%ebp) ,ft_tab)
+	fwd_rnd2(+144(%ebp) ,fl_tab)	// last round uses a different table
 
 // move final values to the output array.  CAUTION: the 
 // order of these assigns rely on the register mappings
 
 	add     $8,%esp
-	mov     out_blk+12(%esp),%r6
-	mov     %r5,12(%r6)
+	mov     out_blk+12(%esp),%ebp
+	mov     %r5,12(%ebp)
 	pop     %edi
-	mov     %r4,8(%r6)
+	mov     %r4,8(%ebp)
 	pop     %esi
-	mov     %r1,4(%r6)
+	mov     %r1,4(%ebp)
 	pop     %ebx
-	mov     %r0,(%r6)
+	mov     %r0,(%ebp)
 	pop     %ebp
 	mov     $1,%eax
 	ret
@@ -273,7 +307,6 @@
 aes_dec_blk:
 	push    %ebp
 	mov     ctx(%esp),%ebp       // pointer to context
-	xor     %eax,%eax
 
 // CAUTION: the order and the values used in these assigns 
 // rely on the register mappings
@@ -283,10 +316,12 @@
 	push    %esi
 	mov     nrnd(%ebp),%r3   // number of rounds
 	push    %edi
-	lea     dkey(%ebp),%r6   // key pointer
+#if dkey != 0
+	lea     dkey(%ebp),%ebp  // key pointer
+#endif
 	mov     %r3,%r0
 	shl     $4,%r0
-	add     %r0,%r6
+	add     %r0,%ebp
 	
 // input four columns and xor in first round key
 
@@ -294,47 +329,47 @@
 	mov     4(%r2),%r1
 	mov     8(%r2),%r4
 	mov     12(%r2),%r5
-	xor     (%r6),%r0
-	xor     4(%r6),%r1
-	xor     8(%r6),%r4
-	xor     12(%r6),%r5
+	xor     (%ebp),%r0
+	xor     4(%ebp),%r1
+	xor     8(%ebp),%r4
+	xor     12(%ebp),%r5
 
-	sub     $8,%esp           // space for register saves on stack
-	sub     $16,%r6           // increment to next round key   
+	sub     $8,%esp         // space for register saves on stack
+	sub     $16,%ebp        // increment to next round key
 	sub     $10,%r3          
 	je      4f              // 10 rounds for 128-bit key
-	sub     $32,%r6
+	sub     $32,%ebp
 	sub     $2,%r3
 	je      3f              // 12 rounds for 128-bit key
-	sub     $32,%r6
+	sub     $32,%ebp
 
-2:	inv_rnd( +64(%r6), it_tab)	// 14 rounds for 128-bit key 
-	inv_rnd( +48(%r6), it_tab)
-3:	inv_rnd( +32(%r6), it_tab)	// 12 rounds for 128-bit key
-	inv_rnd( +16(%r6), it_tab)
-4:	inv_rnd(    (%r6), it_tab)	// 10 rounds for 128-bit key
-	inv_rnd( -16(%r6), it_tab)
-	inv_rnd( -32(%r6), it_tab)
-	inv_rnd( -48(%r6), it_tab)
-	inv_rnd( -64(%r6), it_tab)
-	inv_rnd( -80(%r6), it_tab)
-	inv_rnd( -96(%r6), it_tab)
-	inv_rnd(-112(%r6), it_tab)
-	inv_rnd(-128(%r6), it_tab)
-	inv_rnd(-144(%r6), il_tab)	// last round uses a different table
+2:	inv_rnd1( +64(%ebp), it_tab)	// 14 rounds for 128-bit key
+	inv_rnd2( +48(%ebp), it_tab)
+3:	inv_rnd1( +32(%ebp), it_tab)	// 12 rounds for 128-bit key
+	inv_rnd2( +16(%ebp), it_tab)
+4:	inv_rnd1(    (%ebp), it_tab)	// 10 rounds for 128-bit key
+	inv_rnd2( -16(%ebp), it_tab)
+	inv_rnd1( -32(%ebp), it_tab)
+	inv_rnd2( -48(%ebp), it_tab)
+	inv_rnd1( -64(%ebp), it_tab)
+	inv_rnd2( -80(%ebp), it_tab)
+	inv_rnd1( -96(%ebp), it_tab)
+	inv_rnd2(-112(%ebp), it_tab)
+	inv_rnd1(-128(%ebp), it_tab)
+	inv_rnd2(-144(%ebp), il_tab)	// last round uses a different table
 
 // move final values to the output array.  CAUTION: the 
 // order of these assigns rely on the register mappings
 
 	add     $8,%esp
-	mov     out_blk+12(%esp),%r6
-	mov     %r5,12(%r6)
+	mov     out_blk+12(%esp),%ebp
+	mov     %r5,12(%ebp)
 	pop     %edi
-	mov     %r4,8(%r6)
+	mov     %r4,8(%ebp)
 	pop     %esi
-	mov     %r1,4(%r6)
+	mov     %r1,4(%ebp)
 	pop     %ebx
-	mov     %r0,(%r6)
+	mov     %r0,(%ebp)
 	pop     %ebp
 	mov     $1,%eax
 	ret
diff -Nru a/arch/i386/defconfig b/arch/i386/defconfig
--- a/arch/i386/defconfig	2004-12-24 13:37:01 -08:00
+++ b/arch/i386/defconfig	2004-12-24 13:37:01 -08:00
@@ -71,6 +71,7 @@
 # CONFIG_MK7 is not set
 # CONFIG_MK8 is not set
 # CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
 # CONFIG_MWINCHIPC6 is not set
 # CONFIG_MWINCHIP2 is not set
 # CONFIG_MWINCHIP3D is not set
diff -Nru a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
--- a/arch/i386/kernel/Makefile	2004-12-24 13:36:19 -08:00
+++ b/arch/i386/kernel/Makefile	2004-12-24 13:36:19 -08:00
@@ -5,9 +5,9 @@
 extra-y := head.o init_task.o vmlinux.lds
 
 obj-y	:= process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \
-		ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_i386.o \
+		ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
 		pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \
-		doublefault.o
+		doublefault.o quirks.o
 
 obj-y				+= cpu/
 obj-y				+= timers/
diff -Nru a/arch/i386/kernel/acpi/Makefile b/arch/i386/kernel/acpi/Makefile
--- a/arch/i386/kernel/acpi/Makefile	2004-12-24 13:36:49 -08:00
+++ b/arch/i386/kernel/acpi/Makefile	2004-12-24 13:36:49 -08:00
@@ -1,3 +1,4 @@
 obj-$(CONFIG_ACPI_BOOT)		:= boot.o
+obj-$(CONFIG_X86_IO_APIC)	+= earlyquirk.o
 obj-$(CONFIG_ACPI_SLEEP)	+= sleep.o wakeup.o
 
diff -Nru a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
--- a/arch/i386/kernel/acpi/boot.c	2004-12-24 13:37:19 -08:00
+++ b/arch/i386/kernel/acpi/boot.c	2004-12-24 13:37:19 -08:00
@@ -40,7 +40,7 @@
 #ifdef	CONFIG_X86_64
 
 static inline void  acpi_madt_oem_check(char *oem_id, char *oem_table_id) { }
-static inline void clustered_apic_check(void) { }
+extern void __init clustered_apic_check(void);
 static inline int ioapic_setup_disabled(void) { return 0; }
 #include <asm/proto.h>
 
@@ -409,28 +409,38 @@
 void __init
 acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
 {
-	unsigned char mask = 1 << (irq & 7);
-	unsigned int port = 0x4d0 + (irq >> 3);
-	unsigned char val = inb(port);
+	unsigned int mask = 1 << irq;
+	unsigned int old, new;
 
-	
-	printk(PREFIX "IRQ%d SCI:", irq);
-	if (!(val & mask)) {
-		printk(" Edge");
-
-		if (trigger == 3) {
-			printk(" set to Level");
-			outb(val | mask, port);
-		}
-	} else {
-		printk(" Level");
+	/* Real old ELCR mask */
+	old = inb(0x4d0) | (inb(0x4d1) << 8);
 
-		if (trigger == 1) {
-			printk(" set to Edge");
-			outb(val & ~mask, port);
-		}
-	}
-	printk(" Trigger.\n");
+	/*
+	 * If we use ACPI to set PCI irq's, then we should clear ELCR
+	 * since we will set it correctly as we enable the PCI irq
+	 * routing.
+	 */
+	new = acpi_noirq ? old : 0;
+
+	/*
+	 * Update SCI information in the ELCR, it isn't in the PCI
+	 * routing tables..
+	 */
+	switch (trigger) {
+	case 1:	/* Edge - clear */
+		new &= ~mask;
+		break;
+	case 3: /* Level - set */
+		new |= mask;
+		break;
+	}
+
+	if (old == new)
+		return;
+
+	printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
+	outb(new, 0x4d0);
+	outb(new >> 8, 0x4d1);
 }
 
 
@@ -450,31 +460,26 @@
 unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
 {
 	unsigned int irq;
+	unsigned int plat_gsi = gsi;
 
 #ifdef CONFIG_PCI
 	/*
 	 * Make sure all (legacy) PCI IRQs are set as level-triggered.
 	 */
 	if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
-		static u16 irq_mask;
 		extern void eisa_set_level_irq(unsigned int irq);
 
-		if (edge_level == ACPI_LEVEL_SENSITIVE) {
-			if ((gsi < 16) && !((1 << gsi) & irq_mask)) {
-				Dprintk(KERN_DEBUG PREFIX "Setting GSI %u as level-triggered\n", gsi);
-				irq_mask |= (1 << gsi);
+		if (edge_level == ACPI_LEVEL_SENSITIVE)
 				eisa_set_level_irq(gsi);
-			}
-		}
 	}
 #endif
 
 #ifdef CONFIG_X86_IO_APIC
 	if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
-		mp_register_gsi(gsi, edge_level, active_high_low);
+		plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
 	}
 #endif
-	acpi_gsi_to_irq(gsi, &irq);
+	acpi_gsi_to_irq(plat_gsi, &irq);
 	return irq;
 }
 EXPORT_SYMBOL(acpi_register_gsi);
@@ -748,7 +753,7 @@
 	int count, error;
 
 	count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
-	if (count == 1) {
+	if (count >= 1) {
 
 		/*
 		 * Parse MADT LAPIC entries
@@ -822,6 +827,10 @@
 		disable_acpi();
 		return error;
 	}
+
+#ifdef __i386__
+	check_acpi_pci();
+#endif
 
 	acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
 
diff -Nru a/arch/i386/kernel/acpi/earlyquirk.c b/arch/i386/kernel/acpi/earlyquirk.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/i386/kernel/acpi/earlyquirk.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,51 @@
+/* 
+ * Do early PCI probing for bug detection when the main PCI subsystem is 
+ * not up yet.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <asm/pci-direct.h>
+#include <asm/acpi.h>
+
+static int __init check_bridge(int vendor, int device) 
+{
+	/* According to Nvidia all timer overrides are bogus. Just ignore
+	   them all. */
+	if (vendor == PCI_VENDOR_ID_NVIDIA) { 
+		acpi_skip_timer_override = 1; 		
+	}
+	return 0;
+}
+   
+void __init check_acpi_pci(void) 
+{ 
+	int num,slot,func; 
+
+	/* Assume the machine supports type 1. If not it will 
+	   always read ffffffff and should not have any side effect. */
+
+	/* Poor man's PCI discovery */
+	for (num = 0; num < 32; num++) { 
+		for (slot = 0; slot < 32; slot++) { 
+			for (func = 0; func < 8; func++) { 
+				u32 class;
+				u32 vendor;
+				class = read_pci_config(num,slot,func,
+							PCI_CLASS_REVISION);
+				if (class == 0xffffffff)
+					break; 
+
+				if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
+					continue; 
+				
+				vendor = read_pci_config(num, slot, func, 
+							 PCI_VENDOR_ID);
+				
+				if (check_bridge(vendor&0xffff, vendor >> 16))
+					return; 
+			} 
+			
+		}
+	}
+}
diff -Nru a/arch/i386/kernel/acpi/sleep.c b/arch/i386/kernel/acpi/sleep.c
--- a/arch/i386/kernel/acpi/sleep.c	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/kernel/acpi/sleep.c	2004-12-24 13:36:48 -08:00
@@ -56,7 +56,7 @@
 }
 
 /*
- * acpi_restore_state
+ * acpi_restore_state - undo effects of acpi_save_state_mem
  */
 void acpi_restore_state_mem (void)
 {
diff -Nru a/arch/i386/kernel/acpi/wakeup.S b/arch/i386/kernel/acpi/wakeup.S
--- a/arch/i386/kernel/acpi/wakeup.S	2004-12-24 13:36:30 -08:00
+++ b/arch/i386/kernel/acpi/wakeup.S	2004-12-24 13:36:30 -08:00
@@ -59,6 +59,14 @@
 	movl	$swapper_pg_dir-__PAGE_OFFSET, %eax
 	movl	%eax, %cr3
 
+	testl	$1, real_efer_save_restore - wakeup_code
+	jz	4f
+	# restore efer setting
+	movl	real_save_efer_edx - wakeup_code, %edx
+	movl	real_save_efer_eax - wakeup_code, %eax
+	mov     $0xc0000080, %ecx
+	wrmsr
+4:
 	# make sure %cr4 is set correctly (features, etc)
 	movl	real_save_cr4 - wakeup_code, %eax
 	movl	%eax, %cr4
@@ -89,6 +97,9 @@
 real_magic:	.long 0
 video_mode:	.long 0
 video_flags:	.long 0
+real_efer_save_restore:	.long 0
+real_save_efer_edx: 	.long 0
+real_save_efer_eax: 	.long 0
 
 bogus_real_magic:
 	movw	$0x0e00 + 'B', %fs:(0x12)
@@ -222,6 +233,20 @@
 	sidt	saved_idt
 	sldt	saved_ldt
 	str	saved_tss
+
+	movl	nx_enabled, %edx
+	movl	%edx, real_efer_save_restore - wakeup_start (%eax)
+	testl	$1, real_efer_save_restore - wakeup_start (%eax)
+	jz	2f
+	# save efer setting
+	pushl	%eax
+	movl	%eax, %ebx
+	mov     $0xc0000080, %ecx
+	rdmsr
+	movl	%edx, real_save_efer_edx - wakeup_start (%ebx)
+	movl	%eax, real_save_efer_eax - wakeup_start (%ebx)
+	popl	%eax
+2:
 
 	movl    %cr3, %edx
 	movl    %edx, real_save_cr3 - wakeup_start (%eax)
diff -Nru a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
--- a/arch/i386/kernel/apic.c	2004-12-24 13:37:32 -08:00
+++ b/arch/i386/kernel/apic.c	2004-12-24 13:37:32 -08:00
@@ -47,6 +47,24 @@
 
 static void apic_pm_activate(void);
 
+/*
+ * 'what should we do if we get a hw irq event on an illegal vector'.
+ * each architecture has to answer this themselves.
+ */
+void ack_bad_irq(unsigned int irq)
+{
+	printk("unexpected IRQ trap at vector %02x\n", irq);
+	/*
+	 * Currently unexpected vectors happen only on SMP and APIC.
+	 * We _must_ ack these because every local APIC has only N
+	 * irq slots per priority level, and a 'hanging, unacked' IRQ
+	 * holds up an irq slot - in excessive cases (when multiple
+	 * unexpected vectors occur) that might lock up the APIC
+	 * completely.
+	 */
+	ack_APIC_irq();
+}
+
 void __init apic_intr_init(void)
 {
 #ifdef CONFIG_SMP
@@ -282,6 +300,10 @@
 
 void __init sync_Arb_IDs(void)
 {
+	/* Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 */
+	unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
+	if (ver >= 0x14)	/* P4 or higher */
+		return;
 	/*
 	 * Wait for idle.
 	 */
@@ -491,12 +513,25 @@
 	apic_pm_activate();
 }
 
+/*
+ * If Linux enabled the LAPIC against the BIOS default
+ * disable it down before re-entering the BIOS on shutdown.
+ * Otherwise the BIOS may get confused and not power-off.
+ */
+void
+lapic_shutdown()
+{
+	if (!cpu_has_apic || !enabled_via_apicbase)
+		return;
+
+	local_irq_disable();
+	disable_local_APIC();
+	local_irq_enable();
+}
+
 #ifdef CONFIG_PM
 
 static struct {
-	/* 'active' is true if the local APIC was enabled by us and
-	   not the BIOS; this signifies that we are also responsible
-	   for disabling it before entering apm/acpi suspend */
 	int active;
 	/* r/w apic fields */
 	unsigned int apic_id;
@@ -584,6 +619,10 @@
 	return 0;
 }
 
+/*
+ * This device has no shutdown method - fully functioning local APICs
+ * are needed on every CPU up until machine_halt/restart/poweroff.
+ */
 
 static struct sysdev_class lapic_sysclass = {
 	set_kset_name("lapic"),
@@ -667,7 +706,7 @@
 	u32 h, l, features;
 	extern void get_cpu_vendor(struct cpuinfo_x86*);
 
-	/* Disabled by DMI scan or kernel option? */
+	/* Disabled by kernel option? */
 	if (enable_local_apic < 0)
 		return -1;
 
@@ -681,8 +720,7 @@
 			break;
 		goto no_apic;
 	case X86_VENDOR_INTEL:
-		if (boot_cpu_data.x86 == 6 ||
-		    (boot_cpu_data.x86 == 15 && (cpu_has_apic || enable_local_apic > 0)) ||
+		if (boot_cpu_data.x86 == 6 || boot_cpu_data.x86 == 15 ||
 		    (boot_cpu_data.x86 == 5 && cpu_has_apic))
 			break;
 		goto no_apic;
@@ -692,20 +730,23 @@
 
 	if (!cpu_has_apic) {
 		/*
-		 * Over-ride BIOS and try to enable LAPIC
-		 * only if "lapic" specified
+		 * Over-ride BIOS and try to enable the local
+		 * APIC only if "lapic" specified.
 		 */
-		if (enable_local_apic != 1)
-			goto no_apic;
+		if (enable_local_apic <= 0) {
+			printk("Local APIC disabled by BIOS -- "
+			       "you can enable it with \"lapic\"\n");
+			return -1;
+		}
 		/*
 		 * Some BIOSes disable the local APIC in the
 		 * APIC_BASE MSR. This can only be done in
-		 * software for Intel P6 and AMD K7 (Model > 1).
+		 * software for Intel P6 or later and AMD K7
+		 * (Model > 1) or later.
 		 */
 		rdmsr(MSR_IA32_APICBASE, l, h);
 		if (!(l & MSR_IA32_APICBASE_ENABLE)) {
-			apic_printk(APIC_VERBOSE, "Local APIC disabled "
-					"by BIOS -- reenabling.\n");
+			printk("Local APIC disabled by BIOS -- reenabling.\n");
 			l &= ~MSR_IA32_APICBASE_BASE;
 			l |= MSR_IA32_APICBASE_ENABLE | APIC_DEFAULT_PHYS_BASE;
 			wrmsr(MSR_IA32_APICBASE, l, h);
@@ -732,7 +773,7 @@
 	if (nmi_watchdog != NMI_NONE)
 		nmi_watchdog = NMI_LOCAL_APIC;
 
-	apic_printk(APIC_VERBOSE, "Found and enabled local APIC!\n");
+	printk("Found and enabled local APIC!\n");
 
 	apic_pm_activate();
 
@@ -759,8 +800,8 @@
 		apic_phys = mp_lapic_addr;
 
 	set_fixmap_nocache(FIX_APIC_BASE, apic_phys);
-	apic_printk(APIC_DEBUG, "mapped APIC to %08lx (%08lx)\n", APIC_BASE,
-			apic_phys);
+	printk(KERN_DEBUG "mapped APIC to %08lx (%08lx)\n", APIC_BASE,
+	       apic_phys);
 
 	/*
 	 * Fetch the APIC ID of the BSP in case we have a
@@ -778,21 +819,23 @@
 			if (smp_found_config) {
 				ioapic_phys = mp_ioapics[i].mpc_apicaddr;
 				if (!ioapic_phys) {
-					printk(KERN_ERR "WARNING: bogus zero IO-APIC address found in MPTABLE, disabling IO/APIC support!\n");
-
+					printk(KERN_ERR
+					       "WARNING: bogus zero IO-APIC "
+					       "address found in MPTABLE, "
+					       "disabling IO/APIC support!\n");
 					smp_found_config = 0;
 					skip_ioapic_setup = 1;
 					goto fake_ioapic_page;
 				}
 			} else {
 fake_ioapic_page:
-				ioapic_phys = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
+				ioapic_phys = (unsigned long)
+					      alloc_bootmem_pages(PAGE_SIZE);
 				ioapic_phys = __pa(ioapic_phys);
 			}
 			set_fixmap_nocache(idx, ioapic_phys);
-			apic_printk(APIC_DEBUG, "mapped IOAPIC to "
-					"%08lx (%08lx)\n",
-					__fix_to_virt(idx), ioapic_phys);
+			printk(KERN_DEBUG "mapped IOAPIC to %08lx (%08lx)\n",
+			       __fix_to_virt(idx), ioapic_phys);
 			idx++;
 		}
 	}
@@ -1123,7 +1166,7 @@
  *   interrupt as well. Thus we cannot inline the local irq ... ]
  */
 
-void smp_apic_timer_interrupt(struct pt_regs regs)
+fastcall void smp_apic_timer_interrupt(struct pt_regs *regs)
 {
 	int cpu = smp_processor_id();
 
@@ -1143,14 +1186,14 @@
 	 * interrupt lock, which is the WrongThing (tm) to do.
 	 */
 	irq_enter();
-	smp_local_timer_interrupt(&regs);
+	smp_local_timer_interrupt(regs);
 	irq_exit();
 }
 
 /*
  * This interrupt should _never_ happen with our APIC/SMP architecture
  */
-asmlinkage void smp_spurious_interrupt(void)
+fastcall void smp_spurious_interrupt(struct pt_regs *regs)
 {
 	unsigned long v;
 
@@ -1174,7 +1217,7 @@
  * This interrupt should never happen with our APIC/SMP architecture
  */
 
-asmlinkage void smp_error_interrupt(void)
+fastcall void smp_error_interrupt(struct pt_regs *regs)
 {
 	unsigned long v, v1;
 
diff -Nru a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
--- a/arch/i386/kernel/apm.c	2004-12-24 13:36:17 -08:00
+++ b/arch/i386/kernel/apm.c	2004-12-24 13:36:17 -08:00
@@ -2393,27 +2393,27 @@
 MODULE_AUTHOR("Stephen Rothwell");
 MODULE_DESCRIPTION("Advanced Power Management");
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
+module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, "Enable debug mode");
-MODULE_PARM(power_off, "i");
+module_param(power_off, bool, 0444);
 MODULE_PARM_DESC(power_off, "Enable power off");
-MODULE_PARM(bounce_interval, "i");
+module_param(bounce_interval, int, 0444);
 MODULE_PARM_DESC(bounce_interval,
 		"Set the number of ticks to ignore suspend bounces");
-MODULE_PARM(allow_ints, "i");
+module_param(allow_ints, bool, 0444);
 MODULE_PARM_DESC(allow_ints, "Allow interrupts during BIOS calls");
-MODULE_PARM(broken_psr, "i");
+module_param(broken_psr, bool, 0444);
 MODULE_PARM_DESC(broken_psr, "BIOS has a broken GetPowerStatus call");
-MODULE_PARM(realmode_power_off, "i");
+module_param(realmode_power_off, bool, 0444);
 MODULE_PARM_DESC(realmode_power_off,
 		"Switch to real mode before powering off");
-MODULE_PARM(idle_threshold, "i");
+module_param(idle_threshold, int, 0444);
 MODULE_PARM_DESC(idle_threshold,
 	"System idle percentage above which to make APM BIOS idle calls");
-MODULE_PARM(idle_period, "i");
+module_param(idle_period, int, 0444);
 MODULE_PARM_DESC(idle_period,
 	"Period (in sec/100) over which to caculate the idle percentage");
-MODULE_PARM(smp, "i");
+module_param(smp, bool, 0444);
 MODULE_PARM_DESC(smp,
 	"Set this to enable APM use on an SMP platform. Use with caution on older systems");
 MODULE_ALIAS_MISCDEV(APM_MINOR_DEV);
diff -Nru a/arch/i386/kernel/cpu/Makefile b/arch/i386/kernel/cpu/Makefile
--- a/arch/i386/kernel/cpu/Makefile	2004-12-24 13:36:56 -08:00
+++ b/arch/i386/kernel/cpu/Makefile	2004-12-24 13:36:56 -08:00
@@ -8,7 +8,7 @@
 obj-y	+=	cyrix.o
 obj-y	+=	centaur.o
 obj-y	+=	transmeta.o
-obj-y	+=	intel.o
+obj-y	+=	intel.o intel_cacheinfo.o
 obj-y	+=	rise.o
 obj-y	+=	nexgen.o
 obj-y	+=	umc.o
diff -Nru a/arch/i386/kernel/cpu/cpufreq/Kconfig b/arch/i386/kernel/cpu/cpufreq/Kconfig
--- a/arch/i386/kernel/cpu/cpufreq/Kconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/Kconfig	2004-12-24 13:36:31 -08:00
@@ -4,18 +4,6 @@
 
 menu "CPU Frequency scaling"
 
-config CPU_FREQ
-	bool "CPU Frequency scaling"
-	help
-	  Clock scaling allows you to change the clock speed of CPUs on the
-	  fly. This is a nice method to save battery power on notebooks,
-	  because the lower the clock speed, the less power the CPU consumes.
-
-	  For more information, take a look at <file:Documentation/cpu-freq/>
-	  or at <http://www.codemonkey.org.uk/projects/cpufreq/>
-
-	  If in doubt, say N.
-
 source "drivers/cpufreq/Kconfig"
 
 config CPU_FREQ_TABLE
@@ -42,16 +30,6 @@
 
 	  If in doubt, say N.
 
-config X86_ACPI_CPUFREQ_PROC_INTF
-        bool "/proc/acpi/processor/../performance interface (deprecated)"
-	depends on X86_ACPI_CPUFREQ && PROC_FS
-	help
-	  This enables the deprecated /proc/acpi/processor/../performance 
-	  interface. While it is helpful for debugging, the generic,
-	  cross-architecture cpufreq interfaces should be used.
-
-	  If in doubt, say N.
-
 config ELAN_CPUFREQ
 	tristate "AMD Elan"
 	depends on CPU_FREQ_TABLE && X86_ELAN
@@ -95,7 +73,7 @@
 
 config X86_POWERNOW_K8
 	tristate "AMD Opteron/Athlon64 PowerNow!"
-	depends on CPU_FREQ && EXPERIMENTAL
+	depends on CPU_FREQ_TABLE && EXPERIMENTAL
 	help
 	  This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors.
 
@@ -122,29 +100,40 @@
 config X86_SPEEDSTEP_CENTRINO
 	tristate "Intel Enhanced SpeedStep"
 	depends on CPU_FREQ_TABLE
+	select X86_SPEEDSTEP_CENTRINO_TABLE if (!X86_SPEEDSTEP_CENTRINO_ACPI)
 	help
 	  This adds the CPUFreq driver for Enhanced SpeedStep enabled
-	  mobile CPUs.  This means Intel Pentium M (Centrino) CPUs.
+	  mobile CPUs.  This means Intel Pentium M (Centrino) CPUs. However,
+	  you also need to say Y to "Use ACPI tables to decode..." below
+	  [which might imply enabling ACPI] if you want to use this driver
+	  on non-Banias CPUs.
 	  
 	  For details, take a look at <file:Documentation/cpu-freq/>.
 	  
 	  If in doubt, say N.
 
-config X86_SPEEDSTEP_CENTRINO_TABLE
-	bool
-	depends on X86_SPEEDSTEP_CENTRINO
-	default y
-
 config X86_SPEEDSTEP_CENTRINO_ACPI
-	bool "Use ACPI tables to decode valid frequency/voltage pairs (EXPERIMENTAL)"
-	depends on EXPERIMENTAL
+	bool "Use ACPI tables to decode valid frequency/voltage pairs"
+	depends on X86_SPEEDSTEP_CENTRINO
 	depends on ((X86_SPEEDSTEP_CENTRINO = "m" && ACPI_PROCESSOR) || (X86_SPEEDSTEP_CENTRINO = "y" && ACPI_PROCESSOR = "y"))
+	default y
 	help
 	  Use primarily the information provided in the BIOS ACPI tables
-	  to determine valid CPU frequency and voltage pairings.
+	  to determine valid CPU frequency and voltage pairings. It is
+	  required for the driver to work on non-Banias CPUs.
 
 	  If in doubt, say Y.
 
+config X86_SPEEDSTEP_CENTRINO_TABLE
+	bool "Built-in tables for Banias CPUs"
+	depends on X86_SPEEDSTEP_CENTRINO
+	default y
+	help
+	  Use built-in tables for Banias CPUs if ACPI encoding
+	  is not available.
+
+	  If in doubt, say N.
+
 config X86_SPEEDSTEP_ICH
 	tristate "Intel Speedstep on ICH-M chipsets (ioport interface)"
 	depends on CPU_FREQ_TABLE
@@ -181,27 +170,23 @@
 
 	  If in doubt, say N.
 
-config X86_SPEEDSTEP_LIB
-	tristate
-	depends on (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD)
-	default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD)
-
-config X86_SPEEDSTEP_RELAXED_CAP_CHECK
-	bool "Relaxed speedstep capability checks"
-	depends on (X86_SPEEDSTEP_SMI || X86_SPEEDSTEP_ICH)
+config X86_CPUFREQ_NFORCE2
+	tristate "nVidia nForce2 FSB changing"
+	depends on CPU_FREQ && EXPERIMENTAL
 	help
-	  Don't perform all checks for a speedstep capable system which would 
-	  normally be done. Some ancient or strange systems, though speedstep 
-	  capable, don't always indicate that they are speedstep capable. This 
-	  option let's the probing code bypass some of those checks if the
-	  parameter "relaxed_check=1" is passed to the module.
+	  This adds the CPUFreq driver for FSB changing on nVidia nForce2
+	  plattforms.
+
+	  For details, take a look at <file:Documentation/cpu-freq/>.
+
+	  If in doubt, say N.
 
 config X86_LONGRUN
 	tristate "Transmeta LongRun"
 	depends on CPU_FREQ
 	help
-	  This adds the CPUFreq driver for Transmeta Crusoe processors which
-	  support LongRun.
+	  This adds the CPUFreq driver for Transmeta Crusoe and Efficeon processors
+	  which support LongRun.
 
 	  For details, take a look at <file:Documentation/cpu-freq/>.
 
@@ -218,5 +203,35 @@
 	  For details, take a look at <file:Documentation/cpu-freq/>.
 
 	  If in doubt, say N.
+
+comment "shared options"
+	depends on CPU_FREQ
+
+config X86_ACPI_CPUFREQ_PROC_INTF
+        bool "/proc/acpi/processor/../performance interface (deprecated)"
+	depends on PROC_FS
+	depends on X86_ACPI_CPUFREQ || X86_SPEEDSTEP_CENTRINO_ACPI || X86_POWERNOW_K7_ACPI || X86_POWERNOW_K8_ACPI
+	help
+	  This enables the deprecated /proc/acpi/processor/../performance 
+	  interface. While it is helpful for debugging, the generic,
+	  cross-architecture cpufreq interfaces should be used.
+
+	  If in doubt, say N.
+
+config X86_SPEEDSTEP_LIB
+	tristate
+	depends on (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD)
+	default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD)
+
+config X86_SPEEDSTEP_RELAXED_CAP_CHECK
+	bool "Relaxed speedstep capability checks"
+	depends on (X86_SPEEDSTEP_SMI || X86_SPEEDSTEP_ICH)
+	help
+	  Don't perform all checks for a speedstep capable system which would 
+	  normally be done. Some ancient or strange systems, though speedstep 
+	  capable, don't always indicate that they are speedstep capable. This 
+	  option lets the probing code bypass some of those checks if the
+	  parameter "relaxed_check=1" is passed to the module.
+
 
 endmenu
diff -Nru a/arch/i386/kernel/cpu/cpufreq/Makefile b/arch/i386/kernel/cpu/cpufreq/Makefile
--- a/arch/i386/kernel/cpu/cpufreq/Makefile	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/Makefile	2004-12-24 13:36:48 -08:00
@@ -1,19 +1,14 @@
-obj-$(CONFIG_X86_POWERNOW_K6)	+= powernow-k6.o
-obj-$(CONFIG_X86_POWERNOW_K7)	+= powernow-k7.o
-obj-$(CONFIG_X86_POWERNOW_K8)	+= powernow-k8.o
-obj-$(CONFIG_X86_LONGHAUL)	+= longhaul.o
-obj-$(CONFIG_ELAN_CPUFREQ)	+= elanfreq.o
-obj-$(CONFIG_X86_LONGRUN)	+= longrun.o  
-obj-$(CONFIG_X86_GX_SUSPMOD)    += gx-suspmod.o
-obj-$(CONFIG_X86_SPEEDSTEP_ICH)	+= speedstep-ich.o
-obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
-obj-$(CONFIG_X86_SPEEDSTEP_LIB) += speedstep-lib.o
-obj-$(CONFIG_X86_SPEEDSTEP_SMI) += speedstep-smi.o
-obj-$(CONFIG_X86_ACPI_CPUFREQ)	+= acpi.o
-obj-$(CONFIG_X86_P4_CLOCKMOD)	+= p4-clockmod.o
-
-ifdef CONFIG_X86_ACPI_CPUFREQ
-  ifdef CONFIG_ACPI_DEBUG
-    EXTRA_CFLAGS += -DACPI_DEBUG_OUTPUT
-  endif
-endif
+obj-$(CONFIG_X86_POWERNOW_K6)		+= powernow-k6.o
+obj-$(CONFIG_X86_POWERNOW_K7)		+= powernow-k7.o
+obj-$(CONFIG_X86_POWERNOW_K8)		+= powernow-k8.o
+obj-$(CONFIG_X86_LONGHAUL)		+= longhaul.o
+obj-$(CONFIG_ELAN_CPUFREQ)		+= elanfreq.o
+obj-$(CONFIG_X86_LONGRUN)		+= longrun.o  
+obj-$(CONFIG_X86_GX_SUSPMOD)		+= gx-suspmod.o
+obj-$(CONFIG_X86_SPEEDSTEP_ICH)		+= speedstep-ich.o
+obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO)	+= speedstep-centrino.o
+obj-$(CONFIG_X86_SPEEDSTEP_LIB)		+= speedstep-lib.o
+obj-$(CONFIG_X86_SPEEDSTEP_SMI)		+= speedstep-smi.o
+obj-$(CONFIG_X86_ACPI_CPUFREQ)		+= acpi-cpufreq.o
+obj-$(CONFIG_X86_P4_CLOCKMOD)		+= p4-clockmod.o
+obj-$(CONFIG_X86_CPUFREQ_NFORCE2)	+= cpufreq-nforce2.o
diff -Nru a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c	2004-12-24 13:36:18 -08:00
@@ -0,0 +1,509 @@
+/*
+ * acpi-cpufreq.c - ACPI Processor P-States Driver ($Revision: 1.3 $)
+ *
+ *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
+ *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2002 - 2004 Dominik Brodowski <linux@brodo.de>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/cpufreq.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/io.h>
+#include <asm/delay.h>
+#include <asm/uaccess.h>
+
+#include <linux/acpi.h>
+#include <acpi/processor.h>
+
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg)
+
+MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
+MODULE_DESCRIPTION("ACPI Processor P-States Driver");
+MODULE_LICENSE("GPL");
+
+
+struct cpufreq_acpi_io {
+	struct acpi_processor_performance	acpi_data;
+	struct cpufreq_frequency_table		*freq_table;
+};
+
+static struct cpufreq_acpi_io	*acpi_io_data[NR_CPUS];
+
+
+static int
+acpi_processor_write_port(
+	u16	port,
+	u8	bit_width,
+	u32	value)
+{
+	if (bit_width <= 8) {
+		outb(value, port);
+	} else if (bit_width <= 16) {
+		outw(value, port);
+	} else if (bit_width <= 32) {
+		outl(value, port);
+	} else {
+		return -ENODEV;
+	}
+	return 0;
+}
+
+static int
+acpi_processor_read_port(
+	u16	port,
+	u8	bit_width,
+	u32	*ret)
+{
+	*ret = 0;
+	if (bit_width <= 8) {
+		*ret = inb(port);
+	} else if (bit_width <= 16) {
+		*ret = inw(port);
+	} else if (bit_width <= 32) {
+		*ret = inl(port);
+	} else {
+		return -ENODEV;
+	}
+	return 0;
+}
+
+static int
+acpi_processor_set_performance (
+	struct cpufreq_acpi_io	*data,
+	unsigned int		cpu,
+	int			state)
+{
+	u16			port = 0;
+	u8			bit_width = 0;
+	int			ret = 0;
+	u32			value = 0;
+	int			i = 0;
+	struct cpufreq_freqs    cpufreq_freqs;
+	cpumask_t		saved_mask;
+	int			retval;
+
+	dprintk("acpi_processor_set_performance\n");
+
+	/*
+	 * TBD: Use something other than set_cpus_allowed.
+	 * As set_cpus_allowed is a bit racy, 
+	 * with any other set_cpus_allowed for this process.
+	 */
+	saved_mask = current->cpus_allowed;
+	set_cpus_allowed(current, cpumask_of_cpu(cpu));
+	if (smp_processor_id() != cpu) {
+		return (-EAGAIN);
+	}
+	
+	if (state == data->acpi_data.state) {
+		dprintk("Already at target state (P%d)\n", state);
+		retval = 0;
+		goto migrate_end;
+	}
+
+	dprintk("Transitioning from P%d to P%d\n",
+		data->acpi_data.state, state);
+
+	/* cpufreq frequency struct */
+	cpufreq_freqs.cpu = cpu;
+	cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency;
+	cpufreq_freqs.new = data->freq_table[state].frequency;
+
+	/* notify cpufreq */
+	cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE);
+
+	/*
+	 * First we write the target state's 'control' value to the
+	 * control_register.
+	 */
+
+	port = data->acpi_data.control_register.address;
+	bit_width = data->acpi_data.control_register.bit_width;
+	value = (u32) data->acpi_data.states[state].control;
+
+	dprintk("Writing 0x%08x to port 0x%04x\n", value, port);
+
+	ret = acpi_processor_write_port(port, bit_width, value);
+	if (ret) {
+		dprintk("Invalid port width 0x%04x\n", bit_width);
+		retval = ret;
+		goto migrate_end;
+	}
+
+	/*
+	 * Then we read the 'status_register' and compare the value with the
+	 * target state's 'status' to make sure the transition was successful.
+	 * Note that we'll poll for up to 1ms (100 cycles of 10us) before
+	 * giving up.
+	 */
+
+	port = data->acpi_data.status_register.address;
+	bit_width = data->acpi_data.status_register.bit_width;
+
+	dprintk("Looking for 0x%08x from port 0x%04x\n",
+		(u32) data->acpi_data.states[state].status, port);
+
+	for (i=0; i<100; i++) {
+		ret = acpi_processor_read_port(port, bit_width, &value);
+		if (ret) {	
+			dprintk("Invalid port width 0x%04x\n", bit_width);
+			retval = ret;
+			goto migrate_end;
+		}
+		if (value == (u32) data->acpi_data.states[state].status)
+			break;
+		udelay(10);
+	}
+
+	/* notify cpufreq */
+	cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
+
+	if (value != (u32) data->acpi_data.states[state].status) {
+		unsigned int tmp = cpufreq_freqs.new;
+		cpufreq_freqs.new = cpufreq_freqs.old;
+		cpufreq_freqs.old = tmp;
+		cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE);
+		cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
+		printk(KERN_WARNING "acpi-cpufreq: Transition failed\n");
+		retval = -ENODEV;
+		goto migrate_end;
+	}
+
+	dprintk("Transition successful after %d microseconds\n", i * 10);
+
+	data->acpi_data.state = state;
+
+	retval = 0;
+migrate_end:
+	set_cpus_allowed(current, saved_mask);
+	return (retval);
+}
+
+
+static int
+acpi_cpufreq_target (
+	struct cpufreq_policy   *policy,
+	unsigned int target_freq,
+	unsigned int relation)
+{
+	struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
+	unsigned int next_state = 0;
+	unsigned int result = 0;
+
+	dprintk("acpi_cpufreq_setpolicy\n");
+
+	result = cpufreq_frequency_table_target(policy,
+			data->freq_table,
+			target_freq,
+			relation,
+			&next_state);
+	if (result)
+		return (result);
+
+	result = acpi_processor_set_performance (data, policy->cpu, next_state);
+
+	return (result);
+}
+
+
+static int
+acpi_cpufreq_verify (
+	struct cpufreq_policy   *policy)
+{
+	unsigned int result = 0;
+	struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
+
+	dprintk("acpi_cpufreq_verify\n");
+
+	result = cpufreq_frequency_table_verify(policy, 
+			data->freq_table);
+
+	return (result);
+}
+
+
+static unsigned long
+acpi_cpufreq_guess_freq (
+	struct cpufreq_acpi_io	*data,
+	unsigned int		cpu)
+{
+	if (cpu_khz) {
+		/* search the closest match to cpu_khz */
+		unsigned int i;
+		unsigned long freq;
+		unsigned long freqn = data->acpi_data.states[0].core_frequency * 1000;
+
+		for (i=0; i < (data->acpi_data.state_count - 1); i++) {
+			freq = freqn;
+			freqn = data->acpi_data.states[i+1].core_frequency * 1000;
+			if ((2 * cpu_khz) > (freqn + freq)) {
+				data->acpi_data.state = i;
+				return (freq);
+			}
+		}
+		data->acpi_data.state = data->acpi_data.state_count - 1;
+		return (freqn);
+	} else
+		/* assume CPU is at P0... */
+		data->acpi_data.state = 0;
+		return data->acpi_data.states[0].core_frequency * 1000;
+	
+}
+
+
+/* 
+ * acpi_processor_cpu_init_pdc_est - let BIOS know about the SMP capabilities
+ * of this driver
+ * @perf: processor-specific acpi_io_data struct
+ * @cpu: CPU being initialized
+ *
+ * To avoid issues with legacy OSes, some BIOSes require to be informed of
+ * the SMP capabilities of OS P-state driver. Here we set the bits in _PDC 
+ * accordingly, for Enhanced Speedstep. Actual call to _PDC is done in
+ * driver/acpi/processor.c
+ */
+static void 
+acpi_processor_cpu_init_pdc_est(
+		struct acpi_processor_performance *perf, 
+		unsigned int cpu,
+		struct acpi_object_list *obj_list
+		)
+{
+	union acpi_object *obj;
+	u32 *buf;
+	struct cpuinfo_x86 *c = cpu_data + cpu;
+	dprintk("acpi_processor_cpu_init_pdc_est\n");
+
+	if (!cpu_has(c, X86_FEATURE_EST))
+		return;
+
+	/* Initialize pdc. It will be used later. */
+	if (!obj_list)
+		return;
+		
+	if (!(obj_list->count && obj_list->pointer))
+		return;
+
+	obj = obj_list->pointer;
+	if ((obj->buffer.length == 12) && obj->buffer.pointer) {
+		buf = (u32 *)obj->buffer.pointer;
+       		buf[0] = ACPI_PDC_REVISION_ID;
+       		buf[1] = 1;
+       		buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
+		perf->pdc = obj_list;
+	}
+	return;
+}
+ 
+
+/* CPU specific PDC initialization */
+static void 
+acpi_processor_cpu_init_pdc(
+		struct acpi_processor_performance *perf, 
+		unsigned int cpu,
+		struct acpi_object_list *obj_list
+		)
+{
+	struct cpuinfo_x86 *c = cpu_data + cpu;
+	dprintk("acpi_processor_cpu_init_pdc\n");
+	perf->pdc = NULL;
+	if (cpu_has(c, X86_FEATURE_EST))
+		acpi_processor_cpu_init_pdc_est(perf, cpu, obj_list);
+	return;
+}
+
+
+static int
+acpi_cpufreq_cpu_init (
+	struct cpufreq_policy   *policy)
+{
+	unsigned int		i;
+	unsigned int		cpu = policy->cpu;
+	struct cpufreq_acpi_io	*data;
+	unsigned int		result = 0;
+
+	union acpi_object		arg0 = {ACPI_TYPE_BUFFER};
+	u32				arg0_buf[3];
+	struct acpi_object_list 	arg_list = {1, &arg0};
+
+	dprintk("acpi_cpufreq_cpu_init\n");
+	/* setup arg_list for _PDC settings */
+        arg0.buffer.length = 12;
+        arg0.buffer.pointer = (u8 *) arg0_buf;
+
+	data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
+	if (!data)
+		return (-ENOMEM);
+	memset(data, 0, sizeof(struct cpufreq_acpi_io));
+
+	acpi_io_data[cpu] = data;
+
+	acpi_processor_cpu_init_pdc(&data->acpi_data, cpu, &arg_list);
+	result = acpi_processor_register_performance(&data->acpi_data, cpu);
+	data->acpi_data.pdc = NULL;
+
+	if (result)
+		goto err_free;
+
+	/* capability check */
+	if (data->acpi_data.state_count <= 1) {
+		dprintk("No P-States\n");
+		result = -ENODEV;
+		goto err_unreg;
+	}
+	if ((data->acpi_data.control_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO) ||
+	    (data->acpi_data.status_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
+		dprintk("Unsupported address space [%d, %d]\n",
+			(u32) (data->acpi_data.control_register.space_id),
+			(u32) (data->acpi_data.status_register.space_id));
+		result = -ENODEV;
+		goto err_unreg;
+	}
+
+	/* alloc freq_table */
+	data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * (data->acpi_data.state_count + 1), GFP_KERNEL);
+	if (!data->freq_table) {
+		result = -ENOMEM;
+		goto err_unreg;
+	}
+
+	/* detect transition latency */
+	policy->cpuinfo.transition_latency = 0;
+	for (i=0; i<data->acpi_data.state_count; i++) {
+		if ((data->acpi_data.states[i].transition_latency * 1000) > policy->cpuinfo.transition_latency)
+			policy->cpuinfo.transition_latency = data->acpi_data.states[i].transition_latency * 1000;
+	}
+	policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
+
+	/* The current speed is unknown and not detectable by ACPI...  */
+	policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
+
+	/* table init */
+	for (i=0; i<=data->acpi_data.state_count; i++)
+	{
+		data->freq_table[i].index = i;
+		if (i<data->acpi_data.state_count)
+			data->freq_table[i].frequency = data->acpi_data.states[i].core_frequency * 1000;
+		else
+			data->freq_table[i].frequency = CPUFREQ_TABLE_END;
+	}
+
+	result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
+	if (result) {
+		goto err_freqfree;
+	}
+
+	/* notify BIOS that we exist */
+	acpi_processor_notify_smm(THIS_MODULE);
+
+	printk(KERN_INFO "acpi-cpufreq: CPU%u - ACPI performance management activated.\n",
+	       cpu);
+	for (i = 0; i < data->acpi_data.state_count; i++)
+		dprintk("     %cP%d: %d MHz, %d mW, %d uS\n",
+			(i == data->acpi_data.state?'*':' '), i,
+			(u32) data->acpi_data.states[i].core_frequency,
+			(u32) data->acpi_data.states[i].power,
+			(u32) data->acpi_data.states[i].transition_latency);
+
+	cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);
+	return (result);
+
+ err_freqfree:
+	kfree(data->freq_table);
+ err_unreg:
+	acpi_processor_unregister_performance(&data->acpi_data, cpu);
+ err_free:
+	kfree(data);
+	acpi_io_data[cpu] = NULL;
+
+	return (result);
+}
+
+
+static int
+acpi_cpufreq_cpu_exit (
+	struct cpufreq_policy   *policy)
+{
+	struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
+
+
+	dprintk("acpi_cpufreq_cpu_exit\n");
+
+	if (data) {
+		cpufreq_frequency_table_put_attr(policy->cpu);
+		acpi_io_data[policy->cpu] = NULL;
+		acpi_processor_unregister_performance(&data->acpi_data, policy->cpu);
+		kfree(data);
+	}
+
+	return (0);
+}
+
+
+static struct freq_attr* acpi_cpufreq_attr[] = {
+	&cpufreq_freq_attr_scaling_available_freqs,
+	NULL,
+};
+
+static struct cpufreq_driver acpi_cpufreq_driver = {
+	.verify 	= acpi_cpufreq_verify,
+	.target 	= acpi_cpufreq_target,
+	.init		= acpi_cpufreq_cpu_init,
+	.exit		= acpi_cpufreq_cpu_exit,
+	.name		= "acpi-cpufreq",
+	.owner		= THIS_MODULE,
+	.attr           = acpi_cpufreq_attr,
+};
+
+
+static int __init
+acpi_cpufreq_init (void)
+{
+	int                     result = 0;
+
+	dprintk("acpi_cpufreq_init\n");
+
+ 	result = cpufreq_register_driver(&acpi_cpufreq_driver);
+	
+	return (result);
+}
+
+
+static void __exit
+acpi_cpufreq_exit (void)
+{
+	dprintk("acpi_cpufreq_exit\n");
+
+	cpufreq_unregister_driver(&acpi_cpufreq_driver);
+
+	return;
+}
+
+
+late_initcall(acpi_cpufreq_init);
+module_exit(acpi_cpufreq_exit);
+
+MODULE_ALIAS("acpi");
diff -Nru a/arch/i386/kernel/cpu/cpufreq/acpi.c b/arch/i386/kernel/cpu/cpufreq/acpi.c
--- a/arch/i386/kernel/cpu/cpufreq/acpi.c	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,518 +0,0 @@
-/*
- * acpi-cpufreq-io.c - ACPI Processor P-States Driver ($Revision: 1.3 $)
- *
- *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
- *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
- *  Copyright (C) 2002 - 2004 Dominik Brodowski <linux@brodo.de>
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or (at
- *  your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/cpufreq.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <asm/io.h>
-#include <asm/delay.h>
-#include <asm/uaccess.h>
-
-#include <linux/acpi.h>
-#include <acpi/processor.h>
-
-#define ACPI_PROCESSOR_COMPONENT	0x01000000
-#define ACPI_PROCESSOR_CLASS		"processor"
-#define ACPI_PROCESSOR_DRIVER_NAME	"ACPI Processor P-States Driver"
-#define ACPI_PROCESSOR_DEVICE_NAME	"Processor"
-
-#define _COMPONENT		ACPI_PROCESSOR_COMPONENT
-ACPI_MODULE_NAME		("acpi_processor_perf")
-
-MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
-MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME);
-MODULE_LICENSE("GPL");
-
-
-struct cpufreq_acpi_io {
-	struct acpi_processor_performance	acpi_data;
-	struct cpufreq_frequency_table		*freq_table;
-};
-
-static struct cpufreq_acpi_io	*acpi_io_data[NR_CPUS];
-
-
-static int
-acpi_processor_write_port(
-	u16	port,
-	u8	bit_width,
-	u32	value)
-{
-	if (bit_width <= 8) {
-		outb(value, port);
-	} else if (bit_width <= 16) {
-		outw(value, port);
-	} else if (bit_width <= 32) {
-		outl(value, port);
-	} else {
-		return -ENODEV;
-	}
-	return 0;
-}
-
-static int
-acpi_processor_read_port(
-	u16	port,
-	u8	bit_width,
-	u32	*ret)
-{
-	*ret = 0;
-	if (bit_width <= 8) {
-		*ret = inb(port);
-	} else if (bit_width <= 16) {
-		*ret = inw(port);
-	} else if (bit_width <= 32) {
-		*ret = inl(port);
-	} else {
-		return -ENODEV;
-	}
-	return 0;
-}
-
-static int
-acpi_processor_set_performance (
-	struct cpufreq_acpi_io	*data,
-	unsigned int		cpu,
-	int			state)
-{
-	u16			port = 0;
-	u8			bit_width = 0;
-	int			ret = 0;
-	u32			value = 0;
-	int			i = 0;
-	struct cpufreq_freqs    cpufreq_freqs;
-	cpumask_t		saved_mask;
-	int			retval;
-
-	ACPI_FUNCTION_TRACE("acpi_processor_set_performance");
-
-	/*
-	 * TBD: Use something other than set_cpus_allowed.
-	 * As set_cpus_allowed is a bit racy, 
-	 * with any other set_cpus_allowed for this process.
-	 */
-	saved_mask = current->cpus_allowed;
-	set_cpus_allowed(current, cpumask_of_cpu(cpu));
-	if (smp_processor_id() != cpu) {
-		return_VALUE(-EAGAIN);
-	}
-	
-	if (state == data->acpi_data.state) {
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
-			"Already at target state (P%d)\n", state));
-		retval = 0;
-		goto migrate_end;
-	}
-
-	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Transitioning from P%d to P%d\n",
-		data->acpi_data.state, state));
-
-	/* cpufreq frequency struct */
-	cpufreq_freqs.cpu = cpu;
-	cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency;
-	cpufreq_freqs.new = data->freq_table[state].frequency;
-
-	/* notify cpufreq */
-	cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE);
-
-	/*
-	 * First we write the target state's 'control' value to the
-	 * control_register.
-	 */
-
-	port = data->acpi_data.control_register.address;
-	bit_width = data->acpi_data.control_register.bit_width;
-	value = (u32) data->acpi_data.states[state].control;
-
-	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
-		"Writing 0x%08x to port 0x%04x\n", value, port));
-
-	ret = acpi_processor_write_port(port, bit_width, value);
-	if (ret) {
-		ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-			"Invalid port width 0x%04x\n", bit_width));
-		retval = ret;
-		goto migrate_end;
-	}
-
-	/*
-	 * Then we read the 'status_register' and compare the value with the
-	 * target state's 'status' to make sure the transition was successful.
-	 * Note that we'll poll for up to 1ms (100 cycles of 10us) before
-	 * giving up.
-	 */
-
-	port = data->acpi_data.status_register.address;
-	bit_width = data->acpi_data.status_register.bit_width;
-
-	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
-		"Looking for 0x%08x from port 0x%04x\n",
-		(u32) data->acpi_data.states[state].status, port));
-
-	for (i=0; i<100; i++) {
-		ret = acpi_processor_read_port(port, bit_width, &value);
-		if (ret) {	
-			ACPI_DEBUG_PRINT((ACPI_DB_WARN,
-				"Invalid port width 0x%04x\n", bit_width));
-			retval = ret;
-			goto migrate_end;
-		}
-		if (value == (u32) data->acpi_data.states[state].status)
-			break;
-		udelay(10);
-	}
-
-	/* notify cpufreq */
-	cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
-
-	if (value != (u32) data->acpi_data.states[state].status) {
-		unsigned int tmp = cpufreq_freqs.new;
-		cpufreq_freqs.new = cpufreq_freqs.old;
-		cpufreq_freqs.old = tmp;
-		cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE);
-		cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
-		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Transition failed\n"));
-		retval = -ENODEV;
-		goto migrate_end;
-	}
-
-	ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
-		"Transition successful after %d microseconds\n",
-		i * 10));
-
-	data->acpi_data.state = state;
-
-	retval = 0;
-migrate_end:
-	set_cpus_allowed(current, saved_mask);
-	return_VALUE(retval);
-}
-
-
-static int
-acpi_cpufreq_target (
-	struct cpufreq_policy   *policy,
-	unsigned int target_freq,
-	unsigned int relation)
-{
-	struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
-	unsigned int next_state = 0;
-	unsigned int result = 0;
-
-	ACPI_FUNCTION_TRACE("acpi_cpufreq_setpolicy");
-
-	result = cpufreq_frequency_table_target(policy,
-			data->freq_table,
-			target_freq,
-			relation,
-			&next_state);
-	if (result)
-		return_VALUE(result);
-
-	result = acpi_processor_set_performance (data, policy->cpu, next_state);
-
-	return_VALUE(result);
-}
-
-
-static int
-acpi_cpufreq_verify (
-	struct cpufreq_policy   *policy)
-{
-	unsigned int result = 0;
-	struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
-
-	ACPI_FUNCTION_TRACE("acpi_cpufreq_verify");
-
-	result = cpufreq_frequency_table_verify(policy, 
-			data->freq_table);
-
-	return_VALUE(result);
-}
-
-
-static unsigned long
-acpi_cpufreq_guess_freq (
-	struct cpufreq_acpi_io	*data,
-	unsigned int		cpu)
-{
-	if (cpu_khz) {
-		/* search the closest match to cpu_khz */
-		unsigned int i;
-		unsigned long freq;
-		unsigned long freqn = data->acpi_data.states[0].core_frequency * 1000;
-
-		for (i=0; i < (data->acpi_data.state_count - 1); i++) {
-			freq = freqn;
-			freqn = data->acpi_data.states[i+1].core_frequency * 1000;
-			if ((2 * cpu_khz) > (freqn + freq)) {
-				data->acpi_data.state = i;
-				return (freq);
-			}
-		}
-		data->acpi_data.state = data->acpi_data.state_count - 1;
-		return (freqn);
-	} else
-		/* assume CPU is at P0... */
-		data->acpi_data.state = 0;
-		return data->acpi_data.states[0].core_frequency * 1000;
-	
-}
-
-
-/* 
- * acpi_processor_cpu_init_pdc_est - let BIOS know about the SMP capabilities
- * of this driver
- * @perf: processor-specific acpi_io_data struct
- * @cpu: CPU being initialized
- *
- * To avoid issues with legacy OSes, some BIOSes require to be informed of
- * the SMP capabilities of OS P-state driver. Here we set the bits in _PDC 
- * accordingly, for Enhanced Speedstep. Actual call to _PDC is done in
- * driver/acpi/processor.c
- */
-static void 
-acpi_processor_cpu_init_pdc_est(
-		struct acpi_processor_performance *perf, 
-		unsigned int cpu,
-		struct acpi_object_list *obj_list
-		)
-{
-	union acpi_object *obj;
-	u32 *buf;
-	struct cpuinfo_x86 *c = cpu_data + cpu;
-	ACPI_FUNCTION_TRACE("acpi_processor_cpu_init_pdc_est");
-
-	if (!cpu_has(c, X86_FEATURE_EST))
-		return_VOID;
-
-	/* Initialize pdc. It will be used later. */
-	if (!obj_list)
-		return_VOID;
-		
-	if (!(obj_list->count && obj_list->pointer))
-		return_VOID;
-
-	obj = obj_list->pointer;
-	if ((obj->buffer.length == 12) && obj->buffer.pointer) {
-		buf = (u32 *)obj->buffer.pointer;
-       		buf[0] = ACPI_PDC_REVISION_ID;
-       		buf[1] = 1;
-       		buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
-		perf->pdc = obj_list;
-	}
-	return_VOID;
-}
- 
-
-/* CPU specific PDC initialization */
-static void 
-acpi_processor_cpu_init_pdc(
-		struct acpi_processor_performance *perf, 
-		unsigned int cpu,
-		struct acpi_object_list *obj_list
-		)
-{
-	struct cpuinfo_x86 *c = cpu_data + cpu;
-	ACPI_FUNCTION_TRACE("acpi_processor_cpu_init_pdc");
-	perf->pdc = NULL;
-	if (cpu_has(c, X86_FEATURE_EST))
-		acpi_processor_cpu_init_pdc_est(perf, cpu, obj_list);
-	return_VOID;
-}
-
-
-static int
-acpi_cpufreq_cpu_init (
-	struct cpufreq_policy   *policy)
-{
-	unsigned int		i;
-	unsigned int		cpu = policy->cpu;
-	struct cpufreq_acpi_io	*data;
-	unsigned int		result = 0;
-
-	union acpi_object		arg0 = {ACPI_TYPE_BUFFER};
-	u32				arg0_buf[3];
-	struct acpi_object_list 	arg_list = {1, &arg0};
-
-	ACPI_FUNCTION_TRACE("acpi_cpufreq_cpu_init");
-	/* setup arg_list for _PDC settings */
-        arg0.buffer.length = 12;
-        arg0.buffer.pointer = (u8 *) arg0_buf;
-
-	data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
-	if (!data)
-		return_VALUE(-ENOMEM);
-	memset(data, 0, sizeof(struct cpufreq_acpi_io));
-
-	acpi_io_data[cpu] = data;
-
-	acpi_processor_cpu_init_pdc(&data->acpi_data, cpu, &arg_list);
-	result = acpi_processor_register_performance(&data->acpi_data, cpu);
-	data->acpi_data.pdc = NULL;
-
-	if (result)
-		goto err_free;
-
-	/* capability check */
-	if (data->acpi_data.state_count <= 1) {
-		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No P-States\n"));
-		result = -ENODEV;
-		goto err_unreg;
-	}
-	if ((data->acpi_data.control_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO) ||
-	    (data->acpi_data.status_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
-		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported address space [%d, %d]\n",
-				  (u32) (data->acpi_data.control_register.space_id),
-				  (u32) (data->acpi_data.status_register.space_id)));
-		result = -ENODEV;
-		goto err_unreg;
-	}
-
-	/* alloc freq_table */
-	data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * (data->acpi_data.state_count + 1), GFP_KERNEL);
-	if (!data->freq_table) {
-		result = -ENOMEM;
-		goto err_unreg;
-	}
-
-	/* detect transition latency */
-	policy->cpuinfo.transition_latency = 0;
-	for (i=0; i<data->acpi_data.state_count; i++) {
-		if ((data->acpi_data.states[i].transition_latency * 1000) > policy->cpuinfo.transition_latency)
-			policy->cpuinfo.transition_latency = data->acpi_data.states[i].transition_latency * 1000;
-	}
-	policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
-
-	/* The current speed is unknown and not detectable by ACPI...  */
-	policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
-
-	/* table init */
-	for (i=0; i<=data->acpi_data.state_count; i++)
-	{
-		data->freq_table[i].index = i;
-		if (i<data->acpi_data.state_count)
-			data->freq_table[i].frequency = data->acpi_data.states[i].core_frequency * 1000;
-		else
-			data->freq_table[i].frequency = CPUFREQ_TABLE_END;
-	}
-
-	result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
-	if (result) {
-		goto err_freqfree;
-	}
-		
-
-	printk(KERN_INFO "cpufreq: CPU%u - ACPI performance management activated.\n",
-	       cpu);
-	for (i = 0; i < data->acpi_data.state_count; i++)
-		printk(KERN_INFO "cpufreq: %cP%d: %d MHz, %d mW, %d uS\n",
-			(i == data->acpi_data.state?'*':' '), i,
-			(u32) data->acpi_data.states[i].core_frequency,
-			(u32) data->acpi_data.states[i].power,
-			(u32) data->acpi_data.states[i].transition_latency);
-
-	cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);
-	return_VALUE(result);
-
- err_freqfree:
-	kfree(data->freq_table);
- err_unreg:
-	acpi_processor_unregister_performance(&data->acpi_data, cpu);
- err_free:
-	kfree(data);
-	acpi_io_data[cpu] = NULL;
-
-	return_VALUE(result);
-}
-
-
-static int
-acpi_cpufreq_cpu_exit (
-	struct cpufreq_policy   *policy)
-{
-	struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
-
-
-	ACPI_FUNCTION_TRACE("acpi_cpufreq_cpu_exit");
-
-	if (data) {
-		cpufreq_frequency_table_put_attr(policy->cpu);
-		acpi_io_data[policy->cpu] = NULL;
-		acpi_processor_unregister_performance(&data->acpi_data, policy->cpu);
-		kfree(data);
-	}
-
-	return_VALUE(0);
-}
-
-
-static struct freq_attr* acpi_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
-static struct cpufreq_driver acpi_cpufreq_driver = {
-	.verify 	= acpi_cpufreq_verify,
-	.target 	= acpi_cpufreq_target,
-	.init		= acpi_cpufreq_cpu_init,
-	.exit		= acpi_cpufreq_cpu_exit,
-	.name		= "acpi-cpufreq",
-	.owner		= THIS_MODULE,
-	.attr           = acpi_cpufreq_attr,
-};
-
-
-static int __init
-acpi_cpufreq_init (void)
-{
-	int                     result = 0;
-
-	ACPI_FUNCTION_TRACE("acpi_cpufreq_init");
-
- 	result = cpufreq_register_driver(&acpi_cpufreq_driver);
-	
-	return_VALUE(result);
-}
-
-
-static void __exit
-acpi_cpufreq_exit (void)
-{
-	ACPI_FUNCTION_TRACE("acpi_cpufreq_exit");
-
-	cpufreq_unregister_driver(&acpi_cpufreq_driver);
-
-	return_VOID;
-}
-
-
-late_initcall(acpi_cpufreq_init);
-module_exit(acpi_cpufreq_exit);
diff -Nru a/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c b/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,466 @@
+/*
+ * (C) 2004  Sebastian Witt <se.witt@gmx.net>
+ *
+ *  Licensed under the terms of the GNU GPL License version 2.
+ *  Based upon reverse engineered information
+ *
+ *  BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous*
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/cpufreq.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+
+#define NFORCE2_XTAL 25
+#define NFORCE2_BOOTFSB 0x48
+#define NFORCE2_PLLENABLE 0xa8
+#define NFORCE2_PLLREG 0xa4
+#define NFORCE2_PLLADR 0xa0
+#define NFORCE2_PLL(mul, div) (0x100000 | (mul << 8) | div)
+
+#define NFORCE2_MIN_FSB 50
+#define NFORCE2_SAFE_DISTANCE 50
+
+/* Delay in ms between FSB changes */
+//#define NFORCE2_DELAY 10
+
+/* nforce2_chipset:
+ * FSB is changed using the chipset
+ */
+static struct pci_dev *nforce2_chipset_dev;
+
+/* fid:
+ * multiplier * 10
+ */
+static int fid = 0;
+
+/* min_fsb, max_fsb:
+ * minimum and maximum FSB (= FSB at boot time) 
+ */
+static int min_fsb = 0;
+static int max_fsb = 0;
+
+MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");
+MODULE_DESCRIPTION("nForce2 FSB changing cpufreq driver");
+MODULE_LICENSE("GPL");
+
+module_param(fid, int, 0444);
+module_param(min_fsb, int, 0444);
+
+MODULE_PARM_DESC(fid, "CPU multiplier to use (11.5 = 115)");
+MODULE_PARM_DESC(min_fsb,
+                 "Minimum FSB to use, if not defined: current FSB - 50");
+
+/* DEBUG
+ *   Define it if you want verbose debug output, e.g. for bug reporting
+ */
+//#define NFORCE2_DEBUG
+
+#ifdef NFORCE2_DEBUG
+#define dprintk(msg...) printk(msg)
+#else
+#define dprintk(msg...) do { } while(0)
+#endif
+
+/*
+ * nforce2_calc_fsb - calculate FSB
+ * @pll: PLL value
+ * 
+ *   Calculates FSB from PLL value
+ */
+static int nforce2_calc_fsb(int pll)
+{
+	unsigned char mul, div;
+
+	mul = (pll >> 8) & 0xff;
+	div = pll & 0xff;
+
+	if (div > 0)
+		return NFORCE2_XTAL * mul / div;
+
+	return 0;
+}
+
+/*
+ * nforce2_calc_pll - calculate PLL value
+ * @fsb: FSB
+ * 
+ *   Calculate PLL value for given FSB
+ */
+static int nforce2_calc_pll(unsigned int fsb)
+{
+	unsigned char xmul, xdiv;
+	unsigned char mul = 0, div = 0;
+	int tried = 0;
+
+	/* Try to calculate multiplier and divider up to 4 times */
+	while (((mul == 0) || (div == 0)) && (tried <= 3)) {
+		for (xdiv = 1; xdiv <= 0x80; xdiv++)
+			for (xmul = 1; xmul <= 0xfe; xmul++)
+				if (nforce2_calc_fsb(NFORCE2_PLL(xmul, xdiv)) ==
+				    fsb + tried) {
+					mul = xmul;
+					div = xdiv;
+				}
+		tried++;
+	}
+
+	if ((mul == 0) || (div == 0))
+		return -1;
+
+	return NFORCE2_PLL(mul, div);
+}
+
+/*
+ * nforce2_write_pll - write PLL value to chipset
+ * @pll: PLL value
+ * 
+ *   Writes new FSB PLL value to chipset
+ */
+static void nforce2_write_pll(int pll)
+{
+	int temp;
+
+	/* Set the pll addr. to 0x00 */
+	temp = 0x00;
+	pci_write_config_dword(nforce2_chipset_dev, NFORCE2_PLLADR, temp);
+
+	/* Now write the value in all 64 registers */
+	for (temp = 0; temp <= 0x3f; temp++) {
+		pci_write_config_dword(nforce2_chipset_dev, 
+                                       NFORCE2_PLLREG, pll);
+	}
+
+	return;
+}
+
+/*
+ * nforce2_fsb_read - Read FSB
+ *
+ *   Read FSB from chipset
+ *   If bootfsb != 0, return FSB at boot-time
+ */
+static unsigned int nforce2_fsb_read(int bootfsb)
+{
+	struct pci_dev *nforce2_sub5;
+	u32 fsb, temp = 0;
+
+	
+	/* Get chipset boot FSB from subdevice 5 (FSB at boot-time) */
+	nforce2_sub5 = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
+                                      0x01EF,
+                                      PCI_ANY_ID,
+                                      PCI_ANY_ID,
+                                      NULL);
+	
+	if (!nforce2_sub5)
+		return 0;
+
+	pci_read_config_dword(nforce2_sub5, NFORCE2_BOOTFSB, &fsb);
+	fsb /= 1000000;
+	
+	/* Check if PLL register is already set */
+	pci_read_config_byte(nforce2_chipset_dev, 
+                             NFORCE2_PLLENABLE, (u8 *)&temp);
+	
+	if(bootfsb || !temp)
+		return fsb;
+		
+	/* Use PLL register FSB value */
+	pci_read_config_dword(nforce2_chipset_dev, 
+                              NFORCE2_PLLREG, &temp);
+	fsb = nforce2_calc_fsb(temp);
+
+	return fsb;
+}
+
+/*
+ * nforce2_set_fsb - set new FSB
+ * @fsb: New FSB
+ * 
+ *   Sets new FSB
+ */
+static int nforce2_set_fsb(unsigned int fsb)
+{
+	u32 pll, temp = 0;
+	unsigned int tfsb;
+	int diff;
+
+	if ((fsb > max_fsb) || (fsb < NFORCE2_MIN_FSB)) {
+		printk(KERN_ERR "cpufreq: FSB %d is out of range!\n", fsb);
+		return -EINVAL;
+	}
+	
+	tfsb = nforce2_fsb_read(0);
+	if (!tfsb) {
+		printk(KERN_ERR "cpufreq: Error while reading the FSB\n");
+		return -EINVAL;
+	}
+
+	/* First write? Then set actual value */
+	pci_read_config_byte(nforce2_chipset_dev, 
+                             NFORCE2_PLLENABLE, (u8 *)&temp);
+	if (!temp) {
+		pll = nforce2_calc_pll(tfsb);
+
+		if (pll < 0)
+			return -EINVAL;
+
+		nforce2_write_pll(pll);
+	}
+
+	/* Enable write access */
+	temp = 0x01;
+	pci_write_config_byte(nforce2_chipset_dev, NFORCE2_PLLENABLE, (u8)temp);
+
+	diff = tfsb - fsb;
+
+	if (!diff)
+		return 0;
+
+	while ((tfsb != fsb) && (tfsb <= max_fsb) && (tfsb >= min_fsb)) {
+		if (diff < 0)
+			tfsb++;
+		else
+			tfsb--;
+
+		/* Calculate the PLL reg. value */
+		if ((pll = nforce2_calc_pll(tfsb)) == -1)
+			return -EINVAL;
+		
+		nforce2_write_pll(pll);
+#ifdef NFORCE2_DELAY
+		mdelay(NFORCE2_DELAY);
+#endif
+	}
+
+	temp = 0x40;
+	pci_write_config_byte(nforce2_chipset_dev, NFORCE2_PLLADR, (u8)temp);
+
+	return 0;
+}
+
+/**
+ * nforce2_get - get the CPU frequency
+ * @cpu: CPU number
+ * 
+ * Returns the CPU frequency
+ */
+static unsigned int nforce2_get(unsigned int cpu)
+{
+	if (cpu)
+		return 0;
+	return nforce2_fsb_read(0) * fid * 100;
+}
+
+/**
+ * nforce2_target - set a new CPUFreq policy
+ * @policy: new policy
+ * @target_freq: the target frequency
+ * @relation: how that frequency relates to achieved frequency (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
+ *
+ * Sets a new CPUFreq policy.
+ */
+static int nforce2_target(struct cpufreq_policy *policy,
+			  unsigned int target_freq, unsigned int relation)
+{
+//        unsigned long         flags;
+	struct cpufreq_freqs freqs;
+	unsigned int target_fsb;
+
+	if ((target_freq > policy->max) || (target_freq < policy->min))
+		return -EINVAL;
+
+	target_fsb = target_freq / (fid * 100);
+
+	freqs.old = nforce2_get(policy->cpu);
+	freqs.new = target_fsb * fid * 100;
+	freqs.cpu = 0;		/* Only one CPU on nForce2 plattforms */
+
+	if (freqs.old == freqs.new)
+		return 0;
+
+	dprintk(KERN_INFO "cpufreq: Old CPU frequency %d kHz, new %d kHz\n",
+	       freqs.old, freqs.new);
+
+	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+
+	/* Disable IRQs */
+	//local_irq_save(flags);
+
+	if (nforce2_set_fsb(target_fsb) < 0)
+		printk(KERN_ERR "cpufreq: Changing FSB to %d failed\n",
+                       target_fsb);
+	else
+		dprintk(KERN_INFO "cpufreq: Changed FSB successfully to %d\n",
+                       target_fsb);
+
+	/* Enable IRQs */
+	//local_irq_restore(flags);
+
+	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+
+	return 0;
+}
+
+/**
+ * nforce2_verify - verifies a new CPUFreq policy
+ * @policy: new policy
+ */
+static int nforce2_verify(struct cpufreq_policy *policy)
+{
+	unsigned int fsb_pol_max;
+
+	fsb_pol_max = policy->max / (fid * 100);
+
+	if (policy->min < (fsb_pol_max * fid * 100))
+		policy->max = (fsb_pol_max + 1) * fid * 100;
+
+	cpufreq_verify_within_limits(policy,
+                                     policy->cpuinfo.min_freq,
+                                     policy->cpuinfo.max_freq);
+	return 0;
+}
+
+static int nforce2_cpu_init(struct cpufreq_policy *policy)
+{
+	unsigned int fsb;
+	unsigned int rfid;
+
+	/* capability check */
+	if (policy->cpu != 0)
+		return -ENODEV;
+
+	/* Get current FSB */
+	fsb = nforce2_fsb_read(0);
+
+	if (!fsb)
+		return -EIO;
+
+	/* FIX: Get FID from CPU */
+	if (!fid) {
+		if (!cpu_khz) {
+			printk(KERN_WARNING
+			       "cpufreq: cpu_khz not set, can't calculate multiplier!\n");
+			return -ENODEV;
+		}
+
+		fid = cpu_khz / (fsb * 100);
+		rfid = fid % 5;
+
+		if (rfid) {
+			if (rfid > 2)
+				fid += 5 - rfid;
+			else
+				fid -= rfid;
+		}
+	}
+
+	printk(KERN_INFO "cpufreq: FSB currently at %i MHz, FID %d.%d\n", fsb,
+	       fid / 10, fid % 10);
+	
+	/* Set maximum FSB to FSB at boot time */
+	max_fsb = nforce2_fsb_read(1);
+	
+	if(!max_fsb)
+		return -EIO;
+
+	if (!min_fsb)
+		min_fsb = max_fsb - NFORCE2_SAFE_DISTANCE;
+
+	if (min_fsb < NFORCE2_MIN_FSB)
+		min_fsb = NFORCE2_MIN_FSB;
+
+	/* cpuinfo and default policy values */
+	policy->cpuinfo.min_freq = min_fsb * fid * 100;
+	policy->cpuinfo.max_freq = max_fsb * fid * 100;
+	policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
+	policy->cur = nforce2_get(policy->cpu);
+	policy->min = policy->cpuinfo.min_freq;
+	policy->max = policy->cpuinfo.max_freq;
+	policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
+
+	return 0;
+}
+
+static int nforce2_cpu_exit(struct cpufreq_policy *policy)
+{
+	return 0;
+}
+
+static struct cpufreq_driver nforce2_driver = {
+	.name = "nforce2",
+	.verify = nforce2_verify,
+	.target = nforce2_target,
+	.get = nforce2_get,
+	.init = nforce2_cpu_init,
+	.exit = nforce2_cpu_exit,
+	.owner = THIS_MODULE,
+};
+
+/**
+ * nforce2_detect_chipset - detect the Southbridge which contains FSB PLL logic
+ *
+ * Detects nForce2 A2 and C1 stepping
+ * 
+ */
+static unsigned int nforce2_detect_chipset(void)
+{
+	u8 revision;
+
+	nforce2_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
+                                             PCI_DEVICE_ID_NVIDIA_NFORCE2,
+                                             PCI_ANY_ID,
+                                             PCI_ANY_ID,
+                                             NULL);
+
+	if (nforce2_chipset_dev == NULL)
+		return -ENODEV;
+
+	pci_read_config_byte(nforce2_chipset_dev, PCI_REVISION_ID, &revision);
+
+	printk(KERN_INFO "cpufreq: Detected nForce2 chipset revision %X\n",
+	       revision);
+	printk(KERN_INFO
+	       "cpufreq: FSB changing is maybe unstable and can lead to crashes and data loss.\n");
+
+	return 0;
+}
+
+/**
+ * nforce2_init - initializes the nForce2 CPUFreq driver
+ *
+ * Initializes the nForce2 FSB support. Returns -ENODEV on unsupported
+ * devices, -EINVAL on problems during initiatization, and zero on
+ * success.
+ */
+static int __init nforce2_init(void)
+{
+	/* TODO: do we need to detect the processor? */
+
+	/* detect chipset */
+	if (nforce2_detect_chipset()) {
+		printk(KERN_ERR "cpufreq: No nForce2 chipset.\n");
+		return -ENODEV;
+	}
+
+	return cpufreq_register_driver(&nforce2_driver);
+}
+
+/**
+ * nforce2_exit - unregisters cpufreq module
+ *
+ *   Unregisters nForce2 FSB change support.
+ */
+static void __exit nforce2_exit(void)
+{
+	cpufreq_unregister_driver(&nforce2_driver);
+}
+
+module_init(nforce2_init);
+module_exit(nforce2_exit);
+
diff -Nru a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
--- a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c	2004-12-24 13:36:49 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c	2004-12-24 13:36:49 -08:00
@@ -141,17 +141,7 @@
 #define POLICY_MIN_DIV 20
 
 
-/* DEBUG
- *   Define it if you want verbose debug output
- */
-
-#define SUSPMOD_DEBUG 1
-
-#ifdef SUSPMOD_DEBUG
-#define dprintk(msg...) printk(KERN_DEBUG "cpufreq:" msg)
-#else
-#define dprintk(msg...) do { } while(0)
-#endif
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "gx-suspmod", msg)
 
 /**
  *      we can detect a core multipiler from dir0_lsb 
@@ -194,18 +184,18 @@
 	/* check if CPU is a MediaGX or a Geode. */
         if ((current_cpu_data.x86_vendor != X86_VENDOR_NSC) && 
 	    (current_cpu_data.x86_vendor != X86_VENDOR_CYRIX)) {
-		printk(KERN_INFO "gx-suspmod: error: no MediaGX/Geode processor found!\n");
+		dprintk("error: no MediaGX/Geode processor found!\n");
 		return NULL;		
 	}
 
 	/* detect which companion chip is used */
-	while ((gx_pci = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, gx_pci)) != NULL) {
+	while ((gx_pci = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, gx_pci)) != NULL) {
 		if ((pci_match_device (gx_chipset_tbl, gx_pci)) != NULL) {
 			return gx_pci;
 		}
 	}
 
-	dprintk(KERN_INFO "gx-suspmod: error: no supported chipset found!\n");
+	dprintk("error: no supported chipset found!\n");
 	return NULL;
 }
 
@@ -499,6 +489,7 @@
 static void __exit cpufreq_gx_exit(void)
 {
 	cpufreq_unregister_driver(&gx_suspmod_driver);
+	pci_dev_put(gx_params->cs55x0);
 	kfree(gx_params);
 }
 
diff -Nru a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c
--- a/arch/i386/kernel/cpu/cpufreq/longhaul.c	2004-12-24 13:36:17 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c	2004-12-24 13:36:17 -08:00
@@ -58,21 +58,9 @@
 
 /* Module parameters */
 static int dont_scale_voltage;
-static int debug;
 
-static void dprintk(const char *fmt, ...)
-{
-	char s[256];
-	va_list args;
-
-	if (debug == 0)
-		return;
 
-	va_start(args, fmt);
-	vsprintf(s, fmt, args);
-	printk(s);
-	va_end(args);
-}
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "longhaul", msg)
 
 
 #define __hlt()     __asm__ __volatile__("hlt": : :"memory")
@@ -84,6 +72,8 @@
 static unsigned int highest_speed, lowest_speed; /* kHz */
 static int longhaul_version;
 static struct cpufreq_frequency_table *longhaul_table;
+
+#ifdef CONFIG_CPU_FREQ_DEBUG
 static char speedbuffer[8];
 
 static char *print_speed(int speed)
@@ -98,6 +88,7 @@
 
 	return speedbuffer;
 }
+#endif
 
 
 static unsigned int calc_speed(int mult)
@@ -192,7 +183,7 @@
 
 	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
 
-	dprintk (KERN_INFO PFX "Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
+	dprintk ("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
 			fsb, mult/10, mult%10, print_speed(speed/1000));
 
 	switch (longhaul_version) {
@@ -356,7 +347,7 @@
 		}
 	}
 
-	dprintk (KERN_INFO PFX "MinMult:%d.%dx MaxMult:%d.%dx\n",
+	dprintk ("MinMult:%d.%dx MaxMult:%d.%dx\n",
 		 minmult/10, minmult%10, maxmult/10, maxmult%10);
 
 	if (fsb == -1) {
@@ -366,9 +357,9 @@
 
 	highest_speed = calc_speed(maxmult);
 	lowest_speed = calc_speed(minmult);
-	dprintk (KERN_INFO PFX "FSB:%dMHz  ", fsb);
-	dprintk ("Lowest speed:%s  ", print_speed(lowest_speed/1000));
-	dprintk ("Highest speed:%s\n", print_speed(highest_speed/1000));
+	dprintk ("FSB:%dMHz  Lowest speed: %s   Highest speed:%s\n", fsb,
+		 print_speed(lowest_speed/1000), 
+		 print_speed(highest_speed/1000));
 
 	if (lowest_speed == highest_speed) {
 		printk (KERN_INFO PFX "highestspeed == lowest, aborting.\n");
@@ -434,11 +425,11 @@
 	}
 
 	if (vrmrev==0) {
-		dprintk (KERN_INFO PFX "VRM 8.5 : ");
+		dprintk ("VRM 8.5 \n");
 		memcpy (voltage_table, vrm85scales, sizeof(voltage_table));
 		numvscales = (voltage_table[maxvid]-voltage_table[minvid])/25;
 	} else {
-		dprintk (KERN_INFO PFX "Mobile VRM : ");
+		dprintk ("Mobile VRM \n");
 		memcpy (voltage_table, mobilevrmscales, sizeof(voltage_table));
 		numvscales = (voltage_table[maxvid]-voltage_table[minvid])/5;
 	}
@@ -657,9 +648,6 @@
 
 module_param (dont_scale_voltage, int, 0644);
 MODULE_PARM_DESC(dont_scale_voltage, "Don't scale voltage of processor");
-
-module_param (debug, int, 0644);
-MODULE_PARM_DESC(debug, "Dump debugging information.");
 
 MODULE_AUTHOR ("Dave Jones <davej@codemonkey.org.uk>");
 MODULE_DESCRIPTION ("Longhaul driver for VIA Cyrix processors.");
diff -Nru a/arch/i386/kernel/cpu/cpufreq/longrun.c b/arch/i386/kernel/cpu/cpufreq/longrun.c
--- a/arch/i386/kernel/cpu/cpufreq/longrun.c	2004-12-24 13:37:03 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/longrun.c	2004-12-24 13:37:03 -08:00
@@ -16,6 +16,8 @@
 #include <asm/processor.h>
 #include <asm/timex.h>
 
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "longrun", msg)
+
 static struct cpufreq_driver	longrun_driver;
 
 /**
@@ -38,12 +40,14 @@
 	u32 msr_lo, msr_hi;
 
 	rdmsr(MSR_TMTA_LONGRUN_FLAGS, msr_lo, msr_hi);
+	dprintk("longrun flags are %x - %x\n", msr_lo, msr_hi);
 	if (msr_lo & 0x01)
 		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
 	else
 		policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
 	rdmsr(MSR_TMTA_LONGRUN_CTRL, msr_lo, msr_hi);
+	dprintk("longrun ctrl is %x - %x\n", msr_lo, msr_hi);
 	msr_lo &= 0x0000007F;
 	msr_hi &= 0x0000007F;
 
@@ -146,6 +150,7 @@
 		return 0;
 
 	cpuid(0x80860007, &eax, &ebx, &ecx, &edx);
+	dprintk("cpuid eax is %u\n", eax);
 
 	return (eax * 1000);
 }
@@ -191,6 +196,8 @@
 		rdmsr(MSR_TMTA_LRTI_VOLT_MHZ, msr_lo, msr_hi);
 		*high_freq = msr_lo * 1000; /* to kHz */
 
+		dprintk("longrun table interface told %u - %u kHz\n", *low_freq, *high_freq);
+
 		if (*low_freq > *high_freq)
 			*low_freq = *high_freq;
 		return 0;
@@ -199,6 +206,7 @@
 	/* set the upper border to the value determined during TSC init */
 	*high_freq = (cpu_khz / 1000);
 	*high_freq = *high_freq * 1000;
+	dprintk("high frequency is %u kHz\n", *high_freq);
 
 	/* get current borders */
 	rdmsr(MSR_TMTA_LONGRUN_CTRL, msr_lo, msr_hi);
@@ -225,6 +233,7 @@
 		/* restore values */
 		wrmsr(MSR_TMTA_LONGRUN_CTRL, save_lo, save_hi);
 	}
+	dprintk("percentage is %u %%, freq is %u MHz\n", ecx, eax);
 
 	/* performance_pctg = (current_freq - low_freq)/(high_freq - low_freq)
 	 * eqals
@@ -240,6 +249,8 @@
 	edx = (eax - ebx) / (100 - ecx);
 	*low_freq = edx * 1000; /* back to kHz */
 
+	dprintk("low frequency is %u kHz\n", *low_freq);
+
 	if (*low_freq > *high_freq)
 		*low_freq = *high_freq;
 
@@ -308,7 +319,7 @@
 
 
 MODULE_AUTHOR ("Dominik Brodowski <linux@brodo.de>");
-MODULE_DESCRIPTION ("LongRun driver for Transmeta Crusoe processors.");
+MODULE_DESCRIPTION ("LongRun driver for Transmeta Crusoe and Efficeon processors.");
 MODULE_LICENSE ("GPL");
 
 module_init(longrun_init);
diff -Nru a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
--- a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c	2004-12-24 13:37:19 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c	2004-12-24 13:37:19 -08:00
@@ -36,6 +36,7 @@
 #include "speedstep-lib.h"
 
 #define PFX	"p4-clockmod: "
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "p4-clockmod", msg)
 
 /*
  * Duty Cycle (3bits), note DC_DISABLE is not specified in
@@ -62,20 +63,20 @@
 		return -EINVAL;
 
 	rdmsr(MSR_IA32_THERM_STATUS, l, h);
-#if 0
+
 	if (l & 0x01)
-		printk(KERN_DEBUG PFX "CPU#%d currently thermal throttled\n", cpu);
-#endif
+		dprintk("CPU#%d currently thermal throttled\n", cpu);
+
 	if (has_N44_O17_errata[cpu] && (newstate == DC_25PT || newstate == DC_DFLT))
 		newstate = DC_38PT;
 
 	rdmsr(MSR_IA32_THERM_CONTROL, l, h);
 	if (newstate == DC_DISABLE) {
-		/* printk(KERN_INFO PFX "CPU#%d disabling modulation\n", cpu); */
+		dprintk("CPU#%d disabling modulation\n", cpu);
 		wrmsr(MSR_IA32_THERM_CONTROL, l & ~(1<<4), h);
 	} else {
-		/* printk(KERN_INFO PFX "CPU#%d setting duty cycle to %d%%\n",
-			cpu, ((125 * newstate) / 10)); */
+		dprintk("CPU#%d setting duty cycle to %d%%\n",
+			cpu, ((125 * newstate) / 10));
 		/* bits 63 - 5	: reserved 
 		 * bit  4	: enable/disable
 		 * bits 3-1	: duty cycle
@@ -110,7 +111,7 @@
 {
 	unsigned int    newstate = DC_RESV;
 	struct cpufreq_freqs freqs;
-	cpumask_t cpus_allowed, affected_cpu_map;
+	cpumask_t cpus_allowed;
 	int i;
 
 	if (cpufreq_frequency_table_target(policy, &p4clockmod_table[0], target_freq, relation, &newstate))
@@ -122,18 +123,8 @@
 	if (freqs.new == freqs.old)
 		return 0;
 
-	/* switch to physical CPU where state is to be changed*/
-	cpus_allowed = current->cpus_allowed;
-
-	/* only run on CPU to be set, or on its sibling */
-#ifdef CONFIG_SMP
-	affected_cpu_map = cpu_sibling_map[policy->cpu];
-#else
-	affected_cpu_map = cpumask_of_cpu(policy->cpu);
-#endif
-
 	/* notifiers */
-	for_each_cpu_mask(i, affected_cpu_map) {
+	for_each_cpu_mask(i, policy->cpus) {
 		freqs.cpu = i;
 		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
 	}
@@ -141,7 +132,9 @@
 	/* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software
 	 * Developer's Manual, Volume 3 
 	 */
-	for_each_cpu_mask(i, affected_cpu_map) {
+	cpus_allowed = current->cpus_allowed;
+
+	for_each_cpu_mask(i, policy->cpus) {
 		cpumask_t this_cpu = cpumask_of_cpu(i);
 
 		set_cpus_allowed(current, this_cpu);
@@ -152,7 +145,7 @@
 	set_cpus_allowed(current, cpus_allowed);
 
 	/* notifiers */
-	for_each_cpu_mask(i, affected_cpu_map) {
+	for_each_cpu_mask(i, policy->cpus) {
 		freqs.cpu = i;
 		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 	}
@@ -219,6 +212,10 @@
 	int cpuid = 0;
 	unsigned int i;
 
+#ifdef CONFIG_SMP
+	policy->cpus = cpu_sibling_map[policy->cpu];
+#endif
+
 	/* Errata workaround */
 	cpuid = (c->x86 << 8) | (c->x86_model << 4) | c->x86_mask;
 	switch (cpuid) {
@@ -227,6 +224,7 @@
 	case 0x0f11:
 	case 0x0f12:
 		has_N44_O17_errata[policy->cpu] = 1;
+		dprintk("has errata -- disabling low frequencies\n");
 	}
 	
 	/* get max frequency */
@@ -260,14 +258,13 @@
 
 static unsigned int cpufreq_p4_get(unsigned int cpu)
 {
-	cpumask_t cpus_allowed, affected_cpu_map;
+	cpumask_t cpus_allowed;
 	u32 l, h;
 
 	cpus_allowed = current->cpus_allowed;
-        affected_cpu_map = cpumask_of_cpu(cpu);
 
-	set_cpus_allowed(current, affected_cpu_map);
-        BUG_ON(!cpu_isset(smp_processor_id(), affected_cpu_map));
+	set_cpus_allowed(current, cpumask_of_cpu(cpu));
+	BUG_ON(smp_processor_id() != cpu);
 
 	rdmsr(MSR_IA32_THERM_CONTROL, l, h);
 
@@ -305,6 +302,7 @@
 static int __init cpufreq_p4_init(void)
 {	
 	struct cpuinfo_x86 *c = cpu_data;
+	int ret;
 
 	/*
 	 * THERM_CONTROL is architectural for IA32 now, so 
@@ -317,9 +315,11 @@
 		!test_bit(X86_FEATURE_ACC, c->x86_capability))
 		return -ENODEV;
 
-	printk(KERN_INFO PFX "P4/Xeon(TM) CPU On-Demand Clock Modulation available\n");
+	ret = cpufreq_register_driver(&p4clockmod_driver);
+	if (!ret)
+		printk(KERN_INFO PFX "P4/Xeon(TM) CPU On-Demand Clock Modulation available\n");
 
-	return cpufreq_register_driver(&p4clockmod_driver);
+	return (ret);
 }
 
 
@@ -335,4 +335,3 @@
 
 late_initcall(cpufreq_p4_init);
 module_exit(cpufreq_p4_exit);
-
diff -Nru a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c	2004-12-24 13:36:17 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c	2004-12-24 13:36:17 -08:00
@@ -66,6 +66,7 @@
 };
 #endif
 
+#ifdef CONFIG_CPU_FREQ_DEBUG
 /* divide by 1000 to get VID. */
 static int mobile_vid_table[32] = {
     2000, 1950, 1900, 1850, 1800, 1750, 1700, 1650,
@@ -73,6 +74,7 @@
     1275, 1250, 1225, 1200, 1175, 1150, 1125, 1100,
     1075, 1050, 1024, 1000, 975, 950, 925, 0,
 };
+#endif
 
 /* divide by 10 to get FID. */
 static int fid_codes[32] = {
@@ -87,7 +89,6 @@
  */
 
 static int acpi_force;
-static int debug;
 
 static struct cpufreq_frequency_table *powernow_table;
 
@@ -100,20 +101,7 @@
 static unsigned int latency;
 static char have_a0;
 
-static void dprintk(const char *fmt, ...)
-{
-	char s[256];
-	va_list args;
-
-	if (debug==0)
-		return;
-
-	va_start(args,fmt);
-	vsprintf(s, fmt, args);
-	printk(s);
-	va_end(args);
-}
-
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "powernow-k7", msg)
 
 static int check_fsb(unsigned int fsbspeed)
 {
@@ -202,9 +190,6 @@
 #endif
 		}
 
-		dprintk (KERN_INFO PFX "   FID: 0x%x (%d.%dx [%dMHz])  ", fid,
-			fid_codes[fid] / 10, fid_codes[fid] % 10, speed/1000);
-
 		if (speed < minimum_speed)
 			minimum_speed = speed;
 		if (speed > maximum_speed)
@@ -212,8 +197,12 @@
 
 		vid = *pst++;
 		powernow_table[j].index |= (vid << 8); /* upper 8 bits */
-		dprintk ("VID: 0x%x (%d.%03dV)\n", vid,	mobile_vid_table[vid]/1000,
-			mobile_vid_table[vid]%1000);
+
+		dprintk ("   FID: 0x%x (%d.%dx [%dMHz])  "
+			 "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, 
+			 fid_codes[fid] % 10, speed/1000, vid,	
+			 mobile_vid_table[vid]/1000,
+			 mobile_vid_table[vid]%1000);
 	}
 	powernow_table[number_scales].frequency = CPUFREQ_TABLE_END;
 	powernow_table[number_scales].index = 0;
@@ -302,7 +291,7 @@
 
 #ifdef CONFIG_X86_POWERNOW_K7_ACPI
 
-struct acpi_processor_performance *acpi_processor_perf;
+static struct acpi_processor_performance *acpi_processor_perf;
 
 static int powernow_acpi_init(void)
 {
@@ -361,7 +350,7 @@
 		unsigned int speed;
 
 		pc.val = (unsigned long) acpi_processor_perf->states[i].control;
-		dprintk (KERN_INFO PFX "acpi:  P%d: %d MHz %d mW %d uS control %08x SGTC %d\n",
+		dprintk ("acpi:  P%d: %d MHz %d mW %d uS control %08x SGTC %d\n",
 			 i,
 			 (u32) acpi_processor_perf->states[i].core_frequency,
 			 (u32) acpi_processor_perf->states[i].power,
@@ -383,10 +372,11 @@
 				powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
 		}
 
-		dprintk (KERN_INFO PFX "   FID: 0x%x (%d.%dx [%dMHz])  ", fid,
-			fid_codes[fid] / 10, fid_codes[fid] % 10, speed/1000);
-		dprintk ("VID: 0x%x (%d.%03dV)\n", vid,	mobile_vid_table[vid]/1000,
-			mobile_vid_table[vid]%1000);
+		dprintk ("   FID: 0x%x (%d.%dx [%dMHz])  "
+			 "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, 
+			 fid_codes[fid] % 10, speed/1000, vid,	
+			 mobile_vid_table[vid]/1000,
+			 mobile_vid_table[vid]%1000);
 
 		if (latency < pc.bits.sgtc)
 			latency = pc.bits.sgtc;
@@ -400,6 +390,9 @@
 	powernow_table[i].frequency = CPUFREQ_TABLE_END;
 	powernow_table[i].index = 0;
 
+	/* notify BIOS that we exist */
+	acpi_processor_notify_smm(THIS_MODULE);
+
 	return 0;
 
 err2:
@@ -436,21 +429,20 @@
 		p = phys_to_virt(i);
 
 		if (memcmp(p, "AMDK7PNOW!",  10) == 0){
-			dprintk (KERN_INFO PFX "Found PSB header at %p\n", p);
+			dprintk ("Found PSB header at %p\n", p);
 			psb = (struct psb_s *) p;
-			dprintk (KERN_INFO PFX "Table version: 0x%x\n", psb->tableversion);
+			dprintk ("Table version: 0x%x\n", psb->tableversion);
 			if (psb->tableversion != 0x12) {
 				printk (KERN_INFO PFX "Sorry, only v1.2 tables supported right now\n");
 				return -ENODEV;
 			}
 
-			dprintk (KERN_INFO PFX "Flags: 0x%x (", psb->flags);
+			dprintk ("Flags: 0x%x\n", psb->flags);
 			if ((psb->flags & 1)==0) {
-				dprintk ("Mobile");
+				dprintk ("Mobile voltage regulator\n");
 			} else {
-				dprintk ("Desktop");
+				dprintk ("Desktop voltage regulator\n");
 			}
-			dprintk (" voltage regulator)\n");
 
 			latency = psb->settlingtime;
 			if (latency < 100) {
@@ -458,8 +450,8 @@
 						"Should be at least 100. Correcting.\n", latency);
 				latency = 100;
 			}
-			dprintk (KERN_INFO PFX "Settling Time: %d microseconds.\n", psb->settlingtime);
-			dprintk (KERN_INFO PFX "Has %d PST tables. (Only dumping ones relevant to this CPU).\n", psb->numpst);
+			dprintk ("Settling Time: %d microseconds.\n", psb->settlingtime);
+			dprintk ("Has %d PST tables. (Only dumping ones relevant to this CPU).\n", psb->numpst);
 
 			p += sizeof (struct psb_s);
 
@@ -472,11 +464,9 @@
 				if ((etuple == pst->cpuid) && check_fsb(pst->fsbspeed) &&
 				    (maxfid==pst->maxfid) && (startvid==pst->startvid))
 				{
-					dprintk (KERN_INFO PFX "PST:%d (@%p)\n", i, pst);
-					dprintk (KERN_INFO PFX " cpuid: 0x%x  ", pst->cpuid);
-					dprintk ("fsb: %d  ", pst->fsbspeed);
-					dprintk ("maxFID: 0x%x  ", pst->maxfid);
-					dprintk ("startvid: 0x%x\n", pst->startvid);
+					dprintk ("PST:%d (@%p)\n", i, pst);
+					dprintk (" cpuid: 0x%x  fsb: %d  maxFID: 0x%x  startvid: 0x%x\n", 
+						 pst->cpuid, pst->fsbspeed, pst->maxfid, pst->startvid);
 
 					ret = get_ranges ((char *) pst + sizeof (struct pst_s));
 					return ret;
@@ -602,7 +592,7 @@
 		printk(KERN_WARNING PFX "can not determine bus frequency\n");
 		return -EINVAL;
 	}
-	dprintk(KERN_INFO PFX "FSB: %3d.%03d MHz\n", fsb/1000, fsb%1000);
+	dprintk("FSB: %3d.%03d MHz\n", fsb/1000, fsb%1000);
 
 	if (dmi_check_system(powernow_dmi_table) || acpi_force) {
 		printk (KERN_INFO PFX "PSB/PST known to be broken.  Trying ACPI instead\n");
@@ -685,8 +675,6 @@
 		kfree(powernow_table);
 }
 
-module_param(debug, int, 0444);
-MODULE_PARM_DESC(debug, "enable debug output.");
 module_param(acpi_force,  int, 0444);
 MODULE_PARM_DESC(acpi_force, "Force ACPI to be used.");
 
diff -Nru a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c	2004-12-24 13:36:59 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c	2004-12-24 13:36:59 -08:00
@@ -39,7 +39,7 @@
 
 #define PFX "powernow-k8: "
 #define BFX PFX "BIOS error: "
-#define VERSION "version 1.00.09b"
+#define VERSION "version 1.00.09e"
 #include "powernow-k8.h"
 
 /* serialize freq changes  */
@@ -136,7 +136,7 @@
 	fid = lo & MSR_S_LO_CURRENT_FID;
 	lo = fid | (vid << MSR_C_LO_VID_SHIFT);
 	hi = MSR_C_HI_STP_GNT_BENIGN;
-	dprintk(PFX "cpu%d, init lo 0x%x, hi 0x%x\n", smp_processor_id(), lo, hi);
+	dprintk("cpu%d, init lo 0x%x, hi 0x%x\n", smp_processor_id(), lo, hi);
 	wrmsr(MSR_FIDVID_CTL, lo, hi);
 }
 
@@ -154,7 +154,7 @@
 
 	lo = fid | (data->currvid << MSR_C_LO_VID_SHIFT) | MSR_C_LO_INIT_FID_VID;
 
-	dprintk(KERN_DEBUG PFX "writing fid 0x%x, lo 0x%x, hi 0x%x\n",
+	dprintk("writing fid 0x%x, lo 0x%x, hi 0x%x\n",
 		fid, lo, data->plllock * PLL_LOCK_CONVERSION);
 
 	wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION);
@@ -192,7 +192,7 @@
 
 	lo = data->currfid | (vid << MSR_C_LO_VID_SHIFT) | MSR_C_LO_INIT_FID_VID;
 
-	dprintk(KERN_DEBUG PFX "writing vid 0x%x, lo 0x%x, hi 0x%x\n",
+	dprintk("writing vid 0x%x, lo 0x%x, hi 0x%x\n",
 		vid, lo, STOP_GRANT_5NS);
 
 	wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS);
@@ -255,7 +255,7 @@
 		return 1;
 	}
 
-	dprintk(KERN_INFO PFX "transitioned (cpu%d): new fid 0x%x, vid 0x%x\n",
+	dprintk("transitioned (cpu%d): new fid 0x%x, vid 0x%x\n",
 		smp_processor_id(), data->currfid, data->currvid);
 
 	return 0;
@@ -267,13 +267,12 @@
 	u32 rvosteps = data->rvo;
 	u32 savefid = data->currfid;
 
-	dprintk(KERN_DEBUG PFX
-		"ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, reqvid 0x%x, rvo 0x%x\n",
+	dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, reqvid 0x%x, rvo 0x%x\n",
 		smp_processor_id(),
 		data->currfid, data->currvid, reqvid, data->rvo);
 
 	while (data->currvid > reqvid) {
-		dprintk(KERN_DEBUG PFX "ph1: curr 0x%x, req vid 0x%x\n",
+		dprintk("ph1: curr 0x%x, req vid 0x%x\n",
 			data->currvid, reqvid);
 		if (decrease_vid_code_by_step(data, reqvid, data->vidmvs))
 			return 1;
@@ -283,8 +282,7 @@
 		if (data->currvid == 0) {
 			rvosteps = 0;
 		} else {
-			dprintk(KERN_DEBUG PFX
-				"ph1: changing vid for rvo, req 0x%x\n",
+			dprintk("ph1: changing vid for rvo, req 0x%x\n",
 				data->currvid - 1);
 			if (decrease_vid_code_by_step(data, data->currvid - 1, 1))
 				return 1;
@@ -300,7 +298,7 @@
 		return 1;
 	}
 
-	dprintk(KERN_DEBUG PFX "ph1 complete, currfid 0x%x, currvid 0x%x\n",
+	dprintk("ph1 complete, currfid 0x%x, currvid 0x%x\n",
 		data->currfid, data->currvid);
 
 	return 0;
@@ -325,8 +323,7 @@
 		return 0;
 	}
 
-	dprintk(KERN_DEBUG PFX
-		"ph2 (cpu%d): starting, currfid 0x%x, currvid 0x%x, reqfid 0x%x\n",
+	dprintk("ph2 (cpu%d): starting, currfid 0x%x, currvid 0x%x, reqfid 0x%x\n",
 		smp_processor_id(),
 		data->currfid, data->currvid, reqfid);
 
@@ -376,7 +373,7 @@
 		return 1;
 	}
 
-	dprintk(KERN_DEBUG PFX "ph2 complete, currfid 0x%x, currvid 0x%x\n",
+	dprintk("ph2 complete, currfid 0x%x, currvid 0x%x\n",
 		data->currfid, data->currvid);
 
 	return 0;
@@ -388,7 +385,7 @@
 	u32 savefid = data->currfid;
 	u32 savereqvid = reqvid;
 
-	dprintk(KERN_DEBUG PFX "ph3 (cpu%d): starting, currfid 0x%x, currvid 0x%x\n",
+	dprintk("ph3 (cpu%d): starting, currfid 0x%x, currvid 0x%x\n",
 		smp_processor_id(),
 		data->currfid, data->currvid);
 
@@ -415,17 +412,17 @@
 		return 1;
 
 	if (savereqvid != data->currvid) {
-		dprintk(KERN_ERR PFX "ph3 failed, currvid 0x%x\n", data->currvid);
+		dprintk("ph3 failed, currvid 0x%x\n", data->currvid);
 		return 1;
 	}
 
 	if (savefid != data->currfid) {
-		dprintk(KERN_ERR PFX "ph3 failed, currfid changed 0x%x\n",
+		dprintk("ph3 failed, currfid changed 0x%x\n",
 			data->currfid);
 		return 1;
 	}
 
-	dprintk(KERN_DEBUG PFX "ph3 complete, currfid 0x%x, currvid 0x%x\n",
+	dprintk("ph3 complete, currfid 0x%x, currvid 0x%x\n",
 		data->currfid, data->currvid);
 
 	return 0;
@@ -577,7 +574,7 @@
 		return -EIO;
 	}
 
-	dprintk(KERN_INFO PFX "cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid);
+	dprintk("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid);
 	data->powernow_table = powernow_table;
 	print_basics(data);
 
@@ -585,7 +582,7 @@
 		if ((pst[j].fid==data->currfid) && (pst[j].vid==data->currvid))
 			return 0;
 
-	dprintk(KERN_ERR PFX "currfid/vid do not match PST, ignoring\n");
+	dprintk("currfid/vid do not match PST, ignoring\n");
 	return 0;
 }
 
@@ -596,6 +593,8 @@
 	unsigned int i;
 	u32 mvs;
 	u8 maxvid;
+	u32 cpst = 0;
+	u32 thiscpuid;
 
 	for (i = 0xc0000; i < 0xffff0; i += 0x10) {
 		/* Scan BIOS looking for the signature. */
@@ -605,48 +604,55 @@
 		if (memcmp(psb, PSB_ID_STRING, PSB_ID_STRING_LEN) != 0)
 			continue;
 
-		dprintk(KERN_DEBUG PFX "found PSB header at 0x%p\n", psb);
+		dprintk("found PSB header at 0x%p\n", psb);
 
-		dprintk(KERN_DEBUG PFX "table vers: 0x%x\n", psb->tableversion);
+		dprintk("table vers: 0x%x\n", psb->tableversion);
 		if (psb->tableversion != PSB_VERSION_1_4) {
 			printk(KERN_INFO BFX "PSB table is not v1.4\n");
 			return -ENODEV;
 		}
 
-		dprintk(KERN_DEBUG PFX "flags: 0x%x\n", psb->flags1);
+		dprintk("flags: 0x%x\n", psb->flags1);
 		if (psb->flags1) {
 			printk(KERN_ERR BFX "unknown flags\n");
 			return -ENODEV;
 		}
 
 		data->vstable = psb->voltagestabilizationtime;
-		dprintk(KERN_INFO PFX "voltage stabilization time: %d(*20us)\n", data->vstable);
+		dprintk("voltage stabilization time: %d(*20us)\n", data->vstable);
 
-		dprintk(KERN_DEBUG PFX "flags2: 0x%x\n", psb->flags2);
+		dprintk("flags2: 0x%x\n", psb->flags2);
 		data->rvo = psb->flags2 & 3;
 		data->irt = ((psb->flags2) >> 2) & 3;
 		mvs = ((psb->flags2) >> 4) & 3;
 		data->vidmvs = 1 << mvs;
 		data->batps = ((psb->flags2) >> 6) & 3;
 
-		dprintk(KERN_INFO PFX "ramp voltage offset: %d\n", data->rvo);
-		dprintk(KERN_INFO PFX "isochronous relief time: %d\n", data->irt);
-		dprintk(KERN_INFO PFX "maximum voltage step: %d - 0x%x\n", mvs, data->vidmvs);
-
-		dprintk(KERN_DEBUG PFX "numpst: 0x%x\n", psb->numpst);
-		if (psb->numpst != 1) {
+		dprintk("ramp voltage offset: %d\n", data->rvo);
+		dprintk("isochronous relief time: %d\n", data->irt);
+		dprintk("maximum voltage step: %d - 0x%x\n", mvs, data->vidmvs);
+
+		dprintk("numpst: 0x%x\n", psb->numpst);
+		cpst = psb->numpst;
+		if ((psb->cpuid == 0x00000fc0) || (psb->cpuid == 0x00000fe0) ){
+			thiscpuid = cpuid_eax(CPUID_PROCESSOR_SIGNATURE);
+			if ((thiscpuid == 0x00000fc0) || (thiscpuid == 0x00000fe0) ) {
+				cpst = 1;
+			}
+		}
+		if (cpst != 1) {
 			printk(KERN_ERR BFX "numpst must be 1\n");
 			return -ENODEV;
 		}
 
 		data->plllock = psb->plllocktime;
-		dprintk(KERN_INFO PFX "plllocktime: 0x%x (units 1us)\n", psb->plllocktime);
-		dprintk(KERN_INFO PFX "maxfid: 0x%x\n", psb->maxfid);
-		dprintk(KERN_INFO PFX "maxvid: 0x%x\n", psb->maxvid);
+		dprintk("plllocktime: 0x%x (units 1us)\n", psb->plllocktime);
+		dprintk("maxfid: 0x%x\n", psb->maxfid);
+		dprintk("maxvid: 0x%x\n", psb->maxvid);
 		maxvid = psb->maxvid;
 
 		data->numps = psb->numpstates;
-		dprintk(KERN_INFO PFX "numpstates: 0x%x\n", data->numps);
+		dprintk("numpstates: 0x%x\n", data->numps);
 		return fill_powernow_table(data, (struct pst_s *)(psb+1), maxvid);
 	}
 	/*
@@ -684,19 +690,21 @@
 	struct cpufreq_frequency_table *powernow_table;
 
 	if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) {
-		dprintk(KERN_DEBUG PFX "register performance failed\n");
+		dprintk("register performance failed\n");
 		return -EIO;
 	}
 
 	/* verify the data contained in the ACPI structures */
 	if (data->acpi_data.state_count <= 1) {
-		dprintk(KERN_DEBUG PFX "No ACPI P-States\n");
+		dprintk("No ACPI P-States\n");
 		goto err_out;
 	}
 
 	if ((data->acpi_data.control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) ||
 		(data->acpi_data.status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) {
-		dprintk(KERN_DEBUG PFX "Invalid control/status registers\n");
+		dprintk("Invalid control/status registers (%x - %x)\n",
+			data->acpi_data.control_register.space_id,
+			data->acpi_data.status_register.space_id);
 		goto err_out;
 	}
 
@@ -704,7 +712,7 @@
 	powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table)
 		* (data->acpi_data.state_count + 1)), GFP_KERNEL);
 	if (!powernow_table) {
-		dprintk(KERN_ERR PFX "powernow_table memory alloc failure\n");
+		dprintk("powernow_table memory alloc failure\n");
 		goto err_out;
 	}
 
@@ -712,7 +720,7 @@
 		u32 fid = data->acpi_data.states[i].control & FID_MASK;
 		u32 vid = (data->acpi_data.states[i].control >> VID_SHIFT) & VID_MASK;
 
-		dprintk(KERN_INFO PFX "   %d : fid 0x%x, vid 0x%x\n", i, fid, vid);
+		dprintk("   %d : fid 0x%x, vid 0x%x\n", i, fid, vid);
 
 		powernow_table[i].index = fid; /* lower 8 bits */
 		powernow_table[i].index |= (vid << 8); /* upper 8 bits */
@@ -721,14 +729,14 @@
 		/* verify frequency is OK */
 		if ((powernow_table[i].frequency > (MAX_FREQ * 1000)) ||
 			(powernow_table[i].frequency < (MIN_FREQ * 1000))) {
-			dprintk(KERN_INFO PFX "invalid freq %u kHz, ignoring\n", powernow_table[i].frequency);
+			dprintk("invalid freq %u kHz, ignoring\n", powernow_table[i].frequency);
 			powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
 			continue;
 		}
 
 		/* verify voltage is OK - BIOSs are using "off" to indicate invalid */
 		if (vid == 0x1f) {
-			dprintk(KERN_INFO PFX "invalid vid %u, ignoring\n", vid);
+			dprintk("invalid vid %u, ignoring\n", vid);
 			powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
 			continue;
 		}
@@ -744,7 +752,7 @@
  					goto err_out_mem;
  				}
 				
- 				dprintk(KERN_INFO PFX "double low frequency table entry, ignoring it.\n");
+ 				dprintk("double low frequency table entry, ignoring it.\n");
  				powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
  				continue;
  			} else
@@ -768,6 +776,10 @@
 	data->numps = data->acpi_data.state_count;
 	print_basics(data);
 	powernow_k8_acpi_pst_values(data, 0);
+
+	/* notify BIOS that we exist */
+	acpi_processor_notify_smm(THIS_MODULE);
+
 	return 0;
 
 err_out_mem:
@@ -802,8 +814,7 @@
 	int res;
 	struct cpufreq_freqs freqs;
 
-	dprintk(KERN_DEBUG PFX "cpu %d transition to index %u\n",
-		smp_processor_id(), index );
+	dprintk("cpu %d transition to index %u\n", smp_processor_id(), index);
 
 	/* fid are the lower 8 bits of the index we stored into
 	 * the cpufreq frequency table in find_psb_table, vid are 
@@ -813,28 +824,25 @@
 	fid = data->powernow_table[index].index & 0xFF;
 	vid = (data->powernow_table[index].index & 0xFF00) >> 8;
 
-	dprintk(KERN_DEBUG PFX "table matched fid 0x%x, giving vid 0x%x\n",
-		fid, vid);
+	dprintk("table matched fid 0x%x, giving vid 0x%x\n", fid, vid);
 
 	if (query_current_values_with_pending_wait(data))
 		return 1;
 
 	if ((data->currvid == vid) && (data->currfid == fid)) {
-		dprintk(KERN_DEBUG PFX
-			"target matches current values (fid 0x%x, vid 0x%x)\n",
+		dprintk("target matches current values (fid 0x%x, vid 0x%x)\n",
 			fid, vid);
 		return 0;
 	}
 
 	if ((fid < HI_FID_TABLE_BOTTOM) && (data->currfid < HI_FID_TABLE_BOTTOM)) {
-		printk(KERN_ERR PFX
-		       "ignoring illegal change in lo freq table-%x to 0x%x\n",
+		printk("ignoring illegal change in lo freq table-%x to 0x%x\n",
 		       data->currfid, fid);
 		return 1;
 	}
 
-	dprintk(KERN_DEBUG PFX "cpu %d, changing to fid 0x%x, vid 0x%x\n",
-				smp_processor_id(), fid, vid);
+	dprintk("cpu %d, changing to fid 0x%x, vid 0x%x\n",
+		smp_processor_id(), fid, vid);
 
 	freqs.cpu = data->cpu;
 
@@ -877,7 +885,7 @@
 		goto err_out;
 	}
 
-	dprintk(KERN_DEBUG PFX "targ: cpu %d, %d kHz, min %d, max %d, relation %d\n",
+	dprintk("targ: cpu %d, %d kHz, min %d, max %d, relation %d\n",
 		pol->cpu, targfreq, pol->min, pol->max, relation);
 
 	if (query_current_values_with_pending_wait(data)) {
@@ -885,7 +893,7 @@
 		goto err_out;
 	}
 
-	dprintk(KERN_DEBUG PFX "targ: curr fid 0x%x, vid 0x%x\n",
+	dprintk("targ: curr fid 0x%x, vid 0x%x\n",
 		data->currfid, data->currvid);
 
 	if ((checkvid != data->currvid) || (checkfid != data->currfid)) {
@@ -997,7 +1005,7 @@
 	    + (3 * (1 << data->irt) * 10)) * 1000;
 
 	pol->cur = find_khz_freq_from_fid(data->currfid);
-	dprintk(KERN_DEBUG PFX "policy current frequency %d kHz\n", pol->cur);
+	dprintk("policy current frequency %d kHz\n", pol->cur);
 
 	/* min/max the cpu is capable of */
 	if (cpufreq_frequency_table_cpuinfo(pol, data->powernow_table)) {
@@ -1009,7 +1017,7 @@
 
 	cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu);
 
-	printk(KERN_INFO PFX "cpu_init done, current fid 0x%x, vid 0x%x\n",
+	printk("cpu_init done, current fid 0x%x, vid 0x%x\n",
 	       data->currfid, data->currvid);
 
 	powernow_data[pol->cpu] = data;
@@ -1107,7 +1115,7 @@
 /* driver entry point for term */
 static void __exit powernowk8_exit(void)
 {
-	dprintk(KERN_INFO PFX "exit\n");
+	dprintk("exit\n");
 
 	cpufreq_unregister_driver(&cpufreq_amd64_driver);
 }
diff -Nru a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h	2004-12-24 13:36:59 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h	2004-12-24 13:36:59 -08:00
@@ -168,11 +168,7 @@
 	u8 vid;
 };
 
-#ifdef DEBUG
-#define dprintk(msg...) printk(msg)
-#else
-#define dprintk(msg...) do { } while(0)
-#endif
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "powernow-k8", msg)
 
 static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid);
 static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvid);
diff -Nru a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c	2004-12-24 13:36:47 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c	2004-12-24 13:36:47 -08:00
@@ -35,13 +35,8 @@
 #define PFX		"speedstep-centrino: "
 #define MAINTAINER	"Jeremy Fitzhardinge <jeremy@goop.org>"
 
-/*#define CENTRINO_DEBUG*/
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg)
 
-#ifdef CENTRINO_DEBUG
-#define dprintk(msg...) printk(msg)
-#else
-#define dprintk(msg...) do { } while(0)
-#endif
 
 struct cpu_id
 {
@@ -77,7 +72,7 @@
 
 /* Operating points for current CPU */
 static struct cpu_model *centrino_model;
-static int centrino_cpu;
+static const struct cpu_id *centrino_cpu;
 
 #ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE
 
@@ -254,13 +249,15 @@
 		/* Matched a non-match */
 		printk(KERN_INFO PFX "no table support for CPU model \"%s\": \n",
 		       cpu->x86_model_id);
+#ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI
 		printk(KERN_INFO PFX "try compiling with CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI enabled\n");
+#endif
 		return -ENOENT;
 	}
 
 	centrino_model = model;
 
-	printk(KERN_INFO PFX "found \"%s\": max frequency: %dkHz\n",
+	dprintk("found \"%s\": max frequency: %dkHz\n",
 	       model->model_name, model->max_freq);
 
 	return 0;
@@ -289,7 +286,9 @@
 	 * for centrino, as some DSDTs are buggy.
 	 * Ideally, this can be done using the acpi_data structure.
 	 */
-	if (centrino_cpu) {
+	if ((centrino_cpu == &cpu_ids[CPU_BANIAS]) ||
+	    (centrino_cpu == &cpu_ids[CPU_DOTHAN_A1]) ||
+	    (centrino_cpu == &cpu_ids[CPU_DOTHAN_B0])) {
 		msr = (msr >> 8) & 0xff;
 		return msr * 100000;
 	}
@@ -342,47 +341,52 @@
 	int				result = 0, i;
 
 	/* _PDC settings */
-        arg0.buffer.length = 12;
-        arg0.buffer.pointer = (u8 *) arg0_buf;
-        arg0_buf[0] = ACPI_PDC_REVISION_ID;
-        arg0_buf[1] = 1;
-        arg0_buf[2] = ACPI_PDC_EST_CAPABILITY_SMP | ACPI_PDC_EST_CAPABILITY_MSR;
+	arg0.buffer.length = 12;
+	arg0.buffer.pointer = (u8 *) arg0_buf;
+	arg0_buf[0] = ACPI_PDC_REVISION_ID;
+	arg0_buf[1] = 1;
+	arg0_buf[2] = ACPI_PDC_EST_CAPABILITY_SMP | ACPI_PDC_EST_CAPABILITY_MSR;
 
 	p.pdc = &arg_list;
 
 	/* register with ACPI core */
-        if (acpi_processor_register_performance(&p, policy->cpu))
-                return -EIO;
+	if (acpi_processor_register_performance(&p, policy->cpu)) {
+		printk(KERN_INFO PFX "obtaining ACPI data failed\n");
+		return -EIO;
+	}
 
 	/* verify the acpi_data */
 	if (p.state_count <= 1) {
-                printk(KERN_DEBUG "No P-States\n");
-                result = -ENODEV;
-                goto err_unreg;
+		dprintk("No P-States\n");
+		result = -ENODEV;
+		goto err_unreg;
 	}
 
 	if ((p.control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) ||
 	    (p.status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) {
-		printk(KERN_DEBUG "Invalid control/status registers\n");
+		dprintk("Invalid control/status registers (%x - %x)\n",
+			p.control_register.space_id, p.status_register.space_id);
 		result = -EIO;
 		goto err_unreg;
 	}
 
 	for (i=0; i<p.state_count; i++) {
 		if (p.states[i].control != p.states[i].status) {
-			printk(KERN_DEBUG "Different control and status values\n");
+			dprintk("Different control (%x) and status values (%x)\n",
+				p.states[i].control, p.states[i].status);
 			result = -EINVAL;
 			goto err_unreg;
 		}
 
 		if (!p.states[i].core_frequency) {
-			printk(KERN_DEBUG "Zero core frequency\n");
+			dprintk("Zero core frequency for state %u\n", i);
 			result = -EINVAL;
 			goto err_unreg;
 		}
 
 		if (p.states[i].core_frequency > p.states[0].core_frequency) {
-			printk(KERN_DEBUG "P%u has larger frequency than P0, skipping\n", i);
+			dprintk("P%u has larger frequency (%u) than P0 (%u), skipping\n", i,
+				p.states[i].core_frequency, p.states[0].core_frequency);
 			p.states[i].core_frequency = 0;
 			continue;
 		}
@@ -407,25 +411,36 @@
         for (i=0; i<p.state_count; i++) {
 		centrino_model->op_points[i].index = p.states[i].control;
 		centrino_model->op_points[i].frequency = p.states[i].core_frequency * 1000;
+		dprintk("adding state %i with frequency %u and control value %04x\n", 
+			i, centrino_model->op_points[i].frequency, centrino_model->op_points[i].index);
 	}
 	centrino_model->op_points[p.state_count].frequency = CPUFREQ_TABLE_END;
 
 	cur_freq = get_cur_freq(policy->cpu);
 
 	for (i=0; i<p.state_count; i++) {
+		if (!p.states[i].core_frequency) {
+			dprintk("skipping state %u\n", i);
+			centrino_model->op_points[i].frequency = CPUFREQ_ENTRY_INVALID;
+			continue;
+		}
+		
 		if (extract_clock(centrino_model->op_points[i].index) !=
 		    (centrino_model->op_points[i].frequency)) {
-			printk(KERN_DEBUG "Invalid encoded frequency\n");
+			dprintk("Invalid encoded frequency (%u vs. %u)\n",
+				extract_clock(centrino_model->op_points[i].index),
+				centrino_model->op_points[i].frequency);
 			result = -EINVAL;
 			goto err_kfree_all;
 		}
 
 		if (cur_freq == centrino_model->op_points[i].frequency)
 			p.state = i;
-		if (!p.states[i].core_frequency)
-			centrino_model->op_points[i].frequency = CPUFREQ_ENTRY_INVALID;
 	}
 
+	/* notify BIOS that we exist */
+	acpi_processor_notify_smm(THIS_MODULE);
+
 	return 0;
 
  err_kfree_all:
@@ -434,6 +449,7 @@
 	kfree(centrino_model);
  err_unreg:
 	acpi_processor_unregister_performance(&p, policy->cpu);
+	printk(KERN_INFO PFX "invalid ACPI data\n");
 	return (result);
 }
 #else
@@ -457,7 +473,7 @@
 			break;
 
 	if (i != N_IDS)
-		centrino_cpu = 1;
+		centrino_cpu = &cpu_ids[i];
 
 	if (centrino_cpu_init_acpi(policy)) {
 		if (policy->cpu != 0)
@@ -481,6 +497,7 @@
 
 	if (!(l & (1<<16))) {
 		l |= (1<<16);
+		dprintk("trying to enable Enhanced SpeedStep (%x)\n", l);
 		wrmsr(MSR_IA32_MISC_ENABLE, l, h);
 
 		/* check to see if it stuck */
@@ -497,8 +514,7 @@
 	policy->cpuinfo.transition_latency = 10000; /* 10uS transition latency */
 	policy->cur = freq;
 
-	dprintk(KERN_INFO PFX "centrino_cpu_init: policy=%d cur=%dkHz\n",
-		policy->policy, policy->cur);
+	dprintk("centrino_cpu_init: cur=%dkHz\n", policy->cur);
 
 	ret = cpufreq_frequency_table_cpuinfo(policy, centrino_model->op_points);
 	if (ret)
@@ -518,6 +534,7 @@
 
 #ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI
 	if (!centrino_model->model_name) {
+		dprintk("unregistering and freeing ACPI data\n");
 		acpi_processor_unregister_performance(&p, policy->cpu);
 		kfree(centrino_model->op_points);
 		kfree(centrino_model);
@@ -567,8 +584,9 @@
 	 * Make sure we are running on the CPU that wants to change frequency
 	 */
 	saved_mask = current->cpus_allowed;
-	set_cpus_allowed(current, cpumask_of_cpu(policy->cpu));
+	set_cpus_allowed(current, policy->cpus);
 	if (smp_processor_id() != policy->cpu) {
+		dprintk("couldn't limit to CPUs in this domain\n");
 		return(-EAGAIN);
 	}
 
@@ -583,26 +601,15 @@
 
 	if (msr == (oldmsr & 0xffff)) {
 		retval = 0;
+		dprintk("no change needed - msr was and needs to be %x\n", oldmsr);
 		goto migrate_end;
 	}
 
-	/* Hm, old frequency can either be the last value we put in
-	   PERF_CTL, or whatever it is now. The trouble is that TM2
-	   can change it behind our back, which means we never get to
-	   see the speed change.  Reading back the current speed would
-	   tell us something happened, but it may leave the things on
-	   the notifier chain confused; we therefore stick to using
-	   the last programmed speed rather than the current speed for
-	   "old".
-
-	   TODO: work out how the TCC interrupts work, and try to
-	   catch the CPU changing things under us.
-	*/
 	freqs.cpu = policy->cpu;
 	freqs.old = extract_clock(oldmsr);
 	freqs.new = extract_clock(msr);
 
-	dprintk(KERN_INFO PFX "target=%dkHz old=%d new=%d msr=%04x\n",
+	dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
 		target_freq, freqs.old, freqs.new, msr);
 
 	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
diff -Nru a/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c b/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c	2004-12-24 13:36:16 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c	2004-12-24 13:36:16 -08:00
@@ -52,16 +52,7 @@
 };
 
 
-/* DEBUG
- *   Define it if you want verbose debug output, e.g. for bug reporting
- */
-//#define SPEEDSTEP_DEBUG
-
-#ifdef SPEEDSTEP_DEBUG
-#define dprintk(msg...) printk(msg)
-#else
-#define dprintk(msg...) do { } while(0)
-#endif
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-ich", msg)
 
 
 /**
@@ -83,13 +74,13 @@
 	/* get PMBASE */
 	pci_read_config_dword(speedstep_chipset_dev, 0x40, &pmbase);
 	if (!(pmbase & 0x01)) {
-		printk(KERN_ERR "cpufreq: could not find speedstep register\n");
+		printk(KERN_ERR "speedstep-ich: could not find speedstep register\n");
 		return;
 	}
 
 	pmbase &= 0xFFFFFFFE;
 	if (!pmbase) {
-		printk(KERN_ERR "cpufreq: could not find speedstep register\n");
+		printk(KERN_ERR "speedstep-ich: could not find speedstep register\n");
 		return;
 	}
 
@@ -99,13 +90,13 @@
 	/* read state */
 	value = inb(pmbase + 0x50);
 
-	dprintk(KERN_DEBUG "cpufreq: read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value);
+	dprintk("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value);
 
 	/* write new state */
 	value &= 0xFE;
 	value |= state;
 
-	dprintk(KERN_DEBUG "cpufreq: writing 0x%x to pmbase 0x%x + 0x50\n", value, pmbase);
+	dprintk("writing 0x%x to pmbase 0x%x + 0x50\n", value, pmbase);
 
 	/* Disable bus master arbitration */
 	pm2_blk = inb(pmbase + 0x20);
@@ -125,10 +116,10 @@
 	/* Enable IRQs */
 	local_irq_restore(flags);
 
-	dprintk(KERN_DEBUG "cpufreq: read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value);
+	dprintk("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value);
 
 	if (state == (value & 0x1)) {
-		dprintk (KERN_INFO "cpufreq: change to %u MHz succeeded\n", (speedstep_get_processor_frequency(speedstep_processor) / 1000));
+		dprintk("change to %u MHz succeeded\n", (speedstep_get_processor_frequency(speedstep_processor) / 1000));
 	} else {
 		printk (KERN_ERR "cpufreq: change failed - I/O error\n");
 	}
@@ -153,7 +144,7 @@
 	pci_read_config_word(speedstep_chipset_dev, 0x00A0, &value);
 	if (!(value & 0x08)) {
 		value |= 0x08;
-		dprintk(KERN_DEBUG "cpufreq: activating SpeedStep (TM) registers\n");
+		dprintk("activating SpeedStep (TM) registers\n");
 		pci_write_config_word(speedstep_chipset_dev, 0x00A0, value);
 	}
 
@@ -171,7 +162,7 @@
  */
 static unsigned int speedstep_detect_chipset (void)
 {
-	speedstep_chipset_dev = pci_find_subsys(PCI_VENDOR_ID_INTEL,
+	speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
 			      PCI_DEVICE_ID_INTEL_82801DB_12,
 			      PCI_ANY_ID,
 			      PCI_ANY_ID,
@@ -179,7 +170,7 @@
 	if (speedstep_chipset_dev)
 		return 4; /* 4-M */
 
-	speedstep_chipset_dev = pci_find_subsys(PCI_VENDOR_ID_INTEL,
+	speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
 			      PCI_DEVICE_ID_INTEL_82801CA_12,
 			      PCI_ANY_ID,
 			      PCI_ANY_ID,
@@ -188,7 +179,7 @@
 		return 3; /* 3-M */
 
 
-	speedstep_chipset_dev = pci_find_subsys(PCI_VENDOR_ID_INTEL,
+	speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
 			      PCI_DEVICE_ID_INTEL_82801BA_10,
 			      PCI_ANY_ID,
 			      PCI_ANY_ID,
@@ -201,7 +192,7 @@
 		static struct pci_dev *hostbridge;
 		u8 rev = 0;
 
-		hostbridge  = pci_find_subsys(PCI_VENDOR_ID_INTEL,
+		hostbridge  = pci_get_subsys(PCI_VENDOR_ID_INTEL,
 			      PCI_DEVICE_ID_INTEL_82815_MC,
 			      PCI_ANY_ID,
 			      PCI_ANY_ID,
@@ -212,35 +203,37 @@
 
 		pci_read_config_byte(hostbridge, PCI_REVISION_ID, &rev);
 		if (rev < 5) {
-			dprintk(KERN_INFO "cpufreq: hostbridge does not support speedstep\n");
+			dprintk("hostbridge does not support speedstep\n");
 			speedstep_chipset_dev = NULL;
+			pci_dev_put(hostbridge);
 			return 0;
 		}
 
+		pci_dev_put(hostbridge);
 		return 2; /* 2-M */
 	}
 
 	return 0;
 }
 
-static unsigned int speedstep_get(unsigned int cpu)
+static unsigned int _speedstep_get(cpumask_t cpus)
 {
 	unsigned int speed;
-	cpumask_t cpus_allowed,affected_cpu_map;
+	cpumask_t cpus_allowed;
 
-	/* only run on CPU to be set, or on its sibling */
 	cpus_allowed = current->cpus_allowed;
-#ifdef CONFIG_SMP
-	affected_cpu_map = cpu_sibling_map[cpu];
-#else
-	affected_cpu_map = cpumask_of_cpu(cpu);
-#endif
-	set_cpus_allowed(current, affected_cpu_map);
-	speed=speedstep_get_processor_frequency(speedstep_processor);
+	set_cpus_allowed(current, cpus);
+	speed = speedstep_get_processor_frequency(speedstep_processor);
 	set_cpus_allowed(current, cpus_allowed);
+	dprintk("detected %u kHz as current frequency\n", speed);
 	return speed;
 }
 
+static unsigned int speedstep_get(unsigned int cpu)
+{
+	return _speedstep_get(cpumask_of_cpu(cpu));
+}
+
 /**
  * speedstep_target - set a new CPUFreq policy
  * @policy: new policy
@@ -255,43 +248,38 @@
 {
 	unsigned int newstate = 0;
 	struct cpufreq_freqs freqs;
-	cpumask_t cpus_allowed, affected_cpu_map;
+	cpumask_t cpus_allowed;
 	int i;
 
 	if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate))
 		return -EINVAL;
 
-	freqs.old = speedstep_get(policy->cpu);
+	freqs.old = _speedstep_get(policy->cpus);
 	freqs.new = speedstep_freqs[newstate].frequency;
 	freqs.cpu = policy->cpu;
 
+	dprintk("transiting from %u to %u kHz\n", freqs.old, freqs.new);
+
 	/* no transition necessary */
 	if (freqs.old == freqs.new)
 		return 0;
 
 	cpus_allowed = current->cpus_allowed;
 
-	/* only run on CPU to be set, or on its sibling */
-#ifdef CONFIG_SMP
-	affected_cpu_map = cpu_sibling_map[policy->cpu];
-#else
-	affected_cpu_map = cpumask_of_cpu(policy->cpu);
-#endif
-
-	for_each_cpu_mask(i, affected_cpu_map) {
+	for_each_cpu_mask(i, policy->cpus) {
 		freqs.cpu = i;
 		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
 	}
 
 	/* switch to physical CPU where state is to be changed */
-	set_cpus_allowed(current, affected_cpu_map);
+	set_cpus_allowed(current, policy->cpus);
 
 	speedstep_set_state(newstate);
 
 	/* allow to be run on all CPUs */
 	set_cpus_allowed(current, cpus_allowed);
 
-	for_each_cpu_mask(i, affected_cpu_map) {
+	for_each_cpu_mask(i, policy->cpus) {
 		freqs.cpu = i;
 		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 	}
@@ -317,21 +305,15 @@
 {
 	int result = 0;
 	unsigned int speed;
-	cpumask_t cpus_allowed,affected_cpu_map;
-
-
-	/* capability check */
-	if (policy->cpu != 0) /* FIXME: better support for SMT in cpufreq core. Up until then, it's better to register only one CPU */
-		return -ENODEV;
+	cpumask_t cpus_allowed;
 
 	/* only run on CPU to be set, or on its sibling */
-	cpus_allowed = current->cpus_allowed;
 #ifdef CONFIG_SMP
-	affected_cpu_map = cpu_sibling_map[policy->cpu];
-#else
-	affected_cpu_map = cpumask_of_cpu(policy->cpu);
+	policy->cpus = cpu_sibling_map[policy->cpu];
 #endif
-	set_cpus_allowed(current, affected_cpu_map);
+
+	cpus_allowed = current->cpus_allowed;
+	set_cpus_allowed(current, policy->cpus);
 
 	/* detect low and high frequency */
 	result = speedstep_get_freqs(speedstep_processor,
@@ -343,11 +325,11 @@
 		return result;
 
 	/* get current speed setting */
-	speed = speedstep_get(policy->cpu);
+	speed = _speedstep_get(policy->cpus);
 	if (!speed)
 		return -EIO;
 
-	dprintk(KERN_INFO "cpufreq: currently at %s speed setting - %i MHz\n",
+	dprintk("currently at %s speed setting - %i MHz\n",
 		(speed == speedstep_freqs[SPEEDSTEP_LOW].frequency) ? "low" : "high",
 		(speed / 1000));
 
@@ -401,18 +383,22 @@
 {
 	/* detect processor */
 	speedstep_processor = speedstep_detect_processor();
-	if (!speedstep_processor)
+	if (!speedstep_processor) {
+		dprintk("Intel(R) SpeedStep(TM) capable processor not found\n");
 		return -ENODEV;
+	}
 
 	/* detect chipset */
 	if (!speedstep_detect_chipset()) {
-		printk(KERN_INFO "cpufreq: Intel(R) SpeedStep(TM) for this chipset not (yet) available.\n");
+		dprintk("Intel(R) SpeedStep(TM) for this chipset not (yet) available.\n");
 		return -ENODEV;
 	}
 
 	/* activate speedstep support */
-	if (speedstep_activate())
+	if (speedstep_activate()) {
+		pci_dev_put(speedstep_chipset_dev);
 		return -EINVAL;
+	}
 
 	return cpufreq_register_driver(&speedstep_driver);
 }
@@ -425,6 +411,7 @@
  */
 static void __exit speedstep_exit(void)
 {
+	pci_dev_put(speedstep_chipset_dev);
 	cpufreq_unregister_driver(&speedstep_driver);
 }
 
diff -Nru a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c	2004-12-24 13:37:19 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c	2004-12-24 13:37:19 -08:00
@@ -19,17 +19,7 @@
 #include <asm/msr.h>
 #include "speedstep-lib.h"
 
-
-/* DEBUG
- *   Define it if you want verbose debug output, e.g. for bug reporting
- */
-//#define SPEEDSTEP_DEBUG
-
-#ifdef SPEEDSTEP_DEBUG
-#define dprintk(msg...) printk(msg)
-#else
-#define dprintk(msg...) do { } while(0)
-#endif
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-lib", msg)
 
 #ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK
 static int relaxed_check = 0;
@@ -83,7 +73,7 @@
 
 	/* read MSR 0x2a - we only need the low 32 bits */
 	rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp);
-	dprintk(KERN_DEBUG "speedstep-lib: P3 - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
+	dprintk("P3 - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
 	msr_tmp = msr_lo;
 
 	/* decode the FSB */
@@ -96,9 +86,10 @@
 	}
 
 	/* decode the multiplier */
-	if (processor == SPEEDSTEP_PROCESSOR_PIII_C_EARLY)
+	if (processor == SPEEDSTEP_PROCESSOR_PIII_C_EARLY) {
+		dprintk("workaround for early PIIIs\n");
 		msr_lo &= 0x03c00000;
-	else
+	} else
 		msr_lo &= 0x0bc00000;
 	msr_lo >>= 22;
 	while (msr_lo != msr_decode_mult[j].bitmap) {
@@ -107,6 +98,8 @@
 		j++;
 	}
 
+	dprintk("speed is %u\n", (msr_decode_mult[j].ratio * msr_decode_fsb[i].value * 100));
+
 	return (msr_decode_mult[j].ratio * msr_decode_fsb[i].value * 100);
 }
 
@@ -116,7 +109,7 @@
 	u32     msr_lo, msr_tmp;
 
 	rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp);
-	dprintk(KERN_DEBUG "speedstep-lib: PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
+	dprintk("PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
 
 	/* see table B-2 of 24547212.pdf */
 	if (msr_lo & 0x00040000) {
@@ -125,7 +118,7 @@
 	}
 
 	msr_tmp = (msr_lo >> 22) & 0x1f;
-	dprintk(KERN_DEBUG "speedstep-lib: bits 22-26 are 0x%x\n", msr_tmp);
+	dprintk("bits 22-26 are 0x%x, speed is %u\n", msr_tmp, (msr_tmp * 100 * 1000));
 
 	return (msr_tmp * 100 * 1000);
 }
@@ -139,7 +132,7 @@
 
 	rdmsr(0x2c, msr_lo, msr_hi);
 
-	dprintk(KERN_DEBUG "speedstep-lib: P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi);
+	dprintk("P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi);
 
 	/* decode the FSB: see IA-32 Intel (C) Architecture Software 
 	 * Developer's Manual, Volume 3: System Prgramming Guide,
@@ -169,7 +162,7 @@
 	/* Multiplier. */
 	mult = msr_lo >> 24;
 
-	dprintk(KERN_DEBUG "speedstep-lib: P4 - FSB %u kHz; Multiplier %u\n", fsb, mult);
+	dprintk("P4 - FSB %u kHz; Multiplier %u; Speed %u kHz\n", fsb, mult, (fsb * mult));
 
 	return (fsb * mult);
 }
@@ -204,6 +197,8 @@
 	struct cpuinfo_x86 *c = cpu_data;
 	u32			ebx, msr_lo, msr_hi;
 
+	dprintk("x86: %x, model: %x\n", c->x86, c->x86_model);
+
 	if ((c->x86_vendor != X86_VENDOR_INTEL) || 
 	    ((c->x86 != 6) && (c->x86 != 0xF)))
 		return 0;
@@ -217,7 +212,7 @@
 		ebx = cpuid_ebx(0x00000001);
 		ebx &= 0x000000FF;
 
-		dprintk(KERN_INFO "ebx value is %x, x86_mask is %x\n", ebx, c->x86_mask);
+		dprintk("ebx value is %x, x86_mask is %x\n", ebx, c->x86_mask);
 
 		switch (c->x86_mask) {
 		case 4: 
@@ -269,6 +264,7 @@
 		/* cpuid_ebx(1) is 0x04 for desktop PIII, 
 		                   0x06 for mobile PIII-M */
 		ebx = cpuid_ebx(0x00000001);
+		dprintk("ebx is %x\n", ebx);
 
 		ebx &= 0x000000FF;
 
@@ -286,7 +282,7 @@
 		/* all mobile PIII Coppermines have FSB 100 MHz
 		 * ==> sort out a few desktop PIIIs. */
 		rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_hi);
-		dprintk(KERN_DEBUG "cpufreq: Coppermine: MSR_IA32_EBL_CR_POWERON is 0x%x, 0x%x\n", msr_lo, msr_hi);
+		dprintk("Coppermine: MSR_IA32_EBL_CR_POWERON is 0x%x, 0x%x\n", msr_lo, msr_hi);
 		msr_lo &= 0x00c0000;
 		if (msr_lo != 0x0080000)
 			return 0;
@@ -298,11 +294,12 @@
 		 * bit 56 or 57 is set
 		 */
 		rdmsr(MSR_IA32_PLATFORM_ID, msr_lo, msr_hi);
-		dprintk(KERN_DEBUG "cpufreq: Coppermine: MSR_IA32_PLATFORM ID is 0x%x, 0x%x\n", msr_lo, msr_hi);
+		dprintk("Coppermine: MSR_IA32_PLATFORM ID is 0x%x, 0x%x\n", msr_lo, msr_hi);
 		if ((msr_hi & (1<<18)) && (relaxed_check ? 1 : (msr_hi & (3<<24)))) {
-			if (c->x86_mask == 0x01)
+			if (c->x86_mask == 0x01) {
+				dprintk("early PIII version\n");
 				return SPEEDSTEP_PROCESSOR_PIII_C_EARLY;
-			else
+			} else
 				return SPEEDSTEP_PROCESSOR_PIII_C;
 		}
 
@@ -329,10 +326,14 @@
 	if ((!processor) || (!low_speed) || (!high_speed) || (!set_state))
 		return -EINVAL;
 
+	dprintk("trying to determine both speeds\n");
+
 	/* get current speed */
 	prev_speed = speedstep_get_processor_frequency(processor);
 	if (!prev_speed)
 		return -EIO;
+
+	dprintk("previous seped is %u\n", prev_speed);
 	
 	local_irq_save(flags);
 
@@ -344,6 +345,8 @@
 		goto out;
 	}
 
+	dprintk("low seped is %u\n", *low_speed);
+
 	/* switch to high state */
 	set_state(SPEEDSTEP_HIGH);
 	*high_speed = speedstep_get_processor_frequency(processor);
@@ -351,6 +354,8 @@
 		ret = -EIO;
 		goto out;
 	}
+
+	dprintk("high seped is %u\n", *high_speed);
 
 	if (*low_speed == *high_speed) {
 		ret = -ENODEV;
diff -Nru a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c	2004-12-24 13:36:48 -08:00
@@ -24,8 +24,6 @@
 
 #include "speedstep-lib.h"
 
-#define PFX "speedstep-smi: "
-
 /* speedstep system management interface port/command.
  *
  * These parameters are got from IST-SMI BIOS call.
@@ -58,16 +56,7 @@
  * of DMA activity going on? */
 #define SMI_TRIES 5
 
-/* DEBUG
- *   Define it if you want verbose debug output, e.g. for bug reporting
- */
-//#define SPEEDSTEP_DEBUG
-
-#ifdef SPEEDSTEP_DEBUG
-#define dprintk(msg...) printk(msg)
-#else
-#define dprintk(msg...) do { } while(0)
-#endif
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-smi", msg)
 
 /**
  * speedstep_smi_ownership
@@ -81,12 +70,16 @@
 	command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
 	magic = virt_to_phys(magic_data);
 
+	dprintk("trying to obtain ownership with command %x at port %x\n", command, smi_port);
+
 	__asm__ __volatile__(
 		"out %%al, (%%dx)\n"
 		: "=D" (result)
 		: "a" (command), "b" (function), "c" (0), "d" (smi_port), "D" (0), "S" (magic)
 	);
 
+	dprintk("result is %x\n", result);
+
 	return result;
 }
 
@@ -101,21 +94,27 @@
  */
 static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high)
 {
-	u32 command, result, edi, high_mhz, low_mhz;
+	u32 command, result = 0, edi, high_mhz, low_mhz;
 	u32 state=0;
 	u32 function = GET_SPEEDSTEP_FREQS;
 
-	if (!(ist_info.event & 0xFFFF))
+	if (!(ist_info.event & 0xFFFF)) {
+		dprintk("bug #1422 -- can't read freqs from BIOS\n", result);
 		return -ENODEV;
+	}
 
 	command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
 
+	dprintk("trying to determine frequencies with command %x at port %x\n", command, smi_port);
+
 	__asm__ __volatile__("movl $0, %%edi\n"
 		"out %%al, (%%dx)\n"
 		: "=a" (result), "=b" (high_mhz), "=c" (low_mhz), "=d" (state), "=D" (edi)
 		: "a" (command), "b" (function), "c" (state), "d" (smi_port), "S" (0)
 	);
 
+	dprintk("result %x, low_freq %u, high_freq %u\n", result, low_mhz, high_mhz);
+
 	/* abort if results are obviously incorrect... */
 	if ((high_mhz + low_mhz) < 600)
 		return -EINVAL;
@@ -138,15 +137,20 @@
 
 	command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
 
+	dprintk("trying to determine current setting with command %x at port %x\n", command, smi_port);
+
 	__asm__ __volatile__("movl $0, %%edi\n"
 		"out %%al, (%%dx)\n"
 		: "=a" (result), "=b" (state), "=D" (edi)
 		: "a" (command), "b" (function), "c" (0), "d" (smi_port), "S" (0)
 	);
 
+	dprintk("state is %x, result is %x\n", state, result);
+
 	return (state & 1);
 }
 
+
 /**
  * speedstep_set_state - set the SpeedStep state
  * @state: new processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH)
@@ -167,9 +171,11 @@
 
 	command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
 
+	dprintk("trying to set frequency to state %u with command %x at port %x\n", state, command, smi_port);
+
 	do {
 		if (retry) {
-			dprintk(KERN_INFO "cpufreq: retry %u, previous result %u\n", retry, result);
+			dprintk("retry %u, previous result %u, waiting...\n", retry, result);
 			mdelay(retry * 50);
 		}
 		retry++;
@@ -185,7 +191,7 @@
 	local_irq_restore(flags);
 
 	if (new_state == state) {
-		dprintk(KERN_INFO "cpufreq: change to %u MHz succeeded after %u tries with result %u\n", (speedstep_freqs[new_state].frequency / 1000), retry, result);
+		dprintk("change to %u MHz succeeded after %u tries with result %u\n", (speedstep_freqs[new_state].frequency / 1000), retry, result);
 	} else {
 		printk(KERN_ERR "cpufreq: change failed with new_state %u and result %u\n", new_state, result);
 	}
@@ -250,7 +256,7 @@
 
 	result = speedstep_smi_ownership();
 	if (result) {
-		dprintk(KERN_INFO "cpufreq: fails an aquiring ownership of a SMI interface.\n");
+		dprintk("fails in aquiring ownership of a SMI interface.\n");
 		return -EINVAL;
 	}
 
@@ -259,30 +265,24 @@
 				&speedstep_freqs[SPEEDSTEP_HIGH].frequency);
 	if (result) {
 		/* fall back to speedstep_lib.c dection mechanism: try both states out */
-		dprintk(KERN_INFO PFX "could not detect low and high frequencies by SMI call.\n");
-		if (!speedstep_processor)
-			speedstep_processor = speedstep_detect_processor();
-
-		if (!speedstep_processor)
-			return -ENODEV;
-
+		dprintk("could not detect low and high frequencies by SMI call.\n");
 		result = speedstep_get_freqs(speedstep_processor,
 				&speedstep_freqs[SPEEDSTEP_LOW].frequency,
 				&speedstep_freqs[SPEEDSTEP_HIGH].frequency,
 				&speedstep_set_state);
 
 		if (result) {
-			dprintk(KERN_INFO PFX "could not detect two different speeds -- aborting.\n");
+			dprintk("could not detect two different speeds -- aborting.\n");
 			return result;
 		} else
-			dprintk(KERN_INFO PFX "workaround worked.\n");
+			dprintk("workaround worked.\n");
 	}
 
 	/* get current speed setting */
 	state = speedstep_get_state();
 	speed = speedstep_freqs[state].frequency;
 
-	dprintk(KERN_INFO "cpufreq: currently at %s speed setting - %i MHz\n", 
+	dprintk("currently at %s speed setting - %i MHz\n", 
 		(speed == speedstep_freqs[SPEEDSTEP_LOW].frequency) ? "low" : "high",
 		(speed / 1000));
 
@@ -310,10 +310,6 @@
 {
 	if (cpu)
 		return -ENODEV;
-	if (!speedstep_processor)
-		speedstep_processor = speedstep_detect_processor();
-	if (!speedstep_processor)
-		return 0;
 	return speedstep_get_processor_frequency(speedstep_processor);
 }
 
@@ -323,7 +319,7 @@
 	int result = speedstep_smi_ownership();
 
 	if (result)
-		dprintk(KERN_INFO "cpufreq: fails an aquiring ownership of a SMI interface.\n");
+		dprintk("fails in re-aquiring ownership of a SMI interface.\n");
 
 	return result;
 }
@@ -354,14 +350,23 @@
  */
 static int __init speedstep_init(void)
 {
-    struct cpuinfo_x86 *c = cpu_data;
+	speedstep_processor = speedstep_detect_processor();
+
+	switch (speedstep_processor) {
+	case SPEEDSTEP_PROCESSOR_PIII_T:
+	case SPEEDSTEP_PROCESSOR_PIII_C:
+	case SPEEDSTEP_PROCESSOR_PIII_C_EARLY:
+		break;
+	default:
+		speedstep_processor = 0;
+	}
 
-    if (c->x86_vendor != X86_VENDOR_INTEL) {
-		printk (KERN_INFO PFX "No Intel CPU detected.\n");
+	if (!speedstep_processor) {
+		dprintk ("No supported Intel CPU detected.\n");
 		return -ENODEV;
 	}
 
-	dprintk(KERN_DEBUG PFX "signature:0x%.8lx, command:0x%.8lx, event:0x%.8lx, perf_level:0x%.8lx.\n", 
+	dprintk("signature:0x%.8lx, command:0x%.8lx, event:0x%.8lx, perf_level:0x%.8lx.\n", 
 		ist_info.signature, ist_info.command, ist_info.event, ist_info.perf_level);
 
 
diff -Nru a/arch/i386/kernel/cpu/cyrix.c b/arch/i386/kernel/cpu/cyrix.c
--- a/arch/i386/kernel/cpu/cyrix.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/kernel/cpu/cyrix.c	2004-12-24 13:36:31 -08:00
@@ -187,6 +187,14 @@
 }
 
 
+#ifdef CONFIG_PCI
+static struct pci_device_id cyrix_55x0[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5510) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5520) },
+	{ },
+};
+#endif
+
 static void __init init_cyrix(struct cpuinfo_x86 *c)
 {
 	unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0;
@@ -274,8 +282,7 @@
 		/*
 		 *  The 5510/5520 companion chips have a funky PIT.
 		 */  
-		if (pci_find_device(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5510, NULL) ||
-		    pci_find_device(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5520, NULL))
+		if (pci_dev_present(cyrix_55x0))
 			pit_latch_buggy = 1;
 
 		/* GXm supports extended cpuid levels 'ala' AMD */
diff -Nru a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
--- a/arch/i386/kernel/cpu/intel.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/kernel/cpu/intel.c	2004-12-24 13:36:31 -08:00
@@ -56,62 +56,6 @@
 	return 0;
 }
 	
-#define LVL_1_INST	1
-#define LVL_1_DATA	2
-#define LVL_2		3
-#define LVL_3		4
-#define LVL_TRACE	5
-
-struct _cache_table
-{
-	unsigned char descriptor;
-	char cache_type;
-	short size;
-};
-
-/* all the cache descriptor types we care about (no TLB or trace cache entries) */
-static struct _cache_table cache_table[] __initdata =
-{
-	{ 0x06, LVL_1_INST, 8 },	/* 4-way set assoc, 32 byte line size */
-	{ 0x08, LVL_1_INST, 16 },	/* 4-way set assoc, 32 byte line size */
-	{ 0x0a, LVL_1_DATA, 8 },	/* 2 way set assoc, 32 byte line size */
-	{ 0x0c, LVL_1_DATA, 16 },	/* 4-way set assoc, 32 byte line size */
-	{ 0x22, LVL_3,      512 },	/* 4-way set assoc, sectored cache, 64 byte line size */
-	{ 0x23, LVL_3,      1024 },	/* 8-way set assoc, sectored cache, 64 byte line size */
-	{ 0x25, LVL_3,      2048 },	/* 8-way set assoc, sectored cache, 64 byte line size */
-	{ 0x29, LVL_3,      4096 },	/* 8-way set assoc, sectored cache, 64 byte line size */
-	{ 0x2c, LVL_1_DATA, 32 },	/* 8-way set assoc, 64 byte line size */
-	{ 0x30, LVL_1_INST, 32 },	/* 8-way set assoc, 64 byte line size */
-	{ 0x39, LVL_2,      128 },	/* 4-way set assoc, sectored cache, 64 byte line size */
-	{ 0x3b, LVL_2,      128 },	/* 2-way set assoc, sectored cache, 64 byte line size */
-	{ 0x3c, LVL_2,      256 },	/* 4-way set assoc, sectored cache, 64 byte line size */
-	{ 0x41, LVL_2,      128 },	/* 4-way set assoc, 32 byte line size */
-	{ 0x42, LVL_2,      256 },	/* 4-way set assoc, 32 byte line size */
-	{ 0x43, LVL_2,      512 },	/* 4-way set assoc, 32 byte line size */
-	{ 0x44, LVL_2,      1024 },	/* 4-way set assoc, 32 byte line size */
-	{ 0x45, LVL_2,      2048 },	/* 4-way set assoc, 32 byte line size */
-	{ 0x60, LVL_1_DATA, 16 },	/* 8-way set assoc, sectored cache, 64 byte line size */
-	{ 0x66, LVL_1_DATA, 8 },	/* 4-way set assoc, sectored cache, 64 byte line size */
-	{ 0x67, LVL_1_DATA, 16 },	/* 4-way set assoc, sectored cache, 64 byte line size */
-	{ 0x68, LVL_1_DATA, 32 },	/* 4-way set assoc, sectored cache, 64 byte line size */
-	{ 0x70, LVL_TRACE,  12 },	/* 8-way set assoc */
-	{ 0x71, LVL_TRACE,  16 },	/* 8-way set assoc */
-	{ 0x72, LVL_TRACE,  32 },	/* 8-way set assoc */
-	{ 0x78, LVL_2,    1024 },	/* 4-way set assoc, 64 byte line size */
-	{ 0x79, LVL_2,     128 },	/* 8-way set assoc, sectored cache, 64 byte line size */
-	{ 0x7a, LVL_2,     256 },	/* 8-way set assoc, sectored cache, 64 byte line size */
-	{ 0x7b, LVL_2,     512 },	/* 8-way set assoc, sectored cache, 64 byte line size */
-	{ 0x7c, LVL_2,    1024 },	/* 8-way set assoc, sectored cache, 64 byte line size */
-	{ 0x7d, LVL_2,    2048 },	/* 8-way set assoc, 64 byte line size */
-	{ 0x7f, LVL_2,     512 },	/* 2-way set assoc, 64 byte line size */
-	{ 0x82, LVL_2,     256 },	/* 8-way set assoc, 32 byte line size */
-	{ 0x83, LVL_2,     512 },	/* 8-way set assoc, 32 byte line size */
-	{ 0x84, LVL_2,    1024 },	/* 8-way set assoc, 32 byte line size */
-	{ 0x85, LVL_2,    2048 },	/* 8-way set assoc, 32 byte line size */
-	{ 0x86, LVL_2,     512 },	/* 4-way set assoc, 64 byte line size */
-	{ 0x87, LVL_2,    1024 },	/* 8-way set assoc, 64 byte line size */
-	{ 0x00, 0, 0}
-};
 
 /*
  * P4 Xeon errata 037 workaround.
@@ -135,8 +79,8 @@
 
 static void __init init_intel(struct cpuinfo_x86 *c)
 {
+	unsigned int l2 = 0;
 	char *p = NULL;
-	unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */
 
 #ifdef CONFIG_X86_F00F_BUG
 	/*
@@ -158,79 +102,7 @@
 #endif
 
 	select_idle_routine(c);
-	if (c->cpuid_level > 1) {
-		/* supports eax=2  call */
-		int i, j, n;
-		int regs[4];
-		unsigned char *dp = (unsigned char *)regs;
-
-		/* Number of times to iterate */
-		n = cpuid_eax(2) & 0xFF;
-
-		for ( i = 0 ; i < n ; i++ ) {
-			cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]);
-			
-			/* If bit 31 is set, this is an unknown format */
-			for ( j = 0 ; j < 3 ; j++ ) {
-				if ( regs[j] < 0 ) regs[j] = 0;
-			}
-
-			/* Byte 0 is level count, not a descriptor */
-			for ( j = 1 ; j < 16 ; j++ ) {
-				unsigned char des = dp[j];
-				unsigned char k = 0;
-
-				/* look up this descriptor in the table */
-				while (cache_table[k].descriptor != 0)
-				{
-					if (cache_table[k].descriptor == des) {
-						switch (cache_table[k].cache_type) {
-						case LVL_1_INST:
-							l1i += cache_table[k].size;
-							break;
-						case LVL_1_DATA:
-							l1d += cache_table[k].size;
-							break;
-						case LVL_2:
-							l2 += cache_table[k].size;
-							break;
-						case LVL_3:
-							l3 += cache_table[k].size;
-							break;
-						case LVL_TRACE:
-							trace += cache_table[k].size;
-							break;
-						}
-
-						break;
-					}
-
-					k++;
-				}
-			}
-		}
-
-		if ( trace )
-			printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
-		else if ( l1i )
-			printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
-		if ( l1d )
-			printk(", L1 D cache: %dK\n", l1d);
-		else
-			printk("\n");
-		if ( l2 )
-			printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
-		if ( l3 )
-			printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
-
-		/*
-		 * This assumes the L3 cache is shared; it typically lives in
-		 * the northbridge.  The L1 caches are included by the L2
-		 * cache, and so should not be included for the purpose of
-		 * SMP switching weights.
-		 */
-		c->x86_cache_size = l2 ? l2 : (l1i+l1d);
-	}
+	l2 = init_intel_cacheinfo(c);
 
 	/* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until model 3 mask 3 */
 	if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633)
diff -Nru a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/i386/kernel/cpu/intel_cacheinfo.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,140 @@
+#include <linux/init.h>
+#include <asm/processor.h>
+
+#define LVL_1_INST	1
+#define LVL_1_DATA	2
+#define LVL_2		3
+#define LVL_3		4
+#define LVL_TRACE	5
+
+struct _cache_table
+{
+	unsigned char descriptor;
+	char cache_type;
+	short size;
+};
+
+/* all the cache descriptor types we care about (no TLB or trace cache entries) */
+static struct _cache_table cache_table[] __initdata =
+{
+	{ 0x06, LVL_1_INST, 8 },	/* 4-way set assoc, 32 byte line size */
+	{ 0x08, LVL_1_INST, 16 },	/* 4-way set assoc, 32 byte line size */
+	{ 0x0a, LVL_1_DATA, 8 },	/* 2 way set assoc, 32 byte line size */
+	{ 0x0c, LVL_1_DATA, 16 },	/* 4-way set assoc, 32 byte line size */
+	{ 0x22, LVL_3,      512 },	/* 4-way set assoc, sectored cache, 64 byte line size */
+	{ 0x23, LVL_3,      1024 },	/* 8-way set assoc, sectored cache, 64 byte line size */
+	{ 0x25, LVL_3,      2048 },	/* 8-way set assoc, sectored cache, 64 byte line size */
+	{ 0x29, LVL_3,      4096 },	/* 8-way set assoc, sectored cache, 64 byte line size */
+	{ 0x2c, LVL_1_DATA, 32 },	/* 8-way set assoc, 64 byte line size */
+	{ 0x30, LVL_1_INST, 32 },	/* 8-way set assoc, 64 byte line size */
+	{ 0x39, LVL_2,      128 },	/* 4-way set assoc, sectored cache, 64 byte line size */
+	{ 0x3b, LVL_2,      128 },	/* 2-way set assoc, sectored cache, 64 byte line size */
+	{ 0x3c, LVL_2,      256 },	/* 4-way set assoc, sectored cache, 64 byte line size */
+	{ 0x41, LVL_2,      128 },	/* 4-way set assoc, 32 byte line size */
+	{ 0x42, LVL_2,      256 },	/* 4-way set assoc, 32 byte line size */
+	{ 0x43, LVL_2,      512 },	/* 4-way set assoc, 32 byte line size */
+	{ 0x44, LVL_2,      1024 },	/* 4-way set assoc, 32 byte line size */
+	{ 0x45, LVL_2,      2048 },	/* 4-way set assoc, 32 byte line size */
+	{ 0x60, LVL_1_DATA, 16 },	/* 8-way set assoc, sectored cache, 64 byte line size */
+	{ 0x66, LVL_1_DATA, 8 },	/* 4-way set assoc, sectored cache, 64 byte line size */
+	{ 0x67, LVL_1_DATA, 16 },	/* 4-way set assoc, sectored cache, 64 byte line size */
+	{ 0x68, LVL_1_DATA, 32 },	/* 4-way set assoc, sectored cache, 64 byte line size */
+	{ 0x70, LVL_TRACE,  12 },	/* 8-way set assoc */
+	{ 0x71, LVL_TRACE,  16 },	/* 8-way set assoc */
+	{ 0x72, LVL_TRACE,  32 },	/* 8-way set assoc */
+	{ 0x78, LVL_2,    1024 },	/* 4-way set assoc, 64 byte line size */
+	{ 0x79, LVL_2,     128 },	/* 8-way set assoc, sectored cache, 64 byte line size */
+	{ 0x7a, LVL_2,     256 },	/* 8-way set assoc, sectored cache, 64 byte line size */
+	{ 0x7b, LVL_2,     512 },	/* 8-way set assoc, sectored cache, 64 byte line size */
+	{ 0x7c, LVL_2,    1024 },	/* 8-way set assoc, sectored cache, 64 byte line size */
+	{ 0x7d, LVL_2,    2048 },	/* 8-way set assoc, 64 byte line size */
+	{ 0x7f, LVL_2,     512 },	/* 2-way set assoc, 64 byte line size */
+	{ 0x82, LVL_2,     256 },	/* 8-way set assoc, 32 byte line size */
+	{ 0x83, LVL_2,     512 },	/* 8-way set assoc, 32 byte line size */
+	{ 0x84, LVL_2,    1024 },	/* 8-way set assoc, 32 byte line size */
+	{ 0x85, LVL_2,    2048 },	/* 8-way set assoc, 32 byte line size */
+	{ 0x86, LVL_2,     512 },	/* 4-way set assoc, 64 byte line size */
+	{ 0x87, LVL_2,    1024 },	/* 8-way set assoc, 64 byte line size */
+	{ 0x00, 0, 0}
+};
+
+unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c)
+{
+	unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */
+
+	if (c->cpuid_level > 1) {
+		/* supports eax=2  call */
+		int i, j, n;
+		int regs[4];
+		unsigned char *dp = (unsigned char *)regs;
+
+		/* Number of times to iterate */
+		n = cpuid_eax(2) & 0xFF;
+
+		for ( i = 0 ; i < n ; i++ ) {
+			cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]);
+
+			/* If bit 31 is set, this is an unknown format */
+			for ( j = 0 ; j < 3 ; j++ ) {
+				if ( regs[j] < 0 ) regs[j] = 0;
+			}
+
+			/* Byte 0 is level count, not a descriptor */
+			for ( j = 1 ; j < 16 ; j++ ) {
+				unsigned char des = dp[j];
+				unsigned char k = 0;
+
+				/* look up this descriptor in the table */
+				while (cache_table[k].descriptor != 0)
+				{
+					if (cache_table[k].descriptor == des) {
+						switch (cache_table[k].cache_type) {
+						case LVL_1_INST:
+							l1i += cache_table[k].size;
+							break;
+						case LVL_1_DATA:
+							l1d += cache_table[k].size;
+							break;
+						case LVL_2:
+							l2 += cache_table[k].size;
+							break;
+						case LVL_3:
+							l3 += cache_table[k].size;
+							break;
+						case LVL_TRACE:
+							trace += cache_table[k].size;
+							break;
+						}
+
+						break;
+					}
+
+					k++;
+				}
+			}
+		}
+
+		if ( trace )
+			printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
+		else if ( l1i )
+			printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
+		if ( l1d )
+			printk(", L1 D cache: %dK\n", l1d);
+		else
+			printk("\n");
+		if ( l2 )
+			printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
+		if ( l3 )
+			printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
+
+		/*
+		 * This assumes the L3 cache is shared; it typically lives in
+		 * the northbridge.  The L1 caches are included by the L2
+		 * cache, and so should not be included for the purpose of
+		 * SMP switching weights.
+		 */
+		c->x86_cache_size = l2 ? l2 : (l1i+l1d);
+	}
+
+	return l2;
+}
diff -Nru a/arch/i386/kernel/cpu/mcheck/k7.c b/arch/i386/kernel/cpu/mcheck/k7.c
--- a/arch/i386/kernel/cpu/mcheck/k7.c	2004-12-24 13:36:59 -08:00
+++ b/arch/i386/kernel/cpu/mcheck/k7.c	2004-12-24 13:36:59 -08:00
@@ -18,7 +18,7 @@
 #include "mce.h"
 
 /* Machine Check Handler For AMD Athlon/Duron */
-static asmlinkage void k7_machine_check(struct pt_regs * regs, long error_code)
+static fastcall void k7_machine_check(struct pt_regs * regs, long error_code)
 {
 	int recover=1;
 	u32 alow, ahigh, high, low;
@@ -54,6 +54,7 @@
 			wrmsr (MSR_IA32_MC0_STATUS+i*4, 0UL, 0UL);
 			/* Serialize */
 			wmb();
+			add_taint(TAINT_MACHINE_CHECK);
 		}
 	}
 
diff -Nru a/arch/i386/kernel/cpu/mcheck/mce.c b/arch/i386/kernel/cpu/mcheck/mce.c
--- a/arch/i386/kernel/cpu/mcheck/mce.c	2004-12-24 13:37:04 -08:00
+++ b/arch/i386/kernel/cpu/mcheck/mce.c	2004-12-24 13:37:04 -08:00
@@ -22,13 +22,13 @@
 EXPORT_SYMBOL_GPL(nr_mce_banks);	/* non-fatal.o */
 
 /* Handle unconfigured int18 (should never happen) */
-static asmlinkage void unexpected_machine_check(struct pt_regs * regs, long error_code)
+static fastcall void unexpected_machine_check(struct pt_regs * regs, long error_code)
 {	
 	printk(KERN_ERR "CPU#%d: Unexpected int18 (Machine Check).\n", smp_processor_id());
 }
 
 /* Call the installed machine check handler for this CPU setup. */
-void asmlinkage (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check;
+void fastcall (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check;
 
 /* This has to be run for each processor */
 void __init mcheck_init(struct cpuinfo_x86 *c)
diff -Nru a/arch/i386/kernel/cpu/mcheck/mce.h b/arch/i386/kernel/cpu/mcheck/mce.h
--- a/arch/i386/kernel/cpu/mcheck/mce.h	2004-12-24 13:36:18 -08:00
+++ b/arch/i386/kernel/cpu/mcheck/mce.h	2004-12-24 13:36:18 -08:00
@@ -7,7 +7,7 @@
 void winchip_mcheck_init(struct cpuinfo_x86 *c);
 
 /* Call the installed machine check handler for this CPU setup. */
-extern asmlinkage void (*machine_check_vector)(struct pt_regs *, long error_code);
+extern fastcall void (*machine_check_vector)(struct pt_regs *, long error_code);
 
 extern int mce_disabled __initdata;
 extern int nr_mce_banks;
diff -Nru a/arch/i386/kernel/cpu/mcheck/non-fatal.c b/arch/i386/kernel/cpu/mcheck/non-fatal.c
--- a/arch/i386/kernel/cpu/mcheck/non-fatal.c	2004-12-24 13:36:18 -08:00
+++ b/arch/i386/kernel/cpu/mcheck/non-fatal.c	2004-12-24 13:36:18 -08:00
@@ -48,6 +48,7 @@
 
 			/* Serialize */
 			wmb();
+			add_taint(TAINT_MACHINE_CHECK);
 		}
 	}
 }
diff -Nru a/arch/i386/kernel/cpu/mcheck/p4.c b/arch/i386/kernel/cpu/mcheck/p4.c
--- a/arch/i386/kernel/cpu/mcheck/p4.c	2004-12-24 13:37:00 -08:00
+++ b/arch/i386/kernel/cpu/mcheck/p4.c	2004-12-24 13:37:00 -08:00
@@ -40,6 +40,7 @@
 {	
 	printk(KERN_ERR "CPU%d: Unexpected LVT TMR interrupt!\n",
 			smp_processor_id());
+	add_taint(TAINT_MACHINE_CHECK);
 }
 
 /* P4/Xeon Thermal transition interrupt handler */
@@ -60,6 +61,7 @@
 		printk(KERN_EMERG "CPU%d: Temperature above threshold\n", cpu);
 		printk(KERN_EMERG "CPU%d: Running in modulated clock mode\n",
 				cpu);
+		add_taint(TAINT_MACHINE_CHECK);
 	} else {
 		printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu);
 	}
@@ -68,10 +70,10 @@
 /* Thermal interrupt handler for this CPU setup */
 static void (*vendor_thermal_interrupt)(struct pt_regs *regs) = unexpected_thermal_interrupt;
 
-asmlinkage void smp_thermal_interrupt(struct pt_regs regs)
+fastcall void smp_thermal_interrupt(struct pt_regs *regs)
 {
 	irq_enter();
-	vendor_thermal_interrupt(&regs);
+	vendor_thermal_interrupt(regs);
 	irq_exit();
 }
 
@@ -157,7 +159,7 @@
 	return mce_num_extended_msrs;
 }
 
-static asmlinkage void intel_machine_check(struct pt_regs * regs, long error_code)
+static fastcall void intel_machine_check(struct pt_regs * regs, long error_code)
 {
 	int recover=1;
 	u32 alow, ahigh, high, low;
@@ -222,6 +224,7 @@
 			wrmsr(msr, 0UL, 0UL);
 			/* Serialize */
 			wmb();
+			add_taint(TAINT_MACHINE_CHECK);
 		}
 	}
 	mcgstl &= ~(1<<2);
diff -Nru a/arch/i386/kernel/cpu/mcheck/p5.c b/arch/i386/kernel/cpu/mcheck/p5.c
--- a/arch/i386/kernel/cpu/mcheck/p5.c	2004-12-24 13:37:43 -08:00
+++ b/arch/i386/kernel/cpu/mcheck/p5.c	2004-12-24 13:37:43 -08:00
@@ -17,7 +17,7 @@
 #include "mce.h"
 
 /* Machine check handler for Pentium class Intel */
-static asmlinkage void pentium_machine_check(struct pt_regs * regs, long error_code)
+static fastcall void pentium_machine_check(struct pt_regs * regs, long error_code)
 {
 	u32 loaddr, hi, lotype;
 	rdmsr(MSR_IA32_P5_MC_ADDR, loaddr, hi);
@@ -25,6 +25,7 @@
 	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());
+	add_taint(TAINT_MACHINE_CHECK);
 }
 
 /* Set up machine check reporting for processors with Intel style MCE */
diff -Nru a/arch/i386/kernel/cpu/mcheck/p6.c b/arch/i386/kernel/cpu/mcheck/p6.c
--- a/arch/i386/kernel/cpu/mcheck/p6.c	2004-12-24 13:37:00 -08:00
+++ b/arch/i386/kernel/cpu/mcheck/p6.c	2004-12-24 13:37:00 -08:00
@@ -17,7 +17,7 @@
 #include "mce.h"
 
 /* Machine Check Handler For PII/PIII */
-static asmlinkage void intel_machine_check(struct pt_regs * regs, long error_code)
+static fastcall void intel_machine_check(struct pt_regs * regs, long error_code)
 {
 	int recover=1;
 	u32 alow, ahigh, high, low;
@@ -72,6 +72,7 @@
 			wrmsr (msr, 0UL, 0UL);
 			/* Serialize */
 			wmb();
+			add_taint(TAINT_MACHINE_CHECK);
 		}
 	}
 	mcgstl &= ~(1<<2);
diff -Nru a/arch/i386/kernel/cpu/mcheck/winchip.c b/arch/i386/kernel/cpu/mcheck/winchip.c
--- a/arch/i386/kernel/cpu/mcheck/winchip.c	2004-12-24 13:36:55 -08:00
+++ b/arch/i386/kernel/cpu/mcheck/winchip.c	2004-12-24 13:36:55 -08:00
@@ -16,9 +16,10 @@
 #include "mce.h"
 
 /* Machine check handler for WinChip C6 */
-static asmlinkage void winchip_machine_check(struct pt_regs * regs, long error_code)
+static fastcall void winchip_machine_check(struct pt_regs * regs, long error_code)
 {
 	printk(KERN_EMERG "CPU0: Machine Check Exception.\n");
+	add_taint(TAINT_MACHINE_CHECK);
 }
 
 /* Set up machine check reporting on the Winchip C6 series */
diff -Nru a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
--- a/arch/i386/kernel/cpu/mtrr/main.c	2004-12-24 13:36:17 -08:00
+++ b/arch/i386/kernel/cpu/mtrr/main.c	2004-12-24 13:36:17 -08:00
@@ -77,22 +77,24 @@
 {
 	struct pci_dev *dev;
 	
-	if ((dev = pci_find_class(PCI_CLASS_BRIDGE_HOST << 8, NULL)) != NULL) {
+	if ((dev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, NULL)) != NULL) {
 		/* ServerWorks LE chipsets have problems with write-combining 
 		   Don't allow it and leave room for other chipsets to be tagged */
 		if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
 		    dev->device == PCI_DEVICE_ID_SERVERWORKS_LE) {
 			printk(KERN_INFO "mtrr: Serverworks LE detected. Write-combining disabled.\n");
+			pci_dev_put(dev);
 			return 0;
 		}
 		/* Intel 450NX errata # 23. Non ascending cachline evictions to
 		   write combining memory may resulting in data corruption */
 		if (dev->vendor == PCI_VENDOR_ID_INTEL &&
-		    dev->device == PCI_DEVICE_ID_INTEL_82451NX)
-		{
+		    dev->device == PCI_DEVICE_ID_INTEL_82451NX) {
 			printk(KERN_INFO "mtrr: Intel 450NX MMC detected. Write-combining disabled.\n");
+			pci_dev_put(dev);
 			return 0;
 		}
+		pci_dev_put(dev);
 	}		
 	return (mtrr_if->have_wrcomb ? mtrr_if->have_wrcomb() : 0);
 }
@@ -147,10 +149,8 @@
 	local_irq_save(flags);
 
 	atomic_dec(&data->count);
-	while(!atomic_read(&data->gate)) {
+	while(!atomic_read(&data->gate))
 		cpu_relax();
-		barrier();
-	}
 
 	/*  The master has cleared me to execute  */
 	if (data->smp_reg != ~0U) 
@@ -160,10 +160,9 @@
 		mtrr_if->set_all();
 
 	atomic_dec(&data->count);
-	while(atomic_read(&data->gate)) {
+	while(atomic_read(&data->gate))
 		cpu_relax();
-		barrier();
-	}
+
 	atomic_dec(&data->count);
 	local_irq_restore(flags);
 }
@@ -228,10 +227,9 @@
 
 	local_irq_save(flags);
 
-	while(atomic_read(&data.count)) {
+	while(atomic_read(&data.count))
 		cpu_relax();
-		barrier();
-	}
+
 	/* ok, reset count and toggle gate */
 	atomic_set(&data.count, num_booting_cpus() - 1);
 	atomic_set(&data.gate,1);
@@ -248,10 +246,9 @@
 		mtrr_if->set(reg,base,size,type);
 
 	/* wait for the others */
-	while(atomic_read(&data.count)) {
+	while(atomic_read(&data.count))
 		cpu_relax();
-		barrier();
-	}
+
 	atomic_set(&data.count, num_booting_cpus() - 1);
 	atomic_set(&data.gate,0);
 
@@ -259,10 +256,9 @@
 	 * Wait here for everyone to have seen the gate change
 	 * So we're the last ones to touch 'data'
 	 */
-	while(atomic_read(&data.count)) {
+	while(atomic_read(&data.count))
 		cpu_relax();
-		barrier();
-	}
+
 	local_irq_restore(flags);
 }
 
diff -Nru a/arch/i386/kernel/cpu/nexgen.c b/arch/i386/kernel/cpu/nexgen.c
--- a/arch/i386/kernel/cpu/nexgen.c	2004-12-24 13:36:18 -08:00
+++ b/arch/i386/kernel/cpu/nexgen.c	2004-12-24 13:36:18 -08:00
@@ -32,7 +32,7 @@
 	c->x86_cache_size = 256; /* A few had 1 MB... */
 }
 
-static void nexgen_identify(struct cpuinfo_x86 * c)
+static void __init nexgen_identify(struct cpuinfo_x86 * c)
 {
 	/* Detect NexGen with old hypercode */
 	if ( deep_magic_nexgen_probe() ) {
diff -Nru a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
--- a/arch/i386/kernel/cpu/proc.c	2004-12-24 13:37:19 -08:00
+++ b/arch/i386/kernel/cpu/proc.c	2004-12-24 13:37:19 -08:00
@@ -25,7 +25,7 @@
 	        "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
 
 		/* AMD-defined */
-		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+		"pni", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
 		NULL, NULL, NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
@@ -88,7 +88,7 @@
 	if (c->x86_cache_size >= 0)
 		seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
 #ifdef CONFIG_X86_HT
-	if (cpu_has_ht) {
+	if (smp_num_siblings > 1) {
 		extern int phys_proc_id[NR_CPUS];
 		seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]);
 		seq_printf(m, "siblings\t: %d\n", smp_num_siblings);
diff -Nru a/arch/i386/kernel/cpu/transmeta.c b/arch/i386/kernel/cpu/transmeta.c
--- a/arch/i386/kernel/cpu/transmeta.c	2004-12-24 13:37:43 -08:00
+++ b/arch/i386/kernel/cpu/transmeta.c	2004-12-24 13:37:43 -08:00
@@ -8,7 +8,7 @@
 {
 	unsigned int cap_mask, uk, max, dummy;
 	unsigned int cms_rev1, cms_rev2;
-	unsigned int cpu_rev, cpu_freq, cpu_flags;
+	unsigned int cpu_rev, cpu_freq, cpu_flags, new_cpu_rev;
 	char cpu_info[65];
 
 	get_model_name(c);	/* Same as AMD/Cyrix */
@@ -16,17 +16,24 @@
 
 	/* Print CMS and CPU revision */
 	max = cpuid_eax(0x80860000);
+	cpu_rev = 0;
 	if ( max >= 0x80860001 ) {
 		cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags); 
-		printk(KERN_INFO "CPU: Processor revision %u.%u.%u.%u, %u MHz\n",
-		       (cpu_rev >> 24) & 0xff,
-		       (cpu_rev >> 16) & 0xff,
-		       (cpu_rev >> 8) & 0xff,
-		       cpu_rev & 0xff,
-		       cpu_freq);
+		if (cpu_rev != 0x02000000) {
+			printk(KERN_INFO "CPU: Processor revision %u.%u.%u.%u, %u MHz\n",
+				(cpu_rev >> 24) & 0xff,
+				(cpu_rev >> 16) & 0xff,
+				(cpu_rev >> 8) & 0xff,
+				cpu_rev & 0xff,
+				cpu_freq);
+		}
 	}
 	if ( max >= 0x80860002 ) {
-		cpuid(0x80860002, &dummy, &cms_rev1, &cms_rev2, &dummy);
+		cpuid(0x80860002, &new_cpu_rev, &cms_rev1, &cms_rev2, &dummy);
+		if (cpu_rev == 0x02000000) {
+			printk(KERN_INFO "CPU: Processor revision %08X, %u MHz\n",
+				new_cpu_rev, cpu_freq);
+		}
 		printk(KERN_INFO "CPU: Code Morphing Software revision %u.%u.%u-%u-%u\n",
 		       (cms_rev1 >> 24) & 0xff,
 		       (cms_rev1 >> 16) & 0xff,
diff -Nru a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
--- a/arch/i386/kernel/dmi_scan.c	2004-12-24 13:36:47 -08:00
+++ b/arch/i386/kernel/dmi_scan.c	2004-12-24 13:36:47 -08:00
@@ -214,20 +214,6 @@
 	}
 	return 0;
 } 
-
-/*
- * early nForce2 reference BIOS shipped with a
- * bogus ACPI IRQ0 -> pin2 interrupt override -- ignore it
- */
-static __init int ignore_timer_override(struct dmi_blacklist *d)
-{
-	extern int acpi_skip_timer_override;
-	printk(KERN_NOTICE "%s detected: BIOS IRQ0 pin2 override"
-		" will be ignored\n", d->ident); 	
-
-	acpi_skip_timer_override = 1;
-	return 0;
-}
 #endif
 
 #ifdef	CONFIG_ACPI_PCI
@@ -308,21 +294,6 @@
 			MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
 			NO_MATCH, NO_MATCH }},
 
-	{ force_acpi_ht, "Compaq ProLiant DL380 G2", {
-			MATCH(DMI_SYS_VENDOR, "Compaq"),
-			MATCH(DMI_PRODUCT_NAME, "ProLiant DL380 G2"),
-			NO_MATCH, NO_MATCH }},
-
-	{ force_acpi_ht, "Compaq ProLiant ML530 G2", {
-			MATCH(DMI_SYS_VENDOR, "Compaq"),
-			MATCH(DMI_PRODUCT_NAME, "ProLiant ML530 G2"),
-			NO_MATCH, NO_MATCH }},
-
-	{ force_acpi_ht, "Compaq ProLiant ML350 G3", {
-			MATCH(DMI_SYS_VENDOR, "Compaq"),
-			MATCH(DMI_PRODUCT_NAME, "ProLiant ML350 G3"),
-			NO_MATCH, NO_MATCH }},
-
 	{ force_acpi_ht, "Compaq Workstation W8000", {
 			MATCH(DMI_SYS_VENDOR, "Compaq"),
 			MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
@@ -368,48 +339,6 @@
 			MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
 			NO_MATCH, NO_MATCH }},
 
-	/*
-	 * Systems with nForce2 BIOS timer override bug
-	 * nVidia claims all nForce have timer on pin0,
-	 * and applying this workaround is a NOP on fixed BIOS,
-	 * so prospects are good for replacing these entries
-	 * with something to key of chipset PCI-ID.
-	 */
-	{ ignore_timer_override, "Abit NF7-S v2", {
-			MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"),
-			MATCH(DMI_BOARD_NAME, "NF7-S/NF7,NF7-V (nVidia-nForce2)"),
-			MATCH(DMI_BIOS_VERSION, "6.00 PG"),
-			MATCH(DMI_BIOS_DATE, "03/24/2004") }},
-
-	{ ignore_timer_override, "Asus A7N8X v2", {
-			MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
-			MATCH(DMI_BOARD_NAME, "A7N8X2.0"),
-			MATCH(DMI_BIOS_VERSION, "ASUS A7N8X2.0 Deluxe ACPI BIOS Rev 1007"),
-			MATCH(DMI_BIOS_DATE, "10/06/2003") }},
-
-	{ ignore_timer_override, "Asus A7N8X-X", {
-			MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
-			MATCH(DMI_BOARD_NAME, "A7N8X-X"),
-			MATCH(DMI_BIOS_VERSION, "ASUS A7N8X-X ACPI BIOS Rev 1009"),
-			MATCH(DMI_BIOS_DATE, "2/3/2004") }},
-
-	{ ignore_timer_override, "MSI K7N2-Delta", {
-			MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
-			MATCH(DMI_BOARD_NAME, "MS-6570"),
-			MATCH(DMI_BIOS_VERSION, "6.00 PG"),
-			MATCH(DMI_BIOS_DATE, "03/29/2004") }},
-
-	{ ignore_timer_override, "Shuttle SN41G2", {
-			MATCH(DMI_BOARD_VENDOR, "Shuttle Inc"),
-			MATCH(DMI_BOARD_NAME, "FN41"),
-			MATCH(DMI_BIOS_VERSION, "6.00 PG"),
-			MATCH(DMI_BIOS_DATE, "01/14/2004") }},
-
-	{ ignore_timer_override, "Shuttle AN35N", {
-			MATCH(DMI_BOARD_VENDOR, "Shuttle Inc"),
-			MATCH(DMI_BOARD_NAME, "AN35"),
-			MATCH(DMI_BIOS_VERSION, "6.00 PG"),
-			MATCH(DMI_BIOS_DATE, "12/05/2003") }},
 #endif	// CONFIG_ACPI_BOOT
 
 #ifdef	CONFIG_ACPI_PCI
diff -Nru a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
--- a/arch/i386/kernel/entry.S	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/kernel/entry.S	2004-12-24 13:36:31 -08:00
@@ -131,7 +131,7 @@
 	movl $(__USER_DS), %edx; \
 	movl %edx, %ds; \
 	movl %edx, %es; \
-	pushl $11;	\
+	movl $11,%eax;	\
 	call do_exit;	\
 .previous;		\
 .section __ex_table,"a";\
@@ -140,40 +140,6 @@
 .previous
 
 
-
-ENTRY(lcall7)
-	pushfl			# We get a different stack layout with call
-				# gates, which has to be cleaned up later..
-	pushl %eax
-	SAVE_ALL
-	movl %esp, %ebp
-	pushl %ebp
-	pushl $0x7
-do_lcall:
-	movl EIP(%ebp), %eax	# due to call gates, this is eflags, not eip..
-	movl CS(%ebp), %edx	# this is eip..
-	movl EFLAGS(%ebp), %ecx	# and this is cs..
-	movl %eax,EFLAGS(%ebp)	#
-	movl %edx,EIP(%ebp)	# Now we move them to their "normal" places
-	movl %ecx,CS(%ebp)	#
-	GET_THREAD_INFO_WITH_ESP(%ebp)	# GET_THREAD_INFO
-	movl TI_exec_domain(%ebp), %edx	# Get the execution domain
-	call *EXEC_DOMAIN_handler(%edx)	# Call the handler for the domain
-	addl $4, %esp
-	popl %eax
-	jmp resume_userspace
-
-ENTRY(lcall27)
-	pushfl			# We get a different stack layout with call
-				# gates, which has to be cleaned up later..
-	pushl %eax
-	SAVE_ALL
-	movl %esp, %ebp
-	pushl %ebp
-	pushl $0x27
-	jmp do_lcall
-
-
 ENTRY(ret_from_fork)
 	pushl %eax
 	call schedule_tail
@@ -221,8 +187,8 @@
 	movl $PREEMPT_ACTIVE,TI_preempt_count(%ebp)
 	sti
 	call schedule
-	movl $0,TI_preempt_count(%ebp)
 	cli
+	movl $0,TI_preempt_count(%ebp)
 	jmp need_resched
 #endif
 
@@ -269,6 +235,7 @@
 /* if something modifies registers it must also disable sysexit */
 	movl EIP(%esp), %edx
 	movl OLDESP(%esp), %ecx
+	xorl %ebp,%ebp
 	sti
 	sysexit
 
@@ -325,8 +292,8 @@
 
 	ALIGN
 work_notifysig_v86:
-	pushl %ecx
-	call save_v86_state
+	pushl %ecx			# save ti_flags for do_notify_resume
+	call save_v86_state		# %eax contains pt_regs pointer
 	popl %ecx
 	movl %eax, %esp
 	xorl %edx, %edx
@@ -393,6 +360,7 @@
 	ALIGN
 common_interrupt:
 	SAVE_ALL
+	movl %esp,%eax
 	call do_IRQ
 	jmp ret_from_intr
 
@@ -400,7 +368,8 @@
 ENTRY(name)				\
 	pushl $nr-256;			\
 	SAVE_ALL			\
-	call smp_/**/name;	\
+	movl %esp,%eax;			\
+	call smp_/**/name;		\
 	jmp ret_from_intr;
 
 /* The include is where all of the SMP etc. interrupts come from */
@@ -423,18 +392,15 @@
 	pushl %ebx
 	cld
 	movl %es, %ecx
-	movl ORIG_EAX(%esp), %esi	# get the error code
 	movl ES(%esp), %edi		# get the function address
+	movl ORIG_EAX(%esp), %edx	# get the error code
 	movl %eax, ORIG_EAX(%esp)
 	movl %ecx, ES(%esp)
-	movl %esp, %edx
-	pushl %esi			# push the error code
-	pushl %edx			# push the pt_regs pointer
-	movl $(__USER_DS), %edx
-	movl %edx, %ds
-	movl %edx, %es
+	movl $(__USER_DS), %ecx
+	movl %ecx, %ds
+	movl %ecx, %es
+	movl %esp,%eax			# pt_regs pointer
 	call *%edi
-	addl $8, %esp
 	jmp ret_from_exception
 
 ENTRY(coprocessor_error)
@@ -491,11 +457,9 @@
 debug_stack_correct:
 	pushl $-1			# mark this as an int
 	SAVE_ALL
-	movl %esp,%edx
-  	pushl $0
-	pushl %edx
+	xorl %edx,%edx			# error code 0
+	movl %esp,%eax			# pt_regs pointer
 	call do_debug
-	addl $8,%esp
 	testl %eax,%eax
 	jnz restore_all
 	jmp ret_from_exception
@@ -525,11 +489,9 @@
 nmi_stack_correct:
 	pushl %eax
 	SAVE_ALL
-	movl %esp, %edx
-	pushl $0
-	pushl %edx
+	xorl %edx,%edx		# zero error code
+	movl %esp,%eax		# pt_regs pointer
 	call do_nmi
-	addl $8, %esp
 	RESTORE_ALL
 
 nmi_stack_fixup:
@@ -549,11 +511,9 @@
 ENTRY(int3)
 	pushl $-1			# mark this as an int
 	SAVE_ALL
-	movl %esp,%edx
-	pushl $0
-	pushl %edx
+	xorl %edx,%edx		# zero error code
+	movl %esp,%eax		# pt_regs pointer
 	call do_int3
-	addl $8,%esp
 	testl %eax,%eax
 	jnz restore_all
 	jmp ret_from_exception
@@ -901,5 +861,9 @@
 	.long sys_mq_getsetattr
 	.long sys_ni_syscall		/* reserved for kexec */
 	.long sys_waitid
+	.long sys_ni_syscall		/* 285 */ /* available */
+	.long sys_add_key
+	.long sys_request_key
+	.long sys_keyctl
 
 syscall_table_size=(.-sys_call_table)
diff -Nru a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c
--- a/arch/i386/kernel/i386_ksyms.c	2004-12-24 13:37:31 -08:00
+++ b/arch/i386/kernel/i386_ksyms.c	2004-12-24 13:37:31 -08:00
@@ -71,14 +71,10 @@
 #endif
 EXPORT_SYMBOL(dump_thread);
 EXPORT_SYMBOL(dump_fpu);
-EXPORT_SYMBOL(dump_extended_fpu);
 EXPORT_SYMBOL_GPL(kernel_fpu_begin);
 EXPORT_SYMBOL(__ioremap);
 EXPORT_SYMBOL(ioremap_nocache);
 EXPORT_SYMBOL(iounmap);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(disable_irq_nosync);
 EXPORT_SYMBOL(probe_irq_mask);
 EXPORT_SYMBOL(kernel_thread);
 EXPORT_SYMBOL(pm_idle);
@@ -146,7 +142,6 @@
 EXPORT_SYMBOL(__read_lock_failed);
 
 /* Global SMP stuff */
-EXPORT_SYMBOL(synchronize_irq);
 EXPORT_SYMBOL(smp_call_function);
 
 /* TLB flushing */
@@ -179,7 +174,7 @@
 
 EXPORT_SYMBOL(register_die_notifier);
 #ifdef CONFIG_HAVE_DEC_LOCK
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
 #endif
 
 EXPORT_SYMBOL(__PAGE_KERNEL);
diff -Nru a/arch/i386/kernel/i387.c b/arch/i386/kernel/i387.c
--- a/arch/i386/kernel/i387.c	2004-12-24 13:37:33 -08:00
+++ b/arch/i386/kernel/i387.c	2004-12-24 13:37:33 -08:00
@@ -519,21 +519,6 @@
 	return fpvalid;
 }
 
-int dump_extended_fpu( struct pt_regs *regs, struct user_fxsr_struct *fpu )
-{
-	int fpvalid;
-	struct task_struct *tsk = current;
-
-	fpvalid = tsk->used_math && cpu_has_fxsr;
-	if ( fpvalid ) {
-		unlazy_fpu( tsk );
-		memcpy( fpu, &tsk->thread.i387.fxsave,
-			sizeof(struct user_fxsr_struct) );
-	}
-
-	return fpvalid;
-}
-
 int dump_task_fpu(struct task_struct *tsk, struct user_i387_struct *fpu)
 {
 	int fpvalid = tsk->used_math;
diff -Nru a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
--- a/arch/i386/kernel/i8259.c	2004-12-24 13:37:19 -08:00
+++ b/arch/i386/kernel/i8259.c	2004-12-24 13:37:19 -08:00
@@ -10,6 +10,7 @@
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
+#include <linux/bitops.h>
 
 #include <asm/8253pit.h>
 #include <asm/atomic.h>
@@ -17,7 +18,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/timer.h>
-#include <asm/bitops.h>
 #include <asm/pgtable.h>
 #include <asm/delay.h>
 #include <asm/desc.h>
diff -Nru a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
--- a/arch/i386/kernel/io_apic.c	2004-12-24 13:36:34 -08:00
+++ b/arch/i386/kernel/io_apic.c	2004-12-24 13:36:34 -08:00
@@ -42,6 +42,9 @@
 
 #include "io_ports.h"
 
+int (*ioapic_renumber_irq)(int ioapic, int irq);
+atomic_t irq_mis_count;
+
 static spinlock_t ioapic_lock = SPIN_LOCK_UNLOCKED;
 
 /*
@@ -255,8 +258,6 @@
 #  define Dprintk(x...) 
 # endif
 
-extern cpumask_t irq_affinity[NR_IRQS];
-
 cpumask_t __cacheline_aligned pending_irq_balance_cpumask[NR_IRQS];
 
 #define IRQBALANCE_CHECK_ARCH -999
@@ -636,7 +637,7 @@
 	return 0;
 }
 
-static int __init irqbalance_disable(char *str)
+int __init irqbalance_disable(char *str)
 {
 	irqbalance_disabled = 1;
 	return 0;
@@ -653,7 +654,7 @@
 	}
 }
 
-__initcall(balanced_irq_init);
+late_initcall(balanced_irq_init);
 
 #else /* !CONFIG_IRQBALANCE */
 static inline void move_irq(int irq) { }
@@ -728,7 +729,7 @@
 /*
  * Find the IRQ entry number of a certain pin.
  */
-static int __init find_irq_entry(int apic, int pin, int type)
+static int find_irq_entry(int apic, int pin, int type)
 {
 	int i;
 
@@ -838,7 +839,7 @@
 /*
  * EISA Edge/Level control register, ELCR
  */
-static int __init EISA_ELCR(unsigned int irq)
+static int EISA_ELCR(unsigned int irq)
 {
 	if (irq < 16) {
 		unsigned int port = 0x4d0 + (irq >> 3);
@@ -955,7 +956,7 @@
 	return polarity;
 }
 
-static int __init MPBIOS_trigger(int idx)
+static int MPBIOS_trigger(int idx)
 {
 	int bus = mp_irqs[idx].mpc_srcbus;
 	int trigger;
@@ -1069,8 +1070,13 @@
 			while (i < apic)
 				irq += nr_ioapic_registers[i++];
 			irq += pin;
-			if ((!apic) && (irq < 16)) 
-				irq += 16;
+
+			/*
+			 * For MPS mode, so far only needed by ES7000 platform
+			 */
+			if (ioapic_renumber_irq)
+				irq = ioapic_renumber_irq(apic, irq);
+
 			break;
 		}
 		default:
@@ -1879,9 +1885,7 @@
 	ack_APIC_irq();
 
 	if (!(v & (1 << (i & 0x1f)))) {
-#ifdef APIC_MISMATCH_DEBUG
 		atomic_inc(&irq_mis_count);
-#endif
 		spin_lock(&ioapic_lock);
 		__mask_and_edge_IO_APIC_irq(irq);
 		__unmask_and_level_IO_APIC_irq(irq);
diff -Nru a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c
--- a/arch/i386/kernel/irq.c	2004-12-24 13:36:17 -08:00
+++ b/arch/i386/kernel/irq.c	2004-12-24 13:36:17 -08:00
@@ -3,437 +3,58 @@
  *
  *	Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  *
- * This file contains the code used by various IRQ handling routines:
- * asking for different IRQ's should be done through these routines
- * instead of just grabbing them. Thus setups with different IRQ numbers
- * shouldn't result in any weird surprises, and installing new handlers
- * should be easier.
+ * This file contains the lowest level x86-specific interrupt
+ * entry, irq-stacks and irq statistics code. All the remaining
+ * irq logic is done by the generic kernel/irq/ code and
+ * by the x86-specific irq controller code. (e.g. i8259.c and
+ * io_apic.c.)
  */
 
-/*
- * (mostly architecture independent, will move to kernel/irq.c in 2.5.)
- *
- * IRQs are in fact implemented a bit like signal handlers for the kernel.
- * Naturally it's not a 1:1 relation, but there are similarities.
- */
-
-#include <linux/config.h>
-#include <linux/errno.h>
+#include <asm/uaccess.h>
 #include <linux/module.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
+#include <linux/seq_file.h>
 #include <linux/interrupt.h>
-#include <linux/timex.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-#include <linux/smp_lock.h>
-#include <linux/init.h>
 #include <linux/kernel_stat.h>
-#include <linux/irq.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <linux/kallsyms.h>
-
-#include <asm/atomic.h>
-#include <asm/io.h>
-#include <asm/smp.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/delay.h>
-#include <asm/desc.h>
-#include <asm/irq.h>
-
-/*
- * Linux has a controller-independent x86 interrupt architecture.
- * every controller has a 'controller-template', that is used
- * by the main code to do the right thing. Each driver-visible
- * interrupt source is transparently wired to the apropriate
- * controller. Thus drivers need not be aware of the
- * interrupt-controller.
- *
- * Various interrupt controllers we handle: 8259 PIC, SMP IO-APIC,
- * PIIX4's internal 8259 PIC and SGI's Visual Workstation Cobalt (IO-)APIC.
- * (IO-APICs assumed to be messaging to Pentium local-APICs)
- *
- * the code is designed to be easily extended with new/different
- * interrupt controllers, without having to do assembly magic.
- */
 
-/*
- * Controller mappings for all interrupt sources:
- */
-irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
-	[0 ... NR_IRQS-1] = {
-		.handler = &no_irq_type,
-		.lock = SPIN_LOCK_UNLOCKED
-	}
-};
-
-static void register_irq_proc (unsigned int irq);
-
-/*
- * per-CPU IRQ handling stacks
- */
-#ifdef CONFIG_4KSTACKS
-union irq_ctx *hardirq_ctx[NR_CPUS];
-union irq_ctx *softirq_ctx[NR_CPUS];
-#endif
-
-/*
- * Special irq handlers.
- */
-
-irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs)
-{ return IRQ_NONE; }
-
-/*
- * Generic no controller code
- */
-
-static void enable_none(unsigned int irq) { }
-static unsigned int startup_none(unsigned int irq) { return 0; }
-static void disable_none(unsigned int irq) { }
-static void ack_none(unsigned int irq)
-{
+#ifndef CONFIG_X86_LOCAL_APIC
 /*
  * 'what should we do if we get a hw irq event on an illegal vector'.
- * each architecture has to answer this themselves, it doesn't deserve
- * a generic callback i think.
+ * each architecture has to answer this themselves.
  */
-#ifdef CONFIG_X86
+void ack_bad_irq(unsigned int irq)
+{
 	printk("unexpected IRQ trap at vector %02x\n", irq);
-#ifdef CONFIG_X86_LOCAL_APIC
-	/*
-	 * Currently unexpected vectors happen only on SMP and APIC.
-	 * We _must_ ack these because every local APIC has only N
-	 * irq slots per priority level, and a 'hanging, unacked' IRQ
-	 * holds up an irq slot - in excessive cases (when multiple
-	 * unexpected vectors occur) that might lock up the APIC
-	 * completely.
-	 */
-	ack_APIC_irq();
-#endif
-#endif
 }
-
-/* startup is the same as "enable", shutdown is same as "disable" */
-#define shutdown_none	disable_none
-#define end_none	enable_none
-
-struct hw_interrupt_type no_irq_type = {
-	"none",
-	startup_none,
-	shutdown_none,
-	enable_none,
-	disable_none,
-	ack_none,
-	end_none
-};
-
-atomic_t irq_err_count;
-#if defined(CONFIG_X86_IO_APIC) && defined(APIC_MISMATCH_DEBUG)
-atomic_t irq_mis_count;
 #endif
 
+#ifdef CONFIG_4KSTACKS
 /*
- * Generic, controller-independent functions:
+ * per-CPU IRQ handling contexts (thread information and stack)
  */
+union irq_ctx {
+	struct thread_info      tinfo;
+	u32                     stack[THREAD_SIZE/sizeof(u32)];
+};
 
-int show_interrupts(struct seq_file *p, void *v)
-{
-	int i = *(loff_t *) v, j;
-	struct irqaction * action;
-	unsigned long flags;
-
-	if (i == 0) {
-		seq_printf(p, "           ");
-		for (j=0; j<NR_CPUS; j++)
-			if (cpu_online(j))
-				seq_printf(p, "CPU%d       ",j);
-		seq_putc(p, '\n');
-	}
-
-	if (i < NR_IRQS) {
-		spin_lock_irqsave(&irq_desc[i].lock, flags);
-		action = irq_desc[i].action;
-		if (!action) 
-			goto skip;
-		seq_printf(p, "%3d: ",i);
-#ifndef CONFIG_SMP
-		seq_printf(p, "%10u ", kstat_irqs(i));
-#else
-		for (j = 0; j < NR_CPUS; j++)
-			if (cpu_online(j))
-				seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
-#endif
-		seq_printf(p, " %14s", irq_desc[i].handler->typename);
-		seq_printf(p, "  %s", action->name);
-
-		for (action=action->next; action; action = action->next)
-			seq_printf(p, ", %s", action->name);
-
-		seq_putc(p, '\n');
-skip:
-		spin_unlock_irqrestore(&irq_desc[i].lock, flags);
-	} else if (i == NR_IRQS) {
-		seq_printf(p, "NMI: ");
-		for (j = 0; j < NR_CPUS; j++)
-			if (cpu_online(j))
-				seq_printf(p, "%10u ", nmi_count(j));
-		seq_putc(p, '\n');
-#ifdef CONFIG_X86_LOCAL_APIC
-		seq_printf(p, "LOC: ");
-		for (j = 0; j < NR_CPUS; j++)
-			if (cpu_online(j))
-				seq_printf(p, "%10u ", irq_stat[j].apic_timer_irqs);
-		seq_putc(p, '\n');
-#endif
-		seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
-#if defined(CONFIG_X86_IO_APIC) && defined(APIC_MISMATCH_DEBUG)
-		seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count));
-#endif
-	}
-	return 0;
-}
-
-
-
-
-#ifdef CONFIG_SMP
-inline void synchronize_irq(unsigned int irq)
-{
-	while (irq_desc[irq].status & IRQ_INPROGRESS)
-		cpu_relax();
-}
+static union irq_ctx *hardirq_ctx[NR_CPUS];
+static union irq_ctx *softirq_ctx[NR_CPUS];
 #endif
 
 /*
- * This should really return information about whether
- * we should do bottom half handling etc. Right now we
- * end up _always_ checking the bottom half, which is a
- * waste of time and is not what some drivers would
- * prefer.
- */
-asmlinkage int handle_IRQ_event(unsigned int irq,
-		struct pt_regs *regs, struct irqaction *action)
-{
-	int status = 1;	/* Force the "do bottom halves" bit */
-	int ret, retval = 0;
-
-	if (!(action->flags & SA_INTERRUPT))
-		local_irq_enable();
-
-	do {
-		ret = action->handler(irq, action->dev_id, regs);
-		if (ret == IRQ_HANDLED)
-			status |= action->flags;
-		retval |= ret;
-		action = action->next;
-	} while (action);
-	if (status & SA_SAMPLE_RANDOM)
-		add_interrupt_randomness(irq);
-	local_irq_disable();
-	return retval;
-}
-
-static void __report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	struct irqaction *action;
-
-	if (action_ret != IRQ_HANDLED && action_ret != IRQ_NONE) {
-		printk(KERN_ERR "irq event %d: bogus return value %x\n",
-				irq, action_ret);
-	} else {
-		printk(KERN_ERR "irq %d: nobody cared!\n", irq);
-	}
-	dump_stack();
-	printk(KERN_ERR "handlers:\n");
-	action = desc->action;
-	do {
-		printk(KERN_ERR "[<%p>]", action->handler);
-		print_symbol(" (%s)",
-			(unsigned long)action->handler);
-		printk("\n");
-		action = action->next;
-	} while (action);
-}
-
-static void report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	static int count = 100;
-
-	if (count) {
-		count--;
-		__report_bad_irq(irq, desc, action_ret);
-	}
-}
-
-static int noirqdebug;
-
-static int __init noirqdebug_setup(char *str)
-{
-	noirqdebug = 1;
-	printk("IRQ lockup detection disabled\n");
-	return 1;
-}
-
-__setup("noirqdebug", noirqdebug_setup);
-
-/*
- * If 99,900 of the previous 100,000 interrupts have not been handled then
- * assume that the IRQ is stuck in some manner.  Drop a diagnostic and try to
- * turn the IRQ off.
- *
- * (The other 100-of-100,000 interrupts may have been a correctly-functioning
- *  device sharing an IRQ with the failing one)
- *
- * Called under desc->lock
- */
-static void note_interrupt(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	if (action_ret != IRQ_HANDLED) {
-		desc->irqs_unhandled++;
-		if (action_ret != IRQ_NONE)
-			report_bad_irq(irq, desc, action_ret);
-	}
-
-	desc->irq_count++;
-	if (desc->irq_count < 100000)
-		return;
-
-	desc->irq_count = 0;
-	if (desc->irqs_unhandled > 99900) {
-		/*
-		 * The interrupt is stuck
-		 */
-		__report_bad_irq(irq, desc, action_ret);
-		/*
-		 * Now kill the IRQ
-		 */
-		printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
-		desc->status |= IRQ_DISABLED;
-		desc->handler->disable(irq);
-	}
-	desc->irqs_unhandled = 0;
-}
-
-/*
- * Generic enable/disable code: this just calls
- * down into the PIC-specific version for the actual
- * hardware disable after having gotten the irq
- * controller lock. 
- */
- 
-/**
- *	disable_irq_nosync - disable an irq without waiting
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line.  Disables and Enables are
- *	nested.
- *	Unlike disable_irq(), this function does not ensure existing
- *	instances of the IRQ handler have completed before returning.
- *
- *	This function may be called from IRQ context.
- */
- 
-inline void disable_irq_nosync(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	if (!desc->depth++) {
-		desc->status |= IRQ_DISABLED;
-		desc->handler->disable(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-/**
- *	disable_irq - disable an irq and wait for completion
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line.  Enables and Disables are
- *	nested.
- *	This function waits for any pending IRQ handlers for this interrupt
- *	to complete before returning. If you use this function while
- *	holding a resource the IRQ handler may need you will deadlock.
- *
- *	This function may be called - with care - from IRQ context.
- */
- 
-void disable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	disable_irq_nosync(irq);
-	if (desc->action)
-		synchronize_irq(irq);
-}
-
-/**
- *	enable_irq - enable handling of an irq
- *	@irq: Interrupt to enable
- *
- *	Undoes the effect of one call to disable_irq().  If this
- *	matches the last disable, processing of interrupts on this
- *	IRQ line is re-enabled.
- *
- *	This function may be called from IRQ context.
- */
- 
-void enable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	switch (desc->depth) {
-	case 1: {
-		unsigned int status = desc->status & ~IRQ_DISABLED;
-		desc->status = status;
-		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
-			desc->status = status | IRQ_REPLAY;
-			hw_resend_irq(desc->handler,irq);
-		}
-		desc->handler->enable(irq);
-		/* fall-through */
-	}
-	default:
-		desc->depth--;
-		break;
-	case 0:
-		printk("enable_irq(%u) unbalanced from %p\n", irq,
-		       __builtin_return_address(0));
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-/*
  * do_IRQ handles all normal device IRQ's (the special
  * SMP cross-CPU interrupts have their own specific
  * handlers).
  */
-asmlinkage unsigned int do_IRQ(struct pt_regs regs)
+fastcall unsigned int do_IRQ(struct pt_regs *regs)
 {	
-	/* 
-	 * We 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).
-	 *
-	 * 0 return value means that this irq is already being
-	 * handled by some other CPU. (or is disabled)
-	 */
-	int irq = regs.orig_eax & 0xff; /* high bits used in ret_from_ code  */
-	irq_desc_t *desc = irq_desc + irq;
-	struct irqaction * action;
-	unsigned int status;
+	/* high bits used in ret_from_ code */
+	int irq = regs->orig_eax & 0xff;
+#ifdef CONFIG_4KSTACKS
+	union irq_ctx *curctx, *irqctx;
+	u32 *isp;
+#endif
 
 	irq_enter();
-
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
 	/* Debugging check for stack overflow: is there less than 1KB free? */
 	{
@@ -448,642 +69,54 @@
 		}
 	}
 #endif
-	kstat_this_cpu.irqs[irq]++;
-	spin_lock(&desc->lock);
-	desc->handler->ack(irq);
-	/*
-	   REPLAY is when Linux resends an IRQ that was dropped earlier
-	   WAITING is used by probe to mark irqs that are being tested
-	   */
-	status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
-	status |= IRQ_PENDING; /* we _want_ to handle it */
 
-	/*
-	 * If the IRQ is disabled for whatever reason, we cannot
-	 * use the action we have.
-	 */
-	action = NULL;
-	if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
-		action = desc->action;
-		status &= ~IRQ_PENDING; /* we commit to handling */
-		status |= IRQ_INPROGRESS; /* we are handling it */
-	}
-	desc->status = status;
+#ifdef CONFIG_4KSTACKS
 
-	/*
-	 * If there is no IRQ handler or it was disabled, exit early.
-	   Since we set PENDING, if another processor is handling
-	   a different instance of this same irq, the other processor
-	   will take care of it.
-	 */
-	if (unlikely(!action))
-		goto out;
+	curctx = (union irq_ctx *) current_thread_info();
+	irqctx = hardirq_ctx[smp_processor_id()];
 
 	/*
-	 * Edge triggered interrupts need to remember
-	 * pending events.
-	 * This applies to any hw interrupts that allow a second
-	 * instance of the same irq to arrive while we are in do_IRQ
-	 * or in the handler. But the code here only handles the _second_
-	 * instance of the irq, not the third or fourth. So it is mostly
-	 * useful for irq hardware that does not mask cleanly in an
-	 * SMP environment.
+	 * this is where we switch to the IRQ stack. However, if we are
+	 * already using the IRQ stack (because we interrupted a hardirq
+	 * handler) we can't do that and just have to keep using the
+	 * current stack (which is the irq stack already after all)
 	 */
-#ifdef CONFIG_4KSTACKS
-
-	for (;;) {
-		irqreturn_t action_ret;
-		u32 *isp;
-		union irq_ctx * curctx;
-		union irq_ctx * irqctx;
-
-		curctx = (union irq_ctx *) current_thread_info();
-		irqctx = hardirq_ctx[smp_processor_id()];
-
-		spin_unlock(&desc->lock);
-
-		/*
-		 * this is where we switch to the IRQ stack. However, if we are already using
-		 * the IRQ stack (because we interrupted a hardirq handler) we can't do that
-		 * and just have to keep using the current stack (which is the irq stack already
-		 * after all)
-		 */
-
-		if (curctx == irqctx)
-			action_ret = handle_IRQ_event(irq, &regs, action);
-		else {
-			/* build the stack frame on the IRQ stack */
-			isp = (u32*) ((char*)irqctx + sizeof(*irqctx));
-			irqctx->tinfo.task = curctx->tinfo.task;
-			irqctx->tinfo.previous_esp = current_stack_pointer();
-
-			*--isp = (u32) action;
-			*--isp = (u32) &regs;
-			*--isp = (u32) irq;
-
-			asm volatile(
-				"       xchgl   %%ebx,%%esp     \n"
-				"       call    handle_IRQ_event \n"
-				"       xchgl   %%ebx,%%esp     \n"
-				: "=a"(action_ret)
-				: "b"(isp)
-				: "memory", "cc", "edx", "ecx"
-			);
+	if (curctx != irqctx) {
+		int arg1, arg2, ebx;
 
+		/* build the stack frame on the IRQ stack */
+		isp = (u32*) ((char*)irqctx + sizeof(*irqctx));
+		irqctx->tinfo.task = curctx->tinfo.task;
+		irqctx->tinfo.previous_esp = current_stack_pointer;
 
-		}
-		spin_lock(&desc->lock);
-		if (!noirqdebug)
-			note_interrupt(irq, desc, action_ret);
-		if (curctx != irqctx)
-			irqctx->tinfo.task = NULL;
-		if (likely(!(desc->status & IRQ_PENDING)))
-			break;
-		desc->status &= ~IRQ_PENDING;
-	}
-
-#else
-
-	for (;;) {
-		irqreturn_t action_ret;
-
-		spin_unlock(&desc->lock);
-
-		action_ret = handle_IRQ_event(irq, &regs, action);
-
-		spin_lock(&desc->lock);
-		if (!noirqdebug)
-			note_interrupt(irq, desc, action_ret);
-		if (likely(!(desc->status & IRQ_PENDING)))
-			break;
-		desc->status &= ~IRQ_PENDING;
-	}
+		asm volatile(
+			"       xchgl   %%ebx,%%esp      \n"
+			"       call    __do_IRQ         \n"
+			"       movl   %%ebx,%%esp      \n"
+			: "=a" (arg1), "=d" (arg2), "=b" (ebx)
+			:  "0" (irq),   "1" (regs),  "2" (isp)
+			: "memory", "cc", "ecx"
+		);
+	} else
 #endif
-	desc->status &= ~IRQ_INPROGRESS;
-
-out:
-	/*
-	 * The ->end() handler has to deal with interrupts which got
-	 * disabled while the handler was running.
-	 */
-	desc->handler->end(irq);
-	spin_unlock(&desc->lock);
+		__do_IRQ(irq, regs);
 
 	irq_exit();
 
 	return 1;
 }
 
-int can_request_irq(unsigned int irq, unsigned long irqflags)
-{
-	struct irqaction *action;
-
-	if (irq >= NR_IRQS)
-		return 0;
-	action = irq_desc[irq].action;
-	if (action) {
-		if (irqflags & action->flags & SA_SHIRQ)
-			action = NULL;
-	}
-	return !action;
-}
-
-/**
- *	request_irq - allocate an interrupt line
- *	@irq: Interrupt line to allocate
- *	@handler: Function to be called when the IRQ occurs
- *	@irqflags: Interrupt type flags
- *	@devname: An ascii name for the claiming device
- *	@dev_id: A cookie passed back to the handler function
- *
- *	This call allocates interrupt resources and enables the
- *	interrupt line and IRQ handling. From the point this
- *	call is made your handler function may be invoked. Since
- *	your handler function must clear any interrupt the board 
- *	raises, you must take care both to initialise your hardware
- *	and to set up the interrupt handler in the right order.
- *
- *	Dev_id must be globally unique. Normally the address of the
- *	device data structure is used as the cookie. Since the handler
- *	receives this value it makes sense to use it.
- *
- *	If your interrupt is shared you must pass a non NULL dev_id
- *	as this is required when freeing the interrupt.
- *
- *	Flags:
- *
- *	SA_SHIRQ		Interrupt is shared
- *
- *	SA_INTERRUPT		Disable local interrupts while processing
- *
- *	SA_SAMPLE_RANDOM	The interrupt can be used for entropy
- *
- */
- 
-int request_irq(unsigned int irq, 
-		irqreturn_t (*handler)(int, void *, struct pt_regs *),
-		unsigned long irqflags, 
-		const char * devname,
-		void *dev_id)
-{
-	int retval;
-	struct irqaction * action;
-
-#if 1
-	/*
-	 * Sanity-check: shared interrupts should REALLY pass in
-	 * a real dev-ID, otherwise we'll have trouble later trying
-	 * to figure out which interrupt is which (messes up the
-	 * interrupt freeing logic etc).
-	 */
-	if (irqflags & SA_SHIRQ) {
-		if (!dev_id)
-			printk("Bad boy: %s (at 0x%x) called us without a dev_id!\n", devname, (&irq)[-1]);
-	}
-#endif
-
-	if (irq >= NR_IRQS)
-		return -EINVAL;
-	if (!handler)
-		return -EINVAL;
-
-	action = (struct irqaction *)
-			kmalloc(sizeof(struct irqaction), GFP_ATOMIC);
-	if (!action)
-		return -ENOMEM;
-
-	action->handler = handler;
-	action->flags = irqflags;
-	cpus_clear(action->mask);
-	action->name = devname;
-	action->next = NULL;
-	action->dev_id = dev_id;
-
-	retval = setup_irq(irq, action);
-	if (retval)
-		kfree(action);
-	return retval;
-}
-
-EXPORT_SYMBOL(request_irq);
-
-/**
- *	free_irq - free an interrupt
- *	@irq: Interrupt line to free
- *	@dev_id: Device identity to free
- *
- *	Remove an interrupt handler. The handler is removed and if the
- *	interrupt line is no longer in use by any driver it is disabled.
- *	On a shared IRQ the caller must ensure the interrupt is disabled
- *	on the card it drives before calling this function. The function
- *	does not return until any executing interrupts for this IRQ
- *	have completed.
- *
- *	This function must not be called from interrupt context. 
- */
- 
-void free_irq(unsigned int irq, void *dev_id)
-{
-	irq_desc_t *desc;
-	struct irqaction **p;
-	unsigned long flags;
-
-	if (irq >= NR_IRQS)
-		return;
-
-	desc = irq_desc + irq;
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	for (;;) {
-		struct irqaction * action = *p;
-		if (action) {
-			struct irqaction **pp = p;
-			p = &action->next;
-			if (action->dev_id != dev_id)
-				continue;
-
-			/* Found it - now remove it from the list of entries */
-			*pp = action->next;
-			if (!desc->action) {
-				desc->status |= IRQ_DISABLED;
-				desc->handler->shutdown(irq);
-			}
-			spin_unlock_irqrestore(&desc->lock,flags);
-
-			/* Wait to make sure it's not being used on another CPU */
-			synchronize_irq(irq);
-			kfree(action);
-			return;
-		}
-		printk("Trying to free free IRQ%d\n",irq);
-		spin_unlock_irqrestore(&desc->lock,flags);
-		return;
-	}
-}
-
-EXPORT_SYMBOL(free_irq);
-
-/*
- * IRQ autodetection code..
- *
- * This depends on the fact that any interrupt that
- * comes in on to an unassigned handler will get stuck
- * with "IRQ_WAITING" cleared and the interrupt
- * disabled.
- */
-
-static DECLARE_MUTEX(probe_sem);
-
-/**
- *	probe_irq_on	- begin an interrupt autodetect
- *
- *	Commence probing for an interrupt. The interrupts are scanned
- *	and a mask of potential interrupt lines is returned.
- *
- */
- 
-unsigned long probe_irq_on(void)
-{
-	unsigned int i;
-	irq_desc_t *desc;
-	unsigned long val;
-	unsigned long delay;
-
-	down(&probe_sem);
-	/* 
-	 * something may have generated an irq long ago and we want to
-	 * flush such a longstanding irq before considering it as spurious. 
-	 */
-	for (i = NR_IRQS-1; i > 0; i--)  {
-		desc = irq_desc + i;
-
-		spin_lock_irq(&desc->lock);
-		if (!irq_desc[i].action) 
-			irq_desc[i].handler->startup(i);
-		spin_unlock_irq(&desc->lock);
-	}
-
-	/* Wait for longstanding interrupts to trigger. */
-	for (delay = jiffies + HZ/50; time_after(delay, jiffies); )
-		/* about 20ms delay */ barrier();
-
-	/*
-	 * enable any unassigned irqs
-	 * (we must startup again here because if a longstanding irq
-	 * happened in the previous stage, it may have masked itself)
-	 */
-	for (i = NR_IRQS-1; i > 0; i--) {
-		desc = irq_desc + i;
-
-		spin_lock_irq(&desc->lock);
-		if (!desc->action) {
-			desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
-			if (desc->handler->startup(i))
-				desc->status |= IRQ_PENDING;
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-
-	/*
-	 * Wait for spurious interrupts to trigger
-	 */
-	for (delay = jiffies + HZ/10; time_after(delay, jiffies); )
-		/* about 100ms delay */ barrier();
-
-	/*
-	 * Now filter out any obviously spurious interrupts
-	 */
-	val = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			/* It triggered already - consider it spurious. */
-			if (!(status & IRQ_WAITING)) {
-				desc->status = status & ~IRQ_AUTODETECT;
-				desc->handler->shutdown(i);
-			} else
-				if (i < 32)
-					val |= 1 << i;
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-
-	return val;
-}
-
-EXPORT_SYMBOL(probe_irq_on);
-
-/*
- * Return a mask of triggered interrupts (this
- * can handle only legacy ISA interrupts).
- */
- 
-/**
- *	probe_irq_mask - scan a bitmap of interrupt lines
- *	@val:	mask of interrupts to consider
- *
- *	Scan the ISA bus interrupt lines and return a bitmap of
- *	active interrupts. The interrupt probe logic state is then
- *	returned to its previous value.
- *
- *	Note: we need to scan all the irq's even though we will
- *	only return ISA irq numbers - just so that we reset them
- *	all to a known state.
- */
-unsigned int probe_irq_mask(unsigned long val)
-{
-	int i;
-	unsigned int mask;
-
-	mask = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			if (i < 16 && !(status & IRQ_WAITING))
-				mask |= 1 << i;
-
-			desc->status = status & ~IRQ_AUTODETECT;
-			desc->handler->shutdown(i);
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-	up(&probe_sem);
-
-	return mask & val;
-}
-
-/*
- * Return the one interrupt that triggered (this can
- * handle any interrupt source).
- */
-
-/**
- *	probe_irq_off	- end an interrupt autodetect
- *	@val: mask of potential interrupts (unused)
- *
- *	Scans the unused interrupt lines and returns the line which
- *	appears to have triggered the interrupt. If no interrupt was
- *	found then zero is returned. If more than one interrupt is
- *	found then minus the first candidate is returned to indicate
- *	their is doubt.
- *
- *	The interrupt probe logic state is returned to its previous
- *	value.
- *
- *	BUGS: When used in a module (which arguably shouldnt happen)
- *	nothing prevents two IRQ probe callers from overlapping. The
- *	results of this are non-optimal.
- */
- 
-int probe_irq_off(unsigned long val)
-{
-	int i, irq_found, nr_irqs;
-
-	nr_irqs = 0;
-	irq_found = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			if (!(status & IRQ_WAITING)) {
-				if (!nr_irqs)
-					irq_found = i;
-				nr_irqs++;
-			}
-			desc->status = status & ~IRQ_AUTODETECT;
-			desc->handler->shutdown(i);
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-	up(&probe_sem);
-
-	if (nr_irqs > 1)
-		irq_found = -irq_found;
-	return irq_found;
-}
-
-EXPORT_SYMBOL(probe_irq_off);
-
-/* this was setup_x86_irq but it seems pretty generic */
-int setup_irq(unsigned int irq, struct irqaction * new)
-{
-	int shared = 0;
-	unsigned long flags;
-	struct irqaction *old, **p;
-	irq_desc_t *desc = irq_desc + irq;
-
-	if (desc->handler == &no_irq_type)
-		return -ENOSYS;
-	/*
-	 * Some drivers like serial.c use request_irq() heavily,
-	 * so we have to be careful not to interfere with a
-	 * running system.
-	 */
-	if (new->flags & SA_SAMPLE_RANDOM) {
-		/*
-		 * This function might sleep, we want to call it first,
-		 * outside of the atomic block.
-		 * Yes, this might clear the entropy pool if the wrong
-		 * driver is attempted to be loaded, without actually
-		 * installing a new handler, but is this really a problem,
-		 * only the sysadmin is able to do this.
-		 */
-		rand_initialize_irq(irq);
-	}
-
-	/*
-	 * The following block of code has to be executed atomically
-	 */
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	if ((old = *p) != NULL) {
-		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
-			spin_unlock_irqrestore(&desc->lock,flags);
-			return -EBUSY;
-		}
-
-		/* add new interrupt at end of irq queue */
-		do {
-			p = &old->next;
-			old = *p;
-		} while (old);
-		shared = 1;
-	}
-
-	*p = new;
-
-	if (!shared) {
-		desc->depth = 0;
-		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS);
-		desc->handler->startup(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock,flags);
-
-	register_irq_proc(irq);
-	return 0;
-}
-
-static struct proc_dir_entry * root_irq_dir;
-static struct proc_dir_entry * irq_dir [NR_IRQS];
-
-#ifdef CONFIG_SMP
-
-static struct proc_dir_entry *smp_affinity_entry[NR_IRQS];
-
-cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
-
-static int irq_affinity_read_proc(char *page, char **start, off_t off,
-			int count, int *eof, void *data)
-{
-	int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
-	if (count - len < 2)
-		return -EINVAL;
-	len += sprintf(page + len, "\n");
-	return len;
-}
-
-static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
-					unsigned long count, void *data)
-{
-	int irq = (long)data, full_count = count, err;
-	cpumask_t new_value, tmp;
-
-	if (!irq_desc[irq].handler->set_affinity)
-		return -EIO;
-
-	err = cpumask_parse(buffer, count, new_value);
-	if (err)
-		return err;
-
-	/*
-	 * Do not allow disabling IRQs completely - it's a too easy
-	 * way to make the system unusable accidentally :-) At least
-	 * one online CPU still has to be targeted.
-	 */
-	cpus_and(tmp, new_value, cpu_online_map);
-	if (cpus_empty(tmp))
-		return -EINVAL;
-
-	irq_affinity[irq] = new_value;
-	irq_desc[irq].handler->set_affinity(irq,
-					cpumask_of_cpu(first_cpu(new_value)));
-
-	return full_count;
-}
-
-#endif
-#define MAX_NAMELEN 10
-
-static void register_irq_proc (unsigned int irq)
-{
-	char name [MAX_NAMELEN];
-
-	if (!root_irq_dir || (irq_desc[irq].handler == &no_irq_type) ||
-			irq_dir[irq])
-		return;
-
-	memset(name, 0, MAX_NAMELEN);
-	sprintf(name, "%d", irq);
-
-	/* create /proc/irq/1234 */
-	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
-
-#ifdef CONFIG_SMP
-	{
-		struct proc_dir_entry *entry;
-
-		/* create /proc/irq/1234/smp_affinity */
-		entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
-
-		if (entry) {
-			entry->nlink = 1;
-			entry->data = (void *)(long)irq;
-			entry->read_proc = irq_affinity_read_proc;
-			entry->write_proc = irq_affinity_write_proc;
-		}
-
-		smp_affinity_entry[irq] = entry;
-	}
-#endif
-}
-
-void init_irq_proc (void)
-{
-	int i;
-
-	/* create /proc/irq */
-	root_irq_dir = proc_mkdir("irq", NULL);
-	create_prof_cpu_mask(root_irq_dir);
-	/*
-	 * Create entries for all existing IRQs.
-	 */
-	for (i = 0; i < NR_IRQS; i++)
-		register_irq_proc(i);
-}
-
-
 #ifdef CONFIG_4KSTACKS
+
 /*
  * These should really be __section__(".bss.page_aligned") as well, but
  * gcc's 3.0 and earlier don't handle that correctly.
  */
-static char softirq_stack[NR_CPUS * THREAD_SIZE]  __attribute__((__aligned__(THREAD_SIZE)));
-static char hardirq_stack[NR_CPUS * THREAD_SIZE]  __attribute__((__aligned__(THREAD_SIZE)));
+static char softirq_stack[NR_CPUS * THREAD_SIZE]
+		__attribute__((__aligned__(THREAD_SIZE)));
+
+static char hardirq_stack[NR_CPUS * THREAD_SIZE]
+		__attribute__((__aligned__(THREAD_SIZE)));
 
 /*
  * allocate per-cpu stacks for hardirq and for softirq processing
@@ -1135,12 +168,11 @@
 		curctx = current_thread_info();
 		irqctx = softirq_ctx[smp_processor_id()];
 		irqctx->tinfo.task = curctx->task;
-		irqctx->tinfo.previous_esp = current_stack_pointer();
+		irqctx->tinfo.previous_esp = current_stack_pointer;
 
 		/* build the stack frame on the softirq stack */
 		isp = (u32*) ((char*)irqctx + sizeof(*irqctx));
 
-
 		asm volatile(
 			"       xchgl   %%ebx,%%esp     \n"
 			"       call    __do_softirq    \n"
@@ -1156,3 +188,71 @@
 
 EXPORT_SYMBOL(do_softirq);
 #endif
+
+/*
+ * Interrupt statistics:
+ */
+
+atomic_t irq_err_count;
+
+/*
+ * /proc/interrupts printing:
+ */
+
+int show_interrupts(struct seq_file *p, void *v)
+{
+	int i = *(loff_t *) v, j;
+	struct irqaction * action;
+	unsigned long flags;
+
+	if (i == 0) {
+		seq_printf(p, "           ");
+		for (j=0; j<NR_CPUS; j++)
+			if (cpu_online(j))
+				seq_printf(p, "CPU%d       ",j);
+		seq_putc(p, '\n');
+	}
+
+	if (i < NR_IRQS) {
+		spin_lock_irqsave(&irq_desc[i].lock, flags);
+		action = irq_desc[i].action;
+		if (!action)
+			goto skip;
+		seq_printf(p, "%3d: ",i);
+#ifndef CONFIG_SMP
+		seq_printf(p, "%10u ", kstat_irqs(i));
+#else
+		for (j = 0; j < NR_CPUS; j++)
+			if (cpu_online(j))
+				seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
+#endif
+		seq_printf(p, " %14s", irq_desc[i].handler->typename);
+		seq_printf(p, "  %s", action->name);
+
+		for (action=action->next; action; action = action->next)
+			seq_printf(p, ", %s", action->name);
+
+		seq_putc(p, '\n');
+skip:
+		spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+	} else if (i == NR_IRQS) {
+		seq_printf(p, "NMI: ");
+		for (j = 0; j < NR_CPUS; j++)
+			if (cpu_online(j))
+				seq_printf(p, "%10u ", nmi_count(j));
+		seq_putc(p, '\n');
+#ifdef CONFIG_X86_LOCAL_APIC
+		seq_printf(p, "LOC: ");
+		for (j = 0; j < NR_CPUS; j++)
+			if (cpu_online(j))
+				seq_printf(p, "%10u ",
+					irq_stat[j].apic_timer_irqs);
+		seq_putc(p, '\n');
+#endif
+		seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
+#if defined(CONFIG_X86_IO_APIC)
+		seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count));
+#endif
+	}
+	return 0;
+}
diff -Nru a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
--- a/arch/i386/kernel/kprobes.c	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/kernel/kprobes.c	2004-12-24 13:36:48 -08:00
@@ -42,6 +42,7 @@
 static long *jprobe_saved_esp;
 /* copy of the kernel stack at the probe fire time */
 static kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
+void jprobe_return_end(void);
 
 /*
  * returns non-zero if opcode modifies the interrupt flag.
@@ -58,9 +59,14 @@
 	return 0;
 }
 
-void arch_prepare_kprobe(struct kprobe *p)
+int arch_prepare_kprobe(struct kprobe *p)
+{
+	memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
+	return 0;
+}
+
+void arch_remove_kprobe(struct kprobe *p)
 {
-	memcpy(p->insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
 }
 
 static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
@@ -73,7 +79,7 @@
 {
 	regs->eflags |= TF_MASK;
 	regs->eflags &= ~IF_MASK;
-	regs->eip = (unsigned long)&p->insn;
+	regs->eip = (unsigned long)&p->ainsn.insn;
 }
 
 /*
@@ -111,6 +117,11 @@
 	p = get_kprobe(addr);
 	if (!p) {
 		unlock_kprobes();
+		if (regs->eflags & VM_MASK) {
+			/* We are in virtual-8086 mode. Return 0 */
+			goto no_kprobe;
+		}
+
 		if (*addr != BREAKPOINT_INSTRUCTION) {
 			/*
 			 * The breakpoint instruction was removed right
@@ -153,7 +164,7 @@
  * instruction.  To avoid the SMP problems that can occur when we
  * temporarily put back the original opcode to single-step, we
  * single-stepped a copy of the instruction.  The address of this
- * copy is p->insn.
+ * copy is p->ainsn.insn.
  *
  * This function prepares to return from the post-single-step
  * interrupt.  We have to fix up the stack as follows:
@@ -173,10 +184,10 @@
 {
 	unsigned long *tos = (unsigned long *)&regs->esp;
 	unsigned long next_eip = 0;
-	unsigned long copy_eip = (unsigned long)&p->insn;
+	unsigned long copy_eip = (unsigned long)&p->ainsn.insn;
 	unsigned long orig_eip = (unsigned long)p->addr;
 
-	switch (p->insn[0]) {
+	switch (p->ainsn.insn[0]) {
 	case 0x9c:		/* pushfl */
 		*tos &= ~(TF_MASK | IF_MASK);
 		*tos |= kprobe_old_eflags;
@@ -185,13 +196,13 @@
 		*tos = orig_eip + (*tos - copy_eip);
 		break;
 	case 0xff:
-		if ((p->insn[1] & 0x30) == 0x10) {
+		if ((p->ainsn.insn[1] & 0x30) == 0x10) {
 			/* call absolute, indirect */
 			/* Fix return addr; eip is correct. */
 			next_eip = regs->eip;
 			*tos = orig_eip + (*tos - copy_eip);
-		} else if (((p->insn[1] & 0x31) == 0x20) ||	/* jmp near, absolute indirect */
-			   ((p->insn[1] & 0x31) == 0x21)) {	/* jmp far, absolute indirect */
+		} else if (((p->ainsn.insn[1] & 0x31) == 0x20) ||	/* jmp near, absolute indirect */
+			   ((p->ainsn.insn[1] & 0x31) == 0x21)) {	/* jmp far, absolute indirect */
 			/* eip is correct. */
 			next_eip = regs->eip;
 		}
@@ -315,12 +326,12 @@
 {
 	preempt_enable_no_resched();
 	asm volatile ("       xchgl   %%ebx,%%esp     \n"
-		      "       int3			\n"::"b"
+		      "       int3			\n"
+		      "       .globl jprobe_return_end	\n"
+		      "       jprobe_return_end:	\n"
+		      "       nop			\n"::"b"
 		      (jprobe_saved_esp):"memory");
 }
-void jprobe_return_end(void)
-{
-};
 
 int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
 {
diff -Nru a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
--- a/arch/i386/kernel/microcode.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/kernel/microcode.c	2004-12-24 13:36:31 -08:00
@@ -69,7 +69,8 @@
  *		Thanks to Stuart Swales for pointing out this bug.
  */
 
-
+//#define DEBUG /* pr_debug */
+#include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/module.h>
@@ -88,12 +89,6 @@
 MODULE_LICENSE("GPL");
 
 #define MICROCODE_VERSION 	"1.14"
-#define MICRO_DEBUG 		0
-#if MICRO_DEBUG
-#define dprintk(x...) printk(KERN_INFO x)
-#else
-#define dprintk(x...)
-#endif
 
 #define DEFAULT_UCODE_DATASIZE 	(2000) 	  /* 2000 bytes */
 #define MC_HEADER_SIZE		(sizeof (microcode_header_t))  	  /* 48 bytes */
@@ -172,7 +167,7 @@
 	__asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
 	/* get the current revision from MSR 0x8B */
 	rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev);
-	dprintk("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n", 
+	pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
 			uci->sig, uci->pf, uci->rev);
 }
 
@@ -180,22 +175,22 @@
 {
 	struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
 
-	dprintk("Microcode Found.\n");
-	dprintk("   Header Revision 0x%x\n", mc_header->hdrver);
-	dprintk("   Loader Revision 0x%x\n", mc_header->ldrver);
-	dprintk("   Revision 0x%x \n", mc_header->rev);
-	dprintk("   Date %x/%x/%x\n",
+	pr_debug("Microcode Found.\n");
+	pr_debug("   Header Revision 0x%x\n", mc_header->hdrver);
+	pr_debug("   Loader Revision 0x%x\n", mc_header->ldrver);
+	pr_debug("   Revision 0x%x \n", mc_header->rev);
+	pr_debug("   Date %x/%x/%x\n",
 		((mc_header->date >> 24 ) & 0xff),
 		((mc_header->date >> 16 ) & 0xff),
 		(mc_header->date & 0xFFFF));
-	dprintk("   Signature 0x%x\n", sig);
-	dprintk("   Type 0x%x Family 0x%x Model 0x%x Stepping 0x%x\n",
+	pr_debug("   Signature 0x%x\n", sig);
+	pr_debug("   Type 0x%x Family 0x%x Model 0x%x Stepping 0x%x\n",
 		((sig >> 12) & 0x3),
 		((sig >> 8) & 0xf),
 		((sig >> 4) & 0xf),
 		((sig & 0xf)));
-	dprintk("   Processor Flags 0x%x\n", pf);
-	dprintk("   Checksum 0x%x\n", cksum);
+	pr_debug("   Processor Flags 0x%x\n", pf);
+	pr_debug("   Checksum 0x%x\n", cksum);
 
 	if (mc_header->rev < uci->rev) {
 		printk(KERN_ERR "microcode: CPU%d not 'upgrading' to earlier revision"
@@ -209,7 +204,7 @@
 		goto out;
 	}
 
-	dprintk("microcode: CPU%d found a matching microcode update with "
+	pr_debug("microcode: CPU%d found a matching microcode update with "
 		" revision 0x%x (current=0x%x)\n", cpu_num, mc_header->rev, uci->rev);
 	uci->cksum = cksum;
 	uci->pf = pf; /* keep the original mc pf for cksum calculation */
diff -Nru a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
--- a/arch/i386/kernel/mpparse.c	2004-12-24 13:36:33 -08:00
+++ b/arch/i386/kernel/mpparse.c	2004-12-24 13:36:33 -08:00
@@ -808,7 +808,6 @@
 		smp_scan_config(address, 0x400);
 }
 
-
 /* --------------------------------------------------------------------------
                             ACPI-based MP Configuration
    -------------------------------------------------------------------------- */
@@ -996,6 +995,12 @@
 	mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
 	Dprintk("Bus #%d is ISA\n", MP_ISA_BUS);
 
+	/*
+	 * ES7000 has no legacy identity mappings
+	 */
+	if (es7000_plat)
+		return;
+
 	/* 
 	 * Locate the IOAPIC that manages the ISA IRQs (0-15). 
 	 */
@@ -1049,9 +1054,7 @@
 	}
 }
 
-int (*platform_rename_gsi)(int ioapic, int gsi);
-
-void mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
+int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
 {
 	int			ioapic = -1;
 	int			ioapic_pin = 0;
@@ -1060,19 +1063,19 @@
 #ifdef CONFIG_ACPI_BUS
 	/* Don't set up the ACPI SCI because it's already set up */
 	if (acpi_fadt.sci_int == gsi)
-		return;
+		return gsi;
 #endif
 
 	ioapic = mp_find_ioapic(gsi);
 	if (ioapic < 0) {
 		printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
-		return;
+		return gsi;
 	}
 
 	ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
 
-	if (platform_rename_gsi)
-		gsi = platform_rename_gsi(ioapic, gsi);
+	if (ioapic_renumber_irq)
+		gsi = ioapic_renumber_irq(ioapic, gsi);
 
 	/* 
 	 * Avoid pin reprogramming.  PRTs typically include entries  
@@ -1085,12 +1088,12 @@
 		printk(KERN_ERR "Invalid reference to IOAPIC pin "
 			"%d-%d\n", mp_ioapic_routing[ioapic].apic_id, 
 			ioapic_pin);
-		return;
+		return gsi;
 	}
 	if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
 		Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
 			mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
-		return;
+		return gsi;
 	}
 
 	mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
@@ -1098,6 +1101,7 @@
 	io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
 		    edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1,
 		    active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1);
+	return gsi;
 }
 
 #endif /*CONFIG_X86_IO_APIC && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)*/
diff -Nru a/arch/i386/kernel/numaq.c b/arch/i386/kernel/numaq.c
--- a/arch/i386/kernel/numaq.c	2004-12-24 13:37:03 -08:00
+++ b/arch/i386/kernel/numaq.c	2004-12-24 13:37:03 -08:00
@@ -28,6 +28,7 @@
 #include <linux/bootmem.h>
 #include <linux/mmzone.h>
 #include <linux/module.h>
+#include <linux/nodemask.h>
 #include <asm/numaq.h>
 
 /* These are needed before the pgdat's are created */
diff -Nru a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
--- a/arch/i386/kernel/process.c	2004-12-24 13:36:16 -08:00
+++ b/arch/i386/kernel/process.c	2004-12-24 13:36:16 -08:00
@@ -28,7 +28,7 @@
 #include <linux/a.out.h>
 #include <linux/interrupt.h>
 #include <linux/config.h>
-#include <linux/version.h>
+#include <linux/utsname.h>
 #include <linux/delay.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
@@ -57,6 +57,9 @@
 
 int hlt_counter;
 
+unsigned long boot_option_idle_override = 0;
+EXPORT_SYMBOL(boot_option_idle_override);
+
 /*
  * Return saved PC of a blocked thread.
  */
@@ -96,6 +99,8 @@
 			safe_halt();
 		else
 			local_irq_enable();
+	} else {
+		cpu_relax();
 	}
 }
 
@@ -214,6 +219,7 @@
 		pm_idle = default_idle;
 	}
 
+	boot_option_idle_override = 1;
 	return 1;
 }
 
@@ -230,7 +236,8 @@
 
 	if (regs->xcs & 3)
 		printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp);
-	printk(" EFLAGS: %08lx    %s  (%s)\n",regs->eflags, print_tainted(),UTS_RELEASE);
+	printk(" EFLAGS: %08lx    %s  (%s)\n",
+	       regs->eflags, print_tainted(), system_utsname.release);
 	printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
 		regs->eax,regs->ebx,regs->ecx,regs->edx);
 	printk("ESI: %08lx EDI: %08lx EBP: %08lx",
@@ -344,7 +351,7 @@
 		}
 	}
 
-	release_x86_irqs(dead_task);
+	release_vm86_irqs(dead_task);
 }
 
 /*
@@ -368,7 +375,6 @@
 	*childregs = *regs;
 	childregs->eax = 0;
 	childregs->esp = esp;
-	p->set_child_tid = p->clear_child_tid = NULL;
 
 	p->thread.esp = (unsigned long) childregs;
 	p->thread.esp0 = (unsigned long) (childregs+1);
@@ -656,7 +662,9 @@
 			(char __user * __user *) regs.edx,
 			&regs);
 	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
 		/* Make sure we don't return using sysenter.. */
 		set_thread_flag(TIF_IRET);
 	}
diff -Nru a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
--- a/arch/i386/kernel/ptrace.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/kernel/ptrace.c	2004-12-24 13:36:31 -08:00
@@ -138,6 +138,28 @@
 	return retval;
 }
 
+static void set_singlestep(struct task_struct *child)
+{
+	long eflags;
+
+	set_tsk_thread_flag(child, TIF_SINGLESTEP);
+	eflags = get_stack_long(child, EFL_OFFSET);
+	put_stack_long(child, EFL_OFFSET, eflags | TRAP_FLAG);
+	child->ptrace |= PT_DTRACE;
+}
+
+static void clear_singlestep(struct task_struct *child)
+{
+	if (child->ptrace & PT_DTRACE) {
+		long eflags;
+
+		clear_tsk_thread_flag(child, TIF_SINGLESTEP);
+		eflags = get_stack_long(child, EFL_OFFSET);
+		put_stack_long(child, EFL_OFFSET, eflags & ~TRAP_FLAG);
+		child->ptrace &= ~PT_DTRACE;
+	}
+}
+
 /*
  * Called by kernel/ptrace.c when detaching..
  *
@@ -145,11 +167,7 @@
  */
 void ptrace_disable(struct task_struct *child)
 { 
-	long tmp;
-
-	clear_tsk_thread_flag(child, TIF_SINGLESTEP);
-	tmp = get_stack_long(child, EFL_OFFSET) & ~TRAP_FLAG;
-	put_stack_long(child, EFL_OFFSET, tmp);
+	clear_singlestep(child);
 }
 
 /*
@@ -344,6 +362,36 @@
 			  if(addr < (long) &dummy->u_debugreg[4] &&
 			     ((unsigned long) data) >= TASK_SIZE-3) break;
 			  
+			  /* Sanity-check data. Take one half-byte at once with
+			   * check = (val >> (16 + 4*i)) & 0xf. It contains the
+			   * R/Wi and LENi bits; bits 0 and 1 are R/Wi, and bits
+			   * 2 and 3 are LENi. Given a list of invalid values,
+			   * we do mask |= 1 << invalid_value, so that
+			   * (mask >> check) & 1 is a correct test for invalid
+			   * values.
+			   *
+			   * R/Wi contains the type of the breakpoint /
+			   * watchpoint, LENi contains the length of the watched
+			   * data in the watchpoint case.
+			   *
+			   * The invalid values are:
+			   * - LENi == 0x10 (undefined), so mask |= 0x0f00.
+			   * - R/Wi == 0x10 (break on I/O reads or writes), so
+			   *   mask |= 0x4444.
+			   * - R/Wi == 0x00 && LENi != 0x00, so we have mask |=
+			   *   0x1110.
+			   *
+			   * Finally, mask = 0x0f00 | 0x4444 | 0x1110 == 0x5f54.
+			   *
+			   * See the Intel Manual "System Programming Guide",
+			   * 15.2.4
+			   *
+			   * Note that LENi == 0x10 is defined on x86_64 in long
+			   * mode (i.e. even for 32-bit userspace software, but
+			   * 64-bit kernel), so the x86_64 mask value is 0x5454.
+			   * See the AMD manual no. 24593 (AMD64 System
+			   * Programming)*/
+
 			  if(addr == (long) &dummy->u_debugreg[7]) {
 				  data &= ~DR_CONTROL_RESERVED;
 				  for(i=0; i<4; i++)
@@ -358,10 +406,8 @@
 		  }
 		  break;
 
-	case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
-	case PTRACE_CONT: { /* restart after signal. */
-		long tmp;
-
+	case PTRACE_SYSCALL:	/* continue and stop at next (return from) syscall */
+	case PTRACE_CONT:	/* restart after signal. */
 		ret = -EIO;
 		if ((unsigned long) data > _NSIG)
 			break;
@@ -371,56 +417,39 @@
 		else {
 			clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
 		}
-		clear_tsk_thread_flag(child, TIF_SINGLESTEP);
 		child->exit_code = data;
-	/* make sure the single step bit is not set. */
-		tmp = get_stack_long(child, EFL_OFFSET) & ~TRAP_FLAG;
-		put_stack_long(child, EFL_OFFSET,tmp);
+		/* make sure the single step bit is not set. */
+		clear_singlestep(child);
 		wake_up_process(child);
 		ret = 0;
 		break;
-	}
 
 /*
  * make the child exit.  Best I can do is send it a sigkill. 
  * perhaps it should be put in the status that it wants to 
  * exit.
  */
-	case PTRACE_KILL: {
-		long tmp;
-
+	case PTRACE_KILL:
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
-		clear_tsk_thread_flag(child, TIF_SINGLESTEP);
 		/* make sure the single step bit is not set. */
-		tmp = get_stack_long(child, EFL_OFFSET) & ~TRAP_FLAG;
-		put_stack_long(child, EFL_OFFSET, tmp);
+		clear_singlestep(child);
 		wake_up_process(child);
 		break;
-	}
-
-	case PTRACE_SINGLESTEP: {  /* set the trap flag. */
-		long tmp;
 
+	case PTRACE_SINGLESTEP:	/* set the trap flag. */
 		ret = -EIO;
 		if ((unsigned long) data > _NSIG)
 			break;
 		clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-		if ((child->ptrace & PT_DTRACE) == 0) {
-			/* Spurious delayed TF traps may occur */
-			child->ptrace |= PT_DTRACE;
-		}
-		tmp = get_stack_long(child, EFL_OFFSET) | TRAP_FLAG;
-		put_stack_long(child, EFL_OFFSET, tmp);
-		set_tsk_thread_flag(child, TIF_SINGLESTEP);
+		set_singlestep(child);
 		child->exit_code = data;
 		/* give it a chance to run. */
 		wake_up_process(child);
 		ret = 0;
 		break;
-	}
 
 	case PTRACE_DETACH:
 		/* detach a process that was attached. */
diff -Nru a/arch/i386/kernel/quirks.c b/arch/i386/kernel/quirks.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/i386/kernel/quirks.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,50 @@
+/*
+ * This file contains work-arounds for x86 and x86_64 platform bugs.
+ */
+#include <linux/config.h>
+#include <linux/pci.h>
+#include <linux/irq.h>
+
+#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
+
+void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
+{
+	u8 config, rev;
+	u32 word;
+
+	/* BIOS may enable hardware IRQ balancing for
+	 * E7520/E7320/E7525(revision ID 0x9 and below)
+	 * based platforms.
+	 * Disable SW irqbalance/affinity on those platforms.
+	 */
+	pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev);
+	if (rev > 0x9)
+		return;
+
+	printk(KERN_INFO "Intel E7520/7320/7525 detected.");
+
+	/* enable access to config space*/
+	pci_read_config_byte(dev, 0xf4, &config);
+	config |= 0x2;
+	pci_write_config_byte(dev, 0xf4, config);
+
+	/* read xTPR register */
+	raw_pci_ops->read(0, 0, 0x40, 0x4c, 2, &word);
+
+	if (!(word & (1 << 13))) {
+		printk(KERN_INFO "Disabling irq balancing and affinity\n");
+#ifdef CONFIG_IRQBALANCE
+		irqbalance_disable("");
+#endif
+		noirqdebug_setup("");
+		no_irq_affinity = 1;
+	}
+
+	config &= ~0x2;
+	/* disable access to config space*/
+	pci_write_config_byte(dev, 0xf4, config);
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7320_MCH,	quirk_intel_irqbalance);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7525_MCH,	quirk_intel_irqbalance);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7520_MCH,	quirk_intel_irqbalance);
+#endif
diff -Nru a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
--- a/arch/i386/kernel/reboot.c	2004-12-24 13:36:32 -08:00
+++ b/arch/i386/kernel/reboot.c	2004-12-24 13:36:32 -08:00
@@ -137,7 +137,7 @@
 	{ }
 };
 
-static int reboot_init(void)
+static int __init reboot_init(void)
 {
 	dmi_check_system(reboot_dmi_table);
 	return 0;
@@ -331,13 +331,10 @@
 	 * other OSs see a clean IRQ state.
 	 */
 	smp_send_stop();
-#elif defined(CONFIG_X86_LOCAL_APIC)
-	if (cpu_has_apic) {
-		local_irq_disable();
-		disable_local_APIC();
-		local_irq_enable();
-	}
-#endif
+#endif /* CONFIG_SMP */
+
+	lapic_shutdown();
+
 #ifdef CONFIG_X86_IO_APIC
 	disable_IO_APIC();
 #endif
@@ -373,6 +370,8 @@
 
 void machine_power_off(void)
 {
+	lapic_shutdown();
+
 	if (efi_enabled)
 		efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
 	if (pm_power_off)
diff -Nru a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c
--- a/arch/i386/kernel/scx200.c	2004-12-24 13:37:19 -08:00
+++ b/arch/i386/kernel/scx200.c	2004-12-24 13:37:19 -08:00
@@ -22,9 +22,47 @@
 unsigned scx200_gpio_base = 0;
 long scx200_gpio_shadow[2];
 
+static struct pci_device_id scx200_tbl[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) },
+	{ },
+};
+MODULE_DEVICE_TABLE(pci,scx200_tbl);
+
+static int __devinit scx200_probe(struct pci_dev *, const struct pci_device_id *);
+
+static struct pci_driver scx200_pci_driver = {
+	.name = "scx200",
+	.id_table = scx200_tbl,
+	.probe = scx200_probe,
+};
+
 spinlock_t scx200_gpio_lock = SPIN_LOCK_UNLOCKED;
 static spinlock_t scx200_gpio_config_lock = SPIN_LOCK_UNLOCKED;
 
+static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	int bank;
+	unsigned base;
+
+	base = pci_resource_start(pdev, 0);
+	printk(KERN_INFO NAME ": GPIO base 0x%x\n", base);
+
+	if (request_region(base, SCx200_GPIO_SIZE, "NatSemi SCx200 GPIO") == 0) {
+		printk(KERN_ERR NAME ": can't allocate I/O for GPIOs\n");
+		return -EBUSY;
+	}
+
+	scx200_gpio_base = base;
+
+	/* read the current values driven on the GPIO signals */
+	for (bank = 0; bank < 2; ++bank)
+		scx200_gpio_shadow[bank] = inl(scx200_gpio_base + 0x10 * bank);
+
+	return 0;
+
+}
+
 u32 scx200_gpio_configure(int index, u32 mask, u32 bits)
 {
 	u32 config, new_config;
@@ -77,39 +115,14 @@
 
 int __init scx200_init(void)
 {
-	struct pci_dev *bridge;
-	int bank;
-	unsigned base;
-
 	printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n");
 
-	if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, 
-				      PCI_DEVICE_ID_NS_SCx200_BRIDGE,
-				      NULL)) == NULL
-	    && (bridge = pci_find_device(PCI_VENDOR_ID_NS,
-					 PCI_DEVICE_ID_NS_SC1100_BRIDGE,
-					 NULL)) == NULL)
-		return -ENODEV;
-
-	base = pci_resource_start(bridge, 0);
-	printk(KERN_INFO NAME ": GPIO base 0x%x\n", base);
-
-	if (request_region(base, SCx200_GPIO_SIZE, "NatSemi SCx200 GPIO") == 0) {
-		printk(KERN_ERR NAME ": can't allocate I/O for GPIOs\n");
-		return -EBUSY;
-	}
-
-	scx200_gpio_base = base;
-
-	/* read the current values driven on the GPIO signals */
-	for (bank = 0; bank < 2; ++bank)
-		scx200_gpio_shadow[bank] = inl(scx200_gpio_base + 0x10 * bank);
-
-	return 0;
+	return pci_module_init(&scx200_pci_driver);
 }
 
 void __exit scx200_cleanup(void)
 {
+	pci_unregister_driver(&scx200_pci_driver);
 	release_region(scx200_gpio_base, SCx200_GPIO_SIZE);
 }
 
diff -Nru a/arch/i386/kernel/semaphore.c b/arch/i386/kernel/semaphore.c
--- a/arch/i386/kernel/semaphore.c	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/kernel/semaphore.c	2004-12-24 13:36:48 -08:00
@@ -49,12 +49,12 @@
  *    we cannot lose wakeup events.
  */
 
-asmlinkage void __up(struct semaphore *sem)
+fastcall void __up(struct semaphore *sem)
 {
 	wake_up(&sem->wait);
 }
 
-asmlinkage void __sched __down(struct semaphore * sem)
+fastcall void __sched __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -91,7 +91,7 @@
 	tsk->state = TASK_RUNNING;
 }
 
-asmlinkage int __sched __down_interruptible(struct semaphore * sem)
+fastcall int __sched __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
@@ -154,7 +154,7 @@
  * single "cmpxchg" without failure cases,
  * but then it wouldn't work on a 386.
  */
-asmlinkage int __down_trylock(struct semaphore * sem)
+fastcall int __down_trylock(struct semaphore * sem)
 {
 	int sleepers;
 	unsigned long flags;
@@ -183,9 +183,9 @@
  * need to convert that sequence back into the C sequence when
  * there is contention on the semaphore.
  *
- * %ecx contains the semaphore pointer on entry. Save the C-clobbered
- * registers (%eax, %edx and %ecx) except %eax when used as a return
- * value..
+ * %eax contains the semaphore pointer on entry. Save the C-clobbered
+ * registers (%eax, %edx and %ecx) except %eax whish is either a return
+ * value or just clobbered..
  */
 asm(
 ".section .sched.text\n"
@@ -196,13 +196,11 @@
 	"pushl %ebp\n\t"
 	"movl  %esp,%ebp\n\t"
 #endif
-	"pushl %eax\n\t"
 	"pushl %edx\n\t"
 	"pushl %ecx\n\t"
 	"call __down\n\t"
 	"popl %ecx\n\t"
 	"popl %edx\n\t"
-	"popl %eax\n\t"
 #if defined(CONFIG_FRAME_POINTER)
 	"movl %ebp,%esp\n\t"
 	"popl %ebp\n\t"
@@ -257,13 +255,11 @@
 ".align 4\n"
 ".globl __up_wakeup\n"
 "__up_wakeup:\n\t"
-	"pushl %eax\n\t"
 	"pushl %edx\n\t"
 	"pushl %ecx\n\t"
 	"call __up\n\t"
 	"popl %ecx\n\t"
 	"popl %edx\n\t"
-	"popl %eax\n\t"
 	"ret"
 );
 
diff -Nru a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
--- a/arch/i386/kernel/signal.c	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/kernel/signal.c	2004-12-24 13:36:48 -08:00
@@ -292,10 +292,15 @@
 	err |= __put_user(current->thread.error_code, &sc->err);
 	err |= __put_user(regs->eip, &sc->eip);
 	err |= __put_user(regs->xcs, (unsigned int __user *)&sc->cs);
+
+	/*
+	 * Iff TF was set because the program is being single-stepped by a
+	 * debugger, don't save that information on the signal stack.. We
+	 * don't want debugging to change state.
+	 */
 	eflags = regs->eflags;
-	if (current->ptrace & PT_PTRACED) {
+	if (current->ptrace & PT_DTRACE)
 		eflags &= ~TF_MASK;
-	}
 	err |= __put_user(eflags, &sc->eflags);
 	err |= __put_user(regs->esp, &sc->esp_at_signal);
 	err |= __put_user(regs->xss, (unsigned int __user *)&sc->ss);
@@ -412,12 +417,17 @@
 	regs->xes = __USER_DS;
 	regs->xss = __USER_DS;
 	regs->xcs = __USER_CS;
+
+	/*
+	 * Clear TF when entering the signal handler, but
+	 * notify any tracer that was single-stepping it.
+	 * The tracer may want to single-step inside the
+	 * handler too.
+	 */
 	if (regs->eflags & TF_MASK) {
-		if (current->ptrace & PT_PTRACED) {
+		regs->eflags &= ~TF_MASK;
+		if (current->ptrace & PT_DTRACE)
 			ptrace_notify(SIGTRAP);
-		} else {
-			regs->eflags &= ~TF_MASK;
-		}
 	}
 
 #if DEBUG_SIG
@@ -502,12 +512,17 @@
 	regs->xes = __USER_DS;
 	regs->xss = __USER_DS;
 	regs->xcs = __USER_CS;
+
+	/*
+	 * Clear TF when entering the signal handler, but
+	 * notify any tracer that was single-stepping it.
+	 * The tracer may want to single-step inside the
+	 * handler too.
+	 */
 	if (regs->eflags & TF_MASK) {
-		if (current->ptrace & PT_PTRACED) {
+		regs->eflags &= ~TF_MASK;
+		if (current->ptrace & PT_DTRACE)
 			ptrace_notify(SIGTRAP);
-		} else {
-			regs->eflags &= ~TF_MASK;
-		}
 	}
 
 #if DEBUG_SIG
@@ -600,7 +615,9 @@
 		 * have been cleared if the watchpoint triggered
 		 * inside the kernel.
 		 */
-		__asm__("movl %0,%%db7"	: : "r" (current->thread.debugreg[7]));
+		if (unlikely(current->thread.debugreg[7])) {
+			__asm__("movl %0,%%db7"	: : "r" (current->thread.debugreg[7]));
+		}
 
 		/* Whee!  Actually deliver the signal.  */
 		handle_signal(signr, &info, &ka, oldset, regs);
diff -Nru a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
--- a/arch/i386/kernel/smp.c	2004-12-24 13:36:18 -08:00
+++ b/arch/i386/kernel/smp.c	2004-12-24 13:36:18 -08:00
@@ -308,7 +308,7 @@
  * 2) Leave the mm if we are in the lazy tlb mode.
  */
 
-asmlinkage void smp_invalidate_interrupt (void)
+fastcall void smp_invalidate_interrupt(struct pt_regs *regs)
 {
 	unsigned long cpu;
 
@@ -538,11 +538,11 @@
 
 	/* Wait for response */
 	while (atomic_read(&data.started) != cpus)
-		barrier();
+		cpu_relax();
 
 	if (wait)
 		while (atomic_read(&data.finished) != cpus)
-			barrier();
+			cpu_relax();
 	spin_unlock(&call_lock);
 
 	return 0;
@@ -579,12 +579,12 @@
  * all the work is done automatically when
  * we return from the interrupt.
  */
-asmlinkage void smp_reschedule_interrupt(void)
+fastcall void smp_reschedule_interrupt(struct pt_regs *regs)
 {
 	ack_APIC_irq();
 }
 
-asmlinkage void smp_call_function_interrupt(void)
+fastcall void smp_call_function_interrupt(struct pt_regs *regs)
 {
 	void (*func) (void *info) = call_data->func;
 	void *info = call_data->info;
diff -Nru a/arch/i386/kernel/srat.c b/arch/i386/kernel/srat.c
--- a/arch/i386/kernel/srat.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/kernel/srat.c	2004-12-24 13:36:31 -08:00
@@ -28,6 +28,7 @@
 #include <linux/bootmem.h>
 #include <linux/mmzone.h>
 #include <linux/acpi.h>
+#include <linux/nodemask.h>
 #include <asm/srat.h>
 
 /*
diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
--- a/arch/i386/kernel/time.c	2004-12-24 13:36:49 -08:00
+++ b/arch/i386/kernel/time.c	2004-12-24 13:36:49 -08:00
@@ -319,47 +319,57 @@
 	return retval;
 }
 
-static long clock_cmos_diff;
+static long clock_cmos_diff, sleep_start;
 
-static int time_suspend(struct sys_device *dev, u32 state)
+static int timer_suspend(struct sys_device *dev, u32 state)
 {
 	/*
 	 * Estimate time zone so that set_time can update the clock
 	 */
 	clock_cmos_diff = -get_cmos_time();
 	clock_cmos_diff += get_seconds();
+	sleep_start = get_cmos_time();
 	return 0;
 }
 
-static int time_resume(struct sys_device *dev)
+static int timer_resume(struct sys_device *dev)
 {
 	unsigned long flags;
-	unsigned long sec = get_cmos_time() + clock_cmos_diff;
+	unsigned long sec;
+	unsigned long sleep_length;
+
+#ifdef CONFIG_HPET_TIMER
+	if (is_hpet_enabled())
+		hpet_reenable();
+#endif
+	sec = get_cmos_time() + clock_cmos_diff;
+	sleep_length = get_cmos_time() - sleep_start;
 	write_seqlock_irqsave(&xtime_lock, flags);
 	xtime.tv_sec = sec;
 	xtime.tv_nsec = 0;
 	write_sequnlock_irqrestore(&xtime_lock, flags);
+	jiffies += sleep_length * HZ;
 	return 0;
 }
 
-static struct sysdev_class pit_sysclass = {
-	.resume = time_resume,
-	.suspend = time_suspend,
-	set_kset_name("pit"),
+static struct sysdev_class timer_sysclass = {
+	.resume = timer_resume,
+	.suspend = timer_suspend,
+	set_kset_name("timer"),
 };
 
 
 /* XXX this driverfs stuff should probably go elsewhere later -john */
-static struct sys_device device_i8253 = {
+static struct sys_device device_timer = {
 	.id	= 0,
-	.cls	= &pit_sysclass,
+	.cls	= &timer_sysclass,
 };
 
 static int time_init_device(void)
 {
-	int error = sysdev_class_register(&pit_sysclass);
+	int error = sysdev_class_register(&timer_sysclass);
 	if (!error)
-		error = sysdev_register(&device_i8253);
+		error = sysdev_register(&device_timer);
 	return error;
 }
 
@@ -371,9 +381,9 @@
 void __init hpet_time_init(void)
 {
 	xtime.tv_sec = get_cmos_time();
-	wall_to_monotonic.tv_sec = -xtime.tv_sec;
 	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
-	wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
+	set_normalized_timespec(&wall_to_monotonic,
+		-xtime.tv_sec, -xtime.tv_nsec);
 
 	if (hpet_enable() >= 0) {
 		printk("Using HPET for base-timer\n");
@@ -399,9 +409,9 @@
 	}
 #endif
 	xtime.tv_sec = get_cmos_time();
-	wall_to_monotonic.tv_sec = -xtime.tv_sec;
 	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
-	wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
+	set_normalized_timespec(&wall_to_monotonic,
+		-xtime.tv_sec, -xtime.tv_nsec);
 
 	cur_timer = select_timer();
 	printk(KERN_INFO "Using %s for high-res timesource\n",cur_timer->name);
diff -Nru a/arch/i386/kernel/time_hpet.c b/arch/i386/kernel/time_hpet.c
--- a/arch/i386/kernel/time_hpet.c	2004-12-24 13:36:30 -08:00
+++ b/arch/i386/kernel/time_hpet.c	2004-12-24 13:36:30 -08:00
@@ -60,13 +60,46 @@
 }
 #endif
 
+static int hpet_timer_stop_set_go(unsigned long tick)
+{
+	unsigned int cfg;
+
+	/*
+	 * Stop the timers and reset the main counter.
+	 */
+	cfg = hpet_readl(HPET_CFG);
+	cfg &= ~HPET_CFG_ENABLE;
+	hpet_writel(cfg, HPET_CFG);
+	hpet_writel(0, HPET_COUNTER);
+	hpet_writel(0, HPET_COUNTER + 4);
+
+	/*
+	 * Set up timer 0, as periodic with first interrupt to happen at
+	 * hpet_tick, and period also hpet_tick.
+	 */
+	cfg = hpet_readl(HPET_T0_CFG);
+	cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
+	       HPET_TN_SETVAL | HPET_TN_32BIT;
+	hpet_writel(cfg, HPET_T0_CFG);
+	hpet_writel(tick, HPET_T0_CMP);
+
+	/*
+ 	 * Go!
+ 	 */
+	cfg = hpet_readl(HPET_CFG);
+	cfg |= HPET_CFG_ENABLE | HPET_CFG_LEGACY;
+	hpet_writel(cfg, HPET_CFG);
+
+	return 0;
+}
+
 /*
  * Check whether HPET was found by ACPI boot parse. If yes setup HPET
  * counter 0 for kernel base timer.
  */
 int __init hpet_enable(void)
 {
-	unsigned int cfg, id;
+	unsigned int id;
 	unsigned long tick_fsec_low, tick_fsec_high; /* tick in femto sec */
 	unsigned long hpet_tick_rem;
 
@@ -108,31 +141,8 @@
 	if (hpet_tick_rem > (hpet_period >> 1))
 		hpet_tick++; /* rounding the result */
 
-	/*
-	 * Stop the timers and reset the main counter.
-	 */
-	cfg = hpet_readl(HPET_CFG);
-	cfg &= ~HPET_CFG_ENABLE;
-	hpet_writel(cfg, HPET_CFG);
-	hpet_writel(0, HPET_COUNTER);
-	hpet_writel(0, HPET_COUNTER + 4);
-
-	/*
-	 * Set up timer 0, as periodic with first interrupt to happen at
-	 * hpet_tick, and period also hpet_tick.
-	 */
-	cfg = hpet_readl(HPET_T0_CFG);
-	cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
-	       HPET_TN_SETVAL | HPET_TN_32BIT;
-	hpet_writel(cfg, HPET_T0_CFG);
-	hpet_writel(hpet_tick, HPET_T0_CMP);
-
-	/*
- 	 * Go!
- 	 */
-	cfg = hpet_readl(HPET_CFG);
-	cfg |= HPET_CFG_ENABLE | HPET_CFG_LEGACY;
-	hpet_writel(cfg, HPET_CFG);
+	if (hpet_timer_stop_set_go(hpet_tick))
+		return -1;
 
 	use_hpet = 1;
 
@@ -151,6 +161,7 @@
 		 * Register with driver.
 		 * Timer0 and Timer1 is used by platform.
 		 */
+		hd.hd_phys_address = hpet_address;
 		hd.hd_address = hpet_virt_address;
 		hd.hd_nirqs = ntimer;
 		hd.hd_flags = HPET_DATA_PLATFORM;
@@ -183,6 +194,11 @@
 	wait_timer_tick = wait_hpet_tick;
 #endif
 	return 0;
+}
+
+int hpet_reenable(void)
+{
+	return hpet_timer_stop_set_go(hpet_tick);
 }
 
 int is_hpet_enabled(void)
diff -Nru a/arch/i386/kernel/timers/common.c b/arch/i386/kernel/timers/common.c
--- a/arch/i386/kernel/timers/common.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/kernel/timers/common.c	2004-12-24 13:36:31 -08:00
@@ -5,6 +5,7 @@
 #include <linux/init.h>
 #include <linux/timex.h>
 #include <linux/errno.h>
+#include <linux/jiffies.h>
 
 #include <asm/io.h>
 #include <asm/timer.h>
diff -Nru a/arch/i386/kernel/timers/timer.c b/arch/i386/kernel/timers/timer.c
--- a/arch/i386/kernel/timers/timer.c	2004-12-24 13:37:29 -08:00
+++ b/arch/i386/kernel/timers/timer.c	2004-12-24 13:37:29 -08:00
@@ -12,18 +12,18 @@
  */
 #endif
 /* list of timers, ordered by preference, NULL terminated */
-static struct timer_opts* timers[] = {
+static struct init_timer_opts* __initdata timers[] = {
 #ifdef CONFIG_X86_CYCLONE_TIMER
-	&timer_cyclone,
+	&timer_cyclone_init,
 #endif
 #ifdef CONFIG_HPET_TIMER
-	&timer_hpet,
+	&timer_hpet_init,
 #endif
 #ifdef CONFIG_X86_PM_TIMER
-	&timer_pmtmr,
+	&timer_pmtmr_init,
 #endif
-	&timer_tsc,
-	&timer_pit,
+	&timer_tsc_init,
+	&timer_pit_init,
 	NULL,
 };
 
@@ -49,7 +49,7 @@
 /* iterates through the list of timers, returning the first 
  * one that initializes successfully.
  */
-struct timer_opts* select_timer(void)
+struct timer_opts* __init select_timer(void)
 {
 	int i = 0;
 	
@@ -57,7 +57,7 @@
 	while (timers[i]) {
 		if (timers[i]->init)
 			if (timers[i]->init(clock_override) == 0)
-				return timers[i];
+				return timers[i]->opts;
 		++i;
 	}
 		
diff -Nru a/arch/i386/kernel/timers/timer_cyclone.c b/arch/i386/kernel/timers/timer_cyclone.c
--- a/arch/i386/kernel/timers/timer_cyclone.c	2004-12-24 13:37:02 -08:00
+++ b/arch/i386/kernel/timers/timer_cyclone.c	2004-12-24 13:37:02 -08:00
@@ -245,11 +245,15 @@
 /************************************************************/
 
 /* cyclone timer_opts struct */
-struct timer_opts timer_cyclone = {
+static struct timer_opts timer_cyclone = {
 	.name = "cyclone",
-	.init = init_cyclone, 
 	.mark_offset = mark_offset_cyclone, 
 	.get_offset = get_offset_cyclone,
 	.monotonic_clock =	monotonic_clock_cyclone,
 	.delay = delay_cyclone,
+};
+
+struct init_timer_opts __initdata timer_cyclone_init = {
+	.init = init_cyclone,
+	.opts = &timer_cyclone,
 };
diff -Nru a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c
--- a/arch/i386/kernel/timers/timer_hpet.c	2004-12-24 13:37:18 -08:00
+++ b/arch/i386/kernel/timers/timer_hpet.c	2004-12-24 13:37:18 -08:00
@@ -177,11 +177,15 @@
 /************************************************************/
 
 /* tsc timer_opts struct */
-struct timer_opts timer_hpet = {
+static struct timer_opts timer_hpet = {
 	.name = 		"hpet",
-	.init =			init_hpet,
 	.mark_offset =		mark_offset_hpet,
 	.get_offset =		get_offset_hpet,
 	.monotonic_clock =	monotonic_clock_hpet,
 	.delay = 		delay_hpet,
+};
+
+struct init_timer_opts __initdata timer_hpet_init = {
+	.init =	init_hpet,
+	.opts = &timer_hpet,
 };
diff -Nru a/arch/i386/kernel/timers/timer_none.c b/arch/i386/kernel/timers/timer_none.c
--- a/arch/i386/kernel/timers/timer_none.c	2004-12-24 13:36:55 -08:00
+++ b/arch/i386/kernel/timers/timer_none.c	2004-12-24 13:36:55 -08:00
@@ -1,11 +1,6 @@
 #include <linux/init.h>
 #include <asm/timer.h>
 
-static int __init init_none(char* override)
-{
-	return 0;
-}
-
 static void mark_offset_none(void)
 {
 	/* nothing needed */
@@ -37,7 +32,6 @@
 /* none timer_opts struct */
 struct timer_opts timer_none = {
 	.name = 	"none",
-	.init =		init_none, 
 	.mark_offset =	mark_offset_none, 
 	.get_offset =	get_offset_none,
 	.monotonic_clock =	monotonic_clock_none,
diff -Nru a/arch/i386/kernel/timers/timer_pit.c b/arch/i386/kernel/timers/timer_pit.c
--- a/arch/i386/kernel/timers/timer_pit.c	2004-12-24 13:37:18 -08:00
+++ b/arch/i386/kernel/timers/timer_pit.c	2004-12-24 13:37:18 -08:00
@@ -152,14 +152,18 @@
 
 /* tsc timer_opts struct */
 struct timer_opts timer_pit = {
-	.name = 	"pit",
-	.init =		init_pit, 
-	.mark_offset =	mark_offset_pit, 
-	.get_offset =	get_offset_pit,
+	.name = "pit",
+	.mark_offset = mark_offset_pit, 
+	.get_offset = get_offset_pit,
 	.monotonic_clock = monotonic_clock_pit,
 	.delay = delay_pit,
 };
 
+struct init_timer_opts __initdata timer_pit_init = {
+	.init = init_pit, 
+	.opts = &timer_pit,
+};
+
 void setup_pit_timer(void)
 {
 	extern spinlock_t i8253_lock;
@@ -181,7 +185,7 @@
 }
 
 static struct sysdev_class timer_sysclass = {
-	set_kset_name("timer"),
+	set_kset_name("timer_pit"),
 	.resume	= timer_resume,
 };
 
diff -Nru a/arch/i386/kernel/timers/timer_pm.c b/arch/i386/kernel/timers/timer_pm.c
--- a/arch/i386/kernel/timers/timer_pm.c	2004-12-24 13:36:18 -08:00
+++ b/arch/i386/kernel/timers/timer_pm.c	2004-12-24 13:36:18 -08:00
@@ -240,15 +240,18 @@
 
 
 /* acpi timer_opts struct */
-struct timer_opts timer_pmtmr = {
+static struct timer_opts timer_pmtmr = {
 	.name			= "pmtmr",
-	.init 			= init_pmtmr,
 	.mark_offset		= mark_offset_pmtmr,
 	.get_offset		= get_offset_pmtmr,
 	.monotonic_clock 	= monotonic_clock_pmtmr,
 	.delay 			= delay_pmtmr,
 };
 
+struct init_timer_opts __initdata timer_pmtmr_init = {
+	.init = init_pmtmr,
+	.opts = &timer_pmtmr,
+};
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
diff -Nru a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
--- a/arch/i386/kernel/timers/timer_tsc.c	2004-12-24 13:37:01 -08:00
+++ b/arch/i386/kernel/timers/timer_tsc.c	2004-12-24 13:37:01 -08:00
@@ -28,7 +28,7 @@
 #ifdef CONFIG_HPET_TIMER
 static unsigned long hpet_usec_quotient;
 static unsigned long hpet_last;
-struct timer_opts timer_tsc;
+static struct timer_opts timer_tsc;
 #endif
 
 static inline void cpufreq_delayed_get(void);
@@ -546,11 +546,15 @@
 /************************************************************/
 
 /* tsc timer_opts struct */
-struct timer_opts timer_tsc = {
-	.name = 	"tsc",
-	.init =		init_tsc,
-	.mark_offset =	mark_offset_tsc, 
-	.get_offset =	get_offset_tsc,
-	.monotonic_clock =	monotonic_clock_tsc,
+static struct timer_opts timer_tsc = {
+	.name = "tsc",
+	.mark_offset = mark_offset_tsc, 
+	.get_offset = get_offset_tsc,
+	.monotonic_clock = monotonic_clock_tsc,
 	.delay = delay_tsc,
+};
+
+struct init_timer_opts __initdata timer_tsc_init = {
+	.init = init_tsc,
+	.opts = &timer_tsc,
 };
diff -Nru a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
--- a/arch/i386/kernel/traps.c	2004-12-24 13:36:19 -08:00
+++ b/arch/i386/kernel/traps.c	2004-12-24 13:36:19 -08:00
@@ -25,7 +25,7 @@
 #include <linux/highmem.h>
 #include <linux/kallsyms.h>
 #include <linux/ptrace.h>
-#include <linux/version.h>
+#include <linux/utsname.h>
 #include <linux/kprobes.h>
 
 #ifdef CONFIG_EISA
@@ -57,8 +57,6 @@
 #include "mach_traps.h"
 
 asmlinkage int system_call(void);
-asmlinkage void lcall7(void);
-asmlinkage void lcall27(void);
 
 struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 },
 		{ 0, 0 }, { 0, 0 } };
@@ -107,36 +105,27 @@
 	return err;
 }
 
-static int valid_stack_ptr(struct task_struct *task, void *p)
+static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
 {
-	if (p <= (void *)task->thread_info)
-		return 0;
-	if (kstack_end(p))
-		return 0;
-	return 1;
+	return	p > (void *)tinfo &&
+		p < (void *)tinfo + THREAD_SIZE - 3;
 }
 
-#ifdef CONFIG_FRAME_POINTER
-static void print_context_stack(struct task_struct *task, unsigned long *stack,
-			 unsigned long ebp)
+static inline unsigned long print_context_stack(struct thread_info *tinfo,
+				unsigned long *stack, unsigned long ebp)
 {
 	unsigned long addr;
 
-	while (valid_stack_ptr(task, (void *)ebp)) {
+#ifdef	CONFIG_FRAME_POINTER
+	while (valid_stack_ptr(tinfo, (void *)ebp)) {
 		addr = *(unsigned long *)(ebp + 4);
 		printk(" [<%08lx>] ", addr);
 		print_symbol("%s", addr);
 		printk("\n");
 		ebp = *(unsigned long *)ebp;
 	}
-}
 #else
-static void print_context_stack(struct task_struct *task, unsigned long *stack,
-			 unsigned long ebp)
-{
-	unsigned long addr;
-
-	while (!kstack_end(stack)) {
+	while (valid_stack_ptr(tinfo, stack)) {
 		addr = *stack++;
 		if (__kernel_text_address(addr)) {
 			printk(" [<%08lx>]", addr);
@@ -144,8 +133,9 @@
 			printk("\n");
 		}
 	}
-}
 #endif
+	return ebp;
+}
 
 void show_trace(struct task_struct *task, unsigned long * stack)
 {
@@ -154,11 +144,6 @@
 	if (!task)
 		task = current;
 
-	if (!valid_stack_ptr(task, stack)) {
-		printk("Stack pointer is garbage, not printing trace\n");
-		return;
-	}
-
 	if (task == current) {
 		/* Grab ebp right from our regs */
 		asm ("movl %%ebp, %0" : "=r" (ebp) : );
@@ -171,7 +156,7 @@
 		struct thread_info *context;
 		context = (struct thread_info *)
 			((unsigned long)stack & (~(THREAD_SIZE - 1)));
-		print_context_stack(task, stack, ebp);
+		ebp = print_context_stack(context, stack, ebp);
 		stack = (unsigned long*)context->previous_esp;
 		if (!stack)
 			break;
@@ -233,7 +218,7 @@
 	printk("CPU:    %d\nEIP:    %04x:[<%08lx>]    %s VLI\nEFLAGS: %08lx"
 			"   (%s) \n",
 		smp_processor_id(), 0xffff & regs->xcs, regs->eip,
-		print_tainted(), regs->eflags, UTS_RELEASE);
+		print_tainted(), regs->eflags, system_utsname.release);
 	print_symbol("EIP is at %s\n", regs->eip);
 	printk("eax: %08lx   ebx: %08lx   ecx: %08lx   edx: %08lx\n",
 		regs->eax, regs->ebx, regs->ecx, regs->edx);
@@ -373,16 +358,7 @@
 		die(str, regs, err);
 }
 
-static inline unsigned long get_cr2(void)
-{
-	unsigned long address;
-
-	/* get the address */
-	__asm__("movl %%cr2,%0":"=r" (address));
-	return address;
-}
-
-static inline void do_trap(int trapnr, int signr, char *str, int vm86,
+static void do_trap(int trapnr, int signr, char *str, int vm86,
 			   struct pt_regs * regs, long error_code, siginfo_t *info)
 {
 	if (regs->eflags & VM_MASK) {
@@ -419,7 +395,7 @@
 }
 
 #define DO_ERROR(trapnr, signr, str, name) \
-asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
+fastcall void do_##name(struct pt_regs * regs, long error_code) \
 { \
 	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
 						== NOTIFY_STOP) \
@@ -428,7 +404,7 @@
 }
 
 #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
-asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
+fastcall void do_##name(struct pt_regs * regs, long error_code) \
 { \
 	siginfo_t info; \
 	info.si_signo = signr; \
@@ -442,7 +418,7 @@
 }
 
 #define DO_VM86_ERROR(trapnr, signr, str, name) \
-asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
+fastcall void do_##name(struct pt_regs * regs, long error_code) \
 { \
 	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
 						== NOTIFY_STOP) \
@@ -451,7 +427,7 @@
 }
 
 #define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
-asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
+fastcall void do_##name(struct pt_regs * regs, long error_code) \
 { \
 	siginfo_t info; \
 	info.si_signo = signr; \
@@ -477,7 +453,7 @@
 DO_ERROR(12, SIGBUS,  "stack segment", stack_segment)
 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
 
-asmlinkage void do_general_protection(struct pt_regs * regs, long error_code)
+fastcall void do_general_protection(struct pt_regs * regs, long error_code)
 {
 	int cpu = get_cpu();
 	struct tss_struct *tss = &per_cpu(init_tss, cpu);
@@ -528,7 +504,7 @@
 gp_in_kernel:
 	if (!fixup_exception(regs)) {
 		if (notify_die(DIE_GPF, "general protection fault", regs,
-				error_code, 13, SIGSEGV) == NOTIFY_STOP);
+				error_code, 13, SIGSEGV) == NOTIFY_STOP)
 			return;
 		die("general protection fault", regs, error_code);
 	}
@@ -598,7 +574,11 @@
 
 static void default_do_nmi(struct pt_regs * regs)
 {
-	unsigned char reason = get_nmi_reason();
+	unsigned char reason = 0;
+
+	/* Only the BSP gets external NMIs from the system.  */
+	if (!smp_processor_id())
+		reason = get_nmi_reason();
  
 	if (!(reason & 0xc0)) {
 		if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 0, SIGINT)
@@ -637,7 +617,7 @@
  
 static nmi_callback_t nmi_callback = dummy_nmi_callback;
  
-asmlinkage void do_nmi(struct pt_regs * regs, long error_code)
+fastcall void do_nmi(struct pt_regs * regs, long error_code)
 {
 	int cpu;
 
@@ -663,7 +643,7 @@
 }
 
 #ifdef CONFIG_KPROBES
-asmlinkage int do_int3(struct pt_regs *regs, long error_code)
+fastcall int do_int3(struct pt_regs *regs, long error_code)
 {
 	if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
 			== NOTIFY_STOP)
@@ -698,7 +678,7 @@
  * find every occurrence of the TF bit that could be saved away even
  * by user code)
  */
-asmlinkage void do_debug(struct pt_regs * regs, long error_code)
+fastcall void do_debug(struct pt_regs * regs, long error_code)
 {
 	unsigned int condition;
 	struct task_struct *tsk = current;
@@ -837,7 +817,7 @@
 	force_sig_info(SIGFPE, &info, task);
 }
 
-asmlinkage void do_coprocessor_error(struct pt_regs * regs, long error_code)
+fastcall void do_coprocessor_error(struct pt_regs * regs, long error_code)
 {
 	ignore_fpu_irq = 1;
 	math_error((void __user *)regs->eip);
@@ -891,7 +871,7 @@
 	force_sig_info(SIGFPE, &info, task);
 }
 
-asmlinkage void do_simd_coprocessor_error(struct pt_regs * regs,
+fastcall void do_simd_coprocessor_error(struct pt_regs * regs,
 					  long error_code)
 {
 	if (cpu_has_xmm) {
@@ -915,7 +895,7 @@
 	}
 }
 
-asmlinkage void do_spurious_interrupt_bug(struct pt_regs * regs,
+fastcall void do_spurious_interrupt_bug(struct pt_regs * regs,
 					  long error_code)
 {
 #if 0
@@ -1015,11 +995,6 @@
 	_set_gate(idt_table+n,15,3,addr,__KERNEL_CS);
 }
 
-static void __init set_call_gate(void *a, void *addr)
-{
-	_set_gate(a,12,3,addr,__KERNEL_CS);
-}
-
 static void __init set_task_gate(unsigned int n, unsigned int gdt_entry)
 {
 	_set_gate(idt_table+n,5,0,0,(gdt_entry<<3));
@@ -1062,13 +1037,6 @@
 	set_trap_gate(19,&simd_coprocessor_error);
 
 	set_system_gate(SYSCALL_VECTOR,&system_call);
-
-	/*
-	 * default LDT is a single-entry callgate to lcall7 for iBCS
-	 * and a callgate to lcall27 for Solaris/x86 binaries
-	 */
-	set_call_gate(&default_ldt[0],lcall7);
-	set_call_gate(&default_ldt[4],lcall27);
 
 	/*
 	 * Should be a barrier for any external CPU state.
diff -Nru a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
--- a/arch/i386/kernel/vm86.c	2004-12-24 13:36:18 -08:00
+++ b/arch/i386/kernel/vm86.c	2004-12-24 13:36:18 -08:00
@@ -723,7 +723,14 @@
 	irqbits |= irq_bit;
 	if (vm86_irqs[intno].sig)
 		send_sig(vm86_irqs[intno].sig, vm86_irqs[intno].tsk, 1);
-	/* else user will poll for IRQs */
+	spin_unlock_irqrestore(&irqbits_lock, flags);
+	/*
+	 * IRQ will be re-enabled when user asks for the irq (whether
+	 * polling or as a result of the signal)
+	 */
+	disable_irq(intno);
+	return IRQ_HANDLED;
+
 out:
 	spin_unlock_irqrestore(&irqbits_lock, flags);	
 	return IRQ_NONE;
@@ -741,7 +748,7 @@
 	spin_unlock_irqrestore(&irqbits_lock, flags);	
 }
 
-void release_x86_irqs(struct task_struct *task)
+void release_vm86_irqs(struct task_struct *task)
 {
 	int i;
 	for (i = FIRST_VM86_IRQ ; i <= LAST_VM86_IRQ; i++)
diff -Nru a/arch/i386/kernel/vsyscall-sysenter.S b/arch/i386/kernel/vsyscall-sysenter.S
--- a/arch/i386/kernel/vsyscall-sysenter.S	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/kernel/vsyscall-sysenter.S	2004-12-24 13:36:48 -08:00
@@ -84,7 +84,7 @@
 	.byte 0x04		/* DW_CFA_advance_loc4 */
 	.long .Lpop_ebp-.Lenter_kernel
 	.byte 0x0e		/* DW_CFA_def_cfa_offset */
-	.byte 0x12		/* RA at offset 12 now */
+	.byte 0x0c		/* RA at offset 12 now */
 	.byte 0xc5		/* DW_CFA_restore %ebp */
 	.byte 0x04		/* DW_CFA_advance_loc4 */
 	.long .Lpop_edx-.Lpop_ebp
diff -Nru a/arch/i386/lib/dec_and_lock.c b/arch/i386/lib/dec_and_lock.c
--- a/arch/i386/lib/dec_and_lock.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/lib/dec_and_lock.c	2004-12-24 13:36:31 -08:00
@@ -10,7 +10,7 @@
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
 
-int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
+int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
 {
 	int counter;
 	int newcount;
diff -Nru a/arch/i386/mach-default/topology.c b/arch/i386/mach-default/topology.c
--- a/arch/i386/mach-default/topology.c	2004-12-24 13:37:18 -08:00
+++ b/arch/i386/mach-default/topology.c	2004-12-24 13:37:18 -08:00
@@ -27,6 +27,7 @@
  */
 #include <linux/init.h>
 #include <linux/smp.h>
+#include <linux/nodemask.h>
 #include <asm/cpu.h>
 
 struct i386_cpu cpu_devices[NR_CPUS];
diff -Nru a/arch/i386/mach-es7000/es7000.h b/arch/i386/mach-es7000/es7000.h
--- a/arch/i386/mach-es7000/es7000.h	2004-12-24 13:36:18 -08:00
+++ b/arch/i386/mach-es7000/es7000.h	2004-12-24 13:36:18 -08:00
@@ -104,13 +104,6 @@
 #define	MIP_SW_APIC		0x1020b
 #define	MIP_FUNC(VALUE) 	(VALUE & 0xff)
 
-#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
-#define IOAPIC_GSI_BOUND(ioapic) ((ioapic+1) * (nr_ioapic_registers[ioapic]-1))
-#define MAX_GSI_MAPSIZE 32
-#endif
-
-extern unsigned long io_apic_irqs;
-
 extern int parse_unisys_oem (char *oemptr, int oem_entries);
 extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
 extern int es7000_start_cpu(int cpu, unsigned long eip);
diff -Nru a/arch/i386/mach-es7000/es7000plat.c b/arch/i386/mach-es7000/es7000plat.c
--- a/arch/i386/mach-es7000/es7000plat.c	2004-12-24 13:37:19 -08:00
+++ b/arch/i386/mach-es7000/es7000plat.c	2004-12-24 13:37:19 -08:00
@@ -52,72 +52,27 @@
 unsigned long		mip_addr, host_addr;
 
 #if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
-static unsigned long cycle_irqs = 0;
-static unsigned long free_irqs = 0;
-static int gsi_map[MAX_GSI_MAPSIZE] = { [0 ... MAX_GSI_MAPSIZE-1] = -1 };
 
 /*
  * GSI override for ES7000 platforms.
  */
 
-static int __init
-es7000_gsi_override(int ioapic, int gsi)
-{
-	static int newgsi = 0;
-
-	if (gsi_map[gsi] != -1)
-		gsi = gsi_map[gsi];
-	else if (cycle_irqs ^ free_irqs) {
-		newgsi = find_next_bit(&cycle_irqs, IOAPIC_GSI_BOUND(0), newgsi);
-		__set_bit(newgsi, &free_irqs);
-		gsi_map[gsi] = newgsi;
-		gsi = newgsi;
-		newgsi++;
-		Dprintk("es7000_gsi_override: free_irqs = 0x%lx\n", free_irqs);
-	}
-
-	return gsi;
-}
+static unsigned int base;
 
-static int __init
+static int
 es7000_rename_gsi(int ioapic, int gsi)
 {
-	static int initialized = 0;
-	int i;
-
-	/*
-	 * These should NEVER be true at this point but we'd rather be
-	 * safe than sorry.
-	 */
-	if (acpi_disabled || acpi_pci_disabled || acpi_noirq)
- 		return gsi;
-
-	if (ioapic)
- 		return gsi;
-
-	if (!initialized) {
-		unsigned long tmp_irqs = 0;
-
-		for (i = 0; i < nr_ioapic_registers[0]; i++)
-			__set_bit(mp_irqs[i].mpc_srcbusirq, &tmp_irqs);
-
-		cycle_irqs = (~tmp_irqs & io_apic_irqs & ((1 << IOAPIC_GSI_BOUND(0)) - 1));
-
-		initialized = 1;
-		Dprintk("es7000_rename_gsi: cycle_irqs = 0x%lx\n", cycle_irqs);
-	}
-
-	for (i = 0; i < nr_ioapic_registers[0]; i++) {
-		if (mp_irqs[i].mpc_srcbusirq == gsi) {
-			if (mp_irqs[i].mpc_dstirq == gsi)
-				return gsi;
-			else
-				return es7000_gsi_override(0, gsi);
-		}
+	if (!base) {
+		int i;
+		for (i = 0; i < nr_ioapics; i++)
+			base += nr_ioapic_registers[i];
 	}
 
+	if (!ioapic && (gsi < 16)) 
+		gsi += base;
 	return gsi;
 }
+
 #endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)
 
 /*
@@ -184,7 +139,7 @@
 	} else {
 		printk("\nEnabling ES7000 specific features...\n");
 		es7000_plat = 1;
-		platform_rename_gsi = es7000_rename_gsi;
+		ioapic_renumber_irq = es7000_rename_gsi;
 	}
 	return es7000_plat;
 }
diff -Nru a/arch/i386/mach-voyager/voyager_basic.c b/arch/i386/mach-voyager/voyager_basic.c
--- a/arch/i386/mach-voyager/voyager_basic.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/mach-voyager/voyager_basic.c	2004-12-24 13:36:31 -08:00
@@ -53,7 +53,7 @@
 static struct sysrq_key_op sysrq_voyager_dump_op = {
 	.handler	= voyager_dump,
 	.help_msg	= "Voyager",
-	.action_msg	= "Dump Voyager Status\n",
+	.action_msg	= "Dump Voyager Status",
 };
 #endif
 
diff -Nru a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
--- a/arch/i386/mach-voyager/voyager_smp.c	2004-12-24 13:36:47 -08:00
+++ b/arch/i386/mach-voyager/voyager_smp.c	2004-12-24 13:36:47 -08:00
@@ -785,8 +785,8 @@
  * System interrupts occur because some problem was detected on the
  * various busses.  To find out what you have to probe all the
  * hardware via the CAT bus.  FIXME: At the moment we do nothing. */
-asmlinkage void
-smp_vic_sys_interrupt(void)
+fastcall void
+smp_vic_sys_interrupt(struct pt_regs *regs)
 {
 	ack_CPI(VIC_SYS_INT);
 	printk("Voyager SYSTEM INTERRUPT\n");
@@ -795,8 +795,8 @@
 /* Handle a voyager CMN_INT; These interrupts occur either because of
  * a system status change or because a single bit memory error
  * occurred.  FIXME: At the moment, ignore all this. */
-asmlinkage void
-smp_vic_cmn_interrupt(void)
+fastcall void
+smp_vic_cmn_interrupt(struct pt_regs *regs)
 {
 	static __u8 in_cmn_int = 0;
 	static spinlock_t cmn_int_lock = SPIN_LOCK_UNLOCKED;
@@ -824,7 +824,7 @@
 /*
  * Reschedule call back. Nothing to do, all the work is done
  * automatically when we return from the interrupt.  */
-asmlinkage void
+static void
 smp_reschedule_interrupt(void)
 {
 	/* do nothing */
@@ -855,7 +855,7 @@
 /*
  * Invalidate call-back
  */
-asmlinkage void 
+static void 
 smp_invalidate_interrupt(void)
 {
 	__u8 cpu = smp_processor_id();
@@ -989,7 +989,7 @@
 }
 
 /* enable the requested IRQs */
-asmlinkage void
+static void
 smp_enable_irq_interrupt(void)
 {
 	__u8 irq;
@@ -1038,7 +1038,7 @@
  * previously set up.  This is used to schedule a function for
  * execution on all CPU's - set up the function then broadcast a
  * function_interrupt CPI to come here on each CPU */
-asmlinkage void
+static void
 smp_call_function_interrupt(void)
 {
 	void (*func) (void *info) = call_data->func;
@@ -1133,50 +1133,50 @@
  * no local APIC, so I can't do this
  *
  * This function is currently a placeholder and is unused in the code */
-asmlinkage void 
-smp_apic_timer_interrupt(struct pt_regs regs)
+fastcall void 
+smp_apic_timer_interrupt(struct pt_regs *regs)
 {
-	wrapper_smp_local_timer_interrupt(&regs);
+	wrapper_smp_local_timer_interrupt(regs);
 }
 
 /* All of the QUAD interrupt GATES */
-asmlinkage void
-smp_qic_timer_interrupt(struct pt_regs regs)
+fastcall void
+smp_qic_timer_interrupt(struct pt_regs *regs)
 {
 	ack_QIC_CPI(QIC_TIMER_CPI);
-	wrapper_smp_local_timer_interrupt(&regs);
+	wrapper_smp_local_timer_interrupt(regs);
 }
 
-asmlinkage void
-smp_qic_invalidate_interrupt(void)
+fastcall void
+smp_qic_invalidate_interrupt(struct pt_regs *regs)
 {
 	ack_QIC_CPI(QIC_INVALIDATE_CPI);
 	smp_invalidate_interrupt();
 }
 
-asmlinkage void
-smp_qic_reschedule_interrupt(void)
+fastcall void
+smp_qic_reschedule_interrupt(struct pt_regs *regs)
 {
 	ack_QIC_CPI(QIC_RESCHEDULE_CPI);
 	smp_reschedule_interrupt();
 }
 
-asmlinkage void
-smp_qic_enable_irq_interrupt(void)
+fastcall void
+smp_qic_enable_irq_interrupt(struct pt_regs *regs)
 {
 	ack_QIC_CPI(QIC_ENABLE_IRQ_CPI);
 	smp_enable_irq_interrupt();
 }
 
-asmlinkage void
-smp_qic_call_function_interrupt(void)
+fastcall void
+smp_qic_call_function_interrupt(struct pt_regs *regs)
 {
 	ack_QIC_CPI(QIC_CALL_FUNCTION_CPI);
 	smp_call_function_interrupt();
 }
 
-asmlinkage void
-smp_vic_cpi_interrupt(struct pt_regs regs)
+fastcall void
+smp_vic_cpi_interrupt(struct pt_regs *regs)
 {
 	__u8 cpu = smp_processor_id();
 
@@ -1186,7 +1186,7 @@
 		ack_VIC_CPI(VIC_CPI_LEVEL0);
 
 	if(test_and_clear_bit(VIC_TIMER_CPI, &vic_cpi_mailbox[cpu]))
-		wrapper_smp_local_timer_interrupt(&regs);
+		wrapper_smp_local_timer_interrupt(regs);
 	if(test_and_clear_bit(VIC_INVALIDATE_CPI, &vic_cpi_mailbox[cpu]))
 		smp_invalidate_interrupt();
 	if(test_and_clear_bit(VIC_RESCHEDULE_CPI, &vic_cpi_mailbox[cpu]))
diff -Nru a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c
--- a/arch/i386/mm/discontig.c	2004-12-24 13:36:56 -08:00
+++ b/arch/i386/mm/discontig.c	2004-12-24 13:36:56 -08:00
@@ -28,6 +28,7 @@
 #include <linux/mmzone.h>
 #include <linux/highmem.h>
 #include <linux/initrd.h>
+#include <linux/nodemask.h>
 #include <asm/e820.h>
 #include <asm/setup.h>
 #include <asm/mmzone.h>
@@ -467,7 +468,7 @@
 	if (high0->spanned_pages > 0)
 	      	highmem_start_page = high0->zone_mem_map;
 	else
-		highmem_start_page = pfn_to_page(max_low_pfn+1); 
+		highmem_start_page = pfn_to_page(max_low_pfn - 1) + 1;
 	num_physpages = highend_pfn;
 #else
 	num_physpages = max_low_pfn;
diff -Nru a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c
--- a/arch/i386/mm/fault.c	2004-12-24 13:36:16 -08:00
+++ b/arch/i386/mm/fault.c	2004-12-24 13:36:16 -08:00
@@ -201,7 +201,7 @@
 	return 0;
 } 
 
-asmlinkage void do_invalid_op(struct pt_regs *, unsigned long);
+fastcall void do_invalid_op(struct pt_regs *, unsigned long);
 
 /*
  * This routine handles page faults.  It determines the address,
@@ -213,7 +213,7 @@
  *	bit 1 == 0 means read, 1 means write
  *	bit 2 == 0 means kernel, 1 means user-mode
  */
-asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
+fastcall void do_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
 	struct task_struct *tsk;
 	struct mm_struct *mm;
diff -Nru a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c
--- a/arch/i386/mm/hugetlbpage.c	2004-12-24 13:37:19 -08:00
+++ b/arch/i386/mm/hugetlbpage.c	2004-12-24 13:37:19 -08:00
@@ -247,6 +247,7 @@
 
 			page = pmd_page(*pmd);
 			pmd_clear(pmd);
+			mm->nr_ptes--;
 			dec_page_state(nr_page_table_pages);
 			page_cache_release(page);
 		}
@@ -281,3 +282,143 @@
 	spin_unlock(&mm->page_table_lock);
 	return ret;
 }
+
+/* x86_64 also uses this file */
+
+#ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
+static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
+		unsigned long addr, unsigned long len,
+		unsigned long pgoff, unsigned long flags)
+{
+	struct mm_struct *mm = current->mm;
+	struct vm_area_struct *vma;
+	unsigned long start_addr;
+
+	start_addr = mm->free_area_cache;
+
+full_search:
+	addr = ALIGN(start_addr, HPAGE_SIZE);
+
+	for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
+		/* At this point:  (!vma || addr < vma->vm_end). */
+		if (TASK_SIZE - len < addr) {
+			/*
+			 * Start a new search - just in case we missed
+			 * some holes.
+			 */
+			if (start_addr != TASK_UNMAPPED_BASE) {
+				start_addr = TASK_UNMAPPED_BASE;
+				goto full_search;
+			}
+			return -ENOMEM;
+		}
+		if (!vma || addr + len <= vma->vm_start) {
+			mm->free_area_cache = addr + len;
+			return addr;
+		}
+		addr = ALIGN(vma->vm_end, HPAGE_SIZE);
+	}
+}
+
+static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
+		unsigned long addr0, unsigned long len,
+		unsigned long pgoff, unsigned long flags)
+{
+	struct mm_struct *mm = current->mm;
+	struct vm_area_struct *vma, *prev_vma;
+	unsigned long base = mm->mmap_base, addr = addr0;
+	int first_time = 1;
+
+	/* don't allow allocations above current base */
+	if (mm->free_area_cache > base)
+		mm->free_area_cache = base;
+
+try_again:
+	/* make sure it can fit in the remaining address space */
+	if (mm->free_area_cache < len)
+		goto fail;
+
+	/* either no address requested or cant fit in requested address hole */
+	addr = (mm->free_area_cache - len) & HPAGE_MASK;
+	do {
+		/*
+		 * Lookup failure means no vma is above this address,
+		 * i.e. return with success:
+		 */
+		if (!(vma = find_vma_prev(mm, addr, &prev_vma)))
+			return addr;
+
+		/*
+		 * new region fits between prev_vma->vm_end and
+		 * vma->vm_start, use it:
+		 */
+		if (addr + len <= vma->vm_start &&
+				(!prev_vma || (addr >= prev_vma->vm_end)))
+			/* remember the address as a hint for next time */
+			return (mm->free_area_cache = addr);
+		else
+			/* pull free_area_cache down to the first hole */
+			if (mm->free_area_cache == vma->vm_end)
+				mm->free_area_cache = vma->vm_start;
+
+		/* try just below the current vma->vm_start */
+		addr = (vma->vm_start - len) & HPAGE_MASK;
+	} while (len <= vma->vm_start);
+
+fail:
+	/*
+	 * if hint left us with no space for the requested
+	 * mapping then try again:
+	 */
+	if (first_time) {
+		mm->free_area_cache = base;
+		first_time = 0;
+		goto try_again;
+	}
+	/*
+	 * A failed mmap() very likely causes application failure,
+	 * so fall back to the bottom-up function here. This scenario
+	 * can happen with large stack limits and large mmap()
+	 * allocations.
+	 */
+	mm->free_area_cache = TASK_UNMAPPED_BASE;
+	addr = hugetlb_get_unmapped_area_bottomup(file, addr0,
+			len, pgoff, flags);
+
+	/*
+	 * Restore the topdown base:
+	 */
+	mm->free_area_cache = base;
+
+	return addr;
+}
+
+unsigned long
+hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
+		unsigned long len, unsigned long pgoff, unsigned long flags)
+{
+	struct mm_struct *mm = current->mm;
+	struct vm_area_struct *vma;
+
+	if (len & ~HPAGE_MASK)
+		return -EINVAL;
+	if (len > TASK_SIZE)
+		return -ENOMEM;
+
+	if (addr) {
+		addr = ALIGN(addr, HPAGE_SIZE);
+		vma = find_vma(mm, addr);
+		if (TASK_SIZE - len >= addr &&
+		    (!vma || addr + len <= vma->vm_start))
+			return addr;
+	}
+	if (mm->get_unmapped_area == arch_get_unmapped_area)
+		return hugetlb_get_unmapped_area_bottomup(file, addr, len,
+				pgoff, flags);
+	else
+		return hugetlb_get_unmapped_area_topdown(file, addr, len,
+				pgoff, flags);
+}
+
+#endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
+
diff -Nru a/arch/i386/mm/init.c b/arch/i386/mm/init.c
--- a/arch/i386/mm/init.c	2004-12-24 13:37:04 -08:00
+++ b/arch/i386/mm/init.c	2004-12-24 13:37:04 -08:00
@@ -438,8 +438,8 @@
 
 __setup("noexec=", noexec_setup);
 
-#ifdef CONFIG_X86_PAE
 int nx_enabled = 0;
+#ifdef CONFIG_X86_PAE
 
 static void __init set_nx(void)
 {
@@ -704,6 +704,7 @@
 	for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
 		ClearPageReserved(virt_to_page(addr));
 		set_page_count(virt_to_page(addr), 1);
+		memset((void *)addr, 0xcc, PAGE_SIZE);
 		free_page(addr);
 		totalram_pages++;
 	}
diff -Nru a/arch/i386/mm/mmap.c b/arch/i386/mm/mmap.c
--- a/arch/i386/mm/mmap.c	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/mm/mmap.c	2004-12-24 13:36:48 -08:00
@@ -37,7 +37,7 @@
 
 static inline unsigned long mmap_base(struct mm_struct *mm)
 {
-	unsigned long gap = current->rlim[RLIMIT_STACK].rlim_cur;
+	unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
 
 	if (gap < MIN_GAP)
 		gap = MIN_GAP;
@@ -59,7 +59,7 @@
 	 */
 	if (sysctl_legacy_va_layout ||
 			(current->personality & ADDR_COMPAT_LAYOUT) ||
-			current->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY) {
+			current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY) {
 		mm->mmap_base = TASK_UNMAPPED_BASE;
 		mm->get_unmapped_area = arch_get_unmapped_area;
 		mm->unmap_area = arch_unmap_area;
diff -Nru a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c
--- a/arch/i386/mm/pageattr.c	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/mm/pageattr.c	2004-12-24 13:36:48 -08:00
@@ -208,7 +208,6 @@
 	 */
 	__flush_tlb_all();
 }
-EXPORT_SYMBOL(kernel_map_pages);
 #endif
 
 EXPORT_SYMBOL(change_page_attr);
diff -Nru a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
--- a/arch/i386/mm/pgtable.c	2004-12-24 13:37:43 -08:00
+++ b/arch/i386/mm/pgtable.c	2004-12-24 13:37:43 -08:00
@@ -165,10 +165,8 @@
  * against pageattr.c; it is the unique case in which a valid change
  * of kernel pagetables can't be lazily synchronized by vmalloc faults.
  * vmalloc faults work because attached pagetables are never freed.
- * If the locking proves to be non-performant, a ticketing scheme with
- * checks at dup_mmap(), exec(), and other mmlist addition points
- * could be used. The locking scheme was chosen on the basis of
- * manfred's recommendations and having no core impact whatsoever.
+ * The locking scheme was chosen on the basis of manfred's
+ * recommendations and having no core impact whatsoever.
  * -- wli
  */
 spinlock_t pgd_lock = SPIN_LOCK_UNLOCKED;
@@ -235,7 +233,7 @@
 		pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
 		if (!pmd)
 			goto out_oom;
-		set_pgd(&pgd[i], __pgd(1 + __pa((u64)((u32)pmd))));
+		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
 	}
 	return pgd;
 
diff -Nru a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
--- a/arch/i386/pci/acpi.c	2004-12-24 13:37:00 -08:00
+++ b/arch/i386/pci/acpi.c	2004-12-24 13:37:00 -08:00
@@ -15,6 +15,7 @@
 	return pcibios_scan_root(busnum);
 }
 
+extern int pci_routeirq;
 static int __init pci_acpi_init(void)
 {
 	struct pci_dev *dev = NULL;
@@ -30,14 +31,27 @@
 	pcibios_scanned++;
 	pcibios_enable_irq = acpi_pci_irq_enable;
 
-	/*
-	 * PCI IRQ routing is set up by pci_enable_device(), but we
-	 * also do it here in case there are still broken drivers that
-	 * don't use pci_enable_device().
-	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
-		acpi_pci_irq_enable(dev);
-
+	if (pci_routeirq) {
+		/*
+		 * PCI IRQ routing is set up by pci_enable_device(), but we
+		 * also do it here in case there are still broken drivers that
+		 * don't use pci_enable_device().
+		 */
+		printk(KERN_INFO "** Routing PCI interrupts for all devices because \"pci=routeirq\"\n");
+		printk(KERN_INFO "** was specified.  If this was required to make a driver work,\n");
+		printk(KERN_INFO "** please email the output of \"lspci\" to bjorn.helgaas@hp.com\n");
+		printk(KERN_INFO "** so I can fix the driver.\n");
+		while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
+			acpi_pci_irq_enable(dev);
+	} else {
+		printk(KERN_INFO "** PCI interrupts are no longer routed automatically.  If this\n");
+		printk(KERN_INFO "** causes a device to stop working, it is probably because the\n");
+		printk(KERN_INFO "** driver failed to call pci_enable_device().  As a temporary\n");
+		printk(KERN_INFO "** workaround, the \"pci=routeirq\" argument restores the old\n");
+		printk(KERN_INFO "** behavior.  If this argument makes the device work again,\n");
+		printk(KERN_INFO "** please email the output of \"lspci\" to bjorn.helgaas@hp.com\n");
+		printk(KERN_INFO "** so I can fix the driver.\n");
+	}
 #ifdef CONFIG_X86_IO_APIC
 	if (acpi_ioapic)
 		print_IO_APIC();
diff -Nru a/arch/i386/pci/changelog b/arch/i386/pci/changelog
--- a/arch/i386/pci/changelog	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,62 +0,0 @@
-/*
- * CHANGELOG :
- * Jun 17, 1994 : Modified to accommodate the broken pre-PCI BIOS SPECIFICATION
- *	Revision 2.0 present on <thys@dennis.ee.up.ac.za>'s ASUS mainboard.
- *
- * Jan 5,  1995 : Modified to probe PCI hardware at boot time by Frederic
- *     Potter, potter@cao-vlsi.ibp.fr
- *
- * Jan 10, 1995 : Modified to store the information about configured pci
- *      devices into a list, which can be accessed via /proc/pci by
- *      Curtis Varner, cvarner@cs.ucr.edu
- *
- * Jan 12, 1995 : CPU-PCI bridge optimization support by Frederic Potter.
- *	Alpha version. Intel & UMC chipset support only.
- *
- * Apr 16, 1995 : Source merge with the DEC Alpha PCI support. Most of the code
- *	moved to drivers/pci/pci.c.
- *
- * Dec 7, 1996  : Added support for direct configuration access of boards
- *      with Intel compatible access schemes (tsbogend@alpha.franken.de)
- *
- * Feb 3, 1997  : Set internal functions to static, save/restore flags
- *	avoid dead locks reading broken PCI BIOS, werner@suse.de 
- *
- * Apr 26, 1997 : Fixed case when there is BIOS32, but not PCI BIOS
- *	(mj@atrey.karlin.mff.cuni.cz)
- *
- * May 7,  1997 : Added some missing cli()'s. [mj]
- * 
- * Jun 20, 1997 : Corrected problems in "conf1" type accesses.
- *      (paubert@iram.es)
- *
- * Aug 2,  1997 : Split to PCI BIOS handling and direct PCI access parts
- *	and cleaned it up...     Martin Mares <mj@atrey.karlin.mff.cuni.cz>
- *
- * Feb 6,  1998 : No longer using BIOS to find devices and device classes. [mj]
- *
- * May 1,  1998 : Support for peer host bridges. [mj]
- *
- * Jun 19, 1998 : Changed to use spinlocks, so that PCI configuration space
- *	can be accessed from interrupts even on SMP systems. [mj]
- *
- * August  1998 : Better support for peer host bridges and more paranoid
- *	checks for direct hardware access. Ugh, this file starts to look as
- *	a large gallery of common hardware bug workarounds (watch the comments)
- *	-- the PCI specs themselves are sane, but most implementors should be
- *	hit hard with \hammer scaled \magstep5. [mj]
- *
- * Jan 23, 1999 : More improvements to peer host bridge logic. i450NX fixup. [mj]
- *
- * Feb 8,  1999 : Added UM8886BF I/O address fixup. [mj]
- *
- * August  1999 : New resource management and configuration access stuff. [mj]
- *
- * Sep 19, 1999 : Use PCI IRQ routing tables for detection of peer host bridges.
- *		  Based on ideas by Chris Frantz and David Hinds. [mj]
- *
- * Sep 28, 1999 : Handle unreported/unassigned IRQs. Thanks to Shuu Yamaguchi
- *		  for a lot of patience during testing. [mj]
- *
- * Oct  8, 1999 : Split to pci-i386.c, pci-pc.c and pci-visws.c. [mj]
- */
\ No newline at end of file
diff -Nru a/arch/i386/pci/common.c b/arch/i386/pci/common.c
--- a/arch/i386/pci/common.c	2004-12-24 13:36:48 -08:00
+++ b/arch/i386/pci/common.c	2004-12-24 13:36:48 -08:00
@@ -23,6 +23,7 @@
 unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
 				PCI_PROBE_MMCONF;
 
+int pci_routeirq;
 int pcibios_last_bus = -1;
 struct pci_bus *pci_root_bus = NULL;
 struct pci_raw_ops *raw_pci_ops;
@@ -226,6 +227,9 @@
 		return NULL;
 	} else if (!strcmp(str, "assign-busses")) {
 		pci_probe |= PCI_ASSIGN_ALL_BUSSES;
+		return NULL;
+	} else if (!strcmp(str, "routeirq")) {
+		pci_routeirq = 1;
 		return NULL;
 	}
 	return str;
diff -Nru a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
--- a/arch/i386/pci/fixup.c	2004-12-24 13:37:02 -08:00
+++ b/arch/i386/pci/fixup.c	2004-12-24 13:37:02 -08:00
@@ -255,3 +255,132 @@
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2, pci_fixup_nforce2);
 
+/* Max PCI Express root ports */
+#define MAX_PCIEROOT	6
+static int quirk_aspm_offset[MAX_PCIEROOT << 3];
+
+#define GET_INDEX(a, b) (((a - PCI_DEVICE_ID_INTEL_MCH_PA) << 3) + b)
+
+static int quirk_pcie_aspm_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
+{
+	return raw_pci_ops->read(0, bus->number, devfn, where, size, value);
+}
+
+/*
+ * Replace the original pci bus ops for write with a new one that will filter
+ * the request to insure ASPM cannot be enabled.
+ */
+static int quirk_pcie_aspm_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
+{
+	u8 offset;
+
+	offset = quirk_aspm_offset[GET_INDEX(bus->self->device, devfn)];
+
+	if ((offset) && (where == offset))
+		value = value & 0xfffffffc;
+	
+	return raw_pci_ops->write(0, bus->number, devfn, where, size, value);
+}
+
+struct pci_ops quirk_pcie_aspm_ops = {
+	.read = quirk_pcie_aspm_read,
+	.write = quirk_pcie_aspm_write,
+};
+
+/*
+ * Prevents PCI Express ASPM (Active State Power Management) being enabled.
+ *
+ * Save the register offset, where the ASPM control bits are located,
+ * for each PCI Express device that is in the device list of
+ * the root port in an array for fast indexing. Replace the bus ops
+ * with the modified one.
+ */
+void pcie_rootport_aspm_quirk(struct pci_dev *pdev)
+{
+	int cap_base, i;
+	struct pci_bus  *pbus;
+	struct pci_dev *dev;
+
+	if ((pbus = pdev->subordinate) == NULL)
+		return;
+
+	/*
+	 * Check if the DID of pdev matches one of the six root ports. This
+	 * check is needed in the case this function is called directly by the
+	 * hot-plug driver.
+	 */
+	if ((pdev->device < PCI_DEVICE_ID_INTEL_MCH_PA) ||
+	    (pdev->device > PCI_DEVICE_ID_INTEL_MCH_PC1))
+		return;
+
+	if (list_empty(&pbus->devices)) {
+		/*
+		 * If no device is attached to the root port at power-up or
+		 * after hot-remove, the pbus->devices is empty and this code
+		 * will set the offsets to zero and the bus ops to parent's bus
+		 * ops, which is unmodified.
+	 	 */
+		for (i= GET_INDEX(pdev->device, 0); i <= GET_INDEX(pdev->device, 7); ++i)
+			quirk_aspm_offset[i] = 0;
+
+		pbus->ops = pbus->parent->ops;
+	} else {
+		/*
+		 * If devices are attached to the root port at power-up or
+		 * after hot-add, the code loops through the device list of
+		 * each root port to save the register offsets and replace the
+		 * bus ops.
+		 */
+		list_for_each_entry(dev, &pbus->devices, bus_list) {
+			/* There are 0 to 8 devices attached to this bus */
+			cap_base = pci_find_capability(dev, PCI_CAP_ID_EXP);
+			quirk_aspm_offset[GET_INDEX(pdev->device, dev->devfn)]= cap_base + 0x10;
+		}
+		pbus->ops = &quirk_pcie_aspm_ops;
+	}
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_MCH_PA,	pcie_rootport_aspm_quirk );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_MCH_PA1,	pcie_rootport_aspm_quirk );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_MCH_PB,	pcie_rootport_aspm_quirk );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_MCH_PB1,	pcie_rootport_aspm_quirk );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_MCH_PC,	pcie_rootport_aspm_quirk );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_MCH_PC1,	pcie_rootport_aspm_quirk );
+
+/*
+ * Fixup to mark boot BIOS video selected by BIOS before it changes
+ *
+ * From information provided by "Jon Smirl" <jonsmirl@yahoo.com>
+ *
+ * The standard boot ROM sequence for an x86 machine uses the BIOS
+ * to select an initial video card for boot display. This boot video 
+ * card will have it's BIOS copied to C0000 in system RAM. 
+ * IORESOURCE_ROM_SHADOW is used to associate the boot video
+ * card with this copy. On laptops this copy has to be used since
+ * the main ROM may be compressed or combined with another image.
+ * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW
+ * is marked here since the boot video device will be the only enabled
+ * video device at this point.
+ *
+ */static void __devinit pci_fixup_video(struct pci_dev *pdev)
+{
+	struct pci_dev *bridge;
+	struct pci_bus *bus;
+	u16 l;
+
+	if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
+		return;
+
+	/* Is VGA routed to us? */
+	bus = pdev->bus;
+	while (bus) {
+		bridge = bus->self;
+		if (bridge) {
+			pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, &l);
+			if (!(l & PCI_BRIDGE_CTL_VGA))
+				return;
+		}
+		bus = bus->parent;
+	}
+	pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);
diff -Nru a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c
--- a/arch/i386/pci/i386.c	2004-12-24 13:36:31 -08:00
+++ b/arch/i386/pci/i386.c	2004-12-24 13:36:31 -08:00
@@ -96,15 +96,13 @@
 
 static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
 {
-	struct list_head *ln;
 	struct pci_bus *bus;
 	struct pci_dev *dev;
 	int idx;
 	struct resource *r, *pr;
 
 	/* Depth-First Search on bus tree */
-	for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
-		bus = pci_bus_b(ln);
+	list_for_each_entry(bus, bus_list, node) {
 		if ((dev = bus->self)) {
 			for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
 				r = &dev->resource[idx];
@@ -126,7 +124,7 @@
 	u16 command;
 	struct resource *r, *pr;
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
 		pci_read_config_word(dev, PCI_COMMAND, &command);
 		for(idx = 0; idx < 6; idx++) {
 			r = &dev->resource[idx];
@@ -170,7 +168,7 @@
 	int idx;
 	struct resource *r;
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
 		int class = dev->class >> 8;
 
 		/* Don't touch classless devices and host bridges */
@@ -297,7 +295,7 @@
 	/* Write-combine setting is ignored, it is changed via the mtrr
 	 * interfaces on this platform.
 	 */
-	if (remap_page_range(vma, vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+	if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot))
 		return -EAGAIN;
diff -Nru a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
--- a/arch/i386/pci/irq.c	2004-12-24 13:37:31 -08:00
+++ b/arch/i386/pci/irq.c	2004-12-24 13:37:31 -08:00
@@ -17,6 +17,7 @@
 #include <asm/smp.h>
 #include <asm/io_apic.h>
 #include <asm/hw_irq.h>
+#include <linux/acpi.h>
 
 #include "pci.h"
 
@@ -127,8 +128,15 @@
 {
 	unsigned char mask = 1 << (irq & 7);
 	unsigned int port = 0x4d0 + (irq >> 3);
-	unsigned char val = inb(port);
+	unsigned char val;
+	static u16 eisa_irq_mask;
 
+	if (irq >= 16 || (1 << irq) & eisa_irq_mask)
+		return;
+
+	eisa_irq_mask |= (1 << irq);
+	printk("PCI: setting IRQ %u as level-triggered\n", irq);
+	val = inb(port);
 	if (!(val & mask)) {
 		DBG(" -> edge");
 		outb(val | mask, port);
@@ -452,14 +460,16 @@
 
 #endif
 
-
 static __init int intel_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
 {
+	static struct pci_device_id pirq_440gx[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_0) },
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_2) },
+		{ },
+	};
+
 	/* 440GX has a proprietary PIRQ router -- don't use it */
-	if (	pci_find_device(PCI_VENDOR_ID_INTEL,
-				PCI_DEVICE_ID_INTEL_82443GX_0, NULL) ||
-		pci_find_device(PCI_VENDOR_ID_INTEL,
-				PCI_DEVICE_ID_INTEL_82443GX_2, NULL))
+	if (pci_dev_present(pirq_440gx))
 		return 0;
 
 	switch(device)
@@ -804,7 +814,7 @@
 	printk(KERN_INFO "PCI: %s IRQ %d for device %s\n", msg, irq, pci_name(dev));
 
 	/* Update IRQ for all devices with the same pirq value */
-	while ((dev2 = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) {
+	while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) {
 		pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin);
 		if (!pin)
 			continue;
@@ -838,7 +848,7 @@
 	u8 pin;
 
 	DBG("PCI: IRQ fixup\n");
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
 		/*
 		 * If the BIOS has set an out of range IRQ number, just ignore it.
 		 * Also keep track of which IRQ's are already in use.
@@ -854,7 +864,7 @@
 	}
 
 	dev = NULL;
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
 		pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
 #ifdef CONFIG_X86_IO_APIC
 		/*
@@ -989,13 +999,24 @@
 subsys_initcall(pcibios_irq_init);
 
 
-void pcibios_penalize_isa_irq(int irq)
+static void pirq_penalize_isa_irq(int irq)
 {
 	/*
 	 *  If any ISAPnP device reports an IRQ in its list of possible
 	 *  IRQ's, we try to avoid assigning it to PCI devices.
 	 */
-	pirq_penalty[irq] += 100;
+	if (irq < 16)
+		pirq_penalty[irq] += 100;
+}
+
+void pcibios_penalize_isa_irq(int irq)
+{
+#ifdef CONFIG_ACPI_PCI
+	if (!acpi_noirq)
+		acpi_penalize_isa_irq(irq);
+	else
+#endif
+		pirq_penalize_isa_irq(irq);
 }
 
 int pirq_enable_irq(struct pci_dev *dev)
diff -Nru a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
--- a/arch/i386/pci/mmconfig.c	2004-12-24 13:37:01 -08:00
+++ b/arch/i386/pci/mmconfig.c	2004-12-24 13:37:01 -08:00
@@ -30,7 +30,7 @@
 	u32 dev_base = pci_mmcfg_base_addr | (bus << 20) | (devfn << 12);
 	if (dev_base != mmcfg_last_accessed_device) {
 		mmcfg_last_accessed_device = dev_base;
-		set_fixmap(FIX_PCIE_MCFG, dev_base);
+		set_fixmap_nocache(FIX_PCIE_MCFG, dev_base);
 	}
 }
 
@@ -85,9 +85,6 @@
 		break;
 	}
 
-	/* Dummy read to flush PCI write */
-	readl(mmcfg_virt_addr);
-
 	spin_unlock_irqrestore(&pci_config_lock, flags);
 
 	return 0;
@@ -104,6 +101,13 @@
 		goto out;
 	if (!pci_mmcfg_base_addr)
 		goto out;
+
+	/* Kludge for now. Don't use mmconfig on AMD systems because
+	   those have some busses where mmconfig doesn't work,
+	   and we don't parse ACPI MCFG well enough to handle that. 
+	   Remove when proper handling is added. */
+	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+		goto out; 
 
 	printk(KERN_INFO "PCI: Using MMCONFIG\n");
 	raw_pci_ops = &pci_mmcfg;
diff -Nru a/arch/i386/power/cpu.c b/arch/i386/power/cpu.c
--- a/arch/i386/power/cpu.c	2004-12-24 13:37:18 -08:00
+++ b/arch/i386/power/cpu.c	2004-12-24 13:37:18 -08:00
@@ -148,6 +148,6 @@
 	__restore_processor_state(&saved_context);
 }
 
-
+/* Needed by apm.c */
 EXPORT_SYMBOL(save_processor_state);
 EXPORT_SYMBOL(restore_processor_state);
diff -Nru a/arch/ia64/Makefile b/arch/ia64/Makefile
--- a/arch/ia64/Makefile	2004-12-24 13:36:17 -08:00
+++ b/arch/ia64/Makefile	2004-12-24 13:36:17 -08:00
@@ -42,8 +42,7 @@
 endif
 
 ifeq ($(GCC_VERSION),0304)
-# Workaround Itanium 1 bugs in gcc 3.4.
-#	cflags-$(CONFIG_ITANIUM)	+= -mtune=merced
+	cflags-$(CONFIG_ITANIUM)	+= -mtune=merced
 	cflags-$(CONFIG_MCKINLEY)	+= -mtune=mckinley
 endif
 
@@ -83,7 +82,9 @@
 archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
 
-CLEAN_FILES += include/asm-ia64/.offsets.h.stamp include/asm-ia64/offsets.h vmlinux.gz bootloader
+CLEAN_FILES += include/asm-ia64/.offsets.h.stamp vmlinux.gz bootloader
+
+MRPROPER_FILES += include/asm-ia64/offsets.h
 
 prepare: include/asm-ia64/offsets.h
 
diff -Nru a/arch/ia64/configs/bigsur_defconfig b/arch/ia64/configs/bigsur_defconfig
--- a/arch/ia64/configs/bigsur_defconfig	2004-12-24 13:36:17 -08:00
+++ b/arch/ia64/configs/bigsur_defconfig	2004-12-24 13:36:17 -08:00
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-rc2
-# Tue Sep 28 13:26:53 2004
+# Linux kernel version: 2.6.10-rc2
+# Mon Nov 29 13:27:48 2004
 #
 
 #
@@ -9,6 +9,7 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
@@ -22,6 +23,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=16
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
@@ -29,12 +31,12 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_TINY_SHMEM is not set
 
 #
@@ -45,6 +47,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -84,6 +87,7 @@
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_IA32_SUPPORT=y
 CONFIG_COMPAT=y
+# CONFIG_IA64_MCA_RECOVERY is not set
 CONFIG_PERFMON=y
 CONFIG_IA64_PALINFO=y
 
@@ -107,9 +111,11 @@
 CONFIG_ACPI_BOOT=y
 CONFIG_ACPI_INTERPRETER=y
 CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
 CONFIG_ACPI_FAN=m
 CONFIG_ACPI_PROCESSOR=m
 CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_BLACKLIST_YEAR=0
 # CONFIG_ACPI_DEBUG is not set
 CONFIG_ACPI_BUS=y
 CONFIG_ACPI_POWER=y
@@ -131,9 +137,13 @@
 # CONFIG_HOTPLUG_PCI is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# PC-card bridges
 #
-# CONFIG_PCMCIA is not set
 
 #
 # Device Drivers
@@ -160,6 +170,7 @@
 #
 # Plug and Play support
 #
+# CONFIG_PNP is not set
 
 #
 # Block devices
@@ -175,6 +186,16 @@
 # CONFIG_BLK_DEV_UB is not set
 CONFIG_BLK_DEV_RAM=m
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -193,7 +214,6 @@
 CONFIG_BLK_DEV_IDEFLOPPY=m
 # CONFIG_BLK_DEV_IDESCSI is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -282,12 +302,14 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR is not set
 # CONFIG_SCSI_QLOGIC_ISP is not set
 # CONFIG_SCSI_QLOGIC_FC is not set
 CONFIG_SCSI_QLOGIC_1280=y
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
 # CONFIG_SCSI_QLA21XX is not set
 # CONFIG_SCSI_QLA22XX is not set
@@ -311,6 +333,7 @@
 CONFIG_MD_RAID5=m
 CONFIG_MD_RAID6=m
 CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
 CONFIG_BLK_DEV_DM=m
 CONFIG_DM_CRYPT=m
 CONFIG_DM_SNAPSHOT=m
@@ -357,6 +380,8 @@
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
 # CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -376,7 +401,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -437,7 +461,6 @@
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -450,6 +473,7 @@
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 # CONFIG_TIGON3 is not set
 
 #
@@ -549,7 +573,7 @@
 #
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_ACPI is not set
+CONFIG_SERIAL_8250_ACPI=y
 CONFIG_SERIAL_8250_NR_UARTS=4
 CONFIG_SERIAL_8250_EXTENDED=y
 CONFIG_SERIAL_8250_SHARE_IRQ=y
@@ -627,6 +651,7 @@
 # CONFIG_I2C_SIS5595 is not set
 # CONFIG_I2C_SIS630 is not set
 # CONFIG_I2C_SIS96X is not set
+# CONFIG_I2C_STUB is not set
 # CONFIG_I2C_VIA is not set
 # CONFIG_I2C_VIAPRO is not set
 # CONFIG_I2C_VOODOO3 is not set
@@ -644,14 +669,17 @@
 # CONFIG_SENSORS_FSCHER is not set
 # CONFIG_SENSORS_GL518SM is not set
 # CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM63 is not set
 # CONFIG_SENSORS_LM75 is not set
 # CONFIG_SENSORS_LM77 is not set
 # CONFIG_SENSORS_LM78 is not set
 # CONFIG_SENSORS_LM80 is not set
 # CONFIG_SENSORS_LM83 is not set
 # CONFIG_SENSORS_LM85 is not set
+# CONFIG_SENSORS_LM87 is not set
 # CONFIG_SENSORS_LM90 is not set
 # CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_PC87360 is not set
 # CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_VIA686A is not set
 # CONFIG_SENSORS_W83781D is not set
@@ -773,7 +801,7 @@
 # CONFIG_SND_VX222 is not set
 
 #
-# ALSA USB devices
+# USB devices
 #
 # CONFIG_SND_USB_AUDIO is not set
 # CONFIG_SND_USB_USX2Y is not set
@@ -797,6 +825,8 @@
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_SUSPEND is not set
 # CONFIG_USB_OTG is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Host Controller Drivers
@@ -826,7 +856,7 @@
 # CONFIG_USB_STORAGE_JUMPSHOT is not set
 
 #
-# USB Human Interface Devices (HID)
+# USB Input Devices
 #
 CONFIG_USB_HID=m
 CONFIG_USB_HIDINPUT=y
@@ -864,7 +894,7 @@
 #
 
 #
-# USB Network adaptors
+# USB Network Adapters
 #
 # CONFIG_USB_CATC is not set
 # CONFIG_USB_KAWETH is not set
@@ -893,10 +923,15 @@
 # CONFIG_USB_LCD is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
 # CONFIG_USB_PHIDGETSERVO is not set
 # CONFIG_USB_TEST is not set
 
 #
+# USB ATM/DSL drivers
+#
+
+#
 # USB Gadget Support
 #
 # CONFIG_USB_GADGET is not set
@@ -925,6 +960,7 @@
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
 CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -957,6 +993,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 CONFIG_HUGETLBFS=y
 CONFIG_HUGETLB_PAGE=y
 CONFIG_RAMFS=y
@@ -1087,9 +1124,11 @@
 #
 CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
 # CONFIG_DEBUG_INFO is not set
 # CONFIG_IA64_GRANULE_16MB is not set
 CONFIG_IA64_GRANULE_64MB=y
@@ -1102,6 +1141,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
@@ -1115,7 +1155,7 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
-# CONFIG_CRYPTO_WHIRLPOOL is not set
+# CONFIG_CRYPTO_WP512 is not set
 CONFIG_CRYPTO_DES=y
 # CONFIG_CRYPTO_BLOWFISH is not set
 # CONFIG_CRYPTO_TWOFISH is not set
@@ -1126,6 +1166,7 @@
 # CONFIG_CRYPTO_TEA is not set
 # CONFIG_CRYPTO_ARC4 is not set
 # CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_ANUBIS is not set
 # CONFIG_CRYPTO_DEFLATE is not set
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
 # CONFIG_CRYPTO_CRC32C is not set
diff -Nru a/arch/ia64/configs/generic_defconfig b/arch/ia64/configs/generic_defconfig
--- a/arch/ia64/configs/generic_defconfig	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1123 +0,0 @@
-#
-# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-rc1
-# Tue Aug 24 15:08:24 2004
-#
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-CONFIG_POSIX_MQUEUE=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=20
-CONFIG_HOTPLUG=y
-CONFIG_IKCONFIG=y
-CONFIG_IKCONFIG_PROC=y
-# CONFIG_EMBEDDED is not set
-CONFIG_KALLSYMS=y
-CONFIG_KALLSYMS_ALL=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-CONFIG_STOP_MACHINE=y
-
-#
-# Processor type and features
-#
-CONFIG_IA64=y
-CONFIG_64BIT=y
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_TIME_INTERPOLATION=y
-CONFIG_EFI=y
-CONFIG_IA64_GENERIC=y
-# CONFIG_IA64_DIG is not set
-# CONFIG_IA64_HP_ZX1 is not set
-# CONFIG_IA64_SGI_SN2 is not set
-# CONFIG_IA64_HP_SIM is not set
-# CONFIG_ITANIUM is not set
-CONFIG_MCKINLEY=y
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-CONFIG_IA64_PAGE_SIZE_16KB=y
-# CONFIG_IA64_PAGE_SIZE_64KB is not set
-CONFIG_IA64_L1_CACHE_SHIFT=7
-CONFIG_NUMA=y
-CONFIG_VIRTUAL_MEM_MAP=y
-CONFIG_DISCONTIGMEM=y
-CONFIG_IA64_CYCLONE=y
-CONFIG_IOSAPIC=y
-CONFIG_FORCE_MAX_ZONEORDER=18
-CONFIG_SMP=y
-CONFIG_NR_CPUS=512
-CONFIG_HOTPLUG_CPU=y
-# CONFIG_PREEMPT is not set
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_IA32_SUPPORT=y
-CONFIG_COMPAT=y
-CONFIG_PERFMON=y
-CONFIG_IA64_PALINFO=y
-
-#
-# Firmware Drivers
-#
-CONFIG_EFI_VARS=y
-CONFIG_EFI_PCDP=y
-CONFIG_BINFMT_ELF=y
-CONFIG_BINFMT_MISC=m
-
-#
-# Power management and ACPI
-#
-CONFIG_PM=y
-CONFIG_ACPI=y
-
-#
-# ACPI (Advanced Configuration and Power Interface) Support
-#
-CONFIG_ACPI_BOOT=y
-CONFIG_ACPI_INTERPRETER=y
-CONFIG_ACPI_BUTTON=m
-CONFIG_ACPI_FAN=m
-CONFIG_ACPI_PROCESSOR=m
-CONFIG_ACPI_THERMAL=m
-CONFIG_ACPI_NUMA=y
-# CONFIG_ACPI_DEBUG is not set
-CONFIG_ACPI_BUS=y
-CONFIG_ACPI_POWER=y
-CONFIG_ACPI_PCI=y
-CONFIG_ACPI_SYSTEM=y
-
-#
-# Bus options (PCI, PCMCIA)
-#
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-# CONFIG_PCI_MSI is not set
-CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
-
-#
-# PCI Hotplug Support
-#
-CONFIG_HOTPLUG_PCI=m
-# CONFIG_HOTPLUG_PCI_FAKE is not set
-CONFIG_HOTPLUG_PCI_ACPI=m
-# CONFIG_HOTPLUG_PCI_ACPI_IBM is not set
-# CONFIG_HOTPLUG_PCI_CPCI is not set
-# CONFIG_HOTPLUG_PCI_PCIE is not set
-# CONFIG_HOTPLUG_PCI_SHPC is not set
-
-#
-# PCMCIA/CardBus support
-#
-# CONFIG_PCMCIA is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_STANDALONE=y
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
-# CONFIG_DEBUG_DRIVER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# 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_UMEM is not set
-CONFIG_BLK_DEV_LOOP=m
-CONFIG_BLK_DEV_CRYPTOLOOP=m
-CONFIG_BLK_DEV_NBD=m
-# CONFIG_BLK_DEV_SX8 is not set
-# CONFIG_BLK_DEV_UB is not set
-CONFIG_BLK_DEV_RAM=m
-CONFIG_BLK_DEV_RAM_SIZE=4096
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_IDE_SATA is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECD=y
-# CONFIG_BLK_DEV_IDETAPE is not set
-CONFIG_BLK_DEV_IDEFLOPPY=y
-CONFIG_BLK_DEV_IDESCSI=m
-# CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
-
-#
-# IDE chipset support/bugfixes
-#
-CONFIG_IDE_GENERIC=y
-CONFIG_BLK_DEV_IDEPCI=y
-# CONFIG_IDEPCI_SHARE_IRQ is not set
-# CONFIG_BLK_DEV_OFFBOARD is not set
-CONFIG_BLK_DEV_GENERIC=y
-# CONFIG_BLK_DEV_OPTI621 is not set
-CONFIG_BLK_DEV_IDEDMA_PCI=y
-# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
-CONFIG_IDEDMA_PCI_AUTO=y
-# CONFIG_IDEDMA_ONLYDISK is not set
-CONFIG_BLK_DEV_ADMA=y
-# CONFIG_BLK_DEV_AEC62XX is not set
-# CONFIG_BLK_DEV_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD74XX is not set
-CONFIG_BLK_DEV_CMD64X=y
-# CONFIG_BLK_DEV_TRIFLEX is not set
-# CONFIG_BLK_DEV_CY82C693 is not set
-# CONFIG_BLK_DEV_CS5520 is not set
-# CONFIG_BLK_DEV_CS5530 is not set
-# CONFIG_BLK_DEV_HPT34X is not set
-# CONFIG_BLK_DEV_HPT366 is not set
-# CONFIG_BLK_DEV_SC1200 is not set
-CONFIG_BLK_DEV_PIIX=y
-# CONFIG_BLK_DEV_NS87415 is not set
-# CONFIG_BLK_DEV_PDC202XX_OLD is not set
-# CONFIG_BLK_DEV_PDC202XX_NEW is not set
-# CONFIG_BLK_DEV_SVWKS is not set
-CONFIG_BLK_DEV_SGIIOC4=y
-# CONFIG_BLK_DEV_SIIMAGE is not set
-# CONFIG_BLK_DEV_SLC90E66 is not set
-# CONFIG_BLK_DEV_TRM290 is not set
-# CONFIG_BLK_DEV_VIA82CXXX is not set
-# CONFIG_IDE_ARM is not set
-CONFIG_BLK_DEV_IDEDMA=y
-# CONFIG_IDEDMA_IVB is not set
-CONFIG_IDEDMA_AUTO=y
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI device support
-#
-CONFIG_SCSI=y
-CONFIG_SCSI_PROC_FS=y
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=y
-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_CHR_DEV_SG=m
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-# CONFIG_SCSI_MULTI_LUN is not set
-# CONFIG_SCSI_CONSTANTS is not set
-# CONFIG_SCSI_LOGGING is not set
-
-#
-# SCSI Transport Attributes
-#
-CONFIG_SCSI_SPI_ATTRS=y
-CONFIG_SCSI_FC_ATTRS=y
-
-#
-# SCSI low-level drivers
-#
-# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
-# CONFIG_SCSI_3W_9XXX is not set
-# CONFIG_SCSI_ACARD is not set
-# CONFIG_SCSI_AACRAID is not set
-# CONFIG_SCSI_AIC7XXX is not set
-# CONFIG_SCSI_AIC7XXX_OLD is not set
-# CONFIG_SCSI_AIC79XX is not set
-# CONFIG_SCSI_MEGARAID is not set
-# CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_BUSLOGIC is not set
-# CONFIG_SCSI_DMX3191D is not set
-# CONFIG_SCSI_EATA 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_IPS is not set
-# CONFIG_SCSI_INIA100 is not set
-CONFIG_SCSI_SYM53C8XX_2=y
-CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
-CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
-CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
-# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
-# CONFIG_SCSI_IPR is not set
-# CONFIG_SCSI_QLOGIC_ISP is not set
-CONFIG_SCSI_QLOGIC_FC=y
-# CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set
-CONFIG_SCSI_QLOGIC_1280=y
-CONFIG_SCSI_QLA2XXX=y
-CONFIG_SCSI_QLA21XX=m
-CONFIG_SCSI_QLA22XX=m
-CONFIG_SCSI_QLA2300=m
-CONFIG_SCSI_QLA2322=m
-# CONFIG_SCSI_QLA6312 is not set
-# CONFIG_SCSI_QLA6322 is not set
-# CONFIG_SCSI_DC395x is not set
-# CONFIG_SCSI_DC390T is not set
-# CONFIG_SCSI_DEBUG is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-CONFIG_MD=y
-CONFIG_BLK_DEV_MD=m
-CONFIG_MD_LINEAR=m
-CONFIG_MD_RAID0=m
-CONFIG_MD_RAID1=m
-# CONFIG_MD_RAID10 is not set
-CONFIG_MD_RAID5=m
-CONFIG_MD_RAID6=m
-CONFIG_MD_MULTIPATH=m
-CONFIG_BLK_DEV_DM=m
-CONFIG_DM_CRYPT=m
-CONFIG_DM_SNAPSHOT=m
-CONFIG_DM_MIRROR=m
-CONFIG_DM_ZERO=m
-
-#
-# Fusion MPT device support
-#
-CONFIG_FUSION=y
-CONFIG_FUSION_MAX_SGE=40
-# CONFIG_FUSION_ISENSE is not set
-# CONFIG_FUSION_CTL is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-# CONFIG_NET_KEY 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 is not set
-CONFIG_ARPD=y
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETPOLL=y
-# CONFIG_NETPOLL_RX is not set
-# CONFIG_NETPOLL_TRAP is not set
-CONFIG_NET_POLL_CONTROLLER=y
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-CONFIG_DUMMY=m
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=m
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-CONFIG_NET_TULIP=y
-# CONFIG_DE2104X is not set
-CONFIG_TULIP=m
-# CONFIG_TULIP_MWI is not set
-# CONFIG_TULIP_MMIO is not set
-# CONFIG_TULIP_NAPI is not set
-# CONFIG_DE4X5 is not set
-# CONFIG_WINBOND_840 is not set
-# CONFIG_DM9102 is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=m
-# CONFIG_EEPRO100_PIO is not set
-CONFIG_E100=m
-# CONFIG_E100_NAPI is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-CONFIG_E1000=m
-# CONFIG_E1000_NAPI is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-CONFIG_TIGON3=y
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_NET_FC is not set
-# CONFIG_SHAPER is not set
-CONFIG_NETCONSOLE=y
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-CONFIG_GAMEPORT=m
-CONFIG_SOUND_GAMEPORT=m
-# CONFIG_GAMEPORT_NS558 is not set
-# CONFIG_GAMEPORT_L4 is not set
-# CONFIG_GAMEPORT_EMU10K1 is not set
-# CONFIG_GAMEPORT_VORTEX is not set
-# CONFIG_GAMEPORT_FM801 is not set
-# CONFIG_GAMEPORT_CS461x is not set
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-
-#
-# Input Device Drivers
-#
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-CONFIG_INPUT_MOUSE=y
-CONFIG_MOUSE_PS2=y
-# CONFIG_MOUSE_SERIAL is not set
-# CONFIG_MOUSE_VSXXXAA is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-CONFIG_SERIAL_NONSTANDARD=y
-# CONFIG_ROCKETPORT is not set
-# CONFIG_CYCLADES is not set
-# CONFIG_SYNCLINK is not set
-# CONFIG_SYNCLINKMP is not set
-# CONFIG_N_HDLC is not set
-# CONFIG_STALDRV is not set
-CONFIG_SGI_SNSC=y
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_ACPI=y
-CONFIG_SERIAL_8250_NR_UARTS=6
-CONFIG_SERIAL_8250_EXTENDED=y
-CONFIG_SERIAL_8250_SHARE_IRQ=y
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_MULTIPORT is not set
-# CONFIG_SERIAL_8250_RSA is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_SERIAL_SGI_L1_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_HW_RANDOM is not set
-CONFIG_EFI_RTC=y
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-CONFIG_AGP=m
-CONFIG_AGP_I460=m
-CONFIG_AGP_HP_ZX1=m
-CONFIG_DRM=y
-CONFIG_DRM_TDFX=m
-CONFIG_DRM_GAMMA=m
-CONFIG_DRM_R128=m
-CONFIG_DRM_RADEON=m
-CONFIG_DRM_MGA=m
-CONFIG_DRM_SIS=m
-CONFIG_RAW_DRIVER=m
-CONFIG_HPET=y
-# CONFIG_HPET_RTC_IRQ is not set
-CONFIG_HPET_MMAP=y
-CONFIG_MAX_RAW_DEVS=256
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Dallas's 1-wire bus
-#
-# CONFIG_W1 is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Console display driver support
-#
-CONFIG_VGA_CONSOLE=y
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-CONFIG_SOUND=m
-
-#
-# Advanced Linux Sound Architecture
-#
-CONFIG_SND=m
-CONFIG_SND_TIMER=m
-CONFIG_SND_PCM=m
-CONFIG_SND_HWDEP=m
-CONFIG_SND_RAWMIDI=m
-CONFIG_SND_SEQUENCER=m
-CONFIG_SND_SEQ_DUMMY=m
-CONFIG_SND_OSSEMUL=y
-CONFIG_SND_MIXER_OSS=m
-CONFIG_SND_PCM_OSS=m
-CONFIG_SND_SEQUENCER_OSS=y
-CONFIG_SND_VERBOSE_PRINTK=y
-# CONFIG_SND_DEBUG is not set
-
-#
-# Generic devices
-#
-CONFIG_SND_MPU401_UART=m
-CONFIG_SND_OPL3_LIB=m
-CONFIG_SND_DUMMY=m
-CONFIG_SND_VIRMIDI=m
-CONFIG_SND_MTPAV=m
-CONFIG_SND_SERIAL_U16550=m
-CONFIG_SND_MPU401=m
-
-#
-# PCI devices
-#
-CONFIG_SND_AC97_CODEC=m
-# CONFIG_SND_ALI5451 is not set
-# CONFIG_SND_ATIIXP is not set
-# CONFIG_SND_AU8810 is not set
-# CONFIG_SND_AU8820 is not set
-# CONFIG_SND_AU8830 is not set
-# CONFIG_SND_AZT3328 is not set
-# CONFIG_SND_BT87X is not set
-CONFIG_SND_CS46XX=m
-CONFIG_SND_CS46XX_NEW_DSP=y
-CONFIG_SND_CS4281=m
-CONFIG_SND_EMU10K1=m
-# CONFIG_SND_KORG1212 is not set
-# CONFIG_SND_MIXART is not set
-# CONFIG_SND_NM256 is not set
-# CONFIG_SND_RME32 is not set
-# CONFIG_SND_RME96 is not set
-# CONFIG_SND_RME9652 is not set
-# CONFIG_SND_HDSP is not set
-# CONFIG_SND_TRIDENT is not set
-# CONFIG_SND_YMFPCI is not set
-# CONFIG_SND_ALS4000 is not set
-# CONFIG_SND_CMIPCI is not set
-# CONFIG_SND_ENS1370 is not set
-# CONFIG_SND_ENS1371 is not set
-# CONFIG_SND_ES1938 is not set
-# CONFIG_SND_ES1968 is not set
-# CONFIG_SND_MAESTRO3 is not set
-CONFIG_SND_FM801=m
-# CONFIG_SND_FM801_TEA575X is not set
-# CONFIG_SND_ICE1712 is not set
-# CONFIG_SND_ICE1724 is not set
-# CONFIG_SND_INTEL8X0 is not set
-# CONFIG_SND_INTEL8X0M is not set
-# CONFIG_SND_SONICVIBES is not set
-# CONFIG_SND_VIA82XX is not set
-# CONFIG_SND_VX222 is not set
-
-#
-# ALSA USB devices
-#
-# CONFIG_SND_USB_AUDIO is not set
-
-#
-# Open Sound System
-#
-# CONFIG_SOUND_PRIME is not set
-
-#
-# USB support
-#
-CONFIG_USB=m
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-# CONFIG_USB_DYNAMIC_MINORS is not set
-# CONFIG_USB_SUSPEND is not set
-
-#
-# USB Host Controller Drivers
-#
-CONFIG_USB_EHCI_HCD=m
-# CONFIG_USB_EHCI_SPLIT_ISO is not set
-# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
-CONFIG_USB_OHCI_HCD=m
-CONFIG_USB_UHCI_HCD=m
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH_TTY is not set
-# CONFIG_USB_MIDI is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-CONFIG_USB_STORAGE=m
-# CONFIG_USB_STORAGE_DEBUG is not set
-# CONFIG_USB_STORAGE_RW_DETECT is not set
-# CONFIG_USB_STORAGE_DATAFAB 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_STORAGE_HP8200e is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_SDDR55 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT is not set
-
-#
-# USB Human Interface Devices (HID)
-#
-CONFIG_USB_HID=m
-CONFIG_USB_HIDINPUT=y
-# CONFIG_HID_FF is not set
-# CONFIG_USB_HIDDEV is not set
-
-#
-# USB HID Boot Protocol drivers
-#
-# CONFIG_USB_KBD is not set
-# CONFIG_USB_MOUSE is not set
-# CONFIG_USB_AIPTEK is not set
-# CONFIG_USB_WACOM is not set
-# CONFIG_USB_KBTAB is not set
-# CONFIG_USB_POWERMATE is not set
-# CONFIG_USB_MTOUCH is not set
-# CONFIG_USB_EGALAX is not set
-# CONFIG_USB_XPAD is not set
-# CONFIG_USB_ATI_REMOTE is not set
-
-#
-# USB Imaging devices
-#
-# CONFIG_USB_MDC800 is not set
-# CONFIG_USB_MICROTEK is not set
-# CONFIG_USB_HPUSBSCSI is not set
-
-#
-# USB Multimedia devices
-#
-# CONFIG_USB_DABUSB is not set
-
-#
-# Video4Linux support is needed for USB Multimedia device support
-#
-
-#
-# USB Network adaptors
-#
-# CONFIG_USB_CATC is not set
-# CONFIG_USB_KAWETH is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_RTL8150 is not set
-# CONFIG_USB_USBNET is not set
-
-#
-# USB port drivers
-#
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_EMI62 is not set
-# CONFIG_USB_EMI26 is not set
-# CONFIG_USB_TIGL is not set
-# CONFIG_USB_AUERSWALD is not set
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_LEGOTOWER is not set
-# CONFIG_USB_LCD is not set
-# CONFIG_USB_LED is not set
-# CONFIG_USB_CYTHERM is not set
-# CONFIG_USB_PHIDGETSERVO is not set
-# CONFIG_USB_TEST is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-CONFIG_EXT2_FS_SECURITY=y
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-CONFIG_EXT3_FS_SECURITY=y
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-# CONFIG_REISERFS_FS_XATTR is not set
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-CONFIG_XFS_FS=y
-# CONFIG_XFS_RT is not set
-# CONFIG_XFS_QUOTA is not set
-# CONFIG_XFS_SECURITY is not set
-# CONFIG_XFS_POSIX_ACL is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=y
-CONFIG_AUTOFS4_FS=y
-
-#
-# CD-ROM/DVD Filesystems
-#
-CONFIG_ISO9660_FS=m
-CONFIG_JOLIET=y
-# CONFIG_ZISOFS is not set
-CONFIG_UDF_FS=m
-CONFIG_UDF_NLS=y
-
-#
-# DOS/FAT/NT Filesystems
-#
-CONFIG_FAT_FS=y
-# CONFIG_MSDOS_FS is not set
-CONFIG_VFAT_FS=y
-CONFIG_FAT_DEFAULT_CODEPAGE=437
-CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
-CONFIG_NTFS_FS=m
-# CONFIG_NTFS_DEBUG is not set
-# CONFIG_NTFS_RW is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_HUGETLBFS=y
-CONFIG_HUGETLB_PAGE=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=m
-CONFIG_NFS_V3=y
-CONFIG_NFS_V4=y
-CONFIG_NFS_DIRECTIO=y
-CONFIG_NFSD=m
-CONFIG_NFSD_V3=y
-CONFIG_NFSD_V4=y
-CONFIG_NFSD_TCP=y
-CONFIG_LOCKD=m
-CONFIG_LOCKD_V4=y
-CONFIG_EXPORTFS=m
-CONFIG_SUNRPC=m
-CONFIG_SUNRPC_GSS=m
-CONFIG_RPCSEC_GSS_KRB5=m
-# CONFIG_RPCSEC_GSS_SPKM3 is not set
-CONFIG_SMB_FS=m
-CONFIG_SMB_NLS_DEFAULT=y
-CONFIG_SMB_NLS_REMOTE="cp437"
-CONFIG_CIFS=m
-# CONFIG_CIFS_STATS is not set
-# CONFIG_CIFS_XATTR is not set
-# CONFIG_CIFS_POSIX is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS 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_EFI_PARTITION=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS=y
-CONFIG_NLS_DEFAULT="iso8859-1"
-CONFIG_NLS_CODEPAGE_437=y
-CONFIG_NLS_CODEPAGE_737=m
-CONFIG_NLS_CODEPAGE_775=m
-CONFIG_NLS_CODEPAGE_850=m
-CONFIG_NLS_CODEPAGE_852=m
-CONFIG_NLS_CODEPAGE_855=m
-CONFIG_NLS_CODEPAGE_857=m
-CONFIG_NLS_CODEPAGE_860=m
-CONFIG_NLS_CODEPAGE_861=m
-CONFIG_NLS_CODEPAGE_862=m
-CONFIG_NLS_CODEPAGE_863=m
-CONFIG_NLS_CODEPAGE_864=m
-CONFIG_NLS_CODEPAGE_865=m
-CONFIG_NLS_CODEPAGE_866=m
-CONFIG_NLS_CODEPAGE_869=m
-CONFIG_NLS_CODEPAGE_936=m
-CONFIG_NLS_CODEPAGE_950=m
-CONFIG_NLS_CODEPAGE_932=m
-CONFIG_NLS_CODEPAGE_949=m
-CONFIG_NLS_CODEPAGE_874=m
-CONFIG_NLS_ISO8859_8=m
-CONFIG_NLS_CODEPAGE_1250=m
-CONFIG_NLS_CODEPAGE_1251=m
-# CONFIG_NLS_ASCII is not set
-CONFIG_NLS_ISO8859_1=y
-CONFIG_NLS_ISO8859_2=m
-CONFIG_NLS_ISO8859_3=m
-CONFIG_NLS_ISO8859_4=m
-CONFIG_NLS_ISO8859_5=m
-CONFIG_NLS_ISO8859_6=m
-CONFIG_NLS_ISO8859_7=m
-CONFIG_NLS_ISO8859_9=m
-CONFIG_NLS_ISO8859_13=m
-CONFIG_NLS_ISO8859_14=m
-CONFIG_NLS_ISO8859_15=m
-CONFIG_NLS_KOI8_R=m
-CONFIG_NLS_KOI8_U=m
-CONFIG_NLS_UTF8=m
-
-#
-# Library routines
-#
-# CONFIG_CRC_CCITT is not set
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-
-#
-# HP Simulator drivers
-#
-# CONFIG_HP_SIMETH is not set
-# CONFIG_HP_SIMSERIAL is not set
-# CONFIG_HP_SIMSCSI is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Kernel hacking
-#
-CONFIG_DEBUG_KERNEL=y
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_DEBUG_INFO is not set
-CONFIG_IA64_GRANULE_16MB=y
-# CONFIG_IA64_GRANULE_64MB is not set
-# CONFIG_IA64_PRINT_HAZARDS is not set
-# CONFIG_DISABLE_VHPT is not set
-# CONFIG_IA64_DEBUG_CMPXCHG is not set
-# CONFIG_IA64_DEBUG_IRQ is not set
-CONFIG_SYSVIPC_COMPAT=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-# CONFIG_CRYPTO_HMAC is not set
-# CONFIG_CRYPTO_NULL is not set
-# CONFIG_CRYPTO_MD4 is not set
-CONFIG_CRYPTO_MD5=m
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-# CONFIG_CRYPTO_SHA512 is not set
-CONFIG_CRYPTO_DES=m
-# CONFIG_CRYPTO_BLOWFISH is not set
-# CONFIG_CRYPTO_TWOFISH is not set
-# CONFIG_CRYPTO_SERPENT is not set
-# CONFIG_CRYPTO_AES is not set
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_TEA is not set
-# CONFIG_CRYPTO_ARC4 is not set
-# CONFIG_CRYPTO_KHAZAD is not set
-# CONFIG_CRYPTO_DEFLATE is not set
-# CONFIG_CRYPTO_MICHAEL_MIC is not set
-# CONFIG_CRYPTO_CRC32C is not set
-# CONFIG_CRYPTO_TEST is not set
diff -Nru a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig
--- a/arch/ia64/configs/sn2_defconfig	2004-12-24 13:36:17 -08:00
+++ b/arch/ia64/configs/sn2_defconfig	2004-12-24 13:36:17 -08:00
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-rc2
-# Fri Sep 24 08:59:00 2004
+# Linux kernel version: 2.6.10-rc1
+# Mon Nov  1 14:35:44 2004
 #
 
 #
@@ -9,6 +9,7 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
@@ -22,6 +23,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=20
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
@@ -29,12 +31,12 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_TINY_SHMEM is not set
 
 #
@@ -45,6 +47,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -84,6 +87,7 @@
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_IA32_SUPPORT=y
 CONFIG_COMPAT=y
+CONFIG_IA64_MCA_RECOVERY=y
 CONFIG_PERFMON=y
 CONFIG_IA64_PALINFO=y
 
@@ -109,6 +113,7 @@
 # CONFIG_ACPI_FAN is not set
 # CONFIG_ACPI_PROCESSOR is not set
 CONFIG_ACPI_NUMA=y
+CONFIG_ACPI_BLACKLIST_YEAR=0
 # CONFIG_ACPI_DEBUG is not set
 CONFIG_ACPI_BUS=y
 CONFIG_ACPI_POWER=y
@@ -136,9 +141,13 @@
 CONFIG_HOTPLUG_PCI_SGI=y
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# PC-card bridges
 #
-# CONFIG_PCMCIA is not set
 
 #
 # Device Drivers
@@ -181,6 +190,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -199,7 +218,6 @@
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_BLK_DEV_IDESCSI is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -283,6 +301,7 @@
 # CONFIG_MEGARAID_NEWGEN is not set
 # CONFIG_MEGARAID_LEGACY is not set
 CONFIG_SCSI_SATA=y
+# CONFIG_SCSI_SATA_AHCI is not set
 # CONFIG_SCSI_SATA_SVW is not set
 # CONFIG_SCSI_ATA_PIIX is not set
 # CONFIG_SCSI_SATA_NV is not set
@@ -290,6 +309,7 @@
 # CONFIG_SCSI_SATA_SX4 is not set
 # CONFIG_SCSI_SATA_SIL is not set
 # CONFIG_SCSI_SATA_SIS is not set
+# CONFIG_SCSI_SATA_ULI is not set
 # CONFIG_SCSI_SATA_VIA is not set
 CONFIG_SCSI_SATA_VITESSE=y
 # CONFIG_SCSI_BUSLOGIC is not set
@@ -299,12 +319,14 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR is not set
 # CONFIG_SCSI_QLOGIC_ISP is not set
 # CONFIG_SCSI_QLOGIC_FC is not set
 CONFIG_SCSI_QLOGIC_1280=y
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
 # CONFIG_SCSI_QLA21XX is not set
 CONFIG_SCSI_QLA22XX=y
@@ -402,7 +424,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -632,6 +653,8 @@
 # CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_OTG is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Host Controller Drivers
@@ -651,7 +674,7 @@
 # CONFIG_USB_STORAGE is not set
 
 #
-# USB Human Interface Devices (HID)
+# USB Input Devices
 #
 CONFIG_USB_HID=m
 CONFIG_USB_HIDINPUT=y
@@ -718,9 +741,14 @@
 # CONFIG_USB_LCD is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
 # CONFIG_USB_PHIDGETSERVO is not set
 
 #
+# USB ATM/DSL drivers
+#
+
+#
 # USB Gadget Support
 #
 # CONFIG_USB_GADGET is not set
@@ -758,6 +786,7 @@
 # CONFIG_QFMT_V1 is not set
 # CONFIG_QFMT_V2 is not set
 CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -789,6 +818,8 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+CONFIG_TMPFS_XATTR=y
+CONFIG_TMPFS_SECURITY=y
 CONFIG_HUGETLBFS=y
 CONFIG_HUGETLB_PAGE=y
 CONFIG_RAMFS=y
@@ -921,9 +952,11 @@
 #
 CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_INFO=y
 CONFIG_IA64_GRANULE_16MB=y
 # CONFIG_IA64_GRANULE_64MB is not set
@@ -936,6 +969,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
@@ -949,7 +983,7 @@
 CONFIG_CRYPTO_SHA1=m
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
-# CONFIG_CRYPTO_WHIRLPOOL is not set
+# CONFIG_CRYPTO_WP512 is not set
 CONFIG_CRYPTO_DES=m
 # CONFIG_CRYPTO_BLOWFISH is not set
 # CONFIG_CRYPTO_TWOFISH is not set
diff -Nru a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig
--- a/arch/ia64/configs/tiger_defconfig	2004-12-24 13:36:17 -08:00
+++ b/arch/ia64/configs/tiger_defconfig	2004-12-24 13:36:17 -08:00
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-rc2
-# Tue Sep 28 09:03:25 2004
+# Linux kernel version: 2.6.10-rc1
+# Tue Nov  2 11:35:10 2004
 #
 
 #
@@ -9,6 +9,7 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
@@ -22,6 +23,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=20
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_EMBEDDED is not set
@@ -30,12 +32,12 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_TINY_SHMEM is not set
 
 #
@@ -46,6 +48,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -83,6 +86,7 @@
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_IA32_SUPPORT=y
 CONFIG_COMPAT=y
+CONFIG_IA64_MCA_RECOVERY=y
 CONFIG_PERFMON=y
 CONFIG_IA64_PALINFO=y
 
@@ -109,6 +113,7 @@
 CONFIG_ACPI_FAN=m
 CONFIG_ACPI_PROCESSOR=m
 CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_BLACKLIST_YEAR=0
 # CONFIG_ACPI_DEBUG is not set
 CONFIG_ACPI_BUS=y
 CONFIG_ACPI_POWER=y
@@ -136,9 +141,13 @@
 # CONFIG_HOTPLUG_PCI_SHPC is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# PC-card bridges
 #
-# CONFIG_PCMCIA is not set
 
 #
 # Device Drivers
@@ -180,6 +189,16 @@
 # CONFIG_BLK_DEV_UB is not set
 CONFIG_BLK_DEV_RAM=m
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -198,7 +217,6 @@
 CONFIG_BLK_DEV_IDEFLOPPY=y
 CONFIG_BLK_DEV_IDESCSI=m
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -288,6 +306,7 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 CONFIG_SCSI_SYM53C8XX_2=y
 CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
@@ -299,6 +318,7 @@
 CONFIG_SCSI_QLOGIC_FC=y
 # CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set
 CONFIG_SCSI_QLOGIC_1280=y
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
 CONFIG_SCSI_QLA21XX=m
 CONFIG_SCSI_QLA22XX=m
@@ -371,6 +391,7 @@
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
 # CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -390,7 +411,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -463,7 +483,6 @@
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -477,6 +496,7 @@
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 CONFIG_TIGON3=y
 
 #
@@ -691,6 +711,8 @@
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_SUSPEND is not set
 # CONFIG_USB_OTG is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Host Controller Drivers
@@ -720,7 +742,7 @@
 # CONFIG_USB_STORAGE_JUMPSHOT is not set
 
 #
-# USB Human Interface Devices (HID)
+# USB Input Devices
 #
 CONFIG_USB_HID=y
 CONFIG_USB_HIDINPUT=y
@@ -781,10 +803,15 @@
 # CONFIG_USB_LCD is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
 # CONFIG_USB_PHIDGETSERVO is not set
 # CONFIG_USB_TEST is not set
 
 #
+# USB ATM/DSL drivers
+#
+
+#
 # USB Gadget Support
 #
 # CONFIG_USB_GADGET is not set
@@ -819,6 +846,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=y
 CONFIG_AUTOFS4_FS=y
 
@@ -852,6 +880,8 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+CONFIG_TMPFS_XATTR=y
+CONFIG_TMPFS_SECURITY=y
 CONFIG_HUGETLBFS=y
 CONFIG_HUGETLB_PAGE=y
 CONFIG_RAMFS=y
@@ -983,9 +1013,11 @@
 #
 CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
 # CONFIG_DEBUG_INFO is not set
 CONFIG_IA64_GRANULE_16MB=y
 # CONFIG_IA64_GRANULE_64MB is not set
@@ -998,6 +1030,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
@@ -1011,7 +1044,7 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
-# CONFIG_CRYPTO_WHIRLPOOL is not set
+# CONFIG_CRYPTO_WP512 is not set
 CONFIG_CRYPTO_DES=m
 # CONFIG_CRYPTO_BLOWFISH is not set
 # CONFIG_CRYPTO_TWOFISH is not set
diff -Nru a/arch/ia64/defconfig b/arch/ia64/defconfig
--- a/arch/ia64/defconfig	2004-12-24 13:36:18 -08:00
+++ b/arch/ia64/defconfig	2004-12-24 13:36:18 -08:00
@@ -1,50 +1,54 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1
+# Tue Nov  2 11:47:56 2004
 #
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-# CONFIG_CLEAN_COMPILE is not set
-# CONFIG_STANDALONE is not set
-CONFIG_BROKEN=y
-CONFIG_BROKEN_ON_SMP=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
-CONFIG_BSD_PROCESS_ACCT=y
-# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 # CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=16
+CONFIG_LOG_BUF_SHIFT=20
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
+CONFIG_KALLSYMS_ALL=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
 #
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
-CONFIG_MODULE_FORCE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -57,9 +61,10 @@
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
 CONFIG_TIME_INTERPOLATION=y
 CONFIG_EFI=y
-# CONFIG_IA64_GENERIC is not set
+CONFIG_GENERIC_IOMAP=y
+CONFIG_IA64_GENERIC=y
 # CONFIG_IA64_DIG is not set
-CONFIG_IA64_HP_ZX1=y
+# CONFIG_IA64_HP_ZX1 is not set
 # CONFIG_IA64_SGI_SN2 is not set
 # CONFIG_IA64_HP_SIM is not set
 # CONFIG_ITANIUM is not set
@@ -69,18 +74,20 @@
 CONFIG_IA64_PAGE_SIZE_16KB=y
 # CONFIG_IA64_PAGE_SIZE_64KB is not set
 CONFIG_IA64_L1_CACHE_SHIFT=7
-# CONFIG_NUMA is not set
+CONFIG_NUMA=y
 CONFIG_VIRTUAL_MEM_MAP=y
-# CONFIG_IA64_CYCLONE is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_IA64_CYCLONE=y
 CONFIG_IOSAPIC=y
 CONFIG_FORCE_MAX_ZONEORDER=18
 CONFIG_SMP=y
-CONFIG_NR_CPUS=16
-# CONFIG_HOTPLUG_CPU is not set
+CONFIG_NR_CPUS=512
+CONFIG_HOTPLUG_CPU=y
 # CONFIG_PREEMPT is not set
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_IA32_SUPPORT=y
 CONFIG_COMPAT=y
+CONFIG_IA64_MCA_RECOVERY=y
 CONFIG_PERFMON=y
 CONFIG_IA64_PALINFO=y
 
@@ -90,7 +97,7 @@
 CONFIG_EFI_VARS=y
 CONFIG_EFI_PCDP=y
 CONFIG_BINFMT_ELF=y
-CONFIG_BINFMT_MISC=y
+CONFIG_BINFMT_MISC=m
 
 #
 # Power management and ACPI
@@ -103,10 +110,12 @@
 #
 CONFIG_ACPI_BOOT=y
 CONFIG_ACPI_INTERPRETER=y
-CONFIG_ACPI_BUTTON=y
-CONFIG_ACPI_FAN=y
-CONFIG_ACPI_PROCESSOR=y
-CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_FAN=m
+CONFIG_ACPI_PROCESSOR=m
+CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_NUMA=y
+CONFIG_ACPI_BLACKLIST_YEAR=0
 # CONFIG_ACPI_DEBUG is not set
 CONFIG_ACPI_BUS=y
 CONFIG_ACPI_POWER=y
@@ -118,19 +127,29 @@
 #
 CONFIG_PCI=y
 CONFIG_PCI_DOMAINS=y
-# CONFIG_PCI_USE_VECTOR is not set
+# CONFIG_PCI_MSI is not set
 CONFIG_PCI_LEGACY_PROC=y
 CONFIG_PCI_NAMES=y
 
 #
 # PCI Hotplug Support
 #
-# CONFIG_HOTPLUG_PCI is not set
+CONFIG_HOTPLUG_PCI=m
+# CONFIG_HOTPLUG_PCI_FAKE is not set
+CONFIG_HOTPLUG_PCI_ACPI=m
+# CONFIG_HOTPLUG_PCI_ACPI_IBM is not set
+# CONFIG_HOTPLUG_PCI_CPCI is not set
+# CONFIG_HOTPLUG_PCI_PCIE is not set
+# CONFIG_HOTPLUG_PCI_SHPC is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# PC-card bridges
 #
-# CONFIG_PCMCIA is not set
 
 #
 # Device Drivers
@@ -139,6 +158,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 # CONFIG_DEBUG_DRIVER is not set
@@ -164,13 +184,23 @@
 # CONFIG_BLK_CPQ_CISS_DA is not set
 # CONFIG_BLK_DEV_DAC960 is not set
 # CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
 # CONFIG_BLK_DEV_SX8 is not set
-CONFIG_BLK_DEV_RAM=y
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=m
 CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -183,20 +213,19 @@
 #
 # CONFIG_BLK_DEV_IDE_SATA is not set
 CONFIG_BLK_DEV_IDEDISK=y
-CONFIG_IDEDISK_MULTI_MODE=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
-CONFIG_BLK_DEV_IDEFLOPPY=m
+CONFIG_BLK_DEV_IDEFLOPPY=y
 CONFIG_BLK_DEV_IDESCSI=m
-CONFIG_IDE_TASK_IOCTL=y
-CONFIG_IDE_TASKFILE_IO=y
+# CONFIG_IDE_TASK_IOCTL is not set
 
 #
 # IDE chipset support/bugfixes
 #
-# CONFIG_IDE_GENERIC is not set
+CONFIG_IDE_GENERIC=y
 CONFIG_BLK_DEV_IDEPCI=y
-CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_IDEPCI_SHARE_IRQ is not set
 # CONFIG_BLK_DEV_OFFBOARD is not set
 CONFIG_BLK_DEV_GENERIC=y
 # CONFIG_BLK_DEV_OPTI621 is not set
@@ -204,7 +233,6 @@
 # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
 CONFIG_IDEDMA_PCI_AUTO=y
 # CONFIG_IDEDMA_ONLYDISK is not set
-CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_AEC62XX is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_BLK_DEV_AMD74XX is not set
@@ -216,12 +244,13 @@
 # CONFIG_BLK_DEV_HPT34X is not set
 # CONFIG_BLK_DEV_HPT366 is not set
 # CONFIG_BLK_DEV_SC1200 is not set
-# CONFIG_BLK_DEV_PIIX is not set
+CONFIG_BLK_DEV_PIIX=y
 # CONFIG_BLK_DEV_NS87415 is not set
 # CONFIG_BLK_DEV_PDC202XX_OLD is not set
 # CONFIG_BLK_DEV_PDC202XX_NEW is not set
 # CONFIG_BLK_DEV_SVWKS is not set
-CONFIG_BLK_DEV_SIIMAGE=y
+CONFIG_BLK_DEV_SGIIOC4=y
+# CONFIG_BLK_DEV_SIIMAGE is not set
 # CONFIG_BLK_DEV_SLC90E66 is not set
 # CONFIG_BLK_DEV_TRM290 is not set
 # CONFIG_BLK_DEV_VIA82CXXX is not set
@@ -241,24 +270,24 @@
 # SCSI support type (disk, tape, CD-ROM)
 #
 CONFIG_BLK_DEV_SD=y
-CONFIG_CHR_DEV_ST=y
-CONFIG_CHR_DEV_OSST=y
-CONFIG_BLK_DEV_SR=y
-CONFIG_BLK_DEV_SR_VENDOR=y
-CONFIG_CHR_DEV_SG=y
+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_CHR_DEV_SG=m
 
 #
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
 #
-CONFIG_SCSI_MULTI_LUN=y
-CONFIG_SCSI_CONSTANTS=y
-CONFIG_SCSI_LOGGING=y
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
 
 #
 # SCSI Transport Attributes
 #
 CONFIG_SCSI_SPI_ATTRS=y
-# CONFIG_SCSI_FC_ATTRS is not set
+CONFIG_SCSI_FC_ATTRS=y
 
 #
 # SCSI low-level drivers
@@ -268,13 +297,12 @@
 # CONFIG_SCSI_ACARD is not set
 # CONFIG_SCSI_AACRAID is not set
 # CONFIG_SCSI_AIC7XXX is not set
-CONFIG_SCSI_AIC7XXX_OLD=y
+# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_AIC79XX is not set
-# CONFIG_SCSI_ADVANSYS is not set
-CONFIG_SCSI_MEGARAID=y
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
 # CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_BUSLOGIC is not set
-# CONFIG_SCSI_CPQFCTS is not set
 # CONFIG_SCSI_DMX3191D is not set
 # CONFIG_SCSI_EATA is not set
 # CONFIG_SCSI_EATA_PIO is not set
@@ -289,16 +317,16 @@
 CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
 # CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
 # CONFIG_SCSI_IPR is not set
-# CONFIG_SCSI_PCI2000 is not set
-# CONFIG_SCSI_PCI2220I is not set
 # CONFIG_SCSI_QLOGIC_ISP is not set
-# CONFIG_SCSI_QLOGIC_FC is not set
+CONFIG_SCSI_QLOGIC_FC=y
+# CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set
 CONFIG_SCSI_QLOGIC_1280=y
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
-# CONFIG_SCSI_QLA21XX is not set
-# CONFIG_SCSI_QLA22XX is not set
-# CONFIG_SCSI_QLA2300 is not set
-# CONFIG_SCSI_QLA2322 is not set
+CONFIG_SCSI_QLA21XX=m
+CONFIG_SCSI_QLA22XX=m
+CONFIG_SCSI_QLA2300=m
+CONFIG_SCSI_QLA2322=m
 # CONFIG_SCSI_QLA6312 is not set
 # CONFIG_SCSI_QLA6322 is not set
 # CONFIG_SCSI_DC395x is not set
@@ -313,21 +341,21 @@
 CONFIG_MD_LINEAR=m
 CONFIG_MD_RAID0=m
 CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
 CONFIG_MD_RAID5=m
-# CONFIG_MD_RAID6 is not set
+CONFIG_MD_RAID6=m
 CONFIG_MD_MULTIPATH=m
 CONFIG_BLK_DEV_DM=m
-# CONFIG_DM_CRYPT is not set
-# CONFIG_DM_SNAPSHOT is not set
-# CONFIG_DM_MIRROR is not set
-# CONFIG_DM_ZERO is not set
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
 
 #
 # Fusion MPT device support
 #
 CONFIG_FUSION=y
 CONFIG_FUSION_MAX_SGE=40
-# CONFIG_FUSION_ISENSE is not set
 # CONFIG_FUSION_CTL is not set
 
 #
@@ -350,7 +378,7 @@
 #
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
+CONFIG_NETLINK_DEV=y
 CONFIG_UNIX=y
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
@@ -360,31 +388,15 @@
 # CONFIG_NET_IPIP is not set
 # CONFIG_NET_IPGRE is not set
 # CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
+CONFIG_ARPD=y
+CONFIG_SYN_COOKIES=y
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
 # CONFIG_IPV6 is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-
-#
-# IP: Netfilter Configuration
-#
-# CONFIG_IP_NF_CONNTRACK is not set
-# CONFIG_IP_NF_QUEUE is not set
-# CONFIG_IP_NF_IPTABLES is not set
-CONFIG_IP_NF_ARPTABLES=y
-# CONFIG_IP_NF_ARPFILTER is not set
-# CONFIG_IP_NF_ARP_MANGLE is not set
-# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
+# CONFIG_NETFILTER is not set
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -402,7 +414,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -414,16 +425,19 @@
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 CONFIG_NETDEVICES=y
-CONFIG_DUMMY=y
-CONFIG_BONDING=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
 
 #
 # ARCnet devices
@@ -434,7 +448,7 @@
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
+CONFIG_MII=m
 # CONFIG_HAPPYMEAL is not set
 # CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
@@ -442,7 +456,15 @@
 #
 # Tulip family network device support
 #
-# CONFIG_NET_TULIP is not set
+CONFIG_NET_TULIP=y
+# CONFIG_DE2104X is not set
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+# CONFIG_TULIP_NAPI is not set
+# CONFIG_DE4X5 is not set
+# CONFIG_WINBOND_840 is not set
+# CONFIG_DM9102 is not set
 # CONFIG_HP100 is not set
 CONFIG_NET_PCI=y
 # CONFIG_PCNET32 is not set
@@ -451,9 +473,10 @@
 # CONFIG_B44 is not set
 # CONFIG_FORCEDETH is not set
 # CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
+CONFIG_EEPRO100=m
 # CONFIG_EEPRO100_PIO is not set
-# CONFIG_E100 is not set
+CONFIG_E100=m
+# CONFIG_E100_NAPI is not set
 # CONFIG_FEALNX is not set
 # CONFIG_NATSEMI is not set
 # CONFIG_NE2K_PCI is not set
@@ -463,7 +486,6 @@
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -477,6 +499,7 @@
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 CONFIG_TIGON3=y
 
 #
@@ -505,7 +528,7 @@
 # CONFIG_SLIP is not set
 # CONFIG_NET_FC is not set
 # CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
+CONFIG_NETCONSOLE=y
 
 #
 # ISDN subsystem
@@ -529,27 +552,42 @@
 CONFIG_INPUT_MOUSEDEV_PSAUX=y
 CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
 CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-CONFIG_INPUT_JOYDEV=y
+# CONFIG_INPUT_JOYDEV is not set
 # CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVDEV is not set
 # CONFIG_INPUT_EVBUG is not set
 
 #
 # Input I/O drivers
 #
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
+CONFIG_GAMEPORT=m
+CONFIG_SOUND_GAMEPORT=m
+# CONFIG_GAMEPORT_NS558 is not set
+# CONFIG_GAMEPORT_L4 is not set
+# CONFIG_GAMEPORT_EMU10K1 is not set
+# CONFIG_GAMEPORT_VORTEX is not set
+# CONFIG_GAMEPORT_FM801 is not set
+# CONFIG_GAMEPORT_CS461x is not set
 CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
+CONFIG_SERIO_I8042=y
 # CONFIG_SERIO_SERPORT is not set
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
 #
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_VSXXXAA is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TOUCHSCREEN is not set
 # CONFIG_INPUT_MISC is not set
@@ -560,7 +598,14 @@
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_ROCKETPORT is not set
+# CONFIG_CYCLADES is not set
+# CONFIG_SYNCLINK is not set
+# CONFIG_SYNCLINKMP is not set
+# CONFIG_N_HDLC is not set
+# CONFIG_STALDRV is not set
+CONFIG_SGI_SNSC=y
 
 #
 # Serial drivers
@@ -568,28 +613,27 @@
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_ACPI=y
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
+CONFIG_SERIAL_8250_NR_UARTS=6
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+# CONFIG_SERIAL_8250_DETECT_IRQ is not set
+# CONFIG_SERIAL_8250_MULTIPORT is not set
+# CONFIG_SERIAL_8250_RSA is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_SGI_L1_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
 #
-CONFIG_IPMI_HANDLER=m
-CONFIG_IPMI_PANIC_EVENT=y
-CONFIG_IPMI_PANIC_STRING=y
-CONFIG_IPMI_DEVICE_INTERFACE=m
-CONFIG_IPMI_SI=m
-CONFIG_IPMI_WATCHDOG=m
+# CONFIG_IPMI_HANDLER is not set
 
 #
 # Watchdog Cards
@@ -604,90 +648,26 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 CONFIG_AGP=m
+CONFIG_AGP_I460=m
 CONFIG_AGP_HP_ZX1=m
 CONFIG_DRM=y
-# CONFIG_DRM_TDFX is not set
-# CONFIG_DRM_GAMMA is not set
-# CONFIG_DRM_R128 is not set
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_R128=m
 CONFIG_DRM_RADEON=m
-# CONFIG_DRM_MGA is not set
-# CONFIG_DRM_SIS is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HPET is not set
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_RAW_DRIVER=m
+CONFIG_HPET=y
+# CONFIG_HPET_RTC_IRQ is not set
+CONFIG_HPET_MMAP=y
+CONFIG_MAX_RAW_DEVS=256
+CONFIG_MMTIMER=y
 
 #
 # I2C support
 #
-CONFIG_I2C=y
-# CONFIG_I2C_CHARDEV is not set
-
-#
-# I2C Algorithms
-#
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ALGOPCF is not set
-
-#
-# I2C Hardware Bus support
-#
-# CONFIG_I2C_ALI1535 is not set
-# CONFIG_I2C_ALI1563 is not set
-# CONFIG_I2C_ALI15X3 is not set
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-# CONFIG_I2C_I801 is not set
-# CONFIG_I2C_I810 is not set
-# CONFIG_I2C_ISA is not set
-# CONFIG_I2C_NFORCE2 is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PROSAVAGE is not set
-# CONFIG_I2C_SAVAGE4 is not set
-# CONFIG_SCx200_ACB is not set
-# CONFIG_I2C_SIS5595 is not set
-# CONFIG_I2C_SIS630 is not set
-# CONFIG_I2C_SIS96X is not set
-# CONFIG_I2C_VIA is not set
-# CONFIG_I2C_VIAPRO is not set
-# CONFIG_I2C_VOODOO3 is not set
-
-#
-# Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_ADM1025 is not set
-# CONFIG_SENSORS_ADM1031 is not set
-# CONFIG_SENSORS_ASB100 is not set
-# CONFIG_SENSORS_DS1621 is not set
-# CONFIG_SENSORS_FSCHER is not set
-# CONFIG_SENSORS_GL518SM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM77 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM80 is not set
-# CONFIG_SENSORS_LM83 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_LM90 is not set
-# CONFIG_SENSORS_MAX1619 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_SENSORS_W83L785TS is not set
-# CONFIG_SENSORS_W83627HF is not set
-
-#
-# Other I2C Chip support
-#
-# CONFIG_SENSORS_EEPROM is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_SENSORS_RTC8564 is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
+# CONFIG_I2C is not set
 
 #
 # Dallas's 1-wire bus
@@ -711,53 +691,18 @@
 #
 # Graphics support
 #
-CONFIG_FB=y
-# CONFIG_FB_CIRRUS is not set
-# CONFIG_FB_PM2 is not set
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_ASILIANT is not set
-# CONFIG_FB_IMSTT is not set
-CONFIG_FB_RIVA=m
-CONFIG_FB_RIVA_I2C=y
-# CONFIG_FB_MATROX is not set
-# CONFIG_FB_RADEON_OLD is not set
-CONFIG_FB_RADEON=m
-CONFIG_FB_RADEON_I2C=y
-# CONFIG_FB_RADEON_DEBUG is not set
-# CONFIG_FB_ATY128 is not set
-# CONFIG_FB_ATY is not set
-# CONFIG_FB_SIS is not set
-# CONFIG_FB_NEOMAGIC is not set
-# CONFIG_FB_KYRO is not set
-# CONFIG_FB_3DFX is not set
-# CONFIG_FB_VOODOO1 is not set
-# CONFIG_FB_TRIDENT is not set
-# CONFIG_FB_PM3 is not set
-# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB is not set
 
 #
 # Console display driver support
 #
 CONFIG_VGA_CONSOLE=y
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
-CONFIG_FRAMEBUFFER_CONSOLE=y
-# CONFIG_FONTS is not set
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-
-#
-# Logo configuration
-#
-CONFIG_LOGO=y
-# CONFIG_LOGO_LINUX_MONO is not set
-# CONFIG_LOGO_LINUX_VGA16 is not set
-CONFIG_LOGO_LINUX_CLUT224=y
 
 #
 # Sound
 #
-CONFIG_SOUND=y
+CONFIG_SOUND=m
 
 #
 # Advanced Linux Sound Architecture
@@ -768,11 +713,12 @@
 CONFIG_SND_HWDEP=m
 CONFIG_SND_RAWMIDI=m
 CONFIG_SND_SEQUENCER=m
-# CONFIG_SND_SEQ_DUMMY is not set
-# CONFIG_SND_MIXER_OSS is not set
-# CONFIG_SND_PCM_OSS is not set
-# CONFIG_SND_SEQUENCER_OSS is not set
-# CONFIG_SND_VERBOSE_PRINTK is not set
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_VERBOSE_PRINTK=y
 # CONFIG_SND_DEBUG is not set
 
 #
@@ -780,11 +726,11 @@
 #
 CONFIG_SND_MPU401_UART=m
 CONFIG_SND_OPL3_LIB=m
-# CONFIG_SND_DUMMY is not set
-# CONFIG_SND_VIRMIDI is not set
-# CONFIG_SND_MTPAV is not set
-# CONFIG_SND_SERIAL_U16550 is not set
-# CONFIG_SND_MPU401 is not set
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
 
 #
 # PCI devices
@@ -792,14 +738,16 @@
 CONFIG_SND_AC97_CODEC=m
 # CONFIG_SND_ALI5451 is not set
 # CONFIG_SND_ATIIXP is not set
+# CONFIG_SND_ATIIXP_MODEM is not set
 # CONFIG_SND_AU8810 is not set
 # CONFIG_SND_AU8820 is not set
 # CONFIG_SND_AU8830 is not set
 # CONFIG_SND_AZT3328 is not set
 # CONFIG_SND_BT87X is not set
-# CONFIG_SND_CS46XX is not set
-# CONFIG_SND_CS4281 is not set
-# CONFIG_SND_EMU10K1 is not set
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS4281=m
+CONFIG_SND_EMU10K1=m
 # CONFIG_SND_KORG1212 is not set
 # CONFIG_SND_MIXART is not set
 # CONFIG_SND_NM256 is not set
@@ -827,9 +775,10 @@
 # CONFIG_SND_VX222 is not set
 
 #
-# ALSA USB devices
+# USB devices
 #
 # CONFIG_SND_USB_AUDIO is not set
+# CONFIG_SND_USB_USX2Y is not set
 
 #
 # Open Sound System
@@ -839,24 +788,28 @@
 #
 # USB support
 #
-CONFIG_USB=y
+CONFIG_USB=m
 # CONFIG_USB_DEBUG is not set
 
 #
 # Miscellaneous USB options
 #
 CONFIG_USB_DEVICEFS=y
-CONFIG_USB_BANDWIDTH=y
+# CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_OTG is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Host Controller Drivers
 #
-CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_HCD=m
 # CONFIG_USB_EHCI_SPLIT_ISO is not set
-CONFIG_USB_EHCI_ROOT_HUB_TT=y
-CONFIG_USB_OHCI_HCD=y
-CONFIG_USB_UHCI_HCD=y
+# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
+CONFIG_USB_OHCI_HCD=m
+CONFIG_USB_UHCI_HCD=m
 
 #
 # USB Device Class drivers
@@ -866,15 +819,31 @@
 # CONFIG_USB_MIDI is not set
 # CONFIG_USB_ACM is not set
 # CONFIG_USB_PRINTER is not set
-# CONFIG_USB_STORAGE is not set
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_RW_DETECT is not set
+# CONFIG_USB_STORAGE_DATAFAB 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_STORAGE_HP8200e is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
 
 #
-# USB Human Interface Devices (HID)
+# USB Input Devices
 #
-CONFIG_USB_HID=y
+CONFIG_USB_HID=m
 CONFIG_USB_HIDINPUT=y
 # CONFIG_HID_FF is not set
-CONFIG_USB_HIDDEV=y
+# CONFIG_USB_HIDDEV is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
 # CONFIG_USB_AIPTEK is not set
 # CONFIG_USB_WACOM is not set
 # CONFIG_USB_KBTAB is not set
@@ -930,10 +899,15 @@
 # CONFIG_USB_LCD is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
 # CONFIG_USB_PHIDGETSERVO is not set
 # CONFIG_USB_TEST is not set
 
 #
+# USB ATM/DSL drivers
+#
+
+#
 # USB Gadget Support
 #
 # CONFIG_USB_GADGET is not set
@@ -943,42 +917,55 @@
 #
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
-# CONFIG_EXT2_FS_POSIX_ACL is not set
-# CONFIG_EXT2_FS_SECURITY is not set
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
 CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
 CONFIG_JBD=y
 # CONFIG_JBD_DEBUG is not set
 CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
+CONFIG_REISERFS_FS=y
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
 # CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=y
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=y
-# CONFIG_AUTOFS4_FS is not set
+CONFIG_AUTOFS4_FS=y
 
 #
 # CD-ROM/DVD Filesystems
 #
-CONFIG_ISO9660_FS=y
+CONFIG_ISO9660_FS=m
 CONFIG_JOLIET=y
 # CONFIG_ZISOFS is not set
-CONFIG_UDF_FS=y
+CONFIG_UDF_FS=m
 CONFIG_UDF_NLS=y
 
 #
 # DOS/FAT/NT Filesystems
 #
 CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
+# CONFIG_MSDOS_FS is not set
 CONFIG_VFAT_FS=y
 CONFIG_FAT_DEFAULT_CODEPAGE=437
 CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
-# CONFIG_NTFS_FS is not set
+CONFIG_NTFS_FS=m
+# CONFIG_NTFS_DEBUG is not set
+# CONFIG_NTFS_RW is not set
 
 #
 # Pseudo filesystems
@@ -989,6 +976,8 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+CONFIG_TMPFS_XATTR=y
+CONFIG_TMPFS_SECURITY=y
 CONFIG_HUGETLBFS=y
 CONFIG_HUGETLB_PAGE=y
 CONFIG_RAMFS=y
@@ -1003,7 +992,6 @@
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -1014,22 +1002,28 @@
 #
 # Network File Systems
 #
-CONFIG_NFS_FS=y
+CONFIG_NFS_FS=m
 CONFIG_NFS_V3=y
 CONFIG_NFS_V4=y
 CONFIG_NFS_DIRECTIO=y
-CONFIG_NFSD=y
+CONFIG_NFSD=m
 CONFIG_NFSD_V3=y
-# CONFIG_NFSD_V4 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_LOCKD=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
 CONFIG_LOCKD_V4=y
-CONFIG_EXPORTFS=y
-CONFIG_SUNRPC=y
-CONFIG_SUNRPC_GSS=y
-CONFIG_RPCSEC_GSS_KRB5=y
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_RPCSEC_GSS_KRB5=m
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_POSIX is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -1049,7 +1043,7 @@
 # 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_SGI_PARTITION=y
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
 CONFIG_EFI_PARTITION=y
@@ -1060,43 +1054,43 @@
 CONFIG_NLS=y
 CONFIG_NLS_DEFAULT="iso8859-1"
 CONFIG_NLS_CODEPAGE_437=y
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-CONFIG_NLS_ASCII=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+# CONFIG_NLS_ASCII is not set
 CONFIG_NLS_ISO8859_1=y
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
 
 #
 # Library routines
@@ -1106,6 +1100,13 @@
 # CONFIG_LIBCRC32C is not set
 
 #
+# HP Simulator drivers
+#
+# CONFIG_HP_SIMETH is not set
+# CONFIG_HP_SIMSERIAL is not set
+# CONFIG_HP_SIMSCSI is not set
+
+#
 # Profiling support
 #
 # CONFIG_PROFILING is not set
@@ -1113,24 +1114,26 @@
 #
 # Kernel hacking
 #
-CONFIG_IA64_GRANULE_16MB=y
-# CONFIG_IA64_GRANULE_64MB is not set
 CONFIG_DEBUG_KERNEL=y
-CONFIG_IA64_PRINT_HAZARDS=y
-# CONFIG_DISABLE_VHPT is not set
 CONFIG_MAGIC_SYSRQ=y
-# CONFIG_IA64_EARLY_PRINTK_VGA is not set
+# CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_INFO is not set
+CONFIG_IA64_GRANULE_16MB=y
+# CONFIG_IA64_GRANULE_64MB is not set
+# CONFIG_IA64_PRINT_HAZARDS is not set
+# CONFIG_DISABLE_VHPT is not set
 # CONFIG_IA64_DEBUG_CMPXCHG is not set
 # CONFIG_IA64_DEBUG_IRQ is not set
-CONFIG_DEBUG_INFO=y
 CONFIG_SYSVIPC_COMPAT=y
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
@@ -1140,11 +1143,12 @@
 # CONFIG_CRYPTO_HMAC is not set
 # CONFIG_CRYPTO_NULL is not set
 # CONFIG_CRYPTO_MD4 is not set
-CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_MD5=m
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
-CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=m
 # CONFIG_CRYPTO_BLOWFISH is not set
 # CONFIG_CRYPTO_TWOFISH is not set
 # CONFIG_CRYPTO_SERPENT is not set
@@ -1153,6 +1157,7 @@
 # CONFIG_CRYPTO_CAST6 is not set
 # CONFIG_CRYPTO_TEA is not set
 # CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_KHAZAD is not set
 # CONFIG_CRYPTO_DEFLATE is not set
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
 # CONFIG_CRYPTO_CRC32C is not set
diff -Nru a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
--- a/arch/ia64/hp/common/sba_iommu.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ia64/hp/common/sba_iommu.c	2004-12-24 13:36:18 -08:00
@@ -33,13 +33,14 @@
 #include <linux/seq_file.h>
 #include <linux/acpi.h>
 #include <linux/efi.h>
+#include <linux/nodemask.h>
+#include <linux/bitops.h>         /* hweight64() */
 
 #include <asm/delay.h>		/* ia64_get_itc() */
 #include <asm/io.h>
 #include <asm/page.h>		/* PAGE_OFFSET */
 #include <asm/dma.h>
 #include <asm/system.h>		/* wmb() */
-#include <asm/bitops.h>		/* hweight64() */
 
 #include <asm/acpi-ext.h>
 
@@ -478,7 +479,7 @@
 	 * purges IOTLB entries in power-of-two sizes, so we also
 	 * allocate IOVA space in power-of-two sizes.
 	 */
-	bits_wanted = 1UL << get_iovp_order(bits_wanted << PAGE_SHIFT);
+	bits_wanted = 1UL << get_iovp_order(bits_wanted << iovp_shift);
 
 	if (likely(bits_wanted == 1)) {
 		unsigned int bitshiftcnt;
@@ -687,7 +688,7 @@
 	unsigned long m;
 
 	/* Round up to power-of-two size: see AR2305 note above */
-	bits_not_wanted = 1UL << get_iovp_order(bits_not_wanted << PAGE_SHIFT);
+	bits_not_wanted = 1UL << get_iovp_order(bits_not_wanted << iovp_shift);
 	for (; bits_not_wanted > 0 ; res_ptr++) {
 		
 		if (unlikely(bits_not_wanted > BITS_PER_LONG)) {
diff -Nru a/arch/ia64/hp/sim/simeth.c b/arch/ia64/hp/sim/simeth.c
--- a/arch/ia64/hp/sim/simeth.c	2004-12-24 13:37:00 -08:00
+++ b/arch/ia64/hp/sim/simeth.c	2004-12-24 13:37:00 -08:00
@@ -20,7 +20,7 @@
 #include <linux/if_arp.h>
 #include <linux/skbuff.h>
 #include <linux/notifier.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
 #include <asm/irq.h>
 
diff -Nru a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
--- a/arch/ia64/hp/sim/simserial.c	2004-12-24 13:36:49 -08:00
+++ b/arch/ia64/hp/sim/simserial.c	2004-12-24 13:36:49 -08:00
@@ -301,7 +301,7 @@
 }
 
 
-static int rs_write(struct tty_struct * tty, int from_user,
+static int rs_write(struct tty_struct * tty,
 		    const unsigned char *buf, int count)
 {
 	int	c, ret = 0;
@@ -310,58 +310,22 @@
 
 	if (!tty || !info->xmit.buf || !tmp_buf) return 0;
 
-	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;
-			}
-
-			local_irq_save(flags);
-			{
-				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));
-			}
-			local_irq_restore(flags);
-
-			buf += c;
-			count -= c;
-			ret += c;
-		}
-		up(&tmp_buf_sem);
-	} else {
-		local_irq_save(flags);
-		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;
+	local_irq_save(flags);
+	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;
 		}
-		local_irq_restore(flags);
+		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;
 	}
+	local_irq_restore(flags);
 	/*
 	 * Hey, we transmit directly from here in our case
 	 */
diff -Nru a/arch/ia64/ia32/binfmt_elf32.c b/arch/ia64/ia32/binfmt_elf32.c
--- a/arch/ia64/ia32/binfmt_elf32.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ia64/ia32/binfmt_elf32.c	2004-12-24 13:37:19 -08:00
@@ -100,7 +100,11 @@
 		vma->vm_ops = &ia32_shared_page_vm_ops;
 		down_write(&current->mm->mmap_sem);
 		{
-			insert_vm_struct(current->mm, vma);
+			if (insert_vm_struct(current->mm, vma)) {
+				kmem_cache_free(vm_area_cachep, vma);
+				up_write(&current->mm->mmap_sem);
+				return;
+			}
 		}
 		up_write(&current->mm->mmap_sem);
 	}
@@ -123,7 +127,11 @@
 		vma->vm_ops = &ia32_gate_page_vm_ops;
 		down_write(&current->mm->mmap_sem);
 		{
-			insert_vm_struct(current->mm, vma);
+			if (insert_vm_struct(current->mm, vma)) {
+				kmem_cache_free(vm_area_cachep, vma);
+				up_write(&current->mm->mmap_sem);
+				return;
+			}
 		}
 		up_write(&current->mm->mmap_sem);
 	}
@@ -142,7 +150,11 @@
 		vma->vm_flags = VM_READ|VM_WRITE|VM_MAYREAD|VM_MAYWRITE;
 		down_write(&current->mm->mmap_sem);
 		{
-			insert_vm_struct(current->mm, vma);
+			if (insert_vm_struct(current->mm, vma)) {
+				kmem_cache_free(vm_area_cachep, vma);
+				up_write(&current->mm->mmap_sem);
+				return;
+			}
 		}
 		up_write(&current->mm->mmap_sem);
 	}
@@ -190,7 +202,7 @@
 	unsigned long stack_base;
 	struct vm_area_struct *mpnt;
 	struct mm_struct *mm = current->mm;
-	int i;
+	int i, ret;
 
 	stack_base = IA32_STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE;
 	mm->arg_start = bprm->p + stack_base;
@@ -225,7 +237,11 @@
 			mpnt->vm_flags = VM_STACK_FLAGS;
 		mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC)?
 					PAGE_COPY_EXEC: PAGE_COPY;
-		insert_vm_struct(current->mm, mpnt);
+		if ((ret = insert_vm_struct(current->mm, mpnt))) {
+			up_write(&current->mm->mmap_sem);
+			kmem_cache_free(vm_area_cachep, mpnt);
+			return ret;
+		}
 		current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
 	}
 
diff -Nru a/arch/ia64/ia32/elfcore32.h b/arch/ia64/ia32/elfcore32.h
--- a/arch/ia64/ia32/elfcore32.h	2004-12-24 13:36:49 -08:00
+++ b/arch/ia64/ia32/elfcore32.h	2004-12-24 13:36:49 -08:00
@@ -9,6 +9,7 @@
 #define _ELFCORE32_H_
 
 #include <asm/intrinsics.h>
+#include <asm/uaccess.h>
 
 #define USE_ELF_CORE_DUMP 1
 
diff -Nru a/arch/ia64/ia32/ia32_entry.S b/arch/ia64/ia32/ia32_entry.S
--- a/arch/ia64/ia32/ia32_entry.S	2004-12-24 13:36:56 -08:00
+++ b/arch/ia64/ia32/ia32_entry.S	2004-12-24 13:36:56 -08:00
@@ -470,16 +470,16 @@
 	data8 sys_remap_file_pages
 	data8 sys_set_tid_address
  	data8 sys32_timer_create
- 	data8 compat_timer_settime	/* 260 */
- 	data8 compat_timer_gettime
+ 	data8 compat_sys_timer_settime	/* 260 */
+ 	data8 compat_sys_timer_gettime
  	data8 sys_timer_getoverrun
  	data8 sys_timer_delete
- 	data8 compat_clock_settime
- 	data8 compat_clock_gettime /* 265 */
- 	data8 compat_clock_getres
- 	data8 compat_clock_nanosleep
-	data8 compat_statfs64
-	data8 compat_fstatfs64
+ 	data8 compat_sys_clock_settime
+ 	data8 compat_sys_clock_gettime /* 265 */
+ 	data8 compat_sys_clock_getres
+ 	data8 compat_sys_clock_nanosleep
+	data8 compat_sys_statfs64
+	data8 compat_sys_fstatfs64
  	data8 sys_tgkill	/* 270 */
  	data8 compat_sys_utimes
  	data8 sys32_fadvise64_64
diff -Nru a/arch/ia64/ia32/ia32priv.h b/arch/ia64/ia32/ia32priv.h
--- a/arch/ia64/ia32/ia32priv.h	2004-12-24 13:37:29 -08:00
+++ b/arch/ia64/ia32/ia32priv.h	2004-12-24 13:37:29 -08:00
@@ -559,6 +559,10 @@
 extern int save_ia32_fpstate (struct task_struct *, struct ia32_user_i387_struct __user *);
 extern int save_ia32_fpxstate (struct task_struct *, struct ia32_user_fxsr_struct __user *);
 
+/* Prototypes for use in sys_ia32.c */
+int copy_siginfo_to_user32 (siginfo_t32 __user *to, siginfo_t *from);
+int copy_siginfo_from_user32 (siginfo_t *to, siginfo_t32 __user *from);
+
 #endif /* !CONFIG_IA32_SUPPORT */
 
 #endif /* _ASM_IA64_IA32_PRIV_H */
diff -Nru a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
--- a/arch/ia64/kernel/Makefile	2004-12-24 13:37:31 -08:00
+++ b/arch/ia64/kernel/Makefile	2004-12-24 13:37:31 -08:00
@@ -14,7 +14,7 @@
 obj-$(CONFIG_IA64_PALINFO)	+= palinfo.o
 obj-$(CONFIG_IOSAPIC)		+= iosapic.o
 obj-$(CONFIG_MODULES)		+= module.o
-obj-$(CONFIG_SMP)		+= smp.o smpboot.o
+obj-$(CONFIG_SMP)		+= smp.o smpboot.o domain.o
 obj-$(CONFIG_PERFMON)		+= perfmon_default_smpl.o
 obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 obj-$(CONFIG_IA64_MCA_RECOVERY)	+= mca_recovery.o
diff -Nru a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
--- a/arch/ia64/kernel/acpi.c	2004-12-24 13:36:49 -08:00
+++ b/arch/ia64/kernel/acpi.c	2004-12-24 13:36:49 -08:00
@@ -43,6 +43,7 @@
 #include <linux/acpi.h>
 #include <linux/efi.h>
 #include <linux/mmzone.h>
+#include <linux/nodemask.h>
 #include <asm/io.h>
 #include <asm/iosapic.h>
 #include <asm/machvec.h>
diff -Nru a/arch/ia64/kernel/asm-offsets.c b/arch/ia64/kernel/asm-offsets.c
--- a/arch/ia64/kernel/asm-offsets.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ia64/kernel/asm-offsets.c	2004-12-24 13:37:19 -08:00
@@ -217,6 +217,7 @@
 	DEFINE(IA64_TIME_INTERPOLATOR_LAST_CYCLE_OFFSET, offsetof (struct time_interpolator, last_cycle));
 	DEFINE(IA64_TIME_INTERPOLATOR_LAST_COUNTER_OFFSET, offsetof (struct time_interpolator, last_counter));
 	DEFINE(IA64_TIME_INTERPOLATOR_JITTER_OFFSET, offsetof (struct time_interpolator, jitter));
+	DEFINE(IA64_TIME_INTERPOLATOR_MASK_OFFSET, offsetof (struct time_interpolator, mask));
 	DEFINE(IA64_TIME_SOURCE_CPU, TIME_SOURCE_CPU);
 	DEFINE(IA64_TIME_SOURCE_MMIO64, TIME_SOURCE_MMIO64);
 	DEFINE(IA64_TIME_SOURCE_MMIO32, TIME_SOURCE_MMIO32);
diff -Nru a/arch/ia64/kernel/cyclone.c b/arch/ia64/kernel/cyclone.c
--- a/arch/ia64/kernel/cyclone.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ia64/kernel/cyclone.c	2004-12-24 13:36:48 -08:00
@@ -19,10 +19,11 @@
 
 
 struct time_interpolator cyclone_interpolator = {
-	.source =	TIME_SOURCE_MMIO32,
-	.shift =	32,
+	.source =	TIME_SOURCE_MMIO64,
+	.shift =	16,
 	.frequency =	CYCLONE_TIMER_FREQ,
 	.drift =	-100,
+	.mask =		(1LL << 40) - 1
 };
 
 int __init init_cyclone_clock(void)
diff -Nru a/arch/ia64/kernel/domain.c b/arch/ia64/kernel/domain.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/kernel/domain.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,382 @@
+/*
+ * arch/ia64/kernel/domain.c
+ * Architecture specific sched-domains builder.
+ *
+ * Copyright (C) 2004 Jesse Barnes
+ * Copyright (C) 2004 Silicon Graphics, Inc.
+ */
+
+#include <linux/sched.h>
+#include <linux/percpu.h>
+#include <linux/slab.h>
+#include <linux/cpumask.h>
+#include <linux/init.h>
+#include <linux/topology.h>
+
+#define SD_NODES_PER_DOMAIN 6
+
+#ifdef CONFIG_NUMA
+/**
+ * find_next_best_node - find the next node to include in a sched_domain
+ * @node: node whose sched_domain we're building
+ * @used_nodes: nodes already in the sched_domain
+ *
+ * Find the next node to include in a given scheduling domain.  Simply
+ * finds the closest node not already in the @used_nodes map.
+ *
+ * Should use nodemask_t.
+ */
+static int __devinit find_next_best_node(int node, unsigned long *used_nodes)
+{
+	int i, n, val, min_val, best_node = 0;
+
+	min_val = INT_MAX;
+
+	for (i = 0; i < MAX_NUMNODES; i++) {
+		/* Start at @node */
+		n = (node + i) % MAX_NUMNODES;
+
+		if (!nr_cpus_node(n))
+			continue;
+
+		/* Skip already used nodes */
+		if (test_bit(n, used_nodes))
+			continue;
+
+		/* Simple min distance search */
+		val = node_distance(node, n);
+
+		if (val < min_val) {
+			min_val = val;
+			best_node = n;
+		}
+	}
+
+	set_bit(best_node, used_nodes);
+	return best_node;
+}
+
+/**
+ * sched_domain_node_span - get a cpumask for a node's sched_domain
+ * @node: node whose cpumask we're constructing
+ * @size: number of nodes to include in this span
+ *
+ * Given a node, construct a good cpumask for its sched_domain to span.  It
+ * should be one that prevents unnecessary balancing, but also spreads tasks
+ * out optimally.
+ */
+static cpumask_t __devinit sched_domain_node_span(int node)
+{
+	int i;
+	cpumask_t span, nodemask;
+	DECLARE_BITMAP(used_nodes, MAX_NUMNODES);
+
+	cpus_clear(span);
+	bitmap_zero(used_nodes, MAX_NUMNODES);
+
+	nodemask = node_to_cpumask(node);
+	cpus_or(span, span, nodemask);
+	set_bit(node, used_nodes);
+
+	for (i = 1; i < SD_NODES_PER_DOMAIN; i++) {
+		int next_node = find_next_best_node(node, used_nodes);
+		nodemask = node_to_cpumask(next_node);
+		cpus_or(span, span, nodemask);
+	}
+
+	return span;
+}
+#endif
+
+/*
+ * At the moment, CONFIG_SCHED_SMT is never defined, but leave it in so we
+ * can switch it on easily if needed.
+ */
+#ifdef CONFIG_SCHED_SMT
+static DEFINE_PER_CPU(struct sched_domain, cpu_domains);
+static struct sched_group sched_group_cpus[NR_CPUS];
+static int __devinit cpu_to_cpu_group(int cpu)
+{
+	return cpu;
+}
+#endif
+
+static DEFINE_PER_CPU(struct sched_domain, phys_domains);
+static struct sched_group sched_group_phys[NR_CPUS];
+static int __devinit cpu_to_phys_group(int cpu)
+{
+#ifdef CONFIG_SCHED_SMT
+	return first_cpu(cpu_sibling_map[cpu]);
+#else
+	return cpu;
+#endif
+}
+
+#ifdef CONFIG_NUMA
+/*
+ * The init_sched_build_groups can't handle what we want to do with node
+ * groups, so roll our own. Now each node has its own list of groups which
+ * gets dynamically allocated.
+ */
+static DEFINE_PER_CPU(struct sched_domain, node_domains);
+static struct sched_group *sched_group_nodes[MAX_NUMNODES];
+
+static DEFINE_PER_CPU(struct sched_domain, allnodes_domains);
+static struct sched_group sched_group_allnodes[MAX_NUMNODES];
+
+static int __devinit cpu_to_allnodes_group(int cpu)
+{
+	return cpu_to_node(cpu);
+}
+#endif
+
+/*
+ * Set up scheduler domains and groups.  Callers must hold the hotplug lock.
+ */
+void __devinit arch_init_sched_domains(void)
+{
+	int i;
+	cpumask_t cpu_default_map;
+
+	/*
+	 * Setup mask for cpus without special case scheduling requirements.
+	 * For now this just excludes isolated cpus, but could be used to
+	 * exclude other special cases in the future.
+	 */
+	cpus_complement(cpu_default_map, cpu_isolated_map);
+	cpus_and(cpu_default_map, cpu_default_map, cpu_online_map);
+
+	/*
+	 * Set up domains. Isolated domains just stay on the dummy domain.
+	 */
+	for_each_cpu_mask(i, cpu_default_map) {
+		int node = cpu_to_node(i);
+		int group;
+		struct sched_domain *sd = NULL, *p;
+		cpumask_t nodemask = node_to_cpumask(node);
+
+		cpus_and(nodemask, nodemask, cpu_default_map);
+
+#ifdef CONFIG_NUMA
+		if (num_online_cpus()
+				> SD_NODES_PER_DOMAIN*cpus_weight(nodemask)) {
+			sd = &per_cpu(allnodes_domains, i);
+			*sd = SD_ALLNODES_INIT;
+			sd->span = cpu_default_map;
+			group = cpu_to_allnodes_group(i);
+			sd->groups = &sched_group_allnodes[group];
+			p = sd;
+		} else
+			p = NULL;
+
+		sd = &per_cpu(node_domains, i);
+		*sd = SD_NODE_INIT;
+		sd->span = sched_domain_node_span(node);
+		sd->parent = p;
+		cpus_and(sd->span, sd->span, cpu_default_map);
+#endif
+
+		p = sd;
+		sd = &per_cpu(phys_domains, i);
+		group = cpu_to_phys_group(i);
+		*sd = SD_CPU_INIT;
+		sd->span = nodemask;
+		sd->parent = p;
+		sd->groups = &sched_group_phys[group];
+
+#ifdef CONFIG_SCHED_SMT
+		p = sd;
+		sd = &per_cpu(cpu_domains, i);
+		group = cpu_to_cpu_group(i);
+		*sd = SD_SIBLING_INIT;
+		sd->span = cpu_sibling_map[i];
+		cpus_and(sd->span, sd->span, cpu_default_map);
+		sd->parent = p;
+		sd->groups = &sched_group_cpus[group];
+#endif
+	}
+
+#ifdef CONFIG_SCHED_SMT
+	/* Set up CPU (sibling) groups */
+	for_each_cpu_mask(i, cpu_default_map) {
+		cpumask_t this_sibling_map = cpu_sibling_map[i];
+		cpus_and(this_sibling_map, this_sibling_map, cpu_default_map);
+		if (i != first_cpu(this_sibling_map))
+			continue;
+
+		init_sched_build_groups(sched_group_cpus, this_sibling_map,
+						&cpu_to_cpu_group);
+	}
+#endif
+
+	/* Set up physical groups */
+	for (i = 0; i < MAX_NUMNODES; i++) {
+		cpumask_t nodemask = node_to_cpumask(i);
+
+		cpus_and(nodemask, nodemask, cpu_default_map);
+		if (cpus_empty(nodemask))
+			continue;
+
+		init_sched_build_groups(sched_group_phys, nodemask,
+						&cpu_to_phys_group);
+	}
+
+#ifdef CONFIG_NUMA
+	init_sched_build_groups(sched_group_allnodes, cpu_default_map,
+				&cpu_to_allnodes_group);
+
+	for (i = 0; i < MAX_NUMNODES; i++) {
+		/* Set up node groups */
+		struct sched_group *sg, *prev;
+		cpumask_t nodemask = node_to_cpumask(i);
+		cpumask_t domainspan;
+		cpumask_t covered = CPU_MASK_NONE;
+		int j;
+
+		cpus_and(nodemask, nodemask, cpu_default_map);
+		if (cpus_empty(nodemask))
+			continue;
+
+		domainspan = sched_domain_node_span(i);
+		cpus_and(domainspan, domainspan, cpu_default_map);
+
+		sg = kmalloc(sizeof(struct sched_group), GFP_KERNEL);
+		sched_group_nodes[i] = sg;
+		for_each_cpu_mask(j, nodemask) {
+			struct sched_domain *sd;
+			sd = &per_cpu(node_domains, j);
+			sd->groups = sg;
+			if (sd->groups == NULL) {
+				/* Turn off balancing if we have no groups */
+				sd->flags = 0;
+			}
+		}
+		if (!sg) {
+			printk(KERN_WARNING
+			"Can not alloc domain group for node %d\n", i);
+			continue;
+		}
+		sg->cpu_power = 0;
+		sg->cpumask = nodemask;
+		cpus_or(covered, covered, nodemask);
+		prev = sg;
+
+		for (j = 0; j < MAX_NUMNODES; j++) {
+			cpumask_t tmp, notcovered;
+			int n = (i + j) % MAX_NUMNODES;
+
+			cpus_complement(notcovered, covered);
+			cpus_and(tmp, notcovered, cpu_default_map);
+			cpus_and(tmp, tmp, domainspan);
+			if (cpus_empty(tmp))
+				break;
+
+			nodemask = node_to_cpumask(n);
+			cpus_and(tmp, tmp, nodemask);
+			if (cpus_empty(tmp))
+				continue;
+
+			sg = kmalloc(sizeof(struct sched_group), GFP_KERNEL);
+			if (!sg) {
+				printk(KERN_WARNING
+				"Can not alloc domain group for node %d\n", j);
+				break;
+			}
+			sg->cpu_power = 0;
+			sg->cpumask = tmp;
+			cpus_or(covered, covered, tmp);
+			prev->next = sg;
+			prev = sg;
+		}
+		prev->next = sched_group_nodes[i];
+	}
+#endif
+
+	/* Calculate CPU power for physical packages and nodes */
+	for_each_cpu_mask(i, cpu_default_map) {
+		int power;
+		struct sched_domain *sd;
+#ifdef CONFIG_SCHED_SMT
+		sd = &per_cpu(cpu_domains, i);
+		power = SCHED_LOAD_SCALE;
+		sd->groups->cpu_power = power;
+#endif
+
+		sd = &per_cpu(phys_domains, i);
+		power = SCHED_LOAD_SCALE + SCHED_LOAD_SCALE *
+				(cpus_weight(sd->groups->cpumask)-1) / 10;
+		sd->groups->cpu_power = power;
+
+#ifdef CONFIG_NUMA
+		sd = &per_cpu(allnodes_domains, i);
+		if (sd->groups) {
+			power = SCHED_LOAD_SCALE + SCHED_LOAD_SCALE *
+				(cpus_weight(sd->groups->cpumask)-1) / 10;
+			sd->groups->cpu_power = power;
+		}
+#endif
+	}
+
+#ifdef CONFIG_NUMA
+	for (i = 0; i < MAX_NUMNODES; i++) {
+		struct sched_group *sg = sched_group_nodes[i];
+		int j;
+
+		if (sg == NULL)
+			continue;
+next_sg:
+		for_each_cpu_mask(j, sg->cpumask) {
+			struct sched_domain *sd;
+			int power;
+
+			sd = &per_cpu(phys_domains, j);
+			if (j != first_cpu(sd->groups->cpumask)) {
+				/*
+				 * Only add "power" once for each
+				 * physical package.
+				 */
+				continue;
+			}
+			power = SCHED_LOAD_SCALE + SCHED_LOAD_SCALE *
+				(cpus_weight(sd->groups->cpumask)-1) / 10;
+
+			sg->cpu_power += power;
+		}
+		sg = sg->next;
+		if (sg != sched_group_nodes[i])
+			goto next_sg;
+	}
+#endif
+
+	/* Attach the domains */
+	for_each_online_cpu(i) {
+		struct sched_domain *sd;
+#ifdef CONFIG_SCHED_SMT
+		sd = &per_cpu(cpu_domains, i);
+#else
+		sd = &per_cpu(phys_domains, i);
+#endif
+		cpu_attach_domain(sd, i);
+	}
+}
+
+void __devinit arch_destroy_sched_domains(void)
+{
+#ifdef CONFIG_NUMA
+	int i;
+	for (i = 0; i < MAX_NUMNODES; i++) {
+		struct sched_group *oldsg, *sg = sched_group_nodes[i];
+		if (sg == NULL)
+			continue;
+		sg = sg->next;
+next_sg:
+		oldsg = sg;
+		sg = sg->next;
+		kfree(oldsg);
+		if (oldsg != sched_group_nodes[i])
+			goto next_sg;
+		sched_group_nodes[i] = NULL;
+	}
+#endif
+}
+
diff -Nru a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c
--- a/arch/ia64/kernel/efi.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ia64/kernel/efi.c	2004-12-24 13:36:17 -08:00
@@ -28,6 +28,7 @@
 
 #include <asm/io.h>
 #include <asm/kregs.h>
+#include <asm/meminit.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/mca.h>
@@ -324,12 +325,12 @@
 		 * [granule_addr - first_non_wb_addr) is guaranteed to
 		 * be contiguous WB memory.
 		 */
-		granule_addr = md->phys_addr & ~(IA64_GRANULE_SIZE - 1);
+		granule_addr = GRANULEROUNDDOWN(md->phys_addr);
 		first_non_wb_addr = max(first_non_wb_addr, granule_addr);
 
 		if (first_non_wb_addr < md->phys_addr) {
 			trim_bottom(md, granule_addr + IA64_GRANULE_SIZE);
-			granule_addr = md->phys_addr & ~(IA64_GRANULE_SIZE - 1);
+			granule_addr = GRANULEROUNDDOWN(md->phys_addr);
 			first_non_wb_addr = max(first_non_wb_addr, granule_addr);
 		}
 
@@ -343,24 +344,36 @@
 				break;		/* non-WB or hole */
 		}
 
-		last_granule_addr = first_non_wb_addr & ~(IA64_GRANULE_SIZE - 1);
+		last_granule_addr = GRANULEROUNDDOWN(first_non_wb_addr);
 		if (last_granule_addr < md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT))
 			trim_top(md, last_granule_addr);
 
 		if (is_available_memory(md)) {
-			if (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) > max_addr) {
-				if (md->phys_addr > max_addr)
+			if (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) >= max_addr) {
+				if (md->phys_addr >= max_addr)
 					continue;
 				md->num_pages = (max_addr - md->phys_addr) >> EFI_PAGE_SHIFT;
+				first_non_wb_addr = max_addr;
 			}
 
 			if (total_mem >= mem_limit)
 				continue;
-			total_mem += (md->num_pages << EFI_PAGE_SHIFT);
-			if (total_mem > mem_limit) {
-				md->num_pages -= ((total_mem - mem_limit) >> EFI_PAGE_SHIFT);
-				max_addr = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
+
+			if (total_mem + (md->num_pages << EFI_PAGE_SHIFT) > mem_limit) {
+				unsigned long limit_addr = md->phys_addr;
+
+				limit_addr += mem_limit - total_mem;
+				limit_addr = GRANULEROUNDDOWN(limit_addr);
+
+				if (md->phys_addr > limit_addr)
+					continue;
+
+				md->num_pages = (limit_addr - md->phys_addr) >>
+				                EFI_PAGE_SHIFT;
+				first_non_wb_addr = max_addr = md->phys_addr +
+				              (md->num_pages << EFI_PAGE_SHIFT);
 			}
+			total_mem += (md->num_pages << EFI_PAGE_SHIFT);
 
 			if (md->num_pages == 0)
 				continue;
@@ -495,13 +508,13 @@
 	for (cp = saved_command_line; *cp; ) {
 		if (memcmp(cp, "mem=", 4) == 0) {
 			cp += 4;
-			mem_limit = memparse(cp, &end) - 2;
+			mem_limit = memparse(cp, &end);
 			if (end != cp)
 				break;
 			cp = end;
 		} else if (memcmp(cp, "max_addr=", 9) == 0) {
 			cp += 9;
-			max_addr = memparse(cp, &end) - 1;
+			max_addr = GRANULEROUNDDOWN(memparse(cp, &end));
 			if (end != cp)
 				break;
 			cp = end;
diff -Nru a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
--- a/arch/ia64/kernel/entry.S	2004-12-24 13:36:31 -08:00
+++ b/arch/ia64/kernel/entry.S	2004-12-24 13:36:31 -08:00
@@ -1526,11 +1526,11 @@
 	data8 sys_mq_notify
 	data8 sys_mq_getsetattr
 	data8 sys_ni_syscall			// reserved for kexec_load
-	data8 sys_ni_syscall
-	data8 sys_ni_syscall			// 1270
-	data8 sys_ni_syscall
-	data8 sys_ni_syscall
-	data8 sys_ni_syscall
+	data8 sys_ni_syscall			// reserved for vserver
+	data8 sys_waitid			// 1270
+	data8 sys_add_key
+	data8 sys_request_key
+	data8 sys_keyctl
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall			// 1275
 	data8 sys_ni_syscall
diff -Nru a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S
--- a/arch/ia64/kernel/fsys.S	2004-12-24 13:37:43 -08:00
+++ b/arch/ia64/kernel/fsys.S	2004-12-24 13:37:43 -08:00
@@ -177,7 +177,7 @@
 	// r11 = preserved: saved ar.pfs
 	// r12 = preserved: memory stack
 	// r13 = preserved: thread pointer
-	// r14 = debug pointer / usable
+	// r14 = address of mask / mask
 	// r15 = preserved: system call number
 	// r16 = preserved: current task pointer
 	// r17 = wall to monotonic use
@@ -226,7 +226,6 @@
 	add r10 = IA64_TIME_INTERPOLATOR_ADDRESS_OFFSET,r20
 	extr r3 = r21,32,32	// time_interpolator->nsec_per_cyc
 	extr r8 = r21,0,16	// time_interpolator->source
-	nop.i 123
 	cmp.ne p6, p0 = 0, r2	// Fallback if work is scheduled
 (p6)    br.cond.spnt.many fsys_fallback_syscall
 	;;
@@ -257,17 +256,20 @@
 	add r24 = IA64_TIME_INTERPOLATOR_OFFSET_OFFSET,r20
 (p15)	ld8 r17 = [r19],IA64_TIMESPEC_TV_NSEC_OFFSET
  	ld8 r9 = [r27],IA64_TIMESPEC_TV_NSEC_OFFSET
-	nop.i 123
+	add r14 = IA64_TIME_INTERPOLATOR_MASK_OFFSET, r20
 	;;
 	ld8 r18 = [r24]		// time_interpolator->offset
 	ld8 r8 = [r27],-IA64_TIMESPEC_TV_NSEC_OFFSET	// xtime.tv_nsec
 (p13)	sub r3 = r25,r2	// Diff needed before comparison (thanks davidm)
 	;;
+	ld8 r14 = [r14]		// time_interpolator->mask
 (p13)	cmp.gt.unc p6,p7 = r3,r0	// check if it is less than last. p6,p7 cleared
 	sub r10 = r2,r26	// current_counter - last_counter
 	;;
 (p6)	sub r10 = r25,r26	// time we got was less than last_cycle
 (p7)	mov ar.ccv = r25	// more than last_cycle. Prep for cmpxchg
+	;;
+	and r10 = r10,r14	// Apply mask
 	;;
 	setf.sig f8 = r10
 	nop.i 123
diff -Nru a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
--- a/arch/ia64/kernel/iosapic.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ia64/kernel/iosapic.c	2004-12-24 13:36:48 -08:00
@@ -521,7 +521,12 @@
 			goto skip_numa_setup;
 
 		cpu_mask = node_to_cpumask(iosapic_lists[iosapic_index].node);
-		
+
+		for_each_cpu_mask(numa_cpu, cpu_mask) {
+			if (!cpu_online(numa_cpu))
+				cpu_clear(numa_cpu, cpu_mask);
+		}
+
 		num_cpus = cpus_weight(cpu_mask);
 
 		if (!num_cpus)
diff -Nru a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
--- a/arch/ia64/kernel/irq.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ia64/kernel/irq.c	2004-12-24 13:37:19 -08:00
@@ -43,13 +43,13 @@
 #include <linux/seq_file.h>
 #include <linux/kallsyms.h>
 #include <linux/notifier.h>
+#include <linux/bitops.h>
 
 #include <asm/atomic.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
 #include <asm/smp.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
@@ -215,11 +215,6 @@
 skip:
 		spin_unlock_irqrestore(&idesc->lock, flags);
 	} else if (i == NR_IRQS) {
-		seq_puts(p, "NMI: ");
-		for (j = 0; j < NR_CPUS; j++)
-			if (cpu_online(j))
-				seq_printf(p, "%10u ", nmi_count(j));
-		seq_putc(p, '\n');
 #ifdef CONFIG_X86_LOCAL_APIC
 		seq_puts(p, "LOC: ");
 		for (j = 0; j < NR_CPUS; j++)
diff -Nru a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
--- a/arch/ia64/kernel/irq_ia64.c	2004-12-24 13:36:47 -08:00
+++ b/arch/ia64/kernel/irq_ia64.c	2004-12-24 13:36:47 -08:00
@@ -30,8 +30,8 @@
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/threads.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/delay.h>
 #include <asm/intrinsics.h>
 #include <asm/io.h>
diff -Nru a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S
--- a/arch/ia64/kernel/ivt.S	2004-12-24 13:36:19 -08:00
+++ b/arch/ia64/kernel/ivt.S	2004-12-24 13:36:19 -08:00
@@ -852,7 +852,7 @@
 	add r17=PT(R11),r1			// initialize second base pointer
 	;;
 	alloc r19=ar.pfs,8,0,0,0		// ensure in0-in7 are writable
-	st8 [r16]=r29,PT(CR_IFS)-PT(CR_IPSR)	// save cr.ipsr
+	st8 [r16]=r29,PT(AR_PFS)-PT(CR_IPSR)	// save cr.ipsr
 	tnat.nz p8,p0=in0
 
 	st8.spill [r17]=r11,PT(CR_IIP)-PT(R11)	// save r11
@@ -860,31 +860,31 @@
 (pKStk)	mov r18=r0				// make sure r18 isn't NaT
 	;;
 
+	st8 [r16]=r26,PT(CR_IFS)-PT(AR_PFS)	// save ar.pfs
 	st8 [r17]=r28,PT(AR_UNAT)-PT(CR_IIP)	// save cr.iip
 	mov r28=b0				// save b0 (2 cyc)
-(p8)	mov in0=-1
 	;;
 
-	st8 [r16]=r0,PT(AR_PFS)-PT(CR_IFS)	// clear cr.ifs
 	st8 [r17]=r25,PT(AR_RSC)-PT(AR_UNAT)	// save ar.unat
-(p9)	mov in1=-1
+	dep r19=0,r19,38,26			// clear all bits but 0..37 [I0]
+(p8)	mov in0=-1
 	;;
 
-	st8 [r16]=r26,PT(AR_RNAT)-PT(AR_PFS)	// save ar.pfs
+	st8 [r16]=r19,PT(AR_RNAT)-PT(CR_IFS)	// store ar.pfs.pfm in cr.ifs
 	st8 [r17]=r27,PT(AR_BSPSTORE)-PT(AR_RSC)// save ar.rsc
-	tnat.nz p10,p0=in2
+(p9)	mov in1=-1
 
 (pUStk) sub r18=r18,r22				// r18=RSE.ndirty*8
 	tbit.nz p15,p0=r29,IA64_PSR_I_BIT
-	tnat.nz p11,p0=in3
+	tnat.nz p10,p0=in2
 	;;
 (pKStk) adds r16=PT(PR)-PT(AR_RNAT),r16		// skip over ar_rnat field
 (pKStk) adds r17=PT(B0)-PT(AR_BSPSTORE),r17	// skip over ar_bspstore field
+	tnat.nz p11,p0=in3
+	;;
 (p10)	mov in2=-1
-
+	tnat.nz p12,p0=in4				// [I0]
 (p11)	mov in3=-1
-	tnat.nz p12,p0=in4
-	tnat.nz p13,p0=in5
 	;;
 (pUStk) st8 [r16]=r24,PT(PR)-PT(AR_RNAT)	// save ar.rnat
 (pUStk) st8 [r17]=r23,PT(B0)-PT(AR_BSPSTORE)	// save ar.bspstore
@@ -892,28 +892,29 @@
 	;;
 	st8 [r16]=r31,PT(LOADRS)-PT(PR)		// save predicates
 	st8 [r17]=r28,PT(R1)-PT(B0)		// save b0
-(p12)	mov in4=-1
+	tnat.nz p13,p0=in5				// [I0]
 	;;
 	st8 [r16]=r18,PT(R12)-PT(LOADRS)	// save ar.rsc value for "loadrs"
 	st8.spill [r17]=r20,PT(R13)-PT(R1)	// save original r1
-(p13)	mov in5=-1
+(p12)	mov in4=-1
 	;;
 
 .mem.offset 0,0; st8.spill [r16]=r12,PT(AR_FPSR)-PT(R12)	// save r12
 .mem.offset 8,0; st8.spill [r17]=r13,PT(R15)-PT(R13)		// save r13
-	tnat.nz p14,p0=in6
+(p13)	mov in5=-1
 	;;
 	st8 [r16]=r21,PT(R8)-PT(AR_FPSR)	// save ar.fpsr
 	st8.spill [r17]=r15			// save r15
-	tnat.nz p8,p0=in7
+	tnat.nz p14,p0=in6
 	;;
 	stf8 [r16]=f1		// ensure pt_regs.r8 != 0 (see handle_syscall_error)
 	adds r12=-16,r1		// switch to kernel memory stack (with 16 bytes of scratch)
-(p14)	mov in6=-1
+	tnat.nz p8,p0=in7
 
 	mov r13=r2				// establish `current'
 	movl r1=__gp				// establish kernel global pointer
 	;;
+(p14)	mov in6=-1
 (p8)	mov in7=-1
 	tnat.nz p9,p0=r15
 
diff -Nru a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
--- a/arch/ia64/kernel/mca.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ia64/kernel/mca.c	2004-12-24 13:36:48 -08:00
@@ -593,7 +593,7 @@
 {
 	cmcv_reg_t	cmcv;
 
-	cmcv = (cmcv_reg_t)ia64_getreg(_IA64_REG_CR_CMCV);
+	cmcv.cmcv_regval = ia64_getreg(_IA64_REG_CR_CMCV);
 
 	cmcv.cmcv_mask = 1; /* Mask/disable interrupt */
 	ia64_setreg(_IA64_REG_CR_CMCV, cmcv.cmcv_regval);
@@ -620,7 +620,7 @@
 {
 	cmcv_reg_t	cmcv;
 
-	cmcv = (cmcv_reg_t)ia64_getreg(_IA64_REG_CR_CMCV);
+	cmcv.cmcv_regval = ia64_getreg(_IA64_REG_CR_CMCV);
 
 	cmcv.cmcv_mask = 0; /* Unmask/enable interrupt */
 	ia64_setreg(_IA64_REG_CR_CMCV, cmcv.cmcv_regval);
@@ -686,6 +686,7 @@
 			irr = ia64_getreg(_IA64_REG_CR_IRR3);
 			break;
 		}
+		cpu_relax();
 	} while (!(irr & (1UL << irr_bit))) ;
 }
 
diff -Nru a/arch/ia64/kernel/mca_asm.S b/arch/ia64/kernel/mca_asm.S
--- a/arch/ia64/kernel/mca_asm.S	2004-12-24 13:37:19 -08:00
+++ b/arch/ia64/kernel/mca_asm.S	2004-12-24 13:37:19 -08:00
@@ -868,7 +868,7 @@
 
 
 GLOBAL_ENTRY(ia64_monarch_init_handler)
-
+	.prologue
 	// stash the information the SAL passed to os
 	SAL_TO_OS_MCA_HANDOFF_STATE_SAVE(r2)
 	;;
@@ -907,6 +907,7 @@
 	adds out0=16,sp				// out0 = pointer to pt_regs
 	;;
 	DO_SAVE_SWITCH_STACK
+	.body
 	adds out1=16,sp				// out0 = pointer to switch_stack
 
 	br.call.sptk.many rp=ia64_init_handler
diff -Nru a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
--- a/arch/ia64/kernel/perfmon.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ia64/kernel/perfmon.c	2004-12-24 13:37:19 -08:00
@@ -38,8 +38,8 @@
 #include <linux/pagemap.h>
 #include <linux/mount.h>
 #include <linux/version.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/errno.h>
 #include <asm/intrinsics.h>
 #include <asm/page.h>
@@ -572,12 +572,6 @@
 	ClearPageReserved(vmalloc_to_page((void*)a));
 }
 
-static inline int
-pfm_remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long phys_addr, unsigned long size, pgprot_t prot)
-{
-	return remap_page_range(vma, from, phys_addr, size, prot);
-}
-
 static inline unsigned long
 pfm_protect_ctx_ctxsw(pfm_context_t *x)
 {
@@ -805,18 +799,6 @@
 	DPRINT(("ctx=%p msgq reset\n", ctx));
 }
 
-
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the
- * area and marking the pages as reserved.
- */
-static inline unsigned long
-pfm_kvirt_to_pa(unsigned long adr)
-{
-	__u64 pa = ia64_tpa(adr);
-	return pa;
-}
-
 static void *
 pfm_rvmalloc(unsigned long size)
 {
@@ -1656,7 +1638,7 @@
 }
 
 /*
- * context is locked when coming here and interrupts are disabled
+ * interrupt cannot be masked when coming here
  */
 static inline int
 pfm_do_fasync(int fd, struct file *filp, pfm_context_t *ctx, int on)
@@ -2016,7 +1998,7 @@
 
 		/*
 		 * XXX: check for signals :
-		 * 	- ok of explicit close
+		 * 	- ok for explicit close
 		 * 	- not ok when coming from exit_files()
 		 */
       		schedule();
@@ -2244,14 +2226,14 @@
 static int
 pfm_remap_buffer(struct vm_area_struct *vma, unsigned long buf, unsigned long addr, unsigned long size)
 {
-	unsigned long page;
-
 	DPRINT(("CPU%d buf=0x%lx addr=0x%lx size=%ld\n", smp_processor_id(), buf, addr, size));
 
 	while (size > 0) {
-		page = pfm_kvirt_to_pa(buf);
+		unsigned long pfn = ia64_tpa(buf) >> PAGE_SHIFT;
 
-		if (pfm_remap_page_range(vma, addr, page, PAGE_SIZE, PAGE_READONLY)) return -ENOMEM;
+
+		if (remap_pfn_range(vma, addr, pfn, PAGE_SIZE, PAGE_READONLY))
+			return -ENOMEM;
 
 		addr  += PAGE_SIZE;
 		buf   += PAGE_SIZE;
@@ -2287,7 +2269,8 @@
 	 * if ((mm->total_vm << PAGE_SHIFT) + len> task->rlim[RLIMIT_AS].rlim_cur)
 	 * 	return -ENOMEM;
 	 */
-	if (size > task->rlim[RLIMIT_MEMLOCK].rlim_cur) return -ENOMEM;
+	if (size > task->signal->rlim[RLIMIT_MEMLOCK].rlim_cur)
+		return -ENOMEM;
 
 	/*
 	 * We do the easy to undo allocations first.
@@ -2312,10 +2295,6 @@
 
 	/*
 	 * partially initialize the vma for the sampling buffer
-	 *
-	 * The VM_DONTCOPY flag is very important as it ensures that the mapping
-	 * will never be inherited for any child process (via fork()) which is always
-	 * what we want.
 	 */
 	vma->vm_mm	     = mm;
 	vma->vm_flags	     = VM_READ| VM_MAYREAD |VM_RESERVED;
@@ -2345,6 +2324,7 @@
 		goto error;
 	}
 	vma->vm_end = vma->vm_start + size;
+	vma->vm_pgoff = vma->vm_start >> PAGE_SHIFT;
 
 	DPRINT(("aligned size=%ld, hdr=%p mapped @0x%lx\n", size, ctx->ctx_smpl_hdr, vma->vm_start));
 
@@ -2592,7 +2572,7 @@
 		return -EINVAL;
 	}
 
-	if (task->state == TASK_ZOMBIE) {
+	if (task->exit_state == EXIT_ZOMBIE) {
 		DPRINT(("cannot attach to  zombie task [%d]\n", task->pid));
 		return -EBUSY;
 	}
@@ -3077,11 +3057,12 @@
 #endif
 		}
 
-		DPRINT(("pmc[%u]=0x%lx loaded=%d access_pmu=%d all_pmcs=0x%lx used_pmds=0x%lx eventid=%ld smpl_pmds=0x%lx reset_pmds=0x%lx reloads_pmcs=0x%lx used_monitors=0x%lx ovfl_regs=0x%lx\n",
+		DPRINT(("pmc[%u]=0x%lx ld=%d apmu=%d flags=0x%x all_pmcs=0x%lx used_pmds=0x%lx eventid=%ld smpl_pmds=0x%lx reset_pmds=0x%lx reloads_pmcs=0x%lx used_monitors=0x%lx ovfl_regs=0x%lx\n",
 			  cnum,
 			  value,
 			  is_loaded,
 			  can_access_pmu,
+			  flags,
 			  ctx->ctx_all_pmcs[0],
 			  ctx->ctx_used_pmds[0],
 			  ctx->ctx_pmds[cnum].eventid,
@@ -3257,8 +3238,8 @@
 			}
 		}
 
-		DPRINT(("pmd[%u]=0x%lx loaded=%d access_pmu=%d, hw_value=0x%lx ctx_pmd=0x%lx  short_reset=0x%lx "
-			  "long_reset=0x%lx notify=%c used_pmds=0x%lx reset_pmds=0x%lx reload_pmds=0x%lx all_pmds=0x%lx ovfl_regs=0x%lx\n",
+		DPRINT(("pmd[%u]=0x%lx ld=%d apmu=%d, hw_value=0x%lx ctx_pmd=0x%lx  short_reset=0x%lx "
+			  "long_reset=0x%lx notify=%c seed=0x%lx mask=0x%lx used_pmds=0x%lx reset_pmds=0x%lx reload_pmds=0x%lx all_pmds=0x%lx ovfl_regs=0x%lx\n",
 			cnum,
 			value,
 			is_loaded,
@@ -3268,6 +3249,8 @@
 			ctx->ctx_pmds[cnum].short_reset,
 			ctx->ctx_pmds[cnum].long_reset,
 			PMC_OVFL_NOTIFY(ctx, cnum) ? 'Y':'N',
+			ctx->ctx_pmds[cnum].seed,
+			ctx->ctx_pmds[cnum].mask,
 			ctx->ctx_used_pmds[0],
 			ctx->ctx_pmds[cnum].reset_pmds[0],
 			ctx->ctx_reload_pmds[0],
@@ -3345,7 +3328,7 @@
 	}
 	expert_mode = pfm_sysctl.expert_mode; 
 
-	DPRINT(("loaded=%d access_pmu=%d ctx_state=%d\n",
+	DPRINT(("ld=%d apmu=%d ctx_state=%d\n",
 		is_loaded,
 		can_access_pmu,
 		state));
@@ -3885,7 +3868,7 @@
 
 			ctx->ctx_ibrs[rnum] = dbreg.val;
 
-			DPRINT(("write ibr%u=0x%lx used_ibrs=0x%x is_loaded=%d access_pmu=%d\n",
+			DPRINT(("write ibr%u=0x%lx used_ibrs=0x%x ld=%d apmu=%d\n",
 				rnum, dbreg.val, ctx->ctx_used_ibrs[0], is_loaded, can_access_pmu));
 		} else {
 			CTX_USED_DBR(ctx, rnum);
@@ -3896,7 +3879,7 @@
 			}
 			ctx->ctx_dbrs[rnum] = dbreg.val;
 
-			DPRINT(("write dbr%u=0x%lx used_dbrs=0x%x is_loaded=%d access_pmu=%d\n",
+			DPRINT(("write dbr%u=0x%lx used_dbrs=0x%x ld=%d apmu=%d\n",
 				rnum, dbreg.val, ctx->ctx_used_dbrs[0], is_loaded, can_access_pmu));
 		}
 	}
@@ -4995,26 +4978,14 @@
 static void
 pfm_context_force_terminate(pfm_context_t *ctx, struct pt_regs *regs)
 {
-	if (ctx->ctx_fl_system) {
-		printk(KERN_ERR "perfmon: pfm_context_force_terminate [%d] is system-wide\n", current->pid);
-		return;
-	}
-	/*
-	 * we stop the whole thing, we do no need to flush
-	 * we know we WERE masked
-	 */
-	pfm_clear_psr_up();
-	ia64_psr(regs)->up = 0;
-	ia64_psr(regs)->sp = 1;
+	int ret;
 
-	/*
-	 * disconnect the task from the context and vice-versa
-	 */
-	current->thread.pfm_context  = NULL;
-	current->thread.flags       &= ~IA64_THREAD_PM_VALID;
-	ctx->ctx_task = NULL;
+	DPRINT(("entering for [%d]\n", current->pid));
 
-	DPRINT(("context terminated\n"));
+	ret = pfm_context_unload(ctx, NULL, 0, regs);
+	if (ret) {
+		printk(KERN_ERR "pfm_context_force_terminate: [%d] unloaded failed with %d\n", current->pid, ret);
+	}
 
 	/*
 	 * and wakeup controlling task, indicating we are now disconnected
@@ -5074,6 +5045,18 @@
 
 	UNPROTECT_CTX(ctx, flags);
 
+	 /*
+	  * pfm_handle_work() is currently called with interrupts disabled.
+	  * The down_interruptible call may sleep, therefore we
+	  * must re-enable interrupts to avoid deadlocks. It is
+	  * safe to do so because this function is called ONLY
+	  * when returning to user level (PUStk=1), in which case
+	  * there is no risk of kernel stack overflow due to deep
+	  * interrupt nesting.
+	  */
+	BUG_ON(flags & IA64_PSR_I);
+	local_irq_enable();
+
 	DPRINT(("before block sleeping\n"));
 
 	/*
@@ -5084,6 +5067,12 @@
 
 	DPRINT(("after block sleeping ret=%d\n", ret));
 
+	/*
+	 * disable interrupts to restore state we had upon entering
+	 * this function
+	 */
+	local_irq_disable();
+
 	PROTECT_CTX(ctx, flags);
 
 	/*
@@ -5369,9 +5358,8 @@
 		if (ovfl_notify == 0) reset_pmds = ovfl_pmds;
 	}
 
-	DPRINT(("ovfl_pmds=0x%lx reset_pmds=0x%lx\n",
-		ovfl_pmds,
-		reset_pmds));
+	DPRINT_ovfl(("ovfl_pmds=0x%lx reset_pmds=0x%lx\n", ovfl_pmds, reset_pmds));
+
 	/*
 	 * reset the requested PMD registers using the short reset values
 	 */
@@ -5872,14 +5860,6 @@
 	}
 
 	/*
-	 * sanity check
-	 */
-	if (ctx->ctx_last_activation != GET_ACTIVATION()) {
-		pfm_unprotect_ctx_ctxsw(ctx, flags);
-		return;
-	}
-
-	/*
 	 * save current PSR: needed because we modify it
 	 */
 	ia64_srlz_d();
@@ -6374,6 +6354,9 @@
 	 * XXX: sampling situation is not taken into account here
 	 */
 	mask2 = ctx->ctx_used_pmds[0];
+
+	DPRINT(("is_self=%d ovfl_val=0x%lx mask2=0x%lx\n", is_self, ovfl_val, mask2));
+
 	for (i = 0; mask2; i++, mask2>>=1) {
 
 		/* skip non used pmds */
@@ -6412,7 +6395,7 @@
 			}
 		}
 
-		DPRINT(("[%d] is_self=%d ctx_pmd[%d]=0x%lx  pmd_val=0x%lx\n", task->pid, is_self, i, val, pmd_val));
+		DPRINT(("[%d] ctx_pmd[%d]=0x%lx  pmd_val=0x%lx\n", task->pid, i, val, pmd_val));
 
 		if (is_self) task->thread.pmds[i] = pmd_val;
 
diff -Nru a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
--- a/arch/ia64/kernel/process.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ia64/kernel/process.c	2004-12-24 13:36:48 -08:00
@@ -47,6 +47,8 @@
 
 void (*ia64_mark_idle)(int);
 
+unsigned long boot_option_idle_override = 0;
+EXPORT_SYMBOL(boot_option_idle_override);
 
 void
 ia64_do_show_stack (struct unw_frame_info *info, void *arg)
@@ -185,6 +187,8 @@
 	while (!need_resched())
 		if (pal_halt && !pmu_active)
 			safe_halt();
+		else
+			cpu_relax();
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
diff -Nru a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
--- a/arch/ia64/kernel/ptrace.c	2004-12-24 13:37:30 -08:00
+++ b/arch/ia64/kernel/ptrace.c	2004-12-24 13:37:30 -08:00
@@ -1,7 +1,7 @@
 /*
  * Kernel support for the ptrace() and syscall tracing interfaces.
  *
- * Copyright (C) 1999-2003 Hewlett-Packard Co
+ * Copyright (C) 1999-2004 Hewlett-Packard Co
  *	David Mosberger-Tang <davidm@hpl.hp.com>
  *
  * Derived from the x86 and Alpha versions.  Most of the code in here
@@ -304,7 +304,6 @@
 	long num_regs, nbits;
 	struct pt_regs *pt;
 	unsigned long cfm, *urbs_kargs;
-	struct unw_frame_info info;
 
 	pt = ia64_task_regs(task);
 	kbsp = (unsigned long *) sw->ar_bspstore;
@@ -316,11 +315,8 @@
 		 * If entered via syscall, don't allow user to set rnat bits
 		 * for syscall args.
 		 */
-		unw_init_from_blocked_task(&info,task);
-		if (unw_unwind_to_user(&info) == 0) {
-			unw_get_cfm(&info,&cfm);
-			urbs_kargs = ia64_rse_skip_regs(urbs_end,-(cfm & 0x7f));
-		}
+		cfm = pt->cr_ifs;
+		urbs_kargs = ia64_rse_skip_regs(urbs_end, -(cfm & 0x7f));
 	}
 
 	if (urbs_kargs >= urnat_addr)
@@ -480,27 +476,18 @@
 unsigned long
 ia64_get_user_rbs_end (struct task_struct *child, struct pt_regs *pt, unsigned long *cfmp)
 {
-	unsigned long *krbs, *bspstore, cfm;
-	struct unw_frame_info info;
+	unsigned long *krbs, *bspstore, cfm = pt->cr_ifs;
 	long ndirty;
 
 	krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
 	bspstore = (unsigned long *) pt->ar_bspstore;
 	ndirty = ia64_rse_num_regs(krbs, krbs + (pt->loadrs >> 19));
-	cfm = pt->cr_ifs & ~(1UL << 63);
 
-	if (in_syscall(pt)) {
-		/*
-		 * If bit 63 of cr.ifs is cleared, the kernel was entered via a system
-		 * call and we need to recover the CFM that existed on entry to the
-		 * kernel by unwinding the kernel stack.
-		 */
-		unw_init_from_blocked_task(&info, child);
-		if (unw_unwind_to_user(&info) == 0) {
-			unw_get_cfm(&info, &cfm);
-			ndirty += (cfm & 0x7f);
-		}
-	}
+	if (in_syscall(pt))
+		ndirty += (cfm & 0x7f);
+	else
+		cfm &= ~(1UL << 63);	/* clear valid bit */
+
 	if (cfmp)
 		*cfmp = cfm;
 	return (unsigned long) ia64_rse_skip_regs(bspstore, ndirty);
@@ -1422,7 +1409,7 @@
 		 * sigkill.  Perhaps it should be put in the status
 		 * that it wants to exit.
 		 */
-		if (child->state == TASK_ZOMBIE)		/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)		/* already dead */
 			goto out_tsk;
 		child->exit_code = SIGKILL;
 
diff -Nru a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
--- a/arch/ia64/kernel/setup.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ia64/kernel/setup.c	2004-12-24 13:36:18 -08:00
@@ -258,25 +258,6 @@
 	num_io_spaces = 1;
 }
 
-#ifdef CONFIG_SERIAL_8250_CONSOLE
-static void __init
-setup_serial_legacy (void)
-{
-	struct uart_port port;
-	unsigned int i, iobase[] = {0x3f8, 0x2f8};
-
-	printk(KERN_INFO "Registering legacy COM ports for serial console\n");
-	memset(&port, 0, sizeof(port));
-	port.iotype = SERIAL_IO_PORT;
-	port.uartclk = BASE_BAUD * 16;
-	for (i = 0; i < ARRAY_SIZE(iobase); i++) {
-		port.line = i;
-		port.iobase = iobase[i];
-		early_serial_setup(&port);
-	}
-}
-#endif
-
 /**
  * early_console_setup - setup debugging console
  *
@@ -287,19 +268,36 @@
  * Returns non-zero if a console couldn't be setup.
  */
 static inline int __init
-early_console_setup (void)
+early_console_setup (char *cmdline)
 {
 #ifdef CONFIG_SERIAL_SGI_L1_CONSOLE
 	{
 		extern int sn_serial_console_early_setup(void);
-		if(!sn_serial_console_early_setup())
+		if (!sn_serial_console_early_setup())
 			return 0;
 	}
 #endif
+#ifdef CONFIG_EFI_PCDP
+	if (!efi_setup_pcdp_console(cmdline))
+		return 0;
+#endif
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+	if (!early_serial_console_init(cmdline))
+		return 0;
+#endif
 
 	return -1;
 }
 
+static inline void
+mark_bsp_online (void)
+{
+#ifdef CONFIG_SMP
+	/* If we register an early console, allow CPU 0 to printk */
+	cpu_set(smp_processor_id(), cpu_online_map);
+#endif
+}
+
 void __init
 setup_arch (char **cmdline_p)
 {
@@ -317,11 +315,8 @@
 	machvec_init(acpi_get_sysname());
 #endif
 
-#ifdef CONFIG_SMP
-	/* If we register an early console, allow CPU 0 to printk */
-	if (!early_console_setup())
-		cpu_set(smp_processor_id(), cpu_online_map);
-#endif
+	if (early_console_setup(*cmdline_p) == 0)
+		mark_bsp_online();
 
 #ifdef CONFIG_ACPI_BOOT
 	/* Initialize the ACPI boot-time table parser */
@@ -348,13 +343,6 @@
 
 #ifdef CONFIG_ACPI_BOOT
 	acpi_boot_init();
-#endif
-#ifdef CONFIG_EFI_PCDP
-	efi_setup_pcdp_console(*cmdline_p);
-#endif
-#ifdef CONFIG_SERIAL_8250_CONSOLE
-	if (!efi.hcdp)
-		setup_serial_legacy();
 #endif
 
 #ifdef CONFIG_VT
diff -Nru a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
--- a/arch/ia64/kernel/signal.c	2004-12-24 13:36:59 -08:00
+++ b/arch/ia64/kernel/signal.c	2004-12-24 13:36:59 -08:00
@@ -290,12 +290,10 @@
 
 	if (on_sig_stack((unsigned long) sc))
 		flags |= IA64_SC_FLAG_ONSTACK;
-	if ((ifs & (1UL << 63)) == 0) {
-		/* if cr_ifs isn't valid, we got here through a syscall */
+	if ((ifs & (1UL << 63)) == 0)
+		/* if cr_ifs doesn't have the valid bit set, we got here through a syscall */
 		flags |= IA64_SC_FLAG_IN_SYSCALL;
-		cfm = scr->ar_pfs & ((1UL << 38) - 1);
-	} else
-		cfm = ifs & ((1UL << 38) - 1);
+	cfm = ifs & ((1UL << 38) - 1);
 	ia64_flush_fph(current);
 	if ((current->thread.flags & IA64_THREAD_FPH_VALID)) {
 		flags |= IA64_SC_FLAG_FPH_VALID;
diff -Nru a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
--- a/arch/ia64/kernel/smp.c	2004-12-24 13:37:30 -08:00
+++ b/arch/ia64/kernel/smp.c	2004-12-24 13:37:30 -08:00
@@ -29,9 +29,9 @@
 #include <linux/cache.h>
 #include <linux/delay.h>
 #include <linux/efi.h>
+#include <linux/bitops.h>
 
 #include <asm/atomic.h>
-#include <asm/bitops.h>
 #include <asm/current.h>
 #include <asm/delay.h>
 #include <asm/machvec.h>
@@ -290,11 +290,11 @@
 
 	/* Wait for response */
 	while (atomic_read(&data.started) != cpus)
-		barrier();
+		cpu_relax();
 
 	if (wait)
 		while (atomic_read(&data.finished) != cpus)
-			barrier();
+			cpu_relax();
 	call_data = NULL;
 
 	spin_unlock_bh(&call_lock);
@@ -349,11 +349,11 @@
 
 	/* Wait for response */
 	while (atomic_read(&data.started) != cpus)
-		barrier();
+		cpu_relax();
 
 	if (wait)
 		while (atomic_read(&data.finished) != cpus)
-			barrier();
+			cpu_relax();
 	call_data = NULL;
 
 	spin_unlock(&call_lock);
diff -Nru a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
--- a/arch/ia64/kernel/smpboot.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ia64/kernel/smpboot.c	2004-12-24 13:36:31 -08:00
@@ -29,9 +29,9 @@
 #include <linux/spinlock.h>
 #include <linux/efi.h>
 #include <linux/percpu.h>
+#include <linux/bitops.h>
 
 #include <asm/atomic.h>
-#include <asm/bitops.h>
 #include <asm/cache.h>
 #include <asm/current.h>
 #include <asm/delay.h>
diff -Nru a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
--- a/arch/ia64/kernel/sys_ia64.c	2004-12-24 13:36:59 -08:00
+++ b/arch/ia64/kernel/sys_ia64.c	2004-12-24 13:36:59 -08:00
@@ -138,7 +138,7 @@
 		goto out;
 
 	/* Check against rlimit.. */
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
 		goto out;
 
diff -Nru a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
--- a/arch/ia64/kernel/time.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ia64/kernel/time.c	2004-12-24 13:36:31 -08:00
@@ -45,7 +45,11 @@
 
 #endif
 
-static struct time_interpolator itc_interpolator;
+static struct time_interpolator itc_interpolator = {
+	.shift = 16,
+	.mask = 0xffffffffffffffffLL,
+	.source = TIME_SOURCE_CPU
+};
 
 static irqreturn_t
 timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
@@ -67,14 +71,8 @@
 	profile_tick(CPU_PROFILING, regs);
 
 	while (1) {
-#ifdef CONFIG_SMP
-		/*
-		 * For UP, this is done in do_timer().  Weird, but
-		 * fixing that would require updates to all
-		 * platforms.
-		 */
 		update_process_times(user_mode(regs));
-#endif
+
 		new_itm += local_cpu_data->itm_delta;
 
 		if (smp_processor_id() == TIME_KEEPER_ID) {
@@ -192,17 +190,20 @@
 		itc_ratio.den = 1;	/* avoid division by zero */
 
 	itc_freq = (platform_base_freq*itc_ratio.num)/itc_ratio.den;
-	if (platform_base_drift != -1)
-		itc_drift = platform_base_drift*itc_ratio.num/itc_ratio.den;
-	else
-		itc_drift = -1;
 
 	local_cpu_data->itm_delta = (itc_freq + HZ/2) / HZ;
 	printk(KERN_DEBUG "CPU %d: base freq=%lu.%03luMHz, ITC ratio=%lu/%lu, "
-	       "ITC freq=%lu.%03luMHz+/-%ldppm\n", smp_processor_id(),
+	       "ITC freq=%lu.%03luMHz", smp_processor_id(),
 	       platform_base_freq / 1000000, (platform_base_freq / 1000) % 1000,
-	       itc_ratio.num, itc_ratio.den, itc_freq / 1000000, (itc_freq / 1000) % 1000,
-	       itc_drift);
+	       itc_ratio.num, itc_ratio.den, itc_freq / 1000000, (itc_freq / 1000) % 1000);
+
+	if (platform_base_drift != -1) {
+		itc_drift = platform_base_drift*itc_ratio.num/itc_ratio.den;
+		printk("+/-%ldppm\n", itc_drift);
+	} else {
+		itc_drift = -1;
+		printk("\n");
+	}
 
 	local_cpu_data->proc_freq = (platform_base_freq*proc_ratio.num)/proc_ratio.den;
 	local_cpu_data->itc_freq = itc_freq;
@@ -212,9 +213,7 @@
 
 	if (!(sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)) {
 		itc_interpolator.frequency = local_cpu_data->itc_freq;
-		itc_interpolator.shift = 16;
 		itc_interpolator.drift = itc_drift;
-		itc_interpolator.source = TIME_SOURCE_CPU;
 #ifdef CONFIG_SMP
 		/* On IA64 in an SMP configuration ITCs are never accurately synchronized.
 		 * Jitter compensation requires a cmpxchg which may limit
@@ -228,7 +227,6 @@
 		 */
 		if (!nojitter) itc_interpolator.jitter = 1;
 #endif
-		itc_interpolator.addr = NULL;
 		register_time_interpolator(&itc_interpolator);
 	}
 
diff -Nru a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c
--- a/arch/ia64/kernel/unwind.c	2004-12-24 13:37:43 -08:00
+++ b/arch/ia64/kernel/unwind.c	2004-12-24 13:37:43 -08:00
@@ -1269,7 +1269,6 @@
 {
 	struct unw_script *script, *prev, *tmp;
 	unw_hash_index_t index;
-	unsigned long flags;
 	unsigned short head;
 
 	STAT(++unw.stat.script.news);
@@ -1278,13 +1277,9 @@
 	 * Can't (easily) use cmpxchg() here because of ABA problem
 	 * that is intrinsic in cmpxchg()...
 	 */
-	spin_lock_irqsave(&unw.lock, flags);
-	{
-		head = unw.lru_head;
-		script = unw.cache + head;
-		unw.lru_head = script->lru_chain;
-	}
-	spin_unlock(&unw.lock);
+	head = unw.lru_head;
+	script = unw.cache + head;
+	unw.lru_head = script->lru_chain;
 
 	/*
 	 * We'd deadlock here if we interrupted a thread that is holding a read lock on
@@ -1295,43 +1290,39 @@
 	if (!write_trylock(&script->lock))
 		return NULL;
 
-	spin_lock(&unw.lock);
-	{
-		/* re-insert script at the tail of the LRU chain: */
-		unw.cache[unw.lru_tail].lru_chain = head;
-		unw.lru_tail = head;
-
-		/* remove the old script from the hash table (if it's there): */
-		if (script->ip) {
-			index = hash(script->ip);
-			tmp = unw.cache + unw.hash[index];
-			prev = NULL;
-			while (1) {
-				if (tmp == script) {
-					if (prev)
-						prev->coll_chain = tmp->coll_chain;
-					else
-						unw.hash[index] = tmp->coll_chain;
-					break;
-				} else
-					prev = tmp;
-				if (tmp->coll_chain >= UNW_CACHE_SIZE)
-				/* old script wasn't in the hash-table */
-					break;
-				tmp = unw.cache + tmp->coll_chain;
-			}
+	/* re-insert script at the tail of the LRU chain: */
+	unw.cache[unw.lru_tail].lru_chain = head;
+	unw.lru_tail = head;
+
+	/* remove the old script from the hash table (if it's there): */
+	if (script->ip) {
+		index = hash(script->ip);
+		tmp = unw.cache + unw.hash[index];
+		prev = NULL;
+		while (1) {
+			if (tmp == script) {
+				if (prev)
+					prev->coll_chain = tmp->coll_chain;
+				else
+					unw.hash[index] = tmp->coll_chain;
+				break;
+			} else
+				prev = tmp;
+			if (tmp->coll_chain >= UNW_CACHE_SIZE)
+			/* old script wasn't in the hash-table */
+				break;
+			tmp = unw.cache + tmp->coll_chain;
 		}
+	}
 
-		/* enter new script in the hash table */
-		index = hash(ip);
-		script->coll_chain = unw.hash[index];
-		unw.hash[index] = script - unw.cache;
+	/* enter new script in the hash table */
+	index = hash(ip);
+	script->coll_chain = unw.hash[index];
+	unw.hash[index] = script - unw.cache;
 
-		script->ip = ip;	/* set new IP while we're holding the locks */
+	script->ip = ip;	/* set new IP while we're holding the locks */
 
-		STAT(if (script->coll_chain < UNW_CACHE_SIZE) ++unw.stat.script.collisions);
-	}
-	spin_unlock_irqrestore(&unw.lock, flags);
+	STAT(if (script->coll_chain < UNW_CACHE_SIZE) ++unw.stat.script.collisions);
 
 	script->flags = 0;
 	script->hint = 0;
@@ -1830,6 +1821,7 @@
 {
 	int have_write_lock = 0;
 	struct unw_script *scr;
+	unsigned long flags = 0;
 
 	if ((info->ip & (local_cpu_data->unimpl_va_mask | 0xf)) || info->ip < TASK_SIZE) {
 		/* don't let obviously bad addresses pollute the cache */
@@ -1841,8 +1833,10 @@
 
 	scr = script_lookup(info);
 	if (!scr) {
+		spin_lock_irqsave(&unw.lock, flags);
 		scr = build_script(info);
 		if (!scr) {
+			spin_unlock_irqrestore(&unw.lock, flags);
 			UNW_DPRINT(0,
 				   "unwind.%s: failed to locate/build unwind script for ip %lx\n",
 				   __FUNCTION__, info->ip);
@@ -1855,9 +1849,10 @@
 
 	run_script(scr, info);
 
-	if (have_write_lock)
+	if (have_write_lock) {
 		write_unlock(&scr->lock);
-	else
+		spin_unlock_irqrestore(&unw.lock, flags);
+	} else
 		read_unlock(&scr->lock);
 	return 0;
 }
diff -Nru a/arch/ia64/lib/bitop.c b/arch/ia64/lib/bitop.c
--- a/arch/ia64/lib/bitop.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ia64/lib/bitop.c	2004-12-24 13:37:18 -08:00
@@ -2,7 +2,7 @@
 #include <linux/types.h>
 #include <asm/intrinsics.h>
 #include <linux/module.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 /*
  * Find next zero bit in a bitmap reasonably efficiently..
diff -Nru a/arch/ia64/lib/dec_and_lock.c b/arch/ia64/lib/dec_and_lock.c
--- a/arch/ia64/lib/dec_and_lock.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ia64/lib/dec_and_lock.c	2004-12-24 13:37:18 -08:00
@@ -19,7 +19,7 @@
  * acquiring the spinlock first.
  */
 int
-atomic_dec_and_lock (atomic_t *refcount, spinlock_t *lock)
+_atomic_dec_and_lock (atomic_t *refcount, spinlock_t *lock)
 {
 	int old, new;
 
@@ -39,4 +39,4 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
diff -Nru a/arch/ia64/lib/io.c b/arch/ia64/lib/io.c
--- a/arch/ia64/lib/io.c	2004-12-24 13:36:16 -08:00
+++ b/arch/ia64/lib/io.c	2004-12-24 13:36:16 -08:00
@@ -73,6 +73,7 @@
 #undef __ia64_writew
 #undef __ia64_writel
 #undef __ia64_writeq
+#undef __ia64_mmiowb
 
 unsigned int
 __ia64_inb (unsigned long port)
@@ -156,6 +157,12 @@
 __ia64_readq_relaxed (void __iomem *addr)
 {
 	return ___ia64_readq (addr);
+}
+
+void
+__ia64_mmiowb(void)
+{
+	___ia64_mmiowb();
 }
 
 #endif /* CONFIG_IA64_GENERIC */
diff -Nru a/arch/ia64/lib/swiotlb.c b/arch/ia64/lib/swiotlb.c
--- a/arch/ia64/lib/swiotlb.c	2004-12-24 13:37:03 -08:00
+++ b/arch/ia64/lib/swiotlb.c	2004-12-24 13:37:03 -08:00
@@ -305,8 +305,15 @@
 	flags |= GFP_DMA;
 
 	ret = (void *)__get_free_pages(flags, get_order(size));
-	if (!ret)
-		return NULL;
+	if (!ret) {
+		 /* DMA_FROM_DEVICE is to avoid the memcpy in map_single */
+		dma_addr_t handle;
+		handle = swiotlb_map_single(NULL, NULL, size, DMA_FROM_DEVICE);
+		if (dma_mapping_error(handle))
+			return NULL;
+
+		ret = phys_to_virt(handle);
+	}
 
 	memset(ret, 0, size);
 	dev_addr = virt_to_phys(ret);
@@ -319,7 +326,12 @@
 void
 swiotlb_free_coherent (struct device *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle)
 {
-	free_pages((unsigned long) vaddr, get_order(size));
+	if (!(vaddr >= (void *)io_tlb_start
+                    && vaddr < (void *)io_tlb_end))
+		free_pages((unsigned long) vaddr, get_order(size));
+	else
+		/* DMA_TO_DEVICE to avoid memcpy in unmap_single */
+		swiotlb_unmap_single (hwdev, dma_handle, size, DMA_TO_DEVICE);
 }
 
 static void swiotlb_full(struct device *dev, size_t size, int dir, int do_panic)
diff -Nru a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
--- a/arch/ia64/mm/discontig.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ia64/mm/discontig.c	2004-12-24 13:37:18 -08:00
@@ -16,6 +16,7 @@
 #include <linux/bootmem.h>
 #include <linux/acpi.h>
 #include <linux/efi.h>
+#include <linux/nodemask.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/meminit.h>
@@ -601,7 +602,7 @@
  * for each piece of usable memory and will setup these values for each node.
  * Very similar to build_maps().
  */
-static int count_node_pages(unsigned long start, unsigned long len, int node)
+static __init int count_node_pages(unsigned long start, unsigned long len, int node)
 {
 	unsigned long end = start + len;
 
@@ -626,7 +627,7 @@
  * paging_init() sets up the page tables for each node of the system and frees
  * the bootmem allocator memory for general use.
  */
-void paging_init(void)
+void __init paging_init(void)
 {
 	unsigned long max_dma;
 	unsigned long zones_size[MAX_NR_ZONES];
@@ -680,7 +681,7 @@
 				PAGE_ALIGN(max_low_pfn * sizeof(struct page));
 			vmem_map = (struct page *) vmalloc_end;
 
-			efi_memmap_walk(create_mem_map_page_table, 0);
+			efi_memmap_walk(create_mem_map_page_table, NULL);
 			printk("Virtual mem_map starts at 0x%p\n", vmem_map);
 		}
 
diff -Nru a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
--- a/arch/ia64/mm/fault.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ia64/mm/fault.c	2004-12-24 13:37:29 -08:00
@@ -32,8 +32,8 @@
 	unsigned long grow;
 
 	grow = PAGE_SIZE >> PAGE_SHIFT;
-	if (address - vma->vm_start > current->rlim[RLIMIT_STACK].rlim_cur
-	    || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur))
+	if (address - vma->vm_start > current->signal->rlim[RLIMIT_STACK].rlim_cur
+	    || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->signal->rlim[RLIMIT_AS].rlim_cur))
 		return -ENOMEM;
 	vma->vm_end += PAGE_SIZE;
 	vma->vm_mm->total_vm += grow;
diff -Nru a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
--- a/arch/ia64/mm/init.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ia64/mm/init.c	2004-12-24 13:36:48 -08:00
@@ -19,9 +19,9 @@
 #include <linux/slab.h>
 #include <linux/swap.h>
 #include <linux/proc_fs.h>
+#include <linux/bitops.h>
 
 #include <asm/a.out.h>
-#include <asm/bitops.h>
 #include <asm/dma.h>
 #include <asm/ia32.h>
 #include <asm/io.h>
@@ -98,7 +98,7 @@
 inline void
 ia64_set_rbs_bot (void)
 {
-	unsigned long stack_size = current->rlim[RLIMIT_STACK].rlim_max & -16;
+	unsigned long stack_size = current->signal->rlim[RLIMIT_STACK].rlim_max & -16;
 
 	if (stack_size > MAX_USER_STACK_SIZE)
 		stack_size = MAX_USER_STACK_SIZE;
@@ -131,7 +131,13 @@
 		vma->vm_end = vma->vm_start + PAGE_SIZE;
 		vma->vm_page_prot = protection_map[VM_DATA_DEFAULT_FLAGS & 0x7];
 		vma->vm_flags = VM_DATA_DEFAULT_FLAGS | VM_GROWSUP;
-		insert_vm_struct(current->mm, vma);
+		down_write(&current->mm->mmap_sem);
+		if (insert_vm_struct(current->mm, vma)) {
+			up_write(&current->mm->mmap_sem);
+			kmem_cache_free(vm_area_cachep, vma);
+			return;
+		}
+		up_write(&current->mm->mmap_sem);
 	}
 
 	/* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
@@ -143,7 +149,13 @@
 			vma->vm_end = PAGE_SIZE;
 			vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT);
 			vma->vm_flags = VM_READ | VM_MAYREAD | VM_IO | VM_RESERVED;
-			insert_vm_struct(current->mm, vma);
+			down_write(&current->mm->mmap_sem);
+			if (insert_vm_struct(current->mm, vma)) {
+				up_write(&current->mm->mmap_sem);
+				kmem_cache_free(vm_area_cachep, vma);
+				return;
+			}
+			up_write(&current->mm->mmap_sem);
 		}
 	}
 }
diff -Nru a/arch/ia64/mm/numa.c b/arch/ia64/mm/numa.c
--- a/arch/ia64/mm/numa.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ia64/mm/numa.c	2004-12-24 13:36:31 -08:00
@@ -70,7 +70,7 @@
 	memset(sysfs_cpus, 0, sizeof(struct cpu) * NR_CPUS);
 
 	for (i = 0; i < numnodes; i++)
-		if ((err = register_node(&sysfs_nodes[i], i, 0)))
+		if ((err = register_node(&sysfs_nodes[i], i, NULL)))
 			goto out;
 
 	for (i = 0; i < NR_CPUS; i++)
diff -Nru a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
--- a/arch/ia64/pci/pci.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ia64/pci/pci.c	2004-12-24 13:36:48 -08:00
@@ -46,6 +46,8 @@
 #define DBG(x...)
 #endif
 
+static int pci_routeirq;
+
 /*
  * Low-level SAL-based PCI configuration access functions. Note that SAL
  * calls are already serialized (via sal_lock), so we don't need another
@@ -124,7 +126,7 @@
 				  devfn, where, size, value);
 }
 
-static struct pci_ops pci_root_ops = {
+struct pci_ops pci_root_ops = {
 	.read = pci_read,
 	.write = pci_write,
 };
@@ -141,13 +143,28 @@
 
 	acpi_get_devices(NULL, acpi_map_iosapic, NULL, NULL);
 #endif
-	/*
-	 * PCI IRQ routing is set up by pci_enable_device(), but we
-	 * also do it here in case there are still broken drivers that
-	 * don't use pci_enable_device().
-	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
-		acpi_pci_irq_enable(dev);
+
+	if (pci_routeirq) {
+		/*
+		 * PCI IRQ routing is set up by pci_enable_device(), but we
+		 * also do it here in case there are still broken drivers that
+		 * don't use pci_enable_device().
+		 */
+		printk(KERN_INFO "** Routing PCI interrupts for all devices because \"pci=routeirq\"\n");
+		printk(KERN_INFO "** was specified.  If this was required to make a driver work,\n");
+		printk(KERN_INFO "** please email the output of \"lspci\" to bjorn.helgaas@hp.com\n");
+		printk(KERN_INFO "** so I can fix the driver.\n");
+		while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
+			acpi_pci_irq_enable(dev);
+	} else {
+		printk(KERN_INFO "** PCI interrupts are no longer routed automatically.  If this\n");
+		printk(KERN_INFO "** causes a device to stop working, it is probably because the\n");
+		printk(KERN_INFO "** driver failed to call pci_enable_device().  As a temporary\n");
+		printk(KERN_INFO "** workaround, the \"pci=routeirq\" argument restores the old\n");
+		printk(KERN_INFO "** behavior.  If this argument makes the device work again,\n");
+		printk(KERN_INFO "** please email the output of \"lspci\" to bjorn.helgaas@hp.com\n");
+		printk(KERN_INFO "** so I can fix the driver.\n");
+	}
 
 	return 0;
 }
@@ -275,7 +292,7 @@
 			return AE_OK;
 
 		window = &info->controller->window[info->controller->windows++];
-		window->resource.flags |= flags;
+		window->resource.flags	= flags;
 		window->resource.start  = addr.min_address_range;
 		window->resource.end    = addr.max_address_range;
 		window->offset		= offset;
@@ -328,33 +345,65 @@
 	return NULL;
 }
 
-void __init
-pcibios_fixup_device_resources (struct pci_dev *dev, struct pci_bus *bus)
+void pcibios_resource_to_bus(struct pci_dev *dev,
+		struct pci_bus_region *region, struct resource *res)
 {
 	struct pci_controller *controller = PCI_CONTROLLER(dev);
-	struct pci_window *window;
-	int i, j;
+	unsigned long offset = 0;
+	int i;
+
+	for (i = 0; i < controller->windows; i++) {
+		struct pci_window *window = &controller->window[i];
+		if (!(window->resource.flags & res->flags))
+			continue;
+		if (window->resource.start > res->start - window->offset)
+			continue;
+		if (window->resource.end < res->end - window->offset)
+			continue;
+		offset = window->offset;
+		break;
+	}
+
+	region->start = res->start - offset;
+	region->end = res->end - offset;
+}
+
+void pcibios_bus_to_resource(struct pci_dev *dev,
+		struct resource *res, struct pci_bus_region *region)
+{
+	struct pci_controller *controller = PCI_CONTROLLER(dev);
+	unsigned long offset = 0;
+	int i;
+
+	for (i = 0; i < controller->windows; i++) {
+		struct pci_window *window = &controller->window[i];
+		if (!(window->resource.flags & res->flags))
+			continue;
+		if (window->resource.start > region->start)
+			continue;
+		if (window->resource.end < region->end)
+			continue;
+		offset = window->offset;
+		break;
+	}
+
+	res->start = region->start + offset;
+	res->end = region->end + offset;
+}
+
+static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
+{
+	struct pci_bus_region region;
+	int i;
 	int limit = (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) ? \
 		PCI_BRIDGE_RESOURCES : PCI_NUM_RESOURCES;
 
 	for (i = 0; i < limit; i++) {
-		if (!dev->resource[i].start)
+		if (!dev->resource[i].flags)
 			continue;
-
-#define contains(win, res)	((res)->start >= (win)->start && \
-				 (res)->end   <= (win)->end)
-
-		for (j = 0; j < controller->windows; j++) {
-			window = &controller->window[j];
-			if (((dev->resource[i].flags & IORESOURCE_MEM &&
-			      window->resource.flags & IORESOURCE_MEM) ||
-			     (dev->resource[i].flags & IORESOURCE_IO &&
-			      window->resource.flags & IORESOURCE_IO)) &&
-			    contains(&window->resource, &dev->resource[i])) {
-				dev->resource[i].start += window->offset;
-				dev->resource[i].end   += window->offset;
-			}
-		}
+		region.start = dev->resource[i].start;
+		region.end = dev->resource[i].end;
+		pcibios_bus_to_resource(dev, &dev->resource[i], &region);
 		pci_claim_resource(dev, i);
 	}
 }
@@ -365,10 +414,10 @@
 void __devinit
 pcibios_fixup_bus (struct pci_bus *b)
 {
-	struct list_head *ln;
+	struct pci_dev *dev;
 
-	for (ln = b->devices.next; ln != &b->devices; ln = ln->next)
-		pcibios_fixup_device_resources(pci_dev_b(ln), b);
+	list_for_each_entry(dev, &b->devices, bus_list)
+		pcibios_fixup_device_resources(dev);
 
 	return;
 }
@@ -443,6 +492,8 @@
 char * __init
 pcibios_setup (char *str)
 {
+	if (!strcmp(str, "routeirq"))
+		pci_routeirq = 1;
 	return NULL;
 }
 
@@ -451,21 +502,21 @@
 		     enum pci_mmap_state mmap_state, int write_combine)
 {
 	/*
-	 * I/O space cannot be accessed via normal processor loads and stores on this
-	 * platform.
+	 * I/O space cannot be accessed via normal processor loads and
+	 * stores on this platform.
 	 */
 	if (mmap_state == pci_mmap_io)
 		/*
-		 * XXX we could relax this for I/O spaces for which ACPI indicates that
-		 * the space is 1-to-1 mapped.  But at the moment, we don't support
-		 * multiple PCI address spaces and the legacy I/O space is not 1-to-1
-		 * mapped, so this is moot.
+		 * XXX we could relax this for I/O spaces for which ACPI
+		 * indicates that the space is 1-to-1 mapped.  But at the
+		 * moment, we don't support multiple PCI address spaces and
+		 * the legacy I/O space is not 1-to-1 mapped, so this is moot.
 		 */
 		return -EINVAL;
 
 	/*
-	 * Leave vm_pgoff as-is, the PCI space address is the physical address on this
-	 * platform.
+	 * Leave vm_pgoff as-is, the PCI space address is the physical
+	 * address on this platform.
 	 */
 	vma->vm_flags |= (VM_SHM | VM_LOCKED | VM_IO);
 
@@ -474,7 +525,7 @@
 	else
 		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
-	if (remap_page_range(vma, vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+	if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
 			     vma->vm_end - vma->vm_start, vma->vm_page_prot))
 		return -EAGAIN;
 
diff -Nru a/arch/ia64/sn/Makefile b/arch/ia64/sn/Makefile
--- a/arch/ia64/sn/Makefile	2004-12-24 13:37:18 -08:00
+++ b/arch/ia64/sn/Makefile	2004-12-24 13:37:18 -08:00
@@ -4,9 +4,11 @@
 # License.  See the file "COPYING" in the main directory of this archive
 # for more details.
 #
-# Copyright (C) 2003 Silicon Graphics, Inc.  All Rights Reserved.
+# Copyright (C) 2004 Silicon Graphics, Inc.  All Rights Reserved.
 #
 # Makefile for the sn ia64 subplatform
 #
 
-obj-y += kernel/ io/
+CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
+
+obj-y += kernel/ pci/
diff -Nru a/arch/ia64/sn/include/ioerror.h b/arch/ia64/sn/include/ioerror.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/ioerror.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,81 @@
+/*
+ * 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 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ */
+#ifndef _ASM_IA64_SN_IOERROR_H
+#define _ASM_IA64_SN_IOERROR_H
+
+/*
+ * IO error structure.
+ *
+ * This structure would expand to hold the information retrieved from
+ * all IO related error registers.
+ *
+ * This structure is defined to hold all system specific
+ * information related to a single error.
+ *
+ * This serves a couple of purpose.
+ *      - Error handling often involves translating one form of address to other
+ *        form. So, instead of having different data structures at each level,
+ *        we have a single structure, and the appropriate fields get filled in
+ *        at each layer.
+ *      - This provides a way to dump all error related information in any layer
+ *        of erorr handling (debugging aid).
+ *
+ * A second possibility is to allow each layer to define its own error
+ * data structure, and fill in the proper fields. This has the advantage
+ * of isolating the layers.
+ * A big concern is the potential stack usage (and overflow), if each layer
+ * defines these structures on stack (assuming we don't want to do kmalloc.
+ *
+ * Any layer wishing to pass extra information to a layer next to it in
+ * error handling hierarchy, can do so as a separate parameter.
+ */
+
+typedef struct io_error_s {
+    /* Bit fields indicating which structure fields are valid */
+    union {
+	struct {
+	    unsigned                ievb_errortype:1;
+	    unsigned                ievb_widgetnum:1;
+	    unsigned                ievb_widgetdev:1;
+	    unsigned                ievb_srccpu:1;
+	    unsigned                ievb_srcnode:1;
+	    unsigned                ievb_errnode:1;
+	    unsigned                ievb_sysioaddr:1;
+	    unsigned                ievb_xtalkaddr:1;
+	    unsigned                ievb_busspace:1;
+	    unsigned                ievb_busaddr:1;
+	    unsigned                ievb_vaddr:1;
+	    unsigned                ievb_memaddr:1;
+	    unsigned		    ievb_epc:1;
+	    unsigned		    ievb_ef:1;
+	    unsigned		    ievb_tnum:1;
+	} iev_b;
+	unsigned                iev_a;
+    } ie_v;
+
+    short                   ie_errortype;	/* error type: extra info about error */
+    short                   ie_widgetnum;	/* Widget number that's in error */
+    short                   ie_widgetdev;	/* Device within widget in error */
+    cpuid_t                 ie_srccpu;	/* CPU on srcnode generating error */
+    cnodeid_t               ie_srcnode;		/* Node which caused the error   */
+    cnodeid_t               ie_errnode;		/* Node where error was noticed  */
+    iopaddr_t               ie_sysioaddr;	/* Sys specific IO address       */
+    iopaddr_t               ie_xtalkaddr;	/* Xtalk (48bit) addr of Error   */
+    iopaddr_t               ie_busspace;	/* Bus specific address space    */
+    iopaddr_t               ie_busaddr;		/* Bus specific address          */
+    caddr_t                 ie_vaddr;	/* Virtual address of error      */
+    iopaddr_t               ie_memaddr;		/* Physical memory address       */
+    caddr_t		    ie_epc;		/* pc when error reported	 */
+    caddr_t		    ie_ef;		/* eframe when error reported	 */
+    short		    ie_tnum;		/* Xtalk TNUM field */
+} ioerror_t;
+
+#define	IOERROR_INIT(e)		do { (e)->ie_v.iev_a = 0; } while (0)
+#define	IOERROR_SETVALUE(e,f,v)	do { (e)->ie_ ## f = (v); (e)->ie_v.iev_b.ievb_ ## f = 1; } while (0)
+
+#endif /* _ASM_IA64_SN_IOERROR_H */
diff -Nru a/arch/ia64/sn/include/pci/pcibr_provider.h b/arch/ia64/sn/include/pci/pcibr_provider.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/pci/pcibr_provider.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,149 @@
+/*
+ * 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-1997,2000-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+#ifndef _ASM_IA64_SN_PCI_PCIBR_PROVIDER_H
+#define _ASM_IA64_SN_PCI_PCIBR_PROVIDER_H
+
+/* Workarounds */
+#define PV907516 (1 << 1) /* TIOCP: Don't write the write buffer flush reg */
+
+#define BUSTYPE_MASK                    0x1
+
+/* Macros given a pcibus structure */
+#define IS_PCIX(ps)     ((ps)->pbi_bridge_mode & BUSTYPE_MASK)
+#define IS_PCI_BRIDGE_ASIC(asic) (asic == PCIIO_ASIC_TYPE_PIC || \
+                asic == PCIIO_ASIC_TYPE_TIOCP)
+#define IS_PIC_SOFT(ps)     (ps->pbi_bridge_type == PCIBR_BRIDGETYPE_PIC)
+
+
+/* 
+ * The different PCI Bridge types supported on the SGI Altix platforms
+ */
+#define PCIBR_BRIDGETYPE_UNKNOWN       -1
+#define PCIBR_BRIDGETYPE_PIC            2
+#define PCIBR_BRIDGETYPE_TIOCP          3
+
+/*
+ * Bridge 64bit Direct Map Attributes
+ */
+#define PCI64_ATTR_PREF                 (1ull << 59)
+#define PCI64_ATTR_PREC                 (1ull << 58)
+#define PCI64_ATTR_VIRTUAL              (1ull << 57)
+#define PCI64_ATTR_BAR                  (1ull << 56)
+#define PCI64_ATTR_SWAP                 (1ull << 55)
+#define PCI64_ATTR_VIRTUAL1             (1ull << 54)
+
+#define PCI32_LOCAL_BASE                0
+#define PCI32_MAPPED_BASE               0x40000000
+#define PCI32_DIRECT_BASE               0x80000000
+
+#define IS_PCI32_MAPPED(x)              ((uint64_t)(x) < PCI32_DIRECT_BASE && \
+                                         (uint64_t)(x) >= PCI32_MAPPED_BASE)
+#define IS_PCI32_DIRECT(x)              ((uint64_t)(x) >= PCI32_MAPPED_BASE)
+
+
+/*
+ * Bridge PMU Address Transaltion Entry Attibutes
+ */
+#define PCI32_ATE_V                     (0x1 << 0)
+#define PCI32_ATE_CO                    (0x1 << 1)
+#define PCI32_ATE_PREC                  (0x1 << 2)
+#define PCI32_ATE_PREF                  (0x1 << 3)
+#define PCI32_ATE_BAR                   (0x1 << 4)
+#define PCI32_ATE_ADDR_SHFT             12
+
+#define MINIMAL_ATES_REQUIRED(addr, size) \
+	(IOPG(IOPGOFF(addr) + (size) - 1) == IOPG((size) - 1))
+
+#define MINIMAL_ATE_FLAG(addr, size) \
+	(MINIMAL_ATES_REQUIRED((uint64_t)addr, size) ? 1 : 0)
+
+/* bit 29 of the pci address is the SWAP bit */
+#define ATE_SWAPSHIFT                   29
+#define ATE_SWAP_ON(x)                  ((x) |= (1 << ATE_SWAPSHIFT))
+#define ATE_SWAP_OFF(x)                 ((x) &= ~(1 << ATE_SWAPSHIFT))
+
+/*
+ * I/O page size
+ */
+#if PAGE_SIZE < 16384
+#define IOPFNSHIFT                      12      /* 4K per mapped page */
+#else
+#define IOPFNSHIFT                      14      /* 16K per mapped page */
+#endif
+
+#define IOPGSIZE                        (1 << IOPFNSHIFT)
+#define IOPG(x)                         ((x) >> IOPFNSHIFT)
+#define IOPGOFF(x)                      ((x) & (IOPGSIZE-1))
+
+#define PCIBR_DEV_SWAP_DIR              (1ull << 19)
+#define PCIBR_CTRL_PAGE_SIZE            (0x1 << 21)
+
+/*
+ * PMU resources.
+ */
+struct ate_resource{
+	uint64_t *ate;
+	uint64_t num_ate;
+	uint64_t lowest_free_index;
+};
+
+struct pcibus_info {
+	struct pcibus_bussoft	pbi_buscommon;   /* common header */
+	uint32_t                pbi_moduleid;
+	short                   pbi_bridge_type;
+	short                   pbi_bridge_mode;
+
+	struct ate_resource     pbi_int_ate_resource;
+	uint64_t                pbi_int_ate_size;
+	
+	uint64_t                pbi_dir_xbase;
+	char                    pbi_hub_xid;
+
+	uint64_t                pbi_devreg[8];
+	spinlock_t              pbi_lock;
+
+	uint32_t		pbi_valid_devices;
+	uint32_t		pbi_enabled_devices;
+};
+
+/*
+ * pcibus_info structure locking macros
+ */
+inline static unsigned long
+pcibr_lock(struct pcibus_info *pcibus_info)
+{
+	unsigned long flag;
+	spin_lock_irqsave(&pcibus_info->pbi_lock, flag);
+	return(flag);
+}
+#define pcibr_unlock(pcibus_info, flag)  spin_unlock_irqrestore(&pcibus_info->pbi_lock, flag)
+
+extern void *pcibr_bus_fixup(struct pcibus_bussoft *);
+extern uint64_t pcibr_dma_map(struct pcidev_info *, unsigned long, size_t, unsigned int);
+extern void pcibr_dma_unmap(struct pcidev_info *, dma_addr_t, int);
+
+/*
+ * prototypes for the bridge asic register access routines in pcibr_reg.c
+ */
+extern void             pcireg_control_bit_clr(struct pcibus_info *, uint64_t);
+extern void             pcireg_control_bit_set(struct pcibus_info *, uint64_t);
+extern uint64_t         pcireg_tflush_get(struct pcibus_info *);
+extern uint64_t         pcireg_intr_status_get(struct pcibus_info *);
+extern void             pcireg_intr_enable_bit_clr(struct pcibus_info *, uint64_t);
+extern void             pcireg_intr_enable_bit_set(struct pcibus_info *, uint64_t);
+extern void             pcireg_intr_addr_addr_set(struct pcibus_info *, int, uint64_t);
+extern void             pcireg_force_intr_set(struct pcibus_info *, int);
+extern uint64_t         pcireg_wrb_flush_get(struct pcibus_info *, int);
+extern void             pcireg_int_ate_set(struct pcibus_info *, int, uint64_t);
+extern uint64_t *	pcireg_int_ate_addr(struct pcibus_info *, int);
+extern void 		pcibr_force_interrupt(struct sn_irq_info *sn_irq_info);
+extern void 		pcibr_change_devices_irq(struct sn_irq_info *sn_irq_info);
+extern int 		pcibr_ate_alloc(struct pcibus_info *, int);
+extern void 		pcibr_ate_free(struct pcibus_info *, int);
+extern void 		ate_write(struct pcibus_info *, int, int, uint64_t);
+#endif
diff -Nru a/arch/ia64/sn/include/pci/pcibus_provider_defs.h b/arch/ia64/sn/include/pci/pcibus_provider_defs.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/pci/pcibus_provider_defs.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,43 @@
+/*
+ * 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 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+#ifndef _ASM_IA64_SN_PCI_PCIBUS_PROVIDER_H
+#define _ASM_IA64_SN_PCI_PCIBUS_PROVIDER_H
+
+/*
+ * SN pci asic types.  Do not ever renumber these or reuse values.  The
+ * values must agree with what prom thinks they are.
+ */
+
+#define PCIIO_ASIC_TYPE_UNKNOWN	0
+#define PCIIO_ASIC_TYPE_PPB	1
+#define PCIIO_ASIC_TYPE_PIC	2
+#define PCIIO_ASIC_TYPE_TIOCP	3
+
+/*
+ * Common pciio bus provider data.  There should be one of these as the
+ * first field in any pciio based provider soft structure (e.g. pcibr_soft
+ * tioca_soft, etc).
+ */
+
+struct pcibus_bussoft {
+	uint32_t		bs_asic_type;	/* chipset type */
+	uint32_t		bs_xid;		/* xwidget id */
+	uint64_t		bs_persist_busnum; /* Persistent Bus Number */
+	uint64_t		bs_legacy_io;	/* legacy io pio addr */
+	uint64_t		bs_legacy_mem;	/* legacy mem pio addr */
+	uint64_t		bs_base;	/* widget base */
+	struct xwidget_info	*bs_xwidget_info;
+};
+
+/*
+ * DMA mapping flags
+ */
+
+#define SN_PCIDMA_CONSISTENT    0x0001
+
+#endif				/* _ASM_IA64_SN_PCI_PCIBUS_PROVIDER_H */
diff -Nru a/arch/ia64/sn/include/pci/pcidev.h b/arch/ia64/sn/include/pci/pcidev.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/pci/pcidev.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,54 @@
+/*
+ * 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 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+#ifndef _ASM_IA64_SN_PCI_PCIDEV_H
+#define _ASM_IA64_SN_PCI_PCIDEV_H
+
+#include <linux/pci.h>
+
+extern struct sn_irq_info **sn_irq;
+
+#define SN_PCIDEV_INFO(pci_dev) \
+        ((struct pcidev_info *)(pci_dev)->sysdata)
+
+/*
+ * Given a pci_bus, return the sn pcibus_bussoft struct.  Note that
+ * this only works for root busses, not for busses represented by PPB's.
+ */
+
+#define SN_PCIBUS_BUSSOFT(pci_bus) \
+        ((struct pcibus_bussoft *)(PCI_CONTROLLER((pci_bus))->platform_data))
+
+/*
+ * Given a struct pci_dev, return the sn pcibus_bussoft struct.  Note
+ * that this is not equivalent to SN_PCIBUS_BUSSOFT(pci_dev->bus) due
+ * due to possible PPB's in the path.
+ */
+
+#define SN_PCIDEV_BUSSOFT(pci_dev) \
+	(SN_PCIDEV_INFO(pci_dev)->pdi_host_pcidev_info->pdi_pcibus_info)
+
+#define PCIIO_BUS_NONE	255      /* bus 255 reserved */
+#define PCIIO_SLOT_NONE 255
+#define PCIIO_FUNC_NONE 255
+#define PCIIO_VENDOR_ID_NONE	(-1)
+
+struct pcidev_info {
+	uint64_t		pdi_pio_mapped_addr[7]; /* 6 BARs PLUS 1 ROM */
+	uint64_t		pdi_slot_host_handle;	/* Bus and devfn Host pci_dev */
+
+	struct pcibus_bussoft	*pdi_pcibus_info;	/* Kernel common bus soft */
+	struct pcidev_info	*pdi_host_pcidev_info;	/* Kernel Host pci_dev */
+	struct pci_dev		*pdi_linux_pcidev;	/* Kernel pci_dev */
+
+	struct sn_irq_info	*pdi_sn_irq_info;
+};
+
+extern void sn_irq_fixup(struct pci_dev *pci_dev,
+			 struct sn_irq_info *sn_irq_info);
+
+#endif				/* _ASM_IA64_SN_PCI_PCIDEV_H */
diff -Nru a/arch/ia64/sn/include/pci/pic.h b/arch/ia64/sn/include/pci/pic.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/pci/pic.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,261 @@
+/*
+ * 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 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ */
+#ifndef _ASM_IA64_SN_PCI_PIC_H
+#define _ASM_IA64_SN_PCI_PIC_H
+
+/*
+ * PIC AS DEVICE ZERO
+ * ------------------
+ *
+ * PIC handles PCI/X busses.  PCI/X requires that the 'bridge' (i.e. PIC)
+ * be designated as 'device 0'.   That is a departure from earlier SGI
+ * PCI bridges.  Because of that we use config space 1 to access the
+ * config space of the first actual PCI device on the bus. 
+ * Here's what the PIC manual says:
+ *
+ *     The current PCI-X bus specification now defines that the parent
+ *     hosts bus bridge (PIC for example) must be device 0 on bus 0. PIC
+ *     reduced the total number of devices from 8 to 4 and removed the
+ *     device registers and windows, now only supporting devices 0,1,2, and
+ *     3. PIC did leave all 8 configuration space windows. The reason was
+ *     there was nothing to gain by removing them. Here in lies the problem.
+ *     The device numbering we do using 0 through 3 is unrelated to the device
+ *     numbering which PCI-X requires in configuration space. In the past we
+ *     correlated Configs pace and our device space 0 <-> 0, 1 <-> 1, etc.
+ *     PCI-X requires we start a 1, not 0 and currently the PX brick
+ *     does associate our:
+ * 
+ *         device 0 with configuration space window 1,
+ *         device 1 with configuration space window 2, 
+ *         device 2 with configuration space window 3,
+ *         device 3 with configuration space window 4.
+ *
+ * The net effect is that all config space access are off-by-one with 
+ * relation to other per-slot accesses on the PIC.   
+ * Here is a table that shows some of that:
+ *
+ *                               Internal Slot#
+ *           |
+ *           |     0         1        2         3
+ * ----------|---------------------------------------
+ * config    |  0x21000   0x22000  0x23000   0x24000
+ *           |
+ * even rrb  |  0[0]      n/a      1[0]      n/a	[] == implied even/odd
+ *           |
+ * odd rrb   |  n/a       0[1]     n/a       1[1]
+ *           |
+ * int dev   |  00       01        10        11
+ *           |
+ * ext slot# |  1        2         3         4
+ * ----------|---------------------------------------
+ */
+
+#define PIC_ATE_TARGETID_SHFT           8
+#define PIC_HOST_INTR_ADDR              0x0000FFFFFFFFFFFFUL
+#define PIC_PCI64_ATTR_TARG_SHFT        60
+
+
+/*****************************************************************************
+ *********************** PIC MMR structure mapping ***************************
+ *****************************************************************************/
+
+/* NOTE: PIC WAR. PV#854697.  PIC does not allow writes just to [31:0]
+ * of a 64-bit register.  When writing PIC registers, always write the 
+ * entire 64 bits.
+ */
+
+struct pic {
+
+    /* 0x000000-0x00FFFF -- Local Registers */
+
+    /* 0x000000-0x000057 -- Standard Widget Configuration */
+    uint64_t		p_wid_id;			/* 0x000000 */
+    uint64_t		p_wid_stat;			/* 0x000008 */
+    uint64_t		p_wid_err_upper;		/* 0x000010 */
+    uint64_t		p_wid_err_lower;		/* 0x000018 */
+    #define p_wid_err p_wid_err_lower
+    uint64_t		p_wid_control;			/* 0x000020 */
+    uint64_t		p_wid_req_timeout;		/* 0x000028 */
+    uint64_t		p_wid_int_upper;		/* 0x000030 */
+    uint64_t		p_wid_int_lower;		/* 0x000038 */
+    #define p_wid_int p_wid_int_lower
+    uint64_t		p_wid_err_cmdword;		/* 0x000040 */
+    uint64_t		p_wid_llp;			/* 0x000048 */
+    uint64_t		p_wid_tflush;			/* 0x000050 */
+
+    /* 0x000058-0x00007F -- Bridge-specific Widget Configuration */
+    uint64_t		p_wid_aux_err;			/* 0x000058 */
+    uint64_t		p_wid_resp_upper;		/* 0x000060 */
+    uint64_t		p_wid_resp_lower;		/* 0x000068 */
+    #define p_wid_resp p_wid_resp_lower
+    uint64_t		p_wid_tst_pin_ctrl;		/* 0x000070 */
+    uint64_t		p_wid_addr_lkerr;		/* 0x000078 */
+
+    /* 0x000080-0x00008F -- PMU & MAP */
+    uint64_t		p_dir_map;			/* 0x000080 */
+    uint64_t		_pad_000088;			/* 0x000088 */
+
+    /* 0x000090-0x00009F -- SSRAM */
+    uint64_t		p_map_fault;			/* 0x000090 */
+    uint64_t		_pad_000098;			/* 0x000098 */
+
+    /* 0x0000A0-0x0000AF -- Arbitration */
+    uint64_t		p_arb;				/* 0x0000A0 */
+    uint64_t		_pad_0000A8;			/* 0x0000A8 */
+
+    /* 0x0000B0-0x0000BF -- Number In A Can or ATE Parity Error */
+    uint64_t		p_ate_parity_err;		/* 0x0000B0 */
+    uint64_t		_pad_0000B8;			/* 0x0000B8 */
+
+    /* 0x0000C0-0x0000FF -- PCI/GIO */
+    uint64_t		p_bus_timeout;			/* 0x0000C0 */
+    uint64_t		p_pci_cfg;			/* 0x0000C8 */
+    uint64_t		p_pci_err_upper;		/* 0x0000D0 */
+    uint64_t		p_pci_err_lower;		/* 0x0000D8 */
+    #define p_pci_err p_pci_err_lower
+    uint64_t		_pad_0000E0[4];			/* 0x0000{E0..F8} */
+
+    /* 0x000100-0x0001FF -- Interrupt */
+    uint64_t		p_int_status;			/* 0x000100 */
+    uint64_t		p_int_enable;			/* 0x000108 */
+    uint64_t		p_int_rst_stat;			/* 0x000110 */
+    uint64_t		p_int_mode;			/* 0x000118 */
+    uint64_t		p_int_device;			/* 0x000120 */
+    uint64_t		p_int_host_err;			/* 0x000128 */
+    uint64_t		p_int_addr[8];			/* 0x0001{30,,,68} */
+    uint64_t		p_err_int_view;			/* 0x000170 */
+    uint64_t		p_mult_int;			/* 0x000178 */
+    uint64_t		p_force_always[8];		/* 0x0001{80,,,B8} */
+    uint64_t		p_force_pin[8];			/* 0x0001{C0,,,F8} */
+
+    /* 0x000200-0x000298 -- Device */
+    uint64_t		p_device[4];			/* 0x0002{00,,,18} */
+    uint64_t		_pad_000220[4];			/* 0x0002{20,,,38} */
+    uint64_t		p_wr_req_buf[4];		/* 0x0002{40,,,58} */
+    uint64_t		_pad_000260[4];			/* 0x0002{60,,,78} */
+    uint64_t		p_rrb_map[2];			/* 0x0002{80,,,88} */
+    #define p_even_resp p_rrb_map[0]			/* 0x000280 */
+    #define p_odd_resp  p_rrb_map[1]			/* 0x000288 */
+    uint64_t		p_resp_status;			/* 0x000290 */
+    uint64_t		p_resp_clear;			/* 0x000298 */
+
+    uint64_t		_pad_0002A0[12];		/* 0x0002{A0..F8} */
+
+    /* 0x000300-0x0003F8 -- Buffer Address Match Registers */
+    struct {
+	uint64_t	upper;				/* 0x0003{00,,,F0} */
+	uint64_t	lower;				/* 0x0003{08,,,F8} */
+    } p_buf_addr_match[16];
+
+    /* 0x000400-0x0005FF -- Performance Monitor Registers (even only) */
+    struct {
+	uint64_t	flush_w_touch;			/* 0x000{400,,,5C0} */
+	uint64_t	flush_wo_touch;			/* 0x000{408,,,5C8} */
+	uint64_t	inflight;			/* 0x000{410,,,5D0} */
+	uint64_t	prefetch;			/* 0x000{418,,,5D8} */
+	uint64_t	total_pci_retry;		/* 0x000{420,,,5E0} */
+	uint64_t	max_pci_retry;			/* 0x000{428,,,5E8} */
+	uint64_t	max_latency;			/* 0x000{430,,,5F0} */
+	uint64_t	clear_all;			/* 0x000{438,,,5F8} */
+    } p_buf_count[8];
+
+    
+    /* 0x000600-0x0009FF -- PCI/X registers */
+    uint64_t		p_pcix_bus_err_addr;		/* 0x000600 */
+    uint64_t		p_pcix_bus_err_attr;		/* 0x000608 */
+    uint64_t		p_pcix_bus_err_data;		/* 0x000610 */
+    uint64_t		p_pcix_pio_split_addr;		/* 0x000618 */
+    uint64_t		p_pcix_pio_split_attr;		/* 0x000620 */
+    uint64_t		p_pcix_dma_req_err_attr;	/* 0x000628 */
+    uint64_t		p_pcix_dma_req_err_addr;	/* 0x000630 */
+    uint64_t		p_pcix_timeout;			/* 0x000638 */
+
+    uint64_t		_pad_000640[120];		/* 0x000{640,,,9F8} */
+
+    /* 0x000A00-0x000BFF -- PCI/X Read&Write Buffer */
+    struct {
+	uint64_t	p_buf_addr;			/* 0x000{A00,,,AF0} */
+	uint64_t	p_buf_attr;			/* 0X000{A08,,,AF8} */
+    } p_pcix_read_buf_64[16];
+
+    struct {
+	uint64_t	p_buf_addr;			/* 0x000{B00,,,BE0} */
+	uint64_t	p_buf_attr;			/* 0x000{B08,,,BE8} */
+	uint64_t	p_buf_valid;			/* 0x000{B10,,,BF0} */
+	uint64_t	__pad1;				/* 0x000{B18,,,BF8} */
+    } p_pcix_write_buf_64[8];
+
+    /* End of Local Registers -- Start of Address Map space */
+
+    char		_pad_000c00[0x010000 - 0x000c00];
+
+    /* 0x010000-0x011fff -- Internal ATE RAM (Auto Parity Generation) */
+    uint64_t		p_int_ate_ram[1024];		/* 0x010000-0x011fff */
+
+    /* 0x012000-0x013fff -- Internal ATE RAM (Manual Parity Generation) */
+    uint64_t		p_int_ate_ram_mp[1024];		/* 0x012000-0x013fff */
+
+    char		_pad_014000[0x18000 - 0x014000];
+
+    /* 0x18000-0x197F8 -- PIC Write Request Ram */
+    uint64_t		p_wr_req_lower[256];		/* 0x18000 - 0x187F8 */
+    uint64_t		p_wr_req_upper[256];		/* 0x18800 - 0x18FF8 */
+    uint64_t		p_wr_req_parity[256];		/* 0x19000 - 0x197F8 */
+
+    char		_pad_019800[0x20000 - 0x019800];
+
+    /* 0x020000-0x027FFF -- PCI Device Configuration Spaces */
+    union {
+	uint8_t		c[0x1000 / 1];			/* 0x02{0000,,,7FFF} */
+	uint16_t	s[0x1000 / 2];			/* 0x02{0000,,,7FFF} */
+	uint32_t	l[0x1000 / 4];			/* 0x02{0000,,,7FFF} */
+	uint64_t	d[0x1000 / 8];			/* 0x02{0000,,,7FFF} */
+	union {
+	    uint8_t	c[0x100 / 1];
+	    uint16_t	s[0x100 / 2];
+	    uint32_t	l[0x100 / 4];
+	    uint64_t	d[0x100 / 8];
+	} f[8];
+    } p_type0_cfg_dev[8];				/* 0x02{0000,,,7FFF} */
+
+    /* 0x028000-0x028FFF -- PCI Type 1 Configuration Space */
+    union {
+	uint8_t		c[0x1000 / 1];			/* 0x028000-0x029000 */
+	uint16_t	s[0x1000 / 2];			/* 0x028000-0x029000 */
+	uint32_t	l[0x1000 / 4];			/* 0x028000-0x029000 */
+	uint64_t	d[0x1000 / 8];			/* 0x028000-0x029000 */
+	union {
+	    uint8_t	c[0x100 / 1];
+	    uint16_t	s[0x100 / 2];
+	    uint32_t	l[0x100 / 4];
+	    uint64_t	d[0x100 / 8];
+	} f[8];
+    } p_type1_cfg;					/* 0x028000-0x029000 */
+
+    char		_pad_029000[0x030000-0x029000];
+
+    /* 0x030000-0x030007 -- PCI Interrupt Acknowledge Cycle */
+    union {
+	uint8_t		c[8 / 1];
+	uint16_t	s[8 / 2];
+	uint32_t	l[8 / 4];
+	uint64_t	d[8 / 8];
+    } p_pci_iack;					/* 0x030000-0x030007 */
+
+    char		_pad_030007[0x040000-0x030008];
+
+    /* 0x040000-0x030007 -- PCIX Special Cycle */
+    union {
+	uint8_t		c[8 / 1];
+	uint16_t	s[8 / 2];
+	uint32_t	l[8 / 4];
+	uint64_t	d[8 / 8];
+    } p_pcix_cycle;					/* 0x040000-0x040007 */
+};
+
+#endif                          /* _ASM_IA64_SN_PCI_PIC_H */
diff -Nru a/arch/ia64/sn/include/pci/tiocp.h b/arch/ia64/sn/include/pci/tiocp.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/pci/tiocp.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,256 @@
+/*
+ * 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) 2003-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+#ifndef _ASM_IA64_SN_PCI_TIOCP_H
+#define _ASM_IA64_SN_PCI_TIOCP_H
+
+#define TIOCP_HOST_INTR_ADDR            0x003FFFFFFFFFFFFFUL
+#define TIOCP_PCI64_CMDTYPE_MEM         (0x1ull << 60)
+
+
+/*****************************************************************************
+ *********************** TIOCP MMR structure mapping ***************************
+ *****************************************************************************/
+
+struct tiocp{
+
+    /* 0x000000-0x00FFFF -- Local Registers */
+
+    /* 0x000000-0x000057 -- (Legacy Widget Space) Configuration */
+    uint64_t		cp_id;				/* 0x000000 */
+    uint64_t		cp_stat;			/* 0x000008 */
+    uint64_t		cp_err_upper;			/* 0x000010 */
+    uint64_t		cp_err_lower;			/* 0x000018 */
+    #define cp_err cp_err_lower
+    uint64_t		cp_control;			/* 0x000020 */
+    uint64_t		cp_req_timeout;			/* 0x000028 */
+    uint64_t		cp_intr_upper;			/* 0x000030 */
+    uint64_t		cp_intr_lower;			/* 0x000038 */
+    #define cp_intr cp_intr_lower
+    uint64_t		cp_err_cmdword;			/* 0x000040 */
+    uint64_t		_pad_000048;			/* 0x000048 */
+    uint64_t		cp_tflush;			/* 0x000050 */
+
+    /* 0x000058-0x00007F -- Bridge-specific Configuration */
+    uint64_t		cp_aux_err;			/* 0x000058 */
+    uint64_t		cp_resp_upper;			/* 0x000060 */
+    uint64_t		cp_resp_lower;			/* 0x000068 */
+    #define cp_resp cp_resp_lower
+    uint64_t		cp_tst_pin_ctrl;		/* 0x000070 */
+    uint64_t		cp_addr_lkerr;			/* 0x000078 */
+
+    /* 0x000080-0x00008F -- PMU & MAP */
+    uint64_t		cp_dir_map;			/* 0x000080 */
+    uint64_t		_pad_000088;			/* 0x000088 */
+
+    /* 0x000090-0x00009F -- SSRAM */
+    uint64_t		cp_map_fault;			/* 0x000090 */
+    uint64_t		_pad_000098;			/* 0x000098 */
+
+    /* 0x0000A0-0x0000AF -- Arbitration */
+    uint64_t		cp_arb;				/* 0x0000A0 */
+    uint64_t		_pad_0000A8;			/* 0x0000A8 */
+
+    /* 0x0000B0-0x0000BF -- Number In A Can or ATE Parity Error */
+    uint64_t		cp_ate_parity_err;		/* 0x0000B0 */
+    uint64_t		_pad_0000B8;			/* 0x0000B8 */
+
+    /* 0x0000C0-0x0000FF -- PCI/GIO */
+    uint64_t		cp_bus_timeout;			/* 0x0000C0 */
+    uint64_t		cp_pci_cfg;			/* 0x0000C8 */
+    uint64_t		cp_pci_err_upper;		/* 0x0000D0 */
+    uint64_t		cp_pci_err_lower;		/* 0x0000D8 */
+    #define cp_pci_err cp_pci_err_lower
+    uint64_t		_pad_0000E0[4];			/* 0x0000{E0..F8} */
+
+    /* 0x000100-0x0001FF -- Interrupt */
+    uint64_t		cp_int_status;			/* 0x000100 */
+    uint64_t		cp_int_enable;			/* 0x000108 */
+    uint64_t		cp_int_rst_stat;		/* 0x000110 */
+    uint64_t		cp_int_mode;			/* 0x000118 */
+    uint64_t		cp_int_device;			/* 0x000120 */
+    uint64_t		cp_int_host_err;		/* 0x000128 */
+    uint64_t		cp_int_addr[8];			/* 0x0001{30,,,68} */
+    uint64_t		cp_err_int_view;		/* 0x000170 */
+    uint64_t		cp_mult_int;			/* 0x000178 */
+    uint64_t		cp_force_always[8];		/* 0x0001{80,,,B8} */
+    uint64_t		cp_force_pin[8];		/* 0x0001{C0,,,F8} */
+
+    /* 0x000200-0x000298 -- Device */
+    uint64_t		cp_device[4];			/* 0x0002{00,,,18} */
+    uint64_t		_pad_000220[4];			/* 0x0002{20,,,38} */
+    uint64_t		cp_wr_req_buf[4];		/* 0x0002{40,,,58} */
+    uint64_t		_pad_000260[4];			/* 0x0002{60,,,78} */
+    uint64_t		cp_rrb_map[2];			/* 0x0002{80,,,88} */
+    #define cp_even_resp cp_rrb_map[0]			/* 0x000280 */
+    #define cp_odd_resp  cp_rrb_map[1]			/* 0x000288 */
+    uint64_t		cp_resp_status;			/* 0x000290 */
+    uint64_t		cp_resp_clear;			/* 0x000298 */
+
+    uint64_t		_pad_0002A0[12];		/* 0x0002{A0..F8} */
+
+    /* 0x000300-0x0003F8 -- Buffer Address Match Registers */
+    struct {
+	uint64_t	upper;				/* 0x0003{00,,,F0} */
+	uint64_t	lower;				/* 0x0003{08,,,F8} */
+    } cp_buf_addr_match[16];
+
+    /* 0x000400-0x0005FF -- Performance Monitor Registers (even only) */
+    struct {
+	uint64_t	flush_w_touch;			/* 0x000{400,,,5C0} */
+	uint64_t	flush_wo_touch;			/* 0x000{408,,,5C8} */
+	uint64_t	inflight;			/* 0x000{410,,,5D0} */
+	uint64_t	prefetch;			/* 0x000{418,,,5D8} */
+	uint64_t	total_pci_retry;		/* 0x000{420,,,5E0} */
+	uint64_t	max_pci_retry;			/* 0x000{428,,,5E8} */
+	uint64_t	max_latency;			/* 0x000{430,,,5F0} */
+	uint64_t	clear_all;			/* 0x000{438,,,5F8} */
+    } cp_buf_count[8];
+
+    
+    /* 0x000600-0x0009FF -- PCI/X registers */
+    uint64_t		cp_pcix_bus_err_addr;		/* 0x000600 */
+    uint64_t		cp_pcix_bus_err_attr;		/* 0x000608 */
+    uint64_t		cp_pcix_bus_err_data;		/* 0x000610 */
+    uint64_t		cp_pcix_pio_split_addr;		/* 0x000618 */
+    uint64_t		cp_pcix_pio_split_attr;		/* 0x000620 */
+    uint64_t		cp_pcix_dma_req_err_attr;	/* 0x000628 */
+    uint64_t		cp_pcix_dma_req_err_addr;	/* 0x000630 */
+    uint64_t		cp_pcix_timeout;		/* 0x000638 */
+
+    uint64_t		_pad_000640[24];		/* 0x000{640,,,6F8} */
+
+    /* 0x000700-0x000737 -- Debug Registers */
+    uint64_t		cp_ct_debug_ctl;		/* 0x000700 */
+    uint64_t		cp_br_debug_ctl;		/* 0x000708 */
+    uint64_t		cp_mux3_debug_ctl;		/* 0x000710 */
+    uint64_t		cp_mux4_debug_ctl;		/* 0x000718 */
+    uint64_t		cp_mux5_debug_ctl;		/* 0x000720 */
+    uint64_t		cp_mux6_debug_ctl;		/* 0x000728 */
+    uint64_t		cp_mux7_debug_ctl;		/* 0x000730 */
+
+    uint64_t		_pad_000738[89];		/* 0x000{738,,,9F8} */
+
+    /* 0x000A00-0x000BFF -- PCI/X Read&Write Buffer */
+    struct {
+	uint64_t	cp_buf_addr;			/* 0x000{A00,,,AF0} */
+	uint64_t	cp_buf_attr;			/* 0X000{A08,,,AF8} */
+    } cp_pcix_read_buf_64[16];
+
+    struct {
+	uint64_t	cp_buf_addr;			/* 0x000{B00,,,BE0} */
+	uint64_t	cp_buf_attr;			/* 0x000{B08,,,BE8} */
+	uint64_t	cp_buf_valid;			/* 0x000{B10,,,BF0} */
+	uint64_t	__pad1;				/* 0x000{B18,,,BF8} */
+    } cp_pcix_write_buf_64[8];
+
+    /* End of Local Registers -- Start of Address Map space */
+
+    char		_pad_000c00[0x010000 - 0x000c00];
+
+    /* 0x010000-0x011FF8 -- Internal ATE RAM (Auto Parity Generation) */
+    uint64_t		cp_int_ate_ram[1024];		/* 0x010000-0x011FF8 */
+
+    char		_pad_012000[0x14000 - 0x012000];
+
+    /* 0x014000-0x015FF8 -- Internal ATE RAM (Manual Parity Generation) */
+    uint64_t		cp_int_ate_ram_mp[1024];	/* 0x014000-0x015FF8 */
+
+    char		_pad_016000[0x18000 - 0x016000];
+
+    /* 0x18000-0x197F8 -- TIOCP Write Request Ram */
+    uint64_t		cp_wr_req_lower[256];		/* 0x18000 - 0x187F8 */
+    uint64_t		cp_wr_req_upper[256];		/* 0x18800 - 0x18FF8 */
+    uint64_t		cp_wr_req_parity[256];		/* 0x19000 - 0x197F8 */
+
+    char		_pad_019800[0x1C000 - 0x019800];
+
+    /* 0x1C000-0x1EFF8 -- TIOCP Read Response Ram */
+    uint64_t		cp_rd_resp_lower[512];		/* 0x1C000 - 0x1CFF8 */
+    uint64_t		cp_rd_resp_upper[512];		/* 0x1D000 - 0x1DFF8 */
+    uint64_t		cp_rd_resp_parity[512];		/* 0x1E000 - 0x1EFF8 */
+
+    char		_pad_01F000[0x20000 - 0x01F000];
+
+    /* 0x020000-0x021FFF -- Host Device (CP) Configuration Space (not used)  */
+    char		_pad_020000[0x021000 - 0x20000];
+
+    /* 0x021000-0x027FFF -- PCI Device Configuration Spaces */
+    union {
+	uint8_t		c[0x1000 / 1];			/* 0x02{0000,,,7FFF} */
+	uint16_t	s[0x1000 / 2];			/* 0x02{0000,,,7FFF} */
+	uint32_t	l[0x1000 / 4];			/* 0x02{0000,,,7FFF} */
+	uint64_t	d[0x1000 / 8];			/* 0x02{0000,,,7FFF} */
+	union {
+	    uint8_t	c[0x100 / 1];
+	    uint16_t	s[0x100 / 2];
+	    uint32_t	l[0x100 / 4];
+	    uint64_t	d[0x100 / 8];
+	} f[8];
+    } cp_type0_cfg_dev[7];				/* 0x02{1000,,,7FFF} */
+
+    /* 0x028000-0x028FFF -- PCI Type 1 Configuration Space */
+    union {
+	uint8_t		c[0x1000 / 1];			/* 0x028000-0x029000 */
+	uint16_t	s[0x1000 / 2];			/* 0x028000-0x029000 */
+	uint32_t	l[0x1000 / 4];			/* 0x028000-0x029000 */
+	uint64_t	d[0x1000 / 8];			/* 0x028000-0x029000 */
+	union {
+	    uint8_t	c[0x100 / 1];
+	    uint16_t	s[0x100 / 2];
+	    uint32_t	l[0x100 / 4];
+	    uint64_t	d[0x100 / 8];
+	} f[8];
+    } cp_type1_cfg;					/* 0x028000-0x029000 */
+
+    char		_pad_029000[0x030000-0x029000];
+
+    /* 0x030000-0x030007 -- PCI Interrupt Acknowledge Cycle */
+    union {
+	uint8_t		c[8 / 1];
+	uint16_t	s[8 / 2];
+	uint32_t	l[8 / 4];
+	uint64_t	d[8 / 8];
+    } cp_pci_iack;					/* 0x030000-0x030007 */
+
+    char		_pad_030007[0x040000-0x030008];
+
+    /* 0x040000-0x040007 -- PCIX Special Cycle */
+    union {
+	uint8_t		c[8 / 1];
+	uint16_t	s[8 / 2];
+	uint32_t	l[8 / 4];
+	uint64_t	d[8 / 8];
+    } cp_pcix_cycle;					/* 0x040000-0x040007 */
+
+    char		_pad_040007[0x200000-0x040008];
+
+    /* 0x200000-0x7FFFFF -- PCI/GIO Device Spaces */
+    union {
+	uint8_t		c[0x100000 / 1];
+	uint16_t	s[0x100000 / 2];
+	uint32_t	l[0x100000 / 4];
+	uint64_t	d[0x100000 / 8];
+    } cp_devio_raw[6];					/* 0x200000-0x7FFFFF */
+
+    #define cp_devio(n)  cp_devio_raw[((n)<2)?(n*2):(n+2)]
+
+    char		_pad_800000[0xA00000-0x800000];
+
+    /* 0xA00000-0xBFFFFF -- PCI/GIO Device Spaces w/flush  */
+    union {
+	uint8_t		c[0x100000 / 1];
+	uint16_t	s[0x100000 / 2];
+	uint32_t	l[0x100000 / 4];
+	uint64_t	d[0x100000 / 8];
+    } cp_devio_raw_flush[6];				/* 0xA00000-0xBFFFFF */
+
+    #define cp_devio_flush(n)  cp_devio_raw_flush[((n)<2)?(n*2):(n+2)]
+
+};
+
+#endif 	/* _ASM_IA64_SN_PCI_TIOCP_H */
diff -Nru a/arch/ia64/sn/include/shub.h b/arch/ia64/sn/include/shub.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/shub.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,39 @@
+/*
+ * 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-2004 Silicon Graphics, Inc.  All rights reserved.
+ */
+
+#ifndef _ASM_IA64_SN_SHUB_H
+#define _ASM_IA64_SN_SHUB_H
+
+
+#define MD_MEM_BANKS            4
+
+
+/*
+ * Junk Bus Address Space
+ *   The junk bus is used to access the PROM, LED's, and UART. It's 
+ *   accessed through the local block MMR space. The data path is
+ *   16 bits wide. This space requires address bits 31-27 to be set, and
+ *   is further divided by address bits 26:15.
+ *   The LED addresses are write-only. To read the LEDs, you need to use
+ *   SH_JUNK_BUS_LED0-3, defined in shub_mmr.h
+ *		
+ */
+#define SH_REAL_JUNK_BUS_LED0           0x7fed00000UL
+#define SH_REAL_JUNK_BUS_LED1           0x7fed10000UL
+#define SH_REAL_JUNK_BUS_LED2           0x7fed20000UL
+#define SH_REAL_JUNK_BUS_LED3           0x7fed30000UL
+#define SH_JUNK_BUS_UART0               0x7fed40000UL
+#define SH_JUNK_BUS_UART1               0x7fed40008UL
+#define SH_JUNK_BUS_UART2               0x7fed40010UL
+#define SH_JUNK_BUS_UART3               0x7fed40018UL
+#define SH_JUNK_BUS_UART4               0x7fed40020UL
+#define SH_JUNK_BUS_UART5               0x7fed40028UL
+#define SH_JUNK_BUS_UART6               0x7fed40030UL
+#define SH_JUNK_BUS_UART7               0x7fed40038UL
+
+#endif /* _ASM_IA64_SN_SHUB_H */
diff -Nru a/arch/ia64/sn/include/shubio.h b/arch/ia64/sn/include/shubio.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/shubio.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,3476 @@
+/*
+ * 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 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#ifndef _ASM_IA64_SN_SHUBIO_H
+#define _ASM_IA64_SN_SHUBIO_H
+
+#define HUB_WIDGET_ID_MAX 0xf
+#define IIO_NUM_ITTES   7
+#define HUB_NUM_BIG_WINDOW      (IIO_NUM_ITTES - 1)
+
+#define    IIO_WID                   0x00400000    /* Crosstalk Widget Identification */
+                                                   /* This register is also accessible from
+                                                    * Crosstalk at address 0x0.  */
+#define    IIO_WSTAT                 0x00400008    /* Crosstalk Widget Status */
+#define    IIO_WCR                   0x00400020    /* Crosstalk Widget Control Register */
+#define    IIO_ILAPR                 0x00400100    /* IO Local Access Protection Register */
+#define    IIO_ILAPO                 0x00400108    /* IO Local Access Protection Override */
+#define    IIO_IOWA                  0x00400110    /* IO Outbound Widget Access */
+#define    IIO_IIWA                  0x00400118    /* IO Inbound Widget Access */
+#define    IIO_IIDEM                 0x00400120    /* IO Inbound Device Error Mask */
+#define    IIO_ILCSR                 0x00400128    /* IO LLP Control and Status Register */
+#define    IIO_ILLR                  0x00400130    /* IO LLP Log Register    */
+#define    IIO_IIDSR                 0x00400138    /* IO Interrupt Destination */
+
+#define    IIO_IGFX0                 0x00400140    /* IO Graphics Node-Widget Map 0 */
+#define    IIO_IGFX1                 0x00400148    /* IO Graphics Node-Widget Map 1 */
+
+#define    IIO_ISCR0                 0x00400150    /* IO Scratch Register 0 */
+#define    IIO_ISCR1                 0x00400158    /* IO Scratch Register 1 */
+
+#define    IIO_ITTE1                 0x00400160    /* IO Translation Table Entry 1 */
+#define    IIO_ITTE2                 0x00400168    /* IO Translation Table Entry 2 */
+#define    IIO_ITTE3                 0x00400170    /* IO Translation Table Entry 3 */
+#define    IIO_ITTE4                 0x00400178    /* IO Translation Table Entry 4 */
+#define    IIO_ITTE5                 0x00400180    /* IO Translation Table Entry 5 */
+#define    IIO_ITTE6                 0x00400188    /* IO Translation Table Entry 6 */
+#define    IIO_ITTE7                 0x00400190    /* IO Translation Table Entry 7 */
+
+#define    IIO_IPRB0                 0x00400198    /* IO PRB Entry 0         */
+#define    IIO_IPRB8                 0x004001A0    /* IO PRB Entry 8         */
+#define    IIO_IPRB9                 0x004001A8    /* IO PRB Entry 9         */
+#define    IIO_IPRBA                 0x004001B0    /* IO PRB Entry A         */
+#define    IIO_IPRBB                 0x004001B8    /* IO PRB Entry B         */
+#define    IIO_IPRBC                 0x004001C0    /* IO PRB Entry C         */
+#define    IIO_IPRBD                 0x004001C8    /* IO PRB Entry D         */
+#define    IIO_IPRBE                 0x004001D0    /* IO PRB Entry E         */
+#define    IIO_IPRBF                 0x004001D8    /* IO PRB Entry F         */
+
+#define    IIO_IXCC                  0x004001E0    /* IO Crosstalk Credit Count Timeout */
+#define    IIO_IMEM                  0x004001E8    /* IO Miscellaneous Error Mask */
+#define    IIO_IXTT                  0x004001F0    /* IO Crosstalk Timeout Threshold */
+#define    IIO_IECLR                 0x004001F8    /* IO Error Clear Register */
+#define    IIO_IBCR                  0x00400200    /* IO BTE Control Register */
+
+#define    IIO_IXSM                  0x00400208    /* IO Crosstalk Spurious Message */
+#define    IIO_IXSS                  0x00400210    /* IO Crosstalk Spurious Sideband */
+
+#define    IIO_ILCT                  0x00400218    /* IO LLP Channel Test    */
+
+#define    IIO_IIEPH1                0x00400220    /* IO Incoming Error Packet Header, Part 1 */
+#define    IIO_IIEPH2                0x00400228    /* IO Incoming Error Packet Header, Part 2 */
+
+
+#define    IIO_ISLAPR                0x00400230    /* IO SXB Local Access Protection Regster */
+#define    IIO_ISLAPO                0x00400238    /* IO SXB Local Access Protection Override */
+
+#define    IIO_IWI                   0x00400240    /* IO Wrapper Interrupt Register */
+#define    IIO_IWEL                  0x00400248    /* IO Wrapper Error Log Register */
+#define    IIO_IWC                   0x00400250    /* IO Wrapper Control Register */
+#define    IIO_IWS                   0x00400258    /* IO Wrapper Status Register */
+#define    IIO_IWEIM                 0x00400260    /* IO Wrapper Error Interrupt Masking Register */
+
+#define    IIO_IPCA                  0x00400300    /* IO PRB Counter Adjust */
+
+#define    IIO_IPRTE0_A              0x00400308    /* IO PIO Read Address Table Entry 0, Part A */
+#define    IIO_IPRTE1_A              0x00400310    /* IO PIO Read Address Table Entry 1, Part A */
+#define    IIO_IPRTE2_A              0x00400318    /* IO PIO Read Address Table Entry 2, Part A */
+#define    IIO_IPRTE3_A               0x00400320    /* IO PIO Read Address Table Entry 3, Part A */
+#define    IIO_IPRTE4_A               0x00400328    /* IO PIO Read Address Table Entry 4, Part A */
+#define    IIO_IPRTE5_A               0x00400330    /* IO PIO Read Address Table Entry 5, Part A */
+#define    IIO_IPRTE6_A               0x00400338    /* IO PIO Read Address Table Entry 6, Part A */
+#define    IIO_IPRTE7_A               0x00400340    /* IO PIO Read Address Table Entry 7, Part A */
+
+#define    IIO_IPRTE0_B              0x00400348    /* IO PIO Read Address Table Entry 0, Part B */
+#define    IIO_IPRTE1_B              0x00400350    /* IO PIO Read Address Table Entry 1, Part B */
+#define    IIO_IPRTE2_B              0x00400358    /* IO PIO Read Address Table Entry 2, Part B */
+#define    IIO_IPRTE3_B               0x00400360    /* IO PIO Read Address Table Entry 3, Part B */
+#define    IIO_IPRTE4_B               0x00400368    /* IO PIO Read Address Table Entry 4, Part B */
+#define    IIO_IPRTE5_B               0x00400370    /* IO PIO Read Address Table Entry 5, Part B */
+#define    IIO_IPRTE6_B               0x00400378    /* IO PIO Read Address Table Entry 6, Part B */
+#define    IIO_IPRTE7_B               0x00400380    /* IO PIO Read Address Table Entry 7, Part B */
+
+#define    IIO_IPDR                  0x00400388    /* IO PIO Deallocation Register */
+#define    IIO_ICDR                  0x00400390    /* IO CRB Entry Deallocation Register */
+#define    IIO_IFDR                  0x00400398    /* IO IOQ FIFO Depth Register */
+#define    IIO_IIAP                  0x004003A0    /* IO IIQ Arbitration Parameters */
+#define    IIO_ICMR                  0x004003A8    /* IO CRB Management Register */
+#define    IIO_ICCR                  0x004003B0    /* IO CRB Control Register */
+#define    IIO_ICTO                  0x004003B8    /* IO CRB Timeout         */
+#define    IIO_ICTP                  0x004003C0    /* IO CRB Timeout Prescalar */
+
+#define    IIO_ICRB0_A               0x00400400    /* IO CRB Entry 0_A       */
+#define    IIO_ICRB0_B               0x00400408    /* IO CRB Entry 0_B       */
+#define    IIO_ICRB0_C               0x00400410    /* IO CRB Entry 0_C       */
+#define    IIO_ICRB0_D               0x00400418    /* IO CRB Entry 0_D       */
+#define    IIO_ICRB0_E               0x00400420    /* IO CRB Entry 0_E       */
+
+#define    IIO_ICRB1_A               0x00400430    /* IO CRB Entry 1_A       */
+#define    IIO_ICRB1_B               0x00400438    /* IO CRB Entry 1_B       */
+#define    IIO_ICRB1_C               0x00400440    /* IO CRB Entry 1_C       */
+#define    IIO_ICRB1_D               0x00400448    /* IO CRB Entry 1_D       */
+#define    IIO_ICRB1_E               0x00400450    /* IO CRB Entry 1_E       */
+
+#define    IIO_ICRB2_A               0x00400460    /* IO CRB Entry 2_A       */
+#define    IIO_ICRB2_B               0x00400468    /* IO CRB Entry 2_B       */
+#define    IIO_ICRB2_C               0x00400470    /* IO CRB Entry 2_C       */
+#define    IIO_ICRB2_D               0x00400478    /* IO CRB Entry 2_D       */
+#define    IIO_ICRB2_E               0x00400480    /* IO CRB Entry 2_E       */
+
+#define    IIO_ICRB3_A               0x00400490    /* IO CRB Entry 3_A       */
+#define    IIO_ICRB3_B               0x00400498    /* IO CRB Entry 3_B       */
+#define    IIO_ICRB3_C               0x004004a0    /* IO CRB Entry 3_C       */
+#define    IIO_ICRB3_D               0x004004a8    /* IO CRB Entry 3_D       */
+#define    IIO_ICRB3_E               0x004004b0    /* IO CRB Entry 3_E       */
+
+#define    IIO_ICRB4_A               0x004004c0    /* IO CRB Entry 4_A       */
+#define    IIO_ICRB4_B               0x004004c8    /* IO CRB Entry 4_B       */
+#define    IIO_ICRB4_C               0x004004d0    /* IO CRB Entry 4_C       */
+#define    IIO_ICRB4_D               0x004004d8    /* IO CRB Entry 4_D       */
+#define    IIO_ICRB4_E               0x004004e0    /* IO CRB Entry 4_E       */
+
+#define    IIO_ICRB5_A               0x004004f0    /* IO CRB Entry 5_A       */
+#define    IIO_ICRB5_B               0x004004f8    /* IO CRB Entry 5_B       */
+#define    IIO_ICRB5_C               0x00400500    /* IO CRB Entry 5_C       */
+#define    IIO_ICRB5_D               0x00400508    /* IO CRB Entry 5_D       */
+#define    IIO_ICRB5_E               0x00400510    /* IO CRB Entry 5_E       */
+
+#define    IIO_ICRB6_A               0x00400520    /* IO CRB Entry 6_A       */
+#define    IIO_ICRB6_B               0x00400528    /* IO CRB Entry 6_B       */
+#define    IIO_ICRB6_C               0x00400530    /* IO CRB Entry 6_C       */
+#define    IIO_ICRB6_D               0x00400538    /* IO CRB Entry 6_D       */
+#define    IIO_ICRB6_E               0x00400540    /* IO CRB Entry 6_E       */
+
+#define    IIO_ICRB7_A               0x00400550    /* IO CRB Entry 7_A       */
+#define    IIO_ICRB7_B               0x00400558    /* IO CRB Entry 7_B       */
+#define    IIO_ICRB7_C               0x00400560    /* IO CRB Entry 7_C       */
+#define    IIO_ICRB7_D               0x00400568    /* IO CRB Entry 7_D       */
+#define    IIO_ICRB7_E               0x00400570    /* IO CRB Entry 7_E       */
+
+#define    IIO_ICRB8_A               0x00400580    /* IO CRB Entry 8_A       */
+#define    IIO_ICRB8_B               0x00400588    /* IO CRB Entry 8_B       */
+#define    IIO_ICRB8_C               0x00400590    /* IO CRB Entry 8_C       */
+#define    IIO_ICRB8_D               0x00400598    /* IO CRB Entry 8_D       */
+#define    IIO_ICRB8_E               0x004005a0    /* IO CRB Entry 8_E       */
+
+#define    IIO_ICRB9_A               0x004005b0    /* IO CRB Entry 9_A       */
+#define    IIO_ICRB9_B               0x004005b8    /* IO CRB Entry 9_B       */
+#define    IIO_ICRB9_C               0x004005c0    /* IO CRB Entry 9_C       */
+#define    IIO_ICRB9_D               0x004005c8    /* IO CRB Entry 9_D       */
+#define    IIO_ICRB9_E               0x004005d0    /* IO CRB Entry 9_E       */
+
+#define    IIO_ICRBA_A               0x004005e0    /* IO CRB Entry A_A       */
+#define    IIO_ICRBA_B               0x004005e8    /* IO CRB Entry A_B       */
+#define    IIO_ICRBA_C               0x004005f0    /* IO CRB Entry A_C       */
+#define    IIO_ICRBA_D               0x004005f8    /* IO CRB Entry A_D       */
+#define    IIO_ICRBA_E               0x00400600    /* IO CRB Entry A_E       */
+
+#define    IIO_ICRBB_A               0x00400610    /* IO CRB Entry B_A       */
+#define    IIO_ICRBB_B               0x00400618    /* IO CRB Entry B_B       */
+#define    IIO_ICRBB_C               0x00400620    /* IO CRB Entry B_C       */
+#define    IIO_ICRBB_D               0x00400628    /* IO CRB Entry B_D       */
+#define    IIO_ICRBB_E               0x00400630    /* IO CRB Entry B_E       */
+
+#define    IIO_ICRBC_A               0x00400640    /* IO CRB Entry C_A       */
+#define    IIO_ICRBC_B               0x00400648    /* IO CRB Entry C_B       */
+#define    IIO_ICRBC_C               0x00400650    /* IO CRB Entry C_C       */
+#define    IIO_ICRBC_D               0x00400658    /* IO CRB Entry C_D       */
+#define    IIO_ICRBC_E               0x00400660    /* IO CRB Entry C_E       */
+
+#define    IIO_ICRBD_A               0x00400670    /* IO CRB Entry D_A       */
+#define    IIO_ICRBD_B               0x00400678    /* IO CRB Entry D_B       */
+#define    IIO_ICRBD_C               0x00400680    /* IO CRB Entry D_C       */
+#define    IIO_ICRBD_D               0x00400688    /* IO CRB Entry D_D       */
+#define    IIO_ICRBD_E               0x00400690    /* IO CRB Entry D_E       */
+
+#define    IIO_ICRBE_A               0x004006a0    /* IO CRB Entry E_A       */
+#define    IIO_ICRBE_B               0x004006a8    /* IO CRB Entry E_B       */
+#define    IIO_ICRBE_C               0x004006b0    /* IO CRB Entry E_C       */
+#define    IIO_ICRBE_D               0x004006b8    /* IO CRB Entry E_D       */
+#define    IIO_ICRBE_E               0x004006c0    /* IO CRB Entry E_E       */
+
+#define    IIO_ICSML                 0x00400700    /* IO CRB Spurious Message Low */
+#define    IIO_ICSMM                 0x00400708    /* IO CRB Spurious Message Middle */
+#define    IIO_ICSMH                 0x00400710    /* IO CRB Spurious Message High */
+
+#define    IIO_IDBSS                 0x00400718    /* IO Debug Submenu Select */
+
+#define    IIO_IBLS0                 0x00410000    /* IO BTE Length Status 0 */
+#define    IIO_IBSA0                 0x00410008    /* IO BTE Source Address 0 */
+#define    IIO_IBDA0                 0x00410010    /* IO BTE Destination Address 0 */
+#define    IIO_IBCT0                 0x00410018    /* IO BTE Control Terminate 0 */
+#define    IIO_IBNA0                 0x00410020    /* IO BTE Notification Address 0 */
+#define    IIO_IBIA0                 0x00410028    /* IO BTE Interrupt Address 0 */
+#define    IIO_IBLS1                 0x00420000    /* IO BTE Length Status 1 */
+#define    IIO_IBSA1                 0x00420008    /* IO BTE Source Address 1 */
+#define    IIO_IBDA1                 0x00420010    /* IO BTE Destination Address 1 */
+#define    IIO_IBCT1                 0x00420018    /* IO BTE Control Terminate 1 */
+#define    IIO_IBNA1                 0x00420020    /* IO BTE Notification Address 1 */
+#define    IIO_IBIA1                 0x00420028    /* IO BTE Interrupt Address 1 */
+
+#define    IIO_IPCR                  0x00430000    /* IO Performance Control */
+#define    IIO_IPPR                  0x00430008    /* IO Performance Profiling */
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This register echoes some information from the         *
+ * LB_REV_ID register. It is available through Crosstalk as described   *
+ * above. The REV_NUM and MFG_NUM fields receive their values from      *
+ * the REVISION and MANUFACTURER fields in the LB_REV_ID register.      *
+ * The PART_NUM field's value is the Crosstalk device ID number that    *
+ * Steve Miller assigned to the SHub chip.                              *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_wid_u {
+	uint64_t	ii_wid_regval;
+	struct	{
+		uint64_t	w_rsvd_1		  :	 1;
+		uint64_t	w_mfg_num		  :	11;
+		uint64_t	w_part_num		  :	16;
+		uint64_t	w_rev_num		  :	 4;
+		uint64_t	w_rsvd			  :	32;
+	} ii_wid_fld_s;
+} ii_wid_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  The fields in this register are set upon detection of an error      *
+ * and cleared by various mechanisms, as explained in the               *
+ * description.                                                         *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_wstat_u {
+	uint64_t	ii_wstat_regval;
+	struct	{
+		uint64_t	w_pending		  :	 4;
+		uint64_t	w_xt_crd_to		  :	 1;
+		uint64_t	w_xt_tail_to		  :	 1;
+		uint64_t	w_rsvd_3		  :	 3;
+		uint64_t       w_tx_mx_rty               :      1;
+		uint64_t	w_rsvd_2		  :	 6;
+		uint64_t	w_llp_tx_cnt		  :	 8;
+		uint64_t	w_rsvd_1		  :	 8;
+		uint64_t	w_crazy			  :	 1;
+		uint64_t	w_rsvd			  :	31;
+	} ii_wstat_fld_s;
+} ii_wstat_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This is a read-write enabled register. It controls     *
+ * various aspects of the Crosstalk flow control.                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_wcr_u {
+	uint64_t	ii_wcr_regval;
+	struct	{
+		uint64_t	w_wid			  :	 4;
+		uint64_t	w_tag			  :	 1;
+		uint64_t	w_rsvd_1		  :	 8;
+		uint64_t	w_dst_crd		  :	 3;
+		uint64_t	w_f_bad_pkt		  :	 1;
+		uint64_t	w_dir_con		  :	 1;
+		uint64_t	w_e_thresh		  :	 5;
+		uint64_t	w_rsvd			  :	41;
+	} ii_wcr_fld_s;
+} ii_wcr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This register's value is a bit vector that guards      *
+ * access to local registers within the II as well as to external       *
+ * Crosstalk widgets. Each bit in the register corresponds to a         *
+ * particular region in the system; a region consists of one, two or    *
+ * four nodes (depending on the value of the REGION_SIZE field in the   *
+ * LB_REV_ID register, which is documented in Section 8.3.1.1). The     *
+ * protection provided by this register applies to PIO read             *
+ * operations as well as PIO write operations. The II will perform a    *
+ * PIO read or write request only if the bit for the requestor's        *
+ * region is set; otherwise, the II will not perform the requested      *
+ * operation and will return an error response. When a PIO read or      *
+ * write request targets an external Crosstalk widget, then not only    *
+ * must the bit for the requestor's region be set in the ILAPR, but     *
+ * also the target widget's bit in the IOWA register must be set in     *
+ * order for the II to perform the requested operation; otherwise,      *
+ * the II will return an error response. Hence, the protection          *
+ * provided by the IOWA register supplements the protection provided    *
+ * by the ILAPR for requests that target external Crosstalk widgets.    *
+ * This register itself can be accessed only by the nodes whose         *
+ * region ID bits are enabled in this same register. It can also be     *
+ * accessed through the IAlias space by the local processors.           *
+ * The reset value of this register allows access by all nodes.         *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ilapr_u {
+	uint64_t	ii_ilapr_regval;
+	struct  {
+		uint64_t	i_region                  :	64;
+	} ii_ilapr_fld_s;
+} ii_ilapr_u_t;
+
+
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  A write to this register of the 64-bit value           *
+ * "SGIrules" in ASCII, will cause the bit in the ILAPR register        *
+ * corresponding to the region of the requestor to be set (allow        *
+ * access). A write of any other value will be ignored. Access          *
+ * protection for this register is "SGIrules".                          *
+ * This register can also be accessed through the IAlias space.         *
+ * However, this access will not change the access permissions in the   *
+ * ILAPR.                                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ilapo_u {
+	uint64_t	ii_ilapo_regval;
+	struct	{
+		uint64_t	i_io_ovrride            :	64;
+	} ii_ilapo_fld_s;
+} ii_ilapo_u_t;
+
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register qualifies all the PIO and Graphics writes launched    *
+ * from the SHUB towards a widget.                                      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iowa_u {
+	uint64_t	ii_iowa_regval;
+	struct	{
+		uint64_t	i_w0_oac		  :	 1;
+		uint64_t	i_rsvd_1		  :	 7;
+                uint64_t       i_wx_oac                  :      8;
+		uint64_t	i_rsvd			  :	48;
+	} ii_iowa_fld_s;
+} ii_iowa_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This register qualifies all the requests launched      *
+ * from a widget towards the Shub. This register is intended to be      *
+ * used by software in case of misbehaving widgets.                     *
+ *                                                                      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iiwa_u {
+	uint64_t	ii_iiwa_regval;
+	struct  {
+		uint64_t	i_w0_iac                  :	 1;
+		uint64_t	i_rsvd_1		  :	 7;
+		uint64_t	i_wx_iac		  :	 8;
+		uint64_t	i_rsvd			  :	48;
+	} ii_iiwa_fld_s;
+} ii_iiwa_u_t;
+
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This register qualifies all the operations launched    *
+ * from a widget towards the SHub. It allows individual access          *
+ * control for up to 8 devices per widget. A device refers to           *
+ * individual DMA master hosted by a widget.                            *
+ * The bits in each field of this register are cleared by the Shub      *
+ * upon detection of an error which requires the device to be           *
+ * disabled. These fields assume that 0=TNUM=7 (i.e., Bridge-centric    *
+ * Crosstalk). Whether or not a device has access rights to this        *
+ * Shub is determined by an AND of the device enable bit in the         *
+ * appropriate field of this register and the corresponding bit in      *
+ * the Wx_IAC field (for the widget which this device belongs to).      *
+ * The bits in this field are set by writing a 1 to them. Incoming      *
+ * replies from Crosstalk are not subject to this access control        *
+ * mechanism.                                                           *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iidem_u {
+	uint64_t	ii_iidem_regval;
+	struct	{
+		uint64_t	i_w8_dxs		  :	 8;
+		uint64_t	i_w9_dxs		  :	 8;
+		uint64_t	i_wa_dxs		  :	 8;
+		uint64_t	i_wb_dxs		  :	 8;
+		uint64_t	i_wc_dxs		  :	 8;
+		uint64_t	i_wd_dxs		  :	 8;
+		uint64_t	i_we_dxs		  :	 8;
+		uint64_t	i_wf_dxs		  :	 8;
+	} ii_iidem_fld_s;
+} ii_iidem_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the various programmable fields necessary    *
+ * for controlling and observing the LLP signals.                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ilcsr_u {
+	uint64_t	ii_ilcsr_regval;
+	struct  {
+		uint64_t	i_nullto                  :	 6;
+		uint64_t	i_rsvd_4		  :	 2;
+		uint64_t	i_wrmrst		  :	 1;
+		uint64_t	i_rsvd_3		  :	 1;
+		uint64_t	i_llp_en		  :	 1;
+		uint64_t	i_bm8			  :	 1;
+		uint64_t	i_llp_stat		  :	 2;
+		uint64_t	i_remote_power		  :	 1;
+		uint64_t	i_rsvd_2		  :	 1;
+		uint64_t	i_maxrtry		  :	10;
+		uint64_t	i_d_avail_sel		  :	 2;
+		uint64_t	i_rsvd_1		  :	 4;
+		uint64_t	i_maxbrst		  :	10;
+                uint64_t       i_rsvd                    :     22;
+
+	} ii_ilcsr_fld_s;
+} ii_ilcsr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This is simply a status registers that monitors the LLP error       *
+ * rate.                                                                *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_illr_u {
+	uint64_t	ii_illr_regval;
+	struct	{
+		uint64_t	i_sn_cnt		  :	16;
+		uint64_t	i_cb_cnt		  :	16;
+		uint64_t	i_rsvd			  :	32;
+	} ii_illr_fld_s;
+} ii_illr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  All II-detected non-BTE error interrupts are           *
+ * specified via this register.                                         *
+ * NOTE: The PI interrupt register address is hardcoded in the II. If   *
+ * PI_ID==0, then the II sends an interrupt request (Duplonet PWRI      *
+ * packet) to address offset 0x0180_0090 within the local register      *
+ * address space of PI0 on the node specified by the NODE field. If     *
+ * PI_ID==1, then the II sends the interrupt request to address         *
+ * offset 0x01A0_0090 within the local register address space of PI1    *
+ * on the node specified by the NODE field.                             *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iidsr_u {
+	uint64_t	ii_iidsr_regval;
+	struct  {
+		uint64_t	i_level                   :	 8;
+		uint64_t	i_pi_id			  :	 1;
+		uint64_t	i_node			  :	11;
+		uint64_t       i_rsvd_3                  :      4;
+		uint64_t	i_enable		  :	 1;
+		uint64_t	i_rsvd_2		  :	 3;
+		uint64_t	i_int_sent		  :	 2;
+		uint64_t       i_rsvd_1                  :      2;
+		uint64_t	i_pi0_forward_int	  :	 1;
+		uint64_t	i_pi1_forward_int	  :	 1;
+		uint64_t	i_rsvd			  :	30;
+	} ii_iidsr_fld_s;
+} ii_iidsr_u_t;
+
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are two instances of this register. This register is used     *
+ * for matching up the incoming responses from the graphics widget to   *
+ * the processor that initiated the graphics operation. The             *
+ * write-responses are converted to graphics credits and returned to    *
+ * the processor so that the processor interface can manage the flow    *
+ * control.                                                             *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_igfx0_u {
+	uint64_t	ii_igfx0_regval;
+	struct	{
+		uint64_t	i_w_num			  :	 4;
+		uint64_t       i_pi_id                   :      1;
+		uint64_t	i_n_num			  :	12;
+		uint64_t       i_p_num                   :      1;
+		uint64_t       i_rsvd                    :     46;
+	} ii_igfx0_fld_s;
+} ii_igfx0_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are two instances of this register. This register is used     *
+ * for matching up the incoming responses from the graphics widget to   *
+ * the processor that initiated the graphics operation. The             *
+ * write-responses are converted to graphics credits and returned to    *
+ * the processor so that the processor interface can manage the flow    *
+ * control.                                                             *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_igfx1_u {
+	uint64_t	ii_igfx1_regval;
+	struct  {
+		uint64_t	i_w_num			  :	 4;
+		uint64_t       i_pi_id                   :      1;
+		uint64_t	i_n_num			  :	12;
+		uint64_t       i_p_num                   :      1;
+		uint64_t       i_rsvd                    :     46;
+	} ii_igfx1_fld_s;
+} ii_igfx1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are two instances of this registers. These registers are      *
+ * used as scratch registers for software use.                          *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iscr0_u {
+	uint64_t	ii_iscr0_regval;
+	struct  {
+		uint64_t	i_scratch                 :	64;
+	} ii_iscr0_fld_s;
+} ii_iscr0_u_t;
+
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are two instances of this registers. These registers are      *
+ * used as scratch registers for software use.                          *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iscr1_u {
+	uint64_t	ii_iscr1_regval;
+	struct  {
+		uint64_t	i_scratch                 :	64;
+	} ii_iscr1_fld_s;
+} ii_iscr1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are seven instances of translation table entry   *
+ * registers. Each register maps a Shub Big Window to a 48-bit          *
+ * address on Crosstalk.                                                *
+ * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
+ * number) are used to select one of these 7 registers. The Widget      *
+ * number field is then derived from the W_NUM field for synthesizing   *
+ * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
+ * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
+ * are padded with zeros. Although the maximum Crosstalk space          *
+ * addressable by the SHub is thus the lower 16 GBytes per widget       * 
+ * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
+ * space can be accessed.                                               *
+ * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
+ * Window number) are used to select one of these 7 registers. The      *
+ * Widget number field is then derived from the W_NUM field for         *
+ * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
+ * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
+ * field is used as Crosstalk[47], and remainder of the Crosstalk       *
+ * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
+ * Crosstalk space addressable by the Shub is thus the lower            *
+ * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
+ * of this space can be accessed.                                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_itte1_u {
+	uint64_t	ii_itte1_regval;
+	struct  {
+		uint64_t	i_offset                  :	 5;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t	i_w_num			  :	 4;
+		uint64_t	i_iosp			  :	 1;
+		uint64_t	i_rsvd			  :	51;
+	} ii_itte1_fld_s;
+} ii_itte1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are seven instances of translation table entry   *
+ * registers. Each register maps a Shub Big Window to a 48-bit          *
+ * address on Crosstalk.                                                *
+ * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
+ * number) are used to select one of these 7 registers. The Widget      *
+ * number field is then derived from the W_NUM field for synthesizing   *
+ * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
+ * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
+ * are padded with zeros. Although the maximum Crosstalk space          *
+ * addressable by the Shub is thus the lower 16 GBytes per widget       *
+ * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
+ * space can be accessed.                                               *
+ * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
+ * Window number) are used to select one of these 7 registers. The      *
+ * Widget number field is then derived from the W_NUM field for         *
+ * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
+ * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
+ * field is used as Crosstalk[47], and remainder of the Crosstalk       *
+ * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
+ * Crosstalk space addressable by the Shub is thus the lower            *
+ * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
+ * of this space can be accessed.                                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_itte2_u {
+	uint64_t	ii_itte2_regval;
+	struct	{
+		uint64_t	i_offset		  :	 5;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t	i_w_num			  :	 4;
+		uint64_t	i_iosp			  :	 1;
+		uint64_t       i_rsvd                    :     51;
+	} ii_itte2_fld_s;
+} ii_itte2_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are seven instances of translation table entry   *
+ * registers. Each register maps a Shub Big Window to a 48-bit          *
+ * address on Crosstalk.                                                *
+ * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
+ * number) are used to select one of these 7 registers. The Widget      *
+ * number field is then derived from the W_NUM field for synthesizing   *
+ * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
+ * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
+ * are padded with zeros. Although the maximum Crosstalk space          *
+ * addressable by the Shub is thus the lower 16 GBytes per widget       *
+ * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
+ * space can be accessed.                                               *
+ * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
+ * Window number) are used to select one of these 7 registers. The      *
+ * Widget number field is then derived from the W_NUM field for         *
+ * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
+ * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
+ * field is used as Crosstalk[47], and remainder of the Crosstalk       *
+ * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
+ * Crosstalk space addressable by the SHub is thus the lower            *
+ * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
+ * of this space can be accessed.                                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_itte3_u {
+	uint64_t	ii_itte3_regval;
+	struct  {
+		uint64_t	i_offset                  :	 5;
+		uint64_t       i_rsvd_1                  :      3;
+		uint64_t       i_w_num                   :      4;
+		uint64_t       i_iosp                    :      1;
+		uint64_t       i_rsvd                    :     51;
+	} ii_itte3_fld_s;
+} ii_itte3_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are seven instances of translation table entry   *
+ * registers. Each register maps a SHub Big Window to a 48-bit          *
+ * address on Crosstalk.                                                *
+ * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
+ * number) are used to select one of these 7 registers. The Widget      *
+ * number field is then derived from the W_NUM field for synthesizing   *
+ * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
+ * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
+ * are padded with zeros. Although the maximum Crosstalk space          *
+ * addressable by the SHub is thus the lower 16 GBytes per widget       *
+ * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
+ * space can be accessed.                                               *
+ * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
+ * Window number) are used to select one of these 7 registers. The      *
+ * Widget number field is then derived from the W_NUM field for         *
+ * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
+ * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
+ * field is used as Crosstalk[47], and remainder of the Crosstalk       *
+ * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
+ * Crosstalk space addressable by the SHub is thus the lower            *
+ * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
+ * of this space can be accessed.                                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_itte4_u {
+	uint64_t	ii_itte4_regval;
+	struct  {
+		uint64_t	i_offset                  :	 5;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t       i_w_num                   :      4;
+		uint64_t       i_iosp                    :      1;
+		uint64_t       i_rsvd                    :     51;
+	} ii_itte4_fld_s;
+} ii_itte4_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are seven instances of translation table entry   *
+ * registers. Each register maps a SHub Big Window to a 48-bit          *
+ * address on Crosstalk.                                                *
+ * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
+ * number) are used to select one of these 7 registers. The Widget      *
+ * number field is then derived from the W_NUM field for synthesizing   *
+ * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
+ * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
+ * are padded with zeros. Although the maximum Crosstalk space          *
+ * addressable by the Shub is thus the lower 16 GBytes per widget       *
+ * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
+ * space can be accessed.                                               *
+ * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
+ * Window number) are used to select one of these 7 registers. The      *
+ * Widget number field is then derived from the W_NUM field for         *
+ * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
+ * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
+ * field is used as Crosstalk[47], and remainder of the Crosstalk       *
+ * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
+ * Crosstalk space addressable by the Shub is thus the lower            *
+ * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
+ * of this space can be accessed.                                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_itte5_u {
+	uint64_t	ii_itte5_regval;
+	struct  {
+		uint64_t	i_offset                  :	 5;
+		uint64_t       i_rsvd_1                  :      3;
+		uint64_t       i_w_num                   :      4;
+		uint64_t       i_iosp                    :      1;
+		uint64_t       i_rsvd                    :     51;
+	} ii_itte5_fld_s;
+} ii_itte5_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are seven instances of translation table entry   *
+ * registers. Each register maps a Shub Big Window to a 48-bit          *
+ * address on Crosstalk.                                                *
+ * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
+ * number) are used to select one of these 7 registers. The Widget      *
+ * number field is then derived from the W_NUM field for synthesizing   *
+ * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
+ * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
+ * are padded with zeros. Although the maximum Crosstalk space          *
+ * addressable by the Shub is thus the lower 16 GBytes per widget       *
+ * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
+ * space can be accessed.                                               *
+ * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
+ * Window number) are used to select one of these 7 registers. The      *
+ * Widget number field is then derived from the W_NUM field for         *
+ * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
+ * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
+ * field is used as Crosstalk[47], and remainder of the Crosstalk       *
+ * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
+ * Crosstalk space addressable by the Shub is thus the lower            *
+ * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
+ * of this space can be accessed.                                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_itte6_u {
+	uint64_t	ii_itte6_regval;
+	struct  {
+		uint64_t	i_offset                  :	 5;
+		uint64_t       i_rsvd_1                  :      3;
+		uint64_t       i_w_num                   :      4;
+		uint64_t       i_iosp                    :      1;
+		uint64_t       i_rsvd                    :     51;
+	} ii_itte6_fld_s;
+} ii_itte6_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are seven instances of translation table entry   *
+ * registers. Each register maps a Shub Big Window to a 48-bit          *
+ * address on Crosstalk.                                                *
+ * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
+ * number) are used to select one of these 7 registers. The Widget      *
+ * number field is then derived from the W_NUM field for synthesizing   *
+ * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
+ * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
+ * are padded with zeros. Although the maximum Crosstalk space          *
+ * addressable by the Shub is thus the lower 16 GBytes per widget       *
+ * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
+ * space can be accessed.                                               *
+ * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
+ * Window number) are used to select one of these 7 registers. The      *
+ * Widget number field is then derived from the W_NUM field for         *
+ * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
+ * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
+ * field is used as Crosstalk[47], and remainder of the Crosstalk       *
+ * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
+ * Crosstalk space addressable by the SHub is thus the lower            *
+ * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
+ * of this space can be accessed.                                       *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_itte7_u {
+	uint64_t	ii_itte7_regval;
+	struct  {
+		uint64_t	i_offset                  :	 5;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t       i_w_num                   :      4;
+		uint64_t       i_iosp                    :      1;
+		uint64_t       i_rsvd                    :     51;
+	} ii_itte7_fld_s;
+} ii_itte7_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of SHub and Crossbow.           *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ * .                                                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprb0_u {
+	uint64_t	ii_iprb0_regval;
+	struct  {
+		uint64_t	i_c                       :	 8;
+		uint64_t	i_na			  :	14;
+		uint64_t       i_rsvd_2                  :      2;
+		uint64_t	i_nb			  :	14;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_m			  :	 2;
+		uint64_t	i_f			  :	 1;
+		uint64_t	i_of_cnt		  :	 5;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rd_to			  :	 1;
+		uint64_t	i_spur_wr		  :	 1;
+		uint64_t	i_spur_rd		  :	 1;
+		uint64_t	i_rsvd			  :	11;
+		uint64_t	i_mult_err		  :	 1;
+	} ii_iprb0_fld_s;
+} ii_iprb0_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of SHub and Crossbow.           *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ * .                                                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprb8_u {
+	uint64_t	ii_iprb8_regval;
+	struct  {
+		uint64_t	i_c                       :	 8;
+		uint64_t	i_na			  :	14;
+		uint64_t       i_rsvd_2                  :      2;
+		uint64_t	i_nb			  :	14;
+		uint64_t       i_rsvd_1                  :      2;
+		uint64_t       i_m                       :      2;
+		uint64_t       i_f                       :      1;
+		uint64_t       i_of_cnt                  :      5;
+		uint64_t       i_error                   :      1;
+		uint64_t       i_rd_to                   :      1;
+		uint64_t       i_spur_wr                 :      1;
+		uint64_t	i_spur_rd		  :	 1;
+		uint64_t       i_rsvd                    :     11;
+		uint64_t	i_mult_err		  :	 1;
+	} ii_iprb8_fld_s;
+} ii_iprb8_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of SHub and Crossbow.           *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ * .                                                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprb9_u {
+	uint64_t	ii_iprb9_regval;
+	struct	{
+		uint64_t	i_c			  :	 8;
+		uint64_t	i_na			  :	14;
+		uint64_t	i_rsvd_2		  :	 2;
+		uint64_t	i_nb			  :	14;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_m			  :	 2;
+		uint64_t	i_f			  :	 1;
+		uint64_t	i_of_cnt		  :	 5;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rd_to			  :	 1;
+		uint64_t	i_spur_wr		  :	 1;
+		uint64_t	i_spur_rd		  :	 1;
+		uint64_t	i_rsvd			  :	11;
+		uint64_t	i_mult_err		  :	 1;
+	} ii_iprb9_fld_s;
+} ii_iprb9_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of SHub and Crossbow.        *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ *                                                                      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprba_u {
+	uint64_t	ii_iprba_regval;
+	struct  {
+		uint64_t	i_c                       :	 8;
+		uint64_t	i_na			  :	14;
+		uint64_t       i_rsvd_2                  :      2;
+		uint64_t	i_nb			  :	14;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_m			  :	 2;
+		uint64_t	i_f			  :	 1;
+		uint64_t	i_of_cnt		  :	 5;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rd_to			  :	 1;
+		uint64_t	i_spur_wr		  :	 1;
+		uint64_t	i_spur_rd		  :	 1;
+		uint64_t	i_rsvd			  :	11;
+		uint64_t	i_mult_err		  :	 1;
+	} ii_iprba_fld_s;
+} ii_iprba_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of SHub and Crossbow.           *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ * .                                                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprbb_u {
+	uint64_t	ii_iprbb_regval;
+	struct	{
+		uint64_t	i_c			  :	 8;
+		uint64_t	i_na			  :	14;
+		uint64_t	i_rsvd_2		  :	 2;
+		uint64_t	i_nb			  :	14;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_m			  :	 2;
+		uint64_t	i_f			  :	 1;
+		uint64_t	i_of_cnt		  :	 5;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rd_to			  :	 1;
+		uint64_t	i_spur_wr		  :	 1;
+		uint64_t	i_spur_rd		  :	 1;
+		uint64_t	i_rsvd			  :	11;
+		uint64_t	i_mult_err		  :	 1;
+	} ii_iprbb_fld_s;
+} ii_iprbb_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of SHub and Crossbow.           *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ * .                                                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprbc_u {
+	uint64_t	ii_iprbc_regval;
+	struct	{
+		uint64_t	i_c			  :	 8;
+		uint64_t	i_na			  :	14;
+		uint64_t	i_rsvd_2		  :	 2;
+		uint64_t	i_nb			  :	14;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_m			  :	 2;
+		uint64_t	i_f			  :	 1;
+		uint64_t	i_of_cnt		  :	 5;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rd_to			  :	 1;
+		uint64_t	i_spur_wr		  :	 1;
+		uint64_t	i_spur_rd		  :	 1;
+		uint64_t	i_rsvd			  :	11;
+		uint64_t	i_mult_err		  :	 1;
+	} ii_iprbc_fld_s;
+} ii_iprbc_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of SHub and Crossbow.           *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ * .                                                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprbd_u {
+	uint64_t	ii_iprbd_regval;
+	struct	{
+		uint64_t	i_c			  :	 8;
+		uint64_t	i_na			  :	14;
+		uint64_t	i_rsvd_2		  :	 2;
+		uint64_t	i_nb			  :	14;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_m			  :	 2;
+		uint64_t	i_f			  :	 1;
+		uint64_t	i_of_cnt		  :	 5;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rd_to			  :	 1;
+		uint64_t	i_spur_wr		  :	 1;
+		uint64_t	i_spur_rd		  :	 1;
+		uint64_t	i_rsvd			  :	11;
+		uint64_t	i_mult_err		  :	 1;
+	} ii_iprbd_fld_s;
+} ii_iprbd_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of SHub and Crossbow.           *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ * .                                                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprbe_u {
+	uint64_t	ii_iprbe_regval;
+	struct	{
+		uint64_t	i_c			  :	 8;
+		uint64_t	i_na			  :	14;
+		uint64_t	i_rsvd_2		  :	 2;
+		uint64_t	i_nb			  :	14;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_m			  :	 2;
+		uint64_t	i_f			  :	 1;
+		uint64_t	i_of_cnt		  :	 5;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rd_to			  :	 1;
+		uint64_t	i_spur_wr		  :	 1;
+		uint64_t	i_spur_rd		  :	 1;
+		uint64_t	i_rsvd			  :	11;
+		uint64_t	i_mult_err		  :	 1;
+	} ii_iprbe_fld_s;
+} ii_iprbe_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 9 instances of this register, one per        *
+ * actual widget in this implementation of Shub and Crossbow.           *
+ * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
+ * refers to Crossbow's internal space.                                 *
+ * This register contains the state elements per widget that are        *
+ * necessary to manage the PIO flow control on Crosstalk and on the     *
+ * Router Network. See the PIO Flow Control chapter for a complete      *
+ * description of this register                                         *
+ * The SPUR_WR bit requires some explanation. When this register is     *
+ * written, the new value of the C field is captured in an internal     *
+ * register so the hardware can remember what the programmer wrote      *
+ * into the credit counter. The SPUR_WR bit sets whenever the C field   *
+ * increments above this stored value, which indicates that there       *
+ * have been more responses received than requests sent. The SPUR_WR    *
+ * bit cannot be cleared until a value is written to the IPRBx          *
+ * register; the write will correct the C field and capture its new     *
+ * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
+ * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
+ * .                                                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprbf_u {
+        uint64_t       ii_iprbf_regval;
+        struct  {
+                uint64_t       i_c                       :      8;
+                uint64_t       i_na                      :     14;
+                uint64_t       i_rsvd_2                  :      2;
+                uint64_t       i_nb                      :     14;
+                uint64_t       i_rsvd_1                  :      2;
+                uint64_t       i_m                       :      2;
+                uint64_t       i_f                       :      1;
+                uint64_t       i_of_cnt                  :      5;
+                uint64_t       i_error                   :      1;
+                uint64_t       i_rd_to                   :      1;
+                uint64_t       i_spur_wr                 :      1;
+                uint64_t       i_spur_rd                 :      1;
+                uint64_t       i_rsvd                    :     11;
+                uint64_t       i_mult_err                :      1;
+        } ii_iprbe_fld_s;
+} ii_iprbf_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register specifies the timeout value to use for monitoring     *
+ * Crosstalk credits which are used outbound to Crosstalk. An           *
+ * internal counter called the Crosstalk Credit Timeout Counter         *
+ * increments every 128 II clocks. The counter starts counting          *
+ * anytime the credit count drops below a threshold, and resets to      *
+ * zero (stops counting) anytime the credit count is at or above the    *
+ * threshold. The threshold is 1 credit in direct connect mode and 2    *
+ * in Crossbow connect mode. When the internal Crosstalk Credit         *
+ * Timeout Counter reaches the value programmed in this register, a     *
+ * Crosstalk Credit Timeout has occurred. The internal counter is not   *
+ * readable from software, and stops counting at its maximum value,     *
+ * so it cannot cause more than one interrupt.                          *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ixcc_u {
+	uint64_t	ii_ixcc_regval;
+	struct  {
+		uint64_t	i_time_out                :	26;
+		uint64_t	i_rsvd			  :	38;
+	} ii_ixcc_fld_s;
+} ii_ixcc_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This register qualifies all the PIO and DMA            *
+ * operations launched from widget 0 towards the SHub. In               *
+ * addition, it also qualifies accesses by the BTE streams.             *
+ * The bits in each field of this register are cleared by the SHub      *
+ * upon detection of an error which requires widget 0 or the BTE        *
+ * streams to be terminated. Whether or not widget x has access         *
+ * rights to this SHub is determined by an AND of the device            *
+ * enable bit in the appropriate field of this register and bit 0 in    *
+ * the Wx_IAC field. The bits in this field are set by writing a 1 to   *
+ * them. Incoming replies from Crosstalk are not subject to this        *
+ * access control mechanism.                                            *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_imem_u {
+	uint64_t	ii_imem_regval;
+	struct  {
+		uint64_t	i_w0_esd                  :	 1;
+		uint64_t	i_rsvd_3		  :	 3;
+		uint64_t	i_b0_esd		  :	 1;
+		uint64_t	i_rsvd_2		  :	 3;
+		uint64_t	i_b1_esd		  :	 1;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t	i_clr_precise		  :	 1;
+		uint64_t       i_rsvd                    :     51;
+	} ii_imem_fld_s;
+} ii_imem_u_t;
+
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This register specifies the timeout value to use for   *
+ * monitoring Crosstalk tail flits coming into the Shub in the          *
+ * TAIL_TO field. An internal counter associated with this register     *
+ * is incremented every 128 II internal clocks (7 bits). The counter    *
+ * starts counting anytime a header micropacket is received and stops   *
+ * counting (and resets to zero) any time a micropacket with a Tail     *
+ * bit is received. Once the counter reaches the threshold value        *
+ * programmed in this register, it generates an interrupt to the        *
+ * processor that is programmed into the IIDSR. The counter saturates   *
+ * (does not roll over) at its maximum value, so it cannot cause        *
+ * another interrupt until after it is cleared.                         *
+ * The register also contains the Read Response Timeout values. The     *
+ * Prescalar is 23 bits, and counts II clocks. An internal counter      *
+ * increments on every II clock and when it reaches the value in the    *
+ * Prescalar field, all IPRTE registers with their valid bits set       *
+ * have their Read Response timers bumped. Whenever any of them match   *
+ * the value in the RRSP_TO field, a Read Response Timeout has          *
+ * occurred, and error handling occurs as described in the Error        *
+ * Handling section of this document.                                   *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ixtt_u {
+	uint64_t	ii_ixtt_regval;
+	struct  {
+		uint64_t	i_tail_to                 :	26;
+		uint64_t	i_rsvd_1		  :	 6;
+		uint64_t	i_rrsp_ps		  :	23;
+		uint64_t	i_rrsp_to		  :	 5;
+		uint64_t	i_rsvd			  :	 4;
+	} ii_ixtt_fld_s;
+} ii_ixtt_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  Writing a 1 to the fields of this register clears the appropriate   *
+ * error bits in other areas of SHub. Note that when the                *
+ * E_PRB_x bits are used to clear error bits in PRB registers,          *
+ * SPUR_RD and SPUR_WR may persist, because they require additional     *
+ * action to clear them. See the IPRBx and IXSS Register                *
+ * specifications.                                                      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ieclr_u {
+	uint64_t	ii_ieclr_regval;
+	struct  {
+		uint64_t	i_e_prb_0                 :	 1;
+		uint64_t	i_rsvd			  :	 7;
+		uint64_t	i_e_prb_8		  :	 1;
+		uint64_t	i_e_prb_9		  :	 1;
+		uint64_t	i_e_prb_a		  :	 1;
+		uint64_t	i_e_prb_b		  :	 1;
+		uint64_t	i_e_prb_c		  :	 1;
+		uint64_t	i_e_prb_d		  :	 1;
+		uint64_t	i_e_prb_e		  :	 1;
+		uint64_t	i_e_prb_f		  :	 1;
+		uint64_t	i_e_crazy		  :	 1;
+		uint64_t	i_e_bte_0		  :	 1;
+		uint64_t	i_e_bte_1		  :	 1;
+		uint64_t	i_reserved_1		  :	10;
+		uint64_t	i_spur_rd_hdr		  :	 1;
+		uint64_t	i_cam_intr_to		  :	 1;
+		uint64_t	i_cam_overflow		  :	 1;
+		uint64_t	i_cam_read_miss		  :	 1;
+		uint64_t	i_ioq_rep_underflow	  :	 1;
+		uint64_t	i_ioq_req_underflow	  :	 1;
+		uint64_t	i_ioq_rep_overflow	  :	 1;
+		uint64_t	i_ioq_req_overflow	  :	 1;
+		uint64_t	i_iiq_rep_overflow	  :	 1;
+		uint64_t	i_iiq_req_overflow	  :	 1;
+		uint64_t	i_ii_xn_rep_cred_overflow :	 1;
+		uint64_t	i_ii_xn_req_cred_overflow :	 1;
+		uint64_t	i_ii_xn_invalid_cmd	  :	 1;
+		uint64_t	i_xn_ii_invalid_cmd	  :	 1;
+		uint64_t	i_reserved_2		  :	21;
+	} ii_ieclr_fld_s;
+} ii_ieclr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register controls both BTEs. SOFT_RESET is intended for        *
+ * recovery after an error. COUNT controls the total number of CRBs     *
+ * that both BTEs (combined) can use, which affects total BTE           *
+ * bandwidth.                                                           *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibcr_u {
+	uint64_t	ii_ibcr_regval;
+	struct  {
+		uint64_t	i_count                   :	 4;
+		uint64_t	i_rsvd_1		  :	 4;
+		uint64_t	i_soft_reset		  :	 1;
+		uint64_t	i_rsvd			  :	55;
+	} ii_ibcr_fld_s;
+} ii_ibcr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the header of a spurious read response       *
+ * received from Crosstalk. A spurious read response is defined as a    *
+ * read response received by II from a widget for which (1) the SIDN    *
+ * has a value between 1 and 7, inclusive (II never sends requests to   *
+ * these widgets (2) there is no valid IPRTE register which             *
+ * corresponds to the TNUM, or (3) the widget indicated in SIDN is      *
+ * not the same as the widget recorded in the IPRTE register            *
+ * referenced by the TNUM. If this condition is true, and if the        *
+ * IXSS[VALID] bit is clear, then the header of the spurious read       *
+ * response is capture in IXSM and IXSS, and IXSS[VALID] is set. The    *
+ * errant header is thereby captured, and no further spurious read      *
+ * respones are captured until IXSS[VALID] is cleared by setting the    *
+ * appropriate bit in IECLR.Everytime a spurious read response is       *
+ * detected, the SPUR_RD bit of the PRB corresponding to the incoming   *
+ * message's SIDN field is set. This always happens, regarless of       *
+ * whether a header is captured. The programmer should check            *
+ * IXSM[SIDN] to determine which widget sent the spurious response,     *
+ * because there may be more than one SPUR_RD bit set in the PRB        *
+ * registers. The widget indicated by IXSM[SIDN] was the first          *
+ * spurious read response to be received since the last time            *
+ * IXSS[VALID] was clear. The SPUR_RD bit of the corresponding PRB      *
+ * will be set. Any SPUR_RD bits in any other PRB registers indicate    *
+ * spurious messages from other widets which were detected after the    *
+ * header was captured..                                                *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ixsm_u {
+	uint64_t	ii_ixsm_regval;
+	struct  {
+		uint64_t	i_byte_en                 :	32;
+		uint64_t	i_reserved		  :	 1;
+		uint64_t	i_tag			  :	 3;
+		uint64_t	i_alt_pactyp		  :	 4;
+		uint64_t	i_bo			  :	 1;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_vbpm			  :	 1;
+		uint64_t	i_gbr			  :	 1;
+		uint64_t	i_ds			  :	 2;
+		uint64_t	i_ct			  :	 1;
+		uint64_t	i_tnum			  :	 5;
+		uint64_t	i_pactyp		  :	 4;
+		uint64_t	i_sidn			  :	 4;
+		uint64_t	i_didn			  :	 4;
+	} ii_ixsm_fld_s;
+} ii_ixsm_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the sideband bits of a spurious read         *
+ * response received from Crosstalk.                                    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ixss_u {
+	uint64_t	ii_ixss_regval;
+	struct  {
+		uint64_t	i_sideband                :	 8;
+		uint64_t	i_rsvd			  :	55;
+		uint64_t	i_valid			  :	 1;
+	} ii_ixss_fld_s;
+} ii_ixss_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register enables software to access the II LLP's test port.    *
+ * Refer to the LLP 2.5 documentation for an explanation of the test    *
+ * port. Software can write to this register to program the values      *
+ * for the control fields (TestErrCapture, TestClear, TestFlit,         *
+ * TestMask and TestSeed). Similarly, software can read from this       *
+ * register to obtain the values of the test port's status outputs      *
+ * (TestCBerr, TestValid and TestData).                                 *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ilct_u {
+	uint64_t	ii_ilct_regval;
+	struct  {
+		uint64_t	i_test_seed               :	20;
+		uint64_t	i_test_mask               :	 8;
+		uint64_t	i_test_data               :	20;
+		uint64_t	i_test_valid              :	 1;
+		uint64_t	i_test_cberr              :	 1;
+		uint64_t	i_test_flit               :	 3;
+		uint64_t	i_test_clear              :	 1;
+		uint64_t	i_test_err_capture        :	 1;
+		uint64_t	i_rsvd                    :	 9;
+	} ii_ilct_fld_s;
+} ii_ilct_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  If the II detects an illegal incoming Duplonet packet (request or   *
+ * reply) when VALID==0 in the IIEPH1 register, then it saves the       *
+ * contents of the packet's header flit in the IIEPH1 and IIEPH2        *
+ * registers, sets the VALID bit in IIEPH1, clears the OVERRUN bit,     *
+ * and assigns a value to the ERR_TYPE field which indicates the        *
+ * specific nature of the error. The II recognizes four different       *
+ * types of errors: short request packets (ERR_TYPE==2), short reply    *
+ * packets (ERR_TYPE==3), long request packets (ERR_TYPE==4) and long   *
+ * reply packets (ERR_TYPE==5). The encodings for these types of        *
+ * errors were chosen to be consistent with the same types of errors    *
+ * indicated by the ERR_TYPE field in the LB_ERROR_HDR1 register (in    *
+ * the LB unit). If the II detects an illegal incoming Duplonet         *
+ * packet when VALID==1 in the IIEPH1 register, then it merely sets     *
+ * the OVERRUN bit to indicate that a subsequent error has happened,    *
+ * and does nothing further.                                            *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iieph1_u {
+	uint64_t	ii_iieph1_regval;
+	struct	{
+		uint64_t	i_command		  :	 7;
+		uint64_t	i_rsvd_5		  :	 1;
+		uint64_t	i_suppl			  :	14;
+		uint64_t	i_rsvd_4		  :	 1;
+		uint64_t	i_source		  :	14;
+		uint64_t	i_rsvd_3		  :	 1;
+		uint64_t	i_err_type		  :	 4;
+		uint64_t	i_rsvd_2		  :	 4;
+		uint64_t	i_overrun		  :	 1;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t	i_valid			  :	 1;
+		uint64_t	i_rsvd			  :	13;
+	} ii_iieph1_fld_s;
+} ii_iieph1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register holds the Address field from the header flit of an    *
+ * incoming erroneous Duplonet packet, along with the tail bit which    *
+ * accompanied this header flit. This register is essentially an        *
+ * extension of IIEPH1. Two registers were necessary because the 64     *
+ * bits available in only a single register were insufficient to        *
+ * capture the entire header flit of an erroneous packet.               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iieph2_u {
+	uint64_t	ii_iieph2_regval;
+	struct  {
+		uint64_t	i_rsvd_0		  :	 3;
+		uint64_t	i_address                 :	47;
+		uint64_t	i_rsvd_1		  :	10;
+		uint64_t	i_tail			  :	 1;
+		uint64_t	i_rsvd			  :	 3;
+	} ii_iieph2_fld_s;
+} ii_iieph2_u_t;
+
+
+/******************************/
+
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register's value is a bit vector that guards access from SXBs  *
+ * to local registers within the II as well as to external Crosstalk    *
+ * widgets								*
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_islapr_u {
+	uint64_t	ii_islapr_regval;
+	struct  {
+		uint64_t	i_region		  :	64;
+	} ii_islapr_fld_s;
+} ii_islapr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  A write to this register of the 56-bit value "Pup+Bun" will cause	*
+ * the bit in the ISLAPR register corresponding to the region of the	*
+ * requestor to be set (access allowed).				(
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_islapo_u {
+	uint64_t	ii_islapo_regval;
+	struct  {
+		uint64_t	i_io_sbx_ovrride	  :	56;
+		uint64_t	i_rsvd			  :	 8;
+	} ii_islapo_fld_s;
+} ii_islapo_u_t;
+
+/************************************************************************
+ *                                                                      *
+ *  Determines how long the wrapper will wait aftr an interrupt is	*
+ * initially issued from the II before it times out the outstanding	*
+ * interrupt and drops it from the interrupt queue.			* 
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iwi_u {
+	uint64_t	ii_iwi_regval;
+	struct  {
+		uint64_t	i_prescale		  :	24;
+		uint64_t	i_rsvd			  :	 8;
+		uint64_t	i_timeout		  :	 8;
+		uint64_t	i_rsvd1			  :	 8;
+		uint64_t	i_intrpt_retry_period	  :	 8;
+		uint64_t	i_rsvd2			  :	 8;
+	} ii_iwi_fld_s;
+} ii_iwi_u_t;
+
+/************************************************************************
+ *                                                                      *
+ *  Log errors which have occurred in the II wrapper. The errors are	*
+ * cleared by writing to the IECLR register.				* 
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iwel_u {
+	uint64_t	ii_iwel_regval;
+	struct  {
+		uint64_t	i_intr_timed_out	  :	 1;
+		uint64_t	i_rsvd			  :	 7;
+		uint64_t	i_cam_overflow		  :	 1;
+		uint64_t	i_cam_read_miss		  :	 1;
+		uint64_t	i_rsvd1			  :	 2;
+		uint64_t	i_ioq_rep_underflow	  :	 1;
+		uint64_t	i_ioq_req_underflow	  :	 1;
+		uint64_t	i_ioq_rep_overflow	  :	 1;
+		uint64_t	i_ioq_req_overflow	  :	 1;
+		uint64_t	i_iiq_rep_overflow	  :	 1;
+		uint64_t	i_iiq_req_overflow	  :	 1;
+		uint64_t	i_rsvd2			  :	 6;
+		uint64_t	i_ii_xn_rep_cred_over_under:	 1;
+		uint64_t	i_ii_xn_req_cred_over_under:	 1;
+		uint64_t	i_rsvd3			  :	 6;
+		uint64_t	i_ii_xn_invalid_cmd	  :	 1;
+		uint64_t	i_xn_ii_invalid_cmd	  :	 1;
+		uint64_t	i_rsvd4			  :	30;
+	} ii_iwel_fld_s;
+} ii_iwel_u_t;
+
+/************************************************************************
+ *                                                                      *
+ *  Controls the II wrapper.						* 
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iwc_u {
+	uint64_t	ii_iwc_regval;
+	struct  {
+		uint64_t	i_dma_byte_swap		  :	 1;
+		uint64_t	i_rsvd			  :	 3;
+		uint64_t	i_cam_read_lines_reset	  :	 1;
+		uint64_t	i_rsvd1			  :	 3;
+		uint64_t	i_ii_xn_cred_over_under_log:	 1;
+		uint64_t	i_rsvd2			  :	19;
+		uint64_t	i_xn_rep_iq_depth	  :	 5;
+		uint64_t	i_rsvd3			  :	 3;
+		uint64_t	i_xn_req_iq_depth	  :	 5;
+		uint64_t	i_rsvd4			  :	 3;
+		uint64_t	i_iiq_depth		  :	 6;
+		uint64_t	i_rsvd5			  :	12;
+		uint64_t	i_force_rep_cred	  :	 1;
+		uint64_t	i_force_req_cred	  :	 1;
+	} ii_iwc_fld_s;
+} ii_iwc_u_t;
+
+/************************************************************************
+ *                                                                      *
+ *  Status in the II wrapper.						* 
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iws_u {
+	uint64_t	ii_iws_regval;
+	struct  {
+		uint64_t	i_xn_rep_iq_credits	  :	 5;
+		uint64_t	i_rsvd			  :	 3;
+		uint64_t	i_xn_req_iq_credits	  :	 5;
+		uint64_t	i_rsvd1			  :	51;
+	} ii_iws_fld_s;
+} ii_iws_u_t;
+
+/************************************************************************
+ *                                                                      *
+ *  Masks errors in the IWEL register.					*
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iweim_u {
+	uint64_t	ii_iweim_regval;
+	struct  {
+		uint64_t	i_intr_timed_out	  :	 1;
+		uint64_t	i_rsvd			  :	 7;
+		uint64_t	i_cam_overflow		  :	 1;
+		uint64_t	i_cam_read_miss		  :	 1;
+		uint64_t	i_rsvd1			  :	 2;
+		uint64_t	i_ioq_rep_underflow	  :	 1;
+		uint64_t	i_ioq_req_underflow	  :	 1;
+		uint64_t	i_ioq_rep_overflow	  :	 1;
+		uint64_t	i_ioq_req_overflow	  :	 1;
+		uint64_t	i_iiq_rep_overflow	  :	 1;
+		uint64_t	i_iiq_req_overflow	  :	 1;
+		uint64_t	i_rsvd2			  :	 6;
+		uint64_t	i_ii_xn_rep_cred_overflow :	 1;
+		uint64_t	i_ii_xn_req_cred_overflow :	 1;
+		uint64_t	i_rsvd3			  :	 6;
+		uint64_t	i_ii_xn_invalid_cmd	  :	 1;
+		uint64_t	i_xn_ii_invalid_cmd	  :	 1;
+		uint64_t	i_rsvd4			  :	30;
+	} ii_iweim_fld_s;
+} ii_iweim_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  A write to this register causes a particular field in the           *
+ * corresponding widget's PRB entry to be adjusted up or down by 1.     *
+ * This counter should be used when recovering from error and reset     *
+ * conditions. Note that software would be capable of causing           *
+ * inadvertent overflow or underflow of these counters.                 *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ipca_u {
+	uint64_t	ii_ipca_regval;
+	struct  {
+		uint64_t	i_wid                     :	 4;
+		uint64_t	i_adjust		  :	 1;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t	i_field			  :	 2;
+		uint64_t	i_rsvd			  :	54;
+	} ii_ipca_fld_s;
+} ii_ipca_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+
+typedef union ii_iprte0a_u {
+	uint64_t	ii_iprte0a_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	54;
+		uint64_t	i_widget		  :	 4;
+		uint64_t	i_to_cnt		  :	 5;
+		uint64_t       i_vld                     :      1;
+	} ii_iprte0a_fld_s;
+} ii_iprte0a_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte1a_u {
+	uint64_t	ii_iprte1a_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	54;
+		uint64_t	i_widget		  :	 4;
+		uint64_t	i_to_cnt		  :	 5;
+		uint64_t       i_vld                     :      1;
+	} ii_iprte1a_fld_s;
+} ii_iprte1a_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte2a_u {
+	uint64_t	ii_iprte2a_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	54;
+		uint64_t	i_widget		  :	 4;
+		uint64_t	i_to_cnt		  :	 5;
+		uint64_t       i_vld                     :      1;
+	} ii_iprte2a_fld_s;
+} ii_iprte2a_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte3a_u {
+	uint64_t	ii_iprte3a_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	54;
+		uint64_t	i_widget		  :	 4;
+		uint64_t	i_to_cnt		  :	 5;
+		uint64_t	i_vld			  :	 1;
+	} ii_iprte3a_fld_s;
+} ii_iprte3a_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte4a_u {
+	uint64_t	ii_iprte4a_regval;
+	struct	{
+		uint64_t	i_rsvd_1		  :	54;
+		uint64_t	i_widget		  :	 4;
+		uint64_t	i_to_cnt		  :	 5;
+		uint64_t	i_vld			  :	 1;
+	} ii_iprte4a_fld_s;
+} ii_iprte4a_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte5a_u {
+	uint64_t	ii_iprte5a_regval;
+	struct	{
+		uint64_t	i_rsvd_1		  :	54;
+		uint64_t	i_widget		  :	 4;
+		uint64_t	i_to_cnt		  :	 5;
+		uint64_t	i_vld			  :	 1;
+	} ii_iprte5a_fld_s;
+} ii_iprte5a_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte6a_u {
+	uint64_t	ii_iprte6a_regval;
+	struct	{
+		uint64_t	i_rsvd_1		  :	54;
+		uint64_t	i_widget		  :	 4;
+		uint64_t	i_to_cnt		  :	 5;
+		uint64_t	i_vld			  :	 1;
+	} ii_iprte6a_fld_s;
+} ii_iprte6a_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte7a_u {
+        uint64_t       ii_iprte7a_regval;
+        struct  {
+                uint64_t       i_rsvd_1                  :     54;
+                uint64_t       i_widget                  :      4;
+                uint64_t       i_to_cnt                  :      5;
+                uint64_t       i_vld                     :      1;
+        } ii_iprtea7_fld_s;
+} ii_iprte7a_u_t;
+
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+
+typedef union ii_iprte0b_u {
+	uint64_t	ii_iprte0b_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_address		  :	47;
+		uint64_t	i_init			  :	 3;
+		uint64_t       i_source                  :     11;
+	} ii_iprte0b_fld_s;
+} ii_iprte0b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte1b_u {
+	uint64_t	ii_iprte1b_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_address		  :	47;
+		uint64_t	i_init			  :	 3;
+		uint64_t       i_source                  :     11;
+	} ii_iprte1b_fld_s;
+} ii_iprte1b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte2b_u {
+	uint64_t	ii_iprte2b_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_address		  :	47;
+		uint64_t	i_init			  :	 3;
+		uint64_t       i_source                  :     11;
+	} ii_iprte2b_fld_s;
+} ii_iprte2b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte3b_u {
+	uint64_t	ii_iprte3b_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_address		  :	47;
+		uint64_t	i_init			  :	 3;
+		uint64_t       i_source                  :     11;
+	} ii_iprte3b_fld_s;
+} ii_iprte3b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte4b_u {
+	uint64_t	ii_iprte4b_regval;
+	struct	{
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_address		  :	47;
+		uint64_t	i_init			  :	 3;
+		uint64_t       i_source                  :     11;
+	} ii_iprte4b_fld_s;
+} ii_iprte4b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte5b_u {
+	uint64_t	ii_iprte5b_regval;
+	struct	{
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_address		  :	47;
+		uint64_t	i_init			  :	 3;
+		uint64_t       i_source                  :     11;
+	} ii_iprte5b_fld_s;
+} ii_iprte5b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte6b_u {
+	uint64_t	ii_iprte6b_regval;
+	struct	{
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_address		  :	47;
+		uint64_t	i_init			  :	 3;
+		uint64_t       i_source                  :     11;
+
+	} ii_iprte6b_fld_s;
+} ii_iprte6b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  There are 8 instances of this register. This register contains      *
+ * the information that the II has to remember once it has launched a   *
+ * PIO Read operation. The contents are used to form the correct        *
+ * Router Network packet and direct the Crosstalk reply to the          *
+ * appropriate processor.                                               *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iprte7b_u {
+        uint64_t       ii_iprte7b_regval;
+        struct  {
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_address		  :	47;
+		uint64_t	i_init			  :	 3;
+		uint64_t       i_source                  :     11;
+        } ii_iprte7b_fld_s;
+} ii_iprte7b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  SHub II contains a feature which did not exist in      *
+ * the Hub which automatically cleans up after a Read Response          *
+ * timeout, including deallocation of the IPRTE and recovery of IBuf    *
+ * space. The inclusion of this register in SHub is for backward        *
+ * compatibility                                                        *
+ * A write to this register causes an entry from the table of           *
+ * outstanding PIO Read Requests to be freed and returned to the        *
+ * stack of free entries. This register is used in handling the         *
+ * timeout errors that result in a PIO Reply never returning from       *
+ * Crosstalk.                                                           *
+ * Note that this register does not affect the contents of the IPRTE    *
+ * registers. The Valid bits in those registers have to be              *
+ * specifically turned off by software.                                 *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ipdr_u {
+	uint64_t	ii_ipdr_regval;
+	struct  {
+		uint64_t	i_te                      :	 3;
+		uint64_t	i_rsvd_1		  :	 1;
+		uint64_t	i_pnd			  :	 1;
+		uint64_t	i_init_rpcnt		  :	 1;
+		uint64_t	i_rsvd			  :	58;
+	} ii_ipdr_fld_s;
+} ii_ipdr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  A write to this register causes a CRB entry to be returned to the   *
+ * queue of free CRBs. The entry should have previously been cleared    *
+ * (mark bit) via backdoor access to the pertinent CRB entry. This      *
+ * register is used in the last step of handling the errors that are    *
+ * captured and marked in CRB entries.  Briefly: 1) first error for     *
+ * DMA write from a particular device, and first error for a            *
+ * particular BTE stream, lead to a marked CRB entry, and processor     *
+ * interrupt, 2) software reads the error information captured in the   *
+ * CRB entry, and presumably takes some corrective action, 3)           *
+ * software clears the mark bit, and finally 4) software writes to      *
+ * the ICDR register to return the CRB entry to the list of free CRB    *
+ * entries.                                                             *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icdr_u {
+	uint64_t	ii_icdr_regval;
+	struct  {
+		uint64_t	i_crb_num                 :	 4;
+		uint64_t	i_pnd			  :	 1;
+		uint64_t       i_rsvd                    :     59;
+	} ii_icdr_fld_s;
+} ii_icdr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register provides debug access to two FIFOs inside of II.      *
+ * Both IOQ_MAX* fields of this register contain the instantaneous      *
+ * depth (in units of the number of available entries) of the           *
+ * associated IOQ FIFO.  A read of this register will return the        *
+ * number of free entries on each FIFO at the time of the read.  So     *
+ * when a FIFO is idle, the associated field contains the maximum       *
+ * depth of the FIFO.  This register is writable for debug reasons      *
+ * and is intended to be written with the maximum desired FIFO depth    *
+ * while the FIFO is idle. Software must assure that II is idle when    *
+ * this register is written. If there are any active entries in any     *
+ * of these FIFOs when this register is written, the results are        *
+ * undefined.                                                           *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ifdr_u {
+	uint64_t	ii_ifdr_regval;
+	struct  {
+		uint64_t	i_ioq_max_rq              :	 7;
+		uint64_t	i_set_ioq_rq		  :	 1;
+		uint64_t	i_ioq_max_rp		  :	 7;
+		uint64_t	i_set_ioq_rp		  :	 1;
+		uint64_t	i_rsvd			  :	48;
+	} ii_ifdr_fld_s;
+} ii_ifdr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register allows the II to become sluggish in removing          *
+ * messages from its inbound queue (IIQ). This will cause messages to   *
+ * back up in either virtual channel. Disabling the "molasses" mode     *
+ * subsequently allows the II to be tested under stress. In the         *
+ * sluggish ("Molasses") mode, the localized effects of congestion      *
+ * can be observed.                                                     *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iiap_u {
+        uint64_t       ii_iiap_regval;
+        struct  {
+                uint64_t       i_rq_mls                  :      6;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_rp_mls		  :	 6;
+		uint64_t       i_rsvd                    :     50;
+        } ii_iiap_fld_s;
+} ii_iiap_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register allows several parameters of CRB operation to be      *
+ * set. Note that writing to this register can have catastrophic side   *
+ * effects, if the CRB is not quiescent, i.e. if the CRB is             *
+ * processing protocol messages when the write occurs.                  *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icmr_u {
+	uint64_t	ii_icmr_regval;
+	struct  {
+		uint64_t	i_sp_msg                  :	 1;
+		uint64_t	i_rd_hdr		  :	 1;
+		uint64_t	i_rsvd_4		  :	 2;
+		uint64_t	i_c_cnt			  :	 4;
+		uint64_t	i_rsvd_3		  :	 4;
+		uint64_t	i_clr_rqpd		  :	 1;
+		uint64_t	i_clr_rppd		  :	 1;
+		uint64_t	i_rsvd_2		  :	 2;
+		uint64_t	i_fc_cnt		  :	 4;
+		uint64_t	i_crb_vld		  :	15;
+		uint64_t	i_crb_mark		  :	15;
+		uint64_t	i_rsvd_1		  :	 2;
+		uint64_t	i_precise		  :	 1;
+		uint64_t	i_rsvd			  :	11;
+	} ii_icmr_fld_s;
+} ii_icmr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register allows control of the table portion of the CRB        *
+ * logic via software. Control operations from this register have       *
+ * priority over all incoming Crosstalk or BTE requests.                *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_iccr_u {
+	uint64_t	ii_iccr_regval;
+	struct  {
+		uint64_t	i_crb_num                 :	 4;
+		uint64_t	i_rsvd_1		  :	 4;
+		uint64_t	i_cmd			  :	 8;
+		uint64_t	i_pending		  :	 1;
+		uint64_t	i_rsvd			  :	47;
+	} ii_iccr_fld_s;
+} ii_iccr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register allows the maximum timeout value to be programmed.    *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icto_u {
+	uint64_t	ii_icto_regval;
+	struct  {
+		uint64_t	i_timeout                 :	 8;
+		uint64_t	i_rsvd			  :	56;
+	} ii_icto_fld_s;
+} ii_icto_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register allows the timeout prescalar to be programmed. An     *
+ * internal counter is associated with this register. When the          *
+ * internal counter reaches the value of the PRESCALE field, the        *
+ * timer registers in all valid CRBs are incremented (CRBx_D[TIMEOUT]   *
+ * field). The internal counter resets to zero, and then continues      *
+ * counting.                                                            *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ictp_u {
+	uint64_t	ii_ictp_regval;
+	struct  {
+		uint64_t	i_prescale                :	24;
+		uint64_t	i_rsvd			  :	40;
+	} ii_ictp_fld_s;
+} ii_ictp_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
+ * used for Crosstalk operations (both cacheline and partial            *
+ * operations) or BTE/IO. Because the CRB entries are very wide, five   *
+ * registers (_A to _E) are required to read and write each entry.      *
+ * The CRB Entry registers can be conceptualized as rows and columns    *
+ * (illustrated in the table above). Each row contains the 4            *
+ * registers required for a single CRB Entry. The first doubleword      *
+ * (column) for each entry is labeled A, and the second doubleword      *
+ * (higher address) is labeled B, the third doubleword is labeled C,    *
+ * the fourth doubleword is labeled D and the fifth doubleword is       *
+ * labeled E. All CRB entries have their addresses on a quarter         *
+ * cacheline aligned boundary.                   *
+ * Upon reset, only the following fields are initialized: valid         *
+ * (VLD), priority count, timeout, timeout valid, and context valid.    *
+ * All other bits should be cleared by software before use (after       *
+ * recovering any potential error state from before the reset).         *
+ * The following four tables summarize the format for the four          *
+ * registers that are used for each ICRB# Entry.                        *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icrb0_a_u {
+	uint64_t	ii_icrb0_a_regval;
+	struct  {
+		uint64_t	ia_iow                    :	 1;
+		uint64_t	ia_vld			  :	 1;
+		uint64_t	ia_addr			  :	47;
+		uint64_t	ia_tnum			  :	 5;
+		uint64_t	ia_sidn			  :	 4;
+		uint64_t       ia_rsvd                   :      6;
+	} ii_icrb0_a_fld_s;
+} ii_icrb0_a_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
+ * used for Crosstalk operations (both cacheline and partial            *
+ * operations) or BTE/IO. Because the CRB entries are very wide, five   *
+ * registers (_A to _E) are required to read and write each entry.      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icrb0_b_u {
+	uint64_t	ii_icrb0_b_regval;
+	struct	{
+		uint64_t	ib_xt_err		  :	 1;
+		uint64_t	ib_mark			  :	 1;
+		uint64_t	ib_ln_uce		  :	 1;
+		uint64_t	ib_errcode		  :	 3;
+		uint64_t	ib_error		  :	 1;
+		uint64_t	ib_stall__bte_1		  :	 1;
+		uint64_t	ib_stall__bte_0		  :	 1;
+		uint64_t	ib_stall__intr		  :	 1;
+		uint64_t	ib_stall_ib		  :	 1;
+		uint64_t	ib_intvn		  :	 1;
+		uint64_t	ib_wb			  :	 1;
+		uint64_t	ib_hold			  :	 1;
+		uint64_t	ib_ack			  :	 1;
+		uint64_t	ib_resp			  :	 1;
+		uint64_t	ib_ack_cnt		  :	11;
+		uint64_t	ib_rsvd			  :	 7;
+		uint64_t	ib_exc			  :	 5;
+		uint64_t	ib_init			  :	 3;
+		uint64_t	ib_imsg			  :	 8;
+		uint64_t	ib_imsgtype		  :	 2;
+		uint64_t	ib_use_old		  :	 1;
+		uint64_t	ib_rsvd_1		  :	11;
+	} ii_icrb0_b_fld_s;
+} ii_icrb0_b_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
+ * used for Crosstalk operations (both cacheline and partial            *
+ * operations) or BTE/IO. Because the CRB entries are very wide, five   *
+ * registers (_A to _E) are required to read and write each entry.      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icrb0_c_u {
+	uint64_t	ii_icrb0_c_regval;
+	struct	{
+		uint64_t	ic_source		  :	15;
+		uint64_t	ic_size			  :	 2;
+		uint64_t	ic_ct			  :	 1;
+		uint64_t	ic_bte_num		  :	 1;
+		uint64_t	ic_gbr			  :	 1;
+		uint64_t	ic_resprqd		  :	 1;
+		uint64_t	ic_bo			  :	 1;
+		uint64_t	ic_suppl		  :	15;
+		uint64_t	ic_rsvd			  :	27;
+	} ii_icrb0_c_fld_s;
+} ii_icrb0_c_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
+ * used for Crosstalk operations (both cacheline and partial            *
+ * operations) or BTE/IO. Because the CRB entries are very wide, five   *
+ * registers (_A to _E) are required to read and write each entry.      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icrb0_d_u {
+	uint64_t	ii_icrb0_d_regval;
+	struct  {
+		uint64_t	id_pa_be                  :	43;
+		uint64_t	id_bte_op		  :	 1;
+		uint64_t	id_pr_psc		  :	 4;
+		uint64_t	id_pr_cnt		  :	 4;
+		uint64_t	id_sleep		  :	 1;
+		uint64_t	id_rsvd			  :	11;
+	} ii_icrb0_d_fld_s;
+} ii_icrb0_d_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
+ * used for Crosstalk operations (both cacheline and partial            *
+ * operations) or BTE/IO. Because the CRB entries are very wide, five   *
+ * registers (_A to _E) are required to read and write each entry.      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icrb0_e_u {
+	uint64_t	ii_icrb0_e_regval;
+	struct  {
+		uint64_t	ie_timeout                :	 8;
+		uint64_t	ie_context		  :	15;
+		uint64_t	ie_rsvd			  :	 1;
+		uint64_t	ie_tvld			  :	 1;
+		uint64_t	ie_cvld			  :	 1;
+		uint64_t	ie_rsvd_0		  :	38;
+	} ii_icrb0_e_fld_s;
+} ii_icrb0_e_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the lower 64 bits of the header of the       *
+ * spurious message captured by II. Valid when the SP_MSG bit in ICMR   *
+ * register is set.                                                     *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icsml_u {
+	uint64_t	ii_icsml_regval;
+	struct  {
+		uint64_t	i_tt_addr                 :	47;
+		uint64_t	i_newsuppl_ex		  :	14;
+		uint64_t	i_reserved		  :	 2;
+		uint64_t       i_overflow                :      1;
+	} ii_icsml_fld_s;
+} ii_icsml_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the middle 64 bits of the header of the      *
+ * spurious message captured by II. Valid when the SP_MSG bit in ICMR   *
+ * register is set.                                                     *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icsmm_u {
+	uint64_t	ii_icsmm_regval;
+	struct  {
+		uint64_t	i_tt_ack_cnt              :	11;
+		uint64_t	i_reserved		  :	53;
+	} ii_icsmm_fld_s;
+} ii_icsmm_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the microscopic state, all the inputs to     *
+ * the protocol table, captured with the spurious message. Valid when   *
+ * the SP_MSG bit in the ICMR register is set.                          *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_icsmh_u {
+	uint64_t	ii_icsmh_regval;
+	struct  {
+		uint64_t	i_tt_vld                  :	 1;
+		uint64_t	i_xerr			  :	 1;
+		uint64_t	i_ft_cwact_o		  :	 1;
+		uint64_t	i_ft_wact_o		  :	 1;
+		uint64_t       i_ft_active_o             :      1;
+		uint64_t	i_sync			  :	 1;
+		uint64_t	i_mnusg			  :	 1;
+		uint64_t	i_mnusz			  :	 1;
+		uint64_t	i_plusz			  :	 1;
+		uint64_t	i_plusg			  :	 1;
+		uint64_t	i_tt_exc		  :	 5;
+		uint64_t	i_tt_wb			  :	 1;
+		uint64_t	i_tt_hold		  :	 1;
+		uint64_t	i_tt_ack		  :	 1;
+		uint64_t	i_tt_resp		  :	 1;
+		uint64_t	i_tt_intvn		  :	 1;
+		uint64_t	i_g_stall_bte1		  :	 1;
+		uint64_t	i_g_stall_bte0		  :	 1;
+		uint64_t	i_g_stall_il		  :	 1;
+		uint64_t	i_g_stall_ib		  :	 1;
+		uint64_t	i_tt_imsg		  :	 8;
+		uint64_t	i_tt_imsgtype		  :	 2;
+		uint64_t	i_tt_use_old		  :	 1;
+		uint64_t	i_tt_respreqd		  :	 1;
+		uint64_t	i_tt_bte_num		  :	 1;
+		uint64_t	i_cbn			  :	 1;
+		uint64_t	i_match			  :	 1;
+		uint64_t	i_rpcnt_lt_34		  :	 1;
+		uint64_t	i_rpcnt_ge_34		  :	 1;
+		uint64_t	i_rpcnt_lt_18		  :	 1;
+		uint64_t	i_rpcnt_ge_18		  :	 1;
+		uint64_t       i_rpcnt_lt_2              :      1;
+		uint64_t	i_rpcnt_ge_2		  :	 1;
+		uint64_t	i_rqcnt_lt_18		  :	 1;
+		uint64_t	i_rqcnt_ge_18		  :	 1;
+		uint64_t	i_rqcnt_lt_2		  :	 1;
+		uint64_t	i_rqcnt_ge_2		  :	 1;
+		uint64_t	i_tt_device		  :	 7;
+		uint64_t	i_tt_init		  :	 3;
+		uint64_t	i_reserved		  :	 5;
+	} ii_icsmh_fld_s;
+} ii_icsmh_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  The Shub DEBUG unit provides a 3-bit selection signal to the        *
+ * II core and a 3-bit selection signal to the fsbclk domain in the II  *
+ * wrapper.                                                             *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_idbss_u {
+	uint64_t	ii_idbss_regval;
+	struct  {
+		uint64_t	i_iioclk_core_submenu     :	 3;
+		uint64_t	i_rsvd			  :	 5;
+		uint64_t	i_fsbclk_wrapper_submenu  :	 3;
+		uint64_t	i_rsvd_1		  :	 5;
+		uint64_t	i_iioclk_menu		  :	 5;
+		uint64_t	i_rsvd_2		  :	43;
+	} ii_idbss_fld_s;
+} ii_idbss_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This register is used to set up the length for a       *
+ * transfer and then to monitor the progress of that transfer. This     *
+ * register needs to be initialized before a transfer is started. A     *
+ * legitimate write to this register will set the Busy bit, clear the   *
+ * Error bit, and initialize the length to the value desired.           *
+ * While the transfer is in progress, hardware will decrement the       *
+ * length field with each successful block that is copied. Once the     *
+ * transfer completes, hardware will clear the Busy bit. The length     *
+ * field will also contain the number of cache lines left to be         *
+ * transferred.                                                         *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibls0_u {
+	uint64_t	ii_ibls0_regval;
+	struct	{
+		uint64_t	i_length		  :	16;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t	i_busy			  :	 1;
+		uint64_t       i_rsvd                    :     43;
+	} ii_ibls0_fld_s;
+} ii_ibls0_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register should be loaded before a transfer is started. The    *
+ * address to be loaded in bits 39:0 is the 40-bit TRex+ physical       *
+ * address as described in Section 1.3, Figure2 and Figure3. Since      *
+ * the bottom 7 bits of the address are always taken to be zero, BTE    *
+ * transfers are always cacheline-aligned.                              *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibsa0_u {
+	uint64_t	ii_ibsa0_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 7;
+		uint64_t	i_addr			  :	42;
+		uint64_t       i_rsvd                    :     15;
+	} ii_ibsa0_fld_s;
+} ii_ibsa0_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register should be loaded before a transfer is started. The    *
+ * address to be loaded in bits 39:0 is the 40-bit TRex+ physical       *
+ * address as described in Section 1.3, Figure2 and Figure3. Since      *
+ * the bottom 7 bits of the address are always taken to be zero, BTE    *
+ * transfers are always cacheline-aligned.                              *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibda0_u {
+	uint64_t	ii_ibda0_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 7;
+		uint64_t	i_addr			  :	42;
+		uint64_t	i_rsvd			  :	15;
+	} ii_ibda0_fld_s;
+} ii_ibda0_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  Writing to this register sets up the attributes of the transfer     *
+ * and initiates the transfer operation. Reading this register has      *
+ * the side effect of terminating any transfer in progress. Note:       *
+ * stopping a transfer midstream could have an adverse impact on the    *
+ * other BTE. If a BTE stream has to be stopped (due to error           *
+ * handling for example), both BTE streams should be stopped and        *
+ * their transfers discarded.                                           *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibct0_u {
+	uint64_t	ii_ibct0_regval;
+	struct  {
+		uint64_t	i_zerofill                :	 1;
+		uint64_t	i_rsvd_2		  :	 3;
+		uint64_t	i_notify		  :	 1;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t       i_poison                  :      1;
+		uint64_t       i_rsvd                    :     55;
+	} ii_ibct0_fld_s;
+} ii_ibct0_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the address to which the WINV is sent.       *
+ * This address has to be cache line aligned.                           *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibna0_u {
+	uint64_t	ii_ibna0_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 7;
+		uint64_t	i_addr			  :	42;
+		uint64_t	i_rsvd			  :	15;
+	} ii_ibna0_fld_s;
+} ii_ibna0_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the programmable level as well as the node   *
+ * ID and PI unit of the processor to which the interrupt will be       *
+ * sent.                                                                *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibia0_u {
+	uint64_t	ii_ibia0_regval;
+	struct  {
+		uint64_t	i_rsvd_2                   :	 1;
+		uint64_t	i_node_id		  :	11;
+		uint64_t	i_rsvd_1		  :	 4;
+		uint64_t	i_level			  :	 7;
+		uint64_t       i_rsvd                    :     41;
+	} ii_ibia0_fld_s;
+} ii_ibia0_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ * Description:  This register is used to set up the length for a       *
+ * transfer and then to monitor the progress of that transfer. This     *
+ * register needs to be initialized before a transfer is started. A     *
+ * legitimate write to this register will set the Busy bit, clear the   *
+ * Error bit, and initialize the length to the value desired.           *
+ * While the transfer is in progress, hardware will decrement the       *
+ * length field with each successful block that is copied. Once the     *
+ * transfer completes, hardware will clear the Busy bit. The length     *
+ * field will also contain the number of cache lines left to be         *
+ * transferred.                                                         *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibls1_u {
+	uint64_t	ii_ibls1_regval;
+	struct  {
+		uint64_t	i_length                  :	16;
+		uint64_t	i_error			  :	 1;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t	i_busy			  :	 1;
+		uint64_t       i_rsvd                    :     43;
+	} ii_ibls1_fld_s;
+} ii_ibls1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register should be loaded before a transfer is started. The    *
+ * address to be loaded in bits 39:0 is the 40-bit TRex+ physical       *
+ * address as described in Section 1.3, Figure2 and Figure3. Since      *
+ * the bottom 7 bits of the address are always taken to be zero, BTE    *
+ * transfers are always cacheline-aligned.                              *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibsa1_u {
+	uint64_t	ii_ibsa1_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 7;
+		uint64_t	i_addr			  :	33;
+		uint64_t	i_rsvd			  :	24;
+	} ii_ibsa1_fld_s;
+} ii_ibsa1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register should be loaded before a transfer is started. The    *
+ * address to be loaded in bits 39:0 is the 40-bit TRex+ physical       *
+ * address as described in Section 1.3, Figure2 and Figure3. Since      *
+ * the bottom 7 bits of the address are always taken to be zero, BTE    *
+ * transfers are always cacheline-aligned.                              *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibda1_u {
+	uint64_t	ii_ibda1_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 7;
+		uint64_t	i_addr			  :	33;
+		uint64_t	i_rsvd			  :	24;
+	} ii_ibda1_fld_s;
+} ii_ibda1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  Writing to this register sets up the attributes of the transfer     *
+ * and initiates the transfer operation. Reading this register has      *
+ * the side effect of terminating any transfer in progress. Note:       *
+ * stopping a transfer midstream could have an adverse impact on the    *
+ * other BTE. If a BTE stream has to be stopped (due to error           *
+ * handling for example), both BTE streams should be stopped and        *
+ * their transfers discarded.                                           *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibct1_u {
+	uint64_t	ii_ibct1_regval;
+	struct  {
+		uint64_t	i_zerofill                :	 1;
+		uint64_t	i_rsvd_2		  :	 3;
+		uint64_t	i_notify		  :	 1;
+		uint64_t	i_rsvd_1		  :	 3;
+		uint64_t	i_poison		  :	 1;
+		uint64_t	i_rsvd			  :	55;
+	} ii_ibct1_fld_s;
+} ii_ibct1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the address to which the WINV is sent.       *
+ * This address has to be cache line aligned.                           *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibna1_u {
+	uint64_t	ii_ibna1_regval;
+	struct  {
+		uint64_t	i_rsvd_1                  :	 7;
+		uint64_t	i_addr			  :	33;
+		uint64_t       i_rsvd                    :     24;
+	} ii_ibna1_fld_s;
+} ii_ibna1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register contains the programmable level as well as the node   *
+ * ID and PI unit of the processor to which the interrupt will be       *
+ * sent.                                                                *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ibia1_u {
+	uint64_t	ii_ibia1_regval;
+	struct  {
+		uint64_t	i_pi_id                   :	 1;
+		uint64_t	i_node_id		  :	 8;
+		uint64_t	i_rsvd_1		  :	 7;
+		uint64_t	i_level			  :	 7;
+		uint64_t	i_rsvd			  :	41;
+	} ii_ibia1_fld_s;
+} ii_ibia1_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *  This register defines the resources that feed information into      *
+ * the two performance counters located in the IO Performance           *
+ * Profiling Register. There are 17 different quantities that can be    *
+ * measured. Given these 17 different options, the two performance      *
+ * counters have 15 of them in common; menu selections 0 through 0xE    *
+ * are identical for each performance counter. As for the other two     *
+ * options, one is available from one performance counter and the       *
+ * other is available from the other performance counter. Hence, the    *
+ * II supports all 17*16=272 possible combinations of quantities to     *
+ * measure.                                                             *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ipcr_u {
+	uint64_t	ii_ipcr_regval;
+	struct  {
+		uint64_t	i_ippr0_c                 :	 4;
+		uint64_t	i_ippr1_c		  :	 4;
+		uint64_t	i_icct			  :	 8;
+		uint64_t       i_rsvd                    :     48;
+	} ii_ipcr_fld_s;
+} ii_ipcr_u_t;
+
+
+/************************************************************************
+ *                                                                      *
+ *                                                                      *
+ *                                                                      *
+ ************************************************************************/
+
+typedef union ii_ippr_u {
+	uint64_t	ii_ippr_regval;
+	struct  {
+		uint64_t	i_ippr0                   :	32;
+		uint64_t	i_ippr1			  :	32;
+	} ii_ippr_fld_s;
+} ii_ippr_u_t;
+
+
+
+/**************************************************************************
+ *                                                                        *
+ * The following defines which were not formed into structures are        *
+ * probably indentical to another register, and the name of the           *
+ * register is provided against each of these registers. This             *
+ * information needs to be checked carefully                              *
+ *                                                                        *
+ *           IIO_ICRB1_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB1_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB1_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB1_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB1_E                IIO_ICRB0_E                       *
+ *           IIO_ICRB2_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB2_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB2_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB2_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB2_E                IIO_ICRB0_E                       *
+ *           IIO_ICRB3_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB3_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB3_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB3_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB3_E                IIO_ICRB0_E                       *
+ *           IIO_ICRB4_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB4_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB4_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB4_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB4_E                IIO_ICRB0_E                       *
+ *           IIO_ICRB5_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB5_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB5_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB5_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB5_E                IIO_ICRB0_E                       *
+ *           IIO_ICRB6_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB6_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB6_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB6_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB6_E                IIO_ICRB0_E                       *
+ *           IIO_ICRB7_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB7_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB7_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB7_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB7_E                IIO_ICRB0_E                       *
+ *           IIO_ICRB8_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB8_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB8_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB8_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB8_E                IIO_ICRB0_E                       *
+ *           IIO_ICRB9_A                IIO_ICRB0_A                       *
+ *           IIO_ICRB9_B                IIO_ICRB0_B                       *
+ *           IIO_ICRB9_C                IIO_ICRB0_C                       *
+ *           IIO_ICRB9_D                IIO_ICRB0_D                       *
+ *           IIO_ICRB9_E                IIO_ICRB0_E                       *
+ *           IIO_ICRBA_A                IIO_ICRB0_A                       *
+ *           IIO_ICRBA_B                IIO_ICRB0_B                       *
+ *           IIO_ICRBA_C                IIO_ICRB0_C                       *
+ *           IIO_ICRBA_D                IIO_ICRB0_D                       *
+ *           IIO_ICRBA_E                IIO_ICRB0_E                       *
+ *           IIO_ICRBB_A                IIO_ICRB0_A                       *
+ *           IIO_ICRBB_B                IIO_ICRB0_B                       *
+ *           IIO_ICRBB_C                IIO_ICRB0_C                       *
+ *           IIO_ICRBB_D                IIO_ICRB0_D                       *
+ *           IIO_ICRBB_E                IIO_ICRB0_E                       *
+ *           IIO_ICRBC_A                IIO_ICRB0_A                       *
+ *           IIO_ICRBC_B                IIO_ICRB0_B                       *
+ *           IIO_ICRBC_C                IIO_ICRB0_C                       *
+ *           IIO_ICRBC_D                IIO_ICRB0_D                       *
+ *           IIO_ICRBC_E                IIO_ICRB0_E                       *
+ *           IIO_ICRBD_A                IIO_ICRB0_A                       *
+ *           IIO_ICRBD_B                IIO_ICRB0_B                       *
+ *           IIO_ICRBD_C                IIO_ICRB0_C                       *
+ *           IIO_ICRBD_D                IIO_ICRB0_D                       *
+ *           IIO_ICRBD_E                IIO_ICRB0_E                       *
+ *           IIO_ICRBE_A                IIO_ICRB0_A                       *
+ *           IIO_ICRBE_B                IIO_ICRB0_B                       *
+ *           IIO_ICRBE_C                IIO_ICRB0_C                       *
+ *           IIO_ICRBE_D                IIO_ICRB0_D                       *
+ *           IIO_ICRBE_E                IIO_ICRB0_E                       *
+ *                                                                        *
+ **************************************************************************/
+
+
+/*
+ * Slightly friendlier names for some common registers.
+ */
+#define IIO_WIDGET              IIO_WID      /* Widget identification */
+#define IIO_WIDGET_STAT         IIO_WSTAT    /* Widget status register */
+#define IIO_WIDGET_CTRL         IIO_WCR      /* Widget control register */
+#define IIO_PROTECT             IIO_ILAPR    /* IO interface protection */
+#define IIO_PROTECT_OVRRD       IIO_ILAPO    /* IO protect override */
+#define IIO_OUTWIDGET_ACCESS    IIO_IOWA     /* Outbound widget access */
+#define IIO_INWIDGET_ACCESS     IIO_IIWA     /* Inbound widget access */
+#define IIO_INDEV_ERR_MASK      IIO_IIDEM    /* Inbound device error mask */
+#define IIO_LLP_CSR             IIO_ILCSR    /* LLP control and status */
+#define IIO_LLP_LOG             IIO_ILLR     /* LLP log */
+#define IIO_XTALKCC_TOUT        IIO_IXCC     /* Xtalk credit count timeout*/
+#define IIO_XTALKTT_TOUT        IIO_IXTT     /* Xtalk tail timeout */
+#define IIO_IO_ERR_CLR          IIO_IECLR    /* IO error clear */
+#define IIO_IGFX_0 		IIO_IGFX0
+#define IIO_IGFX_1 		IIO_IGFX1
+#define IIO_IBCT_0		IIO_IBCT0
+#define IIO_IBCT_1		IIO_IBCT1
+#define IIO_IBLS_0		IIO_IBLS0
+#define IIO_IBLS_1		IIO_IBLS1
+#define IIO_IBSA_0		IIO_IBSA0
+#define IIO_IBSA_1		IIO_IBSA1
+#define IIO_IBDA_0		IIO_IBDA0
+#define IIO_IBDA_1		IIO_IBDA1
+#define IIO_IBNA_0		IIO_IBNA0
+#define IIO_IBNA_1		IIO_IBNA1
+#define IIO_IBIA_0		IIO_IBIA0
+#define IIO_IBIA_1		IIO_IBIA1
+#define IIO_IOPRB_0		IIO_IPRB0
+
+#define IIO_PRTE_A(_x)		(IIO_IPRTE0_A + (8 * (_x)))
+#define IIO_PRTE_B(_x)		(IIO_IPRTE0_B + (8 * (_x)))
+#define IIO_NUM_PRTES		8	/* Total number of PRB table entries */
+#define IIO_WIDPRTE_A(x)	IIO_PRTE_A(((x) - 8)) /* widget ID to its PRTE num */
+#define IIO_WIDPRTE_B(x)	IIO_PRTE_B(((x) - 8)) /* widget ID to its PRTE num */
+
+#define IIO_NUM_IPRBS 		(9) 
+
+#define IIO_LLP_CSR_IS_UP               0x00002000
+#define IIO_LLP_CSR_LLP_STAT_MASK       0x00003000
+#define IIO_LLP_CSR_LLP_STAT_SHFT       12
+
+#define IIO_LLP_CB_MAX  0xffff	/* in ILLR CB_CNT, Max Check Bit errors */
+#define IIO_LLP_SN_MAX  0xffff	/* in ILLR SN_CNT, Max Sequence Number errors */
+
+/* key to IIO_PROTECT_OVRRD */
+#define IIO_PROTECT_OVRRD_KEY   0x53474972756c6573ull   /* "SGIrules" */
+
+/* BTE register names */
+#define IIO_BTE_STAT_0          IIO_IBLS_0   /* Also BTE length/status 0 */
+#define IIO_BTE_SRC_0           IIO_IBSA_0   /* Also BTE source address  0 */
+#define IIO_BTE_DEST_0          IIO_IBDA_0   /* Also BTE dest. address 0 */
+#define IIO_BTE_CTRL_0          IIO_IBCT_0   /* Also BTE control/terminate 0 */
+#define IIO_BTE_NOTIFY_0        IIO_IBNA_0   /* Also BTE notification 0 */
+#define IIO_BTE_INT_0           IIO_IBIA_0   /* Also BTE interrupt 0 */
+#define IIO_BTE_OFF_0           0            /* Base offset from BTE 0 regs. */
+#define IIO_BTE_OFF_1   	(IIO_IBLS_1 - IIO_IBLS_0) /* Offset from base to BTE 1 */
+
+/* BTE register offsets from base */
+#define BTEOFF_STAT             0
+#define BTEOFF_SRC              (IIO_BTE_SRC_0 - IIO_BTE_STAT_0)
+#define BTEOFF_DEST             (IIO_BTE_DEST_0 - IIO_BTE_STAT_0)
+#define BTEOFF_CTRL             (IIO_BTE_CTRL_0 - IIO_BTE_STAT_0)
+#define BTEOFF_NOTIFY           (IIO_BTE_NOTIFY_0 - IIO_BTE_STAT_0)
+#define BTEOFF_INT              (IIO_BTE_INT_0 - IIO_BTE_STAT_0)
+
+
+/* names used in shub diags */
+#define IIO_BASE_BTE0   IIO_IBLS_0		
+#define IIO_BASE_BTE1   IIO_IBLS_1		
+
+/*
+ * Macro which takes the widget number, and returns the
+ * IO PRB address of that widget.
+ * value _x is expected to be a widget number in the range
+ * 0, 8 - 0xF
+ */
+#define IIO_IOPRB(_x)   (IIO_IOPRB_0 + ( ( (_x) < HUB_WIDGET_ID_MIN ? \
+                        (_x) : \
+                        (_x) - (HUB_WIDGET_ID_MIN-1)) << 3) )
+
+
+/* GFX Flow Control Node/Widget Register */
+#define IIO_IGFX_W_NUM_BITS	4	/* size of widget num field */
+#define IIO_IGFX_W_NUM_MASK	((1<<IIO_IGFX_W_NUM_BITS)-1)
+#define IIO_IGFX_W_NUM_SHIFT	0
+#define IIO_IGFX_PI_NUM_BITS	1	/* size of PI num field */
+#define IIO_IGFX_PI_NUM_MASK	((1<<IIO_IGFX_PI_NUM_BITS)-1)
+#define IIO_IGFX_PI_NUM_SHIFT	4
+#define IIO_IGFX_N_NUM_BITS	8	/* size of node num field */
+#define IIO_IGFX_N_NUM_MASK	((1<<IIO_IGFX_N_NUM_BITS)-1)
+#define IIO_IGFX_N_NUM_SHIFT	5
+#define IIO_IGFX_P_NUM_BITS	1	/* size of processor num field */
+#define IIO_IGFX_P_NUM_MASK	((1<<IIO_IGFX_P_NUM_BITS)-1)
+#define IIO_IGFX_P_NUM_SHIFT	16
+#define IIO_IGFX_INIT(widget, pi, node, cpu)				(\
+	(((widget) & IIO_IGFX_W_NUM_MASK) << IIO_IGFX_W_NUM_SHIFT) |	 \
+	(((pi)     & IIO_IGFX_PI_NUM_MASK)<< IIO_IGFX_PI_NUM_SHIFT)|	 \
+	(((node)   & IIO_IGFX_N_NUM_MASK) << IIO_IGFX_N_NUM_SHIFT) |	 \
+	(((cpu)    & IIO_IGFX_P_NUM_MASK) << IIO_IGFX_P_NUM_SHIFT))
+
+
+/* Scratch registers (all bits available) */
+#define IIO_SCRATCH_REG0        IIO_ISCR0
+#define IIO_SCRATCH_REG1        IIO_ISCR1
+#define IIO_SCRATCH_MASK        0xffffffffffffffffUL
+
+#define IIO_SCRATCH_BIT0_0      0x0000000000000001UL
+#define IIO_SCRATCH_BIT0_1      0x0000000000000002UL
+#define IIO_SCRATCH_BIT0_2      0x0000000000000004UL
+#define IIO_SCRATCH_BIT0_3      0x0000000000000008UL
+#define IIO_SCRATCH_BIT0_4      0x0000000000000010UL
+#define IIO_SCRATCH_BIT0_5      0x0000000000000020UL
+#define IIO_SCRATCH_BIT0_6      0x0000000000000040UL
+#define IIO_SCRATCH_BIT0_7      0x0000000000000080UL
+#define IIO_SCRATCH_BIT0_8      0x0000000000000100UL
+#define IIO_SCRATCH_BIT0_9      0x0000000000000200UL
+#define IIO_SCRATCH_BIT0_A      0x0000000000000400UL
+
+#define IIO_SCRATCH_BIT1_0      0x0000000000000001UL
+#define IIO_SCRATCH_BIT1_1      0x0000000000000002UL
+/* IO Translation Table Entries */
+#define IIO_NUM_ITTES   7               /* ITTEs numbered 0..6 */
+                                        /* Hw manuals number them 1..7! */
+/*
+ * IIO_IMEM Register fields.
+ */
+#define IIO_IMEM_W0ESD  0x1UL             /* Widget 0 shut down due to error */
+#define IIO_IMEM_B0ESD  (1UL << 4)        /* BTE 0 shut down due to error */
+#define IIO_IMEM_B1ESD  (1UL << 8)        /* BTE 1 Shut down due to error */
+
+/*
+ * As a permanent workaround for a bug in the PI side of the shub, we've
+ * redefined big window 7 as small window 0.
+ XXX does this still apply for SN1??
+ */
+#define HUB_NUM_BIG_WINDOW      (IIO_NUM_ITTES - 1)
+
+/*
+ * Use the top big window as a surrogate for the first small window
+ */
+#define SWIN0_BIGWIN            HUB_NUM_BIG_WINDOW
+
+#define ILCSR_WARM_RESET        0x100
+
+/*
+ * CRB manipulation macros
+ *      The CRB macros are slightly complicated, since there are up to
+ *      four registers associated with each CRB entry.
+ */
+#define IIO_NUM_CRBS            15      /* Number of CRBs */
+#define IIO_NUM_PC_CRBS         4       /* Number of partial cache CRBs */
+#define IIO_ICRB_OFFSET         8
+#define IIO_ICRB_0              IIO_ICRB0_A
+#define IIO_ICRB_ADDR_SHFT	2	/* Shift to get proper address */
+/* XXX - This is now tuneable:
+        #define IIO_FIRST_PC_ENTRY 12
+ */
+
+#define IIO_ICRB_A(_x)  ((u64)(IIO_ICRB_0 + (6 * IIO_ICRB_OFFSET * (_x))))
+#define IIO_ICRB_B(_x)  ((u64)((char *)IIO_ICRB_A(_x) + 1*IIO_ICRB_OFFSET))
+#define IIO_ICRB_C(_x)  ((u64)((char *)IIO_ICRB_A(_x) + 2*IIO_ICRB_OFFSET))
+#define IIO_ICRB_D(_x)  ((u64)((char *)IIO_ICRB_A(_x) + 3*IIO_ICRB_OFFSET))
+#define IIO_ICRB_E(_x)  ((u64)((char *)IIO_ICRB_A(_x) + 4*IIO_ICRB_OFFSET))
+
+#define TNUM_TO_WIDGET_DEV(_tnum)	(_tnum & 0x7)
+
+/*
+ * values for "ecode" field
+ */
+#define IIO_ICRB_ECODE_DERR     0       /* Directory error due to IIO access */
+#define IIO_ICRB_ECODE_PERR     1       /* Poison error on IO access */
+#define IIO_ICRB_ECODE_WERR     2       /* Write error by IIO access
+                                         * e.g. WINV to a Read only line. */
+#define IIO_ICRB_ECODE_AERR     3       /* Access error caused by IIO access */
+#define IIO_ICRB_ECODE_PWERR    4       /* Error on partial write       */
+#define IIO_ICRB_ECODE_PRERR    5       /* Error on partial read        */
+#define IIO_ICRB_ECODE_TOUT     6       /* CRB timeout before deallocating */
+#define IIO_ICRB_ECODE_XTERR    7       /* Incoming xtalk pkt had error bit */
+
+/*
+ * Values for field imsgtype
+ */
+#define IIO_ICRB_IMSGT_XTALK    0       /* Incoming Meessage from Xtalk */
+#define IIO_ICRB_IMSGT_BTE      1       /* Incoming message from BTE    */
+#define IIO_ICRB_IMSGT_SN1NET   2       /* Incoming message from SN1 net */
+#define IIO_ICRB_IMSGT_CRB      3       /* Incoming message from CRB ???  */
+
+/*
+ * values for field initiator.
+ */
+#define IIO_ICRB_INIT_XTALK     0       /* Message originated in xtalk  */
+#define IIO_ICRB_INIT_BTE0      0x1     /* Message originated in BTE 0  */
+#define IIO_ICRB_INIT_SN1NET    0x2     /* Message originated in SN1net */
+#define IIO_ICRB_INIT_CRB       0x3     /* Message originated in CRB ?  */
+#define IIO_ICRB_INIT_BTE1      0x5     /* MEssage originated in BTE 1  */
+
+/*
+ * Number of credits Hub widget has while sending req/response to
+ * xbow.
+ * Value of 3 is required by Xbow 1.1
+ * We may be able to increase this to 4 with Xbow 1.2.
+ */
+#define       HUBII_XBOW_CREDIT       3
+#define       HUBII_XBOW_REV2_CREDIT  4
+
+/*
+ * Number of credits that xtalk devices should use when communicating
+ * with a SHub (depth of SHub's queue).
+ */
+#define HUB_CREDIT 4
+
+/*
+ * Some IIO_PRB fields
+ */
+#define IIO_PRB_MULTI_ERR	(1LL << 63)
+#define IIO_PRB_SPUR_RD		(1LL << 51)
+#define IIO_PRB_SPUR_WR		(1LL << 50)
+#define IIO_PRB_RD_TO		(1LL << 49)
+#define IIO_PRB_ERROR		(1LL << 48)
+
+/*************************************************************************
+
+ Some of the IIO field masks and shifts are defined here.
+ This is in order to maintain compatibility in SN0 and SN1 code
+ 
+**************************************************************************/
+
+/*
+ * ICMR register fields
+ * (Note: the IIO_ICMR_P_CNT and IIO_ICMR_PC_VLD from Hub are not
+ * present in SHub)
+ */
+
+#define IIO_ICMR_CRB_VLD_SHFT   20
+#define IIO_ICMR_CRB_VLD_MASK   (0x7fffUL << IIO_ICMR_CRB_VLD_SHFT)
+
+#define IIO_ICMR_FC_CNT_SHFT    16
+#define IIO_ICMR_FC_CNT_MASK    (0xf << IIO_ICMR_FC_CNT_SHFT)
+
+#define IIO_ICMR_C_CNT_SHFT     4
+#define IIO_ICMR_C_CNT_MASK     (0xf << IIO_ICMR_C_CNT_SHFT)
+
+#define IIO_ICMR_PRECISE        (1UL << 52)
+#define IIO_ICMR_CLR_RPPD       (1UL << 13)
+#define IIO_ICMR_CLR_RQPD       (1UL << 12)
+
+/*
+ * IIO PIO Deallocation register field masks : (IIO_IPDR)
+ XXX present but not needed in bedrock?  See the manual.
+ */
+#define IIO_IPDR_PND    (1 << 4)
+
+/*
+ * IIO CRB deallocation register field masks: (IIO_ICDR)
+ */
+#define IIO_ICDR_PND    (1 << 4)
+
+/* 
+ * IO BTE Length/Status (IIO_IBLS) register bit field definitions
+ */
+#define IBLS_BUSY		(0x1UL << 20)
+#define IBLS_ERROR_SHFT		16
+#define IBLS_ERROR		(0x1UL << IBLS_ERROR_SHFT)
+#define IBLS_LENGTH_MASK	0xffff
+
+/*
+ * IO BTE Control/Terminate register (IBCT) register bit field definitions
+ */
+#define IBCT_POISON		(0x1UL << 8)
+#define IBCT_NOTIFY		(0x1UL << 4)
+#define IBCT_ZFIL_MODE		(0x1UL << 0)
+
+/*
+ * IIO Incoming Error Packet Header (IIO_IIEPH1/IIO_IIEPH2)
+ */
+#define IIEPH1_VALID		(1UL << 44)
+#define IIEPH1_OVERRUN		(1UL << 40)
+#define IIEPH1_ERR_TYPE_SHFT	32
+#define IIEPH1_ERR_TYPE_MASK	0xf
+#define IIEPH1_SOURCE_SHFT	20
+#define IIEPH1_SOURCE_MASK	11
+#define IIEPH1_SUPPL_SHFT	8
+#define IIEPH1_SUPPL_MASK	11
+#define IIEPH1_CMD_SHFT		0
+#define IIEPH1_CMD_MASK		7
+
+#define IIEPH2_TAIL		(1UL << 40)
+#define IIEPH2_ADDRESS_SHFT	0
+#define IIEPH2_ADDRESS_MASK	38
+
+#define IIEPH1_ERR_SHORT_REQ	2
+#define IIEPH1_ERR_SHORT_REPLY	3
+#define IIEPH1_ERR_LONG_REQ	4
+#define IIEPH1_ERR_LONG_REPLY	5
+
+/*
+ * IO Error Clear register bit field definitions
+ */
+#define IECLR_PI1_FWD_INT	(1UL << 31)  /* clear PI1_FORWARD_INT in iidsr */
+#define IECLR_PI0_FWD_INT	(1UL << 30)  /* clear PI0_FORWARD_INT in iidsr */
+#define IECLR_SPUR_RD_HDR	(1UL << 29)  /* clear valid bit in ixss reg */
+#define IECLR_BTE1		(1UL << 18)  /* clear bte error 1 */
+#define IECLR_BTE0		(1UL << 17)  /* clear bte error 0 */
+#define IECLR_CRAZY		(1UL << 16)  /* clear crazy bit in wstat reg */
+#define IECLR_PRB_F		(1UL << 15)  /* clear err bit in PRB_F reg */
+#define IECLR_PRB_E		(1UL << 14)  /* clear err bit in PRB_E reg */
+#define IECLR_PRB_D		(1UL << 13)  /* clear err bit in PRB_D reg */
+#define IECLR_PRB_C		(1UL << 12)  /* clear err bit in PRB_C reg */
+#define IECLR_PRB_B		(1UL << 11)  /* clear err bit in PRB_B reg */
+#define IECLR_PRB_A		(1UL << 10)  /* clear err bit in PRB_A reg */
+#define IECLR_PRB_9		(1UL << 9)   /* clear err bit in PRB_9 reg */
+#define IECLR_PRB_8		(1UL << 8)   /* clear err bit in PRB_8 reg */
+#define IECLR_PRB_0		(1UL << 0)   /* clear err bit in PRB_0 reg */
+
+/*
+ * IIO CRB control register Fields: IIO_ICCR 
+ */
+#define	IIO_ICCR_PENDING	(0x10000)
+#define	IIO_ICCR_CMD_MASK	(0xFF)
+#define	IIO_ICCR_CMD_SHFT	(7)
+#define	IIO_ICCR_CMD_NOP	(0x0)	/* No Op */
+#define	IIO_ICCR_CMD_WAKE	(0x100) /* Reactivate CRB entry and process */
+#define	IIO_ICCR_CMD_TIMEOUT	(0x200)	/* Make CRB timeout & mark invalid */
+#define	IIO_ICCR_CMD_EJECT	(0x400)	/* Contents of entry written to memory 
+					 * via a WB
+					 */
+#define	IIO_ICCR_CMD_FLUSH	(0x800)
+
+/*
+ *
+ * CRB Register description.
+ *
+ * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
+ * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
+ * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
+ * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
+ * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
+ *
+ * Many of the fields in CRB are status bits used by hardware
+ * for implementation of the protocol. It's very dangerous to
+ * mess around with the CRB registers.
+ *
+ * It's OK to read the CRB registers and try to make sense out of the
+ * fields in CRB.
+ *
+ * Updating CRB requires all activities in Hub IIO to be quiesced.
+ * otherwise, a write to CRB could corrupt other CRB entries.
+ * CRBs are here only as a back door peek to shub IIO's status.
+ * Quiescing implies  no dmas no PIOs
+ * either directly from the cpu or from sn0net.
+ * this is not something that can be done easily. So, AVOID updating
+ * CRBs.
+ */
+
+/*
+ * Easy access macros for CRBs, all 5 registers (A-E)
+ */
+typedef ii_icrb0_a_u_t icrba_t;
+#define a_sidn          ii_icrb0_a_fld_s.ia_sidn
+#define a_tnum          ii_icrb0_a_fld_s.ia_tnum
+#define a_addr          ii_icrb0_a_fld_s.ia_addr
+#define a_valid         ii_icrb0_a_fld_s.ia_vld
+#define a_iow           ii_icrb0_a_fld_s.ia_iow
+#define a_regvalue	ii_icrb0_a_regval
+
+typedef ii_icrb0_b_u_t icrbb_t;
+#define b_use_old       ii_icrb0_b_fld_s.ib_use_old
+#define b_imsgtype      ii_icrb0_b_fld_s.ib_imsgtype
+#define b_imsg          ii_icrb0_b_fld_s.ib_imsg
+#define b_initiator     ii_icrb0_b_fld_s.ib_init
+#define b_exc           ii_icrb0_b_fld_s.ib_exc
+#define b_ackcnt        ii_icrb0_b_fld_s.ib_ack_cnt
+#define b_resp          ii_icrb0_b_fld_s.ib_resp
+#define b_ack           ii_icrb0_b_fld_s.ib_ack
+#define b_hold          ii_icrb0_b_fld_s.ib_hold
+#define b_wb            ii_icrb0_b_fld_s.ib_wb
+#define b_intvn         ii_icrb0_b_fld_s.ib_intvn
+#define b_stall_ib      ii_icrb0_b_fld_s.ib_stall_ib
+#define b_stall_int     ii_icrb0_b_fld_s.ib_stall__intr
+#define b_stall_bte_0   ii_icrb0_b_fld_s.ib_stall__bte_0
+#define b_stall_bte_1   ii_icrb0_b_fld_s.ib_stall__bte_1
+#define b_error         ii_icrb0_b_fld_s.ib_error
+#define b_ecode         ii_icrb0_b_fld_s.ib_errcode
+#define b_lnetuce       ii_icrb0_b_fld_s.ib_ln_uce
+#define b_mark          ii_icrb0_b_fld_s.ib_mark
+#define b_xerr          ii_icrb0_b_fld_s.ib_xt_err
+#define b_regvalue	ii_icrb0_b_regval
+
+typedef ii_icrb0_c_u_t icrbc_t;
+#define c_suppl         ii_icrb0_c_fld_s.ic_suppl
+#define c_barrop        ii_icrb0_c_fld_s.ic_bo
+#define c_doresp        ii_icrb0_c_fld_s.ic_resprqd
+#define c_gbr           ii_icrb0_c_fld_s.ic_gbr
+#define c_btenum        ii_icrb0_c_fld_s.ic_bte_num
+#define c_cohtrans      ii_icrb0_c_fld_s.ic_ct
+#define c_xtsize        ii_icrb0_c_fld_s.ic_size
+#define c_source        ii_icrb0_c_fld_s.ic_source
+#define c_regvalue	ii_icrb0_c_regval
+
+
+typedef ii_icrb0_d_u_t icrbd_t;
+#define d_sleep         ii_icrb0_d_fld_s.id_sleep
+#define d_pricnt        ii_icrb0_d_fld_s.id_pr_cnt
+#define d_pripsc        ii_icrb0_d_fld_s.id_pr_psc
+#define d_bteop         ii_icrb0_d_fld_s.id_bte_op
+#define d_bteaddr       ii_icrb0_d_fld_s.id_pa_be /* ic_pa_be fld has 2 names*/
+#define d_benable       ii_icrb0_d_fld_s.id_pa_be /* ic_pa_be fld has 2 names*/
+#define d_regvalue	ii_icrb0_d_regval
+
+typedef ii_icrb0_e_u_t icrbe_t;
+#define icrbe_ctxtvld   ii_icrb0_e_fld_s.ie_cvld
+#define icrbe_toutvld   ii_icrb0_e_fld_s.ie_tvld
+#define icrbe_context   ii_icrb0_e_fld_s.ie_context
+#define icrbe_timeout   ii_icrb0_e_fld_s.ie_timeout
+#define e_regvalue	ii_icrb0_e_regval
+
+
+/* Number of widgets supported by shub */
+#define HUB_NUM_WIDGET          9
+#define HUB_WIDGET_ID_MIN       0x8
+#define HUB_WIDGET_ID_MAX       0xf
+
+#define HUB_WIDGET_PART_NUM     0xc120
+#define MAX_HUBS_PER_XBOW       2
+
+/* A few more #defines for backwards compatibility */
+#define iprb_t          ii_iprb0_u_t
+#define iprb_regval     ii_iprb0_regval
+#define iprb_mult_err	ii_iprb0_fld_s.i_mult_err
+#define iprb_spur_rd	ii_iprb0_fld_s.i_spur_rd
+#define iprb_spur_wr	ii_iprb0_fld_s.i_spur_wr
+#define iprb_rd_to	ii_iprb0_fld_s.i_rd_to
+#define iprb_ovflow     ii_iprb0_fld_s.i_of_cnt
+#define iprb_error      ii_iprb0_fld_s.i_error
+#define iprb_ff         ii_iprb0_fld_s.i_f
+#define iprb_mode       ii_iprb0_fld_s.i_m
+#define iprb_bnakctr    ii_iprb0_fld_s.i_nb
+#define iprb_anakctr    ii_iprb0_fld_s.i_na
+#define iprb_xtalkctr   ii_iprb0_fld_s.i_c
+
+#define LNK_STAT_WORKING        0x2		/* LLP is working */
+
+#define IIO_WSTAT_ECRAZY        (1ULL << 32)    /* Hub gone crazy */
+#define IIO_WSTAT_TXRETRY       (1ULL << 9)     /* Hub Tx Retry timeout */
+#define IIO_WSTAT_TXRETRY_MASK  (0x7F)   /* should be 0xFF?? */
+#define IIO_WSTAT_TXRETRY_SHFT  (16)
+#define IIO_WSTAT_TXRETRY_CNT(w)        (((w) >> IIO_WSTAT_TXRETRY_SHFT) & \
+                                          IIO_WSTAT_TXRETRY_MASK)
+
+/* Number of II perf. counters we can multiplex at once */
+
+#define IO_PERF_SETS	32
+
+/* Bit for the widget in inbound access register */
+#define IIO_IIWA_WIDGET(_w)     ((uint64_t)(1ULL << _w))
+/* Bit for the widget in outbound access register */
+#define IIO_IOWA_WIDGET(_w)     ((uint64_t)(1ULL << _w))
+
+/* NOTE: The following define assumes that we are going to get
+ * widget numbers from 8 thru F and the device numbers within
+ * widget from 0 thru 7.
+ */
+#define IIO_IIDEM_WIDGETDEV_MASK(w, d)  ((uint64_t)(1ULL << (8 * ((w) - 8) + (d))))
+
+/* IO Interrupt Destination Register */
+#define IIO_IIDSR_SENT_SHIFT    28
+#define IIO_IIDSR_SENT_MASK     0x30000000
+#define IIO_IIDSR_ENB_SHIFT     24
+#define IIO_IIDSR_ENB_MASK      0x01000000
+#define IIO_IIDSR_NODE_SHIFT    9
+#define IIO_IIDSR_NODE_MASK     0x000ff700
+#define IIO_IIDSR_PI_ID_SHIFT   8
+#define IIO_IIDSR_PI_ID_MASK    0x00000100
+#define IIO_IIDSR_LVL_SHIFT     0
+#define IIO_IIDSR_LVL_MASK      0x000000ff
+
+/* Xtalk timeout threshhold register (IIO_IXTT) */
+#define IXTT_RRSP_TO_SHFT	55	   /* read response timeout */
+#define IXTT_RRSP_TO_MASK	(0x1FULL << IXTT_RRSP_TO_SHFT)
+#define IXTT_RRSP_PS_SHFT	32	   /* read responsed TO prescalar */
+#define IXTT_RRSP_PS_MASK	(0x7FFFFFULL << IXTT_RRSP_PS_SHFT)
+#define IXTT_TAIL_TO_SHFT	0	   /* tail timeout counter threshold */
+#define IXTT_TAIL_TO_MASK	(0x3FFFFFFULL << IXTT_TAIL_TO_SHFT)
+
+/*
+ * The IO LLP control status register and widget control register
+ */
+
+typedef union hubii_wcr_u {
+        uint64_t      wcr_reg_value;
+        struct {
+	  uint64_t	wcr_widget_id:   4,     /* LLP crossbar credit */
+			wcr_tag_mode:	 1,	/* Tag mode */
+			wcr_rsvd1:	 8,	/* Reserved */
+			wcr_xbar_crd:	 3,	/* LLP crossbar credit */
+			wcr_f_bad_pkt:	 1,	/* Force bad llp pkt enable */
+			wcr_dir_con:	 1,	/* widget direct connect */
+			wcr_e_thresh:	 5,	/* elasticity threshold */
+			wcr_rsvd:	41;	/* unused */
+        } wcr_fields_s;
+} hubii_wcr_t;
+
+#define iwcr_dir_con    wcr_fields_s.wcr_dir_con
+
+/* The structures below are defined to extract and modify the ii
+performance registers */
+
+/* io_perf_sel allows the caller to specify what tests will be
+   performed */
+
+typedef union io_perf_sel {
+        uint64_t perf_sel_reg;
+        struct {
+               uint64_t	perf_ippr0 :  4,
+				perf_ippr1 :  4,
+				perf_icct  :  8,
+				perf_rsvd  : 48;
+        } perf_sel_bits;
+} io_perf_sel_t;
+
+/* io_perf_cnt is to extract the count from the shub registers. Due to
+   hardware problems there is only one counter, not two. */
+
+typedef union io_perf_cnt {
+        uint64_t      perf_cnt;
+        struct {
+               uint64_t	perf_cnt   : 20,
+				perf_rsvd2 : 12,
+				perf_rsvd1 : 32;
+        } perf_cnt_bits;
+
+} io_perf_cnt_t;
+
+typedef union iprte_a {
+	uint64_t	entry;
+	struct {
+		uint64_t	i_rsvd_1                  :	 3;
+		uint64_t	i_addr			  :	38;
+		uint64_t	i_init			  :	 3;
+		uint64_t	i_source		  :	 8;
+		uint64_t	i_rsvd			  :	 2;
+		uint64_t	i_widget		  :	 4;
+		uint64_t	i_to_cnt		  :	 5;
+		uint64_t       i_vld                     :      1;
+	} iprte_fields;
+} iprte_a_t;
+
+#endif /* _ASM_IA64_SN_SHUBIO_H */
+
diff -Nru a/arch/ia64/sn/include/tio.h b/arch/ia64/sn/include/tio.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/tio.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,37 @@
+/* 
+ * 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-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#ifndef _ASM_IA64_SN_TIO_H
+#define _ASM_IA64_SN_TIO_H
+
+#define	TIO_MMR_ADDR_MOD
+
+#define TIO_NODE_ID     TIO_MMR_ADDR_MOD(0x0000000090060e80)
+
+#define TIO_ITTE_BASE   0xb0008800        /* base of translation table entries */
+#define TIO_ITTE(bigwin)        (TIO_ITTE_BASE + 8*(bigwin))
+
+#define TIO_ITTE_OFFSET_BITS    8       /* size of offset field */
+#define TIO_ITTE_OFFSET_MASK    ((1<<TIO_ITTE_OFFSET_BITS)-1)
+#define TIO_ITTE_OFFSET_SHIFT   0
+
+#define TIO_ITTE_WIDGET_BITS    2       /* size of widget field */
+#define TIO_ITTE_WIDGET_MASK    ((1<<TIO_ITTE_WIDGET_BITS)-1)
+#define TIO_ITTE_WIDGET_SHIFT   12
+#define TIO_ITTE_VALID_MASK	0x1
+#define TIO_ITTE_VALID_SHIFT	16
+
+
+#define TIO_ITTE_PUT(nasid, bigwin, widget, addr, valid) \
+        REMOTE_HUB_S((nasid), TIO_ITTE(bigwin), \
+                (((((addr) >> TIO_BWIN_SIZE_BITS) & \
+                   TIO_ITTE_OFFSET_MASK) << TIO_ITTE_OFFSET_SHIFT) | \
+                (((widget) & TIO_ITTE_WIDGET_MASK) << TIO_ITTE_WIDGET_SHIFT)) | \
+		(( (valid) & TIO_ITTE_VALID_MASK) << TIO_ITTE_VALID_SHIFT))
+
+#endif /*  _ASM_IA64_SN_TIO_H */
diff -Nru a/arch/ia64/sn/include/xtalk/hubdev.h b/arch/ia64/sn/include/xtalk/hubdev.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/xtalk/hubdev.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,67 @@
+/*
+ * 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 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+#ifndef _ASM_IA64_SN_XTALK_HUBDEV_H
+#define _ASM_IA64_SN_XTALK_HUBDEV_H
+
+#define HUB_WIDGET_ID_MAX 0xf
+#define DEV_PER_WIDGET (2*2*8)
+#define IIO_ITTE_WIDGET_BITS    4       /* size of widget field */
+#define IIO_ITTE_WIDGET_MASK    ((1<<IIO_ITTE_WIDGET_BITS)-1)
+#define IIO_ITTE_WIDGET_SHIFT   8
+
+/*
+ * Use the top big window as a surrogate for the first small window
+ */
+#define SWIN0_BIGWIN            HUB_NUM_BIG_WINDOW
+#define IIO_NUM_ITTES   7
+#define HUB_NUM_BIG_WINDOW      (IIO_NUM_ITTES - 1)
+
+struct sn_flush_device_list {
+	int sfdl_bus;
+	int sfdl_slot;
+	int sfdl_pin;
+	struct bar_list {
+		unsigned long start;
+		unsigned long end;
+	} sfdl_bar_list[6];
+	unsigned long sfdl_force_int_addr;
+	unsigned long sfdl_flush_value;
+	volatile unsigned long *sfdl_flush_addr;
+	uint64_t sfdl_persistent_busnum;
+	struct pcibus_info *sfdl_pcibus_info;
+	spinlock_t sfdl_flush_lock;
+};
+
+/*
+ * **widget_p - Used as an array[wid_num][device] of sn_flush_device_list.
+ */
+struct sn_flush_nasid_entry  {
+	struct sn_flush_device_list **widget_p; /* Used as a array of wid_num */
+	uint64_t iio_itte[8];
+};
+
+struct hubdev_info {
+	geoid_t				hdi_geoid;
+	short				hdi_nasid;
+	short				hdi_peer_nasid;   /* Dual Porting Peer */
+
+	struct sn_flush_nasid_entry	hdi_flush_nasid_list;
+	struct xwidget_info		hdi_xwidget_info[HUB_WIDGET_ID_MAX + 1];
+
+
+	void				*hdi_nodepda;
+	void				*hdi_node_vertex;
+	void				*hdi_xtalk_vertex;
+};
+
+extern void hubdev_init_node(nodepda_t *, cnodeid_t);
+extern void hub_error_init(struct hubdev_info *);
+extern void ice_error_init(struct hubdev_info *);
+
+
+#endif /* _ASM_IA64_SN_XTALK_HUBDEV_H */
diff -Nru a/arch/ia64/sn/include/xtalk/xbow.h b/arch/ia64/sn/include/xtalk/xbow.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/xtalk/xbow.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,291 @@
+/*
+ * 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-1997,2000-2004 Silicon Graphics, Inc. All Rights Reserved.
+ */
+#ifndef _ASM_IA64_SN_XTALK_XBOW_H
+#define _ASM_IA64_SN_XTALK_XBOW_H
+
+#define XBOW_PORT_8	0x8
+#define XBOW_PORT_C	0xc
+#define XBOW_PORT_F	0xf
+
+#define MAX_XBOW_PORTS	8	/* number of ports on xbow chip */
+#define BASE_XBOW_PORT	XBOW_PORT_8	/* Lowest external port */
+
+#define	XBOW_CREDIT	4
+
+#define MAX_XBOW_NAME 	16
+
+/* Register set for each xbow link */
+typedef volatile struct xb_linkregs_s {
+/* 
+ * we access these through synergy unswizzled space, so the address
+ * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
+ * That's why we put the register first and filler second.
+ */
+    uint32_t               link_ibf;
+    uint32_t               filler0;	/* filler for proper alignment */
+    uint32_t               link_control;
+    uint32_t               filler1;
+    uint32_t               link_status;
+    uint32_t               filler2;
+    uint32_t               link_arb_upper;
+    uint32_t               filler3;
+    uint32_t               link_arb_lower;
+    uint32_t               filler4;
+    uint32_t               link_status_clr;
+    uint32_t               filler5;
+    uint32_t               link_reset;
+    uint32_t               filler6;
+    uint32_t               link_aux_status;
+    uint32_t               filler7;
+} xb_linkregs_t;
+
+typedef volatile struct xbow_s {
+    /* standard widget configuration                       0x000000-0x000057 */
+    struct widget_cfg            xb_widget;  /* 0x000000 */
+
+    /* helper fieldnames for accessing bridge widget */
+
+#define xb_wid_id                       xb_widget.w_id
+#define xb_wid_stat                     xb_widget.w_status
+#define xb_wid_err_upper                xb_widget.w_err_upper_addr
+#define xb_wid_err_lower                xb_widget.w_err_lower_addr
+#define xb_wid_control                  xb_widget.w_control
+#define xb_wid_req_timeout              xb_widget.w_req_timeout
+#define xb_wid_int_upper                xb_widget.w_intdest_upper_addr
+#define xb_wid_int_lower                xb_widget.w_intdest_lower_addr
+#define xb_wid_err_cmdword              xb_widget.w_err_cmd_word
+#define xb_wid_llp                      xb_widget.w_llp_cfg
+#define xb_wid_stat_clr                 xb_widget.w_tflush
+
+/* 
+ * we access these through synergy unswizzled space, so the address
+ * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
+ * That's why we put the register first and filler second.
+ */
+    /* xbow-specific widget configuration                  0x000058-0x0000FF */
+    uint32_t               xb_wid_arb_reload;  /* 0x00005C */
+    uint32_t               _pad_000058;
+    uint32_t               xb_perf_ctr_a;      /* 0x000064 */
+    uint32_t               _pad_000060;
+    uint32_t               xb_perf_ctr_b;      /* 0x00006c */
+    uint32_t               _pad_000068;
+    uint32_t               xb_nic;     /* 0x000074 */
+    uint32_t               _pad_000070;
+
+    /* Xbridge only */
+    uint32_t               xb_w0_rst_fnc;      /* 0x00007C */
+    uint32_t               _pad_000078;
+    uint32_t               xb_l8_rst_fnc;      /* 0x000084 */
+    uint32_t               _pad_000080;
+    uint32_t               xb_l9_rst_fnc;      /* 0x00008c */
+    uint32_t               _pad_000088;
+    uint32_t               xb_la_rst_fnc;      /* 0x000094 */
+    uint32_t               _pad_000090;
+    uint32_t               xb_lb_rst_fnc;      /* 0x00009c */
+    uint32_t               _pad_000098;
+    uint32_t               xb_lc_rst_fnc;      /* 0x0000a4 */
+    uint32_t               _pad_0000a0;
+    uint32_t               xb_ld_rst_fnc;      /* 0x0000ac */
+    uint32_t               _pad_0000a8;
+    uint32_t               xb_le_rst_fnc;      /* 0x0000b4 */
+    uint32_t               _pad_0000b0;
+    uint32_t               xb_lf_rst_fnc;      /* 0x0000bc */
+    uint32_t               _pad_0000b8;
+    uint32_t               xb_lock;            /* 0x0000c4 */
+    uint32_t               _pad_0000c0;
+    uint32_t               xb_lock_clr;        /* 0x0000cc */
+    uint32_t               _pad_0000c8;
+    /* end of Xbridge only */
+    uint32_t               _pad_0000d0[12];
+
+    /* Link Specific Registers, port 8..15                 0x000100-0x000300 */
+    xb_linkregs_t           xb_link_raw[MAX_XBOW_PORTS];
+#define xb_link(p)      xb_link_raw[(p) & (MAX_XBOW_PORTS - 1)]
+
+} xbow_t;
+
+#define XB_FLAGS_EXISTS		0x1	/* device exists */
+#define XB_FLAGS_MASTER		0x2
+#define XB_FLAGS_SLAVE		0x0
+#define XB_FLAGS_GBR		0x4
+#define XB_FLAGS_16BIT		0x8
+#define XB_FLAGS_8BIT		0x0
+
+/* is widget port number valid?  (based on version 7.0 of xbow spec) */
+#define XBOW_WIDGET_IS_VALID(wid) ((wid) >= XBOW_PORT_8 && (wid) <= XBOW_PORT_F)
+
+/* whether to use upper or lower arbitration register, given source widget id */
+#define XBOW_ARB_IS_UPPER(wid) 	((wid) >= XBOW_PORT_8 && (wid) <= XBOW_PORT_B)
+#define XBOW_ARB_IS_LOWER(wid) 	((wid) >= XBOW_PORT_C && (wid) <= XBOW_PORT_F)
+
+/* offset of arbitration register, given source widget id */
+#define XBOW_ARB_OFF(wid) 	(XBOW_ARB_IS_UPPER(wid) ? 0x1c : 0x24)
+
+#define	XBOW_WID_ID		WIDGET_ID
+#define	XBOW_WID_STAT		WIDGET_STATUS
+#define	XBOW_WID_ERR_UPPER	WIDGET_ERR_UPPER_ADDR
+#define	XBOW_WID_ERR_LOWER	WIDGET_ERR_LOWER_ADDR
+#define	XBOW_WID_CONTROL	WIDGET_CONTROL
+#define	XBOW_WID_REQ_TO		WIDGET_REQ_TIMEOUT
+#define	XBOW_WID_INT_UPPER	WIDGET_INTDEST_UPPER_ADDR
+#define	XBOW_WID_INT_LOWER	WIDGET_INTDEST_LOWER_ADDR
+#define	XBOW_WID_ERR_CMDWORD	WIDGET_ERR_CMD_WORD
+#define	XBOW_WID_LLP		WIDGET_LLP_CFG
+#define	XBOW_WID_STAT_CLR	WIDGET_TFLUSH
+#define XBOW_WID_ARB_RELOAD 	0x5c
+#define XBOW_WID_PERF_CTR_A 	0x64
+#define XBOW_WID_PERF_CTR_B 	0x6c
+#define XBOW_WID_NIC 		0x74
+
+/* Xbridge only */
+#define XBOW_W0_RST_FNC		0x00007C
+#define	XBOW_L8_RST_FNC		0x000084
+#define	XBOW_L9_RST_FNC		0x00008c
+#define	XBOW_LA_RST_FNC		0x000094
+#define	XBOW_LB_RST_FNC		0x00009c
+#define	XBOW_LC_RST_FNC		0x0000a4
+#define	XBOW_LD_RST_FNC		0x0000ac
+#define	XBOW_LE_RST_FNC		0x0000b4
+#define	XBOW_LF_RST_FNC		0x0000bc
+#define XBOW_RESET_FENCE(x) ((x) > 7 && (x) < 16) ? \
+				(XBOW_W0_RST_FNC + ((x) - 7) * 8) : \
+				((x) == 0) ? XBOW_W0_RST_FNC : 0
+#define XBOW_LOCK		0x0000c4
+#define XBOW_LOCK_CLR		0x0000cc
+/* End of Xbridge only */
+
+/* used only in ide, but defined here within the reserved portion */
+/*              of the widget0 address space (before 0xf4) */
+#define	XBOW_WID_UNDEF		0xe4
+
+/* xbow link register set base, legal value for x is 0x8..0xf */
+#define	XB_LINK_BASE		0x100
+#define	XB_LINK_OFFSET		0x40
+#define	XB_LINK_REG_BASE(x)	(XB_LINK_BASE + ((x) & (MAX_XBOW_PORTS - 1)) * XB_LINK_OFFSET)
+
+#define	XB_LINK_IBUF_FLUSH(x)	(XB_LINK_REG_BASE(x) + 0x4)
+#define	XB_LINK_CTRL(x)		(XB_LINK_REG_BASE(x) + 0xc)
+#define	XB_LINK_STATUS(x)	(XB_LINK_REG_BASE(x) + 0x14)
+#define	XB_LINK_ARB_UPPER(x)	(XB_LINK_REG_BASE(x) + 0x1c)
+#define	XB_LINK_ARB_LOWER(x)	(XB_LINK_REG_BASE(x) + 0x24)
+#define	XB_LINK_STATUS_CLR(x)	(XB_LINK_REG_BASE(x) + 0x2c)
+#define	XB_LINK_RESET(x)	(XB_LINK_REG_BASE(x) + 0x34)
+#define	XB_LINK_AUX_STATUS(x)	(XB_LINK_REG_BASE(x) + 0x3c)
+
+/* link_control(x) */
+#define	XB_CTRL_LINKALIVE_IE		0x80000000	/* link comes alive */
+     /* reserved:			0x40000000 */
+#define	XB_CTRL_PERF_CTR_MODE_MSK	0x30000000	/* perf counter mode */
+#define	XB_CTRL_IBUF_LEVEL_MSK		0x0e000000	/* input packet buffer level */
+#define	XB_CTRL_8BIT_MODE		0x01000000	/* force link into 8 bit mode */
+#define XB_CTRL_BAD_LLP_PKT		0x00800000	/* force bad LLP packet */
+#define XB_CTRL_WIDGET_CR_MSK		0x007c0000	/* LLP widget credit mask */
+#define XB_CTRL_WIDGET_CR_SHFT	18			/* LLP widget credit shift */
+#define XB_CTRL_ILLEGAL_DST_IE		0x00020000	/* illegal destination */
+#define XB_CTRL_OALLOC_IBUF_IE		0x00010000	/* overallocated input buffer */
+     /* reserved:			0x0000fe00 */
+#define XB_CTRL_BNDWDTH_ALLOC_IE	0x00000100	/* bandwidth alloc */
+#define XB_CTRL_RCV_CNT_OFLOW_IE	0x00000080	/* rcv retry overflow */
+#define XB_CTRL_XMT_CNT_OFLOW_IE	0x00000040	/* xmt retry overflow */
+#define XB_CTRL_XMT_MAX_RTRY_IE		0x00000020	/* max transmit retry */
+#define XB_CTRL_RCV_IE			0x00000010	/* receive */
+#define XB_CTRL_XMT_RTRY_IE		0x00000008	/* transmit retry */
+     /* reserved:			0x00000004 */
+#define	XB_CTRL_MAXREQ_TOUT_IE		0x00000002	/* maximum request timeout */
+#define	XB_CTRL_SRC_TOUT_IE		0x00000001	/* source timeout */
+
+/* link_status(x) */
+#define	XB_STAT_LINKALIVE		XB_CTRL_LINKALIVE_IE
+     /* reserved:			0x7ff80000 */
+#define	XB_STAT_MULTI_ERR		0x00040000	/* multi error */
+#define	XB_STAT_ILLEGAL_DST_ERR		XB_CTRL_ILLEGAL_DST_IE
+#define	XB_STAT_OALLOC_IBUF_ERR		XB_CTRL_OALLOC_IBUF_IE
+#define	XB_STAT_BNDWDTH_ALLOC_ID_MSK	0x0000ff00	/* port bitmask */
+#define	XB_STAT_RCV_CNT_OFLOW_ERR	XB_CTRL_RCV_CNT_OFLOW_IE
+#define	XB_STAT_XMT_CNT_OFLOW_ERR	XB_CTRL_XMT_CNT_OFLOW_IE
+#define	XB_STAT_XMT_MAX_RTRY_ERR	XB_CTRL_XMT_MAX_RTRY_IE
+#define	XB_STAT_RCV_ERR			XB_CTRL_RCV_IE
+#define	XB_STAT_XMT_RTRY_ERR		XB_CTRL_XMT_RTRY_IE
+     /* reserved:			0x00000004 */
+#define	XB_STAT_MAXREQ_TOUT_ERR		XB_CTRL_MAXREQ_TOUT_IE
+#define	XB_STAT_SRC_TOUT_ERR		XB_CTRL_SRC_TOUT_IE
+
+/* link_aux_status(x) */
+#define	XB_AUX_STAT_RCV_CNT	0xff000000
+#define	XB_AUX_STAT_XMT_CNT	0x00ff0000
+#define	XB_AUX_STAT_TOUT_DST	0x0000ff00
+#define	XB_AUX_LINKFAIL_RST_BAD	0x00000040
+#define	XB_AUX_STAT_PRESENT	0x00000020
+#define	XB_AUX_STAT_PORT_WIDTH	0x00000010
+     /*	reserved:		0x0000000f */
+
+/*
+ * link_arb_upper/link_arb_lower(x), (reg) should be the link_arb_upper
+ * register if (x) is 0x8..0xb, link_arb_lower if (x) is 0xc..0xf
+ */
+#define	XB_ARB_GBR_MSK		0x1f
+#define	XB_ARB_RR_MSK		0x7
+#define	XB_ARB_GBR_SHFT(x)	(((x) & 0x3) * 8)
+#define	XB_ARB_RR_SHFT(x)	(((x) & 0x3) * 8 + 5)
+#define	XB_ARB_GBR_CNT(reg,x)	((reg) >> XB_ARB_GBR_SHFT(x) & XB_ARB_GBR_MSK)
+#define	XB_ARB_RR_CNT(reg,x)	((reg) >> XB_ARB_RR_SHFT(x) & XB_ARB_RR_MSK)
+
+/* XBOW_WID_STAT */
+#define	XB_WID_STAT_LINK_INTR_SHFT	(24)
+#define	XB_WID_STAT_LINK_INTR_MASK	(0xFF << XB_WID_STAT_LINK_INTR_SHFT)
+#define	XB_WID_STAT_LINK_INTR(x)	(0x1 << (((x)&7) + XB_WID_STAT_LINK_INTR_SHFT))
+#define	XB_WID_STAT_WIDGET0_INTR	0x00800000
+#define XB_WID_STAT_SRCID_MASK		0x000003c0	/* Xbridge only */
+#define	XB_WID_STAT_REG_ACC_ERR		0x00000020
+#define XB_WID_STAT_RECV_TOUT		0x00000010	/* Xbridge only */
+#define XB_WID_STAT_ARB_TOUT		0x00000008	/* Xbridge only */
+#define	XB_WID_STAT_XTALK_ERR		0x00000004
+#define XB_WID_STAT_DST_TOUT		0x00000002	/* Xbridge only */
+#define	XB_WID_STAT_MULTI_ERR		0x00000001
+
+#define XB_WID_STAT_SRCID_SHFT		6
+
+/* XBOW_WID_CONTROL */
+#define XB_WID_CTRL_REG_ACC_IE		XB_WID_STAT_REG_ACC_ERR
+#define XB_WID_CTRL_RECV_TOUT		XB_WID_STAT_RECV_TOUT
+#define XB_WID_CTRL_ARB_TOUT		XB_WID_STAT_ARB_TOUT
+#define XB_WID_CTRL_XTALK_IE		XB_WID_STAT_XTALK_ERR
+
+/* XBOW_WID_INT_UPPER */
+/* defined in xwidget.h for WIDGET_INTDEST_UPPER_ADDR */
+
+/* XBOW WIDGET part number, in the ID register */
+#define XBOW_WIDGET_PART_NUM	0x0		/* crossbow */
+#define XXBOW_WIDGET_PART_NUM	0xd000		/* Xbridge */
+#define	XBOW_WIDGET_MFGR_NUM	0x0
+#define	XXBOW_WIDGET_MFGR_NUM	0x0
+#define PXBOW_WIDGET_PART_NUM   0xd100          /* PIC */
+
+#define	XBOW_REV_1_0		0x1	/* xbow rev 1.0 is "1" */
+#define	XBOW_REV_1_1		0x2	/* xbow rev 1.1 is "2" */
+#define XBOW_REV_1_2		0x3	/* xbow rev 1.2 is "3" */
+#define XBOW_REV_1_3		0x4	/* xbow rev 1.3 is "4" */
+#define XBOW_REV_2_0		0x5	/* xbow rev 2.0 is "5" */
+
+#define XXBOW_PART_REV_1_0		(XXBOW_WIDGET_PART_NUM << 4 | 0x1 )
+#define XXBOW_PART_REV_2_0		(XXBOW_WIDGET_PART_NUM << 4 | 0x2 )
+
+/* XBOW_WID_ARB_RELOAD */
+#define	XBOW_WID_ARB_RELOAD_INT	0x3f	/* GBR reload interval */
+
+#define IS_XBRIDGE_XBOW(wid) \
+        (XWIDGET_PART_NUM(wid) == XXBOW_WIDGET_PART_NUM && \
+                        XWIDGET_MFG_NUM(wid) == XXBOW_WIDGET_MFGR_NUM)
+
+#define IS_PIC_XBOW(wid) \
+        (XWIDGET_PART_NUM(wid) == PXBOW_WIDGET_PART_NUM && \
+                        XWIDGET_MFG_NUM(wid) == XXBOW_WIDGET_MFGR_NUM)
+
+#define XBOW_WAR_ENABLED(pv, widid) ((1 << XWIDGET_REV_NUM(widid)) & pv)
+
+#endif                          /* _ASM_IA64_SN_XTALK_XBOW_H */
diff -Nru a/arch/ia64/sn/include/xtalk/xwidgetdev.h b/arch/ia64/sn/include/xtalk/xwidgetdev.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/include/xtalk/xwidgetdev.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,70 @@
+/*
+ * 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-1997,2000-2003 Silicon Graphics, Inc. All Rights Reserved.
+ */
+#ifndef _ASM_IA64_SN_XTALK_XWIDGET_H
+#define _ASM_IA64_SN_XTALK_XWIDGET_H
+
+/* WIDGET_ID */
+#define WIDGET_REV_NUM                  0xf0000000
+#define WIDGET_PART_NUM                 0x0ffff000
+#define WIDGET_MFG_NUM                  0x00000ffe
+#define WIDGET_REV_NUM_SHFT             28
+#define WIDGET_PART_NUM_SHFT            12
+#define WIDGET_MFG_NUM_SHFT             1
+
+#define XWIDGET_PART_NUM(widgetid) (((widgetid) & WIDGET_PART_NUM) >> WIDGET_PART_NUM_SHFT)
+#define XWIDGET_REV_NUM(widgetid) (((widgetid) & WIDGET_REV_NUM) >> WIDGET_REV_NUM_SHFT)
+#define XWIDGET_MFG_NUM(widgetid) (((widgetid) & WIDGET_MFG_NUM) >> WIDGET_MFG_NUM_SHFT)
+#define XWIDGET_PART_REV_NUM(widgetid) ((XWIDGET_PART_NUM(widgetid) << 4) | \
+                                        XWIDGET_REV_NUM(widgetid))
+#define XWIDGET_PART_REV_NUM_REV(partrev) (partrev & 0xf)
+
+/* widget configuration registers */
+struct widget_cfg{
+	uint32_t	w_id;	/* 0x04 */
+	uint32_t	w_pad_0;	/* 0x00 */
+	uint32_t	w_status;	/* 0x0c */
+	uint32_t	w_pad_1;	/* 0x08 */
+	uint32_t	w_err_upper_addr;	/* 0x14 */
+	uint32_t	w_pad_2;	/* 0x10 */
+	uint32_t	w_err_lower_addr;	/* 0x1c */
+	uint32_t	w_pad_3;	/* 0x18 */
+	uint32_t	w_control;	/* 0x24 */
+	uint32_t	w_pad_4;	/* 0x20 */
+	uint32_t	w_req_timeout;	/* 0x2c */
+	uint32_t	w_pad_5;	/* 0x28 */
+	uint32_t	w_intdest_upper_addr;	/* 0x34 */
+	uint32_t	w_pad_6;	/* 0x30 */
+	uint32_t	w_intdest_lower_addr;	/* 0x3c */
+	uint32_t	w_pad_7;	/* 0x38 */
+	uint32_t	w_err_cmd_word;	/* 0x44 */
+	uint32_t	w_pad_8;	/* 0x40 */
+	uint32_t	w_llp_cfg;	/* 0x4c */
+	uint32_t	w_pad_9;	/* 0x48 */
+	uint32_t	w_tflush;	/* 0x54 */
+	uint32_t	w_pad_10;	/* 0x50 */
+};
+
+/*
+ * Crosstalk Widget Hardware Identification, as defined in the Crosstalk spec.
+ */
+struct xwidget_hwid{
+	int		mfg_num;
+	int		rev_num;
+	int		part_num;
+};
+
+struct xwidget_info{
+
+	struct xwidget_hwid	xwi_hwid;	/* Widget Identification */
+	char			xwi_masterxid;	/* Hub's Widget Port Number */
+	void			*xwi_hubinfo;     /* Hub's provider private info */
+	uint64_t		*xwi_hub_provider; /* prom provider functions */
+	void			*xwi_vertex;
+};
+
+#endif                          /* _ASM_IA64_SN_XTALK_XWIDGET_H */
diff -Nru a/arch/ia64/sn/io/Makefile b/arch/ia64/sn/io/Makefile
--- a/arch/ia64/sn/io/Makefile	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,13 +0,0 @@
-# arch/ia64/sn/io/Makefile
-#
-# 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-2002 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# Makefile for the sn io routines.
-#
-
-obj-y += xswitch.o cdl.o snia_if.o \
-	 io.o machvec/ drivers/ platform_init/ sn2/ hwgfs/
diff -Nru a/arch/ia64/sn/io/cdl.c b/arch/ia64/sn/io/cdl.c
--- a/arch/ia64/sn/io/cdl.c	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,79 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/io.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/pci/pic.h>
-#include "asm/sn/ioerror_handling.h"
-#include <asm/sn/xtalk/xbow.h>
-
-/* these get called directly in cdl_add_connpt in fops bypass hack */
-extern int xbow_attach(vertex_hdl_t);
-extern int pic_attach(vertex_hdl_t);
-
-/*
- *    cdl: Connection and Driver List
- *
- *	We are not porting this to Linux.  Devices are registered via 
- *	the normal Linux PCI layer.  This is a very simplified version 
- *	of cdl that will allow us to register and call our very own 
- *	IO Infrastructure Drivers e.g. pcibr.
- */
-
-#define MAX_SGI_IO_INFRA_DRVR 5
-
-static struct cdl sgi_infrastructure_drivers[MAX_SGI_IO_INFRA_DRVR] =
-{
-	{ PIC_WIDGET_PART_NUM_BUS0,  PIC_WIDGET_MFGR_NUM,   pic_attach /* &pcibr_fops */},
-	{ PIC_WIDGET_PART_NUM_BUS1,  PIC_WIDGET_MFGR_NUM,   pic_attach /* &pcibr_fops */},
-	{ XXBOW_WIDGET_PART_NUM,   XXBOW_WIDGET_MFGR_NUM,   xbow_attach /* &xbow_fops */},
-	{ XBOW_WIDGET_PART_NUM,    XBOW_WIDGET_MFGR_NUM,    xbow_attach /* &xbow_fops */},
-	{ PXBOW_WIDGET_PART_NUM,   XXBOW_WIDGET_MFGR_NUM,   xbow_attach /* &xbow_fops */},
-};
-
-/*
- * cdl_add_connpt: We found a device and it's connect point.  Call the 
- * attach routine of that driver.
- *
- * May need support for pciba registration here ...
- *
- * This routine use to create /hw/.id/pci/.../.. that links to 
- * /hw/module/006c06/Pbrick/xtalk/15/pci/<slotnum> .. do we still need 
- * it?  The specified driver attach routine does not reference these 
- * vertices.
- */
-int
-cdl_add_connpt(int part_num, int mfg_num, 
-	       vertex_hdl_t connpt, int drv_flags)
-{
-	int i;
-	
-	/*
-	 * Find the driver entry point and call the attach routine.
-	 */
-	for (i = 0; i < MAX_SGI_IO_INFRA_DRVR; i++) {
-		if ( (part_num == sgi_infrastructure_drivers[i].part_num) &&
-		   ( mfg_num == sgi_infrastructure_drivers[i].mfg_num) ) {
-			/*
-			 * Call the device attach routines.
-			 */
-			if (sgi_infrastructure_drivers[i].attach) {
-			    return(sgi_infrastructure_drivers[i].attach(connpt));
-			}
-		} else {
-			continue;
-		}
-	}	
-
-	/* printk("WARNING: cdl_add_connpt: Driver not found for part_num 0x%x mfg_num 0x%x\n", part_num, mfg_num); */
-
-	return (0);
-}
diff -Nru a/arch/ia64/sn/io/drivers/Makefile b/arch/ia64/sn/io/drivers/Makefile
--- a/arch/ia64/sn/io/drivers/Makefile	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,10 +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) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# Makefile for the sn2 io routines.
-
-obj-y				+= ioconfig_bus.o
diff -Nru a/arch/ia64/sn/io/drivers/ioconfig_bus.c b/arch/ia64/sn/io/drivers/ioconfig_bus.c
--- a/arch/ia64/sn/io/drivers/ioconfig_bus.c	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,382 +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.
- *
- *  ioconfig_bus - SGI's Persistent PCI Bus Numbering.
- *
- * Copyright (C) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/ctype.h>
-#include <linux/module.h>
-#include <linux/init.h>
-
-#include <linux/pci.h>
-
-#include <asm/uaccess.h>
-#include <asm/sn/sgi.h>
-#include <asm/io.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/ioconfig_bus.h>
-
-#define SGI_IOCONFIG_BUS "SGI-PERSISTENT PCI BUS NUMBERING"
-#define SGI_IOCONFIG_BUS_VERSION "1.0"
-
-/*
- * Some Global definitions.
- */
-static vertex_hdl_t ioconfig_bus_handle;
-static unsigned long ioconfig_bus_debug;
-static struct ioconfig_parm parm;
-
-#ifdef IOCONFIG_BUS_DEBUG
-#define DBG(x...)	printk(x)
-#else
-#define DBG(x...)
-#endif
-
-static u64 ioconfig_activated;
-static char ioconfig_kernopts[128];
-
-/*
- * For debugging purpose .. hardcode a table ..
- */
-struct  ascii_moduleid *ioconfig_bus_table;
-
-static int free_entry;
-static int new_entry;
-
-int next_basebus_number;
-
-void
-ioconfig_get_busnum(char *io_moduleid, int *bus_num)
-{
-	struct	ascii_moduleid  *temp;
-	int index;
-
-	DBG("ioconfig_get_busnum io_moduleid %s\n", io_moduleid);
-
-	*bus_num = -1;
-	temp = ioconfig_bus_table;
-	if (!ioconfig_bus_table)
-		return;
-	for (index = 0; index < free_entry; temp++, index++) {
-		if ( (io_moduleid[0] == temp->io_moduleid[0]) &&
-		     (io_moduleid[1] == temp->io_moduleid[1]) &&
-		     (io_moduleid[2] == temp->io_moduleid[2]) &&
-		     (io_moduleid[4] == temp->io_moduleid[4]) &&
-		     (io_moduleid[5] == temp->io_moduleid[5]) ) {
-			*bus_num = index * 0x10;
-			return;
-		}
-	}
-
-	/*
-	 * New IO Brick encountered.
-	 */
-	if (((int)io_moduleid[0]) == 0) {
-		DBG("ioconfig_get_busnum: Invalid Module Id given %s\n", io_moduleid);
-		return;
-	}
-
-	io_moduleid[3] = '#';
-	strcpy((char *)&(ioconfig_bus_table[free_entry].io_moduleid), io_moduleid);
-	*bus_num = free_entry * 0x10;
-	free_entry++;
-}
-
-static void
-dump_ioconfig_table(void)
-{
-
-	int index = 0;
-	struct ascii_moduleid *temp;
-
-	temp = ioconfig_bus_table;
-	if (!temp) {
-		DBG("ioconfig_bus_table tabel empty\n");
-		return;
-	}
-	while (index < free_entry) {
-		DBG("ASSCI Module ID %s\n", temp->io_moduleid);
-		temp++;
-		index++;
-	}
-}
-
-/*
- * nextline
- *	This routine returns the nextline in the buffer.
- */
-int nextline(char *buffer, char **next, char *line)
-{
-
-	char *temp;
-
-	if (buffer[0] == 0x0) {
-		return(0);
-	}
-
-	temp = buffer;
-	while (*temp != 0) {
-		*line = *temp;
-		if (*temp != '\n'){
-			*line = *temp;
-			temp++; line++;
-		} else
-			break;
-	}
-
-	if (*temp == 0)
-		*next = temp;
-	else
-		*next = ++temp;
-
-	return(1);
-}
-
-/*
- * build_pcibus_name
- *	This routine parses the ioconfig contents read into
- *	memory by ioconfig command in EFI and builds the
- *	persistent pci bus naming table.
- */
-int
-build_moduleid_table(char *file_contents, struct ascii_moduleid *table)
-{
-	/*
-	 * Read the whole file into memory.
-	 */
-	int rc;
-	char *name;
-	char *temp;
-	char *next;
-	char *curr;
-	char *line;
-	struct ascii_moduleid *moduleid;
-
-	line = kmalloc(256, GFP_KERNEL);
-	name = kmalloc(125, GFP_KERNEL);
-	if (!line || !name) {
-		if (line)
-			kfree(line);
-		if (name)
-			kfree(name);
-		printk("build_moduleid_table(): Unabled to allocate memmory");
-		return -ENOMEM;
-	}
-
-	memset(line, 0,256);
-	memset(name, 0, 125);
-	moduleid = table;
-	curr = file_contents;
-	while (nextline(curr, &next, line)){
-
-		DBG("curr 0x%lx next 0x%lx\n", curr, next);
-
-		temp = line;
-		/*
-		 * Skip all leading Blank lines ..
-		 */
-		while (isspace(*temp))
-			if (*temp != '\n')
-				temp++;
-			else
-				break;
-
-		if (*temp == '\n') {
-			curr = next;
-			memset(line, 0, 256);
-			continue;
-		}
- 
-		/*
-		 * Skip comment lines
-		 */
-		if (*temp == '#') {
-			curr = next;
-			memset(line, 0, 256);
-			continue;
-		}
-
-		/*
-		 * Get the next free entry in the table.
-		 */
-		rc = sscanf(temp, "%s", name);
-		strcpy(&moduleid->io_moduleid[0], name);
-		DBG("Found %s\n", name);
-		moduleid++;
-		free_entry++;
-		curr = next;
-		memset(line, 0, 256);
-	}
-
-	new_entry = free_entry;
-	kfree(line);
-	kfree(name);
-
-	return 0;
-}
-
-int
-ioconfig_bus_init(void)
-{
-
-	DBG("ioconfig_bus_init called.\n");
-
-	ioconfig_bus_table = kmalloc( 512, GFP_KERNEL );
-	if (!ioconfig_bus_table) {
-		printk("ioconfig_bus_init : cannot allocate memory\n");
-		return -1;
-	}
-
-	memset(ioconfig_bus_table, 0, 512);
-
-	/*
-	 * If ioconfig options are given on the bootline .. take it.
-	 */
-	if (*ioconfig_kernopts != '\0') {
-		/*
-		 * ioconfig="..." kernel options given.
-		 */
-		DBG("ioconfig_bus_init: Kernel Options given.\n");
-		if ( build_moduleid_table((char *)ioconfig_kernopts, ioconfig_bus_table) < 0 )
-			return -1;
-		(void) dump_ioconfig_table();
-	}
-	return 0;
-}
-
-void
-ioconfig_bus_new_entries(void)
-{
-	int index;
-	struct ascii_moduleid *temp;
-
-	if ((ioconfig_activated) && (free_entry > new_entry)) {
-		printk("### Please add the following new IO Bricks Module ID \n");
-		printk("### to your Persistent Bus Numbering Config File\n");
-	} else
-		return;
-
-	index = new_entry;
-	if (!ioconfig_bus_table) {
-		printk("ioconfig_bus_table table is empty\n");
-		return;
-	}
-	temp = &ioconfig_bus_table[index];
-        while (index < free_entry) {
-                printk("%s\n", (char *)temp);
-		temp++;
-                index++;
-        }
-	printk("### End\n");
-
-}
-static int ioconfig_bus_ioctl(struct inode * inode, struct file * file,
-        unsigned int cmd, unsigned long arg)
-{
-	/*
-	 * Copy in the parameters.
-	 */
-	if (copy_from_user(&parm, (char *)arg, sizeof(struct ioconfig_parm)))
-		return -EFAULT;
-	parm.number = free_entry - new_entry;
-	parm.ioconfig_activated = ioconfig_activated;
-	if (copy_to_user((char *)arg, &parm, sizeof(struct ioconfig_parm)))
-		return -EFAULT;
-
-	if (!ioconfig_bus_table)
-		return -EFAULT;
-
-	if (copy_to_user((char *)parm.buffer, &ioconfig_bus_table[new_entry], sizeof(struct  ascii_moduleid) * (free_entry - new_entry)))
-		return -EFAULT;
-
-	return 0;
-}
-
-/*
- * ioconfig_bus_open - Opens the special device node "/dev/hw/.ioconfig_bus".
- */
-static int ioconfig_bus_open(struct inode * inode, struct file * filp)
-{
-	if (ioconfig_bus_debug) {
-        	DBG("ioconfig_bus_open called.\n");
-	}
-
-        return(0);
-
-}
-
-/*
- * ioconfig_bus_close - Closes the special device node "/dev/hw/.ioconfig_bus".
- */
-static int ioconfig_bus_close(struct inode * inode, struct file * filp)
-{
-
-	if (ioconfig_bus_debug) {
-        	DBG("ioconfig_bus_close called.\n");
-	}
-
-        return(0);
-}
-
-struct file_operations ioconfig_bus_fops = {
-	.ioctl	= ioconfig_bus_ioctl,
-	.open	= ioconfig_bus_open,	/* open */
-	.release=ioconfig_bus_close	/* release */
-};
-
-
-/*
- * init_ifconfig_bus() - Boot time initialization.  Ensure that it is called 
- *	after hwgfs has been initialized.
- *
- */
-int init_ioconfig_bus(void)
-{
-	ioconfig_bus_handle = hwgraph_register(hwgraph_root, ".ioconfig_bus",
-		        0, 0,
-			0, 0,
-			S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
-			&ioconfig_bus_fops, NULL);
-
-	if (ioconfig_bus_handle == NULL) {
-		panic("Unable to create SGI PERSISTENT BUS NUMBERING Driver.\n");
-	}
-
-	return 0;
-}
-
-static int __init ioconfig_bus_setup (char *str)
-{
-
-	char *temp;
-
-	DBG("ioconfig_bus_setup: Kernel Options %s\n", str);
-
-	temp = (char *)ioconfig_kernopts;
-	memset(temp, 0, 128);
-	while ( (*str != '\0') && !isspace (*str) ) {
-		if (*str == ',') {
-			*temp = '\n';
-			temp++;
-			str++;
-			continue;
-		}
-		*temp = *str;
-		temp++;
-		str++;
-	}
-
-	return(0);
-		
-}
-__setup("ioconfig=", ioconfig_bus_setup);
diff -Nru a/arch/ia64/sn/io/hwgfs/Makefile b/arch/ia64/sn/io/hwgfs/Makefile
--- a/arch/ia64/sn/io/hwgfs/Makefile	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,10 +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) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# Makefile for the sn2 io routines.
-
-obj-y		+= hcl.o labelcl.o hcl_util.o ramfs.o interface.o
diff -Nru a/arch/ia64/sn/io/hwgfs/hcl.c b/arch/ia64/sn/io/hwgfs/hcl.c
--- a/arch/ia64/sn/io/hwgfs/hcl.c	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,702 +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.
- *
- *  hcl - SGI's Hardware Graph compatibility layer.
- *
- * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/config.h>
-#include <linux/slab.h>
-#include <linux/ctype.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/string.h>
-#include <linux/sched.h>                /* needed for smp_lock.h :( */
-#include <linux/smp_lock.h>
-#include <asm/sn/sgi.h>
-#include <asm/io.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hwgfs.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/simulator.h>
-
-#define vertex_hdl_t hwgfs_handle_t
-
-vertex_hdl_t hwgraph_root;
-vertex_hdl_t linux_busnum;
-extern int pci_bus_cvlink_init(void);
-unsigned long hwgraph_debug_mask;
-
-/*
- * init_hcl() - Boot time initialization.
- *
- */
-int __init init_hcl(void)
-{
-	extern void string_table_init(struct string_table *);
-	extern struct string_table label_string_table;
-	extern int init_ioconfig_bus(void);
-	extern int init_hwgfs_fs(void);
-	int rv = 0;
-
-	init_hwgfs_fs();
-
-	/*
-	 * Create the hwgraph_root.
-	 */
-	rv = hwgraph_path_add(NULL, EDGE_LBL_HW, &hwgraph_root);
-	if (rv) {
-		printk("init_hcl: Failed to create hwgraph_root.\n");
-		return -1;
-	}
-
-	/*
-	 * Initialize the HCL string table.
-	 */
-
-	string_table_init(&label_string_table);
-
-	/*
-	 * Create the directory that links Linux bus numbers to our Xwidget.
-	 */
-	rv = hwgraph_path_add(hwgraph_root, EDGE_LBL_LINUX_BUS, &linux_busnum);
-	if (linux_busnum == NULL) {
-		printk("HCL: Unable to create %s\n", EDGE_LBL_LINUX_BUS);
-		return -1;
-	}
-
-	if (pci_bus_cvlink_init() < 0 ) {
-		printk("init_hcl: Failed to create pcibus cvlink.\n");
-		return -1;
-	}
-
-	/*
-	 * Persistent Naming.
-	 */
-	init_ioconfig_bus();
-
-	return 0;
-}
-
-/*
- * Get device specific "fast information".
- *
- */
-arbitrary_info_t
-hwgraph_fastinfo_get(vertex_hdl_t de)
-{
-	arbitrary_info_t fastinfo;
-	int rv;
-
-	if (!de) {
-		printk(KERN_WARNING "HCL: hwgraph_fastinfo_get handle given is NULL.\n");
-		dump_stack();
-		return(-1);
-	}
-
-	rv = labelcl_info_get_IDX(de, HWGRAPH_FASTINFO, &fastinfo);
-	if (rv == 0)
-		return(fastinfo);
-
-	return(0);
-}
-
-
-/*
- * hwgraph_connectpt_get: Returns the entry's connect point.
- *
- */
-vertex_hdl_t
-hwgraph_connectpt_get(vertex_hdl_t de)
-{
-	int rv;
-	arbitrary_info_t info;
-	vertex_hdl_t connect;
-
-	rv = labelcl_info_get_IDX(de, HWGRAPH_CONNECTPT, &info);
-	if (rv != 0) {
-		return(NULL);
-	}
-
-	connect = (vertex_hdl_t)info;
-	return(connect);
-
-}
-
-
-/*
- * hwgraph_mk_dir - Creates a directory entry.
- */
-vertex_hdl_t
-hwgraph_mk_dir(vertex_hdl_t de, const char *name,
-                unsigned int namelen, void *info)
-{
-
-	int rv;
-	labelcl_info_t *labelcl_info = NULL;
-	vertex_hdl_t new_handle = NULL;
-	vertex_hdl_t parent = NULL;
-
-	/*
-	 * Create the device info structure for hwgraph compatiblity support.
-	 */
-	labelcl_info = labelcl_info_create();
-	if (!labelcl_info)
-		return(NULL);
-
-	/*
-	 * Create an entry.
-	 */
-	new_handle = hwgfs_mk_dir(de, name, (void *)labelcl_info);
-	if (!new_handle) {
-		labelcl_info_destroy(labelcl_info);
-		return(NULL);
-	}
-
-	/*
-	 * Get the parent handle.
-	 */
-	parent = hwgfs_get_parent (new_handle);
-
-	/*
-	 * To provide the same semantics as the hwgraph, set the connect point.
-	 */
-	rv = hwgraph_connectpt_set(new_handle, parent);
-	if (!rv) {
-		/*
-		 * We need to clean up!
-		 */
-	}
-
-	/*
-	 * If the caller provides a private data pointer, save it in the 
-	 * labelcl info structure(fastinfo).  This can be retrieved via
-	 * hwgraph_fastinfo_get()
-	 */
-	if (info)
-		hwgraph_fastinfo_set(new_handle, (arbitrary_info_t)info);
-		
-	return(new_handle);
-
-}
-
-/*
- * hwgraph_path_add - Create a directory node with the given path starting 
- * from the given fromv.
- */
-int
-hwgraph_path_add(vertex_hdl_t  fromv,
-		 char *path,
-		 vertex_hdl_t *new_de)
-{
-
-	unsigned int	namelen = strlen(path);
-	int		rv;
-
-	/*
-	 * We need to handle the case when fromv is NULL ..
-	 * in this case we need to create the path from the 
-	 * hwgraph root!
-	 */
-	if (fromv == NULL)
-		fromv = hwgraph_root;
-
-	/*
-	 * check the entry doesn't already exist, if it does
-	 * then we simply want new_de to point to it (otherwise
-	 * we'll overwrite the existing labelcl_info struct)
-	 */
-	rv = hwgraph_edge_get(fromv, path, new_de);
-	if (rv)	{	/* couldn't find entry so we create it */
-		*new_de = hwgraph_mk_dir(fromv, path, namelen, NULL);
-		if (new_de == NULL)
-			return(-1);
-		else
-			return(0);
-	}
-	else 
- 		return(0);
-
-}
-
-/*
- * hwgraph_register  - Creates a special device file.
- *
- */
-vertex_hdl_t
-hwgraph_register(vertex_hdl_t de, const char *name,
-                unsigned int namelen, unsigned int flags, 
-		unsigned int major, unsigned int minor,
-                umode_t mode, uid_t uid, gid_t gid, 
-		struct file_operations *fops,
-                void *info)
-{
-
-        vertex_hdl_t new_handle = NULL;
-
-        /*
-         * Create an entry.
-         */
-        new_handle = hwgfs_register(de, name, flags, major,
-				minor, mode, fops, info);
-
-        return(new_handle);
-
-}
-
-
-/*
- * hwgraph_mk_symlink - Create a symbolic link.
- */
-int
-hwgraph_mk_symlink(vertex_hdl_t de, const char *name, unsigned int namelen,
-                unsigned int flags, const char *link, unsigned int linklen, 
-		vertex_hdl_t *handle, void *info)
-{
-
-	void *labelcl_info = NULL;
-	int status = 0;
-	vertex_hdl_t new_handle = NULL;
-
-	/*
-	 * Create the labelcl info structure for hwgraph compatiblity support.
-	 */
-	labelcl_info = labelcl_info_create();
-	if (!labelcl_info)
-		return(-1);
-
-	/*
-	 * Create a symbolic link.
-	 */
-	status = hwgfs_mk_symlink(de, name, flags, link,
-				&new_handle, labelcl_info);
-	if ( (!new_handle) || (!status) ){
-		labelcl_info_destroy((labelcl_info_t *)labelcl_info);
-		return(-1);
-	}
-
-	/*
-	 * If the caller provides a private data pointer, save it in the 
-	 * labelcl info structure(fastinfo).  This can be retrieved via
-	 * hwgraph_fastinfo_get()
-	 */
-	if (info)
-		hwgraph_fastinfo_set(new_handle, (arbitrary_info_t)info);
-
-	*handle = new_handle;
-	return(0);
-
-}
-
-/*
- * hwgraph_vertex_destroy - Destroy the entry
- */
-int
-hwgraph_vertex_destroy(vertex_hdl_t de)
-{
-
-	void *labelcl_info = NULL;
-
-	labelcl_info = hwgfs_get_info(de);
-	hwgfs_unregister(de);
-
-	if (labelcl_info)
-		labelcl_info_destroy((labelcl_info_t *)labelcl_info);
-
-	return(0);
-}
-
-int
-hwgraph_edge_add(vertex_hdl_t from, vertex_hdl_t to, char *name)
-{
-
-	char *path, *link;
-	char *s1;
-	char *index;
-	vertex_hdl_t handle = NULL;
-	int rv;
-	int i, count;
-
-	path = kmalloc(1024, GFP_KERNEL);
-	if (!path)
-		return -ENOMEM;
-	memset((char *)path, 0x0, 1024);
-	link = kmalloc(1024, GFP_KERNEL);
-	if (!link) {
-		kfree(path);
-		return -ENOMEM;
-	}
-	memset((char *)link, 0x0, 1024);
-
-	i = hwgfs_generate_path (from, path, 1024);
-	s1 = (char *)path;
-	count = 0;
-	while (1) {
-		index = strstr (s1, "/");
-		if (index) {
-			count++;
-			s1 = ++index;
-		} else {
-			count++;
-			break;
-		}
-	}
-
-	for (i = 0; i < count; i++) {
-		strcat((char *)link,"../");
-	}
-
-	memset(path, 0x0, 1024);
-	i = hwgfs_generate_path (to, path, 1024);
-	strcat((char *)link, (char *)path);
-
-	/*
-	 * Otherwise, just create a symlink to the vertex.
-	 * In this case the vertex was previous created with a REAL pathname.
-	 */
-	rv = hwgfs_mk_symlink (from, (const char *)name,
-			       0, link,
-			       &handle, NULL);
-	kfree(path);
-	kfree(link);
-
-	return(rv);
-
-
-}
-
-/* ARGSUSED */
-int
-hwgraph_edge_get(vertex_hdl_t from, char *name, vertex_hdl_t *toptr)
-{
-
-	vertex_hdl_t target_handle = NULL;
-
-	if (name == NULL)
-		return(-1);
-
-	if (toptr == NULL)
-		return(-1);
-
-	/*
-	 * If the name is "." just return the current entry handle.
-	 */
-	if (!strcmp(name, HWGRAPH_EDGELBL_DOT)) {
-		if (toptr) {
-			*toptr = from;
-		}
-	} else if (!strcmp(name, HWGRAPH_EDGELBL_DOTDOT)) {
-		/*
-		 * Hmmm .. should we return the connect point or parent ..
-		 * see in hwgraph, the concept of parent is the connectpt!
-		 *
-		 * Maybe we should see whether the connectpt is set .. if 
-		 * not just return the parent!
-		 */
-		target_handle = hwgraph_connectpt_get(from);
-		if (target_handle) {
-			/*
-			 * Just return the connect point.
-			 */
-			*toptr = target_handle;
-			return(0);
-		}
-		target_handle = hwgfs_get_parent(from);
-		*toptr = target_handle;
-
-	} else {
-		target_handle = hwgfs_find_handle (from, name, 0, 0,
-					0, 1); /* Yes traverse symbolic links */
-	}
-
-	if (target_handle == NULL)
-		return(-1);
-	else
-	 *toptr = target_handle;
-
-	return(0);
-}
-
-/*
- * hwgraph_info_add_LBL - Adds a new label for the device.  Mark the info_desc
- *	of the label as INFO_DESC_PRIVATE and store the info in the label.
- */
-/* ARGSUSED */
-int
-hwgraph_info_add_LBL( vertex_hdl_t de,
-			char *name,
-			arbitrary_info_t info)
-{
-	return(labelcl_info_add_LBL(de, name, INFO_DESC_PRIVATE, info));
-}
-
-/*
- * hwgraph_info_remove_LBL - Remove the label entry for the device.
- */
-/* ARGSUSED */
-int
-hwgraph_info_remove_LBL( vertex_hdl_t de,
-				char *name,
-				arbitrary_info_t *old_info)
-{
-	return(labelcl_info_remove_LBL(de, name, NULL, old_info));
-}
-
-/*
- * hwgraph_info_replace_LBL - replaces an existing label with 
- *	a new label info value.
- */
-/* ARGSUSED */
-int
-hwgraph_info_replace_LBL( vertex_hdl_t de,
-				char *name,
-				arbitrary_info_t info,
-				arbitrary_info_t *old_info)
-{
-	return(labelcl_info_replace_LBL(de, name,
-			INFO_DESC_PRIVATE, info,
-			NULL, old_info));
-}
-/*
- * hwgraph_info_get_LBL - Get and return the info value in the label of the 
- * 	device.
- */
-/* ARGSUSED */
-int
-hwgraph_info_get_LBL(vertex_hdl_t de,
-			char *name,
-			arbitrary_info_t *infop)
-{
-	return(labelcl_info_get_LBL(de, name, NULL, infop));
-}
-
-/*
- * hwgraph_info_get_exported_LBL - Retrieve the info_desc and info pointer 
- *	of the given label for the device.  The weird thing is that the label 
- *	that matches the name is return irrespective of the info_desc value!
- *	Do not understand why the word "exported" is used!
- */
-/* ARGSUSED */
-int
-hwgraph_info_get_exported_LBL(vertex_hdl_t de,
-				char *name,
-				int *export_info,
-				arbitrary_info_t *infop)
-{
-	int rc;
-	arb_info_desc_t info_desc;
-
-	rc = labelcl_info_get_LBL(de, name, &info_desc, infop);
-	if (rc == 0)
-		*export_info = (int)info_desc;
-
-	return(rc);
-}
-
-/*
- * hwgraph_info_get_next_LBL - Returns the next label info given the 
- *	current label entry in place.
- *
- *	Once again this has no locking or reference count for protection.
- *
- */
-/* ARGSUSED */
-int
-hwgraph_info_get_next_LBL(vertex_hdl_t de,
-				char *buf,
-				arbitrary_info_t *infop,
-				labelcl_info_place_t *place)
-{
-	return(labelcl_info_get_next_LBL(de, buf, NULL, infop, place));
-}
-
-/*
- * hwgraph_info_export_LBL - Retrieve the specified label entry and modify 
- *	the info_desc field with the given value in nbytes.
- */
-/* ARGSUSED */
-int
-hwgraph_info_export_LBL(vertex_hdl_t de, char *name, int nbytes)
-{
-	arbitrary_info_t info;
-	int rc;
-
-	if (nbytes == 0)
-		nbytes = INFO_DESC_EXPORT;
-
-	if (nbytes < 0)
-		return(-1);
-
-	rc = labelcl_info_get_LBL(de, name, NULL, &info);
-	if (rc != 0)
-		return(rc);
-
-	rc = labelcl_info_replace_LBL(de, name,
-				nbytes, info, NULL, NULL);
-
-	return(rc);
-}
-
-/*
- * hwgraph_info_unexport_LBL - Retrieve the given label entry and change the 
- * label info_descr filed to INFO_DESC_PRIVATE.
- */
-/* ARGSUSED */
-int
-hwgraph_info_unexport_LBL(vertex_hdl_t de, char *name)
-{
-	arbitrary_info_t info;
-	int rc;
-
-	rc = labelcl_info_get_LBL(de, name, NULL, &info);
-	if (rc != 0)
-		return(rc);
-
-	rc = labelcl_info_replace_LBL(de, name,
-				INFO_DESC_PRIVATE, info, NULL, NULL);
-
-	return(rc);
-}
-
-/*
- * hwgraph_traverse - Find and return the handle starting from de.
- *
- */
-graph_error_t
-hwgraph_traverse(vertex_hdl_t de, char *path, vertex_hdl_t *found)
-{
-	/* 
-	 * get the directory entry (path should end in a directory)
-	 */
-
-	*found = hwgfs_find_handle(de,	/* start dir */
-			    path,	/* path */
-			    0,		/* major */
-			    0,		/* minor */
-			    0,		/* char | block */
-			    1);		/* traverse symlinks */
-	if (*found == NULL)
-		return(GRAPH_NOT_FOUND);
-	else
-		return(GRAPH_SUCCESS);
-}
-
-/*
- * Find the canonical name for a given vertex by walking back through
- * connectpt's until we hit the hwgraph root vertex (or until we run
- * out of buffer space or until something goes wrong).
- *
- *	COMPATIBILITY FUNCTIONALITY
- * Walks back through 'parents', not necessarily the same as connectpts.
- *
- * Need to resolve the fact that does not return the path from 
- * "/" but rather it just stops right before /dev ..
- */
-int
-hwgraph_vertex_name_get(vertex_hdl_t vhdl, char *buf, unsigned int buflen)
-{
-	char *locbuf;
-	int   pos;
-
-	if (buflen < 1)
-		return(-1);	/* XXX should be GRAPH_BAD_PARAM ? */
-
-	locbuf = kmalloc(buflen, GFP_KERNEL);
-
-	pos = hwgfs_generate_path(vhdl, locbuf, buflen);
-	if (pos < 0) {
-		kfree(locbuf);
-		return pos;
-	}
-
-	strcpy(buf, &locbuf[pos]);
-	kfree(locbuf);
-	return 0;
-}
-
-/*
-** vertex_to_name converts a vertex into a canonical name by walking
-** back through connect points until we hit the hwgraph root (or until
-** we run out of buffer space).
-**
-** Usually returns a pointer to the original buffer, filled in as
-** appropriate.  If the buffer is too small to hold the entire name,
-** or if anything goes wrong while determining the name, vertex_to_name
-** returns "UnknownDevice".
-*/
-
-#define DEVNAME_UNKNOWN "UnknownDevice"
-
-char *
-vertex_to_name(vertex_hdl_t vhdl, char *buf, unsigned int buflen)
-{
-        if (hwgraph_vertex_name_get(vhdl, buf, buflen) == GRAPH_SUCCESS)
-                return(buf);
-        else
-                return(DEVNAME_UNKNOWN);
-}
-
-
-void
-hwgraph_debug(char *file, const char * function, int line, vertex_hdl_t vhdl1, vertex_hdl_t vhdl2, char *format, ...)
-{
-
-	int pos;
-	char *hwpath;
-	va_list ap;
-
-	if ( !hwgraph_debug_mask )
-		return;
-
-	hwpath = kmalloc(MAXDEVNAME, GFP_KERNEL);
-	if (!hwpath) {
-		printk("HWGRAPH_DEBUG kmalloc fails at %d ", __LINE__);
-		return;
-	}
-
-	printk("HWGRAPH_DEBUG %s %s %d : ", file, function, line);
-
-	if (vhdl1){
-		memset(hwpath, 0, MAXDEVNAME);
-		pos = hwgfs_generate_path(vhdl1, hwpath, MAXDEVNAME);
-		printk("vhdl1 = %s : ", &hwpath[pos]);
-	}
-
-	if (vhdl2){
-		memset(hwpath, 0, MAXDEVNAME);
-		pos = hwgfs_generate_path(vhdl2, hwpath, MAXDEVNAME);
-		printk("vhdl2 = %s :", &hwpath[pos]);
-	}
-
-	memset(hwpath, 0, MAXDEVNAME);
-        va_start(ap, format);
-        vsnprintf(hwpath, 500, format, ap);
-        va_end(ap);
-	hwpath[MAXDEVNAME -1] = (char)0; /* Just in case. */
-        printk(" %s", hwpath);
-	kfree(hwpath);
-}
-
-EXPORT_SYMBOL(hwgraph_mk_dir);
-EXPORT_SYMBOL(hwgraph_path_add);
-EXPORT_SYMBOL(hwgraph_register);
-EXPORT_SYMBOL(hwgraph_vertex_destroy);
-EXPORT_SYMBOL(hwgraph_fastinfo_get);
-EXPORT_SYMBOL(hwgraph_connectpt_get);
-EXPORT_SYMBOL(hwgraph_info_add_LBL);
-EXPORT_SYMBOL(hwgraph_info_remove_LBL);
-EXPORT_SYMBOL(hwgraph_info_replace_LBL);
-EXPORT_SYMBOL(hwgraph_info_get_LBL);
-EXPORT_SYMBOL(hwgraph_info_get_exported_LBL);
-EXPORT_SYMBOL(hwgraph_info_get_next_LBL);
-EXPORT_SYMBOL(hwgraph_info_export_LBL);
-EXPORT_SYMBOL(hwgraph_info_unexport_LBL);
-EXPORT_SYMBOL(hwgraph_traverse);
-EXPORT_SYMBOL(hwgraph_vertex_name_get);
diff -Nru a/arch/ia64/sn/io/hwgfs/hcl_util.c b/arch/ia64/sn/io/hwgfs/hcl_util.c
--- a/arch/ia64/sn/io/hwgfs/hcl_util.c	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,175 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <asm/sn/sgi.h>
-#include <asm/io.h>
-#include <asm/sn/io.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hwgfs.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/nodepda.h>
-
-static vertex_hdl_t hwgraph_all_cnodes = GRAPH_VERTEX_NONE;
-extern vertex_hdl_t hwgraph_root;
-static vertex_hdl_t hwgraph_all_cpuids = GRAPH_VERTEX_NONE;
-extern int maxcpus;
-
-void
-mark_cpuvertex_as_cpu(vertex_hdl_t vhdl, cpuid_t cpuid)
-{
-	char cpuid_buffer[10];
-
-	if (cpuid == CPU_NONE)
-		return;
-
-	if (hwgraph_all_cpuids == GRAPH_VERTEX_NONE) {
-		(void)hwgraph_path_add( hwgraph_root,
-					EDGE_LBL_CPUNUM,
-					&hwgraph_all_cpuids);
-	}
-
-	sprintf(cpuid_buffer, "%ld", cpuid);
-	(void)hwgraph_edge_add( hwgraph_all_cpuids, vhdl, cpuid_buffer);
-}
-
-/*
-** Return the "master" for a given vertex.  A master vertex is a
-** controller or adapter or other piece of hardware that the given
-** vertex passes through on the way to the rest of the system.
-*/
-vertex_hdl_t
-device_master_get(vertex_hdl_t vhdl)
-{
-	graph_error_t rc;
-	vertex_hdl_t master;
-
-	rc = hwgraph_edge_get(vhdl, EDGE_LBL_MASTER, &master);
-	if (rc == GRAPH_SUCCESS)
-		return(master);
-	else
-		return(GRAPH_VERTEX_NONE);
-}
-
-/*
-** Set the master for a given vertex.
-** Returns 0 on success, non-0 indicates failure
-*/
-int
-device_master_set(vertex_hdl_t vhdl, vertex_hdl_t master)
-{
-	graph_error_t rc;
-
-	rc = hwgraph_edge_add(vhdl, master, EDGE_LBL_MASTER);
-	return(rc != GRAPH_SUCCESS);
-}
-
-
-/*
-** Return the compact node id of the node that ultimately "owns" the specified
-** vertex.  In order to do this, we walk back through masters and connect points
-** until we reach a vertex that represents a node.
-*/
-cnodeid_t
-master_node_get(vertex_hdl_t vhdl)
-{
-	cnodeid_t cnodeid;
-	vertex_hdl_t master;
-
-	for (;;) {
-		cnodeid = nodevertex_to_cnodeid(vhdl);
-		if (cnodeid != CNODEID_NONE)
-			return(cnodeid);
-
-		master = device_master_get(vhdl);
-
-		/* Check for exceptional cases */
-		if (master == vhdl) {
-			/* Since we got a reference to the "master" thru
-			 * device_master_get() we should decrement
-			 * its reference count by 1
-			 */
-			return(CNODEID_NONE);
-		}
-
-		if (master == GRAPH_VERTEX_NONE) {
-			master = hwgraph_connectpt_get(vhdl);
-			if ((master == GRAPH_VERTEX_NONE) ||
-			    (master == vhdl)) {
-				return(CNODEID_NONE);
-			}
-		}
-
-		vhdl = master;
-	}
-}
-
-
-/*
-** If the specified device represents a node, return its
-** compact node ID; otherwise, return CNODEID_NONE.
-*/
-cnodeid_t
-nodevertex_to_cnodeid(vertex_hdl_t vhdl)
-{
-	int rv = 0;
-	arbitrary_info_t cnodeid = CNODEID_NONE;
-
-	rv = labelcl_info_get_LBL(vhdl, INFO_LBL_CNODEID, NULL, &cnodeid);
-
-	return((cnodeid_t)cnodeid);
-}
-
-void
-mark_nodevertex_as_node(vertex_hdl_t vhdl, cnodeid_t cnodeid)
-{
-	if (cnodeid == CNODEID_NONE)
-		return;
-
-	cnodeid_to_vertex(cnodeid) = vhdl;
-	labelcl_info_add_LBL(vhdl, INFO_LBL_CNODEID, INFO_DESC_EXPORT, 
-		(arbitrary_info_t)cnodeid);
-
-	{
-		char cnodeid_buffer[10];
-
-		if (hwgraph_all_cnodes == GRAPH_VERTEX_NONE) {
-			(void)hwgraph_path_add( hwgraph_root,
-						EDGE_LBL_NODENUM,
-						&hwgraph_all_cnodes);
-		}
-
-		sprintf(cnodeid_buffer, "%d", cnodeid);
-		(void)hwgraph_edge_add( hwgraph_all_cnodes,
-					vhdl,
-					cnodeid_buffer);
-		HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, hwgraph_all_cnodes, NULL, "Creating path vhdl1\n");
-	}
-}
-
-/*
-** dev_to_name converts a vertex_hdl_t into a canonical name.  If the vertex_hdl_t
-** represents a vertex in the hardware graph, it is converted in the
-** normal way for vertices.  If the vertex_hdl_t is an old vertex_hdl_t (one which
-** does not represent a hwgraph vertex), we synthesize a name based
-** on major/minor number.
-**
-** Usually returns a pointer to the original buffer, filled in as
-** appropriate.  If the buffer is too small to hold the entire name,
-** or if anything goes wrong while determining the name, dev_to_name
-** returns "UnknownDevice".
-*/
-char *
-dev_to_name(vertex_hdl_t dev, char *buf, uint buflen)
-{
-        return(vertex_to_name(dev, buf, buflen));
-}
-
diff -Nru a/arch/ia64/sn/io/hwgfs/interface.c b/arch/ia64/sn/io/hwgfs/interface.c
--- a/arch/ia64/sn/io/hwgfs/interface.c	2004-12-24 13:37:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,325 +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) 2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- *  Portions based on Adam Richter's smalldevfs and thus
- *  Copyright 2002-2003  Yggdrasil Computing, Inc.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/mount.h>
-#include <linux/namei.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <asm/sn/hwgfs.h>
-
-
-extern struct vfsmount *hwgfs_vfsmount;
-
-static int
-walk_parents_mkdir(
-	const char		**path,
-	struct nameidata	*nd,
-	int			is_dir)
-{
-	char			*slash;
-	char			buf[strlen(*path)+1];
-	int			error;
-
-	while ((slash = strchr(*path, '/')) != NULL) {
-		int len = slash - *path;
-		memcpy(buf, *path, len);
-		buf[len] = '\0';
-
-		error = path_walk(buf, nd);
-		if (unlikely(error))
-			return error;
-
-		nd->dentry = lookup_create(nd, is_dir);
-		nd->flags |= LOOKUP_PARENT;
-		if (IS_ERR(nd->dentry))
-			return PTR_ERR(nd->dentry);
-
-		if (!nd->dentry->d_inode)
-			error = vfs_mkdir(nd->dentry->d_parent->d_inode,
-					nd->dentry, 0755);
-		
-		up(&nd->dentry->d_parent->d_inode->i_sem);
-		if (unlikely(error))
-			return error;
-
-		*path += len + 1;
-	}
-
-	return 0;
-}
-
-/* On success, returns with parent_inode->i_sem taken. */
-static int
-hwgfs_decode(
-	hwgfs_handle_t		dir,
-	const char		*name,
-	int			is_dir,
-	struct inode		**parent_inode,
-	struct dentry		**dentry)
-{
-	struct nameidata	nd;
-	int			error;
-
-	if (!dir)
-		dir = hwgfs_vfsmount->mnt_sb->s_root;
-
-	memset(&nd, 0, sizeof(nd));
-	nd.flags = LOOKUP_PARENT;
-	nd.mnt = mntget(hwgfs_vfsmount);
-	nd.dentry = dget(dir);
-
-	error = walk_parents_mkdir(&name, &nd, is_dir);
-	if (unlikely(error))
-		return error;
-
-	error = path_walk(name, &nd);
-	if (unlikely(error))
-		return error;
-
-	*dentry = lookup_create(&nd, is_dir);
-
-	if (IS_ERR(*dentry))
-		return PTR_ERR(*dentry);
-	*parent_inode = (*dentry)->d_parent->d_inode;
-	return 0;
-}
-
-static int
-path_len(
-	struct dentry		*de,
-	struct dentry		*root)
-{
-	int			len = 0;
-
-	while (de != root) {
-		len += de->d_name.len + 1;	/* count the '/' */
-		de = de->d_parent;
-	}
-	return len;		/* -1 because we omit the leading '/',
-				   +1 because we include trailing '\0' */
-}
-
-int
-hwgfs_generate_path(
-	hwgfs_handle_t		de,
-	char			*path,
-	int			buflen)
-{
-	struct dentry		*hwgfs_root;
-	int			len;
-	char			*path_orig = path;
-
-	if (unlikely(de == NULL))
-		return -EINVAL;
-
-	hwgfs_root = hwgfs_vfsmount->mnt_sb->s_root;
-	if (unlikely(de == hwgfs_root))
-		return -EINVAL;
-
-	spin_lock(&dcache_lock);
-	len = path_len(de, hwgfs_root);
-	if (len > buflen) {
-		spin_unlock(&dcache_lock);
-		return -ENAMETOOLONG;
-	}
-
-	path += len - 1;
-	*path = '\0';
-
-	for (;;) {
-		path -= de->d_name.len;
-		memcpy(path, de->d_name.name, de->d_name.len);
-		de = de->d_parent;
-		if (de == hwgfs_root)
-			break;
-		*(--path) = '/';
-	}
-		
-	spin_unlock(&dcache_lock);
-	BUG_ON(path != path_orig);
-	return 0;
-}
-
-hwgfs_handle_t
-hwgfs_register(
-	hwgfs_handle_t		dir,
-	const char		*name,
-	unsigned int		flags,
-	unsigned int		major,
-	unsigned int		minor,
-	umode_t			mode,
-	void			*ops,
-	void			*info)
-{
-	dev_t			devnum = MKDEV(major, minor);
-	struct inode		*parent_inode;
-	struct dentry		*dentry;
-	int			error;
-
-	error = hwgfs_decode(dir, name, 0, &parent_inode, &dentry);
-	if (likely(!error)) {
-		error = vfs_mknod(parent_inode, dentry, mode, devnum);
-		if (likely(!error)) {
-			/*
-			 * Do this inside parents i_sem to avoid racing
-			 * with lookups.
-			 */
-			if (S_ISCHR(mode))
-				dentry->d_inode->i_fop = ops;
-			dentry->d_fsdata = info;
-			up(&parent_inode->i_sem);
-		} else {
-			up(&parent_inode->i_sem);
-			dput(dentry);
-			dentry = NULL;
-                }
-	}
-
-	return dentry;
-}
-
-int
-hwgfs_mk_symlink(
-	hwgfs_handle_t		dir,
-	const char		*name,
-	unsigned int		flags,
-	const char		*link,
-	hwgfs_handle_t		*handle,
-	void			*info)
-{
-	struct inode		*parent_inode;
-	struct dentry		*dentry;
-	int			error;
-
-	error = hwgfs_decode(dir, name, 0, &parent_inode, &dentry);
-	if (likely(!error)) {
-		error = vfs_symlink(parent_inode, dentry, link, S_IALLUGO);
-		dentry->d_fsdata = info;
-		if (handle)
-			*handle = dentry;
-		up(&parent_inode->i_sem);
-		/* dput(dentry); */
-	}
-	return error;
-}
-
-hwgfs_handle_t
-hwgfs_mk_dir(
-	hwgfs_handle_t		dir,
-	const char		*name,
-	void			*info)
-{
-	struct inode		*parent_inode;
-	struct dentry		*dentry;
-	int			error;
-
-	error = hwgfs_decode(dir, name, 1, &parent_inode, &dentry);
-	if (likely(!error)) {
-		error = vfs_mkdir(parent_inode, dentry, 0755);
-		up(&parent_inode->i_sem);
-
-		if (unlikely(error)) {
-			dput(dentry);
-			dentry = NULL;
-		} else {
-			dentry->d_fsdata = info;
-		}
-	}
-	return dentry;
-}
-
-void
-hwgfs_unregister(
-	hwgfs_handle_t		de)
-{
-	struct inode		*parent_inode = de->d_parent->d_inode;
-
-	if (S_ISDIR(de->d_inode->i_mode))
-		vfs_rmdir(parent_inode, de);
-	else
-		vfs_unlink(parent_inode, de);
-}
-
-/* XXX: this function is utterly bogus.  Every use of it is racy and the
-        prototype is stupid.  You have been warned.  --hch.  */
-hwgfs_handle_t
-hwgfs_find_handle(
-	hwgfs_handle_t		base,
-	const char		*name,
-	unsigned int		major,		/* IGNORED */
-	unsigned int		minor,		/* IGNORED */
-	char			type,		/* IGNORED */
-	int			traverse_symlinks)
-{
-	struct dentry		*dentry = NULL;
-	struct nameidata	nd;
-	int			error;
-
-	BUG_ON(*name=='/');
-
-	memset(&nd, 0, sizeof(nd));
-
-	nd.mnt = mntget(hwgfs_vfsmount);
-	nd.dentry = dget(base ? base : hwgfs_vfsmount->mnt_sb->s_root);
-	nd.flags = (traverse_symlinks ? LOOKUP_FOLLOW : 0);
-
-	error = path_walk(name, &nd);
-	if (likely(!error)) {
-		dentry = nd.dentry;
-		path_release(&nd);		/* stale data from here! */
-	}
-
-	return dentry;
-}
-
-hwgfs_handle_t
-hwgfs_get_parent(
-	hwgfs_handle_t		de)
-{
-	struct dentry		*parent;
-
-	spin_lock(&de->d_lock);
-	parent = de->d_parent;
-	spin_unlock(&de->d_lock);
-
-	return parent;
-}
-
-int
-hwgfs_set_info(
-	hwgfs_handle_t		de,
-	void			*info)
-{
-	if (unlikely(de == NULL))
-		return -EINVAL;
-	de->d_fsdata = info;
-	return 0;
-}
-
-void *
-hwgfs_get_info(
-	hwgfs_handle_t		de)
-{
-	return de->d_fsdata;
-}
-
-EXPORT_SYMBOL(hwgfs_generate_path);
-EXPORT_SYMBOL(hwgfs_register);
-EXPORT_SYMBOL(hwgfs_unregister);
-EXPORT_SYMBOL(hwgfs_mk_symlink);
-EXPORT_SYMBOL(hwgfs_mk_dir);
-EXPORT_SYMBOL(hwgfs_find_handle);
-EXPORT_SYMBOL(hwgfs_get_parent);
-EXPORT_SYMBOL(hwgfs_set_info);
-EXPORT_SYMBOL(hwgfs_get_info);
diff -Nru a/arch/ia64/sn/io/hwgfs/labelcl.c b/arch/ia64/sn/io/hwgfs/labelcl.c
--- a/arch/ia64/sn/io/hwgfs/labelcl.c	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,656 +0,0 @@
-/*  labelcl - SGI's Hwgraph Compatibility Layer.
- *
- * 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-2003 Silicon Graphics, Inc.  All rights reserved.
-*/
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/string.h>
-#include <linux/sched.h>                /* needed for smp_lock.h :( */
-#include <linux/smp_lock.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/hwgfs.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-
-/*
-** Very simple and dumb string table that supports only find/insert.
-** In practice, if this table gets too large, we may need a more
-** efficient data structure.   Also note that currently there is no 
-** way to delete an item once it's added.  Therefore, name collision 
-** will return an error.
-*/
-
-struct string_table label_string_table;
-
-
-
-/*
- * string_table_init - Initialize the given string table.
- */
-void
-string_table_init(struct string_table *string_table)
-{
-	string_table->string_table_head = NULL;
-	string_table->string_table_generation = 0;
-
-	/*
-	 * We nedd to initialize locks here!
-	 */
-
-	return;
-}
-
-
-/*
- * string_table_destroy - Destroy the given string table.
- */
-void
-string_table_destroy(struct string_table *string_table)
-{
-	struct string_table_item *item, *next_item;
-
-	item = string_table->string_table_head;
-	while (item) {
-		next_item = item->next;
-
-		STRTBL_FREE(item);
-		item = next_item;
-	}
-
-	/*
-	 * We need to destroy whatever lock we have here
-	 */
-
-	return;
-}
-
-
-
-/*
- * string_table_insert - Insert an entry in the string table .. duplicate 
- *	names are not allowed.
- */
-char *
-string_table_insert(struct string_table *string_table, char *name)
-{
-	struct string_table_item *item, *new_item = NULL, *last_item = NULL;
-
-again:
-	/*
-	 * Need to lock the table ..
-	 */
-	item = string_table->string_table_head;
-	last_item = NULL;
-
-	while (item) {
-		if (!strcmp(item->string, name)) {
-			/*
-			 * If we allocated space for the string and the found that
-			 * someone else already entered it into the string table,
-			 * free the space we just allocated.
-			 */
-			if (new_item)
-				STRTBL_FREE(new_item);
-
-
-			/*
-			 * Search optimization: move the found item to the head
-			 * of the list.
-			 */
-			if (last_item != NULL) {
-				last_item->next = item->next;
-				item->next = string_table->string_table_head;
-				string_table->string_table_head = item;
-			}
-			goto out;
-		}
-		last_item = item;
-		item=item->next;
-	}
-
-	/*
-	 * name was not found, so add it to the string table.
-	 */
-	if (new_item == NULL) {
-		long old_generation = string_table->string_table_generation;
-
-		new_item = STRTBL_ALLOC(strlen(name));
-
-		strcpy(new_item->string, name);
-
-		/*
-		 * While we allocated memory for the new string, someone else 
-		 * changed the string table.
-		 */
-		if (old_generation != string_table->string_table_generation) {
-			goto again;
-		}
-	} else {
-		/* At this we only have the string table lock in access mode.
-		 * Promote the access lock to an update lock for the string
-		 * table insertion below.
-		 */
-			long old_generation = 
-				string_table->string_table_generation;
-
-			/*
-			 * After we did the unlock and wer waiting for update
-			 * lock someone could have potentially updated
-			 * the string table. Check the generation number
-			 * for this case. If it is the case we have to
-			 * try all over again.
-			 */
-			if (old_generation != 
-			    string_table->string_table_generation) {
-				goto again;
-			}
-		}
-
-	/*
-	 * At this point, we're committed to adding new_item to the string table.
-	 */
-	new_item->next = string_table->string_table_head;
-	item = string_table->string_table_head = new_item;
-	string_table->string_table_generation++;
-
-out:
-	/*
-	 * Need to unlock here.
-	 */
-	return(item->string);
-}
-
-/*
- * labelcl_info_create - Creates the data structure that will hold the
- *	device private information asscoiated with a entry.
- *	The pointer to this structure is what gets stored in the 
- *	(void * info).
- */
-labelcl_info_t *
-labelcl_info_create()
-{
-
-	labelcl_info_t *new = NULL;
-
-	/* Initial allocation does not include any area for labels */
-	if ( ( new = (labelcl_info_t *)kmalloc (sizeof(labelcl_info_t), GFP_KERNEL) ) == NULL )
-		return NULL;
-
-	memset (new, 0, sizeof(labelcl_info_t));
-	new->hwcl_magic = LABELCL_MAGIC;
-	return( new);
-
-}
-
-/*
- * labelcl_info_destroy - Frees the data structure that holds the
- *      device private information asscoiated with a entry.  This 
- *	data structure was created by device_info_create().
- *
- *	The caller is responsible for nulling the (void *info) in the 
- *	corresponding entry.
- */
-int
-labelcl_info_destroy(labelcl_info_t *labelcl_info)
-{
-
-	if (labelcl_info == NULL)
-		return(0);
-
-	/* Free the label list */
-	if (labelcl_info->label_list)
-		kfree(labelcl_info->label_list);
-
-	/* Now free the label info area */
-	labelcl_info->hwcl_magic = 0;
-	kfree(labelcl_info);
-
-	return(0);
-}
-
-/*
- * labelcl_info_add_LBL - Adds a new label entry in the labelcl info 
- *	structure.
- *
- *	Error is returned if we find another label with the same name.
- */
-int
-labelcl_info_add_LBL(vertex_hdl_t de,
-			char *info_name,
-			arb_info_desc_t info_desc,
-			arbitrary_info_t info)
-{
-	labelcl_info_t	*labelcl_info = NULL;
-	int num_labels;
-	int new_label_list_size;
-	label_info_t *old_label_list, *new_label_list = NULL;
-	char *name;
-	int i;
-
-	if (de == NULL)
-		return(-1);
-
-        labelcl_info = hwgfs_get_info(de);
-	if (labelcl_info == NULL)
-		return(-1);
-
-	if (labelcl_info->hwcl_magic != LABELCL_MAGIC)
-		return(-1);
-
-	if (info_name == NULL)
-		return(-1);
-
-	if (strlen(info_name) >= LABEL_LENGTH_MAX)
-		return(-1);
-
-	name = string_table_insert(&label_string_table, info_name);
-
-	num_labels = labelcl_info->num_labels;
-	new_label_list_size = sizeof(label_info_t) * (num_labels+1);
-
-	/*
-	 * Create a new label info area.
-	 */
-	if (new_label_list_size != 0) {
-		new_label_list = (label_info_t *) kmalloc(new_label_list_size, GFP_KERNEL);
-
-		if (new_label_list == NULL)
-			return(-1);
-	}
-
-	/*
-	 * At this point, we are committed to adding the labelled info, 
-	 * if there isn't already information there with the same name.
-	 */
-	old_label_list = labelcl_info->label_list;
-
-	/* 
-	 * Look for matching info name.
-	 */
-	for (i=0; i<num_labels; i++) {
-		if (!strcmp(info_name, old_label_list[i].name)) {
-			/* Not allowed to add duplicate labelled info names. */
-			kfree(new_label_list);
-			return(-1);
-		}
-		new_label_list[i] = old_label_list[i]; /* structure copy */
-	}
-
-	new_label_list[num_labels].name = name;
-	new_label_list[num_labels].desc = info_desc;
-	new_label_list[num_labels].info = info;
-
-	labelcl_info->num_labels = num_labels+1;
-	labelcl_info->label_list = new_label_list;
-
-	if (old_label_list != NULL)
-		kfree(old_label_list);
-
-	return(0);
-}
-
-/*
- * labelcl_info_remove_LBL - Remove a label entry.
- */
-int
-labelcl_info_remove_LBL(vertex_hdl_t de,
-			 char *info_name,
-			 arb_info_desc_t *info_desc,
-			 arbitrary_info_t *info)
-{
-	labelcl_info_t	*labelcl_info = NULL;
-	int num_labels;
-	int new_label_list_size;
-	label_info_t *old_label_list, *new_label_list = NULL;
-	arb_info_desc_t label_desc_found;
-	arbitrary_info_t label_info_found;
-	int i;
-
-	if (de == NULL)
-		return(-1);
-
-	labelcl_info = hwgfs_get_info(de);
-	if (labelcl_info == NULL)
-		return(-1);
-
-	if (labelcl_info->hwcl_magic != LABELCL_MAGIC)
-		return(-1);
-
-	num_labels = labelcl_info->num_labels;
-	if (num_labels == 0) {
-		return(-1);
-	}
-
-	/*
-	 * Create a new info area.
-	 */
-	new_label_list_size = sizeof(label_info_t) * (num_labels-1);
-	if (new_label_list_size) {
-		new_label_list = (label_info_t *) kmalloc(new_label_list_size, GFP_KERNEL);
-		if (new_label_list == NULL)
-			return(-1);
-	}
-
-	/*
-	 * At this point, we are committed to removing the labelled info, 
-	 * if it still exists.
-	 */
-	old_label_list = labelcl_info->label_list;
-
-	/* 
-	 * Find matching info name.
-	 */
-	for (i=0; i<num_labels; i++) {
-		if (!strcmp(info_name, old_label_list[i].name)) {
-			label_desc_found = old_label_list[i].desc;
-			label_info_found = old_label_list[i].info;
-			goto found;
-		}
-		if (i < num_labels-1) /* avoid walking off the end of the new vertex */
-			new_label_list[i] = old_label_list[i]; /* structure copy */
-	}
-
-	/* The named info doesn't exist. */
-	if (new_label_list)
-		kfree(new_label_list);
-
-	return(-1);
-
-found:
-	/* Finish up rest of labelled info */
-	for (i=i+1; i<num_labels; i++)
-		new_label_list[i-1] = old_label_list[i]; /* structure copy */
-
-	labelcl_info->num_labels = num_labels+1;
-	labelcl_info->label_list = new_label_list;
-
-	kfree(old_label_list);
-
-	if (info != NULL)
-		*info = label_info_found;
-
-	if (info_desc != NULL)
-		*info_desc = label_desc_found;
-
-	return(0);
-}
-
-
-/*
- * labelcl_info_replace_LBL - Replace an existing label entry with the 
- *	given new information.
- *
- *	Label entry must exist.
- */
-int
-labelcl_info_replace_LBL(vertex_hdl_t de,
-			char *info_name,
-			arb_info_desc_t info_desc,
-			arbitrary_info_t info,
-			arb_info_desc_t *old_info_desc,
-			arbitrary_info_t *old_info)
-{
-	labelcl_info_t	*labelcl_info = NULL;
-	int num_labels;
-	label_info_t *label_list;
-	int i;
-
-	if (de == NULL)
-		return(-1);
-
-	labelcl_info = hwgfs_get_info(de);
-	if (labelcl_info == NULL)
-		return(-1);
-
-	if (labelcl_info->hwcl_magic != LABELCL_MAGIC)
-		return(-1);
-
-	num_labels = labelcl_info->num_labels;
-	if (num_labels == 0) {
-		return(-1);
-	}
-
-	if (info_name == NULL)
-		return(-1);
-
-	label_list = labelcl_info->label_list;
-
-	/* 
-	 * Verify that information under info_name already exists.
-	 */
-	for (i=0; i<num_labels; i++)
-		if (!strcmp(info_name, label_list[i].name)) {
-			if (old_info != NULL)
-				*old_info = label_list[i].info;
-
-			if (old_info_desc != NULL)
-				*old_info_desc = label_list[i].desc;
-
-			label_list[i].info = info;
-			label_list[i].desc = info_desc;
-
-			return(0);
-		}
-
-
-	return(-1);
-}
-
-/*
- * labelcl_info_get_LBL - Retrieve and return the information for the 
- *	given label entry.
- */
-int
-labelcl_info_get_LBL(vertex_hdl_t de,
-		      char *info_name,
-		      arb_info_desc_t *info_desc,
-		      arbitrary_info_t *info)
-{
-	labelcl_info_t	*labelcl_info = NULL;
-	int num_labels;
-	label_info_t *label_list;
-	int i;
-
-	if (de == NULL)
-		return(-1);
-
-	labelcl_info = hwgfs_get_info(de);
-	if (labelcl_info == NULL)
-		return(-1);
-
-	if (labelcl_info->hwcl_magic != LABELCL_MAGIC)
-		return(-1);
-
-	num_labels = labelcl_info->num_labels;
-	if (num_labels == 0) {
-		return(-1);
-	}
-
-	label_list = labelcl_info->label_list;
-
-	/* 
-	 * Find information under info_name.
-	 */
-	for (i=0; i<num_labels; i++)
-		if (!strcmp(info_name, label_list[i].name)) {
-			if (info != NULL)
-				*info = label_list[i].info;
-			if (info_desc != NULL)
-				*info_desc = label_list[i].desc;
-
-			return(0);
-		}
-
-	return(-1);
-}
-
-/*
- * labelcl_info_get_next_LBL - returns the next label entry on the list.
- */
-int
-labelcl_info_get_next_LBL(vertex_hdl_t de,
-			   char *buffer,
-			   arb_info_desc_t *info_descp,
-			   arbitrary_info_t *infop,
-			   labelcl_info_place_t *placeptr)
-{
-	labelcl_info_t	*labelcl_info = NULL;
-	uint which_info;
-	label_info_t *label_list;
-
-	if ((buffer == NULL) && (infop == NULL))
-		return(-1);
-
-	if (placeptr == NULL)
-		return(-1);
-
-	if (de == NULL)
-		return(-1);
-
-	labelcl_info = hwgfs_get_info(de);
-	if (labelcl_info == NULL)
-		return(-1);
-
-	if (labelcl_info->hwcl_magic != LABELCL_MAGIC)
-		return(-1);
-
-	which_info = *placeptr;
-
-	if (which_info >= labelcl_info->num_labels) {
-		return(-1);
-	}
-
-	label_list = (label_info_t *) labelcl_info->label_list;
-
-	if (buffer != NULL)
-		strcpy(buffer, label_list[which_info].name);
-
-	if (infop)
-		*infop = label_list[which_info].info;
-
-	if (info_descp)
-		*info_descp = label_list[which_info].desc;
-
-	*placeptr = which_info + 1;
-
-	return(0);
-}
-
-
-int
-labelcl_info_replace_IDX(vertex_hdl_t de,
-			int index,
-			arbitrary_info_t info,
-			arbitrary_info_t *old_info)
-{
-	arbitrary_info_t *info_list_IDX;
-	labelcl_info_t	*labelcl_info = NULL;
-
-	if (de == NULL) {
-		printk(KERN_ALERT "labelcl: NULL handle given.\n");
-		return(-1);
-	}
-
-	labelcl_info = hwgfs_get_info(de);
-	if (labelcl_info == NULL) {
-		printk(KERN_ALERT "labelcl: Entry %p does not have info pointer.\n", (void *)de);
-		return(-1);
-	}
-
-	if (labelcl_info->hwcl_magic != LABELCL_MAGIC)
-		return(-1);
-
-	if ( (index < 0) || (index >= HWGRAPH_NUM_INDEX_INFO) )
-		return(-1);
-
-	/*
-	 * Replace information at the appropriate index in this vertex with 
-	 * the new info.
-	 */
-	info_list_IDX = labelcl_info->IDX_list;
-	if (old_info != NULL)
-		*old_info = info_list_IDX[index];
-	info_list_IDX[index] = info;
-
-	return(0);
-
-}
-
-/*
- * labelcl_info_connectpt_set - Sets the connectpt.
- */
-int
-labelcl_info_connectpt_set(hwgfs_handle_t de,
-			  hwgfs_handle_t connect_de)
-{
-	arbitrary_info_t old_info;
-	int	rv;
-
-	rv = labelcl_info_replace_IDX(de, HWGRAPH_CONNECTPT, 
-		(arbitrary_info_t) connect_de, &old_info);
-
-	if (rv) {
-		return(rv);
-	}
-
-	return(0);
-}
-
-
-/*
- * labelcl_info_get_IDX - Returns the information pointed at by index.
- *
- */
-int
-labelcl_info_get_IDX(vertex_hdl_t de,
-			int index,
-			arbitrary_info_t *info)
-{
-	arbitrary_info_t *info_list_IDX;
-	labelcl_info_t	*labelcl_info = NULL;
-
-	if (de == NULL)
-		return(-1);
-
-	labelcl_info = hwgfs_get_info(de);
-	if (labelcl_info == NULL)
-		return(-1);
-
-	if (labelcl_info->hwcl_magic != LABELCL_MAGIC)
-		return(-1);
-
-	if ( (index < 0) || (index >= HWGRAPH_NUM_INDEX_INFO) )
-		return(-1);
-
-	/*
-	 * Return information at the appropriate index in this vertex.
-	 */
-	info_list_IDX = labelcl_info->IDX_list;
-	if (info != NULL)
-		*info = info_list_IDX[index];
-
-	return(0);
-}
-
-/*
- * labelcl_info_connectpt_get - Retrieve the connect point for a device entry.
- */
-hwgfs_handle_t
-labelcl_info_connectpt_get(hwgfs_handle_t de)
-{
-	int rv;
-	arbitrary_info_t info;
-
-	rv = labelcl_info_get_IDX(de, HWGRAPH_CONNECTPT, &info);
-	if (rv)
-		return(NULL);
-
-	return((hwgfs_handle_t) info);
-}
diff -Nru a/arch/ia64/sn/io/hwgfs/ramfs.c b/arch/ia64/sn/io/hwgfs/ramfs.c
--- a/arch/ia64/sn/io/hwgfs/ramfs.c	2004-12-24 13:37:02 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,208 +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) 2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- *  Mostly shameless copied from Linus Torvalds' ramfs and thus
- *  Copyright (C) 2000 Linus Torvalds.
- *                2000 Transmeta Corp.
- */
-
-#include <linux/module.h>
-#include <linux/backing-dev.h>
-#include <linux/fs.h>
-#include <linux/pagemap.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <asm/uaccess.h>
-
-/* some random number */
-#define HWGFS_MAGIC	0x12061983
-
-static struct super_operations hwgfs_ops;
-static struct address_space_operations hwgfs_aops;
-static struct file_operations hwgfs_file_operations;
-static struct inode_operations hwgfs_file_inode_operations;
-static struct inode_operations hwgfs_dir_inode_operations;
-
-static struct backing_dev_info hwgfs_backing_dev_info = {
-	.ra_pages       = 0,	/* No readahead */
-	.memory_backed  = 1,	/* Does not contribute to dirty memory */
-};
-
-static struct inode *hwgfs_get_inode(struct super_block *sb, int mode, dev_t dev)
-{
-	struct inode * inode = new_inode(sb);
-
-	if (inode) {
-		inode->i_mode = mode;
-		inode->i_uid = current->fsuid;
-		inode->i_gid = current->fsgid;
-		inode->i_blksize = PAGE_CACHE_SIZE;
-		inode->i_blocks = 0;
-		inode->i_mapping->a_ops = &hwgfs_aops;
-		inode->i_mapping->backing_dev_info = &hwgfs_backing_dev_info;
-		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-		switch (mode & S_IFMT) {
-		default:
-			init_special_inode(inode, mode, dev);
-			break;
-		case S_IFREG:
-			inode->i_op = &hwgfs_file_inode_operations;
-			inode->i_fop = &hwgfs_file_operations;
-			break;
-		case S_IFDIR:
-			inode->i_op = &hwgfs_dir_inode_operations;
-			inode->i_fop = &simple_dir_operations;
-			inode->i_nlink++;
-			break;
-		case S_IFLNK:
-			inode->i_op = &page_symlink_inode_operations;
-			break;
-		}
-	}
-	return inode;
-}
-
-static int hwgfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
-{
-	struct inode * inode = hwgfs_get_inode(dir->i_sb, mode, dev);
-	int error = -ENOSPC;
-
-	if (inode) {
-		d_instantiate(dentry, inode);
-		dget(dentry);		/* Extra count - pin the dentry in core */
-		error = 0;
-	}
-	return error;
-}
-
-static int hwgfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
-{
-	return hwgfs_mknod(dir, dentry, mode | S_IFDIR, 0);
-}
-
-static int hwgfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *unused)
-{
-	return hwgfs_mknod(dir, dentry, mode | S_IFREG, 0);
-}
-
-static int hwgfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
-{
-	struct inode *inode;
-	int error = -ENOSPC;
-
-	inode = hwgfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
-	if (inode) {
-		int l = strlen(symname)+1;
-		error = page_symlink(inode, symname, l);
-		if (!error) {
-			d_instantiate(dentry, inode);
-			dget(dentry);
-		} else
-			iput(inode);
-	}
-	return error;
-}
-
-static struct address_space_operations hwgfs_aops = {
-	.readpage	= simple_readpage,
-	.prepare_write	= simple_prepare_write,
-	.commit_write	= simple_commit_write
-};
-
-static struct file_operations hwgfs_file_operations = {
-	.read		= generic_file_read,
-	.write		= generic_file_write,
-	.mmap		= generic_file_mmap,
-	.fsync		= simple_sync_file,
-	.sendfile	= generic_file_sendfile,
-};
-
-static struct inode_operations hwgfs_file_inode_operations = {
-	.getattr	= simple_getattr,
-};
-
-static struct inode_operations hwgfs_dir_inode_operations = {
-	.create		= hwgfs_create,
-	.lookup		= simple_lookup,
-	.link		= simple_link,
-	.unlink		= simple_unlink,
-	.symlink	= hwgfs_symlink,
-	.mkdir		= hwgfs_mkdir,
-	.rmdir		= simple_rmdir,
-	.mknod		= hwgfs_mknod,
-	.rename		= simple_rename,
-};
-
-static struct super_operations hwgfs_ops = {
-	.statfs		= simple_statfs,
-	.drop_inode	= generic_delete_inode,
-};
-
-static int hwgfs_fill_super(struct super_block * sb, void * data, int silent)
-{
-	struct inode * inode;
-	struct dentry * root;
-
-	sb->s_blocksize = PAGE_CACHE_SIZE;
-	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
-	sb->s_magic = HWGFS_MAGIC;
-	sb->s_op = &hwgfs_ops;
-	inode = hwgfs_get_inode(sb, S_IFDIR | 0755, 0);
-	if (!inode)
-		return -ENOMEM;
-
-	root = d_alloc_root(inode);
-	if (!root) {
-		iput(inode);
-		return -ENOMEM;
-	}
-	sb->s_root = root;
-	return 0;
-}
-
-static struct super_block *hwgfs_get_sb(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
-{
-	return get_sb_single(fs_type, flags, data, hwgfs_fill_super);
-}
-
-static struct file_system_type hwgfs_fs_type = {
-	.owner		= THIS_MODULE,
-	.name           = "hwgfs",
-	.get_sb         = hwgfs_get_sb,
-	.kill_sb        = kill_litter_super,
-};
-
-struct vfsmount *hwgfs_vfsmount;
-
-int __init init_hwgfs_fs(void)
-{
-	int error;
-
-	error = register_filesystem(&hwgfs_fs_type);
-	if (error)
-		return error;
-
-	hwgfs_vfsmount = kern_mount(&hwgfs_fs_type);
-	if (IS_ERR(hwgfs_vfsmount))
-		goto fail;
-	return 0;
-
-fail:
-	unregister_filesystem(&hwgfs_fs_type);
-	return PTR_ERR(hwgfs_vfsmount);
-}
-
-static void __exit exit_hwgfs_fs(void)
-{
-	unregister_filesystem(&hwgfs_fs_type);
-}
-
-MODULE_LICENSE("GPL");
-
-module_init(init_hwgfs_fs)
-module_exit(exit_hwgfs_fs)
diff -Nru a/arch/ia64/sn/io/io.c b/arch/ia64/sn/io/io.c
--- a/arch/ia64/sn/io/io.c	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,739 +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) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/sched.h>
-#include <asm/sn/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/driver.h>
-#include <asm/param.h>
-#include <asm/sn/pio.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/xtalk/xtalkaddrs.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_cpuid.h>
-
-extern xtalk_provider_t hub_provider;
-
-static int force_fire_and_forget = 1;
-static int ignore_conveyor_override;
-
-
-/* 
- * Implementation of hub iobus operations.
- *
- * Hub provides a crosstalk "iobus" on IP27 systems.  These routines
- * provide a platform-specific implementation of xtalk used by all xtalk 
- * cards on IP27 systems.
- *
- * Called from corresponding xtalk_* routines.
- */
-
-
-/* PIO MANAGEMENT */
-/* For mapping system virtual address space to xtalk space on a specified widget */
-
-/*
- * Setup pio structures needed for a particular hub.
- */
-static void
-hub_pio_init(vertex_hdl_t hubv)
-{
-	xwidgetnum_t widget;
-	hubinfo_t hubinfo;
-	nasid_t nasid;
-	int bigwin;
-	hub_piomap_t hub_piomap;
-
-	hubinfo_get(hubv, &hubinfo);
-	nasid = hubinfo->h_nasid;
-
-	/* Initialize small window piomaps for this hub */
-	for (widget=0; widget <= HUB_WIDGET_ID_MAX; widget++) {
-		hub_piomap = hubinfo_swin_piomap_get(hubinfo, (int)widget);
-		hub_piomap->hpio_xtalk_info.xp_target = widget;
-		hub_piomap->hpio_xtalk_info.xp_xtalk_addr = 0;
-		hub_piomap->hpio_xtalk_info.xp_mapsz = SWIN_SIZE;
-		hub_piomap->hpio_xtalk_info.xp_kvaddr = (caddr_t)NODE_SWIN_BASE(nasid, widget);
-		hub_piomap->hpio_hub = hubv;
-		hub_piomap->hpio_flags = HUB_PIOMAP_IS_VALID;
-	}
-
-	/* Initialize big window piomaps for this hub */
-	for (bigwin=0; bigwin < HUB_NUM_BIG_WINDOW; bigwin++) {
-		hub_piomap = hubinfo_bwin_piomap_get(hubinfo, bigwin);
-		hub_piomap->hpio_xtalk_info.xp_mapsz = BWIN_SIZE;
-		hub_piomap->hpio_hub = hubv;
-		hub_piomap->hpio_holdcnt = 0;
-		hub_piomap->hpio_flags = HUB_PIOMAP_IS_BIGWINDOW;
-		IIO_ITTE_DISABLE(nasid, bigwin);
-	}
-	hub_set_piomode(nasid, HUB_PIO_CONVEYOR);
-
-	spin_lock_init(&hubinfo->h_bwlock);
-	init_waitqueue_head(&hubinfo->h_bwwait);
-}
-
-/* 
- * Create a caddr_t-to-xtalk_addr mapping.
- *
- * Use a small window if possible (that's the usual case), but
- * manage big windows if needed.  Big window mappings can be
- * either FIXED or UNFIXED -- we keep at least 1 big window available
- * for UNFIXED mappings.
- *
- * Returns an opaque pointer-sized type which can be passed to
- * other hub_pio_* routines on success, or NULL if the request
- * cannot be satisfied.
- */
-/* ARGSUSED */
-hub_piomap_t
-hub_piomap_alloc(vertex_hdl_t dev,	/* set up mapping for this device */
-		device_desc_t dev_desc,	/* device descriptor */
-		iopaddr_t xtalk_addr,	/* map for this xtalk_addr range */
-		size_t byte_count,
-		size_t byte_count_max, 	/* maximum size of a mapping */
-		unsigned flags)		/* defined in sys/pio.h */
-{
-	xwidget_info_t widget_info = xwidget_info_get(dev);
-	xwidgetnum_t widget = xwidget_info_id_get(widget_info);
-	vertex_hdl_t hubv = xwidget_info_master_get(widget_info);
-	hubinfo_t hubinfo;
-	hub_piomap_t bw_piomap;
-	int bigwin, free_bw_index;
-	nasid_t nasid;
-	volatile hubreg_t junk;
-	caddr_t kvaddr;
-#ifdef PIOMAP_UNC_ACC_SPACE
-	uint64_t addr;
-#endif
-
-	/* sanity check */
-	if (byte_count_max > byte_count)
-		return NULL;
-
-	hubinfo_get(hubv, &hubinfo);
-
-	/* If xtalk_addr range is mapped by a small window, we don't have 
-	 * to do much 
-	 */
-	if (xtalk_addr + byte_count <= SWIN_SIZE) {
-		hub_piomap_t piomap;
-
-		piomap = hubinfo_swin_piomap_get(hubinfo, (int)widget);
-#ifdef PIOMAP_UNC_ACC_SPACE
-		if (flags & PIOMAP_UNC_ACC) {
-			addr = (uint64_t)piomap->hpio_xtalk_info.xp_kvaddr;
-			addr |= PIOMAP_UNC_ACC_SPACE;
-			piomap->hpio_xtalk_info.xp_kvaddr = (caddr_t)addr;
-		}
-#endif
-		return piomap;
-	}
-
-	/* We need to use a big window mapping.  */
-
-	/*
-	 * TBD: Allow requests that would consume multiple big windows --
-	 * split the request up and use multiple mapping entries.
-	 * For now, reject requests that span big windows.
-	 */
-	if ((xtalk_addr % BWIN_SIZE) + byte_count > BWIN_SIZE)
-		return NULL;
-
-
-	/* Round xtalk address down for big window alignement */
-	xtalk_addr = xtalk_addr & ~(BWIN_SIZE-1);
-
-	/*
-	 * Check to see if an existing big window mapping will suffice.
-	 */
-tryagain:
-	free_bw_index = -1;
-	spin_lock(&hubinfo->h_bwlock);
-	for (bigwin=0; bigwin < HUB_NUM_BIG_WINDOW; bigwin++) {
-		bw_piomap = hubinfo_bwin_piomap_get(hubinfo, bigwin);
-
-		/* If mapping is not valid, skip it */
-		if (!(bw_piomap->hpio_flags & HUB_PIOMAP_IS_VALID)) {
-			free_bw_index = bigwin;
-			continue;
-		}
-
-		/* 
-		 * If mapping is UNFIXED, skip it.  We don't allow sharing
-		 * of UNFIXED mappings, because this would allow starvation.
-		 */
-		if (!(bw_piomap->hpio_flags & HUB_PIOMAP_IS_FIXED))
-			continue;
-
-		if ( xtalk_addr == bw_piomap->hpio_xtalk_info.xp_xtalk_addr &&
-		     widget == bw_piomap->hpio_xtalk_info.xp_target) {
-			bw_piomap->hpio_holdcnt++;
-			spin_unlock(&hubinfo->h_bwlock);
-			return bw_piomap;
-		}
-	}
-
-	/*
-	 * None of the existing big window mappings will work for us --
-	 * we need to establish a new mapping.
-	 */
-
-	/* Insure that we don't consume all big windows with FIXED mappings */
-	if (flags & PIOMAP_FIXED) {
-		if (hubinfo->h_num_big_window_fixed < HUB_NUM_BIG_WINDOW-1) {
-			ASSERT(free_bw_index >= 0);
-			hubinfo->h_num_big_window_fixed++;
-		} else {
-			bw_piomap = NULL;
-			goto done;
-		}
-	} else /* PIOMAP_UNFIXED */ {
-		if (free_bw_index < 0) {
-			if (flags & PIOMAP_NOSLEEP) {
-				bw_piomap = NULL;
-				goto done;
-			} else {
-				DECLARE_WAITQUEUE(wait, current);
-
-				spin_unlock(&hubinfo->h_bwlock); 
-				set_current_state(TASK_UNINTERRUPTIBLE);
-				add_wait_queue_exclusive(&hubinfo->h_bwwait, &wait);
-				schedule();
-				remove_wait_queue(&hubinfo->h_bwwait, &wait);
-				goto tryagain;
-			}
-		}
-	}
-
-
-	/* OK!  Allocate big window free_bw_index for this mapping. */
- 	/* 
-	 * The code below does a PIO write to setup an ITTE entry.
-	 * We need to prevent other CPUs from seeing our updated memory 
-	 * shadow of the ITTE (in the piomap) until the ITTE entry is 
-	 * actually set up; otherwise, another CPU might attempt a PIO 
-	 * prematurely.  
-	 *
-	 * Also, the only way we can know that an entry has been received 
-	 * by the hub and can be used by future PIO reads/writes is by 
-	 * reading back the ITTE entry after writing it.
-	 *
-	 * For these two reasons, we PIO read back the ITTE entry after
-	 * we write it.
-	 */
-
-	nasid = hubinfo->h_nasid;
-	IIO_ITTE_PUT(nasid, free_bw_index, HUB_PIO_MAP_TO_MEM, widget, xtalk_addr);	
-	junk = HUB_L(IIO_ITTE_GET(nasid, free_bw_index));
-
-	bw_piomap = hubinfo_bwin_piomap_get(hubinfo, free_bw_index);
-	bw_piomap->hpio_xtalk_info.xp_dev = dev;
-	bw_piomap->hpio_xtalk_info.xp_target = widget;
-	bw_piomap->hpio_xtalk_info.xp_xtalk_addr = xtalk_addr;
-	kvaddr = (caddr_t)NODE_BWIN_BASE(nasid, free_bw_index);
-#ifdef PIOMAP_UNC_ACC_SPACE
-	if (flags & PIOMAP_UNC_ACC) {
-		addr = (uint64_t)kvaddr;
-		addr |= PIOMAP_UNC_ACC_SPACE;
-		kvaddr = (caddr_t)addr;
-	}
-#endif
-	bw_piomap->hpio_xtalk_info.xp_kvaddr = kvaddr;
-	bw_piomap->hpio_holdcnt++;
-	bw_piomap->hpio_bigwin_num = free_bw_index;
-
-	if (flags & PIOMAP_FIXED)
-		bw_piomap->hpio_flags |= HUB_PIOMAP_IS_VALID | HUB_PIOMAP_IS_FIXED;
-	else
-		bw_piomap->hpio_flags |= HUB_PIOMAP_IS_VALID;
-
-done:
-	spin_unlock(&hubinfo->h_bwlock);
-	return bw_piomap;
-}
-
-/*
- * hub_piomap_free destroys a caddr_t-to-xtalk pio mapping and frees
- * any associated mapping resources.  
- *
- * If this * piomap was handled with a small window, or if it was handled
- * in a big window that's still in use by someone else, then there's 
- * nothing to do.  On the other hand, if this mapping was handled 
- * with a big window, AND if we were the final user of that mapping, 
- * then destroy the mapping.
- */
-void
-hub_piomap_free(hub_piomap_t hub_piomap)
-{
-	vertex_hdl_t hubv;
-	hubinfo_t hubinfo;
-	nasid_t nasid;
-
-	/* 
-	 * Small windows are permanently mapped to corresponding widgets,
-	 * so there're no resources to free.
-	 */
-	if (!(hub_piomap->hpio_flags & HUB_PIOMAP_IS_BIGWINDOW))
-		return;
-
-	ASSERT(hub_piomap->hpio_flags & HUB_PIOMAP_IS_VALID);
-	ASSERT(hub_piomap->hpio_holdcnt > 0);
-
-	hubv = hub_piomap->hpio_hub;
-	hubinfo_get(hubv, &hubinfo);
-	nasid = hubinfo->h_nasid;
-
-	spin_lock(&hubinfo->h_bwlock);
-
-	/*
-	 * If this is the last hold on this mapping, free it.
-	 */
-	if (--hub_piomap->hpio_holdcnt == 0) {
-		IIO_ITTE_DISABLE(nasid, hub_piomap->hpio_bigwin_num );
-
-		if (hub_piomap->hpio_flags & HUB_PIOMAP_IS_FIXED) {
-			hub_piomap->hpio_flags &= ~(HUB_PIOMAP_IS_VALID | HUB_PIOMAP_IS_FIXED);
-			hubinfo->h_num_big_window_fixed--;
-			ASSERT(hubinfo->h_num_big_window_fixed >= 0);
-		} else
-			hub_piomap->hpio_flags &= ~HUB_PIOMAP_IS_VALID;
-
-		wake_up(&hubinfo->h_bwwait);
-	}
-
-	spin_unlock(&hubinfo->h_bwlock);
-}
-
-/*
- * Establish a mapping to a given xtalk address range using the resources
- * allocated earlier.
- */
-caddr_t
-hub_piomap_addr(hub_piomap_t hub_piomap,	/* mapping resources */
-		iopaddr_t xtalk_addr,		/* map for this xtalk address */
-		size_t byte_count)		/* map this many bytes */
-{
-	/* Verify that range can be mapped using the specified piomap */
-	if (xtalk_addr < hub_piomap->hpio_xtalk_info.xp_xtalk_addr)
-		return 0;
-
-	if (xtalk_addr + byte_count > 
-		( hub_piomap->hpio_xtalk_info.xp_xtalk_addr + 
-			hub_piomap->hpio_xtalk_info.xp_mapsz))
-		return 0;
-
-	if (hub_piomap->hpio_flags & HUB_PIOMAP_IS_VALID)
-		return hub_piomap->hpio_xtalk_info.xp_kvaddr + 
-			(xtalk_addr % hub_piomap->hpio_xtalk_info.xp_mapsz);
-	else
-		return 0;
-}
-
-
-/*
- * Driver indicates that it's done with PIO's from an earlier piomap_addr.
- */
-/* ARGSUSED */
-void
-hub_piomap_done(hub_piomap_t hub_piomap)	/* done with these mapping resources */
-{
-	/* Nothing to do */
-}
-
-
-/*
- * For translations that require no mapping resources, supply a kernel virtual
- * address that maps to the specified xtalk address range.
- */
-/* ARGSUSED */
-caddr_t
-hub_piotrans_addr(	vertex_hdl_t dev,	/* translate to this device */
-			device_desc_t dev_desc,	/* device descriptor */
-			iopaddr_t xtalk_addr,	/* Crosstalk address */
-			size_t byte_count,	/* map this many bytes */
-			unsigned flags)		/* (currently unused) */
-{
-	xwidget_info_t widget_info = xwidget_info_get(dev);
-	xwidgetnum_t widget = xwidget_info_id_get(widget_info);
-	vertex_hdl_t hubv = xwidget_info_master_get(widget_info);
-	hub_piomap_t hub_piomap;
-	hubinfo_t hubinfo;
-	caddr_t addr;
-
-	hubinfo_get(hubv, &hubinfo);
-
-	if (xtalk_addr + byte_count <= SWIN_SIZE) {
-		hub_piomap = hubinfo_swin_piomap_get(hubinfo, (int)widget);
-		addr = hub_piomap_addr(hub_piomap, xtalk_addr, byte_count);
-#ifdef PIOMAP_UNC_ACC_SPACE
-		if (flags & PIOMAP_UNC_ACC) {
-			uint64_t iaddr;
-			iaddr = (uint64_t)addr;
-			iaddr |= PIOMAP_UNC_ACC_SPACE;
-			addr = (caddr_t)iaddr;
-		}
-#endif
-		return addr;
-	} else
-		return 0;
-}
-
-
-/* DMA MANAGEMENT */
-/* Mapping from crosstalk space to system physical space */
-
-
-/*
- * Allocate resources needed to set up DMA mappings up to a specified size
- * on a specified adapter.
- * 
- * We don't actually use the adapter ID for anything.  It's just the adapter
- * that the lower level driver plans to use for DMA.
- */
-/* ARGSUSED */
-hub_dmamap_t
-hub_dmamap_alloc(	vertex_hdl_t dev,	/* set up mappings for this device */
-			device_desc_t dev_desc,	/* device descriptor */
-			size_t byte_count_max, 	/* max size of a mapping */
-			unsigned flags)		/* defined in dma.h */
-{
-	hub_dmamap_t dmamap;
-	xwidget_info_t widget_info = xwidget_info_get(dev);
-	xwidgetnum_t widget = xwidget_info_id_get(widget_info);
-	vertex_hdl_t hubv = xwidget_info_master_get(widget_info);
-
-	dmamap = kmalloc(sizeof(struct hub_dmamap_s), GFP_ATOMIC);
-	dmamap->hdma_xtalk_info.xd_dev = dev;
-	dmamap->hdma_xtalk_info.xd_target = widget;
-	dmamap->hdma_hub = hubv;
-	dmamap->hdma_flags = HUB_DMAMAP_IS_VALID;
- 	if (flags & XTALK_FIXED)
-		dmamap->hdma_flags |= HUB_DMAMAP_IS_FIXED;
-
-	return dmamap;
-}
-
-/*
- * Destroy a DMA mapping from crosstalk space to system address space.
- * There is no actual mapping hardware to destroy, but we at least mark
- * the dmamap INVALID and free the space that it took.
- */
-void
-hub_dmamap_free(hub_dmamap_t hub_dmamap)
-{
-	hub_dmamap->hdma_flags &= ~HUB_DMAMAP_IS_VALID;
-	kfree(hub_dmamap);
-}
-
-/*
- * Establish a DMA mapping using the resources allocated in a previous dmamap_alloc.
- * Return an appropriate crosstalk address range that maps to the specified physical 
- * address range.
- */
-/* ARGSUSED */
-extern iopaddr_t
-hub_dmamap_addr(	hub_dmamap_t dmamap,	/* use these mapping resources */
-			paddr_t paddr,		/* map for this address */
-			size_t byte_count)	/* map this many bytes */
-{
-	vertex_hdl_t vhdl;
-
-	ASSERT(dmamap->hdma_flags & HUB_DMAMAP_IS_VALID);
-
-	if (dmamap->hdma_flags & HUB_DMAMAP_USED) {
-	    /* If the map is FIXED, re-use is OK. */
-	    if (!(dmamap->hdma_flags & HUB_DMAMAP_IS_FIXED)) {
-		char name[MAXDEVNAME];
-		vhdl = dmamap->hdma_xtalk_info.xd_dev;
-		printk(KERN_WARNING  "%s: hub_dmamap_addr re-uses dmamap.\n", vertex_to_name(vhdl, name, MAXDEVNAME));
-	    }
-	} else {
-		dmamap->hdma_flags |= HUB_DMAMAP_USED;
-	}
-
-	/* There isn't actually any DMA mapping hardware on the hub. */
-        return (PHYS_TO_DMA(paddr));
-}
-
-/*
- * Driver indicates that it has completed whatever DMA it may have started
- * after an earlier dmamap_addr call.
- */
-void
-hub_dmamap_done(hub_dmamap_t hub_dmamap)	/* done with these mapping resources */
-{
-	vertex_hdl_t vhdl;
-
-	if (hub_dmamap->hdma_flags & HUB_DMAMAP_USED) {
-		hub_dmamap->hdma_flags &= ~HUB_DMAMAP_USED;
-	} else {
-	    /* If the map is FIXED, re-done is OK. */
-	    if (!(hub_dmamap->hdma_flags & HUB_DMAMAP_IS_FIXED)) {
-		char name[MAXDEVNAME];
-		vhdl = hub_dmamap->hdma_xtalk_info.xd_dev;
-		printk(KERN_WARNING  "%s: hub_dmamap_done already done with dmamap\n", vertex_to_name(vhdl, name, MAXDEVNAME));
-	    }
-	}
-}
-
-/*
- * Translate a single system physical address into a crosstalk address.
- */
-/* ARGSUSED */
-iopaddr_t
-hub_dmatrans_addr(	vertex_hdl_t dev,	/* translate for this device */
-			device_desc_t dev_desc,	/* device descriptor */
-			paddr_t paddr,		/* system physical address */
-			size_t byte_count,	/* length */
-			unsigned flags)		/* defined in dma.h */
-{
-	return (PHYS_TO_DMA(paddr));
-}
-
-/*ARGSUSED*/
-void
-hub_dmamap_drain(	hub_dmamap_t map)
-{
-    /* XXX- flush caches, if cache coherency WAR is needed */
-}
-
-/*ARGSUSED*/
-void
-hub_dmaaddr_drain(	vertex_hdl_t vhdl,
-			paddr_t addr,
-			size_t bytes)
-{
-    /* XXX- flush caches, if cache coherency WAR is needed */
-}
-
-
-/* CONFIGURATION MANAGEMENT */
-
-/*
- * Perform initializations that allow this hub to start crosstalk support.
- */
-void
-hub_provider_startup(vertex_hdl_t hubv)
-{
-	hubinfo_t       hubinfo;
-
-	hubinfo_get(hubv, &hubinfo);
-	hub_pio_init(hubv);
-	intr_init_vecblk(nasid_to_cnodeid(hubinfo->h_nasid));
-}
-
-/*
- * Shutdown crosstalk support from a hub.
- */
-void
-hub_provider_shutdown(vertex_hdl_t hub)
-{
-	/* TBD */
-	xtalk_provider_unregister(hub);
-}
-
-/*
- * Check that an address is in the real small window widget 0 space
- * or else in the big window we're using to emulate small window 0
- * in the kernel.
- */
-int
-hub_check_is_widget0(void *addr)
-{
-	nasid_t nasid = NASID_GET(addr);
-
-	if (((unsigned long)addr >= RAW_NODE_SWIN_BASE(nasid, 0)) &&
-	    ((unsigned long)addr < RAW_NODE_SWIN_BASE(nasid, 1)))
-		return 1;
-	return 0;
-}
-
-
-/*
- * Check that two addresses use the same widget
- */
-int
-hub_check_window_equiv(void *addra, void *addrb)
-{
-	if (hub_check_is_widget0(addra) && hub_check_is_widget0(addrb))
-		return 1;
-
-	/* XXX - Assume this is really a small window address */
-	if (WIDGETID_GET((unsigned long)addra) ==
-	    WIDGETID_GET((unsigned long)addrb))
-		return 1;
-
-	return 0;
-}
-
-
-/*
- * hub_setup_prb(nasid, prbnum, credits, conveyor)
- *
- * 	Put a PRB into fire-and-forget mode if conveyor isn't set.  Otherwise,
- * 	put it into conveyor belt mode with the specified number of credits.
- */
-void
-hub_setup_prb(nasid_t nasid, int prbnum, int credits, int conveyor)
-{
-	iprb_t prb;
-	int prb_offset;
-
-	if (force_fire_and_forget && !ignore_conveyor_override)
-	    if (conveyor == HUB_PIO_CONVEYOR)
-		conveyor = HUB_PIO_FIRE_N_FORGET;
-
-	/*
-	 * Get the current register value.
-	 */
-	prb_offset = IIO_IOPRB(prbnum);
-	prb.iprb_regval = REMOTE_HUB_L(nasid, prb_offset);
-
-	/*
-	 * Clear out some fields.
-	 */
-	prb.iprb_ovflow = 1;
-	prb.iprb_bnakctr = 0;
-	prb.iprb_anakctr = 0;
-
-	/*
-	 * Enable or disable fire-and-forget mode.
-	 */
-	prb.iprb_ff = ((conveyor == HUB_PIO_CONVEYOR) ? 0 : 1);
-
-	/*
-	 * Set the appropriate number of PIO cresits for the widget.
-	 */
-	prb.iprb_xtalkctr = credits;
-
-	/*
-	 * Store the new value to the register.
-	 */
-	REMOTE_HUB_S(nasid, prb_offset, prb.iprb_regval);
-}
-
-/*
- * hub_set_piomode()
- *
- * 	Put the hub into either "PIO conveyor belt" mode or "fire-and-forget"
- * 	mode.  To do this, we have to make absolutely sure that no PIOs
- *	are in progress so we turn off access to all widgets for the duration
- *	of the function.
- * 
- * XXX - This code should really check what kind of widget we're talking
- * to.  Bridges can only handle three requests, but XG will do more.
- * How many can crossbow handle to widget 0?  We're assuming 1.
- *
- * XXX - There is a bug in the crossbow that link reset PIOs do not
- * return write responses.  The easiest solution to this problem is to
- * leave widget 0 (xbow) in fire-and-forget mode at all times.  This
- * only affects pio's to xbow registers, which should be rare.
- */
-void
-hub_set_piomode(nasid_t nasid, int conveyor)
-{
-	hubreg_t ii_iowa;
-	int direct_connect;
-	hubii_wcr_t ii_wcr;
-	int prbnum;
-
-	ASSERT(nasid_to_cnodeid(nasid) != INVALID_CNODEID);
-
-	ii_iowa = REMOTE_HUB_L(nasid, IIO_OUTWIDGET_ACCESS);
-	REMOTE_HUB_S(nasid, IIO_OUTWIDGET_ACCESS, 0);
-
-	ii_wcr.wcr_reg_value = REMOTE_HUB_L(nasid, IIO_WCR);
-	direct_connect = ii_wcr.iwcr_dir_con;
-
-	if (direct_connect) {
-		/* 
-		 * Assume a bridge here.
-		 */
-		hub_setup_prb(nasid, 0, 3, conveyor);
-	} else {
-		/* 
-		 * Assume a crossbow here.
-		 */
-		hub_setup_prb(nasid, 0, 1, conveyor);
-	}
-
-	for (prbnum = HUB_WIDGET_ID_MIN; prbnum <= HUB_WIDGET_ID_MAX; prbnum++) {
-		/*
-		 * XXX - Here's where we should take the widget type into
-		 * when account assigning credits.
-		 */
-		/* Always set the PRBs in fire-and-forget mode */
-		hub_setup_prb(nasid, prbnum, 3, conveyor);
-	}
-
-	REMOTE_HUB_S(nasid, IIO_OUTWIDGET_ACCESS, ii_iowa);
-}
-/* Interface to allow special drivers to set hub specific
- * device flags.
- * Return 0 on failure , 1 on success
- */
-int
-hub_widget_flags_set(nasid_t		nasid,
-		     xwidgetnum_t	widget_num,
-		     hub_widget_flags_t	flags)
-{
-
-	ASSERT((flags & HUB_WIDGET_FLAGS) == flags);
-
-	if (flags & HUB_PIO_CONVEYOR) {
-		hub_setup_prb(nasid,widget_num,
-			      3,HUB_PIO_CONVEYOR); /* set the PRB in conveyor 
-						    * belt mode with 3 credits
-						    */
-	} else if (flags & HUB_PIO_FIRE_N_FORGET) {
-		hub_setup_prb(nasid,widget_num,
-			      3,HUB_PIO_FIRE_N_FORGET); /* set the PRB in fire
-							 *  and forget mode 
-							 */
-	}
-
-	return 1;
-}
-
-/*
- * A pointer to this structure hangs off of every hub hwgraph vertex.
- * The generic xtalk layer may indirect through it to get to this specific
- * crosstalk bus provider.
- */
-xtalk_provider_t hub_provider = {
-	.piomap_alloc	= (xtalk_piomap_alloc_f *) hub_piomap_alloc,
-	.piomap_free	= (xtalk_piomap_free_f *) hub_piomap_free,
-	.piomap_addr	= (xtalk_piomap_addr_f *) hub_piomap_addr,
-	.piomap_done	= (xtalk_piomap_done_f *) hub_piomap_done,
-	.piotrans_addr	= (xtalk_piotrans_addr_f *) hub_piotrans_addr,
-
-	.dmamap_alloc	= (xtalk_dmamap_alloc_f *) hub_dmamap_alloc,
-	.dmamap_free	= (xtalk_dmamap_free_f *) hub_dmamap_free,
-	.dmamap_addr	= (xtalk_dmamap_addr_f *) hub_dmamap_addr,
-	.dmamap_done	= (xtalk_dmamap_done_f *) hub_dmamap_done,
-	.dmatrans_addr	= (xtalk_dmatrans_addr_f *) hub_dmatrans_addr,
-	.dmamap_drain	= (xtalk_dmamap_drain_f *) hub_dmamap_drain,
-	.dmaaddr_drain	= (xtalk_dmaaddr_drain_f *) hub_dmaaddr_drain,
-
-	.intr_alloc	= (xtalk_intr_alloc_f *) hub_intr_alloc,
-	.intr_alloc_nothd = (xtalk_intr_alloc_f *) hub_intr_alloc_nothd,
-	.intr_free	= (xtalk_intr_free_f *)	hub_intr_free,
-	.intr_connect	= (xtalk_intr_connect_f *) hub_intr_connect,
-	.intr_disconnect = (xtalk_intr_disconnect_f *) hub_intr_disconnect,
-	.provider_startup = (xtalk_provider_startup_f *) hub_provider_startup,
-	.provider_shutdown = (xtalk_provider_shutdown_f *) hub_provider_shutdown,
-};
diff -Nru a/arch/ia64/sn/io/machvec/Makefile b/arch/ia64/sn/io/machvec/Makefile
--- a/arch/ia64/sn/io/machvec/Makefile	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,10 +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) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# Makefile for the sn2 io routines.
-
-obj-y				+= pci.o pci_dma.o pci_bus_cvlink.o iomv.o
diff -Nru a/arch/ia64/sn/io/machvec/iomv.c b/arch/ia64/sn/io/machvec/iomv.c
--- a/arch/ia64/sn/io/machvec/iomv.c	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,76 +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) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/module.h>
-#include <asm/io.h>
-#include <asm/delay.h>
-#include <asm/sn/simulator.h>
-#include <asm/sn/pda.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/sn2/shub_mmr.h>
-
-/**
- * sn_io_addr - convert an in/out port to an i/o address
- * @port: port to convert
- *
- * Legacy in/out instructions are converted to ld/st instructions
- * on IA64.  This routine will convert a port number into a valid 
- * SN i/o address.  Used by sn_in*() and sn_out*().
- */
-void *
-sn_io_addr(unsigned long port)
-{
-	if (!IS_RUNNING_ON_SIMULATOR()) {
-		/* On sn2, legacy I/O ports don't point at anything */
-		if (port < 64*1024)
-			return 0;
-		return( (void *)  (port | __IA64_UNCACHED_OFFSET));
-	} else {
-		/* but the simulator uses them... */
-		unsigned long io_base;
-		unsigned long addr;
- 
-		/*
- 		 * word align port, but need more than 10 bits
- 		 * for accessing registers in bedrock local block
- 		 * (so we don't do port&0xfff)
- 		 */
-		if ((port >= 0x1f0 && port <= 0x1f7) ||
-			port == 0x3f6 || port == 0x3f7) {
-			io_base = (0xc000000fcc000000 | ((unsigned long)get_nasid() << 38));
-			addr = io_base | ((port >> 2) << 12) | (port & 0xfff);
-		} else {
-			addr = __ia64_get_io_port_base() | ((port >> 2) << 2);
-		}
-		return(void *) addr;
-	}
-}
-
-EXPORT_SYMBOL(sn_io_addr);
-
-/**
- * sn_mmiob - I/O space memory barrier
- *
- * Acts as a memory mapped I/O barrier for platforms that queue writes to 
- * I/O space.  This ensures that subsequent writes to I/O space arrive after
- * all previous writes.  For most ia64 platforms, this is a simple
- * 'mf.a' instruction.  For other platforms, mmiob() may have to read
- * a chipset register to ensure ordering.
- *
- * On SN2, we wait for the PIO_WRITE_STATUS SHub register to clear.
- * See PV 871084 for details about the WAR about zero value.
- *
- */
-void
-sn_mmiob (void)
-{
-	while ((((volatile unsigned long) (*pda->pio_write_status_addr)) & SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK) != 
-				SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK)
-		cpu_relax();
-}
-EXPORT_SYMBOL(sn_mmiob);
diff -Nru a/arch/ia64/sn/io/machvec/pci.c b/arch/ia64/sn/io/machvec/pci.c
--- a/arch/ia64/sn/io/machvec/pci.c	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,52 +0,0 @@
-/* 
- * SNI64 specific PCI support for SNI IO.
- *
- * 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, 2000-2003 Silicon Graphics, Inc.  All rights reserved.
- */
-#include <asm/sn/hcl.h>
-#include <asm/sn/pci/pcibr_private.h>
-
-/*
- * These routines are only used during sn_pci_init for probing each bus, and
- * can probably be removed with a little more cleanup now that the SAL routines
- * work on sn2.
- */
-
-extern vertex_hdl_t devfn_to_vertex(unsigned char bus, unsigned char devfn);
-
-int sn_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
-{
-	unsigned long res = 0;
-	vertex_hdl_t device_vertex;
-
-	device_vertex = devfn_to_vertex(bus->number, devfn);
-
-	if (!device_vertex)
-		return PCIBIOS_DEVICE_NOT_FOUND;
-
-	res = pciio_config_get(device_vertex, (unsigned)where, size);
-	*val = (u32)res;
-	return PCIBIOS_SUCCESSFUL;
-}
-
-int sn_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
-{
-	vertex_hdl_t device_vertex;
-
-	device_vertex = devfn_to_vertex(bus->number, devfn);
-
-	if (!device_vertex)
-		return PCIBIOS_DEVICE_NOT_FOUND;
-
-	pciio_config_set(device_vertex, (unsigned)where, size, (uint64_t)val);
-	return PCIBIOS_SUCCESSFUL;
-}
-
-struct pci_ops sn_pci_ops = {
-	.read = sn_read_config,
-	.write = sn_write_config,
-};
diff -Nru a/arch/ia64/sn/io/machvec/pci_bus_cvlink.c b/arch/ia64/sn/io/machvec/pci_bus_cvlink.c
--- a/arch/ia64/sn/io/machvec/pci_bus_cvlink.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,922 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/pci/pci_bus_cvlink.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/simulator.h>
-
-extern int bridge_rev_b_data_check_disable;
-
-vertex_hdl_t busnum_to_pcibr_vhdl[MAX_PCI_XWIDGET];
-nasid_t busnum_to_nid[MAX_PCI_XWIDGET];
-void * busnum_to_atedmamaps[MAX_PCI_XWIDGET];
-unsigned char num_bridges;
-static int done_probing;
-extern irqpda_t *irqpdaindr;
-
-static int pci_bus_map_create(struct pcibr_list_s *softlistp, moduleid_t io_moduleid);
-vertex_hdl_t devfn_to_vertex(unsigned char busnum, unsigned int devfn);
-
-extern void register_pcibr_intr(int irq, pcibr_intr_t intr);
-
-static struct sn_flush_device_list *sn_dma_flush_init(unsigned long start,
-				unsigned long end,
-				int idx, int pin, int slot);
-extern int cbrick_type_get_nasid(nasid_t);
-extern void ioconfig_bus_new_entries(void);
-extern void ioconfig_get_busnum(char *, int *);
-extern int iomoduleid_get(nasid_t);
-extern int pcibr_widget_to_bus(vertex_hdl_t);
-extern int isIO9(int);
-
-#define IS_OPUS(nasid) (cbrick_type_get_nasid(nasid) == MODULE_OPUSBRICK)
-#define IS_ALTIX(nasid) (cbrick_type_get_nasid(nasid) == MODULE_CBRICK)
-
-/*
- * Init the provider asic for a given device
- */
-
-static inline void __init
-set_pci_provider(struct sn_device_sysdata *device_sysdata)
-{
-	pciio_info_t pciio_info = pciio_info_get(device_sysdata->vhdl);
-
-	device_sysdata->pci_provider = pciio_info_pops_get(pciio_info);
-}
-
-/*
- * pci_bus_cvlink_init() - To be called once during initialization before
- *	SGI IO Infrastructure init is called.
- */
-int
-pci_bus_cvlink_init(void)
-{
-
-	extern int ioconfig_bus_init(void);
-
-	memset(busnum_to_pcibr_vhdl, 0x0, sizeof(vertex_hdl_t) * MAX_PCI_XWIDGET);
-	memset(busnum_to_nid, 0x0, sizeof(nasid_t) * MAX_PCI_XWIDGET);
-
-	memset(busnum_to_atedmamaps, 0x0, sizeof(void *) * MAX_PCI_XWIDGET);
-
-	num_bridges = 0;
-
-	return ioconfig_bus_init();
-}
-
-/*
- * pci_bus_to_vertex() - Given a logical Linux Bus Number returns the associated
- *	pci bus vertex from the SGI IO Infrastructure.
- */
-static inline vertex_hdl_t
-pci_bus_to_vertex(unsigned char busnum)
-{
-
-	vertex_hdl_t	pci_bus = NULL;
-
-
-	/*
-	 * First get the xwidget vertex.
-	 */
-	pci_bus = busnum_to_pcibr_vhdl[busnum];
-	return(pci_bus);
-}
-
-/*
- * devfn_to_vertex() - returns the vertex of the device given the bus, slot,
- *	and function numbers.
- */
-vertex_hdl_t
-devfn_to_vertex(unsigned char busnum, unsigned int devfn)
-{
-
-	int slot = 0;
-	int func = 0;
-	char	name[16];
-	vertex_hdl_t  pci_bus = NULL;
-	vertex_hdl_t	device_vertex = (vertex_hdl_t)NULL;
-
-	/*
-	 * Go get the pci bus vertex.
-	 */
-	pci_bus = pci_bus_to_vertex(busnum);
-	if (!pci_bus) {
-		/*
-		 * During probing, the Linux pci code invents non-existent
-		 * bus numbers and pci_dev structures and tries to access
-		 * them to determine existence. Don't crib during probing.
-		 */
-		if (done_probing)
-			printk("devfn_to_vertex: Invalid bus number %d given.\n", busnum);
-		return(NULL);
-	}
-
-
-	/*
-	 * Go get the slot&function vertex.
-	 * Should call pciio_slot_func_to_name() when ready.
-	 */
-	slot = PCI_SLOT(devfn);
-	func = PCI_FUNC(devfn);
-
-	/*
-	 * For a NON Multi-function card the name of the device looks like:
-	 * ../pci/1, ../pci/2 ..
-	 */
-	if (func == 0) {
-		sprintf(name, "%d", slot);
-		if (hwgraph_traverse(pci_bus, name, &device_vertex) ==
-			GRAPH_SUCCESS) {
-			if (device_vertex) {
-				return(device_vertex);
-			}
-		}
-	}
-			
-	/*
-	 * This maybe a multifunction card.  It's names look like:
-	 * ../pci/1a, ../pci/1b, etc.
-	 */
-	sprintf(name, "%d%c", slot, 'a'+func);
-	if (hwgraph_traverse(pci_bus, name, &device_vertex) != GRAPH_SUCCESS) {
-		if (!device_vertex) {
-			return(NULL);
-		}
-	}
-
-	return(device_vertex);
-}
-
-/*
- * sn_alloc_pci_sysdata() - This routine allocates a pci controller
- *	which is expected as the pci_dev and pci_bus sysdata by the Linux
- *      PCI infrastructure.
- */
-static struct pci_controller *
-sn_alloc_pci_sysdata(void)
-{
-	struct pci_controller *pci_sysdata;
-
-	pci_sysdata = kmalloc(sizeof(*pci_sysdata), GFP_KERNEL);
-	if (!pci_sysdata)
-		return NULL;
-
-	memset(pci_sysdata, 0, sizeof(*pci_sysdata));
-	return pci_sysdata;
-}
-
-/*
- * sn_pci_fixup_bus() - This routine sets up a bus's resources
- * consistent with the Linux PCI abstraction layer.
- */
-static int __init
-sn_pci_fixup_bus(struct pci_bus *bus)
-{
-	struct pci_controller *pci_sysdata;
-	struct sn_widget_sysdata *widget_sysdata;
-
-	pci_sysdata = sn_alloc_pci_sysdata();
-	if  (!pci_sysdata) {
-		printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to "
-			       "allocate memory for pci_sysdata\n");
-		return -ENOMEM;
-	}
-	widget_sysdata = kmalloc(sizeof(struct sn_widget_sysdata),
-				 GFP_KERNEL);
-	if (!widget_sysdata) {
-		printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to "
-			       "allocate memory for widget_sysdata\n");
-		kfree(pci_sysdata);
-		return -ENOMEM;
-	}
-
-	widget_sysdata->vhdl = pci_bus_to_vertex(bus->number);
-	pci_sysdata->platform_data = (void *)widget_sysdata;
-	bus->sysdata = pci_sysdata;
-	return 0;
-}
-
-
-/*
- * sn_pci_fixup_slot() - This routine sets up a slot's resources
- * consistent with the Linux PCI abstraction layer.  Resources acquired
- * from our PCI provider include PIO maps to BAR space and interrupt
- * objects.
- */
-static int
-sn_pci_fixup_slot(struct pci_dev *dev)
-{
-	extern int bit_pos_to_irq(int);
-	unsigned int irq;
-	int idx;
-	u16 cmd;
-	vertex_hdl_t vhdl;
-	unsigned long size;
-	struct pci_controller *pci_sysdata;
-	struct sn_device_sysdata *device_sysdata;
-	pciio_intr_line_t lines = 0;
-	vertex_hdl_t device_vertex;
-	pciio_provider_t *pci_provider;
-	pciio_intr_t intr_handle;
-
-	/* Allocate a controller structure */
-	pci_sysdata = sn_alloc_pci_sysdata();
-	if (!pci_sysdata) {
-		printk(KERN_WARNING "sn_pci_fixup_slot: Unable to "
-			       "allocate memory for pci_sysdata\n");
-		return -ENOMEM;
-	}
-
-	/* Set the device vertex */
-	device_sysdata = kmalloc(sizeof(struct sn_device_sysdata), GFP_KERNEL);
-	if (!device_sysdata) {
-		printk(KERN_WARNING "sn_pci_fixup_slot: Unable to "
-			       "allocate memory for device_sysdata\n");
-		kfree(pci_sysdata);
-		return -ENOMEM;
-	}
-
-	device_sysdata->vhdl = devfn_to_vertex(dev->bus->number, dev->devfn);
-	pci_sysdata->platform_data = (void *) device_sysdata;
-	dev->sysdata = pci_sysdata;
-	set_pci_provider(device_sysdata);
-
-	pci_read_config_word(dev, PCI_COMMAND, &cmd);
-
-	/*
-	 * Set the resources address correctly.  The assumption here
-	 * is that the addresses in the resource structure has been
-	 * read from the card and it was set in the card by our
-	 * Infrastructure.  NOTE: PIC and TIOCP don't have big-window
-	 * upport for PCI I/O space.  So by mapping the I/O space
-	 * first we will attempt to use Device(x) registers for I/O
-	 * BARs (which can't use big windows like MEM BARs can).
-	 */
-	vhdl = device_sysdata->vhdl;
-
-	/* Allocate the IORESOURCE_IO space first */
-	for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
-		unsigned long start, end, addr;
-
-		device_sysdata->pio_map[idx] = NULL;
-
-		if (!(dev->resource[idx].flags & IORESOURCE_IO))
-			continue;
-
-		start = dev->resource[idx].start;
-		end = dev->resource[idx].end;
-		size = end - start;
-		if (!size)
-			continue;
-
-		addr = (unsigned long)pciio_pio_addr(vhdl, 0,
-		PCIIO_SPACE_WIN(idx), 0, size,
-				&device_sysdata->pio_map[idx], 0);
-
-		if (!addr) {
-			dev->resource[idx].start = 0;
-			dev->resource[idx].end = 0;
-			printk("sn_pci_fixup(): pio map failure for "
-				"%s bar%d\n", dev->slot_name, idx);
-		} else {
-			addr |= __IA64_UNCACHED_OFFSET;
-			dev->resource[idx].start = addr;
-			dev->resource[idx].end = addr + size;
-			dev->resource[idx].parent = &ioport_resource;
-		}
-
-		if (dev->resource[idx].flags & IORESOURCE_IO)
-			cmd |= PCI_COMMAND_IO;
-	}
-
-	/* Allocate the IORESOURCE_MEM space next */
-	for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
-		unsigned long start, end, addr;
-
-		if ((dev->resource[idx].flags & IORESOURCE_IO))
-			continue;
-
-		start = dev->resource[idx].start;
-		end = dev->resource[idx].end;
-		size = end - start;
-		if (!size)
-			continue;
-
-		addr = (unsigned long)pciio_pio_addr(vhdl, 0,
-		PCIIO_SPACE_WIN(idx), 0, size,
-				&device_sysdata->pio_map[idx], 0);
-
-		if (!addr) {
-			dev->resource[idx].start = 0;
-			dev->resource[idx].end = 0;
-			printk("sn_pci_fixup(): pio map failure for "
-				"%s bar%d\n", dev->slot_name, idx);
-		} else {
-			addr |= __IA64_UNCACHED_OFFSET;
-			dev->resource[idx].start = addr;
-			dev->resource[idx].end = addr + size;
-			dev->resource[idx].parent = &iomem_resource;
-		}
-
-		if (dev->resource[idx].flags & IORESOURCE_MEM)
-			cmd |= PCI_COMMAND_MEMORY;
-	}
-
-        /*
-	 * Assign addresses to the ROMs, but don't enable them yet
-	 * Also note that we only map display card ROMs due to PIO mapping
-	 * space scarcity.
-	 */
-        if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
-                unsigned long addr;
-                size = dev->resource[PCI_ROM_RESOURCE].end -
-                        dev->resource[PCI_ROM_RESOURCE].start;
-
-                if (size) {
-                        addr = (unsigned long) pciio_pio_addr(vhdl, 0,
-					      PCIIO_SPACE_ROM,
-					      0, size, 0, PIOMAP_FIXED);
-                        if (!addr) {
-                                dev->resource[PCI_ROM_RESOURCE].start = 0;
-                                dev->resource[PCI_ROM_RESOURCE].end = 0;
-                                printk("sn_pci_fixup(): ROM pio map failure "
-				       "for %s\n", dev->slot_name);
-                        }
-                        addr |= __IA64_UNCACHED_OFFSET;
-                        dev->resource[PCI_ROM_RESOURCE].start = addr;
-                        dev->resource[PCI_ROM_RESOURCE].end = addr + size;
-			dev->resource[idx].parent = &iomem_resource;
-                        if (dev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_MEM)
-                                cmd |= PCI_COMMAND_MEMORY;
-                }
-        } else {
-		/*
-		 * Remove other ROM resources since they don't have valid
-		 * CPU addresses.
-		 */
-                size = dev->resource[PCI_ROM_RESOURCE].end -
-                        dev->resource[PCI_ROM_RESOURCE].start;
-
-		if (size) {
-			dev->resource[PCI_ROM_RESOURCE].start = 0;
-			dev->resource[PCI_ROM_RESOURCE].end = 0;
-			dev->resource[PCI_ROM_RESOURCE].flags = 0;
-		}
-	}
-
-	/*
-	 * Update the Command Word on the Card.
-	 */
-	cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */
-				   /* bit gets dropped .. no harm */
-	pci_write_config_word(dev, PCI_COMMAND, cmd);
-
-	pci_read_config_byte(dev, PCI_INTERRUPT_PIN, (unsigned char *)&lines);
-	device_vertex = device_sysdata->vhdl;
-	pci_provider = device_sysdata->pci_provider;
-	device_sysdata->intr_handle = NULL;
-
-	if (!lines)
-		return 0;
-
-	irqpdaindr->curr = dev;
-
-	intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines, device_vertex);
-	if (intr_handle == NULL) {
-		printk(KERN_WARNING "sn_pci_fixup:  pcibr_intr_alloc() failed\n");
-		kfree(pci_sysdata);
-		kfree(device_sysdata);
-		return -ENOMEM;
-	}
-
-	device_sysdata->intr_handle = intr_handle;
-	irq = intr_handle->pi_irq;
-	irqpdaindr->device_dev[irq] = dev;
-	(pci_provider->intr_connect)(intr_handle, (intr_func_t)0, (intr_arg_t)0);
-	dev->irq = irq;
-
-	register_pcibr_intr(irq, (pcibr_intr_t)intr_handle);
-
-	for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
-		int ibits = ((pcibr_intr_t)intr_handle)->bi_ibits;
-		int i;
-
-		size = dev->resource[idx].end -
-			dev->resource[idx].start;
-		if (size == 0) continue;
-
-		for (i=0; i<8; i++) {
-			if (ibits & (1 << i) ) {
-				extern pcibr_info_t pcibr_info_get(vertex_hdl_t);
-				device_sysdata->dma_flush_list =
-				 sn_dma_flush_init(dev->resource[idx].start,
-						   dev->resource[idx].end,
-						   idx,
-						   i,
-						   PCIBR_INFO_SLOT_GET_EXT(pcibr_info_get(device_sysdata->vhdl)));
-			}
-		}
-	}
-	return 0;
-}
-
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-
-void
-sn_dma_flush_clear(struct sn_flush_device_list *dma_flush_list,
-                   unsigned long start, unsigned long end)
-{
-
-        int i;
-
-        dma_flush_list->pin = -1;
-        dma_flush_list->bus = -1;
-        dma_flush_list->slot = -1;
-
-        for (i = 0; i < PCI_ROM_RESOURCE; i++)
-                if ((dma_flush_list->bar_list[i].start == start) &&
-                    (dma_flush_list->bar_list[i].end == end)) {
-                        dma_flush_list->bar_list[i].start = 0;
-                        dma_flush_list->bar_list[i].end = 0;
-                        break;
-                }           
-
-}
-
-/*
- * sn_pci_unfixup_slot() - This routine frees a slot's resources
- * consistent with the Linux PCI abstraction layer.  Resources released
- * back to our PCI provider include PIO maps to BAR space and interrupt
- * objects.
- */
-void
-sn_pci_unfixup_slot(struct pci_dev *dev)
-{
-	struct sn_device_sysdata *device_sysdata;
-	vertex_hdl_t vhdl;
-	pciio_intr_t intr_handle;
-	unsigned int irq;
-	unsigned long size;
-	int idx;
-
-	device_sysdata = SN_DEVICE_SYSDATA(dev);
-
-	vhdl = device_sysdata->vhdl;
-
-	if (device_sysdata->dma_flush_list)
-		for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
-			size = dev->resource[idx].end -
-				dev->resource[idx].start;
-			if (size == 0) continue;
-
-			sn_dma_flush_clear(device_sysdata->dma_flush_list,
-				   	   dev->resource[idx].start,
-				   	   dev->resource[idx].end);
-		}
-
-	intr_handle = device_sysdata->intr_handle;
-	if (intr_handle) {
-		extern void unregister_pcibr_intr(int, pcibr_intr_t);
-		irq = intr_handle->pi_irq;
-		irqpdaindr->device_dev[irq] = NULL;
-		unregister_pcibr_intr(irq, (pcibr_intr_t) intr_handle);
-		pciio_intr_disconnect(intr_handle);
-		pciio_intr_free(intr_handle);
-	}
-
-	for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
-		if (device_sysdata->pio_map[idx]) {
-			pciio_piomap_done (device_sysdata->pio_map[idx]);
-			pciio_piomap_free (device_sysdata->pio_map[idx]);
-		}
-	}
-
-}
-#endif /* CONFIG_HOTPLUG_PCI_SGI */
-
-struct sn_flush_nasid_entry flush_nasid_list[MAX_NASIDS];
-
-/* Initialize the data structures for flushing write buffers after a PIO read.
- * The theory is:
- * Take an unused int. pin and associate it with a pin that is in use.
- * After a PIO read, force an interrupt on the unused pin, forcing a write buffer flush
- * on the in use pin.  This will prevent the race condition between PIO read responses and
- * DMA writes.
- */
-static struct sn_flush_device_list *
-sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int slot)
-{
-	nasid_t nasid;
-	unsigned long dnasid;
-	int wid_num;
-	int bus;
-	struct sn_flush_device_list *p;
-	void *b;
-	int bwin;
-	int i;
-
-	nasid = NASID_GET(start);
-	wid_num = SWIN_WIDGETNUM(start);
-	bus = (start >> 23) & 0x1;
-	bwin = BWIN_WINDOWNUM(start);
-
-	if (flush_nasid_list[nasid].widget_p == NULL) {
-		flush_nasid_list[nasid].widget_p = (struct sn_flush_device_list **)kmalloc((HUB_WIDGET_ID_MAX+1) *
-			sizeof(struct sn_flush_device_list *), GFP_KERNEL);
-		if (!flush_nasid_list[nasid].widget_p) {
-			printk(KERN_WARNING "sn_dma_flush_init: Cannot allocate memory for nasid list\n");
-			return NULL;
-		}
-		memset(flush_nasid_list[nasid].widget_p, 0, (HUB_WIDGET_ID_MAX+1) * sizeof(struct sn_flush_device_list *));
-	}
-	if (bwin > 0) {
-		int itte_index = bwin - 1;
-		unsigned long itte;
-
-		itte = HUB_L(IIO_ITTE_GET(nasid, itte_index));
-		flush_nasid_list[nasid].iio_itte[bwin] = itte;
-		wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT)
-				& IIO_ITTE_WIDGET_MASK;
-		bus = itte & IIO_ITTE_OFFSET_MASK;
-		if (bus == 0x4 || bus == 0x8) {
-			bus = 0;
-		} else {
-			bus = 1;
-		}
-	}
-
-	/* if it's IO9, bus 1, we don't care about slots 1 and 4.  This is
-	 * because these are the IOC4 slots and we don't flush them.
-	 */
-	if (isIO9(nasid) && bus == 0 && (slot == 1 || slot == 4)) {
-		return NULL;
-	}
-	if (flush_nasid_list[nasid].widget_p[wid_num] == NULL) {
-		flush_nasid_list[nasid].widget_p[wid_num] = (struct sn_flush_device_list *)kmalloc(
-			DEV_PER_WIDGET * sizeof (struct sn_flush_device_list), GFP_KERNEL);
-		if (!flush_nasid_list[nasid].widget_p[wid_num]) {
-			printk(KERN_WARNING "sn_dma_flush_init: Cannot allocate memory for nasid sub-list\n");
-			return NULL;
-		}
-		memset(flush_nasid_list[nasid].widget_p[wid_num], 0,
-			DEV_PER_WIDGET * sizeof (struct sn_flush_device_list));
-		p = &flush_nasid_list[nasid].widget_p[wid_num][0];
-		for (i=0; i<DEV_PER_WIDGET;i++) {
-			p->bus = -1;
-			p->pin = -1;
-			p->slot = -1;
-			p++;
-		}
-	}
-
-	p = &flush_nasid_list[nasid].widget_p[wid_num][0];
-	for (i=0;i<DEV_PER_WIDGET; i++) {
-		if (p->pin == pin && p->bus == bus && p->slot == slot) break;
-		if (p->pin < 0) {
-			p->pin = pin;
-			p->bus = bus;
-			p->slot = slot;
-			break;
-		}
-		p++;
-	}
-
-	for (i=0; i<PCI_ROM_RESOURCE; i++) {
-		if (p->bar_list[i].start == 0) {
-			p->bar_list[i].start = start;
-			p->bar_list[i].end = end;
-			break;
-		}
-	}
-	b = (void *)(NODE_SWIN_BASE(nasid, wid_num) | (bus << 23) );
-
-	/* If it's IO9, then slot 2 maps to slot 7 and slot 6 maps to slot 8.
-	 * To see this is non-trivial.  By drawing pictures and reading manuals and talking
-	 * to HW guys, we can see that on IO9 bus 1, slots 7 and 8 are always unused.
-	 * Further, since we short-circuit slots  1, 3, and 4 above, we only have to worry
-	 * about the case when there is a card in slot 2.  A multifunction card will appear
-	 * to be in slot 6 (from an interrupt point of view) also.  That's the  most we'll
-	 * have to worry about.  A four function card will overload the interrupt lines in
-	 * slot 2 and 6.
-	 * We also need to special case the 12160 device in slot 3.  Fortunately, we have
-	 * a spare intr. line for pin 4, so we'll use that for the 12160.
-	 * All other buses have slot 3 and 4 and slots 7 and 8 unused.  Since we can only
-	 * see slots 1 and 2 and slots 5 and 6 coming through here for those buses (this
-	 * is true only on Pxbricks with 2 physical slots per bus), we just need to add
-	 * 2 to the slot number to find an unused slot.
-	 * We have convinced ourselves that we will never see a case where two different cards
-	 * in two different slots will ever share an interrupt line, so there is no need to
-	 * special case this.
-	 */
-
-	if (isIO9(nasid) && ( (IS_ALTIX(nasid) && wid_num == 0xc)
-				|| (IS_OPUS(nasid) && wid_num == 0xf) )
-				&& bus == 0) {
-		if (pin == 1) {
-			p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, 6);
-			pcireg_bridge_intr_device_bit_set(b, (1<<18));
-			dnasid = NASID_GET(virt_to_phys(&p->flush_addr));
-			pcireg_bridge_intr_addr_set(b, 6, ((virt_to_phys(&p->flush_addr) & 0xfffffffff) |
-					(dnasid << 36) | (0xfUL << 48)));
-		} else if (pin == 2) { /* 12160 SCSI device in IO9 */
-			p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, 4);
-			pcireg_bridge_intr_device_bit_set(b, (2<<12));
-			dnasid = NASID_GET(virt_to_phys(&p->flush_addr));
-			pcireg_bridge_intr_addr_set(b, 4,
-					((virt_to_phys(&p->flush_addr) & 0xfffffffff) |
-					(dnasid << 36) | (0xfUL << 48)));
-		} else { /* slot == 6 */
-			p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, 7);
-			pcireg_bridge_intr_device_bit_set(b, (5<<21));
-			dnasid = NASID_GET(virt_to_phys(&p->flush_addr));
-			pcireg_bridge_intr_addr_set(b, 7,
-					((virt_to_phys(&p->flush_addr) & 0xfffffffff) |
-					(dnasid << 36) | (0xfUL << 48)));
-		}
-	} else {
-		p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, (pin +2));
-		pcireg_bridge_intr_device_bit_set(b, (pin << (pin * 3)));
-		dnasid = NASID_GET(virt_to_phys(&p->flush_addr));
-		pcireg_bridge_intr_addr_set(b, (pin + 2),
-				((virt_to_phys(&p->flush_addr) & 0xfffffffff) |
-				(dnasid << 36) | (0xfUL << 48)));
-	}
-	return p;
-}
-
-
-/*
- * linux_bus_cvlink() Creates a link between the Linux PCI Bus number
- *	to the actual hardware component that it represents:
- *	/dev/hw/linux/busnum/0 -> ../../../hw/module/001c01/slab/0/Ibrick/xtalk/15/pci
- *
- *	The bus vertex, when called to devfs_generate_path() returns:
- *		hw/module/001c01/slab/0/Ibrick/xtalk/15/pci
- *		hw/module/001c01/slab/1/Pbrick/xtalk/12/pci-x/0
- *		hw/module/001c01/slab/1/Pbrick/xtalk/12/pci-x/1
- */
-void
-linux_bus_cvlink(void)
-{
-	char name[8];
-	int index;
-	
-	for (index=0; index < MAX_PCI_XWIDGET; index++) {
-		if (!busnum_to_pcibr_vhdl[index])
-			continue;
-
-		sprintf(name, "%x", index);
-		(void) hwgraph_edge_add(linux_busnum, busnum_to_pcibr_vhdl[index],
-				name);
-	}
-}
-
-/*
- * pci_bus_map_create() - Called by pci_bus_to_hcl_cvlink() to finish the job.
- *
- *	Linux PCI Bus numbers are assigned from lowest module_id numbers
- *	(rack/slot etc.)
- */
-static int
-pci_bus_map_create(struct pcibr_list_s *softlistp, moduleid_t moduleid)
-{
-	
-	int basebus_num, bus_number;
-	vertex_hdl_t pci_bus = softlistp->bl_vhdl;
-	char moduleid_str[16];
-
-	memset(moduleid_str, 0, 16);
-	format_module_id(moduleid_str, moduleid, MODULE_FORMAT_BRIEF);
-	(void) ioconfig_get_busnum((char *)moduleid_str, &basebus_num);
-
-	/*
-	 * Assign the correct bus number and also the nasid of this
-	 * pci Xwidget.
-	 */
-	bus_number = basebus_num + pcibr_widget_to_bus(pci_bus);
-#ifdef DEBUG
-	{
-	char hwpath[MAXDEVNAME] = "\0";
-	extern int hwgraph_vertex_name_get(vertex_hdl_t, char *, uint);
-
-	pcibr_soft_t pcibr_soft = softlistp->bl_soft;
-	hwgraph_vertex_name_get(pci_bus, hwpath, MAXDEVNAME);
-	printk("%s:\n\tbus_num %d, basebus_num %d, brick_bus %d, "
-		"bus_vhdl 0x%lx, brick_type %d\n", hwpath, bus_number,
-		basebus_num, pcibr_widget_to_bus(pci_bus),
-		(uint64_t)pci_bus, pcibr_soft->bs_bricktype);
-	}
-#endif
-	busnum_to_pcibr_vhdl[bus_number] = pci_bus;
-
-	/*
-	 * Pre assign DMA maps needed for 32 Bits Page Map DMA.
-	 */
-	busnum_to_atedmamaps[bus_number] = (void *) vmalloc(
-			sizeof(struct pcibr_dmamap_s)*MAX_ATE_MAPS);
-	if (busnum_to_atedmamaps[bus_number] <= 0) {
-		printk("pci_bus_map_create: Cannot allocate memory for ate maps\n");
-		return -1;
-	}
-	memset(busnum_to_atedmamaps[bus_number], 0x0,
-			sizeof(struct pcibr_dmamap_s) * MAX_ATE_MAPS);
-	return(0);
-}
-
-/*
- * pci_bus_to_hcl_cvlink() - This routine is called after SGI IO Infrastructure
- *      initialization has completed to set up the mappings between PCI BRIDGE
- *      ASIC and logical pci bus numbers.
- *
- *      Must be called before pci_init() is invoked.
- */
-int
-pci_bus_to_hcl_cvlink(void)
-{
-	int i;
-	extern pcibr_list_p pcibr_list;
-
-	for (i = 0; i < nummodules; i++) {
-		struct pcibr_list_s *softlistp = pcibr_list;
-		struct pcibr_list_s *first_in_list = NULL;
-		struct pcibr_list_s *last_in_list = NULL;
-
-		/* Walk the list of pcibr_soft structs looking for matches */
-		while (softlistp) {
-			struct pcibr_soft_s *pcibr_soft = softlistp->bl_soft;
-			moduleid_t moduleid;
-			
-			/* Is this PCI bus associated with this moduleid? */
-			moduleid = NODE_MODULEID(
-				nasid_to_cnodeid(pcibr_soft->bs_nasid));
-			if (sn_modules[i]->id == moduleid) {
-				struct pcibr_list_s *new_element;
-
-				new_element = kmalloc(sizeof (struct pcibr_soft_s), GFP_KERNEL);
-				if (new_element == NULL) {
-					printk("%s: Couldn't allocate memory\n",__FUNCTION__);
-					return -ENOMEM;
-				}
-				new_element->bl_soft = softlistp->bl_soft;
-				new_element->bl_vhdl = softlistp->bl_vhdl;
-				new_element->bl_next = NULL;
-
-				/* list empty so just put it on the list */
-				if (first_in_list == NULL) {
-					first_in_list = new_element;
-					last_in_list = new_element;
-					softlistp = softlistp->bl_next;
-					continue;
-				}
-
-				/*
-				 * BASEIO IObricks attached to a module have
-				 * a higher priority than non BASEIO IOBricks
-				 * when it comes to persistant pci bus
-				 * numbering, so put them on the front of the
-				 * list.
-				 */
-				if (isIO9(pcibr_soft->bs_nasid)) {
-					new_element->bl_next = first_in_list;
-					first_in_list = new_element;
-				} else {
-					last_in_list->bl_next = new_element;
-					last_in_list = new_element;
-				}
-			}
-			softlistp = softlistp->bl_next;
-		}
-				
-		/*
-		 * We now have a list of all the pci bridges associated with
-		 * the module_id, sn_modules[i].  Call pci_bus_map_create() for
-		 * each pci bridge
-		 */
-		softlistp = first_in_list;
-		while (softlistp) {
-			moduleid_t iobrick;
-			struct pcibr_list_s *next = softlistp->bl_next;
-			iobrick = iomoduleid_get(softlistp->bl_soft->bs_nasid);
-			pci_bus_map_create(softlistp, iobrick);
-			kfree(softlistp);
-			softlistp = next;
-		}
-	}
-
-	/*
-	 * Create the Linux PCI bus number vertex link.
-	 */
-	(void)linux_bus_cvlink();
-	(void)ioconfig_bus_new_entries();
-
-	return(0);
-}
-
-/*
- * Ugly hack to get PCI setup until we have a proper ACPI namespace.
- */
-
-#define PCI_BUSES_TO_SCAN 256
-
-extern struct pci_ops sn_pci_ops;
-int __init
-sn_pci_init (void)
-{
-	int i = 0;
-	struct pci_controller *controller;
-	struct list_head *ln;
-	struct pci_bus *pci_bus = NULL;
-	struct pci_dev *pci_dev = NULL;
-	int ret;
-#ifdef CONFIG_PROC_FS
-	extern void register_sn_procfs(void);
-#endif
-	extern void sgi_master_io_infr_init(void);
-	extern void sn_init_cpei_timer(void);
-
-
-	if (!ia64_platform_is("sn2") || IS_RUNNING_ON_SIMULATOR())
-		return 0;
-
-	/*
-	 * This is needed to avoid bounce limit checks in the blk layer
-	 */
-	ia64_max_iommu_merge_mask = ~PAGE_MASK;
-
-	/*
-	 * set pci_raw_ops, etc.
-	 */
-	sgi_master_io_infr_init();
-
-	sn_init_cpei_timer();
-
-#ifdef CONFIG_PROC_FS
-	register_sn_procfs();
-#endif
-
-	controller = kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
-	if (!controller) {
-		printk(KERN_WARNING "cannot allocate PCI controller\n");
-		return 0;
-	}
-
-	memset(controller, 0, sizeof(struct pci_controller));
-
-	for (i = 0; i < PCI_BUSES_TO_SCAN; i++)
-		if (pci_bus_to_vertex(i))
-			pci_scan_bus(i, &sn_pci_ops, controller);
-
-	done_probing = 1;
-
-	/*
-	 * Initialize the pci bus vertex in the pci_bus struct.
-	 */
-	for( ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
-		pci_bus = pci_bus_b(ln);
-		ret = sn_pci_fixup_bus(pci_bus);
-		if ( ret ) {
-			printk(KERN_WARNING
-				"sn_pci_fixup: sn_pci_fixup_bus fails : error %d\n",
-					ret);
-			return 0;
-		}
-	}
-
-	/*
-	 * set the root start and end so that drivers calling check_region()
-	 * won't see a conflict
-	 */
-	ioport_resource.start = 0xc000000000000000;
-	ioport_resource.end = 0xcfffffffffffffff;
-
-	/*
-	 * Set the root start and end for Mem Resource.
-	 */
-	iomem_resource.start = 0;
-	iomem_resource.end = 0xffffffffffffffff;
-
-	/*
-	 * Initialize the device vertex in the pci_dev struct.
-	 */
-	while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) {
-		ret = sn_pci_fixup_slot(pci_dev);
-		if ( ret ) {
-			printk(KERN_WARNING
-				"sn_pci_fixup: sn_pci_fixup_slot fails : error %d\n",
-					ret);
-			return 0;
-		}
-	}
-
-	return 0;
-}
-
-subsys_initcall(sn_pci_init);
diff -Nru a/arch/ia64/sn/io/machvec/pci_dma.c b/arch/ia64/sn/io/machvec/pci_dma.c
--- a/arch/ia64/sn/io/machvec/pci_dma.c	2004-12-24 13:36:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,677 +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) 2000,2002-2003 Silicon Graphics, Inc. All rights reserved.
- *
- * Routines for PCI DMA mapping.  See Documentation/DMA-mapping.txt for
- * a description of how these routines should be used.
- */
-
-#include <linux/module.h>
-#include <asm/sn/pci/pci_bus_cvlink.h>
-
-/*
- * For ATE allocations
- */
-pciio_dmamap_t get_free_pciio_dmamap(vertex_hdl_t);
-void free_pciio_dmamap(pcibr_dmamap_t);
-static struct pcibr_dmamap_s *find_sn_dma_map(dma_addr_t, unsigned char);
-void sn_pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction);
-
-/*
- * Toplogy stuff
- */
-extern vertex_hdl_t busnum_to_pcibr_vhdl[];
-extern nasid_t busnum_to_nid[];
-extern void * busnum_to_atedmamaps[];
-
-/**
- * get_free_pciio_dmamap - find and allocate an ATE
- * @pci_bus: PCI bus to get an entry for
- *
- * Finds and allocates an ATE on the PCI bus specified
- * by @pci_bus.
- */
-pciio_dmamap_t
-get_free_pciio_dmamap(vertex_hdl_t pci_bus)
-{
-	int i;
-	struct pcibr_dmamap_s *sn_dma_map = NULL;
-
-	/*
-	 * Darn, we need to get the maps allocated for this bus.
-	 */
-	for (i = 0; i < MAX_PCI_XWIDGET; i++) {
-		if (busnum_to_pcibr_vhdl[i] == pci_bus) {
-			sn_dma_map = busnum_to_atedmamaps[i];
-		}
-	}
-
-	/*
-	 * Now get a free dmamap entry from this list.
-	 */
-	for (i = 0; i < MAX_ATE_MAPS; i++, sn_dma_map++) {
-		if (!sn_dma_map->bd_dma_addr) {
-			sn_dma_map->bd_dma_addr = -1;
-			return( (pciio_dmamap_t) sn_dma_map );
-		}
-	}
-
-	return NULL;
-}
-
-/**
- * free_pciio_dmamap - free an ATE
- * @dma_map: ATE to free
- *
- * Frees the ATE specified by @dma_map.
- */
-void
-free_pciio_dmamap(pcibr_dmamap_t dma_map)
-{
-	dma_map->bd_dma_addr = 0;
-}
-
-/**
- * find_sn_dma_map - find an ATE associated with @dma_addr and @busnum
- * @dma_addr: DMA address to look for
- * @busnum: PCI bus to look on
- *
- * Finds the ATE associated with @dma_addr and @busnum.
- */
-static struct pcibr_dmamap_s *
-find_sn_dma_map(dma_addr_t dma_addr, unsigned char busnum)
-{
-
-	struct pcibr_dmamap_s *sn_dma_map = NULL;
-	int i;
-
-	sn_dma_map = busnum_to_atedmamaps[busnum];
-
-	for (i = 0; i < MAX_ATE_MAPS; i++, sn_dma_map++) {
-		if (sn_dma_map->bd_dma_addr == dma_addr) {
-			return sn_dma_map;
-		}
-	}
-
-	return NULL;
-}
-
-/**
- * sn_pci_alloc_consistent - allocate memory for coherent DMA
- * @hwdev: device to allocate for
- * @size: size of the region
- * @dma_handle: DMA (bus) address
- *
- * pci_alloc_consistent() returns a pointer to a memory region suitable for
- * coherent DMA traffic to/from a PCI device.  On SN platforms, this means
- * that @dma_handle will have the %PCIIO_DMA_CMD flag set.
- *
- * This interface is usually used for "command" streams (e.g. the command
- * queue for a SCSI controller).  See Documentation/DMA-mapping.txt for
- * more information.
- *
- * Also known as platform_pci_alloc_consistent() by the IA64 machvec code.
- */
-void *
-sn_pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle)
-{
-        void *cpuaddr;
-	vertex_hdl_t vhdl;
-	struct sn_device_sysdata *device_sysdata;
-	unsigned long phys_addr;
-	pcibr_dmamap_t dma_map = 0;
-
-	/*
-	 * Get hwgraph vertex for the device
-	 */
-	device_sysdata = SN_DEVICE_SYSDATA(hwdev);
-	vhdl = device_sysdata->vhdl;
-
-	/*
-	 * Allocate the memory.
-	 * FIXME: We should be doing alloc_pages_node for the node closest
-	 *        to the PCI device.
-	 */
-	if (!(cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size))))
-		return NULL;
-
-	memset(cpuaddr, 0x0, size);
-
-	/* physical addr. of the memory we just got */
-	phys_addr = __pa(cpuaddr);
-
-	/*
-	 * 64 bit address translations should never fail.
-	 * 32 bit translations can fail if there are insufficient mapping
-	 *   resources and the direct map is already wired to a different
-	 *   2GB range.
-	 * 32 bit translations can also return a > 32 bit address, because
-	 *   pcibr_dmatrans_addr ignores a missing PCIIO_DMA_A64 flag on
-	 *   PCI-X buses.
-	 */
-	if (hwdev->dev.coherent_dma_mask == ~0UL)
-		*dma_handle = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size,
-					  PCIIO_DMA_CMD | PCIIO_DMA_A64);
-	else {
-		dma_map = pcibr_dmamap_alloc(vhdl, NULL, size, PCIIO_DMA_CMD | 
-					     MINIMAL_ATE_FLAG(phys_addr, size));
-		if (dma_map) {
-			*dma_handle = (dma_addr_t)
-				pcibr_dmamap_addr(dma_map, phys_addr, size);
-			dma_map->bd_dma_addr = *dma_handle;
-		}
-		else {
-			*dma_handle = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size,
-						  PCIIO_DMA_CMD);
-		}
-	}
-
-	if (!*dma_handle || *dma_handle > hwdev->dev.coherent_dma_mask) {
-		if (dma_map) {
-			pcibr_dmamap_done(dma_map);
-			pcibr_dmamap_free(dma_map);
-		}
-		free_pages((unsigned long) cpuaddr, get_order(size));
-		return NULL;
-	}
-
-        return cpuaddr;
-}
-
-/**
- * sn_pci_free_consistent - free memory associated with coherent DMAable region
- * @hwdev: device to free for
- * @size: size to free
- * @vaddr: kernel virtual address to free
- * @dma_handle: DMA address associated with this region
- *
- * Frees the memory allocated by pci_alloc_consistent().  Also known
- * as platform_pci_free_consistent() by the IA64 machvec code.
- */
-void
-sn_pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle)
-{
-	struct pcibr_dmamap_s *dma_map = NULL;
-
-	/*
-	 * Get the sn_dma_map entry.
-	 */
-	if (IS_PCI32_MAPPED(dma_handle))
-		dma_map = find_sn_dma_map(dma_handle, hwdev->bus->number);
-
-	/*
-	 * and free it if necessary...
-	 */
-	if (dma_map) {
-		pcibr_dmamap_done(dma_map);
-		pcibr_dmamap_free(dma_map);
-	}
-	free_pages((unsigned long) vaddr, get_order(size));
-}
-
-/**
- * sn_pci_map_sg - map a scatter-gather list for DMA
- * @hwdev: device to map for
- * @sg: scatterlist to map
- * @nents: number of entries
- * @direction: direction of the DMA transaction
- *
- * Maps each entry of @sg for DMA.  Also known as platform_pci_map_sg by the
- * IA64 machvec code.
- */
-int
-sn_pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
-{
-	int i;
-	vertex_hdl_t vhdl;
-	unsigned long phys_addr;
-	struct sn_device_sysdata *device_sysdata;
-	pcibr_dmamap_t dma_map;
-	struct scatterlist *saved_sg = sg;
-	unsigned dma_flag;
-
-	/* can't go anywhere w/o a direction in life */
-	if (direction == PCI_DMA_NONE)
-		BUG();
-
-	/*
-	 * Get the hwgraph vertex for the device
-	 */
-	device_sysdata = SN_DEVICE_SYSDATA(hwdev);
-	vhdl = device_sysdata->vhdl;
-
-	/*
-	 * 64 bit DMA mask can use direct translations
-	 * PCI only
-	 *   32 bit DMA mask might be able to use direct, otherwise use dma map
-	 * PCI-X
-	 *   only 64 bit DMA mask supported; both direct and dma map will fail
-	 */
-	if (hwdev->dma_mask == ~0UL)
-		dma_flag = PCIIO_DMA_DATA | PCIIO_DMA_A64;
-	else
-		dma_flag = PCIIO_DMA_DATA;
-
-	/*
-	 * Setup a DMA address for each entry in the
-	 * scatterlist.
-	 */
-	for (i = 0; i < nents; i++, sg++) {
-		phys_addr = __pa((unsigned long)page_address(sg->page) + sg->offset);
-		sg->dma_address = pcibr_dmatrans_addr(vhdl, NULL, phys_addr,
-					       sg->length, dma_flag);
-		if (sg->dma_address) {
-			sg->dma_length = sg->length;
-			continue;
-		}
-
-		dma_map = pcibr_dmamap_alloc(vhdl, NULL, sg->length,
-			PCIIO_DMA_DATA|MINIMAL_ATE_FLAG(phys_addr, sg->length));
-		if (!dma_map) {
-			printk(KERN_ERR "sn_pci_map_sg: Unable to allocate "
-			       "anymore 32 bit page map entries.\n");
-			/*
-			 * We will need to free all previously allocated entries.
-			 */
-			if (i > 0) {
-				sn_pci_unmap_sg(hwdev, saved_sg, i, direction);
-			}
-			return (0);
-		}
-
-		sg->dma_address = pcibr_dmamap_addr(dma_map, phys_addr, sg->length);
-		sg->dma_length = sg->length;
-		dma_map->bd_dma_addr = sg->dma_address;
-	}
-
-	return nents;
-
-}
-
-/**
- * sn_pci_unmap_sg - unmap a scatter-gather list
- * @hwdev: device to unmap
- * @sg: scatterlist to unmap
- * @nents: number of scatterlist entries
- * @direction: DMA direction
- *
- * Unmap a set of streaming mode DMA translations.  Again, cpu read rules
- * concerning calls here are the same as for pci_unmap_single() below.  Also
- * known as sn_pci_unmap_sg() by the IA64 machvec code.
- */
-void
-sn_pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
-{
-	int i;
-	struct pcibr_dmamap_s *dma_map;
-
-	/* can't go anywhere w/o a direction in life */
-	if (direction == PCI_DMA_NONE)
-		BUG();
-
-	for (i = 0; i < nents; i++, sg++){
-
-		if (IS_PCI32_MAPPED(sg->dma_address)) {
-                	dma_map = find_sn_dma_map(sg->dma_address, hwdev->bus->number);
-        		if (dma_map) {
-                		pcibr_dmamap_done(dma_map);
-                		pcibr_dmamap_free(dma_map);
-			}
-        	}
-
-		sg->dma_address = (dma_addr_t)NULL;
-		sg->dma_length = 0;
-	}
-}
-
-/**
- * sn_pci_map_single - map a single region for DMA
- * @hwdev: device to map for
- * @ptr: kernel virtual address of the region to map
- * @size: size of the region
- * @direction: DMA direction
- *
- * Map the region pointed to by @ptr for DMA and return the
- * DMA address.   Also known as platform_pci_map_single() by
- * the IA64 machvec code.
- *
- * We map this to the one step pcibr_dmamap_trans interface rather than
- * the two step pcibr_dmamap_alloc/pcibr_dmamap_addr because we have
- * no way of saving the dmamap handle from the alloc to later free
- * (which is pretty much unacceptable).
- *
- * TODO: simplify our interface;
- *       get rid of dev_desc and vhdl (seems redundant given a pci_dev);
- *       figure out how to save dmamap handle so can use two step.
- */
-dma_addr_t
-sn_pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
-{
-	vertex_hdl_t vhdl;
-	dma_addr_t dma_addr;
-	unsigned long phys_addr;
-	struct sn_device_sysdata *device_sysdata;
-	pcibr_dmamap_t dma_map = NULL;
-	unsigned dma_flag;
-
-	if (direction == PCI_DMA_NONE)
-		BUG();
-
-	/*
-	 * find vertex for the device
-	 */
-	device_sysdata = SN_DEVICE_SYSDATA(hwdev);
-	vhdl = device_sysdata->vhdl;
-
-	phys_addr = __pa(ptr);
-	/*
-	 * 64 bit DMA mask can use direct translations
-	 * PCI only
-	 *   32 bit DMA mask might be able to use direct, otherwise use dma map
-	 * PCI-X
-	 *   only 64 bit DMA mask supported; both direct and dma map will fail
-	 */
-	if (hwdev->dma_mask == ~0UL)
-		dma_flag = PCIIO_DMA_DATA | PCIIO_DMA_A64;
-	else
-		dma_flag = PCIIO_DMA_DATA;
-
-	dma_addr = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size, dma_flag);
-	if (dma_addr)
-		return dma_addr;
-
-	/*
-	 * It's a 32 bit card and we cannot do direct mapping so
-	 * let's use the PMU instead.
-	 */
-	dma_map = NULL;
-	dma_map = pcibr_dmamap_alloc(vhdl, NULL, size, PCIIO_DMA_DATA | 
-				     MINIMAL_ATE_FLAG(phys_addr, size));
-
-	/* PMU out of entries */
-	if (!dma_map)
-		return 0;
-
-	dma_addr = (dma_addr_t) pcibr_dmamap_addr(dma_map, phys_addr, size);
-	dma_map->bd_dma_addr = dma_addr;
-
-	return ((dma_addr_t)dma_addr);
-}
-
-/**
- * sn_pci_unmap_single - unmap a region used for DMA
- * @hwdev: device to unmap
- * @dma_addr: DMA address to unmap
- * @size: size of region
- * @direction: DMA direction
- *
- * Unmaps the region pointed to by @dma_addr.  Also known as
- * platform_pci_unmap_single() by the IA64 machvec code.
- */
-void
-sn_pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction)
-{
-	struct pcibr_dmamap_s *dma_map = NULL;
-
-        if (direction == PCI_DMA_NONE)
-		BUG();
-
-	/*
-	 * Get the sn_dma_map entry.
-	 */
-	if (IS_PCI32_MAPPED(dma_addr))
-		dma_map = find_sn_dma_map(dma_addr, hwdev->bus->number);
-
-	/*
-	 * and free it if necessary...
-	 */
-	if (dma_map) {
-		pcibr_dmamap_done(dma_map);
-		pcibr_dmamap_free(dma_map);
-	}
-}
-
-/**
- * sn_pci_dma_sync_single_* - make sure all DMAs or CPU accesses
- * have completed
- * @hwdev: device to sync
- * @dma_handle: DMA address to sync
- * @size: size of region
- * @direction: DMA direction
- *
- * This routine is supposed to sync the DMA region specified
- * by @dma_handle into the 'coherence domain'.  We do not need to do 
- * anything on our platform.
- */
-void
-sn_pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle, size_t size, int direction)
-{
-	return;
-}
-
-void
-sn_pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle, size_t size, int direction)
-{
-	return;
-}
-
-/**
- * sn_pci_dma_sync_sg_* - make sure all DMAs or CPU accesses have completed
- * @hwdev: device to sync
- * @sg: scatterlist to sync
- * @nents: number of entries in the scatterlist
- * @direction: DMA direction
- *
- * This routine is supposed to sync the DMA regions specified
- * by @sg into the 'coherence domain'.  We do not need to do anything 
- * on our platform.
- */
-void
-sn_pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
-{
-	return;
-}
-
-void
-sn_pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
-{
-	return;
-}
-
-/**
- * sn_dma_supported - test a DMA mask
- * @hwdev: device to test
- * @mask: DMA mask to test
- *
- * Return whether the given PCI device DMA address mask can be supported
- * properly.  For example, if your device can only drive the low 24-bits
- * during PCI bus mastering, then you would pass 0x00ffffff as the mask to
- * this function.  Of course, SN only supports devices that have 32 or more
- * address bits when using the PMU.  We could theoretically support <32 bit
- * cards using direct mapping, but we'll worry about that later--on the off
- * chance that someone actually wants to use such a card.
- */
-int
-sn_pci_dma_supported(struct pci_dev *hwdev, u64 mask)
-{
-	if (mask < 0xffffffff)
-		return 0;
-	return 1;
-}
-
-/*
- * New generic DMA routines just wrap sn2 PCI routines until we
- * support other bus types (if ever).
- */
-
-int
-sn_dma_supported(struct device *dev, u64 mask)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	return sn_pci_dma_supported(to_pci_dev(dev), mask);
-}
-EXPORT_SYMBOL(sn_dma_supported);
-
-int
-sn_dma_set_mask(struct device *dev, u64 dma_mask)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	if (!sn_dma_supported(dev, dma_mask))
-		return 0;
-
-	*dev->dma_mask = dma_mask;
-	return 1;
-}
-EXPORT_SYMBOL(sn_dma_set_mask);
-
-void *
-sn_dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
-		   int flag)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	return sn_pci_alloc_consistent(to_pci_dev(dev), size, dma_handle);
-}
-EXPORT_SYMBOL(sn_dma_alloc_coherent);
-
-void
-sn_dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
-		    dma_addr_t dma_handle)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	sn_pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
-}
-EXPORT_SYMBOL(sn_dma_free_coherent);
-
-dma_addr_t
-sn_dma_map_single(struct device *dev, void *cpu_addr, size_t size,
-	       int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	return sn_pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_map_single);
-
-void
-sn_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
-		 int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	sn_pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_unmap_single);
-
-dma_addr_t
-sn_dma_map_page(struct device *dev, struct page *page,
-	     unsigned long offset, size_t size,
-	     int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_map_page);
-
-void
-sn_dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
-	       int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_unmap_page);
-
-int
-sn_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
-	   int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	return sn_pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_map_sg);
-
-void
-sn_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
-	     int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	sn_pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_unmap_sg);
-
-void
-sn_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
-			   int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	sn_pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle, size, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_sync_single_for_cpu);
-
-void
-sn_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
-		int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	sn_pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle, size, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_sync_single_for_device);
-
-void
-sn_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
-	    int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	sn_pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg, nelems, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_sync_sg_for_cpu);
-
-void
-sn_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
-	    int direction)
-{
-	BUG_ON(dev->bus != &pci_bus_type);
-
-	sn_pci_dma_sync_sg_for_device(to_pci_dev(dev), sg, nelems, (int)direction);
-}
-EXPORT_SYMBOL(sn_dma_sync_sg_for_device);
-
-int
-sn_dma_mapping_error(dma_addr_t dma_addr)
-{
-	/*
-	 * We can only run out of page mapping entries, so if there's
-	 * an error, tell the caller to try again later.
-	 */
-	if (!dma_addr)
-		return -EAGAIN;
-	return 0;
-}
-
-EXPORT_SYMBOL(sn_dma_mapping_error);
-EXPORT_SYMBOL(sn_pci_unmap_single);
-EXPORT_SYMBOL(sn_pci_map_single);
-EXPORT_SYMBOL(sn_pci_dma_sync_single_for_cpu);
-EXPORT_SYMBOL(sn_pci_dma_sync_single_for_device);
-EXPORT_SYMBOL(sn_pci_dma_sync_sg_for_cpu);
-EXPORT_SYMBOL(sn_pci_dma_sync_sg_for_device);
-EXPORT_SYMBOL(sn_pci_map_sg);
-EXPORT_SYMBOL(sn_pci_unmap_sg);
-EXPORT_SYMBOL(sn_pci_alloc_consistent);
-EXPORT_SYMBOL(sn_pci_free_consistent);
-EXPORT_SYMBOL(sn_pci_dma_supported);
-
diff -Nru a/arch/ia64/sn/io/platform_init/Makefile b/arch/ia64/sn/io/platform_init/Makefile
--- a/arch/ia64/sn/io/platform_init/Makefile	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,10 +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) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# Makefile for the sn2 io routines.
-
-obj-y				+=  sgi_io_init.o
diff -Nru a/arch/ia64/sn/io/platform_init/sgi_io_init.c b/arch/ia64/sn/io/platform_init/sgi_io_init.c
--- a/arch/ia64/sn/io/platform_init/sgi_io_init.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,174 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/config.h>
-#include <linux/slab.h>
-#include <linux/smp.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/pda.h>
-
-extern void init_all_devices(void);
-extern void klhwg_add_all_modules(vertex_hdl_t);
-extern void klhwg_add_all_nodes(vertex_hdl_t);
-
-extern int init_hcl(void);
-extern vertex_hdl_t hwgraph_root;
-extern void io_module_init(void);
-extern int pci_bus_to_hcl_cvlink(void);
-
-nasid_t console_nasid = (nasid_t) - 1;
-char master_baseio_wid;
-
-nasid_t master_baseio_nasid;
-nasid_t master_nasid = INVALID_NASID;	/* This is the partition master nasid */
-
-/*
- * per_hub_init
- *
- * 	This code is executed once for each Hub chip.
- */
-static void __init
-per_hub_init(cnodeid_t cnode)
-{
-	nasid_t nasid;
-	nodepda_t *npdap;
-	ii_icmr_u_t ii_icmr;
-	ii_ibcr_u_t ii_ibcr;
-	ii_ilcsr_u_t ii_ilcsr;
-
-	nasid = cnodeid_to_nasid(cnode);
-
-	ASSERT(nasid != INVALID_NASID);
-	ASSERT(nasid_to_cnodeid(nasid) == cnode);
-
-	npdap = NODEPDA(cnode);
-
-	/* Disable the request and reply errors. */
-	REMOTE_HUB_S(nasid, IIO_IWEIM, 0xC000);
-
-	/*
-	 * Set the total number of CRBs that can be used.
-	 */
-	ii_icmr.ii_icmr_regval = 0x0;
-	ii_icmr.ii_icmr_fld_s.i_c_cnt = 0xf;
-	if (enable_shub_wars_1_1()) {
-		// Set bit one of ICMR to prevent II from sending interrupt for II bug.
-		ii_icmr.ii_icmr_regval |= 0x1;
-	}
-	REMOTE_HUB_S(nasid, IIO_ICMR, ii_icmr.ii_icmr_regval);
-
-	/*
-	 * Set the number of CRBs that both of the BTEs combined
-	 * can use minus 1.
-	 */
-	ii_ibcr.ii_ibcr_regval = 0x0;
-	ii_ilcsr.ii_ilcsr_regval = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
-	if (ii_ilcsr.ii_ilcsr_fld_s.i_llp_stat & LNK_STAT_WORKING) {
-		ii_ibcr.ii_ibcr_fld_s.i_count = 0x8;
-	} else {
-		/*
-		 * if the LLP is down, there is no attached I/O, so
-		 * give BTE all the CRBs.
-		 */
-		ii_ibcr.ii_ibcr_fld_s.i_count = 0x14;
-	}
-	REMOTE_HUB_S(nasid, IIO_IBCR, ii_ibcr.ii_ibcr_regval);
-
-	/*
-	 * Set CRB timeout to be 10ms.
-	 */
-	REMOTE_HUB_S(nasid, IIO_ICTP, 0xffffff);
-	REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
-
-	/* Initialize error interrupts for this hub. */
-	hub_error_init(cnode);
-}
-
-/*
- * This routine is responsible for the setup of all the IRIX hwgraph style
- * stuff that's been pulled into linux.  It's called by sn_pci_find_bios which
- * is called just before the generic Linux PCI layer does its probing (by 
- * platform_pci_fixup aka sn_pci_fixup).
- *
- * It is very IMPORTANT that this call is only made by the Master CPU!
- *
- */
-
-void __init
-sgi_master_io_infr_init(void)
-{
-	cnodeid_t cnode;
-
-	if (init_hcl() < 0) {	/* Sets up the hwgraph compatibility layer */
-		printk("sgi_master_io_infr_init: Cannot init hcl\n");
-		return;
-	}
-
-	/*
-	 * Initialize platform-dependent vertices in the hwgraph:
-	 *      module
-	 *      node
-	 *      cpu
-	 *      memory
-	 *      slot
-	 *      hub
-	 *      router
-	 *      xbow
-	 */
-
-	io_module_init();	/* Use to be called module_init() .. */
-	klhwg_add_all_modules(hwgraph_root);
-	klhwg_add_all_nodes(hwgraph_root);
-
-	for (cnode = 0; cnode < numionodes; cnode++)
-		per_hub_init(cnode);
-
-	/*
-	 *
-	 * Our IO Infrastructure drivers are in place .. 
-	 * Initialize the whole IO Infrastructure .. xwidget/device probes.
-	 *
-	 */
-	init_all_devices();
-	pci_bus_to_hcl_cvlink();
-}
-
-inline int
-check_nasid_equiv(nasid_t nasida, nasid_t nasidb)
-{
-	if ((nasida == nasidb)
-	    || (nasida == NODEPDA(nasid_to_cnodeid(nasidb))->xbow_peer))
-		return 1;
-	else
-		return 0;
-}
-
-int
-is_master_baseio_nasid_widget(nasid_t test_nasid, xwidgetnum_t test_wid)
-{
-	/*
-	 * If the widget numbers are different, we're not the master.
-	 */
-	if (test_wid != (xwidgetnum_t) master_baseio_wid) {
-		return 0;
-	}
-
-	/*
-	 * If the NASIDs are the same or equivalent, we're the master.
-	 */
-	if (check_nasid_equiv(test_nasid, master_baseio_nasid)) {
-		return 1;
-	} else {
-		return 0;
-	}
-}
diff -Nru a/arch/ia64/sn/io/sn2/Makefile b/arch/ia64/sn/io/sn2/Makefile
--- a/arch/ia64/sn/io/sn2/Makefile	2004-12-24 13:37:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,14 +0,0 @@
-# arch/ia64/sn/io/sn2/Makefile
-#
-# 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) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# Makefile for the sn2 specific io routines.
-#
-
-obj-y += pcibr/ ml_SN_intr.o shub_intr.o shuberror.o shub.o bte_error.o \
-	 pic.o geo_op.o l1_command.o klconflib.o klgraph.o ml_SN_init.o \
-	 ml_iograph.o module.o pciio.o xbow.o xtalk.o shubio.o
diff -Nru a/arch/ia64/sn/io/sn2/bte_error.c b/arch/ia64/sn/io/sn2/bte_error.c
--- a/arch/ia64/sn/io/sn2/bte_error.c	2004-12-24 13:37:02 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,217 +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) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
- */
-
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <asm/smp.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/ioerror.h>
-#include <asm/sn/sn2/shubio.h>
-#include <asm/sn/bte.h>
-
-
-/*
- * Bte error handling is done in two parts.  The first captures
- * any crb related errors.  Since there can be multiple crbs per
- * interface and multiple interfaces active, we need to wait until
- * all active crbs are completed.  This is the first job of the
- * second part error handler.  When all bte related CRBs are cleanly
- * completed, it resets the interfaces and gets them ready for new
- * transfers to be queued.
- */
-
-
-void bte_error_handler(unsigned long);
-
-
-/*
- * First part error handler.  This is called whenever any error CRB interrupt
- * is generated by the II.
- */
-void
-bte_crb_error_handler(vertex_hdl_t hub_v, int btenum,
-		      int crbnum, ioerror_t * ioe, int bteop)
-{
-	hubinfo_t hinfo;
-	struct bteinfo_s *bte;
-
-
-	hubinfo_get(hub_v, &hinfo);
-	bte = &hinfo->h_nodepda->bte_if[btenum];
-
-	/*
-	 * The caller has already figured out the error type, we save that
-	 * in the bte handle structure for the thread excercising the
-	 * interface to consume.
-	 */
-	bte->bh_error = ioe->ie_errortype + BTEFAIL_OFFSET;
-	bte->bte_error_count++;
-
-	BTE_PRINTK(("Got an error on cnode %d bte %d: HW error type 0x%x\n",
-		    bte->bte_cnode, bte->bte_num, ioe->ie_errortype));
-	bte_error_handler((unsigned long) hinfo->h_nodepda);
-}
-
-
-/*
- * Second part error handler.  Wait until all BTE related CRBs are completed
- * and then reset the interfaces.
- */
-void
-bte_error_handler(unsigned long _nodepda)
-{
-	struct nodepda_s *err_nodepda = (struct nodepda_s *) _nodepda;
-	spinlock_t *recovery_lock = &err_nodepda->bte_recovery_lock;
-	struct timer_list *recovery_timer = &err_nodepda->bte_recovery_timer;
-	nasid_t nasid;
-	int i;
-	int valid_crbs;
-	unsigned long irq_flags;
-	volatile u64 *notify;
-	bte_result_t bh_error;
-	ii_imem_u_t imem;	/* II IMEM Register */
-	ii_icrb0_d_u_t icrbd;	/* II CRB Register D */
-	ii_ibcr_u_t ibcr;
-	ii_icmr_u_t icmr;
-	ii_ieclr_u_t ieclr;
-
-
-	BTE_PRINTK(("bte_error_handler(%p) - %d\n", err_nodepda,
-		    smp_processor_id()));
-
-	spin_lock_irqsave(recovery_lock, irq_flags);
-
-	if ((err_nodepda->bte_if[0].bh_error == BTE_SUCCESS) &&
-	    (err_nodepda->bte_if[1].bh_error == BTE_SUCCESS)) {
-		BTE_PRINTK(("eh:%p:%d Nothing to do.\n", err_nodepda,
-			    smp_processor_id()));
-		spin_unlock_irqrestore(recovery_lock, irq_flags);
-		return;
-	}
-	/*
-	 * Lock all interfaces on this node to prevent new transfers
-	 * from being queued.
-	 */
-	for (i = 0; i < BTES_PER_NODE; i++) {
-		if (err_nodepda->bte_if[i].cleanup_active) {
-			continue;
-		}
-		spin_lock(&err_nodepda->bte_if[i].spinlock);
-		BTE_PRINTK(("eh:%p:%d locked %d\n", err_nodepda,
-			    smp_processor_id(), i));
-		err_nodepda->bte_if[i].cleanup_active = 1;
-	}
-
-	/* Determine information about our hub */
-	nasid = cnodeid_to_nasid(err_nodepda->bte_if[0].bte_cnode);
-
-
-	/*
-	 * A BTE transfer can use multiple CRBs.  We need to make sure
-	 * that all the BTE CRBs are complete (or timed out) before
-	 * attempting to clean up the error.  Resetting the BTE while
-	 * there are still BTE CRBs active will hang the BTE.
-	 * We should look at all the CRBs to see if they are allocated
-	 * to the BTE and see if they are still active.  When none
-	 * are active, we can continue with the cleanup.
-	 *
-	 * We also want to make sure that the local NI port is up.
-	 * When a router resets the NI port can go down, while it
-	 * goes through the LLP handshake, but then comes back up.
-	 */
-	icmr.ii_icmr_regval = REMOTE_HUB_L(nasid, IIO_ICMR);
-	if (icmr.ii_icmr_fld_s.i_crb_mark != 0) {
-		/*
-		 * There are errors which still need to be cleaned up by
-		 * hubiio_crb_error_handler
-		 */
-		mod_timer(recovery_timer, HZ * 5);
-		BTE_PRINTK(("eh:%p:%d Marked Giving up\n", err_nodepda,
-			    smp_processor_id()));
-		spin_unlock_irqrestore(recovery_lock, irq_flags);
-		return;
-	}
-	if (icmr.ii_icmr_fld_s.i_crb_vld != 0) {
-
-		valid_crbs = icmr.ii_icmr_fld_s.i_crb_vld;
-
-		for (i = 0; i < IIO_NUM_CRBS; i++) {
-			if (!((1 << i) & valid_crbs)) {
-				/* This crb was not marked as valid, ignore */
-				continue;
-			}
-			icrbd.ii_icrb0_d_regval =
-			    REMOTE_HUB_L(nasid, IIO_ICRB_D(i));
-			if (icrbd.d_bteop) {
-				mod_timer(recovery_timer, HZ * 5);
-				BTE_PRINTK(("eh:%p:%d Valid %d, Giving up\n",
-					 err_nodepda, smp_processor_id(), i));
-				spin_unlock_irqrestore(recovery_lock,
-						       irq_flags);
-				return;
-			}
-		}
-	}
-
-
-	BTE_PRINTK(("eh:%p:%d Cleaning up\n", err_nodepda,
-		    smp_processor_id()));
-	/* Reenable both bte interfaces */
-	imem.ii_imem_regval = REMOTE_HUB_L(nasid, IIO_IMEM);
-	imem.ii_imem_fld_s.i_b0_esd = imem.ii_imem_fld_s.i_b1_esd = 1;
-	REMOTE_HUB_S(nasid, IIO_IMEM, imem.ii_imem_regval);
-
-	/* Clear IBLS0/1 error bits */
-	ieclr.ii_ieclr_regval = 0;
-	if (err_nodepda->bte_if[0].bh_error != BTE_SUCCESS)
-		ieclr.ii_ieclr_fld_s.i_e_bte_0 = 1;
-	if (err_nodepda->bte_if[1].bh_error != BTE_SUCCESS)
-                ieclr.ii_ieclr_fld_s.i_e_bte_1 = 1;
-	REMOTE_HUB_S(nasid, IIO_IECLR, ieclr.ii_ieclr_regval);
-
-	/* Reinitialize both BTE state machines. */
-	ibcr.ii_ibcr_regval = REMOTE_HUB_L(nasid, IIO_IBCR);
-	ibcr.ii_ibcr_fld_s.i_soft_reset = 1;
-	REMOTE_HUB_S(nasid, IIO_IBCR, ibcr.ii_ibcr_regval);
-
-
-	for (i = 0; i < BTES_PER_NODE; i++) {
-		bh_error = err_nodepda->bte_if[i].bh_error;
-		if (bh_error != BTE_SUCCESS) {
-			/* There is an error which needs to be notified */
-			notify = err_nodepda->bte_if[i].most_rcnt_na;
-			BTE_PRINTK(("cnode %d bte %d error=0x%lx\n",
-				    err_nodepda->bte_if[i].bte_cnode,
-				    err_nodepda->bte_if[i].bte_num,
-				    IBLS_ERROR | (u64) bh_error));
-			*notify = IBLS_ERROR | bh_error;
-			err_nodepda->bte_if[i].bh_error = BTE_SUCCESS;
-		}
-
-		err_nodepda->bte_if[i].cleanup_active = 0;
-		BTE_PRINTK(("eh:%p:%d Unlocked %d\n", err_nodepda,
-			    smp_processor_id(), i));
-		spin_unlock(&err_nodepda->bte_if[i].spinlock);
-	}
-
-	del_timer(recovery_timer);
-
-	spin_unlock_irqrestore(recovery_lock, irq_flags);
-}
diff -Nru a/arch/ia64/sn/io/sn2/geo_op.c b/arch/ia64/sn/io/sn2/geo_op.c
--- a/arch/ia64/sn/io/sn2/geo_op.c	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,311 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-/*
- * @doc file m:hwcfg
- * DESCRIPTION:
- * 
- * This file contains routines for manipulating and generating 
- * Geographic IDs.  They are in a file by themself since they have
- * no dependencies on other modules.
- *  
- * ORIGIN:
- * 
- * New for SN2
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <asm/smp.h>
-#include <asm/irq.h>
-#include <asm/hw_irq.h>
-#include <asm/sn/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/sn2/shub_mmr_t.h>
-#include <asm/sn/sn2/shubio.h>
-#include <asm/sal.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/module.h>
-#include <asm/sn/geo.h>
-
-/********** Global functions and data (visible outside the module) ***********/
-
-/*
- * @doc gf:geo_module
- * 
- * moduleid_t geo_module(geoid_t g)
- * 
- * DESCRIPTION:
- * 
- * Return the moduleid component of a geoid.
- *  
- * INTERNALS:
- * 
- * Return INVALID_MODULE for an invalid geoid.  Otherwise extract the
- * moduleid from the structure, and return it.
- *   
- * ORIGIN:
- * 
- * New for SN2
- */
-
-moduleid_t
-geo_module(geoid_t g)
-{
-    if (g.any.type == GEO_TYPE_INVALID)
-	return INVALID_MODULE;
-    else
-	return g.any.module;
-}
-
-
-/*
- * @doc gf:geo_slab
- * 
- * slabid_t geo_slab(geoid_t g)
- * 
- * DESCRIPTION:
- * 
- * Return the slabid component of a geoid.
- *  
- * INTERNALS:
- * 
- * Return INVALID_SLAB for an invalid geoid.  Otherwise extract the
- * slabid from the structure, and return it.
- *   
- * ORIGIN:
- * 
- * New for SN2
- */
-
-slabid_t
-geo_slab(geoid_t g)
-{
-    if (g.any.type == GEO_TYPE_INVALID)
-	return INVALID_SLAB;
-    else
-	return g.any.slab;
-}
-
-
-/*
- * @doc gf:geo_type
- * 
- * geo_type_t geo_type(geoid_t g)
- * 
- * DESCRIPTION:
- * 
- * Return the type component of a geoid.
- *  
- * INTERNALS:
- * 
- * Extract the type from the structure, and return it.
- *   
- * ORIGIN:
- * 
- * New for SN2
- */
-
-geo_type_t
-geo_type(geoid_t g)
-{
-    return g.any.type;
-}
-
-
-/*
- * @doc gf:geo_valid
- * 
- * int geo_valid(geoid_t g)
- * 
- * DESCRIPTION:
- * 
- * Return nonzero if g has a valid geoid type.
- *  
- * INTERNALS:
- * 
- * Test the type against GEO_TYPE_INVALID, and return the result.
- *   
- * ORIGIN:
- * 
- * New for SN2
- */
-
-int
-geo_valid(geoid_t g)
-{
-    return g.any.type != GEO_TYPE_INVALID;
-}
-
-
-/*
- * @doc gf:geo_cmp
- * 
- * int geo_cmp(geoid_t g0, geoid_t g1)
- * 
- * DESCRIPTION:
- * 
- * Compare two geoid_t values, from the coarsest field to the finest.
- * The comparison should be consistent with the physical locations of
- * of the hardware named by the geoids.
- *  
- * INTERNALS:
- * 
- * First compare the module, then the slab, type, and type-specific fields.
- *   
- * ORIGIN:
- * 
- * New for SN2
- */
-
-int
-geo_cmp(geoid_t g0, geoid_t g1)
-{
-    int rv;
-
-    /* Compare the common fields */
-    rv = MODULE_CMP(geo_module(g0), geo_module(g1));
-    if (rv != 0)
-	return rv;
-
-    rv = geo_slab(g0) - geo_slab(g1);
-    if (rv != 0)
-	return rv;
-
-    /* Within a slab, sort by type */
-    rv = geo_type(g0) - geo_type(g1);
-    if (rv != 0)
-	return rv;
-
-    switch(geo_type(g0)) {
-    case GEO_TYPE_CPU:
-	rv = g0.cpu.slice - g1.cpu.slice;
-	break;
-
-    case GEO_TYPE_IOCARD:
-	rv = g0.pcicard.bus - g1.pcicard.bus;
-	if (rv) break;
-	rv = SLOTNUM_GETSLOT(g0.pcicard.slot) -
-	    SLOTNUM_GETSLOT(g1.pcicard.slot);
-	break;
-
-    case GEO_TYPE_MEM:
-	rv = g0.mem.membus - g1.mem.membus;
-	if (rv) break;
-	rv = g0.mem.memslot - g1.mem.memslot;
-	break;
-
-    default:
-	rv = 0;
-    }
-
-    return rv;
-}
-
-
-/*
- * @doc gf:geo_new
- * 
- * geoid_t geo_new(geo_type_t type, ...)
- * 
- * DESCRIPTION:
- * 
- * Generate a new geoid_t value of the given type from its components.
- * Expected calling sequences:
- * \@itemize \@bullet
- * \@item
- * \@code\{geo_new(GEO_TYPE_INVALID)\}
- * \@item
- * \@code\{geo_new(GEO_TYPE_MODULE, moduleid_t m)\}
- * \@item
- * \@code\{geo_new(GEO_TYPE_NODE, moduleid_t m, slabid_t s)\}
- * \@item
- * \@code\{geo_new(GEO_TYPE_RTR, moduleid_t m, slabid_t s)\}
- * \@item
- * \@code\{geo_new(GEO_TYPE_IOCNTL, moduleid_t m, slabid_t s)\}
- * \@item
- * \@code\{geo_new(GEO_TYPE_IOCARD, moduleid_t m, slabid_t s, char bus, slotid_t slot)\}
- * \@item
- * \@code\{geo_new(GEO_TYPE_CPU, moduleid_t m, slabid_t s, char slice)\}
- * \@item
- * \@code\{geo_new(GEO_TYPE_MEM, moduleid_t m, slabid_t s, char membus, char slot)\}
- * \@end itemize
- *
- * Invalid types return a GEO_TYPE_INVALID geoid_t.
- *  
- * INTERNALS:
- * 
- * Use the type to determine which fields to expect.  Write the fields into
- * a new geoid_t and return it.  Note:  scalars smaller than an "int" are
- * promoted to "int" by the "..." operator, so we need extra casts on "char",
- * "slotid_t", and "slabid_t".
- *   
- * ORIGIN:
- * 
- * New for SN2
- */
-
-geoid_t
-geo_new(geo_type_t type, ...)
-{
-    va_list al;
-    geoid_t g;
-    memset(&g, 0, sizeof(g));
-
-    va_start(al, type);
-
-    /* Make sure the type is sane */
-    if (type >= GEO_TYPE_MAX)
-	type = GEO_TYPE_INVALID;
-
-    g.any.type = type;
-    if (type == GEO_TYPE_INVALID)
-	goto done;		/* invalid geoids have no components at all */
-
-    g.any.module = va_arg(al, moduleid_t);
-    if (type == GEO_TYPE_MODULE)
-	goto done;
-
-    g.any.slab = (slabid_t)va_arg(al, int);
-
-    /* Some types have additional components */
-    switch(type) {
-    case GEO_TYPE_CPU:
-	g.cpu.slice = (char)va_arg(al, int);
-	break;
-
-    case GEO_TYPE_IOCARD:
-	g.pcicard.bus = (char)va_arg(al, int);
-	g.pcicard.slot = (slotid_t)va_arg(al, int);
-	break;
-
-    case GEO_TYPE_MEM:
-	g.mem.membus = (char)va_arg(al, int);
-	g.mem.memslot = (char)va_arg(al, int);
-	break;
-
-    default:
-	break;
-    }
-
- done:
-    va_end(al);
-    return g;
-}
diff -Nru a/arch/ia64/sn/io/sn2/klconflib.c b/arch/ia64/sn/io/sn2/klconflib.c
--- a/arch/ia64/sn/io/sn2/klconflib.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,572 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-
-#include <linux/types.h>
-#include <linux/ctype.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/nodepda.h>
-#include <asm/sn/module.h>
-#include <asm/sn/router.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/ksys/l1.h>
-
-
-#undef DEBUG_KLGRAPH
-#ifdef DEBUG_KLGRAPH
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...)
-#endif /* DEBUG_KLGRAPH */
-
-extern int numionodes;
-
-lboard_t *root_lboard[MAX_COMPACT_NODES];
-static int hasmetarouter;
-
-
-char brick_types[MAX_BRICK_TYPES + 1] = "crikxdpn%#=vo^34567890123456789...";
-
-lboard_t *
-find_lboard_any(lboard_t *start, unsigned char brd_type)
-{
-	/* Search all boards stored on this node. */
-	while (start) {
-		if (start->brd_type == brd_type)
-			return start;
-		start = KLCF_NEXT_ANY(start);
-	}
-
-	/* Didn't find it. */
-	return (lboard_t *)NULL;
-}
-
-lboard_t *
-find_lboard_nasid(lboard_t *start, nasid_t nasid, unsigned char brd_type)
-{
-
-	while (start) {
-		if ((start->brd_type == brd_type) && 
-		    (start->brd_nasid == nasid))
-			return start;
-
-		if (numionodes == numnodes)
-			start = KLCF_NEXT_ANY(start);
-		else
-			start = KLCF_NEXT(start);
-	}
-
-	/* Didn't find it. */
-	return (lboard_t *)NULL;
-}
-
-lboard_t *
-find_lboard_class_any(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_ANY(start);
-	}
-
-	/* Didn't find it. */
-	return (lboard_t *)NULL;
-}
-
-lboard_t *
-find_lboard_class_nasid(lboard_t *start, nasid_t nasid, unsigned char brd_type)
-{
-	/* Search all boards stored on this node. */
-	while (start) {
-		if (KLCLASS(start->brd_type) == KLCLASS(brd_type) && 
-		    (start->brd_nasid == nasid))
-			return start;
-
-		if (numionodes == numnodes)
-			start = KLCF_NEXT_ANY(start);
-		else
-			start = KLCF_NEXT(start);
-	}
-
-	/* Didn't find it. */
-	return (lboard_t *)NULL;
-}
-
-
-
-klinfo_t *
-find_component(lboard_t *brd, klinfo_t *kli, unsigned char struct_type)
-{
-	int index, j;
-
-	if (kli == (klinfo_t *)NULL) {
-		index = 0;
-	} else {
-		for (j = 0; j < KLCF_NUM_COMPS(brd); j++) {
-			if (kli == KLCF_COMP(brd, j))
-				break;
-		}
-		index = j;
-		if (index == KLCF_NUM_COMPS(brd)) {
-			DBG("find_component: Bad pointer: 0x%p\n", kli);
-			return (klinfo_t *)NULL;
-		}
-		index++;	/* next component */
-	}
-	
-	for (; index < KLCF_NUM_COMPS(brd); index++) {		
-		kli = KLCF_COMP(brd, index);
-		DBG("find_component: brd %p kli %p  request type = 0x%x kli type 0x%x\n", brd, kli, kli->struct_type, KLCF_COMP_TYPE(kli));
-		if (KLCF_COMP_TYPE(kli) == struct_type)
-			return kli;
-	}
-
-	/* Didn't find it. */
-	return (klinfo_t *)NULL;
-}
-
-klinfo_t *
-find_first_component(lboard_t *brd, unsigned char struct_type)
-{
-	return find_component(brd, (klinfo_t *)NULL, struct_type);
-}
-
-lboard_t *
-find_lboard_modslot(lboard_t *start, geoid_t geoid)
-{
-	/* Search all boards stored on this node. */
-	while (start) {
-		if (geo_cmp(start->brd_geoid, geoid))
-			return start;
-		start = KLCF_NEXT(start);
-	}
-
-	/* Didn't find it. */
-	return (lboard_t *)NULL;
-}
-
-/*
- * Convert a NIC name to a name for use in the hardware graph.
- */
-void
-nic_name_convert(char *old_name, char *new_name)
-{
-        int i;
-        char c;
-        char *compare_ptr;
-
-	if ((old_name[0] == '\0') || (old_name[1] == '\0')) {
-                strcpy(new_name, EDGE_LBL_XWIDGET);
-        } else {
-                for (i = 0; i < strlen(old_name); i++) {
-                        c = old_name[i];
-
-                        if (isalpha(c))
-                                new_name[i] = tolower(c);
-                        else if (isdigit(c))
-                                new_name[i] = c;
-                        else
-                                new_name[i] = '_';
-                }
-                new_name[i] = '\0';
-        }
-
-        /* XXX -
-         * Since a bunch of boards made it out with weird names like
-         * IO6-fibbbed and IO6P2, we need to look for IO6 in a name and
-         * replace it with "baseio" to avoid confusion in the field.
-	 * We also have to make sure we don't report media_io instead of
-	 * baseio.
-         */
-
-        /* Skip underscores at the beginning of the name */
-        for (compare_ptr = new_name; (*compare_ptr) == '_'; compare_ptr++)
-                ;
-
-	/*
-	 * Check for some names we need to replace.  Early boards
-	 * had junk following the name so check only the first
-	 * characters.
-	 */
-        if (!strncmp(new_name, "io6", 3) || 
-            !strncmp(new_name, "mio", 3) || 
-	    !strncmp(new_name, "media_io", 8))
-		strcpy(new_name, "baseio");
-	else if (!strncmp(new_name, "divo", 4))
-		strcpy(new_name, "divo") ;
-
-}
-
-/*
- * get_actual_nasid
- *
- *	Completely disabled brds have their klconfig on 
- *	some other nasid as they have no memory. But their
- *	actual nasid is hidden in the klconfig. Use this
- *	routine to get it. Works for normal boards too.
- */
-nasid_t
-get_actual_nasid(lboard_t *brd)
-{
-	klhub_t	*hub ;
-
-	if (!brd)
-		return INVALID_NASID ;
-
-	/* find out if we are a completely disabled brd. */
-
-        hub  = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
-	if (!hub)
-                return INVALID_NASID ;
-	if (!(hub->hub_info.flags & KLINFO_ENABLE))	/* disabled node brd */
-		return hub->hub_info.physid ;
-	else
-		return brd->brd_nasid ;
-}
-
-int
-xbow_port_io_enabled(nasid_t nasid, int link)
-{
-	lboard_t *brd;
-	klxbow_t *xbow_p;
-
-	/*
-	 * look for boards that might contain an xbow or xbridge
-	 */
-	brd = find_lboard_nasid((lboard_t *)KL_CONFIG_INFO(nasid), nasid, KLTYPE_IOBRICK_XBOW);
-	if (brd == NULL) return 0;
-		
-	if ((xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW))
-	    == NULL)
-	    return 0;
-
-	if (!XBOW_PORT_TYPE_IO(xbow_p, link) || !XBOW_PORT_IS_ENABLED(xbow_p, link))
-	    return 0;
-
-	return 1;
-}
-
-void
-board_to_path(lboard_t *brd, char *path)
-{
-	moduleid_t modnum;
-	char *board_name;
-	char buffer[16];
-
-	ASSERT(brd);
-
-	switch (KLCLASS(brd->brd_type)) {
-
-		case KLCLASS_NODE:
-			board_name = EDGE_LBL_NODE;
-			break;
-		case KLCLASS_ROUTER:
-			if (brd->brd_type == KLTYPE_META_ROUTER) {
-				board_name = EDGE_LBL_META_ROUTER;
-				hasmetarouter++;
-			} else if (brd->brd_type == KLTYPE_REPEATER_ROUTER) {
-				board_name = EDGE_LBL_REPEATER_ROUTER;
-				hasmetarouter++;
-			} else
-				board_name = EDGE_LBL_ROUTER;
-			break;
-		case KLCLASS_MIDPLANE:
-			board_name = EDGE_LBL_MIDPLANE;
-			break;
-		case KLCLASS_IO:
-			board_name = EDGE_LBL_IO;
-			break;
-		case KLCLASS_IOBRICK:
-			if (brd->brd_type == KLTYPE_PXBRICK)
-				board_name = EDGE_LBL_PXBRICK;
-			else if (brd->brd_type == KLTYPE_IXBRICK)
-				board_name = EDGE_LBL_IXBRICK;
-			else if (brd->brd_type == KLTYPE_OPUSBRICK)
-				board_name = EDGE_LBL_OPUSBRICK;
-			else if (brd->brd_type == KLTYPE_CGBRICK)
-				board_name = EDGE_LBL_CGBRICK;
-			else 
-				board_name = EDGE_LBL_IOBRICK;
-			break;
-		default:
-			board_name = EDGE_LBL_UNKNOWN;
-	}
-			
-	modnum = geo_module(brd->brd_geoid);
-	memset(buffer, 0, 16);
-	format_module_id(buffer, modnum, MODULE_FORMAT_BRIEF);
-	sprintf(path, EDGE_LBL_MODULE "/%s/" EDGE_LBL_SLAB "/%d/%s", buffer, geo_slab(brd->brd_geoid), board_name);
-}
-
-#define MHZ	1000000
-
-/*
- * Get the serial number of the main  component of a board
- * Returns 0 if a valid serial number is found
- * 1 otherwise.
- * Assumptions: Nic manufacturing string  has the following format
- *			*Serial:<serial_number>;*
- */
-static int
-component_serial_number_get(lboard_t 		*board,
-			    klconf_off_t 	mfg_nic_offset,
-			    char		*serial_number,
-			    char		*key_pattern)
-{
-
-	char	*mfg_nic_string;
-	char	*serial_string,*str;
-	int	i;
-	char	*serial_pattern = "Serial:";
-
-	/* We have an error on a null mfg nic offset */
-	if (!mfg_nic_offset)
-		return(1);
-	/* Get the hub's manufacturing nic information
-	 * which is in the form of a pre-formatted string
-	 */
-	mfg_nic_string = 
-		(char *)NODE_OFFSET_TO_K0(NASID_GET(board),
-					  mfg_nic_offset);
-	/* There is no manufacturing nic info */
-	if (!mfg_nic_string)
-		return(1);
-
-	str = mfg_nic_string;
-	/* Look for the key pattern first (if it is  specified)
-	 * and then print the serial number corresponding to that.
-	 */
-	if (strcmp(key_pattern,"") && 
-	    !(str = strstr(mfg_nic_string,key_pattern)))
-		return(1);
-
-	/* There is no serial number info in the manufacturing
-	 * nic info
-	 */
-	if (!(serial_string = strstr(str,serial_pattern)))
-		return(1);
-
-	serial_string = serial_string + strlen(serial_pattern);
-	/*  Copy the serial number information from the klconfig */
-	i = 0;
-	while (serial_string[i] != ';') {
-		serial_number[i] = serial_string[i];
-		i++;
-	}
-	serial_number[i] = 0;
-	
-	return(0);
-}
-/*
- * Get the serial number of a board
- * Returns 0 if a valid serial number is found
- * 1 otherwise.
- */
-
-int
-board_serial_number_get(lboard_t *board,char *serial_number)
-{
-	ASSERT(board && serial_number);
-	if (!board || !serial_number)
-		return(1);
-
-	strcpy(serial_number,"");
-	switch(KLCLASS(board->brd_type)) {
-	case KLCLASS_CPU: {	/* Node board */
-		klhub_t	*hub;
-		
-		/* Get the hub component information */
-		hub = (klhub_t *)find_first_component(board,
-						      KLSTRUCT_HUB);
-		/* If we don't have a hub component on an IP27
-		 * then we have a weird klconfig.
-		 */
-		if (!hub)
-			return(1);
-		/* Get the serial number information from
-		 * the hub's manufacturing nic info
-		 */
-		if (component_serial_number_get(board,
-						hub->hub_mfg_nic,
-						serial_number,
-						"IP37"))
-				return(1);
-		break;
-	}
-	case KLCLASS_IO: {	/* IO board */
-	     	klbri_t	*bridge;
-		
-		/* Get the bridge component information */
-		bridge = (klbri_t *)find_first_component(board,
-							 KLSTRUCT_BRI);
-		/* If we don't have a bridge component on an IO board
-		 * then we have a weird klconfig.
-		 */
-		if (!bridge)
-			return(1);
-		/* Get the serial number information from
-	 	 * the bridge's manufacturing nic info
-		 */
-		if (component_serial_number_get(board,
-					bridge->bri_mfg_nic,
-					serial_number, ""))
-			return(1);
-		break;
-	}
-	case KLCLASS_ROUTER: {	/* Router board */
-		klrou_t *router;	
-		
-		/* Get the router component information */
-		router = (klrou_t *)find_first_component(board,
-							 KLSTRUCT_ROU);
-		/* If we don't have a router component on a router board
-		 * then we have a weird klconfig.
-		 */
-		if (!router)
-			return(1);
-		/* Get the serial number information from
-		 * the router's manufacturing nic info
-		 */
-		if (component_serial_number_get(board,
-						router->rou_mfg_nic,
-						serial_number,
-						""))
-			return(1);
-		break;
-	}
-	case KLCLASS_GFX: {	/* Gfx board */
-		klgfx_t *graphics;
-		
-		/* Get the graphics component information */
-		graphics = (klgfx_t *)find_first_component(board, KLSTRUCT_GFX);
-		/* If we don't have a gfx component on a gfx board
-		 * then we have a weird klconfig.
-		 */
-		if (!graphics)
-			return(1);
-		/* Get the serial number information from
-		 * the graphics's manufacturing nic info
-		 */
-		if (component_serial_number_get(board,
-						graphics->gfx_mfg_nic,
-						serial_number,
-						""))
-			return(1);
-		break;
-	}
-	default:
-		strcpy(serial_number,"");
-		break;
-	}
-	return(0);
-}
-
-/*
- * Format a module id for printing.
- *
- * There are three possible formats:
- *
- *   MODULE_FORMAT_BRIEF	is the brief 6-character format, including
- *				the actual brick-type as recorded in the 
- *				moduleid_t, eg. 002c15 for a C-brick, or
- *				101#17 for a PX-brick.
- *
- *   MODULE_FORMAT_LONG		is the hwgraph format, eg. rack/002/bay/15
- *				of rack/101/bay/17 (note that the brick
- *				type does not appear in this format).
- *
- *   MODULE_FORMAT_LCD		is like MODULE_FORMAT_BRIEF, except that it
- *				ensures that the module id provided appears
- *				exactly as it would on the LCD display of
- *				the corresponding brick, eg. still 002c15
- *				for a C-brick, but 101p17 for a PX-brick.
- */
-void
-format_module_id(char *buffer, moduleid_t m, int fmt)
-{
-	int rack, position;
-	unsigned char brickchar;
-
-	rack = MODULE_GET_RACK(m);
-	ASSERT(MODULE_GET_BTYPE(m) < MAX_BRICK_TYPES);
-	brickchar = MODULE_GET_BTCHAR(m);
-
-	if (fmt == MODULE_FORMAT_LCD) {
-	    /* Be sure we use the same brick type character as displayed
-	     * on the brick's LCD
-	     */
-	    switch (brickchar) 
-	    {
-	    case L1_BRICKTYPE_PX:
-		brickchar = L1_BRICKTYPE_P;
-		break;
-
-	    case L1_BRICKTYPE_IX:
-		brickchar = L1_BRICKTYPE_I;
-		break;
-	    }
-	}
-
-	position = MODULE_GET_BPOS(m);
-
-	if ((fmt == MODULE_FORMAT_BRIEF) || (fmt == MODULE_FORMAT_LCD)) {
-	    /* Brief module number format, eg. 002c15 */
-
-	    /* Decompress the rack number */
-	    *buffer++ = '0' + RACK_GET_CLASS(rack);
-	    *buffer++ = '0' + RACK_GET_GROUP(rack);
-	    *buffer++ = '0' + RACK_GET_NUM(rack);
-
-	    /* Add the brick type */
-	    *buffer++ = brickchar;
-	}
-	else if (fmt == MODULE_FORMAT_LONG) {
-	    /* Fuller hwgraph format, eg. rack/002/bay/15 */
-
-	    strcpy(buffer, EDGE_LBL_RACK "/");  buffer += strlen(buffer);
-
-	    *buffer++ = '0' + RACK_GET_CLASS(rack);
-	    *buffer++ = '0' + RACK_GET_GROUP(rack);
-	    *buffer++ = '0' + RACK_GET_NUM(rack);
-
-	    strcpy(buffer, "/" EDGE_LBL_RPOS "/");  buffer += strlen(buffer);
-	}
-
-	/* Add the bay position, using at least two digits */
-	if (position < 10)
-	    *buffer++ = '0';
-	sprintf(buffer, "%d", position);
-
-}
-
-int
-cbrick_type_get_nasid(nasid_t nasid)
-{
-	moduleid_t module;
-	int t;
-
-	module = iomoduleid_get(nasid);
-	if (module < 0 ) {
-		return MODULE_CBRICK;
-	}
-	t = MODULE_GET_BTYPE(module);
-	if ((char)t == 'o') {
-		return MODULE_OPUSBRICK;
-	} else {
-		return MODULE_CBRICK;
-	}
-	return -1;
-}
diff -Nru a/arch/ia64/sn/io/sn2/klgraph.c b/arch/ia64/sn/io/sn2/klgraph.c
--- a/arch/ia64/sn/io/sn2/klgraph.c	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,577 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-/*
- * klgraph.c-
- *      This file specifies the interface between the kernel and the PROM's
- *      configuration data structures.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/sn_private.h>
-
-/* #define KLGRAPH_DEBUG 1 */
-#ifdef KLGRAPH_DEBUG
-#define GRPRINTF(x)	printk x
-#else
-#define GRPRINTF(x)
-#endif
-
-void mark_cpuvertex_as_cpu(vertex_hdl_t vhdl, cpuid_t cpuid);
-
-
-/* ARGSUSED */
-static void __init
-klhwg_add_hub(vertex_hdl_t node_vertex, klhub_t *hub, cnodeid_t cnode)
-{
-	vertex_hdl_t myhubv;
-	vertex_hdl_t hub_mon;
-	int rc;
-	extern struct file_operations shub_mon_fops;
-
-	hwgraph_path_add(node_vertex, EDGE_LBL_HUB, &myhubv);
-
-	HWGRAPH_DEBUG(__FILE__, __FUNCTION__,__LINE__, myhubv, NULL, "Created path for hub vertex for Shub node.\n");
-
-	rc = device_master_set(myhubv, node_vertex);
-	if (rc) {
-		printk("klhwg_add_hub: Unable to create hub vertex.\n");
-		return;
-	}
-	hub_mon = hwgraph_register(myhubv, EDGE_LBL_PERFMON,
-		0, 0, 0, 0,
-		S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
-		&shub_mon_fops, (void *)(long)cnode);
-}
-
-/* ARGSUSED */
-static void __init
-klhwg_add_disabled_cpu(vertex_hdl_t node_vertex, cnodeid_t cnode, klcpu_t *cpu, slotid_t slot)
-{
-        vertex_hdl_t my_cpu;
-        char name[120];
-        cpuid_t cpu_id;
-	nasid_t nasid;
-
-	nasid = cnodeid_to_nasid(cnode);
-        cpu_id = nasid_slice_to_cpuid(nasid, cpu->cpu_info.physid);
-        if(cpu_id != -1){
-		snprintf(name, 120, "%s/%s/%c", EDGE_LBL_DISABLED, EDGE_LBL_CPU, 'a' + cpu->cpu_info.physid);
-		(void) hwgraph_path_add(node_vertex, name, &my_cpu);
-
-		HWGRAPH_DEBUG(__FILE__, __FUNCTION__,__LINE__, my_cpu, NULL, "Created path for disabled cpu slice.\n");
-
-		mark_cpuvertex_as_cpu(my_cpu, cpu_id);
-		device_master_set(my_cpu, node_vertex);
-		return;
-        }
-}
-
-/* ARGSUSED */
-static void __init
-klhwg_add_cpu(vertex_hdl_t node_vertex, cnodeid_t cnode, klcpu_t *cpu)
-{
-        vertex_hdl_t my_cpu, cpu_dir;
-        char name[120];
-        cpuid_t cpu_id;
-	nasid_t nasid;
-
-	nasid = cnodeid_to_nasid(cnode);
-        cpu_id = nasid_slice_to_cpuid(nasid, cpu->cpu_info.physid);
-
-        snprintf(name, 120, "%s/%d/%c",
-                EDGE_LBL_CPUBUS,
-                0,
-                'a' + cpu->cpu_info.physid);
-
-        (void) hwgraph_path_add(node_vertex, name, &my_cpu);
-
-	HWGRAPH_DEBUG(__FILE__, __FUNCTION__,__LINE__, my_cpu, NULL, "Created path for active cpu slice.\n");
-
-	mark_cpuvertex_as_cpu(my_cpu, cpu_id);
-        device_master_set(my_cpu, node_vertex);
-
-        /* Add an alias under the node's CPU directory */
-        if (hwgraph_edge_get(node_vertex, EDGE_LBL_CPU, &cpu_dir) == GRAPH_SUCCESS) {
-                snprintf(name, 120, "%c", 'a' + cpu->cpu_info.physid);
-                (void) hwgraph_edge_add(cpu_dir, my_cpu, name);
-		HWGRAPH_DEBUG(__FILE__, __FUNCTION__,__LINE__, cpu_dir, my_cpu, "Created % from vhdl1 to vhdl2.\n", name);
-        }
-}
-
-
-static void __init
-klhwg_add_xbow(cnodeid_t cnode, nasid_t nasid)
-{
-	lboard_t *brd;
-	klxbow_t *xbow_p;
-	nasid_t hub_nasid;
-	cnodeid_t hub_cnode;
-	int widgetnum;
-	vertex_hdl_t xbow_v, hubv;
-	/*REFERENCED*/
-	graph_error_t err;
-
-	if (!(brd = find_lboard_nasid((lboard_t *)KL_CONFIG_INFO(nasid), 
-			nasid, KLTYPE_IOBRICK_XBOW)))
-		return;
-
-	if (KL_CONFIG_DUPLICATE_BOARD(brd))
-	    return;
-
-	if ((xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW))
-	    == NULL)
-	    return;
-
-	for (widgetnum = HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {
-		if (!XBOW_PORT_TYPE_HUB(xbow_p, widgetnum)) 
-		    continue;
-
-		hub_nasid = XBOW_PORT_NASID(xbow_p, widgetnum);
-		if (hub_nasid == INVALID_NASID) {
-			printk(KERN_WARNING  "hub widget %d, skipping xbow graph\n", widgetnum);
-			continue;
-		}
-
-		hub_cnode = nasid_to_cnodeid(hub_nasid);
-
-		if (hub_cnode == INVALID_CNODEID) {
-			continue;
-		}
-			
-		hubv = cnodeid_to_vertex(hub_cnode);
-
-		err = hwgraph_path_add(hubv, EDGE_LBL_XTALK, &xbow_v);
-                if (err != GRAPH_SUCCESS) {
-                        if (err == GRAPH_DUP)
-                                printk(KERN_WARNING  "klhwg_add_xbow: Check for "
-                                        "working routers and router links!");
-
-                        printk("klhwg_add_xbow: Failed to add "
-                                "edge: vertex 0x%p to vertex 0x%p,"
-                                "error %d\n",
-                                (void *)hubv, (void *)xbow_v, err);
-			return;
-                }
-
-		HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, xbow_v, NULL, "Created path for xtalk.\n");
-
-		xswitch_vertex_init(xbow_v); 
-
-		NODEPDA(hub_cnode)->xbow_vhdl = xbow_v;
-
-		/*
-		 * XXX - This won't work is we ever hook up two hubs
-		 * by crosstown through a crossbow.
-		 */
-		if (hub_nasid != nasid) {
-			NODEPDA(hub_cnode)->xbow_peer = nasid;
-			NODEPDA(nasid_to_cnodeid(nasid))->xbow_peer =
-				hub_nasid;
-		}
-	}
-}
-
-
-/* ARGSUSED */
-static void __init
-klhwg_add_node(vertex_hdl_t hwgraph_root, cnodeid_t cnode)
-{
-	nasid_t nasid;
-	lboard_t *brd;
-	klhub_t *hub;
-	vertex_hdl_t node_vertex = NULL;
-	char path_buffer[100];
-	int rv;
-	char *s;
-	int board_disabled = 0;
-	klcpu_t *cpu;
-	vertex_hdl_t cpu_dir;
-
-	nasid = cnodeid_to_nasid(cnode);
-	brd = find_lboard_any((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
-	ASSERT(brd);
-
-	/* Generate a hardware graph path for this board. */
-	board_to_path(brd, path_buffer);
-	rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);
-	if (rv != GRAPH_SUCCESS) {
-		printk("Node vertex creation failed.  Path == %s", path_buffer);
-		return;
-	}
-
-	HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, node_vertex, NULL, "Created path for SHUB node.\n");
-	hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
-	ASSERT(hub);
-	if(hub->hub_info.flags & KLINFO_ENABLE)
-		board_disabled = 0;
-	else
-		board_disabled = 1;
-		
-	if(!board_disabled) {
-		mark_nodevertex_as_node(node_vertex, cnode);
-		s = dev_to_name(node_vertex, path_buffer, sizeof(path_buffer));
-		NODEPDA(cnode)->hwg_node_name =
-					kmalloc(strlen(s) + 1, GFP_KERNEL);
-		if (NODEPDA(cnode)->hwg_node_name <= 0) {
-			printk("%s: no memory\n", __FUNCTION__);
-			return;
-		}
-		strcpy(NODEPDA(cnode)->hwg_node_name, s);
-		hubinfo_set(node_vertex, NODEPDA(cnode)->pdinfo);
-		NODEPDA(cnode)->slotdesc = brd->brd_slot;
-		NODEPDA(cnode)->geoid = brd->brd_geoid;
-		NODEPDA(cnode)->module = module_lookup(geo_module(brd->brd_geoid));
-		klhwg_add_hub(node_vertex, hub, cnode);
-	}
-
-	/*
-	 * If there's at least 1 CPU, add a "cpu" directory to represent
-	 * the collection of all CPUs attached to this node.
-	 */
-	cpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU);
-	if (cpu) {
-		graph_error_t rv;
-
-		rv = hwgraph_path_add(node_vertex, EDGE_LBL_CPU, &cpu_dir);
-		if (rv != GRAPH_SUCCESS) {
-			printk("klhwg_add_node: Cannot create CPU directory\n");
-			return;
-		}
-		HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, cpu_dir, NULL, "Created cpu directiry on SHUB node.\n");
-
-	}
-
-	while (cpu) {
-		cpuid_t cpu_id;
-		cpu_id = nasid_slice_to_cpuid(nasid,cpu->cpu_info.physid);
-		if (cpu_online(cpu_id))
-			klhwg_add_cpu(node_vertex, cnode, cpu);
-		else
-			klhwg_add_disabled_cpu(node_vertex, cnode, cpu, brd->brd_slot);
-
-		cpu = (klcpu_t *)
-			find_component(brd, (klinfo_t *)cpu, KLSTRUCT_CPU);
-	}
-}
-
-
-/* ARGSUSED */
-static void __init
-klhwg_add_all_routers(vertex_hdl_t hwgraph_root)
-{
-	nasid_t nasid;
-	cnodeid_t cnode;
-	lboard_t *brd;
-	vertex_hdl_t node_vertex;
-	char path_buffer[100];
-	int rv;
-
-	for (cnode = 0; cnode < numnodes; cnode++) {
-		nasid = cnodeid_to_nasid(cnode);
-		brd = find_lboard_class_any((lboard_t *)KL_CONFIG_INFO(nasid),
-				KLTYPE_ROUTER);
-
-		if (!brd)
-			/* No routers stored in this node's memory */
-			continue;
-
-		do {
-			ASSERT(brd);
-
-			/* Don't add duplicate boards. */
-			if (brd->brd_flags & DUPLICATE_BOARD)
-				continue;
-
-			/* Generate a hardware graph path for this board. */
-			board_to_path(brd, path_buffer);
-
-			/* Add the router */
-			rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);
-			if (rv != GRAPH_SUCCESS) {
-				printk("Router vertex creation "
-						  "failed.  Path == %s", path_buffer);
-				return;
-			}
-			HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, node_vertex, NULL, "Created router path.\n");
-
-		/* Find the rest of the routers stored on this node. */
-		} while ( (brd = find_lboard_class_any(KLCF_NEXT_ANY(brd),
-			 KLTYPE_ROUTER)) );
-	}
-
-}
-
-/* ARGSUSED */
-static void __init
-klhwg_connect_one_router(vertex_hdl_t hwgraph_root, lboard_t *brd,
-			 cnodeid_t cnode, nasid_t nasid)
-{
-	klrou_t *router;
-	char path_buffer[50];
-	char dest_path[50];
-	vertex_hdl_t router_hndl;
-	vertex_hdl_t dest_hndl;
-	int rc;
-	int port;
-	lboard_t *dest_brd;
-
-	/* Don't add duplicate boards. */
-	if (brd->brd_flags & DUPLICATE_BOARD) {
-		return;
-	}
-
-	/* Generate a hardware graph path for this board. */
-	board_to_path(brd, path_buffer);
-
-	rc = hwgraph_traverse(hwgraph_root, path_buffer, &router_hndl);
-
-	if (rc != GRAPH_SUCCESS)
-			return;
-
-	if (rc != GRAPH_SUCCESS)
-		printk(KERN_WARNING  "Can't find router: %s", path_buffer);
-
-	/* We don't know what to do with multiple router components */
-	if (brd->brd_numcompts != 1) {
-		printk("klhwg_connect_one_router: %d cmpts on router\n",
-			brd->brd_numcompts);
-		return;
-	}
-
-
-	/* Convert component 0 to klrou_t ptr */
-	router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd),
-					      brd->brd_compts[0]);
-
-	for (port = 1; port <= MAX_ROUTER_PORTS; port++) {
-		/* See if the port's active */
-		if (router->rou_port[port].port_nasid == INVALID_NASID) {
-			GRPRINTF(("klhwg_connect_one_router: port %d inactive.\n",
-				 port));
-			continue;
-		}
-		if (nasid_to_cnodeid(router->rou_port[port].port_nasid) 
-		    == INVALID_CNODEID) {
-			continue;
-		}
-
-		dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(
-				router->rou_port[port].port_nasid,
-				router->rou_port[port].port_offset);
-
-		/* Generate a hardware graph path for this board. */
-		board_to_path(dest_brd, dest_path);
-
-		rc = hwgraph_traverse(hwgraph_root, dest_path, &dest_hndl);
-
-		if (rc != GRAPH_SUCCESS) {
-			if (KL_CONFIG_DUPLICATE_BOARD(dest_brd))
-				continue;
-			printk("Can't find router: %s", dest_path);
-			return;
-		}
-
-		sprintf(dest_path, "%d", port);
-
-		rc = hwgraph_edge_add(router_hndl, dest_hndl, dest_path);
-
-		if (rc == GRAPH_DUP) {
-			GRPRINTF(("Skipping port %d. nasid %d %s/%s\n",
-				  port, router->rou_port[port].port_nasid,
-				  path_buffer, dest_path));
-			continue;
-		}
-
-		if (rc != GRAPH_SUCCESS) {
-			printk("Can't create edge: %s/%s to vertex 0x%p error 0x%x\n",
-				path_buffer, dest_path, (void *)dest_hndl, rc);
-			return;
-		}
-		HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, router_hndl, dest_hndl, "Created edge %s from vhdl1 to vhdl2.\n", dest_path);
-		
-	}
-}
-
-
-static void __init
-klhwg_connect_routers(vertex_hdl_t hwgraph_root)
-{
-	nasid_t nasid;
-	cnodeid_t cnode;
-	lboard_t *brd;
-
-	for (cnode = 0; cnode < numnodes; cnode++) {
-		nasid = cnodeid_to_nasid(cnode);
-		brd = find_lboard_class_any((lboard_t *)KL_CONFIG_INFO(nasid),
-				KLTYPE_ROUTER);
-
-		if (!brd)
-			continue;
-
-		do {
-
-			nasid = cnodeid_to_nasid(cnode);
-
-			klhwg_connect_one_router(hwgraph_root, brd,
-						 cnode, nasid);
-
-		/* Find the rest of the routers stored on this node. */
-		} while ( (brd = find_lboard_class_any(KLCF_NEXT_ANY(brd), KLTYPE_ROUTER)) );
-	}
-}
-
-
-
-static void __init
-klhwg_connect_hubs(vertex_hdl_t hwgraph_root)
-{
-	nasid_t nasid;
-	cnodeid_t cnode;
-	lboard_t *brd;
-	klhub_t *hub;
-	lboard_t *dest_brd;
-	vertex_hdl_t hub_hndl;
-	vertex_hdl_t dest_hndl;
-	char path_buffer[50];
-	char dest_path[50];
-	graph_error_t rc;
-	int port;
-
-	for (cnode = 0; cnode < numionodes; cnode++) {
-		nasid = cnodeid_to_nasid(cnode);
-
-		brd = find_lboard_any((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
-
-		hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
-		ASSERT(hub);
-
-		for (port = 1; port <= MAX_NI_PORTS; port++) {
-			if (hub->hub_port[port].port_nasid == INVALID_NASID) {
-				continue; /* Port not active */
-			}
-
-			if (nasid_to_cnodeid(hub->hub_port[port].port_nasid) == INVALID_CNODEID)
-				continue;
-
-			/* Generate a hardware graph path for this board. */
-			board_to_path(brd, path_buffer);
-			rc = hwgraph_traverse(hwgraph_root, path_buffer, &hub_hndl);
-
-			if (rc != GRAPH_SUCCESS)
-				printk(KERN_WARNING  "Can't find hub: %s", path_buffer);
-
-			dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(
-					hub->hub_port[port].port_nasid,
-					hub->hub_port[port].port_offset);
-
-			/* Generate a hardware graph path for this board. */
-			board_to_path(dest_brd, dest_path);
-
-			rc = hwgraph_traverse(hwgraph_root, dest_path, &dest_hndl);
-
-			if (rc != GRAPH_SUCCESS) {
-				if (KL_CONFIG_DUPLICATE_BOARD(dest_brd))
-					continue;
-				printk("Can't find board: %s", dest_path);
-				return;
-			} else {
-				char buf[1024];
-
-				rc = hwgraph_path_add(hub_hndl, EDGE_LBL_INTERCONNECT, &hub_hndl);
-
-				HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, hub_hndl, NULL, "Created link path.\n");
-
-				sprintf(buf,"%s/%s",path_buffer,EDGE_LBL_INTERCONNECT);
-				rc = hwgraph_traverse(hwgraph_root, buf, &hub_hndl);
-				sprintf(buf,"%d",port);
-				rc = hwgraph_edge_add(hub_hndl, dest_hndl, buf);
-
-				HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, hub_hndl, dest_hndl, "Created edge %s from vhdl1 to vhdl2.\n", buf);
-
-				if (rc != GRAPH_SUCCESS) {
-					printk("Can't create edge: %s/%s to vertex 0x%p, error 0x%x\n",
-							path_buffer, dest_path, (void *)dest_hndl, rc);
-					return;
-				}
-			}
-		}
-	}
-}
-
-void __init
-klhwg_add_all_modules(vertex_hdl_t hwgraph_root)
-{
-	cmoduleid_t	cm;
-	char		name[128];
-	vertex_hdl_t	vhdl;
-	vertex_hdl_t  module_vhdl;
-	int		rc;
-	char		buffer[16];
-
-	/* Add devices under each module */
-
-	for (cm = 0; cm < nummodules; cm++) {
-		/* Use module as module vertex fastinfo */
-
-		memset(buffer, 0, 16);
-		format_module_id(buffer, sn_modules[cm]->id, MODULE_FORMAT_BRIEF);
-		sprintf(name, EDGE_LBL_MODULE "/%s", buffer);
-
-		rc = hwgraph_path_add(hwgraph_root, name, &module_vhdl);
-		ASSERT(rc == GRAPH_SUCCESS);
-		rc = rc;
-		HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, module_vhdl, NULL, "Created module path.\n");
-
-		hwgraph_fastinfo_set(module_vhdl, (arbitrary_info_t) sn_modules[cm]);
-
-		/* Add system controller */
-		sprintf(name,
-			EDGE_LBL_MODULE "/%s/" EDGE_LBL_L1,
-			buffer);
-
-		rc = hwgraph_path_add(hwgraph_root, name, &vhdl);
-		ASSERT_ALWAYS(rc == GRAPH_SUCCESS); 
-		rc = rc;
-		HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, vhdl, NULL, "Created L1 path.\n");
-
-		hwgraph_info_add_LBL(vhdl, INFO_LBL_ELSC,
-				     (arbitrary_info_t)1);
-
-	}
-}
-
-void __init
-klhwg_add_all_nodes(vertex_hdl_t hwgraph_root)
-{
-	cnodeid_t	cnode;
-
-	for (cnode = 0; cnode < numionodes; cnode++) {
-		klhwg_add_node(hwgraph_root, cnode);
-	}
-
-	for (cnode = 0; cnode < numionodes; cnode++) {
-		klhwg_add_xbow(cnode, cnodeid_to_nasid(cnode));
-	}
-
-	/*
-	 * As for router hardware inventory information, we set this
-	 * up in router.c. 
-	 */
-	
-	klhwg_add_all_routers(hwgraph_root);
-	klhwg_connect_routers(hwgraph_root);
-	klhwg_connect_hubs(hwgraph_root);
-}
diff -Nru a/arch/ia64/sn/io/sn2/l1_command.c b/arch/ia64/sn/io/sn2/l1_command.c
--- a/arch/ia64/sn/io/sn2/l1_command.c	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,131 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */ 
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/router.h>
-#include <asm/sn/module.h>
-#include <asm/sn/ksys/l1.h>
-#include <asm/sn/nodepda.h>
-#include <asm/sn/clksupport.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/sn_sal.h>
-#include <linux/ctype.h>
-
-/* elsc_display_line writes up to 12 characters to either the top or bottom
- * line of the L1 display.  line points to a buffer containing the message
- * to be displayed.  The zero-based line number is specified by lnum (so
- * lnum == 0 specifies the top line and lnum == 1 specifies the bottom).
- * Lines longer than 12 characters, or line numbers not less than
- * L1_DISPLAY_LINES, cause elsc_display_line to return an error.
- */
-int elsc_display_line(nasid_t nasid, char *line, int lnum)
-{
-    return 0;
-}
-
-
-/*
- * iobrick routines
- */
-
-/* iobrick_rack_bay_type_get fills in the three int * arguments with the
- * rack number, bay number and brick type of the L1 being addressed.  Note
- * that if the L1 operation fails and this function returns an error value, 
- * garbage may be written to brick_type.
- */
-
-
-int iobrick_rack_bay_type_get( nasid_t nasid, uint *rack, 
-			       uint *bay, uint *brick_type )
-{
-	int result = 0;
-
-	if ( ia64_sn_sysctl_iobrick_module_get(nasid, &result) )
-		return( ELSC_ERROR_CMD_SEND );
-
-	*rack = (result & MODULE_RACK_MASK) >> MODULE_RACK_SHFT;
-	*bay = (result & MODULE_BPOS_MASK) >> MODULE_BPOS_SHFT;
-	*brick_type = (result & MODULE_BTYPE_MASK) >> MODULE_BTYPE_SHFT;
-	return 0;
-}
-
-
-int iomoduleid_get(nasid_t nasid)
-{
-	int result = 0;
-
-	if ( ia64_sn_sysctl_iobrick_module_get(nasid, &result) )
-		return( ELSC_ERROR_CMD_SEND );
-
-	return result;
-}
-
-int
-iobrick_type_get_nasid(nasid_t nasid)
-{
-    uint rack, bay, type;
-    int t, ret;
-    extern char brick_types[];
-
-    if ((ret = iobrick_rack_bay_type_get(nasid, &rack, &bay, &type)) < 0) {
-        return ret;
-    }
-
-    /* convert brick_type to lower case */
-    if ((type >= 'A') && (type <= 'Z'))
-        type = type - 'A' + 'a';
-
-    /* convert to a module.h brick type */
-    for( t = 0; t < MAX_BRICK_TYPES; t++ ) {
-        if( brick_types[t] == type ) {
-            return t;
-	}
-    }
-
-    return -1;    /* unknown brick */
-}
-
-/*
- * given a L1 bricktype, return a bricktype string.  This string is the
- * string that will be used in the hwpath for I/O bricks
- */
-char *
-iobrick_L1bricktype_to_name(int type)
-{
-    switch (type)
-    {
-    default:
-        return("Unknown");
-
-    case L1_BRICKTYPE_PX:
-        return(EDGE_LBL_PXBRICK);
-
-    case L1_BRICKTYPE_OPUS:
-        return(EDGE_LBL_OPUSBRICK);
-
-    case L1_BRICKTYPE_IX:
-        return(EDGE_LBL_IXBRICK);
-
-    case L1_BRICKTYPE_C:
-        return("Cbrick");
-
-    case L1_BRICKTYPE_R:
-        return("Rbrick");
-
-    case L1_BRICKTYPE_CHI_CG:
-        return(EDGE_LBL_CGBRICK);
-    }
-}
-
diff -Nru a/arch/ia64/sn/io/sn2/ml_SN_init.c b/arch/ia64/sn/io/sn2/ml_SN_init.c
--- a/arch/ia64/sn/io/sn2/ml_SN_init.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,109 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/bootmem.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/simulator.h>
-
-int		maxcpus;
-
-extern xwidgetnum_t hub_widget_id(nasid_t);
-
-/* XXX - Move the meat of this to intr.c ? */
-/*
- * Set up the platform-dependent fields in the nodepda.
- */
-void init_platform_nodepda(nodepda_t *npda, cnodeid_t node)
-{
-	hubinfo_t hubinfo;
-	nasid_t nasid;
-
-	/* Allocate per-node platform-dependent data */
-	
-	nasid = cnodeid_to_nasid(node);
-	if (node >= numnodes) /* Headless/memless IO nodes */
-		hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(0), sizeof(struct hubinfo_s));
-	else
-		hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(node), sizeof(struct hubinfo_s));
-
-	npda->pdinfo = (void *)hubinfo;
-	hubinfo->h_nodepda = npda;
-	hubinfo->h_cnodeid = node;
-
-	spin_lock_init(&hubinfo->h_crblock);
-
-	npda->xbow_peer = INVALID_NASID;
-
-	/* 
-	 * Initialize the linked list of
-	 * router info pointers to the dependent routers
-	 */
-	npda->npda_rip_first = NULL;
-
-	/*
-	 * npda_rip_last always points to the place
-	 * where the next element is to be inserted
-	 * into the list 
-	 */
-	npda->npda_rip_last = &npda->npda_rip_first;
-	npda->geoid.any.type = GEO_TYPE_INVALID;
-
-	init_MUTEX_LOCKED(&npda->xbow_sema); /* init it locked? */
-}
-
-void
-init_platform_hubinfo(nodepda_t **nodepdaindr)
-{
-	cnodeid_t       cnode;
-	hubinfo_t hubinfo;
-	nodepda_t *npda;
-	extern int numionodes;
-
-	if (IS_RUNNING_ON_SIMULATOR())
-		return;
-	for (cnode = 0; cnode < numionodes; cnode++) {
-		npda = nodepdaindr[cnode];
-		hubinfo = (hubinfo_t)npda->pdinfo;
-		hubinfo->h_nasid = cnodeid_to_nasid(cnode);
-		hubinfo->h_widgetid = hub_widget_id(hubinfo->h_nasid);
-	}
-}
-
-void
-update_node_information(cnodeid_t cnodeid)
-{
-	nodepda_t *npda = NODEPDA(cnodeid);
-	nodepda_router_info_t *npda_rip;
-	
-	/* Go through the list of router info 
-	 * structures and copy some frequently
-	 * accessed info from the info hanging
-	 * off the corresponding router vertices
-	 */
-	npda_rip = npda->npda_rip_first;
-	while(npda_rip) {
-		if (npda_rip->router_infop) {
-			npda_rip->router_portmask = 
-				npda_rip->router_infop->ri_portmask;
-			npda_rip->router_slot = 
-				npda_rip->router_infop->ri_slotnum;
-		} else {
-			/* No router, no ports. */
-			npda_rip->router_portmask = 0;
-		}
-		npda_rip = npda_rip->router_next;
-	}
-}
diff -Nru a/arch/ia64/sn/io/sn2/ml_SN_intr.c b/arch/ia64/sn/io/sn2/ml_SN_intr.c
--- a/arch/ia64/sn/io/sn2/ml_SN_intr.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,320 +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) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <asm/smp.h>
-#include <asm/irq.h>
-#include <asm/hw_irq.h>
-#include <asm/topology.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/sn2/shub_mmr_t.h>
-#include <asm/sn/sn2/shubio.h>
-#include <asm/sal.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/sn2/shub_mmr.h>
-#include <asm/sn/pda.h>
-
-extern irqpda_t	*irqpdaindr;
-extern cnodeid_t master_node_get(vertex_hdl_t vhdl);
-extern nasid_t master_nasid;
-
-/*  Initialize some shub registers for interrupts, both IO and error. */
-void intr_init_vecblk(cnodeid_t node)
-{
-	int 				nasid = cnodeid_to_nasid(node);
-	sh_ii_int0_config_u_t		ii_int_config;
-	cpuid_t				cpu;
-	cpuid_t				cpu0, cpu1;
-	sh_ii_int0_enable_u_t		ii_int_enable;
-	sh_int_node_id_config_u_t	node_id_config;
-	sh_local_int5_config_u_t	local5_config;
-	sh_local_int5_enable_u_t	local5_enable;
-
-	if (is_headless_node(node) ) {
-		struct ia64_sal_retval ret_stuff;
-		int cnode;
-
-		/* retarget all interrupts on this node to the master node. */
-		node_id_config.sh_int_node_id_config_regval = 0;
-		node_id_config.sh_int_node_id_config_s.node_id = master_nasid;
-		node_id_config.sh_int_node_id_config_s.id_sel = 1;
-		HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_INT_NODE_ID_CONFIG),
-			node_id_config.sh_int_node_id_config_regval);
-		cnode = nasid_to_cnodeid(master_nasid);
-		cpu = first_cpu(node_to_cpumask(cnode));
-		cpu = cpu_physical_id(cpu);
-		SAL_CALL(ret_stuff, SN_SAL_REGISTER_CE, nasid, cpu, master_nasid,0,0,0,0);
-		if (ret_stuff.status < 0)
-			printk("%s: SN_SAL_REGISTER_CE SAL_CALL failed\n",__FUNCTION__);
-	} else {
-		cpu = first_cpu(node_to_cpumask(node));
-		cpu = cpu_physical_id(cpu);
-	}
-
-	/* Get the physical id's of the cpu's on this node. */
-	cpu0 = nasid_slice_to_cpu_physical_id(nasid, 0);
-	cpu1 = nasid_slice_to_cpu_physical_id(nasid, 2);
-
-	HUB_S( (unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_PI_ERROR_MASK), 0);
-	HUB_S( (unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_PI_CRBP_ERROR_MASK), 0);
-
-	/* Config and enable UART interrupt, all nodes. */
-	local5_config.sh_local_int5_config_regval = 0;
-	local5_config.sh_local_int5_config_s.idx = SGI_UART_VECTOR;
-	local5_config.sh_local_int5_config_s.pid = cpu;
-	HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_LOCAL_INT5_CONFIG),
-		local5_config.sh_local_int5_config_regval);
-
-	local5_enable.sh_local_int5_enable_regval = 0;
-	local5_enable.sh_local_int5_enable_s.uart_int = 1;
-	HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_LOCAL_INT5_ENABLE),
-		local5_enable.sh_local_int5_enable_regval);
-
-
-	/* The II_INT_CONFIG register for cpu 0. */
-	ii_int_config.sh_ii_int0_config_regval = 0;
-	ii_int_config.sh_ii_int0_config_s.type = 0;
-	ii_int_config.sh_ii_int0_config_s.agt = 0;
-	ii_int_config.sh_ii_int0_config_s.pid = cpu0;
-	ii_int_config.sh_ii_int0_config_s.base = 0;
-
-	HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_II_INT0_CONFIG),
-		ii_int_config.sh_ii_int0_config_regval);
-
-
-	/* The II_INT_CONFIG register for cpu 1. */
-	ii_int_config.sh_ii_int0_config_regval = 0;
-	ii_int_config.sh_ii_int0_config_s.type = 0;
-	ii_int_config.sh_ii_int0_config_s.agt = 0;
-	ii_int_config.sh_ii_int0_config_s.pid = cpu1;
-	ii_int_config.sh_ii_int0_config_s.base = 0;
-
-	HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_II_INT1_CONFIG),
-		ii_int_config.sh_ii_int0_config_regval);
-
-
-	/* Enable interrupts for II_INT0 and 1. */
-	ii_int_enable.sh_ii_int0_enable_regval = 0;
-	ii_int_enable.sh_ii_int0_enable_s.ii_enable = 1;
-
-	HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_II_INT0_ENABLE),
-		ii_int_enable.sh_ii_int0_enable_regval);
-	HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_II_INT1_ENABLE),
-		ii_int_enable.sh_ii_int0_enable_regval);
-}
-
-static int intr_reserve_level(cpuid_t cpu, int bit)
-{
-	irqpda_t	*irqs = irqpdaindr;
-	int		min_shared;
-	int		i;
-
-	if (bit < 0) {
-		for (i = IA64_SN2_FIRST_DEVICE_VECTOR; i <= IA64_SN2_LAST_DEVICE_VECTOR; i++) {
-			if (irqs->irq_flags[i] == 0) {
-				bit = i;
-				break;
-			}
-		}
-	}
-
-	if (bit < 0) {  /* ran out of irqs.  Have to share.  This will be rare. */
-		min_shared = 256;
-		for (i=IA64_SN2_FIRST_DEVICE_VECTOR; i < IA64_SN2_LAST_DEVICE_VECTOR; i++) {
-			/* Share with the same device class */
-			/* XXX: gross layering violation.. */
-			if (irqpdaindr->curr->vendor == irqpdaindr->device_dev[i]->vendor &&
-				irqpdaindr->curr->device == irqpdaindr->device_dev[i]->device &&
-				irqpdaindr->share_count[i] < min_shared) {
-					min_shared = irqpdaindr->share_count[i];
-					bit = i;
-			}
-		}
-	
-		min_shared = 256;
-		if (bit < 0) {  /* didn't find a matching device, just pick one. This will be */
-				/* exceptionally rare. */
-			for (i=IA64_SN2_FIRST_DEVICE_VECTOR; i < IA64_SN2_LAST_DEVICE_VECTOR; i++) {
-				if (irqpdaindr->share_count[i] < min_shared) {
-					min_shared = irqpdaindr->share_count[i];
-					bit = i;
-				}
-			}
-		}
-		irqpdaindr->share_count[bit]++;
-	}
-
-	if (!(irqs->irq_flags[bit] & SN2_IRQ_SHARED)) {
-		if (irqs->irq_flags[bit] & SN2_IRQ_RESERVED)
-			return -1;
-		irqs->num_irq_used++;
-	}
-
-	irqs->irq_flags[bit] |= SN2_IRQ_RESERVED;
-	return bit;
-}
-
-void intr_unreserve_level(cpuid_t cpu,
-		int bit)
-{
-	irqpda_t	*irqs = irqpdaindr;
-
-	if (irqs->irq_flags[bit] & SN2_IRQ_RESERVED) {
-		irqs->num_irq_used--;
-		irqs->irq_flags[bit] &= ~SN2_IRQ_RESERVED;
-	}
-}
-
-int intr_connect_level(cpuid_t cpu, int bit)
-{
-	irqpda_t	*irqs = irqpdaindr;
-
-	if (!(irqs->irq_flags[bit] & SN2_IRQ_SHARED) &&
-	     (irqs->irq_flags[bit] & SN2_IRQ_CONNECTED))
-		return -1;
- 
-	irqs->irq_flags[bit] |= SN2_IRQ_CONNECTED;
-	return bit;
-}
-
-int intr_disconnect_level(cpuid_t cpu, int bit)
-{
-	irqpda_t	*irqs = irqpdaindr;
-
-	if (!(irqs->irq_flags[bit] & SN2_IRQ_CONNECTED))
-		return -1;
-	irqs->irq_flags[bit] &= ~SN2_IRQ_CONNECTED;
-	return bit;
-}
-
-/*
- * Choose a cpu on this node.
- *
- * We choose the one with the least number of int's assigned to it.
- */
-static cpuid_t intr_cpu_choose_from_node(cnodeid_t cnode)
-{
-	cpuid_t		cpu, best_cpu = CPU_NONE;
-	int		slice, min_count = 1000;
-
-	for (slice = CPUS_PER_NODE - 1; slice >= 0; slice--) {
-		int intrs;
-
-		cpu = cnode_slice_to_cpuid(cnode, slice);
-		if (cpu == NR_CPUS)
-			continue;
-		if (!cpu_online(cpu))
-			continue;
-
-		intrs = pdacpu(cpu)->sn_num_irqs;
-
-		if (min_count > intrs) {
-			min_count = intrs;
-			best_cpu = cpu;
-			if (enable_shub_wars_1_1()) {
-				/*
-				 * Rather than finding the best cpu, always
-				 * return the first cpu.  This forces all
-				 * interrupts to the same cpu
-				 */
-				break;
-			}
-		}
-	}
-	pdacpu(best_cpu)->sn_num_irqs++;
-	return best_cpu;
-}
-
-/*
- * We couldn't put it on the closest node.  Try to find another one.
- * Do a stupid round-robin assignment of the node.
- */
-static cpuid_t intr_cpu_choose_node(void)
-{
-	static cnodeid_t last_node = -1;	/* XXX: racy */
-	cnodeid_t candidate_node;
-	cpuid_t cpuid;
-
-	if (last_node >= numnodes)
-		last_node = 0;
-
-	for (candidate_node = last_node + 1; candidate_node != last_node;
-			candidate_node++) {
-		if (candidate_node == numnodes)
-			candidate_node = 0;
-		cpuid = intr_cpu_choose_from_node(candidate_node);
-		if (cpuid != CPU_NONE)
-			return cpuid;
-	}
-
-	return CPU_NONE;
-}
-
-/*
- * Find the node to assign for this interrupt.
- *
- * SN2 + pcibr addressing limitation:
- *   Due to this limitation, all interrupts from a given bridge must
- *   go to the name node.  The interrupt must also be targetted for
- *   the same processor.  This limitation does not exist on PIC.
- *   But, the processor limitation will stay.  The limitation will be
- *   similar to the bedrock/xbridge limit regarding PI's
- */
-cpuid_t intr_heuristic(vertex_hdl_t dev, int req_bit, int *resp_bit)
-{
-	cpuid_t		cpuid;
-	vertex_hdl_t	pconn_vhdl;
-	pcibr_soft_t	pcibr_soft;
-	int 		bit;
-
-	/* XXX: gross layering violation.. */
-	if (hwgraph_edge_get(dev, EDGE_LBL_PCI, &pconn_vhdl) == GRAPH_SUCCESS) {
-		pcibr_soft = pcibr_soft_get(pconn_vhdl);
-		if (pcibr_soft && pcibr_soft->bsi_err_intr) {
-			/*
-			 * The cpu was chosen already when we assigned
-			 * the error interrupt.
-			 */
-			cpuid = ((hub_intr_t)pcibr_soft->bsi_err_intr)->i_cpuid;
-			goto done;
-		}
-	}
-
-	/*
-	 * Need to choose one.  Try the controlling c-brick first.
-	 */
-	cpuid = intr_cpu_choose_from_node(master_node_get(dev));
-	if (cpuid == CPU_NONE)
-		cpuid = intr_cpu_choose_node();
-
- done:
-	if (cpuid != CPU_NONE) {
-		bit = intr_reserve_level(cpuid, req_bit);
-		if (bit >= 0) {
-			*resp_bit = bit;
-			return cpuid;
-		}
-	}
-
-	printk("Cannot target interrupt to target cpu (%ld).\n", cpuid);
-	return CPU_NONE;
-}
diff -Nru a/arch/ia64/sn/io/sn2/ml_iograph.c b/arch/ia64/sn/io/sn2/ml_iograph.c
--- a/arch/ia64/sn/io/sn2/ml_iograph.c	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,770 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/ctype.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/xtalk/xtalkaddrs.h>
-#include <asm/sn/ksys/l1.h>
-
-/* #define IOGRAPH_DEBUG */
-#ifdef IOGRAPH_DEBUG
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...)
-#endif /* IOGRAPH_DEBUG */
-
-/* At most 2 hubs can be connected to an xswitch */
-#define NUM_XSWITCH_VOLUNTEER 2
-
-/*
- * Track which hubs have volunteered to manage devices hanging off of
- * a Crosstalk Switch (e.g. xbow).  This structure is allocated,
- * initialized, and hung off the xswitch vertex early on when the
- * xswitch vertex is created.
- */
-typedef struct xswitch_vol_s {
-	struct semaphore xswitch_volunteer_mutex;
-	int		xswitch_volunteer_count;
-	vertex_hdl_t	xswitch_volunteer[NUM_XSWITCH_VOLUNTEER];
-} *xswitch_vol_t;
-
-void
-xswitch_vertex_init(vertex_hdl_t xswitch)
-{
-	xswitch_vol_t xvolinfo;
-	int rc;
-
-	xvolinfo = kmalloc(sizeof(struct xswitch_vol_s), GFP_KERNEL);
-	if (!xvolinfo) {
-		printk(KERN_WARNING "xswitch_vertex_init(): Unable to "
-			"allocate memory\n");
-		return;
-	}
-       	memset(xvolinfo, 0, sizeof(struct xswitch_vol_s));
-	init_MUTEX(&xvolinfo->xswitch_volunteer_mutex);
-	rc = hwgraph_info_add_LBL(xswitch, INFO_LBL_XSWITCH_VOL,
-			(arbitrary_info_t)xvolinfo);
-	ASSERT(rc == GRAPH_SUCCESS); rc = rc;
-}
-
-
-/*
- * When assignment of hubs to widgets is complete, we no longer need the
- * xswitch volunteer structure hanging around.  Destroy it.
- */
-static void
-xswitch_volunteer_delete(vertex_hdl_t xswitch)
-{
-	xswitch_vol_t xvolinfo;
-	int rc;
-
-	rc = hwgraph_info_remove_LBL(xswitch, 
-				INFO_LBL_XSWITCH_VOL,
-				(arbitrary_info_t *)&xvolinfo);
-	if (xvolinfo > 0)
-		kfree(xvolinfo);
-}
-/*
- * A Crosstalk master volunteers to manage xwidgets on the specified xswitch.
- */
-/* ARGSUSED */
-static void
-volunteer_for_widgets(vertex_hdl_t xswitch, vertex_hdl_t master)
-{
-	xswitch_vol_t xvolinfo = NULL;
-	vertex_hdl_t hubv;
-	hubinfo_t hubinfo;
-
-	(void)hwgraph_info_get_LBL(xswitch, 
-				INFO_LBL_XSWITCH_VOL, 
-				(arbitrary_info_t *)&xvolinfo);
-	if (xvolinfo == NULL) {
-	    if (!is_headless_node_vertex(master)) {
-		    char name[MAXDEVNAME];
-		    printk(KERN_WARNING
-			"volunteer for widgets: vertex %s has no info label",
-			vertex_to_name(xswitch, name, MAXDEVNAME));
-	    }
-	    return;
-	}
-
-	down(&xvolinfo->xswitch_volunteer_mutex);
-	ASSERT(xvolinfo->xswitch_volunteer_count < NUM_XSWITCH_VOLUNTEER);
-	xvolinfo->xswitch_volunteer[xvolinfo->xswitch_volunteer_count] = master;
-	xvolinfo->xswitch_volunteer_count++;
-
-	/*
-	 * if dual ported, make the lowest widgetid always be 
-	 * xswitch_volunteer[0].
-	 */
-	if (xvolinfo->xswitch_volunteer_count == NUM_XSWITCH_VOLUNTEER) {
-		hubv = xvolinfo->xswitch_volunteer[0];
-		hubinfo_get(hubv, &hubinfo);
-		if (hubinfo->h_widgetid != XBOW_HUBLINK_LOW) {
-			xvolinfo->xswitch_volunteer[0] = 
-						xvolinfo->xswitch_volunteer[1];
-			xvolinfo->xswitch_volunteer[1] = hubv;
-		}
-	}
-	up(&xvolinfo->xswitch_volunteer_mutex);
-}
-
-extern int xbow_port_io_enabled(nasid_t nasid, int widgetnum);
-
-/*
- * Assign all the xwidgets hanging off the specified xswitch to the
- * Crosstalk masters that have volunteered for xswitch duty.
- */
-/* ARGSUSED */
-static void
-assign_widgets_to_volunteers(vertex_hdl_t xswitch, vertex_hdl_t hubv)
-{
-	xswitch_info_t xswitch_info;
-	xswitch_vol_t xvolinfo = NULL;
-	xwidgetnum_t widgetnum;
-	int num_volunteer;
-	nasid_t nasid;
-	hubinfo_t hubinfo;
-	extern int iobrick_type_get_nasid(nasid_t);
-
-
-	hubinfo_get(hubv, &hubinfo);
-	nasid = hubinfo->h_nasid;
-	
-	xswitch_info = xswitch_info_get(xswitch);
-	ASSERT(xswitch_info != NULL);
-
-	(void)hwgraph_info_get_LBL(xswitch, 
-				INFO_LBL_XSWITCH_VOL, 
-				(arbitrary_info_t *)&xvolinfo);
-	if (xvolinfo == NULL) {
-	    if (!is_headless_node_vertex(hubv)) {
-		    char name[MAXDEVNAME];
-		    printk(KERN_WARNING
-			"assign_widgets_to_volunteers:vertex %s has "
-			" no info label",
-			vertex_to_name(xswitch, name, MAXDEVNAME));
-	    }
-	    return;
-	}
-
-	num_volunteer = xvolinfo->xswitch_volunteer_count;
-	ASSERT(num_volunteer > 0);
-
-	/* Assign master hub for xswitch itself.  */
-	if (HUB_WIDGET_ID_MIN > 0) {
-		hubv = xvolinfo->xswitch_volunteer[0];
-		xswitch_info_master_assignment_set(xswitch_info, (xwidgetnum_t)0, hubv);
-	}
-
-	/*
-	 * TBD: Use administrative information to alter assignment of
-	 * widgets to hubs.
-	 */
-	for (widgetnum=HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {
-		int i;
-
-		if (!xbow_port_io_enabled(nasid, widgetnum)) 
-		    continue;
-
-		/*
-		 * If this is the master IO board, assign it to the same 
-		 * hub that owned it in the prom.
-		 */
-		if (is_master_baseio_nasid_widget(nasid, widgetnum)) {
-			extern nasid_t snia_get_master_baseio_nasid(void);
-			for (i=0; i<num_volunteer; i++) {
-				hubv = xvolinfo->xswitch_volunteer[i];
-				hubinfo_get(hubv, &hubinfo);
-				nasid = hubinfo->h_nasid;
-				if (nasid == snia_get_master_baseio_nasid())
-					goto do_assignment;
-			}
-			printk("Nasid == %d, console nasid == %d",
-				nasid, snia_get_master_baseio_nasid());
-			nasid = 0;
-		}
-
-		/*
-		 * Assuming that we're dual-hosted and that PCI cards 
-		 * are naturally placed left-to-right, alternate PCI 
-		 * buses across both Cbricks.   For Pbricks, and Ibricks,
-                 * io_brick_map_widget() returns the PCI bus number
-                 * associated with the given brick type and widget number.
-                 * For Xbricks, it returns the XIO slot number.
-		 */
-
-		i = 0;
-		if (num_volunteer > 1) {
-                        int	       bt;
-
-                       	bt = iobrick_type_get_nasid(nasid);
-                        if (bt >= 0) {
-			        i = io_brick_map_widget(bt, widgetnum) & 1;
-                        }
-                }
-
-		hubv = xvolinfo->xswitch_volunteer[i];
-
-do_assignment:
-		/*
-		 * At this point, we want to make hubv the master of widgetnum.
-		 */
-		xswitch_info_master_assignment_set(xswitch_info, widgetnum, hubv);
-	}
-
-	xswitch_volunteer_delete(xswitch);
-}
-
-/* 
- * Probe to see if this hub's xtalk link is active.  If so,
- * return the Crosstalk Identification of the widget that we talk to.  
- * This is called before any of the Crosstalk infrastructure for 
- * this hub is set up.  It's usually called on the node that we're
- * probing, but not always.
- *
- * TBD: Prom code should actually do this work, and pass through 
- * hwid for our use.
- */
-static void
-early_probe_for_widget(vertex_hdl_t hubv, xwidget_hwid_t hwid)
-{
-	nasid_t nasid;
-	hubinfo_t hubinfo;
-	hubreg_t llp_csr_reg;
-	widgetreg_t widget_id;
-	int result = 0;
-
-	hwid->part_num = XWIDGET_PART_NUM_NONE;
-	hwid->rev_num = XWIDGET_REV_NUM_NONE;
-	hwid->mfg_num = XWIDGET_MFG_NUM_NONE;
-
-	hubinfo_get(hubv, &hubinfo);
-	nasid = hubinfo->h_nasid;
-
-	llp_csr_reg = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
-	if (!(llp_csr_reg & IIO_LLP_CSR_IS_UP))
-		return;
-
-	/* Read the Cross-Talk Widget Id on the other end */
-	result = snia_badaddr_val((volatile void *)
-			(RAW_NODE_SWIN_BASE(nasid, 0x0) + WIDGET_ID), 
-			4, (void *) &widget_id);
-
-	if (result == 0) { /* Found something connected */
-		hwid->part_num = XWIDGET_PART_NUM(widget_id);
-		hwid->rev_num = XWIDGET_REV_NUM(widget_id);
-		hwid->mfg_num = XWIDGET_MFG_NUM(widget_id);
-
-		/* TBD: link reset */
-	} else {
-
-		hwid->part_num = XWIDGET_PART_NUM_NONE;
-		hwid->rev_num = XWIDGET_REV_NUM_NONE;
-		hwid->mfg_num = XWIDGET_MFG_NUM_NONE;
-	}
-}
-
-/*
- * io_xswitch_widget_init
- *	
- */
-
-static void
-io_xswitch_widget_init(vertex_hdl_t  	xswitchv,
-		       vertex_hdl_t	hubv,
-		       xwidgetnum_t	widgetnum)
-{
-	xswitch_info_t		xswitch_info;
-	xwidgetnum_t		hub_widgetid;
-	vertex_hdl_t		widgetv;
-	cnodeid_t		cnode;
-	widgetreg_t		widget_id;
-	nasid_t			nasid, peer_nasid;
-	struct xwidget_hwid_s 	hwid;
-	hubinfo_t		hubinfo;
-	/*REFERENCED*/
-	int			rc;
-	char 			pathname[128];
-	lboard_t		*board = NULL;
-	char			buffer[16];
-	char			bt;
-	moduleid_t		io_module;
-	slotid_t get_widget_slotnum(int xbow, int widget);
-	
-	DBG("\nio_xswitch_widget_init: hubv 0x%p, xswitchv 0x%p, widgetnum 0x%x\n", hubv, xswitchv, widgetnum);
-
-	/*
-	 * Verify that xswitchv is indeed an attached xswitch.
-	 */
-	xswitch_info = xswitch_info_get(xswitchv);
-	ASSERT(xswitch_info != NULL);
-
-	hubinfo_get(hubv, &hubinfo);
-	nasid = hubinfo->h_nasid;
-	cnode = nasid_to_cnodeid(nasid);
-	hub_widgetid = hubinfo->h_widgetid;
-
-	/*
-	 * Check that the widget is an io widget and is enabled
-	 * on this nasid or the `peer' nasid.  The peer nasid
-	 * is the other hub/bedrock connected to the xbow.
-	 */
-	peer_nasid = NODEPDA(cnode)->xbow_peer;
-	if (peer_nasid == INVALID_NASID)
-		/* If I don't have a peer, use myself. */
-		peer_nasid = nasid;
-	if (!xbow_port_io_enabled(nasid, widgetnum) &&
-	    !xbow_port_io_enabled(peer_nasid, widgetnum)) {
-		return;
-	}
-
-	if (xswitch_info_link_ok(xswitch_info, widgetnum)) {
-		char			name[4];
-		lboard_t dummy;
-
-
-		/*
-		 * If the current hub is not supposed to be the master 
-		 * for this widgetnum, then skip this widget.
-		 */
-		if (xswitch_info_master_assignment_get(xswitch_info,
-						       widgetnum) != hubv) {
-			return;
-		}
-
-		board = find_lboard_class_nasid( (lboard_t *)KL_CONFIG_INFO(nasid),
-				nasid, KLCLASS_IOBRICK);
-		if (!board && NODEPDA(cnode)->xbow_peer != INVALID_NASID) {
-		    	board = find_lboard_class_nasid(
-				(lboard_t *)KL_CONFIG_INFO( NODEPDA(cnode)->xbow_peer),
-					NODEPDA(cnode)->xbow_peer, KLCLASS_IOBRICK);
-		}
-
-		if (board) {
-			DBG("io_xswitch_widget_init: Found KLTYPE_IOBRICK Board 0x%p brd_type 0x%x\n", board, board->brd_type);
-		} else {
-			DBG("io_xswitch_widget_init: FIXME did not find IOBOARD\n");
-			board = &dummy;
-		}
-
-
-		/* Copy over the nodes' geoid info */
-		{
-			lboard_t *brd;
-
-			brd = find_lboard_any((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
-			if ( brd != (lboard_t *)0 ) {
-				board->brd_geoid = brd->brd_geoid;
-			}
-		}
-
-		/*
- 		 * Make sure we really want to say xbrick, pbrick,
-		 * etc. rather than XIO, graphics, etc.
- 		 */
-
-		memset(buffer, 0, 16);
-		format_module_id(buffer, geo_module(board->brd_geoid), MODULE_FORMAT_BRIEF);
-
-		sprintf(pathname, EDGE_LBL_MODULE "/%s/" EDGE_LBL_SLAB "/%d" "/%s" "/%s/%d",
-			buffer,
-			geo_slab(board->brd_geoid),
-			(board->brd_type == KLTYPE_PXBRICK) ? EDGE_LBL_PXBRICK :
-			(board->brd_type == KLTYPE_IXBRICK) ? EDGE_LBL_IXBRICK :
-			(board->brd_type == KLTYPE_CGBRICK) ? EDGE_LBL_CGBRICK :
-			(board->brd_type == KLTYPE_OPUSBRICK) ? EDGE_LBL_OPUSBRICK : "?brick",
-			EDGE_LBL_XTALK, widgetnum);
-		
-		DBG("io_xswitch_widget_init: path= %s\n", pathname);
-		rc = hwgraph_path_add(hwgraph_root, pathname, &widgetv);
-		
-		ASSERT(rc == GRAPH_SUCCESS);
-
-		/* This is needed to let the user programs to map the
-		 * module,slot numbers to the corresponding widget numbers
-		 * on the crossbow.
-		 */
-		device_master_set(hwgraph_connectpt_get(widgetv), hubv);
-		sprintf(name, "%d", widgetnum);
-		DBG("io_xswitch_widget_init: FIXME hwgraph_edge_add %s xswitchv 0x%p, widgetv 0x%p\n", name, xswitchv, widgetv);
-		rc = hwgraph_edge_add(xswitchv, widgetv, name);
-		
-		/*
-		 * crosstalk switch code tracks which
-		 * widget is attached to each link.
-		 */
-		xswitch_info_vhdl_set(xswitch_info, widgetnum, widgetv);
-		
-		/*
-		 * Peek at the widget to get its crosstalk part and
-		 * mfgr numbers, then present it to the generic xtalk
-		 * bus provider to have its driver attach routine
-		 * called (or not).
-		 */
-		widget_id = XWIDGET_ID_READ(nasid, widgetnum);
-		hwid.part_num = XWIDGET_PART_NUM(widget_id);
-		hwid.rev_num = XWIDGET_REV_NUM(widget_id);
-		hwid.mfg_num = XWIDGET_MFG_NUM(widget_id);
-
-		(void)xwidget_register(&hwid, widgetv, widgetnum,
-				       hubv, hub_widgetid);
-
-		io_module = iomoduleid_get(nasid);
-		if (io_module >= 0) {
-			char			buffer[16];
-			vertex_hdl_t		to, from;
-			char           		*brick_name;
-			extern char *iobrick_L1bricktype_to_name(int type);
-
-
-			memset(buffer, 0, 16);
-			format_module_id(buffer, geo_module(board->brd_geoid), MODULE_FORMAT_BRIEF);
-
-			if ( isupper(MODULE_GET_BTCHAR(io_module)) ) {
-				bt = tolower(MODULE_GET_BTCHAR(io_module));
-			}
-			else {
-				bt = MODULE_GET_BTCHAR(io_module);
-			}
-
-			brick_name = iobrick_L1bricktype_to_name(bt);
-
-			/* Add a helper vertex so xbow monitoring
-			* can identify the brick type. It's simply
-			* an edge from the widget 0 vertex to the
-			*  brick vertex.
-			*/
-
-			sprintf(pathname, EDGE_LBL_HW "/" EDGE_LBL_MODULE "/%s/"
-				EDGE_LBL_SLAB "/%d/"
-				EDGE_LBL_NODE "/" EDGE_LBL_XTALK "/"
-				"0",
-				buffer, geo_slab(board->brd_geoid));
-			from = hwgraph_path_to_vertex(pathname);
-			ASSERT_ALWAYS(from);
-			sprintf(pathname, EDGE_LBL_HW "/" EDGE_LBL_MODULE "/%s/"
-				EDGE_LBL_SLAB "/%d/"
-				"%s",
-				buffer, geo_slab(board->brd_geoid), brick_name);
-
-			to = hwgraph_path_to_vertex(pathname);
-			ASSERT_ALWAYS(to);
-			rc = hwgraph_edge_add(from, to,
-				EDGE_LBL_INTERCONNECT);
-			if (rc != -EEXIST && rc != GRAPH_SUCCESS) {
-				printk("%s: Unable to establish link"
-					" for xbmon.", pathname);
-			}
-		}
-
-	}
-}
-
-
-static void
-io_init_xswitch_widgets(vertex_hdl_t xswitchv, cnodeid_t cnode)
-{
-	xwidgetnum_t		widgetnum;
-	
-	DBG("io_init_xswitch_widgets: xswitchv 0x%p for cnode %d\n", xswitchv, cnode);
-
-	for (widgetnum = HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; 
-	     widgetnum++) {
-		io_xswitch_widget_init(xswitchv,
-				       cnodeid_to_vertex(cnode),
-				       widgetnum);
-	}
-}
-
-/*
- * Initialize all I/O on the specified node.
- */
-static void
-io_init_node(cnodeid_t cnodeid)
-{
-	/*REFERENCED*/
-	vertex_hdl_t hubv, switchv, widgetv;
-	struct xwidget_hwid_s hwid;
-	hubinfo_t hubinfo;
-	int is_xswitch;
-	nodepda_t	*npdap;
-	struct semaphore *peer_sema = 0;
-	uint32_t	widget_partnum;
-
-	npdap = NODEPDA(cnodeid);
-
-	/*
-	 * Get the "top" vertex for this node's hardware
-	 * graph; it will carry the per-hub hub-specific
-	 * data, and act as the crosstalk provider master.
-	 * It's canonical path is probably something of the
-	 * form /hw/module/%M/slot/%d/node
-	 */
-	hubv = cnodeid_to_vertex(cnodeid);
-	DBG("io_init_node: Initialize IO for cnode %d hubv(node) 0x%p npdap 0x%p\n", cnodeid, hubv, npdap);
-
-	ASSERT(hubv != GRAPH_VERTEX_NONE);
-
-	/* 
-	 * attach our hub_provider information to hubv,
-	 * so we can use it as a crosstalk provider "master"
-	 * vertex.
-	 */
-	xtalk_provider_register(hubv, &hub_provider);
-	xtalk_provider_startup(hubv);
-
-	/* 
-	 * If nothing connected to this hub's xtalk port, we're done.
-	 */
-	early_probe_for_widget(hubv, &hwid);
-	if (hwid.part_num == XWIDGET_PART_NUM_NONE) {
-		DBG("**** io_init_node: Node's 0x%p hub widget has XWIDGET_PART_NUM_NONE ****\n", hubv);
-		return;
-		/* NOTREACHED */
-	}
-
-	/*
-	 * Create a vertex to represent the crosstalk bus
-	 * attached to this hub, and a vertex to be used
-	 * as the connect point for whatever is out there
-	 * on the other side of our crosstalk connection.
-	 *
-	 * Crosstalk Switch drivers "climb up" from their
-	 * connection point to try and take over the switch
-	 * point.
-	 *
-	 * Of course, the edges and verticies may already
-	 * exist, in which case our net effect is just to
-	 * associate the "xtalk_" driver with the connection
-	 * point for the device.
-	 */
-
-	(void)hwgraph_path_add(hubv, EDGE_LBL_XTALK, &switchv);
-
-	DBG("io_init_node: Created 'xtalk' entry to '../node/' xtalk vertex 0x%p\n", switchv);
-
-	ASSERT(switchv != GRAPH_VERTEX_NONE);
-
-	(void)hwgraph_edge_add(hubv, switchv, EDGE_LBL_IO);
-
-	DBG("io_init_node: Created symlink 'io' from ../node/io to ../node/xtalk \n");
-
-	/*
-	 * We need to find the widget id and update the basew_id field
-	 * accordingly. In particular, SN00 has direct connected bridge,
-	 * and hence widget id is Not 0.
-	 */
-	widget_partnum = (((*(volatile int32_t *)(NODE_SWIN_BASE
-			(cnodeid_to_nasid(cnodeid), 0) + 
-			WIDGET_ID))) & WIDGET_PART_NUM) 
-			>> WIDGET_PART_NUM_SHFT;
-
-	if ((widget_partnum == XBOW_WIDGET_PART_NUM) ||
-			(widget_partnum == XXBOW_WIDGET_PART_NUM) ||
-			(widget_partnum == PXBOW_WIDGET_PART_NUM) ) {
-		/* 
-		 * Xbow control register does not have the widget ID field.
-		 * So, hard code the widget ID to be zero.
-		 */
-		DBG("io_init_node: Found XBOW widget_partnum= 0x%x\n", widget_partnum);
-		npdap->basew_id = 0;
-
-	} else {
-		void	*bridge;
-
-		bridge = (void *)NODE_SWIN_BASE(cnodeid_to_nasid(cnodeid), 0);
-		npdap->basew_id = pcireg_bridge_control_get(bridge) & WIDGET_WIDGET_ID;
-
-		printk(" ****io_init_node: Unknown Widget Part Number 0x%x Widget ID 0x%x attached to Hubv 0x%p ****\n", widget_partnum, npdap->basew_id, (void *)hubv);
-		return;
-	}
-	{
-		char widname[10];
-		sprintf(widname, "%x", npdap->basew_id);
-		(void)hwgraph_path_add(switchv, widname, &widgetv);
-		DBG("io_init_node: Created '%s' to '..node/xtalk/' vertex 0x%p\n", widname, widgetv);
-		ASSERT(widgetv != GRAPH_VERTEX_NONE);
-	}
-	
-	nodepda->basew_xc = widgetv;
-
-	is_xswitch = xwidget_hwid_is_xswitch(&hwid);
-
-	/* 
-	 * Try to become the master of the widget.  If this is an xswitch
-	 * with multiple hubs connected, only one will succeed.  Mastership
-	 * of an xswitch is used only when touching registers on that xswitch.
-	 * The slave xwidgets connected to the xswitch can be owned by various
-	 * masters.
-	 */
-	if (device_master_set(widgetv, hubv) == 0) {
-
-		/* Only one hub (thread) per Crosstalk device or switch makes
-		 * it to here.
-		 */
-
-		/* 
-		 * Initialize whatever xwidget is hanging off our hub.
-		 * Whatever it is, it's accessible through widgetnum 0.
-		 */
-		hubinfo_get(hubv, &hubinfo);
-
-		(void)xwidget_register(&hwid, widgetv, npdap->basew_id, hubv, hubinfo->h_widgetid);
-
-		/* 
-		 * Special handling for Crosstalk Switches (e.g. xbow).
-		 * We need to do things in roughly the following order:
-		 *	1) Initialize xswitch hardware (done above)
-		 *	2) Determine which hubs are available to be widget masters
-		 *	3) Discover which links are active from the xswitch
-		 *	4) Assign xwidgets hanging off the xswitch to hubs
-		 *	5) Initialize all xwidgets on the xswitch
-		 */
-
-		volunteer_for_widgets(switchv, hubv);
-
-		/* If there's someone else on this crossbow, recognize him */
-		if (npdap->xbow_peer != INVALID_NASID) {
-			nodepda_t *peer_npdap = NODEPDA(nasid_to_cnodeid(npdap->xbow_peer));
-			peer_sema = &peer_npdap->xbow_sema;
-			volunteer_for_widgets(switchv, peer_npdap->node_vertex);
-		}
-
-		assign_widgets_to_volunteers(switchv, hubv);
-
-		/* Signal that we're done */
-		if (peer_sema) {
-			up(peer_sema);
-		}
-		
-	}
-	else {
-	    /* Wait 'til master is done assigning widgets. */
-	    down(&npdap->xbow_sema);
-	}
-
-	/* Now both nodes can safely inititialize widgets */
-	io_init_xswitch_widgets(switchv, cnodeid);
-
-	DBG("\nio_init_node: DONE INITIALIZED ALL I/O FOR CNODEID %d\n\n", cnodeid);
-}
-
-#include <asm/sn/ioerror_handling.h>
-
-/*
- * Initialize all I/O devices.  Starting closest to nodes, probe and
- * initialize outward.
- */
-void
-init_all_devices(void)
-{
-	cnodeid_t cnodeid, active;
-
-	active = 0;
-	for (cnodeid = 0; cnodeid < numionodes; cnodeid++) {
-                DBG("init_all_devices: Calling io_init_node() for cnode %d\n", cnodeid);
-                io_init_node(cnodeid);
-
-		DBG("init_all_devices: Done io_init_node() for cnode %d\n", cnodeid);
-	}
-
-	for (cnodeid = 0; cnodeid < numnodes; cnodeid++) {
-		/*
-	 	 * Update information generated by IO init.
-		 */
-		update_node_information(cnodeid);
-	}
-}
-
-static
-struct io_brick_map_s io_brick_tab[] = {
-
-/* PXbrick widget number to PCI bus number map */
- {      MODULE_PXBRICK,                         /* PXbrick type   */ 
-    /*  PCI Bus #                                  Widget #       */
-    {   0, 0, 0, 0, 0, 0, 0, 0,                 /* 0x0 - 0x7      */
-        0,                                      /* 0x8            */
-        0,                                      /* 0x9            */
-        0, 0,                                   /* 0xa - 0xb      */
-        1,                                      /* 0xc            */
-        5,                                      /* 0xd            */
-        0,                                      /* 0xe            */
-        3                                       /* 0xf            */
-    }
- },
-
-/* OPUSbrick widget number to PCI bus number map */
- {      MODULE_OPUSBRICK,                       /* OPUSbrick type */ 
-    /*  PCI Bus #                                  Widget #       */
-    {   0, 0, 0, 0, 0, 0, 0, 0,                 /* 0x0 - 0x7      */
-        0,                                      /* 0x8            */
-        0,                                      /* 0x9            */
-        0, 0,                                   /* 0xa - 0xb      */
-        0,                                      /* 0xc            */
-        0,                                      /* 0xd            */
-        0,                                      /* 0xe            */
-        1                                       /* 0xf            */
-    }
- },
-
-/* IXbrick widget number to PCI bus number map */
- {      MODULE_IXBRICK,                         /* IXbrick type   */ 
-    /*  PCI Bus #                                  Widget #       */
-    {   0, 0, 0, 0, 0, 0, 0, 0,                 /* 0x0 - 0x7      */
-        0,                                      /* 0x8            */
-        0,                                      /* 0x9            */
-        0, 0,                                   /* 0xa - 0xb      */
-        1,                                      /* 0xc            */
-        5,                                      /* 0xd            */
-        0,                                      /* 0xe            */
-        3                                       /* 0xf            */
-    }
- },
-
-/* CG brick widget number to PCI bus number map */
- {      MODULE_CGBRICK,				/* CG brick       */
-    /*  PCI Bus #                                  Widget #       */
-    {   0, 0, 0, 0, 0, 0, 0, 0,                 /* 0x0 - 0x7      */
-        0,                                      /* 0x8            */
-        0,                                      /* 0x9            */
-        0, 1,                                   /* 0xa - 0xb      */
-        0,                                      /* 0xc            */
-        0,                                      /* 0xd            */
-        0,                                      /* 0xe            */
-        0                                       /* 0xf            */
-     }
- },
-};
-
-/*
- * Use the brick's type to map a widget number to a meaningful int
- */
-int
-io_brick_map_widget(int brick_type, int widget_num)
-{
-        int num_bricks, i;
-
-        /* Calculate number of bricks in table */
-        num_bricks = sizeof(io_brick_tab)/sizeof(io_brick_tab[0]);
-
-        /* Look for brick prefix in table */
-        for (i = 0; i < num_bricks; i++) {
-               if (brick_type == io_brick_tab[i].ibm_type)
-                       return io_brick_tab[i].ibm_map_wid[widget_num];
-        }
-
-        return 0;
-
-}
diff -Nru a/arch/ia64/sn/io/sn2/module.c b/arch/ia64/sn/io/sn2/module.c
--- a/arch/ia64/sn/io/sn2/module.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,236 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/io.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/module.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/xtalk/xswitch.h>
-#include <asm/sn/nodepda.h>
-#include <asm/sn/sn_cpuid.h>
-
-
-/* #define LDEBUG	1  */
-
-#ifdef LDEBUG
-#define DPRINTF		printk
-#define printf		printk
-#else
-#define DPRINTF(x...)
-#endif
-
-module_t	       *sn_modules[MODULE_MAX];
-int			nummodules;
-
-#define SN00_SERIAL_FUDGE	0x3b1af409d513c2
-#define SN0_SERIAL_FUDGE	0x6e
-
-
-static void __init
-encode_str_serial(const char *src, char *dest)
-{
-    int i;
-
-    for (i = 0; i < MAX_SERIAL_NUM_SIZE; i++) {
-
-	dest[i] = src[MAX_SERIAL_NUM_SIZE/2 +
-		     ((i%2) ? ((i/2 * -1) - 1) : (i/2))] +
-	    SN0_SERIAL_FUDGE;
-    }
-}
-
-module_t * __init 
-module_lookup(moduleid_t id)
-{
-    int			i;
-
-    for (i = 0; i < nummodules; i++)
-	if (sn_modules[i]->id == id) {
-	    DPRINTF("module_lookup: found m=0x%p\n", sn_modules[i]);
-	    return sn_modules[i];
-	}
-
-    return NULL;
-}
-
-/*
- * module_add_node
- *
- *   The first time a new module number is seen, a module structure is
- *   inserted into the module list in order sorted by module number
- *   and the structure is initialized.
- *
- *   The node number is added to the list of nodes in the module.
- */
-static module_t * __init
-module_add_node(geoid_t geoid, cnodeid_t cnodeid)
-{
-    module_t	       *m;
-    int			i;
-    char		buffer[16];
-    moduleid_t		moduleid;
-    slabid_t		slab_number;
-
-    memset(buffer, 0, 16);
-    moduleid = geo_module(geoid);
-    format_module_id(buffer, moduleid, MODULE_FORMAT_BRIEF);
-    DPRINTF("module_add_node: moduleid=%s node=%d\n", buffer, cnodeid);
-
-    if ((m = module_lookup(moduleid)) == 0) {
-	m = kmalloc(sizeof (module_t), GFP_KERNEL);
-	ASSERT_ALWAYS(m);
-	memset(m, 0 , sizeof(module_t));
-
-	for (slab_number = 0; slab_number <= MAX_SLABS; slab_number++) {
-		m->nodes[slab_number] = -1;
-	}
-
-	m->id = moduleid;
-	spin_lock_init(&m->lock);
-
-	/* Insert in sorted order by module number */
-
-	for (i = nummodules; i > 0 && sn_modules[i - 1]->id > moduleid; i--)
-	    sn_modules[i] = sn_modules[i - 1];
-
-	sn_modules[i] = m;
-	nummodules++;
-    }
-
-    /*
-     * Save this information in the correct slab number of the node in the 
-     * module.
-     */
-    slab_number = geo_slab(geoid);
-    DPRINTF("slab number added 0x%x\n", slab_number);
-
-    if (m->nodes[slab_number] != -1) {
-	printk("module_add_node .. slab previously found\n");
-	return NULL;
-    }
-
-    m->nodes[slab_number] = cnodeid;
-    m->geoid[slab_number] = geoid;
-
-    return m;
-}
-
-static int __init
-module_probe_snum(module_t *m, nasid_t host_nasid, nasid_t nasid)
-{
-    lboard_t	       *board;
-    klmod_serial_num_t *comp;
-    char serial_number[16];
-
-    /*
-     * record brick serial number
-     */
-    board = find_lboard_nasid((lboard_t *) KL_CONFIG_INFO(host_nasid), host_nasid, KLTYPE_SNIA);
-
-    if (! board || KL_CONFIG_DUPLICATE_BOARD(board))
-    {
-	return 0;
-    }
-
-    board_serial_number_get( board, serial_number );
-    if( serial_number[0] != '\0' ) {
-	encode_str_serial( serial_number, m->snum.snum_str );
-	m->snum_valid = 1;
-    }
-
-    board = find_lboard_nasid((lboard_t *) KL_CONFIG_INFO(nasid),
-			nasid, KLTYPE_IOBRICK_XBOW);
-
-    if (! board || KL_CONFIG_DUPLICATE_BOARD(board))
-	return 0;
-
-    comp = GET_SNUM_COMP(board);
-
-    if (comp) {
-	    if (comp->snum.snum_str[0] != '\0') {
-		    memcpy(m->sys_snum, comp->snum.snum_str,
-			   MAX_SERIAL_NUM_SIZE);
-		    m->sys_snum_valid = 1;
-	    }
-    }
-
-    if (m->sys_snum_valid)
-	return 1;
-    else {
-	DPRINTF("Invalid serial number for module %d, "
-		"possible missing or invalid NIC.", m->id);
-	return 0;
-    }
-}
-
-void __init
-io_module_init(void)
-{
-    cnodeid_t		node;
-    lboard_t	       *board;
-    nasid_t		nasid;
-    int			nserial;
-    module_t	       *m;
-    extern		int numionodes;
-
-    DPRINTF("*******module_init\n");
-
-    nserial = 0;
-
-    /*
-     * First pass just scan for compute node boards KLTYPE_SNIA.
-     * We do not support memoryless compute nodes.
-     */
-    for (node = 0; node < numnodes; node++) {
-	nasid = cnodeid_to_nasid(node);
-	board = find_lboard_nasid((lboard_t *) KL_CONFIG_INFO(nasid), nasid, KLTYPE_SNIA);
-	ASSERT(board);
-
-	HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, NULL, NULL, "Found Shub lboard 0x%lx nasid 0x%x cnode 0x%x \n", (unsigned long)board, (int)nasid, (int)node);
-
-	m = module_add_node(board->brd_geoid, node);
-	if (! m->snum_valid && module_probe_snum(m, nasid, nasid))
-	    nserial++;
-    }
-
-    /*
-     * Second scan, look for headless/memless board hosted by compute nodes.
-     */
-    for (node = numnodes; node < numionodes; node++) {
-	nasid_t		nasid;
-	char		serial_number[16];
-
-        nasid = cnodeid_to_nasid(node);
-	board = find_lboard_nasid((lboard_t *) KL_CONFIG_INFO(nasid), 
-				nasid, KLTYPE_SNIA);
-	ASSERT(board);
-
-	HWGRAPH_DEBUG(__FILE__, __FUNCTION__, __LINE__, NULL, NULL, "Found headless/memless lboard 0x%lx node %d nasid %d cnode %d\n", (unsigned long)board, node, (int)nasid, (int)node);
-
-        m = module_add_node(board->brd_geoid, node);
-
-	/*
-	 * Get and initialize the serial number.
-	 */
-	board_serial_number_get( board, serial_number );
-    	if( serial_number[0] != '\0' ) {
-        	encode_str_serial( serial_number, m->snum.snum_str );
-        	m->snum_valid = 1;
-		nserial++;
-	}
-    }
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/Makefile b/arch/ia64/sn/io/sn2/pcibr/Makefile
--- a/arch/ia64/sn/io/sn2/pcibr/Makefile	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,16 +0,0 @@
-# arch/ia64/sn/io/sn2/pcibr/Makefile
-#
-# 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) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# Makefile for the sn2 specific pci bridge routines.
-#
-
-obj-y += pcibr_ate.o pcibr_config.o \
-	 pcibr_dvr.o pcibr_hints.o  \
-	 pcibr_intr.o pcibr_rrb.o   \
-	 pcibr_slot.o pcibr_error.o \
-	 pcibr_reg.o 
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,178 +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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-
-/*
- * functions
- */
-int		pcibr_ate_alloc(pcibr_soft_t, int, struct resource *);
-void		pcibr_ate_free(pcibr_soft_t, int, int, struct resource *);
-bridge_ate_t	pcibr_flags_to_ate(pcibr_soft_t, unsigned);
-bridge_ate_p	pcibr_ate_addr(pcibr_soft_t, int);
-void		ate_write(pcibr_soft_t, int, int, bridge_ate_t);
-
-int pcibr_invalidate_ate;  /* by default don't invalidate ATE on free */
-
-/*
- * Allocate "count" contiguous Bridge Address Translation Entries
- * on the specified bridge to be used for PCI to XTALK mappings.
- * Indices in rm map range from 1..num_entries.  Indicies returned
- * to caller range from 0..num_entries-1.
- *
- * Return the start index on success, -1 on failure.
- */
-int
-pcibr_ate_alloc(pcibr_soft_t pcibr_soft, int count, struct resource *res)
-{
-    int			    status = 0;
-    unsigned long	    flag;
-
-    memset(res, 0, sizeof(struct resource));
-    flag = pcibr_lock(pcibr_soft);
-    status = allocate_resource( &pcibr_soft->bs_int_ate_resource, res,
-				count, pcibr_soft->bs_int_ate_resource.start, 
-				pcibr_soft->bs_int_ate_resource.end, 1,
-				NULL, NULL);
-    if (status) {
-	/* Failed to allocate */
-	pcibr_unlock(pcibr_soft, flag);
-	return -1;
-    }
-
-    /* Save the resource for freeing */
-    pcibr_unlock(pcibr_soft, flag);
-
-    return res->start;
-}
-
-void
-pcibr_ate_free(pcibr_soft_t pcibr_soft, int index, int count, struct resource *res)
-{
-
-    bridge_ate_t ate;
-    int status = 0;
-    unsigned long flags;
-
-    if (pcibr_invalidate_ate) {
-	/* For debugging purposes, clear the valid bit in the ATE */
-	ate = *pcibr_ate_addr(pcibr_soft, index);
-	ate_write(pcibr_soft, index, count, (ate & ~ATE_V));
-    }
-
-    flags = pcibr_lock(pcibr_soft);
-    status = release_resource(res);
-    pcibr_unlock(pcibr_soft, flags);
-    if (status)
-	BUG(); /* Ouch .. */
-
-}
-
-/*
- * Convert PCI-generic software flags and Bridge-specific software flags
- * into Bridge-specific Address Translation Entry attribute bits.
- */
-bridge_ate_t
-pcibr_flags_to_ate(pcibr_soft_t pcibr_soft, unsigned flags)
-{
-    bridge_ate_t            attributes;
-
-    /* default if nothing specified:
-     * NOBARRIER
-     * NOPREFETCH
-     * NOPRECISE
-     * COHERENT
-     * Plus the valid bit
-     */
-    attributes = ATE_CO | ATE_V;
-
-    /* Generic macro flags
-     */
-    if (flags & PCIIO_DMA_DATA) {	/* standard data channel */
-	attributes &= ~ATE_BAR;		/* no barrier */
-	attributes |= ATE_PREF;		/* prefetch on */
-    }
-    if (flags & PCIIO_DMA_CMD) {	/* standard command channel */
-	attributes |= ATE_BAR;		/* barrier bit on */
-	attributes &= ~ATE_PREF;	/* disable prefetch */
-    }
-    /* Generic detail flags
-     */
-    if (flags & PCIIO_PREFETCH)
-	attributes |= ATE_PREF;
-    if (flags & PCIIO_NOPREFETCH)
-	attributes &= ~ATE_PREF;
-
-    /* Provider-specific flags
-     */
-    if (flags & PCIBR_BARRIER)
-	attributes |= ATE_BAR;
-    if (flags & PCIBR_NOBARRIER)
-	attributes &= ~ATE_BAR;
-
-    if (flags & PCIBR_PREFETCH)
-	attributes |= ATE_PREF;
-    if (flags & PCIBR_NOPREFETCH)
-	attributes &= ~ATE_PREF;
-
-    if (flags & PCIBR_PRECISE)
-	attributes |= ATE_PREC;
-    if (flags & PCIBR_NOPRECISE)
-	attributes &= ~ATE_PREC;
-
-    /* In PCI-X mode, Prefetch & Precise not supported */
-    if (IS_PCIX(pcibr_soft)) {
-	attributes &= ~(ATE_PREC | ATE_PREF);
-    }
-
-    return (attributes);
-}
-
-/*
- * Setup an Address Translation Entry as specified.  Use either the Bridge
- * internal maps or the external map RAM, as appropriate.
- */
-bridge_ate_p
-pcibr_ate_addr(pcibr_soft_t pcibr_soft,
-	       int ate_index)
-{
-    if (ate_index < pcibr_soft->bs_int_ate_size) {
-	return (pcireg_int_ate_addr(pcibr_soft, ate_index));
-    } else {
-	printk("pcibr_ate_addr(): INVALID ate_index 0x%x", ate_index);
-	return (bridge_ate_p)0;
-    }
-}
-
-/*
- * Write the ATE.
- */
-void
-ate_write(pcibr_soft_t pcibr_soft, int ate_index, int count, bridge_ate_t ate)
-{
-    while (count-- > 0) {
-	if (ate_index < pcibr_soft->bs_int_ate_size) {
-	    pcireg_int_ate_set(pcibr_soft, ate_index, ate);
-	    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pcibr_soft->bs_vhdl,
-			"ate_write(): ate_index=0x%x, ate=0x%lx\n",
-			ate_index, (uint64_t)ate));
-	} else {
-	    printk("ate_write(): INVALID ate_index 0x%x", ate_index);
-	    return;
-	}
-	ate_index++;
-	ate += IOPGSIZE;
-    }
-
-    pcireg_tflush_get(pcibr_soft);	/* wait until Bridge PIO complete */
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_config.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_config.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_config.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,195 +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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-
-extern pcibr_info_t      pcibr_info_get(vertex_hdl_t);
-
-uint64_t          pcibr_config_get(vertex_hdl_t, unsigned, unsigned);
-uint64_t          do_pcibr_config_get(cfg_p, unsigned, unsigned);
-void              pcibr_config_set(vertex_hdl_t, unsigned, unsigned, uint64_t);
-void       	  do_pcibr_config_set(cfg_p, unsigned, unsigned, uint64_t);
-
-/*
- * fancy snia bit twiddling....
- */
-#define	CBP(b,r) (((volatile uint8_t *) b)[(r)])
-#define	CSP(b,r) (((volatile uint16_t *) b)[((r)/2)])
-#define	CWP(b,r) (((volatile uint32_t *) b)[(r)/4])
-
-/*
- * Return a config space address for given slot / func / offset.  Note the
- * returned pointer is a 32bit word (ie. cfg_p) aligned pointer pointing to
- * the 32bit word that contains the "offset" byte.
- */
-cfg_p
-pcibr_func_config_addr(pcibr_soft_t soft, pciio_bus_t bus, pciio_slot_t slot, 
-					pciio_function_t func, int offset)
-{
-	/*
-	 * Type 1 config space
-	 */
-	if (bus > 0) {
-		pcireg_type1_cntr_set(soft, ((bus << 16) | (slot << 11)));
-		return (pcireg_type1_cfg_addr(soft, func, offset));
-	}
-
-	/*
-	 * Type 0 config space
-	 */
-	return (pcireg_type0_cfg_addr(soft, slot, func, offset));
-}
-
-/*
- * Return config space address for given slot / offset.  Note the returned
- * pointer is a 32bit word (ie. cfg_p) aligned pointer pointing to the
- * 32bit word that contains the "offset" byte.
- */
-cfg_p
-pcibr_slot_config_addr(pcibr_soft_t soft, pciio_slot_t slot, int offset)
-{
-	return pcibr_func_config_addr(soft, 0, slot, 0, offset);
-}
-
-/*
- * Set config space data for given slot / func / offset
- */
-void
-pcibr_func_config_set(pcibr_soft_t soft, pciio_slot_t slot, 
-			pciio_function_t func, int offset, unsigned val)
-{
-	cfg_p  cfg_base;
-
-	cfg_base = pcibr_func_config_addr(soft, 0, slot, func, 0);
-	do_pcibr_config_set(cfg_base, offset, sizeof(unsigned), val);
-}
-
-int pcibr_config_debug = 0;
-
-cfg_p
-pcibr_config_addr(vertex_hdl_t conn,
-		  unsigned reg)
-{
-    pcibr_info_t            pcibr_info;
-    pciio_bus_t		    pciio_bus;
-    pciio_slot_t            pciio_slot;
-    pciio_function_t        pciio_func;
-    cfg_p                   cfgbase = (cfg_p)0;
-    pciio_info_t	    pciio_info;
-
-    pciio_info = pciio_info_get(conn);
-    pcibr_info = pcibr_info_get(conn);
-
-    /*
-     * Determine the PCI bus/slot/func to generate a config address for.
-     */
-
-    if (pciio_info_type1_get(pciio_info)) {
-	/*
-	 * Conn is a vhdl which uses TYPE 1 addressing explicitly passed 
-	 * in reg.
-	 */
-	pciio_bus = PCI_TYPE1_BUS(reg);
-	pciio_slot = PCI_TYPE1_SLOT(reg);
-	pciio_func = PCI_TYPE1_FUNC(reg);
-
-	ASSERT(pciio_bus != 0);
-    } else {
-	/*
-	 * Conn is directly connected to the host bus.  PCI bus number is
-	 * hardcoded to 0 (even though it may have a logical bus number != 0)
-	 * and slot/function are derived from the pcibr_info_t associated
-	 * with the device.
-	 */
-	pciio_bus = 0;
-
-    pciio_slot = PCIBR_INFO_SLOT_GET_INT(pcibr_info);
-    if (pciio_slot == PCIIO_SLOT_NONE)
-	pciio_slot = PCI_TYPE1_SLOT(reg);
-
-    pciio_func = pcibr_info->f_func;
-    if (pciio_func == PCIIO_FUNC_NONE)
-	pciio_func = PCI_TYPE1_FUNC(reg);
-    }
-
-    cfgbase = pcibr_func_config_addr((pcibr_soft_t) pcibr_info->f_mfast,
-			pciio_bus, pciio_slot, pciio_func, 0);
-
-    return cfgbase;
-}
-
-uint64_t
-pcibr_config_get(vertex_hdl_t conn,
-		 unsigned reg,
-		 unsigned size)
-{
-	return do_pcibr_config_get(pcibr_config_addr(conn, reg),
-				PCI_TYPE1_REG(reg), size);
-}
-
-uint64_t
-do_pcibr_config_get(cfg_p cfgbase,
-		       unsigned reg,
-		       unsigned size)
-{
-    unsigned                value;
-
-    value = CWP(cfgbase, reg);
-    if (reg & 3)
-	value >>= 8 * (reg & 3);
-    if (size < 4)
-	value &= (1 << (8 * size)) - 1;
-    return value;
-}
-
-void
-pcibr_config_set(vertex_hdl_t conn,
-		 unsigned reg,
-		 unsigned size,
-		 uint64_t value)
-{
-	do_pcibr_config_set(pcibr_config_addr(conn, reg),
-			PCI_TYPE1_REG(reg), size, value);
-}
-
-void
-do_pcibr_config_set(cfg_p cfgbase,
-		    unsigned reg,
-		    unsigned size,
-		    uint64_t value)
-{
-	switch (size) {
-	case 1:
-		CBP(cfgbase, reg) = value;
-		break;
-	case 2:
-		if (reg & 1) {
-			CBP(cfgbase, reg) = value;
-			CBP(cfgbase, reg + 1) = value >> 8;
-		} else
-			CSP(cfgbase, reg) = value;
-		break;
-	case 3:
-		if (reg & 1) {
-			CBP(cfgbase, reg) = value;
-			CSP(cfgbase, (reg + 1)) = value >> 8;
-		} else {
-			CSP(cfgbase, reg) = value;
-			CBP(cfgbase, reg + 2) = value >> 16;
-		}
-		break;
-	case 4:
-		CWP(cfgbase, reg) = value;
-		break;
- 	}
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c	2004-12-24 13:37:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,2662 +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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/interrupt.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-
-#include <asm/sn/prio.h> 
-#include <asm/sn/sn_private.h>
-
-/*
- * global variables to toggle the different levels of pcibr debugging.  
- *   -pcibr_debug_mask is the mask of the different types of debugging
- *    you want to enable.  See sys/PCI/pcibr_private.h 
- *   -pcibr_debug_module is the module you want to trace.  By default
- *    all modules are trace.  The format is something like "001c10".
- *   -pcibr_debug_widget is the widget you want to trace.  For TIO 
- *    based bricks use the corelet id.
- *   -pcibr_debug_slot is the pci slot you want to trace.
- */
-uint32_t   	  pcibr_debug_mask;			/* 0x00000000 to disable */
-static char      *pcibr_debug_module = "all";		/* 'all' for all modules */
-static int	   pcibr_debug_widget = -1;		/* '-1' for all widgets  */
-static int	   pcibr_debug_slot = -1;		/* '-1' for all slots    */
-
-
-#if PCIBR_SOFT_LIST
-pcibr_list_p            pcibr_list;
-#endif
-
-extern char *pci_space[];
-
-/* =====================================================================
- *    Function Table of Contents
- *
- *      The order of functions in this file has stopped
- *      making much sense. We might want to take a look
- *      at it some time and bring back some sanity, or
- *      perhaps bust this file into smaller chunks.
- */
-
-extern void		 do_pcibr_rrb_free_all(pcibr_soft_t, pciio_slot_t);
-extern void              do_pcibr_rrb_autoalloc(pcibr_soft_t, int, int, int);
-extern void		 pcibr_rrb_alloc_more(pcibr_soft_t pcibr_soft, int slot,
-							int vchan, int more_rrbs);
-
-extern int  		 pcibr_wrb_flush(vertex_hdl_t);
-extern int               pcibr_rrb_alloc(vertex_hdl_t, int *, int *);
-void            	 pcibr_rrb_alloc_more(pcibr_soft_t, int, int, int);
-
-extern void              pcibr_rrb_flush(vertex_hdl_t);
-
-static int                pcibr_try_set_device(pcibr_soft_t, pciio_slot_t, unsigned, uint64_t);
-void                     pcibr_release_device(pcibr_soft_t, pciio_slot_t, uint64_t);
-
-extern iopaddr_t         pcibr_bus_addr_alloc(pcibr_soft_t, pciio_win_info_t,
-                                              pciio_space_t, int, int, int);
-extern int		 hwgraph_vertex_name_get(vertex_hdl_t vhdl, char *buf, 
-						 uint buflen);
-
-int			 pcibr_detach(vertex_hdl_t);
-void			 pcibr_directmap_init(pcibr_soft_t);
-int			 pcibr_pcix_rbars_calc(pcibr_soft_t);
-extern int               pcibr_ate_alloc(pcibr_soft_t, int, struct resource *);
-extern void              pcibr_ate_free(pcibr_soft_t, int, int, struct resource *);
-extern pciio_dmamap_t	 get_free_pciio_dmamap(vertex_hdl_t);
-extern void		 free_pciio_dmamap(pcibr_dmamap_t);
-extern int 		 pcibr_widget_to_bus(vertex_hdl_t pcibr_vhdl);
-
-extern void 		ate_write(pcibr_soft_t, int, int, bridge_ate_t);
-
-pcibr_info_t      pcibr_info_get(vertex_hdl_t);
-
-static iopaddr_t         pcibr_addr_pci_to_xio(vertex_hdl_t, pciio_slot_t, pciio_space_t, iopaddr_t, size_t, unsigned);
-
-pcibr_piomap_t          pcibr_piomap_alloc(vertex_hdl_t, device_desc_t, pciio_space_t, iopaddr_t, size_t, size_t, unsigned);
-void                    pcibr_piomap_free(pcibr_piomap_t);
-caddr_t                 pcibr_piomap_addr(pcibr_piomap_t, iopaddr_t, size_t);
-void                    pcibr_piomap_done(pcibr_piomap_t);
-caddr_t                 pcibr_piotrans_addr(vertex_hdl_t, device_desc_t, pciio_space_t, iopaddr_t, size_t, unsigned);
-iopaddr_t               pcibr_piospace_alloc(vertex_hdl_t, device_desc_t, pciio_space_t, size_t, size_t);
-void                    pcibr_piospace_free(vertex_hdl_t, pciio_space_t, iopaddr_t, size_t);
-
-static iopaddr_t         pcibr_flags_to_d64(unsigned, pcibr_soft_t);
-extern bridge_ate_t     pcibr_flags_to_ate(pcibr_soft_t, unsigned);
-
-pcibr_dmamap_t          pcibr_dmamap_alloc(vertex_hdl_t, device_desc_t, size_t, unsigned);
-void                    pcibr_dmamap_free(pcibr_dmamap_t);
-extern bridge_ate_p     pcibr_ate_addr(pcibr_soft_t, int);
-static iopaddr_t         pcibr_addr_xio_to_pci(pcibr_soft_t, iopaddr_t, size_t);
-iopaddr_t               pcibr_dmamap_addr(pcibr_dmamap_t, paddr_t, size_t);
-void                    pcibr_dmamap_done(pcibr_dmamap_t);
-cnodeid_t		pcibr_get_dmatrans_node(vertex_hdl_t);
-iopaddr_t               pcibr_dmatrans_addr(vertex_hdl_t, device_desc_t, paddr_t, size_t, unsigned);
-void                    pcibr_dmamap_drain(pcibr_dmamap_t);
-void                    pcibr_dmaaddr_drain(vertex_hdl_t, paddr_t, size_t);
-iopaddr_t               pcibr_dmamap_pciaddr_get(pcibr_dmamap_t);
-
-void                    pcibr_provider_startup(vertex_hdl_t);
-void                    pcibr_provider_shutdown(vertex_hdl_t);
-
-int                     pcibr_reset(vertex_hdl_t);
-pciio_endian_t          pcibr_endian_set(vertex_hdl_t, pciio_endian_t, pciio_endian_t);
-int                     pcibr_device_flags_set(vertex_hdl_t, pcibr_device_flags_t);
-
-extern int		pcibr_slot_info_free(vertex_hdl_t,pciio_slot_t);
-extern int              pcibr_slot_detach(vertex_hdl_t, pciio_slot_t, int,
-                                                      char *, int *);
-
-pciio_businfo_t		pcibr_businfo_get(vertex_hdl_t);
-
-/* =====================================================================
- *    Device(x) register management
- */
-
-/* pcibr_try_set_device: attempt to modify Device(x)
- * for the specified slot on the specified bridge
- * as requested in flags, limited to the specified
- * bits. Returns which BRIDGE bits were in conflict,
- * or ZERO if everything went OK.
- *
- * Caller MUST hold pcibr_lock when calling this function.
- */
-static int
-pcibr_try_set_device(pcibr_soft_t pcibr_soft,
-		     pciio_slot_t slot,
-		     unsigned flags,
-		     uint64_t mask)
-{
-    pcibr_soft_slot_t       slotp;
-    uint64_t		    old;
-    uint64_t		    new;
-    uint64_t		    chg;
-    uint64_t		    bad;
-    uint64_t		    badpmu;
-    uint64_t		    badd32;
-    uint64_t		    badd64;
-    uint64_t		    fix;
-    unsigned long	    s;
-
-    slotp = &pcibr_soft->bs_slot[slot];
-
-    s = pcibr_lock(pcibr_soft);
-
-    old = slotp->bss_device;
-
-    /* figure out what the desired
-     * Device(x) bits are based on
-     * the flags specified.
-     */
-
-    new = old;
-
-    /* Currently, we inherit anything that
-     * the new caller has not specified in
-     * one way or another, unless we take
-     * action here to not inherit.
-     *
-     * This is needed for the "swap" stuff,
-     * since it could have been set via
-     * pcibr_endian_set -- altho note that
-     * any explicit PCIBR_BYTE_STREAM or
-     * PCIBR_WORD_VALUES will freely override
-     * the effect of that call (and vice
-     * versa, no protection either way).
-     *
-     * I want to get rid of pcibr_endian_set
-     * in favor of tracking DMA endianness
-     * using the flags specified when DMA
-     * channels are created.
-     */
-
-#define	BRIDGE_DEV_WRGA_BITS	(BRIDGE_DEV_PMU_WRGA_EN | BRIDGE_DEV_DIR_WRGA_EN)
-#define	BRIDGE_DEV_SWAP_BITS	(BRIDGE_DEV_SWAP_PMU | BRIDGE_DEV_SWAP_DIR)
-
-    /* Do not use Barrier, Write Gather,
-     * or Prefetch unless asked.
-     * Leave everything else as it
-     * was from the last time.
-     */
-    new = new
-	& ~BRIDGE_DEV_BARRIER
-	& ~BRIDGE_DEV_WRGA_BITS
-	& ~BRIDGE_DEV_PREF
-	;
-
-    /* Generic macro flags
-     */
-    if (flags & PCIIO_DMA_DATA) {
-	new = (new
-            & ~BRIDGE_DEV_BARRIER)      /* barrier off */
-            | BRIDGE_DEV_PREF;          /* prefetch on */
-
-    }
-    if (flags & PCIIO_DMA_CMD) {
-        new = ((new
-            & ~BRIDGE_DEV_PREF)         /* prefetch off */
-            & ~BRIDGE_DEV_WRGA_BITS)    /* write gather off */
-            | BRIDGE_DEV_BARRIER;       /* barrier on */
-    }
-    /* Generic detail flags
-     */
-    if (flags & PCIIO_WRITE_GATHER)
-	new |= BRIDGE_DEV_WRGA_BITS;
-    if (flags & PCIIO_NOWRITE_GATHER)
-	new &= ~BRIDGE_DEV_WRGA_BITS;
-
-    if (flags & PCIIO_PREFETCH)
-	new |= BRIDGE_DEV_PREF;
-    if (flags & PCIIO_NOPREFETCH)
-	new &= ~BRIDGE_DEV_PREF;
-
-    if (flags & PCIBR_WRITE_GATHER)
-	new |= BRIDGE_DEV_WRGA_BITS;
-    if (flags & PCIBR_NOWRITE_GATHER)
-	new &= ~BRIDGE_DEV_WRGA_BITS;
-
-    if (flags & PCIIO_BYTE_STREAM)
-	new |= BRIDGE_DEV_SWAP_DIR;
-    if (flags & PCIIO_WORD_VALUES)
-	new &= ~BRIDGE_DEV_SWAP_DIR;
-
-    /* Provider-specific flags
-     */
-    if (flags & PCIBR_PREFETCH)
-	new |= BRIDGE_DEV_PREF;
-    if (flags & PCIBR_NOPREFETCH)
-	new &= ~BRIDGE_DEV_PREF;
-
-    if (flags & PCIBR_PRECISE)
-	new |= BRIDGE_DEV_PRECISE;
-    if (flags & PCIBR_NOPRECISE)
-	new &= ~BRIDGE_DEV_PRECISE;
-
-    if (flags & PCIBR_BARRIER)
-	new |= BRIDGE_DEV_BARRIER;
-    if (flags & PCIBR_NOBARRIER)
-	new &= ~BRIDGE_DEV_BARRIER;
-
-    if (flags & PCIBR_64BIT)
-	new |= BRIDGE_DEV_DEV_SIZE;
-    if (flags & PCIBR_NO64BIT)
-	new &= ~BRIDGE_DEV_DEV_SIZE;
-
-    /*
-     * PIC BRINGUP WAR (PV# 855271):
-     * Allow setting BRIDGE_DEV_VIRTUAL_EN on PIC iff we're a 64-bit
-     * device.  The bit is only intended for 64-bit devices and, on
-     * PIC, can cause problems for 32-bit devices.
-     */
-    if (mask == BRIDGE_DEV_D64_BITS &&
-				PCIBR_WAR_ENABLED(PV855271, pcibr_soft)) {
-	if (flags & PCIBR_VCHAN1) {
-		new |= BRIDGE_DEV_VIRTUAL_EN;
-		mask |= BRIDGE_DEV_VIRTUAL_EN;
-	}
-    }
-
-    /* PIC BRINGUP WAR (PV# 878674):   Don't allow 64bit PIO accesses */
-    if ((flags & PCIBR_64BIT) &&
-				PCIBR_WAR_ENABLED(PV878674, pcibr_soft)) {
-	new &= ~(1ull << 22);
-    }
-
-    chg = old ^ new;				/* what are we changing, */
-    chg &= mask;				/* of the interesting bits */
-
-    if (chg) {
-
-	badd32 = slotp->bss_d32_uctr ? (BRIDGE_DEV_D32_BITS & chg) : 0;
-	badpmu = slotp->bss_pmu_uctr ? (XBRIDGE_DEV_PMU_BITS & chg) : 0;
-	badd64 = slotp->bss_d64_uctr ? (XBRIDGE_DEV_D64_BITS & chg) : 0;
-	bad = badpmu | badd32 | badd64;
-
-	if (bad) {
-
-	    /* some conflicts can be resolved by
-	     * forcing the bit on. this may cause
-	     * some performance degredation in
-	     * the stream(s) that want the bit off,
-	     * but the alternative is not allowing
-	     * the new stream at all.
-	     */
-            if ( (fix = bad & (BRIDGE_DEV_PRECISE |
-                             BRIDGE_DEV_BARRIER)) ) {
-		bad &= ~fix;
-		/* don't change these bits if
-		 * they are already set in "old"
-		 */
-		chg &= ~(fix & old);
-	    }
-	    /* some conflicts can be resolved by
-	     * forcing the bit off. this may cause
-	     * some performance degredation in
-	     * the stream(s) that want the bit on,
-	     * but the alternative is not allowing
-	     * the new stream at all.
-	     */
-	    if ( (fix = bad & (BRIDGE_DEV_WRGA_BITS |
-			     BRIDGE_DEV_PREF)) ) {
-		bad &= ~fix;
-		/* don't change these bits if
-		 * we wanted to turn them on.
-		 */
-		chg &= ~(fix & new);
-	    }
-	    /* conflicts in other bits mean
-	     * we can not establish this DMA
-	     * channel while the other(s) are
-	     * still present.
-	     */
-	    if (bad) {
-		pcibr_unlock(pcibr_soft, s);
-		PCIBR_DEBUG((PCIBR_DEBUG_DEVREG, pcibr_soft->bs_vhdl,
-			    "pcibr_try_set_device: mod blocked by 0x%x\n", bad));
-		return bad;
-	    }
-	}
-    }
-    if (mask == BRIDGE_DEV_PMU_BITS)
-	slotp->bss_pmu_uctr++;
-    if (mask == BRIDGE_DEV_D32_BITS)
-	slotp->bss_d32_uctr++;
-    if (mask == BRIDGE_DEV_D64_BITS)
-	slotp->bss_d64_uctr++;
-
-    /* the value we want to write is the
-     * original value, with the bits for
-     * our selected changes flipped, and
-     * with any disabled features turned off.
-     */
-    new = old ^ chg;			/* only change what we want to change */
-
-    if (slotp->bss_device == new) {
-	pcibr_unlock(pcibr_soft, s);
-	return 0;
-    }
-    
-    pcireg_device_set(pcibr_soft, slot, new);
-    slotp->bss_device = new;
-    pcireg_tflush_get(pcibr_soft);	/* wait until Bridge PIO complete */
-    pcibr_unlock(pcibr_soft, s);
-
-    PCIBR_DEBUG((PCIBR_DEBUG_DEVREG, pcibr_soft->bs_vhdl,
-		"pcibr_try_set_device: Device(%d): 0x%x\n", slot, new));
-    return 0;
-}
-
-void
-pcibr_release_device(pcibr_soft_t pcibr_soft,
-		     pciio_slot_t slot,
-		     uint64_t mask)
-{
-    pcibr_soft_slot_t       slotp;
-    unsigned long           s;
-
-    slotp = &pcibr_soft->bs_slot[slot];
-
-    s = pcibr_lock(pcibr_soft);
-
-    if (mask == BRIDGE_DEV_PMU_BITS)
-	slotp->bss_pmu_uctr--;
-    if (mask == BRIDGE_DEV_D32_BITS)
-	slotp->bss_d32_uctr--;
-    if (mask == BRIDGE_DEV_D64_BITS)
-	slotp->bss_d64_uctr--;
-
-    pcibr_unlock(pcibr_soft, s);
-}
-
-
-/* =====================================================================
- *    Bridge (pcibr) "Device Driver" entry points
- */
-
-
-static int
-pcibr_mmap(struct file * file, struct vm_area_struct * vma)
-{
-	vertex_hdl_t		pcibr_vhdl = file->f_dentry->d_fsdata;
-	pcibr_soft_t            pcibr_soft;
-	void               *bridge;
-	unsigned long		phys_addr;
-	int			error = 0;
-
-	pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-	bridge = pcibr_soft->bs_base;
-	phys_addr = (unsigned long)bridge & ~0xc000000000000000; /* Mask out the Uncache bits */
-        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-        vma->vm_flags |= VM_RESERVED | VM_IO;
-        error = io_remap_page_range(vma, phys_addr, vma->vm_start,
-				    vma->vm_end - vma->vm_start,
-				    vma->vm_page_prot);
-	return error;
-}
-
-/*
- * This is the file operation table for the pcibr driver.
- * As each of the functions are implemented, put the
- * appropriate function name below.
- */
-static int pcibr_mmap(struct file * file, struct vm_area_struct * vma);
-struct file_operations pcibr_fops = {
-	.owner		= THIS_MODULE,
-	.mmap		= pcibr_mmap,
-};
-
-
-/* This is special case code used by grio. There are plans to make
- * this a bit more general in the future, but till then this should
- * be sufficient.
- */
-pciio_slot_t
-pcibr_device_slot_get(vertex_hdl_t dev_vhdl)
-{
-    char                    devname[MAXDEVNAME];
-    vertex_hdl_t            tdev;
-    pciio_info_t            pciio_info;
-    pciio_slot_t            slot = PCIIO_SLOT_NONE;
-
-    vertex_to_name(dev_vhdl, devname, MAXDEVNAME);
-
-    /* run back along the canonical path
-     * until we find a PCI connection point.
-     */
-    tdev = hwgraph_connectpt_get(dev_vhdl);
-    while (tdev != GRAPH_VERTEX_NONE) {
-	pciio_info = pciio_info_chk(tdev);
-	if (pciio_info) {
-	    slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-	    break;
-	}
-	hwgraph_vertex_unref(tdev);
-	tdev = hwgraph_connectpt_get(tdev);
-    }
-    hwgraph_vertex_unref(tdev);
-
-    return slot;
-}
-
-pcibr_info_t
-pcibr_info_get(vertex_hdl_t vhdl)
-{
-    return (pcibr_info_t) pciio_info_get(vhdl);
-}
-
-pcibr_info_t
-pcibr_device_info_new(
-			 pcibr_soft_t pcibr_soft,
-			 pciio_slot_t slot,
-			 pciio_function_t rfunc,
-			 pciio_vendor_id_t vendor,
-			 pciio_device_id_t device)
-{
-    pcibr_info_t            pcibr_info;
-    pciio_function_t        func;
-    int                     ibit;
-
-    func = (rfunc == PCIIO_FUNC_NONE) ? 0 : rfunc;
-
-    /*
-     * Create a pciio_info_s for this device.  pciio_device_info_new()
-     * will set the c_slot (which is suppose to represent the external
-     * slot (i.e the slot number silk screened on the back of the I/O
-     * brick)).  So for PIC we need to adjust this "internal slot" num
-     * passed into us, into its external representation.  See comment
-     * for the PCIBR_DEVICE_TO_SLOT macro for more information.
-     */
-    pcibr_info = kmalloc(sizeof (*(pcibr_info)), GFP_KERNEL);
-    if ( !pcibr_info ) {
-	return NULL;
-    }
-    memset(pcibr_info, 0, sizeof (*(pcibr_info)));
-
-    pciio_device_info_new(&pcibr_info->f_c, pcibr_soft->bs_vhdl,
-			  PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot),
-			  rfunc, vendor, device);
-    pcibr_info->f_dev = slot;
-
-    /* Set PCI bus number */
-    pcibr_info->f_bus = pcibr_widget_to_bus(pcibr_soft->bs_vhdl);
-
-    if (slot != PCIIO_SLOT_NONE) {
-
-	/*
-	 * Currently favored mapping from PCI
-	 * slot number and INTA/B/C/D to Bridge
-	 * PCI Interrupt Bit Number:
-	 *
-	 *     SLOT     A B C D
-	 *      0       0 4 0 4
-	 *      1       1 5 1 5
-	 *      2       2 6 2 6
-	 *      3       3 7 3 7
-	 *      4       4 0 4 0
-	 *      5       5 1 5 1
-	 *      6       6 2 6 2
-	 *      7       7 3 7 3
-	 *
-	 * XXX- allow pcibr_hints to override default
-	 * XXX- allow ADMIN to override pcibr_hints
-	 */
-	for (ibit = 0; ibit < 4; ++ibit)
-	    pcibr_info->f_ibit[ibit] =
-		(slot + 4 * ibit) & 7;
-
-	/*
-	 * Record the info in the sparse func info space.
-	 */
-	if (func < pcibr_soft->bs_slot[slot].bss_ninfo)
-	    pcibr_soft->bs_slot[slot].bss_infos[func] = pcibr_info;
-    }
-    return pcibr_info;
-}
-
-
-/*
- * pcibr_device_unregister
- *	This frees up any hardware resources reserved for this PCI device
- * 	and removes any PCI infrastructural information setup for it.
- *	This is usually used at the time of shutting down of the PCI card.
- */
-int
-pcibr_device_unregister(vertex_hdl_t pconn_vhdl)
-{
-    pciio_info_t	 pciio_info;
-    vertex_hdl_t	 pcibr_vhdl;
-    pciio_slot_t	 slot;
-    pcibr_soft_t	 pcibr_soft;
-    int                  count_vchan0, count_vchan1;
-    unsigned long	 s;
-    int			 error_call;
-    int			 error = 0;
-
-    pciio_info = pciio_info_get(pconn_vhdl);
-
-    pcibr_vhdl = pciio_info_master_get(pciio_info);
-    slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    /* Clear all the hardware xtalk resources for this device */
-    xtalk_widgetdev_shutdown(pcibr_soft->bs_conn, slot);
-
-    /* Flush all the rrbs */
-    pcibr_rrb_flush(pconn_vhdl);
-
-    /*
-     * If the RRB configuration for this slot has changed, set it 
-     * back to the boot-time default
-     */
-    if (pcibr_soft->bs_rrb_valid_dflt[slot][VCHAN0] >= 0) {
-
-        s = pcibr_lock(pcibr_soft);
-
-        pcibr_soft->bs_rrb_res[slot] = pcibr_soft->bs_rrb_res[slot] +
-                                       pcibr_soft->bs_rrb_valid[slot][VCHAN0] +
-                                       pcibr_soft->bs_rrb_valid[slot][VCHAN1] +
-                                       pcibr_soft->bs_rrb_valid[slot][VCHAN2] +
-                                       pcibr_soft->bs_rrb_valid[slot][VCHAN3];
-
-        /* Free the rrbs allocated to this slot, both the normal & virtual */
-	do_pcibr_rrb_free_all(pcibr_soft, slot);
-
-        count_vchan0 = pcibr_soft->bs_rrb_valid_dflt[slot][VCHAN0];
-        count_vchan1 = pcibr_soft->bs_rrb_valid_dflt[slot][VCHAN1];
-
-        pcibr_unlock(pcibr_soft, s);
-
-        pcibr_rrb_alloc(pconn_vhdl, &count_vchan0, &count_vchan1);
-
-    }
-
-    /* Flush the write buffers !! */
-    error_call = pcibr_wrb_flush(pconn_vhdl);
-
-    if (error_call)
-        error = error_call;
-
-    /* Clear the information specific to the slot */
-    error_call = pcibr_slot_info_free(pcibr_vhdl, slot);
-
-    if (error_call)
-        error = error_call;
-
-    return error;
-    
-}
-
-/*
- * pcibr_driver_reg_callback
- *      CDL will call this function for each device found in the PCI
- *      registry that matches the vendor/device IDs supported by 
- *      the driver being registered.  The device's connection vertex
- *      and the driver's attach function return status enable the
- *      slot's device status to be set.
- */
-void
-pcibr_driver_reg_callback(vertex_hdl_t pconn_vhdl,
-			  int key1, int key2, int error)
-{
-    pciio_info_t	 pciio_info;
-    pcibr_info_t         pcibr_info;
-    vertex_hdl_t	 pcibr_vhdl;
-    pciio_slot_t	 slot;
-    pcibr_soft_t	 pcibr_soft;
-
-    /* Do not set slot status for vendor/device ID wildcard drivers */
-    if ((key1 == -1) || (key2 == -1))
-        return;
-
-    pciio_info = pciio_info_get(pconn_vhdl);
-    pcibr_info = pcibr_info_get(pconn_vhdl);
-
-    pcibr_vhdl = pciio_info_master_get(pciio_info);
-    slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    pcibr_info->f_att_det_error = error;
-
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-    pcibr_soft->bs_slot[slot].slot_status &= ~SLOT_STATUS_MASK;
-
-    if (error) {
-        pcibr_soft->bs_slot[slot].slot_status |= SLOT_STARTUP_INCMPLT;
-    } else {
-        pcibr_soft->bs_slot[slot].slot_status |= SLOT_STARTUP_CMPLT;
-    }
-#endif	/* CONFIG_HOTPLUG_PCI_SGI */
-}
-
-/*
- * pcibr_driver_unreg_callback
- *      CDL will call this function for each device found in the PCI
- *      registry that matches the vendor/device IDs supported by 
- *      the driver being unregistered.  The device's connection vertex
- *      and the driver's detach function return status enable the
- *      slot's device status to be set.
- */
-void
-pcibr_driver_unreg_callback(vertex_hdl_t pconn_vhdl, 
-                            int key1, int key2, int error)
-{
-    pciio_info_t	 pciio_info;
-    pcibr_info_t         pcibr_info;
-    vertex_hdl_t	 pcibr_vhdl;
-    pciio_slot_t	 slot;
-    pcibr_soft_t	 pcibr_soft;
-
-    /* Do not set slot status for vendor/device ID wildcard drivers */
-    if ((key1 == -1) || (key2 == -1))
-        return;
-
-    pciio_info = pciio_info_get(pconn_vhdl);
-    pcibr_info = pcibr_info_get(pconn_vhdl);
-
-    pcibr_vhdl = pciio_info_master_get(pciio_info);
-    slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    pcibr_info->f_att_det_error = error;
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-    pcibr_soft->bs_slot[slot].slot_status &= ~SLOT_STATUS_MASK;
-
-    if (error) {
-        pcibr_soft->bs_slot[slot].slot_status |= SLOT_SHUTDOWN_INCMPLT;
-    } else {
-        pcibr_soft->bs_slot[slot].slot_status |= SLOT_SHUTDOWN_CMPLT;
-    }
-#endif	/* CONFIG_HOTPLUG_PCI_SGI */
-}
-
-/*
- * pcibr_detach:
- *	Detach the bridge device from the hwgraph after cleaning out all the 
- *	underlying vertices.
- */
-
-int
-pcibr_detach(vertex_hdl_t xconn)
-{
-    pciio_slot_t	 slot;
-    vertex_hdl_t	 pcibr_vhdl;
-    pcibr_soft_t	 pcibr_soft;
-    unsigned long        s;
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DETACH, xconn, "pcibr_detach\n"));
-
-    /* Get the bridge vertex from its xtalk connection point */
-    if (hwgraph_traverse(xconn, EDGE_LBL_PCI, &pcibr_vhdl) != GRAPH_SUCCESS)
-	return 1;
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    /* Disable the interrupts from the bridge */
-    s = pcibr_lock(pcibr_soft);
-    pcireg_intr_enable_set(pcibr_soft, 0);
-    pcibr_unlock(pcibr_soft, s);
-
-    /* Detach all the PCI devices talking to this bridge */
-    for (slot = pcibr_soft->bs_min_slot; 
-				slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-	pcibr_slot_detach(pcibr_vhdl, slot, 0, (char *)NULL, (int *)NULL);
-    }
-
-    /* Unregister the no-slot connection point */
-    pciio_device_info_unregister(pcibr_vhdl,
-				 &(pcibr_soft->bs_noslot_info->f_c));
-
-    kfree(pcibr_soft->bs_name);
-    
-    /* Disconnect the error interrupt and free the xtalk resources 
-     * associated with it.
-     */
-    xtalk_intr_disconnect(pcibr_soft->bsi_err_intr);
-    xtalk_intr_free(pcibr_soft->bsi_err_intr);
-
-    /* Clear the software state maintained by the bridge driver for this
-     * bridge.
-     */
-    kfree(pcibr_soft);
-
-    /* Remove the Bridge revision labelled info */
-    (void)hwgraph_info_remove_LBL(pcibr_vhdl, INFO_LBL_PCIBR_ASIC_REV, NULL);
-
-    return 0;
-}
-
-
-/*
- * Set the Bridge's 32-bit PCI to XTalk Direct Map register to the most useful
- * value we can determine.  Note that we must use a single xid for all of:
- * 	-direct-mapped 32-bit DMA accesses
- *	-direct-mapped 64-bit DMA accesses
- * 	-DMA accesses through the PMU
- *	-interrupts
- * This is the only way to guarantee that completion interrupts will reach a
- * CPU after all DMA data has reached memory.
- */
-void
-pcibr_directmap_init(pcibr_soft_t pcibr_soft)
-{
-    paddr_t		paddr;
-    iopaddr_t		xbase;
-    uint64_t		diroff;
-    cnodeid_t		cnodeid = 0;	/* We need api for diroff api */
-    nasid_t		nasid;
-
-    nasid = cnodeid_to_nasid(cnodeid);
-    paddr = NODE_OFFSET(nasid) + 0;
-
-    /* Assume that if we ask for a DMA mapping to zero the XIO host will
-     * transmute this into a request for the lowest hunk of memory.
-     */
-    xbase = xtalk_dmatrans_addr(pcibr_soft->bs_conn, 0, paddr, PAGE_SIZE, 0);
-
-    diroff = xbase >> BRIDGE_DIRMAP_OFF_ADDRSHFT;
-    pcireg_dirmap_diroff_set(pcibr_soft, diroff);
-    pcireg_dirmap_wid_set(pcibr_soft, pcibr_soft->bs_mxid);
-    pcibr_soft->bs_dir_xport = pcibr_soft->bs_mxid;
-    if (xbase  == (512 << 20)) { /* 512Meg */
-	pcireg_dirmap_add512_set(pcibr_soft);
-	pcibr_soft->bs_dir_xbase = (512 << 20);
-    } else {
-	pcireg_dirmap_add512_clr(pcibr_soft);
-	pcibr_soft->bs_dir_xbase = diroff << BRIDGE_DIRMAP_OFF_ADDRSHFT;
-    }
-}
-
-
-int
-pcibr_asic_rev(vertex_hdl_t pconn_vhdl)
-{
-    vertex_hdl_t            pcibr_vhdl;
-    int			    rc;
-    arbitrary_info_t        ainfo;
-
-    if (GRAPH_SUCCESS !=
-	hwgraph_traverse(pconn_vhdl, EDGE_LBL_MASTER, &pcibr_vhdl))
-	return -1;
-
-    rc = hwgraph_info_get_LBL(pcibr_vhdl, INFO_LBL_PCIBR_ASIC_REV, &ainfo);
-
-    /*
-     * Any hwgraph function that returns a vertex handle will implicity
-     * increment that vertex's reference count.  The caller must explicity
-     * decrement the vertex's referece count after the last reference to
-     * that vertex.
-     *
-     * Decrement reference count incremented by call to hwgraph_traverse().
-     *
-     */
-    hwgraph_vertex_unref(pcibr_vhdl);
-
-    if (rc != GRAPH_SUCCESS) 
-	return -1;
-
-    return (int) ainfo;
-}
-
-/* =====================================================================
- *    PIO MANAGEMENT
- */
-
-static iopaddr_t
-pcibr_addr_pci_to_xio(vertex_hdl_t pconn_vhdl,
-		      pciio_slot_t slot,
-		      pciio_space_t space,
-		      iopaddr_t pci_addr,
-		      size_t req_size,
-		      unsigned flags)
-{
-    pcibr_info_t            pcibr_info = pcibr_info_get(pconn_vhdl);
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    unsigned                bar;	/* which BASE reg on device is decoding */
-    iopaddr_t               xio_addr = XIO_NOWHERE;
-    iopaddr_t               base = 0;
-    iopaddr_t               limit = 0;
-
-    pciio_space_t           wspace;	/* which space device is decoding */
-    iopaddr_t               wbase;	/* base of device decode on PCI */
-    size_t                  wsize;	/* size of device decode on PCI */
-
-    int                     try;	/* DevIO(x) window scanning order control */
-    int			    maxtry, halftry;
-    int                     win;	/* which DevIO(x) window is being used */
-    pciio_space_t           mspace;	/* target space for devio(x) register */
-    iopaddr_t               mbase;	/* base of devio(x) mapped area on PCI */
-    size_t                  msize;	/* size of devio(x) mapped area on PCI */
-    size_t                  mmask;	/* addr bits stored in Device(x) */
-
-    unsigned long           s;
-
-    s = pcibr_lock(pcibr_soft);
-
-    if (pcibr_soft->bs_slot[slot].has_host) {
-	slot = pcibr_soft->bs_slot[slot].host_slot;
-	pcibr_info = pcibr_soft->bs_slot[slot].bss_infos[0];
-
-	/*
-	 * Special case for dual-slot pci devices such as ioc3 on IP27
-	 * baseio.  In these cases, pconn_vhdl should never be for a pci
-	 * function on a subordiate PCI bus, so we can safely reset pciio_info
-	 * to be the info struct embedded in pcibr_info.  Failure to do this
-	 * results in using a bogus pciio_info_t for calculations done later
-	 * in this routine.
-	 */
-
-	pciio_info = &pcibr_info->f_c;
-    }
-    if (space == PCIIO_SPACE_NONE)
-	goto done;
-
-    if (space == PCIIO_SPACE_CFG) {
-	/*
-	 * Usually, the first mapping
-	 * established to a PCI device
-	 * is to its config space.
-	 *
-	 * In any case, we definitely
-	 * do NOT need to worry about
-	 * PCI BASE registers, and
-	 * MUST NOT attempt to point
-	 * the DevIO(x) window at
-	 * this access ...
-	 */
-	if (((flags & PCIIO_BYTE_STREAM) == 0) &&
-	    ((pci_addr + req_size) <= BRIDGE_TYPE0_CFG_FUNC_OFF))
-	    xio_addr = pci_addr + PCIBR_TYPE0_CFG_DEV(pcibr_soft, slot);
-
-	goto done;
-    }
-    if (space == PCIIO_SPACE_ROM) {
-	/* PIO to the Expansion Rom.
-	 * Driver is responsible for
-	 * enabling and disabling
-	 * decodes properly.
-	 */
-	wbase = pciio_info->c_rbase;
-	wsize = pciio_info->c_rsize;
-
-	/*
-	 * While the driver should know better
-	 * than to attempt to map more space
-	 * than the device is decoding, he might
-	 * do it; better to bail out here.
-	 */
-	if ((pci_addr + req_size) > wsize)
-	    goto done;
-
-	pci_addr += wbase;
-	space = PCIIO_SPACE_MEM;
-    }
-    /*
-     * reduce window mappings to raw
-     * space mappings (maybe allocating
-     * windows), and try for DevIO(x)
-     * usage (setting it if it is available).
-     */
-    bar = space - PCIIO_SPACE_WIN0;
-    if (bar < 6) {
-	wspace = pciio_info->c_window[bar].w_space;
-	if (wspace == PCIIO_SPACE_NONE)
-	    goto done;
-
-	/* get PCI base and size */
-	wbase = pciio_info->c_window[bar].w_base;
-	wsize = pciio_info->c_window[bar].w_size;
-
-	/*
-	 * While the driver should know better
-	 * than to attempt to map more space
-	 * than the device is decoding, he might
-	 * do it; better to bail out here.
-	 */
-	if ((pci_addr + req_size) > wsize)
-	    goto done;
-
-	/* shift from window relative to
-	 * decoded space relative.
-	 */
-	pci_addr += wbase;
-	space = wspace;
-    } else
-	bar = -1;
-
-    /* Scan all the DevIO(x) windows twice looking for one
-     * that can satisfy our request. The first time through,
-     * only look at assigned windows; the second time, also
-     * look at PCIIO_SPACE_NONE windows. Arrange the order
-     * so we always look at our own window first.
-     *
-     * We will not attempt to satisfy a single request
-     * by concatinating multiple windows.
-     */
-    maxtry = PCIBR_NUM_SLOTS(pcibr_soft) * 2;
-    halftry = PCIBR_NUM_SLOTS(pcibr_soft) - 1;
-    for (try = 0; try < maxtry; ++try) {
-	uint64_t		devreg;
-	unsigned                offset;
-
-	/* calculate win based on slot, attempt, and max possible
-	   devices on bus */
-	win = (try + slot) % PCIBR_NUM_SLOTS(pcibr_soft);
-
-	/* If this DevIO(x) mapping area can provide
-	 * a mapping to this address, use it.
-	 */
-	msize = (win < 2) ? 0x200000 : 0x100000;
-	mmask = -msize;
-	if (space != PCIIO_SPACE_IO)
-	    mmask &= 0x3FFFFFFF;
-
-	offset = pci_addr & (msize - 1);
-
-	/* If this window can't possibly handle that request,
-	 * go on to the next window.
-	 */
-	if (((pci_addr & (msize - 1)) + req_size) > msize)
-	    continue;
-
-	devreg = pcibr_soft->bs_slot[win].bss_device;
-
-	/* Is this window "nailed down"?
-	 * If not, maybe we can use it.
-	 * (only check this the second time through)
-	 */
-	mspace = pcibr_soft->bs_slot[win].bss_devio.bssd_space;
-	if ((try > halftry) && (mspace == PCIIO_SPACE_NONE)) {
-
-	    /* If this is the primary DevIO(x) window
-	     * for some other device, skip it.
-	     */
-	    if ((win != slot) &&
-		(PCIIO_VENDOR_ID_NONE !=
-		 pcibr_soft->bs_slot[win].bss_vendor_id))
-		continue;
-
-	    /* It's a free window, and we fit in it.
-	     * Set up Device(win) to our taste.
-	     */
-	    mbase = pci_addr & mmask;
-
-	    /* check that we would really get from
-	     * here to there.
-	     */
-	    if ((mbase | offset) != pci_addr)
-		continue;
-
-	    devreg &= ~BRIDGE_DEV_OFF_MASK;
-	    if (space != PCIIO_SPACE_IO)
-		devreg |= BRIDGE_DEV_DEV_IO_MEM;
-	    else
-		devreg &= ~BRIDGE_DEV_DEV_IO_MEM;
-	    devreg |= (mbase >> 20) & BRIDGE_DEV_OFF_MASK;
-
-	    /* default is WORD_VALUES.
-	     * if you specify both,
-	     * operation is undefined.
-	     */
-	    if (flags & PCIIO_BYTE_STREAM)
-		devreg |= BRIDGE_DEV_DEV_SWAP;
-	    else
-		devreg &= ~BRIDGE_DEV_DEV_SWAP;
-
-	    if (pcibr_soft->bs_slot[win].bss_device != devreg) {
-		pcireg_device_set(pcibr_soft, win, devreg);
-		pcibr_soft->bs_slot[win].bss_device = devreg;
-		pcireg_tflush_get(pcibr_soft);	
-
-		PCIBR_DEBUG((PCIBR_DEBUG_DEVREG, pconn_vhdl, 
-			    "pcibr_addr_pci_to_xio: Device(%d): 0x%x\n",
-			    win, devreg));
-	    }
-	    pcibr_soft->bs_slot[win].bss_devio.bssd_space = space;
-	    pcibr_soft->bs_slot[win].bss_devio.bssd_base = mbase;
-	    xio_addr = PCIBR_BRIDGE_DEVIO(pcibr_soft, win) + (pci_addr - mbase);
-
-            /* Increment this DevIO's use count */
-            pcibr_soft->bs_slot[win].bss_devio.bssd_ref_cnt++;
-
-            /* Save the DevIO register index used to access this BAR */
-            if (bar != -1)
-                pcibr_info->f_window[bar].w_devio_index = win;
-
-	    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_addr_pci_to_xio: map to space %s [0x%lx..0x%lx] "
-		    "for slot %d allocates DevIO(%d) Device(%d) set to %lx\n",
-		    pci_space[space], pci_addr, pci_addr + req_size - 1,
-		    slot, win, win, devreg));
-
-	    goto done;
-	}				/* endif DevIO(x) not pointed */
-	mbase = pcibr_soft->bs_slot[win].bss_devio.bssd_base;
-
-	/* Now check for request incompat with DevIO(x)
-	 */
-	if ((mspace != space) ||
-	    (pci_addr < mbase) ||
-	    ((pci_addr + req_size) > (mbase + msize)) ||
-	    ((flags & PCIIO_BYTE_STREAM) && !(devreg & BRIDGE_DEV_DEV_SWAP)) ||
-	    (!(flags & PCIIO_BYTE_STREAM) && (devreg & BRIDGE_DEV_DEV_SWAP)))
-	    continue;
-
-	/* DevIO(x) window is pointed at PCI space
-	 * that includes our target. Calculate the
-	 * final XIO address, release the lock and
-	 * return.
-	 */
-	xio_addr = PCIBR_BRIDGE_DEVIO(pcibr_soft, win) + (pci_addr - mbase);
-
-        /* Increment this DevIO's use count */
-        pcibr_soft->bs_slot[win].bss_devio.bssd_ref_cnt++;
-
-        /* Save the DevIO register index used to access this BAR */
-        if (bar != -1)
-            pcibr_info->f_window[bar].w_devio_index = win;
-
-	PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		"pcibr_addr_pci_to_xio: map to space %s [0x%lx..0x%lx] "
-		"for slot %d uses DevIO(%d)\n", pci_space[space],
-		pci_addr, pci_addr + req_size - 1, slot, win));
-	goto done;
-    }
-
-    switch (space) {
-	/*
-	 * Accesses to device decode
-	 * areas that do a not fit
-	 * within the DevIO(x) space are
-	 * modified to be accesses via
-	 * the direct mapping areas.
-	 *
-	 * If necessary, drivers can
-	 * explicitly ask for mappings
-	 * into these address spaces,
-	 * but this should never be needed.
-	 */
-    case PCIIO_SPACE_MEM:		/* "mem space" */
-    case PCIIO_SPACE_MEM32:		/* "mem, use 32-bit-wide bus" */
-	if (IS_PIC_BUSNUM_SOFT(pcibr_soft, 0)) {	/* PIC bus 0 */
-		base = PICBRIDGE0_PCI_MEM32_BASE;
-		limit = PICBRIDGE0_PCI_MEM32_LIMIT;
-	} else if (IS_PIC_BUSNUM_SOFT(pcibr_soft, 1)) {	/* PIC bus 1 */
-		base = PICBRIDGE1_PCI_MEM32_BASE;
-		limit = PICBRIDGE1_PCI_MEM32_LIMIT;
-	} else {
-		printk("pcibr_addr_pci_to_xio(): unknown bridge type");
-		return (iopaddr_t)0;
-	}
-
-	if ((pci_addr + base + req_size - 1) <= limit)
-	    xio_addr = pci_addr + base;
-	break;
-
-    case PCIIO_SPACE_MEM64:		/* "mem, use 64-bit-wide bus" */
-	if (IS_PIC_BUSNUM_SOFT(pcibr_soft, 0)) {	/* PIC bus 0 */
-		base = PICBRIDGE0_PCI_MEM64_BASE;
-		limit = PICBRIDGE0_PCI_MEM64_LIMIT;
-	} else if (IS_PIC_BUSNUM_SOFT(pcibr_soft, 1)) {	/* PIC bus 1 */
-		base = PICBRIDGE1_PCI_MEM64_BASE;
-		limit = PICBRIDGE1_PCI_MEM64_LIMIT;
-	} else {
-		printk("pcibr_addr_pci_to_xio(): unknown bridge type");
-		return (iopaddr_t)0;
-	}
-
-	if ((pci_addr + base + req_size - 1) <= limit)
-	    xio_addr = pci_addr + base;
-	break;
-
-    case PCIIO_SPACE_IO:		/* "i/o space" */
-	/*
-	 * PIC bridges do not support big-window aliases into PCI I/O space
-	 */
-	xio_addr = XIO_NOWHERE;
-	break;
-    }
-
-    /* Check that "Direct PIO" byteswapping matches,
-     * try to change it if it does not.
-     */
-    if (xio_addr != XIO_NOWHERE) {
-	unsigned                bst;	/* nonzero to set bytestream */
-	unsigned               *bfp;	/* addr of record of how swapper is set */
-	uint64_t		swb;	/* which control bit to mung */
-	unsigned                bfo;	/* current swapper setting */
-	unsigned                bfn;	/* desired swapper setting */
-
-	bfp = ((space == PCIIO_SPACE_IO)
-	       ? (&pcibr_soft->bs_pio_end_io)
-	       : (&pcibr_soft->bs_pio_end_mem));
-
-	bfo = *bfp;
-
-	bst = flags & PCIIO_BYTE_STREAM;
-
-	bfn = bst ? PCIIO_BYTE_STREAM : PCIIO_WORD_VALUES;
-
-	if (bfn == bfo) {		/* we already match. */
-	    ;
-	} else if (bfo != 0) {		/* we have a conflict. */
-	    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_addr_pci_to_xio: swap conflict in %s, "
-		    "was%s%s, want%s%s\n", pci_space[space],
-		    bfo & PCIIO_BYTE_STREAM ? " BYTE_STREAM" : "",
-		    bfo & PCIIO_WORD_VALUES ? " WORD_VALUES" : "",
-		    bfn & PCIIO_BYTE_STREAM ? " BYTE_STREAM" : "",
-		    bfn & PCIIO_WORD_VALUES ? " WORD_VALUES" : ""));
-	    xio_addr = XIO_NOWHERE;
-	} else {			/* OK to make the change. */
-	    swb = (space == PCIIO_SPACE_IO) ? 0: BRIDGE_CTRL_MEM_SWAP;
-	    if (bst) {
-		pcireg_control_bit_set(pcibr_soft, swb);
-	    } else {
-		pcireg_control_bit_clr(pcibr_soft, swb);
-	    }
-
-	    *bfp = bfn;			/* record the assignment */
-
-	    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_addr_pci_to_xio: swap for %s set to%s%s\n",
-		    pci_space[space],
-		    bfn & PCIIO_BYTE_STREAM ? " BYTE_STREAM" : "",
-		    bfn & PCIIO_WORD_VALUES ? " WORD_VALUES" : ""));
-	}
-    }
-  done:
-    pcibr_unlock(pcibr_soft, s);
-    return xio_addr;
-}
-
-/*ARGSUSED6 */
-pcibr_piomap_t
-pcibr_piomap_alloc(vertex_hdl_t pconn_vhdl,
-		   device_desc_t dev_desc,
-		   pciio_space_t space,
-		   iopaddr_t pci_addr,
-		   size_t req_size,
-		   size_t req_size_max,
-		   unsigned flags)
-{
-    pcibr_info_t	    pcibr_info = pcibr_info_get(pconn_vhdl);
-    pciio_info_t            pciio_info = &pcibr_info->f_c;
-    pciio_slot_t            pciio_slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    vertex_hdl_t            xconn_vhdl = pcibr_soft->bs_conn;
-
-    pcibr_piomap_t         *mapptr;
-    pcibr_piomap_t          maplist;
-    pcibr_piomap_t          pcibr_piomap;
-    iopaddr_t               xio_addr;
-    xtalk_piomap_t          xtalk_piomap;
-    unsigned long           s;
-
-    /* Make sure that the req sizes are non-zero */
-    if ((req_size < 1) || (req_size_max < 1)) {
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_piomap_alloc: req_size | req_size_max < 1\n"));
-	return NULL;
-    }
-
-    /*
-     * Code to translate slot/space/addr
-     * into xio_addr is common between
-     * this routine and pcibr_piotrans_addr.
-     */
-    xio_addr = pcibr_addr_pci_to_xio(pconn_vhdl, pciio_slot, space, pci_addr, req_size, flags);
-
-    if (xio_addr == XIO_NOWHERE) {
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_piomap_alloc: xio_addr == XIO_NOWHERE\n"));
-	return NULL;
-    }
-
-    /* Check the piomap list to see if there is already an allocated
-     * piomap entry but not in use. If so use that one. Otherwise
-     * allocate a new piomap entry and add it to the piomap list
-     */
-    mapptr = &(pcibr_info->f_piomap);
-
-    s = pcibr_lock(pcibr_soft);
-    for (pcibr_piomap = *mapptr;
-	 pcibr_piomap != NULL;
-	 pcibr_piomap = pcibr_piomap->bp_next) {
-	if (pcibr_piomap->bp_mapsz == 0)
-	    break;
-    }
-
-    if (pcibr_piomap)
-	mapptr = NULL;
-    else {
-	pcibr_unlock(pcibr_soft, s);
-	pcibr_piomap = kmalloc(sizeof (*(pcibr_piomap)), GFP_KERNEL);
-	if ( !pcibr_piomap ) {
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    	"pcibr_piomap_alloc: malloc fails\n"));
-		return NULL;
-	}
-	memset(pcibr_piomap, 0, sizeof (*(pcibr_piomap)));
-    }
-
-    pcibr_piomap->bp_dev = pconn_vhdl;
-    pcibr_piomap->bp_slot = PCIBR_DEVICE_TO_SLOT(pcibr_soft, pciio_slot);
-    pcibr_piomap->bp_flags = flags;
-    pcibr_piomap->bp_space = space;
-    pcibr_piomap->bp_pciaddr = pci_addr;
-    pcibr_piomap->bp_mapsz = req_size;
-    pcibr_piomap->bp_soft = pcibr_soft;
-    pcibr_piomap->bp_toc = ATOMIC_INIT(0);
-
-    if (mapptr) {
-	s = pcibr_lock(pcibr_soft);
-	maplist = *mapptr;
-	pcibr_piomap->bp_next = maplist;
-	*mapptr = pcibr_piomap;
-    }
-    pcibr_unlock(pcibr_soft, s);
-
-
-    if (pcibr_piomap) {
-	xtalk_piomap =
-	    xtalk_piomap_alloc(xconn_vhdl, 0,
-			       xio_addr,
-			       req_size, req_size_max,
-			       flags & PIOMAP_FLAGS);
-	if (xtalk_piomap) {
-	    pcibr_piomap->bp_xtalk_addr = xio_addr;
-	    pcibr_piomap->bp_xtalk_pio = xtalk_piomap;
-	} else {
-	    pcibr_piomap->bp_mapsz = 0;
-	    pcibr_piomap = 0;
-	}
-    }
-    
-    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		"pcibr_piomap_alloc: map=0x%lx\n", pcibr_piomap));
-
-    return pcibr_piomap;
-}
-
-/*ARGSUSED */
-void
-pcibr_piomap_free(pcibr_piomap_t pcibr_piomap)
-{
-    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pcibr_piomap->bp_dev,
-		"pcibr_piomap_free: map=0x%lx\n", pcibr_piomap));
-
-    xtalk_piomap_free(pcibr_piomap->bp_xtalk_pio);
-    pcibr_piomap->bp_xtalk_pio = 0;
-    pcibr_piomap->bp_mapsz = 0;
-}
-
-/*ARGSUSED */
-caddr_t
-pcibr_piomap_addr(pcibr_piomap_t pcibr_piomap,
-		  iopaddr_t pci_addr,
-		  size_t req_size)
-{
-    caddr_t	addr;
-    addr = xtalk_piomap_addr(pcibr_piomap->bp_xtalk_pio,
-			     pcibr_piomap->bp_xtalk_addr +
-			     pci_addr - pcibr_piomap->bp_pciaddr,
-			     req_size);
-    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pcibr_piomap->bp_dev,
-                "pcibr_piomap_addr: map=0x%lx, addr=0x%lx\n", 
-		pcibr_piomap, addr));
-
-    return addr;
-}
-
-/*ARGSUSED */
-void
-pcibr_piomap_done(pcibr_piomap_t pcibr_piomap)
-{
-    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pcibr_piomap->bp_dev,
-		"pcibr_piomap_done: map=0x%lx\n", pcibr_piomap));
-    xtalk_piomap_done(pcibr_piomap->bp_xtalk_pio);
-}
-
-/*ARGSUSED */
-caddr_t
-pcibr_piotrans_addr(vertex_hdl_t pconn_vhdl,
-		    device_desc_t dev_desc,
-		    pciio_space_t space,
-		    iopaddr_t pci_addr,
-		    size_t req_size,
-		    unsigned flags)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pciio_slot_t            pciio_slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    vertex_hdl_t            xconn_vhdl = pcibr_soft->bs_conn;
-
-    iopaddr_t               xio_addr;
-    caddr_t		    addr;
-
-    xio_addr = pcibr_addr_pci_to_xio(pconn_vhdl, pciio_slot, space, pci_addr, req_size, flags);
-
-    if (xio_addr == XIO_NOWHERE) {
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIODIR, pconn_vhdl,
-		    "pcibr_piotrans_addr: xio_addr == XIO_NOWHERE\n"));
-	return NULL;
-    }
-
-    addr = xtalk_piotrans_addr(xconn_vhdl, 0, xio_addr, req_size, flags & PIOMAP_FLAGS);
-    PCIBR_DEBUG((PCIBR_DEBUG_PIODIR, pconn_vhdl,
-		"pcibr_piotrans_addr: xio_addr=0x%lx, addr=0x%lx\n",
-		xio_addr, addr));
-    return addr;
-}
-
-/*
- * PIO Space allocation and management.
- *      Allocate and Manage the PCI PIO space (mem and io space)
- *      This routine is pretty simplistic at this time, and
- *      does pretty trivial management of allocation and freeing.
- *      The current scheme is prone for fragmentation.
- *      Change the scheme to use bitmaps.
- */
-
-/*ARGSUSED */
-iopaddr_t
-pcibr_piospace_alloc(vertex_hdl_t pconn_vhdl,
-		     device_desc_t dev_desc,
-		     pciio_space_t space,
-		     size_t req_size,
-		     size_t alignment)
-{
-    pcibr_info_t            pcibr_info = pcibr_info_get(pconn_vhdl);
-    pciio_info_t            pciio_info = &pcibr_info->f_c;
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-
-    pciio_piospace_t        piosp;
-    unsigned long           s;
-
-    iopaddr_t               start_addr;
-    size_t                  align_mask;
-
-    /*
-     * Check for proper alignment
-     */
-    ASSERT(alignment >= PAGE_SIZE);
-    ASSERT((alignment & (alignment - 1)) == 0);
-
-    align_mask = alignment - 1;
-    s = pcibr_lock(pcibr_soft);
-
-    /*
-     * First look if a previously allocated chunk exists.
-     */
-    piosp = pcibr_info->f_piospace;
-    if (piosp) {
-	/*
-	 * Look through the list for a right sized free chunk.
-	 */
-	do {
-	    if (piosp->free &&
-		(piosp->space == space) &&
-		(piosp->count >= req_size) &&
-		!(piosp->start & align_mask)) {
-		piosp->free = 0;
-		pcibr_unlock(pcibr_soft, s);
-		return piosp->start;
-	    }
-	    piosp = piosp->next;
-	} while (piosp);
-    }
-    ASSERT(!piosp);
-
-    /*
-     * Allocate PCI bus address, usually for the Universe chip driver;
-     * do not pass window info since the actual PCI bus address
-     * space will never be freed.  The space may be reused after it
-     * is logically released by pcibr_piospace_free().
-     */
-    switch (space) {
-    case PCIIO_SPACE_IO:
-        start_addr = pcibr_bus_addr_alloc(pcibr_soft, NULL,
-                                          PCIIO_SPACE_IO,
-                                          0, req_size, alignment);
-	break;
-
-    case PCIIO_SPACE_MEM:
-    case PCIIO_SPACE_MEM32:
-        start_addr = pcibr_bus_addr_alloc(pcibr_soft, NULL,
-                                          PCIIO_SPACE_MEM32,
-                                          0, req_size, alignment);
-	break;
-
-    default:
-	ASSERT(0);
-	pcibr_unlock(pcibr_soft, s);
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_piospace_alloc: unknown space %d\n", space));
-	return 0;
-    }
-
-    /*
-     * If too big a request, reject it.
-     */
-    if (!start_addr) {
-	pcibr_unlock(pcibr_soft, s);
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_piospace_alloc: request 0x%lx to big\n", req_size));
-	return 0;
-    }
-
-    piosp = kmalloc(sizeof (*(piosp)), GFP_KERNEL);
-    if ( !piosp ) {
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_piospace_alloc: malloc fails\n"));
-	return 0;
-    }
-    memset(piosp, 0, sizeof (*(piosp)));
-
-    piosp->free = 0;
-    piosp->space = space;
-    piosp->start = start_addr;
-    piosp->count = req_size;
-    piosp->next = pcibr_info->f_piospace;
-    pcibr_info->f_piospace = piosp;
-
-    pcibr_unlock(pcibr_soft, s);
-
-    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		"pcibr_piospace_alloc: piosp=0x%lx\n", piosp));
-
-    return start_addr;
-}
-
-#define ERR_MSG "!Device %s freeing size (0x%lx) different than allocated (0x%lx)"
-/*ARGSUSED */
-void
-pcibr_piospace_free(vertex_hdl_t pconn_vhdl,
-		    pciio_space_t space,
-		    iopaddr_t pciaddr,
-		    size_t req_size)
-{
-    pcibr_info_t            pcibr_info = pcibr_info_get(pconn_vhdl);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pcibr_info->f_mfast;
-    pciio_piospace_t        piosp;
-    unsigned long           s;
-    char                    name[1024];
-
-    /*
-     * Look through the bridge data structures for the pciio_piospace_t
-     * structure corresponding to  'pciaddr'
-     */
-    s = pcibr_lock(pcibr_soft);
-    piosp = pcibr_info->f_piospace;
-    while (piosp) {
-	/*
-	 * Piospace free can only be for the complete
-	 * chunk and not parts of it..
-	 */
-	if (piosp->start == pciaddr) {
-	    if (piosp->count == req_size)
-		break;
-	    /*
-	     * Improper size passed for freeing..
-	     * Print a message and break;
-	     */
-	    hwgraph_vertex_name_get(pconn_vhdl, name, 1024);
-	    printk(KERN_WARNING  "pcibr_piospace_free: error");
-	    printk(KERN_WARNING  "Device %s freeing size (0x%lx) different than allocated (0x%lx)",
-					name, req_size, piosp->count);
-	    printk(KERN_WARNING  "Freeing 0x%lx instead", piosp->count);
-	    break;
-	}
-	piosp = piosp->next;
-    }
-
-    if (!piosp) {
-	printk(KERN_WARNING  
-		"pcibr_piospace_free: Address 0x%lx size 0x%lx - No match\n",
-		pciaddr, req_size);
-	pcibr_unlock(pcibr_soft, s);
-	return;
-    }
-    piosp->free = 1;
-    pcibr_unlock(pcibr_soft, s);
-
-    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		"pcibr_piospace_free: piosp=0x%lx\n", piosp));
-    return;
-}
-
-/* =====================================================================
- *    DMA MANAGEMENT
- *
- *      The Bridge ASIC provides three methods of doing
- *      DMA: via a "direct map" register available in
- *      32-bit PCI space (which selects a contiguous 2G
- *      address space on some other widget), via
- *      "direct" addressing via 64-bit PCI space (all
- *      destination information comes from the PCI
- *      address, including transfer attributes), and via
- *      a "mapped" region that allows a bunch of
- *      different small mappings to be established with
- *      the PMU.
- *
- *      For efficiency, we most prefer to use the 32-bit
- *      direct mapping facility, since it requires no
- *      resource allocations. The advantage of using the
- *      PMU over the 64-bit direct is that single-cycle
- *      PCI addressing can be used; the advantage of
- *      using 64-bit direct over PMU addressing is that
- *      we do not have to allocate entries in the PMU.
- */
-
-/*
- * Convert PCI-generic software flags and Bridge-specific software flags
- * into Bridge-specific Direct Map attribute bits.
- */
-static iopaddr_t
-pcibr_flags_to_d64(unsigned flags, pcibr_soft_t pcibr_soft)
-{
-    iopaddr_t               attributes = 0;
-
-    /* Sanity check: Bridge only allows use of VCHAN1 via 64-bit addrs */
-#ifdef LATER
-    ASSERT_ALWAYS(!(flags & PCIBR_VCHAN1) || (flags & PCIIO_DMA_A64));
-#endif
-
-    /* Generic macro flags
-     */
-    if (flags & PCIIO_DMA_DATA) {	/* standard data channel */
-	attributes &= ~PCI64_ATTR_BAR;	/* no barrier bit */
-	attributes |= PCI64_ATTR_PREF;	/* prefetch on */
-    }
-    if (flags & PCIIO_DMA_CMD) {	/* standard command channel */
-	attributes |= PCI64_ATTR_BAR;	/* barrier bit on */
-	attributes &= ~PCI64_ATTR_PREF;	/* disable prefetch */
-    }
-    /* Generic detail flags
-     */
-    if (flags & PCIIO_PREFETCH)
-	attributes |= PCI64_ATTR_PREF;
-    if (flags & PCIIO_NOPREFETCH)
-	attributes &= ~PCI64_ATTR_PREF;
-
-    /* the swap bit is in the address attributes for xbridge */
-    if (flags & PCIIO_BYTE_STREAM)
-       	attributes |= PCI64_ATTR_SWAP;
-    if (flags & PCIIO_WORD_VALUES)
-       	attributes &= ~PCI64_ATTR_SWAP;
-
-    /* Provider-specific flags
-     */
-    if (flags & PCIBR_BARRIER)
-	attributes |= PCI64_ATTR_BAR;
-    if (flags & PCIBR_NOBARRIER)
-	attributes &= ~PCI64_ATTR_BAR;
-
-    if (flags & PCIBR_PREFETCH)
-	attributes |= PCI64_ATTR_PREF;
-    if (flags & PCIBR_NOPREFETCH)
-	attributes &= ~PCI64_ATTR_PREF;
-
-    if (flags & PCIBR_PRECISE)
-	attributes |= PCI64_ATTR_PREC;
-    if (flags & PCIBR_NOPRECISE)
-	attributes &= ~PCI64_ATTR_PREC;
-
-    if (flags & PCIBR_VCHAN1)
-	attributes |= PCI64_ATTR_VIRTUAL;
-    if (flags & PCIBR_VCHAN0)
-	attributes &= ~PCI64_ATTR_VIRTUAL;
-
-    /* PIC in PCI-X mode only supports barrier & swap */
-    if (IS_PCIX(pcibr_soft)) {
-	attributes &= (PCI64_ATTR_BAR | PCI64_ATTR_SWAP);
-    }
-
-    return attributes;
-}
-
-/*ARGSUSED */
-pcibr_dmamap_t
-pcibr_dmamap_alloc(vertex_hdl_t pconn_vhdl,
-		   device_desc_t dev_desc,
-		   size_t req_size_max,
-		   unsigned flags)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    vertex_hdl_t            xconn_vhdl = pcibr_soft->bs_conn;
-    pciio_slot_t            slot;
-    xwidgetnum_t            xio_port;
-
-    xtalk_dmamap_t          xtalk_dmamap;
-    pcibr_dmamap_t          pcibr_dmamap;
-    int                     ate_count;
-    int                     ate_index;
-    int			    vchan = VCHAN0;
-    unsigned long	    s;
-
-    /* merge in forced flags */
-    flags |= pcibr_soft->bs_dma_flags;
-
-    /*
-     * On SNIA64, these maps are pre-allocated because pcibr_dmamap_alloc()
-     * can be called within an interrupt thread.
-     */
-    s = pcibr_lock(pcibr_soft);
-    pcibr_dmamap = (pcibr_dmamap_t)get_free_pciio_dmamap(pcibr_soft->bs_vhdl);
-    pcibr_unlock(pcibr_soft, s);
-
-    if (!pcibr_dmamap)
-	return 0;
-
-    xtalk_dmamap = xtalk_dmamap_alloc(xconn_vhdl, dev_desc, req_size_max,
-				      flags & DMAMAP_FLAGS);
-    if (!xtalk_dmamap) {
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP, pconn_vhdl,
-		    "pcibr_dmamap_alloc: xtalk_dmamap_alloc failed\n"));
-	free_pciio_dmamap(pcibr_dmamap);
-	return 0;
-    }
-    xio_port = pcibr_soft->bs_mxid;
-    slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-
-    pcibr_dmamap->bd_dev = pconn_vhdl;
-    pcibr_dmamap->bd_slot = PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot);
-    pcibr_dmamap->bd_soft = pcibr_soft;
-    pcibr_dmamap->bd_xtalk = xtalk_dmamap;
-    pcibr_dmamap->bd_max_size = req_size_max;
-    pcibr_dmamap->bd_xio_port = xio_port;
-
-    if (flags & PCIIO_DMA_A64) {
-	if (!pcibr_try_set_device(pcibr_soft, slot, flags, BRIDGE_DEV_D64_BITS)) {
-	    iopaddr_t               pci_addr;
-	    int                     have_rrbs;
-	    int                     min_rrbs;
-
-	    /* Device is capable of A64 operations,
-	     * and the attributes of the DMA are
-	     * consistent with any previous DMA
-	     * mappings using shared resources.
-	     */
-
-	    pci_addr = pcibr_flags_to_d64(flags, pcibr_soft);
-
-	    pcibr_dmamap->bd_flags = flags;
-	    pcibr_dmamap->bd_xio_addr = 0;
-	    pcibr_dmamap->bd_pci_addr = pci_addr;
-
-	    /* If in PCI mode, make sure we have an RRB (or two). 
-	     */
-	    if (IS_PCI(pcibr_soft) && 
-		!(pcibr_soft->bs_rrb_fixed & (1 << slot))) {
-		if (flags & PCIBR_VCHAN1)
-		    vchan = VCHAN1;
-		have_rrbs = pcibr_soft->bs_rrb_valid[slot][vchan];
-		if (have_rrbs < 2) {
-		    if (pci_addr & PCI64_ATTR_PREF)
-			min_rrbs = 2;
-		    else
-			min_rrbs = 1;
-		    if (have_rrbs < min_rrbs)
-			pcibr_rrb_alloc_more(pcibr_soft, slot, vchan,
-					       min_rrbs - have_rrbs);
-		}
-	    }
-	    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		 	"pcibr_dmamap_alloc: using direct64, map=0x%lx\n",
-			pcibr_dmamap));
-	    return pcibr_dmamap;
-	}
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		    "pcibr_dmamap_alloc: unable to use direct64\n"));
-
-	/* PIC in PCI-X mode only supports 64-bit direct mapping so
-	 * don't fall thru and try 32-bit direct mapping or 32-bit
-	 * page mapping
-	 */
-	if (IS_PCIX(pcibr_soft)) {
-	    kfree(pcibr_dmamap);
-	    return 0;
-	}
-
-	flags &= ~PCIIO_DMA_A64;
-    }
-    if (flags & PCIIO_FIXED) {
-	/* warning: mappings may fail later,
-	 * if direct32 can't get to the address.
-	 */
-	if (!pcibr_try_set_device(pcibr_soft, slot, flags, BRIDGE_DEV_D32_BITS)) {
-	    /* User desires DIRECT A32 operations,
-	     * and the attributes of the DMA are
-	     * consistent with any previous DMA
-	     * mappings using shared resources.
-	     * Mapping calls may fail if target
-	     * is outside the direct32 range.
-	     */
-	    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, pconn_vhdl,
-			"pcibr_dmamap_alloc: using direct32, map=0x%lx\n", 
-			pcibr_dmamap));
-	    pcibr_dmamap->bd_flags = flags;
-	    pcibr_dmamap->bd_xio_addr = pcibr_soft->bs_dir_xbase;
-	    pcibr_dmamap->bd_pci_addr = PCI32_DIRECT_BASE;
-	    return pcibr_dmamap;
-	}
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		    "pcibr_dmamap_alloc: unable to use direct32\n"));
-
-	/* If the user demands FIXED and we can't
-	 * give it to him, fail.
-	 */
-	xtalk_dmamap_free(xtalk_dmamap);
-	free_pciio_dmamap(pcibr_dmamap);
-	return 0;
-    }
-    /*
-     * Allocate Address Translation Entries from the mapping RAM.
-     * Unless the PCIBR_NO_ATE_ROUNDUP flag is specified,
-     * the maximum number of ATEs is based on the worst-case
-     * scenario, where the requested target is in the
-     * last byte of an ATE; thus, mapping IOPGSIZE+2
-     * does end up requiring three ATEs.
-     */
-    if (!(flags & PCIBR_NO_ATE_ROUNDUP)) {
-	ate_count = IOPG((IOPGSIZE - 1)	/* worst case start offset */
-		     +req_size_max	/* max mapping bytes */
-		     - 1) + 1;		/* round UP */
-    } else {	/* assume requested target is page aligned */
-	ate_count = IOPG(req_size_max   /* max mapping bytes */
-		     - 1) + 1;		/* round UP */
-    }
-
-    ate_index = pcibr_ate_alloc(pcibr_soft, ate_count, &pcibr_dmamap->resource);
-
-    if (ate_index != -1) {
-	if (!pcibr_try_set_device(pcibr_soft, slot, flags, BRIDGE_DEV_PMU_BITS)) {
-	    bridge_ate_t            ate_proto;
-	    int                     have_rrbs;
-	    int                     min_rrbs;
-
-	    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pconn_vhdl,
-			"pcibr_dmamap_alloc: using PMU, ate_index=%d, "
-			"pcibr_dmamap=0x%lx\n", ate_index, pcibr_dmamap));
-
-	    ate_proto = pcibr_flags_to_ate(pcibr_soft, flags);
-
-	    pcibr_dmamap->bd_flags = flags;
-	    pcibr_dmamap->bd_pci_addr =
-		PCI32_MAPPED_BASE + IOPGSIZE * ate_index;
-
-	    if (flags & PCIIO_BYTE_STREAM)
-		    ATE_SWAP_ON(pcibr_dmamap->bd_pci_addr);
-	    /*
-	     * If swap was set in bss_device in pcibr_endian_set()
-	     * we need to change the address bit.
-	     */
-	    if (pcibr_soft->bs_slot[slot].bss_device & 
-						BRIDGE_DEV_SWAP_PMU)
-		    ATE_SWAP_ON(pcibr_dmamap->bd_pci_addr);
-	    if (flags & PCIIO_WORD_VALUES)
-		    ATE_SWAP_OFF(pcibr_dmamap->bd_pci_addr);
-	    pcibr_dmamap->bd_xio_addr = 0;
-	    pcibr_dmamap->bd_ate_ptr = pcibr_ate_addr(pcibr_soft, ate_index);
-	    pcibr_dmamap->bd_ate_index = ate_index;
-	    pcibr_dmamap->bd_ate_count = ate_count;
-	    pcibr_dmamap->bd_ate_proto = ate_proto;
-
-	    /* Make sure we have an RRB (or two).
-	     */
-	    if (!(pcibr_soft->bs_rrb_fixed & (1 << slot))) {
-		have_rrbs = pcibr_soft->bs_rrb_valid[slot][vchan];
-		if (have_rrbs < 2) {
-		    if (ate_proto & ATE_PREF)
-			min_rrbs = 2;
-		    else
-			min_rrbs = 1;
-		    if (have_rrbs < min_rrbs)
-			pcibr_rrb_alloc_more(pcibr_soft, slot, vchan,
-					       min_rrbs - have_rrbs);
-		}
-	    }
-	    return pcibr_dmamap;
-	}
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP, pconn_vhdl,
-		    "pcibr_dmamap_alloc: PMU use failed, ate_index=%d\n",
-		    ate_index));
-
-	pcibr_ate_free(pcibr_soft, ate_index, ate_count, &pcibr_dmamap->resource);
-    }
-    /* total failure: sorry, you just can't
-     * get from here to there that way.
-     */
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP, pconn_vhdl,
-		"pcibr_dmamap_alloc: complete failure.\n"));
-    xtalk_dmamap_free(xtalk_dmamap);
-    free_pciio_dmamap(pcibr_dmamap);
-    return 0;
-}
-
-/*ARGSUSED */
-void
-pcibr_dmamap_free(pcibr_dmamap_t pcibr_dmamap)
-{
-    pcibr_soft_t            pcibr_soft = pcibr_dmamap->bd_soft;
-    pciio_slot_t            slot = PCIBR_SLOT_TO_DEVICE(pcibr_soft,
-							pcibr_dmamap->bd_slot);
-
-    xtalk_dmamap_free(pcibr_dmamap->bd_xtalk);
-
-    if (pcibr_dmamap->bd_flags & PCIIO_DMA_A64) {
-	pcibr_release_device(pcibr_soft, slot, BRIDGE_DEV_D64_BITS);
-    }
-    if (pcibr_dmamap->bd_ate_count) {
-	pcibr_ate_free(pcibr_dmamap->bd_soft,
-		       pcibr_dmamap->bd_ate_index,
-		       pcibr_dmamap->bd_ate_count,
-		       &pcibr_dmamap->resource);
-	pcibr_release_device(pcibr_soft, slot, XBRIDGE_DEV_PMU_BITS);
-    }
-
-    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pcibr_dmamap->bd_dev,
-		"pcibr_dmamap_free: pcibr_dmamap=0x%lx\n", pcibr_dmamap));
-
-    free_pciio_dmamap(pcibr_dmamap);
-}
-
-/*
- *    pcibr_addr_xio_to_pci: given a PIO range, hand
- *      back the corresponding base PCI MEM address;
- *      this is used to short-circuit DMA requests that
- *      loop back onto this PCI bus.
- */
-static iopaddr_t
-pcibr_addr_xio_to_pci(pcibr_soft_t soft,
-		      iopaddr_t xio_addr,
-		      size_t req_size)
-{
-    iopaddr_t               xio_lim = xio_addr + req_size - 1;
-    iopaddr_t               pci_addr;
-    pciio_slot_t            slot;
-
-    if (IS_PIC_BUSNUM_SOFT(soft, 0)) {
-    	if ((xio_addr >= PICBRIDGE0_PCI_MEM32_BASE) &&
-	    (xio_lim <= PICBRIDGE0_PCI_MEM32_LIMIT)) {
-	    pci_addr = xio_addr - PICBRIDGE0_PCI_MEM32_BASE;
-	    return pci_addr;
-    	}
-    	if ((xio_addr >= PICBRIDGE0_PCI_MEM64_BASE) &&
-	    (xio_lim <= PICBRIDGE0_PCI_MEM64_LIMIT)) {
-	    pci_addr = xio_addr - PICBRIDGE0_PCI_MEM64_BASE;
-	    return pci_addr;
-    	}
-    } else if (IS_PIC_BUSNUM_SOFT(soft, 1)) {
-    	if ((xio_addr >= PICBRIDGE1_PCI_MEM32_BASE) &&
-	    (xio_lim <= PICBRIDGE1_PCI_MEM32_LIMIT)) {
-	    pci_addr = xio_addr - PICBRIDGE1_PCI_MEM32_BASE;
-	    return pci_addr;
-    	}
-    	if ((xio_addr >= PICBRIDGE1_PCI_MEM64_BASE) &&
-	    (xio_lim <= PICBRIDGE1_PCI_MEM64_LIMIT)) {
-	    pci_addr = xio_addr - PICBRIDGE1_PCI_MEM64_BASE;
-	    return pci_addr;
-    	}
-    } else {
-	printk("pcibr_addr_xio_to_pci(): unknown bridge type");
-	return (iopaddr_t)0;
-    }
-    for (slot = soft->bs_min_slot; slot < PCIBR_NUM_SLOTS(soft); ++slot)
-	if ((xio_addr >= PCIBR_BRIDGE_DEVIO(soft, slot)) &&
-	    (xio_lim < PCIBR_BRIDGE_DEVIO(soft, slot + 1))) {
-	    uint64_t		dev;
-
-	    dev = soft->bs_slot[slot].bss_device;
-	    pci_addr = dev & BRIDGE_DEV_OFF_MASK;
-	    pci_addr <<= BRIDGE_DEV_OFF_ADDR_SHFT;
-	    pci_addr += xio_addr - PCIBR_BRIDGE_DEVIO(soft, slot);
-	    return (dev & BRIDGE_DEV_DEV_IO_MEM) ? pci_addr : PCI_NOWHERE;
-	}
-    return 0;
-}
-
-/*ARGSUSED */
-iopaddr_t
-pcibr_dmamap_addr(pcibr_dmamap_t pcibr_dmamap,
-		  paddr_t paddr,
-		  size_t req_size)
-{
-    pcibr_soft_t            pcibr_soft;
-    iopaddr_t               xio_addr;
-    xwidgetnum_t            xio_port;
-    iopaddr_t               pci_addr;
-    unsigned                flags;
-
-    ASSERT(pcibr_dmamap != NULL);
-    ASSERT(req_size > 0);
-    ASSERT(req_size <= pcibr_dmamap->bd_max_size);
-
-    pcibr_soft = pcibr_dmamap->bd_soft;
-
-    flags = pcibr_dmamap->bd_flags;
-
-    xio_addr = xtalk_dmamap_addr(pcibr_dmamap->bd_xtalk, paddr, req_size);
-    if (XIO_PACKED(xio_addr)) {
-	xio_port = XIO_PORT(xio_addr);
-	xio_addr = XIO_ADDR(xio_addr);
-    } else
-	xio_port = pcibr_dmamap->bd_xio_port;
-
-    /* If this DMA is to an address that
-     * refers back to this Bridge chip,
-     * reduce it back to the correct
-     * PCI MEM address.
-     */
-    if (xio_port == pcibr_soft->bs_xid) {
-	pci_addr = pcibr_addr_xio_to_pci(pcibr_soft, xio_addr, req_size);
-    } else if (flags & PCIIO_DMA_A64) {
-	/* A64 DMA:
-	 * always use 64-bit direct mapping,
-	 * which always works.
-	 * Device(x) was set up during
-	 * dmamap allocation.
-	 */
-
-	/* attributes are already bundled up into bd_pci_addr.
-	 */
-	pci_addr = pcibr_dmamap->bd_pci_addr
-	    | ((uint64_t) xio_port << PCI64_ATTR_TARG_SHFT)
-	    | xio_addr;
-
-	/* Bridge Hardware WAR #482836:
-	 * If the transfer is not cache aligned
-	 * and the Bridge Rev is <= B, force
-	 * prefetch to be off.
-	 */
-	if (flags & PCIBR_NOPREFETCH)
-	    pci_addr &= ~PCI64_ATTR_PREF;
-
-	PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, 
-		    pcibr_dmamap->bd_dev,
-		    "pcibr_dmamap_addr: (direct64): wanted paddr [0x%lx..0x%lx] "
-		    "XIO port 0x%x offset 0x%lx, returning PCI 0x%lx\n",
-		    paddr, paddr + req_size - 1, xio_port, xio_addr, pci_addr));
-
-    } else if (flags & PCIIO_FIXED) {
-	/* A32 direct DMA:
-	 * always use 32-bit direct mapping,
-	 * which may fail.
-	 * Device(x) was set up during
-	 * dmamap allocation.
-	 */
-
-	if (xio_port != pcibr_soft->bs_dir_xport)
-	    pci_addr = 0;		/* wrong DIDN */
-	else if (xio_addr < pcibr_dmamap->bd_xio_addr)
-	    pci_addr = 0;		/* out of range */
-	else if ((xio_addr + req_size) >
-		 (pcibr_dmamap->bd_xio_addr + BRIDGE_DMA_DIRECT_SIZE))
-	    pci_addr = 0;		/* out of range */
-	else
-	    pci_addr = pcibr_dmamap->bd_pci_addr +
-		xio_addr - pcibr_dmamap->bd_xio_addr;
-
-	PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, 
-		    pcibr_dmamap->bd_dev,
-		    "pcibr_dmamap_addr (direct32): wanted paddr [0x%lx..0x%lx] "
-		    "XIO port 0x%x offset 0x%lx, returning PCI 0x%lx\n",
-		    paddr, paddr + req_size - 1, xio_port, xio_addr, pci_addr));
-
-    } else {
-	iopaddr_t               offset = IOPGOFF(xio_addr);
-	bridge_ate_t            ate_proto = pcibr_dmamap->bd_ate_proto;
-	int                     ate_count = IOPG(offset + req_size - 1) + 1;
-	int                     ate_index = pcibr_dmamap->bd_ate_index;
-	bridge_ate_t            ate;
-
-	ate = ate_proto | (xio_addr - offset);
-	ate |= (xio_port << ATE_TIDSHIFT);
-
-	pci_addr = pcibr_dmamap->bd_pci_addr + offset;
-
-	/* Fill in our mapping registers
-	 * with the appropriate xtalk data,
-	 * and hand back the PCI address.
-	 */
-
-	ASSERT(ate_count > 0);
-	if (ate_count <= pcibr_dmamap->bd_ate_count) {
-		ate_write(pcibr_soft, ate_index, ate_count, ate);
-
-		PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pcibr_dmamap->bd_dev,
-			    "pcibr_dmamap_addr (PMU) : wanted paddr "
-			    "[0x%lx..0x%lx] returning PCI 0x%lx\n", 
-			    paddr, paddr + req_size - 1, pci_addr));
-
-	} else {
-		/* The number of ATE's required is greater than the number
-		 * allocated for this map. One way this can happen is if
-		 * pcibr_dmamap_alloc() was called with the PCIBR_NO_ATE_ROUNDUP
-		 * flag, and then when that map is used (right now), the
-		 * target address tells us we really did need to roundup.
-		 * The other possibility is that the map is just plain too
-		 * small to handle the requested target area.
-		 */
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP, pcibr_dmamap->bd_dev, 
-		            "pcibr_dmamap_addr (PMU) : wanted paddr "
-			    "[0x%lx..0x%lx] ate_count 0x%x bd_ate_count 0x%x "
-			    "ATE's required > number allocated\n",
-			     paddr, paddr + req_size - 1,
-			     ate_count, pcibr_dmamap->bd_ate_count));
-		pci_addr = 0;
-	}
-
-    }
-    return pci_addr;
-}
-
-/*ARGSUSED */
-void
-pcibr_dmamap_done(pcibr_dmamap_t pcibr_dmamap)
-{
-    xtalk_dmamap_done(pcibr_dmamap->bd_xtalk);
-
-    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pcibr_dmamap->bd_dev,
-		"pcibr_dmamap_done: pcibr_dmamap=0x%lx\n", pcibr_dmamap));
-}
-
-
-/*
- * For each bridge, the DIR_OFF value in the Direct Mapping Register
- * determines the PCI to Crosstalk memory mapping to be used for all
- * 32-bit Direct Mapping memory accesses. This mapping can be to any
- * node in the system. This function will return that compact node id.
- */
-
-/*ARGSUSED */
-cnodeid_t
-pcibr_get_dmatrans_node(vertex_hdl_t pconn_vhdl)
-{
-
-	pciio_info_t	pciio_info = pciio_info_get(pconn_vhdl);
-	pcibr_soft_t	pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-
-	return nasid_to_cnodeid(NASID_GET(pcibr_soft->bs_dir_xbase));
-}
-
-/*ARGSUSED */
-iopaddr_t
-pcibr_dmatrans_addr(vertex_hdl_t pconn_vhdl,
-		    device_desc_t dev_desc,
-		    paddr_t paddr,
-		    size_t req_size,
-		    unsigned flags)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    vertex_hdl_t            xconn_vhdl = pcibr_soft->bs_conn;
-    pciio_slot_t            pciio_slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-    pcibr_soft_slot_t       slotp = &pcibr_soft->bs_slot[pciio_slot];
-
-    xwidgetnum_t            xio_port;
-    iopaddr_t               xio_addr;
-    iopaddr_t               pci_addr;
-
-    int                     have_rrbs;
-    int                     min_rrbs;
-    int			    vchan = VCHAN0;
-
-    /* merge in forced flags */
-    flags |= pcibr_soft->bs_dma_flags;
-
-    xio_addr = xtalk_dmatrans_addr(xconn_vhdl, 0, paddr, req_size,
-				   flags & DMAMAP_FLAGS);
-    if (!xio_addr) {
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		    "pcibr_dmatrans_addr: wanted paddr [0x%lx..0x%lx], "
-		    "xtalk_dmatrans_addr failed with 0x%lx\n",
-		    paddr, paddr + req_size - 1, xio_addr));
-	return 0;
-    }
-    /*
-     * find which XIO port this goes to.
-     */
-    if (XIO_PACKED(xio_addr)) {
-	if (xio_addr == XIO_NOWHERE) {
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		        "pcibr_dmatrans_addr: wanted paddr [0x%lx..0x%lx], "
-		        "xtalk_dmatrans_addr failed with XIO_NOWHERE\n",
-		        paddr, paddr + req_size - 1));
-	    return 0;
-	}
-	xio_port = XIO_PORT(xio_addr);
-	xio_addr = XIO_ADDR(xio_addr);
-
-    } else
-	xio_port = pcibr_soft->bs_mxid;
-
-    /*
-     * If this DMA comes back to us,
-     * return the PCI MEM address on
-     * which it would land, or NULL
-     * if the target is something
-     * on bridge other than PCI MEM.
-     */
-    if (xio_port == pcibr_soft->bs_xid) {
-	pci_addr = pcibr_addr_xio_to_pci(pcibr_soft, xio_addr, req_size);
-        PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		    "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
-		    "xio_port=0x%x, pci_addr=0x%lx\n",
-		    paddr, paddr + req_size - 1, xio_port, pci_addr));
-	return pci_addr;
-    }
-    /* If the caller can use A64, try to
-     * satisfy the request with the 64-bit
-     * direct map. This can fail if the
-     * configuration bits in Device(x)
-     * conflict with our flags.
-     */
-
-    if (flags & PCIIO_DMA_A64) {
-	pci_addr = slotp->bss_d64_base;
-	if (!(flags & PCIBR_VCHAN1))
-	    flags |= PCIBR_VCHAN0;
-	if ((pci_addr != PCIBR_D64_BASE_UNSET) &&
-	    (flags == slotp->bss_d64_flags)) {
-
-	    pci_addr |= xio_addr |
-		((uint64_t) xio_port << PCI64_ATTR_TARG_SHFT);
-	    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-			"pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
-			"xio_port=0x%x, direct64: pci_addr=0x%lx\n",
-			paddr, paddr + req_size - 1, xio_addr, pci_addr));
-	    return pci_addr;
-	}
-	if (!pcibr_try_set_device(pcibr_soft, pciio_slot, flags, BRIDGE_DEV_D64_BITS)) {
-	    pci_addr = pcibr_flags_to_d64(flags, pcibr_soft);
-	    slotp->bss_d64_flags = flags;
-	    slotp->bss_d64_base = pci_addr;
-            pci_addr |= xio_addr
-		| ((uint64_t) xio_port << PCI64_ATTR_TARG_SHFT);
-
-	    /* If in PCI mode, make sure we have an RRB (or two).
-	     */
-	    if (IS_PCI(pcibr_soft) && 
-		!(pcibr_soft->bs_rrb_fixed & (1 << pciio_slot))) {
-		if (flags & PCIBR_VCHAN1)
-		    vchan = VCHAN1;
-		have_rrbs = pcibr_soft->bs_rrb_valid[pciio_slot][vchan];
-		if (have_rrbs < 2) {
-		    if (pci_addr & PCI64_ATTR_PREF)
-			min_rrbs = 2;
-		    else
-			min_rrbs = 1;
-		    if (have_rrbs < min_rrbs)
-			pcibr_rrb_alloc_more(pcibr_soft, pciio_slot, vchan,
-					       min_rrbs - have_rrbs);
-		}
-	    }
-	    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-			"pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
-			"xio_port=0x%x, direct64: pci_addr=0x%lx, "
-			"new flags: 0x%x\n", paddr, paddr + req_size - 1,
-			xio_addr, pci_addr, (uint64_t) flags));
-	    return pci_addr;
-	}
-
-	PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		    "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
-		    "xio_port=0x%x, Unable to set direct64 Device(x) bits\n",
-		    paddr, paddr + req_size - 1, xio_addr));
-
-	/* PIC only supports 64-bit direct mapping in PCI-X mode */
-	if (IS_PCIX(pcibr_soft)) {
-	    return 0;
-	}
-
-	/* our flags conflict with Device(x). try direct32*/
-	flags = flags & ~(PCIIO_DMA_A64 | PCIBR_VCHAN0);
-    } else {
-	/* BUS in PCI-X mode only supports 64-bit direct mapping */
-	if (IS_PCIX(pcibr_soft)) {
-	    return 0;
-	}
-    }
-    /* Try to satisfy the request with the 32-bit direct
-     * map. This can fail if the configuration bits in
-     * Device(x) conflict with our flags, or if the
-     * target address is outside where DIR_OFF points.
-     */
-    {
-	size_t                  map_size = 1ULL << 31;
-	iopaddr_t               xio_base = pcibr_soft->bs_dir_xbase;
-	iopaddr_t               offset = xio_addr - xio_base;
-	iopaddr_t               endoff = req_size + offset;
-
-	if ((req_size > map_size) ||
-	    (xio_addr < xio_base) ||
-	    (xio_port != pcibr_soft->bs_dir_xport) ||
-	    (endoff > map_size)) {
-
-	    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-			"pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
-			"xio_port=0x%x, xio region outside direct32 target\n",
-			paddr, paddr + req_size - 1, xio_addr));
-	} else {
-	    pci_addr = slotp->bss_d32_base;
-	    if ((pci_addr != PCIBR_D32_BASE_UNSET) &&
-		(flags == slotp->bss_d32_flags)) {
-
-		pci_addr |= offset;
-
-		PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-                            "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx],"
-                            " xio_port=0x%x, direct32: pci_addr=0x%lx\n",
-                            paddr, paddr + req_size - 1, xio_addr, pci_addr));
-
-		return pci_addr;
-	    }
-	    if (!pcibr_try_set_device(pcibr_soft, pciio_slot, flags, BRIDGE_DEV_D32_BITS)) {
-
-		pci_addr = PCI32_DIRECT_BASE;
-		slotp->bss_d32_flags = flags;
-		slotp->bss_d32_base = pci_addr;
-		pci_addr |= offset;
-
-		/* Make sure we have an RRB (or two).
-		 */
-		if (!(pcibr_soft->bs_rrb_fixed & (1 << pciio_slot))) {
-		    have_rrbs = pcibr_soft->bs_rrb_valid[pciio_slot][vchan];
-		    if (have_rrbs < 2) {
-			if (slotp->bss_device & BRIDGE_DEV_PREF)
-			    min_rrbs = 2;
-			else
-			    min_rrbs = 1;
-			if (have_rrbs < min_rrbs)
-			    pcibr_rrb_alloc_more(pcibr_soft, pciio_slot, 
-						   vchan, min_rrbs - have_rrbs);
-		    }
-		}
-		PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-                            "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx],"
-                            " xio_port=0x%x, direct32: pci_addr=0x%lx, "
-			    "new flags: 0x%x\n", paddr, paddr + req_size - 1,
-			    xio_addr, pci_addr, (uint64_t) flags));
-
-		return pci_addr;
-	    }
-	    /* our flags conflict with Device(x).
-	     */
-	    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-                    "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
-                    "xio_port=0x%x, Unable to set direct32 Device(x) bits\n",
-                    paddr, paddr + req_size - 1, xio_port));
-	}
-    }
-
-    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		"pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
-		"xio_port=0x%x, No acceptable PCI address found\n",
-		paddr, paddr + req_size - 1, xio_port));
-
-    return 0;
-}
-
-void
-pcibr_dmamap_drain(pcibr_dmamap_t map)
-{
-    xtalk_dmamap_drain(map->bd_xtalk);
-}
-
-void
-pcibr_dmaaddr_drain(vertex_hdl_t pconn_vhdl,
-		    paddr_t paddr,
-		    size_t bytes)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    vertex_hdl_t            xconn_vhdl = pcibr_soft->bs_conn;
-
-    xtalk_dmaaddr_drain(xconn_vhdl, paddr, bytes);
-}
-
-/*
- * Get the starting PCIbus address out of the given DMA map.
- * This function is supposed to be used by a close friend of PCI bridge
- * since it relies on the fact that the starting address of the map is fixed at
- * the allocation time in the current implementation of PCI bridge.
- */
-iopaddr_t
-pcibr_dmamap_pciaddr_get(pcibr_dmamap_t pcibr_dmamap)
-{
-    return pcibr_dmamap->bd_pci_addr;
-}
-
-/* =====================================================================
- *    CONFIGURATION MANAGEMENT
- */
-/*ARGSUSED */
-void
-pcibr_provider_startup(vertex_hdl_t pcibr)
-{
-}
-
-/*ARGSUSED */
-void
-pcibr_provider_shutdown(vertex_hdl_t pcibr)
-{
-}
-
-int
-pcibr_reset(vertex_hdl_t conn)
-{
-	BUG();
-	return -1;
-}
-
-pciio_endian_t
-pcibr_endian_set(vertex_hdl_t pconn_vhdl,
-		 pciio_endian_t device_end,
-		 pciio_endian_t desired_end)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pciio_slot_t            pciio_slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    uint64_t		    devreg;
-    unsigned long	    s;
-
-    /*
-     * Bridge supports hardware swapping; so we can always
-     * arrange for the caller's desired endianness.
-     */
-
-    s = pcibr_lock(pcibr_soft);
-    devreg = pcibr_soft->bs_slot[pciio_slot].bss_device;
-    if (device_end != desired_end)
-	devreg |= BRIDGE_DEV_SWAP_BITS;
-    else
-	devreg &= ~BRIDGE_DEV_SWAP_BITS;
-
-    /* NOTE- if we ever put SWAP bits
-     * onto the disabled list, we will
-     * have to change the logic here.
-     */
-    if (pcibr_soft->bs_slot[pciio_slot].bss_device != devreg) {
-	pcireg_device_set(pcibr_soft, pciio_slot, devreg);
-	pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-	pcireg_tflush_get(pcibr_soft);
-    }
-    pcibr_unlock(pcibr_soft, s);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEVREG, pconn_vhdl,
-    		"pcibr_endian_set: Device(%d): 0x%x\n",
-		pciio_slot, devreg));
-
-    return desired_end;
-}
-
-/*
- * Interfaces to allow special (e.g. SGI) drivers to set/clear
- * Bridge-specific device flags.  Many flags are modified through
- * PCI-generic interfaces; we don't allow them to be directly
- * manipulated here.  Only flags that at this point seem pretty
- * Bridge-specific can be set through these special interfaces.
- * We may add more flags as the need arises, or remove flags and
- * create PCI-generic interfaces as the need arises.
- *
- * Returns 0 on failure, 1 on success
- */
-int
-pcibr_device_flags_set(vertex_hdl_t pconn_vhdl,
-		       pcibr_device_flags_t flags)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pciio_slot_t            pciio_slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    uint64_t		    set = 0;
-    uint64_t		    clr = 0;
-
-    ASSERT((flags & PCIBR_DEVICE_FLAGS) == flags);
-
-    if (flags & PCIBR_WRITE_GATHER)
-	set |= BRIDGE_DEV_PMU_WRGA_EN;
-    if (flags & PCIBR_NOWRITE_GATHER)
-	clr |= BRIDGE_DEV_PMU_WRGA_EN;
-
-    if (flags & PCIBR_PREFETCH)
-	set |= BRIDGE_DEV_PREF;
-    if (flags & PCIBR_NOPREFETCH)
-	clr |= BRIDGE_DEV_PREF;
-
-    if (flags & PCIBR_PRECISE)
-	set |= BRIDGE_DEV_PRECISE;
-    if (flags & PCIBR_NOPRECISE)
-	clr |= BRIDGE_DEV_PRECISE;
-
-    if (flags & PCIBR_BARRIER)
-	set |= BRIDGE_DEV_BARRIER;
-    if (flags & PCIBR_NOBARRIER)
-	clr |= BRIDGE_DEV_BARRIER;
-
-    if (flags & PCIBR_64BIT)
-	set |= BRIDGE_DEV_DEV_SIZE;
-    if (flags & PCIBR_NO64BIT)
-	clr |= BRIDGE_DEV_DEV_SIZE;
-
-    /* PIC BRINGUP WAR (PV# 878674):   Don't allow 64bit PIO accesses */
-    if ((flags & PCIBR_64BIT) && PCIBR_WAR_ENABLED(PV878674, pcibr_soft)) {
-	set &= ~BRIDGE_DEV_DEV_SIZE;
-    }
-
-    if (set || clr) {
-	uint64_t		devreg;
-	unsigned long		s;
-
-	s = pcibr_lock(pcibr_soft);
-	devreg = pcibr_soft->bs_slot[pciio_slot].bss_device;
-	devreg = (devreg & ~clr) | set;
-	if (pcibr_soft->bs_slot[pciio_slot].bss_device != devreg) {
-	    pcireg_device_set(pcibr_soft, pciio_slot, devreg);
-	    pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-	    pcireg_tflush_get(pcibr_soft);
-	}
-	pcibr_unlock(pcibr_soft, s);
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEVREG, pconn_vhdl,
-		    "pcibr_device_flags_set: Device(%d): 0x%x\n",
-		    pciio_slot, devreg));
-    }
-    return 1;
-}
-
-/*
- * PIC has 16 RBARs per bus; meaning it can have a total of 16 outstanding 
- * split transactions.  If the functions on the bus have requested a total 
- * of 16 or less, then we can give them what they requested (ie. 100%). 
- * Otherwise we have make sure each function can get at least one buffer
- * and then divide the rest of the buffers up among the functions as ``A 
- * PERCENTAGE OF WHAT THEY REQUESTED'' (i.e. 0% - 100% of a function's
- * pcix_type0_status.max_out_split).  This percentage does not include the
- * one RBAR that all functions get by default.
- */
-int
-pcibr_pcix_rbars_calc(pcibr_soft_t pcibr_soft)
-{
-    /* 'percent_allowed' is the percentage of requested RBARs that functions
-     * are allowed, ***less the 1 RBAR that all functions get by default***
-     */
-    int percent_allowed; 
-
-    if (pcibr_soft->bs_pcix_num_funcs) {
-	if (pcibr_soft->bs_pcix_num_funcs > NUM_RBAR) {
-	    printk(KERN_WARNING
-		"%s: Must oversubscribe Read Buffer Attribute Registers"
-		"(RBAR).  Bus has %d RBARs but %d funcs need them.\n",
-		pcibr_soft->bs_name, NUM_RBAR, pcibr_soft->bs_pcix_num_funcs);
-	    percent_allowed = 0;
-	} else {
-	    percent_allowed = (((NUM_RBAR-pcibr_soft->bs_pcix_num_funcs)*100) /
-		               pcibr_soft->bs_pcix_split_tot);
-
-	    /* +1 to percentage to solve rounding errors that occur because
-	     * we're not doing fractional math. (ie. ((3 * 66%) / 100) = 1)
-	     * but should be "2" if doing true fractional math.  NOTE: Since
-	     * the greatest number of outstanding transactions a function 
-	     * can request is 32, this "+1" will always work (i.e. we won't
-	     * accidentally oversubscribe the RBARs because of this rounding
-	     * of the percentage).
-	     */
-	    percent_allowed=(percent_allowed > 100) ? 100 : percent_allowed+1;
-	}
-    } else {
-	return -ENODEV;
-    }
-
-    return percent_allowed;
-}
-
-/*
- * pcibr_debug() is used to print pcibr debug messages to the console.  A
- * user enables tracing by setting the following global variables:
- *
- *    pcibr_debug_mask 	   -Bitmask of what to trace. see pcibr_private.h
- *    pcibr_debug_module   -Module to trace.  'all' means trace all modules
- *    pcibr_debug_widget   -Widget to trace. '-1' means trace all widgets
- *    pcibr_debug_slot	   -Slot to trace.  '-1' means trace all slots
- *
- * 'type' is the type of debugging that the current PCIBR_DEBUG macro is
- * tracing.  'vhdl' (which can be NULL) is the vhdl associated with the
- * debug statement.  If there is a 'vhdl' associated with this debug
- * statement, it is parsed to obtain the module, widget, and slot.  If the
- * globals above match the PCIBR_DEBUG params, then the debug info in the
- * parameter 'format' is sent to the console.
- */
-void
-pcibr_debug(uint32_t type, vertex_hdl_t vhdl, char *format, ...)
-{
-    char hwpath[MAXDEVNAME] = "\0";
-    char copy_of_hwpath[MAXDEVNAME];
-    char *buffer;
-    char *module = "all";
-    short widget = -1;
-    short slot = -1;
-    va_list ap;
-
-    if (pcibr_debug_mask & type) {
-        if (vhdl) {
-            if (!hwgraph_vertex_name_get(vhdl, hwpath, MAXDEVNAME)) {
-                char *cp;
-
-                if (strcmp(module, pcibr_debug_module)) {
-		    /* use a copy */
-                    (void)strcpy(copy_of_hwpath, hwpath);
-		    cp = strstr(copy_of_hwpath, "/" EDGE_LBL_MODULE "/");
-                    if (cp) {
-                        cp += strlen("/" EDGE_LBL_MODULE "/");
-			module = strsep(&cp, "/");
-                    }
-                }
-                if (pcibr_debug_widget != -1) {
-		    cp = strstr(hwpath, "/" EDGE_LBL_XTALK "/");
-                    if (cp) {
-			cp += strlen("/" EDGE_LBL_XTALK "/");
-                        widget = simple_strtoul(cp, NULL, 0);
-                    }
-                }
-                if (pcibr_debug_slot != -1) {
-		    cp = strstr(hwpath, "/" EDGE_LBL_PCIX_0 "/");
-		    if (!cp) {
-			cp = strstr(hwpath, "/" EDGE_LBL_PCIX_1 "/");
-		    }
-                    if (cp) {
-                        cp += strlen("/" EDGE_LBL_PCIX_0 "/");
-                        slot = simple_strtoul(cp, NULL, 0);
-                    }
-                }
-            }
-        }
-        if ((vhdl == NULL) ||
-            (!strcmp(module, pcibr_debug_module) &&
-             (widget == pcibr_debug_widget) &&
-             (slot == pcibr_debug_slot))) {
-
-	    buffer = kmalloc(1024, GFP_KERNEL);
-	    if (buffer) {
-		printk("PCIBR_DEBUG<%d>\t: %s :", smp_processor_id(), hwpath);
-		/*
-		 * KERN_MSG translates to this 3 line sequence. Since
-		 * we have a variable length argument list, we need to
-		 * call KERN_MSG this way rather than directly
-		 */
-		va_start(ap, format);
-		memset(buffer, 0, 1024);
-		vsnprintf(buffer, 1024, format, ap);
-		va_end(ap);
-		printk("%s", buffer);
-		kfree(buffer);
-	    }
-        }
-    }
-}
-
-/*
- * given a xconn_vhdl and a bus number under that widget, return a 
- * bridge_t pointer.
- */
-void *
-pcibr_bridge_ptr_get(vertex_hdl_t widget_vhdl, int bus_num)
-{
-    void       *bridge;
-
-    bridge = (void *)xtalk_piotrans_addr(widget_vhdl, 0, 0, 
-							sizeof(bridge), 0);
-
-    /* PIC ASIC has two bridges (ie. two buses) under a single widget */
-    if (bus_num == 1) {
-	bridge = (void *)((char *)bridge + PIC_BUS1_OFFSET);
-    }
-    return bridge;
-}		
-
-
-int
-isIO9(nasid_t nasid)
-{
-	lboard_t *brd = (lboard_t *)KL_CONFIG_INFO(nasid);
-
-	while (brd) {
-		if (brd->brd_flags & LOCAL_MASTER_IO6) {
-			return 1;
-		}
-                if (numionodes == numnodes)
-                        brd = KLCF_NEXT_ANY(brd);
-                else
-                        brd = KLCF_NEXT(brd);
-	}
-	/* if it's dual ported, check the peer also */
-	nasid = NODEPDA(nasid_to_cnodeid(nasid))->xbow_peer;
-	if (nasid < 0) return 0;
-	brd = (lboard_t *)KL_CONFIG_INFO(nasid);
-	while (brd) {
-		if (brd->brd_flags & LOCAL_MASTER_IO6) {
-			return 1;
-		}
-                if (numionodes == numnodes)
-                        brd = KLCF_NEXT_ANY(brd);
-                else
-                        brd = KLCF_NEXT(brd);
-
-	}
-	return 0;
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_error.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_error.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_error.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1873 +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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/interrupt.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-
-
-extern int	hubii_check_widget_disabled(nasid_t, int);
-
-
-/* =====================================================================
- *    ERROR HANDLING
- */
-
-#ifdef	DEBUG
-#ifdef	ERROR_DEBUG
-#define BRIDGE_PIOERR_TIMEOUT	100	/* Timeout with ERROR_DEBUG defined */
-#else
-#define BRIDGE_PIOERR_TIMEOUT	40	/* Timeout in debug mode  */
-#endif
-#else
-#define BRIDGE_PIOERR_TIMEOUT	1	/* Timeout in non-debug mode */
-#endif
-
-#ifdef  DEBUG
-#ifdef ERROR_DEBUG
-uint64_t bridge_errors_to_dump = ~BRIDGE_ISR_INT_MSK;
-#else
-uint64_t bridge_errors_to_dump = BRIDGE_ISR_ERROR_DUMP;
-#endif
-#else
-uint64_t bridge_errors_to_dump = BRIDGE_ISR_ERROR_FATAL |
-                                   BRIDGE_ISR_PCIBUS_PIOERR;
-#endif
-
-int pcibr_pioerr_dump = 1;	/* always dump pio errors */
-
-/*
- * register values
- * map between numeric values and symbolic values
- */
-struct reg_values {
-	unsigned long long rv_value;
-	char *rv_name;
-};
-
-/*
- * register descriptors are used for formatted prints of register values
- * rd_mask and rd_shift must be defined, other entries may be null
- */
-struct reg_desc {
-	unsigned long long rd_mask;	/* mask to extract field */
-	int rd_shift;		/* shift for extracted value, - >>, + << */
-	char *rd_name;		/* field name */
-	char *rd_format;	/* format to print field */
-	struct reg_values *rd_values;	/* symbolic names of values */
-};
-
-/* Crosstalk Packet Types */
-static struct reg_values xtalk_cmd_pactyp[] =
-{
-    {0x0, "RdReq"},
-    {0x1, "RdResp"},
-    {0x2, "WrReqWithResp"},
-    {0x3, "WrResp"},
-    {0x4, "WrReqNoResp"},
-    {0x5, "Reserved(5)"},
-    {0x6, "FetchAndOp"},
-    {0x7, "Reserved(7)"},
-    {0x8, "StoreAndOp"},
-    {0x9, "Reserved(9)"},
-    {0xa, "Reserved(a)"},
-    {0xb, "Reserved(b)"},
-    {0xc, "Reserved(c)"},
-    {0xd, "Reserved(d)"},
-    {0xe, "SpecialReq"},
-    {0xf, "SpecialResp"},
-    {0}
-};
-
-static struct reg_desc   xtalk_cmd_bits[] =
-{
-    {WIDGET_DIDN, -28, "DIDN", "%x"},
-    {WIDGET_SIDN, -24, "SIDN", "%x"},
-    {WIDGET_PACTYP, -20, "PACTYP", 0, xtalk_cmd_pactyp},
-    {WIDGET_TNUM, -15, "TNUM", "%x"},
-    {WIDGET_COHERENT, 0, "COHERENT"},
-    {WIDGET_DS, 0, "DS"},
-    {WIDGET_GBR, 0, "GBR"},
-    {WIDGET_VBPM, 0, "VBPM"},
-    {WIDGET_ERROR, 0, "ERROR"},
-    {WIDGET_BARRIER, 0, "BARRIER"},
-    {0}
-};
-
-#define F(s,n)          { 1l<<(s),-(s), n }
-
-char *pci_space[] = {"NONE",
-                     "ROM",
-                     "IO",
-                     "",
-                     "MEM",
-                     "MEM32",
-                     "MEM64",
-                     "CFG",
-                     "WIN0",
-                     "WIN1",
-                     "WIN2",
-                     "WIN3",
-                     "WIN4",
-                     "WIN5",
-                     "",
-                     "BAD"};
-
-static char             *pcibr_isr_errs[] =
-{
-    "", "", "", "", "", "", "", "",
-    "08: Reserved Bit 08",
-    "09: PCI to Crosstalk read request timeout",
-    "10: PCI retry operation count exhausted.",
-    "11: PCI bus device select timeout",
-    "12: PCI device reported parity error",
-    "13: PCI Address/Cmd parity error ",
-    "14: PCI Bridge detected parity error",
-    "15: PCI abort condition",
-    "16: Reserved Bit 16",
-    "17: LLP Transmitter Retry count wrapped",	/* PIC ONLY */
-    "18: LLP Transmitter side required Retry",	/* PIC ONLY */
-    "19: LLP Receiver retry count wrapped",	/* PIC ONLY */
-    "20: LLP Receiver check bit error",		/* PIC ONLY */
-    "21: LLP Receiver sequence number error",	/* PIC ONLY */
-    "22: Request packet overflow",
-    "23: Request operation not supported by bridge",
-    "24: Request packet has invalid address for bridge widget",
-    "25: Incoming request xtalk command word error bit set or invalid sideband",
-    "26: Incoming response xtalk command word error bit set or invalid sideband",
-    "27: Framing error, request cmd data size does not match actual",
-    "28: Framing error, response cmd data size does not match actual",
-    "29: Unexpected response arrived",
-    "30: PMU Access Fault",
-    "31: Reserved Bit 31",
-    "32: PCI-X address or attribute cycle parity error",
-    "33: PCI-X data cycle parity error",
-    "34: PCI-X master timeout (ie. master abort)",
-    "35: PCI-X pio retry counter exhausted",
-    "36: PCI-X SERR",
-    "37: PCI-X PERR", 
-    "38: PCI-X target abort",
-    "39: PCI-X read request timeout",
-    "40: PCI / PCI-X device requestin arbitration error",
-    "41: internal RAM parity error",
-    "42: PCI-X unexpected completion cycle to master",
-    "43: PCI-X split completion timeout",
-    "44: PCI-X split completion error message",
-    "45: PCI-X split completion message parity error",
-};
-
-/*
- * print_register() allows formatted printing of bit fields.  individual
- * bit fields are described by a struct reg_desc, multiple bit fields within
- * a single word can be described by multiple reg_desc structures.
- * %r outputs a string of the format "<bit field descriptions>"
- * %R outputs a string of the format "0x%x<bit field descriptions>"
- *
- * The fields in a reg_desc are:
- *	unsigned long long rd_mask; An appropriate mask to isolate the bit field
- *				within a word, and'ed with val
- *
- *	int rd_shift;		A shift amount to be done to the isolated
- *				bit field.  done before printing the isolate
- *				bit field with rd_format and before searching
- *				for symbolic value names in rd_values
- *
- *	char *rd_name;		If non-null, a bit field name to label any
- *				out from rd_format or searching rd_values.
- *				if neither rd_format or rd_values is non-null
- *				rd_name is printed only if the isolated
- *				bit field is non-null.
- *
- *	char *rd_format;	If non-null, the shifted bit field value
- *				is printed using this format.
- *
- *	struct reg_values *rd_values;	If non-null, a pointer to a table
- *				matching numeric values with symbolic names.
- *				rd_values are searched and the symbolic
- *				value is printed if a match is found, if no
- *				match is found "???" is printed.
- *				
- */
-
-static void
-print_register(unsigned long long reg, struct reg_desc *addr)
-{
-	register struct reg_desc *rd;
-	register struct reg_values *rv;
-	unsigned long long field;
-	int any;
-
-	printk("<");
-	any = 0;
-	for (rd = addr; rd->rd_mask; rd++) {
-		field = reg & rd->rd_mask;
-		field = (rd->rd_shift > 0) ? field << rd->rd_shift : field >> -rd->rd_shift;
-		if (any && (rd->rd_format || rd->rd_values || (rd->rd_name && field)))
-			printk(",");
-		if (rd->rd_name) {
-			if (rd->rd_format || rd->rd_values || field) {
-				printk("%s", rd->rd_name);
-				any = 1;
-			}
-			if (rd->rd_format || rd->rd_values) {
-				printk("=");
-				any = 1;
-			}
-		}
-		/* You can have any format so long as it is %x */
-		if (rd->rd_format) {
-			printk("%llx", field);
-			any = 1;
-			if (rd->rd_values)
-				printk(":");
-		}
-		if (rd->rd_values) {
-			any = 1;
-			for (rv = rd->rd_values; rv->rv_name; rv++) {
-				if (field == rv->rv_value) {
-					printk("%s", rv->rv_name);
-					break;
-				}
-			}
-			if (rv->rv_name == NULL)
-				printk("???");
-		}
-	}
-	printk(">\n");
-}
-
-
-/*
- * display memory directory state
- */
-static void
-pcibr_show_dir_state(paddr_t paddr, char *prefix)
-{
-#ifdef PCIBR_LATER
-	int state;
-	uint64_t vec_ptr;
-	hubreg_t elo;
-	extern char *dir_state_str[];
-	extern void get_dir_ent(paddr_t, int *, uint64_t *, hubreg_t *);
-
-	get_dir_ent(paddr, &state, &vec_ptr, &elo);
-
-	printf("%saddr 0x%lx: state 0x%x owner 0x%lx (%s)\n", 
-		prefix, (uint64_t)paddr, state, (uint64_t)vec_ptr, 
-		dir_state_str[state]);
-#endif /* PCIBR_LATER */
-}
-
-
-void
-print_bridge_errcmd(pcibr_soft_t pcibr_soft, uint32_t cmdword, char *errtype)
-{
-    printk(
-	    "\t    Bridge %sError Command Word Register ", errtype);
-    print_register(cmdword, xtalk_cmd_bits);
-}
-
-
-/*
- *	Dump relevant error information for Bridge error interrupts.
- */
-/*ARGSUSED */
-void
-pcibr_error_dump(pcibr_soft_t pcibr_soft)
-{
-    uint64_t		    int_status;
-    uint64_t		    mult_int;
-    uint64_t		    bit;
-    int                     i;
-
-    int_status = (pcireg_intr_status_get(pcibr_soft) & ~BRIDGE_ISR_INT_MSK);
-
-    if (!int_status) {
-	/* No error bits set */
-	return;
-    }
-
-    /* Check if dumping the same error information multiple times */
-    if ( pcibr_soft->bs_errinfo.bserr_intstat == int_status )
-	return;
-    pcibr_soft->bs_errinfo.bserr_intstat = int_status;
-
-    printk(KERN_ALERT "PCI BRIDGE ERROR: int_status is 0x%lx for %s\n"
-	"    Dumping relevant %s registers for each bit set...\n",
-	    int_status, pcibr_soft->bs_name,
-	    "PIC");
-
-    for (i = PCIBR_ISR_ERR_START; i < 64; i++) {
-	bit = 1ull << i;
-
-	/* A number of int_status bits are only valid for PIC's bus0 */
-	if ((pcibr_soft->bs_busnum != 0) && 
-	    ((bit == BRIDGE_ISR_UNSUPPORTED_XOP) ||
-	     (bit == BRIDGE_ISR_LLP_REC_SNERR) ||
-	     (bit == BRIDGE_ISR_LLP_REC_CBERR) ||
-	     (bit == BRIDGE_ISR_LLP_RCTY) ||
-	     (bit == BRIDGE_ISR_LLP_TX_RETRY) ||
-	     (bit == BRIDGE_ISR_LLP_TCTY))) {
-	    continue;
-	}
-
-	if (int_status & bit) {
-	    printk("\t%s\n", pcibr_isr_errs[i]);
-
-	    switch (bit) {
-
-	    case PIC_ISR_INT_RAM_PERR:	    /* bit41	INT_RAM_PERR */
-		/* XXX: should breakdown meaning of bits in reg */
-		printk("\t	Internal RAM Parity Error: 0x%lx\n",
-		    pcireg_parity_err_get(pcibr_soft));
-		break;
-
-	    case PIC_ISR_PCIX_ARB_ERR:	    /* bit40	PCI_X_ARB_ERR */
-		/* XXX: should breakdown meaning of bits in reg */
-		printk("\t	Arbitration Reg: 0x%lx\n",
-		    pcireg_arbitration_get(pcibr_soft));
-		break;
-
-	    case PIC_ISR_PCIX_REQ_TOUT:	    /* bit39	PCI_X_REQ_TOUT */
-		/* XXX: should breakdown meaning of attribute bit */
-		printk(
-		    "\t	   PCI-X DMA Request Error Address Reg: 0x%lx\n"
-		    "\t	   PCI-X DMA Request Error Attribute Reg: 0x%lx\n",
-		    pcireg_pcix_req_err_addr_get(pcibr_soft),
-		    pcireg_pcix_req_err_attr_get(pcibr_soft));
-		break;
-
-	    case PIC_ISR_PCIX_SPLIT_MSG_PE: /* bit45	PCI_X_SPLIT_MES_PE */
-	    case PIC_ISR_PCIX_SPLIT_EMSG:   /* bit44	PCI_X_SPLIT_EMESS */
-	    case PIC_ISR_PCIX_SPLIT_TO:	    /* bit43	PCI_X_SPLIT_TO */
-		/* XXX: should breakdown meaning of attribute bit */
-		printk(
-		    "\t	   PCI-X Split Request Address Reg: 0x%lx\n"
-		    "\t	   PCI-X Split Request Attribute Reg: 0x%lx\n",
-		    pcireg_pcix_pio_split_addr_get(pcibr_soft),
-		    pcireg_pcix_pio_split_attr_get(pcibr_soft));
-		/* FALL THRU */
-
-	    case PIC_ISR_PCIX_UNEX_COMP:    /* bit42	PCI_X_UNEX_COMP */
-	    case PIC_ISR_PCIX_TABORT:	    /* bit38	PCI_X_TABORT */
-	    case PIC_ISR_PCIX_PERR:	    /* bit37	PCI_X_PERR */
-	    case PIC_ISR_PCIX_SERR:	    /* bit36	PCI_X_SERR */
-	    case PIC_ISR_PCIX_MRETRY:	    /* bit35	PCI_X_MRETRY */
-	    case PIC_ISR_PCIX_MTOUT:	    /* bit34	PCI_X_MTOUT */
-	    case PIC_ISR_PCIX_DA_PARITY:    /* bit33	PCI_X_DA_PARITY */
-	    case PIC_ISR_PCIX_AD_PARITY:    /* bit32	PCI_X_AD_PARITY */
-		/* XXX: should breakdown meaning of attribute bit */
-		printk(
-		    "\t	   PCI-X Bus Error Address Reg: 0x%lx\n"
-		    "\t	   PCI-X Bus Error Attribute Reg: 0x%lx\n"
-		    "\t	   PCI-X Bus Error Data Reg: 0x%lx\n",
-		    pcireg_pcix_bus_err_addr_get(pcibr_soft),
-		    pcireg_pcix_bus_err_attr_get(pcibr_soft),
-		    pcireg_pcix_bus_err_data_get(pcibr_soft));
-		break;
-
-	    case BRIDGE_ISR_PAGE_FAULT:	/* bit30    PMU_PAGE_FAULT */
-		printk("\t    Map Fault Address Reg: 0x%lx\n",
-		    pcireg_map_fault_get(pcibr_soft));
-		break;
-
-	    case BRIDGE_ISR_UNEXP_RESP:		/* bit29    UNEXPECTED_RESP */
-		print_bridge_errcmd(pcibr_soft,
-			    pcireg_linkside_err_get(pcibr_soft), "Aux ");
-
-		/* PIC in PCI-X mode, dump the PCIX DMA Request registers */
-		if (IS_PCIX(pcibr_soft)) {
-		    /* XXX: should breakdown meaning of attr bit */
-		    printk( 
-			"\t    PCI-X DMA Request Error Addr Reg: 0x%lx\n"
-			"\t    PCI-X DMA Request Error Attr Reg: 0x%lx\n",
-			pcireg_pcix_req_err_addr_get(pcibr_soft),
-			pcireg_pcix_req_err_attr_get(pcibr_soft));
-		}
-		break;
-
-	    case BRIDGE_ISR_BAD_XRESP_PKT:	/* bit28    BAD_RESP_PACKET */
-	    case BRIDGE_ISR_RESP_XTLK_ERR:	/* bit26    RESP_XTALK_ERROR */
-		print_bridge_errcmd(pcibr_soft,
-				pcireg_linkside_err_get(pcibr_soft), "Aux ");
-		 
-		/* PCI-X mode, DMA Request Error registers are valid.  But
-		 * in PCI mode, Response Buffer Address register are valid.
-		 */
-		if (IS_PCIX(pcibr_soft)) {
-		    /* XXX: should breakdown meaning of attribute bit */
-		    printk(
-			"\t    PCI-X DMA Request Error Addr Reg: 0x%lx\n"
-		        "\t    PCI-X DMA Request Error Attribute Reg: 0x%lx\n",
-			pcireg_pcix_req_err_addr_get(pcibr_soft),
-			pcireg_pcix_req_err_attr_get(pcibr_soft));
-		} else {
-		    printk(
-		        "\t    Bridge Response Buf Error Addr Reg: 0x%lx\n"
-		        "\t    dev-num %d buff-num %d addr 0x%lx\n",
-			pcireg_resp_err_get(pcibr_soft),
-			(int)pcireg_resp_err_dev_get(pcibr_soft),
-			(int)pcireg_resp_err_buf_get(pcibr_soft),
-			pcireg_resp_err_addr_get(pcibr_soft));
-		    if (bit == BRIDGE_ISR_RESP_XTLK_ERR) {
-			/* display memory directory associated with cacheline */
-			pcibr_show_dir_state(
-				    pcireg_resp_err_get(pcibr_soft), "\t    ");
-		    }
-		}
-		break;
-
-	    case BRIDGE_ISR_BAD_XREQ_PKT:	/* bit27    BAD_XREQ_PACKET */
-	    case BRIDGE_ISR_REQ_XTLK_ERR:	/* bit25    REQ_XTALK_ERROR */
-	    case BRIDGE_ISR_INVLD_ADDR:		/* bit24    INVALID_ADDRESS */
-		print_bridge_errcmd(pcibr_soft,
-				pcireg_cmdword_err_get(pcibr_soft), "");
-		printk(
-		    "\t    Bridge Error Address Register: 0x%lx\n"
-		    "\t    Bridge Error Address: 0x%lx\n",
-		    pcireg_bus_err_get(pcibr_soft),
-		    pcireg_bus_err_get(pcibr_soft));
-		break;
-
-	    case BRIDGE_ISR_UNSUPPORTED_XOP:	/* bit23    UNSUPPORTED_XOP */
-		print_bridge_errcmd(pcibr_soft,
-				pcireg_linkside_err_get(pcibr_soft), "Aux ");
-		printk("\t    Address Holding Link Side Error Reg: 0x%lx\n",
-			pcireg_linkside_err_addr_get(pcibr_soft));
-		break;
-
-	    case BRIDGE_ISR_XREQ_FIFO_OFLOW:	/* bit22    XREQ_FIFO_OFLOW */
-		print_bridge_errcmd(pcibr_soft,
-				pcireg_linkside_err_get(pcibr_soft), "Aux ");
-		printk("\t    Address Holding Link Side Error Reg: 0x%lx\n",
-			pcireg_linkside_err_addr_get(pcibr_soft));
-		break;
-
-	    case BRIDGE_ISR_PCI_ABORT:		/* bit15    PCI_ABORT */
-	    case BRIDGE_ISR_PCI_PARITY:		/* bit14    PCI_PARITY */
-	    case BRIDGE_ISR_PCI_SERR:		/* bit13    PCI_SERR */
-	    case BRIDGE_ISR_PCI_PERR:		/* bit12    PCI_PERR */
-	    case BRIDGE_ISR_PCI_MST_TIMEOUT:	/* bit11    PCI_MASTER_TOUT */
-	    case BRIDGE_ISR_PCI_RETRY_CNT:	/* bit10    PCI_RETRY_CNT */
-		printk("\t    PCI Error Address Register: 0x%lx\n"
-		    "\t    PCI Error Address: 0x%lx\n",
-		    pcireg_pci_bus_addr_get(pcibr_soft),
-		    pcireg_pci_bus_addr_addr_get(pcibr_soft));
-		break;
-
-	    case BRIDGE_ISR_XREAD_REQ_TIMEOUT:	/* bit09    XREAD_REQ_TOUT */
-		printk("\t    Bridge Response Buf Error Addr Reg: 0x%lx\n"
-		    "\t    dev-num %d buff-num %d addr 0x%lx\n",
-		    pcireg_resp_err_get(pcibr_soft),
-		    (int)pcireg_resp_err_dev_get(pcibr_soft),
-		    (int)pcireg_resp_err_buf_get(pcibr_soft),
-		    pcireg_resp_err_get(pcibr_soft));
-		break;
-	    }
-	}
-    }
-
-    mult_int = pcireg_intr_multiple_get(pcibr_soft);
-
-    if (mult_int & ~BRIDGE_ISR_INT_MSK) {
-	printk("    %s Multiple Interrupt Register is 0x%lx\n",
-		pcibr_soft->bs_asic_name, mult_int);
-	for (i = PCIBR_ISR_ERR_START; i < 64; i++) {
-	    if (mult_int & (1ull << i))
-		printk( "\t%s\n", pcibr_isr_errs[i]);
-	}
-    }
-}
-
-/* pcibr_pioerr_check():
- *	Check to see if this pcibr has a PCI PIO
- *	TIMEOUT error; if so, bump the timeout-count
- *	on any piomaps that could cover the address.
- */
-static void
-pcibr_pioerr_check(pcibr_soft_t soft)
-{
-    uint64_t		    int_status;
-    iopaddr_t		    pci_addr;
-    pciio_slot_t	    slot;
-    pcibr_piomap_t	    map;
-    iopaddr_t		    base;
-    size_t		    size;
-    unsigned		    win;
-    int			    func;
-
-    int_status = pcireg_intr_status_get(soft);
-
-    if (int_status & BRIDGE_ISR_PCIBUS_PIOERR) {
-	pci_addr = pcireg_pci_bus_addr_get(soft);
-
-	slot = PCIBR_NUM_SLOTS(soft);
-	while (slot-- > 0) {
-	    int 		nfunc = soft->bs_slot[slot].bss_ninfo;
-	    pcibr_info_h	pcibr_infoh = soft->bs_slot[slot].bss_infos;
-
-	    for (func = 0; func < nfunc; func++) {
-		pcibr_info_t 	pcibr_info = pcibr_infoh[func];
-
-		if (!pcibr_info)
-		    continue;
-
-		for (map = pcibr_info->f_piomap;
-		        map != NULL; map = map->bp_next) {
-		    base = map->bp_pciaddr;
-		    size = map->bp_mapsz;
-		    win = map->bp_space - PCIIO_SPACE_WIN(0);
-		    if (win < 6)
-			base += soft->bs_slot[slot].bss_window[win].bssw_base;
-		    else if (map->bp_space == PCIIO_SPACE_ROM)
-			base += pcibr_info->f_rbase;
-		    if ((pci_addr >= base) && (pci_addr < (base + size)))
-			atomic_inc(&map->bp_toc);
-		}
-	    }
-	}
-    }
-}
-
-/*
- * PCI Bridge Error interrupt handler.
- *      This gets invoked, whenever a PCI bridge sends an error interrupt.
- *      Primarily this servers two purposes.
- *              - If an error can be handled (typically a PIO read/write
- *                error, we try to do it silently.
- *              - If an error cannot be handled, we die violently.
- *      Interrupt due to PIO errors:
- *              - Bridge sends an interrupt, whenever a PCI operation
- *                done by the bridge as the master fails. Operations could
- *                be either a PIO read or a PIO write.
- *                PIO Read operation also triggers a bus error, and it's
- *                We primarily ignore this interrupt in that context..
- *                For PIO write errors, this is the only indication.
- *                and we have to handle with the info from here.
- *
- *                So, there is no way to distinguish if an interrupt is
- *                due to read or write error!.
- */
-
-irqreturn_t
-pcibr_error_intr_handler(int irq, void *arg, struct pt_regs *ep)
-{
-    pcibr_soft_t            pcibr_soft;
-    void               *bridge;
-    uint64_t		    int_status;
-    uint64_t		    err_status;
-    int                     i;
-    uint64_t		    disable_errintr_mask = 0;
-    nasid_t		    nasid;
-
-
-#if PCIBR_SOFT_LIST
-    /*
-     * Defensive code for linked pcibr_soft structs
-     */
-    {
-	extern pcibr_list_p	pcibr_list;
-	pcibr_list_p            entry;
-
-	entry = pcibr_list;
-	while (1) {
-	    if (entry == NULL) {
-		printk("pcibr_error_intr_handler: (0x%lx) is not a pcibr_soft!",
-	 	      (uint64_t)arg);
-    		return IRQ_NONE;
-	    }
-	    if ((intr_arg_t) entry->bl_soft == arg)
-		break;
-	    entry = entry->bl_next;
-	}
-    }
-#endif /* PCIBR_SOFT_LIST */
-    pcibr_soft = (pcibr_soft_t) arg;
-    bridge = pcibr_soft->bs_base;
-
-    /*
-     * pcibr_error_intr_handler gets invoked whenever bridge encounters
-     * an error situation, and the interrupt for that error is enabled.
-     * This routine decides if the error is fatal or not, and takes
-     * action accordingly.
-     *
-     * In the case of PIO read/write timeouts, there is no way
-     * to know if it was a read or write request that timed out.
-     * If the error was due to a "read", a bus error will also occur
-     * and the bus error handling code takes care of it. 
-     * If the error is due to a "write", the error is currently logged 
-     * by this routine. For SN1 and SN0, if fire-and-forget mode is 
-     * disabled, a write error response xtalk packet will be sent to 
-     * the II, which will cause an II error interrupt. No write error 
-     * recovery actions of any kind currently take place at the pcibr 
-     * layer! (e.g., no panic on unrecovered write error)
-     *
-     * Prior to reading the Bridge int_status register we need to ensure
-     * that there are no error bits set in the lower layers (hubii)
-     * that have disabled PIO access to the widget. If so, there is nothing
-     * we can do until the bits clear, so we setup a timeout and try again
-     * later.
-     */
-
-    nasid = NASID_GET(bridge);
-    if (hubii_check_widget_disabled(nasid, pcibr_soft->bs_xid)) {
-	DECLARE_WAIT_QUEUE_HEAD(wq);
-	sleep_on_timeout(&wq, BRIDGE_PIOERR_TIMEOUT*HZ );  /* sleep */
-	pcibr_soft->bs_errinfo.bserr_toutcnt++;
-	/* Let's go recursive */
-	return(pcibr_error_intr_handler(irq, arg, ep));
-    }
-
-    int_status = pcireg_intr_status_get(pcibr_soft);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ERROR, pcibr_soft->bs_conn,
-		"pcibr_error_intr_handler: int_status=0x%lx\n", int_status));
-
-    /* int_status is which bits we have to clear;
-     * err_status is the bits we haven't handled yet.
-     */
-    err_status = int_status;
-
-    if (!(int_status & ~BRIDGE_ISR_INT_MSK)) {
-	/*
-	 * No error bit set!!.
-	 */
-	return IRQ_HANDLED;
-    }
-    /*
-     * If we have a PCIBUS_PIOERR, hand it to the logger.
-     */
-    if (int_status & BRIDGE_ISR_PCIBUS_PIOERR) {
-	pcibr_pioerr_check(pcibr_soft);
-    }
-
-    if (err_status) {
-	struct bs_errintr_stat_s *bs_estat ;
-        bs_estat = &pcibr_soft->bs_errintr_stat[PCIBR_ISR_ERR_START];
-
-	for (i = PCIBR_ISR_ERR_START; i < 64; i++, bs_estat++) {
-	    if (err_status & (1ull << i)) {
-		uint32_t              errrate = 0;
-		uint32_t              errcount = 0;
-		uint32_t              errinterval = 0, current_tick = 0;
-		int                     llp_tx_retry_errors = 0;
-		int                     is_llp_tx_retry_intr = 0;
-
-		bs_estat->bs_errcount_total++;
-
-		current_tick = jiffies;
-		errinterval = (current_tick - bs_estat->bs_lasterr_timestamp);
-		errcount = (bs_estat->bs_errcount_total -
-			    bs_estat->bs_lasterr_snapshot);
-
-		/* LLP interrrupt errors are only valid on BUS0 of the PIC */
-		if (pcibr_soft->bs_busnum == 0)
-		    is_llp_tx_retry_intr = (BRIDGE_ISR_LLP_TX_RETRY==(1ull << i));
-
-		/* Check for the divide by zero condition while
-		 * calculating the error rates.
-		 */
-
-		if (errinterval) {
-		    errrate = errcount / errinterval;
-		    /* If able to calculate error rate
-		     * on a LLP transmitter retry interrupt, check
-		     * if the error rate is nonzero and we have seen
-		     * a certain minimum number of errors.
-		     *
-		     * NOTE : errcount is being compared to
-		     * PCIBR_ERRTIME_THRESHOLD to make sure that we are not
-		     * seeing cases like x error interrupts per y ticks for
-		     * very low x ,y (x > y ) which could result in a
-		     * rate > 100/tick.
-		     */
-		    if (is_llp_tx_retry_intr &&
-			errrate &&
-			(errcount >= PCIBR_ERRTIME_THRESHOLD)) {
-			llp_tx_retry_errors = 1;
-		    }
-		} else {
-		    errrate = 0;
-		    /* Since we are not able to calculate the
-		     * error rate check if we exceeded a certain
-		     * minimum number of errors for LLP transmitter
-		     * retries. Note that this can only happen
-		     * within the first tick after the last snapshot.
-		     */
-		    if (is_llp_tx_retry_intr &&
-			(errcount >= PCIBR_ERRINTR_DISABLE_LEVEL)) {
-			llp_tx_retry_errors = 1;
-		    }
-		}
-
-		/*
-		 * If a non-zero error rate (which is equivalent to
-		 * to 100 errors/tick at least) for the LLP transmitter
-		 * retry interrupt was seen, check if we should print
-		 * a warning message.
-		 */
-
-		if (llp_tx_retry_errors) {
-		    static uint32_t       last_printed_rate;
-
-		    if (errrate > last_printed_rate) {
-			last_printed_rate = errrate;
-			/* Print the warning only if the error rate
-			 * for the transmitter retry interrupt
-			 * exceeded the previously printed rate.
-			 */
-			printk(KERN_WARNING
-				"%s: %s, Excessive error interrupts : %d/tick\n",
-				pcibr_soft->bs_name,
-				pcibr_isr_errs[i],
-				errrate);
-
-		    }
-		    /*
-		     * Update snapshot, and time
-		     */
-		    bs_estat->bs_lasterr_timestamp = current_tick;
-		    bs_estat->bs_lasterr_snapshot =
-			bs_estat->bs_errcount_total;
-
-		}
-		/*
-		 * If the error rate is high enough, print the error rate.
-		 */
-		if (errinterval > PCIBR_ERRTIME_THRESHOLD) {
-
-		    if (errrate > PCIBR_ERRRATE_THRESHOLD) {
-			printk(KERN_NOTICE "%s: %s, Error rate %d/tick",
-				pcibr_soft->bs_name,
-				pcibr_isr_errs[i],
-				errrate);
-			/*
-			 * Update snapshot, and time
-			 */
-			bs_estat->bs_lasterr_timestamp = current_tick;
-			bs_estat->bs_lasterr_snapshot =
-			    bs_estat->bs_errcount_total;
-		    }
-		}
-		/* PIC BRINGUP WAR (PV# 856155):
-		 * Dont disable PCI_X_ARB_ERR interrupts, we need the
-		 * interrupt inorder to clear the DEV_BROKE bits in
-		 * b_arb register to re-enable the device.
-		 */
-		if (!(err_status & PIC_ISR_PCIX_ARB_ERR) &&
-				PCIBR_WAR_ENABLED(PV856155, pcibr_soft)) {
-
-		if (bs_estat->bs_errcount_total > PCIBR_ERRINTR_DISABLE_LEVEL) {
-		    /*
-		     * We have seen a fairly large number of errors of
-		     * this type. Let's disable the interrupt. But flash
-		     * a message about the interrupt being disabled.
-		     */
-		    printk(KERN_NOTICE
-			    "%s Disabling error interrupt type %s. Error count %d",
-			    pcibr_soft->bs_name,
-			    pcibr_isr_errs[i],
-			    bs_estat->bs_errcount_total);
-		    disable_errintr_mask |= (1ull << i);
-		}
-		} /* PIC: WAR for PV 856155 end-of-if */
-	    }
-	}
-    }
-
-    if (disable_errintr_mask) {
-	unsigned long s;
-	/*
-	 * Disable some high frequency errors as they
-	 * could eat up too much cpu time.
-	 */
-	s = pcibr_lock(pcibr_soft);
-	pcireg_intr_enable_bit_clr(pcibr_soft, disable_errintr_mask);
-	pcibr_unlock(pcibr_soft, s);
-    }
-    /*
-     * If we leave the PROM cacheable, T5 might
-     * try to do a cache line sized writeback to it,
-     * which will cause a BRIDGE_ISR_INVLD_ADDR.
-     */
-    if ((err_status & BRIDGE_ISR_INVLD_ADDR) &&
-	(0x00C00000 == (pcireg_bus_err_get(pcibr_soft) & 0xFFFFFFFFFFC00000)) &&
-	(0x00402000 == (0x00F07F00 & pcireg_cmdword_err_get(pcibr_soft)))) {
-	err_status &= ~BRIDGE_ISR_INVLD_ADDR;
-    }
-    /*
-     * pcibr_pioerr_dump is a systune that make be used to not
-     * print bridge registers for interrupts generated by pio-errors.
-     * Some customers do early probes and expect a lot of failed
-     * pios.
-     */
-    if (!pcibr_pioerr_dump) {
-	bridge_errors_to_dump &= ~BRIDGE_ISR_PCIBUS_PIOERR;
-    } else {
-	bridge_errors_to_dump |= BRIDGE_ISR_PCIBUS_PIOERR;
-    }
-
-    /* Dump/Log Bridge error interrupt info */
-    if (err_status & bridge_errors_to_dump) {
-	printk("BRIDGE ERR_STATUS 0x%lx\n", err_status);
-	pcibr_error_dump(pcibr_soft);
-    }
-
-    /* PIC BRINGUP WAR (PV# 867308):
-     * Make BRIDGE_ISR_LLP_REC_SNERR & BRIDGE_ISR_LLP_REC_CBERR fatal errors
-     * so we know we've hit the problem defined in PV 867308 that we believe
-     * has only been seen in simulation
-     */
-    if (PCIBR_WAR_ENABLED(PV867308, pcibr_soft) &&
-	(err_status & (BRIDGE_ISR_LLP_REC_SNERR | BRIDGE_ISR_LLP_REC_CBERR))) {
-	printk("BRIDGE ERR_STATUS 0x%lx\n", err_status);
-	pcibr_error_dump(pcibr_soft);
-	/* machine_error_dump(""); */
-	panic("PCI Bridge Error interrupt killed the system");
-    }
-
-    if (err_status & BRIDGE_ISR_ERROR_FATAL) {
-	panic("PCI Bridge Error interrupt killed the system");
-	    /*NOTREACHED */
-    }
-
-
-    /*
-     * We can't return without re-enabling the interrupt, since
-     * it would cause problems for devices like IOC3 (Lost
-     * interrupts ?.). So, just cleanup the interrupt, and
-     * use saved values later..
-     * 
-     * PIC doesn't require groups of interrupts to be cleared...
-     */
-    pcireg_intr_reset_set(pcibr_soft, (int_status | BRIDGE_IRR_MULTI_CLR));
-
-    /* PIC BRINGUP WAR (PV# 856155):
-     * On a PCI_X_ARB_ERR error interrupt clear the DEV_BROKE bits from
-     * the b_arb register to re-enable the device.
-     */
-    if ((err_status & PIC_ISR_PCIX_ARB_ERR) &&
-		PCIBR_WAR_ENABLED(PV856155, pcibr_soft)) {
-	pcireg_arbitration_bit_set(pcibr_soft, (0xf << 20));
-    }
-
-    /* Zero out bserr_intstat field */
-    pcibr_soft->bs_errinfo.bserr_intstat = 0;
-    return IRQ_HANDLED;
-}
-
-/*
- * pcibr_addr_toslot
- *      Given the 'pciaddr' find out which slot this address is
- *      allocated to, and return the slot number.
- *      While we have the info handy, construct the
- *      function number, space code and offset as well.
- *
- * NOTE: if this routine is called, we don't know whether
- * the address is in CFG, MEM, or I/O space. We have to guess.
- * This will be the case on PIO stores, where the only way
- * we have of getting the address is to check the Bridge, which
- * stores the PCI address but not the space and not the xtalk
- * address (from which we could get it).
- */
-static int
-pcibr_addr_toslot(pcibr_soft_t pcibr_soft,
-		  iopaddr_t pciaddr,
-		  pciio_space_t *spacep,
-		  iopaddr_t *offsetp,
-		  pciio_function_t *funcp)
-{
-    int                     s, f = 0, w;
-    iopaddr_t               base;
-    size_t                  size;
-    pciio_piospace_t        piosp;
-
-    /*
-     * Check if the address is in config space
-     */
-
-    if ((pciaddr >= BRIDGE_CONFIG_BASE) && (pciaddr < BRIDGE_CONFIG_END)) {
-
-	if (pciaddr >= BRIDGE_CONFIG1_BASE)
-	    pciaddr -= BRIDGE_CONFIG1_BASE;
-	else
-	    pciaddr -= BRIDGE_CONFIG_BASE;
-
-	s = pciaddr / BRIDGE_CONFIG_SLOT_SIZE;
-	pciaddr %= BRIDGE_CONFIG_SLOT_SIZE;
-
-	if (funcp) {
-	    f = pciaddr / 0x100;
-	    pciaddr %= 0x100;
-	}
-	if (spacep)
-	    *spacep = PCIIO_SPACE_CFG;
-	if (offsetp)
-	    *offsetp = pciaddr;
-	if (funcp)
-	    *funcp = f;
-
-	return s;
-    }
-    for (s = pcibr_soft->bs_min_slot; s < PCIBR_NUM_SLOTS(pcibr_soft); ++s) {
-	int                     nf = pcibr_soft->bs_slot[s].bss_ninfo;
-	pcibr_info_h            pcibr_infoh = pcibr_soft->bs_slot[s].bss_infos;
-
-	for (f = 0; f < nf; f++) {
-	    pcibr_info_t            pcibr_info = pcibr_infoh[f];
-
-	    if (!pcibr_info)
-		continue;
-	    for (w = 0; w < 6; w++) {
-		if (pcibr_info->f_window[w].w_space
-		    == PCIIO_SPACE_NONE) {
-		    continue;
-		}
-		base = pcibr_info->f_window[w].w_base;
-		size = pcibr_info->f_window[w].w_size;
-
-		if ((pciaddr >= base) && (pciaddr < (base + size))) {
-		    if (spacep)
-			*spacep = PCIIO_SPACE_WIN(w);
-		    if (offsetp)
-			*offsetp = pciaddr - base;
-		    if (funcp)
-			*funcp = f;
-		    return s;
-		}			/* endif match */
-	    }				/* next window */
-	}				/* next func */
-    }					/* next slot */
-
-    /*
-     * Check if the address was allocated as part of the
-     * pcibr_piospace_alloc calls.
-     */
-    for (s = pcibr_soft->bs_min_slot; s < PCIBR_NUM_SLOTS(pcibr_soft); ++s) {
-	int                     nf = pcibr_soft->bs_slot[s].bss_ninfo;
-	pcibr_info_h            pcibr_infoh = pcibr_soft->bs_slot[s].bss_infos;
-
-	for (f = 0; f < nf; f++) {
-	    pcibr_info_t            pcibr_info = pcibr_infoh[f];
-
-	    if (!pcibr_info)
-		continue;
-	    piosp = pcibr_info->f_piospace;
-	    while (piosp) {
-		if ((piosp->start <= pciaddr) &&
-		    ((piosp->count + piosp->start) > pciaddr)) {
-		    if (spacep)
-			*spacep = piosp->space;
-		    if (offsetp)
-			*offsetp = pciaddr - piosp->start;
-		    return s;
-		}			/* endif match */
-		piosp = piosp->next;
-	    }				/* next piosp */
-	}				/* next func */
-    }					/* next slot */
-
-    /*
-     * Some other random address on the PCI bus ...
-     * we have no way of knowing whether this was
-     * a MEM or I/O access; so, for now, we just
-     * assume that the low 1G is MEM, the next
-     * 3G is I/O, and anything above the 4G limit
-     * is obviously MEM.
-     */
-
-    if (spacep)
-	*spacep = ((pciaddr < (1ul << 30)) ? PCIIO_SPACE_MEM :
-		   (pciaddr < (4ul << 30)) ? PCIIO_SPACE_IO :
-		   PCIIO_SPACE_MEM);
-    if (offsetp)
-	*offsetp = pciaddr;
-
-    return PCIIO_SLOT_NONE;
-
-}
-
-void
-pcibr_error_cleanup(pcibr_soft_t pcibr_soft, int error_code)
-{
-    uint64_t	clr_bits = BRIDGE_IRR_ALL_CLR;
-
-    ASSERT(error_code & IOECODE_PIO);
-    error_code = error_code;
-
-    pcireg_intr_reset_set(pcibr_soft, clr_bits);
-
-    pcireg_tflush_get(pcibr_soft);	/* flushbus */
-}
-
-
-/*
- * pcibr_error_extract
- *      Given the 'pcibr vertex handle' find out which slot
- *      the bridge status error address (from pcibr_soft info
- *      hanging off the vertex)
- *      allocated to, and return the slot number.
- *      While we have the info handy, construct the
- *      space code and offset as well.
- *
- * NOTE: if this routine is called, we don't know whether
- * the address is in CFG, MEM, or I/O space. We have to guess.
- * This will be the case on PIO stores, where the only way
- * we have of getting the address is to check the Bridge, which
- * stores the PCI address but not the space and not the xtalk
- * address (from which we could get it).
- *
- * XXX- this interface has no way to return the function
- * number on a multifunction card, even though that data
- * is available.
- */
-
-pciio_slot_t
-pcibr_error_extract(vertex_hdl_t pcibr_vhdl,
-		    pciio_space_t *spacep,
-		    iopaddr_t *offsetp)
-{
-    pcibr_soft_t            pcibr_soft = 0;
-    iopaddr_t               bserr_addr;
-    pciio_slot_t            slot = PCIIO_SLOT_NONE;
-    arbitrary_info_t	    rev;
-
-    /* Do a sanity check as to whether we really got a 
-     * bridge vertex handle.
-     */
-    if (hwgraph_info_get_LBL(pcibr_vhdl, INFO_LBL_PCIBR_ASIC_REV, &rev) !=
-	GRAPH_SUCCESS) 
-	return(slot);
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    if (pcibr_soft) {
-	bserr_addr = pcireg_pci_bus_addr_get(pcibr_soft);
-	slot = pcibr_addr_toslot(pcibr_soft, bserr_addr,
-				 spacep, offsetp, NULL);
-    }
-    return slot;
-}
-
-/*ARGSUSED */
-void
-pcibr_device_disable(pcibr_soft_t pcibr_soft, int devnum)
-{
-    /*
-     * XXX
-     * Device failed to handle error. Take steps to
-     * disable this device ? HOW TO DO IT ?
-     *
-     * If there are any Read response buffers associated
-     * with this device, it's time to get them back!!
-     *
-     * We can disassociate any interrupt level associated
-     * with this device, and disable that interrupt level
-     *
-     * For now it's just a place holder
-     */
-}
-
-/*
- * pcibr_pioerror
- *      Handle PIO error that happened at the bridge pointed by pcibr_soft.
- *
- *      Queries the Bus interface attached to see if the device driver
- *      mapping the device-number that caused error can handle the
- *      situation. If so, it will clean up any error, and return
- *      indicating the error was handled. If the device driver is unable
- *      to handle the error, it expects the bus-interface to disable that
- *      device, and takes any steps needed here to take away any resources
- *      associated with this device.
- *
- * A note about slots:
- *
- * 	PIC-based bridges use zero-based device numbering when devices to
- * 	internal registers.  However, the physical slots are numbered using a
- *	one-based scheme because in PCI-X, device 0 is reserved (see comments
- * 	in pcibr_private.h for a better description).
- *
- * 	When building up the hwgraph, we use the external (one-based) number
- *	scheme when numbering slot components so that hwgraph more accuratly
- * 	reflects what is silkscreened on the bricks.
- *
- * 	Since pciio_error_handler() needs to ultimatly be able to do a hwgraph
- *	lookup, the ioerror that gets built up in pcibr_pioerror() encodes the
- *	external (one-based) slot number.  However, loops in pcibr_pioerror() 
- * 	which attempt to translate the virtual address into the correct
- * 	PCI physical address use the device (zero-based) numbering when 
- * 	walking through bridge structures.
- *
- * 	To that end, pcibr_pioerror() uses device to denote the 
- *	zero-based device number, and external_slot to denote the corresponding
- *	one-based slot number.  Loop counters (eg. cs) are always device based.
- */
-
-/* BEM_ADD_IOE doesn't dump the whole ioerror, it just
- * decodes the PCI specific portions -- we count on our
- * callers to dump the raw IOE data.
- */
-#define BEM_ADD_IOE(ioe)						\
-	do {								\
-	    if (IOERROR_FIELDVALID(ioe, busspace)) {			\
-		iopaddr_t		spc;				\
-		iopaddr_t		win;				\
-		short			widdev;				\
-		iopaddr_t		busaddr;			\
-									\
-		IOERROR_GETVALUE(spc, ioe, busspace);			\
-		win = spc - PCIIO_SPACE_WIN(0);				\
-		IOERROR_GETVALUE(busaddr, ioe, busaddr);		\
-		IOERROR_GETVALUE(widdev, ioe, widgetdev);		\
-									\
-		switch (spc) {						\
-		case PCIIO_SPACE_CFG:					\
-		    printk("\tPCI Slot %d Func %d CFG space Offset 0x%lx\n",\
-			    	pciio_widgetdev_slot_get(widdev),	\
-	    			pciio_widgetdev_func_get(widdev),	\
-				busaddr);				\
-		    break;						\
-		case PCIIO_SPACE_IO:					\
-		    printk("\tPCI I/O space  Offset 0x%lx\n", busaddr);	\
-		    break;						\
-		case PCIIO_SPACE_MEM:					\
-		case PCIIO_SPACE_MEM32:					\
-		case PCIIO_SPACE_MEM64:					\
-		    printk("\tPCI MEM space Offset 0x%lx\n", busaddr);	\
-		    break;						\
-		default:						\
-		    if (win < 6) {					\
-		    printk("\tPCI Slot %d Func %d Window %ld Offset 0x%lx\n",\
-	    			pciio_widgetdev_slot_get(widdev),	\
-	    			pciio_widgetdev_func_get(widdev),	\
-			    	win,					\
-			    	busaddr);				\
-		    }							\
-		    break;						\
-		}							\
-	    }								\
-	} while (0)
-
-/*ARGSUSED */
-int
-pcibr_pioerror(
-		  pcibr_soft_t pcibr_soft,
-		  int error_code,
-		  ioerror_mode_t mode,
-		  ioerror_t *ioe)
-{
-    int                     retval = IOERROR_HANDLED;
-
-    vertex_hdl_t            pcibr_vhdl = pcibr_soft->bs_vhdl;
-    iopaddr_t               bad_xaddr;
-
-    pciio_space_t           raw_space;	/* raw PCI space */
-    iopaddr_t               raw_paddr;	/* raw PCI address */
-
-    pciio_space_t           space;	/* final PCI space */
-    pciio_slot_t            device;	/* final PCI device if appropriate */
-    pciio_slot_t            external_slot;/* external slot for device */
-    pciio_function_t        func;	/* final PCI func, if appropriate */
-    iopaddr_t               offset;	/* final PCI offset */
-    
-    int                     cs, cw, cf;
-    pciio_space_t           wx;
-    iopaddr_t               wb;
-    size_t                  ws;
-    iopaddr_t               wl;
-
-
-    /*
-     * We expect to have an "xtalkaddr" coming in,
-     * and need to construct the slot/space/offset.
-     */
-
-    IOERROR_GETVALUE(bad_xaddr, ioe, xtalkaddr);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR, pcibr_soft->bs_conn,
-                "pcibr_pioerror: pcibr_soft=0x%lx, bad_xaddr=0x%lx\n",
-		pcibr_soft, bad_xaddr));
-
-    device = PCIIO_SLOT_NONE;
-    func = PCIIO_FUNC_NONE;
-    raw_space = PCIIO_SPACE_NONE;
-    raw_paddr = 0;
-
-    if ((bad_xaddr >= PCIBR_BUS_TYPE0_CFG_DEV(pcibr_soft, 0)) &&
-	(bad_xaddr < PCIBR_TYPE1_CFG(pcibr_soft))) {
-	raw_paddr = bad_xaddr - PCIBR_BUS_TYPE0_CFG_DEV(pcibr_soft, 0);
-	device = raw_paddr / BRIDGE_CONFIG_SLOT_SIZE;
-	raw_paddr = raw_paddr % BRIDGE_CONFIG_SLOT_SIZE;
-	raw_space = PCIIO_SPACE_CFG;
-    }
-    if ((bad_xaddr >= PCIBR_TYPE1_CFG(pcibr_soft)) &&
-	(bad_xaddr < (PCIBR_TYPE1_CFG(pcibr_soft) + 0x1000))) {
-	/* Type 1 config space:
-	 * slot and function numbers not known.
-	 * Perhaps we can read them back?
-	 */
-	raw_paddr = bad_xaddr - PCIBR_TYPE1_CFG(pcibr_soft);
-	raw_space = PCIIO_SPACE_CFG;
-    }
-    if ((bad_xaddr >= PCIBR_BRIDGE_DEVIO(pcibr_soft, 0)) &&
-	(bad_xaddr < PCIBR_BRIDGE_DEVIO(pcibr_soft, BRIDGE_DEV_CNT))) {
-	int                     x;
-
-	raw_paddr = bad_xaddr - PCIBR_BRIDGE_DEVIO(pcibr_soft, 0);
-	x = raw_paddr / BRIDGE_DEVIO_OFF;
-	raw_paddr %= BRIDGE_DEVIO_OFF;
-	/* first two devio windows are double-sized */
-	if ((x == 1) || (x == 3))
-	    raw_paddr += BRIDGE_DEVIO_OFF;
-	if (x > 0)
-	    x--;
-	if (x > 1)
-	    x--;
-	/* x is which devio reg; no guarantee
-	 * PCI slot x will be responding.
-	 * still need to figure out who decodes
-	 * space/offset on the bus.
-	 */
-	raw_space = pcibr_soft->bs_slot[x].bss_devio.bssd_space;
-	if (raw_space == PCIIO_SPACE_NONE) {
-	    /* Someone got an error because they
-	     * accessed the PCI bus via a DevIO(x)
-	     * window that pcibr has not yet assigned
-	     * to any specific PCI address. It is
-	     * quite possible that the Device(x)
-	     * register has been changed since they
-	     * made their access, but we will give it
-	     * our best decode shot.
-	     */
-	    raw_space = pcibr_soft->bs_slot[x].bss_device
-		& BRIDGE_DEV_DEV_IO_MEM
-		? PCIIO_SPACE_MEM
-		: PCIIO_SPACE_IO;
-	    raw_paddr +=
-		(pcibr_soft->bs_slot[x].bss_device &
-		 BRIDGE_DEV_OFF_MASK) <<
-		BRIDGE_DEV_OFF_ADDR_SHFT;
-	} else
-	    raw_paddr += pcibr_soft->bs_slot[x].bss_devio.bssd_base;
-    }
-
-    if (IS_PIC_BUSNUM_SOFT(pcibr_soft, 0)) {
-    	if ((bad_xaddr >= PICBRIDGE0_PCI_MEM32_BASE) &&
-	    (bad_xaddr <= PICBRIDGE0_PCI_MEM32_LIMIT)) {
-	    raw_space = PCIIO_SPACE_MEM32;
-	    raw_paddr = bad_xaddr - PICBRIDGE0_PCI_MEM32_BASE;
-    	}
-    	if ((bad_xaddr >= PICBRIDGE0_PCI_MEM64_BASE) &&
-	    (bad_xaddr <= PICBRIDGE0_PCI_MEM64_LIMIT)) {
-	    raw_space = PCIIO_SPACE_MEM64;
-	    raw_paddr = bad_xaddr - PICBRIDGE0_PCI_MEM64_BASE;
-    	}
-    } else if (IS_PIC_BUSNUM_SOFT(pcibr_soft, 1)) {
-    	if ((bad_xaddr >= PICBRIDGE1_PCI_MEM32_BASE) &&
-	    (bad_xaddr <= PICBRIDGE1_PCI_MEM32_LIMIT)) {
-	    raw_space = PCIIO_SPACE_MEM32;
-	    raw_paddr = bad_xaddr - PICBRIDGE1_PCI_MEM32_BASE;
-    	}
-    	if ((bad_xaddr >= PICBRIDGE1_PCI_MEM64_BASE) &&
-	    (bad_xaddr <= PICBRIDGE1_PCI_MEM64_LIMIT)) {
-	    raw_space = PCIIO_SPACE_MEM64;
-	    raw_paddr = bad_xaddr - PICBRIDGE1_PCI_MEM64_BASE;
-    	}
-    } else {
-	printk("pcibr_pioerror(): unknown bridge type");
-	return IOERROR_UNHANDLED;
-    }
-    space = raw_space;
-    offset = raw_paddr;
-
-    if ((device == PCIIO_SLOT_NONE) && (space != PCIIO_SPACE_NONE)) {
-	/* we've got a space/offset but not which
-	 * PCI slot decodes it. Check through our
-	 * notions of which devices decode where.
-	 *
-	 * Yes, this "duplicates" some logic in
-	 * pcibr_addr_toslot; the difference is,
-	 * this code knows which space we are in,
-	 * and can really really tell what is
-	 * going on (no guessing).
-	 */
-
-	for (cs = pcibr_soft->bs_min_slot; 
-		(cs < PCIBR_NUM_SLOTS(pcibr_soft)) && 
-				(device == PCIIO_SLOT_NONE); cs++) {
-	    int                     nf = pcibr_soft->bs_slot[cs].bss_ninfo;
-	    pcibr_info_h            pcibr_infoh = pcibr_soft->bs_slot[cs].bss_infos;
-
-	    for (cf = 0; (cf < nf) && (device == PCIIO_SLOT_NONE); cf++) {
-		pcibr_info_t            pcibr_info = pcibr_infoh[cf];
-
-		if (!pcibr_info)
-		    continue;
-		for (cw = 0; (cw < 6) && (device == PCIIO_SLOT_NONE); ++cw) {
-		    if (((wx = pcibr_info->f_window[cw].w_space) != PCIIO_SPACE_NONE) &&
-			((wb = pcibr_info->f_window[cw].w_base) != 0) &&
-			((ws = pcibr_info->f_window[cw].w_size) != 0) &&
-			((wl = wb + ws) > wb) &&
-			((wb <= offset) && (wl > offset))) {
-			/* MEM, MEM32 and MEM64 need to
-			 * compare as equal ...
-			 */
-			if ((wx == space) ||
-			    (((wx == PCIIO_SPACE_MEM) ||
-			      (wx == PCIIO_SPACE_MEM32) ||
-			      (wx == PCIIO_SPACE_MEM64)) &&
-			     ((space == PCIIO_SPACE_MEM) ||
-			      (space == PCIIO_SPACE_MEM32) ||
-			      (space == PCIIO_SPACE_MEM64)))) {
-			    device = cs;
-			    func = cf;
-			    space = PCIIO_SPACE_WIN(cw);
-			    offset -= wb;
-			}		/* endif window space match */
-		    }			/* endif window valid and addr match */
-		}			/* next window unless slot set */
-	    }				/* next func unless slot set */
-	}				/* next slot unless slot set */
-	/* XXX- if slot is still -1, no PCI devices are
-	 * decoding here using their standard PCI BASE
-	 * registers. This would be a really good place
-	 * to cross-coordinate with the pciio PCI
-	 * address space allocation routines, to find
-	 * out if this address is "allocated" by any of
-	 * our subsidiary devices.
-	 */
-    }
-    /* Scan all piomap records on this PCI bus to update
-     * the TimeOut Counters on all matching maps. If we
-     * don't already know the slot number, take it from
-     * the first matching piomap. Note that we have to
-     * compare maps against raw_space and raw_paddr
-     * since space and offset could already be
-     * window-relative.
-     *
-     * There is a chance that one CPU could update
-     * through this path, and another CPU could also
-     * update due to an interrupt. Closing this hole
-     * would only result in the possibility of some
-     * errors never getting logged at all, and since the
-     * use for bp_toc is as a logical test rather than a
-     * strict count, the excess counts are not a
-     * problem.
-     */
-    for (cs = pcibr_soft->bs_min_slot; 
-				cs < PCIBR_NUM_SLOTS(pcibr_soft); ++cs) {
-	int 		nf = pcibr_soft->bs_slot[cs].bss_ninfo;
-	pcibr_info_h	pcibr_infoh = pcibr_soft->bs_slot[cs].bss_infos;
-
-	for (cf = 0; cf < nf; cf++) {
-	    pcibr_info_t 	pcibr_info = pcibr_infoh[cf];
-	    pcibr_piomap_t	map;    
-
-	    if (!pcibr_info)
-		continue;
-
-	    for (map = pcibr_info->f_piomap;
-	     map != NULL; map = map->bp_next) {
-	    wx = map->bp_space;
-	    wb = map->bp_pciaddr;
-	    ws = map->bp_mapsz;
-	    cw = wx - PCIIO_SPACE_WIN(0);
-	    if (cw >= 0 && cw < 6) {
-		wb += pcibr_soft->bs_slot[cs].bss_window[cw].bssw_base;
-		wx = pcibr_soft->bs_slot[cs].bss_window[cw].bssw_space;
-	    }
-	    if (wx == PCIIO_SPACE_ROM) {
-		wb += pcibr_info->f_rbase;
-		wx = PCIIO_SPACE_MEM;
-	    }
-	    if ((wx == PCIIO_SPACE_MEM32) ||
-		(wx == PCIIO_SPACE_MEM64))
-		wx = PCIIO_SPACE_MEM;
-	    wl = wb + ws;
-	    if ((wx == raw_space) && (raw_paddr >= wb) && (raw_paddr < wl)) {
-		atomic_inc(&map->bp_toc);
-		if (device == PCIIO_SLOT_NONE) {
-		    device = cs;
-		    func = cf;
-		    space = map->bp_space;
-		    if (cw >= 0 && cw < 6)
-			offset -= pcibr_soft->bs_slot[device].bss_window[cw].bssw_base;
-		}
-
-		break;
-	    }
-	    }
-	}
-    }
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR, pcibr_soft->bs_conn,
-                "pcibr_pioerror: space=%d, offset=0x%lx, dev=0x%x, func=0x%x\n",
-		space, offset, device, func));
-
-    if (space != PCIIO_SPACE_NONE) {
-	if (device != PCIIO_SLOT_NONE)  {
-	    external_slot = PCIBR_DEVICE_TO_SLOT(pcibr_soft, device);
-
-	    if (func != PCIIO_FUNC_NONE)
-		IOERROR_SETVALUE(ioe, widgetdev, 
-				 pciio_widgetdev_create(external_slot,func));
-	    else
-    		IOERROR_SETVALUE(ioe, widgetdev, 
-				 pciio_widgetdev_create(external_slot,0));
-	}
-	IOERROR_SETVALUE(ioe, busspace, space);
-	IOERROR_SETVALUE(ioe, busaddr, offset);
-    }
-    if (mode == MODE_DEVPROBE) {
-	/*
-	 * During probing, we don't really care what the
-	 * error is. Clean up the error in Bridge, notify
-	 * subsidiary devices, and return success.
-	 */
-	pcibr_error_cleanup(pcibr_soft, error_code);
-
-	/* if appropriate, give the error handler for this slot
-	 * a shot at this probe access as well.
-	 */
-	return (device == PCIIO_SLOT_NONE) ? IOERROR_HANDLED :
-	    pciio_error_handler(pcibr_vhdl, error_code, mode, ioe);
-    }
-    /*
-     * If we don't know what "PCI SPACE" the access
-     * was targeting, we may have problems at the
-     * Bridge itself. Don't touch any bridge registers,
-     * and do complain loudly.
-     */
-
-    if (space == PCIIO_SPACE_NONE) {
-	printk("XIO Bus Error at %s\n"
-		"\taccess to XIO bus offset 0x%lx\n"
-		"\tdoes not correspond to any PCI address\n",
-		pcibr_soft->bs_name, bad_xaddr);
-
-	/* caller will dump contents of ioe struct */
-	return IOERROR_XTALKLEVEL;
-    }
-
-    /*
-     * Actual PCI Error handling situation.
-     * Typically happens when a user level process accesses
-     * PCI space, and it causes some error.
-     *
-     * Due to PCI Bridge implementation, we get two indication
-     * for a read error: an interrupt and a Bus error.
-     * We like to handle read error in the bus error context.
-     * But the interrupt comes and goes before bus error
-     * could make much progress. (NOTE: interrupd does
-     * come in _after_ bus error processing starts. But it's
-     * completed by the time bus error code reaches PCI PIO
-     * error handling.
-     * Similarly write error results in just an interrupt,
-     * and error handling has to be done at interrupt level.
-     * There is no way to distinguish at interrupt time, if an
-     * error interrupt is due to read/write error..
-     */
-
-    /* We know the xtalk addr, the raw PCI bus space,
-     * the raw PCI bus address, the decoded PCI bus
-     * space, the offset within that space, and the
-     * decoded PCI slot (which may be "PCIIO_SLOT_NONE" if no slot
-     * is known to be involved).
-     */
-
-    /*
-     * Hand the error off to the handler registered
-     * for the slot that should have decoded the error,
-     * or to generic PCI handling (if pciio decides that
-     * such is appropriate).
-     */
-    retval = pciio_error_handler(pcibr_vhdl, error_code, mode, ioe);
-
-    if (retval != IOERROR_HANDLED) {
-
-	/* Generate a generic message for IOERROR_UNHANDLED
-	 * since the subsidiary handlers were silent, and
-	 * did no recovery.
-	 */
-	if (retval == IOERROR_UNHANDLED) {
-	    retval = IOERROR_PANIC;
-
-	    /* we may or may not want to print some of this,
-	     * depending on debug level and which error code.
-	     */
-
-	    printk(KERN_ALERT
-		    "PIO Error on PCI Bus %s",
-		    pcibr_soft->bs_name);
-	    BEM_ADD_IOE(ioe);
-	}
-
-	/*
-	 * Since error could not be handled at lower level,
-	 * error data logged has not  been cleared.
-	 * Clean up errors, and
-	 * re-enable bridge to interrupt on error conditions.
-	 * NOTE: Wheather we get the interrupt on PCI_ABORT or not is
-	 * dependent on INT_ENABLE register. This write just makes sure
-	 * that if the interrupt was enabled, we do get the interrupt.
-	 *
-	 * CAUTION: Resetting bit BRIDGE_IRR_PCI_GRP_CLR, acknowledges
-	 *      a group of interrupts. If while handling this error,
-	 *      some other error has occurred, that would be
-	 *      implicitly cleared by this write.
-	 *      Need a way to ensure we don't inadvertently clear some
-	 *      other errors.
-	 */
-	if (IOERROR_FIELDVALID(ioe, widgetdev)) {
-	    short widdev;
-	    IOERROR_GETVALUE(widdev, ioe, widgetdev);
-	    external_slot = pciio_widgetdev_slot_get(widdev);
-	    device = PCIBR_SLOT_TO_DEVICE(pcibr_soft, external_slot);
-	    pcibr_device_disable(pcibr_soft, device);
-	}
-	if (mode == MODE_DEVUSERERROR)
-	    pcibr_error_cleanup(pcibr_soft, error_code);
-    }
-    return retval;
-}
-
-/*
- * bridge_dmaerror
- *      Some error was identified in a DMA transaction.
- *      This routine will identify the <device, address> that caused the error,
- *      and try to invoke the appropriate bus service to handle this.
- */
-
-int
-pcibr_dmard_error(
-		     pcibr_soft_t pcibr_soft,
-		     int error_code,
-		     ioerror_mode_t mode,
-		     ioerror_t *ioe)
-{
-    vertex_hdl_t            pcibr_vhdl = pcibr_soft->bs_vhdl;
-    int                     retval = 0;
-    int                     bufnum, device;
-
-    /*
-     * In case of DMA errors, bridge should have logged the
-     * address that caused the error.
-     * Look up the address, in the bridge error registers, and
-     * take appropriate action
-     */
-    {
-	short tmp;
-	IOERROR_GETVALUE(tmp, ioe, widgetnum);
-	ASSERT(tmp == pcibr_soft->bs_xid);
-    }
-
-    /*
-     * read error log registers
-     */
-    bufnum = pcireg_resp_err_buf_get(pcibr_soft);
-    device = pcireg_resp_err_dev_get(pcibr_soft);
-    IOERROR_SETVALUE(ioe, widgetdev, pciio_widgetdev_create(device, 0));
-    IOERROR_SETVALUE(ioe, busaddr, pcireg_resp_err_get(pcibr_soft));
-
-    /*
-     * need to ensure that the xtalk address in ioe
-     * maps to PCI error address read from bridge.
-     * How to convert PCI address back to Xtalk address ?
-     * (better idea: convert XTalk address to PCI address
-     * and then do the compare!)
-     */
-
-    retval = pciio_error_handler(pcibr_vhdl, error_code, mode, ioe);
-    if (retval != IOERROR_HANDLED) {
-	short tmp;
-	IOERROR_GETVALUE(tmp, ioe, widgetdev);
-	pcibr_device_disable(pcibr_soft, pciio_widgetdev_slot_get(tmp));
-    }
-
-    /*
-     * Re-enable bridge to interrupt on BRIDGE_IRR_RESP_BUF_GRP_CLR
-     * NOTE: Wheather we get the interrupt on BRIDGE_IRR_RESP_BUF_GRP_CLR or
-     * not is dependent on INT_ENABLE register. This write just makes sure
-     * that if the interrupt was enabled, we do get the interrupt.
-     */
-    pcireg_intr_reset_set(pcibr_soft, BRIDGE_IRR_RESP_BUF_GRP_CLR);
-
-    /*
-     * Also, release the "bufnum" back to buffer pool that could be re-used.
-     * This is done by "disabling" the buffer for a moment, then restoring
-     * the original assignment.
-     */
-
-    {
-	uint64_t		rrb_reg;
-	uint64_t		mask;
-
-	rrb_reg = pcireg_rrb_get(pcibr_soft, (bufnum & 1));
-	mask = 0xF << ((bufnum >> 1) * 4);
-	pcireg_rrb_set(pcibr_soft, (bufnum & 1), (rrb_reg & ~mask));
-	pcireg_rrb_set(pcibr_soft, (bufnum & 1), rrb_reg);
-    }
-
-    return retval;
-}
-
-/*
- * pcibr_dmawr_error:
- *      Handle a dma write error caused by a device attached to this bridge.
- *
- *      ioe has the widgetnum, widgetdev, and memaddr fields updated
- *      But we don't know the PCI address that corresponds to "memaddr"
- *      nor do we know which device driver is generating this address.
- *
- *      There is no easy way to find out the PCI address(es) that map
- *      to a specific system memory address. Bus handling code is also
- *      of not much help, since they don't keep track of the DMA mapping
- *      that have been handed out.
- *      So it's a dead-end at this time.
- *
- *      If translation is available, we could invoke the error handling
- *      interface of the device driver.
- */
-/*ARGSUSED */
-int
-pcibr_dmawr_error(
-		     pcibr_soft_t pcibr_soft,
-		     int error_code,
-		     ioerror_mode_t mode,
-		     ioerror_t *ioe)
-{
-    vertex_hdl_t            pcibr_vhdl = pcibr_soft->bs_vhdl;
-    int                     retval;
-
-    retval = pciio_error_handler(pcibr_vhdl, error_code, mode, ioe);
-
-    if (retval != IOERROR_HANDLED) {
-	short tmp;
-
-	IOERROR_GETVALUE(tmp, ioe, widgetdev);
-	pcibr_device_disable(pcibr_soft, pciio_widgetdev_slot_get(tmp));
-    }
-    return retval;
-}
-
-/*
- * Bridge error handler.
- *      Interface to handle all errors that involve bridge in some way.
- *
- *      This normally gets called from xtalk error handler.
- *      ioe has different set of fields set depending on the error that
- *      was encountered. So, we have a bit field indicating which of the
- *      fields are valid.
- *
- * NOTE: This routine could be operating in interrupt context. So,
- *      don't try to sleep here (till interrupt threads work!!)
- */
-int
-pcibr_error_handler(
-		       error_handler_arg_t einfo,
-		       int error_code,
-		       ioerror_mode_t mode,
-		       ioerror_t *ioe)
-{
-    pcibr_soft_t            pcibr_soft;
-    int                     retval = IOERROR_BADERRORCODE;
-
-    pcibr_soft = (pcibr_soft_t) einfo;
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR, pcibr_soft->bs_conn,
-		"pcibr_error_handler: pcibr_soft=0x%lx, error_code=0x%x\n",
-		pcibr_soft, error_code));
-
-#if DEBUG && ERROR_DEBUG
-    printk( "%s: pcibr_error_handler\n", pcibr_soft->bs_name);
-#endif
-
-    ASSERT(pcibr_soft != NULL);
-
-    if (error_code & IOECODE_PIO)
-	retval = pcibr_pioerror(pcibr_soft, error_code, mode, ioe);
-
-    if (error_code & IOECODE_DMA) {
-	if (error_code & IOECODE_READ) {
-	    /*
-	     * DMA read error occurs when a device attached to the bridge
-	     * tries to read some data from system memory, and this
-	     * either results in a timeout or access error.
-	     * First case is indicated by the bit "XREAD_REQ_TOUT"
-	     * and second case by "RESP_XTALK_ERROR" bit in bridge error
-	     * interrupt status register.
-	     *
-	     * pcibr_error_intr_handler would get invoked first, and it has
-	     * the responsibility of calling pcibr_error_handler with
-	     * suitable parameters.
-	     */
-
-	    retval = pcibr_dmard_error(pcibr_soft, error_code, MODE_DEVERROR, ioe);
-	}
-	if (error_code & IOECODE_WRITE) {
-	    /*
-	     * A device attached to this bridge has been generating
-	     * bad DMA writes. Find out the device attached, and
-	     * slap on it's wrist.
-	     */
-
-	    retval = pcibr_dmawr_error(pcibr_soft, error_code, MODE_DEVERROR, ioe);
-	}
-    }
-    return retval;
-
-}
-
-/*
- * PIC has 2 busses under a single widget so pcibr_attach2 registers this
- * wrapper function rather than pcibr_error_handler() for PIC.  It's upto
- * this wrapper to call pcibr_error_handler() with the correct pcibr_soft
- * struct (ie. the pcibr_soft struct for the bus that saw the error).
- *
- * NOTE: this wrapper function is only registered for PIC ASICs and will
- * only be called for a PIC
- */
-int
-pcibr_error_handler_wrapper(
-		       error_handler_arg_t einfo,
-		       int error_code,
-		       ioerror_mode_t mode,
-		       ioerror_t *ioe)
-{
-    pcibr_soft_t       pcibr_soft = (pcibr_soft_t) einfo;
-    int                pio_retval = -1; 
-    int		       dma_retval = -1;
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR, pcibr_soft->bs_conn,
-                "pcibr_error_handler_wrapper: pcibr_soft=0x%lx, "
-		"error_code=0x%x\n", pcibr_soft, error_code));
-
-    /*
-     * It is possible that both a IOECODE_PIO and a IOECODE_DMA, and both
-     * IOECODE_READ and IOECODE_WRITE could be set in error_code so we must
-     * process all.  Since we are a wrapper for pcibr_error_handler(), and
-     * will be calling it several times within this routine, we turn off the
-     * error_code bits we don't want it to be processing during that call.
-     */
-    /* 
-     * If the error was a result of a PIO, we tell what bus on the PIC saw
-     * the error from the PIO address.
-     */
-
-    if (error_code & IOECODE_PIO) {
-	iopaddr_t               bad_xaddr;
-	/*
-	 * PIC bus0 PIO space 0x000000 - 0x7fffff or 0x40000000 - 0xbfffffff
-	 *     bus1 PIO space 0x800000 - 0xffffff or 0xc0000000 - 0x13fffffff
-	 */
-	IOERROR_GETVALUE(bad_xaddr, ioe, xtalkaddr);
-	if ((bad_xaddr <= 0x7fffff) ||
-	    ((bad_xaddr >= 0x40000000) && (bad_xaddr <= 0xbfffffff))) {
-	    /* bus 0 saw the error */
-	    pio_retval = pcibr_error_handler((error_handler_arg_t)pcibr_soft,
-			 (error_code & ~IOECODE_DMA), mode, ioe);
-	} else if (((bad_xaddr >= 0x800000) && (bad_xaddr <= 0xffffff)) ||
-	    ((bad_xaddr >= 0xc0000000) && (bad_xaddr <= 0x13fffffff))) {
-	    /* bus 1 saw the error */
-	    pcibr_soft = pcibr_soft->bs_peers_soft;
-	    if (!pcibr_soft) {
-#if DEBUG
-		printk(KERN_WARNING "pcibr_error_handler: "
-			"bs_peers_soft==NULL. bad_xaddr= 0x%lx mode= 0x%lx\n",
-						bad_xaddr, mode);
-#endif
-  		pio_retval = IOERROR_HANDLED;
-	    } else
-	        pio_retval= pcibr_error_handler((error_handler_arg_t)pcibr_soft,
-			 (error_code & ~IOECODE_DMA), mode, ioe);
-	} else {
-	    printk(KERN_WARNING "pcibr_error_handler_wrapper(): IOECODE_PIO: "
-		    "saw an invalid pio address: 0x%lx\n", bad_xaddr);
-	    pio_retval = IOERROR_UNHANDLED;
-	}
-    } 
-
-    /* 
-     * If the error was a result of a DMA Write, we tell what bus on the PIC
-     * saw the error by looking at tnum.
-     */
-    if ((error_code & IOECODE_DMA) && (error_code & IOECODE_WRITE)) {
-	short tmp;
-	/*
-         * For DMA writes [X]Bridge encodes the TNUM field of a Xtalk
-         * packet like this:
-         *              bits  value
-         *              4:3   10b
-         *              2:0   device number
-         *
-         * BUT PIC needs the bus number so it does this:
-         *              bits  value
-         *              4:3   10b
-         *              2     busnumber
-         *              1:0   device number
-	 *
-	 * Pull out the bus number from `tnum' and reset the `widgetdev'
-	 * since when hubiio_crb_error_handler() set `widgetdev' it had
-	 * no idea if it was a PIC or a BRIDGE ASIC so it set it based
-	 * off bits 2:0
-	 */
-	IOERROR_GETVALUE(tmp, ioe, tnum);
-	IOERROR_SETVALUE(ioe, widgetdev, (tmp & 0x3));
-	if ((tmp & 0x4) == 0) {
-	    /* bus 0 saw the error. */
-	    dma_retval = pcibr_error_handler((error_handler_arg_t)pcibr_soft,
-			 (error_code & ~(IOECODE_PIO|IOECODE_READ)), mode, ioe);
-	} else {
-	    /* bus 1 saw the error */
-	    pcibr_soft = pcibr_soft->bs_peers_soft;
-	    dma_retval = pcibr_error_handler((error_handler_arg_t)pcibr_soft,
-			 (error_code & ~(IOECODE_PIO|IOECODE_READ)), mode, ioe);
-	}
-    } 
-    
-    /* 
-     * If the error was a result of a DMA READ, XXX ???
-     */
-    if ((error_code & IOECODE_DMA) && (error_code & IOECODE_READ)) {
-	/*
-	 * A DMA Read error will result in a BRIDGE_ISR_RESP_XTLK_ERR
-	 * or BRIDGE_ISR_BAD_XRESP_PKT bridge error interrupt which 
-	 * are fatal interrupts (ie. BRIDGE_ISR_ERROR_FATAL) causing
-	 * pcibr_error_intr_handler() to panic the system.  So is the
-	 * error handler even going to get called???  It appears that
-	 * the pcibr_dmard_error() attempts to clear the interrupts
-	 * so pcibr_error_intr_handler() won't see them, but there
-	 * appears to be nothing to prevent pcibr_error_intr_handler()
-	 * from running before pcibr_dmard_error() has a chance to
-	 * clear the interrupt.
-	 *
-	 * Since we'll be panicing anyways, don't bother handling the
-	 * error for now until we can fix this race condition mentioned
-	 * above.
-	 */
-	dma_retval = IOERROR_UNHANDLED;
-    } 
-    
-    /* XXX: pcibr_error_handler() should probably do the same thing, it over-
-     * write it's return value as it processes the different "error_code"s.
-     */
-    if ((pio_retval == -1) && (dma_retval == -1)) {
-    	return IOERROR_BADERRORCODE;
-    } else if ((dma_retval != IOERROR_HANDLED) && (dma_retval != -1)) {
-	return dma_retval;
-    } else if ((pio_retval != IOERROR_HANDLED) && (pio_retval != -1)) {
-	return pio_retval;
-    } else {
-	return IOERROR_HANDLED;
-    }
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_hints.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_hints.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_hints.c	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,175 +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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-
-pcibr_hints_t           pcibr_hints_get(vertex_hdl_t, int);
-void                    pcibr_hints_fix_rrbs(vertex_hdl_t);
-void                    pcibr_hints_dualslot(vertex_hdl_t, pciio_slot_t, pciio_slot_t);
-void			pcibr_hints_intr_bits(vertex_hdl_t, pcibr_intr_bits_f *);
-void                    pcibr_set_rrb_callback(vertex_hdl_t, rrb_alloc_funct_t);
-void                    pcibr_hints_handsoff(vertex_hdl_t);
-void                    pcibr_hints_subdevs(vertex_hdl_t, pciio_slot_t, uint64_t);
-
-pcibr_hints_t
-pcibr_hints_get(vertex_hdl_t xconn_vhdl, int alloc)
-{
-    arbitrary_info_t        ainfo = 0;
-    graph_error_t	    rv;
-    pcibr_hints_t           hint;
-
-    rv = hwgraph_info_get_LBL(xconn_vhdl, INFO_LBL_PCIBR_HINTS, &ainfo);
-
-    if (alloc && (rv != GRAPH_SUCCESS)) {
-
-	hint = kmalloc(sizeof (*(hint)), GFP_KERNEL);
-	if ( !hint ) {
-		printk(KERN_WARNING "pcibr_hints_get(): unable to allocate "
-			"memory\n");
-		goto abnormal_exit;
-	}
-	memset(hint, 0, sizeof (*(hint)));
-
-	hint->rrb_alloc_funct = NULL;
-	hint->ph_intr_bits = NULL;
-	rv = hwgraph_info_add_LBL(xconn_vhdl, 
-				  INFO_LBL_PCIBR_HINTS, 	
-				  (arbitrary_info_t) hint);
-	if (rv != GRAPH_SUCCESS)
-	    goto abnormal_exit;
-
-	rv = hwgraph_info_get_LBL(xconn_vhdl, INFO_LBL_PCIBR_HINTS, &ainfo);
-	
-	if (rv != GRAPH_SUCCESS)
-	    goto abnormal_exit;
-
-	if (ainfo != (arbitrary_info_t) hint)
-	    goto abnormal_exit;
-    }
-    return (pcibr_hints_t) ainfo;
-
-abnormal_exit:
-    kfree(hint);
-    return NULL;
-
-}
-
-void
-pcibr_hints_fix_some_rrbs(vertex_hdl_t xconn_vhdl, unsigned mask)
-{
-    pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
-
-    if (hint)
-	hint->ph_rrb_fixed = mask;
-    else
-        PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
-		    "pcibr_hints_fix_rrbs: pcibr_hints_get failed\n"));
-}
-
-void
-pcibr_hints_fix_rrbs(vertex_hdl_t xconn_vhdl)
-{
-    pcibr_hints_fix_some_rrbs(xconn_vhdl, 0xFF);
-}
-
-void
-pcibr_hints_dualslot(vertex_hdl_t xconn_vhdl,
-		     pciio_slot_t host,
-		     pciio_slot_t guest)
-{
-    pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
-
-    if (hint)
-	hint->ph_host_slot[guest] = host + 1;
-    else
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
-		    "pcibr_hints_dualslot: pcibr_hints_get failed\n"));
-}
-
-void
-pcibr_hints_intr_bits(vertex_hdl_t xconn_vhdl,
-		      pcibr_intr_bits_f *xxx_intr_bits)
-{
-    pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
-
-    if (hint)
-	hint->ph_intr_bits = xxx_intr_bits;
-    else
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
-		    "pcibr_hints_intr_bits: pcibr_hints_get failed\n"));
-}
-
-void
-pcibr_set_rrb_callback(vertex_hdl_t xconn_vhdl, rrb_alloc_funct_t rrb_alloc_funct)
-{
-    pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
-
-    if (hint)
-	hint->rrb_alloc_funct = rrb_alloc_funct;
-}
-
-void
-pcibr_hints_handsoff(vertex_hdl_t xconn_vhdl)
-{
-    pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
-
-    if (hint)
-	hint->ph_hands_off = 1;
-    else
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
-		    "pcibr_hints_handsoff: pcibr_hints_get failed\n"));
-}
-
-void
-pcibr_hints_subdevs(vertex_hdl_t xconn_vhdl,
-		    pciio_slot_t slot,
-		    uint64_t subdevs)
-{
-    arbitrary_info_t        ainfo = 0;
-    char                    sdname[16];
-    vertex_hdl_t            pconn_vhdl = GRAPH_VERTEX_NONE;
-
-    sprintf(sdname, "%s/%d", EDGE_LBL_PCI, slot);
-    (void) hwgraph_path_add(xconn_vhdl, sdname, &pconn_vhdl);
-    if (pconn_vhdl == GRAPH_VERTEX_NONE) {
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
-		    "pcibr_hints_subdevs: hwgraph_path_create failed\n"));
-	return;
-    }
-    hwgraph_info_get_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, &ainfo);
-    if (ainfo == 0) {
-	uint64_t                *subdevp;
-
-	subdevp = kmalloc(sizeof (*(subdevp)), GFP_KERNEL);
-	if (!subdevp) {
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
-			"pcibr_hints_subdevs: subdev ptr alloc failed\n"));
-	    return;
-	}
-	memset(subdevp, 0, sizeof (*(subdevp)));
-	*subdevp = subdevs;
-	hwgraph_info_add_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, (arbitrary_info_t) subdevp);
-	hwgraph_info_get_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, &ainfo);
-	if (ainfo == (arbitrary_info_t) subdevp)
-	    return;
-	kfree(subdevp);
-	if (ainfo == (arbitrary_info_t) NULL) {
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
-			"pcibr_hints_subdevs: null subdevs ptr\n"));
-	    return;
-	}
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
-		    "pcibr_subdevs_get: dup subdev add_LBL\n"));
-    }
-    *(uint64_t *) ainfo = subdevs;
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c	2004-12-24 13:37:04 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,700 +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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/module.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/arch.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
-
-#ifdef __ia64
-inline int
-compare_and_swap_ptr(void **location, void *old_ptr, void *new_ptr)
-{
-	/* FIXME - compare_and_swap_ptr NOT ATOMIC */
-	if (*location == old_ptr) {
-		*location = new_ptr;
-		return 1;
-	}
-	else
-		return 0;
-}
-#endif
-
-unsigned int		pcibr_intr_bits(pciio_info_t info, pciio_intr_line_t lines, int nslots);
-pcibr_intr_t            pcibr_intr_alloc(vertex_hdl_t, device_desc_t, pciio_intr_line_t, vertex_hdl_t);
-void                    pcibr_intr_free(pcibr_intr_t);
-void              pcibr_setpciint(xtalk_intr_t);
-int                     pcibr_intr_connect(pcibr_intr_t, intr_func_t, intr_arg_t);
-void                    pcibr_intr_disconnect(pcibr_intr_t);
-
-vertex_hdl_t            pcibr_intr_cpu_get(pcibr_intr_t);
-
-extern pcibr_info_t      pcibr_info_get(vertex_hdl_t);
-
-/* =====================================================================
- *    INTERRUPT MANAGEMENT
- */
-
-unsigned int
-pcibr_intr_bits(pciio_info_t info,
-		pciio_intr_line_t lines, int nslots)
-{
-    pciio_slot_t            slot = PCIBR_INFO_SLOT_GET_INT(info);
-    unsigned		    bbits = 0;
-
-    /*
-     * Currently favored mapping from PCI
-     * slot number and INTA/B/C/D to Bridge
-     * PCI Interrupt Bit Number:
-     *
-     *     SLOT     A B C D
-     *      0       0 4 0 4
-     *      1       1 5 1 5
-     *      2       2 6 2 6
-     *      3       3 7 3 7
-     *      4       4 0 4 0
-     *      5       5 1 5 1
-     *      6       6 2 6 2
-     *      7       7 3 7 3
-     */
-
-    if (slot < nslots) {
-	if (lines & (PCIIO_INTR_LINE_A| PCIIO_INTR_LINE_C))
-	    bbits |= 1 << slot;
-	if (lines & (PCIIO_INTR_LINE_B| PCIIO_INTR_LINE_D))
-	    bbits |= 1 << (slot ^ 4);
-    }
-    return bbits;
-}
-
-
-/*
- *	On SN systems there is a race condition between a PIO read response
- *	and DMA's.  In rare cases, the read response may beat the DMA, causing
- *	the driver to think that data in memory is complete and meaningful.
- *	This code eliminates that race.
- *	This routine is called by the PIO read routines after doing the read.
- *	This routine then forces a fake interrupt on another line, which
- *	is logically associated with the slot that the PIO is addressed to.
- *	(see sn_dma_flush_init() )
- *	It then spins while watching the memory location that the interrupt
- *	is targetted to.  When the interrupt response arrives, we are sure
- *	that the DMA has landed in memory and it is safe for the driver
- *	to proceed.
- */
-
-extern struct sn_flush_nasid_entry flush_nasid_list[MAX_NASIDS];
-
-void
-sn_dma_flush(unsigned long addr)
-{
-	nasid_t nasid;
-	int wid_num;
-	struct sn_flush_device_list *p;
-	int i,j;
-	int bwin;
-	unsigned long flags;
-
-	nasid = NASID_GET(addr);
-	wid_num = SWIN_WIDGETNUM(addr);
-	bwin = BWIN_WINDOWNUM(addr);
-
-	if (flush_nasid_list[nasid].widget_p == NULL) return;
-	if (bwin > 0) {
-		unsigned long itte = flush_nasid_list[nasid].iio_itte[bwin];
-
-		wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) &
-				  IIO_ITTE_WIDGET_MASK;
-	}
-	if (flush_nasid_list[nasid].widget_p == NULL) return;
-	if (flush_nasid_list[nasid].widget_p[wid_num] == NULL) return;
-	p = &flush_nasid_list[nasid].widget_p[wid_num][0];
-
-	/* find a matching BAR */
-
-	for (i=0; i<DEV_PER_WIDGET;i++) {
-		for (j=0; j<PCI_ROM_RESOURCE;j++) {
-			if (p->bar_list[j].start == 0) break;
-			if (addr >= p->bar_list[j].start && addr <= p->bar_list[j].end) break;
-		}
-		if (j < PCI_ROM_RESOURCE && p->bar_list[j].start != 0) break;
-		p++;
-	}
-
-	/* if no matching BAR, return without doing anything. */
-
-	if (i == DEV_PER_WIDGET) return;
-
-	spin_lock_irqsave(&p->flush_lock, flags);
-
-	p->flush_addr = 0;
-
-	/* force an interrupt. */
-
-	*(volatile uint32_t *)(p->force_int_addr) = 1;
-
-	/* wait for the interrupt to come back. */
-
-	while (p->flush_addr != 0x10f);
-
-	/* okay, everything is synched up. */
-	spin_unlock_irqrestore(&p->flush_lock, flags);
-}
-
-EXPORT_SYMBOL(sn_dma_flush);
-
-/*
- *	There are end cases where a deadlock can occur if interrupt 
- *	processing completes and the Bridge b_int_status bit is still set.
- *
- *	One scenerio is if a second PCI interrupt occurs within 60ns of
- *	the previous interrupt being cleared. In this case the Bridge
- *	does not detect the transition, the Bridge b_int_status bit
- *	remains set, and because no transition was detected no interrupt
- *	packet is sent to the Hub/Heart.
- *
- *	A second scenerio is possible when a b_int_status bit is being
- *	shared by multiple devices:
- *						Device #1 generates interrupt
- *						Bridge b_int_status bit set
- *						Device #2 generates interrupt
- *		interrupt processing begins
- *		  ISR for device #1 runs and
- *			clears interrupt
- *						Device #1 generates interrupt
- *		  ISR for device #2 runs and
- *			clears interrupt
- *						(b_int_status bit still set)
- *		interrupt processing completes
- *		  
- *	Interrupt processing is now complete, but an interrupt is still
- *	outstanding for Device #1. But because there was no transition of
- *	the b_int_status bit, no interrupt packet will be generated and
- *	a deadlock will occur.
- *
- *	To avoid these deadlock situations, this function is used
- *	to check if a specific Bridge b_int_status bit is set, and if so,
- *	cause the setting of the corresponding interrupt bit.
- *
- *	On a XBridge (SN1) and PIC (SN2), we do this by writing the appropriate Bridge Force 
- *	Interrupt register.
- */
-void
-pcibr_force_interrupt(pcibr_intr_t intr)
-{
-	unsigned	bit;
-	unsigned	bits;
-	pcibr_soft_t    pcibr_soft = intr->bi_soft;
-
-	bits = intr->bi_ibits;
-	for (bit = 0; bit < 8; bit++) {
-		if (bits & (1 << bit)) {
-
-			PCIBR_DEBUG((PCIBR_DEBUG_INTR, pcibr_soft->bs_vhdl,
-		    		"pcibr_force_interrupt: bit=0x%x\n", bit));
-
-			pcireg_force_intr_set(pcibr_soft, bit);
-		}
-	}
-}
-
-/*ARGSUSED */
-pcibr_intr_t
-pcibr_intr_alloc(vertex_hdl_t pconn_vhdl,
-		 device_desc_t dev_desc,
-		 pciio_intr_line_t lines,
-		 vertex_hdl_t owner_dev)
-{
-    pcibr_info_t            pcibr_info = pcibr_info_get(pconn_vhdl);
-    pciio_slot_t            pciio_slot = PCIBR_INFO_SLOT_GET_INT(pcibr_info);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pcibr_info->f_mfast;
-    vertex_hdl_t            xconn_vhdl = pcibr_soft->bs_conn;
-    int                     is_threaded = 0;
-
-    xtalk_intr_t           *xtalk_intr_p;
-    pcibr_intr_t           *pcibr_intr_p;
-    pcibr_intr_list_t      *intr_list_p;
-
-    unsigned                pcibr_int_bits;
-    unsigned                pcibr_int_bit;
-    xtalk_intr_t            xtalk_intr = (xtalk_intr_t)0;
-    hub_intr_t		    hub_intr;
-    pcibr_intr_t            pcibr_intr;
-    pcibr_intr_list_t       intr_entry;
-    pcibr_intr_list_t       intr_list;
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-    		"pcibr_intr_alloc: %s%s%s%s%s\n",
-		!(lines & 15) ? " No INTs?" : "",
-		lines & 1 ? " INTA" : "",
-		lines & 2 ? " INTB" : "",
-		lines & 4 ? " INTC" : "",
-		lines & 8 ? " INTD" : ""));
-
-    pcibr_intr = kmalloc(sizeof (*(pcibr_intr)), GFP_KERNEL);
-    if (!pcibr_intr)
-	return NULL;
-    memset(pcibr_intr, 0, sizeof (*(pcibr_intr)));
-
-    pcibr_intr->bi_dev = pconn_vhdl;
-    pcibr_intr->bi_lines = lines;
-    pcibr_intr->bi_soft = pcibr_soft;
-    pcibr_intr->bi_ibits = 0;		/* bits will be added below */
-    pcibr_intr->bi_func = 0;            /* unset until connect */
-    pcibr_intr->bi_arg = 0;             /* unset until connect */
-    pcibr_intr->bi_flags = is_threaded ? 0 : PCIIO_INTR_NOTHREAD;
-    pcibr_intr->bi_mustruncpu = CPU_NONE;
-    pcibr_intr->bi_ibuf.ib_in = 0;
-    pcibr_intr->bi_ibuf.ib_out = 0;
-    spin_lock_init(&pcibr_intr->bi_ibuf.ib_lock);
-
-    pcibr_int_bits = pcibr_soft->bs_intr_bits((pciio_info_t)pcibr_info, 
-					lines, PCIBR_NUM_SLOTS(pcibr_soft));
-
-    /*
-     * For each PCI interrupt line requested, figure
-     * out which Bridge PCI Interrupt Line it maps
-     * to, and make sure there are xtalk resources
-     * allocated for it.
-     */
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-		"pcibr_intr_alloc: pcibr_int_bits: 0x%x\n", pcibr_int_bits));
-    for (pcibr_int_bit = 0; pcibr_int_bit < 8; pcibr_int_bit ++) {
-	if (pcibr_int_bits & (1 << pcibr_int_bit)) {
-	    xtalk_intr_p = &pcibr_soft->bs_intr[pcibr_int_bit].bsi_xtalk_intr;
-
-	    xtalk_intr = *xtalk_intr_p;
-
-	    if (xtalk_intr == NULL) {
-		/*
-		 * This xtalk_intr_alloc is constrained for two reasons:
-		 * 1) Normal interrupts and error interrupts need to be delivered
-		 *    through a single xtalk target widget so that there aren't any
-		 *    ordering problems with DMA, completion interrupts, and error
-		 *    interrupts. (Use of xconn_vhdl forces this.)
-		 *
-		 * 2) On SN1, addressing constraints on SN1 and Bridge force
-		 *    us to use a single PI number for all interrupts from a
-		 *    single Bridge. (SN1-specific code forces this).
-		 */
-
-		/*
-		 * All code dealing with threaded PCI interrupt handlers
-		 * is located at the pcibr level. Because of this,
-		 * we always want the lower layers (hub/heart_intr_alloc, 
-		 * intr_level_connect) to treat us as non-threaded so we
-		 * don't set up a duplicate threaded environment. We make
-		 * this happen by calling a special xtalk interface.
-		 */
-		xtalk_intr = xtalk_intr_alloc_nothd(xconn_vhdl, dev_desc, 
-			owner_dev);
-
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-			    "pcibr_intr_alloc: xtalk_intr=0x%lx\n", xtalk_intr));
-
-		/* both an assert and a runtime check on this:
-		 * we need to check in non-DEBUG kernels, and
-		 * the ASSERT gets us more information when
-		 * we use DEBUG kernels.
-		 */
-		ASSERT(xtalk_intr != NULL);
-		if (xtalk_intr == NULL) {
-		    /* it is quite possible that our
-		     * xtalk_intr_alloc failed because
-		     * someone else got there first,
-		     * and we can find their results
-		     * in xtalk_intr_p.
-		     */
-		    if (!*xtalk_intr_p) {
-			printk(KERN_ALERT "pcibr_intr_alloc %s: "
-				"unable to get xtalk interrupt resources",
-				pcibr_soft->bs_name);
-			/* yes, we leak resources here. */
-			return 0;
-		    }
-		} else if (compare_and_swap_ptr((void **) xtalk_intr_p, NULL, xtalk_intr)) {
-		    /*
-		     * now tell the bridge which slot is
-		     * using this interrupt line.
-		     */
-		    pcireg_intr_device_bit_clr(pcibr_soft, 
-			    BRIDGE_INT_DEV_MASK(pcibr_int_bit));
-		    pcireg_intr_device_bit_set(pcibr_soft, 
-			    (pciio_slot << BRIDGE_INT_DEV_SHFT(pcibr_int_bit)));
-
-		    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-		    		"bridge intr bit %d clears my wrb\n",
-				pcibr_int_bit));
-		} else {
-		    /* someone else got one allocated first;
-		     * free the one we just created, and
-		     * retrieve the one they allocated.
-		     */
-		    xtalk_intr_free(xtalk_intr);
-		    xtalk_intr = *xtalk_intr_p;
-		}
-	    }
-
-	    pcibr_intr->bi_ibits |= 1 << pcibr_int_bit;
-
-	    intr_entry = kmalloc(sizeof (*(intr_entry)), GFP_KERNEL);
-	    if ( !intr_entry ) {
-		printk(KERN_ALERT "pcibr_intr_alloc %s: "
-			"unable to get memory",
-			pcibr_soft->bs_name);
-		return 0;
-	    }
-	    memset(intr_entry, 0, sizeof (*(intr_entry)));
-
-	    intr_entry->il_next = NULL;
-	    intr_entry->il_intr = pcibr_intr;
-	    intr_entry->il_soft = pcibr_soft;
-	    intr_entry->il_slot = pciio_slot;
-	    intr_list_p = 
-		&pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_list;
-
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-			"Bridge bit 0x%x wrap=0x%lx\n", pcibr_int_bit,
-			&(pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap)));
-
-	    if (compare_and_swap_ptr((void **) intr_list_p, NULL, intr_entry)) {
-		/* we are the first interrupt on this bridge bit.
-		 */
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-			    "INT 0x%x (bridge bit %d) allocated [FIRST]\n",
-			    pcibr_int_bits, pcibr_int_bit));
-		continue;
-	    }
-	    intr_list = *intr_list_p;
-	    pcibr_intr_p = &intr_list->il_intr;
-	    if (compare_and_swap_ptr((void **) pcibr_intr_p, NULL, pcibr_intr)) {
-		/* first entry on list was erased,
-		 * and we replaced it, so we
-		 * don't need our intr_entry.
-		 */
-		kfree(intr_entry);
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-			    "INT 0x%x (bridge bit %d) replaces erased first\n",
-			    pcibr_int_bits, pcibr_int_bit));
-		continue;
-	    }
-	    intr_list_p = &intr_list->il_next;
-	    if (compare_and_swap_ptr((void **) intr_list_p, NULL, intr_entry)) {
-		/* we are the new second interrupt on this bit.
-		 */
-		pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_shared = 1;
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-			    "INT 0x%x (bridge bit %d) is new SECOND\n",
-			    pcibr_int_bits, pcibr_int_bit));
-		continue;
-	    }
-	    while (1) {
-		pcibr_intr_p = &intr_list->il_intr;
-		if (compare_and_swap_ptr((void **) pcibr_intr_p, NULL, pcibr_intr)) {
-		    /* an entry on list was erased,
-		     * and we replaced it, so we
-		     * don't need our intr_entry.
-		     */
-		    kfree(intr_entry);
-
-		    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-				"INT 0x%x (bridge bit %d) replaces erase Nth\n",
-				pcibr_int_bits, pcibr_int_bit));
-		    break;
-		}
-		intr_list_p = &intr_list->il_next;
-		if (compare_and_swap_ptr((void **) intr_list_p, NULL, intr_entry)) {
-		    /* entry appended to share list
-		     */
-		    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-				"INT 0x%x (bridge bit %d) is new Nth\n",
-				pcibr_int_bits, pcibr_int_bit));
-		    break;
-		}
-		/* step to next record in chain
-		 */
-		intr_list = *intr_list_p;
-	    }
-	}
-    }
-
-    hub_intr = (hub_intr_t)xtalk_intr;
-    pcibr_intr->bi_irq = hub_intr->i_bit;
-    pcibr_intr->bi_cpu = hub_intr->i_cpuid;
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-		"pcibr_intr_alloc complete: pcibr_intr=0x%lx\n", pcibr_intr));
-    return pcibr_intr;
-}
-
-/*ARGSUSED */
-void
-pcibr_intr_free(pcibr_intr_t pcibr_intr)
-{
-    unsigned                pcibr_int_bits = pcibr_intr->bi_ibits;
-    pcibr_soft_t            pcibr_soft = pcibr_intr->bi_soft;
-    unsigned                pcibr_int_bit;
-    pcibr_intr_list_t       intr_list;
-    int			    intr_shared;
-    xtalk_intr_t	    *xtalk_intrp;
-
-    for (pcibr_int_bit = 0; pcibr_int_bit < 8; pcibr_int_bit++) {
-	if (pcibr_int_bits & (1 << pcibr_int_bit)) {
-	    for (intr_list = 
-		     pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_list;
-		 intr_list != NULL;
-		 intr_list = intr_list->il_next)
-		if (compare_and_swap_ptr((void **) &intr_list->il_intr, 
-					 pcibr_intr, 
-					 NULL)) {
-
-		    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, 
-				pcibr_intr->bi_dev,
-		    		"pcibr_intr_free: cleared hdlr from bit 0x%x\n",
-				pcibr_int_bit));
-		}
-	    /* If this interrupt line is not being shared between multiple
-	     * devices release the xtalk interrupt resources.
-	     */
-	    intr_shared = 
-		pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_shared;
-	    xtalk_intrp = &pcibr_soft->bs_intr[pcibr_int_bit].bsi_xtalk_intr;
-
-	    if ((!intr_shared) && (*xtalk_intrp)) {
-
-		xtalk_intr_free(*xtalk_intrp);
-		*xtalk_intrp = 0;
-
-		/* Clear the PCI device interrupt to bridge interrupt pin
-		 * mapping.
-		 */
-		pcireg_intr_device_bit_clr(pcibr_soft, 
-			BRIDGE_INT_DEV_MASK(pcibr_int_bit));
-	    }
-	}
-    }
-    kfree(pcibr_intr);
-}
-
-void
-pcibr_setpciint(xtalk_intr_t xtalk_intr)
-{
-    iopaddr_t		 addr;
-    xtalk_intr_vector_t	 vect;
-    vertex_hdl_t	 vhdl;
-    int			 bus_num;
-    int			 pcibr_int_bit;
-    void		 *bridge;
-    
-    addr = xtalk_intr_addr_get(xtalk_intr);
-    vect = xtalk_intr_vector_get(xtalk_intr);
-    vhdl = xtalk_intr_dev_get(xtalk_intr);
-
-    /* bus and int_bits are stored in sfarg, bus bit3, int_bits bit2:0 */
-    pcibr_int_bit = *((int *)xtalk_intr_sfarg_get(xtalk_intr)) & 0x7;
-    bus_num = ((*((int *)xtalk_intr_sfarg_get(xtalk_intr)) & 0x8) >> 3);
-
-    bridge = pcibr_bridge_ptr_get(vhdl, bus_num);
-    pcireg_bridge_intr_addr_vect_set(bridge, pcibr_int_bit, vect);
-    pcireg_bridge_intr_addr_addr_set(bridge, pcibr_int_bit, addr);
-}
-
-/*ARGSUSED */
-int
-pcibr_intr_connect(pcibr_intr_t pcibr_intr, intr_func_t intr_func, intr_arg_t intr_arg)
-{
-    pcibr_soft_t            pcibr_soft = pcibr_intr->bi_soft;
-    unsigned                pcibr_int_bits = pcibr_intr->bi_ibits;
-    unsigned                pcibr_int_bit;
-    unsigned long	    s;
-
-    if (pcibr_intr == NULL)
-	return -1;
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pcibr_intr->bi_dev,
-		"pcibr_intr_connect: intr_func=0x%lx, intr_arg=0x%lx\n",
-		intr_func, intr_arg));
-
-    pcibr_intr->bi_func = intr_func;
-    pcibr_intr->bi_arg = intr_arg;
-    *((volatile unsigned *)&pcibr_intr->bi_flags) |= PCIIO_INTR_CONNECTED;
-
-    /*
-     * For each PCI interrupt line requested, figure
-     * out which Bridge PCI Interrupt Line it maps
-     * to, and make sure there are xtalk resources
-     * allocated for it.
-     */
-    for (pcibr_int_bit = 0; pcibr_int_bit < 8; pcibr_int_bit++)
-	if (pcibr_int_bits & (1 << pcibr_int_bit)) {
-            pcibr_intr_wrap_t       intr_wrap;
-	    xtalk_intr_t            xtalk_intr;
-            void                   *int_addr;
-
-	    xtalk_intr = pcibr_soft->bs_intr[pcibr_int_bit].bsi_xtalk_intr;
-	    intr_wrap = &pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap;
-
-	    /*
-	     * If this interrupt line is being shared and the connect has
-	     * already been done, no need to do it again.
-	     */
-	    if (pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_connected)
-		continue;
-
-
-	    /*
-	     * Use the pcibr wrapper function to handle all Bridge interrupts
-	     * regardless of whether the interrupt line is shared or not.
-	     */
-	    int_addr = pcireg_intr_addr_addr(pcibr_soft, pcibr_int_bit);
-	    pcibr_soft->bs_intr[pcibr_int_bit].bsi_int_bit = 
-			       ((pcibr_soft->bs_busnum << 3) | pcibr_int_bit);
-	    xtalk_intr_connect(xtalk_intr,
-			       NULL,
-			       (intr_arg_t) intr_wrap,
-			       (xtalk_intr_setfunc_t) pcibr_setpciint,
-			       &pcibr_soft->bs_intr[pcibr_int_bit].bsi_int_bit);
-
-	    pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_connected = 1;
-
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pcibr_intr->bi_dev,
-			"pcibr_setpciint: int_addr=0x%lx, *int_addr=0x%lx, "
-			"pcibr_int_bit=0x%x\n", int_addr, 
-			pcireg_intr_addr_get(pcibr_soft, pcibr_int_bit),
-			pcibr_int_bit));
-	}
-
-	s = pcibr_lock(pcibr_soft);
-	pcireg_intr_enable_bit_set(pcibr_soft, pcibr_int_bits);
-	pcireg_tflush_get(pcibr_soft);
-	pcibr_unlock(pcibr_soft, s);
-
-    return 0;
-}
-
-/*ARGSUSED */
-void
-pcibr_intr_disconnect(pcibr_intr_t pcibr_intr)
-{
-    pcibr_soft_t            pcibr_soft = pcibr_intr->bi_soft;
-    unsigned                pcibr_int_bits = pcibr_intr->bi_ibits;
-    unsigned                pcibr_int_bit;
-    pcibr_intr_wrap_t	    intr_wrap;
-    unsigned long	    s;
-
-    /* Stop calling the function. Now.
-     */
-    *((volatile unsigned *)&pcibr_intr->bi_flags) &= ~PCIIO_INTR_CONNECTED;
-    pcibr_intr->bi_func = 0;
-    pcibr_intr->bi_arg = 0;
-    /*
-     * For each PCI interrupt line requested, figure
-     * out which Bridge PCI Interrupt Line it maps
-     * to, and disconnect the interrupt.
-     */
-
-    /* don't disable interrupts for lines that
-     * are shared between devices.
-     */
-    for (pcibr_int_bit = 0; pcibr_int_bit < 8; pcibr_int_bit++)
-	if ((pcibr_int_bits & (1 << pcibr_int_bit)) &&
-	    (pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_shared))
-	    pcibr_int_bits &= ~(1 << pcibr_int_bit);
-    if (!pcibr_int_bits)
-	return;
-
-    s = pcibr_lock(pcibr_soft);
-    pcireg_intr_enable_bit_clr(pcibr_soft, pcibr_int_bits);
-    pcireg_tflush_get(pcibr_soft); 	/* wait until Bridge PIO complete */
-    pcibr_unlock(pcibr_soft, s);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pcibr_intr->bi_dev,
-		"pcibr_intr_disconnect: disabled int_bits=0x%x\n", 
-		pcibr_int_bits));
-
-    for (pcibr_int_bit = 0; pcibr_int_bit < 8; pcibr_int_bit++)
-	if (pcibr_int_bits & (1 << pcibr_int_bit)) {
-
-	    /* if the interrupt line is now shared,
-	     * do not disconnect it.
-	     */
-	    if (pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_shared)
-		continue;
-
-	    xtalk_intr_disconnect(pcibr_soft->bs_intr[pcibr_int_bit].bsi_xtalk_intr);
-	    pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_connected = 0;
-
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pcibr_intr->bi_dev,
-			"pcibr_intr_disconnect: disconnect int_bits=0x%x\n",
-			pcibr_int_bits));
-
-	    /* if we are sharing the interrupt line,
-	     * connect us up; this closes the hole
-	     * where the another pcibr_intr_alloc()
-	     * was in progress as we disconnected.
-	     */
-	    intr_wrap = &pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap;
-	    if (!pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_shared)
-		continue;
-
-	    pcibr_soft->bs_intr[pcibr_int_bit].bsi_int_bit =
-				((pcibr_soft->bs_busnum << 3) | pcibr_int_bit);
-	    xtalk_intr_connect(pcibr_soft->bs_intr[pcibr_int_bit].bsi_xtalk_intr,
-			       NULL,
-			       (intr_arg_t) intr_wrap,
-			       (xtalk_intr_setfunc_t) pcibr_setpciint,
-			       &pcibr_soft->bs_intr[pcibr_int_bit].bsi_int_bit);
-
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pcibr_intr->bi_dev,
-			"pcibr_intr_disconnect: now-sharing int_bits=0x%x\n",
-			pcibr_int_bit));
-	}
-}
-
-/*ARGSUSED */
-vertex_hdl_t
-pcibr_intr_cpu_get(pcibr_intr_t pcibr_intr)
-{
-    pcibr_soft_t            pcibr_soft = pcibr_intr->bi_soft;
-    unsigned                pcibr_int_bits = pcibr_intr->bi_ibits;
-    unsigned                pcibr_int_bit;
-
-    for (pcibr_int_bit = 0; pcibr_int_bit < 8; pcibr_int_bit++)
-	if (pcibr_int_bits & (1 << pcibr_int_bit))
-	    return xtalk_intr_cpu_get(pcibr_soft->bs_intr[pcibr_int_bit].bsi_xtalk_intr);
-    return 0;
-}
-
-/* =====================================================================
- *    INTERRUPT HANDLING
- */
-void
-pcibr_clearwidint(pcibr_soft_t pcibr_soft)
-{
-    pcireg_intr_dst_set(pcibr_soft, 0);
-}
-
-
-void
-pcibr_setwidint(xtalk_intr_t intr)
-{
-    xwidgetnum_t            targ = xtalk_intr_target_get(intr);
-    iopaddr_t               addr = xtalk_intr_addr_get(intr);
-    xtalk_intr_vector_t     vect = xtalk_intr_vector_get(intr);
-
-    pcibr_soft_t	   bridge = (pcibr_soft_t)xtalk_intr_sfarg_get(intr);
-
-    pcireg_intr_dst_target_id_set(bridge, targ);
-    pcireg_intr_dst_addr_set(bridge, addr);
-    pcireg_intr_host_err_set(bridge, vect);
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_reg.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_reg.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_reg.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,879 +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) 2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-
-
-/*
- * Identification Register Access -- Read Only			    0000_0000 
- */
-static uint64_t
-__pcireg_id_get(pic_t *bridge)
-{
-	return bridge->p_wid_id;
-}
-
-uint64_t
-pcireg_bridge_id_get(void *ptr)
-{
-	return __pcireg_id_get((pic_t *)ptr);
-}
-
-uint64_t
-pcireg_id_get(pcibr_soft_t ptr)
-{
-	return __pcireg_id_get((pic_t *)ptr->bs_base);
-}
-
-
-
-/*
- * Address Bus Side Holding Register Access -- Read Only	    0000_0010
- */
-uint64_t
-pcireg_bus_err_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_wid_err;
-}
-
-
-/*
- * Control Register Access -- Read/Write			    0000_0020
- */
-static uint64_t
-__pcireg_control_get(pic_t *bridge)
-{
-	return bridge->p_wid_control;
-}
-
-uint64_t
-pcireg_bridge_control_get(void *ptr)
-{
-	return __pcireg_control_get((pic_t *)ptr);
-}
-
-uint64_t
-pcireg_control_get(pcibr_soft_t ptr)
-{
-	return __pcireg_control_get((pic_t *)ptr->bs_base);
-}
-
-
-void
-pcireg_control_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	/* WAR for PV 439897 & 454474.  Add a readback of the control 
-	 * register.  Lock to protect against MP accesses to this
-	 * register along with other write-only registers (See PVs).
-	 * This register isnt accessed in the "hot path" so the splhi
-	 * shouldn't be a bottleneck
-	 */
-
-	bridge->p_wid_control = val;
-	bridge->p_wid_control;	/* WAR */
-}
-
-
-void
-pcireg_control_bit_clr(pcibr_soft_t ptr, uint64_t bits)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	/* WAR for PV 439897 & 454474.  Add a readback of the control
-	 * register.  Lock to protect against MP accesses to this
-	 * register along with other write-only registers (See PVs).
-	 * This register isnt accessed in the "hot path" so the splhi
-	 * shouldn't be a bottleneck
-	 */
-
-	bridge->p_wid_control &= ~bits;
-	bridge->p_wid_control;	/* WAR */
-}
-
-
-void
-pcireg_control_bit_set(pcibr_soft_t ptr, uint64_t bits)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	/* WAR for PV 439897 & 454474.  Add a readback of the control
-	 * register.  Lock to protect against MP accesses to this
-	 * register along with other write-only registers (See PVs).
-	 * This register isnt accessed in the "hot path" so the splhi
-	 * shouldn't be a bottleneck
-	 */
-
-	bridge->p_wid_control |= bits;
-	bridge->p_wid_control;	/* WAR */
-}
-
-/*
- * Bus Speed (from control register); -- Read Only access	    0000_0020
- * 0x00 == 33MHz, 0x01 == 66MHz, 0x10 == 100MHz, 0x11 == 133MHz
- */
-uint64_t
-pcireg_speed_get(pcibr_soft_t ptr)
-{
-	uint64_t speedbits;
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	speedbits = bridge->p_wid_control & PIC_CTRL_PCI_SPEED;
-	return (speedbits >> 4);
-}
-
-/*
- * Bus Mode (ie. PCIX or PCI) (from Status register);		    0000_0008
- * 0x0 == PCI, 0x1 == PCI-X
- */
-uint64_t
-pcireg_mode_get(pcibr_soft_t ptr)
-{
-	uint64_t pcix_active_bit;
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	pcix_active_bit = bridge->p_wid_stat & PIC_STAT_PCIX_ACTIVE;
-	return (pcix_active_bit >> PIC_STAT_PCIX_ACTIVE_SHFT);
-}
-
-void
-pcireg_req_timeout_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_wid_req_timeout = val;
-}
-
-/*
- * Interrupt Destination Addr Register Access -- Read/Write	    0000_0038
- */
-
-void
-pcireg_intr_dst_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_wid_int = val;
-}
-
-/*
- * Intr Destination Addr Reg Access (target_id) -- Read/Write	    0000_0038
- */
-uint64_t
-pcireg_intr_dst_target_id_get(pcibr_soft_t ptr)
-{
-	uint64_t tid_bits;
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	tid_bits = (bridge->p_wid_int & PIC_INTR_DEST_TID);
-	return (tid_bits >> PIC_INTR_DEST_TID_SHFT);
-}
-
-void
-pcireg_intr_dst_target_id_set(pcibr_soft_t ptr, uint64_t target_id)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_wid_int &= ~PIC_INTR_DEST_TID;
-	bridge->p_wid_int |=
-		    ((target_id << PIC_INTR_DEST_TID_SHFT) & PIC_INTR_DEST_TID);
-}
-
-/*
- * Intr Destination Addr Register Access (addr) -- Read/Write	    0000_0038
- */
-uint64_t
-pcireg_intr_dst_addr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_wid_int & PIC_XTALK_ADDR_MASK;
-}
-
-void
-pcireg_intr_dst_addr_set(pcibr_soft_t ptr, uint64_t addr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_wid_int &= ~PIC_XTALK_ADDR_MASK;
-	bridge->p_wid_int |= (addr & PIC_XTALK_ADDR_MASK);
-}
-
-/*
- * Cmd Word Holding Bus Side Error Register Access -- Read Only	    0000_0040
- */
-uint64_t
-pcireg_cmdword_err_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_wid_err_cmdword;
-}
-
-/*
- * PCI/PCIX Target Flush Register Access -- Read Only		    0000_0050
- */
-uint64_t
-pcireg_tflush_get(pcibr_soft_t ptr)
-{
-	uint64_t ret = 0;
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	ret = bridge->p_wid_tflush;
-
-	/* Read of the Targer Flush should always return zero */
-	ASSERT_ALWAYS(ret == 0);
-	return ret;
-}
-
-/*
- * Cmd Word Holding Link Side Error Register Access -- Read Only    0000_0058
- */
-uint64_t
-pcireg_linkside_err_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_wid_aux_err;
-}
-
-/*
- * PCI Response Buffer Address Holding Register -- Read Only	    0000_0068
- */
-uint64_t
-pcireg_resp_err_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_wid_resp;
-}
-
-/*
- * PCI Resp Buffer Address Holding Reg (Address) -- Read Only	    0000_0068
- */
-uint64_t
-pcireg_resp_err_addr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_wid_resp & PIC_RSP_BUF_ADDR;
-}
-
-/*
- * PCI Resp Buffer Address Holding Register (Buffer)-- Read Only    0000_0068
- */
-uint64_t
-pcireg_resp_err_buf_get(pcibr_soft_t ptr)
-{
-	uint64_t bufnum_bits;
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bufnum_bits = (bridge->p_wid_resp_upper & PIC_RSP_BUF_NUM);
-	return (bufnum_bits >> PIC_RSP_BUF_NUM_SHFT);
-}
-
-/*
- * PCI Resp Buffer Address Holding Register (Device)-- Read Only    0000_0068
- */
-uint64_t
-pcireg_resp_err_dev_get(pcibr_soft_t ptr)
-{
-	uint64_t devnum_bits;
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	devnum_bits = (bridge->p_wid_resp_upper & PIC_RSP_BUF_DEV_NUM);
-	return (devnum_bits >> PIC_RSP_BUF_DEV_NUM_SHFT);
-}
-
-/*
- * Address Holding Register Link Side Errors -- Read Only	    0000_0078
- */
-uint64_t
-pcireg_linkside_err_addr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_wid_addr_lkerr;
-}
-
-void
-pcireg_dirmap_wid_set(pcibr_soft_t ptr, uint64_t target)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_dir_map &= ~PIC_DIRMAP_WID;
-	bridge->p_dir_map |=
-		    ((target << PIC_DIRMAP_WID_SHFT) & PIC_DIRMAP_WID);
-}
-
-void
-pcireg_dirmap_diroff_set(pcibr_soft_t ptr, uint64_t dir_off)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_dir_map &= ~PIC_DIRMAP_DIROFF;
-	bridge->p_dir_map |= (dir_off & PIC_DIRMAP_DIROFF);
-}
-
-void
-pcireg_dirmap_add512_set(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_dir_map |= PIC_DIRMAP_ADD512;
-}
-
-void
-pcireg_dirmap_add512_clr(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_dir_map &= ~PIC_DIRMAP_ADD512;
-}
-
-/*
- * PCI Page Map Fault Address Register Access -- Read Only	    0000_0090
- */
-uint64_t
-pcireg_map_fault_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_map_fault;
-}
-
-/*
- * Arbitration Register Access -- Read/Write			    0000_00A0
- */
-uint64_t
-pcireg_arbitration_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_arb;
-}
-
-void
-pcireg_arbitration_bit_set(pcibr_soft_t ptr, uint64_t bits)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_arb |= bits;
-}
-
-/*
- * Internal Ram Parity Error Register Access -- Read Only	    0000_00B0
- */
-uint64_t
-pcireg_parity_err_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_ate_parity_err;
-}
-
-/*
- * Type 1 Configuration Register Access -- Read/Write		    0000_00C8
- */
-void
-pcireg_type1_cntr_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_pci_cfg = val;
-}
-
-/*
- * PCI Bus Error Lower Addr Holding Reg Access -- Read Only	    0000_00D8
- */
-uint64_t
-pcireg_pci_bus_addr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pci_err;
-}
-
-/*
- * PCI Bus Error Addr Holding Reg Access (Address) -- Read Only	    0000_00D8
- */
-uint64_t
-pcireg_pci_bus_addr_addr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pci_err & PIC_XTALK_ADDR_MASK;
-}
-
-/*
- * Interrupt Status Register Access -- Read Only		    0000_0100
- */
-uint64_t
-pcireg_intr_status_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_int_status;
-}
-
-/*
- * Interrupt Enable Register Access -- Read/Write		    0000_0108
- */
-uint64_t
-pcireg_intr_enable_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_int_enable;
-}
-
-void
-pcireg_intr_enable_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_int_enable = val;
-}
-
-void
-pcireg_intr_enable_bit_clr(pcibr_soft_t ptr, uint64_t bits)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_int_enable &= ~bits;
-}
-
-void
-pcireg_intr_enable_bit_set(pcibr_soft_t ptr, uint64_t bits)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_int_enable |= bits;
-}
-
-/*
- * Interrupt Reset Register Access -- Write Only		    0000_0110
- */
-void
-pcireg_intr_reset_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_int_rst_stat = val;
-}
-
-void
-pcireg_intr_mode_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_int_mode = val;
-}
-
-void
-pcireg_intr_device_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_int_device = val;
-}
-
-static void
-__pcireg_intr_device_bit_set(pic_t *bridge, uint64_t bits)
-{
-	bridge->p_int_device |= bits;
-}
-
-void
-pcireg_bridge_intr_device_bit_set(void *ptr, uint64_t bits)
-{
-	__pcireg_intr_device_bit_set((pic_t *)ptr, bits);
-}
-
-void
-pcireg_intr_device_bit_set(pcibr_soft_t ptr, uint64_t bits)
-{
-	__pcireg_intr_device_bit_set((pic_t *)ptr->bs_base, bits);
-}
-
-void
-pcireg_intr_device_bit_clr(pcibr_soft_t ptr, uint64_t bits)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_int_device &= ~bits;
-}
-
-/*
- * Host Error Interrupt Field Register Access -- Read/Write	    0000_0128
- */
-void
-pcireg_intr_host_err_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_int_host_err = val;
-}
-
-/*
- * Interrupt Host Address Register -- Read/Write	0000_0130 - 0000_0168
- */
-uint64_t
-pcireg_intr_addr_get(pcibr_soft_t ptr, int int_n)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_int_addr[int_n];
-}
-
-static void
-__pcireg_intr_addr_set(pic_t *bridge, int int_n, uint64_t val)
-{
-	bridge->p_int_addr[int_n] = val;
-}
-
-void
-pcireg_bridge_intr_addr_set(void *ptr, int int_n, uint64_t val)
-{
-	__pcireg_intr_addr_set((pic_t *)ptr, int_n, val);
-}
-
-void
-pcireg_intr_addr_set(pcibr_soft_t ptr, int int_n, uint64_t val)
-{
-	__pcireg_intr_addr_set((pic_t *)ptr->bs_base, int_n, val);
-}
-
-void *
-pcireg_intr_addr_addr(pcibr_soft_t ptr, int int_n)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return (void *)&(bridge->p_int_addr[int_n]);
-}
-
-static void
-__pcireg_intr_addr_vect_set(pic_t *bridge, int int_n, uint64_t vect)
-{
-	bridge->p_int_addr[int_n] &= ~PIC_HOST_INTR_FLD;
-	bridge->p_int_addr[int_n] |=
-		    ((vect << PIC_HOST_INTR_FLD_SHFT) & PIC_HOST_INTR_FLD);
-}
-
-void
-pcireg_bridge_intr_addr_vect_set(void *ptr, int int_n, uint64_t vect)
-{
-	__pcireg_intr_addr_vect_set((pic_t *)ptr, int_n, vect);
-}
-
-void
-pcireg_intr_addr_vect_set(pcibr_soft_t ptr, int int_n, uint64_t vect)
-{
-	__pcireg_intr_addr_vect_set((pic_t *)ptr->bs_base, int_n, vect);
-}
-
-
-
-/*
- * Intr Host Address Register (int_addr) -- Read/Write	0000_0130 - 0000_0168
- */
-static void
-__pcireg_intr_addr_addr_set(pic_t *bridge, int int_n, uint64_t addr)
-{
-	bridge->p_int_addr[int_n] &= ~PIC_HOST_INTR_ADDR;
-	bridge->p_int_addr[int_n] |= (addr & PIC_HOST_INTR_ADDR);
-}
-
-void
-pcireg_bridge_intr_addr_addr_set(void *ptr, int int_n, uint64_t addr)
-{
-	__pcireg_intr_addr_addr_set((pic_t *)ptr, int_n, addr);
-}
-
-void
-pcireg_intr_addr_addr_set(pcibr_soft_t ptr, int int_n, uint64_t addr)
-{
-	__pcireg_intr_addr_addr_set((pic_t *)ptr->bs_base, int_n, addr);
-}
-
-/*
- * Multiple Interrupt Register Access -- Read Only		    0000_0178
- */
-uint64_t
-pcireg_intr_multiple_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_mult_int;
-}
-
-/*
- * Force Always Intr Register Access -- Write Only	0000_0180 - 0000_01B8
- */
-static void *
-__pcireg_force_always_addr_get(pic_t *bridge, int int_n)
-{
-	return (void *)&(bridge->p_force_always[int_n]);
-}
-
-void *
-pcireg_bridge_force_always_addr_get(void *ptr, int int_n)
-{
-	return __pcireg_force_always_addr_get((pic_t *)ptr, int_n);
-}
-
-void *
-pcireg_force_always_addr_get(pcibr_soft_t ptr, int int_n)
-{
-	return __pcireg_force_always_addr_get((pic_t *)ptr->bs_base, int_n);
-}
-
-/*
- * Force Interrupt Register Access -- Write Only	0000_01C0 - 0000_01F8
- */
-void
-pcireg_force_intr_set(pcibr_soft_t ptr, int int_n)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_force_pin[int_n] = 1;
-}
-
-/*
- * Device(x) Register Access -- Read/Write		0000_0200 - 0000_0218
- */
-uint64_t
-pcireg_device_get(pcibr_soft_t ptr, int device)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	ASSERT_ALWAYS((device >= 0) && (device <= 3));
-	return bridge->p_device[device];
-}
-
-void
-pcireg_device_set(pcibr_soft_t ptr, int device, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	ASSERT_ALWAYS((device >= 0) && (device <= 3));
-	bridge->p_device[device] = val;
-}
-
-/*
- * Device(x) Write Buffer Flush Reg Access -- Read Only	0000_0240 - 0000_0258
- */
-uint64_t
-pcireg_wrb_flush_get(pcibr_soft_t ptr, int device)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-	uint64_t ret = 0;
-
-	ASSERT_ALWAYS((device >= 0) && (device <= 3));
-	ret = bridge->p_wr_req_buf[device];
-
-	/* Read of the Write Buffer Flush should always return zero */
-	ASSERT_ALWAYS(ret == 0);
-	return ret;
-}
-
-/*
- * Even/Odd RRB Register Access -- Read/Write		0000_0280 - 0000_0288
- */
-uint64_t
-pcireg_rrb_get(pcibr_soft_t ptr, int even_odd)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_rrb_map[even_odd];
-}
-
-void
-pcireg_rrb_set(pcibr_soft_t ptr, int even_odd, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_rrb_map[even_odd] = val;
-}
-
-void
-pcireg_rrb_bit_set(pcibr_soft_t ptr, int even_odd, uint64_t bits)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_rrb_map[even_odd] |= bits;
-}
-
-/*
- * RRB Status Register Access -- Read Only			    0000_0290
- */
-uint64_t
-pcireg_rrb_status_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_resp_status;
-}
-
-/*
- * RRB Clear Register Access -- Write Only			    0000_0298
- */
-void
-pcireg_rrb_clear_set(pcibr_soft_t ptr, uint64_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	bridge->p_resp_clear = val;
-}
-
-/*
- * PCIX Bus Error Address Register Access -- Read Only		    0000_0600
- */
-uint64_t
-pcireg_pcix_bus_err_addr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pcix_bus_err_addr;
-}
-
-/*
- * PCIX Bus Error Attribute Register Access -- Read Only	    0000_0608
- */
-uint64_t
-pcireg_pcix_bus_err_attr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pcix_bus_err_attr;
-}
-
-/*
- * PCIX Bus Error Data Register Access -- Read Only		    0000_0610
- */
-uint64_t
-pcireg_pcix_bus_err_data_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pcix_bus_err_data;
-}
-
-/*
- * PCIX PIO Split Request Address Register Access -- Read Only	    0000_0618
- */
-uint64_t
-pcireg_pcix_pio_split_addr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pcix_pio_split_addr;
-}
-
-/*
- * PCIX PIO Split Request Attribute Register Access -- Read Only    0000_0620
- */
-uint64_t
-pcireg_pcix_pio_split_attr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pcix_pio_split_attr;
-}
-
-/*
- * PCIX DMA Request Error Attribute Register Access -- Read Only    0000_0628
- */
-uint64_t
-pcireg_pcix_req_err_attr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pcix_dma_req_err_attr;
-}
-
-/*
- * PCIX DMA Request Error Address Register Access -- Read Only	    0000_0630
- */
-uint64_t
-pcireg_pcix_req_err_addr_get(pcibr_soft_t ptr)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	return bridge->p_pcix_dma_req_err_addr;
-}
-
-/*
- * Type 0 Configuration Space Access -- Read/Write
- */
-cfg_p
-pcireg_type0_cfg_addr(pcibr_soft_t ptr, uint8_t slot, uint8_t func, int off)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	/* Type 0 Config space accesses on PIC are 1-4, not 0-3 since
-	 * it is a PCIX Bridge.  See sys/PCI/pic.h for explanation.
-	 */
-	slot++;
-	ASSERT_ALWAYS(((int) slot >= 1) && ((int) slot <= 4));
-	return &(bridge->p_type0_cfg_dev[slot].f[func].l[(off / 4)]);
-}
-
-/*
- * Type 1 Configuration Space Access -- Read/Write
- */
-cfg_p
-pcireg_type1_cfg_addr(pcibr_soft_t ptr, uint8_t func, int offset)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	/*
-	 * Return a config space address for the given slot/func/offset.
-	 * Note the returned ptr is a 32bit word (ie. cfg_p) aligned ptr
-	 * pointing to the 32bit word that contains the "offset" byte.
-	 */
-	return &(bridge->p_type1_cfg.f[func].l[(offset / 4)]);
-}
-
-/*
- * Internal ATE SSRAM Access -- Read/Write 
- */
-bridge_ate_t
-pcireg_int_ate_get(pcibr_soft_t ptr, int ate_index)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	ASSERT_ALWAYS((ate_index >= 0) && (ate_index <= 1024));
-	return bridge->p_int_ate_ram[ate_index];
-}
-
-void
-pcireg_int_ate_set(pcibr_soft_t ptr, int ate_index, bridge_ate_t val)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	ASSERT_ALWAYS((ate_index >= 0) && (ate_index <= 1024));
-	bridge->p_int_ate_ram[ate_index] = (picate_t) val;
-}
-
-bridge_ate_p
-pcireg_int_ate_addr(pcibr_soft_t ptr, int ate_index)
-{
-	pic_t *bridge = (pic_t *)ptr->bs_base;
-
-	ASSERT_ALWAYS((ate_index >= 0) && (ate_index <= 1024));
-	return &(bridge->p_int_ate_ram[ate_index]);
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c	2004-12-24 13:37:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,887 +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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-
-void		pcibr_rrb_alloc_init(pcibr_soft_t, int, int, int);
-void		pcibr_rrb_alloc_more(pcibr_soft_t, int, int, int);
-
-int		pcibr_wrb_flush(vertex_hdl_t);
-int		pcibr_rrb_alloc(vertex_hdl_t, int *, int *);
-int		pcibr_rrb_check(vertex_hdl_t, int *, int *, int *, int *);
-int		pcibr_alloc_all_rrbs(vertex_hdl_t, int, int, int, int, 
-			     	     int, int, int, int, int);
-void		pcibr_rrb_flush(vertex_hdl_t);
-int		pcibr_slot_initial_rrb_alloc(vertex_hdl_t,pciio_slot_t);
-
-void            pcibr_rrb_debug(char *, pcibr_soft_t);
-
-
-/*
- * RRB Management
- *
- * All the do_pcibr_rrb_ routines manipulate the Read Response Buffer (rrb)
- * registers within the Bridge.	 Two 32 registers (b_rrb_map[2] also known
- * as the b_even_resp & b_odd_resp registers) are used to allocate the 16
- * rrbs to devices.  The b_even_resp register represents even num devices,
- * and b_odd_resp represent odd number devices.	 Each rrb is represented by
- * 4-bits within a register.
- *   BRIDGE & XBRIDGE:	1 enable bit, 1 virtual channel bit, 2 device bits
- *   PIC:		1 enable bit, 2 virtual channel bits, 1 device bit
- * PIC has 4 devices per bus, and 4 virtual channels (1 normal & 3 virtual)
- * per device.	BRIDGE & XBRIDGE have 8 devices per bus and 2 virtual
- * channels (1 normal & 1 virtual) per device.	See the BRIDGE and PIC ASIC
- * Programmers Reference guides for more information.
- */ 
- 
-#define RRB_MASK (0xf)			/* mask a single rrb within reg */
-#define RRB_SIZE (4)			/* sizeof rrb within reg (bits) */
- 
-#define RRB_ENABLE_BIT		      (0x8)  /* [BRIDGE | PIC]_RRB_EN */
-#define NUM_PDEV_BITS		      (1)
-#define NUMBER_VCHANNELS	      (4)
-#define SLOT_2_PDEV(slot)		((slot) >> 1)
-#define SLOT_2_RRB_REG(slot)  		((slot) & 0x1)
-
-#define RRB_VALID(rrb)		      (0x00010000 << (rrb))
-#define RRB_INUSE(rrb)		      (0x00000001 << (rrb))
-#define RRB_CLEAR(rrb)		      (0x00000001 << (rrb))
- 
-/* validate that the slot and virtual channel are valid */
-#define VALIDATE_SLOT_n_VCHAN(s, v) \
-    (((((s) != PCIIO_SLOT_NONE) && ((s) <= (pciio_slot_t)3)) && \
-      (((v) >= 0) && ((v) <= 3))) ? 1 : 0)
- 
-/*  
- * Count how many RRBs are marked valid for the specified PCI slot
- * and virtual channel.	 Return the count.
- */ 
-static int
-do_pcibr_rrb_count_valid(pcibr_soft_t pcibr_soft,
-			 pciio_slot_t slot,
-			 int vchan)
-{
-    uint64_t tmp;
-    uint16_t enable_bit, vchan_bits, pdev_bits, rrb_bits;
-    int rrb_index, cnt=0;
-
-    if (!VALIDATE_SLOT_n_VCHAN(slot, vchan)) {
-	printk(KERN_WARNING "do_pcibr_rrb_count_valid() invalid slot/vchan [%d/%d]\n", slot, vchan);
-	return 0;
-    }
-    
-    enable_bit = RRB_ENABLE_BIT;
-    vchan_bits = vchan << NUM_PDEV_BITS;
-    pdev_bits = SLOT_2_PDEV(slot);
-    rrb_bits = enable_bit | vchan_bits | pdev_bits;
-    
-    tmp = pcireg_rrb_get(pcibr_soft, SLOT_2_RRB_REG(slot));
-    
-    for (rrb_index = 0; rrb_index < 8; rrb_index++) {
-	if ((tmp & RRB_MASK) == rrb_bits)
-	    cnt++;
-	tmp = (tmp >> RRB_SIZE);
-    }
-    return cnt;
-}
- 
- 
-/*  
- * Count how many RRBs are available to be allocated to the specified
- * slot.  Return the count.
- */ 
-static int
-do_pcibr_rrb_count_avail(pcibr_soft_t pcibr_soft,
-			 pciio_slot_t slot)
-{
-    uint64_t tmp;
-    uint16_t enable_bit;
-    int rrb_index, cnt=0;
-    
-    if (!VALIDATE_SLOT_n_VCHAN(slot, 0)) {
-	printk(KERN_WARNING "do_pcibr_rrb_count_avail() invalid slot/vchan");
-	return 0;
-    }
-    
-    enable_bit = RRB_ENABLE_BIT;
-    
-    tmp = pcireg_rrb_get(pcibr_soft, SLOT_2_RRB_REG(slot));
-    
-    for (rrb_index = 0; rrb_index < 8; rrb_index++) {
-	if ((tmp & enable_bit) != enable_bit)
-	    cnt++;
-	tmp = (tmp >> RRB_SIZE);
-    }
-    return cnt;
-}
- 
- 
-/*  
- * Allocate some additional RRBs for the specified slot and the specified
- * virtual channel.  Returns -1 if there were insufficient free RRBs to
- * satisfy the request, or 0 if the request was fulfilled.
- *
- * Note that if a request can be partially filled, it will be, even if
- * we return failure.
- */ 
-static int
-do_pcibr_rrb_alloc(pcibr_soft_t pcibr_soft,
-		   pciio_slot_t slot,
-		   int vchan,
-		   int more)
-{
-    uint64_t reg, tmp = 0;
-    uint16_t enable_bit, vchan_bits, pdev_bits, rrb_bits;
-    int rrb_index;
-    
-    if (!VALIDATE_SLOT_n_VCHAN(slot, vchan)) {
-	printk(KERN_WARNING "do_pcibr_rrb_alloc() invalid slot/vchan");
-	return -1;
-    }
-    
-    enable_bit = RRB_ENABLE_BIT;
-    vchan_bits = vchan << NUM_PDEV_BITS;
-    pdev_bits = SLOT_2_PDEV(slot);
-    rrb_bits = enable_bit | vchan_bits | pdev_bits;
-    
-    reg = tmp = pcireg_rrb_get(pcibr_soft, SLOT_2_RRB_REG(slot));
-    
-    for (rrb_index = 0; ((rrb_index < 8) && (more > 0)); rrb_index++) {
-	if ((tmp & enable_bit) != enable_bit) {
-	    /* clear the rrb and OR in the new rrb into 'reg' */
-	    reg = reg & ~(RRB_MASK << (RRB_SIZE * rrb_index));
-	    reg = reg | (rrb_bits << (RRB_SIZE * rrb_index));
-	    more--;
-	}
-	tmp = (tmp >> RRB_SIZE);
-    }
-    
-    pcireg_rrb_set(pcibr_soft, SLOT_2_RRB_REG(slot), reg);
-    return (more ? -1 : 0);
-}
- 
-/*
- * Wait for the the specified rrb to have no outstanding XIO pkts
- * and for all data to be drained.  Mark the rrb as no longer being 
- * valid.
- */
-static void
-do_pcibr_rrb_clear(pcibr_soft_t pcibr_soft, int rrb)
-{
-    uint64_t             status;
-
-    /* bridge_lock must be held;  this RRB must be disabled. */
-
-    /* wait until RRB has no outstanduing XIO packets. */
-    status = pcireg_rrb_status_get(pcibr_soft);
-    while (status & RRB_INUSE(rrb)) {
-	status = pcireg_rrb_status_get(pcibr_soft);
-    }
-
-    /* if the RRB has data, drain it. */
-    if (status & RRB_VALID(rrb)) {
-	pcireg_rrb_clear_set(pcibr_soft, RRB_CLEAR(rrb));
-
-	/* wait until RRB is no longer valid. */
-	status = pcireg_rrb_status_get(pcibr_soft);
-	while (status & RRB_VALID(rrb)) {
-	    status = pcireg_rrb_status_get(pcibr_soft);
-	}
-    }
-}
-
- 
-/*  
- * Release some of the RRBs that have been allocated for the specified
- * slot. Returns zero for success, or negative if it was unable to free
- * that many RRBs.
- *
- * Note that if a request can be partially fulfilled, it will be, even
- * if we return failure.
- */ 
-static int
-do_pcibr_rrb_free(pcibr_soft_t pcibr_soft,
-		  pciio_slot_t slot,
-		  int vchan,
-		  int less)
-{
-    uint64_t reg, tmp = 0, clr = 0;
-    uint16_t enable_bit, vchan_bits, pdev_bits, rrb_bits;
-    int rrb_index;
-    
-    if (!VALIDATE_SLOT_n_VCHAN(slot, vchan)) {
-	printk(KERN_WARNING "do_pcibr_rrb_free() invalid slot/vchan");
-	return -1;
-    }
-    
-    enable_bit = RRB_ENABLE_BIT;
-    vchan_bits = vchan << NUM_PDEV_BITS;
-    pdev_bits = SLOT_2_PDEV(slot);
-    rrb_bits = enable_bit | vchan_bits | pdev_bits;
-    
-    reg = tmp = pcireg_rrb_get(pcibr_soft, SLOT_2_RRB_REG(slot));
-    
-    for (rrb_index = 0; ((rrb_index < 8) && (less > 0)); rrb_index++) {
-	if ((tmp & RRB_MASK) == rrb_bits) {
-	   /*
-	    * the old do_pcibr_rrb_free() code only clears the enable bit
-	    * but I say we should clear the whole rrb (ie):
-	    *	  reg = reg & ~(RRB_MASK << (RRB_SIZE * rrb_index));
-	    * But to be compatible with old code we'll only clear enable.
-	    */
-	    reg = reg & ~(RRB_ENABLE_BIT << (RRB_SIZE * rrb_index));
-	    clr = clr | (enable_bit << (RRB_SIZE * rrb_index));
-	    less--;
-	}
-	tmp = (tmp >> RRB_SIZE);
-    }
-    
-    pcireg_rrb_set(pcibr_soft, SLOT_2_RRB_REG(slot), reg);
-    
-    /* call do_pcibr_rrb_clear() for all the rrbs we've freed */
-    for (rrb_index = 0; rrb_index < 8; rrb_index++) {
-	int evn_odd = SLOT_2_RRB_REG(slot);
-	if (clr & (enable_bit << (RRB_SIZE * rrb_index)))
-	    do_pcibr_rrb_clear(pcibr_soft, (2 * rrb_index) + evn_odd);
-    }
-    
-    return (less ? -1 : 0);
-}
- 
-/* 
- * Flush the specified rrb by calling do_pcibr_rrb_clear().  This
- * routine is just a wrapper to make sure the rrb is disabled 
- * before calling do_pcibr_rrb_clear().
- */
-static void
-do_pcibr_rrb_flush(pcibr_soft_t pcibr_soft, int rrbn)
-{
-    uint64_t	rrbv;
-    int		shft = (RRB_SIZE * (rrbn >> 1));
-    uint64_t	ebit = RRB_ENABLE_BIT << shft;
-
-    rrbv = pcireg_rrb_get(pcibr_soft, (rrbn & 1));
-    if (rrbv & ebit) {
-	pcireg_rrb_set(pcibr_soft, (rrbn & 1), (rrbv & ~ebit));
-    }
-
-    do_pcibr_rrb_clear(pcibr_soft, rrbn);
-
-    if (rrbv & ebit) {
-	pcireg_rrb_set(pcibr_soft, (rrbn & 1), rrbv);
-    }
-}
-
-/*  
- * free all the rrbs (both the normal and virtual channels) for the
- * specified slot.
- */ 
-void
-do_pcibr_rrb_free_all(pcibr_soft_t pcibr_soft,
-		      pciio_slot_t slot)
-{
-    int vchan;
-    int vchan_total = NUMBER_VCHANNELS;
-    
-    /* pretend we own all 8 rrbs and just ignore the return value */
-    for (vchan = 0; vchan < vchan_total; vchan++) {
-	    do_pcibr_rrb_free(pcibr_soft, slot, vchan, 8);
-	    pcibr_soft->bs_rrb_valid[slot][vchan] = 0;
-    }
-}
-
-
-/*
- * Initialize a slot with a given number of RRBs.  (this routine
- * will also give back RRBs if the slot has more than we want).
- */
-void
-pcibr_rrb_alloc_init(pcibr_soft_t pcibr_soft,
-		     int slot,
-		     int vchan,
-		     int init_rrbs)
-{
-    int			 had = pcibr_soft->bs_rrb_valid[slot][vchan];
-    int			 have = had;
-    int			 added = 0;
-
-    for (added = 0; have < init_rrbs; ++added, ++have) {
-	if (pcibr_soft->bs_rrb_res[slot] > 0)
-	    pcibr_soft->bs_rrb_res[slot]--;
-	else if (pcibr_soft->bs_rrb_avail[slot & 1] > 0)
-	    pcibr_soft->bs_rrb_avail[slot & 1]--;
-	else
-	    break;
-	if (do_pcibr_rrb_alloc(pcibr_soft, slot, vchan, 1) < 0)
-	    break;
-
-	pcibr_soft->bs_rrb_valid[slot][vchan]++;
-    }
-
-    /* Free any extra RRBs that the slot may have allocated to it */
-    while (have > init_rrbs) {
-	pcibr_soft->bs_rrb_avail[slot & 1]++;
-	pcibr_soft->bs_rrb_valid[slot][vchan]--;
-	do_pcibr_rrb_free(pcibr_soft, slot, vchan, 1);
-	added--;
-	have--;
-    }
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
-		"pcibr_rrb_alloc_init: had %d, added/removed %d, "
-		"(of requested %d) RRBs "
-		"to slot %d, vchan %d\n", had, added, init_rrbs,
-		PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), vchan));
-
-    pcibr_rrb_debug("pcibr_rrb_alloc_init", pcibr_soft);
-}
-
-
-/*
- * Allocate more RRBs to a given slot (if the RRBs are available).
- */
-void
-pcibr_rrb_alloc_more(pcibr_soft_t pcibr_soft,
-		     int slot,
-		     int vchan, 
-		     int more_rrbs)
-{
-    int			 added;
-
-    for (added = 0; added < more_rrbs; ++added) {
-	if (pcibr_soft->bs_rrb_res[slot] > 0)
-	    pcibr_soft->bs_rrb_res[slot]--;
-	else if (pcibr_soft->bs_rrb_avail[slot & 1] > 0)
-	    pcibr_soft->bs_rrb_avail[slot & 1]--;
-	else
-	    break;
-	if (do_pcibr_rrb_alloc(pcibr_soft, slot, vchan, 1) < 0)
-	    break;
-
-	pcibr_soft->bs_rrb_valid[slot][vchan]++;
-    }
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
-		"pcibr_rrb_alloc_more: added %d (of %d requested) RRBs "
-		"to slot %d, vchan %d\n", added, more_rrbs, 
-		PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), vchan));
-
-    pcibr_rrb_debug("pcibr_rrb_alloc_more", pcibr_soft);
-}
-
-
-/*
- * Flush all the rrb's assigned to the specified connection point.
- */
-void
-pcibr_rrb_flush(vertex_hdl_t pconn_vhdl)
-{
-    pciio_info_t  pciio_info = pciio_info_get(pconn_vhdl);
-    pcibr_soft_t  pcibr_soft = (pcibr_soft_t)pciio_info_mfast_get(pciio_info);
-    pciio_slot_t  slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-
-    uint64_t tmp;
-    uint16_t enable_bit, pdev_bits, rrb_bits, rrb_mask;
-    int rrb_index;
-    unsigned long s;
-
-    enable_bit = RRB_ENABLE_BIT;
-    pdev_bits = SLOT_2_PDEV(slot);
-    rrb_bits = enable_bit | pdev_bits;
-    rrb_mask = enable_bit | ((NUM_PDEV_BITS << 1) - 1);
-
-    tmp = pcireg_rrb_get(pcibr_soft, SLOT_2_RRB_REG(slot));
-
-    s = pcibr_lock(pcibr_soft);
-    for (rrb_index = 0; rrb_index < 8; rrb_index++) {
-	int evn_odd = SLOT_2_RRB_REG(slot);
-	if ((tmp & rrb_mask) == rrb_bits)
-	    do_pcibr_rrb_flush(pcibr_soft, (2 * rrb_index) + evn_odd);
-	tmp = (tmp >> RRB_SIZE);
-    }
-    pcibr_unlock(pcibr_soft, s);
-}
-
-
-/*
- * Device driver interface to flush the write buffers for a specified
- * device hanging off the bridge.
- */
-int
-pcibr_wrb_flush(vertex_hdl_t pconn_vhdl)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pciio_slot_t            pciio_slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-
-    pcireg_wrb_flush_get(pcibr_soft, pciio_slot);
-
-    return 0;
-}
-
-/*
- * Device driver interface to request RRBs for a specified device
- * hanging off a Bridge.  The driver requests the total number of
- * RRBs it would like for the normal channel (vchan0) and for the
- * "virtual channel" (vchan1).  The actual number allocated to each
- * channel is returned.
- *
- * If we cannot allocate at least one RRB to a channel that needs
- * at least one, return -1 (failure).  Otherwise, satisfy the request
- * as best we can and return 0.
- */
-int
-pcibr_rrb_alloc(vertex_hdl_t pconn_vhdl,
-		int *count_vchan0,
-		int *count_vchan1)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pciio_slot_t            pciio_slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    int                     desired_vchan0;
-    int                     desired_vchan1;
-    int                     orig_vchan0;
-    int                     orig_vchan1;
-    int                     delta_vchan0;
-    int                     delta_vchan1;
-    int                     final_vchan0;
-    int                     final_vchan1;
-    int                     avail_rrbs;
-    int                     res_rrbs;
-    int			    vchan_total;
-    int			    vchan;
-    unsigned long                s;
-    int                     error;
-
-    /*
-     * TBD: temper request with admin info about RRB allocation,
-     * and according to demand from other devices on this Bridge.
-     *
-     * One way of doing this would be to allocate two RRBs
-     * for each device on the bus, before any drivers start
-     * asking for extras. This has the weakness that one
-     * driver might not give back an "extra" RRB until after
-     * another driver has already failed to get one that
-     * it wanted.
-     */
-
-    s = pcibr_lock(pcibr_soft);
-
-    vchan_total = NUMBER_VCHANNELS;
-
-    /* Save the boot-time RRB configuration for this slot */
-    if (pcibr_soft->bs_rrb_valid_dflt[pciio_slot][VCHAN0] < 0) {
-	for (vchan = 0; vchan < vchan_total; vchan++) 
-	    pcibr_soft->bs_rrb_valid_dflt[pciio_slot][vchan] =
-		    pcibr_soft->bs_rrb_valid[pciio_slot][vchan];
-        pcibr_soft->bs_rrb_res_dflt[pciio_slot] =
-                pcibr_soft->bs_rrb_res[pciio_slot];
-                  
-    }
-
-    /* How many RRBs do we own? */
-    orig_vchan0 = pcibr_soft->bs_rrb_valid[pciio_slot][VCHAN0];
-    orig_vchan1 = pcibr_soft->bs_rrb_valid[pciio_slot][VCHAN1];
-
-    /* How many RRBs do we want? */
-    desired_vchan0 = count_vchan0 ? *count_vchan0 : orig_vchan0;
-    desired_vchan1 = count_vchan1 ? *count_vchan1 : orig_vchan1;
-
-    /* How many RRBs are free? */
-    avail_rrbs = pcibr_soft->bs_rrb_avail[pciio_slot & 1]
-	+ pcibr_soft->bs_rrb_res[pciio_slot];
-
-    /* Figure desired deltas */
-    delta_vchan0 = desired_vchan0 - orig_vchan0;
-    delta_vchan1 = desired_vchan1 - orig_vchan1;
-
-    /* Trim back deltas to something
-     * that we can actually meet, by
-     * decreasing the ending allocation
-     * for whichever channel wants
-     * more RRBs. If both want the same
-     * number, cut the second channel.
-     * NOTE: do not change the allocation for
-     * a channel that was passed as NULL.
-     */
-    while ((delta_vchan0 + delta_vchan1) > avail_rrbs) {
-	if (count_vchan0 &&
-	    (!count_vchan1 ||
-	     ((orig_vchan0 + delta_vchan0) >
-	      (orig_vchan1 + delta_vchan1))))
-	    delta_vchan0--;
-	else
-	    delta_vchan1--;
-    }
-
-    /* Figure final RRB allocations
-     */
-    final_vchan0 = orig_vchan0 + delta_vchan0;
-    final_vchan1 = orig_vchan1 + delta_vchan1;
-
-    /* If either channel wants RRBs but our actions
-     * would leave it with none, declare an error,
-     * but DO NOT change any RRB allocations.
-     */
-    if ((desired_vchan0 && !final_vchan0) ||
-	(desired_vchan1 && !final_vchan1)) {
-
-	error = -1;
-
-    } else {
-
-	/* Commit the allocations: free, then alloc.
-	 */
-	if (delta_vchan0 < 0)
-	    do_pcibr_rrb_free(pcibr_soft, pciio_slot, VCHAN0, -delta_vchan0);
-	if (delta_vchan1 < 0)
-	    do_pcibr_rrb_free(pcibr_soft, pciio_slot, VCHAN1, -delta_vchan1);
-
-	if (delta_vchan0 > 0)
-	    do_pcibr_rrb_alloc(pcibr_soft, pciio_slot, VCHAN0, delta_vchan0);
-	if (delta_vchan1 > 0)
-	    do_pcibr_rrb_alloc(pcibr_soft, pciio_slot, VCHAN1, delta_vchan1);
-
-	/* Return final values to caller.
-	 */
-	if (count_vchan0)
-	    *count_vchan0 = final_vchan0;
-	if (count_vchan1)
-	    *count_vchan1 = final_vchan1;
-
-	/* prevent automatic changes to this slot's RRBs
-	 */
-	pcibr_soft->bs_rrb_fixed |= 1 << pciio_slot;
-
-	/* Track the actual allocations, release
-	 * any further reservations, and update the
-	 * number of available RRBs.
-	 */
-
-	pcibr_soft->bs_rrb_valid[pciio_slot][VCHAN0] = final_vchan0;
-	pcibr_soft->bs_rrb_valid[pciio_slot][VCHAN1] = final_vchan1;
-	pcibr_soft->bs_rrb_avail[pciio_slot & 1] =
-	    pcibr_soft->bs_rrb_avail[pciio_slot & 1]
-	    + pcibr_soft->bs_rrb_res[pciio_slot]
-	    - delta_vchan0
-	    - delta_vchan1;
-	pcibr_soft->bs_rrb_res[pciio_slot] = 0;
-
-        /*
-         * Reserve enough RRBs so this slot's RRB configuration can be
-         * reset to its boot-time default following a hot-plug shut-down
-         */
-	res_rrbs = (pcibr_soft->bs_rrb_res_dflt[pciio_slot] -
-		    pcibr_soft->bs_rrb_res[pciio_slot]);
-	for (vchan = 0; vchan < vchan_total; vchan++) {
-	    res_rrbs += (pcibr_soft->bs_rrb_valid_dflt[pciio_slot][vchan] -
-			 pcibr_soft->bs_rrb_valid[pciio_slot][vchan]);
-	}
-
-	if (res_rrbs > 0) {
-            pcibr_soft->bs_rrb_res[pciio_slot] = res_rrbs;
-            pcibr_soft->bs_rrb_avail[pciio_slot & 1] =
-                pcibr_soft->bs_rrb_avail[pciio_slot & 1]
-                - res_rrbs;
-        }
- 
-	pcibr_rrb_debug("pcibr_rrb_alloc", pcibr_soft);
-
-	error = 0;
-    }
-
-    pcibr_unlock(pcibr_soft, s);
-
-    return error;
-}
-
-/*
- * Device driver interface to check the current state
- * of the RRB allocations.
- *
- *   pconn_vhdl is your PCI connection point (specifies which
- *      PCI bus and which slot).
- *
- *   count_vchan0 points to where to return the number of RRBs
- *      assigned to the primary DMA channel, used by all DMA
- *      that does not explicitly ask for the alternate virtual
- *      channel.
- *
- *   count_vchan1 points to where to return the number of RRBs
- *      assigned to the secondary DMA channel, used when
- *      PCIBR_VCHAN1 and PCIIO_DMA_A64 are specified.
- *
- *   count_reserved points to where to return the number of RRBs
- *      that have been automatically reserved for your device at
- *      startup, but which have not been assigned to a
- *      channel. RRBs must be assigned to a channel to be used;
- *      this can be done either with an explicit pcibr_rrb_alloc
- *      call, or automatically by the infrastructure when a DMA
- *      translation is constructed. Any call to pcibr_rrb_alloc
- *      will release any unassigned reserved RRBs back to the
- *      free pool.
- *
- *   count_pool points to where to return the number of RRBs
- *      that are currently unassigned and unreserved. This
- *      number can (and will) change as other drivers make calls
- *      to pcibr_rrb_alloc, or automatically allocate RRBs for
- *      DMA beyond their initial reservation.
- *
- * NULL may be passed for any of the return value pointers
- * the caller is not interested in.
- *
- * The return value is "0" if all went well, or "-1" if
- * there is a problem. Additionally, if the wrong vertex
- * is passed in, one of the subsidiary support functions
- * could panic with a "bad pciio fingerprint."
- */
-
-int
-pcibr_rrb_check(vertex_hdl_t pconn_vhdl,
-		int *count_vchan0,
-		int *count_vchan1,
-		int *count_reserved,
-		int *count_pool)
-{
-    pciio_info_t            pciio_info;
-    pciio_slot_t            pciio_slot;
-    pcibr_soft_t            pcibr_soft;
-    unsigned long                s;
-    int                     error = -1;
-
-    if ((pciio_info = pciio_info_get(pconn_vhdl)) &&
-	(pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info)) &&
-	((pciio_slot = PCIBR_INFO_SLOT_GET_INT(pciio_info)) < PCIBR_NUM_SLOTS(pcibr_soft))) {
-
-	s = pcibr_lock(pcibr_soft);
-
-	if (count_vchan0)
-	    *count_vchan0 =
-		pcibr_soft->bs_rrb_valid[pciio_slot][VCHAN0];
-
-	if (count_vchan1)
-	    *count_vchan1 =
-		pcibr_soft->bs_rrb_valid[pciio_slot][VCHAN1];
-
-	if (count_reserved)
-	    *count_reserved =
-		pcibr_soft->bs_rrb_res[pciio_slot];
-
-	if (count_pool)
-	    *count_pool =
-		pcibr_soft->bs_rrb_avail[pciio_slot & 1];
-
-	error = 0;
-
-	pcibr_unlock(pcibr_soft, s);
-    }
-    return error;
-}
-
-/*
- * pcibr_slot_initial_rrb_alloc
- *	Allocate a default number of rrbs for this slot on 
- * 	the two channels.  This is dictated by the rrb allocation
- * 	strategy routine defined per platform.
- */
-
-int
-pcibr_slot_initial_rrb_alloc(vertex_hdl_t pcibr_vhdl,
-			     pciio_slot_t slot)
-{
-    pcibr_soft_t	 pcibr_soft;
-    pcibr_info_h	 pcibr_infoh;
-    pcibr_info_t	 pcibr_info;
-    int 		 vchan_total;
-    int			 vchan;
-    int                  chan[4];
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    if (!pcibr_soft)
-	return -EINVAL;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    /* How many RRBs are on this slot? */
-    vchan_total = NUMBER_VCHANNELS;
-    for (vchan = 0; vchan < vchan_total; vchan++) 
-        chan[vchan] = do_pcibr_rrb_count_valid(pcibr_soft, slot, vchan);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_vhdl,
-	    "pcibr_slot_initial_rrb_alloc: slot %d started with %d+%d+%d+%d\n",
-	    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), 
-	    chan[VCHAN0], chan[VCHAN1], chan[VCHAN2], chan[VCHAN3]));
-
-    /* Do we really need any?
-     */
-    pcibr_infoh = pcibr_soft->bs_slot[slot].bss_infos;
-    pcibr_info = pcibr_infoh[0];
-    /*
-     * PIC BRINGUP WAR (PV# 856866, 859504, 861476, 861478):
-     * Don't free RRBs we allocated to device[2|3]--vchan3 as
-     * a WAR to those PVs mentioned above.  In pcibr_attach2
-     * we allocate RRB0,8,1,9 to device[2|3]--vchan3.
-     */
-    if (PCIBR_WAR_ENABLED(PV856866, pcibr_soft) && 
-			(slot == 2 || slot == 3) &&
-        		(pcibr_info->f_vendor == PCIIO_VENDOR_ID_NONE) &&
-        		!pcibr_soft->bs_slot[slot].has_host) {
-
-	for (vchan = 0; vchan < 2; vchan++) {
-	    do_pcibr_rrb_free(pcibr_soft, slot, vchan, 8);
-	    pcibr_soft->bs_rrb_valid[slot][vchan] = 0;
-	}
-
-        pcibr_soft->bs_rrb_valid[slot][3] = chan[3];
-
-        return -ENODEV;
-    }
-
-    if ((pcibr_info->f_vendor == PCIIO_VENDOR_ID_NONE) &&
-	!pcibr_soft->bs_slot[slot].has_host) {
-	do_pcibr_rrb_free_all(pcibr_soft, slot);
-        
-	/* Reserve RRBs for this empty slot for hot-plug */
-	for (vchan = 0; vchan < vchan_total; vchan++) 
-	    pcibr_soft->bs_rrb_valid[slot][vchan] = 0;
-
-	return -ENODEV;
-    }
-
-    for (vchan = 0; vchan < vchan_total; vchan++)
-        pcibr_soft->bs_rrb_valid[slot][vchan] = chan[vchan];
-
-    return 0;
-}
-
-
-/*
- * pcibr_initial_rrb
- *      Assign an equal total number of RRBs to all candidate slots, 
- *      where the total is the sum of the number of RRBs assigned to
- *      the normal channel, the number of RRBs assigned to the virtual
- *      channels, and the number of RRBs assigned as reserved. 
- *
- *      A candidate slot is any existing (populated or empty) slot.
- *      Empty SN1 slots need RRBs to support hot-plug operations.
- */
-
-int
-pcibr_initial_rrb(vertex_hdl_t pcibr_vhdl,
-			     pciio_slot_t first, pciio_slot_t last)
-{
-    pcibr_soft_t            pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    pciio_slot_t            slot;
-    int			    rrb_total;
-    int			    vchan_total;
-    int			    vchan;
-    int                     have[2][3];
-    int                     res[2];
-    int                     eo;
-
-    have[0][0] = have[0][1] = have[0][2] = 0;
-    have[1][0] = have[1][1] = have[1][2] = 0;
-    res[0] = res[1] = 0;
-
-    vchan_total = NUMBER_VCHANNELS;
-
-    for (slot = pcibr_soft->bs_min_slot; 
-			slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-        /* Initial RRB management; give back RRBs in all non-existent slots */
-        pcibr_slot_initial_rrb_alloc(pcibr_vhdl, slot);
-
-        /* Base calculations only on existing slots */
-        if ((slot >= first) && (slot <= last)) {
-	    rrb_total = 0;
-	    for (vchan = 0; vchan < vchan_total; vchan++) 
-		rrb_total += pcibr_soft->bs_rrb_valid[slot][vchan];
-
-            if (rrb_total < 3)
-                have[slot & 1][rrb_total]++;
-        }
-    }
-
-    /* Initialize even/odd slot available RRB counts */
-    pcibr_soft->bs_rrb_avail[0] = do_pcibr_rrb_count_avail(pcibr_soft, 0);
-    pcibr_soft->bs_rrb_avail[1] = do_pcibr_rrb_count_avail(pcibr_soft, 1);
-
-    /*
-     * Calculate reserved RRBs for slots based on current RRB usage
-     */
-    for (eo = 0; eo < 2; eo++) {
-        if ((3 * have[eo][0] + 2 * have[eo][1] + have[eo][2]) <= pcibr_soft->bs_rrb_avail[eo])
-            res[eo] = 3;
-        else if ((2 * have[eo][0] + have[eo][1]) <= pcibr_soft->bs_rrb_avail[eo])
-            res[eo] = 2;
-        else if (have[eo][0] <= pcibr_soft->bs_rrb_avail[eo])
-            res[eo] = 1;
-        else
-            res[eo] = 0;
-
-    }
-
-    /* Assign reserved RRBs to existing slots */
-    for (slot = first; slot <= last; ++slot) {
-        int                     r;
-
-	if (pcibr_soft->bs_unused_slot & (1 << slot))
-	    continue;
-
-	rrb_total = 0;
-	for (vchan = 0; vchan < vchan_total; vchan++)
-		rrb_total += pcibr_soft->bs_rrb_valid[slot][vchan];
-
-        r = res[slot & 1] - (rrb_total);
-
-        if (r > 0) {
-            pcibr_soft->bs_rrb_res[slot] = r;
-            pcibr_soft->bs_rrb_avail[slot & 1] -= r;
-        }
-    }
-
-    pcibr_rrb_debug("pcibr_initial_rrb", pcibr_soft);
-
-    return 0;
-
-}
-
-/*
- * Dump the pcibr_soft_t RRB state variable
- */
-void
-pcibr_rrb_debug(char *calling_func, pcibr_soft_t pcibr_soft)
-{
-    pciio_slot_t slot;
-    
-    if (pcibr_debug_mask & PCIBR_DEBUG_RRB) {
-        PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
-                    "%s: rrbs available, even=%d, odd=%d\n", calling_func,
-                    pcibr_soft->bs_rrb_avail[0], pcibr_soft->bs_rrb_avail[1]));
-
-        PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
-                    "\tslot\tvchan0\tvchan1\tvchan2\tvchan3\treserved\n"));
-
-        for (slot=0; slot < PCIBR_NUM_SLOTS(pcibr_soft); slot++) {
-            PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
-		    "\t %d\t  %d\t  %d\t  %d\t  %d\t  %d\n",
-		    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot),
-		    0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN0],
-		    0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN1],
-		    0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN2],
-		    0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN3],
-		    pcibr_soft->bs_rrb_res[slot]));
-        }
-    }
-}
diff -Nru a/arch/ia64/sn/io/sn2/pcibr/pcibr_slot.c b/arch/ia64/sn/io/sn2/pcibr/pcibr_slot.c
--- a/arch/ia64/sn/io/sn2/pcibr/pcibr_slot.c	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1842 +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) 2001-2004 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/uaccess.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/sn_sal.h>
-
-extern pcibr_info_t     pcibr_info_get(vertex_hdl_t);
-extern int              pcibr_widget_to_bus(vertex_hdl_t pcibr_vhdl);
-extern pcibr_info_t     pcibr_device_info_new(pcibr_soft_t, pciio_slot_t, pciio_function_t, pciio_vendor_id_t, pciio_device_id_t);
-extern int		pcibr_slot_initial_rrb_alloc(vertex_hdl_t,pciio_slot_t);
-extern int		pcibr_pcix_rbars_calc(pcibr_soft_t);
-
-extern char *pci_space[];
-
-int pcibr_slot_info_init(vertex_hdl_t pcibr_vhdl, pciio_slot_t slot);
-int pcibr_slot_info_free(vertex_hdl_t pcibr_vhdl, pciio_slot_t slot);
-int pcibr_slot_addr_space_init(vertex_hdl_t pcibr_vhdl,  pciio_slot_t slot);
-int pcibr_slot_pcix_rbar_init(pcibr_soft_t pcibr_soft,  pciio_slot_t slot);
-int pcibr_slot_device_init(vertex_hdl_t pcibr_vhdl,  pciio_slot_t slot);
-int pcibr_slot_guest_info_init(vertex_hdl_t pcibr_vhdl,  pciio_slot_t slot);
-int pcibr_slot_call_device_attach(vertex_hdl_t pcibr_vhdl,
-		 pciio_slot_t slot, int drv_flags);
-int pcibr_slot_call_device_detach(vertex_hdl_t pcibr_vhdl,
-		 pciio_slot_t slot, int drv_flags);
-int pcibr_slot_detach(vertex_hdl_t pcibr_vhdl, pciio_slot_t slot,
-                 int drv_flags, char *l1_msg, int *sub_errorp);
-static int pcibr_probe_slot(pcibr_soft_t, cfg_p, unsigned int *);
-static int pcibr_probe_work(pcibr_soft_t pcibr_soft, void *addr, int len, void *valp);
-void pcibr_device_info_free(vertex_hdl_t, pciio_slot_t);
-iopaddr_t pcibr_bus_addr_alloc(pcibr_soft_t, pciio_win_info_t, 
-                               pciio_space_t, int, int, int);
-void pcibr_bus_addr_free(pciio_win_info_t);
-cfg_p pcibr_find_capability(cfg_p, unsigned);
-extern uint64_t  do_pcibr_config_get(cfg_p, unsigned, unsigned);
-void do_pcibr_config_set(cfg_p, unsigned, unsigned, uint64_t); 
-int pcibr_slot_pwr(vertex_hdl_t pcibr_vhdl, pciio_slot_t slot, int up, char *err_msg);
-
-
-/* 
- * PCI-X Max Outstanding Split Transactions translation array and Max Memory
- * Read Byte Count translation array, as defined in the PCI-X Specification.
- * Section 7.2.3 & 7.2.4 of PCI-X Specification - rev 1.0
- */
-#define MAX_SPLIT_TABLE 8
-#define MAX_READCNT_TABLE 4
-int max_splittrans_to_numbuf[MAX_SPLIT_TABLE] = {1, 2, 3, 4, 8, 12, 16, 32};
-int max_readcount_to_bufsize[MAX_READCNT_TABLE] = {512, 1024, 2048, 4096 };
-
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-
-/*
- * PCI slot manipulation errors from the system controller, and their
- * associated descriptions
- */
-#define SYSCTL_REQERR_BASE	(-106000)
-#define SYSCTL_PCI_ERROR_BASE	(SYSCTL_REQERR_BASE - 100)
-#define SYSCTL_PCIX_ERROR_BASE	(SYSCTL_REQERR_BASE - 3000)
-
-struct sysctl_pci_error_s {
-
-    int	 	error;
-    char	*msg;
-
-} sysctl_pci_errors[] = {
-
-#define SYSCTL_PCI_UNINITIALIZED	(SYSCTL_PCI_ERROR_BASE - 0)
-    { SYSCTL_PCI_UNINITIALIZED, "module not initialized" },
-
-#define SYSCTL_PCI_UNSUPPORTED_BUS	(SYSCTL_PCI_ERROR_BASE - 1)
-    { SYSCTL_PCI_UNSUPPORTED_BUS, "unsupported bus" },
-
-#define SYSCTL_PCI_UNSUPPORTED_SLOT	(SYSCTL_PCI_ERROR_BASE - 2)
-    { SYSCTL_PCI_UNSUPPORTED_SLOT, "unsupported slot" },
-
-#define SYSCTL_PCI_POWER_NOT_OKAY	(SYSCTL_PCI_ERROR_BASE - 3)
-    { SYSCTL_PCI_POWER_NOT_OKAY, "slot power not okay" },
-
-#define SYSCTL_PCI_CARD_NOT_PRESENT	(SYSCTL_PCI_ERROR_BASE - 4)
-    { SYSCTL_PCI_CARD_NOT_PRESENT, "card not present" },
-
-#define SYSCTL_PCI_POWER_LIMIT		(SYSCTL_PCI_ERROR_BASE - 5)
-    { SYSCTL_PCI_POWER_LIMIT, "power limit reached - some cards not powered up" },
-
-#define SYSCTL_PCI_33MHZ_ON_66MHZ	(SYSCTL_PCI_ERROR_BASE - 6)
-    { SYSCTL_PCI_33MHZ_ON_66MHZ, "cannot add a 33 MHz card to an active 66 MHz bus" },
-
-#define SYSCTL_PCI_INVALID_ORDER	(SYSCTL_PCI_ERROR_BASE - 7)
-    { SYSCTL_PCI_INVALID_ORDER, "invalid reset order" },
-
-#define SYSCTL_PCI_DOWN_33MHZ		(SYSCTL_PCI_ERROR_BASE - 8)
-    { SYSCTL_PCI_DOWN_33MHZ, "cannot power down a 33 MHz card on an active bus" },
-
-#define SYSCTL_PCI_RESET_33MHZ		(SYSCTL_PCI_ERROR_BASE - 9)
-    { SYSCTL_PCI_RESET_33MHZ, "cannot reset a 33 MHz card on an active bus" },
-
-#define SYSCTL_PCI_SLOT_NOT_UP		(SYSCTL_PCI_ERROR_BASE - 10)
-    { SYSCTL_PCI_SLOT_NOT_UP, "cannot reset a slot that is not powered up" },
-
-#define SYSCTL_PCIX_UNINITIALIZED	(SYSCTL_PCIX_ERROR_BASE - 0)
-    { SYSCTL_PCIX_UNINITIALIZED, "module not initialized" },
-
-#define SYSCTL_PCIX_UNSUPPORTED_BUS	(SYSCTL_PCIX_ERROR_BASE - 1)
-    { SYSCTL_PCIX_UNSUPPORTED_BUS, "unsupported bus" },
-
-#define SYSCTL_PCIX_UNSUPPORTED_SLOT	(SYSCTL_PCIX_ERROR_BASE - 2)
-    { SYSCTL_PCIX_UNSUPPORTED_SLOT, "unsupported slot" },
-
-#define SYSCTL_PCIX_POWER_NOT_OKAY	(SYSCTL_PCIX_ERROR_BASE - 3)
-    { SYSCTL_PCIX_POWER_NOT_OKAY, "slot power not okay" },
-
-#define SYSCTL_PCIX_CARD_NOT_PRESENT	(SYSCTL_PCIX_ERROR_BASE - 4)
-    { SYSCTL_PCIX_CARD_NOT_PRESENT, "card not present" },
-
-#define SYSCTL_PCIX_POWER_LIMIT		(SYSCTL_PCIX_ERROR_BASE - 5)
-    { SYSCTL_PCIX_POWER_LIMIT, "power limit reached - some cards not powered up" },
-
-#define SYSCTL_PCIX_33MHZ_ON_66MHZ	(SYSCTL_PCIX_ERROR_BASE - 6)
-    { SYSCTL_PCIX_33MHZ_ON_66MHZ, "cannot add a 33 MHz card to an active 66 MHz bus" },
-
-#define SYSCTL_PCIX_PCI_ON_PCIX		(SYSCTL_PCIX_ERROR_BASE - 7)
-    { SYSCTL_PCIX_PCI_ON_PCIX, "cannot add a PCI card to an active PCIX bus" },
-
-#define SYSCTL_PCIX_ANYTHING_ON_133MHZ		(SYSCTL_PCIX_ERROR_BASE - 8)
-    { SYSCTL_PCIX_ANYTHING_ON_133MHZ, "cannot add any card to an active 133MHz PCIX bus" },
-
-#define SYSCTL_PCIX_X66MHZ_ON_X100MHZ		(SYSCTL_PCIX_ERROR_BASE - 9)
-    { SYSCTL_PCIX_X66MHZ_ON_X100MHZ, "cannot add a PCIX 66MHz card to an active 100MHz PCIX bus" },
-
-#define SYSCTL_PCIX_INVALID_ORDER	(SYSCTL_PCIX_ERROR_BASE - 10)
-    { SYSCTL_PCIX_INVALID_ORDER, "invalid reset order" },
-
-#define SYSCTL_PCIX_DOWN_33MHZ		(SYSCTL_PCIX_ERROR_BASE - 11)
-    { SYSCTL_PCIX_DOWN_33MHZ, "cannot power down a 33 MHz card on an active bus" },
-
-#define SYSCTL_PCIX_RESET_33MHZ		(SYSCTL_PCIX_ERROR_BASE - 12)
-    { SYSCTL_PCIX_RESET_33MHZ, "cannot reset a 33 MHz card on an active bus" },
-
-#define SYSCTL_PCIX_SLOT_NOT_UP		(SYSCTL_PCIX_ERROR_BASE - 13)
-    { SYSCTL_PCIX_SLOT_NOT_UP, "cannot reset a slot that is not powered up" },
-
-#define SYSCTL_PCIX_INVALID_BUS_SETTING	(SYSCTL_PCIX_ERROR_BASE - 14)
-    { SYSCTL_PCIX_INVALID_BUS_SETTING, "invalid bus type/speed selection (PCIX<66MHz, PCI>66MHz)" },
-
-#define SYSCTL_PCIX_INVALID_DEPENDENT_SLOT (SYSCTL_PCIX_ERROR_BASE - 15)
-    { SYSCTL_PCIX_INVALID_DEPENDENT_SLOT, "invalid dependent slot in PCI slot configuration" },
-
-#define SYSCTL_PCIX_SHARED_IDSELECT	(SYSCTL_PCIX_ERROR_BASE - 16)
-    { SYSCTL_PCIX_SHARED_IDSELECT, "cannot enable two slots sharing the same IDSELECT" },
-
-#define SYSCTL_PCIX_SLOT_DISABLED	(SYSCTL_PCIX_ERROR_BASE - 17)
-    { SYSCTL_PCIX_SLOT_DISABLED, "slot is disabled" },
-
-}; /* end sysctl_pci_errors[] */
-
-/*
- * look up an error message for PCI operations that fail
- */
-static void
-sysctl_pci_error_lookup(int error, char *err_msg)
-{
-    int i;
-    struct sysctl_pci_error_s *e = sysctl_pci_errors;
-    
-    for (i = 0; 
-	 i < (sizeof(sysctl_pci_errors) / sizeof(*e));
-	 i++, e++ )
-    {
-	if (e->error == error)
-	{
-	    strcpy(err_msg, e->msg);
-	    return;
-	}
-    }
-
-    sprintf(err_msg, "unrecognized PCI error type");
-}
-
-/*
- * pcibr_slot_attach
- *	This is a place holder routine to keep track of all the
- *	slot-specific initialization that needs to be done.
- *	This is usually called when we want to initialize a new
- * 	PCI card on the bus.
- */
-int
-pcibr_slot_attach(vertex_hdl_t pcibr_vhdl,
-		  pciio_slot_t slot,
-		  int          drv_flags,
-		  char        *l1_msg,
-                  int         *sub_errorp)
-{
-    pcibr_soft_t  pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    int		  error;
-
-    if (!(pcibr_soft->bs_slot[slot].slot_status & PCI_SLOT_POWER_ON)) {
-	uint64_t speed;
-	uint64_t mode;
-
-        /* Power-up the slot */
-        error = pcibr_slot_pwr(pcibr_vhdl, slot, PCI_REQ_SLOT_POWER_ON, l1_msg);
-
-        if (error) {
-            if (sub_errorp)
-                *sub_errorp = error;
-            return(PCI_L1_ERR);
-        } else {
-            pcibr_soft->bs_slot[slot].slot_status &= ~PCI_SLOT_POWER_MASK;
-            pcibr_soft->bs_slot[slot].slot_status |= PCI_SLOT_POWER_ON;
-        }
-
-	/* The speed/mode of the bus may have changed due to the hotplug */
-	speed = pcireg_speed_get(pcibr_soft);
-	mode = pcireg_mode_get(pcibr_soft);
-	pcibr_soft->bs_bridge_mode = ((speed << 1) | mode);
-
-        /*
-         * Allow cards like the Alteon Gigabit Ethernet Adapter to complete
-         * on-card initialization following the slot reset
-         */
-        set_current_state (TASK_INTERRUPTIBLE);
-        schedule_timeout (HZ);
-
-        /* Find out what is out there */
-        error = pcibr_slot_info_init(pcibr_vhdl, slot);
-
-        if (error) {
-            if (sub_errorp)
-                *sub_errorp = error;
-            return(PCI_SLOT_INFO_INIT_ERR);
-        }
-
-        /* Set up the address space for this slot in the PCI land */
-
-        error = pcibr_slot_addr_space_init(pcibr_vhdl, slot);
-
-        if (error) {
-            if (sub_errorp)
-                *sub_errorp = error;
-            return(PCI_SLOT_ADDR_INIT_ERR);
-        }
-
-	/* Allocate the PCI-X Read Buffer Attribute Registers (RBARs)*/
-	if (IS_PCIX(pcibr_soft)) {
-	    int tmp_slot;
-
-	    /* Recalculate the RBARs for all the devices on the bus.  Only
-	     * return an error if we error for the given 'slot'
-	     */
-	    pcibr_soft->bs_pcix_rbar_inuse = 0;
-	    pcibr_soft->bs_pcix_rbar_avail = NUM_RBAR;
-	    pcibr_soft->bs_pcix_rbar_percent_allowed = 
-					pcibr_pcix_rbars_calc(pcibr_soft);
-	    for (tmp_slot = pcibr_soft->bs_min_slot;
-			tmp_slot < PCIBR_NUM_SLOTS(pcibr_soft); ++tmp_slot) {
-		if (tmp_slot == slot)
-		    continue;	/* skip this 'slot', we do it below */
-                (void)pcibr_slot_pcix_rbar_init(pcibr_soft, tmp_slot);
-	    }
-
-	    error = pcibr_slot_pcix_rbar_init(pcibr_soft, slot);
-	    if (error) {
-		if (sub_errorp)
-		    *sub_errorp = error;
-		return(PCI_SLOT_RBAR_ALLOC_ERR);
-	    }
-	}
-
-        /* Setup the device register */
-        error = pcibr_slot_device_init(pcibr_vhdl, slot);
-
-        if (error) {
-            if (sub_errorp)
-                *sub_errorp = error;
-            return(PCI_SLOT_DEV_INIT_ERR);
-        }
-
-        /* Setup host/guest relations */
-        error = pcibr_slot_guest_info_init(pcibr_vhdl, slot);
-
-        if (error) {
-            if (sub_errorp)
-                *sub_errorp = error;
-            return(PCI_SLOT_GUEST_INIT_ERR);
-        }
-
-        /* Initial RRB management */
-        error = pcibr_slot_initial_rrb_alloc(pcibr_vhdl, slot);
-
-        if (error) {
-            if (sub_errorp)
-                *sub_errorp = error;
-            return(PCI_SLOT_RRB_ALLOC_ERR);
-        }
-
-    }
-
-    /* Call the device attach */
-    error = pcibr_slot_call_device_attach(pcibr_vhdl, slot, drv_flags);
-
-    if (error) {
-        if (sub_errorp)
-            *sub_errorp = error;
-        if (error == EUNATCH)
-            return(PCI_NO_DRIVER);
-        else
-            return(PCI_SLOT_DRV_ATTACH_ERR);
-    }
-
-    return(0);
-}
-
-/*
- * pcibr_slot_enable
- *	Enable the PCI slot for a hot-plug insert.
- */
-int
-pcibr_slot_enable(vertex_hdl_t pcibr_vhdl, struct pcibr_slot_enable_req_s *req_p)
-{
-    pcibr_soft_t                   pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    pciio_slot_t                   slot = req_p->req_device;
-    int                            error = 0;
-
-    /* Make sure that we are dealing with a bridge device vertex */
-    if (!pcibr_soft) {
-        return(PCI_NOT_A_BRIDGE);
-    }
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HOTPLUG, pcibr_vhdl,
-                "pcibr_slot_enable: pcibr_soft=0x%lx, slot=%d, req_p=0x%lx\n",
-                pcibr_soft, slot, req_p));
-
-    /* Check for the valid slot */
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-        return(PCI_NOT_A_SLOT);
-
-    if (pcibr_soft->bs_slot[slot].slot_status & PCI_SLOT_ENABLE_CMPLT) {
-        error = PCI_SLOT_ALREADY_UP;
-        goto enable_unlock;
-    }
-
-    error = pcibr_slot_attach(pcibr_vhdl, slot, 0,
-                              req_p->req_resp.resp_l1_msg,
-			      &req_p->req_resp.resp_sub_errno);
-
-    req_p->req_resp.resp_l1_msg[PCI_L1_QSIZE] = '\0';
-
-    enable_unlock:
-
-    return(error);
-}
-
-/*
- * pcibr_slot_disable
- *	Disable the PCI slot for a hot-plug removal.
- */
-int
-pcibr_slot_disable(vertex_hdl_t pcibr_vhdl, struct pcibr_slot_disable_req_s *req_p)
-{
-    pcibr_soft_t                   pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    pciio_slot_t                   slot = req_p->req_device;
-    int                            error = 0;
-    pciio_slot_t                   tmp_slot;
-
-    /* Make sure that we are dealing with a bridge device vertex */
-    if (!pcibr_soft) {
-        return(PCI_NOT_A_BRIDGE);
-    }
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HOTPLUG, pcibr_vhdl,
-                "pcibr_slot_disable: pcibr_soft=0x%lx, slot=%d, req_p=0x%lx\n",
-                pcibr_soft, slot, req_p));
-
-    /* Check for valid slot */
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-        return(PCI_NOT_A_SLOT);
-
-    if ((pcibr_soft->bs_slot[slot].slot_status & PCI_SLOT_DISABLE_CMPLT) ||
-       ((pcibr_soft->bs_slot[slot].slot_status & PCI_SLOT_STATUS_MASK) == 0)) {
-        error = PCI_SLOT_ALREADY_DOWN;
-        /*
-         * RJR - Should we invoke an L1 slot power-down command just in case
-         *       a previous shut-down failed to power-down the slot?
-         */
-        goto disable_unlock;
-    }
-
-    /* Do not allow the last 33 MHz card to be removed */
-    if (IS_33MHZ(pcibr_soft)) {
-        for (tmp_slot = pcibr_soft->bs_first_slot;
-             tmp_slot <= pcibr_soft->bs_last_slot; tmp_slot++)
-            if (tmp_slot != slot)
-                if (pcibr_soft->bs_slot[tmp_slot].slot_status & PCI_SLOT_POWER_ON) {
-                    error++;
-                    break;
-                }
-        if (!error) {
-            error = PCI_EMPTY_33MHZ;
-            goto disable_unlock;
-        }
-    }
-
-    if (req_p->req_action == PCI_REQ_SLOT_ELIGIBLE)
-	return(0);
-
-    error = pcibr_slot_detach(pcibr_vhdl, slot, 1,
-                              req_p->req_resp.resp_l1_msg,
-			      &req_p->req_resp.resp_sub_errno);
-
-    req_p->req_resp.resp_l1_msg[PCI_L1_QSIZE] = '\0';
-
-    disable_unlock:
-
-    return(error);
-}
-
-/*
- * pcibr_slot_pwr
- *      Power-up or power-down a PCI slot.  This routines makes calls to
- *      the L1 system controller driver which requires "external" slot#.
- */
-int
-pcibr_slot_pwr(vertex_hdl_t pcibr_vhdl,
-               pciio_slot_t slot,
-               int          up,
-	       char        *err_msg)
-{
-    pcibr_soft_t        pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    nasid_t             nasid;
-    u64			connection_type;
-    int			rv;
-
-    nasid = NASID_GET(pcibr_soft->bs_base);
-    connection_type = SAL_SYSCTL_IO_XTALK;
-
-    rv = (int) ia64_sn_sysctl_iobrick_pci_op
-	(nasid,
-	 connection_type,
-	 (u64) pcibr_widget_to_bus(pcibr_vhdl),
-	 PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot),
-	 (up ? SAL_SYSCTL_PCI_POWER_UP : SAL_SYSCTL_PCI_POWER_DOWN));
-
-    if (!rv) {
-	/* everything's okay; no error message */
-	*err_msg = '\0';
-    }
-    else {
-	/* there was a problem; look up an appropriate error message */
-	sysctl_pci_error_lookup(rv, err_msg);
-    }
-    return rv;
-}
-
-#endif /* CONFIG_HOTPLUG_PCI_SGI */
-
-/*
- * pcibr_slot_info_init
- *	Probe for this slot and see if it is populated.
- *	If it is populated initialize the generic PCI infrastructural
- * 	information associated with this particular PCI device.
- */
-int
-pcibr_slot_info_init(vertex_hdl_t 	pcibr_vhdl,
-		     pciio_slot_t 	slot)
-{
-    pcibr_soft_t	    pcibr_soft;
-    pcibr_info_h	    pcibr_infoh;
-    pcibr_info_t	    pcibr_info;
-    cfg_p                   cfgw;
-    unsigned                idword;
-    unsigned                pfail;
-    unsigned                idwords[8];
-    pciio_vendor_id_t       vendor;
-    pciio_device_id_t       device;
-    unsigned                htype;
-    unsigned                lt_time;
-    int                     nbars;
-    cfg_p                   wptr;
-    cfg_p                   pcix_cap;
-    int                     win;
-    pciio_space_t           space;
-    int			    nfunc;
-    pciio_function_t	    rfunc;
-    int			    func;
-    vertex_hdl_t	    conn_vhdl;
-    pcibr_soft_slot_t	    slotp;
-    uint64_t		    device_reg;
-
-    /* Get the basic software information required to proceed */
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    if (!pcibr_soft)
-	return -EINVAL;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    /* If we have a host slot (eg:- IOC3 has 2 PCI slots and the initialization
-     * is done by the host slot then we are done.
-     */
-    if (pcibr_soft->bs_slot[slot].has_host) {
-	return 0;
-    }
-
-    /* Try to read the device-id/vendor-id from the config space */
-    cfgw = pcibr_slot_config_addr(pcibr_soft, slot, 0);
-
-    if (pcibr_probe_slot(pcibr_soft, cfgw, &idword)) 
-	return -ENODEV;
-
-    slotp = &pcibr_soft->bs_slot[slot];
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-    slotp->slot_status |= SLOT_POWER_UP;
-#endif
-
-    vendor = 0xFFFF & idword;
-    device = 0xFFFF & (idword >> 16);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PROBE, pcibr_vhdl,
-		"pcibr_slot_info_init: slot=%d, vendor=0x%x, device=0x%x\n",
-		PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), vendor, device));
-
-    /* If the vendor id is not valid then the slot is not populated
-     * and we are done.
-     */
-    if (vendor == 0xFFFF) 
-	return -ENODEV;
-    
-    htype = do_pcibr_config_get(cfgw, PCI_CFG_HEADER_TYPE, 1);
-    nfunc = 1;
-    rfunc = PCIIO_FUNC_NONE;
-    pfail = 0;
-
-    /* NOTE: if a card claims to be multifunction
-     * but only responds to config space 0, treat
-     * it as a unifunction card.
-     */
-
-    if (htype & 0x80) {		/* MULTIFUNCTION */
-	for (func = 1; func < 8; ++func) {
-	    cfgw = pcibr_func_config_addr(pcibr_soft, 0, slot, func, 0);
-	    if (pcibr_probe_slot(pcibr_soft, cfgw, &idwords[func])) {
-		pfail |= 1 << func;
-		continue;
-	    }
-	    vendor = 0xFFFF & idwords[func];
-	    if (vendor == 0xFFFF) {
-		pfail |= 1 << func;
-		continue;
-	    }
-	    nfunc = func + 1;
-	    rfunc = 0;
-	}
-        cfgw = pcibr_slot_config_addr(pcibr_soft, slot, 0);
-    }
-    pcibr_infoh = kmalloc(nfunc*sizeof (*(pcibr_infoh)), GFP_KERNEL);
-    if ( !pcibr_infoh ) {
-	return -ENOMEM;
-    }
-    memset(pcibr_infoh, 0, nfunc*sizeof (*(pcibr_infoh)));
-    
-    pcibr_soft->bs_slot[slot].bss_ninfo = nfunc;
-    pcibr_soft->bs_slot[slot].bss_infos = pcibr_infoh;
-
-    for (func = 0; func < nfunc; ++func) {
-	unsigned                cmd_reg;
-	
-	if (func) {
-	    if (pfail & (1 << func))
-		continue;
-	    
-	    idword = idwords[func];
-	    cfgw = pcibr_func_config_addr(pcibr_soft, 0, slot, func, 0);
-	    
-	    device = 0xFFFF & (idword >> 16);
-	    htype = do_pcibr_config_get(cfgw, PCI_CFG_HEADER_TYPE, 1);
-	    rfunc = func;
-	}
-	htype &= 0x7f;
-	if (htype != 0x00) {
-	    printk(KERN_WARNING 
-		"%s pcibr: pci slot %d func %d has strange header type 0x%x\n",
-		    pcibr_soft->bs_name, slot, func, htype);
-	    nbars = 2;
-	} else {
-	    nbars = PCI_CFG_BASE_ADDRS;
-	}
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_CONFIG, pcibr_vhdl,
-                "pcibr_slot_info_init: slot=%d, func=%d, cfgw=0x%lx\n",
-		PCIBR_DEVICE_TO_SLOT(pcibr_soft,slot), func, cfgw));
-
-	/* 
-	 * If the latency timer has already been set, by prom or by the
-	 * card itself, use that value.  Otherwise look at the device's
-	 * 'min_gnt' and attempt to calculate a latency time. 
-	 *
-	 * NOTE: For now if the device is on the 'real time' arbitration
-	 * ring we don't set the latency timer.  
-	 *
-	 * WAR: SGI's IOC3 and RAD devices target abort if you write a 
-	 * single byte into their config space.  So don't set the Latency
-	 * Timer for these devices
-	 */
-
-	lt_time = do_pcibr_config_get(cfgw, PCI_CFG_LATENCY_TIMER, 1);
-	device_reg = pcireg_device_get(pcibr_soft, slot);
-	if ((lt_time == 0) && !(device_reg & BRIDGE_DEV_RT)) {
-	     unsigned	min_gnt;
-	     unsigned	min_gnt_mult;
-	    
-	    /* 'min_gnt' indicates how long of a burst period a device
-	     * needs in increments of 250ns.  But latency timer is in
-	     * PCI clock cycles, so a conversion is needed.
-	     */
-	    min_gnt = do_pcibr_config_get(cfgw, PCI_MIN_GNT, 1);
-
-	    if (IS_133MHZ(pcibr_soft))
-		min_gnt_mult = 32;	/* 250ns @ 133MHz in clocks */
-	    else if (IS_100MHZ(pcibr_soft))
-		min_gnt_mult = 24;	/* 250ns @ 100MHz in clocks */
-	    else if (IS_66MHZ(pcibr_soft))
-		min_gnt_mult = 16;	/* 250ns @ 66MHz, in clocks */
-	    else
-		min_gnt_mult = 8;	/* 250ns @ 33MHz, in clocks */
-
-	    if ((min_gnt != 0) && ((min_gnt * min_gnt_mult) < 256))
-		lt_time = (min_gnt * min_gnt_mult);
-	    else
-		lt_time = 4 * min_gnt_mult;	  /* 1 micro second */
-
-	    do_pcibr_config_set(cfgw, PCI_CFG_LATENCY_TIMER, 1, lt_time);
-
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_CONFIG, pcibr_vhdl,
-                    "pcibr_slot_info_init: set Latency Timer for slot=%d, "
-		    "func=%d, to 0x%x\n", 
-		    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, lt_time));
-	}
-
-
-	/* In our architecture the setting of the cacheline size isn't 
-	 * beneficial for cards in PCI mode, but in PCI-X mode devices
-	 * can optionally use the cacheline size value for internal 
-	 * device optimizations    (See 7.1.5 of the PCI-X v1.0 spec).
-	 * NOTE: cachline size is in doubleword increments
-	 */
-	if (IS_PCIX(pcibr_soft)) {
-	    if (!do_pcibr_config_get(cfgw, PCI_CFG_CACHE_LINE, 1)) {
-		do_pcibr_config_set(cfgw, PCI_CFG_CACHE_LINE, 1, 0x20);
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_CONFIG, pcibr_vhdl,
-			"pcibr_slot_info_init: set CacheLine for slot=%d, "
-			"func=%d, to 0x20\n",
-			PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func));
-	    }
-	}
-
-	/* Get the PCI-X capability if running in PCI-X mode.  If the func
-	 * doesnt have a pcix capability, allocate a PCIIO_VENDOR_ID_NONE
-	 * pcibr_info struct so the device driver for that function is not
-	 * called.
-	 */
-	if (IS_PCIX(pcibr_soft)) {
-	    if (!(pcix_cap = pcibr_find_capability(cfgw, PCI_CAP_PCIX))) {
-		printk(KERN_WARNING
-		        "%s: Bus running in PCI-X mode, But card in slot %d, "
-		        "func %d not PCI-X capable\n", 
-			pcibr_soft->bs_name, slot, func);
-		pcibr_device_info_new(pcibr_soft, slot, PCIIO_FUNC_NONE,
-		               PCIIO_VENDOR_ID_NONE, PCIIO_DEVICE_ID_NONE);
-		continue;
-	    }
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_CONFIG, pcibr_vhdl,
-                    "pcibr_slot_info_init: PCI-X capability at 0x%lx for "
-		    "slot=%d, func=%d\n", 
-		    pcix_cap, PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func));
-	} else {
-	    pcix_cap = NULL;
-	}
-
-	pcibr_info = pcibr_device_info_new
-	    (pcibr_soft, slot, rfunc, vendor, device);
-
-	/* Keep a running total of the number of PIC-X functions on the bus
-         * and the number of max outstanding split trasnactions that they
-	 * have requested.  NOTE: "pcix_cap != NULL" implies IS_PCIX()
-	 */
-	pcibr_info->f_pcix_cap = (cap_pcix_type0_t *)pcix_cap;
-	if (pcibr_info->f_pcix_cap) {
-	    int max_out;      /* max outstanding splittrans from status reg */
-
-	    pcibr_soft->bs_pcix_num_funcs++;
-	    max_out = pcibr_info->f_pcix_cap->pcix_type0_status.max_out_split;
-	    pcibr_soft->bs_pcix_split_tot += max_splittrans_to_numbuf[max_out];
-	}
-
-	conn_vhdl = pciio_device_info_register(pcibr_vhdl, &pcibr_info->f_c);
-	if (func == 0)
-	    slotp->slot_conn = conn_vhdl;
-
-	cmd_reg = do_pcibr_config_get(cfgw, PCI_CFG_COMMAND, 4);
-	
-	wptr = cfgw + PCI_CFG_BASE_ADDR_0 / 4;
-
-	for (win = 0; win < nbars; ++win) {
-	    iopaddr_t               base, mask, code;
-	    size_t                  size;
-
-	    /*
-	     * GET THE BASE & SIZE OF THIS WINDOW:
-	     *
-	     * The low two or four bits of the BASE register
-	     * determines which address space we are in; the
-	     * rest is a base address. BASE registers
-	     * determine windows that are power-of-two sized
-	     * and naturally aligned, so we can get the size
-	     * of a window by writing all-ones to the
-	     * register, reading it back, and seeing which
-	     * bits are used for decode; the least
-	     * significant nonzero bit is also the size of
-	     * the window.
-	     *
-	     * WARNING: someone may already have allocated
-	     * some PCI space to this window, and in fact
-	     * PIO may be in process at this very moment
-	     * from another processor (or even from this
-	     * one, if we get interrupted)! So, if the BASE
-	     * already has a nonzero address, be generous
-	     * and use the LSBit of that address as the
-	     * size; this could overstate the window size.
-	     * Usually, when one card is set up, all are set
-	     * up; so, since we don't bitch about
-	     * overlapping windows, we are ok.
-	     *
-	     * UNFORTUNATELY, some cards do not clear their
-	     * BASE registers on reset. I have two heuristics
-	     * that can detect such cards: first, if the
-	     * decode enable is turned off for the space
-	     * that the window uses, we can disregard the
-	     * initial value. second, if the address is
-	     * outside the range that we use, we can disregard
-	     * it as well.
-	     *
-	     * This is looking very PCI generic. Except for
-	     * knowing how many slots and where their config
-	     * spaces are, this window loop and the next one
-	     * could probably be shared with other PCI host
-	     * adapters. It would be interesting to see if
-	     * this could be pushed up into pciio, when we
-	     * start supporting more PCI providers.
-	     */
-	    base = do_pcibr_config_get(wptr, (win * 4), 4);
-
-	    if (base & PCI_BA_IO_SPACE) {
-		/* BASE is in I/O space. */
-		space = PCIIO_SPACE_IO;
-		mask = -4;
-		code = base & 3;
-		base = base & mask;
-		if (base == 0) {
-		    ;		/* not assigned */
-		} else if (!(cmd_reg & PCI_CMD_IO_SPACE)) {
-		    base = 0;	/* decode not enabled */
-		}
-	    } else {
-		/* BASE is in MEM space. */
-		space = PCIIO_SPACE_MEM;
-		mask = -16;
-		code = base & PCI_BA_MEM_LOCATION;	/* extract BAR type */
-		base = base & mask;
-		if (base == 0) {
-		    ;		/* not assigned */
-		} else if (!(cmd_reg & PCI_CMD_MEM_SPACE)) {
-		    base = 0;	/* decode not enabled */
-		} else if (base & 0xC0000000) {
-		    base = 0;	/* outside permissable range */
-		} else if ((code == PCI_BA_MEM_64BIT) &&
-			   (do_pcibr_config_get(wptr, ((win + 1)*4), 4) != 0)) {
-		    base = 0;	/* outside permissable range */
-		}
-	    }
-
-	    if (base != 0) {	/* estimate size */
-		pciio_space_t	tmp_space = space;
-		iopaddr_t	tmp_base;
-
-		size = base & -base;
-
-		/*
-		 * Reserve this space in the relavent address map.  Don't
-		 * care about the return code from pcibr_bus_addr_alloc().
-		 */
-
-		if (space == PCIIO_SPACE_MEM && code != PCI_BA_MEM_1MEG) {
-			tmp_space = PCIIO_SPACE_MEM32;
-		}
-
-                tmp_base = pcibr_bus_addr_alloc(pcibr_soft,
-                                            	&pcibr_info->f_window[win],
-                                            	tmp_space,
-                                            	base, size, 0);
-
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
-			"pcibr_slot_info_init: slot=%d, func=%d win %d "
-			"reserving space %s [0x%lx..0x%lx], tmp_base 0x%lx\n",
-			PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, win,
-			pci_space[tmp_space], (uint64_t)base,
-			(uint64_t)(base + size - 1), (uint64_t)tmp_base));
-	    } else {		/* calculate size */
-		do_pcibr_config_set(wptr, (win * 4), 4, ~0);    /* write 1's */
-		size = do_pcibr_config_get(wptr, (win * 4), 4); /* read back */
-		size &= mask;	/* keep addr */
-		size &= -size;	/* keep lsbit */
-		if (size == 0)
-		    continue;
-	    }	
-
-	    pcibr_info->f_window[win].w_space = space;
-	    pcibr_info->f_window[win].w_base = base;
-	    pcibr_info->f_window[win].w_size = size;
-
-	    if (code == PCI_BA_MEM_64BIT) {
-		win++;		/* skip upper half */
-		do_pcibr_config_set(wptr, (win * 4), 4, 0);  /* must be zero */
-	    }
-	}				/* next win */
-    }				/* next func */
-
-    return 0;
-}					
-
-/*
- * pcibr_find_capability
- *	Walk the list of capabilities (if it exists) looking for
- *	the requested capability.  Return a cfg_p pointer to the
- *	capability if found, else return NULL
- */
-cfg_p
-pcibr_find_capability(cfg_p	cfgw,
-		      unsigned	capability)
-{
-    unsigned		cap_nxt;
-    unsigned		cap_id;
-    int			defend_against_circular_linkedlist = 0;
-
-    /* Check to see if there is a capabilities pointer in the cfg header */
-    if (!(do_pcibr_config_get(cfgw, PCI_CFG_STATUS, 2) & PCI_STAT_CAP_LIST)) {
-	return NULL;
-    }
-
-    /*
-     * Read up the capabilities head pointer from the configuration header.
-     * Capabilities are stored as a linked list in the lower 48 dwords of
-     * config space and are dword aligned. (Note: spec states the least two
-     * significant bits of the next pointer must be ignored,  so we mask
-     * with 0xfc).
-     */
-    cap_nxt = (do_pcibr_config_get(cfgw, PCI_CAPABILITIES_PTR, 1) & 0xfc);
-
-    while (cap_nxt && (defend_against_circular_linkedlist <= 48)) {
-	cap_id = do_pcibr_config_get(cfgw, cap_nxt, 1);
-	if (cap_id == capability) {
-	    return (cfg_p)((char *)cfgw + cap_nxt);
-	}
-	cap_nxt = (do_pcibr_config_get(cfgw, cap_nxt+1, 1) & 0xfc);
-	defend_against_circular_linkedlist++;
-    }
-
-    return NULL;
-}
-
-/*
- * pcibr_slot_info_free
- *	Remove all the PCI infrastructural information associated
- * 	with a particular PCI device.
- */
-int
-pcibr_slot_info_free(vertex_hdl_t pcibr_vhdl,
-                     pciio_slot_t slot)
-{
-    pcibr_soft_t	pcibr_soft;
-    pcibr_info_h	pcibr_infoh;
-    int			nfunc;
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    if (!pcibr_soft)
-	return -EINVAL;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    nfunc = pcibr_soft->bs_slot[slot].bss_ninfo;
-
-    pcibr_device_info_free(pcibr_vhdl, slot);
-
-    pcibr_infoh = pcibr_soft->bs_slot[slot].bss_infos;
-    kfree(pcibr_infoh);
-    pcibr_soft->bs_slot[slot].bss_ninfo = 0;
-
-    return 0;
-}
-
-/*
- * pcibr_slot_pcix_rbar_init
- *	Allocate RBARs to the PCI-X functions on a given device
- */
-int
-pcibr_slot_pcix_rbar_init(pcibr_soft_t pcibr_soft,
-			    pciio_slot_t slot)
-{
-    pcibr_info_h	 pcibr_infoh;
-    pcibr_info_t	 pcibr_info;
-    int		       	 nfunc;
-    int			 func;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    if ((nfunc = pcibr_soft->bs_slot[slot].bss_ninfo) < 1)
-	return -EINVAL;
-
-    if (!(pcibr_infoh = pcibr_soft->bs_slot[slot].bss_infos))
-	return -EINVAL;
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RBAR, pcibr_soft->bs_vhdl,
-		"pcibr_slot_pcix_rbar_init for slot %d\n", 
-		PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot)));
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RBAR, pcibr_soft->bs_vhdl,
-		"\tslot/func\trequested\tgiven\tinuse\tavail\n"));
-
-    for (func = 0; func < nfunc; ++func) {
-	cap_pcix_type0_t	*pcix_cap_p;
-	cap_pcix_stat_reg_t	*pcix_statreg_p;
-	cap_pcix_cmd_reg_t	*pcix_cmdreg_p;
-	int 			 num_rbar;
-
-	if (!(pcibr_info = pcibr_infoh[func]))
-	    continue;
-
-	if (pcibr_info->f_vendor == PCIIO_VENDOR_ID_NONE)
-	    continue;
-
-	if (!(pcix_cap_p = pcibr_info->f_pcix_cap))
-	    continue;
-
-	pcix_statreg_p = &pcix_cap_p->pcix_type0_status;
-	pcix_cmdreg_p = &pcix_cap_p->pcix_type0_command;
-
-	/* If there are enough RBARs to satify the number of "max outstanding 
-	 * transactions" each function requested (bs_pcix_rbar_percent_allowed
-	 * is 100%), then give each function what it requested, otherwise give 
-	 * the functions a "percentage of what they requested".
-	 */
-	if (pcibr_soft->bs_pcix_rbar_percent_allowed >= 100) {
-	    pcix_cmdreg_p->max_split = pcix_statreg_p->max_out_split;
-	    num_rbar = max_splittrans_to_numbuf[pcix_cmdreg_p->max_split];
-	    pcibr_soft->bs_pcix_rbar_inuse += num_rbar;
-	    pcibr_soft->bs_pcix_rbar_avail -= num_rbar;
-	    pcix_cmdreg_p->max_mem_read_cnt = pcix_statreg_p->max_mem_read_cnt;
-	} else {
-	    int index;	    /* index into max_splittrans_to_numbuf table */
-	    int max_out;    /* max outstanding transactions given to func */
-
-	    /* Calculate the percentage of RBARs this function can have.
-	     * NOTE: Every function gets at least 1 RBAR (thus the "+1").
-	     * bs_pcix_rbar_percent_allowed is the percentage of what was
-	     * requested less this 1 RBAR that all functions automatically 
-	     * gets
-	     */
-	    max_out = ((max_splittrans_to_numbuf[pcix_statreg_p->max_out_split]
-			* pcibr_soft->bs_pcix_rbar_percent_allowed) / 100) + 1;
-
-	    /* round down the newly caclulated max_out to a valid number in
-	     * max_splittrans_to_numbuf[]
-	     */
-	    for (index = 0; index < MAX_SPLIT_TABLE-1; index++)
-		if (max_splittrans_to_numbuf[index + 1] > max_out)
-		    break;
-
-	    pcix_cmdreg_p->max_split = index;
-	    num_rbar = max_splittrans_to_numbuf[pcix_cmdreg_p->max_split];
-	    pcibr_soft->bs_pcix_rbar_inuse += num_rbar;
-            pcibr_soft->bs_pcix_rbar_avail -= num_rbar;
-	    pcix_cmdreg_p->max_mem_read_cnt = pcix_statreg_p->max_mem_read_cnt;
-	}
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RBAR, pcibr_soft->bs_vhdl,
-		"\t  %d/%d   \t    %d    \t  %d  \t  %d  \t  %d\n",
-		PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func,
-		max_splittrans_to_numbuf[pcix_statreg_p->max_out_split],
-		max_splittrans_to_numbuf[pcix_cmdreg_p->max_split],
-		pcibr_soft->bs_pcix_rbar_inuse,
-		pcibr_soft->bs_pcix_rbar_avail));
-    }
-    return 0;
-}
-
-int as_debug = 0;
-/*
- * pcibr_slot_addr_space_init
- *	Reserve chunks of PCI address space as required by 
- * 	the base registers in the card.
- */
-int
-pcibr_slot_addr_space_init(vertex_hdl_t pcibr_vhdl,
-			   pciio_slot_t	slot)
-{
-    pcibr_soft_t	 pcibr_soft;
-    pcibr_info_h	 pcibr_infoh;
-    pcibr_info_t	 pcibr_info;
-    iopaddr_t            mask;
-    int		       	 nbars;
-    int		       	 nfunc;
-    int			 func;
-    int			 win;
-    int                  rc = 0;
-    int			 align = 0;
-    int			 align_slot;
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    if (!pcibr_soft)
-	return -EINVAL;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    /* allocate address space,
-     * for windows that have not been
-     * previously assigned.
-     */
-    if (pcibr_soft->bs_slot[slot].has_host) {
-	return 0;
-    }
-
-    nfunc = pcibr_soft->bs_slot[slot].bss_ninfo;
-    if (nfunc < 1)
-	return -EINVAL;
-
-    pcibr_infoh = pcibr_soft->bs_slot[slot].bss_infos;
-    if (!pcibr_infoh)
-	return -EINVAL;
-
-    /*
-     * Try to make the DevIO windows not
-     * overlap by pushing the "io" and "hi"
-     * allocation areas up to the next one
-     * or two megabyte bound. This also
-     * keeps them from being zero.
-     *
-     * DO NOT do this with "pci_lo" since
-     * the entire "lo" area is only a
-     * megabyte, total ...
-     */
-    align_slot = (slot < 2) ? 0x200000 : 0x100000;
-
-    for (func = 0; func < nfunc; ++func) {
-	cfg_p                   cfgw;
-	cfg_p                   wptr;
-	pciio_space_t           space;
-	iopaddr_t               base;
-	size_t                  size;
-	unsigned                pci_cfg_cmd_reg;
-	unsigned                pci_cfg_cmd_reg_add = 0;
-
-	pcibr_info = pcibr_infoh[func];
-
-	if (!pcibr_info)
-	    continue;
-
-	if (pcibr_info->f_vendor == PCIIO_VENDOR_ID_NONE)
-	    continue;
-	
-        cfgw = pcibr_func_config_addr(pcibr_soft, 0, slot, func, 0);
-	wptr = cfgw + PCI_CFG_BASE_ADDR_0 / 4;
-
-	if ((do_pcibr_config_get(cfgw, PCI_CFG_HEADER_TYPE, 1) & 0x7f) != 0)
-	    nbars = 2;
-	else
-	    nbars = PCI_CFG_BASE_ADDRS;
-
-	for (win = 0; win < nbars; ++win) {
-	    space = pcibr_info->f_window[win].w_space;
-	    base = pcibr_info->f_window[win].w_base;
-	    size = pcibr_info->f_window[win].w_size;
-	    
-	    if (size < 1)
-		continue;
-
-	    if (base >= size) {
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
-			"pcibr_slot_addr_space_init: slot=%d, "
-			"func=%d win %d is in space %s [0x%lx..0x%lx], "
-			"allocated by prom\n",
-			PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, win,
-			pci_space[space], (uint64_t)base,
-			(uint64_t)(base + size - 1)));
-
-		continue;		/* already allocated */
-	    }
-
-	    align = (win) ? size : align_slot; 
-
-	    if (align < PAGE_SIZE)
-		align = PAGE_SIZE;        /* ie. 0x00004000 */
- 
-	    switch (space) {
-	    case PCIIO_SPACE_IO:
-                base = pcibr_bus_addr_alloc(pcibr_soft,
-                                            &pcibr_info->f_window[win],
-                                            PCIIO_SPACE_IO,
-                                            0, size, align);
-                if (!base)
-                    rc = ENOSPC;
-		break;
-		
-	    case PCIIO_SPACE_MEM:
-		if ((do_pcibr_config_get(wptr, (win * 4), 4) &
-		     PCI_BA_MEM_LOCATION) == PCI_BA_MEM_1MEG) {
- 
-		    /* allocate from 20-bit PCI space */
-                    base = pcibr_bus_addr_alloc(pcibr_soft,
-                                                &pcibr_info->f_window[win],
-                                                PCIIO_SPACE_MEM,
-                                                0, size, align);
-                    if (!base)
-                        rc = ENOSPC;
-		} else {
-		    /* allocate from 32-bit or 64-bit PCI space */
-                    base = pcibr_bus_addr_alloc(pcibr_soft,
-                                                &pcibr_info->f_window[win],
-                                                PCIIO_SPACE_MEM32,
-                                                0, size, align);
-		    if (!base) 
-			rc = ENOSPC;
-		}
-		break;
-		
-	    default:
-		base = 0;
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
-			    "pcibr_slot_addr_space_init: slot=%d, window %d "
-			    "had bad space code %d\n", 
-			    PCIBR_DEVICE_TO_SLOT(pcibr_soft,slot), win, space));
-	    }
-	    pcibr_info->f_window[win].w_base = base;
-	    do_pcibr_config_set(wptr, (win * 4), 4, base);
-
-	    if (base >= size) {
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
-			"pcibr_slot_addr_space_init: slot=%d, func=%d. win %d "
-			"is in space %s [0x%lx..0x%lx], allocated by pcibr\n",
-			PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, win,
-			pci_space[space], (uint64_t)base, 
-			(uint64_t)(base + size - 1)));
-	    } else {
-		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
-			"pcibr_slot_addr_space_init: slot=%d, func=%d, win %d, "
-			"unable to alloc 0x%lx in space %s\n",
-			PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, win,
-			(uint64_t)size, pci_space[space]));
-	    }
-	}				/* next base */
-
-	/*
-	 * Allocate space for the EXPANSION ROM
-	 */
-	base = size = 0;
-	{
-	    wptr = cfgw + PCI_EXPANSION_ROM / 4;
-	    do_pcibr_config_set(wptr, 0, 4, 0xFFFFF000);
-	    mask = do_pcibr_config_get(wptr, 0, 4);
-	    if (mask & 0xFFFFF000) {
-		size = mask & -mask;
-                base = pcibr_bus_addr_alloc(pcibr_soft,
-                                            &pcibr_info->f_rwindow,
-                                            PCIIO_SPACE_MEM32, 
-                                            0, size, align);
-		if (!base)
-		    rc = ENOSPC;
-		else {
-		    do_pcibr_config_set(wptr, 0, 4, base);
-		    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
-				"pcibr_slot_addr_space_init: slot=%d, func=%d, "
-				"ROM in [0x%X..0x%X], allocated by pcibr\n",
-				PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), 
-				func, base, base + size - 1));
-		}
-	    }
-	}
-	pcibr_info->f_rbase = base;
-	pcibr_info->f_rsize = size;
-
-	/*
-	 * if necessary, update the board's
-	 * command register to enable decoding
-	 * in the windows we added.
-	 *
-	 * There are some bits we always want to
-	 * be sure are set.
-	 */
-	pci_cfg_cmd_reg_add |= PCI_CMD_IO_SPACE;
-
-	/*
-	 * The Adaptec 1160 FC Controller WAR #767995:
-	 * The part incorrectly ignores the upper 32 bits of a 64 bit
-	 * address when decoding references to its registers so to
-	 * keep it from responding to a bus cycle that it shouldn't
-	 * we only use I/O space to get at it's registers.  Don't
-	 * enable memory space accesses on that PCI device.
-	 */
-	#define FCADP_VENDID 0x9004 /* Adaptec Vendor ID from fcadp.h */
-	#define FCADP_DEVID 0x1160  /* Adaptec 1160 Device ID from fcadp.h */
-
-	if ((pcibr_info->f_vendor != FCADP_VENDID) ||
-	    (pcibr_info->f_device != FCADP_DEVID))
-	    pci_cfg_cmd_reg_add |= PCI_CMD_MEM_SPACE;
-
-	pci_cfg_cmd_reg_add |= PCI_CMD_BUS_MASTER;
-
-	pci_cfg_cmd_reg = do_pcibr_config_get(cfgw, PCI_CFG_COMMAND, 4);
-	pci_cfg_cmd_reg &= 0xFFFF;
-	if (pci_cfg_cmd_reg_add & ~pci_cfg_cmd_reg)
-	    do_pcibr_config_set(cfgw, PCI_CFG_COMMAND, 4, 
-				pci_cfg_cmd_reg | pci_cfg_cmd_reg_add);
-    }				/* next func */
-    return rc;
-}
-
-/*
- * pcibr_slot_device_init
- * 	Setup the device register in the bridge for this PCI slot.
- */
-
-int
-pcibr_slot_device_init(vertex_hdl_t pcibr_vhdl,
-		       pciio_slot_t slot)
-{
-    pcibr_soft_t	 pcibr_soft;
-    uint64_t		 devreg;
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    if (!pcibr_soft)
-	return -EINVAL;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    /*
-     * Adjustments to Device(x) and init of bss_device shadow
-     */
-    devreg = pcireg_device_get(pcibr_soft, slot);
-    devreg &= ~BRIDGE_DEV_PAGE_CHK_DIS;
-
-    /*
-     * Enable virtual channels by default (exception: see PIC WAR below)
-     */
-    devreg |= BRIDGE_DEV_VIRTUAL_EN;
-
-    /*
-     * PIC WAR. PV# 855271:  Disable virtual channels in the PIC since
-     * it can cause problems with 32-bit devices.  We'll set the bit in
-     * pcibr_try_set_device() iff we're 64-bit and requesting virtual 
-     * channels.
-     */
-    if (PCIBR_WAR_ENABLED(PV855271, pcibr_soft)) {
-	devreg &= ~BRIDGE_DEV_VIRTUAL_EN;
-    }
-    devreg |= BRIDGE_DEV_COH;
-
-    pcibr_soft->bs_slot[slot].bss_device = devreg;
-    pcireg_device_set(pcibr_soft, slot, devreg);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEVREG, pcibr_vhdl,
-		"pcibr_slot_device_init: Device(%d): 0x%x\n",
-		slot, devreg));
-    return 0;
-}
-
-/*
- * pcibr_slot_guest_info_init
- *	Setup the host/guest relations for a PCI slot.
- */
-int
-pcibr_slot_guest_info_init(vertex_hdl_t pcibr_vhdl,
-			   pciio_slot_t	slot)
-{
-    pcibr_soft_t	pcibr_soft;
-    pcibr_info_h	pcibr_infoh;
-    pcibr_info_t	pcibr_info;
-    pcibr_soft_slot_t	slotp;
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    if (!pcibr_soft)
-	return -EINVAL;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    slotp = &pcibr_soft->bs_slot[slot];
-
-    /* create info and verticies for guest slots;
-     * for compatibilitiy macros, create info
-     * for even unpopulated slots (but do not
-     * build verticies for them).
-     */
-    if (pcibr_soft->bs_slot[slot].bss_ninfo < 1) {
-	pcibr_infoh = kmalloc(sizeof (*(pcibr_infoh)), GFP_KERNEL);
-	if ( !pcibr_infoh ) {
-		return -ENOMEM;
-	}
-	memset(pcibr_infoh, 0, sizeof (*(pcibr_infoh)));
-
-	pcibr_soft->bs_slot[slot].bss_ninfo = 1;
-	pcibr_soft->bs_slot[slot].bss_infos = pcibr_infoh;
-
-	pcibr_info = pcibr_device_info_new
-	    (pcibr_soft, slot, PCIIO_FUNC_NONE,
-	     PCIIO_VENDOR_ID_NONE, PCIIO_DEVICE_ID_NONE);
-
-	if (pcibr_soft->bs_slot[slot].has_host) {
-	    slotp->slot_conn = pciio_device_info_register
-		(pcibr_vhdl, &pcibr_info->f_c);
-	}
-    }
-
-    /* generate host/guest relations
-     */
-    if (pcibr_soft->bs_slot[slot].has_host) {
-	int  host = pcibr_soft->bs_slot[slot].host_slot;
-	pcibr_soft_slot_t host_slotp = &pcibr_soft->bs_slot[host];
-
-	hwgraph_edge_add(slotp->slot_conn,
-			 host_slotp->slot_conn,
-			 EDGE_LBL_HOST);
-
-	/* XXX- only gives us one guest edge per
-	 * host. If/when we have a host with more than
-	 * one guest, we will need to figure out how
-	 * the host finds all its guests, and sorts
-	 * out which one is which.
-	 */
-	hwgraph_edge_add(host_slotp->slot_conn,
-			 slotp->slot_conn,
-			 EDGE_LBL_GUEST);
-    }
-
-    return 0;
-}
-
-
-/*
- * pcibr_slot_call_device_attach
- *	This calls the associated driver attach routine for the PCI
- * 	card in this slot.
- */
-int
-pcibr_slot_call_device_attach(vertex_hdl_t pcibr_vhdl,
-			      pciio_slot_t slot,
-			      int          drv_flags)
-{
-    pcibr_soft_t	pcibr_soft;
-    pcibr_info_h	pcibr_infoh;
-    pcibr_info_t	pcibr_info;
-    int			func;
-    vertex_hdl_t	xconn_vhdl, conn_vhdl;
-    int			nfunc;
-    int                 error_func;
-    int                 error_slot = 0;
-    int                 error = ENODEV;
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    if (!pcibr_soft)
-	return -EINVAL;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    if (pcibr_soft->bs_slot[slot].has_host) {
-        return -EPERM;
-    }
-    
-    xconn_vhdl = pcibr_soft->bs_conn;
-
-    nfunc = pcibr_soft->bs_slot[slot].bss_ninfo;
-    pcibr_infoh = pcibr_soft->bs_slot[slot].bss_infos;
-
-    for (func = 0; func < nfunc; ++func) {
-
-	pcibr_info = pcibr_infoh[func];
-	
-	if (!pcibr_info)
-	    continue;
-
-	if (pcibr_info->f_vendor == PCIIO_VENDOR_ID_NONE)
-	    continue;
-
-	conn_vhdl = pcibr_info->f_vertex;
-
-	error_func = pciio_device_attach(conn_vhdl, drv_flags);
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEV_ATTACH, pcibr_vhdl,
-		    "pcibr_slot_call_device_attach: slot=%d, func=%d "
-		    "drv_flags=0x%x, pciio_device_attach returned %d\n",
-		    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, 
-		    drv_flags, error_func));
-        pcibr_info->f_att_det_error = error_func;
-
-	if (error_func)
-	    error_slot = error_func;
-
-        error = error_slot;
-
-    }				/* next func */
-
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-    if (error) {
-	if ((error != ENODEV) && (error != EUNATCH) && (error != EPERM)) {
-	    pcibr_soft->bs_slot[slot].slot_status &= ~SLOT_STATUS_MASK;
-	    pcibr_soft->bs_slot[slot].slot_status |= SLOT_STARTUP_INCMPLT;
-	}
-    } else {
-        pcibr_soft->bs_slot[slot].slot_status &= ~SLOT_STATUS_MASK;
-        pcibr_soft->bs_slot[slot].slot_status |= SLOT_STARTUP_CMPLT;
-    }
-#endif	/* CONFIG_HOTPLUG_PCI_SGI */
-    return error;
-}
-
-/*
- * pcibr_slot_call_device_detach
- *	This calls the associated driver detach routine for the PCI
- * 	card in this slot.
- */
-int
-pcibr_slot_call_device_detach(vertex_hdl_t pcibr_vhdl,
-			      pciio_slot_t slot,
-			      int          drv_flags)
-{
-    pcibr_soft_t	pcibr_soft;
-    pcibr_info_h	pcibr_infoh;
-    pcibr_info_t	pcibr_info;
-    int			func;
-    vertex_hdl_t	conn_vhdl = GRAPH_VERTEX_NONE;
-    int			nfunc;
-    int                 error_func;
-    int                 error_slot = 0;
-    int                 error = ENODEV;
-
-    pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-
-    if (!pcibr_soft)
-	return -EINVAL;
-
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-	return -EINVAL;
-
-    if (pcibr_soft->bs_slot[slot].has_host)
-        return -EPERM;
-
-    nfunc = pcibr_soft->bs_slot[slot].bss_ninfo;
-    pcibr_infoh = pcibr_soft->bs_slot[slot].bss_infos;
-
-    for (func = 0; func < nfunc; ++func) {
-
-	pcibr_info = pcibr_infoh[func];
-	
-	if (!pcibr_info)
-	    continue;
-
-	if (pcibr_info->f_vendor == PCIIO_VENDOR_ID_NONE)
-	    continue;
-
-	if (IS_PCIX(pcibr_soft) && pcibr_info->f_pcix_cap) {
-	    int max_out;
-
-	    pcibr_soft->bs_pcix_num_funcs--;
-	    max_out = pcibr_info->f_pcix_cap->pcix_type0_status.max_out_split;
-	    pcibr_soft->bs_pcix_split_tot -= max_splittrans_to_numbuf[max_out];
-	}
-
-	conn_vhdl = pcibr_info->f_vertex;
-
-	error_func = pciio_device_detach(conn_vhdl, drv_flags);
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEV_DETACH, pcibr_vhdl,
-		    "pcibr_slot_call_device_detach: slot=%d, func=%d "
-		    "drv_flags=0x%x, pciio_device_detach returned %d\n",
-		    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, 
-		    drv_flags, error_func));
-
-        pcibr_info->f_att_det_error = error_func;
-
-	if (error_func)
-	    error_slot = error_func;
-
-	error = error_slot;
-
-    }				/* next func */
-
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-    if (error) {
-	if ((error != ENODEV) && (error != EUNATCH) && (error != EPERM)) {
-	    pcibr_soft->bs_slot[slot].slot_status &= ~SLOT_STATUS_MASK;
-            pcibr_soft->bs_slot[slot].slot_status |= SLOT_SHUTDOWN_INCMPLT;
-	}
-    } else {
-        if (conn_vhdl != GRAPH_VERTEX_NONE) 
-            pcibr_device_unregister(conn_vhdl);
-        pcibr_soft->bs_slot[slot].slot_status &= ~SLOT_STATUS_MASK;
-        pcibr_soft->bs_slot[slot].slot_status |= SLOT_SHUTDOWN_CMPLT;
-    }
-#endif	/* CONFIG_HOTPLUG_PCI_SGI */
-    return error;
-}
-
-
-
-/*
- * pcibr_slot_detach
- *	This is a place holder routine to keep track of all the
- *	slot-specific freeing that needs to be done.
- */
-int
-pcibr_slot_detach(vertex_hdl_t pcibr_vhdl,
-		  pciio_slot_t slot,
-		  int          drv_flags,
-		  char        *l1_msg,
-                  int         *sub_errorp)
-{
-    pcibr_soft_t  pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    int		  error;
-    
-    /* Call the device detach function */
-    error = (pcibr_slot_call_device_detach(pcibr_vhdl, slot, drv_flags));
-    if (error) {
-        if (sub_errorp)
-            *sub_errorp = error;       
-	if (l1_msg)
-	    ;
-        return PCI_SLOT_DRV_DETACH_ERR;
-    }
-
-    /* Recalculate the RBARs for all the devices on the bus since we've
-     * just freed some up and some of the devices could use them.
-     */
-    if (IS_PCIX(pcibr_soft)) {
-	int tmp_slot;
-
-	pcibr_soft->bs_pcix_rbar_inuse = 0;
-	pcibr_soft->bs_pcix_rbar_avail = NUM_RBAR;
-	pcibr_soft->bs_pcix_rbar_percent_allowed = 
-					pcibr_pcix_rbars_calc(pcibr_soft);
-
-	for (tmp_slot = pcibr_soft->bs_min_slot;
-			tmp_slot < PCIBR_NUM_SLOTS(pcibr_soft); ++tmp_slot)
-            (void)pcibr_slot_pcix_rbar_init(pcibr_soft, tmp_slot);
-    }
-
-    return 0;
-
-}
-
-/*
- * pcibr_probe_slot_pic: read a config space word
- * while trapping any errors; return zero if
- * all went OK, or nonzero if there was an error.
- * The value read, if any, is passed back
- * through the valp parameter.
- */
-static int
-pcibr_probe_slot(pcibr_soft_t pcibr_soft,
-		 cfg_p cfg,
-		 unsigned *valp)
-{
-    return pcibr_probe_work(pcibr_soft, (void *)cfg, 4, (void *)valp);
-}
-
-/*
- * Probe an offset within a piomap with errors disabled.
- * len must be 1, 2, 4, or 8.  	The probed address must be a multiple of
- * len.
- *
- * Returns:	0	if the offset was probed and put valid data in valp
- *		-1	if there was a usage error such as improper alignment
- *			or out of bounds offset/len combination.  In this
- *			case, the map was not probed
- *		1 	if the offset was probed but resulted in an error
- *			such as device not responding, bus error, etc.
- */
-
-int
-pcibr_piomap_probe(pcibr_piomap_t piomap, off_t offset, int len, void *valp)
-{
-	if (offset + len > piomap->bp_mapsz) {
-		return -1;
-	}
-
-	return pcibr_probe_work(piomap->bp_soft,
-				piomap->bp_kvaddr + offset, len, valp);
-}
-
-static uint64_t
-pcibr_disable_mst_timeout(pcibr_soft_t pcibr_soft)
-{
-    uint64_t		old_enable;
-    uint64_t		new_enable;
-    uint64_t		intr_bits;
-
-    intr_bits = PIC_ISR_PCI_MST_TIMEOUT
-		| PIC_ISR_PCIX_MTOUT | PIC_ISR_PCIX_SPLIT_EMSG;
-    old_enable = pcireg_intr_enable_get(pcibr_soft);
-    pcireg_intr_enable_bit_clr(pcibr_soft, intr_bits);
-    new_enable = pcireg_intr_enable_get(pcibr_soft);
-
-    if (old_enable == new_enable) {
-	return 0;		/* was already disabled */
-    } else {
-	return 1;
-    }
-}
-
-static int
-pcibr_enable_mst_timeout(pcibr_soft_t pcibr_soft)
-{
-    uint64_t		old_enable;
-    uint64_t		new_enable;
-    uint64_t		intr_bits;
-    
-    intr_bits = PIC_ISR_PCI_MST_TIMEOUT
-		| PIC_ISR_PCIX_MTOUT | PIC_ISR_PCIX_SPLIT_EMSG;
-    old_enable = pcireg_intr_enable_get(pcibr_soft);
-    pcireg_intr_enable_bit_set(pcibr_soft, intr_bits);
-    new_enable = pcireg_intr_enable_get(pcibr_soft);
-
-    if (old_enable == new_enable) {
-	return 0;		/* was alread enabled */
-    } else {
-	return 1;
-    }
-}
-
-/*
- * pcibr_probe_slot: read a config space word
- * while trapping any errors; return zero if
- * all went OK, or nonzero if there was an error.
- * The value read, if any, is passed back
- * through the valp parameter.
- */
-static int
-pcibr_probe_work(pcibr_soft_t pcibr_soft,
-		 void *addr,
-		 int len,
-		 void *valp)
-{
-    int			rv, changed;
-
-    /*
-     * Sanity checks ...
-     */
-
-    if (len != 1 && len != 2 && len != 4 && len != 8) {
-	return -1;				/* invalid len */
-    }
-
-    if ((uint64_t)addr & (len-1)) {
-	return -1;				/* invalid alignment */
-    }
-
-    changed = pcibr_disable_mst_timeout(pcibr_soft);
-
-    rv = snia_badaddr_val((void *)addr, len, valp);
-
-    /* Clear the int_view register incase it was set */
-    pcireg_intr_reset_set(pcibr_soft, BRIDGE_IRR_MULTI_CLR);
-
-    if (changed) {
-	pcibr_enable_mst_timeout(pcibr_soft);
-    }
-    return (rv ? 1 : 0);	/* return 1 for snia_badaddr_val error, 0 if ok */
-}
-
-void
-pcibr_device_info_free(vertex_hdl_t pcibr_vhdl, pciio_slot_t slot)
-{
-    pcibr_soft_t	pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    pcibr_info_t	pcibr_info;
-    pciio_function_t	func;
-    pcibr_soft_slot_t	slotp = &pcibr_soft->bs_slot[slot];
-    cfg_p               cfgw;
-    int			nfunc = slotp->bss_ninfo;
-    int                 bar;
-    int                 devio_index;
-    unsigned long	s;
-    unsigned            cmd_reg;
-
-
-    for (func = 0; func < nfunc; func++) {
-	pcibr_info = slotp->bss_infos[func];
-
-	if (!pcibr_info) 
-	    continue;
-
-        s = pcibr_lock(pcibr_soft);
-
-        /* Disable memory and I/O BARs */
-	cfgw = pcibr_func_config_addr(pcibr_soft, 0, slot, func, 0);
-	cmd_reg = do_pcibr_config_get(cfgw, PCI_CFG_COMMAND, 4);
-	cmd_reg &= (PCI_CMD_MEM_SPACE | PCI_CMD_IO_SPACE);
-	do_pcibr_config_set(cfgw, PCI_CFG_COMMAND, 4, cmd_reg);
-
-        for (bar = 0; bar < PCI_CFG_BASE_ADDRS; bar++) {
-            if (pcibr_info->f_window[bar].w_space == PCIIO_SPACE_NONE)
-                continue;
-
-            /* Free the PCI bus space */
-            pcibr_bus_addr_free(&pcibr_info->f_window[bar]);
-
-            /* Get index of the DevIO(x) register used to access this BAR */
-            devio_index = pcibr_info->f_window[bar].w_devio_index;
-
- 
-            /* On last use, clear the DevIO(x) used to access this BAR */
-            if (! --pcibr_soft->bs_slot[devio_index].bss_devio.bssd_ref_cnt) {
-               pcibr_soft->bs_slot[devio_index].bss_devio.bssd_space =
-                                                       PCIIO_SPACE_NONE; 
-               pcibr_soft->bs_slot[devio_index].bss_devio.bssd_base =
-                                                       PCIBR_D32_BASE_UNSET;
-               pcibr_soft->bs_slot[devio_index].bss_device = 0;
-            }
-        }
-
-        /* Free the Expansion ROM PCI bus space */
-	if(pcibr_info->f_rbase && pcibr_info->f_rsize) {
-            pcibr_bus_addr_free(&pcibr_info->f_rwindow);
-        }
-
-        pcibr_unlock(pcibr_soft, s);
-
-	slotp->bss_infos[func] = 0;
-	pciio_device_info_unregister(pcibr_vhdl, &pcibr_info->f_c);
-	pciio_device_info_free(&pcibr_info->f_c);
-
-	kfree(pcibr_info);
-    }
-
-    /* Reset the mapping usage counters */
-    slotp->bss_pmu_uctr = 0;
-    slotp->bss_d32_uctr = 0;
-    slotp->bss_d64_uctr = 0;
-
-    /* Clear the Direct translation info */
-    slotp->bss_d64_base = PCIBR_D64_BASE_UNSET;
-    slotp->bss_d64_flags = 0;
-    slotp->bss_d32_base = PCIBR_D32_BASE_UNSET;
-    slotp->bss_d32_flags = 0;
-}
-
-
-iopaddr_t
-pcibr_bus_addr_alloc(pcibr_soft_t pcibr_soft, pciio_win_info_t win_info_p,
-                     pciio_space_t space, int start, int size, int align)
-{
-    pciio_win_map_t win_map_p;
-    struct resource *root_resource = NULL;
-    iopaddr_t iopaddr = 0;
-
-    switch (space) {
-
-        case PCIIO_SPACE_IO:
-            win_map_p = &pcibr_soft->bs_io_win_map;
-	    root_resource = &pcibr_soft->bs_io_win_root_resource;
-            break;
-
-        case PCIIO_SPACE_MEM:
-            win_map_p = &pcibr_soft->bs_swin_map;
-	    root_resource = &pcibr_soft->bs_swin_root_resource;
-            break;
-
-        case PCIIO_SPACE_MEM32:
-            win_map_p = &pcibr_soft->bs_mem_win_map;
-	    root_resource = &pcibr_soft->bs_mem_win_root_resource;
-            break;
-
-        default:
-            return 0;
-
-    }
-    iopaddr = pciio_device_win_alloc(root_resource,
-				  win_info_p
-				  ? &win_info_p->w_win_alloc
-				  : NULL,
-				  start, size, align);
-    return iopaddr;
-}
-
-
-void
-pcibr_bus_addr_free(pciio_win_info_t win_info_p)
-{
-	pciio_device_win_free(&win_info_p->w_win_alloc);
-}
-
-/*
- * given a vertex_hdl to the pcibr_vhdl, return the brick's bus number
- * associated with that vertex_hdl.  The true mapping happens from the
- * io_brick_tab[] array defined in ml/SN/iograph.c
- */
-int
-pcibr_widget_to_bus(vertex_hdl_t pcibr_vhdl) 
-{
-    pcibr_soft_t	pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    xwidgetnum_t	widget = pcibr_soft->bs_xid;
-    int			bricktype = pcibr_soft->bs_bricktype;
-    int			bus;
-    
-    if ((bus = io_brick_map_widget(bricktype, widget)) <= 0) {
-	printk(KERN_WARNING "pcibr_widget_to_bus() bad bricktype %d\n", bricktype);
-	return 0;
-    }
-
-    /* For PIC there are 2 busses per widget and pcibr_soft->bs_busnum
-     * will be 0 or 1.  Add in the correct PIC bus offset.
-     */
-    bus += pcibr_soft->bs_busnum;
-    return bus;
-}
diff -Nru a/arch/ia64/sn/io/sn2/pciio.c b/arch/ia64/sn/io/sn2/pciio.c
--- a/arch/ia64/sn/io/sn2/pciio.c	2004-12-24 13:37:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1004 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <asm/sn/pci/pci_bus_cvlink.h>
-#include <asm/sn/simulator.h>
-
-char                    pciio_info_fingerprint[] = "pciio_info";
-
-/* =====================================================================
- *    PCI Generic Bus Provider
- * Implement PCI provider operations.  The pciio* layer provides a
- * platform-independent interface for PCI devices.  This layer
- * switches among the possible implementations of a PCI adapter.
- */
-
-/* =====================================================================
- *    Provider Function Location
- *
- *      If there is more than one possible provider for
- *      this platform, we need to examine the master
- *      vertex of the current vertex for a provider
- *      function structure, and indirect through the
- *      appropriately named member.
- */
-
-pciio_provider_t *
-pciio_to_provider_fns(vertex_hdl_t dev)
-{
-    pciio_info_t            card_info;
-    pciio_provider_t       *provider_fns;
-
-    /*
-     * We're called with two types of vertices, one is
-     * the bridge vertex (ends with "pci") and the other is the
-     * pci slot vertex (ends with "pci/[0-8]").  For the first type
-     * we need to get the provider from the PFUNCS label.  For
-     * the second we get it from fastinfo/c_pops.
-     */
-    provider_fns = pciio_provider_fns_get(dev);
-    if (provider_fns == NULL) {
-	card_info = pciio_info_get(dev);
-	if (card_info != NULL) {
-		provider_fns = pciio_info_pops_get(card_info);
-	}
-    }
-
-    if (provider_fns == NULL) {
-	char devname[MAXDEVNAME];
-	panic("%s: provider_fns == NULL", vertex_to_name(dev, devname, MAXDEVNAME));
-    }
-    return provider_fns;
-
-}
-
-#define DEV_FUNC(dev,func)	pciio_to_provider_fns(dev)->func
-#define CAST_PIOMAP(x)		((pciio_piomap_t)(x))
-#define CAST_DMAMAP(x)		((pciio_dmamap_t)(x))
-#define CAST_INTR(x)		((pciio_intr_t)(x))
-
-/*
- * Many functions are not passed their vertex
- * information directly; rather, they must
- * dive through a resource map. These macros
- * are available to coordinate this detail.
- */
-#define PIOMAP_FUNC(map,func)		DEV_FUNC((map)->pp_dev,func)
-#define DMAMAP_FUNC(map,func)		DEV_FUNC((map)->pd_dev,func)
-#define INTR_FUNC(intr_hdl,func)	DEV_FUNC((intr_hdl)->pi_dev,func)
-
-/* =====================================================================
- *          PIO MANAGEMENT
- *
- *      For mapping system virtual address space to
- *      pciio space on a specified card
- */
-
-pciio_piomap_t
-pciio_piomap_alloc(vertex_hdl_t dev,	/* set up mapping for this device */
-		   device_desc_t dev_desc,	/* device descriptor */
-		   pciio_space_t space,	/* CFG, MEM, IO, or a device-decoded window */
-		   iopaddr_t addr,	/* lowest address (or offset in window) */
-		   size_t byte_count,	/* size of region containing our mappings */
-		   size_t byte_count_max,	/* maximum size of a mapping */
-		   unsigned flags)
-{					/* defined in sys/pio.h */
-    return (pciio_piomap_t) DEV_FUNC(dev, piomap_alloc)
-	(dev, dev_desc, space, addr, byte_count, byte_count_max, flags);
-}
-
-void
-pciio_piomap_free(pciio_piomap_t pciio_piomap)
-{
-    PIOMAP_FUNC(pciio_piomap, piomap_free)
-	(CAST_PIOMAP(pciio_piomap));
-}
-
-caddr_t
-pciio_piomap_addr(pciio_piomap_t pciio_piomap,	/* mapping resources */
-		  iopaddr_t pciio_addr,	/* map for this pciio address */
-		  size_t byte_count)
-{					/* map this many bytes */
-    pciio_piomap->pp_kvaddr = PIOMAP_FUNC(pciio_piomap, piomap_addr)
-	(CAST_PIOMAP(pciio_piomap), pciio_addr, byte_count);
-
-    return pciio_piomap->pp_kvaddr;
-}
-
-void
-pciio_piomap_done(pciio_piomap_t pciio_piomap)
-{
-    PIOMAP_FUNC(pciio_piomap, piomap_done)
-	(CAST_PIOMAP(pciio_piomap));
-}
-
-caddr_t
-pciio_piotrans_addr(vertex_hdl_t dev,	/* translate for this device */
-		    device_desc_t dev_desc,	/* device descriptor */
-		    pciio_space_t space,	/* CFG, MEM, IO, or a device-decoded window */
-		    iopaddr_t addr,	/* starting address (or offset in window) */
-		    size_t byte_count,	/* map this many bytes */
-		    unsigned flags)
-{					/* (currently unused) */
-    return DEV_FUNC(dev, piotrans_addr)
-	(dev, dev_desc, space, addr, byte_count, flags);
-}
-
-caddr_t
-pciio_pio_addr(vertex_hdl_t dev,	/* translate for this device */
-	       device_desc_t dev_desc,	/* device descriptor */
-	       pciio_space_t space,	/* CFG, MEM, IO, or a device-decoded window */
-	       iopaddr_t addr,		/* starting address (or offset in window) */
-	       size_t byte_count,	/* map this many bytes */
-	       pciio_piomap_t *mapp,	/* where to return the map pointer */
-	       unsigned flags)
-{					/* PIO flags */
-    pciio_piomap_t          map = 0;
-    int			    errfree = 0;
-    caddr_t                 res;
-
-    if (mapp) {
-	map = *mapp;			/* possible pre-allocated map */
-	*mapp = 0;			/* record "no map used" */
-    }
-
-    res = pciio_piotrans_addr
-	(dev, dev_desc, space, addr, byte_count, flags);
-    if (res)
-	return res;			/* pciio_piotrans worked */
-
-    if (!map) {
-	map = pciio_piomap_alloc
-	    (dev, dev_desc, space, addr, byte_count, byte_count, flags);
-	if (!map)
-	    return res;			/* pciio_piomap_alloc failed */
-	errfree = 1;
-    }
-
-    res = pciio_piomap_addr
-	(map, addr, byte_count);
-    if (!res) {
-	if (errfree)
-	    pciio_piomap_free(map);
-	return res;			/* pciio_piomap_addr failed */
-    }
-    if (mapp)
-	*mapp = map;			/* pass back map used */
-
-    return res;				/* pciio_piomap_addr succeeded */
-}
-
-iopaddr_t
-pciio_piospace_alloc(vertex_hdl_t dev,	/* Device requiring space */
-		     device_desc_t dev_desc,	/* Device descriptor */
-		     pciio_space_t space,	/* MEM32/MEM64/IO */
-		     size_t byte_count,	/* Size of mapping */
-		     size_t align)
-{					/* Alignment needed */
-    if (align < PAGE_SIZE)
-	align = PAGE_SIZE;
-    return DEV_FUNC(dev, piospace_alloc)
-	(dev, dev_desc, space, byte_count, align);
-}
-
-void
-pciio_piospace_free(vertex_hdl_t dev,	/* Device freeing space */
-		    pciio_space_t space,	/* Type of space        */
-		    iopaddr_t pciaddr,	/* starting address */
-		    size_t byte_count)
-{					/* Range of address   */
-    DEV_FUNC(dev, piospace_free)
-	(dev, space, pciaddr, byte_count);
-}
-
-/* =====================================================================
- *          DMA MANAGEMENT
- *
- *      For mapping from pci space to system
- *      physical space.
- */
-
-pciio_dmamap_t
-pciio_dmamap_alloc(vertex_hdl_t dev,	/* set up mappings for this device */
-		   device_desc_t dev_desc,	/* device descriptor */
-		   size_t byte_count_max,	/* max size of a mapping */
-		   unsigned flags)
-{					/* defined in dma.h */
-    return (pciio_dmamap_t) DEV_FUNC(dev, dmamap_alloc)
-	(dev, dev_desc, byte_count_max, flags);
-}
-
-void
-pciio_dmamap_free(pciio_dmamap_t pciio_dmamap)
-{
-    DMAMAP_FUNC(pciio_dmamap, dmamap_free)
-	(CAST_DMAMAP(pciio_dmamap));
-}
-
-iopaddr_t
-pciio_dmamap_addr(pciio_dmamap_t pciio_dmamap,	/* use these mapping resources */
-		  paddr_t paddr,	/* map for this address */
-		  size_t byte_count)
-{					/* map this many bytes */
-    return DMAMAP_FUNC(pciio_dmamap, dmamap_addr)
-	(CAST_DMAMAP(pciio_dmamap), paddr, byte_count);
-}
-
-void
-pciio_dmamap_done(pciio_dmamap_t pciio_dmamap)
-{
-    DMAMAP_FUNC(pciio_dmamap, dmamap_done)
-	(CAST_DMAMAP(pciio_dmamap));
-}
-
-iopaddr_t
-pciio_dmatrans_addr(vertex_hdl_t dev,	/* translate for this device */
-		    device_desc_t dev_desc,	/* device descriptor */
-		    paddr_t paddr,	/* system physical address */
-		    size_t byte_count,	/* length */
-		    unsigned flags)
-{					/* defined in dma.h */
-    return DEV_FUNC(dev, dmatrans_addr)
-	(dev, dev_desc, paddr, byte_count, flags);
-}
-
-iopaddr_t
-pciio_dma_addr(vertex_hdl_t dev,	/* translate for this device */
-	       device_desc_t dev_desc,	/* device descriptor */
-	       paddr_t paddr,		/* system physical address */
-	       size_t byte_count,	/* length */
-	       pciio_dmamap_t *mapp,	/* map to use, then map we used */
-	       unsigned flags)
-{					/* PIO flags */
-    pciio_dmamap_t          map = 0;
-    int			    errfree = 0;
-    iopaddr_t               res;
-
-    if (mapp) {
-	map = *mapp;			/* possible pre-allocated map */
-	*mapp = 0;			/* record "no map used" */
-    }
-
-    res = pciio_dmatrans_addr
-	(dev, dev_desc, paddr, byte_count, flags);
-    if (res)
-	return res;			/* pciio_dmatrans worked */
-
-    if (!map) {
-	map = pciio_dmamap_alloc
-	    (dev, dev_desc, byte_count, flags);
-	if (!map)
-	    return res;			/* pciio_dmamap_alloc failed */
-	errfree = 1;
-    }
-
-    res = pciio_dmamap_addr
-	(map, paddr, byte_count);
-    if (!res) {
-	if (errfree)
-	    pciio_dmamap_free(map);
-	return res;			/* pciio_dmamap_addr failed */
-    }
-    if (mapp)
-	*mapp = map;			/* pass back map used */
-
-    return res;				/* pciio_dmamap_addr succeeded */
-}
-
-void
-pciio_dmamap_drain(pciio_dmamap_t map)
-{
-    DMAMAP_FUNC(map, dmamap_drain)
-	(CAST_DMAMAP(map));
-}
-
-void
-pciio_dmaaddr_drain(vertex_hdl_t dev, paddr_t addr, size_t size)
-{
-    DEV_FUNC(dev, dmaaddr_drain)
-	(dev, addr, size);
-}
-
-/* =====================================================================
- *          INTERRUPT MANAGEMENT
- *
- *      Allow crosstalk devices to establish interrupts
- */
-
-/*
- * Allocate resources required for an interrupt as specified in intr_desc.
- * Return resource handle in intr_hdl.
- */
-pciio_intr_t
-pciio_intr_alloc(vertex_hdl_t dev,	/* which Crosstalk device */
-		 device_desc_t dev_desc,	/* device descriptor */
-		 pciio_intr_line_t lines,	/* INTR line(s) to attach */
-		 vertex_hdl_t owner_dev)
-{					/* owner of this interrupt */
-    return (pciio_intr_t) DEV_FUNC(dev, intr_alloc)
-	(dev, dev_desc, lines, owner_dev);
-}
-
-/*
- * Free resources consumed by intr_alloc.
- */
-void
-pciio_intr_free(pciio_intr_t intr_hdl)
-{
-    INTR_FUNC(intr_hdl, intr_free)
-	(CAST_INTR(intr_hdl));
-}
-
-/*
- * Associate resources allocated with a previous pciio_intr_alloc call with the
- * described handler, arg, name, etc.
- *
- * Returns 0 on success, returns <0 on failure.
- */
-int
-pciio_intr_connect(pciio_intr_t intr_hdl,
-		intr_func_t intr_func, intr_arg_t intr_arg)	/* pciio intr resource handle */
-{
-    return INTR_FUNC(intr_hdl, intr_connect)
-	(CAST_INTR(intr_hdl), intr_func, intr_arg);
-}
-
-/*
- * Disassociate handler with the specified interrupt.
- */
-void
-pciio_intr_disconnect(pciio_intr_t intr_hdl)
-{
-    INTR_FUNC(intr_hdl, intr_disconnect)
-	(CAST_INTR(intr_hdl));
-}
-
-/*
- * Return a hwgraph vertex that represents the CPU currently
- * targeted by an interrupt.
- */
-vertex_hdl_t
-pciio_intr_cpu_get(pciio_intr_t intr_hdl)
-{
-    return INTR_FUNC(intr_hdl, intr_cpu_get)
-	(CAST_INTR(intr_hdl));
-}
-
-void
-pciio_slot_func_to_name(char		       *name,
-			pciio_slot_t		slot,
-			pciio_function_t	func)
-{
-    /*
-     * standard connection points:
-     *
-     * PCIIO_SLOT_NONE:	.../pci/direct
-     * PCIIO_FUNC_NONE: .../pci/<SLOT>			ie. .../pci/3
-     * multifunction:   .../pci/<SLOT><FUNC>		ie. .../pci/3c
-     */
-
-    if (slot == PCIIO_SLOT_NONE)
-	sprintf(name, EDGE_LBL_DIRECT);
-    else if (func == PCIIO_FUNC_NONE)
-	sprintf(name, "%d", slot);
-    else
-	sprintf(name, "%d%c", slot, 'a'+func);
-}
-
-/*
- * pciio_cardinfo_get
- *
- * Get the pciio info structure corresponding to the
- * specified PCI "slot" (we like it when the same index
- * number is used for the PCI IDSEL, the REQ/GNT pair,
- * and the interrupt line being used for INTA. We like
- * it so much we call it the slot number).
- */
-static pciio_info_t
-pciio_cardinfo_get(
-		      vertex_hdl_t pciio_vhdl,
-		      pciio_slot_t pci_slot)
-{
-    char                    namebuf[16];
-    pciio_info_t	    info = 0;
-    vertex_hdl_t	    conn;
-
-    pciio_slot_func_to_name(namebuf, pci_slot, PCIIO_FUNC_NONE);
-    if (GRAPH_SUCCESS ==
-	hwgraph_traverse(pciio_vhdl, namebuf, &conn)) {
-	info = pciio_info_chk(conn);
-	hwgraph_vertex_unref(conn);
-    }
-
-    return info;
-}
-
-
-/*
- * pciio_error_handler:
- * dispatch an error to the appropriate
- * pciio connection point, or process
- * it as a generic pci error.
- * Yes, the first parameter is the
- * provider vertex at the middle of
- * the bus; we get to the pciio connect
- * point using the ioerror widgetdev field.
- *
- * This function is called by the
- * specific PCI provider, after it has figured
- * out where on the PCI bus (including which slot,
- * if it can tell) the error came from.
- */
-/*ARGSUSED */
-int
-pciio_error_handler(
-		       vertex_hdl_t pciio_vhdl,
-		       int error_code,
-		       ioerror_mode_t mode,
-		       ioerror_t *ioerror)
-{
-    pciio_info_t            pciio_info;
-    vertex_hdl_t            pconn_vhdl;
-    pciio_slot_t            slot;
-
-    int                     retval;
-
-#if DEBUG && ERROR_DEBUG
-    printk("%v: pciio_error_handler\n", pciio_vhdl);
-#endif
-
-    IOERR_PRINTF(printk(KERN_NOTICE "%v: PCI Bus Error: Error code: %d Error mode: %d\n",
-			 pciio_vhdl, error_code, mode));
-
-    /* If there is an error handler sitting on
-     * the "no-slot" connection point, give it
-     * first crack at the error. NOTE: it is
-     * quite possible that this function may
-     * do further refining of the ioerror.
-     */
-    pciio_info = pciio_cardinfo_get(pciio_vhdl, PCIIO_SLOT_NONE);
-    if (pciio_info && pciio_info->c_efunc) {
-	pconn_vhdl = pciio_info_dev_get(pciio_info);
-
-	retval = pciio_info->c_efunc
-	    (pciio_info->c_einfo, error_code, mode, ioerror);
-	if (retval != IOERROR_UNHANDLED)
-	    return retval;
-    }
-
-    /* Is the error associated with a particular slot?
-     */
-    if (IOERROR_FIELDVALID(ioerror, widgetdev)) {
-	short widgetdev;
-	/*
-	 * NOTE : 
-	 * widgetdev is a 4byte value encoded as slot in the higher order
-	 * 2 bytes and function in the lower order 2 bytes.
-	 */
-	IOERROR_GETVALUE(widgetdev, ioerror, widgetdev);
-	slot = pciio_widgetdev_slot_get(widgetdev);
-
-	/* If this slot has an error handler,
-	 * deliver the error to it.
-	 */
-	pciio_info = pciio_cardinfo_get(pciio_vhdl, slot);
-	if (pciio_info != NULL) {
-	    if (pciio_info->c_efunc != NULL) {
-
-		pconn_vhdl = pciio_info_dev_get(pciio_info);
-
-		retval = pciio_info->c_efunc
-		    (pciio_info->c_einfo, error_code, mode, ioerror);
-		if (retval != IOERROR_UNHANDLED)
-		    return retval;
-	    }
-	}
-    }
-
-    return (mode == MODE_DEVPROBE)
-	? IOERROR_HANDLED	/* probes are OK */
-	: IOERROR_UNHANDLED;	/* otherwise, foo! */
-}
-
-/* =====================================================================
- *          CONFIGURATION MANAGEMENT
- */
-
-/*
- * Startup a crosstalk provider
- */
-void
-pciio_provider_startup(vertex_hdl_t pciio_provider)
-{
-    DEV_FUNC(pciio_provider, provider_startup)
-	(pciio_provider);
-}
-
-/*
- * Shutdown a crosstalk provider
- */
-void
-pciio_provider_shutdown(vertex_hdl_t pciio_provider)
-{
-    DEV_FUNC(pciio_provider, provider_shutdown)
-	(pciio_provider);
-}
-
-/*
- * Read value of configuration register
- */
-uint64_t
-pciio_config_get(vertex_hdl_t	dev,
-		 unsigned	reg,
-		 unsigned	size)
-{
-    uint64_t	value = 0;
-    unsigned	shift = 0;
-
-    /* handle accesses that cross words here,
-     * since that's common code between all
-     * possible providers.
-     */
-    while (size > 0) {
-	unsigned	biw = 4 - (reg&3);
-	if (biw > size)
-	    biw = size;
-
-	value |= DEV_FUNC(dev, config_get)
-	    (dev, reg, biw) << shift;
-
-	shift += 8*biw;
-	reg += biw;
-	size -= biw;
-    }
-    return value;
-}
-
-/*
- * Change value of configuration register
- */
-void
-pciio_config_set(vertex_hdl_t	dev,
-		 unsigned	reg,
-		 unsigned	size,
-		 uint64_t	value)
-{
-    /* handle accesses that cross words here,
-     * since that's common code between all
-     * possible providers.
-     */
-    while (size > 0) {
-	unsigned	biw = 4 - (reg&3);
-	if (biw > size)
-	    biw = size;
-	    
-	DEV_FUNC(dev, config_set)
-	    (dev, reg, biw, value);
-	reg += biw;
-	size -= biw;
-	value >>= biw * 8;
-    }
-}
-
-/* =====================================================================
- *          GENERIC PCI SUPPORT FUNCTIONS
- */
-
-/*
- * Issue a hardware reset to a card.
- */
-int
-pciio_reset(vertex_hdl_t dev)
-{
-    return DEV_FUNC(dev, reset) (dev);
-}
-
-/****** Generic pci slot information interfaces ******/
-
-pciio_info_t
-pciio_info_chk(vertex_hdl_t pciio)
-{
-    arbitrary_info_t        ainfo = 0;
-
-    hwgraph_info_get_LBL(pciio, INFO_LBL_PCIIO, &ainfo);
-    return (pciio_info_t) ainfo;
-}
-
-pciio_info_t
-pciio_info_get(vertex_hdl_t pciio)
-{
-    pciio_info_t            pciio_info;
-
-    pciio_info = (pciio_info_t) hwgraph_fastinfo_get(pciio);
-
-    if ((pciio_info != NULL) &&
-        (pciio_info->c_fingerprint != pciio_info_fingerprint)
-        && (pciio_info->c_fingerprint != NULL)) {
-
-        return((pciio_info_t)-1); /* Should panic .. */
-    }
-
-    return pciio_info;
-}
-
-void
-pciio_info_set(vertex_hdl_t pciio, pciio_info_t pciio_info)
-{
-    if (pciio_info != NULL)
-	pciio_info->c_fingerprint = pciio_info_fingerprint;
-    hwgraph_fastinfo_set(pciio, (arbitrary_info_t) pciio_info);
-
-    /* Also, mark this vertex as a PCI slot
-     * and use the pciio_info, so pciio_info_chk
-     * can work (and be fairly efficient).
-     */
-    hwgraph_info_add_LBL(pciio, INFO_LBL_PCIIO,
-			 (arbitrary_info_t) pciio_info);
-}
-
-vertex_hdl_t
-pciio_info_dev_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_vertex);
-}
-
-/*ARGSUSED*/
-pciio_bus_t
-pciio_info_bus_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_bus);
-}
-
-pciio_slot_t
-pciio_info_slot_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_slot);
-}
-
-pciio_function_t
-pciio_info_function_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_func);
-}
-
-pciio_vendor_id_t
-pciio_info_vendor_id_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_vendor);
-}
-
-pciio_device_id_t
-pciio_info_device_id_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_device);
-}
-
-vertex_hdl_t
-pciio_info_master_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_master);
-}
-
-arbitrary_info_t
-pciio_info_mfast_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_mfast);
-}
-
-pciio_provider_t       *
-pciio_info_pops_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_pops);
-}
-
-/* =====================================================================
- *          GENERIC PCI INITIALIZATION FUNCTIONS
- */
-
-/*
- *    pciioattach: called for each vertex in the graph
- *      that is a PCI provider.
- */
-/*ARGSUSED */
-int
-pciio_attach(vertex_hdl_t pciio)
-{
-#if DEBUG && ATTACH_DEBUG
-    char devname[MAXDEVNAME];
-    printk("%s: pciio_attach\n", vertex_to_name(pciio, devname, MAXDEVNAME));
-#endif
-    return 0;
-}
-
-/*
- * Associate a set of pciio_provider functions with a vertex.
- */
-void
-pciio_provider_register(vertex_hdl_t provider, pciio_provider_t *pciio_fns)
-{
-    hwgraph_info_add_LBL(provider, INFO_LBL_PFUNCS, (arbitrary_info_t) pciio_fns);
-}
-
-/*
- * Disassociate a set of pciio_provider functions with a vertex.
- */
-void
-pciio_provider_unregister(vertex_hdl_t provider)
-{
-    arbitrary_info_t        ainfo;
-
-    hwgraph_info_remove_LBL(provider, INFO_LBL_PFUNCS, (long *) &ainfo);
-}
-
-/*
- * Obtain a pointer to the pciio_provider functions for a specified Crosstalk
- * provider.
- */
-pciio_provider_t       *
-pciio_provider_fns_get(vertex_hdl_t provider)
-{
-    arbitrary_info_t        ainfo = 0;
-
-    (void) hwgraph_info_get_LBL(provider, INFO_LBL_PFUNCS, &ainfo);
-    return (pciio_provider_t *) ainfo;
-}
-
-pciio_info_t
-pciio_device_info_new(
-		pciio_info_t pciio_info,
-		vertex_hdl_t master,
-		pciio_slot_t slot,
-		pciio_function_t func,
-		pciio_vendor_id_t vendor_id,
-		pciio_device_id_t device_id)
-{
-    if (!pciio_info) {
-	pciio_info = kmalloc(sizeof (*(pciio_info)), GFP_KERNEL);
-	if ( pciio_info )
-		memset(pciio_info, 0, sizeof (*(pciio_info)));
-	else {
-		printk(KERN_WARNING "pciio_device_info_new(): Unable to "
- 			"allocate memory\n");
- 		return NULL;
-	}
-    }
-    pciio_info->c_slot = slot;
-    pciio_info->c_func = func;
-    pciio_info->c_vendor = vendor_id;
-    pciio_info->c_device = device_id;
-    pciio_info->c_master = master;
-    pciio_info->c_mfast = hwgraph_fastinfo_get(master);
-    pciio_info->c_pops = pciio_provider_fns_get(master);
-    pciio_info->c_efunc = 0;
-    pciio_info->c_einfo = 0;
-
-    return pciio_info;
-}
-
-void
-pciio_device_info_free(pciio_info_t pciio_info)
-{
-    /* NOTE : pciio_info is a structure within the pcibr_info
-     *	      and not a pointer to memory allocated on the heap !!
-     */
-    memset((char *)pciio_info, 0, sizeof(pciio_info));
-}
-
-vertex_hdl_t
-pciio_device_info_register(
-		vertex_hdl_t connectpt,		/* vertex at center of bus */
-		pciio_info_t pciio_info)	/* details about the connectpt */
-{
-    char		name[32];
-    vertex_hdl_t	pconn;
-    int device_master_set(vertex_hdl_t, vertex_hdl_t);
-
-    pciio_slot_func_to_name(name,
-			    pciio_info->c_slot,
-			    pciio_info->c_func);
-
-    if (GRAPH_SUCCESS !=
-	hwgraph_path_add(connectpt, name, &pconn))
-	return pconn;
-
-    pciio_info->c_vertex = pconn;
-    pciio_info_set(pconn, pciio_info);
-
-    /*
-     * create link to our pci provider
-     */
-
-    device_master_set(pconn, pciio_info->c_master);
-    return pconn;
-}
-
-void
-pciio_device_info_unregister(vertex_hdl_t connectpt,
-			     pciio_info_t pciio_info)
-{
-    char		name[32];
-    vertex_hdl_t	pconn = NULL;
-
-    if (!pciio_info)
-	return;
-
-    pciio_slot_func_to_name(name,
-			    pciio_info->c_slot,
-			    pciio_info->c_func);
-
-    pciio_info_set(pconn,0);
-
-    hwgraph_vertex_unref(pconn);
-    hwgraph_vertex_destroy(pconn);
-}
-
-/*ARGSUSED */
-int
-pciio_device_attach(vertex_hdl_t pconn,
-		    int          drv_flags)
-{
-    pciio_info_t            pciio_info;
-    pciio_vendor_id_t       vendor_id;
-    pciio_device_id_t       device_id;
-
-
-    pciio_info = pciio_info_get(pconn);
-
-    vendor_id = pciio_info->c_vendor;
-    device_id = pciio_info->c_device;
-
-    /* we don't start attaching things until
-     * all the driver init routines (including
-     * pciio_init) have been called; so we
-     * can assume here that we have a registry.
-     */
-
-    return(cdl_add_connpt(vendor_id, device_id, pconn, drv_flags));
-}
-
-int
-pciio_device_detach(vertex_hdl_t pconn,
-		    int          drv_flags)
-{
-    return(0);
-}
-
-/*
- * Allocate space from the specified PCI window mapping resource.  On
- * success record information about the allocation in the supplied window
- * allocation cookie (if non-NULL) and return the address of the allocated
- * window.  On failure return NULL.
- *
- * The "size" parameter is usually from a PCI device's Base Address Register
- * (BAR) decoder.  As such, the allocation must be aligned to be a multiple of
- * that.  The "align" parameter acts as a ``minimum alignment'' allocation
- * constraint.  The alignment contraint reflects system or device addressing
- * restrictions such as the inability to share higher level ``windows''
- * between devices, etc.  The returned PCI address allocation will be a
- * multiple of the alignment constraint both in alignment and size.  Thus, the
- * returned PCI address block is aligned to the maximum of the requested size
- * and alignment.
- */
-iopaddr_t
-pciio_device_win_alloc(struct resource *root_resource,
-		       pciio_win_alloc_t win_alloc,
-		       size_t start, size_t size, size_t align)
-{
-
-	struct resource *new_res;
-	int status;
-
-	new_res = (struct resource *) kmalloc( sizeof(struct resource), GFP_KERNEL);
-	if (!new_res)
-		return 0;
-
-	if (start > 0) {
-		status = allocate_resource( root_resource, new_res,
-			size, start /* Min start addr. */,
-			(start + size) - 1, 1,
-			NULL, NULL);
-	} else {
-		if (size > align)
-			align = size;
-		status = allocate_resource( root_resource, new_res,
-				    size, align /* Min start addr. */,
-				    root_resource->end, align,
-				    NULL, NULL);
-	}
-
-	if (status) {
-		kfree(new_res);
-		return((iopaddr_t) NULL);
-	}
-
-	/*
-	 * If a window allocation cookie has been supplied, use it to keep
-	 * track of all the allocated space assigned to this window.
-	 */
-	if (win_alloc) {
-		win_alloc->wa_resource = new_res;
-		win_alloc->wa_base = new_res->start;
-		win_alloc->wa_pages = size;
-	}
-
-	return new_res->start;
-}
-
-/*
- * Free the specified window allocation back into the PCI window mapping
- * resource.  As noted above, we keep page addresses offset by 1 ...
- */
-void
-pciio_device_win_free(pciio_win_alloc_t win_alloc)
-{
-	int status;
-
-	if (win_alloc->wa_resource) {
-		status = release_resource(win_alloc->wa_resource);
-		if (!status)
-			kfree(win_alloc->wa_resource);
-		else
-			BUG();
-	}
-}
-
-/*
- * pciio_error_register:
- * arrange for a function to be called with
- * a specified first parameter plus other
- * information when an error is encountered
- * and traced to the pci slot corresponding
- * to the connection point pconn.
- *
- * may also be called with a null function
- * pointer to "unregister" the error handler.
- *
- * NOTE: subsequent calls silently overwrite
- * previous data for this vertex. We assume that
- * cooperating drivers, well, cooperate ...
- */
-void
-pciio_error_register(vertex_hdl_t pconn,
-		     error_handler_f *efunc,
-		     error_handler_arg_t einfo)
-{
-    pciio_info_t            pciio_info;
-
-    pciio_info = pciio_info_get(pconn);
-    ASSERT(pciio_info != NULL);
-    pciio_info->c_efunc = efunc;
-    pciio_info->c_einfo = einfo;
-}
-
-/*
- * Check if any device has been found in this slot, and return
- * true or false
- * vhdl is the vertex for the slot
- */
-int
-pciio_slot_inuse(vertex_hdl_t pconn_vhdl)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-
-    ASSERT(pciio_info);
-    ASSERT(pciio_info->c_vertex == pconn_vhdl);
-    if (pciio_info->c_vendor) {
-	/*
-	 * Non-zero value for vendor indicate
-	 * a board being found in this slot.
-	 */
-	return 1;
-    }
-    return 0;
-}
-
-int
-pciio_info_type1_get(pciio_info_t pci_info)
-{
-	return (pci_info->c_type1);
-}
diff -Nru a/arch/ia64/sn/io/sn2/pic.c b/arch/ia64/sn/io/sn2/pic.c
--- a/arch/ia64/sn/io/sn2/pic.c	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,835 +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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/interrupt.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/pci/pic.h>
-#include <asm/sn/sn_private.h>
-
-extern struct file_operations pcibr_fops;
-extern pcibr_list_p	pcibr_list;
-
-static int		pic_attach2(vertex_hdl_t, void *, vertex_hdl_t,
- 				int, pcibr_soft_t *);
-
-extern int		isIO9(nasid_t);
-extern char	       *dev_to_name(vertex_hdl_t dev, char *buf, uint buflen);
-extern int		pcibr_widget_to_bus(vertex_hdl_t pcibr_vhdl);
-extern pcibr_hints_t	pcibr_hints_get(vertex_hdl_t, int);
-extern unsigned		pcibr_intr_bits(pciio_info_t info,
-				pciio_intr_line_t lines, int nslots);
-extern void		pcibr_setwidint(xtalk_intr_t);
-extern int		pcibr_error_handler_wrapper(error_handler_arg_t, int,
-				ioerror_mode_t, ioerror_t *);
-extern void		pcibr_error_intr_handler(intr_arg_t);
-extern void		pcibr_directmap_init(pcibr_soft_t);
-extern int		pcibr_slot_info_init(vertex_hdl_t,pciio_slot_t);
-extern int		pcibr_slot_addr_space_init(vertex_hdl_t,pciio_slot_t);
-extern int		pcibr_slot_device_init(vertex_hdl_t, pciio_slot_t);
-extern int		pcibr_slot_pcix_rbar_init(pcibr_soft_t, pciio_slot_t);
-extern int		pcibr_slot_guest_info_init(vertex_hdl_t,pciio_slot_t);
-extern int		pcibr_slot_call_device_attach(vertex_hdl_t,
-				pciio_slot_t, int);
-extern void		pcibr_rrb_alloc_init(pcibr_soft_t, int, int, int);
-extern int		pcibr_pcix_rbars_calc(pcibr_soft_t);
-extern pcibr_info_t	pcibr_device_info_new(pcibr_soft_t, pciio_slot_t,
-				pciio_function_t, pciio_vendor_id_t,
-				pciio_device_id_t);
-extern int		pcibr_initial_rrb(vertex_hdl_t, pciio_slot_t, 
-				pciio_slot_t);
-extern void		xwidget_error_register(vertex_hdl_t, error_handler_f *,
-				error_handler_arg_t);
-extern void		pcibr_clearwidint(pcibr_soft_t);
-
-
-
-/*
- * copy xwidget_info_t from conn_v to peer_conn_v
- */
-static int
-pic_bus1_widget_info_dup(vertex_hdl_t conn_v, vertex_hdl_t peer_conn_v,
-					cnodeid_t xbow_peer, char *peer_path)
-{
-	xwidget_info_t widget_info, peer_widget_info;
-	vertex_hdl_t peer_hubv;
-	hubinfo_t peer_hub_info;
-
-	/* get the peer hub's widgetid */
-	peer_hubv = NODEPDA(xbow_peer)->node_vertex;
-	peer_hub_info = NULL;
-	hubinfo_get(peer_hubv, &peer_hub_info);
-	if (peer_hub_info == NULL)
-		return 0;
-
-	if (hwgraph_info_get_LBL(conn_v, INFO_LBL_XWIDGET,
-			(arbitrary_info_t *)&widget_info) == GRAPH_SUCCESS) {
-		peer_widget_info = kmalloc(sizeof (*(peer_widget_info)), GFP_KERNEL);
-		if ( !peer_widget_info ) {
-			return -ENOMEM;
-		}
-		memset(peer_widget_info, 0, sizeof (*(peer_widget_info)));
-
-		peer_widget_info->w_fingerprint = widget_info_fingerprint;
-    		peer_widget_info->w_vertex = peer_conn_v;
-    		peer_widget_info->w_id = widget_info->w_id;
-    		peer_widget_info->w_master = peer_hubv;
-    		peer_widget_info->w_masterid = peer_hub_info->h_widgetid;
-		/* structure copy */
-    		peer_widget_info->w_hwid = widget_info->w_hwid;
-    		peer_widget_info->w_efunc = 0;
-    		peer_widget_info->w_einfo = 0;
-		peer_widget_info->w_name = kmalloc(strlen(peer_path) + 1, GFP_KERNEL);
-		if (!peer_widget_info->w_name) {
-			kfree(peer_widget_info);
-			return -ENOMEM;
-		}
-		strcpy(peer_widget_info->w_name, peer_path);
-
-		if (hwgraph_info_add_LBL(peer_conn_v, INFO_LBL_XWIDGET,
-			(arbitrary_info_t)peer_widget_info) != GRAPH_SUCCESS) {
-			kfree(peer_widget_info->w_name);
-				kfree(peer_widget_info);
-				return 0;
-		}
-
-		xwidget_info_set(peer_conn_v, peer_widget_info);
-
-		return 1;
-	}
-
-	printk("pic_bus1_widget_info_dup: "
-			"cannot get INFO_LBL_XWIDGET from 0x%lx\n", (uint64_t)conn_v);
-	return 0;
-}
-
-/*
- * If this PIC is attached to two Cbricks ("dual-ported") then
- * attach each bus to opposite Cbricks.
- *
- * If successful, return a new vertex suitable for attaching the PIC bus.
- * If not successful, return zero and both buses will attach to the
- * vertex passed into pic_attach().
- */
-static vertex_hdl_t
-pic_bus1_redist(nasid_t nasid, vertex_hdl_t conn_v)
-{
-	cnodeid_t cnode = nasid_to_cnodeid(nasid);
-	cnodeid_t xbow_peer = -1;
-	char pathname[256], peer_path[256], tmpbuf[256];
-	char *p;
-	int rc;
-	vertex_hdl_t peer_conn_v, hubv;
-	int pos;
-	slabid_t slab;
-
-	if (NODEPDA(cnode)->xbow_peer >= 0) {			/* if dual-ported */
-		/* create a path for this widget on the peer Cbrick */
-		/* pcibr widget hw/module/001c11/slab/0/Pbrick/xtalk/12 */
-		/* sprintf(pathname, "%v", conn_v); */
-		xbow_peer = nasid_to_cnodeid(NODEPDA(cnode)->xbow_peer);
-		pos = hwgfs_generate_path(conn_v, tmpbuf, 256);
-		strcpy(pathname, &tmpbuf[pos]);
-		p = pathname + strlen("hw/module/001c01/slab/0/");
-
-		memset(tmpbuf, 0, 16);
-		format_module_id(tmpbuf, geo_module((NODEPDA(xbow_peer))->geoid), MODULE_FORMAT_BRIEF);
-		slab = geo_slab((NODEPDA(xbow_peer))->geoid);
-		sprintf(peer_path, "module/%s/slab/%d/%s", tmpbuf, (int)slab, p); 
-		
-		/* Look for vertex for this widget on the peer Cbrick.
-		 * Expect GRAPH_NOT_FOUND.
-		 */
-		rc = hwgraph_traverse(hwgraph_root, peer_path, &peer_conn_v);
-		if (GRAPH_SUCCESS == rc)
-			printk("pic_attach: found unexpected vertex: 0x%lx\n",
-								(uint64_t)peer_conn_v);
-		else if (GRAPH_NOT_FOUND != rc) {
-			printk("pic_attach: hwgraph_traverse unexpectedly"
-					" returned 0x%x\n", rc);
-		} else {
-			/* try to add the widget vertex to the peer Cbrick */
-			rc = hwgraph_path_add(hwgraph_root, peer_path, &peer_conn_v);
-
-			if (GRAPH_SUCCESS != rc)
-			    printk("pic_attach: hwgraph_path_add"
-						" failed with 0x%x\n", rc);
-			else {
-			    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v,
-					"pic_bus1_redist: added vertex %v\n", peer_conn_v)); 
-
-			    /* Now hang appropiate stuff off of the new
-			     * vertex.	We bail out if we cannot add something.
-			     * In that case, we don't remove the newly added
-			     * vertex but that should be safe and we don't
-			     * really expect the additions to fail anyway.
-			     */
-			    if (!pic_bus1_widget_info_dup(conn_v, peer_conn_v, 
-							  xbow_peer, peer_path))
-					return 0;
-
-			    hubv = cnodeid_to_vertex(xbow_peer);
-			    ASSERT(hubv != GRAPH_VERTEX_NONE);
-			    device_master_set(peer_conn_v, hubv);
-			    xtalk_provider_register(hubv, &hub_provider);
-			    xtalk_provider_startup(hubv);
-			    return peer_conn_v;
-			}
-		}
-	}
-	return 0;
-}
-
-/*
- * PIC has two buses under a single widget.  pic_attach() calls pic_attach2()
- * to attach each of those buses.
- */
-int
-pic_attach(vertex_hdl_t conn_v)
-{
-	int		rc;
-	void	*bridge0, *bridge1 = (void *)0;
-	vertex_hdl_t	pcibr_vhdl0, pcibr_vhdl1 = (vertex_hdl_t)0;
-	pcibr_soft_t	bus0_soft, bus1_soft = (pcibr_soft_t)0;
-	vertex_hdl_t  conn_v0, conn_v1, peer_conn_v;
-	int		bricktype;
-	int		iobrick_type_get_nasid(nasid_t nasid);
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v, "pic_attach()\n"));
-
-	bridge0 = pcibr_bridge_ptr_get(conn_v, 0);
-	bridge1 = pcibr_bridge_ptr_get(conn_v, 1);
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v,
-		    "pic_attach: bridge0=0x%lx, bridge1=0x%lx\n", 
-		    bridge0, bridge1));
-
-	conn_v0 = conn_v1 = conn_v;
-
-	/* If dual-ported then split the two PIC buses across both Cbricks */
-	peer_conn_v = pic_bus1_redist(NASID_GET(bridge0), conn_v);
-	if (peer_conn_v)
-		conn_v1 = peer_conn_v;
-
-	/*
-	 * Create the vertex for the PCI buses, which we
-	 * will also use to hold the pcibr_soft and
-	 * which will be the "master" vertex for all the
-	 * pciio connection points we will hang off it.
-	 * This needs to happen before we call nic_bridge_vertex_info
-	 * as we are some of the *_vmc functions need access to the edges.
-	 *
-	 * Opening this vertex will provide access to
-	 * the Bridge registers themselves.
-	 */
-	bricktype = iobrick_type_get_nasid(NASID_GET(bridge0));
-	if ( bricktype == MODULE_CGBRICK ) {
-		rc = hwgraph_path_add(conn_v0, EDGE_LBL_AGP_0, &pcibr_vhdl0);
-		ASSERT(rc == GRAPH_SUCCESS);
-		rc = hwgraph_path_add(conn_v1, EDGE_LBL_AGP_1, &pcibr_vhdl1);
-		ASSERT(rc == GRAPH_SUCCESS);
-	} else {
-		rc = hwgraph_path_add(conn_v0, EDGE_LBL_PCIX_0, &pcibr_vhdl0);
-		ASSERT(rc == GRAPH_SUCCESS);
-		rc = hwgraph_path_add(conn_v1, EDGE_LBL_PCIX_1, &pcibr_vhdl1);
-		ASSERT(rc == GRAPH_SUCCESS);
-	}
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v,
-		    "pic_attach: pcibr_vhdl0=0x%lx, pcibr_vhdl1=0x%lx\n",
-		    pcibr_vhdl0, pcibr_vhdl1));
-
-	/* register pci provider array */
-	pciio_provider_register(pcibr_vhdl0, &pci_pic_provider);
-	pciio_provider_register(pcibr_vhdl1, &pci_pic_provider);
-
-	pciio_provider_startup(pcibr_vhdl0);
-	pciio_provider_startup(pcibr_vhdl1);
-
-	pic_attach2(conn_v0, bridge0, pcibr_vhdl0, 0, &bus0_soft);
-	pic_attach2(conn_v1, bridge1, pcibr_vhdl1, 1, &bus1_soft);
-
-	{
-	    /* If we're dual-ported finish duplicating the peer info structure.
-	     * The error handler and arg are done in pic_attach2().
-	     */
-	    xwidget_info_t info0, info1;
-		if (conn_v0 != conn_v1) {	/* dual ported */
-			info0 = xwidget_info_get(conn_v0);
-			info1 = xwidget_info_get(conn_v1);
-			if (info1->w_efunc == (error_handler_f *)NULL)
-				info1->w_efunc = info0->w_efunc;
-			if (info1->w_einfo == (error_handler_arg_t)0)
-				info1->w_einfo = bus1_soft;
-		}
-	}
-
-	/* save a pointer to the PIC's other bus's soft struct */
-        bus0_soft->bs_peers_soft = bus1_soft;
-        bus1_soft->bs_peers_soft = bus0_soft;
-
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v,
-		    "pic_attach: bus0_soft=0x%lx, bus1_soft=0x%lx\n",
-		    bus0_soft, bus1_soft));
-
-	return 0;
-}
-
-
-/*
- * PIC has two buses under a single widget.  pic_attach() calls pic_attach2()
- * to attach each of those buses.
- */
-static int
-pic_attach2(vertex_hdl_t xconn_vhdl, void *bridge,
-	      vertex_hdl_t pcibr_vhdl, int busnum, pcibr_soft_t *ret_softp)
-{
-    vertex_hdl_t	    ctlr_vhdl;
-    pcibr_soft_t	    pcibr_soft;
-    pcibr_info_t	    pcibr_info;
-    xwidget_info_t	    info;
-    xtalk_intr_t	    xtalk_intr;
-    pcibr_list_p	    self;
-    int			    entry, slot, ibit, i;
-    vertex_hdl_t	    noslot_conn;
-    char		    devnm[MAXDEVNAME], *s;
-    pcibr_hints_t	    pcibr_hints;
-    picreg_t		    id;
-    picreg_t		    int_enable;
-    picreg_t		    pic_ctrl_reg;
-
-    int			    iobrick_type_get_nasid(nasid_t nasid);
-    int			    iomoduleid_get(nasid_t nasid);
-    int			    irq;
-    int			    cpu;
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, pcibr_vhdl,
-		"pic_attach2: bridge=0x%lx, busnum=%d\n", bridge, busnum));
-
-    ctlr_vhdl = NULL;
-    ctlr_vhdl = hwgraph_register(pcibr_vhdl, EDGE_LBL_CONTROLLER, 0,
-		0, 0, 0,
-		S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
-		(struct file_operations *)&pcibr_fops, (void *)pcibr_vhdl);
-    ASSERT(ctlr_vhdl != NULL);
-
-    id = pcireg_bridge_id_get(bridge);
-    hwgraph_info_add_LBL(pcibr_vhdl, INFO_LBL_PCIBR_ASIC_REV,
-                         (arbitrary_info_t)XWIDGET_PART_REV_NUM(id));
-
-    /*
-     * Get the hint structure; if some NIC callback marked this vertex as
-     * "hands-off" then we just return here, before doing anything else.
-     */
-    pcibr_hints = pcibr_hints_get(xconn_vhdl, 0);
-
-    if (pcibr_hints && pcibr_hints->ph_hands_off)
-        return -1;
-
-    /* allocate soft structure to hang off the vertex.  Link the new soft
-     * structure to the pcibr_list linked list
-     */
-    pcibr_soft = kmalloc(sizeof (*(pcibr_soft)), GFP_KERNEL);
-    if ( !pcibr_soft )
-	return -ENOMEM;
-
-    self = kmalloc(sizeof (*(self)), GFP_KERNEL);
-    if ( !self ) {
-	kfree(pcibr_soft);
-	return -ENOMEM;
-    }
-    memset(pcibr_soft, 0, sizeof (*(pcibr_soft)));
-    memset(self, 0, sizeof (*(self)));
-
-    self->bl_soft = pcibr_soft;
-    self->bl_vhdl = pcibr_vhdl;
-    self->bl_next = pcibr_list;
-    pcibr_list = self;
-
-    if (ret_softp)
-        *ret_softp = pcibr_soft;
-
-    memset(pcibr_soft, 0, sizeof *pcibr_soft);
-    pcibr_soft_set(pcibr_vhdl, pcibr_soft);
-
-    s = dev_to_name(pcibr_vhdl, devnm, MAXDEVNAME);
-    pcibr_soft->bs_name = kmalloc(strlen(s) + 1, GFP_KERNEL);
-    if (!pcibr_soft->bs_name)
-	    return -ENOMEM;
-
-    strcpy(pcibr_soft->bs_name, s);
-
-    pcibr_soft->bs_conn = xconn_vhdl;
-    pcibr_soft->bs_vhdl = pcibr_vhdl;
-    pcibr_soft->bs_base = (void *)bridge;
-    pcibr_soft->bs_rev_num = XWIDGET_PART_REV_NUM(id);
-    pcibr_soft->bs_intr_bits = (pcibr_intr_bits_f *)pcibr_intr_bits;
-    pcibr_soft->bsi_err_intr = 0;
-    pcibr_soft->bs_min_slot = 0;
-    pcibr_soft->bs_max_slot = 3;
-    pcibr_soft->bs_busnum = busnum;
-    pcibr_soft->bs_bridge_type = PCIBR_BRIDGETYPE_PIC;
-    pcibr_soft->bs_int_ate_size = PIC_INTERNAL_ATES;
-    /* Make sure this is called after setting the bs_base and bs_bridge_type */
-    pcibr_soft->bs_bridge_mode = (pcireg_speed_get(pcibr_soft) << 1) |
-                                  pcireg_mode_get(pcibr_soft);
-
-    info = xwidget_info_get(xconn_vhdl);
-    pcibr_soft->bs_xid = xwidget_info_id_get(info);
-    pcibr_soft->bs_master = xwidget_info_master_get(info);
-    pcibr_soft->bs_mxid = xwidget_info_masterid_get(info);
-
-    strcpy(pcibr_soft->bs_asic_name, "PIC");
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, pcibr_vhdl,
-                "pic_attach2: pcibr_soft=0x%lx, mode=0x%x\n",
-                pcibr_soft, pcibr_soft->bs_bridge_mode));
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, pcibr_vhdl,
-                "pic_attach2: %s ASIC: rev %s (code=0x%x)\n",
-                pcibr_soft->bs_asic_name,
-                (IS_PIC_PART_REV_A(pcibr_soft->bs_rev_num)) ? "A" :
-                (IS_PIC_PART_REV_B(pcibr_soft->bs_rev_num)) ? "B" :
-                (IS_PIC_PART_REV_C(pcibr_soft->bs_rev_num)) ? "C" :
-                "unknown", pcibr_soft->bs_rev_num));
-
-    /* PV854845: Must clear write request buffer to avoid parity errors */
-    for (i=0; i < PIC_WR_REQ_BUFSIZE; i++) {
-        ((pic_t *)bridge)->p_wr_req_lower[i] = 0;
-        ((pic_t *)bridge)->p_wr_req_upper[i] = 0;
-        ((pic_t *)bridge)->p_wr_req_parity[i] = 0;
-    }
-
-    pcibr_soft->bs_nasid = NASID_GET(bridge);
-
-    pcibr_soft->bs_bricktype = iobrick_type_get_nasid(pcibr_soft->bs_nasid);
-    if (pcibr_soft->bs_bricktype < 0)
-        printk(KERN_WARNING "%s: bricktype was unknown by L1 (ret val = 0x%x)\n",
-                pcibr_soft->bs_name, pcibr_soft->bs_bricktype);
-
-    pcibr_soft->bs_moduleid = iomoduleid_get(pcibr_soft->bs_nasid);
-
-    if (pcibr_soft->bs_bricktype > 0) {
-        switch (pcibr_soft->bs_bricktype) {
-	case MODULE_PXBRICK:
-	case MODULE_IXBRICK:
-	case MODULE_OPUSBRICK:
-            pcibr_soft->bs_first_slot = 0;
-            pcibr_soft->bs_last_slot = 1;
-            pcibr_soft->bs_last_reset = 1;
-
-            /* Bus 1 of IXBrick has a IO9, so there are 4 devices, not 2 */
-	    if ((pcibr_widget_to_bus(pcibr_vhdl) == 1) 
-		    && isIO9(pcibr_soft->bs_nasid)) {
-                pcibr_soft->bs_last_slot = 3;
-                pcibr_soft->bs_last_reset = 3;
-            }
-            break;
-
-        case MODULE_CGBRICK:
-            pcibr_soft->bs_first_slot = 0;
-            pcibr_soft->bs_last_slot = 0;
-            pcibr_soft->bs_last_reset = 0;
-            break;
-
-        default:
-	    printk(KERN_WARNING "%s: Unknown bricktype: 0x%x\n",
-                    pcibr_soft->bs_name, pcibr_soft->bs_bricktype);
-            break;
-        }
-
-        PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, pcibr_vhdl,
-                    "pic_attach2: bricktype=%d, brickbus=%d, "
-		    "slots %d-%d\n", pcibr_soft->bs_bricktype,
-		    pcibr_widget_to_bus(pcibr_vhdl),
-                    pcibr_soft->bs_first_slot, pcibr_soft->bs_last_slot));
-    }
-
-    /*
-     * Initialize bridge and bus locks
-     */
-    spin_lock_init(&pcibr_soft->bs_lock);
-
-    /*
-     * If we have one, process the hints structure.
-     */
-    if (pcibr_hints) {
-        unsigned	rrb_fixed;
-        PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, pcibr_vhdl,
-                    "pic_attach2: pcibr_hints=0x%lx\n", pcibr_hints));
-
-        rrb_fixed = pcibr_hints->ph_rrb_fixed;
-
-        pcibr_soft->bs_rrb_fixed = rrb_fixed;
-
-        if (pcibr_hints->ph_intr_bits)
-            pcibr_soft->bs_intr_bits = pcibr_hints->ph_intr_bits;
-
-
-        for (slot = pcibr_soft->bs_min_slot;
-                                slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-            int hslot = pcibr_hints->ph_host_slot[slot] - 1;
-
-            if (hslot < 0) {
-                pcibr_soft->bs_slot[slot].host_slot = slot;
-            } else {
-                pcibr_soft->bs_slot[slot].has_host = 1;
-                pcibr_soft->bs_slot[slot].host_slot = hslot;
-            }
-        }
-    }
-
-    /*
-     * Set-up initial values for state fields
-     */
-    for (slot = pcibr_soft->bs_min_slot;
-                                slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-        pcibr_soft->bs_slot[slot].bss_devio.bssd_space = PCIIO_SPACE_NONE;
-        pcibr_soft->bs_slot[slot].bss_devio.bssd_ref_cnt = 0;
-        pcibr_soft->bs_slot[slot].bss_d64_base = PCIBR_D64_BASE_UNSET;
-        pcibr_soft->bs_slot[slot].bss_d32_base = PCIBR_D32_BASE_UNSET;
-        pcibr_soft->bs_rrb_valid_dflt[slot][VCHAN0] = -1;
-    }
-
-    for (ibit = 0; ibit < 8; ++ibit) {
-        pcibr_soft->bs_intr[ibit].bsi_xtalk_intr = 0;
-        pcibr_soft->bs_intr[ibit].bsi_pcibr_intr_wrap.iw_soft = pcibr_soft;
-        pcibr_soft->bs_intr[ibit].bsi_pcibr_intr_wrap.iw_list = NULL;
-        pcibr_soft->bs_intr[ibit].bsi_pcibr_intr_wrap.iw_ibit = ibit;
-        pcibr_soft->bs_intr[ibit].bsi_pcibr_intr_wrap.iw_hdlrcnt = 0;
-        pcibr_soft->bs_intr[ibit].bsi_pcibr_intr_wrap.iw_shared = 0;
-        pcibr_soft->bs_intr[ibit].bsi_pcibr_intr_wrap.iw_connected = 0;
-    }
-
-
-    /*
-     * connect up our error handler.  PIC has 2 busses (thus resulting in 2
-     * pcibr_soft structs under 1 widget), so only register a xwidget error
-     * handler for PIC's bus0.  NOTE: for PIC pcibr_error_handler_wrapper()
-     * is a wrapper routine we register that will call the real error handler
-     * pcibr_error_handler() with the correct pcibr_soft struct.
-     */
-    if (busnum == 0) {
-        xwidget_error_register(xconn_vhdl,
-                                pcibr_error_handler_wrapper, pcibr_soft);
-    }
-
-    /*
-     * Clear all pending interrupts.  Assume all interrupts are from slot 3
-     * until otherise setup.
-     */
-    pcireg_intr_reset_set(pcibr_soft, PIC_IRR_ALL_CLR);
-    pcireg_intr_device_set(pcibr_soft, 0x006db6db);
-
-    /* Setup the mapping register used for direct mapping */
-    pcibr_directmap_init(pcibr_soft);
-
-    /*
-     * Initialize the PICs control register.
-     */
-    pic_ctrl_reg = pcireg_control_get(pcibr_soft);
-
-    /* Bridges Requester ID: bus = busnum, dev = 0, func = 0 */
-    pic_ctrl_reg &= ~PIC_CTRL_BUS_NUM_MASK;
-    pic_ctrl_reg |= PIC_CTRL_BUS_NUM(busnum);
-    pic_ctrl_reg &= ~PIC_CTRL_DEV_NUM_MASK;
-    pic_ctrl_reg &= ~PIC_CTRL_FUN_NUM_MASK;
-
-    pic_ctrl_reg &= ~PIC_CTRL_NO_SNOOP;
-    pic_ctrl_reg &= ~PIC_CTRL_RELAX_ORDER;
-
-    /* enable parity checking on PICs internal RAM */
-    pic_ctrl_reg |= PIC_CTRL_PAR_EN_RESP;
-    pic_ctrl_reg |= PIC_CTRL_PAR_EN_ATE;
-
-    /* PIC BRINGUP WAR (PV# 862253): dont enable write request parity */
-    if (!PCIBR_WAR_ENABLED(PV862253, pcibr_soft)) {
-        pic_ctrl_reg |= PIC_CTRL_PAR_EN_REQ;
-    }
-
-    pic_ctrl_reg |= PIC_CTRL_PAGE_SIZE;
-
-    pcireg_control_set(pcibr_soft, pic_ctrl_reg);
-
-    /* Initialize internal mapping entries (ie. the ATEs) */
-    for (entry = 0; entry < pcibr_soft->bs_int_ate_size; entry++)
-	pcireg_int_ate_set(pcibr_soft, entry, 0);
-
-    pcibr_soft->bs_int_ate_resource.start = 0;
-    pcibr_soft->bs_int_ate_resource.end = pcibr_soft->bs_int_ate_size - 1;
-
-    /* Setup the PICs error interrupt handler. */
-    xtalk_intr = xtalk_intr_alloc(xconn_vhdl, (device_desc_t)0, pcibr_vhdl);
-
-    ASSERT(xtalk_intr != NULL);
-
-    irq = ((hub_intr_t)xtalk_intr)->i_bit;
-    cpu = ((hub_intr_t)xtalk_intr)->i_cpuid;
-
-    intr_unreserve_level(cpu, irq);
-    ((hub_intr_t)xtalk_intr)->i_bit = SGI_PCIBR_ERROR;
-    xtalk_intr->xi_vector = SGI_PCIBR_ERROR;
-
-    pcibr_soft->bsi_err_intr = xtalk_intr;
-
-    /*
-     * On IP35 with XBridge, we do some extra checks in pcibr_setwidint
-     * in order to work around some addressing limitations.  In order
-     * for that fire wall to work properly, we need to make sure we
-     * start from a known clean state.
-     */
-    pcibr_clearwidint(pcibr_soft);
-
-    xtalk_intr_connect(xtalk_intr,
-		       (intr_func_t) pcibr_error_intr_handler,
-		       (intr_arg_t) pcibr_soft,
-		       (xtalk_intr_setfunc_t) pcibr_setwidint,
-		       (void *) pcibr_soft);
-
-    request_irq(SGI_PCIBR_ERROR, (void *)pcibr_error_intr_handler, SA_SHIRQ, 
-			"PCIBR error", (intr_arg_t) pcibr_soft);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pcibr_vhdl,
-		"pcibr_setwidint: target_id=0x%lx, int_addr=0x%lx\n",
-		pcireg_intr_dst_target_id_get(pcibr_soft),
-		pcireg_intr_dst_addr_get(pcibr_soft)));
-
-    /* now we can start handling error interrupts */
-    int_enable = pcireg_intr_enable_get(pcibr_soft);
-    int_enable |= PIC_ISR_ERRORS;
-
-    /* PIC BRINGUP WAR (PV# 856864 & 856865): allow the tnums that are
-     * locked out to be freed up sooner (by timing out) so that the
-     * read tnums are never completely used up.
-     */
-    if (PCIBR_WAR_ENABLED(PV856864, pcibr_soft)) {
-	int_enable &= ~PIC_ISR_PCIX_REQ_TOUT;
-	int_enable &= ~PIC_ISR_XREAD_REQ_TIMEOUT;
-
-	pcireg_req_timeout_set(pcibr_soft, 0x750);
-    }
-
-    pcireg_intr_enable_set(pcibr_soft, int_enable);
-    pcireg_intr_mode_set(pcibr_soft, 0); /* dont send 'clear interrupt' pkts */
-    pcireg_tflush_get(pcibr_soft);       /* wait until Bridge PIO complete */
-
-    /*
-     * PIC BRINGUP WAR (PV# 856866, 859504, 861476, 861478): Don't use
-     * RRB0, RRB8, RRB1, and RRB9.  Assign them to DEVICE[2|3]--VCHAN3
-     * so they are not used.  This works since there is currently no
-     * API to penable VCHAN3.
-     */
-    if (PCIBR_WAR_ENABLED(PV856866, pcibr_soft)) {
-	pcireg_rrb_bit_set(pcibr_soft, 0, 0x000f000f);	/* even rrb reg */
-	pcireg_rrb_bit_set(pcibr_soft, 1, 0x000f000f);	/* odd rrb reg */
-    }
-
-    /* PIC only supports 64-bit direct mapping in PCI-X mode.  Since
-     * all PCI-X devices that initiate memory transactions must be
-     * capable of generating 64-bit addressed, we force 64-bit DMAs.
-     */
-    pcibr_soft->bs_dma_flags = 0;
-    if (IS_PCIX(pcibr_soft)) {
-	pcibr_soft->bs_dma_flags |= PCIIO_DMA_A64;
-    }
-
-    {
-
-    iopaddr_t		    prom_base_addr = pcibr_soft->bs_xid << 24;
-    int			    prom_base_size = 0x1000000;
-    int			    status;
-    struct resource	    *res;
-
-    /* Allocate resource maps based on bus page size; for I/O and memory
-     * space, free all pages except those in the base area and in the
-     * range set by the PROM.
-     *
-     * PROM creates BAR addresses in this format: 0x0ws00000 where w is
-     * the widget number and s is the device register offset for the slot.
-     */
-
-    /* Setup the Bus's PCI IO Root Resource. */
-    pcibr_soft->bs_io_win_root_resource.start = PCIBR_BUS_IO_BASE;
-    pcibr_soft->bs_io_win_root_resource.end = 0xffffffff;
-    res = (struct resource *) kmalloc( sizeof(struct resource), GFP_KERNEL);
-    if (!res)
-	panic("PCIBR:Unable to allocate resource structure\n");
-
-    /* Block off the range used by PROM. */
-    res->start = prom_base_addr;
-    res->end = prom_base_addr + (prom_base_size - 1);
-    status = request_resource(&pcibr_soft->bs_io_win_root_resource, res);
-    if (status)
-	panic("PCIBR:Unable to request_resource()\n");
-
-    /* Setup the Small Window Root Resource */
-    pcibr_soft->bs_swin_root_resource.start = PAGE_SIZE;
-    pcibr_soft->bs_swin_root_resource.end = 0x000FFFFF;
-
-    /* Setup the Bus's PCI Memory Root Resource */
-    pcibr_soft->bs_mem_win_root_resource.start = 0x200000;
-    pcibr_soft->bs_mem_win_root_resource.end = 0xffffffff;
-    res = (struct resource *) kmalloc( sizeof(struct resource), GFP_KERNEL);
-    if (!res)
-	panic("PCIBR:Unable to allocate resource structure\n");
-
-    /* Block off the range used by PROM. */
-    res->start = prom_base_addr;
-    res->end = prom_base_addr + (prom_base_size - 1);
-    status = request_resource(&pcibr_soft->bs_mem_win_root_resource, res);
-    if (status)
-	panic("PCIBR:Unable to request_resource()\n");
-
-    }
-
-
-    /* build "no-slot" connection point */
-    pcibr_info = pcibr_device_info_new(pcibr_soft, PCIIO_SLOT_NONE,
-		 PCIIO_FUNC_NONE, PCIIO_VENDOR_ID_NONE, PCIIO_DEVICE_ID_NONE);
-    noslot_conn = pciio_device_info_register(pcibr_vhdl, &pcibr_info->f_c);
-
-    /* Store no slot connection point info for tearing it down during detach. */
-    pcibr_soft->bs_noslot_conn = noslot_conn;
-    pcibr_soft->bs_noslot_info = pcibr_info;
-
-    for (slot = pcibr_soft->bs_min_slot;
-				slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-	/* Find out what is out there */
-	(void)pcibr_slot_info_init(pcibr_vhdl, slot);
-    }
-
-    for (slot = pcibr_soft->bs_min_slot;
-				slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-	/* Set up the address space for this slot in the PCI land */
-	(void)pcibr_slot_addr_space_init(pcibr_vhdl, slot);
-    }
-
-    for (slot = pcibr_soft->bs_min_slot;
-				slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-	/* Setup the device register */
-	(void)pcibr_slot_device_init(pcibr_vhdl, slot);
-    }
-
-    if (IS_PCIX(pcibr_soft)) {
-	pcibr_soft->bs_pcix_rbar_inuse = 0;
-	pcibr_soft->bs_pcix_rbar_avail = NUM_RBAR;
-	pcibr_soft->bs_pcix_rbar_percent_allowed =
-					pcibr_pcix_rbars_calc(pcibr_soft);
-
-	for (slot = pcibr_soft->bs_min_slot;
-				slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-	    /* Setup the PCI-X Read Buffer Attribute Registers (RBARs) */
-	    (void)pcibr_slot_pcix_rbar_init(pcibr_soft, slot);
-	}
-    }
-
-    for (slot = pcibr_soft->bs_min_slot;
-				slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-	/* Setup host/guest relations */
-	(void)pcibr_slot_guest_info_init(pcibr_vhdl, slot);
-    }
-
-    /* Handle initial RRB management */
-    pcibr_initial_rrb(pcibr_vhdl,
-		      pcibr_soft->bs_first_slot, pcibr_soft->bs_last_slot);
-
-   /* Before any drivers get called that may want to re-allocate RRB's,
-    * let's get some special cases pre-allocated. Drivers may override
-    * these pre-allocations, but by doing pre-allocations now we're
-    * assured not to step all over what the driver intended.
-    */
-    if (pcibr_soft->bs_bricktype > 0) {
-	switch (pcibr_soft->bs_bricktype) {
-	case MODULE_PXBRICK:
-	case MODULE_IXBRICK:
-	case MODULE_OPUSBRICK:
-		/*
-		 * If IO9 in bus 1, allocate RRBs to all the IO9 devices
-		 */
-		if ((pcibr_widget_to_bus(pcibr_vhdl) == 1) &&
-		    (pcibr_soft->bs_slot[0].bss_vendor_id == 0x10A9) &&
-		    (pcibr_soft->bs_slot[0].bss_device_id == 0x100A)) {
-			pcibr_rrb_alloc_init(pcibr_soft, 0, VCHAN0, 4);
-			pcibr_rrb_alloc_init(pcibr_soft, 1, VCHAN0, 4);
-			pcibr_rrb_alloc_init(pcibr_soft, 2, VCHAN0, 4);
-			pcibr_rrb_alloc_init(pcibr_soft, 3, VCHAN0, 4);
-		} else {
-			pcibr_rrb_alloc_init(pcibr_soft, 0, VCHAN0, 4);
-			pcibr_rrb_alloc_init(pcibr_soft, 1, VCHAN0, 4);
-		}
-		break;
-
-	case MODULE_CGBRICK:
-		pcibr_rrb_alloc_init(pcibr_soft, 0, VCHAN0, 8);
-		break;
-	} /* switch */
-    }
-
-
-    for (slot = pcibr_soft->bs_min_slot;
-				slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
-	/* Call the device attach */
-	(void)pcibr_slot_call_device_attach(pcibr_vhdl, slot, 0);
-    }
-
-    pciio_device_attach(noslot_conn, 0);
-
-    return 0;
-}
-
-
-/*
- * pci provider functions
- *
- * mostly in pcibr.c but if any are needed here then
- * this might be a way to get them here.
- */
-pciio_provider_t        pci_pic_provider =
-{
-    PCIIO_ASIC_TYPE_PIC,
-
-    (pciio_piomap_alloc_f *) pcibr_piomap_alloc,
-    (pciio_piomap_free_f *) pcibr_piomap_free,
-    (pciio_piomap_addr_f *) pcibr_piomap_addr,
-    (pciio_piomap_done_f *) pcibr_piomap_done,
-    (pciio_piotrans_addr_f *) pcibr_piotrans_addr,
-    (pciio_piospace_alloc_f *) pcibr_piospace_alloc,
-    (pciio_piospace_free_f *) pcibr_piospace_free,
-
-    (pciio_dmamap_alloc_f *) pcibr_dmamap_alloc,
-    (pciio_dmamap_free_f *) pcibr_dmamap_free,
-    (pciio_dmamap_addr_f *) pcibr_dmamap_addr,
-    (pciio_dmamap_done_f *) pcibr_dmamap_done,
-    (pciio_dmatrans_addr_f *) pcibr_dmatrans_addr,
-    (pciio_dmamap_drain_f *) pcibr_dmamap_drain,
-    (pciio_dmaaddr_drain_f *) pcibr_dmaaddr_drain,
-
-    (pciio_intr_alloc_f *) pcibr_intr_alloc,
-    (pciio_intr_free_f *) pcibr_intr_free,
-    (pciio_intr_connect_f *) pcibr_intr_connect,
-    (pciio_intr_disconnect_f *) pcibr_intr_disconnect,
-    (pciio_intr_cpu_get_f *) pcibr_intr_cpu_get,
-
-    (pciio_provider_startup_f *) pcibr_provider_startup,
-    (pciio_provider_shutdown_f *) pcibr_provider_shutdown,
-    (pciio_reset_f *) pcibr_reset,
-    (pciio_endian_set_f *) pcibr_endian_set,
-    (pciio_config_get_f *) pcibr_config_get,
-    (pciio_config_set_f *) pcibr_config_set,
-
-    (pciio_error_extract_f *) pcibr_error_extract,
-
-    (pciio_driver_reg_callback_f *) pcibr_driver_reg_callback,
-    (pciio_driver_unreg_callback_f *) pcibr_driver_unreg_callback,
-    (pciio_device_unregister_f 	*) pcibr_device_unregister,
-};
diff -Nru a/arch/ia64/sn/io/sn2/shub.c b/arch/ia64/sn/io/sn2/shub.c
--- a/arch/ia64/sn/io/sn2/shub.c	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,246 +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) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/seq_file.h>
-#include <linux/sched.h>
-#include <asm/smp.h>
-#include <asm/irq.h>
-#include <asm/hw_irq.h>
-#include <asm/system.h>
-#include <asm/sn/sgi.h>
-#include <asm/uaccess.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/sn2/shub_mmr.h>
-#include <asm/sn/sn2/shub_mmr_t.h>
-#include <asm/sal.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/sndrv.h>
-#include <asm/sn/sn2/shubio.h>
-
-#define SHUB_NUM_ECF_REGISTERS 8
-
-static uint32_t	shub_perf_counts[SHUB_NUM_ECF_REGISTERS];
-
-static shubreg_t shub_perf_counts_regs[SHUB_NUM_ECF_REGISTERS] = {
-	SH_PERFORMANCE_COUNTER0,
-	SH_PERFORMANCE_COUNTER1,
-	SH_PERFORMANCE_COUNTER2,
-	SH_PERFORMANCE_COUNTER3,
-	SH_PERFORMANCE_COUNTER4,
-	SH_PERFORMANCE_COUNTER5,
-	SH_PERFORMANCE_COUNTER6,
-	SH_PERFORMANCE_COUNTER7
-};
-
-static inline void
-shub_mmr_write(cnodeid_t cnode, shubreg_t reg, uint64_t val)
-{
-	int		   nasid = cnodeid_to_nasid(cnode);
-	volatile uint64_t *addr = (uint64_t *)(GLOBAL_MMR_ADDR(nasid, reg));
-
-	*addr = val;
-	__ia64_mf_a();
-}
-
-static inline void
-shub_mmr_write_iospace(cnodeid_t cnode, shubreg_t reg, uint64_t val)
-{
-	int		   nasid = cnodeid_to_nasid(cnode);
-
-	REMOTE_HUB_S(nasid, reg, val);
-}
-
-static inline void
-shub_mmr_write32(cnodeid_t cnode, shubreg_t reg, uint32_t val)
-{
-	int		   nasid = cnodeid_to_nasid(cnode);
-	volatile uint32_t *addr = (uint32_t *)(GLOBAL_MMR_ADDR(nasid, reg));
-
-	*addr = val;
-	__ia64_mf_a();
-}
-
-static inline uint64_t
-shub_mmr_read(cnodeid_t cnode, shubreg_t reg)
-{
-	int		  nasid = cnodeid_to_nasid(cnode);
-	volatile uint64_t val;
-
-	val = *(uint64_t *)(GLOBAL_MMR_ADDR(nasid, reg));
-	__ia64_mf_a();
-
-	return val;
-}
-
-static inline uint64_t
-shub_mmr_read_iospace(cnodeid_t cnode, shubreg_t reg)
-{
-	int		  nasid = cnodeid_to_nasid(cnode);
-
-	return REMOTE_HUB_L(nasid, reg);
-}
-
-static inline uint32_t
-shub_mmr_read32(cnodeid_t cnode, shubreg_t reg)
-{
-	int		  nasid = cnodeid_to_nasid(cnode);
-	volatile uint32_t val;
-
-	val = *(uint32_t *)(GLOBAL_MMR_ADDR(nasid, reg));
-	__ia64_mf_a();
-
-	return val;
-}
-
-static int
-reset_shub_stats(cnodeid_t cnode)
-{
-	int i;
-
-	for (i=0; i < SHUB_NUM_ECF_REGISTERS; i++) {
-		shub_perf_counts[i] = 0;
-		shub_mmr_write32(cnode, shub_perf_counts_regs[i], 0);
-	}
-	return 0;
-}
-
-static int
-configure_shub_stats(cnodeid_t cnode, unsigned long arg)
-{
-	uint64_t	*p = (uint64_t *)arg;
-	uint64_t	i;
-	uint64_t	regcnt;
-	uint64_t	regval[2];
-
-	if (copy_from_user((void *)&regcnt, p, sizeof(regcnt)))
-	    return -EFAULT;
-
-	for (p++, i=0; i < regcnt; i++, p += 2) {
-		if (copy_from_user((void *)regval, (void *)p, sizeof(regval)))
-		    return -EFAULT;
-		if (regval[0] & 0x7) {
-		    printk("Error: configure_shub_stats: unaligned address 0x%016lx\n", regval[0]);
-		    return -EINVAL;
-		}
-		shub_mmr_write(cnode, (shubreg_t)regval[0], regval[1]);
-	}
-	return 0;
-}
-
-static int
-capture_shub_stats(cnodeid_t cnode, uint32_t *counts)
-{
-	int 		i;
-
-	for (i=0; i < SHUB_NUM_ECF_REGISTERS; i++) {
-		counts[i] = shub_mmr_read32(cnode, shub_perf_counts_regs[i]);
-	}
-	return 0;
-}
-
-static int
-shubstats_ioctl(struct inode *inode, struct file *file,
-        unsigned int cmd, unsigned long arg)
-{
-	cnodeid_t       cnode;
-	uint64_t        longarg;
-	uint64_t        intarg;
-	uint64_t        regval[2];
-	int		nasid;
-
-        cnode = (cnodeid_t)(u64)file->f_dentry->d_fsdata;
-        if (cnode < 0 || cnode >= numnodes)
-                return -ENODEV;
-
-        switch (cmd) {
-	case SNDRV_SHUB_CONFIGURE:
-		return configure_shub_stats(cnode, arg);
-		break;
-
-	case SNDRV_SHUB_RESETSTATS:
-		reset_shub_stats(cnode);
-		break;
-
-	case SNDRV_SHUB_INFOSIZE:
-		longarg = sizeof(shub_perf_counts);
-		if (copy_to_user((void *)arg, &longarg, sizeof(longarg))) {
-		    return -EFAULT;
-		}
-		break;
-
-	case SNDRV_SHUB_GETSTATS:
-		capture_shub_stats(cnode, shub_perf_counts);
-		if (copy_to_user((void *)arg, shub_perf_counts,
-				       	sizeof(shub_perf_counts))) {
-		    return -EFAULT;
-		}
-		break;
-
-	case SNDRV_SHUB_GETNASID:
-		nasid = cnodeid_to_nasid(cnode);
-		if (copy_to_user((void *)arg, &nasid,
-				       	sizeof(nasid))) {
-		    return -EFAULT;
-		}
-		break;
-
-	case SNDRV_SHUB_GETMMR32:
-		intarg = shub_mmr_read32(cnode, arg);
-		if (copy_to_user((void *)arg, &intarg,
-					sizeof(intarg))) {
-		    return -EFAULT;
-		}
-		break;
- 
-	case SNDRV_SHUB_GETMMR64:
-	case SNDRV_SHUB_GETMMR64_IO:
-		if (cmd == SNDRV_SHUB_GETMMR64)
-		    longarg = shub_mmr_read(cnode, arg);
-		else
-		    longarg = shub_mmr_read_iospace(cnode, arg);
-		if (copy_to_user((void *)arg, &longarg, sizeof(longarg)))
-		    return -EFAULT;
-		break;
- 
-	case SNDRV_SHUB_PUTMMR64:
-	case SNDRV_SHUB_PUTMMR64_IO:
-		if (copy_from_user((void *)regval, (void *)arg, sizeof(regval)))
-		    return -EFAULT;
-		if (regval[0] & 0x7) {
-		    printk("Error: configure_shub_stats: unaligned address 0x%016lx\n", regval[0]);
-		    return -EINVAL;
-		}
-		if (cmd == SNDRV_SHUB_PUTMMR64)
-		    shub_mmr_write(cnode, (shubreg_t)regval[0], regval[1]);
-		else
-		    shub_mmr_write_iospace(cnode, (shubreg_t)regval[0], regval[1]);
-		break;
- 
-	default:
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-struct file_operations shub_mon_fops = {
-	        .ioctl          = shubstats_ioctl,
-};
diff -Nru a/arch/ia64/sn/io/sn2/shub_intr.c b/arch/ia64/sn/io/sn2/shub_intr.c
--- a/arch/ia64/sn/io/sn2/shub_intr.c	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,259 +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) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <asm/sn/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/driver.h>
-#include <asm/param.h>
-#include <asm/sn/pio.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/xtalk/xtalkaddrs.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn2/shub_mmr.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-
-/* ARGSUSED */
-void
-hub_intr_init(vertex_hdl_t hubv)
-{
-}
-
-xwidgetnum_t
-hub_widget_id(nasid_t nasid)
-{
-
-	if (!(nasid & 1)) {
-        	hubii_wcr_t     ii_wcr; /* the control status register */
-        	ii_wcr.wcr_reg_value = REMOTE_HUB_L(nasid,IIO_WCR);
-        	return ii_wcr.wcr_fields_s.wcr_widget_id;
-	} else {
-		/* ICE does not have widget id. */
-		return(-1);
-	}
-}
-
-static hub_intr_t
-do_hub_intr_alloc(vertex_hdl_t dev,
-		device_desc_t dev_desc,
-		vertex_hdl_t owner_dev,
-		int uncond_nothread)
-{
-	cpuid_t		cpu;
-	int		vector;
-	hub_intr_t	intr_hdl;
-	cnodeid_t	cnode;
-	int		cpuphys, slice;
-	int		nasid;
-	iopaddr_t	xtalk_addr;
-	struct xtalk_intr_s	*xtalk_info;
-	xwidget_info_t	xwidget_info;
-
-	cpu = intr_heuristic(dev, -1, &vector);
-	if (cpu == CPU_NONE) {
-		printk("Unable to allocate interrupt for 0x%p\n", (void *)owner_dev);
-		return(0);
-	}
-
-	cpuphys = cpu_physical_id(cpu);
-	slice = cpu_physical_id_to_slice(cpuphys);
-	nasid = cpu_physical_id_to_nasid(cpuphys);
-	cnode = cpuid_to_cnodeid(cpu);
-
-	if (slice) {
-		xtalk_addr = SH_II_INT1 | ((unsigned long)nasid << 36) | (1UL << 47);
-	} else {
-		xtalk_addr = SH_II_INT0 | ((unsigned long)nasid << 36) | (1UL << 47);
-	}
-
-	intr_hdl = kmalloc(sizeof(struct hub_intr_s), GFP_KERNEL);
-	ASSERT_ALWAYS(intr_hdl);
-	memset(intr_hdl, 0, sizeof(struct hub_intr_s));
-
-	xtalk_info = &intr_hdl->i_xtalk_info;
-	xtalk_info->xi_dev = dev;
-	xtalk_info->xi_vector = vector;
-	xtalk_info->xi_addr = xtalk_addr;
-
-	xwidget_info = xwidget_info_get(dev);
-	if (xwidget_info) {
-		xtalk_info->xi_target = xwidget_info_masterid_get(xwidget_info);
-	}
-
-	intr_hdl->i_cpuid = cpu;
-	intr_hdl->i_bit = vector;
-	intr_hdl->i_flags |= HUB_INTR_IS_ALLOCED;
-
-	return intr_hdl;
-}
-
-hub_intr_t
-hub_intr_alloc(vertex_hdl_t dev,
-		device_desc_t dev_desc,
-		vertex_hdl_t owner_dev)
-{
-	return(do_hub_intr_alloc(dev, dev_desc, owner_dev, 0));
-}
-
-hub_intr_t
-hub_intr_alloc_nothd(vertex_hdl_t dev,
-		device_desc_t dev_desc,
-		vertex_hdl_t owner_dev)
-{
-	return(do_hub_intr_alloc(dev, dev_desc, owner_dev, 1));
-}
-
-void
-hub_intr_free(hub_intr_t intr_hdl)
-{
-	cpuid_t		cpu = intr_hdl->i_cpuid;
-	int		vector = intr_hdl->i_bit;
-	xtalk_intr_t	xtalk_info;
-
-	if (intr_hdl->i_flags & HUB_INTR_IS_CONNECTED) {
-		xtalk_info = &intr_hdl->i_xtalk_info;
-		xtalk_info->xi_dev = 0;
-		xtalk_info->xi_vector = 0;
-		xtalk_info->xi_addr = 0;
-		hub_intr_disconnect(intr_hdl);
-	}
-
-	if (intr_hdl->i_flags & HUB_INTR_IS_ALLOCED) {
-		kfree(intr_hdl);
-	}
-	intr_unreserve_level(cpu, vector);
-}
-
-int
-hub_intr_connect(hub_intr_t intr_hdl,
-		intr_func_t intr_func,          /* xtalk intr handler */
-		void *intr_arg,                 /* arg to intr handler */
-		xtalk_intr_setfunc_t setfunc,
-		void *setfunc_arg)
-{
-	int		rv;
-	cpuid_t		cpu = intr_hdl->i_cpuid;
-	int 		vector = intr_hdl->i_bit;
-
-	ASSERT(intr_hdl->i_flags & HUB_INTR_IS_ALLOCED);
-
-	rv = intr_connect_level(cpu, vector);
-	if (rv < 0)
-		return rv;
-
-	intr_hdl->i_xtalk_info.xi_setfunc = setfunc;
-	intr_hdl->i_xtalk_info.xi_sfarg = setfunc_arg;
-
-	if (setfunc) {
-		(*setfunc)((xtalk_intr_t)intr_hdl);
-	}
-
-	intr_hdl->i_flags |= HUB_INTR_IS_CONNECTED;
-
-	return 0;
-}
-
-/*
- * Disassociate handler with the specified interrupt.
- */
-void
-hub_intr_disconnect(hub_intr_t intr_hdl)
-{
-	/*REFERENCED*/
-	int rv;
-	cpuid_t cpu = intr_hdl->i_cpuid;
-	int bit = intr_hdl->i_bit;
-	xtalk_intr_setfunc_t setfunc;
-
-	setfunc = intr_hdl->i_xtalk_info.xi_setfunc;
-
-	/* TBD: send disconnected interrupts somewhere harmless */
-	if (setfunc) (*setfunc)((xtalk_intr_t)intr_hdl);
-
-	rv = intr_disconnect_level(cpu, bit);
-	ASSERT(rv == 0);
-	intr_hdl->i_flags &= ~HUB_INTR_IS_CONNECTED;
-}
-
-/* 
- * Redirect an interrupt to another cpu.
- */
-
-void
-sn_shub_redirect_intr(pcibr_intr_t intr, unsigned long cpu)
-{
-	unsigned long bit;
-	int cpuphys, slice;
-	nasid_t nasid;
-	unsigned long xtalk_addr;
-	int		irq;
-	int		i;
-	int		old_cpu;
-	int		new_cpu;
-
-	cpuphys = cpu_physical_id(cpu);
-	slice = cpu_physical_id_to_slice(cpuphys);
-	nasid = cpu_physical_id_to_nasid(cpuphys);
-
-	for (i = CPUS_PER_NODE - 1; i >= 0; i--) {
-		new_cpu = nasid_slice_to_cpuid(nasid, i);
-		if (new_cpu == NR_CPUS) {
-			continue;
-		}
-
-		if (!cpu_online(new_cpu)) {
-			continue;
-		}
-		break;
-	}
-
-	if (enable_shub_wars_1_1() && slice != i) {
-		printk("smp_affinity WARNING: SHUB 1.1 present: cannot target cpu %d, targeting cpu %d instead.\n",(int)cpu, new_cpu);
-		cpu = new_cpu;
-		slice = i;
-	}
-
-	if (slice) {    
-		xtalk_addr = SH_II_INT1 | ((unsigned long)nasid << 36) | (1UL << 47);
-	} else {
-		xtalk_addr = SH_II_INT0 | ((unsigned long)nasid << 36) | (1UL << 47);
-	}
-
-	for (bit = 0; bit < 8; bit++) {
-		if (intr->bi_ibits & (1 << bit) ) {
-			/* Disable interrupts. */
-			pcireg_intr_enable_bit_clr(intr->bi_soft, bit);
-			/* Reset Host address (Interrupt destination) */
-			pcireg_intr_addr_addr_set(intr->bi_soft, bit, xtalk_addr);
-			/* Enable interrupt */
-			pcireg_intr_enable_bit_set(intr->bi_soft, bit);
-			/* Force an interrupt, just in case. */
-			pcireg_force_intr_set(intr->bi_soft, bit);
-		}
-	}
-	irq = intr->bi_irq;
-	old_cpu = intr->bi_cpu;
-	if (pdacpu(cpu)->sn_first_irq == 0 || pdacpu(cpu)->sn_first_irq > irq) {
-		pdacpu(cpu)->sn_first_irq = irq;
-	}
-	if (pdacpu(cpu)->sn_last_irq < irq) {
-		pdacpu(cpu)->sn_last_irq = irq;
-	}
-	pdacpu(old_cpu)->sn_num_irqs--;
-	pdacpu(cpu)->sn_num_irqs++;
-	intr->bi_cpu = (int)cpu;
-}
diff -Nru a/arch/ia64/sn/io/sn2/shuberror.c b/arch/ia64/sn/io/sn2/shuberror.c
--- a/arch/ia64/sn/io/sn2/shuberror.c	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,822 +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) 1992 - 1997, 2000,2002-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/irq.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/smp.h>
-#include <asm/delay.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/ioerror_handling.h>
-#include <asm/sn/ioerror.h>
-#include <asm/sn/sn2/shubio.h>
-#include <asm/sn/sn2/shub_mmr.h>
-#include <asm/sn/bte.h>
-
-extern void hubni_eint_init(cnodeid_t cnode);
-extern void hubii_eint_init(cnodeid_t cnode);
-extern irqreturn_t hubii_eint_handler (int irq, void *arg, struct pt_regs *ep);
-int hubiio_crb_error_handler(vertex_hdl_t hub_v, hubinfo_t hinfo);
-int hubiio_prb_error_handler(vertex_hdl_t hub_v, hubinfo_t hinfo);
-extern void bte_crb_error_handler(vertex_hdl_t hub_v, int btenum, int crbnum, ioerror_t *ioe, int bteop);
-void print_crb_fields(int crb_num, ii_icrb0_a_u_t icrba,
-	ii_icrb0_b_u_t icrbb, ii_icrb0_c_u_t icrbc,
-	ii_icrb0_d_u_t icrbd, ii_icrb0_e_u_t icrbe);
-
-extern int maxcpus;
-extern error_return_code_t error_state_set(vertex_hdl_t v,error_state_t new_state);
-
-#define HUB_ERROR_PERIOD        (120 * HZ)      /* 2 minutes */
-
-void
-hub_error_clear(nasid_t nasid)
-{
-	int i;
-
-    /*
-     * Make sure spurious write response errors are cleared
-     * (values are from hub_set_prb())
-     */
-    for (i = 0; i <= HUB_WIDGET_ID_MAX - HUB_WIDGET_ID_MIN + 1; i++) {
-        iprb_t prb;
-
-	prb.iprb_regval = REMOTE_HUB_L(nasid, IIO_IOPRB_0 + (i * sizeof(hubreg_t)));
-
-        /* Clear out some fields */
-        prb.iprb_ovflow = 1;
-        prb.iprb_bnakctr = 0;
-        prb.iprb_anakctr = 0;
-
-        prb.iprb_xtalkctr = 3;  /* approx. PIO credits for the widget */
-
-        REMOTE_HUB_S(nasid, IIO_IOPRB_0 + (i * sizeof(hubreg_t)), prb.iprb_regval);
-    }
-
-    REMOTE_HUB_S(nasid, IIO_IECLR, -1);
-
-}
-
-
-/*
- * Function	: hub_error_init
- * Purpose	: initialize the error handling requirements for a given hub.
- * Parameters	: cnode, the compact nodeid.
- * Assumptions	: Called only once per hub, either by a local cpu. Or by a 
- *			remote cpu, when this hub is headless.(cpuless)
- * Returns	: None
- */
-
-void
-hub_error_init(cnodeid_t cnode)
-{
-	nasid_t nasid;
-
-    nasid = cnodeid_to_nasid(cnode);
-    hub_error_clear(nasid);
-
-
-    /*
-     * Now setup the hub ii error interrupt handler.
-     */
-
-    hubii_eint_init(cnode);
-
-    return;
-}
-
-/*
- * Function	: hubii_eint_init
- * Parameters	: cnode
- * Purpose	: to initialize the hub iio error interrupt.
- * Assumptions	: Called once per hub, by the cpu which will ultimately
- *			handle this interrupt.
- * Returns	: None.
- */
-
-void
-hubii_eint_init(cnodeid_t cnode)
-{
-    int			bit, rv;
-    ii_iidsr_u_t    	hubio_eint;
-    hubinfo_t		hinfo; 
-    cpuid_t		intr_cpu;
-    vertex_hdl_t 	hub_v;
-    int bit_pos_to_irq(int bit);
-    ii_ilcsr_u_t	ilcsr;
-
-
-    hub_v = (vertex_hdl_t)cnodeid_to_vertex(cnode);
-    ASSERT_ALWAYS(hub_v);
-    hubinfo_get(hub_v, &hinfo);
-
-    ASSERT(hinfo);
-    ASSERT(hinfo->h_cnodeid == cnode);
-
-    ilcsr.ii_ilcsr_regval = REMOTE_HUB_L(hinfo->h_nasid, IIO_ILCSR);
-    if ((ilcsr.ii_ilcsr_fld_s.i_llp_stat & 0x2) == 0) {
-	/*
-	 * HUB II link is not up.  Disable LLP. Clear old errors.
-	 * Enable interrupts to handle BTE errors.
-	 */
-	ilcsr.ii_ilcsr_fld_s.i_llp_en = 0;
-	REMOTE_HUB_S(hinfo->h_nasid, IIO_ILCSR, ilcsr.ii_ilcsr_regval);
-    }
-
-    /* Select a possible interrupt target where there is a free interrupt
-     * bit and also reserve the interrupt bit for this IO error interrupt
-     */
-    intr_cpu = intr_heuristic(hub_v, SGI_II_ERROR, &bit);
-    if (intr_cpu == CPU_NONE) {
-	printk("hubii_eint_init: intr_heuristic failed, cnode %d", cnode);
-	return;
-    }
-	
-    rv = intr_connect_level(intr_cpu, SGI_II_ERROR);
-    request_irq(SGI_II_ERROR, hubii_eint_handler, SA_SHIRQ, "SN_hub_error", (void *)hub_v);
-    irq_descp(bit)->status |= SN2_IRQ_PER_HUB;
-    ASSERT_ALWAYS(rv >= 0);
-    hubio_eint.ii_iidsr_regval = 0;
-    hubio_eint.ii_iidsr_fld_s.i_enable = 1;
-    hubio_eint.ii_iidsr_fld_s.i_level = bit;/* Take the least significant bits*/
-    hubio_eint.ii_iidsr_fld_s.i_node = cnodeid_to_nasid(cnode);
-    hubio_eint.ii_iidsr_fld_s.i_pi_id = cpuid_to_subnode(intr_cpu);
-    REMOTE_HUB_S(hinfo->h_nasid, IIO_IIDSR, hubio_eint.ii_iidsr_regval);
-
-}
-
-
-/*ARGSUSED*/
-irqreturn_t
-hubii_eint_handler (int irq, void *arg, struct pt_regs *ep)
-{
-    vertex_hdl_t	hub_v;
-    hubinfo_t		hinfo; 
-    ii_wstat_u_t	wstat;
-    hubreg_t		idsr;
-
-
-    /* two levels of casting avoids compiler warning.!! */
-    hub_v = (vertex_hdl_t)(long)(arg); 
-    ASSERT(hub_v);
-
-    hubinfo_get(hub_v, &hinfo);
-    
-    idsr = REMOTE_HUB_L(hinfo->h_nasid, IIO_ICMR);
-#if 0
-    if (idsr & 0x1) {
-	/* ICMR bit is set .. we are getting into "Spurious Interrupts condition. */
-	printk("Cnode %d II has seen the ICMR condition\n", hinfo->h_cnodeid);
-	printk("***** Please file PV with the above messages *****\n");
-	/* panic("We have to panic to prevent further unknown states ..\n"); */
-    }
-#endif
-	
-    /* 
-     * Identify the reason for error. 
-     */
-    wstat.ii_wstat_regval = REMOTE_HUB_L(hinfo->h_nasid, IIO_WSTAT);
-
-    if (wstat.ii_wstat_fld_s.w_crazy) {
-	char	*reason;
-	/*
-	 * We can do a couple of things here. 
-	 * Look at the fields TX_MX_RTY/XT_TAIL_TO/XT_CRD_TO to check
-	 * which of these caused the CRAZY bit to be set. 
-	 * You may be able to check if the Link is up really.
-	 */
-	if (wstat.ii_wstat_fld_s.w_tx_mx_rty)
-		reason = "Micro Packet Retry Timeout";
-	else if (wstat.ii_wstat_fld_s.w_xt_tail_to)
-		reason = "Crosstalk Tail Timeout";
-	else if (wstat.ii_wstat_fld_s.w_xt_crd_to)
-		reason = "Crosstalk Credit Timeout";
-	else {
-		hubreg_t	hubii_imem;
-		/*
-		 * Check if widget 0 has been marked as shutdown, or
-		 * if BTE 0/1 has been marked.
-		 */
-		hubii_imem = REMOTE_HUB_L(hinfo->h_nasid, IIO_IMEM);
-		if (hubii_imem & IIO_IMEM_W0ESD)
-			reason = "Hub Widget 0 has been Shutdown";
-		else if (hubii_imem & IIO_IMEM_B0ESD)
-			reason = "BTE 0 has been shutdown";
-		else if (hubii_imem & IIO_IMEM_B1ESD)
-			reason = "BTE 1 has been shutdown";
-		else	reason = "Unknown";
-	
-	}
-	/*
-	 * Only print the II_ECRAZY message if there is an attached xbow.
-	 */
-	if (NODEPDA(hinfo->h_cnodeid)->xbow_vhdl != 0) {
-	    printk("Hub %d, cnode %d to Xtalk Link failed (II_ECRAZY) Reason: %s", 
-		hinfo->h_nasid, hinfo->h_cnodeid, reason);
-	}
-    }
-
-
-    /*
-     * Before processing any interrupt related information, clear all
-     * error indication and reenable interrupts.  This will prevent
-     * lost interrupts due to the interrupt handler scanning past a PRB/CRB
-     * which has not errorred yet and then the PRB/CRB goes into error.
-     * Note, PRB errors are cleared individually.
-     */
-    REMOTE_HUB_S(hinfo->h_nasid, IIO_IECLR, 0xff0000);
-    idsr = REMOTE_HUB_L(hinfo->h_nasid, IIO_IIDSR) & ~IIO_IIDSR_SENT_MASK;
-    REMOTE_HUB_S(hinfo->h_nasid, IIO_IIDSR, idsr);
-
-
-    /* 
-     * It's a toss as to which one among PRB/CRB to check first. 
-     * Current decision is based on the severity of the errors. 
-     * IO CRB errors tend to be more severe than PRB errors.
-     *
-     * It is possible for BTE errors to have been handled already, so we
-     * may not see any errors handled here. 
-     */
-    (void)hubiio_crb_error_handler(hub_v, hinfo);
-    (void)hubiio_prb_error_handler(hub_v, hinfo);
-
-    return IRQ_HANDLED;
-}
-
-/*
- * Free the hub CRB "crbnum" which encountered an error.
- * Assumption is, error handling was successfully done,
- * and we now want to return the CRB back to Hub for normal usage.
- *
- * In order to free the CRB, all that's needed is to de-allocate it
- *
- * Assumption:
- *      No other processor is mucking around with the hub control register.
- *      So, upper layer has to single thread this.
- */
-void
-hubiio_crb_free(hubinfo_t hinfo, int crbnum)
-{
-	ii_icrb0_b_u_t         icrbb;
-
-	/*
-	* The hardware does NOT clear the mark bit, so it must get cleared
-	* here to be sure the error is not processed twice.
-	*/
-	icrbb.ii_icrb0_b_regval = REMOTE_HUB_L(hinfo->h_nasid, IIO_ICRB_B(crbnum));
-	icrbb.b_mark   = 0;
-	REMOTE_HUB_S(hinfo->h_nasid, IIO_ICRB_B(crbnum), icrbb.ii_icrb0_b_regval);
-
-	/*
-	* Deallocate the register.
-	*/
-
-	REMOTE_HUB_S(hinfo->h_nasid, IIO_ICDR, (IIO_ICDR_PND | crbnum));
-
-	/*
-	* Wait till hub indicates it's done.
-	*/
-	while (REMOTE_HUB_L(hinfo->h_nasid, IIO_ICDR) & IIO_ICDR_PND)
-		udelay(1);
-
-}
-
-
-/*
- * Array of error names  that get logged in CRBs
- */ 
-char *hubiio_crb_errors[] = {
-	"Directory Error",
-	"CRB Poison Error",
-	"I/O Write Error",
-	"I/O Access Error",
-	"I/O Partial Write Error",
-	"I/O Partial Read Error",
-	"I/O Timeout Error",
-	"Xtalk Error Packet"
-};
-
-void
-print_crb_fields(int crb_num, ii_icrb0_a_u_t icrba,
-	ii_icrb0_b_u_t icrbb, ii_icrb0_c_u_t icrbc,
-	ii_icrb0_d_u_t icrbd, ii_icrb0_e_u_t icrbe)
-{
-    printk("CRB %d regA\n\t"
-	    "a_iow 0x%x\n\t"
-	    "valid0x%x\n\t"
-	    "Address0x%lx\n\t"
-	    "a_tnum 0x%x\n\t"
-	    "a_sidn 0x%x\n",
-	    crb_num,
-	    icrba.a_iow, 
-	    icrba.a_valid, 
-	    icrba.a_addr, 
-	    icrba.a_tnum, 
-	    icrba.a_sidn);
-    printk("CRB %d regB\n\t"
-	    "b_imsgtype 0x%x\n\t"
-	    "b_imsg 0x%x\n"
-	    "\tb_use_old 0x%x\n\t"
-	    "b_initiator 0x%x\n\t"
-	    "b_exc 0x%x\n"
-	    "\tb_ackcnt 0x%x\n\t"
-	    "b_resp 0x%x\n\t"
-	    "b_ack 0x%x\n"
-	    "\tb_hold 0x%x\n\t"
-	    "b_wb 0x%x\n\t"
-	    "b_intvn 0x%x\n"
-	    "\tb_stall_ib 0x%x\n\t"
-	    "b_stall_int 0x%x\n"
-	    "\tb_stall_bte_0 0x%x\n\t"
-	    "b_stall_bte_1 0x%x\n"
-	    "\tb_error 0x%x\n\t"
-	    "b_lnetuce 0x%x\n\t"
-	    "b_mark 0x%x\n\t"
-	    "b_xerr 0x%x\n",
-	    crb_num,
-	    icrbb.b_imsgtype, 
-	    icrbb.b_imsg, 
-	    icrbb.b_use_old, 
-	    icrbb.b_initiator,
-	    icrbb.b_exc, 
-	    icrbb.b_ackcnt, 
-	    icrbb.b_resp, 
-	    icrbb.b_ack, 
-	    icrbb.b_hold,
-	    icrbb.b_wb, 
-	    icrbb.b_intvn, 
-	    icrbb.b_stall_ib, 
-	    icrbb.b_stall_int,
-	    icrbb.b_stall_bte_0, 
-	    icrbb.b_stall_bte_1, 
-	    icrbb.b_error,
-	    icrbb.b_lnetuce, 
-	    icrbb.b_mark, 
-	    icrbb.b_xerr);
-    printk("CRB %d regC\n\t"
-	    "c_source 0x%x\n\t"
-	    "c_xtsize 0x%x\n\t"
-	    "c_cohtrans 0x%x\n\t"
-	    "c_btenum 0x%x\n\t"
-	    "c_gbr 0x%x\n\t"
-	    "c_doresp 0x%x\n\t"
-	    "c_barrop 0x%x\n\t"
-	    "c_suppl 0x%x\n",
-	    crb_num,
-	    icrbc.c_source,
-	    icrbc.c_xtsize,
-	    icrbc.c_cohtrans,
-	    icrbc.c_btenum,
-	    icrbc.c_gbr,
-	    icrbc.c_doresp,
-	    icrbc.c_barrop,
-	    icrbc.c_suppl);
-    printk("CRB %d regD\n\t"
-	    "d_bteaddr 0x%lx\n\t"
-	    "d_bteop 0x%x\n\t"
-	    "d_pripsc 0x%x\n\t"
-	    "d_pricnt 0x%x\n\t"
-	    "d_sleep 0x%x\n\t",
-	    crb_num,
-	    icrbd.d_bteaddr,
-	    icrbd.d_bteop,
-	    icrbd.d_pripsc,
-	    icrbd.d_pricnt,
-	    icrbd.d_sleep);
-    printk("CRB %d regE\n\t"
-	    "icrbe_timeout 0x%x\n\t"
-	    "icrbe_context 0x%x\n\t"
-	    "icrbe_toutvld 0x%x\n\t"
-	    "icrbe_ctxtvld 0x%x\n\t",
-	    crb_num,
-	    icrbe.icrbe_timeout,
-	    icrbe.icrbe_context,
-	    icrbe.icrbe_toutvld,
-	    icrbe.icrbe_ctxtvld);
-}
-
-/*
- * hubiio_crb_error_handler
- *
- *	This routine gets invoked when a hub gets an error 
- *	interrupt. So, the routine is running in interrupt context
- *	at error interrupt level.
- * Action:
- *	It's responsible for identifying ALL the CRBs that are marked
- *	with error, and process them. 
- *	
- * 	If you find the CRB that's marked with error, map this to the
- *	reason it caused error, and invoke appropriate error handler.
- *
- *	XXX Be aware of the information in the context register.
- *
- * NOTE:
- *	Use REMOTE_HUB_* macro instead of LOCAL_HUB_* so that the interrupt
- *	handler can be run on any node. (not necessarily the node 
- *	corresponding to the hub that encountered error).
- */
-
-int
-hubiio_crb_error_handler(vertex_hdl_t hub_v, hubinfo_t hinfo)
-{
-	cnodeid_t	cnode;
-	nasid_t		nasid;
-	ii_icrb0_a_u_t		icrba;		/* II CRB Register A */
-	ii_icrb0_b_u_t		icrbb;		/* II CRB Register B */
-	ii_icrb0_c_u_t		icrbc;		/* II CRB Register C */
-	ii_icrb0_d_u_t		icrbd;		/* II CRB Register D */
-	ii_icrb0_e_u_t		icrbe;		/* II CRB Register D */
-	int		i;
-	int		num_errors = 0;	/* Num of errors handled */
-	ioerror_t	ioerror;
-	int		rc;
-
-	nasid = hinfo->h_nasid;
-	cnode = nasid_to_cnodeid(nasid);
-
-	/*
-	 * XXX - Add locking for any recovery actions
-	 */
-	/*
-	 * Scan through all CRBs in the Hub, and handle the errors
-	 * in any of the CRBs marked.
-	 */
-	for (i = 0; i < IIO_NUM_CRBS; i++) {
-		/* Check this crb entry to see if it is in error. */
-		icrbb.ii_icrb0_b_regval = REMOTE_HUB_L(nasid, IIO_ICRB_B(i));
-
-		if (icrbb.b_mark == 0) {
-			continue;
-		}
-
-		icrba.ii_icrb0_a_regval = REMOTE_HUB_L(nasid, IIO_ICRB_A(i));
-
-		IOERROR_INIT(&ioerror);
-
-		/* read other CRB error registers. */
-		icrbc.ii_icrb0_c_regval = REMOTE_HUB_L(nasid, IIO_ICRB_C(i));
-		icrbd.ii_icrb0_d_regval = REMOTE_HUB_L(nasid, IIO_ICRB_D(i));
-		icrbe.ii_icrb0_e_regval = REMOTE_HUB_L(nasid, IIO_ICRB_E(i));
-
-		IOERROR_SETVALUE(&ioerror,errortype,icrbb.b_ecode);
-
-		/* Check if this error is due to BTE operation,
-		* and handle it separately.
-		*/
-		if (icrbd.d_bteop ||
-			((icrbb.b_initiator == IIO_ICRB_INIT_BTE0 ||
-			icrbb.b_initiator == IIO_ICRB_INIT_BTE1) &&
-			(icrbb.b_imsgtype == IIO_ICRB_IMSGT_BTE ||
-			icrbb.b_imsgtype == IIO_ICRB_IMSGT_SN1NET))){
-
-			int bte_num;
-
-			if (icrbd.d_bteop)
-				bte_num = icrbc.c_btenum;
-			else /* b_initiator bit 2 gives BTE number */
-				bte_num = (icrbb.b_initiator & 0x4) >> 2;
-
-			hubiio_crb_free(hinfo, i);
-
-			bte_crb_error_handler(hub_v, bte_num,
-					      i, &ioerror,
-					      icrbd.d_bteop);
-			num_errors++;
-			continue;
-		}
-
-		/*
-		 * XXX
-		 * Assuming the only other error that would reach here is
-		 * crosstalk errors. 
-		 * If CRB times out on a message from Xtalk, it changes 
-		 * the message type to CRB. 
-		 *
-		 * If we get here due to other errors (SN0net/CRB)
-		 * what's the action ?
-		 */
-
-		/*
-		 * Pick out the useful fields in CRB, and
-		 * tuck them away into ioerror structure.
-		 */
-		IOERROR_SETVALUE(&ioerror,xtalkaddr,icrba.a_addr << IIO_ICRB_ADDR_SHFT);
-		IOERROR_SETVALUE(&ioerror,widgetnum,icrba.a_sidn);
-
-
-		if (icrba.a_iow){
-			/*
-			 * XXX We shouldn't really have BRIDGE-specific code
-			 * here, but alas....
-			 *
-			 * The BRIDGE (or XBRIDGE) sets the upper bit of TNUM
-			 * to indicate a WRITE operation.  It sets the next
-			 * bit to indicate an INTERRUPT operation.  The bottom
-			 * 3 bits of TNUM indicate which device was responsible.
-			 */
-			IOERROR_SETVALUE(&ioerror,widgetdev,
-					 TNUM_TO_WIDGET_DEV(icrba.a_tnum));
-			/*
-			* The encoding of TNUM (see comments above) is
-			* different for PIC. So we'll save TNUM here and
-			* deal with the differences later when we can
-			* determine if we're using a Bridge or the PIC.
-			*
-			* XXX:  We may be able to remove saving the widgetdev
-			* above and just sort it out of TNUM later.
-			*/
-			IOERROR_SETVALUE(&ioerror, tnum, icrba.a_tnum);
-
-		}
-		if (icrbb.b_error) {
-		    /*
-		     * CRB 'i' has some error. Identify the type of error,
-		     * and try to handle it.
-		     *
-		     */
-		    switch(icrbb.b_ecode) {
-			case IIO_ICRB_ECODE_PERR:
-			case IIO_ICRB_ECODE_WERR:
-			case IIO_ICRB_ECODE_AERR:
-			case IIO_ICRB_ECODE_PWERR:
-			case IIO_ICRB_ECODE_TOUT:
-			case IIO_ICRB_ECODE_XTERR:
-			    printk("Shub II CRB %d: error %s on hub cnodeid: %d",
-				    i, hubiio_crb_errors[icrbb.b_ecode], cnode);
-			    /*
-			     * Any sort of write error is mostly due
-			     * bad programming (Note it's not a timeout.)
-			     * So, invoke hub_iio_error_handler with
-			     * appropriate information.
-			     */
-			    IOERROR_SETVALUE(&ioerror,errortype,icrbb.b_ecode);
-
-			    /* Go through the error bit lookup phase */
-			    if (error_state_set(hub_v, ERROR_STATE_LOOKUP) ==
-				    ERROR_RETURN_CODE_CANNOT_SET_STATE)
-				return(IOERROR_UNHANDLED);
-			    rc = hub_ioerror_handler(
-				    hub_v,
-				    DMA_WRITE_ERROR,
-				    MODE_DEVERROR,
-				    &ioerror);
-			    if (rc == IOERROR_HANDLED) {
-				rc = hub_ioerror_handler(
-					hub_v,
-					DMA_WRITE_ERROR,
-					MODE_DEVREENABLE,
-					&ioerror);
-			    }else {
-				printk("Unable to handle %s on hub %d",
-					hubiio_crb_errors[icrbb.b_ecode],
-					cnode);
-				/* panic; */
-			    }
-			    /* Go to Next error */
-			    print_crb_fields(i, icrba, icrbb, icrbc,
-				    icrbd, icrbe);
-			    hubiio_crb_free(hinfo, i);
-			    continue;
-			case IIO_ICRB_ECODE_PRERR:
-			case IIO_ICRB_ECODE_DERR:
-			    printk("Shub II CRB %d: error %s on hub : %d",
-				    i, hubiio_crb_errors[icrbb.b_ecode], cnode);
-			    /* panic */
-			default:
-			    printk("Shub II CRB error (code : %d) on hub : %d",
-				    icrbb.b_ecode, cnode);
-			    /* panic */
-		    }
-		} 
-		/*
-		 * Error is not indicated via the errcode field
-		 * Check other error indications in this register.
-		 */
-		if (icrbb.b_xerr) {
-		    printk("Shub II CRB %d: Xtalk Packet with error bit set to hub %d",
-			    i, cnode);
-		    /* panic */
-		}
-		if (icrbb.b_lnetuce) {
-		    printk("Shub II CRB %d: Uncorrectable data error detected on data "
-			    " from NUMAlink to node %d",
-			    i, cnode);
-		    /* panic */
-		}
-		print_crb_fields(i, icrba, icrbb, icrbc, icrbd, icrbe);
-
-
-
-
-
-		if (icrbb.b_error) {
-		/* 
-		 * CRB 'i' has some error. Identify the type of error,
-		 * and try to handle it.
-		 */
-		switch(icrbb.b_ecode) {
-		case IIO_ICRB_ECODE_PERR:
-		case IIO_ICRB_ECODE_WERR:
-		case IIO_ICRB_ECODE_AERR:
-		case IIO_ICRB_ECODE_PWERR:
-
-			printk("%s on hub cnodeid: %d",
-				hubiio_crb_errors[icrbb.b_ecode], cnode);
-			/*
-			 * Any sort of write error is mostly due
-			 * bad programming (Note it's not a timeout.)
-			 * So, invoke hub_iio_error_handler with
-			 * appropriate information.
-			 */
-			IOERROR_SETVALUE(&ioerror,errortype,icrbb.b_ecode);
-
-			rc = hub_ioerror_handler(
-					hub_v, 
-					DMA_WRITE_ERROR, 
-					MODE_DEVERROR, 
-					&ioerror);
-
-                        if (rc == IOERROR_HANDLED) {
-                                rc = hub_ioerror_handler(
-                                        hub_v,
-                                        DMA_WRITE_ERROR,
-                                        MODE_DEVREENABLE,
-                                        &ioerror);
-                                ASSERT(rc == IOERROR_HANDLED);
-                        }else {
-
-				panic("Unable to handle %s on hub %d",
-					hubiio_crb_errors[icrbb.b_ecode],
-					cnode);
-				/*NOTREACHED*/
-			}
-			/* Go to Next error */
-			hubiio_crb_free(hinfo, i);
-			continue;
-
-		case IIO_ICRB_ECODE_PRERR:
-
-                case IIO_ICRB_ECODE_TOUT:
-                case IIO_ICRB_ECODE_XTERR:
-
-		case IIO_ICRB_ECODE_DERR:
-			panic("Fatal %s on hub : %d",
-				hubiio_crb_errors[icrbb.b_ecode], cnode);
-			/*NOTREACHED*/
-		
-		default:
-			panic("Fatal error (code : %d) on hub : %d",
-				icrbb.b_ecode, cnode);
-			/*NOTREACHED*/
-
-		}
-		} 	/* if (icrbb.b_error) */	
-
-		/*
-		 * Error is not indicated via the errcode field 
-		 * Check other error indications in this register.
-		 */
-		
-		if (icrbb.b_xerr) {
-			panic("Xtalk Packet with error bit set to hub %d",
-				cnode);
-			/*NOTREACHED*/
-		}
-
-		if (icrbb.b_lnetuce) {
-			panic("Uncorrectable data error detected on data "
-				" from Craylink to node %d",
-				cnode);
-			/*NOTREACHED*/
-		}
-
-	}
-	return	num_errors;
-}
-
-/*
- * hubii_check_widget_disabled
- *
- *	Check if PIO access to the specified widget is disabled due
- *	to any II errors that are currently set.
- *
- *	The specific error bits checked are:
- *		IPRBx register: SPUR_RD (51)
- *				SPUR_WR (50)
- *				RD_TO (49)
- *				ERROR (48)
- *
- *		WSTAT register: CRAZY (32)
- */
-
-int
-hubii_check_widget_disabled(nasid_t nasid, int wnum)
-{
-	iprb_t		iprb;
-	ii_wstat_u_t	wstat;
-
-	iprb.iprb_regval = REMOTE_HUB_L(nasid, IIO_IOPRB(wnum));
-	if (iprb.iprb_regval & (IIO_PRB_SPUR_RD | IIO_PRB_SPUR_WR |
-		IIO_PRB_RD_TO | IIO_PRB_ERROR)) {
-#ifdef DEBUG
-	    printk(KERN_WARNING "II error, IPRB%x=0x%lx\n", wnum, iprb.iprb_regval);
-#endif
-	    return(1);
-	}
-
-	wstat.ii_wstat_regval = REMOTE_HUB_L(nasid, IIO_WSTAT);
-	if (wstat.ii_wstat_regval & IIO_WSTAT_ECRAZY) {
-#ifdef DEBUG
-	    printk(KERN_WARNING "II error, WSTAT=0x%lx\n", wstat.ii_wstat_regval);
-#endif
-	    return(1);
-	}
-	return(0);
-}
-
-/*ARGSUSED*/
-/*
- * hubii_prb_handler
- *      Handle the error reported in the PRB for wiget number wnum.
- *      This typically happens on a PIO write error.
- *      There is nothing much we can do in this interrupt context for
- *      PIO write errors. For e.g. QL scsi controller has the
- *      habit of flaking out on PIO writes.
- *      Print a message and try to continue for now
- *      Cleanup involes freeing the PRB register
- */
-static void
-hubii_prb_handler(vertex_hdl_t hub_v, hubinfo_t hinfo, int wnum)
-{
-        nasid_t         nasid;
-
-        nasid = hinfo->h_nasid;
-        /*
-         * Clear error bit by writing to IECLR register.
-         */
-        REMOTE_HUB_S(nasid, IIO_IECLR, (1 << wnum));
-        /*
-         * PIO Write to Widget 'i' got into an error.
-         * Invoke hubiio_error_handler with this information.
-         */
-        printk( "Hub nasid %d got a PIO Write error from widget %d, "
-				"cleaning up and continuing", nasid, wnum);
-        /*
-         * XXX
-         * It may be necessary to adjust IO PRB counter
-         * to account for any lost credits.
-         */
-}
-
-int
-hubiio_prb_error_handler(vertex_hdl_t hub_v, hubinfo_t hinfo)
-{
-        int             wnum;
-        nasid_t         nasid;
-        int             num_errors = 0;
-        iprb_t          iprb;
-
-        nasid = hinfo->h_nasid;
-        /*
-         * Check if IPRB0 has any error first.
-         */
-        iprb.iprb_regval = REMOTE_HUB_L(nasid, IIO_IOPRB(0));
-        if (iprb.iprb_error) {
-                num_errors++;
-                hubii_prb_handler(hub_v, hinfo, 0);
-        }
-        /*
-         * Look through PRBs 8 - F to see if any of them has error bit set.
-         * If true, invoke hub iio error handler for this widget.
-         */
-        for (wnum = HUB_WIDGET_ID_MIN; wnum <= HUB_WIDGET_ID_MAX; wnum++) {
-                iprb.iprb_regval = REMOTE_HUB_L(nasid, IIO_IOPRB(wnum));
-
-                if (!iprb.iprb_error)
-                        continue;
-
-                num_errors++;
-                hubii_prb_handler(hub_v, hinfo, wnum);
-        }
-
-        return num_errors;
-}
-
diff -Nru a/arch/ia64/sn/io/sn2/shubio.c b/arch/ia64/sn/io/sn2/shubio.c
--- a/arch/ia64/sn/io/sn2/shubio.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,490 +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) 1992 - 1997, 2000,2002-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <asm/smp.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/ioerror_handling.h>
-#include <asm/sn/ioerror.h>
-#include <asm/sn/sn2/shubio.h>
-
-
-error_state_t error_state_get(vertex_hdl_t v);
-error_return_code_t error_state_set(vertex_hdl_t v,error_state_t new_state);
-
-
-/*
- * Get the xtalk provider function pointer for the
- * specified hub.
- */
-
-/*ARGSUSED*/
-int
-hub_xp_error_handler(
-	vertex_hdl_t 	hub_v, 
-	nasid_t		nasid, 
-	int		error_code, 
-	ioerror_mode_t	mode, 
-	ioerror_t	*ioerror)
-{
-	/*REFERENCED*/
-	hubreg_t	iio_imem;
-	vertex_hdl_t	xswitch;
-	error_state_t	e_state;
-	cnodeid_t	cnode;
-
-	/*
-	 * Before walking down to the next level, check if
-	 * the I/O link is up. If it's been disabled by the 
-	 * hub ii for some reason, we can't even touch the
-	 * widget registers.
-	 */
-	iio_imem = REMOTE_HUB_L(nasid, IIO_IMEM);
-
-	if (!(iio_imem & (IIO_IMEM_B0ESD|IIO_IMEM_W0ESD))){
-		/* 
-		 * IIO_IMEM_B0ESD getting set, indicates II shutdown
-		 * on HUB0 parts.. Hopefully that's not true for 
-		 * Hub1 parts..
-		 *
-		 *
-		 * If either one of them is shut down, can't
-		 * go any further.
-		 */
-		return IOERROR_XTALKLEVEL;
-	}
-
-	/* Get the error state of the hub */
-	e_state = error_state_get(hub_v);
-
-	cnode = nasid_to_cnodeid(nasid);
-
-	xswitch = NODEPDA(cnode)->basew_xc;
-
-	/* Set the error state of the crosstalk device to that of
-	 * hub.
-	 */
-	if (error_state_set(xswitch , e_state) == 
-	    ERROR_RETURN_CODE_CANNOT_SET_STATE)
-		return(IOERROR_UNHANDLED);
-
-	/* Clean the error state of the hub if we are in the action handling
-	 * phase.
-	 */
-	if (e_state == ERROR_STATE_ACTION)
-		(void)error_state_set(hub_v, ERROR_STATE_NONE);
-	/* hand the error off to the switch or the directly
-	 * connected crosstalk device.
-	 */
-	return  xtalk_error_handler(xswitch,
-				    error_code, mode, ioerror);
-
-}
-
-/* 
- * Check if the widget in error has been enabled for PIO accesses
- */
-int
-is_widget_pio_enabled(ioerror_t *ioerror)
-{
-	cnodeid_t	src_node;
-	nasid_t		src_nasid;
-	hubreg_t	ii_iowa;
-	xwidgetnum_t	widget;
-	iopaddr_t	p;
-
-	/* Get the node where the PIO error occurred */
-	IOERROR_GETVALUE(p,ioerror, srcnode);
-	src_node = p;
-	if (src_node == CNODEID_NONE)
-		return(0);
-
-	/* Get the nasid for the cnode */
-	src_nasid = cnodeid_to_nasid(src_node);
-	if (src_nasid == INVALID_NASID)
-		return(0);
-
-	/* Read the Outbound widget access register for this hub */
-	ii_iowa = REMOTE_HUB_L(src_nasid, IIO_IOWA);
-	IOERROR_GETVALUE(p,ioerror, widgetnum);
-	widget = p;
-
-	/* Check if the PIOs to the widget with PIO error have been
-	 * enabled.
-	 */
-	if (ii_iowa & IIO_IOWA_WIDGET(widget))
-		return(1);
-
-	return(0);
-}
-
-/*
- * Hub IO error handling.
- *
- *	Gets invoked for different types of errors found at the hub. 
- *	Typically this includes situations from bus error or due to 
- *	an error interrupt (mostly generated at the hub).
- */
-int
-hub_ioerror_handler(
-	vertex_hdl_t 	hub_v, 
-	int		error_code,
-	int		mode,
-	struct io_error_s	*ioerror)
-{
-	hubinfo_t 	hinfo; 		/* Hub info pointer */
-	nasid_t		nasid;
-	int		retval = 0;
-	/*REFERENCED*/
-	iopaddr_t 	p;
-	caddr_t 	cp;
-
-	hubinfo_get(hub_v, &hinfo);
-
-	if (!hinfo){
-		/* Print an error message and return */
-		goto end;
-	}
-	nasid = hinfo->h_nasid;
-
-	switch(error_code) {
-
-	case PIO_READ_ERROR:
-		/* 
-		 * Cpu got a bus error while accessing IO space.
-		 * hubaddr field in ioerror structure should have
-		 * the IO address that caused access error.
-		 */
-
-		/*
-		 * Identify if  the physical address in hub_error_data
-		 * corresponds to small/large window, and accordingly,
-		 * get the xtalk address.
-		 */
-
-		/*
-		 * Evaluate the widget number and the widget address that
-		 * caused the error. Use 'vaddr' if it's there.
-		 * This is typically true either during probing
-		 * or a kernel driver getting into trouble. 
-		 * Otherwise, use paddr to figure out widget details
-		 * This is typically true for user mode bus errors while
-		 * accessing I/O space.
-		 */
-		 IOERROR_GETVALUE(cp,ioerror,vaddr);
-		 if (cp){
-		    /* 
-		     * If neither in small window nor in large window range,
-		     * outright reject it.
-		     */
-		    IOERROR_GETVALUE(cp,ioerror,vaddr);
-		    if (NODE_SWIN_ADDR(nasid, (paddr_t)cp)){
-			iopaddr_t	hubaddr;
-			xwidgetnum_t	widgetnum;
-			iopaddr_t	xtalkaddr;
-
-			IOERROR_GETVALUE(p,ioerror,hubaddr);
-			hubaddr = p;
-			widgetnum = SWIN_WIDGETNUM(hubaddr);
-			xtalkaddr = SWIN_WIDGETADDR(hubaddr);
-			/* 
-			 * differentiate local register vs IO space access
-			 */
-			IOERROR_SETVALUE(ioerror,widgetnum,widgetnum);
-			IOERROR_SETVALUE(ioerror,xtalkaddr,xtalkaddr);
-
-
-		    } else if (NODE_BWIN_ADDR(nasid, (paddr_t)cp)){
-			/* 
-			 * Address corresponds to large window space. 
-			 * Convert it to xtalk address.
-			 */
-			int		bigwin;
-			hub_piomap_t    bw_piomap;
-			xtalk_piomap_t	xt_pmap = NULL;
-			iopaddr_t	hubaddr;
-			xwidgetnum_t	widgetnum;
-			iopaddr_t	xtalkaddr;
-
-			IOERROR_GETVALUE(p,ioerror,hubaddr);
-			hubaddr = p;
-
-			/*
-			 * Have to loop to find the correct xtalk_piomap 
-			 * because the're not allocated on a one-to-one
-			 * basis to the window number.
-			 */
-			for (bigwin=0; bigwin < HUB_NUM_BIG_WINDOW; bigwin++) {
-				bw_piomap = hubinfo_bwin_piomap_get(hinfo,
-								    bigwin);
-
-				if (bw_piomap->hpio_bigwin_num ==
-				    (BWIN_WINDOWNUM(hubaddr) - 1)) {
-					xt_pmap = hub_piomap_xt_piomap(bw_piomap);
-					break;
-				}
-			}
-
-			ASSERT(xt_pmap);
-
-			widgetnum = xtalk_pio_target_get(xt_pmap);
-			xtalkaddr = xtalk_pio_xtalk_addr_get(xt_pmap) + BWIN_WIDGETADDR(hubaddr);
-
-			IOERROR_SETVALUE(ioerror,widgetnum,widgetnum);
-			IOERROR_SETVALUE(ioerror,xtalkaddr,xtalkaddr);
-
-			/* 
-			 * Make sure that widgetnum doesnot map to hub 
-			 * register widget number, as we never use
-			 * big window to access hub registers. 
-			 */
-			ASSERT(widgetnum != HUB_REGISTER_WIDGET);
-		    }
-		} else if (IOERROR_FIELDVALID(ioerror,hubaddr)) {
-			iopaddr_t	hubaddr;
-			xwidgetnum_t	widgetnum;
-			iopaddr_t	xtalkaddr;
-
-			IOERROR_GETVALUE(p,ioerror,hubaddr);
-			hubaddr = p;
-			if (BWIN_WINDOWNUM(hubaddr)){
-				int 	window = BWIN_WINDOWNUM(hubaddr) - 1;
-				hubreg_t itte;
-				itte = (hubreg_t)HUB_L(IIO_ITTE_GET(nasid, window));
-				widgetnum =  (itte >> IIO_ITTE_WIDGET_SHIFT) & 
-						IIO_ITTE_WIDGET_MASK;
-				xtalkaddr = (((itte >> IIO_ITTE_OFFSET_SHIFT) &
-					IIO_ITTE_OFFSET_MASK) << 
-					     BWIN_SIZE_BITS) +
-					BWIN_WIDGETADDR(hubaddr);
-			} else {
-				widgetnum = SWIN_WIDGETNUM(hubaddr);
-				xtalkaddr = SWIN_WIDGETADDR(hubaddr);
-			}
-			IOERROR_SETVALUE(ioerror,widgetnum,widgetnum);
-			IOERROR_SETVALUE(ioerror,xtalkaddr,xtalkaddr);
-		} else {
-			IOERR_PRINTF(printk(
-				"hub_ioerror_handler: Invalid address passed"));
-
-			return IOERROR_INVALIDADDR;
-		}
-
-
-		IOERROR_GETVALUE(p,ioerror,widgetnum);
-		if ((p) == HUB_REGISTER_WIDGET) {
-			/* 
-			 * Error in accessing Hub local register
-			 * This should happen mostly in SABLE mode..
-			 */
-			retval = 0;
-		} else {
-			/* Make sure that the outbound widget access for this
-			 * widget is enabled.
-			 */
-			if (!is_widget_pio_enabled(ioerror)) {
-				return(IOERROR_HANDLED);
-			}
-		  
-
-			retval = hub_xp_error_handler(
-				hub_v, nasid, error_code, mode, ioerror);
-
-		}
-
-		IOERR_PRINTF(printk(
-			"hub_ioerror_handler:PIO_READ_ERROR return: %d",
-				retval));
-
-		break;
-
-	case PIO_WRITE_ERROR:
-		/*
-		 * This hub received an interrupt indicating a widget 
-		 * attached to this hub got a timeout. 
-		 * widgetnum field should be filled to indicate the
-		 * widget that caused error.
-		 *
-		 * NOTE: This hub may have nothing to do with this error.
-		 * We are here since the widget attached to the xbow 
-		 * gets its PIOs through this hub.
-		 *
-		 * There is nothing that can be done at this level. 
-		 * Just invoke the xtalk error handling mechanism.
-		 */
-		IOERROR_GETVALUE(p,ioerror,widgetnum);
-		if ((p) == HUB_REGISTER_WIDGET) {
-		} else {
-			/* Make sure that the outbound widget access for this
-			 * widget is enabled.
-			 */
-
-			if (!is_widget_pio_enabled(ioerror)) {
-				return(IOERROR_HANDLED);
-			}
-		  
-			retval = hub_xp_error_handler(
-				hub_v, nasid, error_code, mode, ioerror);
-		}
-		break;
-	
-	case DMA_READ_ERROR:
-		/* 
-		 * DMA Read error always ends up generating an interrupt
-		 * at the widget level, and never at the hub level. So,
-		 * we don't expect to come here any time
-		 */
-		ASSERT(0);
-		retval = IOERROR_UNHANDLED;
-		break;
-
-	case DMA_WRITE_ERROR:
-		/*
-		 * DMA Write error is generated when a write by an I/O 
-		 * device could not be completed. Problem is, device is
-		 * totally unaware of this problem, and would continue
-		 * writing to system memory. So, hub has a way to send
-		 * an error interrupt on the first error, and bitbucket
-		 * all further write transactions.
-		 * Coming here indicates that hub detected one such error,
-		 * and we need to handle it.
-		 *
-		 * Hub interrupt handler would have extracted physaddr, 
-		 * widgetnum, and widgetdevice from the CRB 
-		 *
-		 * There is nothing special to do here, since gathering
-		 * data from crb's is done elsewhere. Just pass the 
-		 * error to xtalk layer.
-		 */
-		retval = hub_xp_error_handler(hub_v, nasid, error_code, mode,
-					      ioerror);
-		break;
-	
-	default:
-		ASSERT(0);
-		return IOERROR_BADERRORCODE;
-	
-	}
-	
-	/*
-	 * If error was not handled, we may need to take certain action
-	 * based on the error code.
-	 * For e.g. in case of PIO_READ_ERROR, we may need to release the
-	 * PIO Read entry table (they are sticky after errors).
-	 * Similarly other cases. 
-	 *
-	 * Further Action TBD 
-	 */
-end:	
-	if (retval == IOERROR_HWGRAPH_LOOKUP) {
-		/*
-		 * If we get errors very early, we can't traverse
-		 * the path using hardware graph. 
-		 * To handle this situation, we need a functions
-		 * which don't depend on the hardware graph vertex to 
-		 * handle errors. This break the modularity of the
-		 * existing code. Instead we print out the reason for
-		 * not handling error, and return. On return, all the
-		 * info collected would be dumped. This should provide 
-		 * sufficient info to analyse the error.
-		 */
-		printk("Unable to handle IO error: hardware graph not setup\n");
-	}
-
-	return retval;
-}
-
-#define INFO_LBL_ERROR_STATE    "error_state"
-
-#define v_error_state_get(v,s)                                          \
-(hwgraph_info_get_LBL(v,INFO_LBL_ERROR_STATE, (arbitrary_info_t *)&s))
-
-#define v_error_state_set(v,s,replace)                                  \
-(replace ?                                                              \
-hwgraph_info_replace_LBL(v,INFO_LBL_ERROR_STATE,(arbitrary_info_t)s,0) :\
-hwgraph_info_add_LBL(v,INFO_LBL_ERROR_STATE, (arbitrary_info_t)s))
-
-
-#define v_error_state_clear(v)                                          \
-(hwgraph_info_remove_LBL(v,INFO_LBL_ERROR_STATE,0))
-
-/*
- * error_state_get
- *              Get the state of the vertex.
- *              Returns ERROR_STATE_INVALID on failure
- *                      current state otherwise
- */
-error_state_t
-error_state_get(vertex_hdl_t v)
-{
-        error_state_t   s;
-
-        /* Check if we have a valid hwgraph vertex */
-        if ( v == (vertex_hdl_t)0 )
-                return(ERROR_STATE_NONE);
-
-        /* Get the labelled info hanging off the vertex which corresponds
-         * to the state.
-         */
-        if (v_error_state_get(v, s) != GRAPH_SUCCESS) {
-                return(ERROR_STATE_NONE);
-        }
-        return(s);
-}
-
-
-/*
- * error_state_set
- *              Set the state of the vertex
- *              Returns ERROR_RETURN_CODE_CANNOT_SET_STATE on failure
- *                      ERROR_RETURN_CODE_SUCCESS otherwise
- */
-error_return_code_t
-error_state_set(vertex_hdl_t v,error_state_t new_state)
-{
-        error_state_t   old_state;
-        int       replace = 1;
-
-        /* Check if we have a valid hwgraph vertex */
-        if ( v == (vertex_hdl_t)0 )
-                return(ERROR_RETURN_CODE_GENERAL_FAILURE);
-
-
-        /* This means that the error state needs to be cleaned */
-        if (new_state == ERROR_STATE_NONE) {
-                /* Make sure that we have an error state */
-                if (v_error_state_get(v,old_state) == GRAPH_SUCCESS)
-                        v_error_state_clear(v);
-                return(ERROR_RETURN_CODE_SUCCESS);
-        }
-
-        /* Check if the state information has been set at least once
-         * for this vertex.
-         */
-        if (v_error_state_get(v,old_state) != GRAPH_SUCCESS)
-                replace = 0;
-
-        if (v_error_state_set(v,new_state,replace) != GRAPH_SUCCESS) {
-                return(ERROR_RETURN_CODE_CANNOT_SET_STATE);
-        }
-        return(ERROR_RETURN_CODE_SUCCESS);
-}
diff -Nru a/arch/ia64/sn/io/sn2/xbow.c b/arch/ia64/sn/io/sn2/xbow.c
--- a/arch/ia64/sn/io/sn2/xbow.c	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1020 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn2/sn_private.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/simulator.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/pci/pcibr_private.h>
-
-/* #define DEBUG		1 */
-/* #define XBOW_DEBUG	1 */
-
-#define kdebug 0
-
-
-/*
- * This file supports the Xbow chip.  Main functions: initializtion,
- * error handling.
- */
-
-/*
- * each vertex corresponding to an xbow chip
- * has a "fastinfo" pointer pointing at one
- * of these things.
- */
-
-struct xbow_soft_s {
-    vertex_hdl_t            conn;	/* our connection point */
-    vertex_hdl_t            vhdl;	/* xbow's private vertex */
-    vertex_hdl_t            busv;	/* the xswitch vertex */
-    xbow_t                 *base;	/* PIO pointer to crossbow chip */
-    char                   *name;	/* hwgraph name */
-
-    xbow_link_status_t      xbow_link_status[MAX_XBOW_PORTS];
-    widget_cfg_t	   *wpio[MAX_XBOW_PORTS];	/* cached PIO pointer */
-
-    /* Bandwidth allocation state. Bandwidth values are for the
-     * destination port since contention happens there.
-     * Implicit mapping from xbow ports (8..f) -> (0..7) array indices.
-     */
-    unsigned long long	    bw_hiwm[MAX_XBOW_PORTS];	/* hiwater mark values */
-    unsigned long long      bw_cur_used[MAX_XBOW_PORTS]; /* bw used currently */
-};
-
-#define xbow_soft_set(v,i)	hwgraph_fastinfo_set((v), (arbitrary_info_t)(i))
-#define xbow_soft_get(v)	((struct xbow_soft_s *)hwgraph_fastinfo_get((v)))
-
-/*
- * Function Table of Contents
- */
-
-int                     xbow_attach(vertex_hdl_t);
-
-int                     xbow_widget_present(xbow_t *, int);
-static int              xbow_link_alive(xbow_t *, int);
-vertex_hdl_t            xbow_widget_lookup(vertex_hdl_t, int);
-
-void                    xbow_intr_preset(void *, int, xwidgetnum_t, iopaddr_t, xtalk_intr_vector_t);
-static void		xbow_setwidint(xtalk_intr_t);
-
-xswitch_reset_link_f    xbow_reset_link;
-
-xswitch_provider_t      xbow_provider =
-{
-    xbow_reset_link,
-};
-
-
-static int
-xbow_mmap(struct file * file, struct vm_area_struct * vma)
-{
-        unsigned long           phys_addr;
-        int                     error;
-
-        phys_addr = (unsigned long)file->private_data & ~0xc000000000000000; /* Mask out the Uncache bits */
-        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-        vma->vm_flags |= VM_RESERVED | VM_IO;
-        error = io_remap_page_range(vma, vma->vm_start, phys_addr,
-                                   vma->vm_end-vma->vm_start,
-                                   vma->vm_page_prot);
-        return(error);
-}
-
-/*
- * This is the file operation table for the pcibr driver.
- * As each of the functions are implemented, put the
- * appropriate function name below.
- */
-struct file_operations xbow_fops = {
-        .owner		= THIS_MODULE,
-        .mmap		= xbow_mmap,
-};
-
-#ifdef XBRIDGE_REGS_SIM
-/*    xbow_set_simulated_regs: sets xbow regs as needed
- *	for powering through the boot
- */
-void
-xbow_set_simulated_regs(xbow_t *xbow, int port)
-{
-    /*
-     * turn on link
-     */
-    xbow->xb_link(port).link_status = (1<<31);
-    /*
-     * and give it a live widget too
-     */
-    xbow->xb_link(port).link_aux_status = XB_AUX_STAT_PRESENT;
-    /*
-     * zero the link control reg
-     */
-    xbow->xb_link(port).link_control = 0x0;
-}
-#endif /* XBRIDGE_REGS_SIM */
-
-/*
- *    xbow_attach: the crosstalk provider has
- *      determined that there is a crossbow widget
- *      present, and has handed us the connection
- *      point for that vertex.
- *
- *      We not only add our own vertex, but add
- *      some "xtalk switch" data to the switch
- *      vertex (at the connect point's parent) if
- *      it does not have any.
- */
-
-/*ARGSUSED */
-int
-xbow_attach(vertex_hdl_t conn)
-{
-    /*REFERENCED */
-    vertex_hdl_t            vhdl;
-    vertex_hdl_t            busv;
-    xbow_t                  *xbow;
-    struct xbow_soft_s      *soft;
-    int                     port;
-    xswitch_info_t          info;
-    xtalk_intr_t            intr_hdl;
-    char                    devnm[MAXDEVNAME], *s;
-    xbowreg_t               id;
-    int                     rev;
-    int			    i;
-    int			    xbow_num;
-#if DEBUG && ATTACH_DEBUG
-    char		    name[MAXDEVNAME];
-#endif
-    static irqreturn_t xbow_errintr_handler(int, void *, struct pt_regs *);
-
-	
-#if DEBUG && ATTACH_DEBUG
-    printk("%s: xbow_attach\n", vertex_to_name(conn, name, MAXDEVNAME));
-#endif
-
-    /*
-     * Get a PIO pointer to the base of the crossbow
-     * chip.
-     */
-#ifdef XBRIDGE_REGS_SIM
-    printk("xbow_attach: XBRIDGE_REGS_SIM FIXME: allocating %ld bytes for xbow_s\n", sizeof(xbow_t));
-    xbow = (xbow_t *) kmalloc(sizeof(xbow_t), GFP_KERNEL);
-    if (!xbow)
-	    return -ENOMEM;
-    /*
-     * turn on ports e and f like in a real live ibrick
-     */
-    xbow_set_simulated_regs(xbow, 0xe);
-    xbow_set_simulated_regs(xbow, 0xf);
-#else
-    xbow = (xbow_t *) xtalk_piotrans_addr(conn, 0, 0, sizeof(xbow_t), 0);
-#endif /* XBRIDGE_REGS_SIM */
-
-    /*
-     * Locate the "switch" vertex: it is the parent
-     * of our connection point.
-     */
-    busv = hwgraph_connectpt_get(conn);
-#if DEBUG && ATTACH_DEBUG
-    printk("xbow_attach: Bus Vertex 0x%p, conn 0x%p, xbow register 0x%p wid= 0x%x\n", busv, conn, xbow, *(volatile u32 *)xbow);
-#endif
-
-    ASSERT(busv != GRAPH_VERTEX_NONE);
-
-    /*
-     * Create our private vertex, and connect our
-     * driver information to it. This makes it possible
-     * for diagnostic drivers to open the crossbow
-     * vertex for access to registers.
-     */
-
-    /*
-     * Register a xbow driver with hwgraph.
-     * file ops.
-     */
-    vhdl = hwgraph_register(conn, EDGE_LBL_XBOW, 0,
-	   0, 0, 0,
-	   S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
-	   (struct file_operations *)&xbow_fops, (void *)xbow);
-    if (!vhdl) {
-        printk(KERN_WARNING "xbow_attach: Unable to create char device for xbow conn %p\n",
-                (void *)conn);
-    }
-
-    /*
-     * Allocate the soft state structure and attach
-     * it to the xbow's vertex
-     */
-    soft = kmalloc(sizeof(*soft), GFP_KERNEL);
-    if (!soft)
-	    return -ENOMEM;
-    soft->conn = conn;
-    soft->vhdl = vhdl;
-    soft->busv = busv;
-    soft->base = xbow;
-    /* does the universe really need another macro?  */
-    /* xbow_soft_set(vhdl, (arbitrary_info_t) soft); */
-    /* hwgraph_fastinfo_set(vhdl, (arbitrary_info_t) soft); */
-
-#define XBOW_NUM_SUFFIX_FORMAT	"[xbow# %d]"
-
-    /* Add xbow number as a suffix to the hwgraph name of the xbow.
-     * This is helpful while looking at the error/warning messages.
-     */
-    xbow_num = 0;
-
-    /*
-     * get the name of this xbow vertex and keep the info.
-     * This is needed during errors and interupts, but as
-     * long as we have it, we can use it elsewhere.
-     */
-    s = dev_to_name(vhdl, devnm, MAXDEVNAME);
-    soft->name = kmalloc(strlen(s) + strlen(XBOW_NUM_SUFFIX_FORMAT) + 1, 
-			    GFP_KERNEL);
-    if (!soft->name) {
-	    kfree(soft);
-	    return -ENOMEM;
-    }
-    sprintf(soft->name,"%s"XBOW_NUM_SUFFIX_FORMAT, s,xbow_num);
-
-#ifdef XBRIDGE_REGS_SIM
-    /* my o200/ibrick has id=0x2d002049, but XXBOW_WIDGET_PART_NUM is defined
-     * as 0xd000, so I'm using that for the partnum bitfield.
-     */
-    printk("xbow_attach: XBRIDGE_REGS_SIM FIXME: need xb_wid_id value!!\n");
-    id = 0x2d000049;
-#else
-    id = xbow->xb_wid_id;
-#endif /* XBRIDGE_REGS_SIM */
-    rev = XWIDGET_PART_REV_NUM(id);
-
-#define XBOW_16_BIT_PORT_BW_MAX		(800 * 1000 * 1000)	/* 800 MB/s */
-
-    /* Set bandwidth hiwatermark and current values */
-    for (i = 0; i < MAX_XBOW_PORTS; i++) {
-	soft->bw_hiwm[i] = XBOW_16_BIT_PORT_BW_MAX;	/* for now */
-	soft->bw_cur_used[i] = 0;
-    }
-
-     /*
-      * attach the crossbow error interrupt.
-      */
-     intr_hdl = xtalk_intr_alloc(conn, (device_desc_t)0, vhdl);
-     ASSERT(intr_hdl != NULL);
-
-        {
-                int irq = ((hub_intr_t)intr_hdl)->i_bit;
-                int cpu = ((hub_intr_t)intr_hdl)->i_cpuid;
-
-                intr_unreserve_level(cpu, irq);
-                ((hub_intr_t)intr_hdl)->i_bit = SGI_XBOW_ERROR;
-        }
- 
-     xtalk_intr_connect(intr_hdl,
-                        (intr_func_t) xbow_errintr_handler,
-                        (intr_arg_t) soft,
-                        (xtalk_intr_setfunc_t) xbow_setwidint,
-                        (void *) xbow);
-
-     request_irq(SGI_XBOW_ERROR, (void *)xbow_errintr_handler, SA_SHIRQ, "XBOW error",
-			(intr_arg_t) soft);
-
- 
-    /*
-     * Enable xbow error interrupts
-     */
-    xbow->xb_wid_control = (XB_WID_CTRL_REG_ACC_IE | XB_WID_CTRL_XTALK_IE);
-
-    /*
-     * take a census of the widgets present,
-     * leaving notes at the switch vertex.
-     */
-    info = xswitch_info_new(busv);
-
-    for (port = MAX_PORT_NUM - MAX_XBOW_PORTS;
-	 port < MAX_PORT_NUM; ++port) {
-	if (!xbow_link_alive(xbow, port)) {
-#if DEBUG && XBOW_DEBUG
-	    printk(KERN_INFO "0x%p link %d is not alive\n",
-		    (void *)busv, port);
-#endif
-	    continue;
-	}
-	if (!xbow_widget_present(xbow, port)) {
-#if DEBUG && XBOW_DEBUG
-	    printk(KERN_INFO "0x%p link %d is alive but no widget is present\n", (void *)busv, port);
-#endif
-	    continue;
-	}
-#if DEBUG && XBOW_DEBUG
-	printk(KERN_INFO "0x%p link %d has a widget\n",
-		(void *)busv, port);
-#endif
-
-	xswitch_info_link_is_ok(info, port);
-	/*
-	 * Turn some error interrupts on
-	 * and turn others off. The PROM has
-	 * some things turned on we don't
-	 * want to see (bandwidth allocation
-	 * errors for instance); so if it
-	 * is not listed here, it is not on.
-	 */
-	xbow->xb_link(port).link_control =
-	    ( (xbow->xb_link(port).link_control
-	/*
-	 * Turn off these bits; they are non-fatal,
-	 * but we might want to save some statistics
-	 * on the frequency of these errors.
-	 * XXX FIXME XXX
-	 */
-	    & ~XB_CTRL_RCV_CNT_OFLOW_IE
-	    & ~XB_CTRL_XMT_CNT_OFLOW_IE
-	    & ~XB_CTRL_BNDWDTH_ALLOC_IE
-	    & ~XB_CTRL_RCV_IE)
-	/*
-	 * These are the ones we want to turn on.
-	 */
-	    | (XB_CTRL_ILLEGAL_DST_IE
-	    | XB_CTRL_OALLOC_IBUF_IE
-	    | XB_CTRL_XMT_MAX_RTRY_IE
-	    | XB_CTRL_MAXREQ_TOUT_IE
-	    | XB_CTRL_XMT_RTRY_IE
-	    | XB_CTRL_SRC_TOUT_IE) );
-    }
-
-    xswitch_provider_register(busv, &xbow_provider);
-
-    return 0;				/* attach successful */
-}
-
-/*
- * xbow_widget_present: See if a device is present
- * on the specified port of this crossbow.
- */
-int
-xbow_widget_present(xbow_t *xbow, int port)
-{
-	if ( IS_RUNNING_ON_SIMULATOR() ) {
-		if ( (port == 14) || (port == 15) ) {
-			return 1;
-		}
-		else {
-			return 0;
-		}
-	}
-	else {
-		/* WAR: port 0xf on PIC is missing present bit */
-		if (XBOW_WAR_ENABLED(PV854827, xbow->xb_wid_id) &&
-					IS_PIC_XBOW(xbow->xb_wid_id) && port==0xf) {
-			return 1;
-		}
-		else if ( IS_PIC_XBOW(xbow->xb_wid_id) && port==0xb ) {
-			/* for opus the present bit doesn't work on port 0xb */
-			return 1;
-		}
-		return xbow->xb_link(port).link_aux_status & XB_AUX_STAT_PRESENT;
-	}
-}
-
-static int
-xbow_link_alive(xbow_t * xbow, int port)
-{
-    xbwX_stat_t             xbow_linkstat;
-
-    xbow_linkstat.linkstatus = xbow->xb_link(port).link_status;
-    return (xbow_linkstat.link_alive);
-}
-
-/*
- * xbow_widget_lookup
- *      Lookup the edges connected to the xbow specified, and
- *      retrieve the handle corresponding to the widgetnum
- *      specified.
- *      If not found, return 0.
- */
-vertex_hdl_t
-xbow_widget_lookup(vertex_hdl_t vhdl,
-		   int widgetnum)
-{
-    xswitch_info_t          xswitch_info;
-    vertex_hdl_t            conn;
-
-    xswitch_info = xswitch_info_get(vhdl);
-    conn = xswitch_info_vhdl_get(xswitch_info, widgetnum);
-    return conn;
-}
-
-/*
- * xbow_setwidint: called when xtalk
- * is establishing or migrating our
- * interrupt service.
- */
-static void
-xbow_setwidint(xtalk_intr_t intr)
-{
-    xwidgetnum_t            targ = xtalk_intr_target_get(intr);
-    iopaddr_t               addr = xtalk_intr_addr_get(intr);
-    xtalk_intr_vector_t     vect = xtalk_intr_vector_get(intr);
-    xbow_t                 *xbow = (xbow_t *) xtalk_intr_sfarg_get(intr);
-
-    xbow_intr_preset((void *) xbow, 0, targ, addr, vect);
-}
-
-/*
- * xbow_intr_preset: called during mlreset time
- * if the platform specific code needs to route
- * an xbow interrupt before the xtalk infrastructure
- * is available for use.
- *
- * Also called from xbow_setwidint, so we don't
- * replicate the guts of the routine.
- *
- * XXX- probably should be renamed xbow_wid_intr_set or
- * something to reduce confusion.
- */
-/*ARGSUSED3 */
-void
-xbow_intr_preset(void *which_widget,
-		 int which_widget_intr,
-		 xwidgetnum_t targ,
-		 iopaddr_t addr,
-		 xtalk_intr_vector_t vect)
-{
-    xbow_t                 *xbow = (xbow_t *) which_widget;
-
-    xbow->xb_wid_int_upper = ((0xFF000000 & (vect << 24)) |
-			      (0x000F0000 & (targ << 16)) |
-			      XTALK_ADDR_TO_UPPER(addr));
-    xbow->xb_wid_int_lower = XTALK_ADDR_TO_LOWER(addr);
-
-}
-
-#define	XEM_ADD_STR(s)		printk("%s", (s))
-#define	XEM_ADD_NVAR(n,v)	printk("\t%20s: 0x%llx\n", (n), ((unsigned long long)v))
-#define	XEM_ADD_VAR(v)		XEM_ADD_NVAR(#v,(v))
-#define XEM_ADD_IOEF(p,n)	if (IOERROR_FIELDVALID(ioe,n)) {	\
-				    IOERROR_GETVALUE(p,ioe,n);		\
-				    XEM_ADD_NVAR("ioe." #n, p);		\
-				}
-
-int
-xbow_xmit_retry_error(struct xbow_soft_s *soft,
-		      int port)
-{
-    xswitch_info_t          info;
-    vertex_hdl_t            vhdl;
-    widget_cfg_t           *wid;
-    widgetreg_t             id;
-    int                     part;
-    int                     mfgr;
-
-    wid = soft->wpio[port - BASE_XBOW_PORT];
-    if (wid == NULL) {
-	/* If we can't track down a PIO
-	 * pointer to our widget yet,
-	 * leave our caller knowing that
-	 * we are interested in this
-	 * interrupt if it occurs in
-	 * the future.
-	 */
-	info = xswitch_info_get(soft->busv);
-	if (!info)
-	    return 1;
-	vhdl = xswitch_info_vhdl_get(info, port);
-	if (vhdl == GRAPH_VERTEX_NONE)
-	    return 1;
-	wid = (widget_cfg_t *) xtalk_piotrans_addr
-	    (vhdl, 0, 0, sizeof *wid, 0);
-	if (!wid)
-	    return 1;
-	soft->wpio[port - BASE_XBOW_PORT] = wid;
-    }
-    id = wid->w_id;
-    part = XWIDGET_PART_NUM(id);
-    mfgr = XWIDGET_MFG_NUM(id);
-
-    return 0;
-}
-
-/*
- * xbow_errintr_handler will be called if the xbow
- * sends an interrupt request to report an error.
- */
-static irqreturn_t
-xbow_errintr_handler(int irq, void *arg, struct pt_regs *ep)
-{
-    ioerror_t               ioe[1];
-    struct xbow_soft_s     *soft = (struct xbow_soft_s *)arg;
-    xbow_t                 *xbow = soft->base;
-    xbowreg_t               wid_control;
-    xbowreg_t               wid_stat;
-    xbowreg_t               wid_err_cmdword;
-    xbowreg_t               wid_err_upper;
-    xbowreg_t               wid_err_lower;
-    w_err_cmd_word_u        wid_err;
-    unsigned long long      wid_err_addr;
-
-    int                     fatal = 0;
-    int                     dump_ioe = 0;
-    static int xbow_error_handler(void *, int, ioerror_mode_t, ioerror_t *);
-
-    wid_control = xbow->xb_wid_control;
-    wid_stat = xbow->xb_wid_stat_clr;
-    wid_err_cmdword = xbow->xb_wid_err_cmdword;
-    wid_err_upper = xbow->xb_wid_err_upper;
-    wid_err_lower = xbow->xb_wid_err_lower;
-    xbow->xb_wid_err_cmdword = 0;
-
-    wid_err_addr = wid_err_lower | (((iopaddr_t) wid_err_upper & WIDGET_ERR_UPPER_ADDR_ONLY) << 32);
-
-    if (wid_stat & XB_WID_STAT_LINK_INTR_MASK) {
-	int                     port;
-
-	wid_err.r = wid_err_cmdword;
-
-	for (port = MAX_PORT_NUM - MAX_XBOW_PORTS;
-	     port < MAX_PORT_NUM; port++) {
-	    if (wid_stat & XB_WID_STAT_LINK_INTR(port)) {
-		xb_linkregs_t          *link = &(xbow->xb_link(port));
-		xbowreg_t               link_control = link->link_control;
-		xbowreg_t               link_status = link->link_status_clr;
-		xbowreg_t               link_aux_status = link->link_aux_status;
-		xbowreg_t               link_pend;
-
-		link_pend = link_status & link_control &
-		    (XB_STAT_ILLEGAL_DST_ERR
-		     | XB_STAT_OALLOC_IBUF_ERR
-		     | XB_STAT_RCV_CNT_OFLOW_ERR
-		     | XB_STAT_XMT_CNT_OFLOW_ERR
-		     | XB_STAT_XMT_MAX_RTRY_ERR
-		     | XB_STAT_RCV_ERR
-		     | XB_STAT_XMT_RTRY_ERR
-		     | XB_STAT_MAXREQ_TOUT_ERR
-		     | XB_STAT_SRC_TOUT_ERR
-		    );
-
-		if (link_pend & XB_STAT_ILLEGAL_DST_ERR) {
-		    if (wid_err.f.sidn == port) {
-			IOERROR_INIT(ioe);
-			IOERROR_SETVALUE(ioe, widgetnum, port);
-			IOERROR_SETVALUE(ioe, xtalkaddr, wid_err_addr);
-			if (IOERROR_HANDLED ==
-			    xbow_error_handler(soft,
-					       IOECODE_DMA,
-					       MODE_DEVERROR,
-					       ioe)) {
-			    link_pend &= ~XB_STAT_ILLEGAL_DST_ERR;
-			} else {
-			    dump_ioe++;
-			}
-		    }
-		}
-		/* Xbow/Bridge WAR:
-		 * if the bridge signals an LLP Transmitter Retry,
-		 * rewrite its control register.
-		 * If someone else triggers this interrupt,
-		 * ignore (and disable) the interrupt.
-		 */
-		if (link_pend & XB_STAT_XMT_RTRY_ERR) {
-		    if (!xbow_xmit_retry_error(soft, port)) {
-			link_control &= ~XB_CTRL_XMT_RTRY_IE;
-			link->link_control = link_control;
-			link->link_control;	/* stall until written */
-		    }
-		    link_pend &= ~XB_STAT_XMT_RTRY_ERR;
-		}
-		if (link_pend) {
-		    vertex_hdl_t	xwidget_vhdl;
-		    char		*xwidget_name;
-		    
-		    /* Get the widget name corresponding to the current
-		     * xbow link.
-		     */
-		    xwidget_vhdl = xbow_widget_lookup(soft->busv,port);
-		    xwidget_name = xwidget_name_get(xwidget_vhdl);
-
-		    printk("%s port %X[%s] XIO Bus Error",
-			    soft->name, port, xwidget_name);
-		    if (link_status & XB_STAT_MULTI_ERR)
-			XEM_ADD_STR("\tMultiple Errors\n");
-		    if (link_status & XB_STAT_ILLEGAL_DST_ERR)
-			XEM_ADD_STR("\tInvalid Packet Destination\n");
-		    if (link_status & XB_STAT_OALLOC_IBUF_ERR)
-			XEM_ADD_STR("\tInput Overallocation Error\n");
-		    if (link_status & XB_STAT_RCV_CNT_OFLOW_ERR)
-			XEM_ADD_STR("\tLLP receive error counter overflow\n");
-		    if (link_status & XB_STAT_XMT_CNT_OFLOW_ERR)
-			XEM_ADD_STR("\tLLP transmit retry counter overflow\n");
-		    if (link_status & XB_STAT_XMT_MAX_RTRY_ERR)
-			XEM_ADD_STR("\tLLP Max Transmitter Retry\n");
-		    if (link_status & XB_STAT_RCV_ERR)
-			XEM_ADD_STR("\tLLP Receiver error\n");
-		    if (link_status & XB_STAT_XMT_RTRY_ERR)
-			XEM_ADD_STR("\tLLP Transmitter Retry\n");
-		    if (link_status & XB_STAT_MAXREQ_TOUT_ERR)
-			XEM_ADD_STR("\tMaximum Request Timeout\n");
-		    if (link_status & XB_STAT_SRC_TOUT_ERR)
-			XEM_ADD_STR("\tSource Timeout Error\n");
-
-		    {
-			int                     other_port;
-
-			for (other_port = 8; other_port < 16; ++other_port) {
-			    if (link_aux_status & (1 << other_port)) {
-				/* XXX- need to go to "other_port"
-				 * and clean up after the timeout?
-				 */
-				XEM_ADD_VAR(other_port);
-			    }
-			}
-		    }
-
-#if !DEBUG
-		    if (kdebug) {
-#endif
-			XEM_ADD_VAR(link_control);
-			XEM_ADD_VAR(link_status);
-			XEM_ADD_VAR(link_aux_status);
-
-#if !DEBUG
-		    }
-#endif
-		    fatal++;
-		}
-	    }
-	}
-    }
-    if (wid_stat & wid_control & XB_WID_STAT_WIDGET0_INTR) {
-	/* we have a "widget zero" problem */
-
-	if (wid_stat & (XB_WID_STAT_MULTI_ERR
-			| XB_WID_STAT_XTALK_ERR
-			| XB_WID_STAT_REG_ACC_ERR)) {
-
-	    printk("%s Port 0 XIO Bus Error",
-		    soft->name);
-	    if (wid_stat & XB_WID_STAT_MULTI_ERR)
-		XEM_ADD_STR("\tMultiple Error\n");
-	    if (wid_stat & XB_WID_STAT_XTALK_ERR)
-		XEM_ADD_STR("\tXIO Error\n");
-	    if (wid_stat & XB_WID_STAT_REG_ACC_ERR)
-		XEM_ADD_STR("\tRegister Access Error\n");
-
-	    fatal++;
-	}
-    }
-    if (fatal) {
-	XEM_ADD_VAR(wid_stat);
-	XEM_ADD_VAR(wid_control);
-	XEM_ADD_VAR(wid_err_cmdword);
-	XEM_ADD_VAR(wid_err_upper);
-	XEM_ADD_VAR(wid_err_lower);
-	XEM_ADD_VAR(wid_err_addr);
-	panic("XIO Bus Error");
-    }
-    return IRQ_HANDLED;
-}
-
-/*
- * XBOW ERROR Handling routines.
- * These get invoked as part of walking down the error handling path
- * from hub/heart towards the I/O device that caused the error.
- */
-
-/*
- * xbow_error_handler
- *      XBow error handling dispatch routine.
- *      This is the primary interface used by external world to invoke
- *      in case of an error related to a xbow.
- *      Only functionality in this layer is to identify the widget handle
- *      given the widgetnum. Otherwise, xbow does not gathers any error
- *      data.
- */
-static int
-xbow_error_handler(
-		      void *einfo,
-		      int error_code,
-		      ioerror_mode_t mode,
-		      ioerror_t *ioerror)
-{
-    int                    retval = IOERROR_WIDGETLEVEL;
-
-    struct xbow_soft_s    *soft = (struct xbow_soft_s *) einfo;
-    int                   port;
-    vertex_hdl_t          conn;
-    vertex_hdl_t          busv;
-
-    xbow_t                 *xbow = soft->base;
-    xbowreg_t               wid_stat;
-    xbowreg_t               wid_err_cmdword;
-    xbowreg_t               wid_err_upper;
-    xbowreg_t               wid_err_lower;
-    unsigned long long      wid_err_addr;
-
-    xb_linkregs_t          *link;
-    xbowreg_t               link_control;
-    xbowreg_t               link_status;
-    xbowreg_t               link_aux_status;
-
-    ASSERT(soft != 0);
-    busv = soft->busv;
-
-#if DEBUG && ERROR_DEBUG
-    printk("%s: xbow_error_handler\n", soft->name, busv);
-#endif
-
-    IOERROR_GETVALUE(port, ioerror, widgetnum);
-
-    if (port == 0) {
-	/* error during access to xbow:
-	 * do NOT attempt to access xbow regs.
-	 */
-	if (mode == MODE_DEVPROBE)
-	    return IOERROR_HANDLED;
-
-	if (error_code & IOECODE_DMA) {
-	    printk(KERN_ALERT
-		    "DMA error blamed on Crossbow at %s\n"
-		    "\tbut Crosbow never initiates DMA!",
-		    soft->name);
-	}
-	if (error_code & IOECODE_PIO) {
-	    iopaddr_t tmp;
-	    IOERROR_GETVALUE(tmp, ioerror, xtalkaddr);
-	    printk(KERN_ALERT "PIO Error on XIO Bus %s\n"
-		    "\tattempting to access XIO controller\n"
-		    "\twith offset 0x%lx",
-		    soft->name, tmp);
-	}
-	/* caller will dump contents of ioerror
-	 * in DEBUG and kdebug kernels.
-	 */
-
-	return retval;
-    }
-    /*
-     * error not on port zero:
-     * safe to read xbow registers.
-     */
-    wid_stat = xbow->xb_wid_stat;
-    wid_err_cmdword = xbow->xb_wid_err_cmdword;
-    wid_err_upper = xbow->xb_wid_err_upper;
-    wid_err_lower = xbow->xb_wid_err_lower;
-
-    wid_err_addr =
-	wid_err_lower
-	| (((iopaddr_t) wid_err_upper
-	    & WIDGET_ERR_UPPER_ADDR_ONLY)
-	   << 32);
-
-    if ((port < BASE_XBOW_PORT) ||
-	(port >= MAX_PORT_NUM)) {
-
-	if (mode == MODE_DEVPROBE)
-	    return IOERROR_HANDLED;
-
-	if (error_code & IOECODE_DMA) {
-	    printk(KERN_ALERT
-		    "DMA error blamed on XIO port at %s/%d\n"
-		    "\tbut Crossbow does not support that port",
-		    soft->name, port);
-	}
-	if (error_code & IOECODE_PIO) {
-	    iopaddr_t tmp;
-	    IOERROR_GETVALUE(tmp, ioerror, xtalkaddr);
-	    printk(KERN_ALERT
-		    "PIO Error on XIO Bus %s\n"
-		    "\tattempting to access XIO port %d\n"
-		    "\t(which Crossbow does not support)"
-		    "\twith offset 0x%lx",
-		    soft->name, port, tmp);
-	}
-#if !DEBUG
-	if (kdebug) {
-#endif
-	    XEM_ADD_STR("Raw status values for Crossbow:\n");
-	    XEM_ADD_VAR(wid_stat);
-	    XEM_ADD_VAR(wid_err_cmdword);
-	    XEM_ADD_VAR(wid_err_upper);
-	    XEM_ADD_VAR(wid_err_lower);
-	    XEM_ADD_VAR(wid_err_addr);
-#if !DEBUG
-	}
-#endif
-
-	/* caller will dump contents of ioerror
-	 * in DEBUG and kdebug kernels.
-	 */
-
-	return retval;
-    }
-    /* access to valid port:
-     * ok to check port status.
-     */
-
-    link = &(xbow->xb_link(port));
-    link_control = link->link_control;
-    link_status = link->link_status;
-    link_aux_status = link->link_aux_status;
-
-    /* Check that there is something present
-     * in that XIO port.
-     */
-    /* WAR: PIC widget 0xf is missing prescense bit */
-    if (XBOW_WAR_ENABLED(PV854827, xbow->xb_wid_id) &&
-		IS_PIC_XBOW(xbow->xb_wid_id) && (port==0xf))
-		;
-    else if (IS_PIC_XBOW(xbow->xb_wid_id) && (port==0xb))
-		;	/* WAR for opus this is missing on 0xb */
-    else if (!(link_aux_status & XB_AUX_STAT_PRESENT)) {
-	/* nobody connected. */
-	if (mode == MODE_DEVPROBE)
-	    return IOERROR_HANDLED;
-
-	if (error_code & IOECODE_DMA) {
-	    printk(KERN_ALERT
-		    "DMA error blamed on XIO port at %s/%d\n"
-		    "\tbut there is no device connected there.",
-		    soft->name, port);
-	}
-	if (error_code & IOECODE_PIO) {
-	    iopaddr_t tmp;
-	    IOERROR_GETVALUE(tmp, ioerror, xtalkaddr);
-	    printk(KERN_ALERT
-		    "PIO Error on XIO Bus %s\n"
-		    "\tattempting to access XIO port %d\n"
-		    "\t(which has no device connected)"
-		    "\twith offset 0x%lx",
-		    soft->name, port, tmp);
-	}
-#if !DEBUG
-	if (kdebug) {
-#endif
-	    XEM_ADD_STR("Raw status values for Crossbow:\n");
-	    XEM_ADD_VAR(wid_stat);
-	    XEM_ADD_VAR(wid_err_cmdword);
-	    XEM_ADD_VAR(wid_err_upper);
-	    XEM_ADD_VAR(wid_err_lower);
-	    XEM_ADD_VAR(wid_err_addr);
-	    XEM_ADD_VAR(port);
-	    XEM_ADD_VAR(link_control);
-	    XEM_ADD_VAR(link_status);
-	    XEM_ADD_VAR(link_aux_status);
-#if !DEBUG
-	}
-#endif
-	return retval;
-
-    }
-    /* Check that the link is alive.
-     */
-    if (!(link_status & XB_STAT_LINKALIVE)) {
-	iopaddr_t tmp;
-	/* nobody connected. */
-	if (mode == MODE_DEVPROBE)
-	    return IOERROR_HANDLED;
-
-	printk(KERN_ALERT
-		"%s%sError on XIO Bus %s port %d",
-		(error_code & IOECODE_DMA) ? "DMA " : "",
-		(error_code & IOECODE_PIO) ? "PIO " : "",
-		soft->name, port);
-
-	IOERROR_GETVALUE(tmp, ioerror, xtalkaddr);
-	if ((error_code & IOECODE_PIO) &&
-	    (IOERROR_FIELDVALID(ioerror, xtalkaddr))) {
-		printk("\tAccess attempted to offset 0x%lx\n", tmp);
-	}
-	if (link_aux_status & XB_AUX_LINKFAIL_RST_BAD)
-	    XEM_ADD_STR("\tLink never came out of reset\n");
-	else
-	    XEM_ADD_STR("\tLink failed while transferring data\n");
-
-    }
-    /* get the connection point for the widget
-     * involved in this error; if it exists and
-     * is not our connectpoint, cycle back through
-     * xtalk_error_handler to deliver control to
-     * the proper handler (or to report a generic
-     * crosstalk error).
-     *
-     * If the downstream handler won't handle
-     * the problem, we let our upstream caller
-     * deal with it, after (in DEBUG and kdebug
-     * kernels) dumping the xbow state for this
-     * port.
-     */
-    conn = xbow_widget_lookup(busv, port);
-    if ((conn != GRAPH_VERTEX_NONE) &&
-	(conn != soft->conn)) {
-	retval = xtalk_error_handler(conn, error_code, mode, ioerror);
-	if (retval == IOERROR_HANDLED)
-	    return IOERROR_HANDLED;
-    }
-    if (mode == MODE_DEVPROBE)
-	return IOERROR_HANDLED;
-
-    if (retval == IOERROR_UNHANDLED) {
-	iopaddr_t tmp;
-	retval = IOERROR_PANIC;
-
-	printk(KERN_ALERT
-		"%s%sError on XIO Bus %s port %d",
-		(error_code & IOECODE_DMA) ? "DMA " : "",
-		(error_code & IOECODE_PIO) ? "PIO " : "",
-		soft->name, port);
-
-	IOERROR_GETVALUE(tmp, ioerror, xtalkaddr);
-	if ((error_code & IOECODE_PIO) &&
-	    (IOERROR_FIELDVALID(ioerror, xtalkaddr))) {
-	    printk("\tAccess attempted to offset 0x%lx\n", tmp);
-	}
-    }
-
-#if !DEBUG
-    if (kdebug) {
-#endif
-	XEM_ADD_STR("Raw status values for Crossbow:\n");
-	XEM_ADD_VAR(wid_stat);
-	XEM_ADD_VAR(wid_err_cmdword);
-	XEM_ADD_VAR(wid_err_upper);
-	XEM_ADD_VAR(wid_err_lower);
-	XEM_ADD_VAR(wid_err_addr);
-	XEM_ADD_VAR(port);
-	XEM_ADD_VAR(link_control);
-	XEM_ADD_VAR(link_status);
-	XEM_ADD_VAR(link_aux_status);
-#if !DEBUG
-    }
-#endif
-    /* caller will dump raw ioerror data
-     * in DEBUG and kdebug kernels.
-     */
-
-    return retval;
-}
-
-int
-xbow_reset_link(vertex_hdl_t xconn_vhdl)
-{
-    xwidget_info_t          widget_info;
-    xwidgetnum_t            port;
-    xbow_t                 *xbow;
-    xbowreg_t               ctrl;
-    xbwX_stat_t             stat;
-    unsigned                long itick;
-    unsigned int            dtick;
-    static long             ticks_to_wait = HZ / 1000;
-
-    widget_info = xwidget_info_get(xconn_vhdl);
-    port = xwidget_info_id_get(widget_info);
-
-#ifdef XBOW_K1PTR			/* defined if we only have one xbow ... */
-    xbow = XBOW_K1PTR;
-#else
-    {
-	vertex_hdl_t            xbow_vhdl;
-	struct xbow_soft_s      *xbow_soft;
-
-	hwgraph_traverse(xconn_vhdl, ".master/xtalk/0/xbow", &xbow_vhdl);
-	xbow_soft = xbow_soft_get(xbow_vhdl);
-	xbow = xbow_soft->base;
-    }
-#endif
-
-    /*
-     * This requires three PIOs (reset the link, check for the
-     * reset, restore the control register for the link) plus
-     * 10us to wait for the reset. We allow up to 1ms for the
-     * widget to come out of reset before giving up and
-     * returning a failure.
-     */
-    ctrl = xbow->xb_link(port).link_control;
-    xbow->xb_link(port).link_reset = 0;
-    itick = jiffies;
-    while (1) {
-	stat.linkstatus = xbow->xb_link(port).link_status;
-	if (stat.link_alive)
-	    break;
-	dtick = jiffies - itick;
-	if (dtick > ticks_to_wait) {
-	    return -1;			/* never came out of reset */
-	}
-	udelay(2);			/* don't beat on link_status */
-    }
-    xbow->xb_link(port).link_control = ctrl;
-    return 0;
-}
diff -Nru a/arch/ia64/sn/io/sn2/xtalk.c b/arch/ia64/sn/io/sn2/xtalk.c
--- a/arch/ia64/sn/io/sn2/xtalk.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,927 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/io.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/xtalk/xswitch.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/xtalk/xtalk_private.h>
-
-/*
- * Implement io channel provider operations.  The xtalk* layer provides a
- * platform-independent interface for io channel devices.  This layer
- * switches among the possible implementations of a io channel adapter.
- *
- * On platforms with only one possible xtalk provider, macros can be
- * set up at the top that cause the table lookups and indirections to
- * completely disappear.
- */
-
-char                    widget_info_fingerprint[] = "widget_info";
-
-/* =====================================================================
- *            Function Table of Contents
- */
-xtalk_piomap_t          xtalk_piomap_alloc(vertex_hdl_t, device_desc_t, iopaddr_t, size_t, size_t, unsigned);
-void                    xtalk_piomap_free(xtalk_piomap_t);
-caddr_t                 xtalk_piomap_addr(xtalk_piomap_t, iopaddr_t, size_t);
-void                    xtalk_piomap_done(xtalk_piomap_t);
-caddr_t                 xtalk_piotrans_addr(vertex_hdl_t, device_desc_t, iopaddr_t, size_t, unsigned);
-caddr_t                 xtalk_pio_addr(vertex_hdl_t, device_desc_t, iopaddr_t, size_t, xtalk_piomap_t *, unsigned);
-void                    xtalk_set_early_piotrans_addr(xtalk_early_piotrans_addr_f *);
-caddr_t                 xtalk_early_piotrans_addr(xwidget_part_num_t, xwidget_mfg_num_t, int, iopaddr_t, size_t, unsigned);
-static caddr_t          null_xtalk_early_piotrans_addr(xwidget_part_num_t, xwidget_mfg_num_t, int, iopaddr_t, size_t, unsigned);
-xtalk_dmamap_t          xtalk_dmamap_alloc(vertex_hdl_t, device_desc_t, size_t, unsigned);
-void                    xtalk_dmamap_free(xtalk_dmamap_t);
-iopaddr_t               xtalk_dmamap_addr(xtalk_dmamap_t, paddr_t, size_t);
-void                    xtalk_dmamap_done(xtalk_dmamap_t);
-iopaddr_t               xtalk_dmatrans_addr(vertex_hdl_t, device_desc_t, paddr_t, size_t, unsigned);
-void			xtalk_dmamap_drain(xtalk_dmamap_t);
-void			xtalk_dmaaddr_drain(vertex_hdl_t, iopaddr_t, size_t);
-xtalk_intr_t            xtalk_intr_alloc(vertex_hdl_t, device_desc_t, vertex_hdl_t);
-xtalk_intr_t            xtalk_intr_alloc_nothd(vertex_hdl_t, device_desc_t, vertex_hdl_t);
-void                    xtalk_intr_free(xtalk_intr_t);
-int                     xtalk_intr_connect(xtalk_intr_t, intr_func_t, intr_arg_t, xtalk_intr_setfunc_t, void *);
-void                    xtalk_intr_disconnect(xtalk_intr_t);
-vertex_hdl_t            xtalk_intr_cpu_get(xtalk_intr_t);
-int                     xtalk_error_handler(vertex_hdl_t, int, ioerror_mode_t, ioerror_t *);
-void                    xtalk_provider_startup(vertex_hdl_t);
-void                    xtalk_provider_shutdown(vertex_hdl_t);
-vertex_hdl_t            xtalk_intr_dev_get(xtalk_intr_t);
-xwidgetnum_t            xtalk_intr_target_get(xtalk_intr_t);
-xtalk_intr_vector_t     xtalk_intr_vector_get(xtalk_intr_t);
-iopaddr_t               xtalk_intr_addr_get(struct xtalk_intr_s *);
-void                   *xtalk_intr_sfarg_get(xtalk_intr_t);
-vertex_hdl_t            xtalk_pio_dev_get(xtalk_piomap_t);
-xwidgetnum_t            xtalk_pio_target_get(xtalk_piomap_t);
-iopaddr_t               xtalk_pio_xtalk_addr_get(xtalk_piomap_t);
-ulong                   xtalk_pio_mapsz_get(xtalk_piomap_t);
-caddr_t                 xtalk_pio_kvaddr_get(xtalk_piomap_t);
-vertex_hdl_t            xtalk_dma_dev_get(xtalk_dmamap_t);
-xwidgetnum_t            xtalk_dma_target_get(xtalk_dmamap_t);
-xwidget_info_t          xwidget_info_chk(vertex_hdl_t);
-xwidget_info_t          xwidget_info_get(vertex_hdl_t);
-void                    xwidget_info_set(vertex_hdl_t, xwidget_info_t);
-vertex_hdl_t            xwidget_info_dev_get(xwidget_info_t);
-xwidgetnum_t            xwidget_info_id_get(xwidget_info_t);
-vertex_hdl_t            xwidget_info_master_get(xwidget_info_t);
-xwidgetnum_t            xwidget_info_masterid_get(xwidget_info_t);
-xwidget_part_num_t      xwidget_info_part_num_get(xwidget_info_t);
-xwidget_mfg_num_t       xwidget_info_mfg_num_get(xwidget_info_t);
-char 			*xwidget_info_name_get(xwidget_info_t);
-void                    xtalk_provider_register(vertex_hdl_t, xtalk_provider_t *);
-void                    xtalk_provider_unregister(vertex_hdl_t);
-xtalk_provider_t       *xtalk_provider_fns_get(vertex_hdl_t);
-int                     xwidget_driver_register(xwidget_part_num_t, 
-						xwidget_mfg_num_t, 
-						char *, unsigned);
-void                    xwidget_driver_unregister(char *);
-int                     xwidget_register(xwidget_hwid_t, vertex_hdl_t, 
-					 xwidgetnum_t, vertex_hdl_t, 
-					 xwidgetnum_t);
-int			xwidget_unregister(vertex_hdl_t);
-void                    xwidget_reset(vertex_hdl_t);
-char			*xwidget_name_get(vertex_hdl_t);
-#if !defined(DEV_FUNC)
-/*
- * There is more than one possible provider
- * for this platform. We need to examine the
- * master vertex of the current vertex for
- * a provider function structure, and indirect
- * through the appropriately named member.
- */
-#define	DEV_FUNC(dev,func)	xwidget_to_provider_fns(dev)->func
-#define	CAST_PIOMAP(x)		((xtalk_piomap_t)(x))
-#define	CAST_DMAMAP(x)		((xtalk_dmamap_t)(x))
-#define	CAST_INTR(x)		((xtalk_intr_t)(x))
-xtalk_provider_t * xwidget_info_pops_get(xwidget_info_t info);
-
-static xtalk_provider_t *
-xwidget_to_provider_fns(vertex_hdl_t xconn)
-{
-    xwidget_info_t          widget_info;
-    xtalk_provider_t       *provider_fns;
-
-    widget_info = xwidget_info_get(xconn);
-    ASSERT(widget_info != NULL);
-
-    provider_fns = xwidget_info_pops_get(widget_info);
-    ASSERT(provider_fns != NULL);
-
-    return (provider_fns);
-}
-
-xtalk_provider_t *
-xwidget_info_pops_get(xwidget_info_t info) {
-	vertex_hdl_t master = info->w_master;
-	xtalk_provider_t *provider_fns;
-
-	provider_fns = xtalk_provider_fns_get(master);
-
-	ASSERT(provider_fns != NULL);
-	return provider_fns;
-}
-#endif
-
-/*
- * Many functions are not passed their vertex
- * information directly; rather, they must
- * dive through a resource map. These macros
- * are available to coordinate this detail.
- */
-#define	PIOMAP_FUNC(map,func)	DEV_FUNC(map->xp_dev,func)
-#define	DMAMAP_FUNC(map,func)	DEV_FUNC(map->xd_dev,func)
-#define	INTR_FUNC(intr,func)	DEV_FUNC(intr_hdl->xi_dev,func)
-
-/* =====================================================================
- *                    PIO MANAGEMENT
- *
- *      For mapping system virtual address space to
- *      xtalk space on a specified widget
- */
-
-xtalk_piomap_t
-xtalk_piomap_alloc(vertex_hdl_t dev,	/* set up mapping for this device */
-		   device_desc_t dev_desc,	/* device descriptor */
-		   iopaddr_t xtalk_addr,	/* map for this xtalk_addr range */
-		   size_t byte_count,
-		   size_t byte_count_max,	/* maximum size of a mapping */
-		   unsigned flags)
-{				/* defined in sys/pio.h */
-    return (xtalk_piomap_t) DEV_FUNC(dev, piomap_alloc)
-	(dev, dev_desc, xtalk_addr, byte_count, byte_count_max, flags);
-}
-
-
-void
-xtalk_piomap_free(xtalk_piomap_t xtalk_piomap)
-{
-    PIOMAP_FUNC(xtalk_piomap, piomap_free)
-	(CAST_PIOMAP(xtalk_piomap));
-}
-
-
-caddr_t
-xtalk_piomap_addr(xtalk_piomap_t xtalk_piomap,	/* mapping resources */
-		  iopaddr_t xtalk_addr,		/* map for this xtalk address */
-		  size_t byte_count)
-{				/* map this many bytes */
-    return PIOMAP_FUNC(xtalk_piomap, piomap_addr)
-	(CAST_PIOMAP(xtalk_piomap), xtalk_addr, byte_count);
-}
-
-
-void
-xtalk_piomap_done(xtalk_piomap_t xtalk_piomap)
-{
-    PIOMAP_FUNC(xtalk_piomap, piomap_done)
-	(CAST_PIOMAP(xtalk_piomap));
-}
-
-
-caddr_t
-xtalk_piotrans_addr(vertex_hdl_t dev,	/* translate for this device */
-		    device_desc_t dev_desc,	/* device descriptor */
-		    iopaddr_t xtalk_addr,	/* Crosstalk address */
-		    size_t byte_count,	/* map this many bytes */
-		    unsigned flags)
-{				/* (currently unused) */
-    return DEV_FUNC(dev, piotrans_addr)
-	(dev, dev_desc, xtalk_addr, byte_count, flags);
-}
-
-caddr_t
-xtalk_pio_addr(vertex_hdl_t dev,	/* translate for this device */
-	       device_desc_t dev_desc,	/* device descriptor */
-	       iopaddr_t addr,		/* starting address (or offset in window) */
-	       size_t byte_count,	/* map this many bytes */
-	       xtalk_piomap_t *mapp,	/* where to return the map pointer */
-	       unsigned flags)
-{					/* PIO flags */
-    xtalk_piomap_t          map = 0;
-    caddr_t                 res;
-
-    if (mapp)
-	*mapp = 0;			/* record "no map used" */
-
-    res = xtalk_piotrans_addr
-	(dev, dev_desc, addr, byte_count, flags);
-    if (res)
-	return res;			/* xtalk_piotrans worked */
-
-    map = xtalk_piomap_alloc
-	(dev, dev_desc, addr, byte_count, byte_count, flags);
-    if (!map)
-	return res;			/* xtalk_piomap_alloc failed */
-
-    res = xtalk_piomap_addr
-	(map, addr, byte_count);
-    if (!res) {
-	xtalk_piomap_free(map);
-	return res;			/* xtalk_piomap_addr failed */
-    }
-    if (mapp)
-	*mapp = map;			/* pass back map used */
-
-    return res;				/* xtalk_piomap_addr succeeded */
-}
-
-/* =====================================================================
- *            EARLY PIOTRANS SUPPORT
- *
- *      There are places where drivers (mgras, for instance)
- *      need to get PIO translations before the infrastructure
- *      is extended to them (setting up textports, for
- *      instance). These drivers should call
- *      xtalk_early_piotrans_addr with their xtalk ID
- *      information, a sequence number (so we can use the second
- *      mgras for instance), and the usual piotrans parameters.
- *
- *      Machine specific code should provide an implementation
- *      of early_piotrans_addr, and present a pointer to this
- *      function to xtalk_set_early_piotrans_addr so it can be
- *      used by clients without the clients having to know what
- *      platform or what xtalk provider is in use.
- */
-
-static xtalk_early_piotrans_addr_f null_xtalk_early_piotrans_addr;
-
-xtalk_early_piotrans_addr_f *impl_early_piotrans_addr = null_xtalk_early_piotrans_addr;
-
-/* xtalk_set_early_piotrans_addr:
- * specify the early_piotrans_addr implementation function.
- */
-void
-xtalk_set_early_piotrans_addr(xtalk_early_piotrans_addr_f *impl)
-{
-    impl_early_piotrans_addr = impl;
-}
-
-/* xtalk_early_piotrans_addr:
- * figure out a PIO address for the "nth" io channel widget that
- * matches the specified part and mfgr number. Returns NULL if
- * there is no such widget, or if the requested mapping can not
- * be constructed.
- * Limitations on which io channel slots (and busses) are
- * checked, and definitions of the ordering of the search across
- * the io channel slots, are defined by the platform.
- */
-caddr_t
-xtalk_early_piotrans_addr(xwidget_part_num_t part_num,
-			  xwidget_mfg_num_t mfg_num,
-			  int which,
-			  iopaddr_t xtalk_addr,
-			  size_t byte_count,
-			  unsigned flags)
-{
-    return impl_early_piotrans_addr
-	(part_num, mfg_num, which, xtalk_addr, byte_count, flags);
-}
-
-/* null_xtalk_early_piotrans_addr:
- * used as the early_piotrans_addr implementation until and
- * unless a real implementation is provided. In DEBUG kernels,
- * we want to know who is calling before the implementation is
- * registered; in non-DEBUG kernels, return NULL representing
- * lack of mapping support.
- */
-/*ARGSUSED */
-static caddr_t
-null_xtalk_early_piotrans_addr(xwidget_part_num_t part_num,
-			       xwidget_mfg_num_t mfg_num,
-			       int which,
-			       iopaddr_t xtalk_addr,
-			       size_t byte_count,
-			       unsigned flags)
-{
-#if DEBUG
-    panic("null_xtalk_early_piotrans_addr");
-#endif
-    return NULL;
-}
-
-/* =====================================================================
- *                    DMA MANAGEMENT
- *
- *      For mapping from io channel space to system
- *      physical space.
- */
-
-xtalk_dmamap_t
-xtalk_dmamap_alloc(vertex_hdl_t dev,	/* set up mappings for this device */
-		   device_desc_t dev_desc,	/* device descriptor */
-		   size_t byte_count_max,	/* max size of a mapping */
-		   unsigned flags)
-{				/* defined in dma.h */
-    return (xtalk_dmamap_t) DEV_FUNC(dev, dmamap_alloc)
-	(dev, dev_desc, byte_count_max, flags);
-}
-
-
-void
-xtalk_dmamap_free(xtalk_dmamap_t xtalk_dmamap)
-{
-    DMAMAP_FUNC(xtalk_dmamap, dmamap_free)
-	(CAST_DMAMAP(xtalk_dmamap));
-}
-
-
-iopaddr_t
-xtalk_dmamap_addr(xtalk_dmamap_t xtalk_dmamap,	/* use these mapping resources */
-		  paddr_t paddr,	/* map for this address */
-		  size_t byte_count)
-{				/* map this many bytes */
-    return DMAMAP_FUNC(xtalk_dmamap, dmamap_addr)
-	(CAST_DMAMAP(xtalk_dmamap), paddr, byte_count);
-}
-
-
-void
-xtalk_dmamap_done(xtalk_dmamap_t xtalk_dmamap)
-{
-    DMAMAP_FUNC(xtalk_dmamap, dmamap_done)
-	(CAST_DMAMAP(xtalk_dmamap));
-}
-
-
-iopaddr_t
-xtalk_dmatrans_addr(vertex_hdl_t dev,	/* translate for this device */
-		    device_desc_t dev_desc,	/* device descriptor */
-		    paddr_t paddr,	/* system physical address */
-		    size_t byte_count,	/* length */
-		    unsigned flags)
-{				/* defined in dma.h */
-    return DEV_FUNC(dev, dmatrans_addr)
-	(dev, dev_desc, paddr, byte_count, flags);
-}
-
-
-void
-xtalk_dmamap_drain(xtalk_dmamap_t map)
-{
-    DMAMAP_FUNC(map, dmamap_drain)
-	(CAST_DMAMAP(map));
-}
-
-void
-xtalk_dmaaddr_drain(vertex_hdl_t dev, paddr_t addr, size_t size)
-{
-    DEV_FUNC(dev, dmaaddr_drain)
-	(dev, addr, size);
-}
-
-/* =====================================================================
- *                    INTERRUPT MANAGEMENT
- *
- *      Allow io channel devices to establish interrupts
- */
-
-/*
- * Allocate resources required for an interrupt as specified in intr_desc.
- * Return resource handle in intr_hdl.
- */
-xtalk_intr_t
-xtalk_intr_alloc(vertex_hdl_t dev,	/* which Crosstalk device */
-		 device_desc_t dev_desc,	/* device descriptor */
-		 vertex_hdl_t owner_dev)
-{				/* owner of this interrupt */
-    return (xtalk_intr_t) DEV_FUNC(dev, intr_alloc)
-	(dev, dev_desc, owner_dev);
-}
-
-/*
- * Allocate resources required for an interrupt as specified in dev_desc.
- * Unconditionally setup resources to be non-threaded.
- * Return resource handle in intr_hdl.
- */
-xtalk_intr_t
-xtalk_intr_alloc_nothd(vertex_hdl_t dev,	/* which Crosstalk device */
-		 	device_desc_t dev_desc,	/* device descriptor */
-		 	vertex_hdl_t owner_dev)	/* owner of this interrupt */
-{
-    return (xtalk_intr_t) DEV_FUNC(dev, intr_alloc_nothd)
-	(dev, dev_desc, owner_dev);
-}
-
-/*
- * Free resources consumed by intr_alloc.
- */
-void
-xtalk_intr_free(xtalk_intr_t intr_hdl)
-{
-    INTR_FUNC(intr_hdl, intr_free)
-	(CAST_INTR(intr_hdl));
-}
-
-
-/*
- * Associate resources allocated with a previous xtalk_intr_alloc call with the
- * described handler, arg, name, etc.
- *
- * Returns 0 on success, returns <0 on failure.
- */
-int
-xtalk_intr_connect(xtalk_intr_t intr_hdl,	/* xtalk intr resource handle */
-		   intr_func_t intr_func,       /* xtalk intr handler */
-		   intr_arg_t intr_arg,         /* arg to intr handler */
-		   xtalk_intr_setfunc_t setfunc,	/* func to set intr hw */
-		   void *setfunc_arg)	/* arg to setfunc */
-{
-    return INTR_FUNC(intr_hdl, intr_connect)
-	(CAST_INTR(intr_hdl), intr_func, intr_arg, setfunc, setfunc_arg);
-}
-
-
-/*
- * Disassociate handler with the specified interrupt.
- */
-void
-xtalk_intr_disconnect(xtalk_intr_t intr_hdl)
-{
-    INTR_FUNC(intr_hdl, intr_disconnect)
-	(CAST_INTR(intr_hdl));
-}
-
-
-/*
- * Return a hwgraph vertex that represents the CPU currently
- * targeted by an interrupt.
- */
-vertex_hdl_t
-xtalk_intr_cpu_get(xtalk_intr_t intr_hdl)
-{
-      return (vertex_hdl_t)0;
-}
-
-
-/*
- * =====================================================================
- *                      ERROR MANAGEMENT
- */
-
-/*
- * xtalk_error_handler:
- * pass this error on to the handler registered
- * at the specified xtalk connecdtion point,
- * or complain about it here if there is no handler.
- *
- * This routine plays two roles during error delivery
- * to most widgets: first, the external agent (heart,
- * hub, or whatever) calls in with the error and the
- * connect point representing the io channel switch,
- * or whatever io channel device is directly connected
- * to the agent.
- *
- * If there is a switch, it will generally look at the
- * widget number stashed in the ioerror structure; and,
- * if the error came from some widget other than the
- * switch, it will call back into xtalk_error_handler
- * with the connection point of the offending port.
- */
-int
-xtalk_error_handler(
-		       vertex_hdl_t xconn,
-		       int error_code,
-		       ioerror_mode_t mode,
-		       ioerror_t *ioerror)
-{
-    xwidget_info_t          xwidget_info;
-    char		    name[MAXDEVNAME];
-
-
-    xwidget_info = xwidget_info_get(xconn);
-    /* Make sure that xwidget_info is a valid pointer before derefencing it.
-     * We could come in here during very early initialization. 
-     */
-    if (xwidget_info && xwidget_info->w_efunc)
-	return xwidget_info->w_efunc
-	    (xwidget_info->w_einfo,
-	     error_code, mode, ioerror);
-    /*
-     * no error handler registered for
-     * the offending port. it's not clear
-     * what needs to be done, but reporting
-     * it would be a good thing, unless it
-     * is a mode that requires nothing.
-     */
-    if ((mode == MODE_DEVPROBE) || (mode == MODE_DEVUSERERROR) ||
-	(mode == MODE_DEVREENABLE))
-	return IOERROR_HANDLED;
-
-    printk(KERN_WARNING "Xbow at %s encountered Fatal error", vertex_to_name(xconn, name, MAXDEVNAME));
-
-    return IOERROR_UNHANDLED;
-}
-
-
-/* =====================================================================
- *                    CONFIGURATION MANAGEMENT
- */
-
-/*
- * Startup an io channel provider
- */
-void
-xtalk_provider_startup(vertex_hdl_t xtalk_provider)
-{
-    ((xtalk_provider_t *) hwgraph_fastinfo_get(xtalk_provider))->provider_startup(xtalk_provider);
-}
-
-
-/*
- * Shutdown an io channel provider
- */
-void
-xtalk_provider_shutdown(vertex_hdl_t xtalk_provider)
-{
-    ((xtalk_provider_t *) hwgraph_fastinfo_get(xtalk_provider))->provider_shutdown(xtalk_provider);
-}
-
-/* 
- * Enable a device on a xtalk widget 
- */
-void
-xtalk_widgetdev_enable(vertex_hdl_t xconn_vhdl, int devnum)
-{
-	return;
-}
-
-/* 
- * Shutdown a device on a xtalk widget 
- */
-void
-xtalk_widgetdev_shutdown(vertex_hdl_t xconn_vhdl, int devnum)
-{
-	return;
-}
-
-/*
- * Generic io channel functions, for use with all io channel providers
- * and all io channel devices.
- */
-
-/* Generic io channel interrupt interfaces */
-vertex_hdl_t
-xtalk_intr_dev_get(xtalk_intr_t xtalk_intr)
-{
-    return (xtalk_intr->xi_dev);
-}
-
-xwidgetnum_t
-xtalk_intr_target_get(xtalk_intr_t xtalk_intr)
-{
-    return (xtalk_intr->xi_target);
-}
-
-xtalk_intr_vector_t
-xtalk_intr_vector_get(xtalk_intr_t xtalk_intr)
-{
-    return (xtalk_intr->xi_vector);
-}
-
-iopaddr_t
-xtalk_intr_addr_get(struct xtalk_intr_s *xtalk_intr)
-{
-    return (xtalk_intr->xi_addr);
-}
-
-void                   *
-xtalk_intr_sfarg_get(xtalk_intr_t xtalk_intr)
-{
-    return (xtalk_intr->xi_sfarg);
-}
-
-/* Generic io channel pio interfaces */
-vertex_hdl_t
-xtalk_pio_dev_get(xtalk_piomap_t xtalk_piomap)
-{
-    return (xtalk_piomap->xp_dev);
-}
-
-xwidgetnum_t
-xtalk_pio_target_get(xtalk_piomap_t xtalk_piomap)
-{
-    return (xtalk_piomap->xp_target);
-}
-
-iopaddr_t
-xtalk_pio_xtalk_addr_get(xtalk_piomap_t xtalk_piomap)
-{
-    return (xtalk_piomap->xp_xtalk_addr);
-}
-
-ulong
-xtalk_pio_mapsz_get(xtalk_piomap_t xtalk_piomap)
-{
-    return (xtalk_piomap->xp_mapsz);
-}
-
-caddr_t
-xtalk_pio_kvaddr_get(xtalk_piomap_t xtalk_piomap)
-{
-    return (xtalk_piomap->xp_kvaddr);
-}
-
-
-/* Generic io channel dma interfaces */
-vertex_hdl_t
-xtalk_dma_dev_get(xtalk_dmamap_t xtalk_dmamap)
-{
-    return (xtalk_dmamap->xd_dev);
-}
-
-xwidgetnum_t
-xtalk_dma_target_get(xtalk_dmamap_t xtalk_dmamap)
-{
-    return (xtalk_dmamap->xd_target);
-}
-
-
-/* Generic io channel widget information interfaces */
-
-/* xwidget_info_chk:
- * check to see if this vertex is a widget;
- * if so, return its widget_info (if any).
- * if not, return NULL.
- */
-xwidget_info_t
-xwidget_info_chk(vertex_hdl_t xwidget)
-{
-    arbitrary_info_t        ainfo = 0;
-
-    hwgraph_info_get_LBL(xwidget, INFO_LBL_XWIDGET, &ainfo);
-    return (xwidget_info_t) ainfo;
-}
-
-
-xwidget_info_t
-xwidget_info_get(vertex_hdl_t xwidget)
-{
-    xwidget_info_t          widget_info;
-
-    widget_info = (xwidget_info_t)
-	hwgraph_fastinfo_get(xwidget);
-
-    return (widget_info);
-}
-
-void
-xwidget_info_set(vertex_hdl_t xwidget, xwidget_info_t widget_info)
-{
-    if (widget_info != NULL)
-	widget_info->w_fingerprint = widget_info_fingerprint;
-
-    hwgraph_fastinfo_set(xwidget, (arbitrary_info_t) widget_info);
-
-    /* Also, mark this vertex as an xwidget,
-     * and use the widget_info, so xwidget_info_chk
-     * can work (and be fairly efficient).
-     */
-    hwgraph_info_add_LBL(xwidget, INFO_LBL_XWIDGET,
-			 (arbitrary_info_t) widget_info);
-}
-
-vertex_hdl_t
-xwidget_info_dev_get(xwidget_info_t xwidget_info)
-{
-    if (xwidget_info == NULL)
-	panic("xwidget_info_dev_get: null xwidget_info");
-    return (xwidget_info->w_vertex);
-}
-
-xwidgetnum_t
-xwidget_info_id_get(xwidget_info_t xwidget_info)
-{
-    if (xwidget_info == NULL)
-	panic("xwidget_info_id_get: null xwidget_info");
-    return (xwidget_info->w_id);
-}
-
-
-vertex_hdl_t
-xwidget_info_master_get(xwidget_info_t xwidget_info)
-{
-    if (xwidget_info == NULL)
-	panic("xwidget_info_master_get: null xwidget_info");
-    return (xwidget_info->w_master);
-}
-
-xwidgetnum_t
-xwidget_info_masterid_get(xwidget_info_t xwidget_info)
-{
-    if (xwidget_info == NULL)
-	panic("xwidget_info_masterid_get: null xwidget_info");
-    return (xwidget_info->w_masterid);
-}
-
-xwidget_part_num_t
-xwidget_info_part_num_get(xwidget_info_t xwidget_info)
-{
-    if (xwidget_info == NULL)
-	panic("xwidget_info_part_num_get: null xwidget_info");
-    return (xwidget_info->w_hwid.part_num);
-}
-
-xwidget_mfg_num_t
-xwidget_info_mfg_num_get(xwidget_info_t xwidget_info)
-{
-    if (xwidget_info == NULL)
-	panic("xwidget_info_mfg_num_get: null xwidget_info");
-    return (xwidget_info->w_hwid.mfg_num);
-}
-/* Extract the widget name from the widget information
- * for the xtalk widget.
- */
-char *
-xwidget_info_name_get(xwidget_info_t xwidget_info)
-{
-    if (xwidget_info == NULL)
-	panic("xwidget_info_name_get: null xwidget_info");
-    return(xwidget_info->w_name);
-}
-/* Generic io channel initialization interfaces */
-
-/*
- * Associate a set of xtalk_provider functions with a vertex.
- */
-void
-xtalk_provider_register(vertex_hdl_t provider, xtalk_provider_t *xtalk_fns)
-{
-    hwgraph_fastinfo_set(provider, (arbitrary_info_t) xtalk_fns);
-}
-
-/*
- * Disassociate a set of xtalk_provider functions with a vertex.
- */
-void
-xtalk_provider_unregister(vertex_hdl_t provider)
-{
-    hwgraph_fastinfo_set(provider, (arbitrary_info_t)NULL);
-}
-
-/*
- * Obtain a pointer to the xtalk_provider functions for a specified Crosstalk
- * provider.
- */
-xtalk_provider_t       *
-xtalk_provider_fns_get(vertex_hdl_t provider)
-{
-    return ((xtalk_provider_t *) hwgraph_fastinfo_get(provider));
-}
-
-/*
- * Inform xtalk infrastructure that a driver is no longer available for
- * handling any widgets.
- */
-void
-xwidget_driver_unregister(char *driver_prefix)
-{
-	return;
-}
-
-/*
- * Call some function with each vertex that
- * might be one of this driver's attach points.
- */
-void
-xtalk_iterate(char *driver_prefix,
-	      xtalk_iter_f *func)
-{
-}
-
-/*
- * xwidget_register:
- *	Register a xtalk device (xwidget) by doing the following.
- *      -allocate and initialize xwidget_info data
- *      -allocate a hwgraph vertex with name based on widget number (id)
- *      -look up the widget's initialization function and call it,
- *      or remember the vertex for later initialization.
- *
- */
-int
-xwidget_register(xwidget_hwid_t hwid,		/* widget's hardware ID */
-		 vertex_hdl_t 	widget,		/* widget to initialize */
-		 xwidgetnum_t 	id,		/* widget's target id (0..f) */
-		 vertex_hdl_t 	master,		/* widget's master vertex */
-		 xwidgetnum_t 	targetid)	/* master's target id (9/a) */
-{			
-    xwidget_info_t          widget_info;
-    char		    *s,devnm[MAXDEVNAME];
-
-    /* Allocate widget_info and associate it with widget vertex */
-    widget_info = kmalloc(sizeof(*widget_info), GFP_KERNEL);
-     if (!widget_info)
- 	return - ENOMEM;
-
-    /* Initialize widget_info */
-    widget_info->w_vertex = widget;
-    widget_info->w_id = id;
-    widget_info->w_master = master;
-    widget_info->w_masterid = targetid;
-    widget_info->w_hwid = *hwid;	/* structure copy */
-    widget_info->w_efunc = 0;
-    widget_info->w_einfo = 0;
-    /*
-     * get the name of this xwidget vertex and keep the info.
-     * This is needed during errors and interupts, but as
-     * long as we have it, we can use it elsewhere.
-     */
-    s = dev_to_name(widget,devnm,MAXDEVNAME);
-    widget_info->w_name = kmalloc(strlen(s) + 1, GFP_KERNEL);
-    strcpy(widget_info->w_name,s);
-    
-    xwidget_info_set(widget, widget_info);
-
-    device_master_set(widget, master);
-
-    /* 
-     * Add pointer to async attach info -- tear down will be done when
-     * the particular descendant is done with the info.
-     */
-    return cdl_add_connpt(hwid->part_num, hwid->mfg_num,
-                          widget, 0);
-}
-
-/*
- * xwidget_unregister :
- *	Unregister the xtalk device and detach all its hwgraph namespace.
- */
-int
-xwidget_unregister(vertex_hdl_t widget)
-{
-    xwidget_info_t	widget_info;
-    xwidget_hwid_t	hwid;
-
-    /* Make sure that we have valid widget information initialized */
-    if (!(widget_info = xwidget_info_get(widget)))
-	return 1;
-
-    hwid = &(widget_info->w_hwid);
-
-    kfree(widget_info->w_name);
-    kfree(widget_info);
-    return 0;
-}
-
-void
-xwidget_error_register(vertex_hdl_t xwidget,
-		       error_handler_f *efunc,
-		       error_handler_arg_t einfo)
-{
-    xwidget_info_t          xwidget_info;
-
-    xwidget_info = xwidget_info_get(xwidget);
-    ASSERT(xwidget_info != NULL);
-    xwidget_info->w_efunc = efunc;
-    xwidget_info->w_einfo = einfo;
-}
-
-/*
- * Issue a link reset to a widget.
- */
-void
-xwidget_reset(vertex_hdl_t xwidget)
-{
-    xswitch_reset_link(xwidget);
-}
-
-
-void
-xwidget_gfx_reset(vertex_hdl_t xwidget)
-{
-	return;
-}
-
-#define ANON_XWIDGET_NAME	"No Name"	/* Default Widget Name */
-
-/* Get the canonical hwgraph  name of xtalk widget */
-char *
-xwidget_name_get(vertex_hdl_t xwidget_vhdl)
-{
-	xwidget_info_t  info;
-
-	/* If we have a bogus widget handle then return
-	 * a default anonymous widget name.
-	 */
-	if (xwidget_vhdl == GRAPH_VERTEX_NONE)
-	    return(ANON_XWIDGET_NAME);
-	/* Read the widget name stored in the widget info
-	 * for the widget setup during widget initialization.
-	 */
-	info = xwidget_info_get(xwidget_vhdl);
-	ASSERT(info != NULL);
-	return(xwidget_info_name_get(info));
-}
diff -Nru a/arch/ia64/sn/io/snia_if.c b/arch/ia64/sn/io/snia_if.c
--- a/arch/ia64/sn/io/snia_if.c	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,108 +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) 2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/pci/pci_bus_cvlink.h>
-#include <asm/sn/simulator.h>
-
-extern pciio_provider_t *pciio_to_provider_fns(vertex_hdl_t dev);
-
-int
-snia_badaddr_val(volatile void *addr, int len, volatile void *ptr)
-{
-	int ret = 0;
-	volatile void *new_addr;
-
-	switch (len) {
-	case 4:
-		new_addr = (void *) addr;
-		ret = ia64_sn_probe_io_slot((long) new_addr, len, (void *) ptr);
-		break;
-	default:
-		printk(KERN_WARNING
-		       "snia_badaddr_val given len %x but supports len of 4 only\n",
-		       len);
-	}
-
-	if (ret < 0)
-		panic("snia_badaddr_val: unexpected status (%d) in probing",
-		      ret);
-	return (ret);
-
-}
-
-nasid_t
-snia_get_console_nasid(void)
-{
-	extern nasid_t console_nasid;
-	extern nasid_t master_baseio_nasid;
-
-	if (console_nasid < 0) {
-		console_nasid = ia64_sn_get_console_nasid();
-		if (console_nasid < 0) {
-// ZZZ What do we do if we don't get a console nasid on the hardware????
-			if (IS_RUNNING_ON_SIMULATOR())
-				console_nasid = master_baseio_nasid;
-		}
-	}
-	return console_nasid;
-}
-
-nasid_t
-snia_get_master_baseio_nasid(void)
-{
-	extern nasid_t master_baseio_nasid;
-	extern char master_baseio_wid;
-
-	if (master_baseio_nasid < 0) {
-		master_baseio_nasid = ia64_sn_get_master_baseio_nasid();
-
-		if (master_baseio_nasid >= 0) {
-			master_baseio_wid =
-			    WIDGETID_GET(KL_CONFIG_CH_CONS_INFO
-					 (master_baseio_nasid)->memory_base);
-		}
-	}
-	return master_baseio_nasid;
-}
-
-/*
- * XXX: should probably be called __sn2_pci_rrb_alloc
- * used by qla1280
- */
-
-int
-snia_pcibr_rrb_alloc(struct pci_dev *pci_dev,
-		     int *count_vchan0, int *count_vchan1)
-{
-	vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev);
-
-	return pcibr_rrb_alloc(dev, count_vchan0, count_vchan1);
-}
-
-/* 
- * XXX: interface should be more like
- *
- *     int __sn2_pci_enable_bwswap(struct pci_dev *dev);
- *     void __sn2_pci_disable_bswap(struct pci_dev *dev);
- */
-/* used by ioc4 ide */
-
-pciio_endian_t
-snia_pciio_endian_set(struct pci_dev * pci_dev,
-		      pciio_endian_t device_end, pciio_endian_t desired_end)
-{
-	vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev);
-
-	return ((pciio_to_provider_fns(dev))->endian_set)
-		(dev, device_end, desired_end);
-}
-
-EXPORT_SYMBOL(snia_pciio_endian_set);
-EXPORT_SYMBOL(snia_pcibr_rrb_alloc);
diff -Nru a/arch/ia64/sn/io/xswitch.c b/arch/ia64/sn/io/xswitch.c
--- a/arch/ia64/sn/io/xswitch.c	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,168 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <asm/errno.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/xtalk/xswitch.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/xtalk/xtalk_private.h>
-
-
-/*
- * This file provides generic support for Crosstalk
- * Switches, in a way that insulates crosstalk providers
- * from specifics about the switch chips being used.
- */
-
-#include <asm/sn/xtalk/xbow.h>
-
-#define	XSWITCH_CENSUS_BIT(port)		(1<<(port))
-#define	XSWITCH_CENSUS_PORT_MAX			(0xF)
-#define	XSWITCH_CENSUS_PORTS			(0x10)
-#define	XSWITCH_WIDGET_PRESENT(infop,port)	((infop)->census & XSWITCH_CENSUS_BIT(port))
-
-static char             xswitch_info_fingerprint[] = "xswitch_info";
-
-struct xswitch_info_s {
-    char                   *fingerprint;
-    unsigned                census;
-    vertex_hdl_t            vhdl[XSWITCH_CENSUS_PORTS];
-    vertex_hdl_t            master_vhdl[XSWITCH_CENSUS_PORTS];
-    xswitch_provider_t     *xswitch_fns;
-};
-
-xswitch_info_t
-xswitch_info_get(vertex_hdl_t xwidget)
-{
-    xswitch_info_t          xswitch_info;
-
-    xswitch_info = (xswitch_info_t)
-	hwgraph_fastinfo_get(xwidget);
-
-    return (xswitch_info);
-}
-
-void
-xswitch_info_vhdl_set(xswitch_info_t xswitch_info,
-		      xwidgetnum_t port,
-		      vertex_hdl_t xwidget)
-{
-    if (port > XSWITCH_CENSUS_PORT_MAX)
-	return;
-
-    xswitch_info->vhdl[(int)port] = xwidget;
-}
-
-vertex_hdl_t
-xswitch_info_vhdl_get(xswitch_info_t xswitch_info,
-		      xwidgetnum_t port)
-{
-    if (port > XSWITCH_CENSUS_PORT_MAX)
-	return GRAPH_VERTEX_NONE;
-
-    return xswitch_info->vhdl[(int)port];
-}
-
-/*
- * Some systems may allow for multiple switch masters.  On such systems,
- * we assign a master for each port on the switch.  These interfaces
- * establish and retrieve that assignment.
- */
-void
-xswitch_info_master_assignment_set(xswitch_info_t xswitch_info,
-				   xwidgetnum_t port,
-				   vertex_hdl_t master_vhdl)
-{
-    if (port > XSWITCH_CENSUS_PORT_MAX)
-	return;
-
-    xswitch_info->master_vhdl[(int)port] = master_vhdl;
-}
-
-vertex_hdl_t
-xswitch_info_master_assignment_get(xswitch_info_t xswitch_info,
-				   xwidgetnum_t port)
-{
-    if (port > XSWITCH_CENSUS_PORT_MAX)
-	return GRAPH_VERTEX_NONE;
-
-    return xswitch_info->master_vhdl[(int)port];
-}
-
-void
-xswitch_info_set(vertex_hdl_t xwidget, xswitch_info_t xswitch_info)
-{
-    xswitch_info->fingerprint = xswitch_info_fingerprint;
-    hwgraph_fastinfo_set(xwidget, (arbitrary_info_t) xswitch_info);
-}
-
-xswitch_info_t
-xswitch_info_new(vertex_hdl_t xwidget)
-{
-    xswitch_info_t          xswitch_info;
-
-    xswitch_info = xswitch_info_get(xwidget);
-    if (xswitch_info == NULL) {
-	int                     port;
-
-	xswitch_info = kmalloc(sizeof(*xswitch_info), GFP_KERNEL);
-	if (!xswitch_info) {
-		printk(KERN_WARNING "xswitch_info_new(): Unable to "
-			"allocate memory\n");
-		return NULL;
-	}
-	xswitch_info->census = 0;
-	for (port = 0; port <= XSWITCH_CENSUS_PORT_MAX; port++) {
-	    xswitch_info_vhdl_set(xswitch_info, port,
-				  GRAPH_VERTEX_NONE);
-
-	    xswitch_info_master_assignment_set(xswitch_info,
-					       port,
-					       GRAPH_VERTEX_NONE);
-	}
-	xswitch_info_set(xwidget, xswitch_info);
-    }
-    return xswitch_info;
-}
-
-void
-xswitch_provider_register(vertex_hdl_t busv,
-			  xswitch_provider_t * xswitch_fns)
-{
-    xswitch_info_t          xswitch_info = xswitch_info_get(busv);
-
-    ASSERT(xswitch_info);
-    xswitch_info->xswitch_fns = xswitch_fns;
-}
-
-void
-xswitch_info_link_is_ok(xswitch_info_t xswitch_info, xwidgetnum_t port)
-{
-    xswitch_info->census |= XSWITCH_CENSUS_BIT(port);
-}
-
-int
-xswitch_info_link_ok(xswitch_info_t xswitch_info, xwidgetnum_t port)
-{
-    if (port > XSWITCH_CENSUS_PORT_MAX)
-	return 0;
-
-    return (xswitch_info->census & XSWITCH_CENSUS_BIT(port));
-}
-
-int
-xswitch_reset_link(vertex_hdl_t xconn_vhdl)
-{
-    return xbow_reset_link(xconn_vhdl);
-}
diff -Nru a/arch/ia64/sn/kernel/Makefile b/arch/ia64/sn/kernel/Makefile
--- a/arch/ia64/sn/kernel/Makefile	2004-12-24 13:36:18 -08:00
+++ b/arch/ia64/sn/kernel/Makefile	2004-12-24 13:36:18 -08:00
@@ -7,5 +7,6 @@
 # Copyright (C) 1999,2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
 #
 
-obj-y				+= probe.o setup.o bte.o irq.o mca.o idle.o sn2/
+obj-y				+= setup.o bte.o bte_error.o irq.o mca.o idle.o \
+				   huberror.o io_init.o iomv.o klconflib.o sn2/
 obj-$(CONFIG_IA64_GENERIC)      += machvec.o
diff -Nru a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
--- a/arch/ia64/sn/kernel/bte.c	2004-12-24 13:36:56 -08:00
+++ b/arch/ia64/sn/kernel/bte.c	2004-12-24 13:36:56 -08:00
@@ -8,14 +8,14 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
-#include <asm/sn/sgi.h>
 #include <asm/sn/nodepda.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/arch.h>
 #include <asm/sn/sn_cpuid.h>
 #include <asm/sn/pda.h>
-#include <asm/sn/sn2/shubio.h>
+#include "shubio.h"
 #include <asm/nodedata.h>
+#include <asm/delay.h>
 
 #include <linux/bootmem.h>
 #include <linux/string.h>
@@ -30,8 +30,7 @@
 /* two interfaces on two btes */
 #define MAX_INTERFACES_TO_TRY		4
 
-static struct bteinfo_s *
-bte_if_on_node(nasid_t nasid, int interface)
+static struct bteinfo_s *bte_if_on_node(nasid_t nasid, int interface)
 {
 	nodepda_t *tmp_nodepda;
 
@@ -40,13 +39,11 @@
 
 }
 
-
 /************************************************************************
  * Block Transfer Engine copy related functions.
  *
  ***********************************************************************/
 
-
 /*
  * bte_copy(src, dest, len, mode, notification)
  *
@@ -66,17 +63,17 @@
  * NOTE:  This function requires src, dest, and len to
  * be cacheline aligned.
  */
-bte_result_t
-bte_copy(u64 src, u64 dest, u64 len, u64 mode, void *notification)
+bte_result_t bte_copy(u64 src, u64 dest, u64 len, u64 mode, void *notification)
 {
 	u64 transfer_size;
 	u64 transfer_stat;
 	struct bteinfo_s *bte;
 	bte_result_t bte_status;
 	unsigned long irq_flags;
+	unsigned long itc_end = 0;
 	struct bteinfo_s *btes_to_try[MAX_INTERFACES_TO_TRY];
 	int bte_if_index;
-
+	int bte_pri, bte_sec;
 
 	BTE_PRINTK(("bte_copy(0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%p)\n",
 		    src, dest, len, mode, notification));
@@ -85,34 +82,44 @@
 		return BTE_SUCCESS;
 	}
 
-	ASSERT(!((len & L1_CACHE_MASK) ||
-		 (src & L1_CACHE_MASK) || (dest & L1_CACHE_MASK)));
-	ASSERT(len < ((BTE_LEN_MASK + 1) << L1_CACHE_SHIFT));
+	BUG_ON((len & L1_CACHE_MASK) ||
+		 (src & L1_CACHE_MASK) || (dest & L1_CACHE_MASK));
+	BUG_ON(!(len < ((BTE_LEN_MASK + 1) << L1_CACHE_SHIFT)));
+
+	/* CPU 0 (per node) tries bte0 first, CPU 1 try bte1 first */
+	if (cpuid_to_subnode(smp_processor_id()) == 0) {
+		bte_pri = 0;
+		bte_sec = 1;
+	} else {
+		bte_pri = 1;
+		bte_sec = 0;
+	}
 
 	if (mode & BTE_USE_DEST) {
 		/* try remote then local */
-		btes_to_try[0] = bte_if_on_node(NASID_GET(dest), 0);
-		btes_to_try[1] = bte_if_on_node(NASID_GET(dest), 1);
+		btes_to_try[0] = bte_if_on_node(NASID_GET(dest), bte_pri);
+		btes_to_try[1] = bte_if_on_node(NASID_GET(dest), bte_sec);
 		if (mode & BTE_USE_ANY) {
-			btes_to_try[2] = bte_if_on_node(get_nasid(), 0);
-			btes_to_try[3] = bte_if_on_node(get_nasid(), 1);
+			btes_to_try[2] = bte_if_on_node(get_nasid(), bte_pri);
+			btes_to_try[3] = bte_if_on_node(get_nasid(), bte_sec);
 		} else {
 			btes_to_try[2] = NULL;
 			btes_to_try[3] = NULL;
 		}
 	} else {
 		/* try local then remote */
-		btes_to_try[0] = bte_if_on_node(get_nasid(), 0);
-		btes_to_try[1] = bte_if_on_node(get_nasid(), 1);
+		btes_to_try[0] = bte_if_on_node(get_nasid(), bte_pri);
+		btes_to_try[1] = bte_if_on_node(get_nasid(), bte_sec);
 		if (mode & BTE_USE_ANY) {
-			btes_to_try[2] = bte_if_on_node(NASID_GET(dest), 0);
-			btes_to_try[3] = bte_if_on_node(NASID_GET(dest), 1);
+			btes_to_try[2] = bte_if_on_node(NASID_GET(dest), bte_pri);
+			btes_to_try[3] = bte_if_on_node(NASID_GET(dest), bte_sec);
 		} else {
 			btes_to_try[2] = NULL;
 			btes_to_try[3] = NULL;
 		}
 	}
 
+retry_bteop:
 	do {
 		local_irq_save(irq_flags);
 
@@ -127,16 +134,16 @@
 			}
 
 			if (spin_trylock(&bte->spinlock)) {
-				if ((*bte->most_rcnt_na & BTE_ACTIVE) ||
+				if (!(*bte->most_rcnt_na & BTE_WORD_AVAILABLE) ||
 				    (BTE_LNSTAT_LOAD(bte) & BTE_ACTIVE)) {
 					/* Got the lock but BTE still busy */
 					spin_unlock(&bte->spinlock);
-					bte = NULL;
 				} else {
 					/* we got the lock and it's not busy */
 					break;
 				}
 			}
+			bte = NULL;
 		}
 
 		if (bte != NULL) {
@@ -150,7 +157,6 @@
 		}
 	} while (1);
 
-
 	if (notification == NULL) {
 		/* User does not want to be notified. */
 		bte->most_rcnt_na = &bte->notify;
@@ -162,7 +168,7 @@
 	transfer_size = ((len >> L1_CACHE_SHIFT) & BTE_LEN_MASK);
 
 	/* Initialize the notification to a known value. */
-	*bte->most_rcnt_na = -1L;
+	*bte->most_rcnt_na = BTE_WORD_BUSY;
 
 	/* Set the status reg busy bit and transfer length */
 	BTE_PRINTKV(("IBLS = 0x%lx\n", IBLS_BUSY | transfer_size));
@@ -175,42 +181,53 @@
 	BTE_DEST_STORE(bte, TO_PHYS(dest));
 
 	/* Set the notification register */
-	BTE_PRINTKV(("IBNA = 0x%lx)\n", 
+	BTE_PRINTKV(("IBNA = 0x%lx)\n",
 		     TO_PHYS(ia64_tpa((unsigned long)bte->most_rcnt_na))));
-	BTE_NOTIF_STORE(bte, TO_PHYS(ia64_tpa((unsigned long)bte->most_rcnt_na)));
-
+	BTE_NOTIF_STORE(bte,
+			TO_PHYS(ia64_tpa((unsigned long)bte->most_rcnt_na)));
 
 	/* Initiate the transfer */
 	BTE_PRINTK(("IBCT = 0x%lx)\n", BTE_VALID_MODE(mode)));
 	BTE_CTRL_STORE(bte, BTE_VALID_MODE(mode));
 
-	spin_unlock_irqrestore(&bte->spinlock, irq_flags);
+	itc_end = ia64_get_itc() + (40000000 * local_cpu_data->cyc_per_usec);
 
+	spin_unlock_irqrestore(&bte->spinlock, irq_flags);
 
 	if (notification != NULL) {
 		return BTE_SUCCESS;
 	}
 
-	while ((transfer_stat = *bte->most_rcnt_na) == -1UL) {
+	while ((transfer_stat = *bte->most_rcnt_na) == BTE_WORD_BUSY) {
+		if (ia64_get_itc() > itc_end) {
+			BTE_PRINTK(("BTE timeout nasid 0x%x bte%d IBLS = 0x%lx na 0x%lx\n",
+				NASID_GET(bte->bte_base_addr), bte->bte_num,
+				BTE_LNSTAT_LOAD(bte), *bte->most_rcnt_na) );
+			bte->bte_error_count++;
+			bte->bh_error = IBLS_ERROR;
+			bte_error_handler((unsigned long)NODEPDA(bte->bte_cnode));
+			*bte->most_rcnt_na = BTE_WORD_AVAILABLE;
+			goto retry_bteop;
+		}
 	}
 
-
 	BTE_PRINTKV((" Delay Done.  IBLS = 0x%lx, most_rcnt_na = 0x%lx\n",
-				BTE_LNSTAT_LOAD(bte), *bte->most_rcnt_na));
+		     BTE_LNSTAT_LOAD(bte), *bte->most_rcnt_na));
 
 	if (transfer_stat & IBLS_ERROR) {
 		bte_status = transfer_stat & ~IBLS_ERROR;
-		*bte->most_rcnt_na = 0L;
 	} else {
 		bte_status = BTE_SUCCESS;
 	}
+	*bte->most_rcnt_na = BTE_WORD_AVAILABLE;
+
 	BTE_PRINTK(("Returning status is 0x%lx and most_rcnt_na is 0x%lx\n",
-				BTE_LNSTAT_LOAD(bte), *bte->most_rcnt_na));
+		    BTE_LNSTAT_LOAD(bte), *bte->most_rcnt_na));
 
 	return bte_status;
 }
-EXPORT_SYMBOL(bte_copy);
 
+EXPORT_SYMBOL(bte_copy);
 
 /*
  * bte_unaligned_copy(src, dest, len, mode)
@@ -228,8 +245,7 @@
  * NOTE: If the source, dest, and len are all cache line aligned,
  * then it would be _FAR_ preferrable to use bte_copy instead.
  */
-bte_result_t
-bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
+bte_result_t bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
 {
 	int destFirstCacheOffset;
 	u64 headBteSource;
@@ -254,7 +270,7 @@
 	if (bteBlock_unaligned == NULL) {
 		return BTEFAIL_NOTAVAIL;
 	}
-	bteBlock = (char *) L1_CACHE_ALIGN((u64) bteBlock_unaligned);
+	bteBlock = (char *)L1_CACHE_ALIGN((u64) bteBlock_unaligned);
 
 	headBcopySrcOffset = src & L1_CACHE_MASK;
 	destFirstCacheOffset = dest & L1_CACHE_MASK;
@@ -302,15 +318,13 @@
 		}
 
 		if (len > headBcopyLen) {
-			footBcopyLen =
-			    (len - headBcopyLen) & L1_CACHE_MASK;
+			footBcopyLen = (len - headBcopyLen) & L1_CACHE_MASK;
 			footBteLen = L1_CACHE_BYTES;
 
 			footBteSource = src + len - footBcopyLen;
 			footBcopyDest = dest + len - footBcopyLen;
 
-			if (footBcopyDest ==
-			    (headBcopyDest + headBcopyLen)) {
+			if (footBcopyDest == (headBcopyDest + headBcopyLen)) {
 				/*
 				 * We have two contigous bcopy
 				 * blocks.  Merge them.
@@ -326,9 +340,8 @@
 					return rv;
 				}
 
-
 				memcpy(__va(footBcopyDest),
-				       (char *) bteBlock, footBcopyLen);
+				       (char *)bteBlock, footBcopyLen);
 			}
 		} else {
 			footBcopyLen = 0;
@@ -350,7 +363,6 @@
 		}
 	} else {
 
-
 		/*
 		 * The transfer is not symetric, we will
 		 * allocate a buffer large enough for all the
@@ -361,8 +373,7 @@
 		/* Add the leader from source */
 		headBteLen = len + (src & L1_CACHE_MASK);
 		/* Add the trailing bytes from footer. */
-		headBteLen +=
-		    L1_CACHE_BYTES - (headBteLen & L1_CACHE_MASK);
+		headBteLen += L1_CACHE_BYTES - (headBteLen & L1_CACHE_MASK);
 		headBteSource = src & ~L1_CACHE_MASK;
 		headBcopySrcOffset = src & L1_CACHE_MASK;
 		headBcopyDest = dest;
@@ -371,40 +382,37 @@
 
 	if (headBcopyLen > 0) {
 		rv = bte_copy(headBteSource,
-			      ia64_tpa((unsigned long)bteBlock), headBteLen, mode, NULL);
+			      ia64_tpa((unsigned long)bteBlock), headBteLen,
+			      mode, NULL);
 		if (rv != BTE_SUCCESS) {
 			kfree(bteBlock_unaligned);
 			return rv;
 		}
 
-		memcpy(__va(headBcopyDest), ((char *) bteBlock +
-					     headBcopySrcOffset),
-		       headBcopyLen);
+		memcpy(__va(headBcopyDest), ((char *)bteBlock +
+					     headBcopySrcOffset), headBcopyLen);
 	}
 	kfree(bteBlock_unaligned);
 	return BTE_SUCCESS;
 }
-EXPORT_SYMBOL(bte_unaligned_copy);
 
+EXPORT_SYMBOL(bte_unaligned_copy);
 
 /************************************************************************
  * Block Transfer Engine initialization functions.
  *
  ***********************************************************************/
 
-
 /*
  * bte_init_node(nodepda, cnode)
  *
  * Initialize the nodepda structure with BTE base addresses and
  * spinlocks.
  */
-void
-bte_init_node(nodepda_t * mynodepda, cnodeid_t cnode)
+void bte_init_node(nodepda_t * mynodepda, cnodeid_t cnode)
 {
 	int i;
 
-
 	/*
 	 * Indicate that all the block transfer engines on this node
 	 * are available.
@@ -418,13 +426,13 @@
 	spin_lock_init(&mynodepda->bte_recovery_lock);
 	init_timer(&mynodepda->bte_recovery_timer);
 	mynodepda->bte_recovery_timer.function = bte_error_handler;
-	mynodepda->bte_recovery_timer.data = (unsigned long) mynodepda;
+	mynodepda->bte_recovery_timer.data = (unsigned long)mynodepda;
 
 	for (i = 0; i < BTES_PER_NODE; i++) {
 		/* Which link status register should we use? */
 		unsigned long link_status = (i == 0 ? IIO_IBLS0 : IIO_IBLS1);
 		mynodepda->bte_if[i].bte_base_addr = (u64 *)
-			REMOTE_HUB_ADDR(cnodeid_to_nasid(cnode), link_status);
+		    REMOTE_HUB_ADDR(cnodeid_to_nasid(cnode), link_status);
 
 		/*
 		 * Initialize the notification and spinlock
@@ -432,7 +440,7 @@
 		 */
 		mynodepda->bte_if[i].most_rcnt_na =
 		    &(mynodepda->bte_if[i].notify);
-		mynodepda->bte_if[i].notify = 0L;
+		mynodepda->bte_if[i].notify = BTE_WORD_AVAILABLE;
 		spin_lock_init(&mynodepda->bte_if[i].spinlock);
 
 		mynodepda->bte_if[i].bte_cnode = cnode;
diff -Nru a/arch/ia64/sn/kernel/bte_error.c b/arch/ia64/sn/kernel/bte_error.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/kernel/bte_error.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,188 @@
+/*
+ * 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-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ */
+
+#include <linux/types.h>
+#include <asm/sn/sn_sal.h>
+#include "ioerror.h"
+#include <asm/sn/addrs.h>
+#include "shubio.h"
+#include <asm/sn/geo.h>
+#include "xtalk/xwidgetdev.h"
+#include "xtalk/hubdev.h"
+#include <asm/sn/bte.h>
+
+/*
+ * Bte error handling is done in two parts.  The first captures
+ * any crb related errors.  Since there can be multiple crbs per
+ * interface and multiple interfaces active, we need to wait until
+ * all active crbs are completed.  This is the first job of the
+ * second part error handler.  When all bte related CRBs are cleanly
+ * completed, it resets the interfaces and gets them ready for new
+ * transfers to be queued.
+ */
+
+void bte_error_handler(unsigned long);
+
+/*
+ * Wait until all BTE related CRBs are completed
+ * and then reset the interfaces.
+ */
+void bte_error_handler(unsigned long _nodepda)
+{
+	struct nodepda_s *err_nodepda = (struct nodepda_s *)_nodepda;
+	spinlock_t *recovery_lock = &err_nodepda->bte_recovery_lock;
+	struct timer_list *recovery_timer = &err_nodepda->bte_recovery_timer;
+	nasid_t nasid;
+	int i;
+	int valid_crbs;
+	unsigned long irq_flags;
+	volatile u64 *notify;
+	bte_result_t bh_error;
+	ii_imem_u_t imem;	/* II IMEM Register */
+	ii_icrb0_d_u_t icrbd;	/* II CRB Register D */
+	ii_ibcr_u_t ibcr;
+	ii_icmr_u_t icmr;
+
+	BTE_PRINTK(("bte_error_handler(%p) - %d\n", err_nodepda,
+		    smp_processor_id()));
+
+	spin_lock_irqsave(recovery_lock, irq_flags);
+
+	if ((err_nodepda->bte_if[0].bh_error == BTE_SUCCESS) &&
+	    (err_nodepda->bte_if[1].bh_error == BTE_SUCCESS)) {
+		BTE_PRINTK(("eh:%p:%d Nothing to do.\n", err_nodepda,
+			    smp_processor_id()));
+		spin_unlock_irqrestore(recovery_lock, irq_flags);
+		return;
+	}
+	/*
+	 * Lock all interfaces on this node to prevent new transfers
+	 * from being queued.
+	 */
+	for (i = 0; i < BTES_PER_NODE; i++) {
+		if (err_nodepda->bte_if[i].cleanup_active) {
+			continue;
+		}
+		spin_lock(&err_nodepda->bte_if[i].spinlock);
+		BTE_PRINTK(("eh:%p:%d locked %d\n", err_nodepda,
+			    smp_processor_id(), i));
+		err_nodepda->bte_if[i].cleanup_active = 1;
+	}
+
+	/* Determine information about our hub */
+	nasid = cnodeid_to_nasid(err_nodepda->bte_if[0].bte_cnode);
+
+	/*
+	 * A BTE transfer can use multiple CRBs.  We need to make sure
+	 * that all the BTE CRBs are complete (or timed out) before
+	 * attempting to clean up the error.  Resetting the BTE while
+	 * there are still BTE CRBs active will hang the BTE.
+	 * We should look at all the CRBs to see if they are allocated
+	 * to the BTE and see if they are still active.  When none
+	 * are active, we can continue with the cleanup.
+	 *
+	 * We also want to make sure that the local NI port is up.
+	 * When a router resets the NI port can go down, while it
+	 * goes through the LLP handshake, but then comes back up.
+	 */
+	icmr.ii_icmr_regval = REMOTE_HUB_L(nasid, IIO_ICMR);
+	if (icmr.ii_icmr_fld_s.i_crb_mark != 0) {
+		/*
+		 * There are errors which still need to be cleaned up by
+		 * hubiio_crb_error_handler
+		 */
+		mod_timer(recovery_timer, HZ * 5);
+		BTE_PRINTK(("eh:%p:%d Marked Giving up\n", err_nodepda,
+			    smp_processor_id()));
+		spin_unlock_irqrestore(recovery_lock, irq_flags);
+		return;
+	}
+	if (icmr.ii_icmr_fld_s.i_crb_vld != 0) {
+
+		valid_crbs = icmr.ii_icmr_fld_s.i_crb_vld;
+
+		for (i = 0; i < IIO_NUM_CRBS; i++) {
+			if (!((1 << i) & valid_crbs)) {
+				/* This crb was not marked as valid, ignore */
+				continue;
+			}
+			icrbd.ii_icrb0_d_regval =
+			    REMOTE_HUB_L(nasid, IIO_ICRB_D(i));
+			if (icrbd.d_bteop) {
+				mod_timer(recovery_timer, HZ * 5);
+				BTE_PRINTK(("eh:%p:%d Valid %d, Giving up\n",
+					    err_nodepda, smp_processor_id(),
+					    i));
+				spin_unlock_irqrestore(recovery_lock,
+						       irq_flags);
+				return;
+			}
+		}
+	}
+
+	BTE_PRINTK(("eh:%p:%d Cleaning up\n", err_nodepda, smp_processor_id()));
+	/* Reenable both bte interfaces */
+	imem.ii_imem_regval = REMOTE_HUB_L(nasid, IIO_IMEM);
+	imem.ii_imem_fld_s.i_b0_esd = imem.ii_imem_fld_s.i_b1_esd = 1;
+	REMOTE_HUB_S(nasid, IIO_IMEM, imem.ii_imem_regval);
+
+	/* Reinitialize both BTE state machines. */
+	ibcr.ii_ibcr_regval = REMOTE_HUB_L(nasid, IIO_IBCR);
+	ibcr.ii_ibcr_fld_s.i_soft_reset = 1;
+	REMOTE_HUB_S(nasid, IIO_IBCR, ibcr.ii_ibcr_regval);
+
+	for (i = 0; i < BTES_PER_NODE; i++) {
+		bh_error = err_nodepda->bte_if[i].bh_error;
+		if (bh_error != BTE_SUCCESS) {
+			/* There is an error which needs to be notified */
+			notify = err_nodepda->bte_if[i].most_rcnt_na;
+			BTE_PRINTK(("cnode %d bte %d error=0x%lx\n",
+				    err_nodepda->bte_if[i].bte_cnode,
+				    err_nodepda->bte_if[i].bte_num,
+				    IBLS_ERROR | (u64) bh_error));
+			*notify = IBLS_ERROR | bh_error;
+			err_nodepda->bte_if[i].bh_error = BTE_SUCCESS;
+		}
+
+		err_nodepda->bte_if[i].cleanup_active = 0;
+		BTE_PRINTK(("eh:%p:%d Unlocked %d\n", err_nodepda,
+			    smp_processor_id(), i));
+		spin_unlock(&pda->cpu_bte_if[i]->spinlock);
+	}
+
+	del_timer(recovery_timer);
+
+	spin_unlock_irqrestore(recovery_lock, irq_flags);
+}
+
+/*
+ * First part error handler.  This is called whenever any error CRB interrupt
+ * is generated by the II.
+ */
+void
+bte_crb_error_handler(cnodeid_t cnode, int btenum,
+                      int crbnum, ioerror_t * ioe, int bteop)
+{
+	struct bteinfo_s *bte;
+
+
+	bte = &(NODEPDA(cnode)->bte_if[btenum]);
+
+	/*
+	 * The caller has already figured out the error type, we save that
+	 * in the bte handle structure for the thread excercising the
+	 * interface to consume.
+	 */
+	bte->bh_error = ioe->ie_errortype + BTEFAIL_OFFSET;
+	bte->bte_error_count++;
+
+	BTE_PRINTK(("Got an error on cnode %d bte %d: HW error type 0x%x\n",
+		bte->bte_cnode, bte->bte_num, ioe->ie_errortype));
+	bte_error_handler((unsigned long) NODEPDA(cnode));
+}
+
diff -Nru a/arch/ia64/sn/kernel/huberror.c b/arch/ia64/sn/kernel/huberror.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/kernel/huberror.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,201 @@
+/*
+ * 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 - 1997, 2000,2002-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <asm/delay.h>
+#include <asm/sn/sn_sal.h>
+#include "ioerror.h"
+#include <asm/sn/addrs.h>
+#include "shubio.h"
+#include <asm/sn/geo.h>
+#include "xtalk/xwidgetdev.h"
+#include "xtalk/hubdev.h"
+#include <asm/sn/bte.h>
+
+void hubiio_crb_error_handler(struct hubdev_info *hubdev_info);
+extern void bte_crb_error_handler(cnodeid_t, int, int, ioerror_t *,
+				  int);
+static irqreturn_t hub_eint_handler(int irq, void *arg, struct pt_regs *ep)
+{
+	struct hubdev_info *hubdev_info;
+	struct ia64_sal_retval ret_stuff;
+	nasid_t nasid;
+
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+	hubdev_info = (struct hubdev_info *)arg;
+	nasid = hubdev_info->hdi_nasid;
+	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_HUB_ERROR_INTERRUPT,
+			(u64) nasid, 0, 0, 0, 0, 0, 0);
+
+	if ((int)ret_stuff.v0)
+		panic("hubii_eint_handler(): Fatal TIO Error");
+
+	if (!(nasid & 1)) /* Not a TIO, handle CRB errors */
+		(void)hubiio_crb_error_handler(hubdev_info);
+
+	return IRQ_HANDLED;
+}
+
+/*
+ * Free the hub CRB "crbnum" which encountered an error.
+ * Assumption is, error handling was successfully done,
+ * and we now want to return the CRB back to Hub for normal usage.
+ *
+ * In order to free the CRB, all that's needed is to de-allocate it
+ *
+ * Assumption:
+ *      No other processor is mucking around with the hub control register.
+ *      So, upper layer has to single thread this.
+ */
+void hubiio_crb_free(struct hubdev_info *hubdev_info, int crbnum)
+{
+	ii_icrb0_b_u_t icrbb;
+
+	/*
+	 * The hardware does NOT clear the mark bit, so it must get cleared
+	 * here to be sure the error is not processed twice.
+	 */
+	icrbb.ii_icrb0_b_regval = REMOTE_HUB_L(hubdev_info->hdi_nasid,
+					       IIO_ICRB_B(crbnum));
+	icrbb.b_mark = 0;
+	REMOTE_HUB_S(hubdev_info->hdi_nasid, IIO_ICRB_B(crbnum),
+		     icrbb.ii_icrb0_b_regval);
+	/*
+	 * Deallocate the register wait till hub indicates it's done.
+	 */
+	REMOTE_HUB_S(hubdev_info->hdi_nasid, IIO_ICDR, (IIO_ICDR_PND | crbnum));
+	while (REMOTE_HUB_L(hubdev_info->hdi_nasid, IIO_ICDR) & IIO_ICDR_PND)
+		udelay(1);
+
+}
+
+/*
+ * hubiio_crb_error_handler
+ *
+ *	This routine gets invoked when a hub gets an error 
+ *	interrupt. So, the routine is running in interrupt context
+ *	at error interrupt level.
+ * Action:
+ *	It's responsible for identifying ALL the CRBs that are marked
+ *	with error, and process them. 
+ *	
+ * 	If you find the CRB that's marked with error, map this to the
+ *	reason it caused error, and invoke appropriate error handler.
+ *
+ *	XXX Be aware of the information in the context register.
+ *
+ * NOTE:
+ *	Use REMOTE_HUB_* macro instead of LOCAL_HUB_* so that the interrupt
+ *	handler can be run on any node. (not necessarily the node 
+ *	corresponding to the hub that encountered error).
+ */
+
+void hubiio_crb_error_handler(struct hubdev_info *hubdev_info)
+{
+	nasid_t nasid;
+	ii_icrb0_a_u_t icrba;	/* II CRB Register A */
+	ii_icrb0_b_u_t icrbb;	/* II CRB Register B */
+	ii_icrb0_c_u_t icrbc;	/* II CRB Register C */
+	ii_icrb0_d_u_t icrbd;	/* II CRB Register D */
+	ii_icrb0_e_u_t icrbe;	/* II CRB Register D */
+	int i;
+	int num_errors = 0;	/* Num of errors handled */
+	ioerror_t ioerror;
+
+	nasid = hubdev_info->hdi_nasid;
+
+	/*
+	 * XXX - Add locking for any recovery actions
+	 */
+	/*
+	 * Scan through all CRBs in the Hub, and handle the errors
+	 * in any of the CRBs marked.
+	 */
+	for (i = 0; i < IIO_NUM_CRBS; i++) {
+		/* Check this crb entry to see if it is in error. */
+		icrbb.ii_icrb0_b_regval = REMOTE_HUB_L(nasid, IIO_ICRB_B(i));
+
+		if (icrbb.b_mark == 0) {
+			continue;
+		}
+
+		icrba.ii_icrb0_a_regval = REMOTE_HUB_L(nasid, IIO_ICRB_A(i));
+
+		IOERROR_INIT(&ioerror);
+
+		/* read other CRB error registers. */
+		icrbc.ii_icrb0_c_regval = REMOTE_HUB_L(nasid, IIO_ICRB_C(i));
+		icrbd.ii_icrb0_d_regval = REMOTE_HUB_L(nasid, IIO_ICRB_D(i));
+		icrbe.ii_icrb0_e_regval = REMOTE_HUB_L(nasid, IIO_ICRB_E(i));
+
+		IOERROR_SETVALUE(&ioerror, errortype, icrbb.b_ecode);
+
+		/* Check if this error is due to BTE operation,
+		 * and handle it separately.
+		 */
+		if (icrbd.d_bteop ||
+		    ((icrbb.b_initiator == IIO_ICRB_INIT_BTE0 ||
+		      icrbb.b_initiator == IIO_ICRB_INIT_BTE1) &&
+		     (icrbb.b_imsgtype == IIO_ICRB_IMSGT_BTE ||
+		      icrbb.b_imsgtype == IIO_ICRB_IMSGT_SN1NET))) {
+
+			int bte_num;
+
+			if (icrbd.d_bteop)
+				bte_num = icrbc.c_btenum;
+			else	/* b_initiator bit 2 gives BTE number */
+				bte_num = (icrbb.b_initiator & 0x4) >> 2;
+
+			hubiio_crb_free(hubdev_info, i);
+
+			bte_crb_error_handler(nasid_to_cnodeid(nasid), bte_num,
+					      i, &ioerror, icrbd.d_bteop);
+			num_errors++;
+			continue;
+		}
+	}
+}
+
+/*
+ * Function	: hub_error_init
+ * Purpose	: initialize the error handling requirements for a given hub.
+ * Parameters	: cnode, the compact nodeid.
+ * Assumptions	: Called only once per hub, either by a local cpu. Or by a
+ *			remote cpu, when this hub is headless.(cpuless)
+ * Returns	: None
+ */
+void hub_error_init(struct hubdev_info *hubdev_info)
+{
+	if (request_irq(SGI_II_ERROR, (void *)hub_eint_handler, SA_SHIRQ,
+			"SN_hub_error", (void *)hubdev_info))
+		printk("hub_error_init: Failed to request_irq for 0x%p\n",
+		    hubdev_info);
+	return;
+}
+
+
+/*
+ * Function	: ice_error_init
+ * Purpose	: initialize the error handling requirements for a given tio.
+ * Parameters	: cnode, the compact nodeid.
+ * Assumptions	: Called only once per tio.
+ * Returns	: None
+ */
+void ice_error_init(struct hubdev_info *hubdev_info)
+{
+        if (request_irq
+            (SGI_TIO_ERROR, (void *)hub_eint_handler, SA_SHIRQ, "SN_TIO_error",
+             (void *)hubdev_info))
+                printk("ice_error_init: request_irq() error hubdev_info 0x%p\n",
+                       hubdev_info);
+        return;
+}
+
diff -Nru a/arch/ia64/sn/kernel/idle.c b/arch/ia64/sn/kernel/idle.c
--- a/arch/ia64/sn/kernel/idle.c	2004-12-24 13:37:32 -08:00
+++ b/arch/ia64/sn/kernel/idle.c	2004-12-24 13:37:32 -08:00
@@ -3,14 +3,13 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
+ * Copyright (c) 2001-2004 Silicon Graphics, Inc.  All rights reserved.
  */
 
-#include <linux/config.h>
 #include <asm/sn/leds.h>
-#include <asm/sn/simulator.h>
 
-void snidle(int state) {
+void snidle(int state)
+{
 	if (state) {
 		if (pda->idle_flag == 0) {
 			/* 
@@ -18,11 +17,6 @@
 			 */
 			set_led_bits(0, LED_CPU_ACTIVITY);
 		}
-
-#ifdef CONFIG_IA64_SGI_SN_SIM
-		if (IS_RUNNING_ON_SIMULATOR())
-			SIMULATOR_SLEEP();
-#endif
 
 		pda->idle_flag = 1;
 	} else {
diff -Nru a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/kernel/io_init.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,410 @@
+/*
+ * 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 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/bootmem.h>
+#include <asm/sn/types.h>
+#include <asm/sn/sn_sal.h>
+#include <asm/sn/addrs.h>
+#include "pci/pcibus_provider_defs.h"
+#include "pci/pcidev.h"
+#include "pci/pcibr_provider.h"
+#include "xtalk/xwidgetdev.h"
+#include <asm/sn/geo.h>
+#include "xtalk/hubdev.h"
+#include <asm/sn/io.h>
+#include <asm/sn/simulator.h>
+
+char master_baseio_wid;
+nasid_t master_nasid = INVALID_NASID;	/* Partition Master */
+
+struct slab_info {
+	struct hubdev_info hubdev;
+};
+
+struct brick {
+	moduleid_t id;		/* Module ID of this module        */
+	struct slab_info slab_info[MAX_SLABS + 1];
+};
+
+int sn_ioif_inited = 0;		/* SN I/O infrastructure initialized? */
+
+/*
+ * Retrieve the DMA Flush List given nasid.  This list is needed 
+ * to implement the WAR - Flush DMA data on PIO Reads.
+ */
+static inline uint64_t
+sal_get_widget_dmaflush_list(u64 nasid, u64 widget_num, u64 address)
+{
+
+	struct ia64_sal_retval ret_stuff;
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+
+	SAL_CALL_NOLOCK(ret_stuff,
+			(u64) SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
+			(u64) nasid, (u64) widget_num, (u64) address, 0, 0, 0,
+			0);
+	return ret_stuff.v0;
+
+}
+
+/*
+ * Retrieve the hub device info structure for the given nasid.
+ */
+static inline uint64_t sal_get_hubdev_info(u64 handle, u64 address)
+{
+
+	struct ia64_sal_retval ret_stuff;
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+
+	SAL_CALL_NOLOCK(ret_stuff,
+			(u64) SN_SAL_IOIF_GET_HUBDEV_INFO,
+			(u64) handle, (u64) address, 0, 0, 0, 0, 0);
+	return ret_stuff.v0;
+}
+
+/*
+ * Retrieve the pci bus information given the bus number.
+ */
+static inline uint64_t sal_get_pcibus_info(u64 segment, u64 busnum, u64 address)
+{
+
+	struct ia64_sal_retval ret_stuff;
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+
+	SAL_CALL_NOLOCK(ret_stuff,
+			(u64) SN_SAL_IOIF_GET_PCIBUS_INFO,
+			(u64) segment, (u64) busnum, (u64) address, 0, 0, 0, 0);
+	return ret_stuff.v0;
+}
+
+/*
+ * Retrieve the pci device information given the bus and device|function number.
+ */
+static inline uint64_t
+sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev, 
+			u64 sn_irq_info)
+{
+	struct ia64_sal_retval ret_stuff;
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+
+	SAL_CALL_NOLOCK(ret_stuff,
+			(u64) SN_SAL_IOIF_GET_PCIDEV_INFO,
+			(u64) segment, (u64) bus_number, (u64) devfn, 
+			(u64) pci_dev,
+			sn_irq_info, 0, 0);
+	return ret_stuff.v0;
+}
+
+/*
+ * sn_alloc_pci_sysdata() - This routine allocates a pci controller
+ *	which is expected as the pci_dev and pci_bus sysdata by the Linux
+ *	PCI infrastructure.
+ */
+static inline struct pci_controller *sn_alloc_pci_sysdata(void)
+{
+	struct pci_controller *pci_sysdata;
+
+	pci_sysdata = kmalloc(sizeof(*pci_sysdata), GFP_KERNEL);
+	if (!pci_sysdata)
+		BUG();
+
+	memset(pci_sysdata, 0, sizeof(*pci_sysdata));
+	return pci_sysdata;
+}
+
+/*
+ * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for 
+ *	each node in the system.
+ */
+static void sn_fixup_ionodes(void)
+{
+
+	struct sn_flush_device_list *sn_flush_device_list;
+	struct hubdev_info *hubdev;
+	uint64_t status;
+	uint64_t nasid;
+	int i, widget;
+
+	for (i = 0; i < numionodes; i++) {
+		hubdev = (struct hubdev_info *)(NODEPDA(i)->pdinfo);
+		nasid = cnodeid_to_nasid(i);
+		status = sal_get_hubdev_info(nasid, (uint64_t) __pa(hubdev));
+		if (status)
+			continue;
+
+		for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++)
+			hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev;
+
+		if (!hubdev->hdi_flush_nasid_list.widget_p)
+			continue;
+
+		hubdev->hdi_flush_nasid_list.widget_p =
+		    kmalloc((HUB_WIDGET_ID_MAX + 1) *
+			    sizeof(struct sn_flush_device_list *), GFP_KERNEL);
+
+		memset(hubdev->hdi_flush_nasid_list.widget_p, 0x0,
+		       (HUB_WIDGET_ID_MAX + 1) *
+		       sizeof(struct sn_flush_device_list *));
+
+		for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
+			sn_flush_device_list = kmalloc(DEV_PER_WIDGET *
+						       sizeof(struct
+							      sn_flush_device_list),
+						       GFP_KERNEL);
+			memset(sn_flush_device_list, 0x0,
+			       DEV_PER_WIDGET *
+			       sizeof(struct sn_flush_device_list));
+
+			status =
+			    sal_get_widget_dmaflush_list(nasid, widget,
+							 (uint64_t)
+							 __pa
+							 (sn_flush_device_list));
+			if (status) {
+				kfree(sn_flush_device_list);
+				continue;
+			}
+
+			hubdev->hdi_flush_nasid_list.widget_p[widget] =
+			    sn_flush_device_list;
+		}
+
+		if (!(i & 1))
+			hub_error_init(hubdev);
+		else
+			ice_error_init(hubdev);
+	}
+
+}
+
+/*
+ * sn_pci_fixup_slot() - This routine sets up a slot's resources
+ * consistent with the Linux PCI abstraction layer.  Resources acquired
+ * from our PCI provider include PIO maps to BAR space and interrupt
+ * objects.
+ */
+static void sn_pci_fixup_slot(struct pci_dev *dev)
+{
+	int idx;
+	int segment = 0;
+	uint64_t size;
+	struct sn_irq_info *sn_irq_info;
+	struct pci_dev *host_pci_dev;
+	int status = 0;
+
+	SN_PCIDEV_INFO(dev) = kmalloc(sizeof(struct pcidev_info), GFP_KERNEL);
+	if (SN_PCIDEV_INFO(dev) <= 0)
+		BUG();		/* Cannot afford to run out of memory */
+	memset(SN_PCIDEV_INFO(dev), 0, sizeof(struct pcidev_info));
+
+	sn_irq_info = kmalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
+	if (sn_irq_info <= 0)
+		BUG();		/* Cannot afford to run out of memory */
+	memset(sn_irq_info, 0, sizeof(struct sn_irq_info));
+
+	/* Call to retrieve pci device information needed by kernel. */
+	status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number, 
+				     dev->devfn,
+				     (u64) __pa(SN_PCIDEV_INFO(dev)),
+				     (u64) __pa(sn_irq_info));
+	if (status)
+		BUG();		/* Cannot get platform pci device information information */
+
+	/* Copy over PIO Mapped Addresses */
+	for (idx = 0; idx <= PCI_ROM_RESOURCE; idx++) {
+		unsigned long start, end, addr;
+
+		if (!SN_PCIDEV_INFO(dev)->pdi_pio_mapped_addr[idx])
+			continue;
+
+		start = dev->resource[idx].start;
+		end = dev->resource[idx].end;
+		size = end - start;
+		addr = SN_PCIDEV_INFO(dev)->pdi_pio_mapped_addr[idx];
+		addr = ((addr << 4) >> 4) | __IA64_UNCACHED_OFFSET;
+		dev->resource[idx].start = addr;
+		dev->resource[idx].end = addr + size;
+		if (dev->resource[idx].flags & IORESOURCE_IO)
+			dev->resource[idx].parent = &ioport_resource;
+		else
+			dev->resource[idx].parent = &iomem_resource;
+	}
+
+	/* set up host bus linkages */
+	host_pci_dev =
+	    pci_find_slot(SN_PCIDEV_INFO(dev)->pdi_slot_host_handle >> 32,
+			  SN_PCIDEV_INFO(dev)->
+			  pdi_slot_host_handle & 0xffffffff);
+	SN_PCIDEV_INFO(dev)->pdi_host_pcidev_info =
+	    SN_PCIDEV_INFO(host_pci_dev);
+	SN_PCIDEV_INFO(dev)->pdi_linux_pcidev = dev;
+	SN_PCIDEV_INFO(dev)->pdi_pcibus_info = SN_PCIBUS_BUSSOFT(dev->bus);
+
+	/* Only set up IRQ stuff if this device has a host bus context */
+	if (SN_PCIDEV_BUSSOFT(dev) && sn_irq_info->irq_irq) {
+		SN_PCIDEV_INFO(dev)->pdi_sn_irq_info = sn_irq_info;
+		dev->irq = SN_PCIDEV_INFO(dev)->pdi_sn_irq_info->irq_irq;
+		sn_irq_fixup(dev, sn_irq_info);
+	}
+}
+
+/*
+ * sn_pci_controller_fixup() - This routine sets up a bus's resources
+ * consistent with the Linux PCI abstraction layer.
+ */
+static void sn_pci_controller_fixup(int segment, int busnum)
+{
+	int status = 0;
+	int nasid, cnode;
+	struct pci_bus *bus;
+	struct pci_controller *controller;
+	struct pcibus_bussoft *prom_bussoft_ptr;
+	struct hubdev_info *hubdev_info;
+	void *provider_soft;
+
+	status =
+	    sal_get_pcibus_info((u64) segment, (u64) busnum,
+				(u64) ia64_tpa(&prom_bussoft_ptr));
+	if (status > 0) {
+		return;		/* bus # does not exist */
+	}
+
+	prom_bussoft_ptr = __va(prom_bussoft_ptr);
+	controller = sn_alloc_pci_sysdata();
+	/* controller non-zero is BUG'd in sn_alloc_pci_sysdata */
+
+	bus = pci_scan_bus(busnum, &pci_root_ops, controller);
+	if (bus == NULL) {
+		return;		/* error, or bus already scanned */
+	}
+
+	/*
+	 * Per-provider fixup.  Copies the contents from prom to local
+	 * area and links SN_PCIBUS_BUSSOFT().
+	 *
+	 * Note:  Provider is responsible for ensuring that prom_bussoft_ptr
+	 * represents an asic-type that it can handle.
+	 */
+
+	if (prom_bussoft_ptr->bs_asic_type == PCIIO_ASIC_TYPE_PPB) {
+		return;		/* no further fixup necessary */
+	}
+
+	provider_soft = pcibr_bus_fixup(prom_bussoft_ptr);
+	if (provider_soft == NULL) {
+		return;		/* fixup failed or not applicable */
+	}
+
+	/*
+	 * Generic bus fixup goes here.  Don't reference prom_bussoft_ptr
+	 * after this point.
+	 */
+
+	PCI_CONTROLLER(bus) = controller;
+	SN_PCIBUS_BUSSOFT(bus) = provider_soft;
+
+	nasid = NASID_GET(SN_PCIBUS_BUSSOFT(bus)->bs_base);
+	cnode = nasid_to_cnodeid(nasid);
+	hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
+	SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info =
+	    &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]);
+}
+
+/*
+ * Ugly hack to get PCI setup until we have a proper ACPI namespace.
+ */
+
+#define PCI_BUSES_TO_SCAN 256
+
+static int __init sn_pci_init(void)
+{
+	int i = 0;
+	struct pci_dev *pci_dev = NULL;
+	extern void sn_init_cpei_timer(void);
+#ifdef CONFIG_PROC_FS
+	extern void register_sn_procfs(void);
+#endif
+
+	if (!ia64_platform_is("sn2") || IS_RUNNING_ON_SIMULATOR())
+		return 0;
+
+	/*
+	 * This is needed to avoid bounce limit checks in the blk layer
+	 */
+	ia64_max_iommu_merge_mask = ~PAGE_MASK;
+	sn_fixup_ionodes();
+	sn_irq = kmalloc(sizeof(struct sn_irq_info *) * NR_IRQS, GFP_KERNEL);
+	if (sn_irq <= 0)
+		BUG();		/* Canno afford to run out of memory. */
+	memset(sn_irq, 0, sizeof(struct sn_irq_info *) * NR_IRQS);
+
+	sn_init_cpei_timer();
+
+#ifdef CONFIG_PROC_FS
+	register_sn_procfs();
+#endif
+
+	for (i = 0; i < PCI_BUSES_TO_SCAN; i++) {
+		sn_pci_controller_fixup(0, i);
+	}
+
+	/*
+	 * Generic Linux PCI Layer has created the pci_bus and pci_dev 
+	 * structures - time for us to add our SN PLatform specific 
+	 * information.
+	 */
+
+	while ((pci_dev =
+		pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) {
+		sn_pci_fixup_slot(pci_dev);
+	}
+
+	sn_ioif_inited = 1;	/* sn I/O infrastructure now initialized */
+
+	return 0;
+}
+
+/*
+ * hubdev_init_node() - Creates the HUB data structure and link them to it's 
+ *	own NODE specific data area.
+ */
+void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
+{
+
+	struct hubdev_info *hubdev_info;
+
+	if (node >= numnodes)	/* Headless/memless IO nodes */
+		hubdev_info =
+		    (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(0),
+							     sizeof(struct
+								    hubdev_info));
+	else
+		hubdev_info =
+		    (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(node),
+							     sizeof(struct
+								    hubdev_info));
+	npda->pdinfo = (void *)hubdev_info;
+
+}
+
+geoid_t
+cnodeid_get_geoid(cnodeid_t cnode)
+{
+
+	struct hubdev_info *hubdev;
+
+	hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
+	return hubdev->hdi_geoid;
+
+}
+
+subsys_initcall(sn_pci_init);
diff -Nru a/arch/ia64/sn/kernel/iomv.c b/arch/ia64/sn/kernel/iomv.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/kernel/iomv.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,75 @@
+/* 
+ * 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-2003 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/module.h>
+#include <asm/io.h>
+#include <asm/delay.h>
+#include <asm/sn/nodepda.h>
+#include <asm/sn/simulator.h>
+#include <asm/sn/pda.h>
+#include <asm/sn/sn_cpuid.h>
+#include <asm/sn/shub_mmr.h>
+
+/**
+ * sn_io_addr - convert an in/out port to an i/o address
+ * @port: port to convert
+ *
+ * Legacy in/out instructions are converted to ld/st instructions
+ * on IA64.  This routine will convert a port number into a valid 
+ * SN i/o address.  Used by sn_in*() and sn_out*().
+ */
+void *sn_io_addr(unsigned long port)
+{
+	if (!IS_RUNNING_ON_SIMULATOR()) {
+		/* On sn2, legacy I/O ports don't point at anything */
+		if (port < (64 * 1024))
+			return NULL;
+		return ((void *)(port | __IA64_UNCACHED_OFFSET));
+	} else {
+		/* but the simulator uses them... */
+		unsigned long io_base;
+		unsigned long addr;
+
+		/*
+		 * word align port, but need more than 10 bits
+		 * for accessing registers in bedrock local block
+		 * (so we don't do port&0xfff)
+		 */
+		if ((port >= 0x1f0 && port <= 0x1f7) ||
+		    port == 0x3f6 || port == 0x3f7) {
+			io_base = (0xc000000fcc000000UL |
+				   ((unsigned long)get_nasid() << 38));
+			addr = io_base | ((port >> 2) << 12) | (port & 0xfff);
+		} else {
+			addr = __ia64_get_io_port_base() | ((port >> 2) << 2);
+		}
+		return (void *)addr;
+	}
+}
+
+EXPORT_SYMBOL(sn_io_addr);
+
+/**
+ * __sn_mmiowb - I/O space memory barrier
+ *
+ * See include/asm-ia64/io.h and Documentation/DocBook/deviceiobook.tmpl
+ * for details.
+ *
+ * On SN2, we wait for the PIO_WRITE_STATUS SHub register to clear.
+ * See PV 871084 for details about the WAR about zero value.
+ *
+ */
+void __sn_mmiowb(void)
+{
+	while ((((volatile unsigned long)(*pda->pio_write_status_addr)) &
+		SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK) !=
+	       SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK)
+		cpu_relax();
+}
+
+EXPORT_SYMBOL(__sn_mmiowb);
diff -Nru a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
--- a/arch/ia64/sn/kernel/irq.c	2004-12-24 13:36:19 -08:00
+++ b/arch/ia64/sn/kernel/irq.c	2004-12-24 13:36:19 -08:00
@@ -5,97 +5,83 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
  */
 
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/vmalloc.h>
 #include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/bootmem.h>
-#include <linux/cpumask.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/types.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pciio_private.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/io.h>
 #include <asm/sn/intr.h>
 #include <asm/sn/addrs.h>
-#include <asm/sn/driver.h>
 #include <asm/sn/arch.h>
-#include <asm/sn/pda.h>
-#include <asm/processor.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
-#include <asm/sn/sn2/shub_mmr.h>
+#include "xtalk/xwidgetdev.h"
+#include "pci/pcibus_provider_defs.h"
+#include "pci/pcidev.h"
+#include "pci/pcibr_provider.h"
+#include <asm/sn/shub_mmr.h>
+#include <asm/sn/sn_sal.h>
 
 static void force_interrupt(int irq);
-extern void pcibr_force_interrupt(pcibr_intr_t intr);
-extern int sn_force_interrupt_flag;
-struct irq_desc * sn_irq_desc(unsigned int irq);
-extern cpumask_t    __cacheline_aligned pending_irq_cpumask[NR_IRQS];
+static void register_intr_pda(struct sn_irq_info *sn_irq_info);
+static void unregister_intr_pda(struct sn_irq_info *sn_irq_info);
 
-struct sn_intr_list_t {
-	struct sn_intr_list_t *next;
-	pcibr_intr_t intr;
-};
+extern int sn_force_interrupt_flag;
+extern int sn_ioif_inited;
+struct sn_irq_info **sn_irq;
 
-static struct sn_intr_list_t *sn_intr_list[NR_IRQS];
+static inline uint64_t sn_intr_alloc(nasid_t local_nasid, int local_widget,
+				     u64 sn_irq_info,
+				     int req_irq, nasid_t req_nasid,
+				     int req_slice)
+{
+	struct ia64_sal_retval ret_stuff;
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
 
+	SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_INTERRUPT,
+			(u64) SAL_INTR_ALLOC, (u64) local_nasid,
+			(u64) local_widget, (u64) sn_irq_info, (u64) req_irq,
+			(u64) req_nasid, (u64) req_slice);
+	return ret_stuff.status;
+}
 
-static unsigned int
-sn_startup_irq(unsigned int irq)
+static inline void sn_intr_free(nasid_t local_nasid, int local_widget,
+				struct sn_irq_info *sn_irq_info)
 {
-        return(0);
+	struct ia64_sal_retval ret_stuff;
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+
+	SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_INTERRUPT,
+			(u64) SAL_INTR_FREE, (u64) local_nasid,
+			(u64) local_widget, (u64) sn_irq_info->irq_irq,
+			(u64) sn_irq_info->irq_cookie, 0, 0);
 }
 
-static void
-sn_shutdown_irq(unsigned int irq)
+static unsigned int sn_startup_irq(unsigned int irq)
 {
+	return 0;
 }
 
-static void
-sn_disable_irq(unsigned int irq)
+static void sn_shutdown_irq(unsigned int irq)
 {
 }
 
-static void
-sn_enable_irq(unsigned int irq)
+static void sn_disable_irq(unsigned int irq)
 {
 }
 
-static inline void sn_move_irq(int irq)
+static void sn_enable_irq(unsigned int irq)
 {
-	/* note - we hold desc->lock */
-	cpumask_t tmp;
-	irq_desc_t *desc = irq_descp(irq);
-
-	if (!cpus_empty(pending_irq_cpumask[irq])) {
-		cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
-		if (unlikely(!cpus_empty(tmp))) {
-			desc->handler->set_affinity(irq, pending_irq_cpumask[irq]);
-		}
-		cpus_clear(pending_irq_cpumask[irq]);
-	}
 }
 
-static void
-sn_ack_irq(unsigned int irq)
+static void sn_ack_irq(unsigned int irq)
 {
-	unsigned long event_occurred, mask = 0;
+	uint64_t event_occurred, mask = 0;
 	int nasid;
 
 	irq = irq & 0xff;
-	nasid = smp_physical_node_id();
-	event_occurred = HUB_L( (unsigned long *)GLOBAL_MMR_ADDR(nasid,SH_EVENT_OCCURRED) );
+	nasid = get_nasid();
+	event_occurred =
+	    HUB_L((uint64_t *) GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED));
 	if (event_occurred & SH_EVENT_OCCURRED_UART_INT_MASK) {
 		mask |= (1 << SH_EVENT_OCCURRED_UART_INT_SHFT);
 	}
@@ -108,63 +94,102 @@
 	if (event_occurred & SH_EVENT_OCCURRED_II_INT1_MASK) {
 		mask |= (1 << SH_EVENT_OCCURRED_II_INT1_SHFT);
 	}
-	HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED_ALIAS), mask );
+	HUB_S((uint64_t *) GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED_ALIAS),
+	      mask);
 	__set_bit(irq, (volatile void *)pda->sn_in_service_ivecs);
-	sn_move_irq(irq);
+
+	move_irq(irq);
 }
 
-static void
-sn_end_irq(unsigned int irq)
+static void sn_end_irq(unsigned int irq)
 {
 	int nasid;
 	int ivec;
-	unsigned long event_occurred;
-	irq_desc_t *desc = sn_irq_desc(irq);
-	unsigned int status = desc->status;
+	uint64_t event_occurred;
 
 	ivec = irq & 0xff;
 	if (ivec == SGI_UART_VECTOR) {
-		nasid = smp_physical_node_id();
-		event_occurred = HUB_L( (unsigned long *)GLOBAL_MMR_ADDR(nasid,SH_EVENT_OCCURRED) );
-		// If the UART bit is set here, we may have received an interrupt from the
-		// UART that the driver missed.  To make sure, we IPI ourselves to force us
-		// to look again.
+		nasid = get_nasid();
+		event_occurred = HUB_L((uint64_t *) GLOBAL_MMR_ADDR
+				       (nasid, SH_EVENT_OCCURRED));
+		/* If the UART bit is set here, we may have received an 
+		 * interrupt from the UART that the driver missed.  To
+		 * make sure, we IPI ourselves to force us to look again.
+		 */
 		if (event_occurred & SH_EVENT_OCCURRED_UART_INT_MASK) {
-				platform_send_ipi(smp_processor_id(), SGI_UART_VECTOR, IA64_IPI_DM_INT, 0);
+			platform_send_ipi(smp_processor_id(), SGI_UART_VECTOR,
+					  IA64_IPI_DM_INT, 0);
 		}
 	}
 	__clear_bit(ivec, (volatile void *)pda->sn_in_service_ivecs);
 	if (sn_force_interrupt_flag)
-		if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-			force_interrupt(irq);
+		force_interrupt(irq);
 }
 
-static void
-sn_set_affinity_irq(unsigned int irq, cpumask_t mask)
+static void sn_set_affinity_irq(unsigned int irq, cpumask_t mask)
 {
-#ifdef CONFIG_SMP
-	int redir = 0;
-	int cpu;
-	struct sn_intr_list_t *p = sn_intr_list[irq];
-	pcibr_intr_t intr;
-	extern void sn_shub_redirect_intr(pcibr_intr_t intr, unsigned long cpu);
-	extern void sn_tio_redirect_intr(pcibr_intr_t intr, unsigned long cpu);
-
-	if (p == NULL)
-		return; 
-        
-	intr = p->intr;
-
-	if (intr == NULL)
-		return; 
-
-	cpu = first_cpu(mask);
-	sn_shub_redirect_intr(intr, cpu);
-	irq = irq & 0xff;  /* strip off redirect bit, if someone stuck it on. */
-	(void) set_irq_affinity_info(irq, cpu_physical_id(intr->bi_cpu), redir);
-#endif /* CONFIG_SMP */
-}
+	struct sn_irq_info *sn_irq_info = sn_irq[irq];
+	struct sn_irq_info *tmp_sn_irq_info;
+	int cpuid, cpuphys;
+	nasid_t t_nasid;	/* nasid to target */
+	int t_slice;		/* slice to target */
+
+	/* allocate a temp sn_irq_info struct to get new target info */
+	tmp_sn_irq_info = kmalloc(sizeof(*tmp_sn_irq_info), GFP_KERNEL);
+	if (!tmp_sn_irq_info)
+		return;
 
+	cpuid = first_cpu(mask);
+	cpuphys = cpu_physical_id(cpuid);
+	t_nasid = cpuid_to_nasid(cpuid);
+	t_slice = cpuid_to_slice(cpuid);
+
+	while (sn_irq_info) {
+		int status;
+		int local_widget;
+		uint64_t bridge = (uint64_t) sn_irq_info->irq_bridge;
+		nasid_t local_nasid = NASID_GET(bridge);
+
+		if (!bridge)
+			break;	/* irq is not a device interrupt */
+
+		if (local_nasid & 1)
+			local_widget = TIO_SWIN_WIDGETNUM(bridge);
+		else
+			local_widget = SWIN_WIDGETNUM(bridge);
+
+		/* Free the old PROM sn_irq_info structure */
+		sn_intr_free(local_nasid, local_widget, sn_irq_info);
+
+		/* allocate a new PROM sn_irq_info struct */
+		status = sn_intr_alloc(local_nasid, local_widget,
+				       __pa(tmp_sn_irq_info), irq, t_nasid,
+				       t_slice);
+
+		if (status == 0) {
+			/* Update kernels sn_irq_info with new target info */
+			unregister_intr_pda(sn_irq_info);
+			sn_irq_info->irq_cpuid = cpuid;
+			sn_irq_info->irq_nasid = t_nasid;
+			sn_irq_info->irq_slice = t_slice;
+			sn_irq_info->irq_xtalkaddr =
+			    tmp_sn_irq_info->irq_xtalkaddr;
+			sn_irq_info->irq_cookie = tmp_sn_irq_info->irq_cookie;
+			register_intr_pda(sn_irq_info);
+
+			if (IS_PCI_BRIDGE_ASIC(sn_irq_info->irq_bridge_type)) {
+				pcibr_change_devices_irq(sn_irq_info);
+			}
+
+			sn_irq_info = sn_irq_info->irq_next;
+
+			set_irq_affinity_info((irq & 0xff), cpuphys, 0);
+		} else {
+			break;	/* snp_affinity failed the intr_alloc */
+		}
+	}
+	kfree(tmp_sn_irq_info);
+}
 
 struct hw_interrupt_type irq_type_sn = {
 	"SN hub",
@@ -172,208 +197,243 @@
 	sn_shutdown_irq,
 	sn_enable_irq,
 	sn_disable_irq,
-	sn_ack_irq, 
+	sn_ack_irq,
 	sn_end_irq,
 	sn_set_affinity_irq
 };
 
-
-struct irq_desc *
-sn_irq_desc(unsigned int irq)
+struct irq_desc *sn_irq_desc(unsigned int irq)
 {
-
-	irq = SN_IVEC_FROM_IRQ(irq);
-
-	return(_irq_desc + irq);
+	return (_irq_desc + irq);
 }
 
-u8
-sn_irq_to_vector(unsigned int irq)
+u8 sn_irq_to_vector(unsigned int irq)
 {
-	return(irq);
+	return irq;
 }
 
-unsigned int
-sn_local_vector_to_irq(u8 vector)
+unsigned int sn_local_vector_to_irq(u8 vector)
 {
 	return (CPU_VECTOR_TO_IRQ(smp_processor_id(), vector));
 }
 
-void
-sn_irq_init (void)
+void sn_irq_init(void)
 {
 	int i;
 	irq_desc_t *base_desc = _irq_desc;
 
-	for (i=0; i<NR_IRQS; i++) {
+	for (i = 0; i < NR_IRQS; i++) {
 		if (base_desc[i].handler == &no_irq_type) {
 			base_desc[i].handler = &irq_type_sn;
 		}
 	}
 }
 
-void
-register_pcibr_intr(int irq, pcibr_intr_t intr)
+static void register_intr_pda(struct sn_irq_info *sn_irq_info)
 {
-	struct sn_intr_list_t *p = kmalloc(sizeof(struct sn_intr_list_t), GFP_KERNEL);
-	struct sn_intr_list_t *list;
-	int cpu = intr->bi_cpu;
+	int irq = sn_irq_info->irq_irq;
+	int cpu = sn_irq_info->irq_cpuid;
 
 	if (pdacpu(cpu)->sn_last_irq < irq) {
 		pdacpu(cpu)->sn_last_irq = irq;
 	}
-	if (pdacpu(cpu)->sn_first_irq == 0 || pdacpu(cpu)->sn_first_irq > irq) pdacpu(cpu)->sn_first_irq = irq;
-	if (!p) panic("Could not allocate memory for sn_intr_list_t\n");
-	if ((list = sn_intr_list[irq])) {
-		while (list->next) list = list->next;
-		list->next = p;
-		p->next = NULL;
-		p->intr = intr;
-	} else {
-		sn_intr_list[irq] = p;
-		p->next = NULL;
-		p->intr = intr;
+
+	if (pdacpu(cpu)->sn_first_irq == 0 || pdacpu(cpu)->sn_first_irq > irq) {
+		pdacpu(cpu)->sn_first_irq = irq;
 	}
 }
 
-void
-unregister_pcibr_intr(int irq, pcibr_intr_t intr)
+static void unregister_intr_pda(struct sn_irq_info *sn_irq_info)
 {
+	int irq = sn_irq_info->irq_irq;
+	int cpu = sn_irq_info->irq_cpuid;
+	struct sn_irq_info *tmp_irq_info;
+	int i, foundmatch;
 
-	struct sn_intr_list_t **prev, *curr;
-	int cpu = intr->bi_cpu;
-	int i;
-
-	if (sn_intr_list[irq] == NULL)
-		return;
-
-	prev = &sn_intr_list[irq];
-	curr = sn_intr_list[irq];
-	while (curr) {
-		if (curr->intr == intr)	 {
-			*prev = curr->next;
-			break;
+	if (pdacpu(cpu)->sn_last_irq == irq) {
+		foundmatch = 0;
+		for (i = pdacpu(cpu)->sn_last_irq - 1; i; i--) {
+			tmp_irq_info = sn_irq[i];
+			while (tmp_irq_info) {
+				if (tmp_irq_info->irq_cpuid == cpu) {
+					foundmatch++;
+					break;
+				}
+				tmp_irq_info = tmp_irq_info->irq_next;
+			}
+			if (foundmatch) {
+				break;
+			}
 		}
-		prev = &curr->next;
-		curr = curr->next;
+		pdacpu(cpu)->sn_last_irq = i;
 	}
 
-	if (curr)
-		kfree(curr);
-
-	if (!sn_intr_list[irq]) {
-		if (pdacpu(cpu)->sn_last_irq == irq) {
-			for (i = pdacpu(cpu)->sn_last_irq - 1; i; i--)
-				if (sn_intr_list[i])
+	if (pdacpu(cpu)->sn_first_irq == irq) {
+		foundmatch = 0;
+		for (i = pdacpu(cpu)->sn_first_irq + 1; i < NR_IRQS; i++) {
+			tmp_irq_info = sn_irq[i];
+			while (tmp_irq_info) {
+				if (tmp_irq_info->irq_cpuid == cpu) {
+					foundmatch++;
 					break;
-			pdacpu(cpu)->sn_last_irq = i;
+				}
+				tmp_irq_info = tmp_irq_info->irq_next;
+			}
+			if (foundmatch) {
+				break;
+			}
 		}
+		pdacpu(cpu)->sn_first_irq = ((i == NR_IRQS) ? 0 : i);
+	}
+}
 
-		if (pdacpu(cpu)->sn_first_irq == irq) {
-			pdacpu(cpu)->sn_first_irq = 0;
-			for (i = pdacpu(cpu)->sn_first_irq + 1; i < NR_IRQS; i++)
-				if (sn_intr_list[i])
-					pdacpu(cpu)->sn_first_irq = i;
-		}
+struct sn_irq_info *sn_irq_alloc(nasid_t local_nasid, int local_widget, int irq,
+				 nasid_t nasid, int slice)
+{
+	struct sn_irq_info *sn_irq_info;
+	int status;
+
+	sn_irq_info = kmalloc(sizeof(*sn_irq_info), GFP_KERNEL);
+	if (sn_irq_info == NULL)
+		return NULL;
+
+	memset(sn_irq_info, 0x0, sizeof(*sn_irq_info));
+
+	status =
+	    sn_intr_alloc(local_nasid, local_widget, __pa(sn_irq_info), irq,
+			  nasid, slice);
+
+	if (status) {
+		kfree(sn_irq_info);
+		return NULL;
+	} else {
+		return sn_irq_info;
 	}
+}
+
+void sn_irq_free(struct sn_irq_info *sn_irq_info)
+{
+	uint64_t bridge = (uint64_t) sn_irq_info->irq_bridge;
+	nasid_t local_nasid = NASID_GET(bridge);
+	int local_widget;
 
+	if (local_nasid & 1)	/* tio check */
+		local_widget = TIO_SWIN_WIDGETNUM(bridge);
+	else
+		local_widget = SWIN_WIDGETNUM(bridge);
+
+	sn_intr_free(local_nasid, local_widget, sn_irq_info);
+
+	kfree(sn_irq_info);
 }
 
-void
-force_polled_int(void)
+void sn_irq_fixup(struct pci_dev *pci_dev, struct sn_irq_info *sn_irq_info)
 {
-	int i;
-	struct sn_intr_list_t *p;
+	nasid_t nasid = sn_irq_info->irq_nasid;
+	int slice = sn_irq_info->irq_slice;
+	int cpu = nasid_slice_to_cpuid(nasid, slice);
 
-	for (i=0; i<NR_IRQS;i++) {
-		p = sn_intr_list[i];
-		while (p) {
-			if (p->intr){
-				pcibr_force_interrupt(p->intr);
-			}
-			p = p->next;
-		}
-	}
+	sn_irq_info->irq_cpuid = cpu;
+	sn_irq_info->irq_pciioinfo = SN_PCIDEV_INFO(pci_dev);
+
+	/* link it into the sn_irq[irq] list */
+	sn_irq_info->irq_next = sn_irq[sn_irq_info->irq_irq];
+	sn_irq[sn_irq_info->irq_irq] = sn_irq_info;
+
+	(void)register_intr_pda(sn_irq_info);
 }
 
-static void
-force_interrupt(int irq)
+static void force_interrupt(int irq)
 {
-	struct sn_intr_list_t *p = sn_intr_list[irq];
+	struct sn_irq_info *sn_irq_info;
 
-	while (p) {
-		if (p->intr) {
-			pcibr_force_interrupt(p->intr);
+	if (!sn_ioif_inited)
+		return;
+	sn_irq_info = sn_irq[irq];
+	while (sn_irq_info) {
+		if (IS_PCI_BRIDGE_ASIC(sn_irq_info->irq_bridge_type) &&
+		    (sn_irq_info->irq_bridge != NULL)) {
+			pcibr_force_interrupt(sn_irq_info);
 		}
-		p = p->next;
+		sn_irq_info = sn_irq_info->irq_next;
 	}
 }
 
 /*
-Check for lost interrupts.  If the PIC int_status reg. says that
-an interrupt has been sent, but not handled, and the interrupt
-is not pending in either the cpu irr regs or in the soft irr regs,
-and the interrupt is not in service, then the interrupt may have
-been lost.  Force an interrupt on that pin.  It is possible that
-the interrupt is in flight, so we may generate a spurious interrupt,
-but we should never miss a real lost interrupt.
-*/
-
-static void
-sn_check_intr(int irq, pcibr_intr_t intr)
+ * Check for lost interrupts.  If the PIC int_status reg. says that
+ * an interrupt has been sent, but not handled, and the interrupt
+ * is not pending in either the cpu irr regs or in the soft irr regs,
+ * and the interrupt is not in service, then the interrupt may have
+ * been lost.  Force an interrupt on that pin.  It is possible that
+ * the interrupt is in flight, so we may generate a spurious interrupt,
+ * but we should never miss a real lost interrupt.
+ */
+static void sn_check_intr(int irq, struct sn_irq_info *sn_irq_info)
 {
-	unsigned long regval;
+	uint64_t regval;
 	int irr_reg_num;
 	int irr_bit;
-	unsigned long irr_reg;
+	uint64_t irr_reg;
+	struct pcidev_info *pcidev_info;
+	struct pcibus_info *pcibus_info;
+
+	pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
+	if (!pcidev_info)
+		return;
 
+	pcibus_info =
+	    (struct pcibus_info *)pcidev_info->pdi_host_pcidev_info->
+	    pdi_pcibus_info;
+	regval = pcireg_intr_status_get(pcibus_info);
 
-	regval = pcireg_intr_status_get(intr->bi_soft);
 	irr_reg_num = irq_to_vector(irq) / 64;
 	irr_bit = irq_to_vector(irq) % 64;
 	switch (irr_reg_num) {
-		case 0:
-			irr_reg = ia64_getreg(_IA64_REG_CR_IRR0);
-			break;
-		case 1:
-			irr_reg = ia64_getreg(_IA64_REG_CR_IRR1);
-			break;
-		case 2:
-			irr_reg = ia64_getreg(_IA64_REG_CR_IRR2);
-			break;
-		case 3:
-			irr_reg = ia64_getreg(_IA64_REG_CR_IRR3);
-			break;
-	}
-	if (!test_bit(irr_bit, &irr_reg) ) {
-		if (!test_bit(irq, pda->sn_soft_irr) ) {
-			if (!test_bit(irq, pda->sn_in_service_ivecs) ) {
+	case 0:
+		irr_reg = ia64_getreg(_IA64_REG_CR_IRR0);
+		break;
+	case 1:
+		irr_reg = ia64_getreg(_IA64_REG_CR_IRR1);
+		break;
+	case 2:
+		irr_reg = ia64_getreg(_IA64_REG_CR_IRR2);
+		break;
+	case 3:
+		irr_reg = ia64_getreg(_IA64_REG_CR_IRR3);
+		break;
+	}
+	if (!test_bit(irr_bit, &irr_reg)) {
+		if (!test_bit(irq, pda->sn_soft_irr)) {
+			if (!test_bit(irq, pda->sn_in_service_ivecs)) {
 				regval &= 0xff;
-				if (intr->bi_ibits & regval & intr->bi_last_intr) {
-					regval &= ~(intr->bi_ibits & regval);
-					pcibr_force_interrupt(intr);
+				if (sn_irq_info->irq_int_bit & regval &
+				    sn_irq_info->irq_last_intr) {
+					regval &=
+					    ~(sn_irq_info->
+					      irq_int_bit & regval);
+					pcibr_force_interrupt(sn_irq_info);
 				}
 			}
 		}
 	}
-	intr->bi_last_intr = regval;
+	sn_irq_info->irq_last_intr = regval;
 }
 
-void
-sn_lb_int_war_check(void)
+void sn_lb_int_war_check(void)
 {
 	int i;
 
-	if (pda->sn_first_irq == 0) return;
-	for (i=pda->sn_first_irq;
-		i <= pda->sn_last_irq; i++) {
-			struct sn_intr_list_t *p = sn_intr_list[i];
-			if (p == NULL) {
-				continue;
-			}
-			while (p) {
-				sn_check_intr(i, p->intr);
-				p = p->next;
+	if (!sn_ioif_inited || pda->sn_first_irq == 0)
+		return;
+	for (i = pda->sn_first_irq; i <= pda->sn_last_irq; i++) {
+		struct sn_irq_info *sn_irq_info = sn_irq[i];
+		while (sn_irq_info) {
+			/* Only call for PCI bridges that are fully initialized. */
+			if (IS_PCI_BRIDGE_ASIC(sn_irq_info->irq_bridge_type) &&
+			    (sn_irq_info->irq_bridge != NULL)) {
+				sn_check_intr(i, sn_irq_info);
 			}
+			sn_irq_info = sn_irq_info->irq_next;
+		}
 	}
 }
diff -Nru a/arch/ia64/sn/kernel/klconflib.c b/arch/ia64/sn/kernel/klconflib.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/kernel/klconflib.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,108 @@
+/*
+ * 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 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/types.h>
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <asm/sn/types.h>
+#include <asm/sn/module.h>
+#include <asm/sn/l1.h>
+
+char brick_types[MAX_BRICK_TYPES + 1] = "cri.xdpn%#=vo^kjbf890123456789...";
+/*
+ * Format a module id for printing.
+ *
+ * There are three possible formats:
+ *
+ *   MODULE_FORMAT_BRIEF	is the brief 6-character format, including
+ *				the actual brick-type as recorded in the 
+ *				moduleid_t, eg. 002c15 for a C-brick, or
+ *				101#17 for a PX-brick.
+ *
+ *   MODULE_FORMAT_LONG		is the hwgraph format, eg. rack/002/bay/15
+ *				of rack/101/bay/17 (note that the brick
+ *				type does not appear in this format).
+ *
+ *   MODULE_FORMAT_LCD		is like MODULE_FORMAT_BRIEF, except that it
+ *				ensures that the module id provided appears
+ *				exactly as it would on the LCD display of
+ *				the corresponding brick, eg. still 002c15
+ *				for a C-brick, but 101p17 for a PX-brick.
+ *
+ * maule (9/13/04):  Removed top-level check for (fmt == MODULE_FORMAT_LCD)
+ * making MODULE_FORMAT_LCD equivalent to MODULE_FORMAT_BRIEF.  It was
+ * decided that all callers should assume the returned string should be what
+ * is displayed on the brick L1 LCD.
+ */
+void
+format_module_id(char *buffer, moduleid_t m, int fmt)
+{
+	int rack, position;
+	unsigned char brickchar;
+
+	rack = MODULE_GET_RACK(m);
+	brickchar = MODULE_GET_BTCHAR(m);
+
+	/* Be sure we use the same brick type character as displayed
+	 * on the brick's LCD
+	 */
+	switch (brickchar) 
+	{
+	case L1_BRICKTYPE_GA:
+	case L1_BRICKTYPE_OPUS_TIO:
+		brickchar = L1_BRICKTYPE_C;
+		break;
+
+	case L1_BRICKTYPE_PX:
+	case L1_BRICKTYPE_PE:
+	case L1_BRICKTYPE_PA:
+	case L1_BRICKTYPE_SA: /* we can move this to the "I's" later
+			       * if that makes more sense
+			       */
+		brickchar = L1_BRICKTYPE_P;
+		break;
+
+	case L1_BRICKTYPE_IX:
+	case L1_BRICKTYPE_IA:
+
+		brickchar = L1_BRICKTYPE_I;
+		break;
+	}
+
+	position = MODULE_GET_BPOS(m);
+
+	if ((fmt == MODULE_FORMAT_BRIEF) || (fmt == MODULE_FORMAT_LCD)) {
+	    /* Brief module number format, eg. 002c15 */
+
+	    /* Decompress the rack number */
+	    *buffer++ = '0' + RACK_GET_CLASS(rack);
+	    *buffer++ = '0' + RACK_GET_GROUP(rack);
+	    *buffer++ = '0' + RACK_GET_NUM(rack);
+
+	    /* Add the brick type */
+	    *buffer++ = brickchar;
+	}
+	else if (fmt == MODULE_FORMAT_LONG) {
+	    /* Fuller hwgraph format, eg. rack/002/bay/15 */
+
+	    strcpy(buffer, "rack" "/");  buffer += strlen(buffer);
+
+	    *buffer++ = '0' + RACK_GET_CLASS(rack);
+	    *buffer++ = '0' + RACK_GET_GROUP(rack);
+	    *buffer++ = '0' + RACK_GET_NUM(rack);
+
+	    strcpy(buffer, "/" "bay" "/");  buffer += strlen(buffer);
+	}
+
+	/* Add the bay position, using at least two digits */
+	if (position < 10)
+	    *buffer++ = '0';
+	sprintf(buffer, "%d", position);
+
+}
diff -Nru a/arch/ia64/sn/kernel/mca.c b/arch/ia64/sn/kernel/mca.c
--- a/arch/ia64/sn/kernel/mca.c	2004-12-24 13:36:19 -08:00
+++ b/arch/ia64/sn/kernel/mca.c	2004-12-24 13:36:19 -08:00
@@ -10,13 +10,10 @@
 #include <linux/kernel.h>
 #include <linux/timer.h>
 #include <linux/vmalloc.h>
-#include <asm/sn/sgi.h>
 #include <asm/mca.h>
 #include <asm/sal.h>
 #include <asm/sn/sn_sal.h>
 
-
-
 /*
  * Interval for calling SAL to poll for errors that do NOT cause error
  * interrupts. SAL will raise a CPEI if any errors are present that
@@ -24,7 +21,6 @@
  */
 #define CPEI_INTERVAL	(5*HZ)
 
-
 struct timer_list sn_cpei_timer;
 void sn_init_cpei_timer(void);
 
@@ -42,8 +38,7 @@
  * info for platform errors.  buf is appended to sn_oemdata, resizing as
  * required.
  */
-static int
-print_hook(const char *fmt, ...)
+static int print_hook(const char *fmt, ...)
 {
 	char buf[400];
 	int len;
@@ -55,7 +50,8 @@
 	while (*sn_oemdata_size + len + 1 > sn_oemdata_bufsize) {
 		u8 *newbuf = vmalloc(sn_oemdata_bufsize += 1000);
 		if (!newbuf) {
-			printk(KERN_ERR "%s: unable to extend sn_oemdata\n", __FUNCTION__);
+			printk(KERN_ERR "%s: unable to extend sn_oemdata\n",
+			       __FUNCTION__);
 			return 0;
 		}
 		memcpy(newbuf, *sn_oemdata, *sn_oemdata_size);
@@ -67,9 +63,7 @@
 	return 0;
 }
 
-
-static void
-sn_cpei_handler(int irq, void *devid, struct pt_regs *regs)
+static void sn_cpei_handler(int irq, void *devid, struct pt_regs *regs)
 {
 	/*
 	 * this function's sole purpose is to call SAL when we receive
@@ -82,16 +76,13 @@
 	ia64_sn_plat_cpei_handler();
 }
 
-
-static void
-sn_cpei_timer_handler(unsigned long dummy)
+static void sn_cpei_timer_handler(unsigned long dummy)
 {
 	sn_cpei_handler(-1, NULL, NULL);
 	mod_timer(&sn_cpei_timer, jiffies + CPEI_INTERVAL);
 }
 
-void
-sn_init_cpei_timer(void)
+void sn_init_cpei_timer(void)
 {
 	init_timer(&sn_cpei_timer);
 	sn_cpei_timer.expires = jiffies + CPEI_INTERVAL;
@@ -100,16 +91,14 @@
 }
 
 static int
-sn_platform_plat_specific_err_print(const u8 *sect_header, u8 **oemdata, u64 *oemdata_size)
+sn_platform_plat_specific_err_print(const u8 * sect_header, u8 ** oemdata,
+				    u64 * oemdata_size)
 {
-	sal_log_plat_specific_err_info_t *psei = (sal_log_plat_specific_err_info_t *)sect_header;
-	if (!psei->valid.oem_data)
-		return 0;
 	down(&sn_oemdata_mutex);
 	sn_oemdata = oemdata;
 	sn_oemdata_size = oemdata_size;
 	sn_oemdata_bufsize = 0;
-	ia64_sn_plat_specific_err_print(print_hook, (char *)psei);
+	ia64_sn_plat_specific_err_print(print_hook, (char *)sect_header);
 	up(&sn_oemdata_mutex);
 	return 0;
 }
@@ -120,13 +109,21 @@
 int sn_salinfo_platform_oemdata(const u8 *sect_header, u8 **oemdata, u64 *oemdata_size)
 {
 	efi_guid_t guid = *(efi_guid_t *)sect_header;
+	int valid = 0;
 	*oemdata_size = 0;
 	vfree(*oemdata);
 	*oemdata = NULL;
-	if (efi_guidcmp(guid, SAL_PLAT_SPECIFIC_ERR_SECT_GUID) == 0 ||
-	    efi_guidcmp(guid, SAL_PLAT_MEM_DEV_ERR_SECT_GUID) == 0)
+	if (efi_guidcmp(guid, SAL_PLAT_SPECIFIC_ERR_SECT_GUID) == 0) {
+		sal_log_plat_specific_err_info_t *psei = (sal_log_plat_specific_err_info_t *)sect_header;
+		valid = psei->valid.oem_data;
+	} else if (efi_guidcmp(guid, SAL_PLAT_MEM_DEV_ERR_SECT_GUID) == 0) {
+		sal_log_mem_dev_err_info_t *mdei = (sal_log_mem_dev_err_info_t *)sect_header;
+		valid = mdei->valid.oem_data;
+	}
+	if (valid)
 		return sn_platform_plat_specific_err_print(sect_header, oemdata, oemdata_size);
-	return 0;
+	else
+		return 0;
 }
 
 static int __init sn_salinfo_init(void)
diff -Nru a/arch/ia64/sn/kernel/probe.c b/arch/ia64/sn/kernel/probe.c
--- a/arch/ia64/sn/kernel/probe.c	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,58 +0,0 @@
-/*
- * Platform dependent support for IO probing.
- *
- * 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-2003 Silicon Graphics, Inc.  All rights reserved.
- */
-
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-
-/**
- * ia64_sn_probe_io_slot - test a memory location for readability
- * @paddr: physical address to probe
- * @size: number bytes to read (1,2,4,8)
- * @data_ptr: address to store value read by probe (-1 returned if probe fails)
- *
- * This function will probe a physical address to determine if
- * the address can be read. If reading the address causes a BUS
- * error, an error is returned. If the probe succeeds, the contents 
- * of the memory location is returned.
- *
- * Return values:
- *  0 - probe successful
- *  1 - probe failed (generated MCA)
- *  2 - Bad arg
- * <0 - PAL error
- */
-u64
-ia64_sn_probe_io_slot(long paddr, long size, void *data_ptr)
-{
-	struct ia64_sal_retval isrv;
-
-	SAL_CALL(isrv, SN_SAL_PROBE, paddr, size, 0, 0, 0, 0, 0);
-
-	if (data_ptr) {
-		switch (size) {
-			case 1:
-				*((u8*)data_ptr) = (u8)isrv.v0;
-				break;
-			case 2:
-				*((u16*)data_ptr) = (u16)isrv.v0;
-				break;
-			case 4:
-				*((u32*)data_ptr) = (u32)isrv.v0;
-				break;
-			case 8:
-				*((u64*)data_ptr) = (u64)isrv.v0;
-				break;
-			default:
-				isrv.status = 2;	
-		}
-	}
-
-	return isrv.status;
-}
diff -Nru a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
--- a/arch/ia64/sn/kernel/setup.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ia64/sn/kernel/setup.c	2004-12-24 13:36:31 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1999,2001-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1999,2001-2004 Silicon Graphics, Inc. All rights reserved.
  */
 
 #include <linux/config.h>
@@ -34,65 +34,59 @@
 #include <asm/machvec.h>
 #include <asm/system.h>
 #include <asm/processor.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
 #include <asm/sn/arch.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/pda.h>
 #include <asm/sn/nodepda.h>
 #include <asm/sn/sn_cpuid.h>
-#include <asm/sn/sn_private.h>
 #include <asm/sn/simulator.h>
+#include "shub.h"
 #include <asm/sn/leds.h>
 #include <asm/sn/bte.h>
+#include <asm/sn/shub_mmr.h>
 #include <asm/sn/clksupport.h>
 #include <asm/sn/sn_sal.h>
-#include <asm/sn/sn2/shub.h>
+#include <asm/sn/geo.h>
+#include "xtalk/xwidgetdev.h"
+#include "xtalk/hubdev.h"
+#include <asm/sn/klconfig.h>
+
 
 DEFINE_PER_CPU(struct pda_s, pda_percpu);
 
-#define MAX_PHYS_MEMORY		(1UL << 49)     /* 1 TB */
+#define MAX_PHYS_MEMORY		(1UL << 49)	/* 1 TB */
+
+lboard_t *root_lboard[MAX_COMPACT_NODES];
+
+extern void bte_init_node(nodepda_t *, cnodeid_t);
 
-extern void bte_init_node (nodepda_t *, cnodeid_t);
 extern void sn_timer_init(void);
 extern unsigned long last_time_offset;
-extern void init_platform_hubinfo(nodepda_t **nodepdaindr);
-extern void (*ia64_mark_idle)(int);
+extern void (*ia64_mark_idle) (int);
 extern void snidle(int);
 extern unsigned char acpi_kbd_controller_present;
 
-
-unsigned long sn_rtc_cycles_per_second;   
+unsigned long sn_rtc_cycles_per_second;
 
 EXPORT_SYMBOL(sn_rtc_cycles_per_second);
 
 partid_t sn_partid = -1;
+EXPORT_SYMBOL(sn_partid);
 char sn_system_serial_number_string[128];
+EXPORT_SYMBOL(sn_system_serial_number_string);
 u64 sn_partition_serial_number;
+EXPORT_SYMBOL(sn_partition_serial_number);
 
 short physical_node_map[MAX_PHYSNODE_ID];
 
 EXPORT_SYMBOL(physical_node_map);
 
-int	numionodes;
-/*
- * This is the address of the RRegs in the HSpace of the global
- * master.  It is used by a hack in serial.c (serial_[in|out],
- * printk.c (early_printk), and kdb_io.c to put console output on that
- * node's Bedrock UART.  It is initialized here to 0, so that
- * early_printk won't try to access the UART before
- * master_node_bedrock_address is properly calculated.
- */
-u64 master_node_bedrock_address;
+int numionodes;
 
 static void sn_init_pdas(char **);
 static void scan_for_ionodes(void);
 
-
-static nodepda_t	*nodepdaindr[MAX_COMPACT_NODES];
-
-irqpda_t		*irqpdaindr;
-
+static nodepda_t *nodepdaindr[MAX_COMPACT_NODES];
 
 /*
  * The format of "screen_info" is strange, and due to early i386-setup
@@ -100,14 +94,14 @@
  * VGA color display.
  */
 struct screen_info sn_screen_info = {
-	.orig_x			= 0,
-	.orig_y			= 0,
-	.orig_video_mode	= 3,
-	.orig_video_cols	= 80,
-	.orig_video_ega_bx	= 3,
-	.orig_video_lines	= 25,
-	.orig_video_isVGA	= 1,
-	.orig_video_points	= 16
+	.orig_x = 0,
+	.orig_y = 0,
+	.orig_video_mode = 3,
+	.orig_video_cols = 80,
+	.orig_video_ega_bx = 3,
+	.orig_video_lines = 25,
+	.orig_video_isVGA = 1,
+	.orig_video_points = 16
 };
 
 /*
@@ -119,12 +113,25 @@
  * is sufficient (the IDE driver will autodetect the drive geometry).
  */
 #ifdef CONFIG_IA64_GENERIC
-extern char drive_info[4*16];
+extern char drive_info[4 * 16];
 #else
-char drive_info[4*16];
+char drive_info[4 * 16];
 #endif
 
 /*
+ * Get nasid of current cpu early in boot before nodepda is initialized
+ */
+static int
+boot_get_nasid(void)
+{
+	int nasid;
+
+	if (ia64_sn_get_sapic_info(get_sapicid(), &nasid, NULL, NULL))
+		BUG();
+	return nasid;
+}
+
+/*
  * This routine can only be used during init, since
  * smp_boot_data is an init data structure.
  * We have to use smp_boot_data.cpu_phys_id to find
@@ -133,8 +140,7 @@
  * may not be initialized yet.
  */
 
-static int __init
-pxm_to_nasid(int pxm)
+static int __init pxm_to_nasid(int pxm)
 {
 	int i;
 	int nid;
@@ -147,6 +153,7 @@
 	}
 	return -1;
 }
+
 /**
  * early_sn_setup - early setup routine for SN platforms
  *
@@ -154,16 +161,15 @@
  * for bringup.  See start_kernel() in init/main.c.
  */
 
-void __init
-early_sn_setup(void)
+void __init early_sn_setup(void)
 {
-	void ia64_sal_handler_init (void *entry_point, void *gpval);
-	efi_system_table_t			*efi_systab;
-	efi_config_table_t 			*config_tables;
-	struct ia64_sal_systab			*sal_systab;
-	struct ia64_sal_desc_entry_point	*ep;
-	char					*p;
-	int					i;
+	void ia64_sal_handler_init(void *entry_point, void *gpval);
+	efi_system_table_t *efi_systab;
+	efi_config_table_t *config_tables;
+	struct ia64_sal_systab *sal_systab;
+	struct ia64_sal_desc_entry_point *ep;
+	char *p;
+	int i;
 
 	/*
 	 * Parse enough of the SAL tables to locate the SAL entry point. Since, console
@@ -172,82 +178,58 @@
 	 * This code duplicates some of the ACPI table parsing that is in efi.c & sal.c.
 	 * Any changes to those file may have to be made hereas well.
 	 */
-	efi_systab = (efi_system_table_t*)__va(ia64_boot_param->efi_systab);
+	efi_systab = (efi_system_table_t *) __va(ia64_boot_param->efi_systab);
 	config_tables = __va(efi_systab->tables);
 	for (i = 0; i < efi_systab->nr_tables; i++) {
-		if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) == 0) {
+		if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) ==
+		    0) {
 			sal_systab = __va(config_tables[i].table);
-			p = (char*)(sal_systab+1);
+			p = (char *)(sal_systab + 1);
 			for (i = 0; i < sal_systab->entry_count; i++) {
 				if (*p == SAL_DESC_ENTRY_POINT) {
-					ep = (struct ia64_sal_desc_entry_point *) p;
-					ia64_sal_handler_init(__va(ep->sal_proc), __va(ep->gp));
+					ep = (struct ia64_sal_desc_entry_point
+					      *)p;
+					ia64_sal_handler_init(__va
+							      (ep->sal_proc),
+							      __va(ep->gp));
 					break;
 				}
 				p += SAL_DESC_SIZE(*p);
 			}
 		}
 	}
-
-	if ( IS_RUNNING_ON_SIMULATOR() ) {
-		master_node_bedrock_address = (u64)REMOTE_HUB(get_nasid(), SH_JUNK_BUS_UART0);
-		printk(KERN_DEBUG "early_sn_setup: setting master_node_bedrock_address to 0x%lx\n", master_node_bedrock_address);
-	}
 }
 
 extern int platform_intr_list[];
 extern nasid_t master_nasid;
 static int shub_1_1_found __initdata;
 
-
 /*
  * sn_check_for_wars
  *
  * Set flag for enabling shub specific wars
  */
 
-static inline int __init
-is_shub_1_1(int nasid)
+static inline int __init is_shub_1_1(int nasid)
 {
 	unsigned long id;
-	int	rev;
+	int rev;
 
 	id = REMOTE_HUB_L(nasid, SH_SHUB_ID);
-	rev =  (id & SH_SHUB_ID_REVISION_MASK) >> SH_SHUB_ID_REVISION_SHFT;
+	rev = (id & SH_SHUB_ID_REVISION_MASK) >> SH_SHUB_ID_REVISION_SHFT;
 	return rev <= 2;
 }
 
-static void __init
-sn_check_for_wars(void)
+static void __init sn_check_for_wars(void)
 {
-	int	cnode;
+	int cnode;
 
-	for (cnode=0; cnode< numnodes; cnode++)
+	for (cnode = 0; cnode < numnodes; cnode++)
 		if (is_shub_1_1(cnodeid_to_nasid(cnode)))
 			shub_1_1_found = 1;
 }
 
 /**
- * sn_set_error_handling_features - Tell the SN prom how to handle certain
- * error types.
- */
-static void __init
-sn_set_error_handling_features(void)
-{
-	u64 ret;
-	u64 sn_ehf_bits[7];	/* see ia64_sn_set_error_handling_features */
-	memset(sn_ehf_bits, 0, sizeof(sn_ehf_bits));
-#define EHF(x) __set_bit(SN_SAL_EHF_ ## x, sn_ehf_bits)
-	EHF(MCA_SLV_TO_OS_INIT_SLV);
-	EHF(NO_RZ_TLBC);
-	// Uncomment once Jesse's code goes in - EHF(NO_RZ_IO_READ); 
-#undef	EHF
-	ret = ia64_sn_set_error_handling_features(sn_ehf_bits);
-	if (ret)
-		printk(KERN_ERR "%s: failed, return code %ld\n", __FUNCTION__, ret);
-}
-
-/**
  * sn_setup - SN platform setup routine
  * @cmdline_p: kernel command line
  *
@@ -255,15 +237,12 @@
  * the RTC frequency (via a SAL call), initializing secondary CPUs, and
  * setting up per-node data areas.  The console is also initialized here.
  */
-void __init
-sn_setup(char **cmdline_p)
+void __init sn_setup(char **cmdline_p)
 {
 	long status, ticks_per_sec, drift;
 	int pxm;
 	int major = sn_sal_rev_major(), minor = sn_sal_rev_minor();
-	extern nasid_t snia_get_master_baseio_nasid(void);
 	extern void sn_cpu_init(void);
-	extern nasid_t snia_get_console_nasid(void);
 
 	/*
 	 * If the generic code has enabled vga console support - lets
@@ -278,17 +257,17 @@
 		conswitchp = &dummy_con;
 #else
 		conswitchp = NULL;
-#endif /* CONFIG_DUMMY_CONSOLE */
+#endif				/* CONFIG_DUMMY_CONSOLE */
 	}
-#endif /* def(CONFIG_VT) && def(CONFIG_VGA_CONSOLE) */
+#endif				/* def(CONFIG_VT) && def(CONFIG_VGA_CONSOLE) */
 
 	MAX_DMA_ADDRESS = PAGE_OFFSET + MAX_PHYS_MEMORY;
 
 	memset(physical_node_map, -1, sizeof(physical_node_map));
-	for (pxm=0; pxm<MAX_PXM_DOMAINS; pxm++)
+	for (pxm = 0; pxm < MAX_PXM_DOMAINS; pxm++)
 		if (pxm_to_nid_map[pxm] != -1)
-			physical_node_map[pxm_to_nasid(pxm)] = pxm_to_nid_map[pxm];
-
+			physical_node_map[pxm_to_nasid(pxm)] =
+			    pxm_to_nid_map[pxm];
 
 	/*
 	 * Old PROMs do not provide an ACPI FADT. Disable legacy keyboard
@@ -314,32 +293,21 @@
 		panic("PROM version too old\n");
 	}
 
-	master_nasid = get_nasid();
-	(void)snia_get_console_nasid();
-	(void)snia_get_master_baseio_nasid();
+	master_nasid = boot_get_nasid();
 
-	status = ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec, &drift);
+	status =
+	    ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec,
+			       &drift);
 	if (status != 0 || ticks_per_sec < 100000) {
-		printk(KERN_WARNING "unable to determine platform RTC clock frequency, guessing.\n");
+		printk(KERN_WARNING
+		       "unable to determine platform RTC clock frequency, guessing.\n");
 		/* PROM gives wrong value for clock freq. so guess */
-		sn_rtc_cycles_per_second = 1000000000000UL/30000UL;
-	}
-	else
+		sn_rtc_cycles_per_second = 1000000000000UL / 30000UL;
+	} else
 		sn_rtc_cycles_per_second = ticks_per_sec;
 
 	platform_intr_list[ACPI_INTERRUPT_CPEI] = IA64_CPE_VECTOR;
 
-
-	if ( IS_RUNNING_ON_SIMULATOR() )
-	{
-		master_node_bedrock_address = (u64)REMOTE_HUB(get_nasid(), SH_JUNK_BUS_UART0);
-		printk(KERN_DEBUG "sn_setup: setting master_node_bedrock_address to 0x%lx\n",
-		       master_node_bedrock_address);
-	}
-
-	/* Tell the prom how to handle certain error types */
-	sn_set_error_handling_features();
-
 	/*
 	 * we set the default root device to /dev/hda
 	 * to make simulation easy
@@ -359,12 +327,6 @@
 	 */
 	sn_cpu_init();
 
-	/*
-	 * Setup hubinfo stuff. Has to happen AFTER sn_cpu_init(),
-	 * because it uses the cnode to nasid tables.
-	 */
-	init_platform_hubinfo(nodepdaindr);
-
 #ifdef CONFIG_SMP
 	init_smp_config();
 #endif
@@ -378,32 +340,45 @@
  *
  * One time setup for Node Data Area.  Called by sn_setup().
  */
-void __init
-sn_init_pdas(char **cmdline_p)
+void __init sn_init_pdas(char **cmdline_p)
 {
-	cnodeid_t	cnode;
+	cnodeid_t cnode;
 
-	memset(pda->cnodeid_to_nasid_table, -1, sizeof(pda->cnodeid_to_nasid_table));
-	for (cnode=0; cnode<numnodes; cnode++)
-		pda->cnodeid_to_nasid_table[cnode] = pxm_to_nasid(nid_to_pxm_map[cnode]);
+	memset(pda->cnodeid_to_nasid_table, -1,
+	       sizeof(pda->cnodeid_to_nasid_table));
+	for (cnode = 0; cnode < numnodes; cnode++)
+		pda->cnodeid_to_nasid_table[cnode] =
+		    pxm_to_nasid(nid_to_pxm_map[cnode]);
 
 	numionodes = numnodes;
 	scan_for_ionodes();
 
-        /*
-         * Allocate & initalize the nodepda for each node.
-         */
-        for (cnode=0; cnode < numnodes; cnode++) {
-		nodepdaindr[cnode] = alloc_bootmem_node(NODE_DATA(cnode), sizeof(nodepda_t));
+	/*
+	 * Allocate & initalize the nodepda for each node.
+	 */
+	for (cnode = 0; cnode < numnodes; cnode++) {
+		nodepdaindr[cnode] =
+		    alloc_bootmem_node(NODE_DATA(cnode), sizeof(nodepda_t));
 		memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));
-        }
+		memset(nodepdaindr[cnode]->phys_cpuid, -1, 
+		    sizeof(nodepdaindr[cnode]->phys_cpuid));
+	}
 
 	/*
-	 * Now copy the array of nodepda pointers to each nodepda.
+	 * Allocate & initialize nodepda for TIOs.  For now, put them on node 0.
 	 */
-        for (cnode=0; cnode < numionodes; cnode++)
-		memcpy(nodepdaindr[cnode]->pernode_pdaindr, nodepdaindr, sizeof(nodepdaindr));
+	for (cnode = numnodes; cnode < numionodes; cnode++) {
+		nodepdaindr[cnode] =
+		    alloc_bootmem_node(NODE_DATA(0), sizeof(nodepda_t));
+		memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));
+	}
 
+	/*
+	 * Now copy the array of nodepda pointers to each nodepda.
+	 */
+	for (cnode = 0; cnode < numionodes; cnode++)
+		memcpy(nodepdaindr[cnode]->pernode_pdaindr, nodepdaindr,
+		       sizeof(nodepdaindr));
 
 	/*
 	 * Set up IO related platform-dependent nodepda fields.
@@ -411,8 +386,15 @@
 	 * in nodepda.
 	 */
 	for (cnode = 0; cnode < numnodes; cnode++) {
-		init_platform_nodepda(nodepdaindr[cnode], cnode);
-		bte_init_node (nodepdaindr[cnode], cnode);
+		bte_init_node(nodepdaindr[cnode], cnode);
+	}
+
+	/*
+	 * Initialize the per node hubdev.  This includes IO Nodes and 
+	 * headless/memless nodes.
+	 */
+	for (cnode = 0; cnode < numionodes; cnode++) {
+		hubdev_init_node(nodepdaindr[cnode], cnode);
 	}
 }
 
@@ -425,15 +407,16 @@
  * Also sets up a few fields in the nodepda.  Also known as
  * platform_cpu_init() by the ia64 machvec code.
  */
-void __init
-sn_cpu_init(void)
+void __init sn_cpu_init(void)
 {
-	int	cpuid;
-	int	cpuphyid;
-	int	nasid;
-	int	slice;
-	int	cnode;
-	static int	wars_have_been_checked;
+	int cpuid;
+	int cpuphyid;
+	int nasid;
+	int subnode;
+	int slice;
+	int cnode;
+	int i;
+	static int wars_have_been_checked;
 
 	/*
 	 * The boot cpu makes this call again after platform initialization is
@@ -443,22 +426,34 @@
 		return;
 
 	cpuid = smp_processor_id();
-	cpuphyid = ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff);
-	nasid = cpu_physical_id_to_nasid(cpuphyid);
+	cpuphyid = get_sapicid();
+
+	if (ia64_sn_get_sapic_info(cpuphyid, &nasid, &subnode, &slice))
+		BUG();
+
+	for (i=0; i < NR_NODES; i++) {
+		if (nodepdaindr[i]) {
+			nodepdaindr[i]->phys_cpuid[cpuid].nasid = nasid;
+			nodepdaindr[i]->phys_cpuid[cpuid].slice = slice;
+			nodepdaindr[i]->phys_cpuid[cpuid].subnode = subnode;
+		}
+	}
+
 	cnode = nasid_to_cnodeid(nasid);
-	slice = cpu_physical_id_to_slice(cpuphyid);
 
 	memset(pda, 0, sizeof(pda));
 	pda->p_nodepda = nodepdaindr[cnode];
-	pda->led_address = (typeof(pda->led_address)) (LED0 + (slice<<LED_CPU_SHIFT));
+	pda->led_address =
+	    (typeof(pda->led_address)) (LED0 + (slice << LED_CPU_SHIFT));
 	pda->led_state = LED_ALWAYS_SET;
-	pda->hb_count = HZ/2;
+	pda->hb_count = HZ / 2;
 	pda->hb_state = 0;
 	pda->idle_flag = 0;
 
-	if (cpuid != 0){
-		memcpy(pda->cnodeid_to_nasid_table, pdacpu(0)->cnodeid_to_nasid_table,
-				sizeof(pda->cnodeid_to_nasid_table));
+	if (cpuid != 0) {
+		memcpy(pda->cnodeid_to_nasid_table,
+		       pdacpu(0)->cnodeid_to_nasid_table,
+		       sizeof(pda->cnodeid_to_nasid_table));
 	}
 
 	/*
@@ -472,30 +467,27 @@
 		wars_have_been_checked = 1;
 	}
 	pda->shub_1_1_found = shub_1_1_found;
-	
 
 	/*
 	 * We must use different memory allocators for first cpu (bootmem 
 	 * allocator) than for the other cpus (regular allocator).
 	 */
-	if (cpuid == 0)
-		irqpdaindr = alloc_bootmem_node(NODE_DATA(cpuid_to_cnodeid(cpuid)),sizeof(irqpda_t));
-
-	memset(irqpdaindr, 0, sizeof(irqpda_t));
-	irqpdaindr->irq_flags[SGI_PCIBR_ERROR] = SN2_IRQ_SHARED;
-	irqpdaindr->irq_flags[SGI_PCIBR_ERROR] |= SN2_IRQ_RESERVED;
-	irqpdaindr->irq_flags[SGI_II_ERROR] = SN2_IRQ_SHARED;
-	irqpdaindr->irq_flags[SGI_II_ERROR] |= SN2_IRQ_RESERVED;
-
 	pda->pio_write_status_addr = (volatile unsigned long *)
-			LOCAL_MMR_ADDR((slice < 2 ? SH_PIO_WRITE_STATUS_0 : SH_PIO_WRITE_STATUS_1 ) );
+	    LOCAL_MMR_ADDR((slice <
+			    2 ? SH_PIO_WRITE_STATUS_0 : SH_PIO_WRITE_STATUS_1));
 	pda->mem_write_status_addr = (volatile u64 *)
-			LOCAL_MMR_ADDR((slice < 2 ? SH_MEMORY_WRITE_STATUS_0 : SH_MEMORY_WRITE_STATUS_1 ) );
+	    LOCAL_MMR_ADDR((slice <
+			    2 ? SH_MEMORY_WRITE_STATUS_0 :
+			    SH_MEMORY_WRITE_STATUS_1));
 
 	if (local_node_data->active_cpu_count++ == 0) {
-		int	buddy_nasid;
-		buddy_nasid = cnodeid_to_nasid(numa_node_id() == numnodes-1 ? 0 : numa_node_id()+ 1);
-		pda->pio_shub_war_cam_addr = (volatile unsigned long*)GLOBAL_MMR_ADDR(nasid, SH_PI_CAM_CONTROL);
+		int buddy_nasid;
+		buddy_nasid =
+		    cnodeid_to_nasid(numa_node_id() ==
+				     numnodes - 1 ? 0 : numa_node_id() + 1);
+		pda->pio_shub_war_cam_addr =
+		    (volatile unsigned long *)GLOBAL_MMR_ADDR(nasid,
+							      SH_PI_CAM_CONTROL);
 	}
 }
 
@@ -504,48 +496,53 @@
  * physical_node_map and the pda and increment numionodes.
  */
 
-static void __init
-scan_for_ionodes(void)
+static void __init scan_for_ionodes(void)
 {
 	int nasid = 0;
 	lboard_t *brd;
 
 	/* Setup ionodes with memory */
-	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid +=2) {
+	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
 		u64 klgraph_header;
 		cnodeid_t cnodeid;
 
-		if (physical_node_map[nasid] == -1) 
+		if (physical_node_map[nasid] == -1)
 			continue;
 
 		klgraph_header = cnodeid = -1;
 		klgraph_header = ia64_sn_get_klconfig_addr(nasid);
 		if (klgraph_header <= 0) {
-			if ( IS_RUNNING_ON_SIMULATOR() )
+			if (IS_RUNNING_ON_SIMULATOR())
 				continue;
-			BUG(); /* All nodes must have klconfig tables! */
+			BUG();	/* All nodes must have klconfig tables! */
 		}
 		cnodeid = nasid_to_cnodeid(nasid);
 		root_lboard[cnodeid] = (lboard_t *)
-					NODE_OFFSET_TO_LBOARD( (nasid),
-					((kl_config_hdr_t *)(klgraph_header))->
-					ch_board_info);
+		    NODE_OFFSET_TO_LBOARD((nasid),
+					  ((kl_config_hdr_t
+					    *) (klgraph_header))->
+					  ch_board_info);
 	}
 
 	/* Scan headless/memless IO Nodes. */
-	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid +=2) {
+	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
 		/* if there's no nasid, don't try to read the klconfig on the node */
-		if (physical_node_map[nasid] == -1) continue;
-		brd = find_lboard_any((lboard_t *)root_lboard[nasid_to_cnodeid(nasid)], KLTYPE_SNIA);
+		if (physical_node_map[nasid] == -1)
+			continue;
+		brd = find_lboard_any((lboard_t *)
+				      root_lboard[nasid_to_cnodeid(nasid)],
+				      KLTYPE_SNIA);
 		if (brd) {
-			brd = KLCF_NEXT_ANY(brd); /* Skip this node's lboard */
+			brd = KLCF_NEXT_ANY(brd);	/* Skip this node's lboard */
 			if (!brd)
 				continue;
 		}
 
 		brd = find_lboard_any(brd, KLTYPE_SNIA);
+
 		while (brd) {
-			pda->cnodeid_to_nasid_table[numionodes] = brd->brd_nasid;
+			pda->cnodeid_to_nasid_table[numionodes] =
+			    brd->brd_nasid;
 			physical_node_map[brd->brd_nasid] = numionodes;
 			root_lboard[numionodes] = brd;
 			numionodes++;
@@ -556,4 +553,39 @@
 			brd = find_lboard_any(brd, KLTYPE_SNIA);
 		}
 	}
+
+	/* Scan for TIO nodes. */
+	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
+		/* if there's no nasid, don't try to read the klconfig on the node */
+		if (physical_node_map[nasid] == -1)
+			continue;
+		brd = find_lboard_any((lboard_t *)
+				      root_lboard[nasid_to_cnodeid(nasid)],
+				      KLTYPE_TIO);
+		while (brd) {
+			pda->cnodeid_to_nasid_table[numionodes] =
+			    brd->brd_nasid;
+			physical_node_map[brd->brd_nasid] = numionodes;
+			root_lboard[numionodes] = brd;
+			numionodes++;
+			brd = KLCF_NEXT_ANY(brd);
+			if (!brd)
+				break;
+
+			brd = find_lboard_any(brd, KLTYPE_TIO);
+		}
+	}
+
+}
+
+int
+nasid_slice_to_cpuid(int nasid, int slice)
+{
+	long cpu;
+	
+	for (cpu=0; cpu < NR_CPUS; cpu++) 
+		if (nodepda->phys_cpuid[cpu].nasid == nasid && nodepda->phys_cpuid[cpu].slice == slice)
+			return cpu;
+
+	return -1;
 }
diff -Nru a/arch/ia64/sn/kernel/sn2/io.c b/arch/ia64/sn/kernel/sn2/io.c
--- a/arch/ia64/sn/kernel/sn2/io.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ia64/sn/kernel/sn2/io.c	2004-12-24 13:37:19 -08:00
@@ -9,7 +9,7 @@
  * we wrap the inlines from asm/ia64/sn/sn2/io.h here.
  */
 
-#include <asm/sn/sn2/io.h>
+#include <asm/sn/io.h>
 
 #ifdef CONFIG_IA64_GENERIC
 
@@ -28,88 +28,74 @@
 #undef __sn_readl_relaxed
 #undef __sn_readq_relaxed
 
-unsigned int
-__sn_inb (unsigned long port)
+unsigned int __sn_inb(unsigned long port)
 {
 	return ___sn_inb(port);
 }
 
-unsigned int
-__sn_inw (unsigned long port)
+unsigned int __sn_inw(unsigned long port)
 {
 	return ___sn_inw(port);
 }
 
-unsigned int
-__sn_inl (unsigned long port)
+unsigned int __sn_inl(unsigned long port)
 {
 	return ___sn_inl(port);
 }
 
-void
-__sn_outb (unsigned char val, unsigned long port)
+void __sn_outb(unsigned char val, unsigned long port)
 {
 	___sn_outb(val, port);
 }
 
-void
-__sn_outw (unsigned short val, unsigned long port)
+void __sn_outw(unsigned short val, unsigned long port)
 {
 	___sn_outw(val, port);
 }
 
-void
-__sn_outl (unsigned int val, unsigned long port)
+void __sn_outl(unsigned int val, unsigned long port)
 {
 	___sn_outl(val, port);
 }
 
-unsigned char
-__sn_readb (void *addr)
+unsigned char __sn_readb(void __iomem *addr)
 {
-	return ___sn_readb (addr);
+	return ___sn_readb(addr);
 }
 
-unsigned short
-__sn_readw (void *addr)
+unsigned short __sn_readw(void __iomem *addr)
 {
-	return ___sn_readw (addr);
+	return ___sn_readw(addr);
 }
 
-unsigned int
-__sn_readl (void *addr)
+unsigned int __sn_readl(void __iomem *addr)
 {
-	return ___sn_readl (addr);
+	return ___sn_readl(addr);
 }
 
-unsigned long
-__sn_readq (void *addr)
+unsigned long __sn_readq(void __iomem *addr)
 {
-	return ___sn_readq (addr);
+	return ___sn_readq(addr);
 }
 
-unsigned char
-__sn_readb_relaxed (void *addr)
+unsigned char __sn_readb_relaxed(void __iomem *addr)
 {
-	return ___sn_readb_relaxed (addr);
+	return ___sn_readb_relaxed(addr);
 }
 
-unsigned short
-__sn_readw_relaxed (void *addr)
+unsigned short __sn_readw_relaxed(void __iomem *addr)
 {
-	return ___sn_readw_relaxed (addr);
+	return ___sn_readw_relaxed(addr);
 }
 
-unsigned int
-__sn_readl_relaxed (void *addr)
+unsigned int __sn_readl_relaxed(void __iomem *addr)
 {
-	return ___sn_readl_relaxed (addr);
+	return ___sn_readl_relaxed(addr);
 }
 
-unsigned long
-__sn_readq_relaxed (void *addr)
+unsigned long __sn_readq_relaxed(void __iomem *addr)
 {
-	return ___sn_readq_relaxed (addr);
+	return ___sn_readq_relaxed(addr);
 }
 
 #endif
diff -Nru a/arch/ia64/sn/kernel/sn2/prominfo_proc.c b/arch/ia64/sn/kernel/sn2/prominfo_proc.c
--- a/arch/ia64/sn/kernel/sn2/prominfo_proc.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ia64/sn/kernel/sn2/prominfo_proc.c	2004-12-24 13:36:31 -08:00
@@ -16,7 +16,7 @@
 #include <asm/io.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/sn_cpuid.h>
-#include <asm/sn/sn2/addrs.h>
+#include <asm/sn/addrs.h>
 
 MODULE_DESCRIPTION("PROM version reporting for /proc");
 MODULE_AUTHOR("Chad Talbott");
@@ -55,30 +55,29 @@
 	((unsigned) ((q) >> FIT_TYPE_SHIFT) & FIT_TYPE_MASK)
 
 struct fit_type_map_t {
-	unsigned char	type;
-	const char	*name;
+	unsigned char type;
+	const char *name;
 };
 
 static const struct fit_type_map_t fit_entry_types[] = {
-	{ FIT_ENTRY_FIT_HEADER, "FIT Header" },
-	{ FIT_ENTRY_PAL_A_GEN,  "Generic PAL_A" },
-	{ FIT_ENTRY_PAL_A_PROC, "Processor-specific PAL_A" },
-	{ FIT_ENTRY_PAL_A,      "PAL_A" },
-	{ FIT_ENTRY_PAL_B,      "PAL_B" },
-	{ FIT_ENTRY_SAL_A,      "SAL_A" },
-	{ FIT_ENTRY_SAL_B,      "SAL_B" },
-	{ FIT_ENTRY_SALRUNTIME, "SAL runtime" },
-	{ FIT_ENTRY_EFI,	"EFI" },
-	{ FIT_ENTRY_VMLINUX,    "Embedded Linux" },
-	{ FIT_ENTRY_FPSWA,      "Embedded FPSWA" },
-	{ FIT_ENTRY_UNUSED,     "Unused" },
-	{ 0xff,                 "Error" },
+	{FIT_ENTRY_FIT_HEADER, "FIT Header"},
+	{FIT_ENTRY_PAL_A_GEN, "Generic PAL_A"},
+	{FIT_ENTRY_PAL_A_PROC, "Processor-specific PAL_A"},
+	{FIT_ENTRY_PAL_A, "PAL_A"},
+	{FIT_ENTRY_PAL_B, "PAL_B"},
+	{FIT_ENTRY_SAL_A, "SAL_A"},
+	{FIT_ENTRY_SAL_B, "SAL_B"},
+	{FIT_ENTRY_SALRUNTIME, "SAL runtime"},
+	{FIT_ENTRY_EFI, "EFI"},
+	{FIT_ENTRY_VMLINUX, "Embedded Linux"},
+	{FIT_ENTRY_FPSWA, "Embedded FPSWA"},
+	{FIT_ENTRY_UNUSED, "Unused"},
+	{0xff, "Error"},
 };
 
-static const char *
-fit_type_name(unsigned char type)
+static const char *fit_type_name(unsigned char type)
 {
-	struct fit_type_map_t const*mapp;
+	struct fit_type_map_t const *mapp;
 
 	for (mapp = fit_entry_types; mapp->type != 0xff; mapp++)
 		if (type == mapp->type)
@@ -92,132 +91,18 @@
 	return "Unknown type";
 }
 
-
-/* ============ BEGIN temp til old PROMs are no longer supported =============
- *
- * The OS should not make direct access to the PROM flash memory. Access to
- * this region must be serialized with a PROM lock. If SAL on one cpu is
- * updating the FLASH error log at the same time another cpu is accessing the
- * PROM, data corruption will occur.
- *
- * To solve the problem, all flash PROM access has been moved to SAL. Because
- * not all systems will have instant PROM updates, we need to support a new OS
- * running on a system with old PROMs.
- *
- * This code should be deleted after 1 OS/PROM release has occurred & the OS
- * no longer supports downrev PROMs. (PROM support should be in the 3.50
- * PROMs).
- */
-#define SUPPORT_OLD_PROMS
-#ifdef SUPPORT_OLD_PROMS
-
-
-#define FIT_SIGNATURE		0x2020205f5449465ful
-
-/* Sub-regions determined by bits in Node Offset */
-#define	LB_PROM_SPACE		0x0000000700000000ul /* Local LB PROM */
-
-/* Offset of PROM banner pointers in SAL A and SAL B */
-#define SAL_A_BANNER_OFFSET	(1 * 16)
-#define SAL_B_BANNER_OFFSET	(3 * 16)
-
-/* Architected IA64 firmware space */
-#define FW_BASE                 0x00000000FF000000
-#define FW_TOP                  0x0000000100000000
-
-static unsigned long
-convert_fw_addr(nasid_t nasid, unsigned long addr)
-{
-	/* snag just the node-relative offset */
-	addr &= ~0ul >> (63-35);
-	/* the pointer to SAL A is relative to IA-64 compatibility
-	 * space.  However, the PROM is mapped at a different offset
-	 * in MMR space (both local and global)
-	 */
-	addr += 0x700000000;
-	return GLOBAL_MMR_ADDR(nasid, addr);
-}
-
-static int
-valid_fw_addr(unsigned long addr)
-{
-	addr &= ~(1ul << 63); /* Clear cached/uncached bit */
-	return (addr >= FW_BASE && addr < FW_TOP);
-}
-
-static unsigned long *
-lookup_fit(int nasid)
-{
-	unsigned long *fitp;
-	unsigned long fit_paddr;
-	unsigned long *fit_vaddr;
-
-	fitp = (void *)GLOBAL_MMR_ADDR(nasid, LB_PROM_SPACE - 32);
-	fit_paddr = readq(fitp);
-	fit_vaddr = (unsigned long *) convert_fw_addr(nasid, fit_paddr);
-	return fit_vaddr;
-}
-#endif /* SUPPORT_OLD_PROMS */
-/* ============ END temp til old PROMs are no longer supported ============= */
-
 static int
 get_fit_entry(unsigned long nasid, int index, unsigned long *fentry,
 	      char *banner, int banlen)
 {
-	int ret;
-
-	ret = ia64_sn_get_fit_compt(nasid, index, fentry, banner, banlen);
-
-#ifdef SUPPORT_OLD_PROMS
-	/* The following is hack is temporary until PROMs are updated */
-	if (ret == SALRET_NOT_IMPLEMENTED) {
-		unsigned long *fitadr = lookup_fit(nasid);
-		int nentries;
-
-		if (readq(fitadr) != FIT_SIGNATURE) {
-			printk(KERN_WARNING "Unrecognized FIT signature");
-			return -2;
-		}
-
-		nentries = (unsigned int) (readq(fitadr + 1) & 0xffffff);
-		if (index >= nentries)
-			return -2;
-
-		fentry[0] = readq(fitadr + 2 * index);
-		fentry[1] = readq(fitadr + 2 * index + 1);
-		ret = 0;
-
-		if (banner && FIT_TYPE(fentry[1]) == FIT_ENTRY_SAL_A) {
-			unsigned long i, qw, *bwp, *qwp;
-
-			banner[0] = '\0';
-			qw = fentry[0];	/* Address of SAL A */
-			if (!valid_fw_addr(qw))
-				return 0;
-
-			qw += SAL_A_BANNER_OFFSET;
-			qw = convert_fw_addr(nasid, qw);
-
-			qw = readq(qw);			/* Address of banner */
-			if (!valid_fw_addr(qw))
-				return 0;
-			qw = convert_fw_addr(nasid, qw);
-			qwp = (unsigned long *) qw;
-			bwp = (unsigned long *) banner;
-			for (i=0; i<banlen/8; i++)
-				bwp[i] = qwp[i];
-		}
-	}
-#endif /* SUPPORT_OLD_PROMS */
-	return ret;
+	return ia64_sn_get_fit_compt(nasid, index, fentry, banner, banlen);
 }
 
 
 /*
  * These two routines display the FIT table for each node.
  */
-static int
-dump_fit_entry(char *page, unsigned long *fentry)
+static int dump_fit_entry(char *page, unsigned long *fentry)
 {
 	unsigned type;
 
@@ -289,11 +174,14 @@
 proc_calc_metrics(char *page, char **start, off_t off, int count, int *eof,
 		  int len)
 {
-	if (len <= off+count) *eof = 1;
+	if (len <= off + count)
+		*eof = 1;
 	*start = page + off;
 	len -= off;
-	if (len>count) len = count;
-	if (len<0) len = 0;
+	if (len > count)
+		len = count;
+	if (len < 0)
+		len = 0;
 	return len;
 }
 
@@ -334,8 +222,7 @@
 
 #define NODE_NAME_LEN 11
 
-int __init
-prominfo_init(void)
+int __init prominfo_init(void)
 {
 	struct proc_dir_entry **entp;
 	struct proc_dir_entry *p;
@@ -372,16 +259,14 @@
 	return 0;
 }
 
-void __exit
-prominfo_exit(void)
+void __exit prominfo_exit(void)
 {
 	struct proc_dir_entry **entp;
 	unsigned cnodeid;
 	char name[NODE_NAME_LEN];
 
 	for (cnodeid = 0, entp = proc_entries;
-	     cnodeid < numnodes;
-	     cnodeid++, entp++) {
+	     cnodeid < numnodes; cnodeid++, entp++) {
 		remove_proc_entry("fit", *entp);
 		remove_proc_entry("version", *entp);
 		sprintf(name, "node%d", cnodeid);
diff -Nru a/arch/ia64/sn/kernel/sn2/ptc_deadlock.S b/arch/ia64/sn/kernel/sn2/ptc_deadlock.S
--- a/arch/ia64/sn/kernel/sn2/ptc_deadlock.S	2004-12-24 13:37:29 -08:00
+++ b/arch/ia64/sn/kernel/sn2/ptc_deadlock.S	2004-12-24 13:37:29 -08:00
@@ -3,10 +3,10 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
 
-#include <asm/sn/sn2/shub_mmr.h>
+#include <asm/sn/shub_mmr.h>
 
 #define ZEROVAL		0x3f		// "zero" value for outstanding PIO requests
 #define DEADLOCKBIT	SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK_SHFT
diff -Nru a/arch/ia64/sn/kernel/sn2/sn2_smp.c b/arch/ia64/sn/kernel/sn2/sn2_smp.c
--- a/arch/ia64/sn/kernel/sn2/sn2_smp.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ia64/sn/kernel/sn2/sn2_smp.c	2004-12-24 13:37:19 -08:00
@@ -18,10 +18,10 @@
 #include <linux/irq.h>
 #include <linux/mmzone.h>
 #include <linux/module.h>
+#include <linux/bitops.h>
 
 #include <asm/processor.h>
 #include <asm/irq.h>
-#include <asm/sn/sgi.h>
 #include <asm/sal.h>
 #include <asm/system.h>
 #include <asm/delay.h>
@@ -29,46 +29,41 @@
 #include <asm/smp.h>
 #include <asm/tlb.h>
 #include <asm/numa.h>
-#include <asm/bitops.h>
 #include <asm/hw_irq.h>
 #include <asm/current.h>
 #include <asm/sn/sn_cpuid.h>
+#include <asm/sn/sn_sal.h>
 #include <asm/sn/addrs.h>
-#include <asm/sn/sn2/shub_mmr.h>
+#include <asm/sn/shub_mmr.h>
 #include <asm/sn/nodepda.h>
 #include <asm/sn/rw_mmr.h>
 
 void sn2_ptc_deadlock_recovery(unsigned long data0, unsigned long data1);
 
-
 static spinlock_t sn2_global_ptc_lock __cacheline_aligned = SPIN_LOCK_UNLOCKED;
 
 static unsigned long sn2_ptc_deadlock_count;
 
-
-static inline unsigned long
-wait_piowc(void)
+static inline unsigned long wait_piowc(void)
 {
 	volatile unsigned long *piows;
-	unsigned long	ws;
+	unsigned long ws;
 
 	piows = pda->pio_write_status_addr;
 	do {
 		ia64_mfa();
-	} while (((ws = *piows) & SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK) != 
-			SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK);
+	} while (((ws =
+		   *piows) & SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK) !=
+		 SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK);
 	return ws;
 }
 
-
-void
-sn_tlb_migrate_finish(struct mm_struct *mm)
+void sn_tlb_migrate_finish(struct mm_struct *mm)
 {
 	if (mm == current->mm)
 		flush_tlb_mm(mm);
 }
 
-
 /**
  * sn2_global_tlb_purge - globally purge translation cache of virtual address range
  * @start: start of virtual address range
@@ -90,13 +85,14 @@
  */
 
 void
-sn2_global_tlb_purge (unsigned long start, unsigned long end, unsigned long nbits)
+sn2_global_tlb_purge(unsigned long start, unsigned long end,
+		     unsigned long nbits)
 {
-	int			i, cnode, mynasid, cpu, lcpu=0, nasid, flushed=0;
-	volatile unsigned	long	*ptc0, *ptc1;
-	unsigned long		flags=0, data0, data1;
-	struct mm_struct	*mm=current->active_mm;
-	short			nasids[NR_NODES], nix;
+	int i, cnode, mynasid, cpu, lcpu = 0, nasid, flushed = 0;
+	volatile unsigned long *ptc0, *ptc1;
+	unsigned long flags = 0, data0, data1;
+	struct mm_struct *mm = current->active_mm;
+	short nasids[NR_NODES], nix;
 	DECLARE_BITMAP(nodes_flushed, NR_NODES);
 
 	bitmap_zero(nodes_flushed, NR_NODES);
@@ -114,7 +110,7 @@
 
 	if (likely(i == 1 && lcpu == smp_processor_id())) {
 		do {
-			ia64_ptcl(start, nbits<<2);
+			ia64_ptcl(start, nbits << 2);
 			start += (1UL << nbits);
 		} while (start < end);
 		ia64_srlz_i();
@@ -128,42 +124,42 @@
 		return;
 	}
 
-
 	nix = 0;
-	for (cnode=find_first_bit(&nodes_flushed, NR_NODES); cnode < NR_NODES; 
-			cnode=find_next_bit(&nodes_flushed, NR_NODES, ++cnode))
+	for (cnode = find_first_bit(&nodes_flushed, NR_NODES); cnode < NR_NODES;
+	     cnode = find_next_bit(&nodes_flushed, NR_NODES, ++cnode))
 		nasids[nix++] = cnodeid_to_nasid(cnode);
 
+	data0 = (1UL << SH_PTC_0_A_SHFT) |
+	    (nbits << SH_PTC_0_PS_SHFT) |
+	    ((ia64_get_rr(start) >> 8) << SH_PTC_0_RID_SHFT) |
+	    (1UL << SH_PTC_0_START_SHFT);
 
-	data0 = (1UL<<SH_PTC_0_A_SHFT) |
-		(nbits<<SH_PTC_0_PS_SHFT) |
-		((ia64_get_rr(start)>>8)<<SH_PTC_0_RID_SHFT) |
-		(1UL<<SH_PTC_0_START_SHFT);
-
-	ptc0 = (long*)GLOBAL_MMR_PHYS_ADDR(0, SH_PTC_0);
-	ptc1 = (long*)GLOBAL_MMR_PHYS_ADDR(0, SH_PTC_1);
+	ptc0 = (long *)GLOBAL_MMR_PHYS_ADDR(0, SH_PTC_0);
+	ptc1 = (long *)GLOBAL_MMR_PHYS_ADDR(0, SH_PTC_1);
 
-
-	mynasid = smp_physical_node_id();
+	mynasid = get_nasid();
 
 	spin_lock_irqsave(&sn2_global_ptc_lock, flags);
 
 	do {
-		data1 = start | (1UL<<SH_PTC_1_START_SHFT);
-		for (i=0; i<nix; i++) {
+		data1 = start | (1UL << SH_PTC_1_START_SHFT);
+		for (i = 0; i < nix; i++) {
 			nasid = nasids[i];
 			if (likely(nasid == mynasid)) {
-				ia64_ptcga(start, nbits<<2);
+				ia64_ptcga(start, nbits << 2);
 				ia64_srlz_i();
 			} else {
 				ptc0 = CHANGE_NASID(nasid, ptc0);
 				ptc1 = CHANGE_NASID(nasid, ptc1);
-				pio_atomic_phys_write_mmrs(ptc0, data0, ptc1, data1);
+				pio_atomic_phys_write_mmrs(ptc0, data0, ptc1,
+							   data1);
 				flushed = 1;
 			}
 		}
 
-		if (flushed && (wait_piowc() & SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK_MASK)) {
+		if (flushed
+		    && (wait_piowc() &
+			SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK_MASK)) {
 			sn2_ptc_deadlock_recovery(data0, data1);
 		}
 
@@ -183,18 +179,18 @@
  * TLB flush transaction.  The recovery sequence is somewhat tricky & is
  * coded in assembly language.
  */
-void
-sn2_ptc_deadlock_recovery(unsigned long data0, unsigned long data1)
+void sn2_ptc_deadlock_recovery(unsigned long data0, unsigned long data1)
 {
-	extern void sn2_ptc_deadlock_recovery_core(long*, long, long*, long, long*);
-	int	cnode, mycnode, nasid;
-	long	*ptc0, *ptc1, *piows;
+	extern void sn2_ptc_deadlock_recovery_core(long *, long, long *, long,
+						   long *);
+	int cnode, mycnode, nasid;
+	long *ptc0, *ptc1, *piows;
 
 	sn2_ptc_deadlock_count++;
 
-	ptc0 = (long*)GLOBAL_MMR_PHYS_ADDR(0, SH_PTC_0);
-	ptc1 = (long*)GLOBAL_MMR_PHYS_ADDR(0, SH_PTC_1);
-	piows = (long*)pda->pio_write_status_addr;
+	ptc0 = (long *)GLOBAL_MMR_PHYS_ADDR(0, SH_PTC_0);
+	ptc1 = (long *)GLOBAL_MMR_PHYS_ADDR(0, SH_PTC_1);
+	piows = (long *)pda->pio_write_status_addr;
 
 	mycnode = numa_node_id();
 
@@ -210,6 +206,7 @@
 
 /**
  * sn_send_IPI_phys - send an IPI to a Nasid and slice
+ * @nasid: nasid to receive the interrupt (may be outside partition)
  * @physid: physical cpuid to receive the interrupt.
  * @vector: command to send
  * @delivery_mode: delivery mechanism
@@ -224,34 +221,31 @@
  * %IA64_IPI_DM_NMI - pend an NMI
  * %IA64_IPI_DM_INIT - pend an INIT interrupt
  */
-void
-sn_send_IPI_phys(long physid, int vector, int delivery_mode)
+void sn_send_IPI_phys(int nasid, long physid, int vector, int delivery_mode)
 {
-	long		nasid, slice, val;
-	unsigned long	flags=0;
-	volatile long	*p;
-
-	nasid = cpu_physical_id_to_nasid(physid);
-        slice = cpu_physical_id_to_slice(physid);
-
-	p = (long*)GLOBAL_MMR_PHYS_ADDR(nasid, SH_IPI_INT);
-	val =   (1UL<<SH_IPI_INT_SEND_SHFT) | 
-		(physid<<SH_IPI_INT_PID_SHFT) | 
-	        ((long)delivery_mode<<SH_IPI_INT_TYPE_SHFT) | 
-		((long)vector<<SH_IPI_INT_IDX_SHFT) |
-		(0x000feeUL<<SH_IPI_INT_BASE_SHFT);
+	long val;
+	unsigned long flags = 0;
+	volatile long *p;
+
+	p = (long *)GLOBAL_MMR_PHYS_ADDR(nasid, SH_IPI_INT);
+	val = (1UL << SH_IPI_INT_SEND_SHFT) |
+	    (physid << SH_IPI_INT_PID_SHFT) |
+	    ((long)delivery_mode << SH_IPI_INT_TYPE_SHFT) |
+	    ((long)vector << SH_IPI_INT_IDX_SHFT) |
+	    (0x000feeUL << SH_IPI_INT_BASE_SHFT);
 
 	mb();
-	if (enable_shub_wars_1_1() ) {
+	if (enable_shub_wars_1_1()) {
 		spin_lock_irqsave(&sn2_global_ptc_lock, flags);
 	}
 	pio_phys_write_mmr(p, val);
-	if (enable_shub_wars_1_1() ) {
+	if (enable_shub_wars_1_1()) {
 		wait_piowc();
 		spin_unlock_irqrestore(&sn2_global_ptc_lock, flags);
 	}
 
 }
+
 EXPORT_SYMBOL(sn_send_IPI_phys);
 
 /**
@@ -270,12 +264,17 @@
  * %IA64_IPI_DM_NMI - pend an NMI
  * %IA64_IPI_DM_INIT - pend an INIT interrupt
  */
-void
-sn2_send_IPI(int cpuid, int vector, int delivery_mode, int redirect)
+void sn2_send_IPI(int cpuid, int vector, int delivery_mode, int redirect)
 {
-	long		physid;
+	long physid;
+	int nasid;
 
 	physid = cpu_physical_id(cpuid);
+	nasid = cpuid_to_nasid(cpuid);
+
+	/* the following is used only when starting cpus at boot time */
+	if (unlikely(nasid == -1))
+		ia64_sn_get_sapic_info(physid, &nasid, NULL, NULL);
 
-	sn_send_IPI_phys(physid, vector, delivery_mode);
+	sn_send_IPI_phys(nasid, physid, vector, delivery_mode);
 }
diff -Nru a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c	2004-12-24 13:37:18 -08:00
@@ -36,9 +36,12 @@
 #include <asm/semaphore.h>
 #include <asm/segment.h>
 #include <asm/uaccess.h>
-#include <asm-ia64/sal.h>
-#include <asm-ia64/sn/sn_sal.h>
-#include <asm-ia64/sn/sn2/sn_hwperf.h>
+#include <asm/sal.h>
+#include <asm/sn/io.h>
+#include <asm/sn/sn_sal.h>
+#include <asm/sn/module.h>
+#include <asm/sn/geo.h>
+#include <asm/sn/sn2/sn_hwperf.h>
 
 static void *sn_hwperf_salheap = NULL;
 static int sn_hwperf_obj_cnt = 0;
@@ -80,21 +83,26 @@
 static int sn_hwperf_geoid_to_cnode(char *location)
 {
 	int cnode;
-	int mod, slot, slab;
-	int cmod, cslot, cslab;
+	geoid_t geoid;
+	moduleid_t module_id;
+	char type;
+	int rack, slot, slab;
+	int this_rack, this_slot, this_slab;
 
-	if (sscanf(location, "%03dc%02d#%d", &mod, &slot, &slab) != 3)
+	if (sscanf(location, "%03d%c%02d#%d", &rack, &type, &slot, &slab) != 4)
 		return -1;
-	for (cnode = 0; cnode < numnodes; cnode++) {
-		/* XXX: need a better way than this ... */
-		if (sscanf(NODEPDA(cnode)->hwg_node_name,
-		   "hw/module/%03dc%02d/slab/%d", &cmod, &cslot, &cslab) == 3) {
-			if (mod == cmod && slot == cslot && slab == cslab)
-				break;
-		}
+
+	for (cnode = 0; cnode < numionodes; cnode++) {
+		geoid = cnodeid_get_geoid(cnode);
+		module_id = geo_module(geoid);
+		this_rack = MODULE_GET_RACK(module_id);
+		this_slot = MODULE_GET_BPOS(module_id);
+		this_slab = geo_slab(geoid);
+		if (rack == this_rack && slot == this_slot && slab == this_slab)
+			break;
 	}
 
-	return cnode < numnodes ? cnode : -1;
+	return cnode < numionodes ? cnode : -1;
 }
 
 static int sn_hwperf_obj_to_cnode(struct sn_hwperf_object_info * obj)
@@ -113,52 +121,35 @@
 	for (ordinal=0, p=objs; p != obj; p++) {
 		if (SN_HWPERF_FOREIGN(p))
 			continue;
-		if (p->location[3] == obj->location[3])
+		if (SN_HWPERF_SAME_OBJTYPE(p, obj))
 			ordinal++;
 	}
 
 	return ordinal;
 }
 
-#ifndef MODULE_IOBRICK 
-/* this will be available when ioif TIO support is added */
-#define MODULE_IOBRICK (MODULE_OPUSBRICK+1)
-#endif
-
-static const char *sn_hwperf_get_brickname(struct sn_hwperf_object_info *obj,
-				struct sn_hwperf_object_info *objs, int *ordinal)
-{
-	int i;
-	const char *objtype = NULL;
-
-	for (i=0; i < MAX_BRICK_TYPES; i++) {
-		if (brick_types[i] != obj->location[3])
-			continue;
-		switch (i) {
-		case MODULE_CBRICK:
-		    objtype = "node";
-		    *ordinal = sn_hwperf_obj_to_cnode(obj); /* cnodeid */
-		    break;
-
-		case MODULE_RBRICK:
-		    objtype = "router";
-		    *ordinal = sn_hwperf_generic_ordinal(obj, objs);
-		    break;
-
-		case MODULE_IOBRICK:
-		    objtype = "ionode";
-		    *ordinal = sn_hwperf_generic_ordinal(obj, objs);
-		    break;
-		}
-		break;
+static const char *slabname_node =	"node"; /* SHub asic */
+static const char *slabname_ionode =	"ionode"; /* TIO asic */
+static const char *slabname_router =	"router"; /* NL3R or NL4R */
+static const char *slabname_other =	"other"; /* unknown asic */
+
+static const char *sn_hwperf_get_slabname(struct sn_hwperf_object_info *obj,
+			struct sn_hwperf_object_info *objs, int *ordinal)
+{
+	int isnode;
+	const char *slabname = slabname_other;
+
+	if ((isnode = SN_HWPERF_IS_NODE(obj)) || SN_HWPERF_IS_IONODE(obj)) {
+	    	slabname = isnode ? slabname_node : slabname_ionode;
+		*ordinal = sn_hwperf_obj_to_cnode(obj);
 	}
-
-	if (i == MAX_BRICK_TYPES) {
-		objtype = "other";
+	else {
 		*ordinal = sn_hwperf_generic_ordinal(obj, objs);
+		if (SN_HWPERF_IS_ROUTER(obj))
+			slabname = slabname_router;
 	}
 
-	return objtype;
+	return slabname;
 }
 
 static int sn_topology_show(struct seq_file *s, void *d)
@@ -168,7 +159,7 @@
 	int e;
 	int i;
 	int j;
-	const char *brickname;
+	const char *slabname;
 	int ordinal;
 	cpumask_t cpumask;
 	char slice;
@@ -194,22 +185,22 @@
 			obj->name[i] = '_';
 	}
 
-	brickname = sn_hwperf_get_brickname(obj, objs, &ordinal);
-	seq_printf(s, "%s %d %s %s asic %s", brickname, ordinal, obj->location,
+	slabname = sn_hwperf_get_slabname(obj, objs, &ordinal);
+	seq_printf(s, "%s %d %s %s asic %s", slabname, ordinal, obj->location,
 		obj->sn_hwp_this_part ? "local" : "shared", obj->name);
 
-	if (obj->location[3] != 'c')
+	if (!SN_HWPERF_IS_NODE(obj) && !SN_HWPERF_IS_IONODE(obj))
 		seq_putc(s, '\n');
 	else {
 		seq_printf(s, ", nasid 0x%x", cnodeid_to_nasid(ordinal));
-		for (i=0; i < numnodes; i++) {
+		for (i=0; i < numionodes; i++) {
 			seq_printf(s, i ? ":%d" : ", dist %d",
 				node_distance(ordinal, i));
 		}
 		seq_putc(s, '\n');
 
 		/*
-		 * CPUs on this node
+		 * CPUs on this node, if any
 		 */
 		cpumask = node_to_cpumask(ordinal);
 		for_each_online_cpu(i) {
@@ -253,11 +244,16 @@
 					break;
 				}
 			}
-			if (i >= sn_hwperf_obj_cnt)
-				continue;
 			seq_printf(s, "numalink %d %s-%d",
 			    ordinal+pt, obj->location, ptdata[pt].port);
 
+			if (i >= sn_hwperf_obj_cnt) {
+				/* no connection */
+				seq_puts(s, " local endpoint disconnected"
+					    ", protocol unknown\n");
+				continue;
+			}
+
 			if (obj->sn_hwp_this_part && p->sn_hwp_this_part)
 				/* both ends local to this partition */
 				seq_puts(s, " local");
@@ -276,9 +272,8 @@
 			 */
 			seq_printf(s, " endpoint %s-%d, protocol %s\n",
 				p->location, ptdata[pt].conn_port,
-				strcmp(obj->name, "NL3Router") == 0 ||
-				strcmp(p->name, "NL3Router") == 0 ?
-				"LLP3" : "LLP4");
+				(SN_HWPERF_IS_NL3ROUTER(obj) ||
+				SN_HWPERF_IS_NL3ROUTER(p)) ?  "LLP3" : "LLP4");
 		}
 		vfree(ptdata);
 	}
@@ -405,7 +400,7 @@
 		r = -EINVAL;
 		goto error;
 	}
-	r = copy_from_user(&a, (const void *)arg,
+	r = copy_from_user(&a, (const void __user *)arg,
 		sizeof(struct sn_hwperf_ioctl_args));
 	if (r != 0) {
 		r = -EFAULT;
@@ -426,7 +421,7 @@
 	}
 
 	if (op & SN_HWPERF_OP_MEM_COPYIN) {
-		r = copy_from_user(p, (const void *)a.ptr, a.sz);
+		r = copy_from_user(p, (const void __user *)a.ptr, a.sz);
 		if (r != 0) {
 			r = -EFAULT;
 			goto error;
@@ -473,7 +468,7 @@
 
 	case SN_HWPERF_GET_NODE_NASID:
 		if (a.sz != sizeof(u64) ||
-		   (node = a.arg) < 0 || node >= numnodes) {
+		   (node = a.arg) < 0 || node >= numionodes) {
 			r = -EINVAL;
 			goto error;
 		}
@@ -526,7 +521,7 @@
 	}
 
 	if (op & SN_HWPERF_OP_MEM_COPYOUT) {
-		r = copy_to_user((void *)a.ptr, p, a.sz);
+		r = copy_to_user((void __user *)a.ptr, p, a.sz);
 		if (r != 0) {
 			r = -EFAULT;
 			goto error;
diff -Nru a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
--- a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c	2004-12-24 13:37:30 -08:00
+++ b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c	2004-12-24 13:37:30 -08:00
@@ -11,7 +11,6 @@
 #ifdef CONFIG_PROC_FS
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <asm/sn/sgi.h>
 #include <asm/sn/sn_sal.h>
 
 static int partition_id_show(struct seq_file *s, void *p)
@@ -63,9 +62,14 @@
 }
 
 static ssize_t sn_force_interrupt_write_proc(struct file *file,
-		const __user char *buffer, size_t count, loff_t *data)
+		const char __user *buffer, size_t count, loff_t *data)
 {
-	sn_force_interrupt_flag = (*buffer == '0') ? 0 : 1;
+	char val;
+
+	if (copy_from_user(&val, buffer, 1))
+		return -EFAULT;
+
+	sn_force_interrupt_flag = (val == '0') ? 0 : 1;
 	return count;
 }
 
@@ -76,7 +80,8 @@
 
 static int coherence_id_show(struct seq_file *s, void *p)
 {
-	seq_printf(s, "%d\n", cpuid_to_coherence_id(smp_processor_id()));
+	seq_printf(s, "%d\n", partition_coherence_id());
+
 	return 0;
 }
 
@@ -117,7 +122,7 @@
 	struct proc_dir_entry *e;
 
 	BUG_ON(sgi_proc_dir != NULL);
-	if (!(sgi_proc_dir = proc_mkdir("sgi_sn", 0)))
+	if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
 		return;
 
 	sn_procfs_create_entry("partition_id", sgi_proc_dir,
diff -Nru a/arch/ia64/sn/kernel/sn2/timer.c b/arch/ia64/sn/kernel/sn2/timer.c
--- a/arch/ia64/sn/kernel/sn2/timer.c	2004-12-24 13:36:57 -08:00
+++ b/arch/ia64/sn/kernel/sn2/timer.c	2004-12-24 13:36:57 -08:00
@@ -15,21 +15,23 @@
 #include <asm/hw_irq.h>
 #include <asm/system.h>
 
+#include "shub.h"
 #include <asm/sn/leds.h>
+#include <asm/sn/shub_mmr.h>
 #include <asm/sn/clksupport.h>
 
-
 extern unsigned long sn_rtc_cycles_per_second;
 
-static struct time_interpolator sn2_interpolator;
+static struct time_interpolator sn2_interpolator = {
+	.drift = -1,
+	.shift = 10,
+	.mask = (1LL << 55) - 1,
+	.source = TIME_SOURCE_MMIO64,
+	.addr = RTC_COUNTER_ADDR
+};
 
-void __init
-sn_timer_init(void)
+void __init sn_timer_init(void)
 {
 	sn2_interpolator.frequency = sn_rtc_cycles_per_second;
-	sn2_interpolator.drift = -1;	/* unknown */
-	sn2_interpolator.shift = 10;	/* RTC is 54 bits maximum shift is 10 */
-	sn2_interpolator.addr = RTC_COUNTER_ADDR;
-	sn2_interpolator.source = TIME_SOURCE_MMIO64;
 	register_time_interpolator(&sn2_interpolator);
 }
diff -Nru a/arch/ia64/sn/kernel/sn2/timer_interrupt.c b/arch/ia64/sn/kernel/sn2/timer_interrupt.c
--- a/arch/ia64/sn/kernel/sn2/timer_interrupt.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ia64/sn/kernel/sn2/timer_interrupt.c	2004-12-24 13:37:19 -08:00
@@ -34,26 +34,27 @@
 
 #include <linux/interrupt.h>
 #include <asm/sn/pda.h>
+#include "shub.h"
 #include <asm/sn/leds.h>
 
 extern void sn_lb_int_war_check(void);
-extern irqreturn_t timer_interrupt (int irq, void *dev_id, struct pt_regs *regs);
+extern irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 #define SN_LB_INT_WAR_INTERVAL 100
 
-void
-sn_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+void sn_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/* LED blinking */
 	if (!pda->hb_count--) {
-		pda->hb_count = HZ/2;
-		set_led_bits(pda->hb_state ^= LED_CPU_HEARTBEAT, LED_CPU_HEARTBEAT);
+		pda->hb_count = HZ / 2;
+		set_led_bits(pda->hb_state ^=
+			     LED_CPU_HEARTBEAT, LED_CPU_HEARTBEAT);
 	}
 
 	if (enable_shub_wars_1_1()) {
 		/* Bugfix code for SHUB 1.1 */
-        	if (pda->pio_shub_war_cam_addr)
-                	*pda->pio_shub_war_cam_addr = 0x8000000000000010UL;
+		if (pda->pio_shub_war_cam_addr)
+			*pda->pio_shub_war_cam_addr = 0x8000000000000010UL;
 	}
 	if (pda->sn_lb_int_war_ticks == 0)
 		sn_lb_int_war_check();
diff -Nru a/arch/ia64/sn/pci/Makefile b/arch/ia64/sn/pci/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/pci/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,10 @@
+#
+# 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-2004 Silicon Graphics, Inc.  All Rights Reserved.
+#
+# Makefile for the sn pci general routines.
+
+obj-y := pci_dma.o pcibr/ 
diff -Nru a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/pci/pci_dma.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,477 @@
+/*
+ * 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,2002-2004 Silicon Graphics, Inc. All rights reserved.
+ *
+ * Routines for PCI DMA mapping.  See Documentation/DMA-mapping.txt for
+ * a description of how these routines should be used.
+ */
+
+#include <linux/module.h>
+#include <asm/sn/sn_sal.h>
+#include "pci/pcibus_provider_defs.h"
+#include "pci/pcidev.h"
+#include "pci/pcibr_provider.h"
+
+void sn_pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents,
+		     int direction);
+
+/**
+ * sn_pci_alloc_consistent - allocate memory for coherent DMA
+ * @hwdev: device to allocate for
+ * @size: size of the region
+ * @dma_handle: DMA (bus) address
+ *
+ * pci_alloc_consistent() returns a pointer to a memory region suitable for
+ * coherent DMA traffic to/from a PCI device.  On SN platforms, this means
+ * that @dma_handle will have the %PCIIO_DMA_CMD flag set.
+ *
+ * This interface is usually used for "command" streams (e.g. the command
+ * queue for a SCSI controller).  See Documentation/DMA-mapping.txt for
+ * more information.
+ *
+ * Also known as platform_pci_alloc_consistent() by the IA64 machvec code.
+ */
+void *sn_pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
+			      dma_addr_t * dma_handle)
+{
+	void *cpuaddr;
+	unsigned long phys_addr;
+	struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
+	struct pcibus_bussoft *bussoft = SN_PCIDEV_BUSSOFT(hwdev);
+
+	if (bussoft == NULL) {
+		return NULL;
+	}
+
+	if (! IS_PCI_BRIDGE_ASIC(bussoft->bs_asic_type)) {
+		return NULL;		/* unsupported asic type */
+	}
+
+	/*
+	 * Allocate the memory.
+	 * FIXME: We should be doing alloc_pages_node for the node closest
+	 *        to the PCI device.
+	 */
+	if (!(cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size))))
+		return NULL;
+
+	memset(cpuaddr, 0x0, size);
+
+	/* physical addr. of the memory we just got */
+	phys_addr = __pa(cpuaddr);
+
+	/*
+	 * 64 bit address translations should never fail.
+	 * 32 bit translations can fail if there are insufficient mapping
+	 *   resources.
+	 */
+
+	*dma_handle = pcibr_dma_map(pcidev_info, phys_addr, size, SN_PCIDMA_CONSISTENT);
+	if (!*dma_handle) {
+		printk(KERN_ERR
+		       "sn_pci_alloc_consistent():  failed  *dma_handle = 0x%lx hwdev->dev.coherent_dma_mask = 0x%lx \n",
+		       *dma_handle, hwdev->dev.coherent_dma_mask);
+		free_pages((unsigned long)cpuaddr, get_order(size));
+		return NULL;
+	}
+
+	return cpuaddr;
+}
+
+/**
+ * sn_pci_free_consistent - free memory associated with coherent DMAable region
+ * @hwdev: device to free for
+ * @size: size to free
+ * @vaddr: kernel virtual address to free
+ * @dma_handle: DMA address associated with this region
+ *
+ * Frees the memory allocated by pci_alloc_consistent().  Also known
+ * as platform_pci_free_consistent() by the IA64 machvec code.
+ */
+void
+sn_pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr,
+		       dma_addr_t dma_handle)
+{
+	struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
+	struct pcibus_bussoft *bussoft = SN_PCIDEV_BUSSOFT(hwdev);
+
+	if (! bussoft) {
+		return;
+	}
+
+	pcibr_dma_unmap(pcidev_info, dma_handle, 0);
+	free_pages((unsigned long)vaddr, get_order(size));
+}
+
+/**
+ * sn_pci_map_sg - map a scatter-gather list for DMA
+ * @hwdev: device to map for
+ * @sg: scatterlist to map
+ * @nents: number of entries
+ * @direction: direction of the DMA transaction
+ *
+ * Maps each entry of @sg for DMA.  Also known as platform_pci_map_sg by the
+ * IA64 machvec code.
+ */
+int
+sn_pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents,
+	      int direction)
+{
+
+	int i;
+	unsigned long phys_addr;
+	struct scatterlist *saved_sg = sg;
+	struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
+	struct pcibus_bussoft *bussoft = SN_PCIDEV_BUSSOFT(hwdev);
+
+	/* can't go anywhere w/o a direction in life */
+	if (direction == PCI_DMA_NONE)
+		BUG();
+
+	if (! bussoft) {
+		return 0;
+	}
+
+	/* SN cannot support DMA addresses smaller than 32 bits. */
+	if (hwdev->dma_mask < 0x7fffffff)
+		return 0;
+
+	/*
+	 * Setup a DMA address for each entry in the
+	 * scatterlist.
+	 */
+	for (i = 0; i < nents; i++, sg++) {
+		phys_addr =
+		    __pa((unsigned long)page_address(sg->page) + sg->offset);
+		sg->dma_address = pcibr_dma_map(pcidev_info, phys_addr, sg->length, 0);
+
+		if (!sg->dma_address) {
+			printk(KERN_ERR "sn_pci_map_sg: Unable to allocate "
+			       "anymore page map entries.\n");
+			/*
+			 * We will need to free all previously allocated entries.
+			 */
+			if (i > 0) {
+				sn_pci_unmap_sg(hwdev, saved_sg, i, direction);
+			}
+			return (0);
+		}
+
+		sg->dma_length = sg->length;
+	}
+
+	return nents;
+
+}
+
+/**
+ * sn_pci_unmap_sg - unmap a scatter-gather list
+ * @hwdev: device to unmap
+ * @sg: scatterlist to unmap
+ * @nents: number of scatterlist entries
+ * @direction: DMA direction
+ *
+ * Unmap a set of streaming mode DMA translations.  Again, cpu read rules
+ * concerning calls here are the same as for pci_unmap_single() below.  Also
+ * known as sn_pci_unmap_sg() by the IA64 machvec code.
+ */
+void
+sn_pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents,
+		int direction)
+{
+	int i;
+	struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
+	struct pcibus_bussoft *bussoft = SN_PCIDEV_BUSSOFT(hwdev);
+
+	/* can't go anywhere w/o a direction in life */
+	if (direction == PCI_DMA_NONE)
+		BUG();
+
+	if (! bussoft) {
+		return;
+	}
+
+	for (i = 0; i < nents; i++, sg++) {
+		pcibr_dma_unmap(pcidev_info, sg->dma_address, direction);
+		sg->dma_address = (dma_addr_t) NULL;
+		sg->dma_length = 0;
+	}
+}
+
+/**
+ * sn_pci_map_single - map a single region for DMA
+ * @hwdev: device to map for
+ * @ptr: kernel virtual address of the region to map
+ * @size: size of the region
+ * @direction: DMA direction
+ *
+ * Map the region pointed to by @ptr for DMA and return the
+ * DMA address.   Also known as platform_pci_map_single() by
+ * the IA64 machvec code.
+ *
+ * We map this to the one step pcibr_dmamap_trans interface rather than
+ * the two step pcibr_dmamap_alloc/pcibr_dmamap_addr because we have
+ * no way of saving the dmamap handle from the alloc to later free
+ * (which is pretty much unacceptable).
+ *
+ * TODO: simplify our interface;
+ *       get rid of dev_desc and vhdl (seems redundant given a pci_dev);
+ *       figure out how to save dmamap handle so can use two step.
+ */
+dma_addr_t
+sn_pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
+{
+	dma_addr_t dma_addr;
+	unsigned long phys_addr;
+	struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
+	struct pcibus_bussoft *bussoft = SN_PCIDEV_BUSSOFT(hwdev);
+
+	if (direction == PCI_DMA_NONE)
+		BUG();
+
+	if (bussoft == NULL) {
+		return 0;
+	}
+
+	if (! IS_PCI_BRIDGE_ASIC(bussoft->bs_asic_type)) {
+		return 0;		/* unsupported asic type */
+	}
+
+	/* SN cannot support DMA addresses smaller than 32 bits. */
+	if (hwdev->dma_mask < 0x7fffffff)
+		return 0;
+
+	/*
+	 * Call our dmamap interface
+	 */
+
+	phys_addr = __pa(ptr);
+	dma_addr = pcibr_dma_map(pcidev_info, phys_addr, size, 0);
+	if (!dma_addr) {
+		printk(KERN_ERR "pci_map_single: Unable to allocate anymore "
+		       "page map entries.\n");
+		return 0;
+	}
+	return ((dma_addr_t) dma_addr);
+}
+
+/**
+ * sn_pci_dma_sync_single_* - make sure all DMAs or CPU accesses
+ * have completed
+ * @hwdev: device to sync
+ * @dma_handle: DMA address to sync
+ * @size: size of region
+ * @direction: DMA direction
+ *
+ * This routine is supposed to sync the DMA region specified
+ * by @dma_handle into the 'coherence domain'.  We do not need to do
+ * anything on our platform.
+ */
+void
+sn_pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size,
+		    int direction)
+{
+	struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
+	struct pcibus_bussoft *bussoft = SN_PCIDEV_BUSSOFT(hwdev);
+
+	if (direction == PCI_DMA_NONE)
+		BUG();
+
+	if (bussoft == NULL) {
+		return;
+	}
+
+	if (! IS_PCI_BRIDGE_ASIC(bussoft->bs_asic_type)) {
+		return;		/* unsupported asic type */
+	}
+
+	pcibr_dma_unmap(pcidev_info, dma_addr, direction);
+}
+
+/**
+ * sn_dma_supported - test a DMA mask
+ * @hwdev: device to test
+ * @mask: DMA mask to test
+ *
+ * Return whether the given PCI device DMA address mask can be supported
+ * properly.  For example, if your device can only drive the low 24-bits
+ * during PCI bus mastering, then you would pass 0x00ffffff as the mask to
+ * this function.  Of course, SN only supports devices that have 32 or more
+ * address bits when using the PMU.  We could theoretically support <32 bit
+ * cards using direct mapping, but we'll worry about that later--on the off
+ * chance that someone actually wants to use such a card.
+ */
+int sn_pci_dma_supported(struct pci_dev *hwdev, u64 mask)
+{
+	if (mask < 0x7fffffff)
+		return 0;
+	return 1;
+}
+
+/*
+ * New generic DMA routines just wrap sn2 PCI routines until we
+ * support other bus types (if ever).
+ */
+
+int sn_dma_supported(struct device *dev, u64 mask)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	return sn_pci_dma_supported(to_pci_dev(dev), mask);
+}
+
+EXPORT_SYMBOL(sn_dma_supported);
+
+int sn_dma_set_mask(struct device *dev, u64 dma_mask)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	if (!sn_dma_supported(dev, dma_mask))
+		return 0;
+
+	*dev->dma_mask = dma_mask;
+	return 1;
+}
+
+EXPORT_SYMBOL(sn_dma_set_mask);
+
+void *sn_dma_alloc_coherent(struct device *dev, size_t size,
+			    dma_addr_t * dma_handle, int flag)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	return sn_pci_alloc_consistent(to_pci_dev(dev), size, dma_handle);
+}
+
+EXPORT_SYMBOL(sn_dma_alloc_coherent);
+
+void
+sn_dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
+		     dma_addr_t dma_handle)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	sn_pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
+}
+
+EXPORT_SYMBOL(sn_dma_free_coherent);
+
+dma_addr_t
+sn_dma_map_single(struct device *dev, void *cpu_addr, size_t size,
+		  int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	return sn_pci_map_single(to_pci_dev(dev), cpu_addr, size,
+				 (int)direction);
+}
+
+EXPORT_SYMBOL(sn_dma_map_single);
+
+void
+sn_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
+		    int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	sn_pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
+}
+
+EXPORT_SYMBOL(sn_dma_unmap_single);
+
+dma_addr_t
+sn_dma_map_page(struct device *dev, struct page *page,
+		unsigned long offset, size_t size, int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	return pci_map_page(to_pci_dev(dev), page, offset, size,
+			    (int)direction);
+}
+
+EXPORT_SYMBOL(sn_dma_map_page);
+
+void
+sn_dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
+		  int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
+}
+
+EXPORT_SYMBOL(sn_dma_unmap_page);
+
+int
+sn_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
+	      int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	return sn_pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
+}
+
+EXPORT_SYMBOL(sn_dma_map_sg);
+
+void
+sn_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
+		int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+
+	sn_pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
+}
+
+EXPORT_SYMBOL(sn_dma_unmap_sg);
+
+void
+sn_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+			   size_t size, int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+}
+
+EXPORT_SYMBOL(sn_dma_sync_single_for_cpu);
+
+void
+sn_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
+			      size_t size, int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+}
+
+EXPORT_SYMBOL(sn_dma_sync_single_for_device);
+
+void
+sn_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
+		       int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+}
+
+EXPORT_SYMBOL(sn_dma_sync_sg_for_cpu);
+
+void
+sn_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
+			  int nelems, int direction)
+{
+	BUG_ON(dev->bus != &pci_bus_type);
+}
+
+int sn_dma_mapping_error(dma_addr_t dma_addr)
+{
+	return 0;
+}
+
+EXPORT_SYMBOL(sn_dma_sync_sg_for_device);
+EXPORT_SYMBOL(sn_pci_unmap_single);
+EXPORT_SYMBOL(sn_pci_map_single);
+EXPORT_SYMBOL(sn_pci_map_sg);
+EXPORT_SYMBOL(sn_pci_unmap_sg);
+EXPORT_SYMBOL(sn_pci_alloc_consistent);
+EXPORT_SYMBOL(sn_pci_free_consistent);
+EXPORT_SYMBOL(sn_pci_dma_supported);
+EXPORT_SYMBOL(sn_dma_mapping_error);
diff -Nru a/arch/ia64/sn/pci/pcibr/Makefile b/arch/ia64/sn/pci/pcibr/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/pci/pcibr/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,11 @@
+#
+# 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) 2002-2004 Silicon Graphics, Inc.  All Rights Reserved.
+#
+# Makefile for the sn2 io routines.
+
+obj-y				+=  pcibr_dma.o pcibr_reg.o \
+				    pcibr_ate.o pcibr_provider.o
diff -Nru a/arch/ia64/sn/pci/pcibr/pcibr_ate.c b/arch/ia64/sn/pci/pcibr/pcibr_ate.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/pci/pcibr/pcibr_ate.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,188 @@
+/*
+ * 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-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/types.h>
+#include <asm/sn/sn_sal.h>
+#include "pci/pcibus_provider_defs.h"
+#include "pci/pcidev.h"
+#include "pci/pcibr_provider.h"
+
+int pcibr_invalidate_ate = 0;	/* by default don't invalidate ATE on free */
+
+/*
+ * mark_ate: Mark the ate as either free or inuse.
+ */
+static void mark_ate(struct ate_resource *ate_resource, int start, int number,
+		     uint64_t value)
+{
+
+	uint64_t *ate = ate_resource->ate;
+	int index;
+	int length = 0;
+
+	for (index = start; length < number; index++, length++)
+		ate[index] = value;
+
+}
+
+/*
+ * find_free_ate:  Find the first free ate index starting from the given
+ *		   index for the desired consequtive count.
+ */
+static int find_free_ate(struct ate_resource *ate_resource, int start,
+			 int count)
+{
+
+	uint64_t *ate = ate_resource->ate;
+	int index;
+	int start_free;
+
+	for (index = start; index < ate_resource->num_ate;) {
+		if (!ate[index]) {
+			int i;
+			int free;
+			free = 0;
+			start_free = index;	/* Found start free ate */
+			for (i = start_free; i < ate_resource->num_ate; i++) {
+				if (!ate[i]) {	/* This is free */
+					if (++free == count)
+						return start_free;
+				} else {
+					index = i + 1;
+					break;
+				}
+			}
+		} else
+			index++;	/* Try next ate */
+	}
+
+	return -1;
+}
+
+/*
+ * free_ate_resource:  Free the requested number of ATEs.
+ */
+static inline void free_ate_resource(struct ate_resource *ate_resource,
+				     int start)
+{
+
+	mark_ate(ate_resource, start, ate_resource->ate[start], 0);
+	if ((ate_resource->lowest_free_index > start) ||
+	    (ate_resource->lowest_free_index < 0))
+		ate_resource->lowest_free_index = start;
+
+}
+
+/*
+ * alloc_ate_resource:  Allocate the requested number of ATEs.
+ */
+static inline int alloc_ate_resource(struct ate_resource *ate_resource,
+				     int ate_needed)
+{
+
+	int start_index;
+
+	/*
+	 * Check for ate exhaustion.
+	 */
+	if (ate_resource->lowest_free_index < 0)
+		return -1;
+
+	/*
+	 * Find the required number of free consequtive ates.
+	 */
+	start_index =
+	    find_free_ate(ate_resource, ate_resource->lowest_free_index,
+			  ate_needed);
+	if (start_index >= 0)
+		mark_ate(ate_resource, start_index, ate_needed, ate_needed);
+
+	ate_resource->lowest_free_index =
+	    find_free_ate(ate_resource, ate_resource->lowest_free_index, 1);
+
+	return start_index;
+}
+
+/*
+ * Allocate "count" contiguous Bridge Address Translation Entries
+ * on the specified bridge to be used for PCI to XTALK mappings.
+ * Indices in rm map range from 1..num_entries.  Indicies returned
+ * to caller range from 0..num_entries-1.
+ *
+ * Return the start index on success, -1 on failure.
+ */
+int pcibr_ate_alloc(struct pcibus_info *pcibus_info, int count)
+{
+	int status = 0;
+	uint64_t flag;
+
+	flag = pcibr_lock(pcibus_info);
+	status = alloc_ate_resource(&pcibus_info->pbi_int_ate_resource, count);
+
+	if (status < 0) {
+		/* Failed to allocate */
+		pcibr_unlock(pcibus_info, flag);
+		return -1;
+	}
+
+	pcibr_unlock(pcibus_info, flag);
+
+	return status;
+}
+
+/*
+ * Setup an Address Translation Entry as specified.  Use either the Bridge
+ * internal maps or the external map RAM, as appropriate.
+ */
+static inline uint64_t *pcibr_ate_addr(struct pcibus_info *pcibus_info,
+				       int ate_index)
+{
+	if (ate_index < pcibus_info->pbi_int_ate_size) {
+		return pcireg_int_ate_addr(pcibus_info, ate_index);
+	}
+	panic("pcibr_ate_addr: invalid ate_index 0x%x", ate_index);
+}
+
+/*
+ * Update the ate.
+ */
+void inline
+ate_write(struct pcibus_info *pcibus_info, int ate_index, int count,
+	  volatile uint64_t ate)
+{
+	while (count-- > 0) {
+		if (ate_index < pcibus_info->pbi_int_ate_size) {
+			pcireg_int_ate_set(pcibus_info, ate_index, ate);
+		} else {
+			panic("ate_write: invalid ate_index 0x%x", ate_index);
+		}
+		ate_index++;
+		ate += IOPGSIZE;
+	}
+
+	pcireg_tflush_get(pcibus_info);	/* wait until Bridge PIO complete */
+}
+
+void pcibr_ate_free(struct pcibus_info *pcibus_info, int index)
+{
+
+	volatile uint64_t ate;
+	int count;
+	uint64_t flags;
+
+	if (pcibr_invalidate_ate) {
+		/* For debugging purposes, clear the valid bit in the ATE */
+		ate = *pcibr_ate_addr(pcibus_info, index);
+		count = pcibus_info->pbi_int_ate_resource.ate[index];
+		ate_write(pcibus_info, index, count, (ate & ~PCI32_ATE_V));
+	}
+
+	flags = pcibr_lock(pcibus_info);
+	free_ate_resource(&pcibus_info->pbi_int_ate_resource, index);
+	pcibr_unlock(pcibus_info, flags);
+}
diff -Nru a/arch/ia64/sn/pci/pcibr/pcibr_dma.c b/arch/ia64/sn/pci/pcibr/pcibr_dma.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/pci/pcibr/pcibr_dma.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,379 @@
+/*
+ * 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-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <asm/sn/sn_sal.h>
+#include <asm/sn/geo.h>
+#include "xtalk/xwidgetdev.h"
+#include "xtalk/hubdev.h"
+#include "pci/pcibus_provider_defs.h"
+#include "pci/pcidev.h"
+#include "pci/tiocp.h"
+#include "pci/pic.h"
+#include "pci/pcibr_provider.h"
+#include "pci/tiocp.h"
+#include "tio.h"
+#include <asm/sn/addrs.h>
+
+extern int sn_ioif_inited;
+
+/* =====================================================================
+ *    DMA MANAGEMENT
+ *
+ *      The Bridge ASIC provides three methods of doing DMA: via a "direct map"
+ *      register available in 32-bit PCI space (which selects a contiguous 2G
+ *	address space on some other widget), via "direct" addressing via 64-bit
+ *      PCI space (all destination information comes from the PCI address,
+ *      including transfer attributes), and via a "mapped" region that allows 
+ *      a bunch of different small mappings to be established with the PMU.
+ *
+ *      For efficiency, we most prefer to use the 32bit direct mapping facility,
+ *      since it requires no resource allocations. The advantage of using the
+ *      PMU over the 64-bit direct is that single-cycle PCI addressing can be
+ *      used; the advantage of using 64-bit direct over PMU addressing is that
+ *      we do not have to allocate entries in the PMU.
+ */
+
+static uint64_t
+pcibr_dmamap_ate32(struct pcidev_info *info,
+		   uint64_t paddr, size_t req_size, uint64_t flags)
+{
+
+	struct pcidev_info *pcidev_info = info->pdi_host_pcidev_info;
+	struct pcibus_info *pcibus_info = (struct pcibus_info *)pcidev_info->
+	    pdi_pcibus_info;
+	uint8_t internal_device = (PCI_SLOT(pcidev_info->pdi_host_pcidev_info->
+					    pdi_linux_pcidev->devfn)) - 1;
+	int ate_count;
+	int ate_index;
+	uint64_t ate_flags = flags | PCI32_ATE_V;
+	uint64_t ate;
+	uint64_t pci_addr;
+	uint64_t xio_addr;
+	uint64_t offset;
+
+	/* PIC in PCI-X mode does not supports 32bit PageMap mode */
+	if (IS_PIC_SOFT(pcibus_info) && IS_PCIX(pcibus_info)) {
+		return 0;
+	}
+
+	/* Calculate the number of ATEs needed. */
+	if (!(MINIMAL_ATE_FLAG(paddr, req_size))) {
+		ate_count = IOPG((IOPGSIZE - 1)	/* worst case start offset */
+				 +req_size	/* max mapping bytes */
+				 - 1) + 1;	/* round UP */
+	} else {		/* assume requested target is page aligned */
+		ate_count = IOPG(req_size	/* max mapping bytes */
+				 - 1) + 1;	/* round UP */
+	}
+
+	/* Get the number of ATEs required. */
+	ate_index = pcibr_ate_alloc(pcibus_info, ate_count);
+	if (ate_index < 0)
+		return 0;
+
+	/* In PCI-X mode, Prefetch not supported */
+	if (IS_PCIX(pcibus_info))
+		ate_flags &= ~(PCI32_ATE_PREF);
+
+	xio_addr =
+	    IS_PIC_SOFT(pcibus_info) ? PHYS_TO_DMA(paddr) :
+	    PHYS_TO_TIODMA(paddr);
+	offset = IOPGOFF(xio_addr);
+	ate = ate_flags | (xio_addr - offset);
+
+	/* If PIC, put the targetid in the ATE */
+	if (IS_PIC_SOFT(pcibus_info)) {
+		ate |= (pcibus_info->pbi_hub_xid << PIC_ATE_TARGETID_SHFT);
+	}
+	ate_write(pcibus_info, ate_index, ate_count, ate);
+
+	/*
+	 * Set up the DMA mapped Address.
+	 */
+	pci_addr = PCI32_MAPPED_BASE + offset + IOPGSIZE * ate_index;
+
+	/*
+	 * If swap was set in device in pcibr_endian_set()
+	 * we need to turn swapping on.
+	 */
+	if (pcibus_info->pbi_devreg[internal_device] & PCIBR_DEV_SWAP_DIR)
+		ATE_SWAP_ON(pci_addr);
+
+	return pci_addr;
+}
+
+static uint64_t
+pcibr_dmatrans_direct64(struct pcidev_info * info, uint64_t paddr,
+			uint64_t dma_attributes)
+{
+	struct pcibus_info *pcibus_info = (struct pcibus_info *)
+	    ((info->pdi_host_pcidev_info)->pdi_pcibus_info);
+	uint64_t pci_addr;
+
+	/* Translate to Crosstalk View of Physical Address */
+	pci_addr = (IS_PIC_SOFT(pcibus_info) ? PHYS_TO_DMA(paddr) :
+		    PHYS_TO_TIODMA(paddr)) | dma_attributes;
+
+	/* Handle Bus mode */
+	if (IS_PCIX(pcibus_info))
+		pci_addr &= ~PCI64_ATTR_PREF;
+
+	/* Handle Bridge Chipset differences */
+	if (IS_PIC_SOFT(pcibus_info)) {
+		pci_addr |=
+		    ((uint64_t) pcibus_info->
+		     pbi_hub_xid << PIC_PCI64_ATTR_TARG_SHFT);
+	} else
+		pci_addr |= TIOCP_PCI64_CMDTYPE_MEM;
+
+	/* If PCI mode, func zero uses VCHAN0, every other func uses VCHAN1 */
+	if (!IS_PCIX(pcibus_info) && PCI_FUNC(info->pdi_linux_pcidev->devfn))
+		pci_addr |= PCI64_ATTR_VIRTUAL;
+
+	return pci_addr;
+
+}
+
+static uint64_t
+pcibr_dmatrans_direct32(struct pcidev_info * info,
+			uint64_t paddr, size_t req_size, uint64_t flags)
+{
+
+	struct pcidev_info *pcidev_info = info->pdi_host_pcidev_info;
+	struct pcibus_info *pcibus_info = (struct pcibus_info *)pcidev_info->
+	    pdi_pcibus_info;
+	uint64_t xio_addr;
+
+	uint64_t xio_base;
+	uint64_t offset;
+	uint64_t endoff;
+
+	if (IS_PCIX(pcibus_info)) {
+		return 0;
+	}
+
+	xio_addr = IS_PIC_SOFT(pcibus_info) ? PHYS_TO_DMA(paddr) :
+	    PHYS_TO_TIODMA(paddr);
+
+	xio_base = pcibus_info->pbi_dir_xbase;
+	offset = xio_addr - xio_base;
+	endoff = req_size + offset;
+	if ((req_size > (1ULL << 31)) ||	/* Too Big */
+	    (xio_addr < xio_base) ||	/* Out of range for mappings */
+	    (endoff > (1ULL << 31))) {	/* Too Big */
+		return 0;
+	}
+
+	return PCI32_DIRECT_BASE | offset;
+
+}
+
+/*
+ * Wrapper routine for free'ing DMA maps
+ * DMA mappings for Direct 64 and 32 do not have any DMA maps.
+ */
+void
+pcibr_dma_unmap(struct pcidev_info *pcidev_info, dma_addr_t dma_handle,
+		int direction)
+{
+	struct pcibus_info *pcibus_info = (struct pcibus_info *)pcidev_info->
+	    pdi_pcibus_info;
+
+	if (IS_PCI32_MAPPED(dma_handle)) {
+		int ate_index;
+
+		ate_index =
+		    IOPG((ATE_SWAP_OFF(dma_handle) - PCI32_MAPPED_BASE));
+		pcibr_ate_free(pcibus_info, ate_index);
+	}
+}
+
+/*
+ * On SN systems there is a race condition between a PIO read response and 
+ * DMA's.  In rare cases, the read response may beat the DMA, causing the
+ * driver to think that data in memory is complete and meaningful.  This code
+ * eliminates that race.  This routine is called by the PIO read routines
+ * after doing the read.  For PIC this routine then forces a fake interrupt
+ * on another line, which is logically associated with the slot that the PIO
+ * is addressed to.  It then spins while watching the memory location that
+ * the interrupt is targetted to.  When the interrupt response arrives, we 
+ * are sure that the DMA has landed in memory and it is safe for the driver
+ * to proceed.	For TIOCP use the Device(x) Write Request Buffer Flush 
+ * Bridge register since it ensures the data has entered the coherence domain,
+ * unlike the PIC Device(x) Write Request Buffer Flush register.
+ */
+
+void sn_dma_flush(uint64_t addr)
+{
+	nasid_t nasid;
+	int is_tio;
+	int wid_num;
+	int i, j;
+	int bwin;
+	uint64_t flags;
+	struct hubdev_info *hubinfo;
+	volatile struct sn_flush_device_list *p;
+	struct sn_flush_nasid_entry *flush_nasid_list;
+
+	if (!sn_ioif_inited)
+		return;
+
+	nasid = NASID_GET(addr);
+	if (-1 == nasid_to_cnodeid(nasid))
+		return;
+
+	hubinfo = (NODEPDA(nasid_to_cnodeid(nasid)))->pdinfo;
+
+	if (!hubinfo) {
+		BUG();
+	}
+	is_tio = (nasid & 1);
+	if (is_tio) {
+		wid_num = TIO_SWIN_WIDGETNUM(addr);
+		bwin = TIO_BWIN_WINDOWNUM(addr);
+	} else {
+		wid_num = SWIN_WIDGETNUM(addr);
+		bwin = BWIN_WINDOWNUM(addr);
+	}
+
+	flush_nasid_list = &hubinfo->hdi_flush_nasid_list;
+	if (flush_nasid_list->widget_p == NULL)
+		return;
+	if (bwin > 0) {
+		uint64_t itte = flush_nasid_list->iio_itte[bwin];
+
+		if (is_tio) {
+			wid_num = (itte >> TIO_ITTE_WIDGET_SHIFT) &
+			    TIO_ITTE_WIDGET_MASK;
+		} else {
+			wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) &
+			    IIO_ITTE_WIDGET_MASK;
+		}
+	}
+	if (flush_nasid_list->widget_p == NULL)
+		return;
+	if (flush_nasid_list->widget_p[wid_num] == NULL)
+		return;
+	p = &flush_nasid_list->widget_p[wid_num][0];
+
+	/* find a matching BAR */
+	for (i = 0; i < DEV_PER_WIDGET; i++) {
+		for (j = 0; j < PCI_ROM_RESOURCE; j++) {
+			if (p->sfdl_bar_list[j].start == 0)
+				break;
+			if (addr >= p->sfdl_bar_list[j].start
+			    && addr <= p->sfdl_bar_list[j].end)
+				break;
+		}
+		if (j < PCI_ROM_RESOURCE && p->sfdl_bar_list[j].start != 0)
+			break;
+		p++;
+	}
+
+	/* if no matching BAR, return without doing anything. */
+	if (i == DEV_PER_WIDGET)
+		return;
+
+	/*
+	 * For TIOCP use the Device(x) Write Request Buffer Flush Bridge
+	 * register since it ensures the data has entered the coherence
+	 * domain, unlike PIC
+	 */
+	if (is_tio) {
+		uint32_t tio_id = REMOTE_HUB_L(nasid, TIO_NODE_ID);
+		uint32_t revnum = XWIDGET_PART_REV_NUM(tio_id);
+
+		/* TIOCP BRINGUP WAR (PV907516): Don't write buffer flush reg */
+		if ((1 << XWIDGET_PART_REV_NUM_REV(revnum)) & PV907516) {
+			return;
+		} else {
+			pcireg_wrb_flush_get(p->sfdl_pcibus_info,
+					     (p->sfdl_slot - 1));
+		}
+	} else {
+		spin_lock_irqsave(&((struct sn_flush_device_list *)p)->
+				  sfdl_flush_lock, flags);
+
+		p->sfdl_flush_value = 0;
+
+		/* force an interrupt. */
+		*(volatile uint32_t *)(p->sfdl_force_int_addr) = 1;
+
+		/* wait for the interrupt to come back. */
+		while (*(p->sfdl_flush_addr) != 0x10f) ;
+
+		/* okay, everything is synched up. */
+		spin_unlock_irqrestore((spinlock_t *)&p->sfdl_flush_lock, flags);
+	}
+	return;
+}
+
+/*
+ * Wrapper DMA interface.  Called from pci_dma.c routines.
+ */
+
+uint64_t
+pcibr_dma_map(struct pcidev_info * pcidev_info, unsigned long phys_addr,
+	      size_t size, unsigned int flags)
+{
+	dma_addr_t dma_handle;
+	struct pci_dev *pcidev = pcidev_info->pdi_linux_pcidev;
+
+	if (flags & SN_PCIDMA_CONSISTENT) {
+		/* sn_pci_alloc_consistent interfaces */
+		if (pcidev->dev.coherent_dma_mask == ~0UL) {
+			dma_handle =
+			    pcibr_dmatrans_direct64(pcidev_info, phys_addr,
+						    PCI64_ATTR_BAR);
+		} else {
+			dma_handle =
+			    (dma_addr_t) pcibr_dmamap_ate32(pcidev_info,
+							    phys_addr, size,
+							    PCI32_ATE_BAR);
+		}
+	} else {
+		/* map_sg/map_single interfaces */
+
+		/* SN cannot support DMA addresses smaller than 32 bits. */
+		if (pcidev->dma_mask < 0x7fffffff) {
+			return 0;
+		}
+
+		if (pcidev->dma_mask == ~0UL) {
+			/*
+			 * Handle the most common case: 64 bit cards.  This
+			 * call should always succeed.
+			 */
+
+			dma_handle =
+			    pcibr_dmatrans_direct64(pcidev_info, phys_addr,
+						    PCI64_ATTR_PREF);
+		} else {
+			/* Handle 32-63 bit cards via direct mapping */
+			dma_handle =
+			    pcibr_dmatrans_direct32(pcidev_info, phys_addr,
+						    size, 0);
+			if (!dma_handle) {
+				/*
+				 * It is a 32 bit card and we cannot do direct mapping,
+				 * so we use an ATE.
+				 */
+
+				dma_handle =
+				    pcibr_dmamap_ate32(pcidev_info, phys_addr,
+						       size, PCI32_ATE_PREF);
+			}
+		}
+	}
+
+	return dma_handle;
+}
+
+EXPORT_SYMBOL(sn_dma_flush);
diff -Nru a/arch/ia64/sn/pci/pcibr/pcibr_provider.c b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/pci/pcibr/pcibr_provider.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,170 @@
+/*
+ * 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-2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <asm/sn/sn_sal.h>
+#include "xtalk/xwidgetdev.h"
+#include <asm/sn/geo.h>
+#include "xtalk/hubdev.h"
+#include "pci/pcibus_provider_defs.h"
+#include "pci/pcidev.h"
+#include "pci/pcibr_provider.h"
+#include <asm/sn/addrs.h>
+
+
+static int sal_pcibr_error_interrupt(struct pcibus_info *soft)
+{
+	struct ia64_sal_retval ret_stuff;
+	uint64_t busnum;
+	int segment;
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+
+	segment = 0;
+	busnum = soft->pbi_buscommon.bs_persist_busnum;
+	SAL_CALL_NOLOCK(ret_stuff,
+			(u64) SN_SAL_IOIF_ERROR_INTERRUPT,
+			(u64) segment, (u64) busnum, 0, 0, 0, 0, 0);
+
+	return (int)ret_stuff.v0;
+}
+
+/* 
+ * PCI Bridge Error interrupt handler.  Gets invoked whenever a PCI 
+ * bridge sends an error interrupt.
+ */
+static irqreturn_t
+pcibr_error_intr_handler(int irq, void *arg, struct pt_regs *regs)
+{
+	struct pcibus_info *soft = (struct pcibus_info *)arg;
+
+	if (sal_pcibr_error_interrupt(soft) < 0) {
+		panic("pcibr_error_intr_handler(): Fatal Bridge Error");
+	}
+	return IRQ_HANDLED;
+}
+
+void *
+pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft)
+{
+	int nasid, cnode, j;
+	struct hubdev_info *hubdev_info;
+	struct pcibus_info *soft;
+	struct sn_flush_device_list *sn_flush_device_list;
+
+	if (! IS_PCI_BRIDGE_ASIC(prom_bussoft->bs_asic_type)) {
+		return NULL;
+	}
+
+	/*
+	 * Allocate kernel bus soft and copy from prom.
+	 */
+
+	soft = kmalloc(sizeof(struct pcibus_info), GFP_KERNEL);
+	if (!soft) {
+		return NULL;
+	}
+
+	memcpy(soft, prom_bussoft, sizeof(struct pcibus_info));
+	soft->pbi_buscommon.bs_base =
+	    (((u64) soft->pbi_buscommon.
+	      bs_base << 4) >> 4) | __IA64_UNCACHED_OFFSET;
+
+	spin_lock_init(&soft->pbi_lock);
+
+	/*
+	 * register the bridge's error interrupt handler
+	 */
+	if (request_irq(SGI_PCIBR_ERROR, (void *)pcibr_error_intr_handler,
+			SA_SHIRQ, "PCIBR error", (void *)(soft))) {
+		printk(KERN_WARNING
+		       "pcibr cannot allocate interrupt for error handler\n");
+	}
+
+	/* 
+	 * Update the Bridge with the "kernel" pagesize 
+	 */
+	if (PAGE_SIZE < 16384) {
+		pcireg_control_bit_clr(soft, PCIBR_CTRL_PAGE_SIZE);
+	} else {
+		pcireg_control_bit_set(soft, PCIBR_CTRL_PAGE_SIZE);
+	}
+
+	nasid = NASID_GET(soft->pbi_buscommon.bs_base);
+	cnode = nasid_to_cnodeid(nasid);
+	hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
+
+	if (hubdev_info->hdi_flush_nasid_list.widget_p) {
+		sn_flush_device_list = hubdev_info->hdi_flush_nasid_list.
+		    widget_p[(int)soft->pbi_buscommon.bs_xid];
+		if (sn_flush_device_list) {
+			for (j = 0; j < DEV_PER_WIDGET;
+			     j++, sn_flush_device_list++) {
+				if (sn_flush_device_list->sfdl_slot == -1)
+					continue;
+				if (sn_flush_device_list->
+				    sfdl_persistent_busnum ==
+				    soft->pbi_buscommon.bs_persist_busnum)
+					sn_flush_device_list->sfdl_pcibus_info =
+					    soft;
+			}
+		}
+	}
+
+	/* Setup the PMU ATE map */
+	soft->pbi_int_ate_resource.lowest_free_index = 0;
+	soft->pbi_int_ate_resource.ate =
+	    kmalloc(soft->pbi_int_ate_size * sizeof(uint64_t), GFP_KERNEL);
+	memset(soft->pbi_int_ate_resource.ate, 0,
+ 	       (soft->pbi_int_ate_size * sizeof(uint64_t)));
+
+	return soft;
+}
+
+void pcibr_force_interrupt(struct sn_irq_info *sn_irq_info)
+{
+	struct pcidev_info *pcidev_info;
+	struct pcibus_info *pcibus_info;
+	int bit = sn_irq_info->irq_int_bit;
+
+	pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
+	if (pcidev_info) {
+		pcibus_info =
+		    (struct pcibus_info *)pcidev_info->pdi_host_pcidev_info->
+		    pdi_pcibus_info;
+		pcireg_force_intr_set(pcibus_info, bit);
+	}
+}
+
+void pcibr_change_devices_irq(struct sn_irq_info *sn_irq_info)
+{
+	struct pcidev_info *pcidev_info;
+	struct pcibus_info *pcibus_info;
+	int bit = sn_irq_info->irq_int_bit;
+	uint64_t xtalk_addr = sn_irq_info->irq_xtalkaddr;
+
+	pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
+	if (pcidev_info) {
+		pcibus_info =
+		    (struct pcibus_info *)pcidev_info->pdi_host_pcidev_info->
+		    pdi_pcibus_info;
+
+		/* Disable the device's IRQ   */
+		pcireg_intr_enable_bit_clr(pcibus_info, bit);
+
+		/* Change the device's IRQ    */
+		pcireg_intr_addr_addr_set(pcibus_info, bit, xtalk_addr);
+
+		/* Re-enable the device's IRQ */
+		pcireg_intr_enable_bit_set(pcibus_info, bit);
+
+		pcibr_force_interrupt(sn_irq_info);
+	}
+}
diff -Nru a/arch/ia64/sn/pci/pcibr/pcibr_reg.c b/arch/ia64/sn/pci/pcibr/pcibr_reg.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ia64/sn/pci/pcibr/pcibr_reg.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,282 @@
+/*
+ * 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) 2004 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include "pci/pcibus_provider_defs.h"
+#include "pci/pcidev.h"
+#include "pci/tiocp.h"
+#include "pci/pic.h"
+#include "pci/pcibr_provider.h"
+
+union br_ptr {
+	struct tiocp tio;
+	struct pic pic;
+};
+
+/*
+ * Control Register Access -- Read/Write                            0000_0020
+ */
+void pcireg_control_bit_clr(struct pcibus_info *pcibus_info, uint64_t bits)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ptr->tio.cp_control &= ~bits;
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ptr->pic.p_wid_control &= ~bits;
+			break;
+		default:
+			panic
+			    ("pcireg_control_bit_clr: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+}
+
+void pcireg_control_bit_set(struct pcibus_info *pcibus_info, uint64_t bits)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ptr->tio.cp_control |= bits;
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ptr->pic.p_wid_control |= bits;
+			break;
+		default:
+			panic
+			    ("pcireg_control_bit_set: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+}
+
+/*
+ * PCI/PCIX Target Flush Register Access -- Read Only		    0000_0050
+ */
+uint64_t pcireg_tflush_get(struct pcibus_info *pcibus_info)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+	uint64_t ret = 0;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ret = ptr->tio.cp_tflush;
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ret = ptr->pic.p_wid_tflush;
+			break;
+		default:
+			panic
+			    ("pcireg_tflush_get: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+
+	/* Read of the Target Flush should always return zero */
+	if (ret != 0)
+		panic("pcireg_tflush_get:Target Flush failed\n");
+
+	return ret;
+}
+
+/*
+ * Interrupt Status Register Access -- Read Only		    0000_0100
+ */
+uint64_t pcireg_intr_status_get(struct pcibus_info * pcibus_info)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+	uint64_t ret = 0;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ret = ptr->tio.cp_int_status;
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ret = ptr->pic.p_int_status;
+			break;
+		default:
+			panic
+			    ("pcireg_intr_status_get: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+	return ret;
+}
+
+/*
+ * Interrupt Enable Register Access -- Read/Write                   0000_0108
+ */
+void pcireg_intr_enable_bit_clr(struct pcibus_info *pcibus_info, uint64_t bits)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ptr->tio.cp_int_enable &= ~bits;
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ptr->pic.p_int_enable &= ~bits;
+			break;
+		default:
+			panic
+			    ("pcireg_intr_enable_bit_clr: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+}
+
+void pcireg_intr_enable_bit_set(struct pcibus_info *pcibus_info, uint64_t bits)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ptr->tio.cp_int_enable |= bits;
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ptr->pic.p_int_enable |= bits;
+			break;
+		default:
+			panic
+			    ("pcireg_intr_enable_bit_set: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+}
+
+/*
+ * Intr Host Address Register (int_addr) -- Read/Write  0000_0130 - 0000_0168
+ */
+void pcireg_intr_addr_addr_set(struct pcibus_info *pcibus_info, int int_n,
+			       uint64_t addr)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ptr->tio.cp_int_addr[int_n] &= ~TIOCP_HOST_INTR_ADDR;
+			ptr->tio.cp_int_addr[int_n] |=
+			    (addr & TIOCP_HOST_INTR_ADDR);
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ptr->pic.p_int_addr[int_n] &= ~PIC_HOST_INTR_ADDR;
+			ptr->pic.p_int_addr[int_n] |=
+			    (addr & PIC_HOST_INTR_ADDR);
+			break;
+		default:
+			panic
+			    ("pcireg_intr_addr_addr_get: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+}
+
+/*
+ * Force Interrupt Register Access -- Write Only	0000_01C0 - 0000_01F8
+ */
+void pcireg_force_intr_set(struct pcibus_info *pcibus_info, int int_n)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ptr->tio.cp_force_pin[int_n] = 1;
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ptr->pic.p_force_pin[int_n] = 1;
+			break;
+		default:
+			panic
+			    ("pcireg_force_intr_set: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+}
+
+/*
+ * Device(x) Write Buffer Flush Reg Access -- Read Only 0000_0240 - 0000_0258
+ */
+uint64_t pcireg_wrb_flush_get(struct pcibus_info *pcibus_info, int device)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+	uint64_t ret = 0;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ret = ptr->tio.cp_wr_req_buf[device];
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ret = ptr->pic.p_wr_req_buf[device];
+			break;
+		default:
+		      panic("pcireg_wrb_flush_get: unknown bridgetype bridge 0x%p", (void *)ptr);
+		}
+
+	}
+	/* Read of the Write Buffer Flush should always return zero */
+	return ret;
+}
+
+void pcireg_int_ate_set(struct pcibus_info *pcibus_info, int ate_index,
+			uint64_t val)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ptr->tio.cp_int_ate_ram[ate_index] = (uint64_t) val;
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ptr->pic.p_int_ate_ram[ate_index] = (uint64_t) val;
+			break;
+		default:
+			panic
+			    ("pcireg_int_ate_set: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+}
+
+uint64_t *pcireg_int_ate_addr(struct pcibus_info *pcibus_info, int ate_index)
+{
+	union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
+	uint64_t *ret = (uint64_t *) 0;
+
+	if (pcibus_info) {
+		switch (pcibus_info->pbi_bridge_type) {
+		case PCIBR_BRIDGETYPE_TIOCP:
+			ret =
+			    (uint64_t *) & (ptr->tio.cp_int_ate_ram[ate_index]);
+			break;
+		case PCIBR_BRIDGETYPE_PIC:
+			ret =
+			    (uint64_t *) & (ptr->pic.p_int_ate_ram[ate_index]);
+			break;
+		default:
+			panic
+			    ("pcireg_int_ate_addr: unknown bridgetype bridge 0x%p",
+			     (void *)ptr);
+		}
+	}
+	return ret;
+}
diff -Nru a/arch/m32r/Kconfig b/arch/m32r/Kconfig
--- a/arch/m32r/Kconfig	2004-12-24 13:36:16 -08:00
+++ b/arch/m32r/Kconfig	2004-12-24 13:36:16 -08:00
@@ -3,7 +3,7 @@
 # see Documentation/kbuild/kconfig-language.txt.
 #
 
-mainmenu "Linux Kernel Configuration"
+mainmenu "Linux/M32R Kernel Configuration"
 
 config M32R
 	bool
@@ -20,6 +20,10 @@
 	bool
 	default y
 
+#config GENERIC_HARDIRQS
+#	bool
+#	default y
+
 source "init/Kconfig"
 
 
@@ -189,6 +193,10 @@
 	bool
 	default n
 
+config GENERIC_CALIBRATE_DELAY
+	bool
+	default y
+
 config PREEMPT
 	bool "Preemptible Kernel"
 	help
@@ -346,96 +354,10 @@
 
 source "arch/m32r/oprofile/Kconfig"
 
-menu "Kernel hacking"
-
-config DEBUG_KERNEL
-	bool "Kernel debugging"
-	help
-	  Say Y here if you are developing drivers or trying to debug and
-	  identify kernel problems.
-
-config DEBUG_STACKOVERFLOW
-	bool "Check for stack overflows"
-	depends on DEBUG_KERNEL
-
-config DEBUG_SLAB
-	bool "Debug memory allocations"
-	depends on DEBUG_KERNEL
-	help
-	  Say Y here to have the kernel do limited verification on memory
-	  allocation as well as poisoning memory on free to catch use of freed
-	  memory.
-
-config DEBUG_IOVIRT
-	bool "Memory mapped I/O debugging"
-	depends on DEBUG_KERNEL
-	help
-	  Say Y here to get warned whenever an attempt is made to do I/O on
-	  obviously invalid addresses such as those generated when ioremap()
-	  calls are forgotten.  Memory mapped I/O will go through an extra
-	  check to catch access to unmapped ISA addresses, an access method
-	  that can still be used by old drivers that are being ported from
-	  2.0/2.2.
-
-config MAGIC_SYSRQ
-	bool "Magic SysRq key"
-	depends on DEBUG_KERNEL
-	help
-	  If you say Y here, you will have some control over the system even
-	  if the system crashes for example during kernel debugging (e.g., you
-	  will be able to flush the buffer cache to disk, reboot the system
-	  immediately or dump some status information). This is accomplished
-	  by pressing various keys while holding SysRq (Alt+PrintScreen). It
-	  also works on a serial console (on PC hardware at least), if you
-	  send a BREAK and then within 5 seconds a command keypress. The
-	  keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
-	  unless you really know what this hack does.
-
-config DEBUG_SPINLOCK
-	bool "Spinlock debugging"
-	depends on DEBUG_KERNEL
-	help
-	  Say Y here and build SMP to catch missing spinlock initialization
-	  and certain other kinds of spinlock errors commonly made.  This is
-	  best used in conjunction with the NMI watchdog so that spinlock
-	  deadlocks are also debuggable.
-
-config DEBUG_PAGEALLOC
-	bool "Page alloc debugging"
-	depends on DEBUG_KERNEL
-	help
-	  Unmap pages from the kernel linear mapping after free_pages().
-	  This results in a large slowdown, but helps to find certain types
-	  of memory corruptions.
-
-config DEBUG_INFO
-	bool "Compile the kernel with debug info"
-	depends on DEBUG_KERNEL
-	help
-          If you say Y here the resulting kernel image will include
-	  debugging info resulting in a larger kernel image.
-	  Say Y here only if you plan to use gdb to debug the kernel.
-	  If you don't debug the kernel, you can say N.
-
-config DEBUG_SPINLOCK_SLEEP
-	bool "Sleep-inside-spinlock checking"
-	help
-	  If you say Y here, various routines which may sleep will become very
-	  noisy if they are called with a spinlock held.
-
-config FRAME_POINTER
-	bool "Compile the kernel with frame pointers"
-	help
-	  If you say Y here the resulting kernel image will be slightly larger
-	  and slower, but it will give very useful debugging information.
-	  If you don't debug the kernel, you can say N, but we may not be able
-	  to solve problems without frame pointers.
-
-endmenu
+source "arch/m32r/Kconfig.debug"
 
 source "security/Kconfig"
 
 source "crypto/Kconfig"
 
 source "lib/Kconfig"
-
diff -Nru a/arch/m32r/Kconfig.debug b/arch/m32r/Kconfig.debug
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m32r/Kconfig.debug	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,34 @@
+menu "Kernel hacking"
+
+source "lib/Kconfig.debug"
+
+config DEBUG_STACKOVERFLOW
+	bool "Check for stack overflows"
+	depends on DEBUG_KERNEL
+
+config DEBUG_STACK_USAGE
+	bool "Stack utilization instrumentation"
+	depends on DEBUG_KERNEL
+	help
+	  Enables the display of the minimum amount of free stack which each
+	  task has ever had available in the sysrq-T and sysrq-P debug output.
+
+	  This option will slow down process creation somewhat.
+
+config DEBUG_PAGEALLOC
+	bool "Page alloc debugging"
+	depends on DEBUG_KERNEL
+	help
+	  Unmap pages from the kernel linear mapping after free_pages().
+	  This results in a large slowdown, but helps to find certain types
+	  of memory corruptions.
+
+config FRAME_POINTER
+	bool "Compile the kernel with frame pointers"
+	help
+	  If you say Y here the resulting kernel image will be slightly larger
+	  and slower, but it will give very useful debugging information.
+	  If you don't debug the kernel, you can say N, but we may not be able
+	  to solve problems without frame pointers.
+
+endmenu
diff -Nru a/arch/m32r/Makefile b/arch/m32r/Makefile
--- a/arch/m32r/Makefile	2004-12-24 13:37:18 -08:00
+++ b/arch/m32r/Makefile	2004-12-24 13:37:18 -08:00
@@ -5,7 +5,6 @@
 LDFLAGS		:=
 OBJCOPYFLAGS	:= -O binary -R .note -R .comment -S
 LDFLAGS_vmlinux	:= -e startup_32
-LDFLAGS_BLOB	:= --format binary --oformat elf32-m32r
 
 CFLAGS += -pipe -fno-schedule-insns
 CFLAGS_KERNEL += -mmodel=medium
@@ -42,6 +41,8 @@
 
 .PHONY: zImage
 
+all: zImage
+
 zImage: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
@@ -51,5 +52,5 @@
 	$(Q)$(MAKE) $(clean)=$(boot)
 
 define archhelp
-	@echo '  zImage			- Compressed kernel image (arch/m32r/boot/zImage)'
+	echo  '* zImage          - Compressed kernel image (arch/$(ARCH)/boot/zImage)'
 endef
diff -Nru a/arch/m32r/boot/compressed/Makefile b/arch/m32r/boot/compressed/Makefile
--- a/arch/m32r/boot/compressed/Makefile	2004-12-24 13:36:17 -08:00
+++ b/arch/m32r/boot/compressed/Makefile	2004-12-24 13:36:17 -08:00
@@ -5,10 +5,10 @@
 #
 
 targets		:= vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o \
-		   m32r-sio.o piggy.o vmlinux.lds
+		   piggy.o vmlinux.lds
 EXTRA_AFLAGS	:= -traditional
 
-OBJECTS = $(obj)/head.o $(obj)/misc.o $(obj)/m32r_sio.o
+OBJECTS = $(obj)/head.o $(obj)/misc.o
 
 #
 # IMAGE_OFFSET is the load offset of the compression loader
@@ -28,8 +28,7 @@
 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
 	$(call if_changed,gzip)
 
-$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.S FORCE
-	$(CPP) $(EXTRA_AFLAGS) -C -P -I include $< >$@
+CFLAGS_misc.o += -fpic
 
 LDFLAGS_piggy.o := -r --format binary --oformat elf32-m32r-linux -T
 OBJCOPYFLAGS += -R .empty_zero_page
diff -Nru a/arch/m32r/boot/compressed/head.S b/arch/m32r/boot/compressed/head.S
--- a/arch/m32r/boot/compressed/head.S	2004-12-24 13:36:31 -08:00
+++ b/arch/m32r/boot/compressed/head.S	2004-12-24 13:36:31 -08:00
@@ -13,20 +13,62 @@
 #include <asm/page.h>
 #include <asm/assembler.h>
 
+	/*
+	 * This code can be loaded anywhere, as long as output will not
+	 * overlap it.
+	 *
+	 * NOTE: This head.S should *NOT* be compiled with -fpic.
+	 *
+	 */
+
 	.global	startup
+	.global __bss_start, _ebss, end, zimage_data, zimage_len
 	__ALIGN
 startup:
 	ldi	r0, #0x0000			/* SPI, disable EI */
 	mvtc	r0, psw
 
+	ldi	r12, #-8
+	bl	1f
+	.fillinsn
+1:
+	seth	r1, #high(CONFIG_MEMORY_START + 0x00400000) /* Start address */
+	add	r12, r14				/* Real address */
+	sub	r12, r1					/* difference */
+
+	.global got_len
+	seth	r3, #high(_GLOBAL_OFFSET_TABLE_+8)
+	or3	r3, r3, #low(_GLOBAL_OFFSET_TABLE_+12)
+	add	r3, r14
+
+	/* Update the contents of global offset table */
+	ldi	r1, #low(got_len)
+	srli	r1, #2
+	beqz	r1, 2f
+	.fillinsn
+1:
+	ld	r2, @r3
+	add	r2, r12
+	st	r2, @r3
+	addi	r3, #4
+	addi	r1, #-1
+	bnez	r1, 1b
+	.fillinsn
+2:
+	/* XXX: resolve plt */
+
 /*
  * Clear BSS first so that there are no surprises...
  */
 #ifdef CONFIG_ISA_DUAL_ISSUE
+	seth	r2, #high(__bss_start)
+	or3	r2, r2, #low(__bss_start)
+	add	r2, r12
+	seth	r3, #high(_ebss)
+	or3	r3, r3, #low(_ebss)
+	add	r3, r12
+	sub	r3, r2
 
-	LDIMM	(r2, __bss_start)
-	LDIMM	(r3, _end)
-	sub	r3, r2		; BSS size in bytes
 	; R4 = BSS size in longwords (rounded down)
 	mv	r4, r3		    ||	ldi	r1, #0
 	srli	r4, #4		    ||	addi	r2, #-4
@@ -52,10 +94,13 @@
 .Lendloop2:
 
 #else /* not CONFIG_ISA_DUAL_ISSUE */
-
-	LDIMM	(r2, __bss_start)
-	LDIMM	(r3, _end)
-	sub	r3, r2		; BSS size in bytes
+	seth	r2, #high(__bss_start)
+	or3	r2, r2, #low(__bss_start)
+	add	r2, r12
+	seth	r3, #high(_ebss)
+	or3	r3, r3, #low(_ebss)
+	add	r3, r12
+	sub	r3, r2
 	mv	r4, r3
 	srli	r4, #2		; R4 = BSS size in longwords (rounded down)
 	ldi	r1, #0		; clear R1 for longwords store
@@ -66,27 +111,29 @@
 	addi	r4, #-1		; decrement count
 	bnez	r4, .Lloop1	; go do some more
 .Lendloop1:
-	and3	r4, r3, #3	; get no. of remaining BSS bytes to clear
-	addi	r2, #4		; account for pre-inc store
-	beqz	r4, .Lendloop2	; any more to go?
-.Lloop2:
-	stb	r1, @r2		; yep, zero out another byte
-	addi	r2, #1		; bump address
-	addi	r4, #-1		; decrement count
-	bnez	r4, .Lloop2	; go do some more
-.Lendloop2:
 
 #endif /* not CONFIG_ISA_DUAL_ISSUE */
 
-	seth	r0, #shigh(stack_start)
-	ld	sp, @(r0, low(stack_start))	/* set stack point */
+	seth	r1, #high(end)
+	or3	r1, r1, #low(end)
+	add	r1, r12
+	mv	sp, r1
 
 /*
  * decompress the kernel
  */
+	mv	r0, sp
+	srli	r0, 31				/* MMU is ON or OFF */
+        seth	r1, #high(zimage_data)
+        or3	r1, r1, #low(zimage_data)
+	add	r1, r12
+        seth	r2, #high(zimage_len)
+        or3	r2, r2, #low(zimage_len)
+	mv	r3, sp
+
 	bl	decompress_kernel
 
-#if defined(CONFIG_CHIP_M32700)
+#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_VDEC2)
 	/* Cache flush */
 	ldi	r0, -1
 	ldi	r1, 0xd0	; invalidate i-cache, copy back d-cache
@@ -94,9 +141,14 @@
 #else
 #error "put your cache flush function, please"
 #endif
-        seth	r0, #high(CONFIG_MEMORY_START)
-        or3	r0, r0, #0x2000
-        jmp	r0
+
+	mv	r0, sp
+	srli	r0, 31				/* MMU is ON or OFF */
+	slli	r0, 31
+	or3	r0, r0, #0x2000
+	seth	r1, #high(CONFIG_MEMORY_START)
+	or	r0, r1
+	jmp	r0
 
 	.balign 512
 fake_headers_as_bzImage:
diff -Nru a/arch/m32r/boot/compressed/m32r_sio.c b/arch/m32r/boot/compressed/m32r_sio.c
--- a/arch/m32r/boot/compressed/m32r_sio.c	2004-12-24 13:36:56 -08:00
+++ b/arch/m32r/boot/compressed/m32r_sio.c	2004-12-24 13:36:56 -08:00
@@ -6,12 +6,10 @@
  */
 
 #include <linux/config.h>
-#include <asm/m32r.h>
-#include <asm/io.h>
 
-void putc(char c);
+static void putc(char c);
 
-int puts(const char *s)
+static int puts(const char *s)
 {
 	char c;
 	while ((c = *s++)) putc(c);
@@ -19,6 +17,9 @@
 }
 
 #if defined(CONFIG_PLAT_M32700UT_Alpha) || defined(CONFIG_PLAT_M32700UT)
+#include <asm/m32r.h>
+#include <asm/io.h>
+
 #define USE_FPGA_MAP	0
 
 #if USE_FPGA_MAP
@@ -35,7 +36,7 @@
 #define BOOT_SIO0TXB	PLD_ESIO0TXB
 #endif
 
-void putc(char c)
+static void putc(char c)
 {
 
 	while ((*BOOT_SIO0STS & 0x3) != 0x3) ;
@@ -46,8 +47,17 @@
 	*BOOT_SIO0TXB = c;
 }
 #else
-void putc(char c)
+#define SIO0STS	(volatile unsigned short *)(0xa0efd000 + 14)
+#define SIO0TXB	(volatile unsigned short *)(0xa0efd000 + 30)
+
+static void putc(char c)
 {
-	/* do nothing */
+
+	while ((*SIO0STS & 0x1) == 0) ;
+	if (c == '\n') {
+		*SIO0TXB = '\r';
+		while ((*SIO0STS & 0x1) == 0) ;
+	}
+	*SIO0TXB = c;
 }
 #endif
diff -Nru a/arch/m32r/boot/compressed/misc.c b/arch/m32r/boot/compressed/misc.c
--- a/arch/m32r/boot/compressed/misc.c	2004-12-24 13:36:19 -08:00
+++ b/arch/m32r/boot/compressed/misc.c	2004-12-24 13:36:19 -08:00
@@ -8,8 +8,6 @@
  *
  * Adapted for SH by Stuart Menefy, Aug 1999
  *
- * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
- *
  * 2003-02-12:	Support M32R by Takeo Takahashi
  * 		This is based on arch/sh/boot/compressed/misc.c.
  */
@@ -38,9 +36,9 @@
 static uch *inbuf;	     /* input buffer */
 static uch window[WSIZE];    /* Sliding window buffer */
 
-static unsigned insize;  /* valid bytes in inbuf */
-static unsigned inptr;   /* index of next byte to be processed in inbuf */
-static unsigned outcnt;  /* bytes in output buffer */
+static unsigned insize = 0;  /* valid bytes in inbuf */
+static unsigned inptr = 0;   /* index of next byte to be processed in inbuf */
+static unsigned outcnt = 0;  /* bytes in output buffer */
 
 /* gzip flag byte */
 #define ASCII_FLAG   0x01 /* bit 0 set: file probably ASCII text */
@@ -76,24 +74,18 @@
 static void gzip_mark(void **);
 static void gzip_release(void **);
 
-extern char input_data[];
-extern int input_len;
+static unsigned char *input_data;
+static int input_len;
 
-static long bytes_out;
+static long bytes_out = 0;
 static uch *output_data;
-static unsigned long output_ptr;
+static unsigned long output_ptr = 0;
 
+#include "m32r_sio.c"
 
 static void *malloc(int size);
 static void free(void *where);
-static void error(char *m);
-static void gzip_mark(void **);
-static void gzip_release(void **);
 
-extern int puts(const char *);
-
-extern int _text;		/* Defined in vmlinux.lds.S */
-extern int _end;
 static unsigned long free_mem_ptr;
 static unsigned long free_mem_end_ptr;
 
@@ -105,8 +97,8 @@
 {
 	void *p;
 
-	if (size <0) error("Malloc error\n");
-	if (free_mem_ptr == 0) error("Memory error\n");
+	if (size <0) error("Malloc error");
+	if (free_mem_ptr == 0) error("Memory error");
 
 	free_mem_ptr = (free_mem_ptr + 3) & ~3;	/* Align */
 
@@ -114,7 +106,7 @@
 	free_mem_ptr += size;
 
 	if (free_mem_ptr >= free_mem_end_ptr)
-		error("\nOut of memory\n");
+		error("Out of memory");
 
 	return p;
 }
@@ -159,7 +151,7 @@
 static int fill_inbuf(void)
 {
 	if (insize != 0) {
-		error("ran out of input data\n");
+		error("ran out of input data");
 	}
 
 	inbuf = input_data;
@@ -199,25 +191,20 @@
 	while(1);	/* Halt */
 }
 
-#define STACK_SIZE (4096)
-long user_stack [STACK_SIZE];
-long* stack_start = &user_stack[STACK_SIZE];
-
 /* return decompressed size */
-long decompress_kernel(void)
-{
-	insize = 0;
-	inptr = 0;
-	bytes_out = 0;
-	outcnt = 0;
-	output_data = 0;
-	output_ptr = CONFIG_MEMORY_START + 0x2000;
-	free_mem_ptr = (unsigned long)&_end;
+void
+decompress_kernel(int mmu_on, unsigned char *zimage_data,
+		  unsigned int zimage_len, unsigned long heap)
+{
+	output_data = (unsigned char *)CONFIG_MEMORY_START + 0x2000
+		+ (mmu_on ? 0x80000000 : 0);
+	free_mem_ptr = heap;
 	free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
+	input_data = zimage_data;
+	input_len = zimage_len;
 
 	makecrc();
 	puts("Uncompressing Linux... ");
 	gunzip();
 	puts("Ok, booting the kernel.\n");
-	return bytes_out;
 }
diff -Nru a/arch/m32r/boot/compressed/vmlinux.lds.S b/arch/m32r/boot/compressed/vmlinux.lds.S
--- a/arch/m32r/boot/compressed/vmlinux.lds.S	2004-12-24 13:37:00 -08:00
+++ b/arch/m32r/boot/compressed/vmlinux.lds.S	2004-12-24 13:37:00 -08:00
@@ -8,16 +8,24 @@
 
   _text = .;
   .text : { *(.text) } = 0
-  .rodata : { *(.rodata) }
+  .rodata : { *(.rodata) *(.rodata.*) }
   _etext = .;
 
-  . = ALIGN(32) + (. & (32 - 1));
+  . = ALIGN(32 / 8);
   .data : { *(.data) }
+  . = ALIGN(32 / 8);
+  _got = .;
+  .got  : { *(.got) _egot = .; *(.got.*) }
   _edata  =  .;
 
   . = ALIGN(32 / 8);
   __bss_start = .;
-  .bss : { *(.bss) }
+  .bss : { *(.bss) *(.sbss) }
   . = ALIGN(32 / 8);
-  _end = . ;
+  _ebss = .;
+  . = ALIGN(4096);
+  . += 4096;
+  end = . ;
+
+  got_len = (_egot - _got);
 }
diff -Nru a/arch/m32r/boot/compressed/vmlinux.scr b/arch/m32r/boot/compressed/vmlinux.scr
--- a/arch/m32r/boot/compressed/vmlinux.scr	2004-12-24 13:36:31 -08:00
+++ b/arch/m32r/boot/compressed/vmlinux.scr	2004-12-24 13:36:31 -08:00
@@ -1,9 +1,9 @@
 SECTIONS
 {
   .data : {
-	input_len = .;
-	LONG(input_data_end - input_data) input_data = .;
+	zimage_data = .;
 	*(.data)
-	input_data_end = .;
+	zimage_data_end = .;
 	}
+  zimage_len = zimage_data_end - zimage_data;
 }
diff -Nru a/arch/m32r/boot/setup.S b/arch/m32r/boot/setup.S
--- a/arch/m32r/boot/setup.S	2004-12-24 13:36:49 -08:00
+++ b/arch/m32r/boot/setup.S	2004-12-24 13:36:49 -08:00
@@ -24,7 +24,7 @@
 #define CPU_PARAMS	boot_cpu_data
 #define M32R_MCICAR	 0xfffffff0
 #define M32R_MCDCAR	 0xfffffff4
-#define	M32R_MCCR 	 0xfffffffc
+#define M32R_MCCR 	 0xfffffffc
 #define M32R_BSCR0	 0xffffffd2
 
 ;BSEL
diff -Nru a/arch/m32r/defconfig b/arch/m32r/defconfig
--- a/arch/m32r/defconfig	2004-12-24 13:37:00 -08:00
+++ b/arch/m32r/defconfig	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:08:49 2004
 #
 CONFIG_M32R=y
 CONFIG_UID16=y
@@ -11,10 +13,12 @@
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -24,17 +28,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 # CONFIG_IKCONFIG_PROC is not set
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -44,6 +51,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -78,33 +86,26 @@
 # CONFIG_SMP is not set
 
 #
-# M32R drivers
-#
-# CONFIG_M32RPCC is not set
-CONFIG_M32R_CFC=y
-CONFIG_M32700UT_CFC=y
-CONFIG_CFC_NUM=1
-# CONFIG_MTD_M32R is not set
-CONFIG_M32R_SMC91111=y
-CONFIG_M32700UT_DS1302=y
-
-#
-# Power management options (ACPI, APM)
-#
-# CONFIG_PM is not set
-
-#
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=y
+CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=y
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
+# CONFIG_M32R_PCC is not set
+CONFIG_M32R_CFC=y
+CONFIG_M32R_CFC_NUM=1
 
 #
 # PCI Hotplug Support
@@ -151,6 +152,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -170,7 +181,6 @@
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_BLK_DEV_IDESCSI is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -213,9 +223,8 @@
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -271,6 +280,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -290,7 +302,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -307,7 +318,50 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+CONFIG_SMC91X=y
+# CONFIG_NE2000 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
@@ -342,6 +396,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -355,7 +410,9 @@
 #
 # Character devices
 #
-# CONFIG_VT is not set
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -368,13 +425,12 @@
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_M32R_SIO is not set
+CONFIG_SERIAL_M32R_SIO=y
+CONFIG_SERIAL_M32R_SIO_CONSOLE=y
 CONFIG_SERIAL_M32R_PLDSIO=y
-CONFIG_SERIAL_M32R_PLDSIO_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -387,6 +443,7 @@
 # CONFIG_WATCHDOG is not set
 # CONFIG_RTC is not set
 # CONFIG_GEN_RTC is not set
+CONFIG_DS1302=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
@@ -429,8 +486,8 @@
 # Video Adapters
 #
 # CONFIG_VIDEO_CPIA is not set
-CONFIG_M32R_AR=y
-CONFIG_M32R_AR_VGA=y
+CONFIG_VIDEO_M32R_AR=y
+CONFIG_VIDEO_M32R_AR_M64278=y
 
 #
 # Radio Adapters
@@ -445,7 +502,28 @@
 #
 # Graphics support
 #
-# CONFIG_FB is not set
+CONFIG_FB=y
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
 
 #
 # Sound
@@ -455,6 +533,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -482,6 +562,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -515,6 +596,7 @@
 # CONFIG_DEVFS_DEBUG is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -549,6 +631,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -620,6 +703,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/m32r/kernel/io_m32700ut.c b/arch/m32r/kernel/io_m32700ut.c
--- a/arch/m32r/kernel/io_m32700ut.c	2004-12-24 13:37:00 -08:00
+++ b/arch/m32r/kernel/io_m32700ut.c	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,5 @@
 /*
- *  linux/arch/m32r/kernel/io_mappi.c
+ *  linux/arch/m32r/kernel/io_m32700ut.c
  *
  *  Typical I/O routines for M32700UT board.
  *
@@ -9,7 +9,6 @@
  *  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 <linux/config.h>
@@ -32,16 +31,16 @@
 extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int);
 #endif /* CONFIG_PCMCIA && CONFIG_M32R_CFC */
 
-#define PORT2ADDR(port)  _port2addr(port)
-#define PORT2ADDR_USB(port) _port2addr_usb(port)
+#define PORT2ADDR(port)		_port2addr(port)
+#define PORT2ADDR_USB(port)	_port2addr_usb(port)
 
-static __inline__ void *_port2addr(unsigned long port)
+static inline void *_port2addr(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET);
 }
 
 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
-static __inline__ void *__port2addr_ata(unsigned long port)
+static inline void *__port2addr_ata(unsigned long port)
 {
 	static int	dummy_reg;
 
@@ -67,16 +66,16 @@
  */
 #define LAN_IOSTART	0x300
 #define LAN_IOEND	0x320
-static __inline__ void *_port2addr_ne(unsigned long port)
+static inline void *_port2addr_ne(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET + 0x10000000);
 }
-static __inline__ void *_port2addr_usb(unsigned long port)
+static inline void *_port2addr_usb(unsigned long port)
 {
-  return (void *)((port & 0x0f) + NONCACHE_OFFSET + 0x10303000);
+	return (void *)((port & 0x0f) + NONCACHE_OFFSET + 0x10303000);
 }
 
-static __inline__ void delay(void)
+static inline void delay(void)
 {
 	__asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
 }
@@ -87,29 +86,30 @@
 
 #define PORT2ADDR_NE(port)  _port2addr_ne(port)
 
-static __inline__ unsigned char _ne_inb(void *portp)
+static inline unsigned char _ne_inb(void *portp)
 {
 	return *(volatile unsigned char *)portp;
 }
 
-static __inline__ unsigned short _ne_inw(void *portp)
+static inline unsigned short _ne_inw(void *portp)
 {
 	return (unsigned short)le16_to_cpu(*(volatile unsigned short *)portp);
 }
 
-static __inline__ void _ne_insb(void *portp, void * addr, unsigned long count)
+static inline void _ne_insb(void *portp, void *addr, unsigned long count)
 {
 	unsigned char *buf = (unsigned char *)addr;
 
-	while (count--) *buf++ = _ne_inb(portp);
+	while (count--)
+		*buf++ = _ne_inb(portp);
 }
 
-static __inline__ void _ne_outb(unsigned char b, void *portp)
+static inline void _ne_outb(unsigned char b, void *portp)
 {
 	*(volatile unsigned char *)portp = b;
 }
 
-static __inline__ void _ne_outw(unsigned short w, void *portp)
+static inline void _ne_outw(unsigned short w, void *portp)
 {
 	*(volatile unsigned short *)portp = cpu_to_le16(w);
 }
@@ -126,9 +126,9 @@
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned char b;
-	   pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
-	   return b;
+		unsigned char b;
+		pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
+		return b;
 	} else
 #endif
 
@@ -146,13 +146,13 @@
 #endif
 #if defined(CONFIG_USB)
 	else if(port >= 0x340 && port < 0x3a0)
-	  return *(volatile unsigned short *)PORT2ADDR_USB(port);
+		return *(volatile unsigned short *)PORT2ADDR_USB(port);
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned short w;
-	   pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
-	   return w;
+		unsigned short w;
+		pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
+		return w;
 	} else
 #endif
 	return *(volatile unsigned short *)PORT2ADDR(port);
@@ -162,9 +162,9 @@
 {
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned long l;
-	   pcc_ioread_word(0, port, &l, sizeof(l), 1, 0);
-	   return l;
+		unsigned long l;
+		pcc_ioread_word(0, port, &l, sizeof(l), 1, 0);
+		return l;
 	} else
 #endif
 	return *(volatile unsigned long *)PORT2ADDR(port);
@@ -184,9 +184,9 @@
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned char b;
-	   pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
-	   return b;
+		unsigned char b;
+		pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
+		return b;
 	} else
 #endif
 		v = *(volatile unsigned char *)PORT2ADDR(port);
@@ -208,15 +208,15 @@
 	} else
 #endif
 #if defined(CONFIG_USB)
-	  if(port >= 0x340 && port < 0x3a0)
-	    return *(volatile unsigned short *)PORT2ADDR_USB(port);
+	if(port >= 0x340 && port < 0x3a0)
+		return *(volatile unsigned short *)PORT2ADDR_USB(port);
 	else
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned short w;
-	   pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
-	   return w;
+		unsigned short w;
+		pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
+		return w;
 	} else
 #endif
 		v = *(volatile unsigned short *)PORT2ADDR(port);
@@ -246,7 +246,7 @@
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
 	} else
 #endif
 		*(volatile unsigned char *)PORT2ADDR(port) = b;
@@ -264,12 +264,12 @@
 #endif
 #if defined(CONFIG_USB)
 	if(port >= 0x340 && port < 0x3a0)
-	  *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
+		*(volatile unsigned short *)PORT2ADDR_USB(port) = w;
 	else
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
 	} else
 #endif
 		*(volatile unsigned short *)PORT2ADDR(port) = w;
@@ -279,7 +279,7 @@
 {
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0);
+		pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0);
 	} else
 #endif
 	*(volatile unsigned long *)PORT2ADDR(port) = l;
@@ -297,7 +297,7 @@
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
 	} else
 #endif
 		*(volatile unsigned char *)PORT2ADDR(port) = b;
@@ -316,13 +316,13 @@
 	} else
 #endif
 #if defined(CONFIG_USB)
-	  if(port >= 0x340 && port < 0x3a0)
-	    *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
+	if(port >= 0x340 && port < 0x3a0)
+		*(volatile unsigned short *)PORT2ADDR_USB(port) = w;
 	else
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
 	} else
 #endif
 		*(volatile unsigned short *)PORT2ADDR(port) = w;
@@ -336,7 +336,7 @@
 	delay();
 }
 
-void _insb(unsigned int port, void * addr, unsigned long count)
+void _insb(unsigned int port, void *addr, unsigned long count)
 {
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		_ne_insb(PORT2ADDR_NE(port), addr, count);
@@ -344,22 +344,25 @@
 	else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
 		unsigned char *buf = addr;
 		unsigned char *portp = __port2addr_ata(port);
-		while(count--) *buf++ = *(volatile unsigned char *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
 	}
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
-	  else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char), count, 1);
+	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
+		pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char),
+				count, 1);
 	}
 #endif
 	else {
 		unsigned char *buf = addr;
 		unsigned char *portp = PORT2ADDR(port);
-		while(count--) *buf++ = *(volatile unsigned char *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
 	}
 }
 
-void _insw(unsigned int port, void * addr, unsigned long count)
+void _insw(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned short *buf = addr;
 	unsigned short *portp;
@@ -370,55 +373,64 @@
 		 * from the DATA_REG. Do not swap the data.
 		 */
 		portp = PORT2ADDR_NE(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short),
+				count, 1);
 #endif
 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
 	} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
 		portp = __port2addr_ata(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 	}
 }
 
-void _insl(unsigned int port, void * addr, unsigned long count)
+void _insl(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned long *buf = addr;
 	unsigned long *portp;
 
 	portp = PORT2ADDR(port);
-	while (count--) *buf++ = *(volatile unsigned long *)portp;
+	while (count--)
+		*buf++ = *(volatile unsigned long *)portp;
 }
 
-void _outsb(unsigned int port, const void * addr, unsigned long count)
+void _outsb(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned char *buf = addr;
 	unsigned char *portp;
 
 	if (port >= LAN_IOSTART && port < LAN_IOEND) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) _ne_outb(*buf++, portp);
+		while (count--)
+			_ne_outb(*buf++, portp);
 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
 	} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
 		portp = __port2addr_ata(port);
-		while(count--) *(volatile unsigned char *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned char *)portp = *buf++;
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char), count, 1);
+		pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char),
+				 count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned char *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned char *)portp = *buf++;
 	}
 }
 
-void _outsw(unsigned int port, const void * addr, unsigned long count)
+void _outsw(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned short *buf = addr;
 	unsigned short *portp;
@@ -429,27 +441,32 @@
 		 * into the DATA_REG. Do not swap the data.
 		 */
 		portp = PORT2ADDR_NE(port);
-		while(count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
 	} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
 		portp = __port2addr_ata(port);
-		while(count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short),
+				 count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
 	}
 }
 
-void _outsl(unsigned int port, const void * addr, unsigned long count)
+void _outsl(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned long *buf = addr;
 	unsigned char *portp;
 
 	portp = PORT2ADDR(port);
-	while(count--) *(volatile unsigned long *)portp = *buf++;
+	while (count--)
+		*(volatile unsigned long *)portp = *buf++;
 }
diff -Nru a/arch/m32r/kernel/io_mappi.c b/arch/m32r/kernel/io_mappi.c
--- a/arch/m32r/kernel/io_mappi.c	2004-12-24 13:36:31 -08:00
+++ b/arch/m32r/kernel/io_mappi.c	2004-12-24 13:36:31 -08:00
@@ -7,15 +7,13 @@
  *                            Hitoshi Yamamoto
  */
 
-/* $Id: io_mappi.c,v 1.9 2003/12/02 07:18:08 fujiwara Exp $ */
-
 #include <linux/config.h>
 #include <asm/m32r.h>
 #include <asm/page.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 #include <linux/types.h>
 
 #define M32R_PCC_IOMAP_SIZE 0x1000
@@ -27,21 +25,21 @@
 
 extern void pcc_ioread(int, unsigned long, void *, size_t, size_t, int);
 extern void pcc_iowrite(int, unsigned long, void *, size_t, size_t, int);
-#endif /* CONFIG_PCMCIA && CONFIG_M32RPCC */
+#endif /* CONFIG_PCMCIA && CONFIG_M32R_PCC */
 
 #define PORT2ADDR(port)  _port2addr(port)
 
-static __inline__ void *_port2addr(unsigned long port)
+static inline void *_port2addr(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET);
 }
 
-static __inline__ void *_port2addr_ne(unsigned long port)
+static inline void *_port2addr_ne(unsigned long port)
 {
 	return (void *)((port<<1) + NONCACHE_OFFSET + 0x0C000000);
 }
 
-static __inline__ void delay(void)
+static inline void delay(void)
 {
 	__asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
 }
@@ -52,12 +50,12 @@
 
 #define PORT2ADDR_NE(port)  _port2addr_ne(port)
 
-static __inline__ unsigned char _ne_inb(void *portp)
+static inline unsigned char _ne_inb(void *portp)
 {
 	return (unsigned char) *(volatile unsigned short *)portp;
 }
 
-static __inline__ unsigned short _ne_inw(void *portp)
+static inline unsigned short _ne_inw(void *portp)
 {
 	unsigned short tmp;
 
@@ -65,12 +63,12 @@
 	return le16_to_cpu(tmp);
 }
 
-static __inline__ void _ne_outb(unsigned char b, void *portp)
+static inline void _ne_outb(unsigned char b, void *portp)
 {
 	*(volatile unsigned short *)portp = (unsigned short)b;
 }
 
-static __inline__ void _ne_outw(unsigned short w, void *portp)
+static inline void _ne_outw(unsigned short w, void *portp)
 {
 	*(volatile unsigned short *)portp = cpu_to_le16(w);
 }
@@ -80,15 +78,15 @@
 	if (port >= 0x300 && port < 0x320)
 		return _ne_inb(PORT2ADDR_NE(port));
 	else
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
         if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned char b;
-	   pcc_ioread(0, port, &b, sizeof(b), 1, 0);
-	   return b;
-	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	  unsigned char b;
-	   pcc_ioread(1, port, &b, sizeof(b), 1, 0);
-	   return b;
+		unsigned char b;
+		pcc_ioread(0, port, &b, sizeof(b), 1, 0);
+		return b;
+	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
+		unsigned char b;
+		pcc_ioread(1, port, &b, sizeof(b), 1, 0);
+		return b;
 	} else
 #endif
 
@@ -100,15 +98,15 @@
 	if (port >= 0x300 && port < 0x320)
 		return _ne_inw(PORT2ADDR_NE(port));
 	else
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned short w;
-	   pcc_ioread(0, port, &w, sizeof(w), 1, 0);
-	   return w;
-	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   unsigned short w;
-	   pcc_ioread(1, port, &w, sizeof(w), 1, 0);
-	   return w;
+		unsigned short w;
+		pcc_ioread(0, port, &w, sizeof(w), 1, 0);
+		return w;
+	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
+		unsigned short w;
+		pcc_ioread(1, port, &w, sizeof(w), 1, 0);
+		return w;
 	} else
 #endif
 	return *(volatile unsigned short *)PORT2ADDR(port);
@@ -116,15 +114,15 @@
 
 unsigned long _inl(unsigned long port)
 {
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned long l;
-	   pcc_ioread(0, port, &l, sizeof(l), 1, 0);
-	   return l;
-	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   unsigned short l;
-	   pcc_ioread(1, port, &l, sizeof(l), 1, 0);
-	   return l;
+		unsigned long l;
+		pcc_ioread(0, port, &l, sizeof(l), 1, 0);
+		return l;
+	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
+		unsigned short l;
+		pcc_ioread(1, port, &l, sizeof(l), 1, 0);
+		return l;
 	} else
 #endif
 	return *(volatile unsigned long *)PORT2ADDR(port);
@@ -137,15 +135,15 @@
 	if (port >= 0x300 && port < 0x320)
 		v = _ne_inb(PORT2ADDR_NE(port));
 	else
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned char b;
-	   pcc_ioread(0, port, &b, sizeof(b), 1, 0);
-	   return b;
-	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	  unsigned char b;
-	   pcc_ioread(1, port, &b, sizeof(b), 1, 0);
-	   return b;
+		unsigned char b;
+		pcc_ioread(0, port, &b, sizeof(b), 1, 0);
+		return b;
+	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
+		unsigned char b;
+		pcc_ioread(1, port, &b, sizeof(b), 1, 0);
+		return b;
 	} else
 #endif
 		v = *(volatile unsigned char *)PORT2ADDR(port);
@@ -161,15 +159,15 @@
 	if (port >= 0x300 && port < 0x320)
 		v = _ne_inw(PORT2ADDR_NE(port));
 	else
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned short w;
-	   pcc_ioread(0, port, &w, sizeof(w), 1, 0);
-	   return w;
-	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   unsigned short w;
-	   pcc_ioread(1, port, &w, sizeof(w), 1, 0);
-	   return w;
+		unsigned short w;
+		pcc_ioread(0, port, &w, sizeof(w), 1, 0);
+		return w;
+	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
+		unsigned short w;
+		pcc_ioread(1, port, &w, sizeof(w), 1, 0);
+		return w;
 	} else
 #endif
 		v = *(volatile unsigned short *)PORT2ADDR(port);
@@ -192,11 +190,11 @@
 	if (port >= 0x300 && port < 0x320)
 		_ne_outb(b, PORT2ADDR_NE(port));
 	else
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite(0, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite(0, port, &b, sizeof(b), 1, 0);
 	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_iowrite(1, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite(1, port, &b, sizeof(b), 1, 0);
 	} else
 #endif
 		*(volatile unsigned char *)PORT2ADDR(port) = b;
@@ -207,11 +205,11 @@
 	if (port >= 0x300 && port < 0x320)
 		_ne_outw(w, PORT2ADDR_NE(port));
 	else
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite(0, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite(0, port, &w, sizeof(w), 1, 0);
 	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_iowrite(1, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite(1, port, &w, sizeof(w), 1, 0);
 	} else
 #endif
 		*(volatile unsigned short *)PORT2ADDR(port) = w;
@@ -219,11 +217,11 @@
 
 void _outl(unsigned long l, unsigned long port)
 {
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite(0, port, &l, sizeof(l), 1, 0);
+		pcc_iowrite(0, port, &l, sizeof(l), 1, 0);
 	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_iowrite(1, port, &l, sizeof(l), 1, 0);
+		pcc_iowrite(1, port, &l, sizeof(l), 1, 0);
 	} else
 #endif
 	*(volatile unsigned long *)PORT2ADDR(port) = l;
@@ -234,11 +232,11 @@
 	if (port >= 0x300 && port < 0x320)
 		_ne_outb(b, PORT2ADDR_NE(port));
 	else
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite(0, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite(0, port, &b, sizeof(b), 1, 0);
 	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_iowrite(1, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite(1, port, &b, sizeof(b), 1, 0);
 	} else
 #endif
 		*(volatile unsigned char *)PORT2ADDR(port) = b;
@@ -251,11 +249,11 @@
 	if (port >= 0x300 && port < 0x320)
 		_ne_outw(w, PORT2ADDR_NE(port));
 	else
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite(0, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite(0, port, &w, sizeof(w), 1, 0);
 	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_iowrite(1, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite(1, port, &w, sizeof(w), 1, 0);
 	} else
 #endif
 		*(volatile unsigned short *)PORT2ADDR(port) = w;
@@ -269,100 +267,118 @@
 	delay();
 }
 
-void _insb(unsigned int port, void * addr, unsigned long count)
+void _insb(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned short *buf = addr;
 	unsigned short *portp;
 
 	if (port >= 0x300 && port < 0x320){
 		portp = PORT2ADDR_NE(port);
-		while(count--) *buf++ = *(volatile unsigned char *)portp;
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_ioread(0, port, (void *)addr, sizeof(unsigned char), count, 1);
+		pcc_ioread(0, port, (void *)addr, sizeof(unsigned char),
+			   count, 1);
 	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_ioread(1, port, (void *)addr, sizeof(unsigned char), count, 1);
+		pcc_ioread(1, port, (void *)addr, sizeof(unsigned char),
+			   count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *buf++ = *(volatile unsigned char *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
 	}
 }
 
-void _insw(unsigned int port, void * addr, unsigned long count)
+void _insw(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned short *buf = addr;
 	unsigned short *portp;
 
 	if (port >= 0x300 && port < 0x320) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) *buf++ = _ne_inw(portp);
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+		while (count--)
+			*buf++ = _ne_inw(portp);
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_ioread(0, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_ioread(0, port, (void *)addr, sizeof(unsigned short),
+			   count, 1);
 	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_ioread(1, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_ioread(1, port, (void *)addr, sizeof(unsigned short),
+			   count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 	}
 }
 
-void _insl(unsigned int port, void * addr, unsigned long count)
+void _insl(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned long *buf = addr;
 	unsigned long *portp;
 
 	portp = PORT2ADDR(port);
-	while (count--) *buf++ = *(volatile unsigned long *)portp;
+	while (count--)
+		*buf++ = *(volatile unsigned long *)portp;
 }
 
-void _outsb(unsigned int port, const void * addr, unsigned long count)
+void _outsb(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned char *buf = addr;
 	unsigned char *portp;
 
 	if (port >= 0x300 && port < 0x320) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) _ne_outb(*buf++, portp);
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+		while (count--)
+			_ne_outb(*buf++, portp);
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite(0, port, (void *)addr, sizeof(unsigned char), count, 1);
+		pcc_iowrite(0, port, (void *)addr, sizeof(unsigned char),
+			    count, 1);
 	} else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_iowrite(1, port, (void *)addr, sizeof(unsigned char), count, 1);
+		pcc_iowrite(1, port, (void *)addr, sizeof(unsigned char),
+			    count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned char *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned char *)portp = *buf++;
 	}
 }
 
-void _outsw(unsigned int port, const void * addr, unsigned long count)
+void _outsw(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned short *buf = addr;
 	unsigned short *portp;
 
 	if (port >= 0x300 && port < 0x320) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) _ne_outw(*buf++, portp);
-#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32RPCC)
+		while (count--)
+			_ne_outw(*buf++, portp);
+#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite(0, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_iowrite(0, port, (void *)addr, sizeof(unsigned short),
+			    count, 1);
 	} else 	if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
-	   pcc_iowrite(1, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_iowrite(1, port, (void *)addr, sizeof(unsigned short),
+			    count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
 	}
 }
 
-void _outsl(unsigned int port, const void * addr, unsigned long count)
+void _outsl(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned long *buf = addr;
 	unsigned char *portp;
 
 	portp = PORT2ADDR(port);
-	while(count--) *(volatile unsigned long *)portp = *buf++;
+	while (count--)
+		*(volatile unsigned long *)portp = *buf++;
 }
diff -Nru a/arch/m32r/kernel/io_mappi2.c b/arch/m32r/kernel/io_mappi2.c
--- a/arch/m32r/kernel/io_mappi2.c	2004-12-24 13:37:29 -08:00
+++ b/arch/m32r/kernel/io_mappi2.c	2004-12-24 13:37:29 -08:00
@@ -4,15 +4,14 @@
  *  Typical I/O routines for Mappi2 board.
  *
  *  Copyright (c) 2001-2003  Hiroyuki Kondo, Hirokazu Takata,
- *                            Hitoshi Yamamoto, Mamoru Sakugawa
+ *                           Hitoshi Yamamoto, Mamoru Sakugawa
  */
 
-/* $Id:$ */
-
 #include <linux/config.h>
 #include <asm/m32r.h>
 #include <asm/page.h>
 #include <asm/io.h>
+#include <asm/byteorder.h>
 
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 #include <linux/types.h>
@@ -32,29 +31,50 @@
 #define PORT2ADDR_NE(port)   _port2addr_ne(port)
 #define PORT2ADDR_USB(port)  _port2addr_usb(port)
 
-static __inline__ void *_port2addr(unsigned long port)
+static inline void *_port2addr(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET);
 }
 
 #define LAN_IOSTART	0x300
 #define LAN_IOEND	0x320
+
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+static inline void *__port2addr_ata(unsigned long port)
+{
+	static int	dummy_reg;
+
+	switch (port) {
+	case 0x1f0:	return (void *)0xac002000;
+	case 0x1f1:	return (void *)0xac012800;
+	case 0x1f2:	return (void *)0xac012002;
+	case 0x1f3:	return (void *)0xac012802;
+	case 0x1f4:	return (void *)0xac012004;
+	case 0x1f5:	return (void *)0xac012804;
+	case 0x1f6:	return (void *)0xac012006;
+	case 0x1f7:	return (void *)0xac012806;
+	case 0x3f6:	return (void *)0xac01200e;
+	default: 	return (void *)&dummy_reg;
+	}
+}
+#endif
+
 #ifdef CONFIG_CHIP_OPSP
-static __inline__ void *_port2addr_ne(unsigned long port)
+static inline void *_port2addr_ne(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET + 0x10000000);
 }
 #else
-static __inline__ void *_port2addr_ne(unsigned long port)
+static inline void *_port2addr_ne(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET + 0x04000000);
 }
 #endif
-static __inline__ void *_port2addr_usb(unsigned long port)
+static inline void *_port2addr_usb(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET + 0x14000000);
 }
-static __inline__ void delay(void)
+static inline void delay(void)
 {
 	__asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
 }
@@ -63,51 +83,48 @@
  * NIC I/O function
  */
 
-static __inline__ unsigned char _ne_inb(void *portp)
+static inline unsigned char _ne_inb(void *portp)
 {
 	return (unsigned char) *(volatile unsigned char *)portp;
 }
 
-static __inline__ unsigned short _ne_inw(void *portp)
+static inline unsigned short _ne_inw(void *portp)
 {
-#if 1  /* byte swap */
-	unsigned short tmp,tmp2;
-	tmp = *(volatile unsigned short *)portp;
-	tmp2 = (tmp>>8|tmp<<8);
-	return tmp2;
-#else
-	return *(volatile unsigned short *)portp;
-#endif
+	return (unsigned short)le16_to_cpu(*(volatile unsigned short *)portp);
 }
 
-static __inline__ void _ne_insb(void *portp, void * addr, unsigned long count)
+static inline void _ne_insb(void *portp, void * addr, unsigned long count)
 {
-	unsigned short tmp;
 	unsigned char *buf = addr;
 
-	tmp = *(volatile unsigned char *)portp;
-	while (count--) *buf++ = *(volatile unsigned char *)portp;
+	while (count--)
+		*buf++ = *(volatile unsigned char *)portp;
 }
 
-static __inline__ void _ne_outb(unsigned char b, void *portp)
+static inline void _ne_outb(unsigned char b, void *portp)
 {
 	*(volatile unsigned char *)portp = (unsigned char)b;
 }
 
-static __inline__ void _ne_outw(unsigned short w, void *portp)
+static inline void _ne_outw(unsigned short w, void *portp)
 {
-	*(volatile unsigned short *)portp = (w>>8|w<<8);
+	*(volatile unsigned short *)portp = cpu_to_le16(w);
 }
 
 unsigned char _inb(unsigned long port)
 {
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		return _ne_inb(PORT2ADDR_NE(port));
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		return *(volatile unsigned char *)__port2addr_ata(port);
+	}
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned char b;
-	   pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
-	   return b;
+		unsigned char b;
+		pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
+		return b;
 	} else
 #endif
 
@@ -118,16 +135,21 @@
 {
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		return _ne_inw(PORT2ADDR_NE(port));
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		return *(volatile unsigned short *)__port2addr_ata(port);
+	}
+#endif
 #if defined(CONFIG_USB)
-        else if (port >= 0x340 && port < 0x3a0)
-	  return *(volatile unsigned short *)PORT2ADDR_USB(port);
+	else if (port >= 0x340 && port < 0x3a0)
+		return *(volatile unsigned short *)PORT2ADDR_USB(port);
 #endif
 
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
-	  else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned short w;
-	   pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
-	   return w;
+	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
+		unsigned short w;
+		pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
+		return w;
 	} else
 #endif
 	return *(volatile unsigned short *)PORT2ADDR(port);
@@ -137,9 +159,9 @@
 {
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned long l;
-	   pcc_ioread_word(0, port, &l, sizeof(l), 1, 0);
-	   return l;
+		unsigned long l;
+		pcc_ioread_word(0, port, &l, sizeof(l), 1, 0);
+		return l;
 	} else
 #endif
 	return *(volatile unsigned long *)PORT2ADDR(port);
@@ -149,14 +171,19 @@
 {
 	unsigned char  v;
 
-	if (port >= 0x300 && port < 0x320)
+	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		v = _ne_inb(PORT2ADDR_NE(port));
 	else
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		return *(volatile unsigned char *)__port2addr_ata(port);
+	} else
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned char b;
-	   pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
-	   return b;
+		unsigned char b;
+		pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
+		return b;
 	} else
 #endif
 		v = *(volatile unsigned char *)PORT2ADDR(port);
@@ -169,19 +196,24 @@
 {
 	unsigned short  v;
 
-	if (port >= 0x300 && port < 0x320)
+	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		v = _ne_inw(PORT2ADDR_NE(port));
 	else
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		return *(volatile unsigned short *)__port2addr_ata(port);
+	} else
+#endif
 #if defined(CONFIG_USB)
-	  if (port >= 0x340 && port < 0x3a0)
+	if (port >= 0x340 && port < 0x3a0)
 		v = *(volatile unsigned short *)PORT2ADDR_USB(port);
-	  else
+	else
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned short w;
-	   pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
-	   return w;
+		unsigned short w;
+		pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
+		return w;
 	} else
 #endif
 		v = *(volatile unsigned short *)PORT2ADDR(port);
@@ -204,9 +236,14 @@
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		_ne_outb(b, PORT2ADDR_NE(port));
 	else
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		*(volatile unsigned char *)__port2addr_ata(port) = b;
+	} else
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
 	} else
 #endif
 		*(volatile unsigned char *)PORT2ADDR(port) = b;
@@ -217,14 +254,19 @@
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		_ne_outw(w, PORT2ADDR_NE(port));
 	else
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		*(volatile unsigned short *)__port2addr_ata(port) = w;
+	} else
+#endif
 #if defined(CONFIG_USB)
-	  if (port >= 0x340 && port < 0x3a0)
-	    *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
+	if (port >= 0x340 && port < 0x3a0)
+		*(volatile unsigned short *)PORT2ADDR_USB(port) = w;
 	else
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
 	} else
 #endif
 		*(volatile unsigned short *)PORT2ADDR(port) = w;
@@ -234,7 +276,7 @@
 {
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0);
+		pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0);
 	} else
 #endif
 	*(volatile unsigned long *)PORT2ADDR(port) = l;
@@ -245,9 +287,14 @@
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		_ne_outb(b, PORT2ADDR_NE(port));
 	else
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		*(volatile unsigned char *)__port2addr_ata(port) = b;
+	} else
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
 	} else
 #endif
 		*(volatile unsigned char *)PORT2ADDR(port) = b;
@@ -260,6 +307,11 @@
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		_ne_outw(w, PORT2ADDR_NE(port));
 	else
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		*(volatile unsigned short *)__port2addr_ata(port) = w;
+	} else
+#endif
 #if defined(CONFIG_USB)
 	  if (port >= 0x340 && port < 0x3a0)
 		*(volatile unsigned short *)PORT2ADDR_USB(port) = w;
@@ -267,7 +319,7 @@
 #endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
 	} else
 #endif
 		*(volatile unsigned short *)PORT2ADDR(port) = w;
@@ -285,15 +337,25 @@
 {
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		_ne_insb(PORT2ADDR_NE(port), addr, count);
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		unsigned char *buf = addr;
+		unsigned char *portp = __port2addr_ata(port);
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
+	}
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
-	  else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char), count, 1);
+	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
+		pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char),
+				count, 1);
 	}
 #endif
 	else {
 		unsigned char *buf = addr;
 		unsigned char *portp = PORT2ADDR(port);
-		while(count--) *buf++ = *(volatile unsigned char *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
 	}
 }
 
@@ -302,16 +364,25 @@
 	unsigned short *buf = addr;
 	unsigned short *portp;
 
-	if (port >= LAN_IOSTART && port < LAN_IOEND)
+	if (port >= LAN_IOSTART && port < LAN_IOEND) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short),
+				count, 1);
+#endif
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		portp = __port2addr_ata(port);
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 	}
 }
 
@@ -321,7 +392,8 @@
 	unsigned long *portp;
 
 	portp = PORT2ADDR(port);
-	while (count--) *buf++ = *(volatile unsigned long *)portp;
+	while (count--)
+		*buf++ = *(volatile unsigned long *)portp;
 }
 
 void _outsb(unsigned int port, const void * addr, unsigned long count)
@@ -329,16 +401,25 @@
 	const unsigned char *buf = addr;
 	unsigned char *portp;
 
-	if (port >= LAN_IOSTART && port < LAN_IOEND)
+	if (port >= LAN_IOSTART && port < LAN_IOEND) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) _ne_outb(*buf++, portp);
+		while (count--)
+			_ne_outb(*buf++, portp);
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		portp = __port2addr_ata(port);
+		while (count--)
+			*(volatile unsigned char *)portp = *buf++;
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char), count, 1);
+		pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char),
+				 count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned char *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned char *)portp = *buf++;
 	}
 }
 
@@ -347,16 +428,25 @@
 	const unsigned short *buf = addr;
 	unsigned short *portp;
 
-	if (port >= LAN_IOSTART && port < LAN_IOEND)
+	if (port >= LAN_IOSTART && port < LAN_IOEND) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
+#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
+	} else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
+		portp = __port2addr_ata(port);
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
+#endif
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short),
+				 count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
 	}
 }
 
@@ -366,5 +456,6 @@
 	unsigned char *portp;
 
 	portp = PORT2ADDR(port);
-	while(count--) *(volatile unsigned long *)portp = *buf++;
+	while (count--)
+		*(volatile unsigned long *)portp = *buf++;
 }
diff -Nru a/arch/m32r/kernel/io_oaks32r.c b/arch/m32r/kernel/io_oaks32r.c
--- a/arch/m32r/kernel/io_oaks32r.c	2004-12-24 13:37:30 -08:00
+++ b/arch/m32r/kernel/io_oaks32r.c	2004-12-24 13:37:30 -08:00
@@ -4,11 +4,9 @@
  *  Typical I/O routines for OAKS32R board.
  *
  *  Copyright (c) 2001-2004  Hiroyuki Kondo, Hirokazu Takata,
- *                            Hitoshi Yamamoto, Mamoru Sakugawa
+ *                           Hitoshi Yamamoto, Mamoru Sakugawa
  */
 
-/* $Id$ */
-
 #include <linux/config.h>
 #include <asm/m32r.h>
 #include <asm/page.h>
@@ -16,17 +14,17 @@
 
 #define PORT2ADDR(port)  _port2addr(port)
 
-static __inline__ void *_port2addr(unsigned long port)
+static inline void *_port2addr(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET);
 }
 
-static __inline__  void *_port2addr_ne(unsigned long port)
+static inline  void *_port2addr_ne(unsigned long port)
 {
 	return (void *)((port<<1) + NONCACHE_OFFSET + 0x02000000);
 }
 
-static __inline__ void delay(void)
+static inline void delay(void)
 {
 	__asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
 }
@@ -37,12 +35,12 @@
 
 #define PORT2ADDR_NE(port)  _port2addr_ne(port)
 
-static __inline__ unsigned char _ne_inb(void *portp)
+static inline unsigned char _ne_inb(void *portp)
 {
 	return *(volatile unsigned char *)(portp+1);
 }
 
-static __inline__ unsigned short _ne_inw(void *portp)
+static inline unsigned short _ne_inw(void *portp)
 {
 	unsigned short tmp;
 
@@ -51,21 +49,22 @@
 	return tmp;
 }
 
-static __inline__  void _ne_insb(void *portp, void * addr, unsigned long count)
+static inline  void _ne_insb(void *portp, void *addr, unsigned long count)
 {
 	unsigned char *buf = addr;
-	while (count--) *buf++ = *(volatile unsigned char *)(portp+1);
+	while (count--)
+		*buf++ = *(volatile unsigned char *)(portp+1);
 }
 
-static __inline__ void _ne_outb(unsigned char b, void *portp)
+static inline void _ne_outb(unsigned char b, void *portp)
 {
 	*(volatile unsigned char *)(portp+1) = b;
 }
 
-static __inline__ void _ne_outw(unsigned short w, void *portp)
+static inline void _ne_outw(unsigned short w, void *portp)
 {
-  *(volatile unsigned short *)portp =  (w >> 8);
-  *(volatile unsigned short *)(portp+2) =  (w & 0xff);
+	*(volatile unsigned short *)portp =  (w >> 8);
+	*(volatile unsigned short *)(portp+2) =  (w & 0xff);
 }
 
 unsigned char _inb(unsigned long port)
@@ -171,73 +170,82 @@
 	delay();
 }
 
-void _insb(unsigned int port, void * addr, unsigned long count)
+void _insb(unsigned int port, void *addr, unsigned long count)
 {
 	if (port >= 0x300 && port < 0x320)
 		_ne_insb(PORT2ADDR_NE(port), addr, count);
 	else {
 		unsigned char *buf = addr;
 		unsigned char *portp = PORT2ADDR(port);
-		while(count--) *buf++ = *(volatile unsigned char *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
 	}
 }
 
-void _insw(unsigned int port, void * addr, unsigned long count)
+void _insw(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned short *buf = addr;
 	unsigned short *portp;
 
 	if (port >= 0x300 && port < 0x320) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) *buf++ = _ne_inw(portp);
+		while (count--)
+			*buf++ = _ne_inw(portp);
 	} else {
 		portp = PORT2ADDR(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 	}
 }
 
-void _insl(unsigned int port, void * addr, unsigned long count)
+void _insl(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned long *buf = addr;
 	unsigned long *portp;
 
 	portp = PORT2ADDR(port);
-	while (count--) *buf++ = *(volatile unsigned long *)portp;
+	while (count--)
+		*buf++ = *(volatile unsigned long *)portp;
 }
 
-void _outsb(unsigned int port, const void * addr, unsigned long count)
+void _outsb(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned char *buf = addr;
 	unsigned char *portp;
 
 	if (port >= 0x300 && port < 0x320) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) _ne_outb(*buf++, portp);
+		while (count--)
+			_ne_outb(*buf++, portp);
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned char *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned char *)portp = *buf++;
 	}
 }
 
-void _outsw(unsigned int port, const void * addr, unsigned long count)
+void _outsw(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned short *buf = addr;
 	unsigned short *portp;
 
 	if (port >= 0x300 && port < 0x320) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) _ne_outw(*buf++, portp);
+		while (count--)
+			_ne_outw(*buf++, portp);
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
 	}
 }
 
-void _outsl(unsigned int port, const void * addr, unsigned long count)
+void _outsl(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned long *buf = addr;
 	unsigned char *portp;
 
 	portp = PORT2ADDR(port);
-	while(count--) *(volatile unsigned long *)portp = *buf++;
+	while (count--)
+		*(volatile unsigned long *)portp = *buf++;
 }
diff -Nru a/arch/m32r/kernel/io_opsput.c b/arch/m32r/kernel/io_opsput.c
--- a/arch/m32r/kernel/io_opsput.c	2004-12-24 13:37:00 -08:00
+++ b/arch/m32r/kernel/io_opsput.c	2004-12-24 13:37:00 -08:00
@@ -9,7 +9,6 @@
  *  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 <linux/config.h>
@@ -35,7 +34,7 @@
 #define PORT2ADDR(port)  _port2addr(port)
 #define PORT2ADDR_USB(port) _port2addr_usb(port)
 
-static __inline__ void *_port2addr(unsigned long port)
+static inline void *_port2addr(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET);
 }
@@ -47,16 +46,16 @@
  */
 #define LAN_IOSTART	0x300
 #define LAN_IOEND	0x320
-static __inline__ void *_port2addr_ne(unsigned long port)
+static inline void *_port2addr_ne(unsigned long port)
 {
 	return (void *)(port + NONCACHE_OFFSET + 0x10000000);
 }
-static __inline__ void *_port2addr_usb(unsigned long port)
+static inline void *_port2addr_usb(unsigned long port)
 {
-  return (void *)((port & 0x0f) + NONCACHE_OFFSET + 0x10303000);
+	return (void *)((port & 0x0f) + NONCACHE_OFFSET + 0x10303000);
 }
 
-static __inline__ void delay(void)
+static inline void delay(void)
 {
 	__asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
 }
@@ -67,29 +66,30 @@
 
 #define PORT2ADDR_NE(port)  _port2addr_ne(port)
 
-static __inline__ unsigned char _ne_inb(void *portp)
+static inline unsigned char _ne_inb(void *portp)
 {
 	return *(volatile unsigned char *)portp;
 }
 
-static __inline__ unsigned short _ne_inw(void *portp)
+static inline unsigned short _ne_inw(void *portp)
 {
 	return (unsigned short)le16_to_cpu(*(volatile unsigned short *)portp);
 }
 
-static __inline__ void _ne_insb(void *portp, void * addr, unsigned long count)
+static inline void _ne_insb(void *portp, void *addr, unsigned long count)
 {
 	unsigned char *buf = (unsigned char *)addr;
 
-	while (count--) *buf++ = _ne_inb(portp);
+	while (count--)
+		*buf++ = _ne_inb(portp);
 }
 
-static __inline__ void _ne_outb(unsigned char b, void *portp)
+static inline void _ne_outb(unsigned char b, void *portp)
 {
 	*(volatile unsigned char *)portp = b;
 }
 
-static __inline__ void _ne_outw(unsigned short w, void *portp)
+static inline void _ne_outw(unsigned short w, void *portp)
 {
 	*(volatile unsigned short *)portp = cpu_to_le16(w);
 }
@@ -101,9 +101,9 @@
 
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned char b;
-	   pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
-	   return b;
+		unsigned char b;
+		pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
+		return b;
 	} else
 #endif
 
@@ -116,14 +116,14 @@
 		return _ne_inw(PORT2ADDR_NE(port));
 #if defined(CONFIG_USB)
 	else if(port >= 0x340 && port < 0x3a0)
-	  return *(volatile unsigned short *)PORT2ADDR_USB(port);
+		return *(volatile unsigned short *)PORT2ADDR_USB(port);
 #endif
 
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
-	  else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned short w;
-	   pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
-	   return w;
+	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
+		unsigned short w;
+		pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
+		return w;
 	} else
 #endif
 	return *(volatile unsigned short *)PORT2ADDR(port);
@@ -133,9 +133,9 @@
 {
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned long l;
-	   pcc_ioread_word(0, port, &l, sizeof(l), 1, 0);
-	   return l;
+		unsigned long l;
+		pcc_ioread_word(0, port, &l, sizeof(l), 1, 0);
+		return l;
 	} else
 #endif
 	return *(volatile unsigned long *)PORT2ADDR(port);
@@ -150,9 +150,9 @@
 	else
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned char b;
-	   pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
-	   return b;
+		unsigned char b;
+		pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
+		return b;
 	} else
 #endif
 		v = *(volatile unsigned char *)PORT2ADDR(port);
@@ -169,16 +169,16 @@
 		v = _ne_inw(PORT2ADDR_NE(port));
 	else
 #if defined(CONFIG_USB)
-	  if(port >= 0x340 && port < 0x3a0)
-	    return *(volatile unsigned short *)PORT2ADDR_USB(port);
+	if(port >= 0x340 && port < 0x3a0)
+		return *(volatile unsigned short *)PORT2ADDR_USB(port);
 	else
 #endif
 
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   unsigned short w;
-	   pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
-	   return w;
+		unsigned short w;
+		pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
+		return w;
 	} else
 #endif
 		v = *(volatile unsigned short *)PORT2ADDR(port);
@@ -203,7 +203,7 @@
 	else
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
 	} else
 #endif
 		*(volatile unsigned char *)PORT2ADDR(port) = b;
@@ -216,13 +216,13 @@
 	else
 #if defined(CONFIG_USB)
 	if(port >= 0x340 && port < 0x3a0)
-	  *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
+		*(volatile unsigned short *)PORT2ADDR_USB(port) = w;
 	else
 #endif
 
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
 	} else
 #endif
 		*(volatile unsigned short *)PORT2ADDR(port) = w;
@@ -232,7 +232,7 @@
 {
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0);
+		pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0);
 	} else
 #endif
 	*(volatile unsigned long *)PORT2ADDR(port) = l;
@@ -245,7 +245,7 @@
 	else
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
+		pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
 	} else
 #endif
 		*(volatile unsigned char *)PORT2ADDR(port) = b;
@@ -259,14 +259,14 @@
 		_ne_outw(w, PORT2ADDR_NE(port));
 	else
 #if defined(CONFIG_USB)
-	  if(port >= 0x340 && port < 0x3a0)
-	    *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
+	if(port >= 0x340 && port < 0x3a0)
+		*(volatile unsigned short *)PORT2ADDR_USB(port) = w;
 	else
 #endif
 
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
+		pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
 	} else
 #endif
 		*(volatile unsigned short *)PORT2ADDR(port) = w;
@@ -280,23 +280,25 @@
 	delay();
 }
 
-void _insb(unsigned int port, void * addr, unsigned long count)
+void _insb(unsigned int port, void *addr, unsigned long count)
 {
 	if (port >= LAN_IOSTART && port < LAN_IOEND)
 		_ne_insb(PORT2ADDR_NE(port), addr, count);
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
-	  else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char), count, 1);
+	else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
+		pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char),
+				count, 1);
 	}
 #endif
 	else {
 		unsigned char *buf = addr;
 		unsigned char *portp = PORT2ADDR(port);
-		while(count--) *buf++ = *(volatile unsigned char *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
 	}
 }
 
-void _insw(unsigned int port, void * addr, unsigned long count)
+void _insw(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned short *buf = addr;
 	unsigned short *portp;
@@ -307,45 +309,52 @@
 		 * from the DATA_REG. Do not swap the data.
 		 */
 		portp = PORT2ADDR_NE(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short),
+				count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 	}
 }
 
-void _insl(unsigned int port, void * addr, unsigned long count)
+void _insl(unsigned int port, void *addr, unsigned long count)
 {
 	unsigned long *buf = addr;
 	unsigned long *portp;
 
 	portp = PORT2ADDR(port);
-	while (count--) *buf++ = *(volatile unsigned long *)portp;
+	while (count--)
+		*buf++ = *(volatile unsigned long *)portp;
 }
 
-void _outsb(unsigned int port, const void * addr, unsigned long count)
+void _outsb(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned char *buf = addr;
 	unsigned char *portp;
 
 	if (port >= LAN_IOSTART && port < LAN_IOEND) {
 		portp = PORT2ADDR_NE(port);
-		while (count--) _ne_outb(*buf++, portp);
+		while (count--)
+			_ne_outb(*buf++, portp);
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char), count, 1);
+		pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char),
+				 count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned char *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned char *)portp = *buf++;
 	}
 }
 
-void _outsw(unsigned int port, const void * addr, unsigned long count)
+void _outsw(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned short *buf = addr;
 	unsigned short *portp;
@@ -356,22 +365,26 @@
 		 * into the DATA_REG. Do not swap the data.
 		 */
 		portp = PORT2ADDR_NE(port);
-		while(count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
 	} else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
-	   pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short), count, 1);
+		pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short),
+				 count, 1);
 #endif
 	} else {
 		portp = PORT2ADDR(port);
-		while(count--) *(volatile unsigned short *)portp = *buf++;
+		while (count--)
+			*(volatile unsigned short *)portp = *buf++;
 	}
 }
 
-void _outsl(unsigned int port, const void * addr, unsigned long count)
+void _outsl(unsigned int port, const void *addr, unsigned long count)
 {
 	const unsigned long *buf = addr;
 	unsigned char *portp;
 
 	portp = PORT2ADDR(port);
-	while(count--) *(volatile unsigned long *)portp = *buf++;
+	while (count--)
+		*(volatile unsigned long *)portp = *buf++;
 }
diff -Nru a/arch/m32r/kernel/io_usrv.c b/arch/m32r/kernel/io_usrv.c
--- a/arch/m32r/kernel/io_usrv.c	2004-12-24 13:37:19 -08:00
+++ b/arch/m32r/kernel/io_usrv.c	2004-12-24 13:37:19 -08:00
@@ -178,7 +178,8 @@
 	else {
 		unsigned char *buf = addr;
 		unsigned char *portp = PORT2ADDR(port);
-		while(count--) *buf++ = *(volatile unsigned char *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned char *)portp;
 	}
 }
 
@@ -192,7 +193,8 @@
 			1);
 	else {
 		portp = PORT2ADDR(port);
-		while (count--) *buf++ = *(volatile unsigned short *)portp;
+		while (count--)
+			*buf++ = *(volatile unsigned short *)portp;
 	}
 }
 
diff -Nru a/arch/m32r/kernel/irq.c b/arch/m32r/kernel/irq.c
--- a/arch/m32r/kernel/irq.c	2004-12-24 13:36:49 -08:00
+++ b/arch/m32r/kernel/irq.c	2004-12-24 13:36:49 -08:00
@@ -42,12 +42,12 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/kallsyms.h>
+#include <linux/bitops.h>
 
 #include <asm/atomic.h>
 #include <asm/io.h>
 #include <asm/smp.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/delay.h>
 #include <asm/irq.h>
diff -Nru a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
--- a/arch/m32r/kernel/process.c	2004-12-24 13:37:32 -08:00
+++ b/arch/m32r/kernel/process.c	2004-12-24 13:37:32 -08:00
@@ -247,8 +247,6 @@
 	unsigned long sp = (unsigned long)tsk->thread_info + THREAD_SIZE;
 	extern void ret_from_fork(void);
 
-	tsk->set_child_tid = tsk->clear_child_tid = NULL;
-
 	/* Copy registers */
 	sp -= sizeof (struct pt_regs);
 	childregs = (struct pt_regs *)sp;
@@ -335,8 +333,11 @@
 		goto out;
 
 	error = do_execve(filename, uargv, uenvp, &regs);
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 out:
 	return error;
diff -Nru a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c
--- a/arch/m32r/kernel/ptrace.c	2004-12-24 13:37:19 -08:00
+++ b/arch/m32r/kernel/ptrace.c	2004-12-24 13:37:19 -08:00
@@ -713,7 +713,7 @@
 		ret = 0;
 		unregister_all_debug_traps(child);
 		invalidate_cache();
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		wake_up_process(child);
diff -Nru a/arch/m32r/kernel/setup_m32700ut.c b/arch/m32r/kernel/setup_m32700ut.c
--- a/arch/m32r/kernel/setup_m32700ut.c	2004-12-24 13:37:19 -08:00
+++ b/arch/m32r/kernel/setup_m32700ut.c	2004-12-24 13:37:19 -08:00
@@ -435,7 +435,7 @@
 	icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
 	enable_m32700ut_irq(M32R_IRQ_INT2);
 
-//#if defined(CONFIG_M32R_AR_VGA)
+//#if defined(CONFIG_VIDEO_M32R_AR)
 	/*
 	 * INT3# is used for AR
 	 */
@@ -445,7 +445,7 @@
 	irq_desc[M32R_IRQ_INT3].depth = 1;
 	icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
 	disable_m32700ut_irq(M32R_IRQ_INT3);
-//#endif	/* CONFIG_M32R_ARV */
+//#endif	/* CONFIG_VIDEO_M32R_AR */
 }
 
 #define LAN_IOSTART     0x300
diff -Nru a/arch/m32r/kernel/setup_mappi.c b/arch/m32r/kernel/setup_mappi.c
--- a/arch/m32r/kernel/setup_mappi.c	2004-12-24 13:37:00 -08:00
+++ b/arch/m32r/kernel/setup_mappi.c	2004-12-24 13:37:00 -08:00
@@ -140,7 +140,7 @@
 	disable_mappi_irq(M32R_IRQ_SIO1_S);
 #endif /* CONFIG_SERIAL_M32R_SIO */
 
-#if defined(CONFIG_M32RPCC)
+#if defined(CONFIG_M32R_PCC)
 	/* INT1 : pccard0 interrupt */
 	irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
 	irq_desc[M32R_IRQ_INT1].handler = &mappi_irq_type;
diff -Nru a/arch/m32r/kernel/setup_mappi2.c b/arch/m32r/kernel/setup_mappi2.c
--- a/arch/m32r/kernel/setup_mappi2.c	2004-12-24 13:36:47 -08:00
+++ b/arch/m32r/kernel/setup_mappi2.c	2004-12-24 13:36:47 -08:00
@@ -151,7 +151,6 @@
 	disable_mappi2_irq(M32R_IRQ_INT1);
 #endif /* CONFIG_USB */
 
-#if defined(CONFIG_M32R_CFC)
 	/* ICUCR40: CFC IREQ */
 	irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
 	irq_desc[PLD_IRQ_CFIREQ].handler = &mappi2_irq_type;
@@ -161,6 +160,7 @@
 	icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
 	disable_mappi2_irq(PLD_IRQ_CFIREQ);
 
+#if defined(CONFIG_M32R_CFC)
 	/* ICUCR41: CFC Insert */
 	irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
 	irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi2_irq_type;
diff -Nru a/arch/m32r/kernel/setup_opsput.c b/arch/m32r/kernel/setup_opsput.c
--- a/arch/m32r/kernel/setup_opsput.c	2004-12-24 13:36:16 -08:00
+++ b/arch/m32r/kernel/setup_opsput.c	2004-12-24 13:36:16 -08:00
@@ -439,7 +439,7 @@
 	icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
 	enable_opsput_irq(M32R_IRQ_INT2);
 
-//#if defined(CONFIG_M32R_AR_VGA)
+//#if defined(CONFIG_VIDEO_M32R_AR)
 	/*
 	 * INT3# is used for AR
 	 */
@@ -449,7 +449,7 @@
 	irq_desc[M32R_IRQ_INT3].depth = 1;
 	icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
 	disable_opsput_irq(M32R_IRQ_INT3);
-//#endif	/* CONFIG_M32R_ARV */
+//#endif	/* CONFIG_VIDEO_M32R_AR */
 }
 
 #define LAN_IOSTART     0x300
diff -Nru a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
--- a/arch/m32r/kernel/smpboot.c	2004-12-24 13:37:43 -08:00
+++ b/arch/m32r/kernel/smpboot.c	2004-12-24 13:37:43 -08:00
@@ -433,7 +433,7 @@
 	cpu_init();
 	smp_callin();
 	while (!cpu_isset(smp_processor_id(), smp_commenced_mask))
-		rep_nop();
+		cpu_relax();
 
 	smp_online();
 
@@ -482,7 +482,7 @@
 		/* Has the boot CPU finished it's STARTUP sequence ? */
 		if (cpu_isset(cpu_id, cpu_callout_map))
 			break;
-		rep_nop();
+		cpu_relax();
 	}
 
 	if (!time_before(jiffies, timeout)) {
diff -Nru a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
--- a/arch/m32r/kernel/sys_m32r.c	2004-12-24 13:37:43 -08:00
+++ b/arch/m32r/kernel/sys_m32r.c	2004-12-24 13:37:43 -08:00
@@ -57,10 +57,10 @@
 	if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
 		return -EFAULT;
 
-	spin_lock(&tas_lock);
+	_raw_spin_lock(&tas_lock);
 	oldval = *addr;
 	*addr = 1;
-	spin_unlock(&tas_lock);
+	_raw_spin_unlock(&tas_lock);
 
 	return oldval;
 }
diff -Nru a/arch/m32r/kernel/time.c b/arch/m32r/kernel/time.c
--- a/arch/m32r/kernel/time.c	2004-12-24 13:37:18 -08:00
+++ b/arch/m32r/kernel/time.c	2004-12-24 13:37:18 -08:00
@@ -193,7 +193,7 @@
  * BUG: This routine does not handle hour overflow properly; it just
  *      sets the minutes. Usually you won't notice until after reboot!
  */
-static __inline__ int set_rtc_mmss(unsigned long nowtime)
+static inline int set_rtc_mmss(unsigned long nowtime)
 {
 	return 0;
 }
@@ -205,11 +205,17 @@
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
  */
-static __inline__ void do_timer_interrupt(int irq, void *dev_id,
-	struct pt_regs * regs)
+static inline void
+do_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
+#ifndef CONFIG_SMP
+	profile_tick(CPU_PROFILING, regs);
+#endif
 	do_timer(regs);
 
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	/*
 	 * If we have an externally synchronized Linux clock, then update
 	 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
@@ -241,10 +247,6 @@
 	do_timer_interrupt(irq, NULL, regs);
 	write_sequnlock(&xtime_lock);
 
-#ifndef CONFIG_SMP
-	profile_tick(CPU_PROFILING, regs);
-#endif
-
 	return IRQ_HANDLED;
 }
 
@@ -273,8 +275,8 @@
 
 	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
 	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
-	wall_to_monotonic.tv_sec = -xtime.tv_sec;
-	wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
+	set_normalized_timespec(&wall_to_monotonic,
+		-xtime.tv_sec, -xtime.tv_nsec);
 
 #if defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_XNUX2) \
 	|| defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_M32700) \
@@ -314,4 +316,3 @@
 {
 	return (unsigned long long)jiffies * (1000000000 / HZ);
 }
-
diff -Nru a/arch/m32r/lib/delay.c b/arch/m32r/lib/delay.c
--- a/arch/m32r/lib/delay.c	2004-12-24 13:37:31 -08:00
+++ b/arch/m32r/lib/delay.c	2004-12-24 13:37:31 -08:00
@@ -51,7 +51,7 @@
 		"addi	%0, #-1			\n\t"
 		"bgtz	%0, 1b			\n\t"
 		" .fillinsn			\n\t"
-		"2:i				\n\t"
+		"2:				\n\t"
 		: "+r" (loops)
 		: "r" (0)
 	);
diff -Nru a/arch/m32r/lib/memset.S b/arch/m32r/lib/memset.S
--- a/arch/m32r/lib/memset.S	2004-12-24 13:37:29 -08:00
+++ b/arch/m32r/lib/memset.S	2004-12-24 13:37:29 -08:00
@@ -70,16 +70,18 @@
 	st	r1, @+r4
 	bnc	qword_set_loop	    ||  cmpz	r2
 	jc	r14
-word_set_wrap:
+set_remainder:
 	cmpui	r2, #4
-	bc	byte_set
+	bc	byte_set_wrap1
 	addi	r2, #-4
 	bra	word_set_loop
 
 byte_set_wrap:
 	addi	r2, #4
-	addi	r4, #4		    ||  cmpz	r2
+	cmpz	r2
 	jc	r14
+byte_set_wrap1:
+	addi	r4, #4
 #if defined(CONFIG_ISA_M32R2)
 byte_set:
 	addi	r2, #-1		    ||	stb	r1, @r4+
@@ -153,18 +155,19 @@
 	st	r1, @+r4
 	st	r1, @+r4
 	bnc	qword_set_loop
-	bnez	r2, word_set_wrap
+	bnez	r2, set_remainder
 	jmp	r14
-word_set_wrap:
+set_remainder:
 	cmpui	r2, #4
-	bc	byte_set
+	bc	byte_set_wrap1
 	addi	r2, #-4
 	bra	word_set_loop
 
 byte_set_wrap:
 	addi	r2, #4
-	addi	r4, #4
 	beqz	r2, end_memset
+byte_set_wrap1:
+	addi	r4, #4
 byte_set:
 	addi	r2, #-1
 	stb	r1, @r4
diff -Nru a/arch/m32r/m32700ut/defconfig.m32700ut.smp b/arch/m32r/m32700ut/defconfig.m32700ut.smp
--- a/arch/m32r/m32700ut/defconfig.m32700ut.smp	2004-12-24 13:36:56 -08:00
+++ b/arch/m32r/m32700ut/defconfig.m32700ut.smp	2004-12-24 13:36:56 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:08:45 2004
 #
 CONFIG_M32R=y
 CONFIG_UID16=y
@@ -10,10 +12,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -23,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=15
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 # CONFIG_IKCONFIG_PROC is not set
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -43,6 +50,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -81,33 +89,26 @@
 # CONFIG_NUMA is not set
 
 #
-# M32R drivers
-#
-# CONFIG_M32RPCC is not set
-CONFIG_M32R_CFC=y
-CONFIG_M32700UT_CFC=y
-CONFIG_CFC_NUM=1
-# CONFIG_MTD_M32R is not set
-CONFIG_M32R_SMC91111=y
-CONFIG_M32700UT_DS1302=y
-
-#
-# Power management options (ACPI, APM)
-#
-# CONFIG_PM is not set
-
-#
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=y
+CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=y
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
+# CONFIG_M32R_PCC is not set
+CONFIG_M32R_CFC=y
+CONFIG_M32R_CFC_NUM=1
 
 #
 # PCI Hotplug Support
@@ -154,6 +155,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -173,7 +184,6 @@
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_BLK_DEV_IDESCSI is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -216,9 +226,8 @@
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -274,6 +283,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -293,7 +305,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -310,7 +321,50 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+CONFIG_SMC91X=y
+# CONFIG_NE2000 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
@@ -345,6 +399,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -373,13 +428,12 @@
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_M32R_SIO is not set
+CONFIG_SERIAL_M32R_SIO=y
+CONFIG_SERIAL_M32R_SIO_CONSOLE=y
 CONFIG_SERIAL_M32R_PLDSIO=y
-CONFIG_SERIAL_M32R_PLDSIO_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -392,6 +446,7 @@
 # CONFIG_WATCHDOG is not set
 # CONFIG_RTC is not set
 # CONFIG_GEN_RTC is not set
+CONFIG_DS1302=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
@@ -434,8 +489,8 @@
 # Video Adapters
 #
 # CONFIG_VIDEO_CPIA is not set
-CONFIG_M32R_AR=y
-CONFIG_M32R_AR_VGA=y
+CONFIG_VIDEO_M32R_AR=y
+CONFIG_VIDEO_M32R_AR_M64278=y
 
 #
 # Radio Adapters
@@ -451,14 +506,14 @@
 # Graphics support
 #
 CONFIG_FB=y
-CONFIG_FB_EPSON_S1D13806=y
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
 # CONFIG_FB_VIRTUAL is not set
 
 #
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
 # CONFIG_FONTS is not set
@@ -472,7 +527,6 @@
 CONFIG_LOGO_LINUX_MONO=y
 CONFIG_LOGO_LINUX_VGA16=y
 CONFIG_LOGO_LINUX_CLUT224=y
-CONFIG_LOGO_M32R_CLUT224=y
 
 #
 # Sound
@@ -482,6 +536,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -509,6 +565,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -542,6 +599,7 @@
 # CONFIG_DEVFS_DEBUG is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -576,6 +634,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -647,6 +706,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/m32r/m32700ut/defconfig.m32700ut.up b/arch/m32r/m32700ut/defconfig.m32700ut.up
--- a/arch/m32r/m32700ut/defconfig.m32700ut.up	2004-12-24 13:37:01 -08:00
+++ b/arch/m32r/m32700ut/defconfig.m32700ut.up	2004-12-24 13:37:01 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:08:49 2004
 #
 CONFIG_M32R=y
 CONFIG_UID16=y
@@ -11,10 +13,12 @@
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -24,17 +28,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 # CONFIG_IKCONFIG_PROC is not set
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -44,6 +51,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -78,33 +86,26 @@
 # CONFIG_SMP is not set
 
 #
-# M32R drivers
-#
-# CONFIG_M32RPCC is not set
-CONFIG_M32R_CFC=y
-CONFIG_M32700UT_CFC=y
-CONFIG_CFC_NUM=1
-# CONFIG_MTD_M32R is not set
-CONFIG_M32R_SMC91111=y
-CONFIG_M32700UT_DS1302=y
-
-#
-# Power management options (ACPI, APM)
-#
-# CONFIG_PM is not set
-
-#
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=y
+CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=y
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
+# CONFIG_M32R_PCC is not set
+CONFIG_M32R_CFC=y
+CONFIG_M32R_CFC_NUM=1
 
 #
 # PCI Hotplug Support
@@ -151,6 +152,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -170,7 +181,6 @@
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_BLK_DEV_IDESCSI is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -213,9 +223,8 @@
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -271,6 +280,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -290,7 +302,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -307,7 +318,50 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+CONFIG_SMC91X=y
+# CONFIG_NE2000 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
@@ -342,6 +396,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -370,13 +425,12 @@
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_M32R_SIO is not set
+CONFIG_SERIAL_M32R_SIO=y
+CONFIG_SERIAL_M32R_SIO_CONSOLE=y
 CONFIG_SERIAL_M32R_PLDSIO=y
-CONFIG_SERIAL_M32R_PLDSIO_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -389,6 +443,7 @@
 # CONFIG_WATCHDOG is not set
 # CONFIG_RTC is not set
 # CONFIG_GEN_RTC is not set
+CONFIG_DS1302=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
@@ -431,8 +486,8 @@
 # Video Adapters
 #
 # CONFIG_VIDEO_CPIA is not set
-CONFIG_M32R_AR=y
-CONFIG_M32R_AR_VGA=y
+CONFIG_VIDEO_M32R_AR=y
+CONFIG_VIDEO_M32R_AR_M64278=y
 
 #
 # Radio Adapters
@@ -448,14 +503,14 @@
 # Graphics support
 #
 CONFIG_FB=y
-CONFIG_FB_EPSON_S1D13806=y
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
 # CONFIG_FB_VIRTUAL is not set
 
 #
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
 # CONFIG_FONTS is not set
@@ -469,7 +524,6 @@
 CONFIG_LOGO_LINUX_MONO=y
 CONFIG_LOGO_LINUX_VGA16=y
 CONFIG_LOGO_LINUX_CLUT224=y
-CONFIG_LOGO_M32R_CLUT224=y
 
 #
 # Sound
@@ -479,6 +533,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -506,6 +562,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -539,6 +596,7 @@
 # CONFIG_DEVFS_DEBUG is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -573,6 +631,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -644,6 +703,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/m32r/m32700ut/dot.gdbinit_200MHz_16MB b/arch/m32r/m32700ut/dot.gdbinit_200MHz_16MB
--- a/arch/m32r/m32700ut/dot.gdbinit_200MHz_16MB	2004-12-24 13:37:00 -08:00
+++ b/arch/m32r/m32700ut/dot.gdbinit_200MHz_16MB	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,5 @@
 # .gdbinit file
-# $Id: dot.gdbinit_200MHz_16MB,v 1.1 2004/08/17 02:58:11 takata Exp $
+# $Id: dot.gdbinit_200MHz_16MB,v 1.2 2004/10/20 03:02:27 fujiwara Exp $
 #-----
 # NOTE: this file is generated by a script, "gen_gdbinit.pl".
 # (Please type "gen_gdbinit.pl --help" and check the help message).
@@ -178,11 +178,11 @@
 
 # Set kernel parameters
 define set_kernel_parameters
-  set $param = (void*)0x08002000
+  set $param = (void*)0x08001000
   # INITRD_START
-  set *(unsigned long *)($param + 0x0010) = 0x082a0000
+#  set *(unsigned long *)($param + 0x0010) = 0x08300000
   # INITRD_SIZE
-  set *(unsigned long *)($param + 0x0014) = 0x00000000
+#  set *(unsigned long *)($param + 0x0014) = 0x00000000
   # M32R_CPUCLK
   set *(unsigned long *)($param + 0x0018) = 0d200000000
   # M32R_BUSCLK
@@ -191,15 +191,15 @@
   # M32R_TIMER_DIVIDE
   set *(unsigned long *)($param + 0x0020) = 0d128
 
-  set {char[0x200]}($param + 0x100) = "console=ttyD0,115200n8x console=tty1 video=s1d13xxxfb:mode:240x320-16 root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/rootfs,rsize=1024,wsize=1024 nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 mem=16M \0"
+  set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x console=tty1 root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/rootfs,rsize=1024,wsize=1024 nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 mem=16M \0"
 end
 
 # Boot
 define boot
   set_kernel_parameters
   set $fp = 0
-  set $pc = 0x08001000
-  set *(unsigned char *)0xffffffff = 0x03
+  set $pc = 0x08002000
+# set *(unsigned char *)0xffffffff = 0x03
   si
   c
 end
diff -Nru a/arch/m32r/m32700ut/dot.gdbinit_300MHz_32MB b/arch/m32r/m32700ut/dot.gdbinit_300MHz_32MB
--- a/arch/m32r/m32700ut/dot.gdbinit_300MHz_32MB	2004-12-24 13:37:04 -08:00
+++ b/arch/m32r/m32700ut/dot.gdbinit_300MHz_32MB	2004-12-24 13:37:04 -08:00
@@ -1,5 +1,5 @@
 # .gdbinit file
-# $Id: dot.gdbinit_300MHz_32MB,v 1.1 2004/08/17 02:58:11 takata Exp $
+# $Id: dot.gdbinit_300MHz_32MB,v 1.2 2004/10/20 03:02:27 fujiwara Exp $
 #-----
 # NOTE: this file is generated by a script, "gen_gdbinit.pl".
 # (Please type "gen_gdbinit.pl --help" and check the help message).
@@ -42,8 +42,8 @@
   set *(unsigned long *)0x00ef602c = 0x00000020
   # Ch0-TR
   set *(unsigned long *)0x00ef6028 = 0x00051502
-  # Ch0-ADR (size:16MB)
-  set *(unsigned long *)0x00ef6020 = 0x08000002
+  # Ch0-ADR (size:32MB)
+  set *(unsigned long *)0x00ef6020 = 0x08000003
   # AutoRef On
   set *(unsigned long *)0x00ef6004 = 0x00010e24
   # Access enable
@@ -51,7 +51,7 @@
 end
 document sdram_init
   SDRAM controller initialization
-  0x08000000 - 0x08ffffff (16MB)
+  0x08000000 - 0x09ffffff (32MB)
 end
 
 # Initialize BSEL3 for UT-CFC
@@ -161,8 +161,8 @@
   shell sleep 0.1
   clock_init
   shell sleep 0.1
-  # SDRAM: 16MB
-  set *(unsigned long *)0x00ef6020 = 0x08000002
+  # SDRAM: 32MB
+  set *(unsigned long *)0x00ef6020 = 0x08000003
   cfc_init
   # USB
   set *(unsigned short *)0xb0301000 = 0x100
@@ -178,11 +178,11 @@
 
 # Set kernel parameters
 define set_kernel_parameters
-  set $param = (void*)0x08002000
+  set $param = (void*)0x08001000
   # INITRD_START
-  set *(unsigned long *)($param + 0x0010) = 0x082a0000
+#  set *(unsigned long *)($param + 0x0010) = 0x08300000
   # INITRD_SIZE
-  set *(unsigned long *)($param + 0x0014) = 0x00000000
+#  set *(unsigned long *)($param + 0x0014) = 0x00000000
   # M32R_CPUCLK
   set *(unsigned long *)($param + 0x0018) = 0d300000000
   # M32R_BUSCLK
@@ -191,15 +191,15 @@
   # M32R_TIMER_DIVIDE
   set *(unsigned long *)($param + 0x0020) = 0d128
 
-  set {char[0x200]}($param + 0x100) = "console=ttyD0,115200n8x console=tty1 video=s1d13xxxfb:mode:240x320-16 root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/rootfs,rsize=1024,wsize=1024 nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 mem=16M \0"
+  set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x console=tty1 root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/rootfs,rsize=1024,wsize=1024 nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 mem=32M \0"
 end
 
 # Boot
 define boot
   set_kernel_parameters
   set $fp = 0
-  set $pc = 0x08001000
-  set *(unsigned char *)0xffffffff = 0x03
+  set $pc = 0x08002000
+# set *(unsigned char *)0xffffffff = 0x03
   si
   c
 end
diff -Nru a/arch/m32r/m32700ut/dot.gdbinit_400MHz_32MB b/arch/m32r/m32700ut/dot.gdbinit_400MHz_32MB
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m32r/m32700ut/dot.gdbinit_400MHz_32MB	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,249 @@
+# .gdbinit file
+# $Id: dot.gdbinit_400MHz_32MB,v 1.1 2004/10/21 01:41:27 fujiwara Exp $
+#-----
+# NOTE: this file is generated by a script, "gen_gdbinit.pl".
+# (Please type "gen_gdbinit.pl --help" and check the help message).
+# $ Id: gen_gdbinit.pl,v 1.12 2004/07/26 09:56:10 takata Exp $
+#-----
+# target platform: m32700ut
+
+# setting
+set width 0d70
+set radix 0d16
+
+debug_chaos
+
+# clk xin:cpu:bif:bus=25:400:100:50
+define clock_init
+  set *(unsigned long *)0x00ef4008 = 0x00000000
+  set *(unsigned long *)0x00ef4004 = 0
+  shell sleep 0.1
+  # NOTE: Please change the master clock source from PLL-clock to Xin-clock
+  # and switch off PLL, before resetting the clock gear ratio.
+
+  set *(unsigned long *)0x00ef4024 = 3
+  set *(unsigned long *)0x00ef4020 = 2
+  set *(unsigned long *)0x00ef4010 = 0
+  set *(unsigned long *)0x00ef4014 = 0
+  set *(unsigned long *)0x00ef4004 = 7
+  shell sleep 0.1
+  set *(unsigned long *)0x00ef4008 = 0x00000200
+end
+
+# Initialize SDRAM controller
+define sdram_init
+  # SDIR0
+  set *(unsigned long *)0x00ef6008 = 0x00000182
+  # SDIR1
+  set *(unsigned long *)0x00ef600c = 0x00000001
+  # Initialize wait
+  shell sleep 0.1
+  # Ch0-MOD
+  set *(unsigned long *)0x00ef602c = 0x00000020
+  # Ch0-TR
+  set *(unsigned long *)0x00ef6028 = 0x00041302
+  # Ch0-ADR (size:32MB)
+  set *(unsigned long *)0x00ef6020 = 0x08000003
+  # AutoRef On
+  set *(unsigned long *)0x00ef6004 = 0x00010517
+  # Access enable
+  set *(unsigned long *)0x00ef6024 = 0x00000001
+end
+document sdram_init
+  SDRAM controller initialization
+  0x08000000 - 0x09ffffff (32MB)
+end
+
+# Initialize BSEL3 for UT-CFC
+define cfc_init
+  set $sfrbase = 0xa0ef0000
+# too fast
+#  set *(unsigned long *)($sfrbase + 0x5300) = 0x0b0b8000
+#  set *(unsigned long *)($sfrbase + 0x5304) = 0x00102204
+#  set *(unsigned long *)($sfrbase + 0x5300) = 0x1f1f8000
+#  set *(unsigned long *)($sfrbase + 0x5300) = 0x1f1f1fdf
+#  set *(unsigned long *)($sfrbase + 0x5304) = 0x0013220f
+#  set *(unsigned long *)($sfrbase + 0x5304) = 0x0013330f
+end
+document cfc_init
+  CF controller initialization
+end
+
+# MMU enable
+define mmu_enable
+  set $evb=0x88000000
+  set *(unsigned long *)0xffff0024=1
+end
+
+# MMU disable
+define mmu_disable
+  set $evb=0
+  set *(unsigned long *)0xffff0024=0
+end
+
+# Show TLB entries
+define show_tlb_entries
+  set $i = 0
+  set $addr = $arg0
+  set $nr_entries = $arg1
+  use_mon_code
+  while ($i < $nr_entries)
+    set $tlb_tag = *(unsigned long*)$addr
+    set $tlb_data = *(unsigned long*)($addr + 4)
+    printf " [%2d] 0x%08lx : 0x%08lx - 0x%08lx\n", $i, $addr, $tlb_tag, $tlb_data
+    set $i = $i + 1
+    set $addr = $addr + 8
+  end
+  use_debug_dma
+end
+define itlb
+  set $itlb=0xfe000000
+  show_tlb_entries $itlb 0d32
+end
+define dtlb
+  set $dtlb=0xfe000800
+  show_tlb_entries $dtlb 0d32
+end
+
+# Initialize TLB entries
+define init_tlb_entries
+  set $i = 0
+  set $addr = $arg0
+  set $nr_entries = $arg1
+  use_mon_code
+  while ($i < $nr_entries)
+    set *(unsigned long *)($addr + 0x4) = 0
+    set $i = $i + 1
+    set $addr = $addr + 8
+  end
+  use_debug_dma
+end
+define tlb_init
+  set $itlb=0xfe000000
+  init_tlb_entries $itlb 0d32
+  set $dtlb=0xfe000800
+  init_tlb_entries $dtlb 0d32
+end
+
+# Show current task structure
+define show_current
+  set $current = $spi & 0xffffe000
+  printf "$current=0x%08lX\n",$current
+  print *(struct task_struct *)$current
+end
+
+# Show user assigned task structure
+define show_task
+  set  = $arg0 & 0xffffe000
+  printf "$task=0x%08lX\n",$task
+  print *(struct task_struct *)$task
+end
+document show_task
+  Show user assigned task structure
+  arg0 : task structure address
+end
+
+# Show M32R registers
+define show_regs
+  printf " R0[0x%08lX]   R1[0x%08lX]   R2[0x%08lX]   R3[0x%08lX]\n",$r0,$r1,$r2,$r3
+  printf " R4[0x%08lX]   R5[0x%08lX]   R6[0x%08lX]   R7[0x%08lX]\n",$r4,$r5,$r6,$r7
+  printf " R8[0x%08lX]   R9[0x%08lX]  R10[0x%08lX]  R11[0x%08lX]\n",$r8,$r9,$r10,$r11
+  printf "R12[0x%08lX]   FP[0x%08lX]   LR[0x%08lX]   SP[0x%08lX]\n",$r12,$fp,$lr,$sp
+  printf "PSW[0x%08lX]  CBR[0x%08lX]  SPI[0x%08lX]  SPU[0x%08lX]\n",$psw,$cbr,$spi,$spu
+  printf "BPC[0x%08lX]   PC[0x%08lX] ACCL[0x%08lX] ACCH[0x%08lX]\n",$bpc,$pc,$accl,$acch
+  printf "EVB[0x%08lX]\n",$evb
+end
+
+# Setup all
+define setup
+  use_mon_code
+  set *(unsigned int)0xfffffffc=0x60
+  shell sleep 0.1
+  clock_init
+  shell sleep 0.1
+  # SDRAM: 32MB
+  set *(unsigned long *)0x00ef6020 = 0x08000003
+  cfc_init
+  # USB
+  set *(unsigned short *)0xb0301000 = 0x100
+
+  set $evb=0x08000000
+end
+
+# Load modules
+define load_modules
+  use_debug_dma
+  load
+end
+
+# Set kernel parameters
+define set_kernel_parameters
+  set $param = (void*)0x08001000
+  # INITRD_START
+#  set *(unsigned long *)($param + 0x0010) = 0x08300000
+  # INITRD_SIZE
+#  set *(unsigned long *)($param + 0x0014) = 0x00000000
+  # M32R_CPUCLK
+  set *(unsigned long *)($param + 0x0018) = 0d400000000
+  # M32R_BUSCLK
+  set *(unsigned long *)($param + 0x001c) = 0d50000000
+
+  # M32R_TIMER_DIVIDE
+  set *(unsigned long *)($param + 0x0020) = 0d128
+
+  set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x console=tty1 root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/rootfs,rsize=1024,wsize=1024 nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 mem=32M \0"
+end
+
+# Boot
+define boot
+  set_kernel_parameters
+  set $fp = 0
+  set $pc = 0x08002000
+# set *(unsigned char *)0xffffffff = 0x03
+  si
+  c
+end
+
+# Set breakpoints
+define set_breakpoints
+  b *0x08000030
+end
+
+# Restart
+define restart
+  sdireset
+  sdireset
+  set $pc = 0
+  b *0x04001000
+  b *0x08001000
+  b *0x08002000
+  si
+  c
+  tlb_init
+  del
+  setup
+  load_modules
+  boot
+end
+
+define si
+  stepi
+  x/i $pc
+  show_reg
+end
+
+sdireset
+sdireset
+file vmlinux
+target m32rsdi
+set $pc = 0
+b *0x04001000
+b *0x08001000
+b *0x08002000
+c
+tlb_init
+del
+setup
+load_modules
+boot
+
diff -Nru a/arch/m32r/mappi/defconfig.nommu b/arch/m32r/mappi/defconfig.nommu
--- a/arch/m32r/mappi/defconfig.nommu	2004-12-24 13:37:30 -08:00
+++ b/arch/m32r/mappi/defconfig.nommu	2004-12-24 13:37:30 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:08:51 2004
 #
 CONFIG_M32R=y
 CONFIG_UID16=y
@@ -11,10 +13,12 @@
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
@@ -22,17 +26,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 # CONFIG_IKCONFIG_PROC is not set
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -42,6 +49,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -76,26 +84,24 @@
 # CONFIG_SMP is not set
 
 #
-# M32R drivers
-#
-# CONFIG_M32RPCC is not set
-CONFIG_M32R_NE2000=y
-
-#
-# Power management options (ACPI, APM)
-#
-# CONFIG_PM is not set
-
-#
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
+#
+CONFIG_PCCARD=y
+# CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=y
+
+#
+# PC-card bridges
 #
-# CONFIG_PCMCIA is not set
+# CONFIG_TCIC is not set
+CONFIG_M32R_PCC=y
 
 #
 # PCI Hotplug Support
@@ -144,6 +150,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -199,6 +215,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -218,7 +237,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -235,7 +253,48 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+CONFIG_NE2000=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
@@ -270,6 +329,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -302,7 +362,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -323,6 +382,11 @@
 #
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -362,6 +426,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -381,6 +447,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -443,6 +510,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -514,6 +582,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/m32r/mappi/defconfig.smp b/arch/m32r/mappi/defconfig.smp
--- a/arch/m32r/mappi/defconfig.smp	2004-12-24 13:37:00 -08:00
+++ b/arch/m32r/mappi/defconfig.smp	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:08:53 2004
 #
 CONFIG_M32R=y
 CONFIG_UID16=y
@@ -12,10 +14,12 @@
 # CONFIG_CLEAN_COMPILE is not set
 CONFIG_BROKEN=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -24,17 +28,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=15
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -44,6 +51,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -84,28 +92,24 @@
 # CONFIG_NUMA is not set
 
 #
-# M32R drivers
-#
-CONFIG_M32RPCC=y
-CONFIG_M32R_NE2000=y
-
-#
-# Power management options (ACPI, APM)
-#
-# CONFIG_PM is not set
-
-#
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=y
+CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=y
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
+CONFIG_M32R_PCC=y
 
 #
 # PCI Hotplug Support
@@ -213,6 +217,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -231,7 +245,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -291,6 +304,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -310,7 +326,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -327,7 +342,48 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+CONFIG_NE2000=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
@@ -365,6 +421,7 @@
 # CONFIG_SERIO_I8042 is not set
 # CONFIG_SERIO_SERPORT is not set
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -397,7 +454,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -462,6 +518,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -481,6 +539,7 @@
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -513,6 +572,7 @@
 # CONFIG_DEVFS_DEBUG is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLBFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
@@ -558,6 +618,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -629,6 +690,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/m32r/mappi/defconfig.up b/arch/m32r/mappi/defconfig.up
--- a/arch/m32r/mappi/defconfig.up	2004-12-24 13:36:47 -08:00
+++ b/arch/m32r/mappi/defconfig.up	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:08:55 2004
 #
 CONFIG_M32R=y
 CONFIG_UID16=y
@@ -12,10 +14,12 @@
 # CONFIG_CLEAN_COMPILE is not set
 CONFIG_BROKEN=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -24,17 +28,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -44,6 +51,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -80,28 +88,24 @@
 # CONFIG_SMP is not set
 
 #
-# M32R drivers
-#
-CONFIG_M32RPCC=y
-CONFIG_M32R_NE2000=y
-
-#
-# Power management options (ACPI, APM)
-#
-# CONFIG_PM is not set
-
-#
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=y
+CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=y
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
+CONFIG_M32R_PCC=y
 
 #
 # PCI Hotplug Support
@@ -209,6 +213,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -227,7 +241,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -287,6 +300,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -306,7 +322,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -323,7 +338,48 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+CONFIG_NE2000=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
@@ -361,6 +417,7 @@
 # CONFIG_SERIO_I8042 is not set
 # CONFIG_SERIO_SERPORT is not set
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -393,7 +450,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -458,6 +514,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -477,6 +535,7 @@
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -509,6 +568,7 @@
 # CONFIG_DEVFS_DEBUG is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLBFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
@@ -554,6 +614,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -625,6 +686,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/m32r/mappi/dot.gdbinit b/arch/m32r/mappi/dot.gdbinit
--- a/arch/m32r/mappi/dot.gdbinit	2004-12-24 13:36:18 -08:00
+++ b/arch/m32r/mappi/dot.gdbinit	2004-12-24 13:36:18 -08:00
@@ -1,9 +1,9 @@
 # .gdbinit file
-# $Id$
+# $Id: dot.gdbinit.mappi,v 1.4 2004/10/20 02:24:37 takata Exp $
 #-----
 # NOTE: this file is generated by a script, "gen_gdbinit.pl".
 # (Please type "gen_gdbinit.pl --help" and check the help message).
-# $ Id: gen_gdbinit.pl,v 1.8 2004/02/27 07:08:32 takata Exp $
+# $ Id: gen_gdbinit.pl,v 1.12 2004/07/26 09:56:10 takata Exp $
 #-----
 # target platform: mappi
 
@@ -192,11 +192,11 @@
 
 # Set kernel parameters
 define set_kernel_parameters
-  set $param = (void*)0x08002000
+  set $param = (void*)0x08001000
   # INITRD_START
-  set *(unsigned long *)($param + 0x0010) = 0x082a0000
+#  set *(unsigned long *)($param + 0x0010) = 0x08300000
   # INITRD_SIZE
-  set *(unsigned long *)($param + 0x0014) = 0x00000000
+#  set *(unsigned long *)($param + 0x0014) = 0x00000000
   # M32R_CPUCLK
   set *(unsigned long *)($param + 0x0018) = 0d360000000
   # M32R_BUSCLK
@@ -205,14 +205,14 @@
   # M32R_TIMER_DIVIDE
   set *(unsigned long *)($param + 0x0020) = 0d128
 
-  set {char[0x200]}($param + 0x100) = "console=ttyD0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.x nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
+  set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x console=tty1 root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/rootfs nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
 end
 
 # Boot
 define boot
   set_kernel_parameters
   set $fp = 0
-  set $pc=0x08001000
+  set $pc = 0x08002000
   si
   c
 end
@@ -236,7 +236,7 @@
 file vmlinux
 target m32rsdi
 setup
-#load_module
+#load_modules
 #set_breakpoints
 #boot
 
diff -Nru a/arch/m32r/mappi/dot.gdbinit.nommu b/arch/m32r/mappi/dot.gdbinit.nommu
--- a/arch/m32r/mappi/dot.gdbinit.nommu	2004-12-24 13:36:49 -08:00
+++ b/arch/m32r/mappi/dot.gdbinit.nommu	2004-12-24 13:36:49 -08:00
@@ -192,7 +192,7 @@
 
 # Set kernel parameters
 define set_kernel_parameters
-  set $param = (void*)0x00002000
+  set $param = (void*)0x00001000
   # INITRD_START
   #set *(unsigned long *)($param + 0x0010) = 0x082a0000
   # INITRD_SIZE
@@ -205,14 +205,14 @@
   # M32R_TIMER_DIVIDE
   set *(unsigned long *)($param + 0x0020) = 0d128
 
-  set {char[0x200]}($param + 0x100) = "console=ttyD0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.bbox-httpd nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
+  set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.bbox-httpd nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
 end
 
 # Boot
 define boot
   set_kernel_parameters
   set $fp = 0
-  set $pc=0x00001000
+  set $pc=0x00002000
   set *(long *)0xfffffff4=0x8080
 #  b load_flat_binary
 #  set *(unsigned char *)0x08001003=0x63
diff -Nru a/arch/m32r/mappi/dot.gdbinit.smp b/arch/m32r/mappi/dot.gdbinit.smp
--- a/arch/m32r/mappi/dot.gdbinit.smp	2004-12-24 13:36:17 -08:00
+++ b/arch/m32r/mappi/dot.gdbinit.smp	2004-12-24 13:36:17 -08:00
@@ -269,11 +269,11 @@
 
 # Set kernel parameters
 define set_kernel_parameters
-  set $param = (void*)0x08002000
+  set $param = (void*)0x08001000
   # INITRD_START
 # set *(unsigned long *)($param + 0x0010) = 0x082a0000
   # INITRD_SIZE
-  set *(unsigned long *)($param + 0x0014) = 0x00000000
+#  set *(unsigned long *)($param + 0x0014) = 0x00000000
   # M32R_CPUCLK
   set *(unsigned long *)($param + 0x0018) = 0d160000000
 #  set *(unsigned long *)($param + 0x0018) = 0d80000000
@@ -284,14 +284,14 @@
   # M32R_TIMER_DIVIDE
   set *(unsigned long *)($param + 0x0020) = 0d128
 
-  set {char[0x200]}($param + 0x100) = "console=tty1 console=ttyD0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.x nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
+  set {char[0x200]}($param + 0x100) = "console=tty1 console=ttyS0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.x nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
 #  set {char[0x200]}($param + 0x100) = "console=tty1 root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.x nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
 end
 
 # Boot
 define boot
   set_kernel_parameters
-  set $pc=0x08001000
+  set $pc=0x08002000
   set *(unsigned char *)0x08001003=0x03
   si
   c
@@ -309,7 +309,7 @@
   set *(unsigned long *)0x00eff2f8 = 0x2
   x 0x00eff2f8
 
-  set $pc=0x08001000
+  set $pc=0x08002000
   si
   c
 end
@@ -320,7 +320,7 @@
 ## Boot UP
 define boot_up
   set_kernel_parameters
-  set $pc=0x08001000
+  set $pc=0x08002000
   si
   c
 end
diff -Nru a/arch/m32r/mappi2/defconfig.vdec2 b/arch/m32r/mappi2/defconfig.vdec2
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m32r/mappi2/defconfig.vdec2	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,698 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:08:58 2004
+#
+CONFIG_M32R=y
+CONFIG_UID16=y
+CONFIG_GENERIC_ISA_DMA=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
+CONFIG_IKCONFIG=y
+# CONFIG_IKCONFIG_PROC is not set
+CONFIG_EMBEDDED=y
+# CONFIG_KALLSYMS is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Processor type and features
+#
+# CONFIG_PLAT_MAPPI is not set
+# CONFIG_PLAT_USRV is not set
+# CONFIG_PLAT_M32700UT is not set
+# CONFIG_PLAT_OPSPUT is not set
+# CONFIG_PLAT_OAKS32R is not set
+CONFIG_PLAT_MAPPI2=y
+# CONFIG_CHIP_M32700 is not set
+# CONFIG_CHIP_M32102 is not set
+CONFIG_CHIP_VDEC2=y
+# CONFIG_CHIP_OPSP is not set
+CONFIG_MMU=y
+CONFIG_TLB_ENTRIES=16
+CONFIG_ISA_M32R2=y
+CONFIG_BUS_CLOCK=50000000
+CONFIG_TIMER_DIVIDE=128
+# CONFIG_CPU_LITTLE_ENDIAN is not set
+CONFIG_MEMORY_START=0x08000000
+CONFIG_MEMORY_SIZE=0x01000000
+CONFIG_NOHIGHMEM=y
+# CONFIG_DISCONTIGMEM is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_PREEMPT=y
+# CONFIG_HAVE_DEC_LOCK is not set
+# CONFIG_SMP is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+# CONFIG_PCI is not set
+# CONFIG_ISA is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+CONFIG_PCCARD=y
+# CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=y
+
+#
+# PC-card bridges
+#
+# CONFIG_TCIC is not set
+# CONFIG_M32R_CFC is not set
+
+#
+# PCI Hotplug Support
+#
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECS=y
+CONFIG_BLK_DEV_IDECD=m
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_IDE_ARM is not set
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=m
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# PCMCIA SCSI adapter support
+#
+# CONFIG_PCMCIA_AHA152X is not set
+# CONFIG_PCMCIA_FDOMAIN is not set
+# CONFIG_PCMCIA_NINJA_SCSI is not set
+# CONFIG_PCMCIA_QLOGIC is not set
+# CONFIG_PCMCIA_SYM53C500 is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# 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_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+CONFIG_SMC91X=y
+# CONFIG_NE2000 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_M32R_SIO=y
+CONFIG_SERIAL_M32R_SIO_CONSOLE=y
+# CONFIG_SERIAL_M32R_PLDSIO is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=y
+
+#
+# Video For Linux
+#
+
+#
+# Video Adapters
+#
+# CONFIG_VIDEO_CPIA is not set
+# CONFIG_VIDEO_M32R_AR is not set
+
+#
+# Radio Adapters
+#
+# CONFIG_RADIO_MAESTRO is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_JBD=m
+CONFIG_JBD_DEBUG=y
+CONFIG_FS_MBCACHE=y
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+# CONFIG_ZISOFS is not set
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+# CONFIG_NFSD is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_DEBUG_KERNEL is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
diff -Nru a/arch/m32r/mappi2/dot.gdbinit.vdec2 b/arch/m32r/mappi2/dot.gdbinit.vdec2
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m32r/mappi2/dot.gdbinit.vdec2	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,233 @@
+# .gdbinit file
+# $Id: dot.gdbinit.vdec2,v 1.2 2004/11/11 02:03:15 takata Exp $
+
+# setting
+set width 0d70
+set radix 0d16
+use_debug_dma
+
+# Initialize SDRAM controller for Mappi
+define sdram_init
+  # SDIR0
+  set *(unsigned long *)0x00ef6008=0x00000182
+  # SDIR1
+  set *(unsigned long *)0x00ef600c=0x00000001
+  # Initialize wait
+  shell sleep 1
+  # Ch0-MOD
+  set *(unsigned long *)0x00ef602c=0x00000020
+  # Ch0-TR
+  set *(unsigned long *)0x00ef6028=0x00041302
+  # Ch0-ADR
+  set *(unsigned long *)0x00ef6020=0x08000004
+  # AutoRef On
+  set *(unsigned long *)0x00ef6004=0x00010705
+  # Access enable
+  set *(unsigned long *)0x00ef6024=0x00000001
+end
+document sdram_init
+  Mappi SDRAM controller initialization
+  0x08000000 - 0x0bffffff (64MB)
+end
+
+# Initialize SDRAM controller for Mappi
+define sdram_init2
+  # SDIR0
+  set *(unsigned long *)0x00ef6008=0x00000182
+  # Ch0-MOD
+  set *(unsigned long *)0x00ef602c=0x00000020
+  # Ch0-TR
+  set *(unsigned long *)0x00ef6028=0x00010002
+  # Ch0-ADR
+  set *(unsigned long *)0x00ef6020=0x08000004
+  # AutoRef On
+  set *(unsigned long *)0x00ef6004=0x00010107
+  # SDIR1
+  set *(unsigned long *)0x00ef600c=0x00000001
+  # Initialize wait
+  shell sleep 1
+  # Access enable
+  set *(unsigned long *)0x00ef6024=0x00000001
+  shell sleep 1
+end
+document sdram_init
+  Mappi SDRAM controller initialization
+  0x08000000 - 0x0bffffff (64MB)
+end
+
+# Initialize LAN controller for Mappi
+define lanc_init
+  # Set BSEL1 (BSEL3 for the Chaos's bselc)
+  #set *(unsigned long *)0x00ef5004 = 0x0fff330f
+  #set *(unsigned long *)0x00ef5004 = 0x01113301
+
+#  set *(unsigned long *)0x00ef5004 = 0x02011101
+#  set *(unsigned long *)0x00ef5004 = 0x04441104
+
+  # BSEL5
+#  set *(unsigned long *)0x00ef5014 = 0x0ccc310c
+#  set *(unsigned long *)0x00ef5014 = 0x0303310f
+#  set *(unsigned long *)0x00ef5014 = 0x01011102 -> NG
+#  set *(unsigned long *)0x00ef5014 = 0x03033103
+
+ set *(unsigned long *)0x00ef500c = 0x0b0b1304
+ set *(unsigned long *)0x00ef5010 = 0x03033302
+# set *(unsigned long *)0x00ef5018 = 0x02223302
+end
+
+# MMU enable
+define mmu_enable
+  set $evb=0x88000000
+  set *(unsigned long *)0xffff0024=1
+end
+
+# MMU disable
+define mmu_disable
+  set $evb=0
+  set *(unsigned long *)0xffff0024=0
+end
+
+# Show TLB entries
+define show_tlb_entries
+  set $i = 0
+  set $addr = $arg0
+  while ($i < 0d16 )
+    set $tlb_tag = *(unsigned long*)$addr
+    set $tlb_data = *(unsigned long*)($addr + 4)
+    printf " [%2d] 0x%08lx : 0x%08lx - 0x%08lx\n", $i, $addr, $tlb_tag, $tlb_data
+    set $i = $i + 1
+    set $addr = $addr + 8
+  end
+end
+define itlb
+  set $itlb=0xfe000000
+  show_tlb_entries $itlb
+end
+define dtlb
+  set $dtlb=0xfe000800
+  show_tlb_entries $dtlb
+end
+
+# Cache ON
+define set_cache_type
+  set $mctype = (void*)0xfffffff8
+# chaos
+# set *(unsigned long *)($mctype) = 0x0000c000
+# m32102 i-cache only
+  set *(unsigned long *)($mctype) = 0x00008000
+# m32102 d-cache only
+#  set *(unsigned long *)($mctype) = 0x00004000
+end
+define cache_on
+  set $param = (void*)0x08001000
+  set *(unsigned long *)($param) = 0x60ff6102
+end
+
+
+# Show current task structure
+define show_current
+  set $current = $spi & 0xffffe000
+  printf "$current=0x%08lX\n",$current
+  print *(struct task_struct *)$current
+end
+
+# Show user assigned task structure
+define show_task
+  set $task = $arg0 & 0xffffe000
+  printf "$task=0x%08lX\n",$task
+  print *(struct task_struct *)$task
+end
+document show_task
+  Show user assigned task structure
+  arg0 : task structure address
+end
+
+# Show M32R registers
+define show_regs
+  printf " R0[0x%08lX]   R1[0x%08lX]   R2[0x%08lX]   R3[0x%08lX]\n",$r0,$r1,$r2,$r3
+  printf " R4[0x%08lX]   R5[0x%08lX]   R6[0x%08lX]   R7[0x%08lX]\n",$r4,$r5,$r6,$r7
+  printf " R8[0x%08lX]   R9[0x%08lX]  R10[0x%08lX]  R11[0x%08lX]\n",$r8,$r9,$r10,$r11
+  printf "R12[0x%08lX]   FP[0x%08lX]   LR[0x%08lX]   SP[0x%08lX]\n",$r12,$fp,$lr,$sp
+  printf "PSW[0x%08lX]  CBR[0x%08lX]  SPI[0x%08lX]  SPU[0x%08lX]\n",$psw,$cbr,$spi,$spu
+  printf "BPC[0x%08lX]   PC[0x%08lX] ACCL[0x%08lX] ACCH[0x%08lX]\n",$bpc,$pc,$accl,$acch
+  printf "EVB[0x%08lX]\n",$evb
+
+  set $mests = *(unsigned long *)0xffff000c
+  set $mdeva = *(unsigned long *)0xffff0010
+  printf "MESTS[0x%08lX] MDEVA[0x%08lX]\n",$mests,$mdeva
+end
+
+
+# Setup all
+define setup
+  sdram_init
+#  lanc_init
+#  dispc_init
+#  set $evb=0x08000000
+end
+
+# Load modules
+define load_modules
+  use_debug_dma
+  load
+#  load busybox.mot
+end
+
+# Set kernel parameters
+define set_kernel_parameters
+  set $param = (void*)0x08001000
+
+  ## MOUNT_ROOT_RDONLY
+  set {long}($param+0x00)=0
+  ## RAMDISK_FLAGS
+  #set {long}($param+0x04)=0
+  ## ORIG_ROOT_DEV
+  #set {long}($param+0x08)=0x00000100
+  ## LOADER_TYPE
+  #set {long}($param+0x0C)=0
+  ## INITRD_START
+  set {long}($param+0x10)=0x082a0000
+  ## INITRD_SIZE
+  set {long}($param+0x14)=0d6200000
+
+  # M32R_CPUCLK
+  set *(unsigned long *)($param + 0x0018) = 0d25000000
+  # M32R_BUSCLK
+  set *(unsigned long *)($param + 0x001c) = 0d25000000
+  # M32R_TIMER_DIVIDE
+  set *(unsigned long *)($param + 0x0020) = 0d128
+
+
+ set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.2.6 nfsaddrs=192.168.0.102:192.168.0.1:192.168.0.1:255.255.255.0:mappi: \0"
+
+
+end
+
+# Boot
+define boot
+  set_kernel_parameters
+  debug_chaos
+  set $pc=0x08002000
+  set $fp=0
+  del b
+  si
+end
+
+# Restart
+define restart
+  sdireset
+  sdireset
+  setup
+  load_modules
+  boot
+end
+
+sdireset
+sdireset
+file vmlinux
+target m32rsdi
+
+restart
+boot
+
+
diff -Nru a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
--- a/arch/m32r/mm/init.c	2004-12-24 13:37:03 -08:00
+++ b/arch/m32r/mm/init.c	2004-12-24 13:37:03 -08:00
@@ -18,9 +18,9 @@
 #include <linux/bootmem.h>
 #include <linux/swap.h>
 #include <linux/highmem.h>
+#include <linux/bitops.h>
 #include <asm/types.h>
 #include <asm/processor.h>
-#include <asm/bitops.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
diff -Nru a/arch/m32r/oaks32r/defconfig.nommu b/arch/m32r/oaks32r/defconfig.nommu
--- a/arch/m32r/oaks32r/defconfig.nommu	2004-12-24 13:36:16 -08:00
+++ b/arch/m32r/oaks32r/defconfig.nommu	2004-12-24 13:36:16 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:09:00 2004
 #
 CONFIG_M32R=y
 CONFIG_UID16=y
@@ -11,10 +13,12 @@
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
@@ -22,16 +26,19 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -41,6 +48,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -71,25 +79,19 @@
 # CONFIG_SMP is not set
 
 #
-# M32R drivers
-#
-CONFIG_M32R_NE2000=y
-
-#
-# Power management options (ACPI, APM)
-#
-# CONFIG_PM is not set
-
-#
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# PC-card bridges
 #
-# CONFIG_PCMCIA is not set
 
 #
 # PCI Hotplug Support
@@ -138,6 +140,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -193,6 +205,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -212,7 +227,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -229,7 +243,43 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+CONFIG_NE2000=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
@@ -264,6 +314,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -296,7 +347,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -356,6 +406,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -375,6 +427,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -435,6 +488,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -506,6 +560,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/m32r/oaks32r/dot.gdbinit.nommu b/arch/m32r/oaks32r/dot.gdbinit.nommu
--- a/arch/m32r/oaks32r/dot.gdbinit.nommu	2004-12-24 13:36:17 -08:00
+++ b/arch/m32r/oaks32r/dot.gdbinit.nommu	2004-12-24 13:36:17 -08:00
@@ -1,9 +1,9 @@
 # .gdbinit file
-# $Id: dot.gdbinit.oaks32r,v 1.2 2004/04/15 02:33:14 takata Exp $
+# $Id: dot.gdbinit.oaks32r,v 1.4 2004/10/20 02:24:37 takata Exp $
 #-----
 # NOTE: this file is generated by a script, "gen_gdbinit.pl".
 # (Please type "gen_gdbinit.pl --help" and check the help message).
-# $ Id: gen_gdbinit.pl,v 1.10 2004/04/15 02:10:45 takata Exp $
+# $ Id: gen_gdbinit.pl,v 1.12 2004/07/26 09:56:10 takata Exp $
 #-----
 # target platform: oaks32r
 
@@ -103,11 +103,11 @@
 
 # Set kernel parameters
 define set_kernel_parameters
-  set $param = (void*)0x01002000
+  set $param = (void*)0x01001000
   # INITRD_START
-  set *(unsigned long *)($param + 0x0010) = 0x00000000
+#  set *(unsigned long *)($param + 0x0010) = 0x00000000
   # INITRD_SIZE
-  set *(unsigned long *)($param + 0x0014) = 0x00000000
+#  set *(unsigned long *)($param + 0x0014) = 0x00000000
   # M32R_CPUCLK
   set *(unsigned long *)($param + 0x0018) = 0d66666667
   # M32R_BUSCLK
@@ -116,15 +116,14 @@
   # M32R_TIMER_DIVIDE
   set *(unsigned long *)($param + 0x0020) = 0d128
 
-#  set {char[0x200]}($param + 0x100) = "console=ttyD0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/rootfs nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
-  set {char[0x200]}($param + 0x100) = "console=ttyD0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.busybox.flat nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
+  set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/rootfs nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \0"
 end
 
 # Boot
 define boot
   set_kernel_parameters
   set $fp = 0
-  set $pc = 0x01001000
+  set $pc = 0x01002000
   si
   c
 end
diff -Nru a/arch/m32r/opsput/defconfig.opsput b/arch/m32r/opsput/defconfig.opsput
--- a/arch/m32r/opsput/defconfig.opsput	2004-12-24 13:36:31 -08:00
+++ b/arch/m32r/opsput/defconfig.opsput	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1-bk21
+# Fri Nov 12 16:09:02 2004
 #
 CONFIG_M32R=y
 CONFIG_UID16=y
@@ -15,6 +17,7 @@
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -24,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 # CONFIG_IKCONFIG_PROC is not set
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -44,6 +50,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -77,29 +84,25 @@
 # CONFIG_SMP is not set
 
 #
-# M32R drivers
-#
-# CONFIG_M32R_CFC is not set
-CONFIG_M32R_SMC91111=y
-CONFIG_M32700UT_DS1302=y
-
-#
-# Power management options (ACPI, APM)
-#
-# CONFIG_PM is not set
-
-#
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=y
+CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=y
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
+CONFIG_M32R_CFC=y
+CONFIG_M32R_CFC_NUM=1
 
 #
 # PCI Hotplug Support
@@ -147,6 +150,16 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -185,9 +198,8 @@
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -243,6 +255,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -262,7 +277,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -279,7 +293,50 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+CONFIG_SMC91X=y
+# CONFIG_NE2000 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
@@ -314,6 +371,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -340,13 +398,12 @@
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_M32R_SIO is not set
+CONFIG_SERIAL_M32R_SIO=y
+CONFIG_SERIAL_M32R_SIO_CONSOLE=y
 CONFIG_SERIAL_M32R_PLDSIO=y
-CONFIG_SERIAL_M32R_PLDSIO_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -359,6 +416,7 @@
 # CONFIG_WATCHDOG is not set
 # CONFIG_RTC is not set
 # CONFIG_GEN_RTC is not set
+CONFIG_DS1302=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
@@ -411,6 +469,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -438,6 +498,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -471,6 +532,7 @@
 # CONFIG_DEVFS_DEBUG is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -505,6 +567,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -583,6 +646,7 @@
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/m32r/opsput/dot.gdbinit b/arch/m32r/opsput/dot.gdbinit
--- a/arch/m32r/opsput/dot.gdbinit	2004-12-24 13:36:55 -08:00
+++ b/arch/m32r/opsput/dot.gdbinit	2004-12-24 13:36:55 -08:00
@@ -7,6 +7,39 @@
 set height 0
 debug_chaos
 
+# clk xin:cpu:bus=1:8:1
+define clock_init_on_181
+  set *(unsigned long *)0x00ef400c = 0x2
+  set *(unsigned long *)0x00ef4004 = 0x1
+  shell sleep 0.1
+  set *(unsigned long *)0x00ef4000 = 0x101
+end
+# clk xin:cpu:bus=1:8:2
+define clock_init_on_182
+  set *(unsigned long *)0x00ef400c = 0x1
+  set *(unsigned long *)0x00ef4004 = 0x1
+  shell sleep 0.1
+  set *(unsigned long *)0x00ef4000 = 0x101
+end
+
+# clk xin:cpu:bus=1:8:4
+define clock_init_on_184
+  set *(unsigned long *)0x00ef400c = 0x0
+  set *(unsigned long *)0x00ef4004 = 0x1
+  shell sleep 0.1
+  set *(unsigned long *)0x00ef4000 = 0x101
+end
+
+# clk xin:cpu:bus=1:1:1
+define clock_init_off
+  shell sleep 0.1
+  set *(unsigned long *)0x00ef4000 = 0x0
+  shell sleep 0.1
+  set *(unsigned long *)0x00ef4004 = 0x0
+  shell sleep 0.1
+  set *(unsigned long *)0x00ef400c = 0x0
+end
+
 define tlb_init
   set $tlbbase = 0xfe000000
   set *(unsigned long *)($tlbbase + 0x04) = 0x0
@@ -83,7 +116,7 @@
 
 # Set kernel parameters
 define set_kernel_parameters
-  set $param = (void*)0x88002000
+  set $param = (void*)0x88001000
   # INITRD_START
 #  set *(unsigned long *)($param + 0x0010) = 0x08300000
   # INITRD_SIZE
@@ -97,7 +130,7 @@
   # M32R_TIMER_DIVIDE
   set *(unsigned long *)($param + 0x0020) = 0d128
 
-  set {char[0x200]}($param + 0x100) = "console=ttyD0,115200n8x\
+  set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x console=tty1 \
   root=/dev/nfsroot \
   nfsroot=192.168.0.1:/project/m32r-linux/export/root.2.6 \
   nfsaddrs=192.168.0.101:192.168.0.1:192.168.0.1:255.255.255.0:mappi001 \
@@ -106,16 +139,11 @@
 
 define boot
   set_kernel_parameters
-  set $pc=0x88001000
+  set $pc=0x88002000
   set $fp=0
   set $evb=0x88000000
-  # I/D-Cache ON
-
-# IPI
-#  set *(long *)0x00eff2f8 = 0x2
-  set $fp=0
-#  set *(unsigned long *)0xa0ef4000 = 0x100
   si
+  c
 end
 
 # Show TLB entries
@@ -151,11 +179,29 @@
   printf "EVB[%08lx]\n",$evb
 end
 
+define restart
+  sdireset
+  sdireset
+  en 1
+  set $pc=0x0
+  c
+  tlb_init
+  setup
+  load_modules
+  boot
+end
+
 define setup
   debug_chaos
+# Clock
+#  shell sleep 0.1
+#  clock_init_off
+#  shell sleep 1
+#  clock_init_on_182
+#  shell sleep 0.1
+# SDRAM
   set *(unsigned long *)0xa0ef6004 = 0x0001053f
   set *(unsigned long *)0xa0ef6028 = 0x00031102
-#  set *(unsigned long *)0xa0ef400c = 0x2
 end
 
 sdireset
@@ -165,16 +211,8 @@
 set $pc=0x0
 b *0x30000
 c
+dis 1
 setup
 tlb_init
 load_modules
-#set *(long *)0xa0ef4000=0x101
-#set *(long *)0xa0ef400c=0x002
-
 boot
-#b tme_handler
-b *0x88000020
-
-
-
-
diff -Nru a/arch/m68k/Kconfig b/arch/m68k/Kconfig
--- a/arch/m68k/Kconfig	2004-12-24 13:37:00 -08:00
+++ b/arch/m68k/Kconfig	2004-12-24 13:37:00 -08:00
@@ -185,17 +185,19 @@
 	  drivers for SCSI, Ethernet and serial ports later on.
 
 config HP300
-	bool "HP9000/300 support"
+	bool "HP9000/300 and HP9000/400 support"
 	depends on !MMU_SUN3
 	help
-	  This option enables support for the HP9000/300 series of
-	  workstations. Support for these machines is still very experimental.
-	  If you plan to try to use the kernel on such a machine say Y here.
+	  This option enables support for the HP9000/300 and HP9000/400 series
+	  of workstations. Support for these machines is still somewhat
+	  experimental. If you plan to try to use the kernel on such a machine
+	  say Y here.
 	  Everybody else says N.
 
 config DIO
 	bool "DIO bus support"
 	depends on HP300
+	default y
 	help
 	  Say Y here to enable support for the "DIO" expansion bus used in
 	  HP300 machines. If you are using such a system you almost certainly
@@ -582,11 +584,18 @@
 
 config HPDCA
 	tristate "HP DCA serial support"
-	depends on DIO
+	depends on DIO && SERIAL_8250
 	help
 	  If you want to use the internal "DCA" serial ports on an HP300
 	  machine, say Y here.
 
+config HPAPCI
+	tristate "HP APCI serial support"
+	depends on HP300 && SERIAL_8250 && EXPERIMENTAL
+	help
+	  If you want to use the internal "APCI" serial ports on an HP400
+	  machine, say Y here.
+
 config MVME147_SCC
 	bool "SCC support for MVME147 serial ports"
 	depends on MVME147
@@ -623,7 +632,7 @@
 
 config SERIAL_CONSOLE
 	bool "Support for serial port console"
-	depends on (AMIGA || ATARI || MAC || HP300 || SUN3 || SUN3X || VME || APOLLO) && (ATARI_MFPSER=y || ATARI_SCC=y || ATARI_MIDI=y || MAC_SCC=y || AMIGA_BUILTIN_SERIAL=y || GVPIOEXT=y || MULTIFACE_III_TTY=y || HPDCA=y || SERIAL=y || MVME147_SCC || SERIAL167 || MVME162_SCC || BVME6000_SCC || DN_SERIAL)
+	depends on (AMIGA || ATARI || MAC || SUN3 || SUN3X || VME || APOLLO) && (ATARI_MFPSER=y || ATARI_SCC=y || ATARI_MIDI=y || MAC_SCC=y || AMIGA_BUILTIN_SERIAL=y || GVPIOEXT=y || MULTIFACE_III_TTY=y || SERIAL=y || MVME147_SCC || SERIAL167 || MVME162_SCC || BVME6000_SCC || DN_SERIAL)
 	---help---
 	  If you say Y here, it will be possible to use a serial port as the
 	  system console (the system console is the device which receives all
diff -Nru a/arch/m68k/Makefile b/arch/m68k/Makefile
--- a/arch/m68k/Makefile	2004-12-24 13:37:19 -08:00
+++ b/arch/m68k/Makefile	2004-12-24 13:37:19 -08:00
@@ -28,7 +28,7 @@
 LDFLAGS_vmlinux = -N
 endif
 
-CHECKFLAGS += -D__mc68000__ -I$(shell $(CC) -print-file-name=include)
+CHECKFLAGS += -D__mc68000__
 
 # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
 CFLAGS += -pipe -fno-strength-reduce -ffixed-a2
diff -Nru a/arch/m68k/atari/hades-pci.c b/arch/m68k/atari/hades-pci.c
--- a/arch/m68k/atari/hades-pci.c	2004-12-24 13:36:55 -08:00
+++ b/arch/m68k/atari/hades-pci.c	2004-12-24 13:36:55 -08:00
@@ -311,7 +311,7 @@
 	 * Go through all devices, fixing up irqs as we see fit:
 	 */
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
 	{
 		if (dev->class >> 16 != PCI_BASE_CLASS_BRIDGE)
 		{
diff -Nru a/arch/m68k/configs/amiga_defconfig b/arch/m68k/configs/amiga_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/amiga_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,964 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:25 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-amiga"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+CONFIG_AMIGA=y
+# CONFIG_ATARI is not set
+# CONFIG_MAC is not set
+# CONFIG_APOLLO is not set
+# CONFIG_VME is not set
+# CONFIG_HP300 is not set
+# CONFIG_SUN3X is not set
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+CONFIG_M68020=y
+CONFIG_M68030=y
+CONFIG_M68040=y
+CONFIG_M68060=y
+CONFIG_MMU_MOTOROLA=y
+CONFIG_M68KFPU_EMU=y
+CONFIG_M68KFPU_EMU_EXTRAPREC=y
+# CONFIG_M68KFPU_EMU_ONLY is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_ZORRO=y
+CONFIG_AMIGA_PCMCIA=y
+# CONFIG_HEARTBEAT is not set
+CONFIG_PROC_HARDWARE=y
+CONFIG_ISA=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_ZORRO_NAMES=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+CONFIG_PARPORT=m
+# CONFIG_PARPORT_PC is not set
+CONFIG_PARPORT_AMIGA=m
+CONFIG_PARPORT_MFC3=m
+# CONFIG_PARPORT_OTHER is not set
+CONFIG_PARPORT_1284=y
+
+#
+# Plug and Play support
+#
+# CONFIG_PNP is not set
+
+#
+# Block devices
+#
+CONFIG_AMIGA_FLOPPY=y
+CONFIG_AMIGA_Z2RAM=y
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECD=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_GAYLE=y
+CONFIG_BLK_DEV_IDEDOUBLER=y
+CONFIG_BLK_DEV_BUDDHA=y
+# CONFIG_IDE_CHIPSETS is not set
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_7000FASST is not set
+# CONFIG_SCSI_AHA152X is not set
+# CONFIG_SCSI_AHA1542 is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_IN2000 is not set
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_EATA 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_GENERIC_NCR5380_MMIO is not set
+# CONFIG_SCSI_PPA is not set
+# CONFIG_SCSI_IMM is not set
+# CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PSI240I is not set
+# CONFIG_SCSI_QLOGIC_FAS is not set
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_DEBUG is not set
+CONFIG_A3000_SCSI=y
+CONFIG_A2091_SCSI=y
+CONFIG_GVP11_SCSI=y
+CONFIG_CYBERSTORM_SCSI=y
+CONFIG_CYBERSTORMII_SCSI=y
+CONFIG_BLZ2060_SCSI=y
+CONFIG_BLZ1230_SCSI=y
+CONFIG_FASTLANE_SCSI=y
+CONFIG_OKTAGON_SCSI=y
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_ARIADNE=m
+CONFIG_A2065=m
+CONFIG_HYDRA=m
+CONFIG_ZORRO8390=m
+CONFIG_APNE=m
+# 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)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PLIP=m
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_KEYBOARD_AMIGA=y
+CONFIG_INPUT_MOUSE=y
+# CONFIG_MOUSE_PS2 is not set
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_INPORT is not set
+# CONFIG_MOUSE_LOGIBM is not set
+# CONFIG_MOUSE_PC110PAD is not set
+CONFIG_MOUSE_AMIGA=y
+# CONFIG_MOUSE_VSXXXAA is not set
+CONFIG_INPUT_JOYSTICK=y
+# CONFIG_JOYSTICK_IFORCE is not set
+# CONFIG_JOYSTICK_WARRIOR is not set
+# CONFIG_JOYSTICK_MAGELLAN is not set
+# CONFIG_JOYSTICK_SPACEORB is not set
+# CONFIG_JOYSTICK_SPACEBALL is not set
+# CONFIG_JOYSTICK_STINGER is not set
+# CONFIG_JOYSTICK_TWIDDLER is not set
+# CONFIG_JOYSTICK_DB9 is not set
+# CONFIG_JOYSTICK_GAMECON is not set
+# CONFIG_JOYSTICK_TURBOGRAFX is not set
+CONFIG_JOYSTICK_AMIGA=m
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_A2232=m
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+CONFIG_PRINTER=m
+# CONFIG_LP_CONSOLE is not set
+# CONFIG_PPDEV is not set
+# CONFIG_TIPAR is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=m
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+CONFIG_FB_CIRRUS=m
+CONFIG_FB_AMIGA=y
+CONFIG_FB_AMIGA_OCS=y
+CONFIG_FB_AMIGA_ECS=y
+CONFIG_FB_AMIGA_AGA=y
+CONFIG_FB_FM2=y
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+CONFIG_FONT_PEARL_8x8=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+CONFIG_DMASOUND_PAULA=m
+CONFIG_DMASOUND=m
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+CONFIG_AMIGA_BUILTIN_SERIAL=y
+# CONFIG_WHIPPET_SERIAL is not set
+CONFIG_MULTIFACE_III_TTY=m
+# CONFIG_SERIAL_CONSOLE is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=y
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_RPCSEC_GSS_KRB5=m
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+# CONFIG_NCPFS_SMALLDOS is not set
+CONFIG_NCPFS_NLS=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_AMIGA_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/apollo_defconfig b/arch/m68k/configs/apollo_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/apollo_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,821 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:29 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-apollo"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+# CONFIG_ATARI is not set
+# CONFIG_MAC is not set
+CONFIG_APOLLO=y
+# CONFIG_VME is not set
+# CONFIG_HP300 is not set
+# CONFIG_SUN3X is not set
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+CONFIG_M68020=y
+CONFIG_M68030=y
+CONFIG_M68040=y
+CONFIG_M68060=y
+CONFIG_MMU_MOTOROLA=y
+CONFIG_M68KFPU_EMU=y
+CONFIG_M68KFPU_EMU_EXTRAPREC=y
+# CONFIG_M68KFPU_EMU_ONLY is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_HEARTBEAT=y
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_APOLLO_ELPLUS=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=y
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+CONFIG_DN_SERIAL=y
+CONFIG_SERIAL_CONSOLE=y
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+# CONFIG_NCPFS_SMALLDOS is not set
+CONFIG_NCPFS_NLS=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/atari_defconfig b/arch/m68k/configs/atari_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/atari_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,876 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:34 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-atari"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+CONFIG_ATARI=y
+# CONFIG_MAC is not set
+# CONFIG_APOLLO is not set
+# CONFIG_VME is not set
+# CONFIG_HP300 is not set
+# CONFIG_SUN3X is not set
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+CONFIG_M68020=y
+CONFIG_M68030=y
+CONFIG_M68040=y
+CONFIG_M68060=y
+CONFIG_MMU_MOTOROLA=y
+CONFIG_M68KFPU_EMU=y
+CONFIG_M68KFPU_EMU_EXTRAPREC=y
+# CONFIG_M68KFPU_EMU_ONLY is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_STRAM_PROC=y
+CONFIG_HEARTBEAT=y
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+CONFIG_PARPORT=m
+# CONFIG_PARPORT_PC is not set
+CONFIG_PARPORT_ATARI=m
+# CONFIG_PARPORT_OTHER is not set
+CONFIG_PARPORT_1284=y
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_ATARI_FLOPPY=y
+# CONFIG_PARIDE is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECD=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_FALCON_IDE=y
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_PPA is not set
+# CONFIG_SCSI_IMM is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_ATARILANCE=m
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PLIP is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_M68K_BEEP=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+CONFIG_PRINTER=m
+# CONFIG_LP_CONSOLE is not set
+# CONFIG_PPDEV is not set
+# CONFIG_TIPAR is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_NVRAM=y
+CONFIG_GEN_RTC=y
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_ATY is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+# CONFIG_LOGO is not set
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+CONFIG_DMASOUND_ATARI=m
+CONFIG_DMASOUND=m
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+CONFIG_ATARI_MFPSER=m
+CONFIG_ATARI_SCC=y
+CONFIG_ATARI_SCC_DMA=y
+CONFIG_ATARI_MIDI=m
+CONFIG_ATARI_DSP56K=m
+# CONFIG_SERIAL_CONSOLE is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+CONFIG_REISERFS_PROC_INFO=y
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V4 is not set
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=m
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+# CONFIG_NCPFS_SMALLDOS is not set
+CONFIG_NCPFS_NLS=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_ATARI_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/bvme6000_defconfig b/arch/m68k/configs/bvme6000_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/bvme6000_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,820 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:38 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-bvme6000"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+# CONFIG_ATARI is not set
+# CONFIG_MAC is not set
+# CONFIG_APOLLO is not set
+CONFIG_VME=y
+# CONFIG_MVME147 is not set
+# CONFIG_MVME16x is not set
+CONFIG_BVME6000=y
+# CONFIG_HP300 is not set
+# CONFIG_SUN3X is not set
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+# CONFIG_M68020 is not set
+# CONFIG_M68030 is not set
+CONFIG_M68040=y
+CONFIG_M68060=y
+CONFIG_MMU_MOTOROLA=y
+# CONFIG_M68KFPU_EMU is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_BVME6000_NET=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+# CONFIG_PPP_FILTER is not set
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=m
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+CONFIG_BVME6000_SCC=y
+CONFIG_SERIAL_CONSOLE=y
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+# CONFIG_NCPFS_SMALLDOS is not set
+CONFIG_NCPFS_NLS=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=m
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/hp300_defconfig b/arch/m68k/configs/hp300_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/hp300_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,820 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:44 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-hp300"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+# CONFIG_ATARI is not set
+# CONFIG_MAC is not set
+# CONFIG_APOLLO is not set
+# CONFIG_VME is not set
+CONFIG_HP300=y
+CONFIG_DIO=y
+# CONFIG_SUN3X is not set
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+CONFIG_M68020=y
+CONFIG_M68030=y
+CONFIG_M68040=y
+CONFIG_M68060=y
+CONFIG_MMU_MOTOROLA=y
+CONFIG_M68KFPU_EMU=y
+CONFIG_M68KFPU_EMU_EXTRAPREC=y
+# CONFIG_M68KFPU_EMU_ONLY is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_HEARTBEAT=y
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HPLANCE=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=y
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+# CONFIG_NCPFS_SMALLDOS is not set
+CONFIG_NCPFS_NLS=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/mac_defconfig b/arch/m68k/configs/mac_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/mac_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,899 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:47 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-mac"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+# CONFIG_ATARI is not set
+CONFIG_MAC=y
+CONFIG_NUBUS=y
+CONFIG_M68K_L2_CACHE=y
+# CONFIG_APOLLO is not set
+# CONFIG_VME is not set
+# CONFIG_HP300 is not set
+# CONFIG_SUN3X is not set
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+CONFIG_M68020=y
+CONFIG_M68030=y
+CONFIG_M68040=y
+# CONFIG_M68060 is not set
+CONFIG_MMU_MOTOROLA=y
+CONFIG_M68KFPU_EMU=y
+CONFIG_M68KFPU_EMU_EXTRAPREC=y
+# CONFIG_M68KFPU_EMU_ONLY is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+# CONFIG_HEARTBEAT is not set
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECD=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_MAC_IDE=y
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
+CONFIG_MAC_SCSI=y
+CONFIG_SCSI_MAC_ESP=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Macintosh device drivers
+#
+CONFIG_ADB=y
+CONFIG_ADB_MACII=y
+CONFIG_ADB_MACIISI=y
+CONFIG_ADB_IOP=y
+CONFIG_ADB_PMU68K=y
+CONFIG_ADB_CUDA=y
+CONFIG_INPUT_ADBHID=y
+CONFIG_MAC_EMUMOUSEBTN=y
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+CONFIG_DEV_APPLETALK=y
+CONFIG_IPDDP=m
+CONFIG_IPDDP_ENCAP=y
+CONFIG_IPDDP_DECAP=y
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_MII is not set
+CONFIG_MAC8390=y
+CONFIG_MAC89x0=y
+CONFIG_MACSONIC=y
+CONFIG_MACMACE=y
+# CONFIG_NET_VENDOR_SMC is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+# CONFIG_PPP_ASYNC is not set
+# CONFIG_PPP_SYNC_TTY is not set
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=m
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+CONFIG_FB_VALKYRIE=y
+CONFIG_FB_MAC=y
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+CONFIG_FONT_6x11=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_LOGO_MAC_CLUT224=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+CONFIG_MAC_SCC=y
+CONFIG_MAC_HID=y
+CONFIG_MAC_ADBKEYCODES=y
+CONFIG_SERIAL_CONSOLE=y
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=y
+CONFIG_HFSPLUS_FS=y
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_RPCSEC_GSS_KRB5=m
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+# CONFIG_NCPFS_SMALLDOS is not set
+CONFIG_NCPFS_NLS=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+# CONFIG_OSF_PARTITION is not set
+CONFIG_AMIGA_PARTITION=y
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+CONFIG_LDM_DEBUG=y
+# CONFIG_SGI_PARTITION is not set
+# CONFIG_ULTRIX_PARTITION is not set
+CONFIG_SUN_PARTITION=y
+# CONFIG_EFI_PARTITION is not set
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/mvme147_defconfig b/arch/m68k/configs/mvme147_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/mvme147_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,839 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:49 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-mvme147"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+# CONFIG_ATARI is not set
+# CONFIG_MAC is not set
+# CONFIG_APOLLO is not set
+CONFIG_VME=y
+CONFIG_MVME147=y
+# CONFIG_MVME16x is not set
+# CONFIG_BVME6000 is not set
+# CONFIG_HP300 is not set
+# CONFIG_SUN3X is not set
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+# CONFIG_M68020 is not set
+CONFIG_M68030=y
+# CONFIG_M68040 is not set
+# CONFIG_M68060 is not set
+CONFIG_MMU_MOTOROLA=y
+# CONFIG_M68KFPU_EMU is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
+CONFIG_MVME147_SCSI=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_MVME147_NET=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=m
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+CONFIG_MVME147_SCC=y
+CONFIG_SERIAL_CONSOLE=y
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# 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=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/mvme16x_defconfig b/arch/m68k/configs/mvme16x_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/mvme16x_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,838 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:52 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-mvme16x"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+# CONFIG_ATARI is not set
+# CONFIG_MAC is not set
+# CONFIG_APOLLO is not set
+CONFIG_VME=y
+# CONFIG_MVME147 is not set
+CONFIG_MVME16x=y
+# CONFIG_BVME6000 is not set
+# CONFIG_HP300 is not set
+# CONFIG_SUN3X is not set
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+# CONFIG_M68020 is not set
+# CONFIG_M68030 is not set
+CONFIG_M68040=y
+CONFIG_M68060=y
+CONFIG_MMU_MOTOROLA=y
+# CONFIG_M68KFPU_EMU is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_MVME16x_NET=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=m
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+CONFIG_MVME162_SCC=y
+CONFIG_SERIAL_CONSOLE=y
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# 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=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/q40_defconfig b/arch/m68k/configs/q40_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/q40_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,911 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:55 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-q40"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+# CONFIG_ATARI is not set
+# CONFIG_MAC is not set
+# CONFIG_APOLLO is not set
+# CONFIG_VME is not set
+# CONFIG_HP300 is not set
+# CONFIG_SUN3X is not set
+CONFIG_Q40=y
+
+#
+# Processor type
+#
+# CONFIG_M68020 is not set
+# CONFIG_M68030 is not set
+CONFIG_M68040=y
+CONFIG_M68060=y
+CONFIG_MMU_MOTOROLA=y
+CONFIG_M68KFPU_EMU=y
+CONFIG_M68KFPU_EMU_EXTRAPREC=y
+# CONFIG_M68KFPU_EMU_ONLY is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+# CONFIG_HEARTBEAT is not set
+CONFIG_PROC_HARDWARE=y
+CONFIG_ISA=y
+CONFIG_GENERIC_ISA_DMA=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+# CONFIG_PNP is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECD=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_Q40IDE=y
+# CONFIG_IDE_CHIPSETS is not set
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_7000FASST is not set
+# CONFIG_SCSI_AHA152X is not set
+# CONFIG_SCSI_AHA1542 is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_IN2000 is not set
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_EATA 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_GENERIC_NCR5380_MMIO is not set
+# CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PSI240I is not set
+# CONFIG_SCSI_QLOGIC_FAS is not set
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+# 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_NE2000=m
+# CONFIG_NET_PCI is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=m
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_Q40KBD=m
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_INPORT is not set
+# CONFIG_MOUSE_LOGIBM is not set
+# CONFIG_MOUSE_PC110PAD is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=m
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+CONFIG_FB_Q40=y
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+
+#
+# Sound
+#
+CONFIG_SOUND=y
+CONFIG_DMASOUND_Q40=y
+CONFIG_DMASOUND=y
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+CONFIG_UFS_FS_WRITE=y
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# 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=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/sun3_defconfig b/arch/m68k/configs/sun3_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/sun3_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,826 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:58 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-sun3"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+CONFIG_SUN3=y
+
+#
+# Processor type
+#
+CONFIG_M68020=y
+CONFIG_MMU_SUN3=y
+CONFIG_M68KFPU_EMU=y
+CONFIG_M68KFPU_EMU_EXTRAPREC=y
+# CONFIG_M68KFPU_EMU_ONLY is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
+CONFIG_SUN3_SCSI=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_SUN3LANCE=y
+CONFIG_SUN3_82586=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+CONFIG_KEYBOARD_SUNKBD=y
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=y
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+CONFIG_UFS_FS_WRITE=y
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# 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=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/configs/sun3x_defconfig b/arch/m68k/configs/sun3x_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68k/configs/sun3x_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,836 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:22:01 2004
+#
+CONFIG_M68K=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION="-sun3x"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+CONFIG_AUDIT=y
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Platform dependent setup
+#
+# CONFIG_SUN3 is not set
+# CONFIG_AMIGA is not set
+# CONFIG_ATARI is not set
+# CONFIG_MAC is not set
+# CONFIG_APOLLO is not set
+# CONFIG_VME is not set
+# CONFIG_HP300 is not set
+CONFIG_SUN3X=y
+# CONFIG_Q40 is not set
+
+#
+# Processor type
+#
+# CONFIG_M68020 is not set
+CONFIG_M68030=y
+# CONFIG_M68040 is not set
+# CONFIG_M68060 is not set
+CONFIG_MMU_MOTOROLA=y
+CONFIG_M68KFPU_EMU=y
+CONFIG_M68KFPU_EMU_EXTRAPREC=y
+# CONFIG_M68KFPU_EMU_ONLY is not set
+# CONFIG_ADVANCED is not set
+
+#
+# General setup
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_PROC_HARDWARE=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
+CONFIG_SUN3X_ESP=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+# CONFIG_MD_RAID10 is not set
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_MATCH_SCTP is not set
+# CONFIG_IP_NF_MATCH_COMMENT is not set
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_IP_NF_COMPAT_IPCHAINS=m
+CONFIG_IP_NF_COMPAT_IPFWADM=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_LIMIT=m
+CONFIG_IP6_NF_MATCH_MAC=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_MULTIPORT=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_MARK=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AHESP=m
+CONFIG_IP6_NF_MATCH_LENGTH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_MARK=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+CONFIG_NET_POLL_CONTROLLER=y
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+CONFIG_EQUALIZER=m
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_SUN3LANCE=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPPOE=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_SHAPER=m
+CONFIG_NETCONSOLE=m
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+CONFIG_SERIO_SERPORT=m
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+CONFIG_KEYBOARD_SUNKBD=y
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_GEN_RTC=y
+CONFIG_GEN_RTC_X=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+CONFIG_JFS_FS=m
+# CONFIG_JFS_POSIX_ACL is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+CONFIG_HPFS_FS=m
+# CONFIG_QNX4FS_FS is not set
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+CONFIG_UFS_FS_WRITE=y
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+# CONFIG_CIFS is not set
+CONFIG_NCP_FS=m
+# 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=y
+# CONFIG_NCPFS_EXTRAS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
diff -Nru a/arch/m68k/defconfig b/arch/m68k/defconfig
--- a/arch/m68k/defconfig	2004-12-24 13:36:17 -08:00
+++ b/arch/m68k/defconfig	2004-12-24 13:36:17 -08:00
@@ -1,28 +1,63 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc3-m68k
+# Sun Dec  5 14:21:41 2004
 #
+CONFIG_M68K=y
+CONFIG_MMU=y
 CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
 
 #
 # Platform dependent setup
 #
-# CONFIG_ISA is not set
-# CONFIG_PCMCIA is not set
+# CONFIG_SUN3 is not set
 CONFIG_AMIGA=y
 # CONFIG_ATARI is not set
-# CONFIG_HADES is not set
-# CONFIG_PCI is not set
 # CONFIG_MAC is not set
 # CONFIG_APOLLO is not set
 # CONFIG_VME is not set
 # CONFIG_HP300 is not set
 # CONFIG_SUN3X is not set
-# CONFIG_SUN3 is not set
 # CONFIG_Q40 is not set
 
 #
@@ -32,114 +67,89 @@
 CONFIG_M68030=y
 CONFIG_M68040=y
 # CONFIG_M68060 is not set
+CONFIG_MMU_MOTOROLA=y
 # CONFIG_M68KFPU_EMU is not set
 # CONFIG_ADVANCED is not set
 
 #
 # General setup
 #
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
 CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_ZORRO=y
 # CONFIG_AMIGA_PCMCIA is not set
 # CONFIG_HEARTBEAT is not set
 CONFIG_PROC_HARDWARE=y
-# CONFIG_PARPORT is not set
-# CONFIG_PRINTER is not set
+# CONFIG_ZORRO_NAMES is not set
 
 #
-# Loadable module support
+# Device Drivers
 #
-# CONFIG_MODULES is not set
 
 #
-# Block devices
+# Generic Driver Options
 #
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_AMIGA_FLOPPY=y
-# CONFIG_AMIGA_Z2RAM is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_MD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_INITRD=y
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
-# Networking options
+# Memory Technology Devices (MTD)
 #
-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 is not set
-# CONFIG_IP_ROUTER is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_ALIAS is not set
-# CONFIG_SYN_COOKIES is not set
+# CONFIG_MTD is not set
 
 #
-# (it is safe to leave these untouched)
+# Parallel port support
 #
-# CONFIG_SKB_LARGE is not set
-# CONFIG_IPV6 is not set
-# CONFIG_KHTTPD is not set
-# CONFIG_ATM is not set
+# CONFIG_PARPORT is not set
 
 #
+# Plug and Play support
 #
+
 #
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_DECNET is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_LLC is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
+# Block devices
+#
+CONFIG_AMIGA_FLOPPY=y
+# CONFIG_AMIGA_Z2RAM 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_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
 
 #
-# QoS and/or fair queueing
+# IO Schedulers
 #
-# CONFIG_NET_SCHED is not set
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
-# ATA/IDE/MFM/RLL support
+# ATA/ATAPI/MFM/RLL support
 #
 # CONFIG_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
 
 #
-# SCSI support
+# SCSI device support
 #
 CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
 
 #
 # SCSI support type (disk, tape, CD-ROM)
 #
 CONFIG_BLK_DEV_SD=y
-CONFIG_SD_EXTRA_DEVS=40
 CONFIG_CHR_DEV_ST=y
-CONFIG_ST_EXTRA_DEVS=2
+# CONFIG_CHR_DEV_OSST is not set
 CONFIG_BLK_DEV_SR=y
 # CONFIG_BLK_DEV_SR_VENDOR is not set
-CONFIG_SR_EXTRA_DEVS=2
 # CONFIG_CHR_DEV_SG is not set
 
 #
@@ -150,10 +160,17 @@
 # CONFIG_SCSI_LOGGING is not set
 
 #
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
 # SCSI low-level drivers
 #
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
 CONFIG_A3000_SCSI=y
-# CONFIG_A4000T_SCSI is not set
 CONFIG_A2091_SCSI=y
 CONFIG_GVP11_SCSI=y
 # CONFIG_CYBERSTORM_SCSI is not set
@@ -161,107 +178,389 @@
 # CONFIG_BLZ2060_SCSI is not set
 # CONFIG_BLZ1230_SCSI is not set
 # CONFIG_FASTLANE_SCSI is not set
-# CONFIG_A4091_SCSI is not set
-# CONFIG_WARPENGINE_SCSI is not set
-# CONFIG_BLZ603EPLUS_SCSI is not set
 # CONFIG_OKTAGON_SCSI is not set
 
 #
-# Network device support
+# Multi-device support (RAID and LVM)
 #
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# 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_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # 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_ARIADNE is not set
-# CONFIG_ZORRO8390 is not set
-# CONFIG_A2065 is not set
-# CONFIG_HYDRA is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_AMIGA is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_AMIGA is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
 
 #
 # Character devices
 #
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
-CONFIG_BUSMOUSE=y
-CONFIG_AMIGA_BUILTIN_SERIAL=y
-# CONFIG_GVPIOEXT is not set
-# CONFIG_GVPIOEXT_LP is not set
-# CONFIG_GVPIOEXT_PLIP is not set
-# CONFIG_MULTIFACE_III_TTY is not set
-# CONFIG_SUN3X_ZS is not set
-# CONFIG_SUN_KEYBOARD is not set
-# CONFIG_SUN_MOUSE is not set
-# CONFIG_SBUS is not set
-# CONFIG_SERIAL_CONSOLE is not set
-# CONFIG_USERIAL is not set
-# CONFIG_WATCHDOG is not set
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_A2232 is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
 
 #
-# Sound support
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_CIRRUS is not set
+CONFIG_FB_AMIGA=y
+CONFIG_FB_AMIGA_OCS=y
+CONFIG_FB_AMIGA_ECS=y
+CONFIG_FB_AMIGA_AGA=y
+# CONFIG_FB_FM2 is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE is not set
+
+#
+# Logo configuration
+#
+# CONFIG_LOGO is not set
+
+#
+# Sound
 #
 # CONFIG_SOUND is not set
 
 #
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Character devices
+#
+CONFIG_AMIGA_BUILTIN_SERIAL=y
+# CONFIG_MULTIFACE_III_TTY is not set
+# CONFIG_GVPIOEXT is not set
+# CONFIG_SERIAL_CONSOLE is not set
+
+#
 # File systems
 #
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+# CONFIG_VFAT_FS is not set
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+# CONFIG_TMPFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
-CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
-# CONFIG_UMSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_CRAMFS is not set
-# CONFIG_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-CONFIG_MINIX_FS=y
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG is not set
-# CONFIG_NTFS_RW is not set
+# CONFIG_VXFS_FS 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_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_UDF_FS is not set
 # CONFIG_UFS_FS is not set
 
 #
 # Network File Systems
 #
-# CONFIG_CODA_FS is not set
 CONFIG_NFS_FS=y
-# CONFIG_ROOT_NFS is not set
+# CONFIG_NFS_V3 is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
-CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
 
 #
 # Partition Types
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_AMIGA_PARTITION=y
-CONFIG_NLS=y
+CONFIG_MSDOS_PARTITION=y
 
 #
 # Native Language Support
 #
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
 CONFIG_NLS_CODEPAGE_437=y
 # CONFIG_NLS_CODEPAGE_737 is not set
 # CONFIG_NLS_CODEPAGE_775 is not set
@@ -277,7 +576,15 @@
 # CONFIG_NLS_CODEPAGE_865 is not set
 # CONFIG_NLS_CODEPAGE_866 is not set
 # CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
 # CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
 # CONFIG_NLS_ISO8859_1 is not set
 # CONFIG_NLS_ISO8859_2 is not set
 # CONFIG_NLS_ISO8859_3 is not set
@@ -285,44 +592,33 @@
 # CONFIG_NLS_ISO8859_5 is not set
 # CONFIG_NLS_ISO8859_6 is not set
 # CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_8 is not set
 # CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
 # CONFIG_NLS_ISO8859_14 is not set
 # CONFIG_NLS_ISO8859_15 is not set
 # CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
 
 #
-# Console drivers
+# Kernel hacking
 #
-CONFIG_FB=y
+# CONFIG_DEBUG_KERNEL is not set
 
 #
-# Frame-buffer support
+# Security options
 #
-CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_CLGEN is not set
-# CONFIG_FB_PM2 is not set
-CONFIG_FB_AMIGA=y
-CONFIG_FB_AMIGA_OCS=y
-CONFIG_FB_AMIGA_ECS=y
-CONFIG_FB_AMIGA_AGA=y
-# CONFIG_FB_CYBER is not set
-# CONFIG_FB_VIRGE is not set
-# CONFIG_FB_RETINAZ3 is not set
-# CONFIG_FB_FM2 is not set
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_MFB=y
-CONFIG_FBCON_AFB=y
-CONFIG_FBCON_ILBM=y
-# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
-# CONFIG_FBCON_FONTS is not set
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-CONFIG_FONT_PEARL_8x8=y
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
 
 #
-# Kernel hacking
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
 #
-# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_CRC_CCITT is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
diff -Nru a/arch/m68k/hp300/config.c b/arch/m68k/hp300/config.c
--- a/arch/m68k/hp300/config.c	2004-12-24 13:36:17 -08:00
+++ b/arch/m68k/hp300/config.c	2004-12-24 13:36:17 -08:00
@@ -8,55 +8,272 @@
  */
 
 #include <linux/config.h>
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/kd.h>
-#include <linux/tty.h>
-#include <linux/console.h>
-#include <linux/interrupt.h>
+#include <linux/module.h>
 #include <linux/init.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/console.h>
+
+#include <asm/bootinfo.h>
 #include <asm/machdep.h>
 #include <asm/blinken.h>
-#include <asm/hwtest.h>                           /* hwreg_present() */
+#include <asm/io.h>                               /* readb() and writeb() */
+#include <asm/hp300hw.h>
+#include <asm/rtc.h>
 
 #include "ints.h"
 #include "time.h"
 
+unsigned long hp300_model;
+unsigned long hp300_uart_scode = -1;
+unsigned char ledstate;
+
+static char s_hp330[] __initdata = "330";
+static char s_hp340[] __initdata = "340";
+static char s_hp345[] __initdata = "345";
+static char s_hp360[] __initdata = "360";
+static char s_hp370[] __initdata = "370";
+static char s_hp375[] __initdata = "375";
+static char s_hp380[] __initdata = "380";
+static char s_hp385[] __initdata = "385";
+static char s_hp400[] __initdata = "400";
+static char s_hp425t[] __initdata = "425t";
+static char s_hp425s[] __initdata = "425s";
+static char s_hp425e[] __initdata = "425e";
+static char s_hp433t[] __initdata = "433t";
+static char s_hp433s[] __initdata = "433s";
+static char *hp300_models[] __initdata = {
+	[HP_320]	= NULL,
+	[HP_330]	= s_hp330,
+	[HP_340]	= s_hp340,
+	[HP_345]	= s_hp345,
+	[HP_350]	= NULL,
+	[HP_360]	= s_hp360,
+	[HP_370]	= s_hp370,
+	[HP_375]	= s_hp375,
+	[HP_380]	= s_hp380,
+	[HP_385]	= s_hp385,
+	[HP_400]	= s_hp400,
+	[HP_425T]	= s_hp425t,
+	[HP_425S]	= s_hp425s,
+	[HP_425E]	= s_hp425e,
+	[HP_433T]	= s_hp433t,
+	[HP_433S]	= s_hp433s,
+};
+
+static char hp300_model_name[13] = "HP9000/";
+
 extern void hp300_reset(void);
 extern irqreturn_t (*hp300_default_handler[])(int, void *, struct pt_regs *);
 extern int show_hp300_interrupts(struct seq_file *, void *);
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+extern int hp300_setup_serial_console(void) __init;
+#endif
+
+int __init hp300_parse_bootinfo(const struct bi_record *record)
+{
+	int unknown = 0;
+	const unsigned long *data = record->data;
+
+	switch (record->tag) {
+	case BI_HP300_MODEL:
+		hp300_model = *data;
+		break;
+
+	case BI_HP300_UART_SCODE:
+		hp300_uart_scode = *data;
+		break;
+
+	case BI_HP300_UART_ADDR:
+		/* serial port address: ignored here */
+		break;
+
+        default:
+		unknown = 1;
+	}
+
+	return unknown;
+}
 
 #ifdef CONFIG_HEARTBEAT
 static void hp300_pulse(int x)
 {
-   if (x)
-      blinken_leds(0xfe);
-   else
-      blinken_leds(0xff);
+	if (x)
+		blinken_leds(0x10, 0);
+	else
+		blinken_leds(0, 0x10);
 }
 #endif
 
 static void hp300_get_model(char *model)
 {
-  strcpy(model, "HP9000/300");
+	strcpy(model, hp300_model_name);
+}
+
+#define RTCBASE			0xf0420000
+#define RTC_DATA		0x1
+#define RTC_CMD			0x3
+
+#define	RTC_BUSY		0x02
+#define	RTC_DATA_RDY		0x01
+
+#define rtc_busy()		(in_8(RTCBASE + RTC_CMD) & RTC_BUSY)
+#define rtc_data_available()	(in_8(RTCBASE + RTC_CMD) & RTC_DATA_RDY)
+#define rtc_status()		(in_8(RTCBASE + RTC_CMD))
+#define rtc_command(x)		out_8(RTCBASE + RTC_CMD, (x))
+#define rtc_read_data()		(in_8(RTCBASE + RTC_DATA))
+#define rtc_write_data(x)	out_8(RTCBASE + RTC_DATA, (x))
+
+#define RTC_SETREG	0xe0
+#define RTC_WRITEREG	0xc2
+#define RTC_READREG	0xc3
+
+#define RTC_REG_SEC2	0
+#define RTC_REG_SEC1	1
+#define RTC_REG_MIN2	2
+#define RTC_REG_MIN1	3
+#define RTC_REG_HOUR2	4
+#define RTC_REG_HOUR1	5
+#define RTC_REG_WDAY	6
+#define RTC_REG_DAY2	7
+#define RTC_REG_DAY1	8
+#define RTC_REG_MON2	9
+#define RTC_REG_MON1	10
+#define RTC_REG_YEAR2	11
+#define RTC_REG_YEAR1	12
+
+#define RTC_HOUR1_24HMODE 0x8
+
+#define RTC_STAT_MASK	0xf0
+#define RTC_STAT_RDY	0x40
+
+static inline unsigned char hp300_rtc_read(unsigned char reg)
+{
+	unsigned char s, ret;
+	unsigned long flags;
+
+	local_irq_save(flags);
+
+	while (rtc_busy());
+	rtc_command(RTC_SETREG);
+	while (rtc_busy());
+	rtc_write_data(reg);
+	while (rtc_busy());
+	rtc_command(RTC_READREG);
+
+	do {
+		while (!rtc_data_available());
+		s = rtc_status();
+		ret = rtc_read_data();
+	} while ((s & RTC_STAT_MASK) != RTC_STAT_RDY);
+
+	local_irq_restore(flags);
+
+	return ret;
+}
+
+static inline unsigned char hp300_rtc_write(unsigned char reg,
+					    unsigned char val)
+{
+	unsigned char s, ret;
+	unsigned long flags;
+
+	local_irq_save(flags);
+
+	while (rtc_busy());
+	rtc_command(RTC_SETREG);
+	while (rtc_busy());
+	rtc_write_data((val << 4) | reg);
+	while (rtc_busy());
+	rtc_command(RTC_WRITEREG);
+	while (rtc_busy());
+	rtc_command(RTC_READREG);
+
+	do {
+		while (!rtc_data_available());
+		s = rtc_status();
+		ret = rtc_read_data();
+	} while ((s & RTC_STAT_MASK) != RTC_STAT_RDY);
+
+	local_irq_restore(flags);
+
+	return ret;
+}
+
+static int hp300_hwclk(int op, struct rtc_time *t)
+{
+	if (!op) { /* read */
+		t->tm_sec  = hp300_rtc_read(RTC_REG_SEC1) * 10 +
+			hp300_rtc_read(RTC_REG_SEC2);
+		t->tm_min  = hp300_rtc_read(RTC_REG_MIN1) * 10 +
+			hp300_rtc_read(RTC_REG_MIN2);
+		t->tm_hour = (hp300_rtc_read(RTC_REG_HOUR1) & 3) * 10 +
+			hp300_rtc_read(RTC_REG_HOUR2);
+		t->tm_wday = -1;
+		t->tm_mday = hp300_rtc_read(RTC_REG_DAY1) * 10 +
+			hp300_rtc_read(RTC_REG_DAY2);
+		t->tm_mon  = hp300_rtc_read(RTC_REG_MON1) * 10 +
+			hp300_rtc_read(RTC_REG_MON2) - 1;
+		t->tm_year = hp300_rtc_read(RTC_REG_YEAR1) * 10 +
+			hp300_rtc_read(RTC_REG_YEAR2);
+		if (t->tm_year <= 69)
+			t->tm_year += 100;
+	} else {
+		hp300_rtc_write(RTC_REG_SEC1, t->tm_sec / 10);
+		hp300_rtc_write(RTC_REG_SEC2, t->tm_sec % 10);
+		hp300_rtc_write(RTC_REG_MIN1, t->tm_min / 10);
+		hp300_rtc_write(RTC_REG_MIN2, t->tm_min % 10);
+		hp300_rtc_write(RTC_REG_HOUR1,
+				((t->tm_hour / 10) & 3) | RTC_HOUR1_24HMODE);
+		hp300_rtc_write(RTC_REG_HOUR2, t->tm_hour % 10);
+		hp300_rtc_write(RTC_REG_DAY1, t->tm_mday / 10);
+		hp300_rtc_write(RTC_REG_DAY2, t->tm_mday % 10);
+		hp300_rtc_write(RTC_REG_MON1, (t->tm_mon + 1) / 10);
+		hp300_rtc_write(RTC_REG_MON2, (t->tm_mon + 1) % 10);
+		if (t->tm_year >= 100)
+			t->tm_year -= 100;
+		hp300_rtc_write(RTC_REG_YEAR1, t->tm_year / 10);
+		hp300_rtc_write(RTC_REG_YEAR2, t->tm_year % 10);
+	}
+
+	return 0;
+}
+
+static unsigned int hp300_get_ss(void)
+{
+	return hp300_rtc_read(RTC_REG_SEC1) * 10 +
+		hp300_rtc_read(RTC_REG_SEC2);
 }
 
 void __init config_hp300(void)
 {
-  mach_sched_init      = hp300_sched_init;
-  mach_init_IRQ        = hp300_init_IRQ;
-  mach_request_irq     = hp300_request_irq;
-  mach_free_irq        = hp300_free_irq;
-  mach_get_model       = hp300_get_model;
-  mach_get_irq_list    = show_hp300_interrupts;
-  mach_gettimeoffset   = hp300_gettimeoffset;
-  mach_default_handler = &hp300_default_handler;
-  mach_reset           = hp300_reset;
+	mach_sched_init      = hp300_sched_init;
+	mach_init_IRQ        = hp300_init_IRQ;
+	mach_request_irq     = hp300_request_irq;
+	mach_free_irq        = hp300_free_irq;
+	mach_get_model       = hp300_get_model;
+	mach_get_irq_list    = show_hp300_interrupts;
+	mach_gettimeoffset   = hp300_gettimeoffset;
+	mach_default_handler = &hp300_default_handler;
+	mach_hwclk	     = hp300_hwclk;
+	mach_get_ss	     = hp300_get_ss;
+	mach_reset           = hp300_reset;
 #ifdef CONFIG_HEARTBEAT
-  mach_heartbeat       = hp300_pulse;
+	mach_heartbeat       = hp300_pulse;
 #endif
 #ifdef CONFIG_DUMMY_CONSOLE
-  conswitchp	       = &dummy_con;
+	conswitchp	     = &dummy_con;
+#endif
+	mach_max_dma_address = 0xffffffff;
+
+	if (hp300_model >= HP_330 && hp300_model <= HP_433S && hp300_model != HP_350) {
+		printk(KERN_INFO "Detected HP9000 model %s\n", hp300_models[hp300_model-HP_320]);
+		strcat(hp300_model_name, hp300_models[hp300_model-HP_320]);
+	}
+	else {
+		panic("Unknown HP9000 Model");
+	}
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+	hp300_setup_serial_console();
 #endif
-  mach_max_dma_address = 0xffffffff;
 }
diff -Nru a/arch/m68k/hp300/ints.c b/arch/m68k/hp300/ints.c
--- a/arch/m68k/hp300/ints.c	2004-12-24 13:37:03 -08:00
+++ b/arch/m68k/hp300/ints.c	2004-12-24 13:37:03 -08:00
@@ -57,14 +57,21 @@
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t hp300_badint(int irq, void *dev_id, struct pt_regs *fp)
+{
+	num_spurious += 1;
+	return IRQ_NONE;
+}
+
 irqreturn_t (*hp300_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = {
-	[0] = hp300_int_handler,
+	[0] = hp300_badint,
 	[1] = hp300_int_handler,
 	[2] = hp300_int_handler,
 	[3] = hp300_int_handler,
 	[4] = hp300_int_handler,
 	[5] = hp300_int_handler,
 	[6] = hp300_int_handler,
+	[7] = hp300_int_handler
 };
 
 /* dev_id had better be unique to each handler because it's the only way we have
diff -Nru a/arch/m68k/hp300/reboot.S b/arch/m68k/hp300/reboot.S
--- a/arch/m68k/hp300/reboot.S	2004-12-24 13:36:31 -08:00
+++ b/arch/m68k/hp300/reboot.S	2004-12-24 13:36:31 -08:00
@@ -13,23 +13,4 @@
 
 	.globl	hp300_reset
 hp300_reset:
-	.chip	68030
-	oriw    #0x0700,%sr			/* cli() */
-	movel	hp300_phys_ram_base, %d1
-	movel	#0, %d0
-	movec	%d0, %vbr			/* reset vector table */
-	lea	zero, %a0
-	lea	1f, %a1
-	add	%d1, %a0
-	add	%d1, %a1
-	pmove	%tc, %a0@
-	bclr	#7, %a0@
-	pmove	%a0@, %tc			/* goodbye MMU */
-	jmp	%a1@
-1:	movel	#0x808, %d0
-	movec	%d0, %cacr			/* cache off */
-	moveb	#0, 0x1ffff
-	movel	#0x1a4, %a0
-	jmp	%a0@
-
-zero:	.quad	0
+	jmp	hp300_reset
diff -Nru a/arch/m68k/hp300/time.c b/arch/m68k/hp300/time.c
--- a/arch/m68k/hp300/time.c	2004-12-24 13:37:18 -08:00
+++ b/arch/m68k/hp300/time.c	2004-12-24 13:37:18 -08:00
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/traps.h>
+#include <asm/blinken.h>
 #include "ints.h"
 
 /* Clock hardware definitions */
@@ -38,11 +39,13 @@
 
 static irqreturn_t hp300_tick(int irq, void *dev_id, struct pt_regs *regs)
 {
-  unsigned long tmp;
-  irqreturn_t (*vector)(int, void *, struct pt_regs *) = dev_id;
-  in_8(CLOCKBASE + CLKSR);
-  asm volatile ("movpw %1@(5),%0" : "=d" (tmp) : "a" (CLOCKBASE));
-  return vector(irq, NULL, regs);
+	unsigned long tmp;
+	irqreturn_t (*vector)(int, void *, struct pt_regs *) = dev_id;
+	in_8(CLOCKBASE + CLKSR);
+	asm volatile ("movpw %1@(5),%0" : "=d" (tmp) : "a" (CLOCKBASE));
+	/* Turn off the network and SCSI leds */
+	blinken_leds(0, 0xe0);
+	return vector(irq, NULL, regs);
 }
 
 unsigned long hp300_gettimeoffset(void)
diff -Nru a/arch/m68k/kernel/bios32.c b/arch/m68k/kernel/bios32.c
--- a/arch/m68k/kernel/bios32.c	2004-12-24 13:36:56 -08:00
+++ b/arch/m68k/kernel/bios32.c	2004-12-24 13:36:56 -08:00
@@ -46,8 +46,6 @@
 
 #define ALIGN(val,align)	(((val) + ((align) - 1)) & ~((align) - 1))
 
-#define MAX(val1, val2)		(((val1) > (val2)) ? val1 : val2)
-
 /*
  * Offsets relative to the I/O and memory base addresses from where resources
  * are allocated.
@@ -171,7 +169,7 @@
 			 * Align to multiple of size of minimum base.
 			 */
 
-			alignto = MAX(0x040, size) ;
+			alignto = max_t(unsigned int, 0x040, size);
 			base = ALIGN(io_base, alignto);
 			io_base = base + size;
 			pci_write_config_dword(dev, reg, base | PCI_BASE_ADDRESS_SPACE_IO);
@@ -214,7 +212,7 @@
 			 * Align to multiple of size of minimum base.
 			 */
 
-			alignto = MAX(0x1000, size) ;
+			alignto = max_t(unsigned int, 0x1000, size);
 			base = ALIGN(mem_base, alignto);
 			mem_base = base + size;
 			pci_write_config_dword(dev, reg, base);
diff -Nru a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
--- a/arch/m68k/kernel/entry.S	2004-12-24 13:36:17 -08:00
+++ b/arch/m68k/kernel/entry.S	2004-12-24 13:36:17 -08:00
@@ -663,3 +663,50 @@
 	.long sys_lremovexattr
 	.long sys_fremovexattr
 	.long sys_futex		/* 235 */
+	.long sys_sendfile64
+	.long sys_mincore
+	.long sys_madvise
+	.long sys_fcntl64
+	.long sys_readahead	/* 240 */
+	.long sys_io_setup
+	.long sys_io_destroy
+	.long sys_io_getevents
+	.long sys_io_submit
+	.long sys_io_cancel	/* 245 */
+	.long sys_fadvise64
+	.long sys_exit_group
+	.long sys_lookup_dcookie
+	.long sys_epoll_create
+	.long sys_epoll_ctl	/* 250 */
+	.long sys_epoll_wait
+	.long sys_remap_file_pages
+	.long sys_set_tid_address
+	.long sys_timer_create
+	.long sys_timer_settime	/* 255 */
+	.long sys_timer_gettime
+	.long sys_timer_getoverrun
+	.long sys_timer_delete
+	.long sys_clock_settime
+	.long sys_clock_gettime	/* 260 */
+	.long sys_clock_getres
+	.long sys_clock_nanosleep
+	.long sys_statfs64
+	.long sys_fstatfs64
+	.long sys_tgkill	/* 265 */
+	.long sys_utimes
+	.long sys_fadvise64_64
+	.long sys_mbind	
+	.long sys_get_mempolicy
+	.long sys_set_mempolicy	/* 270 */
+	.long sys_mq_open
+	.long sys_mq_unlink
+	.long sys_mq_timedsend
+	.long sys_mq_timedreceive
+	.long sys_mq_notify	/* 275 */
+	.long sys_mq_getsetattr
+	.long sys_waitid
+	.long sys_ni_syscall	/* for sys_vserver */
+	.long sys_add_key
+	.long sys_request_key	/* 280 */
+	.long sys_keyctl
+
diff -Nru a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
--- a/arch/m68k/kernel/head.S	2004-12-24 13:37:32 -08:00
+++ b/arch/m68k/kernel/head.S	2004-12-24 13:37:32 -08:00
@@ -24,6 +24,7 @@
 ** 1998/08/30 David Kilzer: Added support for font_desc structures
 **            for linux-2.1.115
 ** 9/02/11  Richard Zidlicky: added Q40 support (initial vesion 99/01/01)
+** 2004/05/13 Kars de Jong: Finalised HP300 support
 **
 ** This file is subject to the terms and conditions of the GNU General Public
 ** License. See the file README.legal in the main directory of this archive
@@ -313,9 +314,6 @@
 #ifdef CONFIG_Q40
 .globl q40_mem_cptr
 #endif
-#ifdef CONFIG_HP300
-.globl hp300_phys_ram_base
-#endif
 
 CPUTYPE_040	= 1	/* indicates an 040 */
 CPUTYPE_060	= 2	/* indicates an 060 */
@@ -467,7 +465,7 @@
 func_define	mmu_get_page_table_entry,2
 func_define	mmu_print
 func_define	get_new_page
-#ifdef CONFIG_HP300
+#if defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
 func_define	set_leds
 #endif
 
@@ -594,6 +592,7 @@
 	.long	MACH_BVME6000, BVME6000_BOOTI_VERSION
 	.long	MACH_MAC, MAC_BOOTI_VERSION
 	.long	MACH_Q40, Q40_BOOTI_VERSION
+	.long	MACH_HP300, HP300_BOOTI_VERSION
 	.long	0
 1:	jra	__start
 
@@ -605,65 +604,6 @@
 	jra	__start
 __INIT
 ENTRY(__start)
-
-#ifdef CONFIG_HP300
-/* This is a hack.  The HP NetBSD bootloader loads us at an arbitrary
-   address (apparently 0xff002000 in practice) which is not good if we need
-   to be able to map this to VA 0x1000.  We could do it with pagetables but
-   a better solution seems to be to relocate the kernel in physical memory
-   before we start.
-
-   So, we copy the entire kernel image (code+data+bss) down to the 16MB
-   boundary that marks the start of RAM.  This is slightly tricky because
-   we must not overwrite the copying code itself. :-)  */
-
-/* 15/5/98.  The start address of physical RAM changes depending on how much
-   RAM is present.  This is actually a blessing in disguise as it provides
-   a way for us to work out the RAM size rather than hardwiring it.  */
-
-	lea	%pc@(_start),%a0
-	movel	%a0,%d6
-	and	#0xffff0000, %d6
-	lea	%pc@(hp300_phys_ram_base),%a0
-	movel	%d6, %a0@
-	movel	%pc@(L(custom)),%a3
-	moveb	#0xfe,%d7
-	moveb	%d7,%a3@(0x1ffff)
-	lea	%pc@(Lcopystart),%a0
-	lea	%pc@(Lcopyend),%a1
-	movel	%d6,%a2			/* Start of physical RAM */
-1:	moveb	%a0@+,%d0
-	moveb	%d0,%a2@+
-	cmpl	%a0,%a1
-	jbne	1b
-	movel	%d6,%a2
-	moveb	#0xfd,%d7
-	moveb	%d7,%a3@(0x1ffff)
-	lea	%pc@(_stext),%a0
-	lea	%pc@(_end),%a1
-	jmp	%a2@
-
-Lcopystart:
-	moveb	#0xf7,%d7
-	moveb	%d7,%a3@(0x1ffff)
-	movel	%d6,%a2	/* Start of kernel */
-	add	#0x1000,%a2
-1:	moveb	%a0@+,%d0
-	moveb	%d0,%a2@+
-	cmpl	%a0,%a1
-	jbne	1b
-	moveb	#0,%d7
-	moveb	%d7,%a3@(0x1ffff)
-	movel	%d6,%a0
-	addl	#Lstart1,%a0
-	jmp	%a0@
-Lcopyend:
-
-Lstart1:
-	moveb	#0x3f,%d7
-	moveb	%d7,%a3@(0x1ffff)
-#endif /* CONFIG_HP300 */
-
 /*
  * Setup initial stack pointer
  */
@@ -672,8 +612,6 @@
 /*
  * Record the CPU and machine type.
  */
-
-#ifndef CONFIG_HP300
 	get_bi_record	BI_MACHTYPE
 	lea	%pc@(m68k_machtype),%a1
 	movel	%a0@,%a1@
@@ -689,23 +627,8 @@
 	get_bi_record	BI_CPUTYPE
 	lea	%pc@(m68k_cputype),%a1
 	movel	%a0@,%a1@
-#else /* CONFIG_HP300 */
-	/* FIXME HP300 doesn't use bootinfo yet */
-	movel	#MACH_HP300,%d4
-	lea	%pc@(m68k_machtype),%a0
-	movel	%d4,%a0@
-	movel	#FPU_68881,%d0
-	lea	%pc@(m68k_fputype),%a0
-	movel	%d0,%a0@
-	movel	#MMU_68030,%d0
-	lea	%pc@(m68k_mmutype),%a0
-	movel	%d0,%a0@
-	movel	#CPU_68030,%d0
-	lea	%pc@(m68k_cputype),%a0
-	movel	%d0,%a0@
 
-	leds(0x1)
-#endif /* CONFIG_HP300 */
+	leds	0x1
 
 #ifdef CONFIG_MAC
 /*
@@ -956,6 +879,26 @@
 
 #endif
 
+#ifdef CONFIG_HP300
+	is_not_hp300(L(nothp))
+
+	/* Get the address of the UART for serial debugging */
+	get_bi_record	BI_HP300_UART_ADDR
+	tstl	%d0
+	jbmi	1f
+	movel	%a0@,%d3
+	lea	%pc@(L(uartbase)),%a0
+	movel	%d3,%a0@
+	get_bi_record	BI_HP300_UART_SCODE
+	tstl	%d0
+	jbmi	1f
+	movel	%a0@,%d3
+	lea	%pc@(L(uart_scode)),%a0
+	movel	%d3,%a0@
+1:
+L(nothp):
+#endif
+
 /*
  * Initialize serial port
  */
@@ -979,9 +922,7 @@
 
 	putc	'\n'
 	putc	'A'
-#ifdef CONFIG_HP300
-	leds(0x2)
-#endif /* CONFIG_HP300 */
+	leds	0x2
 	dputn	%pc@(L(cputype))
 	dputn	%pc@(m68k_supervisor_cachemode)
 	dputn	%pc@(m68k_pgtable_cachemode)
@@ -1124,16 +1065,30 @@
 #ifdef CONFIG_HP300
 	is_not_hp300(L(nothp300))
 
-/* On the HP300, we map the ROM, INTIO and DIO regions (phys. 0x00xxxxxx)
-   by mapping 32MB from 0xf0xxxxxx -> 0x00xxxxxx) using an 030 early
-   termination page descriptor.  The ROM mapping is needed because the LEDs
-   are mapped there too.  */
+	/* On the HP300, we map the ROM, INTIO and DIO regions (phys. 0x00xxxxxx)
+	 * by mapping 32MB (on 020/030) or 16 MB (on 040) from 0xf0xxxxxx -> 0x00xxxxxx).
+	 * The ROM mapping is needed because the LEDs are mapped there too.
+	 */
+
+	is_040(1f)
 
+	/*
+	 * 030: Map the 32Meg range physical 0x0 upto logical 0xf000.0000
+	 */
 	mmu_map	#0xf0000000,#0,#0x02000000,#_PAGE_NOCACHE030
 
-L(nothp300):
+	jbra	L(mmu_init_done)
 
-#endif
+1:
+	/*
+	 * 040: Map the 16Meg range physical 0x0 upto logical 0xf000.0000
+	 */
+	mmu_map #0xf0000000,#0,#0x01000000,#_PAGE_NOCACHE_S
+
+	jbra	L(mmu_init_done)
+
+L(nothp300):
+#endif /* CONFIG_HP300 */
 
 #ifdef CONFIG_MVME147
 
@@ -1480,15 +1435,23 @@
 #ifdef CONFIG_HP300
 	is_not_hp300(1f)
 	/*
-	 * Fix up the custom register to point to the new location of the LEDs.
+	 * Fix up the iobase register to point to the new location of the LEDs.
 	 */
-	movel	#0xf0000000,L(custom)
+	movel	#0xf0000000,L(iobase)
 
 	/*
 	 * Energise the FPU and caches.
 	 */
+	is_040(1f)
 	movel	#0x60,0xf05f400c
-1:
+	jbra	2f
+
+	/*
+	 * 040: slightly different, apparently.
+	 */
+1:	movew	#0,0xf05f400e
+	movew	#0x64,0xf05f400e
+2:
 #endif
 
 #ifdef CONFIG_SUN3X
@@ -1585,7 +1548,6 @@
 
 	movel	ARG1,%d0
 	lea	%pc@(_end),%a0
-#ifndef CONFIG_HP300
 1:	tstw	%a0@(BIR_TAG)
 	jeq	3f
 	cmpw	%a0@(BIR_TAG),%d0
@@ -1599,7 +1561,6 @@
 3:	moveq	#-1,%d0
 	lea	%a0@(BIR_SIZE),%a0
 4:
-#endif /* CONFIG_HP300 */
 func_return	get_bi_record
 
 
@@ -3013,6 +2974,10 @@
 /* We count on the PROM initializing SIO1 */
 #endif
 
+#ifdef CONFIG_HP300
+/* We count on the boot loader initialising the UART */
+#endif
+
 L(serial_init_done):
 func_return	serial_init
 
@@ -3205,9 +3170,31 @@
 1:      moveb   %a1@(LSRB0),%d0
 	andb	#0x4,%d0
 	beq	1b
+	jbra	L(serial_putc_done)
 2:
 #endif
 
+#ifdef CONFIG_HP300
+	is_not_hp300(3f)
+	movl    %pc@(L(iobase)),%a1
+	addl	%pc@(L(uartbase)),%a1
+	movel	%pc@(L(uart_scode)),%d1	/* Check the scode */
+	jmi	3f			/* Unset? Exit */
+	cmpi	#256,%d1		/* APCI scode? */
+	jeq	2f
+1:      moveb   %a1@(DCALSR),%d1	/* Output to DCA */
+	andb	#0x20,%d1
+	beq	1b
+	moveb	%d0,%a1@(DCADATA)
+	jbra	L(serial_putc_done)
+2:	moveb	%a1@(APCILSR),%d1	/* Output to APCI */
+	andb	#0x20,%d1
+	beq	2b
+	moveb	%d0,%a1@(APCIDATA)
+	jbra	L(serial_putc_done)
+3:
+#endif
+	
 L(serial_putc_done):
 func_return	serial_putc
 
@@ -3295,7 +3282,7 @@
 	movel	ARG1,%d0
 #ifdef CONFIG_HP300
 	is_not_hp300(1f)
-	movel	%pc@(L(custom)),%a0
+	movel	%pc@(L(iobase)),%a0
 	moveb	%d0,%a0@(0x1ffff)
 	jra	2f
 #endif
@@ -3829,10 +3816,6 @@
 __INITDATA
 	.align	4
 
-#ifdef CONFIG_HP300
-hp300_phys_ram_base:
-#endif
-
 #if defined(CONFIG_ATARI) || defined(CONFIG_AMIGA) || \
     defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
 L(custom):
@@ -3922,6 +3905,17 @@
 LSRB0        = 0x10412
 LTHRB0       = 0x10416
 LCPUCTRL     = 0x10100
+#endif
+
+#if defined(CONFIG_HP300)
+DCADATA	     = 0x11
+DCALSR	     = 0x1b
+APCIDATA     = 0x00
+APCILSR      = 0x14
+L(uartbase):
+	.long	0
+L(uart_scode):
+	.long	-1
 #endif
 
 __FINIT
diff -Nru a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c
--- a/arch/m68k/kernel/ptrace.c	2004-12-24 13:36:31 -08:00
+++ b/arch/m68k/kernel/ptrace.c	2004-12-24 13:36:31 -08:00
@@ -277,7 +277,7 @@
 			long tmp;
 
 			ret = 0;
-			if (child->state == TASK_ZOMBIE) /* already dead */
+			if (child->exit_state == EXIT_ZOMBIE) /* already dead */
 				break;
 			child->exit_code = SIGKILL;
 	/* make sure the single step bit is not set. */
diff -Nru a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c
--- a/arch/m68k/kernel/setup.c	2004-12-24 13:37:29 -08:00
+++ b/arch/m68k/kernel/setup.c	2004-12-24 13:37:29 -08:00
@@ -109,6 +109,7 @@
 extern int bvme6000_parse_bootinfo(const struct bi_record *);
 extern int mvme16x_parse_bootinfo(const struct bi_record *);
 extern int mvme147_parse_bootinfo(const struct bi_record *);
+extern int hp300_parse_bootinfo(const struct bi_record *);
 
 extern void config_amiga(void);
 extern void config_atari(void);
@@ -175,6 +176,8 @@
 		    unknown = mvme16x_parse_bootinfo(record);
 		else if (MACH_IS_MVME147)
 		    unknown = mvme147_parse_bootinfo(record);
+		else if (MACH_IS_HP300)
+		    unknown = hp300_parse_bootinfo(record);
 		else
 		    unknown = 1;
 	}
@@ -204,20 +207,8 @@
 	int i;
 	char *p, *q;
 
-	if (!MACH_IS_HP300) {
-		/* The bootinfo is located right after the kernel bss */
-		m68k_parse_bootinfo((const struct bi_record *)&_end);
-	} else {
-		/* FIXME HP300 doesn't use bootinfo yet */
-		extern unsigned long hp300_phys_ram_base;
-		unsigned long hp300_mem_size = 0xffffffff-hp300_phys_ram_base;
-		m68k_cputype = CPU_68030;
-		m68k_fputype = FPU_68882;
-		m68k_memory[0].addr = hp300_phys_ram_base;
-		/* 0.5M fudge factor */
-		m68k_memory[0].size = hp300_mem_size-512*1024;
-		m68k_num_memory++;
-	}
+	/* The bootinfo is located right after the kernel bss */
+	m68k_parse_bootinfo((const struct bi_record *)&_end);
 
 	if (CPU_IS_040)
 		m68k_is040or060 = 4;
@@ -352,7 +343,7 @@
 #ifndef CONFIG_SUN3
 	startmem= m68k_memory[0].addr;
 	endmem = startmem + m68k_memory[0].size;
-	high_memory = PAGE_OFFSET;
+	high_memory = (void *)PAGE_OFFSET;
 	for (i = 0; i < m68k_num_memory; i++) {
 		m68k_memory[i].size &= MASK_256K;
 		if (m68k_memory[i].addr < startmem)
@@ -550,7 +541,5 @@
 				"emulation project\n" );
 		panic( "no FPU" );
 	}
-
-#endif /* CONFIG_SUN3 */
-
+#endif /* !CONFIG_M68KFPU_EMU */
 }
diff -Nru a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
--- a/arch/m68k/kernel/time.c	2004-12-24 13:36:31 -08:00
+++ b/arch/m68k/kernel/time.c	2004-12-24 13:36:31 -08:00
@@ -45,6 +45,9 @@
 static irqreturn_t timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
 {
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	profile_tick(CPU_PROFILING, regs);
 
 #ifdef CONFIG_HEARTBEAT
diff -Nru a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
--- a/arch/m68k/kernel/vmlinux-std.lds	2004-12-24 13:37:19 -08:00
+++ b/arch/m68k/kernel/vmlinux-std.lds	2004-12-24 13:37:19 -08:00
@@ -15,7 +15,7 @@
 	SCHED_TEXT
 	*(.fixup)
 	*(.gnu.warning)
-	} = 0x4e75
+	} :text = 0x4e75
 
   . = ALIGN(16);		/* Exception table */
   __start___ex_table = .;
@@ -34,7 +34,7 @@
   .bss : { *(.bss) }		/* BSS */
 
   . = ALIGN(16);
-  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
+  .data.cacheline_aligned : { *(.data.cacheline_aligned) } :data
 
   _edata = .;			/* End of data section */
 
diff -Nru a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
--- a/arch/m68k/kernel/vmlinux-sun3.lds	2004-12-24 13:36:16 -08:00
+++ b/arch/m68k/kernel/vmlinux-sun3.lds	2004-12-24 13:36:16 -08:00
@@ -16,7 +16,7 @@
 	SCHED_TEXT
 	*(.fixup)
 	*(.gnu.warning)
-	} = 0x4e75
+	} :text = 0x4e75
 	RODATA
 
   _etext = .;			/* End of text section */
@@ -28,7 +28,7 @@
 	__start___ex_table = .;
 	*(__ex_table)
 	__stop___ex_table = .;
-	}
+	} :data
   /* End of data goes *here* so that freeing init code works properly. */
   _edata = .;
 
diff -Nru a/arch/m68k/kernel/vmlinux.lds.S b/arch/m68k/kernel/vmlinux.lds.S
--- a/arch/m68k/kernel/vmlinux.lds.S	2004-12-24 13:36:47 -08:00
+++ b/arch/m68k/kernel/vmlinux.lds.S	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,9 @@
 #include <linux/config.h>
-
+PHDRS
+{
+  text PT_LOAD FILEHDR PHDRS FLAGS (7);
+  data PT_LOAD FLAGS (7);
+}
 #ifdef CONFIG_SUN3
 #include "vmlinux-sun3.lds"
 #else
diff -Nru a/arch/m68k/mm/memory.c b/arch/m68k/mm/memory.c
--- a/arch/m68k/mm/memory.c	2004-12-24 13:37:01 -08:00
+++ b/arch/m68k/mm/memory.c	2004-12-24 13:37:01 -08:00
@@ -77,7 +77,7 @@
 		ptable_desc *new;
 
 		if (!(page = (void *)get_zeroed_page(GFP_KERNEL)))
-			return 0;
+			return NULL;
 
 		flush_tlb_kernel_page(page);
 		nocache_page(page);
diff -Nru a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
--- a/arch/m68k/mm/motorola.c	2004-12-24 13:37:00 -08:00
+++ b/arch/m68k/mm/motorola.c	2004-12-24 13:37:00 -08:00
@@ -258,7 +258,7 @@
 	printk ("before free_area_init\n");
 #endif
 	zones_size[0] = (mach_max_dma_address < (unsigned long)high_memory ?
-			 mach_max_dma_address : (unsigned long)high_memory);
+			 (mach_max_dma_address+1) : (unsigned long)high_memory);
 	zones_size[1] = (unsigned long)high_memory - zones_size[0];
 
 	zones_size[0] = (zones_size[0] - PAGE_OFFSET) >> PAGE_SHIFT;
diff -Nru a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c
--- a/arch/m68k/mm/sun3mmu.c	2004-12-24 13:36:31 -08:00
+++ b/arch/m68k/mm/sun3mmu.c	2004-12-24 13:36:31 -08:00
@@ -7,7 +7,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
diff -Nru a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c
--- a/arch/m68k/q40/config.c	2004-12-24 13:36:49 -08:00
+++ b/arch/m68k/q40/config.c	2004-12-24 13:36:49 -08:00
@@ -33,7 +33,6 @@
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/traps.h>
-#include <asm/rtc.h>
 #include <asm/machdep.h>
 #include <asm/q40_master.h>
 
diff -Nru a/arch/m68k/q40/q40ints.c b/arch/m68k/q40/q40ints.c
--- a/arch/m68k/q40/q40ints.c	2004-12-24 13:37:19 -08:00
+++ b/arch/m68k/q40/q40ints.c	2004-12-24 13:37:19 -08:00
@@ -11,7 +11,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
diff -Nru a/arch/m68k/sun3/Makefile b/arch/m68k/sun3/Makefile
--- a/arch/m68k/sun3/Makefile	2004-12-24 13:37:43 -08:00
+++ b/arch/m68k/sun3/Makefile	2004-12-24 13:37:43 -08:00
@@ -4,5 +4,4 @@
 
 obj-y	:= sun3_ksyms.o sun3ints.o sun3dvma.o sbus.o idprom.o
 
-obj-$(CONFIG_SUN3) += config.o mmu_emu.o leds.o dvma.o \
-			intersil.o
+obj-$(CONFIG_SUN3) += config.o mmu_emu.o leds.o dvma.o intersil.o
diff -Nru a/arch/m68k/sun3/mmu_emu.c b/arch/m68k/sun3/mmu_emu.c
--- a/arch/m68k/sun3/mmu_emu.c	2004-12-24 13:37:00 -08:00
+++ b/arch/m68k/sun3/mmu_emu.c	2004-12-24 13:37:00 -08:00
@@ -12,6 +12,8 @@
 #include <linux/ptrace.h>
 #include <linux/delay.h>
 #include <linux/bootmem.h>
+#include <linux/bitops.h>
+#include <linux/module.h>
 
 #include <asm/setup.h>
 #include <asm/traps.h>
@@ -21,7 +23,6 @@
 #include <asm/pgtable.h>
 #include <asm/sun3mmu.h>
 #include <asm/segment.h>
-#include <asm/bitops.h>
 #include <asm/oplib.h>
 #include <asm/mmu_context.h>
 #include <asm/dvma.h>
@@ -46,6 +47,8 @@
 */
 
 unsigned long vmalloc_end;
+EXPORT_SYMBOL(vmalloc_end);
+
 unsigned long pmeg_vaddr[PMEGS_NUM];
 unsigned char pmeg_alloc[PMEGS_NUM];
 unsigned char pmeg_ctx[PMEGS_NUM];
diff -Nru a/arch/m68k/sun3/sun3dvma.c b/arch/m68k/sun3/sun3dvma.c
--- a/arch/m68k/sun3/sun3dvma.c	2004-12-24 13:37:43 -08:00
+++ b/arch/m68k/sun3/sun3dvma.c	2004-12-24 13:37:43 -08:00
@@ -6,6 +6,7 @@
  * Contains common routines for sun3/sun3x DVMA management.
  */
 
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/list.h>
diff -Nru a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c
--- a/arch/m68k/sun3/sun3ints.c	2004-12-24 13:37:33 -08:00
+++ b/arch/m68k/sun3/sun3ints.c	2004-12-24 13:37:33 -08:00
@@ -6,6 +6,7 @@
  * for more details.
  */
 
+#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -85,6 +86,9 @@
 	intersil_clear();
 #endif
         do_timer(fp);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(fp));
+#endif
         if(!(kstat_cpu(0).irqs[SYS_IRQS + irq] % 20))
                 sun3_leds(led_pattern[(kstat_cpu(0).irqs[SYS_IRQS+irq]%160)
                 /20]);
diff -Nru a/arch/m68k/sun3x/config.c b/arch/m68k/sun3x/config.c
--- a/arch/m68k/sun3x/config.c	2004-12-24 13:36:17 -08:00
+++ b/arch/m68k/sun3x/config.c	2004-12-24 13:36:17 -08:00
@@ -6,6 +6,7 @@
  * based on code from Oliver Jowett <oliver@jowett.manawatu.gen.nz>
  */
 
+#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/console.h>
@@ -70,7 +71,7 @@
 	mach_get_model       = sun3_get_model;
 	mach_get_hardware_list = sun3x_get_hardware_list;
 
-#if defined(CONFIG_DUMMY_CONSOLE)
+#ifdef CONFIG_DUMMY_CONSOLE
 	conswitchp	     = &dummy_con;
 #endif
 
diff -Nru a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
--- a/arch/m68knommu/Kconfig	2004-12-24 13:37:02 -08:00
+++ b/arch/m68knommu/Kconfig	2004-12-24 13:37:02 -08:00
@@ -72,15 +72,20 @@
 	help
 	  Motorola ColdFire 5249 processor support.
 
+config M527x
+	bool "MCF527x"
+	help
+	  Freescale (Motorola) ColdFire 5270/5271/5274/5275 processor support.
+
 config M5272
 	bool "MCF5272"
 	help
 	  Motorola ColdFire 5272 processor support.
 
-config M5282
-	bool "MCF5282"
+config M528x
+	bool "MCF528x"
 	help
-	  Motorola ColdFire 5282 processor support.
+	  Motorola ColdFire 5280/5282 processor support.
 
 config M5307
 	bool "MCF5307"
@@ -96,7 +101,7 @@
 
 config COLDFIRE
 	bool
-	depends on (M5206 || M5206e || M5249 || M5272 || M5282 || M5307 || M5407)
+	depends on (M5206 || M5206e || M5249 || M527x || M5272 || M528x || M5307 || M5407)
 	default y
 
 choice
@@ -117,82 +122,97 @@
 config CLOCK_11MHz
 	bool "11MHz"
 	help
-	  Select an 11MHz CPU clock frequency.
+	  Select a 11MHz CPU clock frequency.
 
 config CLOCK_16MHz
 	bool "16MHz"
 	help
-	  Select an 16MHz CPU clock frequency.
+	  Select a 16MHz CPU clock frequency.
 
 config CLOCK_20MHz
 	bool "20MHz"
 	help
-	  Select an 20MHz CPU clock frequency.
+	  Select a 20MHz CPU clock frequency.
 
 config CLOCK_24MHz
 	bool "24MHz"
 	help
-	  Select an 24MHz CPU clock frequency.
+	  Select a 24MHz CPU clock frequency.
 
 config CLOCK_25MHz
 	bool "25MHz"
 	help
-	  Select an 25MHz CPU clock frequency.
+	  Select a 25MHz CPU clock frequency.
 
 config CLOCK_33MHz
 	bool "33MHz"
 	help
-	  Select an 33MHz CPU clock frequency.
+	  Select a 33MHz CPU clock frequency.
 
 config CLOCK_40MHz
 	bool "40MHz"
 	help
-	  Select an 40MHz CPU clock frequency.
+	  Select a 40MHz CPU clock frequency.
 
 config CLOCK_45MHz
 	bool "45MHz"
 	help
-	  Select an 45MHz CPU clock frequency.
+	  Select a 45MHz CPU clock frequency.
 
 config CLOCK_48MHz
 	bool "48MHz"
 	help
-	  Select an 48MHz CPU clock frequency.
+	  Select a 48MHz CPU clock frequency.
 
 config CLOCK_50MHz
 	bool "50MHz"
 	help
-	  Select an 50MHz CPU clock frequency.
+	  Select a 50MHz CPU clock frequency.
 
 config CLOCK_54MHz
 	bool "54MHz"
 	help
-	  Select an 54MHz CPU clock frequency.
+	  Select a 54MHz CPU clock frequency.
 
 config CLOCK_60MHz
 	bool "60MHz"
 	help
-	  Select an 60MHz CPU clock frequency.
+	  Select a 60MHz CPU clock frequency.
 
 config CLOCK_64MHz
 	bool "64MHz"
 	help
-	  Select an 64MHz CPU clock frequency.
+	  Select a 64MHz CPU clock frequency.
 
 config CLOCK_66MHz
 	bool "66MHz"
 	help
-	  Select an 66MHz CPU clock frequency.
+	  Select a 66MHz CPU clock frequency.
 
 config CLOCK_70MHz
 	bool "70MHz"
 	help
-	  Select an 70MHz CPU clock frequency.
+	  Select a 70MHz CPU clock frequency.
+
+config CLOCK_100MHz
+	bool "100MHz"
+	help
+	  Select a 100MHz CPU clock frequency.
 
 config CLOCK_140MHz
 	bool "140MHz"
 	help
-	  Select an 140MHz CPU clock frequency.
+	  Select a 140MHz CPU clock frequency.
+
+config CLOCK_150MHz
+	bool "150MHz"
+	help
+	  Select a 150MHz CPU clock frequency.
+
+config CLOCK_166MHz
+	bool "166MHz"
+	help
+	  Select a 166MHz CPU clock frequency.
 
 endchoice
 
@@ -284,6 +304,18 @@
 	help
 	  Support for the Motorola M5249C3 board.
 
+config M5271EVB
+	bool "Freescale (Motorola) M5271EVB board support"
+	depends on M527x
+	help
+	  Support for the Freescale (Motorola) M5271EVB board.
+
+config M5275EVB
+	bool "Freescale (Motorola) M5275EVB board support"
+	depends on M527x
+	help
+	  Support for the Freescale (Motorola) M5275EVB board.
+
 config M5272C3
 	bool "Motorola M5272C3 board support"
 	depends on M5272
@@ -296,15 +328,21 @@
 	help
 	  Support for the senTec COBRA5272 board.
 
-config M5282C3
-	bool "Motorola M5282C3 board support"
-	depends on M5282
+config M5275EVB
+	bool "Freescale (Motorola) M5275EVB board support"
+	depends on M527x
+	help
+	  Support for the Freescale (Motorola) M5275EVB board.
+
+config M5282EVB
+	bool "Motorola M5282EVB board support"
+	depends on M528x
 	help
-	  Support for the Motorola M5282C3 board.
+	  Support for the Motorola M5282EVB board.
 
 config COBRA5282
 	bool "senTec COBRA5282 board support"
-	depends on M5282
+	depends on M528x
 	help
 	  Support for the senTec COBRA5282 board.
 
@@ -344,6 +382,18 @@
 	help
 	  Support for the Feith Cleopatra boards.
 
+config CANCam
+	bool "Feith CANCam board support"
+	depends on M5272
+	help
+	  Support for the Feith CANCam board.
+
+config SCALES
+	bool "Feith SCALES board support"
+	depends on M5272
+	help
+	  Support for the Feith SCALES board.
+
 config NETtel
 	bool "SecureEdge/NETtel board support"
 	depends on (M5206e || M5272 || M5307)
@@ -356,6 +406,12 @@
 	help
 	  Special additional support for SnapGear router boards.
 
+config CPU16B
+	bool "Sneha Technologies S.L. Sarasvati board support"
+	depends on M5272
+	help
+	  Support for the SNEHA CPU16B board.
+
 config ROMFS_FROM_ROM
 	bool "  ROMFS image not RAM resident"
 	depends on (NETtel || SNAPGEAR)
@@ -376,13 +432,23 @@
 config MOTOROLA
 	bool
 	default y
-	depends on (M5206eC3 || M5249C3 || M5272C3 || M5282C3 || M5307C3 || M5407C3)
+	depends on (M5206eC3 || M5249C3 || M5271EVB || M5272C3 || M5275EVB || M5282EVB || M5307C3 || M5407C3)
+
+config HW_FEITH
+	bool
+	default y
+	depends on (CLEOPATRA || CANCam || SCALES)
 
 config senTec
 	bool
 	default y
 	depends on (COBRA5272 || COBRA5282)
 
+config SNEHA
+        bool
+	default y
+	depends on CPU16B
+	
 config LARGE_ALLOCS
 	bool "Allow allocating large blocks (> 1MB) of memory"
 	help
diff -Nru a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile
--- a/arch/m68knommu/Makefile	2004-12-24 13:37:02 -08:00
+++ b/arch/m68knommu/Makefile	2004-12-24 13:37:02 -08:00
@@ -15,8 +15,9 @@
 platform-$(CONFIG_M5206)	:= 5206
 platform-$(CONFIG_M5206e)	:= 5206e
 platform-$(CONFIG_M5249)	:= 5249
+platform-$(CONFIG_M527x)	:= 527x
 platform-$(CONFIG_M5272)	:= 5272
-platform-$(CONFIG_M5282)	:= 5282
+platform-$(CONFIG_M528x)	:= 528x
 platform-$(CONFIG_M5307)	:= 5307
 platform-$(CONFIG_M5407)	:= 5407
 PLATFORM := $(platform-y)
@@ -28,12 +29,16 @@
 board-$(CONFIG_DRAGEN2)		:= de2
 board-$(CONFIG_ARNEWSH)		:= ARNEWSH
 board-$(CONFIG_MOTOROLA)	:= MOTOROLA
+board-$(CONFIG_M5271EVB)	:= M5271EVB
+board-$(CONFIG_M5275EVB)	:= M5275EVB
+board-$(CONFIG_M5282EVB)	:= M5282EVB
 board-$(CONFIG_ELITE)		:= eLITE
 board-$(CONFIG_eLIA)		:= eLIA
 board-$(CONFIG_NETtel)		:= NETtel
 board-$(CONFIG_SECUREEDGEMP3)	:= MP3
 board-$(CONFIG_CLEOPATRA)	:= CLEOPATRA
-board-$(CONFIG_senTec) 	:= senTec
+board-$(CONFIG_senTec)		:= senTec
+board-$(CONFIG_SNEHA) 	        := SNEHA
 BOARD := $(board-y)
 
 model-$(CONFIG_RAMKERNEL)	:= ram
@@ -50,8 +55,9 @@
 cpuclass-$(CONFIG_M5206)	:= 5307
 cpuclass-$(CONFIG_M5206e)	:= 5307
 cpuclass-$(CONFIG_M5249)	:= 5307
+cpuclass-$(CONFIG_M527x)	:= 5307
 cpuclass-$(CONFIG_M5272)	:= 5307
-cpuclass-$(CONFIG_M5282)	:= 5307
+cpuclass-$(CONFIG_M528x)	:= 5307
 cpuclass-$(CONFIG_M5407)	:= 5307
 cpuclass-$(CONFIG_M68EZ328)	:= 68328
 cpuclass-$(CONFIG_M68VZ328)	:= 68328
@@ -69,8 +75,9 @@
 cflags-$(CONFIG_M5206)		:= -m5200 -Wa,-S -Wa,-m5200
 cflags-$(CONFIG_M5206e)		:= -m5200 -Wa,-S -Wa,-m5200
 cflags-$(CONFIG_M5249)		:= -m5200 -Wa,-S -Wa,-m5200
+cflags-$(CONFIG_M527x)		:= -m5307 -Wa,-S -Wa,-m5307
 cflags-$(CONFIG_M5272)		:= -m5307 -Wa,-S -Wa,-m5307
-cflags-$(CONFIG_M5282)		:= -m5307 -Wa,-S -Wa,-m5307
+cflags-$(CONFIG_M528x)		:= -m5307 -Wa,-S -Wa,-m5307
 cflags-$(CONFIG_M5307)		:= -m5307 -Wa,-S -Wa,-m5307
 cflags-$(CONFIG_M5407)		:= -m5200 -Wa,-S -Wa,-m5200
 cflags-$(CONFIG_M68328)		:= -m68000
@@ -82,7 +89,7 @@
 
 CFLAGS += $(cflags-y)
 CFLAGS += -fno-builtin
-CFLAGS += -O2 -g
+CFLAGS += -O1 -g
 CFLAGS += -D__linux__
 CFLAGS += -DUTS_SYSNAME=\"uClinux\"
 
diff -Nru a/arch/m68knommu/defconfig b/arch/m68knommu/defconfig
--- a/arch/m68knommu/defconfig	2004-12-24 13:37:02 -08:00
+++ b/arch/m68knommu/defconfig	2004-12-24 13:37:02 -08:00
@@ -35,8 +35,9 @@
 # CONFIG_M5206 is not set
 # CONFIG_M5206e is not set
 # CONFIG_M5249 is not set
+# CONFIG_M527x is not set
 CONFIG_M5272=y
-# CONFIG_M5282 is not set
+# CONFIG_M528x is not set
 # CONFIG_M5307 is not set
 # CONFIG_M5407 is not set
 CONFIG_COLDFIRE=y
@@ -55,7 +56,10 @@
 # CONFIG_CLOCK_60MHz is not set
 CONFIG_CLOCK_66MHz=y
 # CONFIG_CLOCK_70MHz is not set
+# CONFIG_CLOCK_100MHz is not set
 # CONFIG_CLOCK_140MHz is not set
+# CONFIG_CLOCK_150MHz is not set
+# CONFIG_CLOCK_166MHz is not set
 
 #
 # Platform
diff -Nru a/arch/m68knommu/kernel/module.c b/arch/m68knommu/kernel/module.c
--- a/arch/m68knommu/kernel/module.c	2004-12-24 13:36:31 -08:00
+++ b/arch/m68knommu/kernel/module.c	2004-12-24 13:36:31 -08:00
@@ -82,9 +82,38 @@
 		       unsigned int relsec,
 		       struct module *me)
 {
-	printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n",
-	       me->name);
-	return -ENOEXEC;
+	unsigned int i;
+	Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr;
+	Elf32_Sym *sym;
+	uint32_t *location;
+
+	DEBUGP("Applying relocate_add section %u to %u\n", relsec,
+	       sechdrs[relsec].sh_info);
+	for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
+		/* This is where to make the change */
+		location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+			+ rel[i].r_offset;
+		/* This is the symbol it is referring to.  Note that all
+		   undefined symbols have been resolved.  */
+		sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
+			+ ELF32_R_SYM(rel[i].r_info);
+
+		switch (ELF32_R_TYPE(rel[i].r_info)) {
+		case R_68K_32:
+			/* We add the value into the location given */
+			*location = rel[i].r_addend + sym->st_value;
+			break;
+		case R_68K_PC32:
+			/* Add the value, subtract its postition */
+			*location = rel[i].r_addend + sym->st_value - (uint32_t)location;
+			break;
+		default:
+			printk(KERN_ERR "module %s: Unknown relocation: %u\n",
+			       me->name, ELF32_R_TYPE(rel[i].r_info));
+			return -ENOEXEC;
+		}
+	}
+	return 0;
 }
 
 int module_finalize(const Elf_Ehdr *hdr,
diff -Nru a/arch/m68knommu/kernel/ptrace.c b/arch/m68knommu/kernel/ptrace.c
--- a/arch/m68knommu/kernel/ptrace.c	2004-12-24 13:36:56 -08:00
+++ b/arch/m68knommu/kernel/ptrace.c	2004-12-24 13:36:56 -08:00
@@ -264,7 +264,7 @@
 			long tmp;
 
 			ret = 0;
-			if (child->state == TASK_ZOMBIE) /* already dead */
+			if (child->exit_state == EXIT_ZOMBIE) /* already dead */
 				break;
 			child->exit_code = SIGKILL;
 			/* make sure the single step bit is not set. */
diff -Nru a/arch/m68knommu/kernel/setup.c b/arch/m68knommu/kernel/setup.c
--- a/arch/m68knommu/kernel/setup.c	2004-12-24 13:37:01 -08:00
+++ b/arch/m68knommu/kernel/setup.c	2004-12-24 13:37:01 -08:00
@@ -1,7 +1,7 @@
 /*
  *  linux/arch/m68knommu/kernel/setup.c
  *
- *  Copyright (C) 1999-2002  Greg Ungerer (gerg@snapgear.com)
+ *  Copyright (C) 1999-2004  Greg Ungerer (gerg@snapgear.com)
  *  Copyright (C) 1998,1999  D. Jeff Dionne <jeff@lineo.ca>
  *  Copyleft  ()) 2000       James D. Schettine {james@telos-systems.com}
  *  Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
@@ -106,11 +106,14 @@
 #if defined(CONFIG_M5249)
 	#define CPU "COLDFIRE(m5249)"
 #endif
+#if defined(CONFIG_M527x)
+	#define CPU "COLDFIRE(m5270/5271/5274/5275)"
+#endif
 #if defined(CONFIG_M5272)
 	#define CPU "COLDFIRE(m5272)"
 #endif
-#if defined(CONFIG_M5282)
-	#define CPU "COLDFIRE(m5282)"
+#if defined(CONFIG_M528x)
+	#define CPU "COLDFIRE(m5280/5282)"
 #endif
 #if defined(CONFIG_M5307)
 	#define	CPU "COLDFIRE(m5307)"
diff -Nru a/arch/m68knommu/kernel/signal.c b/arch/m68knommu/kernel/signal.c
--- a/arch/m68knommu/kernel/signal.c	2004-12-24 13:37:00 -08:00
+++ b/arch/m68knommu/kernel/signal.c	2004-12-24 13:37:00 -08:00
@@ -745,147 +745,44 @@
  * Note that 'init' is a special process: it doesn't get signals it doesn't
  * want to handle. Thus you cannot kill init even with a SIGKILL even by
  * mistake.
- *
- * Note that we go through the signals twice: once to check the signals
- * that the kernel can handle, and then we build all the user-level signal
- * handling stack-frames in one go after that.
  */
 asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs)
 {
+	struct k_sigaction ka;
 	siginfo_t info;
-	struct k_sigaction *ka;
+	int signr;
 
-	current->thread.esp0 = (unsigned long) regs;
+	/*
+	 * We want the common case to go fast, which
+	 * is why we may in certain cases get here from
+	 * kernel mode. Just return without doing anything
+	 * if so.
+	 */
+	if (!user_mode(regs))
+		return 1;
 
 	if (!oldset)
 		oldset = &current->blocked;
 
-	for (;;) {
-		int signr;
-
-		signr = get_signal_to_deliver(&info, regs, NULL);
-
-		if (!signr)
-			break;
-
-		if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
-			current->exit_code = signr;
-			current->state = TASK_STOPPED;
-			regs->sr &= ~PS_T;
-
-			/* Did we come from a system call? */
-			if (regs->orig_d0 >= 0) {
-				/* Restart the system call the same way as
-				   if the process were not traced.  */
-				struct k_sigaction *ka =
-					&current->sighand->action[signr-1];
-				int has_handler =
-					(ka->sa.sa_handler != SIG_IGN &&
-					 ka->sa.sa_handler != SIG_DFL);
-				handle_restart(regs, ka, has_handler);
-			}
-			notify_parent(current, SIGCHLD);
-			schedule();
-
-			/* We're back.  Did the debugger cancel the sig?  */
-			if (!(signr = current->exit_code)) {
-			discard_frame:
-			    continue;
-			}
-			current->exit_code = 0;
-
-			/* The debugger continued.  Ignore SIGSTOP.  */
-			if (signr == SIGSTOP)
-				goto discard_frame;
-
-			/* Update the siginfo structure.  Is this good?  */
-			if (signr != info.si_signo) {
-				info.si_signo = signr;
-				info.si_errno = 0;
-				info.si_code = SI_USER;
-				info.si_pid = current->parent->pid;
-				info.si_uid = current->parent->uid;
-			}
-
-			/* If the (new) signal is now blocked, requeue it.  */
-			if (sigismember(&current->blocked, signr)) {
-				send_sig_info(signr, &info, current);
-				continue;
-			}
-		}
-
-		ka = &current->sighand->action[signr-1];
-		if (ka->sa.sa_handler == SIG_IGN) {
-			if (signr != SIGCHLD)
-				continue;
-			/* Check for SIGCHLD: it's special.  */
-			while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0)
-				/* nothing */;
-			continue;
-		}
-
-		if (ka->sa.sa_handler == SIG_DFL) {
-			int exit_code = signr;
-
-			if (current->pid == 1)
-				continue;
-
-			switch (signr) {
-			case SIGCONT: case SIGCHLD:
-			case SIGWINCH: case SIGURG:
-				continue;
-
-			case SIGTSTP: case SIGTTIN: case SIGTTOU:
-				if (is_orphaned_pgrp(process_group(current)))
-					continue;
-				/* FALLTHRU */
-
-			case SIGSTOP:
-				current->state = TASK_STOPPED;
-				current->exit_code = signr;
-				if (!(current->parent->sighand->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
-					notify_parent(current, SIGCHLD);
-				schedule();
-				continue;
-
-			case SIGQUIT: case SIGILL: case SIGTRAP:
-			case SIGIOT: case SIGFPE: case SIGSEGV:
-			case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ:
-				if (do_coredump(signr, exit_code, regs))
-					exit_code |= 0x80;
-				/* FALLTHRU */
-
-			default:
-				sigaddset(&current->pending.signal, signr);
-				recalc_sigpending();
-				current->flags |= PF_SIGNALED;
-				do_exit(exit_code);
-				/* NOTREACHED */
-			}
-		}
-
+	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
+	if (signr > 0) {
 		/* Whee!  Actually deliver the signal.  */
-		handle_signal(signr, ka, &info, oldset, regs);
+		handle_signal(signr, &ka, &info, oldset, regs);
 		return 1;
 	}
 
 	/* Did we come from a system call? */
-	if (regs->orig_d0 >= 0)
+	if (regs->orig_d0 >= 0) {
 		/* Restart the system call - no handlers present */
-		handle_restart(regs, NULL, 0);
-
-	/* If we are about to discard some frame stuff we must copy
-	   over the remaining frame. */
-	if (regs->stkadj) {
-		struct pt_regs *tregs =
-		  (struct pt_regs *) ((ulong) regs + regs->stkadj);
-
-		/* This must be copied with decreasing addresses to
-		   handle overlaps.  */
-		tregs->vector = 0;
-		tregs->format = 0;
-		tregs->pc = regs->pc;
-		tregs->sr = regs->sr;
+		if (regs->d0 == -ERESTARTNOHAND
+		    || regs->d0 == -ERESTARTSYS
+		    || regs->d0 == -ERESTARTNOINTR) {
+			regs->d0 = regs->orig_d0;
+			regs->pc -= 2;
+		} else if (regs->d0 == -ERESTART_RESTARTBLOCK) {
+			regs->d0 = __NR_restart_syscall;
+			regs->pc -= 2;
+		}
 	}
 	return 0;
 }
diff -Nru a/arch/m68knommu/kernel/syscalltable.S b/arch/m68knommu/kernel/syscalltable.S
--- a/arch/m68knommu/kernel/syscalltable.S	2004-12-24 13:36:16 -08:00
+++ b/arch/m68knommu/kernel/syscalltable.S	2004-12-24 13:36:16 -08:00
@@ -185,7 +185,7 @@
 	.long sys_ni_syscall	/* sys_mremap */
 	.long sys_setresuid16
 	.long sys_getresuid16	/* 165 */
-	.long sys_ni_syscall	/* for vm86 */
+	.long sys_getpagesize	/* sys_getpagesize */
 	.long sys_ni_syscall	/* old "query_module" */
 	.long sys_poll
 	.long sys_ni_syscall	/* sys_nfsservctl */
@@ -237,42 +237,70 @@
 	.long sys_setfsuid	/* 215 */
 	.long sys_setfsgid
 	.long sys_pivot_root
-	.long sys_ni_syscall	/* sys_mincore */
-	.long sys_ni_syscall	/* sys_madvise */
-	.long sys_getdents64	/* 220 */
-	.long sys_fcntl64
-	.long sys_ni_syscall	/* reserved for TUX */
 	.long sys_ni_syscall
+	.long sys_ni_syscall
+	.long sys_getdents64	/* 220 */
 	.long sys_gettid
-	.long sys_ni_syscall	/* 225 */ /* sys_readahead */
+	.long sys_tkill
 	.long sys_setxattr
 	.long sys_lsetxattr
-	.long sys_fsetxattr
+	.long sys_fsetxattr	/* 225 */
 	.long sys_getxattr
-	.long sys_lgetxattr	/* 230 */
+	.long sys_lgetxattr
 	.long sys_fgetxattr
 	.long sys_listxattr
-	.long sys_llistxattr
+	.long sys_llistxattr	/* 230 */
 	.long sys_flistxattr
-	.long sys_removexattr	/* 235 */
+	.long sys_removexattr
 	.long sys_lremovexattr
 	.long sys_fremovexattr
-	.long sys_tkill
+	.long sys_futex		/* 235 */
 	.long sys_sendfile64
-	.long sys_futex		/* 240 */
-	.long sys_sched_setaffinity
-	.long sys_sched_getaffinity
-	.long sys_ni_syscall	/* sys_set_thread_area */
-	.long sys_ni_syscall	/* sys_get_thread_area */
-	.long sys_io_setup	/* 245 */
+	.long sys_ni_syscall	/* sys_mincore */
+	.long sys_ni_syscall	/* sys_madvise */
+	.long sys_fcntl64
+	.long sys_readahead	/* 240 */
+	.long sys_io_setup
 	.long sys_io_destroy
 	.long sys_io_getevents
 	.long sys_io_submit
-	.long sys_io_cancel
-	.long sys_ni_syscall	/* 250 */ /* sys_alloc_hugepages */
-	.long sys_ni_syscall	/* sys_freec_hugepages */
+	.long sys_io_cancel	/* 245 */
+	.long sys_fadvise64
 	.long sys_exit_group
 	.long sys_lookup_dcookie
+	.long sys_epoll_create
+	.long sys_epoll_ctl	/* 250 */
+	.long sys_epoll_wait
+	.long sys_ni_syscall	/* sys_remap_file_pages */
+	.long sys_set_tid_address
+	.long sys_timer_create
+	.long sys_timer_settime	/* 255 */
+	.long sys_timer_gettime
+	.long sys_timer_getoverrun
+	.long sys_timer_delete
+	.long sys_clock_settime
+	.long sys_clock_gettime	/* 260 */
+	.long sys_clock_getres
+	.long sys_clock_nanosleep
+	.long sys_statfs64
+	.long sys_fstatfs64
+	.long sys_tgkill	/* 265 */
+	.long sys_utimes
+	.long sys_fadvise64_64
+	.long sys_mbind	
+	.long sys_get_mempolicy
+	.long sys_set_mempolicy	/* 270 */
+	.long sys_mq_open
+	.long sys_mq_unlink
+	.long sys_mq_timedsend
+	.long sys_mq_timedreceive
+	.long sys_mq_notify	/* 275 */
+	.long sys_mq_getsetattr
+	.long sys_waitid
+	.long sys_ni_syscall	/* sys_setaltroot */
+	.long sys_ni_syscall	/* sys_add_key */
+	.long sys_ni_syscall	/* 280 */ /* sys_request_key */
+	.long sys_ni_syscall	/* sys_keyctl */
 
 	.rept NR_syscalls-(.-sys_call_table)/4
 		.long sys_ni_syscall
diff -Nru a/arch/m68knommu/kernel/time.c b/arch/m68knommu/kernel/time.c
--- a/arch/m68knommu/kernel/time.c	2004-12-24 13:37:01 -08:00
+++ b/arch/m68knommu/kernel/time.c	2004-12-24 13:37:01 -08:00
@@ -57,6 +57,9 @@
 	write_seqlock(&xtime_lock);
 
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	if (current->pid)
 		profile_tick(CPU_PROFILING, regs);
 
diff -Nru a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
--- a/arch/m68knommu/kernel/vmlinux.lds.S	2004-12-24 13:36:48 -08:00
+++ b/arch/m68knommu/kernel/vmlinux.lds.S	2004-12-24 13:36:48 -08:00
@@ -1,7 +1,7 @@
 /*
  *	vmlinux.lds.S -- master linker script for m68knommu arch
  *
- *	(C) Copyright 2002-2003, Greg Ungerer <gerg@snapgear.com>
+ *	(C) Copyright 2002-2004, Greg Ungerer <gerg@snapgear.com>
  *
  *	This ends up looking compilcated, because of the number of
  *	address variations for ram and rom/flash layouts. The real
@@ -117,7 +117,8 @@
  */
 #if defined(CONFIG_M5206eC3) || defined(CONFIG_M5249C3) || \
     defined(CONFIG_M5272C3) || defined(CONFIG_M5307C3) || \
-    defined(CONFIG_ARN5307) || defined(CONFIG_M5407C3)
+    defined(CONFIG_ARN5307) || defined(CONFIG_M5407C3) || \
+    defined(CONFIG_M5271EVB) || defined(CONFIG_M5275EVB)
 #define	RAM_START	0x20000
 #define	RAM_LENGTH	0x3e0000
 #endif
@@ -132,14 +133,14 @@
 #define RAM_LENGTH  0xfe0000
 #endif
 
-#if defined(CONFIG_M5282C3)
+#if defined(CONFIG_M5282EVB)
 #define	RAM_START	0x10000
 #define	RAM_LENGTH	0x3f0000
 #endif
 
 /*
  *   The senTec COBRA5282 board has the same
- *   memory layout as the M5282C3.
+ *   memory layout as the M5282EVB.
  */
 #if defined(CONFIG_COBRA5282)
 #define  RAM_START   0x10000
@@ -153,11 +154,22 @@
  */
 #if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
     defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \
-    defined(CONFIG_CLEOPATRA)
+    defined(CONFIG_HW_FEITH)
 #define	RAM_START	0x400
 #define	RAM_LENGTH	0x3ffc00
 #endif
 
+/*
+ *	Sneha Boards mimimun memmory
+ *	The end of RAM will vary depending on how much ram is fitted,
+ *	but this isn't important here, we assume at least 4MiB.
+ */
+#if defined(CONFIG_CPU16B)   
+#define	RAM_START	0x20000
+#define	RAM_LENGTH	0x3e0000
+#endif
+
+
 #if defined(CONFIG_RAMKERNEL)
 #define	TEXT		ram
 #define	DATA		ram
@@ -247,6 +259,11 @@
 		/* Kernel symbol table: strings */
 		*(__ksymtab_strings)
 
+		/* Built-in module parameters */
+		__start___param = .;
+		*(__param)
+		__stop___param = .;
+
 		. = ALIGN(4) ;
 		_etext = . ;
 	} > TEXT
@@ -303,7 +320,7 @@
 		__initramfs_start = .;
 		*(.init.ramfs)
 		__initramfs_end = .;
-		. = ALIGN(4);
+		. = ALIGN(4096);
 		__init_end = .;
 	} > INIT
 
diff -Nru a/arch/m68knommu/lib/Makefile b/arch/m68knommu/lib/Makefile
--- a/arch/m68knommu/lib/Makefile	2004-12-24 13:36:31 -08:00
+++ b/arch/m68knommu/lib/Makefile	2004-12-24 13:36:31 -08:00
@@ -4,4 +4,4 @@
 
 lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o \
 	   muldi3.o mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
-	   checksum.o semaphore.o memcpy.o memset.o
+	   checksum.o semaphore.o memcpy.o memset.o delay.o
diff -Nru a/arch/m68knommu/lib/delay.c b/arch/m68knommu/lib/delay.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/lib/delay.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,18 @@
+/*
+ *	arch/m68knommu/lib/delay.c
+ *
+ *	(C) Copyright 2004, Greg Ungerer <gerg@snapgear.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.
+ */
+
+#include <asm/param.h>
+#include <asm/delay.h>
+
+void udelay(unsigned long usecs)
+{
+	_udelay(usecs);
+}
+
diff -Nru a/arch/m68knommu/mm/init.c b/arch/m68knommu/mm/init.c
--- a/arch/m68knommu/mm/init.c	2004-12-24 13:37:01 -08:00
+++ b/arch/m68knommu/mm/init.c	2004-12-24 13:37:01 -08:00
@@ -38,7 +38,6 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 #include <asm/machdep.h>
-#include <asm/shglcore.h>
 
 #undef DEBUG
 
diff -Nru a/arch/m68knommu/mm/memory.c b/arch/m68knommu/mm/memory.c
--- a/arch/m68knommu/mm/memory.c	2004-12-24 13:37:19 -08:00
+++ b/arch/m68knommu/mm/memory.c	2004-12-24 13:37:19 -08:00
@@ -24,7 +24,6 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 #include <asm/traps.h>
-#include <asm/shglcore.h>
 #include <asm/io.h>
 
 /*
diff -Nru a/arch/m68knommu/platform/5206e/MOTOROLA/crt0_ram.S b/arch/m68knommu/platform/5206e/MOTOROLA/crt0_ram.S
--- a/arch/m68knommu/platform/5206e/MOTOROLA/crt0_ram.S	2004-12-24 13:36:31 -08:00
+++ b/arch/m68knommu/platform/5206e/MOTOROLA/crt0_ram.S	2004-12-24 13:36:31 -08:00
@@ -21,7 +21,6 @@
  */
 
 #define	MEM_BASE	0x00000000	/* Memory base at address 0 */
-#define	MEM_SIZE	0x00400000	/* Memory size 4Mb */
 #define	VBR_BASE	MEM_BASE	/* Vector address */
 
 /*****************************************************************************/
@@ -78,9 +77,36 @@
 
 
 	/*
-	 *	Set to 4 meg for the Cadre III board (m5206e).
+	 *	SDRAM size for the Cadre III board (m5206e).
 	 */
+#if defined(CONFIG_RAMAUTO)
+	movea.l	#0x00000000,%a0
+	move.l	MCF_MBAR+MCFSIM_DCMR0,%d0
+	and.l	#0x00fe0000, %d0
+	beq	noaddr1
+	add.l	#0x00020000,%d0
+	move.l	%d0,%a0
+noaddr1:
+	move.l	MCF_MBAR+MCFSIM_DCMR1,%d0
+	and.l	#0x00fe0000, %d0
+	beq	noaddr2
+	add.l	#0x00020000,%d0
+	add.l	%d0,%a0
+noaddr2:
+
+#else
+
+#if defined(CONFIG_RAM32MB)
+#define MEM_SIZE	0x02000000	/* Memory size 32Mb */
+#elif defined(CONFIG_RAM16MB)
+#define MEM_SIZE	0x01000000	/* Memory size 16Mb */
+#elif defined(CONFIG_RAM8MB)
+#define MEM_SIZE	0x00800000	/* Memory size 8Mb */
+#else
+#define MEM_SIZE	0x00400000	/* Memory size 4Mb */
+#endif
 	move.l	#MEM_SIZE, %a0
+#endif
 
 	move.l	%a0, %d0			/* Mem end addr is in a0 */
 	move.l	%d0, %sp			/* Set up initial stack ptr */
diff -Nru a/arch/m68knommu/platform/5206e/config.c b/arch/m68knommu/platform/5206e/config.c
--- a/arch/m68knommu/platform/5206e/config.c	2004-12-24 13:36:47 -08:00
+++ b/arch/m68knommu/platform/5206e/config.c	2004-12-24 13:36:47 -08:00
@@ -22,7 +22,6 @@
 #include <asm/mcfsim.h>
 #include <asm/mcfdma.h>
 #include <asm/irq.h>
-#include <asm/delay.h>
 
 /***************************************************************************/
 
diff -Nru a/arch/m68knommu/platform/5249/config.c b/arch/m68knommu/platform/5249/config.c
--- a/arch/m68knommu/platform/5249/config.c	2004-12-24 13:36:59 -08:00
+++ b/arch/m68knommu/platform/5249/config.c	2004-12-24 13:36:59 -08:00
@@ -21,7 +21,6 @@
 #include <asm/mcftimer.h>
 #include <asm/mcfsim.h>
 #include <asm/mcfdma.h>
-#include <asm/delay.h>
 
 /***************************************************************************/
 
diff -Nru a/arch/m68knommu/platform/5272/CANCam/crt0_ram.S b/arch/m68knommu/platform/5272/CANCam/crt0_ram.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/5272/CANCam/crt0_ram.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,154 @@
+/*****************************************************************************/
+
+/*
+ *	crt0_ram.S -- startup code for Feith CANCan board.
+ *
+ *	(C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com).
+ *	(C) Copyright 2000, Lineo (www.lineo.com).
+ */
+
+/*****************************************************************************/
+
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/linkage.h>
+#include <asm/segment.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+
+/*****************************************************************************/
+
+/*
+ *	Feith ColdFire CANCam, chip select and memory setup.
+ */
+
+#define	MEM_BASE	0x00000000	/* Memory base at address 0 */
+#define	VBR_BASE	MEM_BASE	/* Vector address */
+#define MEM_SIZE  0x04000000      /* Memory size 64Mb */
+
+
+/*****************************************************************************/
+
+.global	_start
+.global _rambase
+.global _ramvec
+.global	_ramstart
+.global	_ramend
+
+/*****************************************************************************/
+
+.data
+
+/*
+ *	Set up the usable of RAM stuff. Size of RAM is determined then
+ *	an initial stack set up at the end.
+ */
+_rambase:
+.long	0
+_ramvec:
+.long	0
+_ramstart:
+.long	0
+_ramend:
+.long	0
+
+/*****************************************************************************/
+
+.text
+
+/*
+ *	This is the codes first entry point. This is where it all
+ *	begins...
+ */
+
+_start:
+	nop					/* Filler */
+	move.w	#0x2700, %sr			/* No interrupts */
+
+	/*
+	 * Setup VBR here, otherwise buserror remap will not work.
+	 * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
+	 *
+	 * bkr@cut.de 19990306
+	 *
+	 * Note: this is because dBUG points VBR to ROM, making vectors read
+	 * only, so the bus trap can't be changed. (RS)
+	 */
+	move.l	#VBR_BASE, %a7			/* Note VBR can't be read */
+	movec   %a7, %VBR
+	move.l	%a7, _ramvec			/* Set up vector addr */
+	move.l	%a7, _rambase			/* Set up base RAM addr */
+
+
+	/*
+	 *	Set memory size.
+	 */
+	move.l	#MEM_SIZE, %a0
+
+	move.l	%a0, %d0			/* Mem end addr is in a0 */
+	move.l	%d0, %sp			/* Set up initial stack ptr */
+	move.l	%d0, _ramend			/* Set end ram addr */
+
+	/*
+	 *	Enable CPU internal cache.
+	 */
+	move.l	#0x01000000, %d0		/* Invalidate cache cmd */
+	movec	%d0, %CACR			/* Invalidate cache */
+	move.l	#0x80000100, %d0		/* Setup cache mask */
+	movec	%d0, %CACR			/* Enable cache */
+	nop
+
+#ifdef CONFIG_ROMFS_FS
+	/*
+	 *	Move ROM filesystem above bss :-)
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Set up destination  */
+	move.l	%a0, %a2			/* Copy of bss start */
+
+	move.l	8(%a0), %d0			/* Get size of ROMFS */
+	addq.l	#8, %d0				/* Allow for rounding */
+	and.l	#0xfffffffc, %d0		/* Whole words */
+
+	add.l	%d0, %a0			/* Copy from end */
+	add.l	%d0, %a1			/* Copy from end */
+	move.l	%a1, _ramstart			/* Set start of ram */
+
+_copy_romfs:
+	move.l	-(%a0), %d0			/* Copy dword */
+	move.l	%d0, -(%a1)
+	cmp.l	%a0, %a2			/* Check if at end */
+	bne	_copy_romfs
+
+#else /* CONFIG_ROMFS_FS */
+	lea.l	_ebss, %a1
+	move.l	%a1, _ramstart
+#endif /* CONFIG_ROMFS_FS */
+
+
+	/*
+	 *	Zero out the bss region.
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Get end of bss */
+	clr.l	%d0				/* Set value */
+_clear_bss:
+	move.l	%d0, (%a0)+			/* Clear each word */
+	cmp.l	%a0, %a1			/* Check if at end */
+	bne	_clear_bss
+
+	/*
+	 *	Load the current thread pointer and stack.
+	 */
+	lea	init_thread_union, %a0
+	lea	0x2000(%a0), %sp
+
+	/*
+	 *	Assember start up done, start code proper.
+	 */
+	jsr	start_kernel			/* Start Linux kernel */
+
+_exit:
+	jmp	_exit				/* Should never get here */
+
+/*****************************************************************************/
diff -Nru a/arch/m68knommu/platform/5272/SCALES/crt0_ram.S b/arch/m68knommu/platform/5272/SCALES/crt0_ram.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/5272/SCALES/crt0_ram.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,154 @@
+/*****************************************************************************/
+
+/*
+ *	crt0_ram.S -- startup code for Feith SCALES board.
+ *
+ *	(C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com).
+ *	(C) Copyright 2000, Lineo (www.lineo.com).
+ */
+
+/*****************************************************************************/
+
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/linkage.h>
+#include <asm/segment.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+
+/*****************************************************************************/
+
+/*
+ *	Feith ColdFire SCALES, chip select and memory setup.
+ */
+
+#define	MEM_BASE	0x00000000	/* Memory base at address 0 */
+#define	VBR_BASE	MEM_BASE	/* Vector address */
+#define MEM_SIZE  0x02000000      /* Memory size 32Mb */
+
+
+/*****************************************************************************/
+
+.global	_start
+.global _rambase
+.global _ramvec
+.global	_ramstart
+.global	_ramend
+
+/*****************************************************************************/
+
+.data
+
+/*
+ *	Set up the usable of RAM stuff. Size of RAM is determined then
+ *	an initial stack set up at the end.
+ */
+_rambase:
+.long	0
+_ramvec:
+.long	0
+_ramstart:
+.long	0
+_ramend:
+.long	0
+
+/*****************************************************************************/
+
+.text
+
+/*
+ *	This is the codes first entry point. This is where it all
+ *	begins...
+ */
+
+_start:
+	nop					/* Filler */
+	move.w	#0x2700, %sr			/* No interrupts */
+
+	/*
+	 * Setup VBR here, otherwise buserror remap will not work.
+	 * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
+	 *
+	 * bkr@cut.de 19990306
+	 *
+	 * Note: this is because dBUG points VBR to ROM, making vectors read
+	 * only, so the bus trap can't be changed. (RS)
+	 */
+	move.l	#VBR_BASE, %a7			/* Note VBR can't be read */
+	movec   %a7, %VBR
+	move.l	%a7, _ramvec			/* Set up vector addr */
+	move.l	%a7, _rambase			/* Set up base RAM addr */
+
+
+	/*
+	 *	Set memory size.
+	 */
+	move.l	#MEM_SIZE, %a0
+
+	move.l	%a0, %d0			/* Mem end addr is in a0 */
+	move.l	%d0, %sp			/* Set up initial stack ptr */
+	move.l	%d0, _ramend			/* Set end ram addr */
+
+	/*
+	 *	Enable CPU internal cache.
+	 */
+	move.l	#0x01000000, %d0		/* Invalidate cache cmd */
+	movec	%d0, %CACR			/* Invalidate cache */
+	move.l	#0x80000100, %d0		/* Setup cache mask */
+	movec	%d0, %CACR			/* Enable cache */
+	nop
+
+#ifdef CONFIG_ROMFS_FS
+	/*
+	 *	Move ROM filesystem above bss :-)
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Set up destination  */
+	move.l	%a0, %a2			/* Copy of bss start */
+
+	move.l	8(%a0), %d0			/* Get size of ROMFS */
+	addq.l	#8, %d0				/* Allow for rounding */
+	and.l	#0xfffffffc, %d0		/* Whole words */
+
+	add.l	%d0, %a0			/* Copy from end */
+	add.l	%d0, %a1			/* Copy from end */
+	move.l	%a1, _ramstart			/* Set start of ram */
+
+_copy_romfs:
+	move.l	-(%a0), %d0			/* Copy dword */
+	move.l	%d0, -(%a1)
+	cmp.l	%a0, %a2			/* Check if at end */
+	bne	_copy_romfs
+
+#else /* CONFIG_ROMFS_FS */
+	lea.l	_ebss, %a1
+	move.l	%a1, _ramstart
+#endif /* CONFIG_ROMFS_FS */
+
+
+	/*
+	 *	Zero out the bss region.
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Get end of bss */
+	clr.l	%d0				/* Set value */
+_clear_bss:
+	move.l	%d0, (%a0)+			/* Clear each word */
+	cmp.l	%a0, %a1			/* Check if at end */
+	bne	_clear_bss
+
+	/*
+	 *	Load the current thread pointer and stack.
+	 */
+	lea	init_thread_union, %a0
+	lea	0x2000(%a0), %sp
+
+	/*
+	 *	Assember start up done, start code proper.
+	 */
+	jsr	start_kernel			/* Start Linux kernel */
+
+_exit:
+	jmp	_exit				/* Should never get here */
+
+/*****************************************************************************/
diff -Nru a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c
--- a/arch/m68knommu/platform/5272/config.c	2004-12-24 13:36:33 -08:00
+++ b/arch/m68knommu/platform/5272/config.c	2004-12-24 13:36:33 -08:00
@@ -23,7 +23,6 @@
 #include <asm/mcftimer.h>
 #include <asm/mcfsim.h>
 #include <asm/mcfdma.h>
-#include <asm/delay.h>
 
 /***************************************************************************/
 
@@ -110,13 +109,17 @@
 #if defined(CONFIG_BOOTPARAM)
 	strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
 	commandp[size-1] = 0;
-#elif defined(CONFIG_NETtel)
+#elif defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
 	/* Copy command line from FLASH to local buffer... */
 	memcpy(commandp, (char *) 0xf0004000, size);
 	commandp[size-1] = 0;
 #elif defined(CONFIG_MTD_KeyTechnology)
 	/* Copy command line from FLASH to local buffer... */
 	memcpy(commandp, (char *) 0xffe06000, size);
+	commandp[size-1] = 0;
+#elif defined(CONFIG_CANCam)
+	/* Copy command line from FLASH to local buffer... */
+	memcpy(commandp, (char *) 0xf0010000, size);
 	commandp[size-1] = 0;
 #else
 	memset(commandp, 0, size);
diff -Nru a/arch/m68knommu/platform/527x/M5271EVB/crt0_ram.S b/arch/m68knommu/platform/527x/M5271EVB/crt0_ram.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/527x/M5271EVB/crt0_ram.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,166 @@
+/*****************************************************************************/
+
+/*
+ *	crt0_ram.S -- startup code for MCF527x ColdFire based Freescale boards.
+ *
+ *	(C) Copyright 2003-2004, Greg Ungerer (gerg@snapgear.com).
+ */
+
+/*****************************************************************************/
+
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/linkage.h>
+#include <asm/segment.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+
+/*****************************************************************************/
+
+/*
+ *	Freescale M5271EVB ColdFire eval board, chip select and memory setup.
+ */
+
+#define	MEM_BASE	0x00000000	/* Memory base at address 0 */
+#define	VBR_BASE	MEM_BASE	/* Vector address */
+
+#if defined(CONFIG_RAM4MB)
+#define	MEM_SIZE	0x00400000	/* Memory size 4Mb */
+#elif defined(CONFIG_RAM8MB)
+#define	MEM_SIZE	0x00800000	/* Memory size 8Mb */
+#else
+#define	MEM_SIZE	0x01000000	/* Memory size 16Mb */
+#endif
+
+/*****************************************************************************/
+
+.global	_start
+.global _rambase
+.global _ramvec
+.global	_ramstart
+.global	_ramend
+
+/*****************************************************************************/
+
+.data
+
+/*
+ *	Set up the usable of RAM stuff. Size of RAM is determined then
+ *	an initial stack set up at the end.
+ */
+_rambase:
+.long	0
+_ramvec:
+.long	0
+_ramstart:
+.long	0
+_ramend:
+.long	0
+
+/*****************************************************************************/
+
+.text
+
+/*
+ *	This is the codes first entry point. This is where it all
+ *	begins...
+ */
+
+_start:
+	nop					/* Filler */
+	move.w	#0x2700, %sr			/* No interrupts */
+
+	/*
+	 * Setup VBR here, otherwise buserror remap will not work.
+	 * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
+	 *
+	 * bkr@cut.de 19990306
+	 *
+	 * Note: this is because dBUG points VBR to ROM, making vectors read
+	 * only, so the bus trap can't be changed. (RS)
+	 */
+	move.l	#VBR_BASE, %a7			/* Note VBR can't be read */
+	movec   %a7, %VBR
+	move.l	%a7, _ramvec			/* Set up vector addr */
+	move.l	%a7, _rambase			/* Set up base RAM addr */
+
+
+	/*
+	 *	Set memory size.
+	 */
+	move.l	#MEM_SIZE, %a0
+
+	move.l	%a0, %d0			/* Mem end addr is in a0 */
+	move.l	%d0, %sp			/* Set up initial stack ptr */
+	move.l	%d0, _ramend			/* Set end ram addr */
+
+	/*
+	 *	Enable CPU internal cache.
+	 */
+	move.l	#0x01400000, %d0
+	movec	%d0, %CACR			/* Invalidate cache */
+	nop
+
+	move.l	#0x0000c000, %d0		/* Set SDRAM cached only */
+	movec	%d0, %ACR0
+	move.l	#0x00000000, %d0		/* No other regions cached */
+	movec	%d0, %ACR1
+
+	move.l	#0x80400100, %d0		/* Configure cache */
+	movec	%d0, %CACR			/* Enable cache */
+	nop
+
+
+#ifdef CONFIG_ROMFS_FS
+	/*
+	 *	Move ROM filesystem above bss :-)
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Set up destination  */
+	move.l	%a0, %a2			/* Copy of bss start */
+
+	move.l	8(%a0), %d0			/* Get size of ROMFS */
+	addq.l	#8, %d0				/* Allow for rounding */
+	and.l	#0xfffffffc, %d0		/* Whole words */
+
+	add.l	%d0, %a0			/* Copy from end */
+	add.l	%d0, %a1			/* Copy from end */
+	move.l	%a1, _ramstart			/* Set start of ram */
+
+_copy_romfs:
+	move.l	-(%a0), %d0			/* Copy dword */
+	move.l	%d0, -(%a1)
+	cmp.l	%a0, %a2			/* Check if at end */
+	bne	_copy_romfs
+#else /* CONFIG_ROMFS_FS */
+	lea.l	_ebss, %a1
+	move.l	%a1, _ramstart
+#endif /* CONFIG_ROMFS_FS */
+
+
+	/*
+	 *	Zero out the bss region.
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Get end of bss */
+	clr.l	%d0				/* Set value */
+_clear_bss:
+	move.l	%d0, (%a0)+			/* Clear each word */
+	cmp.l	%a0, %a1			/* Check if at end */
+	bne	_clear_bss
+
+	/*
+	 *	Load the current thread pointer and stack.
+	 */
+	lea	init_thread_union, %a0
+	lea	0x2000(%a0), %sp
+
+	/*
+	 *	Assember start up done, start code proper.
+	 */
+	jsr	start_kernel			/* Start Linux kernel */
+
+_exit:
+	jmp	_exit				/* Should never get here */
+
+/*****************************************************************************/
diff -Nru a/arch/m68knommu/platform/527x/M5275EVB/crt0_ram.S b/arch/m68knommu/platform/527x/M5275EVB/crt0_ram.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/527x/M5275EVB/crt0_ram.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,166 @@
+/*****************************************************************************/
+
+/*
+ *	crt0_ram.S -- startup code for MCF527x ColdFire based Freescale boards.
+ *
+ *	(C) Copyright 2003-2004, Greg Ungerer (gerg@snapgear.com).
+ */
+
+/*****************************************************************************/
+
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/linkage.h>
+#include <asm/segment.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+
+/*****************************************************************************/
+
+/*
+ *	Freescale M5275EVB ColdFire eval board, chip select and memory setup.
+ */
+
+#define	MEM_BASE	0x00000000	/* Memory base at address 0 */
+#define	VBR_BASE	MEM_BASE	/* Vector address */
+
+#if defined(CONFIG_RAM4MB)
+#define	MEM_SIZE	0x00400000	/* Memory size 4Mb */
+#elif defined(CONFIG_RAM8MB)
+#define	MEM_SIZE	0x00800000	/* Memory size 8Mb */
+#else
+#define	MEM_SIZE	0x01000000	/* Memory size 16Mb */
+#endif
+
+/*****************************************************************************/
+
+.global	_start
+.global _rambase
+.global _ramvec
+.global	_ramstart
+.global	_ramend
+
+/*****************************************************************************/
+
+.data
+
+/*
+ *	Set up the usable of RAM stuff. Size of RAM is determined then
+ *	an initial stack set up at the end.
+ */
+_rambase:
+.long	0
+_ramvec:
+.long	0
+_ramstart:
+.long	0
+_ramend:
+.long	0
+
+/*****************************************************************************/
+
+.text
+
+/*
+ *	This is the codes first entry point. This is where it all
+ *	begins...
+ */
+
+_start:
+	nop					/* Filler */
+	move.w	#0x2700, %sr			/* No interrupts */
+
+	/*
+	 * Setup VBR here, otherwise buserror remap will not work.
+	 * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
+	 *
+	 * bkr@cut.de 19990306
+	 *
+	 * Note: this is because dBUG points VBR to ROM, making vectors read
+	 * only, so the bus trap can't be changed. (RS)
+	 */
+	move.l	#VBR_BASE, %a7			/* Note VBR can't be read */
+	movec   %a7, %VBR
+	move.l	%a7, _ramvec			/* Set up vector addr */
+	move.l	%a7, _rambase			/* Set up base RAM addr */
+
+
+	/*
+	 *	Set memory size.
+	 */
+	move.l	#MEM_SIZE, %a0
+
+	move.l	%a0, %d0			/* Mem end addr is in a0 */
+	move.l	%d0, %sp			/* Set up initial stack ptr */
+	move.l	%d0, _ramend			/* Set end ram addr */
+
+	/*
+	 *	Enable CPU internal cache.
+	 */
+	move.l	#0x01400000, %d0
+	movec	%d0, %CACR			/* Invalidate cache */
+	nop
+
+	move.l	#0x0000c000, %d0		/* Set SDRAM cached only */
+	movec	%d0, %ACR0
+	move.l	#0x00000000, %d0		/* No other regions cached */
+	movec	%d0, %ACR1
+
+	move.l	#0x80400100, %d0		/* Configure cache */
+	movec	%d0, %CACR			/* Enable cache */
+	nop
+
+
+#ifdef CONFIG_ROMFS_FS
+	/*
+	 *	Move ROM filesystem above bss :-)
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Set up destination  */
+	move.l	%a0, %a2			/* Copy of bss start */
+
+	move.l	8(%a0), %d0			/* Get size of ROMFS */
+	addq.l	#8, %d0				/* Allow for rounding */
+	and.l	#0xfffffffc, %d0		/* Whole words */
+
+	add.l	%d0, %a0			/* Copy from end */
+	add.l	%d0, %a1			/* Copy from end */
+	move.l	%a1, _ramstart			/* Set start of ram */
+
+_copy_romfs:
+	move.l	-(%a0), %d0			/* Copy dword */
+	move.l	%d0, -(%a1)
+	cmp.l	%a0, %a2			/* Check if at end */
+	bne	_copy_romfs
+#else /* CONFIG_ROMFS_FS */
+	lea.l	_ebss, %a1
+	move.l	%a1, _ramstart
+#endif /* CONFIG_ROMFS_FS */
+
+
+	/*
+	 *	Zero out the bss region.
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Get end of bss */
+	clr.l	%d0				/* Set value */
+_clear_bss:
+	move.l	%d0, (%a0)+			/* Clear each word */
+	cmp.l	%a0, %a1			/* Check if at end */
+	bne	_clear_bss
+
+	/*
+	 *	Load the current thread pointer and stack.
+	 */
+	lea	init_thread_union, %a0
+	lea	0x2000(%a0), %sp
+
+	/*
+	 *	Assember start up done, start code proper.
+	 */
+	jsr	start_kernel			/* Start Linux kernel */
+
+_exit:
+	jmp	_exit				/* Should never get here */
+
+/*****************************************************************************/
diff -Nru a/arch/m68knommu/platform/527x/Makefile b/arch/m68knommu/platform/527x/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/527x/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,21 @@
+#
+# Makefile for the linux kernel.
+#
+
+#
+# If you want to play with the HW breakpoints then you will
+# need to add define this,  which will give you a stack backtrace
+# on the console port whenever a DBG interrupt occurs.  You have to
+# set up you HW breakpoints to trigger a DBG interrupt:
+#
+# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT
+# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
+#
+
+ifdef CONFIG_FULLDEBUG
+AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+endif
+
+obj-y := config.o
+
+extra-y := $(BOARD)/crt0_$(MODEL).o
diff -Nru a/arch/m68knommu/platform/527x/config.c b/arch/m68knommu/platform/527x/config.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/527x/config.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,82 @@
+/***************************************************************************/
+
+/*
+ *	linux/arch/m68knommu/platform/527x/config.c
+ *
+ *	Sub-architcture dependant initialization code for the Freescale
+ *	5270/5271 CPUs.
+ *
+ *	Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com)
+ *	Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
+ */
+
+/***************************************************************************/
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/param.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <asm/dma.h>
+#include <asm/traps.h>
+#include <asm/machdep.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+#include <asm/mcfdma.h>
+
+/***************************************************************************/
+
+void coldfire_pit_tick(void);
+void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+unsigned long coldfire_pit_offset(void);
+void coldfire_trap_init(void);
+void coldfire_reset(void);
+
+/***************************************************************************/
+
+/*
+ *	DMA channel base address table.
+ */
+unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
+        MCF_MBAR + MCFDMA_BASE0,
+};
+
+unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+
+/***************************************************************************/
+
+void mcf_disableall(void)
+{
+	*((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
+	*((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
+}
+
+/***************************************************************************/
+
+void mcf_autovector(unsigned int vec)
+{
+	/* Everything is auto-vectored on the 5272 */
+}
+
+/***************************************************************************/
+
+void config_BSP(char *commandp, int size)
+{
+	mcf_disableall();
+
+#ifdef CONFIG_BOOTPARAM
+	strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
+	commandp[size-1] = 0;
+#else
+	memset(commandp, 0, size);
+#endif
+
+	mach_sched_init = coldfire_pit_init;
+	mach_tick = coldfire_pit_tick;
+	mach_gettimeoffset = coldfire_pit_offset;
+	mach_trap_init = coldfire_trap_init;
+	mach_reset = coldfire_reset;
+}
+
+/***************************************************************************/
diff -Nru a/arch/m68knommu/platform/5282/MOTOROLA/crt0_ram.S b/arch/m68knommu/platform/5282/MOTOROLA/crt0_ram.S
--- a/arch/m68knommu/platform/5282/MOTOROLA/crt0_ram.S	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,171 +0,0 @@
-/*****************************************************************************/
-
-/*
- *	crt0_ram.S -- startup code for MCF5282 ColdFire based MOTOROLA boards.
- *
- *	(C) Copyright 2003, Greg Ungerer (gerg@snapgear.com).
- */
-
-/*****************************************************************************/
-
-#include <linux/config.h>
-#include <linux/threads.h>
-#include <linux/linkage.h>
-#include <asm/segment.h>
-#include <asm/coldfire.h>
-#include <asm/mcfsim.h>
-
-/*****************************************************************************/
-
-/*
- *	Motorola M5282C3 ColdFire eval board, chip select and memory setup.
- */
-
-#define	MEM_BASE	0x00000000	/* Memory base at address 0 */
-#define	VBR_BASE	MEM_BASE	/* Vector address */
-
-#if defined(CONFIG_RAM16MB)
-#define	MEM_SIZE	0x01000000	/* Memory size 16Mb */
-#elif defined(CONFIG_RAM8MB)
-#define	MEM_SIZE	0x00800000	/* Memory size 8Mb */
-#else
-#define	MEM_SIZE	0x00400000	/* Memory size 4Mb */
-#endif
-
-/*****************************************************************************/
-
-.global	_start
-.global _rambase
-.global _ramvec
-.global	_ramstart
-.global	_ramend
-
-/*****************************************************************************/
-
-.data
-
-/*
- *	Set up the usable of RAM stuff. Size of RAM is determined then
- *	an initial stack set up at the end.
- */
-_rambase:
-.long	0
-_ramvec:
-.long	0
-_ramstart:
-.long	0
-_ramend:
-.long	0
-
-/*****************************************************************************/
-
-.text
-
-/*
- *	This is the codes first entry point. This is where it all
- *	begins...
- */
-
-_start:
-	nop					/* Filler */
-	move.w	#0x2700, %sr			/* No interrupts */
-
-	/*
-	 * Setup VBR here, otherwise buserror remap will not work.
-	 * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
-	 *
-	 * bkr@cut.de 19990306
-	 *
-	 * Note: this is because dBUG points VBR to ROM, making vectors read
-	 * only, so the bus trap can't be changed. (RS)
-	 */
-	move.l	#VBR_BASE, %a7			/* Note VBR can't be read */
-	movec   %a7, %VBR
-	move.l	%a7, _ramvec			/* Set up vector addr */
-	move.l	%a7, _rambase			/* Set up base RAM addr */
-
-
-	/*
-	 *	Set memory size.
-	 */
-	move.l	#MEM_SIZE, %a0
-
-	move.l	%a0, %d0			/* Mem end addr is in a0 */
-	move.l	%d0, %sp			/* Set up initial stack ptr */
-	move.l	%d0, _ramend			/* Set end ram addr */
-
-	/*
-	 *	Enable CPU internal cache.
-	 *
-	 *	Cache is totally broken in first 5282 silicon.
-	 *	No point enabling it for now.
-	 */
-#if 0
-	move.l	#0x01000000, %d0
-	movec	%d0, %CACR			/* Invalidate cache */
-	nop
-
-	move.l	#0x0000c000, %d0		/* Set SDRAM cached only */
-	movec	%d0, %ACR0
-	move.l	#0x00000000, %d0		/* No other regions cached */
-	movec	%d0, %ACR1
-
-	move.l	#0x00000000, %d0		/* Setup cache mask */
-	movec	%d0, %CACR			/* Enable cache */
-	nop
-#endif
-
-
-#ifdef CONFIG_ROMFS_FS
-	/*
-	 *	Move ROM filesystem above bss :-)
-	 */
-	lea.l	_sbss, %a0			/* Get start of bss */
-	lea.l	_ebss, %a1			/* Set up destination  */
-	move.l	%a0, %a2			/* Copy of bss start */
-
-	move.l	8(%a0), %d0			/* Get size of ROMFS */
-	addq.l	#8, %d0				/* Allow for rounding */
-	and.l	#0xfffffffc, %d0		/* Whole words */
-
-	add.l	%d0, %a0			/* Copy from end */
-	add.l	%d0, %a1			/* Copy from end */
-	move.l	%a1, _ramstart			/* Set start of ram */
-
-_copy_romfs:
-	move.l	-(%a0), %d0			/* Copy dword */
-	move.l	%d0, -(%a1)
-	cmp.l	%a0, %a2			/* Check if at end */
-	bne	_copy_romfs
-#else /* CONFIG_ROMFS_FS */
-	lea.l	_ebss, %a1
-	move.l	%a1, _ramstart
-#endif /* CONFIG_ROMFS_FS */
-
-
-	/*
-	 *	Zero out the bss region.
-	 */
-	lea.l	_sbss, %a0			/* Get start of bss */
-	lea.l	_ebss, %a1			/* Get end of bss */
-	clr.l	%d0				/* Set value */
-_clear_bss:
-	move.l	%d0, (%a0)+			/* Clear each word */
-	cmp.l	%a0, %a1			/* Check if at end */
-	bne	_clear_bss
-
-	/*
-	 *	Load the current thread pointer and stack.
-	 */
-	lea	init_thread_union, %a0
-	lea	0x2000(%a0), %sp
-
-	/*
-	 *	Assember start up done, start code proper.
-	 */
-	jsr	start_kernel			/* Start Linux kernel */
-
-_exit:
-	jmp	_exit				/* Should never get here */
-
-/*****************************************************************************/
diff -Nru a/arch/m68knommu/platform/5282/Makefile b/arch/m68knommu/platform/5282/Makefile
--- a/arch/m68knommu/platform/5282/Makefile	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,21 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-#
-# If you want to play with the HW breakpoints then you will
-# need to add define this,  which will give you a stack backtrace
-# on the console port whenever a DBG interrupt occurs.  You have to
-# set up you HW breakpoints to trigger a DBG interrupt:
-#
-# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT
-# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
-#
-
-ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
-endif
-
-obj-y := config.o pit.o
-
-extra-y := $(BOARD)/crt0_$(MODEL).o
diff -Nru a/arch/m68knommu/platform/5282/config.c b/arch/m68knommu/platform/5282/config.c
--- a/arch/m68knommu/platform/5282/config.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,82 +0,0 @@
-/***************************************************************************/
-
-/*
- *	linux/arch/m68knommu/platform/5282/config.c
- *
- *	Sub-architcture dependant initialization code for the Motorola
- *	5282 CPU.
- *
- *	Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
- *	Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
- */
-
-/***************************************************************************/
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/param.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <asm/dma.h>
-#include <asm/traps.h>
-#include <asm/machdep.h>
-#include <asm/coldfire.h>
-#include <asm/mcfsim.h>
-#include <asm/mcfdma.h>
-
-/***************************************************************************/
-
-void coldfire_pit_tick(void);
-void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
-unsigned long coldfire_pit_offset(void);
-void coldfire_trap_init(void);
-void coldfire_reset(void);
-
-/***************************************************************************/
-
-/*
- *	DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-        MCF_MBAR + MCFDMA_BASE0,
-};
-
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
-
-/***************************************************************************/
-
-void mcf_disableall(void)
-{
-	*((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
-	*((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
-}
-
-/***************************************************************************/
-
-void mcf_autovector(unsigned int vec)
-{
-	/* Everything is auto-vectored on the 5272 */
-}
-
-/***************************************************************************/
-
-void config_BSP(char *commandp, int size)
-{
-	mcf_disableall();
-
-#ifdef CONFIG_BOOTPARAM
-	strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
-	commandp[size-1] = 0;
-#else
-	memset(commandp, 0, size);
-#endif
-
-	mach_sched_init = coldfire_pit_init;
-	mach_tick = coldfire_pit_tick;
-	mach_gettimeoffset = coldfire_pit_offset;
-	mach_trap_init = coldfire_trap_init;
-	mach_reset = coldfire_reset;
-}
-
-/***************************************************************************/
diff -Nru a/arch/m68knommu/platform/5282/pit.c b/arch/m68knommu/platform/5282/pit.c
--- a/arch/m68knommu/platform/5282/pit.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,87 +0,0 @@
-/***************************************************************************/
-
-/*
- *	pit.c -- Motorola ColdFire PIT timer. Currently this type of
- *	         hardware timer only exists in the Motorola ColdFire
- *		 5282 CPU.
- *
- *	Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
- *	Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
- *
- */
-
-/***************************************************************************/
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/param.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <asm/irq.h>
-#include <asm/coldfire.h>
-#include <asm/mcfpit.h>
-#include <asm/mcfsim.h>
-
-/***************************************************************************/
-
-void coldfire_pit_tick(void)
-{
-	volatile struct mcfpit *tp;
-
-	/* Reset the ColdFire timer */
-	tp = (volatile struct mcfpit *) (MCF_IPSBAR + MCFPIT_BASE1);
-	tp->pcsr |= MCFPIT_PCSR_PIF;
-}
-
-/***************************************************************************/
-
-void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *))
-{
-	volatile unsigned char *icrp;
-	volatile unsigned long *imrp;
-	volatile struct mcfpit *tp;
-
-	request_irq(64+55, handler, SA_INTERRUPT, "ColdFire Timer", NULL);
-
-	icrp = (volatile unsigned char *) (MCF_IPSBAR + MCFICM_INTC0 +
-		MCFINTC_ICR0 + MCFINT_PIT1);
-	*icrp = 0x2b; /* PIT1 with level 5, priority 3 */
-
-	imrp = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
-	*imrp &= ~(1 << (55 - 32));
-
-	/* Set up PIT timer 1 as poll clock */
-	tp = (volatile struct mcfpit *) (MCF_IPSBAR + MCFPIT_BASE1);
-	tp->pcsr = MCFPIT_PCSR_DISABLE;
-
-	tp->pmr = ((MCF_CLK / 2) / 64) / HZ;
-	tp->pcsr = MCFPIT_PCSR_EN | MCFPIT_PCSR_PIE | MCFPIT_PCSR_OVW |
-		MCFPIT_PCSR_RLD | MCFPIT_PCSR_CLK64;
-}
-
-/***************************************************************************/
-
-unsigned long coldfire_pit_offset(void)
-{
-	volatile struct mcfpit *tp;
-	volatile unsigned long *ipr;
-	unsigned long pmr, pcntr, offset;
-
-	tp = (volatile struct mcfpit *) (MCF_IPSBAR + MCFPIT_BASE1);
-	ipr = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IPRH);
-
-	pmr = tp->pmr;
-	pcntr = tp->pcntr;
-
-	/*
-	 * If we are still in the first half of the upcount and a
-	 * timer interupt is pending, then add on a ticks worth of time.
-	 */
-	offset = ((pcntr * (1000000 / HZ)) / pmr);
-	if ((offset < (1000000 / HZ / 2)) && (*ipr & (1 << (55 - 32))))
-		offset += 1000000 / HZ;
-	return offset;	
-}
-
-/***************************************************************************/
diff -Nru a/arch/m68knommu/platform/5282/senTec/crt0_ram.S b/arch/m68knommu/platform/5282/senTec/crt0_ram.S
--- a/arch/m68knommu/platform/5282/senTec/crt0_ram.S	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,180 +0,0 @@
-/*****************************************************************************/
-
-/*
- *	crt0_ram.S -- startup code for MCF5282 ColdFire based boards.
- *
- *	(C) Copyright 2003, Greg Ungerer (gerg@snapgear.com).
- */
-
-/*****************************************************************************/
-
-#include <linux/config.h>
-#include <linux/threads.h>
-#include <linux/linkage.h>
-#include <asm/segment.h>
-#include <asm/coldfire.h>
-#include <asm/mcfsim.h>
-
-/*****************************************************************************/
-
-/*
- *	senTec COBRA5282 board, chip select and memory setup.
- */
-
-#define	MEM_BASE	0x00000000	/* Memory base at address 0 */
-#define	VBR_BASE	MEM_BASE	/* Vector address */
-
-#if defined(CONFIG_RAM16MB)
-#define	MEM_SIZE	0x01000000	/* Memory size 16Mb */
-#elif defined(CONFIG_RAM8MB)
-#define	MEM_SIZE	0x00800000	/* Memory size 8Mb */
-#else
-#define	MEM_SIZE	0x00400000	/* Memory size 4Mb */
-#endif
-
-#define IPSBAR 0x40000000
-#define GPACR0 0x30
-/*****************************************************************************/
-
-.global	_start
-.global	_rambase
-.global	_ramvec
-.global	_ramstart
-.global	_ramend
-
-/*****************************************************************************/
-
-.data
-
-/*
- *	Set up the usable of RAM stuff. Size of RAM is determined then
- *	an initial stack set up at the end.
- */
-_rambase:
-.long	0
-_ramvec:
-.long	0
-_ramstart:
-.long	0
-_ramend:
-.long	0
-
-/*****************************************************************************/
-
-.text
-
-/*
- *	This is the codes first entry point. This is where it all
- *	begins...
- */
-
-_start:
-	nop								/* Filler */
-	move.w	#0x2700, %sr			/* No interrupts */
-
-	/*
-	 * Setup VBR here, otherwise buserror remap will not work.
-	 * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
-	 *
-	 * bkr@cut.de 19990306
-	 *
-	 * Note: this is because dBUG points VBR to ROM, making vectors read
-	 * only, so the bus trap can't be changed. (RS)
-	 */
-	move.l	#VBR_BASE, %a7			/* Note VBR can't be read */
-	movec   %a7, %VBR
-	move.l	%a7, _ramvec			/* Set up vector addr */
-	move.l	%a7, _rambase			/* Set up base RAM addr */
-
-
-	/*
-	 *	Set memory size.
-	 */
-	move.l	#MEM_SIZE, %a0
-
-	move.l	%a0, %d0			/* Mem end addr is in a0 */
-	move.l	%d0, %sp			/* Set up initial stack ptr */
-	move.l	%d0, _ramend		/* Set end ram addr */
-
-	/*
-	 *	Enable CPU internal cache.
-	 *
-	 *	Cache is totally broken in first 5282 silicon.
-	 *	No point enabling it for now.
-	 */
-#if 0
-	move.l	#0x01000000, %d0
-	movec	%d0, %CACR				/* Invalidate cache */
-	nop
-
-	move.l	#0x0000c000, %d0		/* Set SDRAM cached only */
-	movec	%d0, %ACR0
-	move.l	#0x00000000, %d0		/* No other regions cached */
-	movec	%d0, %ACR1
-
-	move.l	#0x00000000, %d0		/* Setup cache mask */
-	movec	%d0, %CACR				/* Enable cache */
-	nop
-#endif
-
-
-#ifdef CONFIG_ROMFS_FS
-	/*
-	 *	Move ROM filesystem above bss :-)
-	 */
-	lea.l	_sbss, %a0			/* Get start of bss */
-	lea.l	_ebss, %a1			/* Set up destination  */
-	move.l	%a0, %a2			/* Copy of bss start */
-
-	move.l	8(%a0), %d0			/* Get size of ROMFS */
-	addq.l	#8, %d0				/* Allow for rounding */
-	and.l	#0xfffffffc, %d0	/* Whole words */
-
-	add.l	%d0, %a0			/* Copy from end */
-	add.l	%d0, %a1			/* Copy from end */
-	move.l	%a1, _ramstart		/* Set start of ram */
-
-_copy_romfs:
-	move.l	-(%a0), %d0			/* Copy dword */
-	move.l	%d0, -(%a1)
-	cmp.l	%a0, %a2			/* Check if at end */
-	bne	_copy_romfs
-#else /* CONFIG_ROMFS_FS */
-	lea.l	_ebss, %a1
-	move.l	%a1, _ramstart
-#endif /* CONFIG_ROMFS_FS */
-
-
-	/*
-	 *	Zero out the bss region.
-	 */
-	lea.l	_sbss, %a0			/* Get start of bss */
-	lea.l	_ebss, %a1			/* Get end of bss */
-	clr.l	%d0					/* Set value */
-_clear_bss:
-	move.l	%d0, (%a0)+			/* Clear each word */
-	cmp.l	%a0, %a1			/* Check if at end */
-	bne	_clear_bss
-
-	/*
-	 *	Load the current thread pointer and stack.
-	 */
-	lea	init_thread_union, %a0
-	lea	0x2000(%a0), %sp
-
-   /*
-    * User mode port access
-    */
-   move.l   #0x0000000c, %d0
-   move.b   %d0, (IPSBAR+GPACR0)
-
-
-	/*
-	 *	Assember start up done, start code proper.
-	 */
-	jsr	start_kernel			/* Start Linux kernel */
-
-_exit:
-	jmp	_exit				/* Should never get here */
-
-/*****************************************************************************/
diff -Nru a/arch/m68knommu/platform/528x/M5282EVB/crt0_ram.S b/arch/m68knommu/platform/528x/M5282EVB/crt0_ram.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/528x/M5282EVB/crt0_ram.S	2004-12-24 13:37:43 -08:00
@@ -0,0 +1,171 @@
+/*****************************************************************************/
+
+/*
+ *	crt0_ram.S -- startup code for M5282EVB ColdFire based MOTOROLA boards.
+ *
+ *	(C) Copyright 2003, Greg Ungerer (gerg@snapgear.com).
+ */
+
+/*****************************************************************************/
+
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/linkage.h>
+#include <asm/segment.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+
+/*****************************************************************************/
+
+/*
+ *	Motorola M5282EVB ColdFire eval board, chip select and memory setup.
+ */
+
+#define	MEM_BASE	0x00000000	/* Memory base at address 0 */
+#define	VBR_BASE	MEM_BASE	/* Vector address */
+
+#if defined(CONFIG_RAM16MB)
+#define	MEM_SIZE	0x01000000	/* Memory size 16Mb */
+#elif defined(CONFIG_RAM8MB)
+#define	MEM_SIZE	0x00800000	/* Memory size 8Mb */
+#else
+#define	MEM_SIZE	0x00400000	/* Memory size 4Mb */
+#endif
+
+/*****************************************************************************/
+
+.global	_start
+.global _rambase
+.global _ramvec
+.global	_ramstart
+.global	_ramend
+
+/*****************************************************************************/
+
+.data
+
+/*
+ *	Set up the usable of RAM stuff. Size of RAM is determined then
+ *	an initial stack set up at the end.
+ */
+_rambase:
+.long	0
+_ramvec:
+.long	0
+_ramstart:
+.long	0
+_ramend:
+.long	0
+
+/*****************************************************************************/
+
+.text
+
+/*
+ *	This is the codes first entry point. This is where it all
+ *	begins...
+ */
+
+_start:
+	nop					/* Filler */
+	move.w	#0x2700, %sr			/* No interrupts */
+
+	/*
+	 * Setup VBR here, otherwise buserror remap will not work.
+	 * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
+	 *
+	 * bkr@cut.de 19990306
+	 *
+	 * Note: this is because dBUG points VBR to ROM, making vectors read
+	 * only, so the bus trap can't be changed. (RS)
+	 */
+	move.l	#VBR_BASE, %a7			/* Note VBR can't be read */
+	movec   %a7, %VBR
+	move.l	%a7, _ramvec			/* Set up vector addr */
+	move.l	%a7, _rambase			/* Set up base RAM addr */
+
+
+	/*
+	 *	Set memory size.
+	 */
+	move.l	#MEM_SIZE, %a0
+
+	move.l	%a0, %d0			/* Mem end addr is in a0 */
+	move.l	%d0, %sp			/* Set up initial stack ptr */
+	move.l	%d0, _ramend			/* Set end ram addr */
+
+	/*
+	 *	Enable CPU internal cache.
+	 *
+	 *	Cache is totally broken in first 5282 silicon.
+	 *	No point enabling it for now.
+	 */
+#if 0
+	move.l	#0x01000000, %d0
+	movec	%d0, %CACR			/* Invalidate cache */
+	nop
+
+	move.l	#0x0000c000, %d0		/* Set SDRAM cached only */
+	movec	%d0, %ACR0
+	move.l	#0x00000000, %d0		/* No other regions cached */
+	movec	%d0, %ACR1
+
+	move.l	#0x00000000, %d0		/* Setup cache mask */
+	movec	%d0, %CACR			/* Enable cache */
+	nop
+#endif
+
+
+#ifdef CONFIG_ROMFS_FS
+	/*
+	 *	Move ROM filesystem above bss :-)
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Set up destination  */
+	move.l	%a0, %a2			/* Copy of bss start */
+
+	move.l	8(%a0), %d0			/* Get size of ROMFS */
+	addq.l	#8, %d0				/* Allow for rounding */
+	and.l	#0xfffffffc, %d0		/* Whole words */
+
+	add.l	%d0, %a0			/* Copy from end */
+	add.l	%d0, %a1			/* Copy from end */
+	move.l	%a1, _ramstart			/* Set start of ram */
+
+_copy_romfs:
+	move.l	-(%a0), %d0			/* Copy dword */
+	move.l	%d0, -(%a1)
+	cmp.l	%a0, %a2			/* Check if at end */
+	bne	_copy_romfs
+#else /* CONFIG_ROMFS_FS */
+	lea.l	_ebss, %a1
+	move.l	%a1, _ramstart
+#endif /* CONFIG_ROMFS_FS */
+
+
+	/*
+	 *	Zero out the bss region.
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Get end of bss */
+	clr.l	%d0				/* Set value */
+_clear_bss:
+	move.l	%d0, (%a0)+			/* Clear each word */
+	cmp.l	%a0, %a1			/* Check if at end */
+	bne	_clear_bss
+
+	/*
+	 *	Load the current thread pointer and stack.
+	 */
+	lea	init_thread_union, %a0
+	lea	0x2000(%a0), %sp
+
+	/*
+	 *	Assember start up done, start code proper.
+	 */
+	jsr	start_kernel			/* Start Linux kernel */
+
+_exit:
+	jmp	_exit				/* Should never get here */
+
+/*****************************************************************************/
diff -Nru a/arch/m68knommu/platform/528x/Makefile b/arch/m68knommu/platform/528x/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/528x/Makefile	2004-12-24 13:37:43 -08:00
@@ -0,0 +1,21 @@
+#
+# Makefile for the linux kernel.
+#
+
+#
+# If you want to play with the HW breakpoints then you will
+# need to add define this,  which will give you a stack backtrace
+# on the console port whenever a DBG interrupt occurs.  You have to
+# set up you HW breakpoints to trigger a DBG interrupt:
+#
+# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT
+# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
+#
+
+ifdef CONFIG_FULLDEBUG
+AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+endif
+
+obj-y := config.o
+
+extra-y := $(BOARD)/crt0_$(MODEL).o
diff -Nru a/arch/m68knommu/platform/528x/config.c b/arch/m68knommu/platform/528x/config.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/528x/config.c	2004-12-24 13:36:17 -08:00
@@ -0,0 +1,82 @@
+/***************************************************************************/
+
+/*
+ *	linux/arch/m68knommu/platform/528x/config.c
+ *
+ *	Sub-architcture dependant initialization code for the Motorola
+ *	5280 and 5282 CPUs.
+ *
+ *	Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
+ *	Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
+ */
+
+/***************************************************************************/
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/param.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <asm/dma.h>
+#include <asm/traps.h>
+#include <asm/machdep.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+#include <asm/mcfdma.h>
+
+/***************************************************************************/
+
+void coldfire_pit_tick(void);
+void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+unsigned long coldfire_pit_offset(void);
+void coldfire_trap_init(void);
+void coldfire_reset(void);
+
+/***************************************************************************/
+
+/*
+ *	DMA channel base address table.
+ */
+unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
+        MCF_MBAR + MCFDMA_BASE0,
+};
+
+unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+
+/***************************************************************************/
+
+void mcf_disableall(void)
+{
+	*((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
+	*((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
+}
+
+/***************************************************************************/
+
+void mcf_autovector(unsigned int vec)
+{
+	/* Everything is auto-vectored on the 5272 */
+}
+
+/***************************************************************************/
+
+void config_BSP(char *commandp, int size)
+{
+	mcf_disableall();
+
+#ifdef CONFIG_BOOTPARAM
+	strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
+	commandp[size-1] = 0;
+#else
+	memset(commandp, 0, size);
+#endif
+
+	mach_sched_init = coldfire_pit_init;
+	mach_tick = coldfire_pit_tick;
+	mach_gettimeoffset = coldfire_pit_offset;
+	mach_trap_init = coldfire_trap_init;
+	mach_reset = coldfire_reset;
+}
+
+/***************************************************************************/
diff -Nru a/arch/m68knommu/platform/528x/senTec/crt0_ram.S b/arch/m68knommu/platform/528x/senTec/crt0_ram.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/528x/senTec/crt0_ram.S	2004-12-24 13:37:00 -08:00
@@ -0,0 +1,180 @@
+/*****************************************************************************/
+
+/*
+ *	crt0_ram.S -- startup code for senTec COBRA5282 ColdFire based boards.
+ *
+ *	(C) Copyright 2003, Greg Ungerer (gerg@snapgear.com).
+ */
+
+/*****************************************************************************/
+
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/linkage.h>
+#include <asm/segment.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+
+/*****************************************************************************/
+
+/*
+ *	senTec COBRA5282 board, chip select and memory setup.
+ */
+
+#define	MEM_BASE	0x00000000	/* Memory base at address 0 */
+#define	VBR_BASE	MEM_BASE	/* Vector address */
+
+#if defined(CONFIG_RAM16MB)
+#define	MEM_SIZE	0x01000000	/* Memory size 16Mb */
+#elif defined(CONFIG_RAM8MB)
+#define	MEM_SIZE	0x00800000	/* Memory size 8Mb */
+#else
+#define	MEM_SIZE	0x00400000	/* Memory size 4Mb */
+#endif
+
+#define IPSBAR 0x40000000
+#define GPACR0 0x30
+/*****************************************************************************/
+
+.global	_start
+.global	_rambase
+.global	_ramvec
+.global	_ramstart
+.global	_ramend
+
+/*****************************************************************************/
+
+.data
+
+/*
+ *	Set up the usable of RAM stuff. Size of RAM is determined then
+ *	an initial stack set up at the end.
+ */
+_rambase:
+.long	0
+_ramvec:
+.long	0
+_ramstart:
+.long	0
+_ramend:
+.long	0
+
+/*****************************************************************************/
+
+.text
+
+/*
+ *	This is the codes first entry point. This is where it all
+ *	begins...
+ */
+
+_start:
+	nop								/* Filler */
+	move.w	#0x2700, %sr			/* No interrupts */
+
+	/*
+	 * Setup VBR here, otherwise buserror remap will not work.
+	 * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
+	 *
+	 * bkr@cut.de 19990306
+	 *
+	 * Note: this is because dBUG points VBR to ROM, making vectors read
+	 * only, so the bus trap can't be changed. (RS)
+	 */
+	move.l	#VBR_BASE, %a7			/* Note VBR can't be read */
+	movec   %a7, %VBR
+	move.l	%a7, _ramvec			/* Set up vector addr */
+	move.l	%a7, _rambase			/* Set up base RAM addr */
+
+
+	/*
+	 *	Set memory size.
+	 */
+	move.l	#MEM_SIZE, %a0
+
+	move.l	%a0, %d0			/* Mem end addr is in a0 */
+	move.l	%d0, %sp			/* Set up initial stack ptr */
+	move.l	%d0, _ramend		/* Set end ram addr */
+
+	/*
+	 *	Enable CPU internal cache.
+	 *
+	 *	Cache is totally broken in first 5282 silicon.
+	 *	No point enabling it for now.
+	 */
+#if 0
+	move.l	#0x01000000, %d0
+	movec	%d0, %CACR				/* Invalidate cache */
+	nop
+
+	move.l	#0x0000c000, %d0		/* Set SDRAM cached only */
+	movec	%d0, %ACR0
+	move.l	#0x00000000, %d0		/* No other regions cached */
+	movec	%d0, %ACR1
+
+	move.l	#0x00000000, %d0		/* Setup cache mask */
+	movec	%d0, %CACR				/* Enable cache */
+	nop
+#endif
+
+
+#ifdef CONFIG_ROMFS_FS
+	/*
+	 *	Move ROM filesystem above bss :-)
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Set up destination  */
+	move.l	%a0, %a2			/* Copy of bss start */
+
+	move.l	8(%a0), %d0			/* Get size of ROMFS */
+	addq.l	#8, %d0				/* Allow for rounding */
+	and.l	#0xfffffffc, %d0	/* Whole words */
+
+	add.l	%d0, %a0			/* Copy from end */
+	add.l	%d0, %a1			/* Copy from end */
+	move.l	%a1, _ramstart		/* Set start of ram */
+
+_copy_romfs:
+	move.l	-(%a0), %d0			/* Copy dword */
+	move.l	%d0, -(%a1)
+	cmp.l	%a0, %a2			/* Check if at end */
+	bne	_copy_romfs
+#else /* CONFIG_ROMFS_FS */
+	lea.l	_ebss, %a1
+	move.l	%a1, _ramstart
+#endif /* CONFIG_ROMFS_FS */
+
+
+	/*
+	 *	Zero out the bss region.
+	 */
+	lea.l	_sbss, %a0			/* Get start of bss */
+	lea.l	_ebss, %a1			/* Get end of bss */
+	clr.l	%d0					/* Set value */
+_clear_bss:
+	move.l	%d0, (%a0)+			/* Clear each word */
+	cmp.l	%a0, %a1			/* Check if at end */
+	bne	_clear_bss
+
+	/*
+	 *	Load the current thread pointer and stack.
+	 */
+	lea	init_thread_union, %a0
+	lea	0x2000(%a0), %sp
+
+   /*
+    * User mode port access
+    */
+   move.l   #0x0000000c, %d0
+   move.b   %d0, (IPSBAR+GPACR0)
+
+
+	/*
+	 *	Assember start up done, start code proper.
+	 */
+	jsr	start_kernel			/* Start Linux kernel */
+
+_exit:
+	jmp	_exit				/* Should never get here */
+
+/*****************************************************************************/
diff -Nru a/arch/m68knommu/platform/5307/Makefile b/arch/m68knommu/platform/5307/Makefile
--- a/arch/m68knommu/platform/5307/Makefile	2004-12-24 13:37:18 -08:00
+++ b/arch/m68knommu/platform/5307/Makefile	2004-12-24 13:37:18 -08:00
@@ -20,8 +20,10 @@
 obj-$(CONFIG_M5206)	+= timers.o
 obj-$(CONFIG_M5206e)	+= timers.o
 obj-$(CONFIG_M5249)	+= timers.o
+obj-$(CONFIG_M527x)     += pit.o
 obj-$(CONFIG_M5272)	+= timers.o
 obj-$(CONFIG_M5307)	+= config.o timers.o
+obj-$(CONFIG_M528x)     += pit.o
 obj-$(CONFIG_M5407)	+= timers.o
 
 ifeq ($(CONFIG_M5307),y)
diff -Nru a/arch/m68knommu/platform/5307/config.c b/arch/m68knommu/platform/5307/config.c
--- a/arch/m68knommu/platform/5307/config.c	2004-12-24 13:36:18 -08:00
+++ b/arch/m68knommu/platform/5307/config.c	2004-12-24 13:36:18 -08:00
@@ -23,7 +23,6 @@
 #include <asm/mcftimer.h>
 #include <asm/mcfsim.h>
 #include <asm/mcfdma.h>
-#include <asm/delay.h>
 #include <asm/mcfwdebug.h>
 
 /***************************************************************************/
diff -Nru a/arch/m68knommu/platform/5307/pit.c b/arch/m68knommu/platform/5307/pit.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/m68knommu/platform/5307/pit.c	2004-12-24 13:37:18 -08:00
@@ -0,0 +1,88 @@
+/***************************************************************************/
+
+/*
+ *	pit.c -- Motorola ColdFire PIT timer. Currently this type of
+ *	         hardware timer only exists in the Motorola ColdFire
+ *		 5270/5271 and 5282 CPUs.
+ *
+ *	Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com)
+ *	Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
+ *
+ */
+
+/***************************************************************************/
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/param.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <asm/irq.h>
+#include <asm/coldfire.h>
+#include <asm/mcfpit.h>
+#include <asm/mcfsim.h>
+
+/***************************************************************************/
+
+void coldfire_pit_tick(void)
+{
+	volatile struct mcfpit *tp;
+
+	/* Reset the ColdFire timer */
+	tp = (volatile struct mcfpit *) (MCF_IPSBAR + MCFPIT_BASE1);
+	tp->pcsr |= MCFPIT_PCSR_PIF;
+}
+
+/***************************************************************************/
+
+void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *))
+{
+	volatile unsigned char *icrp;
+	volatile unsigned long *imrp;
+	volatile struct mcfpit *tp;
+
+	request_irq(MCFINT_VECBASE + MCFINT_PIT1, handler, SA_INTERRUPT,
+		"ColdFire Timer", NULL);
+
+	icrp = (volatile unsigned char *) (MCF_IPSBAR + MCFICM_INTC0 +
+		MCFINTC_ICR0 + MCFINT_PIT1);
+	*icrp = 0x2b; /* PIT1 with level 5, priority 3 */
+
+	imrp = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
+	*imrp &= ~(1 << (MCFINT_PIT1 - 32));
+
+	/* Set up PIT timer 1 as poll clock */
+	tp = (volatile struct mcfpit *) (MCF_IPSBAR + MCFPIT_BASE1);
+	tp->pcsr = MCFPIT_PCSR_DISABLE;
+
+	tp->pmr = ((MCF_CLK / 2) / 64) / HZ;
+	tp->pcsr = MCFPIT_PCSR_EN | MCFPIT_PCSR_PIE | MCFPIT_PCSR_OVW |
+		MCFPIT_PCSR_RLD | MCFPIT_PCSR_CLK64;
+}
+
+/***************************************************************************/
+
+unsigned long coldfire_pit_offset(void)
+{
+	volatile struct mcfpit *tp;
+	volatile unsigned long *ipr;
+	unsigned long pmr, pcntr, offset;
+
+	tp = (volatile struct mcfpit *) (MCF_IPSBAR + MCFPIT_BASE1);
+	ipr = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IPRH);
+
+	pmr = *(&tp->pmr);
+	pcntr = *(&tp->pcntr);
+
+	/*
+	 * If we are still in the first half of the upcount and a
+	 * timer interupt is pending, then add on a ticks worth of time.
+	 */
+	offset = ((pmr - pcntr) * (1000000 / HZ)) / pmr;
+	if ((offset < (1000000 / HZ / 2)) && (*ipr & (1 << (MCFINT_PIT1 - 32))))
+		offset += 1000000 / HZ;
+	return offset;	
+}
+
+/***************************************************************************/
diff -Nru a/arch/m68knommu/platform/5307/vectors.c b/arch/m68knommu/platform/5307/vectors.c
--- a/arch/m68knommu/platform/5307/vectors.c	2004-12-24 13:37:18 -08:00
+++ b/arch/m68knommu/platform/5307/vectors.c	2004-12-24 13:37:18 -08:00
@@ -14,6 +14,7 @@
 #include <linux/param.h>
 #include <linux/init.h>
 #include <linux/unistd.h>
+#include <linux/delay.h>
 #include <asm/irq.h>
 #include <asm/dma.h>
 #include <asm/traps.h>
@@ -22,7 +23,6 @@
 #include <asm/mcftimer.h>
 #include <asm/mcfsim.h>
 #include <asm/mcfdma.h>
-#include <asm/delay.h>
 #include <asm/mcfwdebug.h>
 
 /***************************************************************************/
diff -Nru a/arch/m68knommu/platform/5407/config.c b/arch/m68knommu/platform/5407/config.c
--- a/arch/m68knommu/platform/5407/config.c	2004-12-24 13:37:01 -08:00
+++ b/arch/m68knommu/platform/5407/config.c	2004-12-24 13:37:01 -08:00
@@ -23,7 +23,6 @@
 #include <asm/mcftimer.h>
 #include <asm/mcfsim.h>
 #include <asm/mcfdma.h>
-#include <asm/delay.h>
 
 /***************************************************************************/
 
diff -Nru a/arch/mips/Kconfig b/arch/mips/Kconfig
--- a/arch/mips/Kconfig	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/Kconfig	2004-12-24 13:36:49 -08:00
@@ -11,7 +11,7 @@
 	  only select this option if you have hardware that actually has a
 	  64-bit processor and if your application will actually benefit from
 	  64-bit processing, otherwise say N.  You must say Y for kernels for
-	  SGI IP27 (Origin 200 and 2000).  If in doubt say N.
+	  SGI IP27 (Origin 200 and 2000) and SGI IP32 (O2).  If in doubt say N.
 
 config 64BIT
 	def_bool MIPS64
@@ -66,14 +66,6 @@
 	  the MIPS architecture, check out the Linux/MIPS FAQ on the WWW at
 	  <http://www.linux-mips.org/>.
 
-config BAGET_MIPS
-	bool "Support for BAGET MIPS series (EXPERIMENTAL)"
-	depends on MIPS32 && EXPERIMENTAL
-	help
-	  This enables support for the Baget, a Russian embedded system.  For
-	  more details about the Baget see the Linux/MIPS FAQ on
-	  <http://www.linux-mips.org/>.
-
 config MACH_VR41XX
 	bool "Support for NEC VR41XX-based machines"
 
@@ -146,6 +138,7 @@
 	depends on MIPS32
 	select DMA_NONCOHERENT
 	select HW_HAS_PCI
+	select SWAP_IO_SPACE
 
 config MIPS_COBALT
 	bool "Support for Cobalt Server (EXPERIMENTAL)"
@@ -198,6 +191,7 @@
 	select IRQ_CPU
 	select MIPS_GT96100
 	select RM7000_CPU_SCACHE
+	select SWAP_IO_SPACE
 	help
 	  This is an evaluation board based on the Galileo GT-96100 LAN/WAN
 	  communications controllers containing a MIPS R5000 compatible core
@@ -237,13 +231,6 @@
 	bool "LASAT sysctl interface"
 	depends on LASAT
 
-config HP_LASERJET
-	bool "Support for Hewlett Packard LaserJet board"
-	depends on BROKEN
-	select DMA_NONCOHERENT
-	select HW_HAS_PCI
-	select IRQ_CPU
-
 config MIPS_ITE8172
 	bool "Support for ITE 8172G board"
 	select DMA_NONCOHERENT
@@ -268,6 +255,7 @@
 	bool "Support for MIPS Atlas board"
 	select DMA_NONCOHERENT
 	select HW_HAS_PCI
+	select SWAP_IO_SPACE
 	help
 	  This enables support for the QED R5231-based MIPS Atlas evaluation
 	  board.
@@ -277,6 +265,7 @@
 	select HAVE_STD_PC_SERIAL_PORT
 	select DMA_NONCOHERENT
 	select HW_HAS_PCI
+	select SWAP_IO_SPACE
 	help
 	  This enables support for the VR5000-based MIPS Malta evaluation
 	  board.
@@ -294,6 +283,7 @@
 	select IRQ_CPU
 	select IRQ_CPU_RM7K
 	select RM7000_CPU_SCACHE
+	select SWAP_IO_SPACE
 	help
 	  The Ocelot is a MIPS-based Single Board Computer (SBC) made by
 	  Momentum Computer <http://www.momenco.com/>.
@@ -306,6 +296,7 @@
 	select IRQ_CPU_RM7K
 	select PCI_MARVELL
 	select RM7000_CPU_SCACHE
+	select SWAP_IO_SPACE
 	help
 	  The Ocelot is a MIPS-based Single Board Computer (SBC) made by
 	  Momentum Computer <http://www.momenco.com/>.
@@ -318,10 +309,25 @@
 	select IRQ_MV64340
 	select PCI_MARVELL
 	select RM7000_CPU_SCACHE
+	select SWAP_IO_SPACE
 	help
 	  The Ocelot is a MIPS-based Single Board Computer (SBC) made by
 	  Momentum Computer <http://www.momenco.com/>.
 
+config MOMENCO_OCELOT_3
+	bool "Support for Momentum Ocelot-3 board"
+	select DMA_NONCOHERENT
+	select HW_HAS_PCI
+	select IRQ_CPU
+	select IRQ_CPU_RM7K
+	select IRQ_MV64340
+	select PCI_MARVELL
+	select RM7000_CPU_SCACHE
+	select SWAP_IO_SPACE
+	help
+	  The Ocelot-3 is based off Discovery III System Controller and
+	  PMC-Sierra Rm79000 core.
+
 config MOMENCO_JAGUAR_ATX
 	bool "Support for Momentum Jaguar board"
 	select DMA_NONCOHERENT
@@ -332,6 +338,7 @@
 	select LIMITED_DMA
 	select PCI_MARVELL
 	select RM7000_CPU_SCACHE
+	select SWAP_IO_SPACE
 	help
 	  The Jaguar ATX is a MIPS-based Single Board Computer (SBC) made by
 	  Momentum Computer <http://www.momenco.com/>.
@@ -349,6 +356,7 @@
 	select HW_HAS_PCI
 	select IRQ_CPU
 	select IRQ_CPU_RM7K
+	select SWAP_IO_SPACE
 	help
 	  Yosemite is an evaluation board for the RM9000x2 processor
 	  manufactured by PMC-Sierra
@@ -411,6 +419,7 @@
 	select DMA_NONCOHERENT
 	select IP22_CPU_SCACHE
 	select IRQ_CPU
+	select SWAP_IO_SPACE
 	help
 	  This are the SGI Indy, Challenge S and Indigo2, as well as certain
 	  OEM variants like the Tandem CMN B006S. To compile a Linux kernel
@@ -421,6 +430,7 @@
 	depends on MIPS64
 	select DMA_IP27
 	select HW_HAS_PCI
+	select PCI_DOMAINS
 	help
 	  This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
 	  workstations.  To compile a Linux kernel that runs on these, say Y
@@ -462,9 +472,9 @@
 	bool "Mapped kernel support"
 	depends on SGI_IP27
 	help
-	  Change the way a Linux kernel is loaded unto memory on a MIPS64
+	  Change the way a Linux kernel is loaded into memory on a MIPS64
 	  machine.  This is required in order to support text replication and
-	  NUMA.  If you need to undersatand it, read the source code.
+	  NUMA.  If you need to understand it, read the source code.
 
 config REPLICATE_KTEXT
 	bool "Kernel text replication support"
@@ -483,7 +493,7 @@
 
 config SGI_IP32
 	bool "Support for SGI IP32 (O2) (EXPERIMENTAL)"
-	depends on EXPERIMENTAL
+	depends on MIPS64 && EXPERIMENTAL
 	select DMA_NONCOHERENT
 	select HW_HAS_PCI
 	select R5000_CPU_SCACHE
@@ -529,24 +539,27 @@
 	depends on SOC_AU1000
 	select DMA_NONCOHERENT
 	select HW_HAS_PCI
+	select SWAP_IO_SPACE
 
 config MIPS_PB1100
 	bool "PB1100 board"
 	depends on SOC_AU1100
 	select DMA_NONCOHERENT
 	select HW_HAS_PCI
+	select SWAP_IO_SPACE
 
 config MIPS_PB1500
 	bool "PB1500 board"
 	depends on SOC_AU1500
-	select DMA_NONCOHERENT
+	select DMA_COHERENT
 	select HW_HAS_PCI
 
 config MIPS_PB1550
 	bool "PB1550 board"
 	depends on SOC_AU1550
-	select DMA_NONCOHERENT
+	select DMA_COHERENT
 	select HW_HAS_PCI
+	select MIPS_DISABLE_OBSOLETE_IDE
 
 config MIPS_DB1000
 	bool "DB1000 board"
@@ -562,13 +575,16 @@
 config MIPS_DB1500
 	bool "DB1500 board"
 	depends on SOC_AU1500
-	select DMA_NONCOHERENT
+	select DMA_COHERENT
 	select HW_HAS_PCI
+	select MIPS_DISABLE_OBSOLETE_IDE
 
 config MIPS_DB1550
 	bool "DB1550 board"
 	depends on SOC_AU1550
 	select HW_HAS_PCI
+	select DMA_COHERENT
+	select MIPS_DISABLE_OBSOLETE_IDE
 
 config MIPS_BOSPORUS
 	bool "Bosporus board"
@@ -596,6 +612,7 @@
 	bool "Support for Broadcom BCM1xxx SOCs (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
 	select DMA_COHERENT
+	select SWAP_IO_SPACE
 
 choice
 	prompt "BCM1xxx SOC-based board"
@@ -817,7 +834,16 @@
 	depends on MIPS32
 	select DMA_NONCOHERENT
 	select HW_HAS_PCI
+	select I8259
 	select ISA
+	select SWAP_IO_SPACE
+	help
+	  This Toshiba board is based on the TX4927 processor. Say Y here to
+	  support this machine type
+
+config TOSHIBA_FPCIB0
+	bool "FPCIB0 Backplane Support"
+	depends on TOSHIBA_RBTX4927
 
 config RWSEM_GENERIC_SPINLOCK
 	bool
@@ -881,10 +907,13 @@
 	depends on LASAT
 	default y
 
+config MIPS_DISABLE_OBSOLETE_IDE
+	bool
+
 config CPU_LITTLE_ENDIAN
 	bool "Generate little endian code"
-	default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || HP_LASERJET || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || SOC_AU1X00 || NEC_OSPREY || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA
-	default n if BAGET_MIPS || MIPS_EV64120 || MIPS_EV96100 || MOMENCO_OCELOT || MOMENCO_OCELOT_G || SGI_IP22 || SGI_IP27 || SGI_IP32 || TOSHIBA_JMR3927
+	default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || SOC_AU1X00 || NEC_OSPREY || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA
+	default n if MIPS_EV64120 || MIPS_EV96100 || MOMENCO_OCELOT || MOMENCO_OCELOT_G || SGI_IP22 || SGI_IP27 || SGI_IP32 || TOSHIBA_JMR3927
 	help
 	  Some MIPS machines can be configured for either little or big endian
 	  byte order. These modes require different kernels. Say Y if your
@@ -934,8 +963,6 @@
 
 config SWAP_IO_SPACE
 	bool
-	depends on TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || SIBYTE_SB1xxx_SOC || SGI_IP22 || MOMENCO_OCELOT_C || MOMENCO_OCELOT_G || MOMENCO_OCELOT || MOMENCO_JAGUAR_ATX || MIPS_MALTA || MIPS_ATLAS || MIPS_EV96100 || MIPS_PB1100 || MIPS_PB1000
-	default y
 
 #
 # Unfortunately not all GT64120 systems run the chip at the same clock.
@@ -984,7 +1011,7 @@
 
 config BOOT_ELF32
 	bool
-	depends on MACH_DECSTATION || MIPS_ATLAS || MIPS_MALTA || MOMENCO_JAGUAR_ATX || SIBYTE_SB1xxx_SOC || SGI_IP32 || SGI_IP22 || SNI_RM200_PCI
+	depends on MACH_DECSTATION || MIPS_ATLAS || MIPS_MALTA || MOMENCO_JAGUAR_ATX || MOMENCO_OCELOT_3 || SIBYTE_SB1xxx_SOC || SGI_IP32 || SGI_IP22 || SNI_RM200_PCI
 	default y
 
 config MIPS_L1_CACHE_SHIFT
@@ -1033,11 +1060,6 @@
 	  (e.g. an accelerated X server) and that are not frame buffer
 	  device-aware may cause unexpected results. If unsure, say N.
 
-config FB_G364
-	bool
-	depends on MIPS_MAGNUM_4000 || OLIVETTI_M700
-	default y
-
 config HAVE_STD_PC_SERIAL_PORT
 	bool
 
@@ -1156,9 +1178,9 @@
 	  processors are extremly rare and the support for them is incomplete.
 
 config CPU_NEVADA
-	bool "R52xx"
+	bool "RM52xx"
 	help
-	  MIPS Technologies R52x0-series ("Nevada") processors.
+	  QED / PMC-Sierra RM52xx-series ("Nevada") processors.
 
 config CPU_R8000
 	bool "R8000"
@@ -1333,7 +1355,7 @@
 #
 config HIGHMEM
 	bool "High Memory Support"
-	depends on MIPS32 && (CPU_R3000 || CPU_SB1 || CPU_R7000 || CPU_RM9000 || CPU_R10000) && !(BAGET_MIPS || MACH_DECSTATION || MOMENCO_JAGUAR_ATX)
+	depends on MIPS32 && (CPU_R3000 || CPU_SB1 || CPU_R7000 || CPU_RM9000 || CPU_R10000) && !(MACH_DECSTATION || MOMENCO_JAGUAR_ATX)
 
 config SMP
 	bool "Multi-Processing support"
@@ -1420,6 +1442,10 @@
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
+config PCI_DOMAINS
+	bool
+	depends on PCI
+
 source "drivers/pci/Kconfig"
 
 #
@@ -1486,9 +1512,24 @@
 	bool
 	default y if MIPS32
 
+config BUILD_ELF64
+	bool "Use 64-bit ELF format for building"
+	depends on MIPS64
+	help
+	  A 64-bit kernel is usually built using the 64-bit ELF binary object
+	  format as it's one that allows arbitrary 64-bit constructs.  For
+	  kernels that are loaded within the KSEG compatibility segments the
+	  32-bit ELF format can optionally be used resulting in a somewhat
+	  smaller binary, but this option is not explicitly supported by the
+	  toolchain and since binutils 2.14 it does not even work at all.
+
+	  Say Y to use the 64-bit format or N to use the 32-bit one.
+
+	  If unsure say Y.
+
 config BINFMT_IRIX
 	bool "Include IRIX binary compatibility"
-	depends on !CPU_LITTLE_ENDIAN && MIPS32
+	depends on !CPU_LITTLE_ENDIAN && MIPS32 && BROKEN
 
 config MIPS32_COMPAT
 	bool "Kernel support for Linux/MIPS 32-bit binary compatibility"
@@ -1534,24 +1575,6 @@
 
 endmenu
 
-menu "MIPS initrd options"
-	depends on BLK_DEV_INITRD
-
-config EMBEDDED_RAMDISK
-	bool "Embed root filesystem ramdisk into the kernel"
-
-config EMBEDDED_RAMDISK_IMAGE
-	string "Filename of gziped ramdisk image"
-	depends on EMBEDDED_RAMDISK
-	default "ramdisk.gz"
-	help
-	  This is the filename of the ramdisk image to be built into the
-	  kernel.  Relative pathnames are relative to arch/mips/ramdisk/.
-	  The ramdisk image is not part of the kernel distribution; you must
-	  provide one yourself.
-
-endmenu
-
 source "drivers/Kconfig"
 
 source "fs/Kconfig"
@@ -1563,3 +1586,14 @@
 source "crypto/Kconfig"
 
 source "lib/Kconfig"
+
+#
+# Use the generic interrupt handling code in kernel/irq/:
+#
+config GENERIC_HARDIRQS
+	bool
+	default y
+
+config GENERIC_IRQ_PROBE
+	bool
+	default y
diff -Nru a/arch/mips/Makefile b/arch/mips/Makefile
--- a/arch/mips/Makefile	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/Makefile	2004-12-24 13:36:17 -08:00
@@ -5,13 +5,19 @@
 #
 # Copyright (C) 1994, 95, 96, 2003 by Ralf Baechle
 # DECStation modifications by Paul M. Antoine, 1996
-# Copyright (C) 2002, 2003  Maciej W. Rozycki
+# Copyright (C) 2002, 2003, 2004  Maciej W. Rozycki
 #
 # This file is included by the global makefile so that you can add your own
 # architecture-specific flags and dependencies. Remember to do have actions
 # for "archclean" cleaning up for this architecture.
 #
 
+as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
+	     -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
+	     else echo "$(2)"; fi ;)
+
+cflags-y :=
+
 #
 # Select the object file format to substitute into the linker script.
 #
@@ -20,22 +26,24 @@
 64bit-tool-prefix	= mips64el-linux-
 32bit-bfd		= elf32-tradlittlemips
 64bit-bfd		= elf64-tradlittlemips
+32bit-emul		= elf32ltsmip
+64bit-emul		= elf64ltsmip
 else
 32bit-tool-prefix	= mips-linux-
 64bit-tool-prefix	= mips64-linux-
 32bit-bfd		= elf32-tradbigmips
 64bit-bfd		= elf64-tradbigmips
+32bit-emul		= elf32btsmip
+64bit-emul		= elf64btsmip
 endif
 
 ifdef CONFIG_MIPS32
 gcc-abi			= 32
-gas-abi			= 32
 tool-prefix		= $(32bit-tool-prefix)
 UTS_MACHINE		:= mips
 endif
 ifdef CONFIG_MIPS64
 gcc-abi			= 64
-gas-abi			= 32
 tool-prefix		= $(64bit-tool-prefix)
 UTS_MACHINE		:= mips64
 endif
@@ -44,6 +52,20 @@
 CROSS_COMPILE		:= $(tool-prefix)
 endif
 
+ifdef CONFIG_BUILD_ELF64
+gas-abi			= 64
+ld-emul			= $(64bit-emul)
+vmlinux-32		= vmlinux.32
+vmlinux-64		= vmlinux
+else
+gas-abi			= 32
+ld-emul			= $(32bit-emul)
+vmlinux-32		= vmlinux
+vmlinux-64		= vmlinux.64
+
+cflags-$(CONFIG_MIPS64)	+= $(call cc-option,-mno-explicit-relocs)
+endif
+
 #
 # GCC uses -G 0 -mabicalls -fpic as default.  We don't want PIC in the kernel
 # code since it only slows down the whole thing.  At some point we might make
@@ -54,7 +76,7 @@
 # machines may also.  Since BFD is incredibly buggy with respect to
 # crossformat linking we rely on the elf2ecoff tool for format conversion.
 #
-cflags-y			:= -I $(TOPDIR)/include/asm/gcc
+cflags-y			+= -I $(TOPDIR)/include/asm/gcc
 cflags-y			+= -G 0 -mno-abicalls -fno-pic -pipe
 cflags-y			+= $(call cc-option, -finline-limit=100000)
 LDFLAGS_vmlinux			+= -G 0 -static -n
@@ -141,6 +163,10 @@
 			$(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \
 			-Wa,--trap
 
+cflags-$(CONFIG_CPU_TX49XX)	+= \
+			$(call set_gccflags,r4600,mips3,r4600,mips3,mips2)  \
+			-Wa,--trap
+
 cflags-$(CONFIG_CPU_MIPS32)	+= \
 			$(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \
 			-Wa,--trap
@@ -189,14 +215,6 @@
 endif
 
 #
-# ramdisk/initrd support
-# You need a compressed ramdisk image, named
-# CONFIG_EMBEDDED_RAMDISK_IMAGE. Relative pathnames 
-# are relative to arch/mips/ramdisk/.
-#
-core-$(CONFIG_EMBEDDED_RAMDISK)	+= arch/mips/ramdisk/
-
-#
 # Firmware support
 #
 libs-$(CONFIG_ARC)		+= arch/mips/arc/
@@ -211,7 +229,7 @@
 #
 core-$(CONFIG_MACH_JAZZ)	+= arch/mips/jazz/
 cflags-$(CONFIG_MACH_JAZZ)	+= -Iinclude/asm-mips/mach-jazz
-load-$(CONFIG_MACH_JAZZ)	+= 0x80080000
+load-$(CONFIG_MACH_JAZZ)	+= 0xffffffff80080000
 
 #
 # Common Alchemy Au1x00 stuff
@@ -224,87 +242,88 @@
 #
 libs-$(CONFIG_MIPS_PB1000)	+= arch/mips/au1000/pb1000/
 cflags-$(CONFIG_MIPS_PB1000)	+= -Iinclude/asm-mips/mach-pb1x00
-load-$(CONFIG_MIPS_PB1000)	+= 0x80100000
+load-$(CONFIG_MIPS_PB1000)	+= 0xffffffff80100000
 
 #
 # AMD Alchemy Pb1100 eval board
 #
 libs-$(CONFIG_MIPS_PB1100)	+= arch/mips/au1000/pb1100/
 cflags-$(CONFIG_MIPS_PB1100)	+= -Iinclude/asm-mips/mach-pb1x00
-load-$(CONFIG_MIPS_PB1100)	+= 0x80100000
+load-$(CONFIG_MIPS_PB1100)	+= 0xffffffff80100000
 
 #
 # AMD Alchemy Pb1500 eval board
 #
 libs-$(CONFIG_MIPS_PB1500)	+= arch/mips/au1000/pb1500/
 cflags-$(CONFIG_MIPS_PB1500)	+= -Iinclude/asm-mips/mach-pb1x00
-load-$(CONFIG_MIPS_PB1500)	+= 0x80100000
+load-$(CONFIG_MIPS_PB1500)	+= 0xffffffff80100000
 
 #
 # AMD Alchemy Pb1550 eval board
 #
 libs-$(CONFIG_MIPS_PB1550)	+= arch/mips/au1000/pb1550/
 cflags-$(CONFIG_MIPS_PB1550)	+= -Iinclude/asm-mips/mach-pb1x00
-load-$(CONFIG_MIPS_PB1550)	+= 0x80100000
+load-$(CONFIG_MIPS_PB1550)	+= 0xffffffff80100000
 
 #
 # AMD Alchemy Db1000 eval board
 #
 libs-$(CONFIG_MIPS_DB1000)	+= arch/mips/au1000/db1x00/
 cflags-$(CONFIG_MIPS_DB1000)	+= -Iinclude/asm-mips/mach-db1x00
-load-$(CONFIG_MIPS_DB1000)	+= 0x80100000
+load-$(CONFIG_MIPS_DB1000)	+= 0xffffffff80100000
 
 #
 # AMD Alchemy Db1100 eval board
 #
 libs-$(CONFIG_MIPS_DB1100)	+= arch/mips/au1000/db1x00/
 cflags-$(CONFIG_MIPS_DB1100)	+= -Iinclude/asm-mips/mach-db1x00
-load-$(CONFIG_MIPS_DB1100)	+= 0x80100000
+load-$(CONFIG_MIPS_DB1100)	+= 0xffffffff80100000
 
 #
 # AMD Alchemy Db1500 eval board
 #
 libs-$(CONFIG_MIPS_DB1500)	+= arch/mips/au1000/db1x00/
 cflags-$(CONFIG_MIPS_DB1500)	+= -Iinclude/asm-mips/mach-db1x00
-load-$(CONFIG_MIPS_DB1500)	+= 0x80100000
+load-$(CONFIG_MIPS_DB1500)	+= 0xffffffff80100000
+
+#
+# AMD Alchemy Db1550 eval board
+#
+libs-$(CONFIG_MIPS_DB1550)	+= arch/mips/au1000/db1x00/
+cflags-$(CONFIG_MIPS_DB1550)	+= -Iinclude/asm-mips/mach-db1x00
+load-$(CONFIG_MIPS_DB1550)	+= 0xffffffff80100000
 
 #
 # AMD Alchemy Bosporus eval board
 #
 libs-$(CONFIG_MIPS_BOSPORUS)	+= arch/mips/au1000/db1x00/
 cflags-$(CONFIG_MIPS_BOSPORUS)	+= -Iinclude/asm-mips/mach-db1x00
-load-$(CONFIG_MIPS_BOSPORUS)	+= 0x80100000
+load-$(CONFIG_MIPS_BOSPORUS)	+= 0xffffffff80100000
 
 #
 # AMD Alchemy Mirage eval board
 #
 libs-$(CONFIG_MIPS_MIRAGE)	+= arch/mips/au1000/db1x00/
 cflags-$(CONFIG_MIPS_MIRAGE)	+= -Iinclude/asm-mips/mach-db1x00
-load-$(CONFIG_MIPS_MIRAGE)	+= 0x80100000
+load-$(CONFIG_MIPS_MIRAGE)	+= 0xffffffff80100000
 
 #
 # 4G-Systems eval board
 #
 libs-$(CONFIG_MIPS_MTX1)	+= arch/mips/au1000/mtx-1/
-load-$(CONFIG_MIPS_MTX1)	+= 0x80100000
+load-$(CONFIG_MIPS_MTX1)	+= 0xffffffff80100000
 
 #
 # MyCable eval board
 #
 libs-$(CONFIG_MIPS_XXS1500)	+= arch/mips/au1000/xxs1500/
-load-$(CONFIG_MIPS_XXS1500)	+= 0x80100000
-
-#
-# Baget/MIPS
-#
-libs-$(CONFIG_BAGET_MIPS)	+= arch/mips/baget/ arch/mips/baget/prom/
-load-$(CONFIG_BAGET_MIPS)	+= 0x80001000
+load-$(CONFIG_MIPS_XXS1500)	+= 0xffffffff80100000
 
 #
 # Cobalt Server
 #
 core-$(CONFIG_MIPS_COBALT)	+= arch/mips/cobalt/
-load-$(CONFIG_MIPS_COBALT)	+= 0x80080000
+load-$(CONFIG_MIPS_COBALT)	+= 0xffffffff80080000
 
 #
 # DECstation family
@@ -312,7 +331,7 @@
 core-$(CONFIG_MACH_DECSTATION)	+= arch/mips/dec/
 cflags-$(CONFIG_MACH_DECSTATION)+= -Iinclude/asm-mips/mach-dec
 libs-$(CONFIG_MACH_DECSTATION)	+= arch/mips/dec/prom/
-load-$(CONFIG_MACH_DECSTATION)	+= 0x80040000
+load-$(CONFIG_MACH_DECSTATION)	+= 0xffffffff80040000
 CLEAN_FILES			+= drivers/tc/lk201-map.c
 
 #
@@ -321,33 +340,27 @@
 core-$(CONFIG_MIPS_EV64120)	+= arch/mips/gt64120/ev64120/
 core-$(CONFIG_MIPS_EV64120)	+= arch/mips/gt64120/common/
 cflags-$(CONFIG_MIPS_EV64120)	+= -Iinclude/asm-mips/mach-ev64120
-load-$(CONFIG_MIPS_EV64120)	+= 0x80100000
+load-$(CONFIG_MIPS_EV64120)	+= 0xffffffff80100000
 
 #
 # Galileo EV96100 Board
 #
 core-$(CONFIG_MIPS_EV96100)	+= arch/mips/galileo-boards/ev96100/
 cflags-$(CONFIG_MIPS_EV96100)	+= -Iinclude/asm-mips/mach-ev96100
-load-$(CONFIG_MIPS_EV96100)	+= 0x80100000
+load-$(CONFIG_MIPS_EV96100)	+= 0xffffffff80100000
 
 #
 # Globespan IVR eval board with QED 5231 CPU
 #
 core-$(CONFIG_ITE_BOARD_GEN)	+= arch/mips/ite-boards/generic/
 core-$(CONFIG_MIPS_IVR)		+= arch/mips/ite-boards/ivr/
-load-$(CONFIG_MIPS_IVR)		+= 0x80100000
-
-#
-# HP LaserJet
-#
-core-$(CONFIG_HP_LASERJET)	+= arch/mips/hp-lj/
-load-$(CONFIG_HP_LASERJET)	+= 0x80030000
+load-$(CONFIG_MIPS_IVR)		+= 0xffffffff80100000
 
 #
 # ITE 8172 eval board with QED 5231 CPU
 #
 core-$(CONFIG_MIPS_ITE8172)	+= arch/mips/ite-boards/qed-4n-s01b/
-load-$(CONFIG_MIPS_ITE8172)	+= 0x80100000
+load-$(CONFIG_MIPS_ITE8172)	+= 0xffffffff80100000
 
 #
 # For all MIPS, Inc. eval boards
@@ -360,20 +373,20 @@
 core-$(CONFIG_MIPS_ATLAS)	+= arch/mips/mips-boards/atlas/
 cflags-$(CONFIG_MIPS_ATLAS)	+= -Iinclude/asm-mips/mach-atlas
 cflags-$(CONFIG_MIPS_ATLAS)	+= -Iinclude/asm-mips/mach-mips
-load-$(CONFIG_MIPS_ATLAS)	+= 0x80100000
+load-$(CONFIG_MIPS_ATLAS)	+= 0xffffffff80100000
 
 #
 # MIPS Malta board
 #
 core-$(CONFIG_MIPS_MALTA)	+= arch/mips/mips-boards/malta/
 cflags-$(CONFIG_MIPS_MALTA)	+= -Iinclude/asm-mips/mach-mips
-load-$(CONFIG_MIPS_MALTA)	+= 0x80100000
+load-$(CONFIG_MIPS_MALTA)	+= 0xffffffff80100000
 
 #
 # MIPS SEAD board
 #
 core-$(CONFIG_MIPS_SEAD)	+= arch/mips/mips-boards/sead/
-load-$(CONFIG_MIPS_SEAD)	+= 0x80100000
+load-$(CONFIG_MIPS_SEAD)	+= 0xffffffff80100000
 
 #
 # Momentum Ocelot board
@@ -384,7 +397,7 @@
 core-$(CONFIG_MOMENCO_OCELOT)	+= arch/mips/gt64120/common/ \
 				   arch/mips/gt64120/momenco_ocelot/
 cflags-$(CONFIG_MOMENCO_OCELOT)	+= -Iinclude/asm-mips/mach-ocelot
-load-$(CONFIG_MOMENCO_OCELOT)	+= 0x80100000
+load-$(CONFIG_MOMENCO_OCELOT)	+= 0xffffffff80100000
 
 #
 # Momentum Ocelot-G board
@@ -393,7 +406,7 @@
 # mips_io_port_base.
 #
 core-$(CONFIG_MOMENCO_OCELOT_G)	+= arch/mips/momentum/ocelot_g/
-load-$(CONFIG_MOMENCO_OCELOT_G)	+= 0x80100000
+load-$(CONFIG_MOMENCO_OCELOT_G)	+= 0xffffffff80100000
 
 #
 # Momentum Ocelot-C and -CS boards
@@ -401,14 +414,21 @@
 # The Ocelot-C[S] setup.o must be linked early - it does the ioremap() for the
 # mips_io_port_base.
 core-$(CONFIG_MOMENCO_OCELOT_C)	+= arch/mips/momentum/ocelot_c/
-load-$(CONFIG_MOMENCO_OCELOT_C)	+= 0x80100000
+load-$(CONFIG_MOMENCO_OCELOT_C)	+= 0xffffffff80100000
 
 #
 # PMC-Sierra Yosemite
 #
 core-$(CONFIG_PMC_YOSEMITE)	+= arch/mips/pmc-sierra/yosemite/
 cflags-$(CONFIG_PMC_YOSEMITE)	+= -Iinclude/asm-mips/mach-yosemite
-load-$(CONFIG_PMC_YOSEMITE)	+= 0x80100000
+load-$(CONFIG_PMC_YOSEMITE)	+= 0xffffffff80100000
+
+#
+# Momentum Ocelot-3
+#
+core-$(CONFIG_MOMENCO_OCELOT_3) 	+= arch/mips/momentum/ocelot_3/
+cflags-$(CONFIG_MOMENCO_OCELOT_3)	+= -Iinclude/asm-mips/mach-ocelot3
+load-$(CONFIG_MOMENCO_OCELOT_3) 	+= 0xffffffff80100000
 
 #
 # Momentum Jaguar ATX
@@ -416,9 +436,9 @@
 core-$(CONFIG_MOMENCO_JAGUAR_ATX)	+= arch/mips/momentum/jaguar_atx/
 cflags-$(CONFIG_MOMENCO_JAGUAR_ATX)	+= -Iinclude/asm-mips/mach-ja
 #ifdef CONFIG_JAGUAR_DMALOW
-#load-$(CONFIG_MOMENCO_JAGUAR_ATX)	+= 0x88000000
+#load-$(CONFIG_MOMENCO_JAGUAR_ATX)	+= 0xffffffff88000000
 #else
-load-$(CONFIG_MOMENCO_JAGUAR_ATX)	+= 0x80100000
+load-$(CONFIG_MOMENCO_JAGUAR_ATX)	+= 0xffffffff80100000
 #endif
 
 #
@@ -430,30 +450,30 @@
 # NEC DDB Vrc-5074
 #
 core-$(CONFIG_DDB5074)		+= arch/mips/ddb5xxx/ddb5074/
-load-$(CONFIG_DDB5074)		+= 0x80080000
+load-$(CONFIG_DDB5074)		+= 0xffffffff80080000
 
 #
 # NEC DDB Vrc-5476
 #
 core-$(CONFIG_DDB5476)		+= arch/mips/ddb5xxx/ddb5476/
-load-$(CONFIG_DDB5476)		+= 0x80080000
+load-$(CONFIG_DDB5476)		+= 0xffffffff80080000
 
 #
 # NEC DDB Vrc-5477
 #
 core-$(CONFIG_DDB5477)		+= arch/mips/ddb5xxx/ddb5477/
-load-$(CONFIG_DDB5477)		+= 0x80100000
+load-$(CONFIG_DDB5477)		+= 0xffffffff80100000
 
 core-$(CONFIG_LASAT)		+= arch/mips/lasat/
 cflags-$(CONFIG_LASAT)		+= -Iinclude/asm-mips/mach-lasat
-load-$(CONFIG_LASAT)		+= 0x80000000
+load-$(CONFIG_LASAT)		+= 0xffffffff80000000
 
 #
 # NEC Osprey (vr4181) board
 #
 core-$(CONFIG_NEC_OSPREY)	+= arch/mips/vr4181/common/ \
 				   arch/mips/vr4181/osprey/
-load-$(CONFIG_NEC_OSPREY)	+= 0x80002000
+load-$(CONFIG_NEC_OSPREY)	+= 0xffffffff80002000
 
 #
 # Common VR41xx
@@ -465,70 +485,84 @@
 # ZAO Networks Capcella (VR4131)
 #
 core-$(CONFIG_ZAO_CAPCELLA)	+= arch/mips/vr41xx/zao-capcella/
-load-$(CONFIG_ZAO_CAPCELLA)	+= 0x80000000
+load-$(CONFIG_ZAO_CAPCELLA)	+= 0xffffffff80000000
 
 #
 # Victor MP-C303/304 (VR4122)
 #
 core-$(CONFIG_VICTOR_MPC30X)	+= arch/mips/vr41xx/victor-mpc30x/
-load-$(CONFIG_VICTOR_MPC30X)	+= 0x80001000
+load-$(CONFIG_VICTOR_MPC30X)	+= 0xffffffff80001000
 
 #
 # IBM WorkPad z50 (VR4121)
 #
 core-$(CONFIG_IBM_WORKPAD)	+= arch/mips/vr41xx/ibm-workpad/
-load-$(CONFIG_IBM_WORKPAD)	+= 0x80004000
+load-$(CONFIG_IBM_WORKPAD)	+= 0xffffffff80004000
 
 #
 # CASIO CASSIPEIA E-55/65 (VR4111)
 #
 core-$(CONFIG_CASIO_E55)	+= arch/mips/vr41xx/casio-e55/
-load-$(CONFIG_CASIO_E55)	+= 0x80004000
+load-$(CONFIG_CASIO_E55)	+= 0xffffffff80004000
 
 #
 # TANBAC TB0226 Mbase (VR4131)
 #
 core-$(CONFIG_TANBAC_TB0226)	+= arch/mips/vr41xx/tanbac-tb0226/
-load-$(CONFIG_TANBAC_TB0226)	+= 0x80000000
+load-$(CONFIG_TANBAC_TB0226)	+= 0xffffffff80000000
 
 #
 # TANBAC TB0229 VR4131DIMM (VR4131)
 #
 core-$(CONFIG_TANBAC_TB0229)	+= arch/mips/vr41xx/tanbac-tb0229/
-load-$(CONFIG_TANBAC_TB0229)	+= 0x80000000
+load-$(CONFIG_TANBAC_TB0229)	+= 0xffffffff80000000
 
 #
 # SGI IP22 (Indy/Indigo2)
 #
-# Set the load address to >= 0x88069000 if you want to leave space for symmon,
-# 0x80002000 for production kernels.  Note that the value must be aligned to
-# a multiple of the kernel stack size or the handling of the current variable
-# will break so for 64-bit kernels we have to raise the start address by 8kb.
+# Set the load address to >= 0xffffffff88069000 if you want to leave space for
+# symmon, 0xffffffff80002000 for production kernels.  Note that the value must
+# be aligned to a multiple of the kernel stack size or the handling of the
+# current variable will break so for 64-bit kernels we have to raise the start
+# address by 8kb.
 #
 core-$(CONFIG_SGI_IP22)		+= arch/mips/sgi-ip22/
 cflags-$(CONFIG_SGI_IP22)	+= -Iinclude/asm-mips/mach-ip22
 ifdef CONFIG_MIPS32
-load-$(CONFIG_SGI_IP22)		+= 0x88002000
+load-$(CONFIG_SGI_IP22)		+= 0xffffffff88002000
 endif
 ifdef CONFIG_MIPS64
-load-$(CONFIG_SGI_IP22)		+= 0x88004000
+load-$(CONFIG_SGI_IP22)		+= 0xffffffff88004000
 endif
 
 #
 # SGI-IP27 (Origin200/2000)
 #
 # Set the load address to >= 0xc000000000300000 if you want to leave space for
-# symmon, 0xc00000000001c000 for production kernels.  Note that the value
-# must be 16kb aligned or the handling of the current variable will break.
+# symmon, 0xc00000000001c000 for production kernels.  Note that the value must
+# be 16kb aligned or the handling of the current variable will break.
 #
 ifdef CONFIG_SGI_IP27
 core-$(CONFIG_SGI_IP27)		+= arch/mips/sgi-ip27/
 cflags-$(CONFIG_SGI_IP27)	+= -Iinclude/asm-mips/mach-ip27
-#load-$(CONFIG_SGI_IP27)	+= 0xa80000000001c000
+ifdef CONFIG_BUILD_ELF64
+ifdef CONFIG_MAPPED_KERNEL
+load-$(CONFIG_SGI_IP27)		+= 0xc00000004001c000
+OBJCOPYFLAGS			:= --change-addresses=0x3fffffff80000000
+dataoffset-$(CONFIG_SGI_IP27)	+= 0x01000000
+else
+load-$(CONFIG_SGI_IP27)		+= 0xa80000000001c000
+OBJCOPYFLAGS			:= --change-addresses=0x57ffffff80000000
+endif
+else
 ifdef CONFIG_MAPPED_KERNEL
-load-$(CONFIG_SGI_IP27)		+= 0xc001c000
+load-$(CONFIG_SGI_IP27)		+= 0xffffffffc001c000
+OBJCOPYFLAGS			:= --change-addresses=0xc000000080000000
+dataoffset-$(CONFIG_SGI_IP27)	+= 0x01000000
 else
-load-$(CONFIG_SGI_IP27)		+= 0x8001c000
+load-$(CONFIG_SGI_IP27)		+= 0xffffffff8001c000
+OBJCOPYFLAGS			:= --change-addresses=0xa800000080000000
+endif
 endif
 endif
 
@@ -536,18 +570,13 @@
 # SGI-IP32 (O2)
 #
 # Set the load address to >= 80069000 if you want to leave space for symmon,
-# 0x80002000 for production kernels.  Note that the value must be aligned to
+# 0xffffffff80004000 for production kernels.  Note that the value must be aligned to
 # a multiple of the kernel stack size or the handling of the current variable
-# will break so for 64-bit kernels we have to raise the start address by 8kb.
+# will break.
 #
 core-$(CONFIG_SGI_IP32)		+= arch/mips/sgi-ip32/
 cflags-$(CONFIG_SGI_IP32)	+= -Iinclude/asm-mips/mach-ip32
-ifdef CONFIG_MIPS32
-load-$(CONFIG_SGI_IP32)		+= 0x80002000
-endif
-ifdef CONFIG_MIPS64
-load-$(CONFIG_SGI_IP32)		+= 0x80004000
-endif
+load-$(CONFIG_SGI_IP32)		+= 0xffffffff80004000
 
 #
 # Sibyte SB1250 SOC
@@ -557,8 +586,10 @@
 # removed (as happens, even if they have __initcall/module_init)
 #
 core-$(CONFIG_SIBYTE_BCM112X)	+= arch/mips/sibyte/sb1250/
+cflags-$(CONFIG_SIBYTE_BCM112X)	+= -Iinclude/asm-mips/mach-sibyte
 
 core-$(CONFIG_SIBYTE_SB1250)	+= arch/mips/sibyte/sb1250/
+cflags-$(CONFIG_SIBYTE_SB1250)	+= -Iinclude/asm-mips/mach-sibyte
 
 #
 # Sibyte BCM91120x (Carmel) board
@@ -568,31 +599,31 @@
 # Sibyte SWARM board
 #
 libs-$(CONFIG_SIBYTE_CARMEL)	+= arch/mips/sibyte/swarm/
-load-$(CONFIG_SIBYTE_CARMEL)	:= 0x80100000
+load-$(CONFIG_SIBYTE_CARMEL)	:= 0xffffffff80100000
 libs-$(CONFIG_SIBYTE_CRHINE)	+= arch/mips/sibyte/swarm/
-load-$(CONFIG_SIBYTE_CRHINE)	:= 0x80100000
+load-$(CONFIG_SIBYTE_CRHINE)	:= 0xffffffff80100000
 libs-$(CONFIG_SIBYTE_CRHONE)	+= arch/mips/sibyte/swarm/
-load-$(CONFIG_SIBYTE_CRHONE)	:= 0x80100000
+load-$(CONFIG_SIBYTE_CRHONE)	:= 0xffffffff80100000
 libs-$(CONFIG_SIBYTE_RHONE)	+= arch/mips/sibyte/swarm/
-load-$(CONFIG_SIBYTE_RHONE)	:= 0x80100000
+load-$(CONFIG_SIBYTE_RHONE)	:= 0xffffffff80100000
 libs-$(CONFIG_SIBYTE_SENTOSA)	+= arch/mips/sibyte/swarm/
-load-$(CONFIG_SIBYTE_SENTOSA)	:= 0x80100000
+load-$(CONFIG_SIBYTE_SENTOSA)	:= 0xffffffff80100000
 libs-$(CONFIG_SIBYTE_SWARM)	+= arch/mips/sibyte/swarm/
-load-$(CONFIG_SIBYTE_SWARM)	:= 0x80100000
+load-$(CONFIG_SIBYTE_SWARM)	:= 0xffffffff80100000
 
 #
 # SNI RM200 PCI
 #
 core-$(CONFIG_SNI_RM200_PCI)	+= arch/mips/sni/
 cflags-$(CONFIG_SNI_RM200_PCI)	+= -Iinclude/asm-mips/mach-rm200
-load-$(CONFIG_SNI_RM200_PCI)	+= 0x80600000
+load-$(CONFIG_SNI_RM200_PCI)	+= 0xffffffff80600000
 
 #
 # Toshiba JMR-TX3927 board
 #
 core-$(CONFIG_TOSHIBA_JMR3927)	+= arch/mips/jmr3927/rbhma3100/ \
 				   arch/mips/jmr3927/common/
-load-$(CONFIG_TOSHIBA_JMR3927)	+= 0x80050000
+load-$(CONFIG_TOSHIBA_JMR3927)	+= 0xffffffff80050000
 
 #
 # Toshiba RBTX4927 board or
@@ -600,21 +631,12 @@
 #
 core-$(CONFIG_TOSHIBA_RBTX4927)	+= arch/mips/tx4927/toshiba_rbtx4927/
 core-$(CONFIG_TOSHIBA_RBTX4927)	+= arch/mips/tx4927/common/
-load-$(CONFIG_TOSHIBA_RBTX4927)	+= 0x80020000
+load-$(CONFIG_TOSHIBA_RBTX4927)	+= 0xffffffff80020000
 
 cflags-y			+= -Iinclude/asm-mips/mach-generic
 drivers-$(CONFIG_PCI)		+= arch/mips/pci/
 
 ifdef CONFIG_MIPS32
-build-bfd		= $(32bit-bfd)
-cflags-y		+= $(32bit-isa-y)
-endif
-ifdef CONFIG_MIPS64
-build-bfd		= $(64bit-bfd)
-cflags-y		+= $(64bit-isa-y)
-endif
-
-ifdef CONFIG_MIPS32
 ifdef CONFIG_CPU_LITTLE_ENDIAN
 JIFFIES			= jiffies_64
 else
@@ -624,16 +646,12 @@
 JIFFIES			= jiffies_64
 endif
 
-#
-# Some machines like the Indy need 32-bit ELF binaries for booting purposes.
-# Other need ECOFF, so we build a 32-bit ELF binary for them which we then
-# convert to ECOFF using elf2ecoff.
-#
-# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit
-# ELF files from 32-bit files by conversion.
-#
-#AS += -64
-#LDFLAGS += -m elf64bmip
+AFLAGS		+= $(cflags-y)
+CFLAGS		+= $(cflags-y)
+
+LDFLAGS			+= -m $(ld-emul)
+
+OBJCOPYFLAGS		+= --remove-section=.reginfo
 
 #
 # Choosing incompatible machines durings configuration will result in
@@ -642,14 +660,10 @@
 #
 
 CPPFLAGS_vmlinux.lds := \
+	$(CFLAGS) \
 	-D"LOADADDR=$(load-y)" \
 	-D"JIFFIES=$(JIFFIES)" \
-	-imacros $(srctree)/include/asm-$(ARCH)/sn/mapped_kernel.h
-
-AFLAGS		+= $(cflags-y)
-CFLAGS		+= $(cflags-y)
-
-LDFLAGS			+= --oformat $(32bit-bfd)
+	-D"DATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)"
 
 head-y := arch/mips/kernel/head.o arch/mips/kernel/init_task.o
 
@@ -659,44 +673,44 @@
 
 core-y			+= arch/mips/kernel/ arch/mips/mm/ arch/mips/math-emu/
 
-ifdef CONFIG_BAGET_MIPS
-
-BAGETBOOT = $(MAKE) -C arch/$(ARCH)/baget
-
-balo: vmlinux
-	$(BAGETBOOT) balo
-
-endif
-
 ifdef CONFIG_LASAT
 rom.bin rom.sw: vmlinux
 	$(call descend,arch/mips/lasat/image,$@)
 endif
 
-ifdef CONFIG_MAPPED_KERNEL
-vmlinux.64: vmlinux
-	$(OBJCOPY) -O $(64bit-bfd) --remove-section=.reginfo \
-		--change-addresses=0xc000000080000000 $< $@
-else
+#
+# Some machines like the Indy need 32-bit ELF binaries for booting purposes.
+# Other need ECOFF, so we build a 32-bit ELF binary for them which we then
+# convert to ECOFF using elf2ecoff.
+#
+vmlinux.32: vmlinux
+	$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
+
+#
+# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit
+# ELF files from 32-bit files by conversion.
+#
 vmlinux.64: vmlinux
-	$(OBJCOPY) -O $(64bit-bfd) --remove-section=.reginfo \
-		--change-addresses=0xa800000080000000 $< $@
-endif
+	$(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@
 
-makeboot =$(Q)$(MAKE) $(build)=arch/mips/boot $(1)
+makeboot =$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) $(1)
 
-ifdef CONFIG_SGI_IP27
-all:	vmlinux.64
+ifdef CONFIG_BOOT_ELF32
+all:	$(vmlinux-32)
+endif
+
+ifdef CONFIG_BOOT_ELF64
+all:	$(vmlinux-64)
 endif
 
 ifdef CONFIG_SNI_RM200_PCI
 all:	vmlinux.ecoff
 endif
 
-vmlinux.ecoff vmlinux.rm200: vmlinux
+vmlinux.ecoff vmlinux.rm200: $(vmlinux-32)
 	+@$(call makeboot,$@)
 
-vmlinux.srec: vmlinux
+vmlinux.srec: $(vmlinux-32)
 	+@$(call makeboot,$@)
 
 CLEAN_FILES += vmlinux.ecoff \
@@ -706,7 +720,6 @@
 
 archclean:
 	@$(MAKE) $(clean)=arch/mips/boot
-	@$(MAKE) $(clean)=arch/mips/baget
 	@$(MAKE) $(clean)=arch/mips/lasat
 
 # Generate <asm/offset.h 
@@ -761,5 +774,6 @@
 	       include/asm-$(ARCH)/offset.h \
 	       include/asm-$(ARCH)/reg.h.tmp \
 	       include/asm-$(ARCH)/reg.h \
+	       vmlinux.32 \
 	       vmlinux.64 \
 	       vmlinux.ecoff
diff -Nru a/arch/mips/arc/identify.c b/arch/mips/arc/identify.c
--- a/arch/mips/arc/identify.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/arc/identify.c	2004-12-24 13:36:31 -08:00
@@ -45,7 +45,7 @@
 		MACH_SGI_IP28,
 		PROM_FLAG_ARCS
 	}, {	"SGI-IP32",
-		"SGI IP32",
+		"SGI O2",
 		MACH_GROUP_SGI,
 		MACH_SGI_IP32,
 		PROM_FLAG_ARCS
diff -Nru a/arch/mips/arc/misc.c b/arch/mips/arc/misc.c
--- a/arch/mips/arc/misc.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/arc/misc.c	2004-12-24 13:36:19 -08:00
@@ -104,5 +104,5 @@
 
 DISPLAY_STATUS * __init ArcGetDisplayStatus(ULONG FileID)
 {
-	return ARC_CALL1(GetDisplayStatus, FileID);
+	return (DISPLAY_STATUS *) ARC_CALL1(GetDisplayStatus, FileID);
 }
diff -Nru a/arch/mips/au1000/common/Makefile b/arch/mips/au1000/common/Makefile
--- a/arch/mips/au1000/common/Makefile	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/au1000/common/Makefile	2004-12-24 13:37:29 -08:00
@@ -7,14 +7,9 @@
 #
 
 obj-y += prom.o int-handler.o irq.o puts.o time.o reset.o \
-	au1xxx_irqmap.o clocks.o power.o setup.o sleeper.o cputable.o
+	au1xxx_irqmap.o clocks.o platform.o power.o setup.o \
+	sleeper.o cputable.o dma.o dbdma.o
 
 obj-$(CONFIG_AU1X00_USB_DEVICE)	+= usbdev.o
 obj-$(CONFIG_KGDB)		+= dbg_io.o
 obj-$(CONFIG_PCI)		+= pci.o
-
-ifdef CONFIG_SOC_AU1550
-obj-y += dbdma.o
-else
-obj-y += dma.o
-endif
diff -Nru a/arch/mips/au1000/common/au1xxx_irqmap.c b/arch/mips/au1000/common/au1xxx_irqmap.c
--- a/arch/mips/au1000/common/au1xxx_irqmap.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/au1000/common/au1xxx_irqmap.c	2004-12-24 13:36:31 -08:00
@@ -39,8 +39,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
@@ -91,10 +91,10 @@
 
 #elif defined(CONFIG_SOC_AU1500)
 
-	{ AU1000_UART0_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1500_UART0_INT, INTC_INT_HIGH_LEVEL, 0},
 	{ AU1000_PCI_INTA, INTC_INT_LOW_LEVEL, 0 },
 	{ AU1000_PCI_INTB, INTC_INT_LOW_LEVEL, 0 },
-	{ AU1000_UART3_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1500_UART3_INT, INTC_INT_HIGH_LEVEL, 0},
 	{ AU1000_PCI_INTC, INTC_INT_LOW_LEVEL, 0 },
 	{ AU1000_PCI_INTD, INTC_INT_LOW_LEVEL, 0 },
 	{ AU1000_DMA_INT_BASE, INTC_INT_HIGH_LEVEL, 0},
@@ -117,16 +117,16 @@
 	{ AU1000_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 },
 	{ AU1000_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 },
 	{ AU1000_ACSYNC_INT, INTC_INT_RISE_EDGE, 0 },
-	{ AU1000_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0},
-	{ AU1000_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1500_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1500_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0},
 	{ AU1000_AC97C_INT, INTC_INT_RISE_EDGE, 0 },
 
 #elif defined(CONFIG_SOC_AU1100)
 
-	{ AU1000_UART0_INT, INTC_INT_HIGH_LEVEL, 0},
-	{ AU1000_UART1_INT, INTC_INT_HIGH_LEVEL, 0},
-	{ 2/*AU1000_SD_INT*/, INTC_INT_HIGH_LEVEL, 0},
-	{ AU1000_UART3_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1100_UART0_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1100_UART1_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1100_SD_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1100_UART3_INT, INTC_INT_HIGH_LEVEL, 0},
 	{ AU1000_SSI0_INT, INTC_INT_HIGH_LEVEL, 0},
 	{ AU1000_SSI1_INT, INTC_INT_HIGH_LEVEL, 0},
 	{ AU1000_DMA_INT_BASE, INTC_INT_HIGH_LEVEL, 0},
@@ -151,9 +151,9 @@
 	{ AU1000_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 },
 	{ AU1000_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 },
 	{ AU1000_ACSYNC_INT, INTC_INT_RISE_EDGE, 0 },
-	{ AU1000_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1100_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0},
 	/*{ AU1000_GPIO215_208_INT, INTC_INT_HIGH_LEVEL, 0},*/
-	/*{ AU1000_LCD_INT, INTC_INT_HIGH_LEVEL, 0 },*/
+	{ AU1100_LCD_INT, INTC_INT_HIGH_LEVEL, 0},
 	{ AU1000_AC97C_INT, INTC_INT_RISE_EDGE, 0 },
 
 #elif defined(CONFIG_SOC_AU1550)
@@ -186,6 +186,32 @@
 	{ AU1550_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 },
 	{ AU1550_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0},
 	{ AU1550_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0},
+
+#elif defined(CONFIG_SOC_AU1200)
+
+	{ AU1200_UART0_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_SWT_INT, INTC_INT_RISE_EDGE, 0 },
+	{ AU1200_SD_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_DDMA_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_MAE_BE_INT, INTC_INT_HIGH_LEVEL, 0 },
+	{ AU1200_UART1_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_MAE_FE_INT, INTC_INT_HIGH_LEVEL, 0 },
+	{ AU1200_PSC0_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_PSC1_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_AES_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_CAMERA_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_TOY_INT, INTC_INT_RISE_EDGE, 0 },
+	{ AU1200_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
+	{ AU1200_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
+	{ AU1200_TOY_MATCH2_INT, INTC_INT_RISE_EDGE, 1 },
+	{ AU1200_RTC_INT, INTC_INT_RISE_EDGE, 0 },
+	{ AU1200_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
+	{ AU1200_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
+	{ AU1200_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
+	{ AU1200_NAND_INT, INTC_INT_RISE_EDGE, 0},
+	{ AU1200_USB_INT, INTC_INT_HIGH_LEVEL, 0 },
+	{ AU1200_LCD_INT, INTC_INT_HIGH_LEVEL, 0},
+	{ AU1200_MAE_BOTH_INT, INTC_INT_HIGH_LEVEL, 0},
 
 #else
 #error "Error: Unknown Alchemy SOC"
diff -Nru a/arch/mips/au1000/common/cputable.c b/arch/mips/au1000/common/cputable.c
--- a/arch/mips/au1000/common/cputable.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/au1000/common/cputable.c	2004-12-24 13:36:18 -08:00
@@ -39,6 +39,7 @@
     { 0xffffffff, 0x02030203, "Au1100 BD", 0, 1 },
     { 0xffffffff, 0x02030204, "Au1100 BE", 0, 1 },
     { 0xffffffff, 0x03030200, "Au1550 AA", 0, 1 },
+    { 0xffffffff, 0x04030200, "Au1200 AA", 0, 1 },
     { 0x00000000, 0x00000000, "Unknown Au1xxx", 1, 0 },
 };
 
diff -Nru a/arch/mips/au1000/common/dbdma.c b/arch/mips/au1000/common/dbdma.c
--- a/arch/mips/au1000/common/dbdma.c	2004-12-24 13:36:32 -08:00
+++ b/arch/mips/au1000/common/dbdma.c	2004-12-24 13:36:32 -08:00
@@ -37,10 +37,13 @@
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/delay.h>
+#include <linux/interrupt.h>
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-au1x00/au1xxx_dbdma.h>
 #include <asm/system.h>
 
+#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
+
 /*
  * The Descriptor Based DMA supports up to 16 channels.
  *
@@ -63,6 +66,7 @@
 static void au1xxx_dbdma_init(void);
 
 typedef struct dbdma_device_table {
+	u32		dev_id;
 	u32		dev_flags;
 	u32		dev_tsize;
 	u32		dev_devwidth;
@@ -89,64 +93,116 @@
 #define DEV_FLAGS_IN		(1 << 3)
 
 static dbdev_tab_t dbdev_tab[] = {
+#ifdef CONFIG_SOC_AU1550
 	/* UARTS */
-	{ DEV_FLAGS_OUT, 0, 8, 0x11100004, 0, 0 },
-	{ DEV_FLAGS_IN, 0, 8, 0x11100000, 0, 0 },
-	{ DEV_FLAGS_OUT, 0, 8, 0x11400004, 0, 0 },
-	{ DEV_FLAGS_IN, 0, 8, 0x11400000, 0, 0 },
+	{ DSCR_CMD0_UART0_TX, DEV_FLAGS_OUT, 0, 8, 0x11100004, 0, 0 },
+	{ DSCR_CMD0_UART0_RX, DEV_FLAGS_IN, 0, 8, 0x11100000, 0, 0 },
+	{ DSCR_CMD0_UART3_TX, DEV_FLAGS_OUT, 0, 8, 0x11400004, 0, 0 },
+	{ DSCR_CMD0_UART3_RX, DEV_FLAGS_IN, 0, 8, 0x11400000, 0, 0 },
 
 	/* EXT DMA */
-	{ 0, 0, 0, 0x00000000, 0, 0 },
-	{ 0, 0, 0, 0x00000000, 0, 0 },
-	{ 0, 0, 0, 0x00000000, 0, 0 },
-	{ 0, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_DMA_REQ0, 0, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_DMA_REQ1, 0, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_DMA_REQ2, 0, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_DMA_REQ3, 0, 0, 0, 0x00000000, 0, 0 },
 
 	/* USB DEV */
-	{ DEV_FLAGS_IN, 4, 8, 0x10200000, 0, 0 },
-	{ DEV_FLAGS_OUT, 4, 8, 0x10200004, 0, 0 },
-	{ DEV_FLAGS_OUT, 4, 8, 0x10200008, 0, 0 },
-	{ DEV_FLAGS_OUT, 4, 8, 0x1020000c, 0, 0 },
-	{ DEV_FLAGS_IN, 4, 8, 0x10200010, 0, 0 },
-	{ DEV_FLAGS_IN, 4, 8, 0x10200014, 0, 0 },
+	{ DSCR_CMD0_USBDEV_RX0, DEV_FLAGS_IN, 4, 8, 0x10200000, 0, 0 },
+	{ DSCR_CMD0_USBDEV_TX0, DEV_FLAGS_OUT, 4, 8, 0x10200004, 0, 0 },
+	{ DSCR_CMD0_USBDEV_TX1, DEV_FLAGS_OUT, 4, 8, 0x10200008, 0, 0 },
+	{ DSCR_CMD0_USBDEV_TX2, DEV_FLAGS_OUT, 4, 8, 0x1020000c, 0, 0 },
+	{ DSCR_CMD0_USBDEV_RX3, DEV_FLAGS_IN, 4, 8, 0x10200010, 0, 0 },
+	{ DSCR_CMD0_USBDEV_RX4, DEV_FLAGS_IN, 4, 8, 0x10200014, 0, 0 },
 
 	/* PSC 0 */
-	{ DEV_FLAGS_OUT, 0, 0, 0x11a0001c, 0, 0 },
-	{ DEV_FLAGS_IN, 0, 0, 0x11a0001c, 0, 0 },
+	{ DSCR_CMD0_PSC0_TX, DEV_FLAGS_OUT, 0, 0, 0x11a0001c, 0, 0 },
+	{ DSCR_CMD0_PSC0_RX, DEV_FLAGS_IN, 0, 0, 0x11a0001c, 0, 0 },
 
 	/* PSC 1 */
-	{ DEV_FLAGS_OUT, 0, 0, 0x11b0001c, 0, 0 },
-	{ DEV_FLAGS_IN, 0, 0, 0x11b0001c, 0, 0 },
+	{ DSCR_CMD0_PSC1_TX, DEV_FLAGS_OUT, 0, 0, 0x11b0001c, 0, 0 },
+	{ DSCR_CMD0_PSC1_RX, DEV_FLAGS_IN, 0, 0, 0x11b0001c, 0, 0 },
 
 	/* PSC 2 */
-	{ DEV_FLAGS_OUT, 0, 0, 0x10a0001c, 0, 0 },
-	{ DEV_FLAGS_IN, 0, 0, 0x10a0001c, 0, 0 },
+	{ DSCR_CMD0_PSC2_TX, DEV_FLAGS_OUT, 0, 0, 0x10a0001c, 0, 0 },
+	{ DSCR_CMD0_PSC2_RX, DEV_FLAGS_IN, 0, 0, 0x10a0001c, 0, 0 },
 
 	/* PSC 3 */
-	{ DEV_FLAGS_OUT, 0, 0, 0x10b0001c, 0, 0 },
-	{ DEV_FLAGS_IN, 0, 0, 0x10b0001c, 0, 0 },
+	{ DSCR_CMD0_PSC3_TX, DEV_FLAGS_OUT, 0, 0, 0x10b0001c, 0, 0 },
+	{ DSCR_CMD0_PSC3_RX, DEV_FLAGS_IN, 0, 0, 0x10b0001c, 0, 0 },
 
-	{ 0, 0, 0, 0x00000000, 0, 0 },	/* PCI */
-	{ 0, 0, 0, 0x00000000, 0, 0 },	/* NAND */
+	{ DSCR_CMD0_PCI_WRITE, 0, 0, 0, 0x00000000, 0, 0 },	/* PCI */
+	{ DSCR_CMD0_NAND_FLASH, 0, 0, 0, 0x00000000, 0, 0 },	/* NAND */
 
 	/* MAC 0 */
-	{ DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
-	{ DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_MAC0_RX, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_MAC0_TX, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
 
 	/* MAC 1 */
-	{ DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
-	{ DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_MAC1_RX, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_MAC1_TX, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
+
+#endif /* CONFIG_SOC_AU1550 */
+
+#ifdef CONFIG_SOC_AU1200
+	{ DSCR_CMD0_UART0_TX, DEV_FLAGS_OUT, 0, 8, 0x11100004, 0, 0 },
+	{ DSCR_CMD0_UART0_RX, DEV_FLAGS_IN, 0, 8, 0x11100000, 0, 0 },
+	{ DSCR_CMD0_UART1_TX, DEV_FLAGS_OUT, 0, 8, 0x11200004, 0, 0 },
+	{ DSCR_CMD0_UART1_RX, DEV_FLAGS_IN, 0, 8, 0x11200000, 0, 0 },
+
+	{ DSCR_CMD0_DMA_REQ0, 0, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_DMA_REQ1, 0, 0, 0, 0x00000000, 0, 0 },
+
+	{ DSCR_CMD0_MAE_BE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_MAE_FE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_MAE_BOTH, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_LCD, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
+
+	{ DSCR_CMD0_SDMS_TX0, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_SDMS_RX0, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_SDMS_TX1, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_SDMS_RX1, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
+
+	{ DSCR_CMD0_AES_TX, DEV_FLAGS_OUT, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_AES_RX, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
+
+	{ DSCR_CMD0_PSC0_TX, DEV_FLAGS_OUT, 0, 0, 0x11a0001c, 0, 0 },
+	{ DSCR_CMD0_PSC0_RX, DEV_FLAGS_IN, 0, 0, 0x11a0001c, 0, 0 },
+	{ DSCR_CMD0_PSC0_SYNC, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
+
+	{ DSCR_CMD0_PSC1_TX, DEV_FLAGS_OUT, 0, 0, 0x11b0001c, 0, 0 },
+	{ DSCR_CMD0_PSC1_RX, DEV_FLAGS_IN, 0, 0, 0x11b0001c, 0, 0 },
+	{ DSCR_CMD0_PSC1_SYNC, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
+
+	{ DSCR_CMD0_CIM_RXA, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_CIM_RXB, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_CIM_RXC, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_CIM_SYNC, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
+
+	{ DSCR_CMD0_NAND_FLASH, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
 
-	/* reserved */
-	{ DEV_FLAGS_INUSE, 0, 0, 0x00000000, 0, 0 },
-	{ DEV_FLAGS_INUSE, 0, 0, 0x00000000, 0, 0 },
-
-	/* Memory */
-	{ DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },	/* throttle */
-	{ DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },	/* always */
+#endif // CONFIG_SOC_AU1200
+
+	{ DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
+	{ DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
 };
 
+#define DBDEV_TAB_SIZE (sizeof(dbdev_tab) / sizeof(dbdev_tab_t))
+
 static chan_tab_t *chan_tab_ptr[NUM_DBDMA_CHANS];
 
+static dbdev_tab_t *
+find_dbdev_id (u32 id)
+{
+	int i;
+	dbdev_tab_t *p;
+	for (i = 0; i < DBDEV_TAB_SIZE; ++i) {
+		p = &dbdev_tab[i];
+		if (p->dev_id == id)
+			return p;
+	}
+	return NULL;
+}
+
 /* Allocate a channel and return a non-zero descriptor if successful.
 */
 u32
@@ -172,8 +228,9 @@
 	if ((srcid > DSCR_NDEV_IDS) || (destid > DSCR_NDEV_IDS))
 		return 0;
 
-	stp = &dbdev_tab[srcid];
-	dtp = &dbdev_tab[destid];
+	if ((stp = find_dbdev_id(srcid)) == NULL) return 0;
+	if ((dtp = find_dbdev_id(destid)) == NULL) return 0;
+
 	used = 0;
 	rv = 0;
 
@@ -212,7 +269,7 @@
 				/* If kmalloc fails, it is caught below same
 				 * as a channel not available.
 				 */
-				ctp = (chan_tab_t *)kmalloc(sizeof(chan_tab_t), GFP_KERNEL);
+				ctp = kmalloc(sizeof(chan_tab_t), GFP_KERNEL);
 				chan_tab_ptr[i] = ctp;
 				ctp->chan_index = chan = i;
 				break;
@@ -313,7 +370,7 @@
 	 * and if we try that first we are likely to not waste larger
 	 * slabs of memory.
 	 */
-	desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t), GFP_KERNEL);
+	desc_base = kmalloc(entries * sizeof(au1x_ddma_desc_t), GFP_KERNEL);
 	if (desc_base == 0)
 		return 0;
 
@@ -324,7 +381,7 @@
 		kfree((const void *)desc_base);
 		i = entries * sizeof(au1x_ddma_desc_t);
 		i += (sizeof(au1x_ddma_desc_t) - 1);
-		if ((desc_base = (u32)kmalloc(i, GFP_KERNEL)) == 0)
+		if ((desc_base = kmalloc(i, GFP_KERNEL)) == 0)
 			return 0;
 
 		desc_base = ALIGN_ADDR(desc_base, sizeof(au1x_ddma_desc_t));
@@ -337,8 +394,8 @@
 
 	/* Initialize the rings with as much information as we know.
 	 */
-	srcid = stp - dbdev_tab;	/* Index is channel device ID */
-	destid = dtp - dbdev_tab;
+	srcid = stp->dev_id;
+	destid = dtp->dev_id;
 
 	cmd0 = cmd1 = src1 = dest1 = 0;
 	src0 = dest0 = 0;
@@ -691,7 +748,7 @@
 	kfree(ctp);
 }
 
-static void
+static irqreturn_t
 dbdma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	u32	intstat;
@@ -718,6 +775,7 @@
 
 	ctp->cur_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
 
+	return IRQ_HANDLED;
 }
 
 static void
@@ -773,3 +831,6 @@
 		dp = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
 	} while (dp != ctp->chan_desc_base);
 }
+
+#endif /* defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) */
+
diff -Nru a/arch/mips/au1000/common/dma.c b/arch/mips/au1000/common/dma.c
--- a/arch/mips/au1000/common/dma.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/au1000/common/dma.c	2004-12-24 13:37:19 -08:00
@@ -30,6 +30,7 @@
  *
  */
 
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
@@ -37,6 +38,7 @@
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/module.h>
 #include <asm/system.h>
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-au1x00/au1000_dma.h>
@@ -71,6 +73,7 @@
       {.dev_id = -1,},
       {.dev_id = -1,}
 };
+EXPORT_SYMBOL(au1000_dma_table);
 
 // Device FIFO addresses and default DMA modes
 static const struct dma_dev {
@@ -216,6 +219,7 @@
 
 	return i;
 }
+EXPORT_SYMBOL(request_au1000_dma);
 
 void free_au1000_dma(unsigned int dmanr)
 {
@@ -233,4 +237,6 @@
 	chan->irq_dev = NULL;
 	chan->dev_id = -1;
 }
+EXPORT_SYMBOL(free_au1000_dma);
+
 #endif // AU1000 AU1500 AU1100
diff -Nru a/arch/mips/au1000/common/irq.c b/arch/mips/au1000/common/irq.c
--- a/arch/mips/au1000/common/irq.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/au1000/common/irq.c	2004-12-24 13:36:47 -08:00
@@ -41,8 +41,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
@@ -66,10 +66,6 @@
 #define EXT_INTC1_REQ1 5 /* IP 5 */
 #define MIPS_TIMER_IP  7 /* IP 7 */
 
-#ifdef CONFIG_KGDB
-extern void breakpoint(void);
-#endif
-
 extern asmlinkage void au1000_IRQ(void);
 extern void set_debug_traps(void);
 extern irq_cpustat_t irq_stat [NR_CPUS];
@@ -84,7 +80,6 @@
 inline void local_enable_irq(unsigned int irq_nr);
 inline void local_disable_irq(unsigned int irq_nr);
 
-extern void __init init_generic_irq(void);
 void	(*board_init_irq)(void);
 
 #ifdef CONFIG_PM
@@ -420,7 +415,7 @@
 }
 
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	int i;
 	unsigned long cp0_status;
@@ -434,8 +429,6 @@
 	memset(irq_desc, 0, sizeof(irq_desc));
 	set_except_vector(0, au1000_IRQ);
 
-	init_generic_irq();
-
 	/* Initialize interrupt controllers to a safe state.
 	*/
 	au_writel(0xffffffff, IC0_CFG0CLR);
@@ -482,13 +475,6 @@
 	*/
 	if (board_init_irq)
 		(*board_init_irq)();
-
-#ifdef CONFIG_KGDB
-	/* If local serial I/O used for debug port, enter kgdb at once */
-	puts("Waiting for kgdb to connect...");
-	set_debug_traps();
-	breakpoint();
-#endif
 }
 
 
diff -Nru a/arch/mips/au1000/common/pci.c b/arch/mips/au1000/common/pci.c
--- a/arch/mips/au1000/common/pci.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/au1000/common/pci.c	2004-12-24 13:37:18 -08:00
@@ -6,6 +6,8 @@
  * Author: MontaVista Software, Inc.
  *         	ppopov@mvista.com or source@mvista.com
  *
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
+ *
  *  Support for all devices (greater than 16) added by David Gathright.
  *
  *  This program is free software; you can redistribute  it and/or modify it
@@ -35,7 +37,6 @@
 #include <linux/init.h>
 
 #include <asm/mach-au1x00/au1000.h>
-#include <asm/pci_channel.h>
 
 /* TBD */
 static struct resource pci_io_resource = {
@@ -67,15 +68,12 @@
 static int __init au1x_pci_setup(void)
 {
 #if defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550)
-	int i;
-	struct pci_dev *dev;
-	
 	virt_io_addr = (unsigned long)ioremap(Au1500_PCI_IO_START, 
 			Au1500_PCI_IO_END - Au1500_PCI_IO_START + 1);
 
 	if (!virt_io_addr) {
 		printk(KERN_ERR "Unable to ioremap pci space\n");
-		return;
+		return 1;
 	}
 
 #ifdef CONFIG_DMA_NONCOHERENT
diff -Nru a/arch/mips/au1000/common/platform.c b/arch/mips/au1000/common/platform.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/au1000/common/platform.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,54 @@
+/*
+ * Platform device support for Au1x00 SoCs.
+ *
+ * Copyright 2004, Matt Porter <mporter@kernel.crashing.org>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#include <linux/config.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/resource.h>
+
+#include <asm/mach-au1x00/au1000.h>
+
+static struct resource au1xxx_usb_ohci_resources[] = {
+	[0] = {
+		.start		= USB_OHCI_BASE,
+		.end		= USB_OHCI_BASE + USB_OHCI_LEN,
+		.flags		= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start		= AU1000_USB_HOST_INT,
+		.end		= AU1000_USB_HOST_INT,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+/* The dmamask must be set for OHCI to work */
+static u64 ohci_dmamask = ~(u32)0;
+
+static struct platform_device au1xxx_usb_ohci_device = {
+	.name		= "au1xxx-ohci",
+	.id		= 0,
+	.dev = {
+		.dma_mask		= &ohci_dmamask,
+		.coherent_dma_mask	= 0xffffffff,
+	},
+	.num_resources	= ARRAY_SIZE(au1xxx_usb_ohci_resources),
+	.resource	= au1xxx_usb_ohci_resources,
+};
+
+static struct platform_device *au1xxx_platform_devices[] __initdata = {
+	&au1xxx_usb_ohci_device,
+};
+
+int au1xxx_platform_init(void)
+{
+	return platform_add_devices(au1xxx_platform_devices, ARRAY_SIZE(au1xxx_platform_devices));
+}
+
+arch_initcall(au1xxx_platform_init);
diff -Nru a/arch/mips/au1000/common/puts.c b/arch/mips/au1000/common/puts.c
--- a/arch/mips/au1000/common/puts.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/au1000/common/puts.c	2004-12-24 13:37:18 -08:00
@@ -92,7 +92,7 @@
 }
 
 void
-fputs(unsigned char *cp)
+fputs(const char *cp)
 {
     unsigned char ch;
     int i = 0;
diff -Nru a/arch/mips/au1000/common/reset.c b/arch/mips/au1000/common/reset.c
--- a/arch/mips/au1000/common/reset.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/au1000/common/reset.c	2004-12-24 13:36:18 -08:00
@@ -43,6 +43,7 @@
 void au1000_restart(char *command)
 {
 	/* Set all integrated peripherals to disabled states */
+	extern void board_reset (void);
 	u32 prid = read_c0_prid();
 
 	printk(KERN_NOTICE "\n** Resetting Integrated Peripherals\n");
@@ -154,18 +155,10 @@
 	flush_cache_all();
 	write_c0_wired(0);
 
-#if defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_DB1500)
-	/* Do a HW reset if the board can do it */
-
-	au_writel(0x00000000, 0xAE00001C);
-#endif
-
-#if defined(CONFIG_MIPS_PB1550)
-	 /* reset entire system */
-	au_writew(au_readw(0xAF00001C) & ~(1<<15), 0xAF00001C);
-	au_sync();
-#endif
+	/* Give board a chance to do a hardware reset */
+	board_reset();
 
+	/* Jump to the beggining in case board_reset() is empty */
 	__asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
 }
 
diff -Nru a/arch/mips/au1000/common/setup.c b/arch/mips/au1000/common/setup.c
--- a/arch/mips/au1000/common/setup.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/au1000/common/setup.c	2004-12-24 13:37:19 -08:00
@@ -3,6 +3,8 @@
  * Author: MontaVista Software, Inc.
  *         	ppopov@mvista.com or source@mvista.com
  *
+ * Updates to 2.6, Pete Popov, Embedded Alley Solutions, 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
@@ -40,11 +42,6 @@
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/time.h>
 
-#ifdef CONFIG_BLK_DEV_INITRD
-extern unsigned long initrd_start, initrd_end;
-extern void * __rd_start, * __rd_end;
-#endif
-
 extern char * __init prom_getcmdline(void);
 extern void __init board_setup(void);
 extern void au1000_restart(char *);
@@ -56,12 +53,9 @@
 extern void au1x_time_init(void);
 extern void (*board_timer_setup)(struct irqaction *irq);
 extern void au1x_timer_setup(struct irqaction *irq);
-#if defined(CONFIG_64BIT_PHYS_ADDR) && (defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550))
-extern phys_t (*fixup_bigphys_addr)(phys_t phys_addr, phys_t size);
-static phys_t au1500_fixup_bigphys_addr(phys_t phys_addr, phys_t size);
-#endif
 extern void au1xxx_time_init(void);
 extern void au1xxx_timer_setup(struct irqaction *irq);
+extern void set_cpuspec(void);
 
 static int __init au1x00_setup(void)
 {
@@ -76,7 +70,7 @@
 
 	prid = read_c0_prid();
 	cpupll = (au_readl(0xB1900060) & 0x3F) * 12;
-	printk("(PRId %08X) @ %dMHZ\n", prid, cpupll);
+	printk("(PRId %08lx) @ %ldMHZ\n", prid, cpupll);
 
 	bclk = sp->cpu_bclk;
 	if (bclk)
@@ -146,9 +140,6 @@
 	_machine_power_off = au1000_power_off;
 	board_time_init = au1xxx_time_init;
 	board_timer_setup = au1xxx_timer_setup;
-#if defined(CONFIG_64BIT_PHYS_ADDR) && (defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550))
-	fixup_bigphys_addr = au1500_fixup_bigphys_addr;
-#endif
 
 	/* IO/MEM resources. */
 	set_io_port_base(0);
@@ -157,62 +148,48 @@
 	iomem_resource.start = IOMEM_RESOURCE_START;
 	iomem_resource.end = IOMEM_RESOURCE_END;
 
-#ifdef CONFIG_BLK_DEV_INITRD
-	ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
-	initrd_start = (unsigned long)&__rd_start;
-	initrd_end = (unsigned long)&__rd_end;
-#endif
-
-#if defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE)
-#ifdef CONFIG_USB_OHCI
-	if ((argptr = strstr(argptr, "usb_ohci=")) == NULL) {
-	        char usb_args[80];
-		argptr = prom_getcmdline();
-		memset(usb_args, 0, sizeof(usb_args));
-		sprintf(usb_args, " usb_ohci=base:0x%x,len:0x%x,irq:%d",
-			USB_OHCI_BASE, USB_OHCI_LEN, AU1000_USB_HOST_INT);
-		strcat(argptr, usb_args);
-	}
-#endif
-
-#ifdef CONFIG_USB_OHCI
-	/* enable host controller and wait for reset done */
-	au_writel(0x08, USB_HOST_CONFIG);
-	udelay(1000);
-	au_writel(0x0E, USB_HOST_CONFIG);
-	udelay(1000);
-	au_readl(USB_HOST_CONFIG); /* throw away first read */
-	while (!(au_readl(USB_HOST_CONFIG) & 0x10))
-		au_readl(USB_HOST_CONFIG);
-#endif
-#endif /* defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) */
-
 	while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_E0S);
 	au_writel(SYS_CNTRL_E0 | SYS_CNTRL_EN0, SYS_COUNTER_CNTRL);
 	au_sync();
 	while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S);
 	au_writel(0, SYS_TOYTRIM);
+
 	return 0;
 }
 
 early_initcall(au1x00_setup);
 
-#if defined(CONFIG_64BIT_PHYS_ADDR) && (defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550))
-/* This routine should be valid for all Au1500 based boards */
-static phys_t au1500_fixup_bigphys_addr(phys_t phys_addr, phys_t size)
+#if defined(CONFIG_64BIT_PHYS_ADDR)
+/* This routine should be valid for all Au1x based boards */
+phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
 {
-	u32 pci_start = (u32)Au1500_PCI_MEM_START;
-	u32 pci_end = (u32)Au1500_PCI_MEM_END;
+	u32 start, end;
 
 	/* Don't fixup 36 bit addresses */
 	if ((phys_addr >> 32) != 0) return phys_addr;
 
+#ifdef CONFIG_PCI
+	start = (u32)Au1500_PCI_MEM_START;
+	end = (u32)Au1500_PCI_MEM_END;
 	/* check for pci memory window */
-	if ((phys_addr >= pci_start) && ((phys_addr + size) < pci_end)) {
-		return (phys_t)((phys_addr - pci_start) +
-				     Au1500_PCI_MEM_START);
+	if ((phys_addr >= start) && ((phys_addr + size) < end)) {
+		return (phys_t)((phys_addr - start) + Au1500_PCI_MEM_START);
 	}
-	else 
-		return phys_addr;
+#endif
+
+	/* All Au1x SOCs have a pcmcia controller */
+	/* We setup our 32 bit pseudo addresses to be equal to the
+	 * 36 bit addr >> 4, to make it easier to check the address
+	 * and fix it.
+	 * The Au1x socket 0 phys attribute address is 0xF 4000 0000.
+	 * The pseudo address we use is 0xF400 0000. Any address over
+	 * 0xF400 0000 is a pcmcia pseudo address.
+	 */
+	if ((phys_addr >= 0xF4000000) && (phys_addr < 0xFFFFFFFF)) {
+		return (phys_t)(phys_addr << 4);
+	}
+
+	/* default nop */
+	return phys_addr;
 }
 #endif
diff -Nru a/arch/mips/au1000/common/time.c b/arch/mips/au1000/common/time.c
--- a/arch/mips/au1000/common/time.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/au1000/common/time.c	2004-12-24 13:36:47 -08:00
@@ -40,6 +40,7 @@
 #include <linux/spinlock.h>
 #include <linux/hardirq.h>
 
+#include <asm/compiler.h>
 #include <asm/mipsregs.h>
 #include <asm/ptrace.h>
 #include <asm/time.h>
@@ -99,6 +100,9 @@
 
 		kstat_this_cpu.irqs[irq]++;
 		do_timer(regs);
+#ifndef CONFIG_SMP
+		update_process_times(user_mode(regs));
+#endif
 		r4k_cur += r4k_offset;
 		ack_r4ktimer(r4k_cur);
 
@@ -137,6 +141,9 @@
 
 	while (time_elapsed > 0) {
 		do_timer(regs);
+#ifndef CONFIG_SMP
+		update_process_times(user_mode(regs));
+#endif
 		time_elapsed -= MATCH20_INC;
 		last_match20 += MATCH20_INC;
 		jiffie_drift++;
@@ -153,6 +160,9 @@
 	if (jiffie_drift >= 999) {
 		jiffie_drift -= 999;
 		do_timer(regs); /* increment jiffies by one */
+#ifndef CONFIG_SMP
+		update_process_times(user_mode(regs));
+#endif
 	}
 }
 
@@ -342,9 +352,9 @@
 
 	__asm__("multu\t%1,%2\n\t"
 		"mfhi\t%0"
-		:"=r" (res)
-		:"r" (count),
-		 "r" (quotient));
+		: "=r" (res)
+		: "r" (count), "r" (quotient)
+		: "hi", "lo", GCC_REG_ACCUM);
 
 	/*
  	 * Due to possible jiffies inconsistencies, we need to check 
diff -Nru a/arch/mips/au1000/common/usbdev.c b/arch/mips/au1000/common/usbdev.c
--- a/arch/mips/au1000/common/usbdev.c	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/au1000/common/usbdev.c	2004-12-24 13:37:43 -08:00
@@ -61,8 +61,6 @@
 #define vdbg(fmt, arg...) do {} while (0)
 #endif
 
-#define MAX(a,b)	(((a)>(b))?(a):(b))
-
 #define ALLOC_FLAGS (in_interrupt () ? GFP_ATOMIC : GFP_KERNEL)
 
 #define EP_FIFO_DEPTH 8
@@ -211,9 +209,8 @@
 static inline usbdev_pkt_t *
 alloc_packet(endpoint_t * ep, int data_size, void* data)
 {
-	usbdev_pkt_t* pkt =
-		(usbdev_pkt_t *)kmalloc(sizeof(usbdev_pkt_t) + data_size,
-					ALLOC_FLAGS);
+	usbdev_pkt_t* pkt = kmalloc(sizeof(usbdev_pkt_t) + data_size,
+				    ALLOC_FLAGS);
 	if (!pkt)
 		return NULL;
 	pkt->ep_addr = ep->address;
diff -Nru a/arch/mips/au1000/csb250/irqmap.c b/arch/mips/au1000/csb250/irqmap.c
--- a/arch/mips/au1000/csb250/irqmap.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/au1000/csb250/irqmap.c	2004-12-24 13:36:17 -08:00
@@ -39,8 +39,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
diff -Nru a/arch/mips/au1000/db1x00/board_setup.c b/arch/mips/au1000/db1x00/board_setup.c
--- a/arch/mips/au1000/db1x00/board_setup.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/au1000/db1x00/board_setup.c	2004-12-24 13:36:17 -08:00
@@ -48,6 +48,12 @@
 /* not correct for db1550 */
 static BCSR * const bcsr = (BCSR *)0xAE000000;
 
+void board_reset (void)
+{
+	/* Hit BCSR.SYSTEM_CONTROL[SW_RST] */
+	au_writel(0x00000000, 0xAE00001C);
+}
+
 void __init board_setup(void)
 {
 	u32 pin_func;
diff -Nru a/arch/mips/au1000/db1x00/irqmap.c b/arch/mips/au1000/db1x00/irqmap.c
--- a/arch/mips/au1000/db1x00/irqmap.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/au1000/db1x00/irqmap.c	2004-12-24 13:36:31 -08:00
@@ -40,8 +40,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
diff -Nru a/arch/mips/au1000/db1x00/mirage_ts.c b/arch/mips/au1000/db1x00/mirage_ts.c
--- a/arch/mips/au1000/db1x00/mirage_ts.c	2004-12-24 13:37:01 -08:00
+++ b/arch/mips/au1000/db1x00/mirage_ts.c	2004-12-24 13:37:01 -08:00
@@ -68,7 +68,7 @@
 #define err(format, arg...) printk(KERN_ERR TS_NAME ": " format "\n" , ## arg)
 #define info(format, arg...) printk(KERN_INFO TS_NAME ": " format "\n" , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING TS_NAME ": " format "\n" , ## arg)
-#define DPRINTK(format, arg...) printk(__FUNCTION__ ": " format "\n" , ## arg)
+#define DPRINTK(format, arg...) printk("%s: " format "\n", __FUNCTION__ , ## arg)
 
 
 #define PEN_DOWN_IRQ	AU1000_GPIO_7
diff -Nru a/arch/mips/au1000/hydrogen3/board_setup.c b/arch/mips/au1000/hydrogen3/board_setup.c
--- a/arch/mips/au1000/hydrogen3/board_setup.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/au1000/hydrogen3/board_setup.c	2004-12-24 13:36:48 -08:00
@@ -47,6 +47,10 @@
 
 extern struct rtc_ops no_rtc_ops;
 
+void board_reset (void)
+{
+}
+
 void __init board_setup(void)
 {
 	u32 pin_func;
diff -Nru a/arch/mips/au1000/hydrogen3/irqmap.c b/arch/mips/au1000/hydrogen3/irqmap.c
--- a/arch/mips/au1000/hydrogen3/irqmap.c	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/au1000/hydrogen3/irqmap.c	2004-12-24 13:37:43 -08:00
@@ -39,8 +39,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
diff -Nru a/arch/mips/au1000/mtx-1/irqmap.c b/arch/mips/au1000/mtx-1/irqmap.c
--- a/arch/mips/au1000/mtx-1/irqmap.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/au1000/mtx-1/irqmap.c	2004-12-24 13:36:18 -08:00
@@ -39,8 +39,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
diff -Nru a/arch/mips/au1000/pb1000/board_setup.c b/arch/mips/au1000/pb1000/board_setup.c
--- a/arch/mips/au1000/pb1000/board_setup.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/au1000/pb1000/board_setup.c	2004-12-24 13:36:19 -08:00
@@ -48,6 +48,10 @@
     !!! I shall not define symbols starting with CONFIG_ !!!
 #endif
 
+void board_reset (void)
+{
+}
+
 void __init board_setup(void)
 {
 	u32 pin_func, static_cfg0;
diff -Nru a/arch/mips/au1000/pb1000/irqmap.c b/arch/mips/au1000/pb1000/irqmap.c
--- a/arch/mips/au1000/pb1000/irqmap.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/au1000/pb1000/irqmap.c	2004-12-24 13:37:18 -08:00
@@ -39,8 +39,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
diff -Nru a/arch/mips/au1000/pb1100/board_setup.c b/arch/mips/au1000/pb1100/board_setup.c
--- a/arch/mips/au1000/pb1100/board_setup.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/au1000/pb1100/board_setup.c	2004-12-24 13:37:18 -08:00
@@ -37,8 +37,8 @@
 #include <asm/mipsregs.h>
 #include <asm/reboot.h>
 #include <asm/pgtable.h>
-#include <asm/au1000.h>
-#include <asm/pb1100.h>
+#include <asm/mach-au1x00/au1000.h>
+#include <asm/mach-pb1x00/pb1100.h>
 
 #ifdef CONFIG_USB_OHCI
 // Enable the workaround for the OHCI DoneHead
@@ -47,6 +47,12 @@
         ^^^^^^^^^^^^^^^^^^^^^^
     !!! I shall not define symbols starting with CONFIG_ !!!
 #endif
+
+void board_reset (void)
+{
+    /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */
+    au_writel(0x00000000, 0xAE00001C);
+}
 
 void __init board_setup(void)
 {
diff -Nru a/arch/mips/au1000/pb1100/irqmap.c b/arch/mips/au1000/pb1100/irqmap.c
--- a/arch/mips/au1000/pb1100/irqmap.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/au1000/pb1100/irqmap.c	2004-12-24 13:37:00 -08:00
@@ -39,13 +39,13 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.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>
+#include <asm/mach-au1x00/au1000.h>
 
 au1xxx_irq_map_t au1xxx_irq_map[] = {
 	{ AU1000_GPIO_9, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card Fully_Interted#
diff -Nru a/arch/mips/au1000/pb1500/board_setup.c b/arch/mips/au1000/pb1500/board_setup.c
--- a/arch/mips/au1000/pb1500/board_setup.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/au1000/pb1500/board_setup.c	2004-12-24 13:36:18 -08:00
@@ -48,6 +48,12 @@
     !!! I shall not define symbols starting with CONFIG_ !!!
 #endif
 
+void board_reset (void)
+{
+    /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */
+    au_writel(0x00000000, 0xAE00001C);
+}
+
 void __init board_setup(void)
 {
 	u32 pin_func;
diff -Nru a/arch/mips/au1000/pb1500/irqmap.c b/arch/mips/au1000/pb1500/irqmap.c
--- a/arch/mips/au1000/pb1500/irqmap.c	2004-12-24 13:37:33 -08:00
+++ b/arch/mips/au1000/pb1500/irqmap.c	2004-12-24 13:37:33 -08:00
@@ -39,8 +39,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
diff -Nru a/arch/mips/au1000/pb1550/board_setup.c b/arch/mips/au1000/pb1550/board_setup.c
--- a/arch/mips/au1000/pb1550/board_setup.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/au1000/pb1550/board_setup.c	2004-12-24 13:37:18 -08:00
@@ -45,6 +45,12 @@
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-pb1x00/pb1550.h>
 
+void board_reset (void)
+{
+    /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */
+	au_writew(au_readw(0xAF00001C) & ~(1<<15), 0xAF00001C);
+}
+
 void __init board_setup(void)
 {
 	u32 pin_func;
diff -Nru a/arch/mips/au1000/pb1550/irqmap.c b/arch/mips/au1000/pb1550/irqmap.c
--- a/arch/mips/au1000/pb1550/irqmap.c	2004-12-24 13:37:31 -08:00
+++ b/arch/mips/au1000/pb1550/irqmap.c	2004-12-24 13:37:31 -08:00
@@ -39,8 +39,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
diff -Nru a/arch/mips/au1000/xxs1500/board_setup.c b/arch/mips/au1000/xxs1500/board_setup.c
--- a/arch/mips/au1000/xxs1500/board_setup.c	2004-12-24 13:37:30 -08:00
+++ b/arch/mips/au1000/xxs1500/board_setup.c	2004-12-24 13:37:30 -08:00
@@ -40,6 +40,12 @@
 #include <asm/pgtable.h>
 #include <asm/au1000.h>
 
+void board_reset (void)
+{
+	/* Hit BCSR.SYSTEM_CONTROL[SW_RST] */
+	au_writel(0x00000000, 0xAE00001C);
+}
+
 void __init board_setup(void)
 {
 	u32 pin_func;
diff -Nru a/arch/mips/au1000/xxs1500/irqmap.c b/arch/mips/au1000/xxs1500/irqmap.c
--- a/arch/mips/au1000/xxs1500/irqmap.c	2004-12-24 13:36:56 -08:00
+++ b/arch/mips/au1000/xxs1500/irqmap.c	2004-12-24 13:36:56 -08:00
@@ -39,8 +39,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
diff -Nru a/arch/mips/baget/Makefile b/arch/mips/baget/Makefile
--- a/arch/mips/baget/Makefile	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,53 +0,0 @@
-#
-# Makefile for the Baget specific kernel interface routines
-# under Linux.
-#
-
-obj-y			:= baget.o print.o setup.o time.o irq.o bagetIRQ.o \
-			   reset.o
-obj-$(CONFIG_VAC_RTC)	+= vacrtc.o
-
-EXTRA_AFLAGS := $(CFLAGS)
-
-bagetIRQ.o : bagetIRQ.S
-	$(CC) $(CFLAGS) -c -o $@ $<
-
-##################### Baget Loader stuff ########################
-
-image: ../../../vmlinux
-	cp -f $< $@
-
-image.bin: image
-	$(OBJCOPY) -O binary $< $@
-
-ramdisk.bin:
-	echo "Dummy ramdisk used. Provide your own if needed !" > $@
-
-dummy.c:
-	touch $@
-
-dummy.o: dummy.c image.bin ramdisk.bin
-	$(CC) $(CFLAGS) -c -o $@ $<
-	$(OBJCOPY) --add-section=.vmlinux=image.bin \
-                   --add-section=.ramdisk=ramdisk.bin   $@
-
-balo.h: image
-	$(NM) $< | awk ' \
-	BEGIN               { printf "/* DO NOT EDIT THIS FILE */\n" }    \
-	/_ftext/            { printf "#define LOADADDR 0x%s\n", $$1     } \
-	/kernel_entry/      { printf "#define START 0x%s\n", $$1 }        \
-	/balo_ramdisk_base/ { printf "#define RAMDISK_BASE 0x%s\n", $$1 } \
-	/balo_ramdisk_size/ { printf "#define RAMDISK_SIZE 0x%s\n", $$1 } \
-                       ' > $@
-balo.o:   balo.c balo.h
-	$(CC) $(CFLAGS) -c $<
-
-balo_supp.o: balo_supp.S
-	$(CC) $(CFLAGS) -c $<
-
-balo:   balo.o dummy.o balo_supp.o print.o
-	$(LD) $(LDFLAGS) -T ld.script.balo -o $@ $^
-
-clean:
-	rm -f balo balo.h dummy.c image image.bin
-
diff -Nru a/arch/mips/baget/baget.c b/arch/mips/baget/baget.c
--- a/arch/mips/baget/baget.c	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,96 +0,0 @@
-/*
- * baget.c: Baget low level stuff
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- *
- */
-#include <stdarg.h>
-
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <asm/system.h>
-#include <asm/bootinfo.h>
-#include <asm/mipsregs.h>
-#include <asm/pgtable.h>
-
-#include <asm/baget/baget.h>
-
-/*
- *  Following code is based on routines from 'mm/vmalloc.c'
- *  Additional parameters  ioaddr  is needed to iterate across real I/O address.
- */
-static inline int alloc_area_pte(pte_t * pte, unsigned long address,
-				 unsigned long size, unsigned long ioaddr)
-{
-        unsigned long end;
-
-        address &= ~PMD_MASK;
-        end = address + size;
-        if (end > PMD_SIZE)
-                end = PMD_SIZE;
-        while (address < end) {
-                unsigned long page;
-                if (!pte_none(*pte))
-                        printk("kseg2_alloc_io: page already exists\n");
-		/*
-		 *  For MIPS looks pretty to have transparent mapping
-		 *  for KSEG2 areas  -- user can't access one, and no
-		 *  problems with  virtual <--> physical  translation.
-		 */
-                page = ioaddr & PAGE_MASK;
-
-                set_pte(pte, __pte(page | pgprot_val(PAGE_USERIO) |
-				  _PAGE_GLOBAL | __READABLE | __WRITEABLE));
-                address += PAGE_SIZE;
-		ioaddr  += PAGE_SIZE;
-                pte++;
-        }
-        return 0;
-}
-
-static inline int alloc_area_pmd(pmd_t * pmd, unsigned long address,
-				 unsigned long size, unsigned long ioaddr)
-{
-        unsigned long end;
-
-        address &= ~PGDIR_MASK;
-        end = address + size;
-        if (end > PGDIR_SIZE)
-                end = PGDIR_SIZE;
-        while (address < end) {
-                pte_t * pte = pte_alloc_kernel(pmd, address);
-                if (!pte)
-                        return -ENOMEM;
-                if (alloc_area_pte(pte, address, end - address, ioaddr))
-                        return -ENOMEM;
-                address = (address + PMD_SIZE) & PMD_MASK;
-		ioaddr  += PMD_SIZE;
-                pmd++;
-        }
-        return 0;
-}
-
-int kseg2_alloc_io (unsigned long address, unsigned long size)
-{
-        pgd_t * dir;
-        unsigned long end = address + size;
-
-        dir = pgd_offset_k(address);
-        flush_cache_all();
-        while (address < end) {
-                pmd_t *pmd;
-                pgd_t olddir = *dir;
-
-                pmd = pmd_alloc_kernel(dir, address);
-                if (!pmd)
-                        return -ENOMEM;
-                if (alloc_area_pmd(pmd, address, end - address, address))
-                        return -ENOMEM;
-                if (pgd_val(olddir) != pgd_val(*dir))
-                        set_pgdir(address, *dir);
-                address = (address + PGDIR_SIZE) & PGDIR_MASK;
-                dir++;
-        }
-        flush_tlb_all();
-        return 0;
-}
diff -Nru a/arch/mips/baget/bagetIRQ.S b/arch/mips/baget/bagetIRQ.S
--- a/arch/mips/baget/bagetIRQ.S	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,96 +0,0 @@
-/*
- * bagetIRQ.S: Interrupt exception dispatch code for Baget/MIPS
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#include <asm/asm.h>
-#include <asm/mipsregs.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-#include <asm/addrspace.h>
-
-	.text
-	.set    mips1
-	.set    reorder
-	.set    macro
-	.set    noat
-	.align	5
-
-NESTED(bagetIRQ, PT_SIZE, sp)
-	SAVE_ALL
-	CLI				# Important: mark KERNEL mode !
-
-	la      a1, baget_interrupt
-	.set	push
-	.set    noreorder
-	jal	a1
-	.set    pop
-	move	a0, sp
-
-	la      a1, ret_from_irq
-	jr	a1
-END(bagetIRQ)
-
-#define DBE_HANDLER       0x1C
-
-NESTED(try_read, PT_SIZE, sp)
-	mfc0	t3, CP0_STATUS		# save flags and
-	CLI				#  disable interrupts
-
-	li	t0, KSEG2
-	sltu    t1, t0, a0              # Is it KSEG2 address ?
-	beqz	t1, mapped              # No - already mapped !
-
-	move    t0, a0
-	ori	t0, 0xfff
-	xori    t0, 0xfff               # round address to page
-
-	ori     t1, t0, 0xf00           # prepare EntryLo (N,V,D,G)
-
-	mfc0    t2,   CP0_ENTRYHI       # save ASID value
-	mtc0	zero, CP0_INDEX
-	mtc0	t0,   CP0_ENTRYHI       # Load MMU values ...
-	mtc0    t1,   CP0_ENTRYLO0
-	nop                             # let it understand
-	nop
-	tlbwi				# ... and write ones
-	nop
-	nop
-	mtc0    t2,  CP0_ENTRYHI
-
-mapped:
-	la	t0, exception_handlers
-	lw	t1, DBE_HANDLER(t0)	# save real handler
-	la	t2, dbe_handler
-	sw	t2, DBE_HANDLER(t0)	# set temporary local handler
-	li	v0, -1			# default (failure) value
-
-	li	t2, 1
-	beq	t2, a1, 1f
-	li	t2, 2
-	beq	t2, a1, 2f
-	li	t2, 4
-	beq	t2, a1, 4f
-	b	out
-
-1:	lbu	v0, (a0)		# byte
-	b	out
-
-2:	lhu	v0, (a0)		# short
-	b	out
-
-4:	lw	v0, (a0)		# word
-
-out:
-	sw	t1, DBE_HANDLER(t0)	# restore real handler
-	mtc0	t3, CP0_STATUS		# restore CPU flags
-	jr	ra
-
-dbe_handler:
-	li	v0, -1			# mark our failure
-	.set	push
-	.set	noreorder
-	b	out			# "no problems !"
-	rfe				#   return from trap
-	.set	pop
-END(try_read)
diff -Nru a/arch/mips/baget/balo.c b/arch/mips/baget/balo.c
--- a/arch/mips/baget/balo.c	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,190 +0,0 @@
-/*
- * balo.c: BAget LOader
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#include <linux/kernel.h>
-#include <asm/system.h>
-#include <asm/ptrace.h>
-#include <asm/addrspace.h>
-
-#include <asm/baget/baget.h>
-
-#include "balo.h"  /* Includes some kernel symbol values */
-
-static char *banner = "\nBaget Linux Loader v0.2\n";
-
-static void mem_move (long *to, long *from, long size)
-{
-	while (size > 0) {
-		*to++ = *from++;
-		size -= sizeof(long);
-	}
-}
-
-static volatile int *mem_limit     = (volatile int*)KSEG1;
-static volatile int *mem_limit_dbe = (volatile int*)KSEG1;
-
-static int can_write (volatile int* p) {
-        return p <  (int*)(KSEG1+BALO_OFFSET) ||
-               p >= (int*)(KSEG1+BALO_OFFSET+BALO_SIZE);
-}
-
-static volatile enum balo_state_enum {
-	BALO_INIT,
-	MEM_INIT,
-	MEM_PROBE,
-	START_KERNEL
-} balo_state = BALO_INIT;
-
-
-static __inline__ void reset_and_jump(int start, int mem_upper)
-{
-	unsigned long tmp;
-
-	__asm__ __volatile__(
-                ".set\tnoreorder\n\t"
-                ".set\tnoat\n\t"
-                "mfc0\t$1, $12\n\t"
-                "nop\n\t"
-                "nop\n\t"
-                "nop\n\t"
-                "ori\t$1, $1, 0xff00\n\t"
-                "xori\t$1, $1, 0xff00\n\t"
-                "mtc0\t$1, $12\n\t"
-                "nop\n\t"
-                "nop\n\t"
-                "nop\n\t"
-		"move\t%0, %2\n\t"
-		"jr\t%1\n\t"
-		"nop\n\t"
-                ".set\tat\n\t"
-                ".set\treorder"
-                : "=&r" (tmp)
-                : "Ir" (start), "Ir" (mem_upper)
-                : "memory");
-}
-
-static void start_kernel(void)
-{
-	extern char _vmlinux_start, _vmlinux_end;
-	extern char _ramdisk_start, _ramdisk_end;
-
-        outs( "Relocating Linux... " );
-	mem_move((long*)KSEG0, (long*)&_vmlinux_start,
-                 &_vmlinux_end-&_vmlinux_start);
-	outs("done.\n");
-
-	if (&_ramdisk_start != &_ramdisk_end) {
-		outs("Setting up RAMDISK... ");
-		if (*(unsigned long*)RAMDISK_BASE != 0xBA) {
-			outs("Bad RAMDISK_BASE signature in system image.\n");
-                        balo_hungup();
-		}
-		*(unsigned long*)RAMDISK_BASE = (unsigned long)&_ramdisk_start;
-		*(unsigned long*)RAMDISK_SIZE = &_ramdisk_end -&_ramdisk_start;
-		outs("done.\n");
-	}
-
-	{
-		extern void flush_cache_low(int isize, int dsize);
-		flush_cache_low(256*1024,256*1024);
-	}
-
-        balo_printf( "Kernel entry: %x\n\n", START);
-	balo_state = START_KERNEL;
-	reset_and_jump(START, (int)mem_limit-KSEG1+KSEG0);
-}
-
-
-static void mem_probe(void)
-{
-	balo_state = MEM_PROBE;
-	outs("RAM: <");
-	while(mem_limit < mem_limit_dbe) {
-                if (can_write(mem_limit) && *mem_limit != 0)
-                        break; /* cycle found */
-		outc('.');
-		if (can_write(mem_limit))
-                        *mem_limit = -1; /* mark */
-                mem_limit += 0x40000;
-	}
-	outs(">\n");
-	start_kernel();
-}
-
-volatile unsigned int int_cause;
-volatile unsigned int epc;
-volatile unsigned int badvaddr;
-
-static void print_regs(void)
-{
-        balo_printf("CAUSE=%x EPC=%x BADVADDR=%x\n",
-                    int_cause, epc, badvaddr);
-}
-
-void int_handler(struct pt_regs *regs)
-{
-        switch (balo_state) {
-	case BALO_INIT:
-                balo_printf("\nBALO: trap in balo itself.\n");
-		print_regs();
-                balo_hungup();
-		break;
-	case MEM_INIT:
-                if ((int_cause & CAUSE_MASK) != CAUSE_DBE) {
-                        balo_printf("\nBALO: unexpected trap during memory init.\n");
-			print_regs();
-                        balo_hungup();
-		} else {
-			mem_probe();
-		}
-		break;
-	case MEM_PROBE:
-                balo_printf("\nBALO: unexpected trap during memory probe.\n");
-		print_regs();
-                balo_hungup();
-		break;
-	case START_KERNEL:
-                balo_printf("\nBALO: unexpected kernel trap.\n");
-		print_regs();
-                balo_hungup();
-		break;
-	}
-        balo_printf("\nBALO: unexpected return from handler.\n");
-	print_regs();
-        balo_hungup();
-}
-
-static void mem_init(void)
-{
-	balo_state = MEM_INIT;
-
-	while(1) {
-		*mem_limit_dbe;
-		if (can_write(mem_limit_dbe))
-			*mem_limit_dbe = 0;
-
-		mem_limit_dbe += 0x40000; /* +1M */
-	}
-        /*  no return: must go to int_handler */
-}
-
-void balo_entry(void)
-{
-        extern void except_vec3_generic(void);
-
-	cli();
-	outs(banner);
-        memcpy((void *)(KSEG0 + 0x80), &except_vec3_generic, 0x80);
-	mem_init();
-}
-
-/* Needed for linking */
-
-int vsprintf(char *buf, const char *fmt, va_list arg)
-{
-	outs("BALO: vsprintf called.\n");
-	balo_hungup();
-	return 0;
-}
diff -Nru a/arch/mips/baget/balo_supp.S b/arch/mips/baget/balo_supp.S
--- a/arch/mips/baget/balo_supp.S	2004-12-24 13:36:56 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,142 +0,0 @@
-/*
- * balo_supp.S: BAget Loader supplement
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#include <asm/asm.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-#include <asm/mipsregs.h>
-#include <asm/addrspace.h>
-
-	.text
-	.set    mips1
-
-	/* General exception vector. */
-NESTED(except_vec3_generic, 0, sp)
-	.set    noat
-	la	k0, except_vec3_generic_code
-	jr	k0
-END(except_vec3_generic)
-
-NESTED(except_vec3_generic_code, 0, sp)
-	SAVE_ALL
-	mfc0	k1, CP0_CAUSE
-	la	k0, int_cause
-	sw      k1, (k0)
-
-        mfc0    k1, CP0_EPC
-        la      k0, epc
-        sw      k1, (k0)
-
-        mfc0    k1, CP0_BADVADDR
-        la      k0, badvaddr
-        sw      k1, (k0)
-
-	la	k0, int_handler
-        .set    noreorder
-	jal	k0
-        .set    reorder
-	move	a0, sp
-
-        RESTORE_ALL_AND_RET
-END(except_vec3_generic_code)
-
-        .align  5
-NESTED(flush_cache_low, PT_SIZE, sp)
-        .set    at
-        .set    macro
-        .set    noreorder
-
-        move    t1, a0  # ISIZE
-        move    t2, a1  # DSIZE
-
-        mfc0    t3, CP0_STATUS       # Save the status register.
-        mtc0    zero, CP0_STATUS     # Disable interrupts.
-        la      v0, 1f
-        or      v0, KSEG1            # Run uncached.
-        j       v0
-        nop
-/*
- * Flush the instruction cache.
- */
-1:
-        li      v0, ST0_DE | ST0_CE
-        mtc0    v0, CP0_STATUS       # Isolate and swap caches.
-        li      t0, KSEG1
-        subu    t0, t0, t1
-        li      t1, KSEG1
-        la      v0, 1f                          # Run cached
-        j       v0
-        nop
-1:
-        addu    t0, t0, 64
-        sb      zero, -64(t0)
-        sb      zero, -60(t0)
-        sb      zero, -56(t0)
-        sb      zero, -52(t0)
-        sb      zero, -48(t0)
-        sb      zero, -44(t0)
-        sb      zero, -40(t0)
-        sb      zero, -36(t0)
-        sb      zero, -32(t0)
-        sb      zero, -28(t0)
-        sb      zero, -24(t0)
-        sb      zero, -20(t0)
-        sb      zero, -16(t0)
-        sb      zero, -12(t0)
-        sb      zero, -8(t0)
-        bne     t0, t1, 1b
-        sb      zero, -4(t0)
-
-        la      v0, 1f
-        or      v0, KSEG1
-        j       v0                              # Run uncached
-        nop
-/*
- * Flush the data cache.
- */
-1:
-        li      v0, ST0_DE
-        mtc0    v0, CP0_STATUS       # Isolate and swap back caches
-        li      t0, KSEG1
-        subu    t0, t0, t2
-        la      v0, 1f
-        j       v0                              # Back to cached mode
-        nop
-1:
-        addu    t0, t0, 64
-        sb      zero, -64(t0)
-        sb      zero, -60(t0)
-        sb      zero, -56(t0)
-        sb      zero, -52(t0)
-        sb      zero, -48(t0)
-        sb      zero, -44(t0)
-        sb      zero, -40(t0)
-        sb      zero, -36(t0)
-        sb      zero, -32(t0)
-        sb      zero, -28(t0)
-        sb      zero, -24(t0)
-        sb      zero, -20(t0)
-        sb      zero, -16(t0)
-        sb      zero, -12(t0)
-        sb      zero, -8(t0)
-        bne     t0, t1, 1b
-        sb      zero, -4(t0)
-
-        nop                                     # Insure isolated stores
-        nop                                     #   out of pipe.
-        nop
-        nop
-        mtc0    t3, CP0_STATUS                 # Restore status reg.
-        nop                                    # Insure cache unisolated.
-        nop
-        nop
-        nop
-        j       ra
-        nop
-END(flush_cache_low)
-
-/* To satisfy macros only */
-EXPORT(kernelsp)
-	PTR	0x80001000
diff -Nru a/arch/mips/baget/irq.c b/arch/mips/baget/irq.c
--- a/arch/mips/baget/irq.c	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,407 +0,0 @@
-/*
- * Code to handle Baget/MIPS IRQs plus some generic interrupt stuff.
- *
- * Copyright (C) 1998 Vladimir Roganov & Gleb Raiko
- *      Code (mostly sleleton and comments) derived from DECstation IRQ
- *      handling.
- */
-#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/irq.h>
-#include <asm/mipsregs.h>
-#include <asm/system.h>
-
-#include <asm/baget/baget.h>
-
-volatile unsigned long irq_err_count;
-
-/*
- * This table is a correspondence between IRQ numbers and CPU PILs
- */
-
-static int irq_to_pil_map[BAGET_IRQ_NR] = {
-	7/*fixme: dma_err -1*/,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 0x00 - 0x0f */
-	-1,-1,-1,-1, 3,-1,-1,-1, 2, 2, 2,-1, 3,-1,-1,3/*fixme: lance*/, /* 0x10 - 0x1f */
-        -1,-1,-1,-1,-1,-1, 5,-1,-1,-1,-1,-1, 7,-1,-1,-1, /* 0x20 - 0x2f */
-	-1, 3, 2/*fixme systimer:3*/, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3  /* 0x30 - 0x3f */
-};
-
-static inline int irq_to_pil(int irq_nr)
-{
-	int pil = -1;
-
-	if (irq_nr >= BAGET_IRQ_NR)
-		baget_printk("irq_to_pil: too large irq_nr = 0x%x\n", irq_nr);
-	else {
-		pil = irq_to_pil_map[irq_nr];
-		if (pil == -1)
-			baget_printk("irq_to_pil: unknown irq = 0x%x\n", irq_nr);
-	}
-
-	return pil;
-}
-
-/* Function for careful CP0 interrupt mask access */
-
-static inline void modify_cp0_intmask(unsigned clr_mask, unsigned set_mask)
-{
-	unsigned long status = read_c0_status();
-	status &= ~((clr_mask & 0xFF) << 8);
-	status |=   (set_mask & 0xFF) << 8;
-	write_c0_status(status);
-}
-
-/*
- *  These two functions may be used for unconditional IRQ
- *  masking via their PIL protection.
- */
-
-static inline void mask_irq(unsigned int irq_nr)
-{
-        modify_cp0_intmask(irq_to_pil(irq_nr), 0);
-}
-
-static inline void unmask_irq(unsigned int irq_nr)
-{
-	modify_cp0_intmask(0, irq_to_pil(irq_nr));
-}
-
-/*
- * The following section is introduced for masking/unasking IRQ
- * only while no more IRQs uses same CPU PIL.
- *
- * These functions are used in request_irq, free_irq, but it looks
- * they cannot change something: CP0_STATUS is private for any
- * process, and their action is invisible for system.
- */
-
-static volatile unsigned int pil_in_use[BAGET_PIL_NR] = { 0, };
-
-void mask_irq_count(int irq_nr)
-{
-	unsigned long flags;
-	int pil = irq_to_pil(irq_nr);
-
-	local_irq_save(flags);
-	if (!--pil_in_use[pil])
-		mask_irq(irq_nr);
-	local_irq_restore(flags);
-}
-
-void unmask_irq_count(int irq_nr)
-{
-	unsigned long flags;
-	int pil = irq_to_pil(irq_nr);
-
-	local_irq_save(flags);
-	if (!pil_in_use[pil]++)
-		unmask_irq(irq_nr);
-	local_irq_restore(flags);
-}
-
-/*
- * Two functions below are exported versions of mask/unmask IRQ
- */
-
-void disable_irq(unsigned int irq_nr)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-	mask_irq(irq_nr);
-	local_irq_restore(flags);
-}
-
-void enable_irq(unsigned int irq_nr)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-	unmask_irq(irq_nr);
-	local_irq_restore(flags);
-}
-
-/*
- * Pointers to the low-level handlers: first the general ones, then the
- * fast ones, then the bad ones.
- */
-static struct irqaction *irq_action[BAGET_IRQ_NR] = { NULL, };
-
-int get_irq_list(char *buf)
-{
-	int i, len = 0;
-	struct irqaction * action;
-	unsigned long flags;
-
-	for (i = 0 ; i < BAGET_IRQ_NR ; i++) {
-		local_irq_save(flags);
-		action = irq_action[i];
-		if (!action)
-			gotos skip;
-		len += sprintf(buf+len, "%2d: %8d %c %s",
-			i, kstat_this_cpu.irqs[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");
-skip:
-		local_irq_restore(flags);
-	}
-	return len;
-}
-
-
-/*
- * 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.
- */
-static void do_IRQ(int irq, struct pt_regs * regs)
-{
-	struct irqaction *action;
-	int ret, do_random, cpu;
-
-	cpu = smp_processor_id();
-	irq_enter();
-	kstat_cpus(cpu).irqs[irq]++;
-
-	mask_irq(irq);
-	action = *(irq + irq_action);
-	if (action) {
-		if (!(action->flags & SA_INTERRUPT))
-			local_irq_enable();
-		action = *(irq + irq_action);
-		do_random = 0;
-        	do {
-			ret = action->handler(irq, action->dev_id, regs);
-			if (ret == IRQ_HANDLED)
-				do_random |= action->flags;
-			action = action->next;
-        	} while (action);
-		if (do_random & SA_SAMPLE_RANDOM)
-			add_interrupt_randomness(irq);
-		local_irq_disable();
-	} else {
-		printk("do_IRQ: Unregistered IRQ (0x%X) occurred\n", irq);
-	}
-	unmask_irq(irq);
-	irq_exit();
-
-	/* unmasking and bottom half handling is done magically for us. */
-}
-
-/*
- *  What to do in case of 'no VIC register available' for current interrupt
- */
-static void vic_reg_error(unsigned long address, unsigned char active_pils)
-{
-	printk("\nNo VIC register found: reg=%08lx active_pils=%02x\n"
-	       "Current interrupt mask from CP0_CAUSE: %02x\n",
-	       address, 0xff & active_pils,
-	       0xff & (read_c0_cause()>>8));
-	{ int i; for (i=0; i<10000; i++) udelay(1000); }
-}
-
-static char baget_fpu_irq = BAGET_FPU_IRQ;
-#define BAGET_INT_FPU {(unsigned long)&baget_fpu_irq, 1}
-
-/*
- *  Main interrupt handler: interrupt demultiplexer
- */
-asmlinkage void baget_interrupt(struct pt_regs *regs)
-{
-	static struct baget_int_reg int_reg[BAGET_PIL_NR] = {
-		BAGET_INT_NONE, BAGET_INT_NONE, BAGET_INT0_ACK, BAGET_INT1_ACK,
-		BAGET_INT_NONE, BAGET_INT_FPU,  BAGET_INT_NONE, BAGET_INT5_ACK
-	};
-	unsigned char active_pils;
-	while ((active_pils = read_c0_cause()>>8)) {
-		int pil;
-		struct baget_int_reg* reg;
-
-                for (pil = 0; pil < BAGET_PIL_NR; pil++) {
-                        if (!(active_pils & (1<<pil))) continue;
-
-			reg = &int_reg[pil];
-
-			if (reg->address) {
-                                extern int try_read(unsigned long,int);
-				int irq  = try_read(reg->address, reg->size);
-
-				if (irq != -1)
-				      do_IRQ(BAGET_IRQ_MASK(irq), regs);
-				else
-				      vic_reg_error(reg->address, active_pils);
-			} else {
-				printk("baget_interrupt: unknown interrupt "
-				       "(pil = %d)\n", pil);
-			}
-		}
-	}
-}
-
-/*
- * Idea is to put all interrupts
- * in a single table and differenciate them just by number.
- */
-int setup_baget_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);
-
-	local_irq_save(flags);
-	*p = new;
-	local_irq_restore(flags);
-
-	if (!shared) {
-		unmask_irq_count(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)
-{
-	int retval;
-	struct irqaction * action;
-
-	if (irq >= BAGET_IRQ_NR)
-		return -EINVAL;
-	if (!handler)
-		return -EINVAL;
-	if (irq_to_pil_map[irq] < 0)
-		return -EINVAL;
-
-	action = (struct irqaction *)
-			kmalloc(sizeof(struct irqaction), GFP_KERNEL);
-	if (!action)
-		return -ENOMEM;
-
-	action->handler = handler;
-	action->flags = irqflags;
-	cpus_clear(action->mask);
-	action->name = devname;
-	action->next = NULL;
-	action->dev_id = dev_id;
-
-	retval = setup_baget_irq(irq, action);
-
-	if (retval)
-		kfree(action);
-
-	return retval;
-}
-
-EXPORT_SYMBOL(request_irq);
-
-void free_irq(unsigned int irq, void *dev_id)
-{
-	struct irqaction * action, **p;
-	unsigned long flags;
-
-	if (irq >= BAGET_IRQ_NR)
-		printk("Trying to free IRQ%d\n",irq);
-
-	for (p = irq + irq_action; (action = *p) != NULL; p = &action->next) {
-		if (action->dev_id != dev_id)
-			continue;
-
-		/* Found it - now free it */
-		local_irq_save(flags);
-		*p = action->next;
-		if (!irq[irq_action])
-			unmask_irq_count(irq);
-		local_irq_restore(flags);
-		kfree(action);
-		return;
-	}
-	printk("Trying to free free IRQ%d\n",irq);
-}
-
-EXPORT_SYMBOL(free_irq);
-
-unsigned long probe_irq_on (void)
-{
-	/* TODO */
-	return 0;
-}
-
-EXPORT_SYMBOL(probe_irq_on);
-
-int probe_irq_off (unsigned long irqs)
-{
-	/* TODO */
-	return 0;
-}
-
-EXPORT_SYMBOL(probe_irq_off);
-
-
-static void write_err_interrupt(int irq, void *dev_id, struct pt_regs * regs)
-{
-	*(volatile char*) BAGET_WRERR_ACK = 0;
-}
-
-static struct irqaction irq0  =
-{ write_err_interrupt, SA_INTERRUPT, CPU_MASK_NONE, "bus write error", NULL, NULL};
-
-void __init init_IRQ(void)
-{
-	irq_setup();
-
-	/* Enable access to VIC interrupt registers */
-	vac_outw(0xacef | 0x8200, VAC_PIO_FUNC);
-
-	/* Enable interrupts for pils 2 and 3 (lines 0 and 1) */
-	modify_cp0_intmask(0, (1<<2)|(1<<3));
-
-	if (setup_baget_irq(0, &irq0) < 0)
-		printk("init_IRQ: unable to register write_err irq\n");
-}
diff -Nru a/arch/mips/baget/ld.script.balo b/arch/mips/baget/ld.script.balo
--- a/arch/mips/baget/ld.script.balo	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,125 +0,0 @@
-OUTPUT_FORMAT("elf32-tradbigmips")
-OUTPUT_ARCH(mips)
-ENTRY(balo_entry)
-SECTIONS
-{
-  /* Read-only sections, merged into text segment: */
-  . = 0x80400000;
-  .rel.text      : { *(.rel.text)	}
-  .rela.text     : { *(.rela.text) 	}
-  .rel.data      : { *(.rel.data)	}
-  .rela.data     : { *(.rela.data) 	}
-  .rel.rodata    : { *(.rel.rodata) 	}
-  .rela.rodata   : { *(.rela.rodata) 	}
-  .rel.got       : { *(.rel.got)	}
-  .rela.got      : { *(.rela.got)	}
-  .rel.ctors     : { *(.rel.ctors)	}
-  .rela.ctors    : { *(.rela.ctors)	}
-  .rel.dtors     : { *(.rel.dtors)	}
-  .rela.dtors    : { *(.rela.dtors)	}
-  .rel.init      : { *(.rel.init)	}
-  .rela.init     : { *(.rela.init)	}
-  .rel.fini      : { *(.rel.fini)	}
-  .rela.fini     : { *(.rela.fini)	}
-  .rel.bss       : { *(.rel.bss)	}
-  .rela.bss      : { *(.rela.bss)	}
-  .rel.plt       : { *(.rel.plt)	}
-  .rela.plt      : { *(.rela.plt)	}
-  .init          : { *(.init)		} =0
-  .text      :
-  {
-    _ftext = . ;
-    *(.text)
-    *(.rodata)
-    *(.rodata.*)
-    *(.rodata1)
-    /* .gnu.warning sections are handled specially by elf32.em.  */
-    *(.gnu.warning)
-
-  _etext = .;
-  PROVIDE (etext = .);
-
-  /* Startup code */
-  . = ALIGN(4096);
-  __init_begin = .;
-  *(.text.init)
-  *(.data.init)
-  . = ALIGN(4096);	/* Align double page for init_task_union */
-  __init_end = .;
-
-   *(.fini)
-  *(.reginfo)
-  /* Adjust the address for the data segment.  We want to adjust up to
-     the same address within the page on the next page up.  It would
-     be more correct to do this:
-       . = .;
-     The current expression does not correctly handle the case of a
-     text segment ending precisely at the end of a page; it causes the
-     data segment to skip a page.  The above expression does not have
-     this problem, but it will currently (2/95) cause BFD to allocate
-     a single segment, combining both text and data, for this case.
-     This will prevent the text segment from being shared among
-     multiple executions of the program; I think that is more
-     important than losing a page of the virtual address space (note
-     that no actual memory is lost; the page which is skipped can not
-     be referenced).  */
-  . = .;
-    _fdata = . ;
-    *(.data)
-    CONSTRUCTORS
-
-  *(.data1)
-  _gp = . + 0x8000;
-  *(.lit8)
-  *(.lit4)
-  *(.ctors)
-  *(.dtors)
-  *(.got.plt) *(.got)
-  *(.dynamic)
-  /* We want the small data sections together, so single-instruction offsets
-     can access them all, and initialized data all before uninitialized, so
-     we can shorten the on-disk segment size.  */
-  *(.sdata)
-  _edata  =  .;
-  PROVIDE (edata = .);
-
-  __bss_start = .;
-  _fbss = .;
-
-   *(.dynbss)
-   *(.bss)
-   *(COMMON)
-  _end = . ;
-  PROVIDE (end = .);
-   *(.sbss)
-   *(.scommon)
-
-  /* These are needed for ELF backends which have not yet been
-     converted to the new style linker.  */
-  *(.stab)
-  *(.stabstr)
-  /* DWARF debug sections.
-     Symbols in the .debug DWARF section are relative to the beginning of the
-     section so we begin .debug at 0.  It's not clear yet what needs to happen
-     for the others.   */
-  *(.debug)
-  *(.debug_srcinfo)
-  *(.debug_aranges)
-  *(.debug_pubnames)
-  *(.debug_sfnames)
-  *(.line)
-  /* These must appear regardless of  .  */
-  *(.gptab.data) *(.gptab.sdata)
-  *(.gptab.bss) *(.gptab.sbss)
-
-  _vmlinux_start = .;
-  *(.vmlinux)
-  _vmlinux_end = .;
-
-  _ramdisk_start = .;
-  *(.ramdisk)
-  _ramdisk_end = .;
-
-} =0
-
-}
diff -Nru a/arch/mips/baget/print.c b/arch/mips/baget/print.c
--- a/arch/mips/baget/print.c	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,116 +0,0 @@
-/*
- * print.c: Simple print fascility
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#include <stdarg.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-
-#include <asm/baget/baget.h>
-
-/*
- *  Define this to see 'baget_printk' (debug) messages
- */
-// #define BAGET_PRINTK
-
-/*
- *  This function is same for BALO and Linux baget_printk,
- *  and normally prints characted to second (UART A) console.
- */
-
-static void delay(void) {}
-
-static void outc_low(char c)
-{
-        int i;
-        vac_outb(c, VAC_UART_B_TX);
-        for (i=0; i<10000; i++)
-                delay();
-}
-
-void outc(char c)
-{
-        if (c == '\n')
-                outc_low('\r');
-        outc_low(c);
-}
-
-void outs(char *s)
-{
-        while(*s) outc(*s++);
-}
-
-void baget_write(char *s, int l)
-{
-        while(l--)
-                outc(*s++);
-}
-
-int baget_printk(const char *fmt, ...)
-{
-#ifdef BAGET_PRINTK
-        va_list args;
-        int i;
-        static char buf[1024];
-
-        va_start(args, fmt);
-        i = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf)-4 */
-        va_end(args);
-        baget_write(buf, i);
-        return i;
-#else
-	return 0;
-#endif
-}
-
-static __inline__ void puthex( int a )
-{
-        static char s[9];
-        static char e[] = "0123456789ABCDEF";
-        int i;
-        for( i = 7; i >= 0; i--, a >>= 4 ) s[i] = e[a & 0x0F];
-        s[8] = '\0';
-        outs( s );
-}
-
-void __init balo_printf( char *f, ... )
-{
-        int *arg = (int*)&f + 1;
-        char c;
-        int format = 0;
-
-        while((c = *f++) != 0) {
-                switch(c) {
-                default:
-                        if(format) {
-                                outc('%');
-                                format = 0;
-                        }
-                        outc( c );
-                        break;
-                case '%':
-                        if( format ){
-                                format = 0;
-                                outc(c);
-                        } else format = 1;
-                        break;
-                case 'x':
-                        if(format) puthex( *arg++ );
-                        else outc(c);
-                        format = 0;
-                        break;
-                case 's':
-                        if( format ) outs((char *)*arg++);
-                        else outc(c);
-                        format = 0;
-                        break;
-                }
-        }
-}
-
-void __init balo_hungup(void)
-{
-        outs("Hunging up.\n");
-        while(1);
-}
diff -Nru a/arch/mips/baget/prom/Makefile b/arch/mips/baget/prom/Makefile
--- a/arch/mips/baget/prom/Makefile	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,5 +0,0 @@
-#
-# Makefile for the Baget/MIPS prom emulator library routines.
-#
-
-lib-y	:= init.o
diff -Nru a/arch/mips/baget/prom/init.c b/arch/mips/baget/prom/init.c
--- a/arch/mips/baget/prom/init.c	2004-12-24 13:36:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,32 +0,0 @@
-/*
- * init.c: PROM library initialisation code.
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#include <linux/init.h>
-#include <asm/addrspace.h>
-#include <asm/bootinfo.h>
-
-const char *get_system_type(void)
-{
-	/* Should probably return one of "BT23-201", "BT23-202" */
-	return "Baget";
-}
-
-void __init prom_init(void)
-{
-	mem_upper = PHYSADDR(fw_arg0);
-
-	mips_machgroup  = MACH_GROUP_UNKNOWN;
-	mips_machtype   = MACH_UNKNOWN;
-	arcs_cmdline[0] = 0;
-
-	vac_memory_upper = mem_upper;
-
-	add_memory_region(0, mem_upper, BOOT_MEM_RAM);
-}
-
-unsigned long __init prom_free_prom_memory(void)
-{
-	return 0;
-}
diff -Nru a/arch/mips/baget/reset.c b/arch/mips/baget/reset.c
--- a/arch/mips/baget/reset.c	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,32 +0,0 @@
-#include <linux/kernel.h>
-#include <asm/system.h>
-#include <asm/baget/baget.h>
-
-
-#define R3000_RESET_VEC  0xbfc00000
-typedef void vector(void);
-
-
-static void baget_reboot(char *from_fun)
-{
-	cli();
-	baget_printk("\n%s: jumping to RESET code...\n", from_fun);
-	(*(vector*)R3000_RESET_VEC)();
-}
-
-/* fixme: proper functionality */
-
-void baget_machine_restart(char *command)
-{
-	baget_reboot("restart");
-}
-
-void baget_machine_halt(void)
-{
-	baget_reboot("halt");
-}
-
-void baget_machine_power_off(void)
-{
-	baget_reboot("power off");
-}
diff -Nru a/arch/mips/baget/setup.c b/arch/mips/baget/setup.c
--- a/arch/mips/baget/setup.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,489 +0,0 @@
-/*
- * setup.c: Baget/MIPS specific setup, including init of the feature struct.
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <asm/irq.h>
-#include <asm/addrspace.h>
-#include <asm/reboot.h>
-
-#include <asm/baget/baget.h>
-
-long int vac_memory_upper;
-
-#define CACHEABLE_STR(val) ((val) ? "not cached" : "cached")
-
-static void __init vac_show(void)
-{
-	int i;
-	unsigned short val, decode = vac_inw(VAC_DECODE_CTRL);
-	unsigned short a24_base = vac_inw(VAC_A24_BASE);
-	unsigned long  a24_addr = ((unsigned long)
-					   (a24_base & VAC_A24_MASK)) << 16;
-	char *decode_mode[]  = { "eprom", "vsb", "shared", "dram" };
-	char *address_mode[] = { "", ", A16", ", A32/A24", ", A32/A24/A16" };
-	char *state[] = { "", " on write", " on read", " on read/write", };
-	char *region_mode[] = { "inactive", "shared", "vsb", "vme" };
-	char *asiz[]        = { "user", "A32", "A16", "A24" };
-	unsigned short regs[] = { VAC_REG1,     VAC_REG2, VAC_REG3  };
-	unsigned short bndr[] = { VAC_DRAM_MASK,VAC_BNDR2,VAC_BNDR3 };
-	unsigned short io_sels[] = { VAC_IOSEL0_CTRL,
-				     VAC_IOSEL1_CTRL,
-				     VAC_IOSEL2_CTRL,
-				     VAC_IOSEL3_CTRL,
-				     VAC_IOSEL4_CTRL,
-				     VAC_IOSEL5_CTRL };
-
-	printk("[DSACKi %s, DRAMCS%s qualified, boundary%s qualified%s]\n",
-	       (decode & VAC_DECODE_DSACKI)     ? "on" : "off",
-	       (decode & VAC_DECODE_QFY_DRAMCS) ? ""   : " not",
-	       (decode & VAC_DECODE_QFY_BNDR)   ? ""   : " not",
-	       (decode & VAC_DECODE_FPUCS)      ? ", fpu" : "");
-
-	printk("slave0 ");
-	if (decode & VAC_DECODE_RDR_SLSEL0)
-		printk("at %08lx (%d MB)\t[dram %s]\n",
-		       ((unsigned long)vac_inw(VAC_SLSEL0_BASE))<<16,
-		       ((0xffff ^ vac_inw(VAC_SLSEL0_MASK)) + 1) >> 4,
-		       (decode & VAC_DECODE_QFY_SLSEL0) ? "qualified" : "");
-	else
-		printk("off\n");
-
-	printk("slave1 ");
-	if (decode & VAC_DECODE_RDR_SLSEL1)
-		printk("at %08lx (%d MB)\t[%s%s, %s]\n",
-		       ((unsigned long)vac_inw(VAC_SLSEL1_BASE))<<16,
-		       ((0xffff ^ vac_inw(VAC_SLSEL1_MASK)) + 1) >> 4,
-		       decode_mode[VAC_DECODE_MODE_VAL(decode)],
-		       address_mode[VAC_DECODE_CMP_SLSEL1_VAL(decode)],
-		       (decode & VAC_DECODE_QFY_SLSEL1) ? "qualified" : "");
-	else
-		printk("off\n");
-
-	printk("icf global at %04x, module at %04x [%s]\n",
-		       ((unsigned int)
-			VAC_ICFSEL_GLOBAL_VAL(vac_inw(VAC_ICFSEL_BASE)))<<4,
-		       ((unsigned int)
-			VAC_ICFSEL_MODULE_VAL(vac_inw(VAC_ICFSEL_BASE)))<<4,
-		       (decode & VAC_DECODE_QFY_ICFSEL) ? "qualified" : "");
-
-
-	printk("region0 at 00000000 (%dMB)\t[dram, %s, delay %d cpuclk"
-	       ", cached]\n",
-	       (vac_inw(VAC_DRAM_MASK)+1)>>4,
-	       (decode & VAC_DECODE_DSACK) ? "D32" : "3state",
-	       VAC_DECODE_CPUCLK_VAL(decode));
-
-	for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) {
-		unsigned long from =
-			((unsigned long)vac_inw(bndr[i]))<<16;
-		unsigned long to   =
-			((unsigned long)
-			 ((i+1 == sizeof(bndr)/sizeof(bndr[0])) ?
-			  0xff00 : vac_inw(bndr[i+1])))<<16;
-
-
-		val = vac_inw(regs[i]);
-		printk("region%d at %08lx (%dMB)\t[%s %s/%s, %s]\n",
-		       i+1,
-		       from,
-		       (unsigned int)((to - from) >> 20),
-		       region_mode[VAC_REG_MODE(val)],
-		       asiz[VAC_REG_ASIZ_VAL(val)],
-		       ((val & VAC_REG_WORD) ?  "D16" : "D32"),
-		       CACHEABLE_STR(val&VAC_A24_A24_CACHINH));
-
-		if (a24_addr >= from && a24_addr < to)
-			printk("\ta24 at %08lx (%dMB)\t[vme, A24/%s, %s]\n",
-			       a24_addr,
-			       min((unsigned int)(a24_addr - from)>>20, 32U),
-			       (a24_base & VAC_A24_DATAPATH) ?  "user" :
-			       ((a24_base & VAC_A24_D32_ENABLE)  ?
-				"D32" : "D16"),
-			       CACHEABLE_STR(a24_base & VAC_A24_A24_CACHINH));
-	}
-
-	printk("region4 at ff000000 (15MB)\t[eprom]\n");
-	val = vac_inw(VAC_EPROMCS_CTRL);
-	printk("\t[ack %d cpuclk%s, %s%srecovery %d cpuclk, "
-	       "read %d%s, write %d%s, assert %d%s]\n",
-	       VAC_CTRL_DELAY_DSACKI_VAL(val),
-	       state[val & (VAC_CTRL_IORD|VAC_CTRL_IOWR)],
-	       (val & VAC_CTRL_DSACK0) ? "dsack0*, " : "",
-	       (val & VAC_CTRL_DSACK1) ? "dsack1*, " : "",
-	       VAC_CTRL_RECOVERY_IOSELI_VAL(val),
-	       VAC_CTRL_DELAY_IORD_VAL(val)/2,
-	       (VAC_CTRL_DELAY_IORD_VAL(val)&1) ? ".5" : "",
-	       VAC_CTRL_DELAY_IOWR_VAL(val)/2,
-	       (VAC_CTRL_DELAY_IOWR_VAL(val)&1) ? ".5" : "",
-	       VAC_CTRL_DELAY_IOSELI_VAL(val)/2,
-	       (VAC_CTRL_DELAY_IOSELI_VAL(val)&1) ? ".5" : "");
-
-	printk("region5 at fff00000 (896KB)\t[local io, %s]\n",
-	       CACHEABLE_STR(vac_inw(VAC_A24_BASE) & VAC_A24_IO_CACHINH));
-
-	for (i = 0; i < sizeof(io_sels)/sizeof(io_sels[0]); i++) {
-		val = vac_inw(io_sels[i]);
-		printk("\tio%d[ack %d cpuclk%s, %s%srecovery %d cpuclk, "
-		       "\n\t read %d%s cpuclk, write %d%s cpuclk, "
-		       "assert %d%s%s cpuclk]\n",
-		       i,
-		       VAC_CTRL_DELAY_DSACKI_VAL(val),
-		       state[val & (VAC_CTRL_IORD|VAC_CTRL_IOWR)],
-		       (val & VAC_CTRL_DSACK0) ? "dsack0*, " : "",
-		       (val & VAC_CTRL_DSACK1) ? "dsack1*, " : "",
-		       VAC_CTRL_RECOVERY_IOSELI_VAL(val),
-		       VAC_CTRL_DELAY_IORD_VAL(val)/2,
-		       (VAC_CTRL_DELAY_IORD_VAL(val)&1) ? ".5" : "",
-		       VAC_CTRL_DELAY_IOWR_VAL(val)/2,
-		       (VAC_CTRL_DELAY_IOWR_VAL(val)&1) ? ".5" : "",
-		       VAC_CTRL_DELAY_IOSELI_VAL(val)/2,
-		       (VAC_CTRL_DELAY_IOSELI_VAL(val)&1) ? ".5" : "",
-		       (vac_inw(VAC_DEV_LOC) & VAC_DEV_LOC_IOSEL(i)) ?
-		          ", id" : "");
-	}
-
-	printk("region6 at fffe0000 (128KB)\t[vme, A16/%s, "
-	       "not cached]\n",
-	       (a24_base & VAC_A24_A16D32_ENABLE) ?
-	       ((a24_base & VAC_A24_A16D32) ? "D32" : "D16") : "user");
-
-	val = vac_inw(VAC_SHRCS_CTRL);
-	printk("shared[ack %d cpuclk%s, %s%srecovery %d cpuclk, "
-	       "read %d%s, write %d%s, assert %d%s]\n",
-	       VAC_CTRL_DELAY_DSACKI_VAL(val),
-	       state[val & (VAC_CTRL_IORD|VAC_CTRL_IOWR)],
-	       (val & VAC_CTRL_DSACK0) ? "dsack0*, " : "",
-	       (val & VAC_CTRL_DSACK1) ? "dsack1*, " : "",
-	       VAC_CTRL_RECOVERY_IOSELI_VAL(val),
-	       VAC_CTRL_DELAY_IORD_VAL(val)/2,
-	       (VAC_CTRL_DELAY_IORD_VAL(val)&1) ? ".5" : "",
-	       VAC_CTRL_DELAY_IOWR_VAL(val)/2,
-	       (VAC_CTRL_DELAY_IOWR_VAL(val)&1) ? ".5" : "",
-	       VAC_CTRL_DELAY_IOSELI_VAL(val)/2,
-	       (VAC_CTRL_DELAY_IOSELI_VAL(val)&1) ? ".5" : "");
-}
-
-static void __init vac_init(void)
-{
-	unsigned short mem_limit = (vac_memory_upper >> 16);
-
-	switch(vac_inw(VAC_ID)) {
-	case 0x1AC0:
-		printk("VAC068-F5: ");
-		break;
-	case 0x1AC1:
-		printk("VAC068A: ");
-		break;
-	default:
-		panic("Unknown VAC revision number");
-	}
-
-	vac_outw(mem_limit-1, VAC_DRAM_MASK);
-	vac_outw(mem_limit, VAC_BNDR2);
-	vac_outw(mem_limit, VAC_BNDR3);
-	vac_outw(((BAGET_A24M_BASE>>16)&~VAC_A24_D32_ENABLE)|VAC_A24_DATAPATH,
-		 VAC_A24_BASE);
-	vac_outw(VAC_REG_INACTIVE|VAC_REG_ASIZ0,VAC_REG1);
-	vac_outw(VAC_REG_INACTIVE|VAC_REG_ASIZ0,VAC_REG2);
-	vac_outw(VAC_REG_MWB|VAC_REG_ASIZ1,VAC_REG3);
-	vac_outw(BAGET_A24S_BASE>>16,VAC_SLSEL0_BASE);
-	vac_outw(BAGET_A24S_MASK>>16,VAC_SLSEL0_MASK);
-	vac_outw(BAGET_A24S_BASE>>16,VAC_SLSEL1_BASE);
-	vac_outw(BAGET_A24S_MASK>>16,VAC_SLSEL1_MASK);
-	vac_outw(BAGET_GSW_BASE|BAGET_MSW_BASE(0),VAC_ICFSEL_BASE);
-	vac_outw(VAC_DECODE_FPUCS|
-		 VAC_DECODE_CPUCLK(3)|
-		 VAC_DECODE_RDR_SLSEL0|VAC_DECODE_RDR_SLSEL1|
-		 VAC_DECODE_DSACK|
-		 VAC_DECODE_QFY_BNDR|
-		 VAC_DECODE_QFY_ICFSEL|
-		 VAC_DECODE_QFY_SLSEL1|VAC_DECODE_QFY_SLSEL0|
-		 VAC_DECODE_CMP_SLSEL1_HI|
-		 VAC_DECODE_DRAMCS|
-		 VAC_DECODE_QFY_DRAMCS|
-		 VAC_DECODE_DSACKI,VAC_DECODE_CTRL);
-	vac_outw(VAC_PIO_FUNC_UART_A_TX|VAC_PIO_FUNC_UART_A_RX|
-		 VAC_PIO_FUNC_UART_B_TX|VAC_PIO_FUNC_UART_B_RX|
-		 VAC_PIO_FUNC_IOWR|
-		 VAC_PIO_FUNC_IOSEL3|
-		 VAC_PIO_FUNC_IRQ7|VAC_PIO_FUNC_IRQ10|VAC_PIO_FUNC_IRQ11|
-		 VAC_PIO_FUNC_IOSEL2|
-		 VAC_PIO_FUNC_FCIACK,VAC_PIO_FUNC);
-	vac_outw(VAC_PIO_DIR_FCIACK |
-		 VAC_PIO_DIR_OUT(0) |
-		 VAC_PIO_DIR_OUT(1) |
-		 VAC_PIO_DIR_OUT(2) |
-		 VAC_PIO_DIR_OUT(3) |
-		 VAC_PIO_DIR_IN(4)  |
-		 VAC_PIO_DIR_OUT(5) |
-		 VAC_PIO_DIR_OUT(6) |
-		 VAC_PIO_DIR_OUT(7) |
-		 VAC_PIO_DIR_OUT(8) |
-		 VAC_PIO_DIR_IN(9)  |
-		 VAC_PIO_DIR_OUT(10)|
-		 VAC_PIO_DIR_OUT(11)|
-		 VAC_PIO_DIR_OUT(12)|
-		 VAC_PIO_DIR_OUT(13),VAC_PIO_DIRECTION);
-	vac_outw(VAC_DEV_LOC_IOSEL(2),VAC_DEV_LOC);
-	vac_outw(VAC_CTRL_IOWR|
-		 VAC_CTRL_DELAY_IOWR(3)|
-		 VAC_CTRL_DELAY_IORD(3)|
-		 VAC_CTRL_RECOVERY_IOSELI(1)|
-		 VAC_CTRL_DELAY_DSACKI(8),VAC_SHRCS_CTRL);
-	vac_outw(VAC_CTRL_IOWR|
-		 VAC_CTRL_DELAY_IOWR(3)|
-		 VAC_CTRL_DELAY_IORD(3)|
-		 VAC_CTRL_RECOVERY_IOSELI(1)|
-		 VAC_CTRL_DSACK0|VAC_CTRL_DSACK1|
-		 VAC_CTRL_DELAY_DSACKI(8),VAC_EPROMCS_CTRL);
-	vac_outw(VAC_CTRL_IOWR|
-		 VAC_CTRL_DELAY_IOWR(3)|
-		 VAC_CTRL_DELAY_IORD(3)|
-		 VAC_CTRL_RECOVERY_IOSELI(2)|
-		 VAC_CTRL_DSACK0|VAC_CTRL_DSACK1|
-		 VAC_CTRL_DELAY_DSACKI(8),VAC_IOSEL0_CTRL);
-	vac_outw(VAC_CTRL_IOWR|
-		 VAC_CTRL_DELAY_IOWR(3)|
-		 VAC_CTRL_DELAY_IORD(3)|
-		 VAC_CTRL_RECOVERY_IOSELI(2)|
-		 VAC_CTRL_DSACK0|VAC_CTRL_DSACK1|
-		 VAC_CTRL_DELAY_DSACKI(8),VAC_IOSEL1_CTRL);
-	vac_outw(VAC_CTRL_IOWR|
-		 VAC_CTRL_DELAY_IOWR(3)|
-		 VAC_CTRL_DELAY_IORD(3)|
-		 VAC_CTRL_RECOVERY_IOSELI(2)|
-		 VAC_CTRL_DSACK0|VAC_CTRL_DSACK1|
-		 VAC_CTRL_DELAY_DSACKI(8),VAC_IOSEL2_CTRL);
-	vac_outw(VAC_CTRL_IOWR|
-		 VAC_CTRL_DELAY_IOWR(3)|
-		 VAC_CTRL_DELAY_IORD(3)|
-		 VAC_CTRL_RECOVERY_IOSELI(2)|
-		 VAC_CTRL_DSACK0|VAC_CTRL_DSACK1|
-		 VAC_CTRL_DELAY_DSACKI(8),VAC_IOSEL3_CTRL);
-	vac_outw(VAC_CTRL_IOWR|
-		 VAC_CTRL_DELAY_IOWR(3)|
-		 VAC_CTRL_DELAY_IORD(3)|
-		 VAC_CTRL_RECOVERY_IOSELI(2)|
-		 VAC_CTRL_DELAY_DSACKI(8),VAC_IOSEL4_CTRL);
-	vac_outw(VAC_CTRL_IOWR|
-		 VAC_CTRL_DELAY_IOWR(3)|
-		 VAC_CTRL_DELAY_IORD(3)|
-		 VAC_CTRL_RECOVERY_IOSELI(2)|
-		 VAC_CTRL_DELAY_DSACKI(8),VAC_IOSEL5_CTRL);
-
-        vac_show();
-}
-
-static void __init vac_start(void)
-{
-	vac_outw(0, VAC_ID);
-	vac_outw(VAC_INT_CTRL_TIMER_DISABLE|
-		 VAC_INT_CTRL_UART_B_DISABLE|
-		 VAC_INT_CTRL_UART_A_DISABLE|
-		 VAC_INT_CTRL_MBOX_DISABLE|
-		 VAC_INT_CTRL_PIO4_DISABLE|
-		 VAC_INT_CTRL_PIO7_DISABLE|
-		 VAC_INT_CTRL_PIO8_DISABLE|
-		 VAC_INT_CTRL_PIO9_DISABLE,VAC_INT_CTRL);
-	vac_outw(VAC_INT_CTRL_TIMER_PIO10|
-		 VAC_INT_CTRL_UART_B_PIO7|
-		 VAC_INT_CTRL_UART_A_PIO7,VAC_INT_CTRL);
-	/*
-	 *  Set quadro speed for both UARTs.
-	 *  To do it we need use formulae from VIC/VAC manual,
-	 *  keeping in mind Baget's 50MHz frequency...
-	 */
-	vac_outw((500000/(384*16))<<8,VAC_CPU_CLK_DIV);
-}
-
-static void __init vic_show(void)
-{
-	unsigned char val;
-	char *timeout[]  = { "4", "16", "32", "64", "128", "256", "disabled" };
-	char *deadlock[] = { "[dedlk only]", "[dedlk only]",
-			     "[dedlk], [halt w/ rmc], [lberr]",
-			     "[dedlk], [halt w/o rmc], [lberr]" };
-
-	val = vic_inb(VIC_IFACE_CFG);
-	if (val & VIC_IFACE_CFG_VME)
-		printk("VMEbus controller ");
-	if (val & VIC_IFACE_CFG_TURBO)
-		printk("turbo ");
-	if (val & VIC_IFACE_CFG_MSTAB)
-		printk("metastability delay ");
-	printk("%s ",
-	       deadlock[VIC_IFACE_CFG_DEADLOCK_VAL(val)]);
-
-
-	printk("interrupts: ");
-	val = vic_inb(VIC_ERR_INT);
-	if (!(val & VIC_ERR_INT_SYSFAIL))
-		printk("[sysfail]");
-	if (!(val & VIC_ERR_INT_TIMO))
-		printk("[timeout]");
-	if (!(val & VIC_ERR_INT_WRPOST))
-		printk("[write post]");
-	if (!(val & VIC_ERR_INT_ACFAIL))
-		printk("[acfail] ");
-	printk("\n");
-
-	printk("timeouts: ");
-	val = vic_inb(VIC_XFER_TIMO);
-	printk("local %s, vme %s ",
-	       timeout[VIC_XFER_TIMO_LOCAL_PERIOD_VAL(val)],
-	       timeout[VIC_XFER_TIMO_VME_PERIOD_VAL(val)]);
-	if (val & VIC_XFER_TIMO_VME)
-		printk("acquisition ");
-	if (val & VIC_XFER_TIMO_ARB)
-		printk("arbitration ");
-	printk("\n");
-
-	val = vic_inb(VIC_LOCAL_TIM);
-	printk("pas time: (%d,%d), ds time: %d\n",
-	       VIC_LOCAL_TIM_PAS_ASSERT_VAL(val),
-	       VIC_LOCAL_TIM_PAS_DEASSERT_VAL(val),
-	       VIC_LOCAT_TIM_DS_DEASSERT_VAL(val));
-
-	val = vic_inb(VIC_BXFER_DEF);
-	printk("dma: ");
-	if (val & VIC_BXFER_DEF_DUAL)
-		printk("[dual path]");
-	if (val & VIC_BXFER_DEF_LOCAL_CROSS)
-		printk("[local boundary cross]");
-	if (val & VIC_BXFER_DEF_VME_CROSS)
-		printk("[vme boundary cross]");
-
-}
-
-static void __init vic_init(void)
-{
-	 unsigned char id = vic_inb(VIC_ID);
-	 if ((id & 0xf0) != 0xf0)
-		 panic("VIC not found");
-	 printk(" VIC068A Rev. %X: ", id & 0x0f);
-
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE,VIC_VME_II);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE,VIC_VME_INT1);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE,VIC_VME_INT2);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE,VIC_VME_INT3);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE,VIC_VME_INT4);
-/*
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE, VIC_VME_INT5);
-*/
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE, VIC_VME_INT6);
-
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE, VIC_VME_INT7);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_DISABLE, VIC_DMA_INT);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_NOAUTO|VIC_INT_EDGE|
-		  VIC_INT_LOW|VIC_INT_DISABLE, VIC_LINT1);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_NOAUTO|VIC_INT_EDGE|
-		  VIC_INT_HIGH|VIC_INT_DISABLE, VIC_LINT2);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_NOAUTO|VIC_INT_EDGE|
-		  VIC_INT_HIGH|VIC_INT_DISABLE, VIC_LINT3);
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_NOAUTO|VIC_INT_EDGE|
-		  VIC_INT_LOW|VIC_INT_DISABLE, VIC_LINT4);
-/*
-	 vic_outb(VIC_INT_IPL(3)|VIC_INT_NOAUTO|VIC_INT_LEVEL|
-		  VIC_INT_LOW|VIC_INT_DISABLE, VIC_LINT5);
-*/
-	 vic_outb(VIC_INT_IPL(6)|VIC_INT_NOAUTO|VIC_INT_EDGE|
-		  VIC_INT_LOW|VIC_INT_DISABLE, VIC_LINT6);
-	 vic_outb(VIC_INT_IPL(6)|VIC_INT_NOAUTO|VIC_INT_EDGE|
-		  VIC_INT_LOW|VIC_INT_DISABLE, VIC_LINT7);
-
-	 vic_outb(VIC_INT_IPL(3)|
-		  VIC_INT_SWITCH(0)|
-		  VIC_INT_SWITCH(1)|
-		  VIC_INT_SWITCH(2)|
-		  VIC_INT_SWITCH(3), VIC_ICGS_INT);
-	 vic_outb(VIC_INT_IPL(3)|
-		  VIC_INT_SWITCH(0)|
-		  VIC_INT_SWITCH(1)|
-		  VIC_INT_SWITCH(2)|
-		  VIC_INT_SWITCH(3), VIC_ICMS_INT);
-	 vic_outb(VIC_INT_IPL(6)|
-		  VIC_ERR_INT_SYSFAIL|
-		  VIC_ERR_INT_TIMO|
-		  VIC_ERR_INT_WRPOST|
-		  VIC_ERR_INT_ACFAIL, VIC_ERR_INT);
-	 vic_outb(VIC_ICxS_BASE_ID(0xf), VIC_ICGS_BASE);
-	 vic_outb(VIC_ICxS_BASE_ID(0xe), VIC_ICMS_BASE);
-	 vic_outb(VIC_LOCAL_BASE_ID(0x6), VIC_LOCAL_BASE);
-	 vic_outb(VIC_ERR_BASE_ID(0x3), VIC_ERR_BASE);
-	 vic_outb(VIC_XFER_TIMO_VME_PERIOD_32|
-		  VIC_XFER_TIMO_LOCAL_PERIOD_32, VIC_XFER_TIMO);
-	 vic_outb(VIC_LOCAL_TIM_PAS_ASSERT(2)|
-		  VIC_LOCAT_TIM_DS_DEASSERT(1)|
-		  VIC_LOCAL_TIM_PAS_DEASSERT(1), VIC_LOCAL_TIM);
-	 vic_outb(VIC_BXFER_DEF_VME_CROSS|
-		  VIC_BXFER_DEF_LOCAL_CROSS|
-		  VIC_BXFER_DEF_AMSR|
-		  VIC_BXFER_DEF_DUAL, VIC_BXFER_DEF);
-	 vic_outb(VIC_SSxCR0_LOCAL_XFER_SINGLE|
-		  VIC_SSxCR0_A32|VIC_SSxCR0_D32|
-		  VIC_SS0CR0_TIMER_FREQ_NONE, VIC_SS0CR0);
-	 vic_outb(VIC_SSxCR1_TF1(0xf)|
-		  VIC_SSxCR1_TF2(0xf), VIC_SS0CR1);
-	 vic_outb(VIC_SSxCR0_LOCAL_XFER_SINGLE|
-		  VIC_SSxCR0_A24|VIC_SSxCR0_D32, VIC_SS1CR0);
-	 vic_outb(VIC_SSxCR1_TF1(0xf)|
-		  VIC_SSxCR1_TF2(0xf), VIC_SS1CR1);
-         vic_outb(VIC_IFACE_CFG_NOHALT|
-		  VIC_IFACE_CFG_NOTURBO, VIC_IFACE_CFG);
-	 vic_outb(VIC_AMS_CODE(0), VIC_AMS);
-	 vic_outb(VIC_BXFER_CTRL_INTERLEAVE(0), VIC_BXFER_CTRL);
-	 vic_outb(0, VIC_BXFER_LEN_LO);
-	 vic_outb(0, VIC_BXFER_LEN_HI);
-	 vic_outb(VIC_REQ_CFG_FAIRNESS_DISABLED|
-		  VIC_REQ_CFG_LEVEL(3)|
-		  VIC_REQ_CFG_RR_ARBITRATION, VIC_REQ_CFG);
-	 vic_outb(VIC_RELEASE_BLKXFER_BLEN(0)|
-		  VIC_RELEASE_RWD, VIC_RELEASE);
-	 vic_outb(VIC_IC6_RUN, VIC_IC6);
-	 vic_outb(0, VIC_IC7);
-
-	 vic_show();
-}
-
-static void vic_start(void)
-{
-	vic_outb(VIC_INT_IPL(3)|
-		 VIC_INT_NOAUTO|
-		 VIC_INT_EDGE|
-		 VIC_INT_HIGH|
-		 VIC_INT_ENABLE, VIC_LINT7);
-}
-
-void __init baget_irq_setup(void)
-{
-	extern void bagetIRQ(void);
-
-        /* Now, it's safe to set the exception vector. */
-	set_except_vector(0, bagetIRQ);
-}
-
-extern void baget_machine_restart(char *command);
-extern void baget_machine_halt(void);
-extern void baget_machine_power_off(void);
-
-static void __init baget_setup(void)
-{
-	printk("BT23/63-201n found.\n");
-	*BAGET_WRERR_ACK = 0;
-	irq_setup = baget_irq_setup;
-
-        _machine_restart   = baget_machine_restart;
-        _machine_halt      = baget_machine_halt;
-        _machine_power_off = baget_machine_power_off;
-
-	vac_init();
-	vic_init();
-	vac_start();
-	vic_start();
-}
-
-early_initcall(baget_setup);
diff -Nru a/arch/mips/baget/time.c b/arch/mips/baget/time.c
--- a/arch/mips/baget/time.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,105 +0,0 @@
-/*
- * time.c: Baget/MIPS specific time handling details
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/param.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/time.h>
-#include <linux/interrupt.h>
-#include <linux/timex.h>
-#include <linux/spinlock.h>
-
-#include <asm/bootinfo.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/ptrace.h>
-#include <asm/system.h>
-
-#include <asm/baget/baget.h>
-
-/*
- *  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;
-
-	if (ticks++ * FREQ_DEN >= valid_ticks * FREQ_NOM) {
-		/*
-		 *  We need no overflow checks,
-		 *  due baget unable to work 3000 years...
-		 *  At least without reboot...
-		 */
-		valid_ticks++;
-		return 1;
-	}
-	return 0;
-}
-
-void static timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
-{
-	if (timer_intr_valid()) {
-		sti();
-		do_timer(regs);
-	}
-}
-
-static void __init timer_enable(void)
-{
-	unsigned char ss0cr0 = vic_inb(VIC_SS0CR0);
-	ss0cr0 &= ~VIC_SS0CR0_TIMER_FREQ_MASK;
-	ss0cr0 |= VIC_SS0CR0_TIMER_FREQ_1000HZ;
-	vic_outb(ss0cr0, VIC_SS0CR0);
-
-	vic_outb(VIC_INT_IPL(6)|VIC_INT_NOAUTO|VIC_INT_EDGE|
-		 VIC_INT_LOW|VIC_INT_ENABLE, VIC_LINT2);
-}
-
-static struct irqaction timer_irq  =
-{ timer_interrupt, SA_INTERRUPT, CPU_MASK_NONE, "timer", NULL, NULL};
-
-void __init time_init(void)
-{
-	if (setup_baget_irq(BAGET_VIC_TIMER_IRQ, &timer_irq) < 0)
-		printk("time_init: unable request irq for system timer\n");
-	timer_enable();
-	/* We don't call sti() here, because it is too early for baget */
-}
-
-void do_gettimeofday(struct timeval *tv)
-{
-	unsigned long seq;
-
-	do {
-		seq = read_seqbegin(&xtime_lock);
-		tv->tv_sec = xtime.tv_sec;
-		tv->tv_usec = xtime.tv_nsec / 1000;
-	} while (read_seqretry(&xtime_lock, seq));
-}
-
-EXPORT_SYMBOL(do_gettimeofday);
-
-void do_settimeofday(struct timeval *tv)
-{
-	write_seqlock_irq(&xtime_lock);
-	xtime.tv_usec = tv->tv_sec;
-	xtime.tv_nsec = tv->tv_usec;
-	time_adjust = 0;		/* stop active adjtime() */
-	time_status |= STA_UNSYNC;
-	time_maxerror = NTP_PHASE_LIMIT;
-	time_esterror = NTP_PHASE_LIMIT;
-	write_sequnlock_irq(&xtime_lock);
-}
-
-EXPORT_SYMBOL(do_settimeofday);
diff -Nru a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
--- a/arch/mips/boot/Makefile	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/boot/Makefile	2004-12-24 13:37:18 -08:00
@@ -4,6 +4,7 @@
 # for more details.
 #
 # Copyright (C) 1995, 1998, 2001, 2002 by Ralf Baechle
+# Copyright (C) 2004  Maciej W. Rozycki
 #
 
 #
@@ -19,29 +20,30 @@
 # Drop some uninteresting sections in the kernel.
 # This is only relevant for ELF kernels but doesn't hurt a.out
 #
-drop-sections	= .reginfo .mdebug .comment .note .pdr
+drop-sections	= .reginfo .mdebug .comment .note .pdr .options .MIPS.options
 strip-flags	= $(addprefix --remove-section=,$(drop-sections))
 
+VMLINUX = vmlinux
+
 all: vmlinux.ecoff vmlinux.srec addinitrd
 
-vmlinux.ecoff:	$(obj)/elf2ecoff vmlinux
-	$(obj)/elf2ecoff vmlinux vmlinux.ecoff $(E2EFLAGS)
+vmlinux.ecoff: $(obj)/elf2ecoff $(VMLINUX)
+	$(obj)/elf2ecoff $(VMLINUX) vmlinux.ecoff $(E2EFLAGS)
 
 $(obj)/elf2ecoff: $(obj)/elf2ecoff.c
 	$(HOSTCC) -o $@ $^
 
-vmlinux.srec:   vmlinux
-	$(OBJCOPY) -S -O srec $(strip-flags) vmlinux $(obj)/vmlinux.srec
+vmlinux.srec: $(VMLINUX)
+	$(OBJCOPY) -S -O srec $(strip-flags) $(VMLINUX) $(obj)/vmlinux.srec
 
 $(obj)/addinitrd: $(obj)/addinitrd.c
 	$(HOSTCC) -o $@ $^
 
 archhelp:
 	@echo	'* vmlinux.ecoff	- ECOFF boot image'
+	@echo	'* vmlinux.srec		- SREC boot image'
 
 clean-files += addinitrd \
 	       elf2ecoff \
 	       vmlinux.ecoff \
-	       vmlinux.srec \
-	       zImage.tmp \
-	       zImage
+	       vmlinux.srec
diff -Nru a/arch/mips/boot/addinitrd.c b/arch/mips/boot/addinitrd.c
--- a/arch/mips/boot/addinitrd.c	2004-12-24 13:37:02 -08:00
+++ b/arch/mips/boot/addinitrd.c	2004-12-24 13:37:02 -08:00
@@ -2,6 +2,8 @@
  * addinitrd - program to add a initrd image to an ecoff kernel
  *
  * (C) 1999 Thomas Bogendoerfer
+ * minor modifications, cleanup: Guido Guenther <agx@sigxcpu.org>
+ * further cleanup: Maciej W. Rozycki
  */
 
 #include <sys/types.h>
@@ -54,7 +56,7 @@
 		exit (1);
 	}
 
-	if ((fd_vmlinux = open (argv[1],O_RDWR)) < 0)
+	if ((fd_vmlinux = open (argv[1],O_RDONLY)) < 0)
 		 die ("open vmlinux");
 	if (read (fd_vmlinux, &efile, sizeof efile) != sizeof efile)
 		die ("read file header");
@@ -78,6 +80,11 @@
 			swab = 1;
 	}
 
+	/* make sure we have an empty data segment for the initrd */
+	if (eaout.dsize || esecs[1].s_size) {
+		fprintf (stderr, "Data segment not empty. Giving up!\n");
+		exit (1);
+	}
 	if ((fd_initrd = open (argv[2], O_RDONLY)) < 0)
 		die ("open initrd");
 	if (fstat (fd_initrd, &st) < 0)
diff -Nru a/arch/mips/cobalt/irq.c b/arch/mips/cobalt/irq.c
--- a/arch/mips/cobalt/irq.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/cobalt/irq.c	2004-12-24 13:37:00 -08:00
@@ -87,7 +87,7 @@
 	}
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	set_except_vector(0, cobalt_handle_int);
 
diff -Nru a/arch/mips/cobalt/setup.c b/arch/mips/cobalt/setup.c
--- a/arch/mips/cobalt/setup.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/cobalt/setup.c	2004-12-24 13:36:17 -08:00
@@ -5,7 +5,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1996, 1997 by Ralf Baechle
+ * Copyright (C) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org)
  * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv)
  *
  */
@@ -15,7 +15,6 @@
 #include <linux/init.h>
 
 #include <asm/bootinfo.h>
-#include <asm/pci_channel.h>
 #include <asm/time.h>
 #include <asm/io.h>
 #include <asm/irq.h>
diff -Nru a/arch/mips/configs/atlas_defconfig b/arch/mips/configs/atlas_defconfig
--- a/arch/mips/configs/atlas_defconfig	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/configs/atlas_defconfig	2004-12-24 13:37:19 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:55 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,7 +51,6 @@
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -62,6 +66,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -69,7 +74,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -118,7 +122,6 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -135,7 +138,6 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
-# CONFIG_BINFMT_IRIX is not set
 
 #
 # Device Drivers
@@ -144,6 +146,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -175,7 +178,19 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -221,7 +236,8 @@
 # CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_AIC79XX is not set
 # CONFIG_SCSI_DPT_I2O is not set
-# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
 # CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_BUSLOGIC is not set
 # CONFIG_SCSI_DMX3191D is not set
@@ -230,12 +246,14 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR 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_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
 # CONFIG_SCSI_QLA21XX is not set
 # CONFIG_SCSI_QLA22XX is not set
@@ -295,10 +313,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -316,7 +337,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -439,6 +459,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -473,7 +494,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -493,7 +513,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -504,6 +523,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -525,7 +549,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -537,6 +560,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -556,6 +581,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -568,7 +594,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -615,6 +642,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -635,13 +663,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -652,6 +682,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/bosporus_defconfig b/arch/mips/configs/bosporus_defconfig
--- a/arch/mips/configs/bosporus_defconfig	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,671 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
-# CONFIG_64BIT is not set
-CONFIG_MIPS32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_HOTPLUG=y
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Machine selection
-#
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SOC_AU1X00 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-# CONFIG_FB is not set
-
-#
-# CPU selection
-#
-CONFIG_CPU_MIPS32=y
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-# CONFIG_CPU_VR41XX is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_8KB is not set
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-CONFIG_CPU_HAS_PREFETCH=y
-# CONFIG_VTAG_ICACHE is not set
-# CONFIG_64BIT_PHYS_ADDR is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_LLSC=y
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_MMU=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_PCMCIA_DEBUG is not set
-# CONFIG_TCIC is not set
-
-#
-# PCI Hotplug Support
-#
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_TRAD_SIGNALS=y
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-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_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-# CONFIG_IPV6 is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-
-#
-# IP: Netfilter Configuration
-#
-# CONFIG_IP_NF_CONNTRACK is not set
-# CONFIG_IP_NF_QUEUE is not set
-# CONFIG_IP_NF_IPTABLES is not set
-# CONFIG_IP_NF_ARPTABLES is not set
-# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-
-#
-# Token Ring devices
-#
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-CONFIG_PPP=m
-CONFIG_PPP_MULTILINK=y
-# CONFIG_PPP_FILTER is not set
-CONFIG_PPP_ASYNC=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-CONFIG_PPPOE=m
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG 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
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-CONFIG_EXT3_FS_SECURITY=y
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-CONFIG_REISERFS_FS_XATTR=y
-CONFIG_REISERFS_FS_POSIX_ACL=y
-CONFIG_REISERFS_FS_SECURITY=y
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=m
-CONFIG_AUTOFS4_FS=m
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-CONFIG_CRAMFS=m
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=m
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=m
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-CONFIG_SMB_FS=m
-# CONFIG_SMB_NLS_DEFAULT is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS=m
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-# CONFIG_CRYPTO_MD4 is not set
-# CONFIG_CRYPTO_MD5 is not set
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-CONFIG_CRYPTO_SHA512=y
-# CONFIG_CRYPTO_DES is not set
-# CONFIG_CRYPTO_BLOWFISH is not set
-CONFIG_CRYPTO_TWOFISH=y
-# CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_ARC4 is not set
-CONFIG_CRYPTO_DEFLATE=y
-CONFIG_CRYPTO_MICHAEL_MIC=y
-CONFIG_CRYPTO_CRC32C=m
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Library routines
-#
-CONFIG_CRC16=m
-CONFIG_CRC32=y
-CONFIG_LIBCRC32C=m
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/mips/configs/capcella_defconfig b/arch/mips/configs/capcella_defconfig
--- a/arch/mips/configs/capcella_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/configs/capcella_defconfig	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:55 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 CONFIG_MACH_VR41XX=y
 # CONFIG_CASIO_E55 is not set
 # CONFIG_IBM_WORKPAD is not set
@@ -75,6 +80,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -82,7 +88,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -122,7 +127,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -147,6 +151,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -175,7 +180,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -193,7 +210,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -257,10 +273,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -278,7 +297,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -400,6 +418,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -434,7 +453,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -466,7 +484,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -477,6 +494,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -498,7 +520,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -510,6 +531,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -529,6 +552,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=y
 CONFIG_AUTOFS4_FS=y
 
@@ -541,7 +565,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -589,6 +614,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -609,13 +635,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -626,6 +654,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/cobalt_defconfig b/arch/mips/configs/cobalt_defconfig
--- a/arch/mips/configs/cobalt_defconfig	2004-12-24 13:36:32 -08:00
+++ b/arch/mips/configs/cobalt_defconfig	2004-12-24 13:36:32 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:55 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,7 +51,6 @@
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 CONFIG_MIPS_COBALT=y
@@ -62,6 +66,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -69,7 +74,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -113,7 +117,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -138,6 +141,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -167,7 +171,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -185,7 +201,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -245,10 +260,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -266,7 +284,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -388,6 +405,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -422,7 +440,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -442,7 +459,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -453,6 +469,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -474,7 +495,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -486,6 +506,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -509,6 +531,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -521,7 +544,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -566,6 +590,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -586,13 +611,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -603,6 +630,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/db1000_defconfig b/arch/mips/configs/db1000_defconfig
--- a/arch/mips/configs/db1000_defconfig	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/configs/db1000_defconfig	2004-12-24 13:36:49 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:56 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 CONFIG_SOC_AU1X00=y
 CONFIG_SOC_AU1000=y
 # CONFIG_SOC_AU1100 is not set
@@ -133,7 +138,6 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -143,10 +147,16 @@
 CONFIG_MMU=y
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=m
+CONFIG_PCCARD=m
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=m
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
 # CONFIG_PCMCIA_AU1X00 is not set
 
@@ -168,6 +178,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 
@@ -193,7 +204,19 @@
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -217,7 +240,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -251,6 +273,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 
 #
 # IP: Virtual Server Configuration
@@ -264,13 +289,14 @@
 # IP: Netfilter Configuration
 #
 # CONFIG_IP_NF_CONNTRACK is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
 # CONFIG_IP_NF_QUEUE is not set
 # CONFIG_IP_NF_IPTABLES is not set
 # CONFIG_IP_NF_ARPTABLES is not set
 # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
 # CONFIG_IP_NF_COMPAT_IPFWADM is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -288,7 +314,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -316,7 +341,7 @@
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
+CONFIG_MII=m
 CONFIG_MIPS_AU1X00_ENET=y
 
 #
@@ -341,13 +366,13 @@
 #
 CONFIG_NET_PCMCIA=y
 CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
 
 #
 # Wan interfaces
@@ -401,6 +426,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -436,7 +462,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -450,19 +475,17 @@
 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
 
 #
 # PCMCIA character devices
 #
-# CONFIG_SYNCLINK_CS is not set
+CONFIG_SYNCLINK_CS=m
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -471,6 +494,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -492,7 +520,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -503,6 +530,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -535,6 +564,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -547,7 +577,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -560,6 +591,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -595,6 +627,7 @@
 CONFIG_EXPORTFS=m
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 # CONFIG_CIFS is not set
@@ -655,13 +688,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -675,14 +710,18 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 # CONFIG_CRYPTO_DES is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
 CONFIG_CRYPTO_TWOFISH=y
 # CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 CONFIG_CRYPTO_CRC32C=m
@@ -691,8 +730,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/db1100_defconfig b/arch/mips/configs/db1100_defconfig
--- a/arch/mips/configs/db1100_defconfig	2004-12-24 13:36:34 -08:00
+++ b/arch/mips/configs/db1100_defconfig	2004-12-24 13:36:34 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:56 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 CONFIG_SOC_AU1X00=y
 # CONFIG_SOC_AU1000 is not set
 CONFIG_SOC_AU1100=y
@@ -133,7 +138,6 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -141,10 +145,16 @@
 CONFIG_MMU=y
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=m
+CONFIG_PCCARD=m
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=m
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
 # CONFIG_PCMCIA_AU1X00 is not set
 
@@ -166,6 +176,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 
@@ -191,7 +202,19 @@
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -215,7 +238,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -249,6 +271,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 
 #
 # IP: Virtual Server Configuration
@@ -262,13 +287,14 @@
 # IP: Netfilter Configuration
 #
 # CONFIG_IP_NF_CONNTRACK is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
 # CONFIG_IP_NF_QUEUE is not set
 # CONFIG_IP_NF_IPTABLES is not set
 # CONFIG_IP_NF_ARPTABLES is not set
 # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
 # CONFIG_IP_NF_COMPAT_IPFWADM is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -286,7 +312,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -314,7 +339,7 @@
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
+CONFIG_MII=m
 # CONFIG_MIPS_AU1X00_ENET is not set
 
 #
@@ -339,13 +364,13 @@
 #
 CONFIG_NET_PCMCIA=y
 CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
 
 #
 # Wan interfaces
@@ -399,6 +424,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -431,7 +457,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -445,19 +470,17 @@
 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
 
 #
 # PCMCIA character devices
 #
-# CONFIG_SYNCLINK_CS is not set
+CONFIG_SYNCLINK_CS=m
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -466,6 +489,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -487,7 +515,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -498,6 +525,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -530,6 +559,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -542,7 +572,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -555,6 +586,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -590,6 +622,7 @@
 CONFIG_EXPORTFS=m
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 # CONFIG_CIFS is not set
@@ -650,13 +683,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -670,14 +705,18 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 # CONFIG_CRYPTO_DES is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
 CONFIG_CRYPTO_TWOFISH=y
 # CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 CONFIG_CRYPTO_CRC32C=m
@@ -686,8 +725,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/db1500_defconfig b/arch/mips/configs/db1500_defconfig
--- a/arch/mips/configs/db1500_defconfig	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/configs/db1500_defconfig	2004-12-24 13:36:48 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:56 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 CONFIG_SOC_AU1X00=y
 # CONFIG_SOC_AU1000 is not set
 # CONFIG_SOC_AU1100 is not set
@@ -97,7 +102,8 @@
 # CONFIG_TOSHIBA_RBTX4927 is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_HAVE_DEC_LOCK=y
-CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_COHERENT=y
+CONFIG_MIPS_DISABLE_OBSOLETE_IDE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
 # CONFIG_FB is not set
@@ -133,26 +139,38 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
 #
 CONFIG_HW_HAS_PCI=y
-# CONFIG_PCI is not set
+CONFIG_PCI=y
+CONFIG_PCI_LEGACY_PROC=y
+CONFIG_PCI_NAMES=y
 CONFIG_MMU=y
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=m
+CONFIG_PCCARD=m
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=m
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+# CONFIG_YENTA is not set
+# CONFIG_PD6729 is not set
+# CONFIG_I82092 is not set
 # CONFIG_TCIC is not set
-# CONFIG_PCMCIA_AU1X00 is not set
+CONFIG_PCMCIA_AU1X00=m
 
 #
 # PCI Hotplug Support
 #
+# CONFIG_HOTPLUG_PCI is not set
 
 #
 # Executable file formats
@@ -168,6 +186,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 
@@ -197,13 +216,24 @@
 # CONFIG_MTD_JEDECPROBE is not set
 CONFIG_MTD_GEN_PROBE=y
 # CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
 CONFIG_MTD_CFI_INTELEXT=y
 CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_CFI_AMDSTD_RETRY=0
 # CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
 
 #
 # Mapping drivers for chip access
@@ -217,7 +247,9 @@
 #
 # Self-contained MTD device drivers
 #
+# CONFIG_MTD_PMC551 is not set
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
 # CONFIG_MTD_BLKMTD is not set
 
@@ -246,11 +278,29 @@
 # Block devices
 #
 # CONFIG_BLK_DEV_FD 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_UMEM is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_UB is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -269,12 +319,12 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
 #
-CONFIG_IDE_GENERIC=y
+# CONFIG_IDE_GENERIC is not set
+# CONFIG_BLK_DEV_IDEPCI is not set
 # CONFIG_IDE_ARM is not set
 # CONFIG_BLK_DEV_IDEDMA is not set
 # CONFIG_IDEDMA_AUTO is not set
@@ -302,6 +352,7 @@
 #
 # I2O device support
 #
+# CONFIG_I2O is not set
 
 #
 # Networking support
@@ -331,6 +382,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 
 #
 # IP: Virtual Server Configuration
@@ -344,13 +398,14 @@
 # IP: Netfilter Configuration
 #
 # CONFIG_IP_NF_CONNTRACK is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
 # CONFIG_IP_NF_QUEUE is not set
 # CONFIG_IP_NF_IPTABLES is not set
 # CONFIG_IP_NF_ARPTABLES is not set
 # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
 # CONFIG_IP_NF_COMPAT_IPFWADM is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -368,7 +423,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -393,23 +447,50 @@
 # CONFIG_ETHERTAP is not set
 
 #
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
 CONFIG_MIPS_AU1X00_ENET=y
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
+# CONFIG_HP100 is not set
+# CONFIG_NET_PCI is not set
 
 #
 # Ethernet (1000 Mbit)
 #
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
 
 #
 # Ethernet (10000 Mbit)
 #
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
 
 #
 # Token Ring devices
 #
+# CONFIG_TR is not set
 
 #
 # Wireless LAN (non-hamradio)
@@ -419,20 +500,14 @@
 #
 # PCMCIA network device support
 #
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
+# CONFIG_NET_PCMCIA is not set
 
 #
 # Wan interfaces
 #
 # CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
 CONFIG_PPP=m
 CONFIG_PPP_MULTILINK=y
 # CONFIG_PPP_FILTER is not set
@@ -481,6 +556,8 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -514,7 +591,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -533,14 +609,13 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
-# CONFIG_SYNCLINK_CS is not set
+CONFIG_SYNCLINK_CS=m
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -549,6 +624,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -569,11 +649,139 @@
 #
 # Sound
 #
-# CONFIG_SOUND is not set
+CONFIG_SOUND=y
+
+#
+# Advanced Linux Sound Architecture
+#
+# CONFIG_SND is not set
+
+#
+# Open Sound System
+#
+CONFIG_SOUND_PRIME=y
+# CONFIG_SOUND_BT878 is not set
+# CONFIG_SOUND_CMPCI is not set
+# CONFIG_SOUND_EMU10K1 is not set
+# CONFIG_SOUND_FUSION is not set
+# CONFIG_SOUND_CS4281 is not set
+# CONFIG_SOUND_ES1370 is not set
+# CONFIG_SOUND_ES1371 is not set
+# CONFIG_SOUND_ESSSOLO1 is not set
+# CONFIG_SOUND_MAESTRO is not set
+# CONFIG_SOUND_MAESTRO3 is not set
+# CONFIG_SOUND_ICH is not set
+# CONFIG_SOUND_SONICVIBES is not set
+CONFIG_SOUND_AU1000=y
+# CONFIG_SOUND_TRIDENT is not set
+# CONFIG_SOUND_MSNDCLAS is not set
+# CONFIG_SOUND_MSNDPIN is not set
+# CONFIG_SOUND_VIA82CXXX is not set
+# CONFIG_SOUND_OSS is not set
+# CONFIG_SOUND_ALI5455 is not set
+# CONFIG_SOUND_FORTE is not set
+# CONFIG_SOUND_RME96XX is not set
+# CONFIG_SOUND_AD1980 is not set
 
 #
 # USB support
 #
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+# CONFIG_USB_DEVICEFS is not set
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_EHCI_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_UHCI_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH_TTY is not set
+# CONFIG_USB_MIDI is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+# CONFIG_USB_STORAGE is not set
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+CONFIG_USB_HIDINPUT=y
+# CONFIG_HID_FF is not set
+# CONFIG_USB_HIDDEV is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_MTOUCH is not set
+# CONFIG_USB_EGALAX is not set
+# CONFIG_USB_XPAD is not set
+# CONFIG_USB_ATI_REMOTE is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+
+#
+# USB Multimedia devices
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# Video4Linux support is needed for USB Multimedia device support
+#
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_TIGL is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
+# CONFIG_USB_PHIDGETSERVO is not set
+
+#
+# USB ATM/DSL drivers
+#
 
 #
 # USB Gadget Support
@@ -606,6 +814,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -618,7 +827,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -631,6 +841,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -668,6 +879,7 @@
 CONFIG_EXPORTFS=m
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 # CONFIG_CIFS is not set
@@ -728,13 +940,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -748,14 +962,18 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 # CONFIG_CRYPTO_DES is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
 CONFIG_CRYPTO_TWOFISH=y
 # CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 CONFIG_CRYPTO_CRC32C=m
@@ -764,8 +982,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/db1550_defconfig b/arch/mips/configs/db1550_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/configs/db1550_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,906 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:57 2004
+#
+CONFIG_MIPS=y
+# CONFIG_MIPS64 is not set
+# CONFIG_64BIT is not set
+CONFIG_MIPS32=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+
+#
+# Machine selection
+#
+# CONFIG_MACH_JAZZ is not set
+# CONFIG_MACH_VR41XX is not set
+# CONFIG_TOSHIBA_JMR3927 is not set
+# CONFIG_MIPS_COBALT is not set
+# CONFIG_MACH_DECSTATION is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_LASAT is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_MIPS_SEAD is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_MOMENCO_OCELOT_G is not set
+# CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
+# CONFIG_MOMENCO_JAGUAR_ATX is not set
+# CONFIG_PMC_YOSEMITE is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
+# CONFIG_NEC_OSPREY is not set
+# CONFIG_SGI_IP22 is not set
+CONFIG_SOC_AU1X00=y
+# CONFIG_SOC_AU1000 is not set
+# CONFIG_SOC_AU1100 is not set
+# CONFIG_SOC_AU1500 is not set
+CONFIG_SOC_AU1550=y
+# CONFIG_MIPS_PB1000 is not set
+# CONFIG_MIPS_PB1100 is not set
+# CONFIG_MIPS_PB1500 is not set
+# CONFIG_MIPS_PB1550 is not set
+# CONFIG_MIPS_DB1000 is not set
+# CONFIG_MIPS_DB1100 is not set
+# CONFIG_MIPS_DB1500 is not set
+CONFIG_MIPS_DB1550=y
+# CONFIG_MIPS_BOSPORUS is not set
+# CONFIG_MIPS_MIRAGE is not set
+# CONFIG_MIPS_XXS1500 is not set
+# CONFIG_MIPS_MTX1 is not set
+# CONFIG_SIBYTE_SB1xxx_SOC is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_TOSHIBA_RBTX4927 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_HAVE_DEC_LOCK=y
+CONFIG_DMA_COHERENT=y
+CONFIG_MIPS_DISABLE_OBSOLETE_IDE=y
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+# CONFIG_FB is not set
+
+#
+# CPU selection
+#
+CONFIG_CPU_MIPS32=y
+# CONFIG_CPU_MIPS64 is not set
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_TX39XX is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_TX49XX is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R8000 is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_RM9000 is not set
+# CONFIG_CPU_SB1 is not set
+CONFIG_PAGE_SIZE_4KB=y
+# CONFIG_PAGE_SIZE_8KB is not set
+# CONFIG_PAGE_SIZE_16KB is not set
+# CONFIG_PAGE_SIZE_64KB is not set
+CONFIG_CPU_HAS_PREFETCH=y
+# CONFIG_VTAG_ICACHE is not set
+CONFIG_64BIT_PHYS_ADDR=y
+# CONFIG_CPU_ADVANCED is not set
+CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_SYNC=y
+# CONFIG_PREEMPT is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, ISA, TC)
+#
+CONFIG_HW_HAS_PCI=y
+CONFIG_PCI=y
+CONFIG_PCI_LEGACY_PROC=y
+CONFIG_PCI_NAMES=y
+CONFIG_MMU=y
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+CONFIG_PCCARD=m
+# CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=m
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+# CONFIG_YENTA is not set
+# CONFIG_PD6729 is not set
+# CONFIG_I82092 is not set
+# CONFIG_TCIC is not set
+CONFIG_PCMCIA_AU1X00=m
+
+#
+# PCI Hotplug Support
+#
+# CONFIG_HOTPLUG_PCI is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_TRAD_SIGNALS=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_CONCAT is not set
+# CONFIG_MTD_REDBOOT_PARTS is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_CFI_AMDSTD_RETRY=0
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_DB1550=y
+CONFIG_MTD_DB1550_BOOT=y
+CONFIG_MTD_DB1550_USER=y
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLKMTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_AU1550=m
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD 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_UMEM is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECS=m
+# CONFIG_BLK_DEV_IDECD is not set
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+CONFIG_BLK_DEV_IDEPCI=y
+# CONFIG_IDEPCI_SHARE_IRQ is not set
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+# CONFIG_IDEDMA_PCI_AUTO is not set
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_BLK_DEV_CMD64X is not set
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT34X is not set
+# CONFIG_BLK_DEV_HPT366 is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+# CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+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_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+# CONFIG_IPV6 is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+# CONFIG_IP_NF_CONNTRACK is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_QUEUE is not set
+# CONFIG_IP_NF_IPTABLES is not set
+# CONFIG_IP_NF_ARPTABLES is not set
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_MIPS_AU1X00_ENET=y
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
+# CONFIG_HP100 is not set
+# CONFIG_NET_PCI is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+# CONFIG_PPP_FILTER is not set
+CONFIG_PPP_ASYNC=m
+# CONFIG_PPP_SYNC_TTY is not set
+CONFIG_PPP_DEFLATE=m
+# CONFIG_PPP_BSDCOMP is not set
+CONFIG_PPPOE=m
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_AU1X00_GPIO is not set
+# CONFIG_TS_AU1X00_ADS7846 is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_AU1X00=y
+CONFIG_SERIAL_AU1X00_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_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_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# PCMCIA character devices
+#
+CONFIG_SYNCLINK_CS=m
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+# CONFIG_EXT2_FS_SECURITY is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+CONFIG_DEVPTS_FS_XATTR=y
+CONFIG_DEVPTS_FS_SECURITY=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+CONFIG_CRAMFS=m
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+# CONFIG_NFS_V3 is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=m
+# CONFIG_NFSD_V3 is not set
+# CONFIG_NFSD_TCP is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+# CONFIG_SMB_NLS_DEFAULT is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=m
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_DEBUG_KERNEL is not set
+CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE=""
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=y
+# CONFIG_CRYPTO_MD4 is not set
+# CONFIG_CRYPTO_MD5 is not set
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
+# CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+CONFIG_CRYPTO_TWOFISH=y
+# CONFIG_CRYPTO_SERPENT is not set
+CONFIG_CRYPTO_AES=m
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
+# CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=y
+CONFIG_CRYPTO_MICHAEL_MIC=y
+CONFIG_CRYPTO_CRC32C=m
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ddb5476_defconfig b/arch/mips/configs/ddb5476_defconfig
--- a/arch/mips/configs/ddb5476_defconfig	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/configs/ddb5476_defconfig	2004-12-24 13:37:43 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:57 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,7 +51,6 @@
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -62,6 +66,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -69,7 +74,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -114,7 +118,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -140,6 +143,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -170,7 +174,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -188,7 +204,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -257,10 +272,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -278,7 +296,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -407,6 +424,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -441,7 +459,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -461,7 +478,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -472,6 +488,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -488,6 +509,8 @@
 #
 # Graphics support
 #
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
 # CONFIG_FB_CIRRUS is not set
 # CONFIG_FB_PM2 is not set
 # CONFIG_FB_CYBER2000 is not set
@@ -499,6 +522,7 @@
 # CONFIG_FB_RADEON is not set
 # CONFIG_FB_ATY128 is not set
 # CONFIG_FB_ATY is not set
+# CONFIG_FB_SAVAGE is not set
 # CONFIG_FB_SIS is not set
 # CONFIG_FB_NEOMAGIC is not set
 # CONFIG_FB_KYRO is not set
@@ -530,6 +554,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -549,6 +575,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -561,7 +588,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -607,6 +635,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -627,13 +656,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE="ip=any"
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -644,6 +675,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ddb5477_defconfig b/arch/mips/configs/ddb5477_defconfig
--- a/arch/mips/configs/ddb5477_defconfig	2004-12-24 13:37:03 -08:00
+++ b/arch/mips/configs/ddb5477_defconfig	2004-12-24 13:37:03 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:58 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,7 +51,6 @@
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -62,6 +66,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -70,7 +75,6 @@
 CONFIG_DDB5477_BUS_FREQUENCY=0
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -114,7 +118,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -139,6 +142,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -167,7 +171,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -225,10 +241,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -246,7 +265,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -308,7 +326,6 @@
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 # CONFIG_LAN_SAA9730 is not set
 
 #
@@ -322,6 +339,7 @@
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 # CONFIG_TIGON3 is not set
 
 #
@@ -388,6 +406,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -422,7 +441,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -442,7 +460,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -453,6 +470,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -474,7 +496,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -486,6 +507,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -505,6 +528,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=y
 CONFIG_AUTOFS4_FS=y
 
@@ -517,7 +541,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -565,6 +590,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -585,13 +611,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE="ip=any"
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -602,6 +630,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/decstation_defconfig b/arch/mips/configs/decstation_defconfig
--- a/arch/mips/configs/decstation_defconfig	2004-12-24 13:37:01 -08:00
+++ b/arch/mips/configs/decstation_defconfig	2004-12-24 13:37:01 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:58 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -116,7 +121,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_WB=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -138,6 +142,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -161,7 +166,19 @@
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -201,9 +218,8 @@
 #
 CONFIG_SCSI_DECNCR=y
 # CONFIG_SCSI_DECSII is not set
-# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -218,7 +234,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -251,10 +266,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -272,7 +290,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -365,6 +382,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -398,7 +416,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -413,12 +430,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -429,6 +444,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -450,7 +470,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -461,6 +480,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -484,6 +505,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -496,7 +518,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -569,13 +592,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -586,6 +611,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/e55_defconfig b/arch/mips/configs/e55_defconfig
--- a/arch/mips/configs/e55_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/configs/e55_defconfig	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:58 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 CONFIG_MACH_VR41XX=y
 CONFIG_CASIO_E55=y
 # CONFIG_IBM_WORKPAD is not set
@@ -74,6 +79,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -81,7 +87,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -121,7 +126,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -143,6 +147,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -168,7 +173,19 @@
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -186,7 +203,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -220,7 +236,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -251,10 +266,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -272,7 +290,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -380,6 +397,7 @@
 CONFIG_SERIO_I8042=y
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -414,7 +432,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -442,12 +459,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -458,6 +473,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -490,6 +510,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -509,6 +531,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=y
 CONFIG_AUTOFS4_FS=y
 
@@ -521,7 +544,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -568,6 +592,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -588,13 +613,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -605,6 +632,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ev64120_defconfig b/arch/mips/configs/ev64120_defconfig
--- a/arch/mips/configs/ev64120_defconfig	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/configs/ev64120_defconfig	2004-12-24 13:36:48 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:59 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 # CONFIG_KMOD is not set
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -68,6 +73,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -75,7 +81,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -121,7 +126,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -138,7 +142,6 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
-# CONFIG_BINFMT_IRIX is not set
 
 #
 # Device Drivers
@@ -147,6 +150,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -175,7 +179,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -232,10 +248,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -253,7 +272,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -382,6 +400,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -416,7 +435,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -436,7 +454,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -447,6 +464,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -468,7 +490,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -480,6 +501,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -499,6 +522,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -511,7 +535,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -557,6 +582,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -577,13 +603,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs rw nfsroot=192.168.1.1:/mnt/disk2/fs.gal ip=192.168.1.211:192.168.1.1:::gt::"
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -594,6 +622,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+CONFIG_CRC_CCITT=y
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ev96100_defconfig b/arch/mips/configs/ev96100_defconfig
--- a/arch/mips/configs/ev96100_defconfig	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/configs/ev96100_defconfig	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:59 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 # CONFIG_KMOD is not set
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -123,7 +128,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -138,7 +142,6 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
-# CONFIG_BINFMT_IRIX is not set
 
 #
 # Device Drivers
@@ -147,6 +150,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -170,7 +174,19 @@
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -194,7 +210,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -226,10 +241,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -247,7 +265,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -340,6 +357,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -374,7 +392,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -389,12 +406,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -405,6 +420,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -426,7 +446,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -437,6 +456,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -456,6 +477,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -468,7 +490,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -514,6 +537,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -534,13 +558,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -551,6 +577,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ip22_defconfig b/arch/mips/configs/ip22_defconfig
--- a/arch/mips/configs/ip22_defconfig	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/configs/ip22_defconfig	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:59 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,6 +27,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_EMBEDDED=y
@@ -32,11 +35,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,13 +51,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -68,6 +73,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -75,7 +81,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 CONFIG_SGI_IP22=y
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -126,7 +131,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -140,7 +144,6 @@
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=m
 CONFIG_TRAD_SIGNALS=y
-CONFIG_BINFMT_IRIX=y
 
 #
 # Device Drivers
@@ -149,6 +152,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -172,7 +176,19 @@
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -212,9 +228,8 @@
 # SCSI low-level drivers
 #
 CONFIG_SGIWD93_SCSI=y
-# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -229,7 +244,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -263,6 +277,9 @@
 CONFIG_INET_AH=m
 CONFIG_INET_ESP=m
 CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
 
 #
 # IP: Virtual Server Configuration
@@ -302,6 +319,7 @@
 CONFIG_INET6_AH=m
 CONFIG_INET6_ESP=m
 CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
 CONFIG_IPV6_TUNNEL=m
 CONFIG_NETFILTER=y
 # CONFIG_NETFILTER_DEBUG is not set
@@ -310,6 +328,9 @@
 # IP: Netfilter Configuration
 #
 CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_CT_ACCT=y
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
 CONFIG_IP_NF_FTP=m
 CONFIG_IP_NF_IRC=m
 CONFIG_IP_NF_TFTP=m
@@ -334,8 +355,17 @@
 CONFIG_IP_NF_MATCH_STATE=m
 CONFIG_IP_NF_MATCH_CONNTRACK=m
 CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+CONFIG_IP_NF_MATCH_SCTP=m
+CONFIG_IP_NF_MATCH_COMMENT=m
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
 CONFIG_IP_NF_NAT=m
 CONFIG_IP_NF_NAT_NEEDED=y
 CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -354,18 +384,15 @@
 CONFIG_IP_NF_TARGET_DSCP=m
 CONFIG_IP_NF_TARGET_MARK=m
 CONFIG_IP_NF_TARGET_CLASSIFY=m
-CONFIG_IP_NF_TARGET_LOG=m
-CONFIG_IP_NF_TARGET_ULOG=m
-CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
 CONFIG_IP_NF_ARPTABLES=m
 CONFIG_IP_NF_ARPFILTER=m
 CONFIG_IP_NF_ARP_MANGLE=m
-CONFIG_IP_NF_COMPAT_IPCHAINS=m
-CONFIG_IP_NF_COMPAT_IPFWADM=m
-CONFIG_IP_NF_TARGET_NOTRACK=m
-CONFIG_IP_NF_RAW=m
-CONFIG_IP_NF_MATCH_ADDRTYPE=m
-CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
 
 #
 # IPv6: Netfilter Configuration
@@ -414,16 +441,17 @@
 CONFIG_NET_DIVERT=y
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
 #
 CONFIG_NET_SCHED=y
+# CONFIG_NET_SCH_CLK_JIFFIES is not set
+CONFIG_NET_SCH_CLK_GETTIMEOFDAY=y
+# CONFIG_NET_SCH_CLK_CPU is not set
 CONFIG_NET_SCH_CBQ=m
 CONFIG_NET_SCH_HTB=m
 CONFIG_NET_SCH_HFSC=m
-CONFIG_NET_SCH_CSZ=m
 CONFIG_NET_SCH_PRIO=m
 CONFIG_NET_SCH_RED=m
 CONFIG_NET_SCH_SFQ=m
@@ -431,7 +459,7 @@
 CONFIG_NET_SCH_TBF=m
 CONFIG_NET_SCH_GRED=m
 CONFIG_NET_SCH_DSMARK=m
-CONFIG_NET_SCH_DELAY=m
+CONFIG_NET_SCH_NETEM=m
 CONFIG_NET_SCH_INGRESS=m
 CONFIG_NET_QOS=y
 CONFIG_NET_ESTIMATOR=y
@@ -515,7 +543,7 @@
 #
 # Userland interfaces
 #
-CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV=m
 CONFIG_INPUT_MOUSEDEV_PSAUX=y
 CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
 CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
@@ -533,6 +561,7 @@
 CONFIG_SERIO_I8042=y
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -543,7 +572,10 @@
 # CONFIG_KEYBOARD_LKKBD is not set
 # CONFIG_KEYBOARD_XTKBD is not set
 # CONFIG_KEYBOARD_NEWTON is not set
-# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TOUCHSCREEN is not set
 # CONFIG_INPUT_MISC is not set
@@ -569,7 +601,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -588,16 +619,14 @@
 # CONFIG_SOFT_WATCHDOG is not set
 CONFIG_INDYDOG=m
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 CONFIG_SGI_DS1286=m
+# CONFIG_GEN_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
 CONFIG_RAW_DRIVER=m
@@ -609,6 +638,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -630,7 +664,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_SGI_NEWPORT_CONSOLE=y
 CONFIG_DUMMY_CONSOLE=y
 CONFIG_FONT_8x16=y
@@ -652,6 +685,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -684,6 +719,7 @@
 # CONFIG_QFMT_V1 is not set
 CONFIG_QFMT_V2=m
 CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -695,6 +731,7 @@
 CONFIG_ZISOFS=y
 CONFIG_ZISOFS_FS=m
 CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
 
 #
 # DOS/FAT/NT Filesystems
@@ -754,10 +791,17 @@
 CONFIG_SUNRPC=m
 CONFIG_SUNRPC_GSS=m
 CONFIG_RPCSEC_GSS_KRB5=m
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_POSIX is not set
 # CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
 # CONFIG_AFS_FS is not set
 
 #
@@ -827,13 +871,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -841,30 +887,36 @@
 #
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-CONFIG_CRYPTO_MD4=y
-CONFIG_CRYPTO_MD5=y
-CONFIG_CRYPTO_SHA1=y
-CONFIG_CRYPTO_SHA256=y
-CONFIG_CRYPTO_SHA512=y
-CONFIG_CRYPTO_DES=y
-CONFIG_CRYPTO_BLOWFISH=y
-CONFIG_CRYPTO_TWOFISH=y
-CONFIG_CRYPTO_SERPENT=y
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_CRC32C=m
-# CONFIG_CRYPTO_TEST is not set
+CONFIG_CRYPTO_TEST=m
 
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
--- a/arch/mips/configs/ip27_defconfig	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/configs/ip27_defconfig	2004-12-24 13:36:48 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:00 2004
 #
 CONFIG_MIPS=y
 CONFIG_MIPS64=y
@@ -10,11 +12,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
@@ -23,6 +26,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=15
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_EMBEDDED=y
@@ -30,11 +34,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -44,6 +50,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -65,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -75,7 +83,7 @@
 CONFIG_SGI_IP27=y
 # CONFIG_SGI_SN0_N_MODE is not set
 CONFIG_DISCONTIGMEM=y
-# CONFIG_NUMA is not set
+CONFIG_NUMA=y
 # CONFIG_MAPPED_KERNEL is not set
 # CONFIG_REPLICATE_KTEXT is not set
 # CONFIG_REPLICATE_EXHANDLERS is not set
@@ -124,7 +132,6 @@
 CONFIG_SMP=y
 CONFIG_NR_CPUS=64
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_MIPS_INSANE_LARGE is not set
 
 #
@@ -132,6 +139,7 @@
 #
 CONFIG_HW_HAS_PCI=y
 CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
 CONFIG_PCI_LEGACY_PROC=y
 CONFIG_PCI_NAMES=y
 CONFIG_MMU=y
@@ -141,6 +149,7 @@
 #
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
+# CONFIG_BUILD_ELF64 is not set
 CONFIG_MIPS32_COMPAT=y
 CONFIG_COMPAT=y
 CONFIG_MIPS32_O32=y
@@ -154,6 +163,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -178,10 +188,23 @@
 # CONFIG_BLK_CPQ_CISS_DA is not set
 # CONFIG_BLK_DEV_DAC960 is not set
 # CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -226,7 +249,8 @@
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_AIC79XX is not set
-# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
 # CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_BUSLOGIC is not set
 # CONFIG_SCSI_DMX3191D is not set
@@ -235,12 +259,14 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR is not set
 CONFIG_SCSI_QLOGIC_ISP=y
 # CONFIG_SCSI_QLOGIC_FC is not set
 # CONFIG_SCSI_QLOGIC_1280 is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
 # CONFIG_SCSI_QLA21XX is not set
 # CONFIG_SCSI_QLA22XX is not set
@@ -255,7 +281,21 @@
 #
 # Multi-device support (RAID and LVM)
 #
-# CONFIG_MD is not set
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=y
+CONFIG_MD_RAID1=y
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID5=y
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
 
 #
 # Fusion MPT device support
@@ -300,10 +340,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -321,37 +364,38 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
 #
 CONFIG_NET_SCHED=y
-CONFIG_NET_SCH_CBQ=y
-CONFIG_NET_SCH_HTB=y
-CONFIG_NET_SCH_HFSC=y
-CONFIG_NET_SCH_CSZ=y
-CONFIG_NET_SCH_PRIO=y
-CONFIG_NET_SCH_RED=y
-CONFIG_NET_SCH_SFQ=y
-CONFIG_NET_SCH_TEQL=y
-CONFIG_NET_SCH_TBF=y
-CONFIG_NET_SCH_GRED=y
-CONFIG_NET_SCH_DSMARK=y
-CONFIG_NET_SCH_DELAY=y
-# CONFIG_NET_SCH_INGRESS is not set
+# CONFIG_NET_SCH_CLK_JIFFIES is not set
+CONFIG_NET_SCH_CLK_GETTIMEOFDAY=y
+# CONFIG_NET_SCH_CLK_CPU is not set
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
 CONFIG_NET_QOS=y
 CONFIG_NET_ESTIMATOR=y
 CONFIG_NET_CLS=y
-CONFIG_NET_CLS_TCINDEX=y
-CONFIG_NET_CLS_ROUTE4=y
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
 CONFIG_NET_CLS_ROUTE=y
-CONFIG_NET_CLS_FW=y
-CONFIG_NET_CLS_U32=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
 # CONFIG_CLS_U32_PERF is not set
 # CONFIG_NET_CLS_IND is not set
-CONFIG_NET_CLS_RSVP=y
-CONFIG_NET_CLS_RSVP6=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
 # CONFIG_NET_CLS_ACT is not set
 CONFIG_NET_CLS_POLICE=y
 
@@ -465,6 +509,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -497,7 +542,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -509,8 +553,8 @@
 #
 # CONFIG_WATCHDOG is not set
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 CONFIG_SGI_IP27_RTC=y
+# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
@@ -528,6 +572,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -554,6 +603,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -577,11 +628,17 @@
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_SECURITY=y
+CONFIG_XFS_POSIX_ACL=y
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=y
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
 # CONFIG_AUTOFS4_FS is not set
 
 #
@@ -593,7 +650,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -634,13 +692,14 @@
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
+# CONFIG_ROOT_NFS is not set
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 CONFIG_SUNRPC_GSS=y
 CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -675,13 +734,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -695,24 +756,30 @@
 CONFIG_CRYPTO_SHA1=y
 CONFIG_CRYPTO_SHA256=y
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_DES=y
 CONFIG_CRYPTO_BLOWFISH=y
 CONFIG_CRYPTO_TWOFISH=y
 CONFIG_CRYPTO_SERPENT=y
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 CONFIG_CRYPTO_CAST5=y
 CONFIG_CRYPTO_CAST6=y
+CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_ARC4=y
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 CONFIG_CRYPTO_CRC32C=m
-# CONFIG_CRYPTO_TEST is not set
+CONFIG_CRYPTO_TEST=m
 
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ip32_defconfig b/arch/mips/configs/ip32_defconfig
--- a/arch/mips/configs/ip32_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/configs/ip32_defconfig	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:00 2004
 #
 CONFIG_MIPS=y
 CONFIG_MIPS64=y
@@ -10,12 +12,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -60,6 +65,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -114,7 +120,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -130,6 +135,7 @@
 #
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=y
+# CONFIG_BUILD_ELF64 is not set
 CONFIG_MIPS32_COMPAT=y
 CONFIG_COMPAT=y
 CONFIG_MIPS32_O32=y
@@ -143,6 +149,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -172,6 +179,18 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -217,13 +236,13 @@
 CONFIG_SCSI_AIC7XXX=y
 CONFIG_AIC7XXX_CMDS_PER_DEVICE=8
 CONFIG_AIC7XXX_RESET_DELAY_MS=15000
-# CONFIG_AIC7XXX_BUILD_FIRMWARE is not set
 CONFIG_AIC7XXX_DEBUG_ENABLE=y
 CONFIG_AIC7XXX_DEBUG_MASK=0
 CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
 # CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_AIC79XX is not set
-# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
 # CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_BUSLOGIC is not set
 # CONFIG_SCSI_DMX3191D is not set
@@ -232,12 +251,14 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR 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_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
 # CONFIG_SCSI_QLA21XX is not set
 # CONFIG_SCSI_QLA22XX is not set
@@ -296,10 +317,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -317,7 +341,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -442,6 +465,7 @@
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
 # CONFIG_SERIO_MACEPS2 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -476,7 +500,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -496,7 +519,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -507,6 +529,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -528,7 +555,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -540,6 +566,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -559,6 +587,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -571,7 +600,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -584,6 +614,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -618,6 +649,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -648,13 +680,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -665,6 +699,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/it8172_defconfig b/arch/mips/configs/it8172_defconfig
--- a/arch/mips/configs/it8172_defconfig	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/configs/it8172_defconfig	2004-12-24 13:36:19 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:00 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -26,17 +28,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,13 +51,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -69,6 +74,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -76,7 +82,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -120,7 +125,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -143,6 +147,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -170,13 +175,23 @@
 # CONFIG_MTD_JEDECPROBE is not set
 CONFIG_MTD_GEN_PROBE=y
 # CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
 CONFIG_MTD_CFI_INTELEXT=y
 # CONFIG_MTD_CFI_AMDSTD is not set
 # CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
 
 #
 # Mapping drivers for chip access
@@ -185,12 +200,13 @@
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_PHYSMAP_START=0x8000000
 CONFIG_MTD_PHYSMAP_LEN=0x2000000
-CONFIG_MTD_PHYSMAP_BUSWIDTH=4
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
 
 #
 # Self-contained MTD device drivers
 #
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
 # CONFIG_MTD_BLKMTD is not set
 
@@ -223,7 +239,19 @@
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -241,7 +269,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -269,7 +296,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -302,10 +328,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -323,7 +352,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -415,6 +443,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -453,7 +482,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -468,12 +496,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -484,6 +510,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -505,7 +536,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -525,8 +555,6 @@
 # CONFIG_SOUND_BT878 is not set
 # CONFIG_SOUND_FUSION is not set
 # CONFIG_SOUND_CS4281 is not set
-# CONFIG_SOUND_ESSSOLO1 is not set
-# CONFIG_SOUND_MAESTRO is not set
 # CONFIG_SOUND_SONICVIBES is not set
 CONFIG_SOUND_IT8172=y
 # CONFIG_SOUND_TRIDENT is not set
@@ -538,6 +566,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -557,6 +587,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -569,7 +600,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -617,6 +649,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -637,13 +670,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -654,6 +689,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ivr_defconfig b/arch/mips/configs/ivr_defconfig
--- a/arch/mips/configs/ivr_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/configs/ivr_defconfig	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:01 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -26,17 +28,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,13 +51,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -68,6 +73,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -75,7 +81,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -118,7 +123,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -143,6 +147,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -171,7 +176,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -189,7 +206,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -252,10 +268,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -273,7 +292,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -395,6 +413,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -431,7 +450,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -450,7 +468,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -461,6 +478,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -482,7 +504,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -494,6 +515,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -513,6 +536,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -525,7 +549,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -571,6 +596,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -591,13 +617,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -608,6 +636,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/jaguar-atx_defconfig b/arch/mips/configs/jaguar-atx_defconfig
--- a/arch/mips/configs/jaguar-atx_defconfig	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/configs/jaguar-atx_defconfig	2004-12-24 13:37:19 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:01 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 # CONFIG_EXPERIMENTAL is not set
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
@@ -24,6 +26,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_EMBEDDED=y
@@ -31,11 +34,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -43,6 +48,7 @@
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_OBSOLETE_MODPARM=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
@@ -60,6 +66,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 CONFIG_MOMENCO_JAGUAR_ATX=y
 CONFIG_JAGUAR_DMALOW=y
 # CONFIG_PMC_YOSEMITE is not set
@@ -119,7 +126,6 @@
 CONFIG_HIGHMEM=y
 # CONFIG_SMP is not set
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -136,7 +142,6 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
-# CONFIG_BINFMT_IRIX is not set
 
 #
 # Device Drivers
@@ -145,6 +150,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -172,7 +178,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -228,7 +246,12 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_NETFILTER is not set
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
 # CONFIG_BRIDGE is not set
 # CONFIG_VLAN_8021Q is not set
 # CONFIG_DECNET is not set
@@ -293,7 +316,6 @@
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -305,6 +327,7 @@
 # CONFIG_HAMACHI is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 # CONFIG_TIGON3 is not set
 CONFIG_MV643XX_ETH=y
 CONFIG_MV643XX_ETH_0=y
@@ -388,7 +411,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -408,7 +430,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -419,6 +440,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -445,6 +471,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -463,6 +491,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -475,7 +504,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -529,13 +559,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -546,6 +578,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/jmr3927_defconfig b/arch/mips/configs/jmr3927_defconfig
--- a/arch/mips/configs/jmr3927_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/configs/jmr3927_defconfig	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:01 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,7 +51,6 @@
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 CONFIG_TOSHIBA_JMR3927=y
 # CONFIG_MIPS_COBALT is not set
@@ -62,6 +66,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -69,7 +74,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -111,7 +115,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 CONFIG_RTC_DS1742=y
 
 #
@@ -129,7 +132,6 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
-# CONFIG_BINFMT_IRIX is not set
 
 #
 # Device Drivers
@@ -138,6 +140,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -166,7 +169,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -224,10 +239,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -245,7 +263,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -367,6 +384,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -415,7 +433,6 @@
 # CONFIG_UNIX98_PTYS is not set
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -435,7 +452,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -446,6 +462,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -462,6 +483,8 @@
 #
 # Graphics support
 #
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
 # CONFIG_FB_CIRRUS is not set
 # CONFIG_FB_PM2 is not set
 # CONFIG_FB_CYBER2000 is not set
@@ -473,6 +496,7 @@
 # CONFIG_FB_RADEON is not set
 # CONFIG_FB_ATY128 is not set
 # CONFIG_FB_ATY is not set
+# CONFIG_FB_SAVAGE is not set
 # CONFIG_FB_SIS is not set
 # CONFIG_FB_NEOMAGIC is not set
 # CONFIG_FB_KYRO is not set
@@ -486,7 +510,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 # CONFIG_FRAMEBUFFER_CONSOLE is not set
 
@@ -504,6 +527,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -522,6 +547,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -534,7 +560,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -578,6 +605,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -598,13 +626,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -615,6 +645,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/lasat200_defconfig b/arch/mips/configs/lasat200_defconfig
--- a/arch/mips/configs/lasat200_defconfig	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/configs/lasat200_defconfig	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:02 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -71,6 +76,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -78,7 +84,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -124,7 +129,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -149,6 +153,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -177,13 +182,24 @@
 # CONFIG_MTD_JEDECPROBE is not set
 CONFIG_MTD_GEN_PROBE=y
 # CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
 # CONFIG_MTD_CFI_INTELEXT is not set
 CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_CFI_AMDSTD_RETRY=0
 # CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
 
 #
 # Mapping drivers for chip access
@@ -197,6 +213,7 @@
 #
 # CONFIG_MTD_PMC551 is not set
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
 # CONFIG_MTD_BLKMTD is not set
 
@@ -233,7 +250,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -251,7 +280,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -266,7 +294,6 @@
 # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
 CONFIG_IDEDMA_PCI_AUTO=y
 # CONFIG_IDEDMA_ONLYDISK is not set
-CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_AEC62XX is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_BLK_DEV_AMD74XX is not set
@@ -340,10 +367,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -361,7 +391,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -482,6 +511,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -516,7 +546,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -536,7 +565,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -547,6 +575,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -568,7 +601,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -580,6 +612,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -604,6 +638,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -616,7 +651,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -664,6 +700,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -684,13 +721,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -701,6 +740,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
--- a/arch/mips/configs/malta_defconfig	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/configs/malta_defconfig	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:02 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -126,7 +131,6 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -151,6 +155,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -181,7 +186,19 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -238,10 +255,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -259,7 +279,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -321,7 +340,6 @@
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 # CONFIG_LAN_SAA9730 is not set
 
 #
@@ -335,6 +353,7 @@
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 # CONFIG_TIGON3 is not set
 
 #
@@ -401,6 +420,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -435,7 +455,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -454,7 +473,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -465,6 +483,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -486,7 +509,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -498,6 +520,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -517,6 +541,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=y
 # CONFIG_AUTOFS4_FS is not set
 
@@ -529,7 +554,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -579,6 +605,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -599,13 +626,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -616,6 +645,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/mirage_defconfig b/arch/mips/configs/mirage_defconfig
--- a/arch/mips/configs/mirage_defconfig	2004-12-24 13:37:04 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,671 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
-# CONFIG_64BIT is not set
-CONFIG_MIPS32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_HOTPLUG=y
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Machine selection
-#
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SOC_AU1X00 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-# CONFIG_FB is not set
-
-#
-# CPU selection
-#
-CONFIG_CPU_MIPS32=y
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-# CONFIG_CPU_VR41XX is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_8KB is not set
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-CONFIG_CPU_HAS_PREFETCH=y
-# CONFIG_VTAG_ICACHE is not set
-# CONFIG_64BIT_PHYS_ADDR is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_LLSC=y
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_MMU=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_PCMCIA_DEBUG is not set
-# CONFIG_TCIC is not set
-
-#
-# PCI Hotplug Support
-#
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_TRAD_SIGNALS=y
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-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_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-# CONFIG_IPV6 is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-
-#
-# IP: Netfilter Configuration
-#
-# CONFIG_IP_NF_CONNTRACK is not set
-# CONFIG_IP_NF_QUEUE is not set
-# CONFIG_IP_NF_IPTABLES is not set
-# CONFIG_IP_NF_ARPTABLES is not set
-# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-
-#
-# Token Ring devices
-#
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-CONFIG_PPP=m
-CONFIG_PPP_MULTILINK=y
-# CONFIG_PPP_FILTER is not set
-CONFIG_PPP_ASYNC=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-CONFIG_PPPOE=m
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG 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
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-CONFIG_EXT3_FS_SECURITY=y
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-CONFIG_REISERFS_FS_XATTR=y
-CONFIG_REISERFS_FS_POSIX_ACL=y
-CONFIG_REISERFS_FS_SECURITY=y
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=m
-CONFIG_AUTOFS4_FS=m
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-CONFIG_CRAMFS=m
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=m
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=m
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-CONFIG_SMB_FS=m
-# CONFIG_SMB_NLS_DEFAULT is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS=m
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-# CONFIG_CRYPTO_MD4 is not set
-# CONFIG_CRYPTO_MD5 is not set
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-CONFIG_CRYPTO_SHA512=y
-# CONFIG_CRYPTO_DES is not set
-# CONFIG_CRYPTO_BLOWFISH is not set
-CONFIG_CRYPTO_TWOFISH=y
-# CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_ARC4 is not set
-CONFIG_CRYPTO_DEFLATE=y
-CONFIG_CRYPTO_MICHAEL_MIC=y
-CONFIG_CRYPTO_CRC32C=m
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Library routines
-#
-CONFIG_CRC16=m
-CONFIG_CRC32=y
-CONFIG_LIBCRC32C=m
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/mips/configs/mpc30x_defconfig b/arch/mips/configs/mpc30x_defconfig
--- a/arch/mips/configs/mpc30x_defconfig	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/configs/mpc30x_defconfig	2004-12-24 13:37:19 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:02 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 CONFIG_MACH_VR41XX=y
 # CONFIG_CASIO_E55 is not set
 # CONFIG_IBM_WORKPAD is not set
@@ -75,6 +80,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -82,7 +88,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -122,7 +127,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -147,6 +151,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -175,7 +180,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -234,10 +251,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -255,7 +275,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -377,6 +396,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -411,7 +431,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -431,7 +450,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -442,6 +460,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -463,7 +486,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -475,6 +497,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -494,6 +518,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=y
 CONFIG_AUTOFS4_FS=y
 
@@ -506,7 +531,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -552,6 +578,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -572,13 +599,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -592,14 +621,18 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 # CONFIG_CRYPTO_DES is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
 CONFIG_CRYPTO_TWOFISH=y
 # CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 CONFIG_CRYPTO_CRC32C=m
@@ -608,8 +641,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig
--- a/arch/mips/configs/mtx1_defconfig	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,671 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
-# CONFIG_64BIT is not set
-CONFIG_MIPS32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_HOTPLUG=y
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Machine selection
-#
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SOC_AU1X00 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-# CONFIG_FB is not set
-
-#
-# CPU selection
-#
-CONFIG_CPU_MIPS32=y
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-# CONFIG_CPU_VR41XX is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_8KB is not set
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-CONFIG_CPU_HAS_PREFETCH=y
-# CONFIG_VTAG_ICACHE is not set
-# CONFIG_64BIT_PHYS_ADDR is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_LLSC=y
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_MMU=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_PCMCIA_DEBUG is not set
-# CONFIG_TCIC is not set
-
-#
-# PCI Hotplug Support
-#
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_TRAD_SIGNALS=y
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-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_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-# CONFIG_IPV6 is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-
-#
-# IP: Netfilter Configuration
-#
-# CONFIG_IP_NF_CONNTRACK is not set
-# CONFIG_IP_NF_QUEUE is not set
-# CONFIG_IP_NF_IPTABLES is not set
-# CONFIG_IP_NF_ARPTABLES is not set
-# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-
-#
-# Token Ring devices
-#
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-CONFIG_PPP=m
-CONFIG_PPP_MULTILINK=y
-# CONFIG_PPP_FILTER is not set
-CONFIG_PPP_ASYNC=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-CONFIG_PPPOE=m
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG 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
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-CONFIG_EXT3_FS_SECURITY=y
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-CONFIG_REISERFS_FS_XATTR=y
-CONFIG_REISERFS_FS_POSIX_ACL=y
-CONFIG_REISERFS_FS_SECURITY=y
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=m
-CONFIG_AUTOFS4_FS=m
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-CONFIG_CRAMFS=m
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=m
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=m
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-CONFIG_SMB_FS=m
-# CONFIG_SMB_NLS_DEFAULT is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS=m
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-# CONFIG_CRYPTO_MD4 is not set
-# CONFIG_CRYPTO_MD5 is not set
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-CONFIG_CRYPTO_SHA512=y
-# CONFIG_CRYPTO_DES is not set
-# CONFIG_CRYPTO_BLOWFISH is not set
-CONFIG_CRYPTO_TWOFISH=y
-# CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_ARC4 is not set
-CONFIG_CRYPTO_DEFLATE=y
-CONFIG_CRYPTO_MICHAEL_MIC=y
-CONFIG_CRYPTO_CRC32C=m
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Library routines
-#
-CONFIG_CRC16=m
-CONFIG_CRC32=y
-CONFIG_LIBCRC32C=m
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/mips/configs/ocelot_3_defconfig b/arch/mips/configs/ocelot_3_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/configs/ocelot_3_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,846 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:03 2004
+#
+CONFIG_MIPS=y
+# CONFIG_MIPS64 is not set
+# CONFIG_64BIT is not set
+CONFIG_MIPS32=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+CONFIG_MODVERSIONS=y
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Machine selection
+#
+# CONFIG_MACH_JAZZ is not set
+# CONFIG_MACH_VR41XX is not set
+# CONFIG_TOSHIBA_JMR3927 is not set
+# CONFIG_MIPS_COBALT is not set
+# CONFIG_MACH_DECSTATION is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_LASAT is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_MIPS_SEAD is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_MOMENCO_OCELOT_G is not set
+# CONFIG_MOMENCO_OCELOT_C is not set
+CONFIG_MOMENCO_OCELOT_3=y
+# CONFIG_MOMENCO_JAGUAR_ATX is not set
+# CONFIG_PMC_YOSEMITE is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
+# CONFIG_NEC_OSPREY is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SOC_AU1X00 is not set
+# CONFIG_SIBYTE_SB1xxx_SOC is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_TOSHIBA_RBTX4927 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_HAVE_DEC_LOCK=y
+CONFIG_DMA_NONCOHERENT=y
+# CONFIG_CPU_LITTLE_ENDIAN is not set
+CONFIG_IRQ_CPU=y
+CONFIG_IRQ_CPU_RM7K=y
+CONFIG_IRQ_MV64340=y
+CONFIG_PCI_MARVELL=y
+CONFIG_SWAP_IO_SPACE=y
+CONFIG_BOOT_ELF32=y
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+CONFIG_FB=y
+
+#
+# CPU selection
+#
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_TX39XX is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_TX49XX is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R8000 is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_RM7000 is not set
+CONFIG_CPU_RM9000=y
+# CONFIG_CPU_SB1 is not set
+CONFIG_PAGE_SIZE_4KB=y
+# CONFIG_PAGE_SIZE_8KB is not set
+# CONFIG_PAGE_SIZE_16KB is not set
+# CONFIG_PAGE_SIZE_64KB is not set
+CONFIG_BOARD_SCACHE=y
+CONFIG_RM7000_CPU_SCACHE=y
+CONFIG_CPU_HAS_PREFETCH=y
+# CONFIG_64BIT_PHYS_ADDR is not set
+# CONFIG_CPU_ADVANCED is not set
+CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
+CONFIG_CPU_HAS_SYNC=y
+# CONFIG_HIGHMEM is not set
+# CONFIG_SMP is not set
+# CONFIG_PREEMPT is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, ISA, TC)
+#
+CONFIG_HW_HAS_PCI=y
+CONFIG_PCI=y
+CONFIG_PCI_LEGACY_PROC=y
+CONFIG_PCI_NAMES=y
+CONFIG_MMU=y
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_TRAD_SIGNALS=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD 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_UMEM is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_LBD is not set
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=m
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+# CONFIG_BLK_DEV_SD is not set
+# 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_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_3W_9XXX is not set
+# CONFIG_SCSI_ACARD is not set
+# CONFIG_SCSI_AACRAID is not set
+# CONFIG_SCSI_AIC7XXX is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_AIC79XX is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_EATA 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_IPS is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_SYM53C8XX_2 is not set
+# CONFIG_SCSI_IPR 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_QLOGIC_1280_1040 is not set
+CONFIG_SCSI_QLA2XXX=m
+# CONFIG_SCSI_QLA21XX is not set
+# CONFIG_SCSI_QLA22XX is not set
+# CONFIG_SCSI_QLA2300 is not set
+# CONFIG_SCSI_QLA2322 is not set
+# CONFIG_SCSI_QLA6312 is not set
+# CONFIG_SCSI_QLA6322 is not set
+# CONFIG_SCSI_DC395x is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=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=y
+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_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+# CONFIG_IPV6_PRIVACY is not set
+# CONFIG_INET6_AH is not set
+# CONFIG_INET6_ESP is not set
+# CONFIG_INET6_IPCOMP is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_IPV6_TUNNEL is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+# CONFIG_IP_NF_CONNTRACK is not set
+# CONFIG_IP_NF_CONNTRACK_MARK is not set
+# CONFIG_IP_NF_QUEUE is not set
+# CONFIG_IP_NF_IPTABLES is not set
+# CONFIG_IP_NF_ARPTABLES is not set
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
+
+#
+# IPv6: Netfilter Configuration
+#
+# CONFIG_IP6_NF_QUEUE is not set
+# CONFIG_IP6_NF_IPTABLES is not set
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+# CONFIG_ETHERTAP is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+# CONFIG_PCNET32 is not set
+# CONFIG_AMD8111_ETH is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_B44 is not set
+# CONFIG_FORCEDETH is not set
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+CONFIG_E100=y
+# CONFIG_E100_NAPI is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_8139CP is not set
+# CONFIG_8139TOO 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_LAN_SAA9730 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
+# CONFIG_TIGON3 is not set
+CONFIG_MV643XX_ETH=y
+CONFIG_MV643XX_ETH_0=y
+CONFIG_MV643XX_ETH_1=y
+CONFIG_MV643XX_ETH_2=y
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+# CONFIG_PPP_FILTER is not set
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+# CONFIG_PPP_BSDCOMP is not set
+CONFIG_PPPOE=m
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PCIPS2 is not set
+# CONFIG_SERIO_RAW is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG 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_AGP is not set
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+# CONFIG_FB_CIRRUS is not set
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+# CONFIG_FB_RIVA is not set
+# CONFIG_FB_MATROX is not set
+# CONFIG_FB_RADEON_OLD is not set
+# CONFIG_FB_RADEON is not set
+# CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
+# CONFIG_FB_SAVAGE is not set
+# CONFIG_FB_SIS is not set
+# CONFIG_FB_NEOMAGIC is not set
+# CONFIG_FB_KYRO is not set
+# CONFIG_FB_3DFX is not set
+# CONFIG_FB_VOODOO1 is not set
+# CONFIG_FB_TRIDENT is not set
+# CONFIG_FB_E1356 is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_JBD=m
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+# CONFIG_JFS_FS is not set
+CONFIG_XFS_FS=m
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_SECURITY is not set
+# CONFIG_XFS_POSIX_ACL is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=y
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS_XATTR=y
+CONFIG_DEVPTS_FS_SECURITY=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+CONFIG_EFS_FS=y
+CONFIG_CRAMFS=y
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=y
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V4 is not set
+# CONFIG_NFSD_TCP is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+# CONFIG_SMB_NLS_DEFAULT is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=m
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_DEBUG_KERNEL is not set
+CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE="ip=any root=nfs"
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ocelot_c_defconfig b/arch/mips/configs/ocelot_c_defconfig
--- a/arch/mips/configs/ocelot_c_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/configs/ocelot_c_defconfig	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:03 2004
 #
 CONFIG_MIPS=y
 CONFIG_MIPS64=y
@@ -10,12 +12,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -24,17 +26,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -59,6 +64,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 CONFIG_MOMENCO_OCELOT_C=y
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -112,7 +118,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -128,6 +133,7 @@
 #
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
+# CONFIG_BUILD_ELF64 is not set
 CONFIG_MIPS32_COMPAT=y
 CONFIG_COMPAT=y
 CONFIG_MIPS32_O32=y
@@ -141,6 +147,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -169,6 +176,18 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -225,10 +244,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -246,7 +268,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -369,6 +390,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -403,7 +425,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -423,7 +444,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -434,6 +454,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -455,7 +480,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -467,6 +491,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -486,6 +512,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -498,7 +525,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -546,6 +574,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -566,13 +595,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -583,6 +614,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ocelot_defconfig b/arch/mips/configs/ocelot_defconfig
--- a/arch/mips/configs/ocelot_defconfig	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/configs/ocelot_defconfig	2004-12-24 13:36:48 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:04 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,7 +51,6 @@
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -62,6 +66,7 @@
 CONFIG_MOMENCO_OCELOT=y
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -69,7 +74,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -121,7 +125,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -136,7 +139,6 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
-# CONFIG_BINFMT_IRIX is not set
 
 #
 # Device Drivers
@@ -145,6 +147,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -168,7 +171,19 @@
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -192,7 +207,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -224,10 +238,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -245,7 +262,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -337,6 +353,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -371,7 +388,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -386,12 +402,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -402,6 +416,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -423,7 +442,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -434,6 +452,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -453,6 +473,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -465,7 +486,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -513,6 +535,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -533,13 +556,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -550,6 +575,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/ocelot_g_defconfig b/arch/mips/configs/ocelot_g_defconfig
--- a/arch/mips/configs/ocelot_g_defconfig	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/configs/ocelot_g_defconfig	2004-12-24 13:36:55 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:04 2004
 #
 CONFIG_MIPS=y
 CONFIG_MIPS64=y
@@ -10,12 +12,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -24,17 +26,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -59,6 +64,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 CONFIG_MOMENCO_OCELOT_G=y
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -115,7 +121,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -131,6 +136,7 @@
 #
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
+# CONFIG_BUILD_ELF64 is not set
 CONFIG_MIPS32_COMPAT=y
 CONFIG_COMPAT=y
 CONFIG_MIPS32_O32=y
@@ -144,6 +150,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -172,6 +179,18 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -228,10 +247,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=y
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -249,7 +271,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -372,6 +393,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -406,7 +428,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -426,7 +447,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -437,6 +457,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -458,7 +483,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -470,6 +494,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -489,6 +515,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -501,7 +528,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -549,6 +577,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -569,13 +598,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -586,6 +617,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/osprey_defconfig b/arch/mips/configs/osprey_defconfig
--- a/arch/mips/configs/osprey_defconfig	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/configs/osprey_defconfig	2004-12-24 13:37:43 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:04 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 CONFIG_NEC_OSPREY=y
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -115,7 +120,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -136,6 +140,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -159,7 +164,19 @@
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -183,7 +200,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -216,10 +232,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -237,7 +256,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -329,6 +347,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -363,7 +382,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -378,12 +396,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -394,6 +410,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -415,7 +436,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -426,6 +446,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -445,6 +467,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -457,7 +480,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -505,6 +529,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -525,13 +550,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE="ip=bootp ether=46,0x03fe0300,eth0"
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -542,6 +569,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/pb1000_defconfig b/arch/mips/configs/pb1000_defconfig
--- a/arch/mips/configs/pb1000_defconfig	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,671 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
-# CONFIG_64BIT is not set
-CONFIG_MIPS32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_HOTPLUG=y
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Machine selection
-#
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SOC_AU1X00 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-# CONFIG_FB is not set
-
-#
-# CPU selection
-#
-CONFIG_CPU_MIPS32=y
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-# CONFIG_CPU_VR41XX is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_8KB is not set
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-CONFIG_CPU_HAS_PREFETCH=y
-# CONFIG_VTAG_ICACHE is not set
-# CONFIG_64BIT_PHYS_ADDR is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_LLSC=y
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_MMU=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_PCMCIA_DEBUG is not set
-# CONFIG_TCIC is not set
-
-#
-# PCI Hotplug Support
-#
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_TRAD_SIGNALS=y
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-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_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-# CONFIG_IPV6 is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-
-#
-# IP: Netfilter Configuration
-#
-# CONFIG_IP_NF_CONNTRACK is not set
-# CONFIG_IP_NF_QUEUE is not set
-# CONFIG_IP_NF_IPTABLES is not set
-# CONFIG_IP_NF_ARPTABLES is not set
-# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-
-#
-# Token Ring devices
-#
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-CONFIG_PPP=m
-CONFIG_PPP_MULTILINK=y
-# CONFIG_PPP_FILTER is not set
-CONFIG_PPP_ASYNC=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-CONFIG_PPPOE=m
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG 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
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-CONFIG_EXT3_FS_SECURITY=y
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-CONFIG_REISERFS_FS_XATTR=y
-CONFIG_REISERFS_FS_POSIX_ACL=y
-CONFIG_REISERFS_FS_SECURITY=y
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=m
-CONFIG_AUTOFS4_FS=m
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-CONFIG_CRAMFS=m
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=m
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=m
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-CONFIG_SMB_FS=m
-# CONFIG_SMB_NLS_DEFAULT is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS=m
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-# CONFIG_CRYPTO_MD4 is not set
-# CONFIG_CRYPTO_MD5 is not set
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-CONFIG_CRYPTO_SHA512=y
-# CONFIG_CRYPTO_DES is not set
-# CONFIG_CRYPTO_BLOWFISH is not set
-CONFIG_CRYPTO_TWOFISH=y
-# CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_ARC4 is not set
-CONFIG_CRYPTO_DEFLATE=y
-CONFIG_CRYPTO_MICHAEL_MIC=y
-CONFIG_CRYPTO_CRC32C=m
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Library routines
-#
-CONFIG_CRC16=m
-CONFIG_CRC32=y
-CONFIG_LIBCRC32C=m
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/mips/configs/pb1100_defconfig b/arch/mips/configs/pb1100_defconfig
--- a/arch/mips/configs/pb1100_defconfig	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/configs/pb1100_defconfig	2004-12-24 13:36:55 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:05 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,14 +80,32 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SOC_AU1X00 is not set
+CONFIG_SOC_AU1X00=y
+# CONFIG_SOC_AU1000 is not set
+CONFIG_SOC_AU1100=y
+# CONFIG_SOC_AU1500 is not set
+# CONFIG_SOC_AU1550 is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_MIPS_PB1100=y
+# CONFIG_MIPS_PB1500 is not set
+# CONFIG_MIPS_PB1550 is not set
+# CONFIG_MIPS_DB1000 is not set
+# CONFIG_MIPS_DB1100 is not set
+# CONFIG_MIPS_DB1500 is not set
+# CONFIG_MIPS_DB1550 is not set
+# CONFIG_MIPS_BOSPORUS is not set
+# CONFIG_MIPS_MIRAGE is not set
+# CONFIG_MIPS_XXS1500 is not set
+# CONFIG_MIPS_MTX1 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_HAVE_DEC_LOCK=y
+CONFIG_DMA_NONCOHERENT=y
 CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_SWAP_IO_SPACE=y
+# CONFIG_AU1000_USB_DEVICE is not set
 CONFIG_MIPS_L1_CACHE_SHIFT=5
 # CONFIG_FB is not set
 
@@ -116,19 +140,27 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
 #
+CONFIG_HW_HAS_PCI=y
+# CONFIG_PCI is not set
 CONFIG_MMU=y
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=m
+CONFIG_PCCARD=m
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=m
+
+#
+# PC-card bridges
+#
 # CONFIG_TCIC is not set
+# CONFIG_PCMCIA_AU1X00 is not set
 
 #
 # PCI Hotplug Support
@@ -148,13 +180,83 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 
 #
 # Memory Technology Devices (MTD)
 #
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_CONCAT is not set
+# CONFIG_MTD_REDBOOT_PARTS is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_CFI_AMDSTD_RETRY=0
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_PB1100=y
+CONFIG_MTD_PB1500_BOOT=y
+CONFIG_MTD_PB1500_USER=y
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLKMTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
 
 #
 # Parallel port support
@@ -173,7 +275,19 @@
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -197,7 +311,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -231,6 +344,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 
 #
 # IP: Virtual Server Configuration
@@ -244,13 +360,14 @@
 # IP: Netfilter Configuration
 #
 # CONFIG_IP_NF_CONNTRACK is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
 # CONFIG_IP_NF_QUEUE is not set
 # CONFIG_IP_NF_IPTABLES is not set
 # CONFIG_IP_NF_ARPTABLES is not set
 # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
 # CONFIG_IP_NF_COMPAT_IPFWADM is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -268,7 +385,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -297,6 +413,7 @@
 #
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
+# CONFIG_MIPS_AU1X00_ENET is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -318,15 +435,7 @@
 #
 # PCMCIA network device support
 #
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
+# CONFIG_NET_PCMCIA is not set
 
 #
 # Wan interfaces
@@ -380,6 +489,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -397,6 +507,8 @@
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
 # CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_AU1X00_GPIO is not set
+# CONFIG_TS_AU1X00_ADS7846 is not set
 
 #
 # Serial drivers
@@ -406,10 +518,10 @@
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_AU1X00 is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -423,19 +535,17 @@
 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
 
 #
 # PCMCIA character devices
 #
-# CONFIG_SYNCLINK_CS is not set
+CONFIG_SYNCLINK_CS=m
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -444,6 +554,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -465,7 +580,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -476,6 +590,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -508,6 +624,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -520,7 +637,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -533,6 +651,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -546,6 +665,8 @@
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 CONFIG_CRAMFS=m
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -568,6 +689,7 @@
 CONFIG_EXPORTFS=m
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 # CONFIG_CIFS is not set
@@ -628,13 +750,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -648,14 +772,18 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 # CONFIG_CRYPTO_DES is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
 CONFIG_CRYPTO_TWOFISH=y
 # CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 CONFIG_CRYPTO_CRC32C=m
@@ -664,8 +792,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/pb1500_defconfig b/arch/mips/configs/pb1500_defconfig
--- a/arch/mips/configs/pb1500_defconfig	2004-12-24 13:36:33 -08:00
+++ b/arch/mips/configs/pb1500_defconfig	2004-12-24 13:36:33 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:05 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 CONFIG_SOC_AU1X00=y
 # CONFIG_SOC_AU1000 is not set
 # CONFIG_SOC_AU1100 is not set
@@ -97,7 +102,7 @@
 # CONFIG_TOSHIBA_RBTX4927 is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_HAVE_DEC_LOCK=y
-CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_COHERENT=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 # CONFIG_AU1000_USB_DEVICE is not set
 CONFIG_MIPS_L1_CACHE_SHIFT=5
@@ -134,7 +139,6 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -146,10 +150,17 @@
 CONFIG_MMU=y
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=m
+CONFIG_PCCARD=m
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=m
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
 # CONFIG_YENTA is not set
 CONFIG_PD6729=m
 # CONFIG_I82092 is not set
@@ -175,6 +186,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 
@@ -205,7 +217,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -219,12 +243,11 @@
 # CONFIG_BLK_DEV_IDE_SATA is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDECS is not set
+CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -238,7 +261,6 @@
 CONFIG_BLK_DEV_IDEDMA_PCI=y
 # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
 # CONFIG_IDEDMA_PCI_AUTO is not set
-CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_AEC62XX is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_BLK_DEV_AMD74XX is not set
@@ -317,6 +339,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 
 #
 # IP: Virtual Server Configuration
@@ -330,13 +355,14 @@
 # IP: Netfilter Configuration
 #
 # CONFIG_IP_NF_CONNTRACK is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
 # CONFIG_IP_NF_QUEUE is not set
 # CONFIG_IP_NF_IPTABLES is not set
 # CONFIG_IP_NF_ARPTABLES is not set
 # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
 # CONFIG_IP_NF_COMPAT_IPFWADM is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -354,7 +380,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -387,7 +412,7 @@
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
+CONFIG_MII=m
 CONFIG_MIPS_AU1X00_ENET=y
 # CONFIG_HAPPYMEAL is not set
 # CONFIG_SUNGEM is not set
@@ -434,13 +459,13 @@
 #
 CONFIG_NET_PCMCIA=y
 CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
 
 #
 # Wan interfaces
@@ -497,6 +522,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -530,7 +556,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -550,14 +575,13 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
-# CONFIG_SYNCLINK_CS is not set
+CONFIG_SYNCLINK_CS=m
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -566,6 +590,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -592,6 +621,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -624,6 +655,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -636,7 +668,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -649,6 +682,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -684,6 +718,7 @@
 CONFIG_EXPORTFS=m
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 # CONFIG_CIFS is not set
@@ -744,13 +779,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -764,14 +801,18 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 # CONFIG_CRYPTO_DES is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
 CONFIG_CRYPTO_TWOFISH=y
 # CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 # CONFIG_CRYPTO_CRC32C is not set
@@ -780,8 +821,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/pb1550_defconfig b/arch/mips/configs/pb1550_defconfig
--- a/arch/mips/configs/pb1550_defconfig	2004-12-24 13:36:30 -08:00
+++ b/arch/mips/configs/pb1550_defconfig	2004-12-24 13:36:30 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:05 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +72,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +80,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 CONFIG_SOC_AU1X00=y
 # CONFIG_SOC_AU1000 is not set
 # CONFIG_SOC_AU1100 is not set
@@ -97,7 +102,8 @@
 # CONFIG_TOSHIBA_RBTX4927 is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_HAVE_DEC_LOCK=y
-CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_COHERENT=y
+CONFIG_MIPS_DISABLE_OBSOLETE_IDE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
 # CONFIG_FB is not set
@@ -133,7 +139,6 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -145,15 +150,22 @@
 CONFIG_MMU=y
 
 #
-# PCMCIA/CardBus support
+# PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCMCIA=m
+CONFIG_PCCARD=m
 # CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_PCMCIA_OBSOLETE is not set
+CONFIG_PCMCIA=m
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
 # CONFIG_YENTA is not set
 CONFIG_PD6729=m
 # CONFIG_I82092 is not set
 # CONFIG_TCIC is not set
-CONFIG_PCMCIA_AU1X00=m
+# CONFIG_PCMCIA_AU1X00 is not set
 
 #
 # PCI Hotplug Support
@@ -174,6 +186,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 
@@ -204,7 +217,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -218,12 +243,11 @@
 # CONFIG_BLK_DEV_IDE_SATA is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_BLK_DEV_IDECS is not set
+CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -237,7 +261,6 @@
 CONFIG_BLK_DEV_IDEDMA_PCI=y
 # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
 # CONFIG_IDEDMA_PCI_AUTO is not set
-CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_AEC62XX is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_BLK_DEV_AMD74XX is not set
@@ -316,6 +339,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 
 #
 # IP: Virtual Server Configuration
@@ -329,13 +355,14 @@
 # IP: Netfilter Configuration
 #
 # CONFIG_IP_NF_CONNTRACK is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
 # CONFIG_IP_NF_QUEUE is not set
 # CONFIG_IP_NF_IPTABLES is not set
 # CONFIG_IP_NF_ARPTABLES is not set
 # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
 # CONFIG_IP_NF_COMPAT_IPFWADM is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -353,7 +380,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -431,15 +457,7 @@
 #
 # PCMCIA network device support
 #
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
+# CONFIG_NET_PCMCIA is not set
 
 #
 # Wan interfaces
@@ -496,6 +514,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -529,7 +548,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -549,14 +567,13 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
-# CONFIG_SYNCLINK_CS is not set
+CONFIG_SYNCLINK_CS=m
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -565,6 +582,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -591,6 +613,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -623,6 +647,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -635,7 +660,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -648,6 +674,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -683,6 +710,7 @@
 CONFIG_EXPORTFS=m
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 # CONFIG_CIFS is not set
@@ -743,13 +771,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -763,14 +793,18 @@
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 # CONFIG_CRYPTO_DES is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
 CONFIG_CRYPTO_TWOFISH=y
 # CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 CONFIG_CRYPTO_CRC32C=m
@@ -779,8 +813,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig
--- a/arch/mips/configs/rm200_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/configs/rm200_defconfig	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:06 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
@@ -26,6 +28,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_EMBEDDED=y
@@ -33,11 +36,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -47,13 +52,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -69,6 +74,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -76,7 +82,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 CONFIG_SNI_RM200_PCI=y
@@ -127,7 +132,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -154,6 +158,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -221,10 +226,23 @@
 CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_CRYPTOLOOP=m
 CONFIG_BLK_DEV_NBD=m
-# CONFIG_BLK_DEV_SX8 is not set
+CONFIG_BLK_DEV_SX8=m
+CONFIG_BLK_DEV_UB=m
 CONFIG_BLK_DEV_RAM=m
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -275,7 +293,9 @@
 # CONFIG_SCSI_AIC79XX is not set
 # CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_IN2000 is not set
-# CONFIG_SCSI_MEGARAID is not set
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
 # CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_BUSLOGIC is not set
 # CONFIG_SCSI_DMX3191D is not set
@@ -287,6 +307,7 @@
 # CONFIG_SCSI_GENERIC_NCR5380 is not set
 # CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 CONFIG_SCSI_PPA=m
 CONFIG_SCSI_IMM=m
@@ -305,6 +326,7 @@
 # CONFIG_SCSI_QLOGIC_ISP is not set
 # CONFIG_SCSI_QLOGIC_FC is not set
 # CONFIG_SCSI_QLOGIC_1280 is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
 # CONFIG_SCSI_QLA21XX is not set
 # CONFIG_SCSI_QLA22XX is not set
@@ -333,14 +355,16 @@
 CONFIG_MD_LINEAR=m
 CONFIG_MD_RAID0=m
 CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
 CONFIG_MD_RAID5=m
 # CONFIG_MD_RAID6 is not set
 CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
 CONFIG_BLK_DEV_DM=m
 # CONFIG_DM_CRYPT is not set
-# CONFIG_DM_SNAPSHOT is not set
-# CONFIG_DM_MIRROR is not set
-# CONFIG_DM_ZERO is not set
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
 
 #
 # Fusion MPT device support
@@ -385,6 +409,9 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
 
 #
 # IP: Virtual Server Configuration
@@ -395,6 +422,7 @@
 CONFIG_INET6_AH=m
 CONFIG_INET6_ESP=m
 CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
 CONFIG_IPV6_TUNNEL=m
 CONFIG_NETFILTER=y
 # CONFIG_NETFILTER_DEBUG is not set
@@ -404,6 +432,9 @@
 # IP: Netfilter Configuration
 #
 CONFIG_IP_NF_CONNTRACK=m
+# CONFIG_IP_NF_CT_ACCT is not set
+CONFIG_IP_NF_CONNTRACK_MARK=y
+CONFIG_IP_NF_CT_PROTO_SCTP=m
 CONFIG_IP_NF_FTP=m
 CONFIG_IP_NF_IRC=m
 CONFIG_IP_NF_TFTP=m
@@ -429,8 +460,17 @@
 CONFIG_IP_NF_MATCH_CONNTRACK=m
 CONFIG_IP_NF_MATCH_OWNER=m
 CONFIG_IP_NF_MATCH_PHYSDEV=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+CONFIG_IP_NF_MATCH_SCTP=m
+CONFIG_IP_NF_MATCH_COMMENT=m
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
 CONFIG_IP_NF_NAT=m
 CONFIG_IP_NF_NAT_NEEDED=y
 CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -449,18 +489,15 @@
 CONFIG_IP_NF_TARGET_DSCP=m
 CONFIG_IP_NF_TARGET_MARK=m
 CONFIG_IP_NF_TARGET_CLASSIFY=m
-CONFIG_IP_NF_TARGET_LOG=m
-CONFIG_IP_NF_TARGET_ULOG=m
-CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
 CONFIG_IP_NF_ARPTABLES=m
 CONFIG_IP_NF_ARPFILTER=m
 CONFIG_IP_NF_ARP_MANGLE=m
-CONFIG_IP_NF_COMPAT_IPCHAINS=m
-CONFIG_IP_NF_COMPAT_IPFWADM=m
-CONFIG_IP_NF_TARGET_NOTRACK=m
-CONFIG_IP_NF_RAW=m
-# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
-# CONFIG_IP_NF_MATCH_REALM is not set
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
 
 #
 # IPv6: Netfilter Configuration
@@ -480,6 +517,7 @@
 CONFIG_IP6_NF_MATCH_AHESP=m
 CONFIG_IP6_NF_MATCH_LENGTH=m
 CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_MATCH_PHYSDEV=m
 CONFIG_IP6_NF_FILTER=m
 CONFIG_IP6_NF_TARGET_LOG=m
 CONFIG_IP6_NF_MANGLE=m
@@ -524,7 +562,6 @@
 CONFIG_BRIDGE=m
 # CONFIG_VLAN_8021Q is not set
 CONFIG_DECNET=m
-# CONFIG_DECNET_SIOCGIFCONF is not set
 # CONFIG_DECNET_ROUTER is not set
 # CONFIG_LLC2 is not set
 # CONFIG_IPX is not set
@@ -534,16 +571,17 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
 #
 CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_CLK_JIFFIES=y
+# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
+# CONFIG_NET_SCH_CLK_CPU is not set
 CONFIG_NET_SCH_CBQ=m
 CONFIG_NET_SCH_HTB=m
 CONFIG_NET_SCH_HFSC=m
-CONFIG_NET_SCH_CSZ=m
 CONFIG_NET_SCH_PRIO=m
 CONFIG_NET_SCH_RED=m
 CONFIG_NET_SCH_SFQ=m
@@ -551,7 +589,7 @@
 CONFIG_NET_SCH_TBF=m
 CONFIG_NET_SCH_GRED=m
 CONFIG_NET_SCH_DSMARK=m
-CONFIG_NET_SCH_DELAY=m
+CONFIG_NET_SCH_NETEM=m
 CONFIG_NET_SCH_INGRESS=m
 CONFIG_NET_QOS=y
 CONFIG_NET_ESTIMATOR=y
@@ -665,7 +703,6 @@
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 # CONFIG_LAN_SAA9730 is not set
 # CONFIG_NET_POCKET is not set
 
@@ -680,6 +717,7 @@
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+CONFIG_VIA_VELOCITY=m
 # CONFIG_TIGON3 is not set
 
 #
@@ -749,6 +787,7 @@
 # CONFIG_SERIO_CT82C710 is not set
 CONFIG_SERIO_PARKBD=m
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -801,7 +840,6 @@
 # CONFIG_LP_CONSOLE is not set
 CONFIG_PPDEV=m
 CONFIG_TIPAR=m
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -821,7 +859,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -832,6 +869,16 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+CONFIG_W1=m
+CONFIG_W1_MATROX=m
+CONFIG_W1_DS9490=m
+CONFIG_W1_DS9490R_BRIDGE=m
+CONFIG_W1_THERM=m
+CONFIG_W1_SMEM=m
+
+#
 # Misc devices
 #
 
@@ -873,6 +920,9 @@
 CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Host Controller Drivers
@@ -901,7 +951,7 @@
 CONFIG_USB_STORAGE_JUMPSHOT=y
 
 #
-# USB Human Interface Devices (HID)
+# USB Input Devices
 #
 CONFIG_USB_HID=m
 CONFIG_USB_HIDINPUT=y
@@ -942,7 +992,7 @@
 #
 
 #
-# USB Network adaptors
+# USB Network Adapters
 #
 CONFIG_USB_CATC=m
 CONFIG_USB_KAWETH=m
@@ -959,6 +1009,7 @@
 CONFIG_USB_GENESYS=y
 CONFIG_USB_NET1080=y
 CONFIG_USB_PL2301=y
+CONFIG_USB_KC2190=y
 
 #
 # Intelligent USB Devices/Gadgets
@@ -986,6 +1037,7 @@
 CONFIG_USB_SERIAL_BELKIN=m
 CONFIG_USB_SERIAL_WHITEHEAT=m
 CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
 CONFIG_USB_SERIAL_EMPEG=m
 CONFIG_USB_SERIAL_FTDI_SIO=m
 CONFIG_USB_SERIAL_VISOR=m
@@ -993,6 +1045,7 @@
 CONFIG_USB_SERIAL_IR=m
 CONFIG_USB_SERIAL_EDGEPORT=m
 CONFIG_USB_SERIAL_EDGEPORT_TI=m
+# CONFIG_USB_SERIAL_IPW is not set
 CONFIG_USB_SERIAL_KEYSPAN_PDA=m
 CONFIG_USB_SERIAL_KEYSPAN=m
 CONFIG_USB_SERIAL_KEYSPAN_MPR=y
@@ -1030,26 +1083,18 @@
 CONFIG_USB_LCD=m
 CONFIG_USB_LED=m
 CONFIG_USB_CYTHERM=m
+CONFIG_USB_PHIDGETKIT=m
 CONFIG_USB_PHIDGETSERVO=m
 CONFIG_USB_TEST=m
 
 #
+# USB ATM/DSL drivers
+#
+
+#
 # USB Gadget Support
 #
-CONFIG_USB_GADGET=m
-CONFIG_USB_GADGET_NET2280=y
-CONFIG_USB_NET2280=m
-# CONFIG_USB_GADGET_PXA2XX is not set
-# CONFIG_USB_GADGET_GOKU is not set
-# CONFIG_USB_GADGET_SA1100 is not set
-# CONFIG_USB_GADGET_DUMMY_HCD is not set
-CONFIG_USB_GADGET_DUALSPEED=y
-CONFIG_USB_ZERO=m
-CONFIG_USB_ETH=m
-# CONFIG_USB_ETH_RNDIS is not set
-CONFIG_USB_GADGETFS=m
-# CONFIG_USB_FILE_STORAGE is not set
-# CONFIG_USB_G_SERIAL is not set
+# CONFIG_USB_GADGET is not set
 
 #
 # File systems
@@ -1069,10 +1114,7 @@
 CONFIG_REISERFS_FS_XATTR=y
 CONFIG_REISERFS_FS_POSIX_ACL=y
 CONFIG_REISERFS_FS_SECURITY=y
-CONFIG_JFS_FS=m
-# CONFIG_JFS_POSIX_ACL is not set
-# CONFIG_JFS_DEBUG is not set
-# CONFIG_JFS_STATISTICS is not set
+# CONFIG_JFS_FS is not set
 CONFIG_FS_POSIX_ACL=y
 CONFIG_XFS_FS=m
 # CONFIG_XFS_RT is not set
@@ -1083,6 +1125,7 @@
 CONFIG_ROMFS_FS=m
 # CONFIG_QUOTA is not set
 CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -1094,6 +1137,7 @@
 CONFIG_ZISOFS=y
 CONFIG_ZISOFS_FS=m
 CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
 
 #
 # DOS/FAT/NT Filesystems
@@ -1158,10 +1202,12 @@
 CONFIG_SUNRPC=m
 CONFIG_SUNRPC_GSS=m
 CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
 CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 CONFIG_CIFS=m
 # CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_XATTR is not set
 # CONFIG_CIFS_POSIX is not set
 CONFIG_NCP_FS=m
 CONFIG_NCPFS_PACKET_SIGNING=y
@@ -1225,7 +1271,7 @@
 CONFIG_NLS_ISO8859_8=m
 CONFIG_NLS_CODEPAGE_1250=m
 CONFIG_NLS_CODEPAGE_1251=m
-# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ASCII=m
 CONFIG_NLS_ISO8859_1=m
 CONFIG_NLS_ISO8859_2=m
 CONFIG_NLS_ISO8859_3=m
@@ -1244,13 +1290,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -1264,6 +1312,7 @@
 CONFIG_CRYPTO_SHA1=m
 CONFIG_CRYPTO_SHA256=m
 CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_DES=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_TWOFISH=m
@@ -1271,7 +1320,10 @@
 CONFIG_CRYPTO_AES=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=m
 CONFIG_CRYPTO_MICHAEL_MIC=m
 # CONFIG_CRYPTO_CRC32C is not set
@@ -1280,8 +1332,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=m
 CONFIG_ZLIB_DEFLATE=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/sb1250-swarm_defconfig b/arch/mips/configs/sb1250-swarm_defconfig
--- a/arch/mips/configs/sb1250-swarm_defconfig	2004-12-24 13:37:32 -08:00
+++ b/arch/mips/configs/sb1250-swarm_defconfig	2004-12-24 13:37:32 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:06 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,11 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -24,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=15
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -44,6 +50,7 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -51,7 +58,6 @@
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -67,6 +73,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -74,7 +81,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 CONFIG_SIBYTE_SB1xxx_SOC=y
 CONFIG_SIBYTE_SWARM=y
@@ -149,7 +155,6 @@
 CONFIG_SMP=y
 CONFIG_NR_CPUS=2
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -166,12 +171,6 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
-# CONFIG_BINFMT_IRIX is not set
-
-#
-# MIPS initrd options
-#
-# CONFIG_EMBEDDED_RAMDISK is not set
 
 #
 # Device Drivers
@@ -180,6 +179,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -210,7 +210,19 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=9220
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -228,7 +240,6 @@
 CONFIG_BLK_DEV_IDETAPE=y
 CONFIG_BLK_DEV_IDEFLOPPY=y
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -292,10 +303,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -313,7 +327,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -347,7 +360,6 @@
 #
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=y
-CONFIG_NET_SB1250_MAC=y
 # CONFIG_HAPPYMEAL is not set
 # CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
@@ -369,6 +381,7 @@
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
+CONFIG_NET_SB1250_MAC=y
 # CONFIG_SK98LIN is not set
 # CONFIG_TIGON3 is not set
 
@@ -428,6 +441,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -458,7 +472,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -488,6 +501,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -514,6 +532,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -537,6 +557,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -549,7 +570,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -595,6 +617,7 @@
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -615,14 +638,16 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SB1XXX_CORELIS is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -636,14 +661,18 @@
 CONFIG_CRYPTO_SHA1=y
 CONFIG_CRYPTO_SHA256=y
 CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_DES=y
 CONFIG_CRYPTO_BLOWFISH=y
 CONFIG_CRYPTO_TWOFISH=y
 CONFIG_CRYPTO_SERPENT=y
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_TEA=m
 # CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=y
 # CONFIG_CRYPTO_CRC32C is not set
@@ -652,8 +681,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/sead_defconfig b/arch/mips/configs/sead_defconfig
--- a/arch/mips/configs/sead_defconfig	2004-12-24 13:36:59 -08:00
+++ b/arch/mips/configs/sead_defconfig	2004-12-24 13:36:59 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:06 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 # CONFIG_SYSVIPC is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
@@ -30,11 +32,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,7 +49,6 @@
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -61,6 +64,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -68,7 +72,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -113,7 +116,6 @@
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -128,18 +130,13 @@
 CONFIG_TRAD_SIGNALS=y
 
 #
-# MIPS initrd options
-#
-CONFIG_EMBEDDED_RAMDISK=y
-CONFIG_EMBEDDED_RAMDISK_IMAGE="ramdisk.gz"
-
-#
 # Device Drivers
 #
 
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -165,7 +162,19 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=18432
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=y
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -189,7 +198,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -237,6 +245,7 @@
 # CONFIG_SERIO_I8042 is not set
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=y
 
 #
 # Input Device Drivers
@@ -271,7 +280,6 @@
 # CONFIG_UNIX98_PTYS is not set
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -286,12 +294,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -302,6 +308,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -322,7 +333,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -333,6 +343,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -356,6 +368,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -368,7 +381,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -413,13 +427,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -430,6 +446,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=y
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/tb0226_defconfig b/arch/mips/configs/tb0226_defconfig
--- a/arch/mips/configs/tb0226_defconfig	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/configs/tb0226_defconfig	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:07 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 CONFIG_MACH_VR41XX=y
 # CONFIG_CASIO_E55 is not set
 # CONFIG_IBM_WORKPAD is not set
@@ -73,6 +78,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -80,7 +86,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -120,7 +125,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -143,6 +147,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -168,7 +173,19 @@
 CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=m
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -187,7 +204,6 @@
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 CONFIG_BLK_DEV_IDESCSI=y
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -230,9 +246,8 @@
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -247,7 +262,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -270,7 +284,6 @@
 CONFIG_IP_MULTICAST=y
 CONFIG_IP_ADVANCED_ROUTER=y
 CONFIG_IP_MULTIPLE_TABLES=y
-CONFIG_IP_ROUTE_NAT=y
 CONFIG_IP_ROUTE_MULTIPATH=y
 CONFIG_IP_ROUTE_VERBOSE=y
 CONFIG_IP_PNP=y
@@ -285,8 +298,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -304,7 +322,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -403,6 +420,7 @@
 CONFIG_SERIO_I8042=y
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -437,7 +455,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -452,12 +469,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -468,6 +483,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -484,13 +504,14 @@
 #
 # Graphics support
 #
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
 # CONFIG_FB_VIRTUAL is not set
 
 #
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 # CONFIG_FRAMEBUFFER_CONSOLE is not set
 
@@ -517,6 +538,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -536,6 +559,7 @@
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=m
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 CONFIG_AUTOFS4_FS=y
 
@@ -568,6 +592,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -605,6 +630,7 @@
 CONFIG_EXPORTFS=m
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
 CONFIG_SMB_NLS_DEFAULT=y
 CONFIG_SMB_NLS_REMOTE="cp932"
@@ -666,13 +692,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -683,8 +711,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/tb0229_defconfig b/arch/mips/configs/tb0229_defconfig
--- a/arch/mips/configs/tb0229_defconfig	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/configs/tb0229_defconfig	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:07 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 CONFIG_MACH_VR41XX=y
 # CONFIG_CASIO_E55 is not set
 # CONFIG_IBM_WORKPAD is not set
@@ -75,6 +80,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -82,7 +88,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -123,7 +128,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -148,6 +152,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -179,7 +184,19 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -227,7 +244,6 @@
 CONFIG_IP_MULTICAST=y
 CONFIG_IP_ADVANCED_ROUTER=y
 CONFIG_IP_MULTIPLE_TABLES=y
-CONFIG_IP_ROUTE_NAT=y
 CONFIG_IP_ROUTE_MULTIPATH=y
 CONFIG_IP_ROUTE_VERBOSE=y
 CONFIG_IP_PNP=y
@@ -243,10 +259,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -264,7 +283,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -396,6 +414,7 @@
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -430,7 +449,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -450,7 +468,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -461,6 +478,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -482,7 +504,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
 #
@@ -494,6 +515,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -526,6 +549,7 @@
 CONFIG_ROMFS_FS=m
 # CONFIG_QUOTA is not set
 CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 CONFIG_AUTOFS4_FS=y
 
@@ -558,6 +582,7 @@
 CONFIG_DEVPTS_FS_XATTR=y
 CONFIG_DEVPTS_FS_SECURITY=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -595,6 +620,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
 CONFIG_SMB_NLS_DEFAULT=y
 CONFIG_SMB_NLS_REMOTE="cp932"
@@ -656,13 +682,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -673,8 +701,10 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+CONFIG_CRC_CCITT=m
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=m
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/workpad_defconfig b/arch/mips/configs/workpad_defconfig
--- a/arch/mips/configs/workpad_defconfig	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/configs/workpad_defconfig	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:12:08 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,17 +27,20 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -45,13 +50,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 CONFIG_MACH_VR41XX=y
 # CONFIG_CASIO_E55 is not set
 CONFIG_IBM_WORKPAD=y
@@ -74,6 +79,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -81,7 +87,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -121,7 +126,6 @@
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -143,6 +147,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -168,7 +173,19 @@
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -186,7 +203,6 @@
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -220,7 +236,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -251,10 +266,13 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
+CONFIG_XFRM_USER=m
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -272,7 +290,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -380,6 +397,7 @@
 CONFIG_SERIO_I8042=y
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -414,7 +432,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -442,12 +459,10 @@
 # CONFIG_GEN_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
 # CONFIG_RAW_DRIVER is not set
@@ -458,6 +473,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -490,6 +510,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -513,6 +535,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=y
 CONFIG_AUTOFS4_FS=y
 
@@ -525,7 +548,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -572,6 +596,7 @@
 CONFIG_EXPORTFS=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
@@ -592,13 +617,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -609,6 +636,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/configs/xxs1500_defconfig b/arch/mips/configs/xxs1500_defconfig
--- a/arch/mips/configs/xxs1500_defconfig	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,671 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
-# CONFIG_64BIT is not set
-CONFIG_MIPS32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_HOTPLUG=y
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Machine selection
-#
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SOC_AU1X00 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-# CONFIG_FB is not set
-
-#
-# CPU selection
-#
-CONFIG_CPU_MIPS32=y
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-# CONFIG_CPU_VR41XX is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_8KB is not set
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-CONFIG_CPU_HAS_PREFETCH=y
-# CONFIG_VTAG_ICACHE is not set
-# CONFIG_64BIT_PHYS_ADDR is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_LLSC=y
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_MMU=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-# CONFIG_PCMCIA_DEBUG is not set
-# CONFIG_TCIC is not set
-
-#
-# PCI Hotplug Support
-#
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_TRAD_SIGNALS=y
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-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_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-# CONFIG_IPV6 is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-
-#
-# IP: Netfilter Configuration
-#
-# CONFIG_IP_NF_CONNTRACK is not set
-# CONFIG_IP_NF_QUEUE is not set
-# CONFIG_IP_NF_IPTABLES is not set
-# CONFIG_IP_NF_ARPTABLES is not set
-# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-
-#
-# Token Ring devices
-#
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-CONFIG_PCMCIA_3C589=m
-# CONFIG_PCMCIA_3C574 is not set
-# CONFIG_PCMCIA_FMVJ18X is not set
-# CONFIG_PCMCIA_PCNET is not set
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-CONFIG_PPP=m
-CONFIG_PPP_MULTILINK=y
-# CONFIG_PPP_FILTER is not set
-CONFIG_PPP_ASYNC=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-# CONFIG_PPP_BSDCOMP is not set
-CONFIG_PPPOE=m
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG 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
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-CONFIG_EXT3_FS_SECURITY=y
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-CONFIG_REISERFS_FS_XATTR=y
-CONFIG_REISERFS_FS_POSIX_ACL=y
-CONFIG_REISERFS_FS_SECURITY=y
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=m
-CONFIG_AUTOFS4_FS=m
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-CONFIG_CRAMFS=m
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=m
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=m
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-CONFIG_SMB_FS=m
-# CONFIG_SMB_NLS_DEFAULT is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS=m
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-# CONFIG_CRYPTO_MD4 is not set
-# CONFIG_CRYPTO_MD5 is not set
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-CONFIG_CRYPTO_SHA512=y
-# CONFIG_CRYPTO_DES is not set
-# CONFIG_CRYPTO_BLOWFISH is not set
-CONFIG_CRYPTO_TWOFISH=y
-# CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_ARC4 is not set
-CONFIG_CRYPTO_DEFLATE=y
-CONFIG_CRYPTO_MICHAEL_MIC=y
-# CONFIG_CRYPTO_CRC32C is not set
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Library routines
-#
-CONFIG_CRC16=m
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/mips/configs/yosemite_defconfig b/arch/mips/configs/yosemite_defconfig
--- a/arch/mips/configs/yosemite_defconfig	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/configs/yosemite_defconfig	2004-12-24 13:37:19 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Fri Nov 26 00:00:39 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 # CONFIG_EXPERIMENTAL is not set
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
@@ -24,18 +26,22 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -43,7 +49,9 @@
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
 
 #
 # Machine selection
@@ -60,6 +68,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 CONFIG_PMC_YOSEMITE=y
 # CONFIG_HYPERTRANSPORT is not set
@@ -76,6 +85,7 @@
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
 CONFIG_IRQ_CPU_RM7K=y
+CONFIG_SWAP_IO_SPACE=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
 # CONFIG_FB is not set
 
@@ -110,9 +120,9 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 CONFIG_HIGHMEM=y
-# CONFIG_SMP is not set
+CONFIG_SMP=y
+CONFIG_NR_CPUS=2
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -129,7 +139,6 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
-# CONFIG_BINFMT_IRIX is not set
 
 #
 # Device Drivers
@@ -138,7 +147,9 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -165,7 +176,19 @@
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -222,7 +245,12 @@
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_NETFILTER is not set
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
 # CONFIG_BRIDGE is not set
 # CONFIG_VLAN_8021Q is not set
 # CONFIG_DECNET is not set
@@ -362,7 +390,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -382,7 +409,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -393,6 +419,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -419,6 +450,8 @@
 # USB support
 #
 # CONFIG_USB is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Gadget Support
@@ -437,6 +470,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -449,7 +483,8 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -460,6 +495,7 @@
 CONFIG_SYSFS=y
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -503,13 +539,26 @@
 #
 # Kernel hacking
 #
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_HIGHMEM is not set
+# CONFIG_DEBUG_INFO is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_KGDB is not set
+# CONFIG_RUNTIME_DEBUG is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -520,6 +569,8 @@
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/ddb5xxx/common/Makefile b/arch/mips/ddb5xxx/common/Makefile
--- a/arch/mips/ddb5xxx/common/Makefile	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/ddb5xxx/common/Makefile	2004-12-24 13:37:29 -08:00
@@ -2,4 +2,4 @@
 # Makefile for the common code of NEC DDB-Vrc5xxx board
 #
 
-obj-y	 += irq.o nile4.o prom.o rtc_ds1386.o
+obj-y	 += nile4.o prom.o rtc_ds1386.o
diff -Nru a/arch/mips/ddb5xxx/common/irq.c b/arch/mips/ddb5xxx/common/irq.c
--- a/arch/mips/ddb5xxx/common/irq.c	2004-12-24 13:37:04 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,47 +0,0 @@
-/*
- * 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>
-#include <asm/irq.h>
-
-void (*irq_setup)(void);
-
-#ifdef CONFIG_KGDB
-static int kgdb_flag = 1;
-static int __init nokgdb(char *str)
-{
-	kgdb_flag = 0;
-	return 1;
-}
-__setup("nokgdb", nokgdb);
-#endif
-
-void __init init_IRQ(void)
-{
-#ifdef CONFIG_KGDB
-	extern void breakpoint(void);
-	extern void set_debug_traps(void);
-
-	if (kgdb_flag) {
-		printk("Wait for gdb client connection ...\n");
-		set_debug_traps();
-		breakpoint();
-	}
-#endif
-	/* set up default irq controller */
-	init_generic_irq();
-
-	/* invoke board-specific irq setup */
-	irq_setup();
-}
diff -Nru a/arch/mips/ddb5xxx/ddb5074/irq.c b/arch/mips/ddb5xxx/ddb5074/irq.c
--- a/arch/mips/ddb5xxx/ddb5074/irq.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/ddb5xxx/ddb5074/irq.c	2004-12-24 13:37:29 -08:00
@@ -134,14 +134,8 @@
 	printk("ddb_8254timer_irq called\n");
 }
 
-void __init ddb_irq_setup(void)
+void __init arch_init_irq(void)
 {
-#ifdef CONFIG_KGDB
-	if (remote_debug)
-		set_debug_traps();
-	breakpoint();		/* you may move this line to whereever you want :-) */
-#endif
-
 	/* setup cascade interrupts */
 	setup_irq(NILE4_IRQ_BASE  + NILE4_INT_INTE, &irq_cascade);
 	setup_irq(CPU_IRQ_BASE + CPU_NILE4_CASCADE, &irq_cascade);
@@ -163,6 +157,4 @@
 
 	/* Enable the interrupt cascade */
 	nile4_enable_irq(NILE4_IRQ_BASE+IRQ_I8259_CASCADE);
-
-
 }
diff -Nru a/arch/mips/ddb5xxx/ddb5074/nile4_pic.c b/arch/mips/ddb5xxx/ddb5074/nile4_pic.c
--- a/arch/mips/ddb5xxx/ddb5074/nile4_pic.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/ddb5xxx/ddb5074/nile4_pic.c	2004-12-24 13:36:47 -08:00
@@ -222,7 +222,6 @@
 void nile4_irq_setup(u32 base) {
 
 	int i;
-	extern irq_desc_t irq_desc[];
 
 	irq_base=base;
 
@@ -258,7 +257,6 @@
 		irq_desc[i].depth = 1;
 		irq_desc[i].handler = &nile4_irq_controller;
 	}
-
 }
 
 #if defined(CONFIG_RUNTIME_DEBUG)
diff -Nru a/arch/mips/ddb5xxx/ddb5074/setup.c b/arch/mips/ddb5xxx/ddb5074/setup.c
--- a/arch/mips/ddb5xxx/ddb5074/setup.c	2004-12-24 13:37:04 -08:00
+++ b/arch/mips/ddb5xxx/ddb5074/setup.c	2004-12-24 13:37:04 -08:00
@@ -26,11 +26,6 @@
 #include <asm/ddb5xxx/ddb5074.h>
 #include <asm/ddb5xxx/ddb5xxx.h>
 
-#ifdef CONFIG_KGDB
-extern void rs_kgdb_hook(int);
-extern void breakpoint(void);
-#endif
-
 static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
 
 static void ddb_machine_restart(char *command)
@@ -63,7 +58,6 @@
 	} while (1);
 }
 
-extern void ddb_irq_setup(void);
 extern void rtc_ds1386_init(unsigned long base);
 
 extern void (*board_timer_setup) (struct irqaction * irq);
@@ -96,7 +90,6 @@
 {
 	extern int panic_timeout;
 
-	irq_setup = ddb_irq_setup;
 	set_io_port_base(NILE4_PCI_IO_BASE);
 	isa_slot_offset = NILE4_PCI_MEM_BASE;
 	board_timer_setup = ddb_timer_init;
diff -Nru a/arch/mips/ddb5xxx/ddb5476/irq.c b/arch/mips/ddb5xxx/ddb5476/irq.c
--- a/arch/mips/ddb5xxx/ddb5476/irq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/ddb5xxx/ddb5476/irq.c	2004-12-24 13:37:18 -08:00
@@ -115,7 +115,7 @@
 extern void mips_cpu_irq_init(u32 irq_base);
 extern void vrc5476_irq_init(u32 irq_base);
 
-void __init ddb5476_irq_setup(void)
+void __init arch_init_irq(void)
 {
 	/* hardware initialization */
 	nile4_irq_setup();
diff -Nru a/arch/mips/ddb5xxx/ddb5476/setup.c b/arch/mips/ddb5xxx/ddb5476/setup.c
--- a/arch/mips/ddb5xxx/ddb5476/setup.c	2004-12-24 13:37:01 -08:00
+++ b/arch/mips/ddb5xxx/ddb5476/setup.c	2004-12-24 13:37:01 -08:00
@@ -36,10 +36,6 @@
 #define TIMER_IRQ			(VRC5476_IRQ_BASE + VRC5476_IRQ_GPT)
 #endif
 
-#ifdef CONFIG_KGDB
-extern void breakpoint(void);
-#endif
-
 static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
 
 static void ddb_machine_restart(char *command)
@@ -70,7 +66,6 @@
 	while (1);
 }
 
-extern void ddb_irq_setup(void);
 extern void rtc_ds1386_init(unsigned long base);
 
 static void __init ddb_time_init(void)
@@ -129,14 +124,11 @@
 
 
 static void ddb5476_board_init(void);
-extern void ddb5476_irq_setup(void);
-extern void (*irq_setup)(void);
 
 static void __init ddb5476_setup(void)
 {
 	extern int panic_timeout;
 
-	irq_setup = ddb5476_irq_setup;
 	set_io_port_base(KSEG1ADDR(DDB_PCI_IO_BASE));
 
 	board_time_init = ddb_time_init;
diff -Nru a/arch/mips/ddb5xxx/ddb5476/vrc5476_irq.c b/arch/mips/ddb5xxx/ddb5476/vrc5476_irq.c
--- a/arch/mips/ddb5xxx/ddb5476/vrc5476_irq.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/ddb5xxx/ddb5476/vrc5476_irq.c	2004-12-24 13:37:19 -08:00
@@ -66,15 +66,14 @@
 void __init
 vrc5476_irq_init(u32 base)
 {
-	extern irq_desc_t irq_desc[];
 	u32 i;
 
 	irq_base = base;
 	for (i= base; i< base + NUM_VRC5476_IRQ; i++) {
 		irq_desc[i].status = IRQ_DISABLED;
 		irq_desc[i].action = NULL;
-		 irq_desc[i].depth = 1;
-		 irq_desc[i].handler = &vrc5476_irq_controller;
+		irq_desc[i].depth = 1;
+		irq_desc[i].handler = &vrc5476_irq_controller;
 	}
 }
 
diff -Nru a/arch/mips/ddb5xxx/ddb5477/irq.c b/arch/mips/ddb5xxx/ddb5477/irq.c
--- a/arch/mips/ddb5xxx/ddb5477/irq.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/ddb5xxx/ddb5477/irq.c	2004-12-24 13:36:18 -08:00
@@ -79,11 +79,8 @@
 extern int setup_irq(unsigned int irq, struct irqaction *irqaction);  
 static struct irqaction irq_cascade = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL };
 
-void
-ddb5477_irq_setup(void)
+void __init arch_init_irq(void)
 {
-	db_run(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);
diff -Nru a/arch/mips/ddb5xxx/ddb5477/irq_5477.c b/arch/mips/ddb5xxx/ddb5477/irq_5477.c
--- a/arch/mips/ddb5xxx/ddb5477/irq_5477.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/ddb5xxx/ddb5477/irq_5477.c	2004-12-24 13:36:31 -08:00
@@ -100,10 +100,8 @@
 	NULL			/* no affinity stuff for UP */
 };
 
-void
-vrc5477_irq_init(u32 irq_base)
+void __init 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++) {
diff -Nru a/arch/mips/ddb5xxx/ddb5477/setup.c b/arch/mips/ddb5xxx/ddb5477/setup.c
--- a/arch/mips/ddb5xxx/ddb5477/setup.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/ddb5xxx/ddb5477/setup.c	2004-12-24 13:37:19 -08:00
@@ -3,6 +3,8 @@
  * Copyright 2001 MontaVista Software Inc.
  * Author: jsun@mvista.com or jsun@junsun.net
  *
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
+ *
  * arch/mips/ddb5xxx/ddb5477/setup.c
  *     Setup file for DDB5477.
  *
@@ -35,7 +37,6 @@
 #include <asm/gdb-stub.h>
 #include <asm/traps.h>
 #include <asm/debug.h>
-#include <asm/pci_channel.h>
 
 #include <asm/ddb5xxx/ddb5xxx.h>
 
@@ -165,8 +166,6 @@
 }
 
 static void ddb5477_board_init(void);
-extern void ddb5477_irq_setup(void);
-extern void (*irq_setup)(void);
 
 extern struct pci_controller ddb5477_ext_controller;
 extern struct pci_controller ddb5477_io_controller;
@@ -178,7 +177,6 @@
 	/* initialize board - we don't trust the loader */
         ddb5477_board_init();
 
-	irq_setup = ddb5477_irq_setup;
 	set_io_port_base(KSEG1ADDR(DDB_PCI_IO_BASE));
 
 	board_time_init = ddb_time_init;
diff -Nru a/arch/mips/dec/boot/decstation.c b/arch/mips/dec/boot/decstation.c
--- a/arch/mips/dec/boot/decstation.c	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/dec/boot/decstation.c	2004-12-24 13:36:55 -08:00
@@ -26,7 +26,6 @@
 #define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
 
 extern int _ftext, _end;		/* begin and end of kernel image */
-extern void *__rd_start, *__rd_end;	/* begin and end of ramdisk image */
 extern void kernel_entry(int, char **, unsigned long, int *);
 
 void * memcpy(void * dest, const void *src, unsigned int count)
@@ -80,12 +79,6 @@
 		rex_clear_cache = (void (*)(void)) * (prom_vec + REX_PROM_CLEARCACHE);
 		rex_clear_cache();
 	}
-
-#ifdef CONFIG_BLK_DEV_INITRD
-	LOADER_TYPE = 1;
-	INITRD_START = (long)&__rd_start;
-	INITRD_SIZE = (long)&__rd_end - (long)&__rd_start;
-#endif
 
 	kernel_entry(argc, argv, magic, prom_vec);
 }
diff -Nru a/arch/mips/dec/setup.c b/arch/mips/dec/setup.c
--- a/arch/mips/dec/setup.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/dec/setup.c	2004-12-24 13:36:47 -08:00
@@ -48,11 +48,6 @@
 
 extern asmlinkage void decstation_handle_int(void);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-extern unsigned long initrd_start, initrd_end;
-extern void * __rd_start, * __rd_end;
-#endif
-
 spinlock_t ioasic_ssr_lock;
 
 volatile u32 *ioasic_base;
@@ -136,11 +131,6 @@
 
 static void __init decstation_setup(void)
 {
-#ifdef CONFIG_BLK_DEV_INITRD
-       ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
-       initrd_start = (unsigned long)&__rd_start;
-       initrd_end = (unsigned long)&__rd_end;
-#endif
 	board_be_init = dec_be_init;
 	board_time_init = dec_time_init;
 	board_timer_setup = dec_timer_setup;
@@ -701,7 +691,7 @@
 }				/* dec_init_kn03 */
 
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	switch (mips_machtype) {
 	case MACH_DS23100:	/* DS2100/DS3100 Pmin/Pmax */
diff -Nru a/arch/mips/defconfig b/arch/mips/defconfig
--- a/arch/mips/defconfig	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/defconfig	2004-12-24 13:36:18 -08:00
@@ -1,5 +1,7 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc2
+# Sun Nov 21 14:11:54 2004
 #
 CONFIG_MIPS=y
 # CONFIG_MIPS64 is not set
@@ -11,12 +13,12 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
@@ -25,6 +27,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_EMBEDDED=y
@@ -32,11 +35,13 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
@@ -46,13 +51,13 @@
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 
 #
 # Machine selection
 #
 # CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
 # CONFIG_MACH_VR41XX is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_MIPS_COBALT is not set
@@ -68,6 +73,7 @@
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_MOMENCO_OCELOT_G is not set
 # CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_3 is not set
 # CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_PMC_YOSEMITE is not set
 # CONFIG_DDB5074 is not set
@@ -75,7 +81,6 @@
 # CONFIG_DDB5477 is not set
 # CONFIG_NEC_OSPREY is not set
 CONFIG_SGI_IP22=y
-# CONFIG_SGI_IP32 is not set
 # CONFIG_SOC_AU1X00 is not set
 # CONFIG_SIBYTE_SB1xxx_SOC is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -126,7 +131,6 @@
 CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
 # CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -140,7 +144,6 @@
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=m
 CONFIG_TRAD_SIGNALS=y
-CONFIG_BINFMT_IRIX=y
 
 #
 # Device Drivers
@@ -149,6 +152,7 @@
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
@@ -172,7 +176,19 @@
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -212,9 +228,8 @@
 # SCSI low-level drivers
 #
 CONFIG_SGIWD93_SCSI=y
-# CONFIG_SCSI_AIC7XXX_OLD is not set
 # CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_QLOGIC_1280_1040 is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -229,7 +244,6 @@
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
@@ -263,6 +277,9 @@
 CONFIG_INET_AH=m
 CONFIG_INET_ESP=m
 CONFIG_INET_IPCOMP=m
+CONFIG_INET_TUNNEL=m
+CONFIG_IP_TCPDIAG=m
+CONFIG_IP_TCPDIAG_IPV6=y
 
 #
 # IP: Virtual Server Configuration
@@ -302,6 +319,7 @@
 CONFIG_INET6_AH=m
 CONFIG_INET6_ESP=m
 CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_TUNNEL=m
 CONFIG_IPV6_TUNNEL=m
 CONFIG_NETFILTER=y
 # CONFIG_NETFILTER_DEBUG is not set
@@ -310,6 +328,9 @@
 # IP: Netfilter Configuration
 #
 CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_CT_ACCT=y
+CONFIG_IP_NF_CONNTRACK_MARK=y
+# CONFIG_IP_NF_CT_PROTO_SCTP is not set
 CONFIG_IP_NF_FTP=m
 CONFIG_IP_NF_IRC=m
 CONFIG_IP_NF_TFTP=m
@@ -334,8 +355,17 @@
 CONFIG_IP_NF_MATCH_STATE=m
 CONFIG_IP_NF_MATCH_CONNTRACK=m
 CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+CONFIG_IP_NF_MATCH_SCTP=m
+CONFIG_IP_NF_MATCH_COMMENT=m
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
 CONFIG_IP_NF_NAT=m
 CONFIG_IP_NF_NAT_NEEDED=y
 CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -354,18 +384,15 @@
 CONFIG_IP_NF_TARGET_DSCP=m
 CONFIG_IP_NF_TARGET_MARK=m
 CONFIG_IP_NF_TARGET_CLASSIFY=m
-CONFIG_IP_NF_TARGET_LOG=m
-CONFIG_IP_NF_TARGET_ULOG=m
-CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_TARGET_NOTRACK=m
 CONFIG_IP_NF_ARPTABLES=m
 CONFIG_IP_NF_ARPFILTER=m
 CONFIG_IP_NF_ARP_MANGLE=m
-CONFIG_IP_NF_COMPAT_IPCHAINS=m
-CONFIG_IP_NF_COMPAT_IPFWADM=m
-CONFIG_IP_NF_TARGET_NOTRACK=m
-CONFIG_IP_NF_RAW=m
-CONFIG_IP_NF_MATCH_ADDRTYPE=m
-CONFIG_IP_NF_MATCH_REALM=m
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
 
 #
 # IPv6: Netfilter Configuration
@@ -414,16 +441,17 @@
 CONFIG_NET_DIVERT=y
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
 #
 CONFIG_NET_SCHED=y
+# CONFIG_NET_SCH_CLK_JIFFIES is not set
+CONFIG_NET_SCH_CLK_GETTIMEOFDAY=y
+# CONFIG_NET_SCH_CLK_CPU is not set
 CONFIG_NET_SCH_CBQ=m
 CONFIG_NET_SCH_HTB=m
 CONFIG_NET_SCH_HFSC=m
-CONFIG_NET_SCH_CSZ=m
 CONFIG_NET_SCH_PRIO=m
 CONFIG_NET_SCH_RED=m
 CONFIG_NET_SCH_SFQ=m
@@ -431,7 +459,7 @@
 CONFIG_NET_SCH_TBF=m
 CONFIG_NET_SCH_GRED=m
 CONFIG_NET_SCH_DSMARK=m
-CONFIG_NET_SCH_DELAY=m
+CONFIG_NET_SCH_NETEM=m
 CONFIG_NET_SCH_INGRESS=m
 CONFIG_NET_QOS=y
 CONFIG_NET_ESTIMATOR=y
@@ -515,7 +543,7 @@
 #
 # Userland interfaces
 #
-CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV=m
 CONFIG_INPUT_MOUSEDEV_PSAUX=y
 CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
 CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
@@ -533,6 +561,7 @@
 CONFIG_SERIO_I8042=y
 CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_CT82C710 is not set
+CONFIG_SERIO_RAW=m
 
 #
 # Input Device Drivers
@@ -543,7 +572,10 @@
 # CONFIG_KEYBOARD_LKKBD is not set
 # CONFIG_KEYBOARD_XTKBD is not set
 # CONFIG_KEYBOARD_NEWTON is not set
-# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_SERIAL=m
+# CONFIG_MOUSE_VSXXXAA is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TOUCHSCREEN is not set
 # CONFIG_INPUT_MISC is not set
@@ -569,7 +601,6 @@
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -588,16 +619,14 @@
 # CONFIG_SOFT_WATCHDOG is not set
 CONFIG_INDYDOG=m
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 CONFIG_SGI_DS1286=m
+# CONFIG_GEN_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
 CONFIG_RAW_DRIVER=m
@@ -609,6 +638,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -630,7 +664,6 @@
 # Console display driver support
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
 CONFIG_SGI_NEWPORT_CONSOLE=y
 CONFIG_DUMMY_CONSOLE=y
 CONFIG_FONT_8x16=y
@@ -652,6 +685,8 @@
 #
 # USB support
 #
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
 # USB Gadget Support
@@ -684,6 +719,7 @@
 # CONFIG_QFMT_V1 is not set
 CONFIG_QFMT_V2=m
 CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -695,6 +731,7 @@
 CONFIG_ZISOFS=y
 CONFIG_ZISOFS_FS=m
 CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
 
 #
 # DOS/FAT/NT Filesystems
@@ -754,10 +791,17 @@
 CONFIG_SUNRPC=m
 CONFIG_SUNRPC_GSS=m
 CONFIG_RPCSEC_GSS_KRB5=m
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_POSIX is not set
 # CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
 # CONFIG_AFS_FS is not set
 
 #
@@ -827,13 +871,15 @@
 #
 # Kernel hacking
 #
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
 CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
 
 #
 # Security options
 #
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
 
 #
@@ -841,30 +887,36 @@
 #
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-CONFIG_CRYPTO_MD4=y
-CONFIG_CRYPTO_MD5=y
-CONFIG_CRYPTO_SHA1=y
-CONFIG_CRYPTO_SHA256=y
-CONFIG_CRYPTO_SHA512=y
-CONFIG_CRYPTO_DES=y
-CONFIG_CRYPTO_BLOWFISH=y
-CONFIG_CRYPTO_TWOFISH=y
-CONFIG_CRYPTO_SERPENT=y
-CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_CRC32C=m
-# CONFIG_CRYPTO_TEST is not set
+CONFIG_CRYPTO_TEST=m
 
 #
 # Library routines
 #
-CONFIG_CRC16=m
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
diff -Nru a/arch/mips/galileo-boards/ev96100/irq.c b/arch/mips/galileo-boards/ev96100/irq.c
--- a/arch/mips/galileo-boards/ev96100/irq.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/galileo-boards/ev96100/irq.c	2004-12-24 13:37:19 -08:00
@@ -59,9 +59,8 @@
 	do_IRQ(ffz8(pending >> 8), regs);
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	set_except_vector(0, ev96100IRQ);
-	init_generic_irq();
 	mips_cpu_irq_init(0);
 }
diff -Nru a/arch/mips/galileo-boards/ev96100/time.c b/arch/mips/galileo-boards/ev96100/time.c
--- a/arch/mips/galileo-boards/ev96100/time.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/galileo-boards/ev96100/time.c	2004-12-24 13:36:49 -08:00
@@ -73,6 +73,9 @@
 	do {
 		kstat_this_cpu.irqs[irq]++;
 		do_timer(regs);
+#ifndef CONFIG_SMP
+		update_process_times(user_mode(regs));
+#endif
 		r4k_cur += r4k_offset;
 		ack_r4ktimer(r4k_cur);
 
diff -Nru a/arch/mips/gt64120/common/time.c b/arch/mips/gt64120/common/time.c
--- a/arch/mips/gt64120/common/time.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/gt64120/common/time.c	2004-12-24 13:37:19 -08:00
@@ -36,6 +36,9 @@
 		handled = 1;
 		irq_src &= ~0x00000800;
 		do_timer(regs);
+#ifndef CONFIG_SMP
+		update_process_times(user_mode(regs));
+#endif
 	}
 
 	GT_WRITE(GT_INTRCAUSE_OFS, 0);
@@ -62,7 +65,6 @@
  */
 void gt64120_time_init(void)
 {
-	extern irq_desc_t irq_desc[NR_IRQS];
 	static struct irqaction timer;
 
 	/* Disable timer first */
diff -Nru a/arch/mips/gt64120/ev64120/irq.c b/arch/mips/gt64120/ev64120/irq.c
--- a/arch/mips/gt64120/ev64120/irq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/gt64120/ev64120/irq.c	2004-12-24 13:37:18 -08:00
@@ -39,7 +39,7 @@
 #include <linux/timex.h>
 #include <linux/slab.h>
 #include <linux/random.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
@@ -128,7 +128,7 @@
 	set_c0_status(IE_IRQ2);
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	int i;
 
diff -Nru a/arch/mips/gt64120/momenco_ocelot/dbg_io.c b/arch/mips/gt64120/momenco_ocelot/dbg_io.c
--- a/arch/mips/gt64120/momenco_ocelot/dbg_io.c	2004-12-24 13:37:30 -08:00
+++ b/arch/mips/gt64120/momenco_ocelot/dbg_io.c	2004-12-24 13:37:30 -08:00
@@ -1,6 +1,6 @@
 #include <linux/config.h>
 
-#if defined(CONFIG_KGDB)
+#ifdef CONFIG_KGDB
 
 #include <asm/serial.h> /* For the serial port location and base baud */
 
diff -Nru a/arch/mips/gt64120/momenco_ocelot/irq.c b/arch/mips/gt64120/momenco_ocelot/irq.c
--- a/arch/mips/gt64120/momenco_ocelot/irq.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/gt64120/momenco_ocelot/irq.c	2004-12-24 13:36:17 -08:00
@@ -41,7 +41,7 @@
 #include <linux/timex.h>
 #include <linux/slab.h>
 #include <linux/random.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -51,7 +51,7 @@
 
 extern asmlinkage void ocelot_handle_int(void);
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	/*
 	 * Clear all of the interrupts while we change the able around a bit.
@@ -63,13 +63,6 @@
 	/* Sets the first-level interrupt dispatcher. */
 	set_except_vector(0, ocelot_handle_int);
 
-	init_generic_irq();
 	mips_cpu_irq_init(0);
 	rm7k_cpu_irq_init(8);
-
-#ifdef CONFIG_KGDB
-	printk("start kgdb ...\n");
-	set_debug_traps();
-	breakpoint();	/* you may move this line to whereever you want :-) */
-#endif
 }
diff -Nru a/arch/mips/hp-lj/Makefile b/arch/mips/hp-lj/Makefile
--- a/arch/mips/hp-lj/Makefile	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,26 +0,0 @@
-#
-# Makefile for the HP specific kernel interface routines
-# under Linux.
-#
-
-obj-y   := init.o setup.o irq.o int-handler.o utils.o asic.o
-
-obj-$(CONFIG_KGDB) += gdb_hook.o
-obj-$(CONFIG_DIRECT_PRINTK) += gdb_hook.o
-
-obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
-
-forceit:
-
-# package filesystem from rootfs directory into binary package
-romfs.bin: forceit ./rootfs
-	@genromfs -d ./rootfs -f $@
-
-# transform rootfs.bin into object file format for linking
-initrd.o: romfs.bin
-	@echo "" | $(CROSS_COMPILE)as -o $@
-	@$(CROSS_COMPILE)objcopy --add-section .initrd=$< $@
-
-EXTRA_AFLAGS := $(CFLAGS)
-
-.PHONY: forceit
diff -Nru a/arch/mips/hp-lj/asic.c b/arch/mips/hp-lj/asic.c
--- a/arch/mips/hp-lj/asic.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,28 +0,0 @@
-
-
-#include "asm/hp-lj/asic.h"
-
-AsicId GetAsicId(void)
-{
-   static int asic = IllegalAsic;
-
-   if (asic == IllegalAsic) {
-      if (*(unsigned int *)0xbff70000 == 0x1114103c)
-         asic = HarmonyAsic;
-      else if (*(unsigned int *)0xbff80000 == 0x110d103c)
-         asic = AndrosAsic;
-      else
-	 asic = UnknownAsic;
-   }
-   return asic;
-}
-
-
-const char* const GetAsicName(void)
-{
-   static const char* const Names[] =
-        { "Illegal", "Unknown", "Andros", "Harmony" };
-
-   return Names[(int)GetAsicId()];
-}
-
diff -Nru a/arch/mips/hp-lj/gdb_hook.c b/arch/mips/hp-lj/gdb_hook.c
--- a/arch/mips/hp-lj/gdb_hook.c	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,99 +0,0 @@
-/*
- * 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>
-#include <asm/hp-lj/asic.h>
-
-
-int putDebugChar(char c);
-char getDebugChar(void);
-
-
-///////////////////////  andros values ///////////////////////////////////////////////////////
-#define SERIAL_REG(offset) (*((volatile unsigned int*)(HPSR_BASE_ADDR|offset)))
-
-// Register set base address
-#define HPSR_BASE_ADDR   0xbfe00000UL
-
-// Transmit / Receive Data
-#define HPSR_DATA_OFFSET    0x00020010UL
-// Transmit control / status
-#define HPSR_TX_STAT_OFFSET 0x0002000CUL
-// Receive status
-#define HPSR_RX_STAT_OFFSET 0x00020008UL
-
-#define HPSR_TX_STAT_READY  0x8UL
-#define HPSR_RX_DATA_AVAIL  0x4UL
-
-
-///////////////////////  harmony values ///////////////////////////////////////////////////////
-// Transmit / Receive Data
-#define H_HPSR_DATA_TX       *((volatile unsigned int*)0xbff65014)
-// Transmit / Receive Data
-#define H_HPSR_DATA_RX       *((volatile unsigned int*)0xbff65018)
-// Status
-#define H_HPSR_STAT          *((volatile unsigned int*)0xbff65004)
-
-// harmony serial status bits
-#define H_SER_STAT_TX_EMPTY       0x04
-#define H_SER_STAT_RX_EMPTY       0x10
-
-
-
-
-int putDebugChar(char c)
-{
-	if (GetAsicId() == HarmonyAsic) {
-		while (!( ( (H_HPSR_STAT) & H_SER_STAT_TX_EMPTY) != 0));
-
-		H_HPSR_DATA_TX = (unsigned int) c;
-
-	} else if (GetAsicId() == AndrosAsic) {
-        	while (((SERIAL_REG(HPSR_TX_STAT_OFFSET) & HPSR_TX_STAT_READY) == 0))
-             		;
-        	SERIAL_REG(HPSR_DATA_OFFSET) = (unsigned int) c;
-        }
-	return 1;
-}
-
-char getDebugChar(void)
-{
-	if (GetAsicId() == HarmonyAsic) {
-		while (!(((H_HPSR_STAT) & H_SER_STAT_RX_EMPTY) == 0));
-
-	        return H_HPSR_DATA_RX;
-
-	} else if (GetAsicId() == AndrosAsic) {
-        	while ((SERIAL_REG(HPSR_RX_STAT_OFFSET) & HPSR_RX_DATA_AVAIL) == 0)
-              		;
-
-        	return (SERIAL_REG(HPSR_DATA_OFFSET));
-
-	}
-}
-
-
diff -Nru a/arch/mips/hp-lj/init.c b/arch/mips/hp-lj/init.c
--- a/arch/mips/hp-lj/init.c	2004-12-24 13:36:59 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,50 +0,0 @@
-/*
- * init.c: PROM library initialisation code.
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-
-#include <linux/mm.h>
-#include <asm/bootinfo.h>
-#include <asm/addrspace.h>
-#include <asm/hp-lj/asic.h>
-#include <linux/bootmem.h>
-
-#include "utils.h"
-
-
-#define Delimiter "CMDLINE="
-const char CommandLine[] = Delimiter
-  "root=/dev/hda3                                                                                                                                                                                                                                            ";
-
-void __init prom_init(void)
-{
-	ulong mem_size = get_mem_avail();
-        int reserve_size = 0;
-
-	printk("Total Memory: %ld bytes\n", mem_size);
-
-	reserve_buffer(CommandLine, mem_size);
-
-	reserve_size = get_reserved_buffer_size();
-	mem_size -= reserve_size;
-
-	add_memory_region(0x0,mem_size, BOOT_MEM_RAM);
-        add_memory_region(mem_size,reserve_size, BOOT_MEM_RESERVED);
-
-	printk("Main Memory: %ld bytes\n", mem_size);
-	printk("Reserved Memory: %ld bytes at 0x%08x\n",
-		get_reserved_buffer_size(), (ulong)get_reserved_buffer());
-
-	printk("Detected %s ASIC\n", GetAsicName());
-	mips_machgroup  = MACH_GROUP_HP_LJ;
-	mips_machtype   = MACH_UNKNOWN;
-
-	strcpy(arcs_cmdline, CommandLine+strlen(Delimiter));
-}
-
-
-unsigned long __init prom_free_prom_memory(void)
-{
-	return 0;
-}
diff -Nru a/arch/mips/hp-lj/int-handler.S b/arch/mips/hp-lj/int-handler.S
--- a/arch/mips/hp-lj/int-handler.S	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,70 +0,0 @@
-#include <asm/asm.h>
-
-#include <asm/mipsregs.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-
-	.text
-	.set    mips1
-	.set    reorder
-	.set    macro
-	.set    noat
-	.align	5
-
-# MIPS has 16 exception vectors numbered 0 to 15
-# vector number 0 is for interrupts and the others are for various exceptions
-# The following code is installed as the handler for exception 0
-# There are 8 possible interrupts that can cause this exception.
-# The cause register indicates which are pending
-# The status register indicates which are enabled
-# This code segment basically will decipher which interrup occurred (7 downto 0)
-# and pass an integer indicating which was the highest priority pending interrupt
-# to the do_IRQ routine.
-
-NESTED(hpIRQ, PT_SIZE, sp)
-	SAVE_ALL
-	CLI				# Important: mark KERNEL mode !
-	/*
-	 * Get pending interrupts
-	 */
-
-	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
-	sll	t0,16			# shift the pending bits down
-	beqz	t0,3f			# no pending intrs, then spurious
-	nop				# delay slot
-
-	/*
-	 * Find irq with highest priority
-	 * FIXME: This is slow - use binary search
-	 */
-
-	la	a0,7
-1:	bltz	t0,2f			# found pending irq
-	subu	a0,1
-	sll	t0,1
-	b	1b
-	nop				# delay slot
-
-
-call_do_IRQ:
-2:	move	a1,sp
-	jal	do_IRQ
-	nop				# delay slot
-	j       ret_from_irq
-	nop
-
-/*
-	mfc0	t0,CP0_STATUS		# disable interrupts
-	ori	t0,1
-	xori	t0,1
-	mtc0	t0,CP0_STATUS
-
-	la      a1, ret_from_irq
-	jr	a1
-*/
-3:	j	spurious_interrupt
-END(hpIRQ)
-
diff -Nru a/arch/mips/hp-lj/irq.c b/arch/mips/hp-lj/irq.c
--- a/arch/mips/hp-lj/irq.c	2004-12-24 13:37:44 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,37 +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.
- *
- * Code to handle x86 style IRQs plus some generic interrupt stuff.
- *
- * Copyright (C) 1992 Linus Torvalds
- * Copyright (C) 1994 - 2000 Ralf Baechle
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <asm/mipsregs.h>
-#include <asm/system.h>
-#include <asm/gdb-stub.h>
-
-void __init init_IRQ(void)
-{
-	extern void hpIRQ(void);
-	extern void mips_cpu_irq_init(u32 base);
-	mips_cpu_irq_init(0);
-	set_except_vector(0, hpIRQ);
-
-#ifdef CONFIG_KGDB
-	{
-		extern void breakpoint(void);
-		extern int remote_debug;
-
-		if (remote_debug) {
-			set_debug_traps();
-			breakpoint();
-		}
-	}
-#endif
-
-}
diff -Nru a/arch/mips/hp-lj/setup.c b/arch/mips/hp-lj/setup.c
--- a/arch/mips/hp-lj/setup.c	2004-12-24 13:36:56 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,150 +0,0 @@
-/*
- * 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
- */
-#include <linux/config.h>
-#include <linux/hdreg.h>
-#include <linux/init.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/ide.h>
-#include <linux/bootmem.h>
-#include <asm/reboot.h>
-#include <asm/time.h>
-#include <asm/hp-lj/asic.h>
-#include "utils.h"
-
-extern char CommandLine[];
-extern void pci_setup(void);
-
-#ifdef CONFIG_KGDB
-int remote_debug = 0;
-#endif
-
-const char *get_system_type(void)
-{
-	return "HP LaserJet";	/* But which exactly?  */
-}
-
-static void (*timer_interrupt_service) (int irq, void *dev_id,
-					struct pt_regs * regs) = NULL;
-
-
-static void andros_timer_interrupt(int irq, void *dev_id,
-				   struct pt_regs *regs)
-{
-	if (!(*((volatile unsigned int *) 0xbfea0010) & 0x20))	// mask = pend & en
-		return;
-
-	/* clear timer interrupt */
-	{
-		unsigned int tmr = *((volatile unsigned int *) 0xbfe90040);	// ctl bits
-		*((volatile unsigned int *) 0xbfe90040) = tmr;	// write to ack
-		*((volatile unsigned int *) 0xbfea000c) = 0x20;	// sys int ack
-	}
-
-	/* service interrupt */
-	timer_interrupt_service(irq, dev_id, regs);
-}
-
-static void harmony_timer_interrupt(int irq, void *dev_id,
-				    struct pt_regs *regs)
-{
-	if (!(*((volatile unsigned int *) 0xbff63000) & 0x01))
-		return;		// big sys     int reg, 01-timer  did it
-	if (!(*((volatile unsigned int *) 0xbff610a4) & 0x01))
-		return;		// local small int reg, 01-timer0 did it
-
-	*((volatile unsigned int *) 0xbff610a4) = 1;	// ack local timer0 bit
-	*((volatile unsigned int *) 0xbff63000) = 1;	// ack global timer bit
-
-	/* service interrupt */
-	timer_interrupt_service(irq, dev_id, regs);
-}
-
-
-#define ASIC_IRQ_NUMBER  2
-
-
-static void __init hp_time_init(struct irqaction *irq)
-{
-	timer_interrupt_service = irq->handler;
-
-	if (GetAsicId() == AndrosAsic) {
-		//*((volatile unsigned int*)0xbfe90000) = 0x2f;  // set by bootloader to 0x20              // prescaler
-		*((volatile unsigned int *) 0xbfe90040) = 0x21;	// 20-res of 1kHz,1-int ack                // control
-		*((volatile unsigned int *) 0xbfe90048) = 0x09;	// 09-reload val                          // reload
-		*((volatile unsigned int *) 0xbfe90044) = 0x09;	// 09-count val                           // count
-		*((volatile unsigned int *) 0xbfe90040) = 0x2f;	// 8-int enable,4-reload en,2-count down en,1-int-ack
-
-		irq->handler = andros_timer_interrupt;
-		irq->flags |= SA_INTERRUPT | SA_SHIRQ;
-		printk("setting up timer in hp_time_init\n");
-		setup_irq(ASIC_IRQ_NUMBER, irq);
-
-		// enable timer interrupt
-		*((volatile unsigned int *) 0xbfea0000) = 0x20;
-
-	} else if (GetAsicId() == HarmonyAsic) {
-
-		*((volatile unsigned int *) 0xbff61000) = 99;	// prescaler, 100Mz sys clk
-		*((volatile unsigned int *) 0xbff61028) = 0x09;	// reload reg
-		*((volatile unsigned int *) 0xbff61024) = 0x09;	// count reg
-		*((volatile unsigned int *) 0xbff61020) = 0x0b;	// 80-1khz res on timer, 2 reload en, 1 - count down en
-
-		irq->handler = harmony_timer_interrupt;
-		irq->flags |= SA_INTERRUPT | SA_SHIRQ;
-		setup_irq(ASIC_IRQ_NUMBER, irq);
-
-		*((volatile unsigned int *) 0xbff610a0) |= 1;	// turn on timer0
-
-	} else if (GetAsicId() == UnknownAsic)
-		printk("Unknown asic in hp_time_init()\n");
-	else
-		printk("Unsupported asic in hp_time_init()\n");
-}
-
-
-static void hplj_restart(void)
-{
-	if (GetAsicId() == AndrosAsic)
-		*((volatile unsigned int *) 0xbfe900c0) = 0;
-
-
-	if (GetAsicId() == HarmonyAsic)
-		*((volatile unsigned int *) 0xbff62030) = 0;
-
-	printk("Restart Failed ... halting instead\n");
-	while (1);
-}
-
-static void hplj_halt(void)
-{
-	while (1);
-}
-
-static void __init hp_setup(void)
-{
-#ifdef CONFIG_PCI
-	pci_setup();
-#endif
-
-	_machine_restart = (void (*)(char *)) hplj_restart;
-	_machine_halt = hplj_halt;
-	_machine_power_off = hplj_halt;
-
-	board_timer_setup = hp_time_init;
-
-#ifdef CONFIG_KGDB
-	remote_debug = (strstr(CommandLine, "kgdb") != NULL);
-#endif
-
-	printk("HP SETUP\n");
-}
-
-early_initcall(hp_setup);
diff -Nru a/arch/mips/hp-lj/utils.c b/arch/mips/hp-lj/utils.c
--- a/arch/mips/hp-lj/utils.c	2004-12-24 13:37:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,69 +0,0 @@
-/*
- *
- *
- *
- *
- */
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include <asm/io.h>
-#include "utils.h"
-
-
-#define  miu_chan_cfg(x)      ((volatile unsigned long  *)(0xbff40000+x*4))       /* for andros */
-
-int mbsize[8] = {1,2,4,8,16,32,64,128};
-
-unsigned long get_mem_avail(void) {
-
-    unsigned long  cfg[10],i,total_mem=0;
-
-	for(i=0;i<10;i++)
-		cfg[i] = *miu_chan_cfg(i);
-
-	for(i=0;i<10;i++){
-		if(cfg[i]==0x1fc160c2) continue;                           // skip empties
-		if(   ( (cfg[i]>>12) & 0xf )   <=  0xb ) continue;         // skip roms
-        total_mem += mbsize[(cfg[i]>>16)&0x7] *1024*1024;
-	}
-    return total_mem;
-}
-
-
-
-
-static ulong* buffer_ptr = NULL;
-static ulong buffer_size = 0;
-
-ulong* get_reserved_buffer(void) {return KSEG0ADDR(buffer_ptr);}
-ulong* get_reserved_buffer_virtual(void) {return (ulong*)ReservedMemVirtualAddr;}
-ulong get_reserved_buffer_size(void) {return buffer_size;}
-
-#define MIN_GEN_MEM (4 << 20)
-
-
-void  reserve_buffer(const char* cl, ulong base_mem)
-{
-	char* pos = strstr(cl, "reserved_buffer=");
- 	if (pos) {
-		buffer_size = simple_strtol(pos+strlen("reserved_buffer="),
-					    0, 10);
-		buffer_size <<= 20;
-		if (buffer_size + MIN_GEN_MEM > base_mem)
-			buffer_size = base_mem - MIN_GEN_MEM;
-		if (buffer_size > 0)
-			buffer_ptr = (ulong*)(base_mem - buffer_size);
-		else
-			buffer_size = 0;
-	}
-}
-
-
-
-EXPORT_SYMBOL(get_reserved_buffer);
-EXPORT_SYMBOL(get_reserved_buffer_virtual);
-EXPORT_SYMBOL(get_reserved_buffer_size);
-
-
diff -Nru a/arch/mips/hp-lj/utils.h b/arch/mips/hp-lj/utils.h
--- a/arch/mips/hp-lj/utils.h	2004-12-24 13:37:02 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,19 +0,0 @@
-/*
- *
- *
- *
- */
-
-#include <linux/types.h>
-
-#define ReservedMemVirtualAddr  0x50000000
-
-unsigned long get_mem_avail(void);
-
-ulong* get_reserved_buffer(void);
-ulong* get_reserved_buffer_virtual(void);
-ulong get_reserved_buffer_size(void);
-
-void  reserve_buffer(const char* cl, ulong base_mem);
-
-
diff -Nru a/arch/mips/ite-boards/generic/irq.c b/arch/mips/ite-boards/generic/irq.c
--- a/arch/mips/ite-boards/generic/irq.c	2004-12-24 13:36:56 -08:00
+++ b/arch/mips/ite-boards/generic/irq.c	2004-12-24 13:36:56 -08:00
@@ -47,8 +47,8 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/serial_reg.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
@@ -65,10 +65,6 @@
 #define DPRINTK(fmt, args...)
 #endif
 
-#ifdef CONFIG_KGDB
-extern void breakpoint(void);
-#endif
-
 /* revisit */
 #define EXT_IRQ0_TO_IP 2 /* IP 2 */
 #define EXT_IRQ5_TO_IP 7 /* IP 7 */
@@ -251,7 +247,7 @@
         local_irq_restore(flags);
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	int i;
         unsigned long flags;
@@ -259,8 +255,6 @@
         memset(irq_desc, 0, sizeof(irq_desc));
         set_except_vector(0, it8172_IRQ);
 
-	init_generic_irq();
-
 	/* mask all interrupts */
 	it8172_hw0_icregs->lb_mask  = 0xffff;
 	it8172_hw0_icregs->lpc_mask = 0xffff;
@@ -297,13 +291,6 @@
 	}
 	irq_desc[MIPS_CPU_TIMER_IRQ].handler = &cp0_irq_type;
 	set_c0_status(ALLINTS_NOTIMER);
-
-#ifdef CONFIG_KGDB
-	/* 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)
diff -Nru a/arch/mips/jazz/irq.c b/arch/mips/jazz/irq.c
--- a/arch/mips/jazz/irq.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/jazz/irq.c	2004-12-24 13:36:17 -08:00
@@ -19,11 +19,9 @@
 
 static spinlock_t r4030_lock = SPIN_LOCK_UNLOCKED;
 
-extern asmlinkage void sni_rm200_pci_handle_int(void);
-
 static void enable_r4030_irq(unsigned int irq)
 {
-	unsigned int mask = 1 << (irq - JAZZ_IE_PARALLEL);
+	unsigned int mask = 1 << (irq - JAZZ_PARALLEL_IRQ);
 	unsigned long flags;
 
 	spin_lock_irqsave(&r4030_lock, flags);
@@ -42,7 +40,7 @@
 
 void disable_r4030_irq(unsigned int irq)
 {
-	unsigned int mask = ~(1 << (irq - JAZZ_IE_PARALLEL));
+	unsigned int mask = ~(1 << (irq - JAZZ_PARALLEL_IRQ));
 	unsigned long flags;
 
 	spin_lock_irqsave(&r4030_lock, flags);
@@ -91,11 +89,10 @@
  * driver compatibility reasons interrupts 0 - 15 to be the i8259
  * interrupts even if the hardware uses a different interrupt numbering.
  */
-void __init init_IRQ (void)
+void __init arch_init_irq(void)
 {
 	set_except_vector(0, jazz_handle_int);
 
-	init_generic_irq();
 	init_i8259_irqs();			/* Integrated i8259  */
 	init_r4030_ints();
 
diff -Nru a/arch/mips/jazz/jazzdma.c b/arch/mips/jazz/jazzdma.c
--- a/arch/mips/jazz/jazzdma.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/jazz/jazzdma.c	2004-12-24 13:37:29 -08:00
@@ -304,6 +304,8 @@
 	return (i << 12) + (paddr & (VDMA_PAGESIZE - 1));
 }
 
+EXPORT_SYMBOL(vdma_phys2log);
+
 /*
  * Translate a logical DMA address to a physical address
  */
@@ -394,6 +396,8 @@
 			  R4030_CHNL_ENABLE);
 }
 
+EXPORT_SYMBOL(vdma_enable);
+
 /*
  * Disable a DMA channel
  */
@@ -429,6 +433,8 @@
 	*((volatile unsigned int *) JAZZ_DUMMY_DEVICE);
 }
 
+EXPORT_SYMBOL(vdma_disable);
+
 /*
  * Set DMA mode. This function accepts the mode values used
  * to set a PC-style DMA controller. For the SCSI and FDC
@@ -496,6 +502,8 @@
 	}
 }
 
+EXPORT_SYMBOL(vdma_set_mode);
+
 /*
  * Set Transfer Address
  */
@@ -508,6 +516,8 @@
 	r4030_write_reg32(JAZZ_R4030_CHNL_ADDR + (channel << 5), addr);
 }
 
+EXPORT_SYMBOL(vdma_set_addr);
+
 /*
  * Set Transfer Count
  */
@@ -519,6 +529,8 @@
 
 	r4030_write_reg32(JAZZ_R4030_CHNL_COUNT + (channel << 5), count);
 }
+
+EXPORT_SYMBOL(vdma_set_count);
 
 /*
  * Get Residual
diff -Nru a/arch/mips/jazz/reset.c b/arch/mips/jazz/reset.c
--- a/arch/mips/jazz/reset.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/jazz/reset.c	2004-12-24 13:37:19 -08:00
@@ -11,8 +11,6 @@
 #include <asm/reboot.h>
 #include <asm/delay.h>
 
-#define jazz_kh ((keyboard_hardware *) JAZZ_KEYBOARD_ADDRESS)
-
 #define KBD_STAT_IBF		0x02	/* Keyboard input buffer full */
 
 static void jazz_write_output(unsigned char val)
diff -Nru a/arch/mips/jmr3927/rbhma3100/irq.c b/arch/mips/jmr3927/rbhma3100/irq.c
--- a/arch/mips/jmr3927/rbhma3100/irq.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/jmr3927/rbhma3100/irq.c	2004-12-24 13:36:48 -08:00
@@ -45,8 +45,8 @@
 #include <linux/random.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
 #include <asm/system.h>
@@ -343,7 +343,8 @@
 int jmr3927_ether1_irq = 0;
 
 void jmr3927_irq_init(u32 irq_base);
-void jmr3927_irq_setup(void)
+
+void __init arch_init_irq(void)
 {
 	/* look for io board's presence */
 	int have_isac = jmr3927_have_isac();
@@ -421,24 +422,6 @@
 	set_c0_status(ST0_IM);	/* IE bit is still 0. */
 }
 
-void (*irq_setup)(void);
-
-void __init init_IRQ(void)
-{
-
-#ifdef CONFIG_KGDB
-        extern void breakpoint(void);
-        extern void set_debug_traps(void);
-
-        puts("Wait for gdb client connection ...\n");
-        set_debug_traps();
-        breakpoint();
-#endif
-
-        /* invoke board-specific irq setup */
-        irq_setup();
-}
-
 static hw_irq_controller jmr3927_irq_controller = {
 	"jmr3927_irq",
 	jmr3927_irq_startup,
@@ -453,7 +436,6 @@
 {
 	u32 i;
 
-	init_generic_irq();
 	for (i= irq_base; i< irq_base + JMR3927_NR_IRQ_IRC + JMR3927_NR_IRQ_IOC; i++) {
 		irq_desc[i].status = IRQ_DISABLED;
 		irq_desc[i].action = NULL;
diff -Nru a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
--- a/arch/mips/jmr3927/rbhma3100/setup.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/jmr3927/rbhma3100/setup.c	2004-12-24 13:37:19 -08:00
@@ -184,17 +184,12 @@
 }
 
 
-#if defined(CONFIG_BLK_DEV_INITRD)
-extern unsigned long __rd_start, __rd_end, initrd_start, initrd_end;
-#endif
-
 //#undef DO_WRITE_THROUGH
 #define DO_WRITE_THROUGH
 #define DO_ENABLE_CACHE
 
 extern char * __init prom_getcmdline(void);
 static void jmr3927_board_init(void);
-extern void jmr3927_irq_setup(void);
 extern struct resource pci_io_resource;
 extern struct resource pci_mem_resource;
 
@@ -203,7 +198,6 @@
 	extern int panic_timeout;
 	char *argptr;
 
-	irq_setup = jmr3927_irq_setup;
 	set_io_port_base(JMR3927_PORT_BASE + JMR3927_PCIIO);
 
 	board_time_init = jmr3927_time_init;
diff -Nru a/arch/mips/kernel/cpu-bugs64.c b/arch/mips/kernel/cpu-bugs64.c
--- a/arch/mips/kernel/cpu-bugs64.c	2004-12-24 13:37:17 -08:00
+++ b/arch/mips/kernel/cpu-bugs64.c	2004-12-24 13:37:17 -08:00
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003  Maciej W. Rozycki
+ * Copyright (C) 2003, 2004  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,6 +13,7 @@
 #include <linux/stddef.h>
 
 #include <asm/bugs.h>
+#include <asm/compiler.h>
 #include <asm/cpu.h>
 #include <asm/fpu.h>
 #include <asm/mipsregs.h>
@@ -82,7 +83,7 @@
 		".set	pop"
 		: "=&r" (lv1), "=r" (lw)
 		: "r" (m1), "r" (m2), "r" (s), "I" (0)
-		: "hi", "lo", "accum");
+		: "hi", "lo", GCC_REG_ACCUM);
 	/* We have to use single integers for m1 and m2 and a double
 	 * one for p to be sure the mulsidi3 gcc's RTL multiplication
 	 * instruction has the workaround applied.  Older versions of
diff -Nru a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
--- a/arch/mips/kernel/cpu-probe.c	2004-12-24 13:36:35 -08:00
+++ b/arch/mips/kernel/cpu-probe.c	2004-12-24 13:36:35 -08:00
@@ -100,6 +100,7 @@
 	case CPU_R5000:
 	case CPU_NEVADA:
 	case CPU_RM7000:
+	case CPU_RM9000:
 	case CPU_TX49XX:
 	case CPU_4KC:
 	case CPU_4KEC:
diff -Nru a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
--- a/arch/mips/kernel/entry.S	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/kernel/entry.S	2004-12-24 13:36:19 -08:00
@@ -16,6 +16,7 @@
 #include <asm/stackframe.h>
 #include <asm/isadep.h>
 #include <asm/thread_info.h>
+#include <asm/war.h>
 
 #ifdef CONFIG_PREEMPT
 	.macro	preempt_stop reg=t0
@@ -139,7 +140,11 @@
 1:	ll      t0, %lo(irq_err_count)(t1)
 	addiu   t0, 1
 	sc      t0, %lo(irq_err_count)(t1)
+#if R10000_LLSC_WAR
+	beqzl	t0, 1b
+#else
 	beqz	t0, 1b
+#endif
 #else
 	lui     t1, %hi(irq_err_count)
 	lw      t0, %lo(irq_err_count)(t1)
diff -Nru a/arch/mips/kernel/gdb-stub.c b/arch/mips/kernel/gdb-stub.c
--- a/arch/mips/kernel/gdb-stub.c	2004-12-24 13:37:30 -08:00
+++ b/arch/mips/kernel/gdb-stub.c	2004-12-24 13:37:30 -08:00
@@ -171,6 +171,8 @@
 static unsigned char *mem2hex(char *mem, char *buf, int count, int may_fault);
 void handle_exception(struct gdb_regs *regs);
 
+int kgdb_enabled;
+
 /*
  * spin locks for smp case
  */
diff -Nru a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
--- a/arch/mips/kernel/genex.S	2004-12-24 13:36:32 -08:00
+++ b/arch/mips/kernel/genex.S	2004-12-24 13:36:32 -08:00
@@ -19,14 +19,25 @@
 #include <asm/stackframe.h>
 #include <asm/war.h>
 
+#define PANIC_PIC(msg)					\
+		.set push;				\
+		.set	reorder;			\
+		PTR_LA	a0,8f;				\
+		.set	noat;				\
+		PTR_LA	AT, panic;			\
+		jr	AT;				\
+9:		b	9b;				\
+		.set	pop;				\
+		TEXT(msg)
+
 	__INIT
 
 NESTED(except_vec0_generic, 0, sp)
-	PANIC("Exception vector 0 called")
+	PANIC_PIC("Exception vector 0 called")
 	END(except_vec0_generic)
 
 NESTED(except_vec1_generic, 0, sp)
-	PANIC("Exception vector 1 called")
+	PANIC_PIC("Exception vector 1 called")
 	END(except_vec1_generic)
 
 /*
@@ -142,19 +153,17 @@
 NESTED(ejtag_debug_handler, PT_SIZE, sp)
 	.set	push
 	.set	noat
-	.set	noreorder
 	MTC0	k0, CP0_DESAVE
 	mfc0	k0, CP0_DEBUG
 
 	sll	k0, k0, 30	# Check for SDBBP.
 	bgez	k0, ejtag_return
-	nop
 
 	PTR_LA	k0, ejtag_debug_buffer
 	LONG_S	k1, 0(k0)
 	SAVE_ALL
+	move	a0, sp
 	jal	ejtag_exception_handler
-	 move	a0, sp
 	RESTORE_ALL
 	PTR_LA	k0, ejtag_debug_buffer
 	LONG_L	k1, 0(k0)
@@ -163,7 +172,6 @@
 	MFC0	k0, CP0_DESAVE
 	.set	mips32
 	deret
- 	 nop
 	.set pop
 	END(ejtag_debug_handler)
 
diff -Nru a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
--- a/arch/mips/kernel/head.S	2004-12-24 13:37:01 -08:00
+++ b/arch/mips/kernel/head.S	2004-12-24 13:37:01 -08:00
@@ -90,15 +90,35 @@
 	.endm
 
 	/*
-	 * For the moment set ST0_KU so the CPU will not spit fire when
-	 * executing 64-bit instructions.  The full initialization of the
-	 * CPU's status register is done later in per_cpu_trap_init().
+	 * For the moment disable interrupts, mark the kernel mode and
+	 * set ST0_KX so that the CPU does not spit fire when using
+	 * 64-bit addresses.  A full initialization of the CPU's status
+	 * register is done later in per_cpu_trap_init().
 	 */
-	.macro	setup_c0_status
-#ifdef CONFIG_MIPS64
+	.macro	setup_c0_status set clr
+	.set	push
 	mfc0	t0, CP0_STATUS
-	or	t0, ST0_KX
+	or	t0, ST0_CU0|\set|0x1f|\clr
+	xor	t0, 0x1f|\clr
 	mtc0	t0, CP0_STATUS
+	.set	noreorder
+	sll	zero,3				# ehb
+	.set	pop
+	.endm
+
+	.macro	setup_c0_status_pri
+#ifdef CONFIG_MIPS64
+	setup_c0_status ST0_KX 0
+#else
+	setup_c0_status 0 0
+#endif
+	.endm
+
+	.macro	setup_c0_status_sec
+#ifdef CONFIG_MIPS64
+	setup_c0_status ST0_KX ST0_BEV
+#else
+	setup_c0_status 0 ST0_BEV
 #endif
 	.endm
 
@@ -114,7 +134,7 @@
 	__INIT
 
 NESTED(kernel_entry, 16, sp)			# kernel entry point
-	setup_c0_status
+	setup_c0_status_pri
 
 #ifdef CONFIG_SGI_IP27
 	GET_NASID_ASM	t1
@@ -124,8 +144,6 @@
 
 	ARC64_TWIDDLE_PC
 
-	CLI					# disable interrupts
-
 	PTR_LA		t0, __bss_start		# clear .bss
 	LONG_S		zero, (t0)
 	PTR_LA		t1, __bss_stop - LONGSIZE
@@ -144,7 +162,7 @@
 	set_saved_sp	sp, t0, t1
 	PTR_SUBU	sp, 4 * SZREG		# init stack pointer
 
-	jal		start_kernel
+	j		start_kernel
 	END(kernel_entry)
 
 #ifdef CONFIG_SMP
@@ -153,6 +171,8 @@
  * function after setting up the stack and gp registers.
  */
 NESTED(smp_bootstrap, 16, sp)
+	setup_c0_status_sec
+
 #ifdef CONFIG_SGI_IP27
 	GET_NASID_ASM	t1
 	dli	t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \
@@ -166,9 +186,7 @@
 	ARC64_TWIDDLE_PC
 #endif /* CONFIG_SGI_IP27 */
 
-	CLI
-	setup_c0_status
-	jal	start_secondary
+	j	start_secondary
 	END(smp_bootstrap)
 #endif /* CONFIG_SMP */
 
@@ -201,13 +219,3 @@
 	page	invalid_pmd_table, _PMD_ORDER
 #endif
 	page	invalid_pte_table, _PTE_ORDER
-
-#ifdef CONFIG_MIPS64
-	/*
-	 * 64-bit kernel mappings are really screwed up ...
-	 */
-	page	kptbl, _PGD_ORDER
-	.globl	ekptbl
-	page	kpmdtbl, 0
-ekptbl:
-#endif
diff -Nru a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
--- a/arch/mips/kernel/i8259.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/kernel/i8259.c	2004-12-24 13:36:19 -08:00
@@ -209,7 +209,7 @@
 		 * lets ACK and report it. [once per IRQ]
 		 */
 		if (!(spurious_irq_mask & irqmask)) {
-			printk("spurious 8259A interrupt: IRQ%d.\n", irq);
+			printk(KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n", irq);
 			spurious_irq_mask |= irqmask;
 		}
 		atomic_inc(&irq_err_count);
@@ -295,7 +295,7 @@
  * IRQ2 is cascade interrupt to second interrupt controller
  */
 static struct irqaction irq2 = {
-	no_action, 0, 0, "cascade", NULL, NULL
+	no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL
 };
 
 static struct resource pic1_io_resource = {
diff -Nru a/arch/mips/kernel/ioctl32.c b/arch/mips/kernel/ioctl32.c
--- a/arch/mips/kernel/ioctl32.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/kernel/ioctl32.c	2004-12-24 13:36:49 -08:00
@@ -47,6 +47,12 @@
 COMPATIBLE_IOCTL(SBPROF_ZBWAITFULL)
 #endif /* CONFIG_SIBYTE_TBPROF */
 
+/*HANDLE_IOCTL(RTC_IRQP_READ, w_long)
+COMPATIBLE_IOCTL(RTC_IRQP_SET)
+HANDLE_IOCTL(RTC_EPOCH_READ, w_long)
+COMPATIBLE_IOCTL(RTC_EPOCH_SET)
+*/
+
 IOCTL_TABLE_END
 
 int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff -Nru a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
--- a/arch/mips/kernel/irixelf.c	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/kernel/irixelf.c	2004-12-24 13:37:43 -08:00
@@ -265,9 +265,8 @@
 	    return 0xffffffff;
 	}
 
-	elf_phdata =  (struct elf_phdr *)
-		kmalloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum,
-			GFP_KERNEL);
+	elf_phdata = kmalloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum,
+			     GFP_KERNEL);
 
 	if(!elf_phdata) {
           printk("Cannot kmalloc phdata for IRIX interp.\n");
@@ -436,9 +435,8 @@
 		if (*name != NULL)
 			goto out;
 
-		*name = (char *) kmalloc((epp->p_filesz +
-					  strlen(IRIX_INTERP_PREFIX)),
-					 GFP_KERNEL);
+		*name = kmalloc((epp->p_filesz + strlen(IRIX_INTERP_PREFIX)),
+				GFP_KERNEL);
 		if (!*name)
 			return -ENOMEM;
 
@@ -611,7 +609,7 @@
 	size = elf_ex.e_phentsize * elf_ex.e_phnum;
 	if (size > 65536)
 		goto out;
-	elf_phdata = (struct elf_phdr *) kmalloc(size, GFP_KERNEL);
+	elf_phdata = kmalloc(size, GFP_KERNEL);
 	if (elf_phdata == NULL) {
 		retval = -ENOMEM;
 		goto out;
@@ -814,8 +812,7 @@
 	if(sizeof(struct elf_phdr) * elf_ex.e_phnum > PAGE_SIZE)
 		return -ENOEXEC;
 
-	elf_phdata =  (struct elf_phdr *)
-		kmalloc(sizeof(struct elf_phdr) * elf_ex.e_phnum, GFP_KERNEL);
+	elf_phdata = kmalloc(sizeof(struct elf_phdr) * elf_ex.e_phnum, GFP_KERNEL);
 	if (elf_phdata == NULL)
 		return -ENOMEM;
 
@@ -1055,7 +1052,7 @@
 	struct vm_area_struct *vma;
 	struct elfhdr elf;
 	off_t offset = 0, dataoff;
-	int limit = current->rlim[RLIMIT_CORE].rlim_cur;
+	int limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
 	int numnote = 4;
 	struct memelfnote notes[4];
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
@@ -1131,14 +1128,28 @@
 	psinfo.pr_ppid = prstatus.pr_ppid = current->parent->pid;
 	psinfo.pr_pgrp = prstatus.pr_pgrp = process_group(current);
 	psinfo.pr_sid = prstatus.pr_sid = current->signal->session;
-	prstatus.pr_utime.tv_sec = CT_TO_SECS(current->utime);
-	prstatus.pr_utime.tv_usec = CT_TO_USECS(current->utime);
-	prstatus.pr_stime.tv_sec = CT_TO_SECS(current->stime);
-	prstatus.pr_stime.tv_usec = CT_TO_USECS(current->stime);
-	prstatus.pr_cutime.tv_sec = CT_TO_SECS(current->cutime);
-	prstatus.pr_cutime.tv_usec = CT_TO_USECS(current->cutime);
-	prstatus.pr_cstime.tv_sec = CT_TO_SECS(current->cstime);
-	prstatus.pr_cstime.tv_usec = CT_TO_USECS(current->cstime);
+	if (current->pid == current->tgid) {
+		/*
+		 * This is the record for the group leader.  Add in the
+		 * cumulative times of previous dead threads.  This total
+		 * won't include the time of each live thread whose state
+		 * is included in the core dump.  The final total reported
+		 * to our parent process when it calls wait4 will include
+		 * those sums as well as the little bit more time it takes
+		 * this and each other thread to finish dying after the
+		 * core dump synchronization phase.
+		 */
+		jiffies_to_timeval(current->utime + current->signal->utime,
+		                   &prstatus.pr_utime);
+		jiffies_to_timeval(current->stime + current->signal->stime,
+		                   &prstatus.pr_stime);
+	} else {
+		jiffies_to_timeval(current->utime, &prstatus.pr_utime);
+		jiffies_to_timeval(current->stime, &prstatus.pr_stime);
+	}
+	jiffies_to_timeval(current->signal->cutime, &prstatus.pr_cutime);
+	jiffies_to_timeval(current->signal->cstime, &prstatus.pr_cstime);
+
 	if (sizeof(elf_gregset_t) != sizeof(struct pt_regs)) {
 		printk("sizeof(elf_gregset_t) (%d) != sizeof(struct pt_regs) "
 		       "(%d)\n", sizeof(elf_gregset_t), sizeof(struct pt_regs));
diff -Nru a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c
--- a/arch/mips/kernel/irixsig.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/kernel/irixsig.c	2004-12-24 13:37:18 -08:00
@@ -133,10 +133,8 @@
 }
 
 static inline void handle_signal(unsigned long sig, siginfo_t *info,
-	sigset_t *oldset, struct pt_regs * regs)
+	struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
 {
-	struct k_sigaction *ka = &current->sighand->action[sig-1];
-
 	switch(regs->regs[0]) {
 	case ERESTARTNOHAND:
 		regs->regs[2] = EINTR;
@@ -158,8 +156,6 @@
 	else
 		setup_irix_frame(ka, regs, sig, oldset);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
@@ -171,6 +167,7 @@
 
 asmlinkage int do_irix_signal(sigset_t *oldset, struct pt_regs *regs)
 {
+	struct k_sigaction ka;
 	siginfo_t info;
 	int signr;
 
@@ -190,9 +187,9 @@
 	if (!oldset)
 		oldset = &current->blocked;
 
-	signr = get_signal_to_deliver(&info, regs, NULL);
+	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
 	if (signr > 0) {
-		handle_signal(signr, &info, oldset, regs);
+		handle_signal(signr, &info, &ka, oldset, regs);
 		return 1;
 	}
 
@@ -543,9 +540,9 @@
 }
 
 /* This is here because of irix5_siginfo definition. */
-#define P_PID    0
-#define P_PGID   2
-#define P_ALL    7
+#define IRIX_P_PID    0
+#define IRIX_P_PGID   2
+#define IRIX_P_ALL    7
 
 extern int getrusage(struct task_struct *, int, struct rusage __user *);
 
@@ -582,7 +579,7 @@
 		retval = -EINVAL;
 		goto out;
 	}
-	if (type != P_PID && type != P_PGID && type != P_ALL) {
+	if (type != IRIX_P_PID && type != IRIX_P_PGID && type != IRIX_P_ALL) {
 		retval = -EINVAL;
 		goto out;
 	}
@@ -594,9 +591,9 @@
 	tsk = current;
 	list_for_each(_p,&tsk->children) {
 		p = list_entry(_p,struct task_struct,sibling);
-		if ((type == P_PID) && p->pid != pid)
+		if ((type == IRIX_P_PID) && p->pid != pid)
 			continue;
-		if ((type == P_PGID) && process_group(p) != pid)
+		if ((type == IRIX_P_PGID) && process_group(p) != pid)
 			continue;
 		if ((p->exit_signal != SIGCHLD))
 			continue;
@@ -631,8 +628,8 @@
 			goto end_waitsys;
 
 		case TASK_ZOMBIE:
-			current->cutime += p->utime + p->cutime;
-			current->cstime += p->stime + p->cstime;
+			current->signal->cutime += p->utime + p->signal->cutime;
+			current->signal->cstime += p->stime + p->signal->cstime;
 			if (ru != NULL)
 				getrusage(p, RUSAGE_BOTH, ru);
 			__put_user(SIGCHLD, &info->sig);
diff -Nru a/arch/mips/kernel/irq-msc01.c b/arch/mips/kernel/irq-msc01.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/kernel/irq-msc01.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2004 MIPS Inc
+ * Author: chris@mips.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/module.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <asm/ptrace.h>
+#include <linux/sched.h>
+#include <linux/kernel_stat.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/msc01_ic.h>
+
+static unsigned long _icctrl_msc;
+#define MSC01_IC_REG_BASE	_icctrl_msc
+
+#define MSCIC_WRITE(reg, data)	do { *(volatile u32 *)(reg) = data; } while (0)
+#define MSCIC_READ(reg, data)	do { data = *(volatile u32 *)(reg); } while (0)
+
+static unsigned int irq_base;
+
+/* mask off an interrupt */
+static inline void mask_msc_irq(unsigned int irq)
+{
+	if (irq < (irq_base + 32))
+		MSCIC_WRITE(MSC01_IC_DISL, 1<<(irq - irq_base));
+	else
+		MSCIC_WRITE(MSC01_IC_DISH, 1<<(irq - irq_base - 32));
+}
+
+/* unmask an interrupt */
+static inline void unmask_msc_irq(unsigned int irq)
+{
+	if (irq < (irq_base + 32))
+		MSCIC_WRITE(MSC01_IC_ENAL, 1<<(irq - irq_base));
+	else
+		MSCIC_WRITE(MSC01_IC_ENAH, 1<<(irq - irq_base - 32));
+}
+
+/*
+ * Enables the IRQ on SOC-it
+ */
+static void enable_msc_irq(unsigned int irq)
+{
+	unmask_msc_irq(irq);
+}
+
+/*
+ * Initialize the IRQ on SOC-it
+ */
+static unsigned int startup_msc_irq(unsigned int irq)
+{
+	unmask_msc_irq(irq);
+	return 0;
+}
+
+/*
+ * Disables the IRQ on SOC-it
+ */
+static void disable_msc_irq(unsigned int irq)
+{
+	mask_msc_irq(irq);
+}
+
+/*
+ * Masks and ACKs an IRQ
+ */
+static void level_mask_and_ack_msc_irq(unsigned int irq)
+{
+	mask_msc_irq(irq);
+	if (!cpu_has_ei)
+		MSCIC_WRITE(MSC01_IC_EOI, 0);
+}
+
+/*
+ * Masks and ACKs an IRQ
+ */
+static void edge_mask_and_ack_msc_irq(unsigned int irq)
+{
+	mask_msc_irq(irq);
+	if (!cpu_has_ei)
+		MSCIC_WRITE(MSC01_IC_EOI, 0);
+	else {
+		u32 r;
+		MSCIC_READ(MSC01_IC_SUP+irq*8, r);
+		MSCIC_WRITE(MSC01_IC_SUP+irq*8, r | ~MSC01_IC_SUP_EDGE_BIT);
+		MSCIC_WRITE(MSC01_IC_SUP+irq*8, r);
+	}
+}
+
+/*
+ * End IRQ processing
+ */
+static void end_msc_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		unmask_msc_irq(irq);
+}
+
+/*
+ * Interrupt handler for interrupts coming from SOC-it.
+ */
+void ll_msc_irq(struct pt_regs *regs)
+{
+ 	unsigned int irq;
+
+	/* read the interrupt vector register */
+	MSCIC_READ(MSC01_IC_VEC, irq);
+	if (irq < 64)
+		do_IRQ(irq + irq_base, regs);
+	else {
+		/* Ignore spurious interrupt */
+	}
+}
+
+void
+msc_bind_eic_interrupt (unsigned int irq, unsigned int set)
+{
+	MSCIC_WRITE(MSC01_IC_RAMW,
+		    (irq<<MSC01_IC_RAMW_ADDR_SHF) | (set<<MSC01_IC_RAMW_DATA_SHF));
+}
+
+#define shutdown_msc_irq	disable_msc_irq
+
+struct hw_interrupt_type msc_levelirq_type = {
+	"SOC-it-Level",
+	startup_msc_irq,
+	shutdown_msc_irq,
+	enable_msc_irq,
+	disable_msc_irq,
+	level_mask_and_ack_msc_irq,
+	end_msc_irq,
+	NULL
+};
+
+struct hw_interrupt_type msc_edgeirq_type = {
+	"SOC-it-Edge",
+	startup_msc_irq,
+	shutdown_msc_irq,
+	enable_msc_irq,
+	disable_msc_irq,
+	edge_mask_and_ack_msc_irq,
+	end_msc_irq,
+	NULL
+};
+
+
+void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq)
+{
+	extern void (*board_bind_eic_interrupt)(unsigned int irq, unsigned int regset);
+
+	_icctrl_msc = (unsigned long) ioremap (MIPS_MSC01_IC_REG_BASE, 0x40000);
+
+	/* Reset interrupt controller - initialises all registers to 0 */
+	MSCIC_WRITE(MSC01_IC_RST, MSC01_IC_RST_RST_BIT);
+
+	board_bind_eic_interrupt = &msc_bind_eic_interrupt;
+
+	for (; nirq >= 0; nirq--, imp++) {
+		int n = imp->im_irq;
+
+		switch (imp->im_type) {
+		case MSC01_IRQ_EDGE:
+			irq_desc[base+n].handler = &msc_edgeirq_type;
+			if (cpu_has_ei)
+				MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT);
+			else
+				MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl);
+			break;
+		case MSC01_IRQ_LEVEL:
+			irq_desc[base+n].handler = &msc_levelirq_type;
+			if (cpu_has_ei)
+				MSCIC_WRITE(MSC01_IC_SUP+n*8, 0);
+			else
+				MSCIC_WRITE(MSC01_IC_SUP+n*8, imp->im_lvl);
+		}
+	}
+
+	irq_base = base;
+
+	MSCIC_WRITE(MSC01_IC_GENA, MSC01_IC_GENA_GENA_BIT);	/* Enable interrupt generation */
+
+}
diff -Nru a/arch/mips/kernel/irq-mv6434x.c b/arch/mips/kernel/irq-mv6434x.c
--- a/arch/mips/kernel/irq-mv6434x.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/kernel/irq-mv6434x.c	2004-12-24 13:36:17 -08:00
@@ -16,7 +16,7 @@
 #include <linux/kernel_stat.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/mv64340.h>
+#include <linux/mv643xx.h>
 
 static unsigned int irq_base;
 
diff -Nru a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
--- a/arch/mips/kernel/irq.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/kernel/irq.c	2004-12-24 13:36:18 -08:00
@@ -28,56 +28,33 @@
 #include <asm/uaccess.h>
 
 /*
- * Controller mappings for all interrupt sources:
+ * 'what should we do if we get a hw irq event on an illegal vector'.
+ * each architecture has to answer this themselves.
  */
-irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
-	[0 ... NR_IRQS-1] = {
-		.handler = &no_irq_type,
-		.lock = SPIN_LOCK_UNLOCKED
-	}
-};
-
-static void register_irq_proc (unsigned int irq);
+void ack_bad_irq(unsigned int irq)
+{
+	printk("unexpected IRQ # %d\n", irq);
+}
 
-/*
- * Special irq handlers.
- */
+atomic_t irq_err_count;
 
-irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs)
-{ return IRQ_NONE; }
+#undef do_IRQ
 
 /*
- * Generic no controller code
+ * do_IRQ handles all normal device IRQ's (the special
+ * SMP cross-CPU interrupts have their own specific
+ * handlers).
  */
-
-static void enable_none(unsigned int irq) { }
-static unsigned int startup_none(unsigned int irq) { return 0; }
-static void disable_none(unsigned int irq) { }
-static void ack_none(unsigned int irq)
+asmlinkage unsigned int do_IRQ(unsigned int irq, struct pt_regs *regs)
 {
-	/*
-	 * 'what should we do if we get a hw irq event on an illegal vector'.
-	 * each architecture has to answer this themselves, it doesn't deserve
-	 * a generic callback i think.
-	 */
-	printk("unexpected interrupt %d\n", irq);
-}
+	irq_enter();
 
-/* startup is the same as "enable", shutdown is same as "disable" */
-#define shutdown_none	disable_none
-#define end_none	enable_none
-
-struct hw_interrupt_type no_irq_type = {
-	"none",
-	startup_none,
-	shutdown_none,
-	enable_none,
-	disable_none,
-	ack_none,
-	end_none
-};
+	__do_IRQ(irq, regs);
 
-atomic_t irq_err_count;
+	irq_exit();
+
+	return 1;
+}
 
 /*
  * Generic, controller-independent functions:
@@ -126,692 +103,20 @@
 	return 0;
 }
 
-#ifdef CONFIG_SMP
-inline void synchronize_irq(unsigned int irq)
-{
-	while (irq_desc[irq].status & IRQ_INPROGRESS)
-		cpu_relax();
-}
-#endif
-
-/*
- * This should really return information about whether
- * we should do bottom half handling etc. Right now we
- * end up _always_ checking the bottom half, which is a
- * waste of time and is not what some drivers would
- * prefer.
- */
-int handle_IRQ_event(unsigned int irq, struct pt_regs * regs, struct irqaction * action)
-{
-	int status = 1;	/* Force the "do bottom halves" bit */
-	int ret, retval = 0;
-
-	if (!(action->flags & SA_INTERRUPT))
-		local_irq_enable();
-
-	do {
-		ret = action->handler(irq, action->dev_id, regs);
-		if (ret == IRQ_HANDLED)
-			status |= action->flags;
-		retval |= ret;
-		action = action->next;
-	} while (action);
-	if (status & SA_SAMPLE_RANDOM)
-		add_interrupt_randomness(irq);
-	local_irq_disable();
-
-	return retval;
-}
-
-static void __report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	struct irqaction *action;
-
-	if (action_ret != IRQ_HANDLED && action_ret != IRQ_NONE) {
-		printk(KERN_ERR "irq event %d: bogus return value %x\n",
-				irq, action_ret);
-	} else {
-		printk(KERN_ERR "irq %d: nobody cared!\n", irq);
-	}
-	dump_stack();
-	printk(KERN_ERR "handlers:\n");
-	action = desc->action;
-	do {
-		printk(KERN_ERR "[<%p>]", action->handler);
-		print_symbol(" (%s)",
-			(unsigned long)action->handler);
-		printk("\n");
-		action = action->next;
-	} while (action);
-}
-
-static void report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	static int count = 100;
-
-	if (count) {
-		count--;
-		__report_bad_irq(irq, desc, action_ret);
-	}
-}
-
-static int noirqdebug;
-
-static int __init noirqdebug_setup(char *str)
-{
-	noirqdebug = 1;
-	printk("IRQ lockup detection disabled\n");
-	return 1;
-}
-
-__setup("noirqdebug", noirqdebug_setup);
-
-/*
- * If 99,900 of the previous 100,000 interrupts have not been handled then
- * assume that the IRQ is stuck in some manner.  Drop a diagnostic and try to
- * turn the IRQ off.
- *
- * (The other 100-of-100,000 interrupts may have been a correctly-functioning
- *  device sharing an IRQ with the failing one)
- *
- * Called under desc->lock
- */
-static void note_interrupt(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	if (action_ret != IRQ_HANDLED) {
-		desc->irqs_unhandled++;
-		if (action_ret != IRQ_NONE)
-			report_bad_irq(irq, desc, action_ret);
-	}
-
-	desc->irq_count++;
-	if (desc->irq_count < 100000)
-		return;
-
-	desc->irq_count = 0;
-	if (desc->irqs_unhandled > 99900) {
-		/*
-		 * The interrupt is stuck
-		 */
-		__report_bad_irq(irq, desc, action_ret);
-		/*
-		 * Now kill the IRQ
-		 */
-		printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
-		desc->status |= IRQ_DISABLED;
-		desc->handler->disable(irq);
-	}
-	desc->irqs_unhandled = 0;
-}
-
-/*
- * Generic enable/disable code: this just calls
- * down into the PIC-specific version for the actual
- * hardware disable after having gotten the irq
- * controller lock.
- */
-
-/**
- *	disable_irq_nosync - disable an irq without waiting
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line. Disables of an interrupt
- *	stack. Unlike disable_irq(), this function does not ensure existing
- *	instances of the IRQ handler have completed before returning.
- *
- *	This function may be called from IRQ context.
- */
-
-void inline disable_irq_nosync(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	if (!desc->depth++) {
-		desc->status |= IRQ_DISABLED;
-		desc->handler->disable(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-/**
- *	disable_irq - disable an irq and wait for completion
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line. Disables of an interrupt
- *	stack. That is for two disables you need two enables. This
- *	function waits for any pending IRQ handlers for this interrupt
- *	to complete before returning. If you use this function while
- *	holding a resource the IRQ handler may need you will deadlock.
- *
- *	This function may be called - with care - from IRQ context.
- */
-
-void disable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	disable_irq_nosync(irq);
-	if (desc->action)
-		synchronize_irq(irq);
-}
-
-/**
- *	enable_irq - enable interrupt handling on an irq
- *	@irq: Interrupt to enable
- *
- *	Re-enables the processing of interrupts on this IRQ line
- *	providing no disable_irq calls are now in effect.
- *
- *	This function may be called from IRQ context.
- */
-
-void enable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	switch (desc->depth) {
-	case 1: {
-		unsigned int status = desc->status & ~(IRQ_DISABLED | IRQ_INPROGRESS);
-		desc->status = status;
-		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
-			desc->status = status | IRQ_REPLAY;
-			hw_resend_irq(desc->handler,irq);
-		}
-		desc->handler->enable(irq);
-		/* fall-through */
-	}
-	default:
-		desc->depth--;
-		break;
-	case 0:
-		printk("enable_irq(%u) unbalanced from %p\n", irq,
-		       __builtin_return_address(0));
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
+#ifdef CONFIG_KGDB
+extern void breakpoint(void);
+extern void set_debug_traps(void);
 
-/*
- * do_IRQ handles all normal device IRQ's (the special
- * SMP cross-CPU interrupts have their own specific
- * handlers).
- */
-asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs)
+static int kgdb_flag = 1;
+static int __init nokgdb(char *str)
 {
-	/*
-	 * We 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).
-	 *
-	 * 0 return value means that this irq is already being
-	 * handled by some other CPU. (or is disabled)
-	 */
-	irq_desc_t *desc = irq_desc + irq;
-	struct irqaction * action;
-	unsigned int status;
-
-	irq_enter();
-	kstat_this_cpu.irqs[irq]++;
-	spin_lock(&desc->lock);
-	desc->handler->ack(irq);
-	/*
-	   REPLAY is when Linux resends an IRQ that was dropped earlier
-	   WAITING is used by probe to mark irqs that are being tested
-	   */
-	status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
-	status |= IRQ_PENDING; /* we _want_ to handle it */
-
-	/*
-	 * If the IRQ is disabled for whatever reason, we cannot
-	 * use the action we have.
-	 */
-	action = NULL;
-	if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
-		action = desc->action;
-		status &= ~IRQ_PENDING; /* we commit to handling */
-		status |= IRQ_INPROGRESS; /* we are handling it */
-	}
-	desc->status = status;
-
-	/*
-	 * If there is no IRQ handler or it was disabled, exit early.
-	   Since we set PENDING, if another processor is handling
-	   a different instance of this same irq, the other processor
-	   will take care of it.
-	 */
-	if (unlikely(!action))
-		goto out;
-
-	/*
-	 * Edge triggered interrupts need to remember
-	 * pending events.
-	 * This applies to any hw interrupts that allow a second
-	 * instance of the same irq to arrive while we are in do_IRQ
-	 * or in the handler. But the code here only handles the _second_
-	 * instance of the irq, not the third or fourth. So it is mostly
-	 * useful for irq hardware that does not mask cleanly in an
-	 * SMP environment.
-	 */
-	for (;;) {
-		irqreturn_t action_ret;
-
-		spin_unlock(&desc->lock);
-		action_ret = handle_IRQ_event(irq, regs, action);
-		spin_lock(&desc->lock);
-		if (!noirqdebug)
-			note_interrupt(irq, desc, action_ret);
-		if (likely(!(desc->status & IRQ_PENDING)))
-			break;
-		desc->status &= ~IRQ_PENDING;
-	}
-	desc->status &= ~IRQ_INPROGRESS;
-
-out:
-	/*
-	 * The ->end() handler has to deal with interrupts which got
-	 * disabled while the handler was running.
-	 */
-	desc->handler->end(irq);
-	spin_unlock(&desc->lock);
-
-	irq_exit();
-
+	kgdb_flag = 0;
 	return 1;
 }
-
-/**
- *	request_irq - allocate an interrupt line
- *	@irq: Interrupt line to allocate
- *	@handler: Function to be called when the IRQ occurs
- *	@irqflags: Interrupt type flags
- *	@devname: An ascii name for the claiming device
- *	@dev_id: A cookie passed back to the handler function
- *
- *	This call allocates interrupt resources and enables the
- *	interrupt line and IRQ handling. From the point this
- *	call is made your handler function may be invoked. Since
- *	your handler function must clear any interrupt the board
- *	raises, you must take care both to initialise your hardware
- *	and to set up the interrupt handler in the right order.
- *
- *	Dev_id must be globally unique. Normally the address of the
- *	device data structure is used as the cookie. Since the handler
- *	receives this value it makes sense to use it.
- *
- *	If your interrupt is shared you must pass a non NULL dev_id
- *	as this is required when freeing the interrupt.
- *
- *	Flags:
- *
- *	SA_SHIRQ		Interrupt is shared
- *
- *	SA_INTERRUPT		Disable local interrupts while processing
- *
- *	SA_SAMPLE_RANDOM	The interrupt can be used for entropy
- *
- */
-
-int request_irq(unsigned int irq,
-		irqreturn_t (*handler)(int, void *, struct pt_regs *),
-		unsigned long irqflags,
-		const char * devname,
-		void *dev_id)
-{
-	int retval;
-	struct irqaction * action;
-
-#if 1
-	/*
-	 * Sanity-check: shared interrupts should REALLY pass in
-	 * a real dev-ID, otherwise we'll have trouble later trying
-	 * to figure out which interrupt is which (messes up the
-	 * interrupt freeing logic etc).
-	 */
-	if (irqflags & SA_SHIRQ) {
-		if (!dev_id)
-			printk("Bad boy: %s (at 0x%x) called us without a dev_id!\n", devname, (&irq)[-1]);
-	}
+__setup("nokgdb", nokgdb);
 #endif
 
-	if (irq >= NR_IRQS)
-		return -EINVAL;
-	if (!handler)
-		return -EINVAL;
-
-	action = (struct irqaction *)
-			kmalloc(sizeof(struct irqaction), GFP_ATOMIC);
-	if (!action)
-		return -ENOMEM;
-
-	action->handler = handler;
-	action->flags = irqflags;
-	cpus_clear(action->mask);
-	action->name = devname;
-	action->next = NULL;
-	action->dev_id = dev_id;
-
-	retval = setup_irq(irq, action);
-	if (retval)
-		kfree(action);
-	return retval;
-}
-
-EXPORT_SYMBOL(request_irq);
-
-/**
- *	free_irq - free an interrupt
- *	@irq: Interrupt line to free
- *	@dev_id: Device identity to free
- *
- *	Remove an interrupt handler. The handler is removed and if the
- *	interrupt line is no longer in use by any driver it is disabled.
- *	On a shared IRQ the caller must ensure the interrupt is disabled
- *	on the card it drives before calling this function. The function
- *	does not return until any executing interrupts for this IRQ
- *	have completed.
- *
- *	This function must not be called from interrupt context.
- */
-
-void free_irq(unsigned int irq, void *dev_id)
-{
-	irq_desc_t *desc;
-	struct irqaction **p;
-	unsigned long flags;
-
-	if (irq >= NR_IRQS)
-		return;
-
-	desc = irq_desc + irq;
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	for (;;) {
-		struct irqaction * action = *p;
-		if (action) {
-			struct irqaction **pp = p;
-			p = &action->next;
-			if (action->dev_id != dev_id)
-				continue;
-
-			/* Found it - now remove it from the list of entries */
-			*pp = action->next;
-			if (!desc->action) {
-				desc->status |= IRQ_DISABLED;
-				desc->handler->shutdown(irq);
-			}
-			spin_unlock_irqrestore(&desc->lock,flags);
-
-			/* Wait to make sure it's not being used on another CPU */
-			synchronize_irq(irq);
-			kfree(action);
-			return;
-		}
-		printk("Trying to free free IRQ%d\n",irq);
-		spin_unlock_irqrestore(&desc->lock,flags);
-		return;
-	}
-}
-
-EXPORT_SYMBOL(free_irq);
-
-/*
- * IRQ autodetection code..
- *
- * This depends on the fact that any interrupt that
- * comes in on to an unassigned handler will get stuck
- * with "IRQ_WAITING" cleared and the interrupt
- * disabled.
- */
-
-static DECLARE_MUTEX(probe_sem);
-
-/**
- *	probe_irq_on	- begin an interrupt autodetect
- *
- *	Commence probing for an interrupt. The interrupts are scanned
- *	and a mask of potential interrupt lines is returned.
- *
- */
-
-unsigned long probe_irq_on(void)
-{
-	unsigned int i;
-	irq_desc_t *desc;
-	unsigned long val;
-	unsigned long delay;
-
-	down(&probe_sem);
-	/*
-	 * something may have generated an irq long ago and we want to
-	 * flush such a longstanding irq before considering it as spurious.
-	 */
-	for (i = NR_IRQS-1; i > 0; i--)  {
-		desc = irq_desc + i;
-
-		spin_lock_irq(&desc->lock);
-		if (!irq_desc[i].action)
-			irq_desc[i].handler->startup(i);
-		spin_unlock_irq(&desc->lock);
-	}
-
-	/* Wait for longstanding interrupts to trigger. */
-	for (delay = jiffies + HZ/50; time_after(delay, jiffies); )
-		/* about 20ms delay */ barrier();
-
-	/*
-	 * enable any unassigned irqs
-	 * (we must startup again here because if a longstanding irq
-	 * happened in the previous stage, it may have masked itself)
-	 */
-	for (i = NR_IRQS-1; i > 0; i--) {
-		desc = irq_desc + i;
-
-		spin_lock_irq(&desc->lock);
-		if (!desc->action) {
-			desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
-			if (desc->handler->startup(i))
-				desc->status |= IRQ_PENDING;
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-
-	/*
-	 * Wait for spurious interrupts to trigger
-	 */
-	for (delay = jiffies + HZ/10; time_after(delay, jiffies); )
-		/* about 100ms delay */ barrier();
-
-	/*
-	 * Now filter out any obviously spurious interrupts
-	 */
-	val = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			/* It triggered already - consider it spurious. */
-			if (!(status & IRQ_WAITING)) {
-				desc->status = status & ~IRQ_AUTODETECT;
-				desc->handler->shutdown(i);
-			} else
-				if (i < 32)
-					val |= 1 << i;
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-
-	return val;
-}
-
-EXPORT_SYMBOL(probe_irq_on);
-
-/*
- * Return a mask of triggered interrupts (this
- * can handle only legacy ISA interrupts).
- */
-
-/**
- *	probe_irq_mask - scan a bitmap of interrupt lines
- *	@val:	mask of interrupts to consider
- *
- *	Scan the ISA bus interrupt lines and return a bitmap of
- *	active interrupts. The interrupt probe logic state is then
- *	returned to its previous value.
- *
- *	Note: we need to scan all the irq's even though we will
- *	only return ISA irq numbers - just so that we reset them
- *	all to a known state.
- */
-unsigned int probe_irq_mask(unsigned long val)
-{
-	int i;
-	unsigned int mask;
-
-	mask = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			if (i < 16 && !(status & IRQ_WAITING))
-				mask |= 1 << i;
-
-			desc->status = status & ~IRQ_AUTODETECT;
-			desc->handler->shutdown(i);
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-	up(&probe_sem);
-
-	return mask & val;
-}
-
-/*
- * Return the one interrupt that triggered (this can
- * handle any interrupt source).
- */
-
-/**
- *	probe_irq_off	- end an interrupt autodetect
- *	@val: mask of potential interrupts (unused)
- *
- *	Scans the unused interrupt lines and returns the line which
- *	appears to have triggered the interrupt. If no interrupt was
- *	found then zero is returned. If more than one interrupt is
- *	found then minus the first candidate is returned to indicate
- *	there is doubt.
- *
- *	The interrupt probe logic state is returned to its previous
- *	value.
- *
- *	BUGS: When used in a module (which arguably shouldnt happen)
- *	nothing prevents two IRQ probe callers from overlapping. The
- *	results of this are non-optimal.
- */
-
-int probe_irq_off(unsigned long val)
-{
-	int i, irq_found, nr_irqs;
-
-	nr_irqs = 0;
-	irq_found = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			if (!(status & IRQ_WAITING)) {
-				if (!nr_irqs)
-					irq_found = i;
-				nr_irqs++;
-			}
-			desc->status = status & ~IRQ_AUTODETECT;
-			desc->handler->shutdown(i);
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-	up(&probe_sem);
-
-	if (nr_irqs > 1)
-		irq_found = -irq_found;
-	return irq_found;
-}
-
-EXPORT_SYMBOL(probe_irq_off);
-
-/* this was setup_x86_irq but it seems pretty generic */
-int setup_irq(unsigned int irq, struct irqaction * new)
-{
-	int shared = 0;
-	unsigned long flags;
-	struct irqaction *old, **p;
-	irq_desc_t *desc = irq_desc + irq;
-
-	/*
-	 * Some drivers like serial.c use request_irq() heavily,
-	 * so we have to be careful not to interfere with a
-	 * running system.
-	 */
-	if (new->flags & SA_SAMPLE_RANDOM) {
-		/*
-		 * This function might sleep, we want to call it first,
-		 * outside of the atomic block.
-		 * Yes, this might clear the entropy pool if the wrong
-		 * driver is attempted to be loaded, without actually
-		 * installing a new handler, but is this really a problem,
-		 * only the sysadmin is able to do this.
-		 */
-		rand_initialize_irq(irq);
-	}
-
-	/*
-	 * The following block of code has to be executed atomically
-	 */
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	if ((old = *p) != NULL) {
-		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
-			spin_unlock_irqrestore(&desc->lock,flags);
-			return -EBUSY;
-		}
-
-		/* add new interrupt at end of irq queue */
-		do {
-			p = &old->next;
-			old = *p;
-		} while (old);
-		shared = 1;
-	}
-
-	*p = new;
-
-	if (!shared) {
-		desc->depth = 0;
-		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS);
-		desc->handler->startup(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock,flags);
-
-	register_irq_proc(irq);
-	return 0;
-}
-
-void __init init_generic_irq(void)
+void __init init_IRQ(void)
 {
 	int i;
 
@@ -820,108 +125,16 @@
 		irq_desc[i].action  = NULL;
 		irq_desc[i].depth   = 1;
 		irq_desc[i].handler = &no_irq_type;
+		irq_desc[i].lock = SPIN_LOCK_UNLOCKED;
 	}
-}
-
-EXPORT_SYMBOL(disable_irq_nosync);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(probe_irq_mask);
 
-static struct proc_dir_entry * root_irq_dir;
-static struct proc_dir_entry * irq_dir [NR_IRQS];
+	arch_init_irq();
 
-#ifdef CONFIG_SMP
-
-static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
-
-static cpumask_t irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = ~0UL };
-static int irq_affinity_read_proc (char *page, char **start, off_t off,
-			int count, int *eof, void *data)
-{
-	int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
-	if (count - len < 2)
-		return -EINVAL;
-	len += sprintf(page + len, "\n");
-	return len;
-}
-
-static int irq_affinity_write_proc (struct file *file, const char *buffer,
-					unsigned long count, void *data)
-{
-	int irq = (long) data, full_count = count, err;
-	cpumask_t new_value, tmp;
-
-	if (!irq_desc[irq].handler->set_affinity)
-		return -EIO;
-
-	err = cpumask_parse(buffer, count, new_value);
-
-	/*
-	 * Do not allow disabling IRQs completely - it's a too easy
-	 * way to make the system unusable accidentally :-) At least
-	 * one online CPU still has to be targeted.
-	 */
-	cpus_and(tmp, new_value, cpu_online_map);
-	if (cpus_empty(tmp))
-		return -EINVAL;
-
-	irq_affinity[irq] = new_value;
-	irq_desc[irq].handler->set_affinity(irq, new_value);
-
-	return full_count;
-}
-
-#endif
-
-#define MAX_NAMELEN 10
-
-static void register_irq_proc (unsigned int irq)
-{
-	char name [MAX_NAMELEN];
-
-	if (!root_irq_dir || (irq_desc[irq].handler == &no_irq_type) ||
-			irq_dir[irq])
-		return;
-
-	memset(name, 0, MAX_NAMELEN);
-	sprintf(name, "%d", irq);
-
-	/* create /proc/irq/1234 */
-	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
-
-#ifdef CONFIG_SMP
-	{
-		struct proc_dir_entry *entry;
-
-		/* create /proc/irq/1234/smp_affinity */
-		entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
-
-		if (entry) {
-			entry->nlink = 1;
-			entry->data = (void *)(long)irq;
-			entry->read_proc = irq_affinity_read_proc;
-			entry->write_proc = irq_affinity_write_proc;
-		}
-
-		smp_affinity_entry[irq] = entry;
+#ifdef CONFIG_KGDB
+	if (kgdb_flag) {
+		printk("Wait for gdb client connection ...\n");
+		set_debug_traps();
+		breakpoint();
 	}
 #endif
-}
-
-void init_irq_proc (void)
-{
-	int i;
-
-	/* create /proc/irq */
-	root_irq_dir = proc_mkdir("irq", 0);
-
-	/* create /proc/irq/prof_cpu_mask */
-	create_prof_cpu_mask(root_irq_dir);
-
-	/*
-	 * Create entries for all existing IRQs.
-	 */
-	for (i = 0; i < NR_IRQS; i++)
-		register_irq_proc(i);
 }
diff -Nru a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
--- a/arch/mips/kernel/process.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/kernel/process.c	2004-12-24 13:36:48 -08:00
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 1994 - 1999, 2000 by Ralf Baechle and others.
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ * Copyright (C) 2004 Thiemo Seufer
  */
 #include <linux/config.h>
 #include <linux/errno.h>
@@ -99,10 +100,14 @@
 
 	childksp = (unsigned long)ti + THREAD_SIZE - 32;
 
+	preempt_disable();
+
 	if (is_fpu_owner()) {
 		save_fp(p);
 	}
 
+	preempt_enable();
+
 	/* set up new TSS. */
 	childregs = (struct pt_regs *) childksp - 1;
 	*childregs = *regs;
@@ -140,7 +145,6 @@
 	p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1);
 	childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);
 	clear_tsk_thread_flag(p, TIF_USEDFPU);
-	p->set_child_tid = p->clear_child_tid = NULL;
 
 	return 0;
 }
@@ -155,39 +159,30 @@
 /*
  * Create a kernel thread
  */
+ATTRIB_NORET void kernel_thread_helper(void *arg, int (*fn)(void *))
+{
+	do_exit(fn(arg));
+}
+
 long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
 {
-	long retval;
+	struct pt_regs regs;
 
-	__asm__ __volatile__(
-		"	move	$6, $sp		\n"
-		"	move	$4, %5		\n"
-		"	li	$2, %1		\n"
-		"	syscall			\n"
-		"	beq	$6, $sp, 1f	\n"
-#ifdef CONFIG_MIPS32	/* On o32 the caller has to create the stackframe */
-		"	subu	$sp, 32		\n"
-#endif
-		"	move	$4, %3		\n"
-		"	jalr	%4		\n"
-		"	move	$4, $2		\n"
-		"	li	$2, %2		\n"
-		"	syscall			\n"
-#ifdef CONFIG_MIPS32	/* On o32 the caller has to deallocate the stackframe */
-		"	addiu	$sp, 32		\n"
+	memset(&regs, 0, sizeof(regs));
+
+	regs.regs[4] = (unsigned long) arg;
+	regs.regs[5] = (unsigned long) fn;
+	regs.cp0_epc = (unsigned long) kernel_thread_helper;
+	regs.cp0_status = read_c0_status();
+#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
+	regs.cp0_status &= ~(ST0_KUP | ST0_IEC);
+	regs.cp0_status |= ST0_IEP;
+#else
+	regs.cp0_status |= ST0_EXL;
 #endif
-		"1:	move	%0, $2"
-		: "=r" (retval)
-		: "i" (__NR_clone), "i" (__NR_exit), "r" (arg), "r" (fn),
-		  "r" (flags | CLONE_VM | CLONE_UNTRACED)
-		 /*
-		  * The called subroutine might have destroyed any of the
-		  * at, result, argument or temporary registers ...
-		  */
-		: "$2", "$3", "$4", "$5", "$6", "$7", "$8",
-		  "$9","$10","$11","$12","$13","$14","$15","$24","$25","$31");
 
-	return retval;
+	/* Ok, create the new process.. */
+	return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
 }
 
 struct mips_frame_info {
diff -Nru a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
--- a/arch/mips/kernel/ptrace.c	2004-12-24 13:37:33 -08:00
+++ b/arch/mips/kernel/ptrace.c	2004-12-24 13:37:33 -08:00
@@ -277,7 +277,7 @@
 	 */
 	case PTRACE_KILL:
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		wake_up_process(child);
diff -Nru a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
--- a/arch/mips/kernel/ptrace32.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/kernel/ptrace32.c	2004-12-24 13:36:48 -08:00
@@ -262,7 +262,7 @@
 	 */
 	case PTRACE_KILL:
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		wake_up_process(child);
diff -Nru a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
--- a/arch/mips/kernel/r4k_switch.S	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/kernel/r4k_switch.S	2004-12-24 13:37:29 -08:00
@@ -75,17 +75,8 @@
 	and	t0, t0, t1
 	LONG_S	t0, ST_OFF(t3)
 
-#ifdef CONFIG_MIPS32
-	fpu_save_double a0 t0			# clobbers t0
-#endif
-#ifdef CONFIG_MIPS64
-	sll	t2, t0, 5
-	bgez	t2, 2f
-	sdc1	$f0, (THREAD_FPU + 0x00)(a0)
-        fpu_save_16odd a0
-2:
-        fpu_save_16even a0 t1                   # clobbers t1
-#endif
+	fpu_save_double a0 t1 t0 t2		# c0_status passed in t1
+						# clobbers t0 and t2
 1:
 
 	/*
@@ -114,18 +105,10 @@
  * Save a thread's fp context.
  */
 LEAF(_save_fp)
-#ifdef CONFIG_MIPS32
-	fpu_save_double a0 t1			# clobbers t1
-#endif
 #ifdef CONFIG_MIPS64
-	mfc0	t0, CP0_STATUS
-	sll	t1, t0, 5
-	bgez	t1, 1f				# 16 register mode?
-	fpu_save_16odd a0
-1:
-	fpu_save_16even a0 t1			# clobbers t1
-	sdc1	$f0, (THREAD_FPU + 0x00)(a0)
+	mfc0	t1, CP0_STATUS
 #endif
+	fpu_save_double a0 t1 t0 t2		# clobbers t1
 	jr	ra
 	END(_save_fp)
 
@@ -133,19 +116,7 @@
  * Restore a thread's fp context.
  */
 LEAF(_restore_fp)
-#ifdef CONFIG_MIPS32
 	fpu_restore_double a0, t1		# clobbers t1
-#endif
-#ifdef CONFIG_MIPS64
-	mfc0	t0, CP0_STATUS
-	sll	t1, t0, 5
-	bgez	t1, 1f				# 16 register mode?
-
-	fpu_restore_16odd a0
-1:	fpu_restore_16even a0, t0		# clobbers t0
-	 ldc1	$f0, (THREAD_FPU + 0x00)(a0)
-#endif
-
 	jr	ra
 	END(_restore_fp)
 
diff -Nru a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
--- a/arch/mips/kernel/scall32-o32.S	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/kernel/scall32-o32.S	2004-12-24 13:36:18 -08:00
@@ -17,6 +17,7 @@
 #include <asm/sysmips.h>
 #include <asm/thread_info.h>
 #include <asm/unistd.h>
+#include <asm/war.h>
 #include <asm/offset.h>
 
 /* Highest syscall used of any syscall flavour */
@@ -65,7 +66,7 @@
 					# restarting
 1:	sw	v0, PT_R2(sp)		# result
 
-EXPORT(o32_syscall_exit)
+o32_syscall_exit:
 	local_irq_disable		# make sure need_resched and
 					# signals dont change between
 					# sampling and return
@@ -83,17 +84,16 @@
 
 syscall_trace_entry:
 	SAVE_STATIC
-	sw	t2, PT_R1(sp)
+	move	s0, t2
 	move	a0, sp
 	li	a1, 0
 	jal	do_syscall_trace
-	lw	t2, PT_R1(sp)
 
 	lw	a0, PT_R4(sp)		# Restore argument registers
 	lw	a1, PT_R5(sp)
 	lw	a2, PT_R6(sp)
 	lw	a3, PT_R7(sp)
-	jalr	t2
+	jalr	s0
 
 	li	t0, -EMAXERRNO - 1	# error?
 	sltu	t0, t0, v0
@@ -199,7 +199,11 @@
 1:	ll	v0, (a1)
 	move	a0, a2
 2:	sc	a0, (a1)
+#if R10000_LLSC_WAR
+	beqzl	a0, 1b
+#else
 	beqz	a0, 1b
+#endif
 
 	.section __ex_table,"a"
 	PTR	1b, bad_stack
@@ -618,7 +622,7 @@
 	sys	sys_clock_nanosleep	4	/* 4265 */
 	sys	sys_tgkill		3
 	sys	sys_utimes		2
-	sys	sys_ni_syscall		0	/* sys_mbind */
+	sys	sys_mbind		4
 	sys	sys_ni_syscall		0	/* sys_get_mempolicy */
 	sys	sys_ni_syscall		0	/* 4270 sys_set_mempolicy */
 	sys	sys_mq_open		4
@@ -628,6 +632,11 @@
 	sys	sys_mq_notify		2	/* 4275 */
 	sys	sys_mq_getsetattr	3
 	sys	sys_ni_syscall		0	/* sys_vserver */
+	sys	sys_waitid		4
+	sys	sys_ni_syscall		0	/* available, was setaltroot */
+	sys	sys_add_key		5
+	sys	sys_request_key		4
+	sys	sys_keyctl		5
 
 	.endm
 
diff -Nru a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
--- a/arch/mips/kernel/scall64-64.S	2004-12-24 13:37:02 -08:00
+++ b/arch/mips/kernel/scall64-64.S	2004-12-24 13:37:02 -08:00
@@ -18,6 +18,7 @@
 #include <asm/sysmips.h>
 #include <asm/thread_info.h>
 #include <asm/unistd.h>
+#include <asm/war.h>
 
 #ifndef CONFIG_BINFMT_ELF32
 /* Neither O32 nor N32, so define handle_sys here */
@@ -37,8 +38,7 @@
 	.set	at
 #endif
 
-FEXPORT(__handle_sys64)
-	subu	t0, v0, __NR_64_Linux	# check syscall number
+	dsubu	t0, v0, __NR_64_Linux	# check syscall number
 	sltiu	t0, t0,	__NR_64_Linux_syscalls + 1
 #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32)
 	ld	t1, PT_EPC(sp)		# skip syscall on return
@@ -63,12 +63,12 @@
 	sd	t0, PT_R7(sp)		# set error flag
 	beqz	t0, 1f
 
-	negu	v0			# error
+	dnegu	v0			# error
 	sd	v0, PT_R0(sp)		# set flag for syscall
 					# restarting
 1:	sd	v0, PT_R2(sp)		# result
 
-syscall_exit:
+n64_syscall_exit:
 	local_irq_disable		# make sure need_resched and
 					# signals dont change between
 					# sampling and return
@@ -86,24 +86,25 @@
 
 syscall_trace_entry:
 	SAVE_STATIC
-	sd	t2,PT_R1(sp)
+	move	s0, t2
 	move	a0, sp
 	li	a1, 0
 	jal	do_syscall_trace
-	ld	t2,PT_R1(sp)
 
 	ld	a0, PT_R4(sp)		# Restore argument registers
 	ld	a1, PT_R5(sp)
 	ld	a2, PT_R6(sp)
 	ld	a3, PT_R7(sp)
-	jalr	t2
+	ld	a4, PT_R8(sp)
+	ld	a5, PT_R9(sp)
+	jalr	s0
 
 	li	t0, -EMAXERRNO - 1	# error?
 	sltu	t0, t0, v0
 	sd	t0, PT_R7(sp)		# set error flag
 	beqz	t0, 1f
 
-	negu	v0			# error
+	dnegu	v0			# error
 	sd	v0, PT_R0(sp)		# set flag for syscall restarting
 1:	sd	v0, PT_R2(sp)		# result
 
@@ -115,7 +116,7 @@
 	sd	v0, PT_R2(sp)
 	li	t0, 1				# set error flag
 	sd	t0, PT_R7(sp)
-	j	syscall_exit
+	j	n64_syscall_exit
 	END(handle_sys64)
 
 	LEAF(mips_atomic_set)
@@ -133,7 +134,11 @@
 1:	ll	v0, (a1)
 	move	a0, a2
 2:	sc	a0, (a1)
+#if R10000_LLSC_WAR
+	beqzl	a0, 1b
+#else
 	beqz	a0, 1b
+#endif
 
 	.section __ex_table,"a"
 	PTR	1b, bad_stack
@@ -173,7 +178,7 @@
 	and	t0, a2, t0
 	bnez	t0, 1f
 
-	b	syscall_exit
+	j	n64_syscall_exit
 
 1:	SAVE_STATIC
 	move	a0, sp
@@ -198,17 +203,6 @@
 	j	_sys_sysmips
 	END(sys_sysmips)
 
-	LEAF(sys_syscall)			/* Quick'n'dirty ... */
-	move	v0, a0
-	move	a0, a1
-	move	a1, a2
-	move	a2, a3
-	move	a3, a4
-	move	a4, a5
-	move	a5, a6
-	j	__handle_sys64
-	END(sys_syscall)
-
 	.align	3
 sys_call_table:
 	PTR	sys_read			/* 5000 */
@@ -438,7 +432,7 @@
 	PTR	sys_clock_nanosleep
 	PTR	sys_tgkill			/* 5225 */
 	PTR	sys_utimes
-	PTR	sys_ni_syscall			/* sys_mbind */
+	PTR	sys_mbind
 	PTR	sys_ni_syscall			/* sys_get_mempolicy */
 	PTR	sys_ni_syscall			/* sys_set_mempolicy */
 	PTR	sys_mq_open			/* 5230 */
@@ -448,3 +442,8 @@
 	PTR	sys_mq_notify
 	PTR	sys_mq_getsetattr		/* 5235 */
 	PTR	sys_ni_syscall			/* sys_vserver */
+	PTR	sys_waitid
+	PTR	sys_ni_syscall			/* available, was setaltroot */
+	PTR	sys_add_key
+	PTR	sys_request_key			/* 5240 */
+	PTR	sys_keyctl
diff -Nru a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
--- a/arch/mips/kernel/scall64-n32.S	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/kernel/scall64-n32.S	2004-12-24 13:37:19 -08:00
@@ -37,7 +37,7 @@
 	.set	at
 #endif
 
-	subu	t0, v0, __NR_N32_Linux	# check syscall number
+	dsubu	t0, v0, __NR_N32_Linux	# check syscall number
 	sltiu	t0, t0,	__NR_N32_Linux_syscalls + 1
 
 #ifndef CONFIG_MIPS32_O32
@@ -64,11 +64,10 @@
 	sd	t0, PT_R7(sp)		# set error flag
 	beqz	t0, 1f
 
-	negu	v0			# error
+	dnegu	v0			# error
 	sd	v0, PT_R0(sp)		# set flag for syscall restarting
 1:	sd	v0, PT_R2(sp)		# result
 
-FEXPORT(n32_syscall_exit)
 	local_irq_disable		# make sure need_resched and
 					# signals dont change between
 					# sampling and return
@@ -86,28 +85,29 @@
 
 n32_syscall_trace_entry:
 	SAVE_STATIC
-	sd	t2,PT_R1(sp)
+	move	s0, t2
 	move	a0, sp
 	li	a1, 0
 	jal	do_syscall_trace
-	ld	t2,PT_R1(sp)
 
 	ld	a0, PT_R4(sp)		# Restore argument registers
 	ld	a1, PT_R5(sp)
 	ld	a2, PT_R6(sp)
 	ld	a3, PT_R7(sp)
-	jalr	t2
+	ld	a4, PT_R8(sp)
+	ld	a5, PT_R9(sp)
+	jalr	s0
 
 	li	t0, -EMAXERRNO - 1	# error?
 	sltu	t0, t0, v0
 	sd	t0, PT_R7(sp)		# set error flag
 	beqz	t0, 1f
 
-	negu	v0			# error
+	dnegu	v0			# error
 	sd	v0, PT_R0(sp)		# set flag for syscall restarting
 1:	sd	v0, PT_R2(sp)		# result
 
-	j	n32_syscall_exit
+	j	syscall_exit
 
 not_n32_scall:
 	/* This is not an n32 compatibility syscall, pass it on to
@@ -334,8 +334,8 @@
 	PTR	sys_restart_syscall
 	PTR	sys_semtimedop			/* 6215 */
 	PTR	sys_fadvise64_64
-	PTR	sys_statfs64
-	PTR	sys_fstatfs64
+	PTR	compat_sys_statfs64
+	PTR	compat_sys_fstatfs64
 	PTR	sys_sendfile64
 	PTR	sys_timer_create		/* 6220 */
 	PTR	sys_timer_settime
@@ -356,5 +356,10 @@
 	PTR	compat_sys_mq_timedsend
 	PTR	compat_sys_mq_timedreceive
 	PTR	compat_sys_mq_notify
-	PTR	compat_sys_mq_getsetattr	/* 6239 */
-	PTR	sys_ni_syscall			/* sys_vserver */
+	PTR	compat_sys_mq_getsetattr
+	PTR	sys_ni_syscall			/* 6240, sys_vserver */
+	PTR	sys_waitid
+	PTR	sys_ni_syscall			/* available, was setaltroot */
+	PTR	sys_add_key
+	PTR	sys_request_key
+	PTR	sys_keyctl			/* 6245 */
diff -Nru a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
--- a/arch/mips/kernel/scall64-o32.S	2004-12-24 13:36:16 -08:00
+++ b/arch/mips/kernel/scall64-o32.S	2004-12-24 13:36:16 -08:00
@@ -31,7 +31,7 @@
 	.set	at
 	ld	t1, PT_EPC(sp)		# skip syscall on return
 
-	subu	t0, v0, __NR_O32_Linux	# check syscall number
+	dsubu	t0, v0, __NR_O32_Linux	# check syscall number
 	sltiu	t0, t0, __NR_O32_Linux_syscalls + 1
 	daddiu	t1, 4			# skip to next instruction
 	sd	t1, PT_EPC(sp)
@@ -48,16 +48,33 @@
 	sll	a2, a2, 0
 	sll	a3, a3, 0
 
-	/* XXX Put both in one cacheline, should save a bit. */
 	dsll	t0, v0, 3		# offset into table
 	ld	t2, (sys_call_table - (__NR_O32_Linux * 8))(t0)
-	lbu	t3, (sys_narg_table - __NR_O32_Linux)(v0)
 
-	subu	t0, t3, 5		# 5 or more arguments?
 	sd	a3, PT_R26(sp)		# save a3 for syscall restarting
-	bgez	t0, stackargs
 
-stack_done:
+	/*
+	 * More than four arguments.  Try to deal with it by copying the
+	 * stack arguments from the user stack to the kernel stack.
+	 * This Sucks (TM).
+	 *
+	 * We intentionally keep the kernel stack a little below the top of
+	 * userspace so we don't have to do a slower byte accurate check here.
+	 */
+	ld	t0, PT_R29(sp)		# get old user stack pointer
+	daddu	t1, t0, 32
+	bltz	t1, bad_stack
+
+1:	lw	a4, 16(t0)		# argument #5 from usp
+2:	lw	a5, 20(t0)		# argument #6 from usp
+3:	lw	a6, 24(t0)		# argument #7 from usp
+
+	.section __ex_table,"a"
+	PTR	1b, bad_stack
+	PTR	2b, bad_stack
+	PTR	3b, bad_stack
+	.previous
+
 	li	t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
 	LONG_L	t0, TI_FLAGS($28)	# syscall tracing enabled?
 	and	t0, t1, t0
@@ -70,7 +87,7 @@
 	sd	t0, PT_R7(sp)		# set error flag
 	beqz	t0, 1f
 
-	negu	v0			# error
+	dnegu	v0			# error
 	sd	v0, PT_R0(sp)		# flag for syscall restarting
 1:	sd	v0, PT_R2(sp)		# result
 
@@ -97,11 +114,10 @@
 	sd	a6, PT_R10(sp)
 	sd	a7, PT_R11(sp)
 
-	sd	t2,PT_R1(sp)
+	move	s0, t2
 	move	a0, sp
 	li	a1, 0
 	jal	do_syscall_trace
-	ld	t2,PT_R1(sp)
 
 	ld	a0, PT_R4(sp)		# Restore argument registers
 	ld	a1, PT_R5(sp)
@@ -109,15 +125,15 @@
 	ld	a3, PT_R7(sp)
 	ld	a4, PT_R8(sp)
 	ld	a5, PT_R9(sp)
-
-	jalr	t2
+	ld	a6, PT_R10(sp)		# For indirect syscalls
+	jalr	s0
 
 	li	t0, -EMAXERRNO - 1	# error?
 	sltu	t0, t0, v0
 	sd	t0, PT_R7(sp)		# set error flag
 	beqz	t0, 1f
 
-	negu	v0			# error
+	dnegu	v0			# error
 	sd	v0, PT_R0(sp)		# set flag for syscall restarting
 1:	sd	v0, PT_R2(sp)		# result
 
@@ -126,45 +142,10 @@
 /* ------------------------------------------------------------------------ */
 
 	/*
-	 * More than four arguments.  Try to deal with it by copying the
-	 * stack arguments from the user stack to the kernel stack.
-	 * This Sucks (TM).
-	 */
-stackargs:
-	ld	t0, PT_R29(sp)		# get old user stack pointer
-	subu	t3, 4
-	sll	t1, t3, 2		# stack valid?
-
-	addu	t1, t0			# end address
-	or	t0, t1
-	bltz	t0, bad_stack		# -> sp is bad
-
-	ld	t0, PT_R29(sp)		# get old user stack pointer
-	PTR_LA	t1, 3f			# copy 1 to 2 arguments
-	sll	t3, t3, 2
-	subu	t1, t3
-	jr	t1
-
-	/* Ok, copy the args from the luser stack to the kernel stack */
-	.set	push
-	.set	noreorder
-	.set	nomacro
-1:	lw	a5, 20(t0)		# argument #6 from usp
-2:	lw	a4, 16(t0)		# argument #5 from usp
-3:	.set	pop
-
-	j	stack_done		# go back
-
-	.section __ex_table,"a"
-	PTR	1b, bad_stack
-	PTR	2b, bad_stack
-	.previous
-
-	/*
 	 * The stackpointer for a call with more than 4 arguments is bad.
 	 */
 bad_stack:
-	negu	v0			# error
+	dnegu	v0			# error
 	sd	v0, PT_R0(sp)
 	sd	v0, PT_R2(sp)
 	li	t0, 1			# set error flag
@@ -200,7 +181,6 @@
 	dsll	v0, a0, 3
 	dla	v1, sys32_syscall
 	ld	t2, (sys_call_table - (__NR_O32_Linux * 8))(v0)
-	lbu	t3, (sys_narg_table - __NR_O32_Linux)(a0)
 
 	li	v0, -EINVAL
 	beq	t2, v1, out		# do not recurse
@@ -220,26 +200,9 @@
 	move	a0, a1			# shift argument registers
 	move	a1, a2
 	move	a2, a3
-
-1:	lw	a3, 16(t0)
-2:	lw	t3, 20(t0)
-3:	lw	t1, 24(t0)
-
-	.section __ex_table,"a"
-	PTR	1b, efault
-	PTR	2b, efault
-	PTR	3b, efault
-	.previous
-
-	sw	t3, 16(sp)		# put into new stackframe
-	sw	t1, 20(sp)
-
-	bnez	t1, 1f			# zero arguments?
-	daddu	a0, sp, 32		# then pass sp in a0
-1:
-
-	sw	t3, 16(sp)
-	sw	v1, 20(sp)
+	move	a3, a4
+	move	a4, a5
+	move	a5, a6
 	jr	t2
 	/* Unreached */
 
@@ -257,299 +220,290 @@
 out:	jr	ra
 	END(sys32_syscall)
 
-	.macro	syscalltable
-	sys	sys32_syscall	0			/* 4000 */
-	sys	sys_exit	1
-	sys	sys_fork	0
-	sys	sys_read	3
-	sys	sys_write	3
-	sys	sys_open	3			/* 4005 */
-	sys	sys_close	1
-	sys	sys_waitpid	3
-	sys	sys_creat	2
-	sys	sys_link	2
-	sys	sys_unlink	1			/* 4010 */
-	sys	sys32_execve	0
-	sys	sys_chdir	1
-	sys	sys_time	1
-	sys	sys_mknod	3
-	sys	sys_chmod	2			/* 4015 */
-	sys	sys_lchown	3
-	sys	sys_ni_syscall	0
-	sys	sys_ni_syscall	0			/* was sys_stat */
-	sys	sys_lseek	3
-	sys	sys_getpid	0			/* 4020 */
-	sys	sys_mount	5
-	sys	sys_oldumount	1
-	sys	sys_setuid	1
-	sys	sys_getuid	0
-	sys	sys_stime	1			/* 4025 */
-	sys	sys32_ptrace	4
-	sys	sys_alarm	1
-	sys	sys_ni_syscall	0			/* was sys_fstat */
-	sys	sys_pause	0
-	sys	compat_sys_utime	2			/* 4030 */
-	sys	sys_ni_syscall	0
-	sys	sys_ni_syscall	0
-	sys	sys_access	2
-	sys	sys_nice	1
-	sys	sys_ni_syscall	0			/* 4035 */
-	sys	sys_sync	0
-	sys	sys_kill	2
-	sys	sys_rename	2
-	sys	sys_mkdir	2
-	sys	sys_rmdir	1			/* 4040 */
-	sys	sys_dup		1
-	sys	sys_pipe	0
-	sys	compat_sys_times	1
-	sys	sys_ni_syscall	0
-	sys	sys_brk		1			/* 4045 */
-	sys	sys_setgid	1
-	sys	sys_getgid	0
-	sys	sys_ni_syscall	0	/* was signal	2 */
-	sys	sys_geteuid	0
-	sys	sys_getegid	0			/* 4050 */
-	sys	sys_acct	0
-	sys	sys_umount	2
-	sys	sys_ni_syscall	0
-	sys	compat_sys_ioctl	3
-	sys	compat_sys_fcntl	3		/* 4055 */
-	sys	sys_ni_syscall	2
-	sys	sys_setpgid	2
-	sys	sys_ni_syscall, 0
-	sys	sys_olduname	1
-	sys	sys_umask	1			/* 4060 */
-	sys	sys_chroot	1
-	sys	sys32_ustat	2
-	sys	sys_dup2	2
-	sys	sys_getppid	0
-	sys	sys_getpgrp	0			/* 4065 */
-	sys	sys_setsid	0
-	sys	sys32_sigaction	3
-	sys	sys_sgetmask	0
-	sys	sys_ssetmask	1
-	sys	sys_setreuid	2			/* 4070 */
-	sys	sys_setregid	2
-	sys	sys32_sigsuspend	0
-	sys	compat_sys_sigpending	1
-	sys	sys_sethostname	2
-	sys	compat_sys_setrlimit	2		/* 4075 */
-	sys	compat_sys_getrlimit	2
-	sys	compat_sys_getrusage	2
-	sys	sys32_gettimeofday 2
-	sys	sys32_settimeofday 2
-	sys	sys_getgroups	2			/* 4080 */
-	sys	sys_setgroups	2
-	sys	sys_ni_syscall	0			/* old_select */
-	sys	sys_symlink	2
-	sys	sys_ni_syscall	0			/* was sys_lstat */
-	sys	sys_readlink	3			/* 4085 */
-	sys	sys_uselib	1
-	sys	sys_swapon	2
-	sys	sys_reboot	3
-	sys	sys32_readdir	3
-	sys	old_mmap	6			/* 4090 */
-	sys	sys_munmap	2
-	sys	sys_truncate	2
-	sys	sys_ftruncate	2
-	sys	sys_fchmod	2
-	sys	sys_fchown	3			/* 4095 */
-	sys	sys_getpriority	2
-	sys	sys_setpriority	3
-	sys	sys_ni_syscall	0
-	sys	compat_sys_statfs	2
-	sys	compat_sys_fstatfs	2		/* 4100 */
-	sys	sys_ni_syscall		0		/* sys_ioperm */
-	sys	sys32_socketcall		2
-	sys	sys_syslog		3
-	sys	compat_sys_setitimer	3
-	sys	compat_sys_getitimer	2	/* 4105 */
-	sys	compat_sys_newstat	2
-	sys	compat_sys_newlstat	2
-	sys	compat_sys_newfstat	2
-	sys	sys_uname		1
-	sys	sys_ni_syscall		0	/* sys_ioperm  *//* 4110 */
-	sys	sys_vhangup		0
-	sys	sys_ni_syscall		0	/* was sys_idle	 */
-	sys	sys_ni_syscall		0	/* sys_vm86 */
-	sys	sys32_wait4		4
-	sys	sys_swapoff		1	/* 4115 */
-	sys	sys32_sysinfo		1
-	sys	sys32_ipc		6
-	sys	sys_fsync	1
-	sys	sys32_sigreturn	0
-	sys	sys_clone	0			/* 4120 */
-	sys	sys_setdomainname 2
-	sys	sys32_newuname	1
-	sys	sys_ni_syscall	0	/* sys_modify_ldt */
-	sys	sys32_adjtimex	1
-	sys	sys_mprotect	3			/* 4125 */
-	sys	compat_sys_sigprocmask	3
-	sys	sys_ni_syscall	0			/* was creat_module */
-	sys	sys_init_module	5
-	sys	sys_delete_module 1
-	sys	sys_ni_syscall	0		/* 4130, get_kernel_syms */
-	sys	sys_quotactl	0
-	sys	sys_getpgid	1
-	sys	sys_fchdir	1
-	sys	sys_bdflush	2
-	sys	sys_sysfs	3			/* 4135 */
-	sys	sys32_personality	1
-	sys	sys_ni_syscall	0 /* for afs_syscall */
-	sys	sys_setfsuid	1
-	sys	sys_setfsgid	1
-	sys	sys32_llseek	5			/* 4140 */
-	sys	sys32_getdents	3
-	sys	compat_sys_select	5
-	sys	sys_flock	2
-	sys	sys_msync	3
-	sys	compat_sys_readv	3		/* 4145 */
-	sys	compat_sys_writev	3
-	sys	sys_cacheflush	3
-	sys	sys_cachectl	3
-	sys	sys_sysmips	4
-	sys	sys_ni_syscall	0			/* 4150 */
-	sys	sys_getsid	1
-	sys	sys_fdatasync	0
-	sys	sys32_sysctl	1
-	sys	sys_mlock	2
-	sys	sys_munlock	2			/* 4155 */
-	sys	sys_mlockall	1
-	sys	sys_munlockall	0
-	sys	sys_sched_setparam 2
-	sys	sys_sched_getparam 2
-	sys	sys_sched_setscheduler 3		/* 4160 */
-	sys	sys_sched_getscheduler 1
-	sys	sys_sched_yield	0
-	sys	sys_sched_get_priority_max 1
-	sys	sys_sched_get_priority_min 1
-	sys	sys32_sched_rr_get_interval 2		/* 4165 */
-	sys	compat_sys_nanosleep	2
-	sys	sys_mremap	4
-	sys	sys_accept	3
-	sys	sys_bind	3
-	sys	sys_connect	3			/* 4170 */
-	sys	sys_getpeername	3
-	sys	sys_getsockname	3
-	sys	sys_getsockopt	5
-	sys	sys_listen	2
-	sys	sys_recv	4			/* 4175 */
-	sys	sys_recvfrom	6
-	sys	compat_sys_recvmsg	3
-	sys	sys_send	4
-	sys	compat_sys_sendmsg	3
-	sys	sys_sendto	6			/* 4180 */
-	sys	compat_sys_setsockopt	5
-	sys	sys_shutdown	2
-	sys	sys_socket	3
-	sys	sys_socketpair	4
-	sys	sys_setresuid	3			/* 4185 */
-	sys	sys_getresuid	3
-	sys	sys_ni_syscall	0			/* was query_module */
-	sys	sys_poll	3
-	sys	sys_nfsservctl	3
-	sys	sys_setresgid	3			/* 4190 */
-	sys	sys_getresgid	3
-	sys	sys_prctl	5
-	sys	sys32_rt_sigreturn 0
-	sys	sys32_rt_sigaction 4
-	sys	sys32_rt_sigprocmask 4			/* 4195 */
-	sys	sys32_rt_sigpending 2
-	sys	sys32_rt_sigtimedwait 4
-	sys	sys32_rt_sigqueueinfo 3
-	sys	sys32_rt_sigsuspend 0
-	sys	sys32_pread	6			/* 4200 */
-	sys	sys32_pwrite	6
-	sys	sys_chown	3
-	sys	sys_getcwd	2
-	sys	sys_capget	2
-	sys	sys_capset	2			/* 4205 */
-	sys	sys32_sigaltstack	0
-	sys	sys32_sendfile	4
-	sys	sys_ni_syscall	0
-	sys	sys_ni_syscall	0
-	sys	sys32_mmap2	6			/* 4210 */
-	sys	sys32_truncate64	4
-	sys	sys32_ftruncate64	4
-	sys	sys_newstat	2
-	sys	sys_newlstat	2
-	sys	sys_newfstat	2			/* 4215 */
-	sys	sys_pivot_root	2
-	sys	sys_mincore	3
-	sys	sys_madvise	3
-	sys	sys_getdents64	3
-	sys	compat_sys_fcntl64	3		/* 4220 */
-	sys	sys_ni_syscall	0
-	sys	sys_gettid	0
-	sys	sys32_readahead	5
-	sys	sys_setxattr	5
-	sys	sys_lsetxattr	5			/* 4225 */
-	sys	sys_fsetxattr	5
-	sys	sys_getxattr	4
-	sys	sys_lgetxattr	4
-	sys	sys_fgetxattr	4
-	sys	sys_listxattr	3			/* 4230 */
-	sys	sys_llistxattr	3
-	sys	sys_flistxattr	3
-	sys	sys_removexattr	2
-	sys	sys_lremovexattr	2
-	sys	sys_fremovexattr	2		/* 4235 */
-	sys	sys_tkill		2
-	sys	sys_sendfile64		5
-	sys	compat_sys_futex	5
-	sys	compat_sys_sched_setaffinity	3
-	sys	compat_sys_sched_getaffinity	3	/* 4240 */
-	sys	sys_io_setup		2
-	sys	sys_io_destroy		1
-	sys	sys_io_getevents	5
-	sys	sys_io_submit		3
-	sys	sys_io_cancel		3		/* 4245 */
-	sys	sys_exit_group		1
-	sys	sys_lookup_dcookie	3
-	sys	sys_epoll_create	1
-	sys	sys_epoll_ctl		4
-	sys	sys_epoll_wait		3		/* 4250 */
-	sys	sys_remap_file_pages	5
-	sys	sys_set_tid_address	1
-	sys	sys_restart_syscall	0
-	sys	sys_fadvise64_64	7
-	sys	sys_statfs64		3		/* 4255 */
-	sys	sys_fstatfs64		2
-	sys	sys_timer_create	3
-	sys	sys_timer_settime	4
-	sys	sys_timer_gettime	2
-	sys	sys_timer_getoverrun	1		/* 4260 */
-	sys	sys_timer_delete	1
-	sys	sys_clock_settime	2
-	sys	sys_clock_gettime	2
-	sys	sys_clock_getres	2
-	sys	sys_clock_nanosleep	4		/* 4265 */
-	sys	sys_tgkill		3
-	sys	compat_sys_utimes	2
-	sys	sys_ni_syscall		0	/* sys_mbind */
-	sys	sys_ni_syscall		0	/* sys_get_mempolicy */
-	sys	sys_ni_syscall		0	/* 4270 sys_set_mempolicy */
-	sys	compat_sys_mq_open	4
-	sys	sys_mq_unlink		1
-	sys	compat_sys_mq_timedsend	5
-	sys	compat_sys_mq_timedreceive 5
-	sys	compat_sys_mq_notify	2	/* 4275 */
-	sys	compat_sys_mq_getsetattr 3
-	sys	sys_ni_syscall		0	/* sys_vserver */
-
-	.endm
-
-	.macro	sys function, nargs
-	PTR	\function
-	.endm
-
 	.align	3
+	.type	sys_call_table,@object;
 sys_call_table:
-	syscalltable
-
-	.macro	sys function, nargs
-	.byte	\nargs
-	.endm
-
-sys_narg_table:
-	syscalltable
+	PTR	sys32_syscall			/* 4000 */
+	PTR	sys_exit
+	PTR	sys_fork
+	PTR	sys_read
+	PTR	sys_write
+	PTR	sys_open			/* 4005 */
+	PTR	sys_close
+	PTR	sys_waitpid
+	PTR	sys_creat
+	PTR	sys_link
+	PTR	sys_unlink			/* 4010 */
+	PTR	sys32_execve
+	PTR	sys_chdir
+	PTR	sys_time
+	PTR	sys_mknod
+	PTR	sys_chmod			/* 4015 */
+	PTR	sys_lchown
+	PTR	sys_ni_syscall
+	PTR	sys_ni_syscall			/* was sys_stat */
+	PTR	sys_lseek
+	PTR	sys_getpid			/* 4020 */
+	PTR	sys_mount
+	PTR	sys_oldumount
+	PTR	sys_setuid
+	PTR	sys_getuid
+	PTR	sys_stime			/* 4025 */
+	PTR	sys32_ptrace
+	PTR	sys_alarm
+	PTR	sys_ni_syscall			/* was sys_fstat */
+	PTR	sys_pause
+	PTR	compat_sys_utime		/* 4030 */
+	PTR	sys_ni_syscall
+	PTR	sys_ni_syscall
+	PTR	sys_access
+	PTR	sys_nice
+	PTR	sys_ni_syscall			/* 4035 */
+	PTR	sys_sync
+	PTR	sys_kill
+	PTR	sys_rename
+	PTR	sys_mkdir
+	PTR	sys_rmdir			/* 4040 */
+	PTR	sys_dup
+	PTR	sys_pipe
+	PTR	compat_sys_times
+	PTR	sys_ni_syscall
+	PTR	sys_brk				/* 4045 */
+	PTR	sys_setgid
+	PTR	sys_getgid
+	PTR	sys_ni_syscall			/* was signal	2 */
+	PTR	sys_geteuid
+	PTR	sys_getegid			/* 4050 */
+	PTR	sys_acct
+	PTR	sys_umount
+	PTR	sys_ni_syscall
+	PTR	compat_sys_ioctl
+	PTR	compat_sys_fcntl		/* 4055 */
+	PTR	sys_ni_syscall
+	PTR	sys_setpgid
+	PTR	sys_ni_syscall
+	PTR	sys_olduname
+	PTR	sys_umask			/* 4060 */
+	PTR	sys_chroot
+	PTR	sys32_ustat
+	PTR	sys_dup2
+	PTR	sys_getppid
+	PTR	sys_getpgrp			/* 4065 */
+	PTR	sys_setsid
+	PTR	sys32_sigaction
+	PTR	sys_sgetmask
+	PTR	sys_ssetmask
+	PTR	sys_setreuid			/* 4070 */
+	PTR	sys_setregid
+	PTR	sys32_sigsuspend
+	PTR	compat_sys_sigpending
+	PTR	sys_sethostname
+	PTR	compat_sys_setrlimit		/* 4075 */
+	PTR	compat_sys_getrlimit
+	PTR	compat_sys_getrusage
+	PTR	sys32_gettimeofday
+	PTR	sys32_settimeofday
+	PTR	sys_getgroups			/* 4080 */
+	PTR	sys_setgroups
+	PTR	sys_ni_syscall			/* old_select */
+	PTR	sys_symlink
+	PTR	sys_ni_syscall			/* was sys_lstat */
+	PTR	sys_readlink			/* 4085 */
+	PTR	sys_uselib
+	PTR	sys_swapon
+	PTR	sys_reboot
+	PTR	sys32_readdir
+	PTR	old_mmap			/* 4090 */
+	PTR	sys_munmap
+	PTR	sys_truncate
+	PTR	sys_ftruncate
+	PTR	sys_fchmod
+	PTR	sys_fchown			/* 4095 */
+	PTR	sys_getpriority
+	PTR	sys_setpriority
+	PTR	sys_ni_syscall
+	PTR	compat_sys_statfs
+	PTR	compat_sys_fstatfs		/* 4100 */
+	PTR	sys_ni_syscall			/* sys_ioperm */
+	PTR	sys32_socketcall
+	PTR	sys_syslog
+	PTR	compat_sys_setitimer
+	PTR	compat_sys_getitimer		/* 4105 */
+	PTR	compat_sys_newstat
+	PTR	compat_sys_newlstat
+	PTR	compat_sys_newfstat
+	PTR	sys_uname
+	PTR	sys_ni_syscall			/* sys_ioperm  *//* 4110 */
+	PTR	sys_vhangup
+	PTR	sys_ni_syscall			/* was sys_idle	 */
+	PTR	sys_ni_syscall			/* sys_vm86 */
+	PTR	sys32_wait4
+	PTR	sys_swapoff			/* 4115 */
+	PTR	sys32_sysinfo
+	PTR	sys32_ipc
+	PTR	sys_fsync
+	PTR	sys32_sigreturn
+	PTR	sys_clone			/* 4120 */
+	PTR	sys_setdomainname
+	PTR	sys32_newuname
+	PTR	sys_ni_syscall			/* sys_modify_ldt */
+	PTR	sys32_adjtimex
+	PTR	sys_mprotect			/* 4125 */
+	PTR	compat_sys_sigprocmask
+	PTR	sys_ni_syscall			/* was creat_module */
+	PTR	sys_init_module
+	PTR	sys_delete_module
+	PTR	sys_ni_syscall			/* 4130, get_kernel_syms */
+	PTR	sys_quotactl
+	PTR	sys_getpgid
+	PTR	sys_fchdir
+	PTR	sys_bdflush
+	PTR	sys_sysfs			/* 4135 */
+	PTR	sys32_personality
+	PTR	sys_ni_syscall	 		/* for afs_syscall */
+	PTR	sys_setfsuid
+	PTR	sys_setfsgid
+	PTR	sys32_llseek			/* 4140 */
+	PTR	sys32_getdents
+	PTR	compat_sys_select
+	PTR	sys_flock
+	PTR	sys_msync
+	PTR	compat_sys_readv		/* 4145 */
+	PTR	compat_sys_writev
+	PTR	sys_cacheflush
+	PTR	sys_cachectl
+	PTR	sys_sysmips
+	PTR	sys_ni_syscall			/* 4150 */
+	PTR	sys_getsid
+	PTR	sys_fdatasync
+	PTR	sys32_sysctl
+	PTR	sys_mlock
+	PTR	sys_munlock			/* 4155 */
+	PTR	sys_mlockall
+	PTR	sys_munlockall
+	PTR	sys_sched_setparam
+	PTR	sys_sched_getparam
+	PTR	sys_sched_setscheduler 		/* 4160 */
+	PTR	sys_sched_getscheduler
+	PTR	sys_sched_yield
+	PTR	sys_sched_get_priority_max
+	PTR	sys_sched_get_priority_min
+	PTR	sys32_sched_rr_get_interval 	/* 4165 */
+	PTR	compat_sys_nanosleep
+	PTR	sys_mremap
+	PTR	sys_accept
+	PTR	sys_bind
+	PTR	sys_connect			/* 4170 */
+	PTR	sys_getpeername
+	PTR	sys_getsockname
+	PTR	sys_getsockopt
+	PTR	sys_listen
+	PTR	sys_recv			/* 4175 */
+	PTR	sys_recvfrom
+	PTR	compat_sys_recvmsg
+	PTR	sys_send
+	PTR	compat_sys_sendmsg
+	PTR	sys_sendto			/* 4180 */
+	PTR	compat_sys_setsockopt
+	PTR	sys_shutdown
+	PTR	sys_socket
+	PTR	sys_socketpair
+	PTR	sys_setresuid			/* 4185 */
+	PTR	sys_getresuid
+	PTR	sys_ni_syscall			/* was query_module */
+	PTR	sys_poll
+	PTR	sys_nfsservctl
+	PTR	sys_setresgid			/* 4190 */
+	PTR	sys_getresgid
+	PTR	sys_prctl
+	PTR	sys32_rt_sigreturn
+	PTR	sys32_rt_sigaction
+	PTR	sys32_rt_sigprocmask 		/* 4195 */
+	PTR	sys32_rt_sigpending
+	PTR	sys32_rt_sigtimedwait
+	PTR	sys32_rt_sigqueueinfo
+	PTR	sys32_rt_sigsuspend
+	PTR	sys32_pread			/* 4200 */
+	PTR	sys32_pwrite
+	PTR	sys_chown
+	PTR	sys_getcwd
+	PTR	sys_capget
+	PTR	sys_capset			/* 4205 */
+	PTR	sys32_sigaltstack
+	PTR	sys32_sendfile
+	PTR	sys_ni_syscall
+	PTR	sys_ni_syscall
+	PTR	sys32_mmap2			/* 4210 */
+	PTR	sys32_truncate64
+	PTR	sys32_ftruncate64
+	PTR	sys_newstat
+	PTR	sys_newlstat
+	PTR	sys_newfstat			/* 4215 */
+	PTR	sys_pivot_root
+	PTR	sys_mincore
+	PTR	sys_madvise
+	PTR	sys_getdents64
+	PTR	compat_sys_fcntl64		/* 4220 */
+	PTR	sys_ni_syscall
+	PTR	sys_gettid
+	PTR	sys32_readahead
+	PTR	sys_setxattr
+	PTR	sys_lsetxattr			/* 4225 */
+	PTR	sys_fsetxattr
+	PTR	sys_getxattr
+	PTR	sys_lgetxattr
+	PTR	sys_fgetxattr
+	PTR	sys_listxattr			/* 4230 */
+	PTR	sys_llistxattr
+	PTR	sys_flistxattr
+	PTR	sys_removexattr
+	PTR	sys_lremovexattr
+	PTR	sys_fremovexattr		/* 4235 */
+	PTR	sys_tkill
+	PTR	sys_sendfile64
+	PTR	compat_sys_futex
+	PTR	compat_sys_sched_setaffinity
+	PTR	compat_sys_sched_getaffinity	/* 4240 */
+	PTR	sys_io_setup
+	PTR	sys_io_destroy
+	PTR	sys_io_getevents
+	PTR	sys_io_submit
+	PTR	sys_io_cancel			/* 4245 */
+	PTR	sys_exit_group
+	PTR	sys_lookup_dcookie
+	PTR	sys_epoll_create
+	PTR	sys_epoll_ctl
+	PTR	sys_epoll_wait			/* 4250 */
+	PTR	sys_remap_file_pages
+	PTR	sys_set_tid_address
+	PTR	sys_restart_syscall
+	PTR	sys_fadvise64_64
+	PTR	compat_sys_statfs64		/* 4255 */
+	PTR	compat_sys_fstatfs64
+	PTR	sys_timer_create
+	PTR	compat_sys_timer_settime
+	PTR	compat_sys_timer_gettime
+	PTR	sys_timer_getoverrun		/* 4260 */
+	PTR	sys_timer_delete
+	PTR	compat_sys_clock_settime
+	PTR	compat_sys_clock_gettime
+	PTR	compat_sys_clock_getres
+	PTR	compat_sys_clock_nanosleep	/* 4265 */
+	PTR	sys_tgkill
+	PTR	compat_sys_utimes
+	PTR	sys_ni_syscall			/* sys_mbind */
+	PTR	sys_ni_syscall			/* sys_get_mempolicy */
+	PTR	sys_ni_syscall			/* 4270 sys_set_mempolicy */
+	PTR	compat_sys_mq_open
+	PTR	sys_mq_unlink
+	PTR	compat_sys_mq_timedsend
+	PTR	compat_sys_mq_timedreceive
+	PTR	compat_sys_mq_notify		/* 4275 */
+	PTR	compat_sys_mq_getsetattr
+	PTR	sys_ni_syscall			/* sys_vserver */
+	PTR	sys_waitid
+	PTR	sys_ni_syscall			/* available, was setaltroot */
+	PTR	sys_add_key			/* 4280 */
+	PTR	sys_request_key
+	PTR	sys_keyctl
+	.size	sys_call_table,.-sys_call_table
diff -Nru a/arch/mips/kernel/semaphore.c b/arch/mips/kernel/semaphore.c
--- a/arch/mips/kernel/semaphore.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/kernel/semaphore.c	2004-12-24 13:37:00 -08:00
@@ -20,11 +20,10 @@
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <asm/atomic.h>
-#include <asm/semaphore.h>
+#include <asm/cpu-features.h>
 #include <asm/errno.h>
-
-#ifdef CONFIG_CPU_HAS_LLSC
-
+#include <asm/semaphore.h>
+#include <asm/war.h>
 /*
  * Atomically update sem->count.
  * This does the equivalent of the following:
@@ -33,49 +32,50 @@
  *	tmp = MAX(old_count, 0) + incr;
  *	sem->count = tmp;
  *	return old_count;
- */
-static inline int __sem_update_count(struct semaphore *sem, int incr)
-{
-	int old_count, tmp;
-
-	__asm__ __volatile__(
-	"1:	ll	%0, %2					\n"
-	"	sra	%1, %0, 31				\n"
-	"	not	%1					\n"
-	"	and	%1, %0, %1				\n"
-	"	add	%1, %1, %3				\n"
-	"	sc	%1, %2					\n"
-	"	beqz	%1, 1b					\n"
-	: "=&r" (old_count), "=&r" (tmp), "=m" (sem->count)
-	: "r" (incr), "m" (sem->count));
-
-	return old_count;
-}
-
-#else
-
-/*
+ *
  * On machines without lld/scd we need a spinlock to make the manipulation of
  * sem->count and sem->waking atomic.  Scalability isn't an issue because
  * this lock is used on UP only so it's just an empty variable.
  */
-static spinlock_t semaphore_lock = SPIN_LOCK_UNLOCKED;
-
 static inline int __sem_update_count(struct semaphore *sem, int incr)
 {
-	unsigned long flags;
 	int old_count, tmp;
 
-	spin_lock_irqsave(&semaphore_lock, flags);
-	old_count = atomic_read(&sem->count);
-	tmp = max_t(int, old_count, 0) + incr;
-	atomic_set(&sem->count, tmp);
-	spin_unlock_irqrestore(&semaphore_lock, flags);
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"1:	ll	%0, %2					\n"
+		"	sra	%1, %0, 31				\n"
+		"	not	%1					\n"
+		"	and	%1, %0, %1				\n"
+		"	add	%1, %1, %3				\n"
+		"	sc	%1, %2					\n"
+		"	beqzl	%1, 1b					\n"
+		: "=&r" (old_count), "=&r" (tmp), "=m" (sem->count)
+		: "r" (incr), "m" (sem->count));
+	} else if (cpu_has_llsc) {
+		__asm__ __volatile__(
+		"1:	ll	%0, %2					\n"
+		"	sra	%1, %0, 31				\n"
+		"	not	%1					\n"
+		"	and	%1, %0, %1				\n"
+		"	add	%1, %1, %3				\n"
+		"	sc	%1, %2					\n"
+		"	beqz	%1, 1b					\n"
+		: "=&r" (old_count), "=&r" (tmp), "=m" (sem->count)
+		: "r" (incr), "m" (sem->count));
+	} else {
+		static spinlock_t semaphore_lock = SPIN_LOCK_UNLOCKED;
+		unsigned long flags;
+
+		spin_lock_irqsave(&semaphore_lock, flags);
+		old_count = atomic_read(&sem->count);
+		tmp = max_t(int, old_count, 0) + incr;
+		atomic_set(&sem->count, tmp);
+		spin_unlock_irqrestore(&semaphore_lock, flags);
+	}
 
 	return old_count;
 }
-
-#endif
 
 void __up(struct semaphore *sem)
 {
diff -Nru a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
--- a/arch/mips/kernel/setup.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/kernel/setup.c	2004-12-24 13:36:19 -08:00
@@ -56,8 +56,6 @@
 
 EXPORT_SYMBOL(PCI_DMA_BUS_IS_PHYS);
 
-extern void * __rd_start, * __rd_end;
-
 /*
  * Setup information
  *
@@ -194,6 +192,68 @@
 	}
 }
 
+static inline int parse_rd_cmdline(unsigned long* rd_start, unsigned long* rd_end)
+{
+	/*
+	 * "rd_start=0xNNNNNNNN" defines the memory address of an initrd
+	 * "rd_size=0xNN" it's size
+	 */
+	unsigned long start = 0;
+	unsigned long size = 0;
+	unsigned long end;
+	char cmd_line[CL_SIZE];
+	char *start_str;
+	char *size_str;
+	char *tmp;
+
+	strcpy(cmd_line, command_line);
+	*command_line = 0;
+	tmp = cmd_line;
+	/* Ignore "rd_start=" strings in other parameters. */
+	start_str = strstr(cmd_line, "rd_start=");
+	if (start_str && start_str != cmd_line && *(start_str - 1) != ' ')
+		start_str = strstr(start_str, " rd_start=");
+	while (start_str) {
+		if (start_str != cmd_line)
+			strncat(command_line, tmp, start_str - tmp);
+		start = memparse(start_str + 9, &start_str);
+		tmp = start_str + 1;
+		start_str = strstr(start_str, " rd_start=");
+	}
+	if (*tmp)
+		strcat(command_line, tmp);
+
+	strcpy(cmd_line, command_line);
+	*command_line = 0;
+	tmp = cmd_line;
+	/* Ignore "rd_size" strings in other parameters. */
+	size_str = strstr(cmd_line, "rd_size=");
+	if (size_str && size_str != cmd_line && *(size_str - 1) != ' ')
+		size_str = strstr(size_str, " rd_size=");
+	while (size_str) {
+		if (size_str != cmd_line)
+			strncat(command_line, tmp, size_str - tmp);
+		size = memparse(size_str + 8, &size_str);
+		tmp = size_str + 1;
+		size_str = strstr(size_str, " rd_size=");
+	}
+	if (*tmp)
+		strcat(command_line, tmp);
+
+#ifdef CONFIG_MIPS64
+	/* HACK: Guess if the sign extension was forgotten */
+	if (start > 0x0000000080000000 && start < 0x00000000ffffffff)
+		start |= 0xffffffff00000000;
+#endif
+
+	end = start + size;
+	if (start && end) {
+		*rd_start = start;
+		*rd_end = end;
+		return 1;
+	}
+	return 0;
+}
 
 #define PFN_UP(x)	(((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
 #define PFN_DOWN(x)	((x) >> PAGE_SHIFT)
@@ -205,30 +265,42 @@
 static inline void bootmem_init(void)
 {
 	unsigned long start_pfn;
+	unsigned long reserved_end = (unsigned long)&_end;
 #ifndef CONFIG_SGI_IP27
-	unsigned long bootmap_size, max_low_pfn, first_usable_pfn;
+	unsigned long first_usable_pfn;
+	unsigned long bootmap_size;
 	int i;
 #endif
 #ifdef CONFIG_BLK_DEV_INITRD
-	unsigned long tmp;
-	unsigned long *initrd_header;
+	int initrd_reserve_bootmem = 0;
 
-	tmp = (((unsigned long)&_end + PAGE_SIZE-1) & PAGE_MASK) - 8;
-	if (tmp < (unsigned long)&_end)
-		tmp += PAGE_SIZE;
-	initrd_header = (unsigned long *)tmp;
-	if (initrd_header[0] == 0x494E5244) {
-		initrd_start = (unsigned long)&initrd_header[2];
-		initrd_end = initrd_start + initrd_header[1];
+	/* Board specific code should have set up initrd_start and initrd_end */
+ 	ROOT_DEV = Root_RAM0;
+	if (parse_rd_cmdline(&initrd_start, &initrd_end)) {
+		reserved_end = max(reserved_end, initrd_end);
+		initrd_reserve_bootmem = 1;
+	} else {
+		unsigned long tmp;
+		unsigned long *initrd_header;
+
+		tmp = ((reserved_end + PAGE_SIZE-1) & PAGE_MASK) - 8;
+		if (tmp < reserved_end)
+			tmp += PAGE_SIZE;
+		initrd_header = (unsigned long *)tmp;
+		if (initrd_header[0] == 0x494E5244) {
+			initrd_start = (unsigned long)&initrd_header[2];
+			initrd_end = initrd_start + initrd_header[1];
+			reserved_end = max(reserved_end, initrd_end);
+			initrd_reserve_bootmem = 1;
+		}
 	}
-	start_pfn = PFN_UP(CPHYSADDR((&_end)+(initrd_end - initrd_start) + PAGE_SIZE));
-#else
+#endif	/* CONFIG_BLK_DEV_INITRD */
+
 	/*
 	 * Partially used pages are not usable - thus
 	 * we are rounding upwards.
 	 */
-	start_pfn = PFN_UP(CPHYSADDR(&_end));
-#endif	/* CONFIG_BLK_DEV_INITRD */
+	start_pfn = PFN_UP(CPHYSADDR(reserved_end));
 
 #ifndef CONFIG_SGI_IP27
 	/* Find the highest page frame number we have available.  */
@@ -341,21 +413,14 @@
 
 	/* Reserve the bootmap memory.  */
 	reserve_bootmem(PFN_PHYS(first_usable_pfn), bootmap_size);
-#endif
+#endif /* CONFIG_SGI_IP27 */
 
 #ifdef CONFIG_BLK_DEV_INITRD
-	/* Board specific code should have set up initrd_start and initrd_end */
-	ROOT_DEV = Root_RAM0;
-	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);
 		printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
-		       (void *)initrd_start,
-		       initrd_size);
+		       (void *)initrd_start, initrd_size);
 
 		if (CPHYSADDR(initrd_end) > PFN_PHYS(max_low_pfn)) {
 			printk("initrd extends beyond end of memory "
@@ -363,7 +428,11 @@
 			       sizeof(long) * 2, CPHYSADDR(initrd_end),
 			       sizeof(long) * 2, PFN_PHYS(max_low_pfn));
 			initrd_start = initrd_end = 0;
+			initrd_reserve_bootmem = 0;
 		}
+
+		if (initrd_reserve_bootmem)
+			reserve_bootmem(CPHYSADDR(initrd_start), initrd_size);
 	}
 #endif /* CONFIG_BLK_DEV_INITRD  */
 }
@@ -453,30 +522,9 @@
 
 void __init setup_arch(char **cmdline_p)
 {
-	unsigned int status;
-
 	cpu_probe();
 	prom_init();
 	cpu_report();
-
-#ifdef CONFIG_MIPS32
-	/* Disable coprocessors and set FPU for 16/32 FPR register model */
-	status = read_c0_status();
-	status &= ~(ST0_CU1|ST0_CU2|ST0_CU3|ST0_KX|ST0_SX|ST0_FR);
-	status |= ST0_CU0;
-	write_c0_status(status);
-#endif
-#ifdef CONFIG_MIPS64
-	/*
-	 * On IP27, I am seeing the TS bit set when the kernel is loaded.
-	 * Maybe because the kernel is in ckseg0 and not xkphys? Clear it
-	 * anyway ...
-	 */
-	status = read_c0_status();
-	status &= ~(ST0_BEV|ST0_TS|ST0_CU1|ST0_CU2|ST0_CU3);
-	status |= (ST0_CU0|ST0_KX|ST0_SX|ST0_FR);
-	write_c0_status(status);
-#endif
 
 #if defined(CONFIG_VT)
 #if defined(CONFIG_VGA_CONSOLE)
diff -Nru a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
--- a/arch/mips/kernel/signal.c	2004-12-24 13:37:44 -08:00
+++ b/arch/mips/kernel/signal.c	2004-12-24 13:37:44 -08:00
@@ -20,9 +20,10 @@
 #include <linux/ptrace.h>
 #include <linux/suspend.h>
 #include <linux/unistd.h>
+#include <linux/compiler.h>
 
 #include <asm/asm.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/cacheflush.h>
 #include <asm/fpu.h>
 #include <asm/sim.h>
@@ -41,7 +42,8 @@
 
 #ifdef CONFIG_TRAD_SIGNALS
 save_static_function(sys_sigsuspend);
-static_unused int _sys_sigsuspend(struct pt_regs regs)
+__attribute_used__ noinline static int
+_sys_sigsuspend(nabi_no_regargs struct pt_regs regs)
 {
 	sigset_t *uset, saveset, newset;
 
@@ -68,7 +70,8 @@
 #endif
 
 save_static_function(sys_rt_sigsuspend);
-static_unused int _sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
+__attribute_used__ noinline static int
+_sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
 {
 	sigset_t *unewset, saveset, newset;
 	size_t sigsetsize;
@@ -178,6 +181,8 @@
 
 	err |= __get_user(current->used_math, &sc->sc_used_math);
 
+	preempt_disable();
+
 	if (current->used_math) {
 		/* restore fpu context if we have used it before */
 		own_fpu();
@@ -187,22 +192,30 @@
 		lose_fpu();
 	}
 
+	preempt_enable();
+
 	return err;
 }
 
+#if PLAT_TRAMPOLINE_STUFF_LINE
+#define __tramp __attribute__((aligned(PLAT_TRAMPOLINE_STUFF_LINE)))
+#else
+#define __tramp
+#endif
+
 #ifdef CONFIG_TRAD_SIGNALS
 struct sigframe {
 	u32 sf_ass[4];			/* argument save space for o32 */
-	u32 sf_code[2];			/* signal trampoline */
-	struct sigcontext sf_sc;
+	u32 sf_code[2] __tramp;		/* signal trampoline */
+	struct sigcontext sf_sc __tramp;
 	sigset_t sf_mask;
 };
 #endif
 
 struct rt_sigframe {
 	u32 rs_ass[4];			/* argument save space for o32 */
-	u32 rs_code[2];			/* signal trampoline */
-	struct siginfo rs_info;
+	u32 rs_code[2] __tramp;		/* signal trampoline */
+	struct siginfo rs_info __tramp;
 	struct ucontext rs_uc;
 };
 
@@ -320,12 +333,16 @@
 	 * Save FPU state to signal context.  Signal handler will "inherit"
 	 * current FPU state.
 	 */
+	preempt_disable();
+
 	if (!is_fpu_owner()) {
 		own_fpu();
 		restore_fp(current);
 	}
 	err |= save_fp_context(sc);
 
+	preempt_enable();
+
 out:
 	return err;
 }
@@ -336,7 +353,7 @@
 static inline void *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
 	size_t frame_size)
 {
-	unsigned long sp;
+	unsigned long sp, almask;
 
 	/* Default to using normal stack */
 	sp = regs->regs[29];
@@ -352,7 +369,12 @@
 	if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags (sp) == 0))
 		sp = current->sas_ss_sp + current->sas_ss_size;
 
-	return (void *)((sp - frame_size) & ALMASK);
+	if (PLAT_TRAMPOLINE_STUFF_LINE)
+		almask = ~(PLAT_TRAMPOLINE_STUFF_LINE - 1);
+	else
+		almask = ALMASK;
+
+	return (void *)((sp - frame_size) & ~(PLAT_TRAMPOLINE_STUFF_LINE - 1));
 }
 
 #ifdef CONFIG_TRAD_SIGNALS
@@ -372,6 +394,9 @@
 	 *         li      v0, __NR_sigreturn
 	 *         syscall
 	 */
+	if (PLAT_TRAMPOLINE_STUFF_LINE)
+		__builtin_memset(frame->sf_code, '0',
+		                 PLAT_TRAMPOLINE_STUFF_LINE);
 	err |= __put_user(0x24020000 + __NR_sigreturn, frame->sf_code + 0);
 	err |= __put_user(0x0000000c                 , frame->sf_code + 1);
 	flush_cache_sigtramp((unsigned long) frame->sf_code);
@@ -426,6 +451,9 @@
 	 *         li      v0, __NR_rt_sigreturn
 	 *         syscall
 	 */
+	if (PLAT_TRAMPOLINE_STUFF_LINE)
+		__builtin_memset(frame->rs_code, '0',
+		                 PLAT_TRAMPOLINE_STUFF_LINE);
 	err |= __put_user(0x24020000 + __NR_rt_sigreturn, frame->rs_code + 0);
 	err |= __put_user(0x0000000c                    , frame->rs_code + 1);
 	flush_cache_sigtramp((unsigned long) frame->rs_code);
@@ -517,8 +545,6 @@
 		setup_frame(ka, regs, sig, oldset);
 #endif
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
diff -Nru a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
--- a/arch/mips/kernel/signal32.c	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/kernel/signal32.c	2004-12-24 13:36:55 -08:00
@@ -19,9 +19,10 @@
 #include <linux/ptrace.h>
 #include <linux/compat.h>
 #include <linux/suspend.h>
+#include <linux/compiler.h>
 
 #include <asm/asm.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/cacheflush.h>
 #include <asm/sim.h>
 #include <asm/uaccess.h>
@@ -29,6 +30,71 @@
 #include <asm/system.h>
 #include <asm/fpu.h>
 
+#define SI_PAD_SIZE32   ((SI_MAX_SIZE/sizeof(int)) - 3)
+
+typedef union sigval32 {
+	int sival_int;
+	s32 sival_ptr;
+} sigval_t32;
+
+typedef struct siginfo32 {
+	int si_signo;
+	int si_code;
+	int si_errno;
+
+	union {
+		int _pad[SI_PAD_SIZE32];
+
+		/* kill() */
+		struct {
+			compat_pid_t _pid;	/* sender's pid */
+			compat_uid_t _uid;	/* sender's uid */
+		} _kill;
+
+		/* SIGCHLD */
+		struct {
+			compat_pid_t _pid;	/* which child */
+			compat_uid_t _uid;	/* sender's uid */
+			int _status;		/* exit code */
+			compat_clock_t _utime;
+			compat_clock_t _stime;
+		} _sigchld;
+
+		/* IRIX SIGCHLD */
+		struct {
+			compat_pid_t _pid;	/* which child */
+			compat_clock_t _utime;
+			int _status;		/* exit code */
+			compat_clock_t _stime;
+		} _irix_sigchld;
+
+		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
+		struct {
+			s32 _addr; /* faulting insn/memory ref. */
+		} _sigfault;
+
+		/* SIGPOLL, SIGXFSZ (To do ...)  */
+		struct {
+			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
+			int _fd;
+		} _sigpoll;
+
+		/* POSIX.1b timers */
+		struct {
+			unsigned int _timer1;
+			unsigned int _timer2;
+		} _timer;
+
+		/* POSIX.1b signals */
+		struct {
+			compat_pid_t _pid;	/* sender's pid */
+			compat_uid_t _uid;	/* sender's uid */
+			sigval_t32 _sigval;
+		} _rt;
+
+	} _sifields;
+} siginfo_t32;
+
 /*
  * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
  */
@@ -127,7 +193,8 @@
  * Atomically swap in the new signal mask, and wait for a signal.
  */
 save_static_function(sys32_sigsuspend);
-static_unused int _sys32_sigsuspend(nabi_no_regargs struct pt_regs regs)
+__attribute_used__ noinline static int
+_sys32_sigsuspend(nabi_no_regargs struct pt_regs regs)
 {
 	compat_sigset_t *uset;
 	sigset_t newset, saveset;
@@ -154,7 +221,8 @@
 }
 
 save_static_function(sys32_rt_sigsuspend);
-static_unused int _sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
+__attribute_used__ noinline static int
+_sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
 {
 	compat_sigset_t *uset;
 	sigset_t newset, saveset;
@@ -295,6 +363,8 @@
 
 	err |= __get_user(current->used_math, &sc->sc_used_math);
 
+	preempt_disable();
+
 	if (current->used_math) {
 		/* restore fpu context if we have used it before */
 		own_fpu();
@@ -304,6 +374,8 @@
 		lose_fpu();
 	}
 
+	preempt_enable();
+
 	return err;
 }
 
@@ -489,12 +561,16 @@
 	 * Save FPU state to signal context.  Signal handler will "inherit"
 	 * current FPU state.
 	 */
+	preempt_disable();
+
 	if (!is_fpu_owner()) {
 		own_fpu();
 		restore_fp(current);
 	}
 	err |= save_fp_context32(sc);
 
+	preempt_enable();
+
 out:
 	return err;
 }
@@ -649,10 +725,8 @@
 }
 
 static inline void handle_signal(unsigned long sig, siginfo_t *info,
-	sigset_t *oldset, struct pt_regs * regs)
+	struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
 {
-	struct k_sigaction *ka = &current->sighand->action[sig-1];
-
 	switch (regs->regs[0]) {
 	case ERESTART_RESTARTBLOCK:
 	case ERESTARTNOHAND:
@@ -676,8 +750,6 @@
 	else
 		setup_frame(ka, regs, sig, oldset);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
@@ -689,6 +761,7 @@
 
 asmlinkage int do_signal32(sigset_t *oldset, struct pt_regs *regs)
 {
+	struct k_sigaction ka;
 	siginfo_t info;
 	int signr;
 
@@ -708,9 +781,9 @@
 	if (!oldset)
 		oldset = &current->blocked;
 
-	signr = get_signal_to_deliver(&info, regs, NULL);
+	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
 	if (signr > 0) {
-		handle_signal(signr, &info, oldset, regs);
+		handle_signal(signr, &info, &ka, oldset, regs);
 		return 1;
 	}
 
diff -Nru a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c
--- a/arch/mips/kernel/signal_n32.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/kernel/signal_n32.c	2004-12-24 13:37:00 -08:00
@@ -26,9 +26,9 @@
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
 #include <linux/compat.h>
+#include <linux/bitops.h>
 
 #include <asm/asm.h>
-#include <asm/bitops.h>
 #include <asm/cacheflush.h>
 #include <asm/sim.h>
 #include <asm/uaccess.h>
diff -Nru a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
--- a/arch/mips/kernel/smp.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/kernel/smp.c	2004-12-24 13:36:19 -08:00
@@ -44,6 +44,7 @@
 int __cpu_number_map[NR_CPUS];		/* Map physical to logical */
 int __cpu_logical_map[NR_CPUS];		/* Map logical to physical */
 
+EXPORT_SYMBOL(phys_cpu_present_map);
 EXPORT_SYMBOL(cpu_online_map);
 
 cycles_t cacheflush_time;
@@ -235,7 +236,6 @@
 	init_new_context(current, &init_mm);
 	current_thread_info()->cpu = 0;
 	smp_tune_scheduling();
-	prom_build_cpu_map();
 	prom_prepare_cpus(max_cpus);
 }
 
diff -Nru a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
--- a/arch/mips/kernel/syscall.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/kernel/syscall.c	2004-12-24 13:37:18 -08:00
@@ -24,6 +24,7 @@
 #include <linux/sem.h>
 #include <linux/msg.h>
 #include <linux/shm.h>
+#include <linux/compiler.h>
 
 #include <asm/branch.h>
 #include <asm/cachectl.h>
@@ -65,7 +66,7 @@
 	int do_color_align;
 	unsigned long task_size;
 
-#if CONFIG_MIPS32
+#ifdef CONFIG_MIPS32
 	task_size = TASK_SIZE;
 #else
 	task_size = (current->thread.mflags & MF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE;
@@ -162,13 +163,15 @@
 }
 
 save_static_function(sys_fork);
-static_unused int _sys_fork(nabi_no_regargs struct pt_regs regs)
+__attribute_used__ noinline static int
+_sys_fork(nabi_no_regargs struct pt_regs regs)
 {
 	return do_fork(SIGCHLD, regs.regs[29], &regs, 0, NULL, NULL);
 }
 
 save_static_function(sys_clone);
-static_unused int _sys_clone(nabi_no_regargs struct pt_regs regs)
+__attribute_used__ noinline static int
+_sys_clone(nabi_no_regargs struct pt_regs regs)
 {
 	unsigned long clone_flags;
 	unsigned long newsp;
diff -Nru a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c
--- a/arch/mips/kernel/sysirix.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/kernel/sysirix.c	2004-12-24 13:37:19 -08:00
@@ -128,16 +128,21 @@
 		if (value > RLIM_INFINITY)
 			value = RLIM_INFINITY;
 		if (capable(CAP_SYS_ADMIN)) {
-			current->rlim[RLIMIT_STACK].rlim_max =
-				current->rlim[RLIMIT_STACK].rlim_cur = value;
+			task_lock(current->group_leader);
+			current->signal->rlim[RLIMIT_STACK].rlim_max =
+				current->signal->rlim[RLIMIT_STACK].rlim_cur = value;
+			task_unlock(current->group_leader);
 			error = value;
 			break;
 		}
-		if (value > current->rlim[RLIMIT_STACK].rlim_max) {
+		task_lock(current->group_leader);
+		if (value > current->signal->rlim[RLIMIT_STACK].rlim_max) {
 			error = -EINVAL;
+			task_unlock(current->group_leader);
 			break;
 		}
-		current->rlim[RLIMIT_STACK].rlim_cur = value;
+		current->signal->rlim[RLIMIT_STACK].rlim_cur = value;
+		task_unlock(current->group_leader);
 		error = value;
 		break;
 	}
@@ -145,7 +150,7 @@
 	case PR_GETSTACKSIZE:
 		printk("irix_prctl[%s:%d]: Wants PR_GETSTACKSIZE\n",
 		       current->comm, current->pid);
-		error = current->rlim[RLIMIT_STACK].rlim_cur;
+		error = current->signal->rlim[RLIMIT_STACK].rlim_cur;
 		break;
 
 	case PR_MAXPPROCS:
@@ -282,9 +287,9 @@
 		int pid = (int) regs->regs[base + 5];
 		char *buf = (char *) regs->regs[base + 6];
 		struct task_struct *p;
-		char comm[16];
+		char tcomm[sizeof(current->comm)];
 
-		retval = verify_area(VERIFY_WRITE, buf, 16);
+		retval = verify_area(VERIFY_WRITE, buf, sizeof(tcomm));
 		if (retval)
 			break;
 		read_lock(&tasklist_lock);
@@ -294,11 +299,11 @@
 			retval = -ESRCH;
 			break;
 		}
-		memcpy(comm, p->comm, 16);
+		get_task_comm(tcomm, p);
 		read_unlock(&tasklist_lock);
 
 		/* XXX Need to check sizes. */
-		copy_to_user(buf, p->comm, 16);
+		copy_to_user(buf, tcomm, sizeof(tcomm));
 		retval = 0;
 		break;
 	}
@@ -558,7 +563,7 @@
 	/*
 	 * Check against rlimit and stack..
 	 */
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim >= RLIM_INFINITY)
 		rlim = ~0;
 	if (brk - mm->end_code > rlim) {
@@ -614,8 +619,14 @@
 
 asmlinkage int irix_stime(int value)
 {
-	if (!capable(CAP_SYS_TIME))
-		return -EPERM;
+	int err;
+	struct timespec tv;
+
+	tv.tv_sec = value;
+	tv.tv_nsec = 0;
+	err = security_settime(&tv, NULL);
+	if (err)
+		return err;
 
 	write_seqlock_irq(&xtime_lock);
 	xtime.tv_sec = value;
@@ -913,8 +924,8 @@
 		return error;
 
 	down_read(&uts_sem);
-	if(len > (__NEW_UTS_LEN - 1))
-		len = __NEW_UTS_LEN - 1;
+	if (len > __NEW_UTS_LEN)
+		len = __NEW_UTS_LEN;
 	error = 0;
 	if (copy_to_user(name, system_utsname.domainname, len))
 		error = -EFAULT;
@@ -2132,7 +2143,7 @@
 		retval = -EINVAL;
 		goto out;
 #endif
-		retval = current->rlim[RLIMIT_NOFILE].rlim_cur;
+		retval = current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
 		goto out;
 
 	case 5:
diff -Nru a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
--- a/arch/mips/kernel/time.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/kernel/time.c	2004-12-24 13:36:48 -08:00
@@ -1,7 +1,7 @@
 /*
  * Copyright 2001 MontaVista Software Inc.
  * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- * Copyright (c) 2003  Maciej W. Rozycki
+ * Copyright (c) 2003, 2004  Maciej W. Rozycki
  *
  * Common time service routines for MIPS machines. See
  * Documentation/mips/time.README.
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 
 #include <asm/bootinfo.h>
+#include <asm/compiler.h>
 #include <asm/cpu.h>
 #include <asm/cpu-features.h>
 #include <asm/div64.h>
@@ -55,12 +56,6 @@
 spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
 
 /*
- * whether we emulate local_timer_interrupts for SMP machines.
- */
-int emulate_local_timer_interrupt;
-
-
-/*
  * By default we provide the null RTC ops
  */
 static unsigned long null_rtc_get_time(void)
@@ -277,7 +272,7 @@
 	__asm__("multu	%1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (sll32_usecs_per_cycle)
-		: "lo", "accum");
+		: "lo", GCC_REG_ACCUM);
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -332,7 +327,7 @@
 	__asm__("multu  %1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (quotient)
-		: "lo", "accum");
+		: "lo", GCC_REG_ACCUM);
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -374,7 +369,7 @@
 				: "r" (timerhi), "m" (timerlo),
 				  "r" (tmp), "r" (USECS_PER_JIFFY),
 				  "r" (USECS_PER_JIFFY_FRAC)
-				: "hi", "lo", "accum");
+				: "hi", "lo", GCC_REG_ACCUM);
 			cached_quotient = quotient;
 		}
 	}
@@ -388,7 +383,7 @@
 	__asm__("multu	%1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (quotient)
-		: "lo", "accum");
+		: "lo", GCC_REG_ACCUM);
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -418,10 +413,7 @@
 {
 	if (current->pid)
 		profile_tick(CPU_PROFILING, regs);
-#ifdef CONFIG_SMP
-	/* in UP mode, update_process_times() is invoked by do_timer() */
 	update_process_times(user_mode(regs));
-#endif
 }
 
 /*
@@ -505,7 +497,6 @@
 		}
 	}
 
-#if !defined(CONFIG_SMP)
 	/*
 	 * In UP mode, we call local_timer_interrupt() to do profiling
 	 * and process accouting.
@@ -514,21 +505,6 @@
 	 * low-level local timer interrupt handler.
 	 */
 	local_timer_interrupt(irq, dev_id, regs);
-
-#else	/* CONFIG_SMP */
-
-	if (emulate_local_timer_interrupt) {
-		/*
-		 * this is the place where we send out inter-process
-		 * interrupts and let each CPU do its own profiling
-		 * and process accouting.
-		 *
-		 * Obviously we need to call local_timer_interrupt() for
-		 * the current CPU too.
-		 */
-		panic("Not implemented yet!!!");
-	}
-#endif	/* CONFIG_SMP */
 
 	return IRQ_HANDLED;
 }
diff -Nru a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
--- a/arch/mips/kernel/traps.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/kernel/traps.c	2004-12-24 13:36:48 -08:00
@@ -390,6 +390,8 @@
 		goto sig;
 	}
 
+	preempt_disable();
+
 	if (ll_task == NULL || ll_task == current) {
 		ll_bit = 1;
 	} else {
@@ -397,6 +399,8 @@
 	}
 	ll_task = current;
 
+	preempt_enable();
+
 	regs->regs[(opcode & RT) >> 16] = value;
 
 	compute_return_epc(regs);
@@ -429,12 +433,18 @@
 		signal = SIGBUS;
 		goto sig;
 	}
+
+	preempt_disable();
+
 	if (ll_bit == 0 || ll_task != current) {
 		regs->regs[reg] = 0;
+		preempt_enable();
 		compute_return_epc(regs);
 		return;
 	}
 
+	preempt_enable();
+
 	if (put_user(regs->regs[reg], vaddr)) {
 		signal = SIGSEGV;
 		goto sig;
@@ -494,6 +504,8 @@
 	if (fcr31 & FPU_CSR_UNI_X) {
 		int sig;
 
+		preempt_disable();
+
 		/*
 	 	 * Unimplemented operation exception.  If we've got the full
 		 * software emulator on-board, let's use it...
@@ -519,6 +531,8 @@
 		/* Restore the hardware register state */
 		restore_fp(current);
 
+		preempt_enable();
+
 		/* If something went wrong, signal */
 		if (sig)
 			force_sig(sig, current);
@@ -638,6 +652,8 @@
 		break;
 
 	case 1:
+		preempt_disable();
+
 		own_fpu();
 		if (current->used_math) {	/* Using the FPU again.  */
 			restore_fp(current);
@@ -653,6 +669,8 @@
 				force_sig(sig, current);
 		}
 
+		preempt_enable();
+
 		return;
 
 	case 2:
@@ -892,15 +910,21 @@
 void __init per_cpu_trap_init(void)
 {
 	unsigned int cpu = smp_processor_id();
+	unsigned int status_set = ST0_CU0;
 
-	/* Some firmware leaves the BEV flag set, clear it.  */
-	clear_c0_status(ST0_CU1|ST0_CU2|ST0_CU3|ST0_BEV);
+	/*
+	 * Disable coprocessors and select 32-bit or 64-bit addressing
+	 * and the 16/32 or 32/32 FPR register model.  Reset the BEV
+	 * flag that some firmware may have left set and the TS bit (for
+	 * IP27).  Set XX for ISA IV code to work.
+	 */
 #ifdef CONFIG_MIPS64
-	set_c0_status(ST0_CU0|ST0_FR|ST0_KX|ST0_SX|ST0_UX);
+	status_set |= ST0_FR|ST0_KX|ST0_SX|ST0_UX;
 #endif
-
 	if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV)
-		set_c0_status(ST0_XX);
+		status_set |= ST0_XX;
+	change_c0_status(ST0_CU|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX,
+			 status_set);
 
 	/*
 	 * Some MIPS CPUs have a dedicated interrupt vector which reduces the
@@ -1008,7 +1032,8 @@
 		set_except_vector(24, handle_mcheck);
 
 	if (cpu_has_vce)
-		memcpy((void *)(CAC_BASE + 0x180), &except_vec3_r4000, 0x80);
+		/* Special exception: R4[04]00 uses also the divec space. */
+		memcpy((void *)(CAC_BASE + 0x180), &except_vec3_r4000, 0x100);
 	else if (cpu_has_4kex)
 		memcpy((void *)(CAC_BASE + 0x180), &except_vec3_generic, 0x80);
 	else
diff -Nru a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
--- a/arch/mips/kernel/vmlinux.lds.S	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/kernel/vmlinux.lds.S	2004-12-24 13:36:47 -08:00
@@ -49,7 +49,7 @@
 
   /* writeable */
   .data : {			/* Data */
-    . = . + MAPPED_OFFSET;	/* for CONFIG_MAPPED_KERNEL */
+    . = . + DATAOFFSET;		/* for CONFIG_MAPPED_KERNEL */
     *(.data.init_task)
 
     *(.data)
@@ -85,8 +85,6 @@
   /* will be freed after init */
   . = ALIGN(4096);		/* Init code and data */
   __init_begin = .;
-  /* /DISCARD/ doesn't work for .reginfo */
-  .reginfo : { *(.reginfo) }
   .init.text : {
 	_sinittext = .;
 	*(.init.text)
@@ -150,6 +148,14 @@
         *(.exit.text)
         *(.exit.data)
         *(.exitcall.exit)
+
+	/* ABI crap starts here */
+	*(.comment)
+	*(.MIPS.options)
+	*(.note)
+	*(.options)
+	*(.pdr)
+	*(.reginfo)
   }
 
   /* This is the MIPS specific mdebug section.  */
diff -Nru a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c
--- a/arch/mips/lasat/interrupt.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/lasat/interrupt.c	2004-12-24 13:37:00 -08:00
@@ -125,12 +125,10 @@
 	}
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	int i;
 
-	init_generic_irq();
-
 	switch (mips_machtype) {
 	case MACH_LASAT_100:
 		lasat_int_status = (void *)LASAT_INT_STATUS_REG_100;
@@ -147,7 +145,7 @@
 		*lasat_int_mask &= 0xffff;
 		break;
 	default:
-		panic("init_IRQ: mips_machtype incorrect");
+		panic("arch_init_irq: mips_machtype incorrect");
 	}
 
 	/* Now safe to set the exception vector. */
diff -Nru a/arch/mips/lasat/setup.c b/arch/mips/lasat/setup.c
--- a/arch/mips/lasat/setup.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/lasat/setup.c	2004-12-24 13:36:17 -08:00
@@ -134,7 +134,7 @@
 
 	memset(&s, 0, sizeof(s));
 
-	s.flags = STD_COM_FLAGS|UPF_RESOURCES;
+	s.flags = STD_COM_FLAGS;
 	s.iotype = SERIAL_IO_MEM;
 
 	if (mips_machtype == MACH_LASAT_100) {
diff -Nru a/arch/mips/lib/csum_partial_copy.c b/arch/mips/lib/csum_partial_copy.c
--- a/arch/mips/lib/csum_partial_copy.c	2004-12-24 13:37:33 -08:00
+++ b/arch/mips/lib/csum_partial_copy.c	2004-12-24 13:37:33 -08:00
@@ -6,11 +6,12 @@
  * Copyright (C) 1994, 1995 Waldorf Electronics GmbH
  * Copyright (C) 1998, 1999 Ralf Baechle
  */
-#include <net/checksum.h>
+#include <linux/kernel.h>
 #include <linux/types.h>
 #include <asm/byteorder.h>
 #include <asm/string.h>
 #include <asm/uaccess.h>
+#include <net/checksum.h>
 
 /*
  * copy while checksumming, otherwise like csum_partial
@@ -37,6 +38,7 @@
 {
 	int missing;
 
+	might_sleep();
 	missing = copy_from_user(dst, src, len);
 	if (missing) {
 		memset(dst + len - missing, 0, missing);
diff -Nru a/arch/mips/lib/dec_and_lock.c b/arch/mips/lib/dec_and_lock.c
--- a/arch/mips/lib/dec_and_lock.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/lib/dec_and_lock.c	2004-12-24 13:36:17 -08:00
@@ -28,7 +28,7 @@
  */
 
 #ifndef ATOMIC_DEC_AND_LOCK
-int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
+int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
 {
 	int counter;
 	int newcount;
@@ -51,5 +51,5 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
 #endif /* ATOMIC_DEC_AND_LOCK */
diff -Nru a/arch/mips/lib/strlen_user.S b/arch/mips/lib/strlen_user.S
--- a/arch/mips/lib/strlen_user.S	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/lib/strlen_user.S	2004-12-24 13:36:19 -08:00
@@ -3,13 +3,12 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 1996, 1998, 1999 by Ralf Baechle
+ * Copyright (c) 1996, 1998, 1999, 2004 by Ralf Baechle
  * Copyright (c) 1999 Silicon Graphics, Inc.
  */
 #include <asm/asm.h>
 #include <asm/offset.h>
 #include <asm/regdef.h>
-#include <asm/sgidefs.h>
 
 #define EX(insn,reg,addr,handler)			\
 9:	insn	reg, addr;				\
diff -Nru a/arch/mips/lib/strnlen_user.S b/arch/mips/lib/strnlen_user.S
--- a/arch/mips/lib/strnlen_user.S	2004-12-24 13:36:16 -08:00
+++ b/arch/mips/lib/strnlen_user.S	2004-12-24 13:36:16 -08:00
@@ -3,13 +3,12 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 1996, 1998, 1999 by Ralf Baechle
+ * Copyright (c) 1996, 1998, 1999, 2004 by Ralf Baechle
  * Copyright (c) 1999 Silicon Graphics, Inc.
  */
 #include <asm/asm.h>
 #include <asm/offset.h>
 #include <asm/regdef.h>
-#include <asm/sgidefs.h>
 
 #define EX(insn,reg,addr,handler)			\
 9:	insn	reg, addr;				\
diff -Nru a/arch/mips/lib-64/dump_tlb.c b/arch/mips/lib-64/dump_tlb.c
--- a/arch/mips/lib-64/dump_tlb.c	2004-12-24 13:37:44 -08:00
+++ b/arch/mips/lib-64/dump_tlb.c	2004-12-24 13:37:44 -08:00
@@ -190,7 +190,7 @@
 	pgd = pgd_offset(current->mm, addr);
 	pmd = pmd_offset(pgd, addr);
 	pte = pte_offset(pmd, addr);
-	paddr = (KSEG1 | (unsigned int) pte_val(*pte)) & PAGE_MASK;
+	paddr = (CKSEG1 | (unsigned int) pte_val(*pte)) & PAGE_MASK;
 	paddr |= (addr & ~PAGE_MASK);
 
 	return paddr;
diff -Nru a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
--- a/arch/mips/math-emu/cp1emu.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/math-emu/cp1emu.c	2004-12-24 13:37:19 -08:00
@@ -528,9 +528,9 @@
 		if (MIPSInst_FUNC(ir) != movc_op)
 			return SIGILL;
 		cond = fpucondbit[MIPSInst_RT(ir) >> 2];
-		if (((ctx->fcr31 & cond) != 0) != ((MIPSInst_RT(ir) & 1) != 0))
-			return 0;
-		xcp->regs[MIPSInst_RD(ir)] = xcp->regs[MIPSInst_RS(ir)];
+		if (((ctx->fcr31 & cond) != 0) == ((MIPSInst_RT(ir) & 1) != 0))
+			xcp->regs[MIPSInst_RD(ir)] =
+				xcp->regs[MIPSInst_RS(ir)];
 		break;
 #endif
 
diff -Nru a/arch/mips/mips-boards/atlas/atlas_int.c b/arch/mips/mips-boards/atlas/atlas_int.c
--- a/arch/mips/mips-boards/atlas/atlas_int.c	2004-12-24 13:37:02 -08:00
+++ b/arch/mips/mips-boards/atlas/atlas_int.c	2004-12-24 13:37:02 -08:00
@@ -118,12 +118,7 @@
 	do_IRQ(irq, regs);
 }
 
-#ifdef CONFIG_KGDB
-extern void breakpoint(void);
-extern int remote_debug;
-#endif
-
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	int i;
 
@@ -145,11 +140,4 @@
 		irq_desc[i].handler	= &atlas_irq_type;
 		spin_lock_init(&irq_desc[i].lock);
 	}
-
-#ifdef CONFIG_KGDB
-	if (remote_debug) {
-		set_debug_traps();
-		breakpoint();
-	}
-#endif
 }
diff -Nru a/arch/mips/mips-boards/atlas/atlas_setup.c b/arch/mips/mips-boards/atlas/atlas_setup.c
--- a/arch/mips/mips-boards/atlas/atlas_setup.c	2004-12-24 13:36:57 -08:00
+++ b/arch/mips/mips-boards/atlas/atlas_setup.c	2004-12-24 13:36:57 -08:00
@@ -84,7 +84,7 @@
 #endif
 	s.irq = ATLASINT_UART;
 	s.uartclk = ATLAS_BASE_BAUD * 16;
-	s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | UPF_RESOURCES | ASYNC_AUTO_IRQ;
+	s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
 	s.iotype = SERIAL_IO_PORT;
 	s.regshift = 3;
 
diff -Nru a/arch/mips/mips-boards/generic/init.c b/arch/mips/mips-boards/generic/init.c
--- a/arch/mips/mips-boards/generic/init.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/mips-boards/generic/init.c	2004-12-24 13:36:17 -08:00
@@ -42,8 +42,6 @@
 extern int saa9730_kgdb_hook(int);
 extern int saa9730_putDebugChar(char);
 extern char saa9730_getDebugChar(void);
-
-int remote_debug = 0;
 #endif
 
 int prom_argc;
@@ -219,7 +217,7 @@
 				generic_putDebugChar (*s++);
 		}
 
-		remote_debug = 1;
+		kgdb_enabled = 1;
 		/* Breakpoint is invoked after interrupts are initialised */
 	}
 }
diff -Nru a/arch/mips/mips-boards/generic/memory.c b/arch/mips/mips-boards/generic/memory.c
--- a/arch/mips/mips-boards/generic/memory.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/mips-boards/generic/memory.c	2004-12-24 13:36:18 -08:00
@@ -77,7 +77,7 @@
 	mdesc[1].base = 0x00001000;
 	mdesc[1].size = 0x000ef000;
 
-#if (CONFIG_MIPS_MALTA)
+#ifdef 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
diff -Nru a/arch/mips/mips-boards/generic/pci.c b/arch/mips/mips-boards/generic/pci.c
--- a/arch/mips/mips-boards/generic/pci.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/mips-boards/generic/pci.c	2004-12-24 13:36:47 -08:00
@@ -2,6 +2,8 @@
  * Carsten Langgaard, carstenl@mips.com
  * Copyright (C) 1999, 2000 MIPS Technologies, Inc.  All rights reserved.
  *
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
+ *
  *  This program is free software; you can distribute it and/or modify it
  *  under the terms of the GNU General Public License (Version 2) as
  *  published by the Free Software Foundation.
@@ -24,7 +26,6 @@
 #include <linux/init.h>
 
 #include <asm/mips-boards/generic.h>
-#include <asm/pci_channel.h>
 #include <asm/gt64120.h>
 #include <asm/mips-boards/bonito64.h>
 #include <asm/mips-boards/msc01_pci.h>
diff -Nru a/arch/mips/mips-boards/malta/malta_int.c b/arch/mips/mips-boards/malta/malta_int.c
--- a/arch/mips/mips-boards/malta/malta_int.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/mips-boards/malta/malta_int.c	2004-12-24 13:36:31 -08:00
@@ -41,12 +41,6 @@
 
 extern asmlinkage void mipsIRQ(void);
 
-#ifdef CONFIG_KGDB
-extern void breakpoint(void);
-extern void set_debug_traps(void);
-extern int remote_debug;
-#endif
-
 static spinlock_t mips_irq_lock = SPIN_LOCK_UNLOCKED;
 
 static inline int mips_pcibios_iack(void)
@@ -187,18 +181,8 @@
         die("CoreHi interrupt", regs);
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	set_except_vector(0, mipsIRQ);
-	init_generic_irq();
 	init_i8259_irqs();
-
-#ifdef CONFIG_KGDB
-	if (remote_debug) {
-		set_debug_traps();
-		breakpoint();
-	}
-#endif
 }
-
-
diff -Nru a/arch/mips/mips-boards/malta/malta_setup.c b/arch/mips/mips-boards/malta/malta_setup.c
--- a/arch/mips/mips-boards/malta/malta_setup.c	2004-12-24 13:37:34 -08:00
+++ b/arch/mips/mips-boards/malta/malta_setup.c	2004-12-24 13:37:34 -08:00
@@ -22,6 +22,13 @@
 #include <linux/pci.h>
 #include <linux/tty.h>
 
+#ifdef CONFIG_MTD
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#endif
+
 #include <asm/cpu.h>
 #include <asm/bootinfo.h>
 #include <asm/irq.h>
@@ -53,6 +60,30 @@
 	{ "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
 };
 
+#ifdef CONFIG_MTD
+static struct mtd_partition malta_mtd_partitions[] = {
+	{
+		.name =		"YAMON",
+		.offset =	0x0,
+		.size =		0x100000,
+		.mask_flags =	MTD_WRITEABLE
+	},
+	{
+		.name =		"User FS",
+		.offset = 	0x100000,
+		.size =		0x2e0000
+	},
+	{
+		.name =		"Board Config",
+		.offset =	0x3e0000,
+		.size =		0x020000,
+		.mask_flags =	MTD_WRITEABLE
+	}
+};
+
+#define number_partitions	(sizeof(malta_mtd_partitions)/sizeof(struct mtd_partition))
+#endif
+
 const char *get_system_type(void)
 {
 	return "MIPS Malta";
@@ -132,13 +163,13 @@
 			}
 		}
 		else
-			panic ("Hardware DMA cache coherency not supported\n");
+			panic("Hardware DMA cache coherency not supported");
 
 #endif
 	}
 #ifdef CONFIG_DMA_COHERENT
 	else {
-		panic ("Hardware DMA cache coherency not supported\n");
+		panic("Hardware DMA cache coherency not supported");
 	}
 #endif
 
@@ -179,6 +210,15 @@
 	};
 #endif
 #endif
+
+#ifdef CONFIG_MTD
+	/*
+	 * Support for MTD on Malta. Use the generic physmap driver
+	 */
+	physmap_configure(0x1e000000, 0x400000, 4, NULL);
+	physmap_set_partitions(malta_mtd_partitions, number_partitions);
+#endif
+
 	mips_reboot_setup();
 
 	board_time_init = mips_time_init;
diff -Nru a/arch/mips/mips-boards/sead/sead_int.c b/arch/mips/mips-boards/sead/sead_int.c
--- a/arch/mips/mips-boards/sead/sead_int.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/mips-boards/sead/sead_int.c	2004-12-24 13:37:18 -08:00
@@ -37,7 +37,7 @@
 	do_IRQ(SEADINT_UART1, regs);
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
         /*
          * Mask out all interrupt
@@ -47,6 +47,5 @@
 	/* Now safe to set the exception vector. */
 	set_except_vector(0, mipsIRQ);
 
-	init_generic_irq();
 	mips_cpu_irq_init(0);
 }
diff -Nru a/arch/mips/mips-boards/sead/sead_setup.c b/arch/mips/mips-boards/sead/sead_setup.c
--- a/arch/mips/mips-boards/sead/sead_setup.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/mips-boards/sead/sead_setup.c	2004-12-24 13:36:17 -08:00
@@ -73,7 +73,7 @@
 #endif
 	s.irq = SEADINT_UART0;
 	s.uartclk = SEAD_BASE_BAUD * 16;
-	s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | UPF_RESOURCES | ASYNC_AUTO_IRQ;
+	s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
 	s.iotype = 0;
 	s.regshift = 3;
 
diff -Nru a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
--- a/arch/mips/mm/Makefile	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/mm/Makefile	2004-12-24 13:37:00 -08:00
@@ -2,7 +2,8 @@
 # Makefile for the Linux/MIPS-specific parts of the memory manager.
 #
 
-obj-y				+= cache.o extable.o fault.o init.o pgtable.o
+obj-y				+= cache.o extable.o fault.o init.o pgtable.o \
+				   tlbex.o
 
 obj-$(CONFIG_MIPS32)		+= ioremap.o pgtable-32.o
 obj-$(CONFIG_MIPS64)		+= pgtable-64.o
@@ -41,22 +42,22 @@
 obj-$(CONFIG_CPU_RM7000)	+= tlbex32-r4k.o
 obj-$(CONFIG_CPU_RM9000)	+= tlbex32-r4k.o
 obj-$(CONFIG_CPU_R10000)	+= tlbex32-r4k.o
-obj-$(CONFIG_CPU_MIPS32)	+= tlbex32-r4k.o
+obj-$(CONFIG_CPU_MIPS32)	+= tlbex32-mips32.o
 obj-$(CONFIG_CPU_MIPS64)	+= tlbex32-r4k.o
 obj-$(CONFIG_CPU_SB1)		+= tlbex32-r4k.o
 obj-$(CONFIG_CPU_TX39XX)	+= tlbex32-r3k.o
 endif
 ifdef CONFIG_MIPS64
-obj-$(CONFIG_CPU_R4300)		+= tlb64-glue-r4k.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_R4X00)		+= tlb64-glue-r4k.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_R5000)		+= tlb64-glue-r4k.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_NEVADA)	+= tlb64-glue-r4k.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_R5432)		+= tlb64-glue-r4k.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_RM7000)	+= tlb64-glue-r4k.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_RM9000)	+= tlb64-glue-r4k.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_R10000)	+= tlb64-glue-r4k.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_SB1)		+= tlb64-glue-sb1.o tlbex64-r4k.o
-obj-$(CONFIG_CPU_MIPS64)	+= tlb64-glue-r4k.o tlbex64-r4k.o
+obj-$(CONFIG_CPU_R4300)		+= tlb64-glue-r4k.o
+obj-$(CONFIG_CPU_R4X00)		+= tlb64-glue-r4k.o
+obj-$(CONFIG_CPU_R5000)		+= tlb64-glue-r4k.o
+obj-$(CONFIG_CPU_NEVADA)	+= tlb64-glue-r4k.o
+obj-$(CONFIG_CPU_R5432)		+= tlb64-glue-r4k.o
+obj-$(CONFIG_CPU_RM7000)	+= tlb64-glue-r4k.o
+obj-$(CONFIG_CPU_RM9000)	+= tlb64-glue-r4k.o
+obj-$(CONFIG_CPU_R10000)	+= tlb64-glue-r4k.o
+obj-$(CONFIG_CPU_SB1)		+= tlb64-glue-sb1.o
+obj-$(CONFIG_CPU_MIPS64)	+= tlb64-glue-r4k.o
 endif
 
 
diff -Nru a/arch/mips/mm/c-r3k.c b/arch/mips/mm/c-r3k.c
--- a/arch/mips/mm/c-r3k.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/mm/c-r3k.c	2004-12-24 13:37:18 -08:00
@@ -7,7 +7,7 @@
  * Tx39XX R4k style caches added. HK
  * Copyright (C) 1998, 1999, 2000 Harald Koerfgen
  * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- * Copyright (C) 2001  Maciej W. Rozycki
+ * Copyright (C) 2001, 2004  Maciej W. Rozycki
  */
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -337,6 +337,8 @@
 	flush_data_cache_page = r3k_flush_data_cache_page;
 
 	_dma_cache_wback_inv = r3k_dma_cache_wback_inv;
+	_dma_cache_wback = r3k_dma_cache_wback_inv;
+	_dma_cache_inv = r3k_dma_cache_wback_inv;
 
 	printk("Primary instruction cache %ldkB, linesize %ld bytes.\n",
 		icache_size >> 10, icache_lsize);
diff -Nru a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
--- a/arch/mips/mm/c-r4k.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/mm/c-r4k.c	2004-12-24 13:37:29 -08:00
@@ -49,7 +49,7 @@
 #define R4600_HIT_CACHEOP_WAR_IMPL					\
 do {									\
 	if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())		\
-		*(volatile unsigned long *)KSEG1;			\
+		*(volatile unsigned long *)CKSEG1;			\
 	if (R4600_V1_HIT_CACHEOP_WAR)					\
 		__asm__ __volatile__("nop;nop;nop;nop");		\
 } while (0)
@@ -86,7 +86,7 @@
 
 static void (* r4k_blast_dcache)(void);
 
-static void r4k_blast_dcache_setup(void)
+static inline void r4k_blast_dcache_setup(void)
 {
 	unsigned long dc_lsize = cpu_dcache_line_size();
 
@@ -254,16 +254,25 @@
 		r4k_blast_scache = blast_scache128;
 }
 
+/*
+ * This is former mm's flush_cache_all() which really should be
+ * flush_cache_vunmap these days ...
+ */
+static inline void local_r4k_flush_cache_all(void * args)
+{
+	r4k_blast_dcache();
+	r4k_blast_icache();
+}
+
 static void r4k_flush_cache_all(void)
 {
 	if (!cpu_has_dc_aliases)
 		return;
 
-	r4k_blast_dcache();
-	r4k_blast_icache();
+	on_each_cpu(local_r4k_flush_cache_all, NULL, 1, 1);
 }
 
-static void r4k___flush_cache_all(void)
+static inline void local_r4k___flush_cache_all(void * args)
 {
 	r4k_blast_dcache();
 	r4k_blast_icache();
@@ -279,9 +288,14 @@
 	}
 }
 
-static void r4k_flush_cache_range(struct vm_area_struct *vma,
-	unsigned long start, unsigned long end)
+static void r4k___flush_cache_all(void)
 {
+	on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1);
+}
+
+static inline void local_r4k_flush_cache_range(void * args)
+{
+	struct vm_area_struct *vma = args;
 	int exec;
 
 	if (!(cpu_context(smp_processor_id(), vma->vm_mm)))
@@ -294,8 +308,16 @@
 		r4k_blast_icache();
 }
 
-static void r4k_flush_cache_mm(struct mm_struct *mm)
+static void r4k_flush_cache_range(struct vm_area_struct *vma,
+	unsigned long start, unsigned long end)
 {
+	on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
+}
+
+static inline void local_r4k_flush_cache_mm(void * args)
+{
+	struct mm_struct *mm = args;
+
 	if (!cpu_has_dc_aliases)
 		return;
 
@@ -316,9 +338,21 @@
 		r4k_blast_scache();
 }
 
-static void r4k_flush_cache_page(struct vm_area_struct *vma,
-					unsigned long page)
+static void r4k_flush_cache_mm(struct mm_struct *mm)
+{
+	on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1);
+}
+
+struct flush_cache_page_args {
+	struct vm_area_struct *vma;
+	unsigned long page;
+};
+
+static inline void local_r4k_flush_cache_page(void *args)
 {
+	struct flush_cache_page_args *fcp_args = args;
+	struct vm_area_struct *vma = fcp_args->vma;
+	unsigned long page = fcp_args->page;
 	int exec = vma->vm_flags & VM_EXEC;
 	struct mm_struct *mm = vma->vm_mm;
 	pgd_t *pgdp;
@@ -377,14 +411,39 @@
 	}
 }
 
+static void r4k_flush_cache_page(struct vm_area_struct *vma,
+	unsigned long page)
+{
+	struct flush_cache_page_args args;
+
+	args.vma = vma;
+	args.page = page;
+
+	on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1);
+}
+
+static inline void local_r4k_flush_data_cache_page(void * addr)
+{
+	r4k_blast_dcache_page((unsigned long) addr);
+}
+
 static void r4k_flush_data_cache_page(unsigned long addr)
 {
-	r4k_blast_dcache_page(addr);
+	on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 1, 1);
 }
 
-static void r4k_flush_icache_range(unsigned long start, unsigned long end)
+struct flush_icache_range_args {
+	unsigned long start;
+	unsigned long end;
+};
+
+static inline void local_r4k_flush_icache_range(void *args)
 {
+	struct flush_icache_range_args *fir_args = args;
 	unsigned long dc_lsize = current_cpu_data.dcache.linesz;
+	unsigned long ic_lsize = current_cpu_data.icache.linesz;
+	unsigned long start = fir_args->start;
+	unsigned long end = fir_args->end;
 	unsigned long addr, aend;
 
 	if (!cpu_has_ic_fills_f_dc) {
@@ -407,18 +466,28 @@
 	if (end - start > icache_size)
 		r4k_blast_icache();
 	else {
-		addr = start & ~(dc_lsize - 1);
-		aend = (end - 1) & ~(dc_lsize - 1);
+		addr = start & ~(ic_lsize - 1);
+		aend = (end - 1) & ~(ic_lsize - 1);
 		while (1) {
 			/* Hit_Invalidate_I */
 			protected_flush_icache_line(addr);
 			if (addr == aend)
 				break;
-			addr += dc_lsize;
+			addr += ic_lsize;
 		}
 	}
 }
 
+static void r4k_flush_icache_range(unsigned long start, unsigned long end)
+{
+	struct flush_icache_range_args args;
+
+	args.start = start;
+	args.end = end;
+
+	on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1);
+}
+
 /*
  * Ok, this seriously sucks.  We use them to flush a user page but don't
  * know the virtual address, so we have to blast away the whole icache
@@ -426,14 +495,17 @@
  * least know the kernel address of the page so we can flush it
  * selectivly.
  */
-static void r4k_flush_icache_page(struct vm_area_struct *vma, struct page *page)
+
+struct flush_icache_page_args {
+	struct vm_area_struct *vma;
+	struct page *page;
+};
+
+static inline void local_r4k_flush_icache_page(void *args)
 {
-	/*
-	 * If there's no context yet, or the page isn't executable, no icache
-	 * flush is needed.
-	 */
-	if (!(vma->vm_flags & VM_EXEC))
-		return;
+	struct flush_icache_page_args *fip_args = args;
+	struct vm_area_struct *vma = fip_args->vma;
+	struct page *page = fip_args->page;
 
 	/*
 	 * Tricky ...  Because we don't know the virtual address we've got the
@@ -471,6 +543,25 @@
 		r4k_blast_icache();
 }
 
+static void r4k_flush_icache_page(struct vm_area_struct *vma,
+	struct page *page)
+{
+	struct flush_icache_page_args args;
+
+	/*
+	 * If there's no context yet, or the page isn't executable, no I-cache
+	 * flush is needed.
+	 */
+	if (!(vma->vm_flags & VM_EXEC))
+		return;
+
+	args.vma = vma;
+	args.page = page;
+
+	on_each_cpu(local_r4k_flush_icache_page, &args, 1, 1);
+}
+
+
 #ifdef CONFIG_DMA_NONCOHERENT
 
 static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size)
@@ -574,10 +665,11 @@
  * very much about what happens in that case.  Usually a segmentation
  * fault will dump the process later on anyway ...
  */
-static void r4k_flush_cache_sigtramp(unsigned long addr)
+static void local_r4k_flush_cache_sigtramp(void * arg)
 {
 	unsigned long ic_lsize = current_cpu_data.icache.linesz;
 	unsigned long dc_lsize = current_cpu_data.dcache.linesz;
+	unsigned long addr = (unsigned long) arg;
 
 	R4600_HIT_CACHEOP_WAR_IMPL;
 	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
@@ -587,10 +679,10 @@
 			".set push\n\t"
 			".set noat\n\t"
 			".set mips3\n\t"
-#if CONFIG_MIPS32
+#ifdef CONFIG_MIPS32
 			"la	$at,1f\n\t"
 #endif
-#if CONFIG_MIPS64
+#ifdef CONFIG_MIPS64
 			"dla	$at,1f\n\t"
 #endif
 			"cache	%0,($at)\n\t"
@@ -604,6 +696,11 @@
 		__asm__ __volatile__ ("sync");
 }
 
+static void r4k_flush_cache_sigtramp(unsigned long addr)
+{
+	on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1);
+}
+
 static void r4k_flush_icache_all(void)
 {
 	if (cpu_has_vtag_icache)
@@ -893,7 +990,7 @@
 	       cpu_has_vtag_icache ? "virtually tagged" : "physically tagged",
 	       way_string[c->icache.ways], c->icache.linesz);
 
-	printk("Primary data cache %ldkB %s, linesize %d bytes.\n",
+	printk("Primary data cache %ldkB, %s, linesize %d bytes.\n",
 	       dcache_size >> 10, way_string[c->dcache.ways], c->dcache.linesz);
 }
 
@@ -982,7 +1079,7 @@
 	case CPU_R4000MC:
 	case CPU_R4400SC:
 	case CPU_R4400MC:
-		probe_scache_kseg1 = (probe_func_t) (KSEG1ADDR(&probe_scache));
+		probe_scache_kseg1 = (probe_func_t) (CKSEG1ADDR(&probe_scache));
 		sc_present = probe_scache_kseg1(config);
 		if (sc_present)
 			c->options |= MIPS_CPU_CACHE_CDEX_S;
diff -Nru a/arch/mips/mm/c-sb1.c b/arch/mips/mm/c-sb1.c
--- a/arch/mips/mm/c-sb1.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/mm/c-sb1.c	2004-12-24 13:36:49 -08:00
@@ -20,10 +20,13 @@
  */
 #include <linux/config.h>
 #include <linux/init.h>
-#include <asm/mmu_context.h>
+
+#include <asm/asm.h>
 #include <asm/bootinfo.h>
 #include <asm/cacheops.h>
 #include <asm/cpu.h>
+#include <asm/mipsregs.h>
+#include <asm/mmu_context.h>
 #include <asm/uaccess.h>
 
 extern void sb1_dma_init(void);
@@ -32,17 +35,17 @@
 static unsigned long icache_size;
 static unsigned long dcache_size;
 
-static unsigned long icache_line_size;
-static unsigned long dcache_line_size;
+static unsigned short icache_line_size;
+static unsigned short dcache_line_size;
 
 static unsigned int icache_index_mask;
 static unsigned int dcache_index_mask;
 
-static unsigned long icache_assoc;
-static unsigned long dcache_assoc;
+static unsigned short icache_assoc;
+static unsigned short dcache_assoc;
 
-static unsigned int icache_sets;
-static unsigned int dcache_sets;
+static unsigned short icache_sets;
+static unsigned short dcache_sets;
 
 static unsigned int icache_range_cutoff;
 static unsigned int dcache_range_cutoff;
@@ -449,6 +452,11 @@
  * 9:7   Dcache Associativity
  */
 
+static char *way_string[] = {
+	"direct mapped", "2-way", "3-way", "4-way",
+	"5-way", "6-way", "7-way", "8-way",
+};
+
 static __init void probe_cache_sizes(void)
 {
 	u32 config1;
@@ -473,6 +481,13 @@
 	 */
 	icache_range_cutoff = icache_sets * icache_line_size;
 	dcache_range_cutoff = (dcache_sets / 2) * icache_line_size;
+
+	printk("Primary instruction cache %ldkB, %s, linesize %d bytes.\n",
+	       icache_size >> 10, way_string[icache_assoc - 1],
+	       icache_line_size);
+	printk("Primary data cache %ldkB, %s, linesize %d bytes.\n",
+	       dcache_size >> 10, way_string[dcache_assoc - 1],
+	       dcache_line_size);
 }
 
 /*
@@ -526,15 +541,14 @@
 	 * before subsequent instruction fetch.
 	 */
 	__asm__ __volatile__(
+		".set	push			\n"
 	"	.set	noat			\n"
 	"	.set	noreorder		\n"
-	"	.set	mips3\n\t		\n"
-	"	la	$1, 1f			\n"
-	"	mtc0	$1, $14			\n"
+	"	.set	mips3			\n"
+	"	" STR(PTR_LA) "	$1, 1f		\n"
+	"	" STR(MTC0) "	$1, $14		\n"
 	"	eret				\n"
-	"1:	.set	mips0\n\t		\n"
-	"	.set	at			\n"
-	"	.set	reorder"
+	"1:	.set	pop"
 	:
 	:
 	: "memory");
diff -Nru a/arch/mips/mm/c-tx39.c b/arch/mips/mm/c-tx39.c
--- a/arch/mips/mm/c-tx39.c	2004-12-24 13:37:33 -08:00
+++ b/arch/mips/mm/c-tx39.c	2004-12-24 13:37:33 -08:00
@@ -484,9 +484,9 @@
 	current_cpu_data.icache.waybit = 0;
 	current_cpu_data.dcache.waybit = 0;
 
-	printk("Primary instruction cache %ldkb, linesize %d bytes\n",
+	printk("Primary instruction cache %ldkB, linesize %d bytes\n",
 		icache_size >> 10, current_cpu_data.icache.linesz);
-	printk("Primary data cache %ldkb, linesize %d bytes\n",
+	printk("Primary data cache %ldkB, linesize %d bytes\n",
 		dcache_size >> 10, current_cpu_data.dcache.linesz);
 
 	build_clear_page();
diff -Nru a/arch/mips/mm/ioremap.c b/arch/mips/mm/ioremap.c
--- a/arch/mips/mm/ioremap.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/mm/ioremap.c	2004-12-24 13:36:49 -08:00
@@ -97,6 +97,15 @@
 }
 
 /*
+ * Allow physical addresses to be fixed up to help 36 bit peripherals.
+ */
+phys_t __attribute__ ((weak))
+fixup_bigphys_addr(phys_t phys_addr, phys_t size)
+{
+	return phys_addr;
+}
+
+/*
  * Generic mapping function (not visible outside):
  */
 
@@ -110,7 +119,7 @@
  * caller shouldn't need to know that small detail.
  */
 
-#define IS_LOW512(addr) (!((phys_t)(addr) & ~0x1fffffffUL))
+#define IS_LOW512(addr) (!((phys_t)(addr) & (phys_t) ~0x1fffffffULL))
 
 void * __ioremap(phys_t phys_addr, phys_t size, unsigned long flags)
 {
@@ -119,6 +128,8 @@
 	phys_t last_addr;
 	void * addr;
 
+	phys_addr = fixup_bigphys_addr(phys_addr, size);
+
 	/* Don't allow wraparound or zero size */
 	last_addr = phys_addr + size - 1;
 	if (!size || last_addr < phys_addr)
@@ -171,15 +182,14 @@
 
 #define IS_KSEG1(addr) (((unsigned long)(addr) & ~0x1fffffffUL) == KSEG1)
 
-void __iounmap(void *addr)
+void __iounmap(volatile void __iomem *addr)
 {
 	struct vm_struct *p;
 
 	if (IS_KSEG1(addr))
 		return;
 
-	vfree((void *) (PAGE_MASK & (unsigned long) addr));
-	p = remove_vm_area((void *) (PAGE_MASK & (unsigned long) addr));
+	p = remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));
 	if (!p) {
 		printk(KERN_ERR "iounmap: bad address %p\n", addr);
 		return;
diff -Nru a/arch/mips/mm/pg-r4k.c b/arch/mips/mm/pg-r4k.c
--- a/arch/mips/mm/pg-r4k.c	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/mm/pg-r4k.c	2004-12-24 13:36:55 -08:00
@@ -224,7 +224,7 @@
 	emit_instruction(mi);
 }
 
-static void __build_store_reg(int reg)
+static void __init __build_store_reg(int reg)
 {
 	union mips_instruction mi;
 	unsigned int width;
@@ -356,7 +356,7 @@
 		case CPU_R10000:
 		case CPU_R12000:
 			pref_src_mode = Pref_LoadStreamed;
-			pref_dst_mode = Pref_StoreRetained;
+			pref_dst_mode = Pref_StoreStreamed;
 			break;
 
 		default:
diff -Nru a/arch/mips/mm/pgtable-64.c b/arch/mips/mm/pgtable-64.c
--- a/arch/mips/mm/pgtable-64.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/mm/pgtable-64.c	2004-12-24 13:36:18 -08:00
@@ -52,29 +52,8 @@
 
 void __init pagetable_init(void)
 {
-	pmd_t *pmd;
-	pte_t *pte;
-	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);
-
-	memset((void *)kptbl, 0, PAGE_SIZE << PGD_ORDER);
-	memset((void *)kpmdtbl, 0, PAGE_SIZE);
-	set_pgd(swapper_pg_dir, __pgd((unsigned long)kpmdtbl));
-
-	/*
-	 * The 64-bit kernel uses a flat pagetable for it's kernel mappings ...
-	 */
-	pmd = kpmdtbl;
-	pte = kptbl;
-	i = 0;
-	while (i < (1 << PGD_ORDER)) {
-		pmd_val(*pmd) = (unsigned long)pte;
-		pte += PTRS_PER_PTE;
-		pmd++;
-		i++;
-	}
 }
diff -Nru a/arch/mips/mm/tlb-andes.c b/arch/mips/mm/tlb-andes.c
--- a/arch/mips/mm/tlb-andes.c	2004-12-24 13:36:30 -08:00
+++ b/arch/mips/mm/tlb-andes.c	2004-12-24 13:36:30 -08:00
@@ -17,10 +17,7 @@
 #include <asm/system.h>
 #include <asm/mmu_context.h>
 
-extern void except_vec0_generic(void);
-extern void except_vec0_r4000(void);
-extern void except_vec1_generic(void);
-extern void except_vec1_r10k(void);
+extern void build_tlb_refill_handler(void);
 
 #define NTLB_ENTRIES       64
 #define NTLB_ENTRIES_HALF  32
@@ -88,7 +85,7 @@
 				idx = read_c0_index();
 				write_c0_entrylo0(0);
 				write_c0_entrylo1(0);
-				write_c0_entryhi(KSEG0);
+				write_c0_entryhi(CKSEG0);
 				if(idx < 0)
 					continue;
 				tlb_write_indexed();
@@ -126,7 +123,7 @@
 			idx = read_c0_index();
 			write_c0_entrylo0(0);
 			write_c0_entrylo1(0);
-			write_c0_entryhi(KSEG0 + (idx << (PAGE_SHIFT+1)));
+			write_c0_entryhi(CKSEG0 + (idx << (PAGE_SHIFT+1)));
 			if (idx < 0)
 				continue;
 			tlb_write_indexed();
@@ -154,7 +151,7 @@
 		idx = read_c0_index();
 		write_c0_entrylo0(0);
 		write_c0_entrylo1(0);
-		write_c0_entryhi(KSEG0);
+		write_c0_entryhi(CKSEG0);
 		if (idx < 0)
 			goto finish;
 		tlb_write_indexed();
@@ -184,7 +181,7 @@
 	write_c0_entrylo1(0);
 	if (idx >= 0) {
 		/* Make sure all entries differ. */
-		write_c0_entryhi(KSEG0+(idx<<(PAGE_SHIFT+1)));
+		write_c0_entryhi(CKSEG0+(idx<<(PAGE_SHIFT+1)));
 		tlb_write_indexed();
 	}
 	write_c0_entryhi(oldpid);
@@ -257,14 +254,5 @@
 
 	/* Did I tell you that ARC SUCKS?  */
 
-#ifdef CONFIG_MIPS32
-	memcpy((void *)KSEG0, &except_vec0_r4000, 0x80);
-	memcpy((void *)(KSEG0 + 0x080), &except_vec1_generic, 0x80);
-	flush_icache_range(KSEG0, KSEG0 + 0x100);
-#endif
-#ifdef CONFIG_MIPS64
-	memcpy((void *)(CKSEG0 + 0x000), &except_vec0_generic, 0x80);
-	memcpy((void *)(CKSEG0 + 0x080), except_vec1_r10k, 0x80);
-	flush_icache_range(CKSEG0 + 0x80, CKSEG0 + 0x100);
-#endif
+	build_tlb_refill_handler();
 }
diff -Nru a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c
--- a/arch/mips/mm/tlb-r3k.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/mm/tlb-r3k.c	2004-12-24 13:37:29 -08:00
@@ -26,7 +26,7 @@
 
 #undef DEBUG_TLB
 
-extern char except_vec0_r2300;
+extern void build_tlb_refill_handler(void);
 
 /* CP0 hazard avoidance. */
 #define BARRIER				\
@@ -284,6 +284,6 @@
 void __init tlb_init(void)
 {
 	local_flush_tlb_all();
-	memcpy((void *)KSEG0, &except_vec0_r2300, 0x80);
-	flush_icache_range(KSEG0, KSEG0 + 0x80);
+
+	build_tlb_refill_handler();
 }
diff -Nru a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
--- a/arch/mips/mm/tlb-r4k.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/mm/tlb-r4k.c	2004-12-24 13:36:31 -08:00
@@ -19,12 +19,7 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 
-extern void except_vec0_generic(void);
-extern void except_vec0_nevada(void);
-extern void except_vec0_r4000(void);
-extern void except_vec0_r4600(void);
-extern void except_vec1_generic(void);
-extern void except_vec1_r4k(void);
+extern void build_tlb_refill_handler(void);
 
 /* CP0 hazard avoidance. */
 #define BARRIER __asm__ __volatile__(".set noreorder\n\t" \
@@ -255,8 +250,14 @@
 	idx = read_c0_index();
 	ptep = pte_offset_map(pmdp, address);
 
-	write_c0_entrylo0(pte_val(*ptep++) >> 6);
-	write_c0_entrylo1(pte_val(*ptep) >> 6);
+ #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
+ 	write_c0_entrylo0(ptep->pte_high);
+ 	ptep++;
+ 	write_c0_entrylo1(ptep->pte_high);
+#else
+  	write_c0_entrylo0(pte_val(*ptep++) >> 6);
+  	write_c0_entrylo1(pte_val(*ptep) >> 6);
+#endif
 	write_c0_entryhi(address | pid);
 	mtc0_tlbw_hazard();
 	if (idx < 0)
@@ -414,19 +415,5 @@
 	temp_tlb_entry = current_cpu_data.tlbsize - 1;
 	local_flush_tlb_all();
 
-#ifdef CONFIG_MIPS32
-	if (current_cpu_data.cputype == CPU_NEVADA)
-		memcpy((void *)KSEG0, &except_vec0_nevada, 0x80);
-	else if (current_cpu_data.cputype == CPU_R4600)
-		memcpy((void *)KSEG0, &except_vec0_r4600, 0x80);
-	else
-		memcpy((void *)KSEG0, &except_vec0_r4000, 0x80);
-	memcpy((void *)(KSEG0 + 0x080), &except_vec1_generic, 0x80);
-	flush_icache_range(KSEG0, KSEG0 + 0x100);
-#endif
-#ifdef CONFIG_MIPS64
-	memcpy((void *)(CKSEG0 + 0x00), &except_vec0_generic, 0x80);
-	memcpy((void *)(CKSEG0 + 0x80), except_vec1_r4k, 0x80);
-	flush_icache_range(CKSEG0 + 0x80, CKSEG0 + 0x100);
-#endif
+	build_tlb_refill_handler();
 }
diff -Nru a/arch/mips/mm/tlb-r8k.c b/arch/mips/mm/tlb-r8k.c
--- a/arch/mips/mm/tlb-r8k.c	2004-12-24 13:37:01 -08:00
+++ b/arch/mips/mm/tlb-r8k.c	2004-12-24 13:37:01 -08:00
@@ -19,8 +19,7 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 
-extern void except_vec0_generic(void);
-extern void except_vec1_r8k(void);
+extern void build_tlb_refill_handler(void);
 
 #define TFP_TLB_SIZE		384
 #define TFP_TLB_SET_SHIFT	7
@@ -247,7 +246,5 @@
 
 	local_flush_tlb_all();
 
-	memcpy((void *)(CKSEG0 + 0x00), &except_vec0_generic, 0x80);
-	memcpy((void *)(CKSEG0 + 0x80), except_vec1_r8k, 0x80);
-	flush_icache_range(CKSEG0 + 0x80, CKSEG0 + 0x100);
+	build_tlb_refill_handler();
 }
diff -Nru a/arch/mips/mm/tlb-sb1.c b/arch/mips/mm/tlb-sb1.c
--- a/arch/mips/mm/tlb-sb1.c	2004-12-24 13:37:32 -08:00
+++ b/arch/mips/mm/tlb-sb1.c	2004-12-24 13:37:32 -08:00
@@ -23,14 +23,7 @@
 #include <asm/bootinfo.h>
 #include <asm/cpu.h>
 
-#ifdef CONFIG_MIPS32
-extern void except_vec0_sb1(void);
-extern void except_vec1_generic(void);
-#endif
-#ifdef CONFIG_MIPS64
-extern void except_vec0_generic(void);
-extern void except_vec1_sb1(void);
-#endif
+extern void build_tlb_refill_handler(void);
 
 #define UNIQUE_ENTRYHI(idx) (KSEG0 + ((idx) << (PAGE_SHIFT + 1)))
 
@@ -286,10 +279,17 @@
    these entries, we just bump the asid. */
 void local_flush_tlb_mm(struct mm_struct *mm)
 {
-	int cpu = smp_processor_id();
+	int cpu;
+
+	preempt_disable();
+
+	cpu = smp_processor_id();
+
 	if (cpu_context(cpu, mm) != 0) {
 		drop_mmu_context(mm, cpu);
 	}
+
+	preempt_enable();
 }
 
 /* Stolen from mips32 routines */
@@ -373,14 +373,5 @@
 	 */
 	sb1_sanitize_tlb();
 
-#ifdef CONFIG_MIPS32
-	memcpy((void *)KSEG0, &except_vec0_sb1, 0x80);
-	memcpy((void *)(KSEG0 + 0x080), &except_vec1_generic, 0x80);
-	flush_icache_range(KSEG0, KSEG0 + 0x100);
-#endif
-#ifdef CONFIG_MIPS64
-	memcpy((void *)CKSEG0, &except_vec0_generic, 0x80);
-	memcpy((void *)(CKSEG0 + 0x80), &except_vec1_sb1, 0x80);
-	flush_icache_range(CKSEG0, CKSEG0 + 0x100);
-#endif
+	build_tlb_refill_handler();
 }
diff -Nru a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/mm/tlbex.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1177 @@
+/*
+ * 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.
+ *
+ * Synthesize TLB refill handlers at runtime.
+ *
+ * Copyright (C) 2004 by Thiemo Seufer
+ */
+
+#include <stdarg.h>
+
+#include <linux/config.h>
+#include <linux/mm.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/init.h>
+
+#include <asm/pgtable.h>
+#include <asm/cacheflush.h>
+#include <asm/cacheflush.h>
+#include <asm/mmu_context.h>
+#include <asm/inst.h>
+#include <asm/elf.h>
+#include <asm/smp.h>
+
+/* #define DEBUG_TLB */
+
+static __init int __attribute__((unused)) r45k_bvahwbug(void)
+{
+	/* XXX: We should probe for the presence of this bug, but we don't. */
+	return 0;
+}
+
+static __init int __attribute__((unused)) r4k_250MHZhwbug(void)
+{
+	/* XXX: We should probe for the presence of this bug, but we don't. */
+	return 0;
+}
+
+static __init int __attribute__((unused)) bcm1250_m3_war(void)
+{
+	return BCM1250_M3_WAR;
+}
+
+/*
+ * A little micro-assembler, intended for TLB refill handler
+ * synthesizing. It is intentionally kept simple, does only support
+ * a subset of instructions, and does not try to hide pipeline effects
+ * like branch delay slots.
+ */
+
+enum fields
+{
+	RS = 0x001,
+	RT = 0x002,
+	RD = 0x004,
+	RE = 0x008,
+	SIMM = 0x010,
+	UIMM = 0x020,
+	BIMM = 0x040,
+	JIMM = 0x080,
+	FUNC = 0x100,
+};
+
+#define OP_MASK		0x2f
+#define OP_SH		26
+#define RS_MASK		0x1f
+#define RS_SH		21
+#define RT_MASK		0x1f
+#define RT_SH		16
+#define RD_MASK		0x1f
+#define RD_SH		11
+#define RE_MASK		0x1f
+#define RE_SH		6
+#define IMM_MASK	0xffff
+#define IMM_SH		0
+#define JIMM_MASK	0x3ffffff
+#define JIMM_SH		0
+#define FUNC_MASK	0x2f
+#define FUNC_SH		0
+
+enum opcode {
+	insn_invalid,
+	insn_addu, insn_addiu, insn_and, insn_andi, insn_beq,
+	insn_bgez, insn_bgezl, insn_bltz, insn_bltzl, insn_bne,
+	insn_daddu, insn_daddiu, insn_dmfc0, insn_dmtc0,
+	insn_dsll, insn_dsll32, insn_dsra, insn_dsrl, insn_dsrl32,
+	insn_dsubu, insn_eret, insn_j, insn_jal, insn_jr, insn_ld,
+	insn_lui, insn_lw, insn_mfc0, insn_mtc0, insn_ori, insn_rfe,
+	insn_sd, insn_sll, insn_sra, insn_srl, insn_subu, insn_sw,
+	insn_tlbp, insn_tlbwi, insn_tlbwr, insn_xor, insn_xori
+};
+
+struct insn {
+	enum opcode opcode;
+	u32 match;
+	enum fields fields;
+};
+
+/* This macro sets the non-variable bits of an instruction. */
+#define M(a, b, c, d, e, f)					\
+	((a) << OP_SH						\
+	 | (b) << RS_SH						\
+	 | (c) << RT_SH						\
+	 | (d) << RD_SH						\
+	 | (e) << RE_SH						\
+	 | (f) << FUNC_SH)
+
+static __initdata struct insn insn_table[] = {
+	{ insn_addiu, M(addiu_op,0,0,0,0,0), RS | RT | SIMM },
+	{ insn_addu, M(spec_op,0,0,0,0,addu_op), RS | RT | RD },
+	{ insn_and, M(spec_op,0,0,0,0,and_op), RS | RT | RD },
+	{ insn_andi, M(andi_op,0,0,0,0,0), RS | RT | UIMM },
+	{ insn_beq, M(beq_op,0,0,0,0,0), RS | RT | BIMM },
+	{ insn_bgez, M(bcond_op,0,bgez_op,0,0,0), RS | BIMM },
+	{ insn_bgezl, M(bcond_op,0,bgezl_op,0,0,0), RS | BIMM },
+	{ insn_bltz, M(bcond_op,0,bltz_op,0,0,0), RS | BIMM },
+	{ insn_bltzl, M(bcond_op,0,bltzl_op,0,0,0), RS | BIMM },
+	{ insn_bne, M(bne_op,0,0,0,0,0), RS | RT | BIMM },
+	{ insn_daddiu, M(daddiu_op,0,0,0,0,0), RS | RT | SIMM },
+	{ insn_daddu, M(spec_op,0,0,0,0,daddu_op), RS | RT | RD },
+	{ insn_dmfc0, M(cop0_op,dmfc_op,0,0,0,0), RT | RD },
+	{ insn_dmtc0, M(cop0_op,dmtc_op,0,0,0,0), RT | RD },
+	{ insn_dsll, M(spec_op,0,0,0,0,dsll_op), RT | RD | RE },
+	{ insn_dsll32, M(spec_op,0,0,0,0,dsll32_op), RT | RD | RE },
+	{ insn_dsra, M(spec_op,0,0,0,0,dsra_op), RT | RD | RE },
+	{ insn_dsrl, M(spec_op,0,0,0,0,dsrl_op), RT | RD | RE },
+	{ insn_dsrl32, M(spec_op,0,0,0,0,dsrl32_op), RT | RD | RE },
+	{ insn_dsubu, M(spec_op,0,0,0,0,dsubu_op), RS | RT | RD },
+	{ insn_eret, M(cop0_op,cop_op,0,0,0,eret_op), 0 },
+	{ insn_j, M(j_op,0,0,0,0,0), JIMM },
+	{ insn_jal, M(jal_op,0,0,0,0,0), JIMM },
+	{ insn_jr, M(spec_op,0,0,0,0,jr_op), RS },
+	{ insn_ld, M(ld_op,0,0,0,0,0), RS | RT | SIMM },
+	{ insn_lui, M(lui_op,0,0,0,0,0), RT | SIMM },
+	{ insn_lw, M(lw_op,0,0,0,0,0), RS | RT | SIMM },
+	{ insn_mfc0, M(cop0_op,mfc_op,0,0,0,0), RT | RD },
+	{ insn_mtc0, M(cop0_op,mtc_op,0,0,0,0), RT | RD },
+	{ insn_ori, M(ori_op,0,0,0,0,0), RS | RT | UIMM },
+	{ insn_rfe, M(cop0_op,cop_op,0,0,0,rfe_op), 0 },
+	{ insn_sd, M(sd_op,0,0,0,0,0), RS | RT | SIMM },
+	{ insn_sll, M(spec_op,0,0,0,0,sll_op), RT | RD | RE },
+	{ insn_sra, M(spec_op,0,0,0,0,sra_op), RT | RD | RE },
+	{ insn_srl, M(spec_op,0,0,0,0,srl_op), RT | RD | RE },
+	{ insn_subu, M(spec_op,0,0,0,0,subu_op), RS | RT | RD },
+	{ insn_sw, M(sw_op,0,0,0,0,0), RS | RT | SIMM },
+	{ insn_tlbp, M(cop0_op,cop_op,0,0,0,tlbp_op), 0 },
+	{ insn_tlbwi, M(cop0_op,cop_op,0,0,0,tlbwi_op), 0 },
+	{ insn_tlbwr, M(cop0_op,cop_op,0,0,0,tlbwr_op), 0 },
+	{ insn_xor, M(spec_op,0,0,0,0,xor_op), RS | RT | RD },
+	{ insn_xori, M(xori_op,0,0,0,0,0), RS | RT | UIMM },
+	{ insn_invalid, 0, 0 }
+};
+
+#undef M
+
+static __init u32 build_rs(u32 arg)
+{
+	if (arg & ~RS_MASK)
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	return (arg & RS_MASK) << RS_SH;
+}
+
+static __init u32 build_rt(u32 arg)
+{
+	if (arg & ~RT_MASK)
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	return (arg & RT_MASK) << RT_SH;
+}
+
+static __init u32 build_rd(u32 arg)
+{
+	if (arg & ~RD_MASK)
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	return (arg & RD_MASK) << RD_SH;
+}
+
+static __init u32 build_re(u32 arg)
+{
+	if (arg & ~RE_MASK)
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	return (arg & RE_MASK) << RE_SH;
+}
+
+static __init u32 build_simm(s32 arg)
+{
+	if (arg > 0x7fff || arg < -0x8000)
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	return arg & 0xffff;
+}
+
+static __init u32 build_uimm(u32 arg)
+{
+	if (arg & ~IMM_MASK)
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	return arg & IMM_MASK;
+}
+
+static __init u32 build_bimm(s32 arg)
+{
+	if (arg > 0x1ffff || arg < -0x20000)
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	if (arg & 0x3)
+		printk(KERN_WARNING "Invalid TLB synthesizer branch target\n");
+
+	return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff);
+}
+
+static __init u32 build_jimm(u32 arg)
+{
+	if (arg & ~((JIMM_MASK) << 2))
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	return (arg >> 2) & JIMM_MASK;
+}
+
+static __init u32 build_func(u32 arg)
+{
+	if (arg & ~FUNC_MASK)
+		printk(KERN_WARNING "TLB synthesizer field overflow\n");
+
+	return arg & FUNC_MASK;
+}
+
+/*
+ * The order of opcode arguments is implicitly left to right,
+ * starting with RS and ending with FUNC or IMM.
+ */
+static void __init build_insn(u32 **buf, enum opcode opc, ...)
+{
+	struct insn *ip = NULL;
+	unsigned int i;
+	va_list ap;
+	u32 op;
+
+	for (i = 0; insn_table[i].opcode != insn_invalid; i++)
+		if (insn_table[i].opcode == opc) {
+			ip = &insn_table[i];
+			break;
+		}
+
+	if (!ip)
+		panic("Unsupported TLB synthesizer instruction %d", opc);
+
+	op = ip->match;
+	va_start(ap, opc);
+	if (ip->fields & RS) op |= build_rs(va_arg(ap, u32));
+	if (ip->fields & RT) op |= build_rt(va_arg(ap, u32));
+	if (ip->fields & RD) op |= build_rd(va_arg(ap, u32));
+	if (ip->fields & RE) op |= build_re(va_arg(ap, u32));
+	if (ip->fields & SIMM) op |= build_simm(va_arg(ap, s32));
+	if (ip->fields & UIMM) op |= build_uimm(va_arg(ap, u32));
+	if (ip->fields & BIMM) op |= build_bimm(va_arg(ap, s32));
+	if (ip->fields & JIMM) op |= build_jimm(va_arg(ap, u32));
+	if (ip->fields & FUNC) op |= build_func(va_arg(ap, u32));
+	va_end(ap);
+
+	**buf = op;
+	(*buf)++;
+}
+
+#define I_u1u2u3(op)						\
+	static inline void i##op(u32 **buf, unsigned int a,	\
+	 	unsigned int b, unsigned int c)			\
+	{							\
+		build_insn(buf, insn##op, a, b, c);		\
+	}
+
+#define I_u2u1u3(op)						\
+	static inline void i##op(u32 **buf, unsigned int a,	\
+	 	unsigned int b, unsigned int c)			\
+	{							\
+		build_insn(buf, insn##op, b, a, c);		\
+	}
+
+#define I_u3u1u2(op)						\
+	static inline void i##op(u32 **buf, unsigned int a,	\
+	 	unsigned int b, unsigned int c)			\
+	{							\
+		build_insn(buf, insn##op, b, c, a);		\
+	}
+
+#define I_u1u2s3(op)						\
+	static inline void i##op(u32 **buf, unsigned int a,	\
+	 	unsigned int b, signed int c)			\
+	{							\
+		build_insn(buf, insn##op, a, b, c);		\
+	}
+
+#define I_u2s3u1(op)						\
+	static inline void i##op(u32 **buf, unsigned int a,	\
+	 	signed int b, unsigned int c)			\
+	{							\
+		build_insn(buf, insn##op, c, a, b);		\
+	}
+
+#define I_u2u1s3(op)						\
+	static inline void i##op(u32 **buf, unsigned int a,	\
+	 	unsigned int b, signed int c)			\
+	{							\
+		build_insn(buf, insn##op, b, a, c);		\
+	}
+
+#define I_u1u2(op)						\
+	static inline void i##op(u32 **buf, unsigned int a,	\
+	 	unsigned int b)					\
+	{							\
+		build_insn(buf, insn##op, a, b);		\
+	}
+
+#define I_u1s2(op)						\
+	static inline void i##op(u32 **buf, unsigned int a,	\
+	 	signed int b)					\
+	{							\
+		build_insn(buf, insn##op, a, b);		\
+	}
+
+#define I_u1(op)						\
+	static inline void i##op(u32 **buf, unsigned int a)	\
+	{							\
+		build_insn(buf, insn##op, a);			\
+	}
+
+#define I_0(op)							\
+	static inline void i##op(u32 **buf)			\
+	{							\
+		build_insn(buf, insn##op);			\
+	}
+
+I_u2u1s3(_addiu);
+I_u3u1u2(_addu);
+I_u2u1u3(_andi);
+I_u3u1u2(_and);
+I_u1u2s3(_beq);
+I_u1s2(_bgez);
+I_u1s2(_bgezl);
+I_u1s2(_bltz);
+I_u1s2(_bltzl);
+I_u1u2s3(_bne);
+I_u1u2(_dmfc0);
+I_u1u2(_dmtc0);
+I_u2u1s3(_daddiu);
+I_u3u1u2(_daddu);
+I_u2u1u3(_dsll);
+I_u2u1u3(_dsll32);
+I_u2u1u3(_dsra);
+I_u2u1u3(_dsrl);
+I_u2u1u3(_dsrl32);
+I_u3u1u2(_dsubu);
+I_0(_eret);
+I_u1(_j);
+I_u1(_jal);
+I_u1(_jr);
+I_u2s3u1(_ld);
+I_u1s2(_lui);
+I_u2s3u1(_lw);
+I_u1u2(_mfc0);
+I_u1u2(_mtc0);
+I_u2u1u3(_ori);
+I_0(_rfe);
+I_u2s3u1(_sd);
+I_u2u1u3(_sll);
+I_u2u1u3(_sra);
+I_u2u1u3(_srl);
+I_u3u1u2(_subu);
+I_u2s3u1(_sw);
+I_0(_tlbp);
+I_0(_tlbwi);
+I_0(_tlbwr);
+I_u3u1u2(_xor)
+I_u2u1u3(_xori);
+
+/*
+ * handling labels
+ */
+
+enum label_id {
+	label_invalid,
+	label_second_part,
+	label_leave,
+	label_vmalloc,
+	label_vmalloc_done,
+	label_tlbwr_hazard,
+	label_split
+};
+
+struct label {
+	u32 *addr;
+	enum label_id lab;
+};
+
+static __init void build_label(struct label **lab, u32 *addr,
+			       enum label_id l)
+{
+	(*lab)->addr = addr;
+	(*lab)->lab = l;
+	(*lab)++;
+}
+
+#define L_LA(lb)						\
+	static inline void l##lb(struct label **lab, u32 *addr) \
+	{							\
+		build_label(lab, addr, label##lb);		\
+	}
+
+L_LA(_second_part)
+L_LA(_leave)
+L_LA(_vmalloc)
+L_LA(_vmalloc_done)
+L_LA(_tlbwr_hazard)
+L_LA(_split)
+
+/* convenience macros for instructions */
+#ifdef CONFIG_MIPS64
+# define i_LW(buf, rs, rt, off) i_ld(buf, rs, rt, off)
+# define i_SW(buf, rs, rt, off) i_sd(buf, rs, rt, off)
+# define i_SLL(buf, rs, rt, sh) i_dsll(buf, rs, rt, sh)
+# define i_SRA(buf, rs, rt, sh) i_dsra(buf, rs, rt, sh)
+# define i_SRL(buf, rs, rt, sh) i_dsrl(buf, rs, rt, sh)
+# define i_MFC0(buf, rt, rd) i_dmfc0(buf, rt, rd)
+# define i_MTC0(buf, rt, rd) i_dmtc0(buf, rt, rd)
+# define i_ADDIU(buf, rs, rt, val) i_daddiu(buf, rs, rt, val)
+# define i_ADDU(buf, rs, rt, rd) i_daddu(buf, rs, rt, rd)
+# define i_SUBU(buf, rs, rt, rd) i_dsubu(buf, rs, rt, rd)
+#else
+# define i_LW(buf, rs, rt, off) i_lw(buf, rs, rt, off)
+# define i_SW(buf, rs, rt, off) i_sw(buf, rs, rt, off)
+# define i_SLL(buf, rs, rt, sh) i_sll(buf, rs, rt, sh)
+# define i_SRA(buf, rs, rt, sh) i_sra(buf, rs, rt, sh)
+# define i_SRL(buf, rs, rt, sh) i_srl(buf, rs, rt, sh)
+# define i_MFC0(buf, rt, rd) i_mfc0(buf, rt, rd)
+# define i_MTC0(buf, rt, rd) i_mtc0(buf, rt, rd)
+# define i_ADDIU(buf, rs, rt, val) i_addiu(buf, rs, rt, val)
+# define i_ADDU(buf, rs, rt, rd) i_addu(buf, rs, rt, rd)
+# define i_SUBU(buf, rs, rt, rd) i_subu(buf, rs, rt, rd)
+#endif
+
+#define i_b(buf, off) i_beq(buf, 0, 0, off)
+#define i_bnez(buf, rs, off) i_bne(buf, rs, 0, off)
+#define i_move(buf, a, b) i_ADDU(buf, a, 0, b)
+#define i_nop(buf) i_sll(buf, 0, 0, 0)
+#define i_ssnop(buf) i_sll(buf, 0, 0, 1)
+#define i_ehb(buf) i_sll(buf, 0, 0, 3)
+
+#if CONFIG_MIPS64
+static __init int in_compat_space_p(long addr)
+{
+	/* Is this address in 32bit compat space? */
+	return (((addr) & 0xffffffff00000000) == 0xffffffff00000000);
+}
+
+static __init int rel_highest(long val)
+{
+	return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000;
+}
+
+static __init int rel_higher(long val)
+{
+	return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000;
+}
+#endif
+
+static __init int rel_hi(long val)
+{
+	return ((((val + 0x8000L) >> 16) & 0xffff) ^ 0x8000) - 0x8000;
+}
+
+static __init int rel_lo(long val)
+{
+	return ((val & 0xffff) ^ 0x8000) - 0x8000;
+}
+
+static __init void i_LA_mostly(u32 **buf, unsigned int rs, long addr)
+{
+#if CONFIG_MIPS64
+	if (!in_compat_space_p(addr)) {
+		i_lui(buf, rs, rel_highest(addr));
+		if (rel_higher(addr))
+			i_daddiu(buf, rs, rs, rel_higher(addr));
+		if (rel_hi(addr)) {
+			i_dsll(buf, rs, rs, 16);
+			i_daddiu(buf, rs, rs, rel_hi(addr));
+			i_dsll(buf, rs, rs, 16);
+		} else
+			i_dsll32(buf, rs, rs, 0);
+	} else
+#endif
+		i_lui(buf, rs, rel_hi(addr));
+}
+
+static __init void __attribute__((unused)) i_LA(u32 **buf, unsigned int rs,
+						long addr)
+{
+	i_LA_mostly(buf, rs, addr);
+	if (rel_lo(addr))
+		i_ADDIU(buf, rs, rs, rel_lo(addr));
+}
+
+/*
+ * handle relocations
+ */
+
+struct reloc {
+	u32 *addr;
+	unsigned int type;
+	enum label_id lab;
+};
+
+static __init void r_mips_pc16(struct reloc **rel, u32 *addr,
+			       enum label_id l)
+{
+	(*rel)->addr = addr;
+	(*rel)->type = R_MIPS_PC16;
+	(*rel)->lab = l;
+	(*rel)++;
+}
+
+static inline void __resolve_relocs(struct reloc *rel, struct label *lab)
+{
+	long laddr = (long)lab->addr;
+	long raddr = (long)rel->addr;
+
+	switch (rel->type) {
+	case R_MIPS_PC16:
+		*rel->addr |= build_bimm(laddr - (raddr + 4));
+		break;
+
+	default:
+		panic("Unsupported TLB synthesizer relocation %d",
+		      rel->type);
+	}
+}
+
+static __init void resolve_relocs(struct reloc *rel, struct label *lab)
+{
+	struct label *l;
+
+	for (; rel->lab != label_invalid; rel++)
+		for (l = lab; l->lab != label_invalid; l++)
+			if (rel->lab == l->lab)
+				__resolve_relocs(rel, l);
+}
+
+static __init void copy_handler(struct reloc *rel, struct label *lab,
+				u32 *first, u32 *end, u32* target)
+{
+	long off = (long)(target - first);
+
+	memcpy(target, first, (end - first) * sizeof(u32));
+
+	for (; rel->lab != label_invalid; rel++)
+		if (rel->addr >= first && rel->addr < end)
+			rel->addr += off;
+
+	for (; lab->lab != label_invalid; lab++)
+		if (lab->addr >= first && lab->addr < end)
+			lab->addr += off;
+}
+
+static __init int __attribute__((unused)) insn_has_bdelay(struct reloc *rel,
+							  u32 *addr)
+{
+	for (; rel->lab != label_invalid; rel++) {
+		if (rel->addr == addr
+		    && (rel->type == R_MIPS_PC16
+			|| rel->type == R_MIPS_26))
+			return 1;
+	}
+
+	return 0;
+}
+
+/* convenience functions for labeled branches */
+static void __attribute__((unused)) il_bltz(u32 **p, struct reloc **r,
+					    unsigned int reg, enum label_id l)
+{
+	r_mips_pc16(r, *p, l);
+	i_bltz(p, reg, 0);
+}
+
+static void __attribute__((unused)) il_b(u32 **p, struct reloc **r,
+					 enum label_id l)
+{
+	r_mips_pc16(r, *p, l);
+	i_b(p, 0);
+}
+
+static void il_bnez(u32 **p, struct reloc **r, unsigned int reg,
+		    enum label_id l)
+{
+	r_mips_pc16(r, *p, l);
+	i_bnez(p, reg, 0);
+}
+
+static void il_bgezl(u32 **p, struct reloc **r, unsigned int reg,
+		     enum label_id l)
+{
+	r_mips_pc16(r, *p, l);
+	i_bgezl(p, reg, 0);
+}
+
+/* The only registers allowed in TLB handlers. */
+#define K0		26
+#define K1		27
+
+/* Some CP0 registers */
+#define C0_INDEX	0
+#define C0_ENTRYLO0	2
+#define C0_ENTRYLO1	3
+#define C0_CONTEXT	4
+#define C0_BADVADDR	8
+#define C0_ENTRYHI	10
+#define C0_EPC		14
+#define C0_XCONTEXT	20
+
+#ifdef CONFIG_MIPS64
+# define GET_CONTEXT(buf, reg) i_MFC0(buf, reg, C0_XCONTEXT)
+#else
+# define GET_CONTEXT(buf, reg) i_MFC0(buf, reg, C0_CONTEXT)
+#endif
+
+/* The worst case length of the handler is around 18 instructions for
+ * R3000-style TLBs and up to 63 instructions for R4000-style TLBs.
+ * Maximum space available is 32 instructions for R3000 and 64
+ * instructions for R4000.
+ *
+ * We deliberately chose a buffer size of 128, so we won't scribble
+ * over anything important on overflow before we panic.
+ */
+static __initdata u32 tlb_handler[128];
+
+/* simply assume worst case size for labels and relocs */
+static __initdata struct label labels[128];
+static __initdata struct reloc relocs[128];
+
+#ifdef CONFIG_MIPS32
+/*
+ * The R3000 TLB handler is simple.
+ */
+static void __init build_r3000_tlb_refill_handler(void)
+{
+	long pgdc = (long)pgd_current;
+	u32 *p;
+
+	memset(tlb_handler, 0, sizeof(tlb_handler));
+	p = tlb_handler;
+
+	i_mfc0(&p, K0, C0_BADVADDR);
+	i_lui(&p, K1, rel_hi(pgdc)); /* cp0 delay */
+	i_lw(&p, K1, rel_lo(pgdc), K1);
+	i_srl(&p, K0, K0, 22); /* load delay */
+	i_sll(&p, K0, K0, 2);
+	i_addu(&p, K1, K1, K0);
+	i_mfc0(&p, K0, C0_CONTEXT);
+	i_lw(&p, K1, 0, K1); /* cp0 delay */
+	i_andi(&p, K0, K0, 0xffc); /* load delay */
+	i_addu(&p, K1, K1, K0);
+	i_lw(&p, K0, 0, K1);
+	i_nop(&p); /* load delay */
+	i_mtc0(&p, K0, C0_ENTRYLO0);
+	i_mfc0(&p, K1, C0_EPC); /* cp0 delay */
+	i_tlbwr(&p); /* cp0 delay */
+	i_jr(&p, K1);
+	i_rfe(&p); /* branch delay */
+
+	if (p > tlb_handler + 32)
+		panic("TLB refill handler space exceeded");
+
+	printk("Synthesized TLB handler (%u instructions).\n",
+	       p - tlb_handler);
+#ifdef DEBUG_TLB
+	{
+		int i;
+		for (i = 0; i < (p - tlb_handler); i++)
+			printk("%08x\n", tlb_handler[i]);
+	}
+#endif
+
+	memcpy((void *)CAC_BASE, tlb_handler, 0x80);
+	flush_icache_range(CAC_BASE, CAC_BASE + 0x80);
+}
+#endif /* CONFIG_MIPS32 */
+
+/*
+ * The R4000 TLB handler is much more complicated. We have two
+ * consecutive handler areas with 32 instructions space each.
+ * Since they aren't used at the same time, we can overflow in the
+ * other one.To keep things simple, we first assume linear space,
+ * then we relocate it to the final handler layout as needed.
+ */
+static __initdata u32 final_handler[64];
+
+/*
+ * Hazards
+ *
+ * From the IDT errata for the QED RM5230 (Nevada), processor revision 1.0:
+ * 2. A timing hazard exists for the TLBP instruction.
+ *
+ *      stalling_instruction
+ *      TLBP
+ *
+ * The JTLB is being read for the TLBP throughout the stall generated by the
+ * previous instruction. This is not really correct as the stalling instruction
+ * can modify the address used to access the JTLB.  The failure symptom is that
+ * the TLBP instruction will use an address created for the stalling instruction
+ * and not the address held in C0_ENHI and thus report the wrong results.
+ *
+ * The software work-around is to not allow the instruction preceding the TLBP
+ * to stall - make it an NOP or some other instruction guaranteed not to stall.
+ *
+ * Errata 2 will not be fixed.  This errata is also on the R5000.
+ *
+ * As if we MIPS hackers wouldn't know how to nop pipelines happy ...
+ */
+static __init void __attribute__((unused)) build_tlb_probe_entry(u32 **p)
+{
+	switch (current_cpu_data.cputype) {
+	case CPU_R5000:
+	case CPU_R5000A:
+	case CPU_NEVADA:
+		i_nop(p);
+		i_tlbp(p);
+		break;
+
+	default:
+		i_tlbp(p);
+		break;
+	}
+}
+
+/*
+ * Write random TLB entry, and care about the hazards from the
+ * preceeding mtc0 and for the following eret.
+ */
+static __init void build_tlb_write_random_entry(u32 **p, struct label **l,
+						struct reloc **r)
+{
+	switch (current_cpu_data.cputype) {
+	case CPU_R4000PC:
+	case CPU_R4000SC:
+	case CPU_R4000MC:
+	case CPU_R4400PC:
+	case CPU_R4400SC:
+	case CPU_R4400MC:
+		/*
+		 * This branch uses up a mtc0 hazard nop slot and saves
+		 * two nops after the tlbwr.
+		 */
+		il_bgezl(p, r, 0, label_tlbwr_hazard);
+		i_tlbwr(p);
+		l_tlbwr_hazard(l, *p);
+		i_nop(p);
+		break;
+
+	case CPU_R4600:
+	case CPU_R4700:
+	case CPU_R5000:
+	case CPU_R5000A:
+	case CPU_5KC:
+	case CPU_AU1000:
+	case CPU_AU1100:
+	case CPU_AU1500:
+	case CPU_AU1550:
+		i_nop(p);
+		i_tlbwr(p);
+		break;
+
+	case CPU_R10000:
+	case CPU_R12000:
+	case CPU_4KC:
+	case CPU_SB1:
+	case CPU_4KSC:
+	case CPU_20KC:
+	case CPU_25KF:
+		i_tlbwr(p);
+		break;
+
+	case CPU_NEVADA:
+		i_nop(p); /* QED specifies 2 nops hazard */
+		/*
+		 * This branch uses up a mtc0 hazard nop slot and saves
+		 * a nop after the tlbwr.
+		 */
+		il_bgezl(p, r, 0, label_tlbwr_hazard);
+		i_tlbwr(p);
+		l_tlbwr_hazard(l, *p);
+		break;
+
+	case CPU_4KEC:
+	case CPU_24K:
+		i_ehb(p);
+		i_tlbwr(p);
+		break;
+
+	case CPU_RM9000:
+		/*
+		 * When the JTLB is updated by tlbwi or tlbwr, a subsequent
+		 * use of the JTLB for instructions should not occur for 4
+		 * cpu cycles and use for data translations should not occur
+		 * for 3 cpu cycles.
+		 */
+		i_ssnop(p);
+		i_ssnop(p);
+		i_ssnop(p);
+		i_ssnop(p);
+		i_tlbwr(p);
+		i_ssnop(p);
+		i_ssnop(p);
+		i_ssnop(p);
+		i_ssnop(p);
+		break;
+
+	default:
+		panic("No TLB refill handler yet (CPU type: %d)",
+		      current_cpu_data.cputype);
+		break;
+	}
+}
+
+#if CONFIG_MIPS64
+/*
+ * TMP and PTR are scratch.
+ * TMP will be clobbered, PTR will hold the pmd entry.
+ */
+static __init void
+build_get_pmde64(u32 **p, struct label **l, struct reloc **r,
+		 unsigned int tmp, unsigned int ptr)
+{
+	long pgdc = (long)pgd_current;
+
+	/*
+	 * The vmalloc handling is not in the hotpath.
+	 */
+	i_dmfc0(p, tmp, C0_BADVADDR);
+	il_bltz(p, r, tmp, label_vmalloc);
+	/* No i_nop needed here, since the next insn doesn't touch TMP. */
+
+# ifdef CONFIG_SMP
+	/*
+	 * 64 bit SMP has the lower part of &pgd_current[smp_processor_id()]
+	 * stored in CONTEXT.
+	 */
+	if (in_compat_space_p(pgdc)) {
+		i_dmfc0(p, ptr, C0_CONTEXT);
+		i_dsra(p, ptr, ptr, 23);
+	} else {
+		i_dmfc0(p, ptr, C0_CONTEXT);
+		i_lui(p, tmp, rel_highest(pgdc));
+		i_dsll(p, ptr, ptr, 9);
+		i_daddiu(p, tmp, tmp, rel_higher(pgdc));
+		i_dsrl32(p, ptr, ptr, 0);
+		i_and(p, ptr, ptr, tmp);
+		i_dmfc0(p, tmp, C0_BADVADDR);
+	}
+	i_ld(p, ptr, 0, ptr);
+# else
+	i_LA_mostly(p, ptr, pgdc);
+	i_ld(p, ptr, rel_lo(pgdc), ptr);
+# endif
+
+	l_vmalloc_done(l, *p);
+	i_dsrl(p, tmp, tmp, PGDIR_SHIFT-3); /* get pgd offset in bytes */
+	i_andi(p, tmp, tmp, (PTRS_PER_PGD - 1)<<3);
+	i_daddu(p, ptr, ptr, tmp); /* add in pgd offset */
+	i_dmfc0(p, tmp, C0_BADVADDR); /* get faulting address */
+	i_ld(p, ptr, 0, ptr); /* get pmd pointer */
+	i_dsrl(p, tmp, tmp, PMD_SHIFT-3); /* get pmd offset in bytes */
+	i_andi(p, tmp, tmp, (PTRS_PER_PMD - 1)<<3);
+	i_daddu(p, ptr, ptr, tmp); /* add in pmd offset */
+}
+
+/*
+ * BVADDR is the faulting address, PTR is scratch.
+ * PTR will hold the pgd for vmalloc.
+ */
+static __init void
+build_get_pgd_vmalloc64(u32 **p, struct label **l, struct reloc **r,
+			unsigned int bvaddr, unsigned int ptr)
+{
+	long swpd = (long)swapper_pg_dir;
+
+	l_vmalloc(l, *p);
+	i_LA(p, ptr, VMALLOC_START);
+	i_dsubu(p, bvaddr, bvaddr, ptr);
+
+	if (in_compat_space_p(swpd) && !rel_lo(swpd)) {
+		il_b(p, r, label_vmalloc_done);
+		i_lui(p, ptr, rel_hi(swpd));
+	} else {
+		i_LA_mostly(p, ptr, swpd);
+		il_b(p, r, label_vmalloc_done);
+		i_daddiu(p, ptr, ptr, rel_lo(swpd));
+	}
+}
+
+#else /* CONFIG_MIPS32 */
+
+/*
+ * TMP and PTR are scratch.
+ * TMP will be clobbered, PTR will hold the pgd entry.
+ */
+static __init void build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
+{
+	long pgdc = (long)pgd_current;
+
+	/* 32 bit SMP has smp_processor_id() stored in CONTEXT. */
+#ifdef CONFIG_SMP
+	i_mfc0(p, ptr, C0_CONTEXT);
+	i_LA_mostly(p, tmp, pgdc);
+	i_srl(p, ptr, ptr, 23);
+	i_sll(p, ptr, ptr, 2);
+	i_addu(p, ptr, tmp, ptr);
+#else
+	i_LA_mostly(p, ptr, pgdc);
+#endif
+	i_mfc0(p, tmp, C0_BADVADDR); /* get faulting address */
+	i_lw(p, ptr, rel_lo(pgdc), ptr);
+	i_srl(p, tmp, tmp, PGDIR_SHIFT); /* get pgd only bits */
+	i_sll(p, tmp, tmp, PGD_T_LOG2);
+	i_addu(p, ptr, ptr, tmp); /* add in pgd offset */
+}
+#endif /* CONFIG_MIPS32 */
+
+static __init void build_adjust_context(u32 **p, unsigned int ctx)
+{
+	unsigned int shift = 0;
+	unsigned int mask = 0xff0;
+
+#if !defined(CONFIG_MIPS64) && !defined(CONFIG_64BIT_PHYS_ADDR)
+	shift++;
+	mask |= 0x008;
+#endif
+
+	switch (current_cpu_data.cputype) {
+	case CPU_VR41XX:
+	case CPU_VR4111:
+	case CPU_VR4121:
+	case CPU_VR4122:
+	case CPU_VR4131:
+	case CPU_VR4181:
+	case CPU_VR4181A:
+	case CPU_VR4133:
+		shift += 2;
+		break;
+
+	default:
+		break;
+	}
+
+	if (shift)
+		i_SRL(p, ctx, ctx, shift);
+	i_andi(p, ctx, ctx, mask);
+}
+
+static __init void build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr)
+{
+	/*
+	 * Bug workaround for the Nevada. It seems as if under certain
+	 * circumstances the move from cp0_context might produce a
+	 * bogus result when the mfc0 instruction and its consumer are
+	 * in a different cacheline or a load instruction, probably any
+	 * memory reference, is between them.
+	 */
+	switch (current_cpu_data.cputype) {
+	case CPU_NEVADA:
+		i_LW(p, ptr, 0, ptr);
+		GET_CONTEXT(p, tmp); /* get context reg */
+		break;
+
+	default:
+		GET_CONTEXT(p, tmp); /* get context reg */
+		i_LW(p, ptr, 0, ptr);
+		break;
+	}
+
+	build_adjust_context(p, tmp);
+	i_ADDU(p, ptr, ptr, tmp); /* add in offset */
+}
+
+static __init void build_update_entries(u32 **p, unsigned int tmp,
+					unsigned int ptep)
+{
+	/*
+	 * 64bit address support (36bit on a 32bit CPU) in a 32bit
+	 * Kernel is a special case. Only a few CPUs use it.
+	 */
+#ifdef CONFIG_64BIT_PHYS_ADDR
+	if (cpu_has_64bit_gp_regs) {
+		i_ld(p, tmp, 0, ptep); /* get even pte */
+		i_ld(p, ptep, sizeof(pte_t), ptep); /* get odd pte */
+		i_dsrl(p, tmp, tmp, 6); /* convert to entrylo0 */
+		i_mtc0(p, tmp, C0_ENTRYLO0); /* load it */
+		i_dsrl(p, ptep, ptep, 6); /* convert to entrylo1 */
+		i_mtc0(p, ptep, C0_ENTRYLO1); /* load it */
+	} else {
+		int pte_off_even = sizeof(pte_t) / 2;
+		int pte_off_odd = pte_off_even + sizeof(pte_t);
+
+		/* The pte entries are pre-shifted */
+		i_lw(p, tmp, pte_off_even, ptep); /* get even pte */
+		i_mtc0(p, tmp, C0_ENTRYLO0); /* load it */
+		i_lw(p, ptep, pte_off_odd, ptep); /* get odd pte */
+		i_mtc0(p, ptep, C0_ENTRYLO1); /* load it */
+	}
+#else
+	i_LW(p, tmp, 0, ptep); /* get even pte */
+	i_LW(p, ptep, sizeof(pte_t), ptep); /* get odd pte */
+	if (r45k_bvahwbug())
+		build_tlb_probe_entry(p);
+	i_SRL(p, tmp, tmp, 6); /* convert to entrylo0 */
+	if (r4k_250MHZhwbug())
+		i_mtc0(p, 0, C0_ENTRYLO0);
+	i_mtc0(p, tmp, C0_ENTRYLO0); /* load it */
+	i_SRL(p, ptep, ptep, 6); /* convert to entrylo1 */
+	if (r45k_bvahwbug())
+		i_mfc0(p, tmp, C0_INDEX);
+	if (r4k_250MHZhwbug())
+		i_mtc0(p, 0, C0_ENTRYLO1);
+	i_mtc0(p, ptep, C0_ENTRYLO1); /* load it */
+#endif
+}
+
+static void __init build_r4000_tlb_refill_handler(void)
+{
+	u32 *p = tlb_handler;
+	struct label *l = labels;
+	struct reloc *r = relocs;
+	u32 *f;
+	unsigned int final_len;
+
+	memset(tlb_handler, 0, sizeof(tlb_handler));
+	memset(labels, 0, sizeof(labels));
+	memset(relocs, 0, sizeof(relocs));
+	memset(final_handler, 0, sizeof(final_handler));
+
+	/*
+	 * create the plain linear handler
+	 */
+	if (bcm1250_m3_war()) {
+		i_MFC0(&p, K0, C0_BADVADDR);
+		i_MFC0(&p, K1, C0_ENTRYHI);
+		i_xor(&p, K0, K0, K1);
+		i_SRL(&p, K0, K0, PAGE_SHIFT+1);
+		il_bnez(&p, &r, K0, label_leave);
+		/* No need for i_nop */
+	}
+
+#ifdef CONFIG_MIPS64
+	build_get_pmde64(&p, &l, &r, K0, K1); /* get pmd ptr in K1 */
+#else
+	build_get_pgde32(&p, K0, K1); /* get pgd ptr in K1 */
+#endif
+
+	build_get_ptep(&p, K0, K1);
+	build_update_entries(&p, K0, K1);
+	build_tlb_write_random_entry(&p, &l, &r);
+	l_leave(&l, p);
+	i_eret(&p); /* return from trap */
+
+#ifdef CONFIG_MIPS64
+	build_get_pgd_vmalloc64(&p, &l, &r, K0, K1);
+#endif
+
+	/*
+	 * Overflow check: For the 64bit handler, we need at least one
+	 * free instruction slot for the wrap-around branch. In worst
+	 * case, if the intended insertion point is a delay slot, we
+	 * need three, with the the second nop'ed and the third being
+	 * unused.
+	 */
+#ifdef CONFIG_MIPS32
+	if ((p - tlb_handler) > 64)
+		panic("TLB refill handler space exceeded");
+#else
+	if (((p - tlb_handler) > 63)
+	    || (((p - tlb_handler) > 61)
+		&& insn_has_bdelay(relocs, tlb_handler + 29)))
+		panic("TLB refill handler space exceeded");
+#endif
+
+	/*
+	 * Now fold the handler in the TLB refill handler space.
+	 */
+#ifdef CONFIG_MIPS32
+	f = final_handler;
+	/* Simplest case, just copy the handler. */
+	copy_handler(relocs, labels, tlb_handler, p, f);
+	final_len = p - tlb_handler;
+#else /* CONFIG_MIPS64 */
+	f = final_handler + 32;
+	if ((p - tlb_handler) <= 32) {
+		/* Just copy the handler. */
+		copy_handler(relocs, labels, tlb_handler, p, f);
+		final_len = p - tlb_handler;
+	} else {
+		u32 *split = tlb_handler + 30;
+
+		/*
+		 * Find the split point.
+		 */
+		if (insn_has_bdelay(relocs, split - 1))
+			split--;
+
+		/* Copy first part of the handler. */
+		copy_handler(relocs, labels, tlb_handler, split, f);
+		f += split - tlb_handler;
+
+		/* Insert branch. */
+		l_split(&l, final_handler);
+		il_b(&f, &r, label_split);
+		if (insn_has_bdelay(relocs, split))
+			i_nop(&f);
+		else {
+			copy_handler(relocs, labels, split, split + 1, f);
+			f++;
+			split++;
+		}
+
+		/* Copy the rest of the handler. */
+		copy_handler(relocs, labels, split, p, final_handler);
+		final_len = (f - (final_handler + 32)) + (p - split);
+	}
+#endif /* CONFIG_MIPS64 */
+
+	resolve_relocs(relocs, labels);
+	printk("Synthesized TLB handler (%u instructions).\n", final_len);
+
+#ifdef DEBUG_TLB
+	{
+		int i;
+
+		for (i = 0; i < 64; i++)
+			printk("%08x\n", final_handler[i]);
+	}
+#endif
+
+	memcpy((void *)CAC_BASE, final_handler, 0x100);
+	flush_icache_range(CAC_BASE, CAC_BASE + 0x100);
+}
+
+void __init build_tlb_refill_handler(void)
+{
+	switch (current_cpu_data.cputype) {
+#ifdef CONFIG_MIPS32
+	case CPU_R2000:
+	case CPU_R3000:
+	case CPU_R3000A:
+	case CPU_R3081E:
+	case CPU_TX3912:
+	case CPU_TX3922:
+	case CPU_TX3927:
+		build_r3000_tlb_refill_handler();
+		break;
+
+	case CPU_R6000:
+	case CPU_R6000A:
+		panic("No R6000 TLB refill handler yet");
+		break;
+#endif
+
+	case CPU_R8000:
+		panic("No R8000 TLB refill handler yet");
+		break;
+
+	default:
+		build_r4000_tlb_refill_handler();
+	}
+}
diff -Nru a/arch/mips/mm/tlbex32-mips32.S b/arch/mips/mm/tlbex32-mips32.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/mm/tlbex32-mips32.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,253 @@
+/*
+ * TLB exception handling code for MIPS32 CPUs.
+ *
+ * Copyright (C) 1994, 1995, 1996 by Ralf Baechle and Andreas Busse
+ *
+ * Multi-cpu abstraction and reworking:
+ * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
+ *
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * Pete Popov, ppopov@pacbell.net
+ * Added 36 bit phys address support.
+ * Copyright (C) 2002 MontaVista Software, Inc.
+ */
+#include <linux/init.h>
+#include <asm/asm.h>
+#include <asm/cachectl.h>
+#include <asm/fpregdef.h>
+#include <asm/mipsregs.h>
+#include <asm/page.h>
+#include <asm/pgtable-bits.h>
+#include <asm/regdef.h>
+#include <asm/stackframe.h>
+
+#define TLB_OPTIMIZE /* If you are paranoid, disable this. */
+
+#ifdef CONFIG_64BIT_PHYS_ADDR
+
+/* We really only support 36 bit physical addresses on MIPS32 */
+#define PTE_L		lw
+#define PTE_S		sw
+#define PTE_SRL		srl
+#define P_MTC0		mtc0
+#define PTE_HALF        4 /* pte_high contains pre-shifted, ready to go entry */
+#define PTE_SIZE        8
+#define PTEP_INDX_MSK	0xff0
+#define PTE_INDX_MSK	0xff8
+#define PTE_INDX_SHIFT 9
+#define CONVERT_PTE(pte)
+#define PTE_MAKEWRITE_HIGH(pte, ptr) \
+	lw	pte, PTE_HALF(ptr); \
+	ori	pte, (_PAGE_VALID | _PAGE_DIRTY); \
+	sw	pte, PTE_HALF(ptr); \
+	lw	pte, 0(ptr);
+
+#define PTE_MAKEVALID_HIGH(pte, ptr) \
+	lw	pte, PTE_HALF(ptr); \
+	ori	pte, pte, _PAGE_VALID; \
+	sw	pte, PTE_HALF(ptr); \
+	lw	pte, 0(ptr);
+
+#else
+
+#define PTE_L		lw
+#define PTE_S		sw
+#define PTE_SRL		srl
+#define P_MTC0		mtc0
+#define PTE_HALF        0
+#define PTE_SIZE	4
+#define PTEP_INDX_MSK	0xff8
+#define PTE_INDX_MSK	0xffc
+#define PTE_INDX_SHIFT	10
+#define CONVERT_PTE(pte) srl pte, pte, 6
+#define PTE_MAKEWRITE_HIGH(pte, ptr)
+#define PTE_MAKEVALID_HIGH(pte, ptr)
+
+#endif  /* CONFIG_64BIT_PHYS_ADDR */
+
+#ifdef CONFIG_64BIT_PHYS_ADDR
+#define GET_PTE_OFF(reg)
+#else
+#define GET_PTE_OFF(reg)	srl	reg, reg, 1
+#endif
+
+/*
+ * ABUSE of CPP macros 101.
+ *
+ * After this macro runs, the pte faulted on is
+ * in register PTE, a ptr into the table in which
+ * the pte belongs is in PTR.
+ */
+
+#ifdef CONFIG_SMP
+#define GET_PGD(scratch, ptr)        \
+	mfc0    ptr, CP0_CONTEXT;    \
+	la      scratch, pgd_current;\
+	srl     ptr, 23;             \
+	sll     ptr, 2;              \
+	addu    ptr, scratch, ptr;   \
+	lw      ptr, (ptr);
+#else
+#define GET_PGD(scratch, ptr)    \
+	lw	ptr, pgd_current;
+#endif
+
+#define LOAD_PTE(pte, ptr) \
+	GET_PGD(pte, ptr)          \
+	mfc0	pte, CP0_BADVADDR; \
+	srl	pte, pte, _PGDIR_SHIFT; \
+	sll	pte, pte, 2; \
+	addu	ptr, ptr, pte; \
+	mfc0	pte, CP0_BADVADDR; \
+	lw	ptr, (ptr); \
+	srl	pte, pte, PTE_INDX_SHIFT; \
+	and	pte, pte, PTE_INDX_MSK; \
+	addu	ptr, ptr, pte; \
+	PTE_L	pte, (ptr);
+
+	/* This places the even/odd pte pair in the page
+	 * table at PTR into ENTRYLO0 and ENTRYLO1 using
+	 * TMP as a scratch register.
+	 */
+#define PTE_RELOAD(ptr, tmp) \
+	ori	ptr, ptr, PTE_SIZE; \
+	xori	ptr, ptr, PTE_SIZE; \
+	PTE_L	tmp, (PTE_HALF+PTE_SIZE)(ptr); \
+	CONVERT_PTE(tmp); \
+	P_MTC0	tmp, CP0_ENTRYLO1; \
+	PTE_L	ptr, PTE_HALF(ptr); \
+	CONVERT_PTE(ptr); \
+	P_MTC0	ptr, CP0_ENTRYLO0;
+
+#define DO_FAULT(write) \
+	.set	noat; \
+	SAVE_ALL; \
+	mfc0	a2, CP0_BADVADDR; \
+	KMODE; \
+	.set	at; \
+	move	a0, sp; \
+	jal	do_page_fault; \
+	 li	a1, write; \
+	j	ret_from_exception; \
+	 nop; \
+	.set	noat;
+
+	/* Check is PTE is present, if not then jump to LABEL.
+	 * PTR points to the page table where this PTE is located,
+	 * when the macro is done executing PTE will be restored
+	 * with it's original value.
+	 */
+#define PTE_PRESENT(pte, ptr, label) \
+	andi	pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
+	xori	pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
+	bnez	pte, label; \
+	PTE_L	pte, (ptr);
+
+	/* Make PTE valid, store result in PTR. */
+#define PTE_MAKEVALID(pte, ptr) \
+	ori	pte, pte, (_PAGE_VALID | _PAGE_ACCESSED); \
+	PTE_S	pte, (ptr);
+
+	/* Check if PTE can be written to, if not branch to LABEL.
+	 * Regardless restore PTE with value from PTR when done.
+	 */
+#define PTE_WRITABLE(pte, ptr, label) \
+	andi	pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
+	xori	pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
+	bnez	pte, label; \
+	PTE_L	pte, (ptr);
+
+	/* Make PTE writable, update software status bits as well,
+	 * then store at PTR.
+	 */
+#define PTE_MAKEWRITE(pte, ptr) \
+	ori	pte, pte, (_PAGE_ACCESSED | _PAGE_MODIFIED | \
+			   _PAGE_VALID | _PAGE_DIRTY); \
+	PTE_S	pte, (ptr);
+
+	.set	noreorder
+
+	.align	5
+	NESTED(handle_tlbl, PT_SIZE, sp)
+	.set	noat
+invalid_tlbl:
+#ifdef TLB_OPTIMIZE
+	/* Test present bit in entry. */
+	LOAD_PTE(k0, k1)
+	tlbp
+	PTE_PRESENT(k0, k1, nopage_tlbl)
+	PTE_MAKEVALID_HIGH(k0, k1)
+	PTE_MAKEVALID(k0, k1)
+	PTE_RELOAD(k1, k0)
+	nop
+	b	1f
+	 tlbwi
+1:
+	nop
+	.set	mips3
+	eret
+	.set	mips0
+#endif
+
+nopage_tlbl:
+	DO_FAULT(0)
+	END(handle_tlbl)
+
+	.align	5
+	NESTED(handle_tlbs, PT_SIZE, sp)
+	.set	noat
+#ifdef TLB_OPTIMIZE
+	.set	mips3
+        li      k0,0
+	LOAD_PTE(k0, k1)
+	tlbp				# find faulting entry
+	PTE_WRITABLE(k0, k1, nopage_tlbs)
+	PTE_MAKEWRITE(k0, k1)
+	PTE_MAKEWRITE_HIGH(k0, k1)
+	PTE_RELOAD(k1, k0)
+	nop
+	b	1f
+	 tlbwi
+1:
+	nop
+	.set	mips3
+	eret
+	.set	mips0
+#endif
+
+nopage_tlbs:
+	DO_FAULT(1)
+	END(handle_tlbs)
+
+	.align	5
+	NESTED(handle_mod, PT_SIZE, sp)
+	.set	noat
+#ifdef TLB_OPTIMIZE
+	.set	mips3
+	LOAD_PTE(k0, k1)
+	tlbp					# find faulting entry
+	andi	k0, k0, _PAGE_WRITE
+	beqz	k0, nowrite_mod
+	PTE_L	k0, (k1)
+
+	/* Present and writable bits set, set accessed and dirty bits. */
+	PTE_MAKEWRITE(k0, k1)
+	PTE_MAKEWRITE_HIGH(k0, k1)
+	/* Now reload the entry into the tlb. */
+	PTE_RELOAD(k1, k0)
+	nop
+	b	1f
+	 tlbwi
+1:
+	nop
+	.set	mips3
+	eret
+	.set	mips0
+#endif
+
+nowrite_mod:
+	DO_FAULT(1)
+	END(handle_mod)
+
diff -Nru a/arch/mips/mm/tlbex32-r3k.S b/arch/mips/mm/tlbex32-r3k.S
--- a/arch/mips/mm/tlbex32-r3k.S	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/mm/tlbex32-r3k.S	2004-12-24 13:37:00 -08:00
@@ -24,36 +24,6 @@
 
 #define TLB_OPTIMIZE /* If you are paranoid, disable this. */
 
-	.text
-	.set	mips1
-	.set	noreorder
-
-	__INIT
-
-	/* TLB refill, R[23]00 version */
-	LEAF(except_vec0_r2300)
-	.set	noat
-	.set	mips1
-	mfc0	k0, CP0_BADVADDR
-	lw	k1, pgd_current			# get pgd pointer
-	srl	k0, k0, 22
-	sll	k0, k0, 2
-	addu	k1, k1, k0
-	mfc0	k0, CP0_CONTEXT
-	lw	k1, (k1)
-	and	k0, k0, 0xffc
-	addu	k1, k1, k0
-	lw	k0, (k1)
-	nop
-	mtc0	k0, CP0_ENTRYLO0
-	mfc0	k1, CP0_EPC
-	tlbwr
-	jr	k1
-	rfe
-	END(except_vec0_r2300)
-
-	__FINIT
-
 	/* ABUSE of CPP macros 101. */
 
 	/* After this macro runs, the pte faulted on is
diff -Nru a/arch/mips/mm/tlbex32-r4k.S b/arch/mips/mm/tlbex32-r4k.S
--- a/arch/mips/mm/tlbex32-r4k.S	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/mm/tlbex32-r4k.S	2004-12-24 13:37:19 -08:00
@@ -139,271 +139,6 @@
 			   _PAGE_VALID | _PAGE_DIRTY); \
 	PTE_S	pte, (ptr);
 
-	__INIT
-
-#ifdef CONFIG_64BIT_PHYS_ADDR
-#define GET_PTE_OFF(reg)
-#elif CONFIG_CPU_VR41XX
-#define GET_PTE_OFF(reg)	srl	reg, reg, 3
-#else
-#define GET_PTE_OFF(reg)	srl	reg, reg, 1
-#endif
-
-/*
- * These handlers much be written in a relocatable manner
- * because based upon the cpu type an arbitrary one of the
- * following pieces of code will be copied to the KSEG0
- * vector location.
- */
-	/* TLB refill, EXL == 0, R4xx0, non-R4600 version */
-	.set	noreorder
-	.set	noat
-	LEAF(except_vec0_r4000)
-	.set	mips3
-	GET_PGD(k0, k1)				# get pgd pointer
-	mfc0	k0, CP0_BADVADDR		# Get faulting address
-	srl	k0, k0, _PGDIR_SHIFT		# get pgd only bits
-
-	sll	k0, k0, 2
-	addu	k1, k1, k0			# add in pgd offset
-	mfc0	k0, CP0_CONTEXT			# get context reg
-	lw	k1, (k1)
-	GET_PTE_OFF(k0)				# get pte offset
-	and	k0, k0, PTEP_INDX_MSK
-	addu	k1, k1, k0			# add in offset
-	PTE_L	k0, 0(k1)			# get even pte
-	PTE_L	k1, PTE_SIZE(k1)		# get odd pte
-	PTE_SRL	k0, k0, 6			# convert to entrylo0
-	P_MTC0	k0, CP0_ENTRYLO0		# load it
-	PTE_SRL	k1, k1, 6			# convert to entrylo1
-	P_MTC0	k1, CP0_ENTRYLO1		# load it
-	mtc0_tlbw_hazard
-	tlbwr					# write random tlb entry
-	tlbw_eret_hazard
-	eret					# return from trap
-	END(except_vec0_r4000)
-
-	/* TLB refill, EXL == 0, R4600 version */
-	LEAF(except_vec0_r4600)
-	.set	mips3
-	GET_PGD(k0, k1)				# get pgd pointer
-	mfc0	k0, CP0_BADVADDR
-	srl	k0, k0, _PGDIR_SHIFT
-	sll	k0, k0, 2			# log2(sizeof(pgd_t)
-	addu	k1, k1, k0
-	mfc0	k0, CP0_CONTEXT
-	lw	k1, (k1)
-	GET_PTE_OFF(k0)				# get pte offset
-	and	k0, k0, PTEP_INDX_MSK
-	addu	k1, k1, k0
-	PTE_L	k0, 0(k1)
-	PTE_L	k1, PTE_SIZE(k1)
-	PTE_SRL	k0, k0, 6
-	P_MTC0	k0, CP0_ENTRYLO0
-	PTE_SRL	k1, k1, 6
-	P_MTC0	k1, CP0_ENTRYLO1
-	nop
-	tlbwr
-	nop
-	eret
-	END(except_vec0_r4600)
-
-	/* TLB refill, EXL == 0, R52x0 "Nevada" version */
-        /*
-         * This version has a bug workaround for the Nevada.  It seems
-         * as if under certain circumstances the move from cp0_context
-         * might produce a bogus result when the mfc0 instruction and
-         * it's consumer are in a different cacheline or a load instruction,
-         * probably any memory reference, is between them.  This is
-         * potencially slower than the R4000 version, so we use this
-         * special version.
-         */
-	.set	noreorder
-	.set	noat
-	LEAF(except_vec0_nevada)
-	.set	mips3
-	mfc0	k0, CP0_BADVADDR		# Get faulting address
-	srl	k0, k0, _PGDIR_SHIFT		# get pgd only bits
-	lw	k1, pgd_current			# get pgd pointer
-	sll	k0, k0, 2			# log2(sizeof(pgd_t)
-	addu	k1, k1, k0			# add in pgd offset
-	lw	k1, (k1)
-	mfc0	k0, CP0_CONTEXT			# get context reg
-	GET_PTE_OFF(k0)				# get pte offset
-	and	k0, k0, PTEP_INDX_MSK
-	addu	k1, k1, k0			# add in offset
-	PTE_L	k0, 0(k1)			# get even pte
-	PTE_L	k1, PTE_SIZE(k1)		# get odd pte
-	PTE_SRL	k0, k0, 6			# convert to entrylo0
-	P_MTC0	k0, CP0_ENTRYLO0		# load it
-	PTE_SRL	k1, k1, 6			# convert to entrylo1
-	P_MTC0	k1, CP0_ENTRYLO1		# load it
-	nop					# QED specified nops
-	nop
-	tlbwr					# write random tlb entry
-	nop					# traditional nop
-	eret					# return from trap
-	END(except_vec0_nevada)
-
-	/* TLB refill, EXL == 0, SB1 with M3 errata handling version */
-	LEAF(except_vec0_sb1)
-#if BCM1250_M3_WAR
-	mfc0	k0, CP0_BADVADDR
-	mfc0	k1, CP0_ENTRYHI
-	xor	k0, k1
-	srl	k0, k0, PAGE_SHIFT+1
-	bnez	k0, 1f
-#endif
-	GET_PGD(k0, k1)				# get pgd pointer
-	mfc0	k0, CP0_BADVADDR		# Get faulting address
-	srl	k0, k0, _PGDIR_SHIFT		# get pgd only bits
-	sll	k0, k0, 2
-	addu	k1, k1, k0			# add in pgd offset
-	mfc0	k0, CP0_CONTEXT			# get context reg
-	lw	k1, (k1)
-	GET_PTE_OFF(k0)				# get pte offset
-	and	k0, k0, PTEP_INDX_MSK
-	addu	k1, k1, k0			# add in offset
-	PTE_L	k0, 0(k1)			# get even pte
-	PTE_L	k1, PTE_SIZE(k1)		# get odd pte
-	PTE_SRL	k0, k0, 6			# convert to entrylo0
-	P_MTC0	k0, CP0_ENTRYLO0		# load it
-	PTE_SRL	k1, k1, 6			# convert to entrylo1
-	P_MTC0	k1, CP0_ENTRYLO1		# load it
-	tlbwr					# write random tlb entry
-1:	eret					# return from trap
-	END(except_vec0_sb1)
-
-	/* TLB refill, EXL == 0, R4[40]00/R5000 badvaddr hwbug version */
-	LEAF(except_vec0_r45k_bvahwbug)
-	.set	mips3
-	GET_PGD(k0, k1)				# get pgd pointer
-	mfc0	k0, CP0_BADVADDR
-	srl	k0, k0, _PGDIR_SHIFT
-	sll	k0, k0, 2			# log2(sizeof(pgd_t)
-	addu	k1, k1, k0
-	mfc0	k0, CP0_CONTEXT
-	lw	k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
-	srl	k0, k0, 1
-#endif
-	and	k0, k0, PTEP_INDX_MSK
-	addu	k1, k1, k0
-	PTE_L	k0, 0(k1)
-	PTE_L	k1, PTE_SIZE(k1)
-	nop				/* XXX */
-	tlbp
-	PTE_SRL	k0, k0, 6
-	P_MTC0	k0, CP0_ENTRYLO0
-	PTE_SRL	k1, k1, 6
-	mfc0	k0, CP0_INDEX
-	P_MTC0	k1, CP0_ENTRYLO1
-	bltzl	k0, 1f
-	tlbwr
-1:
-	nop
-	eret
-	END(except_vec0_r45k_bvahwbug)
-
-#ifdef CONFIG_SMP
-	/* TLB refill, EXL == 0, R4000 MP badvaddr hwbug version */
-	LEAF(except_vec0_r4k_mphwbug)
-	.set	mips3
-	GET_PGD(k0, k1)				# get pgd pointer
-	mfc0	k0, CP0_BADVADDR
-	srl	k0, k0, _PGDIR_SHIFT
-	sll	k0, k0, 2			# log2(sizeof(pgd_t)
-	addu	k1, k1, k0
-	mfc0	k0, CP0_CONTEXT
-	lw	k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
-	srl	k0, k0, 1
-#endif
-	and	k0, k0, PTEP_INDX_MSK
-	addu	k1, k1, k0
-	PTE_L	k0, 0(k1)
-	PTE_L	k1, PTE_SIZE(k1)
-	nop				/* XXX */
-	tlbp
-	PTE_SRL	k0, k0, 6
-	P_MTC0	k0, CP0_ENTRYLO0
-	PTE_SRL	k1, k1, 6
-	mfc0	k0, CP0_INDEX
-	P_MTC0	k1, CP0_ENTRYLO1
-	bltzl	k0, 1f
-	tlbwr
-1:
-	nop
-	eret
-	END(except_vec0_r4k_mphwbug)
-#endif
-
-	/* TLB refill, EXL == 0, R4000 UP 250MHZ entrylo[01] hwbug version */
-	LEAF(except_vec0_r4k_250MHZhwbug)
-	.set	mips3
-	GET_PGD(k0, k1)				# get pgd pointer
-	mfc0	k0, CP0_BADVADDR
-	srl	k0, k0, _PGDIR_SHIFT
-	sll	k0, k0, 2			# log2(sizeof(pgd_t)
-	addu	k1, k1, k0
-	mfc0	k0, CP0_CONTEXT
-	lw	k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
-	srl	k0, k0, 1
-#endif
-	and	k0, k0, PTEP_INDX_MSK
-	addu	k1, k1, k0
-	PTE_L	k0, 0(k1)
-	PTE_L	k1, PTE_SIZE(k1)
-	PTE_SRL	k0, k0, 6
-	P_MTC0	zero, CP0_ENTRYLO0
-	P_MTC0	k0, CP0_ENTRYLO0
-	PTE_SRL	k1, k1, 6
-	P_MTC0	zero, CP0_ENTRYLO1
-	P_MTC0	k1, CP0_ENTRYLO1
-	b	1f
-	tlbwr
-1:
-	nop
-	eret
-	END(except_vec0_r4k_250MHZhwbug)
-
-#ifdef CONFIG_SMP
-	/* TLB refill, EXL == 0, R4000 MP 250MHZ entrylo[01]+badvaddr bug version */
-	LEAF(except_vec0_r4k_MP250MHZhwbug)
-	.set	mips3
-	GET_PGD(k0, k1)				# get pgd pointer
-	mfc0	k0, CP0_BADVADDR
-	srl	k0, k0, _PGDIR_SHIFT
-	sll	k0, k0, 2			# log2(sizeof(pgd_t)
-	addu	k1, k1, k0
-	mfc0	k0, CP0_CONTEXT
-	lw	k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
-	srl	k0, k0, 1
-#endif
-	and	k0, k0, PTEP_INDX_MSK
-	addu	k1, k1, k0
-	PTE_L	k0, 0(k1)
-	PTE_L	k1, PTE_SIZE(k1)
-	nop				/* XXX */
-	tlbp
-	PTE_SRL	k0, k0, 6
-	P_MTC0  zero, CP0_ENTRYLO0
-	P_MTC0  k0, CP0_ENTRYLO0
-	mfc0    k0, CP0_INDEX
-	PTE_SRL	k1, k1, 6
-	P_MTC0	zero, CP0_ENTRYLO1
-	P_MTC0	k1, CP0_ENTRYLO1
-	bltzl	k0, 1f
-	tlbwr
-1:
-	nop
-	eret
-	END(except_vec0_r4k_MP250MHZhwbug)
-#endif
-
-	__FINIT
 
 	.set	noreorder
 
@@ -460,6 +195,7 @@
 	PTE_RELOAD(k1, k0)
 	mtc0_tlbw_hazard
 	tlbwi
+	nop
 	tlbw_eret_hazard
 	.set	mips3
 	eret
@@ -484,6 +220,7 @@
 	PTE_RELOAD(k1, k0)
 	mtc0_tlbw_hazard
 	tlbwi
+	nop
 	tlbw_eret_hazard
 	.set	mips3
 	eret
@@ -513,6 +250,7 @@
 	PTE_RELOAD(k1, k0)
 	mtc0_tlbw_hazard
 	tlbwi
+	nop
 	tlbw_eret_hazard
 	.set	mips3
 	eret
diff -Nru a/arch/mips/mm/tlbex64-r4k.S b/arch/mips/mm/tlbex64-r4k.S
--- a/arch/mips/mm/tlbex64-r4k.S	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,203 +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) 2000 Silicon Graphics, Inc.
- * Written by Ulf Carlsson (ulfc@engr.sgi.com)
- * Copyright (C) 2002  Maciej W. Rozycki
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/threads.h>
-
-#include <asm/asm.h>
-#include <asm/hazards.h>
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-#include <asm/stackframe.h>
-#include <asm/war.h>
-
-#define _VMALLOC_START	0xc000000000000000
-
-	/*
-	 * After this macro runs we have a pointer to the pte of the address
-	 * that caused the fault in PTR.
-	 */
-	.macro	LOAD_PTE2, ptr, tmp, kaddr
-#ifdef CONFIG_SMP
-	dmfc0	\ptr, CP0_CONTEXT
-	dmfc0	\tmp, CP0_BADVADDR
-	dsra	\ptr, 23			# get pgd_current[cpu]
-#else
-	dmfc0	\tmp, CP0_BADVADDR
-	dla	\ptr, pgd_current
-#endif
-	bltz	\tmp, \kaddr
-	 ld	\ptr, (\ptr)
-	dsrl	\tmp, (_PGDIR_SHIFT-3)		# get pgd offset in bytes
-	andi	\tmp, ((_PTRS_PER_PGD - 1)<<3)
-	daddu	\ptr, \tmp			# add in pgd offset
-	dmfc0	\tmp, CP0_BADVADDR
-	ld	\ptr, (\ptr)			# get pmd pointer
-	dsrl	\tmp, (_PMD_SHIFT-3)		# get pmd offset in bytes
-	andi	\tmp, ((_PTRS_PER_PMD - 1)<<3)
-	daddu	\ptr, \tmp			# add in pmd offset
-	dmfc0	\tmp, CP0_XCONTEXT
-	ld	\ptr, (\ptr)			# get pte pointer
-	andi	\tmp, 0xff0			# get pte offset
-	daddu	\ptr, \tmp
-	.endm
-
-
-	/*
-	 * Ditto for the kernel table.
-	 */
-	.macro	LOAD_KPTE2, ptr, tmp, not_vmalloc
-	/*
-	 * First, determine that the address is in/above vmalloc range.
-	 */
-	dmfc0	\tmp, CP0_BADVADDR
-	dli	\ptr, _VMALLOC_START
-
-	/*
-	 * Now find offset into kptbl.
-	 */
-	dsubu	\tmp, \tmp, \ptr
-	dla	\ptr, kptbl
-	dsrl	\tmp, (_PAGE_SHIFT+1)		# get vpn2
-	dsll	\tmp, 4				# byte offset of pte
-	daddu	\ptr, \ptr, \tmp
-
-	/*
-	 * Determine that fault address is within vmalloc range.
-	 */
-	dla	\tmp, ekptbl
-	slt	\tmp, \ptr, \tmp
-	beqz	\tmp, \not_vmalloc		# not vmalloc
-	 nop
-	.endm
-
-
-	/*
-	 * This places the even/odd pte pair in the page table at the pte
-	 * entry pointed to by PTE into ENTRYLO0 and ENTRYLO1.
-	 */
-	.macro	PTE_RELOAD, pte0, pte1
-	dsrl	\pte0, 6			# convert to entrylo0
-	dmtc0	\pte0, CP0_ENTRYLO0		# load it
-	dsrl	\pte1, 6			# convert to entrylo1
-	dmtc0	\pte1, CP0_ENTRYLO1		# load it
-	.endm
-
-
-	.text
-	.set	noreorder
-	.set	mips3
-
-	__INIT
-
-	/*
-	 * TLB refill handlers for the R4000 and SB1.
-	 * Attention:  We may only use 32 instructions / 128 bytes.
-	 */
-	.align  5
-LEAF(except_vec1_r4k)
-	.set    noat
-	dla     k0, handle_vec1_r4k
-	jr      k0
-	 nop
-END(except_vec1_r4k)
-
-LEAF(except_vec1_sb1)
-#if BCM1250_M3_WAR
-	dmfc0	k0, CP0_BADVADDR
-	dmfc0	k1, CP0_ENTRYHI
-	xor	k0, k1
-	dsrl	k0, k0, _PAGE_SHIFT+1
-	bnez	k0, 1f
-#endif
-	.set    noat
-	dla     k0, handle_vec1_r4k
-	jr      k0
-	 nop
-
-1:	eret
-	nop
-END(except_vec1_sb1)
-
-	__FINIT
-
-	.align  5
-LEAF(handle_vec1_r4k)
-	.set    noat
-	LOAD_PTE2 k1 k0 9f
-	ld	k0, 0(k1)			# get even pte
-	ld	k1, 8(k1)			# get odd pte
-	PTE_RELOAD k0 k1
-	mtc0_tlbw_hazard
-	tlbwr
-	tlbw_eret_hazard
-	eret
-
-9:						# handle the vmalloc range
-	LOAD_KPTE2 k1 k0 invalid_vmalloc_address
-	ld	k0, 0(k1)			# get even pte
-	ld	k1, 8(k1)			# get odd pte
-	PTE_RELOAD k0 k1
-	mtc0_tlbw_hazard
-	 tlbwr
-	tlbw_eret_hazard
-	eret
-END(handle_vec1_r4k)
-
-
-	__INIT
-
-	/*
-	 * TLB refill handler for the R10000.
-	 * Attention:  We may only use 32 instructions / 128 bytes.
-	 */
-	.align	5
-LEAF(except_vec1_r10k)
-	.set    noat
-	dla     k0, handle_vec1_r10k
-	jr      k0
-	 nop
-END(except_vec1_r10k)
-
-	__FINIT
-
-	.align	5
-LEAF(handle_vec1_r10k)
-	.set	noat
-	LOAD_PTE2 k1 k0 9f
-	ld	k0, 0(k1)			# get even pte
-	ld	k1, 8(k1)			# get odd pte
-	PTE_RELOAD k0 k1
-	nop
-	tlbwr
-	eret
-
-9:						# handle the vmalloc range
-	LOAD_KPTE2 k1 k0 invalid_vmalloc_address
-	ld	k0, 0(k1)			# get even pte
-	ld	k1, 8(k1)			# get odd pte
-	PTE_RELOAD k0 k1
-	nop
-	tlbwr
-	eret
-END(handle_vec1_r10k)
-
-
-	.align	5
-LEAF(invalid_vmalloc_address)
-	.set	noat
-	SAVE_ALL
-	CLI
-	dmfc0	t0, CP0_BADVADDR
-	sd	t0, PT_BVADDR(sp)
-	move	a0, sp
-	jal	show_regs
-	PANIC("Invalid kernel address")
-END(invalid_vmalloc_address)
diff -Nru a/arch/mips/momentum/jaguar_atx/irq.c b/arch/mips/momentum/jaguar_atx/irq.c
--- a/arch/mips/momentum/jaguar_atx/irq.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/momentum/jaguar_atx/irq.c	2004-12-24 13:37:00 -08:00
@@ -45,7 +45,7 @@
 	no_action, SA_INTERRUPT, CPU_MASK_NONE, "MV64340-Cascade", NULL, NULL
 };
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	/*
 	 * Clear all of the interrupts while we change the able around a bit.
@@ -55,7 +55,6 @@
 
 	/* Sets the first-level interrupt dispatcher. */
 	set_except_vector(0, jaguar_handle_int);
-	init_generic_irq();
 	mips_cpu_irq_init(0);
 	rm7k_cpu_irq_init(8);
 
diff -Nru a/arch/mips/momentum/jaguar_atx/setup.c b/arch/mips/momentum/jaguar_atx/setup.c
--- a/arch/mips/momentum/jaguar_atx/setup.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/momentum/jaguar_atx/setup.c	2004-12-24 13:37:29 -08:00
@@ -2,7 +2,7 @@
  * BRIEF MODULE DESCRIPTION
  * Momentum Computer Jaguar-ATX board dependent boot routines
  *
- * Copyright (C) 1996, 1997, 2001  Ralf Baechle
+ * Copyright (C) 1996, 1997, 2001, 2004  Ralf Baechle (ralf@linux-mips.org)
  * Copyright (C) 2000 RidgeRun, Inc.
  * Copyright (C) 2001 Red Hat, Inc.
  * Copyright (C) 2002 Momentum Computer
@@ -59,7 +59,6 @@
 #include <asm/page.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/pci_channel.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
 #include <asm/reboot.h>
diff -Nru a/arch/mips/momentum/ocelot_3/Makefile b/arch/mips/momentum/ocelot_3/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/momentum/ocelot_3/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,8 @@
+#
+# Makefile for Momentum Computer's Ocelot-3 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).
+#
+obj-y	 += int-handler.o irq.o prom.o reset.o setup.o
diff -Nru a/arch/mips/momentum/ocelot_3/int-handler.S b/arch/mips/momentum/ocelot_3/int-handler.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/momentum/ocelot_3/int-handler.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2002 Momentum Computer Inc.
+ * Author: Matthew Dharm <mdharm@momenco.com>
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * Copyright 2004 PMC-Sierra
+ * Author: Manish Lachwani (lachwani@pmc-sierra.com)
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani, mlachwani@mvista.com
+ *
+ * First-level interrupt dispatcher for Ocelot-3 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 <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-3 board
+ */
+		.align	5
+		NESTED(ocelot3_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_IP0	/* sw0 software interrupt (IRQ0) */
+		bnez	t1, ll_sw0_irq
+
+		andi	t1, t0, STATUSF_IP1	/* sw1 software interrupt (IRQ1) */
+		bnez	t1, ll_sw1_irq
+
+		andi	t1, t0, STATUSF_IP2	/* int0 hardware line (IRQ2) */
+		bnez	t1, ll_pci0slot1_irq
+
+		andi	t1, t0, STATUSF_IP3	/* int1 hardware line (IRQ3) */
+		bnez	t1, ll_pci0slot2_irq
+
+		andi	t1, t0, STATUSF_IP4	/* int2 hardware line (IRQ4) */
+		bnez	t1, ll_pci1slot1_irq
+
+		andi	t1, t0, STATUSF_IP5	/* int3 hardware line (IRQ5) */
+		bnez	t1, ll_pci1slot2_irq
+
+		andi	t1, t0, STATUSF_IP6	/* int4 hardware line (IRQ6) */
+		bnez	t1, ll_uart_irq
+
+		andi	t1, t0, STATUSF_IP7	/* cpu timer (IRQ7) */
+		bnez	t1, ll_cputimer_irq
+
+                /* now look at 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 (IRQ9) */
+                bnez    t1, ll_mv64340_decode_irq
+
+		.set	reorder
+
+		/* wrong alarm or masked ... */
+		j	spurious_interrupt
+		nop
+		END(ocelot3_handle_int)
+
+		.align	5
+ll_sw0_irq:
+		li	a0, 0		/* IRQ 1 */
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+ll_sw1_irq:
+		li	a0, 1		/* IRQ 2 */
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_pci0slot1_irq:
+		li	a0, 2		/* IRQ 3 */
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_pci0slot2_irq:
+		li	a0, 3		/* IRQ 4 */
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_pci1slot1_irq:
+		li	a0, 4		/* IRQ 5 */
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_pci1slot2_irq:
+		li	a0, 5		/* IRQ 6 */
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_uart_irq:
+		li	a0, 6		/* IRQ 7 */
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_cputimer_irq:
+		li	a0, 7		/* IRQ 8 */
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_mv64340_decode_irq:
+		move	a0, sp
+		jal	ll_mv64340_irq
+		j	ret_from_irq
+
diff -Nru a/arch/mips/momentum/ocelot_3/irq.c b/arch/mips/momentum/ocelot_3/irq.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/momentum/ocelot_3/irq.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,81 @@
+/*
+ * 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)
+ *
+ * Copyright 2004 PMC-Sierra
+ * Author: Manish Lachwani (lachwani@pmc-sierra.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.
+ *
+ *  Copyright (C) 2004 MontaVista Software Inc.
+ *  Author: Manish Lachwani, mlachwani@mvista.com
+ *
+ */
+#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 <asm/bitops.h>
+#include <asm/bootinfo.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mipsregs.h>
+#include <asm/system.h>
+
+extern asmlinkage void ocelot3_handle_int(void);
+
+static struct irqaction cascade_mv64340 = {
+	no_action, SA_INTERRUPT, CPU_MASK_NONE, "MV64340-Cascade", NULL, NULL
+};
+
+void __init arch_init_irq(void)
+{
+	/*
+	 * Clear all of the interrupts while we change the able around a bit.
+	 * int-handler is not on bootstrap
+	 */
+	clear_c0_status(ST0_IM | ST0_BEV);
+
+	/* Sets the first-level interrupt dispatcher. */
+	set_except_vector(0, ocelot3_handle_int);
+	mips_cpu_irq_init(0);
+	rm7k_cpu_irq_init(8);
+
+	/* set up the cascading interrupts */
+	setup_irq(8, &cascade_mv64340);		/* unmask intControl IM8, IRQ 9 */
+	mv64340_irq_init(16);
+
+	set_c0_status(ST0_IM); /* IE in the status register */
+
+}
diff -Nru a/arch/mips/momentum/ocelot_3/ocelot_3_fpga.h b/arch/mips/momentum/ocelot_3/ocelot_3_fpga.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/momentum/ocelot_3/ocelot_3_fpga.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,57 @@
+/*
+ * Ocelot-3 Board Register Definitions
+ *
+ * (C) 2002 Momentum Computer 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.
+ *
+ *  Louis Hamilton, Red Hat, Inc.
+ *    hamilton@redhat.com  [MIPS64 modifications]
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani, mlachwani@mvista.com
+ */
+
+#ifndef __OCELOT_3_FPGA_H__
+#define __OCELOT_3_FPGA_H__
+
+#define OCELOT_3_REG_BOARDREV		0x0
+#define OCELOT_3_REG_FPGA_REV		0x1
+#define OCELOT_3_REG_FPGA_TYPE		0x2
+#define OCELOT_3_REG_RESET_STATUS	0x3
+#define OCELOT_3_REG_BOARD_STATUS	0x4
+#define OCELOT_3_REG_CPCI_ID		0x5
+#define OCELOT_3_REG_SET		0x6
+#define OCELOT_3_REG_CLR		0x7
+#define OCELOT_3_REG_EEPROM_MODE	0x9
+#define OCELOT_3_REG_INTMASK		0xa
+#define OCELOT_3_REG_INTSTAT		0xb
+#define OCELOT_3_REG_UART_INTMASK	0xc
+#define OCELOT_3_REG_UART_INTSTAT	0xd
+#define OCELOT_3_REG_INTSET		0xe
+#define OCELOT_3_REG_INTCLR		0xf
+
+extern unsigned long ocelot_fpga_base;
+
+#define OCELOT_FPGA_WRITE(x, y) writeb(x, ocelot_fpga_base + OCELOT_3_REG_##y)
+#define OCELOT_FPGA_READ(x) readb(ocelot_fpga_base + OCELOT_3_REG_##x)
+
+#endif
diff -Nru a/arch/mips/momentum/ocelot_3/prom.c b/arch/mips/momentum/ocelot_3/prom.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/momentum/ocelot_3/prom.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2002 Momentum Computer Inc.
+ * Author: Matthew Dharm <mdharm@momenco.com>
+ *
+ * Louis Hamilton, Red Hat, Inc.
+ *   hamilton@redhat.com  [MIPS64 modifications]
+ *
+ * Copyright 2004 PMC-Sierra
+ * Author: Manish Lachwani (lachwani@pmc-sierra.com)
+ *
+ * Based on Ocelot Linux port, which is
+ * 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.
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani, mlachwani@mvista.com
+ *
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/bootmem.h>
+#include <linux/mv643xx.h>
+
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <asm/pmon.h>
+#include "ocelot_3_fpga.h"
+
+struct callvectors* debug_vectors;
+extern unsigned long marvell_base;
+extern unsigned long cpu_clock;
+
+#ifdef CONFIG_MV643XX_ETH
+extern unsigned char prom_mac_addr_base[6];
+#endif
+
+const char *get_system_type(void)
+{
+	return "Momentum Ocelot-3";
+}
+
+#ifdef CONFIG_MV643XX_ETH
+void burn_clocks(void)
+{
+	int i;
+
+	/* this loop should burn at least 1us -- this should be plenty */
+	for (i = 0; i < 0x10000; i++)
+		;
+}
+
+u8 exchange_bit(u8 val, u8 cs)
+{
+	/* place the data */
+	OCELOT_FPGA_WRITE((val << 2) | cs, EEPROM_MODE);
+	burn_clocks();
+
+	/* turn the clock on */
+	OCELOT_FPGA_WRITE((val << 2) | cs | 0x2, EEPROM_MODE);
+	burn_clocks();
+
+	/* turn the clock off and read-strobe */
+	OCELOT_FPGA_WRITE((val << 2) | cs | 0x10, EEPROM_MODE);
+
+	/* return the data */
+	return ((OCELOT_FPGA_READ(EEPROM_MODE) >> 3) & 0x1);
+}
+
+void get_mac(char dest[6])
+{
+	u8 read_opcode[12] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+	int i,j;
+
+	for (i = 0; i < 12; i++)
+		exchange_bit(read_opcode[i], 1);
+
+	for (j = 0; j < 6; j++) {
+		dest[j] = 0;
+		for (i = 0; i < 8; i++) {
+			dest[j] <<= 1;
+			dest[j] |= exchange_bit(0, 1);
+		}
+	}
+
+	/* turn off CS */
+	exchange_bit(0,0);
+}
+#endif
+
+
+#ifdef CONFIG_MIPS64
+
+unsigned long signext(unsigned long addr)
+{
+	addr &= 0xffffffff;
+	return (unsigned long)((int)addr);
+}
+
+void *get_arg(unsigned long args, int arc)
+{
+	unsigned long ul;
+	unsigned char *puc, uc;
+
+	args += (arc * 4);
+	ul = (unsigned long)signext(args);
+	puc = (unsigned char *)ul;
+	if (puc == 0)
+		return (void *)0;
+
+#ifdef CONFIG_CPU_LITTLE_ENDIAN
+	uc = *puc++;
+	ul = (unsigned long)uc;
+	uc = *puc++;
+	ul |= (((unsigned long)uc) << 8);
+	uc = *puc++;
+	ul |= (((unsigned long)uc) << 16);
+	uc = *puc++;
+	ul |= (((unsigned long)uc) << 24);
+#else  /* CONFIG_CPU_LITTLE_ENDIAN */
+	uc = *puc++;
+	ul = ((unsigned long)uc) << 24;
+	uc = *puc++;
+	ul |= (((unsigned long)uc) << 16);
+	uc = *puc++;
+	ul |= (((unsigned long)uc) << 8);
+	uc = *puc++;
+	ul |= ((unsigned long)uc);
+#endif  /* CONFIG_CPU_LITTLE_ENDIAN */
+	ul = signext(ul);
+	return (void *)ul;
+}
+
+char *arg64(unsigned long addrin, int arg_index)
+{
+	unsigned long args;
+	char *p;
+
+	args = signext(addrin);
+	p = (char *)get_arg(args, arg_index);
+
+	return p;
+}
+#endif  /* CONFIG_MIPS64 */
+
+void __init prom_init(void)
+{
+	int argc = fw_arg0;
+	char **arg = (char **) fw_arg1;
+	char **env = (char **) fw_arg2;
+	struct callvectors *cv = (struct callvectors *) fw_arg3;
+	int i;
+
+#ifdef CONFIG_MIPS64
+	char *ptr;
+	printk("prom_init - MIPS64\n");
+
+	/* save the PROM vectors for debugging use */
+	debug_vectors = (struct callvectors *)signext((unsigned long)cv);
+
+	/* arg[0] is "g", the rest is boot parameters */
+	arcs_cmdline[0] = '\0';
+
+	for (i = 1; i < argc; i++) {
+		ptr = (char *)arg64((unsigned long)arg, i);
+		if ((strlen(arcs_cmdline) + strlen(ptr) + 1) >=
+		    sizeof(arcs_cmdline))
+			break;
+		strcat(arcs_cmdline, ptr);
+		strcat(arcs_cmdline, " ");
+	}
+	i = 0;
+
+	while (1) {
+		ptr = (char *)arg64((unsigned long)env, i);
+		if (! ptr)
+			break;
+
+		if (strncmp("gtbase", ptr, strlen("gtbase")) == 0) {
+			marvell_base = simple_strtol(ptr + strlen("gtbase="),
+							NULL, 16);
+
+			if ((marvell_base & 0xffffffff00000000) == 0)
+				marvell_base |= 0xffffffff00000000;
+
+			printk("marvell_base set to 0x%016lx\n", marvell_base);
+		}
+		if (strncmp("cpuclock", ptr, strlen("cpuclock")) == 0) {
+			cpu_clock = simple_strtol(ptr + strlen("cpuclock="),
+							NULL, 10);
+			printk("cpu_clock set to %d\n", cpu_clock);
+		}
+		i++;
+	}
+	printk("arcs_cmdline: %s\n", arcs_cmdline);
+
+#else   /* CONFIG_MIPS64 */
+
+	/* save the PROM vectors for debugging use */
+	debug_vectors = cv;
+
+	/* 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, " ");
+	}
+
+	while (*env) {
+		if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
+			marvell_base = simple_strtol(*env + strlen("gtbase="),
+							NULL, 16);
+		}
+		if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) {
+			cpu_clock = simple_strtol(*env + strlen("cpuclock="),
+							NULL, 10);
+		}
+		env++;
+	}
+#endif /* CONFIG_MIPS64 */
+
+	mips_machgroup = MACH_GROUP_MOMENCO;
+	mips_machtype = MACH_MOMENCO_OCELOT_3;
+
+#ifdef CONFIG_MV643XX_ETH
+	/* get the base MAC address for on-board ethernet ports */
+	get_mac(prom_mac_addr_base);
+#endif
+
+#ifndef CONFIG_MIPS64
+	debug_vectors->printf("Booting Linux kernel...\n");
+#endif
+}
+
+void __init prom_free_prom_memory(void)
+{
+}
+
+void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
+{
+}
diff -Nru a/arch/mips/momentum/ocelot_3/reset.c b/arch/mips/momentum/ocelot_3/reset.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/momentum/ocelot_3/reset.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,60 @@
+/*
+ * 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
+ *
+ * Copyright (C) 2002 Momentum Computer Inc.
+ * Author: Matthew Dharm <mdharm@momenco.com>
+ *
+ * Louis Hamilton, Red Hat, Inc.
+ * hamilton@redhat.com  [MIPS64 modifications]
+ *
+ * Copyright 2004 PMC-Sierra
+ * Author: Manish Lachwani (lachwani@pmc-sierra.com)
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani, mlachwani@mvista.com
+ */
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/delay.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)
+{
+	/* base address of timekeeper portion of part */
+	void *nvram = (void *) 0xfc807000L;
+
+ 	/* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */
+	writeb(0x84, nvram + 0xff7);
+
+	/* wait for the watchdog to go off */
+	mdelay(100+(1000/16));
+
+	/* if the watchdog fails for some reason, let people know */
+	printk(KERN_NOTICE "Watchdog reset failed\n");
+}
+
+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 -Nru a/arch/mips/momentum/ocelot_3/setup.c b/arch/mips/momentum/ocelot_3/setup.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/momentum/ocelot_3/setup.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,399 @@
+/*
+ * setup.c
+ *
+ * BRIEF MODULE DESCRIPTION
+ * Momentum Computer Ocelot-3 board dependent boot routines
+ *
+ * Copyright (C) 1996, 1997, 2001  Ralf Baechle
+ * Copyright (C) 2000 RidgeRun, Inc.
+ * Copyright (C) 2001 Red Hat, Inc.
+ * Copyright (C) 2002 Momentum Computer
+ *
+ * Author: Matthew Dharm, Momentum Computer
+ *   mdharm@momenco.com
+ *
+ * Louis Hamilton, Red Hat, Inc.
+ *   hamilton@redhat.com  [MIPS64 modifications]
+ *
+ * Author: RidgeRun, Inc.
+ *   glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * Copyright 2004 PMC-Sierra
+ * Author: Manish Lachwani (lachwani@pmc-sierra.com)
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani, mlachwani@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/kernel.h>
+#include <linux/types.h>
+#include <linux/mc146818rtc.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/timex.h>
+#include <linux/bootmem.h>
+#include <linux/mv643xx.h>
+#include <asm/time.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 <asm/tlbflush.h>
+#include "ocelot_3_fpga.h"
+
+/* Marvell Discovery Register Base */
+unsigned long marvell_base = (signed)0xf4000000;
+
+/* CPU clock */
+unsigned long cpu_clock;
+
+/* RTC/NVRAM */
+unsigned char* rtc_base = (unsigned char*)(signed)0xfc800000;
+
+/* FPGA Base */
+unsigned long ocelot_fpga_base = (signed)0xfc000000;
+
+/* Serial base */
+unsigned long uart_base = (signed)0xfd000000;
+
+/*
+ * Marvell Discovery SRAM. This is one place where Ethernet
+ * Tx and Rx descriptors can be placed to improve performance
+ */
+extern unsigned long mv64340_sram_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);
+
+void momenco_time_init(void);
+static char reset_reason;
+
+void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
+		     unsigned long entryhi, unsigned long pagemask);
+
+static inline unsigned long ENTRYLO(unsigned long paddr)
+{
+	return ((paddr & PAGE_MASK) |
+		(_PAGE_PRESENT | __READABLE | __WRITEABLE | _PAGE_GLOBAL |
+		_CACHE_UNCACHED)) >> 6;
+}
+
+void __init bus_error_init(void)
+{
+	/* nothing */
+}
+
+/*
+ * setup code for a handoff from a version 2 PMON 2000 PROM
+ */
+void setup_wired_tlb_entries(void)
+{
+	write_c0_wired(0);
+	local_flush_tlb_all();
+
+	/* marvell and extra space */
+	add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xf4010000), (signed)0xf4000000, PM_64K);
+
+	/* fpga, rtc, and uart */
+	add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), (signed)0xfc000000, PM_16M);
+}
+
+#define CONV_BCD_TO_BIN(val)	(((val) & 0xf) + (((val) >> 4) * 10))
+#define CONV_BIN_TO_BCD(val)	(((val) % 10) + (((val) / 10) << 4))
+
+unsigned long m48t37y_get_time(void)
+{
+	unsigned int year, month, day, hour, min, sec;
+
+	/* stop the update */
+	rtc_base[0x7ff8] = 0x40;
+
+	year = CONV_BCD_TO_BIN(rtc_base[0x7fff]);
+	year += CONV_BCD_TO_BIN(rtc_base[0x7ff1]) * 100;
+
+	month = CONV_BCD_TO_BIN(rtc_base[0x7ffe]);
+
+	day = CONV_BCD_TO_BIN(rtc_base[0x7ffd]);
+
+	hour = CONV_BCD_TO_BIN(rtc_base[0x7ffb]);
+	min = CONV_BCD_TO_BIN(rtc_base[0x7ffa]);
+	sec = CONV_BCD_TO_BIN(rtc_base[0x7ff9]);
+
+	/* start the update */
+	rtc_base[0x7ff8] = 0x00;
+
+	return mktime(year, month, day, hour, min, sec);
+}
+
+int m48t37y_set_time(unsigned long sec)
+{
+	struct rtc_time tm;
+
+	/* convert to a more useful format -- note months count from 0 */
+	to_tm(sec, &tm);
+	tm.tm_mon += 1;
+
+	/* enable writing */
+	rtc_base[0x7ff8] = 0x80;
+
+	/* year */
+	rtc_base[0x7fff] = CONV_BIN_TO_BCD(tm.tm_year % 100);
+	rtc_base[0x7ff1] = CONV_BIN_TO_BCD(tm.tm_year / 100);
+
+	/* month */
+	rtc_base[0x7ffe] = CONV_BIN_TO_BCD(tm.tm_mon);
+
+	/* day */
+	rtc_base[0x7ffd] = CONV_BIN_TO_BCD(tm.tm_mday);
+
+	/* hour/min/sec */
+	rtc_base[0x7ffb] = CONV_BIN_TO_BCD(tm.tm_hour);
+	rtc_base[0x7ffa] = CONV_BIN_TO_BCD(tm.tm_min);
+	rtc_base[0x7ff9] = CONV_BIN_TO_BCD(tm.tm_sec);
+
+	/* day of week -- not really used, but let's keep it up-to-date */
+	rtc_base[0x7ffc] = CONV_BIN_TO_BCD(tm.tm_wday + 1);
+
+	/* disable writing */
+	rtc_base[0x7ff8] = 0x00;
+
+	return 0;
+}
+
+void momenco_timer_setup(struct irqaction *irq)
+{
+	setup_irq(7, irq);	/* Timer interrupt, unmask status IM7 */
+}
+
+void momenco_time_init(void)
+{
+	setup_wired_tlb_entries();
+
+	/*
+	 * Ocelot-3 board has been built with both
+	 * the Rm7900 and the Rm7065C
+	 */
+	mips_hpt_frequency = cpu_clock / 2;
+	board_timer_setup = momenco_timer_setup;
+
+	rtc_get_time = m48t37y_get_time;
+	rtc_set_time = m48t37y_set_time;
+}
+
+/*
+ * PCI Support for Ocelot-3
+ */
+
+/* Bus #0 IO and MEM space */
+#define	OCELOT_3_PCI_IO_0_START		0xe0000000
+#define	OCELOT_3_PCI_IO_0_SIZE		0x08000000
+#define	OCELOT_3_PCI_MEM_0_START	0xc0000000
+#define	OCELOT_3_PCI_MEM_0_SIZE		0x10000000
+
+/* Bus #1 IO and MEM space */
+#define	OCELOT_3_PCI_IO_1_START		0xe8000000
+#define	OCELOT_3_PCI_IO_1_SIZE		0x08000000
+#define	OCELOT_3_PCI_MEM_1_START	0xd0000000
+#define	OCELOT_3_PCI_MEM_1_SIZE		0x10000000
+
+static struct resource mv_pci_io_mem0_resource = {
+	.name	= "MV64340 PCI0 IO MEM",
+	.start	= OCELOT_3_PCI_IO_0_START,
+	.end	= OCELOT_3_PCI_IO_0_START + OCELOT_3_PCI_IO_0_SIZE - 1,
+	.flags  = IORESOURCE_IO,
+};
+
+static struct resource mv_pci_io_mem1_resource = {
+	.name	= "MV64340 PCI1 IO MEM",
+	.start	= OCELOT_3_PCI_IO_1_START,
+	.end	= OCELOT_3_PCI_IO_1_START + OCELOT_3_PCI_IO_1_SIZE - 1,
+	.flags	= IORESOURCE_IO,
+};
+
+static struct resource mv_pci_mem0_resource = {
+	.name	= "MV64340 PCI0 MEM",
+	.start	= OCELOT_3_PCI_MEM_0_START,
+	.end	= OCELOT_3_PCI_MEM_0_START + OCELOT_3_PCI_MEM_0_SIZE - 1,
+	.flags	= IORESOURCE_MEM,
+};
+
+static struct resource mv_pci_mem1_resource = {
+	.name	= "MV64340 PCI1 MEM",
+	.start	= OCELOT_3_PCI_MEM_1_START,
+	.end	= OCELOT_3_PCI_MEM_1_START + OCELOT_3_PCI_MEM_1_SIZE - 1,
+	.flags	= IORESOURCE_MEM,
+};
+
+static struct mv_pci_controller mv_bus0_controller = {
+	.pcic = {
+		 .pci_ops	= &mv_pci_ops,
+		 .mem_resource	= &mv_pci_mem0_resource,
+		 .io_resource	= &mv_pci_io_mem0_resource,
+	},
+	.config_addr	= MV64340_PCI_0_CONFIG_ADDR,
+	.config_vreg	= MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG,
+};
+
+static struct mv_pci_controller mv_bus1_controller = {
+	.pcic = {
+		 .pci_ops	= &mv_pci_ops,
+		 .mem_resource	= &mv_pci_mem1_resource,
+		 .io_resource	= &mv_pci_io_mem1_resource,
+	},
+	.config_addr	= MV64340_PCI_1_CONFIG_ADDR,
+	.config_vreg	= MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG,
+};
+
+static __init int __init ja_pci_init(void)
+{
+	uint32_t enable;
+	extern int pci_probe_only;
+
+	/* PMON will assign PCI resources */
+	pci_probe_only = 1;
+
+	enable = ~MV_READ(MV64340_BASE_ADDR_ENABLE);
+	/*
+	 * We require at least one enabled I/O or PCI memory window or we
+	 * will ignore this PCI bus.  We ignore PCI windows 1, 2 and 3.
+	 */
+	if (enable & (0x01 <<  9) || enable & (0x01 << 10))
+		register_pci_controller(&mv_bus0_controller.pcic);
+
+	if (enable & (0x01 << 14) || enable & (0x01 << 15))
+		register_pci_controller(&mv_bus1_controller.pcic);
+
+	ioport_resource.end = OCELOT_3_PCI_IO_0_START + OCELOT_3_PCI_IO_0_SIZE +
+					OCELOT_3_PCI_IO_1_SIZE - 1;
+
+	iomem_resource.end = OCELOT_3_PCI_MEM_0_START + OCELOT_3_PCI_MEM_0_SIZE +
+					OCELOT_3_PCI_MEM_1_SIZE - 1;
+
+	set_io_port_base(OCELOT_3_PCI_IO_0_START); /* mips_io_port_base */
+
+	return 0;
+}
+
+arch_initcall(ja_pci_init);
+
+static int __init momenco_ocelot_3_setup(void)
+{
+	unsigned int tmpword;
+
+	board_time_init = momenco_time_init;
+
+	_machine_restart = momenco_ocelot_restart;
+	_machine_halt = momenco_ocelot_halt;
+	_machine_power_off = momenco_ocelot_power_off;
+
+	/* Wired TLB entries */
+	setup_wired_tlb_entries();
+
+	/* shut down ethernet ports, just to be sure our memory doesn't get
+	 * corrupted by random ethernet traffic.
+	 */
+	MV_WRITE(MV64340_ETH_TRANSMIT_QUEUE_COMMAND_REG(0), 0xff << 8);
+	MV_WRITE(MV64340_ETH_TRANSMIT_QUEUE_COMMAND_REG(1), 0xff << 8);
+	MV_WRITE(MV64340_ETH_RECEIVE_QUEUE_COMMAND_REG(0), 0xff << 8);
+	MV_WRITE(MV64340_ETH_RECEIVE_QUEUE_COMMAND_REG(1), 0xff << 8);
+	do {}
+	  while (MV_READ(MV64340_ETH_RECEIVE_QUEUE_COMMAND_REG(0)) & 0xff);
+	do {}
+	  while (MV_READ(MV64340_ETH_RECEIVE_QUEUE_COMMAND_REG(1)) & 0xff);
+	do {}
+	  while (MV_READ(MV64340_ETH_TRANSMIT_QUEUE_COMMAND_REG(0)) & 0xff);
+	do {}
+	  while (MV_READ(MV64340_ETH_TRANSMIT_QUEUE_COMMAND_REG(1)) & 0xff);
+	MV_WRITE(MV64340_ETH_PORT_SERIAL_CONTROL_REG(0),
+		 MV_READ(MV64340_ETH_PORT_SERIAL_CONTROL_REG(0)) & ~1);
+	MV_WRITE(MV64340_ETH_PORT_SERIAL_CONTROL_REG(1),
+		 MV_READ(MV64340_ETH_PORT_SERIAL_CONTROL_REG(1)) & ~1);
+
+	/* Turn off the Bit-Error LED */
+	OCELOT_FPGA_WRITE(0x80, CLR);
+
+	tmpword = OCELOT_FPGA_READ(BOARDREV);
+	if (tmpword < 26)
+		printk("Momenco Ocelot-3: Board Assembly Rev. %c\n",
+			'A'+tmpword);
+	else
+		printk("Momenco Ocelot-3: Board Assembly Revision #0x%x\n",
+			tmpword);
+
+	tmpword = OCELOT_FPGA_READ(FPGA_REV);
+	printk("FPGA Rev: %d.%d\n", tmpword>>4, tmpword&15);
+	tmpword = OCELOT_FPGA_READ(RESET_STATUS);
+	printk("Reset reason: 0x%x\n", tmpword);
+	switch (tmpword) {
+		case 0x1:
+			printk("  - Power-up reset\n");
+			break;
+		case 0x2:
+			printk("  - Push-button reset\n");
+			break;
+		case 0x4:
+			printk("  - cPCI bus reset\n");
+			break;
+		case 0x8:
+			printk("  - Watchdog reset\n");
+			break;
+		case 0x10:
+			printk("  - Software reset\n");
+			break;
+		default:
+			printk("  - Unknown reset cause\n");
+	}
+	reset_reason = tmpword;
+	OCELOT_FPGA_WRITE(0xff, RESET_STATUS);
+
+	tmpword = OCELOT_FPGA_READ(CPCI_ID);
+	printk("cPCI ID register: 0x%02x\n", tmpword);
+	printk("  - Slot number: %d\n", tmpword & 0x1f);
+	printk("  - PCI bus present: %s\n", tmpword & 0x40 ? "yes" : "no");
+	printk("  - System Slot: %s\n", tmpword & 0x20 ? "yes" : "no");
+
+	tmpword = OCELOT_FPGA_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("  - L3 cache size: %d MB\n", (1<<((tmpword&12) >> 2))&~1);
+
+	/* Support for 128 MB memory */
+	add_memory_region(0x0, 0x08000000, BOOT_MEM_RAM);
+
+	return 0;
+}
+
+early_initcall(momenco_ocelot_3_setup);
diff -Nru a/arch/mips/momentum/ocelot_c/dbg_io.c b/arch/mips/momentum/ocelot_c/dbg_io.c
--- a/arch/mips/momentum/ocelot_c/dbg_io.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/momentum/ocelot_c/dbg_io.c	2004-12-24 13:37:18 -08:00
@@ -1,6 +1,6 @@
 #include <linux/config.h>
 
-#if defined(CONFIG_KGDB)
+#ifdef CONFIG_KGDB
 
 #include <asm/serial.h> /* For the serial port location and base baud */
 
diff -Nru a/arch/mips/momentum/ocelot_c/irq.c b/arch/mips/momentum/ocelot_c/irq.c
--- a/arch/mips/momentum/ocelot_c/irq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/momentum/ocelot_c/irq.c	2004-12-24 13:37:18 -08:00
@@ -41,7 +41,7 @@
 #include <linux/timex.h>
 #include <linux/slab.h>
 #include <linux/random.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/irq_cpu.h>
@@ -61,7 +61,7 @@
 	no_action, SA_INTERRUPT, CPU_MASK_NONE, "cascade via MV64340", NULL, NULL
 };
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	/*
 	 * Clear all of the interrupts while we change the able around a bit.
@@ -71,7 +71,6 @@
 
 	/* Sets the first-level interrupt dispatcher. */
 	set_except_vector(0, ocelot_handle_int);
-	init_generic_irq();
 	mips_cpu_irq_init(0);
 
 	/* set up the cascading interrupts */
@@ -82,10 +81,4 @@
 	mv64340_irq_init(16);
 	uart_irq_init();
 	cpci_irq_init();
-
-#ifdef CONFIG_KGDB
-	printk("start kgdb ...\n");
-	set_debug_traps();
-	breakpoint();	/* you may move this line to whereever you want :-) */
-#endif
 }
diff -Nru a/arch/mips/momentum/ocelot_g/dbg_io.c b/arch/mips/momentum/ocelot_g/dbg_io.c
--- a/arch/mips/momentum/ocelot_g/dbg_io.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/momentum/ocelot_g/dbg_io.c	2004-12-24 13:36:31 -08:00
@@ -1,6 +1,6 @@
 #include <linux/config.h>
 
-#if defined(CONFIG_KGDB)
+#ifdef CONFIG_KGDB
 
 #include <asm/serial.h> /* For the serial port location and base baud */
 
diff -Nru a/arch/mips/momentum/ocelot_g/gt-irq.c b/arch/mips/momentum/ocelot_g/gt-irq.c
--- a/arch/mips/momentum/ocelot_g/gt-irq.c	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/momentum/ocelot_g/gt-irq.c	2004-12-24 13:37:43 -08:00
@@ -134,6 +134,9 @@
 
 		/* handle the timer call */
 		do_timer(regs);
+#ifndef CONFIG_SMP
+		update_process_times(user_mode(regs));
+#endif
 	}
 
 	if (irq_src) {
@@ -156,7 +159,6 @@
  */
 void gt64240_time_init(void)
 {
-	extern irq_desc_t irq_desc[NR_IRQS];
 	static struct irqaction timer;
 
 	/* Stop the timer -- we'll use timer #0 */
diff -Nru a/arch/mips/momentum/ocelot_g/irq.c b/arch/mips/momentum/ocelot_g/irq.c
--- a/arch/mips/momentum/ocelot_g/irq.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/momentum/ocelot_g/irq.c	2004-12-24 13:36:31 -08:00
@@ -41,7 +41,7 @@
 #include <linux/timex.h>
 #include <linux/slab.h>
 #include <linux/random.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -52,7 +52,7 @@
 extern asmlinkage void ocelot_handle_int(void);
 extern void gt64240_irq_init(void);
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	/*
 	 * Clear all of the interrupts while we change the able around a bit.
@@ -63,15 +63,8 @@
 
 	/* Sets the first-level interrupt dispatcher. */
 	set_except_vector(0, ocelot_handle_int);
-	init_generic_irq();
 	mips_cpu_irq_init(0);
 	rm7k_cpu_irq_init(8);
 
 	gt64240_irq_init();
-
-#ifdef CONFIG_KGDB
-	printk("start kgdb ...\n");
-	set_debug_traps();
-	breakpoint();	/* you may move this line to whereever you want :-) */
-#endif
 }
diff -Nru a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
--- a/arch/mips/pci/Makefile	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/pci/Makefile	2004-12-24 13:36:17 -08:00
@@ -24,8 +24,7 @@
 obj-$(CONFIG_DDB5074)		+= fixup-ddb5074.o pci-ddb5074.o ops-ddb5074.o
 obj-$(CONFIG_DDB5476)		+= ops-ddb5476.o pci-ddb5476.o
 obj-$(CONFIG_DDB5477)		+= fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o
-obj-$(CONFIG_HP_LASERJET)	+= pci-hplj.o
-obj-$(CONFIG_LASAT)		+= pci-lasat.o fixup-lasat.o
+obj-$(CONFIG_LASAT)		+= pci-lasat.o
 obj-$(CONFIG_MIPS_ATLAS)	+= fixup-atlas.o
 obj-$(CONFIG_MIPS_COBALT)	+= fixup-cobalt.o
 obj-$(CONFIG_MIPS_EV96100)	+= fixup-ev64120.o
@@ -37,6 +36,7 @@
 obj-$(CONFIG_MIPS_MALTA)	+= fixup-malta.o
 obj-$(CONFIG_MOMENCO_JAGUAR_ATX)+= fixup-jaguar.o
 obj-$(CONFIG_MOMENCO_OCELOT)	+= fixup-ocelot.o pci-ocelot.o
+obj-$(CONFIG_MOMENCO_OCELOT_3)	+= fixup-ocelot3.o
 obj-$(CONFIG_MOMENCO_OCELOT_C)	+= fixup-ocelot-c.o pci-ocelot-c.o
 obj-$(CONFIG_MOMENCO_OCELOT_G)	+= fixup-ocelot-g.o pci-ocelot-g.o
 obj-$(CONFIG_PMC_YOSEMITE)	+= fixup-yosemite.o ops-titan.o ops-titan-ht.o \
diff -Nru a/arch/mips/pci/fixup-atlas.c b/arch/mips/pci/fixup-atlas.c
--- a/arch/mips/pci/fixup-atlas.c	2004-12-24 13:36:16 -08:00
+++ b/arch/mips/pci/fixup-atlas.c	2004-12-24 13:36:16 -08:00
@@ -40,11 +40,13 @@
 	return irq_tab[slot][pin];
 }
 
-void __init pcibios_fixup_irqs(void)
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
 {
+	return 0;
 }
 
-#if CONFIG_KGDB
+#ifdef CONFIG_KGDB
 /*
  * The PCI scan may have moved the saa9730 I/O address, so reread
  * the address here.
@@ -61,6 +63,6 @@
 }
 
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA9730,
-	atlas_saa9730_base_fixup);
+	 atlas_saa9730_base_fixup);
 
 #endif
diff -Nru a/arch/mips/pci/fixup-au1000.c b/arch/mips/pci/fixup-au1000.c
--- a/arch/mips/pci/fixup-au1000.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/pci/fixup-au1000.c	2004-12-24 13:36:18 -08:00
@@ -100,5 +100,11 @@
 
 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
-return irq_tab_alchemy[slot][pin];
+	return irq_tab_alchemy[slot][pin];
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
diff -Nru a/arch/mips/pci/fixup-capcella.c b/arch/mips/pci/fixup-capcella.c
--- a/arch/mips/pci/fixup-capcella.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/pci/fixup-capcella.c	2004-12-24 13:36:47 -08:00
@@ -42,3 +42,9 @@
 {
 	return irq_tab_capcella[slot][pin];
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-cobalt.c b/arch/mips/pci/fixup-cobalt.c
--- a/arch/mips/pci/fixup-cobalt.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/pci/fixup-cobalt.c	2004-12-24 13:36:48 -08:00
@@ -77,7 +77,7 @@
 }
 
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_GALILEO, PCI_ANY_ID,
-	qube_raq_galileo_fixup);
+	 qube_raq_galileo_fixup);
 
 static char irq_tab_cobalt[] __initdata = {
   [COBALT_PCICONF_CPU]     = 0,
@@ -103,4 +103,10 @@
 		return irq_tab_raq2[slot];
 
 	return irq_tab_cobalt[slot];
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
diff -Nru a/arch/mips/pci/fixup-ddb5074.c b/arch/mips/pci/fixup-ddb5074.c
--- a/arch/mips/pci/fixup-ddb5074.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/pci/fixup-ddb5074.c	2004-12-24 13:36:19 -08:00
@@ -18,4 +18,4 @@
 }
 
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,
-	ddb5074_fixup);
+	  ddb5074_fixup);
diff -Nru a/arch/mips/pci/fixup-ddb5477.c b/arch/mips/pci/fixup-ddb5477.c
--- a/arch/mips/pci/fixup-ddb5477.c	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/pci/fixup-ddb5477.c	2004-12-24 13:36:55 -08:00
@@ -75,4 +75,4 @@
 }
 
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE,
-          ddb5477_amd_lance_fixup);
+	  ddb5477_amd_lance_fixup);
diff -Nru a/arch/mips/pci/fixup-ev96100.c b/arch/mips/pci/fixup-ev96100.c
--- a/arch/mips/pci/fixup-ev96100.c	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/pci/fixup-ev96100.c	2004-12-24 13:36:55 -08:00
@@ -40,3 +40,9 @@
 {
 	return irq_tab_ev96100[slot][pin];
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-ip32.c b/arch/mips/pci/fixup-ip32.c
--- a/arch/mips/pci/fixup-ip32.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/pci/fixup-ip32.c	2004-12-24 13:37:19 -08:00
@@ -1,7 +1,6 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
-#include <asm/pci_channel.h>
 #include <asm/ip32/ip32_ints.h>
 /*
  * O2 has up to 5 PCI devices connected into the MACE bridge.  The device
@@ -43,4 +42,10 @@
 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
 	return irq_tab_mace[slot][pin];
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
diff -Nru a/arch/mips/pci/fixup-ite8172g.c b/arch/mips/pci/fixup-ite8172g.c
--- a/arch/mips/pci/fixup-ite8172g.c	2004-12-24 13:36:59 -08:00
+++ b/arch/mips/pci/fixup-ite8172g.c	2004-12-24 13:36:59 -08:00
@@ -72,3 +72,9 @@
 
 	return irq_tab_ite8172g[slot][pin];
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-ivr.c b/arch/mips/pci/fixup-ivr.c
--- a/arch/mips/pci/fixup-ivr.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/pci/fixup-ivr.c	2004-12-24 13:36:18 -08:00
@@ -67,3 +67,9 @@
 
 	return irq_tab_ivr[slot][pin];
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-jaguar.c b/arch/mips/pci/fixup-jaguar.c
--- a/arch/mips/pci/fixup-jaguar.c	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/pci/fixup-jaguar.c	2004-12-24 13:37:43 -08:00
@@ -8,14 +8,13 @@
  * Marvell wants an NDA for their docs so this was written without
  * documentation.  You've been warned.
  *
- * Copyright (C) 2004 Ralf Baechle
+ * Copyright (C) 2004 Ralf Baechle (ralf@linux-mips.org)
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/pci.h>
 
 #include <asm/mipsregs.h>
-#include <asm/pci_channel.h>
 
 /*
  * WARNING: Example of how _NOT_ to do it.
@@ -35,4 +34,10 @@
 
 return 0;
 	panic("Whooops in pcibios_map_irq");
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
diff -Nru a/arch/mips/pci/fixup-jmr3927.c b/arch/mips/pci/fixup-jmr3927.c
--- a/arch/mips/pci/fixup-jmr3927.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/pci/fixup-jmr3927.c	2004-12-24 13:37:29 -08:00
@@ -88,6 +88,12 @@
 	return irq;
 }
 
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
+
 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
 	/* SMSC SLC90E66 IDE uses irq 14, 15 (default) */
diff -Nru a/arch/mips/pci/fixup-lasat.c b/arch/mips/pci/fixup-lasat.c
--- a/arch/mips/pci/fixup-lasat.c	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,6 +0,0 @@
-#include <linux/init.h>
-#include <linux/pci.h>
-
-void __init pcibios_fixup_irqs(void)
-{
-}
diff -Nru a/arch/mips/pci/fixup-malta.c b/arch/mips/pci/fixup-malta.c
--- a/arch/mips/pci/fixup-malta.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/pci/fixup-malta.c	2004-12-24 13:36:18 -08:00
@@ -43,11 +43,12 @@
 	return pci_irq[virq];
 }
 
-void __init pcibios_fixup_irqs(void)
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
 {
+	return 0;
 }
 
-
 static void __init malta_piix_func0_fixup(struct pci_dev *pdev)
 {
 	unsigned char reg_val;
@@ -99,4 +100,4 @@
 }
 
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB,
-	malta_piix_func1_fixup);
+	 malta_piix_func1_fixup);
diff -Nru a/arch/mips/pci/fixup-mpc30x.c b/arch/mips/pci/fixup-mpc30x.c
--- a/arch/mips/pci/fixup-mpc30x.c	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/pci/fixup-mpc30x.c	2004-12-24 13:36:55 -08:00
@@ -42,3 +42,9 @@
 
 	return irq_tab_mpc30x[slot];
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-ocelot-c.c b/arch/mips/pci/fixup-ocelot-c.c
--- a/arch/mips/pci/fixup-ocelot-c.c	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/pci/fixup-ocelot-c.c	2004-12-24 13:37:43 -08:00
@@ -33,3 +33,9 @@
 return 0;
 	panic("Whooops in pcibios_map_irq");
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-ocelot-g.c b/arch/mips/pci/fixup-ocelot-g.c
--- a/arch/mips/pci/fixup-ocelot-g.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/pci/fixup-ocelot-g.c	2004-12-24 13:36:48 -08:00
@@ -29,3 +29,9 @@
 
 	return -1;
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-ocelot3.c b/arch/mips/pci/fixup-ocelot3.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/mips/pci/fixup-ocelot3.c	2004-12-24 13:37:44 -08:00
@@ -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) 2004 Montavista Software Inc.
+ * Author: Manish Lachwani (mlachwani@mvista.com)
+ *
+ * Looking at the schematics for the Ocelot-3 board, there are
+ * two PCI busses and each bus has two PCI slots.
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <asm/mipsregs.h>
+
+/*
+ * Do platform specific device initialization at
+ * pci_enable_device() time
+ */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
+
+int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+	int bus = dev->bus->number;
+
+	if (bus == 0 && slot == 1)
+		return 2;	/* PCI-X A */
+	if (bus == 0 && slot == 2)
+		return 3;	/* PCI-X B */
+	if (bus == 1 && slot == 1)
+		return 4;	/* PCI A */
+	if (bus == 1 && slot == 2)
+		return 5;	/* PCI B */
+
+return 0;
+	panic("Whooops in pcibios_map_irq");
+}
diff -Nru a/arch/mips/pci/fixup-rbtx4927.c b/arch/mips/pci/fixup-rbtx4927.c
--- a/arch/mips/pci/fixup-rbtx4927.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/pci/fixup-rbtx4927.c	2004-12-24 13:36:31 -08:00
@@ -9,6 +9,9 @@
  *
  * Copyright (C) 2000-2001 Toshiba Corporation 
  *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani (mlachwani@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
@@ -116,108 +119,22 @@
 	return irq;
 }
 
-
-#ifdef  TX4927_SUPPORT_PCI_66
-extern int tx4927_pci66;
-extern void tx4927_pci66_setup(void);
-#endif
-extern void tx4927_pci_setup(void);
-
-#ifdef  TX4927_SUPPORT_PCI_66
-int tx4927_pci66_check(void)
-{
-	struct pci_dev *dev;
-	unsigned short stat;
-	int cap66 = 1;
-
-	if (tx4927_pci66 < 0)
-		return 0;
-
-	/* check 66MHz capability */
-	pci_for_each_dev(dev) {
-		if (cap66) {
-			pci_read_config_word(dev, PCI_STATUS, &stat);
-			if (!(stat & PCI_STATUS_66MHZ)) {
-				printk(KERN_INFO
-				       "PCI: %02x:%02x not 66MHz capable.\n",
-				       dev->bus->number, dev->devfn);
-				cap66 = 0;
-			}
-		}
-	}
-	return cap66;
-}
-#endif
-
-void __init pcibios_fixup_irqs(void)
+int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
-	unsigned char pin;
 	unsigned char irq;
-	struct pci_dev *dev;
-	unsigned int id;
 
-#ifdef  TX4927_SUPPORT_PCI_66
-	if (tx4927_pci66_check()) {
-		tx4927_pci66_setup();
-		tx4927_pci_setup();	/* Reinitialize PCIC */
-	}
-#endif
+	printk("PCI Setup for pin %d \n", pin);
 
-	pci_for_each_dev(dev) {
-		DBG("FIXUP:\n");
-		DBG(" devfn=0x%02x (0x%02x:0x%02x)\n",
-		    dev->devfn, PCI_SLOT(dev->devfn),
-		    PCI_FUNC(dev->devfn));
-
-		pci_read_config_dword(dev, PCI_VENDOR_ID, &id);
-		DBG(" id=0x%08x\n", id);
-
-		pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
-		DBG(" line=0x%02x/%d\n", irq, irq);
-
-		pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
-		DBG(" pin=%d\n", pin);
-
-#ifdef DEBUG
-		{
-			unsigned int tmp;
-			pci_read_config_dword(dev, 0x10, &tmp);
-			DBG(" bar0:0x10=0x%08x\n", tmp);
-			pci_read_config_dword(dev, 0x14, &tmp);
-			DBG(" bar1:0x14=0x%08x\n", tmp);
-			pci_read_config_dword(dev, 0x1c, &tmp);
-			DBG(" bar2:0x1c=0x%08x\n", tmp);
-			pci_read_config_dword(dev, 0x20, &tmp);
-			DBG(" bar3:0x20=0x%08x\n", tmp);
-			pci_read_config_dword(dev, 0x24, &tmp);
-			DBG(" bar4:0x24=0x%08x\n", tmp);
-		}
-#endif
-
-		irq = 0;
+	if (dev->device == 0x9130) /* IDE */
+		irq = 14;
+	else
+		irq = pci_get_irq(dev, pin);
 
-		if (id == 0x91301055) {	/* ide */
-			irq = 14;
-		}
-
-		if (pin == 0) {
-			DBG(" auto irq (now=%d) -- skipping pin=0\n", irq);
-		} else if (irq) {
-			DBG(" auto irq (now=%d) -- skipping hardcoded irq\n", irq);
-		} else {
-			DBG(" auto irq (was=%d)\n", irq);
-			irq = pci_get_irq(dev, pin);
-			pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
-					      irq);
-			dev->irq = irq;
-			DBG(" auto irq (now=%d)\n", irq);
-		}
-
-		pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
-		printk(KERN_INFO
-		       "PCI: 0x%02x:0x%02x(0x%02x,0x%02x) IRQ=%d\n",
-		       dev->bus->number, dev->devfn, PCI_SLOT(dev->devfn),
-		       PCI_FUNC(dev->devfn), irq);
+	return irq;
+}
 
-	}
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
diff -Nru a/arch/mips/pci/fixup-sni.c b/arch/mips/pci/fixup-sni.c
--- a/arch/mips/pci/fixup-sni.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/pci/fixup-sni.c	2004-12-24 13:36:31 -08:00
@@ -5,14 +5,13 @@
  *
  * SNI specific PCI support for RM200/RM300.
  *
- * Copyright (C) 1997 - 2000, 2003 Ralf Baechle
+ * Copyright (C) 1997 - 2000, 2003, 04 Ralf Baechle (ralf@linux-mips.org)
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/pci.h>
 
 #include <asm/mipsregs.h>
-#include <asm/pci_channel.h>
 #include <asm/sni.h>
 
 /*
@@ -81,4 +80,10 @@
 		return irq_tab_rm300d[slot][pin];
 
 	return irq_tab_rm200[slot][pin];
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
diff -Nru a/arch/mips/pci/fixup-tb0219.c b/arch/mips/pci/fixup-tb0219.c
--- a/arch/mips/pci/fixup-tb0219.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/pci/fixup-tb0219.c	2004-12-24 13:37:19 -08:00
@@ -58,3 +58,9 @@
 
 	return irq;
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-tb0226.c b/arch/mips/pci/fixup-tb0226.c
--- a/arch/mips/pci/fixup-tb0226.c	2004-12-24 13:37:03 -08:00
+++ b/arch/mips/pci/fixup-tb0226.c	2004-12-24 13:37:03 -08:00
@@ -77,3 +77,9 @@
 
 	return irq;
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/fixup-yosemite.c b/arch/mips/pci/fixup-yosemite.c
--- a/arch/mips/pci/fixup-yosemite.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/pci/fixup-yosemite.c	2004-12-24 13:36:48 -08:00
@@ -33,3 +33,9 @@
 
 	return 3;			/* Everything goes to one irq bit */
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff -Nru a/arch/mips/pci/ops-au1000.c b/arch/mips/pci/ops-au1000.c
--- a/arch/mips/pci/ops-au1000.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/pci/ops-au1000.c	2004-12-24 13:37:29 -08:00
@@ -288,10 +288,18 @@
 		       int where, int size, u32 * val)
 {
 	switch (size) {
-	case 1:
-		return read_config_byte(bus, devfn, where, (u8 *) val);
-	case 2:
-		return read_config_word(bus, devfn, where, (u16 *) val);
+	case 1: {
+			u8 _val;
+			int rc = read_config_byte(bus, devfn, where, &_val);
+			*val = _val;
+			return rc;
+		}
+       case 2: {
+			u16 _val;
+			int rc = read_config_word(bus, devfn, where, &_val);
+			*val = _val;
+			return rc;
+		}
 	default:
 		return read_config_dword(bus, devfn, where, val);
 	}
diff -Nru a/arch/mips/pci/ops-it8172.c b/arch/mips/pci/ops-it8172.c
--- a/arch/mips/pci/ops-it8172.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/pci/ops-it8172.c	2004-12-24 13:37:18 -08:00
@@ -7,6 +7,8 @@
  * Author: MontaVista Software, Inc.
  *         	ppopov@mvista.com or source@mvista.com
  *
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.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
@@ -32,7 +34,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 
-#include <asm/pci_channel.h>
 #include <asm/it8172/it8172.h>
 #include <asm/it8172/it8172_pci.h>
 
diff -Nru a/arch/mips/pci/ops-titan.c b/arch/mips/pci/ops-titan.c
--- a/arch/mips/pci/ops-titan.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/pci/ops-titan.c	2004-12-24 13:36:31 -08:00
@@ -58,15 +58,15 @@
 
 	switch (size) {
 	case 1:
-		TITAN_READ_8(data_reg + (reg & 0x3), val);
+		*val = TITAN_READ_8(data_reg + (~reg & 0x3));
 		break;
 
 	case 2:
-		TITAN_READ_16(data_reg + (reg & 0x2), val);
+		*val = TITAN_READ_16(data_reg + (~reg & 0x2));
 		break;
 
 	case 4:
-		TITAN_READ(data_reg, val);
+		*val = TITAN_READ(data_reg);
 		break;
 	}
 
@@ -98,11 +98,11 @@
 	/* write the data */
 	switch (size) {
 	case 1:
-		TITAN_WRITE_8(data_reg + (reg & 0x3), val);
+		TITAN_WRITE_8(data_reg + (~reg & 0x3), val);
 		break;
 
 	case 2:
-		TITAN_WRITE_16(data_reg + (reg & 0x2), val);
+		TITAN_WRITE_16(data_reg + (~reg & 0x2), val);
 		break;
 
 	case 4:
@@ -120,16 +120,3 @@
 	titan_read_config,
 	titan_write_config,
 };
-
-void __init pcibios_init(void)
-{
-	/* 
-	 * XXX These values below need to change
-	 */
-	ioport_resource.start = 0xe0000000;
-	ioport_resource.end   = 0xe0000000 + 0x20000000 - 1;
-	iomem_resource.start  = 0xc0000000;
-	iomem_resource.end    = 0xc0000000 + 0x20000000 - 1;
-
-	pci_scan_bus(0, &titan_pci_ops, NULL);
-}
diff -Nru a/arch/mips/pci/ops-tx3927.c b/arch/mips/pci/ops-tx3927.c
--- a/arch/mips/pci/ops-tx3927.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/pci/ops-tx3927.c	2004-12-24 13:37:29 -08:00
@@ -4,6 +4,7 @@
  *              ahennessy@mvista.com
  *
  * Copyright (C) 2000-2001 Toshiba Corporation
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  *
  * Based on arch/mips/ddb5xxx/ddb5477/pci_ops.c
  *
@@ -38,7 +39,6 @@
 #include <linux/init.h>
 
 #include <asm/addrspace.h>
-#include <asm/pci_channel.h>
 #include <asm/jmr3927/jmr3927.h>
 #include <asm/debug.h>
 
diff -Nru a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c
--- a/arch/mips/pci/ops-tx4927.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/pci/ops-tx4927.c	2004-12-24 13:36:47 -08:00
@@ -4,6 +4,7 @@
  *              ahennessy@mvista.com       
  *
  * Copyright (C) 2000-2001 Toshiba Corporation 
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  *
  * Based on arch/mips/ddb5xxx/ddb5477/pci_ops.c
  *
@@ -12,6 +13,9 @@
  * Much of the code is derived from the original DDB5074 port by 
  * Geert Uytterhoeven <geert@sonycom.com>
  *
+ * Copyright 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani (mlachwani@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
@@ -38,39 +42,26 @@
 #include <linux/init.h>
 
 #include <asm/addrspace.h>
-#include <asm/pci_channel.h>
 #include <asm/tx4927/tx4927_pci.h>
 #include <asm/debug.h>
 
 /* initialize in setup */
 struct resource pci_io_resource = {
-	"pci IO space",
-	(PCIBIOS_MIN_IO),
-	((PCIBIOS_MIN_IO) + (TX4927_PCIIO_SIZE)) - 1,
-	IORESOURCE_IO
+	.name	= "TX4927 PCI IO SPACE",
+	.start	= 0x1000,
+	.end	= (0x1000 + (TX4927_PCIIO_SIZE)) - 1,
+	.flags	= IORESOURCE_IO
 };
 
 /* initialize in setup */
 struct resource pci_mem_resource = {
-	"pci memory space",
-	TX4927_PCIMEM,
-	TX4927_PCIMEM + TX4927_PCIMEM_SIZE - 1,
-	IORESOURCE_MEM
-};
-
-extern struct pci_ops tx4927_pci_ops;
-
-/*
- * h/w only supports devices 0x00 to 0x14
- */
-struct pci_controller tx4927_controller = {
-	.pci_ops	= &tx4927_pci_ops,
-	.io_resource	= &pci_io_resource,
-	.mem_resource	= &pci_mem_resource,
+	.name	= "TX4927 PCI MEM SPACE",
+	.start	= TX4927_PCIMEM,
+	.end	= TX4927_PCIMEM + TX4927_PCIMEM_SIZE - 1,
+	.flags	= IORESOURCE_MEM
 };
 
-static int mkaddr(unsigned char bus, unsigned char dev_fn,
-	unsigned char where, int *flagsp)
+static int mkaddr(int bus, int dev_fn, int where, int *flagsp)
 {
 	if (bus > 0) {
 		/* Type 1 configuration */
@@ -107,107 +98,49 @@
 	return code;
 }
 
-/*
- * 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 tx4927_pcibios_read_config_byte(struct pci_dev *dev,
-					   int where, unsigned char *val)
+static int tx4927_pcibios_read_config(struct pci_bus *bus, unsigned int devfn, int where,
+		int size, u32 * val)
 {
-	int flags, retval;
-	unsigned char bus, func_num;
+	int flags, retval, dev, busno, func;
 
-	db_assert((where & 3) == 0);
-	db_assert(where < (1 << 8));
+	busno = bus->number;
+        dev = PCI_SLOT(devfn);
+        func = PCI_FUNC(devfn);
 
-	/* check if the bus is top-level */
-	if (dev->bus->parent != NULL) {
-		bus = dev->bus->number;
-		db_assert(bus != 0);
-	} else {
-		bus = 0;
+	if (size == 2) {
+		if (where & 1)
+	                return PCIBIOS_BAD_REGISTER_NUMBER;
 	}
 
-	func_num = PCI_FUNC(dev->devfn);
-	if (mkaddr(bus, dev->devfn, where, &flags))
-		return -1;
-#ifdef __BIG_ENDIAN
-	*val =
-	    *(volatile u8 *) ((ulong) & tx4927_pcicptr->
-			      g2pcfgdata | ((where & 3) ^ 3));
-#else
-	*val =
-	    *(volatile u8 *) ((ulong) & tx4927_pcicptr->
-			      g2pcfgdata | (where & 3));
-#endif
-	retval = check_abort(flags);
-	if (retval == PCIBIOS_DEVICE_NOT_FOUND)
-		*val = 0xff;
-	return retval;
-}
-
-static int tx4927_pcibios_read_config_word(struct pci_dev *dev,
-					   int where, unsigned short *val)
-{
-	int flags, retval;
-	unsigned char bus, func_num;
-
-	if (where & 1)
-		return PCIBIOS_BAD_REGISTER_NUMBER;
-
-	db_assert((where & 3) == 0);
-	db_assert(where < (1 << 8));
+	if (size == 4) {
+		if (where & 3)
+			return PCIBIOS_BAD_REGISTER_NUMBER;
+	}
 
 	/* check if the bus is top-level */
-	if (dev->bus->parent != NULL) {
-		bus = dev->bus->number;
-		db_assert(bus != 0);
+	if (bus->parent != NULL) {
+		busno = bus->number;
 	} else {
-		bus = 0;
+		busno = 0;
 	}
 
-	func_num = PCI_FUNC(dev->devfn);
-	if (mkaddr(bus, dev->devfn, where, &flags))
+	if (mkaddr(busno, devfn, where, &flags))
 		return -1;
-#ifdef __BIG_ENDIAN
-	*val =
-	    *(volatile u16 *) ((ulong) & tx4927_pcicptr->
-			       g2pcfgdata | ((where & 3) ^ 2));
-#else
-	*val =
-	    *(volatile u16 *) ((ulong) & tx4927_pcicptr->
-			       g2pcfgdata | (where & 3));
-#endif
-	retval = check_abort(flags);
-	if (retval == PCIBIOS_DEVICE_NOT_FOUND)
-		*val = 0xffff;
-	return retval;
-}
-
-static int tx4927_pcibios_read_config_dword(struct pci_dev *dev,
-					    int where, unsigned int *val)
-{
-	int flags, retval;
-	unsigned char bus, func_num;
 
-	if (where & 3)
-		return PCIBIOS_BAD_REGISTER_NUMBER;
-
-	db_assert((where & 3) == 0);
-	db_assert(where < (1 << 8));
-
-	/* check if the bus is top-level */
-	if (dev->bus->parent != NULL) {
-		bus = dev->bus->number;
-		db_assert(bus != 0);
-	} else {
-		bus = 0;
+	switch (size) {
+	case 1:
+		*val = *(volatile u8 *) ((ulong) & tx4927_pcicptr->
+                              g2pcfgdata | (where & 3));
+		break;
+	case 2:
+		*val = *(volatile u16 *) ((ulong) & tx4927_pcicptr->
+                               g2pcfgdata | (where & 3));
+		break;
+	case 4:
+		*val = tx4927_pcicptr->g2pcfgdata;
+		break;
 	}
 
-	func_num = PCI_FUNC(dev->devfn);
-	if (mkaddr(bus, dev->devfn, where, &flags))
-		return -1;
-	*val = tx4927_pcicptr->g2pcfgdata;
 	retval = check_abort(flags);
 	if (retval == PCIBIOS_DEVICE_NOT_FOUND)
 		*val = 0xffffffff;
@@ -215,92 +148,62 @@
 	return retval;
 }
 
-static int tx4927_pcibios_write_config_byte(struct pci_dev *dev,
-					    int where, unsigned char val)
+static int tx4927_pcibios_write_config(struct pci_bus *bus, unsigned int devfn, int where,
+				int size, u32 val)
 {
-	int flags;
-	unsigned char bus, func_num;
+	int flags, dev, busno, func;
+	busno = bus->number;
+        dev = PCI_SLOT(devfn);
+        func = PCI_FUNC(devfn);
 
-	/* check if the bus is top-level */
-	if (dev->bus->parent != NULL) {
-		bus = dev->bus->number;
-		db_assert(bus != 0);
-	} else {
-		bus = 0;
+	if (size == 1) {
+		if (where & 1)
+			return PCIBIOS_BAD_REGISTER_NUMBER;
 	}
 
-	func_num = PCI_FUNC(dev->devfn);
-	if (mkaddr(bus, dev->devfn, where, &flags))
-		return -1;
-#ifdef __BIG_ENDIAN
-	*(volatile u8 *) ((ulong) & tx4927_pcicptr->
-			  g2pcfgdata | ((where & 3) ^ 3)) = val;
-#else
-	*(volatile u8 *) ((ulong) & tx4927_pcicptr->
-			  g2pcfgdata | (where & 3)) = val;
-#endif
-	return check_abort(flags);
-}
-
-static int tx4927_pcibios_write_config_word(struct pci_dev *dev,
-					    int where, unsigned short val)
-{
-	int flags;
-	unsigned char bus, func_num;
-
-	if (where & 1)
-		return PCIBIOS_BAD_REGISTER_NUMBER;
+	if (size == 4) {
+		if (where & 3)
+			return PCIBIOS_BAD_REGISTER_NUMBER;
+	}
 
 	/* check if the bus is top-level */
-	if (dev->bus->parent != NULL) {
-		bus = dev->bus->number;
-		db_assert(bus != 0);
+	if (bus->parent != NULL) {
+		busno = bus->number;
 	} else {
-		bus = 0;
+		busno = 0;
 	}
 
-	func_num = PCI_FUNC(dev->devfn);
-	if (mkaddr(bus, dev->devfn, where, &flags))
+	if (mkaddr(busno, devfn, where, &flags))
 		return -1;
-#ifdef __BIG_ENDIAN
-	*(volatile u16 *) ((ulong) & tx4927_pcicptr->
-			   g2pcfgdata | ((where & 3) ^ 2)) = val;
-#else
-	*(volatile u16 *) ((ulong) & tx4927_pcicptr->
-			   g2pcfgdata | (where & 3)) = val;
-#endif
-	return check_abort(flags);
-}
-
-static int tx4927_pcibios_write_config_dword(struct pci_dev *dev,
-					     int where, unsigned int val)
-{
-	int flags;
-	unsigned char bus, func_num;
 
-	if (where & 3)
-		return PCIBIOS_BAD_REGISTER_NUMBER;
+	switch (size) {
+	case 1:
+		 *(volatile u8 *) ((ulong) & tx4927_pcicptr->
+                          g2pcfgdata | (where & 3)) = val;
+		break;
 
-	/* check if the bus is top-level */
-	if (dev->bus->parent != NULL) {
-		bus = dev->bus->number;
-		db_assert(bus != 0);
-	} else {
-		bus = 0;
+	case 2:
+		*(volatile u16 *) ((ulong) & tx4927_pcicptr->
+                           g2pcfgdata | (where & 3)) = val;
+		break;
+	case 4:
+		tx4927_pcicptr->g2pcfgdata = val;
+		break;
 	}
 
-	func_num = PCI_FUNC(dev->devfn);
-	if (mkaddr(bus, dev->devfn, where, &flags))
-		return -1;
-	tx4927_pcicptr->g2pcfgdata = val;
 	return check_abort(flags);
 }
 
 struct pci_ops tx4927_pci_ops = {
-	tx4927_pcibios_read_config_byte,
-	tx4927_pcibios_read_config_word,
-	tx4927_pcibios_read_config_dword,
-	tx4927_pcibios_write_config_byte,
-	tx4927_pcibios_write_config_word,
-	tx4927_pcibios_write_config_dword
+	tx4927_pcibios_read_config,
+	tx4927_pcibios_write_config
+};
+
+/*
+ * h/w only supports devices 0x00 to 0x14
+ */
+struct pci_controller tx4927_controller = {
+	.pci_ops        = &tx4927_pci_ops,
+	.io_resource    = &pci_io_resource,
+	.mem_resource   = &pci_mem_resource,
 };
diff -Nru a/arch/mips/pci/pci-ddb5074.c b/arch/mips/pci/pci-ddb5074.c
--- a/arch/mips/pci/pci-ddb5074.c	2004-12-24 13:36:18 -08:00
+++ b/arch/mips/pci/pci-ddb5074.c	2004-12-24 13:36:18 -08:00
@@ -3,7 +3,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 
-#include <asm/pci_channel.h>
 #include <asm/debug.h>
 
 #include <asm/ddb5xxx/ddb5xxx.h>
@@ -52,6 +51,12 @@
 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
 	return irq_map[slot];
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
 
 void __init ddb_pci_reset_bus(void)
diff -Nru a/arch/mips/pci/pci-ddb5476.c b/arch/mips/pci/pci-ddb5476.c
--- a/arch/mips/pci/pci-ddb5476.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/pci/pci-ddb5476.c	2004-12-24 13:36:19 -08:00
@@ -3,7 +3,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 
-#include <asm/pci_channel.h>
 #include <asm/debug.h>
 
 #include <asm/ddb5xxx/ddb5xxx.h>
@@ -66,6 +65,12 @@
 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
 	return irq_map[slot];
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
 
 void __init ddb_pci_reset_bus(void)
diff -Nru a/arch/mips/pci/pci-ddb5477.c b/arch/mips/pci/pci-ddb5477.c
--- a/arch/mips/pci/pci-ddb5477.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/pci/pci-ddb5477.c	2004-12-24 13:36:48 -08:00
@@ -4,6 +4,8 @@
  * Copyright (C) 2001 MontaVista Software Inc.
  * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  *
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.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
@@ -15,7 +17,6 @@
 #include <linux/pci.h>
 
 #include <asm/bootinfo.h>
-#include <asm/pci_channel.h>
 #include <asm/debug.h>
 
 #include <asm/ddb5xxx/ddb5xxx.h>
@@ -173,6 +174,12 @@
 	}
 
 	return irq;
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
 
 void ddb_pci_reset_bus(void)
diff -Nru a/arch/mips/pci/pci-ev96100.c b/arch/mips/pci/pci-ev96100.c
--- a/arch/mips/pci/pci-ev96100.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/pci/pci-ev96100.c	2004-12-24 13:37:29 -08:00
@@ -6,6 +6,8 @@
  * Carsten Langgaard, carstenl@mips.com
  * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
  *
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.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
@@ -30,8 +32,6 @@
 #include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
-
-#include <asm/pci_channel.h>
 
 static struct resource pci_io_resource = {
 	.name	= "io pci IO space",
diff -Nru a/arch/mips/pci/pci-hplj.c b/arch/mips/pci/pci-hplj.c
--- a/arch/mips/pci/pci-hplj.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,204 +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.
- *
- * SNI specific PCI support for RM200/RM300.
- *
- * Copyright (C) 1997 - 2000 Ralf Baechle
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/types.h>
-#include <asm/byteorder.h>
-#include <asm/pci_channel.h>
-#include <asm/hp-lj/asic.h>
-
-static volatile u32 *pci_config_address_reg = (volatile u32 *) 0xfdead000;
-static volatile u32 *pci_config_data_reg = (volatile u32 *) 0xfdead000;
-
-
-
-#define cfgaddr(dev, where) (((dev->bus->number & 0xff) << 0x10) |  \
-                             ((dev->devfn & 0xff) << 0x08) |        \
-                             (where & 0xfc))
-
-/*
- * 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 pcimt_read_config_byte(struct pci_dev *dev,
-				  int where, unsigned char *val)
-{
-	*pci_config_address_reg = cfgaddr(dev, where);
-	*val =
-	    (le32_to_cpu(*pci_config_data_reg) >> ((where & 3) << 3)) &
-	    0xff;
-	//printk("pci_read_byte 0x%x == 0x%x\n", where, *val);
-	return PCIBIOS_SUCCESSFUL;
-}
-
-static int pcimt_read_config_word(struct pci_dev *dev,
-				  int where, unsigned short *val)
-{
-	if (where & 1)
-		return PCIBIOS_BAD_REGISTER_NUMBER;
-	*pci_config_address_reg = cfgaddr(dev, where);
-	*val =
-	    (le32_to_cpu(*pci_config_data_reg) >> ((where & 3) << 3)) &
-	    0xffff;
-	//printk("pci_read_word 0x%x == 0x%x\n", where, *val);
-	return PCIBIOS_SUCCESSFUL;
-}
-
-int pcimt_read_config_dword(struct pci_dev *dev,
-			    int where, unsigned int *val)
-{
-	if (where & 3)
-		return PCIBIOS_BAD_REGISTER_NUMBER;
-	*pci_config_address_reg = cfgaddr(dev, where);
-	*val = le32_to_cpu(*pci_config_data_reg);
-	//printk("pci_read_dword 0x%x == 0x%x\n", where, *val);
-	return PCIBIOS_SUCCESSFUL;
-}
-
-static int pcimt_write_config_byte(struct pci_dev *dev,
-				   int where, unsigned char val)
-{
-	*pci_config_address_reg = cfgaddr(dev, where);
-	*(volatile u8 *) (((int) pci_config_data_reg) + (where & 3)) = val;
-	//printk("pci_write_byte 0x%x = 0x%x\n", where, val);
-	return PCIBIOS_SUCCESSFUL;
-}
-
-static int pcimt_write_config_word(struct pci_dev *dev,
-				   int where, unsigned short val)
-{
-	if (where & 1)
-		return PCIBIOS_BAD_REGISTER_NUMBER;
-	*pci_config_address_reg = cfgaddr(dev, where);
-	*(volatile u16 *) (((int) pci_config_data_reg) + (where & 2)) =
-	    le16_to_cpu(val);
-	//printk("pci_write_word 0x%x = 0x%x\n", where, val);
-	return PCIBIOS_SUCCESSFUL;
-}
-
-int pcimt_write_config_dword(struct pci_dev *dev,
-			     int where, unsigned int val)
-{
-	if (where & 3)
-		return PCIBIOS_BAD_REGISTER_NUMBER;
-	*pci_config_address_reg = cfgaddr(dev, where);
-	*pci_config_data_reg = le32_to_cpu(val);
-	//printk("pci_write_dword 0x%x = 0x%x\n", where, val);
-	return PCIBIOS_SUCCESSFUL;
-}
-
-
-
-struct pci_ops hp_pci_ops = {
-	pcimt_read_config_byte,
-	pcimt_read_config_word,
-	pcimt_read_config_dword,
-	pcimt_write_config_byte,
-	pcimt_write_config_word,
-	pcimt_write_config_dword
-};
-
-
-struct pci_controller hp_controller = {
-	.pci_ops	= &hp_pci_ops,
-	.io_resource	= &ioport_resource,
-	.mem_resource	= &iomem_resource,
-};
-
-void __init pcibios_fixup_irqs(void)
-{
-	struct pci_dev *dev = NULL;
-	int slot_num;
-
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
-		slot_num = PCI_SLOT(dev->devfn);
-		switch (slot_num) {
-		case 2:
-			dev->irq = 3;
-			break;
-		case 3:
-			dev->irq = 4;
-			break;
-		case 4:
-			dev->irq = 5;
-			break;
-		default:
-			break;
-		}
-	}
-}
-
-#define IO_MEM_LOGICAL_START   0x3e000000
-#define IO_MEM_LOGICAL_END     0x3fefffff
-
-#define IO_PORT_LOGICAL_START  0x3ff00000
-#define IO_PORT_LOGICAL_END    0x3fffffff
-
-
-#define IO_MEM_VIRTUAL_OFFSET  0xb0000000
-#define IO_PORT_VIRTUAL_OFFSET 0xb0000000
-
-#define ONE_MEG   (1024 * 1024)
-
-void __init pci_setup(void)
-{
-	u32 pci_regs_base_offset = 0xfdead000;
-
-	switch (GetAsicId()) {
-	case AndrosAsic:
-		pci_regs_base_offset = 0xbff80000;
-		break;
-	case HarmonyAsic:
-		pci_regs_base_offset = 0xbff70000;
-		break;
-	default:
-		printk("ERROR: PCI does not support %s Asic\n",
-		       GetAsicName());
-		while (1);
-		break;
-	}
-
-	// set bus stat/command reg
-	// REVIST this setting may need vary depending on the hardware
-	*((volatile unsigned int *) (pci_regs_base_offset | 0x0004)) =
-	    0x38000007;
-
-
-	iomem_resource.start =
-	    IO_MEM_LOGICAL_START + IO_MEM_VIRTUAL_OFFSET;
-	iomem_resource.end = IO_MEM_LOGICAL_END + IO_MEM_VIRTUAL_OFFSET;
-
-	ioport_resource.start =
-	    IO_PORT_LOGICAL_START + IO_PORT_VIRTUAL_OFFSET;
-	ioport_resource.end = IO_PORT_LOGICAL_END + IO_PORT_VIRTUAL_OFFSET;
-
-	// KLUDGE (mips_io_port_base is screwed up, we've got to work around it here)
-	// by letting both low (illegal) and high (legal) addresses appear in pci io space
-	ioport_resource.start = 0x0;
-
-	set_io_port_base(IO_PORT_LOGICAL_START + IO_PORT_VIRTUAL_OFFSET);
-
-	// map the PCI address space
-	// global map - all levels & processes can access
-	// except that the range is outside user space
-	// parameters: lo0, lo1, hi, pagemask
-	// lo indicates physical page, hi indicates virtual address
-	add_wired_entry((IO_MEM_LOGICAL_START >> 6) | 0x17,
-			((IO_MEM_LOGICAL_START +
-			  (16 * ONE_MEG)) >> 6) | 0x17, 0xee000000,
-			PM_16M);
-
-
-	// These are used in pci r/w routines so need to preceed bus scan
-	pci_config_data_reg = (u32 *) (((u32) mips_io_port_base) | 0xcfc);
-	pci_config_address_reg =
-	    (u32 *) (((u32) pci_regs_base_offset) | 0xcf8);
-}
diff -Nru a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c
--- a/arch/mips/pci/pci-ip27.c	2004-12-24 13:37:30 -08:00
+++ b/arch/mips/pci/pci-ip27.c	2004-12-24 13:37:30 -08:00
@@ -4,7 +4,7 @@
  * for more details.
  *
  * Copyright (C) 2003 Christoph Hellwig (hch@lst.de)
- * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
+ * Copyright (C) 1999, 2000, 04 Ralf Baechle (ralf@linux-mips.org)
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  */
 #include <linux/init.h>
@@ -12,11 +12,12 @@
 #include <linux/pci.h>
 #include <asm/sn/arch.h>
 #include <asm/pci/bridge.h>
-#include <asm/pci_channel.h>
 #include <asm/paccess.h>
 #include <asm/sn/intr.h>
 #include <asm/sn/sn0/hub.h>
 
+extern unsigned int allocate_irqno(void);
+
 /*
  * Max #PCI busses we can handle; ie, max #PCI bridges.
  */
@@ -81,7 +82,7 @@
 	else
 		res = get_dbe(*value, (u32 *) addr);
 
-	return PCIBIOS_SUCCESSFUL;
+	return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
 
 oh_my_gawd:
 
@@ -110,6 +111,79 @@
 	return PCIBIOS_SUCCESSFUL;
 }
 
+static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
+				 int where, int size, u32 * value)
+{
+	struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
+	bridge_t *bridge = bc->base;
+	int busno = bus->number;
+	int slot = PCI_SLOT(devfn);
+	int fn = PCI_FUNC(devfn);
+	volatile void *addr;
+	u32 cf, shift, mask;
+	int res;
+
+	bridge->b_pci_cfg = (busno << 16) | (slot << 11);
+	addr = &bridge->b_type1_cfg.c[(fn << 8) | PCI_VENDOR_ID];
+	if (get_dbe(cf, (u32 *) addr))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	/*
+	 * IOC3 is fucked fucked beyond believe ...  Don't even give the
+	 * generic PCI code a chance to look at it for real ...
+	 */
+	if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
+		goto oh_my_gawd;
+
+	bridge->b_pci_cfg = (busno << 16) | (slot << 11);
+	addr = &bridge->b_type1_cfg.c[(fn << 8) | (where ^ (4 - size))];
+
+	if (size == 1)
+		res = get_dbe(*value, (u8 *) addr);
+	else if (size == 2)
+		res = get_dbe(*value, (u16 *) addr);
+	else
+		res = get_dbe(*value, (u32 *) addr);
+
+	return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
+
+oh_my_gawd:
+
+	/*
+	 * IOC3 is fucked fucked beyond believe ...  Don't even give the
+	 * generic PCI code a chance to look at the wrong register.
+	 */
+	if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) {
+		*value = 0;
+		return PCIBIOS_SUCCESSFUL;
+	}
+
+	/*
+	 * IOC3 is fucked fucked beyond believe ...  Don't try to access
+	 * anything but 32-bit words ...
+	 */
+	bridge->b_pci_cfg = (busno << 16) | (slot << 11);
+	addr = &bridge->b_type1_cfg.c[(fn << 8) | where];
+
+	if (get_dbe(cf, (u32 *) addr))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	shift = ((where & 3) << 3);
+	mask = (0xffffffffU >> ((4 - size) << 3));
+	*value = (cf >> shift) & mask;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int pci_read_config(struct pci_bus *bus, unsigned int devfn,
+			   int where, int size, u32 * value)
+{
+	if (bus->number > 0)
+		return pci_conf1_read_config(bus, devfn, where, size, value);
+
+	return pci_conf0_read_config(bus, devfn, where, size, value);
+}
+
 static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,
 				  int where, int size, u32 value)
 {
@@ -176,16 +250,95 @@
 	return PCIBIOS_SUCCESSFUL;
 }
 
+static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
+				  int where, int size, u32 value)
+{
+	struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
+	bridge_t *bridge = bc->base;
+	int slot = PCI_SLOT(devfn);
+	int fn = PCI_FUNC(devfn);
+	int busno = bus->number;
+	volatile void *addr;
+	u32 cf, shift, mask, smask;
+	int res;
+
+	bridge->b_pci_cfg = (busno << 16) | (slot << 11);
+	addr = &bridge->b_type1_cfg.c[(fn << 8) | PCI_VENDOR_ID];
+	if (get_dbe(cf, (u32 *) addr))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	/*
+	 * IOC3 is fucked fucked beyond believe ...  Don't even give the
+	 * generic PCI code a chance to look at it for real ...
+	 */
+	if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
+		goto oh_my_gawd;
+
+	addr = &bridge->b_type1_cfg.c[(fn << 8) | (where ^ (4 - size))];
+
+	if (size == 1) {
+		res = put_dbe(value, (u8 *) addr);
+	} else if (size == 2) {
+		res = put_dbe(value, (u16 *) addr);
+	} else {
+		res = put_dbe(value, (u32 *) addr);
+	}
+
+	if (res)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	return PCIBIOS_SUCCESSFUL;
+
+oh_my_gawd:
+
+	/*
+	 * IOC3 is fucked fucked beyond believe ...  Don't even give the
+	 * generic PCI code a chance to touch the wrong register.
+	 */
+	if ((where >= 0x14 && where < 0x40) || (where >= 0x48))
+		return PCIBIOS_SUCCESSFUL;
+
+	/*
+	 * IOC3 is fucked fucked beyond believe ...  Don't try to access
+	 * anything but 32-bit words ...
+	 */
+	addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
+
+	if (get_dbe(cf, (u32 *) addr))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	shift = ((where & 3) << 3);
+	mask = (0xffffffffU >> ((4 - size) << 3));
+	smask = mask << shift;
+
+	cf = (cf & ~smask) | ((value & mask) << shift);
+	if (put_dbe(cf, (u32 *) addr))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int pci_write_config(struct pci_bus *bus, unsigned int devfn,
+	int where, int size, u32 value)
+{
+	if (bus->number > 0)
+		return pci_conf1_write_config(bus, devfn, where, size, value);
+
+	return pci_conf0_write_config(bus, devfn, where, size, value);
+}
+
 static struct pci_ops bridge_pci_ops = {
-	.read = pci_conf0_read_config,
-	.write = pci_conf0_write_config,
+	.read = pci_read_config,
+	.write = pci_write_config,
 };
 
 int __init bridge_probe(nasid_t nasid, int widget_id, int masterwid)
 {
+	unsigned long offset = NODE_OFFSET(nasid);
 	struct bridge_controller *bc;
-	bridge_t *bridge;
 	static int num_bridges = 0;
+	bridge_t *bridge;
+	int slot;
 
 	printk("a bridge\n");
 
@@ -193,21 +346,23 @@
 	if (!num_bridges)
 		ioport_resource.end = ~0UL;
 
-	bc = &bridges[num_bridges++];
+	bc = &bridges[num_bridges];
 
 	bc->pc.pci_ops		= &bridge_pci_ops;
 	bc->pc.mem_resource	= &bc->mem;
 	bc->pc.io_resource	= &bc->io;
 
+	bc->pc.index		= num_bridges;
+
 	bc->mem.name		= "Bridge PCI MEM";
-	bc->pc.mem_offset	= 0;
+	bc->pc.mem_offset	= offset;
 	bc->mem.start		= 0;
 	bc->mem.end		= ~0UL;
 	bc->mem.flags		= IORESOURCE_MEM;
 
 	bc->io.name		= "Bridge IO MEM";
+	bc->pc.io_offset	= offset;
 	bc->io.start		= 0UL;
-	bc->pc.io_offset	= 0UL;
 	bc->io.end		= ~0UL;
 	bc->io.flags		= IORESOURCE_IO;
 
@@ -231,7 +386,7 @@
 	/*
  	 * Until otherwise set up, assume all interrupts are from slot 0
  	 */
-	bridge->b_int_device = (u32) 0x0;
+	bridge->b_int_device = 0x0;
 
 	/*
  	 * swap pio's to pci mem and io space (big windows)
@@ -248,11 +403,18 @@
 	bridge->b_dir_map = (masterwid << 20);	/* DMA */
 	bridge->b_int_enable = 0;
 
+	for (slot = 0; slot < 8; slot ++) {
+		bridge->b_device[slot].reg |= BRIDGE_DEV_SWAP_DIR;
+		bc->pci_int[slot] = -1;
+	}
 	bridge->b_wid_tflush;     /* wait until Bridge PIO complete */
 
 	bc->base = bridge;
 
 	register_pci_controller(&bc->pc);
+
+	num_bridges++;
+
 	return 0;
 }
 
@@ -268,17 +430,13 @@
 int __devinit pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
 	struct bridge_controller *bc = BRIDGE_CONTROLLER(dev->bus);
-	int irq;
-
-	irq = allocate_irqno();
+	int irq = bc->pci_int[slot];
 
-	/*
-	 * Argh...  This API doesn't handle with errors at all ...
-	 */
 	if (irq == -1) {
-		printk(KERN_ERR "Can't allocate interrupt for PCI device %s\n",
-		       pci_name(dev));
-		return -1;
+		irq = bc->pci_int[slot] = request_bridge_irq(bc);
+		if (irq < 0)
+			panic("Can't allocate interrupt for PCI device %s\n",
+			      pci_name(dev));
 	}
 
 	irq_to_bridge[irq] = bc;
@@ -287,6 +445,12 @@
 	return irq;
 }
 
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
+
 /*
  * 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.
@@ -294,7 +458,7 @@
  * settings.
  */
 
-static void __init pci_disable_swapping(struct pci_dev *dev)
+static inline void pci_disable_swapping(struct pci_dev *dev)
 {
 	struct bridge_controller *bc = BRIDGE_CONTROLLER(dev->bus);
 	bridge_t *bridge = bc->base;
@@ -305,7 +469,7 @@
 	bridge->b_widget.w_tflush;	/* Flush */
 }
 
-static void __init pci_enable_swapping(struct pci_dev *dev)
+static inline void pci_enable_swapping(struct pci_dev *dev)
 {
 	struct bridge_controller *bc = BRIDGE_CONTROLLER(dev->bus);
 	bridge_t *bridge = bc->base;
@@ -318,122 +482,8 @@
 
 static void __init pci_fixup_ioc3(struct pci_dev *d)
 {
-	struct bridge_controller *bc = BRIDGE_CONTROLLER(d->bus);
-	unsigned long offset = NODE_OFFSET(bc->nasid);
-
-	printk("PCI: Fixing base addresses for IOC3 device %s\n", pci_name(d));
-
-	d->resource[0].start |= offset;
-	d->resource[0].end |= offset;
-
 	pci_disable_swapping(d);
 }
 
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3,
-	 pci_fixup_ioc3);
-
-static void __init pci_fixup_isp1020(struct pci_dev *d)
-{
-	struct bridge_controller *bc = BRIDGE_CONTROLLER(d->bus);
-	unsigned short command;
-
-	d->resource[0].start |= (unsigned long) bc->nasid << 32;
-	printk("PCI: Fixing isp1020 in [bus:slot.fn] %s\n", pci_name(d));
-
-	/*
-	 * 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.
-	 */
-	pci_set_master(d);
-	pci_read_config_word(d, PCI_COMMAND, &command);
-	command |= PCI_COMMAND_MEMORY;
-	command |= PCI_COMMAND_IO;
-	pci_write_config_word(d, PCI_COMMAND, command);
-	d->resource[1].flags |= 1;
-
-	pci_enable_swapping(d);
-}
-
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020,
-	 pci_fixup_isp1020);
-
-static void __init pci_fixup_isp2x00(struct pci_dev *d)
-{
-	struct bridge_controller *bc = BRIDGE_CONTROLLER(d->bus);
-	bridge_t *bridge = bc->base;
-	bridgereg_t devreg;
-	int i;
-	int slot = PCI_SLOT(d->devfn);
-	unsigned int start;
-	unsigned short command;
-
-	printk("PCI: Fixing isp2x00 in [bus:slot.fn] %s\n", pci_name(d));
-
-	/* set the resource struct for this device */
-	start = (u32) (u64) bridge;	/* yes, we want to lose the upper 32 bits here */
-	start |= BRIDGE_DEVIO(slot);
-
-	d->resource[0].start = start;
-	d->resource[0].end = d->resource[0].start + 0xff;
-	d->resource[0].flags = IORESOURCE_IO;
-
-	d->resource[1].start = start;
-	d->resource[1].end = d->resource[0].start + 0xfff;
-	d->resource[1].flags = IORESOURCE_MEM;
-
-	/*
-	 * set the bridge device(x) reg for this device
-	 */
-	devreg = bridge->b_device[slot].reg;
-	/* point device(x) to it appropriate small window */
-	devreg &= ~BRIDGE_DEV_OFF_MASK;
-	devreg |= (start >> 20) & BRIDGE_DEV_OFF_MASK;
-	bridge->b_device[slot].reg = devreg;
-
-	pci_enable_swapping(d);
-
-	/* set card's base addr reg */
-	//pci_write_config_dword(d, PCI_BASE_ADDRESS_0, 0x500001);
-	//pci_write_config_dword(d, PCI_BASE_ADDRESS_1, 0x8b00000);
-	//pci_write_config_dword(d, PCI_ROM_ADDRESS, 0x8b20000);
-
-	/* I got these from booting irix on system... */
-	pci_write_config_dword(d, PCI_BASE_ADDRESS_0, 0x200001);
-	//pci_write_config_dword(d, PCI_BASE_ADDRESS_1, 0xf800000);
-	pci_write_config_dword(d, PCI_ROM_ADDRESS, 0x10200000);
-
-	pci_write_config_dword(d, PCI_BASE_ADDRESS_1, start);
-	//pci_write_config_dword(d, PCI_ROM_ADDRESS, (start | 0x20000));
-
-	/* set cache line size */
-	pci_write_config_dword(d, PCI_CACHE_LINE_SIZE, 0xf080);
-
-	/* set pci bus timeout */
-	bridge->b_bus_timeout |= BRIDGE_BUS_PCI_RETRY_HLD(0x3);
-	bridge->b_wid_tflush;
-	printk("PCI: bridge bus timeout= 0x%x \n", bridge->b_bus_timeout);
-
-	/* set host error field */
-	bridge->b_int_host_err = 0x44;
-	bridge->b_wid_tflush;
-
-	bridge->b_wid_tflush;	/* wait until Bridge PIO complete */
-	for (i = 0; i < 8; i++)
-		printk("PCI: device(%d)= 0x%x\n", i,
-		       bridge->b_device[i].reg);
-
-	/* configure device to allow bus mastering, i/o and memory mapping */
-	pci_set_master(d);
-	pci_read_config_word(d, PCI_COMMAND, &command);
-	command |= PCI_COMMAND_MEMORY;
-	command |= PCI_COMMAND_IO;
-	pci_write_config_word(d, PCI_COMMAND, command);
-	/*d->resource[1].flags |= 1; */
-}
-
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100,
-	 pci_fixup_isp2x00);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200,
-	 pci_fixup_isp2x00);
+	pci_fixup_ioc3);
diff -Nru a/arch/mips/pci/pci-ip32.c b/arch/mips/pci/pci-ip32.c
--- a/arch/mips/pci/pci-ip32.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/pci/pci-ip32.c	2004-12-24 13:37:18 -08:00
@@ -4,6 +4,7 @@
  * for more details.
  *
  * Copyright (C) 2000, 2001 Keith M Wesolowski
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  */
 #include <linux/config.h>
 #include <linux/kernel.h>
@@ -11,7 +12,6 @@
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/types.h>
-#include <asm/pci_channel.h>
 #include <asm/ip32/mace.h>
 #include <asm/ip32/ip32_ints.h>
 
diff -Nru a/arch/mips/pci/pci-jmr3927.c b/arch/mips/pci/pci-jmr3927.c
--- a/arch/mips/pci/pci-jmr3927.c	2004-12-24 13:36:30 -08:00
+++ b/arch/mips/pci/pci-jmr3927.c	2004-12-24 13:36:30 -08:00
@@ -4,6 +4,7 @@
  *              ahennessy@mvista.com
  *
  * Copyright (C) 2000-2001 Toshiba Corporation
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.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
@@ -30,7 +31,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 
-#include <asm/pci_channel.h>
 #include <asm/jmr3927/jmr3927.h>
 #include <asm/debug.h>
 
diff -Nru a/arch/mips/pci/pci-lasat.c b/arch/mips/pci/pci-lasat.c
--- a/arch/mips/pci/pci-lasat.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/pci/pci-lasat.c	2004-12-24 13:37:18 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2000, 2001 Keith M Wesolowski
+ * Copyright (C) 2000, 2001, 04 Keith M Wesolowski
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -12,7 +12,6 @@
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <asm/pci_channel.h>
 #include <linux/delay.h>
 #include <asm/bootinfo.h>
 
@@ -66,6 +65,7 @@
 #define LASATINT_PCIB   6
 #define LASATINT_PCIC   7
 #define LASATINT_PCID   8
+
 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
     switch (slot) {
@@ -86,4 +86,10 @@
     }
 
     return -1;
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
 }
diff -Nru a/arch/mips/pci/pci-ocelot-c.c b/arch/mips/pci/pci-ocelot-c.c
--- a/arch/mips/pci/pci-ocelot-c.c	2004-12-24 13:37:02 -08:00
+++ b/arch/mips/pci/pci-ocelot-c.c	2004-12-24 13:37:02 -08:00
@@ -3,13 +3,12 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2004 by Ralf Baechle
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  */
 
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <asm/mv64340.h>
-#include <asm/pci_channel.h>
 
 #include <linux/init.h>
 
diff -Nru a/arch/mips/pci/pci-ocelot-g.c b/arch/mips/pci/pci-ocelot-g.c
--- a/arch/mips/pci/pci-ocelot-g.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/pci/pci-ocelot-g.c	2004-12-24 13:36:49 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2004 by Ralf Baechle
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  *
  * This doesn't really fly - but I don't have a GT64240 system for testing.
  */
@@ -12,7 +12,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <asm/gt64240.h>
-#include <asm/pci_channel.h>
 
 /*
  * We assume these address ranges have been programmed into the GT-64240 by
diff -Nru a/arch/mips/pci/pci-sb1250.c b/arch/mips/pci/pci-sb1250.c
--- a/arch/mips/pci/pci-sb1250.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/pci/pci-sb1250.c	2004-12-24 13:36:19 -08:00
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Broadcom Corporation
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -36,9 +37,9 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/console.h>
+#include <linux/tty.h>
 
 #include <asm/io.h>
-#include <asm/pci_channel.h>
 
 #include <asm/sibyte/sb1250_defs.h>
 #include <asm/sibyte/sb1250_regs.h>
@@ -89,6 +90,12 @@
 	return dev->irq;
 }
 
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
+
 /*
  * Some checks before doing config cycles:
  * In PCI Device Mode, hide everything on bus 0 except the LDT host
@@ -181,22 +188,22 @@
 
 static struct resource sb1250_mem_resource = {
 	.name	= "SB1250 PCI MEM",
-	.start	= 0x14000000UL,
-	.end	= 0x17ffffffUL,
+	.start	= 0x40000000UL,
+	.end	= 0x5fffffffUL,
 	.flags	= IORESOURCE_MEM,
 };
                                                                                 
 static struct resource sb1250_io_resource = {
-	.name	= "SB1250 IO MEM",
-	.start	= 0x14000000UL,
-	.end	= 0x17ffffffUL,
+	.name	= "SB1250 PCI I/O",
+	.start	= 0x00000000UL,
+	.end	= 0x01ffffffUL,
 	.flags	= IORESOURCE_IO,
 };
 
 struct pci_controller sb1250_controller = {
 	.pci_ops	= &sb1250_pci_ops,
 	.mem_resource	= &sb1250_mem_resource,
-	.io_resource	= &sb1250_io_resource
+	.io_resource	= &sb1250_io_resource,
 };
 
 static int __init sb1250_pcibios_init(void)
@@ -208,8 +215,8 @@
 	/* CFE will assign PCI resources */
 	pci_probe_only = 1;
 
-	/* set resource limit to avoid errors */
-	ioport_resource.end = 0x0000ffff;	/* 32MB reserved by sb1250 */
+	/* Set I/O resource limits.  */
+	ioport_resource.end = 0x01ffffff;	/* 32MB accessible by sb1250 */
 	iomem_resource.end = 0xffffffff;	/* no HT support yet */
 
 	cfg_space =
diff -Nru a/arch/mips/pci/pci-vr41xx.c b/arch/mips/pci/pci-vr41xx.c
--- a/arch/mips/pci/pci-vr41xx.c	2004-12-24 13:37:43 -08:00
+++ b/arch/mips/pci/pci-vr41xx.c	2004-12-24 13:37:43 -08:00
@@ -4,6 +4,7 @@
  *  Copyright (C) 2001-2003 MontaVista Software Inc.
  *    Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
  *  Copyright (C) 2004  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.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
@@ -30,7 +31,6 @@
 
 #include <asm/cpu.h>
 #include <asm/io.h>
-#include <asm/pci_channel.h>
 #include <asm/vr41xx/vr41xx.h>
 
 #include "pci-vr41xx.h"
diff -Nru a/arch/mips/pci/pci-yosemite.c b/arch/mips/pci/pci-yosemite.c
--- a/arch/mips/pci/pci-yosemite.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/pci/pci-yosemite.c	2004-12-24 13:37:29 -08:00
@@ -3,15 +3,13 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2004 by Ralf Baechle
- *
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  */
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <asm/gt64240.h>
-#include <asm/pci_channel.h>
 
 extern struct pci_ops titan_pci_ops;
 
@@ -19,19 +17,42 @@
 	"Titan PCI MEM", 0xe0000000UL, 0xe3ffffffUL, IORESOURCE_MEM
 };
 
+/*
+ * PMON really reserves 16MB of I/O port space but that's stupid, nothing
+ * needs that much since allocations are limited to 256 bytes per device
+ * anyway.  So we just claim 64kB here.
+ */
+#define TITAN_IO_SIZE	0x0000ffffUL
+
 static struct resource py_io_resource = {
-	"Titan IO MEM", 0x00000000UL, 0x00ffffffUL, IORESOURCE_IO,
+	"Titan IO MEM", 0x00001000UL, TITAN_IO_SIZE - 1, IORESOURCE_IO,
 };
 
 static struct pci_controller py_controller = {
 	.pci_ops	= &titan_pci_ops,
 	.mem_resource	= &py_mem_resource,
-	.mem_offset	= 0x10000000UL,
+	.mem_offset	= 0x00000000UL,
 	.io_resource	= &py_io_resource,
 	.io_offset	= 0x00000000UL
 };
 
+static char ioremap_failed[] __initdata = "Could not ioremap I/O port range";
+
 static int __init pmc_yosemite_setup(void)
 {
+	unsigned long io_v_base;
+
+	io_v_base = (unsigned long) ioremap(0xe0000000UL,TITAN_IO_SIZE);
+	if (!io_v_base)
+		panic(ioremap_failed);
+
+	set_io_port_base(io_v_base);
+
+	ioport_resource.end = TITAN_IO_SIZE - 1;
+
 	register_pci_controller(&py_controller);
+
+	return 0;
 }
+
+arch_initcall(pmc_yosemite_setup);
diff -Nru a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
--- a/arch/mips/pci/pci.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/pci/pci.c	2004-12-24 13:37:00 -08:00
@@ -4,7 +4,7 @@
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
  *
- * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org)
+ * Copyright (C) 2003, 04 Ralf Baechle (ralf@linux-mips.org)
  */
 #include <linux/config.h>
 #include <linux/kernel.h>
@@ -14,8 +14,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 
-#include <asm/pci_channel.h>
-
 /*
  * Indicate whether we respect the PCI setup left by the firmware.
  *
@@ -223,7 +221,7 @@
 	if ((err = pcibios_enable_resources(dev, mask)) < 0)
 		return err;
 
-	return 0;
+	return pcibios_plat_dev_init(dev);
 }
 
 static void __init pcibios_fixup_device_resources(struct pci_dev *dev,
diff -Nru a/arch/mips/pmc-sierra/yosemite/Makefile b/arch/mips/pmc-sierra/yosemite/Makefile
--- a/arch/mips/pmc-sierra/yosemite/Makefile	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/pmc-sierra/yosemite/Makefile	2004-12-24 13:36:17 -08:00
@@ -5,3 +5,4 @@
 obj-y    += irq-handler.o irq.o i2c-yosemite.o prom.o py-console.o setup.o
 
 obj-$(CONFIG_KGDB)		+= dbg_io.o
+obj-$(CONFIG_SMP)		+= smp.o
diff -Nru a/arch/mips/pmc-sierra/yosemite/dbg_io.c b/arch/mips/pmc-sierra/yosemite/dbg_io.c
--- a/arch/mips/pmc-sierra/yosemite/dbg_io.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/pmc-sierra/yosemite/dbg_io.c	2004-12-24 13:37:19 -08:00
@@ -33,7 +33,7 @@
 
 #include <linux/config.h>
 
-#if defined(CONFIG_KGDB)
+#ifdef CONFIG_KGDB
 #include <asm/serial.h>
 
 /*
diff -Nru a/arch/mips/pmc-sierra/yosemite/irq-handler.S b/arch/mips/pmc-sierra/yosemite/irq-handler.S
--- a/arch/mips/pmc-sierra/yosemite/irq-handler.S	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/pmc-sierra/yosemite/irq-handler.S	2004-12-24 13:37:18 -08:00
@@ -1,6 +1,7 @@
 /*
- * Copyright 2003 PMC-Sierra Inc.
+ * Copyright 2003, 04 PMC-Sierra Inc.
  * Author: Manish Lachwani (lachwani@pmc-sierra.com
+ * Copyright 2004 Ralf Baechle (ralf@linux-mips.org)
  *
  * First-level interrupt router for the PMC-Sierra Titan board
  *
@@ -27,6 +28,7 @@
 		CLI
 		.set	at
 		.set	noreorder
+		la	ra, ret_from_irq
 		mfc0	t0, CP0_CAUSE
 		mfc0	t2, CP0_STATUS
 
@@ -69,42 +71,36 @@
 		li	a0, 2
 		move	a1, sp
 #ifdef CONFIG_HYPERTRANSPORT
-		jal	ll_ht_smp_irq_handler
+		j	ll_ht_smp_irq_handler
 #else
-		jal	do_IRQ
+		j	do_IRQ
 #endif
-		j	ret_from_irq
 
 ll_pcib_irq:
 		li	a0, 3
 		move	a1, sp
-		jal	do_IRQ
-		j	ret_from_irq
+		j	do_IRQ
 
 ll_duart_irq:
 		li	a0, 4
 		move	a1, sp
-		jal	do_IRQ
-		j	ret_from_irq
+		j	do_IRQ
 
 ll_smp_irq:
 		li	a0, 5
 		move	a1, sp
 #ifdef CONFIG_SMP
-		jal	jaguar_mailbox_irq
+		j	titan_mailbox_irq
 #else
-		jal	do_IRQ
+		j	do_IRQ
 #endif
-		j	ret_from_irq
 
 ll_ht_irq:
 		li	a0, 6
 		move	a1, sp
-		jal	ll_ht_smp_irq_handler
-		j	ret_from_irq
+		j	ll_ht_smp_irq_handler
 
 ll_timer_irq:
 		li	a0, 7
 		move	a1, sp
-		jal	do_IRQ
-		j	ret_from_irq
+		j	do_IRQ
diff -Nru a/arch/mips/pmc-sierra/yosemite/irq.c b/arch/mips/pmc-sierra/yosemite/irq.c
--- a/arch/mips/pmc-sierra/yosemite/irq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/pmc-sierra/yosemite/irq.c	2004-12-24 13:37:18 -08:00
@@ -34,10 +34,11 @@
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
+#include <linux/irq.h>
 #include <linux/timex.h>
 #include <linux/slab.h>
 #include <linux/random.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -111,28 +112,22 @@
 
 #ifdef CONFIG_KGDB
 extern void init_second_port(void);
-extern void breakpoint(void);
-extern void set_debug_traps(void);
 #endif
 
 /*
  * Initialize the next level interrupt handler
  */
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	clear_c0_status(ST0_IM);
 
 	set_except_vector(0, titan_handle_int);
-	init_generic_irq();
 	mips_cpu_irq_init(0);
 	rm7k_cpu_irq_init(8);
 
 #ifdef CONFIG_KGDB
 	/* At this point, initialize the second serial port */
 	init_second_port();
-	printk("Start kgdb ... \n");
-	set_debug_traps();
-	breakpoint();
 #endif
 
 #ifdef CONFIG_GDB_CONSOLE
diff -Nru a/arch/mips/pmc-sierra/yosemite/prom.c b/arch/mips/pmc-sierra/yosemite/prom.c
--- a/arch/mips/pmc-sierra/yosemite/prom.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/pmc-sierra/yosemite/prom.c	2004-12-24 13:37:18 -08:00
@@ -4,9 +4,11 @@
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
  *
- * Copyright (C) 2003 PMC-Sierra Inc.
+ * Copyright (C) 2003, 2004 PMC-Sierra Inc.
  * Author: Manish Lachwani (lachwani@pmc-sierra.com)
+ * Copyright (C) 2004 Ralf Baechle
  */
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -21,6 +23,12 @@
 #include <asm/bootinfo.h>
 #include <asm/pmon.h>
 
+#ifdef CONFIG_SMP
+extern void prom_grab_secondary(void);
+#else
+#define prom_grab_secondary() do { } while (0)
+#endif
+
 #include "setup.h"
 
 struct callvectors *debug_vectors;
@@ -116,14 +124,10 @@
 	}
 #endif /* CONFIG_MIPS32 */
 
-#ifdef CONFIG_MIPS64
-
-	/* Do nothing for the 64-bit for now. Just implement for the 32-bit */
-
-#endif /* CONFIG_MIPS64 */
-
 	mips_machgroup = MACH_GROUP_TITAN;
 	mips_machtype = MACH_TITAN_YOSEMITE;
+
+	prom_grab_secondary();
 }
 
 void __init prom_free_prom_memory(void)
diff -Nru a/arch/mips/pmc-sierra/yosemite/py-console.c b/arch/mips/pmc-sierra/yosemite/py-console.c
--- a/arch/mips/pmc-sierra/yosemite/py-console.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/pmc-sierra/yosemite/py-console.c	2004-12-24 13:36:49 -08:00
@@ -48,8 +48,6 @@
 #define iu_iir u3.iir
 #define iu_fcr u3.fcr
 
-extern unsigned long uart_base;
-
 #define IO_BASE_64	0x9000000000000000ULL
 
 static unsigned char readb_outer_space(unsigned long phys)
@@ -108,11 +106,6 @@
 	__asm__("sll	$0, $0, 2\n");
 	__asm__("sll	$0, $0, 2\n");
 	__asm__("sll	$0, $0, 2\n");
-}
-
-static inline struct yo_uartregs *console_uart(void)
-{
-	return (struct yo_uartregs *) (uart_base + 8);
 }
 
 void prom_putchar(char c)
diff -Nru a/arch/mips/pmc-sierra/yosemite/setup.c b/arch/mips/pmc-sierra/yosemite/setup.c
--- a/arch/mips/pmc-sierra/yosemite/setup.c	2004-12-24 13:36:16 -08:00
+++ b/arch/mips/pmc-sierra/yosemite/setup.c	2004-12-24 13:36:16 -08:00
@@ -2,6 +2,8 @@
  *  Copyright (C) 2003 PMC-Sierra Inc.
  *  Author: Manish Lachwani (lachwani@pmc-sierra.com)
  *
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.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
@@ -37,13 +39,11 @@
 #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/processor.h>
 #include <asm/ptrace.h>
 #include <asm/reboot.h>
-#include <asm/pci_channel.h>
 #include <asm/serial.h>
 #include <linux/termios.h>
 #include <linux/tty.h>
diff -Nru a/arch/mips/pmc-sierra/yosemite/smp.c b/arch/mips/pmc-sierra/yosemite/smp.c
--- a/arch/mips/pmc-sierra/yosemite/smp.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/pmc-sierra/yosemite/smp.c	2004-12-24 13:36:47 -08:00
@@ -1,178 +1,152 @@
+#include <linux/linkage.h>
+#include <linux/sched.h>
+
+#include <asm/pmon.h>
+#include <asm/titan_dep.h>
+
+#define LAUNCHSTACK_SIZE 256
+
+static spinlock_t launch_lock __initdata;
+
+static unsigned long secondary_sp __initdata;
+static unsigned long secondary_gp __initdata;
+
+static unsigned char launchstack[LAUNCHSTACK_SIZE] __initdata
+	__attribute__((aligned(2 * sizeof(long))));
+
+static void __init prom_smp_bootstrap(void)
+{
+	local_irq_disable();
+
+	while (spin_is_locked(&launch_lock));
+
+	__asm__ __volatile__(
+	"	move	$sp, %0		\n"
+	"	move	$gp, %1		\n"
+	"	j	smp_bootstrap	\n"
+	:
+	: "r" (secondary_sp), "r" (secondary_gp));
+}
+
 /*
- * Copyright 2003 PMC-Sierra
- * Author: Manish Lachwani (lachwani@pmc-sierra.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 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.
+ * PMON is a fragile beast.  It'll blow up once the mappings it's littering
+ * right into the middle of KSEG3 are blown away so we have to grab the slave
+ * core early and keep it in a waiting loop.
  */
+void __init prom_grab_secondary(void)
+{
+	spin_lock(&launch_lock);
 
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/smp.h>
-#include <linux/kernel_stat.h>
+	debug_vectors->cpustart(1, &prom_smp_bootstrap,
+	                        launchstack + LAUNCHSTACK_SIZE, 0);
+}
 
-#include <asm/mmu_context.h>
-#include <asm/trace.h>
+/*
+ * Detect available CPUs, populate phys_cpu_present_map before smp_init
+ *
+ * We don't want to start the secondary CPU yet nor do we have a nice probing
+ * feature in PMON so we just assume presence of the secondary core.
+ */
+void prom_prepare_cpus(unsigned int max_cpus)
+{
+	cpus_clear(phys_cpu_present_map);
 
-extern void asmlinkage smp_bootstrap(void);
+	/*
+	 * The boot CPU
+	 */
+	cpu_set(0, phys_cpu_present_map);
+	__cpu_number_map[0]	= 0;
+	__cpu_logical_map[0]	= 0;
+
+	/*
+	 * The secondary core
+	 */
+	cpu_set(1, phys_cpu_present_map);
+	__cpu_number_map[1]	= 1;
+	__cpu_logical_map[1]	= 1;
+}
 
 /*
- * Send inter-processor interrupt
+ * Firmware CPU startup hook
+ * Complicated by PMON's weird interface which tries to minimic the UNIX fork.
+ * It launches the next * available CPU and copies some information on the
+ * stack so the first thing we do is throw away that stuff and load useful
+ * values into the registers ...
  */
-void core_send_ipi(int cpu, unsigned int action)
+void prom_boot_secondary(int cpu, struct task_struct *idle)
+{
+	unsigned long gp = (unsigned long) idle->thread_info;
+	unsigned long sp = gp + THREAD_SIZE - 32;
+
+	secondary_sp = sp;
+	secondary_gp = gp;
+
+	spin_unlock(&launch_lock);
+}
+
+/* Hook for after all CPUs are online */
+void prom_cpus_done(void)
 {
-        /*
-         * Generate and INTMSG so that it can be sent over to the destination CPU
-         * The INTMSG will put the STATUS bits based on the action desired
-         */
-        switch(action) {
-                case SMP_RESCHEDULE_YOURSELF:
-                        /* Do nothing */
-                        break;
-                case SMP_CALL_FUNCTION:
-                        if (cpu == 1)
-                                *(volatile uint32_t *)(0xbb000a00) = 0x00610002;
-                        else
-                                *(volatile uint32_t *)(0xbb000a00) = 0x00610001;
-                        break;
-
-                default:
-                        panic("core_send_ipi \n");
-        }
 }
 
 /*
- * Mailbox interrupt to handle IPI
+ *  After we've done initial boot, this function is called to allow the
+ *  board code to clean up state, if needed
  */
-void jaguar_mailbox_irq(struct pt_regs *regs)
+void prom_init_secondary(void)
 {
-        int cpu = smp_processor_id();
+	set_c0_status(ST0_CO | ST0_IE | ST0_IM);
+}
 
-        /* SMP_CALL_FUNCTION */
-        smp_call_function_interrupt();
+void prom_smp_finish(void)
+{
 }
 
-extern atomic_t cpus_booted;
-
-void __init start_secondary(void)
-{
-        unsigned int cpu = smp_processor_id();
-        extern atomic_t smp_commenced;
-
-        if (current->processor != 1) {
-                printk("Impossible CPU %d \n", cpu);
-                current->processor = 1;
-                current->cpus_runnable = 1 << 1;
-                cpu = current->processor;
-        }
-
-        if (current->mm)
-                current->mm = NULL;
-
-        prom_init_secondary();
-        per_cpu_trap_init();
-
-        /*
-         * XXX parity protection should be folded in here when it's converted
-         * to an option instead of something based on .cputype
-         */
-        pgd_current[cpu] = init_mm.pgd;
-        cpu_data[cpu].udelay_val = loops_per_jiffy;
-        prom_smp_finish();
-        CPUMASK_SETB(cpu_online_map, cpu);
-        atomic_inc(&cpus_booted);
-        __flush_cache_all();
-
-        printk("Slave cpu booted successfully  \n");
-        *(volatile uint32_t *)(0xbb000a68) = 0x00000000;
-        *(volatile uint32_t *)(0xbb000a68) = 0x80000000;
-
-        while (*(volatile uint32_t *)(0xbb000a68) != 0x00000000);
-
-        return cpu_idle();
-}
-
-void __init smp_boot_cpus(void)
-{
-        int i;
-        int cur_cpu = 0;
-
-        smp_num_cpus = prom_setup_smp();
-        printk("Detected %d available CPUs \n", smp_num_cpus);
-
-        init_new_context(current, &init_mm);
-        current->processor = 0;
-        cpu_data[0].udelay_val = loops_per_jiffy;
-        cpu_data[0].asid_cache = ASID_FIRST_VERSION;
-        CPUMASK_CLRALL(cpu_online_map);
-        CPUMASK_SETB(cpu_online_map, 0);
-        atomic_set(&cpus_booted, 1);  /* Master CPU is already booted... */
-        init_idle();
-
-        __cpu_number_map[0] = 0;
-        __cpu_logical_map[0] = 0;
-
-        /*
-         * This loop attempts to compensate for "holes" in the CPU
-         * numbering.  It's overkill, but general.
-         */
-        for (i = 1; i < smp_num_cpus; ) {
-                struct task_struct *p;
-                struct pt_regs regs;
-                int retval;
-                printk("Starting CPU %d... \n", i);
-
-                /* Spawn a new process normally.  Grab a pointer to
-                   its task struct so we can mess with it */
-                do_fork(CLONE_VM|CLONE_PID, 0, &regs, 0);
-
-                p = init_task.prev_task;
-                if (!p)
-                        panic("failed fork for CPU %d", i);
-
-                /* This is current for the second processor */
-                p->processor = i;
-                p->cpus_runnable = 1 << i; /* we schedule the first task manually */
-                p->thread.reg31 = (unsigned long) start_secondary;
-
-                del_from_runqueue(p);
-                unhash_process(p);
-                init_tasks[i] = p;
-
-                __flush_cache_all();
-
-                do {
-                        /* Iterate until we find a CPU that comes up */
-                        cur_cpu++;
-                        retval = prom_boot_secondary(cur_cpu,
-                                            (unsigned long)p + KERNEL_STACK_SIZE - 32,
-                                            (unsigned long)p);
-
-                } while (!retval && (cur_cpu < NR_CPUS));
-                if (retval) {
-                        __cpu_number_map[cur_cpu] = i;
-                        __cpu_logical_map[i] = cur_cpu;
-                        i++;
-                } else {
-                        panic("CPU discovery disaster");
-                }
-        }
+asmlinkage void titan_mailbox_irq(struct pt_regs *regs)
+{
+	int cpu = smp_processor_id();
+	unsigned long status;
 
-        /* Local semaphore to both the CPUs */
+	if (cpu == 0) {
+		status = OCD_READ(RM9000x2_OCD_INTP0STATUS3);
+		OCD_WRITE(RM9000x2_OCD_INTP0CLEAR3, status);
+	}
+
+	if (cpu == 1) {
+		status = OCD_READ(RM9000x2_OCD_INTP1STATUS3);
+		OCD_WRITE(RM9000x2_OCD_INTP1CLEAR3, status);
+	}
 
-        *(volatile uint32_t *)(0xbb000a68) = 0x80000000;
-        while (*(volatile uint32_t *)(0xbb000a68) != 0x00000000);
+	if (status & 0x2)
+		smp_call_function_interrupt();
+}
 
-        smp_threads_ready = 1;
+/*
+ * Send inter-processor interrupt
+ */
+void core_send_ipi(int cpu, unsigned int action)
+{
+	/*
+	 * Generate an INTMSG so that it can be sent over to the
+	 * destination CPU. The INTMSG will put the STATUS bits
+	 * based on the action desired. An alternative strategy
+	 * is to write to the Interrupt Set register, read the
+	 * Interrupt Status register and clear the Interrupt
+	 * Clear register. The latter is preffered.
+	 */
+	switch (action) {
+	case SMP_RESCHEDULE_YOURSELF:
+		if (cpu == 1)
+			OCD_WRITE(RM9000x2_OCD_INTP1SET3, 4);
+		else
+			OCD_WRITE(RM9000x2_OCD_INTP0SET3, 4);
+		break;
+
+	case SMP_CALL_FUNCTION:
+		if (cpu == 1)
+			OCD_WRITE(RM9000x2_OCD_INTP1SET3, 2);
+		else
+			OCD_WRITE(RM9000x2_OCD_INTP0SET3, 2);
+		break;
+	}
 }
diff -Nru a/arch/mips/ramdisk/Makefile b/arch/mips/ramdisk/Makefile
--- a/arch/mips/ramdisk/Makefile	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,20 +0,0 @@
-#
-# Makefile for a ramdisk image
-#
-
-obj-y += ramdisk.o
-
-
-O_FORMAT = $(shell $(OBJDUMP) -i | head -n 2 | grep elf32)
-img := $(subst ",,$(CONFIG_EMBEDDED_RAMDISK_IMAGE))
-# add $(src) when $(img) is relative
-img := $(subst $(src)//,/,$(src)/$(img))
-
-quiet_cmd_ramdisk = LD      $@
-define cmd_ramdisk
-	$(LD) $(LDFLAGS) -T $(src)/ld.script -b binary --oformat $(O_FORMAT) -o $@ $(img)
-endef
-
-$(obj)/ramdisk.o: $(img) $(src)/ld.script
-	$(call cmd,ramdisk)
-
diff -Nru a/arch/mips/ramdisk/ld.script b/arch/mips/ramdisk/ld.script
--- a/arch/mips/ramdisk/ld.script	2004-12-24 13:37:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,9 +0,0 @@
-OUTPUT_ARCH(mips)
-SECTIONS
-{
-  .initrd :
-  {
-       *(.data)
-  }
-}
-
diff -Nru a/arch/mips/sgi-ip22/ip22-berr.c b/arch/mips/sgi-ip22/ip22-berr.c
--- a/arch/mips/sgi-ip22/ip22-berr.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/sgi-ip22/ip22-berr.c	2004-12-24 13:36:49 -08:00
@@ -65,7 +65,7 @@
 			cpu_err_stat & SGIMC_CSTAT_BAD_DATA ? "BAD_DATA " : "",
 			cpu_err_addr);
 	if (gio_err_stat & GIO_ERRMASK)
-		printk(KERN_ERR "GIO error 0x%x:<%s%s%s%s%s%s%s%s> @ 0x08%x\n",
+		printk(KERN_ERR "GIO error 0x%x:<%s%s%s%s%s%s%s%s> @ 0x%08x\n",
 			gio_err_stat,
 			gio_err_stat & SGIMC_GSTAT_RD ? "RD " : "",
 			gio_err_stat & SGIMC_GSTAT_WR ? "WR " : "",
diff -Nru a/arch/mips/sgi-ip22/ip22-int.c b/arch/mips/sgi-ip22/ip22-int.c
--- a/arch/mips/sgi-ip22/ip22-int.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/sgi-ip22/ip22-int.c	2004-12-24 13:36:49 -08:00
@@ -309,7 +309,7 @@
 
 extern void mips_cpu_irq_init(unsigned int irq_base);
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	int i;
 
@@ -371,7 +371,6 @@
 
 	set_except_vector(0, indyIRQ);
 
-	init_generic_irq();
 	/* init CPU irqs */
 	mips_cpu_irq_init(SGINT_CPU);
 
diff -Nru a/arch/mips/sgi-ip22/ip22-setup.c b/arch/mips/sgi-ip22/ip22-setup.c
--- a/arch/mips/sgi-ip22/ip22-setup.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/sgi-ip22/ip22-setup.c	2004-12-24 13:36:17 -08:00
@@ -29,12 +29,6 @@
 #include <asm/sgi/hpc3.h>
 #include <asm/sgi/ip22.h>
 
-#ifdef CONFIG_KGDB
-extern void rs_kgdb_hook(int);
-extern void breakpoint(void);
-static int remote_debug = 0;
-#endif
-
 unsigned long sgi_gfxaddr;
 
 /*
@@ -43,7 +37,6 @@
  *
  * FIXME: provide a mechanism to change the value of stop_a_enabled.
  */
-int serial_console;
 int stop_a_enabled;
 
 void ip22_do_break(void)
@@ -63,9 +56,6 @@
 static int __init ip22_setup(void)
 {
 	char *ctype;
-#ifdef CONFIG_KGDB
-	char *kgdb_ttyd;
-#endif
 
 	board_be_init = ip22_be_init;
 	ip22_time_init();
@@ -84,9 +74,10 @@
 	indy_sc_init();
 #endif
 
-	/* Set EISA IO port base for Indigo2 */
-	set_io_port_base(KSEG1ADDR(0x00080000));
-
+	/* Set EISA IO port base for Indigo2
+	 * ioremap cannot fail */
+	set_io_port_base((unsigned long)ioremap(0x00080000,
+						0x1fffffff - 0x00080000));
 	/* ARCS console environment variable is set to "g?" for
 	 * graphics console, it is set to "d" for the first serial
 	 * line and "d2" for the second serial line.
@@ -106,7 +97,9 @@
 	}
 
 #ifdef CONFIG_KGDB
-	kgdb_ttyd = prom_getcmdline();
+	{
+	char *kgdb_ttyd = prom_getcmdline();
+
 	if ((kgdb_ttyd = strstr(kgdb_ttyd, "kgdb=ttyd")) != NULL) {
 		int line;
 		kgdb_ttyd += strlen("kgdb=ttyd");
@@ -121,8 +114,9 @@
 		printk(KERN_INFO "KGDB: Using serial line /dev/ttyd%d for "
 		       "session, please connect your debugger\n", line ? 1:2);
 
-		remote_debug = 1;
+		kgdb_enabled = 1;
 		/* Breakpoints and stuff are in sgi_irq_setup() */
+	}
 	}
 #endif
 
diff -Nru a/arch/mips/sgi-ip27/ip27-hubio.c b/arch/mips/sgi-ip27/ip27-hubio.c
--- a/arch/mips/sgi-ip27/ip27-hubio.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/sgi-ip27/ip27-hubio.c	2004-12-24 13:37:18 -08:00
@@ -8,6 +8,7 @@
 
 #include <linux/bitops.h>
 #include <linux/string.h>
+#include <linux/mmzone.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/arch.h>
 #include <asm/sn/hub.h>
@@ -44,7 +45,7 @@
 
 	xtalk_addr &= ~(BWIN_SIZE-1);
 	for (i = 0; i < HUB_NUM_BIG_WINDOW; i++) {
-		if (test_and_set_bit(i, HUB_DATA(cnode)->h_bigwin_used))
+		if (test_and_set_bit(i, hub_data(cnode)->h_bigwin_used))
 			continue;
 
 		/*
@@ -177,7 +178,7 @@
 	unsigned i;
 
 	/* initialize big window piomaps for this hub */
-	bitmap_zero(HUB_DATA(cnode)->h_bigwin_used, HUB_NUM_BIG_WINDOW);
+	bitmap_zero(hub_data(cnode)->h_bigwin_used, HUB_NUM_BIG_WINDOW);
 	for (i = 0; i < HUB_NUM_BIG_WINDOW; i++)
 		IIO_ITTE_DISABLE(nasid, i);
 
diff -Nru a/arch/mips/sgi-ip27/ip27-init.c b/arch/mips/sgi-ip27/ip27-init.c
--- a/arch/mips/sgi-ip27/ip27-init.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/sgi-ip27/ip27-init.c	2004-12-24 13:37:29 -08:00
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/mmzone.h>	/* for numnodes */
 #include <linux/mm.h>
+#include <linux/module.h>
 #include <linux/cpumask.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
@@ -40,90 +41,25 @@
 #define CPU_NONE		(cpuid_t)-1
 
 static DECLARE_BITMAP(hub_init_mask, MAX_COMPACT_NODES);
-static hubreg_t region_mask;
-static int	fine_mode;
-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];
 
-static hubreg_t get_region(cnodeid_t cnode)
-{
-	if (fine_mode)
-		return COMPACT_TO_NASID_NODEID(cnode) >> NASID_TO_FINEREG_SHFT;
-	else
-		return COMPACT_TO_NASID_NODEID(cnode) >> NASID_TO_COARSEREG_SHFT;
-}
-
-static void gen_region_mask(hubreg_t *region_mask, int maxnodes)
-{
-	cnodeid_t cnode;
-
-	(*region_mask) = 0;
-	for (cnode = 0; cnode < maxnodes; cnode++) {
-		(*region_mask) |= 1ULL << get_region(cnode);
-	}
-}
-
-static int is_fine_dirmode(void)
-{
-	return (((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK)
-		>> NSRI_REGIONSIZE_SHFT) & REGIONSIZE_FINE);
-}
+EXPORT_SYMBOL(nasid_to_compact_node);
 
 extern void pcibr_setup(cnodeid_t);
 
-static __init void per_slice_init(cnodeid_t cnode, int slice)
-{
-	struct slice_data *si = hub_data[cnode]->slice + slice;
-	int cpu = smp_processor_id();
-	int i;
-
-	for (i = 0; i < LEVELS_PER_SLICE; i++)
-		si->level_to_irq[i] = -1;
-	/*
-	 * Some interrupts are reserved by hardware or by software convention.
-	 * Mark these as reserved right away so they won't be used accidently
-	 * later.
-	 */
-	for (i = 0; i <= BASE_PCI_IRQ; i++) {
-		__set_bit(i, si->irq_alloc_mask);
-		LOCAL_HUB_S(PI_INT_PEND_MOD, i);
-	}
-
-	__set_bit(IP_PEND0_6_63, si->irq_alloc_mask);
-	LOCAL_HUB_S(PI_INT_PEND_MOD, IP_PEND0_6_63);
-
-	for (i = NI_BRDCAST_ERR_A; i <= MSC_PANIC_INTR; i++) {
-		__set_bit(i, si->irq_alloc_mask + 1);
-		LOCAL_HUB_S(PI_INT_PEND_MOD, i);
-	}
-
-	LOCAL_HUB_L(PI_INT_PEND0);
-
-	/*
-	 * We use this so we can find the local hub's data as fast as only
-	 * possible.
-	 */
-	cpu_data[cpu].data = si;
-}
-
 extern void xtalk_probe_node(cnodeid_t nid);
 
-void __init per_hub_init(cnodeid_t cnode)
+static void __init per_hub_init(cnodeid_t cnode)
 {
-	struct hub_data *hub = HUB_DATA(cnode);
+	struct hub_data *hub = hub_data(cnode);
 	nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode);
-	int slice = LOCAL_HUB_L(PI_CPU_NUM);
 
 	cpu_set(smp_processor_id(), hub->h_cpus);
 
-	if (!test_and_set_bit(slice, &hub->slice_map))
-		per_slice_init(cnode, slice);
-
 	if (test_and_set_bit(cnode, hub_init_mask))
 		return;
 
@@ -142,13 +78,13 @@
 	 * copy over the caliased exception handlers.
 	 */
 	if (get_compact_nodeid() == cnode) {
-		extern char except_vec0, except_vec1_r10k;
+		extern char except_vec0, except_vec1_r4k;
 		extern char except_vec2_generic, except_vec3_generic;
 
 		memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80);
 		memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80);
 		memcpy((void *)KSEG0, &except_vec0, 0x80);
-		memcpy((void *)KSEG0 + 0x080, &except_vec1_r10k, 0x80);
+		memcpy((void *)KSEG0 + 0x080, &except_vec1_r4k, 0x80);
 		memcpy((void *)(KSEG0 + 0x100), (void *) KSEG0, 0x80);
 		memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x100);
 		__flush_cache_all();
@@ -156,260 +92,76 @@
 #endif
 }
 
-/*
- * get_nasid() returns the physical node id number of the caller.
- */
-nasid_t
-get_nasid(void)
-{
-	return (nasid_t)((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_NODEID_MASK)
-	                 >> NSRI_NODEID_SHFT);
-}
-
-/*
- * Map the physical node id to a virtual node id (virtual node ids are contiguous).
- */
-cnodeid_t get_compact_nodeid(void)
-{
-	return NASID_TO_COMPACT_NODEID(get_nasid());
-}
-
-#define	rou_rflag	rou_flags
-
-static void router_recurse(klrou_t *router_a, klrou_t *router_b, int depth)
+void __init per_cpu_init(void)
 {
-	klrou_t *router;
-	lboard_t *brd;
-	int	port;
+	int cpu = smp_processor_id();
+	int slice = LOCAL_HUB_L(PI_CPU_NUM);
+	cnodeid_t cnode = get_compact_nodeid();
+	struct hub_data *hub = hub_data(cnode);
+	struct slice_data *si = hub->slice + slice;
+	int i;
 
-	if (router_a->rou_rflag == 1)
+	if (test_and_set_bit(slice, &hub->slice_map))
 		return;
 
-	if (depth >= router_distance)
-		return;
+	clear_c0_status(ST0_IM);
 
-	router_a->rou_rflag = 1;
+	for (i = 0; i < LEVELS_PER_SLICE; i++)
+		si->level_to_irq[i] = -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);
-		}
+	/*
+	 * Some interrupts are reserved by hardware or by software convention.
+	 * Mark these as reserved right away so they won't be used accidently
+	 * later.
+	 */
+	for (i = 0; i <= BASE_PCI_IRQ; i++) {
+		__set_bit(i, si->irq_alloc_mask);
+		LOCAL_HUB_S(PI_INT_PEND_MOD, i);
 	}
 
-	router_a->rou_rflag = 0;
-}
-
-int node_distance(nasid_t nasid_a, nasid_t nasid_b)
-{
-	klrou_t *router, *router_a = NULL, *router_b = NULL;
-	lboard_t *brd, *dest_brd;
-	cnodeid_t cnode;
-	nasid_t nasid;
-	int port;
-
-	/* 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)));
-	}
+	__set_bit(IP_PEND0_6_63, si->irq_alloc_mask);
+	LOCAL_HUB_S(PI_INT_PEND_MOD, IP_PEND0_6_63);
 
-	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;
+	for (i = NI_BRDCAST_ERR_A; i <= MSC_PANIC_INTR; i++) {
+		__set_bit(i, si->irq_alloc_mask + 1);
+		LOCAL_HUB_S(PI_INT_PEND_MOD, i);
 	}
 
-	if (nasid_a == nasid_b)
-		return 0;
+	LOCAL_HUB_L(PI_INT_PEND0);
 
-	if (router_a == router_b)
-		return 1;
+	/*
+	 * We use this so we can find the local hub's data as fast as only
+	 * possible.
+	 */
+	cpu_data[cpu].data = si;
 
-	router_distance = 100;
-	router_recurse(router_a, router_b, 2);
+	cpu_time_init();
+	install_ipi();
 
-	return router_distance;
-}
+	/* Install our NMI handler if symmon hasn't installed one. */
+	install_cpu_nmi_handler(cputoslice(cpu));
 
-static void init_topology_matrix(void)
-{
-	nasid_t nasid, nasid2;
-	cnodeid_t row, col;
+	set_c0_status(SRB_DEV0 | SRB_DEV1);
 
-	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);
-		}
-	}
+	per_hub_init(cnode);
 }
 
-static void dump_topology(void)
+/*
+ * get_nasid() returns the physical node id number of the caller.
+ */
+nasid_t
+get_nasid(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)) );
-	}
+	return (nasid_t)((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_NODEID_MASK)
+	                 >> NSRI_NODEID_SHFT);
 }
 
-void mlreset(void)
+/*
+ * Map the physical node id to a virtual node id (virtual node ids are contiguous).
+ */
+cnodeid_t get_compact_nodeid(void)
 {
-	int i;
-
-	master_nasid = get_nasid();
-	fine_mode = is_fine_dirmode();
-
-	/*
-	 * Probe for all CPUs - this creates the cpumask and sets up the
-	 * mapping tables.  We need to do this as early as possible.
-	 */
-#ifdef CONFIG_SMP
-	cpu_node_probe();
-#endif
-
-	init_topology_matrix();
-	dump_topology();
-
-	gen_region_mask(&region_mask, numnodes);
-
-	setup_replication_mask(numnodes);
-
-	/*
-	 * Set all nodes' calias sizes to 8k
-	 */
-	for (i = 0; i < numnodes; i++) {
-		nasid_t nasid;
-
-		nasid = COMPACT_TO_NASID_NODEID(i);
-
-		/*
-		 * Always have node 0 in the region mask, otherwise
-		 * CALIAS accesses get exceptions since the hub
-		 * thinks it is a node 0 address.
-		 */
-		REMOTE_HUB_S(nasid, PI_REGION_PRESENT, (region_mask | 1));
-#ifdef CONFIG_REPLICATE_EXHANDLERS
-		REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K);
-#else
-		REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_0);
-#endif
-
-#ifdef LATER
-		/*
-		 * Set up all hubs to have a big window pointing at
-		 * widget 0. Memory mode, widget 0, offset 0
-		 */
-		REMOTE_HUB_S(nasid, IIO_ITTE(SWIN0_BIGWIN),
-			((HUB_PIO_MAP_TO_MEM << IIO_ITTE_IOSP_SHIFT) |
-			(0 << IIO_ITTE_WIDGET_SHIFT)));
-#endif
-	}
+	return NASID_TO_COMPACT_NODEID(get_nasid());
 }
 
 /* Extracted from the IOC3 meta driver.  FIXME.  */
@@ -442,20 +194,6 @@
 	ioc3 = (struct ioc3 *) KL_CONFIG_CH_CONS_INFO(nid)->memory_base;
 
 	ioc3->eier = 0;
-}
-
-void __init per_cpu_init(void)
-{
-	cnodeid_t cnode = get_compact_nodeid();
-	int cpu = smp_processor_id();
-
-	clear_c0_status(ST0_IM);
-	per_hub_init(cnode);
-	cpu_time_init();
-	install_ipi();
-	/* Install our NMI handler if symmon hasn't installed one. */
-	install_cpu_nmi_handler(cputoslice(cpu));
-	set_c0_status(SRB_DEV0 | SRB_DEV1);
 }
 
 extern void ip27_setup_console(void);
diff -Nru a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
--- a/arch/mips/sgi-ip27/ip27-irq.c	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/sgi-ip27/ip27-irq.c	2004-12-24 13:36:55 -08:00
@@ -14,14 +14,15 @@
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
+#include <linux/irq.h>
 #include <linux/timex.h>
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/smp_lock.h>
 #include <linux/kernel_stat.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/mipsregs.h>
@@ -151,9 +152,6 @@
 	if (!pend0)
 		return;
 
-	/* Prevent any of the picked intrs from recursing */
-	LOCAL_HUB_S(pi_int_mask0, mask0 & ~pend0);
-
 	swlevel = ms1bit(pend0);
 #ifdef CONFIG_SMP
 	if (pend0 & (1UL << CPU_RESCHED_A_IRQ)) {
@@ -176,11 +174,6 @@
 		do_IRQ(irq, regs);
 	}
 
-	/* clear bit in pend0 */
-	pend0 ^= 1UL << swlevel;
-
-	/* Now allow the set of serviced intrs again */
-	LOCAL_HUB_S(pi_int_mask0, mask0);
 	LOCAL_HUB_L(PI_INT_PEND0);
 }
 
@@ -200,19 +193,12 @@
 	if (!pend1)
 		return;
 
-	/* Prevent any of the picked intrs from recursing */
-	LOCAL_HUB_S(pi_int_mask1, mask1 & ~pend1);
-
 	swlevel = ms1bit(pend1);
 	/* "map" swlevel to irq */
 	irq = si->level_to_irq[swlevel];
 	LOCAL_HUB_CLR_INTR(swlevel);
 	do_IRQ(irq, regs);
-	/* clear bit in pend1 */
-	pend1 ^= 1UL << swlevel;
 
-	/* Now allow the set of serviced intrs again */
-	LOCAL_HUB_S(pi_int_mask1, mask1);
 	LOCAL_HUB_L(PI_INT_PEND1);
 }
 
@@ -233,9 +219,6 @@
 
 	__set_bit(bit, si->irq_enable_mask);
 
-	/* Make sure it's not already pending when we connect it. */
-	REMOTE_HUB_CLR_INTR(nasid, bit);
-
 	if (!cputoslice(cpu)) {
 		REMOTE_HUB_S(nasid, PI_INT_MASK0_A, si->irq_enable_mask[0]);
 		REMOTE_HUB_S(nasid, PI_INT_MASK1_A, si->irq_enable_mask[1]);
@@ -272,6 +255,7 @@
 	bridgereg_t device;
 	bridge_t *bridge;
 	int pin, swlevel;
+	cpuid_t cpu;
 
 	pin = SLOT_FROM_PCI_IRQ(irq);
 	bc = IRQ_TO_BRIDGE(irq);
@@ -282,13 +266,10 @@
 	 * "map" irq to a swlevel greater than 6 since the first 6 bits
 	 * of INT_PEND0 are taken
 	 */
-	swlevel = alloc_level(bc->irq_cpu, irq);
-	intr_connect_level(bc->irq_cpu, swlevel);
-
+	swlevel = find_level(&cpu, irq);
 	bridge->b_int_addr[pin].addr = (0x20000 | swlevel | (bc->nasid << 8));
 	bridge->b_int_enable |= (1 << pin);
-	/* more stuff in int_enable reg */
-	bridge->b_int_enable |= 0x7ffffe00;
+	bridge->b_int_enable |= 0x7ffffe00;	/* more stuff in int_enable */
 
 	/*
 	 * Enable sending of an interrupt clear packt to the hub on a high to
@@ -308,7 +289,7 @@
 	device |= (pin << (pin*3));
 	bridge->b_int_device = device;
 
-        bridge->b_widget.w_tflush;                      /* Flush */
+        bridge->b_wid_tflush;
 
         return 0;       /* Never anything pending.  */
 }
@@ -336,26 +317,37 @@
 	si->level_to_irq[swlevel] = -1;
 
 	bridge->b_int_enable &= ~(1 << pin);
-	bridge->b_widget.w_tflush;                      /* Flush */
+	bridge->b_wid_tflush;
 }
 
 static inline void enable_bridge_irq(unsigned int irq)
 {
-	/* All the braindamage happens magically for us in ip27_do_irq */
+	cpuid_t cpu;
+	int swlevel;
+
+	swlevel = find_level(&cpu, irq);	/* Criminal offence */
+	intr_connect_level(cpu, swlevel);
 }
 
-static void disable_bridge_irq(unsigned int irq)
+static inline void disable_bridge_irq(unsigned int irq)
 {
-	/* All the braindamage happens magically for us in ip27_do_irq */
+	cpuid_t cpu;
+	int swlevel;
+
+	swlevel = find_level(&cpu, irq);	/* Criminal offence */
+	intr_disconnect_level(cpu, swlevel);
 }
 
 static void mask_and_ack_bridge_irq(unsigned int irq)
 {
-	/* All the braindamage happens magically for us in ip27_do_irq */
+	disable_bridge_irq(irq);
 }
 
 static void end_bridge_irq(unsigned int irq)
 {
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)) &&
+	    irq_desc[irq].action)
+		enable_bridge_irq(irq);
 }
 
 static struct hw_interrupt_type bridge_irq_type = {
@@ -370,15 +362,15 @@
 
 static unsigned long irq_map[NR_IRQS / BITS_PER_LONG];
 
-unsigned int allocate_irqno(void)
+static int allocate_irqno(void)
 {
 	int irq;
 
 again:
-	irq = find_first_zero_bit(irq_map, LEVELS_PER_SLICE);
+	irq = find_first_zero_bit(irq_map, NR_IRQS);
 
 	if (irq >= NR_IRQS)
-		return -1;
+		return -ENOSPC;
 
 	if (test_and_set_bit(irq, irq_map))
 		goto again;
@@ -391,21 +383,49 @@
 	clear_bit(irq, irq_map);
 }
 
-void __init init_IRQ(void)
+void __devinit register_bridge_irq(unsigned int irq)
 {
-	int i;
+	irq_desc[irq].status	= IRQ_DISABLED;
+	irq_desc[irq].action	= 0;
+	irq_desc[irq].depth	= 1;
+	irq_desc[irq].handler	= &bridge_irq_type;
+}
 
-	set_except_vector(0, ip27_irq);
+int __devinit request_bridge_irq(struct bridge_controller *bc)
+{
+	int irq = allocate_irqno();
+	int swlevel, cpu;
+	nasid_t nasid;
+
+	if (irq < 0)
+		return irq;
 
 	/*
-	 * Right now the bridge irq is our kitchen sink interrupt type
+	 * "map" irq to a swlevel greater than 6 since the first 6 bits
+	 * of INT_PEND0 are taken
 	 */
-	for (i = 0; i <= NR_IRQS; i++) {
-		irq_desc[i].status	= IRQ_DISABLED;
-		irq_desc[i].action	= 0;
-		irq_desc[i].depth	= 1;
-		irq_desc[i].handler	= &bridge_irq_type;
+	cpu = bc->irq_cpu;
+	swlevel = alloc_level(cpu, irq);
+	if (unlikely(swlevel < 0)) {
+		free_irqno(irq);
+
+		return -EAGAIN;
 	}
+
+	/* Make sure it's not already pending when we connect it. */
+	nasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu));
+	REMOTE_HUB_CLR_INTR(nasid, swlevel);
+
+	intr_connect_level(cpu, swlevel);
+
+	register_bridge_irq(irq);
+
+	return irq;
+}
+
+void __init arch_init_irq(void)
+{
+	set_except_vector(0, ip27_irq);
 }
 
 void install_ipi(void)
diff -Nru a/arch/mips/sgi-ip27/ip27-klnuma.c b/arch/mips/sgi-ip27/ip27-klnuma.c
--- a/arch/mips/sgi-ip27/ip27-klnuma.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/sgi-ip27/ip27-klnuma.c	2004-12-24 13:36:47 -08:00
@@ -61,12 +61,12 @@
 
 static __init void set_ktext_source(nasid_t client_nasid, nasid_t server_nasid)
 {
-	kern_vars_t *kvp;
 	cnodeid_t client_cnode;
+	kern_vars_t *kvp;
 
 	client_cnode = NASID_TO_COMPACT_NODEID(client_nasid);
 
-	kvp = &(HUB_DATA(client_nasid)->kern_vars);
+	kvp = &hub_data(client_nasid)->kern_vars;
 
 	KERN_VARS_ADDR(client_nasid) = (unsigned long)kvp;
 
diff -Nru a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
--- a/arch/mips/sgi-ip27/ip27-memory.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/sgi-ip27/ip27-memory.c	2004-12-24 13:36:31 -08:00
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/mmzone.h>
+#include <linux/module.h>
 #include <linux/swap.h>
 #include <linux/bootmem.h>
 #include <asm/page.h>
@@ -36,8 +37,226 @@
 static unsigned short __initdata slot_psize_cache[MAX_COMPACT_NODES][MAX_MEM_SLOTS];
 static struct bootmem_data __initdata plat_node_bdata[MAX_COMPACT_NODES];
 
-struct pglist_data *node_data[MAX_COMPACT_NODES];
-struct hub_data *hub_data[MAX_COMPACT_NODES];
+struct node_data *__node_data[MAX_COMPACT_NODES];
+
+EXPORT_SYMBOL(__node_data);
+
+static int fine_mode;
+
+static int is_fine_dirmode(void)
+{
+	return (((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK)
+	        >> NSRI_REGIONSIZE_SHFT) & REGIONSIZE_FINE);
+}
+
+static hubreg_t get_region(cnodeid_t cnode)
+{
+	if (fine_mode)
+		return COMPACT_TO_NASID_NODEID(cnode) >> NASID_TO_FINEREG_SHFT;
+	else
+		return COMPACT_TO_NASID_NODEID(cnode) >> NASID_TO_COARSEREG_SHFT;
+}
+
+static hubreg_t region_mask;
+
+static void gen_region_mask(hubreg_t *region_mask, int maxnodes)
+{
+	cnodeid_t cnode;
+
+	(*region_mask) = 0;
+	for (cnode = 0; cnode < maxnodes; cnode++) {
+		(*region_mask) |= 1ULL << get_region(cnode);
+	}
+}
+
+#define	rou_rflag	rou_flags
+
+static int router_distance;
+
+static 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;
+}
+
+unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES];
+
+static int __init compute_node_distance(nasid_t nasid_a, nasid_t nasid_b)
+{
+	klrou_t *router, *router_a = NULL, *router_b = NULL;
+	lboard_t *brd, *dest_brd;
+	cnodeid_t cnode;
+	nasid_t nasid;
+	int port;
+
+	/* 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;
+}
+
+static void __init 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] =
+				compute_node_distance(nasid, nasid2);
+		}
+	}
+}
+
+static void __init 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_distance(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)) );
+	}
+}
 
 static pfn_t __init slot_getbasepfn(cnodeid_t cnode, int slot)
 {
@@ -126,6 +345,60 @@
 	}
 }
 
+static void __init mlreset(void)
+{
+	int i;
+
+	master_nasid = get_nasid();
+	fine_mode = is_fine_dirmode();
+
+	/*
+	 * Probe for all CPUs - this creates the cpumask and sets up the
+	 * mapping tables.  We need to do this as early as possible.
+	 */
+#ifdef CONFIG_SMP
+	cpu_node_probe();
+#endif
+
+	init_topology_matrix();
+	dump_topology();
+
+	gen_region_mask(&region_mask, numnodes);
+
+	setup_replication_mask(numnodes);
+
+	/*
+	 * Set all nodes' calias sizes to 8k
+	 */
+	for (i = 0; i < numnodes; i++) {
+		nasid_t nasid;
+
+		nasid = COMPACT_TO_NASID_NODEID(i);
+
+		/*
+		 * Always have node 0 in the region mask, otherwise
+		 * CALIAS accesses get exceptions since the hub
+		 * thinks it is a node 0 address.
+		 */
+		REMOTE_HUB_S(nasid, PI_REGION_PRESENT, (region_mask | 1));
+#ifdef CONFIG_REPLICATE_EXHANDLERS
+		REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K);
+#else
+		REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_0);
+#endif
+
+#ifdef LATER
+		/*
+		 * Set up all hubs to have a big window pointing at
+		 * widget 0. Memory mode, widget 0, offset 0
+		 */
+		REMOTE_HUB_S(nasid, IIO_ITTE(SWIN0_BIGWIN),
+			((HUB_PIO_MAP_TO_MEM << IIO_ITTE_IOSP_SHIFT) |
+			(0 << IIO_ITTE_WIDGET_SHIFT)));
+#endif
+	}
+}
+
 static void __init szmem(void)
 {
 	pfn_t slot_psize, slot0sz = 0, nodebytes;	/* Hack to detect problem configs */
@@ -164,6 +437,45 @@
 	}
 }
 
+static void __init node_mem_init(cnodeid_t node)
+{
+	pfn_t slot_firstpfn = slot_getbasepfn(node, 0);
+	pfn_t slot_lastpfn = slot_firstpfn + slot_getsize(node, 0);
+	pfn_t slot_freepfn = node_getfirstfree(node);
+	struct pglist_data *pd;
+	unsigned long bootmap_size;
+
+	/*
+	 * Allocate the node data structures on the node first.
+	 */
+	__node_data[node] = __va(slot_freepfn << PAGE_SHIFT);
+
+	pd = NODE_DATA(node);
+	pd->bdata = &plat_node_bdata[node];
+
+	cpus_clear(hub_data(node)->h_cpus);
+
+	slot_freepfn += PFN_UP(sizeof(struct pglist_data) +
+			       sizeof(struct hub_data));
+
+  	bootmap_size = init_bootmem_node(NODE_DATA(node), slot_freepfn,
+					slot_firstpfn, slot_lastpfn);
+	free_bootmem_node(NODE_DATA(node), slot_firstpfn << PAGE_SHIFT,
+			(slot_lastpfn - slot_firstpfn) << PAGE_SHIFT);
+	reserve_bootmem_node(NODE_DATA(node), slot_firstpfn << PAGE_SHIFT,
+		((slot_freepfn - slot_firstpfn) << PAGE_SHIFT) + bootmap_size);
+}
+
+/*
+ * A node with nothing.  We use it to avoid any special casing in
+ * node_to_cpumask
+ */
+static struct node_data null_node = {
+	.hub = {
+		.h_cpus = CPU_MASK_NONE
+	}
+};
+
 /*
  * Currently, the intranode memory hole support assumes that each slot
  * contains at least 32 MBytes of memory. We assume all bootmem data
@@ -176,31 +488,12 @@
 	mlreset();
 	szmem();
 
-	for (node = 0; node < numnodes; node++) {
-		pfn_t slot_firstpfn = slot_getbasepfn(node, 0);
-		pfn_t slot_lastpfn = slot_firstpfn + slot_getsize(node, 0);
-		pfn_t slot_freepfn = node_getfirstfree(node);
-		unsigned long bootmap_size;
-
-		/*
-		 * Allocate the node data structures on the node first.
-		 */
-		node_data[node] = __va(slot_freepfn << PAGE_SHIFT);
-		node_data[node]->bdata = &plat_node_bdata[node];
-
-		hub_data[node] = (struct hub_data *)(node_data[node] + 1);
-
-		cpus_clear(hub_data[node]->h_cpus);
-
-		slot_freepfn += PFN_UP(sizeof(struct pglist_data) +
-				       sizeof(struct hub_data));
-	
-	  	bootmap_size = init_bootmem_node(NODE_DATA(node), slot_freepfn,
-						slot_firstpfn, slot_lastpfn);
-		free_bootmem_node(NODE_DATA(node), slot_firstpfn << PAGE_SHIFT,
-				(slot_lastpfn - slot_firstpfn) << PAGE_SHIFT);
-		reserve_bootmem_node(NODE_DATA(node), slot_firstpfn << PAGE_SHIFT,
-		  ((slot_freepfn - slot_firstpfn) << PAGE_SHIFT) + bootmap_size);
+	for (node = 0; node < MAX_COMPACT_NODES; node++) {
+		if (node < numnodes) {
+			node_mem_init(node);
+			continue;
+		}
+		__node_data[node] = &null_node;
 	}
 }
 
diff -Nru a/arch/mips/sgi-ip27/ip27-smp.c b/arch/mips/sgi-ip27/ip27-smp.c
--- a/arch/mips/sgi-ip27/ip27-smp.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/sgi-ip27/ip27-smp.c	2004-12-24 13:37:00 -08:00
@@ -122,10 +122,6 @@
 	printk("Discovered %d cpus on %d nodes\n", highest + 1, numnodes);
 }
 
-void __init prom_build_cpu_map(void)
-{
-}
-
 static void intr_clear_bits(nasid_t nasid, volatile hubreg_t *pend,
 	int base_level)
 {
@@ -157,9 +153,6 @@
 
 	for (cnode = 0; cnode < numnodes; cnode++)
 		intr_clear_all(COMPACT_TO_NASID_NODEID(cnode));
-
-	/* Master has already done per_cpu_init() */
-	install_ipi();
 
 	replicate_kernel_text(numnodes);
 
diff -Nru a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
--- a/arch/mips/sgi-ip27/ip27-timer.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/sgi-ip27/ip27-timer.c	2004-12-24 13:36:47 -08:00
@@ -112,9 +112,7 @@
 	if (cpu == 0)
 		do_timer(regs);
 
-#ifdef CONFIG_SMP
 	update_process_times(user_mode(regs));
-#endif /* CONFIG_SMP */
 
 	/*
 	 * If we have an externally synchronized Linux clock, then update
diff -Nru a/arch/mips/sgi-ip32/crime.c b/arch/mips/sgi-ip32/crime.c
--- a/arch/mips/sgi-ip32/crime.c	2004-12-24 13:36:19 -08:00
+++ b/arch/mips/sgi-ip32/crime.c	2004-12-24 13:36:19 -08:00
@@ -10,13 +10,14 @@
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
 #include <asm/bootinfo.h>
+#include <asm/io.h>
 #include <asm/mipsregs.h>
 #include <asm/ptrace.h>
 #include <asm/page.h>
 #include <asm/ip32/crime.h>
 #include <asm/ip32/mace.h>
 
-void *sgi_crime;
+struct sgi_crime *crime;
 struct sgi_mace *mace;
 
 void __init crime_init(void)
@@ -24,13 +25,12 @@
 	unsigned int id, rev;
 	const int field = 2 * sizeof(unsigned long);
 	
-	sgi_crime = ioremap(CRIME_BASE, 1);
+	crime = ioremap(CRIME_BASE, sizeof(struct sgi_crime));
 	mace = ioremap(MACE_BASE, sizeof(struct sgi_mace));
 
-	id = crime_read(CRIME_ID);
+	id = crime->id;
 	rev = id & CRIME_ID_REV;
 	id = (id & CRIME_ID_IDBITS) >> 4;
-
 	printk (KERN_INFO "CRIME id %1x rev %d at 0x%0*lx\n",
 		id, rev, field, (unsigned long) CRIME_BASE);
 }
@@ -41,19 +41,18 @@
 	unsigned long stat, addr;
 	int fatal = 0;
 
-	stat = crime_read(CRIME_MEM_ERROR_STAT) & CRIME_MEM_ERROR_STAT_MASK;
-	addr = crime_read(CRIME_MEM_ERROR_ADDR) & CRIME_MEM_ERROR_ADDR_MASK;
+	stat = crime->mem_error_stat & CRIME_MEM_ERROR_STAT_MASK;
+	addr = crime->mem_error_addr & CRIME_MEM_ERROR_ADDR_MASK;
 
 	printk("CRIME memory error at 0x%08lx ST 0x%08lx<", addr, stat);
 
 	if (stat & CRIME_MEM_ERROR_INV)
 		printk("INV,");
 	if (stat & CRIME_MEM_ERROR_ECC) {
-		unsigned long ecc_syn = crime_read(CRIME_MEM_ERROR_ECC_SYN) &
-					CRIME_MEM_ERROR_ECC_SYN_MASK;
-		unsigned long ecc_gen = crime_read(CRIME_MEM_ERROR_ECC_CHK) &
-					CRIME_MEM_ERROR_ECC_CHK_MASK;
-
+		unsigned long ecc_syn =
+			crime->mem_ecc_syn & CRIME_MEM_ERROR_ECC_SYN_MASK;
+		unsigned long ecc_gen =
+			crime->mem_ecc_chk & CRIME_MEM_ERROR_ECC_CHK_MASK;
 		printk("ECC,SYN=0x%08lx,GEN=0x%08lx,", ecc_syn, ecc_gen);
 	}
 	if (stat & CRIME_MEM_ERROR_MULTIPLE) {
@@ -77,7 +76,7 @@
 	if (stat & CRIME_MEM_ERROR_MACE_ACCESS)
 		printk("MACE,MACEID=0x%02lx,", stat & CRIME_MEM_ERROR_MACE_ID);
 
-	crime_write(0, CRIME_MEM_ERROR_STAT);
+	crime->mem_error_stat = 0;
 
 	if (fatal) {
 		printk("FATAL>\n");
@@ -91,15 +90,12 @@
 irqreturn_t
 crime_cpuerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs)
 {
-	unsigned long stat = crime_read(CRIME_CPU_ERROR_STAT) &
-			     CRIME_CPU_ERROR_MASK;
-	uint64_t addr = crime_read(CRIME_CPU_ERROR_ADDR) &
-			CRIME_CPU_ERROR_ADDR_MASK;
-	addr <<= 2;
+	unsigned long stat = crime->cpu_error_stat & CRIME_CPU_ERROR_MASK;
+	unsigned long addr = crime->cpu_error_addr & CRIME_CPU_ERROR_ADDR_MASK;
 
+	addr <<= 2;
 	printk ("CRIME CPU error at 0x%09lx status 0x%08lx\n", addr, stat);
-
-	crime_write(0, CRIME_CPU_ERROR_STAT);
+	crime->cpu_error_stat = 0;
 
 	return IRQ_HANDLED;
 }
diff -Nru a/arch/mips/sgi-ip32/ip32-irq.c b/arch/mips/sgi-ip32/ip32-irq.c
--- a/arch/mips/sgi-ip32/ip32-irq.c	2004-12-24 13:36:55 -08:00
+++ b/arch/mips/sgi-ip32/ip32-irq.c	2004-12-24 13:36:55 -08:00
@@ -20,7 +20,6 @@
 #include <linux/random.h>
 #include <linux/sched.h>
 
-#include <asm/bitops.h>
 #include <asm/mipsregs.h>
 #include <asm/signal.h>
 #include <asm/system.h>
@@ -30,10 +29,14 @@
 #include <asm/ip32/ip32_ints.h>
 
 /* issue a PIO read to make sure no PIO writes are pending */
-#define flush_crime_bus() crime_read(CRIME_CONTROL);
+static void inline flush_crime_bus(void)
+{
+	volatile unsigned long junk = crime->control;
+}
+
 static void inline flush_mace_bus(void)
 {
-	volatile unsigned long junk = mace_perif_ctrl_read(misc);
+	volatile unsigned long junk = mace->perif.ctrl.misc;
 }
 
 #undef DEBUG_IRQ
@@ -183,7 +186,7 @@
 
 	spin_lock_irqsave(&ip32_irq_lock, flags);
 	crime_mask |= 1 << (irq - 1);
-	crime_write(crime_mask, CRIME_INT_MASK);
+	crime->imask = crime_mask;
 	spin_unlock_irqrestore(&ip32_irq_lock, flags);
 }
 
@@ -199,7 +202,7 @@
 
 	spin_lock_irqsave(&ip32_irq_lock, flags);
 	crime_mask &= ~(1 << (irq - 1));
-	crime_write(crime_mask, CRIME_INT_MASK);
+	crime->imask = crime_mask;
 	flush_crime_bus();
 	spin_unlock_irqrestore(&ip32_irq_lock, flags);
 }
@@ -214,9 +217,9 @@
 	    || (irq >= CRIME_SOFT0_IRQ && irq <= CRIME_SOFT2_IRQ)) {
 	        uint64_t crime_int;
 		spin_lock_irqsave(&ip32_irq_lock, flags);
-		crime_int = crime_read(CRIME_HARD_INT);
+		crime_int = crime->hard_int;
 		crime_int &= ~(1 << (irq - 1));
-		crime_write(crime_int, CRIME_HARD_INT);
+		crime->hard_int = crime_int;
 		spin_unlock_irqrestore(&ip32_irq_lock, flags);
 	}
 	disable_crime_irq(irq);
@@ -257,7 +260,7 @@
 	macepci_mask |= MACEPCI_CONTROL_INT(irq - 9);
 	mace->pci.control = macepci_mask;
 	crime_mask |= 1 << (irq - 1);
-	crime_write(crime_mask, CRIME_INT_MASK);
+	crime->imask = crime_mask;
 	spin_unlock_irqrestore(&ip32_irq_lock, flags);
 }
 
@@ -273,7 +276,7 @@
 
 	spin_lock_irqsave(&ip32_irq_lock, flags);
 	crime_mask &= ~(1 << (irq - 1));
-	crime_write(crime_mask, CRIME_INT_MASK);
+	crime->imask = crime_mask;
 	flush_crime_bus();
 	macepci_mask &= ~MACEPCI_CONTROL_INT(irq - 9);
 	mace->pci.control = macepci_mask;
@@ -361,9 +364,9 @@
 	DBG ("crime_int %08x enabled\n", crime_int);
 	spin_lock_irqsave(&ip32_irq_lock, flags);
 	crime_mask |= crime_int;
-	crime_write(crime_mask, CRIME_INT_MASK);
+	crime->imask = crime_mask;
 	maceisa_mask |= 1 << (irq - 33);
-	mace_perif_ctrl_write(maceisa_mask, imask);
+	mace->perif.ctrl.imask = maceisa_mask;
 	spin_unlock_irqrestore(&ip32_irq_lock, flags);
 }
 
@@ -387,9 +390,9 @@
         if(!(maceisa_mask & MACEISA_SUPERIO_INT))
 		crime_int |= MACE_SUPERIO_INT;
 	crime_mask &= ~crime_int;
-	crime_write(crime_mask, CRIME_INT_MASK);
+	crime->imask = crime_mask;
 	flush_crime_bus();
-	mace_perif_ctrl_write(maceisa_mask, imask);
+	mace->perif.ctrl.imask = maceisa_mask;
 	flush_mace_bus();
 	spin_unlock_irqrestore(&ip32_irq_lock, flags);
 }
@@ -404,9 +407,9 @@
 	case MACEISA_SERIAL2_TDMAPR_IRQ:
 		/* edge triggered */
 		spin_lock_irqsave(&ip32_irq_lock, flags);
-		mace_int = mace_perif_ctrl_read(istat);
+		mace_int = mace->perif.ctrl.istat;
 		mace_int &= ~(1 << (irq - 33));
-		mace_perif_ctrl_write(mace_int, istat);
+		mace->perif.ctrl.istat = mace_int;
 		spin_unlock_irqrestore(&ip32_irq_lock, flags);
 		break;
 	}
@@ -442,7 +445,7 @@
 
 	spin_lock_irqsave(&ip32_irq_lock, flags);
 	crime_mask |= 1 << (irq - 1);
-	crime_write(crime_mask, CRIME_INT_MASK);
+	crime->imask = crime_mask;
 	spin_unlock_irqrestore(&ip32_irq_lock, flags);
 }
 
@@ -458,7 +461,7 @@
 
 	spin_lock_irqsave(&ip32_irq_lock, flags);
 	crime_mask &= ~(1 << (irq - 1));
-	crime_write(crime_mask, CRIME_INT_MASK);
+	crime->imask = crime_mask;
 	flush_crime_bus();
 	spin_unlock_irqrestore(&ip32_irq_lock, flags);
 }
@@ -485,19 +488,14 @@
 
 static void ip32_unknown_interrupt(struct pt_regs *regs)
 {
-	uint64_t crime;
-
 	printk ("Unknown interrupt occurred!\n");
 	printk ("cp0_status: %08x\n", read_c0_status());
 	printk ("cp0_cause: %08x\n", read_c0_cause());
-	crime = crime_read(CRIME_INT_MASK);
-	printk ("CRIME intr mask: %016lx\n", crime);
-	crime = crime_read(CRIME_INT_STAT);
-	printk ("CRIME intr status: %016lx\n", crime);
-	crime = crime_read(CRIME_HARD_INT);
-	printk ("CRIME hardware intr register: %016lx\n", crime);
-	printk ("MACE ISA intr mask: %08lx\n", mace_perif_ctrl_read(imask));
-	printk ("MACE ISA intr status: %08lx\n", mace_perif_ctrl_read(istat));
+	printk ("CRIME intr mask: %016lx\n", crime->imask);
+	printk ("CRIME intr status: %016lx\n", crime->istat);
+	printk ("CRIME hardware intr register: %016lx\n", crime->hard_int);
+	printk ("MACE ISA intr mask: %08lx\n", mace->perif.ctrl.imask);
+	printk ("MACE ISA intr status: %08lx\n", mace->perif.ctrl.istat);
 	printk ("MACE PCI control register: %08x\n", mace->pci.control);
 
 	printk("Register dump:\n");
@@ -515,12 +513,12 @@
 	uint64_t crime_int;
 	int irq = 0;
 
-	crime_int = crime_read(CRIME_INT_STAT) & crime_mask;
+	crime_int = crime->istat & crime_mask;
 	irq = ffs(crime_int);
 	crime_int = 1 << (irq - 1);
 
 	if (crime_int & CRIME_MACEISA_INT_MASK) {
-		unsigned long mace_int = mace_perif_ctrl_read(istat);
+		unsigned long mace_int = mace->perif.ctrl.istat;
 		irq = ffs(mace_int & maceisa_mask) + 32;
 	}
 	DBG("*irq %u*\n", irq);
@@ -552,18 +550,17 @@
 	ll_timer_interrupt(IP32_R4K_TIMER_IRQ, regs);
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	unsigned int irq;
 
-	init_generic_irq();
 	/* Install our interrupt handler, then clear and disable all
 	 * CRIME and MACE interrupts. */
-	crime_write(0, CRIME_INT_MASK);
-	crime_write(0, CRIME_HARD_INT);
-	crime_write(0, CRIME_SOFT_INT);
-	mace_perif_ctrl_write(0, istat);
-	mace_perif_ctrl_write(0, imask);
+	crime->imask = 0;
+	crime->hard_int = 0;
+	crime->soft_int = 0;
+	mace->perif.ctrl.istat = 0;
+	mace->perif.ctrl.imask = 0;
 	set_except_vector(0, ip32_handle_int);
 
 	for (irq = 0; irq <= IP32_IRQ_MAX; irq++) {
diff -Nru a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c
--- a/arch/mips/sgi-ip32/ip32-reset.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/sgi-ip32/ip32-reset.c	2004-12-24 13:37:19 -08:00
@@ -41,7 +41,7 @@
 
 static void ip32_machine_restart(char *cmd)
 {
-	crime_write(CRIME_CONTROL_HARD_RESET, CRIME_CONTROL);
+	crime->control = CRIME_CONTROL_HARD_RESET;
 	while (1);
 }
 
@@ -83,9 +83,9 @@
 
 static void blink_timeout(unsigned long data)
 {
-	unsigned long led = mace_perif_ctrl_read(misc) ^ MACEISA_LED_RED;
-	mace_perif_ctrl_write(led, misc);
-	mod_timer(&blink_timer, jiffies+data);
+	unsigned long led = mace->perif.ctrl.misc ^ MACEISA_LED_RED;
+	mace->perif.ctrl.misc = led;
+	mod_timer(&blink_timer, jiffies + data);
 }
 
 static void debounce(unsigned long data)
@@ -165,8 +165,8 @@
 	has_paniced = 1;
 
 	/* turn off the green LED */
-	led = mace_perif_ctrl_read(misc) | MACEISA_LED_GREEN;
-	mace_perif_ctrl_write(led, misc);
+	led = mace->perif.ctrl.misc | MACEISA_LED_GREEN;
+	mace->perif.ctrl.misc = led;
 
 	blink_timer.data = PANIC_FREQ;
 	blink_timeout(PANIC_FREQ);
@@ -181,10 +181,10 @@
 static __init int ip32_reboot_setup(void)
 {
 	/* turn on the green led only */
-	unsigned long led = mace_perif_ctrl_read(misc);
+	unsigned long led = mace->perif.ctrl.misc;
 	led |= MACEISA_LED_RED;
 	led &= ~MACEISA_LED_GREEN;
-	mace_perif_ctrl_write(led, misc);
+	mace->perif.ctrl.misc = led;
 
 	_machine_restart = ip32_machine_restart;
 	_machine_halt = ip32_machine_halt;
diff -Nru a/arch/mips/sgi-ip32/ip32-setup.c b/arch/mips/sgi-ip32/ip32-setup.c
--- a/arch/mips/sgi-ip32/ip32-setup.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/sgi-ip32/ip32-setup.c	2004-12-24 13:37:19 -08:00
@@ -80,8 +80,8 @@
 {
 	printk(KERN_INFO "Calibrating system timer... ");
 	write_c0_count(0);
-	crime_write(0, CRIME_TIMER);
-	while (crime_read(CRIME_TIMER) < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
+	crime->timer = 0;
+	while (crime->timer < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
 	mips_hpt_frequency = read_c0_count() * 1000 / WAIT_MS;
 	printk("%d MHz CPU detected\n", mips_hpt_frequency * 2 / 1000000);
 }
@@ -114,7 +114,7 @@
 		o2_serial[0].type	= PORT_16550A;
 		o2_serial[0].line	= 0;
 		o2_serial[0].irq	= MACEISA_SERIAL1_IRQ;
-		o2_serial[0].flags	= STD_COM_FLAGS | UPF_RESOURCES;
+		o2_serial[0].flags	= STD_COM_FLAGS;
 		o2_serial[0].uartclk	= BASE_BAUD * 16;
 		o2_serial[0].iotype	= UPIO_MEM;
 		o2_serial[0].membase	= (char *)&mace->isa.serial1;
@@ -125,7 +125,7 @@
 		o2_serial[1].type	= PORT_16550A;
 		o2_serial[1].line	= 1;
 		o2_serial[1].irq	= MACEISA_SERIAL2_IRQ;
-		o2_serial[1].flags	= STD_COM_FLAGS | UPF_RESOURCES;
+		o2_serial[1].flags	= STD_COM_FLAGS;
 		o2_serial[1].uartclk	= BASE_BAUD * 16;
 		o2_serial[1].iotype	= UPIO_MEM;
 		o2_serial[1].membase	= (char *)&mace->isa.serial2;
diff -Nru a/arch/mips/sibyte/cfe/setup.c b/arch/mips/sibyte/cfe/setup.c
--- a/arch/mips/sibyte/cfe/setup.c	2004-12-24 13:36:31 -08:00
+++ b/arch/mips/sibyte/cfe/setup.c	2004-12-24 13:36:31 -08:00
@@ -19,6 +19,7 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/linkage.h>
 #include <linux/mm.h>
 #include <linux/blkdev.h>
 #include <linux/bootmem.h>
@@ -55,36 +56,45 @@
 
 #ifdef CONFIG_BLK_DEV_INITRD
 extern unsigned long initrd_start, initrd_end;
-extern void * __rd_start, * __rd_end;
-#endif
-
-#ifdef CONFIG_SMP
-static int reboot_smp = 0;
 #endif
 
 #ifdef CONFIG_KGDB
 extern int kgdb_port;
 #endif
 
-static void cfe_linux_exit(void)
+static void ATTRIB_NORET cfe_linux_exit(void *arg)
 {
-#ifdef CONFIG_SMP
+	int warm = *(int *)arg;
+
 	if (smp_processor_id()) {
-		if (reboot_smp) {
-			/* Don't repeat the process from another CPU */
-			for (;;);
-		} else {
+		static int reboot_smp;
+
+		/* Don't repeat the process from another CPU */
+		if (!reboot_smp) {
 			/* Get CPU 0 to do the cfe_exit */
 			reboot_smp = 1;
-			smp_call_function((void *)_machine_restart, NULL, 1, 0);
-			for (;;);
+			smp_call_function(cfe_linux_exit, arg, 1, 0);
 		}
+	} else {
+		printk("Passing control back to CFE...\n");
+		cfe_exit(warm, 0);
+		printk("cfe_exit returned??\n");
 	}
-#endif
-	printk("passing control back to CFE\n");
-	cfe_exit(1, 0);
-	printk("cfe_exit returned??\n");
-	while(1);
+	while (1);
+}
+
+static void ATTRIB_NORET cfe_linux_restart(char *command)
+{
+	static const int zero;
+
+	cfe_linux_exit((void *)&zero);
+}
+
+static void ATTRIB_NORET cfe_linux_halt(void)
+{
+	static const int one = 1;
+
+	cfe_linux_exit((void *)&one);
 }
 
 static __init void prom_meminit(void)
@@ -97,17 +107,6 @@
 	unsigned long initrd_pstart;
 	unsigned long initrd_pend;
 
-#ifdef CONFIG_EMBEDDED_RAMDISK
-	/* If we're using an embedded ramdisk, then __rd_start and __rd_end
-	   are defined by the linker to be on either side of the ramdisk
-	   area.  Otherwise, initrd_start should be defined by kernel command
-	   line arguments */
-	if (initrd_start == 0) {
-		initrd_start = (unsigned long)&__rd_start;
-		initrd_end = (unsigned long)&__rd_end;
-	}
-#endif
-
 	initrd_pstart = CPHYSADDR(initrd_start);
 	initrd_pend = CPHYSADDR(initrd_end);
 	if (initrd_start &&
@@ -247,9 +246,9 @@
 	char *arg;
 #endif
 
-	_machine_restart   = (void (*)(char *))cfe_linux_exit;
-	_machine_halt      = cfe_linux_exit;
-	_machine_power_off = cfe_linux_exit;
+	_machine_restart   = cfe_linux_restart;
+	_machine_halt      = cfe_linux_halt;
+	_machine_power_off = cfe_linux_halt;
 
 	/*
 	 * Check if a loader was used; if NOT, the 4 arguments are
diff -Nru a/arch/mips/sibyte/cfe/smp.c b/arch/mips/sibyte/cfe/smp.c
--- a/arch/mips/sibyte/cfe/smp.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/sibyte/cfe/smp.c	2004-12-24 13:37:18 -08:00
@@ -28,8 +28,10 @@
  * Use CFE to find out how many CPUs are available, setting up
  * phys_cpu_present_map and the logical/physical mappings.
  * XXXKW will the boot CPU ever not be physical 0?
+ *
+ * Common setup before any secondaries are started
  */
-void __init prom_build_cpu_map(void)
+void __init prom_prepare_cpus(unsigned int max_cpus)
 {
 	int i, num;
 
@@ -46,13 +48,6 @@
 		}
 	}
 	printk("Detected %i available secondary CPU(s)\n", num);
-}
-
-/*
- * Common setup before any secondaries are started
- */
-void prom_prepare_cpus(unsigned int max_cpus)
-{
 }
 
 /*
diff -Nru a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c
--- a/arch/mips/sibyte/sb1250/irq.c	2004-12-24 13:37:19 -08:00
+++ b/arch/mips/sibyte/sb1250/irq.c	2004-12-24 13:37:19 -08:00
@@ -61,19 +61,8 @@
 #endif
 
 #ifdef CONFIG_KGDB
-#include <asm/gdb-stub.h>
-extern void breakpoint(void);
 static int kgdb_irq;
 
-/* kgdb is on when configured.  Pass "nokgdb" kernel arg to turn it off */
-static int kgdb_flag = 1;
-static int __init nokgdb(char *str)
-{
-	kgdb_flag = 0;
-	return 1;
-}
-__setup("nokgdb", nokgdb);
-
 /* Default to UART1 */
 int kgdb_port = 1;
 #ifdef CONFIG_SIBYTE_SB1250_DUART
@@ -307,10 +296,10 @@
 }
 
 /*
- *  init_IRQ is called early in the boot sequence from init/main.c.  It
- *  is responsible for setting up the interrupt mapper and installing the
- *  handler that will be responsible for dispatching interrupts to the
- *  "right" place.
+ *  arch_init_irq is called early in the boot sequence from init/main.c via
+ *  init_IRQ.  It is responsible for setting up the interrupt mapper and
+ *  installing the handler that will be responsible for dispatching interrupts
+ *  to the "right" place.
  */
 /*
  * For now, map all interrupts to IP[2].  We could save
@@ -332,7 +321,7 @@
 #define IMR_IP5_VAL	K_INT_MAP_I3
 #define IMR_IP6_VAL	K_INT_MAP_I4
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 
 	unsigned int i;
@@ -405,10 +394,6 @@
 			     IOADDR(A_IMR_REGISTER(0, R_IMR_INTERRUPT_MAP_BASE) +
 				    (kgdb_irq<<3)));
 		sb1250_unmask_irq(0, kgdb_irq);
-
-		prom_printf("Waiting for GDB on UART port %d\n", kgdb_port);
-		set_debug_traps();
-		breakpoint();
 	}
 #endif
 }
diff -Nru a/arch/mips/sibyte/sb1250/irq_handler.S b/arch/mips/sibyte/sb1250/irq_handler.S
--- a/arch/mips/sibyte/sb1250/irq_handler.S	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/sibyte/sb1250/irq_handler.S	2004-12-24 13:36:48 -08:00
@@ -18,8 +18,8 @@
 
 /*
  * sb1250_handle_int() is the routine that is actually called when an interrupt
- * occurs.  It is installed as the exception vector handler in init_IRQ() in
- * arch/mips/sibyte/sb1250/irq.c
+ * occurs.  It is installed as the exception vector handler in arch_init_irq()
+ * in arch/mips/sibyte/sb1250/irq.c
  *
  * In the handle we figure out which interrupts need handling, and use that to
  * call the dispatcher, which will take care of actually calling registered
diff -Nru a/arch/mips/sibyte/sb1250/prom.c b/arch/mips/sibyte/sb1250/prom.c
--- a/arch/mips/sibyte/sb1250/prom.c	2004-12-24 13:37:18 -08:00
+++ b/arch/mips/sibyte/sb1250/prom.c	2004-12-24 13:37:18 -08:00
@@ -23,16 +23,11 @@
 #include <linux/blkdev.h>
 #include <linux/bootmem.h>
 #include <linux/smp.h>
+#include <linux/initrd.h>
 
 #include <asm/bootinfo.h>
 #include <asm/reboot.h>
 
-#ifdef CONFIG_EMBEDDED_RAMDISK
-/* These are symbols defined by the ramdisk linker script */
-extern unsigned char __rd_start;
-extern unsigned char __rd_end;
-#endif
-
 #define MAX_RAM_SIZE ((CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024) - 1)
 
 static __init void prom_meminit(void)
@@ -40,17 +35,6 @@
 #ifdef CONFIG_BLK_DEV_INITRD
 	unsigned long initrd_pstart;
 	unsigned long initrd_pend;
-
-#ifdef CONFIG_EMBEDDED_RAMDISK
-	/* If we're using an embedded ramdisk, then __rd_start and __rd_end
-	   are defined by the linker to be on either side of the ramdisk
-	   area.  Otherwise, initrd_start should be defined by kernel command
-	   line arguments */
-	if (initrd_start == 0) {
-		initrd_start = (unsigned long)&__rd_start;
-		initrd_end = (unsigned long)&__rd_end;
-	}
-#endif
 
 	initrd_pstart = __pa(initrd_start);
 	initrd_pend = __pa(initrd_end);
diff -Nru a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c
--- a/arch/mips/sibyte/swarm/setup.c	2004-12-24 13:36:49 -08:00
+++ b/arch/mips/sibyte/swarm/setup.c	2004-12-24 13:36:49 -08:00
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
+ * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -26,6 +27,8 @@
 #include <linux/bootmem.h>
 #include <linux/blkdev.h>
 #include <linux/init.h>
+#include <linux/tty.h>
+#include <linux/initrd.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
@@ -34,7 +37,6 @@
 #include <asm/reboot.h>
 #include <asm/time.h>
 #include <asm/traps.h>
-#include <asm/pci_channel.h>
 #include <asm/sibyte/sb1250.h>
 #include <asm/sibyte/sb1250_regs.h>
 #include <asm/sibyte/sb1250_genbus.h>
diff -Nru a/arch/mips/sni/irq.c b/arch/mips/sni/irq.c
--- a/arch/mips/sni/irq.c	2004-12-24 13:36:34 -08:00
+++ b/arch/mips/sni/irq.c	2004-12-24 13:36:34 -08:00
@@ -173,13 +173,12 @@
  * 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)
+void __init arch_init_irq(void)
 {
 	int i;
 
 	set_except_vector(0, sni_rm200_pci_handle_int);
 
-	init_generic_irq();
 	init_i8259_irqs();			/* Integrated i8259  */
 	init_pciasic();
 
diff -Nru a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
--- a/arch/mips/sni/setup.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/sni/setup.c	2004-12-24 13:36:48 -08:00
@@ -5,7 +5,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1996, 1997, 1998, 2000, 2003, 2004 by Ralf Baechle
+ * Copyright (C) 1996, 97, 98, 2000, 03, 04 Ralf Baechle (ralf@linux-mips.org)
  */
 #include <linux/config.h>
 #include <linux/eisa.h>
@@ -27,7 +27,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/mc146818-time.h>
-#include <asm/pci_channel.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
 #include <asm/reboot.h>
diff -Nru a/arch/mips/tx4927/common/Makefile b/arch/mips/tx4927/common/Makefile
--- a/arch/mips/tx4927/common/Makefile	2004-12-24 13:36:30 -08:00
+++ b/arch/mips/tx4927/common/Makefile	2004-12-24 13:36:30 -08:00
@@ -8,4 +8,5 @@
 
 obj-y	+= tx4927_prom.o tx4927_setup.o tx4927_irq.o tx4927_irq_handler.o
 
+obj-$(CONFIG_TOSHIBA_FPCIB0)	   += smsc_fdc37m81x.o
 obj-$(CONFIG_KGDB)                 += tx4927_dbgio.o
diff -Nru a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
--- a/arch/mips/tx4927/common/tx4927_irq.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/tx4927/common/tx4927_irq.c	2004-12-24 13:37:29 -08:00
@@ -37,7 +37,7 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/irq.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -48,8 +48,6 @@
 /*
  * DEBUG
  */
-#define TX4927_IRQ_CHECK_CP0
-#define TX4927_IRQ_CHECK_PIC
 
 #undef TX4927_IRQ_DEBUG
 
@@ -239,16 +237,6 @@
 {
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_STARTUP, "irq=%d \n", irq);
 
-#ifdef TX4927_IRQ_CHECK_CP0
-	{
-		if (irq < TX4927_IRQ_CP0_BEG || irq > TX4927_IRQ_CP0_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	tx4927_irq_cp0_enable(irq);
 
 	return (0);
@@ -258,16 +246,6 @@
 {
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_SHUTDOWN, "irq=%d \n", irq);
 
-#ifdef TX4927_IRQ_CHECK_CP0
-	{
-		if (irq < TX4927_IRQ_CP0_BEG || irq > TX4927_IRQ_CP0_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	tx4927_irq_cp0_disable(irq);
 
 	return;
@@ -279,16 +257,6 @@
 
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_ENABLE, "irq=%d \n", irq);
 
-#ifdef TX4927_IRQ_CHECK_CP0
-	{
-		if (irq < TX4927_IRQ_CP0_BEG || irq > TX4927_IRQ_CP0_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	spin_lock_irqsave(&tx4927_cp0_lock, flags);
 
 	tx4927_irq_cp0_modify(CCP0_STATUS, 0, tx4927_irq_cp0_mask(irq));
@@ -304,16 +272,6 @@
 
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_DISABLE, "irq=%d \n", irq);
 
-#ifdef TX4927_IRQ_CHECK_CP0
-	{
-		if (irq < TX4927_IRQ_CP0_BEG || irq > TX4927_IRQ_CP0_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	spin_lock_irqsave(&tx4927_cp0_lock, flags);
 
 	tx4927_irq_cp0_modify(CCP0_STATUS, tx4927_irq_cp0_mask(irq), 0);
@@ -327,16 +285,6 @@
 {
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_MASK, "irq=%d \n", irq);
 
-#ifdef TX4927_IRQ_CHECK_CP0
-	{
-		if (irq < TX4927_IRQ_CP0_BEG || irq > TX4927_IRQ_CP0_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	tx4927_irq_cp0_disable(irq);
 
 	return;
@@ -346,16 +294,6 @@
 {
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_ENDIRQ, "irq=%d \n", irq);
 
-#ifdef TX4927_IRQ_CHECK_CP0
-	{
-		if (irq < TX4927_IRQ_CP0_BEG || irq > TX4927_IRQ_CP0_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
 		tx4927_irq_cp0_enable(irq);
 	}
@@ -516,16 +454,6 @@
 {
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_STARTUP, "irq=%d\n", irq);
 
-#ifdef TX4927_IRQ_CHECK_PIC
-	{
-		if (irq < TX4927_IRQ_PIC_BEG || irq > TX4927_IRQ_PIC_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	tx4927_irq_pic_enable(irq);
 
 	return (0);
@@ -535,16 +463,6 @@
 {
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_SHUTDOWN, "irq=%d\n", irq);
 
-#ifdef TX4927_IRQ_CHECK_PIC
-	{
-		if (irq < TX4927_IRQ_PIC_BEG || irq > TX4927_IRQ_PIC_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	tx4927_irq_pic_disable(irq);
 
 	return;
@@ -556,16 +474,6 @@
 
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_ENABLE, "irq=%d\n", irq);
 
-#ifdef TX4927_IRQ_CHECK_PIC
-	{
-		if (irq < TX4927_IRQ_PIC_BEG || irq > TX4927_IRQ_PIC_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	spin_lock_irqsave(&tx4927_pic_lock, flags);
 
 	tx4927_irq_pic_modify(tx4927_irq_pic_addr(irq), 0,
@@ -582,16 +490,6 @@
 
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_DISABLE, "irq=%d\n", irq);
 
-#ifdef TX4927_IRQ_CHECK_PIC
-	{
-		if (irq < TX4927_IRQ_PIC_BEG || irq > TX4927_IRQ_PIC_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	spin_lock_irqsave(&tx4927_pic_lock, flags);
 
 	tx4927_irq_pic_modify(tx4927_irq_pic_addr(irq),
@@ -606,16 +504,6 @@
 {
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_MASK, "irq=%d\n", irq);
 
-#ifdef TX4927_IRQ_CHECK_PIC
-	{
-		if (irq < TX4927_IRQ_PIC_BEG || irq > TX4927_IRQ_PIC_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
-
 	tx4927_irq_pic_disable(irq);
 
 	return;
@@ -624,16 +512,6 @@
 static void tx4927_irq_pic_end(unsigned int irq)
 {
 	TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_ENDIRQ, "irq=%d\n", irq);
-
-#ifdef TX4927_IRQ_CHECK_PIC
-	{
-		if (irq < TX4927_IRQ_PIC_BEG || irq > TX4927_IRQ_PIC_END) {
-			TX4927_IRQ_DPRINTK(TX4927_IRQ_EROR,
-					   "bad irq=%d \n", irq);
-			panic("\n");
-		}
-	}
-#endif
 
 	if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
 		tx4927_irq_pic_enable(irq);
diff -Nru a/arch/mips/tx4927/common/tx4927_setup.c b/arch/mips/tx4927/common/tx4927_setup.c
--- a/arch/mips/tx4927/common/tx4927_setup.c	2004-12-24 13:36:48 -08:00
+++ b/arch/mips/tx4927/common/tx4927_setup.c	2004-12-24 13:36:48 -08:00
@@ -38,7 +38,7 @@
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/irq.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -89,15 +89,6 @@
 	{
 		extern void toshiba_rbtx4927_time_init(void);
 		toshiba_rbtx4927_time_init();
-	}
-#endif
-
-#ifdef CONFIG_KGDB
-	{
-		printk("Calling breakpoint() -- start remote kgdb\n");
-		set_debug_traps();
-		breakpoint();
-		printk("Calling breakpoint() -- done\n");
 	}
 #endif
 
diff -Nru a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c	2004-12-24 13:36:47 -08:00
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c	2004-12-24 13:36:47 -08:00
@@ -134,10 +134,10 @@
 #include <linux/bootmem.h>
 #include <linux/blkdev.h>
 #ifdef CONFIG_RTC_DS1742
-#include <asm/rtc_ds1742.h>
+#include <linux/ds1742rtc.h>
 #endif
 #ifdef CONFIG_TOSHIBA_FPCIB0
-#include <asm/smsc_fdc37m81x.h>
+#include <asm/tx4927/smsc_fdc37m81x.h>
 #endif
 #include <asm/tx4927/toshiba_rbtx4927.h>
 
@@ -665,7 +665,7 @@
 #endif
 
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	extern void tx4927_irq_init(void);
 
@@ -678,13 +678,6 @@
 		if (tx4927_using_backplane) {
 			toshiba_rbtx4927_irq_isa_init();
 		}
-	}
-#endif
-
-#ifdef CONFIG_PCI
-	{
-		extern void toshiba_rbtx4927_pci_irq_init(void);
-		toshiba_rbtx4927_pci_irq_init();
 	}
 #endif
 
diff -Nru a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c	2004-12-24 13:37:32 -08:00
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c	2004-12-24 13:37:32 -08:00
@@ -6,6 +6,9 @@
  *
  * Copyright 2001-2002 MontaVista Software Inc.
  *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani, mlachwani@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
@@ -86,3 +89,9 @@
 {
 	return "Toshiba RBTX4927/RBTX4937";
 }
+
+char * __init prom_getcmdline(void)
+{
+        return &(arcs_cmdline[0]);
+}
+
diff -Nru a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c	2004-12-24 13:37:00 -08:00
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c	2004-12-24 13:37:00 -08:00
@@ -6,7 +6,7 @@
  *
  * Copyright 2001-2002 MontaVista Software Inc.
  *
- * Copyright (C) 1996, 1997, 2001  Ralf Baechle
+ * Copyright (C) 1996, 97, 2001, 04  Ralf Baechle (ralf@linux-mips.org)
  * Copyright (C) 2000 RidgeRun, Inc.
  * Author: RidgeRun, Inc.
  *   glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
@@ -17,7 +17,10 @@
  * Copyright 2002 MontaVista Software Inc.
  * Author: Michael Pruznick, michael_pruznick@mvista.com
  *
- * Copyright (C) 2000-2001 Toshiba Corporation 
+ * Copyright (C) 2000-2001 Toshiba Corporation
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani, mlachwani@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
@@ -61,15 +64,14 @@
 #include <linux/bootmem.h>
 #include <linux/blkdev.h>
 #ifdef CONFIG_RTC_DS1742
-#include <asm/rtc_ds1742.h>
+#include <linux/ds1742rtc.h>
 #endif
 #ifdef CONFIG_TOSHIBA_FPCIB0
-#include <asm/smsc_fdc37m81x.h>
+#include <asm/tx4927/smsc_fdc37m81x.h>
 #endif
 #include <asm/tx4927/toshiba_rbtx4927.h>
 #ifdef CONFIG_PCI
 #include <asm/tx4927/tx4927_pci.h>
-#include <asm/pci_channel.h>
 #endif
 #ifdef CONFIG_BLK_DEV_IDEPCI
 #include <linux/hdreg.h>
@@ -146,49 +148,15 @@
 unsigned long tx4927_ce_base[8];
 void tx4927_pci_setup(void);
 void tx4927_reset_pci_pcic(void);
-#ifdef  TX4927_SUPPORT_PCI_66
-void tx4927_pci66_setup(void);
-extern int tx4927_pci66_check(void);
-#endif
 int tx4927_pci66 = 0;		/* 0:auto */
 #endif
 
 char *toshiba_name = "";
 
 #ifdef CONFIG_PCI
-void tx4927_dump_pcic_settings(void)
-{
-	printk("%s pcic settings:",toshiba_name);
-	{
-		int i;
-		unsigned long *preg = (unsigned long *) tx4927_pcicptr;
-		for (i = 0; i < sizeof(struct tx4927_pcic_reg); i += 4) {
-			if (i % 32 == 0)
-				printk("\n%04x:", i);
-			if (preg == &tx4927_pcicptr->g2pintack
-			    || preg == &tx4927_pcicptr->g2pspc
-#ifdef CONFIG_TX4927BUG_WORKAROUND
-			    || preg == &tx4927_pcicptr->g2pcfgadrs
-			    || preg == &tx4927_pcicptr->g2pcfgdata
-#endif
-			    ) {
-				printk(" XXXXXXXX");
-				preg++;
-				continue;
-			}
-			printk(" %08lx", *preg++);
-			if (preg == &tx4927_pcicptr->g2pcfgadrs)
-				break;
-		}
-		printk("\n");
-	}
-}
-
 static void tx4927_pcierr_interrupt(int irq, void *dev_id,
 				    struct pt_regs *regs)
 {
-	extern void tx4927_dump_pcic_settings(void);
-
 #ifdef CONFIG_BLK_DEV_IDEPCI
 	/* ignore MasterAbort for ide probing... */
 	if (irq == TX4927_IRQ_IRC_PCIERR &&
@@ -203,6 +171,7 @@
 	}
 #endif
 	printk("PCI error interrupt (irq 0x%x).\n", irq);
+
 	printk("pcistat:%04x, g2pstatus:%08lx, pcicstatus:%08lx\n",
 	       (unsigned short) (tx4927_pcicptr->pcistatus >> 16),
 	       tx4927_pcicptr->g2pstatus, tx4927_pcicptr->pcicstatus);
@@ -211,23 +180,10 @@
 	       (unsigned long) (tx4927_ccfgptr->tear >> 32),
 	       (unsigned long) tx4927_ccfgptr->tear);
 	show_regs(regs);
-	//tx4927_dump_pcic_settings();
-	panic("PCI error at PC:%08lx.", regs->cp0_epc);
 }
 
-static struct irqaction pcic_action = {
-	tx4927_pcierr_interrupt, 0, 0, "PCI-C", NULL, NULL
-};
-
-static struct irqaction pcierr_action = {
-	tx4927_pcierr_interrupt, 0, 0, "PCI-ERR", NULL, NULL
-};
-
-
 void __init toshiba_rbtx4927_pci_irq_init(void)
 {
-	setup_irq(TX4927_IRQ_IRC_PCIC, &pcic_action);
-	setup_irq(TX4927_IRQ_IRC_PCIERR, &pcierr_action);
 	return;
 }
 
@@ -245,91 +201,26 @@
 #endif /* CONFIG_PCI */
 
 #ifdef CONFIG_PCI
-#ifdef  TX4927_SUPPORT_PCI_66
-void tx4927_pci66_setup(void)
-{
-	int pciclk, pciclkin = 1;
-
-	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI66,
-				       "-\n");
-
-	if (tx4927_ccfgptr->ccfg & TX4927_CCFG_PCI66)
-		return;
-
-	tx4927_reset_pci_pcic();
-
-	/* Assert M66EN */
-	tx4927_ccfgptr->ccfg |= TX4927_CCFG_PCI66;
-	/* set PCICLK 66MHz */
-	if (tx4927_ccfgptr->pcfg & TX4927_PCFG_PCICLKEN_ALL) {
-		unsigned int pcidivmode = 0;
-		pcidivmode =
-		    (unsigned long) tx4927_ccfgptr->
-		    ccfg & TX4927_CCFG_PCIDIVMODE_MASK;
-		if (tx4927_cpu_clock >= 170000000) {
-			/* CPU 200MHz */
-			pcidivmode = TX4927_CCFG_PCIDIVMODE_3;
-			pciclk = tx4927_cpu_clock / 3;
-		} else {
-			/* CPU 166MHz */
-			pcidivmode = TX4927_CCFG_PCIDIVMODE_2_5;
-			pciclk = tx4927_cpu_clock * 2 / 5;
-		}
-		tx4927_ccfgptr->ccfg =
-		    (tx4927_ccfgptr->ccfg & ~TX4927_CCFG_PCIDIVMODE_MASK)
-		    | pcidivmode;
-		TOSHIBA_RBTX4927_SETUP_DPRINTK
-		    (TOSHIBA_RBTX4927_SETUP_PCI66,
-		     ":PCICLK: ccfg:0x%08lx\n",
-		     (unsigned long) tx4927_ccfgptr->ccfg);
-	} else {
-		int pciclk_setting = *tx4927_pci_clk_ptr;
-		pciclkin = 0;
-		pciclk = 66666666;
-		pciclk_setting &= ~TX4927_PCI_CLK_MASK;
-		pciclk_setting |= TX4927_PCI_CLK_66;
-		*tx4927_pci_clk_ptr = pciclk_setting;
-		TOSHIBA_RBTX4927_SETUP_DPRINTK
-		    (TOSHIBA_RBTX4927_SETUP_PCI66,
-		     "PCICLK: pci_clk:%02x\n", *tx4927_pci_clk_ptr);
-	}
-
-	udelay(10000);
-
-	/* clear PCIC reset */
-	tx4927_ccfgptr->clkctr &= ~TX4927_CLKCTR_PCIRST;
-	/* clear PCI reset */
-	*tx4927_pcireset_ptr = 0;
-
-	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI66,
-				       "+\n");
-	return;
-}
-#endif				/* TX4927_SUPPORT_PCI_66 */
-
 void print_pci_status(void)
 {
 	printk("PCI STATUS %lx\n", tx4927_pcicptr->pcistatus);
 	printk("PCIC STATUS %lx\n", tx4927_pcicptr->pcicstatus);
 }
 
+extern struct pci_controller tx4927_controller;
+
 static struct pci_dev *fake_pci_dev(struct pci_controller *hose,
 				    int top_bus, int busnr, int devfn)
 {
 	static struct pci_dev dev;
 	static struct pci_bus bus;
 
-	dev.bus = &bus;
-	dev.sysdata = hose;
+	dev.sysdata = (void *)hose;
 	dev.devfn = devfn;
 	bus.number = busnr;
 	bus.ops = hose->pci_ops;
-
-	if (busnr != top_bus)
-		/* Fake a parent bus structure. */
-		bus.parent = &bus;
-	else
-		bus.parent = NULL;
+	bus.parent = NULL;
+	dev.bus = &bus;
 
 	return &dev;
 }
@@ -350,15 +241,19 @@
 EARLY_PCI_OP(write, word, u16)
 EARLY_PCI_OP(write, dword, u32)
 
-static int __init tx4927_pcibios_init(int busno, struct pci_controller *hose)
+static int __init tx4927_pcibios_init(void)
 {
 	unsigned int id;
 	u32 pci_devfn;
+	int devfn_start = 0;
+	int devfn_stop = 0xff;
+	int busno = 0; /* One bus on the Toshiba */
+	struct pci_controller *hose = &tx4927_controller;
 
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS,
 				       "-\n");
 
-	for (pci_devfn = 0x0; pci_devfn < 0xff; pci_devfn++) {
+	for (pci_devfn = devfn_start; pci_devfn < devfn_stop; pci_devfn++) {
 		early_read_config_dword(hose, busno, busno, pci_devfn,
 					PCI_VENDOR_ID, &id);
 
@@ -581,12 +476,15 @@
 
 	}
 
+	register_pci_controller(&tx4927_controller);
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS,
 				       "+\n");
 
-	return busno;
+	return 0;
 }
 
+arch_initcall(tx4927_pcibios_init);
+
 extern struct resource pci_io_resource;
 extern struct resource pci_mem_resource;
 
@@ -597,11 +495,6 @@
 
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "-\n");
 
-#ifndef  TX4927_SUPPORT_PCI_66
-	if (tx4927_ccfgptr->ccfg & TX4927_CCFG_PCI66)
-		printk("PCI 66 current unsupported\n");
-#endif
-
 	mips_memory_upper = tx4927_get_mem_size() << 20;
 	mips_memory_upper += KSEG0;
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
@@ -736,19 +629,6 @@
 	/* PCI->GB mappings (I/O 256B) */
 	tx4927_pcicptr->p2giopbase = 0;	/* 256B */
 
-
-#ifdef TX4927_SUPPORT_COMMAND_IO
-	tx4927_pcicptr->p2giogbase = 0 | TX4927_PCIC_P2GIOGBASE_TIOEN |
-#ifdef __BIG_ENDIAN
-	    TX4927_PCIC_P2GIOGBASE_TECHG
-#else
-	    TX4927_PCIC_P2GIOGBASE_TBSDIS
-#endif
-	    ;
-#else
-	tx4927_pcicptr->p2giogbase = 0;
-#endif
-
 	/* PCI->GB mappings (MEM 512MB) M0 gets all of memory */
 	tx4927_pcicptr->p2gm0plbase = 0;
 	tx4927_pcicptr->p2gm0pubase = 0;
@@ -791,8 +671,6 @@
 	if (tx4927_pcic_trdyto >= 0) {
 		tx4927_pcicptr->g2ptocnt &= ~0xff;
 		tx4927_pcicptr->g2ptocnt |= (tx4927_pcic_trdyto & 0xff);
-		//printk("%s PCIC -- TRDYTO:%02lx\n",toshiba_name,
-		//      tx4927_pcicptr->g2ptocnt & 0xff);
 	}
 
 	/* Clear All Local Bus Status */
@@ -825,17 +703,10 @@
 
 	tx4927_pcicptr->pcistatus = PCI_COMMAND_MASTER |
 	    PCI_COMMAND_MEMORY |
-#ifdef TX4927_SUPPORT_COMMAND_IO
-	    PCI_COMMAND_IO |
-#endif
 	    PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
 
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
 				       ":pci setup complete:\n");
-	//tx4927_dump_pcic_settings();
-
-	tx4927_pcibios_init(0, &tx4927_controller);
-
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "+\n");
 }
 
@@ -883,6 +754,7 @@
 void __init toshiba_rbtx4927_setup(void)
 {
 	vu32 cp0_config;
+	char *argptr;
 
 	printk("CPU is %s\n", toshiba_name);
 
@@ -923,21 +795,16 @@
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
 				       "+\n");
 
-
-
-	mips_io_port_base = KSEG1 + TBTX4927_ISA_IO_OFFSET;
+	set_io_port_base(KSEG1 + TBTX4927_ISA_IO_OFFSET);
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
 				       ":mips_io_port_base=0x%08lx\n",
 				       mips_io_port_base);
 
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
 				       ":Resource\n");
-	ioport_resource.start = 0;
 	ioport_resource.end = 0xffffffff;
-	iomem_resource.start = 0;
 	iomem_resource.end = 0xffffffff;
 
-
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
 				       ":ResetRoutines\n");
 	_machine_restart = toshiba_rbtx4927_restart;
@@ -1000,25 +867,11 @@
 		tx4927_sdramcptr->tr |= 0x02000000;	/* RCD:3tck */
 #endif
 
-#ifdef  TX4927_SUPPORT_PCI_66
-	tx4927_pci66_setup();
-#endif
-
 	tx4927_pci_setup();
-#endif
-
-
-	{
-		u32 id = 0;
-		early_read_config_dword(&tx4927_controller, 0, 0, 0x90,
-					PCI_VENDOR_ID, &id);
-		if (id == 0x94601055) {
-			tx4927_using_backplane = 1;
-			printk("backplane board IS installed\n");
-		} else {
-			printk("backplane board NOT installed\n");
-		}
-	}
+	if (tx4927_using_backplane == 1)
+		printk("backplane board IS installed\n");
+	else
+		printk("No Backplane \n");
 
 	/* this is on ISA bus behind PCI bus, so need PCI up first */
 #ifdef CONFIG_TOSHIBA_FPCIB0
@@ -1065,10 +918,40 @@
 	}
 #endif
 
+#endif /* CONFIG_PCI */
+
+#ifdef CONFIG_SERIAL_TXX9_CONSOLE
+        argptr = prom_getcmdline();
+        if (strstr(argptr, "console=") == NULL) {
+                strcat(argptr, " console=ttyS0,38400");
+        }
+#endif
+
+#ifdef CONFIG_ROOT_NFS
+        argptr = prom_getcmdline();
+        if (strstr(argptr, "root=") == NULL) {
+                strcat(argptr, " root=/dev/nfs rw");
+        }
+#endif
+
+
+#ifdef CONFIG_IP_PNP
+        argptr = prom_getcmdline();
+        if (strstr(argptr, "ip=") == NULL) {
+                strcat(argptr, " ip=any");
+        }
+#endif
+
 
 	TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
-				       "+\n");
+			       "+\n");
 }
+
+#ifdef CONFIG_RTC_DS1742
+extern unsigned long rtc_ds1742_get_time(void);
+extern int rtc_ds1742_set_time(unsigned long);
+extern void rtc_ds1742_wait(void);
+#endif
 
 void __init
 toshiba_rbtx4927_time_init(void)
diff -Nru a/arch/mips/vr4181/common/irq.c b/arch/mips/vr4181/common/irq.c
--- a/arch/mips/vr4181/common/irq.c	2004-12-24 13:37:29 -08:00
+++ b/arch/mips/vr4181/common/irq.c	2004-12-24 13:37:29 -08:00
@@ -184,10 +184,9 @@
 static struct irqaction reserved =
 	{ no_action, SA_INTERRUPT, CPU_MASK_NONE, "cascade", NULL, NULL };
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
 	int i;
-	extern irq_desc_t irq_desc[];
 
 	set_except_vector(0, vr4181_handle_irq);
 
@@ -237,13 +236,4 @@
 	 */
 	setup_irq(VR4181_IRQ_RTCL1, &reserved);
 	setup_irq(VR4181_IRQ_RTCL2, &reserved);
-
-#ifdef CONFIG_KGDB
-	printk("Setting debug traps - please connect the remote debugger.\n");
-
-	set_debug_traps();
-
-	// you may move this line to whereever you want
-	breakpoint();
-#endif
 }
diff -Nru a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
--- a/arch/mips/vr41xx/common/icu.c	2004-12-24 13:36:17 -08:00
+++ b/arch/mips/vr41xx/common/icu.c	2004-12-24 13:36:17 -08:00
@@ -747,11 +747,8 @@
 	setup_irq(INT4_CASCADE_IRQ, &icu_cascade);
 }
 
-void __init init_IRQ(void)
+void __init arch_init_irq(void)
 {
-	memset(irq_desc, 0, sizeof(irq_desc));
-
-	init_generic_irq();
 	mips_cpu_irq_init(MIPS_CPU_IRQ_BASE);
 	init_vr41xx_icu_irq();
 	init_vr41xx_giuint_irq();
diff -Nru a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c
--- a/arch/mips/vr41xx/common/vrc4173.c	2004-12-24 13:37:01 -08:00
+++ b/arch/mips/vr41xx/common/vrc4173.c	2004-12-24 13:37:01 -08:00
@@ -56,6 +56,9 @@
 
 #define VRC4173_SYSINT1REG	0x060
 #define VRC4173_MSYSINT1REG	0x06c
+#define VRC4173_MPIUINTREG	0x06e
+#define VRC4173_MAIUINTREG	0x070
+#define VRC4173_MKIUINTREG	0x072
 
 #define VRC4173_SELECTREG	0x09e
  #define SEL3			0x0008
@@ -329,7 +332,7 @@
 	spin_unlock_irqrestore(&desc->lock, flags);
 }
 
-EXPORT_SYMBOL(vrc4173_eanble_piuint);
+EXPORT_SYMBOL(vrc4173_enable_piuint);
 
 void vrc4173_disable_piuint(uint16_t mask)
 {
diff -Nru a/arch/parisc/Makefile b/arch/parisc/Makefile
--- a/arch/parisc/Makefile	2004-12-24 13:37:19 -08:00
+++ b/arch/parisc/Makefile	2004-12-24 13:37:19 -08:00
@@ -37,8 +37,10 @@
 # are not in gcc 3.2.
 cflags-y	+= -mno-space-regs -mfast-indirect-calls
 
-# No fixed-point multiply
-cflags-y	+= -mdisable-fpregs
+# Currently we save and restore fpregs on all kernel entry/interruption paths.
+# If that gets optimized, we might need to disable the use of fpregs in the
+# kernel.
+#cflags-y	+= -mdisable-fpregs
 
 # Without this, "ld -r" results in .text sections that are too big
 # (> 0x40000) for branches to reach stubs.
@@ -52,7 +54,6 @@
 cflags-$(CONFIG_PA8X00)		+= -march=2.0 -mschedule=8000
 
 head-y			:= arch/parisc/kernel/head.o 
-head-$(CONFIG_PARISC64)	:= arch/parisc/kernel/head64.o
 
 CFLAGS	+= $(cflags-y)
 
@@ -86,6 +87,12 @@
 # Shorthands for known targets not supported by parisc, use palo as default
 Image zImage bzImage: palo
 
+kernel_install: vmlinux
+	sh $(src)/arch/parisc/install.sh \
+			$(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
+
+install: kernel_install modules_install
+
 prepare: include/asm-parisc/offsets.h
 
 arch/parisc/kernel/asm-offsets.s: include/asm include/linux/version.h \
@@ -100,4 +107,8 @@
 define archhelp
 	@echo  '* vmlinux	- Uncompressed kernel image (./vmlinux)'
 	@echo  '  palo		- Bootable image (./lifimage)'
+	@echo  '  install	- Install kernel using'
+	@echo  '		  (your) ~/bin/installkernel or'
+	@echo  '		  (distribution) /sbin/installkernel or'
+	@echo  '		  copy to $$(INSTALL_PATH)'
 endef
diff -Nru a/arch/parisc/configs/a500_defconfig b/arch/parisc/configs/a500_defconfig
--- a/arch/parisc/configs/a500_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/parisc/configs/a500_defconfig	2004-12-24 13:36:31 -08:00
@@ -11,7 +11,6 @@
 #
 CONFIG_EXPERIMENTAL=y
 # CONFIG_CLEAN_COMPILE is not set
-# CONFIG_STANDALONE is not set
 CONFIG_BROKEN=y
 CONFIG_BROKEN_ON_SMP=y
 
@@ -31,6 +30,7 @@
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
 CONFIG_IOSCHED_NOOP=y
@@ -48,6 +48,7 @@
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
 
 #
 # Processor type and features
@@ -61,9 +62,12 @@
 CONFIG_PREFETCH=y
 CONFIG_PARISC64=y
 CONFIG_64BIT=y
-# CONFIG_SMP is not set
+CONFIG_SMP=y
+CONFIG_HOTPLUG_CPU=y
+# CONFIG_DISCONTIGMEM is not set
 # CONFIG_PREEMPT is not set
 CONFIG_COMPAT=y
+CONFIG_NR_CPUS=4
 
 #
 # Bus options (PCI, PCMCIA, EISA, GSC, ISA)
@@ -86,6 +90,7 @@
 CONFIG_PCMCIA_DEBUG=y
 CONFIG_YENTA=m
 CONFIG_CARDBUS=y
+# CONFIG_PD6729 is not set
 # CONFIG_I82092 is not set
 # CONFIG_TCIC is not set
 
@@ -107,6 +112,8 @@
 #
 # Generic Driver Options
 #
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 CONFIG_DEBUG_DRIVER=y
 
@@ -135,7 +142,7 @@
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
+# CONFIG_BLK_DEV_SX8 is not set
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=6144
 CONFIG_BLK_DEV_INITRD=y
@@ -165,7 +172,6 @@
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
 #
 CONFIG_SCSI_MULTI_LUN=y
-CONFIG_SCSI_REPORT_LUNS=y
 # CONFIG_SCSI_CONSTANTS is not set
 # CONFIG_SCSI_LOGGING is not set
 
@@ -179,6 +185,7 @@
 # SCSI low-level drivers
 #
 # CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_3W_9XXX is not set
 # CONFIG_SCSI_ACARD is not set
 # CONFIG_SCSI_AACRAID is not set
 # CONFIG_SCSI_AIC7XXX is not set
@@ -353,6 +360,8 @@
 # CONFIG_IP_NF_COMPAT_IPFWADM is not set
 CONFIG_IP_NF_TARGET_NOTRACK=m
 CONFIG_IP_NF_RAW=m
+# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
+# CONFIG_IP_NF_MATCH_REALM is not set
 CONFIG_XFRM=y
 CONFIG_XFRM_USER=m
 
@@ -379,6 +388,7 @@
 # QoS and/or fair queueing
 #
 # CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
 
 #
 # Network testing
@@ -452,6 +462,7 @@
 # CONFIG_SUNDANCE is not set
 CONFIG_VIA_RHINE=m
 CONFIG_VIA_RHINE_MMIO=y
+# CONFIG_VIA_VELOCITY is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -501,7 +512,6 @@
 #
 # Wireless 802.11b ISA/PCI cards support
 #
-# CONFIG_AIRO is not set
 CONFIG_HERMES=m
 CONFIG_PLX_HERMES=m
 CONFIG_TMD_HERMES=m
@@ -644,7 +654,6 @@
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 
@@ -661,6 +670,11 @@
 # CONFIG_I2C is not set
 
 #
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Misc devices
 #
 
@@ -734,6 +748,7 @@
 CONFIG_JOLIET=y
 # CONFIG_ZISOFS is not set
 CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
 
 #
 # DOS/FAT/NT Filesystems
@@ -741,6 +756,8 @@
 CONFIG_FAT_FS=m
 CONFIG_MSDOS_FS=m
 CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # CONFIG_NTFS_FS is not set
 
 #
@@ -795,6 +812,9 @@
 CONFIG_SMB_NLS_DEFAULT=y
 CONFIG_SMB_NLS_REMOTE="cp437"
 CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_POSIX is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -833,6 +853,7 @@
 # CONFIG_NLS_ISO8859_8 is not set
 # CONFIG_NLS_CODEPAGE_1250 is not set
 # CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
 CONFIG_NLS_ISO8859_1=m
 CONFIG_NLS_ISO8859_2=m
 CONFIG_NLS_ISO8859_3=m
@@ -860,6 +881,8 @@
 CONFIG_DEBUG_KERNEL=y
 # CONFIG_DEBUG_SLAB is not set
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_RWLOCK is not set
 # CONFIG_FRAME_POINTER is not set
 # CONFIG_DEBUG_INFO is not set
 
@@ -886,7 +909,9 @@
 CONFIG_CRYPTO_AES=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
+# CONFIG_CRYPTO_TEA is not set
 # CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_KHAZAD is not set
 CONFIG_CRYPTO_DEFLATE=m
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
 CONFIG_CRYPTO_CRC32C=m
@@ -895,6 +920,7 @@
 #
 # Library routines
 #
+CONFIG_CRC_CCITT=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=m
diff -Nru a/arch/parisc/hpux/fs.c b/arch/parisc/hpux/fs.c
--- a/arch/parisc/hpux/fs.c	2004-12-24 13:36:31 -08:00
+++ b/arch/parisc/hpux/fs.c	2004-12-24 13:36:31 -08:00
@@ -43,8 +43,11 @@
 	error = do_execve(filename, (char **) regs->gr[25],
 		(char **)regs->gr[24], regs);
 
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 
 out:
diff -Nru a/arch/parisc/install.sh b/arch/parisc/install.sh
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/parisc/install.sh	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# arch/parisc/install.sh, derived from arch/i386/boot/install.sh
+#
+# 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 by Linus Torvalds
+#
+# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
+#
+# "make install" script for i386 architecture
+#
+# Arguments:
+#   $1 - kernel version
+#   $2 - kernel image file
+#   $3 - kernel map file
+#   $4 - default install path (blank if root directory)
+#
+
+# User may have a custom install script
+
+if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi
+if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi
+
+# Default install
+
+if [ -f $4/vmlinux ]; then
+	mv $4/vmlinux $4/vmlinux.old
+fi
+
+if [ -f $4/System.map ]; then
+	mv $4/System.map $4/System.old
+fi
+
+cat $2 > $4/vmlinux
+cp $3 $4/System.map
diff -Nru a/arch/parisc/kernel/Makefile b/arch/parisc/kernel/Makefile
--- a/arch/parisc/kernel/Makefile	2004-12-24 13:36:33 -08:00
+++ b/arch/parisc/kernel/Makefile	2004-12-24 13:36:33 -08:00
@@ -2,9 +2,7 @@
 # Makefile for arch/parisc/kernel
 #
 
-head-y			:= head.o
-head-$(CONFIG_PARISC64)	:= head64.o
-extra-y			:= init_task.o $(head-y) vmlinux.lds
+extra-y			:= init_task.o head.o vmlinux.lds
 
 AFLAGS_entry.o	:= -traditional
 AFLAGS_pacache.o := -traditional
@@ -14,7 +12,8 @@
 		   pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \
 		   ptrace.o hardware.o inventory.o drivers.o semaphore.o \
 		   signal.o hpmc.o real2.o parisc_ksyms.o unaligned.o \
-		   process.o processor.o pdc_cons.o pdc_chassis.o unwind.o
+		   process.o processor.o pdc_cons.o pdc_chassis.o unwind.o \
+		   topology.o
 
 obj-$(CONFIG_SMP)	+= smp.o
 obj-$(CONFIG_PA11)	+= pci-dma.o
diff -Nru a/arch/parisc/kernel/asm-offsets.c b/arch/parisc/kernel/asm-offsets.c
--- a/arch/parisc/kernel/asm-offsets.c	2004-12-24 13:36:18 -08:00
+++ b/arch/parisc/kernel/asm-offsets.c	2004-12-24 13:36:18 -08:00
@@ -38,6 +38,7 @@
 #include <asm/ptrace.h>
 #include <asm/processor.h>
 #include <asm/pdc.h>
+#include <asm/uaccess.h>
 
 #define DEFINE(sym, val) \
 	asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -291,5 +292,8 @@
 	DEFINE(ASM_PT_INITIAL, PT_INITIAL);
 	DEFINE(ASM_PAGE_SIZE, PAGE_SIZE);
 	BLANK();
+	DEFINE(EXCDATA_IP, offsetof(struct exception_data, fault_ip));
+	DEFINE(EXCDATA_SPACE, offsetof(struct exception_data, fault_space));
+	DEFINE(EXCDATA_ADDR, offsetof(struct exception_data, fault_addr));
 	return 0;
 }
diff -Nru a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
--- a/arch/parisc/kernel/cache.c	2004-12-24 13:36:48 -08:00
+++ b/arch/parisc/kernel/cache.c	2004-12-24 13:36:48 -08:00
@@ -33,6 +33,17 @@
 int icache_stride;
 EXPORT_SYMBOL(dcache_stride);
 
+
+#if defined(CONFIG_SMP)
+/* On some machines (e.g. ones with the Merced bus), there can be
+ * only a single PxTLB broadcast at a time; this must be guaranteed
+ * by software.  We put a spinlock around all TLB flushes  to
+ * ensure this.
+ */
+spinlock_t pa_tlb_lock = SPIN_LOCK_UNLOCKED;
+EXPORT_SYMBOL(pa_tlb_lock);
+#endif
+
 struct pdc_cache_info cache_info;
 #ifndef CONFIG_PA20
 static struct pdc_btlb_info btlb_info;
@@ -306,3 +317,13 @@
 EXPORT_SYMBOL(flush_kernel_dcache_page);
 EXPORT_SYMBOL(flush_data_cache_local);
 EXPORT_SYMBOL(flush_kernel_icache_range_asm);
+
+void clear_user_page_asm(void *page, unsigned long vaddr)
+{
+	/* This function is implemented in assembly in pacache.S */
+	extern void __clear_user_page_asm(void *page, unsigned long vaddr);
+
+	purge_tlb_start();
+	__clear_user_page_asm(page, vaddr);
+	purge_tlb_end();
+}
diff -Nru a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
--- a/arch/parisc/kernel/entry.S	2004-12-24 13:36:31 -08:00
+++ b/arch/parisc/kernel/entry.S	2004-12-24 13:36:31 -08:00
@@ -440,8 +440,17 @@
 	mfctl		%cr25,\reg
 	.endm
 
-	/* Only allow faults on different spaces from the
-	 * currently active one if we're the kernel */
+	/* 
+		space_check(spc,tmp,fault)
+
+		spc - The space we saw the fault with.
+		tmp - The place to store the current space.
+		fault - Function to call on failure.
+
+		Only allow faults on different spaces from the
+		currently active one if we're the kernel 
+
+	*/
 	.macro		space_check	spc,tmp,fault
 	mfsp		%sr7,\tmp
 	or,COND(<>)	%r0,\spc,%r0	/* user may execute gateway page
@@ -774,7 +783,7 @@
 #ifdef __LP64__
 	ldo	-16(%r30),%r29		/* Reference param save area */
 #endif
-	bl	do_fork, %r2
+	BL	do_fork, %r2
 	copy	%r1, %r24		/* pt_regs */
 
 	/* Parent Returns here */
@@ -827,7 +836,7 @@
 #ifdef __LP64__
 	ldo	-16(%r30),%r29		/* Reference param save area */
 #endif
-	bl	sys_execve, %r2
+	BL	sys_execve, %r2
 	copy	%r16, %r26
 
 	cmpib,=,n 0,%r28,intr_return    /* forward */
@@ -939,6 +948,7 @@
 	STREG   %r19,PT_SR7(%r16)
 
 intr_return:
+	/* NOTE: Need to enable interrupts incase we schedule. */
 	ssm     PSW_SM_I, %r0
 
 	/* Check for software interrupts */
@@ -982,6 +992,8 @@
 	ldo             PT_FR31(%r29),%r1
 	rest_fp         %r1
 	rest_general    %r29
+
+	/* Create a "relied upon translation" PA 2.0 Arch. F-5 */
 	ssm		0,%r0
 	nop
 	nop
@@ -992,8 +1004,15 @@
 	nop
 	tophys_r1       %r29
 	rsm             (PSW_SM_Q|PSW_SM_P|PSW_SM_D|PSW_SM_I),%r0
+
+	/* Restore space id's and special cr's from PT_REGS
+	 * structure pointed to by r29 */
 	rest_specials	%r29
+
+	/* Important: Note that rest_stack restores r29
+	 * last (we are using it)! It also restores r1 and r30. */
 	rest_stack
+
 	rfi
 	nop
 	nop
@@ -1036,7 +1055,14 @@
 
 	.import do_signal,code
 intr_do_signal:
-	/* Only do signals if we are returning to user space */
+	/* 
+		This check is critical to having LWS
+		working. The IASQ is zero on the gateway
+		page and we cannot deliver any signals until
+		we get off the gateway page.
+
+		Only do signals if we are returning to user space 
+	*/
 	LDREG	PT_IASQ0(%r16), %r20
 	CMPIB= 0,%r20,intr_restore /* backward */
 	nop
@@ -1050,7 +1076,7 @@
 	ldo	-16(%r30),%r29			/* Reference param save area */
 #endif
 
-	bl	do_signal,%r2
+	BL	do_signal,%r2
 	copy	%r0, %r26			/* sigset_t *oldset = NULL */
 
 	b	intr_restore
@@ -1443,15 +1469,20 @@
 	 * of the instruction. Since we don't insert a translation
 	 * we can get a lot of faults during a flush loop, so it makes
 	 * sense to try to do it here with minimum overhead. We only
-	 * emulate fdc,fic & pdc instructions whose base and index
-	 * registers are not shadowed. We defer everything else to the
-	 * "slow" path.
+	 * emulate fdc,fic,pdc,probew,prober instructions whose base 
+	 * and index registers are not shadowed. We defer everything 
+	 * else to the "slow" path.
 	 */
 
 	mfctl           %cr19,%r9 /* Get iir */
+
+	/* PA 2.0 Arch Ref. Book pg 382 has a good description of the insn bits.
+	   Checks for fdc,fdce,pdc,"fic,4f",prober,probeir,probew, probeiw */
+
+	/* Checks for fdc,fdce,pdc,"fic,4f" only */
 	ldi             0x280,%r16
 	and             %r9,%r16,%r17
-	cmpb,<>,n       %r16,%r17,nadtlb_fault /* Not fdc,fic,pdc */
+	cmpb,<>,n       %r16,%r17,nadtlb_probe_check
 	bb,>=,n         %r9,26,nadtlb_nullify  /* m bit not set, just nullify */
 	BL		get_register,%r25
 	extrw,u         %r9,15,5,%r8           /* Get index register # */
@@ -1472,6 +1503,32 @@
 	rfir
 	nop
 
+	/* 
+		When there is no translation for the probe address then we
+		must nullify the insn and return zero in the target regsiter.
+		This will indicate to the calling code that it does not have 
+		write/read privileges to this address.
+
+		This should technically work for prober and probew in PA 1.1,
+		and also probe,r and probe,w in PA 2.0
+
+		WARNING: USE ONLY NON-SHADOW REGISTERS WITH PROBE INSN!
+		THE SLOW-PATH EMULATION HAS NOT BEEN WRITTEN YET.
+
+	*/
+nadtlb_probe_check:
+	ldi             0x80,%r16
+	and             %r9,%r16,%r17
+	cmpb,<>,n       %r16,%r17,nadtlb_fault /* Must be probe,[rw]*/
+	BL              get_register,%r25      /* Find the target register */
+	extrw,u         %r9,31,5,%r8           /* Get target register */
+	CMPIB=,n        -1,%r1,nadtlb_fault    /* have to use slow path */
+	BL		set_register,%r25
+	copy            %r0,%r1                /* Write zero to target register */
+	b nadtlb_nullify                       /* Nullify return insn */
+	nop
+
+
 #ifdef __LP64__
 itlb_miss_20w:
 
@@ -1762,7 +1819,7 @@
 
 	LDREG	PT_GR30(%r1),%r25
 	copy	%r1,%r24
-	bl	sys_clone,%r2
+	BL	sys_clone,%r2
 	ldi	SIGCHLD,%r26
 
 	LDREG	-RP_OFFSET-FRAME_SIZE(%r30),%r2
@@ -1782,7 +1839,7 @@
 
 	/* Set the return value for the child */
 child_return:
-	bl	schedule_tail, %r2
+	BL	schedule_tail, %r2
 	nop
 
 	LDREG	TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE-FRAME_SIZE(%r30), %r1
@@ -1807,7 +1864,7 @@
 
 	STREG	%r2,PT_GR19(%r1)	/* save for child */
 	STREG	%r30,PT_GR21(%r1)
-	bl	sys_clone,%r2
+	BL	sys_clone,%r2
 	copy	%r1,%r24
 
 	b	wrapper_exit
@@ -1830,7 +1887,7 @@
 	STREG	%r2,PT_GR19(%r1)	/* save for child */
 	STREG	%r30,PT_GR21(%r1)
 
-	bl	sys_vfork,%r2
+	BL	sys_vfork,%r2
 	copy	%r1,%r26
 
 	b	wrapper_exit
@@ -1893,10 +1950,10 @@
 	STREG	%r2, -RP_OFFSET(%r30)
 #ifdef __LP64__
 	ldo	FRAME_SIZE(%r30), %r30
-	bl	sys_rt_sigreturn,%r2
+	BL	sys_rt_sigreturn,%r2
 	ldo	-16(%r30),%r29		/* Reference param save area */
 #else
-	bl	sys_rt_sigreturn,%r2
+	BL	sys_rt_sigreturn,%r2
 	ldo	FRAME_SIZE(%r30), %r30
 #endif
 
@@ -1924,7 +1981,7 @@
 	STREG	%r2, -RP_OFFSET(%r30)
 #ifdef __LP64__
 	ldo	FRAME_SIZE(%r30), %r30
-	bl	do_sigaltstack,%r2
+	b,l	do_sigaltstack,%r2
 	ldo	-16(%r30),%r29		/* Reference param save area */
 #else
 	bl	do_sigaltstack,%r2
@@ -1944,7 +2001,7 @@
 	LDREG	TASK_PT_GR30(%r24),%r24
 	STREG	%r2, -RP_OFFSET(%r30)
 	ldo	FRAME_SIZE(%r30), %r30
-	bl	do_sigaltstack32,%r2
+	b,l	do_sigaltstack32,%r2
 	ldo	-16(%r30),%r29		/* Reference param save area */
 
 	ldo	-FRAME_SIZE(%r30), %r30
@@ -1962,7 +2019,7 @@
 	STREG	%r2, -RP_OFFSET(%r30)
 #ifdef __LP64__
 	ldo	FRAME_SIZE(%r30), %r30
-	bl	sys_rt_sigsuspend,%r2
+	b,l	sys_rt_sigsuspend,%r2
 	ldo	-16(%r30),%r29		/* Reference param save area */
 #else
 	bl	sys_rt_sigsuspend,%r2
@@ -1981,9 +2038,11 @@
 
 	.export syscall_exit
 syscall_exit:
+
 	/* NOTE: HP-UX syscalls also come through here
-	   after hpux_syscall_exit fixes up return
-	   values. */
+	 * after hpux_syscall_exit fixes up return
+	 * values. */
+
 	/* NOTE: Not all syscalls exit this way.  rt_sigreturn will exit
 	 * via syscall_exit_rfi if the signal was received while the process
 	 * was running.
@@ -2082,11 +2141,15 @@
 	LDREG	TASK_PT_GR29(%r1),%r29
 	LDREG	TASK_PT_GR31(%r1),%r31	   /* restore syscall rp */
 
+	/* NOTE: We use rsm/ssm pair to make this operation atomic */
 	rsm     PSW_SM_I, %r0
 	LDREG   TASK_PT_GR30(%r1),%r30             /* restore user sp */
 	mfsp	%sr3,%r1			   /* Get users space id */
 	mtsp    %r1,%sr7                           /* Restore sr7 */
 	ssm     PSW_SM_I, %r0
+
+	/* Set sr2 to zero for userspace syscalls to work. */
+	mtsp	%r0,%sr2 
 	mtsp	%r1,%sr4			   /* Restore sr4 */
 	mtsp	%r1,%sr5			   /* Restore sr5 */
 	mtsp	%r1,%sr6			   /* Restore sr6 */
@@ -2154,12 +2217,18 @@
 	bb,<	%r2,30,pt_regs_ok		   /* Branch if D set */
 	ldo	TASK_REGS(%r1),%r25
 	reg_save %r25				   /* Save r3 to r18 */
+
+	/* Save the current sr */
 	mfsp	%sr0,%r2
 	STREG	%r2,TASK_PT_SR0(%r1)
+
+	/* Save the scratch sr */
 	mfsp	%sr1,%r2
 	STREG	%r2,TASK_PT_SR1(%r1)
-	mfsp	%sr2,%r2
-	STREG	%r2,TASK_PT_SR2(%r1)
+
+	/* sr2 should be set to zero for userspace syscalls */
+	STREG	%r0,TASK_PT_SR2(%r1)
+
 pt_regs_ok:
 	LDREG	TASK_PT_GR31(%r1),%r2
 	depi	3,31,2,%r2			   /* ensure return to user mode. */
@@ -2174,12 +2243,15 @@
 syscall_do_softirq:
 	bl      do_softirq,%r2
 	nop
+	/* NOTE: We enable I-bit incase we schedule later,
+	 * and we might be going back to userspace if we were
+	 * traced. */
 	b       syscall_check_resched
 	ssm     PSW_SM_I, %r0  /* do_softirq returns with I bit off */
 
 	.import schedule,code
 syscall_do_resched:
-	bl	schedule,%r2
+	BL	schedule,%r2
 #ifdef __LP64__
 	ldo	-16(%r30),%r29		/* Reference param save area */
 #else
@@ -2203,7 +2275,7 @@
 #ifdef __LP64__
 	ldo	-16(%r30),%r29			/* Reference param save area */
 #endif
-	bl	do_signal,%r2
+	BL	do_signal,%r2
 	copy	%r0, %r26			/* sigset_t *oldset = NULL */
 
 	LDREG	TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
diff -Nru a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c
--- a/arch/parisc/kernel/firmware.c	2004-12-24 13:36:18 -08:00
+++ b/arch/parisc/kernel/firmware.c	2004-12-24 13:36:18 -08:00
@@ -1276,7 +1276,7 @@
 long real64_call(unsigned long fn, ...)
 {
 	va_list args;
-	extern struct wide_stack real64_stack __attribute__ ((alias ("real_stack")));
+	extern struct wide_stack real64_stack;
 	extern unsigned long real64_call_asm(unsigned long *,
 					     unsigned long *, 
 					     unsigned long);
diff -Nru a/arch/parisc/kernel/head.S b/arch/parisc/kernel/head.S
--- a/arch/parisc/kernel/head.S	2004-12-24 13:37:18 -08:00
+++ b/arch/parisc/kernel/head.S	2004-12-24 13:37:18 -08:00
@@ -1,12 +1,13 @@
-/*
- *
- * This file is subject to the terms and conditions of the GNU General Public
+/* 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) 1999 by Helge Deller
  * Copyright 1999 SuSE GmbH (Philipp Rumpf)
  * Copyright 1999 Philipp Rumpf (prumpf@tux.org)
+ * Copyright 2000 Hewlett Packard (Paul Bame, bame@puffin.external.hp.com)
+ * Copyright (C) 2001 Grant Grundler (Hewlett Packard)
+ * Copyright (C) 2004 Kyle McMartin <kyle@debian.org>
  *
  * Initial Version 04-23-1999 by Helge Deller <deller@gmx.de>
  */
@@ -15,12 +16,12 @@
 
 #include <asm/offsets.h>
 #include <asm/psw.h>
-
+#include <asm/pdc.h>
+	
 #include <asm/assembly.h>
 #include <asm/pgtable.h>
 
-
-	.level 1.1
+	.level	LEVEL
 
 	.data
 
@@ -32,12 +33,13 @@
 	.word 0 /* arg3 */
 
 	.text
-	.align	4	
+	.align	4
 	.import init_thread_union,data
+	.import fault_vector_20,code    /* IVA parisc 2.0 32 bit */
+#ifndef __LP64__
+        .import fault_vector_11,code    /* IVA parisc 1.1 32 bit */
 	.import	$global$		/* forward declaration */
-	.import fault_vector_11,code	/* IVA parisc 1.1 32 bit */
-	.import fault_vector_20,code	/* IVA parisc 2.0 32 bit */
-
+#endif /*!LP64*/
 	.export stext
 	.export _stext,data		/* Kernel want it this way! */
 _stext:
@@ -56,72 +58,84 @@
 	.import __bss_start,data
 	.import __bss_stop,data
 
-	ldil            L%PA(__bss_start),%r3
-	ldo             R%PA(__bss_start)(%r3),%r3
-	ldil            L%PA(__bss_stop),%r4
-	ldo             R%PA(__bss_stop)(%r4),%r4
+	load32		PA(__bss_start),%r3
+	load32		PA(__bss_stop),%r4
 $bss_loop:
 	cmpb,<<,n       %r3,%r4,$bss_loop
 	stw,ma          %r0,4(%r3)
 
 	/* Save away the arguments the boot loader passed in (32 bit args) */
-
-	ldil            L%PA(boot_args),%r1
-	ldo             R%PA(boot_args)(%r1),%r1
+	load32		PA(boot_args),%r1
 	stw,ma          %arg0,4(%r1)
 	stw,ma          %arg1,4(%r1)
 	stw,ma          %arg2,4(%r1)
 	stw,ma          %arg3,4(%r1)
 
 	/* Initialize startup VM. Just map first 8 MB of memory */
-	ldil		L%PA(pg0),%r1
-	ldo		R%PA(pg0)(%r1),%r1
-	shr		%r1,PxD_VALUE_SHIFT,%r3
-	ldo		(PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3
+	load32		PA(pg0),%r1
 
-	ldil		L%PA(swapper_pg_dir),%r4
-	ldo		R%PA(swapper_pg_dir)(%r4),%r4
+#ifdef __LP64__
+	load32		PA(pmd0),%r5
+	shrd            %r5,PxD_VALUE_SHIFT,%r3	
+#else
+	shr		%r1,PxD_VALUE_SHIFT,%r3
+#endif
+        ldo             (PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3	
+	
+	load32		PA(swapper_pg_dir),%r4
 	mtctl		%r4,%cr24	/* Initialize kernel root pointer */
 	mtctl		%r4,%cr25	/* Initialize user root pointer */
+
+#ifdef __LP64__
+	stw		%r3,ASM_PGD_ENTRY*ASM_PGD_ENTRY_SIZE(%r4)
+	shrd		%r1,PxD_VALUE_SHIFT,%r3
+	ldo		(PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3
+	ldo		ASM_PMD_ENTRY*ASM_PMD_ENTRY_SIZE(%r5),%r5
+#else
+        ldo             ASM_PGD_ENTRY*ASM_PGD_ENTRY_SIZE(%r4),%r4
+#endif
 	ldi		ASM_PT_INITIAL,%r1
-	ldo		ASM_PGD_ENTRY*ASM_PGD_ENTRY_SIZE(%r4),%r4
+
 1:
+#ifdef __LP64__
+	stw             %r3,0(%r5)
+#else
 	stw             %r3,0(%r4)
+#endif
+	
 	ldo		(ASM_PAGE_SIZE >> PxD_VALUE_SHIFT)(%r3),%r3
 	addib,>		-1,%r1,1b
+
+#ifdef __LP64__
+	ldo		ASM_PMD_ENTRY_SIZE(%r5),%r5
+#else
 	ldo		ASM_PGD_ENTRY_SIZE(%r4),%r4
+#endif
 
 	ldo		_PAGE_KERNEL(%r0),%r3 /* Hardwired 0 phys addr start */
-	ldil		L%PA(pg0),%r1
-	ldo		R%PA(pg0)(%r1),%r1
+	load32		PA(pg0),%r1
+
 $pgt_fill_loop:
-	stwm		%r3,ASM_PTE_ENTRY_SIZE(%r1)
+	STREGM          %r3,ASM_PTE_ENTRY_SIZE(%r1)
 	ldo		ASM_PAGE_SIZE(%r3),%r3
 	bb,>=		%r3,31-KERNEL_INITIAL_ORDER,$pgt_fill_loop
 	nop
 
-
 	/* Load the return address...er...crash 'n burn */
 	copy		%r0,%r2
 
 	/* And the RFI Target address too */
-	ldil            L%start_kernel,%r11
-	ldo             R%start_kernel(%r11),%r11
+	load32		start_kernel,%r11
 
 	/* And the initial task pointer */
-
-	ldil            L%init_thread_union,%r6
-	ldo             R%init_thread_union(%r6),%r6
+	load32		init_thread_union,%r6
 	mtctl           %r6,%cr30
 
 	/* And the stack pointer too */
-
 	ldo             THREAD_SZ_ALGN(%r6),%sp
 
 	/* And the interrupt stack */
-
-	ldil            L%interrupt_stack,%r6
-	ldo             R%interrupt_stack(%r6),%r6
+	load32		interrupt_stack,%r6
 	mtctl           %r6,%cr31
 
 #ifdef CONFIG_SMP
@@ -130,8 +144,7 @@
 	** it's just way easier to deal with here because
 	** of 64-bit function ptrs and the address is local to this file.
 	*/
-	ldil		L%PA(smp_slave_stext),%r10
-	ldo		R%PA(smp_slave_stext)(%r10),%r10
+	load32		PA(smp_slave_stext),%r10
 	stw		%r10,0x10(%r0)	/* MEM_RENDEZ */
 	stw		%r0,0x28(%r0)	/* MEM_RENDEZ_HI - assume addr < 4GB */
 
@@ -141,10 +154,16 @@
 	/*
 	** Code Common to both Monarch and Slave processors.
 	** Entry:
+	**
+	**  1.1:	
 	**    %r11 must contain RFI target address.
 	**    %r25/%r26 args to pass to target function
 	**    %r2  in case rfi target decides it didn't like something
 	**
+	**  2.0w:
+	**    %r3  PDCE_PROC address
+	**    %r11 RFI target address
+	**
 	** Caller must init: SR4-7, %sp, %r10, %cr24/25, 
 	*/
 common_stext:
@@ -154,8 +173,50 @@
 	/* Clear PDC entry point - we won't use it */
 	stw		%r0,0x10(%r0)	/* MEM_RENDEZ */
 	stw		%r0,0x28(%r0)	/* MEM_RENDEZ_HI */
-#endif
+#endif /*CONFIG_SMP*/
+
+#ifdef __LP64__
+	tophys_r1	%sp
 
+	/* Save the rfi target address */
+	ldd             TI_TASK-THREAD_SZ_ALGN(%sp), %r10
+	tophys_r1       %r10
+	std             %r11,  TASK_PT_GR11(%r10)
+	/* Switch to wide mode Superdome doesn't support narrow PDC
+	** calls.
+	*/
+1:	mfia            %rp             /* clear upper part of pcoq */
+	ldo             2f-1b(%rp),%rp
+	depdi           0,31,32,%rp
+	bv              (%rp)
+	ssm             PSW_SM_W,%r0
+
+        /* Set Wide mode as the "Default" (eg for traps)
+        ** First trap occurs *right* after (or part of) rfi for slave CPUs.
+        ** Someday, palo might not do this for the Monarch either.
+        */
+2:
+#define MEM_PDC_LO 0x388
+#define MEM_PDC_HI 0x35C
+	ldw             MEM_PDC_LO(%r0),%r3
+	ldw             MEM_PDC_HI(%r0),%r6
+	depd            %r6, 31, 32, %r3        /* move to upper word */
+
+	ldo             PDC_PSW(%r0),%arg0              /* 21 */
+	ldo             PDC_PSW_SET_DEFAULTS(%r0),%arg1 /* 2 */
+	ldo             PDC_PSW_WIDE_BIT(%r0),%arg2     /* 2 */
+	load32          PA(stext_pdc_ret), %rp
+	bv              (%r3)
+	copy            %r0,%arg3
+
+stext_pdc_ret:
+	/* restore rfi target address*/
+	ldd             TI_TASK-THREAD_SZ_ALGN(%sp), %r10
+	tophys_r1       %r10
+	ldd             TASK_PT_GR11(%r10), %r11
+	tovirt_r1       %sp
+#endif
+	
 	/* PARANOID: clear user scratch/user space SR's */
 	mtsp	%r0,%sr0
 	mtsp	%r0,%sr1
@@ -168,17 +229,18 @@
 	mtctl	%r0,%cr12
 	mtctl	%r0,%cr13
 
+	/* Prepare to RFI! Man all the cannons! */
+
 	/* Initialize the global data pointer */
-	ldil		L%$global$,%dp
-	ldo		R%$global$(%dp),%dp
+	loadgp
 
-	/*
-	 * Set up our interrupt table.  HPMCs might not work after this! 
+	/* Set up our interrupt table.  HPMCs might not work after this! 
 	 *
 	 * We need to install the correct iva for PA1.1 or PA2.0. The
 	 * following short sequence of instructions can determine this
 	 * (without being illegal on a PA1.1 machine).
 	 */
+#ifndef __LP64__
 	ldi		32,%r10
 	mtctl		%r10,%cr11
 	.level 2.0
@@ -190,14 +252,39 @@
 	ldo		R%PA(fault_vector_11)(%r10),%r10
 
 $is_pa20:
-	ldil		L%PA(fault_vector_20),%r10
-	ldo		R%PA(fault_vector_20)(%r10),%r10
+	.level		LEVEL /* restore 1.1 || 2.0w */
+#endif /*!LP64*/
+	load32		PA(fault_vector_20),%r10
 
 $install_iva:
 	mtctl		%r10,%cr14
 
-	/* Disable Q bit so we can load the iia queue */
-	rsm            PSW_SM_Q,%r0
+#ifdef __LP64__
+	b		aligned_rfi
+	nop
+
+	.align          256
+aligned_rfi:
+	ssm             0,0
+	nop             /* 1 */
+	nop             /* 2 */
+	nop             /* 3 */
+	nop             /* 4 */
+	nop             /* 5 */
+	nop             /* 6 */
+	nop             /* 7 */
+	nop             /* 8 */
+#endif
+
+#ifdef __LP64__ /* move to psw.h? */
+#define		PSW_BITS	PSW_Q+PSW_I+PSW_D+PSW_P+PSW_R
+#else
+#define		PSW_BITS	PSW_SM_Q
+#endif
+
+$rfi:	
+	/* turn off troublesome PSW bits */
+	rsm		PSW_BITS,%r0
 
 	/* kernel PSW:
 	 *  - no interruptions except HPMC and TOC (which are handled by PDC)
@@ -205,8 +292,7 @@
 	 *  - big-endian
 	 *  - virtually mapped
 	 */
-	ldil		L%KERNEL_PSW,%r10
-	ldo		R%KERNEL_PSW(%r10),%r10
+	load32		KERNEL_PSW,%r10
 	mtctl		%r10,%ipsw
 
 	/* Set the space pointers for the post-RFI world
@@ -232,6 +318,7 @@
 	.import smp_init_current_idle_task,data
 	.import	smp_callin,code
 
+#ifndef __LP64__
 smp_callin_rtn:
         .proc
 	.callinfo
@@ -239,9 +326,9 @@
 	nop
 	nop
         .procend
+#endif /*!LP64*/
 
 /***************************************************************************
-*
 * smp_slave_stext is executed by all non-monarch Processors when the Monarch
 * pokes the slave CPUs in smp.c:smp_boot_cpus().
 *
@@ -249,8 +336,6 @@
 * mode. Once all available/eligible CPUs are in virtual mode, all are
 * released and start out by executing their own idle task.
 *****************************************************************************/
-
-
 smp_slave_stext:
         .proc
 	.callinfo
@@ -264,28 +349,28 @@
 	mtsp	   %r0,%sr7
 
 	/*  Initialize the SP - monarch sets up smp_init_current_idle_task */
-	ldil		L%PA(smp_init_current_idle_task),%sp
-	ldo		R%PA(smp_init_current_idle_task)(%sp),%sp
-	ldw		0(%sp),%sp	/* load task address */
+	load32		PA(smp_init_current_idle_task),%sp
+	LDREG		0(%sp),%sp	/* load task address */
 	tophys_r1	%sp
-	ldw		TASK_THREAD_INFO(%sp), %sp
+	LDREG		TASK_THREAD_INFO(%sp),%sp
 	mtctl           %sp,%cr30       /* store in cr30 */
-	addil		L%THREAD_SZ_ALGN,%sp	/* stack is above task */
-	ldo		R%THREAD_SZ_ALGN(%r1),%sp
+	ldo             THREAD_SZ_ALGN(%sp),%sp
 
 	/* point CPU to kernel page tables */
-	ldil		L%PA(swapper_pg_dir),%r4
-	ldo		R%PA(swapper_pg_dir)(%r4),%r4
+	load32		PA(swapper_pg_dir),%r4
 	mtctl		%r4,%cr24	/* Initialize kernel root pointer */
 	mtctl		%r4,%cr25	/* Initialize user root pointer */
 
+#ifdef __LP64__
+	/* Setup PDCE_PROC entry */
+	copy            %arg0,%r3
+#else
 	/* Load RFI *return* address in case smp_callin bails */
-	ldil		L%smp_callin_rtn,%r2
-	ldo		R%smp_callin_rtn(%r2),%r2
-
+	load32		smp_callin_rtn,%r2
+#endif
+	
 	/* Load RFI target address.  */
-	ldil		L%smp_callin,%r11
-	ldo		R%smp_callin(%r11),%r11
+	load32		smp_callin,%r11
 	
 	/* ok...common code can handle the rest */
 	b		common_stext
@@ -293,7 +378,7 @@
 
 	.procend
 #endif /* CONFIG_SMP */
-
+#ifndef __LP64__
 	.data
 
 	.align	4
@@ -303,3 +388,4 @@
 	.size	$global$,4
 $global$:	
 	.word 0
+#endif /*!LP64*/
diff -Nru a/arch/parisc/kernel/head64.S b/arch/parisc/kernel/head64.S
--- a/arch/parisc/kernel/head64.S	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,327 +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) 1999 by Helge Deller
- * Copyright 1999 SuSE GmbH (Philipp Rumpf)
- * Copyright 1999 Philipp Rumpf (prumpf@tux.org)
- * Copyright 2000 Hewlett Packard (Paul Bame, bame@puffin.external.hp.com)
- * Copyright (C) 2001 Grant Grundler (Hewlett Packard)
- *
- * Initial Version 04-23-1999 by Helge Deller <deller@gmx.de>
- */
-
-
-#include <linux/autoconf.h>	/* for CONFIG_SMP */
-
-#include <asm/offsets.h>
-#include <asm/psw.h>
-
-#include <asm/assembly.h>
-#include <asm/pgtable.h>
-#include <asm/pdc.h>		/* for PDC_PSW defines */
-
-
-	.level 2.0w
-
-	.data
-
-	.export boot_args
-boot_args:
-	.word 0 /* arg0 */
-	.word 0 /* arg1 */
-	.word 0 /* arg2 */
-	.word 0 /* arg3 */
-
-	.text
-	.align	4	
-
-	.export stext
-	.export _stext,data		/* Kernel want it this way! */
-_stext:
-stext:
-	.proc
-	.callinfo
-
-	/* Make sure sr4-sr7 are set to zero for the kernel address space */
-	mtsp	%r0,%sr4
-	mtsp	%r0,%sr5
-	mtsp	%r0,%sr6
-	mtsp	%r0,%sr7
-
-	/* Clear BSS (shouldn't the boot loader do this?) */
-
-	.import __bss_start,data
-	.import __bss_stop,data
-
-	ldil            L%PA(__bss_start),%r3
-	ldo             R%PA(__bss_start)(%r3),%r3
-	ldil            L%PA(__bss_stop),%r4
-	ldo             R%PA(__bss_stop)(%r4),%r4
-$bss_loop:
-	cmpb,<<,n       %r3,%r4,$bss_loop
-	stb,ma          %r0,1(%r3)
-
-	/* Save away the arguments the boot loader passed in (32 bit args) */
-
-	ldil            L%PA(boot_args),%r1
-	ldo             R%PA(boot_args)(%r1),%r1
-	stw,ma          %arg0,4(%r1)
-	stw,ma          %arg1,4(%r1)
-	stw,ma          %arg2,4(%r1)
-	stw,ma          %arg3,4(%r1)
-
-	/* Initialize startup VM. Just map first 8 MB of memory */
-
-	ldil		L%PA(pg0),%r1
-	ldo		R%PA(pg0)(%r1),%r1
-
-	ldil		L%PA(pmd0),%r5
-	ldo		R%PA(pmd0)(%r5),%r5
-	shrd		%r5,PxD_VALUE_SHIFT,%r3
-	ldo		(PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3
-
-	ldil		L%PA(swapper_pg_dir),%r4
-	ldo		R%PA(swapper_pg_dir)(%r4),%r4
-
-	mtctl		%r4,%cr24	/* Initialize kernel root pointer */
-	mtctl		%r4,%cr25	/* Initialize user root pointer */
-
-	stw             %r3,ASM_PGD_ENTRY*ASM_PGD_ENTRY_SIZE(%r4)
-
-	shrd		%r1,PxD_VALUE_SHIFT,%r3
-	ldo		(PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3
-	ldo		ASM_PMD_ENTRY*ASM_PMD_ENTRY_SIZE(%r5),%r5
-	ldi		ASM_PT_INITIAL,%r1
-1:
-	stw		%r3,0(%r5)
-	ldo		(ASM_PAGE_SIZE >> PxD_VALUE_SHIFT)(%r3),%r3
-	addib,>		-1,%r1,1b
-	ldo		ASM_PMD_ENTRY_SIZE(%r5),%r5
-
-	ldo             _PAGE_KERNEL(%r0),%r3 /* Hardwired 0 phys addr start */
-	ldil		L%PA(pg0),%r1
-	ldo		R%PA(pg0)(%r1),%r1
-
-$pgt_fill_loop:
-	std,ma		%r3,ASM_PTE_ENTRY_SIZE(%r1)
-	ldo		ASM_PAGE_SIZE(%r3),%r3
-	bb,>=		%r3,31-KERNEL_INITIAL_ORDER,$pgt_fill_loop
-	nop
-
-	/* And the RFI Target address too */
-	load32          start_kernel, %r11
-
-	/* And the stack pointer too */
-	load32		PA(init_thread_union+THREAD_SZ_ALGN),%sp
-
-	/* And the initial task pointer */
-
-	load32          init_thread_union,%r6
-	mtctl           %r6,%cr30
-
-	/* And the interrupt stack */
-
-	load32          interrupt_stack,%r6
-	mtctl           %r6,%cr31
-
-	/* Act like PDC just called us - that's how slave CPUs enter */
-#define MEM_PDC_LO 0x388
-#define MEM_PDC_HI 0x35C
-	ldw		MEM_PDC_LO(%r0),%r3
-	ldw		MEM_PDC_HI(%r0),%r6
-	depd		%r6, 31, 32, %r3	/* move to upper word */
-
-#ifdef CONFIG_SMP
-	/* Set the smp rendevous address into page zero.
-	** It would be safer to do this in init_smp_config() but
-	** it's just way easier to deal with here because
-	** of 64-bit function ptrs and the address is local to this file.
-	*/
-	ldil		L%PA(smp_slave_stext),%r10
-	ldo		R%PA(smp_slave_stext)(%r10),%r10
-	stw		%r10,0x10(%r0)	/* MEM_RENDEZ */
-	stw		%r0,0x28(%r0)	/* MEM_RENDEZ_HI - assume addr < 4GB */
-
-	/* FALLTHROUGH */
-	.procend
-
-	/*
-	** Code Common to both Monarch and Slave processors.
-	** Entry:
-	**    %r3	PDCE_PROC address
-	**    %r11	RFI target address.
-	**
-	** Caller must init: SR4-7, %sp, %r10, %cr24/25, 
-	*/
-common_stext:
-	.proc
-	.callinfo
-#else /* CONFIG_SMP */
-	/* Clear PDC's CPU handoff address - we won't use it */
-	stw		%r0,0x10(%r0)	/* MEM_RENDEZ */
-	stw		%r0,0x28(%r0)	/* MEM_RENDEZ_HI */
-#endif /* CONFIG_SMP */
-
-	/* Save the rfi target address */
-	ldd		TI_TASK-THREAD_SZ_ALGN(%sp), %r10
-	tophys_r1	%r10
-	std		%r11,  TASK_PT_GR11(%r10)
-
-	/* Switch to wide mode; Superdome doesn't support narrow PDC
-	** calls.
-	*/
-1:	mfia		%rp		/* clear upper part of pcoq */
-	ldo		2f-1b(%rp),%rp
-	depdi		0,31,32,%rp
-	bv		(%rp)
-	ssm		PSW_SM_W,%r0
-2:
-
-	/* Set Wide mode as the "Default" (eg for traps)
-	** First trap occurs *right* after (or part of) rfi for slave CPUs.
-	** Someday, palo might not do this for the Monarch either.
-	*/
-
-	ldo		PDC_PSW(%r0),%arg0		/* 21 */
-	ldo		PDC_PSW_SET_DEFAULTS(%r0),%arg1	/* 2 */
-	ldo		PDC_PSW_WIDE_BIT(%r0),%arg2	/* 2 */
-
-	load32		PA(stext_pdc_ret), %rp
-
-	bv		(%r3)
-	copy		%r0,%arg3
-
-stext_pdc_ret:
-	/* restore rfi target address*/
-	ldd		TI_TASK-THREAD_SZ_ALGN(%sp), %r10
-	tophys_r1	%r10
-	ldd		TASK_PT_GR11(%r10), %r11
-
-	/* PARANOID: clear user scratch/user space SR's */
-	mtsp	%r0,%sr0
-	mtsp	%r0,%sr1
-	mtsp	%r0,%sr2
-	mtsp	%r0,%sr3
-
-	/* Initialize Protection Registers */
-	mtctl	%r0,%cr8
-	mtctl	%r0,%cr9
-	mtctl	%r0,%cr12
-	mtctl	%r0,%cr13
-
-	/* Prepare to RFI! Man all the cannons! */
-	tovirt_r1       %sp
-
-	/* Initialize the global data pointer */
-	load32		__gp,%dp
-
-	/* Set up our interrupt table.  HPMCs might not work after this! */
-	ldil		L%PA(fault_vector_20),%r10
-	ldo		R%PA(fault_vector_20)(%r10),%r10
-	mtctl		%r10,%cr14
-
-	b		aligned_rfi
-	nop
-
-	/* the magic spell */
-	.align          256
-aligned_rfi:
-	ssm		0,0
-	nop		/* 1 */
-	nop		/* 2 */
-	nop		/* 3 */
-	nop		/* 4 */
-	nop		/* 5 */
-	nop		/* 6 */
-	nop		/* 7 */
-	nop		/* 8 */
-
-	/* turn off troublesome PSW bits */
-	rsm		PSW_Q+PSW_I+PSW_D+PSW_P+PSW_R, %r0
-
-	/* kernel PSW:
-	 *  - no interruptions except HPMC and TOC (which are handled by PDC)
-	 *  - Q bit set (IODC / PDC interruptions)
-	 *  - big-endian
-	 *  - virtually mapped
-	 */
-	load32		KERNEL_PSW,%r10
-	mtctl		%r10,%ipsw
-
-	/* Set the space pointers for the post-RFI world
-	** Clear the two-level IIA Space Queue, effectively setting
-	** Kernel space.
-	*/
-	mtctl		%r0,%cr17	/* Clear IIASQ tail */
-	mtctl		%r0,%cr17	/* Clear IIASQ head */
-
-	/* Load RFI target into PC queue */
-	mtctl		%r11,%cr18	/* IIAOQ head */
-	ldo		4(%r11),%r11
-	mtctl		%r11,%cr18	/* IIAOQ tail */
-
-	/* Jump to hyperspace */
-	rfi
-	nop
-
-	.procend
-
-
-#ifdef CONFIG_SMP
-
-	.import smp_init_current_idle_task,data
-	.import	smp_callin,code
-
-/***************************************************************************
-*
-* smp_slave_stext is executed by all non-monarch Processors when the Monarch
-* pokes the slave CPUs in smp.c:smp_boot_cpus().
-*
-* Once here, registers values are initialized in order to branch to virtual
-* mode. Once all available/eligible CPUs are in virtual mode, all are
-* released and start out by executing their own idle task.
-*****************************************************************************/
-
-
-smp_slave_stext:
-        .proc
-	.callinfo
-
-	/*
-	** Initialize Space registers
-	*/
-	mtsp	   %r0,%sr4
-	mtsp	   %r0,%sr5
-	mtsp	   %r0,%sr6
-	mtsp	   %r0,%sr7
-
-	/*  Initialize the SP - monarch sets up smp_init_current_idle_task */
-	load32		PA(smp_init_current_idle_task),%sp
-	ldd		0(%sp),%sp	/* load task address */
-	tophys_r1	%sp
-	ldd		TASK_THREAD_INFO(%sp), %sp
-	mtctl           %sp,%cr30       /* store in cr30 */
-	ldo             THREAD_SZ_ALGN(%sp),%sp
-	tophys_r1       %sp
-
-	/* point CPU to kernel page tables */
-	load32		PA(swapper_pg_dir),%r4
-	mtctl		%r4,%cr24	/* Initialize kernel root pointer */
-	mtctl		%r4,%cr25	/* Initialize user root pointer */
-
-	/* Setup PDCE_PROC entry */
-	copy		%arg0,%r3
-
-	/* Load RFI target address.  */
-	load32		smp_callin, %r11
-	
-	/* ok...common code can handle the rest */
-	b		common_stext
-	nop
-
-	.procend
-#endif /* CONFIG_SMP */
-
diff -Nru a/arch/parisc/kernel/pacache.S b/arch/parisc/kernel/pacache.S
--- a/arch/parisc/kernel/pacache.S	2004-12-24 13:36:30 -08:00
+++ b/arch/parisc/kernel/pacache.S	2004-12-24 13:36:30 -08:00
@@ -68,7 +68,7 @@
 	 * consolidated.
 	 */
 
-	rsm     PSW_SM_I,%r19      /* relied upon translation! */
+	rsm     PSW_SM_I,%r19	/* relied upon translation! PA 2.0 Arch. F-5 */
 	nop
 	nop
 	nop
@@ -475,9 +475,9 @@
 	.procend
 #endif
 
-	.export clear_user_page_asm,code
+	.export __clear_user_page_asm,code
 
-clear_user_page_asm:
+__clear_user_page_asm:
 	.proc
 	.callinfo NO_CALLS
 	.entry
diff -Nru a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c
--- a/arch/parisc/kernel/parisc_ksyms.c	2004-12-24 13:37:32 -08:00
+++ b/arch/parisc/kernel/parisc_ksyms.c	2004-12-24 13:37:32 -08:00
@@ -32,7 +32,6 @@
 #include <linux/string.h>
 EXPORT_SYMBOL(memchr);
 EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
 EXPORT_SYMBOL(memscan);
 EXPORT_SYMBOL(memset);
@@ -65,12 +64,19 @@
 #endif
 
 #include <asm/uaccess.h>
-EXPORT_SYMBOL(lcopy_to_user);
-EXPORT_SYMBOL(lcopy_from_user);
-EXPORT_SYMBOL(lcopy_in_user);
 EXPORT_SYMBOL(lstrncpy_from_user);
 EXPORT_SYMBOL(lclear_user);
 EXPORT_SYMBOL(lstrnlen_user);
+
+/* Global fixups */
+extern void fixup_get_user_skip_1(void);
+extern void fixup_get_user_skip_2(void);
+extern void fixup_put_user_skip_1(void);
+extern void fixup_put_user_skip_2(void);
+EXPORT_SYMBOL(fixup_get_user_skip_1);
+EXPORT_SYMBOL(fixup_get_user_skip_2);
+EXPORT_SYMBOL(fixup_put_user_skip_1);
+EXPORT_SYMBOL(fixup_put_user_skip_2);
 
 #ifndef __LP64__
 /* Needed so insmod can set dp value */
diff -Nru a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
--- a/arch/parisc/kernel/pci-dma.c	2004-12-24 13:37:19 -08:00
+++ b/arch/parisc/kernel/pci-dma.c	2004-12-24 13:37:19 -08:00
@@ -104,7 +104,9 @@
 		if (!pte_none(*pte))
 			printk(KERN_ERR "map_pte_uncached: page already exists\n");
 		set_pte(pte, __mk_pte(*paddr_ptr, PAGE_KERNEL_UNC));
+		purge_tlb_start();
 		pdtlb_kernel(orig_vaddr);
+		purge_tlb_end();
 		vaddr += PAGE_SIZE;
 		orig_vaddr += PAGE_SIZE;
 		(*paddr_ptr) += PAGE_SIZE;
@@ -179,7 +181,9 @@
 	do {
 		pte_t page = *pte;
 		pte_clear(pte);
+		purge_tlb_start();
 		pdtlb_kernel(orig_vaddr);
+		purge_tlb_end();
 		vaddr += PAGE_SIZE;
 		orig_vaddr += PAGE_SIZE;
 		pte++;
diff -Nru a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
--- a/arch/parisc/kernel/pdc_cons.c	2004-12-24 13:37:43 -08:00
+++ b/arch/parisc/kernel/pdc_cons.c	2004-12-24 13:37:43 -08:00
@@ -71,6 +71,19 @@
 	pdc_iodc_outc(c);
 }
 
+void pdc_printf(const char *fmt, ...)
+{
+	va_list args;
+	char buf[1024];
+	int i, len;
+
+	va_start(args, fmt);
+	len = vscnprintf(buf, sizeof(buf), fmt, args);
+	va_end(args);
+
+	for (i = 0; i < len; i++)
+		pdc_iodc_outc(buf[i]);
+}
 
 int pdc_console_poll_key(struct console *co)
 {
diff -Nru a/arch/parisc/kernel/perf_asm.S b/arch/parisc/kernel/perf_asm.S
--- a/arch/parisc/kernel/perf_asm.S	2004-12-24 13:37:18 -08:00
+++ b/arch/parisc/kernel/perf_asm.S	2004-12-24 13:37:18 -08:00
@@ -1,18 +1,19 @@
 
 /*    low-level asm for "intrigue" (PA8500-8700 CPU perf counters)
- *
+ * 
  *    Copyright (C) 2001 Randolph Chung <tausq at parisc-linux.org>
- *
+ *    Copyright (C) 2001 Hewlett-Packard (Grant Grundler)
+ * 
  *    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
@@ -48,7 +49,7 @@
 	.proc
 	.callinfo  frame=0,NO_CALLS
 	.entry
-	
+
 	ldi     0x20,%r25                ; load up perfmon bit
 	mfctl   ccr,%r26                 ; get coprocessor register
 	or      %r25,%r26,%r26             ; set bit
@@ -87,35 +88,35 @@
 	.exit
 	.procend
 
-;************************************************************************
-;*																		*
-;* Name: perf_rdr_shift_in_W												*
-;*																		*
-;* Description:															*
-;*	This routine shifts data in from the RDR in arg0 and returns		*
-;*	the result in ret0.  If the RDR is <= 64 bits in length, it			*
-;*	is shifted shifted backup immediately.  This is to compensate		*
-;*	for RDR10 which has bits that preclude PDC stack operations			*
-;*	when they are in the wrong state.									*
-;*																		*
-;* Arguments:															*
-;*	arg0 : rdr to be read												*
-;*	arg1 : bit length of rdr											*
-;*																		*
-;* Returns:																*
-;*	ret0 = next 64 bits of rdr data from staging register				*
-;*																		*
-;* Register usage:														*
-;*	arg0 : rdr to be read												*
-;*	arg1 : bit length of rdr											*
-;*	%r24  - original DR2 value											*
-;*	%r1   - scratch														*
-;*  %r29  - scratch														*
-;*																		*
-;* Returns:																*
-;*	ret0 = RDR data (right justified)									*
-;*																		*
-;************************************************************************
+;***********************************************************************
+;*
+;* Name: perf_rdr_shift_in_W
+;*
+;* Description:
+;*	This routine shifts data in from the RDR in arg0 and returns
+;*	the result in ret0.  If the RDR is <= 64 bits in length, it
+;*	is shifted shifted backup immediately.  This is to compensate
+;*	for RDR10 which has bits that preclude PDC stack operations
+;*	when they are in the wrong state.
+;*
+;* Arguments:
+;*	arg0 : rdr to be read
+;*	arg1 : bit length of rdr
+;*
+;* Returns:
+;*	ret0 = next 64 bits of rdr data from staging register
+;*
+;* Register usage:
+;*	arg0 : rdr to be read
+;*	arg1 : bit length of rdr
+;*	%r24  - original DR2 value
+;*	%r1   - scratch
+;*  %r29  - scratch
+;*
+;* Returns:
+;*	ret0 = RDR data (right justified)
+;*
+;***********************************************************************
 
 	.export perf_rdr_shift_in_W,code
 perf_rdr_shift_in_W:
@@ -138,7 +139,7 @@
 	nop
 	nop
 	nop
-	nop	
+	nop
 
 ;
 ; Cacheline start (32-byte cacheline)
@@ -146,11 +147,11 @@
 	nop
 	nop
 	nop
-	extrd,u		arg1,63,6,%r1    ; setup shift amount based on bits to move 
+	extrd,u		arg1,63,6,%r1	; setup shift amount by bits to move 
 
 	mtsar		%r1
 	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
-	blr  		%r1,%r0		    ; branch to 8-instruction sequence
+	blr  		%r1,%r0		; branch to 8-instruction sequence
 	nop
 
 ;
@@ -160,19 +161,19 @@
 	;
 	; RDR 0 sequence
 	;
-	SFDIAG		(0)		
+	SFDIAG		(0)
 	ssm		    0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
-	MTDIAG_1	(1)					; mtdiag %dr1, %r1 
+	MTDIAG_1	(1)			; mtdiag %dr1, %r1 
 	STDIAG		(0)
 	ssm		    0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 1 sequence
 	;
-	sync			
+	sync
 	ssm		    0,0
 	SFDIAG		(1)
 	ssm		    0,0
@@ -180,11 +181,11 @@
 	ssm		    0,0
 	b,n         perf_rdr_shift_in_W_leave
 	nop
-	
+
 	;
 	; RDR 2 read sequence
 	;
-	SFDIAG		(2)		
+	SFDIAG		(2)
 	ssm		    0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
@@ -192,7 +193,7 @@
 	STDIAG		(2)
 	ssm		    0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 3 read sequence
 	;
@@ -208,39 +209,39 @@
 	;
 	; RDR 4 read sequence
 	;
-	sync				
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(4)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	; 
 	; RDR 5 read sequence
 	;
-	sync	
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(5)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 6 read sequence
 	;
-	sync	
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(6)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 7 read sequence
 	;
@@ -281,26 +282,26 @@
 	; RDR 10 read sequence
 	;
 	SFDIAG		(10)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(10)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 11 read sequence
 	;
 	SFDIAG		(11)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(11)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 12 read sequence
 	;
@@ -317,77 +318,77 @@
 	; RDR 13 read sequence
 	;
 	sync
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(13)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 14 read sequence
 	;
-	SFDIAG		(14)	
-	ssm			0,0
+	SFDIAG		(14)
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(14)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 15 read sequence
 	;
-	sync				; RDR 15 read sequence
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(15)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
 	nop
-	
+
 	;
 	; RDR 16 read sequence
 	;
-	sync				; RDR 16 read sequence
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(16)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 17 read sequence
 	;
-	SFDIAG		(17)	
-	ssm			0,0
+	SFDIAG		(17)
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(17)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 18 read sequence
 	;
-	SFDIAG		(18)	
-	ssm			0,0
+	SFDIAG		(18)
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(18)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
-;
-; RDR 19 read sequence
-;
+
+	;
+	; RDR 19 read sequence
+	;
 	b,n         perf_rdr_shift_in_W_leave
 	nop
 	nop
@@ -401,144 +402,144 @@
 	; RDR 20 read sequence
 	;
 	sync
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(20)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 21 read sequence
 	;
 	sync
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(21)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 22 read sequence
 	;
 	sync
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(22)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 23 read sequence
 	;
-	sync		
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(23)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 24 read sequence
 	;
-	sync	
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(24)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 25 read sequence
 	;
 	sync
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(25)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 26 read sequence
 	;
-	SFDIAG		(26)		
-	ssm			0,0
+	SFDIAG		(26)
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(26)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 27 read sequence
 	;
 	SFDIAG		(27)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(27)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 28 read sequence
 	;
-	sync				
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(28)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 29 read sequence
 	;
-	sync		
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(29)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_W_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	;
 	; RDR 30 read sequence
 	;
 	SFDIAG		(30)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(30)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_W_leave
-	
+
 	;
 	; RDR 31 read sequence
 	;
-	sync		
-	ssm			0,0
+	sync
+	ssm		0,0
 	SFDIAG		(31)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	;
@@ -552,28 +553,28 @@
 	.procend
 
 
-;************************************************************************
-;*																		*
-;* Name: perf_rdr_shift_out_W												*
-;*																		*
-;* Description:															*
-;*	This routine moves data to the RDR's.  The double-word that			*
-;*	arg1 points to is loaded and moved into the staging register.		*
-;*	Then the STDIAG instruction for the RDR # in arg0 is called			*
-;*	to move the data to the RDR.										*
-;*																		*
-;* Arguments:															*
-;*	arg0 = rdr number													*
-;*	arg1 = 64-bit value to write										*
-;*	%r24 - DR2 | DR2_SLOW_RET											*
-;*	%r23 - original DR2 value											*
-;*																		*
-;* Returns:																*
-;*	None																*
-;*																		*
-;* Register usage:														*
-;*																		*
-;************************************************************************
+;***********************************************************************
+;*
+;* Name: perf_rdr_shift_out_W
+;*
+;* Description:
+;*	This routine moves data to the RDR's.  The double-word that
+;*	arg1 points to is loaded and moved into the staging register.
+;*	Then the STDIAG instruction for the RDR # in arg0 is called
+;*	to move the data to the RDR.
+;*
+;* Arguments:
+;*	arg0 = rdr number
+;*	arg1 = 64-bit value to write
+;*	%r24 - DR2 | DR2_SLOW_RET
+;*	%r23 - original DR2 value
+;*
+;* Returns:
+;*	None
+;*
+;* Register usage:
+;*
+;***********************************************************************
 
 	.export perf_rdr_shift_out_W,code
 perf_rdr_shift_out_W:
@@ -587,24 +588,23 @@
 
 	depdi,z		1,DR2_SLOW_RET,1,%r24
 	MFDIAG_2	(23)
-	or		     %r24,%r23,%r24
-	MTDIAG_2	(24)			; set DR2_SLOW_RET
-
-	MTDIAG_1	(25)			; data to the staging register
+	or		%r24,%r23,%r24
+	MTDIAG_2	(24)		; set DR2_SLOW_RET
+	MTDIAG_1	(25)		; data to the staging register
 	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
-	blr		    %r1,%r0		    ; branch to 8-instruction sequence
+	blr		    %r1,%r0	; branch to 8-instruction sequence
 	nop
 
 	;
 	; RDR 0 write sequence
 	;
 	sync				; RDR 0 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(0)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_W_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	;
@@ -718,7 +718,7 @@
 	;
 	; RDR 10 write sequence
 	;
-	sync	
+	sync
 	ssm		0,0
 	STDIAG		(10)
 	STDIAG		(26)
@@ -862,7 +862,7 @@
 	;
 	; RDR 22 write sequence
 	;
-	sync	
+	sync
 	ssm		0,0
 	STDIAG		(22)
 	ssm		0,0
@@ -910,7 +910,7 @@
 	;
 	; RDR 26 write sequence
 	;
-	sync	
+	sync
 	ssm		0,0
 	STDIAG		(10)
 	STDIAG		(26)
@@ -958,7 +958,7 @@
 	;
 	; RDR 30 write sequence
 	;
-	sync	
+	sync
 	ssm		0,0
 	STDIAG		(30)
 	ssm		0,0
@@ -970,7 +970,7 @@
 	;
 	; RDR 31 write sequence
 	;
-	sync				
+	sync
 	ssm		0,0
 	STDIAG		(31)
 	ssm		0,0
@@ -986,34 +986,32 @@
 	.procend
 
 
-;**************************** CHRIS ***********************************
-
-;************************************************************************
-;*																		*
-;* Name: rdr_shift_in_U													*
-;*																		*
-;* Description:															*
-;*	This routine shifts data in from the RDR in arg0 and returns		*
-;*	the result in ret0.  If the RDR is <= 64 bits in length, it			*
-;*	is shifted shifted backup immediately.  This is to compensate		*
-;*	for RDR10 which has bits that preclude PDC stack operations			*
-;*	when they are in the wrong state.									*
-;*																		*
-;* Arguments:															*
-;*	arg0 : rdr to be read												*
-;*	arg1 : bit length of rdr											*
-;*																		*
-;* Returns:																*
-;*	ret0 = next 64 bits of rdr data from staging register				*
-;*																		*
-;* Register usage:														*
-;*	arg0 : rdr to be read						                        *
-;*	arg1 : bit length of rdr					                        *
-;*	%r24 - original DR2 value											*
-;*	%r23 - DR2 | DR2_SLOW_RET											*
-;*	%r1  - scratch														*
-;*																		*
-;************************************************************************
+;***********************************************************************
+;*
+;* Name: rdr_shift_in_U
+;*
+;* Description:
+;*	This routine shifts data in from the RDR in arg0 and returns
+;*	the result in ret0.  If the RDR is <= 64 bits in length, it
+;*	is shifted shifted backup immediately.  This is to compensate
+;*	for RDR10 which has bits that preclude PDC stack operations
+;*	when they are in the wrong state.
+;*
+;* Arguments:
+;*	arg0 : rdr to be read
+;*	arg1 : bit length of rdr
+;*
+;* Returns:
+;*	ret0 = next 64 bits of rdr data from staging register
+;*
+;* Register usage:
+;*	arg0 : rdr to be read						                        
+;*	arg1 : bit length of rdr					                        
+;*	%r24 - original DR2 value
+;*	%r23 - DR2 | DR2_SLOW_RET
+;*	%r1  - scratch
+;*
+;***********************************************************************
 
 	.export perf_rdr_shift_in_U,code
 perf_rdr_shift_in_U:
@@ -1053,75 +1051,75 @@
 ; Start of next 32-byte cacheline
 ;
 	SFDIAG		(0)		; RDR 0 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(0)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	SFDIAG		(1)		; RDR 1 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(1)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	sync				; RDR 2 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(4)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 3 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(3)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 4 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(4)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 5 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(5)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 6 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(6)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 7 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(7)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	b,n         perf_rdr_shift_in_U_leave
@@ -1134,95 +1132,95 @@
 	nop
 
 	SFDIAG		(9)		; RDR 9 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(9)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
 
 	SFDIAG		(10)		; RDR 10 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(10)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	SFDIAG		(11)		; RDR 11 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(11)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	SFDIAG		(12)		; RDR 12 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(12)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
 
 	SFDIAG		(13)		; RDR 13 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(13)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	SFDIAG		(14)		; RDR 14 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(14)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	SFDIAG		(15)		; RDR 15 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(15)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	sync				; RDR 16 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(16)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	SFDIAG		(17)		; RDR 17 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(17)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	SFDIAG		(18)		; RDR 18 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(18)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	b,n         perf_rdr_shift_in_U_leave
 	nop
 	nop
@@ -1233,86 +1231,86 @@
 	nop
 
 	sync				; RDR 20 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(20)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 21 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(21)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 22 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(22)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 23 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(23)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 24 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(24)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	sync				; RDR 25 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(25)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	SFDIAG		(26)		; RDR 26 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(26)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	SFDIAG		(27)		; RDR 27 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(27)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	sync				; RDR 28 read sequence
-	ssm			0,0
+	ssm		0,0
 	SFDIAG		(28)
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	b,n         perf_rdr_shift_in_U_leave
-	ssm			0,0
+	ssm		0,0
 	nop
-	
+
 	b,n         perf_rdr_shift_in_U_leave
 	nop
 	nop
@@ -1321,23 +1319,23 @@
 	nop
 	nop
 	nop
-	
+
 	SFDIAG		(30)		; RDR 30 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(30)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
-	
+
 	SFDIAG		(31)		; RDR 31 read sequence
-	ssm			0,0
+	ssm		0,0
 	MFDIAG_1	(28)
 	shrpd		ret0,%r0,%sar,%r1
 	MTDIAG_1	(1)
 	STDIAG		(31)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_in_U_leave
 	nop
 
@@ -1347,30 +1345,30 @@
 	MTDIAG_2	(24)			; restore DR2
 	.procend
 
-;************************************************************************
-;*																		*
-;* Name: rdr_shift_out_U												*
-;*																		*
-;* Description:															*
-;*	This routine moves data to the RDR's.  The double-word that			*
-;*	arg1 points to is loaded and moved into the staging register.		*
-;*	Then the STDIAG instruction for the RDR # in arg0 is called			*
-;*	to move the data to the RDR.										*
-;*																		*
-;* Arguments:															*
-;*	arg0 = rdr target													*
-;*	arg1 = buffer pointer												*
-;*																		*
-;* Returns:																*
-;*	None																*
-;*																		*
-;* Register usage:														*
-;*	arg0 = rdr target													*
-;*	arg1 = buffer pointer												*
-;*	%r24 - DR2 | DR2_SLOW_RET											*
-;*	%r23 - original DR2 value											*
-;*																		*
-;************************************************************************
+;***********************************************************************
+;*
+;* Name: rdr_shift_out_U
+;*
+;* Description:
+;*	This routine moves data to the RDR's.  The double-word that
+;*	arg1 points to is loaded and moved into the staging register.
+;*	Then the STDIAG instruction for the RDR # in arg0 is called
+;*	to move the data to the RDR.
+;*
+;* Arguments:
+;*	arg0 = rdr target
+;*	arg1 = buffer pointer
+;*
+;* Returns:
+;*	None
+;*
+;* Register usage:
+;*	arg0 = rdr target
+;*	arg1 = buffer pointer
+;*	%r24 - DR2 | DR2_SLOW_RET
+;*	%r23 - original DR2 value
+;*
+;***********************************************************************
 
 	.export perf_rdr_shift_out_U,code
 perf_rdr_shift_out_U:
@@ -1386,11 +1384,11 @@
 	depdi,z		1,DR2_SLOW_RET,1,%r24
 	MFDIAG_2	(23)
 	or		%r24,%r23,%r24
-	MTDIAG_2	(24)			; set DR2_SLOW_RET
+	MTDIAG_2	(24)		; set DR2_SLOW_RET
 
-	MTDIAG_1	(25)			; data to the staging register
-	shladd		 arg0,2,%r0,%r1	; %r1 = 4 * RDR number
-	blr		    %r1,%r0		    ; branch to 8-instruction sequence
+	MTDIAG_1	(25)		; data to the staging register
+	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
+	blr		%r1,%r0		; branch to 8-instruction sequence
 	nop
 
 ;
@@ -1398,291 +1396,291 @@
 ;
 
 	sync				; RDR 0 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(0)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 1 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(1)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 2 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(2)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 3 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(3)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 4 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(4)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 5 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(5)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 6 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(6)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 7 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(7)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 8 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(8)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 9 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(9)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 10 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(10)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 11 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(11)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 12 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(12)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 13 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(13)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 14 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(14)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 15 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(15)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 16 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(16)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 17 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(17)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 18 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(18)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 19 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(19)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 20 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(20)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 21 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(21)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 22 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(22)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 23 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(23)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 24 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(24)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 25 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(25)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 26 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(26)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 27 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(27)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 28 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(28)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 29 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(29)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 30 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(30)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 	sync				; RDR 31 write sequence
-	ssm			0,0
+	ssm		0,0
 	STDIAG		(31)
-	ssm			0,0
+	ssm		0,0
 	b,n         perf_rdr_shift_out_U_leave
 	nop
-	ssm			0,0
+	ssm		0,0
 	nop
 
 perf_rdr_shift_out_U_leave:
diff -Nru a/arch/parisc/kernel/perf_images.h b/arch/parisc/kernel/perf_images.h
--- a/arch/parisc/kernel/perf_images.h	2004-12-24 13:36:18 -08:00
+++ b/arch/parisc/kernel/perf_images.h	2004-12-24 13:36:18 -08:00
@@ -2,6 +2,7 @@
  *    Imagine for use with the Onyx (PCX-U) CPU interface 
  *
  *    Copyright (C) 2001 Randolph Chung <tausq at parisc-linux.org>
+ *    Copyright (C) 2001 Hewlett-Packard (Grant Grundler)
  *
  *    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
diff -Nru a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
--- a/arch/parisc/kernel/process.c	2004-12-24 13:37:30 -08:00
+++ b/arch/parisc/kernel/process.c	2004-12-24 13:37:30 -08:00
@@ -363,8 +363,11 @@
 		goto out;
 	error = do_execve(filename, (char **) regs->gr[25],
 		(char **) regs->gr[24], regs);
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 out:
 
diff -Nru a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
--- a/arch/parisc/kernel/ptrace.c	2004-12-24 13:36:18 -08:00
+++ b/arch/parisc/kernel/ptrace.c	2004-12-24 13:36:18 -08:00
@@ -303,7 +303,7 @@
 		 * that it wants to exit.
 		 */
 		DBG(("sys_ptrace(KILL)\n"));
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			goto out_tsk;
 		child->exit_code = SIGKILL;
 		goto out_wake_notrap;
@@ -377,6 +377,10 @@
 
 	case PTRACE_DETACH:
 		ret = ptrace_detach(child, data);
+		goto out_tsk;
+
+	case PTRACE_GETEVENTMSG:
+                ret = put_user(child->ptrace_message, (unsigned int __user *) data);
 		goto out_tsk;
 
 	default:
diff -Nru a/arch/parisc/kernel/real2.S b/arch/parisc/kernel/real2.S
--- a/arch/parisc/kernel/real2.S	2004-12-24 13:36:49 -08:00
+++ b/arch/parisc/kernel/real2.S	2004-12-24 13:36:49 -08:00
@@ -149,7 +149,7 @@
 rfi_virt2real:
 	/* switch to real mode... */
 	ssm		0,0		/* See "relied upon translation" */
-	nop				/* comment in interruption.S */
+	nop				/* PA 2.0 Arch. F-5 */
 	nop
 	nop
 	nop
@@ -186,7 +186,7 @@
 	.align 128
 rfi_real2virt:
 	ssm		0,0		/* See "relied upon translation" */
-	nop				/* comment in interruption.S */
+	nop				/* PA 2.0 Arch. F-5 */
 	nop
 	nop
 	nop
diff -Nru a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
--- a/arch/parisc/kernel/signal.c	2004-12-24 13:37:29 -08:00
+++ b/arch/parisc/kernel/signal.c	2004-12-24 13:37:29 -08:00
@@ -494,11 +494,9 @@
  */	
 
 static long
-handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset,
-	      struct pt_regs *regs, int in_syscall)
+handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
+		sigset_t *oldset, struct pt_regs *regs, int in_syscall)
 {
-	struct k_sigaction *ka = &current->sighand->action[sig-1];
-
 	DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n",
 	       sig, ka, info, oldset, regs);
 	
@@ -506,9 +504,6 @@
 	if (!setup_rt_frame(sig, ka, info, oldset, regs, in_syscall))
 		return 0;
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
-
 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
@@ -535,7 +530,7 @@
 do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall)
 {
 	siginfo_t info;
-	struct k_sigaction *ka;
+	struct k_sigaction ka;
 	int signr;
 
 	DBG(1,"\ndo_signal: oldset=0x%p, regs=0x%p, sr7 %#lx, in_syscall=%d\n",
@@ -553,10 +548,15 @@
 		oldset->sig[0], oldset->sig[1]);
 
 
-	signr = get_signal_to_deliver(&info, regs, NULL);
-	DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]); 
+	/* May need to force signal if handle_signal failed to deliver */
+	while (1) {
+	  
+		signr = get_signal_to_deliver(&info, &ka, regs, NULL);
+		DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]); 
 	
-	if (signr > 0) {
+		if (signr <= 0)
+		  break;
+		
 		/* Restart a system call if necessary. */
 		if (in_syscall) {
 			/* Check the return code */
@@ -569,8 +569,7 @@
 				break;
 
 			case -ERESTARTSYS:
-				ka = &current->sighand->action[signr-1];
-				if (!(ka->sa.sa_flags & SA_RESTART)) {
+				if (!(ka.sa.sa_flags & SA_RESTART)) {
 					DBG(1,"ERESTARTSYS: putting -EINTR\n");
 					regs->gr[28] = -EINTR;
 					break;
@@ -578,8 +577,7 @@
 			/* fallthrough */
 			case -ERESTARTNOINTR:
 				/* A syscall is just a branch, so all
-                                   we have to do is fiddle the return
-                                   pointer. */
+				   we have to do is fiddle the return pointer. */
 				regs->gr[31] -= 8; /* delayed branching */
 				/* Preserve original r28. */
 				regs->gr[28] = regs->orig_r28;
@@ -589,12 +587,13 @@
 		/* Whee!  Actually deliver the signal.  If the
 		   delivery failed, we need to continue to iterate in
 		   this loop so we can deliver the SIGSEGV... */
-		if (handle_signal(signr, &info, oldset, regs, in_syscall)) {
+		if (handle_signal(signr, &info, &ka, oldset, regs, in_syscall)) {
 			DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n",
 				regs->gr[28]);
 			return 1;
 		}
 	}
+	/* end of while(1) looping forever if we can't force a signal */
 
 	/* Did we come from a system call? */
 	if (in_syscall) {
diff -Nru a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
--- a/arch/parisc/kernel/smp.c	2004-12-24 13:37:30 -08:00
+++ b/arch/parisc/kernel/smp.c	2004-12-24 13:37:30 -08:00
@@ -33,10 +33,10 @@
 #include <linux/kernel_stat.h>
 #include <linux/mm.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/atomic.h>
-#include <asm/bitops.h>
 #include <asm/current.h>
 #include <asm/delay.h>
 #include <asm/pgalloc.h>	/* for flush_tlb_all() proto/macro */
@@ -333,6 +333,7 @@
 	struct smp_call_struct data;
 	unsigned long timeout;
 	static spinlock_t lock = SPIN_LOCK_UNLOCKED;
+	int retries = 0;
 
 	if (num_online_cpus() < 2)
 		return 0;
@@ -365,21 +366,22 @@
 	/*  Send a message to all other CPUs and wait for them to respond  */
 	send_IPI_allbutself(IPI_CALL_FUNC);
 
+ retry:
 	/*  Wait for response  */
 	timeout = jiffies + HZ;
 	while ( (atomic_read (&data.unstarted_count) > 0) &&
 		time_before (jiffies, timeout) )
 		barrier ();
 
+	if (atomic_read (&data.unstarted_count) > 0) {
+		printk(KERN_CRIT "SMP CALL FUNCTION TIMED OUT! (cpu=%d), try %d\n",
+		      smp_processor_id(), ++retries);
+		goto retry;
+	}
 	/* We either got one or timed out. Release the lock */
 
 	mb();
 	smp_call_function_data = NULL;
-	if (atomic_read (&data.unstarted_count) > 0) {
-		printk(KERN_CRIT "SMP CALL FUNCTION TIMED OUT! (cpu=%d)\n",
-		      smp_processor_id());
-		return -ETIMEDOUT;
-	}
 
 	while (wait && atomic_read (&data.unfinished_count) > 0)
 			barrier ();
diff -Nru a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
--- a/arch/parisc/kernel/sys_parisc.c	2004-12-24 13:37:19 -08:00
+++ b/arch/parisc/kernel/sys_parisc.c	2004-12-24 13:37:19 -08:00
@@ -234,6 +234,14 @@
 	return sys_readahead(fd, (loff_t)high << 32 | low, count);
 }
 
+asmlinkage long parisc_fadvise64_64(int fd,
+			unsigned int high_off, unsigned int low_off,
+			unsigned int high_len, unsigned int low_len, int advice)
+{
+	return sys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off,
+			(loff_t)high_len << 32 | low_len, advice);
+}
+
 asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr, unsigned long len, int prot, int flag)
 {
 	return -ENOMEM;
diff -Nru a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
--- a/arch/parisc/kernel/sys_parisc32.c	2004-12-24 13:36:47 -08:00
+++ b/arch/parisc/kernel/sys_parisc32.c	2004-12-24 13:36:47 -08:00
@@ -80,8 +80,11 @@
 		goto out;
 	error = compat_do_execve(filename, compat_ptr(regs->gr[25]),
 				 compat_ptr(regs->gr[24]), regs);
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 out:
 
diff -Nru a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
--- a/arch/parisc/kernel/syscall.S	2004-12-24 13:37:31 -08:00
+++ b/arch/parisc/kernel/syscall.S	2004-12-24 13:37:31 -08:00
@@ -16,11 +16,32 @@
 #include <asm/assembly.h>
 #include <asm/processor.h>
 
+	/* We fill the empty parts of the gateway page with
+ 	 * something that will kill the kernel or a
+ 	 * userspace application.
+	 */
+#define KILL_INSN	break	0,0
+
+#include <linux/config.h> /* for CONFIG_SMP */
+
 #ifdef __LP64__
 	.level          2.0w
 #else
 	.level		1.1
 #endif
+
+#ifndef __LP64__
+	.macro fixup_branch,lbl
+	b	    \lbl
+	.endm
+#else
+	.macro fixup_branch,lbl
+	ldil	    L%\lbl, %r1
+	ldo	    R%\lbl(%r1), %r1
+	bv,n        %r0(%r1)
+	.endm
+#endif
+
 	.text
 
 	.import syscall_exit,code
@@ -38,21 +59,41 @@
 	.align 4096
 linux_gateway_page:
 
-	.rept 56
-	break   0,0
+        /* ADDRESS 0x00 to 0xb0 = 176 bytes / 4 bytes per insn = 44 insns */
+	.rept 44
+	KILL_INSN
+	.endr
+
+	/* ADDRESS 0xb0 to 0xb4, lws uses 1 insns for entry */
+	/* Light-weight-syscall entry must always be located at 0xb0 */
+	/* WARNING: Keep this number updated with table size changes */
+#define __NR_lws_entries (2)
+
+lws_entry:
+	/* Unconditional branch to lws_start, located on the 
+	   same gateway page */
+	b,n	lws_start
+
+	/* Fill from 0xb4 to 0xe0 */
+	.rept 11
+	KILL_INSN
 	.endr
 
+	/* This function MUST be located at 0xe0 for glibc's threading 
+	mechanism to work. DO NOT MOVE THIS CODE EVER! */
 set_thread_pointer:
 	gate	.+8, %r0		/* increase privilege */
 	depi	3, 31, 2, %r31		/* Ensure we return into user mode. */
 	be	0(%sr7,%r31)		/* return to user space */
 	mtctl	%r26, %cr27		/* move arg0 to the control register */
 
+	/* Increase the chance of trapping if random jumps occur to this
+	address, fill from 0xf0 to 0x100 */
 	.rept 4
-	break   0,0
+	KILL_INSN
 	.endr
 
-/* This address must remain fixed, or user binaries go splat. */
+/* This address must remain fixed at 0x100 for glibc's syscalls to work */
 	.align 256
 linux_gateway_entry:
 	gate	.+8, %r0			/* become privileged */
@@ -157,6 +198,7 @@
 
 	/* Are we being ptraced? */
 	mfctl	%cr30, %r1
+	LDREG	TI_TASK(%r1),%r1
 	LDREG	TASK_PTRACE(%r1), %r1
 	bb,<,n	%r1,31,.Ltracesys
 	
@@ -177,11 +219,8 @@
 	comiclr,>>=	__NR_Linux_syscalls, %r20, %r0
 	b,n	.Lsyscall_nosys
 	
-#ifdef __LP64__
-	ldd,s   %r20(%r19), %r19
-#else
-	ldwx,s  %r20(%r19), %r19
-#endif
+	LDREGX  %r20(%r19), %r19
+
 	/* If this is a sys_rt_sigreturn call, and the signal was received
 	 * when not in_syscall, then we want to return via syscall_exit_rfi,
 	 * not syscall_exit.  Signal no. in r20, in_syscall in r25 (see
@@ -291,11 +330,8 @@
 	comiclr,>>=	__NR_Linux_syscalls, %r20, %r0
 	b,n	.Lsyscall_nosys
 
-#ifdef __LP64__
-	ldd,s   %r20(%r19), %r19
-#else
-	ldwx,s  %r20(%r19), %r19
-#endif
+	LDREGX  %r20(%r19), %r19
+
 	/* If this is a sys_rt_sigreturn call, and the signal was received
 	 * when not in_syscall, then we want to return via syscall_exit_rfi,
 	 * not syscall_exit.  Signal no. in r20, in_syscall in r25 (see
@@ -344,12 +380,292 @@
 	ldil	L%syscall_exit_rfi,%r1
 	be,n	R%syscall_exit_rfi(%sr7,%r1)
 
+
+	/*********************************************************
+		Light-weight-syscall code
+
+		r20 - lws number
+		r26,r25,r24,r23,r22 - Input registers
+		r28 - Function return register
+		r21 - Error code.
+
+		Scracth: Any of the above that aren't being
+		currently used, including r1. 
+
+		Return pointer: r31 (Not usable)
+
+		Error codes returned by entry path:
+
+		ENOSYS - r20 was an invalid LWS number.
+
+	*********************************************************/
+lws_start:
+	/* Gate and ensure we return to userspace */
+	gate	.+8, %r0
+	depi	3, 31, 2, %r31	/* Ensure we return to userspace */
+
+#ifdef __LP64__
+	/* FIXME: If we are a 64-bit kernel just
+	 *        turn this on unconditionally.
+	 */
+	ssm	PSW_SM_W, %r1
+	extrd,u	%r1,PSW_W_BIT,1,%r1
+	/* sp must be aligned on 4, so deposit the W bit setting into
+	 * the bottom of sp temporarily */
+	or,ev	%r1,%r30,%r30
+
+	/* Clip LWS number to a 32-bit value always */
+	depdi	0, 31, 32, %r20
+#endif	
+
+        /* Is the lws entry number valid? */
+	comiclr,>>=	__NR_lws_entries, %r20, %r0
+	b,n	lws_exit_nosys
+
+	/* WARNING: Trashing sr2 and sr3 */
+	mfsp	%sr7,%r1			/* get userspace into sr3 */
+	mtsp	%r1,%sr3
+	mtsp	%r0,%sr2			/* get kernel space into sr2 */
+
+	/* Load table start */
+	ldil	L%lws_table, %r1
+	ldo	R%lws_table(%r1), %r28	/* Scratch use of r28 */
+	LDREGX	%r20(%sr2,r28), %r21	/* Scratch use of r21 */
+
+	/* Jump to lws, lws table pointers already relocated */
+	be,n	0(%sr2,%r21)
+
+lws_exit_nosys:
+	ldo	-ENOSYS(%r0),%r21		   /* set errno */
+	/* Fall through: Return to userspace */
+
+lws_exit:
+#ifdef __LP64__
+	/* decide whether to reset the wide mode bit
+	 *
+	 * For a syscall, the W bit is stored in the lowest bit
+	 * of sp.  Extract it and reset W if it is zero */
+	extrd,u,*<>	%r30,63,1,%r1
+	rsm	PSW_SM_W, %r0
+	/* now reset the lowest bit of sp if it was set */
+	xor	%r30,%r1,%r30
+#endif
+	be,n	0(%sr3, %r31)
+
+
+	
+	/***************************************************
+		Implementing CAS as an atomic operation:
+
+		%r26 - Address to examine
+		%r25 - Old value to check (old)
+		%r24 - New value to set (new)
+		%r28 - Return prev through this register.
+		%r21 - Kernel error code
+
+		If debugging is DISabled:
+
+		%r21 has the following meanings:
+
+		EAGAIN - CAS is busy, ldcw failed, try again.
+		EFAULT - Read or write failed.		
+
+		If debugging is enabled:
+
+		EDEADLOCK - CAS called recursively.
+		EAGAIN && r28 == 1 - CAS is busy. Lock contended.
+		EAGAIN && r28 == 2 - CAS is busy. ldcw failed.
+		EFAULT - Read or write failed.
+
+		Scratch: r20, r28, r1
+
+	****************************************************/
+
+	/* Do not enable LWS debugging */
+#define ENABLE_LWS_DEBUG 0 
+
+	/* ELF64 Process entry path */
+lws_compare_and_swap64:
+#ifdef __LP64__
+	b,n	lws_compare_and_swap
+#else
+	/* If we are not a 64-bit kernel, then we don't
+	 * implement having 64-bit input registers
+	 */
+	b,n	lws_exit_nosys
+#endif
+
+	/* ELF32 Process entry path */
+lws_compare_and_swap32:
+#ifdef __LP64__
+	/* Clip all the input registers */
+	depdi	0, 31, 32, %r26
+	depdi	0, 31, 32, %r25
+	depdi	0, 31, 32, %r24
+#endif
+
+lws_compare_and_swap:
+#ifdef CONFIG_SMP
+	/* Load start of lock table */
+	ldil	L%lws_lock_start, %r20
+	ldo	R%lws_lock_start(%r20), %r28
+
+	/* Extract four bits from r26 and hash lock (Bits 4-7) */
+	extru  %r26, 27, 4, %r20
+
+	/* Find lock to use, the hash is either one of 0 to
+	   15, multiplied by 16 (keep it 16-byte aligned)
+	   and add to the lock table offset. */
+	shlw	%r20, 4, %r20
+	add	%r20, %r28, %r20
+
+# ifdef ENABLE_LWS_DEBUG
+	/*	
+		DEBUG, check for deadlock! 
+		If the thread register values are the same
+		then we were the one that locked it last and
+		this is a recurisve call that will deadlock.
+		We *must* giveup this call and fail.
+	*/
+	ldw	4(%sr2,%r20), %r28			/* Load thread register */
+	mfctl	%cr27, %r21				/* Get current thread register */
+	cmpb,<>,n	%r21, %r28, cas_lock		/* Called recursive? */
+	b	lws_exit				/* Return error! */
+	ldo	-EDEADLOCK(%r0), %r21
+cas_lock:
+	cmpb,=,n	%r0, %r28, cas_nocontend	/* Is nobody using it? */
+	ldo	1(%r0), %r28				/* 1st case */
+	b	lws_exit				/* Contended... */
+	ldo	-EAGAIN(%r0), %r21			/* Spin in userspace */
+cas_nocontend:
+# endif
+/* ENABLE_LWS_DEBUG */
+
+	ldcw	0(%sr2,%r20), %r28			/* Try to acquire the lock */
+	cmpb,<>,n	%r0, %r28, cas_action		/* Did we get it? */
+cas_wouldblock:
+	ldo	2(%r0), %r28				/* 2nd case */
+	b	lws_exit				/* Contended... */
+	ldo	-EAGAIN(%r0), %r21			/* Spin in userspace */
+#endif
+/* CONFIG_SMP */
+
+	/*
+		prev = *addr;
+		if ( prev == old )
+		  *addr = new;
+		return prev;
+	*/
+
+	/* NOTES:
+		This all works becuse intr_do_signal
+		and schedule both check the return iasq
+		and see that we are on the kernel page
+		so this process is never scheduled off
+		or is ever sent any signal of any sort,
+		thus it is wholly atomic from usrspaces
+		perspective
+	*/
+cas_action:
+#if defined CONFIG_SMP && defined ENABLE_LWS_DEBUG
+	/* DEBUG */
+	mfctl	%cr27, %r1
+	stw	%r1, 4(%sr2,%r20)
+#endif
+	/* The load and store could fail */
+1:	ldw	0(%sr3,%r26), %r28
+	sub,<>	%r28, %r25, %r0
+2:	stw	%r24, 0(%sr3,%r26)
+#ifdef CONFIG_SMP
+	/* Free lock */
+	stw	%r20, 0(%sr2,%r20)
+# ifdef ENABLE_LWS_DEBUG
+	/* Clear thread register indicator */
+	stw	%r0, 4(%sr2,%r20)
+# endif
+#endif
+	/* Return to userspace, set no error */
+	b	lws_exit
+	copy	%r0, %r21
+
+3:		
+	/* Error occured on load or store */
+#ifdef CONFIG_SMP
+	/* Free lock */
+	stw	%r20, 0(%sr2,%r20)
+# ifdef ENABLE_LWS_DEBUG
+	stw	%r0, 4(%sr2,%r20)
+# endif
+#endif
+	b	lws_exit
+	ldo	-EFAULT(%r0),%r21	/* set errno */
+	nop
+	nop
+	nop
+	nop
+
+	/* Two exception table entries, one for the load,
+	   the other for the store. Either return -EFAULT.
+	   Each of the entries must be relocated. */
+	.section __ex_table,"aw"
+#ifdef __LP64__
+	/* Pad the address calculation */
+	.word	0,(2b - linux_gateway_page)
+	.word	0,(3b - linux_gateway_page)
+#else
+	.word	(2b - linux_gateway_page)
+	.word	(3b - linux_gateway_page)
+#endif
+	.previous
+
+	.section __ex_table,"aw"
+#ifdef __LP64__
+	/* Pad the address calculation */
+	.word	0,(1b - linux_gateway_page)
+	.word	0,(3b - linux_gateway_page)
+#else
+	.word	(1b - linux_gateway_page)
+	.word	(3b - linux_gateway_page)
+#endif
+	.previous
+
+end_compare_and_swap:
+
+	/* Make sure nothing else is placed on this page */
+	.align 4096
+	.export end_linux_gateway_page
+end_linux_gateway_page:
+
+	/* Relocate symbols assuming linux_gateway_page is mapped
+	   to virtual address 0x0 */
+#ifdef __LP64__
+	/* FIXME: The code will always be on the gateay page
+		  and thus it will be on the first 4k, the
+		  assembler seems to think that the final
+		  subtraction result is only a word in
+		  length, so we pad the value.
+	*/
+#define LWS_ENTRY(_name_) .word 0,(lws_##_name_ - linux_gateway_page)
+#else
+#define LWS_ENTRY(_name_) .word  (lws_##_name_ - linux_gateway_page)
+#endif
+
+	.align 4096
+	/* Light-weight-syscall table */
+	/* Start of lws table. */
+	.export lws_table
+.Llws_table:
+lws_table:
+	LWS_ENTRY(compare_and_swap32)	/* 0 - ELF32 Atomic compare and swap */
+	LWS_ENTRY(compare_and_swap64)	/* 1 - ELF64 Atomic compare and swap */
+	/* End of lws table */
+
 	.align 4096
 	.export sys_call_table
 .Lsys_call_table:
 sys_call_table:
 #include "syscall_table.S"
-.end
+
 #ifdef __LP64__
 	.align 4096
 	.export sys_call_table64
@@ -359,10 +675,29 @@
 #include "syscall_table.S"
 #endif
 
+#ifdef CONFIG_SMP
+	/*
+		All light-weight-syscall atomic operations 
+		will use this set of locks 
+	*/
+	.section .data
+	.align 4096
+	.export lws_lock_start
+.Llws_lock_start:
+lws_lock_start:
+	/* lws locks */
+	.align 16
+	.rept 16
+	/* Keep locks aligned at 16-bytes */
+	.word 1
+	.word 0 
+	.word 0
+	.word 0
+	.endr
+	.previous
+#endif
+/* CONFIG_SMP for lws_lock_start */
 
-	/* Make sure nothing else is placed on this page */
+.end
 
-	.align 4096
-	.export end_linux_gateway_page
-end_linux_gateway_page:
 
diff -Nru a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
--- a/arch/parisc/kernel/syscall_table.S	2004-12-24 13:36:17 -08:00
+++ b/arch/parisc/kernel/syscall_table.S	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,6 @@
 /*    System Call Table
  *
- *    Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org>
+ *    Copyright (C) 1999-2004 Matthew Wilcox <willy at parisc-linux.org>
  *    Copyright (C) 2000-2001 John Marvin <jsm at parisc-linux.org>
  *    Copyright (C) 2000 Alan Modra <amodra at parisc-linux.org>
  *    Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org>
@@ -308,19 +308,18 @@
 	ENTRY_OURS(ftruncate64)		/* 200 */
 	ENTRY_SAME(getdents64)
 	ENTRY_COMP(fcntl64)
-	ENTRY_SAME(ni_syscall)
-	ENTRY_SAME(ni_syscall)
-	ENTRY_SAME(ni_syscall)		/* 205 */
-	ENTRY_SAME(gettid)             
-	ENTRY_OURS(readahead)          
-	ENTRY_SAME(ni_syscall)		/* tkill */
-
+	ENTRY_SAME(ni_syscall)	/* attrctl -- dead */
+	ENTRY_SAME(ni_syscall)	/* acl_get -- dead */
+	ENTRY_SAME(ni_syscall)		/* 205 (acl_set -- dead) */
+	ENTRY_SAME(gettid)
+	ENTRY_OURS(readahead)
+	ENTRY_SAME(tkill)
 	ENTRY_SAME(sendfile64)
 	ENTRY_COMP(futex)		/* 210 */
 	ENTRY_COMP(sched_setaffinity)
 	ENTRY_COMP(sched_getaffinity)
-	ENTRY_SAME(ni_syscall)
-	ENTRY_SAME(ni_syscall)
+	ENTRY_SAME(ni_syscall)	/* set_thread_area */
+	ENTRY_SAME(ni_syscall)	/* get_thread_area */
 	ENTRY_SAME(io_setup)		/* 215 */
 	ENTRY_SAME(io_destroy)
 	ENTRY_SAME(io_getevents)
@@ -334,12 +333,40 @@
 	ENTRY_SAME(epoll_ctl)		/* 225 */
 	ENTRY_SAME(epoll_wait)
  	ENTRY_SAME(remap_file_pages)
-  ENTRY_SAME(semtimedop)
-  ENTRY_SAME(mq_open)
-  ENTRY_SAME(mq_unlink)   /* 230 */
-  ENTRY_SAME(mq_timedsend)
-  ENTRY_SAME(mq_timedreceive)
-  ENTRY_SAME(mq_notify)
-  ENTRY_SAME(mq_getsetattr)
-  /* Nothing yet */       /* 235 */
+	ENTRY_SAME(semtimedop)
+	ENTRY_SAME(mq_open)
+	ENTRY_SAME(mq_unlink)		/* 230 */
+	ENTRY_SAME(mq_timedsend)
+	ENTRY_SAME(mq_timedreceive)
+	ENTRY_SAME(mq_notify)
+	ENTRY_SAME(mq_getsetattr)
+	ENTRY_COMP(waitid)		/* 235 */
+	ENTRY_OURS(fadvise64_64)
+	ENTRY_SAME(set_tid_address)
+	ENTRY_SAME(setxattr)
+	ENTRY_SAME(lsetxattr)
+	ENTRY_SAME(fsetxattr)		/* 240 */
+	ENTRY_SAME(getxattr)
+	ENTRY_SAME(lgetxattr)
+	ENTRY_SAME(fgetxattr)
+	ENTRY_SAME(listxattr)
+	ENTRY_SAME(llistxattr)		/* 245 */
+	ENTRY_SAME(flistxattr)
+	ENTRY_SAME(removexattr)
+	ENTRY_SAME(lremovexattr)
+	ENTRY_SAME(fremovexattr)
+	ENTRY_COMP(timer_create)	/* 250 */
+	ENTRY_COMP(timer_settime)
+	ENTRY_COMP(timer_gettime)
+	ENTRY_SAME(timer_getoverrun)
+	ENTRY_SAME(timer_delete)
+	ENTRY_COMP(clock_settime)	/* 255 */
+	ENTRY_COMP(clock_gettime)
+	ENTRY_COMP(clock_getres)
+	ENTRY_COMP(clock_nanosleep)
+	ENTRY_SAME(tgkill)
+	ENTRY_COMP(mbind)		/* 260 */
+	ENTRY_COMP(get_mempolicy)
+	ENTRY_COMP(set_mempolicy)
+	/* Nothing yet */
 
diff -Nru a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
--- a/arch/parisc/kernel/time.c	2004-12-24 13:37:43 -08:00
+++ b/arch/parisc/kernel/time.c	2004-12-24 13:37:43 -08:00
@@ -79,6 +79,8 @@
 	while (nticks--) {
 #ifdef CONFIG_SMP
 		smp_do_timer(regs);
+#else
+		update_process_times(user_mode(regs));
 #endif
 		if (cpu == 0) {
 			write_seqlock(&xtime_lock);
diff -Nru a/arch/parisc/kernel/topology.c b/arch/parisc/kernel/topology.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/parisc/kernel/topology.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,37 @@
+/*
+ * arch/parisc/kernel/topology.c - Populate driverfs with topology information
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (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, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/smp.h>
+#include <linux/cpu.h>
+
+static struct cpu cpu_devices[NR_CPUS];
+
+static int __init topology_init(void)
+{
+	struct node *parent = NULL;
+	int num;
+
+	for_each_present_cpu(num) {
+		register_cpu(&cpu_devices[num], num, parent);
+	}
+	return 0;
+}
+
+subsys_initcall(topology_init);
diff -Nru a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
--- a/arch/parisc/kernel/traps.c	2004-12-24 13:37:43 -08:00
+++ b/arch/parisc/kernel/traps.c	2004-12-24 13:37:43 -08:00
@@ -135,32 +135,19 @@
 
 EXPORT_SYMBOL(dump_stack);
 
-void show_stack(struct task_struct *task, unsigned long *s)
+static void do_show_stack(struct unwind_frame_info *info)
 {
 	int i = 1;
-	struct unwind_frame_info info;
-
-	if (!task) {
-		unsigned long sp, ip, rp;
-
-HERE:
-		asm volatile ("copy %%r30, %0" : "=r"(sp));
-		ip = (unsigned long)&&HERE;
-		rp = (unsigned long)__builtin_return_address(0);
-		unwind_frame_init(&info, current, sp, ip, rp);
-	} else {
-		unwind_frame_init_from_blocked_task(&info, task);
-	}
 
 	printk("Backtrace:\n");
 	while (i <= 16) {
-		if (unwind_once(&info) < 0 || info.ip == 0)
+		if (unwind_once(info) < 0 || info->ip == 0)
 			break;
 
-		if (__kernel_text_address(info.ip)) {
-			printk(" [<" RFMT ">] ", info.ip);
+		if (__kernel_text_address(info->ip)) {
+			printk(" [<" RFMT ">] ", info->ip);
 #ifdef CONFIG_KALLSYMS
-			print_symbol("%s\n", info.ip);
+			print_symbol("%s\n", info->ip);
 #else
 			if ((i & 0x03) == 0)
 				printk("\n");
@@ -171,6 +158,25 @@
 	printk("\n");
 }
 
+void show_stack(struct task_struct *task, unsigned long *s)
+{
+	struct unwind_frame_info info;
+
+	if (!task) {
+		unsigned long sp, ip, rp;
+
+HERE:
+		asm volatile ("copy %%r30, %0" : "=r"(sp));
+		ip = (unsigned long)&&HERE;
+		rp = (unsigned long)__builtin_return_address(0);
+		unwind_frame_init(&info, current, sp, ip, rp);
+	} else {
+		unwind_frame_init_from_blocked_task(&info, task);
+	}
+
+	do_show_stack(&info);
+}
+
 void die_if_kernel(char *str, struct pt_regs *regs, long err)
 {
 	if (user_mode(regs)) {
@@ -373,9 +379,9 @@
 
 
 /*
- * This routine handles page faults.  It determines the address,
- * and the problem, and then passes it off to one of the appropriate
- * routines.
+ * This routine is called as a last resort when everything else
+ * has gone clearly wrong. We get called for faults in kernel space,
+ * and HPMC's.
  */
 void parisc_terminate(char *msg, struct pt_regs *regs, int code, unsigned long offset)
 {
@@ -407,7 +413,12 @@
 
 	}
 	    
-	show_stack(NULL, (unsigned long *)regs->gr[30]);
+	{
+		/* show_stack(NULL, (unsigned long *)regs->gr[30]); */
+		struct unwind_frame_info info;
+		unwind_frame_init(&info, current, regs->gr[30], regs->iaoq[0], regs->gr[2]);
+		do_show_stack(&info);
+	}
 
 	printk("\n");
 	printk(KERN_CRIT "%s: Code=%d regs=%p (Addr=" RFMT ")\n",
@@ -421,9 +432,16 @@
 	 * system will shut down immediately right here. */
 	pdc_soft_power_button(0);
 	
-	/* Gutter the processor! */
-	for(;;)
-	    ;
+	/* Call kernel panic() so reboot timeouts work properly 
+	 * FIXME: This function should be on the list of
+	 * panic notifiers, and we should call panic
+	 * directly from the location that we wish. 
+	 * e.g. We should not call panic from
+	 * parisc_terminate, but rather the oter way around.
+	 * This hack works, prints the panic message twice,
+	 * and it enables reboot timers!
+	 */
+	panic(msg);
 }
 
 void handle_interruption(int code, struct pt_regs *regs)
@@ -437,6 +455,36 @@
 	else
 	    local_irq_enable();
 
+	/* Security check:
+	 * If the priority level is still user, and the
+	 * faulting space is not equal to the active space
+	 * then the user is attempting something in a space
+	 * that does not belong to them. Kill the process.
+	 *
+	 * This is normally the situation when the user
+	 * attempts to jump into the kernel space at the
+	 * wrong offset, be it at the gateway page or a
+	 * random location.
+	 *
+	 * We cannot normally signal the process because it
+	 * could *be* on the gateway page, and processes
+	 * executing on the gateway page can't have signals
+	 * delivered.
+	 * 
+	 * We merely readjust the address into the users
+	 * space, at a destination address of zero, and
+	 * allow processing to continue.
+	 */
+	if (((unsigned long)regs->iaoq[0] & 3) &&
+	    ((unsigned long)regs->iasq[0] != (unsigned long)regs->sr[7])) { 
+	  	/* Kill the user process later */
+	  	regs->iaoq[0] = 0 | 3;
+		regs->iaoq[1] = regs->iaoq[0] + 4;
+	 	regs->iasq[0] = regs->iasq[0] = regs->sr[7];
+		regs->gr[0] &= ~PSW_B;
+		return;
+	}
+	
 #if 0
 	printk(KERN_CRIT "Interruption # %d\n", code);
 #endif
@@ -461,7 +509,7 @@
 	case  3:
 		/* Recovery counter trap */
 		regs->gr[0] &= ~PSW_R;
-		if (regs->iasq[0])
+		if (user_space(regs))
 			handle_gdb_break(regs, TRAP_TRACE);
 		/* else this must be the start of a syscall - just let it run */
 		return;
@@ -542,12 +590,12 @@
 			/* Set to zero, and let the userspace app figure it out from
 		   	   the insn pointed to by si_addr */
 			si.si_code = 0;
-			si.si_addr = (void *) regs->iaoq[0];
+			si.si_addr = (void __user *) regs->iaoq[0];
 			force_sig_info(SIGFPE, &si, current);
 			return;
-		} else 
-			/* The kernel doesn't want to handle condition codes */
-			break;
+		} 
+		/* The kernel doesn't want to handle condition codes */
+		break;
 		
 	case 14:
 		/* Assist Exception Trap, i.e. floating point exception. */
@@ -565,9 +613,16 @@
 		/* Fall through */
 	case 17:
 		/* Non-access data TLB miss fault/Non-access data page fault */
-		/* TODO: Still need to add slow path emulation code here */
-		/* TODO: Understand what is meant by the TODO listed
-		         above this one. (Carlos) */
+		/* FIXME: 
+		 	 Still need to add slow path emulation code here!
+		         If the insn used a non-shadow register, then the tlb
+			 handlers could not have their side-effect (e.g. probe
+			 writing to a target register) emulated since rfir would
+			 erase the changes to said register. Instead we have to
+			 setup everything, call this function we are in, and emulate
+			 by hand. Technically we need to emulate:
+			 fdc,fdce,pdc,"fic,4f",prober,probeir,probew, probeiw
+		*/			  
 		fault_address = regs->ior;
 		fault_space = regs->isr;
 		break;
@@ -598,7 +653,7 @@
 	case 25:
 		/* Taken branch trap */
 		regs->gr[0] &= ~PSW_T;
-		if (regs->iasq[0])
+		if (user_space(regs))
 			handle_gdb_break(regs, TRAP_BRANCH);
 		/* else this must be the start of a syscall - just let it
 		 * run.
diff -Nru a/arch/parisc/kernel/unaligned.c b/arch/parisc/kernel/unaligned.c
--- a/arch/parisc/kernel/unaligned.c	2004-12-24 13:36:33 -08:00
+++ b/arch/parisc/kernel/unaligned.c	2004-12-24 13:36:33 -08:00
@@ -23,6 +23,7 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <asm/uaccess.h>
 
 /* #define DEBUG_UNALIGNED 1 */
 
@@ -38,6 +39,11 @@
 #define RFMT "%08lx"
 #endif
 
+#define FIXUP_BRANCH(lbl) \
+	"\tldil L%%" #lbl ", %%r1\n"			\
+	"\tldo R%%" #lbl "(%%r1), %%r1\n"		\
+	"\tbv,n %%r0(%%r1)\n"
+
 /* 1111 1100 0000 0000 0001 0011 1100 0000 */
 #define OPCODE1(a,b,c)	((a)<<26|(b)<<12|(c)<<6) 
 #define OPCODE2(a,b)	((a)<<26|(b)<<1)
@@ -134,15 +140,19 @@
 "1:	ldbs	0(%%sr1,%3), %%r20\n"
 "2:	ldbs	1(%%sr1,%3), %0\n"
 "	depw	%%r20, 23, 24, %0\n"
-"	cmpclr,= %%r0, %%r0, %1\n"
-"3:	ldo	-2(%%r0), %1\n"
-"	.section __ex_table,\"a\"\n"
+"	copy	%%r0, %1\n"
+"3:	\n"
+"	.section .fixup,\"ax\"\n"
+"4:	ldi	-2, %1\n"
+	FIXUP_BRANCH(3b)
+"	.previous\n"
+"	.section __ex_table,\"aw\"\n"
 #ifdef __LP64__
-"	.dword	1b,(3b-1b)\n"
-"	.dword  2b,(3b-2b)\n"
+"	.dword	1b,4b\n"
+"	.dword  2b,4b\n"
 #else
-"	.word	1b,(3b-1b)\n"
-"	.word	2b,(3b-2b)\n"
+"	.word	1b,4b\n"
+"	.word	2b,4b\n"
 #endif
 "	.previous\n"
 	: "=r" (val), "=r" (ret)
@@ -175,15 +185,19 @@
 "	subi	32,%%r19,%%r19\n"
 "	mtctl	%%r19,11\n"
 "	vshd	%0,%%r20,%0\n"
-"	cmpclr,= %%r0, %%r0, %1\n"
-"3:	ldo	-2(%%r0), %1\n"
-"	.section __ex_table,\"a\"\n"
+"	copy	%%r0, %1\n"
+"3:	\n"
+"	.section .fixup,\"ax\"\n"
+"4:	ldi	-2, %1\n"
+	FIXUP_BRANCH(3b)
+"	.previous\n"
+"	.section __ex_table,\"aw\"\n"
 #ifdef __LP64__
-"	.dword	1b,(3b-1b)\n"
-"	.dword  2b,(3b-2b)\n"
+"	.dword	1b,4b\n"
+"	.dword  2b,4b\n"
 #else
-"	.word	1b,(3b-1b)\n"
-"	.word	2b,(3b-2b)\n"
+"	.word	1b,4b\n"
+"	.word	2b,4b\n"
 #endif
 "	.previous\n"
 	: "=r" (val), "=r" (ret)
@@ -222,15 +236,19 @@
 "	subi	64,%%r19,%%r19\n"
 "	mtsar	%%r19\n"
 "	shrpd	%0,%%r20,%%sar,%0\n"
-"	cmpclr,= %%r0, %%r0, %1\n"
-"3:	ldo	-2(%%r0), %1\n"
-"	.section __ex_table,\"a\"\n"
+"	copy	%%r0, %1\n"
+"3:	\n"
+"	.section .fixup,\"ax\"\n"
+"4:	ldi	-2, %1\n"
+	FIXUP_BRANCH(3b)
+"	.previous\n"
+"	.section __ex_table,\"aw\"\n"
 #ifdef __LP64__
-"	.dword	1b,(3b-1b)\n"
-"	.dword  2b,(3b-2b)\n"
+"	.dword	1b,4b\n"
+"	.dword  2b,4b\n"
 #else
-"	.word	1b,(3b-1b)\n"
-"	.word	2b,(3b-2b)\n"
+"	.word	1b,4b\n"
+"	.word	2b,4b\n"
 #endif
 "	.previous\n"
 	: "=r" (val), "=r" (ret)
@@ -250,17 +268,21 @@
 "	mtsar	%%r19\n"
 "	vshd	%0,%1,%0\n"
 "	vshd	%1,%%r20,%1\n"
-"	cmpclr,= %%r0, %%r0, %2\n"
-"4:	ldo	-2(%%r0), %2\n"
-"	.section __ex_table,\"a\"\n"
+"	copy	%%r0, %2\n"
+"4:	\n"
+"	.section .fixup,\"ax\"\n"
+"5:	ldi	-2, %2\n"
+	FIXUP_BRANCH(4b)
+"	.previous\n"
+"	.section __ex_table,\"aw\"\n"
 #ifdef __LP64__
-"	.dword	1b,(4b-1b)\n"
-"	.dword  2b,(4b-2b)\n"
-"	.dword	3b,(4b-3b)\n"
-#else
-"	.word	1b,(4b-1b)\n"
-"	.word	2b,(4b-2b)\n"
-"	.word	3b,(4b-3b)\n"
+"	.dword	1b,5b\n"
+"	.dword  2b,5b\n"
+"	.dword	3b,5b\n"
+#else
+"	.word	1b,5b\n"
+"	.word	2b,5b\n"
+"	.word	3b,5b\n"
 #endif
 "	.previous\n"
 	: "=r" (valh), "=r" (vall), "=r" (ret)
@@ -296,15 +318,19 @@
 "	extrw,u %1, 23, 8, %%r19\n"
 "1:	stb %1, 1(%%sr1, %2)\n"
 "2:	stb %%r19, 0(%%sr1, %2)\n"
-"	cmpclr,= %%r0, %%r0, %0\n"
-"3:	ldo	-2(%%r0), %0\n"
-"	.section __ex_table,\"a\"\n"
+"	copy	%%r0, %0\n"
+"3:	\n"
+"	.section .fixup,\"ax\"\n"
+"4:	ldi	-2, %0\n"
+	FIXUP_BRANCH(3b)
+"	.previous\n"
+"	.section __ex_table,\"aw\"\n"
 #ifdef __LP64__
-"	.dword	1b,(3b-1b)\n"
-"	.dword  2b,(3b-2b)\n"
+"	.dword	1b,4b\n"
+"	.dword  2b,4b\n"
 #else
-"	.word	1b,(3b-1b)\n"
-"	.word	2b,(3b-2b)\n"
+"	.word	1b,4b\n"
+"	.word	2b,4b\n"
 #endif
 "	.previous\n"
 	: "=r" (ret)
@@ -346,15 +372,19 @@
 "	or	%%r1, %%r21, %%r21\n"
 "	stw	%%r20,0(%%sr1,%2)\n"
 "	stw	%%r21,4(%%sr1,%2)\n"
-"	cmpclr,= %%r0, %%r0, %0\n"
-"3:	ldo	-2(%%r0), %0\n"
-"	.section __ex_table,\"a\"\n"
+"	copy	%%r0, %0\n"
+"3:	\n"
+"	.section .fixup,\"ax\"\n"
+"4:	ldi	-2, %0\n"
+	FIXUP_BRANCH(3b)
+"	.previous\n"
+"	.section __ex_table,\"aw\"\n"
 #ifdef __LP64__
-"	.dword	1b,(3b-1b)\n"
-"	.dword  2b,(3b-2b)\n"
+"	.dword	1b,4b\n"
+"	.dword  2b,4b\n"
 #else
-"	.word	1b,(3b-1b)\n"
-"	.word	2b,(3b-2b)\n"
+"	.word	1b,4b\n"
+"	.word	2b,4b\n"
 #endif
 "	.previous\n"
 	: "=r" (ret)
@@ -399,19 +429,23 @@
 "	or	%%r1, %%r21, %%r21\n"
 "3:	std	%%r20,0(%%sr1,%2)\n"
 "4:	std	%%r21,8(%%sr1,%2)\n"
-"	cmpclr,= %%r0, %%r0, %0\n"
-"5:	ldo	-2(%%r0), %0\n"
-"	.section __ex_table,\"a\"\n"
+"	copy	%%r0, %0\n"
+"5:	\n"
+"	.section .fixup,\"ax\"\n"
+"6:	ldi	-2, %0\n"
+	FIXUP_BRANCH(5b)
+"	.previous\n"
+"	.section __ex_table,\"aw\"\n"
 #ifdef __LP64__
-"	.dword	1b,(5b-1b)\n"
-"	.dword  2b,(5b-2b)\n"
-"	.dword	3b,(5b-3b)\n"
-"	.dword  4b,(5b-4b)\n"
-#else
-"	.word	1b,(5b-1b)\n"
-"	.word	2b,(5b-2b)\n"
-"	.word	3b,(5b-3b)\n"
-"	.word	4b,(5b-4b)\n"
+"	.dword	1b,6b\n"
+"	.dword  2b,6b\n"
+"	.dword	3b,6b\n"
+"	.dword  4b,6b\n"
+#else
+"	.word	1b,6b\n"
+"	.word	2b,6b\n"
+"	.word	3b,6b\n"
+"	.word	4b,6b\n"
 #endif
 "	.previous\n"
 	: "=r" (ret)
@@ -438,21 +472,25 @@
 "3:	stw	%1,0(%%sr1,%1)\n"
 "4:	stw	%%r1,4(%%sr1,%3)\n"
 "5:	stw	%2,8(%%sr1,%3)\n"
-"	cmpclr,= %%r0, %%r0, %0\n"
-"6:	ldo	-2(%%r0), %0\n"
-"	.section __ex_table,\"a\"\n"
+"	copy	%%r0, %0\n"
+"6:	\n"
+"	.section .fixup,\"ax\"\n"
+"7:	ldi	-2, %0\n"
+	FIXUP_BRANCH(6b)
+"	.previous\n"
+"	.section __ex_table,\"aw\"\n"
 #ifdef __LP64__
-"	.dword	1b,(6b-1b)\n"
-"	.dword  2b,(6b-2b)\n"
-"	.dword	3b,(6b-3b)\n"
-"	.dword  4b,(6b-4b)\n"
-"	.dword  5b,(6b-5b)\n"
-#else
-"	.word	1b,(6b-1b)\n"
-"	.word	2b,(6b-2b)\n"
-"	.word	3b,(6b-3b)\n"
-"	.word	4b,(6b-4b)\n"
-"	.word  	5b,(6b-5b)\n"
+"	.dword	1b,7b\n"
+"	.dword  2b,7b\n"
+"	.dword	3b,7b\n"
+"	.dword  4b,7b\n"
+"	.dword  5b,7b\n"
+#else
+"	.word	1b,7b\n"
+"	.word	2b,7b\n"
+"	.word	3b,7b\n"
+"	.word	4b,7b\n"
+"	.word  	5b,7b\n"
 #endif
 "	.previous\n"
 	: "=r" (ret)
@@ -492,7 +530,6 @@
 			show_regs(regs);
 #endif		
 		}
-
 		if (!unaligned_enabled)
 			goto force_sigbus;
 	}
@@ -555,16 +592,6 @@
 			newbase += IM14(regs->iir&~4);
 		}
 		break;
-	}
-
-	if (regs->isr != regs->sr[7])
-	{
-		printk(KERN_CRIT "isr verification failed (isr: " RFMT ", sr7: " RFMT "\n",
-			regs->isr, regs->sr[7]);
-
-		/* don't kill him though, since he has appropriate access to the page, or we
-		 * would never have gotten here.
-		 */
 	}
 
 	/* TODO: make this cleaner... */
diff -Nru a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c
--- a/arch/parisc/kernel/unwind.c	2004-12-24 13:36:17 -08:00
+++ b/arch/parisc/kernel/unwind.c	2004-12-24 13:36:17 -08:00
@@ -12,8 +12,10 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/kallsyms.h>
 
 #include <asm/uaccess.h>
+#include <asm/assembly.h>
 
 #include <asm/unwind.h>
 
@@ -40,25 +42,27 @@
 static inline const struct unwind_table_entry *
 find_unwind_entry_in_table(const struct unwind_table *table, unsigned long addr)
 {
-	const struct unwind_table_entry *e = 0;
+	const struct unwind_table_entry *e = NULL;
 	unsigned long lo, hi, mid;
 
-	for (lo = 0, hi = table->length; lo < hi; )
-	{
-		mid = (lo + hi) / 2;
+	lo = 0; 
+	hi = table->length - 1; 
+	
+	while (lo <= hi) {
+		mid = (hi - lo) / 2 + lo;
 		e = &table->table[mid];
 		if (addr < e->region_start)
-			hi = mid;
+			hi = mid - 1;
 		else if (addr > e->region_end)
 			lo = mid + 1;
 		else
-			break;
+			return e;
 	}
 
-	return e;
+	return NULL;
 }
 
-static inline const struct unwind_table_entry *
+static const struct unwind_table_entry *
 find_unwind_entry(unsigned long addr)
 {
 	struct unwind_table *table = unwind_tables;
@@ -68,8 +72,7 @@
 	    addr <= kernel_unwind_table.end)
 		e = find_unwind_entry_in_table(&kernel_unwind_table, addr);
 	else
-		for (; table; table = table->next)
-		{
+		for (; table; table = table->next) {
 			if (addr >= table->start && 
 			    addr <= table->end)
 				e = find_unwind_entry_in_table(table, addr);
@@ -99,6 +102,11 @@
 	table->next = NULL;
 
 	for (; start <= end; start++) {
+		if (start < end && 
+		    start->region_end > (start+1)->region_start) {
+			printk("WARNING: Out of order unwind entry! %p and %p\n", start, start+1);
+		}
+
 		start->region_start += base_addr;
 		start->region_end += base_addr;
 	}
@@ -114,7 +122,7 @@
 
 	table = kmalloc(sizeof(struct unwind_table), GFP_USER);
 	if (table == NULL)
-		return 0;
+		return NULL;
 	unwind_table_init(table, name, base_addr, gp, start, end);
 	spin_lock_irqsave(&unwind_lock, flags);
 	if (unwind_tables)
@@ -170,12 +178,40 @@
 	int looking_for_rp, rpoffset = 0;
 
 	e = find_unwind_entry(info->ip);
-	if (!e) {
+	if (e == NULL) {
 		unsigned long sp;
 		extern char _stext[], _etext[];
 
 		dbg("Cannot find unwind entry for 0x%lx; forced unwinding\n", info->ip);
 
+#ifdef CONFIG_KALLSYMS
+		/* Handle some frequent special cases.... */
+		{
+			char symname[KSYM_NAME_LEN+1];
+			char *modname;
+			unsigned long symsize, offset;
+
+			kallsyms_lookup(info->ip, &symsize, &offset,
+					&modname, symname);
+
+			dbg("info->ip = 0x%lx, name = %s\n", info->ip, symname);
+
+			if (strcmp(symname, "_switch_to_ret") == 0) {
+				info->prev_sp = info->sp - CALLEE_SAVE_FRAME_SIZE;
+				info->prev_ip = *(unsigned long *)(info->prev_sp - RP_OFFSET);
+				dbg("_switch_to_ret @ %lx - setting "
+				    "prev_sp=%lx prev_ip=%lx\n", 
+				    info->ip, info->prev_sp, 
+				    info->prev_ip);
+				return;
+			} else if (strcmp(symname, "ret_from_kernel_thread") == 0 ||
+				   strcmp(symname, "syscall_exit") == 0) {
+				info->prev_ip = info->prev_sp = 0;
+				return;
+			}
+		}
+#endif
+
 		/* Since we are doing the unwinding blind, we don't know if
 		   we are adjusting the stack correctly or extracting the rp
 		   correctly. The rp is checked to see if it belongs to the
@@ -185,30 +221,33 @@
 		   modules. */
 		sp = info->sp & ~63;
 		do {
-			info->prev_sp = sp - 64;
-
-			/* FIXME: what happens if we unwind too far so that 
-			   sp no longer falls in a mapped kernel page? */
-#ifndef __LP64__
-			info->prev_ip = *(unsigned long *)(info->prev_sp - 20);
-#else
-			info->prev_ip = *(unsigned long *)(info->prev_sp - 16);
-#endif
+			unsigned long tmp;
 
+			info->prev_sp = sp - 64;
+			info->prev_ip = 0;
+			if (get_user(tmp, (unsigned long *)(info->prev_sp - RP_OFFSET))) 
+				break;
+			info->prev_ip = tmp;
 			sp = info->prev_sp;
 		} while (info->prev_ip < (unsigned long)_stext ||
 			 info->prev_ip > (unsigned long)_etext);
 
-		dbg("analyzing func @ %lx with no unwind info, setting prev_sp=%lx prev_ip=%lx\n", info->ip, info->prev_sp, info->prev_ip);
-	} else {
+		info->rp = 0;
 
-		dbg("e->start = 0x%x, e->end = 0x%x, Save_SP = %d, Save_RP = %d size = %u\n",
-				e->region_start, e->region_end, e->Save_SP, e->Save_RP, e->Total_frame_size);
+		dbg("analyzing func @ %lx with no unwind info, setting "
+		    "prev_sp=%lx prev_ip=%lx\n", info->ip, 
+		    info->prev_sp, info->prev_ip);
+	} else {
+		dbg("e->start = 0x%x, e->end = 0x%x, Save_SP = %d, "
+		    "Save_RP = %d size = %u\n", e->region_start, 
+		    e->region_end, e->Save_SP, e->Save_RP, 
+		    e->Total_frame_size);
 
 		looking_for_rp = e->Save_RP;
 
 		for (npc = e->region_start; 
-		     (frame_size < (e->Total_frame_size << 3) || looking_for_rp) && 
+		     (frame_size < (e->Total_frame_size << 3) || 
+		      looking_for_rp) && 
 		     npc < info->ip; 
 		     npc += 4) {
 
@@ -219,22 +258,28 @@
 				/* ldo X(sp), sp, or stwm X,D(sp) */
 				frame_size += (insn & 0x1 ? -1 << 13 : 0) | 
 					((insn & 0x3fff) >> 1);
-				dbg("analyzing func @ %lx, insn=%08x @ %lx, frame_size = %ld\n", info->ip, insn, npc, frame_size);
-			} else if ((insn & 0xffe00008) == 0x7ec00008) {
+				dbg("analyzing func @ %lx, insn=%08x @ "
+				    "%lx, frame_size = %ld\n", info->ip,
+				    insn, npc, frame_size);
+			} else if ((insn & 0xffe00008) == 0x73c00008) {
 				/* std,ma X,D(sp) */
 				frame_size += (insn & 0x1 ? -1 << 13 : 0) | 
 					(((insn >> 4) & 0x3ff) << 3);
-				dbg("analyzing func @ %lx, insn=%08x @ %lx, frame_size = %ld\n", info->ip, insn, npc, frame_size);
+				dbg("analyzing func @ %lx, insn=%08x @ "
+				    "%lx, frame_size = %ld\n", info->ip,
+				    insn, npc, frame_size);
 			} else if (insn == 0x6bc23fd9) { 
 				/* stw rp,-20(sp) */
 				rpoffset = 20;
 				looking_for_rp = 0;
-				dbg("analyzing func @ %lx, insn=stw rp,-20(sp) @ %lx\n", info->ip, npc);
+				dbg("analyzing func @ %lx, insn=stw rp,"
+				    "-20(sp) @ %lx\n", info->ip, npc);
 			} else if (insn == 0x0fc212c1) {
 				/* std rp,-16(sr0,sp) */
 				rpoffset = 16;
 				looking_for_rp = 0;
-				dbg("analyzing func @ %lx, insn=std rp,-16(sp) @ %lx\n", info->ip, npc);
+				dbg("analyzing func @ %lx, insn=std rp,"
+				    "-16(sp) @ %lx\n", info->ip, npc);
 			}
 		}
 
@@ -244,7 +289,9 @@
 		info->prev_ip = info->rp;
 		info->rp = 0;
 
-		dbg("analyzing func @ %lx, setting prev_sp=%lx prev_ip=%lx\n", info->ip, info->prev_sp, info->prev_ip);
+		dbg("analyzing func @ %lx, setting prev_sp=%lx "
+		    "prev_ip=%lx npc=%lx\n", info->ip, info->prev_sp, 
+		    info->prev_ip, npc);
 	}
 }
 
@@ -257,7 +304,8 @@
 	info->ip = ip;
 	info->rp = rp;
 
-	dbg("(%d) Start unwind from sp=%08lx ip=%08lx\n", t ? (int)t->pid : 0, info->sp, info->ip);
+	dbg("(%d) Start unwind from sp=%08lx ip=%08lx\n", 
+	    t ? (int)t->pid : -1, info->sp, info->ip);
 }
 
 void unwind_frame_init_from_blocked_task(struct unwind_frame_info *info, struct task_struct *t)
@@ -285,7 +333,9 @@
 	next_frame->prev_sp = 0;
 	next_frame->prev_ip = 0;
 
-	dbg("(%d) Continue unwind to sp=%08lx ip=%08lx\n", (int)next_frame->t->pid, next_frame->sp, next_frame->ip);
+	dbg("(%d) Continue unwind to sp=%08lx ip=%08lx\n", 
+	    next_frame->t ? (int)next_frame->t->pid : -1, 
+	    next_frame->sp, next_frame->ip);
 
 	return 0;
 }
diff -Nru a/arch/parisc/lib/Makefile b/arch/parisc/lib/Makefile
--- a/arch/parisc/lib/Makefile	2004-12-24 13:36:56 -08:00
+++ b/arch/parisc/lib/Makefile	2004-12-24 13:36:56 -08:00
@@ -2,6 +2,6 @@
 # Makefile for parisc-specific library files
 #
 
-lib-y	:= lusercopy.o bitops.o checksum.o io.o memset.o
+lib-y	:= lusercopy.o bitops.o checksum.o io.o memset.o fixup.o memcpy.o
 
 lib-$(CONFIG_SMP) += debuglocks.o
diff -Nru a/arch/parisc/lib/bitops.c b/arch/parisc/lib/bitops.c
--- a/arch/parisc/lib/bitops.c	2004-12-24 13:36:18 -08:00
+++ b/arch/parisc/lib/bitops.c	2004-12-24 13:36:18 -08:00
@@ -13,8 +13,8 @@
 #include <asm/atomic.h>
 
 #ifdef CONFIG_SMP
-atomic_lock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned = {
-	[0 ... (ATOMIC_HASH_SIZE-1)]  = (atomic_lock_t) { { 1, 1, 1, 1 } }
+spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned = {
+	[0 ... (ATOMIC_HASH_SIZE-1)]  = SPIN_LOCK_UNLOCKED
 };
 #endif
 
@@ -23,10 +23,10 @@
 {
 	unsigned long temp, flags;
 
-	atomic_spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_lock_irqsave(ptr, flags);
 	temp = *ptr;
 	*ptr = x;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_unlock_irqrestore(ptr, flags);
 	return temp;
 }
 #endif
@@ -36,10 +36,10 @@
 	unsigned long flags;
 	long temp;
 
-	atomic_spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_lock_irqsave(ptr, flags);
 	temp = (long) *ptr;	/* XXX - sign extension wanted? */
 	*ptr = x;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_unlock_irqrestore(ptr, flags);
 	return (unsigned long)temp;
 }
 
@@ -49,10 +49,10 @@
 	unsigned long flags;
 	long temp;
 
-	atomic_spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_lock_irqsave(ptr, flags);
 	temp = (long) *ptr;	/* XXX - sign extension wanted? */
 	*ptr = x;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_unlock_irqrestore(ptr, flags);
 	return (unsigned long)temp;
 }
 
@@ -63,10 +63,10 @@
 	unsigned long flags;
 	unsigned long prev;
 
-	atomic_spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_lock_irqsave(ptr, flags);
 	if ((prev = *ptr) == old)
 		*ptr = new;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_unlock_irqrestore(ptr, flags);
 	return prev;
 }
 #endif
@@ -76,9 +76,9 @@
 	unsigned long flags;
 	unsigned int prev;
 
-	atomic_spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_lock_irqsave(ptr, flags);
 	if ((prev = *ptr) == old)
 		*ptr = new;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);
+	_atomic_spin_unlock_irqrestore(ptr, flags);
 	return (unsigned long)prev;
 }
diff -Nru a/arch/parisc/lib/checksum.c b/arch/parisc/lib/checksum.c
--- a/arch/parisc/lib/checksum.c	2004-12-24 13:37:01 -08:00
+++ b/arch/parisc/lib/checksum.c	2004-12-24 13:37:01 -08:00
@@ -24,6 +24,13 @@
 #include <asm/string.h>
 #include <asm/uaccess.h>
 
+#define addc(_t,_r)                     \
+	__asm__ __volatile__ (          \
+"       add             %0, %1, %0\n"   \
+"       addc            %0, %%r0, %0\n" \
+	: "=r"(_t)                      \
+	: "r"(_r), "0"(_t));
+
 static inline unsigned short from32to16(unsigned int x)
 {
 	/* 32 bits --> 16 bits + carry */
@@ -56,16 +63,25 @@
 		}
 		count >>= 1;		/* nr of 32-bit words.. */
 		if (count) {
-			unsigned int carry = 0;
-			do {
+			while (count >= 4) {
+				unsigned int r1, r2, r3, r4;
+				r1 = *(unsigned int *)(buff + 0);
+				r2 = *(unsigned int *)(buff + 4);
+				r3 = *(unsigned int *)(buff + 8);
+				r4 = *(unsigned int *)(buff + 12);
+				addc(result, r1);
+				addc(result, r2);
+				addc(result, r3);
+				addc(result, r4);
+				count -= 4;
+				buff += 16;
+			}
+			while (count) {
 				unsigned int w = *(unsigned int *) buff;
 				count--;
 				buff += 4;
-				result += carry;
-				result += w;
-				carry = (w > result);
-			} while (count);
-			result += carry;
+				addc(result, w);
+			}
 			result = (result & 0xffff) + (result >> 16);
 		}
 		if (len & 2) {
@@ -77,7 +93,7 @@
 		result += le16_to_cpu(*buff);
 	result = from32to16(result);
 	if (odd)
-		result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
+		result = swab16(result);
 out:
 	return result;
 }
@@ -88,12 +104,8 @@
 unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum)
 {
 	unsigned int result = do_csum(buff, len);
-
-	/* add in old sum, and carry.. */
-	result += sum;
-	if(sum > result)
-		result += 1;
-	return result;
+	addc(result, sum);
+	return from32to16(result);
 }
 
 EXPORT_SYMBOL(csum_partial);
diff -Nru a/arch/parisc/lib/debuglocks.c b/arch/parisc/lib/debuglocks.c
--- a/arch/parisc/lib/debuglocks.c	2004-12-24 13:37:01 -08:00
+++ b/arch/parisc/lib/debuglocks.c	2004-12-24 13:37:01 -08:00
@@ -18,6 +18,11 @@
  *    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
+ *
+ *    We use pdc_printf() throughout the file for all output messages, to avoid
+ *    losing messages because of disabled interrupts. Since we're using these
+ *    messages for debugging purposes, it makes sense not to send them to the
+ *    linux console.
  */
 
 
@@ -27,12 +32,15 @@
 #include <linux/spinlock.h>
 #include <linux/hardirq.h>	/* in_interrupt() */
 #include <asm/system.h>
+#include <asm/hardirq.h>	/* in_interrupt() */
+#include <asm/pdc.h>
 
 #undef INIT_STUCK
 #define INIT_STUCK 1L << 30
 
 #ifdef CONFIG_DEBUG_SPINLOCK
 
+
 void _dbg_spin_lock(spinlock_t * lock, const char *base_file, int line_no)
 {
 	volatile unsigned int *a;
@@ -59,12 +67,14 @@
 	 * <tausq> __ldcw() returns 1 if we get the lock; otherwise we
 	 * 	spin until the value of the lock changes, or we time out.
 	 */
+	mb();
 	a = __ldcw_align(lock);
 	while (stuck && (__ldcw(a) == 0))
 		while ((*a == 0) && --stuck);
+	mb();
 
 	if (unlikely(stuck <= 0)) {
-		printk(KERN_WARNING
+		pdc_printf(
 			"%s:%d: spin_lock(%s/%p) stuck in %s at %p(%d)"
 			" owned by %s:%d in %s at %p(%d)\n",
 			base_file, line_no, lock->module, lock,
@@ -84,7 +94,7 @@
 	lock->bline = line_no;
 
 	if (unlikely(printed)) {
-		printk(KERN_WARNING
+		pdc_printf(
 			"%s:%d: spin_lock grabbed in %s at %p(%d) %ld ticks\n",
 			base_file, line_no, current->comm, inline_pc,
 			cpu, jiffies - started);
@@ -94,21 +104,28 @@
 void _dbg_spin_unlock(spinlock_t * lock, const char *base_file, int line_no)
 {
 	CHECK_LOCK(lock);
-	volatile unsigned int *a = __ldcw_align(lock);
+	volatile unsigned int *a;
+	mb();
+	a = __ldcw_align(lock);
 	if (unlikely((*a != 0) && lock->babble)) {
 		lock->babble--;
-		printk(KERN_WARNING
+		pdc_printf(
 			"%s:%d: spin_unlock(%s:%p) not locked\n",
 			base_file, line_no, lock->module, lock);
 	}
 	*a = 1;	
+	mb();
 }
 
 int _dbg_spin_trylock(spinlock_t * lock, const char *base_file, int line_no)
 {
 	int ret;
-	volatile unsigned int *a = __ldcw_align(lock);
-	if ((ret = (__ldcw(a) != 0))) {
+	volatile unsigned int *a;
+	mb();
+	a = __ldcw_align(lock);
+	ret = (__ldcw(a) != 0);
+	mb();
+	if (ret) {
 		lock->oncpu = smp_processor_id();
 		lock->previous = __builtin_return_address(0);
 		lock->task = current;
@@ -150,7 +167,7 @@
 	int cpu = smp_processor_id();
 	
 	if(unlikely(in_interrupt())) {	/* acquiring write lock in interrupt context, bad idea */
-		printk(KERN_WARNING "write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
+		pdc_printf("write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
 		BUG();
 	}
 
@@ -167,7 +184,7 @@
 		
 		stuck--;
 		if ((unlikely(stuck <= 0)) && (rw->counter < 0)) {
-			printk(KERN_WARNING
+			pdc_printf(
 				"%s:%d: write_lock stuck on writer"
 				" in %s at %p(%d) %ld ticks\n",
 				bfile, bline, current->comm, inline_pc,
@@ -176,7 +193,7 @@
 			printed = 1;
 		}
 		else if (unlikely(stuck <= 0)) {
-			printk(KERN_WARNING
+			pdc_printf(
 				"%s:%d: write_lock stuck on reader"
 				" in %s at %p(%d) %ld ticks\n",
 				bfile, bline, current->comm, inline_pc,
@@ -194,13 +211,47 @@
 	rw->counter = -1; /* remember we are locked */
 
 	if (unlikely(printed)) {
-		printk(KERN_WARNING
+		pdc_printf(
 			"%s:%d: write_lock grabbed in %s at %p(%d) %ld ticks\n",
 			bfile, bline, current->comm, inline_pc,
 			cpu, jiffies - started);
 	}
 }
 
+int _dbg_write_trylock(rwlock_t *rw, const char *bfile, int bline)
+{
+#if 0
+	void *inline_pc = __builtin_return_address(0);
+	int cpu = smp_processor_id();
+#endif
+	
+	if(unlikely(in_interrupt())) {	/* acquiring write lock in interrupt context, bad idea */
+		pdc_printf("write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
+		BUG();
+	}
+
+	/* Note: if interrupts are disabled (which is most likely), the printk
+	will never show on the console. We might need a polling method to flush
+	the dmesg buffer anyhow. */
+	
+	_raw_spin_lock(&rw->lock);
+
+	if(rw->counter != 0) {
+		/* this basically never happens */
+		_raw_spin_unlock(&rw->lock);
+		
+		
+		return 0;
+	}
+
+	/* got it.  now leave without unlocking */
+	rw->counter = -1; /* remember we are locked */
+#if 0
+	pdc_printf("%s:%d: try write_lock grabbed in %s at %p(%d)\n",
+		   bfile, bline, current->comm, inline_pc, cpu);
+#endif
+}
+
 void _dbg_read_lock(rwlock_t * rw, const char *bfile, int bline)
 {
 #if 0
@@ -215,7 +266,7 @@
 
 	rw->counter++;
 #if 0
-	printk(KERN_WARNING
+	pdc_printf(
 		"%s:%d: read_lock grabbed in %s at %p(%d) %ld ticks\n",
 		bfile, bline, current->comm, inline_pc,
 		cpu, jiffies - started);
diff -Nru a/arch/parisc/lib/fixup.S b/arch/parisc/lib/fixup.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/parisc/lib/fixup.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,89 @@
+/*
+ * Linux/PA-RISC Project (http://www.parisc-linux.org/)
+ *
+ *  Copyright (C) 2004  Randolph Chung <tausq@debian.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, 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.
+ * 
+ * Fixup routines for kernel exception handling.
+ */
+#include <linux/config.h>
+#include <asm/offsets.h>
+#include <asm/assembly.h>
+#include <asm/errno.h>
+
+#ifdef CONFIG_SMP
+	.macro  get_fault_ip t1 t2
+	addil LT%__per_cpu_offset,%r27
+	LDREG RT%__per_cpu_offset(%r1),\t1
+	/* t2 = smp_processor_id() */
+	mfctl 30,\t2
+	ldw TI_CPU(\t2),\t2
+#ifdef __LP64__
+	extrd,u \t2,63,32,\t2
+#endif
+	/* t2 = &__per_cpu_offset[smp_processor_id()]; */
+	LDREG,s \t2(\t1),\t2 
+	addil LT%per_cpu__exception_data,%r27
+	LDREG RT%per_cpu__exception_data(%r1),\t1
+	/* t1 = &__get_cpu_var(exception_data) */
+	add,l \t1,\t2,\t1
+	/* t1 = t1->fault_ip */
+	LDREG EXCDATA_IP(\t1), \t1
+	.endm
+#else
+	.macro  get_fault_ip t1 t2
+	/* t1 = &__get_cpu_var(exception_data) */
+	addil LT%per_cpu__exception_data,%r27
+	LDREG RT%per_cpu__exception_data(%r1),\t2
+	/* t1 = t2->fault_ip */
+	LDREG EXCDATA_IP(\t2), \t1
+	.endm
+#endif
+
+	.text
+	.section .fixup, "ax"
+
+	/* get_user() fixups, store -EFAULT in r8, and 0 in r9 */
+	.export fixup_get_user_skip_1
+fixup_get_user_skip_1:
+	get_fault_ip %r1,%r8
+	ldo 4(%r1), %r1
+	ldi -EFAULT, %r8
+	bv %r0(%r1)
+	copy %r0, %r9
+
+	.export fixup_get_user_skip_2
+fixup_get_user_skip_2:
+	get_fault_ip %r1,%r8
+	ldo 8(%r1), %r1
+	ldi -EFAULT, %r8
+	bv %r0(%r1)
+	copy %r0, %r9
+
+	/* put_user() fixups, store -EFAULT in r8 */
+	.export fixup_put_user_skip_1
+fixup_put_user_skip_1:
+	get_fault_ip %r1,%r8
+	ldo 4(%r1), %r1
+	bv %r0(%r1)
+	ldi -EFAULT, %r8
+
+	.export fixup_put_user_skip_2
+fixup_put_user_skip_2:
+	get_fault_ip %r1,%r8
+	ldo 8(%r1), %r1
+	bv %r0(%r1)
+	ldi -EFAULT, %r8
diff -Nru a/arch/parisc/lib/lusercopy.S b/arch/parisc/lib/lusercopy.S
--- a/arch/parisc/lib/lusercopy.S	2004-12-24 13:36:17 -08:00
+++ b/arch/parisc/lib/lusercopy.S	2004-12-24 13:36:17 -08:00
@@ -53,124 +53,11 @@
 	mtsp        %r1,%sr1
 	.endm
 
-	/*
-	 * unsigned long
-	 * lcopy_to_user(void *to, const void *from, unsigned long n)
-	 *
-	 * Returns 0 for success.
-	 * otherwise, returns number of bytes not transferred.
-	 */
-
-	.export lcopy_to_user,code
-lcopy_to_user:
-	.proc
-	.callinfo NO_CALLS
-	.entry
-	comib,=,n   0,%r24,$lctu_done
-	get_sr
-$lctu_loop:
-	ldbs,ma     1(%r25),%r1
-	addib,<>    -1,%r24,$lctu_loop
-1:      stbs,ma     %r1,1(%sr1,%r26)
-$lctu_done:
-	bv          %r0(%r2)
-	copy        %r24,%r28
-	.exit
-
-2:      b $lctu_done
-	ldo         1(%r24),%r24
-
-	.section __ex_table,"a"
-#ifdef __LP64__
-	.dword      1b,(2b-1b)
-#else
-	.word       1b,(2b-1b)
-#endif
-	.previous
-
-	.procend
-
-	/*
-	 * unsigned long
-	 * lcopy_from_user(void *to, const void *from, unsigned long n)
-	 *
-	 * Returns 0 for success.
-	 * otherwise, returns number of bytes not transferred.
-	 *
-	 * NOTE: This routine will also zero any bytes in the
-	 *       destination that were not copied due to a fault.
-	 *
-	 */
-
-	.export lcopy_from_user,code
-lcopy_from_user:
-	.proc
-	.callinfo NO_CALLS
-	.entry
-	comib,=,n   0,%r24,$lcfu_done
-	get_sr
-$lcfu_loop:
-1:      ldbs,ma     1(%sr1,%r25),%r1
-	addib,<>    -1,%r24,$lcfu_loop
-	stbs,ma     %r1,1(%r26)
-$lcfu_done:
-	bv          %r0(%r2)
-	copy        %r24,%r28
-	.exit
-
-2:      copy        %r24,%r23
-$lcfu_zero_loop:
-	addib,<>    -1,%r23,$lcfu_zero_loop
-	stbs,ma     %r0,1(%r26)
-	b           $lcfu_done
-	nop
-
-	.section __ex_table,"a"
-#ifdef __LP64__
-	.dword      1b,(2b-1b)
-#else
-	.word       1b,(2b-1b)
-#endif
-	.previous
-
-	.procend
-
-	/*
-	 * unsigned long
-	 * lcopy_in_user(void *to, const void *from, unsigned long n)
-	 *
-	 * Returns 0 for success.
-	 * otherwise, returns number of bytes not transferred.
-	 */
-
-	.export lcopy_in_user,code
-lcopy_in_user:
-	.proc
-	.callinfo NO_CALLS
-	.entry
-	comib,=,n   0,%r24,$lciu_done
-	get_sr
-$lciu_loop:
-	ldbs,ma     1(%sr1,%r25),%r1
-	addib,<>    -1,%r24,$lciu_loop
-1:      stbs,ma     %r1,1(%sr1,%r26)
-$lciu_done:
-	bv          %r0(%r2)
-	copy        %r24,%r28
-	.exit
-
-2:      b $lciu_done
-	ldo         1(%r24),%r24
-
-	.section __ex_table,"a"
-#ifdef __LP64__
-	.dword      1b,(2b-1b)
-#else
-	.word       1b,(2b-1b)
-#endif
-	.previous
-
-	.procend
+	.macro fixup_branch lbl
+	ldil	    L%\lbl, %r1
+	ldo	    R%\lbl(%r1), %r1
+	bv          %r0(%r1)
+	.endm
 
 	/*
 	 * long lstrncpy_from_user(char *dst, const char *src, long n)
@@ -201,16 +88,18 @@
 	nop
 	.exit
 
-3:      b           $lsfu_exit
+	.section .fixup,"ax"
+3:      fixup_branch $lsfu_exit
 	ldi         -EFAULT,%r28
+	.previous
 
-	.section __ex_table,"a"
+	.section __ex_table,"aw"
 #ifdef __LP64__
-	.dword      1b,(3b-1b)
-	.dword      2b,(3b-2b)
+	.dword      1b,3b
+	.dword      2b,3b
 #else
-	.word       1b,(3b-1b)
-	.word       2b,(3b-2b)
+	.word       1b,3b
+	.word       2b,3b
 #endif
 	.previous
 
@@ -239,14 +128,16 @@
 	copy        %r25,%r28
 	.exit
 
-2:      b $lclu_done
+	.section .fixup,"ax"
+2:      fixup_branch $lclu_done
 	ldo        1(%r25),%r25
+	.previous
 
-	.section __ex_table,"a"
+	.section __ex_table,"aw"
 #ifdef __LP64__
-	.dword      1b,(2b-1b)
+	.dword      1b,2b
 #else
-	.word       1b,(2b-1b)
+	.word       1b,2b
 #endif
 	.previous
 
@@ -282,16 +173,18 @@
 	b           $lslen_done
 	ldo         1(%r26),%r26 /* special case for N == 0 */
 
-3:      b           $lslen_done
+	.section .fixup,"ax"
+3:      fixup_branch $lslen_done
 	copy        %r24,%r26    /* reset r26 so 0 is returned on fault */
+	.previous
 
-	.section __ex_table,"a"
+	.section __ex_table,"aw"
 #ifdef __LP64__
-	.dword      1b,(3b-1b)
-	.dword      2b,(3b-2b)
+	.dword      1b,3b
+	.dword      2b,3b
 #else
-	.word       1b,(3b-1b)
-	.word       2b,(3b-2b)
+	.word       1b,3b
+	.word       2b,3b
 #endif
 	.previous
 
diff -Nru a/arch/parisc/lib/memcpy.c b/arch/parisc/lib/memcpy.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/parisc/lib/memcpy.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,530 @@
+/*
+ *    Optimized memory copy routines.
+ *
+ *    Copyright (C) 2004 Randolph Chung <tausq@debian.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, 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.
+ *
+ *    Portions derived from the GNU C Library
+ *    Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc.
+ *
+ * Several strategies are tried to try to get the best performance for various
+ * conditions. In the optimal case, we copy 64-bytes in an unrolled loop using 
+ * fp regs. This is followed by loops that copy 32- or 16-bytes at a time using
+ * general registers.  Unaligned copies are handled either by aligning the 
+ * destination and then using shift-and-write method, or in a few cases by 
+ * falling back to a byte-at-a-time copy.
+ *
+ * I chose to implement this in C because it is easier to maintain and debug,
+ * and in my experiments it appears that the C code generated by gcc (3.3/3.4
+ * at the time of writing) is fairly optimal. Unfortunately some of the 
+ * semantics of the copy routine (exception handling) is difficult to express
+ * in C, so we have to play some tricks to get it to work.
+ *
+ * All the loads and stores are done via explicit asm() code in order to use
+ * the right space registers. 
+ * 
+ * Testing with various alignments and buffer sizes shows that this code is 
+ * often >10x faster than a simple byte-at-a-time copy, even for strangely
+ * aligned operands. It is interesting to note that the glibc version
+ * of memcpy (written in C) is actually quite fast already. This routine is 
+ * able to beat it by 30-40% for aligned copies because of the loop unrolling, 
+ * but in some cases the glibc version is still slightly faster. This lends 
+ * more credibility that gcc can generate very good code as long as we are 
+ * careful.
+ *
+ * TODO:
+ * - cache prefetching needs more experimentation to get optimal settings
+ * - try not to use the post-increment address modifiers; they create additional
+ *   interlocks
+ * - replace byte-copy loops with stybs sequences
+ */
+
+#ifdef __KERNEL__
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/compiler.h>
+#include <asm/uaccess.h>
+#define s_space "%%sr1"
+#define d_space "%%sr2"
+#else
+#include "memcpy.h"
+#define s_space "%%sr0"
+#define d_space "%%sr0"
+#define pa_memcpy new2_copy
+#endif
+
+DECLARE_PER_CPU(struct exception_data, exception_data);
+
+#define preserve_branch(label)	do {					\
+	volatile int dummy;						\
+	/* The following branch is never taken, it's just here to  */	\
+	/* prevent gcc from optimizing away our exception code. */ 	\
+	if (unlikely(dummy != dummy))					\
+		goto label;						\
+} while (0)
+
+#define get_user_space() (segment_eq(get_fs(), KERNEL_DS) ? 0 : mfsp(3))
+#define get_kernel_space() (0)
+
+#define MERGE(w0, sh_1, w1, sh_2)  ({					\
+	unsigned int _r;						\
+	asm volatile (							\
+	"mtsar %3\n"							\
+	"shrpw %1, %2, %%sar, %0\n"					\
+	: "=r"(_r)							\
+	: "r"(w0), "r"(w1), "r"(sh_2)					\
+	);								\
+	_r;								\
+})
+#define THRESHOLD	16
+
+#ifdef DEBUG_MEMCPY
+#define DPRINTF(fmt, args...) do { printk(KERN_DEBUG "%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__ ); printk(KERN_DEBUG fmt, ##args ); } while (0)
+#else
+#define DPRINTF(fmt, args...)
+#endif
+
+#ifndef __LP64__
+#define EXC_WORD ".word"
+#else
+#define EXC_WORD ".dword"
+#endif
+
+#define def_load_ai_insn(_insn,_sz,_tt,_s,_a,_t,_e)	\
+	__asm__ __volatile__ (				\
+	"1:\t" #_insn ",ma " #_sz "(" _s ",%1), %0\n" 	\
+	"\t.section __ex_table,\"aw\"\n"		\
+	"\t" EXC_WORD "\t1b\n"				\
+	"\t" EXC_WORD "\t" #_e "\n"			\
+	"\t.previous\n"					\
+	: _tt(_t), "+r"(_a)				\
+	: "1"(_a)					\
+	: "r8")
+
+#define def_store_ai_insn(_insn,_sz,_tt,_s,_a,_t,_e) 	\
+	__asm__ __volatile__ (				\
+	"1:\t" #_insn ",ma %1, " #_sz "(" _s ",%0)\n" 	\
+	"\t.section __ex_table,\"aw\"\n"		\
+	"\t" EXC_WORD "\t1b\n"				\
+	"\t" EXC_WORD "\t" #_e "\n"			\
+	"\t.previous\n"					\
+	: "+r"(_a) 					\
+	: _tt(_t), "0"(_a)				\
+	: "r8")
+
+#define ldbma(_s, _a, _t, _e) def_load_ai_insn(ldbs,1,"=r",_s,_a,_t,_e)
+#define stbma(_s, _t, _a, _e) def_store_ai_insn(stbs,1,"r",_s,_a,_t,_e)
+#define ldwma(_s, _a, _t, _e) def_load_ai_insn(ldw,4,"=r",_s,_a,_t,_e)
+#define stwma(_s, _t, _a, _e) def_store_ai_insn(stw,4,"r",_s,_a,_t,_e)
+#define flddma(_s, _a, _t, _e) def_load_ai_insn(fldd,8,"=f",_s,_a,_t,_e)
+#define fstdma(_s, _t, _a, _e) def_store_ai_insn(fstd,8,"f",_s,_a,_t,_e)
+
+#define def_load_insn(_insn,_tt,_s,_o,_a,_t,_e) 	\
+	__asm__ __volatile__ (				\
+	"1:\t" #_insn " " #_o "(" _s ",%1), %0\n"	\
+	"\t.section __ex_table,\"aw\"\n"		\
+	"\t" EXC_WORD "\t1b\n"				\
+	"\t" EXC_WORD "\t" #_e "\n"			\
+	"\t.previous\n"					\
+	: _tt(_t) 					\
+	: "r"(_a)					\
+	: "r8")
+
+#define def_store_insn(_insn,_tt,_s,_t,_o,_a,_e) 	\
+	__asm__ __volatile__ (				\
+	"1:\t" #_insn " %0, " #_o "(" _s ",%1)\n" 	\
+	"\t.section __ex_table,\"aw\"\n"		\
+	"\t" EXC_WORD "\t1b\n"				\
+	"\t" EXC_WORD "\t" #_e "\n"			\
+	"\t.previous\n"					\
+	: 						\
+	: _tt(_t), "r"(_a)				\
+	: "r8")
+
+#define ldw(_s,_o,_a,_t,_e)	def_load_insn(ldw,"=r",_s,_o,_a,_t,_e)
+#define stw(_s,_t,_o,_a,_e) 	def_store_insn(stw,"r",_s,_t,_o,_a,_e)
+
+#ifdef  CONFIG_PREFETCH
+extern inline void prefetch_src(const void *addr)
+{
+	__asm__("ldw 0(" s_space ",%0), %%r0" : : "r" (addr));
+}
+
+extern inline void prefetch_dst(const void *addr)
+{
+	__asm__("ldd 0(" d_space ",%0), %%r0" : : "r" (addr));
+}
+#else
+#define prefetch_src(addr)
+#define prefetch_dst(addr)
+#endif
+
+/* Copy from a not-aligned src to an aligned dst, using shifts. Handles 4 words
+ * per loop.  This code is derived from glibc. 
+ */
+static inline unsigned long copy_dstaligned(unsigned long dst, unsigned long src, unsigned long len, unsigned long o_dst, unsigned long o_src, unsigned long o_len)
+{
+	/* gcc complains that a2 and a3 may be uninitialized, but actually
+	 * they cannot be.  Initialize a2/a3 to shut gcc up.
+	 */
+	register unsigned int a0, a1, a2 = 0, a3 = 0;
+	int sh_1, sh_2;
+	struct exception_data *d;
+
+	/* prefetch_src((const void *)src); */
+
+	/* Calculate how to shift a word read at the memory operation
+	   aligned srcp to make it aligned for copy.  */
+	sh_1 = 8 * (src % sizeof(unsigned int));
+	sh_2 = 8 * sizeof(unsigned int) - sh_1;
+
+	/* Make src aligned by rounding it down.  */
+	src &= -sizeof(unsigned int);
+
+	switch (len % 4)
+	{
+		case 2:
+			/* a1 = ((unsigned int *) src)[0];
+			   a2 = ((unsigned int *) src)[1]; */
+			ldw(s_space, 0, src, a1, cda_ldw_exc);
+			ldw(s_space, 4, src, a2, cda_ldw_exc);
+			src -= 1 * sizeof(unsigned int);
+			dst -= 3 * sizeof(unsigned int);
+			len += 2;
+			goto do1;
+		case 3:
+			/* a0 = ((unsigned int *) src)[0];
+			   a1 = ((unsigned int *) src)[1]; */
+			ldw(s_space, 0, src, a0, cda_ldw_exc);
+			ldw(s_space, 4, src, a1, cda_ldw_exc);
+			src -= 0 * sizeof(unsigned int);
+			dst -= 2 * sizeof(unsigned int);
+			len += 1;
+			goto do2;
+		case 0:
+			if (len == 0)
+				return 0;
+			/* a3 = ((unsigned int *) src)[0];
+			   a0 = ((unsigned int *) src)[1]; */
+			ldw(s_space, 0, src, a3, cda_ldw_exc);
+			ldw(s_space, 4, src, a0, cda_ldw_exc);
+			src -=-1 * sizeof(unsigned int);
+			dst -= 1 * sizeof(unsigned int);
+			len += 0;
+			goto do3;
+		case 1:
+			/* a2 = ((unsigned int *) src)[0];
+			   a3 = ((unsigned int *) src)[1]; */
+			ldw(s_space, 0, src, a2, cda_ldw_exc);
+			ldw(s_space, 4, src, a3, cda_ldw_exc);
+			src -=-2 * sizeof(unsigned int);
+			dst -= 0 * sizeof(unsigned int);
+			len -= 1;
+			if (len == 0)
+				goto do0;
+			goto do4;			/* No-op.  */
+	}
+
+	do
+	{
+		/* prefetch_src((const void *)(src + 4 * sizeof(unsigned int))); */
+do4:
+		/* a0 = ((unsigned int *) src)[0]; */
+		ldw(s_space, 0, src, a0, cda_ldw_exc);
+		/* ((unsigned int *) dst)[0] = MERGE (a2, sh_1, a3, sh_2); */
+		stw(d_space, MERGE (a2, sh_1, a3, sh_2), 0, dst, cda_stw_exc);
+do3:
+		/* a1 = ((unsigned int *) src)[1]; */
+		ldw(s_space, 4, src, a1, cda_ldw_exc);
+		/* ((unsigned int *) dst)[1] = MERGE (a3, sh_1, a0, sh_2); */
+		stw(d_space, MERGE (a3, sh_1, a0, sh_2), 4, dst, cda_stw_exc);
+do2:
+		/* a2 = ((unsigned int *) src)[2]; */
+		ldw(s_space, 8, src, a2, cda_ldw_exc);
+		/* ((unsigned int *) dst)[2] = MERGE (a0, sh_1, a1, sh_2); */
+		stw(d_space, MERGE (a0, sh_1, a1, sh_2), 8, dst, cda_stw_exc);
+do1:
+		/* a3 = ((unsigned int *) src)[3]; */
+		ldw(s_space, 12, src, a3, cda_ldw_exc);
+		/* ((unsigned int *) dst)[3] = MERGE (a1, sh_1, a2, sh_2); */
+		stw(d_space, MERGE (a1, sh_1, a2, sh_2), 12, dst, cda_stw_exc);
+
+		src += 4 * sizeof(unsigned int);
+		dst += 4 * sizeof(unsigned int);
+		len -= 4;
+	}
+	while (len != 0);
+
+do0:
+	/* ((unsigned int *) dst)[0] = MERGE (a2, sh_1, a3, sh_2); */
+	stw(d_space, MERGE (a2, sh_1, a3, sh_2), 0, dst, cda_stw_exc);
+
+	preserve_branch(handle_load_error);
+	preserve_branch(handle_store_error);
+
+	return 0;
+
+handle_load_error:
+	__asm__ __volatile__ ("cda_ldw_exc:\n");
+	d = &__get_cpu_var(exception_data);
+	DPRINTF("cda_ldw_exc: o_len=%lu fault_addr=%lu o_src=%lu ret=%lu\n",
+		o_len, d->fault_addr, o_src, o_len - d->fault_addr + o_src);
+	return o_len * 4 - d->fault_addr + o_src;
+
+handle_store_error:
+	__asm__ __volatile__ ("cda_stw_exc:\n");
+	d = &__get_cpu_var(exception_data);
+	DPRINTF("cda_stw_exc: o_len=%lu fault_addr=%lu o_dst=%lu ret=%lu\n",
+		o_len, d->fault_addr, o_dst, o_len - d->fault_addr + o_dst);
+	return o_len * 4 - d->fault_addr + o_dst;
+}
+
+
+/* Returns 0 for success, otherwise, returns number of bytes not transferred. */
+unsigned long pa_memcpy(void *dstp, const void *srcp, unsigned long len)
+{
+	register unsigned long src, dst, t1, t2, t3;
+	register char *pcs, *pcd;
+	register unsigned int *pws, *pwd;
+	register double *pds, *pdd;
+	unsigned long ret = 0;
+	unsigned long o_dst, o_src, o_len;
+	struct exception_data *d;
+
+	src = (unsigned long)srcp;
+	dst = (unsigned long)dstp;
+	pcs = (unsigned char *)srcp;
+	pcd = (unsigned char *)dstp;
+
+	o_dst = dst; o_src = src; o_len = len;
+
+	/* prefetch_src((const void *)srcp); */
+
+	if (len < THRESHOLD)
+		goto byte_copy;
+
+	/* Check alignment */
+	t1 = (src ^ dst);
+	if (unlikely(t1 & (sizeof(double)-1)))
+		goto unaligned_copy;
+
+	/* src and dst have same alignment. */
+
+	/* Copy bytes till we are double-aligned. */
+	t2 = src & (sizeof(double) - 1);
+	if (unlikely(t2 != 0)) {
+		t2 = sizeof(double) - t2;
+		while (t2 && len) {
+			/* *pcd++ = *pcs++; */
+			ldbma(s_space, pcs, t3, pmc_load_exc);
+			len--;
+			stbma(d_space, t3, pcd, pmc_store_exc);
+			t2--;
+		}
+	}
+
+	pds = (double *)pcs;
+	pdd = (double *)pcd;
+
+	/* Copy 8 doubles at a time */
+	while (len >= 8*sizeof(double)) {
+		register double r1, r2, r3, r4, r5, r6, r7, r8;
+		/* prefetch_src((char *)pds + L1_CACHE_BYTES); */
+		flddma(s_space, pds, r1, pmc_load_exc);
+		flddma(s_space, pds, r2, pmc_load_exc);
+		flddma(s_space, pds, r3, pmc_load_exc);
+		flddma(s_space, pds, r4, pmc_load_exc);
+		fstdma(d_space, r1, pdd, pmc_store_exc);
+		fstdma(d_space, r2, pdd, pmc_store_exc);
+		fstdma(d_space, r3, pdd, pmc_store_exc);
+		fstdma(d_space, r4, pdd, pmc_store_exc);
+
+#if 0
+		if (L1_CACHE_BYTES <= 32)
+			prefetch_src((char *)pds + L1_CACHE_BYTES);
+#endif
+		flddma(s_space, pds, r5, pmc_load_exc);
+		flddma(s_space, pds, r6, pmc_load_exc);
+		flddma(s_space, pds, r7, pmc_load_exc);
+		flddma(s_space, pds, r8, pmc_load_exc);
+		fstdma(d_space, r5, pdd, pmc_store_exc);
+		fstdma(d_space, r6, pdd, pmc_store_exc);
+		fstdma(d_space, r7, pdd, pmc_store_exc);
+		fstdma(d_space, r8, pdd, pmc_store_exc);
+		len -= 8*sizeof(double);
+	}
+
+	pws = (unsigned int *)pds;
+	pwd = (unsigned int *)pdd;
+
+word_copy:
+	while (len >= 8*sizeof(unsigned int)) {
+		register unsigned int r1,r2,r3,r4,r5,r6,r7,r8;
+		/* prefetch_src((char *)pws + L1_CACHE_BYTES); */
+		ldwma(s_space, pws, r1, pmc_load_exc);
+		ldwma(s_space, pws, r2, pmc_load_exc);
+		ldwma(s_space, pws, r3, pmc_load_exc);
+		ldwma(s_space, pws, r4, pmc_load_exc);
+		stwma(d_space, r1, pwd, pmc_store_exc);
+		stwma(d_space, r2, pwd, pmc_store_exc);
+		stwma(d_space, r3, pwd, pmc_store_exc);
+		stwma(d_space, r4, pwd, pmc_store_exc);
+
+		ldwma(s_space, pws, r5, pmc_load_exc);
+		ldwma(s_space, pws, r6, pmc_load_exc);
+		ldwma(s_space, pws, r7, pmc_load_exc);
+		ldwma(s_space, pws, r8, pmc_load_exc);
+		stwma(d_space, r5, pwd, pmc_store_exc);
+		stwma(d_space, r6, pwd, pmc_store_exc);
+		stwma(d_space, r7, pwd, pmc_store_exc);
+		stwma(d_space, r8, pwd, pmc_store_exc);
+		len -= 8*sizeof(unsigned int);
+	}
+
+	while (len >= 4*sizeof(unsigned int)) {
+		register unsigned int r1,r2,r3,r4;
+		ldwma(s_space, pws, r1, pmc_load_exc);
+		ldwma(s_space, pws, r2, pmc_load_exc);
+		ldwma(s_space, pws, r3, pmc_load_exc);
+		ldwma(s_space, pws, r4, pmc_load_exc);
+		stwma(d_space, r1, pwd, pmc_store_exc);
+		stwma(d_space, r2, pwd, pmc_store_exc);
+		stwma(d_space, r3, pwd, pmc_store_exc);
+		stwma(d_space, r4, pwd, pmc_store_exc);
+		len -= 4*sizeof(unsigned int);
+	}
+
+	pcs = (unsigned char *)pws;
+	pcd = (unsigned char *)pwd;
+
+byte_copy:
+	while (len) {
+		/* *pcd++ = *pcs++; */
+		ldbma(s_space, pcs, t3, pmc_load_exc);
+		stbma(d_space, t3, pcd, pmc_store_exc);
+		len--;
+	}
+
+	return 0;
+
+unaligned_copy:
+	/* possibly we are aligned on a word, but not on a double... */
+	if (likely(t1 & (sizeof(unsigned int)-1)) == 0) {
+		t2 = src & (sizeof(unsigned int) - 1);
+
+		if (unlikely(t2 != 0)) {
+			t2 = sizeof(unsigned int) - t2;
+			while (t2) {
+				/* *pcd++ = *pcs++; */
+				ldbma(s_space, pcs, t3, pmc_load_exc);
+				stbma(d_space, t3, pcd, pmc_store_exc);
+				len--;
+				t2--;
+			}
+		}
+
+		pws = (unsigned int *)pcs;
+		pwd = (unsigned int *)pcd;
+		goto word_copy;
+	}
+
+	/* Align the destination.  */
+	if (unlikely((dst & (sizeof(unsigned int) - 1)) != 0)) {
+		t2 = sizeof(unsigned int) - (dst & (sizeof(unsigned int) - 1));
+		while (t2) {
+			/* *pcd++ = *pcs++; */
+			ldbma(s_space, pcs, t3, pmc_load_exc);
+			stbma(d_space, t3, pcd, pmc_store_exc);
+			len--;
+			t2--;
+		}
+		dst = (unsigned long)pcd;
+		src = (unsigned long)pcs;
+	}
+
+	ret = copy_dstaligned(dst, src, len / sizeof(unsigned int), 
+		o_dst, o_src, o_len);
+	if (ret)
+		return ret;
+
+	pcs += (len & -sizeof(unsigned int));
+	pcd += (len & -sizeof(unsigned int));
+	len %= sizeof(unsigned int);
+
+	preserve_branch(handle_load_error);
+	preserve_branch(handle_store_error);
+
+	goto byte_copy;
+
+handle_load_error:
+	__asm__ __volatile__ ("pmc_load_exc:\n");
+	d = &__get_cpu_var(exception_data);
+	DPRINTF("pmc_load_exc: o_len=%lu fault_addr=%lu o_src=%lu ret=%lu\n",
+		o_len, d->fault_addr, o_src, o_len - d->fault_addr + o_src);
+	return o_len - d->fault_addr + o_src;
+
+handle_store_error:
+	__asm__ __volatile__ ("pmc_store_exc:\n");
+	d = &__get_cpu_var(exception_data);
+	DPRINTF("pmc_store_exc: o_len=%lu fault_addr=%lu o_dst=%lu ret=%lu\n",
+		o_len, d->fault_addr, o_dst, o_len - d->fault_addr + o_dst);
+	return o_len - d->fault_addr + o_dst;
+}
+
+#ifdef __KERNEL__
+unsigned long copy_to_user(void __user *dst, const void *src, unsigned long len)
+{
+	mtsp(get_kernel_space(), 1);
+	mtsp(get_user_space(), 2);
+	return pa_memcpy((void __force *)dst, src, len);
+}
+
+unsigned long copy_from_user(void *dst, const void __user *src, unsigned long len)
+{
+	mtsp(get_user_space(), 1);
+	mtsp(get_kernel_space(), 2);
+	return pa_memcpy(dst, (void __force *)src, len);
+}
+
+unsigned long copy_in_user(void __user *dst, const void __user *src, unsigned long len)
+{
+	mtsp(get_user_space(), 1);
+	mtsp(get_user_space(), 2);
+	return pa_memcpy((void __force *)dst, (void __force *)src, len);
+}
+
+
+void * memcpy(void * dst,const void *src, size_t count)
+{
+	mtsp(get_kernel_space(), 1);
+	mtsp(get_kernel_space(), 2);
+	pa_memcpy(dst, src, count);
+	return dst;
+}
+
+void bcopy(const void * srcp, void * destp, size_t count)
+{
+	mtsp(get_kernel_space(), 1);
+	mtsp(get_kernel_space(), 2);
+	pa_memcpy(destp, srcp, count);
+}
+
+EXPORT_SYMBOL(copy_to_user);
+EXPORT_SYMBOL(copy_from_user);
+EXPORT_SYMBOL(copy_in_user);
+EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(bcopy);
+#endif
diff -Nru a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
--- a/arch/parisc/mm/fault.c	2004-12-24 13:37:19 -08:00
+++ b/arch/parisc/mm/fault.c	2004-12-24 13:37:19 -08:00
@@ -36,6 +36,9 @@
 
 #define BITSSET		0x1c0	/* for identifying LDCW */
 
+
+DEFINE_PER_CPU(struct exception_data, exception_data);
+
 /*
  * parisc_acctyp(unsigned int inst) --
  *    Given a PA-RISC memory access instruction, determine if the
@@ -230,17 +233,17 @@
 no_context:
 
 	if (!user_mode(regs)) {
-
 		fix = search_exception_tables(regs->iaoq[0]);
 
 		if (fix) {
+			struct exception_data *d;
 
-			if (fix->skip & 1) 
-				regs->gr[8] = -EFAULT;
-			if (fix->skip & 2)
-				regs->gr[9] = 0;
+			d = &__get_cpu_var(exception_data);
+			d->fault_ip = regs->iaoq[0];
+			d->fault_space = regs->isr;
+			d->fault_addr = regs->ior;
 
-			regs->iaoq[0] += ((fix->skip) & ~3);
+			regs->iaoq[0] = ((fix->fixup) & ~3);
 
 			/*
 			 * NOTE: In some cases the faulting instruction
diff -Nru a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
--- a/arch/parisc/mm/init.c	2004-12-24 13:36:49 -08:00
+++ b/arch/parisc/mm/init.c	2004-12-24 13:36:49 -08:00
@@ -20,6 +20,7 @@
 #include <linux/initrd.h>
 #include <linux/swap.h>
 #include <linux/unistd.h>
+#include <linux/nodemask.h>	/* for node_online_map */
 
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
@@ -750,7 +751,7 @@
 #if PTRS_PER_PMD == 1
 	pmd = (pmd_t *)__pa(pg_dir);
 #else
-	pmd = (pmd_t *) (PAGE_MASK & pgd_val(*pg_dir));
+	pmd = (pmd_t *) pgd_address(*pg_dir);
 
 	/*
 	 * pmd is physical at this point
@@ -761,7 +762,7 @@
 		pmd = (pmd_t *) __pa(pmd);
 	}
 
-	pgd_val(*pg_dir) = _PAGE_TABLE | (unsigned long) pmd;
+	__pgd_val_set(*pg_dir, PxD_FLAG_PRESENT | PxD_FLAG_VALID | (unsigned long) pmd);
 #endif
 	/* now change pmd to kernel virtual addresses */
 
@@ -771,11 +772,11 @@
 	 * pg_table is physical at this point
 	 */
 
-	pg_table = (pte_t *) (PAGE_MASK & pmd_val(*pmd));
+	pg_table = (pte_t *) pmd_address(*pmd);
 	if (!pg_table)
 		pg_table = (pte_t *) __pa(get_zeroed_page(GFP_KERNEL));
 
-	pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) pg_table;
+	__pmd_val_set(*pmd, PxD_FLAG_PRESENT | PxD_FLAG_VALID | (unsigned long) pg_table);
 
 	/* now change pg_table to kernel virtual addresses */
 
@@ -804,19 +805,21 @@
 		   ZONE_DMA zone. */
 		zones_size[ZONE_DMA] = pmem_ranges[i].pages;
 
-		free_area_init_node(i, NODE_DATA(i), zones_size,
-				pmem_ranges[i].start_pfn, 0);
-
 #ifdef CONFIG_DISCONTIGMEM
+		/* Need to initialize the pfnnid_map before we can initialize
+		   the zone */
 		{
 		    int j;
-		    for (j = (node_start_pfn(i) >> PFNNID_SHIFT);
-			 j <= (node_end_pfn(i) >> PFNNID_SHIFT);
+		    for (j = (pmem_ranges[i].start_pfn >> PFNNID_SHIFT);
+			 j <= ((pmem_ranges[i].start_pfn + pmem_ranges[i].pages) >> PFNNID_SHIFT);
 			 j++) {
 			pfnnid_map[j] = i;
 		    }
 		}
 #endif
+
+		free_area_init_node(i, NODE_DATA(i), zones_size,
+				pmem_ranges[i].start_pfn, NULL);
 	}
 }
 
diff -Nru a/arch/ppc/4xx_io/serial_sicc.c b/arch/ppc/4xx_io/serial_sicc.c
--- a/arch/ppc/4xx_io/serial_sicc.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc/4xx_io/serial_sicc.c	2004-12-24 13:36:17 -08:00
@@ -51,12 +51,12 @@
 #include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/serial.h>
 
 
@@ -933,7 +933,7 @@
     restore_flags(flags);
 }
 
-static int siccuart_write(struct tty_struct *tty, int from_user,
+static int siccuart_write(struct tty_struct *tty,
               const u_char * buf, int count)
 {
     struct SICC_info *info = tty->driver_data;
@@ -944,58 +944,23 @@
         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,
-                          SICC_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,
-                           SICC_XMIT_SIZE);
-            if (c1 < c)
-                c = c1;
-            memcpy(info->xmit.buf + info->xmit.head, tmp_buf, c);
-            info->xmit.head = (info->xmit.head + c) &
-                      (SICC_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,
-                          SICC_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) &
-                      (SICC_XMIT_SIZE - 1);
-            buf += c;
-            count -= c;
-            ret += c;
-        }
-        restore_flags(flags);
+    cli();
+    while (1) {
+        c = CIRC_SPACE_TO_END(info->xmit.head,
+                      info->xmit.tail,
+                      SICC_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) &
+                  (SICC_XMIT_SIZE - 1);
+        buf += c;
+        count -= c;
+        ret += c;
     }
+    restore_flags(flags);
     if (info->xmit.head != info->xmit.tail
         && !tty->stopped
         && !tty->hw_stopped)
diff -Nru a/arch/ppc/8260_io/enet.c b/arch/ppc/8260_io/enet.c
--- a/arch/ppc/8260_io/enet.c	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc/8260_io/enet.c	2004-12-24 13:36:16 -08:00
@@ -39,11 +39,11 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 
 #include <asm/immap_cpm2.h>
 #include <asm/pgtable.h>
 #include <asm/mpc8260.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/cpm2.h>
 #include <asm/irq.h>
diff -Nru a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c
--- a/arch/ppc/8260_io/fcc_enet.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc/8260_io/fcc_enet.c	2004-12-24 13:36:48 -08:00
@@ -34,12 +34,12 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 
 #include <asm/immap_cpm2.h>
 #include <asm/pgtable.h>
 #include <asm/mpc8260.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/cpm2.h>
 
diff -Nru a/arch/ppc/8xx_io/Kconfig b/arch/ppc/8xx_io/Kconfig
--- a/arch/ppc/8xx_io/Kconfig	2004-12-24 13:37:00 -08:00
+++ b/arch/ppc/8xx_io/Kconfig	2004-12-24 13:37:00 -08:00
@@ -74,37 +74,6 @@
 	  Allocate large buffers for MPC8xx Etherenet.  Increases throughput
 	  and decreases the likelihood of dropped packets, but costs memory.
 
-config SMC2_UART
-	bool "Use SMC2 for UART"
-	help
-	  If you would like to use SMC2 as a serial port, say Y here.
-
-	  If in doubt, say Y here.
-
-config ALTSMC2
-	bool "Use Alternate SMC2 I/O (823/850)"
-	depends on SMC2_UART
-	help
-	  If you have an MPC823 or MPC850 and would like to use the alternate
-	  SMC2 for I/O, say Y here.
-
-	  If in doubt, say N here.
-
-config CONS_SMC2
-	bool "Use SMC2 for Console"
-	depends on SMC2_UART
-	help
-	  If you are going to have a serial console on your device and are
-	  using SMC2 for your serial port, say Y here, else say N.
-
-config USE_SCC_IO
-	bool "Enable SCC2 and SCC3 for UART"
-	help
-	  If your MPC8xx board has other SCC ports that you would like to use
-	  for for a serial port, say Y here.
-
-	  If in doubt, say N here.
-
 config HTDMSOUND
 	bool "Embedded Planet HIOX Audio"
 	depends on SOUND=y
@@ -134,13 +103,36 @@
 
 	  If in doubt, say N here.
 
-config UCODE_PATCH
-	bool "I2C/SPI Microcode Patch"
+choice
+	prompt "Microcode patch selection"
+	default NO_UCODE_PATCH
+	help
+	  Help not implemented yet, coming soon.
+
+config NO_UCODE_PATCH
+	bool "None"
+
+config USB_SOF_UCODE_PATCH
+	bool "USB SOF patch"
+	help
+	  Help not implemented yet, coming soon.
+
+config I2C_SPI_UCODE_PATCH
+	bool "I2C/SPI relocation patch"
+	help
+	  Help not implemented yet, coming soon.
+
+config I2C_SPI_SMC1_UCODE_PATCH
+	bool "I2C/SPI/SMC1 relocation patch"
 	help
-	  Motorola releases microcode updates for their 8xx CPM modules.  The
-	  microcode update file has updates for IIC, SMC and USB.  Currently only
-	  the USB update is available by default, if the MPC8xx USB option is
-	  enabled.  If in doubt, say 'N' here.
+	  Help not implemented yet, coming soon.
+
+endchoice
+
+config UCODE_PATCH
+	bool
+	default y
+	depends on !NO_UCODE_PATCH
 
 endmenu
 
diff -Nru a/arch/ppc/8xx_io/Makefile b/arch/ppc/8xx_io/Makefile
--- a/arch/ppc/8xx_io/Makefile	2004-12-24 13:37:30 -08:00
+++ b/arch/ppc/8xx_io/Makefile	2004-12-24 13:37:30 -08:00
@@ -2,7 +2,7 @@
 # Makefile for the linux MPC8xx ppc-specific parts of comm processor
 #
 
-obj-y			:= commproc.o uart.o
+obj-y			:= commproc.o
 
 obj-$(CONFIG_FEC_ENET)	+= fec.o
 obj-$(CONFIG_SCC_ENET)	+= enet.o
diff -Nru a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c
--- a/arch/ppc/8xx_io/commproc.c	2004-12-24 13:36:56 -08:00
+++ b/arch/ppc/8xx_io/commproc.c	2004-12-24 13:36:56 -08:00
@@ -23,18 +23,20 @@
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
+#include <linux/dma-mapping.h>
 #include <linux/param.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/module.h>
-#include <asm/irq.h>
 #include <asm/mpc8xx.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/8xx_immap.h>
 #include <asm/commproc.h>
 #include <asm/io.h>
+#include <asm/tlbflush.h>
 #include <asm/rheap.h>
 
 extern int get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep);
@@ -51,68 +53,69 @@
 	void	*dev_id;
 };
 static	struct	cpm_action cpm_vecs[CPMVEC_NR];
-static	void	cpm_interrupt(int irq, void * dev, struct pt_regs * regs);
-static	void	cpm_error_interrupt(void *, struct pt_regs * regs);
+static	irqreturn_t cpm_interrupt(int irq, void * dev, struct pt_regs * regs);
+static	irqreturn_t cpm_error_interrupt(int irq, void *dev, struct pt_regs * regs);
 static	void	alloc_host_memory(void);
+/* Define a table of names to identify CPM interrupt handlers in
+ * /proc/interrupts.
+ */
+const char *cpm_int_name[] =
+	{ "error",	"PC4",		"PC5",		"SMC2",
+	  "SMC1",	"SPI",		"PC6",		"Timer 4",
+	  "",		"PC7",		"PC8",		"PC9",
+	  "Timer 3",	"",		"PC10",		"PC11",
+	  "I2C",	"RISC Timer",	"Timer 2",	"",
+	  "IDMA2",	"IDMA1",	"SDMA error",	"PC12",
+	  "PC13",	"Timer 1",	"PC14",		"SCC4",
+	  "SCC3",	"SCC2",		"SCC1",		"PC15"
+	};
 
-#if 1
-void
-m8xx_cpm_reset(void)
+static void
+cpm_mask_irq(unsigned int irq)
 {
-	volatile immap_t	 *imp;
-	volatile cpm8xx_t	*commproc;
-
-	imp = (immap_t *)IMAP_ADDR;
-	commproc = (cpm8xx_t *)&imp->im_cpm;
-
-#ifdef CONFIG_UCODE_PATCH
-	/* Perform a reset.
-	*/
-	commproc->cp_cpcr = (CPM_CR_RST | CPM_CR_FLG);
-
-	/* Wait for it.
-	*/
-	while (commproc->cp_cpcr & CPM_CR_FLG);
+	int cpm_vec = irq - CPM_IRQ_OFFSET;
 
-	cpm_load_patch(imp);
-#endif
+	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr &= ~(1 << cpm_vec);
+}
 
-	/* Set SDMA Bus Request priority 5.
-	 * On 860T, this also enables FEC priority 6.  I am not sure
-	 * this is what we realy want for some applications, but the
-	 * manual recommends it.
-	 * Bit 25, FAM can also be set to use FEC aggressive mode (860T).
-	 */
-	imp->im_siu_conf.sc_sdcr = 1;
+static void
+cpm_unmask_irq(unsigned int irq)
+{
+	int cpm_vec = irq - CPM_IRQ_OFFSET;
 
-	/* Reclaim the DP memory for our use. */
-	m8xx_cpm_dpinit();
+	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr |= (1 << cpm_vec);
+}
 
-	/* Tell everyone where the comm processor resides.
-	*/
-	cpmp = (cpm8xx_t *)commproc;
+static void
+cpm_ack(unsigned int irq)
+{
+	/* We do not need to do anything here. */
 }
 
-/* We used to do this earlier, but have to postpone as long as possible
- * to ensure the kernel VM is now running.
- */
 static void
-alloc_host_memory()
+cpm_eoi(unsigned int irq)
 {
-	uint	physaddr;
+	int cpm_vec = irq - CPM_IRQ_OFFSET;
 
-	/* Set the host page for allocation.
-	*/
-	host_buffer = (uint)consistent_alloc(GFP_KERNEL, PAGE_SIZE, &physaddr);
-	host_end = host_buffer + PAGE_SIZE;
+	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cisr = (1 << cpm_vec);
 }
-#else
+
+struct hw_interrupt_type cpm_pic = {
+	.typename	= " CPM      ",
+	.enable		= cpm_unmask_irq,
+	.disable	= cpm_mask_irq,
+	.ack		= cpm_ack,
+	.end		= cpm_eoi,
+};
+
+extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
+
 void
-m8xx_cpm_reset(uint host_page_addr)
+m8xx_cpm_reset(uint bootpage)
 {
 	volatile immap_t	 *imp;
 	volatile cpm8xx_t	*commproc;
-	pte_t			*pte;
+	pte_t *pte;
 
 	imp = (immap_t *)IMAP_ADDR;
 	commproc = (cpm8xx_t *)&imp->im_cpm;
@@ -134,40 +137,61 @@
 	 * this is what we realy want for some applications, but the
 	 * manual recommends it.
 	 * Bit 25, FAM can also be set to use FEC aggressive mode (860T).
-	*/
+	 */
 	imp->im_siu_conf.sc_sdcr = 1;
 
 	/* Reclaim the DP memory for our use. */
 	m8xx_cpm_dpinit();
 
-	/* Set the host page for allocation.
-	*/
-	host_buffer = host_page_addr;	/* Host virtual page address */
-	host_end = host_page_addr + PAGE_SIZE;
+	/* get the PTE for the bootpage */
+	if (!get_pteptr(&init_mm, bootpage, &pte))
+	       panic("get_pteptr failed\n");
+																							
+	/* and make it uncachable */
+	pte_val(*pte) |= _PAGE_NO_CACHE;
+	_tlbie(bootpage);
 
-	/* We need to get this page early, so I have to do it the
-	 * hard way.
-	 */
-	if (get_pteptr(&init_mm, host_page_addr, &pte)) {
-		pte_val(*pte) |= _PAGE_NO_CACHE;
-		flush_tlb_page(init_mm.mmap, host_buffer);
-	}
-	else {
-		panic("Huh?  No CPM host page?");
-	}
+	host_buffer = bootpage;
+	host_end = host_buffer + PAGE_SIZE;
 
 	/* Tell everyone where the comm processor resides.
 	*/
 	cpmp = (cpm8xx_t *)commproc;
 }
-#endif
+
+/* We used to do this earlier, but have to postpone as long as possible
+ * to ensure the kernel VM is now running.
+ */
+static void
+alloc_host_memory(void)
+{
+	dma_addr_t	physaddr;
+
+	/* Set the host page for allocation.
+	*/
+	host_buffer = (uint)dma_alloc_coherent(NULL, PAGE_SIZE, &physaddr,
+			GFP_KERNEL);
+	host_end = host_buffer + PAGE_SIZE;
+}
 
 /* This is called during init_IRQ.  We used to do it above, but this
  * was too early since init_IRQ was not yet called.
  */
+static struct irqaction cpm_error_irqaction = {
+	.handler = cpm_error_interrupt,
+	.mask = CPU_MASK_NONE,
+};
+static struct irqaction cpm_interrupt_irqaction = {
+	.handler = cpm_interrupt,
+	.mask = CPU_MASK_NONE,
+	.name = "CPM cascade",
+};
+
 void
 cpm_interrupt_init(void)
 {
+	int i;
+
 	/* Initialize the CPM interrupt controller.
 	*/
 	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr =
@@ -175,41 +199,52 @@
 		((CPM_INTERRUPT/2) << 13) | CICR_HP_MASK;
 	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr = 0;
 
-	/* Set our interrupt handler with the core CPU.
-	*/
-	if (request_8xxirq(CPM_INTERRUPT, cpm_interrupt, 0, "cpm", NULL) != 0)
+        /* install the CPM interrupt controller routines for the CPM
+         * interrupt vectors
+         */
+        for ( i = CPM_IRQ_OFFSET ; i < CPM_IRQ_OFFSET + NR_CPM_INTS ; i++ )
+                irq_desc[i].handler = &cpm_pic;
+
+	/* Set our interrupt handler with the core CPU.	*/
+	if (setup_irq(CPM_INTERRUPT, &cpm_interrupt_irqaction))
 		panic("Could not allocate CPM IRQ!");
 
-	/* Install our own error handler.
-	*/
-	cpm_install_handler(CPMVEC_ERROR, cpm_error_interrupt, NULL);
+	/* Install our own error handler. */
+	cpm_error_irqaction.name = cpm_int_name[CPMVEC_ERROR];
+	if (setup_irq(CPM_IRQ_OFFSET + CPMVEC_ERROR, &cpm_error_irqaction))
+		panic("Could not allocate CPM error IRQ!");
+
 	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr |= CICR_IEN;
 }
 
-/* CPM interrupt controller interrupt.
-*/
-static	void
-cpm_interrupt(int irq, void * dev, struct pt_regs * regs)
+/*
+ * Get the CPM interrupt vector.
+ */
+int
+cpm_get_irq(struct pt_regs *regs)
 {
-	uint	vec;
+	int cpm_vec;
 
 	/* Get the vector by setting the ACK bit and then reading
 	 * the register.
 	 */
 	((volatile immap_t *)IMAP_ADDR)->im_cpic.cpic_civr = 1;
-	vec = ((volatile immap_t *)IMAP_ADDR)->im_cpic.cpic_civr;
-	vec >>= 11;
+	cpm_vec = ((volatile immap_t *)IMAP_ADDR)->im_cpic.cpic_civr;
+	cpm_vec >>= 11;
 
-	if (cpm_vecs[vec].handler != 0)
-		(*cpm_vecs[vec].handler)(cpm_vecs[vec].dev_id, regs);
-	else
-		((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr &= ~(1 << vec);
+	return cpm_vec;
+}
 
-	/* After servicing the interrupt, we have to remove the status
-	 * indicator.
+/* CPM interrupt controller cascade interrupt.
+*/
+static	irqreturn_t
+cpm_interrupt(int irq, void * dev, struct pt_regs * regs)
+{
+	/* This interrupt handler never actually gets called.  It is
+	 * installed only to unmask the CPM cascade interrupt in the SIU
+	 * and to make the CPM cascade interrupt visible in /proc/interrupts.
 	 */
-	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cisr = (1 << vec);
-	
+	return IRQ_HANDLED;
 }
 
 /* The CPM can generate the error interrupt when there is a race condition
@@ -217,41 +252,73 @@
  * and return.  This is a no-op function so we don't need any special
  * tests in the interrupt handler.
  */
-static	void
-cpm_error_interrupt(void *dev, struct pt_regs *regs)
+static	irqreturn_t
+cpm_error_interrupt(int irq, void *dev, struct pt_regs *regs)
 {
+	return IRQ_HANDLED;
+}
+
+/* A helper function to translate the handler prototype required by
+ * request_irq() to the handler prototype required by cpm_install_handler().
+ */
+static irqreturn_t
+cpm_handler_helper(int irq, void *dev_id, struct pt_regs *regs)
+{
+	int cpm_vec = irq - CPM_IRQ_OFFSET;
+
+	(*cpm_vecs[cpm_vec].handler)(dev_id, regs);
+
+	return IRQ_HANDLED;
 }
 
 /* Install a CPM interrupt handler.
-*/
+ * This routine accepts a CPM interrupt vector in the range 0 to 31.
+ * This routine is retained for backward compatibility.  Rather than using
+ * this routine to install a CPM interrupt handler, you can now use
+ * request_irq() with an IRQ in the range CPM_IRQ_OFFSET to
+ * CPM_IRQ_OFFSET + NR_CPM_INTS - 1 (16 to 47).
+ *
+ * Notice that the prototype of the interrupt handler function must be
+ * different depending on whether you install the handler with
+ * request_irq() or cpm_install_handler().
+ */
 void
-cpm_install_handler(int vec, void (*handler)(void *, struct pt_regs *regs),
+cpm_install_handler(int cpm_vec, void (*handler)(void *, struct pt_regs *regs),
 		    void *dev_id)
 {
+	int err;
 
 	/* If null handler, assume we are trying to free the IRQ.
 	*/
 	if (!handler) {
-		cpm_free_handler(vec);
+		free_irq(CPM_IRQ_OFFSET + cpm_vec, dev_id);
 		return;
 	}
 
-	if (cpm_vecs[vec].handler != 0)
-		printk("CPM interrupt %x replacing %x\n",
-			(uint)handler, (uint)cpm_vecs[vec].handler);
-	cpm_vecs[vec].handler = handler;
-	cpm_vecs[vec].dev_id = dev_id;
-	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr |= (1 << vec);
+	if (cpm_vecs[cpm_vec].handler != 0)
+		printk(KERN_INFO "CPM interrupt %x replacing %x\n",
+			(uint)handler, (uint)cpm_vecs[cpm_vec].handler);
+	cpm_vecs[cpm_vec].handler = handler;
+	cpm_vecs[cpm_vec].dev_id = dev_id;
+
+	if ((err = request_irq(CPM_IRQ_OFFSET + cpm_vec, cpm_handler_helper,
+					0, cpm_int_name[cpm_vec], dev_id)))
+		printk(KERN_ERR "request_irq() returned %d for CPM vector %d\n",
+				err, cpm_vec);
 }
 
 /* Free a CPM interrupt handler.
-*/
+ * This routine accepts a CPM interrupt vector in the range 0 to 31.
+ * This routine is retained for backward compatibility.
+ */
 void
-cpm_free_handler(int vec)
+cpm_free_handler(int cpm_vec)
 {
-	cpm_vecs[vec].handler = NULL;
-	cpm_vecs[vec].dev_id = NULL;
-	((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr &= ~(1 << vec);
+	request_irq(CPM_IRQ_OFFSET + cpm_vec, NULL, 0, 0,
+		cpm_vecs[cpm_vec].dev_id);
+
+	cpm_vecs[cpm_vec].handler = NULL;
+	cpm_vecs[cpm_vec].dev_id = NULL;
 }
 
 /* We also own one page of host buffer space for the allocation of
@@ -262,10 +329,8 @@
 {
 	uint	retloc;
 
-#if 1
 	if (host_buffer == 0)
 		alloc_host_memory();
-#endif
 
 	if ((host_buffer + size) >= host_end)
 		return(0);
diff -Nru a/arch/ppc/8xx_io/enet.c b/arch/ppc/8xx_io/enet.c
--- a/arch/ppc/8xx_io/enet.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc/8xx_io/enet.c	2004-12-24 13:36:31 -08:00
@@ -38,11 +38,12 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
+#include <linux/dma-mapping.h>
+#include <linux/bitops.h>
 
 #include <asm/8xx_immap.h>
 #include <asm/pgtable.h>
 #include <asm/mpc8xx.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/commproc.h>
 
@@ -581,10 +582,10 @@
 	
 		/* Log any net taps. */
 		printk("%s: Promiscuous mode enabled.\n", dev->name);
-		cep->sccp->scc_pmsr |= SCC_PMSR_PRO;
+		cep->sccp->scc_psmr |= SCC_PSMR_PRO;
 	} else {
 
-		cep->sccp->scc_pmsr &= ~SCC_PMSR_PRO;
+		cep->sccp->scc_psmr &= ~SCC_PSMR_PRO;
 
 		if (dev->flags & IFF_ALLMULTI) {
 			/* Catch all multicast addresses, so set the
@@ -835,7 +836,8 @@
 
 		/* Allocate a page.
 		*/
-		ba = (unsigned char *)consistent_alloc(GFP_KERNEL, PAGE_SIZE, &mem_addr);
+		ba = (unsigned char *)dma_alloc_coherent(NULL, PAGE_SIZE,
+				&mem_addr, GFP_KERNEL);
 		/* BUG: no check for failure */
 
 		/* Initialize the BD for every fragment in the page.
@@ -889,7 +891,7 @@
 	/* Set processing mode.  Use Ethernet CRC, catch broadcast, and
 	 * start frame search 22 bit times after RENA.
 	 */
-	sccp->scc_pmsr = (SCC_PMSR_ENCRC | SCC_PMSR_NIB22);
+	sccp->scc_psmr = (SCC_PSMR_ENCRC | SCC_PSMR_NIB22);
 
 	/* It is now OK to enable the Ethernet transmitter.
 	 * Unfortunately, there are board implementation differences here.
diff -Nru a/arch/ppc/8xx_io/fec.c b/arch/ppc/8xx_io/fec.c
--- a/arch/ppc/8xx_io/fec.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc/8xx_io/fec.c	2004-12-24 13:37:29 -08:00
@@ -44,6 +44,7 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 #ifdef CONFIG_FEC_PACKETHOOK
 #include <linux/pkthook.h>
 #endif
@@ -52,7 +53,6 @@
 #include <asm/pgtable.h>
 #include <asm/mpc8xx.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/commproc.h>
 
@@ -1684,7 +1684,7 @@
 
 	/* Install our interrupt handler.
 	*/
-	if (request_8xxirq(FEC_INTERRUPT, fec_enet_interrupt, 0, "fec", dev) != 0)
+	if (request_irq(FEC_INTERRUPT, fec_enet_interrupt, 0, "fec", dev) != 0)
 		panic("Could not allocate FEC IRQ!");
 
 #ifdef CONFIG_RPXCLASSIC
@@ -1705,7 +1705,7 @@
 	((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel |=
 		(0x80000000 >> PHY_INTERRUPT);
 
-	if (request_8xxirq(PHY_INTERRUPT, mii_link_interrupt, 0, "mii", dev) != 0)
+	if (request_irq(PHY_INTERRUPT, mii_link_interrupt, 0, "mii", dev) != 0)
 		panic("Could not allocate MII IRQ!");
 #endif
 
diff -Nru a/arch/ppc/8xx_io/micropatch.c b/arch/ppc/8xx_io/micropatch.c
--- a/arch/ppc/8xx_io/micropatch.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc/8xx_io/micropatch.c	2004-12-24 13:37:29 -08:00
@@ -19,18 +19,12 @@
 #include <asm/8xx_immap.h>
 #include <asm/commproc.h>
 
-/* Define this to get SMC patches as well.  You need to modify the uart
- * driver as well......
-#define USE_SMC_PATCH 1
+/*
+ * I2C/SPI relocation patch arrays.
  */
 
-#ifdef CONFIG_USB_MPC8xx
-#define USE_USB_SOF_PATCH
-#endif
+#ifdef CONFIG_I2C_SPI_UCODE_PATCH
 
-#ifdef USE_IIC_PATCH
-#define PATCH_DEFINED
-	/* IIC/SPI */
 uint patch_2000[] = {
 	0x7FFFEFD9,
 	0x3FFD0000,
@@ -183,11 +177,12 @@
 };
 #endif
 
-#ifdef USE_SMC_PATCH
-#define PATCH_DEFINED
-/* SMC2/IIC/SPI Patch */
-/* This is the area from 0x2000 to 0x23ff.
-*/
+/*
+ * I2C/SPI/SMC1 relocation patch arrays.
+ */
+
+#ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
+
 uint patch_2000[] = {
 	0x3fff0000,
 	0x3ffd0000,
@@ -511,8 +506,6 @@
 	0x6079e2bb
 };
 
-	/* This is from 0x2f00 to 0x2fff
-	*/
 uint patch_2f00[] = {
 	0x30303030,
 	0x3e3e3434,
@@ -581,8 +574,6 @@
 };
 
 uint patch_2e00[] = {
-	/* This is from 0x2e00 to 0x2e3c
-	*/
 	0x27eeeeee,
 	0xeeeeeeee,
 	0xeeeeeeee,
@@ -602,8 +593,12 @@
 };
 #endif
 
-#ifdef USE_USB_SOF_PATCH
-#define PATCH_DEFINED
+/*
+ *  USB SOF patch arrays.
+ */
+
+#ifdef CONFIG_USB_SOF_UCODE_PATCH
+
 uint patch_2000[] = {
 	0x7fff0000,
 	0x7ffd0000,
@@ -626,33 +621,21 @@
 };
 #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 uint		*dp;		/* Dual-ported RAM. */
 	volatile cpm8xx_t	*commproc;
 	volatile iic_t		*iip;
 	volatile spi_t		*spp;
+	volatile smc_uart_t	*smp;
 	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.
-	 */
+#ifdef CONFIG_USB_SOF_UCODE_PATCH
 	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];
@@ -661,29 +644,26 @@
 	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;
+	commproc->cp_rccr = 0x0009;
 
-	/* 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
+	printk("USB SOF microcode patch installed\n");
+#endif /* CONFIG_USB_SOF_UCODE_PATCH */
 
-	/* Enable uCode fetches from DPRAM. */
-	commproc->cp_rccr = 0x0009;
+#if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
+    defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
+
+	commproc->cp_rccr = 0;
 
-	printk("USB uCode patch installed\n");
-#endif /* USE_USB_SOF_PATCH */
+	dp = (uint *)(commproc->cp_dpmem);
+	for (i=0; i<(sizeof(patch_2000)/4); i++)
+		*dp++ = patch_2000[i];
 
-#if defined(USE_SMC_PATCH) || defined(USE_IIC_PATCH)
+	dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
+	for (i=0; i<(sizeof(patch_2f00)/4); i++)
+		*dp++ = patch_2f00[i];
 
 	iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC];
-#define RPBASE 0x0400
+# define RPBASE 0x0500
 	iip->iic_rpbase = RPBASE;
 
 	/* Put SPI above the IIC, also 32-byte aligned.
@@ -692,58 +672,46 @@
 	spp = (spi_t *)&commproc->cp_dparam[PROFF_SPI];
 	spp->spi_rpbase = i;
 
-#ifdef USE_SMC_PATCH
+# if defined(CONFIG_I2C_SPI_UCODE_PATCH)
+	commproc->cp_cpmcr1 = 0x802a;
+	commproc->cp_cpmcr2 = 0x8028;
+	commproc->cp_cpmcr3 = 0x802e;
+	commproc->cp_cpmcr4 = 0x802c;
+	commproc->cp_rccr = 1;
+
+	printk("I2C/SPI microcode patch installed.\n");
+# endif /* CONFIG_I2C_SPI_UCODE_PATCH */
+
+# if defined(CONFIG_I2C_SPI_SMC1_UCODE_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
+	smp = (smc_uart_t *)&commproc->cp_dparam[PROFF_SMC1];
+	smp->smc_rpbase = 0x1FC0;
 
-	/* 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;
+	printk("I2C/SPI/SMC1 microcode patch installed.\n");
+# endif /* CONFIG_I2C_SPI_SMC1_UCODE_PATCH) */
 
-#endif /* USE_SMC_PATCH || USE_IIC_PATCH */
-#endif /* PATCH_DEFINED */
+#endif /* some variation of the I2C/SPI patch was selected */
 }
 
+/*
+ *  Take this entire routine out, since no one calls it and its 
+ * logic is suspect.
+ */
+
+#if 0
 void
 verify_patch(volatile immap_t *immr)
 {
-#ifdef PATCH_DEFINED
 	volatile uint		*dp;
 	volatile cpm8xx_t	*commproc;
 	int i;
@@ -772,6 +740,5 @@
 		}
 
 	commproc->cp_rccr = 0x0009;
-#endif /* PATCH_DEFINED */
 }
-
+#endif
diff -Nru a/arch/ppc/8xx_io/uart.c b/arch/ppc/8xx_io/uart.c
--- a/arch/ppc/8xx_io/uart.c	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,3012 +0,0 @@
-/*
- *  UART driver for MPC860 CPM SCC or SMC
- *  Copyright (c) 1997 Dan Malek (dmalek@jlc.net)
- *
- * I used the serial.c driver as the framework for this driver.
- * Give credit to those guys.
- * The original code was written for the MBX860 board.  I tried to make
- * it generic, but there may be some assumptions in the structures that
- * have to be fixed later.
- * To save porting time, I did not bother to change any object names
- * that are not accessed outside of this file.
- * It still needs lots of work........When it was easy, I included code
- * to support the SCCs, but this has never been tested, nor is it complete.
- * Only the SCCs support modem control, so that is not complete either.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#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/serial.h>
-#include <linux/serialP.h>
-#include <linux/major.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/ptrace.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <asm/uaccess.h>
-#include <asm/8xx_immap.h>
-#include <asm/mpc8xx.h>
-#include <asm/commproc.h>
-#ifdef CONFIG_MAGIC_SYSRQ
-#include <linux/sysrq.h>
-#endif
-
-#ifdef CONFIG_KGDB
-#include <asm/kgdb.h>
-#endif
-
-#ifdef CONFIG_SERIAL_CONSOLE
-#include <linux/console.h>
-
-/* this defines the index into rs_table for the port to use
-*/
-# ifndef CONFIG_SERIAL_CONSOLE_PORT
-#  ifdef CONFIG_SCC3_ENET
-#   ifdef CONFIG_CONS_SMC2
-#    define CONFIG_SERIAL_CONSOLE_PORT	0	/* Console on SMC2 is 1st port */
-#   else
-#    error "Can't use SMC1 for console with Ethernet on SCC3"
-#   endif
-#  else	/* ! CONFIG_SCC3_ENET */
-#   ifdef CONFIG_CONS_SMC2			/* Console on SMC2 */
-#    define CONFIG_SERIAL_CONSOLE_PORT	1
-#   else					/* Console on SMC1 */
-#    define CONFIG_SERIAL_CONSOLE_PORT	0
-#   endif /* CONFIG_CONS_SMC2 */
-#  endif  /* CONFIG_SCC3_ENET */
-# endif	  /* CONFIG_SERIAL_CONSOLE_PORT */
-#endif	  /* CONFIG_SERIAL_CONSOLE */
-
-#if 0
-/* SCC2 for console
-*/
-#undef CONFIG_SERIAL_CONSOLE_PORT
-#define CONFIG_SERIAL_CONSOLE_PORT	2
-#endif
-
-#define TX_WAKEUP	ASYNC_SHARE_IRQ
-
-static char *serial_name = "CPM UART driver";
-static char *serial_version = "0.03";
-
-static DECLARE_TASK_QUEUE(tq_serial);
-
-static struct tty_driver *serial_driver;
-static int serial_console_setup(struct console *co, char *options);
-
-static void serial_console_write(struct console *c, const char *s,
-				unsigned count);
-static struct tty_driver *serial_console_device(struct console *c, int *index)
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-static unsigned long break_pressed; /* break, really ... */
-#endif
-
-/*
- * Serial driver configuration section.  Here are the various options:
- */
-#define 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
-
-#define _INLINE_ inline
-
-#define DBG_CNT(s)
-
-/* We overload some of the items in the data structure to meet our
- * needs.  For example, the port address is the CPM parameter ram
- * offset for the SCC or SMC.  The maximum number of ports is 4 SCCs and
- * 2 SMCs.  The "hub6" field is used to indicate the channel number, with
- * a flag indicating SCC or SMC, and the number is used as an index into
- * the CPM parameter area for this device.
- * The "type" field is currently set to 0, for PORT_UNKNOWN.  It is
- * not currently used.  I should probably use it to indicate the port
- * type of SMC or SCC.
- * The SMCs do not support any modem control signals.
- */
-#define smc_scc_num	hub6
-#define NUM_IS_SCC	((int)0x00010000)
-#define PORT_NUM(P)	((P) & 0x0000ffff)
-
-/* The choice of serial port to use for KGDB.  If the system has
- * two ports, you can use one for console and one for KGDB (which
- * doesn't make sense to me, but people asked for it).
- */
-#ifdef CONFIG_KGDB_TTYS1
-#define KGDB_SER_IDX 1		/* SCC2/SMC2 */
-#else
-#define KGDB_SER_IDX 0		/* SCC1/SMC1 */
-#endif
-
-/* Processors other than the 860 only get SMCs configured by default.
- * Either they don't have SCCs or they are allocated somewhere else.
- * Of course, there are now 860s without some SCCs, so we will need to
- * address that someday.
- * The Embedded Planet Multimedia I/O cards use TDM interfaces to the
- * stereo codec parts, and we use SMC2 to help support that.
- */
-static struct serial_state rs_table[] = {
-	/* UART CLK   PORT          IRQ      FLAGS  NUM   */
-#ifndef CONFIG_SCC3_ENET	/* SMC1 not usable with Ethernet on SCC3 */
-  	{ 0,     0, PROFF_SMC1, CPMVEC_SMC1,   0,    0 },    /* SMC1 ttyS0 */
-#endif
-#if !defined(CONFIG_USB_MPC8xx) && !defined(CONFIG_USB_CLIENT_MPC8xx)
-# ifdef CONFIG_SMC2_UART
-  	{ 0,     0, PROFF_SMC2, CPMVEC_SMC2,   0,    1 },    /* SMC2 ttyS1 */
-# endif
-# ifdef CONFIG_USE_SCC_IO
-  	{ 0,     0, PROFF_SCC2, CPMVEC_SCC2,   0,    (NUM_IS_SCC | 1) },    /* SCC2 ttyS2 */
-  	{ 0,     0, PROFF_SCC3, CPMVEC_SCC3,   0,    (NUM_IS_SCC | 2) },    /* SCC3 ttyS3 */
-# endif
-  #else /* CONFIG_USB_xxx */
-# ifdef CONFIG_USE_SCC_IO
-  	{ 0,     0, PROFF_SCC3, CPMVEC_SCC3,   0,    (NUM_IS_SCC | 2) },    /* SCC3 ttyS3 */
-# endif
-#endif	/* CONFIG_USB_xxx */
-};
-
-#define NR_PORTS	(sizeof(rs_table)/sizeof(struct serial_state))
-
-/* The number of buffer descriptors and their sizes.
-*/
-#define RX_NUM_FIFO	4
-#define RX_BUF_SIZE	32
-#define TX_NUM_FIFO	4
-#define TX_BUF_SIZE	32
-
-/* The async_struct in serial.h does not really give us what we
- * need, so define our own here.
- */
-typedef struct serial_info {
-	int			magic;
-	int			flags;
-	struct serial_state	*state;
-	struct tty_struct 	*tty;
-	int			read_status_mask;
-	int			ignore_status_mask;
-	int			timeout;
-	int			line;
-	int			x_char;	/* xon/xoff character */
-	int			close_delay;
-	unsigned short		closing_wait;
-	unsigned short		closing_wait2;
-	unsigned long		event;
-	unsigned long		last_active;
-	int			blocked_open; /* # of blocked opens */
-	struct tq_struct	tqueue;
-	struct tq_struct	tqueue_hangup;
-	wait_queue_head_t	open_wait;
-	wait_queue_head_t	close_wait;
-
-	/* CPM Buffer Descriptor pointers.
-	*/
-	cbd_t			*rx_bd_base;
-	cbd_t			*rx_cur;
-	cbd_t			*tx_bd_base;
-	cbd_t			*tx_cur;
-
-	/* Virtual addresses for the FIFOs because we can't __va() a
-	 * physical address anymore.
-	 */
-	 unsigned char		*rx_va_base;
-	 unsigned char		*tx_va_base;
-} ser_info_t;
-
-static struct console sercons = {
-	.name =		"ttyS",
-	.write =	serial_console_write,
-	.device =	serial_console_device,
-	.setup =	serial_console_setup,
-	.flags =	CON_PRINTBUFFER,
-	.index =	CONFIG_SERIAL_CONSOLE_PORT,
-};
-
-static void change_speed(ser_info_t *info);
-static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout);
-
-static inline int serial_paranoia_check(ser_info_t *info,
-					char *name, 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, name, routine);
-		return 1;
-	}
-	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, name, routine);
-		return 1;
-	}
-#endif
-	return 0;
-}
-
-/*
- * This is used to figure out the divisor speeds and the timeouts,
- * indexed by the termio value.  The generic CPM functions are responsible
- * for setting and assigning baud rate generators for us.
- */
-static int baud_table[] = {
-	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
-	9600, 19200, 38400, 57600, 115200, 230400, 460800, 0 };
-
-
-/*
- * ------------------------------------------------------------
- * 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_8xx_stop(struct tty_struct *tty)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	int	idx;
-	unsigned long flags;
-	volatile scc_t	*sccp;
-	volatile smc_t	*smcp;
-
-	if (serial_paranoia_check(info, tty->name, "rs_stop"))
-		return;
-
-	save_flags(flags); cli();
-	idx = PORT_NUM(info->state->smc_scc_num);
-	if (info->state->smc_scc_num & NUM_IS_SCC) {
-		sccp = &cpmp->cp_scc[idx];
-		sccp->scc_sccm &= ~UART_SCCM_TX;
-	}
-	else {
-		smcp = &cpmp->cp_smc[idx];
-		smcp->smc_smcm &= ~SMCM_TX;
-	}
-	restore_flags(flags);
-}
-
-static void rs_8xx_start(struct tty_struct *tty)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	int	idx;
-	unsigned long flags;
-	volatile scc_t	*sccp;
-	volatile smc_t	*smcp;
-
-	if (serial_paranoia_check(info, tty->name, "rs_stop"))
-		return;
-
-	idx = PORT_NUM(info->state->smc_scc_num);
-	save_flags(flags); cli();
-	if (info->state->smc_scc_num & NUM_IS_SCC) {
-		sccp = &cpmp->cp_scc[idx];
-		sccp->scc_sccm |= UART_SCCM_TX;
-	}
-	else {
-		smcp = &cpmp->cp_smc[idx];
-		smcp->smc_smcm |= SMCM_TX;
-	}
-	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(ser_info_t *info,
-				  int event)
-{
-	info->event |= 1 << event;
-	queue_task(&info->tqueue, &tq_serial);
-	mark_bh(SERIAL_BH);
-}
-
-static _INLINE_ void receive_chars(ser_info_t *info, struct pt_regs *regs)
-{
-	struct tty_struct *tty = info->tty;
-	unsigned char ch, *cp;
-	/*int	ignored = 0;*/
-	int	i;
-	ushort	status;
-	struct	async_icount *icount;
-	volatile cbd_t	*bdp;
-
-	icount = &info->state->icount;
-
-	/* Just loop through the closed BDs and copy the characters into
-	 * the buffer.
-	 */
-	bdp = info->rx_cur;
-	for (;;) {
-		if (bdp->cbd_sc & BD_SC_EMPTY)	/* If this one is empty */
-			break;			/*   we are all done */
-
-		/* The read status mask tell us what we should do with
-		 * incoming characters, especially if errors occur.
-		 * One special case is the use of BD_SC_EMPTY.  If
-		 * this is not set, we are supposed to be ignoring
-		 * inputs.  In this case, just mark the buffer empty and
-		 * continue.
-		if (!(info->read_status_mask & BD_SC_EMPTY)) {
-			bdp->cbd_sc |= BD_SC_EMPTY;
-			bdp->cbd_sc &=
-				~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-
-			if (bdp->cbd_sc & BD_SC_WRAP)
-				bdp = info->rx_bd_base;
-			else
-				bdp++;
-			continue;
-		}
-		 */
-
-		/* Get the number of characters and the buffer pointer.
-		*/
-		i = bdp->cbd_datlen;
-		cp = info->rx_va_base + ((bdp - info->rx_bd_base) * RX_BUF_SIZE);
-		status = bdp->cbd_sc;
-#ifdef CONFIG_KGDB
-		if (info->state->smc_scc_num == KGDB_SER_IDX) {
-			if (*cp == 0x03 || *cp == '$')
-				breakpoint();
-			return;
-		}
-#endif
-
-		/* Check to see if there is room in the tty buffer for
-		 * the characters in our BD buffer.  If not, we exit
-		 * now, leaving the BD with the characters.  We'll pick
-		 * them up again on the next receive interrupt (which could
-		 * be a timeout).
-		 */
-		if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE)
-			break;
-
-		while (i-- > 0) {
-			ch = *cp++;
-			*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 & (BD_SC_BR | BD_SC_FR |
-				       BD_SC_PR | BD_SC_OV)) {
-				/*
-				 * For statistics only
-				 */
-				if (status & BD_SC_BR)
-					icount->brk++;
-				else if (status & BD_SC_PR)
-					icount->parity++;
-				else if (status & BD_SC_FR)
-					icount->frame++;
-				if (status & BD_SC_OV)
-					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;
-					continue;
-				}
-				 */
-				status &= info->read_status_mask;
-
-				if (status & (BD_SC_BR)) {
-#ifdef SERIAL_DEBUG_INTR
-					printk("handling break....");
-#endif
-					*tty->flip.flag_buf_ptr = TTY_BREAK;
-					if (info->flags & ASYNC_SAK)
-						do_SAK(tty);
-				} else if (status & BD_SC_PR)
-					*tty->flip.flag_buf_ptr = TTY_PARITY;
-				else if (status & BD_SC_FR)
-					*tty->flip.flag_buf_ptr = TTY_FRAME;
-				if (status & BD_SC_OV) {
-					/*
-					 * 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;
-					}
-				}
-			}
-#if defined(CONFIG_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);
-					break_pressed = 0;
-					goto ignore_char;
-				} else
-					break_pressed = 0;
-			}
-#endif
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-				break;
-
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
-		}
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-	ignore_char:
-#endif
-		/* This BD is ready to be used again.  Clear status.
-		 * Get next BD.
-		 */
-		bdp->cbd_sc |= BD_SC_EMPTY;
-		bdp->cbd_sc &= ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-
-		if (bdp->cbd_sc & BD_SC_WRAP)
-			bdp = info->rx_bd_base;
-		else
-			bdp++;
-	}
-	info->rx_cur = (cbd_t *)bdp;
-
-	queue_task(&tty->flip.tqueue, &tq_timer);
-}
-
-static _INLINE_ void receive_break(ser_info_t *info, struct pt_regs *regs)
-{
-	struct tty_struct *tty = info->tty;
-
-	info->state->icount.brk++;
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-	if (info->line == sercons.index) {
-		if (!break_pressed) {
-			break_pressed = jiffies;
-			return;
-		} else
-			break_pressed = 0;
-	}
-#endif
-
-	/* Check to see if there is room in the tty buffer for
-	 * the break.  If not, we exit now, losing the break.  FIXME
-	 */
-	if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE)
-		return;
-	*(tty->flip.flag_buf_ptr++) = TTY_BREAK;
-	*(tty->flip.char_buf_ptr++) = 0;
-	tty->flip.count++;
-
-	queue_task(&tty->flip.tqueue, &tq_timer);
-}
-
-static _INLINE_ void transmit_chars(ser_info_t *info, struct pt_regs *regs)
-{
-
-	if ((info->flags & TX_WAKEUP) ||
-	    (info->tty->flags & (1 << TTY_DO_WRITE_WAKEUP))) {
-		rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
-	}
-
-#ifdef SERIAL_DEBUG_INTR
-	printk("THRE...");
-#endif
-}
-
-#ifdef notdef
-	/* I need to do this for the SCCs, so it is left as a reminder.
-	*/
-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 {
-#ifdef SERIAL_DEBUG_OPEN
-			printk("scheduling hangup...");
-#endif
-			schedule_task(&info->tqueue_hangup);
-		}
-	}
-	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);
-			}
-		}
-	}
-}
-#endif
-
-/*
- * This is the serial driver's interrupt routine for a single port
- */
-static void rs_8xx_interrupt(void *dev_id, struct pt_regs *regs)
-{
-	u_char	events;
-	int	idx;
-	ser_info_t *info;
-	volatile smc_t	*smcp;
-	volatile scc_t	*sccp;
-
-	info = (ser_info_t *)dev_id;
-
-	idx = PORT_NUM(info->state->smc_scc_num);
-	if (info->state->smc_scc_num & NUM_IS_SCC) {
-		sccp = &cpmp->cp_scc[idx];
-		events = sccp->scc_scce;
-		if (events & SMCM_BRKE)
-			receive_break(info, regs);
-		if (events & SCCM_RX)
-			receive_chars(info, regs);
-		if (events & SCCM_TX)
-			transmit_chars(info, regs);
-		sccp->scc_scce = events;
-	}
-	else {
-		smcp = &cpmp->cp_smc[idx];
-		events = smcp->smc_smce;
-		if (events & SMCM_BRKE)
-			receive_break(info, regs);
-		if (events & SMCM_RX)
-			receive_chars(info, regs);
-		if (events & SMCM_TX)
-			transmit_chars(info, regs);
-		smcp->smc_smce = events;
-	}
-
-#ifdef SERIAL_DEBUG_INTR
-	printk("rs_interrupt_single(%d, %x)...",
-					info->state->smc_scc_num, events);
-#endif
-#ifdef modem_control
-	check_modem_status(info);
-#endif
-	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_)
-{
-	ser_info_t	*info = (ser_info_t *) 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);
-	}
-}
-
-/*
- * This routine is called from the scheduler tqueue when the interrupt
- * routine has signalled that a hangup has occurred.  The path of
- * hangup processing is:
- *
- * 	serial interrupt routine -> (scheduler tqueue) ->
- * 	do_serial_hangup() -> tty->hangup() -> rs_hangup()
- *
- */
-static void do_serial_hangup(void *private_)
-{
-	struct async_struct	*info = (struct async_struct *) private_;
-	struct tty_struct	*tty;
-
-	tty = info->tty;
-	if (tty)
-		tty_hangup(tty);
-}
-
-/*static void rs_8xx_timer(void)
-{
-	printk("rs_8xx_timer\n");
-}*/
-
-
-static int startup(ser_info_t *info)
-{
-	unsigned long flags;
-	int	retval=0;
-	int	idx;
-	struct serial_state *state= info->state;
-	volatile smc_t		*smcp;
-	volatile scc_t		*sccp;
-	volatile smc_uart_t	*up;
-	volatile scc_uart_t	*scup;
-
-
-	save_flags(flags); cli();
-
-	if (info->flags & ASYNC_INITIALIZED) {
-		goto errout;
-	}
-
-#ifdef maybe
-	if (!state->port || !state->type) {
-		if (info->tty)
-			set_bit(TTY_IO_ERROR, &info->tty->flags);
-		goto errout;
-	}
-#endif
-
-#ifdef SERIAL_DEBUG_OPEN
-	printk("starting up ttys%d (irq %d)...", info->line, state->irq);
-#endif
-
-
-#ifdef modem_control
-	info->MCR = 0;
-	if (info->tty->termios->c_cflag & CBAUD)
-		info->MCR = UART_MCR_DTR | UART_MCR_RTS;
-#endif
-
-	if (info->tty)
-		clear_bit(TTY_IO_ERROR, &info->tty->flags);
-
-	/*
-	 * and set the speed of the serial port
-	 */
-	change_speed(info);
-
-	idx = PORT_NUM(info->state->smc_scc_num);
-	if (info->state->smc_scc_num & NUM_IS_SCC) {
-		sccp = &cpmp->cp_scc[idx];
-		scup = (scc_uart_t *)&cpmp->cp_dparam[state->port];
-		scup->scc_genscc.scc_mrblr = RX_BUF_SIZE;
-		scup->scc_maxidl = RX_BUF_SIZE;
-		sccp->scc_sccm |= (UART_SCCM_TX | UART_SCCM_RX);
-		sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-	}
-	else {
-		smcp = &cpmp->cp_smc[idx];
-
-		/* Enable interrupts and I/O.
-		*/
-		smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
-		smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
-
-		/* We can tune the buffer length and idle characters
-		 * to take advantage of the entire incoming buffer size.
-		 * If mrblr is something other than 1, maxidl has to be
-		 * non-zero or we never get an interrupt.  The maxidl
-		 * is the number of character times we wait after reception
-		 * of the last character before we decide no more characters
-		 * are coming.
-		 */
-		up = (smc_uart_t *)&cpmp->cp_dparam[state->port];
-		up->smc_mrblr = RX_BUF_SIZE;
-		up->smc_maxidl = RX_BUF_SIZE;
-		up->smc_brkcr = 1;	/* number of break chars */
-	}
-
-	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(ser_info_t * info)
-{
-	unsigned long	flags;
-	struct serial_state *state;
-	int		idx;
-	volatile smc_t	*smcp;
-	volatile scc_t	*sccp;
-
-	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 */
-
-	idx = PORT_NUM(state->smc_scc_num);
-	if (state->smc_scc_num & NUM_IS_SCC) {
-		sccp = &cpmp->cp_scc[idx];
-		sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-#ifdef CONFIG_SERIAL_CONSOLE
-		/* We can't disable the transmitter if this is the
-		 * system console.
-		 */
-		if ((state - rs_table) != CONFIG_SERIAL_CONSOLE_PORT)
-#endif
-			sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
-	}
-	else {
-		smcp = &cpmp->cp_smc[idx];
-
-		/* Disable interrupts and I/O.
-		*/
-		smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
-#ifdef CONFIG_SERIAL_CONSOLE
-		/* We can't disable the transmitter if this is the
-		 * system console.
-		 */
-		if ((state - rs_table) != CONFIG_SERIAL_CONSOLE_PORT)
-#endif
-			smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-	}
-
-	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(ser_info_t *info)
-{
-	int	baud_rate;
-	unsigned cflag, cval, scval, prev_mode, new_mode;
-	int	i, bits, sbits, idx;
-	unsigned long	flags;
-	struct serial_state *state;
-	volatile smc_t	*smcp;
-	volatile scc_t	*sccp;
-
-	if (!info->tty || !info->tty->termios)
-		return;
-	cflag = info->tty->termios->c_cflag;
-
-	state = info->state;
-
-	/* Character length programmed into the mode register is the
-	 * sum of: 1 start bit, number of data bits, 0 or 1 parity bit,
-	 * 1 or 2 stop bits, minus 1.
-	 * The value 'bits' counts this for us.
-	 */
-	cval = 0;
-	scval = 0;
-
-	/* byte size and parity */
-	switch (cflag & CSIZE) {
-	      case CS5: bits = 5; break;
-	      case CS6: bits = 6; break;
-	      case CS7: bits = 7; break;
-	      case CS8: bits = 8; break;
-	      /* Never happens, but GCC is too dumb to figure it out */
-	      default:  bits = 8; break;
-	}
-	sbits = bits - 5;
-
-	if (cflag & CSTOPB) {
-		cval |= SMCMR_SL;	/* Two stops */
-		scval |= SCU_PMSR_SL;
-		bits++;
-	}
-	if (cflag & PARENB) {
-		cval |= SMCMR_PEN;
-		scval |= SCU_PMSR_PEN;
-		bits++;
-		if (!(cflag & PARODD)) {
-			cval |= SMCMR_PM_EVEN;
-			scval |= (SCU_PMSR_REVP | SCU_PMSR_TEVP);
-		}
-	}
-
-	/* Determine divisor based on baud rate */
-	i = cflag & CBAUD;
-	if (i >= (sizeof(baud_table)/sizeof(int)))
-		baud_rate = 9600;
-	else
-		baud_rate = baud_table[i];
-
-	info->timeout = (TX_BUF_SIZE*HZ*bits);
-	info->timeout += HZ/50;		/* Add .02 seconds of slop */
-
-#ifdef modem_control
-	/* 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);
-#endif
-
-	/*
-	 * Set up parity check flag
-	 */
-#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
-
-	info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
-	if (I_INPCK(info->tty))
-		info->read_status_mask |= BD_SC_FR | BD_SC_PR;
-	if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
-		info->read_status_mask |= BD_SC_BR;
-
-	/*
-	 * Characters to ignore
-	 */
-	info->ignore_status_mask = 0;
-	if (I_IGNPAR(info->tty))
-		info->ignore_status_mask |= BD_SC_PR | BD_SC_FR;
-	if (I_IGNBRK(info->tty)) {
-		info->ignore_status_mask |= BD_SC_BR;
-		/*
-		 * If we're ignore parity and break indicators, ignore
-		 * overruns too.  (For real raw support).
-		 */
-		if (I_IGNPAR(info->tty))
-			info->ignore_status_mask |= BD_SC_OV;
-	}
-	/*
-	 * !!! ignore all characters if CREAD is not set
-	 */
-	if ((cflag & CREAD) == 0)
-		info->read_status_mask &= ~BD_SC_EMPTY;
-	save_flags(flags); cli();
-
-	/* Start bit has not been added (so don't, because we would just
-	 * subtract it later), and we need to add one for the number of
-	 * stops bits (there is always at least one).
-	 */
-	bits++;
-	idx = PORT_NUM(state->smc_scc_num);
-	if (state->smc_scc_num & NUM_IS_SCC) {
-		sccp = &cpmp->cp_scc[idx];
-		new_mode = (sbits << 12) | scval;
-		prev_mode = sccp->scc_pmsr;
-		if (!(prev_mode & SCU_PMSR_PEN))
-			/* If parity is disabled, mask out even/odd */
-			prev_mode &= ~(SCU_PMSR_TPM|SCU_PMSR_RPM);
-		if (prev_mode != new_mode)
-			sccp->scc_pmsr = new_mode;
-	}
-	else {
-		smcp = &cpmp->cp_smc[idx];
-
-		/* Set the mode register.  We want to keep a copy of the
-		 * enables, because we want to put them back if they were
-		 * present.
-		 */
-		prev_mode = smcp->smc_smcmr;
-		new_mode = smcr_mk_clen(bits) | cval |  SMCMR_SM_UART;
-		new_mode |= (prev_mode & (SMCMR_REN | SMCMR_TEN));
-		if (!(prev_mode & SMCMR_PEN))
-			/* If parity is disabled, mask out even/odd */
-			prev_mode &= ~SMCMR_PM_EVEN;
-		if (prev_mode != new_mode)
-			smcp->smc_smcmr = new_mode;
-	}
-
-	m8xx_cpm_setbrg((state - rs_table), baud_rate);
-
-	restore_flags(flags);
-}
-
-static void rs_8xx_put_char(struct tty_struct *tty, unsigned char ch)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	volatile cbd_t	*bdp;
-	unsigned char *cp;
-
-	if (serial_paranoia_check(info, tty->name, "rs_put_char"))
-		return;
-
-	if (!tty)
-		return;
-
-	bdp = info->tx_cur;
-	while (bdp->cbd_sc & BD_SC_READY);
-
-	cp = info->tx_va_base + ((bdp - info->tx_bd_base) * TX_BUF_SIZE);
-	*cp = ch;
-	bdp->cbd_datlen = 1;
-	bdp->cbd_sc |= BD_SC_READY;
-
-	/* Get next BD.
-	*/
-	if (bdp->cbd_sc & BD_SC_WRAP)
-		bdp = info->tx_bd_base;
-	else
-		bdp++;
-
-	info->tx_cur = (cbd_t *)bdp;
-
-}
-
-static int rs_8xx_write(struct tty_struct * tty, int from_user,
-		    const unsigned char *buf, int count)
-{
-	int	c, ret = 0;
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	volatile cbd_t *bdp;
-	unsigned char	*cp;
-
-#ifdef CONFIG_KGDB_CONSOLE
-        /* Try to let stub handle output. Returns true if it did. */
-        if (kgdb_output_string(buf, count))
-            return ret;
-#endif
-
-	if (serial_paranoia_check(info, tty->name, "rs_write"))
-		return 0;
-
-	if (!tty)
-		return 0;
-
-	bdp = info->tx_cur;
-
-	while (1) {
-		c = min(count, TX_BUF_SIZE);
-
-		if (c <= 0)
-			break;
-
-		if (bdp->cbd_sc & BD_SC_READY) {
-			info->flags |= TX_WAKEUP;
-			break;
-		}
-
-		cp = info->tx_va_base + ((bdp - info->tx_bd_base) * TX_BUF_SIZE);
-		if (from_user) {
-			if (copy_from_user((void *)cp, buf, c)) {
-				if (!ret)
-					ret = -EFAULT;
-				break;
-			}
-		} else {
-			memcpy((void *)cp, buf, c);
-		}
-
-		bdp->cbd_datlen = c;
-		bdp->cbd_sc |= BD_SC_READY;
-
-		buf += c;
-		count -= c;
-		ret += c;
-
-		/* Get next BD.
-		*/
-		if (bdp->cbd_sc & BD_SC_WRAP)
-			bdp = info->tx_bd_base;
-		else
-			bdp++;
-		info->tx_cur = (cbd_t *)bdp;
-	}
-	return ret;
-}
-
-static int rs_8xx_write_room(struct tty_struct *tty)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	int	ret;
-
-	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
-		return 0;
-
-	if ((info->tx_cur->cbd_sc & BD_SC_READY) == 0) {
-		info->flags &= ~TX_WAKEUP;
-		ret = TX_BUF_SIZE;
-	}
-	else {
-		info->flags |= TX_WAKEUP;
-		ret = 0;
-	}
-	return ret;
-}
-
-/* I could track this with transmit counters....maybe later.
-*/
-static int rs_8xx_chars_in_buffer(struct tty_struct *tty)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-		
-	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
-		return 0;
-	return 0;
-}
-
-static void rs_8xx_flush_buffer(struct tty_struct *tty)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-		
-	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
-		return;
-
-	/* There is nothing to "flush", whatever we gave the CPM
-	 * is on its way out.
-	 */
-	wake_up_interruptible(&tty->write_wait);
-	if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-	    tty->ldisc.write_wakeup)
-		(tty->ldisc.write_wakeup)(tty);
-	info->flags &= ~TX_WAKEUP;
-}
-
-/*
- * This function is used to send a high-priority XON/XOFF character to
- * the device
- */
-static void rs_8xx_send_xchar(struct tty_struct *tty, char ch)
-{
-	volatile cbd_t	*bdp;
-	unsigned char	*cp;
-
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-
-	if (serial_paranoia_check(info, tty->name, "rs_send_char"))
-		return;
-
-	bdp = info->tx_cur;
-	while (bdp->cbd_sc & BD_SC_READY);
-
-	cp = info->tx_va_base + ((bdp - info->tx_bd_base) * TX_BUF_SIZE);
-	*cp = ch;
-	bdp->cbd_datlen = 1;
-	bdp->cbd_sc |= BD_SC_READY;
-
-	/* Get next BD.
-	*/
-	if (bdp->cbd_sc & BD_SC_WRAP)
-		bdp = info->tx_bd_base;
-	else
-		bdp++;
-
-	info->tx_cur = (cbd_t *)bdp;
-}
-
-/*
- * ------------------------------------------------------------
- * rs_throttle()
- *
- * This routine is called by the upper-layer tty layer to signal that
- * incoming characters should be throttled.
- * ------------------------------------------------------------
- */
-static void rs_8xx_throttle(struct tty_struct * tty)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-#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->name, "rs_throttle"))
-		return;
-
-	if (I_IXOFF(tty))
-		rs_8xx_send_xchar(tty, STOP_CHAR(tty));
-
-#ifdef modem_control
-	if (tty->termios->c_cflag & CRTSCTS)
-		info->MCR &= ~UART_MCR_RTS;
-
-	cli();
-	serial_out(info, UART_MCR, info->MCR);
-	sti();
-#endif
-}
-
-static void rs_8xx_unthrottle(struct tty_struct * tty)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-#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->name, "rs_unthrottle"))
-		return;
-
-	if (I_IXOFF(tty)) {
-		if (info->x_char)
-			info->x_char = 0;
-		else
-			rs_8xx_send_xchar(tty, START_CHAR(tty));
-	}
-#ifdef modem_control
-	if (tty->termios->c_cflag & CRTSCTS)
-		info->MCR |= UART_MCR_RTS;
-	cli();
-	serial_out(info, UART_MCR, info->MCR);
-	sti();
-#endif
-}
-
-/*
- * ------------------------------------------------------------
- * rs_ioctl() and friends
- * ------------------------------------------------------------
- */
-
-#ifdef maybe
-/*
- * 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;
-
-	cli();
-	status = serial_in(info, UART_LSR);
-	sti();
-	result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
-	return put_user(result,value);
-}
-#endif
-
-static int get_modem_info(ser_info_t *info, unsigned int *value)
-{
-	unsigned int result = 0;
-#ifdef modem_control
-	unsigned char control, status;
-
-	control = info->MCR;
-	cli();
-	status = serial_in(info, UART_MSR);
-	sti();
-	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);
-#endif
-	return put_user(result,value);
-}
-
-static int set_modem_info(ser_info_t *info, unsigned int cmd,
-			  unsigned int *value)
-{
-	int error;
-	unsigned int arg;
-
-	error = get_user(arg, value);
-	if (error)
-		return error;
-#ifdef modem_control
-	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
-		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
-		break;
-	case TIOCMSET:
-		info->MCR = ((info->MCR & ~(UART_MCR_RTS |
-#ifdef TIOCM_OUT1
-					    UART_MCR_OUT1 |
-					    UART_MCR_OUT2 |
-#endif
-					    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_DTR) ? UART_MCR_DTR : 0));
-		break;
-	default:
-		return -EINVAL;
-	}
-	cli();
-	serial_out(info, UART_MCR, info->MCR);
-	sti();
-#endif
-	return 0;
-}
-
-/* Sending a break is a two step process on the SMC/SCC.  It is accomplished
- * by sending a STOP TRANSMIT command followed by a RESTART TRANSMIT
- * command.  We take advantage of the begin/end functions to make this
- * happen.
- */
-static ushort	smc_chan_map[] = {
-	CPM_CR_CH_SMC1,
-	CPM_CR_CH_SMC2
-};
-
-static ushort	scc_chan_map[] = {
-	CPM_CR_CH_SCC1,
-	CPM_CR_CH_SCC2,
-	CPM_CR_CH_SCC3,
-	CPM_CR_CH_SCC4
-};
-
-static void begin_break(ser_info_t *info)
-{
-	volatile cpm8xx_t *cp;
-	ushort	chan;
-	int	idx;
-
-	cp = cpmp;
-
-	idx = PORT_NUM(info->state->smc_scc_num);
-	if (info->state->smc_scc_num & NUM_IS_SCC)
-		chan = scc_chan_map[idx];
-	else
-		chan = smc_chan_map[idx];
-	cp->cp_cpcr = mk_cr_cmd(chan, CPM_CR_STOP_TX) | CPM_CR_FLG;
-	while (cp->cp_cpcr & CPM_CR_FLG);
-}
-
-static void end_break(ser_info_t *info)
-{
-	volatile cpm8xx_t *cp;
-	ushort	chan;
-	int	idx;
-
-	cp = cpmp;
-
-	idx = PORT_NUM(info->state->smc_scc_num);
-	if (info->state->smc_scc_num & NUM_IS_SCC)
-		chan = scc_chan_map[idx];
-	else
-		chan = smc_chan_map[idx];
-	cp->cp_cpcr = mk_cr_cmd(chan, CPM_CR_RESTART_TX) | CPM_CR_FLG;
-	while (cp->cp_cpcr & CPM_CR_FLG);
-}
-
-/*
- * This routine sends a break character out the serial port.
- */
-static void send_break(ser_info_t *info, int duration)
-{
-	current->state = TASK_INTERRUPTIBLE;
-#ifdef SERIAL_DEBUG_SEND_BREAK
-	printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
-#endif
-	begin_break(info);
-	schedule_timeout(duration);
-	end_break(info);
-#ifdef SERIAL_DEBUG_SEND_BREAK
-	printk("done jiffies=%lu\n", jiffies);
-#endif
-}
-
-
-static int rs_8xx_ioctl(struct tty_struct *tty, struct file * file,
-		    unsigned int cmd, unsigned long arg)
-{
-	int error;
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	int retval;
-	struct async_icount cnow;	/* kernel counter temps */
-	struct serial_icounter_struct *p_cuser;	/* user space */
-
-	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
-		return -ENODEV;
-
-	if ((cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
-		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 (signal_pending(current))
-				return -EINTR;
-			if (!arg) {
-				send_break(info, HZ/4);	/* 1/4 second */
-				if (signal_pending(current))
-					return -EINTR;
-			}
-			return 0;
-		case TCSBRKP:	/* support for POSIX tcsendbreak() */
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			tty_wait_until_sent(tty, 0);
-			if (signal_pending(current))
-				return -EINTR;
-			send_break(info, arg ? arg*(HZ/10) : HZ/4);
-			if (signal_pending(current))
-				return -EINTR;
-			return 0;
-		case TIOCSBRK:
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			tty_wait_until_sent(tty, 0);
-			begin_break(info);
-			return 0;
-		case TIOCCBRK:
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			end_break(info);
-			return 0;
-		case TIOCGSOFTCAR:
-			return put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg);
-		case TIOCSSOFTCAR:
-			error = get_user(arg, (unsigned int *) arg);
-			if (error)
-				return error;
-			tty->termios->c_cflag =
-				((tty->termios->c_cflag & ~CLOCAL) |
-				 (arg ? CLOCAL : 0));
-			return 0;
-		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);
-#ifdef maybe
-		case TIOCSERGETLSR: /* Get line status register */
-			return get_lsr_info(info, (unsigned int *) arg);
-#endif
-		/*
-		 * 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:
-#ifdef modem_control
-			cli();
-			/* note the counters on entry */
-			cprev = info->state->icount;
-			sti();
-			while (1) {
-				interruptible_sleep_on(&info->delta_msr_wait);
-				/* see if a signal did it */
-				if (signal_pending(current))
-					return -ERESTARTSYS;
-				cli();
-				cnow = info->state->icount; /* atomic copy */
-				sti();
-				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 */
-#else
-			return 0;
-#endif
-
-		/*
-		 * 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:
-			cli();
-			cnow = info->state->icount;
-			sti();
-			p_cuser = (struct serial_icounter_struct *) arg;
-			error = put_user(cnow.cts, &p_cuser->cts);
-			if (error) return error;
-			error = put_user(cnow.dsr, &p_cuser->dsr);
-			if (error) return error;
-			error = put_user(cnow.rng, &p_cuser->rng);
-			if (error) return error;
-			error = put_user(cnow.dcd, &p_cuser->dcd);
-			if (error) return error;
-			return 0;
-
-		default:
-			return -ENOIOCTLCMD;
-		}
-	return 0;
-}
-
-/* FIX UP modem control here someday......
-*/
-static void rs_8xx_set_termios(struct tty_struct *tty, struct termios *old_termios)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-
-	if (   (tty->termios->c_cflag == old_termios->c_cflag)
-	    && (   RELEVANT_IFLAG(tty->termios->c_iflag)
-		== RELEVANT_IFLAG(old_termios->c_iflag)))
-	  return;
-
-	change_speed(info);
-
-#ifdef modem_control
-	/* Handle transition to B0 status */
-	if ((old_termios->c_cflag & CBAUD) &&
-	    !(tty->termios->c_cflag & CBAUD)) {
-		info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
-		cli();
-		serial_out(info, UART_MCR, info->MCR);
-		sti();
-	}
-
-	/* Handle transition away from B0 status */
-	if (!(old_termios->c_cflag & CBAUD) &&
-	    (tty->termios->c_cflag & CBAUD)) {
-		info->MCR |= UART_MCR_DTR;
-		if (!tty->hw_stopped ||
-		    !(tty->termios->c_cflag & CRTSCTS)) {
-			info->MCR |= UART_MCR_RTS;
-		}
-		cli();
-		serial_out(info, UART_MCR, info->MCR);
-		sti();
-	}
-
-	/* Handle turning off CRTSCTS */
-	if ((old_termios->c_cflag & CRTSCTS) &&
-	    !(tty->termios->c_cflag & CRTSCTS)) {
-		tty->hw_stopped = 0;
-		rs_8xx_start(tty);
-	}
-#endif
-
-#if 0
-	/*
-	 * No need to wake up processes in open wait, since they
-	 * sample the CLOCAL flag once, and don't recheck it.
-	 * XXX  It's not clear whether the current behavior is correct
-	 * or not.  Hence, this may change.....
-	 */
-	if (!(old_termios->c_cflag & CLOCAL) &&
-	    (tty->termios->c_cflag & CLOCAL))
-		wake_up_interruptible(&info->open_wait);
-#endif
-}
-
-/*
- * ------------------------------------------------------------
- * 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_8xx_close(struct tty_struct *tty, struct file * filp)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	struct serial_state *state;
-	unsigned long	flags;
-	int		idx;
-	volatile smc_t	*smcp;
-	volatile scc_t	*sccp;
-
-	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
-		return;
-
-	state = info->state;
-
-	save_flags(flags); cli();
-
-	if (tty_hung_up_p(filp)) {
-		DBG_CNT("before DEC-hung");
-		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");
-		restore_flags(flags);
-		return;
-	}
-	info->flags |= ASYNC_CLOSING;
-	/*
-	 * 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->read_status_mask &= ~BD_SC_EMPTY;
-	if (info->flags & ASYNC_INITIALIZED) {
-		idx = PORT_NUM(info->state->smc_scc_num);
-		if (info->state->smc_scc_num & NUM_IS_SCC) {
-			sccp = &cpmp->cp_scc[idx];
-			sccp->scc_sccm &= ~UART_SCCM_RX;
-			sccp->scc_gsmrl &= ~SCC_GSMRL_ENR;
-		}
-		else {
-			smcp = &cpmp->cp_smc[idx];
-			smcp->smc_smcm &= ~SMCM_RX;
-			smcp->smc_smcmr &= ~SMCMR_REN;
-		}
-		/*
-		 * Before we drop DTR, make sure the UART transmitter
-		 * has completely drained; this is especially
-		 * important if there is a transmit FIFO!
-		 */
-		rs_8xx_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) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(info->close_delay);
-		}
-		wake_up_interruptible(&info->open_wait);
-	}
-	info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-	wake_up_interruptible(&info->close_wait);
-	restore_flags(flags);
-}
-
-/*
- * rs_wait_until_sent() --- wait until the transmitter is empty
- */
-static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	unsigned long orig_jiffies, char_time;
-	/*int lsr;*/
-	volatile cbd_t *bdp;
-
-	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
-		return;
-
-#ifdef maybe
-	if (info->state->type == PORT_UNKNOWN)
-		return;
-#endif
-
-	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 = 1;
-	if (timeout)
-		char_time = min(char_time, 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
-
-	/* We go through the loop at least once because we can't tell
-	 * exactly when the last character exits the shifter.  There can
-	 * be at least two characters waiting to be sent after the buffers
-	 * are empty.
-	 */
-	do {
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
-		printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
-#endif
-		current->state = TASK_INTERRUPTIBLE;
-/*		current->dyn_prio = 0;	 make us low-priority */
-		schedule_timeout(char_time);
-		if (signal_pending(current))
-			break;
-		if (timeout && time_after(jiffies, orig_jiffies + timeout))
-			break;
-
-		/* The 'tx_cur' is really the next buffer to send.  We
-		 * have to back up to the previous BD and wait for it
-		 * to go.  This isn't perfect, because all this indicates
-		 * is the buffer is available.  There are still characters
-		 * in the CPM FIFO.
-		 */
-		bdp = info->tx_cur;
-		if (bdp == info->tx_bd_base)
-			bdp += (TX_NUM_FIFO-1);
-		else
-			bdp--;
-	} while (bdp->cbd_sc & BD_SC_READY);
-	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_8xx_hangup(struct tty_struct *tty)
-{
-	ser_info_t *info = (ser_info_t *)tty->driver_data;
-	struct serial_state *state = info->state;
-
-	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
-		return;
-
-	state = info->state;
-
-	rs_8xx_flush_buffer(tty);
-	shutdown(info);
-	info->event = 0;
-	state->count = 0;
-	info->flags &= ~ASYNC_NORMAL_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,
-			   ser_info_t *info)
-{
-#ifdef DO_THIS_LATER
-	DECLARE_WAITQUEUE(wait, current);
-#endif
-	struct serial_state *state = info->state;
-	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 (tty_hung_up_p(filp) ||
-	    (info->flags & ASYNC_CLOSING)) {
-		if (info->flags & ASYNC_CLOSING)
-			interruptible_sleep_on(&info->close_wait);
-#ifdef SERIAL_DO_RESTART
-		if (info->flags & ASYNC_HUP_NOTIFY)
-			return -EAGAIN;
-		else
-			return -ERESTARTSYS;
-#else
-		return -EAGAIN;
-#endif
-	}
-
-	/*
-	 * If non-blocking mode is set, or the port is not enabled,
-	 * then make the check up front and then exit.
-	 * If this is an SMC port, we don't have modem control to wait
-	 * for, so just get out here.
-	 */
-	if ((filp->f_flags & O_NONBLOCK) ||
-	    (tty->flags & (1 << TTY_IO_ERROR)) ||
-	    !(info->state->smc_scc_num & NUM_IS_SCC)) {
-		info->flags |= ASYNC_NORMAL_ACTIVE;
-		return 0;
-	}
-
-	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;
-#ifdef DO_THIS_LATER
-	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
-	cli();
-	if (!tty_hung_up_p(filp))
-		state->count--;
-	sti();
-	info->blocked_open++;
-	while (1) {
-		cli();
-		if ((tty->termios->c_cflag & CBAUD))
-			serial_out(info, UART_MCR,
-				   serial_inp(info, UART_MCR) |
-				   (UART_MCR_DTR | UART_MCR_RTS));
-		sti();
-		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_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();
-	}
-	current->state = TASK_RUNNING;
-	remove_wait_queue(&info->open_wait, &wait);
-	if (!tty_hung_up_p(filp))
-		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
-#endif /* DO_THIS_LATER */
-	if (retval)
-		return retval;
-	info->flags |= ASYNC_NORMAL_ACTIVE;
-	return 0;
-}
-
-static int get_async_struct(int line, ser_info_t **ret_info)
-{
-	struct serial_state *sstate;
-
-	sstate = rs_table + line;
-	if (sstate->info) {
-		sstate->count++;
-		*ret_info = (ser_info_t *)sstate->info;
-		return 0;
-	}
-	else {
-		return -ENOMEM;
-	}
-}
-
-/*
- * 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_8xx_open(struct tty_struct *tty, struct file * filp)
-{
-	ser_info_t	*info;
-	int 		retval, line;
-
-	line = tty->index;
-	if ((line < 0) || (line >= NR_PORTS))
-		return -ENODEV;
-	retval = get_async_struct(line, &info);
-	if (retval)
-		return retval;
-	if (serial_paranoia_check(info, tty->name, "rs_open"))
-		return -ENODEV;
-
-#ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s, count = %d\n", tty->name, info->state->count);
-#endif
-	tty->driver_data = info;
-	info->tty = tty;
-
-	/*
-	 * Start up serial port
-	 */
-	retval = startup(info);
-	if (retval)
-		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
-		return retval;
-	}
-
-#ifdef SERIAL_DEBUG_OPEN
-	printk("rs_open %s successful...", tty->name);
-#endif
-	return 0;
-}
-
-/*
- * /proc fs routines....
- */
-
-static inline int line_info(char *buf, struct serial_state *state)
-{
-#ifdef notdef
-	struct async_struct *info = state->info, scr_info;
-	char	stat_buf[30], control, status;
-#endif
-	int	ret;
-
-	ret = sprintf(buf, "%d: uart:%s port:%X irq:%d",
-		      state->line,
-		      (state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC",
-		      (unsigned int)(state->port), state->irq);
-
-	if (!state->port || (state->type == PORT_UNKNOWN)) {
-		ret += sprintf(buf+ret, "\n");
-		return ret;
-	}
-
-#ifdef notdef
-	/*
-	 * 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;
-	}
-	cli();
-	status = serial_in(info, UART_MSR);
-	control = info ? info->MCR : serial_in(info, UART_MCR);
-	sti();
-
-	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);
-#endif
-	return ret;
-}
-
-int rs_8xx_read_proc(char *page, char **start, off_t off, int count,
-		 int *eof, void *data)
-{
-	int i, len = 0;
-	off_t	begin = 0;
-
-	len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
-	for (i = 0; i < NR_PORTS && len < 4000; i++) {
-		len += line_info(page + len, &rs_table[i]);
-		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 + (begin-off);
-	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 _INLINE_ void show_serial_version(void)
-{
- 	printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
-}
-
-
-/*
- * The serial console driver used during boot.  Note that these names
- * clash with those found in "serial.c", so we currently can't support
- * the 16xxx uarts and these at the same time.  I will fix this to become
- * an indirect function call from tty_io.c (or something).
- */
-
-#ifdef CONFIG_SERIAL_CONSOLE
-
-/* I need this just so I can store the virtual addresses and have
- * common functions for the early console printing.
- */
-static ser_info_t consinfo;
-
-/*
- * Print a string to the serial port trying not to disturb any possible
- * real use of the port...
- */
-static void my_console_write(int idx, const char *s,
-				unsigned count)
-{
-	struct		serial_state	*ser;
-	ser_info_t			*info;
-	unsigned			i;
-	volatile	cbd_t		*bdp, *bdbase;
-	volatile	smc_uart_t	*up;
-	volatile	u_char		*cp;
-
-	ser = rs_table + idx;
-
-	/* If the port has been initialized for general use, we have
-	 * to use the buffer descriptors allocated there.  Otherwise,
-	 * we simply use the single buffer allocated.
-	 */
-	if ((info = (ser_info_t *)ser->info) != NULL) {
-		bdp = info->tx_cur;
-		bdbase = info->tx_bd_base;
-	}
-	else {
-		/* Pointer to UART in parameter ram.
-		*/
-		up = (smc_uart_t *)&cpmp->cp_dparam[ser->port];
-
-		/* Get the address of the host memory buffer.
-		 */
-		bdp = bdbase = (cbd_t *)&cpmp->cp_dpmem[up->smc_tbase];
-
-		info = &consinfo;
-	}
-
-	/*
-	 * We need to gracefully shut down the transmitter, disable
-	 * interrupts, then send our bytes out.
-	 */
-
-	/*
-	 * Now, do each character.  This is not as bad as it looks
-	 * since this is a holding FIFO and not a transmitting FIFO.
-	 * We could add the complexity of filling the entire transmit
-	 * buffer, but we would just wait longer between accesses......
-	 */
-	for (i = 0; i < count; i++, s++) {
-		/* Wait for transmitter fifo to empty.
-		 * Ready indicates output is ready, and xmt is doing
-		 * that, not that it is ready for us to send.
-		 */
-		while (bdp->cbd_sc & BD_SC_READY);
-
-		/* Send the character out.
-		 * If the buffer address is in the CPM DPRAM, don't
-		 * convert it.
-		 */
-		if ((uint)(bdp->cbd_bufaddr) > (uint)IMAP_ADDR)
-			cp = (u_char *)(bdp->cbd_bufaddr);
-		else
-			cp = info->tx_va_base + ((bdp - info->tx_bd_base) * TX_BUF_SIZE);
-		*cp = *s;
-
-		bdp->cbd_datlen = 1;
-		bdp->cbd_sc |= BD_SC_READY;
-
-		if (bdp->cbd_sc & BD_SC_WRAP)
-			bdp = bdbase;
-		else
-			bdp++;
-
-		/* if a LF, also do CR... */
-		if (*s == 10) {
-			while (bdp->cbd_sc & BD_SC_READY);
-			cp = info->tx_va_base + ((bdp - info->tx_bd_base) * TX_BUF_SIZE);
-			*cp = 13;
-			bdp->cbd_datlen = 1;
-			bdp->cbd_sc |= BD_SC_READY;
-
-			if (bdp->cbd_sc & BD_SC_WRAP) {
-				bdp = bdbase;
-			}
-			else {
-				bdp++;
-			}
-		}
-	}
-
-	/*
-	 * Finally, Wait for transmitter & holding register to empty
-	 *  and restore the IER
-	 */
-	while (bdp->cbd_sc & BD_SC_READY);
-
-	if (info)
-		info->tx_cur = (cbd_t *)bdp;
-}
-
-static void serial_console_write(struct console *c, const char *s,
-				unsigned count)
-{
-#ifdef CONFIG_KGDB_CONSOLE
-	/* Try to let stub handle output. Returns true if it did. */
-	if (kgdb_output_string(s, count))
-		return;
-#endif
-	my_console_write(c->index, s, count);
-}
-
-#ifdef CONFIG_XMON
-int
-xmon_8xx_write(const char *s, unsigned count)
-{
-	my_console_write(0, s, count);
-	return(count);
-}
-#endif
-
-#ifdef CONFIG_KGDB
-void
-putDebugChar(char ch)
-{
-	my_console_write(0, &ch, 1);
-}
-#endif
-
-/*
- * Receive character from the serial port.  This only works well
- * before the port is initialized for real use.
- */
-static int my_console_wait_key(int idx, int xmon, char *obuf)
-{
-	struct serial_state		*ser;
-	u_char				c, *cp;
-	ser_info_t			*info;
-	volatile	cbd_t		*bdp;
-	volatile	smc_uart_t	*up;
-	int				i;
-
-	ser = rs_table + idx;
-
-	/* Pointer to UART in parameter ram.
-	*/
-	up = (smc_uart_t *)&cpmp->cp_dparam[ser->port];
-
-	/* Get the address of the host memory buffer.
-	 * If the port has been initialized for general use, we must
-	 * use information from the port structure.
-	 */
-	if ((info = (ser_info_t *)ser->info)) {
-		bdp = info->rx_cur;
-	}
-	else {
-		bdp = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];
-		info = &consinfo;
-	}
-
-	/*
-	 * We need to gracefully shut down the receiver, disable
-	 * interrupts, then read the input.
-	 * XMON just wants a poll.  If no character, return -1, else
-	 * return the character.
-	 */
-	if (!xmon) {
-		while (bdp->cbd_sc & BD_SC_EMPTY);
-	}
-	else {
-		if (bdp->cbd_sc & BD_SC_EMPTY)
-			return -1;
-	}
-
-	/* If the buffer address is in the CPM DPRAM, don't
-	 * convert it.
-	 */
-	if ((uint)(bdp->cbd_bufaddr) > (uint)IMAP_ADDR)
-		cp = (u_char *)(bdp->cbd_bufaddr);
-	else
-		cp = info->rx_va_base + ((bdp - info->rx_bd_base) * RX_BUF_SIZE);
-
-	if (obuf) {
-		i = c = bdp->cbd_datlen;
-		while (i-- > 0)
-			*obuf++ = *cp++;
-	}
-	else {
-		c = *cp;
-	}
-	bdp->cbd_sc |= BD_SC_EMPTY;
-
-	if (info) {
-		if (bdp->cbd_sc & BD_SC_WRAP) {
-			bdp = info->rx_bd_base;
-		}
-		else {
-			bdp++;
-		}
-		info->rx_cur = (cbd_t *)bdp;
-	}
-
-	return((int)c);
-}
-
-#ifdef CONFIG_XMON
-int
-xmon_8xx_read_poll(void)
-{
-	return(my_console_wait_key(0, 1, NULL));
-}
-
-int
-xmon_8xx_read_char(void)
-{
-	return(my_console_wait_key(0, 0, NULL));
-}
-#endif
-
-#ifdef CONFIG_KGDB
-static char kgdb_buf[RX_BUF_SIZE], *kgdp;
-static int kgdb_chars;
-
-char
-getDebugChar(void)
-{
-	if (kgdb_chars <= 0) {
-		kgdb_chars = my_console_wait_key(0, 0, kgdb_buf);
-		kgdp = kgdb_buf;
-	}
-	kgdb_chars--;
-
-	return(*kgdp++);
-}
-
-void kgdb_interruptible(int yes)
-{
-	volatile smc_t	*smcp;
-
-	smcp = &cpmp->cp_smc[KGDB_SER_IDX];
-
-	if (yes == 1)
-		smcp->smc_smcm |= SMCM_RX;
-	else
-		smcp->smc_smcm &= ~SMCM_RX;
-}
-
-void kgdb_map_scc(void)
-{
-	struct		serial_state *ser;
-	uint		mem_addr;
-	volatile	cbd_t		*bdp;
-	volatile	smc_uart_t	*up;
-
-	cpmp = (cpm8xx_t *)&(((immap_t *)IMAP_ADDR)->im_cpm);
-
-	/* To avoid data cache CPM DMA coherency problems, allocate a
-	 * buffer in the CPM DPRAM.  This will work until the CPM and
-	 * serial ports are initialized.  At that time a memory buffer
-	 * will be allocated.
-	 * The port is already initialized from the boot procedure, all
-	 * we do here is give it a different buffer and make it a FIFO.
-	 */
-
-	ser = rs_table;
-
-	/* Right now, assume we are using SMCs.
-	*/
-	up = (smc_uart_t *)&cpmp->cp_dparam[ser->port];
-
-	/* Allocate space for an input FIFO, plus a few bytes for output.
-	 * Allocate bytes to maintain word alignment.
-	 */
-	mem_addr = (uint)(&cpmp->cp_dpmem[0xa00]);
-
-	/* Set the physical address of the host memory buffers in
-	 * the buffer descriptors.
-	 */
-	bdp = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];
-	bdp->cbd_bufaddr = mem_addr;
-
-	bdp = (cbd_t *)&cpmp->cp_dpmem[up->smc_tbase];
-	bdp->cbd_bufaddr = mem_addr+RX_BUF_SIZE;
-
-	up->smc_mrblr = RX_BUF_SIZE;		/* receive buffer length */
-	up->smc_maxidl = RX_BUF_SIZE;
-}
-#endif
-
-static struct tty_driver *serial_console_device(struct console *c, int *index)
-{
-	*index = c->index;
-	return serial_driver;
-}
-
-/*
- *	Register console.
- */
-static void __init console_8xx_init(long kmem_start, long kmem_end)
-{
-	register_console(&sercons);
-}
-console_initcall(console_8xx_init);
-#endif
-
-/* Index in baud rate table of the default console baud rate.
-*/
-static	int	baud_idx;
-
-static struct tty_operations rs_8xx_ops = {
-	.open = rs_8xx_open,
-	.close = rs_8xx_close,
-	.write = rs_8xx_write,
-	.put_char = rs_8xx_put_char,
-	.write_room = rs_8xx_write_room,
-	.chars_in_buffer = rs_8xx_chars_in_buffer,
-	.flush_buffer = rs_8xx_flush_buffer,
-	.ioctl = rs_8xx_ioctl,
-	.throttle = rs_8xx_throttle,
-	.unthrottle = rs_8xx_unthrottle,
-	.send_xchar = rs_8xx_send_xchar,
-	.set_termios = rs_8xx_set_termios,
-	.stop = rs_8xx_stop,
-	.start = rs_8xx_start,
-	.hangup = rs_8xx_hangup,
-	.wait_until_sent = rs_8xx_wait_until_sent,
-	.read_proc = rs_8xx_read_proc,
-};
-
-/*
- * The serial driver boot-time initialization code!
- */
-static int __init rs_8xx_init(void)
-{
-	struct serial_state * state;
-	ser_info_t	*info;
-	uint		mem_addr, iobits, dp_offset;
-	int		i, j, idx;
-	ushort		chan;
-	volatile	cbd_t		*bdp;
-	volatile	cpm8xx_t	*cp;
-	volatile	smc_t		*sp;
-	volatile	smc_uart_t	*up;
-	volatile	scc_t		*scp;
-	volatile	scc_uart_t	*sup;
-	volatile	immap_t		*immap;
-
-	serial_driver = alloc_tty_driver(NR_PORTS);
-	if (!serial_driver)
-		return -ENOMEM;
-
-	init_bh(SERIAL_BH, do_serial_bh);
-
-	show_serial_version();
-
-	/* Initialize the tty_driver structure */
-
-	serial_driver->owner = THIS_MODULE;
-	serial_driver->driver_name = "serial";
-	serial_driver->devfs_name = "tts/";
-	serial_driver->name = "ttyS";
-	serial_driver->major = TTY_MAJOR;
-	serial_driver->minor_start = 64;
-	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 =
-		baud_idx | CS8 | CREAD | HUPCL | CLOCAL;
-	serial_driver->flags = TTY_DRIVER_REAL_RAW;
-	tty_set_operations(serial_driver, &rs_8xx_ops);
-
-	if (tty_register_driver(serial_driver))
-		panic("Couldn't register serial driver\n");
-
-	cp = cpmp;	/* Get pointer to Communication Processor */
-	immap = (immap_t *)IMAP_ADDR;	/* and to internal registers */
-
-
-	/* Configure SCC2, SCC3, and SCC4 instead of port A parallel I/O.
-	 */
-#ifdef CONFIG_USE_SCC_IO
-#ifndef CONFIG_MBX
-	/* The "standard" configuration through the 860.
-	*/
-	immap->im_ioport.iop_papar |= 0x00fc;
-	immap->im_ioport.iop_padir &= ~0x00fc;
-	immap->im_ioport.iop_paodr &= ~0x00fc;
-#else
-	/* On the MBX, SCC3 is through Port D.
-	*/
-	immap->im_ioport.iop_papar |= 0x000c;	/* SCC2 on port A */
-	immap->im_ioport.iop_padir &= ~0x000c;
-	immap->im_ioport.iop_paodr &= ~0x000c;
-
-	immap->im_ioport.iop_pdpar |= 0x0030;	/* SCC3 on port D */
-#endif
-
-	/* Since we don't yet do modem control, connect the port C pins
-	 * as general purpose I/O.  This will assert CTS and CD for the
-	 * SCC ports.
-	 */
-	immap->im_ioport.iop_pcdir |= 0x03c6;
-	immap->im_ioport.iop_pcpar &= ~0x03c6;
-
-	/* Connect SCC2 and SCC3 to NMSI.  Connect BRG3 to SCC2 and
-	 * BRG4 to SCC3.
-	 */
-	cp->cp_sicr &= ~0x00ffff00;
-	cp->cp_sicr |= 0x001b1200;
-
-#ifdef CONFIG_PP04
-	/* Frequentis PP04 forced to RS-232 until we know better.
-	 * Port C 12 and 13 low enables RS-232 on SCC3 and SCC4.
-	 */
-	immap->im_ioport.iop_pcdir |= 0x000c;
-	immap->im_ioport.iop_pcpar &= ~0x000c;
-	immap->im_ioport.iop_pcdat &= ~0x000c;
-
-	/* This enables the TX driver.
-	*/
-	cp->cp_pbpar &= ~0x6000;
-	cp->cp_pbdat &= ~0x6000;
-#endif
-#endif
-
-	for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
-		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->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;
-		printk(KERN_INFO "ttyS%d at 0x%04x is a %s\n",
-		       i, (unsigned int)(state->port),
-		       (state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC");
-#ifdef CONFIG_SERIAL_CONSOLE
-		/* If we just printed the message on the console port, and
-		 * we are about to initialize it for general use, we have
-		 * to wait a couple of character times for the CR/NL to
-		 * make it out of the transmit buffer.
-		 */
-		if (i == CONFIG_SERIAL_CONSOLE_PORT)
-			mdelay(2);
-#endif
-		info = kmalloc(sizeof(ser_info_t), GFP_KERNEL);
-		if (info) {
-			__clear_user(info,sizeof(ser_info_t));
-			init_waitqueue_head(&info->open_wait);
-			init_waitqueue_head(&info->close_wait);
-			info->magic = SERIAL_MAGIC;
-			info->flags = state->flags;
-			info->tqueue.routine = do_softint;
-			info->tqueue.data = info;
-			info->tqueue_hangup.routine = do_serial_hangup;
-			info->tqueue_hangup.data = info;
-			info->line = i;
-			info->state = state;
-			state->info = (struct async_struct *)info;
-
-			/* We need to allocate a transmit and receive buffer
-			 * descriptors from dual port ram, and a character
-			 * buffer area from host mem.
-			 */
-			dp_offset = cpm_dpalloc(sizeof(cbd_t) * RX_NUM_FIFO, 8);
-
-			/* Allocate space for FIFOs in the host memory.
-			*/
-			mem_addr = m8xx_cpm_hostalloc(RX_NUM_FIFO * RX_BUF_SIZE);
-			info->rx_va_base = (unsigned char *)mem_addr;
-
-			/* Set the physical address of the host memory
-			 * buffers in the buffer descriptors, and the
-			 * virtual address for us to work with.
-			 */
-			bdp = (cbd_t *)&cp->cp_dpmem[dp_offset];
-			info->rx_cur = info->rx_bd_base = (cbd_t *)bdp;
-
-			for (j=0; j<(RX_NUM_FIFO-1); j++) {
-				bdp->cbd_bufaddr = iopa(mem_addr);
-				bdp->cbd_sc = BD_SC_EMPTY | BD_SC_INTRPT;
-				mem_addr += RX_BUF_SIZE;
-				bdp++;
-			}
-			bdp->cbd_bufaddr = iopa(mem_addr);
-			bdp->cbd_sc = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
-
-			idx = PORT_NUM(info->state->smc_scc_num);
-			if (info->state->smc_scc_num & NUM_IS_SCC) {
-				scp = &cp->cp_scc[idx];
-				sup = (scc_uart_t *)&cp->cp_dparam[state->port];
-				sup->scc_genscc.scc_rbase = dp_offset;
-			}
-			else {
-				sp = &cp->cp_smc[idx];
-				up = (smc_uart_t *)&cp->cp_dparam[state->port];
-				up->smc_rbase = dp_offset;
-			}
-
-			dp_offset = cpm_dpalloc(sizeof(cbd_t) * TX_NUM_FIFO, 8);
-
-			/* Allocate space for FIFOs in the host memory.
-			*/
-			mem_addr = m8xx_cpm_hostalloc(TX_NUM_FIFO * TX_BUF_SIZE);
-			info->tx_va_base = (unsigned char *)mem_addr;
-
-			/* Set the physical address of the host memory
-			 * buffers in the buffer descriptors, and the
-			 * virtual address for us to work with.
-			 */
-			bdp = (cbd_t *)&cp->cp_dpmem[dp_offset];
-			info->tx_cur = info->tx_bd_base = (cbd_t *)bdp;
-
-			for (j=0; j<(TX_NUM_FIFO-1); j++) {
-				bdp->cbd_bufaddr = iopa(mem_addr);
-				bdp->cbd_sc = BD_SC_INTRPT;
-				mem_addr += TX_BUF_SIZE;
-				bdp++;
-			}
-			bdp->cbd_bufaddr = iopa(mem_addr);
-			bdp->cbd_sc = (BD_SC_WRAP | BD_SC_INTRPT);
-
-			if (info->state->smc_scc_num & NUM_IS_SCC) {
-				sup->scc_genscc.scc_tbase = dp_offset;
-
-				/* Set up the uart parameters in the
-				 * parameter ram.
-				 */
-				sup->scc_genscc.scc_rfcr = SMC_EB;
-				sup->scc_genscc.scc_tfcr = SMC_EB;
-
-				/* Set this to 1 for now, so we get single
-				 * character interrupts.  Using idle charater
-				 * time requires some additional tuning.
-				 */
-				sup->scc_genscc.scc_mrblr = 1;
-				sup->scc_maxidl = 0;
-				sup->scc_brkcr = 1;
-				sup->scc_parec = 0;
-				sup->scc_frmec = 0;
-				sup->scc_nosec = 0;
-				sup->scc_brkec = 0;
-				sup->scc_uaddr1 = 0;
-				sup->scc_uaddr2 = 0;
-				sup->scc_toseq = 0;
-				sup->scc_char1 = 0x8000;
-				sup->scc_char2 = 0x8000;
-				sup->scc_char3 = 0x8000;
-				sup->scc_char4 = 0x8000;
-				sup->scc_char5 = 0x8000;
-				sup->scc_char6 = 0x8000;
-				sup->scc_char7 = 0x8000;
-				sup->scc_char8 = 0x8000;
-				sup->scc_rccm = 0xc0ff;
-
-				/* Send the CPM an initialize command.
-				*/
-				chan = scc_chan_map[idx];
-
-				cp->cp_cpcr = mk_cr_cmd(chan,
-						CPM_CR_INIT_TRX) | CPM_CR_FLG;
-				while (cp->cp_cpcr & CPM_CR_FLG);
-
-				/* Set UART mode, 8 bit, no parity, one stop.
-				 * Enable receive and transmit.
-				 */
-				scp->scc_gsmrh = 0;
-				scp->scc_gsmrl =
-					(SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
-				/* Disable all interrupts and clear all pending
-				 * events.
-				 */
-				scp->scc_sccm = 0;
-				scp->scc_scce = 0xffff;
-				scp->scc_dsr = 0x7e7e;
-				scp->scc_pmsr = 0x3000;
-
-				/* If the port is the console, enable Rx and Tx.
-				*/
-#ifdef CONFIG_SERIAL_CONSOLE
-				if (i == CONFIG_SERIAL_CONSOLE_PORT)
-					scp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-#endif
-			}
-			else {
-				/* Configure SMCs Tx/Rx instead of port B
-				 * parallel I/O.  On 823/850 these are on
-				 * port A for SMC2.
-				 */
-#ifndef CONFIG_ALTSMC2
-				iobits = 0xc0 << (idx * 4);
-				cp->cp_pbpar |= iobits;
-				cp->cp_pbdir &= ~iobits;
-				cp->cp_pbodr &= ~iobits;
-#else
-				iobits = 0xc0;
-				if (idx == 0) {
-					/* SMC1 on Port B, like all 8xx.
-					*/
-					cp->cp_pbpar |= iobits;
-					cp->cp_pbdir &= ~iobits;
-					cp->cp_pbodr &= ~iobits;
-				}
-				else {
-					/* SMC2 is on Port A.
-					*/
-					immap->im_ioport.iop_papar |= iobits;
-					immap->im_ioport.iop_padir &= ~iobits;
-					immap->im_ioport.iop_paodr &= ~iobits;
-				}
-#endif /* CONFIG_ALTSMC2 */
-
-				/* Connect the baud rate generator to the
-				 * SMC based upon index in rs_table.  Also
-				 * make sure it is connected to NMSI.
-				 */
-				cp->cp_simode &= ~(0xffff << (idx * 16));
-				cp->cp_simode |= (i << ((idx * 16) + 12));
-
-				up->smc_tbase = dp_offset;
-
-				/* Set up the uart parameters in the
-				 * parameter ram.
-				 */
-				up->smc_rfcr = SMC_EB;
-				up->smc_tfcr = SMC_EB;
-
-				/* Set this to 1 for now, so we get single
-				 * character interrupts.  Using idle charater
-				 * time requires some additional tuning.
-				 */
-				up->smc_mrblr = 1;
-				up->smc_maxidl = 0;
-				up->smc_brkcr = 1;
-
-				/* Send the CPM an initialize command.
-				*/
-				chan = smc_chan_map[idx];
-
-				cp->cp_cpcr = mk_cr_cmd(chan,
-						CPM_CR_INIT_TRX) | CPM_CR_FLG;
-				while (cp->cp_cpcr & CPM_CR_FLG);
-
-				/* Set UART mode, 8 bit, no parity, one stop.
-				 * Enable receive and transmit.
-				 */
-				sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
-
-				/* Disable all interrupts and clear all pending
-				 * events.
-				 */
-				sp->smc_smcm = 0;
-				sp->smc_smce = 0xff;
-
-				/* If the port is the console, enable Rx and Tx.
-				*/
-#ifdef CONFIG_SERIAL_CONSOLE
-				if (i == CONFIG_SERIAL_CONSOLE_PORT)
-					sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
-#endif
-			}
-
-			/* Install interrupt handler.
-			*/
-			cpm_install_handler(state->irq, rs_8xx_interrupt, info);
-
-			/* Set up the baud rate generator.
-			*/
-			m8xx_cpm_setbrg(i, baud_table[baud_idx]);
-
-		}
-	}
-
-	return 0;
-}
-module_init(rs_8xx_init);
-
-/* This must always be called before the rs_8xx_init() function, otherwise
- * it blows away the port control information.
-*/
-static int __init serial_console_setup(struct console *co, char *options)
-{
-	struct		serial_state *ser;
-	uint		mem_addr, bidx, idx, dp_offset;
-	ushort		chan;
-	volatile	cbd_t		*bdp;
-	volatile	cpm8xx_t	*cp;
-	volatile	smc_t		*sp;
-	volatile	scc_t		*scp;
-	volatile	smc_uart_t	*up;
-	volatile	scc_uart_t	*sup;
-	bd_t				*bd;
-
-	bd = (bd_t *)__res;
-
-	for (bidx = 0; bidx < (sizeof(baud_table) / sizeof(int)); bidx++)
-		if (bd->bi_baudrate == baud_table[bidx])
-			break;
-	/* make sure we have a useful value */
-	if (bidx == (sizeof(baud_table) / sizeof(int)))
-		bidx = 13;	/* B9600 */
-
-	co->cflag = CREAD|CLOCAL|bidx|CS8;
-	baud_idx = bidx;
-
-	ser = rs_table + co->index;
-
-	cp = cpmp;	/* Get pointer to Communication Processor */
-
-	idx = PORT_NUM(ser->smc_scc_num);
-	if (ser->smc_scc_num & NUM_IS_SCC) {
-		scp = &cp->cp_scc[idx];
-		sup = (scc_uart_t *)&cp->cp_dparam[ser->port];
-	}
-	else {
-		sp = &cp->cp_smc[idx];
-		up = (smc_uart_t *)&cpmp->cp_dparam[ser->port];
-	}
-
-	/* When we get here, the CPM has been reset, so we need
-	 * to configure the port.
-	 * We need to allocate a transmit and receive buffer descriptor
-	 * from dual port ram, and a character buffer area from host mem.
-	 */
-
-	/* Allocate space for two FIFOs.  We can't allocate from host
-	 * memory yet because vm allocator isn't initialized
-	 * during this early console init.
-	 */
-	dp_offset = cpm_dpalloc(8, 8);
-	mem_addr = (uint)(&cpmp->cp_dpmem[dp_offset]);
-
-	/* Allocate space for two buffer descriptors in the DP ram.
-	*/
-	dp_offset = cpm_dpalloc(sizeof(cbd_t) * 2, 8);
-
-	/* Set the physical address of the host memory buffers in
-	 * the buffer descriptors.
-	 */
-	bdp = (cbd_t *)&cp->cp_dpmem[dp_offset];
-	bdp->cbd_bufaddr = iopa(mem_addr);
-	(bdp+1)->cbd_bufaddr = iopa(mem_addr+4);
-
-	consinfo.rx_va_base = mem_addr;
-	consinfo.rx_bd_base = bdp;
-	consinfo.tx_va_base = mem_addr + 4;
-	consinfo.tx_bd_base = bdp+1;
-
-	/* For the receive, set empty and wrap.
-	 * For transmit, set wrap.
-	 */
-	bdp->cbd_sc = BD_SC_EMPTY | BD_SC_WRAP;
-	(bdp+1)->cbd_sc = BD_SC_WRAP;
-
-	/* Set up the uart parameters in the parameter ram.
-	*/
-	if (ser->smc_scc_num & NUM_IS_SCC) {
-
-		sup->scc_genscc.scc_rbase = dp_offset;
-		sup->scc_genscc.scc_tbase = dp_offset + sizeof(cbd_t);
-
-		/* Set up the uart parameters in the
-		 * parameter ram.
-		 */
-		sup->scc_genscc.scc_rfcr = SMC_EB;
-		sup->scc_genscc.scc_tfcr = SMC_EB;
-
-		/* Set this to 1 for now, so we get single
-		 * character interrupts.  Using idle charater
-		 * time requires some additional tuning.
-		 */
-		sup->scc_genscc.scc_mrblr = 1;
-		sup->scc_maxidl = 0;
-		sup->scc_brkcr = 1;
-		sup->scc_parec = 0;
-		sup->scc_frmec = 0;
-		sup->scc_nosec = 0;
-		sup->scc_brkec = 0;
-		sup->scc_uaddr1 = 0;
-		sup->scc_uaddr2 = 0;
-		sup->scc_toseq = 0;
-		sup->scc_char1 = 0x8000;
-		sup->scc_char2 = 0x8000;
-		sup->scc_char3 = 0x8000;
-		sup->scc_char4 = 0x8000;
-		sup->scc_char5 = 0x8000;
-		sup->scc_char6 = 0x8000;
-		sup->scc_char7 = 0x8000;
-		sup->scc_char8 = 0x8000;
-		sup->scc_rccm = 0xc0ff;
-
-		/* Send the CPM an initialize command.
-		*/
-		chan = scc_chan_map[idx];
-
-		cp->cp_cpcr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
-		while (cp->cp_cpcr & CPM_CR_FLG);
-
-		/* Set UART mode, 8 bit, no parity, one stop.
-		 * Enable receive and transmit.
-		 */
-		scp->scc_gsmrh = 0;
-		scp->scc_gsmrl =
-			(SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
-		/* Disable all interrupts and clear all pending
-		 * events.
-		 */
-		scp->scc_sccm = 0;
-		scp->scc_scce = 0xffff;
-		scp->scc_dsr = 0x7e7e;
-		scp->scc_pmsr = 0x3000;
-
-		scp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-
-	}
-	else {
-		up->smc_rbase = dp_offset;	/* Base of receive buffer desc. */
-		up->smc_tbase = dp_offset+sizeof(cbd_t);	/* Base of xmt buffer desc. */
-		up->smc_rfcr = SMC_EB;
-		up->smc_tfcr = SMC_EB;
-
-		/* Set this to 1 for now, so we get single character interrupts.
-		*/
-		up->smc_mrblr = 1;		/* receive buffer length */
-		up->smc_maxidl = 0;		/* wait forever for next char */
-
-		/* Send the CPM an initialize command.
-		*/
-		chan = smc_chan_map[idx];
-		cp->cp_cpcr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
-		printk("%s", "");
-		while (cp->cp_cpcr & CPM_CR_FLG);
-
-		/* Set UART mode, 8 bit, no parity, one stop.
-		 * Enable receive and transmit.
-		 */
-		sp->smc_smcmr = smcr_mk_clen(9) |  SMCMR_SM_UART;
-
-		/* And finally, enable Rx and Tx.
-		*/
-		sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
-	}
-
-	/* Set up the baud rate generator.
-	*/
-	m8xx_cpm_setbrg((ser - rs_table), bd->bi_baudrate);
-
-	return 0;
-}
diff -Nru a/arch/ppc/Kconfig b/arch/ppc/Kconfig
--- a/arch/ppc/Kconfig	2004-12-24 13:37:30 -08:00
+++ b/arch/ppc/Kconfig	2004-12-24 13:37:30 -08:00
@@ -11,6 +11,10 @@
 config UID16
 	bool
 
+config GENERIC_HARDIRQS
+	bool
+	default y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 
@@ -70,6 +74,7 @@
 	bool "POWER4 and 970 (G5)"
 
 config 8xx
+	depends on BROKEN
 	bool "8xx"
 
 config E500
@@ -184,18 +189,6 @@
 	  here.  Saying Y here will not hurt performance (on any machine) but
 	  will increase the size of the kernel.
 
-config CPU_FREQ
-	bool "CPU Frequency scaling"
-	help
-	  Clock scaling allows you to change the clock speed of CPUs on the
-	  fly. This is a nice method to save battery power on notebooks,
-	  because the lower the clock speed, the less power the CPU consumes.
-
-	  For more information, take a look at <file:Documentation/cpu-freq> or
-	  at <http://www.brodo.de/cpufreq/>
-
-	  If in doubt, say N.
-
 source "drivers/cpufreq/Kconfig"
 
 config CPU_FREQ_PMAC
@@ -751,16 +744,6 @@
 config PC_KEYBOARD
 	bool "PC PS/2 style Keyboard"
 	depends on 4xx || CPM2
-
-config SERIAL_CONSOLE
-	bool
-	depends on 8xx
-	default y
-
-config SERIAL_CONSOLE_BAUD
-	int
-	depends on EV64260
-	default "115200"
 
 config PPCBUG_NVRAM
 	bool "Enable reading PPCBUG NVRAM during boot" if PPLUS || LOPEC
diff -Nru a/arch/ppc/Kconfig.debug b/arch/ppc/Kconfig.debug
--- a/arch/ppc/Kconfig.debug	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/Kconfig.debug	2004-12-24 13:37:19 -08:00
@@ -53,18 +53,6 @@
 	  Unless you are intending to debug the kernel with one of these
 	  machines, say N here.
 
-config SCHEDSTATS
-	bool "Collect scheduler statistics"
-	depends on DEBUG_KERNEL && PROC_FS
-	help
-	  If you say Y here, additional code will be inserted into the
-	  scheduler and related routines to collect statistics about
-	  scheduler behavior and provide them in /proc/schedstat.  These
-	  stats may be useful for both tuning and debugging the scheduler
-	  If you aren't debugging the scheduler or trying to tune a specific
-	  application, you can say N to avoid the very slight overhead
-	  this adds.
-
 config BOOTX_TEXT
 	bool "Support for early boot text console (BootX or OpenFirmware only)"
 	depends PPC_OF
@@ -78,7 +66,7 @@
 
 config PPC_OCP
 	bool
-	depends on IBM_OCP || FSL_OCP
+	depends on IBM_OCP || FSL_OCP || XILINX_OCP
 	default y
 
 endmenu
diff -Nru a/arch/ppc/boot/common/util.S b/arch/ppc/boot/common/util.S
--- a/arch/ppc/boot/common/util.S	2004-12-24 13:37:33 -08:00
+++ b/arch/ppc/boot/common/util.S	2004-12-24 13:37:33 -08:00
@@ -27,6 +27,7 @@
 
 	.text
 
+#ifdef CONFIG_6xx
 	.globl	disable_6xx_mmu
 disable_6xx_mmu:
 	/* Establish default MSR value, exception prefix 0xFFF.
@@ -94,6 +95,7 @@
 	sync
 	isync
 	blr
+#endif
 
 	.globl	_setup_L2CR
 _setup_L2CR:
diff -Nru a/arch/ppc/boot/lib/Makefile b/arch/ppc/boot/lib/Makefile
--- a/arch/ppc/boot/lib/Makefile	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc/boot/lib/Makefile	2004-12-24 13:37:18 -08:00
@@ -2,9 +2,22 @@
 # Makefile for some libs needed by zImage.
 #
 
-CFLAGS_kbd.o	+= -Idrivers/char
+CFLAGS_kbd.o	:= -Idrivers/char
+CFLAGS_vreset.o := -I$(srctree)/arch/ppc/boot/include
 
-lib-y := $(addprefix ../../../../lib/zlib_inflate/, \
-           infblock.o infcodes.o inffast.o inflate.o inftrees.o infutil.o)
-lib-y += div64.o
+zlib  := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
+	 
+lib-y += $(zlib:.c=.o) div64.o
 lib-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o
+
+
+# zlib files needs header from their original place
+EXTRA_CFLAGS += -Ilib/zlib_inflate
+
+quiet_cmd_copy_zlib = COPY    $@
+      cmd_copy_zlib = cat $< > $@
+
+$(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
+	$(call cmd,copy_zlib)
+
+clean-files := $(zlib)
diff -Nru a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
--- a/arch/ppc/boot/simple/Makefile	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc/boot/simple/Makefile	2004-12-24 13:36:16 -08:00
@@ -41,7 +41,7 @@
 # if present on 'classic' PPC.
 cacheflag-y	:= -DCLEAR_CACHES=""
 # This file will flush / disable the L2, and L3 if present.
-clear_L2_L3	:= $(boot)/simple/clear.S
+clear_L2_L3	:= $(srctree)/$(boot)/simple/clear.S
 
 #
 # See arch/ppc/kconfig and arch/ppc/platforms/Kconfig
diff -Nru a/arch/ppc/boot/simple/embed_config.c b/arch/ppc/boot/simple/embed_config.c
--- a/arch/ppc/boot/simple/embed_config.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc/boot/simple/embed_config.c	2004-12-24 13:36:18 -08:00
@@ -749,25 +749,25 @@
 	static const unsigned long line_size = 32;
 	static const unsigned long congruence_classes = 256;
 	unsigned long addr;
-	u_char *cp;
-	int i;
+	unsigned long dccr;
 	bd_t *bd;
 
 	/*
-	 * At one point, we were getting machine checks.  Linux was not
-	 * invalidating the data cache before it was enabled.  The
-	 * following code was added to do that.  Soon after we had done
-	 * that, we found the real reasons for the machine checks.  I've
-	 * run the kernel a few times with the following code
-	 * temporarily removed without any apparent problems.  However,
-	 * I objdump'ed the kernel and boot code and found out that
-	 * there were no other dccci's anywhere, so I put the code back
-	 * in and have been reluctant to remove it.  It seems safer to
-	 * just leave it here.
+	 * Invalidate the data cache if the data cache is turned off.
+	 * - The 405 core does not invalidate the data cache on power-up
+	 *   or reset but does turn off the data cache. We cannot assume
+	 *   that the cache contents are valid.
+	 * - If the data cache is turned on this must have been done by
+	 *   a bootloader and we assume that the cache contents are
+	 *   valid.
 	 */
-	for (addr = 0;
-	     addr < (congruence_classes * line_size); addr += line_size) {
-	      __asm__("dccci 0,%0": :"b"(addr));
+	__asm__("mfdccr %0": "=r" (dccr));
+	if (dccr == 0) {
+		for (addr = 0;
+		     addr < (congruence_classes * line_size);
+		     addr += line_size) {
+			__asm__("dccci 0,%0": :"b"(addr));
+		}
 	}
 
 	bd = &bdinfo;
@@ -775,6 +775,9 @@
 	bd->bi_memsize = XPAR_DDR_0_SIZE;
 	bd->bi_intfreq = XPAR_CORE_CLOCK_FREQ_HZ;
 	bd->bi_busfreq = XPAR_PLB_CLOCK_FREQ_HZ;
+	bd->bi_pci_busfreq = XPAR_PCI_0_CLOCK_FREQ_HZ;
+	timebase_period_ns = 1000000000 / bd->bi_tbfreq;
+	/* see bi_tbfreq definition in arch/ppc/platforms/4xx/xilinx_ml300.h */
 }
 #endif /* CONFIG_XILINX_ML300 */
 
diff -Nru a/arch/ppc/boot/simple/misc-embedded.c b/arch/ppc/boot/simple/misc-embedded.c
--- a/arch/ppc/boot/simple/misc-embedded.c	2004-12-24 13:36:19 -08:00
+++ b/arch/ppc/boot/simple/misc-embedded.c	2004-12-24 13:36:19 -08:00
@@ -218,7 +218,7 @@
 	puts("done.\n");
 	{
 		struct bi_record *rec;
-		unsigned long initrd_loc;
+		unsigned long initrd_loc = 0;
 		unsigned long rec_loc = _ALIGN((unsigned long)(zimage_size) +
 				(1 << 20) - 1, (1 << 20));
 		rec = (struct bi_record *)rec_loc;
diff -Nru a/arch/ppc/boot/simple/mpc52xx_tty.c b/arch/ppc/boot/simple/mpc52xx_tty.c
--- a/arch/ppc/boot/simple/mpc52xx_tty.c	2004-12-24 13:37:43 -08:00
+++ b/arch/ppc/boot/simple/mpc52xx_tty.c	2004-12-24 13:37:43 -08:00
@@ -17,6 +17,7 @@
 #include <asm/mpc52xx.h>
 #include <asm/mpc52xx_psc.h>
 #include <asm/serial.h>
+#include <asm/io.h>
 #include <asm/time.h>
 
 #if MPC52xx_PF_CONSOLE_PORT == 0
diff -Nru a/arch/ppc/boot/utils/mkbugboot.c b/arch/ppc/boot/utils/mkbugboot.c
--- a/arch/ppc/boot/utils/mkbugboot.c	2004-12-24 13:36:57 -08:00
+++ b/arch/ppc/boot/utils/mkbugboot.c	2004-12-24 13:36:57 -08:00
@@ -96,7 +96,7 @@
   uint8_t header_block[HEADER_SIZE];
   bug_boot_header_t *bbh = (bug_boot_header_t *)&header_block[0];
 
-  bzero(header_block, HEADER_SIZE);
+  memset(header_block, 0, HEADER_SIZE);
 
   /* Fill in the PPCBUG ROM boot header */
   strncpy(bbh->magic_word, "BOOT", 4);		/* PPCBUG magic word */
diff -Nru a/arch/ppc/configs/FADS_defconfig b/arch/ppc/configs/FADS_defconfig
--- a/arch/ppc/configs/FADS_defconfig	2004-12-24 13:37:03 -08:00
+++ b/arch/ppc/configs/FADS_defconfig	2004-12-24 13:37:03 -08:00
@@ -296,24 +296,26 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+CONFIG_SERIAL_CPM_SMC2=y
+# CONFIG_SERIAL_CPM_ALT_SMC2 is not set
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -478,10 +480,6 @@
 # CONFIG_SCC3_ENET is not set
 # CONFIG_FEC_ENET is not set
 CONFIG_ENET_BIG_BUFFERS=y
-CONFIG_SMC2_UART=y
-# CONFIG_ALTSMC2 is not set
-# CONFIG_CONS_SMC2 is not set
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/IVMS8_defconfig b/arch/ppc/configs/IVMS8_defconfig
--- a/arch/ppc/configs/IVMS8_defconfig	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc/configs/IVMS8_defconfig	2004-12-24 13:37:01 -08:00
@@ -320,24 +320,25 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+# CONFIG_SERIAL_CPM_SMC2 is not set
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -507,8 +508,6 @@
 CONFIG_FEC_LXT971=y
 CONFIG_FEC_QS6612=y
 CONFIG_ENET_BIG_BUFFERS=y
-# CONFIG_SMC2_UART is not set
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/SM850_defconfig b/arch/ppc/configs/SM850_defconfig
--- a/arch/ppc/configs/SM850_defconfig	2004-12-24 13:36:47 -08:00
+++ b/arch/ppc/configs/SM850_defconfig	2004-12-24 13:36:47 -08:00
@@ -92,7 +92,8 @@
 # Parallel port support
 #
 # CONFIG_PARPORT is not set
-# CONFIG_CMDLINE_BOOL is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttyCPM1"
 
 #
 # Advanced setup
@@ -297,24 +298,26 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+CONFIG_SERIAL_CPM_SMC2=y
+CONFIG_SERIAL_CPM_ALT_SMC2=y
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -479,10 +482,6 @@
 CONFIG_SCC3_ENET=y
 # CONFIG_FEC_ENET is not set
 CONFIG_ENET_BIG_BUFFERS=y
-CONFIG_SMC2_UART=y
-CONFIG_ALTSMC2=y
-CONFIG_CONS_SMC2=y
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/SPD823TS_defconfig b/arch/ppc/configs/SPD823TS_defconfig
--- a/arch/ppc/configs/SPD823TS_defconfig	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc/configs/SPD823TS_defconfig	2004-12-24 13:37:29 -08:00
@@ -296,24 +296,26 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+# CONFIG_SERIAL_CPM_SMC2 is not set
+CONFIG_SERIAL_CPM_ALT_SMC2=y
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -478,10 +480,6 @@
 # CONFIG_SCC3_ENET is not set
 # CONFIG_FEC_ENET is not set
 CONFIG_ENET_BIG_BUFFERS=y
-CONFIG_SMC2_UART=y
-CONFIG_ALTSMC2=y
-# CONFIG_CONS_SMC2 is not set
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/TQM823L_defconfig b/arch/ppc/configs/TQM823L_defconfig
--- a/arch/ppc/configs/TQM823L_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc/configs/TQM823L_defconfig	2004-12-24 13:36:31 -08:00
@@ -297,24 +297,26 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+CONFIG_SERIAL_CPM_SMC2=y
+CONFIG_SERIAL_CPM_ALT_SMC2=y
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -479,10 +481,6 @@
 # CONFIG_SCC3_ENET is not set
 # CONFIG_FEC_ENET is not set
 CONFIG_ENET_BIG_BUFFERS=y
-CONFIG_SMC2_UART=y
-CONFIG_ALTSMC2=y
-# CONFIG_CONS_SMC2 is not set
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/TQM850L_defconfig b/arch/ppc/configs/TQM850L_defconfig
--- a/arch/ppc/configs/TQM850L_defconfig	2004-12-24 13:36:59 -08:00
+++ b/arch/ppc/configs/TQM850L_defconfig	2004-12-24 13:36:59 -08:00
@@ -297,24 +297,26 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+CONFIG_SERIAL_CPM_SMC2=y
+CONFIG_SERIAL_CPM_ALT_SMC2=y
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -479,10 +481,6 @@
 # CONFIG_SCC3_ENET is not set
 # CONFIG_FEC_ENET is not set
 CONFIG_ENET_BIG_BUFFERS=y
-CONFIG_SMC2_UART=y
-CONFIG_ALTSMC2=y
-# CONFIG_CONS_SMC2 is not set
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/TQM860L_defconfig b/arch/ppc/configs/TQM860L_defconfig
--- a/arch/ppc/configs/TQM860L_defconfig	2004-12-24 13:36:32 -08:00
+++ b/arch/ppc/configs/TQM860L_defconfig	2004-12-24 13:36:32 -08:00
@@ -321,24 +321,25 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+CONFIG_SERIAL_CPM_SMC2=y
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=32
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -508,10 +509,6 @@
 # CONFIG_SCC3_ENET is not set
 # CONFIG_FEC_ENET is not set
 CONFIG_ENET_BIG_BUFFERS=y
-CONFIG_SMC2_UART=y
-# CONFIG_ALTSMC2 is not set
-# CONFIG_CONS_SMC2 is not set
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/bseip_defconfig b/arch/ppc/configs/bseip_defconfig
--- a/arch/ppc/configs/bseip_defconfig	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc/configs/bseip_defconfig	2004-12-24 13:36:31 -08:00
@@ -293,24 +293,25 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+CONFIG_SERIAL_CPM_SMC2=y
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -476,10 +477,6 @@
 # CONFIG_SCC3_ENET is not set
 # CONFIG_FEC_ENET is not set
 # CONFIG_ENET_BIG_BUFFERS is not set
-CONFIG_SMC2_UART=y
-# CONFIG_ALTSMC2 is not set
-# CONFIG_CONS_SMC2 is not set
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/mbx_defconfig b/arch/ppc/configs/mbx_defconfig
--- a/arch/ppc/configs/mbx_defconfig	2004-12-24 13:36:55 -08:00
+++ b/arch/ppc/configs/mbx_defconfig	2004-12-24 13:36:55 -08:00
@@ -290,23 +290,25 @@
 #
 
 #
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_UNIX98_PTYS is not set
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+CONFIG_SERIAL_CPM_SCC2=y
+CONFIG_SERIAL_CPM_SCC3=y
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+CONFIG_SERIAL_CPM_SMC2=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # I2C support
@@ -470,10 +472,6 @@
 # CONFIG_SCC3_ENET is not set
 # CONFIG_FEC_ENET is not set
 CONFIG_ENET_BIG_BUFFERS=y
-CONFIG_SMC2_UART=y
-# CONFIG_ALTSMC2 is not set
-# CONFIG_CONS_SMC2 is not set
-CONFIG_USE_SCC_IO=y
 
 #
 # Generic MPC8xx Options
diff -Nru a/arch/ppc/configs/rpxcllf_defconfig b/arch/ppc/configs/rpxcllf_defconfig
--- a/arch/ppc/configs/rpxcllf_defconfig	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc/configs/rpxcllf_defconfig	2004-12-24 13:37:18 -08:00
@@ -1,26 +1,49 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1
+# Mon Nov  1 16:41:04 2004
 #
 CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
 CONFIG_HAVE_DEC_LOCK=y
+CONFIG_PPC=y
+CONFIG_PPC32=y
+CONFIG_GENERIC_NVRAM=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
+# CONFIG_CLEAN_COMPILE is not set
+CONFIG_BROKEN=y
+CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
-CONFIG_SWAP=y
+CONFIG_LOCALVERSION=""
+# CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+# CONFIG_KOBJECT_UEVENT is not set
+# CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
-CONFIG_FUTEX=y
+# CONFIG_KALLSYMS is not set
+# CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+# CONFIG_SHMEM is not set
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_TINY_SHMEM=y
 
 #
 # Loadable module support
@@ -28,21 +51,23 @@
 # CONFIG_MODULES is not set
 
 #
-# Platform support
+# Processor
 #
-CONFIG_PPC=y
-CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_40x is not set
+# CONFIG_44x is not set
 # CONFIG_POWER3 is not set
+# CONFIG_POWER4 is not set
 CONFIG_8xx=y
+# CONFIG_E500 is not set
+CONFIG_MATH_EMULATION=y
+# CONFIG_CPU_FREQ is not set
+CONFIG_EMBEDDEDBOOT=y
+CONFIG_NOT_COHERENT_CACHE=y
 
 #
-# IBM 4xx options
+# Platform options
 #
-CONFIG_EMBEDDEDBOOT=y
-CONFIG_SERIAL_CONSOLE=y
-CONFIG_NOT_COHERENT_CACHE=y
 # CONFIG_RPXLITE is not set
 CONFIG_RPXCLASSIC=y
 # CONFIG_BSEIP is not set
@@ -66,27 +91,17 @@
 # CONFIG_WINCEPT is not set
 # CONFIG_SMP is not set
 # CONFIG_PREEMPT is not set
-CONFIG_MATH_EMULATION=y
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
 # CONFIG_HIGHMEM is not set
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-# CONFIG_PCI_QSPAN is not set
-CONFIG_KCORE_ELF=y
 CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
 # CONFIG_BINFMT_MISC is not set
-# CONFIG_HOTPLUG is not set
+# CONFIG_CMDLINE_BOOL is not set
 
 #
-# Parallel port support
+# Bus options
 #
-# CONFIG_PARPORT is not set
-# CONFIG_CMDLINE_BOOL is not set
+# CONFIG_PCI is not set
+# CONFIG_PCI_DOMAINS is not set
+# CONFIG_PCI_QSPAN is not set
 
 #
 # Advanced setup
@@ -100,52 +115,89 @@
 CONFIG_LOWMEM_SIZE=0x30000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_TASK_SIZE=0x80000000
+CONFIG_CONSISTENT_START=0xff100000
+CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_BOOT_LOAD=0x00400000
 
 #
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+
+#
 # Memory Technology Devices (MTD)
 #
 # CONFIG_MTD is not set
 
 #
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
 # Plug and Play support
 #
-# CONFIG_PNP is not set
 
 #
 # Block devices
 #
 # CONFIG_BLK_DEV_FD is not set
 CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP 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
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_LBD is not set
+# CONFIG_CDROM_PKTCDVD is not set
 
 #
-# Multi-device support (RAID and LVM)
+# IO Schedulers
 #
-# CONFIG_MD is not set
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
-# ATA/IDE/MFM/RLL support
+# ATA/ATAPI/MFM/RLL support
 #
 # CONFIG_IDE is not set
 
 #
-# SCSI support
+# SCSI device support
 #
 # CONFIG_SCSI is not set
 
 #
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
 # Fusion MPT device support
 #
 
 #
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
 # I2O device support
 #
 
 #
+# Macintosh device drivers
+#
+
+#
 # Networking support
 #
 CONFIG_NET=y
@@ -156,66 +208,70 @@
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 # CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
 CONFIG_UNIX=y
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=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=y
+# CONFIG_SYN_COOKIES is not set
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
 # CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
+# CONFIG_NETFILTER is not set
 
 #
 # SCTP Configuration (EXPERIMENTAL)
 #
-CONFIG_IPV6_SCTP__=y
 # CONFIG_IP_SCTP is not set
 # CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
 # CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
 # CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
 #
 # CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
+# CONFIG_MII is not set
 # CONFIG_OAKNET is not set
 
 #
@@ -225,48 +281,34 @@
 #
 # Ethernet (10000 Mbit)
 #
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
 
 #
-# Wireless LAN (non-hamradio)
+# Token Ring devices
 #
-# CONFIG_NET_RADIO is not set
 
 #
-# Token Ring devices (depends on LLC=y)
+# Wireless LAN (non-hamradio)
 #
-# CONFIG_SHAPER is not set
+# CONFIG_NET_RADIO 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
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
 #
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
+# CONFIG_ISDN is not set
 
 #
-# Old CD-ROM drivers (not SCSI, not IDE)
+# Telephony Support
 #
-# CONFIG_CD_NO_IDESCSI is not set
+# CONFIG_PHONE is not set
 
 #
 # Input device support
@@ -283,54 +325,38 @@
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
 # CONFIG_SERIO is not set
+# CONFIG_SERIO_I8042 is not set
 
 #
 # Input Device Drivers
 #
 
 #
-# Macintosh device drivers
-#
-
-#
 # Character devices
 #
+# CONFIG_VT is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+CONFIG_SERIAL_CPM_SCC2=y
+CONFIG_SERIAL_CPM_SCC3=y
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+CONFIG_SERIAL_CPM_SMC2=y
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # IPMI
@@ -346,16 +372,27 @@
 # CONFIG_GEN_RTC_X 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
 # CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
 
 #
 # Multimedia devices
@@ -368,6 +405,27 @@
 # CONFIG_DVB is not set
 
 #
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
 # File systems
 #
 CONFIG_EXT2_FS=y
@@ -385,6 +443,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -397,17 +456,22 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
 # Pseudo filesystems
 #
 CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
 # CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
 #
@@ -416,6 +480,7 @@
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
@@ -432,17 +497,18 @@
 CONFIG_NFS_FS=y
 # CONFIG_NFS_V3 is not set
 # CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
 # CONFIG_AFS_FS is not set
 
 #
@@ -456,16 +522,15 @@
 # CONFIG_MAC_PARTITION is not set
 # CONFIG_MSDOS_PARTITION is not set
 # CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
 # CONFIG_SGI_PARTITION is not set
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
 # CONFIG_EFI_PARTITION is not set
 
 #
-# Sound
+# Native Language Support
 #
-# CONFIG_SOUND is not set
+# CONFIG_NLS is not set
 
 #
 # MPC8xx CPM Options
@@ -477,42 +542,38 @@
 CONFIG_FEC_ENET=y
 # CONFIG_USE_MDIO is not set
 CONFIG_ENET_BIG_BUFFERS=y
-CONFIG_SMC2_UART=y
-# CONFIG_ALTSMC2 is not set
-# CONFIG_CONS_SMC2 is not set
-CONFIG_USE_SCC_IO=y
 
 #
 # Generic MPC8xx Options
 #
 CONFIG_8xx_COPYBACK=y
 # CONFIG_8xx_CPU6 is not set
-# CONFIG_UCODE_PATCH is not set
-
-#
-# USB support
-#
-# CONFIG_USB_GADGET is not set
+CONFIG_NO_UCODE_PATCH=y
+# CONFIG_USB_SOF_UCODE_PATCH is not set
+# CONFIG_I2C_SPI_UCODE_PATCH is not set
+# CONFIG_I2C_SPI_SMC1_UCODE_PATCH is not set
 
 #
-# Bluetooth support
+# Library routines
 #
-# CONFIG_BT is not set
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC32 is not set
+# CONFIG_LIBCRC32C is not set
 
 #
-# Library routines
+# Profiling support
 #
-# CONFIG_CRC32 is not set
+# CONFIG_PROFILING is not set
 
 #
 # Kernel hacking
 #
 # CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/ppc/configs/rpxlite_defconfig b/arch/ppc/configs/rpxlite_defconfig
--- a/arch/ppc/configs/rpxlite_defconfig	2004-12-24 13:37:04 -08:00
+++ b/arch/ppc/configs/rpxlite_defconfig	2004-12-24 13:37:04 -08:00
@@ -1,26 +1,49 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.10-rc1
+# Mon Nov  1 16:41:09 2004
 #
 CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
 CONFIG_HAVE_DEC_LOCK=y
+CONFIG_PPC=y
+CONFIG_PPC32=y
+CONFIG_GENERIC_NVRAM=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
+# CONFIG_CLEAN_COMPILE is not set
+CONFIG_BROKEN=y
+CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
 #
-CONFIG_SWAP=y
+CONFIG_LOCALVERSION=""
+# CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+# CONFIG_KOBJECT_UEVENT is not set
+# CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
-CONFIG_FUTEX=y
+# CONFIG_KALLSYMS is not set
+# CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+# CONFIG_SHMEM is not set
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_TINY_SHMEM=y
 
 #
 # Loadable module support
@@ -28,21 +51,23 @@
 # CONFIG_MODULES is not set
 
 #
-# Platform support
+# Processor
 #
-CONFIG_PPC=y
-CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_40x is not set
+# CONFIG_44x is not set
 # CONFIG_POWER3 is not set
+# CONFIG_POWER4 is not set
 CONFIG_8xx=y
+# CONFIG_E500 is not set
+CONFIG_MATH_EMULATION=y
+# CONFIG_CPU_FREQ is not set
+CONFIG_EMBEDDEDBOOT=y
+CONFIG_NOT_COHERENT_CACHE=y
 
 #
-# IBM 4xx options
+# Platform options
 #
-CONFIG_EMBEDDEDBOOT=y
-CONFIG_SERIAL_CONSOLE=y
-CONFIG_NOT_COHERENT_CACHE=y
 CONFIG_RPXLITE=y
 # CONFIG_RPXCLASSIC is not set
 # CONFIG_BSEIP is not set
@@ -66,27 +91,17 @@
 # CONFIG_WINCEPT is not set
 # CONFIG_SMP is not set
 # CONFIG_PREEMPT is not set
-CONFIG_MATH_EMULATION=y
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
 # CONFIG_HIGHMEM is not set
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-# CONFIG_PCI_QSPAN is not set
-CONFIG_KCORE_ELF=y
 CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
 # CONFIG_BINFMT_MISC is not set
-# CONFIG_HOTPLUG is not set
+# CONFIG_CMDLINE_BOOL is not set
 
 #
-# Parallel port support
+# Bus options
 #
-# CONFIG_PARPORT is not set
-# CONFIG_CMDLINE_BOOL is not set
+# CONFIG_PCI is not set
+# CONFIG_PCI_DOMAINS is not set
+# CONFIG_PCI_QSPAN is not set
 
 #
 # Advanced setup
@@ -100,52 +115,89 @@
 CONFIG_LOWMEM_SIZE=0x30000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_TASK_SIZE=0x80000000
+CONFIG_CONSISTENT_START=0xff100000
+CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_BOOT_LOAD=0x00400000
 
 #
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+
+#
 # Memory Technology Devices (MTD)
 #
 # CONFIG_MTD is not set
 
 #
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
 # Plug and Play support
 #
-# CONFIG_PNP is not set
 
 #
 # Block devices
 #
 # CONFIG_BLK_DEV_FD is not set
 CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP 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
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_LBD is not set
+# CONFIG_CDROM_PKTCDVD is not set
 
 #
-# Multi-device support (RAID and LVM)
+# IO Schedulers
 #
-# CONFIG_MD is not set
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
-# ATA/IDE/MFM/RLL support
+# ATA/ATAPI/MFM/RLL support
 #
 # CONFIG_IDE is not set
 
 #
-# SCSI support
+# SCSI device support
 #
 # CONFIG_SCSI is not set
 
 #
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
 # Fusion MPT device support
 #
 
 #
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
 # I2O device support
 #
 
 #
+# Macintosh device drivers
+#
+
+#
 # Networking support
 #
 CONFIG_NET=y
@@ -156,60 +208,64 @@
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 # CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
 CONFIG_UNIX=y
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=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=y
+# CONFIG_SYN_COOKIES is not set
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
 # CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
+# CONFIG_NETFILTER is not set
 
 #
 # SCTP Configuration (EXPERIMENTAL)
 #
-CONFIG_IPV6_SCTP__=y
 # CONFIG_IP_SCTP is not set
 # CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
 # CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
 # CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
 #
 # CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
 
 #
 # Ethernet (10 or 100Mbit)
@@ -225,48 +281,34 @@
 #
 # Ethernet (10000 Mbit)
 #
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
 
 #
-# Wireless LAN (non-hamradio)
+# Token Ring devices
 #
-# CONFIG_NET_RADIO is not set
 
 #
-# Token Ring devices (depends on LLC=y)
+# Wireless LAN (non-hamradio)
 #
-# CONFIG_SHAPER is not set
+# CONFIG_NET_RADIO 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
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
 #
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
+# CONFIG_ISDN is not set
 
 #
-# Old CD-ROM drivers (not SCSI, not IDE)
+# Telephony Support
 #
-# CONFIG_CD_NO_IDESCSI is not set
+# CONFIG_PHONE is not set
 
 #
 # Input device support
@@ -283,54 +325,38 @@
 # CONFIG_GAMEPORT is not set
 CONFIG_SOUND_GAMEPORT=y
 # CONFIG_SERIO is not set
+# CONFIG_SERIO_I8042 is not set
 
 #
 # Input Device Drivers
 #
 
 #
-# Macintosh device drivers
-#
-
-#
 # Character devices
 #
+# CONFIG_VT is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_CPM=y
+CONFIG_SERIAL_CPM_CONSOLE=y
+# CONFIG_SERIAL_CPM_SCC1 is not set
+# CONFIG_SERIAL_CPM_SCC2 is not set
+# CONFIG_SERIAL_CPM_SCC3 is not set
+# CONFIG_SERIAL_CPM_SCC4 is not set
+CONFIG_SERIAL_CPM_SMC1=y
+# CONFIG_SERIAL_CPM_SMC2 is not set
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # IPMI
@@ -346,16 +372,27 @@
 # CONFIG_GEN_RTC_X 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
 # CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
 
 #
 # Multimedia devices
@@ -368,6 +405,27 @@
 # CONFIG_DVB is not set
 
 #
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
 # File systems
 #
 CONFIG_EXT2_FS=y
@@ -385,6 +443,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -397,17 +456,22 @@
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
 # Pseudo filesystems
 #
 CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
 # CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
 #
@@ -416,6 +480,7 @@
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
@@ -432,17 +497,18 @@
 CONFIG_NFS_FS=y
 # CONFIG_NFS_V3 is not set
 # CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 # CONFIG_EXPORTFS is not set
 CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
 # CONFIG_AFS_FS is not set
 
 #
@@ -456,16 +522,15 @@
 # CONFIG_MAC_PARTITION is not set
 # CONFIG_MSDOS_PARTITION is not set
 # CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
 # CONFIG_SGI_PARTITION is not set
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
 # CONFIG_EFI_PARTITION is not set
 
 #
-# Sound
+# Native Language Support
 #
-# CONFIG_SOUND is not set
+# CONFIG_NLS is not set
 
 #
 # MPC8xx CPM Options
@@ -476,40 +541,38 @@
 # CONFIG_SCC3_ENET is not set
 # CONFIG_FEC_ENET is not set
 # CONFIG_ENET_BIG_BUFFERS is not set
-# CONFIG_SMC2_UART is not set
-# CONFIG_USE_SCC_IO is not set
 
 #
 # Generic MPC8xx Options
 #
 CONFIG_8xx_COPYBACK=y
 # CONFIG_8xx_CPU6 is not set
-# CONFIG_UCODE_PATCH is not set
-
-#
-# USB support
-#
-# CONFIG_USB_GADGET is not set
+CONFIG_NO_UCODE_PATCH=y
+# CONFIG_USB_SOF_UCODE_PATCH is not set
+# CONFIG_I2C_SPI_UCODE_PATCH is not set
+# CONFIG_I2C_SPI_SMC1_UCODE_PATCH is not set
 
 #
-# Bluetooth support
+# Library routines
 #
-# CONFIG_BT is not set
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC32 is not set
+# CONFIG_LIBCRC32C is not set
 
 #
-# Library routines
+# Profiling support
 #
-# CONFIG_CRC32 is not set
+# CONFIG_PROFILING is not set
 
 #
 # Kernel hacking
 #
 # CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
--- a/arch/ppc/kernel/Makefile	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/kernel/Makefile	2004-12-24 13:37:19 -08:00
@@ -25,7 +25,7 @@
 obj-$(CONFIG_TAU)		+= temp.o
 obj-$(CONFIG_ALTIVEC)		+= vecemu.o vector.o
 
-ifdef CONFIG_MATH_EMULATION
+ifndef CONFIG_MATH_EMULATION
 obj-$(CONFIG_8xx)		+= softemu8xx.o
 endif
 
diff -Nru a/arch/ppc/kernel/bitops.c b/arch/ppc/kernel/bitops.c
--- a/arch/ppc/kernel/bitops.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc/kernel/bitops.c	2004-12-24 13:36:18 -08:00
@@ -3,7 +3,7 @@
  */
 
 #include <linux/kernel.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 /*
  * If the bitops are not inlined in bitops.h, they are defined here.
diff -Nru a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c
--- a/arch/ppc/kernel/cputable.c	2004-12-24 13:36:55 -08:00
+++ b/arch/ppc/kernel/cputable.c	2004-12-24 13:36:55 -08:00
@@ -30,7 +30,6 @@
 extern void __setup_cpu_power3(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 extern void __setup_cpu_power4(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 extern void __setup_cpu_ppc970(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
-extern void __setup_cpu_8xx(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 extern void __setup_cpu_generic(unsigned long offset, int cpu_nr, struct cpu_spec* spec);
 
 #define CLASSIC_PPC (!defined(CONFIG_8xx) && !defined(CONFIG_4xx) && \
@@ -48,12 +47,21 @@
  */
 #ifdef CONFIG_ALTIVEC
 #define CPU_FTR_ALTIVEC_COMP		CPU_FTR_ALTIVEC
-#define PPC_FEATURE_ALTIVEC_COMP    	PPC_FEATURE_HAS_ALTIVEC  
+#define PPC_FEATURE_ALTIVEC_COMP    	PPC_FEATURE_HAS_ALTIVEC
 #else
 #define CPU_FTR_ALTIVEC_COMP		0
 #define PPC_FEATURE_ALTIVEC_COMP       	0
 #endif
 
+/* We only set the spe features if the kernel was compiled with
+ * spe support
+ */
+#ifdef CONFIG_SPE
+#define PPC_FEATURE_SPE_COMP    	PPC_FEATURE_HAS_SPE
+#else
+#define PPC_FEATURE_SPE_COMP       	0
+#endif
+
 /* We need to mark all pages as being coherent if we're SMP or we
  * have a 74[45]x and an MPC107 host bridge.
  */
@@ -76,555 +84,827 @@
 
 struct cpu_spec	cpu_specs[] = {
 #if CLASSIC_PPC
-    { 	/* 601 */
-	0xffff0000, 0x00010000, "601",
-	CPU_FTR_COMMON |
-	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_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-    	CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-    	32, 32,
-	__setup_cpu_603
-    },
-    {	/* 603e */
-    	0xffff0000, 0x00060000, "603e",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-    	CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_603
-    },
-    {	/* 603ev */
-    	0xffff0000, 0x00070000, "603ev",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-    	CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_603
-    },
-    {	/* 604 */
-    	0xffff0000, 0x00040000, "604",
-	CPU_FTR_COMMON |
-    	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_COMMON |
-    	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_COMMON |
-    	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_COMMON |
-    	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
-    },
-    {	/* 740/750 (0x4202, don't support TAU ?) */
-    	0xffffffff, 0x00084202, "740/750",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750
-    },
-    {	/* 745/755 */
-    	0xfffff000, 0x00083000, "745/755",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750
-    },
-    {	/* 750CX (80100 and 8010x?) */
-    	0xfffffff0, 0x00080100, "750CX",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750cx
-    },
-    {	/* 750CX (82201 and 82202) */
-    	0xfffffff0, 0x00082200, "750CX",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750cx
-    },
-    {	/* 750CXe (82214) */
-    	0xfffffff0, 0x00082210, "750CXe",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750cx
-    },
-    {	/* 750FX rev 1.x */
-    	0xffffff00, 0x70000100, "750FX",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_DUAL_PLL_750FX | CPU_FTR_NO_DPM,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750
-    },
-    {	/* 750FX rev 2.0 must disable HID0[DPM] */
-    	0xffffffff, 0x70000200, "750FX",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_NO_DPM,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750
-    },
-    {	/* 750FX (All revs except 2.0) */
-    	0xffff0000, 0x70000000, "750FX",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750fx
-    },
-    {	/* 750GX */
-    	0xffff0000, 0x70020000, "750GX",
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750fx
-    },
-    {	/* 740/750 (L2CR bit need fixup for 740) */
-    	0xffff0000, 0x00080000, "740/750",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_750
-    },
-    {	/* 7400 rev 1.1 ? (no TAU) */
-    	0xffffffff, 0x000c1101, "7400 (1.1)",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
-	CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_7400
-    },
-    {	/* 7400 */
-    	0xffff0000, 0x000c0000, "7400",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
-	CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_7400
-    },
-    {	/* 7410 */
-    	0xffff0000, 0x800c0000, "7410",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
-	CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_7410
-    },
-    {	/* 7450 2.0 - no doze/nap */
-    	0xffffffff, 0x80000200, "7450",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NEED_COHERENT,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7450 2.1 */
-    	0xffffffff, 0x80000201, "7450",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_L3_DISABLE_NAP | CPU_FTR_NEED_COHERENT,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7450 2.3 and newer */
-    	0xffff0000, 0x80000000, "7450",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_NEED_COHERENT,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7455 rev 1.x */
-    	0xffffff00, 0x80010100, "7455",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_HAS_HIGH_BATS |
-	CPU_FTR_NEED_COHERENT,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7455 rev 2.0 */
-    	0xffffffff, 0x80010200, "7455",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_L3_DISABLE_NAP | CPU_FTR_NEED_COHERENT | CPU_FTR_HAS_HIGH_BATS,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7455 others */
-    	0xffff0000, 0x80010000, "7455",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NEED_COHERENT,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7447/7457 Rev 1.0 */
-    	0xffffffff, 0x80020100, "7447/7457",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NEED_COHERENT | CPU_FTR_NO_BTIC,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7447/7457 Rev 1.1 */
-    	0xffffffff, 0x80020101, "7447/7457",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NEED_COHERENT | CPU_FTR_NO_BTIC,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7447/7457 Rev 1.2 and later */
-    	0xffff0000, 0x80020000, "7447/7457",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NEED_COHERENT,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 7447A */
-    	0xffff0000, 0x80030000, "7447A",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP |
-	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
-	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
-	CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NEED_COHERENT,
-	COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
-	32, 32,
-	__setup_cpu_745x
-    },
-    {	/* 82xx (8240, 8245, 8260 are all 603e cores) */
-	0x7fff0000, 0x00810000, "82xx",
-	CPU_FTR_COMMON |
-	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_603
-    },
-    {	/* All G2_LE (603e core, plus some) have the same pvr */
-	0x7fff0000, 0x00820000, "G2_LE",
-	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
-	CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_HAS_HIGH_BATS,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_603
-    },
-    {	/* default match, we assume split I/D cache & TB (non-601)... */
-    	0x00000000, 0x00000000, "(generic PPC)",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
-	COMMON_PPC,
-	32, 32,
-	__setup_cpu_generic
-    },
+	{ 	/* 601 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00010000,
+		.cpu_name		= "601",
+		.cpu_features		= CPU_FTR_COMMON | CPU_FTR_601 |
+			CPU_FTR_HPTE_TABLE,
+		.cpu_user_features 	= COMMON_PPC | PPC_FEATURE_601_INSTR |
+			PPC_FEATURE_UNIFIED_CACHE,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.cpu_setup		= __setup_cpu_601
+	},
+	{	/* 603 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00030000,
+		.cpu_name		= "603",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.cpu_setup		= __setup_cpu_603
+	},
+	{	/* 603e */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00060000,
+		.cpu_name		= "603e",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.cpu_setup		= __setup_cpu_603
+	},
+	{	/* 603ev */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00070000,
+		.cpu_name		= "603ev",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.cpu_setup		= __setup_cpu_603
+	},
+	{	/* 604 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00040000,
+		.cpu_name		= "604",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_604_PERF_MON | CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 2,
+		.cpu_setup		= __setup_cpu_604
+	},
+	{	/* 604e */
+		.pvr_mask		= 0xfffff000,
+		.pvr_value		= 0x00090000,
+		.cpu_name		= "604e",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_604_PERF_MON | CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_604
+	},
+	{	/* 604r */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00090000,
+		.cpu_name		= "604r",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_604_PERF_MON | CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_604
+	},
+	{	/* 604ev */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x000a0000,
+		.cpu_name		= "604ev",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_604_PERF_MON | CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_604
+	},
+	{	/* 740/750 (0x4202, don't support TAU ?) */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x00084202,
+		.cpu_name		= "740/750",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_HPTE_TABLE |
+			CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750
+	},
+	{	/* 745/755 */
+		.pvr_mask		= 0xfffff000,
+		.pvr_value		= 0x00083000,
+		.cpu_name		= "745/755",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750
+	},
+	{	/* 750CX (80100 and 8010x?) */
+		.pvr_mask		= 0xfffffff0,
+		.pvr_value		= 0x00080100,
+		.cpu_name		= "750CX",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750cx
+	},
+	{	/* 750CX (82201 and 82202) */
+		.pvr_mask		= 0xfffffff0,
+		.pvr_value		= 0x00082200,
+		.cpu_name		= "750CX",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750cx
+	},
+	{	/* 750CXe (82214) */
+		.pvr_mask		= 0xfffffff0,
+		.pvr_value		= 0x00082210,
+		.cpu_name		= "750CXe",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750cx
+	},
+	{	/* 750FX rev 1.x */
+		.pvr_mask		= 0xffffff00,
+		.pvr_value		= 0x70000100,
+		.cpu_name		= "750FX",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
+			CPU_FTR_DUAL_PLL_750FX | CPU_FTR_NO_DPM,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750
+	},
+	{	/* 750FX rev 2.0 must disable HID0[DPM] */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x70000200,
+		.cpu_name		= "750FX",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
+			CPU_FTR_NO_DPM,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750
+	},
+	{	/* 750FX (All revs except 2.0) */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x70000000,
+		.cpu_name		= "750FX",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
+			CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750fx
+	},
+	{	/* 750GX */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x70020000,
+		.cpu_name		= "750GX",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
+			CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_DUAL_PLL_750FX |
+			CPU_FTR_HAS_HIGH_BATS,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750fx
+	},
+	{	/* 740/750 (L2CR bit need fixup for 740) */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00080000,
+		.cpu_name		= "740/750",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_750
+	},
+	{	/* 7400 rev 1.1 ? (no TAU) */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x000c1101,
+		.cpu_name		= "7400 (1.1)",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_7400
+	},
+	{	/* 7400 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x000c0000,
+		.cpu_name		= "7400",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
+			CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_7400
+	},
+	{	/* 7410 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x800c0000,
+		.cpu_name		= "7410",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
+			CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.cpu_setup		= __setup_cpu_7410
+	},
+	{	/* 7450 2.0 - no doze/nap */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x80000200,
+		.cpu_name		= "7450",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_NEED_COHERENT,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7450 2.1 */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x80000201,
+		.cpu_name		= "7450",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP |
+			CPU_FTR_NEED_COHERENT,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7450 2.3 and newer */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x80000000,
+		.cpu_name		= "7450",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_NEED_COHERENT,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7455 rev 1.x */
+		.pvr_mask		= 0xffffff00,
+		.pvr_value		= 0x80010100,
+		.cpu_name		= "7455",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NEED_COHERENT,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7455 rev 2.0 */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x80010200,
+		.cpu_name		= "7455",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP |
+			CPU_FTR_NEED_COHERENT | CPU_FTR_HAS_HIGH_BATS,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7455 others */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x80010000,
+		.cpu_name		= "7455",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS |
+			CPU_FTR_NEED_COHERENT,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7447/7457 Rev 1.0 */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x80020100,
+		.cpu_name		= "7447/7457",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS |
+			CPU_FTR_NEED_COHERENT | CPU_FTR_NO_BTIC,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7447/7457 Rev 1.1 */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x80020101,
+		.cpu_name		= "7447/7457",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS |
+			CPU_FTR_NEED_COHERENT | CPU_FTR_NO_BTIC,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7447/7457 Rev 1.2 and later */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x80020000,
+		.cpu_name		= "7447/7457",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
+			CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
+			CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS |
+			CPU_FTR_NEED_COHERENT,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 7447A */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x80030000,
+		.cpu_name		= "7447A",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
+			CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
+			CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NEED_COHERENT,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 6,
+		.cpu_setup		= __setup_cpu_745x
+	},
+	{	/* 82xx (8240, 8245, 8260 are all 603e cores) */
+		.pvr_mask		= 0x7fff0000,
+		.pvr_value		= 0x00810000,
+		.cpu_name		= "82xx",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.cpu_setup		= __setup_cpu_603
+	},
+	{	/* All G2_LE (603e core, plus some) have the same pvr */
+		.pvr_mask		= 0x7fff0000,
+		.pvr_value		= 0x00820000,
+		.cpu_name		= "G2_LE",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
+			CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_HAS_HIGH_BATS,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.cpu_setup		= __setup_cpu_603
+	},
+	{	/* default match, we assume split I/D cache & TB (non-601)... */
+		.pvr_mask		= 0x00000000,
+		.pvr_value		= 0x00000000,
+		.cpu_name		= "(generic PPC)",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.cpu_setup		= __setup_cpu_generic
+	},
 #endif /* CLASSIC_PPC */
 #ifdef CONFIG_PPC64BRIDGE
-    {	/* Power3 */
-    	0xffff0000, 0x00400000, "Power3 (630)",
-	CPU_FTR_COMMON |
-    	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_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
-    	COMMON_PPC | PPC_FEATURE_64,
-	128, 128,
-	__setup_cpu_power3
-    },
+	{	/* Power3 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00400000,
+		.cpu_name		= "Power3 (630)",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_64,
+		.icache_bsize		= 128,
+		.dcache_bsize		= 128,
+		.num_pmcs		= 8,
+		.cpu_setup		= __setup_cpu_power3
+	},
+	{	/* Power3+ */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00410000,
+		.cpu_name		= "Power3 (630+)",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_64,
+		.icache_bsize		= 128,
+		.dcache_bsize		= 128,
+		.num_pmcs		= 8,
+		.cpu_setup		= __setup_cpu_power3
+	},
 	{	/* I-star */
-		0xffff0000, 0x00360000, "I-star",
-		CPU_FTR_COMMON |
-		CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
-		COMMON_PPC | PPC_FEATURE_64,
-		128, 128,
-		__setup_cpu_power3
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00360000,
+		.cpu_name		= "I-star",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_64,
+		.icache_bsize		= 128,
+		.dcache_bsize		= 128,
+		.num_pmcs		= 8,
+		.cpu_setup		= __setup_cpu_power3
 	},
 	{	/* S-star */
-		0xffff0000, 0x00370000, "S-star",
-		CPU_FTR_COMMON |
-		CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
-		COMMON_PPC | PPC_FEATURE_64,
-		128, 128,
-		__setup_cpu_power3
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00370000,
+		.cpu_name		= "S-star",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_64,
+		.icache_bsize		= 128,
+		.dcache_bsize		= 128,
+		.num_pmcs		= 8,
+		.cpu_setup		= __setup_cpu_power3
 	},
 #endif /* CONFIG_PPC64BRIDGE */
 #ifdef CONFIG_POWER4
-    {	/* Power4 */
-    	0xffff0000, 0x00350000, "Power4",
-	CPU_FTR_COMMON |
-    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
-    	COMMON_PPC | PPC_FEATURE_64,
-	128, 128,
-	__setup_cpu_power4
-    },
-    {	/* PPC970 */
-	0xffff0000, 0x00390000, "PPC970",
-	CPU_FTR_COMMON |
-	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
-	CPU_FTR_ALTIVEC_COMP | CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC | PPC_FEATURE_64 | PPC_FEATURE_ALTIVEC_COMP,
-	128, 128,
-	__setup_cpu_ppc970
-    },
-    {	/* PPC970FX */
-	0xffff0000, 0x003c0000, "PPC970FX",
-	CPU_FTR_COMMON |
-	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
-	CPU_FTR_ALTIVEC_COMP | CPU_FTR_MAYBE_CAN_NAP,
-	COMMON_PPC | PPC_FEATURE_64 | PPC_FEATURE_ALTIVEC_COMP,
-	128, 128,
-	__setup_cpu_ppc970
-    },
+	{	/* Power4 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00350000,
+		.cpu_name		= "Power4",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_HPTE_TABLE,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_64,
+		.icache_bsize		= 128,
+		.dcache_bsize		= 128,
+		.num_pmcs		= 8,
+		.cpu_setup		= __setup_cpu_power4
+	},
+	{	/* PPC970 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00390000,
+		.cpu_name		= "PPC970",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_HPTE_TABLE |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_64 |
+			PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 128,
+		.dcache_bsize		= 128,
+		.num_pmcs		= 8,
+		.cpu_setup		= __setup_cpu_ppc970
+	},
+	{	/* PPC970FX */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x003c0000,
+		.cpu_name		= "PPC970FX",
+		.cpu_features		= CPU_FTR_COMMON |
+			CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+			CPU_FTR_HPTE_TABLE |
+			CPU_FTR_ALTIVEC_COMP | CPU_FTR_MAYBE_CAN_NAP,
+		.cpu_user_features	= COMMON_PPC | PPC_FEATURE_64 |
+			PPC_FEATURE_ALTIVEC_COMP,
+		.icache_bsize		= 128,
+		.dcache_bsize		= 128,
+		.num_pmcs		= 8,
+		.cpu_setup		= __setup_cpu_ppc970
+	},
 #endif /* CONFIG_POWER4 */
 #ifdef CONFIG_8xx
-    {	/* 8xx */
-    	0xffff0000, 0x00500000, "8xx",
+	{	/* 8xx */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00500000,
+		.cpu_name		= "8xx",
 		/* CPU_FTR_MAYBE_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,
-	__setup_cpu_8xx	/* Empty */
-    },
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 16,
+		.dcache_bsize		= 16,
+	},
 #endif /* CONFIG_8xx */
 #ifdef CONFIG_40x
-    {	/* 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 */
-    },
-    {	/* STB 04xxx */
-    	0xffff0000, 0x41810000, "STB04xxx",
-    	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 */
-    },
-    {	/* NP405L */
-    	0xffff0000, 0x41610000, "NP405L",
-    	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 */
-    },
-    {	/* NP4GS3 */
-    	0xffff0000, 0x40B10000, "NP4GS3",
-    	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 */
-    },
-    {   /* NP405H */
-        0xffff0000, 0x41410000, "NP405H",
-        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 */
-     },
-     {	/* 405GPr */
-    	0xffff0000, 0x50910000, "405GPr",
-    	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 */
-    },
-    {   /* STBx25xx */
-        0xffff0000, 0x51510000, "STBx25xx",
-        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 */
-     },
-     {	/* 405LP */
-    	0xffff0000, 0x41F10000, "405LP",
-    	CPU_FTR_SPLIT_ID_CACHE |  CPU_FTR_USE_TB,
-    	PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
-	32, 32,
-	0, /*__setup_cpu_405 */
-     },
-     {	/* Xilinx Virtex-II Pro  */
-	0xffff0000, 0x20010000, "Virtex-II Pro",
-	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 */
-     },
+	{	/* 403GC */
+		.pvr_mask		= 0xffffff00,
+		.pvr_value		= 0x00200200,
+		.cpu_name		= "403GC",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 16,
+		.dcache_bsize		= 16,
+	},
+	{	/* 403GCX */
+		.pvr_mask		= 0xffffff00,
+		.pvr_value		= 0x00201400,
+		.cpu_name		= "403GCX",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 16,
+		.dcache_bsize		= 16,
+	},
+	{	/* 403G ?? */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x00200000,
+		.cpu_name		= "403G ??",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 16,
+		.dcache_bsize		= 16,
+	},
+	{	/* 405GP */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x40110000,
+		.cpu_name		= "405GP",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{	/* STB 03xxx */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x40130000,
+		.cpu_name		= "STB03xxx",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{	/* STB 04xxx */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x41810000,
+		.cpu_name		= "STB04xxx",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{	/* NP405L */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x41610000,
+		.cpu_name		= "NP405L",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{	/* NP4GS3 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x40B10000,
+		.cpu_name		= "NP4GS3",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{   /* NP405H */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x41410000,
+		.cpu_name		= "NP405H",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{	/* 405GPr */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x50910000,
+		.cpu_name		= "405GPr",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{   /* STBx25xx */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x51510000,
+		.cpu_name		= "STBx25xx",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{	/* 405LP */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x41F10000,
+		.cpu_name		= "405LP",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{	/* Xilinx Virtex-II Pro  */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x20010000,
+		.cpu_name		= "Virtex-II Pro",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
 
 #endif /* CONFIG_40x */
 #ifdef CONFIG_44x
-    { /* 440GP Rev. B */
-        0xf0000fff, 0x40000440, "440GP Rev. B",
-        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
-        PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
-        32, 32,
-        0, /*__setup_cpu_440 */
-    },
-    { /* 440GP Rev. C */
-        0xf0000fff, 0x40000481, "440GP Rev. C",
-        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
-        PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
-        32, 32,
-        0, /*__setup_cpu_440 */
-    },
-    { /* 440GX Rev. A */
-        0xf0000fff, 0x50000850, "440GX Rev. A",
-        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
-        PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
-        32, 32,
-        0, /*__setup_cpu_440 */
-    },
-    { /* 440GX Rev. B */
-        0xf0000fff, 0x50000851, "440GX Rev. B",
-        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
-        PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
-        32, 32,
-        0, /*__setup_cpu_440 */
-    },
-    { /* 440GX Rev. C */
-        0xf0000fff, 0x50000892, "440GX Rev. C",
-        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
-        PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
-        32, 32,
-        0, /*__setup_cpu_440 */
-    },
+	{ 	/* 440GP Rev. B */
+		.pvr_mask		= 0xf0000fff,
+		.pvr_value		= 0x40000440,
+		.cpu_name		= "440GP Rev. B",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{ 	/* 440GP Rev. C */
+		.pvr_mask		= 0xf0000fff,
+		.pvr_value		= 0x40000481,
+		.cpu_name		= "440GP Rev. C",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{ /* 440GX Rev. A */
+		.pvr_mask		= 0xf0000fff,
+		.pvr_value		= 0x50000850,
+		.cpu_name		= "440GX Rev. A",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{ /* 440GX Rev. B */
+		.pvr_mask		= 0xf0000fff,
+		.pvr_value		= 0x50000851,
+		.cpu_name		= "440GX Rev. B",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
+	{ /* 440GX Rev. C */
+		.pvr_mask		= 0xf0000fff,
+		.pvr_value		= 0x50000892,
+		.cpu_name		= "440GX Rev. C",
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	},
 #endif /* CONFIG_44x */
 #ifdef CONFIG_E500
-    { /* e500 */
-        0xffff0000, 0x80200000, "e500",
-	/* xxx - galak: add CPU_FTR_MAYBE_CAN_DOZE */
-        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
-        PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
-        32, 32,
-        0, /*__setup_cpu_e500 */
-    },
+	{ 	/* e500 */
+		.pvr_mask		= 0xffff0000,
+		.pvr_value		= 0x80200000,
+		.cpu_name		= "e500",
+		/* xxx - galak: add CPU_FTR_MAYBE_CAN_DOZE */
+		.cpu_features		= CPU_FTR_SPLIT_ID_CACHE |
+			CPU_FTR_USE_TB,
+		.cpu_user_features	= PPC_FEATURE_32 |
+			PPC_FEATURE_HAS_MMU | PPC_FEATURE_SPE_COMP |
+			PPC_FEATURE_HAS_EFP_SINGLE,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+	},
 #endif
 #if !CLASSIC_PPC
-    {	/* default match */
-    	0x00000000, 0x00000000, "(generic PPC)",
-	CPU_FTR_COMMON,
-    	PPC_FEATURE_32,
-	32, 32,
-	0,
-    }
+	{	/* default match */
+		.pvr_mask		= 0x00000000,
+		.pvr_value		= 0x00000000,
+		.cpu_name		= "(generic PPC)",
+		.cpu_features		= CPU_FTR_COMMON,
+		.cpu_user_features	= PPC_FEATURE_32,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+	}
 #endif /* !CLASSIC_PPC */
 };
diff -Nru a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S
--- a/arch/ppc/kernel/head_44x.S	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc/kernel/head_44x.S	2004-12-24 13:36:31 -08:00
@@ -599,64 +599,8 @@
 	mfspr	r10, SPRG0
 	b	InstructionStorage
 
-/* Check for a single step debug exception while in an exception
- * handler before state has been saved.  This is to catch the case
- * where an instruction that we are trying to single step causes
- * an exception (eg ITLB/DTLB miss) and thus the first instruction of
- * the exception handler generates a single step debug exception.
- *
- * If we get a debug trap on the first instruction of an exception handler,
- * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
- * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
- * The exception handler was handling a non-critical interrupt, so it will
- * save (and later restore) the MSR via SPRN_SRR1, which will still have
- * the MSR_DE bit set.
- */
 	/* Debug Interrupt */
-	START_EXCEPTION(Debug)
-	CRITICAL_EXCEPTION_PROLOG
-
-	/*
-	 * If this is a single step or branch-taken exception in an
-	 * exception entry sequence, it was probably meant to apply to
-	 * the code where the exception occurred (since exception entry
-	 * doesn't turn off DE automatically).  We simulate the effect
-	 * of turning off DE on entry to an exception handler by turning
-	 * off DE in the CSRR1 value and clearing the debug status.
-	 */
-	mfspr	r10,SPRN_DBSR		/* check single-step/branch taken */
-	andis.	r10,r10,(DBSR_IC|DBSR_BT)@h
-	beq+	1f
-	andi.	r0,r9,MSR_PR		/* check supervisor */
-	beq	2f			/* branch if we need to fix it up... */
-
-	/* continue normal handling for a critical exception... */
-1:	mfspr	r4,SPRN_DBSR
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	EXC_XFER_TEMPLATE(DebugException, 0x2002, \
-		(MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
-		NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
-
-	/* here it looks like we got an inappropriate debug exception. */
-2:	rlwinm	r9,r9,0,~MSR_DE		/* clear DE in the CSRR1 value */
-	mtspr	SPRN_DBSR,r10		/* clear the IC/BT debug intr status */
-	/* restore state and get out */
-	lwz	r10,_CCR(r11)
-	lwz	r0,GPR0(r11)
-	lwz	r1,GPR1(r11)
-	mtcrf	0x80,r10
-	mtspr	CSRR0,r12
-	mtspr	CSRR1,r9
-	lwz	r9,GPR9(r11)
-
-	mtspr	SPRG2,r8;		/* SPRG2 only used in criticals */
-	lis	r8,crit_save@ha;
-	lwz	r10,crit_r10@l(r8)
-	lwz	r11,crit_r11@l(r8)
-	mfspr	r8,SPRG2
-
-	rfci
-	b	.
+	DEBUG_EXCEPTION
 
 /*
  * Local functions
diff -Nru a/arch/ppc/kernel/head_4xx.S b/arch/ppc/kernel/head_4xx.S
--- a/arch/ppc/kernel/head_4xx.S	2004-12-24 13:37:30 -08:00
+++ b/arch/ppc/kernel/head_4xx.S	2004-12-24 13:37:30 -08:00
@@ -709,8 +709,20 @@
 	EXCEPTION(0x1E00, Trap_1E, UnknownException, EXC_XFER_EE)
 	EXCEPTION(0x1F00, Trap_1F, UnknownException, EXC_XFER_EE)
 
-/* 0x2000 - Debug Exception
-*/
+/* Check for a single step debug exception while in an exception
+ * handler before state has been saved.  This is to catch the case
+ * where an instruction that we are trying to single step causes
+ * an exception (eg ITLB/DTLB miss) and thus the first instruction of
+ * the exception handler generates a single step debug exception.
+ *
+ * If we get a debug trap on the first instruction of an exception handler,
+ * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
+ * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
+ * The exception handler was handling a non-critical interrupt, so it will
+ * save (and later restore) the MSR via SPRN_SRR1, which will still have
+ * the MSR_DE bit set.
+ */
+	/* 0x2000 - Debug Exception */
 	START_EXCEPTION(0x2000, DebugTrap)
 	CRITICAL_EXCEPTION_PROLOG
 
@@ -723,21 +735,20 @@
 	 * off DE in the SRR3 value and clearing the debug status.
 	 */
 	mfspr	r10,SPRN_DBSR		/* check single-step/branch taken */
-	andis.	r10,r10,(DBSR_IC|DBSR_BT)@h
-	beq+	1f
-	andi.	r0,r9,MSR_IR|MSR_PR	/* check supervisor + MMU off */
-	beq	2f			/* branch if we need to fix it up... */
+	andis.	r10,r10,DBSR_IC@h
+	beq+	2f
 
-	/* continue normal handling for a critical exception... */
-1:	mfspr	r4,SPRN_DBSR
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	EXC_XFER_TEMPLATE(DebugException, 0x2002, \
-		(MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
-		NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
+	andi.	r10,r9,MSR_IR|MSR_PR	/* check supervisor + MMU off */
+	beq	1f			/* branch and fix it up */
+
+	mfspr   r10,SPRN_SRR2		/* Faulting instruction address */
+	cmplwi  r10,0x2100
+	bgt+    2f			/* address above exception vectors */
 
 	/* here it looks like we got an inappropriate debug exception. */
-2:	rlwinm	r9,r9,0,~MSR_DE		/* clear DE in the SRR3 value */
-	mtspr	SPRN_DBSR,r10		/* clear the IC/BT debug intr status */
+1:	rlwinm	r9,r9,0,~MSR_DE		/* clear DE in the SRR3 value */
+	lis	r10,DBSR_IC@h		/* clear the IC event */
+	mtspr	SPRN_DBSR,r10
 	/* restore state and get out */
 	lwz	r10,_CCR(r11)
 	lwz	r0,GPR0(r11)
@@ -752,6 +763,13 @@
 	PPC405_ERR77_SYNC
 	rfci
 	b	.
+
+	/* continue normal handling for a critical exception... */
+2:	mfspr	r4,SPRN_DBSR
+	addi	r3,r1,STACK_FRAME_OVERHEAD
+	EXC_XFER_TEMPLATE(DebugException, 0x2002, \
+		(MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
+		NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
 
 /*
  * The other Data TLB exceptions bail out to this point
diff -Nru a/arch/ppc/kernel/head_8xx.S b/arch/ppc/kernel/head_8xx.S
--- a/arch/ppc/kernel/head_8xx.S	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc/kernel/head_8xx.S	2004-12-24 13:36:48 -08:00
@@ -32,14 +32,18 @@
 #include <asm/ppc_asm.h>
 #include <asm/offsets.h>
 
+/* Macro to make the code more readable. */
+#ifdef CONFIG_8xx_CPU6
+#define DO_8xx_CPU6(val, reg)	\
+	li	reg, val;	\
+	stw	reg, 12(r0);	\
+	lwz	reg, 12(r0);
+#else
+#define DO_8xx_CPU6(val, reg)
+#endif
 	.text
 	.globl	_stext
 _stext:
-
-/*
- * _start is defined this way because the XCOFF loader in the OpenFirmware
- * on the powermac expects the entry point to be a procedure descriptor.
- */
 	.text
 	.globl	_start
 _start:
@@ -77,7 +81,6 @@
  * and the CCR at memory location 0.....Someday I'll fix this.....
  *	-- Dan
  */
-
 	.globl	__start
 __start:
 	mr	r31,r3			/* save parameters */
@@ -85,7 +88,6 @@
 	mr	r29,r5
 	mr	r28,r6
 	mr	r27,r7
-	li	r24,0			/* cpu # */
 
 	/* We have to turn on the MMU right away so we get cache modes
 	 * set correctly.
@@ -113,63 +115,106 @@
  * task's thread_struct.
  */
 #define EXCEPTION_PROLOG	\
-	mtspr	SPRG0,r20;	\
-	mtspr	SPRG1,r21;	\
-	mfcr	r20;		\
-	mfspr	r21,SPRG2;		/* exception stack to use from */ \
-	cmpwi	0,r21,0;		/* user mode or RTAS */ \
-	bne	1f;		\
-	tophys(r21,r1);			/* use tophys(kernel sp) otherwise */ \
-	subi	r21,r21,INT_FRAME_SIZE;	/* alloc exc. frame */\
-1:	stw	r20,_CCR(r21);		/* save registers */ \
-	stw	r22,GPR22(r21);	\
-	stw	r23,GPR23(r21);	\
-	mfspr	r20,SPRG0;	\
-	stw	r20,GPR20(r21);	\
-	mfspr	r22,SPRG1;	\
-	stw	r22,GPR21(r21);	\
-	mflr	r20;		\
-	stw	r20,_LINK(r21);	\
-	mfctr	r22;		\
-	stw	r22,_CTR(r21);	\
-	mfspr	r20,XER;	\
-	stw	r20,_XER(r21);	\
-	mfspr	r22,SRR0;	\
-	mfspr	r23,SRR1;	\
-	stw	r0,GPR0(r21);	\
-	stw	r1,GPR1(r21);	\
-	stw	r2,GPR2(r21);	\
-	stw	r1,0(r21);	\
-	tovirt(r1,r21);			/* set new kernel sp */	\
-	SAVE_4GPRS(3, r21);	\
-	SAVE_GPR(7, r21);
+	mtspr	SPRG0,r10;	\
+	mtspr	SPRG1,r11;	\
+	mfcr	r10;		\
+	EXCEPTION_PROLOG_1;	\
+	EXCEPTION_PROLOG_2
+
+#define EXCEPTION_PROLOG_1	\
+	mfspr	r11,SRR1;		/* check whether user or kernel */ \
+	andi.	r11,r11,MSR_PR;	\
+	tophys(r11,r1);			/* use tophys(r1) if kernel */ \
+	beq	1f;		\
+	mfspr	r11,SPRG3;	\
+	lwz	r11,THREAD_INFO-THREAD(r11);	\
+	addi	r11,r11,THREAD_SIZE;	\
+	tophys(r11,r11);	\
+1:	subi	r11,r11,INT_FRAME_SIZE	/* alloc exc. frame */
+
+
+#define EXCEPTION_PROLOG_2	\
+	CLR_TOP32(r11);		\
+	stw	r10,_CCR(r11);		/* save registers */ \
+	stw	r12,GPR12(r11);	\
+	stw	r9,GPR9(r11);	\
+	mfspr	r10,SPRG0;	\
+	stw	r10,GPR10(r11);	\
+	mfspr	r12,SPRG1;	\
+	stw	r12,GPR11(r11);	\
+	mflr	r10;		\
+	stw	r10,_LINK(r11);	\
+	mfspr	r12,SRR0;	\
+	mfspr	r9,SRR1;	\
+	stw	r1,GPR1(r11);	\
+	stw	r1,0(r11);	\
+	tovirt(r1,r11);			/* set new kernel sp */	\
+	li	r10,MSR_KERNEL & ~(MSR_IR|MSR_DR); /* can take exceptions */ \
+	MTMSRD(r10);			/* (except for mach check in rtas) */ \
+	stw	r0,GPR0(r11);	\
+	SAVE_4GPRS(3, r11);	\
+	SAVE_2GPRS(7, r11)
+
 /*
  * Note: code which follows this uses cr0.eq (set if from kernel),
- * r21, r22 (SRR0), and r23 (SRR1).
+ * r11, r12 (SRR0), and r9 (SRR1).
+ *
+ * Note2: once we have set r1 we are in a position to take exceptions
+ * again, and we could thus set MSR:RI at that point.
  */
 
 /*
  * Exception vectors.
  */
-#define STD_EXCEPTION(n, label, hdlr)		\
+#define EXCEPTION(n, label, hdlr, xfer)		\
 	. = n;					\
 label:						\
 	EXCEPTION_PROLOG;			\
 	addi	r3,r1,STACK_FRAME_OVERHEAD;	\
-	li	r20,MSR_KERNEL;			\
-	bl	transfer_to_handler; 		\
-	.long	hdlr;				\
-	.long	ret_from_except
+	xfer(n, hdlr)
+
+#define EXC_XFER_TEMPLATE(n, hdlr, trap, copyee, tfer, ret)	\
+	li	r10,trap;					\
+	stw	r10,TRAP(r11);					\
+	li	r10,MSR_KERNEL;					\
+	copyee(r10, r9);					\
+	bl	tfer;						\
+i##n:								\
+	.long	hdlr;						\
+	.long	ret
+
+#define COPY_EE(d, s)		rlwimi d,s,0,16,16
+#define NOCOPY(d, s)
+
+#define EXC_XFER_STD(n, hdlr)		\
+	EXC_XFER_TEMPLATE(n, hdlr, n, NOCOPY, transfer_to_handler_full,	\
+			  ret_from_except_full)
+
+#define EXC_XFER_LITE(n, hdlr)		\
+	EXC_XFER_TEMPLATE(n, hdlr, n+1, NOCOPY, transfer_to_handler, \
+			  ret_from_except)
+
+#define EXC_XFER_EE(n, hdlr)		\
+	EXC_XFER_TEMPLATE(n, hdlr, n, COPY_EE, transfer_to_handler_full, \
+			  ret_from_except_full)
+
+#define EXC_XFER_EE_LITE(n, hdlr)	\
+	EXC_XFER_TEMPLATE(n, hdlr, n+1, COPY_EE, transfer_to_handler, \
+			  ret_from_except)
 
 /* System reset */
-#ifdef CONFIG_SMP /* MVME/MTX start the secondary here */
-	STD_EXCEPTION(0x100, Reset, __secondary_start_psurge)
-#else
-	STD_EXCEPTION(0x100, Reset, UnknownException)
-#endif
+	EXCEPTION(0x100, Reset, UnknownException, EXC_XFER_STD)
 
 /* Machine check */
-	STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
+	. = 0x200
+MachineCheck:
+	EXCEPTION_PROLOG
+	mfspr r4,DAR
+	stw r4,_DAR(r11)
+	mfspr r5,DSISR
+	stw r5,_DSISR(r11)
+	addi r3,r1,STACK_FRAME_OVERHEAD
+	EXC_XFER_STD(0x200, MachineCheckException)
 
 /* Data access exception.
  * This is "never generated" by the MPC8xx.  We jump to it for other
@@ -178,17 +223,11 @@
 	. = 0x300
 DataAccess:
 	EXCEPTION_PROLOG
-	mfspr	r20,DSISR
-	stw	r20,_DSISR(r21)
-	mr	r5,r20
+	mfspr	r10,DSISR
+	stw	r10,_DSISR(r11)
+	mr	r5,r10
 	mfspr	r4,DAR
-	stw	r4,_DAR(r21)
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		/* copy EE bit from saved MSR */
-	bl	transfer_to_handler
-	.long	do_page_fault
-	.long	ret_from_except
+	EXC_XFER_EE_LITE(0x300, handle_page_fault)
 
 /* Instruction access exception.
  * This is "never generated" by the MPC8xx.  We jump to it for other
@@ -197,94 +236,52 @@
 	. = 0x400
 InstructionAccess:
 	EXCEPTION_PROLOG
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	mr	r4,r22
-	mr	r5,r23
-	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		/* copy EE bit from saved MSR */
-	bl	transfer_to_handler
-	.long	do_page_fault
-	.long	ret_from_except
+	mr	r4,r12
+	mr	r5,r9
+	EXC_XFER_EE_LITE(0x400, handle_page_fault)
 
 /* External interrupt */
-	. = 0x500;
-HardwareInterrupt:
-	EXCEPTION_PROLOG;
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r20,MSR_KERNEL
-	li	r4,0
-	bl	transfer_to_handler
-	.globl do_IRQ_intercept
-do_IRQ_intercept:
-	.long	do_IRQ;
-	.long	ret_from_intercept
-
+	EXCEPTION(0x500, HardwareInterrupt, do_IRQ, EXC_XFER_LITE)
 
 /* Alignment exception */
 	. = 0x600
 Alignment:
 	EXCEPTION_PROLOG
 	mfspr	r4,DAR
-	stw	r4,_DAR(r21)
+	stw	r4,_DAR(r11)
 	mfspr	r5,DSISR
-	stw	r5,_DSISR(r21)
+	stw	r5,_DSISR(r11)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		/* copy EE bit from saved MSR */
-	bl	transfer_to_handler
-	.long	AlignmentException
-	.long	ret_from_except
+	EXC_XFER_EE(0x600, AlignmentException)
 
 /* Program check exception */
-	. = 0x700
-ProgramCheck:
-	EXCEPTION_PROLOG
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		/* copy EE bit from saved MSR */
-	bl	transfer_to_handler
-	.long	ProgramCheckException
-	.long	ret_from_except
+	EXCEPTION(0x700, ProgramCheck, ProgramCheckException, EXC_XFER_STD)
 
 /* No FPU on MPC8xx.  This exception is not supposed to happen.
 */
-	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
+	EXCEPTION(0x800, FPUnavailable, UnknownException, EXC_XFER_STD)
 
-	. = 0x900
-Decrementer:
-	EXCEPTION_PROLOG
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	li	r20,MSR_KERNEL
-	bl	transfer_to_handler
-	.globl timer_interrupt_intercept
-timer_interrupt_intercept:
-	.long	timer_interrupt
-	.long	ret_from_intercept
+/* Decrementer */
+	EXCEPTION(0x900, Decrementer, timer_interrupt, EXC_XFER_LITE)
 
-	STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
-	STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
+	EXCEPTION(0xa00, Trap_0a, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0xb00, Trap_0b, UnknownException, EXC_XFER_EE)
 
 /* System call */
 	. = 0xc00
 SystemCall:
 	EXCEPTION_PROLOG
-	stw	r3,ORIG_GPR3(r21)
-	li	r20,MSR_KERNEL
-	rlwimi	r20,r23,0,16,16		/* copy EE bit from saved MSR */
-	bl	transfer_to_handler
-	.long	DoSyscall
-	.long	ret_from_except
+	EXC_XFER_EE_LITE(0xc00, DoSyscall)
 
 /* Single step - not used on 601 */
-	STD_EXCEPTION(0xd00, SingleStep, SingleStepException)
-
-	STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
-	STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
+	EXCEPTION(0xd00, SingleStep, SingleStepException, EXC_XFER_STD)
+	EXCEPTION(0xe00, Trap_0e, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0xf00, Trap_0f, UnknownException, EXC_XFER_EE)
 
 /* On the MPC8xx, this is a software emulation interrupt.  It occurs
  * for all unimplemented and illegal instructions.
  */
-	STD_EXCEPTION(0x1000, SoftEmu, SoftwareEmulation)
+	EXCEPTION(0x1000, SoftEmu, SoftwareEmulation, EXC_XFER_STD)
 
 	. = 0x1100
 /*
@@ -302,58 +299,43 @@
 InstructionTLBMiss:
 #ifdef CONFIG_8xx_CPU6
 	stw	r3, 8(r0)
-	li	r3, 0x3f80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	M_TW, r20	/* Save a couple of working registers */
-	mfcr	r20
-	stw	r20, 0(r0)
-	stw	r21, 4(r0)
-	mfspr	r20, SRR0	/* Get effective address of fault */
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x3780
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
 #endif
-	mtspr	MD_EPN, r20	/* Have to use MD_EPN for walk, MI_EPN can't */
-	mfspr	r20, M_TWB	/* Get level 1 table entry address */
+	DO_8xx_CPU6(0x3f80, r3)
+	mtspr	M_TW, r10	/* Save a couple of working registers */
+	mfcr	r10
+	stw	r10, 0(r0)
+	stw	r11, 4(r0)
+	mfspr	r10, SRR0	/* Get effective address of fault */
+	DO_8xx_CPU6(0x3780, r3)
+	mtspr	MD_EPN, r10	/* Have to use MD_EPN for walk, MI_EPN can't */
+	mfspr	r10, M_TWB	/* Get level 1 table entry address */
 
 	/* If we are faulting a kernel address, we have to use the
 	 * kernel page tables.
 	 */
-	andi.	r21, r20, 0x0800	/* Address >= 0x80000000 */
+	andi.	r11, r10, 0x0800	/* Address >= 0x80000000 */
 	beq	3f
-	lis	r21, swapper_pg_dir@h
-	ori	r21, r21, swapper_pg_dir@l
-	rlwimi	r20, r21, 0, 2, 19
+	lis	r11, swapper_pg_dir@h
+	ori	r11, r11, swapper_pg_dir@l
+	rlwimi	r10, r11, 0, 2, 19
 3:
-	lwz	r21, 0(r20)	/* Get the level 1 entry */
-	rlwinm.	r20, r21,0,0,19	/* Extract page descriptor page address */
+	lwz	r11, 0(r10)	/* Get the level 1 entry */
+	rlwinm.	r10, r11,0,0,19	/* Extract page descriptor page address */
 	beq	2f		/* If zero, don't try to find a pte */
 
 	/* We have a pte table, so load the MI_TWC with the attributes
 	 * for this "segment."
 	 */
-	tophys(r21,r21)
-	ori	r21,r21,1		/* Set valid bit */
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x2b80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MI_TWC, r21	/* Set segment attributes */
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x3b80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MD_TWC, r21	/* Load pte table base address */
-	mfspr	r21, MD_TWC	/* ....and get the pte address */
-	lwz	r20, 0(r21)	/* Get the pte */
+	ori	r11,r11,1		/* Set valid bit */
+	DO_8xx_CPU6(0x2b80, r3)
+	mtspr	MI_TWC, r11	/* Set segment attributes */
+	DO_8xx_CPU6(0x3b80, r3)
+	mtspr	MD_TWC, r11	/* Load pte table base address */
+	mfspr	r11, MD_TWC	/* ....and get the pte address */
+	lwz	r10, 0(r11)	/* Get the pte */
 
-	ori	r20, r20, _PAGE_ACCESSED
-	stw	r20, 0(r21)
+	ori	r10, r10, _PAGE_ACCESSED
+	stw	r10, 0(r11)
 
 	/* The Linux PTE won't go exactly into the MMU TLB.
 	 * Software indicator bits 21, 22 and 28 must be clear.
@@ -361,29 +343,24 @@
 	 * set.  All other Linux PTE bits control the behavior
 	 * of the MMU.
 	 */
-	li	r21, 0x00f0
-	rlwimi	r20, r21, 0, 24, 28	/* Set 24-27, clear 28 */
-
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x2d80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MI_RPN, r20	/* Update TLB entry */
-
-	mfspr	r20, M_TW	/* Restore registers */
-	lwz	r21, 0(r0)
-	mtcr	r21
-	lwz	r21, 4(r0)
+	li	r11, 0x00f0
+	rlwimi	r10, r11, 0, 24, 28	/* Set 24-27, clear 28 */
+	DO_8xx_CPU6(0x2d80, r3)
+	mtspr	MI_RPN, r10	/* Update TLB entry */
+
+	mfspr	r10, M_TW	/* Restore registers */
+	lwz	r11, 0(r0)
+	mtcr	r11
+	lwz	r11, 4(r0)
 #ifdef CONFIG_8xx_CPU6
 	lwz	r3, 8(r0)
 #endif
 	rfi
 
-2:	mfspr	r20, M_TW	/* Restore registers */
-	lwz	r21, 0(r0)
-	mtcr	r21
-	lwz	r21, 4(r0)
+2:	mfspr	r10, M_TW	/* Restore registers */
+	lwz	r11, 0(r0)
+	mtcr	r11
+	lwz	r11, 4(r0)
 #ifdef CONFIG_8xx_CPU6
 	lwz	r3, 8(r0)
 #endif
@@ -393,41 +370,34 @@
 DataStoreTLBMiss:
 #ifdef CONFIG_8xx_CPU6
 	stw	r3, 8(r0)
-	li	r3, 0x3f80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
 #endif
-	mtspr	M_TW, r20	/* Save a couple of working registers */
-	mfcr	r20
-	stw	r20, 0(r0)
-	stw	r21, 4(r0)
-	mfspr	r20, M_TWB	/* Get level 1 table entry address */
+	DO_8xx_CPU6(0x3f80, r3)
+	mtspr	M_TW, r10	/* Save a couple of working registers */
+	mfcr	r10
+	stw	r10, 0(r0)
+	stw	r11, 4(r0)
+	mfspr	r10, M_TWB	/* Get level 1 table entry address */
 
 	/* If we are faulting a kernel address, we have to use the
 	 * kernel page tables.
 	 */
-	andi.	r21, r20, 0x0800
+	andi.	r11, r10, 0x0800
 	beq	3f
-	lis	r21, swapper_pg_dir@h
-	ori	r21, r21, swapper_pg_dir@l
-	rlwimi r20, r21, 0, 2, 19
+	lis	r11, swapper_pg_dir@h
+	ori	r11, r11, swapper_pg_dir@l
+	rlwimi	r10, r11, 0, 2, 19
 3:
-	lwz	r21, 0(r20)	/* Get the level 1 entry */
-	rlwinm.	r20, r21,0,0,19	/* Extract page descriptor page address */
+	lwz	r11, 0(r10)	/* Get the level 1 entry */
+	rlwinm.	r10, r11,0,0,19	/* Extract page descriptor page address */
 	beq	2f		/* If zero, don't try to find a pte */
 
 	/* We have a pte table, so load fetch the pte from the table.
 	 */
-	tophys(r21, r21)
-	ori	r21, r21, 1	/* Set valid bit in physical L2 page */
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x3b80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MD_TWC, r21	/* Load pte table base address */
-	mfspr	r20, MD_TWC	/* ....and get the pte address */
-	lwz	r20, 0(r20)	/* Get the pte */
+	ori	r11, r11, 1	/* Set valid bit in physical L2 page */
+	DO_8xx_CPU6(0x3b80, r3)
+	mtspr	MD_TWC, r11	/* Load pte table base address */
+	mfspr	r10, MD_TWC	/* ....and get the pte address */
+	lwz	r10, 0(r10)	/* Get the pte */
 
 	/* Insert the Guarded flag into the TWC from the Linux PTE.
 	 * It is bit 27 of both the Linux PTE and the TWC (at least
@@ -435,17 +405,13 @@
 	 * this into the Linux pgd/pmd and load it in the operation
 	 * above.
 	 */
-	rlwimi	r21, r20, 0, 27, 27
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x3b80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MD_TWC, r21
-
-	mfspr	r21, MD_TWC	/* get the pte address again */
-	ori	r20, r20, _PAGE_ACCESSED
-	stw	r20, 0(r21)
+	rlwimi	r11, r10, 0, 27, 27
+	DO_8xx_CPU6(0x3b80, r3)
+	mtspr	MD_TWC, r11
+
+	mfspr	r11, MD_TWC	/* get the pte address again */
+	ori	r10, r10, _PAGE_ACCESSED
+	stw	r10, 0(r11)
 
 	/* The Linux PTE won't go exactly into the MMU TLB.
 	 * Software indicator bits 21, 22 and 28 must be clear.
@@ -453,29 +419,24 @@
 	 * set.  All other Linux PTE bits control the behavior
 	 * of the MMU.
 	 */
-	li	r21, 0x00f0
-	rlwimi	r20, r21, 0, 24, 28	/* Set 24-27, clear 28 */
-
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x3d80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MD_RPN, r20	/* Update TLB entry */
-
-	mfspr	r20, M_TW	/* Restore registers */
-	lwz	r21, 0(r0)
-	mtcr	r21
-	lwz	r21, 4(r0)
+	li	r11, 0x00f0
+	rlwimi	r10, r11, 0, 24, 28	/* Set 24-27, clear 28 */
+	DO_8xx_CPU6(0x3d80, r3)
+	mtspr	MD_RPN, r10	/* Update TLB entry */
+
+	mfspr	r10, M_TW	/* Restore registers */
+	lwz	r11, 0(r0)
+	mtcr	r11
+	lwz	r11, 4(r0)
 #ifdef CONFIG_8xx_CPU6
 	lwz	r3, 8(r0)
 #endif
 	rfi
 
-2:	mfspr	r20, M_TW	/* Restore registers */
-	lwz	r21, 0(r0)
-	mtcr	r21
-	lwz	r21, 4(r0)
+2:	mfspr	r10, M_TW	/* Restore registers */
+	lwz	r11, 0(r0)
+	mtcr	r11
+	lwz	r11, 4(r0)
 #ifdef CONFIG_8xx_CPU6
 	lwz	r3, 8(r0)
 #endif
@@ -501,19 +462,17 @@
 DataTLBError:
 #ifdef CONFIG_8xx_CPU6
 	stw	r3, 8(r0)
-	li	r3, 0x3f80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
 #endif
-	mtspr	M_TW, r20	/* Save a couple of working registers */
-	mfcr	r20
-	stw	r20, 0(r0)
-	stw	r21, 4(r0)
+	DO_8xx_CPU6(0x3f80, r3)
+	mtspr	M_TW, r10	/* Save a couple of working registers */
+	mfcr	r10
+	stw	r10, 0(r0)
+	stw	r11, 4(r0)
 
 	/* First, make sure this was a store operation.
 	*/
-	mfspr	r20, DSISR
-	andis.	r21, r20, 0x0200	/* If set, indicates store op */
+	mfspr	r10, DSISR
+	andis.	r11, r10, 0x0200	/* If set, indicates store op */
 	beq	2f
 
 	/* The EA of a data TLB miss is automatically stored in the MD_EPN
@@ -532,54 +491,45 @@
 	 * are initialized in mapin_ram().  This will avoid the problem,
 	 * assuming we only use the dcbi instruction on kernel addresses.
 	 */
-	mfspr	r20, DAR
-	rlwinm	r21, r20, 0, 0, 19
-	ori	r21, r21, MD_EVALID
-	mfspr	r20, M_CASID
-	rlwimi	r21, r20, 0, 28, 31
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x3780
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MD_EPN, r21
+	mfspr	r10, DAR
+	rlwinm	r11, r10, 0, 0, 19
+	ori	r11, r11, MD_EVALID
+	mfspr	r10, M_CASID
+	rlwimi	r11, r10, 0, 28, 31
+	DO_8xx_CPU6(0x3780, r3)
+	mtspr	MD_EPN, r11
 
-	mfspr	r20, M_TWB	/* Get level 1 table entry address */
+	mfspr	r10, M_TWB	/* Get level 1 table entry address */
 
 	/* If we are faulting a kernel address, we have to use the
 	 * kernel page tables.
 	 */
-	andi.	r21, r20, 0x0800
+	andi.	r11, r10, 0x0800
 	beq	3f
-	lis	r21, swapper_pg_dir@h
-	ori	r21, r21, swapper_pg_dir@l
-	rlwimi	r20, r21, 0, 2, 19
+	lis	r11, swapper_pg_dir@h
+	ori	r11, r11, swapper_pg_dir@l
+	rlwimi	r10, r11, 0, 2, 19
 3:
-	lwz	r21, 0(r20)	/* Get the level 1 entry */
-	rlwinm.	r20, r21,0,0,19	/* Extract page descriptor page address */
+	lwz	r11, 0(r10)	/* Get the level 1 entry */
+	rlwinm.	r10, r11,0,0,19	/* Extract page descriptor page address */
 	beq	2f		/* If zero, bail */
 
 	/* We have a pte table, so fetch the pte from the table.
 	 */
-	tophys(r21, r21)
-	ori	r21, r21, 1		/* Set valid bit in physical L2 page */
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x3b80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MD_TWC, r21		/* Load pte table base address */
-	mfspr	r21, MD_TWC		/* ....and get the pte address */
-	lwz	r20, 0(r21)		/* Get the pte */
+	ori	r11, r11, 1		/* Set valid bit in physical L2 page */
+	DO_8xx_CPU6(0x3b80, r3)
+	mtspr	MD_TWC, r11		/* Load pte table base address */
+	mfspr	r11, MD_TWC		/* ....and get the pte address */
+	lwz	r10, 0(r11)		/* Get the pte */
 
-	andi.	r21, r20, _PAGE_RW	/* Is it writeable? */
+	andi.	r11, r10, _PAGE_RW	/* Is it writeable? */
 	beq	2f			/* Bail out if not */
 
 	/* Update 'changed', among others.
 	*/
-	ori	r20, r20, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
-	mfspr	r21, MD_TWC		/* Get pte address again */
-	stw	r20, 0(r21)		/* and update pte in table */
+	ori	r10, r10, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
+	mfspr	r11, MD_TWC		/* Get pte address again */
+	stw	r10, 0(r11)		/* and update pte in table */
 
 	/* The Linux PTE won't go exactly into the MMU TLB.
 	 * Software indicator bits 21, 22 and 28 must be clear.
@@ -587,60 +537,50 @@
 	 * set.  All other Linux PTE bits control the behavior
 	 * of the MMU.
 	 */
-	li	r21, 0x00f0
-	rlwimi	r20, r21, 0, 24, 28	/* Set 24-27, clear 28 */
-
-#ifdef CONFIG_8xx_CPU6
-	li	r3, 0x3d80
-	stw	r3, 12(r0)
-	lwz	r3, 12(r0)
-#endif
-	mtspr	MD_RPN, r20	/* Update TLB entry */
-
-	mfspr	r20, M_TW	/* Restore registers */
-	lwz	r21, 0(r0)
-	mtcr	r21
-	lwz	r21, 4(r0)
+	li	r11, 0x00f0
+	rlwimi	r10, r11, 0, 24, 28	/* Set 24-27, clear 28 */
+	DO_8xx_CPU6(0x3d80, r3)
+	mtspr	MD_RPN, r10	/* Update TLB entry */
+
+	mfspr	r10, M_TW	/* Restore registers */
+	lwz	r11, 0(r0)
+	mtcr	r11
+	lwz	r11, 4(r0)
 #ifdef CONFIG_8xx_CPU6
 	lwz	r3, 8(r0)
 #endif
 	rfi
 2:
-	mfspr	r20, M_TW	/* Restore registers */
-	lwz	r21, 0(r0)
-	mtcr	r21
-	lwz	r21, 4(r0)
+	mfspr	r10, M_TW	/* Restore registers */
+	lwz	r11, 0(r0)
+	mtcr	r11
+	lwz	r11, 4(r0)
 #ifdef CONFIG_8xx_CPU6
 	lwz	r3, 8(r0)
 #endif
 	b	DataAccess
 
-	STD_EXCEPTION(0x1500, Trap_15, UnknownException)
-	STD_EXCEPTION(0x1600, Trap_16, UnknownException)
-	STD_EXCEPTION(0x1700, Trap_17, TAUException)
-	STD_EXCEPTION(0x1800, Trap_18, UnknownException)
-	STD_EXCEPTION(0x1900, Trap_19, UnknownException)
-	STD_EXCEPTION(0x1a00, Trap_1a, UnknownException)
-	STD_EXCEPTION(0x1b00, Trap_1b, UnknownException)
+	EXCEPTION(0x1500, Trap_15, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1600, Trap_16, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1700, Trap_17, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1800, Trap_18, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1900, Trap_19, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1a00, Trap_1a, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1b00, Trap_1b, UnknownException, EXC_XFER_EE)
 
 /* On the MPC8xx, these next four traps are used for development
  * support of breakpoints and such.  Someday I will get around to
  * using them.
  */
-	STD_EXCEPTION(0x1c00, Trap_1c, UnknownException)
-	STD_EXCEPTION(0x1d00, Trap_1d, UnknownException)
-	STD_EXCEPTION(0x1e00, Trap_1e, UnknownException)
-	STD_EXCEPTION(0x1f00, Trap_1f, UnknownException)
+	EXCEPTION(0x1c00, Trap_1c, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1d00, Trap_1d, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1e00, Trap_1e, UnknownException, EXC_XFER_EE)
+	EXCEPTION(0x1f00, Trap_1f, UnknownException, EXC_XFER_EE)
 
 	. = 0x2000
 
 	.globl	giveup_fpu
 giveup_fpu:
-	blr
-
-/* Maybe someday.......
-*/
-_GLOBAL(__setup_cpu_8xx)
 	blr
 
 /*
diff -Nru a/arch/ppc/kernel/head_booke.h b/arch/ppc/kernel/head_booke.h
--- a/arch/ppc/kernel/head_booke.h	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc/kernel/head_booke.h	2004-12-24 13:36:17 -08:00
@@ -237,4 +237,70 @@
 			  ret_from_except)
 
 
+/* Check for a single step debug exception while in an exception
+ * handler before state has been saved.  This is to catch the case
+ * where an instruction that we are trying to single step causes
+ * an exception (eg ITLB/DTLB miss) and thus the first instruction of
+ * the exception handler generates a single step debug exception.
+ *
+ * If we get a debug trap on the first instruction of an exception handler,
+ * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
+ * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
+ * The exception handler was handling a non-critical interrupt, so it will
+ * save (and later restore) the MSR via SPRN_CSRR1, which will still have
+ * the MSR_DE bit set.
+ */
+#define DEBUG_EXCEPTION							      \
+	START_EXCEPTION(Debug);						      \
+	CRITICAL_EXCEPTION_PROLOG;					      \
+									      \
+	/*								      \
+	 * If there is a single step or branch-taken exception in an	      \
+	 * exception entry sequence, it was probably meant to apply to	      \
+	 * the code where the exception occurred (since exception entry	      \
+	 * doesn't turn off DE automatically).  We simulate the effect	      \
+	 * of turning off DE on entry to an exception handler by turning      \
+	 * off DE in the CSRR1 value and clearing the debug status.	      \
+	 */								      \
+	mfspr	r10,SPRN_DBSR;		/* check single-step/branch taken */  \
+	andis.	r10,r10,DBSR_IC@h;					      \
+	beq+	2f;							      \
+									      \
+	lis	r10,KERNELBASE@h;	/* check if exception in vectors */   \
+	ori	r10,r10,KERNELBASE@l;					      \
+	cmplw	r12,r10;						      \
+	blt+	2f;			/* addr below exception vectors */    \
+									      \
+	lis	r10,Debug@h;						      \
+	ori	r10,r10,Debug@l;					      \
+	cmplw	r12,r10;						      \
+	bgt+	2f;			/* addr above exception vectors */    \
+									      \
+	/* here it looks like we got an inappropriate debug exception. */     \
+1:	rlwinm	r9,r9,0,~MSR_DE;	/* clear DE in the CSRR1 value */     \
+	lis	r10,DBSR_IC@h;		/* clear the IC event */	      \
+	mtspr	SPRN_DBSR,r10;						      \
+	/* restore state and get out */					      \
+	lwz	r10,_CCR(r11);						      \
+	lwz	r0,GPR0(r11);						      \
+	lwz	r1,GPR1(r11);						      \
+	mtcrf	0x80,r10;						      \
+	mtspr	CSRR0,r12;						      \
+	mtspr	CSRR1,r9;						      \
+	lwz	r9,GPR9(r11);						      \
+	lwz	r12,GPR12(r11);						      \
+	mtspr	SPRG2,r8;		/* SPRG2 only used in criticals */    \
+	lis	r8,crit_save@ha;					      \
+	lwz	r10,crit_r10@l(r8);					      \
+	lwz	r11,crit_r11@l(r8);					      \
+	mfspr	r8,SPRG2;						      \
+									      \
+	rfci;								      \
+	b	.;							      \
+									      \
+	/* continue normal handling for a critical exception... */	      \
+2:	mfspr	r4,SPRN_DBSR;						      \
+	addi	r3,r1,STACK_FRAME_OVERHEAD;				      \
+	EXC_XFER_TEMPLATE(DebugException, 0x2002, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
+
 #endif /* __HEAD_BOOKE_H__ */
diff -Nru a/arch/ppc/kernel/head_e500.S b/arch/ppc/kernel/head_e500.S
--- a/arch/ppc/kernel/head_e500.S	2004-12-24 13:37:04 -08:00
+++ b/arch/ppc/kernel/head_e500.S	2004-12-24 13:37:04 -08:00
@@ -668,64 +668,8 @@
 	/* Performance Monitor */
 	EXCEPTION(0x2060, PerformanceMonitor, UnknownException, EXC_XFER_EE)
 
-/* Check for a single step debug exception while in an exception
- * handler before state has been saved.  This is to catch the case
- * where an instruction that we are trying to single step causes
- * an exception (eg ITLB/DTLB miss) and thus the first instruction of
- * the exception handler generates a single step debug exception.
- *
- * If we get a debug trap on the first instruction of an exception handler,
- * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
- * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
- * The exception handler was handling a non-critical interrupt, so it will
- * save (and later restore) the MSR via SPRN_SRR1, which will still have
- * the MSR_DE bit set.
- */
 	/* Debug Interrupt */
-	START_EXCEPTION(Debug)
-	CRITICAL_EXCEPTION_PROLOG
-
-	/*
-	 * If this is a single step or branch-taken exception in an
-	 * exception entry sequence, it was probably meant to apply to
-	 * the code where the exception occurred (since exception entry
-	 * doesn't turn off DE automatically).  We simulate the effect
-	 * of turning off DE on entry to an exception handler by turning
-	 * off DE in the CSRR1 value and clearing the debug status.
-	 */
-	mfspr	r10,SPRN_DBSR		/* check single-step/branch taken */
-	andis.	r10,r10,(DBSR_IC|DBSR_BT)@h
-	beq+	1f
-	andi.	r0,r9,MSR_PR		/* check supervisor */
-	beq	2f			/* branch if we need to fix it up... */
-
-	/* continue normal handling for a critical exception... */
-1:	mfspr	r4,SPRN_DBSR
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	EXC_XFER_TEMPLATE(DebugException, 0x2002, \
-		(MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
-		NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
-
-	/* here it looks like we got an inappropriate debug exception. */
-2:	rlwinm	r9,r9,0,~MSR_DE		/* clear DE in the CSRR1 value */
-	mtspr	SPRN_DBSR,r10		/* clear the IC/BT debug intr status */
-	/* restore state and get out */
-	lwz	r10,_CCR(r11)
-	lwz	r0,GPR0(r11)
-	lwz	r1,GPR1(r11)
-	mtcrf	0x80,r10
-	mtspr	CSRR0,r12
-	mtspr	CSRR1,r9
-	lwz	r9,GPR9(r11)
-
-	mtspr	SPRG2,r8;		/* SPRG2 only used in criticals */
-	lis	r8,crit_save@ha;
-	lwz	r10,crit_r10@l(r8)
-	lwz	r11,crit_r11@l(r8)
-	mfspr	r8,SPRG2
-
-	rfci
-	b	.
+	DEBUG_EXCEPTION
 
 /*
  * Local functions
diff -Nru a/arch/ppc/kernel/irq.c b/arch/ppc/kernel/irq.c
--- a/arch/ppc/kernel/irq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc/kernel/irq.c	2004-12-24 13:37:18 -08:00
@@ -47,9 +47,9 @@
 #include <linux/seq_file.h>
 #include <linux/cpumask.h>
 #include <linux/profile.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
@@ -62,296 +62,20 @@
 
 extern atomic_t ipi_recv;
 extern atomic_t ipi_sent;
-void enable_irq(unsigned int irq_nr);
-void disable_irq(unsigned int irq_nr);
-
-static void register_irq_proc (unsigned int irq);
 
 #define MAXCOUNT 10000000
 
-irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
-	[0 ... NR_IRQS-1] = {
-		.lock = SPIN_LOCK_UNLOCKED
-	}
-};
-
 int ppc_spurious_interrupts = 0;
 struct irqaction *ppc_irq_action[NR_IRQS];
 unsigned long ppc_cached_irq_mask[NR_MASK_WORDS];
 unsigned long ppc_lost_interrupts[NR_MASK_WORDS];
 atomic_t ppc_n_lost_interrupts;
 
-/* nasty hack for shared irq's since we need to do kmalloc calls but
- * can't very early in the boot when we need to do a request irq.
- * this needs to be removed.
- * -- Cort
- */
-#define IRQ_KMALLOC_ENTRIES 8
-static int cache_bitmask = 0;
-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);
+#ifdef CONFIG_TAU_INT
 extern int tau_initialized;
+extern int tau_interrupts(int);
 #endif
 
-void *irq_kmalloc(size_t size, int pri)
-{
-	unsigned int i;
-	if ( mem_init_done )
-		return kmalloc(size,pri);
-	for ( i = 0; i < IRQ_KMALLOC_ENTRIES ; i++ )
-		if ( ! ( cache_bitmask & (1<<i) ) )
-		{
-			cache_bitmask |= (1<<i);
-			return (void *)(&malloc_cache[i]);
-		}
-	return NULL;
-}
-
-void irq_kfree(void *ptr)
-{
-	unsigned int i;
-	for ( i = 0 ; i < IRQ_KMALLOC_ENTRIES ; i++ )
-		if ( ptr == &malloc_cache[i] )
-		{
-			cache_bitmask &= ~(1<<i);
-			return;
-		}
-	kfree(ptr);
-}
-
-int
-setup_irq(unsigned int irq, struct irqaction * new)
-{
-	int shared = 0;
-	unsigned long flags;
-	struct irqaction *old, **p;
-	irq_desc_t *desc = irq_desc + irq;
-
-	/*
-	 * Some drivers like serial.c use request_irq() heavily,
-	 * so we have to be careful not to interfere with a
-	 * running system.
-	 */
-	if (new->flags & SA_SAMPLE_RANDOM) {
-		/*
-		 * This function might sleep, we want to call it first,
-		 * outside of the atomic block.
-		 * Yes, this might clear the entropy pool if the wrong
-		 * driver is attempted to be loaded, without actually
-		 * installing a new handler, but is this really a problem,
-		 * only the sysadmin is able to do this.
-		 */
-		rand_initialize_irq(irq);
-	}
-
-	/*
-	 * The following block of code has to be executed atomically
-	 */
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	if ((old = *p) != NULL) {
-		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
-			spin_unlock_irqrestore(&desc->lock,flags);
-			return -EBUSY;
-		}
-
-		/* add new interrupt at end of irq queue */
-		do {
-			p = &old->next;
-			old = *p;
-		} while (old);
-		shared = 1;
-	}
-
-	*p = new;
-
-	if (!shared) {
-		desc->depth = 0;
-		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING);
-		if (desc->handler) {
-			if (desc->handler->startup)
-				desc->handler->startup(irq);
-			else if (desc->handler->enable)
-				desc->handler->enable(irq);
-		}
-	}
-	spin_unlock_irqrestore(&desc->lock,flags);
-
-	register_irq_proc(irq);
-	return 0;
-}
-
-void free_irq(unsigned int irq, void* dev_id)
-{
-	irq_desc_t *desc;
-	struct irqaction **p;
-	unsigned long flags;
-
-	desc = irq_desc + irq;
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	for (;;) {
-		struct irqaction * action = *p;
-		if (action) {
-			struct irqaction **pp = p;
-			p = &action->next;
-			if (action->dev_id != dev_id)
-				continue;
-
-			/* Found it - now remove it from the list of entries */
-			*pp = action->next;
-			if (!desc->action) {
-				desc->status |= IRQ_DISABLED;
-				mask_irq(irq);
-			}
-			spin_unlock_irqrestore(&desc->lock,flags);
-
-			synchronize_irq(irq);
-			irq_kfree(action);
-			return;
-		}
-		printk("Trying to free free IRQ%d\n",irq);
-		spin_unlock_irqrestore(&desc->lock,flags);
-		break;
-	}
-	return;
-}
-
-EXPORT_SYMBOL(free_irq);
-
-int request_irq(unsigned int irq,
-	irqreturn_t (*handler)(int, void *, struct pt_regs *),
-	unsigned long irqflags, const char * devname, void *dev_id)
-{
-	struct irqaction *action;
-	int retval;
-
-	if (irq >= NR_IRQS)
-		return -EINVAL;
-	if (!handler) {
-		printk(KERN_ERR "request_irq called with NULL handler!\n");
-		dump_stack();
-		return 0;
-	}
-
-	action = (struct irqaction *)
-		irq_kmalloc(sizeof(struct irqaction), GFP_KERNEL);
-	if (!action) {
-		printk(KERN_ERR "irq_kmalloc() failed for irq %d !\n", irq);
-		return -ENOMEM;
-	}
-
-	action->handler = handler;
-	action->flags = irqflags;			
-	cpus_clear(action->mask);
-	action->name = devname;
-	action->dev_id = dev_id;
-	action->next = NULL;
-
-	retval = setup_irq(irq, action);
-	if (retval) {
-		kfree(action);
-		return retval;
-	}
-
-	return 0;
-}
-
-EXPORT_SYMBOL(request_irq);
-
-/*
- * Generic enable/disable code: this just calls
- * down into the PIC-specific version for the actual
- * hardware disable after having gotten the irq
- * controller lock.
- */
-
-/**
- *	disable_irq_nosync - disable an irq without waiting
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line. Disables of an interrupt
- *	stack. Unlike disable_irq(), this function does not ensure existing
- *	instances of the IRQ handler have completed before returning.
- *
- *	This function may be called from IRQ context.
- */
-
-void disable_irq_nosync(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	if (!desc->depth++) {
-		if (!(desc->status & IRQ_PER_CPU))
-			desc->status |= IRQ_DISABLED;
-		mask_irq(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-/**
- *	disable_irq - disable an irq and wait for completion
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line. Disables of an interrupt
- *	stack. That is for two disables you need two enables. This
- *	function waits for any pending IRQ handlers for this interrupt
- *	to complete before returning. If you use this function while
- *	holding a resource the IRQ handler may need you will deadlock.
- *
- *	This function may be called - with care - from IRQ context.
- */
-
-void disable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	disable_irq_nosync(irq);
-	if (desc->action)
-		synchronize_irq(irq);
-}
-
-/**
- *	enable_irq - enable interrupt handling on an irq
- *	@irq: Interrupt to enable
- *
- *	Re-enables the processing of interrupts on this IRQ line
- *	providing no disable_irq calls are now in effect.
- *
- *	This function may be called from IRQ context.
- */
-
-void enable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	switch (desc->depth) {
-	case 1: {
-		unsigned int status = desc->status & ~IRQ_DISABLED;
-		desc->status = status;
-		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
-			desc->status = status | IRQ_REPLAY;
-			hw_resend_irq(desc->handler,irq);
-		}
-		unmask_irq(irq);
-		/* fall-through */
-	}
-	default:
-		desc->depth--;
-		break;
-	case 0:
-		printk("enable_irq(%u) unbalanced\n", irq);
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
 int show_interrupts(struct seq_file *p, void *v)
 {
 	int i = *(loff_t *) v, j;
@@ -411,115 +135,6 @@
 	return 0;
 }
 
-static inline void
-handle_irq_event(int irq, struct pt_regs *regs, struct irqaction *action)
-{
-	int status = 0;
-	int ret;
-
-	if (!(action->flags & SA_INTERRUPT))
-		local_irq_enable();
-
-	do {
-		ret = action->handler(irq, action->dev_id, regs);
-		if (ret == IRQ_HANDLED)
-			status |= action->flags;
-		action = action->next;
-	} while (action);
-	if (status & SA_SAMPLE_RANDOM)
-		add_interrupt_randomness(irq);
-	local_irq_disable();
-}
-
-/*
- * Eventually, this should take an array of interrupts and an array size
- * so it can dispatch multiple interrupts.
- */
-void ppc_irq_dispatch_handler(struct pt_regs *regs, int irq)
-{
-	int status;
-	struct irqaction *action;
-	irq_desc_t *desc = irq_desc + irq;
-
-	kstat_this_cpu.irqs[irq]++;
-	spin_lock(&desc->lock);
-	ack_irq(irq);
-	/*
-	   REPLAY is when Linux resends an IRQ that was dropped earlier
-	   WAITING is used by probe to mark irqs that are being tested
-	   */
-	status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
-	if (!(status & IRQ_PER_CPU))
-		status |= IRQ_PENDING; /* we _want_ to handle it */
-
-	/*
-	 * If the IRQ is disabled for whatever reason, we cannot
-	 * use the action we have.
-	 */
-	action = NULL;
-	if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
-		action = desc->action;
-		if (!action || !action->handler) {
-			ppc_spurious_interrupts++;
-			printk(KERN_DEBUG "Unhandled interrupt %x, disabled\n", irq);
-			/* We can't call disable_irq here, it would deadlock */
-			++desc->depth;
-			desc->status |= IRQ_DISABLED;
-			mask_irq(irq);
-			/* This is a real interrupt, we have to eoi it,
-			   so we jump to out */
-			goto out;
-		}
-		status &= ~IRQ_PENDING; /* we commit to handling */
-		if (!(status & IRQ_PER_CPU))
-			status |= IRQ_INPROGRESS; /* we are handling it */
-	}
-	desc->status = status;
-
-	/*
-	 * If there is no IRQ handler or it was disabled, exit early.
-	   Since we set PENDING, if another processor is handling
-	   a different instance of this same irq, the other processor
-	   will take care of it.
-	 */
-	if (unlikely(!action))
-		goto out;
-
-
-	/*
-	 * Edge triggered interrupts need to remember
-	 * pending events.
-	 * This applies to any hw interrupts that allow a second
-	 * instance of the same irq to arrive while we are in do_IRQ
-	 * or in the handler. But the code here only handles the _second_
-	 * instance of the irq, not the third or fourth. So it is mostly
-	 * useful for irq hardware that does not mask cleanly in an
-	 * SMP environment.
-	 */
-	for (;;) {
-		spin_unlock(&desc->lock);
-		handle_irq_event(irq, regs, action);
-		spin_lock(&desc->lock);
-
-		if (likely(!(desc->status & IRQ_PENDING)))
-			break;
-		desc->status &= ~IRQ_PENDING;
-	}
-out:
-	desc->status &= ~IRQ_INPROGRESS;
-	/*
-	 * The ->end() handler has to deal with interrupts which got
-	 * disabled while the handler was running.
-	 */
-	if (irq_desc[irq].handler) {
-		if (irq_desc[irq].handler->end)
-			irq_desc[irq].handler->end(irq);
-		else if (irq_desc[irq].handler->enable)
-			irq_desc[irq].handler->enable(irq);
-	}
-	spin_unlock(&desc->lock);
-}
-
 void do_IRQ(struct pt_regs *regs)
 {
 	int irq, first = 1;
@@ -534,7 +149,7 @@
 	 * has already been handled. -- Tom
 	 */
 	while ((irq = ppc_md.get_irq(regs)) >= 0) {
-		ppc_irq_dispatch_handler(regs, irq);
+		__do_IRQ(irq, regs);
 		first = 0;
 	}
 	if (irq != -2 && first)
@@ -543,143 +158,7 @@
         irq_exit();
 }
 
-unsigned long probe_irq_on (void)
-{
-	return 0;
-}
-
-EXPORT_SYMBOL(probe_irq_on);
-
-int probe_irq_off (unsigned long irqs)
-{
-	return 0;
-}
-
-EXPORT_SYMBOL(probe_irq_off);
-
-unsigned int probe_irq_mask(unsigned long irqs)
-{
-	return 0;
-}
-
-#ifdef CONFIG_SMP
-void synchronize_irq(unsigned int irq)
-{
-	while (irq_desc[irq].status & IRQ_INPROGRESS)
-		barrier();
-}
-#endif /* CONFIG_SMP */
-
-static struct proc_dir_entry *root_irq_dir;
-static struct proc_dir_entry *irq_dir[NR_IRQS];
-static struct proc_dir_entry *smp_affinity_entry[NR_IRQS];
-
-#ifdef CONFIG_IRQ_ALL_CPUS
-#define DEFAULT_CPU_AFFINITY CPU_MASK_ALL
-#else
-#define DEFAULT_CPU_AFFINITY cpumask_of_cpu(0)
-#endif
-
-cpumask_t irq_affinity [NR_IRQS];
-
-static int irq_affinity_read_proc (char *page, char **start, off_t off,
-			int count, int *eof, void *data)
-{
-	int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
-	if (count - len < 2)
-		return -EINVAL;
-	len += sprintf(page + len, "\n");
-	return len;
-}
-
-static int irq_affinity_write_proc (struct file *file, const char __user *buffer,
-					unsigned long count, void *data)
-{
-	int irq = (int) data, full_count = count, err;
-	cpumask_t new_value, tmp;
-
-	if (!irq_desc[irq].handler->set_affinity)
-		return -EIO;
-
-	err = cpumask_parse(buffer, count, new_value);
-
-	/*
-	 * Do not allow disabling IRQs completely - it's a too easy
-	 * way to make the system unusable accidentally :-) At least
-	 * one online CPU still has to be targeted.
-	 *
-	 * We assume a 1-1 logical<->physical cpu mapping here.  If
-	 * we assume that the cpu indices in /proc/irq/../smp_affinity
-	 * are actually logical cpu #'s then we have no problem.
-	 *  -- Cort <cort@fsmlabs.com>
-	 */
-	cpus_and(tmp, new_value, cpu_online_map);
-	if (cpus_empty(tmp))
-		return -EINVAL;
-
-	irq_affinity[irq] = new_value;
-	irq_desc[irq].handler->set_affinity(irq, new_value);
-
-	return full_count;
-}
-
-#define MAX_NAMELEN 10
-
-static void register_irq_proc (unsigned int irq)
-{
-	struct proc_dir_entry *entry;
-	char name [MAX_NAMELEN];
-
-	if (!root_irq_dir || (irq_desc[irq].handler == NULL) || irq_dir[irq])
-		return;
-
-	memset(name, 0, MAX_NAMELEN);
-	sprintf(name, "%d", irq);
-
-	/* create /proc/irq/1234 */
-	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
-
-	/* create /proc/irq/1234/smp_affinity */
-	entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
-
-	entry->nlink = 1;
-	entry->data = (void *)irq;
-	entry->read_proc = irq_affinity_read_proc;
-	entry->write_proc = irq_affinity_write_proc;
-
-	smp_affinity_entry[irq] = entry;
-}
-
-void init_irq_proc (void)
-{
-	int i;
-
-	/* create /proc/irq */
-	root_irq_dir = proc_mkdir("irq", NULL);
-	/* create /proc/irq/prof_cpu_mask */
-	create_prof_cpu_mask(root_irq_dir);
-
-	/*
-	 * Create entries for all existing IRQs.
-	 */
-	for (i = 0; i < NR_IRQS; i++) {
-		if (irq_desc[i].handler == NULL)
-			continue;
-		register_irq_proc(i);
-	}
-}
-
-irqreturn_t no_action(int irq, void *dev, struct pt_regs *regs)
-{
-	return IRQ_NONE;
-}
-
 void __init init_IRQ(void)
 {
-	int i;
-
-	for (i = 0; i < NR_IRQS; ++i)
-		irq_affinity[i] = DEFAULT_CPU_AFFINITY;
-
 	ppc_md.init_IRQ();
 }
diff -Nru a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S
--- a/arch/ppc/kernel/misc.S	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/kernel/misc.S	2004-12-24 13:37:19 -08:00
@@ -1447,3 +1447,6 @@
 	.long sys_mq_notify
 	.long sys_mq_getsetattr
 	.long sys_ni_syscall		/* 268 reserved for sys_kexec_load */
+	.long sys_add_key
+	.long sys_request_key		/* 270 */
+	.long sys_keyctl
diff -Nru a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
--- a/arch/ppc/kernel/pci.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc/kernel/pci.c	2004-12-24 13:36:48 -08:00
@@ -231,14 +231,12 @@
 static void __init
 pcibios_allocate_bus_resources(struct list_head *bus_list)
 {
-	struct list_head *ln;
 	struct pci_bus *bus;
 	int i;
 	struct resource *res, *pr;
 
 	/* Depth-First Search on bus tree */
-	for (ln = bus_list->next; ln != bus_list; ln=ln->next) {
-		bus = pci_bus_b(ln);
+	list_for_each_entry(bus, bus_list, node) {
 		for (i = 0; i < 4; ++i) {
 			if ((res = bus->resource[i]) == NULL || !res->flags
 			    || res->start > res->end)
@@ -381,7 +379,6 @@
 	struct pci_bus *bus;
 	struct pci_dev *dev;
 	struct resource *r;
-	struct list_head *ln;
 	int i;
 
 	for (r = pr->child; r != NULL; r = r->sibling) {
@@ -390,9 +387,7 @@
 			return 1;
 		}
 	}
-	for (ln = parent->children.next; ln != &parent->children;
-	     ln = ln->next) {
-		bus = pci_bus_b(ln);
+	list_for_each_entry(bus, &parent->children, node) {
 		for (i = 0; i < 4; ++i) {
 			if ((r = bus->resource[i]) == NULL)
 				continue;
@@ -406,8 +401,7 @@
 			}
 		}
 	}
-	for (ln = parent->devices.next; ln != &parent->devices; ln=ln->next) {
-		dev = pci_dev_b(ln);
+	list_for_each_entry(dev, &parent->devices, bus_list) {
 		for (i = 0; i < 6; ++i) {
 			r = &dev->resource[i];
 			if (!r->flags || (r->flags & IORESOURCE_UNSET))
@@ -1102,7 +1096,7 @@
 static int __init
 check_for_io_childs(struct pci_bus *bus, struct resource* res, int *found_vga)
 {
-	struct list_head *ln;
+	struct pci_dev *dev;
 	int	i;
 	int	rc = 0;
 
@@ -1110,8 +1104,7 @@
 	res->end = ((res->end + __sz) / (__sz + 1)) * (__sz + 1) + __sz; \
     } while (0)
 
-	for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) {
-		struct pci_dev *dev = pci_dev_b(ln);
+	list_for_each_entry(dev, &bus->devices, bus_list) {
 		u16 class = dev->class >> 8;
 
 		if (class == PCI_CLASS_DISPLAY_VGA ||
@@ -1152,7 +1145,7 @@
 static void __init
 do_fixup_p2p_level(struct pci_bus *bus)
 {
-	struct list_head *ln;
+	struct pci_bus *b;
 	int i, parent_io;
 	int has_vga = 0;
 
@@ -1163,8 +1156,7 @@
 	if (parent_io >= 4)
 		return;
 
-	for (ln=bus->children.next; ln != &bus->children; ln=ln->next) {
-		struct pci_bus *b = pci_bus_b(ln);
+	list_for_each_entry(b, &bus->children, node) {
 		struct pci_dev *d = b->self;
 		struct pci_controller* hose = (struct pci_controller *)d->sysdata;
 		struct resource *res = b->resource[0];
@@ -1237,12 +1229,10 @@
 static void
 pcibios_fixup_p2p_bridges(void)
 {
-	struct list_head *ln;
+	struct pci_bus *b;
 
-	for(ln=pci_root_buses.next; ln != &pci_root_buses; ln=ln->next) {
-		struct pci_bus *b = pci_bus_b(ln);
+	list_for_each_entry(b, &pci_root_buses, node)
 		do_fixup_p2p_level(b);
-	}
 }
 
 #endif /* CONFIG_PPC_PMAC */
@@ -1601,7 +1591,7 @@
 	__pci_mmap_set_flags(dev, vma, mmap_state);
 	__pci_mmap_set_pgprot(dev, vma, mmap_state, write_combine);
 
-	ret = remap_page_range(vma, vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+	ret = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
 			       vma->vm_end - vma->vm_start, vma->vm_page_prot);
 
 	return ret;
diff -Nru a/arch/ppc/kernel/ppc-stub.c b/arch/ppc/kernel/ppc-stub.c
--- a/arch/ppc/kernel/ppc-stub.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/kernel/ppc-stub.c	2004-12-24 13:37:19 -08:00
@@ -498,7 +498,7 @@
 	unsigned int tt;		/* Trap type code for powerpc */
 	unsigned char signo;		/* Signal that we map this trap into */
 } hard_trap_info[] = {
-#if defined(CONFIG_40x)
+#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
 	{ 0x100, SIGINT  },		/* critical input interrupt */
 	{ 0x200, SIGSEGV },		/* machine check */
 	{ 0x300, SIGSEGV },		/* data storage */
@@ -521,7 +521,7 @@
 	** 0x1100  data TLB miss
 	** 0x1200  instruction TLB miss
 	*/
-	{ 0x2000, SIGTRAP},		/* debug */
+	{ 0x2002, SIGTRAP},		/* debug */
 #else
 	{ 0x200, SIGSEGV },		/* machine check */
 	{ 0x300, SIGSEGV },		/* address error (store) */
@@ -602,11 +602,6 @@
 	sigval = computeSignal(regs->trap);
 	ptr = remcomOutBuffer;
 
-#if defined(CONFIG_40x)
-	*ptr++ = 'S';
-	*ptr++ = hexchars[sigval >> 4];
-	*ptr++ = hexchars[sigval & 0xf];
-#else
 	*ptr++ = 'T';
 	*ptr++ = hexchars[sigval >> 4];
 	*ptr++ = hexchars[sigval & 0xf];
@@ -620,8 +615,6 @@
 	*ptr++ = ':';
 	ptr = mem2hex(((char *)regs) + SP_REGNUM*4, ptr, 4);
 	*ptr++ = ';';
-#endif
-
 	*ptr++ = 0;
 
 	putpacket(remcomOutBuffer);
@@ -774,10 +767,6 @@
  * some location may have changed something that is in the instruction cache.
  */
 			kgdb_flush_cache_all();
-#if defined(CONFIG_40x)
-			strcpy(remcomOutBuffer, "OK");
-			putpacket(remcomOutBuffer);
-#endif
 			mtmsr(msr);
 
 			kgdb_interruptible(1);
@@ -791,10 +780,9 @@
 
 		case 's':
 			kgdb_flush_cache_all();
-#if defined(CONFIG_40x)
+#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
+			mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC);
 			regs->msr |= MSR_DE;
-			regs->dbcr0 |= (DBCR0_IDM | DBCR0_IC);
-			mtmsr(msr);
 #else
 			regs->msr |= MSR_SE;
 #endif
diff -Nru a/arch/ppc/kernel/ppc_htab.c b/arch/ppc/kernel/ppc_htab.c
--- a/arch/ppc/kernel/ppc_htab.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc/kernel/ppc_htab.c	2004-12-24 13:36:17 -08:00
@@ -21,9 +21,9 @@
 #include <linux/smp_lock.h>
 #include <linux/seq_file.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/mmu.h>
 #include <asm/residual.h>
 #include <asm/io.h>
diff -Nru a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
--- a/arch/ppc/kernel/ppc_ksyms.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/kernel/ppc_ksyms.c	2004-12-24 13:37:19 -08:00
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/ide.h>
 #include <linux/pm.h>
+#include <linux/bitops.h>
 
 #include <asm/page.h>
 #include <asm/semaphore.h>
@@ -23,7 +24,6 @@
 #include <asm/io.h>
 #include <asm/ide.h>
 #include <asm/atomic.h>
-#include <asm/bitops.h>
 #include <asm/checksum.h>
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
@@ -84,10 +84,6 @@
 EXPORT_SYMBOL(sys_sigreturn);
 EXPORT_SYMBOL(ppc_n_lost_interrupts);
 EXPORT_SYMBOL(ppc_lost_interrupts);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(disable_irq_nosync);
-EXPORT_SYMBOL(probe_irq_mask);
 
 EXPORT_SYMBOL(ISA_DMA_THRESHOLD);
 EXPORT_SYMBOL(DMA_MODE_READ);
@@ -205,7 +201,6 @@
 #ifdef CONFIG_SMP
 EXPORT_SYMBOL(smp_call_function);
 EXPORT_SYMBOL(smp_hw_index);
-EXPORT_SYMBOL(synchronize_irq);
 #endif
 
 EXPORT_SYMBOL(ppc_md);
@@ -292,8 +287,6 @@
 #endif
 EXPORT_SYMBOL(timer_interrupt);
 EXPORT_SYMBOL(irq_desc);
-void ppc_irq_dispatch_handler(struct pt_regs *, int);
-EXPORT_SYMBOL(ppc_irq_dispatch_handler);
 EXPORT_SYMBOL(tb_ticks_per_jiffy);
 EXPORT_SYMBOL(get_wchan);
 EXPORT_SYMBOL(console_drivers);
@@ -327,9 +320,6 @@
 #endif /* CONFIG_8xx */
 #if defined(CONFIG_8xx) || defined(CONFIG_40x) || defined(CONFIG_85xx)
 EXPORT_SYMBOL(__res);
-#endif
-#if defined(CONFIG_8xx)
-EXPORT_SYMBOL(request_8xxirq);
 #endif
 
 EXPORT_SYMBOL(next_mmu_context);
diff -Nru a/arch/ppc/kernel/process.c b/arch/ppc/kernel/process.c
--- a/arch/ppc/kernel/process.c	2004-12-24 13:36:49 -08:00
+++ b/arch/ppc/kernel/process.c	2004-12-24 13:36:49 -08:00
@@ -321,7 +321,7 @@
 	trap = TRAP(regs);
 	if (trap == 0x300 || trap == 0x600)
 		printk("DAR: %08lX, DSISR: %08lX\n", regs->dar, regs->dsisr);
-	printk("TASK = %p[%d] '%s' THREAD: %p",
+	printk("TASK = %p[%d] '%s' THREAD: %p\n",
 	       current, current->pid, current->comm, current->thread_info);
 	printk("Last syscall: %ld ", current->thread.last_syscall);
 
@@ -370,6 +370,10 @@
 		last_task_used_math = NULL;
 	if (last_task_used_altivec == current)
 		last_task_used_altivec = NULL;
+#ifdef CONFIG_SPE
+	if (last_task_used_spe == current)
+		last_task_used_spe = NULL;
+#endif
 }
 
 void flush_thread(void)
@@ -378,6 +382,10 @@
 		last_task_used_math = NULL;
 	if (last_task_used_altivec == current)
 		last_task_used_altivec = NULL;
+#ifdef CONFIG_SPE
+	if (last_task_used_spe == current)
+		last_task_used_spe = NULL;
+#endif
 }
 
 void
@@ -422,8 +430,6 @@
 	unsigned long sp = (unsigned long)p->thread_info + THREAD_SIZE;
 	unsigned long childframe;
 
-	p->set_child_tid = p->clear_child_tid = NULL;
-
 	CHECK_FULL_REGS(regs);
 	/* Copy registers */
 	sp -= sizeof(struct pt_regs);
@@ -482,6 +488,10 @@
 		last_task_used_math = NULL;
 	if (last_task_used_altivec == current)
 		last_task_used_altivec = NULL;
+#ifdef CONFIG_SPE
+	if (last_task_used_spe == current)
+		last_task_used_spe = NULL;
+#endif
 	memset(current->thread.fpr, 0, sizeof(current->thread.fpr));
 	current->thread.fpscr = 0;
 #ifdef CONFIG_ALTIVEC
@@ -598,8 +608,11 @@
 	preempt_enable();
 	error = do_execve(filename, (char __user *__user *) a1,
 			  (char __user *__user *) a2, regs);
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 out:
 	return error;
diff -Nru a/arch/ppc/kernel/ptrace.c b/arch/ppc/kernel/ptrace.c
--- a/arch/ppc/kernel/ptrace.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc/kernel/ptrace.c	2004-12-24 13:36:31 -08:00
@@ -35,7 +35,7 @@
 /*
  * Set of msr bits that gdb can change on behalf of a process.
  */
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
 #define MSR_DEBUGCHANGE	0
 #else
 #define MSR_DEBUGCHANGE	(MSR_SE | MSR_BE)
@@ -201,9 +201,9 @@
 	struct pt_regs *regs = task->thread.regs;
 
 	if (regs != NULL) {
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
 		task->thread.dbcr0 = DBCR0_IDM | DBCR0_IC;
-		/* MSR.DE should already be set */
+		regs->msr |= MSR_DE;
 #else
 		regs->msr |= MSR_SE;
 #endif
@@ -216,8 +216,9 @@
 	struct pt_regs *regs = task->thread.regs;
 
 	if (regs != NULL) {
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
 		task->thread.dbcr0 = 0;
+		regs->msr &= ~MSR_DE;
 #else
 		regs->msr &= ~MSR_SE;
 #endif
@@ -377,7 +378,7 @@
  */
 	case PTRACE_KILL: {
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		/* make sure the single step bit is not set. */
diff -Nru a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
--- a/arch/ppc/kernel/setup.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc/kernel/setup.c	2004-12-24 13:37:29 -08:00
@@ -226,6 +226,10 @@
 		maj = ((pvr >> 8) & 0xFF) - 1;
 		min = pvr & 0xFF;
 		break;
+	case 0x8020:	/* e500 */
+		maj = PVR_MAJ(pvr);
+		min = PVR_MIN(pvr);
+		break;
 	default:
 		maj = (pvr >> 8) & 0xFF;
 		min = pvr & 0xFF;
diff -Nru a/arch/ppc/kernel/signal.c b/arch/ppc/kernel/signal.c
--- a/arch/ppc/kernel/signal.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc/kernel/signal.c	2004-12-24 13:37:29 -08:00
@@ -290,7 +290,7 @@
 
 	/* force the process to reload the FP registers from
 	   current->thread when it next does FP instructions */
-	regs->msr &= ~MSR_FP;
+	regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1);
 	if (__copy_from_user(current->thread.fpr, &sr->mc_fregs,
 			     sizeof(sr->mc_fregs)))
 		return 1;
@@ -319,7 +319,7 @@
 	if (!__get_user(msr, &sr->mc_gregs[PT_MSR]) && (msr & MSR_SPE) != 0) {
 		/* restore spe registers from the stack */
 		if (__copy_from_user(current->thread.evr, &sr->mc_vregs,
-				     sizeof(sr->mc_vregs)))
+				     ELF_NEVRREG * sizeof(u32)))
 			return 1;
 	} else if (current->thread.used_spe)
 		memset(&current->thread.evr, 0, ELF_NEVRREG * sizeof(u32));
@@ -329,6 +329,16 @@
 		return 1;
 #endif /* CONFIG_SPE */
 
+#ifndef CONFIG_SMP
+	preempt_disable();
+	if (last_task_used_math == current)
+		last_task_used_math = NULL;
+	if (last_task_used_altivec == current)
+		last_task_used_altivec = NULL;
+	if (last_task_used_spe == current)
+		last_task_used_spe = NULL;
+	preempt_enable();
+#endif
 	return 0;
 }
 
diff -Nru a/arch/ppc/kernel/softemu8xx.c b/arch/ppc/kernel/softemu8xx.c
--- a/arch/ppc/kernel/softemu8xx.c	2004-12-24 13:36:55 -08:00
+++ b/arch/ppc/kernel/softemu8xx.c	2004-12-24 13:36:55 -08:00
@@ -133,7 +133,7 @@
 			print_8xx_pte(current->mm,regs->nip);
 			pa = get_8xx_pte(current->mm,regs->nip) & PAGE_MASK;
 			pa |= (regs->nip & ~PAGE_MASK);
-			pa = __va(pa);
+			pa = (unsigned long)__va(pa);
 			printk("Kernel VA for NIP %x ", pa);
 			print_8xx_pte(current->mm,pa);
 		}
diff -Nru a/arch/ppc/kernel/time.c b/arch/ppc/kernel/time.c
--- a/arch/ppc/kernel/time.c	2004-12-24 13:37:04 -08:00
+++ b/arch/ppc/kernel/time.c	2004-12-24 13:37:04 -08:00
@@ -150,6 +150,9 @@
 		write_seqlock(&xtime_lock);
 		tb_last_stamp = jiffy_stamp;
 		do_timer(regs);
+#ifndef CONFIG_SMP
+		update_process_times(user_mode(regs));
+#endif
 
 		/*
 		 * update the rtc when needed, this should be performed on the
diff -Nru a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
--- a/arch/ppc/kernel/traps.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc/kernel/traps.c	2004-12-24 13:36:31 -08:00
@@ -647,22 +647,22 @@
 }
 #endif /* CONFIG_8xx */
 
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
 
 void DebugException(struct pt_regs *regs, unsigned long debug_status)
 {
-#if 0
-	if (debug_status & DBSR_TIE) {		/* trap instruction*/
-		if (!user_mode(regs) && debugger_bpt(regs))
-			return;
-		_exception(SIGTRAP, regs, 0, 0);
-
-	}
-#endif
 	if (debug_status & DBSR_IC) {	/* instruction completion */
-		if (!user_mode(regs) && debugger_sstep(regs))
-			return;
-		current->thread.dbcr0 &= ~DBCR0_IC;
+		regs->msr &= ~MSR_DE;
+		if (user_mode(regs)) {
+			current->thread.dbcr0 &= ~DBCR0_IC;
+		} else {
+			/* Disable instruction completion */
+			mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~DBCR0_IC);
+			/* Clear the instruction completion event */
+			mtspr(SPRN_DBSR, DBSR_IC);
+			if (debugger_sstep(regs))
+				return;
+		}
 		_exception(SIGTRAP, regs, TRAP_TRACE, 0);
 	}
 }
diff -Nru a/arch/ppc/lib/dec_and_lock.c b/arch/ppc/lib/dec_and_lock.c
--- a/arch/ppc/lib/dec_and_lock.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/lib/dec_and_lock.c	2004-12-24 13:37:19 -08:00
@@ -19,7 +19,7 @@
  */
 
 #ifndef ATOMIC_DEC_AND_LOCK
-int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
+int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
 {
 	int counter;
 	int newcount;
@@ -42,5 +42,5 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
 #endif /* ATOMIC_DEC_AND_LOCK */
diff -Nru a/arch/ppc/lib/rheap.c b/arch/ppc/lib/rheap.c
--- a/arch/ppc/lib/rheap.c	2004-12-24 13:36:47 -08:00
+++ b/arch/ppc/lib/rheap.c	2004-12-24 13:36:47 -08:00
@@ -645,6 +645,7 @@
 		return -EINVAL;
 
 	blk->owner = owner;
+	size = blk->size;
 
 	return size;
 }
diff -Nru a/arch/ppc/mm/44x_mmu.c b/arch/ppc/mm/44x_mmu.c
--- a/arch/ppc/mm/44x_mmu.c	2004-12-24 13:37:00 -08:00
+++ b/arch/ppc/mm/44x_mmu.c	2004-12-24 13:37:00 -08:00
@@ -55,10 +55,8 @@
 #include <asm/setup.h>
 
 #include "mmu_decl.h"
-#include "mem_pieces.h"
 
 extern char etext[], _stext[];
-extern struct mem_pieces phys_avail;
 
 /* Used by the 44x TLB replacement exception handler.
  * Just needed it declared someplace.
@@ -104,16 +102,6 @@
 {
 	unsigned int pinned_tlbs = 1;
 	int i;
-
-	/*
-	 * If lowmem is not on a pin tlb entry size boundary,
-	 * then reserve the last page of system memory. This
-	 * eliminates the possibility of a speculative dcache
-	 * fetch past the end of system memory that would
-	 * result in a machine check exception.
-	 */
-	if (total_lowmem | (PPC44x_PIN_SIZE - 1))
-		mem_pieces_remove(&phys_avail, total_lowmem - PAGE_SIZE, PAGE_SIZE, 1);
 
 	/* Determine number of entries necessary to cover lowmem */
 	pinned_tlbs = (unsigned int)
diff -Nru a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
--- a/arch/ppc/mm/pgtable.c	2004-12-24 13:36:19 -08:00
+++ b/arch/ppc/mm/pgtable.c	2004-12-24 13:36:19 -08:00
@@ -153,19 +153,19 @@
 }
 
 #ifndef CONFIG_44x
-void *
+void __iomem *
 ioremap(phys_addr_t addr, unsigned long size)
 {
 	return __ioremap(addr, size, _PAGE_NO_CACHE);
 }
 #else /* CONFIG_44x */
-void *
+void __iomem *
 ioremap64(unsigned long long addr, unsigned long size)
 {
 	return __ioremap(addr, size, _PAGE_NO_CACHE);
 }
 
-void *
+void __iomem *
 ioremap(phys_addr_t addr, unsigned long size)
 {
 	phys_addr_t addr64 = fixup_bigphys_addr(addr, size);
@@ -174,7 +174,7 @@
 }
 #endif /* CONFIG_44x */
 
-void *
+void __iomem *
 __ioremap(phys_addr_t addr, unsigned long size, unsigned long flags)
 {
 	unsigned long v, i;
@@ -257,10 +257,10 @@
 	}
 
 out:
-	return (void *) (v + ((unsigned long)addr & ~PAGE_MASK));
+	return (void __iomem *) (v + ((unsigned long)addr & ~PAGE_MASK));
 }
 
-void iounmap(void *addr)
+void iounmap(volatile void __iomem *addr)
 {
 	/*
 	 * If mapped by BATs then there is nothing to do.
diff -Nru a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
--- a/arch/ppc/platforms/4xx/Kconfig	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc/platforms/4xx/Kconfig	2004-12-24 13:36:18 -08:00
@@ -56,6 +56,11 @@
 	help
 	  This option enables support for the IBM PPC405GP evaluation board.
 
+config XILINX_ML300
+	bool "Xilinx-ML300"
+	help
+	  This option enables support for the Xilinx ML300 evaluation board.
+
 endchoice
 
 choice
@@ -130,6 +135,11 @@
 	depends on ASH || BUBINGA || CPCI405 || EBONY || EP405 || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
 	default y
 
+config XILINX_OCP
+	bool
+	depends on XILINX_ML300
+	default y
+
 config IBM_EMAC4
 	bool
 	depends on 440GX
@@ -160,6 +170,11 @@
 	depends on SYCAMORE
 	default y
 
+config VIRTEX_II_PRO
+	bool
+	depends on XILINX_ML300
+	default y
+
 config STB03xxx
 	bool
 	depends on REDWOOD_5 || REDWOOD_6
@@ -167,7 +182,7 @@
 
 config EMBEDDEDBOOT
 	bool
-	depends on EP405
+	depends on EP405 || XILINX_ML300
 	default y
 
 config IBM_OPENBIOS
@@ -182,6 +197,11 @@
 config PPC4xx_EDMA
 	bool
 	depends on !STB03xxx && PPC4xx_DMA
+	default y
+
+config PPC_GEN550
+	bool
+	depends on 4xx
 	default y
 
 config PM
diff -Nru a/arch/ppc/platforms/4xx/Makefile b/arch/ppc/platforms/4xx/Makefile
--- a/arch/ppc/platforms/4xx/Makefile	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/platforms/4xx/Makefile	2004-12-24 13:37:19 -08:00
@@ -12,6 +12,7 @@
 obj-$(CONFIG_REDWOOD_6)		+= redwood6.o
 obj-$(CONFIG_SYCAMORE)		+= sycamore.o
 obj-$(CONFIG_WALNUT)		+= walnut.o
+obj-$(CONFIG_XILINX_ML300)	+= xilinx_ml300.o
 
 obj-$(CONFIG_405GP)		+= ibm405gp.o
 obj-$(CONFIG_REDWOOD_5)		+= ibmstb4.o
@@ -21,3 +22,4 @@
 obj-$(CONFIG_440GX)		+= ibm440gx.o
 obj-$(CONFIG_405EP)		+= ibm405ep.o
 obj-$(CONFIG_405GPR)		+= ibm405gpr.o
+obj-$(CONFIG_VIRTEX_II_PRO)	+= virtex-ii_pro.o
diff -Nru a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c
--- a/arch/ppc/platforms/4xx/ebony.c	2004-12-24 13:37:32 -08:00
+++ b/arch/ppc/platforms/4xx/ebony.c	2004-12-24 13:37:32 -08:00
@@ -1,10 +1,10 @@
 /*
- * arch/ppc/platforms/ebony.c
+ * arch/ppc/platforms/4xx/ebony.c
  *
  * Ebony board specific routines
  *
- * Matt Porter <mporter@mvista.com>
- * Copyright 2002 MontaVista Software Inc.
+ * Matt Porter <mporter@kernel.crashing.org>
+ * Copyright 2002-2004 MontaVista Software Inc.
  *
  * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  * Copyright (c) 2003, 2004 Zultys Technologies
@@ -50,6 +50,10 @@
 #include <asm/bootinfo.h>
 #include <asm/ppc4xx_pic.h>
 
+#include <syslib/gen550.h>
+
+static struct ibm44x_clocks clocks __initdata;
+
 /*
  * Ebony IRQ triggering/polarity settings
  */
@@ -120,8 +124,6 @@
 	(IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),	/* 63: EMAC 1 WOL */
 };
 
-static struct ibm44x_clocks clocks __initdata;
-
 static void __init
 ebony_calibrate_decr(void)
 {
@@ -284,13 +286,24 @@
 		printk("Early serial init of port 0 failed\n");
 	}
 
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+	/* Configure debug serial access */
+	gen550_init(0, &port);
+#endif
+
 	port.membase = ioremap64(PPC440GP_UART1_ADDR, 8);
 	port.irq = 1;
+	port.uartclk = clocks.uart1;
 	port.line = 1;
 
 	if (early_serial_setup(&port) != 0) {
 		printk("Early serial init of port 1 failed\n");
 	}
+
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+	/* Configure debug serial access */
+	gen550_init(1, &port);
+#endif
 }
 
 static void __init
@@ -300,14 +313,6 @@
 	struct ocp_def *def;
 	struct ocp_func_emac_data *emacdata;
 
-#if !defined(CONFIG_BDI_SWITCH)
-	/*
-	 * The Abatron BDI JTAG debugger does not tolerate others
-	 * mucking with the debug registers.
-	 */
-        mtspr(SPRN_DBCR0, (DBCR0_TDE | DBCR0_IDM));
-#endif
-
 	/* Set mac_addr for each EMAC */
 	vpd_base = ioremap64(EBONY_VPD_BASE, EBONY_VPD_SIZE);
 	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 0);
@@ -378,7 +383,6 @@
 
 	ppc_md.nvram_read_val = todc_direct_read_val;
 	ppc_md.nvram_write_val = todc_direct_write_val;
-
 #ifdef CONFIG_KGDB
 	ppc_md.early_serial_map = ebony_early_serial_map;
 #endif
diff -Nru a/arch/ppc/platforms/4xx/ocotea.c b/arch/ppc/platforms/4xx/ocotea.c
--- a/arch/ppc/platforms/4xx/ocotea.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc/platforms/4xx/ocotea.c	2004-12-24 13:37:18 -08:00
@@ -1,11 +1,11 @@
 /*
- * arch/ppc/platforms/ocotea.c
+ * arch/ppc/platforms/4xx/ocotea.c
  *
  * Ocotea board specific routines
  *
- * Matt Porter <mporter@mvista.com>
+ * Matt Porter <mporter@kernel.crashing.org>
  *
- * Copyright 2003 MontaVista Software Inc.
+ * Copyright 2003-2004 MontaVista Software Inc.
  *
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General  Public License as published by the
@@ -49,6 +49,7 @@
 #include <asm/ppc4xx_pic.h>
 #include <asm/ppcboot.h>
 
+#include <syslib/gen550.h>
 #include <syslib/ibm440gx_common.h>
 
 /*
@@ -80,7 +81,7 @@
 {
 	seq_printf(m, "vendor\t\t: IBM\n");
 	seq_printf(m, "machine\t\t: PPC440GX EVB (Ocotea)\n");
-
+	ibm440gx_show_cpuinfo(m);
 	return 0;
 }
 
@@ -144,13 +145,13 @@
 }
 
 #define PCIX_READW(offset) \
-	(readw((u32)pcix_reg_base+offset))
+	(readw(pcix_reg_base+offset))
 
 #define PCIX_WRITEW(value, offset) \
-	(writew(value, (u32)pcix_reg_base+offset))
+	(writew(value, pcix_reg_base+offset))
 
 #define PCIX_WRITEL(value, offset) \
-	(writel(value, (u32)pcix_reg_base+offset))
+	(writel(value, pcix_reg_base+offset))
 
 /*
  * FIXME: This is only here to "make it work".  This will move
@@ -263,6 +264,11 @@
 		printk("Early serial init of port 0 failed\n");
 	}
 
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+	/* Configure debug serial access */
+	gen550_init(0, &port);
+#endif
+
 	port.membase = ioremap64(PPC440GX_UART1_ADDR, 8);
 	port.irq = UART1_INT;
 	port.uartclk = clocks.uart1;
@@ -271,6 +277,11 @@
 	if (early_serial_setup(&port) != 0) {
 		printk("Early serial init of port 1 failed\n");
 	}
+
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+	/* Configure debug serial access */
+	gen550_init(1, &port);
+#endif
 }
 
 static void __init
@@ -280,23 +291,6 @@
 
 	ibm440gx_tah_enable();
 
-#if !defined(CONFIG_BDI_SWITCH)
-	/*
-	 * The Abatron BDI JTAG debugger does not tolerate others
-	 * mucking with the debug registers.
-	 */
-        mtspr(SPRN_DBCR0, (DBCR0_TDE | DBCR0_IDM));
-#endif
-
-	/*
-	 * Determine various clocks.
-	 * To be completely correct we should get SysClk
-	 * from FPGA, because it can be changed by on-board switches
-	 * --ebs
-	 */
-	ibm440gx_get_clocks(&clocks, 33333333, 6 * 1843200);
-	ocp_sys_info.opb_bus_freq = clocks.opb;
-
 	/* Setup TODC access */
 	TODC_INIT(TODC_TYPE_DS1743,
 			0,
@@ -327,6 +321,11 @@
 	printk("IBM Ocotea port (MontaVista Software, Inc. <source@mvista.com>)\n");
 }
 
+static void __init ocotea_init(void)
+{
+	ibm440gx_l2c_setup(&clocks);
+}
+
 void __init platform_init(unsigned long r3, unsigned long r4,
 		unsigned long r5, unsigned long r6, unsigned long r7)
 {
@@ -339,8 +338,20 @@
 	if (r3)
 		__res = *(bd_t *)(r3 + KERNELBASE);
 
-	/* Disable L2-Cache due to hardware issues */
-	ibm440gx_l2c_disable();
+	/*
+	 * Determine various clocks.
+	 * To be completely correct we should get SysClk
+	 * from FPGA, because it can be changed by on-board switches
+	 * --ebs
+	 */
+	ibm440gx_get_clocks(&clocks, 33333333, 6 * 1843200);
+	ocp_sys_info.opb_bus_freq = clocks.opb;
+
+	/* XXX Fix L2C IRQ triggerring setting (edge-sensitive).
+	 * Firmware (at least PIBS v1.72 OCT/28/2003) sets it incorrectly
+	 * --ebs
+	 */
+	mtdcr(DCRN_UIC_TR(UIC2), mfdcr(DCRN_UIC_TR(UIC2)) | 0x00000100);
 
 	ibm44x_platform_init();
 
@@ -355,8 +366,8 @@
 
 	ppc_md.nvram_read_val = todc_direct_read_val;
 	ppc_md.nvram_write_val = todc_direct_write_val;
-
 #ifdef CONFIG_KGDB
 	ppc_md.early_serial_map = ocotea_early_serial_map;
 #endif
+	ppc_md.init = ocotea_init;
 }
diff -Nru a/arch/ppc/platforms/4xx/virtex-ii_pro.c b/arch/ppc/platforms/4xx/virtex-ii_pro.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc/platforms/4xx/virtex-ii_pro.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,60 @@
+/*
+ * arch/ppc/platforms/4xx/virtex-ii_pro.c
+ *
+ * Author: MontaVista Software, Inc.
+ *         source@mvista.com
+ *
+ * 2002-2004 (c) MontaVista Software, Inc.  This file is licensed under the
+ * terms of the GNU General Public License version 2.  This program is licensed
+ * "as is" without any warranty of any kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <asm/ocp.h>
+#include "virtex-ii_pro.h"
+
+/* Have OCP take care of the serial ports. */
+struct ocp_def core_ocp[] = {
+#ifdef XPAR_UARTNS550_0_BASEADDR
+	{ .vendor	= OCP_VENDOR_XILINX,
+	  .function	= OCP_FUNC_16550,
+	  .index	= 0,
+	  .paddr	= XPAR_UARTNS550_0_BASEADDR,
+	  .irq		= XPAR_INTC_0_UARTNS550_0_VEC_ID,
+	  .pm		= OCP_CPM_NA
+	},
+#ifdef XPAR_UARTNS550_1_BASEADDR
+	{ .vendor	= OCP_VENDOR_XILINX,
+	  .function	= OCP_FUNC_16550,
+	  .index	= 1,
+	  .paddr	= XPAR_UARTNS550_1_BASEADDR,
+	  .irq		= XPAR_INTC_0_UARTNS550_1_VEC_ID,
+	  .pm		= OCP_CPM_NA
+	},
+#ifdef XPAR_UARTNS550_2_BASEADDR
+	{ .vendor	= OCP_VENDOR_XILINX,
+	  .function	= OCP_FUNC_16550,
+	  .index	= 2,
+	  .paddr	= XPAR_UARTNS550_2_BASEADDR,
+	  .irq		= XPAR_INTC_0_UARTNS550_2_VEC_ID,
+	  .pm		= OCP_CPM_NA
+	},
+#ifdef XPAR_UARTNS550_3_BASEADDR
+	{ .vendor	= OCP_VENDOR_XILINX,
+	  .function	= OCP_FUNC_16550,
+	  .index	= 3,
+	  .paddr	= XPAR_UARTNS550_3_BASEADDR,
+	  .irq		= XPAR_INTC_0_UARTNS550_3_VEC_ID,
+	  .pm		= OCP_CPM_NA
+	},
+#ifdef XPAR_UARTNS550_4_BASEADDR
+#error Edit this file to add more devices.
+#endif			/* 4 */
+#endif			/* 3 */
+#endif			/* 2 */
+#endif			/* 1 */
+#endif			/* 0 */
+	{ .vendor	= OCP_VENDOR_INVALID
+	}
+};
diff -Nru a/arch/ppc/platforms/4xx/virtex-ii_pro.h b/arch/ppc/platforms/4xx/virtex-ii_pro.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc/platforms/4xx/virtex-ii_pro.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,99 @@
+/*
+ * arch/ppc/platforms/4xx/virtex-ii_pro.h
+ *
+ * Include file that defines the Xilinx Virtex-II Pro processor
+ *
+ * Author: MontaVista Software, Inc.
+ *         source@mvista.com
+ *
+ * 2002-2004 (c) MontaVista Software, Inc.  This file is licensed under the
+ * terms of the GNU General Public License version 2.  This program is licensed
+ * "as is" without any warranty of any kind, whether express or implied.
+ */
+
+#ifdef __KERNEL__
+#ifndef __ASM_VIRTEXIIPRO_H__
+#define __ASM_VIRTEXIIPRO_H__
+
+#include <linux/config.h>
+#include <asm/xparameters.h>
+
+/* serial defines */
+
+#define RS_TABLE_SIZE  4	/* change this and add more devices below
+				   if you have more then 4 16x50 UARTs */
+
+#define BASE_BAUD		(XPAR_UARTNS550_0_CLOCK_FREQ_HZ/16)
+
+/* The serial ports in the Virtex-II Pro have each I/O byte in the
+ * LSByte of a word.  This means that iomem_reg_shift needs to be 2 to
+ * change the byte offsets into word offsets.  In addition the base
+ * addresses need to have 3 added to them to get to the LSByte.
+ */
+#define STD_UART_OP(num)						 \
+	{ 0, BASE_BAUD, 0, XPAR_INTC_0_UARTNS550_##num##_VEC_ID,	 \
+		ASYNC_BOOT_AUTOCONF,		 			 \
+		.iomem_base = (u8 *)XPAR_UARTNS550_##num##_BASEADDR + 3, \
+		.iomem_reg_shift = 2,					 \
+		.io_type = SERIAL_IO_MEM},
+
+#if defined(XPAR_INTC_0_UARTNS550_0_VEC_ID)
+#define ML300_UART0 STD_UART_OP(0)
+#else
+#define ML300_UART0
+#endif
+
+#if defined(XPAR_INTC_0_UARTNS550_1_VEC_ID)
+#define ML300_UART1 STD_UART_OP(1)
+#else
+#define ML300_UART1
+#endif
+
+#if defined(XPAR_INTC_0_UARTNS550_2_VEC_ID)
+#define ML300_UART2 STD_UART_OP(2)
+#else
+#define ML300_UART2
+#endif
+
+#if defined(XPAR_INTC_0_UARTNS550_3_VEC_ID)
+#define ML300_UART3 STD_UART_OP(3)
+#else
+#define ML300_UART3
+#endif
+
+#if defined(XPAR_INTC_0_UARTNS550_4_VEC_ID)
+#error Edit this file to add more devices.
+#elif defined(XPAR_INTC_0_UARTNS550_3_VEC_ID)
+#define NR_SER_PORTS	4
+#elif defined(XPAR_INTC_0_UARTNS550_2_VEC_ID)
+#define NR_SER_PORTS	3
+#elif defined(XPAR_INTC_0_UARTNS550_1_VEC_ID)
+#define NR_SER_PORTS	2
+#elif defined(XPAR_INTC_0_UARTNS550_0_VEC_ID)
+#define NR_SER_PORTS	1
+#else
+#define NR_SER_PORTS	0
+#endif
+
+#if defined(CONFIG_UART0_TTYS0)
+#define SERIAL_PORT_DFNS	\
+	ML300_UART0		\
+	ML300_UART1		\
+	ML300_UART2		\
+	ML300_UART3
+#endif
+
+#if defined(CONFIG_UART0_TTYS1)
+#define SERIAL_PORT_DFNS	\
+	ML300_UART1		\
+	ML300_UART0		\
+	ML300_UART2		\
+	ML300_UART3
+#endif
+
+#define DCRN_CPMFR_BASE	0
+
+#include <asm/ibm405.h>
+
+#endif				/* __ASM_VIRTEXIIPRO_H__ */
+#endif				/* __KERNEL__ */
diff -Nru a/arch/ppc/platforms/4xx/xilinx_ml300.c b/arch/ppc/platforms/4xx/xilinx_ml300.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,164 @@
+/*
+ * arch/ppc/platforms/4xx/xilinx_ml300.c
+ *
+ * Xilinx ML300 evaluation board initialization
+ *
+ * Author: MontaVista Software, Inc.
+ *         source@mvista.com
+ *
+ * 2002-2004 (c) MontaVista Software, Inc.  This file is licensed under the
+ * terms of the GNU General Public License version 2.  This program is licensed
+ * "as is" without any warranty of any kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/tty.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/serialP.h>
+#include <asm/io.h>
+#include <asm/machdep.h>
+#include <asm/ocp.h>
+
+#include <platforms/4xx/virtex-ii_pro.h>	/* for NR_SER_PORTS */
+
+/*
+ * As an overview of how the following functions (platform_init,
+ * ml300_map_io, ml300_setup_arch and ml300_init_IRQ) fit into the
+ * kernel startup procedure, here's a call tree:
+ *
+ * start_here					arch/ppc/kernel/head_4xx.S
+ *  early_init					arch/ppc/kernel/setup.c
+ *  machine_init				arch/ppc/kernel/setup.c
+ *    platform_init				this file
+ *      ppc4xx_init				arch/ppc/syslib/ppc4xx_setup.c
+ *        parse_bootinfo
+ *          find_bootinfo
+ *        "setup some default ppc_md pointers"
+ *  MMU_init					arch/ppc/mm/init.c
+ *    *ppc_md.setup_io_mappings == ml300_map_io	this file
+ *      ppc4xx_map_io				arch/ppc/syslib/ppc4xx_setup.c
+ *  start_kernel				init/main.c
+ *    setup_arch				arch/ppc/kernel/setup.c
+ * #if defined(CONFIG_KGDB)
+ *      *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
+ * #endif
+ *      *ppc_md.setup_arch == ml300_setup_arch	this file
+ *        ppc4xx_setup_arch			arch/ppc/syslib/ppc4xx_setup.c
+ *          ppc4xx_find_bridges			arch/ppc/syslib/ppc405_pci.c
+ *    init_IRQ					arch/ppc/kernel/irq.c
+ *      *ppc_md.init_IRQ == ml300_init_IRQ	this file
+ *        ppc4xx_init_IRQ			arch/ppc/syslib/ppc4xx_setup.c
+ *          ppc4xx_pic_init			arch/ppc/syslib/xilinx_pic.c
+ */
+
+#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
+
+static volatile unsigned *powerdown_base =
+    (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
+
+static void
+xilinx_power_off(void)
+{
+	local_irq_disable();
+	out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
+	while (1) ;
+}
+#endif
+
+void __init
+ml300_map_io(void)
+{
+	ppc4xx_map_io();
+
+#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
+	powerdown_base = ioremap((unsigned long) powerdown_base,
+				 XPAR_POWER_0_POWERDOWN_HIGHADDR -
+				 XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
+#endif
+}
+
+static void __init
+ml300_early_serial_map(void)
+{
+#ifdef CONFIG_SERIAL_8250
+	struct serial_state old_ports[] = { SERIAL_PORT_DFNS };
+	struct uart_port port;
+	int i;
+
+	/* Setup ioremapped serial port access */
+	for (i = 0; i < ARRAY_SIZE(old_ports); i++ ) {
+		memset(&port, 0, sizeof(port));
+		port.membase = ioremap((phys_addr_t)(old_ports[i].iomem_base), 16);
+		port.irq = old_ports[i].irq;
+		port.uartclk = old_ports[i].baud_base * 16;
+		port.regshift = old_ports[i].iomem_reg_shift;
+		port.iotype = SERIAL_IO_MEM;
+		port.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
+		port.line = i;
+
+		if (early_serial_setup(&port) != 0) {
+			printk("Early serial init of port %d failed\n", i);
+		}
+	}
+#endif /* CONFIG_SERIAL_8250 */
+}
+
+void __init
+ml300_setup_arch(void)
+{
+	ppc4xx_setup_arch();	/* calls ppc4xx_find_bridges() */
+
+	ml300_early_serial_map();
+
+	/* Identify the system */
+	printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
+	printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
+}
+
+/* Called after board_setup_irq from ppc4xx_init_IRQ(). */
+void __init
+ml300_init_irq(void)
+{
+	unsigned int i;
+
+	ppc4xx_init_IRQ();
+
+	/*
+	 * For PowerPC 405 cores the default value for NR_IRQS is 32.
+	 * See include/asm-ppc/irq.h for details.
+	 * This is just fine for ML300.
+	 */
+#if (NR_IRQS != 32)
+#error NR_IRQS must be 32 for ML300
+#endif
+
+	for (i = 0; i < NR_IRQS; i++) {
+		if (XPAR_INTC_0_KIND_OF_INTR & (0x80000000 >> i))
+			irq_desc[i].status &= ~IRQ_LEVEL;
+		else
+			irq_desc[i].status |= IRQ_LEVEL;
+	}
+}
+
+void __init
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+	      unsigned long r6, unsigned long r7)
+{
+	ppc4xx_init(r3, r4, r5, r6, r7);
+
+	ppc_md.setup_arch = ml300_setup_arch;
+	ppc_md.setup_io_mappings = ml300_map_io;
+	ppc_md.init_IRQ = ml300_init_irq;
+
+#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
+	ppc_md.power_off = xilinx_power_off;
+#endif
+
+#ifdef CONFIG_KGDB
+	ppc_md.early_serial_map = ml300_early_serial_map;
+#endif
+}
+
diff -Nru a/arch/ppc/platforms/4xx/xilinx_ml300.h b/arch/ppc/platforms/4xx/xilinx_ml300.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,47 @@
+/*
+ * arch/ppc/platforms/4xx/xilinx_ml300.h
+ *
+ * Include file that defines the Xilinx ML300 evaluation board
+ *
+ * Author: MontaVista Software, Inc.
+ *         source@mvista.com
+ *
+ * 2002-2004 (c) MontaVista Software, Inc.  This file is licensed under the
+ * terms of the GNU General Public License version 2.  This program is licensed
+ * "as is" without any warranty of any kind, whether express or implied.
+ */
+
+#ifdef __KERNEL__
+#ifndef __ASM_XILINX_ML300_H__
+#define __ASM_XILINX_ML300_H__
+
+/* ML300 has a Xilinx Virtex-II Pro processor */
+#include <platforms/4xx/virtex-ii_pro.h>
+
+#ifndef __ASSEMBLY__
+
+#include <linux/types.h>
+
+typedef struct board_info {
+	unsigned int	 bi_memsize;		/* DRAM installed, in bytes */
+	unsigned char	 bi_enetaddr[6];	/* Local Ethernet MAC address */
+	unsigned int	 bi_intfreq;		/* Processor speed, in Hz */
+	unsigned int	 bi_busfreq;		/* PLB Bus speed, in Hz */
+	unsigned int	 bi_pci_busfreq;	/* PCI Bus speed, in Hz */
+} bd_t;
+
+/* Some 4xx parts use a different timebase frequency from the internal clock.
+*/
+#define bi_tbfreq bi_intfreq
+
+#endif /* !__ASSEMBLY__ */
+
+/* We don't need anything mapped.  Size of zero will accomplish that. */
+#define PPC4xx_ONB_IO_PADDR	0u
+#define PPC4xx_ONB_IO_VADDR	0u
+#define PPC4xx_ONB_IO_SIZE	0u
+
+#define PPC4xx_MACHINE_NAME "Xilinx ML300"
+
+#endif /* __ASM_XILINX_ML300_H__ */
+#endif /* __KERNEL__ */
diff -Nru a/arch/ppc/platforms/4xx/xparameters/xparameters_ml300.h b/arch/ppc/platforms/4xx/xparameters/xparameters_ml300.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc/platforms/4xx/xparameters/xparameters_ml300.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,310 @@
+/*******************************************************************
+*
+*     Author: Xilinx, 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.
+*
+*
+*     XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
+*     COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
+*     ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD,
+*     XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE
+*     FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
+*     ANY THIRD PARTY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
+*     XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
+*     THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
+*     WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM
+*     CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND
+*     FITNESS FOR A PARTICULAR PURPOSE.
+*
+*
+*     Xilinx hardware products are not intended for use in life support
+*     appliances, devices, or systems. Use in such applications is
+*     expressly prohibited.
+*
+*
+*     (c) Copyright 2002-2004 Xilinx Inc.
+*     All rights reserved.
+*
+*
+*     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.
+*
+* Description: Driver parameters
+*
+*******************************************************************/
+
+#define XPAR_XPCI_NUM_INSTANCES 1
+#define XPAR_XPCI_CLOCK_HZ 33333333
+#define XPAR_OPB_PCI_REF_0_DEVICE_ID 0
+#define XPAR_OPB_PCI_REF_0_BASEADDR 0x20000000
+#define XPAR_OPB_PCI_REF_0_HIGHADDR 0x3FFFFFFF
+#define XPAR_OPB_PCI_REF_0_CONFIG_ADDR 0x3C000000
+#define XPAR_OPB_PCI_REF_0_CONFIG_DATA 0x3C000004
+#define XPAR_OPB_PCI_REF_0_LCONFIG_ADDR 0x3E000000
+#define XPAR_OPB_PCI_REF_0_MEM_BASEADDR 0x20000000
+#define XPAR_OPB_PCI_REF_0_MEM_HIGHADDR 0x37FFFFFF
+#define XPAR_OPB_PCI_REF_0_IO_BASEADDR 0x38000000
+#define XPAR_OPB_PCI_REF_0_IO_HIGHADDR 0x3BFFFFFF
+
+/******************************************************************/
+
+#define XPAR_XEMAC_NUM_INSTANCES 1
+#define XPAR_OPB_ETHERNET_0_BASEADDR 0x60000000
+#define XPAR_OPB_ETHERNET_0_HIGHADDR 0x60003FFF
+#define XPAR_OPB_ETHERNET_0_DEVICE_ID 0
+#define XPAR_OPB_ETHERNET_0_ERR_COUNT_EXIST 1
+#define XPAR_OPB_ETHERNET_0_DMA_PRESENT 1
+#define XPAR_OPB_ETHERNET_0_MII_EXIST 1
+
+/******************************************************************/
+
+#define XPAR_MY_OPB_GPIO_0_DEVICE_ID_0 0
+#define XPAR_MY_OPB_GPIO_0_BASEADDR_0 0x90000000
+#define XPAR_MY_OPB_GPIO_0_HIGHADDR_0 (0x90000000+0x7)
+#define XPAR_MY_OPB_GPIO_0_DEVICE_ID_1 1
+#define XPAR_MY_OPB_GPIO_0_BASEADDR_1 (0x90000000+0x8)
+#define XPAR_MY_OPB_GPIO_0_HIGHADDR_1 (0x90000000+0x1F)
+#define XPAR_XGPIO_NUM_INSTANCES 2
+
+/******************************************************************/
+
+#define XPAR_XIIC_NUM_INSTANCES 1
+#define XPAR_OPB_IIC_0_BASEADDR 0xA8000000
+#define XPAR_OPB_IIC_0_HIGHADDR 0xA80001FF
+#define XPAR_OPB_IIC_0_DEVICE_ID 0
+#define XPAR_OPB_IIC_0_TEN_BIT_ADR 0
+
+/******************************************************************/
+
+#define XPAR_XUARTNS550_NUM_INSTANCES 2
+#define XPAR_XUARTNS550_CLOCK_HZ 100000000
+#define XPAR_OPB_UART16550_0_BASEADDR 0xA0000000
+#define XPAR_OPB_UART16550_0_HIGHADDR 0xA0001FFF
+#define XPAR_OPB_UART16550_0_DEVICE_ID 0
+#define XPAR_OPB_UART16550_1_BASEADDR 0xA0010000
+#define XPAR_OPB_UART16550_1_HIGHADDR 0xA0011FFF
+#define XPAR_OPB_UART16550_1_DEVICE_ID 1
+
+/******************************************************************/
+
+#define XPAR_XSPI_NUM_INSTANCES 1
+#define XPAR_OPB_SPI_0_BASEADDR 0xA4000000
+#define XPAR_OPB_SPI_0_HIGHADDR 0xA400007F
+#define XPAR_OPB_SPI_0_DEVICE_ID 0
+#define XPAR_OPB_SPI_0_FIFO_EXIST 1
+#define XPAR_OPB_SPI_0_SPI_SLAVE_ONLY 0
+#define XPAR_OPB_SPI_0_NUM_SS_BITS 1
+
+/******************************************************************/
+
+#define XPAR_XPS2_NUM_INSTANCES 2
+#define XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_0 0
+#define XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_0 0xA9000000
+#define XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_0 (0xA9000000+0x3F)
+#define XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_1 1
+#define XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_1 (0xA9000000+0x1000)
+#define XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_1 (0xA9000000+0x103F)
+
+/******************************************************************/
+
+#define XPAR_XTOUCHSCREEN_NUM_INSTANCES 1
+#define XPAR_OPB_TSD_REF_0_BASEADDR 0xAA000000
+#define XPAR_OPB_TSD_REF_0_HIGHADDR 0xAA000007
+#define XPAR_OPB_TSD_REF_0_DEVICE_ID 0
+
+/******************************************************************/
+
+#define XPAR_OPB_AC97_CONTROLLER_REF_0_BASEADDR 0xA6000000
+#define XPAR_OPB_AC97_CONTROLLER_REF_0_HIGHADDR 0xA60000FF
+#define XPAR_OPB_PAR_PORT_REF_0_BASEADDR 0x90010000
+#define XPAR_OPB_PAR_PORT_REF_0_HIGHADDR 0x900100FF
+#define XPAR_PLB_DDR_0_BASEADDR 0x00000000
+#define XPAR_PLB_DDR_0_HIGHADDR 0x0FFFFFFF
+
+/******************************************************************/
+
+#define XPAR_XINTC_HAS_IPR 1
+#define XPAR_INTC_MAX_NUM_INTR_INPUTS 18
+#define XPAR_XINTC_USE_DCR 0
+#define XPAR_XINTC_NUM_INSTANCES 1
+#define XPAR_DCR_INTC_0_BASEADDR 0xD0000FC0
+#define XPAR_DCR_INTC_0_HIGHADDR 0xD0000FDF
+#define XPAR_DCR_INTC_0_DEVICE_ID 0
+#define XPAR_DCR_INTC_0_KIND_OF_INTR 0x00038000
+
+/******************************************************************/
+
+#define XPAR_DCR_INTC_0_MISC_LOGIC_0_PHY_MII_INT_INTR 0
+#define XPAR_DCR_INTC_0_OPB_ETHERNET_0_IP2INTC_IRPT_INTR 1
+#define XPAR_DCR_INTC_0_MISC_LOGIC_0_IIC_TEMP_CRIT_INTR 2
+#define XPAR_DCR_INTC_0_MISC_LOGIC_0_IIC_IRQ_INTR 3
+#define XPAR_DCR_INTC_0_OPB_IIC_0_IP2INTC_IRPT_INTR 4
+#define XPAR_DCR_INTC_0_OPB_SYSACE_0_SYSACE_IRQ_INTR 5
+#define XPAR_DCR_INTC_0_OPB_UART16550_0_IP2INTC_IRPT_INTR 6
+#define XPAR_DCR_INTC_0_OPB_UART16550_1_IP2INTC_IRPT_INTR 7
+#define XPAR_DCR_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR1_INTR 8
+#define XPAR_DCR_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR2_INTR 9
+#define XPAR_DCR_INTC_0_OPB_SPI_0_IP2INTC_IRPT_INTR 10
+#define XPAR_DCR_INTC_0_OPB_TSD_REF_0_INTR_INTR 11
+#define XPAR_DCR_INTC_0_OPB_AC97_CONTROLLER_REF_0_PLAYBACK_INTERRUPT_INTR 12
+#define XPAR_DCR_INTC_0_OPB_AC97_CONTROLLER_REF_0_RECORD_INTERRUPT_INTR 13
+#define XPAR_DCR_INTC_0_OPB_PCI_REF_0_INTR_OUT_INTR 14
+#define XPAR_DCR_INTC_0_PLB2OPB_BRIDGE_0_BUS_ERROR_DET_INTR 15
+#define XPAR_DCR_INTC_0_PLB_V34_0_BUS_ERROR_DET_INTR 16
+#define XPAR_DCR_INTC_0_OPB2PLB_BRIDGE_0_BUS_ERROR_DET_INTR 17
+
+/******************************************************************/
+
+#define XPAR_XTFT_NUM_INSTANCES 1
+#define XPAR_PLB_TFT_CNTLR_REF_0_DCR_BASEADDR 0xD0000200
+#define XPAR_PLB_TFT_CNTLR_REF_0_DCR_HIGHADDR 0xD0000207
+#define XPAR_PLB_TFT_CNTLR_REF_0_DEVICE_ID 0
+
+/******************************************************************/
+
+#define XPAR_XSYSACE_MEM_WIDTH 8
+#define XPAR_XSYSACE_NUM_INSTANCES 1
+#define XPAR_OPB_SYSACE_0_BASEADDR 0xCF000000
+#define XPAR_OPB_SYSACE_0_HIGHADDR 0xCF0001FF
+#define XPAR_OPB_SYSACE_0_DEVICE_ID 0
+#define XPAR_OPB_SYSACE_0_MEM_WIDTH 8
+
+/******************************************************************/
+
+#define XPAR_CPU_PPC405_CORE_CLOCK_FREQ_HZ 300000000
+
+/******************************************************************/
+
+/******************************************************************/
+
+/* Linux Redefines */
+
+/******************************************************************/
+
+#define XPAR_UARTNS550_0_BASEADDR (XPAR_OPB_UART16550_0_BASEADDR+0x1000)
+#define XPAR_UARTNS550_0_HIGHADDR XPAR_OPB_UART16550_0_HIGHADDR
+#define XPAR_UARTNS550_0_CLOCK_FREQ_HZ XPAR_XUARTNS550_CLOCK_HZ
+#define XPAR_UARTNS550_0_DEVICE_ID XPAR_OPB_UART16550_0_DEVICE_ID
+#define XPAR_UARTNS550_1_BASEADDR (XPAR_OPB_UART16550_1_BASEADDR+0x1000)
+#define XPAR_UARTNS550_1_HIGHADDR XPAR_OPB_UART16550_1_HIGHADDR
+#define XPAR_UARTNS550_1_CLOCK_FREQ_HZ XPAR_XUARTNS550_CLOCK_HZ
+#define XPAR_UARTNS550_1_DEVICE_ID XPAR_OPB_UART16550_1_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_GPIO_0_BASEADDR XPAR_MY_OPB_GPIO_0_BASEADDR_0
+#define XPAR_GPIO_0_HIGHADDR XPAR_MY_OPB_GPIO_0_HIGHADDR_0
+#define XPAR_GPIO_0_DEVICE_ID XPAR_MY_OPB_GPIO_0_DEVICE_ID_0
+#define XPAR_GPIO_1_BASEADDR XPAR_MY_OPB_GPIO_0_BASEADDR_1
+#define XPAR_GPIO_1_HIGHADDR XPAR_MY_OPB_GPIO_0_HIGHADDR_1
+#define XPAR_GPIO_1_DEVICE_ID XPAR_MY_OPB_GPIO_0_DEVICE_ID_1
+
+/******************************************************************/
+
+#define XPAR_IIC_0_BASEADDR XPAR_OPB_IIC_0_BASEADDR
+#define XPAR_IIC_0_HIGHADDR XPAR_OPB_IIC_0_HIGHADDR
+#define XPAR_IIC_0_TEN_BIT_ADR XPAR_OPB_IIC_0_TEN_BIT_ADR
+#define XPAR_IIC_0_DEVICE_ID XPAR_OPB_IIC_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_SYSACE_0_BASEADDR XPAR_OPB_SYSACE_0_BASEADDR
+#define XPAR_SYSACE_0_HIGHADDR XPAR_OPB_SYSACE_0_HIGHADDR
+#define XPAR_SYSACE_0_DEVICE_ID XPAR_OPB_SYSACE_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_INTC_0_BASEADDR XPAR_DCR_INTC_0_BASEADDR
+#define XPAR_INTC_0_HIGHADDR XPAR_DCR_INTC_0_HIGHADDR
+#define XPAR_INTC_0_KIND_OF_INTR XPAR_DCR_INTC_0_KIND_OF_INTR
+#define XPAR_INTC_0_DEVICE_ID XPAR_DCR_INTC_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_INTC_0_EMAC_0_VEC_ID XPAR_DCR_INTC_0_OPB_ETHERNET_0_IP2INTC_IRPT_INTR
+#define XPAR_INTC_0_IIC_0_VEC_ID XPAR_DCR_INTC_0_OPB_IIC_0_IP2INTC_IRPT_INTR
+#define XPAR_INTC_0_SYSACE_0_VEC_ID XPAR_DCR_INTC_0_OPB_SYSACE_0_SYSACE_IRQ_INTR
+#define XPAR_INTC_0_UARTNS550_0_VEC_ID XPAR_DCR_INTC_0_OPB_UART16550_0_IP2INTC_IRPT_INTR
+#define XPAR_INTC_0_UARTNS550_1_VEC_ID XPAR_DCR_INTC_0_OPB_UART16550_1_IP2INTC_IRPT_INTR
+#define XPAR_INTC_0_PS2_0_VEC_ID XPAR_DCR_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR1_INTR
+#define XPAR_INTC_0_PS2_1_VEC_ID XPAR_DCR_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR2_INTR
+#define XPAR_INTC_0_SPI_0_VEC_ID XPAR_DCR_INTC_0_OPB_SPI_0_IP2INTC_IRPT_INTR
+#define XPAR_INTC_0_TOUCHSCREEN_0_VEC_ID XPAR_DCR_INTC_0_OPB_TSD_REF_0_INTR_INTR
+#define XPAR_INTC_0_PCI_0_VEC_ID_A XPAR_DCR_INTC_0_OPB_PCI_REF_0_INTR_OUT_INTR
+#define XPAR_INTC_0_PCI_0_VEC_ID_B XPAR_DCR_INTC_0_OPB_PCI_REF_0_INTR_OUT_INTR
+#define XPAR_INTC_0_PCI_0_VEC_ID_C XPAR_DCR_INTC_0_OPB_PCI_REF_0_INTR_OUT_INTR
+#define XPAR_INTC_0_PCI_0_VEC_ID_D XPAR_DCR_INTC_0_OPB_PCI_REF_0_INTR_OUT_INTR
+
+/******************************************************************/
+
+#define XPAR_EMAC_0_BASEADDR XPAR_OPB_ETHERNET_0_BASEADDR
+#define XPAR_EMAC_0_HIGHADDR XPAR_OPB_ETHERNET_0_HIGHADDR
+#define XPAR_EMAC_0_DMA_PRESENT XPAR_OPB_ETHERNET_0_DMA_PRESENT
+#define XPAR_EMAC_0_MII_EXIST XPAR_OPB_ETHERNET_0_MII_EXIST
+#define XPAR_EMAC_0_ERR_COUNT_EXIST XPAR_OPB_ETHERNET_0_ERR_COUNT_EXIST
+#define XPAR_EMAC_0_DEVICE_ID XPAR_OPB_ETHERNET_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_SPI_0_BASEADDR XPAR_OPB_SPI_0_BASEADDR
+#define XPAR_SPI_0_HIGHADDR XPAR_OPB_SPI_0_HIGHADDR
+#define XPAR_SPI_0_DEVICE_ID XPAR_OPB_SPI_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_TOUCHSCREEN_0_BASEADDR XPAR_OPB_TSD_REF_0_BASEADDR
+#define XPAR_TOUCHSCREEN_0_HIGHADDR XPAR_OPB_TSD_REF_0_HIGHADDR
+#define XPAR_TOUCHSCREEN_0_DEVICE_ID XPAR_OPB_TSD_REF_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_TFT_0_BASEADDR XPAR_PLB_TFT_CNTLR_REF_0_DCR_BASEADDR
+
+/******************************************************************/
+
+#define XPAR_PCI_0_BASEADDR XPAR_OPB_PCI_REF_0_BASEADDR
+#define XPAR_PCI_0_HIGHADDR XPAR_OPB_PCI_REF_0_HIGHADDR
+#define XPAR_PCI_0_CONFIG_ADDR XPAR_OPB_PCI_REF_0_CONFIG_ADDR
+#define XPAR_PCI_0_CONFIG_DATA XPAR_OPB_PCI_REF_0_CONFIG_DATA
+#define XPAR_PCI_0_LCONFIG_ADDR XPAR_OPB_PCI_REF_0_LCONFIG_ADDR
+#define XPAR_PCI_0_MEM_BASEADDR XPAR_OPB_PCI_REF_0_MEM_BASEADDR
+#define XPAR_PCI_0_MEM_HIGHADDR XPAR_OPB_PCI_REF_0_MEM_HIGHADDR
+#define XPAR_PCI_0_IO_BASEADDR XPAR_OPB_PCI_REF_0_IO_BASEADDR
+#define XPAR_PCI_0_IO_HIGHADDR XPAR_OPB_PCI_REF_0_IO_HIGHADDR
+#define XPAR_PCI_0_CLOCK_FREQ_HZ XPAR_XPCI_CLOCK_HZ
+#define XPAR_PCI_0_DEVICE_ID XPAR_OPB_PCI_REF_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_PS2_0_BASEADDR XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_0
+#define XPAR_PS2_0_HIGHADDR XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_0
+#define XPAR_PS2_0_DEVICE_ID XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_0
+#define XPAR_PS2_1_BASEADDR XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_1
+#define XPAR_PS2_1_HIGHADDR XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_1
+#define XPAR_PS2_1_DEVICE_ID XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_1
+
+/******************************************************************/
+
+#define XPAR_PLB_CLOCK_FREQ_HZ 100000000
+#define XPAR_CORE_CLOCK_FREQ_HZ XPAR_CPU_PPC405_CORE_CLOCK_FREQ_HZ
+#define XPAR_DDR_0_SIZE 0x08000000
+
+/******************************************************************/
+
+#define XPAR_PERSISTENT_0_IIC_0_BASEADDR 0x00000400
+#define XPAR_PERSISTENT_0_IIC_0_HIGHADDR 0x000007FF
+#define XPAR_PERSISTENT_0_IIC_0_EEPROMADDR 0xA0
+
+/******************************************************************/
+
+#define XPAR_POWER_0_POWERDOWN_BASEADDR 0x90000004
+#define XPAR_POWER_0_POWERDOWN_HIGHADDR 0x90000007
+#define XPAR_POWER_0_POWERDOWN_VALUE 0xFF
+
+/******************************************************************/
diff -Nru a/arch/ppc/platforms/85xx/mpc8555.c b/arch/ppc/platforms/85xx/mpc8555.c
--- a/arch/ppc/platforms/85xx/mpc8555.c	2004-12-24 13:37:02 -08:00
+++ b/arch/ppc/platforms/85xx/mpc8555.c	2004-12-24 13:37:02 -08:00
@@ -77,6 +77,13 @@
           .pm           = OCP_CPM_NA,
         },
         { .vendor       = OCP_VENDOR_FREESCALE,
+          .function     = OCP_FUNC_SEC2,
+          .index        = 0,
+          .paddr        = MPC85xx_SEC2_OFFSET,
+          .irq          = MPC85xx_IRQ_SEC2,
+          .pm           = OCP_CPM_NA,
+	},
+	{ .vendor       = OCP_VENDOR_FREESCALE,
           .function     = OCP_FUNC_PERFMON,
           .index        = 0,
           .paddr        = MPC85xx_PERFMON_OFFSET,
diff -Nru a/arch/ppc/platforms/85xx/mpc8560_ads.c b/arch/ppc/platforms/85xx/mpc8560_ads.c
--- a/arch/ppc/platforms/85xx/mpc8560_ads.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc/platforms/85xx/mpc8560_ads.c	2004-12-24 13:37:18 -08:00
@@ -145,12 +145,18 @@
 
 static irqreturn_t cpm2_cascade(int irq, void *dev_id, struct pt_regs *regs)
 {
-	while ((irq = cpm2_get_irq(regs)) >= 0) {
-		ppc_irq_dispatch_handler(regs, irq);
-	}
+	while ((irq = cpm2_get_irq(regs)) >= 0)
+		__do_IRQ(irq, regs);
 	return IRQ_HANDLED;
 }
 
+static struct irqaction cpm2_irqaction = {
+	.handler = cpm2_cascade,
+	.flags = SA_INTERRUPT,
+	.mask = CPU_MASK_NONE,
+	.name = "cpm2_cascade",
+};
+
 static void __init
 mpc8560_ads_init_IRQ(void)
 {
@@ -174,7 +180,7 @@
 	immap->im_intctl.ic_scprrh = 0x05309770;
 	immap->im_intctl.ic_scprrl = 0x05309770;
 
-	request_irq(MPC85xx_IRQ_CPM, cpm2_cascade, SA_INTERRUPT, "cpm2_cascade", NULL);
+	setup_irq(MPC85xx_IRQ_CPM, &cpm2_irqaction);
 
 	return;
 }
diff -Nru a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
--- a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c	2004-12-24 13:37:30 -08:00
+++ b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c	2004-12-24 13:37:30 -08:00
@@ -142,8 +142,7 @@
 		seq_printf(m, "Machine\t\t: unknown\n");
 		break;
 	}
-	seq_printf(m, "bus freq\t: %u.%.6u MHz\n", freq / 1000000,
-		   freq % 1000000);
+	seq_printf(m, "clock\t\t: %dMHz\n", freq / 1000000);
 	seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
 	seq_printf(m, "SVR\t\t: 0x%x\n", svid);
 
diff -Nru a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c	2004-12-24 13:37:19 -08:00
@@ -172,8 +172,7 @@
 
         seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
 	seq_printf(m, "Machine\t\t: CDS (%x)\n", cadmus[CM_VER]);
-        seq_printf(m, "bus freq\t: %u.%.6u MHz\n", freq / 1000000,
-                   freq % 1000000);
+	seq_printf(m, "clock\t\t: %dMHz\n", freq / 1000000);
         seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
 
@@ -191,10 +190,15 @@
 static void cpm2_cascade(int irq, void *dev_id, struct pt_regs *regs)
 {
 	while((irq = cpm2_get_irq(regs)) >= 0)
-	{
-		ppc_irq_dispatch_handler(regs,irq);
-	}
+		__do_IRQ(irq, regs);
 }
+
+static struct irqaction cpm2_irqaction = {
+	.handler = cpm2_cascade,
+	.flags = SA_INTERRUPT,
+	.mask = CPU_MASK_NONE,
+	.name = "cpm2_cascade",
+};
 #endif /* CONFIG_CPM2 */
 
 void __init
@@ -237,7 +241,7 @@
 	immap->im_intctl.ic_scprrh = 0x05309770;
 	immap->im_intctl.ic_scprrl = 0x05309770;
 
-	request_irq(MPC85xx_IRQ_CPM, cpm2_cascade, SA_INTERRUPT, "cpm2_cascade", NULL);
+	setup_irq(MPC85xx_IRQ_CPM, &cpm2_irqaction);
 #endif
 
         return;
diff -Nru a/arch/ppc/platforms/85xx/sbc85xx.c b/arch/ppc/platforms/85xx/sbc85xx.c
--- a/arch/ppc/platforms/85xx/sbc85xx.c	2004-12-24 13:37:02 -08:00
+++ b/arch/ppc/platforms/85xx/sbc85xx.c	2004-12-24 13:37:02 -08:00
@@ -142,8 +142,7 @@
 		seq_printf(m, "Machine\t\t: unknown\n");
 		break;
 	}
-	seq_printf(m, "bus freq\t: %u.%.6u MHz\n", freq / 1000000,
-		   freq % 1000000);
+	seq_printf(m, "clock\t\t: %dMHz\n", freq / 1000000);
 	seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
 	seq_printf(m, "SVR\t\t: 0x%x\n", svid);
 
diff -Nru a/arch/ppc/platforms/adir_pic.c b/arch/ppc/platforms/adir_pic.c
--- a/arch/ppc/platforms/adir_pic.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc/platforms/adir_pic.c	2004-12-24 13:36:18 -08:00
@@ -11,7 +11,7 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/pci.h>
-#include <linux/irq.h>
+#include <linux/interrupt.h>
 
 #include <asm/io.h>
 #include <asm/i8259.h>
@@ -20,11 +20,6 @@
 static void adir_onboard_pic_enable(unsigned int irq);
 static void adir_onboard_pic_disable(unsigned int irq);
 
-static void
-no_action(int cpl, void *dev_id, struct pt_regs *regs)
-{
-}
-
 __init static void
 adir_onboard_pic_init(void)
 {
@@ -88,6 +83,13 @@
 	NULL
 };
 
+static struct irqaction noop_action = {
+	.handler	= no_action,
+	.flags          = SA_INTERRUPT,
+	.mask           = CPU_MASK_NONE,
+	.name           = "82c59 primary cascade",
+};
+
 /*
  * Linux interrupt values are assigned as follows:
  *
@@ -110,11 +112,7 @@
 	adir_onboard_pic_init();
 
 	/* Enable 8259 interrupt cascade */
-	request_irq(ADIR_IRQ_VT82C686_INTR,
-			no_action,
-			SA_INTERRUPT,
-			"82c59 primary cascade",
-			NULL);
+	setup_irq(ADIR_IRQ_VT82C686_INTR, &noop_action);
 }
 
 int
diff -Nru a/arch/ppc/platforms/chrp_pci.c b/arch/ppc/platforms/chrp_pci.c
--- a/arch/ppc/platforms/chrp_pci.c	2004-12-24 13:37:32 -08:00
+++ b/arch/ppc/platforms/chrp_pci.c	2004-12-24 13:37:32 -08:00
@@ -158,7 +158,7 @@
 	struct device_node *np;
 
 	/* PCI interrupts are controlled by the OpenPIC */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		np = pci_device_to_OF_node(dev);
 		if ((np != 0) && (np->n_intrs > 0) && (np->intrs[0].line != 0))
 			dev->irq = np->intrs[0].line;
diff -Nru a/arch/ppc/platforms/chrp_setup.c b/arch/ppc/platforms/chrp_setup.c
--- a/arch/ppc/platforms/chrp_setup.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc/platforms/chrp_setup.c	2004-12-24 13:37:18 -08:00
@@ -371,6 +371,14 @@
 	}
 }
 
+#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(XMON)
+static struct irqaction xmon_irqaction = {
+	.handler = xmon_irq,
+	.mask = CPU_MASK_NONE,
+	.name = "XMON break",
+};
+#endif
+
 void __init chrp_init_IRQ(void)
 {
 	struct device_node *np;
@@ -416,7 +424,7 @@
 		    && strcmp(kbd->parent->type, "adb") == 0)
 			break;
 	if (kbd)
-		request_irq(HYDRA_INT_ADB_NMI, xmon_irq, 0, "XMON break", 0);
+		setup_irq(HYDRA_INT_ADB_NMI, &xmon_irqaction);
 #endif
 }
 
diff -Nru a/arch/ppc/platforms/gemini_pci.c b/arch/ppc/platforms/gemini_pci.c
--- a/arch/ppc/platforms/gemini_pci.c	2004-12-24 13:36:33 -08:00
+++ b/arch/ppc/platforms/gemini_pci.c	2004-12-24 13:36:33 -08:00
@@ -15,7 +15,7 @@
 	int i;
 	struct pci_dev *dev = NULL;
 	
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		for(i = 0; i < 6; i++) {
 			if (dev->resource[i].flags & IORESOURCE_IO) {
 				dev->resource[i].start |= (0xfe << 24);
diff -Nru a/arch/ppc/platforms/k2.c b/arch/ppc/platforms/k2.c
--- a/arch/ppc/platforms/k2.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc/platforms/k2.c	2004-12-24 13:36:17 -08:00
@@ -116,7 +116,7 @@
 	/*
 	 * Enable DMA support on hdc
 	 */
-	ide_dev = pci_find_device(PCI_VENDOR_ID_AL,
+	ide_dev = pci_get_device(PCI_VENDOR_ID_AL,
 				  PCI_DEVICE_ID_AL_M5229, NULL);
 
 	if (ide_dev) {
@@ -126,6 +126,7 @@
 		ide_dma_base = pci_resource_start(ide_dev, 4);
 		outb(0x00, ide_dma_base + 0x2);
 		outb(0x20, ide_dma_base + 0xa);
+		pci_dev_put(ide_dev);
 	}
 #endif
 }
diff -Nru a/arch/ppc/platforms/lopec.c b/arch/ppc/platforms/lopec.c
--- a/arch/ppc/platforms/lopec.c	2004-12-24 13:36:56 -08:00
+++ b/arch/ppc/platforms/lopec.c	2004-12-24 13:36:56 -08:00
@@ -189,7 +189,7 @@
 static void
 lopec_ide_probe(void)
 {
-	struct pci_dev *dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	struct pci_dev *dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 					      PCI_DEVICE_ID_WINBOND_82C105,
 					      NULL);
 	lopec_ide_ports_known = 1;
@@ -200,6 +200,7 @@
 		lopec_ide_ctl_regbase[0] = dev->resource[1].start;
 		lopec_ide_ctl_regbase[1] = dev->resource[3].start;
 		lopec_idedma_regbase = dev->resource[4].start;
+		pci_dev_put(dev);
 	}
 }
 
diff -Nru a/arch/ppc/platforms/mcpn765.c b/arch/ppc/platforms/mcpn765.c
--- a/arch/ppc/platforms/mcpn765.c	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc/platforms/mcpn765.c	2004-12-24 13:37:01 -08:00
@@ -185,7 +185,7 @@
 	struct pci_dev	*dev;
 	u_char		c;
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 				   PCI_DEVICE_ID_VIA_82C586_0,
 				   NULL)) == NULL) {
 		printk("No VIA ISA bridge found\n");
@@ -209,8 +209,8 @@
 	pci_write_config_dword(dev, 0x54, 0);
 	pci_write_config_byte(dev, 0x58, 0);
 
-
-	if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+	pci_dev_put(dev);
+	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 				   PCI_DEVICE_ID_VIA_82C586_1,
 				   NULL)) == NULL) {
 		printk("No VIA ISA bridge found\n");
@@ -225,6 +225,7 @@
 	pci_read_config_byte(dev, 0x40, &c);
 	c |= 0x03;
 	pci_write_config_byte(dev, 0x40, c);
+	pci_dev_put(dev);
 
 	return;
 }
diff -Nru a/arch/ppc/platforms/mvme5100.c b/arch/ppc/platforms/mvme5100.c
--- a/arch/ppc/platforms/mvme5100.c	2004-12-24 13:36:32 -08:00
+++ b/arch/ppc/platforms/mvme5100.c	2004-12-24 13:36:32 -08:00
@@ -228,7 +228,7 @@
 	for (i = 0; i < NUM_8259_INTERRUPTS; i++)
 		irq_desc[i].handler = &i8259_pic;
 
-	i8259_init(NULL);
+	i8259_init(0);
 #else
 	openpic_init(0);
 #endif
diff -Nru a/arch/ppc/platforms/pcore.c b/arch/ppc/platforms/pcore.c
--- a/arch/ppc/platforms/pcore.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc/platforms/pcore.c	2004-12-24 13:36:17 -08:00
@@ -89,7 +89,7 @@
 {
 	struct pci_dev *dev;
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 				PCI_DEVICE_ID_WINBOND_83C553,
 				0)))
 	{
@@ -108,6 +108,7 @@
 		 */
  		outb(0x00, PCORE_WINBOND_PRI_EDG_LVL);
 		outb(0x1e, PCORE_WINBOND_SEC_EDG_LVL);
+		pci_dev_put(dev);
 	}
 }
 
diff -Nru a/arch/ppc/platforms/pmac_cpufreq.c b/arch/ppc/platforms/pmac_cpufreq.c
--- a/arch/ppc/platforms/pmac_cpufreq.c	2004-12-24 13:36:59 -08:00
+++ b/arch/ppc/platforms/pmac_cpufreq.c	2004-12-24 13:36:59 -08:00
@@ -33,6 +33,8 @@
 #include <asm/sections.h>
 #include <asm/cputable.h>
 #include <asm/time.h>
+#include <asm/system.h>
+#include <asm/open_pic.h>
 
 /* WARNING !!! This will cause calibrate_delay() to be called,
  * but this is an __init function ! So you MUST go edit
@@ -51,10 +53,6 @@
 extern void low_choose_7447a_dfs(int dfs);
 extern void low_choose_750fx_pll(int pll);
 extern void low_sleep_handler(void);
-extern void openpic_suspend(struct sys_device *sysdev, u32 state);
-extern void openpic_resume(struct sys_device *sysdev);
-extern void enable_kernel_altivec(void);
-extern void enable_kernel_fp(void);
 
 /*
  * Currently, PowerMac cpufreq supports only high & low frequencies
@@ -140,11 +138,8 @@
 	if (low_speed == 0) {
 		/* ramping up, set voltage first */
 		pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x05);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/1000);
-	} else {
-		/* ramping down, enable aack delay first */
-		pmac_call_feature(PMAC_FTR_AACK_DELAY_ENABLE, NULL, 1, 0);
+		/* Make sure we sleep for at least 1ms */
+		msleep(1);
 	}
 
 	/* set frequency */
@@ -153,11 +148,7 @@
 	if (low_speed == 1) {
 		/* ramping down, set voltage last */
 		pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x04);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/1000);
-	} else {
-		/* ramping up, disable aack delay last */
-		pmac_call_feature(PMAC_FTR_AACK_DELAY_ENABLE, NULL, 0, 0);
+		msleep(1);
 	}
 
 	return 0;
@@ -174,8 +165,7 @@
 	if (low_speed == 0) {
 		pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x05);
 		/* Delay is way too big but it's ok, we schedule */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	}
 
 	/* Set frequency */
@@ -192,8 +182,7 @@
 	if (low_speed == 1) {
 		pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x04);
 		/* Delay is way too big but it's ok, we schedule */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	}
 
 #ifdef DEBUG_FREQ
@@ -217,7 +206,7 @@
 	printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));
 #endif
 	/* Disable all interrupt sources on openpic */
-	openpic_suspend(NULL, 1);
+ 	openpic_set_priority(0xf);
 
 	/* Make sure the decrementer won't interrupt us */
 	asm volatile("mtdec %0" : : "r" (0x7fffffff));
@@ -284,7 +273,7 @@
 	wakeup_decrementer();
 
 	/* Restore interrupts */
-	openpic_resume(NULL);
+ 	openpic_set_priority(0);
 
 	/* Let interrupts flow again ... */
 	local_irq_enable();
diff -Nru a/arch/ppc/platforms/pmac_feature.c b/arch/ppc/platforms/pmac_feature.c
--- a/arch/ppc/platforms/pmac_feature.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/platforms/pmac_feature.c	2004-12-24 13:37:19 -08:00
@@ -117,10 +117,10 @@
 #define UN_BIC(r,v)	(UN_OUT((r), UN_IN(r) & ~(v)))
 
 static struct device_node* uninorth_node __pmacdata;
-static u32* uninorth_base __pmacdata;
+static u32 __iomem * uninorth_base __pmacdata;
 static u32 uninorth_rev __pmacdata;
 static int uninorth_u3 __pmacdata;
-static void *u3_ht;
+static void __iomem *u3_ht;
 
 /*
  * For each motherboard family, we have a table of functions pointers
@@ -517,7 +517,7 @@
 
 	/* Save state & config of DBDMA channels */
 	for (i=0; i<13; i++) {
-		volatile struct dbdma_regs* chan = (volatile struct dbdma_regs*)
+		volatile struct dbdma_regs __iomem * chan = (void __iomem *)
 			(macio->base + ((0x8000+i*0x100)>>2));
 		save[i].cmdptr_hi = in_le32(&chan->cmdptr_hi);
 		save[i].cmdptr = in_le32(&chan->cmdptr);
@@ -534,7 +534,7 @@
 
 	/* Save state & config of DBDMA channels */
 	for (i=0; i<13; i++) {
-		volatile struct dbdma_regs* chan = (volatile struct dbdma_regs*)
+		volatile struct dbdma_regs __iomem * chan = (void __iomem *)
 			(macio->base + ((0x8000+i*0x100)>>2));
 		out_le32(&chan->control, (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16);
 		while (in_le32(&chan->status) & ACTIVE)
@@ -2286,14 +2286,14 @@
 #ifndef CONFIG_POWER4
 	/* Fixup Hooper vs. Comet */
 	if (pmac_mb.model_id == PMAC_TYPE_HOOPER) {
-		u32* mach_id_ptr = (u32*)ioremap(0xf3000034, 4);
+		u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4);
 		if (!mach_id_ptr)
 			return -ENODEV;
 		/* Here, I used to disable the media-bay on comet. It
 		 * appears this is wrong, the floppy connector is actually
 		 * a kind of media-bay and works with the current driver.
 		 */
-		if ((*mach_id_ptr) & 0x20000000UL)
+		if (__raw_readl(mach_id_ptr) & 0x20000000UL)
 			pmac_mb.model_id = PMAC_TYPE_COMET;
 		iounmap(mach_id_ptr);
 	}
@@ -2394,7 +2394,7 @@
 {
 	struct device_node*	node;
 	int			i;
-	volatile u32*		base;
+	volatile u32 __iomem *	base;
 	u32*			revp;
 
 	node = find_devices(name);
@@ -2419,7 +2419,7 @@
 		printk(KERN_ERR "pmac_feature: %s skipped\n", node->full_name);
 		return;
 	}
-	base = (volatile u32*)ioremap(node->addrs[0].address, node->addrs[0].size);
+	base = ioremap(node->addrs[0].address, node->addrs[0].size);
 	if (!base) {
 		printk(KERN_ERR "pmac_feature: Can't map mac-io chip !\n");
 		return;
diff -Nru a/arch/ppc/platforms/pmac_pci.c b/arch/ppc/platforms/pmac_pci.c
--- a/arch/ppc/platforms/pmac_pci.c	2004-12-24 13:36:55 -08:00
+++ b/arch/ppc/platforms/pmac_pci.c	2004-12-24 13:36:55 -08:00
@@ -889,7 +889,7 @@
 	 * should find the device node and apply the interrupt
 	 * obtained from the OF device-tree
 	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		struct device_node *node;
 		node = pci_device_to_OF_node(dev);
 		/* this is the node, see if it has interrupts */
@@ -989,7 +989,7 @@
 	 *
 	 * -- BenH
 	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		if ((dev->class >> 16) == PCI_BASE_CLASS_STORAGE)
 			pci_enable_device(dev);
 	}
diff -Nru a/arch/ppc/platforms/pmac_pic.c b/arch/ppc/platforms/pmac_pic.c
--- a/arch/ppc/platforms/pmac_pic.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/platforms/pmac_pic.c	2004-12-24 13:37:19 -08:00
@@ -214,7 +214,7 @@
 		if (bits == 0)
 			continue;
 		irq += __ilog2(bits);
-		ppc_irq_dispatch_handler(regs, irq);
+		__do_IRQ(irq, regs);
 		return IRQ_HANDLED;
 	}
 	printk("gatwick irq not from gatwick pic\n");
@@ -383,11 +383,34 @@
 
 	irq = openpic2_get_irq(regs);
 	if (irq != -1)
-		ppc_irq_dispatch_handler(regs, irq);
+		__do_IRQ(irq, regs);
 	return IRQ_HANDLED;
 }
+
+static struct irqaction k2u3_cascade_action = {
+	.handler	= k2u3_action,
+	.flags		= 0,
+	.mask		= CPU_MASK_NONE,
+	.name		= "U3->K2 Cascade",
+};
 #endif /* CONFIG_POWER4 */
 
+#ifdef CONFIG_XMON
+static struct irqaction xmon_action = {
+	.handler	= xmon_irq,
+	.flags		= 0,
+	.mask		= CPU_MASK_NONE,
+	.name		= "NMI - XMON"
+};
+#endif
+
+static struct irqaction gatwick_cascade_action = {
+	.handler	= gatwick_action,
+	.flags		= SA_INTERRUPT,
+	.mask		= CPU_MASK_NONE,
+	.name		= "cascade",
+};
+
 void __init pmac_pic_init(void)
 {
         int i;
@@ -440,8 +463,9 @@
 				OpenPIC_InitSenses = senses;
 				OpenPIC_NumInitSenses = 128;
 				openpic2_init(PMAC_OPENPIC2_OFFSET);
-				if (request_irq(irqctrler2->intrs[0].line, k2u3_action, 0,
-						"U3->K2 Cascade", NULL))
+
+				if (setup_irq(irqctrler2->intrs[0].line,
+					      &k2u3_cascade_action))
 					printk("Unable to get OpenPIC IRQ for cascade\n");
 			}
 #endif /* CONFIG_POWER4 */
@@ -455,8 +479,7 @@
 				if (pswitch && pswitch->n_intrs) {
 					nmi_irq = pswitch->intrs[0].line;
 					openpic_init_nmi_irq(nmi_irq);
-					request_irq(nmi_irq, xmon_irq, 0,
-						    "NMI - XMON", NULL);
+					setup_irq(nmi_irq, &xmon_action);
 				}
 			}
 #endif	/* CONFIG_XMON */
@@ -553,8 +576,7 @@
 			(int)irq_cascade);
 		for ( i = max_real_irqs ; i < max_irqs ; i++ )
 			irq_desc[i].handler = &gatwick_pic;
-		request_irq( irq_cascade, gatwick_action, SA_INTERRUPT,
-			     "cascade", NULL );
+		setup_irq(irq_cascade, &gatwick_cascade_action);
 	}
 	printk("System has %d possible interrupts\n", max_irqs);
 	if (max_irqs != max_real_irqs)
@@ -562,7 +584,7 @@
 			max_real_irqs);
 
 #ifdef CONFIG_XMON
-	request_irq(20, xmon_irq, 0, "NMI - XMON", NULL);
+	setup_irq(20, &xmon_action);
 #endif	/* CONFIG_XMON */
 }
 
diff -Nru a/arch/ppc/platforms/pmac_setup.c b/arch/ppc/platforms/pmac_setup.c
--- a/arch/ppc/platforms/pmac_setup.c	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc/platforms/pmac_setup.c	2004-12-24 13:37:01 -08:00
@@ -51,13 +51,13 @@
 #include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
+#include <linux/bitops.h>
 
 #include <asm/reg.h>
 #include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/pci-bridge.h>
 #include <asm/ohare.h>
diff -Nru a/arch/ppc/platforms/pmac_smp.c b/arch/ppc/platforms/pmac_smp.c
--- a/arch/ppc/platforms/pmac_smp.c	2004-12-24 13:36:54 -08:00
+++ b/arch/ppc/platforms/pmac_smp.c	2004-12-24 13:36:54 -08:00
@@ -405,6 +405,13 @@
 	smp_tb_synchronized = 1;
 }
 
+static struct irqaction psurge_irqaction = {
+	.handler = psurge_primary_intr,
+	.flags = SA_INTERRUPT,
+	.mask = CPU_MASK_NONE,
+	.name = "primary IPI",
+};
+
 static void __init smp_psurge_setup_cpu(int cpu_nr)
 {
 
@@ -421,7 +428,7 @@
 		/* 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, SA_INTERRUPT, "primary IPI", NULL))
+		if (setup_irq(30, &psurge_irqaction))
 			printk(KERN_ERR "Couldn't get primary IPI interrupt");
 	}
 
diff -Nru a/arch/ppc/platforms/pplus.c b/arch/ppc/platforms/pplus.c
--- a/arch/ppc/platforms/pplus.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc/platforms/pplus.c	2004-12-24 13:37:29 -08:00
@@ -359,7 +359,7 @@
 	 * Perform specific configuration for the Via Tech or
 	 * or Winbond PCI-ISA-Bridge part.
 	 */
-	if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 				   PCI_DEVICE_ID_VIA_82C586_1, dev))) {
 		/*
 		 * PPCBUG does not set the enable bits
@@ -371,7 +371,7 @@
 		pci_write_config_byte(dev, 0x40, reg);
 	}
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 				   PCI_DEVICE_ID_VIA_82C586_2,
 				   dev)) && (dev->devfn = 0x5a)) {
 		/* Force correct USB interrupt */
@@ -379,7 +379,7 @@
 		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
 	}
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 				   PCI_DEVICE_ID_WINBOND_83C553, dev))) {
 		/* Clear PCI Interrupt Routing Control Register. */
 		short_reg = 0x0000;
@@ -389,7 +389,7 @@
 		pci_write_config_byte(dev, 0x43, reg);
 	}
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 				   PCI_DEVICE_ID_WINBOND_82C105, dev))) {
 		/*
 		 * Disable LEGIRQ mode so PCI INTS are routed
@@ -401,6 +401,7 @@
 		dev->irq = 14;
 		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
 	}
+	pci_dev_put(dev);
 }
 
 void __init pplus_set_VIA_IDE_legacy(void)
diff -Nru a/arch/ppc/platforms/prep_pci.c b/arch/ppc/platforms/prep_pci.c
--- a/arch/ppc/platforms/prep_pci.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc/platforms/prep_pci.c	2004-12-24 13:37:29 -08:00
@@ -49,10 +49,10 @@
         0,   /* Slot 1  - unused */
         5,   /* Slot 2  - SCSI - NCR825A  */
         0,   /* Slot 3  - unused */
-        1,   /* Slot 4  - Ethernet - DEC2114x */
+        3,   /* Slot 4  - Ethernet - DEC2114x */
         0,   /* Slot 5  - unused */
-        3,   /* Slot 6  - PCI Card slot #1 */
-        4,   /* Slot 7  - PCI Card slot #2 */
+        2,   /* Slot 6  - PCI Card slot #1 */
+        3,   /* Slot 7  - PCI Card slot #2 */
         5,   /* Slot 8  - PCI Card slot #3 */
         5,   /* Slot 9  - PCI Bridge */
              /* added here in case we ever support PCI bridges */
@@ -1069,7 +1069,7 @@
 		 * Perform specific configuration for the Via Tech or
 		 * or Winbond PCI-ISA-Bridge part.
 		 */
-		if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+		if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 					PCI_DEVICE_ID_VIA_82C586_1, dev))) {
 			/*
 			 * PPCBUG does not set the enable bits
@@ -1080,7 +1080,7 @@
 			reg |= 0x03; /* IDE: Chip Enable Bits */
 			pci_write_config_byte(dev, 0x40, reg);
 		}
-		if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+		if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 						PCI_DEVICE_ID_VIA_82C586_2,
 						dev)) && (dev->devfn = 0x5a)) {
 			/* Force correct USB interrupt */
@@ -1089,7 +1089,7 @@
 					PCI_INTERRUPT_LINE,
 					dev->irq);
 		}
-		if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+		if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 					PCI_DEVICE_ID_WINBOND_83C553, dev))) {
 			 /* Clear PCI Interrupt Routing Control Register. */
 			short_reg = 0x0000;
@@ -1100,9 +1100,10 @@
 				pci_write_config_byte(dev, 0x43, reg);
 			}
 		}
+		pci_dev_put(dev);
 	}
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 				   PCI_DEVICE_ID_WINBOND_82C105, dev))){
 		if (OpenPIC_Addr){
 			/*
@@ -1121,6 +1122,7 @@
 			pci_write_config_dword(dev, 0x40, 0x10ff08a1);
 		}
 	}
+	pci_dev_put(dev);
 }
 
 static void __init
@@ -1207,7 +1209,7 @@
 	printk("Setting PCI interrupts for a \"%s\"\n", Motherboard_map_name);
 
 	/* Iterate through all the PCI devices, setting the IRQ */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		/*
 		 * If we have residual data, then this is easy: query the
 		 * residual data for the IRQ line allocated to the device.
@@ -1260,12 +1262,13 @@
 	 * instead of 0xc0000. vgacon.c (for example) is completely unaware of
 	 * this little quirk.
 	 */
-	dev = pci_find_device(PCI_VENDOR_ID_WD, PCI_DEVICE_ID_WD_90C, NULL);
+	dev = pci_get_device(PCI_VENDOR_ID_WD, PCI_DEVICE_ID_WD_90C, NULL);
 	if (dev) {
 		dev->resource[1].end -= dev->resource[1].start;
 		dev->resource[1].start = 0;
 		/* tell the hardware */
 		pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, 0x0);
+		pci_dev_put(dev);
 	}
 #endif
 }
diff -Nru a/arch/ppc/platforms/prpmc750.c b/arch/ppc/platforms/prpmc750.c
--- a/arch/ppc/platforms/prpmc750.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/platforms/prpmc750.c	2004-12-24 13:37:19 -08:00
@@ -109,7 +109,7 @@
 	 * resource subsystem doesn't fixup the
 	 * PCI mem resources on the CL5446.
 	 */
-	if ((dev = pci_find_device(PCI_VENDOR_ID_CIRRUS,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_CIRRUS,
 				   PCI_DEVICE_ID_CIRRUS_5446, 0))) {
 		dev->resource[0].start += PRPMC750_PCI_PHY_MEM_OFFSET;
 		dev->resource[0].end += PRPMC750_PCI_PHY_MEM_OFFSET;
@@ -121,6 +121,7 @@
 		outb(0x0f, 0x3c4);
 		/* Set proper DRAM config */
 		outb(0xdf, 0x3c5);
+		pci_dev_put(dev);
 	}
 }
 
diff -Nru a/arch/ppc/platforms/rpxclassic.h b/arch/ppc/platforms/rpxclassic.h
--- a/arch/ppc/platforms/rpxclassic.h	2004-12-24 13:37:02 -08:00
+++ b/arch/ppc/platforms/rpxclassic.h	2004-12-24 13:37:02 -08:00
@@ -82,7 +82,6 @@
 /* for pcmcia sandisk */
 #ifdef CONFIG_IDE
 # define MAX_HWIFS 1
-# define request_irq(irq,hand,flg,dev,id)    request_8xxirq((irq),(hand),(flg),(dev),(id))
 #endif
 #endif
 
diff -Nru a/arch/ppc/platforms/rpxlite.h b/arch/ppc/platforms/rpxlite.h
--- a/arch/ppc/platforms/rpxlite.h	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc/platforms/rpxlite.h	2004-12-24 13:36:18 -08:00
@@ -68,7 +68,6 @@
 
 #ifdef CONFIG_IDE
 # define MAX_HWIFS 1
-# define request_irq(irq,hand,flg,dev,id)    request_8xxirq((irq),(hand),(flg),(dev),(id))
 #endif
 
 /* CPM Ethernet through SCCx.
diff -Nru a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
--- a/arch/ppc/platforms/sandpoint.c	2004-12-24 13:37:32 -08:00
+++ b/arch/ppc/platforms/sandpoint.c	2004-12-24 13:37:32 -08:00
@@ -60,11 +60,6 @@
  * of the amount of memory in the system.  Once a method of determining
  * what version of DINK initializes the system for us, if applicable, is
  * found, we can hopefully stop hardcoding 32MB of RAM.
- *
- * It is important to note that this code only supports the Sandpoint X3
- * (all flavors) platform, and it does not support the X2 anymore.  Code
- * that at one time worked on the X2 can be found at:
- * ftp://source.mvista.com/pub/linuxppc/obsolete/sandpoint/
  */
 
 #include <linux/config.h>
@@ -107,9 +102,13 @@
 
 #include "sandpoint.h"
 
+/* Set non-zero if an X2 Sandpoint detected. */
+static int sandpoint_is_x2;
+
 unsigned char __res[sizeof(bd_t)];
 
 static void sandpoint_halt(void);
+static void sandpoint_probe_type(void);
 
 /*
  * Define all of the IRQ senses and polarities.  Taken from the
@@ -129,7 +128,7 @@
  * Motorola SPS Sandpoint interrupt routing.
  */
 static inline int
-sandpoint_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
+x3_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
 {
 	static char pci_irq_table[][4] =
 	/*
@@ -149,6 +148,27 @@
 	return PCI_IRQ_TABLE_LOOKUP;
 }
 
+static inline int
+x2_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
+{
+	static char pci_irq_table[][4] =
+	/*
+	 *	PCI IDSEL/INTPIN->INTLINE
+	 * 	   A   B   C   D
+	 */
+	{
+		{ 18,  0,  0,  0 },	/* IDSEL 11 - i8259 on Windbond */
+		{  0,  0,  0,  0 },	/* IDSEL 12 - unused */
+		{ 16, 17, 18, 19 },	/* IDSEL 13 - PCI slot 1 */
+		{ 17, 18, 19, 16 },	/* IDSEL 14 - PCI slot 2 */
+		{ 18, 19, 16, 17 },	/* IDSEL 15 - PCI slot 3 */
+		{ 19, 16, 17, 18 },	/* IDSEL 16 - PCI slot 4 */
+	};
+
+	const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;
+	return PCI_IRQ_TABLE_LOOKUP;
+}
+
 static void __init
 sandpoint_setup_winbond_83553(struct pci_controller *hose)
 {
@@ -216,6 +236,18 @@
 	return;
 }
 
+/* On the sandpoint X2, we must avoid sending configuration cycles to
+ * device #12 (IDSEL addr = AD12).
+ */
+static int
+x2_exclude_device(u_char bus, u_char devfn)
+{
+	if ((bus == 0) && (PCI_SLOT(devfn) == SANDPOINT_HOST_BRIDGE_IDSEL))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	else
+		return PCIBIOS_SUCCESSFUL;
+}
+
 static void __init
 sandpoint_find_bridges(void)
 {
@@ -241,7 +273,11 @@
 		ppc_md.pcibios_fixup = NULL;
 		ppc_md.pcibios_fixup_bus = NULL;
 		ppc_md.pci_swizzle = common_swizzle;
-		ppc_md.pci_map_irq = sandpoint_map_irq;
+		if (sandpoint_is_x2) {
+			ppc_md.pci_map_irq = x2_map_irq;
+			ppc_md.pci_exclude_device = x2_exclude_device;
+		} else
+			ppc_md.pci_map_irq = x3_map_irq;
 	}
 	else {
 		if (ppc_md.progress)
@@ -252,41 +288,14 @@
 	return;
 }
 
-#if defined(CONFIG_SERIAL_8250) && \
-	(defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG))
-static void __init
-sandpoint_early_serial_map(void)
-{
-	struct uart_port serial_req;
-
-	/* Setup serial port access */
-	memset(&serial_req, 0, sizeof(serial_req));
-	serial_req.uartclk = UART_CLK;
-	serial_req.irq = 4;
-	serial_req.flags = STD_COM_FLAGS;
-	serial_req.iotype = SERIAL_IO_MEM;
-	serial_req.membase = (u_char *)SANDPOINT_SERIAL_0;
-
-	gen550_init(0, &serial_req);
-
-	if (early_serial_setup(&serial_req) != 0)
-		printk(KERN_ERR "Early serial init of port 0 failed\n");
-
-	/* Assume early_serial_setup() doesn't modify serial_req */
-	serial_req.line = 1;
-	serial_req.irq = 3; /* XXXX */
-	serial_req.membase = (u_char *)SANDPOINT_SERIAL_1;
-
-	gen550_init(1, &serial_req);
-
-	if (early_serial_setup(&serial_req) != 0)
-		printk(KERN_ERR "Early serial init of port 1 failed\n");
-}
-#endif
-
 static void __init
 sandpoint_setup_arch(void)
 {
+	/* Probe for Sandpoint model */
+	sandpoint_probe_type();
+	if (sandpoint_is_x2)
+		epic_serial_mode = 0;
+
 	loops_per_jiffy = 100000000 / HZ;
 
 #ifdef CONFIG_BLK_DEV_INITRD
@@ -351,13 +360,48 @@
 }
 
 /*
+ * To probe the Sandpoint type, we need to check for a connection between GPIO
+ * pins 6 and 7 on the NS87308 SuperIO.
+ */
+static void __init sandpoint_probe_type(void)
+{
+	u8 x;
+	/* First, ensure that the GPIO pins are enabled. */
+	SANDPOINT_87308_SELECT_DEV(0x07); /* Select GPIO logical device */
+	SANDPOINT_87308_CFG_OUTB(0x60, 0x07); /* Base address 0x700 */
+	SANDPOINT_87308_CFG_OUTB(0x61, 0x00);
+	SANDPOINT_87308_CFG_OUTB(0x30, 0x01); /* Enable */
+
+	/* Now, set pin 7 to output and pin 6 to input. */
+	outb((inb(0x701) | 0x80) & 0xbf, 0x701);
+	/* Set push-pull output */
+	outb(inb(0x702) | 0x80, 0x702);
+	/* Set pull-up on input */
+	outb(inb(0x703) | 0x40, 0x703);
+	/* Set output high and check */
+	x = inb(0x700);
+	outb(x | 0x80, 0x700);
+	x = inb(0x700);
+	sandpoint_is_x2 = ! (x & 0x40);
+	if (ppc_md.progress && sandpoint_is_x2)
+		ppc_md.progress("High output says X2", 0);
+	/* Set output low and check */
+	outb(x & 0x7f, 0x700);
+	sandpoint_is_x2 |= inb(0x700) & 0x40;
+	if (ppc_md.progress && sandpoint_is_x2)
+		ppc_md.progress("Low output says X2", 0);
+	if (ppc_md.progress && ! sandpoint_is_x2)
+		ppc_md.progress("Sandpoint is X3", 0);
+}
+
+/*
  * Fix IDE interrupts.
  */
 static int __init
 sandpoint_fix_winbond_83553(void)
 {
-	/* Make all 8259 interrupt level sensitive */
-	outb(0xf8, 0x4d0);
+	/* Make some 8259 interrupt level sensitive */
+	outb(0xe0, 0x4d0);
 	outb(0xde, 0x4d1);
 
 	return 0;
@@ -430,7 +474,7 @@
 	OpenPIC_NumInitSenses = sizeof(sandpoint_openpic_initsenses);
 
 	mpc10x_set_openpic();
-	openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",
+	openpic_hookup_cascade(sandpoint_is_x2 ? 17 : NUM_8259_INTERRUPTS, "82c59 cascade",
 			i8259_irq);
 
 	/*
@@ -531,7 +575,7 @@
 static void
 sandpoint_ide_probe(void)
 {
-	struct pci_dev *pdev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	struct pci_dev *pdev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 			PCI_DEVICE_ID_WINBOND_82C105, NULL);
 
 	if (pdev) {
@@ -540,6 +584,7 @@
 		sandpoint_ide_ctl_regbase[0]=pdev->resource[1].start;
 		sandpoint_ide_ctl_regbase[1]=pdev->resource[3].start;
 		sandpoint_idedma_regbase=pdev->resource[4].start;
+		pci_dev_put(pdev);
 	}
 
 	sandpoint_ide_ports_known = 1;
@@ -689,15 +734,11 @@
 	ppc_md.nvram_read_val = todc_mc146818_read_val;
 	ppc_md.nvram_write_val = todc_mc146818_write_val;
 
-#if defined(CONFIG_SERIAL_8250) && \
-	(defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG))
-	sandpoint_early_serial_map();
 #ifdef CONFIG_KGDB
 	ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
 #endif
 #ifdef CONFIG_SERIAL_TEXT_DEBUG
 	ppc_md.progress = gen550_progress;
-#endif
 #endif
 
 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
diff -Nru a/arch/ppc/platforms/sbc82xx.c b/arch/ppc/platforms/sbc82xx.c
--- a/arch/ppc/platforms/sbc82xx.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc/platforms/sbc82xx.c	2004-12-24 13:36:31 -08:00
@@ -142,10 +142,17 @@
 			return IRQ_HANDLED;
 		}
 	}
-	ppc_irq_dispatch_handler(regs, NR_SIU_INTS + irq);
+	__do_IRQ(NR_SIU_INTS + irq, regs);
 	return IRQ_HANDLED;
 }
 
+static struct irqaction sbc82xx_i8259_irqaction = {
+	.handler = sbc82xx_i8259_demux,
+	.flags = SA_INTERRUPT,
+	.mask = CPU_MASK_NONE,
+	.name = "i8259 demux",
+};
+
 void __init sbc82xx_init_IRQ(void)
 {
 	volatile memctl_cpm2_t *mc = &cpm2_immr->im_memctl;
@@ -186,8 +193,7 @@
 	sbc82xx_i8259_map[1] = sbc82xx_i8259_mask; /* Set interrupt mask */
 
 	/* Request cascade IRQ */
-	if (request_irq(SIU_INT_IRQ6, sbc82xx_i8259_demux, SA_INTERRUPT,
-			"i8259 demux", 0)) {
+	if (setup_irq(SIU_INT_IRQ6, &sbc82xx_i8259_irqaction)) {
 		printk("Installation of i8259 IRQ demultiplexer failed.\n");
 	}
 }
diff -Nru a/arch/ppc/platforms/tqm8xx.h b/arch/ppc/platforms/tqm8xx.h
--- a/arch/ppc/platforms/tqm8xx.h	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/platforms/tqm8xx.h	2004-12-24 13:37:19 -08:00
@@ -72,8 +72,6 @@
 #define	IDE0_INTERRUPT		13
 
 #ifdef CONFIG_IDE
-#define ide_request_irq(irq,hand,flg,dev,id)    \
-        request_8xxirq((irq),(hand),(flg),(dev),(id))
 #endif
 
 /*-----------------------------------------------------------------------
diff -Nru a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
--- a/arch/ppc/syslib/Makefile	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc/syslib/Makefile	2004-12-24 13:36:17 -08:00
@@ -14,13 +14,17 @@
 obj-$(CONFIG_440GP)		+= ibm440gp_common.o
 obj-$(CONFIG_440GX)		+= ibm440gx_common.o
 ifeq ($(CONFIG_4xx),y)
-obj-$(CONFIG_4xx)		+= ppc4xx_pic.o
+ifeq ($(CONFIG_VIRTEX_II_PRO),y)
+obj-$(CONFIG_40x)		+= xilinx_pic.o
+else
+obj-$(CONFIG_40x)		+= ppc4xx_pic.o
+endif
+obj-$(CONFIG_44x)		+= ppc4xx_pic.o
 obj-$(CONFIG_40x)		+= ppc4xx_setup.o
 obj-$(CONFIG_GEN_RTC)		+= todc_time.o
 obj-$(CONFIG_PPC4xx_DMA)	+= ppc4xx_dma.o
 obj-$(CONFIG_PPC4xx_EDMA)	+= ppc4xx_sgdma.o
 ifeq ($(CONFIG_40x),y)
-obj-$(CONFIG_KGDB)		+= ppc4xx_kgdb.o
 obj-$(CONFIG_PCI)		+= indirect_pci.o pci_auto.o ppc405_pci.o
 endif
 endif
@@ -47,7 +51,8 @@
 obj-$(CONFIG_MENF1)		+= todc_time.o i8259.o mpc10x_common.o \
 					pci_auto.o indirect_pci.o
 obj-$(CONFIG_MVME5100)		+= open_pic.o todc_time.o indirect_pci.o \
-					i8259.o pci_auto.o hawk_common.o
+					pci_auto.o hawk_common.o
+obj-$(CONFIG_MVME5100_IPMC761_PRESENT)	+= i8259.o
 obj-$(CONFIG_OCOTEA)		+= indirect_pci.o pci_auto.o todc_time.o
 obj-$(CONFIG_PAL4)		+= cpc700_pic.o
 obj-$(CONFIG_PCORE)		+= todc_time.o i8259.o pci_auto.o
diff -Nru a/arch/ppc/syslib/gen550.h b/arch/ppc/syslib/gen550.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc/syslib/gen550.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,16 @@
+/*
+ * arch/ppc/syslib/gen550.h
+ *
+ * gen550 prototypes
+ *
+ * Matt Porter <mporter@kernel.crashing.org>
+ *
+ * 2004 (c) MontaVista Software, Inc.  This file is licensed under
+ * the terms of the GNU General Public License version 2.  This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+extern void gen550_progress(char *, unsigned short);
+extern void gen550_init(int, struct uart_port *);
+extern void gen550_kgdb_map_scc(void);
diff -Nru a/arch/ppc/syslib/gen550_dbg.c b/arch/ppc/syslib/gen550_dbg.c
--- a/arch/ppc/syslib/gen550_dbg.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc/syslib/gen550_dbg.c	2004-12-24 13:36:48 -08:00
@@ -40,12 +40,12 @@
 
 unsigned long direct_inb(unsigned long addr)
 {
-	return readb(addr);
+	return readb((void __iomem *)addr);
 }
 
 void direct_outb(unsigned long addr, unsigned char val)
 {
-	writeb(val, addr);
+	writeb(val, (void __iomem *)addr);
 }
 
 unsigned long io_inb(unsigned long port)
diff -Nru a/arch/ppc/syslib/gen550_kgdb.c b/arch/ppc/syslib/gen550_kgdb.c
--- a/arch/ppc/syslib/gen550_kgdb.c	2004-12-24 13:36:47 -08:00
+++ b/arch/ppc/syslib/gen550_kgdb.c	2004-12-24 13:36:47 -08:00
@@ -9,9 +9,9 @@
  *
  * Adapted from ppc4xx_kgdb.c.
  *
- * Author: Matt Porter <mporter@mvista.com>
+ * Author: Matt Porter <mporter@kernel.crashing.org>
  *
- * 2002-2003 (c) MontaVista Software, Inc.  This file is licensed under
+ * 2002-2004 (c) MontaVista Software, Inc.  This file is licensed under
  * the terms of the GNU General Public License version 2.  This program
  * is licensed "as is" without any warranty of any kind, whether express
  * or implied.
@@ -80,5 +80,7 @@
 gen550_kgdb_map_scc(void)
 {
 	printk(KERN_DEBUG "kgdb init\n");
+	if (ppc_md.early_serial_map)
+		ppc_md.early_serial_map();
 	kgdb_debugport = serial_init(KGDB_PORT, NULL);
 }
diff -Nru a/arch/ppc/syslib/i8259.c b/arch/ppc/syslib/i8259.c
--- a/arch/ppc/syslib/i8259.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc/syslib/i8259.c	2004-12-24 13:36:48 -08:00
@@ -151,6 +151,13 @@
 	"8259 edge control", 0x4d0, 0x4d1, IORESOURCE_BUSY
 };
 
+static struct irqaction i8259_irqaction = {
+	.handler = no_action,
+	.flags = SA_INTERRUPT,
+	.mask = CPU_MASK_NONE,
+	.name = "82c59 secondary cascade",
+};
+
 /*
  * i8259_init()
  * intack_addr - PCI interrupt acknowledge (real) address which will return
@@ -185,8 +192,7 @@
 	spin_unlock_irqrestore(&i8259_lock, flags);
 
 	/* reserve our resources */
-	request_irq( i8259_pic_irq_offset + 2, no_action, SA_INTERRUPT,
-				"82c59 secondary cascade", NULL );
+	setup_irq( i8259_pic_irq_offset + 2, &i8259_irqaction);
 	request_resource(&ioport_resource, &pic1_iores);
 	request_resource(&ioport_resource, &pic2_iores);
 	request_resource(&ioport_resource, &pic_edgectrl_iores);
diff -Nru a/arch/ppc/syslib/ibm440gx_common.c b/arch/ppc/syslib/ibm440gx_common.c
--- a/arch/ppc/syslib/ibm440gx_common.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc/syslib/ibm440gx_common.c	2004-12-24 13:37:19 -08:00
@@ -4,7 +4,7 @@
  * PPC440GX system library
  *
  * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
- * Copyright (c) 2003 Zultys Technologies
+ * Copyright (c) 2003, 2004 Zultys Technologies
  *
  * 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
@@ -14,6 +14,7 @@
  */
 #include <linux/config.h>
 #include <linux/kernel.h>
+#include <linux/interrupt.h>
 #include <asm/ibm44x.h>
 #include <asm/mmu.h>
 #include <asm/processor.h>
@@ -97,10 +98,51 @@
 		p->uart1 = p->plb / __fix_zero(uart1 & 0xff, 256);
 }
 
-/* Enable L2 cache (call with IRQs disabled) */
+/* Issue L2C diagnostic command */
+static inline u32 l2c_diag(u32 addr)
+{
+	mtdcr(DCRN_L2C0_ADDR, addr);
+	mtdcr(DCRN_L2C0_CMD, L2C_CMD_DIAG);
+	while (!(mfdcr(DCRN_L2C0_SR) & L2C_SR_CC)) ;
+	return mfdcr(DCRN_L2C0_DATA);
+}
+
+static irqreturn_t l2c_error_handler(int irq, void* dev, struct pt_regs* regs)
+{
+	u32 sr = mfdcr(DCRN_L2C0_SR);
+	if (sr & L2C_SR_CPE){
+		/* Read cache trapped address */
+		u32 addr = l2c_diag(0x42000000);
+		printk(KERN_EMERG "L2C: Cache Parity Error, addr[16:26] = 0x%08x\n", addr);
+	}
+	if (sr & L2C_SR_TPE){
+		/* Read tag trapped address */
+		u32 addr = l2c_diag(0x82000000) >> 16;
+		printk(KERN_EMERG "L2C: Tag Parity Error, addr[16:26] = 0x%08x\n", addr);
+	}
+
+	/* Clear parity errors */
+	if (sr & (L2C_SR_CPE | L2C_SR_TPE)){
+		mtdcr(DCRN_L2C0_ADDR, 0);
+		mtdcr(DCRN_L2C0_CMD, L2C_CMD_CCP | L2C_CMD_CTE);
+	} else
+		printk(KERN_EMERG "L2C: LRU error\n");
+
+	return IRQ_HANDLED;
+}
+
+/* Enable L2 cache */
 void __init ibm440gx_l2c_enable(void){
 	u32 r;
+	unsigned long flags;
+
+	/* Install error handler */
+	if (request_irq(87, l2c_error_handler, SA_INTERRUPT, "L2C", 0) < 0){
+		printk(KERN_ERR "Cannot install L2C error handler, cache is not enabled\n");
+		return;
+	}
 
+	local_irq_save(flags);
 	asm volatile ("sync" ::: "memory");
 
 	/* Disable SRAM */
@@ -137,20 +179,22 @@
 
 	/* Enable ICU/DCU ports */
 	r = mfdcr(DCRN_L2C0_CFG);
-	r &= ~(L2C_CFG_DCW_MASK | L2C_CFG_CPIM | L2C_CFG_TPIM | L2C_CFG_LIM
-		| L2C_CFG_PMUX_MASK | L2C_CFG_PMIM | L2C_CFG_TPEI | L2C_CFG_CPEI
-		| L2C_CFG_NAM | L2C_CFG_NBRM);
+	r &= ~(L2C_CFG_DCW_MASK | L2C_CFG_PMUX_MASK | L2C_CFG_PMIM | L2C_CFG_TPEI
+		| L2C_CFG_CPEI | L2C_CFG_NAM | L2C_CFG_NBRM);
 	r |= L2C_CFG_ICU | L2C_CFG_DCU | L2C_CFG_TPC | L2C_CFG_CPC | L2C_CFG_FRAN
-		| L2C_CFG_SMCM;
+		| L2C_CFG_CPIM | L2C_CFG_TPIM | L2C_CFG_LIM | L2C_CFG_SMCM;
 	mtdcr(DCRN_L2C0_CFG, r);
 
 	asm volatile ("sync; isync" ::: "memory");
+	local_irq_restore(flags);
 }
 
-/* Disable L2 cache (call with IRQs disabled) */
+/* Disable L2 cache */
 void __init ibm440gx_l2c_disable(void){
 	u32 r;
+	unsigned long flags;
 
+	local_irq_save(flags);
 	asm volatile ("sync" ::: "memory");
 
 	/* Disable L2C mode */
@@ -169,6 +213,20 @@
 	      SRAM_SBCR_BAS3 | SRAM_SBCR_BS_64KB | SRAM_SBCR_BU_RW);
 
 	asm volatile ("sync; isync" ::: "memory");
+	local_irq_restore(flags);
+}
+
+void __init ibm440gx_l2c_setup(struct ibm44x_clocks* p)
+{
+	/* Disable L2C on rev.A, rev.B and 800MHz version of rev.C,
+	   enable it on all other revisions
+	 */
+	u32 pvr = mfspr(PVR);
+	if (pvr == PVR_440GX_RA || pvr == PVR_440GX_RB ||
+	    (pvr == PVR_440GX_RC && p->cpu > 667000000))
+		ibm440gx_l2c_disable();
+	else
+		ibm440gx_l2c_enable();
 }
 
 int __init ibm440gx_get_eth_grp(void)
diff -Nru a/arch/ppc/syslib/ibm440gx_common.h b/arch/ppc/syslib/ibm440gx_common.h
--- a/arch/ppc/syslib/ibm440gx_common.h	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc/syslib/ibm440gx_common.h	2004-12-24 13:36:16 -08:00
@@ -4,7 +4,7 @@
  * PPC440GX system library
  *
  * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
- * Copyright (c) 2003 Zultys Technologies
+ * Copyright (c) 2003, 2004 Zultys Technologies
  *
  * 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
@@ -36,6 +36,9 @@
 
 /* Disable L2 cache */
 void ibm440gx_l2c_disable(void) __init;
+
+/* Enable/disable L2 cache for a particular chip revision */
+void ibm440gx_l2c_setup(struct ibm44x_clocks*) __init;
 
 /* Get Ethernet Group */
 int ibm440gx_get_eth_grp(void) __init;
diff -Nru a/arch/ppc/syslib/ibm44x_common.c b/arch/ppc/syslib/ibm44x_common.c
--- a/arch/ppc/syslib/ibm44x_common.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc/syslib/ibm44x_common.c	2004-12-24 13:36:48 -08:00
@@ -3,8 +3,8 @@
  *
  * PPC44x system library
  *
- * Matt Porter <mporter@mvista.com>
- * Copyright 2002-2003 MontaVista Software Inc.
+ * Matt Porter <mporter@kernel.crashing.org>
+ * Copyright 2002-2004 MontaVista Software Inc.
  *
  * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  * Copyright (c) 2003, 2004 Zultys Technologies
@@ -16,15 +16,18 @@
  *
  */
 #include <linux/config.h>
+#include <linux/time.h>
 #include <linux/types.h>
 #include <linux/serial.h>
 
-#include <asm/param.h>
 #include <asm/ibm44x.h>
 #include <asm/mmu.h>
 #include <asm/machdep.h>
 #include <asm/time.h>
 #include <asm/ppc4xx_pic.h>
+#include <asm/param.h>
+
+#include <syslib/gen550.h>
 
 phys_addr_t fixup_bigphys_addr(phys_addr_t addr, phys_addr_t size)
 {
@@ -149,44 +152,6 @@
 		irq_desc[i].handler = ppc4xx_pic;
 }
 
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-#include <linux/serialP.h>
-#include <linux/serial_reg.h>
-#include <asm/serial.h>
-
-static struct serial_state rs_table[RS_TABLE_SIZE] = {
-	SERIAL_PORT_DFNS	/* Defined in <asm/serial.h> */
-};
-
-static void ibm44x_progress(char *s, unsigned short hex)
-{
-	volatile char c;
-	volatile unsigned long com_port;
-	u16 shift;
-
-	com_port = (unsigned long)rs_table[0].iomem_base;
-	shift = rs_table[0].iomem_reg_shift;
-
-	while ((c = *s++) != 0) {
-		while ((*((volatile unsigned char *)com_port +
-				(UART_LSR << shift)) & UART_LSR_THRE) == 0)
-			;
-		*(volatile unsigned char *)com_port = c;
-
-	}
-
-	/* Send LF/CR to pretty up output */
-	while ((*((volatile unsigned char *)com_port +
-		(UART_LSR << shift)) & UART_LSR_THRE) == 0)
-		;
-	*(volatile unsigned char *)com_port = '\r';
-	while ((*((volatile unsigned char *)com_port +
-		(UART_LSR << shift)) & UART_LSR_THRE) == 0)
-		;
-	*(volatile unsigned char *)com_port = '\n';
-}
-#endif /* CONFIG_SERIAL_TEXT_DEBUG */
-
 void __init ibm44x_platform_init(void)
 {
 	ppc_md.init_IRQ = ibm44x_init_irq;
@@ -196,7 +161,22 @@
 	ppc_md.halt = ibm44x_halt;
 
 #ifdef CONFIG_SERIAL_TEXT_DEBUG
-	ppc_md.progress = ibm44x_progress;
+	ppc_md.progress = gen550_progress;
 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
+#ifdef CONFIG_KGDB
+	ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
+#endif
+
+	/*
+	 * The Abatron BDI JTAG debugger does not tolerate others
+	 * mucking with the debug registers.
+	 */
+#if !defined(CONFIG_BDI_SWITCH)
+	/* Enable internal debug mode */
+        mtspr(SPRN_DBCR0, (DBCR0_IDM));
+
+	/* Clear any residual debug events */
+	mtspr(SPRN_DBSR, 0xffffffff);
+#endif
 }
 
diff -Nru a/arch/ppc/syslib/indirect_pci.c b/arch/ppc/syslib/indirect_pci.c
--- a/arch/ppc/syslib/indirect_pci.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc/syslib/indirect_pci.c	2004-12-24 13:36:18 -08:00
@@ -112,15 +112,24 @@
 };
 
 void __init
+setup_indirect_pci_nomap(struct pci_controller* hose, u32 cfg_addr,
+	u32 cfg_data)
+{
+	hose->cfg_addr = (unsigned int *)cfg_addr;
+	hose->cfg_data = (unsigned char *)cfg_data;
+	hose->ops = &indirect_pci_ops;
+}
+
+void __init
 setup_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data)
 {
 	unsigned long base = cfg_addr & PAGE_MASK;
 	char *mbase;
 
 	mbase = ioremap(base, PAGE_SIZE);
-	hose->cfg_addr = (unsigned int *)(mbase + (cfg_addr & ~PAGE_MASK));
+	cfg_addr = (u32)(mbase + (cfg_addr & ~PAGE_MASK));
 	if ((cfg_data & PAGE_MASK) != base)
 		mbase = ioremap(cfg_data & PAGE_MASK, PAGE_SIZE);
-	hose->cfg_data = (unsigned char *)(mbase + (cfg_data & ~PAGE_MASK));
-	hose->ops = &indirect_pci_ops;
+	cfg_data = (u32)(mbase + (cfg_data & ~PAGE_MASK));
+	setup_indirect_pci_nomap(hose, cfg_addr, cfg_data);
 }
diff -Nru a/arch/ppc/syslib/m8260_setup.c b/arch/ppc/syslib/m8260_setup.c
--- a/arch/ppc/syslib/m8260_setup.c	2004-12-24 13:36:49 -08:00
+++ b/arch/ppc/syslib/m8260_setup.c	2004-12-24 13:36:49 -08:00
@@ -16,6 +16,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/initrd.h>
+#include <linux/root_dev.h>
 #include <linux/seq_file.h>
 #include <linux/irq.h>
 
@@ -241,9 +242,6 @@
 		strcpy(cmd_line, (char *)(r6+KERNELBASE));
 	}
 
-	/* Call back for board-specific settings. */
-	m82xx_board_init();
-
 	ppc_md.setup_arch		= m8260_setup_arch;
 	ppc_md.show_cpuinfo		= m8260_show_cpuinfo;
 	ppc_md.init_IRQ			= m8260_init_IRQ;
@@ -259,4 +257,7 @@
 
 	ppc_md.find_end_of_memory	= m8260_find_end_of_memory;
 	ppc_md.setup_io_mappings	= m8260_map_io;
+
+	/* Call back for board-specific settings and overrides. */
+	m82xx_board_init();
 }
diff -Nru a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c
--- a/arch/ppc/syslib/m8xx_setup.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc/syslib/m8xx_setup.c	2004-12-24 13:36:48 -08:00
@@ -57,8 +57,10 @@
 extern void m8xx_ide_init(void);
 
 extern unsigned long find_available_memory(void);
-extern void m8xx_cpm_reset(uint);
+extern void m8xx_cpm_reset(uint cpm_page);
+extern void m8xx_wdt_handler_install(bd_t *bp);
 extern void rpxfb_alloc_pages(void);
+extern void cpm_interrupt_init(void);
 
 void __attribute__ ((weak))
 board_init(void)
@@ -123,11 +125,19 @@
 }
 
 /* A place holder for time base interrupts, if they are ever enabled. */
-void timebase_interrupt(int irq, void * dev, struct pt_regs * regs)
+irqreturn_t timebase_interrupt(int irq, void * dev, struct pt_regs * regs)
 {
 	printk ("timebase_interrupt()\n");
+
+	return IRQ_HANDLED;
 }
 
+static struct irqaction tbint_irqaction = {
+	.handler = timebase_interrupt,
+	.mask = CPU_MASK_NONE,
+	.name = "tbint",
+};
+
 /* The decrementer counts at the system (internal) clock frequency divided by
  * sixteen, or external oscillator divided by four.  We force the processor
  * to use system clock divided by sixteen.
@@ -192,8 +202,15 @@
 				((mk_int_int_mask(DEC_INTERRUPT) << 8) |
 					 (TBSCR_TBF | TBSCR_TBE));
 
-	if (request_8xxirq(DEC_INTERRUPT, timebase_interrupt, 0, "tbint", NULL) != 0)
+	if (setup_irq(DEC_INTERRUPT, &tbint_irqaction))
 		panic("Could not allocate timer IRQ!");
+
+#ifdef CONFIG_8xx_WDT
+	/* Install watchdog timer handler early because it might be
+	 * already enabled by the bootloader
+	 */
+	m8xx_wdt_handler_install(binfo);
+#endif
 }
 
 /* The RTC on the MPC8xx is an internal register.
@@ -261,6 +278,14 @@
 	return 0;
 }
 
+#ifdef CONFIG_PCI
+static struct irqaction mbx_i8259_irqaction = {
+	.handler = mbx_i8259_action,
+	.mask = CPU_MASK_NONE,
+	.name = "i8259 cascade",
+};
+#endif
+
 /* Initialize the internal interrupt controller.  The number of
  * interrupts supported can vary with the processor type, and the
  * 82xx family can have up to 64.
@@ -271,25 +296,26 @@
 m8xx_init_IRQ(void)
 {
 	int i;
-	void cpm_interrupt_init(void);
 
-        for ( i = 0 ; i < NR_SIU_INTS ; i++ )
-                irq_desc[i].handler = &ppc8xx_pic;
+	for (i = SIU_IRQ_OFFSET ; i < SIU_IRQ_OFFSET + NR_SIU_INTS ; i++)
+		irq_desc[i].handler = &ppc8xx_pic;
 
-	/* We could probably incorporate the CPM into the multilevel
-	 * interrupt structure.
-	 */
 	cpm_interrupt_init();
-        unmask_irq(CPM_INTERRUPT);
 
 #if defined(CONFIG_PCI)
-        for ( i = NR_SIU_INTS ; i < (NR_SIU_INTS + NR_8259_INTS) ; i++ )
-                irq_desc[i].handler = &i8259_pic;
-        i8259_pic.irq_offset = NR_SIU_INTS;
-        i8259_init();
-        request_8xxirq(ISA_BRIDGE_INT, mbx_i8259_action, 0, "8259 cascade", NULL);
-        enable_irq(ISA_BRIDGE_INT);
-#endif
+	for (i = I8259_IRQ_OFFSET ; i < I8259_IRQ_OFFSET + NR_8259_INTS ; i++)
+		irq_desc[i].handler = &i8259_pic;
+
+	i8259_pic_irq_offset = I8259_IRQ_OFFSET;
+	i8259_init(0);
+
+	/* The i8259 cascade interrupt must be level sensitive. */
+	((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel &=
+		~(0x80000000 >> ISA_BRIDGE_INT);
+
+	if (setup_irq(ISA_BRIDGE_INT, &mbx_i8259_irqaction))
+		enable_irq(ISA_BRIDGE_INT);
+#endif	/* CONFIG_PCI */
 }
 
 /* -------------------------------------------------------------------- */
@@ -340,7 +366,7 @@
 	io_block_mapping(_IO_BASE,_IO_BASE,_IO_BASE_SIZE, _PAGE_IO);
 #endif
 #endif
-#ifdef CONFIG_HTDMSOUND
+#if defined(CONFIG_HTDMSOUND) || defined(CONFIG_RPXTOUCH) || defined(CONFIG_FB_RPX)
 	io_block_mapping(HIOX_CSR_ADDR, HIOX_CSR_ADDR, HIOX_CSR_SIZE, _PAGE_IO);
 #endif
 #ifdef CONFIG_FADS
@@ -348,6 +374,9 @@
 #endif
 #ifdef CONFIG_PCI
         io_block_mapping(PCI_CSR_ADDR, PCI_CSR_ADDR, PCI_CSR_SIZE, _PAGE_IO);
+#endif
+#if defined(CONFIG_NETTA)
+	io_block_mapping(_IO_BASE,_IO_BASE,_IO_BASE_SIZE, _PAGE_IO);
 #endif
 }
 
diff -Nru a/arch/ppc/syslib/mpc10x_common.c b/arch/ppc/syslib/mpc10x_common.c
--- a/arch/ppc/syslib/mpc10x_common.c	2004-12-24 13:36:19 -08:00
+++ b/arch/ppc/syslib/mpc10x_common.c	2004-12-24 13:36:19 -08:00
@@ -43,7 +43,7 @@
 
 #ifdef CONFIG_MPC10X_OPENPIC
 #ifdef CONFIG_EPIC_SERIAL_MODE
-#define EPIC_IRQ_BASE 16
+#define EPIC_IRQ_BASE (epic_serial_mode ? 16 : 5)
 #else
 #define EPIC_IRQ_BASE 5
 #endif
@@ -69,20 +69,16 @@
 	.vendor		= OCP_VENDOR_MOTOROLA,
 	.function	= OCP_FUNC_IIC,
 	.index		= 0,
-	.irq		= MPC10X_I2C_IRQ,
 	.additions	= &mpc10x_i2c_data
 };
 
 static struct ocp_def mpc10x_dma_ocp[2] = {
 {	.vendor		= OCP_VENDOR_MOTOROLA,
 	.function	= OCP_FUNC_DMA,
-	.index		= 0,
-	.irq		= MPC10X_DMA0_IRQ
-},
+	.index		= 0 },
 {	.vendor		= OCP_VENDOR_MOTOROLA,
 	.function	= OCP_FUNC_DMA,
-	.index		= 1,
-	.irq		= MPC10X_DMA1_IRQ }
+	.index		= 1 }
 };
 
 /* Set resources to match bridge memory map */
@@ -292,12 +288,15 @@
 				MPC10X_EUMB_EPIC_SIZE);
 #endif
 		mpc10x_i2c_ocp.paddr = phys_eumb_base + MPC10X_EUMB_I2C_OFFSET;
+		mpc10x_i2c_ocp.irq = MPC10X_I2C_IRQ;
 		ocp_add_one_device(&mpc10x_i2c_ocp);
 		mpc10x_dma_ocp[0].paddr = phys_eumb_base +
 					MPC10X_EUMB_DMA_OFFSET + 0x100;
+		mpc10x_dma_ocp[0].irq = MPC10X_DMA0_IRQ;
 		ocp_add_one_device(&mpc10x_dma_ocp[0]);
 		mpc10x_dma_ocp[1].paddr = phys_eumb_base +
 					MPC10X_EUMB_DMA_OFFSET + 0x200;
+		mpc10x_dma_ocp[1].irq = MPC10X_DMA1_IRQ;
 		ocp_add_one_device(&mpc10x_dma_ocp[1]);
 	}
 
diff -Nru a/arch/ppc/syslib/mpc52xx_setup.c b/arch/ppc/syslib/mpc52xx_setup.c
--- a/arch/ppc/syslib/mpc52xx_setup.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc/syslib/mpc52xx_setup.c	2004-12-24 13:37:18 -08:00
@@ -19,6 +19,7 @@
 
 #include <linux/config.h>
 
+#include <asm/io.h>
 #include <asm/time.h>
 #include <asm/mpc52xx.h>
 #include <asm/mpc52xx_psc.h>
diff -Nru a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
--- a/arch/ppc/syslib/open_pic.c	2004-12-24 13:36:59 -08:00
+++ b/arch/ppc/syslib/open_pic.c	2004-12-24 13:36:59 -08:00
@@ -53,7 +53,6 @@
 
 /* Global Operations */
 static void openpic_disable_8259_pass_through(void);
-static void openpic_set_priority(u_int pri);
 static void openpic_set_spurious(u_int vector);
 
 #ifdef CONFIG_SMP
@@ -261,6 +260,9 @@
 #endif /* CONFIG_SMP */
 
 #ifdef CONFIG_EPIC_SERIAL_MODE
+/* On platforms that may use EPIC serial mode, the default is enabled. */
+int epic_serial_mode = 1;
+
 static void __init openpic_eicr_set_clk(u_int clkval)
 {
 	openpic_writefield(&OpenPIC->Global.Global_Configuration1,
@@ -415,8 +417,10 @@
 	openpic_set_spurious(OPENPIC_VEC_SPURIOUS);
 	openpic_disable_8259_pass_through();
 #ifdef CONFIG_EPIC_SERIAL_MODE
-	openpic_eicr_set_clk(7);	/* Slowest value until we know better */
-	openpic_enable_sie();
+	if (epic_serial_mode) {
+		openpic_eicr_set_clk(7);	/* Slowest value until we know better */
+		openpic_enable_sie();
+	}
 #endif
 	openpic_set_priority(0);
 
@@ -472,7 +476,7 @@
 }
 #endif /* notused */
 
-static void __init openpic_set_priority(u_int pri)
+void openpic_set_priority(u_int pri)
 {
 	DECL_THIS_CPU;
 
@@ -681,13 +685,21 @@
 /*
  * Hookup a cascade to the OpenPIC.
  */
+
+static struct irqaction openpic_cascade_irqaction = {
+	.handler = no_action,
+	.flags = SA_INTERRUPT,
+	.mask = CPU_MASK_NONE,
+};
+
 void __init
 openpic_hookup_cascade(u_int irq, char *name,
 	int (*cascade_fn)(struct pt_regs *))
 {
 	openpic_cascade_irq = irq;
 	openpic_cascade_fn = cascade_fn;
-	if (request_irq(irq, no_action, SA_INTERRUPT, name, NULL))
+
+	if (setup_irq(irq, &openpic_cascade_irqaction))
 		printk("Unable to get OpenPIC IRQ %d for cascade\n",
 				irq - open_pic_irq_offset);
 }
@@ -942,6 +954,8 @@
 		return 0;
 	}
 
+ 	openpic_set_priority(0xf);
+
 	open_pic.enable = openpic_cached_enable_irq;
 	open_pic.disable = openpic_cached_disable_irq;
 
@@ -1014,6 +1028,8 @@
 
 	open_pic.enable = openpic_enable_irq;
 	open_pic.disable = openpic_disable_irq;
+
+ 	openpic_set_priority(0);
 
 	spin_unlock_irqrestore(&openpic_setup_lock, flags);
 
diff -Nru a/arch/ppc/syslib/ppc405_pci.c b/arch/ppc/syslib/ppc405_pci.c
--- a/arch/ppc/syslib/ppc405_pci.c	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc/syslib/ppc405_pci.c	2004-12-24 13:37:01 -08:00
@@ -82,8 +82,8 @@
 	unsigned int tmp_addr;
 	unsigned int tmp_size;
 	unsigned int reg_index;
-	unsigned int new_pmm_max;
-	unsigned int new_pmm_min;
+	unsigned int new_pmm_max = 0;
+	unsigned int new_pmm_min = 0;
 
 	isa_io_base = 0;
 	isa_mem_base = 0;
diff -Nru a/arch/ppc/syslib/ppc4xx_dma.c b/arch/ppc/syslib/ppc4xx_dma.c
--- a/arch/ppc/syslib/ppc4xx_dma.c	2004-12-24 13:37:32 -08:00
+++ b/arch/ppc/syslib/ppc4xx_dma.c	2004-12-24 13:37:32 -08:00
@@ -466,7 +466,7 @@
 
 	/* clear all polarity signals and then "or" in new signal levels */
 	polarity &= ~GET_DMA_POLARITY(dmanr);
-	polarity |= p_dma_ch->polarity;
+	polarity |= p_init->polarity;
 #if DCRN_POL > 0
 	mtdcr(DCRN_POL, polarity);
 #endif
diff -Nru a/arch/ppc/syslib/ppc4xx_setup.c b/arch/ppc/syslib/ppc4xx_setup.c
--- a/arch/ppc/syslib/ppc4xx_setup.c	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc/syslib/ppc4xx_setup.c	2004-12-24 13:36:16 -08:00
@@ -42,6 +42,8 @@
 #include <asm/pci-bridge.h>
 #include <asm/bootinfo.h>
 
+#include <syslib/gen550.h>
+
 /* Function Prototypes */
 extern void abort(void);
 extern void ppc4xx_find_bridges(void);
@@ -56,8 +58,16 @@
 void __init
 ppc4xx_setup_arch(void)
 {
-	/* Setup PCI host bridges */
+#if !defined(CONFIG_BDI_SWITCH)
+	/*
+	 * The Abatron BDI JTAG debugger does not tolerate others
+	 * mucking with the debug registers.
+	 */
+        mtspr(SPRN_DBCR0, (DBCR0_IDM));
+	mtspr(SPRN_DBSR, 0xffffffff);
+#endif
 
+	/* Setup PCI host bridges */
 #ifdef CONFIG_PCI
 	ppc4xx_find_bridges();
 #endif
@@ -189,34 +199,6 @@
 	/* Set the PIT reload value and just let it run. */
 	mtspr(SPRN_PIT, tb_ticks_per_jiffy);
 }
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-
-/* We assume that the UART has already been initialized by the
-   firmware or the boot loader */
-static void
-serial_putc(u8 * com_port, unsigned char c)
-{
-	while ((readb(com_port + (UART_LSR)) & UART_LSR_THRE) == 0) ;
-	writeb(c, com_port);
-}
-
-static void
-ppc4xx_progress(char *s, unsigned short hex)
-{
-	char c;
-#ifdef SERIAL_DEBUG_IO_BASE
-	u8 *com_port = (u8 *) SERIAL_DEBUG_IO_BASE;
-
-	while ((c = *s++) != '\0') {
-		serial_putc(com_port, c);
-	}
-	serial_putc(com_port, '\r');
-	serial_putc(com_port, '\n');
-#else
-	printk("%s\r\n");
-#endif
-}
-#endif				/* CONFIG_SERIAL_TEXT_DEBUG */
 
 /*
  * IDE stuff.
@@ -319,13 +301,9 @@
 	ppc_md.setup_io_mappings = ppc4xx_map_io;
 
 #ifdef CONFIG_SERIAL_TEXT_DEBUG
-	ppc_md.progress = ppc4xx_progress;
+	ppc_md.progress = gen550_progress;
 #endif
 
-/*
-**   m8xx_setup.c, prep_setup.c use
-**     defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-*/
 #if defined(CONFIG_PCI) && defined(CONFIG_IDE)
 	ppc_ide_md.ide_init_hwif = ppc4xx_ide_init_hwif_ports;
 #endif /* defined(CONFIG_PCI) && defined(CONFIG_IDE) */
diff -Nru a/arch/ppc/syslib/ppc8xx_pic.c b/arch/ppc/syslib/ppc8xx_pic.c
--- a/arch/ppc/syslib/ppc8xx_pic.c	2004-12-24 13:36:35 -08:00
+++ b/arch/ppc/syslib/ppc8xx_pic.c	2004-12-24 13:36:35 -08:00
@@ -4,11 +4,14 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/signal.h>
+#include <linux/interrupt.h>
 #include <asm/irq.h>
 #include <asm/8xx_immap.h>
 #include <asm/mpc8xx.h>
 #include "ppc8xx_pic.h"
 
+extern int cpm_get_irq(struct pt_regs *regs);
+
 /* The 8xx internal interrupt controller.  It is usually
  * the only interrupt controller.  Some boards, like the MBX and
  * Sandpoint have the 8259 as a secondary controller.  Depending
@@ -72,46 +75,13 @@
 }
 
 struct hw_interrupt_type ppc8xx_pic = {
-	" 8xx SIU  ",
-	NULL,
-	NULL,
-	m8xx_unmask_irq,
-	m8xx_mask_irq,
-	m8xx_mask_and_ack,
-	m8xx_end_irq,
-	0
+	.typename = " 8xx SIU  ",
+	.enable = m8xx_unmask_irq,
+	.disable = m8xx_mask_irq,
+	.ack = m8xx_mask_and_ack,
+	.end = m8xx_end_irq,
 };
 
-#if 0
-void
-m8xx_do_IRQ(struct pt_regs *regs,
-	   int            cpu)
-{
-	int irq;
-        unsigned long bits = 0;
-
-        /* For MPC8xx, read the SIVEC register and shift the bits down
-         * to get the irq number.         */
-        bits = ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sivec;
-        irq = bits >> 26;
-#if 0
-        irq += ppc8xx_pic.irq_offset;
-#endif
-        bits = 1UL << irq;
-
-	if (irq < 0) {
-		printk(KERN_DEBUG "Bogus interrupt %d from PC = %lx\n",
-		       irq, regs->nip);
-		ppc_spurious_interrupts++;
-	}
-	else {
-                ppc_irq_dispatch_handler( regs, irq );
-	}
-
-}
-#endif
-
-
 /*
  * We either return a valid interrupt or -1 if there is nothing pending
  */
@@ -129,73 +99,32 @@
 	 * When we read the sivec without an interrupt to process, we will
 	 * get back SIU_LEVEL7.  In this case, return -1
 	 */
-	if (irq == SIU_LEVEL7)
-		return -1;
+        if (irq == CPM_INTERRUPT)
+        	irq = CPM_IRQ_OFFSET + cpm_get_irq(regs);
+#if defined(CONFIG_PCI)
+	else if (irq == ISA_BRIDGE_INT) {
+		int isa_irq;
+
+		if ((isa_irq = i8259_poll(regs)) >= 0)
+			irq = I8259_IRQ_OFFSET + isa_irq;
+	}
+#endif	/* CONFIG_PCI */
+	else if (irq == SIU_LEVEL7)
+		irq = -1;
 
 	return irq;
 }
 
-/* The MBX is the only 8xx board that uses the 8259.
-*/
 #if defined(CONFIG_MBX) && defined(CONFIG_PCI)
-void mbx_i8259_action(int cpl, void *dev_id, struct pt_regs *regs)
-{
-	int bits, irq;
-
-	/* A bug in the QSpan chip causes it to give us 0xff always
-	 * when doing a character read.  So read 32 bits and shift.
-	 * This doesn't seem to return useful values anyway, but
-	 * read it to make sure things are acked.
-	 * -- Cort
-	 */
-	irq = (inl(0x508) >> 24)&0xff;
-	if ( irq != 0xff ) printk("iack %d\n", irq);
-
-	outb(0x0C, 0x20);
-	irq = inb(0x20) & 7;
-	if (irq == 2)
-	{
-		outb(0x0C, 0xA0);
-		irq = inb(0xA0);
-		irq = (irq&7) + 8;
-	}
-	bits = 1UL << irq;
-	irq += i8259_pic.irq_offset;
-	ppc_irq_dispatch_handler( regs, irq );
-}
-#endif
-
 /* Only the MBX uses the external 8259.  This allows us to catch standard
  * drivers that may mess up the internal interrupt controllers, and also
  * allow them to run without modification on the MBX.
  */
-int request_irq(unsigned int irq,
-	irqreturn_t (*handler)(int, void *, struct pt_regs *),
-	unsigned long irqflags, const char * devname, void *dev_id)
+void mbx_i8259_action(int irq, void *dev_id, struct pt_regs *regs)
 {
-
-#if defined(CONFIG_MBX) && defined(CONFIG_PCI)
-	irq += i8259_pic.irq_offset;
-	return (request_8xxirq(irq, handler, irqflags, devname, dev_id));
-#else
-	/*
-	 * Handle other "well-known" interrupts, but panic on unknown ones.
+	/* This interrupt handler never actually gets called.  It is
+	 * installed only to unmask the 8259 cascade interrupt in the SIU
+	 * and to make the 8259 cascade interrupt visible in /proc/interrupts.
 	 */
-	switch (irq) {
-#ifdef	IDE0_INTERRUPT
-		case IDE0_INTERRUPT:	/* IDE0 */
-			return (request_8xxirq(irq, handler, irqflags, devname,
-						dev_id));
-#endif
-#ifdef	IDE1_INTERRUPT
-		case IDE1_INTERRUPT:	/* IDE1 */
-			return (request_8xxirq(irq, handler, irqflags, devname,
-						dev_id));
-#endif
-	default:			/* unknown IRQ -> panic */
-		panic("request_irq");
-	}
-#endif
 }
-
-EXPORT_SYMBOL(request_irq);
+#endif	/* CONFIG_PCI */
diff -Nru a/arch/ppc/syslib/prom.c b/arch/ppc/syslib/prom.c
--- a/arch/ppc/syslib/prom.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc/syslib/prom.c	2004-12-24 13:36:18 -08:00
@@ -19,6 +19,7 @@
 #include <linux/ioport.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
+#include <linux/bitops.h>
 
 #include <asm/sections.h>
 #include <asm/prom.h>
@@ -31,7 +32,6 @@
 #include <asm/system.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/btext.h>
 #include <asm/pci-bridge.h>
diff -Nru a/arch/ppc/syslib/prom_init.c b/arch/ppc/syslib/prom_init.c
--- a/arch/ppc/syslib/prom_init.c	2004-12-24 13:37:30 -08:00
+++ b/arch/ppc/syslib/prom_init.c	2004-12-24 13:37:30 -08:00
@@ -15,6 +15,7 @@
 #include <linux/ioport.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
+#include <linux/bitops.h>
 
 #include <asm/sections.h>
 #include <asm/prom.h>
@@ -26,7 +27,6 @@
 #include <asm/system.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
-#include <asm/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/btext.h>
 #include <asm/pci-bridge.h>
diff -Nru a/arch/ppc/syslib/todc_time.c b/arch/ppc/syslib/todc_time.c
--- a/arch/ppc/syslib/todc_time.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc/syslib/todc_time.c	2004-12-24 13:37:18 -08:00
@@ -18,6 +18,7 @@
 #include <linux/time.h>
 #include <linux/timex.h>
 #include <linux/bcd.h>
+#include <linux/mc146818rtc.h>
 
 #include <asm/machdep.h>
 #include <asm/io.h>
@@ -48,8 +49,6 @@
  * 	 					--MAG
  */
 
-extern spinlock_t	rtc_lock;
-
 /*
  * 'todc_info' should be initialized in your *_setup.c file to
  * point to a fully initialized 'todc_info_t' structure.
@@ -82,13 +81,13 @@
 u_char
 todc_direct_read_val(int addr)
 {
-	return readb(todc_info->nvram_data + addr);
+	return readb((void __iomem *)(todc_info->nvram_data + addr));
 }
 
 void
 todc_direct_write_val(int addr, unsigned char val)
 {
-	writeb(val, todc_info->nvram_data + addr);
+	writeb(val, (void __iomem *)(todc_info->nvram_data + addr));
 	return;
 }
 
diff -Nru a/arch/ppc/syslib/xilinx_pic.c b/arch/ppc/syslib/xilinx_pic.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc/syslib/xilinx_pic.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,142 @@
+/*
+ * arch/ppc/syslib/xilinx_pic.c
+ *
+ * Interrupt controller driver for Xilinx Virtex-II Pro.
+ *
+ * Author: MontaVista Software, Inc.
+ *         source@mvista.com
+ *
+ * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <asm/io.h>
+#include <asm/xparameters.h>
+#include <asm/ibm4xx.h>
+
+/* No one else should require these constants, so define them locally here. */
+#define ISR 0			/* Interrupt Status Register */
+#define IPR 1			/* Interrupt Pending Register */
+#define IER 2			/* Interrupt Enable Register */
+#define IAR 3			/* Interrupt Acknowledge Register */
+#define SIE 4			/* Set Interrupt Enable bits */
+#define CIE 5			/* Clear Interrupt Enable bits */
+#define IVR 6			/* Interrupt Vector Register */
+#define MER 7			/* Master Enable Register */
+
+#if XPAR_XINTC_USE_DCR == 0
+static volatile u32 *intc;
+#define intc_out_be32(addr, mask)     out_be32((addr), (mask))
+#define intc_in_be32(addr)            in_be32((addr))
+#else
+#define intc    XPAR_INTC_0_BASEADDR
+#define intc_out_be32(addr, mask)     mtdcr((addr), (mask))
+#define intc_in_be32(addr)            mfdcr((addr))
+#endif
+
+/* Global Variables */
+struct hw_interrupt_type *ppc4xx_pic;
+
+static void
+xilinx_intc_enable(unsigned int irq)
+{
+	unsigned long mask = (0x00000001 << (irq & 31));
+	pr_debug("enable: %d\n", irq);
+	intc_out_be32(intc + SIE, mask);
+}
+
+static void
+xilinx_intc_disable(unsigned int irq)
+{
+	unsigned long mask = (0x00000001 << (irq & 31));
+	pr_debug("disable: %d\n", irq);
+	intc_out_be32(intc + CIE, mask);
+}
+
+static void
+xilinx_intc_disable_and_ack(unsigned int irq)
+{
+	unsigned long mask = (0x00000001 << (irq & 31));
+	pr_debug("disable_and_ack: %d\n", irq);
+	intc_out_be32(intc + CIE, mask);
+	if (!(irq_desc[irq].status & IRQ_LEVEL))
+		intc_out_be32(intc + IAR, mask);	/* ack edge triggered intr */
+}
+
+static void
+xilinx_intc_end(unsigned int irq)
+{
+	unsigned long mask = (0x00000001 << (irq & 31));
+
+	pr_debug("end: %d\n", irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
+		intc_out_be32(intc + SIE, mask);
+		/* ack level sensitive intr */
+		if (irq_desc[irq].status & IRQ_LEVEL)
+			intc_out_be32(intc + IAR, mask);
+	}
+}
+
+static struct hw_interrupt_type xilinx_intc = {
+	"Xilinx Interrupt Controller",
+	NULL,
+	NULL,
+	xilinx_intc_enable,
+	xilinx_intc_disable,
+	xilinx_intc_disable_and_ack,
+	xilinx_intc_end,
+	0
+};
+
+int
+xilinx_pic_get_irq(struct pt_regs *regs)
+{
+	int irq;
+
+	/*
+	 * NOTE: This function is the one that needs to be improved in
+	 * order to handle multiple interrupt controllers.  It currently
+	 * is hardcoded to check for interrupts only on the first INTC.
+	 */
+
+	irq = intc_in_be32(intc + IVR);
+	if (irq != -1)
+		irq = irq;
+
+	pr_debug("get_irq: %d\n", irq);
+
+	return (irq);
+}
+
+void __init
+ppc4xx_pic_init(void)
+{
+#if XPAR_XINTC_USE_DCR == 0
+	intc = ioremap(XPAR_INTC_0_BASEADDR, 32);
+
+	printk(KERN_INFO "Xilinx INTC #0 at 0x%08lX mapped to 0x%08lX\n",
+	       (unsigned long) XPAR_INTC_0_BASEADDR, (unsigned long) intc);
+#else
+	printk(KERN_INFO "Xilinx INTC #0 at 0x%08lX (DCR)\n",
+	       (unsigned long) XPAR_INTC_0_BASEADDR);
+#endif
+
+	/*
+	 * Disable all external interrupts until they are
+	 * explicity requested.
+	 */
+	intc_out_be32(intc + IER, 0);
+
+	/* Acknowledge any pending interrupts just in case. */
+	intc_out_be32(intc + IAR, ~(u32) 0);
+
+	/* Turn on the Master Enable. */
+	intc_out_be32(intc + MER, 0x3UL);
+
+	ppc4xx_pic = &xilinx_intc;
+	ppc_md.get_irq = xilinx_pic_get_irq;
+}
diff -Nru a/arch/ppc/xmon/start.c b/arch/ppc/xmon/start.c
--- a/arch/ppc/xmon/start.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc/xmon/start.c	2004-12-24 13:36:17 -08:00
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/sysrq.h>
+#include <linux/bitops.h>
 #include <asm/xmon.h>
 #include <asm/prom.h>
 #include <asm/bootx.h>
@@ -21,9 +22,6 @@
 #include <asm/processor.h>
 #include <asm/delay.h>
 #include <asm/btext.h>
-#ifdef CONFIG_SMP
-#include <asm/bitops.h>
-#endif
 
 static volatile unsigned char *sccc, *sccd;
 unsigned int TXRDY, RXRDY, DLAB;
@@ -104,7 +102,7 @@
 {
 	.handler =	sysrq_handle_xmon,
 	.help_msg =	"Xmon",
-	.action_msg =	"Entering xmon\n",
+	.action_msg =	"Entering xmon",
 };
 #endif
 
diff -Nru a/arch/ppc/xmon/xmon.c b/arch/ppc/xmon/xmon.c
--- a/arch/ppc/xmon/xmon.c	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc/xmon/xmon.c	2004-12-24 13:36:16 -08:00
@@ -8,10 +8,10 @@
 #include <linux/sched.h>
 #include <linux/smp.h>
 #include <linux/interrupt.h>
+#include <linux/bitops.h>
 #include <asm/ptrace.h>
 #include <asm/string.h>
 #include <asm/prom.h>
-#include <asm/bitops.h>
 #include <asm/bootx.h>
 #include <asm/machdep.h>
 #include <asm/xmon.h>
diff -Nru a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
--- a/arch/ppc64/Kconfig	2004-12-24 13:36:56 -08:00
+++ b/arch/ppc64/Kconfig	2004-12-24 13:36:56 -08:00
@@ -80,6 +80,16 @@
 	select ADB_PMU
 	select U3_DART
 
+config PPC_MAPLE
+	depends on PPC_MULTIPLATFORM
+	bool "  Maple 970FX Evaluation Board"
+	select U3_DART
+	select MPIC_BROKEN_U3
+	default n
+	help
+          This option enables support for the Maple 970FX Evaluation Board.
+	  For more informations, refer to http://www.970eval.com
+
 config PPC
 	bool
 	default y
@@ -110,11 +120,21 @@
 	  processors, that is, which share physical processors between
 	  two or more partitions.
 
+config IBMVIO
+	depends on PPC_PSERIES || PPC_ISERIES
+	bool
+	default y
+
 config U3_DART
 	bool 
 	depends on PPC_MULTIPLATFORM
 	default n
 
+config MPIC_BROKEN_U3
+	bool
+	depends on PPC_MAPLE
+	default y
+
 config PPC_PMAC64
 	bool
 	depends on PPC_PMAC
@@ -207,6 +227,13 @@
 	  Say Y here if you are building a kernel for a desktop, embedded
 	  or real-time system.  Say N if you are unsure.
 
+#
+# Use the generic interrupt handling code in kernel/irq/:
+#
+config GENERIC_HARDIRQS
+	bool
+	default y
+
 config MSCHUNKS
 	bool
 	depends on PPC_ISERIES
@@ -348,6 +375,11 @@
 source "arch/ppc64/Kconfig.debug"
 
 source "security/Kconfig"
+
+config KEYS_COMPAT
+	bool
+	depends on COMPAT && KEYS
+	default y
 
 source "crypto/Kconfig"
 
diff -Nru a/arch/ppc64/Kconfig.debug b/arch/ppc64/Kconfig.debug
--- a/arch/ppc64/Kconfig.debug	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc64/Kconfig.debug	2004-12-24 13:37:19 -08:00
@@ -44,16 +44,4 @@
 	  for handling hard and soft interrupts.  This can help avoid
 	  overflowing the process kernel stacks.
 
-config SCHEDSTATS
-	bool "Collect scheduler statistics"
-	depends on DEBUG_KERNEL && PROC_FS
-	help
-	  If you say Y here, additional code will be inserted into the
-	  scheduler and related routines to collect statistics about
-	  scheduler behavior and provide them in /proc/schedstat.  These
-	  stats may be useful for both tuning and debugging the scheduler
-	  If you aren't debugging the scheduler or trying to tune a specific
-	  application, you can say N to avoid the very slight overhead
-	  this adds.
-
 endmenu
diff -Nru a/arch/ppc64/Makefile b/arch/ppc64/Makefile
--- a/arch/ppc64/Makefile	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/Makefile	2004-12-24 13:36:18 -08:00
@@ -32,7 +32,8 @@
 
 LDFLAGS		:= -m elf64ppc
 LDFLAGS_vmlinux	:= -Bstatic -e $(KERNELLOAD) -Ttext $(KERNELLOAD)
-CFLAGS		+= -msoft-float -pipe -mminimal-toc -mtraceback=none
+CFLAGS		+= -msoft-float -pipe -mminimal-toc -mtraceback=none \
+		   -mcall-aixdesc
 
 ifeq ($(CONFIG_POWER4_ONLY),y)
 	CFLAGS += $(call cc-option,-mcpu=power4)
@@ -55,11 +56,13 @@
 boot := arch/ppc64/boot
 
 boottarget-$(CONFIG_PPC_PSERIES) := zImage zImage.initrd
+boottarget-$(CONFIG_PPC_MAPLE) := zImage zImage.initrd
 boottarget-$(CONFIG_PPC_ISERIES) := vmlinux.sminitrd vmlinux.initrd vmlinux.sm
 $(boottarget-y): vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
 bootimage-$(CONFIG_PPC_PSERIES) := zImage
+bootimage-$(CONFIG_PPC_MAPLE) := zImage
 bootimage-$(CONFIG_PPC_ISERIES) := vmlinux
 BOOTIMAGE := $(bootimage-y)
 install: vmlinux
diff -Nru a/arch/ppc64/boot/Makefile b/arch/ppc64/boot/Makefile
--- a/arch/ppc64/boot/Makefile	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc64/boot/Makefile	2004-12-24 13:37:18 -08:00
@@ -118,6 +118,6 @@
 		>> $(obj)/imagesize.c
 
 install: $(CONFIGURE) $(obj)/$(BOOTIMAGE)
-	sh -x $(src)/install.sh "$(KERNELRELEASE)" "$(obj)/$(BOOTIMAGE)" "$(INSTALL_PATH)"
+	sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" "$(obj)/$(BOOTIMAGE)" "$(INSTALL_PATH)"
 
 clean-files := $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip)
diff -Nru a/arch/ppc64/boot/main.c b/arch/ppc64/boot/main.c
--- a/arch/ppc64/boot/main.c	2004-12-24 13:37:43 -08:00
+++ b/arch/ppc64/boot/main.c	2004-12-24 13:37:43 -08:00
@@ -166,7 +166,7 @@
 		gunzip((void *)vmlinux.addr, vmlinux.size,
 			(unsigned char *)vmlinuz.addr, &len);
 		printf("done 0x%lx bytes\n\r", len);
-		printf("0x%x bytes of heap consumed, max in use 0x%\n\r",
+		printf("0x%x bytes of heap consumed, max in use 0x%x\n\r",
 		       (unsigned)(avail_high - begin_avail), heap_max);
 	} else {
 		memmove((void *)vmlinux.addr,(void *)vmlinuz.addr,vmlinuz.size);
diff -Nru a/arch/ppc64/configs/maple_defconfig b/arch/ppc64/configs/maple_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/configs/maple_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,921 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.9
+# Wed Oct 20 15:39:14 2004
+#
+CONFIG_64BIT=y
+CONFIG_MMU=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_HAVE_DEC_LOCK=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_COMPAT=y
+CONFIG_FRAME_POINTER=y
+CONFIG_FORCE_MAX_ZONEORDER=13
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=17
+# CONFIG_HOTPLUG is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+# CONFIG_TINY_SHMEM is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+CONFIG_SYSVIPC_COMPAT=y
+
+#
+# Platform support
+#
+# CONFIG_PPC_ISERIES is not set
+CONFIG_PPC_MULTIPLATFORM=y
+# CONFIG_PPC_PSERIES is not set
+# CONFIG_PPC_PMAC is not set
+CONFIG_PPC_MAPLE=y
+CONFIG_PPC=y
+CONFIG_PPC64=y
+CONFIG_PPC_OF=y
+# CONFIG_ALTIVEC is not set
+CONFIG_U3_DART=y
+CONFIG_MPIC_BROKEN_U3=y
+CONFIG_BOOTX_TEXT=y
+CONFIG_POWER4_ONLY=y
+CONFIG_IOMMU_VMERGE=y
+CONFIG_SMP=y
+# CONFIG_IRQ_ALL_CPUS is not set
+CONFIG_NR_CPUS=2
+# CONFIG_SCHED_SMT is not set
+# CONFIG_PREEMPT is not set
+
+#
+# General setup
+#
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_PCI_LEGACY_PROC=y
+CONFIG_PCI_NAMES=y
+CONFIG_PROC_DEVICETREE=y
+# CONFIG_CMDLINE_BOOL is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD 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_UMEM is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=8192
+# CONFIG_BLK_DEV_INITRD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECD=y
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+CONFIG_IDE_TASK_IOCTL=y
+CONFIG_IDE_TASKFILE_IO=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+# CONFIG_BLK_DEV_SL82C105 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+# CONFIG_BLK_DEV_CMD64X is not set
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT34X is not set
+# CONFIG_BLK_DEV_HPT366 is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+# CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Macintosh device drivers
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# 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_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+# CONFIG_PCNET32 is not set
+CONFIG_AMD8111_ETH=y
+# CONFIG_AMD8111E_NAPI is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_B44 is not set
+# CONFIG_FORCEDETH is not set
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+# CONFIG_E100 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_8139CP is not set
+# CONFIG_8139TOO is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_VIA_RHINE is not set
+# CONFIG_VIA_VELOCITY is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+CONFIG_E1000=y
+# CONFIG_E1000_NAPI is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1600
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=1200
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+# CONFIG_SERIO is not set
+# CONFIG_SERIO_I8042 is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_PMACZILOG is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_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_AGP is not set
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=y
+# CONFIG_I2C_ALGOPCF is not set
+# CONFIG_I2C_ALGOPCA is not set
+
+#
+# I2C Hardware Bus support
+#
+# CONFIG_I2C_ALI1535 is not set
+# CONFIG_I2C_ALI1563 is not set
+# CONFIG_I2C_ALI15X3 is not set
+# CONFIG_I2C_AMD756 is not set
+CONFIG_I2C_AMD8111=y
+# CONFIG_I2C_I801 is not set
+# CONFIG_I2C_I810 is not set
+# CONFIG_I2C_ISA is not set
+# CONFIG_I2C_NFORCE2 is not set
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_PROSAVAGE is not set
+# CONFIG_I2C_SAVAGE4 is not set
+# CONFIG_SCx200_ACB is not set
+# CONFIG_I2C_SIS5595 is not set
+# CONFIG_I2C_SIS630 is not set
+# CONFIG_I2C_SIS96X is not set
+# CONFIG_I2C_VIA is not set
+# CONFIG_I2C_VIAPRO is not set
+# CONFIG_I2C_VOODOO3 is not set
+# CONFIG_I2C_PCA_ISA is not set
+
+#
+# Hardware Sensors Chip support
+#
+# CONFIG_I2C_SENSOR is not set
+# CONFIG_SENSORS_ADM1021 is not set
+# CONFIG_SENSORS_ADM1025 is not set
+# CONFIG_SENSORS_ADM1031 is not set
+# CONFIG_SENSORS_ASB100 is not set
+# CONFIG_SENSORS_DS1621 is not set
+# CONFIG_SENSORS_FSCHER is not set
+# CONFIG_SENSORS_GL518SM is not set
+# CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM75 is not set
+# CONFIG_SENSORS_LM77 is not set
+# CONFIG_SENSORS_LM78 is not set
+# CONFIG_SENSORS_LM80 is not set
+# CONFIG_SENSORS_LM83 is not set
+# CONFIG_SENSORS_LM85 is not set
+# CONFIG_SENSORS_LM90 is not set
+# CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_VIA686A is not set
+# CONFIG_SENSORS_W83781D is not set
+# CONFIG_SENSORS_W83L785TS is not set
+# CONFIG_SENSORS_W83627HF is not set
+
+#
+# Other I2C Chip support
+#
+# CONFIG_SENSORS_EEPROM is not set
+# CONFIG_SENSORS_PCF8574 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_SENSORS_RTC8564 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_SPLIT_ISO=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_UHCI_HCD=y
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_BLUETOOTH_TTY is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+# CONFIG_USB_STORAGE is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+CONFIG_USB_HID=y
+CONFIG_USB_HIDINPUT=y
+# CONFIG_HID_FF is not set
+# CONFIG_USB_HIDDEV is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_MTOUCH is not set
+# CONFIG_USB_EGALAX is not set
+# CONFIG_USB_XPAD is not set
+# CONFIG_USB_ATI_REMOTE is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+
+#
+# USB Multimedia devices
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# Video4Linux support is needed for USB Multimedia device support
+#
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+CONFIG_USB_PEGASUS=y
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+CONFIG_USB_SERIAL=y
+# CONFIG_USB_SERIAL_CONSOLE is not set
+CONFIG_USB_SERIAL_GENERIC=y
+# CONFIG_USB_SERIAL_BELKIN 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_IPAQ is not set
+# CONFIG_USB_SERIAL_IR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+CONFIG_USB_SERIAL_KEYSPAN=y
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+# CONFIG_USB_SERIAL_KLSI is not set
+# CONFIG_USB_SERIAL_KOBIL_SCT is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_SAFE is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_XIRCOM is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+CONFIG_USB_EZUSB=y
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_TIGL is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETSERVO is not set
+# CONFIG_USB_TEST is not set
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+CONFIG_DEVPTS_FS_XATTR=y
+# CONFIG_DEVPTS_FS_SECURITY is not set
+CONFIG_TMPFS=y
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+# CONFIG_NFSD is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS 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=y
+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 is not set
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_EFI_PARTITION is not set
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf-8"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=y
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+CONFIG_DEBUG_KERNEL=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_SLAB=y
+CONFIG_DEBUG_SPINLOCK_SLEEP=y
+# CONFIG_DEBUG_INFO is not set
+CONFIG_DEBUG_STACKOVERFLOW=y
+CONFIG_DEBUG_STACK_USAGE=y
+CONFIG_DEBUGGER=y
+CONFIG_XMON=y
+CONFIG_XMON_DEFAULT=y
+# CONFIG_PPCDBG is not set
+# CONFIG_IRQSTACKS is not set
+# CONFIG_SCHEDSTATS is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_WP512 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=y
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
diff -Nru a/arch/ppc64/kernel/LparData.c b/arch/ppc64/kernel/LparData.c
--- a/arch/ppc64/kernel/LparData.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc64/kernel/LparData.c	2004-12-24 13:36:31 -08:00
@@ -6,16 +6,15 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
-#include <asm/types.h>
-#include <asm/page.h>
-#include <stddef.h>
+#include <linux/config.h>
+#include <linux/types.h>
 #include <linux/threads.h>
 #include <linux/module.h>
+#include <linux/bitops.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
 #include <asm/naca.h>
 #include <asm/abs_addr.h>
-#include <asm/bitops.h>
 #include <asm/iSeries/ItLpNaca.h>
 #include <asm/iSeries/ItLpPaca.h>
 #include <asm/iSeries/ItLpRegSave.h>
diff -Nru a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile
--- a/arch/ppc64/kernel/Makefile	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc64/kernel/Makefile	2004-12-24 13:37:29 -08:00
@@ -11,24 +11,23 @@
 			udbg.o binfmt_elf32.o sys_ppc32.o ioctl32.o \
 			ptrace32.o signal32.o rtc.o init_task.o \
 			lmb.o cputable.o cpu_setup_power4.o idle_power4.o \
-			iommu.o sysfs.o vio.o
+			iommu.o sysfs.o
 
 obj-$(CONFIG_PPC_OF) +=	of_device.o
 
-pci-obj-$(CONFIG_PPC_ISERIES)	+= iSeries_pci.o iSeries_pci_reset.o \
-				     iSeries_IoMmTable.o
+pci-obj-$(CONFIG_PPC_ISERIES)	+= iSeries_pci.o iSeries_pci_reset.o
 pci-obj-$(CONFIG_PPC_MULTIPLATFORM)	+= pci_dn.o pci_dma_direct.o
 
 obj-$(CONFIG_PCI)	+= pci.o pci_iommu.o iomap.o $(pci-obj-y)
 
 obj-$(CONFIG_PPC_ISERIES) += iSeries_irq.o \
 			     iSeries_VpdInfo.o XmPciLpEvent.o \
-			     HvCall.o HvLpConfig.o LparData.o mf_proc.o \
+			     HvCall.o HvLpConfig.o LparData.o \
 			     iSeries_setup.o ItLpQueue.o hvCall.o \
 			     mf.o HvLpEvent.o iSeries_proc.o iSeries_htab.o \
 			     iSeries_iommu.o
 
-obj-$(CONFIG_PPC_MULTIPLATFORM) += nvram.o open_pic.o i8259.o prom_init.o prom.o
+obj-$(CONFIG_PPC_MULTIPLATFORM) += nvram.o i8259.o prom_init.o prom.o mpic.o
 
 obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \
 			     eeh.o pSeries_nvram.o rtasd.o ras.o \
@@ -45,14 +44,20 @@
 obj-$(CONFIG_HVC_CONSOLE)	+= hvconsole.o
 obj-$(CONFIG_BOOTX_TEXT)	+= btext.o
 obj-$(CONFIG_HVCS)		+= hvcserver.o
+obj-$(CONFIG_IBMVIO)		+= vio.o
 
 obj-$(CONFIG_PPC_PMAC)		+= pmac_setup.o pmac_feature.o pmac_pci.o \
-				   pmac_time.o pmac_nvram.o pmac_low_i2c.o \
-				   open_pic_u3.o
+				   pmac_time.o pmac_nvram.o pmac_low_i2c.o
+
+obj-$(CONFIG_PPC_MAPLE)		+= maple_setup.o maple_pci.o maple_time.o
+
 obj-$(CONFIG_U3_DART)		+= u3_iommu.o
 
 ifdef CONFIG_SMP
 obj-$(CONFIG_PPC_PMAC)		+= pmac_smp.o smp-tbsync.o
+obj-$(CONFIG_PPC_ISERIES)	+= iSeries_smp.o
+obj-$(CONFIG_PPC_PSERIES)	+= pSeries_smp.o
+obj-$(CONFIG_PPC_MAPLE)		+= smp-tbsync.o
 endif
 
 obj-$(CONFIG_ALTIVEC)		+= vecemu.o vector.o
diff -Nru a/arch/ppc64/kernel/asm-offsets.c b/arch/ppc64/kernel/asm-offsets.c
--- a/arch/ppc64/kernel/asm-offsets.c	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc64/kernel/asm-offsets.c	2004-12-24 13:37:01 -08:00
@@ -103,6 +103,7 @@
         DEFINE(PACA_EXDSI, offsetof(struct paca_struct, exdsi));
         DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp));
 	DEFINE(PACALPPACA, offsetof(struct paca_struct, lppaca));
+	DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id));
         DEFINE(LPPACASRR0, offsetof(struct ItLpPaca, xSavedSrr0));
         DEFINE(LPPACASRR1, offsetof(struct ItLpPaca, xSavedSrr1));
 	DEFINE(LPPACAANYINT, offsetof(struct ItLpPaca, xIntDword.xAnyInt));
diff -Nru a/arch/ppc64/kernel/bitops.c b/arch/ppc64/kernel/bitops.c
--- a/arch/ppc64/kernel/bitops.c	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc64/kernel/bitops.c	2004-12-24 13:37:01 -08:00
@@ -4,7 +4,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/byteorder.h>
 
 unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
diff -Nru a/arch/ppc64/kernel/cpu_setup_power4.S b/arch/ppc64/kernel/cpu_setup_power4.S
--- a/arch/ppc64/kernel/cpu_setup_power4.S	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/kernel/cpu_setup_power4.S	2004-12-24 13:36:18 -08:00
@@ -156,6 +156,15 @@
 	cror	4*cr0+eq,4*cr0+eq,4*cr1+eq
 	bne	1f
 
+	/* Before accessing memory, we make sure rm_ci is clear */
+	li	r0,0
+	mfspr	r3,SPRN_HID4
+	rldimi	r3,r0,40,23	/* clear bit 23 (rm_ci) */
+	sync
+	mtspr	SPRN_HID4,r3
+	isync
+	sync
+
 	/* Clear interrupt prefix */
 	li	r0,0
 	sync
diff -Nru a/arch/ppc64/kernel/dma.c b/arch/ppc64/kernel/dma.c
--- a/arch/ppc64/kernel/dma.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc64/kernel/dma.c	2004-12-24 13:36:17 -08:00
@@ -17,8 +17,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		return pci_dma_supported(to_pci_dev(dev), mask);
+#ifdef CONFIG_IBMVIO
 	if (dev->bus == &vio_bus_type)
 		return vio_dma_supported(to_vio_dev(dev), mask);
+#endif /* CONFIG_IBMVIO */
 	BUG();
 	return 0;
 }
@@ -28,8 +30,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
+#ifdef CONFIG_IBMVIO
 	if (dev->bus == &vio_bus_type)
 		return vio_set_dma_mask(to_vio_dev(dev), dma_mask);
+#endif /* CONFIG_IBMVIO */
 	BUG();
 	return 0;
 }
@@ -40,8 +44,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		return pci_alloc_consistent(to_pci_dev(dev), size, dma_handle);
+#ifdef CONFIG_IBMVIO
 	if (dev->bus == &vio_bus_type)
 		return vio_alloc_consistent(to_vio_dev(dev), size, dma_handle);
+#endif /* CONFIG_IBMVIO */
 	BUG();
 	return NULL;
 }
@@ -52,8 +58,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
+#ifdef CONFIG_IBMVIO
 	else if (dev->bus == &vio_bus_type)
 		vio_free_consistent(to_vio_dev(dev), size, cpu_addr, dma_handle);
+#endif /* CONFIG_IBMVIO */
 	else
 		BUG();
 }
@@ -64,8 +72,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
+#ifdef CONFIG_IBMVIO
 	if (dev->bus == &vio_bus_type)
 		return vio_map_single(to_vio_dev(dev), cpu_addr, size, direction);
+#endif /* CONFIG_IBMVIO */
 	BUG();
 	return (dma_addr_t)0;
 }
@@ -76,8 +86,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
+#ifdef CONFIG_IBMVIO
 	else if (dev->bus == &vio_bus_type)
 		vio_unmap_single(to_vio_dev(dev), dma_addr, size, direction);
+#endif /* CONFIG_IBMVIO */
 	else
 		BUG();
 }
@@ -89,8 +101,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
+#ifdef CONFIG_IBMVIO
 	if (dev->bus == &vio_bus_type)
 		return vio_map_page(to_vio_dev(dev), page, offset, size, direction);
+#endif /* CONFIG_IBMVIO */
 	BUG();
 	return (dma_addr_t)0;
 }
@@ -101,8 +115,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
+#ifdef CONFIG_IBMVIO
 	else if (dev->bus == &vio_bus_type)
 		vio_unmap_page(to_vio_dev(dev), dma_address, size, direction);
+#endif /* CONFIG_IBMVIO */
 	else
 		BUG();
 }
@@ -113,8 +129,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
+#ifdef CONFIG_IBMVIO
 	if (dev->bus == &vio_bus_type)
 		return vio_map_sg(to_vio_dev(dev), sg, nents, direction);
+#endif /* CONFIG_IBMVIO */
 	BUG();
 	return 0;
 }
@@ -125,8 +143,10 @@
 {
 	if (dev->bus == &pci_bus_type)
 		pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
+#ifdef CONFIG_IBMVIO
 	else if (dev->bus == &vio_bus_type)
 		vio_unmap_sg(to_vio_dev(dev), sg, nhwentries, direction);
+#endif /* CONFIG_IBMVIO */
 	else
 		BUG();
 }
diff -Nru a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c
--- a/arch/ppc64/kernel/eeh.c	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc64/kernel/eeh.c	2004-12-24 13:37:01 -08:00
@@ -17,29 +17,79 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
+#include <linux/bootmem.h>
 #include <linux/init.h>
+#include <linux/list.h>
+#include <linux/mm.h>
+#include <linux/notifier.h>
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
 #include <linux/rbtree.h>
-#include <linux/spinlock.h>
 #include <linux/seq_file.h>
-#include <asm/paca.h>
-#include <asm/processor.h>
-#include <asm/naca.h>
+#include <linux/spinlock.h>
+#include <asm/eeh.h>
 #include <asm/io.h>
 #include <asm/machdep.h>
-#include <asm/pgtable.h>
 #include <asm/rtas.h>
+#include <asm/atomic.h>
 #include "pci.h"
 
 #undef DEBUG
 
+/** Overview:
+ *  EEH, or "Extended Error Handling" is a PCI bridge technology for
+ *  dealing with PCI bus errors that can't be dealt with within the
+ *  usual PCI framework, except by check-stopping the CPU.  Systems
+ *  that are designed for high-availability/reliability cannot afford
+ *  to crash due to a "mere" PCI error, thus the need for EEH.
+ *  An EEH-capable bridge operates by converting a detected error
+ *  into a "slot freeze", taking the PCI adapter off-line, making
+ *  the slot behave, from the OS'es point of view, as if the slot
+ *  were "empty": all reads return 0xff's and all writes are silently
+ *  ignored.  EEH slot isolation events can be triggered by parity
+ *  errors on the address or data busses (e.g. during posted writes),
+ *  which in turn might be caused by dust, vibration, humidity,
+ *  radioactivity or plain-old failed hardware.
+ *
+ *  Note, however, that one of the leading causes of EEH slot
+ *  freeze events are buggy device drivers, buggy device microcode,
+ *  or buggy device hardware.  This is because any attempt by the
+ *  device to bus-master data to a memory address that is not
+ *  assigned to the device will trigger a slot freeze.   (The idea
+ *  is to prevent devices-gone-wild from corrupting system memory).
+ *  Buggy hardware/drivers will have a miserable time co-existing
+ *  with EEH.
+ *
+ *  Ideally, a PCI device driver, when suspecting that an isolation
+ *  event has occured (e.g. by reading 0xff's), will then ask EEH
+ *  whether this is the case, and then take appropriate steps to
+ *  reset the PCI slot, the PCI device, and then resume operations.
+ *  However, until that day,  the checking is done here, with the
+ *  eeh_check_failure() routine embedded in the MMIO macros.  If
+ *  the slot is found to be isolated, an "EEH Event" is synthesized
+ *  and sent out for processing.
+ */
+
+/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
 #define BUID_HI(buid) ((buid) >> 32)
 #define BUID_LO(buid) ((buid) & 0xffffffff)
-#define CONFIG_ADDR(busno, devfn) \
-		(((((busno) & 0xff) << 8) | ((devfn) & 0xf8)) << 8)
+
+/* EEH event workqueue setup. */
+static spinlock_t eeh_eventlist_lock = SPIN_LOCK_UNLOCKED;
+LIST_HEAD(eeh_eventlist);
+static void eeh_event_handler(void *);
+DECLARE_WORK(eeh_event_wq, eeh_event_handler, NULL);
+
+static struct notifier_block *eeh_notifier_chain;
+
+/*
+ * If a device driver keeps reading an MMIO register in an interrupt
+ * handler after a slot isolation event has occurred, we assume it
+ * is broken and panic.  This sets the threshold for how many read
+ * attempts we allow before panicking.
+ */
+#define EEH_MAX_FAILS	1000
+static atomic_t eeh_fail_count;
 
 /* RTAS tokens */
 static int ibm_set_eeh_option;
@@ -58,13 +108,15 @@
 static DEFINE_PER_CPU(unsigned long, total_mmio_ffs);
 static DEFINE_PER_CPU(unsigned long, false_positives);
 static DEFINE_PER_CPU(unsigned long, ignored_failures);
+static DEFINE_PER_CPU(unsigned long, slot_resets);
 
 /**
  * The pci address cache subsystem.  This subsystem places
  * PCI device address resources into a red-black tree, sorted
  * according to the address range, so that given only an i/o
  * address, the corresponding PCI device can be **quickly**
- * found.
+ * found. It is safe to perform an address lookup in an interrupt
+ * context; this ability is an important feature.
  *
  * Currently, the only customer of this code is the EEH subsystem;
  * thus, this code has been somewhat tailored to suit EEH better.
@@ -333,6 +385,94 @@
 #endif
 }
 
+/* --------------------------------------------------------------- */
+/* Above lies the PCI Address Cache. Below lies the EEH event infrastructure */
+
+/**
+ * eeh_register_notifier - Register to find out about EEH events.
+ * @nb: notifier block to callback on events
+ */
+int eeh_register_notifier(struct notifier_block *nb)
+{
+	return notifier_chain_register(&eeh_notifier_chain, nb);
+}
+
+/**
+ * eeh_unregister_notifier - Unregister to an EEH event notifier.
+ * @nb: notifier block to callback on events
+ */
+int eeh_unregister_notifier(struct notifier_block *nb)
+{
+	return notifier_chain_unregister(&eeh_notifier_chain, nb);
+}
+
+/**
+ * eeh_panic - call panic() for an eeh event that cannot be handled.
+ * The philosophy of this routine is that it is better to panic and
+ * halt the OS than it is to risk possible data corruption by
+ * oblivious device drivers that don't know better.
+ *
+ * @dev pci device that had an eeh event
+ * @reset_state current reset state of the device slot
+ */
+static void eeh_panic(struct pci_dev *dev, int reset_state)
+{
+	/*
+	 * XXX We should create a separate sysctl for this.
+	 *
+	 * Since the panic_on_oops sysctl is used to halt the system
+	 * in light of potential corruption, we can use it here.
+	 */
+	if (panic_on_oops)
+		panic("EEH: MMIO failure (%d) on device:%s %s\n", reset_state,
+		      pci_name(dev), pci_pretty_name(dev));
+	else {
+		__get_cpu_var(ignored_failures)++;
+		printk(KERN_INFO "EEH: Ignored MMIO failure (%d) on device:%s %s\n",
+		       reset_state, pci_name(dev), pci_pretty_name(dev));
+	}
+}
+
+/**
+ * eeh_event_handler - dispatch EEH events.  The detection of a frozen
+ * slot can occur inside an interrupt, where it can be hard to do
+ * anything about it.  The goal of this routine is to pull these
+ * detection events out of the context of the interrupt handler, and
+ * re-dispatch them for processing at a later time in a normal context.
+ *
+ * @dummy - unused
+ */
+static void eeh_event_handler(void *dummy)
+{
+	unsigned long flags;
+	struct eeh_event	*event;
+
+	while (1) {
+		spin_lock_irqsave(&eeh_eventlist_lock, flags);
+		event = NULL;
+		if (!list_empty(&eeh_eventlist)) {
+			event = list_entry(eeh_eventlist.next, struct eeh_event, list);
+			list_del(&event->list);
+		}
+		spin_unlock_irqrestore(&eeh_eventlist_lock, flags);
+		if (event == NULL)
+			break;
+
+		printk(KERN_INFO "EEH: MMIO failure (%d), notifiying device "
+		       "%s %s\n", event->reset_state,
+		       pci_name(event->dev), pci_pretty_name(event->dev));
+
+		atomic_set(&eeh_fail_count, 0);
+		notifier_call_chain (&eeh_notifier_chain,
+				     EEH_NOTIFY_FREEZE, event);
+
+		__get_cpu_var(slot_resets)++;
+
+		pci_dev_put(event->dev);
+		kfree(event);
+	}
+}
+
 /**
  * eeh_token_to_phys - convert EEH address token to phys address
  * @token i/o token, should be address in the form 0xE....
@@ -357,11 +497,11 @@
  *
  * Check for an EEH failure for the given device node.  Call this
  * routine if the result of a read was all 0xff's and you want to
- * find out if this is due to an EEH slot freeze event.  This routine
+ * find out if this is due to an EEH slot freeze.  This routine
  * will query firmware for the EEH status.
  *
  * Returns 0 if there has not been an EEH error; otherwise returns
- * an error code.
+ * a non-zero value and queues up a solt isolation event notification.
  *
  * It is safe to call this routine in an interrupt context.
  */
@@ -370,6 +510,8 @@
 	int ret;
 	int rets[2];
 	unsigned long flags;
+	int rc, reset_state;
+	struct eeh_event  *event;
 
 	__get_cpu_var(total_mmio_ffs)++;
 
@@ -390,6 +532,24 @@
 	}
 
 	/*
+	 * If we already have a pending isolation event for this
+	 * slot, we know it's bad already, we don't need to check...
+	 */
+	if (dn->eeh_mode & EEH_MODE_ISOLATED) {
+		atomic_inc(&eeh_fail_count);
+		if (atomic_read(&eeh_fail_count) >= EEH_MAX_FAILS) {
+			/* re-read the slot reset state */
+			rets[0] = -1;
+			rtas_call(ibm_read_slot_reset_state, 3, 3, rets,
+				  dn->eeh_config_addr,
+				  BUID_HI(dn->phb->buid),
+				  BUID_LO(dn->phb->buid));
+			eeh_panic(dev, rets[0]);
+		}
+		return 0;
+	}
+
+	/*
 	 * Now test for an EEH failure.  This is VERY expensive.
 	 * Note that the eeh_config_addr may be a parent device
 	 * in the case of a device behind a bridge, or it may be
@@ -400,47 +560,54 @@
 			dn->eeh_config_addr, BUID_HI(dn->phb->buid),
 			BUID_LO(dn->phb->buid));
 
-	if (ret == 0 && rets[1] == 1 && (rets[0] == 2 || rets[0] == 4)) {
-		int log_event;
-
-		spin_lock_irqsave(&slot_errbuf_lock, flags);
-		memset(slot_errbuf, 0, eeh_error_buf_size);
-
-		log_event = rtas_call(ibm_slot_error_detail,
-		                      8, 1, NULL, dn->eeh_config_addr,
-		                      BUID_HI(dn->phb->buid),
-		                      BUID_LO(dn->phb->buid), NULL, 0,
-		                      virt_to_phys(slot_errbuf),
-		                      eeh_error_buf_size,
-		                      1 /* Temporary Error */);
-
-		if (log_event == 0)
-			log_error(slot_errbuf, ERR_TYPE_RTAS_LOG,
-				  1 /* Fatal */);
-
-		spin_unlock_irqrestore(&slot_errbuf_lock, flags);
-
-		printk(KERN_INFO "EEH: MMIO failure (%d) on device: %s %s\n",
-		       rets[0], dn->name, dn->full_name);
-		WARN_ON(1);
-
-		/*
-		 * XXX We should create a separate sysctl for this.
-		 *
-		 * Since the panic_on_oops sysctl is used to halt
-		 * the system in light of potential corruption, we
-		 * can use it here.
-		 */
-		if (panic_on_oops) {
-			panic("EEH: MMIO failure (%d) on device: %s %s\n",
-			      rets[0], dn->name, dn->full_name);
-		} else {
-			__get_cpu_var(ignored_failures)++;
-		}
-	} else {
+	if (!(ret == 0 && rets[1] == 1 && (rets[0] == 2 || rets[0] == 4))) {
 		__get_cpu_var(false_positives)++;
+		return 0;
 	}
 
+	/* prevent repeated reports of this failure */
+	dn->eeh_mode |= EEH_MODE_ISOLATED;
+
+	reset_state = rets[0];
+
+	spin_lock_irqsave(&slot_errbuf_lock, flags);
+	memset(slot_errbuf, 0, eeh_error_buf_size);
+
+	rc = rtas_call(ibm_slot_error_detail,
+	               8, 1, NULL, dn->eeh_config_addr,
+	               BUID_HI(dn->phb->buid),
+	               BUID_LO(dn->phb->buid), NULL, 0,
+	               virt_to_phys(slot_errbuf),
+	               eeh_error_buf_size,
+	               1 /* Temporary Error */);
+
+	if (rc == 0)
+		log_error(slot_errbuf, ERR_TYPE_RTAS_LOG, 0);
+	spin_unlock_irqrestore(&slot_errbuf_lock, flags);
+
+	printk(KERN_INFO "EEH: MMIO failure (%d) on device: %s %s\n",
+	       rets[0], dn->name, dn->full_name);
+	event = kmalloc(sizeof(*event), GFP_ATOMIC);
+	if (event == NULL) {
+		eeh_panic(dev, reset_state);
+		return 1;
+ 	}
+
+	event->dev = dev;
+	event->dn = dn;
+	event->reset_state = reset_state;
+
+	/* We may or may not be called in an interrupt context */
+	spin_lock_irqsave(&eeh_eventlist_lock, flags);
+	list_add(&event->list, &eeh_eventlist);
+	spin_unlock_irqrestore(&eeh_eventlist_lock, flags);
+
+	/* Most EEH events are due to device driver bugs.  Having
+	 * a stack trace will help the device-driver authors figure
+	 * out what happened.  So print that out. */
+	dump_stack();
+	schedule_work(&eeh_event_wq);
+
 	return 0;
 }
 
@@ -701,11 +868,13 @@
 {
 	unsigned int cpu;
 	unsigned long ffs = 0, positives = 0, failures = 0;
+	unsigned long resets = 0;
 
 	for_each_cpu(cpu) {
 		ffs += per_cpu(total_mmio_ffs, cpu);
 		positives += per_cpu(false_positives, cpu);
 		failures += per_cpu(ignored_failures, cpu);
+		resets += per_cpu(slot_resets, cpu);
 	}
 
 	if (0 == eeh_subsystem_enabled) {
@@ -715,8 +884,11 @@
 		seq_printf(m, "EEH Subsystem is enabled\n");
 		seq_printf(m, "eeh_total_mmio_ffs=%ld\n"
 			   "eeh_false_positives=%ld\n"
-			   "eeh_ignored_failures=%ld\n",
-			   ffs, positives, failures);
+			   "eeh_ignored_failures=%ld\n"
+			   "eeh_slot_resets=%ld\n"
+				"eeh_fail_count=%d\n",
+			   ffs, positives, failures, resets,
+				eeh_fail_count.counter);
 	}
 
 	return 0;
diff -Nru a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S
--- a/arch/ppc64/kernel/entry.S	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc64/kernel/entry.S	2004-12-24 13:36:17 -08:00
@@ -162,7 +162,7 @@
 
 	/* check for syscall tracing or audit */
 	ld	r9,TI_FLAGS(r12)
-	andi.	r0,r9,_TIF_SYSCALL_T_OR_A
+	andi.	r0,r9,(_TIF_SYSCALL_T_OR_A|_TIF_SINGLESTEP)
 	bne-	syscall_exit_trace
 syscall_exit_trace_cont:
 
@@ -265,16 +265,21 @@
 _GLOBAL(ppc32_sigsuspend)
 	bl	.save_nvgprs
 	bl	.sys32_sigsuspend
-	b	syscall_exit
+	b	70f
 
 _GLOBAL(ppc64_rt_sigsuspend)
 	bl	.save_nvgprs
 	bl	.sys_rt_sigsuspend
-	b	syscall_exit
+	b	70f
 
 _GLOBAL(ppc32_rt_sigsuspend)
 	bl	.save_nvgprs
 	bl	.sys32_rt_sigsuspend
+	/* If sigsuspend() returns zero, we are going into a signal handler */
+70:	cmpdi	0,r3,0
+	beq	.ret_from_except
+	/* If it returned -EINTR, we need to return via syscall_exit to set
+	   the SO bit in cr0 and potentially stop for ptrace. */
 	b	syscall_exit
 
 _GLOBAL(ppc_fork)
@@ -317,7 +322,7 @@
 	blt	syscall_exit
 	clrrdi	r4,r1,THREAD_SHIFT
 	ld	r4,TI_FLAGS(r4)
-	andi.	r4,r4,_TIF_SYSCALL_T_OR_A
+	andi.	r4,r4,(_TIF_SYSCALL_T_OR_A|_TIF_SINGLESTEP)
 	beq+	81f
 	bl	.do_syscall_trace_leave
 81:	b	.ret_from_except
@@ -497,10 +502,11 @@
 
 	li	r3,0
 	stb	r3,PACAPROCENABLED(r13)	/* ensure we are soft-disabled */
+	ori	r10,r10,MSR_EE
 	mtmsrd	r10			/* hard-enable again */
 	addi	r3,r1,STACK_FRAME_OVERHEAD
 	bl	.do_IRQ
-	b	.ret_from_except		/* loop back and handle more */
+	b	.ret_from_except_lite		/* loop back and handle more */
 
 4:	stb	r5,PACAPROCENABLED(r13)
 #endif
@@ -574,6 +580,7 @@
 	li	r0,1
 	stb	r0,PACAPROCENABLED(r13)
 #endif
+	ori	r10,r10,MSR_EE
 	mtmsrd	r10,1		/* reenable interrupts */
 	bl	.schedule
 	mfmsr	r10
@@ -591,6 +598,7 @@
 user_work:
 #endif
 	/* Enable interrupts */
+	ori	r10,r10,MSR_EE
 	mtmsrd	r10,1
 
 	andi.	r0,r4,_TIF_NEED_RESCHED
diff -Nru a/arch/ppc64/kernel/head.S b/arch/ppc64/kernel/head.S
--- a/arch/ppc64/kernel/head.S	2004-12-24 13:36:55 -08:00
+++ b/arch/ppc64/kernel/head.S	2004-12-24 13:36:55 -08:00
@@ -26,6 +26,7 @@
 #define SECONDARY_PROCESSORS
 
 #include <linux/config.h>
+#include <linux/threads.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -1192,23 +1193,39 @@
 
 /*
  * On pSeries, secondary processors spin in the following code.
- * At entry, r3 = this processor's number (in Linux terms, not hardware).
+ * At entry, r3 = this processor's number (physical cpu id)
  */
 _GLOBAL(pseries_secondary_smp_init)
+	mr	r24,r3
+	
 	/* turn on 64-bit mode */
 	bl	.enable_64b_mode
 	isync
 
-	/* Set up a paca value for this processor. */
-	LOADADDR(r24, paca) 		/* Get base vaddr of paca array	 */
-	mulli	r13,r3,PACA_SIZE	/* Calculate vaddr of right paca */
-	add	r13,r13,r24		/* for this processor.		 */
-
-	mtspr	SPRG3,r13		/* Save vaddr of paca in SPRG3	 */
-	mr	r24,r3			/* __secondary_start needs cpu#	 */
+	/* Copy some CPU settings from CPU 0 */
+	bl	.__restore_cpu_setup
 
-1:
-	HMT_LOW
+	/* Set up a paca value for this processor. Since we have the
+	 * physical cpu id in r3, we need to search the pacas to find
+	 * which logical id maps to our physical one.
+	 */
+	LOADADDR(r13, paca) 		/* Get base vaddr of paca array	 */
+	li	r5,0			/* logical cpu id                */
+1:	lhz	r6,PACAHWCPUID(r13)	/* Load HW procid from paca      */
+	cmpw	r6,r24			/* Compare to our id             */
+	beq	2f
+	addi	r13,r13,PACA_SIZE	/* Loop to next PACA on miss     */
+	addi	r5,r5,1
+	cmpwi	r5,NR_CPUS
+	blt	1b
+
+99:	HMT_LOW				/* Couldn't find our CPU id      */
+	b	99b
+
+2:	mtspr	SPRG3,r13		/* Save vaddr of paca in SPRG3	 */
+	/* From now on, r24 is expected to be logica cpuid */
+	mr	r24,r5
+3:	HMT_LOW
 	lbz	r23,PACAPROCSTART(r13)	/* Test if this processor should */
 					/* start.			 */
 	sync
@@ -1223,7 +1240,7 @@
 	bne	.__secondary_start
 #endif
 #endif
-	b 	1b			/* Loop until told to go	 */
+	b 	3b			/* Loop until told to go	 */
 #ifdef CONFIG_PPC_ISERIES
 _STATIC(__start_initialization_iSeries)
 	/* Clear out the BSS */
@@ -1886,19 +1903,6 @@
 91:
 #endif
 
-#ifdef CONFIG_SMP
-	/* All secondary cpus are now spinning on a common
-	 * spinloop, release them all now so they can start
-	 * to spin on their individual paca spinloops.
-	 * For non SMP kernels, the secondary cpus never
-	 * get out of the common spinloop.
-	 */
-	li	r3,1
-	LOADADDR(r5,__secondary_hold_spinloop)
-	tophys(r4,r5)
-	std	r3,0(r4)
-#endif
-
 	/* The following gets the stack and TOC set up with the regs */
 	/* pointing to the real addr of the kernel stack.  This is   */
 	/* all done to support the C function call below which sets  */
@@ -1913,7 +1917,7 @@
 	li	r0,0
 	stdu	r0,-STACK_FRAME_OVERHEAD(r1)
 
-		/* set up the TOC (physical address) */
+	/* set up the TOC (physical address) */
 	LOADADDR(r2,__toc_start)
 	addi	r2,r2,0x4000
 	addi	r2,r2,0x4000
@@ -1926,6 +1930,12 @@
 	mr	r5,r26
 	bl	.identify_cpu
 
+	/* Save some low level config HIDs of CPU0 to be copied to
+	 * other CPUs later on, or used for suspend/resume
+	 */
+	bl	.__save_cpu_setup
+	sync
+
 	/* Setup a valid physical PACA pointer in SPRG3 for early_setup
 	 * note that boot_cpuid can always be 0 nowadays since there is
 	 * nowhere it can be initialized differently before we reach this
@@ -2122,6 +2132,22 @@
 	mtspr	CTRLT, r4
 	blr
 #endif
+
+#if defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES)
+_GLOBAL(smp_release_cpus)
+	/* All secondary cpus are spinning on a common
+	 * spinloop, release them all now so they can start
+	 * to spin on their individual paca spinloops.
+	 * For non SMP kernels, the secondary cpus never
+	 * get out of the common spinloop.
+	 */
+	li	r3,1
+	LOADADDR(r5,__secondary_hold_spinloop)
+	std	r3,0(r5)
+	sync
+	blr
+#endif /* CONFIG_SMP && !CONFIG_PPC_ISERIES */
+
 
 /*
  * We put a few things here that have to be page-aligned.
diff -Nru a/arch/ppc64/kernel/i8259.c b/arch/ppc64/kernel/i8259.c
--- a/arch/ppc64/kernel/i8259.c	2004-12-24 13:37:30 -08:00
+++ b/arch/ppc64/kernel/i8259.c	2004-12-24 13:37:30 -08:00
@@ -23,7 +23,8 @@
 
 static spinlock_t i8259_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
 
-int i8259_pic_irq_offset;
+static int i8259_pic_irq_offset;
+static int i8259_present;
 
 int i8259_irq(int cpu)
 {
@@ -140,11 +141,13 @@
         NULL
 };
 
-void __init i8259_init(void)
+void __init i8259_init(int offset)
 {
 	unsigned long flags;
 	
 	spin_lock_irqsave(&i8259_lock, flags);
+	i8259_pic_irq_offset = offset;
+	i8259_present = 1;
         /* init master interrupt controller */
         outb(0x11, 0x20); /* Start init sequence */
         outb(0x00, 0x21); /* Vector base */
@@ -160,7 +163,18 @@
         outb(cached_A1, 0xA1);
         outb(cached_21, 0x21);
 	spin_unlock_irqrestore(&i8259_lock, flags);
+        
+}
+
+static int i8259_request_cascade(void)
+{
+	if (!i8259_present)
+		return -ENODEV;
+
         request_irq( i8259_pic_irq_offset + 2, no_action, SA_INTERRUPT,
                      "82c59 secondary cascade", NULL );
-        
+
+	return 0;
 }
+
+arch_initcall(i8259_request_cascade);
diff -Nru a/arch/ppc64/kernel/i8259.h b/arch/ppc64/kernel/i8259.h
--- a/arch/ppc64/kernel/i8259.h	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc64/kernel/i8259.h	2004-12-24 13:36:31 -08:00
@@ -11,7 +11,7 @@
 
 extern struct hw_interrupt_type i8259_pic;
 
-void i8259_init(void);
-int i8259_irq(int);
+extern void i8259_init(int offset);
+extern int i8259_irq(int);
 
 #endif /* _PPC_KERNEL_i8259_H */
diff -Nru a/arch/ppc64/kernel/iSeries_IoMmTable.c b/arch/ppc64/kernel/iSeries_IoMmTable.c
--- a/arch/ppc64/kernel/iSeries_IoMmTable.c	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,169 +0,0 @@
-#define PCIFR(...)
-/************************************************************************/
-/* This module supports the iSeries I/O Address translation mapping     */
-/* Copyright (C) 20yy  <Allan H Trautman> <IBM Corp>                    */
-/*                                                                      */
-/* 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                                          */
-/************************************************************************/
-/* Change Activity:                                                     */
-/*   Created, December 14, 2000                                         */
-/*   Added Bar table for IoMm performance.                              */
-/*   Ported to ppc64                                                    */
-/*   Added dynamic table allocation                                     */
-/* End Change Activity                                                  */
-/************************************************************************/
-#include <asm/types.h>
-#include <asm/resource.h>
-#include <linux/pci.h>
-#include <linux/spinlock.h>
-#include <asm/ppcdebug.h>
-#include <asm/iSeries/HvCallPci.h>
-#include <asm/iSeries/iSeries_pci.h>
-
-#include "iSeries_IoMmTable.h"
-#include "pci.h"
-
-/*
- * Table defines
- * Each Entry size is 4 MB * 1024 Entries = 4GB I/O address space.
- */
-#define Max_Entries 1024
-unsigned long iSeries_IoMmTable_Entry_Size = 0x0000000000400000; 
-unsigned long iSeries_Base_Io_Memory       = 0xE000000000000000;
-unsigned long iSeries_Max_Io_Memory        = 0xE000000000000000;
-static   long iSeries_CurrentIndex         = 0;
-
-/*
- * Lookup Tables.
- */
-struct iSeries_Device_Node **iSeries_IoMmTable;
-u8 *iSeries_IoBarTable;
-
-/*
- * Static and Global variables
- */
-static char *iSeriesPciIoText = "iSeries PCI I/O";
-static spinlock_t iSeriesIoMmTableLock = SPIN_LOCK_UNLOCKED;
-
-/*
- * iSeries_IoMmTable_Initialize
- *
- * Allocates and initalizes the Address Translation Table and Bar
- * Tables to get them ready for use.  Must be called before any
- * I/O space is handed out to the device BARs.
- * A follow up method,iSeries_IoMmTable_Status can be called to
- * adjust the table after the device BARs have been assiged to
- * resize the table.
- */
-void iSeries_IoMmTable_Initialize(void)
-{
-	spin_lock(&iSeriesIoMmTableLock);
-	iSeries_IoMmTable  = kmalloc(sizeof(void *) * Max_Entries, GFP_KERNEL);
-	iSeries_IoBarTable = kmalloc(sizeof(u8) * Max_Entries, GFP_KERNEL);
-	spin_unlock(&iSeriesIoMmTableLock);
-	PCIFR("IoMmTable Initialized 0x%p", iSeries_IoMmTable);
-	if ((iSeries_IoMmTable == NULL) || (iSeries_IoBarTable == NULL))
-		panic("PCI: I/O tables allocation failed.\n");
-}
-
-/*
- * iSeries_IoMmTable_AllocateEntry
- *
- * Adds pci_dev entry in address translation table
- *
- * - Allocates the number of entries required in table base on BAR
- *   size.
- * - Allocates starting at iSeries_Base_Io_Memory and increases.
- * - The size is round up to be a multiple of entry size.
- * - CurrentIndex is incremented to keep track of the last entry.
- * - Builds the resource entry for allocated BARs.
- */
-static void iSeries_IoMmTable_AllocateEntry(struct pci_dev *PciDev,
-		int BarNumber)
-{
-	struct resource *BarResource = &PciDev->resource[BarNumber];
-	long BarSize = pci_resource_len(PciDev, BarNumber);
-
-	/*
-	 * No space to allocate, quick exit, skip Allocation.
-	 */
-	if (BarSize == 0)
-		return;
-	/*
-	 * Set Resource values.
-	 */
-	spin_lock(&iSeriesIoMmTableLock);
-	BarResource->name = iSeriesPciIoText;
-	BarResource->start =
-		iSeries_IoMmTable_Entry_Size * iSeries_CurrentIndex;
-	BarResource->start += iSeries_Base_Io_Memory;
-	BarResource->end = BarResource->start+BarSize-1;
-	/*
-	 * Allocate the number of table entries needed for BAR.
-	 */
-	while (BarSize > 0 ) {
-		*(iSeries_IoMmTable + iSeries_CurrentIndex) =
-			(struct iSeries_Device_Node *)PciDev->sysdata;
-		*(iSeries_IoBarTable + iSeries_CurrentIndex) = BarNumber;
-		BarSize -= iSeries_IoMmTable_Entry_Size;
-		++iSeries_CurrentIndex;
-	}
-	iSeries_Max_Io_Memory = iSeries_Base_Io_Memory +
-		(iSeries_IoMmTable_Entry_Size * iSeries_CurrentIndex);
-	spin_unlock(&iSeriesIoMmTableLock);
-}
-
-/*
- * iSeries_allocateDeviceBars
- *
- * - Allocates ALL pci_dev BAR's and updates the resources with the
- *   BAR value.  BARS with zero length will have the resources
- *   The HvCallPci_getBarParms is used to get the size of the BAR
- *   space.  It calls iSeries_IoMmTable_AllocateEntry to allocate
- *   each entry.
- * - Loops through The Bar resources(0 - 5) including the ROM
- *   is resource(6).
- */
-void iSeries_allocateDeviceBars(struct pci_dev *PciDev)
-{
-	struct resource *BarResource;
-	int BarNumber;
-
-	for (BarNumber = 0; BarNumber <= PCI_ROM_RESOURCE; ++BarNumber) {
-		BarResource = &PciDev->resource[BarNumber];
-		iSeries_IoMmTable_AllocateEntry(PciDev, BarNumber);
-    	}
-}
-
-/*
- * Translates the IoAddress to the device that is mapped to IoSpace.
- * This code is inlined, see the iSeries_pci.c file for the replacement.
- */
-struct iSeries_Device_Node *iSeries_xlateIoMmAddress(void *IoAddress)
-{
-	return NULL;	   
-}
-
-/*
- * Status hook for IoMmTable
- */
-void iSeries_IoMmTable_Status(void)
-{
-	PCIFR("IoMmTable......: 0x%p", iSeries_IoMmTable);
-	PCIFR("IoMmTable Range: 0x%p to 0x%p", iSeries_Base_Io_Memory,
-			iSeries_Max_Io_Memory);
-}
diff -Nru a/arch/ppc64/kernel/iSeries_IoMmTable.h b/arch/ppc64/kernel/iSeries_IoMmTable.h
--- a/arch/ppc64/kernel/iSeries_IoMmTable.h	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,85 +0,0 @@
-#ifndef _ISERIES_IOMMTABLE_H
-#define _ISERIES_IOMMTABLE_H
-/************************************************************************/
-/* File iSeries_IoMmTable.h created by Allan Trautman on Dec 12 2001.   */
-/************************************************************************/
-/* Interfaces for the write/read Io address translation table.          */
-/* Copyright (C) 20yy  Allan H Trautman, IBM Corporation                */
-/*                                                                      */
-/* This program is free software; you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation; either version 2 of the License, or    */
-/* (at your option) any later version.                                  */
-/*                                                                      */
-/* This program is distributed in the hope that it will be useful,      */ 
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of       */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        */
-/* GNU General Public License for more details.                         */
-/*                                                                      */
-/* You should have received a copy of the GNU General Public License    */ 
-/* along with this program; if not, write to the:                       */
-/* Free Software Foundation, Inc.,                                      */ 
-/* 59 Temple Place, Suite 330,                                          */ 
-/* Boston, MA  02111-1307  USA                                          */
-/************************************************************************/
-/* Change Activity:                                                     */
-/*   Created December 12, 2000                                          */
-/*   Ported to ppc64, August 30, 2001                                   */
-/* End Change Activity                                                  */
-/************************************************************************/
-
-struct pci_dev;
-struct iSeries_Device_Node;
-
-extern struct iSeries_Device_Node **iSeries_IoMmTable;
-extern u8 *iSeries_IoBarTable;
-extern unsigned long iSeries_Base_Io_Memory;
-extern unsigned long iSeries_Max_Io_Memory;
-extern unsigned long iSeries_Base_Io_Memory;
-extern unsigned long iSeries_IoMmTable_Entry_Size;
-/*
- * iSeries_IoMmTable_Initialize
- *
- * - Initalizes the Address Translation Table and get it ready for use.
- *   Must be called before any client calls any of the other methods.
- *
- * Parameters: None.
- *
- * Return: None.
- */
-extern void iSeries_IoMmTable_Initialize(void);
-extern void iSeries_IoMmTable_Status(void);
-
-/*
- * iSeries_allocateDeviceBars
- *
- * - Allocates ALL pci_dev BAR's and updates the resources with the BAR
- *   value.  BARS with zero length will not have the resources.  The
- *   HvCallPci_getBarParms is used to get the size of the BAR space.
- *   It calls iSeries_IoMmTable_AllocateEntry to allocate each entry.
- *
- * Parameters:
- * pci_dev = Pointer to pci_dev structure that will be mapped to pseudo
- *           I/O Address.
- *
- * Return:
- *   The pci_dev I/O resources updated with pseudo I/O Addresses.
- */
-extern void iSeries_allocateDeviceBars(struct pci_dev *);
-
-/*
- * iSeries_xlateIoMmAddress
- *
- * - Translates an I/O Memory address to Device Node that has been the
- *   allocated the psuedo I/O Address.
- *
- * Parameters:
- * IoAddress = I/O Memory Address.
- *
- * Return:
- *   An iSeries_Device_Node to the device mapped to the I/O address. The
- *   BarNumber and BarOffset are valid if the Device Node is returned.
- */
-extern struct iSeries_Device_Node *iSeries_xlateIoMmAddress(void *IoAddress);
-
-#endif /* _ISERIES_IOMMTABLE_H */
diff -Nru a/arch/ppc64/kernel/iSeries_iommu.c b/arch/ppc64/kernel/iSeries_iommu.c
--- a/arch/ppc64/kernel/iSeries_iommu.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc64/kernel/iSeries_iommu.c	2004-12-24 13:36:17 -08:00
@@ -25,30 +25,14 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <linux/config.h>
-#include <linux/init.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/spinlock.h>
-#include <linux/string.h>
-#include <linux/pci.h>
 #include <linux/dma-mapping.h>
-#include <asm/io.h>
-#include <asm/prom.h>
-#include <asm/rtas.h>
-#include <asm/ppcdebug.h>
+#include <linux/list.h>
 
-#include <asm/iSeries/HvCallXm.h>
-#include <asm/iSeries/LparData.h>
 #include <asm/iommu.h>
-#include <asm/pci-bridge.h>
-#include <asm/iSeries/iSeries_pci.h>
-
 #include <asm/machdep.h>
-
-#include "pci.h"
-
+#include <asm/iSeries/HvCallXm.h>
+#include <asm/iSeries/iSeries_pci.h>
 
 extern struct list_head iSeries_Global_Device_List;
 
@@ -76,12 +60,11 @@
 				tce.te_bits.tb_pciwr = 1;
 		}
 
-		rc = HvCallXm_setTce((u64)tbl->it_index,
-				     (u64)index,
-				     tce.te_word);
+		rc = HvCallXm_setTce((u64)tbl->it_index, (u64)index,
+				tce.te_word);
 		if (rc)
-			panic("PCI_DMA: HvCallXm_setTce failed, Rc: 0x%lx\n", rc);
-
+			panic("PCI_DMA: HvCallXm_setTce failed, Rc: 0x%lx\n",
+					rc);
 		index++;
 		uaddr += PAGE_SIZE;
 	}
@@ -90,20 +73,14 @@
 static void tce_free_iSeries(struct iommu_table *tbl, long index, long npages)
 {
 	u64 rc;
-	union tce_entry tce;
 
 	while (npages--) {
-		tce.te_word = 0;
-		rc = HvCallXm_setTce((u64)tbl->it_index,
-				     (u64)index,
-				     tce.te_word);
-
+		rc = HvCallXm_setTce((u64)tbl->it_index, (u64)index, 0);
 		if (rc)
-			panic("PCI_DMA: HvCallXm_setTce failed, Rc: 0x%lx\n", rc);
-
+			panic("PCI_DMA: HvCallXm_setTce failed, Rc: 0x%lx\n",
+					rc);
 		index++;
 	}
-
 }
 
 
@@ -115,17 +92,14 @@
 {
 	struct iSeries_Device_Node *dp;
 
-	for (dp =  (struct iSeries_Device_Node *)iSeries_Global_Device_List.next;
-	     dp != (struct iSeries_Device_Node *)&iSeries_Global_Device_List;
-	     dp =  (struct iSeries_Device_Node *)dp->Device_List.next)
-		if (dp->iommu_table                 != NULL &&
-		    dp->iommu_table->it_type        == TCE_PCI &&
-		    dp->iommu_table->it_offset      == tbl->it_offset &&
-		    dp->iommu_table->it_index       == tbl->it_index &&
-		    dp->iommu_table->it_size        == tbl->it_size)
+	list_for_each_entry(dp, &iSeries_Global_Device_List, Device_List) {
+		if ((dp->iommu_table != NULL) &&
+		    (dp->iommu_table->it_type == TCE_PCI) &&
+		    (dp->iommu_table->it_offset == tbl->it_offset) &&
+		    (dp->iommu_table->it_index == tbl->it_index) &&
+		    (dp->iommu_table->it_size == tbl->it_size))
 			return dp->iommu_table;
-
-
+	}
 	return NULL;
 }
 
@@ -143,15 +117,14 @@
 {
 	struct iommu_table_cb *parms;
 
-	parms = (struct iommu_table_cb*)kmalloc(sizeof(*parms), GFP_KERNEL);
-
+	parms = kmalloc(sizeof(*parms), GFP_KERNEL);
 	if (parms == NULL)
 		panic("PCI_DMA: TCE Table Allocation failed.");
 
 	memset(parms, 0, sizeof(*parms));
 
-	parms->itc_busno   = ISERIES_BUS(dn);
-	parms->itc_slotno  = dn->LogicalSlot;
+	parms->itc_busno = ISERIES_BUS(dn);
+	parms->itc_slotno = dn->LogicalSlot;
 	parms->itc_virtbus = 0;
 
 	HvCallXm_getTceTableParms(ISERIES_HV_ADDR(parms));
@@ -159,34 +132,32 @@
 	if (parms->itc_size == 0)
 		panic("PCI_DMA: parms->size is zero, parms is 0x%p", parms);
 
-	tbl->it_size        = parms->itc_size;
-	tbl->it_busno       = parms->itc_busno;
-	tbl->it_offset      = parms->itc_offset;
-	tbl->it_index       = parms->itc_index;
-	tbl->it_entrysize   = sizeof(union tce_entry);
-	tbl->it_blocksize   = 1;
-	tbl->it_type        = TCE_PCI;
+	tbl->it_size = parms->itc_size;
+	tbl->it_busno = parms->itc_busno;
+	tbl->it_offset = parms->itc_offset;
+	tbl->it_index = parms->itc_index;
+	tbl->it_entrysize = sizeof(union tce_entry);
+	tbl->it_blocksize = 1;
+	tbl->it_type = TCE_PCI;
 
 	kfree(parms);
 }
 
 
-void iommu_devnode_init(struct iSeries_Device_Node *dn) {
+void iommu_devnode_init_iSeries(struct iSeries_Device_Node *dn)
+{
 	struct iommu_table *tbl;
 
-	tbl = (struct iommu_table *)kmalloc(sizeof(struct iommu_table), GFP_KERNEL);
+	tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL);
 
 	iommu_table_getparms(dn, tbl);
 
 	/* Look for existing tce table */
 	dn->iommu_table = iommu_table_find(tbl);
-
 	if (dn->iommu_table == NULL)
 		dn->iommu_table = iommu_init_table(tbl);
 	else
 		kfree(tbl);
-
-	return;
 }
 
 
diff -Nru a/arch/ppc64/kernel/iSeries_irq.c b/arch/ppc64/kernel/iSeries_irq.c
--- a/arch/ppc64/kernel/iSeries_irq.c	2004-12-24 13:37:04 -08:00
+++ b/arch/ppc64/kernel/iSeries_irq.c	2004-12-24 13:37:04 -08:00
@@ -110,6 +110,7 @@
 	/* Unmask bridge interrupts in the FISR */
 	mask = 0x01010000 << function;
 	HvCallPci_unmaskFisr(bus, subBus, deviceId, mask);
+	iSeries_enable_IRQ(irq);
 	return 0;
 }
 
diff -Nru a/arch/ppc64/kernel/iSeries_pci.c b/arch/ppc64/kernel/iSeries_pci.c
--- a/arch/ppc64/kernel/iSeries_pci.c	2004-12-24 13:37:30 -08:00
+++ b/arch/ppc64/kernel/iSeries_pci.c	2004-12-24 13:37:30 -08:00
@@ -1,4 +1,3 @@
-#define PCIFR(...)
 /*
  * iSeries_pci.c
  *
@@ -47,26 +46,19 @@
 #include <asm/iSeries/iSeries_pci.h>
 #include <asm/iSeries/mf.h>
 
-#include "iSeries_IoMmTable.h"
 #include "pci.h"
 
 extern int panic_timeout;
 
-extern unsigned long iSeries_Base_Io_Memory;    
-
-extern struct iommu_table *tceTables[256];
-
-extern void iSeries_MmIoTest(void);
+extern unsigned long io_page_mask;
 
 /*
  * Forward declares of prototypes. 
  */
 static struct iSeries_Device_Node *find_Device_Node(int bus, int devfn);
-static void iSeries_Scan_PHBs_Slots(struct pci_controller *Phb);
-static void iSeries_Scan_EADs_Bridge(HvBusNumber Bus, HvSubBusNumber SubBus,
-		int IdSel);
-static int iSeries_Scan_Bridge_Slot(HvBusNumber Bus,
-		struct HvCallPci_BridgeInfo *Info);
+static void scan_PHB_slots(struct pci_controller *Phb);
+static void scan_EADS_bridge(HvBusNumber Bus, HvSubBusNumber SubBus, int IdSel);
+static int scan_bridge_slot(HvBusNumber Bus, struct HvCallPci_BridgeInfo *Info);
 
 LIST_HEAD(iSeries_Global_Device_List);
 
@@ -87,7 +79,116 @@
 static struct pci_ops iSeries_pci_ops;
 
 /*
- * Log Error infor in Flight Recorder to system Console.
+ * Table defines
+ * Each Entry size is 4 MB * 1024 Entries = 4GB I/O address space.
+ */
+#define IOMM_TABLE_MAX_ENTRIES	1024
+#define IOMM_TABLE_ENTRY_SIZE	0x0000000000400000UL
+#define BASE_IO_MEMORY		0xE000000000000000UL
+
+static unsigned long max_io_memory = 0xE000000000000000UL;
+static long current_iomm_table_entry;
+
+/*
+ * Lookup Tables.
+ */
+static struct iSeries_Device_Node **iomm_table;
+static u8 *iobar_table;
+
+/*
+ * Static and Global variables
+ */
+static char *pci_io_text = "iSeries PCI I/O";
+static spinlock_t iomm_table_lock = SPIN_LOCK_UNLOCKED;
+
+/*
+ * iomm_table_initialize
+ *
+ * Allocates and initalizes the Address Translation Table and Bar
+ * Tables to get them ready for use.  Must be called before any
+ * I/O space is handed out to the device BARs.
+ */
+static void iomm_table_initialize(void)
+{
+	spin_lock(&iomm_table_lock);
+	iomm_table = kmalloc(sizeof(*iomm_table) * IOMM_TABLE_MAX_ENTRIES,
+			GFP_KERNEL);
+	iobar_table = kmalloc(sizeof(*iobar_table) * IOMM_TABLE_MAX_ENTRIES,
+			GFP_KERNEL);
+	spin_unlock(&iomm_table_lock);
+	if ((iomm_table == NULL) || (iobar_table == NULL))
+		panic("PCI: I/O tables allocation failed.\n");
+}
+
+/*
+ * iomm_table_allocate_entry
+ *
+ * Adds pci_dev entry in address translation table
+ *
+ * - Allocates the number of entries required in table base on BAR
+ *   size.
+ * - Allocates starting at BASE_IO_MEMORY and increases.
+ * - The size is round up to be a multiple of entry size.
+ * - CurrentIndex is incremented to keep track of the last entry.
+ * - Builds the resource entry for allocated BARs.
+ */
+static void iomm_table_allocate_entry(struct pci_dev *dev, int bar_num)
+{
+	struct resource *bar_res = &dev->resource[bar_num];
+	long bar_size = pci_resource_len(dev, bar_num);
+
+	/*
+	 * No space to allocate, quick exit, skip Allocation.
+	 */
+	if (bar_size == 0)
+		return;
+	/*
+	 * Set Resource values.
+	 */
+	spin_lock(&iomm_table_lock);
+	bar_res->name = pci_io_text;
+	bar_res->start =
+		IOMM_TABLE_ENTRY_SIZE * current_iomm_table_entry;
+	bar_res->start += BASE_IO_MEMORY;
+	bar_res->end = bar_res->start + bar_size - 1;
+	/*
+	 * Allocate the number of table entries needed for BAR.
+	 */
+	while (bar_size > 0 ) {
+		iomm_table[current_iomm_table_entry] = dev->sysdata;
+		iobar_table[current_iomm_table_entry] = bar_num;
+		bar_size -= IOMM_TABLE_ENTRY_SIZE;
+		++current_iomm_table_entry;
+	}
+	max_io_memory = BASE_IO_MEMORY +
+		(IOMM_TABLE_ENTRY_SIZE * current_iomm_table_entry);
+	spin_unlock(&iomm_table_lock);
+}
+
+/*
+ * allocate_device_bars
+ *
+ * - Allocates ALL pci_dev BAR's and updates the resources with the
+ *   BAR value.  BARS with zero length will have the resources
+ *   The HvCallPci_getBarParms is used to get the size of the BAR
+ *   space.  It calls iomm_table_allocate_entry to allocate
+ *   each entry.
+ * - Loops through The Bar resources(0 - 5) including the ROM
+ *   is resource(6).
+ */
+static void allocate_device_bars(struct pci_dev *dev)
+{
+	struct resource *bar_res;
+	int bar_num;
+
+	for (bar_num = 0; bar_num <= PCI_ROM_RESOURCE; ++bar_num) {
+		bar_res = &dev->resource[bar_num];
+		iomm_table_allocate_entry(dev, bar_num);
+    	}
+}
+
+/*
+ * Log error information to system console.
  * Filter out the device not there errors.
  * PCI: EADs Connect Failed 0x18.58.10 Rc: 0x00xx
  * PCI: Read Vendor Failed 0x18.58.10 Rc: 0x00xx
@@ -98,7 +199,6 @@
 {
 	if (HvRc == 0x0302)
 		return;
-
 	printk(KERN_ERR "PCI: %s Failed: 0x%02X.%02X.%02X Rc: 0x%04X",
 	       Error_Text, Bus, SubBus, AgentId, HvRc);
 }
@@ -132,8 +232,6 @@
 	node->DevFn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(AgentId), Function);
 	node->IoRetry = 0;
 	iSeries_Get_Location_Code(node);
-	PCIFR("Device 0x%02X.%2X, Node:0x%p ", ISERIES_BUS(node),
-			ISERIES_DEVFUN(node), node);
 	return node;
 }
 
@@ -158,11 +256,12 @@
 		int ret = HvCallXm_testBus(bus);
 		if (ret == 0) {
 			printk("bus %d appears to exist\n", bus);
-			phb = pci_alloc_pci_controller(phb_type_hypervisor);
-			if (phb == NULL) {
-				PCIFR("Allocate pci_controller failed.");
-				return -1;
-			}
+
+			phb = (struct pci_controller *)kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
+			if (phb == NULL)
+				return -ENOMEM;
+       			pci_setup_pci_controller(phb);
+
 			phb->pci_mem_offset = phb->local_number = bus;
 			phb->first_busno = bus;
 			phb->last_busno = bus;
@@ -170,10 +269,9 @@
 
 			PPCDBG(PPCDBG_BUSWALK, "PCI:Create iSeries pci_controller(%p), Bus: %04X\n",
 					phb, bus);
-			PCIFR("Create iSeries PHB controller: %04X", bus);
 
 			/* Find and connect the devices. */
-			iSeries_Scan_PHBs_Slots(phb);
+			scan_PHB_slots(phb);
 		}
 		/*
 		 * Check for Unexpected Return code, a clue that something
@@ -194,9 +292,9 @@
 void iSeries_pcibios_init(void)
 {
 	PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_init Entry.\n"); 
-	iSeries_IoMmTable_Initialize();
+	iomm_table_initialize();
 	find_and_init_phbs();
-	/* pci_assign_all_busses = 0;		SFRXXX*/
+	io_page_mask = -1;
 	PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_init Exit.\n"); 
 }
 
@@ -213,11 +311,10 @@
 	PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_fixup Entry.\n"); 
 
 	/* Fix up at the device node and pci_dev relationship */
-	mf_displaySrc(0xC9000100);
+	mf_display_src(0xC9000100);
 
 	printk("pcibios_final_fixup\n");
-	while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))
-			!= NULL) {
+	for_each_pci_dev(pdev) {
 		node = find_Device_Node(pdev->bus->number, pdev->devfn);
 		printk("pci dev %p (%x.%x), node %p\n", pdev,
 		       pdev->bus->number, pdev->devfn, node);
@@ -229,19 +326,18 @@
 			PPCDBG(PPCDBG_BUSWALK,
 					"pdev 0x%p <==> DevNode 0x%p\n",
 					pdev, node);
-			iSeries_allocateDeviceBars(pdev);
+			allocate_device_bars(pdev);
 			iSeries_Device_Information(pdev, Buffer,
 					sizeof(Buffer));
 			printk("%d. %s\n", DeviceCount, Buffer);
-			iommu_devnode_init(node);
+			iommu_devnode_init_iSeries(node);
 		} else
 			printk("PCI: Device Tree not found for 0x%016lX\n",
 					(unsigned long)pdev);
 		pdev->irq = node->Irq;
 	}
-	iSeries_IoMmTable_Status();
 	iSeries_activate_IRQs();
-	mf_displaySrc(0xC9000200);
+	mf_display_src(0xC9000200);
 }
 
 void pcibios_fixup_bus(struct pci_bus *PciBus)
@@ -258,7 +354,7 @@
 /*
  * Loop through each node function to find usable EADs bridges.  
  */
-static void iSeries_Scan_PHBs_Slots(struct pci_controller *Phb)
+static void scan_PHB_slots(struct pci_controller *Phb)
 {
 	struct HvCallPci_DeviceInfo *DevInfo;
 	HvBusNumber bus = Phb->local_number;	/* System Bus */	
@@ -281,7 +377,7 @@
 				sizeof(struct HvCallPci_DeviceInfo));
 		if (HvRc == 0) {
 			if (DevInfo->deviceType == HvCallPci_NodeDevice)
-				iSeries_Scan_EADs_Bridge(bus, SubBus, IdSel);
+				scan_EADS_bridge(bus, SubBus, IdSel);
 			else
 				printk("PCI: Invalid System Configuration(0x%02X)"
 				       " for bus 0x%02x id 0x%02x.\n",
@@ -293,7 +389,7 @@
 	kfree(DevInfo);
 }
 
-static void iSeries_Scan_EADs_Bridge(HvBusNumber bus, HvSubBusNumber SubBus,
+static void scan_EADS_bridge(HvBusNumber bus, HvSubBusNumber SubBus,
 		int IdSel)
 {
 	struct HvCallPci_BridgeInfo *BridgeInfo;
@@ -338,7 +434,7 @@
 				if (BridgeInfo->busUnitInfo.deviceType ==
 						HvCallPci_BridgeDevice)  {
 					/* Scan_Bridge_Slot...: 0x18.00.12 */
-					iSeries_Scan_Bridge_Slot(bus, BridgeInfo);
+					scan_bridge_slot(bus, BridgeInfo);
 				} else
 					printk("PCI: Invalid Bridge Configuration(0x%02X)",
 						BridgeInfo->busUnitInfo.deviceType);
@@ -353,7 +449,7 @@
 /*
  * This assumes that the node slot is always on the primary bus!
  */
-static int iSeries_Scan_Bridge_Slot(HvBusNumber Bus,
+static int scan_bridge_slot(HvBusNumber Bus,
 		struct HvCallPci_BridgeInfo *BridgeInfo)
 {
 	struct iSeries_Device_Node *node;
@@ -583,7 +679,7 @@
 		 */
 		if ((DevNode->IoRetry > Pci_Retry_Max) &&
 				(Pci_Error_Flag > 0)) {
-			mf_displaySrc(0xB6000103);
+			mf_display_src(0xB6000103);
 			panic_timeout = 0; 
 			panic("PCI: Hardware I/O Error, SRC B6000103, "
 					"Automatic Reboot Disabled.\n");
@@ -591,12 +687,8 @@
 		return -1;	/* Retry Try */
 	}
 	/* If retry was in progress, log success and rest retry count */
-	if (DevNode->IoRetry > 0) {
-		PCIFR("%s: Device 0x%04X:%02X Retry Successful(%2d).",
-				TextHdr, DevNode->DsaAddr.Dsa.busNumber, DevNode->DevFn,
-				DevNode->IoRetry);
+	if (DevNode->IoRetry > 0)
 		DevNode->IoRetry = 0;
-	}
 	return 0; 
 }
 
@@ -605,8 +697,9 @@
  * Note: Make sure the passed variable end up on the stack to avoid
  * the exposure of being device global.
  */
-static inline struct iSeries_Device_Node *xlateIoMmAddress(const volatile void __iomem *IoAddress,
-		 u64 *dsaptr, u64 *BarOffsetPtr)
+static inline struct iSeries_Device_Node *xlate_iomm_address(
+		const volatile void __iomem *IoAddress,
+		u64 *dsaptr, u64 *BarOffsetPtr)
 {
 	unsigned long OrigIoAddr;
 	unsigned long BaseIoAddr;
@@ -614,17 +707,16 @@
 	struct iSeries_Device_Node *DevNode;
 
 	OrigIoAddr = (unsigned long __force)IoAddress;
-	if ((OrigIoAddr < iSeries_Base_Io_Memory) ||
-			(OrigIoAddr >= iSeries_Max_Io_Memory))
+	if ((OrigIoAddr < BASE_IO_MEMORY) || (OrigIoAddr >= max_io_memory))
 		return NULL;
-	BaseIoAddr = OrigIoAddr - iSeries_Base_Io_Memory;
-	TableIndex = BaseIoAddr / iSeries_IoMmTable_Entry_Size;
-	DevNode = iSeries_IoMmTable[TableIndex];
+	BaseIoAddr = OrigIoAddr - BASE_IO_MEMORY;
+	TableIndex = BaseIoAddr / IOMM_TABLE_ENTRY_SIZE;
+	DevNode = iomm_table[TableIndex];
 
 	if (DevNode != NULL) {
-		int barnum = iSeries_IoBarTable[TableIndex];
+		int barnum = iobar_table[TableIndex];
 		*dsaptr = DevNode->DsaAddr.DsaAddr | (barnum << 24);
-		*BarOffsetPtr = BaseIoAddr % iSeries_IoMmTable_Entry_Size;
+		*BarOffsetPtr = BaseIoAddr % IOMM_TABLE_ENTRY_SIZE;
 	} else
 		panic("PCI: Invalid PCI IoAddress detected!\n");
 	return DevNode;
@@ -645,7 +737,7 @@
 	u64 dsa;
 	struct HvCallPci_LoadReturn ret;
 	struct iSeries_Device_Node *DevNode =
-		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+		xlate_iomm_address(IoAddress, &dsa, &BarOffset);
 
 	if (DevNode == NULL) {
 		static unsigned long last_jiffies;
@@ -674,7 +766,7 @@
 	u64 dsa;
 	struct HvCallPci_LoadReturn ret;
 	struct iSeries_Device_Node *DevNode =
-		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+		xlate_iomm_address(IoAddress, &dsa, &BarOffset);
 
 	if (DevNode == NULL) {
 		static unsigned long last_jiffies;
@@ -704,7 +796,7 @@
 	u64 dsa;
 	struct HvCallPci_LoadReturn ret;
 	struct iSeries_Device_Node *DevNode =
-		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+		xlate_iomm_address(IoAddress, &dsa, &BarOffset);
 
 	if (DevNode == NULL) {
 		static unsigned long last_jiffies;
@@ -741,7 +833,7 @@
 	u64 dsa;
 	u64 rc;
 	struct iSeries_Device_Node *DevNode =
-		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+		xlate_iomm_address(IoAddress, &dsa, &BarOffset);
 
 	if (DevNode == NULL) {
 		static unsigned long last_jiffies;
@@ -768,7 +860,7 @@
 	u64 dsa;
 	u64 rc;
 	struct iSeries_Device_Node *DevNode =
-		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+		xlate_iomm_address(IoAddress, &dsa, &BarOffset);
 
 	if (DevNode == NULL) {
 		static unsigned long last_jiffies;
@@ -795,7 +887,7 @@
 	u64 dsa;
 	u64 rc;
 	struct iSeries_Device_Node *DevNode =
-		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+		xlate_iomm_address(IoAddress, &dsa, &BarOffset);
 
 	if (DevNode == NULL) {
 		static unsigned long last_jiffies;
diff -Nru a/arch/ppc64/kernel/iSeries_proc.c b/arch/ppc64/kernel/iSeries_proc.c
--- a/arch/ppc64/kernel/iSeries_proc.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc64/kernel/iSeries_proc.c	2004-12-24 13:36:31 -08:00
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/param.h>		/* for HZ */
 #include <asm/paca.h>
 #include <asm/processor.h>
 #include <asm/time.h>
diff -Nru a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c
--- a/arch/ppc64/kernel/iSeries_setup.c	2004-12-24 13:37:03 -08:00
+++ b/arch/ppc64/kernel/iSeries_setup.c	2004-12-24 13:37:03 -08:00
@@ -55,6 +55,7 @@
 #include <asm/iSeries/IoHriMainStore.h>
 #include <asm/iSeries/iSeries_proc.h>
 #include <asm/iSeries/mf.h>
+#include <asm/iSeries/HvLpEvent.h>
 
 extern void hvlog(char *fmt, ...);
 
@@ -732,7 +733,7 @@
  */
 void iSeries_power_off(void)
 {
-	mf_powerOff();
+	mf_power_off();
 }
 
 /*
@@ -740,7 +741,7 @@
  */
 void iSeries_halt(void)
 {
-	mf_powerOff();
+	mf_power_off();
 }
 
 /* JDH Hack */
@@ -796,9 +797,9 @@
 	printk("Progress: [%04x] - %s\n", (unsigned)code, st);
 	if (!piranha_simulator && mf_initialized) {
 		if (code != 0xffff)
-			mf_displayProgress(code);
+			mf_display_progress(code);
 		else
-			mf_clearSrc();
+			mf_clear_src();
 	}
 }
 
diff -Nru a/arch/ppc64/kernel/iSeries_smp.c b/arch/ppc64/kernel/iSeries_smp.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/kernel/iSeries_smp.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,152 @@
+/*
+ * SMP support for iSeries machines.
+ *
+ * Dave Engebretsen, Peter Bergner, and
+ * Mike Corrigan {engebret|bergner|mikec}@us.ibm.com
+ *
+ * Plus various changes from other IBM teams...
+ *
+ *      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.
+ */
+
+#undef DEBUG
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.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>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/cache.h>
+#include <linux/err.h>
+#include <linux/sysdev.h>
+#include <linux/cpu.h>
+
+#include <asm/ptrace.h>
+#include <asm/atomic.h>
+#include <asm/irq.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/io.h>
+#include <asm/smp.h>
+#include <asm/naca.h>
+#include <asm/paca.h>
+#include <asm/iSeries/LparData.h>
+#include <asm/iSeries/HvCall.h>
+#include <asm/iSeries/HvCallCfg.h>
+#include <asm/time.h>
+#include <asm/ppcdebug.h>
+#include <asm/machdep.h>
+#include <asm/cputable.h>
+#include <asm/system.h>
+
+static unsigned long iSeries_smp_message[NR_CPUS];
+
+void iSeries_smp_message_recv( struct pt_regs * regs )
+{
+	int cpu = smp_processor_id();
+	int msg;
+
+	if ( num_online_cpus() < 2 )
+		return;
+
+	for ( msg = 0; msg < 4; ++msg )
+		if ( test_and_clear_bit( msg, &iSeries_smp_message[cpu] ) )
+			smp_message_recv( msg, regs );
+}
+
+static inline void smp_iSeries_do_message(int cpu, int msg)
+{
+	set_bit(msg, &iSeries_smp_message[cpu]);
+	HvCall_sendIPI(&(paca[cpu]));
+}
+
+static void smp_iSeries_message_pass(int target, int msg)
+{
+	int i;
+
+	if (target < NR_CPUS)
+		smp_iSeries_do_message(target, msg);
+	else {
+		for_each_online_cpu(i) {
+			if (target == MSG_ALL_BUT_SELF
+			    && i == smp_processor_id())
+				continue;
+			smp_iSeries_do_message(i, msg);
+		}
+	}
+}
+
+static int smp_iSeries_numProcs(void)
+{
+	unsigned np, i;
+
+	np = 0;
+        for (i=0; i < NR_CPUS; ++i) {
+                if (paca[i].lppaca.xDynProcStatus < 2) {
+			cpu_set(i, cpu_possible_map);
+			cpu_set(i, cpu_present_map);
+			cpu_set(i, cpu_sibling_map[i]);
+                        ++np;
+                }
+        }
+	return np;
+}
+
+static int smp_iSeries_probe(void)
+{
+	unsigned i;
+	unsigned np = 0;
+
+	for (i=0; i < NR_CPUS; ++i) {
+		if (paca[i].lppaca.xDynProcStatus < 2) {
+			/*paca[i].active = 1;*/
+			++np;
+		}
+	}
+
+	return np;
+}
+
+static void smp_iSeries_kick_cpu(int nr)
+{
+	BUG_ON(nr < 0 || nr >= NR_CPUS);
+
+	/* Verify that our partition has a processor nr */
+	if (paca[nr].lppaca.xDynProcStatus >= 2)
+		return;
+
+	/* The processor is currently spinning, waiting
+	 * for the cpu_start field to become non-zero
+	 * After we set cpu_start, the processor will
+	 * continue on to secondary_start in iSeries_head.S
+	 */
+	paca[nr].cpu_start = 1;
+}
+
+static void __devinit smp_iSeries_setup_cpu(int nr)
+{
+}
+
+static struct smp_ops_t iSeries_smp_ops = {
+	.message_pass = smp_iSeries_message_pass,
+	.probe        = smp_iSeries_probe,
+	.kick_cpu     = smp_iSeries_kick_cpu,
+	.setup_cpu    = smp_iSeries_setup_cpu,
+};
+
+/* This is called very early. */
+void __init smp_init_iSeries(void)
+{
+	smp_ops = &iSeries_smp_ops;
+	systemcfg->processorCount	= smp_iSeries_numProcs();
+}
+
diff -Nru a/arch/ppc64/kernel/idle.c b/arch/ppc64/kernel/idle.c
--- a/arch/ppc64/kernel/idle.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc64/kernel/idle.c	2004-12-24 13:37:18 -08:00
@@ -22,6 +22,7 @@
 #include <linux/cpu.h>
 #include <linux/module.h>
 #include <linux/sysctl.h>
+#include <linux/smp.h>
 
 #include <asm/system.h>
 #include <asm/processor.h>
@@ -363,12 +364,13 @@
 		}
 	}
 #endif /* CONFIG_PPC_PSERIES */
-#ifdef CONFIG_PPC_PMAC
-	if (systemcfg->platform == PLATFORM_POWERMAC) {
+#ifndef CONFIG_PPC_ISERIES
+	if (systemcfg->platform == PLATFORM_POWERMAC ||
+	    systemcfg->platform == PLATFORM_MAPLE) {
 		printk(KERN_INFO "Using native/NAP idle loop\n");
 		idle_loop = native_idle;
 	}
-#endif /* CONFIG_PPC_PMAC */
+#endif /* CONFIG_PPC_ISERIES */
 
 	return 1;
 }
diff -Nru a/arch/ppc64/kernel/iomap.c b/arch/ppc64/kernel/iomap.c
--- a/arch/ppc64/kernel/iomap.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc64/kernel/iomap.c	2004-12-24 13:36:48 -08:00
@@ -1,3 +1,10 @@
+/*
+ * arch/ppc64/kernel/iomap.c
+ *
+ * ppc64 "iomap" interface implementation.
+ *
+ * (C) Copyright 2004 Linus Torvalds
+ */
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/mm.h>
diff -Nru a/arch/ppc64/kernel/iommu.c b/arch/ppc64/kernel/iommu.c
--- a/arch/ppc64/kernel/iommu.c	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc64/kernel/iommu.c	2004-12-24 13:36:16 -08:00
@@ -33,12 +33,12 @@
 #include <linux/string.h>
 #include <linux/dma-mapping.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/iommu.h>
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>
-#include <asm/bitops.h>
 
 #define DBG(...)
 
@@ -59,13 +59,18 @@
 
 __setup("iommu=", setup_iommu);
 
-static unsigned long iommu_range_alloc(struct iommu_table *tbl, unsigned long npages,
-				       unsigned long *handle)
+static unsigned long iommu_range_alloc(struct iommu_table *tbl,
+                                       unsigned long npages,
+                                       unsigned long *handle,
+                                       unsigned int align_order)
 { 
 	unsigned long n, end, i, start;
 	unsigned long limit;
 	int largealloc = npages > 15;
 	int pass = 0;
+	unsigned long align_mask;
+
+	align_mask = 0xffffffffffffffffl >> (64 - align_order);
 
 	/* This allocator was derived from x86_64's bit string search */
 
@@ -97,6 +102,10 @@
  again:
 
 	n = find_next_zero_bit(tbl->it_map, limit, start);
+
+	/* Align allocation */
+	n = (n + align_mask) & ~align_mask;
+
 	end = n + npages;
 
 	if (unlikely(end >= limit)) {
@@ -141,14 +150,15 @@
 }
 
 static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *page,
-		       unsigned int npages, enum dma_data_direction direction)
+		       unsigned int npages, enum dma_data_direction direction,
+		       unsigned int align_order)
 {
 	unsigned long entry, flags;
 	dma_addr_t ret = DMA_ERROR_CODE;
 	
 	spin_lock_irqsave(&(tbl->it_lock), flags);
 
-	entry = iommu_range_alloc(tbl, npages, NULL);
+	entry = iommu_range_alloc(tbl, npages, NULL, align_order);
 
 	if (unlikely(entry == DMA_ERROR_CODE)) {
 		spin_unlock_irqrestore(&(tbl->it_lock), flags);
@@ -264,7 +274,7 @@
 		vaddr = (unsigned long)page_address(s->page) + s->offset;
 		npages = PAGE_ALIGN(vaddr + slen) - (vaddr & PAGE_MASK);
 		npages >>= PAGE_SHIFT;
-		entry = iommu_range_alloc(tbl, npages, &handle);
+		entry = iommu_range_alloc(tbl, npages, &handle, 0);
 
 		DBG("  - vaddr: %lx, size: %lx\n", vaddr, slen);
 
@@ -425,6 +435,39 @@
 	return tbl;
 }
 
+void iommu_free_table(struct device_node *dn)
+{
+	struct iommu_table *tbl = dn->iommu_table;
+	unsigned long bitmap_sz, i;
+	unsigned int order;
+
+	if (!tbl || !tbl->it_map) {
+		printk(KERN_ERR "%s: expected TCE map for %s\n", __FUNCTION__,
+				dn->full_name);
+		return;
+	}
+
+	/* verify that table contains no entries */
+	/* it_mapsize is in entries, and we're examining 64 at a time */
+	for (i = 0; i < (tbl->it_mapsize/64); i++) {
+		if (tbl->it_map[i] != 0) {
+			printk(KERN_WARNING "%s: Unexpected TCEs for %s\n",
+				__FUNCTION__, dn->full_name);
+			break;
+		}
+	}
+
+	/* calculate bitmap size in bytes */
+	bitmap_sz = (tbl->it_mapsize + 7) / 8;
+
+	/* free bitmap */
+	order = get_order(bitmap_sz);
+	free_pages((unsigned long) tbl->it_map, order);
+
+	/* free table */
+	kfree(tbl);
+}
+
 /* Creates TCEs for a user provided buffer.  The user buffer must be
  * contiguous real kernel storage (not vmalloc).  The address of the buffer
  * passed here is the kernel (virtual) address of the buffer.  The buffer
@@ -445,7 +488,7 @@
 	npages >>= PAGE_SHIFT;
 
 	if (tbl) {
-		dma_handle = iommu_alloc(tbl, vaddr, npages, direction);
+		dma_handle = iommu_alloc(tbl, vaddr, npages, direction, 0);
 		if (dma_handle == DMA_ERROR_CODE) {
 			if (printk_ratelimit())  {
 				printk(KERN_INFO "iommu_alloc failed, "
@@ -504,7 +547,7 @@
 	memset(ret, 0, size);
 
 	/* Set up tces to cover the allocated range */
-	mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL);
+	mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL, order);
 	if (mapping == DMA_ERROR_CODE) {
 		free_pages((unsigned long)ret, order);
 		ret = NULL;
diff -Nru a/arch/ppc64/kernel/irq.c b/arch/ppc64/kernel/irq.c
--- a/arch/ppc64/kernel/irq.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc64/kernel/irq.c	2004-12-24 13:36:48 -08:00
@@ -42,9 +42,9 @@
 #include <linux/random.h>
 #include <linux/kallsyms.h>
 #include <linux/profile.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
@@ -60,259 +60,12 @@
 extern void iSeries_smp_message_recv( struct pt_regs * );
 #endif
 
-static void register_irq_proc (unsigned int irq);
-
-irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
-	[0 ... NR_IRQS-1] = {
-		.lock = SPIN_LOCK_UNLOCKED
-	}
-};
+extern irq_desc_t irq_desc[NR_IRQS];
 
 int __irq_offset_value;
 int ppc_spurious_interrupts;
 unsigned long lpevent_count;
 
-int
-setup_irq(unsigned int irq, struct irqaction * new)
-{
-	int shared = 0;
-	unsigned long flags;
-	struct irqaction *old, **p;
-	irq_desc_t *desc = get_irq_desc(irq);
-
-	/*
-	 * Some drivers like serial.c use request_irq() heavily,
-	 * so we have to be careful not to interfere with a
-	 * running system.
-	 */
-	if (new->flags & SA_SAMPLE_RANDOM) {
-		/*
-		 * This function might sleep, we want to call it first,
-		 * outside of the atomic block.
-		 * Yes, this might clear the entropy pool if the wrong
-		 * driver is attempted to be loaded, without actually
-		 * installing a new handler, but is this really a problem,
-		 * only the sysadmin is able to do this.
-		 */
-		rand_initialize_irq(irq);
-	}
-
-	/*
-	 * The following block of code has to be executed atomically
-	 */
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	if ((old = *p) != NULL) {
-		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
-			spin_unlock_irqrestore(&desc->lock,flags);
-			return -EBUSY;
-		}
-
-		/* add new interrupt at end of irq queue */
-		do {
-			p = &old->next;
-			old = *p;
-		} while (old);
-		shared = 1;
-	}
-
-	*p = new;
-
-	if (!shared) {
-		desc->depth = 0;
-		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS);
-		if (desc->handler && desc->handler->startup)
-			desc->handler->startup(irq);
-		unmask_irq(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock,flags);
-
-	register_irq_proc(irq);
-	return 0;
-}
-
-#ifdef CONFIG_SMP
-
-inline void synchronize_irq(unsigned int irq)
-{
-	while (get_irq_desc(irq)->status & IRQ_INPROGRESS)
-		cpu_relax();
-}
-
-EXPORT_SYMBOL(synchronize_irq);
-
-#endif /* CONFIG_SMP */
-
-int request_irq(unsigned int irq,
-	irqreturn_t (*handler)(int, void *, struct pt_regs *),
-	unsigned long irqflags, const char * devname, void *dev_id)
-{
-	struct irqaction *action;
-	int retval;
-
-	if (irq >= NR_IRQS)
-		return -EINVAL;
-	if (!handler)
-		return -EINVAL;
-
-	action = (struct irqaction *)
-		kmalloc(sizeof(struct irqaction), GFP_KERNEL);
-	if (!action) {
-		printk(KERN_ERR "kmalloc() failed for irq %d !\n", irq);
-		return -ENOMEM;
-	}
-
-	action->handler = handler;
-	action->flags = irqflags;
-	cpus_clear(action->mask);
-	action->name = devname;
-	action->dev_id = dev_id;
-	action->next = NULL;
-
-	retval = setup_irq(irq, action);
-	if (retval)
-		kfree(action);
-
-	return 0;
-}
-
-EXPORT_SYMBOL(request_irq);
-
-void free_irq(unsigned int irq, void *dev_id)
-{
-	irq_desc_t *desc = get_irq_desc(irq);
-	struct irqaction **p;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	for (;;) {
-		struct irqaction * action = *p;
-		if (action) {
-			struct irqaction **pp = p;
-			p = &action->next;
-			if (action->dev_id != dev_id)
-				continue;
-
-			/* Found it - now remove it from the list of entries */
-			*pp = action->next;
-			if (!desc->action) {
-				desc->status |= IRQ_DISABLED;
-				mask_irq(irq);
-			}
-			spin_unlock_irqrestore(&desc->lock,flags);
-
-			/* Wait to make sure it's not being used on another CPU */
-			synchronize_irq(irq);
-			kfree(action);
-			return;
-		}
-		printk("Trying to free free IRQ%d\n",irq);
-		spin_unlock_irqrestore(&desc->lock,flags);
-		break;
-	}
-	return;
-}
-
-EXPORT_SYMBOL(free_irq);
-
-/*
- * Generic enable/disable code: this just calls
- * down into the PIC-specific version for the actual
- * hardware disable after having gotten the irq
- * controller lock. 
- */
- 
-/**
- *	disable_irq_nosync - disable an irq without waiting
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line. Disables of an interrupt
- *	stack. Unlike disable_irq(), this function does not ensure existing
- *	instances of the IRQ handler have completed before returning.
- *
- *	This function may be called from IRQ context.
- */
- 
-inline void disable_irq_nosync(unsigned int irq)
-{
-	irq_desc_t *desc = get_irq_desc(irq);
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	if (!desc->depth++) {
-		if (!(desc->status & IRQ_PER_CPU))
-			desc->status |= IRQ_DISABLED;
-		mask_irq(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-EXPORT_SYMBOL(disable_irq_nosync);
-
-/**
- *	disable_irq - disable an irq and wait for completion
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line. Disables of an interrupt
- *	stack. That is for two disables you need two enables. This
- *	function waits for any pending IRQ handlers for this interrupt
- *	to complete before returning. If you use this function while
- *	holding a resource the IRQ handler may need you will deadlock.
- *
- *	This function may be called - with care - from IRQ context.
- */
- 
-void disable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = get_irq_desc(irq);
-	disable_irq_nosync(irq);
-	if (desc->action)
-		synchronize_irq(irq);
-}
-
-EXPORT_SYMBOL(disable_irq);
-
-/**
- *	enable_irq - enable interrupt handling on an irq
- *	@irq: Interrupt to enable
- *
- *	Re-enables the processing of interrupts on this IRQ line
- *	providing no disable_irq calls are now in effect.
- *
- *	This function may be called from IRQ context.
- */
- 
-void enable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = get_irq_desc(irq);
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	switch (desc->depth) {
-	case 1: {
-		unsigned int status = desc->status & ~IRQ_DISABLED;
-		desc->status = status;
-		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
-			desc->status = status | IRQ_REPLAY;
-			hw_resend_irq(desc->handler,irq);
-		}
-		unmask_irq(irq);
-		/* fall-through */
-	}
-	default:
-		desc->depth--;
-		break;
-	case 0:
-		printk("enable_irq(%u) unbalanced from %p\n", irq,
-		       __builtin_return_address(0));
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-EXPORT_SYMBOL(enable_irq);
-
 int show_interrupts(struct seq_file *p, void *v)
 {
 	int i = *(loff_t *) v, j;
@@ -360,107 +113,7 @@
 	return 0;
 }
 
-int handle_irq_event(int irq, struct pt_regs *regs, struct irqaction *action)
-{
-	int status = 0;
-	int ret, retval = 0;
-
-	if (!(action->flags & SA_INTERRUPT))
-		local_irq_enable();
-
-	do {
-		ret = action->handler(irq, action->dev_id, regs);
-		if (ret == IRQ_HANDLED)
-			status |= action->flags;
-		retval |= ret;
-		action = action->next;
-	} while (action);
-	if (status & SA_SAMPLE_RANDOM)
-		add_interrupt_randomness(irq);
-	local_irq_disable();
-	return retval;
-}
-
-static void __report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	struct irqaction *action;
-
-	if (action_ret != IRQ_HANDLED && action_ret != IRQ_NONE) {
-		printk(KERN_ERR "irq event %d: bogus return value %x\n",
-				irq, action_ret);
-	} else {
-		printk(KERN_ERR "irq %d: nobody cared!\n", irq);
-	}
-	dump_stack();
-	printk(KERN_ERR "handlers:\n");
-	action = desc->action;
-	do {
-		printk(KERN_ERR "[<%p>]", action->handler);
-		print_symbol(" (%s)",
-			(unsigned long)action->handler);
-		printk("\n");
-		action = action->next;
-	} while (action);
-}
-
-static void report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	static int count = 100;
-
-	if (count) {
-		count--;
-		__report_bad_irq(irq, desc, action_ret);
-	}
-}
-
-static int noirqdebug;
-
-static int __init noirqdebug_setup(char *str)
-{
-	noirqdebug = 1;
-	printk("IRQ lockup detection disabled\n");
-	return 1;
-}
-
-__setup("noirqdebug", noirqdebug_setup);
-
-/*
- * If 99,900 of the previous 100,000 interrupts have not been handled then
- * assume that the IRQ is stuck in some manner.  Drop a diagnostic and try to
- * turn the IRQ off.
- *
- * (The other 100-of-100,000 interrupts may have been a correctly-functioning
- *  device sharing an IRQ with the failing one)
- *
- * Called under desc->lock
- */
-static void note_interrupt(int irq, irq_desc_t *desc, irqreturn_t action_ret)
-{
-	if (action_ret != IRQ_HANDLED) {
-		desc->irqs_unhandled++;
-		if (action_ret != IRQ_NONE)
-			report_bad_irq(irq, desc, action_ret);
-	}
-
-	desc->irq_count++;
-	if (desc->irq_count < 100000)
-		return;
-
-	desc->irq_count = 0;
-	if (desc->irqs_unhandled > 99900) {
-		/*
-		 * The interrupt is stuck
-		 */
-		__report_bad_irq(irq, desc, action_ret);
-		/*
-		 * Now kill the IRQ
-		 */
-		printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
-		desc->status |= IRQ_DISABLED;
-		desc->handler->disable(irq);
-	}
-	desc->irqs_unhandled = 0;
-}
+extern int noirqdebug;
 
 /*
  * Eventually, this should take an array of interrupts and an array size
@@ -482,7 +135,7 @@
 	if (desc->status & IRQ_PER_CPU) {
 		/* no locking required for CPU-local interrupts: */
 		ack_irq(irq);
-		action_ret = handle_irq_event(irq, regs, desc->action);
+		action_ret = handle_IRQ_event(irq, regs, desc->action);
 		desc->handler->end(irq);
 		return;
 	}
@@ -550,13 +203,13 @@
 		if (curtp != irqtp) {
 			irqtp->task = curtp->task;
 			irqtp->flags = 0;
-			action_ret = call_handle_irq_event(irq, regs, action, irqtp);
+			action_ret = call_handle_IRQ_event(irq, regs, action, irqtp);
 			irqtp->task = NULL;
 			if (irqtp->flags)
 				set_bits(irqtp->flags, &curtp->flags);
 		} else
 #endif
-			action_ret = handle_irq_event(irq, regs, action);
+			action_ret = handle_IRQ_event(irq, regs, action);
 
 		spin_lock(&desc->lock);
 		if (!noirqdebug)
@@ -658,27 +311,6 @@
 }
 #endif	/* CONFIG_PPC_ISERIES */
 
-unsigned long probe_irq_on (void)
-{
-	return 0;
-}
-
-EXPORT_SYMBOL(probe_irq_on);
-
-int probe_irq_off (unsigned long irqs)
-{
-	return 0;
-}
-
-EXPORT_SYMBOL(probe_irq_off);
-
-unsigned int probe_irq_mask(unsigned long irqs)
-{
-	return 0;
-}
-
-EXPORT_SYMBOL(probe_irq_mask);
-
 void __init init_IRQ(void)
 {
 	static int once = 0;
@@ -690,130 +322,6 @@
 
 	ppc_md.init_IRQ();
 	irq_ctx_init();
-}
-
-static struct proc_dir_entry * root_irq_dir;
-static struct proc_dir_entry * irq_dir [NR_IRQS];
-static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
-
-/* Protected by get_irq_desc(irq)->lock. */
-#ifdef CONFIG_IRQ_ALL_CPUS
-cpumask_t irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
-#else  /* CONFIG_IRQ_ALL_CPUS */
-cpumask_t irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_NONE };
-#endif /* CONFIG_IRQ_ALL_CPUS */
-
-static int irq_affinity_read_proc (char *page, char **start, off_t off,
-			int count, int *eof, void *data)
-{
-	int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
-	if (count - len < 2)
-		return -EINVAL;
-	len += sprintf(page + len, "\n");
-	return len;
-}
-
-static int irq_affinity_write_proc (struct file *file, const char __user *buffer,
-					unsigned long count, void *data)
-{
-	unsigned int irq = (long)data;
-	irq_desc_t *desc = get_irq_desc(irq);
-	int ret;
-	cpumask_t new_value, tmp;
-
-	if (!desc->handler->set_affinity)
-		return -EIO;
-
-	ret = cpumask_parse(buffer, count, new_value);
-	if (ret != 0)
-		return ret;
-
-	/*
-	 * We check for CPU_MASK_ALL in xics to send irqs to all cpus.
-	 * In some cases CPU_MASK_ALL is smaller than the cpumask (eg
-	 * NR_CPUS == 32 and cpumask is a long), so we mask it here to
-	 * be consistent.
-	 */
-	cpus_and(new_value, new_value, CPU_MASK_ALL);
-
-	/*
-	 * Grab lock here so cpu_online_map can't change, and also
-	 * protect irq_affinity[].
-	 */
-	spin_lock(&desc->lock);
-
-	/*
-	 * Do not allow disabling IRQs completely - it's a too easy
-	 * way to make the system unusable accidentally :-) At least
-	 * one online CPU still has to be targeted.
-	 */
-	cpus_and(tmp, new_value, cpu_online_map);
-	if (cpus_empty(tmp)) {
-		ret = -EINVAL;
-		goto out;
-	}
-
-	irq_affinity[irq] = new_value;
-	desc->handler->set_affinity(irq, new_value);
-	ret = count;
-
-out:
-	spin_unlock(&desc->lock);
-	return ret;
-}
-
-#define MAX_NAMELEN 10
-
-static void register_irq_proc (unsigned int irq)
-{
-	struct proc_dir_entry *entry;
-	char name [MAX_NAMELEN];
-
-	if (!root_irq_dir || (irq_desc[irq].handler == NULL) || irq_dir[irq])
-		return;
-
-	memset(name, 0, MAX_NAMELEN);
-	sprintf(name, "%d", irq);
-
-	/* create /proc/irq/1234 */
-	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
-
-	/* create /proc/irq/1234/smp_affinity */
-	entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
-
-	if (entry) {
-		entry->nlink = 1;
-		entry->data = (void *)(long)irq;
-		entry->read_proc = irq_affinity_read_proc;
-		entry->write_proc = irq_affinity_write_proc;
-	}
-
-	smp_affinity_entry[irq] = entry;
-}
-
-void init_irq_proc (void)
-{
-	int i;
-
-	/* create /proc/irq */
-	root_irq_dir = proc_mkdir("irq", NULL);
-
-	/* create /proc/irq/prof_cpu_mask */
-	create_prof_cpu_mask(root_irq_dir);
-
-	/*
-	 * Create entries for all existing IRQs.
-	 */
-	for_each_irq(i) {
-		if (get_irq_desc(i)->handler == NULL)
-			continue;
-		register_irq_proc(i);
-	}
-}
-
-irqreturn_t no_action(int irq, void *dev, struct pt_regs *regs)
-{
-	return IRQ_NONE;
 }
 
 #ifndef CONFIG_PPC_ISERIES
diff -Nru a/arch/ppc64/kernel/lmb.c b/arch/ppc64/kernel/lmb.c
--- a/arch/ppc64/kernel/lmb.c	2004-12-24 13:36:57 -08:00
+++ b/arch/ppc64/kernel/lmb.c	2004-12-24 13:36:57 -08:00
@@ -13,12 +13,12 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <asm/types.h>
 #include <asm/page.h>
 #include <asm/prom.h>
 #include <asm/lmb.h>
 #include <asm/abs_addr.h>
-#include <asm/bitops.h>
 
 struct lmb lmb;
 
diff -Nru a/arch/ppc64/kernel/lparcfg.c b/arch/ppc64/kernel/lparcfg.c
--- a/arch/ppc64/kernel/lparcfg.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/kernel/lparcfg.c	2004-12-24 13:36:18 -08:00
@@ -34,7 +34,7 @@
 #include <asm/rtas.h>
 #include <asm/system.h>
 
-#define MODULE_VERS "1.4"
+#define MODULE_VERS "1.5"
 #define MODULE_NAME "lparcfg"
 
 /* #define LPARCFG_DEBUG */
@@ -70,6 +70,28 @@
 
 #ifdef CONFIG_PPC_ISERIES
 
+/*
+ * For iSeries legacy systems, the PPA purr function is available from the
+ * xEmulatedTimeBase field in the paca.
+ */
+static unsigned long get_purr(void)
+{
+	unsigned long sum_purr = 0;
+	int cpu;
+	struct paca_struct *lpaca;
+
+	for_each_cpu(cpu) {
+		lpaca = paca + cpu;
+		sum_purr += lpaca->lppaca.xEmulatedTimeBase;
+
+#ifdef PURR_DEBUG
+		printk(KERN_INFO "get_purr for cpu (%d) has value (%ld) \n",
+			cpu, lpaca->lppaca.xEmulatedTimeBase);
+#endif
+	}
+	return sum_purr;
+}
+
 #define lparcfg_write NULL
 
 /* 
@@ -81,6 +103,9 @@
 	int shared, entitled_capacity, max_entitled_capacity;
 	int processors, max_processors;
 	struct paca_struct *lpaca = get_paca();
+	unsigned long purr = get_purr();
+
+	seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
 
 	shared = (int)(lpaca->lppaca_ptr->xSharedProc);
 	seq_printf(m, "serial_number=%c%c%c%c%c%c%c\n",
@@ -131,6 +156,7 @@
 		seq_printf(m, "pool_capacity=%d\n",
 			   (int)(HvLpConfig_getNumProcsInSharedPool(pool_id) *
 				 100));
+		seq_printf(m, "purr=%ld\n", purr);
 	}
 
 	seq_printf(m, "shared_processor_mode=%d\n", shared);
@@ -192,7 +218,7 @@
  * is coming, but at this time is still problematic, so for now this
  * function will return 0.
  */
-static unsigned long get_purr()
+static unsigned long get_purr(void)
 {
 	unsigned long sum_purr = 0;
 	return sum_purr;
@@ -524,10 +550,10 @@
 }
 
 struct file_operations lparcfg_fops = {
-      owner:THIS_MODULE,
-      read:seq_read,
-      open:lparcfg_open,
-      release:single_release,
+      .owner	= THIS_MODULE,
+      .read	= seq_read,
+      .open	= lparcfg_open,
+      .release	= single_release,
 };
 
 int __init lparcfg_init(void)
diff -Nru a/arch/ppc64/kernel/maple_pci.c b/arch/ppc64/kernel/maple_pci.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/kernel/maple_pci.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,527 @@
+/*
+ * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
+ *		      IBM Corp.
+ *
+ * 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.
+ */
+
+#define DEBUG
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/bootmem.h>
+
+#include <asm/sections.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <asm/pci-bridge.h>
+#include <asm/machdep.h>
+#include <asm/iommu.h>
+
+#include "pci.h"
+
+#ifdef DEBUG
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+static struct pci_controller *u3_agp, *u3_ht;
+
+static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
+{
+	for (; node != 0;node = node->sibling) {
+		int * bus_range;
+		unsigned int *class_code;
+		int len;
+
+		/* For PCI<->PCI bridges or CardBus bridges, we go down */
+		class_code = (unsigned int *) get_property(node, "class-code", NULL);
+		if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
+			(*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
+			continue;
+		bus_range = (int *) get_property(node, "bus-range", &len);
+		if (bus_range != NULL && len > 2 * sizeof(int)) {
+			if (bus_range[1] > higher)
+				higher = bus_range[1];
+		}
+		higher = fixup_one_level_bus_range(node->child, higher);
+	}
+	return higher;
+}
+
+/* This routine fixes the "bus-range" property of all bridges in the
+ * system since they tend to have their "last" member wrong on macs
+ *
+ * Note that the bus numbers manipulated here are OF bus numbers, they
+ * are not Linux bus numbers.
+ */
+static void __init fixup_bus_range(struct device_node *bridge)
+{
+	int * bus_range;
+	int len;
+
+	/* Lookup the "bus-range" property for the hose */
+	bus_range = (int *) get_property(bridge, "bus-range", &len);
+	if (bus_range == NULL || len < 2 * sizeof(int)) {
+		printk(KERN_WARNING "Can't get bus-range for %s\n",
+			       bridge->full_name);
+		return;
+	}
+	bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
+}
+
+
+#define U3_AGP_CFA0(devfn, off)	\
+	((1 << (unsigned long)PCI_SLOT(dev_fn)) \
+	| (((unsigned long)PCI_FUNC(dev_fn)) << 8) \
+	| (((unsigned long)(off)) & 0xFCUL))
+
+#define U3_AGP_CFA1(bus, devfn, off)	\
+	((((unsigned long)(bus)) << 16) \
+	|(((unsigned long)(devfn)) << 8) \
+	|(((unsigned long)(off)) & 0xFCUL) \
+	|1UL)
+
+static unsigned long u3_agp_cfg_access(struct pci_controller* hose,
+				       u8 bus, u8 dev_fn, u8 offset)
+{
+	unsigned int caddr;
+
+	if (bus == hose->first_busno) {
+		if (dev_fn < (11 << 3))
+			return 0;
+		caddr = U3_AGP_CFA0(dev_fn, offset);
+	} else
+		caddr = U3_AGP_CFA1(bus, dev_fn, offset);
+
+	/* Uninorth will return garbage if we don't read back the value ! */
+	do {
+		out_le32(hose->cfg_addr, caddr);
+	} while (in_le32(hose->cfg_addr) != caddr);
+
+	offset &= 0x07;
+	return ((unsigned long)hose->cfg_data) + offset;
+}
+
+static int u3_agp_read_config(struct pci_bus *bus, unsigned int devfn,
+			      int offset, int len, u32 *val)
+{
+	struct pci_controller *hose;
+	unsigned long addr;
+
+	hose = pci_bus_to_host(bus);
+	if (hose == NULL)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	addr = u3_agp_cfg_access(hose, bus->number, devfn, offset);
+	if (!addr)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	/*
+	 * Note: the caller has already checked that offset is
+	 * suitably aligned and that len is 1, 2 or 4.
+	 */
+	switch (len) {
+	case 1:
+		*val = in_8((u8 *)addr);
+		break;
+	case 2:
+		*val = in_le16((u16 *)addr);
+		break;
+	default:
+		*val = in_le32((u32 *)addr);
+		break;
+	}
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int u3_agp_write_config(struct pci_bus *bus, unsigned int devfn,
+			       int offset, int len, u32 val)
+{
+	struct pci_controller *hose;
+	unsigned long addr;
+
+	hose = pci_bus_to_host(bus);
+	if (hose == NULL)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	addr = u3_agp_cfg_access(hose, bus->number, devfn, offset);
+	if (!addr)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	/*
+	 * Note: the caller has already checked that offset is
+	 * suitably aligned and that len is 1, 2 or 4.
+	 */
+	switch (len) {
+	case 1:
+		out_8((u8 *)addr, val);
+		(void) in_8((u8 *)addr);
+		break;
+	case 2:
+		out_le16((u16 *)addr, val);
+		(void) in_le16((u16 *)addr);
+		break;
+	default:
+		out_le32((u32 *)addr, val);
+		(void) in_le32((u32 *)addr);
+		break;
+	}
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops u3_agp_pci_ops =
+{
+	u3_agp_read_config,
+	u3_agp_write_config
+};
+
+
+#define U3_HT_CFA0(devfn, off)		\
+		((((unsigned long)devfn) << 8) | offset)
+#define U3_HT_CFA1(bus, devfn, off)	\
+		(U3_HT_CFA0(devfn, off) \
+		+ (((unsigned long)bus) << 16) \
+		+ 0x01000000UL)
+
+static unsigned long u3_ht_cfg_access(struct pci_controller* hose,
+				      u8 bus, u8 devfn, u8 offset)
+{
+	if (bus == hose->first_busno) {
+		if (PCI_SLOT(devfn) == 0)
+			return 0;
+		return ((unsigned long)hose->cfg_data) + U3_HT_CFA0(devfn, offset);
+	} else
+		return ((unsigned long)hose->cfg_data) + U3_HT_CFA1(bus, devfn, offset);
+}
+
+static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
+			     int offset, int len, u32 *val)
+{
+	struct pci_controller *hose;
+	unsigned long addr;
+
+	hose = pci_bus_to_host(bus);
+	if (hose == NULL)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
+	if (!addr)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	/*
+	 * Note: the caller has already checked that offset is
+	 * suitably aligned and that len is 1, 2 or 4.
+	 */
+	switch (len) {
+	case 1:
+		*val = in_8((u8 *)addr);
+		break;
+	case 2:
+		*val = in_le16((u16 *)addr);
+		break;
+	default:
+		*val = in_le32((u32 *)addr);
+		break;
+	}
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,
+			      int offset, int len, u32 val)
+{
+	struct pci_controller *hose;
+	unsigned long addr;
+
+	hose = pci_bus_to_host(bus);
+	if (hose == NULL)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
+	if (!addr)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	/*
+	 * Note: the caller has already checked that offset is
+	 * suitably aligned and that len is 1, 2 or 4.
+	 */
+	switch (len) {
+	case 1:
+		out_8((u8 *)addr, val);
+		(void) in_8((u8 *)addr);
+		break;
+	case 2:
+		out_le16((u16 *)addr, val);
+		(void) in_le16((u16 *)addr);
+		break;
+	default:
+		out_le32((u32 *)addr, val);
+		(void) in_le32((u32 *)addr);
+		break;
+	}
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops u3_ht_pci_ops =
+{
+	u3_ht_read_config,
+	u3_ht_write_config
+};
+
+static void __init setup_u3_agp(struct pci_controller* hose)
+{
+	/* On G5, we move AGP up to high bus number so we don't need
+	 * to reassign bus numbers for HT. If we ever have P2P bridges
+	 * on AGP, we'll have to move pci_assign_all_busses to the
+	 * pci_controller structure so we enable it for AGP and not for
+	 * HT childs.
+	 * We hard code the address because of the different size of
+	 * the reg address cell, we shall fix that by killing struct
+	 * reg_property and using some accessor functions instead
+	 */
+       	hose->first_busno = 0xf0;
+	hose->last_busno = 0xff;
+	hose->ops = &u3_agp_pci_ops;
+	hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000);
+	hose->cfg_data = ioremap(0xf0000000 + 0xc00000, 0x1000);
+
+	u3_agp = hose;
+}
+
+static void __init setup_u3_ht(struct pci_controller* hose)
+{
+	hose->ops = &u3_ht_pci_ops;
+
+	/* We hard code the address because of the different size of
+	 * the reg address cell, we shall fix that by killing struct
+	 * reg_property and using some accessor functions instead
+	 */
+	hose->cfg_data = (volatile unsigned char *)ioremap(0xf2000000, 0x02000000);
+
+	hose->first_busno = 0;
+	hose->last_busno = 0xef;
+
+	u3_ht = hose;
+}
+
+static int __init add_bridge(struct device_node *dev)
+{
+	int len;
+	struct pci_controller *hose;
+	char* disp_name;
+	int *bus_range;
+	int primary = 1;
+ 	struct property *of_prop;
+
+	DBG("Adding PCI host bridge %s\n", dev->full_name);
+
+       	bus_range = (int *) get_property(dev, "bus-range", &len);
+       	if (bus_range == NULL || len < 2 * sizeof(int)) {
+       		printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
+       			       dev->full_name);
+       	}
+
+	hose = alloc_bootmem(sizeof(struct pci_controller));
+	if (hose == NULL)
+		return -ENOMEM;
+       	pci_setup_pci_controller(hose);
+
+       	hose->arch_data = dev;
+       	hose->first_busno = bus_range ? bus_range[0] : 0;
+       	hose->last_busno = bus_range ? bus_range[1] : 0xff;
+
+	of_prop = alloc_bootmem(sizeof(struct property) +
+				sizeof(hose->global_number));
+	if (of_prop) {
+		memset(of_prop, 0, sizeof(struct property));
+		of_prop->name = "linux,pci-domain";
+		of_prop->length = sizeof(hose->global_number);
+		of_prop->value = (unsigned char *)&of_prop[1];
+		memcpy(of_prop->value, &hose->global_number, sizeof(hose->global_number));
+		prom_add_property(dev, of_prop);
+	}
+
+	disp_name = NULL;
+       	if (device_is_compatible(dev, "u3-agp")) {
+       		setup_u3_agp(hose);
+       		disp_name = "U3-AGP";
+       		primary = 0;
+       	} else if (device_is_compatible(dev, "u3-ht")) {
+       		setup_u3_ht(hose);
+       		disp_name = "U3-HT";
+       		primary = 1;
+       	}
+       	printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",
+       		disp_name, hose->first_busno, hose->last_busno);
+
+       	/* Interpret the "ranges" property */
+       	/* This also maps the I/O region and sets isa_io/mem_base */
+       	pci_process_bridge_OF_ranges(hose, dev);
+	pci_setup_phb_io(hose, primary);
+
+       	/* Fixup "bus-range" OF property */
+       	fixup_bus_range(dev);
+
+	return 0;
+}
+
+
+void __init maple_pcibios_fixup(void)
+{
+	struct pci_dev *dev = NULL;
+
+	DBG(" -> maple_pcibios_fixup\n");
+
+	for_each_pci_dev(dev)
+		pci_read_irq_line(dev);
+
+	/* Do the mapping of the IO space */
+	phbs_remap_io();
+
+	/* Fixup the pci_bus sysdata pointers */
+	pci_fix_bus_sysdata();
+
+	/* Setup the iommu */
+	iommu_setup_u3();
+
+	DBG(" <- maple_pcibios_fixup\n");
+}
+
+static void __init maple_fixup_phb_resources(void)
+{
+	struct pci_controller *hose, *tmp;
+	
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
+		unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base;
+		hose->io_resource.start += offset;
+		hose->io_resource.end += offset;
+		printk(KERN_INFO "PCI Host %d, io start: %lx; io end: %lx\n",
+		       hose->global_number,
+		       hose->io_resource.start, hose->io_resource.end);
+	}
+}
+
+void __init maple_pci_init(void)
+{
+	struct device_node *np, *root;
+	struct device_node *ht = NULL;
+
+	/* Probe root PCI hosts, that is on U3 the AGP host and the
+	 * HyperTransport host. That one is actually "kept" around
+	 * and actually added last as it's resource management relies
+	 * on the AGP resources to have been setup first
+	 */
+	root = of_find_node_by_path("/");
+	if (root == NULL) {
+		printk(KERN_CRIT "maple_find_bridges: can't find root of device tree\n");
+		return;
+	}
+	for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {
+		if (np->name == NULL)
+			continue;
+		if (strcmp(np->name, "pci") == 0) {
+			if (add_bridge(np) == 0)
+				of_node_get(np);
+		}
+		if (strcmp(np->name, "ht") == 0) {
+			of_node_get(np);
+			ht = np;
+		}
+	}
+	of_node_put(root);
+
+	/* Now setup the HyperTransport host if we found any
+	 */
+	if (ht && add_bridge(ht) != 0)
+		of_node_put(ht);
+
+	/* Fixup the IO resources on our host bridges as the common code
+	 * does it only for childs of the host bridges
+	 */
+	maple_fixup_phb_resources();
+
+	/* Setup the linkage between OF nodes and PHBs */ 
+	pci_devs_phb_init();
+
+	/* Fixup the PCI<->OF mapping for U3 AGP due to bus renumbering. We
+	 * assume there is no P2P bridge on the AGP bus, which should be a
+	 * safe assumptions hopefully.
+	 */
+	if (u3_agp) {
+		struct device_node *np = u3_agp->arch_data;
+		np->busno = 0xf0;
+		for (np = np->child; np; np = np->sibling)
+			np->busno = 0xf0;
+	}
+
+	/* Tell pci.c to use the common resource allocation mecanism */
+	pci_probe_only = 0;
+	
+	/* Allow all IO */
+	io_page_mask = -1;
+}
+
+int maple_pci_get_legacy_ide_irq(struct pci_dev *pdev, int channel)
+{
+	struct device_node *np;
+	int irq = channel ? 15 : 14;
+
+	if (pdev->vendor != PCI_VENDOR_ID_AMD ||
+	    pdev->device != PCI_DEVICE_ID_AMD_8111_IDE)
+		return irq;
+
+	np = pci_device_to_OF_node(pdev);
+	if (np == NULL)
+		return irq;
+	if (np->n_intrs < 2)
+		return irq;
+	return np->intrs[channel & 0x1].line;
+}
+
+/* XXX: To remove once all firmwares are ok */
+static void fixup_maple_ide(struct pci_dev* dev)
+{
+#if 0 /* Enable this to enable IDE port 0 */
+	{
+		u8 v;
+
+		pci_read_config_byte(dev, 0x40, &v);
+		v |= 2;
+		pci_write_config_byte(dev, 0x40, v);
+	}
+#endif
+#if 0 /* fix bus master base */
+	pci_write_config_dword(dev, 0x20, 0xcc01);
+	printk("old ide resource: %lx -> %lx \n",
+	       dev->resource[4].start, dev->resource[4].end);
+	dev->resource[4].start = 0xcc00;
+	dev->resource[4].end = 0xcc10;
+#endif
+#if 1 /* Enable this to fixup IDE sense/polarity of irqs in IO-APICs */
+	{
+		struct pci_dev *apicdev;
+		u32 v;
+
+		apicdev = pci_get_slot (dev->bus, PCI_DEVFN(5,0));
+		if (apicdev == NULL)
+			printk("IDE Fixup IRQ: Can't find IO-APIC !\n");
+		else {
+			pci_write_config_byte(apicdev, 0xf2, 0x10 + 2*14);
+			pci_read_config_dword(apicdev, 0xf4, &v);
+			v &= ~0x00000022;
+			pci_write_config_dword(apicdev, 0xf4, v);
+			pci_write_config_byte(apicdev, 0xf2, 0x10 + 2*15);
+			pci_read_config_dword(apicdev, 0xf4, &v);
+			v &= ~0x00000022;
+			pci_write_config_dword(apicdev, 0xf4, v);
+			pci_dev_put(apicdev);
+		}
+	}
+#endif
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_IDE,
+			 fixup_maple_ide);
diff -Nru a/arch/ppc64/kernel/maple_setup.c b/arch/ppc64/kernel/maple_setup.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/kernel/maple_setup.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,241 @@
+/*
+ *  arch/ppc64/kernel/maple_setup.c
+ *
+ *  (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org),
+ *                     IBM Corp. 
+ *
+ *  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.
+ *
+ */
+
+#define DEBUG
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/stddef.h>
+#include <linux/unistd.h>
+#include <linux/ptrace.h>
+#include <linux/slab.h>
+#include <linux/user.h>
+#include <linux/a.out.h>
+#include <linux/tty.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/major.h>
+#include <linux/initrd.h>
+#include <linux/vt_kern.h>
+#include <linux/console.h>
+#include <linux/ide.h>
+#include <linux/pci.h>
+#include <linux/adb.h>
+#include <linux/cuda.h>
+#include <linux/pmu.h>
+#include <linux/irq.h>
+#include <linux/seq_file.h>
+#include <linux/root_dev.h>
+#include <linux/serial.h>
+#include <linux/smp.h>
+
+#include <asm/processor.h>
+#include <asm/sections.h>
+#include <asm/prom.h>
+#include <asm/system.h>
+#include <asm/pgtable.h>
+#include <asm/bitops.h>
+#include <asm/io.h>
+#include <asm/pci-bridge.h>
+#include <asm/iommu.h>
+#include <asm/machdep.h>
+#include <asm/dma.h>
+#include <asm/cputable.h>
+#include <asm/time.h>
+#include <asm/of_device.h>
+#include <asm/lmb.h>
+
+#include "mpic.h"
+
+#ifdef DEBUG
+#define DBG(fmt...) udbg_printf(fmt)
+#else
+#define DBG(fmt...)
+#endif
+
+extern int maple_set_rtc_time(struct rtc_time *tm);
+extern void maple_get_rtc_time(struct rtc_time *tm);
+extern void maple_get_boot_time(struct rtc_time *tm);
+extern void maple_calibrate_decr(void);
+extern void maple_pci_init(void);
+extern void maple_pcibios_fixup(void);
+extern int maple_pci_get_legacy_ide_irq(struct pci_dev *dev, int channel);
+extern void generic_find_legacy_serial_ports(unsigned int *default_speed);
+
+
+static void maple_restart(char *cmd)
+{
+}
+
+static void maple_power_off(void)
+{
+}
+
+static void maple_halt(void)
+{
+}
+
+#ifdef CONFIG_SMP
+struct smp_ops_t maple_smp_ops = {
+	.probe		= smp_mpic_probe,
+	.message_pass	= smp_mpic_message_pass,
+	.kick_cpu	= smp_generic_kick_cpu,
+	.setup_cpu	= smp_mpic_setup_cpu,
+	.give_timebase	= smp_generic_give_timebase,
+	.take_timebase	= smp_generic_take_timebase,
+};
+#endif /* CONFIG_SMP */
+
+void __init maple_setup_arch(void)
+{
+	/* init to some ~sane value until calibrate_delay() runs */
+	loops_per_jiffy = 50000000;
+
+	/* Setup SMP callback */
+#ifdef CONFIG_SMP
+	smp_ops = &maple_smp_ops;
+#endif
+	/* Setup the PCI DMA to "direct" by default. May be overriden
+	 * by iommu later on
+	 */
+	pci_dma_init_direct();
+
+	/* Lookup PCI hosts */
+       	maple_pci_init();
+
+#ifdef CONFIG_DUMMY_CONSOLE
+	conswitchp = &dummy_con;
+#endif
+}
+
+/* 
+ * Early initialization.
+ */
+static void __init maple_init_early(void)
+{
+	unsigned int default_speed;
+
+	DBG(" -> maple_init_early\n");
+
+	/* Initialize hash table, from now on, we can take hash faults
+	 * and call ioremap
+	 */
+	hpte_init_native();
+
+	/* Find the serial port */
+       	generic_find_legacy_serial_ports(&default_speed);
+
+	DBG("naca->serialPortAddr: %lx\n", (long)naca->serialPortAddr);
+
+	if (naca->serialPortAddr) {
+		void *comport;
+		/* Map the uart for udbg. */
+		comport = (void *)__ioremap(naca->serialPortAddr, 16, _PAGE_NO_CACHE);
+		udbg_init_uart(comport, default_speed);
+
+		ppc_md.udbg_putc = udbg_putc;
+		ppc_md.udbg_getc = udbg_getc;
+		ppc_md.udbg_getc_poll = udbg_getc_poll;
+		DBG("Hello World !\n");
+	}
+
+	/* Setup interrupt mapping options */
+	naca->interrupt_controller = IC_OPEN_PIC;
+
+	DBG(" <- maple_init_early\n");
+}
+
+
+static __init void maple_init_IRQ(void)
+{
+	struct device_node *root;
+	unsigned int *opprop;
+	unsigned long opic_addr;
+	struct mpic *mpic;
+	unsigned char senses[128];
+	int n;
+
+	DBG(" -> maple_init_IRQ\n");
+
+	/* XXX: Non standard, replace that with a proper openpic/mpic node
+	 * in the device-tree. Find the Open PIC if present */
+	root = of_find_node_by_path("/");
+	opprop = (unsigned int *) get_property(root,
+				"platform-open-pic", NULL);
+	if (opprop == 0)
+		panic("OpenPIC not found !\n");
+
+	n = prom_n_addr_cells(root);
+	for (opic_addr = 0; n > 0; --n)
+		opic_addr = (opic_addr << 32) + *opprop++;
+	of_node_put(root);
+
+	/* Obtain sense values from device-tree */
+	prom_get_irq_senses(senses, 0, 128);
+
+	mpic = mpic_alloc(opic_addr,
+			  MPIC_PRIMARY | MPIC_BIG_ENDIAN |
+			  MPIC_BROKEN_U3 | MPIC_WANTS_RESET,
+			  0, 0, 128, 128, senses, 128, "U3-MPIC");
+	BUG_ON(mpic == NULL);
+	mpic_init(mpic);
+
+	DBG(" <- maple_init_IRQ\n");
+}
+
+static void __init maple_progress(char *s, unsigned short hex)
+{
+	printk("*** %04x : %s\n", hex, s ? s : "");
+}
+
+
+/*
+ * Called very early, MMU is off, device-tree isn't unflattened
+ */
+static int __init maple_probe(int platform)
+{
+	if (platform != PLATFORM_MAPLE)
+		return 0;
+	/*
+	 * On U3, the DART (iommu) must be allocated now since it
+	 * has an impact on htab_initialize (due to the large page it
+	 * occupies having to be broken up so the DART itself is not
+	 * part of the cacheable linar mapping
+	 */
+	alloc_u3_dart_table();
+
+	return 1;
+}
+
+struct machdep_calls __initdata maple_md = {
+	.probe			= maple_probe,
+	.setup_arch		= maple_setup_arch,
+	.init_early		= maple_init_early,
+	.init_IRQ		= maple_init_IRQ,
+	.get_irq		= mpic_get_irq,
+	.pcibios_fixup		= maple_pcibios_fixup,
+	.pci_get_legacy_ide_irq	= maple_pci_get_legacy_ide_irq,
+	.restart		= maple_restart,
+	.power_off		= maple_power_off,
+	.halt			= maple_halt,
+       	.get_boot_time		= maple_get_boot_time,
+       	.set_rtc_time		= maple_set_rtc_time,
+       	.get_rtc_time		= maple_get_rtc_time,
+      	.calibrate_decr		= maple_calibrate_decr,
+	.progress		= maple_progress,
+};
diff -Nru a/arch/ppc64/kernel/maple_time.c b/arch/ppc64/kernel/maple_time.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/kernel/maple_time.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,226 @@
+/*
+ *  arch/ppc64/kernel/maple_time.c
+ *
+ *  (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org),
+ *                     IBM Corp. 
+ *
+ *  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.
+ *
+ */
+
+#undef DEBUG
+
+#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/init.h>
+#include <linux/time.h>
+#include <linux/adb.h>
+#include <linux/pmu.h>
+#include <linux/interrupt.h>
+#include <linux/mc146818rtc.h>
+#include <linux/bcd.h>
+
+#include <asm/sections.h>
+#include <asm/prom.h>
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/machdep.h>
+#include <asm/time.h>
+
+#ifdef DEBUG
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+extern void setup_default_decr(void);
+extern void GregorianDay(struct rtc_time * tm);
+
+extern unsigned long ppc_tb_freq;
+extern unsigned long ppc_proc_freq;
+static int maple_rtc_addr;
+
+static int maple_clock_read(int addr)
+{
+	outb_p(addr, maple_rtc_addr);
+	return inb_p(maple_rtc_addr+1);
+}
+
+static void maple_clock_write(unsigned long val, int addr)
+{
+	outb_p(addr, maple_rtc_addr);
+	outb_p(val, maple_rtc_addr+1);
+}
+
+void maple_get_rtc_time(struct rtc_time *tm)
+{
+	int uip, i;
+
+	/* The Linux interpretation of the CMOS clock register contents:
+	 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
+	 * RTC registers show the second which has precisely just started.
+	 * Let's hope other operating systems interpret the RTC the same way.
+	 */
+
+	/* Since the UIP flag is set for about 2.2 ms and the clock
+	 * is typically written with a precision of 1 jiffy, trying
+	 * to obtain a precision better than a few milliseconds is
+	 * an illusion. Only consistency is interesting, this also
+	 * allows to use the routine for /dev/rtc without a potential
+	 * 1 second kernel busy loop triggered by any reader of /dev/rtc.
+	 */
+
+	for (i = 0; i<1000000; i++) {
+		uip = maple_clock_read(RTC_FREQ_SELECT);
+		tm->tm_sec = maple_clock_read(RTC_SECONDS);
+		tm->tm_min = maple_clock_read(RTC_MINUTES);
+		tm->tm_hour = maple_clock_read(RTC_HOURS);
+		tm->tm_mday = maple_clock_read(RTC_DAY_OF_MONTH);
+		tm->tm_mon = maple_clock_read(RTC_MONTH);
+		tm->tm_year = maple_clock_read(RTC_YEAR);
+		uip |= maple_clock_read(RTC_FREQ_SELECT);
+		if ((uip & RTC_UIP)==0)
+			break;
+	}
+
+	if (!(maple_clock_read(RTC_CONTROL) & RTC_DM_BINARY)
+	    || RTC_ALWAYS_BCD) {
+		BCD_TO_BIN(tm->tm_sec);
+		BCD_TO_BIN(tm->tm_min);
+		BCD_TO_BIN(tm->tm_hour);
+		BCD_TO_BIN(tm->tm_mday);
+		BCD_TO_BIN(tm->tm_mon);
+		BCD_TO_BIN(tm->tm_year);
+	  }
+	if ((tm->tm_year + 1900) < 1970)
+		tm->tm_year += 100;
+
+	GregorianDay(tm);
+}
+
+int maple_set_rtc_time(struct rtc_time *tm)
+{
+	unsigned char save_control, save_freq_select;
+	int sec, min, hour, mon, mday, year;
+
+	spin_lock(&rtc_lock);
+
+	save_control = maple_clock_read(RTC_CONTROL); /* tell the clock it's being set */
+
+	maple_clock_write((save_control|RTC_SET), RTC_CONTROL);
+
+	save_freq_select = maple_clock_read(RTC_FREQ_SELECT); /* stop and reset prescaler */
+
+	maple_clock_write((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
+
+	sec = tm->tm_sec;
+	min = tm->tm_min;
+	hour = tm->tm_hour;
+	mon = tm->tm_mon;
+	mday = tm->tm_mday;
+	year = tm->tm_year;
+
+	if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
+		BIN_TO_BCD(sec);
+		BIN_TO_BCD(min);
+		BIN_TO_BCD(hour);
+		BIN_TO_BCD(mon);
+		BIN_TO_BCD(mday);
+		BIN_TO_BCD(year);
+	}
+	maple_clock_write(sec, RTC_SECONDS);
+	maple_clock_write(min, RTC_MINUTES);
+	maple_clock_write(hour, RTC_HOURS);
+	maple_clock_write(mon, RTC_MONTH);
+	maple_clock_write(mday, RTC_DAY_OF_MONTH);
+	maple_clock_write(year, RTC_YEAR);
+
+	/* The following flags have to be released exactly in this order,
+	 * otherwise the DS12887 (popular MC146818A clone with integrated
+	 * battery and quartz) will not reset the oscillator and will not
+	 * 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
+	 */
+	maple_clock_write(save_control, RTC_CONTROL);
+	maple_clock_write(save_freq_select, RTC_FREQ_SELECT);
+
+	spin_unlock(&rtc_lock);
+
+	return 0;
+}
+
+void __init maple_get_boot_time(struct rtc_time *tm)
+{
+	struct device_node *rtcs;
+
+	rtcs = find_compatible_devices("rtc", "pnpPNP,b00");
+	if (rtcs && rtcs->addrs) {
+		maple_rtc_addr = rtcs->addrs[0].address;
+		printk(KERN_INFO "Maple: Found RTC at 0x%x\n", maple_rtc_addr);
+	} else {
+		maple_rtc_addr = RTC_PORT(0); /* legacy address */
+		printk(KERN_INFO "Maple: No device node for RTC, assuming "
+		       "legacy address (0x%x)\n", maple_rtc_addr);
+	}
+	
+	maple_get_rtc_time(tm);
+}
+
+/* XXX FIXME: Some sane defaults: 125 MHz timebase, 1GHz processor */
+#define DEFAULT_TB_FREQ		125000000UL
+#define DEFAULT_PROC_FREQ	(DEFAULT_TB_FREQ * 8)
+
+void __init maple_calibrate_decr(void)
+{
+	struct device_node *cpu;
+	struct div_result divres;
+	unsigned int *fp = NULL;
+
+	/*
+	 * The cpu node should have a timebase-frequency property
+	 * to tell us the rate at which the decrementer counts.
+	 */
+	cpu = of_find_node_by_type(NULL, "cpu");
+
+	ppc_tb_freq = DEFAULT_TB_FREQ;
+	if (cpu != 0)
+		fp = (unsigned int *)get_property(cpu, "timebase-frequency", NULL);
+	if (fp != NULL)
+		ppc_tb_freq = *fp;
+	else
+		printk(KERN_ERR "WARNING: Estimating decrementer frequency (not found)\n");
+	fp = NULL;
+	ppc_proc_freq = DEFAULT_PROC_FREQ;
+	if (cpu != 0)
+		fp = (unsigned int *)get_property(cpu, "clock-frequency", NULL);
+	if (fp != NULL)
+		ppc_proc_freq = *fp;
+	else
+		printk(KERN_ERR "WARNING: Estimating processor frequency (not found)\n");
+
+	of_node_put(cpu);
+
+	printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n",
+	       ppc_tb_freq/1000000, ppc_tb_freq%1000000);
+	printk(KERN_INFO "time_init: processor frequency   = %lu.%.6lu MHz\n",
+	       ppc_proc_freq/1000000, ppc_proc_freq%1000000);
+
+	tb_ticks_per_jiffy = ppc_tb_freq / HZ;
+	tb_ticks_per_sec = tb_ticks_per_jiffy * HZ;
+	tb_ticks_per_usec = ppc_tb_freq / 1000000;
+	tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000);
+	div128_by_32(1024*1024, 0, tb_ticks_per_sec, &divres);
+	tb_to_xs = divres.result_low;
+
+	setup_default_decr();
+}
diff -Nru a/arch/ppc64/kernel/mf.c b/arch/ppc64/kernel/mf.c
--- a/arch/ppc64/kernel/mf.c	2004-12-24 13:37:04 -08:00
+++ b/arch/ppc64/kernel/mf.c	2004-12-24 13:37:04 -08:00
@@ -1,6 +1,7 @@
 /*
   * mf.c
   * Copyright (C) 2001 Troy D. Armstrong  IBM Corporation
+  * Copyright (C) 2004 Stephen Rothwell  IBM Corporation
   *
   * This modules exists as an interface between a Linux secondary partition
   * running on an iSeries and the primary partition's Virtual Service
@@ -8,52 +9,44 @@
   * all partitions in the iSeries.  It also provides miscellaneous low-level
   * machine facility type operations.
   *
-  * 
+  *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
-  * 
+  *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
-  * 
+  *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
   */
 
-#include <asm/iSeries/mf.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/mm.h>
-#include <linux/module.h>
 #include <linux/completion.h>
-#include <asm/iSeries/HvLpConfig.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
-#include <asm/nvram.h>
-#include <asm/time.h>
-#include <asm/iSeries/ItSpCommArea.h>
-#include <asm/uaccess.h>
 #include <linux/dma-mapping.h>
 #include <linux/bcd.h>
+
+#include <asm/time.h>
+#include <asm/uaccess.h>
 #include <asm/iSeries/vio.h>
+#include <asm/iSeries/mf.h>
+#include <asm/iSeries/HvLpConfig.h>
+#include <asm/iSeries/ItSpCommArea.h>
 
 /*
  * This is the structure layout for the Machine Facilites LPAR event
  * flows.
  */
-union safe_cast {
-	u64 ptr_as_u64;
-	void *ptr;
-};
-
-struct VspCmdData {
-	union safe_cast token;
+struct vsp_cmd_data {
+	u64 token;
 	u16 cmd;
 	HvLpIndex lp_index;
 	u8 result_code;
@@ -81,12 +74,12 @@
 	} sub_data;
 };
 
-struct VspRspData {
+struct vsp_rsp_data {
 	struct completion com;
-	struct VspCmdData *response;
+	struct vsp_cmd_data *response;
 };
 
-struct AllocData {
+struct alloc_data {
 	u16 size;
 	u16 type;
 	u32 count;
@@ -95,30 +88,30 @@
 	HvLpIndex target_lp;
 };
 
-struct CeMsgData;
+struct ce_msg_data;
 
-typedef void (*CeMsgCompleteHandler)(void *token, struct CeMsgData *vspCmdRsp);
+typedef void (*ce_msg_comp_hdlr)(void *token, struct ce_msg_data *vsp_cmd_rsp);
 
-struct CeMsgCompleteData {
-	CeMsgCompleteHandler handler;
+struct ce_msg_comp_data {
+	ce_msg_comp_hdlr handler;
 	void *token;
 };
 
-struct CeMsgData {
+struct ce_msg_data {
 	u8 ce_msg[12];
 	char reserved[4];
-	struct CeMsgCompleteData *completion;
+	struct ce_msg_comp_data *completion;
 };
 
-struct IoMFLpEvent {
+struct io_mf_lp_event {
 	struct HvLpEvent hp_lp_event;
 	u16 subtype_result_code;
 	u16 reserved1;
 	u32 reserved2;
 	union {
-		struct AllocData alloc;
-		struct CeMsgData ce_msg;
-		struct VspCmdData vsp_cmd;
+		struct alloc_data alloc;
+		struct ce_msg_data ce_msg;
+		struct vsp_cmd_data vsp_cmd;
 	} data;
 };
 
@@ -134,7 +127,7 @@
  */
 struct pending_event {
 	struct pending_event *next;
-	struct IoMFLpEvent event;
+	struct io_mf_lp_event event;
 	MFCompleteHandler hdlr;
 	char dma_data[72];
 	unsigned dma_data_length;
@@ -172,7 +165,7 @@
 	unsigned long flags;
 	int go = 1;
 	struct pending_event *ev1;
-	HvLpEvent_Rc hvRc;
+	HvLpEvent_Rc hv_rc;
 
 	/* enqueue the event */
 	if (ev != NULL) {
@@ -199,11 +192,11 @@
 					pending_event_head->dma_data_length,
 					HvLpDma_Direction_LocalToRemote);
 
-		hvRc = HvCallEvent_signalLpEvent(
+		hv_rc = HvCallEvent_signalLpEvent(
 				&pending_event_head->event.hp_lp_event);
-		if (hvRc != HvLpEvent_Rc_Good) {
-			printk(KERN_ERR "mf.c: HvCallEvent_signalLpEvent() failed with %d\n",
-					(int)hvRc);
+		if (hv_rc != HvLpEvent_Rc_Good) {
+			printk(KERN_ERR "mf.c: HvCallEvent_signalLpEvent() "
+					"failed with %d\n", (int)hv_rc);
 
 			spin_lock_irqsave(&pending_event_spinlock, flags);
 			ev1 = pending_event_head;
@@ -214,12 +207,8 @@
 
 			if (ev1 == ev)
 				rc = -EIO;
-			else if (ev1->hdlr != NULL) {
-				union safe_cast mySafeCast;
-
-				mySafeCast.ptr_as_u64 = ev1->event.hp_lp_event.xCorrelationToken;
-				(*ev1->hdlr)(mySafeCast.ptr, -EIO);
-			}
+			else if (ev1->hdlr != NULL)
+				(*ev1->hdlr)((void *)ev1->event.hp_lp_event.xCorrelationToken, -EIO);
 
 			spin_lock_irqsave(&pending_event_spinlock, flags);
 			free_pending_event(ev1);
@@ -236,7 +225,7 @@
 static struct pending_event *new_pending_event(void)
 {
 	struct pending_event *ev = NULL;
-	HvLpIndex primaryLp = HvLpConfig_getPrimaryLpIndex();
+	HvLpIndex primary_lp = HvLpConfig_getPrimaryLpIndex();
 	unsigned long flags;
 	struct HvLpEvent *hev;
 
@@ -246,12 +235,13 @@
 		pending_event_avail = pending_event_avail->next;
 	}
 	spin_unlock_irqrestore(&pending_event_spinlock, flags);
-	if (ev == NULL)
-		ev = kmalloc(sizeof(struct pending_event),GFP_ATOMIC);
 	if (ev == NULL) {
-		printk(KERN_ERR "mf.c: unable to kmalloc %ld bytes\n",
-				sizeof(struct pending_event));
-		return NULL;
+		ev = kmalloc(sizeof(struct pending_event), GFP_ATOMIC);
+		if (ev == NULL) {
+			printk(KERN_ERR "mf.c: unable to kmalloc %ld bytes\n",
+					sizeof(struct pending_event));
+			return NULL;
+		}
 	}
 	memset(ev, 0, sizeof(struct pending_event));
 	hev = &ev->event.hp_lp_event;
@@ -261,38 +251,38 @@
 	hev->xFlags.xFunction = HvLpEvent_Function_Int;
 	hev->xType = HvLpEvent_Type_MachineFac;
 	hev->xSourceLp = HvLpConfig_getLpIndex();
-	hev->xTargetLp = primaryLp;
-	hev->xSizeMinus1 = sizeof(ev->event)-1;
+	hev->xTargetLp = primary_lp;
+	hev->xSizeMinus1 = sizeof(ev->event) - 1;
 	hev->xRc = HvLpEvent_Rc_Good;
-	hev->xSourceInstanceId = HvCallEvent_getSourceLpInstanceId(primaryLp,
+	hev->xSourceInstanceId = HvCallEvent_getSourceLpInstanceId(primary_lp,
 			HvLpEvent_Type_MachineFac);
-	hev->xTargetInstanceId = HvCallEvent_getTargetLpInstanceId(primaryLp,
+	hev->xTargetInstanceId = HvCallEvent_getTargetLpInstanceId(primary_lp,
 			HvLpEvent_Type_MachineFac);
 
 	return ev;
 }
 
-static int signal_vsp_instruction(struct VspCmdData *vspCmd)
+static int signal_vsp_instruction(struct vsp_cmd_data *vsp_cmd)
 {
 	struct pending_event *ev = new_pending_event();
 	int rc;
-	struct VspRspData response;
+	struct vsp_rsp_data response;
 
 	if (ev == NULL)
 		return -ENOMEM;
 
 	init_completion(&response.com);
-	response.response = vspCmd;
+	response.response = vsp_cmd;
 	ev->event.hp_lp_event.xSubtype = 6;
 	ev->event.hp_lp_event.x.xSubtypeData =
 		subtype_data('M', 'F',  'V',  'I');
-	ev->event.data.vsp_cmd.token.ptr = &response;
-	ev->event.data.vsp_cmd.cmd = vspCmd->cmd;
+	ev->event.data.vsp_cmd.token = (u64)&response;
+	ev->event.data.vsp_cmd.cmd = vsp_cmd->cmd;
 	ev->event.data.vsp_cmd.lp_index = HvLpConfig_getLpIndex();
 	ev->event.data.vsp_cmd.result_code = 0xFF;
 	ev->event.data.vsp_cmd.reserved = 0;
 	memcpy(&(ev->event.data.vsp_cmd.sub_data),
-			&(vspCmd->sub_data), sizeof(vspCmd->sub_data));
+			&(vsp_cmd->sub_data), sizeof(vsp_cmd->sub_data));
 	mb();
 
 	rc = signal_event(ev);
@@ -305,7 +295,7 @@
 /*
  * Send a 12-byte CE message to the primary partition VSP object
  */
-static int signal_ce_msg(char *ce_msg, struct CeMsgCompleteData *completion)
+static int signal_ce_msg(char *ce_msg, struct ce_msg_comp_data *completion)
 {
 	struct pending_event *ev = new_pending_event();
 
@@ -321,10 +311,22 @@
 }
 
 /*
+ * Send a 12-byte CE message (with no data) to the primary partition VSP object
+ */
+static int signal_ce_msg_simple(u8 ce_op, struct ce_msg_comp_data *completion)
+{
+	u8 ce_msg[12];
+
+	memset(ce_msg, 0, sizeof(ce_msg));
+	ce_msg[3] = ce_op;
+	return signal_ce_msg(ce_msg, completion);
+}
+
+/*
  * Send a 12-byte CE message and DMA data to the primary partition VSP object
  */
 static int dma_and_signal_ce_msg(char *ce_msg,
-		struct CeMsgCompleteData *completion, void *dma_data,
+		struct ce_msg_comp_data *completion, void *dma_data,
 		unsigned dma_data_length, unsigned remote_address)
 {
 	struct pending_event *ev = new_pending_event();
@@ -356,7 +358,7 @@
 	if (rc) {
 		printk(KERN_ALERT "mf.c: SIGINT to init failed (%d), "
 				"hard shutdown commencing\n", rc);
-		mf_powerOff();
+		mf_power_off();
 	} else
 		printk(KERN_INFO "mf.c: init has been successfully notified "
 				"to proceed with shutdown\n");
@@ -367,10 +369,12 @@
  * The primary partition VSP object is sending us a new
  * event flow.  Handle it...
  */
-static void intReceived(struct IoMFLpEvent *event)
+static void handle_int(struct io_mf_lp_event *event)
 {
-	int freeIt = 0;
-	struct pending_event *two = NULL;
+	struct ce_msg_data *ce_msg_data;
+	struct ce_msg_data *pce_msg_data;
+	unsigned long flags;
+	struct pending_event *pev;
 
 	/* ack the interrupt */
 	event->hp_lp_event.xRc = HvLpEvent_Rc_Good;
@@ -379,49 +383,42 @@
 	/* process interrupt */
 	switch (event->hp_lp_event.xSubtype) {
 	case 0:	/* CE message */
-		switch (event->data.ce_msg.ce_msg[3]) {
+		ce_msg_data = &event->data.ce_msg;
+		switch (ce_msg_data->ce_msg[3]) {
 		case 0x5B:	/* power control notification */
-			if ((event->data.ce_msg.ce_msg[5] & 0x20) != 0) {
+			if ((ce_msg_data->ce_msg[5] & 0x20) != 0) {
 				printk(KERN_INFO "mf.c: Commencing partition shutdown\n");
 				if (shutdown() == 0)
-					signal_ce_msg("\x00\x00\x00\xDB\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
+					signal_ce_msg_simple(0xDB, NULL);
 			}
 			break;
 		case 0xC0:	/* get time */
-			if ((pending_event_head == NULL) ||
-			    (pending_event_head->event.data.ce_msg.ce_msg[3]
-			     != 0x40))
+			spin_lock_irqsave(&pending_event_spinlock, flags);
+			pev = pending_event_head;
+			if (pev != NULL)
+				pending_event_head = pending_event_head->next;
+			spin_unlock_irqrestore(&pending_event_spinlock, flags);
+			if (pev == NULL)
 				break;
-			freeIt = 1;
-			if (pending_event_head->event.data.ce_msg.completion != 0) {
-				CeMsgCompleteHandler handler = pending_event_head->event.data.ce_msg.completion->handler;
-				void *token = pending_event_head->event.data.ce_msg.completion->token;
+			pce_msg_data = &pev->event.data.ce_msg;
+			if (pce_msg_data->ce_msg[3] != 0x40)
+				break;
+			if (pce_msg_data->completion != NULL) {
+				ce_msg_comp_hdlr handler =
+					pce_msg_data->completion->handler;
+				void *token = pce_msg_data->completion->token;
 
 				if (handler != NULL)
-					(*handler)(token, &(event->data.ce_msg));
+					(*handler)(token, ce_msg_data);
 			}
-			break;
-		}
-
-		/* remove from queue */
-		if (freeIt == 1) {
-			unsigned long flags;
-
 			spin_lock_irqsave(&pending_event_spinlock, flags);
-			if (pending_event_head != NULL) {
-				struct pending_event *oldHead =
-					pending_event_head;
-
-				pending_event_head = pending_event_head->next;
-				two = pending_event_head;
-				free_pending_event(oldHead);
-			}
+			free_pending_event(pev);
 			spin_unlock_irqrestore(&pending_event_spinlock, flags);
+			/* send next waiting event */
+			if (pending_event_head != NULL)
+				signal_event(NULL);
+			break;
 		}
-
-		/* send next waiting event */
-		if (two != NULL)
-			signal_event(NULL);
 		break;
 	case 1:	/* IT sys shutdown */
 		printk(KERN_INFO "mf.c: Commencing system shutdown\n");
@@ -435,68 +432,70 @@
  * of a flow we sent to them.  If there are other flows queued
  * up, we must send another one now...
  */
-static void ackReceived(struct IoMFLpEvent *event)
+static void handle_ack(struct io_mf_lp_event *event)
 {
 	unsigned long flags;
-	struct pending_event * two = NULL;
-	unsigned long freeIt = 0;
+	struct pending_event *two = NULL;
+	unsigned long free_it = 0;
+	struct ce_msg_data *ce_msg_data;
+	struct ce_msg_data *pce_msg_data;
+	struct vsp_rsp_data *rsp;
 
 	/* handle current event */
-	if (pending_event_head != NULL) {
-		switch (event->hp_lp_event.xSubtype) {
-		case 0:     /* CE msg */
-			if (event->data.ce_msg.ce_msg[3] == 0x40) {
-				if (event->data.ce_msg.ce_msg[2] != 0) {
-					freeIt = 1;
-					if (pending_event_head->event.data.ce_msg.completion
-							!= 0) {
-						CeMsgCompleteHandler handler = pending_event_head->event.data.ce_msg.completion->handler;
-						void *token = pending_event_head->event.data.ce_msg.completion->token;
-
-						if (handler != NULL)
-							(*handler)(token, &(event->data.ce_msg));
-					}
-				}
-			} else
-				freeIt = 1;
-			break;
-		case 4:	/* allocate */
-		case 5:	/* deallocate */
-			if (pending_event_head->hdlr != NULL) {
-				union safe_cast mySafeCast;
+	if (pending_event_head == NULL) {
+		printk(KERN_ERR "mf.c: stack empty for receiving ack\n");
+		return;
+	}
 
-				mySafeCast.ptr_as_u64 = event->hp_lp_event.xCorrelationToken;
-				(*pending_event_head->hdlr)(mySafeCast.ptr, event->data.alloc.count);
-			}
-			freeIt = 1;
+	switch (event->hp_lp_event.xSubtype) {
+	case 0:     /* CE msg */
+		ce_msg_data = &event->data.ce_msg;
+		if (ce_msg_data->ce_msg[3] != 0x40) {
+			free_it = 1;
 			break;
-		case 6:
-			{
-				struct VspRspData *rsp = (struct VspRspData *)event->data.vsp_cmd.token.ptr;
-
-				if (rsp != NULL) {
-					if (rsp->response != NULL)
-						memcpy(rsp->response, &(event->data.vsp_cmd), sizeof(event->data.vsp_cmd));
-					complete(&rsp->com);
-				} else
-					printk(KERN_ERR "mf.c: no rsp\n");
-				freeIt = 1;
-			}
+		}
+		if (ce_msg_data->ce_msg[2] == 0)
 			break;
+		free_it = 1;
+		pce_msg_data = &pending_event_head->event.data.ce_msg;
+		if (pce_msg_data->completion != NULL) {
+			ce_msg_comp_hdlr handler =
+				pce_msg_data->completion->handler;
+			void *token = pce_msg_data->completion->token;
+
+			if (handler != NULL)
+				(*handler)(token, ce_msg_data);
 		}
+		break;
+	case 4:	/* allocate */
+	case 5:	/* deallocate */
+		if (pending_event_head->hdlr != NULL)
+			(*pending_event_head->hdlr)((void *)event->hp_lp_event.xCorrelationToken, event->data.alloc.count);
+		free_it = 1;
+		break;
+	case 6:
+		free_it = 1;
+		rsp = (struct vsp_rsp_data *)event->data.vsp_cmd.token;
+		if (rsp == NULL) {
+			printk(KERN_ERR "mf.c: no rsp\n");
+			break;
+		}
+		if (rsp->response != NULL)
+			memcpy(rsp->response, &event->data.vsp_cmd,
+					sizeof(event->data.vsp_cmd));
+		complete(&rsp->com);
+		break;
 	}
-	else
-		printk(KERN_ERR "mf.c: stack empty for receiving ack\n");
 
 	/* remove from queue */
 	spin_lock_irqsave(&pending_event_spinlock, flags);
-	if ((pending_event_head != NULL) && (freeIt == 1)) {
+	if ((pending_event_head != NULL) && (free_it == 1)) {
 		struct pending_event *oldHead = pending_event_head;
 
 		pending_event_head = pending_event_head->next;
 		two = pending_event_head;
 		free_pending_event(oldHead);
-	} 
+	}
 	spin_unlock_irqrestore(&pending_event_spinlock, flags);
 
 	/* send next waiting event */
@@ -510,15 +509,15 @@
  * parse it enough to know if it is an interrupt or an
  * acknowledge.
  */
-static void hvHandler(struct HvLpEvent *event, struct pt_regs *regs)
+static void hv_handler(struct HvLpEvent *event, struct pt_regs *regs)
 {
 	if ((event != NULL) && (event->xType == HvLpEvent_Type_MachineFac)) {
 		switch(event->xFlags.xFunction) {
 		case HvLpEvent_Function_Ack:
-			ackReceived((struct IoMFLpEvent *)event);
+			handle_ack((struct io_mf_lp_event *)event);
 			break;
 		case HvLpEvent_Function_Int:
-			intReceived((struct IoMFLpEvent *)event);
+			handle_int((struct io_mf_lp_event *)event);
 			break;
 		default:
 			printk(KERN_ERR "mf.c: non ack/int event received\n");
@@ -532,9 +531,9 @@
  * Global kernel interface to allocate and seed events into the
  * Hypervisor.
  */
-void mf_allocateLpEvents(HvLpIndex targetLp, HvLpEvent_Type type,
+void mf_allocate_lp_events(HvLpIndex target_lp, HvLpEvent_Type type,
 		unsigned size, unsigned count, MFCompleteHandler hdlr,
-		void *userToken)
+		void *user_token)
 {
 	struct pending_event *ev = new_pending_event();
 	int rc;
@@ -542,14 +541,11 @@
 	if (ev == NULL) {
 		rc = -ENOMEM;
 	} else {
-		union safe_cast mine;
-
-		mine.ptr = userToken;
 		ev->event.hp_lp_event.xSubtype = 4;
-		ev->event.hp_lp_event.xCorrelationToken = mine.ptr_as_u64;
+		ev->event.hp_lp_event.xCorrelationToken = (u64)user_token;
 		ev->event.hp_lp_event.x.xSubtypeData =
 			subtype_data('M', 'F', 'M', 'A');
-		ev->event.data.alloc.target_lp = targetLp;
+		ev->event.data.alloc.target_lp = target_lp;
 		ev->event.data.alloc.type = type;
 		ev->event.data.alloc.size = size;
 		ev->event.data.alloc.count = count;
@@ -557,16 +553,16 @@
 		rc = signal_event(ev);
 	}
 	if ((rc != 0) && (hdlr != NULL))
-		(*hdlr)(userToken, rc);
+		(*hdlr)(user_token, rc);
 }
-EXPORT_SYMBOL(mf_allocateLpEvents);
+EXPORT_SYMBOL(mf_allocate_lp_events);
 
 /*
  * Global kernel interface to unseed and deallocate events already in
  * Hypervisor.
  */
-void mf_deallocateLpEvents(HvLpIndex targetLp, HvLpEvent_Type type,
-		unsigned count, MFCompleteHandler hdlr, void *userToken)
+void mf_deallocate_lp_events(HvLpIndex target_lp, HvLpEvent_Type type,
+		unsigned count, MFCompleteHandler hdlr, void *user_token)
 {
 	struct pending_event *ev = new_pending_event();
 	int rc;
@@ -574,33 +570,31 @@
 	if (ev == NULL)
 		rc = -ENOMEM;
 	else {
-		union safe_cast mine;
-
-		mine.ptr = userToken;
 		ev->event.hp_lp_event.xSubtype = 5;
-		ev->event.hp_lp_event.xCorrelationToken = mine.ptr_as_u64;
+		ev->event.hp_lp_event.xCorrelationToken = (u64)user_token;
 		ev->event.hp_lp_event.x.xSubtypeData =
 			subtype_data('M', 'F', 'M', 'D');
-		ev->event.data.alloc.target_lp = targetLp;
+		ev->event.data.alloc.target_lp = target_lp;
 		ev->event.data.alloc.type = type;
 		ev->event.data.alloc.count = count;
 		ev->hdlr = hdlr;
 		rc = signal_event(ev);
 	}
 	if ((rc != 0) && (hdlr != NULL))
-		(*hdlr)(userToken, rc);
+		(*hdlr)(user_token, rc);
 }
-EXPORT_SYMBOL(mf_deallocateLpEvents);
+EXPORT_SYMBOL(mf_deallocate_lp_events);
 
 /*
  * Global kernel interface to tell the VSP object in the primary
  * partition to power this partition off.
  */
-void mf_powerOff(void)
+void mf_power_off(void)
 {
 	printk(KERN_INFO "mf.c: Down it goes...\n");
-	signal_ce_msg("\x00\x00\x00\x4D\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
-	for (;;);
+	signal_ce_msg_simple(0x4d, NULL);
+	for (;;)
+		;
 }
 
 /*
@@ -610,18 +604,21 @@
 void mf_reboot(void)
 {
 	printk(KERN_INFO "mf.c: Preparing to bounce...\n");
-	signal_ce_msg("\x00\x00\x00\x4E\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
-	for (;;);
+	signal_ce_msg_simple(0x4e, NULL);
+	for (;;)
+		;
 }
 
 /*
  * Display a single word SRC onto the VSP control panel.
  */
-void mf_displaySrc(u32 word)
+void mf_display_src(u32 word)
 {
 	u8 ce[12];
 
-	memcpy(ce, "\x00\x00\x00\x4A\x00\x00\x00\x01\x00\x00\x00\x00", 12);
+	memset(ce, 0, sizeof(ce));
+	ce[3] = 0x4a;
+	ce[7] = 0x01;
 	ce[8] = word >> 24;
 	ce[9] = word >> 16;
 	ce[10] = word >> 8;
@@ -632,7 +629,7 @@
 /*
  * Display a single word SRC of the form "PROGXXXX" on the VSP control panel.
  */
-void mf_displayProgress(u16 value)
+void mf_display_progress(u16 value)
 {
 	u8 ce[12];
 	u8 src[72];
@@ -656,9 +653,9 @@
  * Clear the VSP control panel.  Used to "erase" an SRC that was
  * previously displayed.
  */
-void mf_clearSrc(void)
+void mf_clear_src(void)
 {
-	signal_ce_msg("\x00\x00\x00\x4B\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
+	signal_ce_msg_simple(0x4b, NULL);
 }
 
 /*
@@ -674,71 +671,331 @@
 	     i < sizeof(pending_event_prealloc) / sizeof(*pending_event_prealloc);
 	     ++i)
 		free_pending_event(&pending_event_prealloc[i]);
-	HvLpEvent_registerHandler(HvLpEvent_Type_MachineFac, &hvHandler);
+	HvLpEvent_registerHandler(HvLpEvent_Type_MachineFac, &hv_handler);
 
 	/* virtual continue ack */
-	signal_ce_msg("\x00\x00\x00\x57\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
+	signal_ce_msg_simple(0x57, NULL);
 
 	/* initialization complete */
-	printk(KERN_NOTICE "mf.c: iSeries Linux LPAR Machine Facilities initialized\n");
+	printk(KERN_NOTICE "mf.c: iSeries Linux LPAR Machine Facilities "
+			"initialized\n");
 }
 
-void mf_setSide(char side)
+struct rtc_time_data {
+	struct completion com;
+	struct ce_msg_data ce_msg;
+	int rc;
+};
+
+static void get_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
 {
-	u64 newSide;
-	struct VspCmdData myVspCmd;
+	struct rtc_time_data *rtc = token;
 
-	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	switch (side) {
-	case 'A':	newSide = 0;
-			break;
-	case 'B':	newSide = 1;
-			break;
-	case 'C':	newSide = 2; 
-			break;
-	default:	newSide = 3;
+	memcpy(&rtc->ce_msg, ce_msg, sizeof(rtc->ce_msg));
+	rtc->rc = 0;
+	complete(&rtc->com);
+}
+
+int mf_get_rtc(struct rtc_time *tm)
+{
+	struct ce_msg_comp_data ce_complete;
+	struct rtc_time_data rtc_data;
+	int rc;
+
+	memset(&ce_complete, 0, sizeof(ce_complete));
+	memset(&rtc_data, 0, sizeof(rtc_data));
+	init_completion(&rtc_data.com);
+	ce_complete.handler = &get_rtc_time_complete;
+	ce_complete.token = &rtc_data;
+	rc = signal_ce_msg_simple(0x40, &ce_complete);
+	if (rc)
+		return rc;
+	wait_for_completion(&rtc_data.com);
+	tm->tm_wday = 0;
+	tm->tm_yday = 0;
+	tm->tm_isdst = 0;
+	if (rtc_data.rc) {
+		tm->tm_sec = 0;
+		tm->tm_min = 0;
+		tm->tm_hour = 0;
+		tm->tm_mday = 15;
+		tm->tm_mon = 5;
+		tm->tm_year = 52;
+		return rtc_data.rc;
+	}
+
+	if ((rtc_data.ce_msg.ce_msg[2] == 0xa9) ||
+	    (rtc_data.ce_msg.ce_msg[2] == 0xaf)) {
+		/* TOD clock is not set */
+		tm->tm_sec = 1;
+		tm->tm_min = 1;
+		tm->tm_hour = 1;
+		tm->tm_mday = 10;
+		tm->tm_mon = 8;
+		tm->tm_year = 71;
+		mf_set_rtc(tm);
+	}
+	{
+		u8 *ce_msg = rtc_data.ce_msg.ce_msg;
+		u8 year = ce_msg[5];
+		u8 sec = ce_msg[6];
+		u8 min = ce_msg[7];
+		u8 hour = ce_msg[8];
+		u8 day = ce_msg[10];
+		u8 mon = ce_msg[11];
+
+		BCD_TO_BIN(sec);
+		BCD_TO_BIN(min);
+		BCD_TO_BIN(hour);
+		BCD_TO_BIN(day);
+		BCD_TO_BIN(mon);
+		BCD_TO_BIN(year);
+
+		if (year <= 69)
+			year += 100;
+
+		tm->tm_sec = sec;
+		tm->tm_min = min;
+		tm->tm_hour = hour;
+		tm->tm_mday = day;
+		tm->tm_mon = mon;
+		tm->tm_year = year;
+	}
+
+	return 0;
+}
+
+int mf_set_rtc(struct rtc_time *tm)
+{
+	char ce_time[12];
+	u8 day, mon, hour, min, sec, y1, y2;
+	unsigned year;
+
+	year = 1900 + tm->tm_year;
+	y1 = year / 100;
+	y2 = year % 100;
+
+	sec = tm->tm_sec;
+	min = tm->tm_min;
+	hour = tm->tm_hour;
+	day = tm->tm_mday;
+	mon = tm->tm_mon + 1;
+
+	BIN_TO_BCD(sec);
+	BIN_TO_BCD(min);
+	BIN_TO_BCD(hour);
+	BIN_TO_BCD(mon);
+	BIN_TO_BCD(day);
+	BIN_TO_BCD(y1);
+	BIN_TO_BCD(y2);
+
+	memset(ce_time, 0, sizeof(ce_time));
+	ce_time[3] = 0x41;
+	ce_time[4] = y1;
+	ce_time[5] = y2;
+	ce_time[6] = sec;
+	ce_time[7] = min;
+	ce_time[8] = hour;
+	ce_time[10] = day;
+	ce_time[11] = mon;
+
+	return signal_ce_msg(ce_time, NULL);
+}
+
+#ifdef CONFIG_PROC_FS
+
+static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+	int len;
+	char *p;
+	struct vsp_cmd_data vsp_cmd;
+	int rc;
+	dma_addr_t dma_addr;
+
+	/* The HV appears to return no more than 256 bytes of command line */
+	if (off >= 256)
+		return 0;
+	if ((off + count) > 256)
+		count = 256 - off;
+
+	dma_addr = dma_map_single(iSeries_vio_dev, page, off + count,
+			DMA_FROM_DEVICE);
+	if (dma_mapping_error(dma_addr))
+		return -ENOMEM;
+	memset(page, 0, off + count);
+	memset(&vsp_cmd, 0, sizeof(vsp_cmd));
+	vsp_cmd.cmd = 33;
+	vsp_cmd.sub_data.kern.token = dma_addr;
+	vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
+	vsp_cmd.sub_data.kern.side = (u64)data;
+	vsp_cmd.sub_data.kern.length = off + count;
+	mb();
+	rc = signal_vsp_instruction(&vsp_cmd);
+	dma_unmap_single(iSeries_vio_dev, dma_addr, off + count,
+			DMA_FROM_DEVICE);
+	if (rc)
+		return rc;
+	if (vsp_cmd.result_code != 0)
+		return -ENOMEM;
+	p = page;
+	len = 0;
+	while (len < (off + count)) {
+		if ((*p == '\0') || (*p == '\n')) {
+			if (*p == '\0')
+				*p = '\n';
+			p++;
+			len++;
+			*eof = 1;
 			break;
+		}
+		p++;
+		len++;
 	}
-	myVspCmd.sub_data.ipl_type = newSide;
-	myVspCmd.cmd = 10;
 
-	(void)signal_vsp_instruction(&myVspCmd);
+	if (len < off) {
+		*eof = 1;
+		len = 0;
+	}
+	return len;
 }
 
-char mf_getSide(void)
+#if 0
+static int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side)
 {
-	char returnValue = ' ';
-	int rc = 0;
-	struct VspCmdData myVspCmd;
+	struct vsp_cmd_data vsp_cmd;
+	int rc;
+	int len = *size;
+	dma_addr_t dma_addr;
+
+	dma_addr = dma_map_single(iSeries_vio_dev, buffer, len,
+			DMA_FROM_DEVICE);
+	memset(buffer, 0, len);
+	memset(&vsp_cmd, 0, sizeof(vsp_cmd));
+	vsp_cmd.cmd = 32;
+	vsp_cmd.sub_data.kern.token = dma_addr;
+	vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
+	vsp_cmd.sub_data.kern.side = side;
+	vsp_cmd.sub_data.kern.offset = offset;
+	vsp_cmd.sub_data.kern.length = len;
+	mb();
+	rc = signal_vsp_instruction(&vsp_cmd);
+	if (rc == 0) {
+		if (vsp_cmd.result_code == 0)
+			*size = vsp_cmd.sub_data.length_out;
+		else
+			rc = -ENOMEM;
+	}
+
+	dma_unmap_single(iSeries_vio_dev, dma_addr, len, DMA_FROM_DEVICE);
+
+	return rc;
+}
 
-	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	myVspCmd.cmd = 2;
-	myVspCmd.sub_data.ipl_type = 0;
+static int proc_mf_dump_vmlinux(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+	int sizeToGet = count;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EACCES;
+
+	if (mf_getVmlinuxChunk(page, &sizeToGet, off, (u64)data) == 0) {
+		if (sizeToGet != 0) {
+			*start = page + off;
+			return sizeToGet;
+		}
+		*eof = 1;
+		return 0;
+	}
+	*eof = 1;
+	return 0;
+}
+#endif
+
+static int proc_mf_dump_side(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+	int len;
+	char mf_current_side = ' ';
+	struct vsp_cmd_data vsp_cmd;
+
+	memset(&vsp_cmd, 0, sizeof(vsp_cmd));
+	vsp_cmd.cmd = 2;
+	vsp_cmd.sub_data.ipl_type = 0;
 	mb();
-	rc = signal_vsp_instruction(&myVspCmd);
 
-	if (rc != 0)
-		return returnValue;
+	if (signal_vsp_instruction(&vsp_cmd) == 0) {
+		if (vsp_cmd.result_code == 0) {
+			switch (vsp_cmd.sub_data.ipl_type) {
+			case 0:	mf_current_side = 'A';
+				break;
+			case 1:	mf_current_side = 'B';
+				break;
+			case 2:	mf_current_side = 'C';
+				break;
+			default:	mf_current_side = 'D';
+				break;
+			}
+		}
+	}
+
+	len = sprintf(page, "%c\n", mf_current_side);
 
-	if (myVspCmd.result_code == 0) {
-		switch (myVspCmd.sub_data.ipl_type) {
-		case 0:	returnValue = 'A';
+	if (len <= (off + count))
+		*eof = 1;
+	*start = page + off;
+	len -= off;
+	if (len > count)
+		len = count;
+	if (len < 0)
+		len = 0;
+	return len;
+}
+
+static int proc_mf_change_side(struct file *file, const char __user *buffer,
+		unsigned long count, void *data)
+{
+	char side;
+	u64 newSide;
+	struct vsp_cmd_data vsp_cmd;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EACCES;
+
+	if (count == 0)
+		return 0;
+
+	if (get_user(side, buffer))
+		return -EFAULT;
+
+	switch (side) {
+	case 'A':	newSide = 0;
 			break;
-		case 1:	returnValue = 'B';
+	case 'B':	newSide = 1;
 			break;
-		case 2:	returnValue = 'C';
+	case 'C':	newSide = 2;
 			break;
-		default:	returnValue = 'D';
+	case 'D':	newSide = 3;
 			break;
-		}
+	default:
+		printk(KERN_ERR "mf_proc.c: proc_mf_change_side: invalid side\n");
+		return -EINVAL;
 	}
-	return returnValue;
+
+	memset(&vsp_cmd, 0, sizeof(vsp_cmd));
+	vsp_cmd.sub_data.ipl_type = newSide;
+	vsp_cmd.cmd = 10;
+
+	(void)signal_vsp_instruction(&vsp_cmd);
+
+	return count;
 }
 
-void mf_getSrcHistory(char *buffer, int size)
-{
 #if 0
-	struct IplTypeReturnStuff returnStuff;
+static void mf_getSrcHistory(char *buffer, int size)
+{
+	struct IplTypeReturnStuff return_stuff;
 	struct pending_event *ev = new_pending_event();
 	int rc = 0;
 	char *pages[4];
@@ -751,13 +1008,13 @@
 			 || (pages[2] == NULL) || (pages[3] == NULL))
 		return -ENOMEM;
 
-	returnStuff.xType = 0;
-	returnStuff.xRc = 0;
-	returnStuff.xDone = 0;
+	return_stuff.xType = 0;
+	return_stuff.xRc = 0;
+	return_stuff.xDone = 0;
 	ev->event.hp_lp_event.xSubtype = 6;
 	ev->event.hp_lp_event.x.xSubtypeData =
 		subtype_data('M', 'F', 'V', 'I');
-	ev->event.data.vsp_cmd.xEvent = &returnStuff;
+	ev->event.data.vsp_cmd.xEvent = &return_stuff;
 	ev->event.data.vsp_cmd.cmd = 4;
 	ev->event.data.vsp_cmd.lp_index = HvLpConfig_getLpIndex();
 	ev->event.data.vsp_cmd.result_code = 0xFF;
@@ -770,312 +1027,213 @@
 	if (signal_event(ev) != 0)
 		return;
 
- 	while (returnStuff.xDone != 1)
+ 	while (return_stuff.xDone != 1)
  		udelay(10);
- 	if (returnStuff.xRc == 0)
+ 	if (return_stuff.xRc == 0)
  		memcpy(buffer, pages[0], size);
 	kfree(pages[0]);
 	kfree(pages[1]);
 	kfree(pages[2]);
 	kfree(pages[3]);
-#endif
-}
-
-void mf_setCmdLine(const char *cmdline, int size, u64 side)
-{
-	struct VspCmdData myVspCmd;
-	dma_addr_t dma_addr = 0;
-	char *page = dma_alloc_coherent(iSeries_vio_dev, size, &dma_addr,
-			GFP_ATOMIC);
-
-	if (page == NULL) {
-		printk(KERN_ERR "mf.c: couldn't allocate memory to set command line\n");
-		return;
-	}
-
-	copy_from_user(page, cmdline, size);
-
-	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	myVspCmd.cmd = 31;
-	myVspCmd.sub_data.kern.token = dma_addr;
-	myVspCmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
-	myVspCmd.sub_data.kern.side = side;
-	myVspCmd.sub_data.kern.length = size;
-	mb();
-	(void)signal_vsp_instruction(&myVspCmd);
-
-	dma_free_coherent(iSeries_vio_dev, size, page, dma_addr);
 }
+#endif
 
-int mf_getCmdLine(char *cmdline, int *size, u64 side)
+static int proc_mf_dump_src(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
 {
-	struct VspCmdData myVspCmd;
-	int rc;
-	int len = *size;
-	dma_addr_t dma_addr;
-
-	dma_addr = dma_map_single(iSeries_vio_dev, cmdline, len,
-			DMA_FROM_DEVICE);
-	memset(cmdline, 0, len);
-	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	myVspCmd.cmd = 33;
-	myVspCmd.sub_data.kern.token = dma_addr;
-	myVspCmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
-	myVspCmd.sub_data.kern.side = side;
-	myVspCmd.sub_data.kern.length = len;
-	mb();
-	rc = signal_vsp_instruction(&myVspCmd);
-
-	if (rc == 0) {
-		if (myVspCmd.result_code == 0)
-			len = myVspCmd.sub_data.length_out;
 #if 0
-		else
-			memcpy(cmdline, "Bad cmdline", 11);
-#endif
-	}
-
-	dma_unmap_single(iSeries_vio_dev, dma_addr, *size, DMA_FROM_DEVICE);
+	int len;
 
+	mf_getSrcHistory(page, count);
+	len = count;
+	len -= off;
+	if (len < count) {
+		*eof = 1;
+		if (len <= 0)
+			return 0;
+	} else
+		len = count;
+	*start = page + off;
 	return len;
+#else
+	return 0;
+#endif
 }
 
-
-int mf_setVmlinuxChunk(const char *buffer, int size, int offset, u64 side)
+static int proc_mf_change_src(struct file *file, const char __user *buffer,
+		unsigned long count, void *data)
 {
-	struct VspCmdData myVspCmd;
-	int rc;
-	dma_addr_t dma_addr = 0;
-	char *page = dma_alloc_coherent(iSeries_vio_dev, size, &dma_addr,
-			GFP_ATOMIC);
+	char stkbuf[10];
 
-	if (page == NULL) {
-		printk(KERN_ERR "mf.c: couldn't allocate memory to set vmlinux chunk\n");
-		return -ENOMEM;
-	}
-
-	copy_from_user(page, buffer, size);
-	memset(&myVspCmd, 0, sizeof(myVspCmd));
+	if (!capable(CAP_SYS_ADMIN))
+		return -EACCES;
 
-	myVspCmd.cmd = 30;
-	myVspCmd.sub_data.kern.token = dma_addr;
-	myVspCmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
-	myVspCmd.sub_data.kern.side = side;
-	myVspCmd.sub_data.kern.offset = offset;
-	myVspCmd.sub_data.kern.length = size;
-	mb();
-	rc = signal_vsp_instruction(&myVspCmd);
-	if (rc == 0) {
-		if (myVspCmd.result_code == 0)
-			rc = 0;
-		else
-			rc = -ENOMEM;
+	if ((count < 4) && (count != 1)) {
+		printk(KERN_ERR "mf_proc: invalid src\n");
+		return -EINVAL;
 	}
 
-	dma_free_coherent(iSeries_vio_dev, size, page, dma_addr);
+	if (count > (sizeof(stkbuf) - 1))
+		count = sizeof(stkbuf) - 1;
+	if (copy_from_user(stkbuf, buffer, count))
+		return -EFAULT;
 
-	return rc;
+	if ((count == 1) && (*stkbuf == '\0'))
+		mf_clear_src();
+	else
+		mf_display_src(*(u32 *)stkbuf);
+
+	return count;
 }
 
-int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side)
+static int proc_mf_change_cmdline(struct file *file, const char __user *buffer,
+		unsigned long count, void *data)
 {
-	struct VspCmdData myVspCmd;
-	int rc;
-	int len = *size;
+	struct vsp_cmd_data vsp_cmd;
 	dma_addr_t dma_addr;
+	char *page;
+	int ret = -EACCES;
 
-	dma_addr = dma_map_single(iSeries_vio_dev, buffer, len,
-			DMA_FROM_DEVICE);
-	memset(buffer, 0, len);
-	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	myVspCmd.cmd = 32;
-	myVspCmd.sub_data.kern.token = dma_addr;
-	myVspCmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
-	myVspCmd.sub_data.kern.side = side;
-	myVspCmd.sub_data.kern.offset = offset;
-	myVspCmd.sub_data.kern.length = len;
-	mb();
-	rc = signal_vsp_instruction(&myVspCmd);
-	if (rc == 0) {
-		if (myVspCmd.result_code == 0)
-			*size = myVspCmd.sub_data.length_out;
-		else
-			rc = -ENOMEM;
-	}
+	if (!capable(CAP_SYS_ADMIN))
+		goto out;
 
-	dma_unmap_single(iSeries_vio_dev, dma_addr, len, DMA_FROM_DEVICE);
+	dma_addr = 0;
+	page = dma_alloc_coherent(iSeries_vio_dev, count, &dma_addr,
+			GFP_ATOMIC);
+	ret = -ENOMEM;
+	if (page == NULL)
+		goto out;
+
+	ret = -EFAULT;
+	if (copy_from_user(page, buffer, count))
+		goto out_free;
+
+	memset(&vsp_cmd, 0, sizeof(vsp_cmd));
+	vsp_cmd.cmd = 31;
+	vsp_cmd.sub_data.kern.token = dma_addr;
+	vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
+	vsp_cmd.sub_data.kern.side = (u64)data;
+	vsp_cmd.sub_data.kern.length = count;
+	mb();
+	(void)signal_vsp_instruction(&vsp_cmd);
+	ret = count;
 
-	return rc;
+out_free:
+	dma_free_coherent(iSeries_vio_dev, count, page, dma_addr);
+out:
+	return ret;
 }
 
-int mf_setRtcTime(unsigned long time)
+static ssize_t proc_mf_change_vmlinux(struct file *file,
+				      const char __user *buf,
+				      size_t count, loff_t *ppos)
 {
-	struct rtc_time tm;
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	ssize_t rc;
+	dma_addr_t dma_addr;
+	char *page;
+	struct vsp_cmd_data vsp_cmd;
 
-	to_tm(time, &tm);
+	rc = -EACCES;
+	if (!capable(CAP_SYS_ADMIN))
+		goto out;
 
-	return mf_setRtc(&tm);
+	dma_addr = 0;
+	page = dma_alloc_coherent(iSeries_vio_dev, count, &dma_addr,
+			GFP_ATOMIC);
+	rc = -ENOMEM;
+	if (page == NULL) {
+		printk(KERN_ERR "mf.c: couldn't allocate memory to set vmlinux chunk\n");
+		goto out;
+	}
+	rc = -EFAULT;
+	if (copy_from_user(page, buf, count))
+		goto out_free;
+
+	memset(&vsp_cmd, 0, sizeof(vsp_cmd));
+	vsp_cmd.cmd = 30;
+	vsp_cmd.sub_data.kern.token = dma_addr;
+	vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
+	vsp_cmd.sub_data.kern.side = (u64)dp->data;
+	vsp_cmd.sub_data.kern.offset = *ppos;
+	vsp_cmd.sub_data.kern.length = count;
+	mb();
+	rc = signal_vsp_instruction(&vsp_cmd);
+	if (rc)
+		goto out_free;
+	rc = -ENOMEM;
+	if (vsp_cmd.result_code != 0)
+		goto out_free;
+
+	*ppos += count;
+	rc = count;
+out_free:
+	dma_free_coherent(iSeries_vio_dev, count, page, dma_addr);
+out:
+	return rc;
 }
 
-struct RtcTimeData {
-	struct completion com;
-	struct CeMsgData xCeMsg;
-	int xRc;
+static struct file_operations proc_vmlinux_operations = {
+	.write		= proc_mf_change_vmlinux,
 };
 
-void getRtcTimeComplete(void * token, struct CeMsgData *ceMsg)
+static int __init mf_proc_init(void)
 {
-	struct RtcTimeData *rtc = (struct RtcTimeData *)token;
-
-	memcpy(&(rtc->xCeMsg), ceMsg, sizeof(rtc->xCeMsg));
-	rtc->xRc = 0;
-	complete(&rtc->com);
-}
-
-static unsigned long lastsec = 1;
+	struct proc_dir_entry *mf_proc_root;
+	struct proc_dir_entry *ent;
+	struct proc_dir_entry *mf;
+	char name[2];
+	int i;
 
-int mf_getRtcTime(unsigned long *time)
-{
-	u32 dataWord1 = *((u32 *)(&xSpCommArea.xBcdTimeAtIplStart));
-	u32 dataWord2 = *(((u32 *)&(xSpCommArea.xBcdTimeAtIplStart)) + 1);
-	int year = 1970;
-	int year1 = (dataWord1 >> 24) & 0x000000FF;
-	int year2 = (dataWord1 >> 16) & 0x000000FF;
-	int sec = (dataWord1 >> 8) & 0x000000FF;
-	int min = dataWord1 & 0x000000FF;
-	int hour = (dataWord2 >> 24) & 0x000000FF;
-	int day = (dataWord2 >> 8) & 0x000000FF;
-	int mon = dataWord2 & 0x000000FF;
-
-	BCD_TO_BIN(sec);
-	BCD_TO_BIN(min);
-	BCD_TO_BIN(hour);
-	BCD_TO_BIN(day);
-	BCD_TO_BIN(mon);
-	BCD_TO_BIN(year1);
-	BCD_TO_BIN(year2);
-	year = year1 * 100 + year2;
-
-	*time = mktime(year, mon, day, hour, min, sec);
-	*time += (jiffies / HZ);
-    
-	/*
-	 * Now THIS is a nasty hack!
-	 * It ensures that the first two calls to mf_getRtcTime get different
-	 * answers.  That way the loop in init_time (time.c) will not think
-	 * the clock is stuck.
-	 */
-	if (lastsec) {
-		*time -= lastsec;
-		--lastsec;
+	mf_proc_root = proc_mkdir("iSeries/mf", NULL);
+	if (!mf_proc_root)
+		return 1;
+
+	name[1] = '\0';
+	for (i = 0; i < 4; i++) {
+		name[0] = 'A' + i;
+		mf = proc_mkdir(name, mf_proc_root);
+		if (!mf)
+			return 1;
+
+		ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
+		if (!ent)
+			return 1;
+		ent->nlink = 1;
+		ent->data = (void *)(long)i;
+		ent->read_proc = proc_mf_dump_cmdline;
+		ent->write_proc = proc_mf_change_cmdline;
+
+		if (i == 3)	/* no vmlinux entry for 'D' */
+			continue;
+
+		ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf);
+		if (!ent)
+			return 1;
+		ent->nlink = 1;
+		ent->data = (void *)(long)i;
+		ent->proc_fops = &proc_vmlinux_operations;
 	}
-	return 0;
-}
-
-int mf_getRtc(struct rtc_time *tm)
-{
-	struct CeMsgCompleteData ceComplete;
-	struct RtcTimeData rtcData;
-	int rc;
-
-	memset(&ceComplete, 0, sizeof(ceComplete));
-	memset(&rtcData, 0, sizeof(rtcData));
-	init_completion(&rtcData.com);
-	ceComplete.handler = &getRtcTimeComplete;
-	ceComplete.token = (void *)&rtcData;
-	rc = signal_ce_msg("\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00",
-			&ceComplete);
-	if (rc == 0) {
-		wait_for_completion(&rtcData.com);
 
-		if (rtcData.xRc == 0) {
-			if ((rtcData.xCeMsg.ce_msg[2] == 0xa9) ||
-			    (rtcData.xCeMsg.ce_msg[2] == 0xaf)) {
-				/* TOD clock is not set */
-				tm->tm_sec = 1;
-				tm->tm_min = 1;
-				tm->tm_hour = 1;
-				tm->tm_mday = 10;
-				tm->tm_mon = 8;
-				tm->tm_year = 71;
-				mf_setRtc(tm);
-			}
-			{
-				u32 dataWord1 = *((u32 *)(rtcData.xCeMsg.ce_msg+4));
-				u32 dataWord2 = *((u32 *)(rtcData.xCeMsg.ce_msg+8));
-				u8 year = (dataWord1 >> 16) & 0x000000FF;
-				u8 sec = (dataWord1 >> 8) & 0x000000FF;
-				u8 min = dataWord1 & 0x000000FF;
-				u8 hour = (dataWord2 >> 24) & 0x000000FF;
-				u8 day = (dataWord2 >> 8) & 0x000000FF;
-				u8 mon = dataWord2 & 0x000000FF;
-
-				BCD_TO_BIN(sec);
-				BCD_TO_BIN(min);
-				BCD_TO_BIN(hour);
-				BCD_TO_BIN(day);
-				BCD_TO_BIN(mon);
-				BCD_TO_BIN(year);
-
-				if (year <= 69)
-					year += 100;
-	    
-				tm->tm_sec = sec;
-				tm->tm_min = min;
-				tm->tm_hour = hour;
-				tm->tm_mday = day;
-				tm->tm_mon = mon;
-				tm->tm_year = year;
-			}
-		} else {
-			rc = rtcData.xRc;
-			tm->tm_sec = 0;
-			tm->tm_min = 0;
-			tm->tm_hour = 0;
-			tm->tm_mday = 15;
-			tm->tm_mon = 5;
-			tm->tm_year = 52;
-
-		}
-		tm->tm_wday = 0;
-		tm->tm_yday = 0;
-		tm->tm_isdst = 0;
-	}
+	ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
+	if (!ent)
+		return 1;
+	ent->nlink = 1;
+	ent->data = (void *)0;
+	ent->read_proc = proc_mf_dump_side;
+	ent->write_proc = proc_mf_change_side;
+
+	ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
+	if (!ent)
+		return 1;
+	ent->nlink = 1;
+	ent->data = (void *)0;
+	ent->read_proc = proc_mf_dump_src;
+	ent->write_proc = proc_mf_change_src;
 
-	return rc;
+	return 0;
 }
 
-int mf_setRtc(struct rtc_time * tm)
-{
-	char ceTime[12] = "\x00\x00\x00\x41\x00\x00\x00\x00\x00\x00\x00\x00";
-	u8 day, mon, hour, min, sec, y1, y2;
-	unsigned year;
-    
-	year = 1900 + tm->tm_year;
-	y1 = year / 100;
-	y2 = year % 100;
-    
-	sec = tm->tm_sec;
-	min = tm->tm_min;
-	hour = tm->tm_hour;
-	day = tm->tm_mday;
-	mon = tm->tm_mon + 1;
-	    
-	BIN_TO_BCD(sec);
-	BIN_TO_BCD(min);
-	BIN_TO_BCD(hour);
-	BIN_TO_BCD(mon);
-	BIN_TO_BCD(day);
-	BIN_TO_BCD(y1);
-	BIN_TO_BCD(y2);
+__initcall(mf_proc_init);
 
-	ceTime[4] = y1;
-	ceTime[5] = y2;
-	ceTime[6] = sec;
-	ceTime[7] = min;
-	ceTime[8] = hour;
-	ceTime[10] = day;
-	ceTime[11] = mon;
-   
-	return signal_ce_msg(ceTime, NULL);
-}
+#endif /* CONFIG_PROC_FS */
diff -Nru a/arch/ppc64/kernel/mf_proc.c b/arch/ppc64/kernel/mf_proc.c
--- a/arch/ppc64/kernel/mf_proc.c	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,250 +0,0 @@
-/*
- * mf_proc.c
- * Copyright (C) 2001 Kyle A. Lucke  IBM Corporation
- * 
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-#include <linux/init.h>
-#include <asm/uaccess.h>
-#include <asm/iSeries/mf.h>
-
-static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
-		int count, int *eof, void *data)
-{
-	int len = count;
-	char *p;
-
-	if (off) {
-		*eof = 1;
-		return 0;
-	}
-
-	len = mf_getCmdLine(page, &len, (u64)data);
-   
-	p = page;
-	while (len < (count - 1)) {
-		if (!*p || *p == '\n')
-			break;
-		p++;
-		len++;
-	}
-	*p = '\n';
-	p++;
-	*p = 0;
-
-	return p - page;
-}
-
-#if 0
-static int proc_mf_dump_vmlinux(char *page, char **start, off_t off,
-		int count, int *eof, void *data)
-{
-	int sizeToGet = count;
-
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
-	if (mf_getVmlinuxChunk(page, &sizeToGet, off, (u64)data) == 0) {
-		if (sizeToGet != 0) {
-			*start = page + off;
-			return sizeToGet;
-		}
-		*eof = 1;
-		return 0;
-	}
-	*eof = 1;
-	return 0;
-}
-#endif
-
-static int proc_mf_dump_side(char *page, char **start, off_t off,
-		int count, int *eof, void *data)
-{
-	int len;
-	char mf_current_side = mf_getSide();
-
-	len = sprintf(page, "%c\n", mf_current_side);
-
-	if (len <= (off + count))
-		*eof = 1;
-	*start = page + off;
-	len -= off;
-	if (len > count)
-		len = count;
-	if (len < 0)
-		len = 0;
-	return len;			
-}
-
-static int proc_mf_change_side(struct file *file, const char __user *buffer,
-		unsigned long count, void *data)
-{
-	char stkbuf[10];
-
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
-	if (count > (sizeof(stkbuf) - 1))
-		count = sizeof(stkbuf) - 1;
-	if (copy_from_user(stkbuf, buffer, count))
-		return -EFAULT;
-	stkbuf[count] = 0;
-	if ((*stkbuf != 'A') && (*stkbuf != 'B') &&
-	    (*stkbuf != 'C') && (*stkbuf != 'D')) {
-		printk(KERN_ERR "mf_proc.c: proc_mf_change_side: invalid side\n");
-		return -EINVAL;
-	}
-
-	mf_setSide(*stkbuf);
-
-	return count;
-}
-
-static int proc_mf_dump_src(char *page, char **start, off_t off,
-		int count, int *eof, void *data)
-{
-	int len;
-
-	mf_getSrcHistory(page, count);
-	len = count;
-	len -= off;			
-	if (len < count) {		
-		*eof = 1;		
-		if (len <= 0)		
-			return 0;	
-	} else				
-		len = count;		
-	*start = page + off;		
-	return len;			
-}
-
-static int proc_mf_change_src(struct file *file, const char __user *buffer,
-		unsigned long count, void *data)
-{
-	char stkbuf[10];
-
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
-	if ((count < 4) && (count != 1)) {
-		printk(KERN_ERR "mf_proc: invalid src\n");
-		return -EINVAL;
-	}
-
-	if (count > (sizeof(stkbuf) - 1))
-		count = sizeof(stkbuf) - 1;
-	if (copy_from_user(stkbuf, buffer, count))
-		return -EFAULT;
-
-	if ((count == 1) && (*stkbuf == '\0'))
-		mf_clearSrc();
-	else
-		mf_displaySrc(*(u32 *)stkbuf);
-
-	return count;			
-}
-
-static int proc_mf_change_cmdline(struct file *file, const char *buffer,
-		unsigned long count, void *data)
-{
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
-	mf_setCmdLine(buffer, count, (u64)data);
-
-	return count;			
-}
-
-static ssize_t proc_mf_change_vmlinux(struct file *file, 
-				      const char __user *buf,
-				      size_t count, loff_t *ppos)
-{
-	struct inode * inode = file->f_dentry->d_inode;
-	struct proc_dir_entry * dp = PDE(inode);
-	int rc;
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
-	rc = mf_setVmlinuxChunk(buf, count, *ppos, (u64)dp->data);
-	if (rc < 0)
-		return rc;
-
-	*ppos += count;
-
-	return count;			
-}
-
-static struct file_operations proc_vmlinux_operations = {
-	.write		= proc_mf_change_vmlinux,
-};
-
-static int __init mf_proc_init(void)
-{
-	struct proc_dir_entry *mf_proc_root;
-	struct proc_dir_entry *ent;
-	struct proc_dir_entry *mf;
-	char name[2];
-	int i;
-
-	mf_proc_root = proc_mkdir("iSeries/mf", NULL);
-	if (!mf_proc_root)
-		return 1;
-
-	name[1] = '\0';
-	for (i = 0; i < 4; i++) {
-		name[0] = 'A' + i;
-		mf = proc_mkdir(name, mf_proc_root);
-		if (!mf)
-			return 1;
-
-		ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
-		if (!ent)
-			return 1;
-		ent->nlink = 1;
-		ent->data = (void *)(long)i;
-		ent->read_proc = proc_mf_dump_cmdline;
-		ent->write_proc = proc_mf_change_cmdline;
-
-		if (i == 3)	/* no vmlinux entry for 'D' */
-			continue;
-
-		ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf);
-		if (!ent)
-			return 1;
-		ent->nlink = 1;
-		ent->data = (void *)(long)i;
-		ent->proc_fops = &proc_vmlinux_operations;
-	}
-
-	ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
-	if (!ent)
-		return 1;
-	ent->nlink = 1;
-	ent->data = (void *)0;
-	ent->read_proc = proc_mf_dump_side;
-	ent->write_proc = proc_mf_change_side;
-
-	ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
-	if (!ent)
-		return 1;
-	ent->nlink = 1;
-	ent->data = (void *)0;
-	ent->read_proc = proc_mf_dump_src;
-	ent->write_proc = proc_mf_change_src;
-
-	return 0;
-}
-
-__initcall(mf_proc_init);
diff -Nru a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S
--- a/arch/ppc64/kernel/misc.S	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc64/kernel/misc.S	2004-12-24 13:37:19 -08:00
@@ -115,12 +115,12 @@
 	mtlr	r0
 	blr
 
-_GLOBAL(call_handle_irq_event)
+_GLOBAL(call_handle_IRQ_event)
 	mflr	r0
 	std	r0,16(r1)
 	stdu	r1,THREAD_SIZE-112(r6)
 	mr	r1,r6
-	bl	.handle_irq_event
+	bl	.handle_IRQ_event
 	ld	r1,0(r1)
 	ld	r0,16(r1)
 	mtlr	r0
@@ -591,7 +591,7 @@
 	isync
 	b	1b
 
-#ifdef CONFIG_PPC_PMAC
+#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE)
 /*
  * Do an IO access in real mode
  */
@@ -653,7 +653,7 @@
 	sync
 	isync
 	blr
-#endif /* CONFIG_PPC_PMAC */
+#endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) */
 
 /*
  * Create a kernel thread
@@ -935,27 +935,27 @@
 	.llong .sys_epoll_wait
 	.llong .sys_remap_file_pages
 	.llong .ppc32_timer_create	/* 240 */
-	.llong .compat_timer_settime
-	.llong .compat_timer_gettime
+	.llong .compat_sys_timer_settime
+	.llong .compat_sys_timer_gettime
 	.llong .sys_timer_getoverrun
 	.llong .sys_timer_delete
-	.llong .compat_clock_settime	/* 245 */
-	.llong .compat_clock_gettime
-	.llong .compat_clock_getres
-	.llong .compat_clock_nanosleep
+	.llong .compat_sys_clock_settime	/* 245 */
+	.llong .compat_sys_clock_gettime
+	.llong .compat_sys_clock_getres
+	.llong .compat_sys_clock_nanosleep
 	.llong .ppc32_swapcontext
 	.llong .sys32_tgkill		/* 250 */
 	.llong .sys32_utimes
-	.llong .compat_statfs64
-	.llong .compat_fstatfs64
+	.llong .compat_sys_statfs64
+	.llong .compat_sys_fstatfs64
 	.llong .ppc32_fadvise64_64	/* 32bit only fadvise64_64 */
 	.llong .ppc_rtas		/* 255 */
 	.llong .sys_ni_syscall		/* 256 reserved for sys_debug_setcontext */
 	.llong .sys_ni_syscall		/* 257 reserved for vserver */
 	.llong .sys_ni_syscall		/* 258 reserved for new sys_remap_file_pages */
-	.llong .compat_mbind
-	.llong .compat_get_mempolicy	/* 260 */
-	.llong .compat_set_mempolicy
+	.llong .compat_sys_mbind
+	.llong .compat_sys_get_mempolicy	/* 260 */
+	.llong .compat_sys_set_mempolicy
 	.llong .compat_sys_mq_open
 	.llong .sys_mq_unlink
 	.llong .compat_sys_mq_timedsend
@@ -963,6 +963,9 @@
 	.llong .compat_sys_mq_notify
 	.llong .compat_sys_mq_getsetattr
 	.llong .sys_ni_syscall		/* 268 reserved for sys_kexec_load */
+	.llong .sys32_add_key
+	.llong .sys32_request_key
+	.llong .compat_sys_keyctl
 
 	.balign 8
 _GLOBAL(sys_call_table)
@@ -1235,3 +1238,6 @@
 	.llong .sys_mq_notify
 	.llong .sys_mq_getsetattr
 	.llong .sys_ni_syscall		/* 268 reserved for sys_kexec_load */
+	.llong .sys_add_key
+	.llong .sys_request_key		/* 270 */
+	.llong .sys_keyctl
diff -Nru a/arch/ppc64/kernel/mpic.c b/arch/ppc64/kernel/mpic.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/kernel/mpic.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,861 @@
+/*
+ *  arch/ppc64/kernel/mpic.c
+ *
+ *  Driver for interrupt controllers following the OpenPIC standard, the
+ *  common implementation beeing IBM's MPIC. This driver also can deal
+ *  with various broken implementations of this HW.
+ *
+ *  Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
+ *
+ *  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.
+ */
+
+#undef DEBUG
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/smp.h>
+#include <linux/interrupt.h>
+#include <linux/bootmem.h>
+#include <linux/spinlock.h>
+#include <linux/pci.h>
+
+#include <asm/ptrace.h>
+#include <asm/signal.h>
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/irq.h>
+#include <asm/machdep.h>
+
+#include "mpic.h"
+
+#ifdef DEBUG
+#define DBG(fmt...) printk(fmt)
+#else
+#define DBG(fmt...)
+#endif
+
+static struct mpic *mpics;
+static struct mpic *mpic_primary;
+static spinlock_t mpic_lock = SPIN_LOCK_UNLOCKED;
+
+
+/*
+ * Register accessor functions
+ */
+
+
+static inline u32 _mpic_read(unsigned int be, volatile u32 __iomem *base,
+			    unsigned int reg)
+{
+	if (be)
+		return in_be32(base + (reg >> 2));
+	else
+		return in_le32(base + (reg >> 2));
+}
+
+static inline void _mpic_write(unsigned int be, volatile u32 __iomem *base,
+			      unsigned int reg, u32 value)
+{
+	if (be)
+		out_be32(base + (reg >> 2), value);
+	else
+		out_le32(base + (reg >> 2), value);
+}
+
+static inline u32 _mpic_ipi_read(struct mpic *mpic, unsigned int ipi)
+{
+	unsigned int be = (mpic->flags & MPIC_BIG_ENDIAN) != 0;
+	unsigned int offset = MPIC_GREG_IPI_VECTOR_PRI_0 + (ipi * 0x10);
+
+	if (mpic->flags & MPIC_BROKEN_IPI)
+		be = !be;
+	return _mpic_read(be, mpic->gregs, offset);
+}
+
+static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 value)
+{
+	unsigned int offset = MPIC_GREG_IPI_VECTOR_PRI_0 + (ipi * 0x10);
+
+	_mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->gregs, offset, value);
+}
+
+static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg)
+{
+	unsigned int cpu = 0;
+
+	if (mpic->flags & MPIC_PRIMARY)
+		cpu = hard_smp_processor_id();
+
+	return _mpic_read(mpic->flags & MPIC_BIG_ENDIAN, mpic->cpuregs[cpu], reg);
+}
+
+static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value)
+{
+	unsigned int cpu = 0;
+
+	if (mpic->flags & MPIC_PRIMARY)
+		cpu = hard_smp_processor_id();
+
+	_mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->cpuregs[cpu], reg, value);
+}
+
+static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigned int reg)
+{
+	unsigned int	isu = src_no >> mpic->isu_shift;
+	unsigned int	idx = src_no & mpic->isu_mask;
+
+	return _mpic_read(mpic->flags & MPIC_BIG_ENDIAN, mpic->isus[isu],
+			  reg + (idx * MPIC_IRQ_STRIDE));
+}
+
+static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no,
+				   unsigned int reg, u32 value)
+{
+	unsigned int	isu = src_no >> mpic->isu_shift;
+	unsigned int	idx = src_no & mpic->isu_mask;
+
+	_mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->isus[isu],
+		    reg + (idx * MPIC_IRQ_STRIDE), value);
+}
+
+#define mpic_read(b,r)		_mpic_read(mpic->flags & MPIC_BIG_ENDIAN,(b),(r))
+#define mpic_write(b,r,v)	_mpic_write(mpic->flags & MPIC_BIG_ENDIAN,(b),(r),(v))
+#define mpic_ipi_read(i)	_mpic_ipi_read(mpic,(i))
+#define mpic_ipi_write(i,v)	_mpic_ipi_write(mpic,(i),(v))
+#define mpic_cpu_read(i)	_mpic_cpu_read(mpic,(i))
+#define mpic_cpu_write(i,v)	_mpic_cpu_write(mpic,(i),(v))
+#define mpic_irq_read(s,r)	_mpic_irq_read(mpic,(s),(r))
+#define mpic_irq_write(s,r,v)	_mpic_irq_write(mpic,(s),(r),(v))
+
+
+/*
+ * Low level utility functions
+ */
+
+
+
+/* Check if we have one of those nice broken MPICs with a flipped endian on
+ * reads from IPI registers
+ */
+static void __init mpic_test_broken_ipi(struct mpic *mpic)
+{
+	u32 r;
+
+	mpic_write(mpic->gregs, MPIC_GREG_IPI_VECTOR_PRI_0, MPIC_VECPRI_MASK);
+	r = mpic_read(mpic->gregs, MPIC_GREG_IPI_VECTOR_PRI_0);
+
+	if (r == le32_to_cpu(MPIC_VECPRI_MASK)) {
+		printk(KERN_INFO "mpic: Detected reversed IPI registers\n");
+		mpic->flags |= MPIC_BROKEN_IPI;
+	}
+}
+
+#ifdef CONFIG_MPIC_BROKEN_U3
+
+/* Test if an interrupt is sourced from HyperTransport (used on broken U3s)
+ * to force the edge setting on the MPIC and do the ack workaround.
+ */
+static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source_no)
+{
+	if (source_no >= 128 || !mpic->fixups)
+		return 0;
+	return mpic->fixups[source_no].base != NULL;
+}
+
+static inline void mpic_apic_end_irq(struct mpic *mpic, unsigned int source_no)
+{
+	struct mpic_irq_fixup *fixup = &mpic->fixups[source_no];
+	u32 tmp;
+
+	spin_lock(&mpic->fixup_lock);
+	writeb(0x11 + 2 * fixup->irq, fixup->base);
+	tmp = readl(fixup->base + 2);
+	writel(tmp | 0x80000000ul, fixup->base + 2);
+	/* config writes shouldn't be posted but let's be safe ... */
+	(void)readl(fixup->base + 2);
+	spin_unlock(&mpic->fixup_lock);
+}
+
+
+static void __init mpic_amd8111_read_irq(struct mpic *mpic, u8 __iomem *devbase)
+{
+	int i, irq;
+	u32 tmp;
+
+	printk(KERN_INFO "mpic:    - Workarounds on AMD 8111 @ %p\n", devbase);
+
+	for (i=0; i < 24; i++) {
+		writeb(0x10 + 2*i, devbase + 0xf2);
+		tmp = readl(devbase + 0xf4);
+		if ((tmp & 0x1) || !(tmp & 0x20))
+			continue;
+		irq = (tmp >> 16) & 0xff;
+		mpic->fixups[irq].irq = i;
+		mpic->fixups[irq].base = devbase + 0xf2;
+	}
+}
+ 
+static void __init mpic_amd8131_read_irq(struct mpic *mpic, u8 __iomem *devbase)
+{
+	int i, irq;
+	u32 tmp;
+
+	printk(KERN_INFO "mpic:    - Workarounds on AMD 8131 @ %p\n", devbase);
+
+	for (i=0; i < 4; i++) {
+		writeb(0x10 + 2*i, devbase + 0xba);
+		tmp = readl(devbase + 0xbc);
+		if ((tmp & 0x1) || !(tmp & 0x20))
+			continue;
+		irq = (tmp >> 16) & 0xff;
+		mpic->fixups[irq].irq = i;
+		mpic->fixups[irq].base = devbase + 0xba;
+	}
+}
+ 
+static void __init mpic_scan_ioapics(struct mpic *mpic)
+{
+	unsigned int devfn;
+	u8 __iomem *cfgspace;
+
+	printk(KERN_INFO "mpic: Setting up IO-APICs workarounds for U3\n");
+
+	/* Allocate fixups array */
+	mpic->fixups = alloc_bootmem(128 * sizeof(struct mpic_irq_fixup));
+	BUG_ON(mpic->fixups == NULL);
+	memset(mpic->fixups, 0, 128 * sizeof(struct mpic_irq_fixup));
+
+	/* Init spinlock */
+	spin_lock_init(&mpic->fixup_lock);
+
+	/* Map u3 config space. We assume all IO-APICs are on the primary bus
+	 * and slot will never be above "0xf" so we only need to map 32k
+	 */
+	cfgspace = (unsigned char __iomem *)ioremap(0xf2000000, 0x8000);
+	BUG_ON(cfgspace == NULL);
+
+	/* Now we scan all slots. We do a very quick scan, we read the header type,
+	 * vendor ID and device ID only, that's plenty enough
+	 */
+	for (devfn = 0; devfn < PCI_DEVFN(0x10,0); devfn ++) {
+		u8 __iomem *devbase = cfgspace + (devfn << 8);
+		u8 hdr_type = readb(devbase + PCI_HEADER_TYPE);
+		u32 l = readl(devbase + PCI_VENDOR_ID);
+		u16 vendor_id, device_id;
+		int multifunc = 0;
+
+		DBG("devfn %x, l: %x\n", devfn, l);
+
+		/* If no device, skip */
+		if (l == 0xffffffff || l == 0x00000000 ||
+		    l == 0x0000ffff || l == 0xffff0000)
+			goto next;
+
+		/* Check if it's a multifunction device (only really used
+		 * to function 0 though
+		 */
+		multifunc = !!(hdr_type & 0x80);
+		vendor_id = l & 0xffff;
+		device_id = (l >> 16) & 0xffff;
+
+		/* If a known device, go to fixup setup code */
+		if (vendor_id == PCI_VENDOR_ID_AMD && device_id == 0x7460)
+			mpic_amd8111_read_irq(mpic, devbase);
+		if (vendor_id == PCI_VENDOR_ID_AMD && device_id == 0x7450)
+			mpic_amd8131_read_irq(mpic, devbase);
+	next:
+		/* next device, if function 0 */
+		if ((PCI_FUNC(devfn) == 0) && !multifunc)
+			devfn += 7;
+	}
+}
+
+#endif /* CONFIG_MPIC_BROKEN_U3 */
+
+
+/* Find an mpic associated with a given linux interrupt */
+static struct mpic *mpic_find(unsigned int irq, unsigned int *is_ipi)
+{
+	struct mpic *mpic = mpics;
+
+	while(mpic) {
+		/* search IPIs first since they may override the main interrupts */
+		if (irq >= mpic->ipi_offset && irq < (mpic->ipi_offset + 4)) {
+			if (is_ipi)
+				*is_ipi = 1;
+			return mpic;
+		}
+		if (irq >= mpic->irq_offset &&
+		    irq < (mpic->irq_offset + mpic->irq_count)) {
+			if (is_ipi)
+				*is_ipi = 0;
+			return mpic;
+		}
+		mpic = mpic -> next;
+	}
+	return NULL;
+}
+
+/* Convert a cpu mask from logical to physical cpu numbers. */
+static inline u32 mpic_physmask(u32 cpumask)
+{
+	int i;
+	u32 mask = 0;
+
+	for (i = 0; i < NR_CPUS; ++i, cpumask >>= 1)
+		mask |= (cpumask & 1) << get_hard_smp_processor_id(i);
+	return mask;
+}
+
+#ifdef CONFIG_SMP
+/* Get the mpic structure from the IPI number */
+static inline struct mpic * mpic_from_ipi(unsigned int ipi)
+{
+	return container_of(irq_desc[ipi].handler, struct mpic, hc_ipi);
+}
+#endif
+
+/* Get the mpic structure from the irq number */
+static inline struct mpic * mpic_from_irq(unsigned int irq)
+{
+	return container_of(irq_desc[irq].handler, struct mpic, hc_irq);
+}
+
+/* Send an EOI */
+static inline void mpic_eoi(struct mpic *mpic)
+{
+	mpic_cpu_write(MPIC_CPU_EOI, 0);
+	(void)mpic_cpu_read(MPIC_CPU_WHOAMI);
+}
+
+#ifdef CONFIG_SMP
+static irqreturn_t mpic_ipi_action(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct mpic *mpic = dev_id;
+
+	smp_message_recv(irq - mpic->ipi_offset, regs);
+	return IRQ_HANDLED;
+}
+#endif /* CONFIG_SMP */
+
+/*
+ * Linux descriptor level callbacks
+ */
+
+
+static void mpic_enable_irq(unsigned int irq)
+{
+	unsigned int loops = 100000;
+	struct mpic *mpic = mpic_from_irq(irq);
+	unsigned int src = irq - mpic->irq_offset;
+
+	DBG("%s: enable_irq: %d (src %d)\n", mpic->name, irq, src);
+
+	mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
+		       mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & ~MPIC_VECPRI_MASK);
+
+	/* make sure mask gets to controller before we return to user */
+	do {
+		if (!loops--) {
+			printk(KERN_ERR "mpic_enable_irq timeout\n");
+			break;
+		}
+	} while(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK);	
+}
+
+static void mpic_disable_irq(unsigned int irq)
+{
+	unsigned int loops = 100000;
+	struct mpic *mpic = mpic_from_irq(irq);
+	unsigned int src = irq - mpic->irq_offset;
+
+	DBG("%s: disable_irq: %d (src %d)\n", mpic->name, irq, src);
+
+	mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
+		       mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) | MPIC_VECPRI_MASK);
+
+	/* make sure mask gets to controller before we return to user */
+	do {
+		if (!loops--) {
+			printk(KERN_ERR "mpic_enable_irq timeout\n");
+			break;
+		}
+	} while(!(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK));
+}
+
+static void mpic_end_irq(unsigned int irq)
+{
+	struct mpic *mpic = mpic_from_irq(irq);
+
+	DBG("%s: end_irq: %d\n", mpic->name, irq);
+
+	/* We always EOI on end_irq() even for edge interrupts since that
+	 * should only lower the priority, the MPIC should have properly
+	 * latched another edge interrupt coming in anyway
+	 */
+
+#ifdef CONFIG_MPIC_BROKEN_U3
+	if (mpic->flags & MPIC_BROKEN_U3) {
+		unsigned int src = irq - mpic->irq_offset;
+		if (mpic_is_ht_interrupt(mpic, src))
+			mpic_apic_end_irq(mpic, src);
+	}
+#endif /* CONFIG_MPIC_BROKEN_U3 */
+
+	mpic_eoi(mpic);
+}
+
+#ifdef CONFIG_SMP
+
+static void mpic_enable_ipi(unsigned int irq)
+{
+	struct mpic *mpic = mpic_from_ipi(irq);
+	unsigned int src = irq - mpic->ipi_offset;
+
+	DBG("%s: enable_ipi: %d (ipi %d)\n", mpic->name, irq, src);
+	mpic_ipi_write(src, mpic_ipi_read(src) & ~MPIC_VECPRI_MASK);
+}
+
+static void mpic_disable_ipi(unsigned int irq)
+{
+	/* NEVER disable an IPI... that's just plain wrong! */
+}
+
+static void mpic_end_ipi(unsigned int irq)
+{
+	struct mpic *mpic = mpic_from_ipi(irq);
+
+	/*
+	 * IPIs are marked IRQ_PER_CPU. This has the side effect of
+	 * preventing the IRQ_PENDING/IRQ_INPROGRESS logic from
+	 * applying to them. We EOI them late to avoid re-entering.
+	 * We mark IPI's with SA_INTERRUPT as they must run with
+	 * irqs disabled.
+	 */
+	mpic_eoi(mpic);
+}
+
+#endif /* CONFIG_SMP */
+
+static void mpic_set_affinity(unsigned int irq, cpumask_t cpumask)
+{
+	struct mpic *mpic = mpic_from_irq(irq);
+
+	cpumask_t tmp;
+
+	cpus_and(tmp, cpumask, cpu_online_map);
+
+	mpic_irq_write(irq - mpic->irq_offset, MPIC_IRQ_DESTINATION,
+		       mpic_physmask(cpus_addr(tmp)[0]));	
+}
+
+
+/*
+ * Exported functions
+ */
+
+
+struct mpic * __init mpic_alloc(unsigned long phys_addr,
+				unsigned int flags,
+				unsigned int isu_size,
+				unsigned int irq_offset,
+				unsigned int irq_count,
+				unsigned int ipi_offset,
+				unsigned char *senses,
+				unsigned int senses_count,
+				const char *name)
+{
+	struct mpic	*mpic;
+	u32		reg;
+	const char	*vers;
+	int		i;
+
+	mpic = alloc_bootmem(sizeof(struct mpic));
+	if (mpic == NULL)
+		return NULL;
+	
+	memset(mpic, 0, sizeof(struct mpic));
+	mpic->name = name;
+
+	mpic->hc_irq.typename = name;
+	mpic->hc_irq.enable = mpic_enable_irq;
+	mpic->hc_irq.disable = mpic_disable_irq;
+	mpic->hc_irq.end = mpic_end_irq;
+	if (flags & MPIC_PRIMARY)
+		mpic->hc_irq.set_affinity = mpic_set_affinity;
+#ifdef CONFIG_SMP
+	mpic->hc_ipi.typename = name;
+	mpic->hc_ipi.enable = mpic_enable_ipi;
+	mpic->hc_ipi.disable = mpic_disable_ipi;
+	mpic->hc_ipi.end = mpic_end_ipi;
+#endif /* CONFIG_SMP */
+
+	mpic->flags = flags;
+	mpic->isu_size = isu_size;
+	mpic->irq_offset = irq_offset;
+	mpic->irq_count = irq_count;
+	mpic->ipi_offset = ipi_offset;
+	mpic->num_sources = 0; /* so far */
+	mpic->senses = senses;
+	mpic->senses_count = senses_count;
+
+	/* Map the global registers */
+	mpic->gregs = ioremap(phys_addr + MPIC_GREG_BASE, 0x1000);
+	mpic->tmregs = mpic->gregs + (MPIC_TIMER_BASE >> 2);
+	BUG_ON(mpic->gregs == NULL);
+
+	/* Reset */
+	if (flags & MPIC_WANTS_RESET) {
+		mpic_write(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0,
+			   mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
+			   | MPIC_GREG_GCONF_RESET);
+		while( mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
+		       & MPIC_GREG_GCONF_RESET)
+			mb();
+	}
+
+	/* Read feature register, calculate num CPUs and, for non-ISU
+	 * MPICs, num sources as well. On ISU MPICs, sources are counted
+	 * as ISUs are added
+	 */
+	reg = mpic_read(mpic->gregs, MPIC_GREG_FEATURE_0);
+	mpic->num_cpus = ((reg & MPIC_GREG_FEATURE_LAST_CPU_MASK)
+			  >> MPIC_GREG_FEATURE_LAST_CPU_SHIFT) + 1;
+	if (isu_size == 0)
+		mpic->num_sources = ((reg & MPIC_GREG_FEATURE_LAST_SRC_MASK)
+				     >> MPIC_GREG_FEATURE_LAST_SRC_SHIFT) + 1;
+
+	/* Map the per-CPU registers */
+	for (i = 0; i < mpic->num_cpus; i++) {
+		mpic->cpuregs[i] = ioremap(phys_addr + MPIC_CPU_BASE +
+					   i * MPIC_CPU_STRIDE, 0x1000);
+		BUG_ON(mpic->cpuregs[i] == NULL);
+	}
+
+	/* Initialize main ISU if none provided */
+	if (mpic->isu_size == 0) {
+		mpic->isu_size = mpic->num_sources;
+		mpic->isus[0] = ioremap(phys_addr + MPIC_IRQ_BASE,
+					MPIC_IRQ_STRIDE * mpic->isu_size);
+		BUG_ON(mpic->isus[0] == NULL);
+	}
+	mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
+	mpic->isu_mask = (1 << mpic->isu_shift) - 1;
+
+	/* Display version */
+	switch (reg & MPIC_GREG_FEATURE_VERSION_MASK) {
+	case 1:
+		vers = "1.0";
+		break;
+	case 2:
+		vers = "1.2";
+		break;
+	case 3:
+		vers = "1.3";
+		break;
+	default:
+		vers = "<unknown>";
+		break;
+	}
+	printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %lx, max %d CPUs\n",
+	       name, vers, phys_addr, mpic->num_cpus);
+	printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n", mpic->isu_size,
+	       mpic->isu_shift, mpic->isu_mask);
+
+	mpic->next = mpics;
+	mpics = mpic;
+
+	if (flags & MPIC_PRIMARY)
+		mpic_primary = mpic;
+
+	return mpic;
+}
+
+void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
+			    unsigned long phys_addr)
+{
+	unsigned int isu_first = isu_num * mpic->isu_size;
+
+	BUG_ON(isu_num >= MPIC_MAX_ISU);
+
+	mpic->isus[isu_num] = ioremap(phys_addr, MPIC_IRQ_STRIDE * mpic->isu_size);
+	if ((isu_first + mpic->isu_size) > mpic->num_sources)
+		mpic->num_sources = isu_first + mpic->isu_size;
+}
+
+void __init mpic_setup_cascade(unsigned int irq, mpic_cascade_t handler,
+			       void *data)
+{
+	struct mpic *mpic = mpic_find(irq, NULL);
+	unsigned long flags;
+
+	/* Synchronization here is a bit dodgy, so don't try to replace cascade
+	 * interrupts on the fly too often ... but normally it's set up at boot.
+	 */
+	spin_lock_irqsave(&mpic_lock, flags);
+	if (mpic->cascade)	       
+		mpic_disable_irq(mpic->cascade_vec + mpic->irq_offset);
+	mpic->cascade = NULL;
+	wmb();
+	mpic->cascade_vec = irq - mpic->irq_offset;
+	mpic->cascade_data = data;
+	wmb();
+	mpic->cascade = handler;
+	mpic_enable_irq(irq);
+	spin_unlock_irqrestore(&mpic_lock, flags);
+}
+
+void __init mpic_init(struct mpic *mpic)
+{
+	int i;
+
+	BUG_ON(mpic->num_sources == 0);
+
+	printk(KERN_INFO "mpic: Initializing for %d sources\n", mpic->num_sources);
+
+	/* Set current processor priority to max */
+	mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0xf);
+
+	/* Initialize timers: just disable them all */
+	for (i = 0; i < 4; i++) {
+		mpic_write(mpic->tmregs,
+			   i * MPIC_TIMER_STRIDE + MPIC_TIMER_DESTINATION, 0);
+		mpic_write(mpic->tmregs,
+			   i * MPIC_TIMER_STRIDE + MPIC_TIMER_VECTOR_PRI,
+			   MPIC_VECPRI_MASK |
+			   (MPIC_VEC_TIMER_0 + i));
+	}
+
+	/* Initialize IPIs to our reserved vectors and mark them disabled for now */
+	mpic_test_broken_ipi(mpic);
+	for (i = 0; i < 4; i++) {
+		mpic_ipi_write(i,
+			       MPIC_VECPRI_MASK |
+			       (10 << MPIC_VECPRI_PRIORITY_SHIFT) |
+			       (MPIC_VEC_IPI_0 + i));
+#ifdef CONFIG_SMP
+		if (!(mpic->flags & MPIC_PRIMARY))
+			continue;
+		irq_desc[mpic->ipi_offset+i].status |= IRQ_PER_CPU;
+		irq_desc[mpic->ipi_offset+i].handler = &mpic->hc_ipi;
+		
+#endif /* CONFIG_SMP */
+	}
+
+	/* Initialize interrupt sources */
+	if (mpic->irq_count == 0)
+		mpic->irq_count = mpic->num_sources;
+
+#ifdef CONFIG_MPIC_BROKEN_U3
+	/* Do the ioapic fixups on U3 broken mpic */
+	DBG("MPIC flags: %x\n", mpic->flags);
+	if ((mpic->flags & MPIC_BROKEN_U3) && (mpic->flags & MPIC_PRIMARY))
+		mpic_scan_ioapics(mpic);
+#endif /* CONFIG_MPIC_BROKEN_U3 */
+
+	for (i = 0; i < mpic->num_sources; i++) {
+		/* start with vector = source number, and masked */
+		u32 vecpri = MPIC_VECPRI_MASK | i | (8 << MPIC_VECPRI_PRIORITY_SHIFT);
+		int level = 0;
+		
+		/* if it's an IPI, we skip it */
+		if ((mpic->irq_offset + i) >= (mpic->ipi_offset + i) &&
+		    (mpic->irq_offset + i) <  (mpic->ipi_offset + i + 4))
+			continue;
+
+		/* do senses munging */
+		if (mpic->senses && i < mpic->senses_count) {
+			if (mpic->senses[i] & IRQ_SENSE_LEVEL)
+				vecpri |= MPIC_VECPRI_SENSE_LEVEL;
+			if (mpic->senses[i] & IRQ_POLARITY_POSITIVE)
+				vecpri |= MPIC_VECPRI_POLARITY_POSITIVE;
+		} else
+			vecpri |= MPIC_VECPRI_SENSE_LEVEL;
+
+		/* remember if it was a level interrupts */
+		level = (vecpri & MPIC_VECPRI_SENSE_LEVEL);
+
+		/* deal with broken U3 */
+		if (mpic->flags & MPIC_BROKEN_U3) {
+#ifdef CONFIG_MPIC_BROKEN_U3
+			if (mpic_is_ht_interrupt(mpic, i)) {
+				vecpri &= ~(MPIC_VECPRI_SENSE_MASK |
+					    MPIC_VECPRI_POLARITY_MASK);
+				vecpri |= MPIC_VECPRI_POLARITY_POSITIVE;
+			}
+#else
+			printk(KERN_ERR "mpic: BROKEN_U3 set, but CONFIG doesn't match\n");
+#endif
+		}
+
+		DBG("setup source %d, vecpri: %08x, level: %d\n", i, vecpri,
+		    (level != 0));
+
+		/* init hw */
+		mpic_irq_write(i, MPIC_IRQ_VECTOR_PRI, vecpri);
+		mpic_irq_write(i, MPIC_IRQ_DESTINATION,
+			       1 << get_hard_smp_processor_id(boot_cpuid));
+
+		/* init linux descriptors */
+		if (i < mpic->irq_count) {
+			irq_desc[mpic->irq_offset+i].status = level ? IRQ_LEVEL : 0;
+			irq_desc[mpic->irq_offset+i].handler = &mpic->hc_irq;
+		}
+	}
+	
+	/* Init spurrious vector */
+	mpic_write(mpic->gregs, MPIC_GREG_SPURIOUS, MPIC_VEC_SPURRIOUS);
+
+	/* Disable 8259 passthrough */
+	mpic_write(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0,
+		   mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
+		   | MPIC_GREG_GCONF_8259_PTHROU_DIS);
+
+	/* Set current processor priority to 0 */
+	mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0);
+}
+
+
+
+void mpic_irq_set_priority(unsigned int irq, unsigned int pri)
+{
+	int is_ipi;
+	struct mpic *mpic = mpic_find(irq, &is_ipi);
+	unsigned long flags;
+	u32 reg;
+
+	spin_lock_irqsave(&mpic_lock, flags);
+	if (is_ipi) {
+		reg = mpic_ipi_read(irq - mpic->ipi_offset) & MPIC_VECPRI_PRIORITY_MASK;
+		mpic_ipi_write(irq - mpic->ipi_offset,
+			       reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT));
+	} else {
+		reg = mpic_irq_read(irq - mpic->irq_offset, MPIC_IRQ_VECTOR_PRI)
+			& MPIC_VECPRI_PRIORITY_MASK;
+		mpic_irq_write(irq - mpic->irq_offset, MPIC_IRQ_VECTOR_PRI,
+			       reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT));
+	}
+	spin_unlock_irqrestore(&mpic_lock, flags);
+}
+
+unsigned int mpic_irq_get_priority(unsigned int irq)
+{
+	int is_ipi;
+	struct mpic *mpic = mpic_find(irq, &is_ipi);
+	unsigned long flags;
+	u32 reg;
+
+	spin_lock_irqsave(&mpic_lock, flags);
+	if (is_ipi)
+		reg = mpic_ipi_read(irq - mpic->ipi_offset);
+	else
+		reg = mpic_irq_read(irq - mpic->irq_offset, MPIC_IRQ_VECTOR_PRI);
+	spin_unlock_irqrestore(&mpic_lock, flags);
+	return (reg & MPIC_VECPRI_PRIORITY_MASK) >> MPIC_VECPRI_PRIORITY_SHIFT;
+}
+
+void mpic_setup_this_cpu(void)
+{
+#ifdef CONFIG_SMP
+	struct mpic *mpic = mpic_primary;
+	unsigned long flags;
+#ifdef CONFIG_IRQ_ALL_CPUS
+	u32 msk = 1 << hard_smp_processor_id();
+	unsigned int i;
+#endif
+
+	BUG_ON(mpic == NULL);
+
+	DBG("%s: setup_this_cpu(%d)\n", mpic->name, hard_smp_processor_id());
+
+	spin_lock_irqsave(&mpic_lock, flags);
+
+#ifdef CONFIG_IRQ_ALL_CPUS
+ 	/* let the mpic know we want intrs. default affinity is 0xffffffff
+	 * until changed via /proc. That's how it's done on x86. If we want
+	 * it differently, then we should make sure we also change the default
+	 * values of irq_affinity in irq.c.
+ 	 */
+ 	for (i = 0; i < mpic->num_sources ; i++)
+		mpic_irq_write(i, MPIC_IRQ_DESTINATION,
+			mpic_irq_read(i, MPIC_IRQ_DESTINATION) | msk);
+#endif /* CONFIG_IRQ_ALL_CPUS */
+
+	/* Set current processor priority to 0 */
+	mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0);
+
+	spin_unlock_irqrestore(&mpic_lock, flags);
+#endif /* CONFIG_SMP */
+}
+
+void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask)
+{
+	struct mpic *mpic = mpic_primary;
+
+	BUG_ON(mpic == NULL);
+
+	DBG("%s: send_ipi(ipi_no: %d)\n", mpic->name, ipi_no);
+
+	mpic_cpu_write(MPIC_CPU_IPI_DISPATCH_0 + ipi_no * 0x10,
+		       mpic_physmask(cpu_mask & cpus_addr(cpu_online_map)[0]));
+}
+
+int mpic_get_one_irq(struct mpic *mpic, struct pt_regs *regs)
+{
+	u32 irq;
+
+	irq = mpic_cpu_read(MPIC_CPU_INTACK) & MPIC_VECPRI_VECTOR_MASK;
+	DBG("%s: get_one_irq(): %d\n", mpic->name, irq);
+
+	if (mpic->cascade && irq == mpic->cascade_vec) {
+		DBG("%s: cascading ...\n", mpic->name);
+		irq = mpic->cascade(regs, mpic->cascade_data);
+		mpic_eoi(mpic);
+		return irq;
+	}
+	if (unlikely(irq == MPIC_VEC_SPURRIOUS))
+		return -1;
+	if (irq < MPIC_VEC_IPI_0) 
+		return irq + mpic->irq_offset;
+       	DBG("%s: ipi %d !\n", mpic->name, irq - MPIC_VEC_IPI_0);
+	return irq - MPIC_VEC_IPI_0 + mpic->ipi_offset;
+}
+
+int mpic_get_irq(struct pt_regs *regs)
+{
+	struct mpic *mpic = mpic_primary;
+
+	BUG_ON(mpic == NULL);
+
+	return mpic_get_one_irq(mpic, regs);
+}
+
+
+#ifdef CONFIG_SMP
+void mpic_request_ipis(void)
+{
+	struct mpic *mpic = mpic_primary;
+
+	BUG_ON(mpic == NULL);
+	
+	printk("requesting IPIs ... \n");
+
+	/* IPIs are marked SA_INTERRUPT as they must run with irqs disabled */
+	request_irq(mpic->ipi_offset+0, mpic_ipi_action, SA_INTERRUPT,
+		    "IPI0 (call function)", mpic);
+	request_irq(mpic->ipi_offset+1, mpic_ipi_action, SA_INTERRUPT,
+		   "IPI1 (reschedule)", mpic);
+	request_irq(mpic->ipi_offset+2, mpic_ipi_action, SA_INTERRUPT,
+		   "IPI2 (unused)", mpic);
+	request_irq(mpic->ipi_offset+3, mpic_ipi_action, SA_INTERRUPT,
+		   "IPI3 (debugger break)", mpic);
+
+	printk("IPIs requested... \n");
+}
+#endif /* CONFIG_SMP */
diff -Nru a/arch/ppc64/kernel/mpic.h b/arch/ppc64/kernel/mpic.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/kernel/mpic.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,267 @@
+#include <linux/irq.h>
+
+/*
+ * Global registers
+ */
+
+#define MPIC_GREG_BASE			0x01000
+
+#define MPIC_GREG_FEATURE_0		0x00000
+#define		MPIC_GREG_FEATURE_LAST_SRC_MASK		0x07ff0000
+#define		MPIC_GREG_FEATURE_LAST_SRC_SHIFT	16
+#define		MPIC_GREG_FEATURE_LAST_CPU_MASK		0x00001f00
+#define		MPIC_GREG_FEATURE_LAST_CPU_SHIFT	8
+#define		MPIC_GREG_FEATURE_VERSION_MASK		0xff
+#define MPIC_GREG_FEATURE_1		0x00010
+#define MPIC_GREG_GLOBAL_CONF_0		0x00020
+#define		MPIC_GREG_GCONF_RESET			0x80000000
+#define		MPIC_GREG_GCONF_8259_PTHROU_DIS		0x20000000
+#define		MPIC_GREG_GCONF_BASE_MASK		0x000fffff
+#define MPIC_GREG_GLOBAL_CONF_1		0x00030
+#define MPIC_GREG_VENDOR_0		0x00040
+#define MPIC_GREG_VENDOR_1		0x00050
+#define MPIC_GREG_VENDOR_2		0x00060
+#define MPIC_GREG_VENDOR_3		0x00070
+#define MPIC_GREG_VENDOR_ID		0x00080
+#define 	MPIC_GREG_VENDOR_ID_STEPPING_MASK	0x00ff0000
+#define 	MPIC_GREG_VENDOR_ID_STEPPING_SHIFT	16
+#define 	MPIC_GREG_VENDOR_ID_DEVICE_ID_MASK	0x0000ff00
+#define 	MPIC_GREG_VENDOR_ID_DEVICE_ID_SHIFT	8
+#define 	MPIC_GREG_VENDOR_ID_VENDOR_ID_MASK	0x000000ff
+#define MPIC_GREG_PROCESSOR_INIT	0x00090
+#define MPIC_GREG_IPI_VECTOR_PRI_0	0x000a0
+#define MPIC_GREG_IPI_VECTOR_PRI_1	0x000b0
+#define MPIC_GREG_IPI_VECTOR_PRI_2	0x000c0
+#define MPIC_GREG_IPI_VECTOR_PRI_3	0x000d0
+#define MPIC_GREG_SPURIOUS		0x000e0
+#define MPIC_GREG_TIMER_FREQ		0x000f0
+
+/*
+ *
+ * Timer registers
+ */
+#define MPIC_TIMER_BASE			0x01100
+#define MPIC_TIMER_STRIDE		0x40
+
+#define MPIC_TIMER_CURRENT_CNT		0x00000
+#define MPIC_TIMER_BASE_CNT		0x00010
+#define MPIC_TIMER_VECTOR_PRI		0x00020
+#define MPIC_TIMER_DESTINATION		0x00030
+
+/*
+ * Per-Processor registers
+ */
+
+#define MPIC_CPU_THISBASE		0x00000
+#define MPIC_CPU_BASE			0x20000
+#define MPIC_CPU_STRIDE			0x01000
+
+#define MPIC_CPU_IPI_DISPATCH_0		0x00040
+#define MPIC_CPU_IPI_DISPATCH_1		0x00050
+#define MPIC_CPU_IPI_DISPATCH_2		0x00060
+#define MPIC_CPU_IPI_DISPATCH_3		0x00070
+#define MPIC_CPU_CURRENT_TASK_PRI	0x00080
+#define 	MPIC_CPU_TASKPRI_MASK			0x0000000f
+#define MPIC_CPU_WHOAMI			0x00090
+#define 	MPIC_CPU_WHOAMI_MASK			0x0000001f
+#define MPIC_CPU_INTACK			0x000a0
+#define MPIC_CPU_EOI			0x000b0
+
+/*
+ * Per-source registers
+ */
+
+#define MPIC_IRQ_BASE			0x10000
+#define MPIC_IRQ_STRIDE			0x00020
+#define MPIC_IRQ_VECTOR_PRI		0x00000
+#define 	MPIC_VECPRI_MASK			0x80000000
+#define 	MPIC_VECPRI_ACTIVITY			0x40000000	/* Read Only */
+#define 	MPIC_VECPRI_PRIORITY_MASK		0x000f0000
+#define 	MPIC_VECPRI_PRIORITY_SHIFT		16
+#define 	MPIC_VECPRI_VECTOR_MASK			0x000007ff
+#define 	MPIC_VECPRI_POLARITY_POSITIVE		0x00800000
+#define 	MPIC_VECPRI_POLARITY_NEGATIVE		0x00000000
+#define 	MPIC_VECPRI_POLARITY_MASK		0x00800000
+#define 	MPIC_VECPRI_SENSE_LEVEL			0x00400000
+#define 	MPIC_VECPRI_SENSE_EDGE			0x00000000
+#define 	MPIC_VECPRI_SENSE_MASK			0x00400000
+#define MPIC_IRQ_DESTINATION		0x00010
+
+#define MPIC_MAX_IRQ_SOURCES	2048
+#define MPIC_MAX_CPUS		32
+#define MPIC_MAX_ISU		32
+
+/*
+ * Special vector numbers (internal use only)
+ */
+#define MPIC_VEC_SPURRIOUS	255
+#define MPIC_VEC_IPI_3		254
+#define MPIC_VEC_IPI_2		253
+#define MPIC_VEC_IPI_1		252
+#define MPIC_VEC_IPI_0		251
+
+/* unused */
+#define MPIC_VEC_TIMER_3	250
+#define MPIC_VEC_TIMER_2	249
+#define MPIC_VEC_TIMER_1	248
+#define MPIC_VEC_TIMER_0	247
+
+/* Type definition of the cascade handler */
+typedef int (*mpic_cascade_t)(struct pt_regs *regs, void *data);
+
+#ifdef CONFIG_MPIC_BROKEN_U3
+/* Fixup table entry */
+struct mpic_irq_fixup
+{
+	u8 __iomem	*base;
+	unsigned int   irq;
+};
+#endif /* CONFIG_MPIC_BROKEN_U3 */
+
+
+/* The instance data of a given MPIC */
+struct mpic
+{
+	/* The "linux" controller struct */
+	hw_irq_controller	hc_irq;
+#ifdef CONFIG_SMP
+	hw_irq_controller	hc_ipi;
+#endif
+	const char		*name;
+	/* Flags */
+	unsigned int		flags;
+	/* How many irq sources in a given ISU */
+	unsigned int		isu_size;
+	unsigned int		isu_shift;
+	unsigned int		isu_mask;
+	/* Offset of irq vector numbers */
+	unsigned int		irq_offset;	
+	unsigned int		irq_count;
+	/* Offset of ipi vector numbers */
+	unsigned int		ipi_offset;
+	/* Number of sources */
+	unsigned int		num_sources;
+	/* Number of CPUs */
+	unsigned int		num_cpus;
+	/* cascade handler */
+	mpic_cascade_t		cascade;
+	void			*cascade_data;
+	unsigned int		cascade_vec;
+	/* senses array */
+	unsigned char		*senses;
+	unsigned int		senses_count;
+
+#ifdef CONFIG_MPIC_BROKEN_U3
+	/* The fixup table */
+	struct mpic_irq_fixup	*fixups;
+	spinlock_t		fixup_lock;
+#endif
+
+	/* The various ioremap'ed bases */
+	volatile u32 __iomem	*gregs;
+	volatile u32 __iomem	*tmregs;
+	volatile u32 __iomem	*cpuregs[MPIC_MAX_CPUS];
+	volatile u32 __iomem	*isus[MPIC_MAX_ISU];
+
+	/* link */
+	struct mpic		*next;
+};
+
+/* This is the primary controller, only that one has IPIs and
+ * has afinity control. A non-primary MPIC always uses CPU0
+ * registers only
+ */
+#define MPIC_PRIMARY			0x00000001
+/* Set this for a big-endian MPIC */
+#define MPIC_BIG_ENDIAN			0x00000002
+/* Broken U3 MPIC */
+#define MPIC_BROKEN_U3			0x00000004
+/* Broken IPI registers (autodetected) */
+#define MPIC_BROKEN_IPI			0x00000008
+/* MPIC wants a reset */
+#define MPIC_WANTS_RESET		0x00000010
+
+/* Allocate the controller structure and setup the linux irq descs
+ * for the range if interrupts passed in. No HW initialization is
+ * actually performed.
+ * 
+ * @phys_addr:	physial base address of the MPIC
+ * @flags:	flags, see constants above
+ * @isu_size:	number of interrupts in an ISU. Use 0 to use a
+ *              standard ISU-less setup (aka powermac)
+ * @irq_offset: first irq number to assign to this mpic
+ * @irq_count:  number of irqs to use with this mpic IRQ sources. Pass 0
+ *	        to match the number of sources
+ * @ipi_offset: first irq number to assign to this mpic IPI sources,
+ *		used only on primary mpic
+ * @senses:	array of sense values
+ * @senses_num: number of entries in the array
+ *
+ * Note about the sense array. If none is passed, all interrupts are
+ * setup to be level negative unless MPIC_BROKEN_U3 is set in which
+ * case they are edge positive (and the array is ignored anyway).
+ * The values in the array start at the first source of the MPIC,
+ * that is senses[0] correspond to linux irq "irq_offset".
+ */
+extern struct mpic *mpic_alloc(unsigned long phys_addr,
+			       unsigned int flags,
+			       unsigned int isu_size,
+			       unsigned int irq_offset,
+			       unsigned int irq_count,
+			       unsigned int ipi_offset,
+			       unsigned char *senses,
+			       unsigned int senses_num,
+			       const char *name);
+
+/* Assign ISUs, to call before mpic_init()
+ *
+ * @mpic:	controller structure as returned by mpic_alloc()
+ * @isu_num:	ISU number
+ * @phys_addr:	physical address of the ISU
+ */
+extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
+			    unsigned long phys_addr);
+
+/* Initialize the controller. After this has been called, none of the above
+ * should be called again for this mpic
+ */
+extern void mpic_init(struct mpic *mpic);
+
+/* Setup a cascade. Currently, only one cascade is supported this
+ * way, though you can always do a normal request_irq() and add
+ * other cascades this way. You should call this _after_ having
+ * added all the ISUs
+ *
+ * @irq_no:	"linux" irq number of the cascade (that is offset'ed vector)
+ * @handler:	cascade handler function
+ */
+extern void mpic_setup_cascade(unsigned int irq_no, mpic_cascade_t hanlder,
+			       void *data);
+
+/*
+ * All of the following functions must only be used after the
+ * ISUs have been assigned and the controller fully initialized
+ * with mpic_init()
+ */
+
+
+/* Change/Read the priority of an interrupt. Default is 8 for irqs and
+ * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the
+ * IPI number is then the offset'ed (linux irq number mapped to the IPI)
+ */
+extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri);
+extern unsigned int mpic_irq_get_priority(unsigned int irq);
+
+/* Setup a non-boot CPU */
+extern void mpic_setup_this_cpu(void);
+
+/* Request IPIs on primary mpic */
+extern void mpic_request_ipis(void);
+
+/* Send an IPI (non offseted number 0..3) */
+extern void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask);
+
+/* Fetch interrupt from a given mpic */
+extern int mpic_get_one_irq(struct mpic *mpic, struct pt_regs *regs);
+/* This one gets to the primary mpic */
+extern int mpic_get_irq(struct pt_regs *regs);
diff -Nru a/arch/ppc64/kernel/nvram.c b/arch/ppc64/kernel/nvram.c
--- a/arch/ppc64/kernel/nvram.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc64/kernel/nvram.c	2004-12-24 13:36:17 -08:00
@@ -43,9 +43,9 @@
 static long nvram_error_log_index = -1;
 static long nvram_error_log_size = 0;
 
-volatile int no_more_logging = 1; /* Until we initialize everything,
-				   * make sure we don't try logging
-				   * anything */
+int no_logging = 1; 	/* Until we initialize everything,
+			 * make sure we don't try logging
+			 * anything */
 
 extern volatile int error_log_cnt;
 
@@ -77,7 +77,7 @@
 }
 
 
-static ssize_t dev_nvram_read(struct file *file, char *buf,
+static ssize_t dev_nvram_read(struct file *file, char __user *buf,
 			  size_t count, loff_t *ppos)
 {
 	ssize_t len;
@@ -117,7 +117,7 @@
 
 }
 
-static ssize_t dev_nvram_write(struct file *file, const char *buf,
+static ssize_t dev_nvram_write(struct file *file, const char __user *buf,
 			   size_t count, loff_t *ppos)
 {
 	ssize_t len;
@@ -640,7 +640,7 @@
 	loff_t tmp_index;
 	struct err_log_info info;
 	
-	if (no_more_logging) {
+	if (no_logging) {
 		return -EPERM;
 	}
 
@@ -711,7 +711,7 @@
 /* This doesn't actually zero anything, but it sets the event_logged
  * word to tell that this event is safely in syslog.
  */
-int nvram_clear_error_log()
+int nvram_clear_error_log(void)
 {
 	loff_t tmp_index;
 	int clear_word = ERR_FLAG_ALREADY_LOGGED;
diff -Nru a/arch/ppc64/kernel/open_pic.c b/arch/ppc64/kernel/open_pic.c
--- a/arch/ppc64/kernel/open_pic.c	2004-12-24 13:36:59 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,886 +0,0 @@
-/*
- *  arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling
- *
- *  Copyright (C) 1997 Geert Uytterhoeven
- *
- *  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 <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/smp.h>
-#include <linux/interrupt.h>
-#include <asm/ptrace.h>
-#include <asm/signal.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/irq.h>
-#include <asm/prom.h>
-
-#include <asm/machdep.h>
-
-#include "open_pic.h"
-#include "open_pic_defs.h"
-#include "i8259.h"
-#include <asm/ppcdebug.h>
-
-void* OpenPIC_Addr;
-static volatile struct OpenPIC *OpenPIC = NULL;
-u_int OpenPIC_NumInitSenses __initdata = 0;
-u_char *OpenPIC_InitSenses __initdata = NULL;
-
-/*
- *  Local (static) OpenPIC Operations
- */
-
-
-/* Global Operations */
-static void openpic_reset(void);
-static void openpic_enable_8259_pass_through(void);
-static void openpic_disable_8259_pass_through(void);
-static u_int openpic_irq(void);
-static void openpic_eoi(void);
-static u_int openpic_get_priority(void);
-static void openpic_set_priority(u_int pri);
-static u_int openpic_get_spurious(void);
-static void openpic_set_spurious(u_int vector);
-
-#ifdef CONFIG_SMP
-/* Interprocessor Interrupts */
-static void openpic_initipi(u_int ipi, u_int pri, u_int vector);
-static irqreturn_t openpic_ipi_action(int cpl, void *dev_id,
-					struct pt_regs *regs);
-#endif
-
-/* Timer Interrupts */
-static void openpic_inittimer(u_int timer, u_int pri, u_int vector);
-static void openpic_maptimer(u_int timer, u_int cpumask);
-
-/* Interrupt Sources */
-static void openpic_enable_irq(u_int irq);
-static void openpic_disable_irq(u_int irq);
-static void openpic_initirq(u_int irq, u_int pri, u_int vector, int polarity,
-			    int is_level);
-static void openpic_mapirq(u_int irq, u_int cpumask);
-
-static void find_ISUs(void);
-
-static u_int NumProcessors;
-static u_int NumSources;
-static int NumISUs;
-static int open_pic_irq_offset;
-static volatile unsigned char* chrp_int_ack_special;
-
-OpenPIC_SourcePtr ISU[OPENPIC_MAX_ISU];
-
-static void openpic_end_irq(unsigned int irq_nr);
-static void openpic_set_affinity(unsigned int irq_nr, cpumask_t cpumask);
-
-struct hw_interrupt_type open_pic = {
-	" OpenPIC  ",
-	NULL,
-	NULL,
-	openpic_enable_irq,
-	openpic_disable_irq,
-	NULL,
-	openpic_end_irq,
-	openpic_set_affinity
-};
-
-#ifdef CONFIG_SMP
-static void openpic_end_ipi(unsigned int irq_nr);
-static void openpic_enable_ipi(unsigned int irq_nr);
-static void openpic_disable_ipi(unsigned int irq_nr);
-
-struct hw_interrupt_type open_pic_ipi = {
-	" OpenPIC  ",
-	NULL,
-	NULL,
-	openpic_enable_ipi,
-	openpic_disable_ipi,
-	NULL,
-	openpic_end_ipi,
-	NULL
-};
-#endif /* CONFIG_SMP */
-
-unsigned int openpic_vec_ipi;
-unsigned int openpic_vec_timer;
-unsigned int openpic_vec_spurious;
-
-/*
- *  Accesses to the current processor's openpic registers
- */
-#ifdef CONFIG_SMP
-#define THIS_CPU		Processor[cpu]
-#define DECL_THIS_CPU		int cpu = hard_smp_processor_id()
-#define CHECK_THIS_CPU		check_arg_cpu(cpu)
-#else
-#define THIS_CPU		Processor[hard_smp_processor_id()]
-#define DECL_THIS_CPU
-#define CHECK_THIS_CPU
-#endif /* CONFIG_SMP */
-
-#if 0
-#define check_arg_ipi(ipi) \
-    if (ipi < 0 || ipi >= OPENPIC_NUM_IPI) \
-	printk(KERN_ERR "open_pic.c:%d: invalid ipi %d\n", __LINE__, ipi);
-#define check_arg_timer(timer) \
-    if (timer < 0 || timer >= OPENPIC_NUM_TIMERS) \
-	printk(KERN_ERR "open_pic.c:%d: invalid timer %d\n", __LINE__, timer);
-#define check_arg_vec(vec) \
-    if (vec < 0 || vec >= OPENPIC_NUM_VECTORS) \
-	printk(KERN_ERR "open_pic.c:%d: invalid vector %d\n", __LINE__, vec);
-#define check_arg_pri(pri) \
-    if (pri < 0 || pri >= OPENPIC_NUM_PRI) \
-	printk(KERN_ERR "open_pic.c:%d: invalid priority %d\n", __LINE__, pri);
-/*
- * Print out a backtrace if it's out of range, since if it's larger than NR_IRQ's
- * data has probably been corrupted and we're going to panic or deadlock later
- * anyway --Troy
- */
-#define check_arg_irq(irq) \
-    if (irq < open_pic_irq_offset || irq >= (NumSources+open_pic_irq_offset)){ \
-      printk(KERN_ERR "open_pic.c:%d: invalid irq %d\n", __LINE__, irq); \
-      dump_stack(); }
-#define check_arg_cpu(cpu) \
-    if (cpu < 0 || cpu >= OPENPIC_MAX_PROCESSORS){ \
-	printk(KERN_ERR "open_pic.c:%d: invalid cpu %d\n", __LINE__, cpu); \
-	dump_stack(); }
-#else
-#define check_arg_ipi(ipi)	do {} while (0)
-#define check_arg_timer(timer)	do {} while (0)
-#define check_arg_vec(vec)	do {} while (0)
-#define check_arg_pri(pri)	do {} while (0)
-#define check_arg_irq(irq)	do {} while (0)
-#define check_arg_cpu(cpu)	do {} while (0)
-#endif
-
-#define GET_ISU(source)	ISU[(source) >> 4][(source) & 0xf]
-
-void __init pSeries_init_openpic(void)
-{
-        struct device_node *np;
-        int i;
-        unsigned int *addrp;
-        unsigned char* chrp_int_ack_special = NULL;
-        unsigned char init_senses[NR_IRQS - NUM_ISA_INTERRUPTS];
-        int nmi_irq = -1;
-#if defined(CONFIG_VT) && defined(CONFIG_ADB_KEYBOARD) && defined(XMON)
-        struct device_node *kbd;
-#endif
-
-        if (!(np = of_find_node_by_name(NULL, "pci"))
-            || !(addrp = (unsigned int *)
-                 get_property(np, "8259-interrupt-acknowledge", NULL)))
-                printk(KERN_ERR "Cannot find pci to get ack address\n");
-        else
-		chrp_int_ack_special = (unsigned char *)
-			__ioremap(addrp[prom_n_addr_cells(np)-1], 1, _PAGE_NO_CACHE);
-        /* hydra still sets OpenPIC_InitSenses to a static set of values */
-        if (OpenPIC_InitSenses == NULL) {
-                prom_get_irq_senses(init_senses, NUM_ISA_INTERRUPTS, NR_IRQS);
-                OpenPIC_InitSenses = init_senses;
-                OpenPIC_NumInitSenses = NR_IRQS - NUM_ISA_INTERRUPTS;
-        }
-        openpic_init(1, NUM_ISA_INTERRUPTS, chrp_int_ack_special, nmi_irq);
-        for (i = 0; i < NUM_ISA_INTERRUPTS; i++)
-                irq_desc[i].handler = &i8259_pic;
-	of_node_put(np);
-}
-
-static inline u_int openpic_read(volatile u_int *addr)
-{
-	u_int val;
-
-	val = in_le32(addr);
-	return val;
-}
-
-static inline void openpic_write(volatile u_int *addr, u_int val)
-{
-	out_le32(addr, val);
-}
-
-static inline u_int openpic_readfield(volatile u_int *addr, u_int mask)
-{
-	u_int val = openpic_read(addr);
-	return val & mask;
-}
-
-static inline void openpic_writefield(volatile u_int *addr, u_int mask,
-			       u_int field)
-{
-	u_int val = openpic_read(addr);
-	openpic_write(addr, (val & ~mask) | (field & mask));
-}
-
-static inline void openpic_clearfield(volatile u_int *addr, u_int mask)
-{
-	openpic_writefield(addr, mask, 0);
-}
-
-static inline void openpic_setfield(volatile u_int *addr, u_int mask)
-{
-	openpic_writefield(addr, mask, mask);
-}
-
-static void openpic_safe_writefield(volatile u_int *addr, u_int mask,
-				    u_int field)
-{
-	unsigned int loops = 100000;
-
-	openpic_setfield(addr, OPENPIC_MASK);
-	while (openpic_read(addr) & OPENPIC_ACTIVITY) {
-		if (!loops--) {
-			printk(KERN_ERR "openpic_safe_writefield timeout\n");
-			break;
-		}
-	}
-	openpic_writefield(addr, mask | OPENPIC_MASK, field | OPENPIC_MASK);
-}
-
-#ifdef CONFIG_SMP
-
-static int broken_ipi_registers;
-
-static u_int openpic_read_IPI(volatile u_int* addr)
-{
-        u_int val = 0;
-
-	if (broken_ipi_registers)
-		/* yes this is right ... bug, feature, you decide! -- tgall */
-		val = in_be32(addr);
-	else
-		val = in_le32(addr);
-
-        return val;
-}
-
-static void openpic_test_broken_IPI(void)
-{
-	u_int t;
-
-	openpic_write(&OpenPIC->Global.IPI_Vector_Priority(0), OPENPIC_MASK);
-	t = openpic_read(&OpenPIC->Global.IPI_Vector_Priority(0));
-	if (t == le32_to_cpu(OPENPIC_MASK)) {
-		printk(KERN_INFO "OpenPIC reversed IPI registers detected\n");
-		broken_ipi_registers = 1;
-	}
-}
-
-/* because of the power3 be / le above, this is needed */
-static inline void openpic_writefield_IPI(volatile u_int* addr, u_int mask, u_int field)
-{
-        u_int  val = openpic_read_IPI(addr);
-        openpic_write(addr, (val & ~mask) | (field & mask));
-}
-
-static inline void openpic_clearfield_IPI(volatile u_int *addr, u_int mask)
-{
-        openpic_writefield_IPI(addr, mask, 0);
-}
-
-static inline void openpic_setfield_IPI(volatile u_int *addr, u_int mask)
-{
-        openpic_writefield_IPI(addr, mask, mask);
-}
-
-static void openpic_safe_writefield_IPI(volatile u_int *addr, u_int mask, u_int field)
-{
-	unsigned int loops = 100000;
-
-        openpic_setfield_IPI(addr, OPENPIC_MASK);
-
-        /* wait until it's not in use */
-        /* BenH: Is this code really enough ? I would rather check the result
-         *       and eventually retry ...
-         */
-        while(openpic_read_IPI(addr) & OPENPIC_ACTIVITY) {
-		if (!loops--) {
-			printk(KERN_ERR "openpic_safe_writefield timeout\n");
-			break;
-		}
-	}
-
-        openpic_writefield_IPI(addr, mask, field | OPENPIC_MASK);
-}
-#endif /* CONFIG_SMP */
-
-void __init openpic_init(int main_pic, int offset, unsigned char* chrp_ack,
-			 int programmer_switch_irq)
-{
-	u_int t, i;
-	u_int timerfreq;
-	const char *version;
-
-	if (!OpenPIC_Addr) {
-		printk(KERN_INFO "No OpenPIC found !\n");
-		return;
-	}
-	OpenPIC = (volatile struct OpenPIC *)OpenPIC_Addr;
-
-	ppc64_boot_msg(0x20, "OpenPic Init");
-
-	t = openpic_read(&OpenPIC->Global.Feature_Reporting0);
-	switch (t & OPENPIC_FEATURE_VERSION_MASK) {
-	case 1:
-		version = "1.0";
-		break;
-	case 2:
-		version = "1.2";
-		break;
-	case 3:
-		version = "1.3";
-		break;
-	default:
-		version = "?";
-		break;
-	}
-	NumProcessors = ((t & OPENPIC_FEATURE_LAST_PROCESSOR_MASK) >>
-			 OPENPIC_FEATURE_LAST_PROCESSOR_SHIFT) + 1;
-	NumSources = ((t & OPENPIC_FEATURE_LAST_SOURCE_MASK) >>
-		      OPENPIC_FEATURE_LAST_SOURCE_SHIFT) + 1;
-	printk(KERN_INFO "OpenPIC Version %s (%d CPUs and %d IRQ sources) at %p\n",
-	       version, NumProcessors, NumSources, OpenPIC);
-	timerfreq = openpic_read(&OpenPIC->Global.Timer_Frequency);
-	if (timerfreq)
-		printk(KERN_INFO "OpenPIC timer frequency is %d.%06d MHz\n",
-		       timerfreq / 1000000, timerfreq % 1000000);
-
-	if (!main_pic)
-		return;
-
-	open_pic_irq_offset = offset;
-	chrp_int_ack_special = (volatile unsigned char*)chrp_ack;
-
-	find_ISUs();
-
-	/* Initialize timer interrupts */
-	for (i = 0; i < OPENPIC_NUM_TIMERS; i++) {
-		/* Disabled, Priority 0 */
-		openpic_inittimer(i, 0, openpic_vec_timer+i);
-		/* No processor */
-		openpic_maptimer(i, 0);
-	}
-
-#ifdef CONFIG_SMP
-	/* Initialize IPI interrupts */
-	openpic_test_broken_IPI();
-	for (i = 0; i < OPENPIC_NUM_IPI; i++) {
-		/* Disabled, Priority 10..13 */
-		openpic_initipi(i, 10+i, openpic_vec_ipi+i);
-		/* IPIs are per-CPU */
-		irq_desc[openpic_vec_ipi+i].status |= IRQ_PER_CPU;
-		irq_desc[openpic_vec_ipi+i].handler = &open_pic_ipi;
-	}
-#endif
-
-	/* Initialize external interrupts */
-	openpic_set_priority(0xf);
-
-	/* SIOint (8259 cascade) is special */
-	if (offset) {
-		openpic_initirq(0, 8, offset, 1, 1);
-		openpic_mapirq(0, 1 << get_hard_smp_processor_id(boot_cpuid));
-	}
-
-	/* Init all external sources */
-	for (i = 0; i < NumSources; i++) {
-		int pri, sense;
-
-		/* skip cascade if any */
-		if (offset && i == 0)
-			continue;
-		/* the bootloader may have left it enabled (bad !) */
-		openpic_disable_irq(i+offset);
-
-		pri = (i == programmer_switch_irq)? 9: 8;
-		sense = (i < OpenPIC_NumInitSenses)? OpenPIC_InitSenses[i]: 1;
-		if (sense)
-			irq_desc[i+offset].status = IRQ_LEVEL;
-
-		/* Enabled, Priority 8 or 9 */
-		openpic_initirq(i, pri, i+offset, !sense, sense);
-		/* Processor 0 */
-		openpic_mapirq(i, 1 << get_hard_smp_processor_id(boot_cpuid));
-	}
-
-	/* Init descriptors */
-	for (i = offset; i < NumSources + offset; i++)
-		irq_desc[i].handler = &open_pic;
-
-	/* Initialize the spurious interrupt */
-	openpic_set_spurious(openpic_vec_spurious);
-
-	openpic_set_priority(0);
-	openpic_disable_8259_pass_through();
-
-	ppc64_boot_msg(0x25, "OpenPic Done");
-}
-
-/* 
- * We cant do this in init_IRQ because we need the memory subsystem up for
- * request_irq()
- */
-static int __init openpic_setup_i8259(void)
-{
-	if (systemcfg->platform == PLATFORM_POWERMAC)
-		return 0;
-
-	if (naca->interrupt_controller == IC_OPEN_PIC) {
-		/* Initialize the cascade */
-		if (request_irq(NUM_ISA_INTERRUPTS, no_action, SA_INTERRUPT,
-				"82c59 cascade", NULL))
-			printk(KERN_ERR "Unable to get OpenPIC IRQ 0 for cascade\n");
-		i8259_init();
-	}
-
-	return 0;
-}
-arch_initcall(openpic_setup_i8259);
-
-void openpic_setup_ISU(int isu_num, unsigned long addr)
-{
-	if (isu_num >= OPENPIC_MAX_ISU)
-		return;
-	ISU[isu_num] = (OpenPIC_SourcePtr) __ioremap(addr, 0x400, _PAGE_NO_CACHE);
-	if (isu_num >= NumISUs)
-		NumISUs = isu_num + 1;
-}
-
-void find_ISUs(void)
-{
-	/* For PowerMac, setup ISUs on base openpic */
-	if (systemcfg->platform == PLATFORM_POWERMAC) {
-		int i;
-		for (i=0; i<128; i+=0x10) {
-			ISU[i>>4] = &((struct OpenPIC *)OpenPIC_Addr)->Source[i];
-			NumISUs++;
-		}
-	}
-        /* Use /interrupt-controller/reg and
-         * /interrupt-controller/interrupt-ranges from OF device tree
-	 * the ISU array is setup in chrp_pci.c in ibm_add_bridges
-	 * as a result
-	 * -- tgall
-         */
-
-	/* basically each ISU is a bus, and this assumes that
-	 * open_pic_isu_count interrupts per bus are possible 
-	 * ISU == Interrupt Source
-	 *
-	 * On G5, we keep the original NumSources provided by the controller,
-	 * it's below 128, so we have room to stuff the IPIs and timers like darwin
-	 * does. We put the spurrious vector up at 0xff though.
-	 */
-	if (systemcfg->platform == PLATFORM_POWERMAC) {
-		openpic_vec_ipi = NumSources;
-		openpic_vec_timer = openpic_vec_ipi + 4; 
-		openpic_vec_spurious = 0xff;
-	} else {
-		NumSources = NumISUs * 0x10;
-
-		openpic_vec_ipi = NumSources + open_pic_irq_offset;
-		openpic_vec_timer = openpic_vec_ipi + OPENPIC_NUM_IPI; 
-		openpic_vec_spurious = openpic_vec_timer + OPENPIC_NUM_TIMERS;
-	}
-}
-
-static inline void openpic_reset(void)
-{
-	openpic_setfield(&OpenPIC->Global.Global_Configuration0,
-			 OPENPIC_CONFIG_RESET);
-}
-
-static inline void openpic_enable_8259_pass_through(void)
-{
-	openpic_clearfield(&OpenPIC->Global.Global_Configuration0,
-			   OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE);
-}
-
-static void openpic_disable_8259_pass_through(void)
-{
-	openpic_setfield(&OpenPIC->Global.Global_Configuration0,
-			 OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE);
-}
-
-/*
- *  Find out the current interrupt
- */
-static u_int openpic_irq(void)
-{
-	u_int vec;
-	DECL_THIS_CPU;
-
-	CHECK_THIS_CPU;
-	vec = openpic_readfield(&OpenPIC->THIS_CPU.Interrupt_Acknowledge,
-				OPENPIC_VECTOR_MASK);
-	return vec;
-}
-
-static void openpic_eoi(void)
-{
-	DECL_THIS_CPU;
-
-	CHECK_THIS_CPU;
-	openpic_write(&OpenPIC->THIS_CPU.EOI, 0);
-	/* Handle PCI write posting */
-	(void)openpic_read(&OpenPIC->THIS_CPU.EOI);
-}
-
-
-static inline u_int openpic_get_priority(void)
-{
-	DECL_THIS_CPU;
-
-	CHECK_THIS_CPU;
-	return openpic_readfield(&OpenPIC->THIS_CPU.Current_Task_Priority,
-				 OPENPIC_CURRENT_TASK_PRIORITY_MASK);
-}
-
-static void openpic_set_priority(u_int pri)
-{
-	DECL_THIS_CPU;
-
-	CHECK_THIS_CPU;
-	check_arg_pri(pri);
-	openpic_writefield(&OpenPIC->THIS_CPU.Current_Task_Priority,
-			   OPENPIC_CURRENT_TASK_PRIORITY_MASK, pri);
-}
-
-/*
- *  Get/set the spurious vector
- */
-static inline u_int openpic_get_spurious(void)
-{
-	return openpic_readfield(&OpenPIC->Global.Spurious_Vector,
-				 OPENPIC_VECTOR_MASK);
-}
-
-static void openpic_set_spurious(u_int vec)
-{
-	check_arg_vec(vec);
-	openpic_writefield(&OpenPIC->Global.Spurious_Vector, OPENPIC_VECTOR_MASK,
-			   vec);
-}
-
-/*
- * Convert a cpu mask from logical to physical cpu numbers.
- */
-static inline u32 physmask(u32 cpumask)
-{
-	int i;
-	u32 mask = 0;
-
-	for (i = 0; i < NR_CPUS; ++i, cpumask >>= 1)
-		mask |= (cpumask & 1) << get_hard_smp_processor_id(i);
-	return mask;
-}
-
-void openpic_init_processor(u_int cpumask)
-{
-	openpic_write(&OpenPIC->Global.Processor_Initialization,
-		      physmask(cpumask & cpus_addr(cpu_online_map)[0]));
-}
-
-#ifdef CONFIG_SMP
-/*
- *  Initialize an interprocessor interrupt (and disable it)
- *
- *  ipi: OpenPIC interprocessor interrupt number
- *  pri: interrupt source priority
- *  vec: the vector it will produce
- */
-static void __init openpic_initipi(u_int ipi, u_int pri, u_int vec)
-{
-	check_arg_ipi(ipi);
-	check_arg_pri(pri);
-	check_arg_vec(vec);
-	openpic_safe_writefield_IPI(&OpenPIC->Global.IPI_Vector_Priority(ipi),
-				OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK,
-				(pri << OPENPIC_PRIORITY_SHIFT) | vec);
-}
-
-/*
- *  Send an IPI to one or more CPUs
- *  
- *  Externally called, however, it takes an IPI number (0...OPENPIC_NUM_IPI)
- *  and not a system-wide interrupt number
- */
-void openpic_cause_IPI(u_int ipi, u_int cpumask)
-{
-	DECL_THIS_CPU;
-
-	CHECK_THIS_CPU;
-	check_arg_ipi(ipi);
-	openpic_write(&OpenPIC->THIS_CPU.IPI_Dispatch(ipi),
-		      physmask(cpumask & cpus_addr(cpu_online_map)[0]));
-}
-
-void openpic_request_IPIs(void)
-{
-	int i;
-	
-	/*
-	 * Make sure this matches what is defined in smp.c for 
-	 * smp_message_{pass|recv}() or what shows up in 
-	 * /proc/interrupts will be wrong!!! --Troy */
-	
-	if (OpenPIC == NULL)
-		return;
-
-	/* IPIs are marked SA_INTERRUPT as they must run with irqs disabled */
-	request_irq(openpic_vec_ipi, openpic_ipi_action, SA_INTERRUPT,
-		    "IPI0 (call function)", NULL);
-	request_irq(openpic_vec_ipi+1, openpic_ipi_action, SA_INTERRUPT,
-		   "IPI1 (reschedule)", NULL);
-	request_irq(openpic_vec_ipi+2, openpic_ipi_action, SA_INTERRUPT,
-		   "IPI2 (unused)", NULL);
-	request_irq(openpic_vec_ipi+3, openpic_ipi_action, SA_INTERRUPT,
-		   "IPI3 (debugger break)", NULL);
-
-	for ( i = 0; i < OPENPIC_NUM_IPI ; i++ )
-		openpic_enable_ipi(openpic_vec_ipi+i);
-}
-
-/*
- * Do per-cpu setup for SMP systems.
- *
- * Get IPI's working and start taking interrupts.
- *   -- Cort
- */
-static spinlock_t openpic_setup_lock __devinitdata = SPIN_LOCK_UNLOCKED;
-
-void __devinit do_openpic_setup_cpu(void)
-{
-#ifdef CONFIG_IRQ_ALL_CPUS
- 	int i;
-	u32 msk = 1 << hard_smp_processor_id();
-#endif
-
-	spin_lock(&openpic_setup_lock);
-
-#ifdef CONFIG_IRQ_ALL_CPUS
- 	/* let the openpic know we want intrs. default affinity
- 	 * is 0xffffffff until changed via /proc
- 	 * That's how it's done on x86. If we want it differently, then
- 	 * we should make sure we also change the default values of irq_affinity
- 	 * in irq.c.
- 	 */
- 	for (i = 0; i < NumSources ; i++)
-		openpic_mapirq(i, openpic_read(&GET_ISU(i).Destination) | msk);
-#endif /* CONFIG_IRQ_ALL_CPUS */
- 	openpic_set_priority(0);
-
-	spin_unlock(&openpic_setup_lock);
-}
-#endif /* CONFIG_SMP */
-
-/*
- *  Initialize a timer interrupt (and disable it)
- *
- *  timer: OpenPIC timer number
- *  pri: interrupt source priority
- *  vec: the vector it will produce
- */
-static void __init openpic_inittimer(u_int timer, u_int pri, u_int vec)
-{
-	check_arg_timer(timer);
-	check_arg_pri(pri);
-	check_arg_vec(vec);
-	openpic_safe_writefield(&OpenPIC->Global.Timer[timer].Vector_Priority,
-				OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK,
-				(pri << OPENPIC_PRIORITY_SHIFT) | vec);
-}
-
-/*
- *  Map a timer interrupt to one or more CPUs
- */
-static void __init openpic_maptimer(u_int timer, u_int cpumask)
-{
-	check_arg_timer(timer);
-	openpic_write(&OpenPIC->Global.Timer[timer].Destination,
-		      physmask(cpumask & cpus_addr(cpu_online_map)[0]));
-}
-
-
-/*
- *
- * All functions below take an offset'ed irq argument
- *
- */
-
-
-/*
- *  Enable/disable an external interrupt source
- *
- *  Externally called, irq is an offseted system-wide interrupt number
- */
-static void openpic_enable_irq(u_int irq)
-{
-	unsigned int loops = 100000;
-	check_arg_irq(irq);
-
-	openpic_clearfield(&GET_ISU(irq - open_pic_irq_offset).Vector_Priority, OPENPIC_MASK);
-	/* make sure mask gets to controller before we return to user */
-	do {
-		if (!loops--) {
-			printk(KERN_ERR "openpic_enable_irq timeout\n");
-			break;
-		}
-
-		mb(); /* sync is probably useless here */
-	} while(openpic_readfield(&GET_ISU(irq - open_pic_irq_offset).Vector_Priority,
-			OPENPIC_MASK));
-}
-
-static void openpic_disable_irq(u_int irq)
-{
-	u32 vp;
-	unsigned int loops = 100000;
-	
-	check_arg_irq(irq);
-
-	openpic_setfield(&GET_ISU(irq - open_pic_irq_offset).Vector_Priority, OPENPIC_MASK);
-	/* make sure mask gets to controller before we return to user */
-	do {
-		if (!loops--) {
-			printk(KERN_ERR "openpic_disable_irq timeout\n");
-			break;
-		}
-
-		mb();  /* sync is probably useless here */
-		vp = openpic_readfield(&GET_ISU(irq - open_pic_irq_offset).Vector_Priority,
-    			OPENPIC_MASK | OPENPIC_ACTIVITY);
-	} while((vp & OPENPIC_ACTIVITY) && !(vp & OPENPIC_MASK));
-}
-
-#ifdef CONFIG_SMP
-/*
- *  Enable/disable an IPI interrupt source
- *  
- *  Externally called, irq is an offseted system-wide interrupt number
- */
-void openpic_enable_ipi(u_int irq)
-{
-	irq -= openpic_vec_ipi;
-	check_arg_ipi(irq);
-	openpic_clearfield_IPI(&OpenPIC->Global.IPI_Vector_Priority(irq), OPENPIC_MASK);
-
-}
-void openpic_disable_ipi(u_int irq)
-{
-   /* NEVER disable an IPI... that's just plain wrong! */
-}
-
-#endif
-
-/*
- *  Initialize an interrupt source (and disable it!)
- *
- *  irq: OpenPIC interrupt number
- *  pri: interrupt source priority
- *  vec: the vector it will produce
- *  pol: polarity (1 for positive, 0 for negative)
- *  sense: 1 for level, 0 for edge
- */
-static void openpic_initirq(u_int irq, u_int pri, u_int vec, int pol, int sense)
-{
-	openpic_safe_writefield(&GET_ISU(irq).Vector_Priority,
-				OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |
-				OPENPIC_SENSE_MASK | OPENPIC_POLARITY_MASK,
-				(pri << OPENPIC_PRIORITY_SHIFT) | vec |
-				(pol ? OPENPIC_POLARITY_POSITIVE :
-			    		OPENPIC_POLARITY_NEGATIVE) |
-				(sense ? OPENPIC_SENSE_LEVEL : OPENPIC_SENSE_EDGE));
-}
-
-/*
- *  Map an interrupt source to one or more CPUs
- */
-static void openpic_mapirq(u_int irq, u_int physmask)
-{
-	openpic_write(&GET_ISU(irq).Destination, physmask);
-}
-
-/*
- *  Set the sense for an interrupt source (and disable it!)
- *
- *  sense: 1 for level, 0 for edge
- */
-#if 0	/* not used */
-static void openpic_set_sense(u_int irq, int sense)
-{
-	openpic_safe_writefield(&GET_ISU(irq).Vector_Priority,
-				OPENPIC_SENSE_LEVEL,
-				(sense ? OPENPIC_SENSE_LEVEL : 0));
-}
-
-static int openpic_get_sense(u_int irq)
-{
-	return openpic_readfield(&GET_ISU(irq).Vector_Priority,
-				 OPENPIC_SENSE_LEVEL) != 0;
-}
-#endif
-
-static void openpic_end_irq(unsigned int irq_nr)
-{
-	openpic_eoi();
-}
-
-static void openpic_set_affinity(unsigned int irq_nr, cpumask_t cpumask)
-{
-	cpumask_t tmp;
-
-	cpus_and(tmp, cpumask, cpu_online_map);
-	openpic_mapirq(irq_nr - open_pic_irq_offset, physmask(cpus_addr(tmp)[0]));
-}
-
-#ifdef CONFIG_SMP
-static void openpic_end_ipi(unsigned int irq_nr)
-{
-	/*
-	 * IPIs are marked IRQ_PER_CPU. This has the side effect of
-	 * preventing the IRQ_PENDING/IRQ_INPROGRESS logic from
-	 * applying to them. We EOI them late to avoid re-entering.
-	 * We mark IPI's with SA_INTERRUPT as they must run with
-	 * irqs disabled.
-	 */
-	openpic_eoi();
-}
-
-static irqreturn_t openpic_ipi_action(int cpl, void *dev_id,
-					struct pt_regs *regs)
-{
-	smp_message_recv(cpl-openpic_vec_ipi, regs);
-	return IRQ_HANDLED;
-}
-
-#endif /* CONFIG_SMP */
-
-int openpic_get_irq(struct pt_regs *regs)
-{
-	extern int i8259_irq(int cpu);
-
-	int irq = openpic_irq();
-
-        if (open_pic_irq_offset && irq == open_pic_irq_offset) {
-                /*
-                 * This magic address generates a PCI IACK cycle.
-                 */
-		if ( chrp_int_ack_special )
-			irq = *chrp_int_ack_special;
-		else
-			irq = i8259_irq( smp_processor_id() );
-		openpic_eoi();
-        }
-	if (irq == openpic_vec_spurious)
-		irq = -1;
-	return irq;
-}
diff -Nru a/arch/ppc64/kernel/open_pic.h b/arch/ppc64/kernel/open_pic.h
--- a/arch/ppc64/kernel/open_pic.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,42 +0,0 @@
-/*
- *  arch/ppc/kernel/open_pic.h -- OpenPIC Interrupt Handling
- *
- *  Copyright (C) 1997 Geert Uytterhoeven
- *
- *  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.
- *  
- */
-
-#ifndef _PPC64_KERNEL_OPEN_PIC_H
-#define _PPC64_KERNEL_OPEN_PIC_H
-
-#include <linux/config.h>
-#include <linux/cpumask.h>
-#include <linux/irq.h>
-
-#define OPENPIC_SIZE	0x40000
-
-/* OpenPIC IRQ controller structure */
-extern struct hw_interrupt_type open_pic;
-
-/* OpenPIC IPI controller structure */
-#ifdef CONFIG_SMP
-extern struct hw_interrupt_type open_pic_ipi;
-#endif /* CONFIG_SMP */
-
-extern u_int OpenPIC_NumInitSenses;
-extern u_char *OpenPIC_InitSenses;
-extern void* OpenPIC_Addr;
-
-/* Exported functions */
-extern void openpic_init(int, int, unsigned char *, int);
-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);
-
-#endif /* _PPC64_KERNEL_OPEN_PIC_H */
diff -Nru a/arch/ppc64/kernel/open_pic_defs.h b/arch/ppc64/kernel/open_pic_defs.h
--- a/arch/ppc64/kernel/open_pic_defs.h	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,283 +0,0 @@
-/*
- *  linux/openpic.h -- OpenPIC definitions
- *
- *  Copyright (C) 1997 Geert Uytterhoeven
- *
- *  This file is based on the following documentation:
- *
- *	The Open Programmable Interrupt Controller (PIC)
- *	Register Interface Specification Revision 1.2
- *
- *	Issue Date: October 1995
- *
- *	Issued jointly by Advanced Micro Devices and Cyrix Corporation
- *
- *	AMD is a registered trademark of Advanced Micro Devices, Inc.
- *	Copyright (C) 1995, Advanced Micro Devices, Inc. and Cyrix, Inc.
- *	All Rights Reserved.
- *
- *  To receive a copy of this documentation, send an email to openpic@amd.com.
- *
- *  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.
- */
-
-#ifndef _LINUX_OPENPIC_H
-#define _LINUX_OPENPIC_H
-
-#ifdef __KERNEL__
-
-#include <linux/config.h>
-
-/*
- *  OpenPIC supports up to 2048 interrupt sources and up to 32 processors
- */
-
-#define OPENPIC_MAX_SOURCES	2048
-#define OPENPIC_MAX_PROCESSORS	32
-#define OPENPIC_MAX_ISU		32
-
-#define OPENPIC_NUM_TIMERS	4
-#define OPENPIC_NUM_IPI		4
-#define OPENPIC_NUM_PRI		16
-#define OPENPIC_NUM_VECTORS	OPENPIC_MAX_SOURCES
-
-/*
- *  OpenPIC Registers are 32 bits and aligned on 128 bit boundaries
- */
-
-typedef struct _OpenPIC_Reg {
-	u_int Reg;					/* Little endian! */
-	char Pad[0xc];
-} OpenPIC_Reg;
-
-
-/*
- *  Per Processor Registers
- */
-
-typedef struct _OpenPIC_Processor {
-	/*
-	 *  Private Shadow Registers (for SLiC backwards compatibility)
-	 */
-	u_int IPI0_Dispatch_Shadow;			/* Write Only */
-	char Pad1[0x4];
-	u_int IPI0_Vector_Priority_Shadow;		/* Read/Write */
-	char Pad2[0x34];
-	/*
-	 *  Interprocessor Interrupt Command Ports
-	 */
-	OpenPIC_Reg _IPI_Dispatch[OPENPIC_NUM_IPI];	/* Write Only */
-	/*
-	 *  Current Task Priority Register
-	 */
-	OpenPIC_Reg _Current_Task_Priority;		/* Read/Write */
-	char Pad3[0x10];
-	/*
-	 *  Interrupt Acknowledge Register
-	 */
-	OpenPIC_Reg _Interrupt_Acknowledge;		/* Read Only */
-	/*
-	 *  End of Interrupt (EOI) Register
-	 */
-	OpenPIC_Reg _EOI;				/* Read/Write */
-	char Pad5[0xf40];
-} OpenPIC_Processor;
-
-
-    /*
-     *  Timer Registers
-     */
-
-typedef struct _OpenPIC_Timer {
-	OpenPIC_Reg _Current_Count;			/* Read Only */
-	OpenPIC_Reg _Base_Count;			/* Read/Write */
-	OpenPIC_Reg _Vector_Priority;			/* Read/Write */
-	OpenPIC_Reg _Destination;			/* Read/Write */
-} OpenPIC_Timer;
-
-
-    /*
-     *  Global Registers
-     */
-
-typedef struct _OpenPIC_Global {
-	/*
-	 *  Feature Reporting Registers
-	 */
-	OpenPIC_Reg _Feature_Reporting0;		/* Read Only */
-	OpenPIC_Reg _Feature_Reporting1;		/* Future Expansion */
-	/*
-	 *  Global Configuration Registers
-	 */
-	OpenPIC_Reg _Global_Configuration0;		/* Read/Write */
-	OpenPIC_Reg _Global_Configuration1;		/* Future Expansion */
-	/*
-	 *  Vendor Specific Registers
-	 */
-	OpenPIC_Reg _Vendor_Specific[4];
-	/*
-	 *  Vendor Identification Register
-	 */
-	OpenPIC_Reg _Vendor_Identification;		/* Read Only */
-	/*
-	 *  Processor Initialization Register
-	 */
-	OpenPIC_Reg _Processor_Initialization;		/* Read/Write */
-	/*
-	 *  IPI Vector/Priority Registers
-	 */
-	OpenPIC_Reg _IPI_Vector_Priority[OPENPIC_NUM_IPI]; /* Read/Write */
-	/*
-	 *  Spurious Vector Register
-	 */
-	OpenPIC_Reg _Spurious_Vector;			/* Read/Write */
-	/*
-	 *  Global Timer Registers
-	 */
-	OpenPIC_Reg _Timer_Frequency;			/* Read/Write */
-	OpenPIC_Timer Timer[OPENPIC_NUM_TIMERS];
-	char Pad1[0xee00];
-} OpenPIC_Global;
-
-
-    /*
-     *  Interrupt Source Registers
-     */
-
-typedef struct _OpenPIC_Source {
-	OpenPIC_Reg _Vector_Priority;			/* Read/Write */
-	OpenPIC_Reg _Destination;			/* Read/Write */
-} OpenPIC_Source, *OpenPIC_SourcePtr;
-
-
-    /*
-     *  OpenPIC Register Map
-     */
-
-struct OpenPIC {
-	char Pad1[0x1000];
-	/*
-	 *  Global Registers
-	 */
-	OpenPIC_Global Global;
-	/*
-	 *  Interrupt Source Configuration Registers
-	 */
-	OpenPIC_Source Source[OPENPIC_MAX_SOURCES];
-	/*
-	 *  Per Processor Registers
-	 */
-	OpenPIC_Processor Processor[OPENPIC_MAX_PROCESSORS];
-};
-
-
-/*
- *  Current Task Priority Register
- */
-
-#define OPENPIC_CURRENT_TASK_PRIORITY_MASK	0x0000000f
-
-/*
- *  Who Am I Register
- */
-
-#define OPENPIC_WHO_AM_I_ID_MASK		0x0000001f
-
-/*
- *  Feature Reporting Register 0
- */
-
-#define OPENPIC_FEATURE_LAST_SOURCE_MASK	0x07ff0000
-#define OPENPIC_FEATURE_LAST_SOURCE_SHIFT	16
-#define OPENPIC_FEATURE_LAST_PROCESSOR_MASK	0x00001f00
-#define OPENPIC_FEATURE_LAST_PROCESSOR_SHIFT	8
-#define OPENPIC_FEATURE_VERSION_MASK		0x000000ff
-
-/*
- *  Global Configuration Register 0
- */
-
-#define OPENPIC_CONFIG_RESET			0x80000000
-#define OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE	0x20000000
-#define OPENPIC_CONFIG_BASE_MASK		0x000fffff
-
-/*
- *  Vendor Identification Register
- */
-
-#define OPENPIC_VENDOR_ID_STEPPING_MASK		0x00ff0000
-#define OPENPIC_VENDOR_ID_STEPPING_SHIFT	16
-#define OPENPIC_VENDOR_ID_DEVICE_ID_MASK	0x0000ff00
-#define OPENPIC_VENDOR_ID_DEVICE_ID_SHIFT	8
-#define OPENPIC_VENDOR_ID_VENDOR_ID_MASK	0x000000ff
-
-/*
- *  Vector/Priority Registers
- */
-
-#define OPENPIC_MASK				0x80000000
-#define OPENPIC_ACTIVITY			0x40000000	/* Read Only */
-#define OPENPIC_PRIORITY_MASK			0x000f0000
-#define OPENPIC_PRIORITY_SHIFT			16
-#define OPENPIC_VECTOR_MASK			0x000007ff
-
-
-/*
- *  Interrupt Source Registers
- */
-
-#define OPENPIC_POLARITY_POSITIVE		0x00800000
-#define OPENPIC_POLARITY_NEGATIVE		0x00000000
-#define OPENPIC_POLARITY_MASK			0x00800000
-#define OPENPIC_SENSE_LEVEL			0x00400000
-#define OPENPIC_SENSE_EDGE			0x00000000
-#define OPENPIC_SENSE_MASK			0x00400000
-
-
-/*
- *  Timer Registers
- */
-
-#define OPENPIC_COUNT_MASK			0x7fffffff
-#define OPENPIC_TIMER_TOGGLE			0x80000000
-#define OPENPIC_TIMER_COUNT_INHIBIT		0x80000000
-
-
-/*
- *  Aliases to make life simpler
- */
-
-/* Per Processor Registers */
-#define IPI_Dispatch(i)			_IPI_Dispatch[i].Reg
-#define Current_Task_Priority		_Current_Task_Priority.Reg
-#define Interrupt_Acknowledge		_Interrupt_Acknowledge.Reg
-#define EOI				_EOI.Reg
-
-/* Global Registers */
-#define Feature_Reporting0		_Feature_Reporting0.Reg
-#define Feature_Reporting1		_Feature_Reporting1.Reg
-#define Global_Configuration0		_Global_Configuration0.Reg
-#define Global_Configuration1		_Global_Configuration1.Reg
-#define Vendor_Specific(i)		_Vendor_Specific[i].Reg
-#define Vendor_Identification		_Vendor_Identification.Reg
-#define Processor_Initialization	_Processor_Initialization.Reg
-#define IPI_Vector_Priority(i)		_IPI_Vector_Priority[i].Reg
-#define Spurious_Vector			_Spurious_Vector.Reg
-#define Timer_Frequency			_Timer_Frequency.Reg
-
-/* Timer Registers */
-#define Current_Count			_Current_Count.Reg
-#define Base_Count			_Base_Count.Reg
-#define Vector_Priority			_Vector_Priority.Reg
-#define Destination			_Destination.Reg
-
-/* Interrupt Source Registers */
-#define Vector_Priority			_Vector_Priority.Reg
-#define Destination			_Destination.Reg
-
-
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_OPENPIC_H */
diff -Nru a/arch/ppc64/kernel/open_pic_u3.c b/arch/ppc64/kernel/open_pic_u3.c
--- a/arch/ppc64/kernel/open_pic_u3.c	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,348 +0,0 @@
-/*
- *  arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling
- *
- *  Copyright (C) 1997 Geert Uytterhoeven
- *
- *  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 <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/smp.h>
-#include <linux/interrupt.h>
-#include <asm/ptrace.h>
-#include <asm/signal.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/irq.h>
-#include <asm/prom.h>
-
-#include <asm/machdep.h>
-
-#include "open_pic.h"
-#include "open_pic_defs.h"
-
-void* OpenPIC2_Addr;
-static volatile struct OpenPIC *OpenPIC2 = NULL;
-
-extern u_int OpenPIC_NumInitSenses;
-extern u_char *OpenPIC_InitSenses;
-
-static u_int NumSources;
-static int NumISUs;
-static int open_pic2_irq_offset;
-
-static OpenPIC_SourcePtr ISU2[OPENPIC_MAX_ISU];
-
-unsigned int openpic2_vec_spurious;
-
-/*
- *  Accesses to the current processor's openpic registers
- *  U3 secondary openpic has only one output
- */
-#define THIS_CPU		Processor[0]
-#define DECL_THIS_CPU
-#define CHECK_THIS_CPU
-
-#define GET_ISU(source)	ISU2[(source) >> 4][(source) & 0xf]
-
-static inline u_int openpic2_read(volatile u_int *addr)
-{
-	u_int val;
-
-	val = in_be32(addr);
-	return val;
-}
-
-static inline void openpic2_write(volatile u_int *addr, u_int val)
-{
-	out_be32(addr, val);
-}
-
-static inline u_int openpic2_readfield(volatile u_int *addr, u_int mask)
-{
-	u_int val = openpic2_read(addr);
-	return val & mask;
-}
-
-static inline void openpic2_writefield(volatile u_int *addr, u_int mask,
-			       u_int field)
-{
-	u_int val = openpic2_read(addr);
-	openpic2_write(addr, (val & ~mask) | (field & mask));
-}
-
-static inline void openpic2_clearfield(volatile u_int *addr, u_int mask)
-{
-	openpic2_writefield(addr, mask, 0);
-}
-
-static inline void openpic2_setfield(volatile u_int *addr, u_int mask)
-{
-	openpic2_writefield(addr, mask, mask);
-}
-
-static void openpic2_safe_writefield(volatile u_int *addr, u_int mask,
-				    u_int field)
-{
-	unsigned int loops = 100000;
-
-	openpic2_setfield(addr, OPENPIC_MASK);
-	while (openpic2_read(addr) & OPENPIC_ACTIVITY) {
-		if (!loops--) {
-			printk(KERN_ERR "openpic2_safe_writefield timeout\n");
-			break;
-		}
-	}
-	openpic2_writefield(addr, mask | OPENPIC_MASK, field | OPENPIC_MASK);
-}
-
-
-static inline void openpic2_reset(void)
-{
-	openpic2_setfield(&OpenPIC2->Global.Global_Configuration0,
-			 OPENPIC_CONFIG_RESET);
-}
-
-static void openpic2_disable_8259_pass_through(void)
-{
-	openpic2_setfield(&OpenPIC2->Global.Global_Configuration0,
-			 OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE);
-}
-
-/*
- *  Find out the current interrupt
- */
-static u_int openpic2_irq(void)
-{
-	u_int vec;
-	DECL_THIS_CPU;
-	CHECK_THIS_CPU;
-	vec = openpic2_readfield(&OpenPIC2->THIS_CPU.Interrupt_Acknowledge,
-				 OPENPIC_VECTOR_MASK);
-	return vec;
-}
-
-static void openpic2_eoi(void)
-{
-	DECL_THIS_CPU;
-	CHECK_THIS_CPU;
-	openpic2_write(&OpenPIC2->THIS_CPU.EOI, 0);
-	/* Handle PCI write posting */
-	(void)openpic2_read(&OpenPIC2->THIS_CPU.EOI);
-}
-
-
-static inline u_int openpic2_get_priority(void)
-{
-	DECL_THIS_CPU;
-	CHECK_THIS_CPU;
-	return openpic2_readfield(&OpenPIC2->THIS_CPU.Current_Task_Priority,
-				  OPENPIC_CURRENT_TASK_PRIORITY_MASK);
-}
-
-static void openpic2_set_priority(u_int pri)
-{
-	DECL_THIS_CPU;
-	CHECK_THIS_CPU;
-	openpic2_writefield(&OpenPIC2->THIS_CPU.Current_Task_Priority,
-			    OPENPIC_CURRENT_TASK_PRIORITY_MASK, pri);
-}
-
-/*
- *  Get/set the spurious vector
- */
-static inline u_int openpic2_get_spurious(void)
-{
-	return openpic2_readfield(&OpenPIC2->Global.Spurious_Vector,
-				  OPENPIC_VECTOR_MASK);
-}
-
-static void openpic2_set_spurious(u_int vec)
-{
-	openpic2_writefield(&OpenPIC2->Global.Spurious_Vector, OPENPIC_VECTOR_MASK,
-			    vec);
-}
-
-/*
- *  Enable/disable an external interrupt source
- *
- *  Externally called, irq is an offseted system-wide interrupt number
- */
-static void openpic2_enable_irq(u_int irq)
-{
-	unsigned int loops = 100000;
-
-	openpic2_clearfield(&GET_ISU(irq - open_pic2_irq_offset).Vector_Priority, OPENPIC_MASK);
-	/* make sure mask gets to controller before we return to user */
-	do {
-		if (!loops--) {
-			printk(KERN_ERR "openpic_enable_irq timeout\n");
-			break;
-		}
-
-		mb(); /* sync is probably useless here */
-	} while(openpic2_readfield(&GET_ISU(irq - open_pic2_irq_offset).Vector_Priority,
-			OPENPIC_MASK));
-}
-
-static void openpic2_disable_irq(u_int irq)
-{
-	u32 vp;
-	unsigned int loops = 100000;
-	
-	openpic2_setfield(&GET_ISU(irq - open_pic2_irq_offset).Vector_Priority,
-			  OPENPIC_MASK);
-	/* make sure mask gets to controller before we return to user */
-	do {
-		if (!loops--) {
-			printk(KERN_ERR "openpic_disable_irq timeout\n");
-			break;
-		}
-
-		mb();  /* sync is probably useless here */
-		vp = openpic2_readfield(&GET_ISU(irq - open_pic2_irq_offset).Vector_Priority,
-    			OPENPIC_MASK | OPENPIC_ACTIVITY);
-	} while((vp & OPENPIC_ACTIVITY) && !(vp & OPENPIC_MASK));
-}
-
-/*
- *  Initialize an interrupt source (and disable it!)
- *
- *  irq: OpenPIC interrupt number
- *  pri: interrupt source priority
- *  vec: the vector it will produce
- *  pol: polarity (1 for positive, 0 for negative)
- *  sense: 1 for level, 0 for edge
- */
-static void openpic2_initirq(u_int irq, u_int pri, u_int vec, int pol, int sense)
-{
-	openpic2_safe_writefield(&GET_ISU(irq).Vector_Priority,
-				 OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |
-				 OPENPIC_SENSE_MASK | OPENPIC_POLARITY_MASK,
-				 (pri << OPENPIC_PRIORITY_SHIFT) | vec |
-				 (pol ? OPENPIC_POLARITY_POSITIVE :
-				  OPENPIC_POLARITY_NEGATIVE) |
-				 (sense ? OPENPIC_SENSE_LEVEL : OPENPIC_SENSE_EDGE));
-}
-
-/*
- *  Map an interrupt source to one or more CPUs
- */
-static void openpic2_mapirq(u_int irq, u_int physmask)
-{
-	openpic2_write(&GET_ISU(irq).Destination, physmask);
-}
-
-/*
- *  Set the sense for an interrupt source (and disable it!)
- *
- *  sense: 1 for level, 0 for edge
- */
-static inline void openpic2_set_sense(u_int irq, int sense)
-{
-	openpic2_safe_writefield(&GET_ISU(irq).Vector_Priority,
-				 OPENPIC_SENSE_LEVEL,
-				 (sense ? OPENPIC_SENSE_LEVEL : 0));
-}
-
-static void openpic2_end_irq(unsigned int irq_nr)
-{
-	openpic2_eoi();
-}
-
-int openpic2_get_irq(struct pt_regs *regs)
-{
-	int irq = openpic2_irq();
-
-	if (irq == openpic2_vec_spurious)
-		return -1;
-	return irq + open_pic2_irq_offset;
-}
-
-struct hw_interrupt_type open_pic2 = {
-	" OpenPIC2 ",
-	NULL,
-	NULL,
-	openpic2_enable_irq,
-	openpic2_disable_irq,
-	NULL,
-	openpic2_end_irq,
-};
-
-void __init openpic2_init(int offset)
-{
-	u_int t, i;
-	const char *version;
-
-	if (!OpenPIC2_Addr) {
-		printk(KERN_INFO "No OpenPIC2 found !\n");
-		return;
-	}
-	OpenPIC2 = (volatile struct OpenPIC *)OpenPIC2_Addr;
-
-	ppc64_boot_msg(0x20, "OpenPic U3 Init");
-
-	t = openpic2_read(&OpenPIC2->Global.Feature_Reporting0);
-	switch (t & OPENPIC_FEATURE_VERSION_MASK) {
-	case 1:
-		version = "1.0";
-		break;
-	case 2:
-		version = "1.2";
-		break;
-	case 3:
-		version = "1.3";
-		break;
-	default:
-		version = "?";
-		break;
-	}
-	printk(KERN_INFO "OpenPIC (U3) Version %s\n", version);
-
-	open_pic2_irq_offset = offset;
-
-	for (i=0; i<128; i+=0x10) {
-		ISU2[i>>4] = &((struct OpenPIC *)OpenPIC2_Addr)->Source[i];
-		NumISUs++;
-	}
-	NumSources = NumISUs * 0x10;
-	openpic2_vec_spurious = NumSources;
-
-	openpic2_set_priority(0xf);
-
-	/* Init all external sources */
-	for (i = 0; i < NumSources; i++) {
-		int pri, sense;
-
-		/* the bootloader may have left it enabled (bad !) */
-		openpic2_disable_irq(i+offset);
-
-		pri = 8;
-		sense = (i < OpenPIC_NumInitSenses) ? OpenPIC_InitSenses[i]: 1;
-		if (sense)
-			irq_desc[i+offset].status = IRQ_LEVEL;
-
-		/* Enabled, Priority 8 or 9 */
-		openpic2_initirq(i, pri, i, !sense, sense);
-		/* Processor 0 */
-		openpic2_mapirq(i, 0x1);
-	}
-
-	/* Init descriptors */
-	for (i = offset; i < NumSources + offset; i++)
-		irq_desc[i].handler = &open_pic2;
-
-	/* Initialize the spurious interrupt */
-	openpic2_set_spurious(openpic2_vec_spurious);
-
-	openpic2_set_priority(0);
-	openpic2_disable_8259_pass_through();
-
-	ppc64_boot_msg(0x25, "OpenPic U3 Done");
-}
diff -Nru a/arch/ppc64/kernel/pSeries_iommu.c b/arch/ppc64/kernel/pSeries_iommu.c
--- a/arch/ppc64/kernel/pSeries_iommu.c	2004-12-24 13:36:19 -08:00
+++ b/arch/ppc64/kernel/pSeries_iommu.c	2004-12-24 13:36:19 -08:00
@@ -276,7 +276,7 @@
 		first_phb = 0;
 
 		for (dn = first_dn; dn != NULL; dn = dn->sibling)
-			iommu_devnode_init(dn);
+			iommu_devnode_init_pSeries(dn);
 	}
 }
 
@@ -290,7 +290,11 @@
 
 	for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
 		bus = pci_bus_b(ln);
-		busdn = PCI_GET_DN(bus);
+
+		if (bus->self)
+			busdn = pci_device_to_OF_node(bus->self);
+		else
+			busdn = bus->sysdata;   /* must be a phb */
 
 		dma_window = (unsigned int *)get_property(busdn, "ibm,dma-window", NULL);
 		if (dma_window) {
@@ -298,7 +302,7 @@
 			 * Do it now because iommu_table_setparms_lpar needs it.
 			 */
 			busdn->bussubno = bus->number;
-			iommu_devnode_init(busdn);
+			iommu_devnode_init_pSeries(busdn);
 		}
 
 		/* look for a window on a bridge even if the PHB had one */
@@ -317,19 +321,16 @@
 
 	node = (struct device_node *)phb->arch_data;
 
-	if (get_property(node, "linux,has-tce-table", NULL) == NULL) {
-		printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has no tce table !\n",
-		      dn->full_name);
-		return;
-	}
 	basep = (unsigned long *)get_property(node, "linux,tce-base", NULL);
 	sizep = (unsigned int *)get_property(node, "linux,tce-size", NULL);
 	if (basep == NULL || sizep == NULL) {
-		printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has missing tce"
-		       " entries !\n", dn->full_name);
+		printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has "
+				"missing tce entries !\n", dn->full_name);
 		return;
 	}
-	memset((void *)(*basep), 0, *sizep);
+
+	tbl->it_base = (unsigned long)__va(*basep);
+	memset((void *)tbl->it_base, 0, *sizep);
 
 	tbl->it_busno = phb->bus->number;
 	
@@ -353,7 +354,6 @@
 	if (phb->dma_window_base_cur > (1 << 19))
 		panic("PCI_DMA: Unexpected number of IOAs under this PHB.\n"); 
 	
-	tbl->it_base = *basep;
 	tbl->it_index = 0;
 	tbl->it_entrysize = sizeof(union tce_entry);
 	tbl->it_blocksize = 16;
@@ -397,7 +397,7 @@
 }
 
 
-void iommu_devnode_init(struct device_node *dn)
+void iommu_devnode_init_pSeries(struct device_node *dn)
 {
 	struct iommu_table *tbl;
 
@@ -412,7 +412,6 @@
 	dn->iommu_table = iommu_init_table(tbl);
 }
 
-
 void iommu_setup_pSeries(void)
 {
 	struct pci_dev *dev = NULL;
@@ -427,8 +426,8 @@
 	 * pci device_node.  This means get_iommu_table() won't need to search
 	 * up the device tree to find it.
 	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
-		mydn = dn = PCI_GET_DN(dev);
+	for_each_pci_dev(dev) {
+		mydn = dn = pci_device_to_OF_node(dev);
 
 		while (dn && dn->iommu_table == NULL)
 			dn = dn->parent;
@@ -436,7 +435,6 @@
 			mydn->iommu_table = dn->iommu_table;
 	}
 }
-
 
 /* These are called very early. */
 void tce_init_pSeries(void)
diff -Nru a/arch/ppc64/kernel/pSeries_lpar.c b/arch/ppc64/kernel/pSeries_lpar.c
--- a/arch/ppc64/kernel/pSeries_lpar.c	2004-12-24 13:37:32 -08:00
+++ b/arch/ppc64/kernel/pSeries_lpar.c	2004-12-24 13:37:32 -08:00
@@ -59,6 +59,74 @@
 
 int vtermno;	/* virtual terminal# for udbg  */
 
+#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
+static void udbg_hvsi_putc(unsigned char c)
+{
+	/* packet's seqno isn't used anyways */
+	uint8_t packet[] __ALIGNED__ = { 0xff, 5, 0, 0, c };
+	int rc;
+
+	if (c == '\n')
+		udbg_hvsi_putc('\r');
+
+	do {
+		rc = plpar_put_term_char(vtermno, sizeof(packet), packet);
+	} while (rc == H_Busy);
+}
+
+static long hvsi_udbg_buf_len;
+static uint8_t hvsi_udbg_buf[256];
+
+static int udbg_hvsi_getc_poll(void)
+{
+	unsigned char ch;
+	int rc, i;
+
+	if (hvsi_udbg_buf_len == 0) {
+		rc = plpar_get_term_char(vtermno, &hvsi_udbg_buf_len, hvsi_udbg_buf);
+		if (rc != H_Success || hvsi_udbg_buf[0] != 0xff) {
+			/* bad read or non-data packet */
+			hvsi_udbg_buf_len = 0;
+		} else {
+			/* remove the packet header */
+			for (i = 4; i < hvsi_udbg_buf_len; i++)
+				hvsi_udbg_buf[i-4] = hvsi_udbg_buf[i];
+			hvsi_udbg_buf_len -= 4;
+		}
+	}
+
+	if (hvsi_udbg_buf_len <= 0 || hvsi_udbg_buf_len > 256) {
+		/* no data ready */
+		hvsi_udbg_buf_len = 0;
+		return -1;
+	}
+
+	ch = hvsi_udbg_buf[0];
+	/* shift remaining data down */
+	for (i = 1; i < hvsi_udbg_buf_len; i++) {
+		hvsi_udbg_buf[i-1] = hvsi_udbg_buf[i];
+	}
+	hvsi_udbg_buf_len--;
+
+	return ch;
+}
+
+static unsigned char udbg_hvsi_getc(void)
+{
+	int ch;
+	for (;;) {
+		ch = udbg_hvsi_getc_poll();
+		if (ch == -1) {
+			/* This shouldn't be needed...but... */
+			volatile unsigned long delay;
+			for (delay=0; delay < 2000000; delay++)
+				;
+		} else {
+			return ch;
+		}
+	}
+}
+
 static void udbg_putcLP(unsigned char c)
 {
 	char buf[16];
@@ -166,11 +234,15 @@
 				ppc_md.udbg_getc_poll = udbg_getc_pollLP;
 				found = 1;
 			}
-		} else {
-			/* XXX implement udbg_putcLP_vtty for hvterm-protocol1 case */
-			printk(KERN_WARNING "%s doesn't speak hvterm1; "
-					"can't print udbg messages\n",
-			       stdout_node->full_name);
+		} else if (device_is_compatible(stdout_node, "hvterm-protocol")) {
+			termno = (u32 *)get_property(stdout_node, "reg", NULL);
+			if (termno) {
+				vtermno = termno[0];
+				ppc_md.udbg_putc = udbg_hvsi_putc;
+				ppc_md.udbg_getc = udbg_hvsi_getc;
+				ppc_md.udbg_getc_poll = udbg_hvsi_getc_poll;
+				found = 1;
+			}
 		}
 	} else if (strncmp(name, "serial", 6)) {
 		/* XXX fix ISA serial console */
@@ -187,6 +259,22 @@
 	return found;
 }
 
+void vpa_init(int cpu)
+{
+	int hwcpu = get_hard_smp_processor_id(cpu);
+	unsigned long vpa = (unsigned long)&(paca[cpu].lppaca);
+	long ret;
+	unsigned long flags;
+
+	/* Register the Virtual Processor Area (VPA) */
+	flags = 1UL << (63 - 18);
+	ret = register_vpa(flags, hwcpu, __pa(vpa));
+
+	if (ret)
+		printk(KERN_ERR "WARNING: vpa_init: VPA registration for "
+				"cpu %d (hw %d) of area %lx returns %ld\n",
+				cpu, hwcpu, __pa(vpa), ret);
+}
 
 long pSeries_lpar_hpte_insert(unsigned long hpte_group,
 			      unsigned long va, unsigned long prpn,
diff -Nru a/arch/ppc64/kernel/pSeries_pci.c b/arch/ppc64/kernel/pSeries_pci.c
--- a/arch/ppc64/kernel/pSeries_pci.c	2004-12-24 13:37:43 -08:00
+++ b/arch/ppc64/kernel/pSeries_pci.c	2004-12-24 13:37:43 -08:00
@@ -26,7 +26,6 @@
 #include <linux/kernel.h>
 #include <linux/threads.h>
 #include <linux/pci.h>
-#include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
@@ -37,12 +36,11 @@
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/pci-bridge.h>
-#include <asm/ppcdebug.h>
 #include <asm/naca.h>
 #include <asm/iommu.h>
 #include <asm/rtas.h>
 
-#include "open_pic.h"
+#include "mpic.h"
 #include "pci.h"
 
 /* RTAS tokens */
@@ -53,7 +51,7 @@
 
 static int s7a_workaround;
 
-extern unsigned long pci_probe_only;
+extern struct mpic *pSeries_mpic;
 
 static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val)
 {
@@ -151,13 +149,49 @@
 	rtas_pci_write_config
 };
 
-static void python_countermeasures(unsigned long addr)
+static int is_python(struct device_node *dev)
 {
-	void *chip_regs;
-	volatile u32 *tmp, i;
+	char *model = (char *)get_property(dev, "model", NULL);
+
+	if (model && strstr(model, "Python"))
+		return 1;
+
+	return 0;
+}
+
+static int get_phb_reg_prop(struct device_node *dev,
+			    unsigned int addr_size_words,
+			    struct reg_property64 *reg)
+{
+	unsigned int *ui_ptr = NULL, len;
+
+	/* Found a PHB, now figure out where his registers are mapped. */
+	ui_ptr = (unsigned int *)get_property(dev, "reg", &len);
+	if (ui_ptr == NULL)
+		return 1;
+
+	if (addr_size_words == 1) {
+		reg->address = ((struct reg_property32 *)ui_ptr)->address;
+		reg->size    = ((struct reg_property32 *)ui_ptr)->size;
+	} else {
+		*reg = *((struct reg_property64 *)ui_ptr);
+	}
+
+	return 0;
+}
+
+static void python_countermeasures(struct device_node *dev,
+				   unsigned int addr_size_words)
+{
+	struct reg_property64 reg_struct;
+	void __iomem *chip_regs;
+	volatile u32 val;
+
+	if (get_phb_reg_prop(dev, addr_size_words, &reg_struct))
+		return;
 
 	/* Python's register file is 1 MB in size. */
-	chip_regs = ioremap(addr & ~(0xfffffUL), 0x100000); 
+	chip_regs = ioremap(reg_struct.address & ~(0xfffffUL), 0x100000);
 
 	/* 
 	 * Firmware doesn't always clear this bit which is critical
@@ -166,17 +200,17 @@
 
 #define PRG_CL_RESET_VALID 0x00010000
 
-	tmp = (u32 *)((unsigned long)chip_regs + 0xf6030);
-
-	if (*tmp & PRG_CL_RESET_VALID) {
+	val = in_be32(chip_regs + 0xf6030);
+	if (val & PRG_CL_RESET_VALID) {
 		printk(KERN_INFO "Python workaround: ");
-		*tmp &= ~PRG_CL_RESET_VALID;
+		val &= ~PRG_CL_RESET_VALID;
+		out_be32(chip_regs + 0xf6030, val);
 		/*
 		 * We must read it back for changes to
 		 * take effect
 		 */
-		i = *tmp;
-		printk("reg0: %x\n", i);
+		val = in_be32(chip_regs + 0xf6030);
+		printk("reg0: %x\n", val);
 	}
 
 	iounmap(chip_regs);
@@ -190,7 +224,7 @@
 	ibm_write_pci_config = rtas_token("ibm,write-pci-config");
 }
 
-unsigned long __init get_phb_buid (struct device_node *phb)
+unsigned long __devinit get_phb_buid (struct device_node *phb)
 {
 	int addr_cells;
 	unsigned int *buid_vals;
@@ -220,88 +254,96 @@
 	return buid;
 }
 
-static struct pci_controller * __init alloc_phb(struct device_node *dev,
-				 unsigned int addr_size_words)
+static int phb_set_bus_ranges(struct device_node *dev,
+			      struct pci_controller *phb)
 {
-	struct pci_controller *phb;
-	unsigned int *ui_ptr = NULL, len;
-	struct reg_property64 reg_struct;
 	int *bus_range;
-	char *model;
-	enum phb_types phb_type;
- 	struct property *of_prop;
-
-	model = (char *)get_property(dev, "model", NULL);
-
-	if (!model) {
-		printk(KERN_ERR "alloc_phb: phb has no model property\n");
-		model = "<empty>";
-	}
-
-	/* Found a PHB, now figure out where his registers are mapped. */
-	ui_ptr = (unsigned int *) get_property(dev, "reg", &len);
-	if (ui_ptr == NULL) {
-		PPCDBG(PPCDBG_PHBINIT, "\tget reg failed.\n"); 
-		return NULL;
-	}
+	unsigned int len;
 
-	if (addr_size_words == 1) {
-		reg_struct.address = ((struct reg_property32 *)ui_ptr)->address;
-		reg_struct.size    = ((struct reg_property32 *)ui_ptr)->size;
-	} else {
-		reg_struct = *((struct reg_property64 *)ui_ptr);
-	}
+	bus_range = (int *) get_property(dev, "bus-range", &len);
+	if (bus_range == NULL || len < 2 * sizeof(int)) {
+		return 1;
+ 	}
+ 
+	phb->first_busno =  bus_range[0];
+	phb->last_busno  =  bus_range[1];
 
-	if (strstr(model, "Python")) {
-		phb_type = phb_type_python;
-	} else if (strstr(model, "Speedwagon")) {
-		phb_type = phb_type_speedwagon;
-	} else if (strstr(model, "Winnipeg")) {
-		phb_type = phb_type_winnipeg;
-	} else {
-		printk(KERN_ERR "alloc_phb: unknown PHB %s\n", model);
-		phb_type = phb_type_unknown;
-	}
+	return 0;
+}
 
-	phb = pci_alloc_pci_controller(phb_type);
-	if (phb == NULL)
-		return NULL;
+static int __devinit setup_phb(struct device_node *dev,
+			       struct pci_controller *phb,
+			       unsigned int addr_size_words)
+{
+	pci_setup_pci_controller(phb);
 
-	if (phb_type == phb_type_python)
-		python_countermeasures(reg_struct.address);
+	if (is_python(dev))
+		python_countermeasures(dev, addr_size_words);
 
-	bus_range = (int *) get_property(dev, "bus-range", &len);
-	if (bus_range == NULL || len < 2 * sizeof(int)) {
-		kfree(phb);
-		return NULL;
-	}
+	if (phb_set_bus_ranges(dev, phb))
+		return 1;
 
-	of_prop = (struct property *)alloc_bootmem(sizeof(struct property) +
-			sizeof(phb->global_number));        
+	phb->arch_data = dev;
+	phb->ops = &rtas_pci_ops;
+	phb->buid = get_phb_buid(dev);
 
-	if (!of_prop) {
-		kfree(phb);
-		return NULL;
-	}
+	return 0;
+}
 
+static void __devinit add_linux_pci_domain(struct device_node *dev,
+					   struct pci_controller *phb,
+					   struct property *of_prop)
+{
 	memset(of_prop, 0, sizeof(struct property));
 	of_prop->name = "linux,pci-domain";
 	of_prop->length = sizeof(phb->global_number);
 	of_prop->value = (unsigned char *)&of_prop[1];
 	memcpy(of_prop->value, &phb->global_number, sizeof(phb->global_number));
 	prom_add_property(dev, of_prop);
+}
 
-	phb->first_busno =  bus_range[0];
-	phb->last_busno  =  bus_range[1];
+static struct pci_controller * __init alloc_phb(struct device_node *dev,
+						unsigned int addr_size_words)
+{
+	struct pci_controller *phb;
+	struct property *of_prop;
 
-	phb->arch_data   = dev;
-	phb->ops = &rtas_pci_ops;
+	phb = alloc_bootmem(sizeof(struct pci_controller));
+	if (phb == NULL)
+		return NULL;
 
-	phb->buid = get_phb_buid(dev);
+	of_prop = alloc_bootmem(sizeof(struct property) +
+				sizeof(phb->global_number));
+	if (!of_prop)
+		return NULL;
+
+	if (setup_phb(dev, phb, addr_size_words))
+		return NULL;
+
+	add_linux_pci_domain(dev, phb, of_prop);
 
 	return phb;
 }
 
+static struct pci_controller * __devinit alloc_phb_dynamic(struct device_node *dev, unsigned int addr_size_words)
+{
+	struct pci_controller *phb;
+
+	phb = (struct pci_controller *)kmalloc(sizeof(struct pci_controller),
+					       GFP_KERNEL);
+	if (phb == NULL)
+		return NULL;
+
+	if (setup_phb(dev, phb, addr_size_words))
+		return NULL;
+
+	phb->is_dynamic = 1;
+
+	/* TODO: linux,pci-domain? */
+
+ 	return phb;
+}
+
 unsigned long __init find_and_init_phbs(void)
 {
 	struct device_node *node;
@@ -330,11 +372,12 @@
 		if (!phb)
 			continue;
 
-		pci_process_bridge_OF_ranges(phb, node, index == 0);
+		pci_process_bridge_OF_ranges(phb, node);
+		pci_setup_phb_io(phb, index == 0);
 
-		if (naca->interrupt_controller == IC_OPEN_PIC) {
+		if (naca->interrupt_controller == IC_OPEN_PIC && pSeries_mpic) {
 			int addr = root_size_cells * (index + 2) - 1;
-			openpic_setup_ISU(index, opprop[addr]); 
+			mpic_assign_isu(pSeries_mpic, index, opprop[addr]);
 		}
 
 		index++;
@@ -343,9 +386,55 @@
 	of_node_put(root);
 	pci_devs_phb_init();
 
+	/*
+	 * pci_probe_only and pci_assign_all_buses can be set via properties
+	 * in chosen.
+	 */
+	if (of_chosen) {
+		int *prop;
+
+		prop = (int *)get_property(of_chosen, "linux,pci-probe-only",
+					   NULL);
+		if (prop)
+			pci_probe_only = *prop;
+
+		prop = (int *)get_property(of_chosen,
+					   "linux,pci-assign-all-buses", NULL);
+		if (prop)
+			pci_assign_all_buses = *prop;
+	}
+
 	return 0;
 }
 
+struct pci_controller * __devinit init_phb_dynamic(struct device_node *dn)
+{
+	struct device_node *root = of_find_node_by_path("/");
+	unsigned int root_size_cells = 0;
+	struct pci_controller *phb;
+	struct pci_bus *bus;
+
+	root_size_cells = prom_n_size_cells(root);
+
+	phb = alloc_phb_dynamic(dn, root_size_cells);
+	if (!phb)
+		return NULL;
+
+	pci_process_bridge_OF_ranges(phb, dn);
+
+	pci_setup_phb_io_dynamic(phb);
+	of_node_put(root);
+
+	pci_devs_phb_init_dynamic(phb);
+	phb->last_busno = 0xff;
+	bus = pci_scan_bus(phb->first_busno, phb->ops, phb->arch_data);
+	phb->bus = bus;
+	phb->last_busno = bus->subordinate;
+
+	return phb;
+}
+EXPORT_SYMBOL(init_phb_dynamic);
+
 #if 0
 void pcibios_name_device(struct pci_dev *dev)
 {
@@ -386,113 +475,64 @@
 	}
 }
 
-static int get_bus_io_range(struct pci_bus *bus, unsigned long *start_phys,
-				unsigned long *start_virt, unsigned long *size)
+/* RPA-specific bits for removing PHBs */
+int pcibios_remove_root_bus(struct pci_controller *phb)
 {
-	struct pci_controller *hose = PCI_GET_PHB_PTR(bus);
-	struct pci_bus_region region;
+	struct pci_bus *b = phb->bus;
 	struct resource *res;
+	int rc, i;
 
-	if (bus->self) {
-		res = bus->resource[0];
-		pcibios_resource_to_bus(bus->self, &region, res);
-		*start_phys = hose->io_base_phys + region.start;
-		*start_virt = (unsigned long) hose->io_base_virt + 
-				region.start;
-		if (region.end > region.start) 
-			*size = region.end - region.start + 1;
-		else {
-			printk("%s(): unexpected region 0x%lx->0x%lx\n", 
-					__FUNCTION__, region.start, region.end);
-			return 1;
-		}
-		
-	} else {
-		/* Root Bus */
-		res = &hose->io_resource;
-		*start_phys = hose->io_base_phys;
-		*start_virt = (unsigned long) hose->io_base_virt;
-		if (res->end > res->start)
-			*size = res->end - res->start + 1;
-		else {
-			printk("%s(): unexpected region 0x%lx->0x%lx\n", 
-					__FUNCTION__, res->start, res->end);
-			return 1;
-		}
+	res = b->resource[0];
+	if (!res->flags) {
+		printk(KERN_ERR "%s: no IO resource for PHB %s\n", __FUNCTION__,
+				b->name);
+		return 1;
 	}
 
-	return 0;
-}
-
-int unmap_bus_range(struct pci_bus *bus)
-{
-	unsigned long start_phys;
-	unsigned long start_virt;
-	unsigned long size;
-
-	if (!bus) {
-		printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
+	rc = unmap_bus_range(b);
+	if (rc) {
+		printk(KERN_ERR "%s: failed to unmap IO on bus %s\n",
+			__FUNCTION__, b->name);
 		return 1;
 	}
-	
-	if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
-		return 1;
-	if (iounmap_explicit((void *) start_virt, size))
-		return 1;
 
-	return 0;
-}
-EXPORT_SYMBOL(unmap_bus_range);
-
-int remap_bus_range(struct pci_bus *bus)
-{
-	unsigned long start_phys;
-	unsigned long start_virt;
-	unsigned long size;
-
-	if (!bus) {
-		printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
+	if (release_resource(res)) {
+		printk(KERN_ERR "%s: failed to release IO on bus %s\n",
+				__FUNCTION__, b->name);
 		return 1;
 	}
-	
-	if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
-		return 1;
-	if (__ioremap_explicit(start_phys, start_virt, size, _PAGE_NO_CACHE))
-		return 1;
 
-	return 0;
-}
-EXPORT_SYMBOL(remap_bus_range);
+	for (i = 1; i < 3; ++i) {
+		res = b->resource[i];
+		if (!res->flags && i == 0) {
+			printk(KERN_ERR "%s: no MEM resource for PHB %s\n",
+				__FUNCTION__, b->name);
+			return 1;
+		}
+		if (res->flags && release_resource(res)) {
+			printk(KERN_ERR
+			       "%s: failed to release IO %d on bus %s\n",
+				__FUNCTION__, i, b->name);
+			return 1;
+		}
+	}
 
-static void phbs_fixup_io(void)
-{
-	struct pci_controller *hose, *tmp;
+	list_del(&phb->list_node);
+	if (phb->is_dynamic)
+		kfree(phb);
 
-	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
-		remap_bus_range(hose->bus);
+	return 0;
 }
+EXPORT_SYMBOL(pcibios_remove_root_bus);
 
 static void __init pSeries_request_regions(void)
 {
-	struct device_node *i8042;
-
 	request_region(0x20,0x20,"pic1");
 	request_region(0xa0,0x20,"pic2");
 	request_region(0x00,0x20,"dma1");
 	request_region(0x40,0x20,"timer");
 	request_region(0x80,0x10,"dma page reg");
 	request_region(0xc0,0x20,"dma2");
-
-#define I8042_DATA_REG 0x60
-
-	/*
-	 * Some machines have an unterminated i8042 so check the device
-	 * tree and reserve the region if it does not appear. Later on
-	 * the i8042 code will try and reserve this region and fail.
-	 */
-	if (!(i8042 = of_find_node_by_type(NULL, "8042")))
-		request_region(I8042_DATA_REG, 16, "reserved (no i8042)");
-	of_node_put(i8042);
 }
 
 void __init pSeries_final_fixup(void)
@@ -501,7 +541,7 @@
 
 	check_s7a();
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		pci_read_irq_line(dev);
 		if (s7a_workaround) {
 			if (dev->irq > 16) {
@@ -511,7 +551,7 @@
 		}
 	}
 
-	phbs_fixup_io();
+	phbs_remap_io();
 	pSeries_request_regions();
 	pci_fix_bus_sysdata();
 
@@ -521,3 +561,30 @@
 	pci_addr_cache_build();
 }
 
+/*
+ * Assume the winbond 82c105 is the IDE controller on a
+ * p610.  We should probably be more careful in case
+ * someone tries to plug in a similar adapter.
+ */
+static void fixup_winbond_82c105(struct pci_dev* dev)
+{
+	int i;
+	unsigned int reg;
+
+	if (!(systemcfg->platform & PLATFORM_PSERIES))
+		return;
+
+	printk("Using INTC for W82c105 IDE controller.\n");
+	pci_read_config_dword(dev, 0x40, &reg);
+	/* Enable LEGIRQ to use INTC instead of ISA interrupts */
+	pci_write_config_dword(dev, 0x40, reg | (1<<11));
+
+	for (i = 0; i < DEVICE_COUNT_RESOURCE; ++i) {
+		/* zap the 2nd function of the winbond chip */
+		if (dev->resource[i].flags & IORESOURCE_IO
+		    && dev->bus->number == 0 && dev->devfn == 0x81)
+			dev->resource[i].flags &= ~IORESOURCE_IO;
+	}
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
+			 fixup_winbond_82c105);
diff -Nru a/arch/ppc64/kernel/pSeries_setup.c b/arch/ppc64/kernel/pSeries_setup.c
--- a/arch/ppc64/kernel/pSeries_setup.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/kernel/pSeries_setup.c	2004-12-24 13:36:18 -08:00
@@ -61,19 +61,18 @@
 #include <asm/nvram.h>
 
 #include "i8259.h"
-#include "open_pic.h"
 #include <asm/xics.h>
 #include <asm/ppcdebug.h>
 #include <asm/cputable.h>
 
+#include "mpic.h"
+
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
 #else
 #define DBG(fmt...)
 #endif
 
-extern void pSeries_init_openpic(void);
-
 extern void find_and_init_phbs(void);
 extern void pSeries_final_fixup(void);
 
@@ -82,6 +81,8 @@
 extern int  pSeries_set_rtc_time(struct rtc_time *rtc_time);
 extern void find_udbg_vterm(void);
 extern void SystemReset_FWNMI(void), MachineCheck_FWNMI(void);	/* from head.S */
+extern void generic_find_legacy_serial_ports(unsigned int *default_speed);
+
 int fwnmi_active;  /* TRUE if an FWNMI handler is present */
 
 unsigned long  virtPython0Facilities = 0;  // python0 facility area (memory mapped io) (64-bit format) VIRTUAL address.
@@ -91,6 +92,9 @@
 extern unsigned long ppc_proc_freq;
 extern unsigned long ppc_tb_freq;
 
+static volatile void __iomem * chrp_int_ack_special;
+struct mpic *pSeries_mpic;
+
 void pSeries_get_cpuinfo(struct seq_file *m)
 {
 	struct device_node *root;
@@ -120,15 +124,84 @@
 		fwnmi_active = 1;
 }
 
-static void __init pSeries_setup_arch(void)
+static int pSeries_irq_cascade(struct pt_regs *regs, void *data)
+{
+	if (chrp_int_ack_special)
+		return readb(chrp_int_ack_special);
+	else
+		return i8259_irq(smp_processor_id());
+}
+
+static void __init pSeries_init_mpic(void)
+{
+        unsigned int *addrp;
+	struct device_node *np;
+        int i;
+
+	/* All ISUs are setup, complete initialization */
+	mpic_init(pSeries_mpic);
+
+	/* Check what kind of cascade ACK we have */
+        if (!(np = of_find_node_by_name(NULL, "pci"))
+            || !(addrp = (unsigned int *)
+                 get_property(np, "8259-interrupt-acknowledge", NULL)))
+                printk(KERN_ERR "Cannot find pci to get ack address\n");
+        else
+		chrp_int_ack_special = ioremap(addrp[prom_n_addr_cells(np)-1], 1);
+	of_node_put(np);
+
+	/* Setup the legacy interrupts & controller */
+        for (i = 0; i < NUM_ISA_INTERRUPTS; i++)
+                irq_desc[i].handler = &i8259_pic;
+	i8259_init(0);
+
+	/* Hook cascade to mpic */
+	mpic_setup_cascade(NUM_ISA_INTERRUPTS, pSeries_irq_cascade, NULL);
+}
+
+static void __init pSeries_setup_mpic(void)
 {
-	struct device_node *root;
 	unsigned int *opprop;
+	unsigned long openpic_addr = 0;
+        unsigned char senses[NR_IRQS - NUM_ISA_INTERRUPTS];
+        struct device_node *root;
+	int irq_count;
+
+	/* Find the Open PIC if present */
+	root = of_find_node_by_path("/");
+	opprop = (unsigned int *) get_property(root, "platform-open-pic", NULL);
+	if (opprop != 0) {
+		int n = prom_n_addr_cells(root);
+
+		for (openpic_addr = 0; n > 0; --n)
+			openpic_addr = (openpic_addr << 32) + *opprop++;
+		printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
+	}
+	of_node_put(root);
+
+	BUG_ON(openpic_addr == 0);
+
+	/* Get the sense values from OF */
+	prom_get_irq_senses(senses, NUM_ISA_INTERRUPTS, NR_IRQS);
+	
+	/* Setup the openpic driver */
+	irq_count = NR_IRQS - NUM_ISA_INTERRUPTS - 4; /* leave room for IPIs */
+	pSeries_mpic = mpic_alloc(openpic_addr, MPIC_PRIMARY,
+				  16, 16, irq_count, /* isu size, irq offset, irq count */ 
+				  NR_IRQS - 4, /* ipi offset */
+				  senses, irq_count, /* sense & sense size */
+				  " MPIC     ");
+}
 
+static void __init pSeries_setup_arch(void)
+{
 	/* Fixup ppc_md depending on the type of interrupt controller */
 	if (naca->interrupt_controller == IC_OPEN_PIC) {
-		ppc_md.init_IRQ       = pSeries_init_openpic; 
-		ppc_md.get_irq        = openpic_get_irq;
+		ppc_md.init_IRQ       = pSeries_init_mpic; 
+		ppc_md.get_irq        = mpic_get_irq;
+		/* Allocate the mpic now, so that find_and_init_phbs() can
+		 * fill the ISUs */
+		pSeries_setup_mpic();
 	} else {
 		ppc_md.init_IRQ       = xics_init_IRQ;
 		ppc_md.get_irq        = xics_get_irq;
@@ -156,26 +229,14 @@
 	eeh_init();
 	find_and_init_phbs();
 
-	/* Find the Open PIC if present */
-	root = of_find_node_by_path("/");
-	opprop = (unsigned int *) get_property(root,
-				"platform-open-pic", NULL);
-	if (opprop != 0) {
-		int n = prom_n_addr_cells(root);
-		unsigned long openpic;
-
-		for (openpic = 0; n > 0; --n)
-			openpic = (openpic << 32) + *opprop++;
-		printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic);
-		OpenPIC_Addr = __ioremap(openpic, 0x40000, _PAGE_NO_CACHE);
-	}
-	of_node_put(root);
-
 #ifdef CONFIG_DUMMY_CONSOLE
 	conswitchp = &dummy_con;
 #endif
 
 	pSeries_nvram_init();
+
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR)
+		vpa_init(boot_cpuid);
 }
 
 static int __init pSeries_init_panel(void)
@@ -189,75 +250,6 @@
 arch_initcall(pSeries_init_panel);
 
 
-
-void __init pSeries_find_serial_port(void)
-{
-	struct device_node *np;
-	unsigned long encode_phys_size = 32;
-	u32 *sizeprop;
-
-	struct isa_reg_property {
-		u32 space;
-		u32 address;
-		u32 size;
-	};
-	struct pci_reg_property {
-		struct pci_address addr;
-		u32 size_hi;
-		u32 size_lo;
-	};                                                                        
-
-	DBG(" -> pSeries_find_serial_port()\n");
-
-	naca->serialPortAddr = 0;
-
-	np = of_find_node_by_path("/");
-	if (!np)
-		return;
-	sizeprop = (u32 *)get_property(np, "#size-cells", NULL);
-	if (sizeprop != NULL)
-		encode_phys_size = (*sizeprop) << 5;
-	
-	for (np = NULL; (np = of_find_node_by_type(np, "serial"));) {
-		struct device_node *isa, *pci;
-		struct isa_reg_property *reg;
-		union pci_range *rangesp;
-		char *typep;
-
-	 	typep = (char *)get_property(np, "ibm,aix-loc", NULL);
-		if ((typep == NULL) || (typep && strcmp(typep, "S1")))
-			continue;
-
-		reg = (struct isa_reg_property *)get_property(np, "reg", NULL);	
-
-		isa = of_get_parent(np);
-		if (!isa) {
-			DBG("no isa parent found\n");
-			break;
-		}
-		pci = of_get_parent(isa);
-		if (!pci) {
-			DBG("no pci parent found\n");
-			break;
-		}
-
-		rangesp = (union pci_range *)get_property(pci, "ranges", NULL);
-
-		if ( encode_phys_size == 32 )
-			naca->serialPortAddr = rangesp->pci32.phys+reg->address;
-		else {
-			naca->serialPortAddr =
-				((((unsigned long)rangesp->pci64.phys_hi) << 32)
-				|
-			(rangesp->pci64.phys_lo)) + reg->address;
-		}
-		break;
-	}
-
-	DBG(" <- pSeries_find_serial_port()\n");
-}
-
-
 /* Build up the firmware_features bitmask field
  * using contents of device-tree/ibm,hypertas-functions.
  * Ultimately this functionality may be moved into prom.c prom_init().
@@ -330,6 +322,20 @@
 	}
 }
 
+static void pSeries_cpu_die(void)
+{
+	local_irq_disable();
+	/* Some hardware requires clearing the CPPR, while other hardware does not
+	 * it is safe either way
+	 */
+	pSeriesLP_cppr_info(0, 0);
+	rtas_stop_self();
+	/* Should never get here... */
+	BUG();
+	for(;;);
+}
+
+
 /*
  * Early initialization.  Relocation is on but do not reference unbolted pages
  */
@@ -337,6 +343,7 @@
 {
 	void *comport;
 	int iommu_off = 0;
+	unsigned int default_speed;
 
 	DBG(" -> pSeries_init_early()\n");
 
@@ -350,14 +357,14 @@
 			     get_property(of_chosen, "linux,iommu-off", NULL));
 	}
 
-	pSeries_find_serial_port();
+	generic_find_legacy_serial_ports(&default_speed);
 
 	if (systemcfg->platform & PLATFORM_LPAR)
 		find_udbg_vterm();
 	else if (naca->serialPortAddr) {
 		/* Map the uart for udbg. */
 		comport = (void *)__ioremap(naca->serialPortAddr, 16, _PAGE_NO_CACHE);
-		udbg_init_uart(comport);
+		udbg_init_uart(comport, default_speed);
 
 		ppc_md.udbg_putc = udbg_putc;
 		ppc_md.udbg_getc = udbg_getc;
@@ -542,6 +549,31 @@
 	setup_default_decr();
 }
 
+static int pSeries_check_legacy_ioport(unsigned int baseport)
+{
+	struct device_node *np;
+
+#define I8042_DATA_REG	0x60
+#define FDC_BASE	0x3f0
+
+
+	switch(baseport) {
+	case I8042_DATA_REG:
+		np = of_find_node_by_type(NULL, "8042");
+		if (np == NULL)
+			return -ENODEV;
+		of_node_put(np);
+		break;
+	case FDC_BASE:
+		np = of_find_node_by_type(NULL, "fdc");
+		if (np == NULL)
+			return -ENODEV;
+		of_node_put(np);
+		break;
+	}
+	return 0;
+}
+
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
@@ -571,9 +603,11 @@
 	.power_off		= rtas_power_off,
 	.halt			= rtas_halt,
 	.panic			= rtas_os_term,
+	.cpu_die		= pSeries_cpu_die,
 	.get_boot_time		= pSeries_get_boot_time,
 	.get_rtc_time		= pSeries_get_rtc_time,
 	.set_rtc_time		= pSeries_set_rtc_time,
 	.calibrate_decr		= pSeries_calibrate_decr,
 	.progress		= pSeries_progress,
+	.check_legacy_ioport	= pSeries_check_legacy_ioport,
 };
diff -Nru a/arch/ppc64/kernel/pSeries_smp.c b/arch/ppc64/kernel/pSeries_smp.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/kernel/pSeries_smp.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,382 @@
+/*
+ * SMP support for pSeries machines.
+ *
+ * Dave Engebretsen, Peter Bergner, and
+ * Mike Corrigan {engebret|bergner|mikec}@us.ibm.com
+ *
+ * Plus various changes from other IBM teams...
+ *
+ *      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.
+ */
+
+#undef DEBUG
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.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>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/cache.h>
+#include <linux/err.h>
+#include <linux/sysdev.h>
+#include <linux/cpu.h>
+
+#include <asm/ptrace.h>
+#include <asm/atomic.h>
+#include <asm/irq.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <asm/smp.h>
+#include <asm/naca.h>
+#include <asm/paca.h>
+#include <asm/time.h>
+#include <asm/ppcdebug.h>
+#include <asm/machdep.h>
+#include <asm/xics.h>
+#include <asm/cputable.h>
+#include <asm/system.h>
+#include <asm/rtas.h>
+#include <asm/plpar_wrappers.h>
+
+#include "mpic.h"
+
+#ifdef DEBUG
+#define DBG(fmt...) udbg_printf(fmt)
+#else
+#define DBG(fmt...)
+#endif
+
+extern void pseries_secondary_smp_init(unsigned long); 
+
+/* Get state of physical CPU.
+ * Return codes:
+ *	0	- The processor is in the RTAS stopped state
+ *	1	- stop-self is in progress
+ *	2	- The processor is not in the RTAS stopped state
+ *	-1	- Hardware Error
+ *	-2	- Hardware Busy, Try again later.
+ */
+static int query_cpu_stopped(unsigned int pcpu)
+{
+	int cpu_status;
+	int status, qcss_tok;
+
+	qcss_tok = rtas_token("query-cpu-stopped-state");
+	if (qcss_tok == RTAS_UNKNOWN_SERVICE)
+		return -1;
+	status = rtas_call(qcss_tok, 1, 2, &cpu_status, pcpu);
+	if (status != 0) {
+		printk(KERN_ERR
+		       "RTAS query-cpu-stopped-state failed: %i\n", status);
+		return status;
+	}
+
+	return cpu_status;
+}
+
+
+#ifdef CONFIG_HOTPLUG_CPU
+
+int __cpu_disable(void)
+{
+	/* FIXME: go put this in a header somewhere */
+	extern void xics_migrate_irqs_away(void);
+
+	systemcfg->processorCount--;
+
+	/*fix boot_cpuid here*/
+	if (smp_processor_id() == boot_cpuid)
+		boot_cpuid = any_online_cpu(cpu_online_map);
+
+	/* FIXME: abstract this to not be platform specific later on */
+	xics_migrate_irqs_away();
+	return 0;
+}
+
+void __cpu_die(unsigned int cpu)
+{
+	int tries;
+	int cpu_status;
+	unsigned int pcpu = get_hard_smp_processor_id(cpu);
+
+	for (tries = 0; tries < 25; tries++) {
+		cpu_status = query_cpu_stopped(pcpu);
+		if (cpu_status == 0 || cpu_status == -1)
+			break;
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(HZ/5);
+	}
+	if (cpu_status != 0) {
+		printk("Querying DEAD? cpu %i (%i) shows %i\n",
+		       cpu, pcpu, cpu_status);
+	}
+
+	/* Isolation and deallocation are definatly done by
+	 * drslot_chrp_cpu.  If they were not they would be
+	 * done here.  Change isolate state to Isolate and
+	 * change allocation-state to Unusable.
+	 */
+	paca[cpu].cpu_start = 0;
+}
+
+/* Search all cpu device nodes for an offline logical cpu.  If a
+ * device node has a "ibm,my-drc-index" property (meaning this is an
+ * LPAR), paranoid-check whether we own the cpu.  For each "thread"
+ * of a cpu, if it is offline and has the same hw index as before,
+ * grab that in preference.
+ */
+static unsigned int find_physical_cpu_to_start(unsigned int old_hwindex)
+{
+	struct device_node *np = NULL;
+	unsigned int best = -1U;
+
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+		int nr_threads, len;
+		u32 *index = (u32 *)get_property(np, "ibm,my-drc-index", NULL);
+		u32 *tid = (u32 *)
+			get_property(np, "ibm,ppc-interrupt-server#s", &len);
+
+		if (!tid)
+			tid = (u32 *)get_property(np, "reg", &len);
+
+		if (!tid)
+			continue;
+
+		/* If there is a drc-index, make sure that we own
+		 * the cpu.
+		 */
+		if (index) {
+			int state;
+			int rc = rtas_get_sensor(9003, *index, &state);
+			if (rc != 0 || state != 1)
+				continue;
+		}
+
+		nr_threads = len / sizeof(u32);
+
+		while (nr_threads--) {
+			if (0 == query_cpu_stopped(tid[nr_threads])) {
+				best = tid[nr_threads];
+				if (best == old_hwindex)
+					goto out;
+			}
+		}
+	}
+out:
+	of_node_put(np);
+	return best;
+}
+
+/**
+ * smp_startup_cpu() - start the given cpu
+ *
+ * At boot time, there is nothing to do.  At run-time, call RTAS with
+ * the appropriate start location, if the cpu is in the RTAS stopped
+ * state.
+ *
+ * Returns:
+ *	0	- failure
+ *	1	- success
+ */
+static inline int __devinit smp_startup_cpu(unsigned int lcpu)
+{
+	int status;
+	unsigned long start_here = __pa((u32)*((unsigned long *)
+					       pseries_secondary_smp_init));
+	unsigned int pcpu;
+
+	/* At boot time the cpus are already spinning in hold
+	 * loops, so nothing to do. */
+ 	if (system_state < SYSTEM_RUNNING)
+		return 1;
+
+	pcpu = find_physical_cpu_to_start(get_hard_smp_processor_id(lcpu));
+	if (pcpu == -1U) {
+		printk(KERN_INFO "No more cpus available, failing\n");
+		return 0;
+	}
+
+	/* Fixup atomic count: it exited inside IRQ handler. */
+	paca[lcpu].__current->thread_info->preempt_count	= 0;
+
+	/* At boot this is done in prom.c. */
+	paca[lcpu].hw_cpu_id = pcpu;
+
+	status = rtas_call(rtas_token("start-cpu"), 3, 1, NULL,
+			   pcpu, start_here, lcpu);
+	if (status != 0) {
+		printk(KERN_ERR "start-cpu failed: %i\n", status);
+		return 0;
+	}
+	return 1;
+}
+#else /* ... CONFIG_HOTPLUG_CPU */
+static inline int __devinit smp_startup_cpu(unsigned int lcpu)
+{
+	return 1;
+}
+#endif /* CONFIG_HOTPLUG_CPU */
+
+static inline void smp_xics_do_message(int cpu, int msg)
+{
+	set_bit(msg, &xics_ipi_message[cpu].value);
+	mb();
+	xics_cause_IPI(cpu);
+}
+
+static void smp_xics_message_pass(int target, int msg)
+{
+	unsigned int i;
+
+	if (target < NR_CPUS) {
+		smp_xics_do_message(target, msg);
+	} else {
+		for_each_online_cpu(i) {
+			if (target == MSG_ALL_BUT_SELF
+			    && i == smp_processor_id())
+				continue;
+			smp_xics_do_message(i, msg);
+		}
+	}
+}
+
+extern void xics_request_IPIs(void);
+
+static int __init smp_xics_probe(void)
+{
+	xics_request_IPIs();
+
+	return cpus_weight(cpu_possible_map);
+}
+
+static void __devinit smp_xics_setup_cpu(int cpu)
+{
+	if (cpu != boot_cpuid)
+		xics_setup_cpu();
+}
+
+static spinlock_t timebase_lock = SPIN_LOCK_UNLOCKED;
+static unsigned long timebase = 0;
+
+static void __devinit pSeries_give_timebase(void)
+{
+	spin_lock(&timebase_lock);
+	rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
+	timebase = get_tb();
+	spin_unlock(&timebase_lock);
+
+	while (timebase)
+		barrier();
+	rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
+}
+
+static void __devinit pSeries_take_timebase(void)
+{
+	while (!timebase)
+		barrier();
+	spin_lock(&timebase_lock);
+	set_tb(timebase >> 32, timebase & 0xffffffff);
+	timebase = 0;
+	spin_unlock(&timebase_lock);
+}
+
+static void __devinit pSeries_late_setup_cpu(int cpu)
+{
+	extern unsigned int default_distrib_server;
+
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
+		vpa_init(cpu); 
+	}
+
+#ifdef CONFIG_IRQ_ALL_CPUS
+	/* Put the calling processor into the GIQ.  This is really only
+	 * necessary from a secondary thread as the OF start-cpu interface
+	 * performs this function for us on primary threads.
+	 */
+	/* TODO: 9005 is #defined in rtas-proc.c -- move to a header */
+	rtas_set_indicator(9005, default_distrib_server, 1);
+#endif
+}
+
+
+void __devinit smp_pSeries_kick_cpu(int nr)
+{
+	BUG_ON(nr < 0 || nr >= NR_CPUS);
+
+	if (!smp_startup_cpu(nr))
+		return;
+
+	/*
+	 * The processor is currently spinning, waiting for the
+	 * cpu_start field to become non-zero After we set cpu_start,
+	 * the processor will continue on to secondary_start
+	 */
+	paca[nr].cpu_start = 1;
+}
+
+static struct smp_ops_t pSeries_mpic_smp_ops = {
+	.message_pass	= smp_mpic_message_pass,
+	.probe		= smp_mpic_probe,
+	.kick_cpu	= smp_pSeries_kick_cpu,
+	.setup_cpu	= smp_mpic_setup_cpu,
+	.late_setup_cpu	= pSeries_late_setup_cpu,
+};
+
+static struct smp_ops_t pSeries_xics_smp_ops = {
+	.message_pass	= smp_xics_message_pass,
+	.probe		= smp_xics_probe,
+	.kick_cpu	= smp_pSeries_kick_cpu,
+	.setup_cpu	= smp_xics_setup_cpu,
+	.late_setup_cpu	= pSeries_late_setup_cpu,
+};
+
+/* This is called very early */
+void __init smp_init_pSeries(void)
+{
+	int ret, i;
+
+	DBG(" -> smp_init_pSeries()\n");
+
+	if (naca->interrupt_controller == IC_OPEN_PIC)
+		smp_ops = &pSeries_mpic_smp_ops;
+	else
+		smp_ops = &pSeries_xics_smp_ops;
+
+	/* Start secondary threads on SMT systems; primary threads
+	 * are already in the running state.
+	 */
+	for_each_present_cpu(i) {
+		if (query_cpu_stopped(get_hard_smp_processor_id(i)) == 0) {
+			printk("%16.16x : starting thread\n", i);
+			DBG("%16.16x : starting thread\n", i);
+			rtas_call(rtas_token("start-cpu"), 3, 1, &ret,
+				  get_hard_smp_processor_id(i),
+				  __pa((u32)*((unsigned long *)
+					      pseries_secondary_smp_init)),
+				  i);
+		}
+	}
+
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR)
+		vpa_init(boot_cpuid);
+
+	/* Non-lpar has additional take/give timebase */
+	if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) {
+		smp_ops->give_timebase = pSeries_give_timebase;
+		smp_ops->take_timebase = pSeries_take_timebase;
+	}
+
+	DBG(" <- smp_init_pSeries()\n");
+}
+
diff -Nru a/arch/ppc64/kernel/pacaData.c b/arch/ppc64/kernel/pacaData.c
--- a/arch/ppc64/kernel/pacaData.c	2004-12-24 13:37:17 -08:00
+++ b/arch/ppc64/kernel/pacaData.c	2004-12-24 13:37:17 -08:00
@@ -7,13 +7,12 @@
  *      2 of the License, or (at your option) any later version.
  */
 
-#include <asm/types.h>
-#include <asm/page.h>
-#include <stddef.h>
 #include <linux/config.h>
+#include <linux/types.h>
 #include <linux/threads.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
+#include <asm/page.h>
 
 #include <asm/iSeries/ItLpPaca.h>
 #include <asm/iSeries/ItLpQueue.h>
@@ -59,6 +58,7 @@
 	.stab_real = (asrr), 		/* Real pointer to segment table */ \
 	.stab_addr = (asrv),		/* Virt pointer to segment table */ \
 	.cpu_start = (start),		/* Processor start */		    \
+	.hw_cpu_id = 0xffff,						    \
 	.lppaca = {							    \
 		.xDesc = 0xd397d781,	/* "LpPa" */			    \
 		.xSize = sizeof(struct ItLpPaca),			    \
diff -Nru a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c
--- a/arch/ppc64/kernel/pci.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc64/kernel/pci.c	2004-12-24 13:37:18 -08:00
@@ -11,17 +11,14 @@
  *      2 of the License, or (at your option) any later version.
  */
 
+#undef DEBUG
+
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
-#include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/capability.h>
-#include <linux/sched.h>
-#include <linux/errno.h>
 #include <linux/bootmem.h>
-#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/list.h>
 
@@ -31,19 +28,24 @@
 #include <asm/pci-bridge.h>
 #include <asm/byteorder.h>
 #include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/ppcdebug.h>
-#include <asm/naca.h>
-#include <asm/iommu.h>
 #include <asm/machdep.h>
+#include <asm/udbg.h>
 
 #include "pci.h"
 
+#ifdef DEBUG
+#define DBG(fmt...) udbg_printf(fmt)
+#else
+#define DBG(fmt...)
+#endif
+
 unsigned long pci_probe_only = 1;
 unsigned long pci_assign_all_buses = 0;
 
-/* legal IO pages under MAX_ISA_PORT.  This is to ensure we don't touch
-   devices we don't have access to. */
+/*
+ * legal IO pages under MAX_ISA_PORT.  This is to ensure we don't touch
+ * devices we don't have access to.
+ */
 unsigned long io_page_mask;
 
 EXPORT_SYMBOL(io_page_mask);
@@ -85,32 +87,8 @@
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TRIDENT, PCI_ANY_ID, fixup_broken_pcnet32);
 
-static void fixup_windbond_82c105(struct pci_dev* dev)
-{
-	/* Assume the windbond 82c105 is the IDE controller on a
-	 * p610.  We should probably be more careful in case
-	 * someone tries to plug in a similar adapter.
-	 */
-	int i;
-	unsigned int reg;
-
-	printk("Using INTC for W82c105 IDE controller.\n");
-	pci_read_config_dword(dev, 0x40, &reg);
-	/* Enable LEGIRQ to use INTC instead of ISA interrupts */
-	pci_write_config_dword(dev, 0x40, reg | (1<<11));
-
-	for (i = 0; i < DEVICE_COUNT_RESOURCE; ++i) {
-		/* zap the 2nd function of the winbond chip */
-		if (dev->resource[i].flags & IORESOURCE_IO
-		    && dev->bus->number == 0 && dev->devfn == 0x81)
-			dev->resource[i].flags &= ~IORESOURCE_IO;
-	}
-}
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105, fixup_windbond_82c105);
-
-void 
-pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
-			struct resource *res)
+void  pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
+			      struct resource *res)
 {
 	unsigned long offset = 0;
 	struct pci_controller *hose = PCI_GET_PHB_PTR(dev);
@@ -179,68 +157,27 @@
 	res->start = start;
 }
 
-/* 
- * Allocate pci_controller(phb) initialized common variables. 
+static spinlock_t hose_spinlock = SPIN_LOCK_UNLOCKED;
+
+/*
+ * pci_controller(phb) initialized common variables.
  */
-struct pci_controller * __init
-pci_alloc_pci_controller(enum phb_types controller_type)
+void __devinit pci_setup_pci_controller(struct pci_controller *hose)
 {
-        struct pci_controller *hose;
-	char *model;
-
-#ifdef CONFIG_PPC_ISERIES
-        hose = (struct pci_controller *)kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
-#else
-        hose = (struct pci_controller *)alloc_bootmem(sizeof(struct pci_controller));
-#endif
-        if(hose == NULL) {
-                printk(KERN_ERR "PCI: Allocate pci_controller failed.\n");
-                return NULL;
-        }
-        memset(hose, 0, sizeof(struct pci_controller));
-
-	switch(controller_type) {
-#ifdef CONFIG_PPC_ISERIES
-	case phb_type_hypervisor:
-		model = "PHB HV";
-		break;
-#endif
-	case phb_type_python:
-		model = "PHB PY";
-		break;
-	case phb_type_speedwagon:
-		model = "PHB SW";
-		break;
-	case phb_type_winnipeg:
-		model = "PHB WP";
-		break;
-	case phb_type_apple:
-		model = "PHB APPLE";
-		break;
-	default:
-		model = "PHB UK";
-		break;
-	}
-
-        if(strlen(model) < 8)
-		strcpy(hose->what,model);
-        else
-		memcpy(hose->what,model,7);
-        hose->type = controller_type;
-        hose->global_number = global_phb_number++;
+	memset(hose, 0, sizeof(struct pci_controller));
 
+	spin_lock(&hose_spinlock);
+	hose->global_number = global_phb_number++;
 	list_add_tail(&hose->list_node, &hose_list);
-
-        return hose;
+	spin_unlock(&hose_spinlock);
 }
 
 static void __init pcibios_claim_one_bus(struct pci_bus *b)
 {
-	struct list_head *ld;
+	struct pci_dev *dev;
 	struct pci_bus *child_bus;
 
-	for (ld = b->devices.next; ld != &b->devices; ld = ld->next) {
-		struct pci_dev *dev = pci_dev_b(ld);
+	list_for_each_entry(dev, &b->devices, bus_list) {
 		int i;
 
 		for (i = 0; i < PCI_NUM_RESOURCES; i++) {
@@ -259,12 +196,10 @@
 #ifndef CONFIG_PPC_ISERIES
 static void __init pcibios_claim_of_setup(void)
 {
-	struct list_head *lb;
+	struct pci_bus *b;
 
-	for (lb = pci_root_buses.next; lb != &pci_root_buses; lb = lb->next) {
-		struct pci_bus *b = pci_bus_b(lb);
+	list_for_each_entry(b, &pci_root_buses, node)
 		pcibios_claim_one_bus(b);
-	}
 }
 #endif
 
@@ -303,7 +238,7 @@
 		ppc_md.pcibios_fixup();
 
 	/* Cache the location of the ISA bridge (if we have one) */
-	ppc64_isabridge_dev = pci_find_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
+	ppc64_isabridge_dev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
 	if (ppc64_isabridge_dev != NULL)
 		printk("ISA bridge at %s\n", pci_name(ppc64_isabridge_dev));
 
@@ -397,9 +332,9 @@
  *
  * Returns negative error code on failure, zero on success.
  */
-static __inline__ int
-__pci_mmap_make_offset(struct pci_dev *dev, struct vm_area_struct *vma,
-		       enum pci_mmap_state mmap_state)
+static __inline__ int __pci_mmap_make_offset(struct pci_dev *dev,
+					     struct vm_area_struct *vma,
+					     enum pci_mmap_state mmap_state)
 {
 	struct pci_controller *hose = PCI_GET_PHB_PTR(dev);
 	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
@@ -454,9 +389,9 @@
  * Set vm_flags of VMA, as appropriate for this architecture, for a pci device
  * mapping.
  */
-static __inline__ void
-__pci_mmap_set_flags(struct pci_dev *dev, struct vm_area_struct *vma,
-		     enum pci_mmap_state mmap_state)
+static __inline__ void __pci_mmap_set_flags(struct pci_dev *dev,
+					    struct vm_area_struct *vma,
+					    enum pci_mmap_state mmap_state)
 {
 	vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO;
 }
@@ -465,9 +400,10 @@
  * Set vm_page_prot of VMA, as appropriate for this architecture, for a pci
  * device mapping.
  */
-static __inline__ void
-__pci_mmap_set_pgprot(struct pci_dev *dev, struct vm_area_struct *vma,
-		      enum pci_mmap_state mmap_state, int write_combine)
+static __inline__ void __pci_mmap_set_pgprot(struct pci_dev *dev,
+					     struct vm_area_struct *vma,
+					     enum pci_mmap_state mmap_state,
+					     int write_combine)
 {
 	long prot = pgprot_val(vma->vm_page_prot);
 
@@ -501,7 +437,7 @@
 	__pci_mmap_set_flags(dev, vma, mmap_state);
 	__pci_mmap_set_pgprot(dev, vma, mmap_state, write_combine);
 
-	ret = remap_page_range(vma, vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+	ret = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
 			       vma->vm_end - vma->vm_start, vma->vm_page_prot);
 
 	return ret;
@@ -534,9 +470,9 @@
 #define ISA_SPACE_MASK 0x1
 #define ISA_SPACE_IO 0x1
 
-static void pci_process_ISA_OF_ranges(struct device_node *isa_node,
+static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node,
 				      unsigned long phb_io_base_phys,
-				      void * phb_io_base_virt)
+				      void __iomem * phb_io_base_virt)
 {
 	struct isa_range *range;
 	unsigned long pci_addr;
@@ -545,9 +481,11 @@
 	int rlen = 0;
 
 	range = (struct isa_range *) get_property(isa_node, "ranges", &rlen);
-	if (rlen < sizeof(struct isa_range)) {
-		printk(KERN_ERR "unexpected isa range size: %s\n", 
-				__FUNCTION__);
+	if (range == NULL || (rlen < sizeof(struct isa_range))) {
+		printk(KERN_ERR "no ISA ranges or unexpected isa range size,"
+		       "mapping 64k\n");
+		__ioremap_explicit(phb_io_base_phys, (unsigned long)phb_io_base_virt, 
+				   0x10000, _PAGE_NO_CACHE);
 		return;	
 	}
 	
@@ -579,8 +517,8 @@
 	}
 }
 
-void __init pci_process_bridge_OF_ranges(struct pci_controller *hose,
-					 struct device_node *dev, int primary)
+void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
+					    struct device_node *dev)
 {
 	unsigned int *ranges;
 	unsigned long size;
@@ -589,7 +527,6 @@
 	struct resource *res;
 	int np, na = prom_n_addr_cells(dev);
 	unsigned long pci_addr, cpu_phys_addr;
-	struct device_node *isa_dn;
 
 	np = na + 5;
 
@@ -613,35 +550,18 @@
 			cpu_phys_addr = cpu_phys_addr << 32 | ranges[4];
 
 		size = (unsigned long)ranges[na+3] << 32 | ranges[na+4];
-
-		switch (ranges[0] >> 24) {
+		if (size == 0)
+			continue;
+		switch ((ranges[0] >> 24) & 0x3) {
 		case 1:		/* I/O space */
 			hose->io_base_phys = cpu_phys_addr;
-			hose->io_base_virt = reserve_phb_iospace(size);
-			PPCDBG(PPCDBG_PHBINIT, 
-			       "phb%d io_base_phys 0x%lx io_base_virt 0x%lx\n", 
-			       hose->global_number, hose->io_base_phys, 
-			       (unsigned long) hose->io_base_virt);
-
-			if (primary) {
-				pci_io_base = (unsigned long)hose->io_base_virt;
-				isa_dn = of_find_node_by_type(NULL, "isa");
-				if (isa_dn) {
-					isa_io_base = pci_io_base;
-					pci_process_ISA_OF_ranges(isa_dn,
-						hose->io_base_phys,
-						hose->io_base_virt);
-					of_node_put(isa_dn);
-                                        /* Allow all IO */
-                                        io_page_mask = -1;
-				}
-			}
+			hose->pci_io_size = size;
 
 			res = &hose->io_resource;
 			res->flags = IORESOURCE_IO;
 			res->start = pci_addr;
-			res->start += (unsigned long)hose->io_base_virt -
-				pci_io_base;
+			DBG("phb%d: IO 0x%lx -> 0x%lx\n", hose->global_number,
+				    res->start, res->start + size - 1);
 			break;
 		case 2:		/* memory space */
 			memno = 0;
@@ -654,6 +574,8 @@
 				res = &hose->mem_resources[memno];
 				res->flags = IORESOURCE_MEM;
 				res->start = cpu_phys_addr;
+				DBG("phb%d: MEM 0x%lx -> 0x%lx\n", hose->global_number,
+					    res->start, res->start + size - 1);
 			}
 			break;
 		}
@@ -668,13 +590,149 @@
 	}
 }
 
-/*********************************************************************** 
- * pci_find_hose_for_OF_device
- *
+void __init pci_setup_phb_io(struct pci_controller *hose, int primary)
+{
+	unsigned long size = hose->pci_io_size;
+	unsigned long io_virt_offset;
+	struct resource *res;
+	struct device_node *isa_dn;
+
+	hose->io_base_virt = reserve_phb_iospace(size);
+	DBG("phb%d io_base_phys 0x%lx io_base_virt 0x%lx\n",
+		hose->global_number, hose->io_base_phys,
+		(unsigned long) hose->io_base_virt);
+
+	if (primary) {
+		pci_io_base = (unsigned long)hose->io_base_virt;
+		isa_dn = of_find_node_by_type(NULL, "isa");
+		if (isa_dn) {
+			isa_io_base = pci_io_base;
+			pci_process_ISA_OF_ranges(isa_dn, hose->io_base_phys,
+						hose->io_base_virt);
+			of_node_put(isa_dn);
+			/* Allow all IO */
+			io_page_mask = -1;
+		}
+	}
+
+	io_virt_offset = (unsigned long)hose->io_base_virt - pci_io_base;
+	res = &hose->io_resource;
+	res->start += io_virt_offset;
+	res->end += io_virt_offset;
+}
+
+void __devinit pci_setup_phb_io_dynamic(struct pci_controller *hose)
+{
+	unsigned long size = hose->pci_io_size;
+	unsigned long io_virt_offset;
+	struct resource *res;
+
+	hose->io_base_virt = __ioremap(hose->io_base_phys, size,
+					_PAGE_NO_CACHE);
+	DBG("phb%d io_base_phys 0x%lx io_base_virt 0x%lx\n",
+		hose->global_number, hose->io_base_phys,
+		(unsigned long) hose->io_base_virt);
+
+	io_virt_offset = (unsigned long)hose->io_base_virt - pci_io_base;
+	res = &hose->io_resource;
+	res->start += io_virt_offset;
+	res->end += io_virt_offset;
+}
+
+
+static int get_bus_io_range(struct pci_bus *bus, unsigned long *start_phys,
+				unsigned long *start_virt, unsigned long *size)
+{
+	struct pci_controller *hose = PCI_GET_PHB_PTR(bus);
+	struct pci_bus_region region;
+	struct resource *res;
+
+	if (bus->self) {
+		res = bus->resource[0];
+		pcibios_resource_to_bus(bus->self, &region, res);
+		*start_phys = hose->io_base_phys + region.start;
+		*start_virt = (unsigned long) hose->io_base_virt + 
+				region.start;
+		if (region.end > region.start) 
+			*size = region.end - region.start + 1;
+		else {
+			printk("%s(): unexpected region 0x%lx->0x%lx\n", 
+					__FUNCTION__, region.start, region.end);
+			return 1;
+		}
+		
+	} else {
+		/* Root Bus */
+		res = &hose->io_resource;
+		*start_phys = hose->io_base_phys;
+		*start_virt = (unsigned long) hose->io_base_virt;
+		if (res->end > res->start)
+			*size = res->end - res->start + 1;
+		else {
+			printk("%s(): unexpected region 0x%lx->0x%lx\n", 
+					__FUNCTION__, res->start, res->end);
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
+int unmap_bus_range(struct pci_bus *bus)
+{
+	unsigned long start_phys;
+	unsigned long start_virt;
+	unsigned long size;
+
+	if (!bus) {
+		printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
+		return 1;
+	}
+	
+	if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
+		return 1;
+	if (iounmap_explicit((void __iomem *) start_virt, size))
+		return 1;
+
+	return 0;
+}
+EXPORT_SYMBOL(unmap_bus_range);
+
+int remap_bus_range(struct pci_bus *bus)
+{
+	unsigned long start_phys;
+	unsigned long start_virt;
+	unsigned long size;
+
+	if (!bus) {
+		printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
+		return 1;
+	}
+	
+	
+	if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
+		return 1;
+	printk("mapping IO %lx -> %lx, size: %lx\n", start_phys, start_virt, size);
+	if (__ioremap_explicit(start_phys, start_virt, size, _PAGE_NO_CACHE))
+		return 1;
+
+	return 0;
+}
+EXPORT_SYMBOL(remap_bus_range);
+
+void phbs_remap_io(void)
+{
+	struct pci_controller *hose, *tmp;
+
+	list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
+		remap_bus_range(hose->bus);
+}
+
+
+/*
  * This function finds the PHB that matching device_node in the 
  * OpenFirmware by scanning all the pci_controllers.
- * 
- ***********************************************************************/
+ */
 struct pci_controller* pci_find_hose_for_OF_device(struct device_node *node)
 {
 	while (node) {
@@ -700,6 +758,9 @@
        else
                busdn = bus->sysdata;   /* must be a phb */
 
+       if (busdn == NULL)
+	       return 0;
+
        /*
         * Check to see if there is any of the 8 functions are in the
         * device tree.  If they are then we need to scan all the
@@ -722,7 +783,8 @@
 
 	for (i = 0; i < PCI_NUM_RESOURCES; i++) {
 		if (dev->resource[i].flags & IORESOURCE_IO) {
-			unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base;
+			unsigned long offset = (unsigned long)hose->io_base_virt
+				- pci_io_base;
                         unsigned long start, end, mask;
 
                         start = dev->resource[i].start += offset;
@@ -753,9 +815,6 @@
 void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 {
 	struct pci_controller *hose = PCI_GET_PHB_PTR(bus);
-	struct list_head *ln;
-
-	/* XXX or bus->parent? */
 	struct pci_dev *dev = bus->self;
 	struct resource *res;
 	int i;
@@ -765,18 +824,13 @@
 
 		hose->bus = bus;
 		bus->resource[0] = res = &hose->io_resource;
-		if (!res->flags)
-			BUG();	/* No I/O resource for this PHB? */
 
-		if (request_resource(&ioport_resource, res))
+		if (res->flags && request_resource(&ioport_resource, res))
 			printk(KERN_ERR "Failed to request IO on "
 					"PCI domain %d\n", pci_domain_nr(bus));
 
-
 		for (i = 0; i < 3; ++i) {
 			res = &hose->mem_resources[i];
-			if (!res->flags && i == 0)
-				BUG();	/* No memory resource for this PHB? */
 			bus->resource[i+1] = res;
 			if (res->flags && request_resource(&iomem_resource, res))
 				printk(KERN_ERR "Failed to request MEM on "
@@ -791,56 +845,41 @@
 		pcibios_fixup_device_resources(dev, bus);
 	}
 
-	/* XXX Need to check why Alpha doesnt do this - Anton */
 	if (!pci_probe_only)
 		return;
 
-	for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
-		struct pci_dev *dev = pci_dev_b(ln);
+	list_for_each_entry(dev, &bus->devices, bus_list) {
 		if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
 			pcibios_fixup_device_resources(dev, bus);
 	}
 }
 EXPORT_SYMBOL(pcibios_fixup_bus);
 
-/******************************************************************
- * pci_read_irq_line
- *
- * Reads the Interrupt Pin to determine if interrupt is use by card.
+/*
+ * Reads the interrupt pin to determine if interrupt is use by card.
  * If the interrupt is used, then gets the interrupt line from the 
  * openfirmware and sets it in the pci_dev and pci_config line.
- *
- ******************************************************************/
+ */
 int pci_read_irq_line(struct pci_dev *pci_dev)
 {
 	u8 intpin;
 	struct device_node *node;
 
     	pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &intpin);
-
-	if (intpin == 0) {
-		PPCDBG(PPCDBG_BUSWALK,"\tDevice: %s No Interrupt used by device.\n",
-		       pci_name(pci_dev));
-		return 0;	
-	}
+	if (intpin == 0)
+		return 0;
 
 	node = pci_device_to_OF_node(pci_dev);
-	if (node == NULL) { 
-		PPCDBG(PPCDBG_BUSWALK,"\tDevice: %s Device Node not found.\n",
-		       pci_name(pci_dev));
-		return -1;	
-	}
-	if (node->n_intrs == 0) 	{
-		PPCDBG(PPCDBG_BUSWALK,"\tDevice: %s No Device OF interrupts defined.\n",
-		       pci_name(pci_dev));
-		return -1;	
-	}
+	if (node == NULL)
+		return -1;
+
+	if (node->n_intrs == 0)
+		return -1;
+
 	pci_dev->irq = node->intrs[0].line;
 
 	pci_write_config_byte(pci_dev, PCI_INTERRUPT_LINE, pci_dev->irq);
-	
-	PPCDBG(PPCDBG_BUSWALK,"\tDevice: %s pci_dev->irq = 0x%02X\n",
-	       pci_name(pci_dev), pci_dev->irq);
+
 	return 0;
 }
 EXPORT_SYMBOL(pci_read_irq_line);
diff -Nru a/arch/ppc64/kernel/pci.h b/arch/ppc64/kernel/pci.h
--- a/arch/ppc64/kernel/pci.h	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc64/kernel/pci.h	2004-12-24 13:36:16 -08:00
@@ -14,28 +14,28 @@
 
 extern unsigned long isa_io_base;
 
-extern struct pci_controller* pci_alloc_pci_controller(enum phb_types controller_type);
+extern void pci_setup_pci_controller(struct pci_controller *hose);
+extern void pci_setup_phb_io(struct pci_controller *hose, int primary);
+
 extern struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node);
+extern void pci_setup_phb_io_dynamic(struct pci_controller *hose);
+
 
 extern struct list_head hose_list;
 extern int global_phb_number;
 
-/*******************************************************************
- * Platform functions that are brand specific implementation. 
- *******************************************************************/
 extern unsigned long find_and_init_phbs(void);
 
 extern struct pci_dev *ppc64_isabridge_dev;	/* may be NULL if no ISA bus */
 
-/*******************************************************************
- * PCI device_node operations
- *******************************************************************/
+/* PCI device_node operations */
 struct device_node;
 typedef void *(*traverse_func)(struct device_node *me, void *data);
 void *traverse_pci_devices(struct device_node *start, traverse_func pre,
 		void *data);
 
 void pci_devs_phb_init(void);
+void pci_devs_phb_init_dynamic(struct pci_controller *phb);
 void pci_fix_bus_sysdata(void);
 struct device_node *fetch_dev_dn(struct pci_dev *dev);
 
@@ -49,5 +49,8 @@
 void init_pci_config_tokens (void);
 unsigned long get_phb_buid (struct device_node *);
 
+extern unsigned long pci_probe_only;
+extern unsigned long pci_assign_all_buses;
+extern int pci_read_irq_line(struct pci_dev *pci_dev);
 
 #endif /* __PPC_KERNEL_PCI_H__ */
diff -Nru a/arch/ppc64/kernel/pci_dn.c b/arch/ppc64/kernel/pci_dn.c
--- a/arch/ppc64/kernel/pci_dn.c	2004-12-24 13:37:31 -08:00
+++ b/arch/ppc64/kernel/pci_dn.c	2004-12-24 13:37:31 -08:00
@@ -42,33 +42,17 @@
  * Traverse_func that inits the PCI fields of the device node.
  * NOTE: this *must* be done before read/write config to the device.
  */
-static void * __init update_dn_pci_info(struct device_node *dn, void *data)
+static void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
 {
 	struct pci_controller *phb = data;
 	u32 *regs;
-	char *device_type = get_property(dn, "device_type", NULL);
-	char *model;
 
 	dn->phb = phb;
-	if (device_type && (strcmp(device_type, "pci") == 0) &&
-			(get_property(dn, "class-code", NULL) == 0)) {
-		/* special case for PHB's.  Sigh. */
-		regs = (u32 *)get_property(dn, "bus-range", NULL);
-		dn->busno = regs[0];
-
-		model = (char *)get_property(dn, "model", NULL);
-
-		if (strstr(model, "U3"))
-			dn->devfn = -1;
-		else
-			dn->devfn = 0;	/* assumption */
-	} else {
-		regs = (u32 *)get_property(dn, "reg", NULL);
-		if (regs) {
-			/* First register entry is addr (00BBSS00)  */
-			dn->busno = (regs[0] >> 16) & 0xff;
-			dn->devfn = (regs[0] >> 8) & 0xff;
-		}
+	regs = (u32 *)get_property(dn, "reg", NULL);
+	if (regs) {
+		/* First register entry is addr (00BBSS00)  */
+		dn->busno = (regs[0] >> 16) & 0xff;
+		dn->devfn = (regs[0] >> 8) & 0xff;
 	}
 	return NULL;
 }
@@ -97,20 +81,25 @@
 	struct device_node *dn, *nextdn;
 	void *ret;
 
-	if (pre && ((ret = pre(start, data)) != NULL))
-		return ret;
+	/* We started with a phb, iterate all childs */
 	for (dn = start->child; dn; dn = nextdn) {
+		u32 *classp, class;
+
 		nextdn = NULL;
-		if (get_property(dn, "class-code", NULL)) {
-			if (pre && ((ret = pre(dn, data)) != NULL))
-				return ret;
-			if (dn->child)
-				/* Depth first...do children */
-				nextdn = dn->child;
-			else if (dn->sibling)
-				/* ok, try next sibling instead. */
-				nextdn = dn->sibling;
-		}
+		classp = (u32 *)get_property(dn, "class-code", NULL);
+		class = classp ? *classp : 0;
+
+		if (pre && ((ret = pre(dn, data)) != NULL))
+			return ret;
+
+		/* If we are a PCI bridge, go down */
+		if (dn->child && ((class >> 8) == PCI_CLASS_BRIDGE_PCI ||
+				  (class >> 8) == PCI_CLASS_BRIDGE_CARDBUS))
+			/* Depth first...do children */
+			nextdn = dn->child;
+		else if (dn->sibling)
+			/* ok, try next sibling instead. */
+			nextdn = dn->sibling;
 		if (!nextdn) {
 			/* Walk up to next valid sibling. */
 			do {
@@ -124,21 +113,17 @@
 	return NULL;
 }
 
-/*
- * Same as traverse_pci_devices except this does it for all phbs.
- */
-static void *traverse_all_pci_devices(traverse_func pre)
+void __devinit pci_devs_phb_init_dynamic(struct pci_controller *phb)
 {
-	struct pci_controller *phb, *tmp;
-	void *ret;
+	struct device_node * dn = (struct device_node *) phb->arch_data;
 
-	list_for_each_entry_safe(phb, tmp, &hose_list, list_node)
-		if ((ret = traverse_pci_devices(phb->arch_data, pre, phb))
-				!= NULL)
-			return ret;
-	return NULL;
-}
+	/* PHB nodes themselves must not match */
+	dn->devfn = dn->busno = -1;
+	dn->phb = phb;
 
+	/* Update dn->phb ptrs for new phb and children devices */
+	traverse_pci_devices(dn, update_dn_pci_info, phb);
+}
 
 /*
  * Traversal func that looks for a <busno,devfcn> value.
@@ -148,6 +133,7 @@
 {
 	int busno = ((unsigned long)data >> 8) & 0xff;
 	int devfn = ((unsigned long)data) & 0xff;
+
 	return ((devfn == dn->devfn) && (busno == dn->busno)) ? dn : NULL;
 }
 
@@ -174,10 +160,8 @@
 
 	phb_dn = phb->arch_data;
 	dn = traverse_pci_devices(phb_dn, is_devfn_node, (void *)searchval);
-	if (dn) {
+	if (dn)
 		dev->sysdata = dn;
-		/* ToDo: call some device init hook here */
-	}
 	return dn;
 }
 EXPORT_SYMBOL(fetch_dev_dn);
@@ -189,18 +173,19 @@
  */
 void __init pci_devs_phb_init(void)
 {
+	struct pci_controller *phb, *tmp;
+
 	/* This must be done first so the device nodes have valid pci info! */
-	traverse_all_pci_devices(update_dn_pci_info);
+	list_for_each_entry_safe(phb, tmp, &hose_list, list_node)
+		pci_devs_phb_init_dynamic(phb);
 }
 
 
 static void __init pci_fixup_bus_sysdata_list(struct list_head *bus_list)
 {
-	struct list_head *ln;
 	struct pci_bus *bus;
 
-	for (ln = bus_list->next; ln != bus_list; ln = ln->next) {
-		bus = pci_bus_b(ln);
+	list_for_each_entry(bus, bus_list, node) {
 		if (bus->self)
 			bus->sysdata = bus->self->sysdata;
 		pci_fixup_bus_sysdata_list(&bus->children);
diff -Nru a/arch/ppc64/kernel/pci_iommu.c b/arch/ppc64/kernel/pci_iommu.c
--- a/arch/ppc64/kernel/pci_iommu.c	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc64/kernel/pci_iommu.c	2004-12-24 13:37:01 -08:00
@@ -43,6 +43,13 @@
 #include <asm/iSeries/iSeries_pci.h>
 #endif /* CONFIG_PPC_ISERIES */
 
+/*
+ * We can use ->sysdata directly and avoid the extra work in
+ * pci_device_to_OF_node since ->sysdata will have been initialised
+ * in the iommu init code for all devices.
+ */
+#define PCI_GET_DN(dev) ((struct device_node *)((dev)->sysdata))
+
 static inline struct iommu_table *devnode_table(struct pci_dev *dev)
 {
 	if (!dev)
diff -Nru a/arch/ppc64/kernel/pmac.h b/arch/ppc64/kernel/pmac.h
--- a/arch/ppc64/kernel/pmac.h	2004-12-24 13:36:49 -08:00
+++ b/arch/ppc64/kernel/pmac.h	2004-12-24 13:36:49 -08:00
@@ -18,7 +18,6 @@
 extern void pmac_pcibios_fixup(void);
 extern void pmac_pci_init(void);
 extern void pmac_setup_pci_dma(void);
-extern void fixup_k2_sata(struct pci_dev* dev);
 extern void pmac_check_ht_link(void);
 
 extern void pmac_setup_smp(void);
diff -Nru a/arch/ppc64/kernel/pmac_low_i2c.c b/arch/ppc64/kernel/pmac_low_i2c.c
--- a/arch/ppc64/kernel/pmac_low_i2c.c	2004-12-24 13:36:47 -08:00
+++ b/arch/ppc64/kernel/pmac_low_i2c.c	2004-12-24 13:36:47 -08:00
@@ -16,9 +16,10 @@
  *  properties parser
  */
 
+#undef DEBUG
+
 #include <linux/config.h>
 #include <linux/types.h>
-#include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/module.h>
@@ -33,12 +34,12 @@
 
 #define MAX_LOW_I2C_HOST	4
 
-#if 1
+#ifdef DEBUG
 #define DBG(x...) do {\
 		printk(KERN_DEBUG "KW:" x);	\
 	} while(0)
 #else
-#define DBGG(x...)
+#define DBG(x...)
 #endif
 
 struct low_i2c_host;
@@ -50,11 +51,11 @@
 	struct device_node	*np;		/* OF device node */
 	struct semaphore	mutex;		/* Access mutex for use by i2c-keywest */
 	low_i2c_func_t		func;		/* Access function */
-	unsigned		is_open : 1;	/* Poor man's access control */
+	unsigned int		is_open : 1;	/* Poor man's access control */
 	int			mode;		/* Current mode */
 	int			channel;	/* Current channel */
 	int			num_channels;	/* Number of channels */
-	unsigned long		base;		/* For keywest-i2c, base address */
+	void __iomem		*base;		/* For keywest-i2c, base address */
 	int			bsteps;		/* And register stepping */
 	int			speed;		/* And speed */
 };
@@ -154,14 +155,12 @@
 
 static inline u8 __kw_read_reg(struct low_i2c_host *host, reg_t reg)
 {
-	return in_8(((volatile u8 *)host->base)
-		+ (((unsigned)reg) << host->bsteps));
+	return readb(host->base + (((unsigned int)reg) << host->bsteps));
 }
 
 static inline void __kw_write_reg(struct low_i2c_host *host, reg_t reg, u8 val)
 {
-	out_8(((volatile u8 *)host->base)
-		+ (((unsigned)reg) << host->bsteps), val);
+	writeb(val, host->base + (((unsigned)reg) << host->bsteps));
 	(void)__kw_read_reg(host, reg_subaddr);
 }
 
@@ -174,14 +173,19 @@
  */
 static u8 kw_wait_interrupt(struct low_i2c_host* host)
 {
-	int i;
+	int i, j;
 	u8 isr;
 	
-	for (i = 0; i < 200000; i++) {
+	for (i = 0; i < 100000; i++) {
 		isr = kw_read_reg(reg_isr) & KW_I2C_IRQ_MASK;
 		if (isr != 0)
 			return isr;
-		udelay(1);
+
+		/* This code is used with the timebase frozen, we cannot rely
+		 * on udelay ! For now, just use a bogus loop
+		 */
+		for (j = 1; j < 10000; j++)
+			mb();
 	}
 	return isr;
 }
@@ -190,6 +194,8 @@
 {
 	u8 ack;
 
+	DBG("kw_handle_interrupt(%s, isr: %x)\n", __kw_state_names[state], isr);
+
 	if (isr == 0) {
 		if (state != state_stop) {
 			DBG("KW: Timeout !\n");
@@ -301,11 +307,9 @@
 		break;
 	case pmac_low_i2c_mode_stdsub:
 		mode_reg |= KW_I2C_MODE_STANDARDSUB;
-		kw_write_reg(reg_subaddr, subaddr);
 		break;
 	case pmac_low_i2c_mode_combined:
 		mode_reg |= KW_I2C_MODE_COMBINED;
-		kw_write_reg(reg_subaddr, subaddr);
 		break;
 	}
 
@@ -317,6 +321,11 @@
 	/* Set up address and r/w bit */
 	kw_write_reg(reg_addr, addr);
 
+	/* Set up the sub address */
+	if ((mode_reg & KW_I2C_MODE_MODE_MASK) == KW_I2C_MODE_STANDARDSUB
+	    || (mode_reg & KW_I2C_MODE_MODE_MASK) == KW_I2C_MODE_COMBINED)
+		kw_write_reg(reg_subaddr, subaddr);
+
 	/* Start sending address & disable interrupt*/
 	kw_write_reg(reg_ier, 0 /*KW_I2C_IRQ_MASK*/);
 	kw_write_reg(reg_control, KW_I2C_CTL_XADDR);
@@ -333,7 +342,7 @@
 static void keywest_low_i2c_add(struct device_node *np)
 {
 	struct low_i2c_host	*host = find_low_i2c_host(NULL);
-	unsigned long		*psteps, *prate, steps, aoffset = 0;
+	u32			*psteps, *prate, steps, aoffset = 0;
 	struct device_node	*parent;
 
 	if (host == NULL) {
@@ -345,7 +354,7 @@
 
 	init_MUTEX(&host->mutex);
 	host->np = of_node_get(np);	
-	psteps = (unsigned long *)get_property(np, "AAPL,address-step", NULL);
+	psteps = (u32 *)get_property(np, "AAPL,address-step", NULL);
 	steps = psteps ? (*psteps) : 0x10;
 	for (host->bsteps = 0; (steps & 0x01) == 0; host->bsteps++)
 		steps >>= 1;
@@ -357,7 +366,7 @@
 	}
 	/* Select interface rate */
 	host->speed = KW_I2C_MODE_100KHZ;
-	prate = (unsigned long *)get_property(np, "AAPL,i2c-rate", NULL);
+	prate = (u32 *)get_property(np, "AAPL,i2c-rate", NULL);
 	if (prate) switch(*prate) {
 	case 100:
 		host->speed = KW_I2C_MODE_100KHZ;
@@ -369,8 +378,9 @@
 		host->speed = KW_I2C_MODE_25KHZ;
 		break;
 	}	
+
 	host->mode = pmac_low_i2c_mode_std;
-	host->base = (unsigned long)ioremap(np->addrs[0].address + aoffset,
+	host->base = ioremap(np->addrs[0].address + aoffset,
 						np->addrs[0].size);
 	host->func = keywest_low_i2c_func;
 }
diff -Nru a/arch/ppc64/kernel/pmac_pci.c b/arch/ppc64/kernel/pmac_pci.c
--- a/arch/ppc64/kernel/pmac_pci.c	2004-12-24 13:37:01 -08:00
+++ b/arch/ppc64/kernel/pmac_pci.c	2004-12-24 13:37:01 -08:00
@@ -39,14 +39,10 @@
 #define DBG(x...)
 #endif
 
-extern int pci_probe_only;
-extern int pci_read_irq_line(struct pci_dev *pci_dev);
-
 /* XXX Could be per-controller, but I don't think we risk anything by
  * assuming we won't have both UniNorth and Bandit */
 static int has_uninorth;
 static struct pci_controller *u3_agp;
-u8 pci_cache_line_size;
 struct pci_dev *k2_skiplist[2];
 
 static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
@@ -150,16 +146,9 @@
 				      int offset, int len, u32 *val)
 {
 	struct pci_controller *hose;
-	struct device_node *busdn;
 	unsigned long addr;
 
-	if (bus->self)
-		busdn = pci_device_to_OF_node(bus->self);
-	else
-		busdn = bus->sysdata;	/* must be a phb */
-	if (busdn == NULL)
-		return PCIBIOS_DEVICE_NOT_FOUND;
-	hose = busdn->phb;
+	hose = pci_bus_to_host(bus);
 	if (hose == NULL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
@@ -188,16 +177,9 @@
 				       int offset, int len, u32 val)
 {
 	struct pci_controller *hose;
-	struct device_node *busdn;
 	unsigned long addr;
 
-	if (bus->self)
-		busdn = pci_device_to_OF_node(bus->self);
-	else
-		busdn = bus->sysdata;	/* must be a phb */
-	if (busdn == NULL)
-		return PCIBIOS_DEVICE_NOT_FOUND;
-	hose = busdn->phb;
+	hose = pci_bus_to_host(bus);
 	if (hose == NULL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
@@ -236,14 +218,44 @@
  * implement self-view of the HT host yet
  */
 
-static int skip_k2_device(struct pci_bus *bus, unsigned int devfn)
+/*
+ * This function deals with some "special cases" devices.
+ *
+ *  0 -> No special case
+ *  1 -> Skip the device but act as if the access was successfull
+ *       (return 0xff's on reads, eventually, cache config space
+ *       accesses in a later version)
+ * -1 -> Hide the device (unsuccessful acess)
+ */
+static int u3_ht_skip_device(struct pci_controller *hose,
+			     struct pci_bus *bus, unsigned int devfn)
 {
+	struct device_node *busdn, *dn;
 	int i;
 
+	/*
+	 * When a device in K2 is powered down, we die on config
+	 * cycle accesses. Fix that here.
+	 */
 	for (i=0; i<2; i++)
 		if (k2_skiplist[i] && k2_skiplist[i]->bus == bus &&
 		    k2_skiplist[i]->devfn == devfn)
 			return 1;
+
+	/* We only allow config cycles to devices that are in OF device-tree
+	 * as we are apparently having some weird things going on with some
+	 * revs of K2 on recent G5s
+	 */
+	if (bus->self)
+		busdn = pci_device_to_OF_node(bus->self);
+	else
+		busdn = hose->arch_data;
+	for (dn = busdn->child; dn; dn = dn->sibling)
+		if (dn->devfn == devfn)
+			break;
+	if (dn == NULL)
+		return -1;
+
 	return 0;
 }
 
@@ -259,8 +271,7 @@
 {
 	if (bus == hose->first_busno) {
 		/* For now, we don't self probe U3 HT bridge */
-		if (PCI_FUNC(devfn) != 0 || PCI_SLOT(devfn) > 7 ||
-		    PCI_SLOT(devfn) < 1)
+		if (PCI_SLOT(devfn) == 0)
 			return 0;
 		return ((unsigned long)hose->cfg_data) + U3_HT_CFA0(devfn, offset);
 	} else
@@ -271,39 +282,21 @@
 				    int offset, int len, u32 *val)
 {
 	struct pci_controller *hose;
-	struct device_node *busdn, *dn;
 	unsigned long addr;
 
-	if (bus->self)
-		busdn = pci_device_to_OF_node(bus->self);
-	else
-		busdn = bus->sysdata;	/* must be a phb */
-	if (busdn == NULL)
-		return PCIBIOS_DEVICE_NOT_FOUND;
-	hose = busdn->phb;
-	if (hose == NULL)
-		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	/* We only allow config cycles to devices that are in OF device-tree
-	 * as we are apparently having some weird things going on with some
-	 * revs of K2 on recent G5s
-	 */
-	for (dn = busdn->child; dn; dn = dn->sibling)
-		if (dn->devfn == devfn)
-			break;
-	if (dn == NULL)
+	hose = pci_bus_to_host(bus);      
+	if (hose == NULL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
 	addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
 	if (!addr)
 		return PCIBIOS_DEVICE_NOT_FOUND;
-	/*
-	 * When a device in K2 is powered down, we die on config
-	 * cycle accesses. Fix that here. We may ultimately want
-	 * to cache the config space for those instead of returning
-	 * 0xffffffff's to make life easier to HW detection tools
-	 */
-	if (skip_k2_device(bus, devfn)) {
+
+	switch (u3_ht_skip_device(hose, bus, devfn)) {
+	case 0:
+		break;
+	case 1:
 		switch (len) {
 		case 1:
 			*val = 0xff; break;
@@ -313,6 +306,8 @@
 			*val = 0xfffffffful; break;
 		}
 		return PCIBIOS_SUCCESSFUL;
+	default:
+		return PCIBIOS_DEVICE_NOT_FOUND;
 	}
 
 	/*
@@ -337,28 +332,24 @@
 				     int offset, int len, u32 val)
 {
 	struct pci_controller *hose;
-	struct device_node *busdn;
 	unsigned long addr;
 
-	if (bus->self)
-		busdn = pci_device_to_OF_node(bus->self);
-	else
-		busdn = bus->sysdata;	/* must be a phb */
-	if (busdn == NULL)
-		return PCIBIOS_DEVICE_NOT_FOUND;
-	hose = busdn->phb;
+	hose = pci_bus_to_host(bus);
 	if (hose == NULL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
 	addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
 	if (!addr)
 		return PCIBIOS_DEVICE_NOT_FOUND;
-	/*
-	 * When a device in K2 is powered down, we die on config
-	 * cycle accesses. Fix that here.
-	 */
-	if (skip_k2_device(bus, devfn))
+
+	switch (u3_ht_skip_device(hose, bus, devfn)) {
+	case 0:
+		break;
+	case 1:
 		return PCIBIOS_SUCCESSFUL;
+	default:
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	}
 
 	/*
 	 * Note: the caller has already checked that offset is
@@ -513,7 +504,7 @@
 	dt_ranges = (unsigned int *) get_property(dev, "ranges", &rlen);
 	if (!dt_ranges)
 		return;
-	/*	lc_ranges = (unsigned int *) alloc_bootmem(rlen);*/
+	/*	lc_ranges = alloc_bootmem(rlen);*/
 	lc_ranges = static_lc_ranges;
 	if (!lc_ranges)
 		return; /* what can we do here ? */
@@ -623,15 +614,17 @@
        			       dev->full_name);
        	}
 
-       	hose = pci_alloc_pci_controller(phb_type_apple);
-       	if (!hose)
-       		return -ENOMEM;
+	hose = alloc_bootmem(sizeof(struct pci_controller));
+	if (hose == NULL)
+		return -ENOMEM;
+       	pci_setup_pci_controller(hose);
+
        	hose->arch_data = dev;
        	hose->first_busno = bus_range ? bus_range[0] : 0;
        	hose->last_busno = bus_range ? bus_range[1] : 0xff;
 
-	of_prop = (struct property *)alloc_bootmem(sizeof(struct property) +
-			sizeof(hose->global_number));        
+	of_prop = alloc_bootmem(sizeof(struct property) +
+				sizeof(hose->global_number));
 	if (of_prop) {
 		memset(of_prop, 0, sizeof(struct property));
 		of_prop->name = "linux,pci-domain";
@@ -669,13 +662,12 @@
 {
 	struct pci_dev *dev = NULL;
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
+	for_each_pci_dev(dev)
 		pci_read_irq_line(dev);
 
 	pci_fix_bus_sysdata();
 
 	iommu_setup_u3();
-
 }
 
 static void __init pmac_fixup_phb_resources(void)
@@ -747,14 +739,9 @@
 
 	pmac_check_ht_link();
 
-	/* Tell pci.c to use the common resource allocation mecanism */
-	pci_probe_only = 0;
+	/* Tell pci.c to not use the common resource allocation mecanism */
+	pci_probe_only = 1;
 	
-	/* HT don't do more than 64 bytes transfers. FIXME: Deal with
-	 * the exception of U3/AGP (hook into pci_set_mwi)
-	 */
-	pci_cache_line_size = 16; /* 64 bytes */
-
 	/* Allow all IO */
 	io_page_mask = -1;
 }
@@ -763,7 +750,7 @@
  * Disable second function on K2-SATA, it's broken
  * and disable IO BARs on first one
  */
-void fixup_k2_sata(struct pci_dev* dev)
+static void fixup_k2_sata(struct pci_dev* dev)
 {
 	int i;
 	u16 cmd;
diff -Nru a/arch/ppc64/kernel/pmac_setup.c b/arch/ppc64/kernel/pmac_setup.c
--- a/arch/ppc64/kernel/pmac_setup.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/kernel/pmac_setup.c	2004-12-24 13:36:18 -08:00
@@ -53,13 +53,12 @@
 #include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
+#include <linux/bitops.h>
 
 #include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/pci-bridge.h>
 #include <asm/iommu.h>
@@ -73,6 +72,7 @@
 #include <asm/lmb.h>
 
 #include "pmac.h"
+#include "mpic.h"
 
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
@@ -320,29 +320,9 @@
 	DBG(" <- pmac_init_early\n");
 }
 
-extern void* OpenPIC_Addr;
-extern void* OpenPIC2_Addr;
-extern u_int OpenPIC_NumInitSenses;
-extern u_char *OpenPIC_InitSenses;
-extern void openpic_init(int main_pic, int offset, unsigned char* chrp_ack,
-			 int programmer_switch_irq);
-extern void openpic2_init(int offset);
-extern int openpic_get_irq(struct pt_regs *regs);
-extern int openpic2_get_irq(struct pt_regs *regs);
-
-static int pmac_cascade_irq = -1;
-
-static irqreturn_t pmac_u3_do_cascade(int cpl, void *dev_id, struct pt_regs *regs)
-{
-	int irq;
-
-	for (;;) {
-		irq = openpic2_get_irq(regs);
-		if (irq == -1)
-			break;
-		ppc_irq_dispatch_handler(regs, irq);
-	}
-	return IRQ_HANDLED;
+static int pmac_u3_cascade(struct pt_regs *regs, void *data)
+{
+	return mpic_get_one_irq((struct mpic *)data, regs);
 }
 
 static __init void pmac_init_IRQ(void)
@@ -350,6 +330,7 @@
         struct device_node *irqctrler  = NULL;
         struct device_node *irqctrler2 = NULL;
 	struct device_node *np = NULL;
+	struct mpic *mpic1, *mpic2;
 
 	/* We first try to detect Apple's new Core99 chipset, since mac-io
 	 * is quite different on those machines and contains an IBM MPIC2.
@@ -369,44 +350,37 @@
 		       (unsigned int)irqctrler->addrs[0].address);
 
 		prom_get_irq_senses(senses, 0, 128);
-		OpenPIC_InitSenses = senses;
-		OpenPIC_NumInitSenses = 128;
-		OpenPIC_Addr = ioremap(irqctrler->addrs[0].address,
-				       irqctrler->addrs[0].size);
-		openpic_init(1, 0, NULL, -1);
+		mpic1 = mpic_alloc(irqctrler->addrs[0].address,
+				   MPIC_PRIMARY | MPIC_WANTS_RESET,
+				   0, 0, 128, 256, senses, 128, " K2-MPIC  ");
+		BUG_ON(mpic1 == NULL);
+		mpic_init(mpic1);		
 
 		if (irqctrler2 != NULL && irqctrler2->n_intrs > 0 &&
 		    irqctrler2->n_addrs > 0) {
 			printk(KERN_INFO "Slave OpenPIC at 0x%08x hooked on IRQ %d\n",
 			       (u32)irqctrler2->addrs[0].address,
 			       irqctrler2->intrs[0].line);
+
 			pmac_call_feature(PMAC_FTR_ENABLE_MPIC, irqctrler2, 0, 0);
-			OpenPIC2_Addr = ioremap(irqctrler2->addrs[0].address,
-						irqctrler2->addrs[0].size);
 			prom_get_irq_senses(senses, 128, 128 + 128);
-			OpenPIC_InitSenses = senses;
-			OpenPIC_NumInitSenses = 128;
-			openpic2_init(128);
-			pmac_cascade_irq = irqctrler2->intrs[0].line;
+
+			/* We don't need to set MPIC_BROKEN_U3 here since we don't have
+			 * hypertransport interrupts routed to it
+			 */
+			mpic2 = mpic_alloc(irqctrler2->addrs[0].address,
+					   MPIC_BIG_ENDIAN | MPIC_WANTS_RESET,
+					   0, 128, 128, 0, senses, 128, " U3-MPIC  ");
+			BUG_ON(mpic2 == NULL);
+			mpic_init(mpic2);
+			mpic_setup_cascade(irqctrler2->intrs[0].line,
+					   pmac_u3_cascade, mpic2);
 		}
 	}
 	of_node_put(irqctrler);
 	of_node_put(irqctrler2);
 }
 
-/* We cannot do request_irq too early ... Right now, we get the
- * cascade as a core_initcall, which should be fine for our needs
- */
-static int __init pmac_irq_cascade_init(void)
-{
-	if (request_irq(pmac_cascade_irq, pmac_u3_do_cascade, 0,
-			"U3->K2 Cascade", NULL))
-		printk(KERN_ERR "Unable to get OpenPIC IRQ for cascade\n");
-	return 0;
-}
-
-core_initcall(pmac_irq_cascade_init);
-
 static void __init pmac_progress(char *s, unsigned short hex)
 {
 	if (sccdbg) {
@@ -421,6 +395,15 @@
 #endif /* CONFIG_BOOTX_TEXT */
 }
 
+/*
+ * pmac has no legacy IO, anything calling this function has to
+ * fail or bad things will happen
+ */
+static int pmac_check_legacy_ioport(unsigned int baseport)
+{
+	return -ENODEV;
+}
+
 static int __init pmac_declare_of_platform_devices(void)
 {
 	struct device_node *np;
@@ -464,7 +447,7 @@
 	.init_early		= pmac_init_early,
        	.get_cpuinfo		= pmac_show_cpuinfo,
 	.init_IRQ		= pmac_init_IRQ,
-	.get_irq		= openpic_get_irq,
+	.get_irq		= mpic_get_irq,
 	.pcibios_fixup		= pmac_pcibios_fixup,
 	.restart		= pmac_restart,
 	.power_off		= pmac_power_off,
@@ -475,4 +458,5 @@
       	.calibrate_decr		= pmac_calibrate_decr,
 	.feature_call		= pmac_do_feature_call,
 	.progress		= pmac_progress,
+	.check_legacy_ioport	= pmac_check_legacy_ioport
 };
diff -Nru a/arch/ppc64/kernel/pmac_smp.c b/arch/ppc64/kernel/pmac_smp.c
--- a/arch/ppc64/kernel/pmac_smp.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc64/kernel/pmac_smp.c	2004-12-24 13:36:17 -08:00
@@ -21,6 +21,9 @@
  *  as published by the Free Software Foundation; either version
  *  2 of the License, or (at your option) any later version.
  */
+
+#undef DEBUG
+
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -28,10 +31,10 @@
 #include <linux/smp_lock.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
-#include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/errno.h>
+#include <linux/irq.h>
 
 #include <asm/ptrace.h>
 #include <asm/atomic.h>
@@ -47,42 +50,180 @@
 #include <asm/time.h>
 #include <asm/cacheflush.h>
 #include <asm/keylargo.h>
+#include <asm/pmac_low_i2c.h>
+
+#include "mpic.h"
 
-#include "open_pic.h"
+#ifdef DEBUG
+#define DBG(fmt...) udbg_printf(fmt)
+#else
+#define DBG(fmt...)
+#endif
 
 extern void pmac_secondary_start_1(void);
 extern void pmac_secondary_start_2(void);
 extern void pmac_secondary_start_3(void);
 
-extern void smp_openpic_message_pass(int target, int msg);
-
 extern struct smp_ops_t *smp_ops;
 
+static void (*pmac_tb_freeze)(int freeze);
+static struct device_node *pmac_tb_clock_chip_host;
+static spinlock_t timebase_lock = SPIN_LOCK_UNLOCKED;
+static unsigned long timebase;
+
+static void smp_core99_cypress_tb_freeze(int freeze)
+{
+	u8 data;
+	int rc;
+
+	/* Strangely, the device-tree says address is 0xd2, but darwin
+	 * accesses 0xd0 ...
+	 */
+	pmac_low_i2c_setmode(pmac_tb_clock_chip_host, pmac_low_i2c_mode_combined);
+	rc = pmac_low_i2c_xfer(pmac_tb_clock_chip_host,
+			       0xd0 | pmac_low_i2c_read,
+			       0x81, &data, 1);
+	if (rc != 0)
+		goto bail;
+
+	data = (data & 0xf3) | (freeze ? 0x00 : 0x0c);
+
+       	pmac_low_i2c_setmode(pmac_tb_clock_chip_host, pmac_low_i2c_mode_stdsub);
+	rc = pmac_low_i2c_xfer(pmac_tb_clock_chip_host,
+			       0xd0 | pmac_low_i2c_write,
+			       0x81, &data, 1);
+
+ bail:
+	if (rc != 0) {
+		printk("Cypress Timebase %s rc: %d\n",
+		       freeze ? "freeze" : "unfreeze", rc);
+		panic("Timebase freeze failed !\n");
+	}
+}
+
+static void smp_core99_pulsar_tb_freeze(int freeze)
+{
+	u8 data;
+	int rc;
+
+	/* Strangely, the device-tree says address is 0xd2, but darwin
+	 * accesses 0xd0 ...
+	 */
+	pmac_low_i2c_setmode(pmac_tb_clock_chip_host, pmac_low_i2c_mode_combined);
+	rc = pmac_low_i2c_xfer(pmac_tb_clock_chip_host,
+			       0xd4 | pmac_low_i2c_read,
+			       0x2e, &data, 1);
+	if (rc != 0)
+		goto bail;
+
+	data = (data & 0x88) | (freeze ? 0x11 : 0x22);
+
+	pmac_low_i2c_setmode(pmac_tb_clock_chip_host, pmac_low_i2c_mode_stdsub);
+	rc = pmac_low_i2c_xfer(pmac_tb_clock_chip_host,
+			       0xd4 | pmac_low_i2c_write,
+			       0x2e, &data, 1);
+ bail:
+	if (rc != 0) {
+		printk(KERN_ERR "Pulsar Timebase %s rc: %d\n",
+		       freeze ? "freeze" : "unfreeze", rc);
+		panic("Timebase freeze failed !\n");
+	}
+}
+
+
+static void smp_core99_give_timebase(void)
+{
+	/* Open i2c bus for synchronous access */
+	if (pmac_low_i2c_open(pmac_tb_clock_chip_host, 0))
+		panic("Can't open i2c for TB sync !\n");
+
+	spin_lock(&timebase_lock);
+	(*pmac_tb_freeze)(1);
+	mb();
+	timebase = get_tb();
+	spin_unlock(&timebase_lock);
+
+	while (timebase)
+		barrier();
+
+	spin_lock(&timebase_lock);
+	(*pmac_tb_freeze)(0);
+	spin_unlock(&timebase_lock);
+
+	/* Close i2c bus */
+	pmac_low_i2c_close(pmac_tb_clock_chip_host);
+}
+
+
+static void __devinit smp_core99_take_timebase(void)
+{
+	while (!timebase)
+		barrier();
+	spin_lock(&timebase_lock);
+	set_tb(timebase >> 32, timebase & 0xffffffff);
+	timebase = 0;
+	spin_unlock(&timebase_lock);
+}
+
+
 static int __init smp_core99_probe(void)
 {
-	struct device_node *cpus;
-	int ncpus = 1;
+	struct device_node *cpus;	
+	struct device_node *cc;	
+	int ncpus = 0;
 
 	/* Maybe use systemconfiguration here ? */
 	if (ppc_md.progress) ppc_md.progress("smp_core99_probe", 0x345);
-	cpus = find_type_devices("cpu");
-	if (cpus == NULL)
-		return 0;
 
-       	while ((cpus = cpus->next) != NULL)
+	/* Count CPUs in the device-tree */
+       	for (cpus = NULL; (cpus = of_find_node_by_type(cpus, "cpu")) != NULL;)
 	       	++ncpus;
 
 	printk(KERN_INFO "PowerMac SMP probe found %d cpus\n", ncpus);
 
-	if (ncpus > 1)
-		openpic_request_IPIs();
+	/* Nothing more to do if less than 2 of them */
+	if (ncpus <= 1)
+		return 1;
+
+	/* Look for the clock chip */
+	for (cc = NULL; (cc = of_find_node_by_name(cc, "i2c-hwclock")) != NULL;) {
+		struct device_node *p = of_get_parent(cc);
+		u32 *reg;
+		int ok;
+		ok = p && device_is_compatible(p, "uni-n-i2c");
+		if (!ok)
+			goto next;
+		reg = (u32 *)get_property(cc, "reg", NULL);
+		if (reg == NULL)
+			goto next;
+		switch (*reg) {
+		case 0xd2:
+			pmac_tb_freeze = smp_core99_cypress_tb_freeze;
+			printk(KERN_INFO "Timebase clock is Cypress chip\n");
+			break;
+		case 0xd4:
+			pmac_tb_freeze = smp_core99_pulsar_tb_freeze;
+			printk(KERN_INFO "Timebase clock is Pulsar chip\n");
+			break;
+		}
+		if (pmac_tb_freeze != NULL) {
+			pmac_tb_clock_chip_host = p;
+			smp_ops->give_timebase = smp_core99_give_timebase;
+			smp_ops->take_timebase = smp_core99_take_timebase;
+			break;
+		}
+	next:
+		of_node_put(p);
+	}
+
+	mpic_request_ipis();
 
 	return ncpus;
 }
 
 static void __init smp_core99_kick_cpu(int nr)
 {
-	int save_vector;
+	int save_vector, j;
 	unsigned long new_vector;
 	unsigned long flags;
 	volatile unsigned int *vector
@@ -102,15 +243,16 @@
 	 *   b .pmac_secondary_start - KERNELBASE
 	 */
 	switch(nr) {
-		case 1:
-			new_vector = (unsigned long)pmac_secondary_start_1;
-			break;
-		case 2:
-			new_vector = (unsigned long)pmac_secondary_start_2;
-			break;
-		case 3:
-			new_vector = (unsigned long)pmac_secondary_start_3;
-			break;
+	case 1:
+		new_vector = (unsigned long)pmac_secondary_start_1;
+		break;
+	case 2:
+		new_vector = (unsigned long)pmac_secondary_start_2;
+		break;			
+	case 3:
+	default:
+		new_vector = (unsigned long)pmac_secondary_start_3;
+		break;
 	}
 	*vector = 0x48000002 + (new_vector - KERNELBASE);
 
@@ -126,7 +268,8 @@
 	 * ideally, all that crap will be done in prom.c and the CPU left
 	 * in a RAM-based wait loop like CHRP.
 	 */
-	mdelay(1);
+	for (j = 1; j < 1000000; j++)
+		mb();
 
 	/* Restore our exception vector */
 	*vector = save_vector;
@@ -138,8 +281,8 @@
 
 static void __init smp_core99_setup_cpu(int cpu_nr)
 {
-	/* Setup openpic */
-	do_openpic_setup_cpu();
+	/* Setup MPIC */
+	mpic_setup_this_cpu();
 
 	if (cpu_nr == 0) {
 		extern void g5_phy_disable_cpu1(void);
@@ -149,15 +292,12 @@
 		 */
 		if (num_online_cpus() < 2)		
 			g5_phy_disable_cpu1();
-		if (ppc_md.progress) ppc_md.progress("core99_setup_cpu 0 done", 0x349);
+		if (ppc_md.progress) ppc_md.progress("smp_core99_setup_cpu 0 done", 0x349);
 	}
 }
 
-extern void smp_generic_give_timebase(void);
-extern void smp_generic_take_timebase(void);
-
 struct smp_ops_t core99_smp_ops __pmacdata = {
-	.message_pass	= smp_openpic_message_pass,
+	.message_pass	= smp_mpic_message_pass,
 	.probe		= smp_core99_probe,
 	.kick_cpu	= smp_core99_kick_cpu,
 	.setup_cpu	= smp_core99_setup_cpu,
diff -Nru a/arch/ppc64/kernel/ppc_ksyms.c b/arch/ppc64/kernel/ppc_ksyms.c
--- a/arch/ppc64/kernel/ppc_ksyms.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc64/kernel/ppc_ksyms.c	2004-12-24 13:36:31 -08:00
@@ -21,6 +21,7 @@
 #include <linux/delay.h>
 #include <linux/smp_lock.h>
 #include <linux/syscalls.h>
+#include <linux/bitops.h>
 
 #include <asm/page.h>
 #include <asm/semaphore.h>
@@ -28,7 +29,6 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/atomic.h>
-#include <asm/bitops.h>
 #include <asm/checksum.h>
 #include <asm/pgtable.h>
 #include <asm/prom.h>
diff -Nru a/arch/ppc64/kernel/proc_ppc64.c b/arch/ppc64/kernel/proc_ppc64.c
--- a/arch/ppc64/kernel/proc_ppc64.c	2004-12-24 13:37:03 -08:00
+++ b/arch/ppc64/kernel/proc_ppc64.c	2004-12-24 13:37:03 -08:00
@@ -33,7 +33,8 @@
 #include <asm/prom.h>
 
 static loff_t  page_map_seek( struct file *file, loff_t off, int whence);
-static ssize_t page_map_read( struct file *file, char *buf, size_t nbytes, loff_t *ppos);
+static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
+			      loff_t *ppos);
 static int     page_map_mmap( struct file *file, struct vm_area_struct *vma );
 
 static struct file_operations page_map_fops = {
@@ -161,7 +162,8 @@
 	return (file->f_pos = new);
 }
 
-static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
+static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
+			      loff_t *ppos)
 {
 	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
 	return simple_read_from_buffer(buf, nbytes, ppos, dp->data, dp->size);
@@ -176,7 +178,8 @@
 	if ((vma->vm_end - vma->vm_start) > dp->size)
 		return -EINVAL;
 
-	remap_page_range( vma, vma->vm_start, __pa(dp->data), dp->size, vma->vm_page_prot );
+	remap_pfn_range(vma, vma->vm_start, __pa(dp->data) >> PAGE_SHIFT,
+						dp->size, vma->vm_page_prot);
 	return 0;
 }
 
@@ -207,7 +210,8 @@
  * whole nodes along with their properties.  Operations on individual
  * properties are not implemented (yet).
  */
-static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
+static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t count,
+			  loff_t *off)
 {
 	int rv = 0;
 	char *kbuf;
@@ -301,7 +305,8 @@
 	return rv;
 }
 
-static struct property *new_property(const char *name, const int length, const unsigned char *value, struct property *last)
+static struct property *new_property(const char *name, const int length,
+				     const unsigned char *value, struct property *last)
 {
 	struct property *new = kmalloc(sizeof(*new), GFP_KERNEL);
 
@@ -342,7 +347,8 @@
  * this function does no allocation or copying of the data.  Return value
  * is set to the next name in buf, or NULL on error.
  */
-static char * parse_next_property(char *buf, char *end, char **name, int *length, unsigned char **value)
+static char * parse_next_property(char *buf, char *end, char **name, int *length,
+				  unsigned char **value)
 {
 	char *tmp;
 
@@ -350,13 +356,15 @@
 
 	tmp = strchr(buf, ' ');
 	if (!tmp) {
-		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		printk(KERN_ERR "property parse failed in %s at line %d\n",
+		       __FUNCTION__, __LINE__);
 		return NULL;
 	}
 	*tmp = '\0';
 
 	if (++tmp >= end) {
-		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		printk(KERN_ERR "property parse failed in %s at line %d\n",
+		       __FUNCTION__, __LINE__);
 		return NULL;
 	}
 
@@ -364,11 +372,13 @@
 	*length = -1;
 	*length = simple_strtoul(tmp, &tmp, 10);
 	if (*length == -1) {
-		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		printk(KERN_ERR "property parse failed in %s at line %d\n", 
+		       __FUNCTION__, __LINE__);
 		return NULL;
 	}
 	if (*tmp != ' ' || ++tmp >= end) {
-		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		printk(KERN_ERR "property parse failed in %s at line %d\n",
+		       __FUNCTION__, __LINE__);
 		return NULL;
 	}
 
@@ -376,11 +386,13 @@
 	*value = tmp;
 	tmp += *length;
 	if (tmp > end) {
-		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		printk(KERN_ERR "property parse failed in %s at line %d\n",
+		       __FUNCTION__, __LINE__);
 		return NULL;
 	}
 	else if (tmp < end && *tmp != ' ' && *tmp != '\0') {
-		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		printk(KERN_ERR "property parse failed in %s at line %d\n",
+		       __FUNCTION__, __LINE__);
 		return NULL;
 	}
 	tmp++;
diff -Nru a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c
--- a/arch/ppc64/kernel/process.c	2004-12-24 13:37:00 -08:00
+++ b/arch/ppc64/kernel/process.c	2004-12-24 13:37:00 -08:00
@@ -315,8 +315,6 @@
 	extern void ret_from_fork(void);
 	unsigned long sp = (unsigned long)p->thread_info + THREAD_SIZE;
 
-	p->set_child_tid = p->clear_child_tid = NULL;
-
 	/* Copy registers */
 	sp -= sizeof(struct pt_regs);
 	childregs = (struct pt_regs *) sp;
@@ -512,8 +510,11 @@
 	error = do_execve(filename, (char __user * __user *) a1,
 				    (char __user * __user *) a2, regs);
   
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 
 out:
diff -Nru a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c
--- a/arch/ppc64/kernel/prom.c	2004-12-24 13:37:03 -08:00
+++ b/arch/ppc64/kernel/prom.c	2004-12-24 13:37:03 -08:00
@@ -31,6 +31,7 @@
 #include <linux/stringify.h>
 #include <linux/delay.h>
 #include <linux/initrd.h>
+#include <linux/bitops.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/lmb.h>
@@ -43,7 +44,6 @@
 #include <asm/system.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
-#include <asm/bitops.h>
 #include <asm/naca.h>
 #include <asm/pci.h>
 #include <asm/iommu.h>
@@ -52,7 +52,6 @@
 #include <asm/btext.h>
 #include <asm/sections.h>
 #include <asm/machdep.h>
-#include "open_pic.h"
 
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
@@ -442,7 +441,7 @@
 	if (rp != 0 && l >= sizeof(struct isa_reg_property)) {
 		i = 0;
 		adr = (struct address_range *) mem_start;
-		while ((l -= sizeof(struct reg_property)) >= 0) {
+		while ((l -= sizeof(struct isa_reg_property)) >= 0) {
 			if (!measure_only) {
 				adr[i].space = rp[i].space;
 				adr[i].address = rp[i].address;
@@ -824,7 +823,7 @@
 			strlcpy(cmd_line, p, min(l, COMMAND_LINE_SIZE));
 	}
 #ifdef CONFIG_CMDLINE
-	if (l == 0) /* dbl check */
+	if (l == 0 || (l == 1 && (*p) == 0))
 		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
 #endif /* CONFIG_CMDLINE */
 
@@ -854,10 +853,19 @@
 		}
 	}
 
-	/* Check if it's the boot-cpu, set it's hw index in paca now */
-	if (get_flat_dt_prop(node, "linux,boot-cpu", NULL) != NULL) {
-		u32 *prop = get_flat_dt_prop(node, "reg", NULL);
-		paca[0].hw_cpu_id = prop == NULL ? 0 : *prop;
+	if (initial_boot_params && initial_boot_params->version >= 2) {
+		/* version 2 of the kexec param format adds the phys cpuid
+		 * of booted proc.
+		 */
+		boot_cpuid_phys = initial_boot_params->boot_cpuid_phys;
+		boot_cpuid = 0;
+	} else {
+		/* Check if it's the boot-cpu, set it's hw index in paca now */
+		if (get_flat_dt_prop(node, "linux,boot-cpu", NULL) != NULL) {
+			u32 *prop = get_flat_dt_prop(node, "reg", NULL);
+			set_hard_smp_processor_id(0, prop == NULL ? 0 : *prop);
+			boot_cpuid_phys = get_hard_smp_processor_id(0);
+		}
 	}
 
 	return 0;
@@ -1024,6 +1032,7 @@
 	scan_flat_dt(early_init_dt_scan_memory, NULL);
 	lmb_analyze();
 	systemcfg->physicalMemorySize = lmb_phys_mem_size();
+	lmb_reserve(0, __pa(klimit));
 
 	DBG("Phys. mem: %lx\n", systemcfg->physicalMemorySize);
 
@@ -1092,8 +1101,7 @@
  * Work out the sense (active-low level / active-high edge)
  * of each interrupt from the device tree.
  */
-void __init
-prom_get_irq_senses(unsigned char *senses, int off, int max)
+void __init prom_get_irq_senses(unsigned char *senses, int off, int max)
 {
 	struct device_node *np;
 	int i, j;
@@ -1105,7 +1113,9 @@
 		for (j = 0; j < np->n_intrs; j++) {
 			i = np->intrs[j].line;
 			if (i >= off && i < max)
-				senses[i-off] = np->intrs[j].sense;
+				senses[i-off] = np->intrs[j].sense ?
+					IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE :
+					IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE;
 		}
 	}
 }
@@ -1740,7 +1750,7 @@
 	if (strcmp(node->name, "pci") == 0 &&
 	    get_property(node, "ibm,dma-window", NULL)) {
 		node->bussubno = node->busno;
-		iommu_devnode_init(node);
+		iommu_devnode_init_pSeries(node);
 	} else
 		node->iommu_table = parent->iommu_table;
 #endif /* CONFIG_PPC_PSERIES */
@@ -1802,6 +1812,15 @@
 }
 
 /*
+ * Prepare an OF node for removal from system
+ */
+static void of_cleanup_node(struct device_node *np)
+{
+	if (np->iommu_table && get_property(np, "ibm,dma-window", NULL))
+		iommu_free_table(np);
+}
+
+/*
  * Remove an OF device node from the system.
  * Caller should have already "gotten" np.
  */
@@ -1817,6 +1836,8 @@
 		of_node_put(child);
 		return -EBUSY;
 	}
+
+	of_cleanup_node(np);
 
 	write_lock(&devtree_lock);
 	OF_MARK_STALE(np);
diff -Nru a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c
--- a/arch/ppc64/kernel/prom_init.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc64/kernel/prom_init.c	2004-12-24 13:37:19 -08:00
@@ -31,6 +31,7 @@
 #include <linux/stringify.h>
 #include <linux/delay.h>
 #include <linux/initrd.h>
+#include <linux/bitops.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/abs_addr.h>
@@ -42,7 +43,6 @@
 #include <asm/system.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
-#include <asm/bitops.h>
 #include <asm/naca.h>
 #include <asm/pci.h>
 #include <asm/iommu.h>
@@ -51,7 +51,6 @@
 #include <asm/btext.h>
 #include <asm/sections.h>
 #include <asm/machdep.h>
-#include "open_pic.h"
 
 #ifdef CONFIG_LOGO_LINUX_CLUT224
 #include <linux/linux_logo.h>
@@ -160,8 +159,6 @@
 
 extern unsigned long klimit;
 
-//int global_width = 640, global_height = 480, global_depth = 8, global_pitch;
-//unsigned global_address;
 /* prom structure */
 static struct prom_t __initdata prom;
 
@@ -675,7 +672,7 @@
 	if ( RELOC(of_platform) == PLATFORM_PSERIES_LPAR )
 		RELOC(alloc_top) = RELOC(rmo_top);
 	else
-		RELOC(alloc_top) = min(0x40000000ul, RELOC(ram_top));
+		RELOC(alloc_top) = RELOC(rmo_top) = min(0x40000000ul, RELOC(ram_top));
 	RELOC(alloc_bottom) = PAGE_ALIGN(RELOC(klimit) - offset + 0x4000);
 	RELOC(alloc_top_high) = RELOC(ram_top);
 
@@ -704,48 +701,51 @@
 {
 	unsigned long offset = reloc_offset();
 	struct prom_t *_prom = PTRRELOC(&prom);
-	phandle prom_rtas;
-	u64 base, entry = 0;
-        u32 size;
+	phandle prom_rtas, rtas_node;
+	u32 base, entry = 0;
+	u32 size = 0;
 
 	prom_debug("prom_instantiate_rtas: start...\n");
 
 	prom_rtas = call_prom("finddevice", 1, 1, ADDR("/rtas"));
-	if (prom_rtas != (phandle) -1) {
-		prom_getprop(prom_rtas, "rtas-size", &size, sizeof(size));
-		if (size != 0) {
-			base = alloc_down(size, PAGE_SIZE, 0);
-			if (base == 0) {
-				prom_printf("RTAS allocation failed !\n");
-				return;
-			}
-			prom_printf("instantiating rtas at 0x%x", base);
+	prom_debug("prom_rtas: %x\n", prom_rtas);
+	if (prom_rtas == (phandle) -1)
+		return;
 
-			prom_rtas = call_prom("open", 1, 1, ADDR("/rtas"));
-			prom_printf("...");
+	prom_getprop(prom_rtas, "rtas-size", &size, sizeof(size));
+	if (size == 0)
+		return;
 
-			if (call_prom("call-method", 3, 2,
-				      ADDR("instantiate-rtas"),
-				      prom_rtas, base) != PROM_ERROR) {
-				entry = (long)_prom->args.rets[1];
-			}
-			if (entry == 0) {
-				prom_printf(" failed\n");
-				return;
-			}
-			prom_printf(" done\n");
+	base = alloc_down(size, PAGE_SIZE, 0);
+	if (base == 0) {
+		prom_printf("RTAS allocation failed !\n");
+		return;
+	}
+	prom_printf("instantiating rtas at 0x%x", base);
 
-	       		reserve_mem(base, size);
-		}
+	rtas_node = call_prom("open", 1, 1, ADDR("/rtas"));
+	prom_printf("...");
 
-		prom_setprop(_prom->chosen, "linux,rtas-base", &base, sizeof(base));
-		prom_setprop(_prom->chosen, "linux,rtas-entry", &entry, sizeof(entry));
-		prom_setprop(_prom->chosen, "linux,rtas-size", &size, sizeof(size));
-
-		prom_debug("rtas base     = 0x%x\n", base);
-		prom_debug("rtas entry    = 0x%x\n", entry);
-		prom_debug("rtas size     = 0x%x\n", (long)size);
+	if (call_prom("call-method", 3, 2,
+		      ADDR("instantiate-rtas"),
+		      rtas_node, base) != PROM_ERROR) {
+		entry = (long)_prom->args.rets[1];
+	}
+	if (entry == 0) {
+		prom_printf(" failed\n");
+		return;
 	}
+	prom_printf(" done\n");
+
+	reserve_mem(base, size);
+
+	prom_setprop(prom_rtas, "linux,rtas-base", &base, sizeof(base));
+	prom_setprop(prom_rtas, "linux,rtas-entry", &entry, sizeof(entry));
+
+	prom_debug("rtas base     = 0x%x\n", base);
+	prom_debug("rtas entry    = 0x%x\n", entry);
+	prom_debug("rtas size     = 0x%x\n", (long)size);
+
 	prom_debug("prom_instantiate_rtas: end...\n");
 }
 
@@ -760,7 +760,7 @@
 	unsigned long offset = reloc_offset();
 	char compatible[64], type[64], model[64];
 	char *path = RELOC(prom_scratch);
-	u64 base, vbase, align;
+	u64 base, align;
 	u32 minalign, minsize;
 	u64 tce_entry, *tce_entryp;
 	u64 local_alloc_top, local_alloc_bottom;
@@ -832,12 +832,9 @@
 		if (base < local_alloc_bottom)
 			local_alloc_bottom = base;
 
-		vbase = (unsigned long)abs_to_virt(base);
-
 		/* Save away the TCE table attributes for later use. */
-		prom_setprop(node, "linux,tce-base", &vbase, sizeof(vbase));
+		prom_setprop(node, "linux,tce-base", &base, sizeof(base));
 		prom_setprop(node, "linux,tce-size", &minsize, sizeof(minsize));
-		prom_setprop(node, "linux,has-tce-table", NULL, 0);
 
 		/* It seems OF doesn't null-terminate the path :-( */
 		memset(path, 0, sizeof(path));
@@ -952,9 +949,9 @@
 			continue;
 
 		/* Skip non-configured cpus. */
-		prom_getprop(node, "status", type, sizeof(type));
-		if (strcmp(type, RELOC("okay")) != 0)
-			continue;
+		if (prom_getprop(node, "status", type, sizeof(type)) > 0)
+			if (strcmp(type, RELOC("okay")) != 0)
+				continue;
 
 		reg = -1;
 		prom_getprop(node, "reg", &reg, sizeof(reg));
@@ -991,12 +988,13 @@
 			/* Primary Thread of non-boot cpu */
 			prom_printf("%x : starting cpu hw idx %x... ", cpuid, reg);
 			call_prom("start-cpu", 3, 0, node,
-				  secondary_hold, cpuid);
+				  secondary_hold, reg);
 
 			for ( i = 0 ; (i < 100000000) && 
-			      (*acknowledge == ((unsigned long)-1)); i++ ) ;
+			      (*acknowledge == ((unsigned long)-1)); i++ )
+				mb();
 
-			if (*acknowledge == cpuid) {
+			if (*acknowledge == reg) {
 				prom_printf("done\n");
 				/* We have to get every CPU out of OF,
 				 * even if we never start it. */
@@ -1110,6 +1108,16 @@
 	}
 }
 
+static void __init prom_close_stdin(void)
+{
+	unsigned long offset = reloc_offset();
+	struct prom_t *_prom = PTRRELOC(&prom);
+	ihandle val;
+
+	if (prom_getprop(_prom->chosen, "stdin", &val, sizeof(val)) > 0)
+		call_prom("close", 1, 0, val);
+}
+
 static int __init prom_find_machine_type(void)
 {
 	unsigned long offset = reloc_offset();
@@ -1130,6 +1138,8 @@
 			if (strstr(p, RELOC("Power Macintosh")) ||
 			    strstr(p, RELOC("MacRISC4")))
 				return PLATFORM_POWERMAC;
+			if (strstr(p, RELOC("Momentum,Maple")))
+				return PLATFORM_MAPLE;
 			i += sl + 1;
 		}
 	}
@@ -1161,7 +1171,7 @@
  * So we check whether we will need to open the display,
  * and if so, open it now.
  */
-static unsigned long __init prom_check_displays(void)
+static void __init prom_check_displays(void)
 {
 	unsigned long offset = reloc_offset();
 	struct prom_t *_prom = PTRRELOC(&prom);
@@ -1603,11 +1613,6 @@
 	prom_debug("offset=0x%x\n", offset);
 
 	/*
-	 * Reserve kernel in reserve map
-	 */
-	reserve_mem(0, __pa(RELOC(klimit)));
-
-	/*
 	 * Check for an initrd
 	 */
 	prom_check_initrd(r3, r4);
@@ -1690,6 +1695,9 @@
 	 */
        	prom_printf("copying OF device tree ...\n");
        	flatten_device_tree();
+
+	/* in case stdin is USB and still active on IBM machines... */
+	prom_close_stdin();
 
 	/*
 	 * Call OF "quiesce" method to shut down pending DMA's from
diff -Nru a/arch/ppc64/kernel/ptrace.c b/arch/ppc64/kernel/ptrace.c
--- a/arch/ppc64/kernel/ptrace.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc64/kernel/ptrace.c	2004-12-24 13:37:18 -08:00
@@ -182,7 +182,7 @@
 	 */
 	case PTRACE_KILL: {
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		/* make sure the single step bit is not set. */
@@ -318,7 +318,8 @@
 	if (unlikely(current->audit_context))
 		audit_syscall_exit(current, 0);	/* FIXME: pass pt_regs */
 
-	if (test_thread_flag(TIF_SYSCALL_TRACE)
+	if ((test_thread_flag(TIF_SYSCALL_TRACE)
+	     || test_thread_flag(TIF_SINGLESTEP))
 	    && (current->ptrace & PT_PTRACED))
 		do_syscall_trace();
 }
diff -Nru a/arch/ppc64/kernel/ptrace32.c b/arch/ppc64/kernel/ptrace32.c
--- a/arch/ppc64/kernel/ptrace32.c	2004-12-24 13:36:59 -08:00
+++ b/arch/ppc64/kernel/ptrace32.c	2004-12-24 13:36:59 -08:00
@@ -314,7 +314,7 @@
 	 */
 	case PTRACE_KILL: {
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		/* make sure the single step bit is not set. */
diff -Nru a/arch/ppc64/kernel/ras.c b/arch/ppc64/kernel/ras.c
--- a/arch/ppc64/kernel/ras.c	2004-12-24 13:36:32 -08:00
+++ b/arch/ppc64/kernel/ras.c	2004-12-24 13:36:32 -08:00
@@ -37,9 +37,9 @@
 #include <linux/irq.h>
 #include <linux/random.h>
 #include <linux/sysrq.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/ppc64/kernel/rtas-proc.c b/arch/ppc64/kernel/rtas-proc.c
--- a/arch/ppc64/kernel/rtas-proc.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc64/kernel/rtas-proc.c	2004-12-24 13:36:48 -08:00
@@ -22,9 +22,9 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/processor.h>
 #include <asm/io.h>
 #include <asm/prom.h>
diff -Nru a/arch/ppc64/kernel/rtas.c b/arch/ppc64/kernel/rtas.c
--- a/arch/ppc64/kernel/rtas.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/kernel/rtas.c	2004-12-24 13:36:18 -08:00
@@ -102,6 +102,27 @@
 	return tokp ? *tokp : RTAS_UNKNOWN_SERVICE;
 }
 
+/*
+ * Return the firmware-specified size of the error log buffer
+ *  for all rtas calls that require an error buffer argument.
+ *  This includes 'check-exception' and 'rtas-last-error'.
+ */
+int rtas_get_error_log_max(void)
+{
+	static int rtas_error_log_max;
+	if (rtas_error_log_max)
+		return rtas_error_log_max;
+
+	rtas_error_log_max = rtas_token ("rtas-error-log-max");
+	if ((rtas_error_log_max == RTAS_UNKNOWN_SERVICE) ||
+	    (rtas_error_log_max > RTAS_ERROR_LOG_MAX)) {
+		printk (KERN_WARNING "RTAS: bad log buffer size %d\n", rtas_error_log_max);
+		rtas_error_log_max = RTAS_ERROR_LOG_MAX;
+	}
+	return rtas_error_log_max;
+}
+
+
 /** Return a copy of the detailed error text associated with the
  *  most recent failed call to rtas.  Because the error text
  *  might go stale if there are any other intervening rtas calls,
@@ -114,12 +135,7 @@
 	struct rtas_args err_args, save_args;
 	u32 bufsz;
 
-	bufsz = rtas_token ("rtas-error-log-max");
-	if ((bufsz == RTAS_UNKNOWN_SERVICE) ||
-	    (bufsz > RTAS_ERROR_LOG_MAX)) {
-		printk (KERN_WARNING "RTAS: bad log buffer size %d\n", bufsz);
-		bufsz = RTAS_ERROR_LOG_MAX;
-	}
+	bufsz = rtas_get_error_log_max();
 
 	err_args.token = rtas_token("rtas-last-error");
 	err_args.nargs = 2;
@@ -439,6 +455,9 @@
 {
 	int status;
 
+	if (RTAS_UNKNOWN_SERVICE == rtas_token("ibm,os-term"))
+		return;
+
 	snprintf(rtas_os_term_buf, 2048, "OS panic: %s", str);
 
 	do {
@@ -516,7 +535,6 @@
 	return 0;
 }
 
-#ifdef CONFIG_HOTPLUG_CPU
 /* This version can't take the spinlock, because it never returns */
 
 struct rtas_args rtas_stop_self_args = {
@@ -541,27 +559,6 @@
 
 	panic("Alas, I survived.\n");
 }
-#endif /* CONFIG_HOTPLUG_CPU */
-
-/*
- * Return the firmware-specified size of the error log buffer
- *  for all rtas calls that require an error buffer argument.
- *  This includes 'check-exception' and 'rtas-last-error'.
- */
-int rtas_get_error_log_max(void)
-{
-	static int rtas_error_log_max;
-	if (rtas_error_log_max)
-		return rtas_error_log_max;
-
-	rtas_error_log_max = rtas_token ("rtas-error-log-max");
-	if ((rtas_error_log_max == RTAS_UNKNOWN_SERVICE) ||
-	    (rtas_error_log_max > RTAS_ERROR_LOG_MAX)) {
-		printk (KERN_WARNING "RTAS: bad log buffer size %d\n", rtas_error_log_max);
-		rtas_error_log_max = RTAS_ERROR_LOG_MAX;
-	}
-	return rtas_error_log_max;
-}
 
 /*
  * Call early during boot, before mem init or bootmem, to retreive the RTAS
@@ -575,15 +572,15 @@
 	 */
 	rtas.dev = of_find_node_by_name(NULL, "rtas");
 	if (rtas.dev) {
-		u64 *basep, *entryp;
+		u32 *basep, *entryp;
 		u32 *sizep;
 
-		basep = (u64 *)get_property(of_chosen, "linux,rtas-base", NULL);
-		sizep = (u32 *)get_property(of_chosen, "linux,rtas-size", NULL);
+		basep = (u32 *)get_property(rtas.dev, "linux,rtas-base", NULL);
+		sizep = (u32 *)get_property(rtas.dev, "rtas-size", NULL);
 		if (basep != NULL && sizep != NULL) {
 			rtas.base = *basep;
 			rtas.size = *sizep;
-			entryp = (u64 *)get_property(of_chosen, "linux,rtas-entry", NULL);
+			entryp = (u32 *)get_property(rtas.dev, "linux,rtas-entry", NULL);
 			if (entryp == NULL) /* Ugh */
 				rtas.entry = rtas.base;
 			else
diff -Nru a/arch/ppc64/kernel/rtas_flash.c b/arch/ppc64/kernel/rtas_flash.c
--- a/arch/ppc64/kernel/rtas_flash.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc64/kernel/rtas_flash.c	2004-12-24 13:37:19 -08:00
@@ -562,6 +562,7 @@
 		validate_flash(args_buf);
 	}
 
+	/* The matching atomic_inc was in rtas_excl_open() */
 	atomic_dec(&dp->count);
 
 	return 0;
@@ -572,7 +573,8 @@
 	if (dp) {
 		if (dp->data != NULL)
 			kfree(dp->data);
-		remove_proc_entry(dp->name, NULL);
+		dp->owner = NULL;
+		remove_proc_entry(dp->name, dp->parent);
 	}
 }
 
diff -Nru a/arch/ppc64/kernel/rtasd.c b/arch/ppc64/kernel/rtasd.c
--- a/arch/ppc64/kernel/rtasd.c	2004-12-24 13:36:33 -08:00
+++ b/arch/ppc64/kernel/rtasd.c	2004-12-24 13:36:33 -08:00
@@ -48,7 +48,7 @@
 
 static int full_rtas_msgs = 0;
 
-extern volatile int no_more_logging;
+extern int no_logging;
 
 volatile int error_log_cnt = 0;
 
@@ -213,7 +213,7 @@
 	}
 
 	/* Write error to NVRAM */
-	if (!no_more_logging && !(err_type & ERR_FLAG_BOOT))
+	if (!no_logging && !(err_type & ERR_FLAG_BOOT))
 		nvram_write_error_log(buf, len, err_type);
 
 	/*
@@ -225,8 +225,8 @@
 		printk_log_rtas(buf, len);
 
 	/* Check to see if we need to or have stopped logging */
-	if (fatal || no_more_logging) {
-		no_more_logging = 1;
+	if (fatal || no_logging) {
+		no_logging = 1;
 		spin_unlock_irqrestore(&rtasd_log_lock, s);
 		return;
 	}
@@ -275,7 +275,7 @@
  * know that we can safely clear the events in NVRAM.
  * Next we'll sit and wait for something else to log.
  */
-static ssize_t rtas_log_read(struct file * file, char * buf,
+static ssize_t rtas_log_read(struct file * file, char __user * buf,
 			 size_t count, loff_t *ppos)
 {
 	int error;
@@ -299,7 +299,7 @@
 
 	spin_lock_irqsave(&rtasd_log_lock, s);
 	/* if it's 0, then we know we got the last one (the one in NVRAM) */
-	if (rtas_log_size == 0 && !no_more_logging)
+	if (rtas_log_size == 0 && !no_logging)
 		nvram_clear_error_log();
 	spin_unlock_irqrestore(&rtasd_log_lock, s);
 
@@ -417,9 +417,6 @@
 		goto error;
 	}
 
-	/* We can use rtas_log_buf now */
-	no_more_logging = 0;
-
 	printk(KERN_ERR "RTAS daemon started\n");
 
 	DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2);
@@ -428,6 +425,10 @@
 	memset(logdata, 0, rtas_error_log_max);
 
 	rc = nvram_read_error_log(logdata, rtas_error_log_max, &err_type);
+
+	/* We can use rtas_log_buf now */
+	no_logging = 0;
+
 	if (!rc) {
 		if (err_type != ERR_FLAG_ALREADY_LOGGED) {
 			pSeries_log_error(logdata, err_type | ERR_FLAG_BOOT, 0);
diff -Nru a/arch/ppc64/kernel/rtc.c b/arch/ppc64/kernel/rtc.c
--- a/arch/ppc64/kernel/rtc.c	2004-12-24 13:36:56 -08:00
+++ b/arch/ppc64/kernel/rtc.c	2004-12-24 13:36:56 -08:00
@@ -185,11 +185,10 @@
 	.release =	rtc_release,
 };
 
-static struct miscdevice rtc_dev=
-{
-	RTC_MINOR,
-	"rtc",
-	&rtc_fops
+static struct miscdevice rtc_dev = {
+	.minor =	RTC_MINOR,
+	.name =		"rtc",
+	.fops =		&rtc_fops
 };
 
 static int __init rtc_init(void)
@@ -201,9 +200,11 @@
 		return retval;
 
 #ifdef CONFIG_PROC_FS
-	if (create_proc_read_entry ("driver/rtc", 0, NULL, rtc_read_proc, NULL) == NULL)
+	if (create_proc_read_entry("driver/rtc", 0, NULL, rtc_read_proc, NULL)
+			== NULL) {
 		misc_deregister(&rtc_dev);
 		return -ENOMEM;
+	}
 #endif
 
 	printk(KERN_INFO "i/pSeries Real Time Clock Driver v" RTC_VERSION "\n");
@@ -275,7 +276,7 @@
 	if (piranha_simulator)
 		return;
 
-	mf_getRtc(rtc_tm);
+	mf_get_rtc(rtc_tm);
 	rtc_tm->tm_mon--;
 }
 
@@ -285,7 +286,7 @@
  */
 int iSeries_set_rtc_time(struct rtc_time *tm)
 {
-	mf_setRtc(tm);
+	mf_set_rtc(tm);
 	return 0;
 }
 
@@ -356,7 +357,7 @@
 		}
 	} while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb));
 
-	if (error != 0) {
+	if (error != 0 && printk_ratelimit()) {
 		printk(KERN_WARNING "error: reading the clock failed (%d)\n",
 			error);
 		return;
@@ -384,7 +385,7 @@
 	do {
 		error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
 		if (error == RTAS_CLOCK_BUSY || rtas_is_extended_busy(error)) {
-			if (in_interrupt()) {
+			if (in_interrupt() && printk_ratelimit()) {
 				printk(KERN_WARNING "error: reading clock would delay interrupt\n");
 				return;	/* delay not allowed */
 			}
@@ -395,7 +396,7 @@
 		}
 	} while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb));
 
-        if (error != 0) {
+        if (error != 0 && printk_ratelimit()) {
                 printk(KERN_WARNING "error: reading the clock failed (%d)\n",
 		       error);
 		return;
@@ -430,7 +431,7 @@
 		}
 	} while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb));
 
-        if (error != 0)
+        if (error != 0 && printk_ratelimit())
                 printk(KERN_WARNING "error: setting the clock failed (%d)\n",
 		       error); 
 
diff -Nru a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c
--- a/arch/ppc64/kernel/setup.c	2004-12-24 13:36:48 -08:00
+++ b/arch/ppc64/kernel/setup.c	2004-12-24 13:36:48 -08:00
@@ -30,6 +30,8 @@
 #include <linux/notifier.h>
 #include <linux/cpu.h>
 #include <linux/unistd.h>
+#include <linux/serial.h>
+#include <linux/serial_8250.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/processor.h>
@@ -51,6 +53,7 @@
 #include <asm/system.h>
 #include <asm/rtas.h>
 #include <asm/iommu.h>
+#include <asm/serial.h>
 
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
@@ -72,11 +75,14 @@
 extern void udbg_init_pmac_realmode(void);
 /* That's RTAS panel debug */
 extern void call_rtas_display_status_delay(unsigned char c);
+/* Here's maple real mode debug */
+extern void udbg_init_maple_realmode(void);
 
 #define EARLY_DEBUG_INIT() do {} while(0)
 
 #if 0
 #define EARLY_DEBUG_INIT() udbg_init_debug_lpar()
+#define EARLY_DEBUG_INIT() udbg_init_maple_realmode()
 #define EARLY_DEBUG_INIT() udbg_init_pmac_realmode()
 #define EARLY_DEBUG_INIT()						\
 	do { ppc_md.udbg_putc = call_rtas_display_status_delay; } while(0)
@@ -93,6 +99,8 @@
 extern void early_init_devtree(void *flat_dt);
 extern void unflatten_device_tree(void);
 
+extern void smp_release_cpus(void);
+
 unsigned long decr_overclock = 1;
 unsigned long decr_overclock_proc0 = 1;
 unsigned long decr_overclock_set = 0;
@@ -100,6 +108,7 @@
 
 int have_of = 1;
 int boot_cpuid = 0;
+int boot_cpuid_phys = 0;
 dev_t boot_dev;
 
 /*
@@ -236,6 +245,7 @@
 {
 	struct device_node *dn = NULL;
 	int cpu = 0;
+	int swap_cpuid = 0;
 
 	check_smt_enabled();
 
@@ -260,11 +270,23 @@
 				cpu_set(cpu, cpu_present_map);
 				set_hard_smp_processor_id(cpu, intserv[j]);
 			}
+			if (intserv[j] == boot_cpuid_phys)
+				swap_cpuid = cpu;
 			cpu_set(cpu, cpu_possible_map);
 			cpu++;
 		}
 	}
 
+	/* Swap CPU id 0 with boot_cpuid_phys, so we can always assume that
+	 * boot cpu is logical 0.
+	 */
+	if (boot_cpuid_phys != get_hard_smp_processor_id(0)) {
+		u32 tmp;
+		tmp = get_hard_smp_processor_id(0);
+		set_hard_smp_processor_id(0, boot_cpuid_phys);
+		set_hard_smp_processor_id(swap_cpuid, tmp);
+	}
+
 	/*
 	 * On pSeries LPAR, we need to know how many cpus
 	 * could possibly be added to this partition.
@@ -323,6 +345,7 @@
 
 extern struct machdep_calls pSeries_md;
 extern struct machdep_calls pmac_md;
+extern struct machdep_calls maple_md;
 
 /* Ultimately, stuff them in an elf section like initcalls... */
 static struct machdep_calls __initdata *machines[] = {
@@ -332,6 +355,9 @@
 #ifdef CONFIG_PPC_PMAC
 	&pmac_md,
 #endif /* CONFIG_PPC_PMAC */
+#ifdef CONFIG_PPC_MAPLE
+	&maple_md,
+#endif /* CONFIG_PPC_MAPLE */
 	NULL
 };
 
@@ -620,6 +646,11 @@
 	 * iSeries has already initialized the cpu maps at this point.
 	 */
 	setup_cpu_maps();
+
+	/* Release secondary cpus out of their spinloops at 0x60 now that
+	 * we can map physical -> logical CPU ids
+	 */
+	smp_release_cpus();
 #endif /* defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES) */
 
 	printk("Starting Linux PPC64 %s\n", UTS_RELEASE);
@@ -630,6 +661,7 @@
 	printk("naca->debug_switch            = 0x%lx\n", naca->debug_switch);
 	printk("naca->interrupt_controller    = 0x%ld\n", naca->interrupt_controller);
 	printk("systemcfg                     = 0x%p\n", systemcfg);
+	printk("systemcfg->platform           = 0x%x\n", systemcfg->platform);
 	printk("systemcfg->processorCount     = 0x%lx\n", systemcfg->processorCount);
 	printk("systemcfg->physicalMemorySize = 0x%lx\n", systemcfg->physicalMemorySize);
 	printk("systemcfg->dCacheL1LineSize   = 0x%x\n", systemcfg->dCacheL1LineSize);
@@ -783,12 +815,11 @@
 #ifdef CONFIG_PPC_MULTIPLATFORM
 static int __init set_preferred_console(void)
 {
-	struct device_node *prom_stdout;
+	struct device_node *prom_stdout = NULL;
 	char *name;
+	u32 *spd;
 	int offset = 0;
-#if  0
-	phandle *stdout_ph;
-#endif
+
 	DBG(" -> set_preferred_console()\n");
 
 	/* The user has requested a console so this is already set up. */
@@ -802,20 +833,7 @@
 		return -ENODEV;
 	}
 	/* We are getting a weird phandle from OF ... */
-#if 0
-	stdout_ph = (phandle *)get_property(of_chosen, "linux,stdout-package", NULL);
-	if (stdout_ph == NULL) {
-		DBG(" no linux,stdout-package !\n");
-		return -ENODEV;
-	}
-	prom_stdout = of_find_node_by_phandle(*stdout_ph);
-	if (!prom_stdout) {
-		DBG(" can't find stdout package for phandle 0x%x !\n", *stdout_ph);
-		return -ENODEV;
-	}
-#endif
 	/* ... So use the full path instead */
-#if 1
 	name = (char *)get_property(of_chosen, "linux,stdout-path", NULL);
 	if (name == NULL) {
 		DBG(" no linux,stdout-path !\n");
@@ -826,7 +844,6 @@
 		DBG(" can't find stdout package %s !\n", name);
 		return -ENODEV;
 	}	
-#endif
 	DBG("stdout is %s\n", prom_stdout->full_name);
 
 	name = (char *)get_property(prom_stdout, "name", NULL);
@@ -834,8 +851,12 @@
 		DBG(" stdout package has no name !\n");
 		goto not_found;
 	}
+	spd = (u32 *)get_property(prom_stdout, "current-speed", NULL);
 
-	if (strcmp(name, "serial") == 0) {
+	if (0)
+		;
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+	else if (strcmp(name, "serial") == 0) {
 		int i;
 		u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
 		if (i > 8) {
@@ -858,6 +879,7 @@
 			}
 		}
 	}
+#endif /* CONFIG_SERIAL_8250_CONSOLE */
 #ifdef CONFIG_PPC_PSERIES
 	else if (strcmp(name, "vty") == 0) {
  		u32 *reg = (u32 *)get_property(prom_stdout, "reg", NULL);
@@ -887,17 +909,24 @@
  		}
 	}
 #endif /* CONFIG_PPC_PSERIES */
+#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
 	else if (strcmp(name, "ch-a") == 0)
 		offset = 0;
 	else if (strcmp(name, "ch-b") == 0)
 		offset = 1;
+#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
 	else
 		goto not_found;
 	of_node_put(prom_stdout);
 
 	DBG("Found serial console at ttyS%d\n", offset);
 
-	return add_preferred_console("ttyS", offset, NULL);
+	if (spd) {
+		static char __initdata opt[16];
+		sprintf(opt, "%d", *spd);
+		return add_preferred_console("ttyS", offset, opt);
+	} else
+		return add_preferred_console("ttyS", offset, NULL);
 
  not_found:
 	DBG("No preferred console found !\n");
@@ -991,11 +1020,11 @@
 	/* set up the bootmem stuff with available memory */
 	do_init_bootmem();
 
+	ppc_md.setup_arch();
+
 	/* Select the correct idle loop for the platform. */
 	idle_setup();
 
-	ppc_md.setup_arch();
-
 	paging_init();
 	ppc64_boot_msg(0x15, "Setup Done");
 }
@@ -1106,15 +1135,210 @@
 __setup("decr_overclock_proc0=", set_decr_overclock_proc0 );
 __setup("decr_overclock=", set_decr_overclock );
 
+#ifndef CONFIG_PPC_ISERIES
+/*
+ * This function can be used by platforms to "find" legacy serial ports.
+ * It works for "serial" nodes under an "isa" node, and will try to
+ * respect the "ibm,aix-loc" property if any. It works with up to 8
+ * ports.
+ */
+
+#define MAX_LEGACY_SERIAL_PORTS	8
+static struct plat_serial8250_port serial_ports[MAX_LEGACY_SERIAL_PORTS+1];
+static unsigned int old_serial_count;
+
+void __init generic_find_legacy_serial_ports(unsigned int *default_speed)
+{
+	struct device_node *np;
+	u32 *sizeprop;
+
+	struct isa_reg_property {
+		u32 space;
+		u32 address;
+		u32 size;
+	};
+	struct pci_reg_property {
+		struct pci_address addr;
+		u32 size_hi;
+		u32 size_lo;
+	};                                                                        
+
+	DBG(" -> generic_find_legacy_serial_port()\n");
+
+	naca->serialPortAddr = 0;
+	if (default_speed)
+		*default_speed = 0;
+
+	np = of_find_node_by_path("/");
+	if (!np)
+		return;
+
+	/* First fill our array */
+	for (np = NULL; (np = of_find_node_by_type(np, "serial"));) {
+		struct device_node *isa, *pci;
+		struct isa_reg_property *reg;
+		unsigned long phys_size, addr_size, io_base;
+		u32 *rangesp;
+		u32 *interrupts, *clk, *spd;
+		char *typep;
+		int index, rlen, rentsize;
+
+		/* Ok, first check if it's under an "isa" parent */
+		isa = of_get_parent(np);
+		if (!isa || strcmp(isa->name, "isa")) {
+			DBG("%s: no isa parent found\n", np->full_name);
+			continue;
+		}
+		
+		/* Now look for an "ibm,aix-loc" property that gives us ordering
+		 * if any...
+		 */
+	 	typep = (char *)get_property(np, "ibm,aix-loc", NULL);
+
+		/* Get the ISA port number */
+		reg = (struct isa_reg_property *)get_property(np, "reg", NULL);	
+		if (reg == NULL)
+			goto next_port;
+		/* We assume the interrupt number isn't translated ... */
+		interrupts = (u32 *)get_property(np, "interrupts", NULL);
+		/* get clock freq. if present */
+		clk = (u32 *)get_property(np, "clock-frequency", NULL);
+		/* get default speed if present */
+		spd = (u32 *)get_property(np, "current-speed", NULL);
+		/* Default to locate at end of array */
+		index = old_serial_count; /* end of the array by default */
+
+		/* If we have a location index, then use it */
+		if (typep && *typep == 'S') {
+			index = simple_strtol(typep+1, NULL, 0) - 1;
+			/* if index is out of range, use end of array instead */
+			if (index >= MAX_LEGACY_SERIAL_PORTS)
+				index = old_serial_count;
+			/* if our index is still out of range, that mean that
+			 * array is full, we could scan for a free slot but that
+			 * make little sense to bother, just skip the port
+			 */
+			if (index >= MAX_LEGACY_SERIAL_PORTS)
+				goto next_port;
+			if (index >= old_serial_count)
+				old_serial_count = index + 1;
+			/* Check if there is a port who already claimed our slot */
+			if (serial_ports[index].iobase != 0) {
+				/* if we still have some room, move it, else override */
+				if (old_serial_count < MAX_LEGACY_SERIAL_PORTS) {
+					DBG("Moved legacy port %d -> %d\n", index,
+					    old_serial_count);
+					serial_ports[old_serial_count++] =
+						serial_ports[index];
+				} else {
+					DBG("Replacing legacy port %d\n", index);
+				}
+			}
+		}
+		if (index >= MAX_LEGACY_SERIAL_PORTS)
+			goto next_port;
+		if (index >= old_serial_count)
+			old_serial_count = index + 1;
+
+		/* Now fill the entry */
+		memset(&serial_ports[index], 0, sizeof(struct plat_serial8250_port));
+		serial_ports[index].uartclk = clk ? *clk : BASE_BAUD * 16;
+		serial_ports[index].iobase = reg->address;
+		serial_ports[index].irq = interrupts ? interrupts[0] : 0;
+		serial_ports[index].flags = ASYNC_BOOT_AUTOCONF;
+
+		DBG("Added legacy port, index: %d, port: %x, irq: %d, clk: %d\n",
+		    index,
+		    serial_ports[index].iobase,
+		    serial_ports[index].irq,
+		    serial_ports[index].uartclk);
+
+		/* Get phys address of IO reg for port 1 */
+		if (index != 0)
+			goto next_port;
+
+		pci = of_get_parent(isa);
+		if (!pci) {
+			DBG("%s: no pci parent found\n", np->full_name);
+			goto next_port;
+		}
+
+		rangesp = (u32 *)get_property(pci, "ranges", &rlen);
+		if (rangesp == NULL) {
+			of_node_put(pci);
+			goto next_port;
+		}
+		rlen /= 4;
+
+		/* we need the #size-cells of the PCI bridge node itself */
+		phys_size = 1;
+		sizeprop = (u32 *)get_property(pci, "#size-cells", NULL);
+		if (sizeprop != NULL)
+			phys_size = *sizeprop;
+		/* we need the parent #addr-cells */
+		addr_size = prom_n_addr_cells(pci);
+		rentsize = 3 + addr_size + phys_size;
+		io_base = 0;
+		for (;rlen >= rentsize; rlen -= rentsize,rangesp += rentsize) {
+			if (((rangesp[0] >> 24) & 0x3) != 1)
+				continue; /* not IO space */
+			io_base = rangesp[3];
+			if (addr_size == 2)
+				io_base = (io_base << 32) | rangesp[4];
+		}
+		if (io_base != 0) {
+			naca->serialPortAddr = io_base + reg->address;
+			if (default_speed && spd)
+				*default_speed = *spd;
+		}
+		of_node_put(pci);
+	next_port:
+		of_node_put(isa);
+	}
+
+	DBG(" <- generic_find_legacy_serial_port()\n");
+}
+
+static struct platform_device serial_device = {
+	.name	= "serial8250",
+	.id	= 0,
+	.dev	= {
+		.platform_data = serial_ports,
+	},
+};
+
+static int __init serial_dev_init(void)
+{
+	return platform_device_register(&serial_device);
+}
+arch_initcall(serial_dev_init);
+
+#endif /* CONFIG_PPC_ISERIES */
+
+int check_legacy_ioport(unsigned long base_port)
+{
+	if (ppc_md.check_legacy_ioport == NULL)
+		return 0;
+	return ppc_md.check_legacy_ioport(base_port);
+}
+EXPORT_SYMBOL(check_legacy_ioport);
+
 #ifdef CONFIG_XMON
 static int __init early_xmon(char *p)
 {
 	/* ensure xmon is enabled */
 	xmon_init();
-	debugger(0);
+	debugger(NULL);
 
 	return 0;
 }
 early_param("xmon", early_xmon);
 #endif
 
+void cpu_die(void)
+{
+	if (ppc_md.cpu_die)
+		ppc_md.cpu_die();
+	local_irq_disable();
+	for (;;);
+}
diff -Nru a/arch/ppc64/kernel/signal.c b/arch/ppc64/kernel/signal.c
--- a/arch/ppc64/kernel/signal.c	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc64/kernel/signal.c	2004-12-24 13:36:16 -08:00
@@ -26,6 +26,7 @@
 #include <linux/unistd.h>
 #include <linux/stddef.h>
 #include <linux/elf.h>
+#include <linux/ptrace.h>
 #include <asm/sigcontext.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
@@ -98,7 +99,7 @@
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();
 		if (do_signal(&saveset, regs))
-			return regs->gpr[3];
+			return 0;
 	}
 }
 
@@ -179,6 +180,9 @@
 	unsigned long err = 0;
 	unsigned long save_r13 = 0;
 	elf_greg_t *gregs = (elf_greg_t *)regs;
+#ifdef CONFIG_ALTIVEC
+	unsigned long msr;
+#endif
 	int i;
 
 	/* If this is not a signal return, we preserve the TLS in r13 */
@@ -204,13 +208,15 @@
 
 #ifdef CONFIG_ALTIVEC
 	err |= __get_user(v_regs, &sc->v_regs);
+	err |= __get_user(msr, &sc->gp_regs[PT_MSR]);
 	if (err)
 		return err;
 	/* Copy 33 vec registers (vr0..31 and vscr) from the stack */
-	if (v_regs != 0 && (regs->msr & MSR_VEC) != 0)
-		err |= __copy_from_user(current->thread.vr, v_regs, 33 * sizeof(vector128));
+	if (v_regs != 0 && (msr & MSR_VEC) != 0)
+		err |= __copy_from_user(current->thread.vr, v_regs,
+					33 * sizeof(vector128));
 	else if (current->thread.used_vr)
-		memset(&current->thread.vr, 0, 33);
+		memset(current->thread.vr, 0, 33 * sizeof(vector128));
 	/* Always get VRSAVE back */
 	if (v_regs != 0)
 		err |= __get_user(current->thread.vrsave, (u32 __user *)&v_regs[33]);
@@ -218,6 +224,14 @@
 		current->thread.vrsave = 0;
 #endif /* CONFIG_ALTIVEC */
 
+#ifndef CONFIG_SMP
+	preempt_disable();
+	if (last_task_used_math == current)
+		last_task_used_math = NULL;
+	if (last_task_used_altivec == current)
+		last_task_used_altivec = NULL;
+	preempt_enable();
+#endif
 	/* Force reload of FP/VEC */
 	regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1 | MSR_VEC);
 
@@ -374,7 +388,7 @@
 	return 0;
 }
 
-static void setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
+static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
 		sigset_t *set, struct pt_regs *regs)
 {
 	/* Handler is *really* a pointer to the function descriptor for
@@ -420,7 +434,7 @@
 
 	/* Allocate a dummy caller frame for the signal handler. */
 	newsp = (unsigned long)frame - __SIGNAL_FRAMESIZE;
-	err |= put_user(0, (unsigned long __user *)newsp);
+	err |= put_user(regs->gpr[1], (unsigned long __user *)newsp);
 
 	/* Set up "regs" so we "return" to the signal handler. */
 	err |= get_user(regs->nip, &funct_desc_ptr->entry);
@@ -439,7 +453,10 @@
 	if (err)
 		goto badframe;
 
-	return;
+	if (test_thread_flag(TIF_SINGLESTEP))
+		ptrace_notify(SIGTRAP);
+
+	return 1;
 
 badframe:
 #if DEBUG_SIG
@@ -447,25 +464,30 @@
 	       regs, frame, newsp);
 #endif
 	force_sigsegv(signr, current);
+	return 0;
 }
 
 
 /*
  * OK, we're invoking a handler
  */
-static void handle_signal(unsigned long sig, struct k_sigaction *ka,
-			  siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
+static int handle_signal(unsigned long sig, struct k_sigaction *ka,
+			 siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
 {
+	int ret;
+
 	/* Set up Signal Frame */
-	setup_rt_frame(sig, ka, info, oldset, regs);
+	ret = setup_rt_frame(sig, ka, info, oldset, regs);
 
-	if (!(ka->sa.sa_flags & SA_NODEFER)) {
+	if (ret && !(ka->sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
 		sigaddset(&current->blocked,sig);
 		recalc_sigpending();
 		spin_unlock_irq(&current->sighand->siglock);
 	}
+
+	return ret;
 }
 
 static inline void syscall_restart(struct pt_regs *regs, struct k_sigaction *ka)
@@ -525,8 +547,7 @@
 		/* Whee!  Actually deliver the signal.  */
 		if (TRAP(regs) == 0x0C00)
 			syscall_restart(regs, &ka);
-		handle_signal(signr, &ka, &info, oldset, regs);
-		return 1;
+		return handle_signal(signr, &ka, &info, oldset, regs);
 	}
 
 	if (TRAP(regs) == 0x0C00) {	/* System Call! */
diff -Nru a/arch/ppc64/kernel/signal32.c b/arch/ppc64/kernel/signal32.c
--- a/arch/ppc64/kernel/signal32.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc64/kernel/signal32.c	2004-12-24 13:37:19 -08:00
@@ -25,6 +25,7 @@
 #include <linux/errno.h>
 #include <linux/elf.h>
 #include <linux/compat.h>
+#include <linux/ptrace.h>
 #include <asm/ppc32.h>
 #include <asm/uaccess.h>
 #include <asm/ppcdebug.h>
@@ -227,13 +228,21 @@
 				     sizeof(sr->mc_vregs)))
 			return 1;
 	} else if (current->thread.used_vr)
-		memset(&current->thread.vr, 0, ELF_NVRREG32 * sizeof(vector128));
+		memset(current->thread.vr, 0, ELF_NVRREG32 * sizeof(vector128));
 
 	/* Always get VRSAVE back */
 	if (__get_user(current->thread.vrsave, (u32 __user *)&sr->mc_vregs[32]))
 		return 1;
 #endif /* CONFIG_ALTIVEC */
 
+#ifndef CONFIG_SMP
+	preempt_disable();
+	if (last_task_used_math == current)
+		last_task_used_math = NULL;
+	if (last_task_used_altivec == current)
+		last_task_used_altivec = NULL;
+	preempt_enable();
+#endif
 	return 0;
 }
 
@@ -276,14 +285,12 @@
 		schedule();
 		if (do_signal32(&saveset, regs))
 			/*
-			 * If a signal handler needs to be called,
-			 * do_signal32() has set R3 to the signal number (the
-			 * first argument of the signal handler), so don't
-			 * overwrite that with EINTR !
-			 * In the other cases, do_signal32() doesn't touch 
-			 * R3, so it's still set to -EINTR (see above).
+			 * Returning 0 means we return to userspace via
+			 * ret_from_except and thus restore all user
+			 * registers from *regs.  This is what we need
+			 * to do when a signal has been delivered.
 			 */
-			return regs->gpr[3];
+			return 0;
 	}
 }
 
@@ -579,14 +586,12 @@
 		schedule();
 		if (do_signal32(&saveset, regs))
 			/*
-			 * If a signal handler needs to be called,
-			 * do_signal32() has set R3 to the signal number (the
-			 * first argument of the signal handler), so don't
-			 * overwrite that with EINTR !
-			 * In the other cases, do_signal32() doesn't touch 
-			 * R3, so it's still set to -EINTR (see above).
+			 * Returning 0 means we return to userspace via
+			 * ret_from_except and thus restore all user
+			 * registers from *regs.  This is what we need
+			 * to do when a signal has been delivered.
 			 */
-			return regs->gpr[3];
+			return 0;
 	}
 }
 
@@ -645,9 +650,9 @@
  * Set up a signal frame for a "real-time" signal handler
  * (one which gets siginfo).
  */
-static void handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
-			       siginfo_t *info, sigset_t *oldset,
-			       struct pt_regs * regs, unsigned long newsp)
+static int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
+			      siginfo_t *info, sigset_t *oldset,
+			      struct pt_regs * regs, unsigned long newsp)
 {
 	struct rt_sigframe32 __user *rt_sf;
 	struct mcontext32 __user *frame;
@@ -696,7 +701,10 @@
 	regs->trap = 0;
 	regs->result = 0;
 
-	return;
+	if (test_thread_flag(TIF_SINGLESTEP))
+		ptrace_notify(SIGTRAP);
+
+	return 1;
 
 badframe:
 #if DEBUG_SIG
@@ -704,6 +712,7 @@
 	       regs, frame, newsp);
 #endif
 	force_sigsegv(sig, current);
+	return 0;
 }
 
 static long do_setcontext32(struct ucontext32 __user *ucp, struct pt_regs *regs, int sig)
@@ -814,7 +823,7 @@
 /*
  * OK, we're invoking a handler
  */
-static void handle_signal32(unsigned long sig, struct k_sigaction *ka,
+static int handle_signal32(unsigned long sig, struct k_sigaction *ka,
 			    siginfo_t *info, sigset_t *oldset,
 			    struct pt_regs * regs, unsigned long newsp)
 {
@@ -859,7 +868,10 @@
 	regs->trap = 0;
 	regs->result = 0;
 
-	return;
+	if (test_thread_flag(TIF_SINGLESTEP))
+		ptrace_notify(SIGTRAP);
+
+	return 1;
 
 badframe:
 #if DEBUG_SIG
@@ -867,6 +879,7 @@
 	       regs, frame, *newspp);
 #endif
 	force_sigsegv(sig, current);
+	return 0;
 }
 
 /*
@@ -976,11 +989,11 @@
 
 	/* Whee!  Actually deliver the signal.  */
 	if (ka.sa.sa_flags & SA_SIGINFO)
-		handle_rt_signal32(signr, &ka, &info, oldset, regs, newsp);
+		ret = handle_rt_signal32(signr, &ka, &info, oldset, regs, newsp);
 	else
-		handle_signal32(signr, &ka, &info, oldset, regs, newsp);
+		ret = handle_signal32(signr, &ka, &info, oldset, regs, newsp);
 
-	if (!(ka.sa.sa_flags & SA_NODEFER)) {
+	if (ret && !(ka.sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked, &current->blocked,
 			  &ka.sa.sa_mask);
@@ -989,5 +1002,5 @@
 		spin_unlock_irq(&current->sighand->siglock);
 	}
 
-	return 1;
+	return ret;
 }
diff -Nru a/arch/ppc64/kernel/smp.c b/arch/ppc64/kernel/smp.c
--- a/arch/ppc64/kernel/smp.c	2004-12-24 13:37:04 -08:00
+++ b/arch/ppc64/kernel/smp.c	2004-12-24 13:37:04 -08:00
@@ -43,18 +43,14 @@
 #include <asm/smp.h>
 #include <asm/naca.h>
 #include <asm/paca.h>
-#include <asm/iSeries/LparData.h>
-#include <asm/iSeries/HvCall.h>
-#include <asm/iSeries/HvCallCfg.h>
 #include <asm/time.h>
 #include <asm/ppcdebug.h>
-#include "open_pic.h"
 #include <asm/machdep.h>
-#include <asm/xics.h>
 #include <asm/cputable.h>
 #include <asm/system.h>
-#include <asm/rtas.h>
-#include <asm/plpar_wrappers.h>
+#include <asm/abs_addr.h>
+
+#include "mpic.h"
 
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
@@ -80,121 +76,15 @@
 
 extern int cpu_idle(void *unused);
 void smp_call_function_interrupt(void);
-extern long register_vpa(unsigned long flags, unsigned long proc,
-			 unsigned long vpa);
 
 int smt_enabled_at_boot = 1;
 
 /* Low level assembly function used to backup CPU 0 state */
 extern void __save_cpu_setup(void);
 
-extern void pseries_secondary_smp_init(unsigned long); 
-
-#ifdef CONFIG_PPC_ISERIES
-static unsigned long iSeries_smp_message[NR_CPUS];
-
-void iSeries_smp_message_recv( struct pt_regs * regs )
-{
-	int cpu = smp_processor_id();
-	int msg;
-
-	if ( num_online_cpus() < 2 )
-		return;
-
-	for ( msg = 0; msg < 4; ++msg )
-		if ( test_and_clear_bit( msg, &iSeries_smp_message[cpu] ) )
-			smp_message_recv( msg, regs );
-}
-
-static inline void smp_iSeries_do_message(int cpu, int msg)
-{
-	set_bit(msg, &iSeries_smp_message[cpu]);
-	HvCall_sendIPI(&(paca[cpu]));
-}
-
-static void smp_iSeries_message_pass(int target, int msg)
-{
-	int i;
-
-	if (target < NR_CPUS)
-		smp_iSeries_do_message(target, msg);
-	else {
-		for_each_online_cpu(i) {
-			if (target == MSG_ALL_BUT_SELF
-			    && i == smp_processor_id())
-				continue;
-			smp_iSeries_do_message(i, msg);
-		}
-	}
-}
-
-static int smp_iSeries_numProcs(void)
-{
-	unsigned np, i;
-
-	np = 0;
-        for (i=0; i < NR_CPUS; ++i) {
-                if (paca[i].lppaca.xDynProcStatus < 2) {
-			cpu_set(i, cpu_possible_map);
-			cpu_set(i, cpu_present_map);
-                        ++np;
-                }
-        }
-	return np;
-}
-
-static int smp_iSeries_probe(void)
-{
-	unsigned i;
-	unsigned np = 0;
-
-	for (i=0; i < NR_CPUS; ++i) {
-		if (paca[i].lppaca.xDynProcStatus < 2) {
-			/*paca[i].active = 1;*/
-			++np;
-		}
-	}
-
-	return np;
-}
-
-static void smp_iSeries_kick_cpu(int nr)
-{
-	BUG_ON(nr < 0 || nr >= NR_CPUS);
-
-	/* Verify that our partition has a processor nr */
-	if (paca[nr].lppaca.xDynProcStatus >= 2)
-		return;
-
-	/* The processor is currently spinning, waiting
-	 * for the cpu_start field to become non-zero
-	 * After we set cpu_start, the processor will
-	 * continue on to secondary_start in iSeries_head.S
-	 */
-	paca[nr].cpu_start = 1;
-}
-
-static void __devinit smp_iSeries_setup_cpu(int nr)
-{
-}
-
-static struct smp_ops_t iSeries_smp_ops = {
-	.message_pass = smp_iSeries_message_pass,
-	.probe        = smp_iSeries_probe,
-	.kick_cpu     = smp_iSeries_kick_cpu,
-	.setup_cpu    = smp_iSeries_setup_cpu,
-};
-
-/* This is called very early. */
-void __init smp_init_iSeries(void)
-{
-	smp_ops = &iSeries_smp_ops;
-	systemcfg->processorCount	= smp_iSeries_numProcs();
-}
-#endif
 
 #ifdef CONFIG_PPC_MULTIPLATFORM
-void smp_openpic_message_pass(int target, int msg)
+void smp_mpic_message_pass(int target, int msg)
 {
 	/* make sure we're sending something that translates to an IPI */
 	if ( msg > 0x3 ){
@@ -205,242 +95,52 @@
 	switch ( target )
 	{
 	case MSG_ALL:
-		openpic_cause_IPI(msg, 0xffffffff);
+		mpic_send_ipi(msg, 0xffffffff);
 		break;
 	case MSG_ALL_BUT_SELF:
-		openpic_cause_IPI(msg,
-				  0xffffffff & ~(1 << smp_processor_id()));
+		mpic_send_ipi(msg, 0xffffffff & ~(1 << smp_processor_id()));
 		break;
 	default:
-		openpic_cause_IPI(msg, 1<<target);
+		mpic_send_ipi(msg, 1 << target);
 		break;
 	}
 }
 
-static int __init smp_openpic_probe(void)
+int __init smp_mpic_probe(void)
 {
 	int nr_cpus;
 
+	DBG("smp_mpic_probe()...\n");
+
 	nr_cpus = cpus_weight(cpu_possible_map);
 
+	DBG("nr_cpus: %d\n", nr_cpus);
+
 	if (nr_cpus > 1)
-		openpic_request_IPIs();
+		mpic_request_ipis();
 
 	return nr_cpus;
 }
 
-static void __devinit smp_openpic_setup_cpu(int cpu)
-{
-	do_openpic_setup_cpu();
-}
-
-#endif /* CONFIG_PPC_MULTIPLATFORM */
-
-#ifdef CONFIG_PPC_PSERIES
-
-/* Get state of physical CPU.
- * Return codes:
- *	0	- The processor is in the RTAS stopped state
- *	1	- stop-self is in progress
- *	2	- The processor is not in the RTAS stopped state
- *	-1	- Hardware Error
- *	-2	- Hardware Busy, Try again later.
- */
-int query_cpu_stopped(unsigned int pcpu)
-{
-	int cpu_status;
-	int status, qcss_tok;
-
-	DBG(" -> query_cpu_stopped(%d)\n", pcpu);
-	qcss_tok = rtas_token("query-cpu-stopped-state");
-	if (qcss_tok == RTAS_UNKNOWN_SERVICE)
-		return -1;
-	status = rtas_call(qcss_tok, 1, 2, &cpu_status, pcpu);
-	if (status != 0) {
-		printk(KERN_ERR
-		       "RTAS query-cpu-stopped-state failed: %i\n", status);
-		return status;
-	}
-
-	DBG(" <- query_cpu_stopped(), status: %d\n", cpu_status);
-
-	return cpu_status;
-}
-
-#ifdef CONFIG_HOTPLUG_CPU
-
-int __cpu_disable(void)
+void __devinit smp_mpic_setup_cpu(int cpu)
 {
-	/* FIXME: go put this in a header somewhere */
-	extern void xics_migrate_irqs_away(void);
-
-	systemcfg->processorCount--;
-
-	/*fix boot_cpuid here*/
-	if (smp_processor_id() == boot_cpuid)
-		boot_cpuid = any_online_cpu(cpu_online_map);
-
-	/* FIXME: abstract this to not be platform specific later on */
-	xics_migrate_irqs_away();
-	return 0;
+	mpic_setup_this_cpu();
 }
 
-void __cpu_die(unsigned int cpu)
-{
-	int tries;
-	int cpu_status;
-	unsigned int pcpu = get_hard_smp_processor_id(cpu);
-
-	for (tries = 0; tries < 25; tries++) {
-		cpu_status = query_cpu_stopped(pcpu);
-		if (cpu_status == 0 || cpu_status == -1)
-			break;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/5);
-	}
-	if (cpu_status != 0) {
-		printk("Querying DEAD? cpu %i (%i) shows %i\n",
-		       cpu, pcpu, cpu_status);
-	}
-
-	/* Isolation and deallocation are definatly done by
-	 * drslot_chrp_cpu.  If they were not they would be
-	 * done here.  Change isolate state to Isolate and
-	 * change allocation-state to Unusable.
-	 */
-	paca[cpu].cpu_start = 0;
-
-	/* So we can recognize if it fails to come up next time. */
-	cpu_callin_map[cpu] = 0;
-}
-
-/* Kill this cpu */
-void cpu_die(void)
-{
-	local_irq_disable();
-	/* Some hardware requires clearing the CPPR, while other hardware does not
-	 * it is safe either way
-	 */
-	pSeriesLP_cppr_info(0, 0);
-	rtas_stop_self();
-	/* Should never get here... */
-	BUG();
-	for(;;);
-}
-
-/* Search all cpu device nodes for an offline logical cpu.  If a
- * device node has a "ibm,my-drc-index" property (meaning this is an
- * LPAR), paranoid-check whether we own the cpu.  For each "thread"
- * of a cpu, if it is offline and has the same hw index as before,
- * grab that in preference.
- */
-static unsigned int find_physical_cpu_to_start(unsigned int old_hwindex)
-{
-	struct device_node *np = NULL;
-	unsigned int best = -1U;
-
-	while ((np = of_find_node_by_type(np, "cpu"))) {
-		int nr_threads, len;
-		u32 *index = (u32 *)get_property(np, "ibm,my-drc-index", NULL);
-		u32 *tid = (u32 *)
-			get_property(np, "ibm,ppc-interrupt-server#s", &len);
-
-		if (!tid)
-			tid = (u32 *)get_property(np, "reg", &len);
-
-		if (!tid)
-			continue;
-
-		/* If there is a drc-index, make sure that we own
-		 * the cpu.
-		 */
-		if (index) {
-			int state;
-			int rc = rtas_get_sensor(9003, *index, &state);
-			if (rc != 0 || state != 1)
-				continue;
-		}
-
-		nr_threads = len / sizeof(u32);
-
-		while (nr_threads--) {
-			if (0 == query_cpu_stopped(tid[nr_threads])) {
-				best = tid[nr_threads];
-				if (best == old_hwindex)
-					goto out;
-			}
-		}
-	}
-out:
-	of_node_put(np);
-	return best;
-}
-
-/**
- * smp_startup_cpu() - start the given cpu
- *
- * At boot time, there is nothing to do.  At run-time, call RTAS with
- * the appropriate start location, if the cpu is in the RTAS stopped
- * state.
- *
- * Returns:
- *	0	- failure
- *	1	- success
- */
-static inline int __devinit smp_startup_cpu(unsigned int lcpu)
-{
-	int status;
-	unsigned long start_here = __pa((u32)*((unsigned long *)
-					       pseries_secondary_smp_init));
-	unsigned int pcpu;
-
-	/* At boot time the cpus are already spinning in hold
-	 * loops, so nothing to do. */
- 	if (system_state < SYSTEM_RUNNING)
-		return 1;
-
-	pcpu = find_physical_cpu_to_start(get_hard_smp_processor_id(lcpu));
-	if (pcpu == -1U) {
-		printk(KERN_INFO "No more cpus available, failing\n");
-		return 0;
-	}
-
-	/* Fixup atomic count: it exited inside IRQ handler. */
-	paca[lcpu].__current->thread_info->preempt_count	= 0;
-
-	/* At boot this is done in prom.c. */
-	paca[lcpu].hw_cpu_id = pcpu;
-
-	status = rtas_call(rtas_token("start-cpu"), 3, 1, NULL,
-			   pcpu, start_here, lcpu);
-	if (status != 0) {
-		printk(KERN_ERR "start-cpu failed: %i\n", status);
-		return 0;
-	}
-	return 1;
-}
-#else /* ... CONFIG_HOTPLUG_CPU */
-static inline int __devinit smp_startup_cpu(unsigned int lcpu)
-{
-	return 1;
-}
-#endif /* CONFIG_HOTPLUG_CPU */
-
-static void smp_pSeries_kick_cpu(int nr)
+void __devinit smp_generic_kick_cpu(int nr)
 {
 	BUG_ON(nr < 0 || nr >= NR_CPUS);
 
-	if (!smp_startup_cpu(nr))
-		return;
-
 	/*
 	 * The processor is currently spinning, waiting for the
 	 * cpu_start field to become non-zero After we set cpu_start,
 	 * the processor will continue on to secondary_start
 	 */
 	paca[nr].cpu_start = 1;
+	mb();
 }
-#endif /* CONFIG_PPC_PSERIES */
+
+#endif /* CONFIG_PPC_MULTIPLATFORM */
 
 static void __init smp_space_timers(unsigned int max_cpus)
 {
@@ -457,136 +157,6 @@
 	}
 }
 
-#ifdef CONFIG_PPC_PSERIES
-static void vpa_init(int cpu)
-{
-	unsigned long flags, pcpu = get_hard_smp_processor_id(cpu);
-
-	/* Register the Virtual Processor Area (VPA) */
-	flags = 1UL << (63 - 18);
-	register_vpa(flags, pcpu, __pa((unsigned long)&(paca[cpu].lppaca)));
-}
-
-static inline void smp_xics_do_message(int cpu, int msg)
-{
-	set_bit(msg, &xics_ipi_message[cpu].value);
-	mb();
-	xics_cause_IPI(cpu);
-}
-
-static void smp_xics_message_pass(int target, int msg)
-{
-	unsigned int i;
-
-	if (target < NR_CPUS) {
-		smp_xics_do_message(target, msg);
-	} else {
-		for_each_online_cpu(i) {
-			if (target == MSG_ALL_BUT_SELF
-			    && i == smp_processor_id())
-				continue;
-			smp_xics_do_message(i, msg);
-		}
-	}
-}
-
-extern void xics_request_IPIs(void);
-
-static int __init smp_xics_probe(void)
-{
-#ifdef CONFIG_SMP
-	xics_request_IPIs();
-#endif
-
-	return cpus_weight(cpu_possible_map);
-}
-
-static void __devinit smp_xics_setup_cpu(int cpu)
-{
-	if (cpu != boot_cpuid)
-		xics_setup_cpu();
-}
-
-static spinlock_t timebase_lock = SPIN_LOCK_UNLOCKED;
-static unsigned long timebase = 0;
-
-static void __devinit pSeries_give_timebase(void)
-{
-	spin_lock(&timebase_lock);
-	rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
-	timebase = get_tb();
-	spin_unlock(&timebase_lock);
-
-	while (timebase)
-		barrier();
-	rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
-}
-
-static void __devinit pSeries_take_timebase(void)
-{
-	while (!timebase)
-		barrier();
-	spin_lock(&timebase_lock);
-	set_tb(timebase >> 32, timebase & 0xffffffff);
-	timebase = 0;
-	spin_unlock(&timebase_lock);
-}
-
-static struct smp_ops_t pSeries_openpic_smp_ops = {
-	.message_pass	= smp_openpic_message_pass,
-	.probe		= smp_openpic_probe,
-	.kick_cpu	= smp_pSeries_kick_cpu,
-	.setup_cpu	= smp_openpic_setup_cpu,
-};
-
-static struct smp_ops_t pSeries_xics_smp_ops = {
-	.message_pass	= smp_xics_message_pass,
-	.probe		= smp_xics_probe,
-	.kick_cpu	= smp_pSeries_kick_cpu,
-	.setup_cpu	= smp_xics_setup_cpu,
-};
-
-/* This is called very early */
-void __init smp_init_pSeries(void)
-{
-	int ret, i;
-
-	DBG(" -> smp_init_pSeries()\n");
-
-	if (naca->interrupt_controller == IC_OPEN_PIC)
-		smp_ops = &pSeries_openpic_smp_ops;
-	else
-		smp_ops = &pSeries_xics_smp_ops;
-
-	/* Start secondary threads on SMT systems; primary threads
-	 * are already in the running state.
-	 */
-	for_each_present_cpu(i) {
-		if (query_cpu_stopped(get_hard_smp_processor_id(i)) == 0) {
-			printk("%16.16x : starting thread\n", i);
-			DBG("%16.16x : starting thread\n", i);
-			rtas_call(rtas_token("start-cpu"), 3, 1, &ret,
-				  get_hard_smp_processor_id(i),
-				  __pa((u32)*((unsigned long *)
-					      pseries_secondary_smp_init)),
-				  i);
-		}
-	}
-
-	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR)
-		vpa_init(boot_cpuid);
-
-	/* Non-lpar has additional take/give timebase */
-	if (systemcfg->platform == PLATFORM_PSERIES) {
-		smp_ops->give_timebase = pSeries_give_timebase;
-		smp_ops->take_timebase = pSeries_take_timebase;
-	}
-
-
-	DBG(" <- smp_init_pSeries()\n");
-}
-#endif /* CONFIG_PPC_PSERIES */
-
 void smp_local_timer_interrupt(struct pt_regs * regs)
 {
 	update_process_times(user_mode(regs));
@@ -809,6 +379,8 @@
 {
 	unsigned int cpu;
 
+	DBG("smp_prepare_cpus\n");
+
 	/* 
 	 * setup_cpu may need to be called on the boot cpu. We havent
 	 * spun any cpus up but lets be paranoid.
@@ -833,9 +405,6 @@
 
 	max_cpus = smp_ops->probe();
  
-	/* Backup CPU 0 state if necessary */
-	__save_cpu_setup();
-
 	smp_space_timers(max_cpus);
 
 	for_each_cpu(cpu)
@@ -876,6 +445,11 @@
 		paca[cpu].stab_real = virt_to_abs(tmp);
 	}
 
+	/* Make sure callin-map entry is 0 (can be leftover a CPU
+	 * hotplug
+	 */
+	cpu_callin_map[cpu] = 0;
+
 	/* The information for processor bringup must
 	 * be written out to main store before we release
 	 * the processor.
@@ -883,6 +457,7 @@
 	mb();
 
 	/* wake up cpus */
+	DBG("smp: kicking cpu %d\n", cpu);
 	smp_ops->kick_cpu(cpu);
 
 	/*
@@ -922,7 +497,7 @@
 	return 0;
 }
 
-extern unsigned int default_distrib_server;
+
 /* Activate a secondary processor. */
 int __devinit start_secondary(void *unused)
 {
@@ -939,20 +514,8 @@
 	if (smp_ops->take_timebase)
 		smp_ops->take_timebase();
 
-#ifdef CONFIG_PPC_PSERIES
-	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
-		vpa_init(cpu); 
-	}
-
-#ifdef CONFIG_IRQ_ALL_CPUS
-	/* Put the calling processor into the GIQ.  This is really only
-	 * necessary from a secondary thread as the OF start-cpu interface
-	 * performs this function for us on primary threads.
-	 */
-	/* TODO: 9005 is #defined in rtas-proc.c -- move to a header */
-	rtas_set_indicator(9005, default_distrib_server, 1);
-#endif
-#endif
+	if (smp_ops->late_setup_cpu)
+		smp_ops->late_setup_cpu(cpu);
 
 	spin_lock(&call_lock);
 	cpu_set(cpu, cpu_online_map);
diff -Nru a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c
--- a/arch/ppc64/kernel/sys_ppc32.c	2004-12-24 13:37:02 -08:00
+++ b/arch/ppc64/kernel/sys_ppc32.c	2004-12-24 13:37:02 -08:00
@@ -621,8 +621,11 @@
 
 	error = compat_do_execve(filename, compat_ptr(a1), compat_ptr(a2), regs);
 
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 
 out:
@@ -1325,3 +1328,21 @@
 
 	return err;
 }
+
+asmlinkage long sys32_add_key(const char __user *_type,
+			      const char __user *_description,
+			      const void __user *_payload,
+			      u32 plen,
+			      u32 ringid)
+{
+	return sys_add_key(_type, _description, _payload, plen, ringid);
+}
+
+asmlinkage long sys32_request_key(const char __user *_type,
+				  const char __user *_description,
+				  const char __user *_callout_info,
+				  u32 destringid)
+{
+	return sys_request_key(_type, _description, _callout_info, destringid);
+}
+
diff -Nru a/arch/ppc64/kernel/sysfs.c b/arch/ppc64/kernel/sysfs.c
--- a/arch/ppc64/kernel/sysfs.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/kernel/sysfs.c	2004-12-24 13:36:18 -08:00
@@ -6,6 +6,8 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/module.h>
+#include <linux/nodemask.h>
+
 #include <asm/current.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
@@ -15,8 +17,7 @@
 
 /* SMT stuff */
 
-#ifndef CONFIG_PPC_ISERIES
-
+#ifdef CONFIG_PPC_MULTIPLATFORM
 /* default to snooze disabled */
 DEFINE_PER_CPU(unsigned long, smt_snooze_delay);
 
@@ -92,19 +93,6 @@
 }
 __setup("smt-snooze-delay=", setup_smt_snooze_delay);
 
-#endif
-
-
-/* PMC stuff */
-
-#ifdef CONFIG_PPC_ISERIES
-void ppc64_enable_pmcs(void)
-{
-	/* XXX Implement for iseries */
-}
-#endif
-
-#ifdef CONFIG_PPC_MULTIPLATFORM
 /*
  * Enabling PMCs will slow partition context switch times so we only do
  * it the first time we write to the PMCs.
@@ -180,6 +168,14 @@
 		mtspr(CTRLT, ctrl);
 	}
 #endif /* CONFIG_PPC_PSERIES */
+}
+
+#else
+
+/* PMC stuff */
+void ppc64_enable_pmcs(void)
+{
+	/* XXX Implement for iseries */
 }
 #endif /* CONFIG_PPC_MULTIPLATFORM */
 
diff -Nru a/arch/ppc64/kernel/time.c b/arch/ppc64/kernel/time.c
--- a/arch/ppc64/kernel/time.c	2004-12-24 13:37:19 -08:00
+++ b/arch/ppc64/kernel/time.c	2004-12-24 13:37:19 -08:00
@@ -49,6 +49,7 @@
 #include <linux/init.h>
 #include <linux/profile.h>
 #include <linux/cpu.h>
+#include <linux/security.h>
 
 #include <asm/segment.h>
 #include <asm/io.h>
@@ -277,6 +278,9 @@
 			write_seqlock(&xtime_lock);
 			tb_last_stamp = lpaca->next_jiffy_update_tb;
 			do_timer(regs);
+#ifndef CONFIG_SMP
+			update_process_times(user_mode(regs));
+#endif
 			timer_sync_xtime( cur_tb );
 			timer_check_rtc();
 			write_sequnlock(&xtime_lock);
@@ -431,9 +435,7 @@
 {
 	int value;
 	struct timespec myTimeval;
-
-	if (!capable(CAP_SYS_TIME))
-		return -EPERM;
+	int err;
 
 	if (get_user(value, tptr))
 		return -EFAULT;
@@ -441,6 +443,10 @@
 	myTimeval.tv_sec = value;
 	myTimeval.tv_nsec = 0;
 
+	err = security_settime(&myTimeval, NULL);
+	if (err)
+		return err;
+
 	do_settimeofday(&myTimeval);
 
 	return 0;
@@ -456,15 +462,17 @@
 {
 	long value;
 	struct timespec myTimeval;
-
-	if (!capable(CAP_SYS_TIME))
-		return -EPERM;
+	int err;
 
 	if (get_user(value, tptr))
 		return -EFAULT;
 
 	myTimeval.tv_sec = value;
 	myTimeval.tv_nsec = 0;
+
+	err = security_settime(&myTimeval, NULL);
+	if (err)
+		return err;
 
 	do_settimeofday(&myTimeval);
 
diff -Nru a/arch/ppc64/kernel/u3_iommu.c b/arch/ppc64/kernel/u3_iommu.c
--- a/arch/ppc64/kernel/u3_iommu.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc64/kernel/u3_iommu.c	2004-12-24 13:37:29 -08:00
@@ -267,6 +267,7 @@
 
 void iommu_setup_u3(void)
 {
+	struct pci_controller *phb, *tmp;
 	struct pci_dev *dev = NULL;
 	struct device_node *dn;
 
@@ -290,7 +291,7 @@
 	/* We only have one iommu table on the mac for now, which makes
 	 * things simple. Setup all PCI devices to point to this table
 	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		/* We must use pci_device_to_OF_node() to make sure that
 		 * we get the real "final" pointer to the device in the
 		 * pci_dev sysdata and not the temporary PHB one
@@ -298,6 +299,11 @@
 		struct device_node *dn = pci_device_to_OF_node(dev);
 		if (dn)
 			dn->iommu_table = &iommu_table_u3;
+	}
+	/* We also make sure we set all PHBs ... */
+	list_for_each_entry_safe(phb, tmp, &hose_list, list_node) {
+		dn = (struct device_node *)phb->arch_data;
+		dn->iommu_table = &iommu_table_u3;
 	}
 }
 
diff -Nru a/arch/ppc64/kernel/udbg.c b/arch/ppc64/kernel/udbg.c
--- a/arch/ppc64/kernel/udbg.c	2004-12-24 13:36:17 -08:00
+++ b/arch/ppc64/kernel/udbg.c	2004-12-24 13:36:17 -08:00
@@ -11,6 +11,8 @@
 
 #include <stdarg.h>
 #define WANT_PPCDBG_TAB /* Only defined here */
+#include <linux/config.h>
+#include <linux/types.h>
 #include <asm/ppcdebug.h>
 #include <asm/processor.h>
 #include <asm/naca.h>
@@ -20,6 +22,9 @@
 #include <asm/prom.h>
 #include <asm/pmac_feature.h>
 
+extern u8 real_readb(volatile u8 __iomem  *addr);
+extern void real_writeb(u8 data, volatile u8 __iomem *addr);
+
 struct NS16550 {
 	/* this struct must be packed */
 	unsigned char rbr;  /* 0 */
@@ -47,21 +52,25 @@
 #define LSR_TEMT 0x40  /* Xmitter empty */
 #define LSR_ERR  0x80  /* Error */
 
-static volatile struct NS16550 *udbg_comport;
+static volatile struct NS16550 __iomem *udbg_comport;
 
-void udbg_init_uart(void *comport)
+void udbg_init_uart(void __iomem *comport, unsigned int speed)
 {
+	u16 dll = speed ? (115200 / speed) : 12;
+
 	if (comport) {
-		udbg_comport = (struct NS16550 *)comport;
-		udbg_comport->lcr = 0x00; eieio();
-		udbg_comport->ier = 0xFF; eieio();
-		udbg_comport->ier = 0x00; eieio();
-		udbg_comport->lcr = 0x80; eieio();	/* Access baud rate */
-		udbg_comport->dll = 12;   eieio();	/* 1 = 115200,  2 = 57600, 3 = 38400, 12 = 9600 baud */
-		udbg_comport->dlm = 0;    eieio();	/* dll >> 8 which should be zero for fast rates; */
-		udbg_comport->lcr = 0x03; eieio();	/* 8 data, 1 stop, no parity */
-		udbg_comport->mcr = 0x03; eieio();	/* RTS/DTR */
-		udbg_comport->fcr = 0x07; eieio();	/* Clear & enable FIFOs */
+		udbg_comport = (struct NS16550 __iomem *)comport;
+		out_8(&udbg_comport->lcr, 0x00);
+		out_8(&udbg_comport->ier, 0xff);
+		out_8(&udbg_comport->ier, 0x00);
+		out_8(&udbg_comport->lcr, 0x80);	/* Access baud rate */
+		out_8(&udbg_comport->dll, dll & 0xff);	/* 1 = 115200,  2 = 57600,
+							   3 = 38400, 12 = 9600 baud */
+		out_8(&udbg_comport->dlm, dll >> 8);	/* dll >> 8 which should be zero
+							   for fast rates; */
+		out_8(&udbg_comport->lcr, 0x03);	/* 8 data, 1 stop, no parity */
+		out_8(&udbg_comport->mcr, 0x03);	/* RTS/DTR */
+		out_8(&udbg_comport->fcr ,0x07);	/* Clear & enable FIFOs */
 	}
 }
 
@@ -70,7 +79,8 @@
 #define	SCC_TXRDY	4
 #define SCC_RXRDY	1
 
-static volatile u8 *sccc, *sccd;
+static volatile u8 __iomem *sccc;
+static volatile u8 __iomem *sccd;
 
 static unsigned char scc_inittab[] = {
     13, 0,		/* set baud rate divisor */
@@ -109,7 +119,7 @@
 
 	/* Setup for 57600 8N1 */
 	addr += 0x20;
-	sccc = (volatile u8 *) ioremap(addr & PAGE_MASK, PAGE_SIZE) ;
+	sccc = (volatile u8 * __iomem) ioremap(addr & PAGE_MASK, PAGE_SIZE) ;
 	sccc += addr & ~PAGE_MASK;
 	sccd = sccc + 0x10;
 
@@ -117,13 +127,11 @@
 	mb();
 
 	for (i = 20000; i != 0; --i)
-		x = *sccc; eieio();
-	*sccc = 9; eieio();		/* reset A or B side */
-	*sccc = 0xc0; eieio();
-	for (i = 0; i < sizeof(scc_inittab); ++i) {
-		*sccc = scc_inittab[i];
-		eieio();
-	}
+		x = in_8(sccc);
+	out_8(sccc, 0x09);		/* reset A or B side */
+	out_8(sccc, 0xc0);
+	for (i = 0; i < sizeof(scc_inittab); ++i)
+		out_8(sccc, scc_inittab[i]);
 
 	ppc_md.udbg_putc = udbg_putc;
 	ppc_md.udbg_getc = udbg_getc;
@@ -135,9 +143,6 @@
 #endif /* CONFIG_PPC_PMAC */
 
 #if CONFIG_PPC_PMAC
-extern u8 real_readb(volatile u8 *addr);
-extern void real_writeb(u8 data, volatile u8 *addr);
-
 static void udbg_real_putc(unsigned char c)
 {
 	while ((real_readb(sccc) & SCC_TXRDY) == 0)
@@ -149,8 +154,8 @@
 
 void udbg_init_pmac_realmode(void)
 {
-	sccc = (volatile u8 *)0x80013020ul;
-	sccd = (volatile u8 *)0x80013030ul;
+	sccc = (volatile u8 __iomem *)0x80013020ul;
+	sccd = (volatile u8 __iomem *)0x80013030ul;
 
 	ppc_md.udbg_putc = udbg_real_putc;
 	ppc_md.udbg_getc = NULL;
@@ -158,25 +163,50 @@
 }
 #endif /* CONFIG_PPC_PMAC */
 
-void udbg_putc(unsigned char c)
+#ifdef CONFIG_PPC_MAPLE
+void udbg_maple_real_putc(unsigned char c)
 {
 	if (udbg_comport) {
-		while ((udbg_comport->lsr & LSR_THRE) == 0)
+		while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
 			/* wait for idle */;
-		udbg_comport->thr = c; eieio();
+		real_writeb(c, &udbg_comport->thr); eieio();
 		if (c == '\n') {
 			/* Also put a CR.  This is for convenience. */
-			while ((udbg_comport->lsr & LSR_THRE) == 0)
+			while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
 				/* wait for idle */;
-			udbg_comport->thr = '\r'; eieio();
+			real_writeb('\r', &udbg_comport->thr); eieio();
+		}
+	}
+}
+
+void udbg_init_maple_realmode(void)
+{
+	udbg_comport = (volatile struct NS16550 __iomem *)0xf40003f8;
+
+	ppc_md.udbg_putc = udbg_maple_real_putc;
+	ppc_md.udbg_getc = NULL;
+	ppc_md.udbg_getc_poll = NULL;
+}
+#endif /* CONFIG_PPC_MAPLE */
+
+void udbg_putc(unsigned char c)
+{
+	if (udbg_comport) {
+		while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0)
+			/* wait for idle */;
+		out_8(&udbg_comport->thr, c);
+		if (c == '\n') {
+			/* Also put a CR.  This is for convenience. */
+			while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0)
+				/* wait for idle */; 
+			out_8(&udbg_comport->thr, '\r');
 		}
 	}
 #ifdef CONFIG_PPC_PMAC
 	else if (sccc) {
-		while ((*sccc & SCC_TXRDY) == 0)
-			eieio();
-		*sccd = c;		
-		eieio();
+		while ((in_8(sccc) & SCC_TXRDY) == 0)
+			;
+		out_8(sccd,  c);		
 		if (c == '\n')
 			udbg_putc('\r');
 	}
@@ -186,16 +216,15 @@
 int udbg_getc_poll(void)
 {
 	if (udbg_comport) {
-		if ((udbg_comport->lsr & LSR_DR) != 0)
-			return udbg_comport->rbr;
+		if ((in_8(&udbg_comport->lsr) & LSR_DR) != 0)
+			return in_8(&udbg_comport->rbr);
 		else
 			return -1;
 	}
 #ifdef CONFIG_PPC_PMAC
 	else if (sccc) {
-		eieio();
-		if ((*sccc & SCC_RXRDY) != 0)
-			return *sccd;
+		if ((in_8(sccc) & SCC_RXRDY) != 0)
+			return in_8(sccd);
 		else
 			return -1;
 	}
@@ -206,16 +235,15 @@
 unsigned char udbg_getc(void)
 {
 	if (udbg_comport) {
-		while ((udbg_comport->lsr & LSR_DR) == 0)
+		while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0)
 			/* wait for char */;
-		return udbg_comport->rbr;
+		return in_8(&udbg_comport->rbr);
 	}
 #ifdef CONFIG_PPC_PMAC
 	else if (sccc) {
-		eieio();
-		while ((*sccc & SCC_RXRDY) == 0)
-			eieio();
-		return *sccd;
+		while ((in_8(sccc) & SCC_RXRDY) == 0)
+			;
+		return in_8(sccd);
 	}
 #endif /* CONFIG_PPC_PMAC */
 	return 0;
diff -Nru a/arch/ppc64/kernel/vecemu.c b/arch/ppc64/kernel/vecemu.c
--- a/arch/ppc64/kernel/vecemu.c	2004-12-24 13:36:16 -08:00
+++ b/arch/ppc64/kernel/vecemu.c	2004-12-24 13:36:16 -08:00
@@ -263,7 +263,7 @@
 	unsigned int va, vb, vc, vd;
 	vector128 *vrs;
 
-	if (get_user(instr, (unsigned int *) regs->nip))
+	if (get_user(instr, (unsigned int __user *) regs->nip))
 		return -EFAULT;
 	if ((instr >> 26) != 4)
 		return -EINVAL;		/* not an altivec instruction */
diff -Nru a/arch/ppc64/kernel/vio.c b/arch/ppc64/kernel/vio.c
--- a/arch/ppc64/kernel/vio.c	2004-12-24 13:36:31 -08:00
+++ b/arch/ppc64/kernel/vio.c	2004-12-24 13:36:31 -08:00
@@ -521,24 +521,7 @@
 
 	newTceTable = (struct iommu_table *) kmalloc(sizeof(struct iommu_table), GFP_KERNEL);
 
-	/* RPA docs say that #address-cells is always 1 for virtual
-		devices, but some older boxes' OF returns 2.  This should
-		be removed by GA, unless there is legacy OFs that still
-		have 2 for #address-cells */
-	size = ((dma_window[1+vio_num_address_cells] >> PAGE_SHIFT) << 3)
-		>> PAGE_SHIFT;
-
-	/* This is just an ugly kludge. Remove as soon as the OF for all
-	machines actually follow the spec and encodes the offset field
-	as phys-encode (that is, #address-cells wide)*/
-	if (dma_window_property_size == 12) {
-		size = ((dma_window[1] >> PAGE_SHIFT) << 3) >> PAGE_SHIFT;
-	} else if (dma_window_property_size == 20) {
-		size = ((dma_window[4] >> PAGE_SHIFT) << 3) >> PAGE_SHIFT;
-	} else {
-		printk(KERN_WARNING "vio_build_iommu_table: Invalid size of ibm,my-dma-window=%i, using 0x80 for size\n", dma_window_property_size);
-		size = 0x80;
-	}
+	size = ((dma_window[4] >> PAGE_SHIFT) << 3) >> PAGE_SHIFT;
 
 	/*  There should be some code to extract the phys-encoded offset
 		using prom_n_addr_cells(). However, according to a comment
diff -Nru a/arch/ppc64/kernel/viopath.c b/arch/ppc64/kernel/viopath.c
--- a/arch/ppc64/kernel/viopath.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/kernel/viopath.c	2004-12-24 13:36:18 -08:00
@@ -473,7 +473,7 @@
 		parms.used_wait_atomic = 0;
 		parms.sem = &Semaphore;
 	}
-	mf_allocateLpEvents(remoteLp, HvLpEvent_Type_VirtualIo, 250,	/* It would be nice to put a real number here! */
+	mf_allocate_lp_events(remoteLp, HvLpEvent_Type_VirtualIo, 250,	/* It would be nice to put a real number here! */
 			    numEvents, &viopath_donealloc, &parms);
 	if (in_atomic()) {
 		while (atomic_read(&wait_atomic))
@@ -582,7 +582,7 @@
 
 	doneAllocParms.used_wait_atomic = 0;
 	doneAllocParms.sem = &Semaphore;
-	mf_deallocateLpEvents(remoteLp, HvLpEvent_Type_VirtualIo,
+	mf_deallocate_lp_events(remoteLp, HvLpEvent_Type_VirtualIo,
 			      numReq, &viopath_donealloc, &doneAllocParms);
 	down(&Semaphore);
 
diff -Nru a/arch/ppc64/kernel/xics.c b/arch/ppc64/kernel/xics.c
--- a/arch/ppc64/kernel/xics.c	2004-12-24 13:36:56 -08:00
+++ b/arch/ppc64/kernel/xics.c	2004-12-24 13:36:56 -08:00
@@ -85,7 +85,7 @@
 	} qirr;
 };
 
-static struct xics_ipl *xics_per_cpu[NR_CPUS];
+static struct xics_ipl __iomem *xics_per_cpu[NR_CPUS];
 
 static int xics_irq_8259_cascade = 0;
 static int xics_irq_8259_cascade_real = 0;
@@ -116,22 +116,22 @@
 
 static int pSeries_xirr_info_get(int n_cpu)
 {
-	return xics_per_cpu[n_cpu]->xirr.word;
+	return in_be32(&xics_per_cpu[n_cpu]->xirr.word);
 }
 
 static void pSeries_xirr_info_set(int n_cpu, int value)
 {
-	xics_per_cpu[n_cpu]->xirr.word = value;
+	out_be32(&xics_per_cpu[n_cpu]->xirr.word, value);
 }
 
 static void pSeries_cppr_info(int n_cpu, u8 value)
 {
-	xics_per_cpu[n_cpu]->xirr.bytes[0] = value;
+	out_8(&xics_per_cpu[n_cpu]->xirr.bytes[0], value);
 }
 
 static void pSeries_qirr_info(int n_cpu, u8 value)
 {
-	xics_per_cpu[n_cpu]->qirr.bytes[0] = value;
+	out_8(&xics_per_cpu[n_cpu]->qirr.bytes[0], value);
 }
 
 static xics_ops pSeries_ops = {
@@ -216,12 +216,15 @@
 
 static unsigned int xics_startup(unsigned int virq)
 {
-	virq = irq_offset_down(virq);
-	if (radix_tree_insert(&irq_map, virt_irq_to_real(virq),
-			      &virt_irq_to_real_map[virq]) == -ENOMEM)
+	unsigned int irq;
+
+	irq = irq_offset_down(virq);
+	if (radix_tree_insert(&irq_map, virt_irq_to_real(irq),
+			      &virt_irq_to_real_map[irq]) == -ENOMEM)
 		printk(KERN_CRIT "Out of memory creating real -> virtual"
 		       " IRQ mapping for irq %u (real 0x%x)\n",
-		       virq, virt_irq_to_real(virq));
+		       virq, virt_irq_to_real(irq));
+	xics_enable_irq(virq);
 	return 0;	/* return value is ignored */
 }
 
@@ -454,7 +457,7 @@
 	struct xics_interrupt_node {
 		unsigned long addr;
 		unsigned long size;
-	} inodes[NR_CPUS]; 
+	} intnodes[NR_CPUS]; 
 
 	ppc64_boot_msg(0x20, "XICS Init");
 
@@ -481,13 +484,13 @@
 		panic("xics_init_IRQ: can't find interrupt reg property");
 	
 	while (ilen) {
-		inodes[indx].addr = (unsigned long long)*ireg++ << 32;
+		intnodes[indx].addr = (unsigned long)*ireg++ << 32;
 		ilen -= sizeof(uint);
-		inodes[indx].addr |= *ireg++;
+		intnodes[indx].addr |= *ireg++;
 		ilen -= sizeof(uint);
-		inodes[indx].size = (unsigned long long)*ireg++ << 32;
+		intnodes[indx].size = (unsigned long)*ireg++ << 32;
 		ilen -= sizeof(uint);
-		inodes[indx].size |= *ireg++;
+		intnodes[indx].size |= *ireg++;
 		ilen -= sizeof(uint);
 		indx++;
 		if (indx >= NR_CPUS) break;
@@ -501,8 +504,9 @@
 	     np;
 	     np = of_find_node_by_type(np, "cpu")) {
 		ireg = (uint *)get_property(np, "reg", &ilen);
-		if (ireg && ireg[0] == hard_smp_processor_id()) {
-			ireg = (uint *)get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen);
+		if (ireg && ireg[0] == boot_cpuid_phys) {
+			ireg = (uint *)get_property(np, "ibm,ppc-interrupt-gserver#s",
+						    &ilen);
 			i = ilen / sizeof(int);
 			if (ireg && i > 0) {
 				default_server = ireg[0];
@@ -513,8 +517,8 @@
 	}
 	of_node_put(np);
 
-	intr_base = inodes[0].addr;
-	intr_size = (ulong)inodes[0].size;
+	intr_base = intnodes[0].addr;
+	intr_size = intnodes[0].size;
 
 	np = of_find_node_by_type(NULL, "interrupt-controller");
 	if (!np) {
@@ -535,16 +539,18 @@
 	if (systemcfg->platform == PLATFORM_PSERIES) {
 #ifdef CONFIG_SMP
 		for_each_cpu(i) {
+			int hard_id;
+
 			/* FIXME: Do this dynamically! --RR */
 			if (!cpu_present(i))
 				continue;
-			xics_per_cpu[i] = __ioremap((ulong)inodes[get_hard_smp_processor_id(i)].addr, 
-						    (ulong)inodes[get_hard_smp_processor_id(i)].size,
-						    _PAGE_NO_CACHE);
+
+			hard_id = get_hard_smp_processor_id(i);
+			xics_per_cpu[i] = ioremap(intnodes[hard_id].addr, 
+						  intnodes[hard_id].size);
 		}
 #else
-		xics_per_cpu[0] = __ioremap((ulong)intr_base, intr_size,
-					    _PAGE_NO_CACHE);
+		xics_per_cpu[0] = ioremap(intr_base, intr_size);
 #endif /* CONFIG_SMP */
 	} else if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
 		ops = &pSeriesLP_ops;
@@ -575,7 +581,7 @@
 				no_action, 0, "8259 cascade", NULL))
 			printk(KERN_ERR "xics_setup_i8259: couldn't get 8259 "
 					"cascade\n");
-		i8259_init();
+		i8259_init(0);
 	}
 	return 0;
 }
diff -Nru a/arch/ppc64/lib/Makefile b/arch/ppc64/lib/Makefile
--- a/arch/ppc64/lib/Makefile	2004-12-24 13:37:43 -08:00
+++ b/arch/ppc64/lib/Makefile	2004-12-24 13:37:43 -08:00
@@ -15,3 +15,4 @@
 obj-$(CONFIG_PCI)	+= e2a.o
 endif
 
+lib-$(CONFIG_XMON) += sstep.o
diff -Nru a/arch/ppc64/lib/dec_and_lock.c b/arch/ppc64/lib/dec_and_lock.c
--- a/arch/ppc64/lib/dec_and_lock.c	2004-12-24 13:36:47 -08:00
+++ b/arch/ppc64/lib/dec_and_lock.c	2004-12-24 13:36:47 -08:00
@@ -28,7 +28,7 @@
  */
 
 #ifndef ATOMIC_DEC_AND_LOCK
-int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
+int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
 {
 	int counter;
 	int newcount;
@@ -51,5 +51,5 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
 #endif /* ATOMIC_DEC_AND_LOCK */
diff -Nru a/arch/ppc64/lib/sstep.c b/arch/ppc64/lib/sstep.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/ppc64/lib/sstep.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,141 @@
+/*
+ * Single-step support.
+ *
+ * Copyright (C) 2004 Paul Mackerras <paulus@au.ibm.com>, IBM
+ *
+ * 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/ptrace.h>
+#include <asm/sstep.h>
+#include <asm/processor.h>
+
+extern char SystemCall_common[];
+
+/* Bits in SRR1 that are copied from MSR */
+#define MSR_MASK	0xffffffff87c0ffff
+
+/*
+ * Determine whether a conditional branch instruction would branch.
+ */
+static int branch_taken(unsigned int instr, struct pt_regs *regs)
+{
+	unsigned int bo = (instr >> 21) & 0x1f;
+	unsigned int bi;
+
+	if ((bo & 4) == 0) {
+		/* decrement counter */
+		--regs->ctr;
+		if (((bo >> 1) & 1) ^ (regs->ctr == 0))
+			return 0;
+	}
+	if ((bo & 0x10) == 0) {
+		/* check bit from CR */
+		bi = (instr >> 16) & 0x1f;
+		if (((regs->ccr >> (31 - bi)) & 1) != ((bo >> 3) & 1))
+			return 0;
+	}
+	return 1;
+}
+
+/*
+ * Emulate instructions that cause a transfer of control.
+ * Returns 1 if the step was emulated, 0 if not,
+ * or -1 if the instruction is one that should not be stepped,
+ * such as an rfid, or a mtmsrd that would clear MSR_RI.
+ */
+int emulate_step(struct pt_regs *regs, unsigned int instr)
+{
+	unsigned int opcode, rd;
+	unsigned long int imm;
+
+	opcode = instr >> 26;
+	switch (opcode) {
+	case 16:	/* bc */
+		imm = (signed short)(instr & 0xfffc);
+		if ((instr & 2) == 0)
+			imm += regs->nip;
+		regs->nip += 4;
+		if ((regs->msr & MSR_SF) == 0)
+			regs->nip &= 0xffffffffUL;
+		if (instr & 1)
+			regs->link = regs->nip;
+		if (branch_taken(instr, regs))
+			regs->nip = imm;
+		return 1;
+	case 17:	/* sc */
+		/*
+		 * N.B. this uses knowledge about how the syscall
+		 * entry code works.  If that is changed, this will
+		 * need to be changed also.
+		 */
+		regs->gpr[9] = regs->gpr[13];
+		regs->gpr[11] = regs->nip + 4;
+		regs->gpr[12] = regs->msr & MSR_MASK;
+		regs->gpr[13] = (unsigned long) get_paca();
+		regs->nip = (unsigned long) &SystemCall_common;
+		regs->msr = MSR_KERNEL;
+		return 1;
+	case 18:	/* b */
+		imm = instr & 0x03fffffc;
+		if (imm & 0x02000000)
+			imm -= 0x04000000;
+		if ((instr & 2) == 0)
+			imm += regs->nip;
+		if (instr & 1) {
+			regs->link = regs->nip + 4;
+			if ((regs->msr & MSR_SF) == 0)
+				regs->link &= 0xffffffffUL;
+		}
+		if ((regs->msr & MSR_SF) == 0)
+			imm &= 0xffffffffUL;
+		regs->nip = imm;
+		return 1;
+	case 19:
+		switch (instr & 0x7fe) {
+		case 0x20:	/* bclr */
+		case 0x420:	/* bcctr */
+			imm = (instr & 0x400)? regs->ctr: regs->link;
+			regs->nip += 4;
+			if ((regs->msr & MSR_SF) == 0) {
+				regs->nip &= 0xffffffffUL;
+				imm &= 0xffffffffUL;
+			}
+			if (instr & 1)
+				regs->link = regs->nip;
+			if (branch_taken(instr, regs))
+				regs->nip = imm;
+			return 1;
+		case 0x24:	/* rfid, scary */
+			return -1;
+		}
+	case 31:
+		rd = (instr >> 21) & 0x1f;
+		switch (instr & 0x7fe) {
+		case 0xa6:	/* mfmsr */
+			regs->gpr[rd] = regs->msr & MSR_MASK;
+			regs->nip += 4;
+			if ((regs->msr & MSR_SF) == 0)
+				regs->nip &= 0xffffffffUL;
+			return 1;
+		case 0x164:	/* mtmsrd */
+			/* only MSR_EE and MSR_RI get changed if bit 15 set */
+			/* mtmsrd doesn't change MSR_HV and MSR_ME */
+			imm = (instr & 0x10000)? 0x8002: 0xefffffffffffefffUL;
+			imm = (regs->msr & MSR_MASK & ~imm)
+				| (regs->gpr[rd] & imm);
+			if ((imm & MSR_RI) == 0)
+				/* can't step mtmsrd that would clear MSR_RI */
+				return -1;
+			regs->msr = imm;
+			regs->nip += 4;
+			if ((imm & MSR_SF) == 0)
+				regs->nip &= 0xffffffffUL;
+			return 1;
+		}
+	}
+	return 0;
+}
diff -Nru a/arch/ppc64/mm/hash_native.c b/arch/ppc64/mm/hash_native.c
--- a/arch/ppc64/mm/hash_native.c	2004-12-24 13:36:47 -08:00
+++ b/arch/ppc64/mm/hash_native.c	2004-12-24 13:36:47 -08:00
@@ -387,33 +387,37 @@
 	local_irq_restore(flags);
 }
 
-void hpte_init_native(void)
-{
 #ifdef CONFIG_PPC_PSERIES
-	struct device_node *root;
-	const char *model;
-#endif /* CONFIG_PPC_PSERIES */
+/* Disable TLB batching on nighthawk */
+static inline int tlb_batching_enabled(void)
+{
+	struct device_node *root = of_find_node_by_path("/");
+	int enabled = 1;
+
+	if (root) {
+		const char *model = get_property(root, "model", NULL);
+		if (model && !strcmp(model, "IBM,9076-N81"))
+			enabled = 0;
+		of_node_put(root);
+	}
+
+	return enabled;
+}
+#else
+static inline int tlb_batching_enabled(void)
+{
+	return 1;
+}
+#endif
 
+void hpte_init_native(void)
+{
 	ppc_md.hpte_invalidate	= native_hpte_invalidate;
 	ppc_md.hpte_updatepp	= native_hpte_updatepp;
 	ppc_md.hpte_updateboltedpp = native_hpte_updateboltedpp;
 	ppc_md.hpte_insert	= native_hpte_insert;
 	ppc_md.hpte_remove     	= native_hpte_remove;
-
-#ifdef CONFIG_PPC_PSERIES
-	/* Disable TLB batching on nighthawk */
-	root = of_find_node_by_path("/");
-	if (root) {
-		model = get_property(root, "model", NULL);
-		if (!strcmp(model, "CHRP IBM,9076-N81")) {
-			of_node_put(root);
-			goto bail;
-		}
-		of_node_put(root);
-	}
-#endif /* CONFIG_PPC_PSERIES */
-
-	ppc_md.flush_hash_range = native_flush_hash_range;
- bail:
+	if (tlb_batching_enabled())
+		ppc_md.flush_hash_range = native_flush_hash_range;
 	htab_finish_init();
 }
diff -Nru a/arch/ppc64/mm/hash_utils.c b/arch/ppc64/mm/hash_utils.c
--- a/arch/ppc64/mm/hash_utils.c	2004-12-24 13:36:59 -08:00
+++ b/arch/ppc64/mm/hash_utils.c	2004-12-24 13:36:59 -08:00
@@ -341,9 +341,7 @@
 		     int local)
 {
 	unsigned long vsid, vpn, va, hash, secondary, slot;
-
-	/* XXX fix for large ptes */
-	unsigned long large = 0;
+	unsigned long huge = pte_huge(pte);
 
 	if ((ea >= USER_START) && (ea <= USER_END))
 		vsid = get_vsid(context, ea);
@@ -351,18 +349,18 @@
 		vsid = get_kernel_vsid(ea);
 
 	va = (vsid << 28) | (ea & 0x0fffffff);
-	if (large)
+	if (huge)
 		vpn = va >> HPAGE_SHIFT;
 	else
 		vpn = va >> PAGE_SHIFT;
-	hash = hpt_hash(vpn, large);
+	hash = hpt_hash(vpn, huge);
 	secondary = (pte_val(pte) & _PAGE_SECONDARY) >> 15;
 	if (secondary)
 		hash = ~hash;
 	slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
 	slot += (pte_val(pte) & _PAGE_GROUP_IX) >> 12;
 
-	ppc_md.hpte_invalidate(slot, va, large, local);
+	ppc_md.hpte_invalidate(slot, va, huge, local);
 }
 
 void flush_hash_range(unsigned long context, unsigned long number, int local)
@@ -401,7 +399,7 @@
 		info.si_signo = SIGBUS;
 		info.si_errno = 0;
 		info.si_code = BUS_ADRERR;
-		info.si_addr = (void *)address;
+		info.si_addr = (void __user *)address;
 		force_sig_info(SIGBUS, &info, current);
 		return;
 	}
diff -Nru a/arch/ppc64/mm/hugetlbpage.c b/arch/ppc64/mm/hugetlbpage.c
--- a/arch/ppc64/mm/hugetlbpage.c	2004-12-24 13:36:55 -08:00
+++ b/arch/ppc64/mm/hugetlbpage.c	2004-12-24 13:36:55 -08:00
@@ -27,116 +27,143 @@
 
 #include <linux/sysctl.h>
 
-/* HugePTE layout:
- *
- * 31 30 ... 15 14 13 12 10 9  8  7   6    5    4    3    2    1    0
- * PFN>>12..... -  -  -  -  -  -  HASH_IX....   2ND  HASH RW   -    HG=1
- */
+#define	HUGEPGDIR_SHIFT		(HPAGE_SHIFT + PAGE_SHIFT - 3)
+#define HUGEPGDIR_SIZE		(1UL << HUGEPGDIR_SHIFT)
+#define HUGEPGDIR_MASK		(~(HUGEPGDIR_SIZE-1))
+
+#define HUGEPTE_INDEX_SIZE	9
+#define HUGEPGD_INDEX_SIZE	10
+
+#define PTRS_PER_HUGEPTE	(1 << HUGEPTE_INDEX_SIZE)
+#define PTRS_PER_HUGEPGD	(1 << HUGEPGD_INDEX_SIZE)
 
-#define HUGEPTE_SHIFT	15
-#define _HUGEPAGE_PFN		0xffff8000
-#define _HUGEPAGE_BAD		0x00007f00
-#define _HUGEPAGE_HASHPTE	0x00000008
-#define _HUGEPAGE_SECONDARY	0x00000010
-#define _HUGEPAGE_GROUP_IX	0x000000e0
-#define _HUGEPAGE_HPTEFLAGS	(_HUGEPAGE_HASHPTE | _HUGEPAGE_SECONDARY | \
-				 _HUGEPAGE_GROUP_IX)
-#define _HUGEPAGE_RW		0x00000004
-
-typedef struct {unsigned int val;} hugepte_t;
-#define hugepte_val(hugepte)	((hugepte).val)
-#define __hugepte(x)		((hugepte_t) { (x) } )
-#define hugepte_pfn(x)		\
-	((unsigned long)(hugepte_val(x)>>HUGEPTE_SHIFT) << HUGETLB_PAGE_ORDER)
-#define mk_hugepte(page,wr)	__hugepte( \
-	((page_to_pfn(page)>>HUGETLB_PAGE_ORDER) << HUGEPTE_SHIFT ) \
-	| (!!(wr) * _HUGEPAGE_RW) | _PMD_HUGEPAGE )
-
-#define hugepte_bad(x)	( !(hugepte_val(x) & _PMD_HUGEPAGE) || \
-			  (hugepte_val(x) & _HUGEPAGE_BAD) )
-#define hugepte_page(x)	pfn_to_page(hugepte_pfn(x))
-#define hugepte_none(x)	(!(hugepte_val(x) & _HUGEPAGE_PFN))
-
-
-static void flush_hash_hugepage(mm_context_t context, unsigned long ea,
-				hugepte_t pte, int local);
-
-static inline unsigned int hugepte_update(hugepte_t *p, unsigned int clr,
-					  unsigned int set)
-{
-	unsigned int old, tmp;
-
-	__asm__ __volatile__(
-	"1:	lwarx	%0,0,%3		# pte_update\n\
-	andc	%1,%0,%4 \n\
-	or	%1,%1,%5 \n\
-	stwcx.	%1,0,%3 \n\
-	bne-	1b"
-	: "=&r" (old), "=&r" (tmp), "=m" (*p)
-	: "r" (p), "r" (clr), "r" (set), "m" (*p)
-	: "cc" );
-	return old;
+static inline int hugepgd_index(unsigned long addr)
+{
+	return (addr & ~REGION_MASK) >> HUGEPGDIR_SHIFT;
 }
 
-static inline void set_hugepte(hugepte_t *ptep, hugepte_t pte)
+static pgd_t *hugepgd_offset(struct mm_struct *mm, unsigned long addr)
 {
-	hugepte_update(ptep, ~_HUGEPAGE_HPTEFLAGS,
-		       hugepte_val(pte) & ~_HUGEPAGE_HPTEFLAGS);
+	int index;
+
+	if (! mm->context.huge_pgdir)
+		return NULL;
+
+
+	index = hugepgd_index(addr);
+	BUG_ON(index >= PTRS_PER_HUGEPGD);
+	return mm->context.huge_pgdir + index;
 }
 
-static hugepte_t *hugepte_alloc(struct mm_struct *mm, unsigned long addr)
+static inline pte_t *hugepte_offset(pgd_t *dir, unsigned long addr)
 {
-	pgd_t *pgd;
-	pmd_t *pmd = NULL;
+	int index;
 
-	BUG_ON(!in_hugepage_area(mm->context, addr));
+	if (pgd_none(*dir))
+		return NULL;
 
-	pgd = pgd_offset(mm, addr);
-	pmd = pmd_alloc(mm, pgd, addr);
+	index = (addr >> HPAGE_SHIFT) % PTRS_PER_HUGEPTE;
+	return (pte_t *)pgd_page(*dir) + index;
+}
 
-	/* We shouldn't find a (normal) PTE page pointer here */
-	BUG_ON(!pmd_none(*pmd) && !pmd_hugepage(*pmd));
-	
-	return (hugepte_t *)pmd;
+static pgd_t *hugepgd_alloc(struct mm_struct *mm, unsigned long addr)
+{
+	BUG_ON(! in_hugepage_area(mm->context, addr));
+
+	if (! mm->context.huge_pgdir) {
+		pgd_t *new;
+		spin_unlock(&mm->page_table_lock);
+		/* Don't use pgd_alloc(), because we want __GFP_REPEAT */
+		new = kmem_cache_alloc(zero_cache, GFP_KERNEL | __GFP_REPEAT);
+		BUG_ON(memcmp(new, empty_zero_page, PAGE_SIZE));
+		spin_lock(&mm->page_table_lock);
+
+		/*
+		 * Because we dropped the lock, we should re-check the
+		 * entry, as somebody else could have populated it..
+		 */
+		if (mm->context.huge_pgdir)
+			pgd_free(new);
+		else
+			mm->context.huge_pgdir = new;
+	}
+	return hugepgd_offset(mm, addr);
 }
 
-static hugepte_t *hugepte_offset(struct mm_struct *mm, unsigned long addr)
+static pte_t *hugepte_alloc(struct mm_struct *mm, pgd_t *dir,
+			    unsigned long addr)
 {
-	pgd_t *pgd;
-	pmd_t *pmd = NULL;
+	if (! pgd_present(*dir)) {
+		pte_t *new;
 
-	BUG_ON(!in_hugepage_area(mm->context, addr));
+		spin_unlock(&mm->page_table_lock);
+		new = kmem_cache_alloc(zero_cache, GFP_KERNEL | __GFP_REPEAT);
+		BUG_ON(memcmp(new, empty_zero_page, PAGE_SIZE));
+		spin_lock(&mm->page_table_lock);
+		/*
+		 * Because we dropped the lock, we should re-check the
+		 * entry, as somebody else could have populated it..
+		 */
+		if (pgd_present(*dir)) {
+			if (new)
+				kmem_cache_free(zero_cache, new);
+		} else {
+			struct page *ptepage;
 
-	pgd = pgd_offset(mm, addr);
-	if (pgd_none(*pgd))
-		return NULL;
+			if (! new)
+				return NULL;
+			ptepage = virt_to_page(new);
+			ptepage->mapping = (void *) mm;
+			ptepage->index = addr & HUGEPGDIR_MASK;
+			pgd_populate(mm, dir, new);
+		}
+	}
 
-	pmd = pmd_offset(pgd, addr);
+	return hugepte_offset(dir, addr);
+}
+
+static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+{
+	pgd_t *pgd;
 
-	/* We shouldn't find a (normal) PTE page pointer here */
-	BUG_ON(!pmd_none(*pmd) && !pmd_hugepage(*pmd));
+	BUG_ON(! in_hugepage_area(mm->context, addr));
 
-	return (hugepte_t *)pmd;
+	pgd = hugepgd_offset(mm, addr);
+	if (! pgd)
+		return NULL;
+
+	return hugepte_offset(pgd, addr);
 }
 
-static void setup_huge_pte(struct mm_struct *mm, struct page *page,
-			   hugepte_t *ptep, int write_access)
+static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
 {
-	hugepte_t entry;
-	int i;
+	pgd_t *pgd;
 
-	mm->rss += (HPAGE_SIZE / PAGE_SIZE);
-	entry = mk_hugepte(page, write_access);
-	for (i = 0; i < HUGEPTE_BATCH_SIZE; i++)
-		set_hugepte(ptep+i, entry);
+	BUG_ON(! in_hugepage_area(mm->context, addr));
+
+	pgd = hugepgd_alloc(mm, addr);
+	if (! pgd)
+		return NULL;
+
+	return hugepte_alloc(mm, pgd, addr);
 }
 
-static void teardown_huge_pte(hugepte_t *ptep)
+static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma,
+			 struct page *page, pte_t *ptep, int write_access)
 {
-	int i;
+	pte_t entry;
 
-	for (i = 0; i < HUGEPTE_BATCH_SIZE; i++)
-		pmd_clear((pmd_t *)(ptep+i));
+	mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+	if (write_access) {
+		entry =
+		    pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
+	} else {
+		entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
+	}
+	entry = pte_mkyoung(entry);
+	entry = pte_mkhuge(entry);
+
+	set_pte(ptep, entry);
 }
 
 /*
@@ -213,6 +240,7 @@
 		}
 		page = pmd_page(*pmd);
 		pmd_clear(pmd);
+		mm->nr_ptes--;
 		dec_page_state(nr_page_table_pages);
 		pte_free_tlb(tlb, page);
 	}
@@ -248,7 +276,7 @@
 {
 	if (within_hugepage_high_range(addr, len))
 		return 0;
-	else if ((addr < 0x100000000) && ((addr+len) < 0x100000000)) {
+	else if ((addr < 0x100000000UL) && ((addr+len) < 0x100000000UL)) {
 		int err;
 		/* Yes, we need both tests, in case addr+len overflows
 		 * 64-bit arithmetic */
@@ -267,34 +295,31 @@
 int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
 			struct vm_area_struct *vma)
 {
-	hugepte_t *src_pte, *dst_pte, entry;
+	pte_t *src_pte, *dst_pte, entry;
 	struct page *ptepage;
 	unsigned long addr = vma->vm_start;
 	unsigned long end = vma->vm_end;
+	int err = -ENOMEM;
 
 	while (addr < end) {
-		BUG_ON(! in_hugepage_area(src->context, addr));
-		BUG_ON(! in_hugepage_area(dst->context, addr));
-
-		dst_pte = hugepte_alloc(dst, addr);
+		dst_pte = huge_pte_alloc(dst, addr);
 		if (!dst_pte)
-			return -ENOMEM;
+			goto out;
 
-		src_pte = hugepte_offset(src, addr);
+		src_pte = huge_pte_offset(src, addr);
 		entry = *src_pte;
 		
-		if ((addr % HPAGE_SIZE) == 0) {
-			/* This is the first hugepte in a batch */
-			ptepage = hugepte_page(entry);
-			get_page(ptepage);
-			dst->rss += (HPAGE_SIZE / PAGE_SIZE);
-		}
-		set_hugepte(dst_pte, entry);
-
+		ptepage = pte_page(entry);
+		get_page(ptepage);
+		dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+		set_pte(dst_pte, entry);
 
-		addr += PMD_SIZE;
+		addr += HPAGE_SIZE;
 	}
-	return 0;
+
+	err = 0;
+ out:
+	return err;
 }
 
 int
@@ -309,18 +334,16 @@
 
 	vpfn = vaddr/PAGE_SIZE;
 	while (vaddr < vma->vm_end && remainder) {
-		BUG_ON(!in_hugepage_area(mm->context, vaddr));
-
 		if (pages) {
-			hugepte_t *pte;
+			pte_t *pte;
 			struct page *page;
 
-			pte = hugepte_offset(mm, vaddr);
+			pte = huge_pte_offset(mm, vaddr);
 
 			/* hugetlb should be locked, and hence, prefaulted */
-			WARN_ON(!pte || hugepte_none(*pte));
+			WARN_ON(!pte || pte_none(*pte));
 
-			page = &hugepte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
+			page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
 
 			WARN_ON(!PageCompound(page));
 
@@ -346,26 +369,31 @@
 struct page *
 follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
 {
-	return ERR_PTR(-EINVAL);
+	pte_t *ptep;
+	struct page *page;
+
+	if (! in_hugepage_area(mm->context, address))
+		return ERR_PTR(-EINVAL);
+
+	ptep = huge_pte_offset(mm, address);
+	page = pte_page(*ptep);
+	if (page)
+		page += (address % HPAGE_SIZE) / PAGE_SIZE;
+
+	return page;
 }
 
 int pmd_huge(pmd_t pmd)
 {
-	return pmd_hugepage(pmd);
+	return 0;
 }
 
 struct page *
 follow_huge_pmd(struct mm_struct *mm, unsigned long address,
 		pmd_t *pmd, int write)
 {
-	struct page *page;
-
-	BUG_ON(! pmd_hugepage(*pmd));
-
-	page = hugepte_page(*(hugepte_t *)pmd);
-	if (page)
-		page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT);
-	return page;
+	BUG();
+	return NULL;
 }
 
 void unmap_hugepage_range(struct vm_area_struct *vma,
@@ -373,44 +401,38 @@
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long addr;
-	hugepte_t *ptep;
+	pte_t *ptep;
 	struct page *page;
-	int cpu;
-	int local = 0;
-	cpumask_t tmp;
 
 	WARN_ON(!is_vm_hugetlb_page(vma));
 	BUG_ON((start % HPAGE_SIZE) != 0);
 	BUG_ON((end % HPAGE_SIZE) != 0);
 
-	/* XXX are there races with checking cpu_vm_mask? - Anton */
-	cpu = get_cpu();
-	tmp = cpumask_of_cpu(cpu);
-	if (cpus_equal(vma->vm_mm->cpu_vm_mask, tmp))
-		local = 1;
-
 	for (addr = start; addr < end; addr += HPAGE_SIZE) {
-		hugepte_t pte;
-
-		BUG_ON(!in_hugepage_area(mm->context, addr));
+		pte_t pte;
 
-		ptep = hugepte_offset(mm, addr);
-		if (!ptep || hugepte_none(*ptep))
+		ptep = huge_pte_offset(mm, addr);
+		if (!ptep || pte_none(*ptep))
 			continue;
 
 		pte = *ptep;
-		page = hugepte_page(pte);
-		teardown_huge_pte(ptep);
-		
-		if (hugepte_val(pte) & _HUGEPAGE_HASHPTE)
-			flush_hash_hugepage(mm->context, addr,
-					    pte, local);
+		page = pte_page(pte);
+		pte_clear(ptep);
 
 		put_page(page);
 	}
-	put_cpu();
-
 	mm->rss -= (end - start) >> PAGE_SHIFT;
+	flush_tlb_pending();
+}
+
+void hugetlb_free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *prev,
+			   unsigned long start, unsigned long end)
+{
+	/* Because the huge pgtables are only 2 level, they can take
+	 * at most around 4M, much less than one hugepage which the
+	 * process is presumably entitled to use.  So we don't bother
+	 * freeing up the pagetables on unmap, and wait until
+	 * destroy_context() to clean up the lot. */
 }
 
 int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
@@ -426,16 +448,14 @@
 	spin_lock(&mm->page_table_lock);
 	for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
 		unsigned long idx;
-		hugepte_t *pte = hugepte_alloc(mm, addr);
+		pte_t *pte = huge_pte_alloc(mm, addr);
 		struct page *page;
 
-		BUG_ON(!in_hugepage_area(mm->context, addr));
-
 		if (!pte) {
 			ret = -ENOMEM;
 			goto out;
 		}
-		if (!hugepte_none(*pte))
+		if (! pte_none(*pte))
 			continue;
 
 		idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
@@ -462,7 +482,7 @@
 				goto out;
 			}
 		}
-		setup_huge_pte(mm, page, pte, vma->vm_flags & VM_WRITE);
+		set_huge_pte(mm, vma, page, pte, vma->vm_flags & VM_WRITE);
 	}
 out:
 	spin_unlock(&mm->page_table_lock);
@@ -716,20 +736,55 @@
 	}
 }
 
+void hugetlb_mm_free_pgd(struct mm_struct *mm)
+{
+	int i;
+	pgd_t *pgdir;
+
+	spin_lock(&mm->page_table_lock);
+
+	pgdir = mm->context.huge_pgdir;
+	if (! pgdir)
+		return;
+
+	mm->context.huge_pgdir = NULL;
+
+	/* cleanup any hugepte pages leftover */
+	for (i = 0; i < PTRS_PER_HUGEPGD; i++) {
+		pgd_t *pgd = pgdir + i;
+
+		if (! pgd_none(*pgd)) {
+			pte_t *pte = (pte_t *)pgd_page(*pgd);
+			struct page *ptepage = virt_to_page(pte);
+
+			ptepage->mapping = NULL;
+
+			BUG_ON(memcmp(pte, empty_zero_page, PAGE_SIZE));
+			kmem_cache_free(zero_cache, pte);
+		}
+		pgd_clear(pgd);
+	}
+
+	BUG_ON(memcmp(pgdir, empty_zero_page, PAGE_SIZE));
+	kmem_cache_free(zero_cache, pgdir);
+
+	spin_unlock(&mm->page_table_lock);
+}
+
 int hash_huge_page(struct mm_struct *mm, unsigned long access,
 		   unsigned long ea, unsigned long vsid, int local)
 {
-	hugepte_t *ptep;
+	pte_t *ptep;
 	unsigned long va, vpn;
 	int is_write;
-	hugepte_t old_pte, new_pte;
-	unsigned long hpteflags, prpn, flags;
+	pte_t old_pte, new_pte;
+	unsigned long hpteflags, prpn;
 	long slot;
+	int err = 1;
+
+	spin_lock(&mm->page_table_lock);
 
-	/* We have to find the first hugepte in the batch, since
-	 * that's the one that will store the HPTE flags */
-	ea &= HPAGE_MASK;
-	ptep = hugepte_offset(mm, ea);
+	ptep = huge_pte_offset(mm, ea);
 
 	/* Search the Linux page table for a match with va */
 	va = (vsid << 28) | (ea & 0x0fffffff);
@@ -739,19 +794,18 @@
 	 * If no pte found or not present, send the problem up to
 	 * do_page_fault
 	 */
-	if (unlikely(!ptep || hugepte_none(*ptep)))
-		return 1;
+	if (unlikely(!ptep || pte_none(*ptep)))
+		goto out;
 
-	BUG_ON(hugepte_bad(*ptep));
+/* 	BUG_ON(pte_bad(*ptep)); */
 
 	/* 
 	 * Check the user's access rights to the page.  If access should be
 	 * prevented then send the problem up to do_page_fault.
 	 */
 	is_write = access & _PAGE_RW;
-	if (unlikely(is_write && !(hugepte_val(*ptep) & _HUGEPAGE_RW)))
-		return 1;
-
+	if (unlikely(is_write && !(pte_val(*ptep) & _PAGE_RW)))
+		goto out;
 	/*
 	 * At this point, we have a pte (old_pte) which can be used to build
 	 * or update an HPTE. There are 2 cases:
@@ -764,41 +818,40 @@
 	 *	page is currently not DIRTY. 
 	 */
 
-	spin_lock_irqsave(&mm->page_table_lock, flags);
 
 	old_pte = *ptep;
 	new_pte = old_pte;
 
-	hpteflags = 0x2 | (! (hugepte_val(new_pte) & _HUGEPAGE_RW));
+	hpteflags = 0x2 | (! (pte_val(new_pte) & _PAGE_RW));
 
 	/* Check if pte already has an hpte (case 2) */
-	if (unlikely(hugepte_val(old_pte) & _HUGEPAGE_HASHPTE)) {
+	if (unlikely(pte_val(old_pte) & _PAGE_HASHPTE)) {
 		/* There MIGHT be an HPTE for this pte */
 		unsigned long hash, slot;
 
 		hash = hpt_hash(vpn, 1);
-		if (hugepte_val(old_pte) & _HUGEPAGE_SECONDARY)
+		if (pte_val(old_pte) & _PAGE_SECONDARY)
 			hash = ~hash;
 		slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
-		slot += (hugepte_val(old_pte) & _HUGEPAGE_GROUP_IX) >> 5;
+		slot += (pte_val(old_pte) & _PAGE_GROUP_IX) >> 12;
 
 		if (ppc_md.hpte_updatepp(slot, hpteflags, va, 1, local) == -1)
-			hugepte_val(old_pte) &= ~_HUGEPAGE_HPTEFLAGS;
+			pte_val(old_pte) &= ~_PAGE_HPTEFLAGS;
 	}
 
-	if (likely(!(hugepte_val(old_pte) & _HUGEPAGE_HASHPTE))) {
+	if (likely(!(pte_val(old_pte) & _PAGE_HASHPTE))) {
 		unsigned long hash = hpt_hash(vpn, 1);
 		unsigned long hpte_group;
 
-		prpn = hugepte_pfn(old_pte);
+		prpn = pte_pfn(old_pte);
 
 repeat:
 		hpte_group = ((hash & htab_data.htab_hash_mask) *
 			      HPTES_PER_GROUP) & ~0x7UL;
 
 		/* Update the linux pte with the HPTE slot */
-		hugepte_val(new_pte) &= ~_HUGEPAGE_HPTEFLAGS;
-		hugepte_val(new_pte) |= _HUGEPAGE_HASHPTE;
+		pte_val(new_pte) &= ~_PAGE_HPTEFLAGS;
+		pte_val(new_pte) |= _PAGE_HASHPTE;
 
 		/* Add in WIMG bits */
 		/* XXX We should store these in the pte */
@@ -809,7 +862,7 @@
 
 		/* Primary is full, try the secondary */
 		if (unlikely(slot == -1)) {
-			hugepte_val(new_pte) |= _HUGEPAGE_SECONDARY;
+			pte_val(new_pte) |= _PAGE_SECONDARY;
 			hpte_group = ((~hash & htab_data.htab_hash_mask) *
 				      HPTES_PER_GROUP) & ~0x7UL; 
 			slot = ppc_md.hpte_insert(hpte_group, va, prpn,
@@ -826,39 +879,20 @@
 		if (unlikely(slot == -2))
 			panic("hash_huge_page: pte_insert failed\n");
 
-		hugepte_val(new_pte) |= (slot<<5) & _HUGEPAGE_GROUP_IX;
+		pte_val(new_pte) |= (slot<<12) & _PAGE_GROUP_IX;
 
 		/* 
 		 * No need to use ldarx/stdcx here because all who
 		 * might be updating the pte will hold the
-		 * page_table_lock or the hash_table_lock
-		 * (we hold both)
+		 * page_table_lock
 		 */
 		*ptep = new_pte;
 	}
 
-	spin_unlock_irqrestore(&mm->page_table_lock, flags);
-
-	return 0;
-}
-
-static void flush_hash_hugepage(mm_context_t context, unsigned long ea,
-				hugepte_t pte, int local)
-{
-	unsigned long vsid, vpn, va, hash, slot;
-
-	BUG_ON(hugepte_bad(pte));
-	BUG_ON(!in_hugepage_area(context, ea));
-
-	vsid = get_vsid(context.id, ea);
+	err = 0;
 
-	va = (vsid << 28) | (ea & 0x0fffffff);
-	vpn = va >> HPAGE_SHIFT;
-	hash = hpt_hash(vpn, 1);
-	if (hugepte_val(pte) & _HUGEPAGE_SECONDARY)
-		hash = ~hash;
-	slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
-	slot += (hugepte_val(pte) & _HUGEPAGE_GROUP_IX) >> 5;
+ out:
+	spin_unlock(&mm->page_table_lock);
 
-	ppc_md.hpte_invalidate(slot, va, 1, local);
+	return err;
 }
diff -Nru a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c
--- a/arch/ppc64/mm/init.c	2004-12-24 13:36:59 -08:00
+++ b/arch/ppc64/mm/init.c	2004-12-24 13:36:59 -08:00
@@ -263,9 +263,10 @@
 		 */
 		;
 	} else {
-		area = im_get_area(ea, size, IM_REGION_UNUSED|IM_REGION_SUBSET);
+		area = im_get_area(ea, size,
+			IM_REGION_UNUSED|IM_REGION_SUBSET|IM_REGION_EXISTS);
 		if (area == NULL) {
-			printk(KERN_ERR "could not obtain imalloc area for ea 0x%lx\n", ea);
+			/* Expected when PHB-dlpar is in play */
 			return 1;
 		}
 		if (ea != (unsigned long) area->addr) {
@@ -477,12 +478,18 @@
 	int index;
 	int err;
 
+#ifdef CONFIG_HUGETLB_PAGE
+	/* We leave htlb_segs as it was, but for a fork, we need to
+	 * clear the huge_pgdir. */
+	mm->context.huge_pgdir = NULL;
+#endif
+
 again:
 	if (!idr_pre_get(&mmu_context_idr, GFP_KERNEL))
 		return -ENOMEM;
 
 	spin_lock(&mmu_context_lock);
-	err = idr_get_new(&mmu_context_idr, NULL, &index);
+	err = idr_get_new_above(&mmu_context_idr, NULL, 1, &index);
 	spin_unlock(&mmu_context_lock);
 
 	if (err == -EAGAIN)
@@ -507,20 +514,9 @@
 	spin_unlock(&mmu_context_lock);
 
 	mm->context.id = NO_CONTEXT;
-}
-
-static int __init mmu_context_init(void)
-{
-	int index;
 
-	/* Reserve the first (invalid) context*/
-	idr_pre_get(&mmu_context_idr, GFP_KERNEL);
-	idr_get_new(&mmu_context_idr, NULL, &index);
-	BUG_ON(0 != index);
-
-	return 0;
+	hugetlb_mm_free_pgd(mm);
 }
-arch_initcall(mmu_context_init);
 
 /*
  * Do very early mm setup.
@@ -873,14 +869,14 @@
 	local_irq_restore(flags);
 }
 
-void * reserve_phb_iospace(unsigned long size)
+void __iomem * reserve_phb_iospace(unsigned long size)
 {
-	void *virt_addr;
+	void __iomem *virt_addr;
 		
 	if (phbs_io_bot >= IMALLOC_BASE) 
 		panic("reserve_phb_iospace(): phb io space overflow\n");
 			
-	virt_addr = (void *) phbs_io_bot;
+	virt_addr = (void __iomem *) phbs_io_bot;
 	phbs_io_bot += size;
 
 	return virt_addr;
diff -Nru a/arch/ppc64/mm/mmap.c b/arch/ppc64/mm/mmap.c
--- a/arch/ppc64/mm/mmap.c	2004-12-24 13:36:18 -08:00
+++ b/arch/ppc64/mm/mmap.c	2004-12-24 13:36:18 -08:00
@@ -37,7 +37,7 @@
 
 static inline unsigned long mmap_base(void)
 {
-	unsigned long gap = current->rlim[RLIMIT_STACK].rlim_cur;
+	unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
 
 	if (gap < MIN_GAP)
 		gap = MIN_GAP;
@@ -58,7 +58,7 @@
 	if (current->personality & ADDR_COMPAT_LAYOUT)
 		return 1;
 
-	if (current->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY)
+	if (current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY)
 		return 1;
 
 	return sysctl_legacy_va_layout;
diff -Nru a/arch/ppc64/mm/numa.c b/arch/ppc64/mm/numa.c
--- a/arch/ppc64/mm/numa.c	2004-12-24 13:37:02 -08:00
+++ b/arch/ppc64/mm/numa.c	2004-12-24 13:37:02 -08:00
@@ -14,6 +14,9 @@
 #include <linux/mm.h>
 #include <linux/mmzone.h>
 #include <linux/module.h>
+#include <linux/nodemask.h>
+#include <linux/cpu.h>
+#include <linux/notifier.h>
 #include <asm/lmb.h>
 #include <asm/machdep.h>
 #include <asm/abs_addr.h>
@@ -38,6 +41,7 @@
 struct pglist_data *node_data[MAX_NUMNODES];
 bootmem_data_t __initdata plat_node_bdata[MAX_NUMNODES];
 static unsigned long node0_io_hole_size;
+static int min_common_depth;
 
 /*
  * We need somewhere to store start/span for each node until we have
@@ -63,7 +67,24 @@
 	}
 }
 
-static struct device_node * __init find_cpu_node(unsigned int cpu)
+#ifdef CONFIG_HOTPLUG_CPU
+static void unmap_cpu_from_node(unsigned long cpu)
+{
+	int node = numa_cpu_lookup_table[cpu];
+
+	dbg("removing cpu %lu from node %d\n", cpu, node);
+
+	if (cpu_isset(cpu, numa_cpumask_lookup_table[node])) {
+		cpu_clear(cpu, numa_cpumask_lookup_table[node]);
+		nr_cpus_in_node[node]--;
+	} else {
+		printk(KERN_ERR "WARNING: cpu %lu not found in node %d\n",
+		       cpu, node);
+	}
+}
+#endif /* CONFIG_HOTPLUG_CPU */
+
+static struct device_node * __devinit find_cpu_node(unsigned int cpu)
 {
 	unsigned int hw_cpuid = get_hard_smp_processor_id(cpu);
 	struct device_node *cpu_node = NULL;
@@ -75,9 +96,11 @@
 		interrupt_server = (unsigned int *)get_property(cpu_node,
 					"ibm,ppc-interrupt-server#s", &len);
 
+		len = len / sizeof(u32);
+
 		if (interrupt_server && (len > 0)) {
 			while (len--) {
-				if (interrupt_server[len-1] == hw_cpuid)
+				if (interrupt_server[len] == hw_cpuid)
 					return cpu_node;
 			}
 		} else {
@@ -93,26 +116,21 @@
 
 /* must hold reference to node during call */
 static int *of_get_associativity(struct device_node *dev)
- {
-	unsigned int *result;
-	int len;
-
-	result = (unsigned int *)get_property(dev, "ibm,associativity", &len);
-
-	if (len <= 0)
-		return NULL;
-
-	return result;
+{
+	return (unsigned int *)get_property(dev, "ibm,associativity", NULL);
 }
 
-static int of_node_numa_domain(struct device_node *device, int depth)
+static int of_node_numa_domain(struct device_node *device)
 {
 	int numa_domain;
 	unsigned int *tmp;
 
+	if (min_common_depth == -1)
+		return 0;
+
 	tmp = of_get_associativity(device);
-	if (tmp && (tmp[0] >= depth)) {
-		numa_domain = tmp[depth];
+	if (tmp && (tmp[0] >= min_common_depth)) {
+		numa_domain = tmp[min_common_depth];
 	} else {
 		dbg("WARNING: no NUMA information for %s\n",
 		    device->full_name);
@@ -135,7 +153,7 @@
  *
  * - Dave Hansen <haveblue@us.ibm.com>
  */
-static int find_min_common_depth(void)
+static int __init find_min_common_depth(void)
 {
 	int depth;
 	unsigned int *ref_points;
@@ -182,11 +200,73 @@
 	return result;
 }
 
+/*
+ * Figure out to which domain a cpu belongs and stick it there.
+ * Return the id of the domain used.
+ */
+static int numa_setup_cpu(unsigned long lcpu)
+{
+	int numa_domain = 0;
+	struct device_node *cpu = find_cpu_node(lcpu);
+
+	if (!cpu) {
+		WARN_ON(1);
+		goto out;
+	}
+
+	numa_domain = of_node_numa_domain(cpu);
+
+	if (numa_domain >= numnodes) {
+		/*
+		 * POWER4 LPAR uses 0xffff as invalid node,
+		 * dont warn in this case.
+		 */
+		if (numa_domain != 0xffff)
+			printk(KERN_ERR "WARNING: cpu %ld "
+			       "maps to invalid NUMA node %d\n",
+			       lcpu, numa_domain);
+		numa_domain = 0;
+	}
+out:
+	node_set_online(numa_domain);
+
+	map_cpu_to_node(lcpu, numa_domain);
+
+	of_node_put(cpu);
+
+	return numa_domain;
+}
+
+static int cpu_numa_callback(struct notifier_block *nfb,
+			     unsigned long action,
+			     void *hcpu)
+{
+	unsigned long lcpu = (unsigned long)hcpu;
+	int ret = NOTIFY_DONE;
+
+	switch (action) {
+	case CPU_UP_PREPARE:
+		if (min_common_depth == -1 || !numa_enabled)
+			map_cpu_to_node(lcpu, 0);
+		else
+			numa_setup_cpu(lcpu);
+		ret = NOTIFY_OK;
+		break;
+#ifdef CONFIG_HOTPLUG_CPU
+	case CPU_DEAD:
+	case CPU_UP_CANCELED:
+		unmap_cpu_from_node(lcpu);
+		break;
+		ret = NOTIFY_OK;
+#endif
+	}
+	return ret;
+}
+
 static int __init parse_numa_properties(void)
 {
 	struct device_node *cpu = NULL;
 	struct device_node *memory = NULL;
-	int depth;
 	int max_domain = 0;
 	long entries = lmb_end_of_DRAM() >> MEMORY_INCREMENT_SHIFT;
 	unsigned long i;
@@ -203,43 +283,34 @@
 	for (i = 0; i < entries ; i++)
 		numa_memory_lookup_table[i] = ARRAY_INITIALISER;
 
-	depth = find_min_common_depth();
+	min_common_depth = find_min_common_depth();
 
-	dbg("NUMA associativity depth for CPU/Memory: %d\n", depth);
-	if (depth < 0)
-		return depth;
+	dbg("NUMA associativity depth for CPU/Memory: %d\n", min_common_depth);
+	if (min_common_depth < 0)
+		return min_common_depth;
 
+	max_domain = numa_setup_cpu(boot_cpuid);
+
+	/*
+	 * Even though we connect cpus to numa domains later in SMP init,
+	 * we need to know the maximum node id now. This is because each
+	 * node id must have NODE_DATA etc backing it.
+	 * As a result of hotplug we could still have cpus appear later on
+	 * with larger node ids. In that case we force the cpu into node 0.
+	 */
 	for_each_cpu(i) {
 		int numa_domain;
 
 		cpu = find_cpu_node(i);
 
 		if (cpu) {
-			numa_domain = of_node_numa_domain(cpu, depth);
+			numa_domain = of_node_numa_domain(cpu);
 			of_node_put(cpu);
 
-			if (numa_domain >= MAX_NUMNODES) {
-				/*
-			 	 * POWER4 LPAR uses 0xffff as invalid node,
-				 * dont warn in this case.
-			 	 */
-				if (numa_domain != 0xffff)
-					printk(KERN_ERR "WARNING: cpu %ld "
-					       "maps to invalid NUMA node %d\n",
-					       i, numa_domain);
-				numa_domain = 0;
-			}
-		} else {
-			dbg("WARNING: no NUMA information for cpu %ld\n", i);
-			numa_domain = 0;
+			if (numa_domain < MAX_NUMNODES &&
+			    max_domain < numa_domain)
+				max_domain = numa_domain;
 		}
-
-		node_set_online(numa_domain);
-
-		if (max_domain < numa_domain)
-			max_domain = numa_domain;
-
-		map_cpu_to_node(i, numa_domain);
 	}
 
 	memory = NULL;
@@ -264,7 +335,7 @@
 		start = _ALIGN_DOWN(start, MEMORY_INCREMENT);
 		size = _ALIGN_UP(size, MEMORY_INCREMENT);
 
-		numa_domain = of_node_numa_domain(memory, depth);
+		numa_domain = of_node_numa_domain(memory);
 
 		if (numa_domain >= MAX_NUMNODES) {
 			if (numa_domain != 0xffff)
@@ -338,8 +409,7 @@
 			numa_memory_lookup_table[i] = ARRAY_INITIALISER;
 	}
 
-	for (i = 0; i < NR_CPUS; i++)
-		map_cpu_to_node(i, 0);
+	map_cpu_to_node(boot_cpuid, 0);
 
 	node_set_online(0);
 
@@ -355,35 +425,10 @@
 static void __init dump_numa_topology(void)
 {
 	unsigned int node;
-	unsigned int cpu, count;
+	unsigned int count;
 
-	for (node = 0; node < MAX_NUMNODES; node++) {
-		if (!node_online(node))
-			continue;
-
-		printk(KERN_INFO "Node %d CPUs:", node);
-
-		count = 0;
-		/*
-		 * If we used a CPU iterator here we would miss printing
-		 * the holes in the cpumap.
-		 */
-		for (cpu = 0; cpu < NR_CPUS; cpu++) {
-			if (cpu_isset(cpu, numa_cpumask_lookup_table[node])) {
-				if (count == 0)
-					printk(" %u", cpu);
-				++count;
-			} else {
-				if (count > 1)
-					printk("-%u", cpu - 1);
-				count = 0;
-			}
-		}
-
-		if (count > 1)
-			printk("-%u", NR_CPUS - 1);
-		printk("\n");
-	}
+	if (min_common_depth == -1 || !numa_enabled)
+		return;
 
 	for (node = 0; node < MAX_NUMNODES; node++) {
 		unsigned long i;
@@ -411,6 +456,7 @@
 			printk("-0x%lx", i);
 		printk("\n");
 	}
+	return;
 }
 
 /*
@@ -457,6 +503,10 @@
 void __init do_init_bootmem(void)
 {
 	int nid;
+	static struct notifier_block ppc64_numa_nb = {
+		.notifier_call = cpu_numa_callback,
+		.priority = 1 /* Must run before sched domains notifier. */
+	};
 
 	min_low_pfn = 0;
 	max_low_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT;
@@ -466,6 +516,8 @@
 		setup_nonnuma();
 	else
 		dump_numa_topology();
+
+	register_cpu_notifier(&ppc64_numa_nb);
 
 	for (nid = 0; nid < numnodes; nid++) {
 		unsigned long start_paddr, end_paddr;
diff -Nru a/arch/ppc64/oprofile/common.c b/arch/ppc64/oprofile/common.c
--- a/arch/ppc64/oprofile/common.c	2004-12-24 13:37:29 -08:00
+++ b/arch/ppc64/oprofile/common.c	2004-12-24 13:37:29 -08:00
@@ -112,10 +112,15 @@
 
 	oprofilefs_create_ulong(sb, root, "enable_kernel", &sys.enable_kernel);
 	oprofilefs_create_ulong(sb, root, "enable_user", &sys.enable_user);
+	oprofilefs_create_ulong(sb, root, "backtrace_spinlocks",
+				&sys.backtrace_spinlocks);
 
 	/* Default to tracing both kernel and user */
 	sys.enable_kernel = 1;
 	sys.enable_user = 1;
+
+	/* Turn on backtracing through spinlocks by default */
+	sys.backtrace_spinlocks = 1;
 
 	return 0;
 }
diff -Nru a/arch/ppc64/oprofile/op_impl.h b/arch/ppc64/oprofile/op_impl.h
--- a/arch/ppc64/oprofile/op_impl.h	2004-12-24 13:36:56 -08:00
+++ b/arch/ppc64/oprofile/op_impl.h	2004-12-24 13:36:56 -08:00
@@ -71,6 +71,7 @@
 	unsigned long mmcra;
 	unsigned long enable_kernel;
 	unsigned long enable_user;
+	unsigned long backtrace_spinlocks;
 };
 
 /* Per-arch configuration */
diff -Nru a/arch/ppc64/oprofile/op_model_power4.c b/arch/ppc64/oprofile/op_model_power4.c
--- a/arch/ppc64/oprofile/op_model_power4.c	2004-12-24 13:37:02 -08:00
+++ b/arch/ppc64/oprofile/op_model_power4.c	2004-12-24 13:37:02 -08:00
@@ -32,6 +32,13 @@
 static u64 mmcr1_val;
 static u32 mmcra_val;
 
+/*
+ * Since we do not have an NMI, backtracing through spinlocks is
+ * only a best guess. In light of this, allow it to be disabled at
+ * runtime.
+ */
+static int backtrace_spinlocks;
+
 static void power4_reg_setup(struct op_counter_config *ctr,
 			     struct op_system_config *sys,
 			     int num_ctrs)
@@ -59,6 +66,8 @@
 	mmcr1_val = sys->mmcr1;
 	mmcra_val = sys->mmcra;
 
+	backtrace_spinlocks = sys->backtrace_spinlocks;
+
 	for (i = 0; i < num_counters; ++i)
 		reset_value[i] = 0x80000000UL - ctr[i].count;
 
@@ -170,19 +179,38 @@
 {
 }
 
+static unsigned long check_spinlock_pc(struct pt_regs *regs,
+				       unsigned long profile_pc)
+{
+	unsigned long pc = instruction_pointer(regs);
+
+	/*
+	 * If both the SIAR (sampled instruction) and the perfmon exception
+	 * occurred in a spinlock region then we account the sample to the
+	 * calling function. This isnt 100% correct, we really need soft
+	 * IRQ disable so we always get the perfmon exception at the
+	 * point at which the SIAR is set.
+	 */
+	if (backtrace_spinlocks && in_lock_functions(pc) &&
+			in_lock_functions(profile_pc))
+		return regs->link;
+	else
+		return profile_pc;
+}
+
 /*
  * On GQ and newer the MMCRA stores the HV and PR bits at the time
  * the SIAR was sampled. We use that to work out if the SIAR was sampled in
  * the hypervisor, our exception vectors or RTAS.
  */
-static unsigned long get_pc(void)
+static unsigned long get_pc(struct pt_regs *regs)
 {
 	unsigned long pc = mfspr(SPRN_SIAR);
 	unsigned long mmcra;
 
 	/* Cant do much about it */
 	if (!mmcra_has_sihv)
-		return pc;
+		return check_spinlock_pc(regs, pc);
 
 	mmcra = mfspr(SPRN_MMCRA);
 
@@ -196,10 +224,6 @@
 	if (mmcra & MMCRA_SIPR)
 		return pc;
 
-	/* Were we in our exception vectors? */
-	if (pc < 0x4000UL)
-		return (unsigned long)__va(pc);
-
 #ifdef CONFIG_PPC_PSERIES
 	/* Were we in RTAS? */
 	if (pc >= rtas.base && pc < (rtas.base + rtas.size))
@@ -207,12 +231,16 @@
 		return *((unsigned long *)rtas_bucket);
 #endif
 
+	/* Were we in our exception vectors or SLB real mode miss handler? */
+	if (pc < 0x1000000UL)
+		return (unsigned long)__va(pc);
+
 	/* Not sure where we were */
 	if (pc < KERNELBASE)
 		/* function descriptor madness */
 		return *((unsigned long *)kernel_unknown_bucket);
 
-	return pc;
+	return check_spinlock_pc(regs, pc);
 }
 
 static int get_kernel(unsigned long pc)
@@ -239,7 +267,7 @@
 	unsigned int cpu = smp_processor_id();
 	unsigned int mmcr0;
 
-	pc = get_pc();
+	pc = get_pc(regs);
 	is_kernel = get_kernel(pc);
 
 	/* set the PMM bit (see comment below) */
diff -Nru a/arch/ppc64/xmon/start.c b/arch/ppc64/xmon/start.c
--- a/arch/ppc64/xmon/start.c	2004-12-24 13:37:33 -08:00
+++ b/arch/ppc64/xmon/start.c	2004-12-24 13:37:33 -08:00
@@ -35,7 +35,7 @@
 {
 	.handler =	sysrq_handle_xmon,
 	.help_msg =	"Xmon",
-	.action_msg =	"Entering xmon\n",
+	.action_msg =	"Entering xmon",
 };
 
 static int __init setup_xmon_sysrq(void)
@@ -173,7 +173,7 @@
 		c = xmon_getchar();
 		if (c == -1) {
 			if (p == str)
-				return 0;
+				return NULL;
 			break;
 		}
 		*p++ = c;
diff -Nru a/arch/ppc64/xmon/xmon.c b/arch/ppc64/xmon/xmon.c
--- a/arch/ppc64/xmon/xmon.c	2004-12-24 13:37:18 -08:00
+++ b/arch/ppc64/xmon/xmon.c	2004-12-24 13:37:18 -08:00
@@ -31,6 +31,7 @@
 #include <asm/ppcdebug.h>
 #include <asm/cputable.h>
 #include <asm/rtas.h>
+#include <asm/sstep.h>
 
 #include "nonstdio.h"
 #include "privinst.h"
@@ -39,7 +40,7 @@
 #define skipbl	xmon_skipbl
 
 #ifdef CONFIG_SMP
-volatile cpumask_t cpus_in_xmon = CPU_MASK_NONE;
+cpumask_t cpus_in_xmon = CPU_MASK_NONE;
 static unsigned long xmon_taken = 1;
 static int xmon_owner;
 static int xmon_gate;
@@ -85,9 +86,6 @@
 
 #define BP_NUM(bp)	((bp) - bpts + 1)
 
-/* Bits in SRR1 that are copied from MSR */
-#define MSR_MASK	0xffffffff87c0ffff
-
 /* Prototypes */
 static int cmds(struct pt_regs *);
 static int mread(unsigned long, void *, int);
@@ -132,7 +130,6 @@
 static void bootcmds(void);
 void dump_segments(void);
 static void symbol_lookup(void);
-static int emulate_step(struct pt_regs *regs, unsigned int instr);
 static void xmon_print_symbol(unsigned long address, const char *mid,
 			      const char *after);
 static const char *getvecname(unsigned long vec);
@@ -148,7 +145,6 @@
 extern int setjmp(long *);
 extern void longjmp(long *, int);
 extern unsigned long _ASR;
-extern char SystemCall_common[];
 
 pte_t *find_linux_pte(pgd_t *pgdir, unsigned long va);	/* from htab.c */
 
@@ -401,9 +397,11 @@
 		if (ncpus > 1) {
 			smp_send_debugger_break(MSG_ALL_BUT_SELF);
 			/* wait for other cpus to come in */
-			for (timeout = 100000000; timeout != 0; --timeout)
+			for (timeout = 100000000; timeout != 0; --timeout) {
 				if (cpus_weight(cpus_in_xmon) >= ncpus)
 					break;
+				barrier();
+			}
 		}
 		remove_bpts();
 		disable_surveillance();
@@ -488,6 +486,9 @@
 			if (stepped == 0) {
 				regs->nip = (unsigned long) &bp->instr[0];
 				atomic_inc(&bp->ref_count);
+			} else if (stepped < 0) {
+				printf("Couldn't single-step %s instruction\n",
+				    (IS_RFID(bp->instr[0])? "rfid": "mtmsrd"));
 			}
 		}
 	}
@@ -645,7 +646,7 @@
 	for (i = 0; i < NBPTS; ++i, ++bp)
 		if (bp->enabled && pc == bp->address)
 			return bp;
-	return 0;
+	return NULL;
 }
 
 static struct bpt *in_breakpoint_table(unsigned long nip, unsigned long *offp)
@@ -755,108 +756,6 @@
 		set_iabr(0);
 }
 
-static int branch_taken(unsigned int instr, struct pt_regs *regs)
-{
-	unsigned int bo = (instr >> 21) & 0x1f;
-	unsigned int bi;
-
-	if ((bo & 4) == 0) {
-		/* decrement counter */
-		--regs->ctr;
-		if (((bo >> 1) & 1) ^ (regs->ctr == 0))
-			return 0;
-	}
-	if ((bo & 0x10) == 0) {
-		/* check bit from CR */
-		bi = (instr >> 16) & 0x1f;
-		if (((regs->ccr >> (31 - bi)) & 1) != ((bo >> 3) & 1))
-			return 0;
-	}
-	return 1;
-}
-
-/*
- * Emulate instructions that cause a transfer of control.
- * Returns 1 if the step was emulated, 0 if not,
- * or -1 if the instruction is one that should not be stepped,
- * such as an rfid, or a mtmsrd that would clear MSR_RI.
- */
-static int emulate_step(struct pt_regs *regs, unsigned int instr)
-{
-	unsigned int opcode, rd;
-	unsigned long int imm;
-
-	opcode = instr >> 26;
-	switch (opcode) {
-	case 16:	/* bc */
-		imm = (signed short)(instr & 0xfffc);
-		if ((instr & 2) == 0)
-			imm += regs->nip;
-		regs->nip += 4;		/* XXX check 32-bit mode */
-		if (instr & 1)
-			regs->link = regs->nip;
-		if (branch_taken(instr, regs))
-			regs->nip = imm;
-		return 1;
-	case 17:	/* sc */
-		regs->gpr[9] = regs->gpr[13];
-		regs->gpr[11] = regs->nip + 4;
-		regs->gpr[12] = regs->msr & MSR_MASK;
-		regs->gpr[13] = (unsigned long) get_paca();
-		regs->nip = (unsigned long) &SystemCall_common;
-		regs->msr = MSR_KERNEL;
-		return 1;
-	case 18:	/* b */
-		imm = instr & 0x03fffffc;
-		if (imm & 0x02000000)
-			imm -= 0x04000000;
-		if ((instr & 2) == 0)
-			imm += regs->nip;
-		if (instr & 1)
-			regs->link = regs->nip + 4;
-		regs->nip = imm;
-		return 1;
-	case 19:
-		switch (instr & 0x7fe) {
-		case 0x20:	/* bclr */
-		case 0x420:	/* bcctr */
-			imm = (instr & 0x400)? regs->ctr: regs->link;
-			regs->nip += 4;		/* XXX check 32-bit mode */
-			if (instr & 1)
-				regs->link = regs->nip;
-			if (branch_taken(instr, regs))
-				regs->nip = imm;
-			return 1;
-		case 0x24:	/* rfid, scary */
-			printf("Can't single-step an rfid instruction\n");
-			return -1;
-		}
-	case 31:
-		rd = (instr >> 21) & 0x1f;
-		switch (instr & 0x7fe) {
-		case 0xa6:	/* mfmsr */
-			regs->gpr[rd] = regs->msr & MSR_MASK;
-			regs->nip += 4;
-			return 1;
-		case 0x164:	/* mtmsrd */
-			/* only MSR_EE and MSR_RI get changed if bit 15 set */
-			/* mtmsrd doesn't change MSR_HV and MSR_ME */
-			imm = (instr & 0x10000)? 0x8002: 0xefffffffffffefffUL;
-			imm = (regs->msr & MSR_MASK & ~imm)
-				| (regs->gpr[rd] & imm);
-			if ((imm & MSR_RI) == 0) {
-				printf("Can't step an instruction that would "
-				       "clear MSR.RI\n");
-				return -1;
-			}
-			regs->msr = imm;
-			regs->nip += 4;
-			return 1;
-		}
-	}
-	return 0;
-}
-
 /* Command interpreting routine */
 static char *last_cmd;
 
@@ -988,8 +887,11 @@
 	if ((regs->msr & (MSR_SF|MSR_PR|MSR_IR)) == (MSR_SF|MSR_IR)) {
 		if (mread(regs->nip, &instr, 4) == 4) {
 			stepped = emulate_step(regs, instr);
-			if (stepped < 0)
+			if (stepped < 0) {
+				printf("Couldn't single-step %s instruction\n",
+				       (IS_RFID(instr)? "rfid": "mtmsrd"));
 				return 0;
+			}
 			if (stepped > 0) {
 				regs->trap = 0xd00 | (regs->trap & 1);
 				printf("stepped to ");
@@ -1582,7 +1484,7 @@
 extern char dec_exc;
 
 void
-super_regs()
+super_regs(void)
 {
 	int cmd;
 	unsigned long val;
@@ -1816,7 +1718,7 @@
     "";
 
 void
-memex()
+memex(void)
 {
 	int cmd, inc, i, nslash;
 	unsigned long n;
@@ -1967,7 +1869,7 @@
 }
 
 int
-bsesc()
+bsesc(void)
 {
 	int c;
 
@@ -1985,7 +1887,7 @@
 			 || ('a' <= (c) && (c) <= 'f') \
 			 || ('A' <= (c) && (c) <= 'F'))
 void
-dump()
+dump(void)
 {
 	int c;
 
@@ -2150,7 +2052,7 @@
 static unsigned mask;
 
 void
-memlocate()
+memlocate(void)
 {
 	unsigned a, n;
 	unsigned char val[4];
@@ -2183,7 +2085,7 @@
 static unsigned long mlim = 0xffffffff;
 
 void
-memzcan()
+memzcan(void)
 {
 	unsigned char v;
 	unsigned a;
@@ -2212,7 +2114,7 @@
 
 /* Input scanning routines */
 int
-skipbl()
+skipbl(void)
 {
 	int c;
 
@@ -2237,8 +2139,7 @@
 };
 
 int
-scanhex(vp)
-unsigned long *vp;
+scanhex(unsigned long *vp)
 {
 	int c, d;
 	unsigned long v;
@@ -2322,7 +2223,7 @@
 }
 
 void
-scannl()
+scannl(void)
 {
 	int c;
 
@@ -2365,13 +2266,13 @@
 static char *lineptr;
 
 void
-flush_input()
+flush_input(void)
 {
 	lineptr = NULL;
 }
 
 int
-inchar()
+inchar(void)
 {
 	if (lineptr == NULL || *lineptr == 0) {
 		if (fgets(line, sizeof(line), stdin) == NULL) {
@@ -2384,8 +2285,7 @@
 }
 
 void
-take_input(str)
-char *str;
+take_input(char *str)
 {
 	lineptr = str;
 }
diff -Nru a/arch/s390/Makefile b/arch/s390/Makefile
--- a/arch/s390/Makefile	2004-12-24 13:36:30 -08:00
+++ b/arch/s390/Makefile	2004-12-24 13:36:30 -08:00
@@ -34,8 +34,20 @@
 cflags-$(CONFIG_MARCH_Z900) += $(call cc-option,-march=z900)
 cflags-$(CONFIG_MARCH_Z990) += $(call cc-option,-march=z990)
 
+# old style option for packed stacks
 ifeq ($(call cc-option-yn,-mkernel-backchain),y)
 cflags-$(CONFIG_PACK_STACK)  += -mkernel-backchain -D__PACK_STACK
+aflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
+cflags-$(CONFIG_SMALL_STACK) += -D__SMALL_STACK
+aflags-$(CONFIG_SMALL_STACK) += -D__SMALL_STACK
+ifdef CONFIG_SMALL_STACK
+STACK_SIZE := $(shell echo $$(($(STACK_SIZE)/2)) )
+endif
+endif
+
+# new style option for packed stacks
+ifeq ($(call cc-option-yn,-mpacked-stack),y)
+cflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
 aflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
 cflags-$(CONFIG_SMALL_STACK) += -D__SMALL_STACK
 aflags-$(CONFIG_SMALL_STACK) += -D__SMALL_STACK
diff -Nru a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile
--- a/arch/s390/boot/Makefile	2004-12-24 13:37:34 -08:00
+++ b/arch/s390/boot/Makefile	2004-12-24 13:37:34 -08:00
@@ -14,5 +14,5 @@
 	$(call if_changed,objcopy)
 
 install: $(CONFIGURE) $(obj)/image
-	sh -x $(obj)/install.sh $(KERNELRELEASE) $(obj)/image \
+	sh -x  $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/image \
 	      System.map Kerntypes "$(INSTALL_PATH)"
diff -Nru a/arch/s390/defconfig b/arch/s390/defconfig
--- a/arch/s390/defconfig	2004-12-24 13:37:18 -08:00
+++ b/arch/s390/defconfig	2004-12-24 13:37:18 -08:00
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-rc3
-# Fri Oct  8 19:17:35 2004
+# Linux kernel version: 2.6.10-rc2
+# Tue Nov 30 14:00:30 2004
 #
 CONFIG_MMU=y
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
@@ -13,6 +13,7 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
@@ -26,6 +27,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=17
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_EMBEDDED is not set
@@ -34,12 +36,12 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_TINY_SHMEM is not set
 
 #
@@ -49,6 +51,7 @@
 # CONFIG_MODULE_UNLOAD is not set
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
 #
@@ -157,7 +160,9 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+# CONFIG_CDROM_PKTCDVD is not set
 
 #
 # S/390 block device drivers
@@ -172,6 +177,14 @@
 # CONFIG_DASD_CMB is not set
 
 #
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+
+#
 # Multi-device support (RAID and LVM)
 #
 CONFIG_MD=y
@@ -183,6 +196,7 @@
 CONFIG_MD_RAID5=m
 # CONFIG_MD_RAID6 is not set
 CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
 # CONFIG_BLK_DEV_DM is not set
 
 #
@@ -192,6 +206,11 @@
 CONFIG_UNIX98_PTY_COUNT=2048
 
 #
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+
+#
 # S/390 character device drivers
 #
 CONFIG_TN3270=y
@@ -217,6 +236,9 @@
 # S/390 tape hardware support
 #
 CONFIG_S390_TAPE_34XX=m
+# CONFIG_VMLOGRDR is not set
+# CONFIG_MONREADER is not set
+# CONFIG_DCSS_SHM is not set
 
 #
 # Cryptographic devices
@@ -249,6 +271,8 @@
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
 # CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+CONFIG_IP_TCPDIAG_IPV6=y
 CONFIG_IPV6=y
 # CONFIG_IPV6_PRIVACY is not set
 # CONFIG_INET6_AH is not set
@@ -276,7 +300,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -395,6 +418,7 @@
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -420,6 +444,7 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -499,13 +524,16 @@
 #
 CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
 # CONFIG_DEBUG_INFO is not set
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
@@ -532,6 +560,7 @@
 # CONFIG_CRYPTO_TEA is not set
 # CONFIG_CRYPTO_ARC4 is not set
 # CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_ANUBIS is not set
 # CONFIG_CRYPTO_DEFLATE is not set
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
 # CONFIG_CRYPTO_CRC32C is not set
diff -Nru a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
--- a/arch/s390/kernel/asm-offsets.c	2004-12-24 13:36:31 -08:00
+++ b/arch/s390/kernel/asm-offsets.c	2004-12-24 13:36:31 -08:00
@@ -22,6 +22,8 @@
 	DEFINE(__THREAD_mm_segment,
 	       offsetof(struct task_struct, thread.mm_segment),);
 	BLANK();
+	DEFINE(__TASK_pid, offsetof(struct task_struct, pid),);
+	BLANK();
 	DEFINE(__PER_atmid, offsetof(per_struct, lowcore.words.perc_atmid),);
 	DEFINE(__PER_address, offsetof(per_struct, lowcore.words.address),);
 	DEFINE(__PER_access_id, offsetof(per_struct, lowcore.words.access_id),);
diff -Nru a/arch/s390/kernel/binfmt_elf32.c b/arch/s390/kernel/binfmt_elf32.c
--- a/arch/s390/kernel/binfmt_elf32.c	2004-12-24 13:37:19 -08:00
+++ b/arch/s390/kernel/binfmt_elf32.c	2004-12-24 13:37:19 -08:00
@@ -56,6 +56,9 @@
 
 #define ELF_CORE_COPY_REGS(pr_reg, regs) dump_regs32(regs, &pr_reg);
 
+#define ELF_CORE_COPY_TASK_REGS(tsk, regs) dump_task_regs32(tsk, regs)
+
+#define ELF_CORE_COPY_FPREGS(tsk, fpregs) dump_task_fpu(tsk, fpregs)
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this CPU supports. */
@@ -99,10 +102,34 @@
 	int i;
 
 	memcpy(&regs->psw.mask, &ptregs->psw.mask, 4);
-	memcpy(&regs->psw.addr, &ptregs->psw.addr, 4);
+	memcpy(&regs->psw.addr, (char *)&ptregs->psw.addr + 4, 4);
 	for (i = 0; i < NUM_GPRS; i++)
 		regs->gprs[i] = ptregs->gprs[i];
+	save_access_regs(regs->acrs);
 	regs->orig_gpr2 = ptregs->orig_gpr2;
+	return 1;
+}
+
+static inline int dump_task_regs32(struct task_struct *tsk, elf_gregset_t *regs)
+{
+	struct pt_regs *ptregs = __KSTK_PTREGS(tsk);
+	int i;
+
+	memcpy(&regs->psw.mask, &ptregs->psw.mask, 4);
+	memcpy(&regs->psw.addr, (char *)&ptregs->psw.addr + 4, 4);
+	for (i = 0; i < NUM_GPRS; i++)
+		regs->gprs[i] = ptregs->gprs[i];
+	memcpy(regs->acrs, tsk->thread.acrs, sizeof(regs->acrs));
+	regs->orig_gpr2 = ptregs->orig_gpr2;
+	return 1;
+}
+
+static inline int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
+{
+	if (tsk == current)
+		save_fp_regs((s390_fp_regs *) fpregs);
+	else
+		memcpy(fpregs, &tsk->thread.fp_regs, sizeof(elf_fpregset_t));
 	return 1;
 }
 
diff -Nru a/arch/s390/kernel/compat_exec.c b/arch/s390/kernel/compat_exec.c
--- a/arch/s390/kernel/compat_exec.c	2004-12-24 13:37:19 -08:00
+++ b/arch/s390/kernel/compat_exec.c	2004-12-24 13:37:19 -08:00
@@ -39,7 +39,7 @@
 	unsigned long stack_base;
 	struct vm_area_struct *mpnt;
 	struct mm_struct *mm = current->mm;
-	int i;
+	int i, ret;
 
 	stack_base = STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE;
 	mm->arg_start = bprm->p + stack_base;
@@ -68,7 +68,11 @@
 		/* executable stack setting would be applied here */
 		mpnt->vm_page_prot = PAGE_COPY;
 		mpnt->vm_flags = VM_STACK_FLAGS;
-		insert_vm_struct(mm, mpnt);
+		if ((ret = insert_vm_struct(mm, mpnt))) {
+			up_write(&mm->mmap_sem);
+			kmem_cache_free(vm_area_cachep, mpnt);
+			return ret;
+		}
 		mm->stack_vm = mm->total_vm = vma_pages(mpnt);
 	} 
 
diff -Nru a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
--- a/arch/s390/kernel/compat_linux.c	2004-12-24 13:37:18 -08:00
+++ b/arch/s390/kernel/compat_linux.c	2004-12-24 13:37:18 -08:00
@@ -751,7 +751,9 @@
 				 compat_ptr(regs.gprs[4]), &regs);
 	if (error == 0)
 	{
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
 		current->thread.fp_regs.fpc=0;
 		__asm__ __volatile__
 		        ("sr  0,0\n\t"
diff -Nru a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
--- a/arch/s390/kernel/compat_wrapper.S	2004-12-24 13:37:33 -08:00
+++ b/arch/s390/kernel/compat_wrapper.S	2004-12-24 13:37:33 -08:00
@@ -1262,19 +1262,19 @@
 sys32_clock_settime_wrapper:
 	lgfr	%r2,%r2			# clockid_t (int)
 	llgtr	%r3,%r3			# struct compat_timespec *
-	jg	compat_clock_settime
+	jg	compat_sys_clock_settime
 
 	.globl	sys32_clock_gettime_wrapper
 sys32_clock_gettime_wrapper:
 	lgfr	%r2,%r2			# clockid_t (int)
 	llgtr	%r3,%r3			# struct compat_timespec *
-	jg	compat_clock_gettime
+	jg	compat_sys_clock_gettime
 
 	.globl	sys32_clock_getres_wrapper
 sys32_clock_getres_wrapper:
 	lgfr	%r2,%r2			# clockid_t (int)
 	llgtr	%r3,%r3			# struct compat_timespec *
-	jg	compat_clock_getres
+	jg	compat_sys_clock_getres
 
 	.globl	sys32_clock_nanosleep_wrapper
 sys32_clock_nanosleep_wrapper:
@@ -1282,7 +1282,7 @@
 	lgfr	%r3,%r3			# int
 	llgtr	%r4,%r4			# struct compat_timespec *
 	llgtr	%r5,%r5			# struct compat_timespec *
-	jg	compat_clock_nanosleep
+	jg	compat_sys_clock_nanosleep
 
 	.globl	sys32_timer_create_wrapper
 sys32_timer_create_wrapper:
@@ -1297,13 +1297,13 @@
 	lgfr	%r3,%r3			# int
 	llgtr	%r4,%r4			# struct compat_itimerspec *
 	llgtr	%r5,%r5			# struct compat_itimerspec *
-	jg	compat_timer_settime
+	jg	compat_sys_timer_settime
 
 	.globl	sys32_timer_gettime_wrapper
 sys32_timer_gettime_wrapper:
 	lgfr	%r2,%r2			# timer_t (int)
 	llgtr	%r3,%r3			# struct compat_itimerspec *
-	jg	compat_timer_gettime
+	jg	compat_sys_timer_gettime
 
 	.globl	sys32_timer_getoverrun_wrapper
 sys32_timer_getoverrun_wrapper:
@@ -1354,14 +1354,14 @@
 	llgtr	%r2,%r2			# const char *
 	llgfr	%r3,%r3			# compat_size_t
 	llgtr	%r4,%r4			# struct compat_statfs64 *
-	jg	compat_statfs64
+	jg	compat_sys_statfs64
 
 	.globl compat_sys_fstatfs64_wrapper
 compat_sys_fstatfs64_wrapper:
 	llgfr	%r2,%r2			# unsigned int fd
 	llgfr	%r3,%r3			# compat_size_t
 	llgtr	%r4,%r4			# struct compat_statfs64 *
-	jg	compat_fstatfs64
+	jg	compat_sys_fstatfs64
 
 	.globl	compat_sys_mq_open_wrapper
 compat_sys_mq_open_wrapper:
diff -Nru a/arch/s390/kernel/cpcmd.c b/arch/s390/kernel/cpcmd.c
--- a/arch/s390/kernel/cpcmd.c	2004-12-24 13:36:48 -08:00
+++ b/arch/s390/kernel/cpcmd.c	2004-12-24 13:36:48 -08:00
@@ -15,7 +15,7 @@
 #include <asm/system.h>
 
 static spinlock_t cpcmd_lock = SPIN_LOCK_UNLOCKED;
-static char cpcmd_buf[128];
+static char cpcmd_buf[240];
 
 void cpcmd(char *cmd, char *response, int rlen)
 {
@@ -24,22 +24,23 @@
         int cmdlen;
 
 	spin_lock_irqsave(&cpcmd_lock, flags);
-        cmdlen = strlen(cmd);
-        strcpy(cpcmd_buf, cmd);
-        ASCEBC(cpcmd_buf, cmdlen);
+	cmdlen = strlen(cmd);
+	BUG_ON(cmdlen>240);
+	strcpy(cpcmd_buf, cmd);
+	ASCEBC(cpcmd_buf, cmdlen);
 
-        if (response != NULL && rlen > 0) {
+	if (response != NULL && rlen > 0) {
 #ifndef CONFIG_ARCH_S390X
                 asm volatile ("LRA   2,0(%0)\n\t"
                               "LR    4,%1\n\t"
                               "O     4,%4\n\t"
                               "LRA   3,0(%2)\n\t"
                               "LR    5,%3\n\t"
-                              ".long 0x83240008 # Diagnose 83\n\t"
+                              ".long 0x83240008 # Diagnose X'08'\n\t"
                               : /* no output */
                               : "a" (cpcmd_buf), "d" (cmdlen),
                                 "a" (response), "d" (rlen), "m" (mask)
-                              : "2", "3", "4", "5" );
+                              : "cc", "2", "3", "4", "5" );
 #else /* CONFIG_ARCH_S390X */
                 asm volatile ("   lrag  2,0(%0)\n"
                               "   lgr   4,%1\n"
@@ -47,19 +48,19 @@
                               "   lrag  3,0(%2)\n"
                               "   lgr   5,%3\n"
                               "   sam31\n"
-                              "   .long 0x83240008 # Diagnose 83\n"
+                              "   .long 0x83240008 # Diagnose X'08'\n"
                               "   sam64"
                               : /* no output */
                               : "a" (cpcmd_buf), "d" (cmdlen),
                                 "a" (response), "d" (rlen), "m" (mask)
-                              : "2", "3", "4", "5" );
+                              : "cc", "2", "3", "4", "5" );
 #endif /* CONFIG_ARCH_S390X */
                 EBCASC(response, rlen);
         } else {
 #ifndef CONFIG_ARCH_S390X
                 asm volatile ("LRA   2,0(%0)\n\t"
                               "LR    3,%1\n\t"
-                              ".long 0x83230008 # Diagnose 83\n\t"
+                              ".long 0x83230008 # Diagnose X'08'\n\t"
                               : /* no output */
                               : "a" (cpcmd_buf), "d" (cmdlen)
                               : "2", "3"  );
@@ -67,7 +68,7 @@
                 asm volatile ("   lrag  2,0(%0)\n"
                               "   lgr   3,%1\n"
                               "   sam31\n"
-                              "   .long 0x83230008 # Diagnose 83\n"
+                              "   .long 0x83230008 # Diagnose X'08'\n"
                               "   sam64"
                               : /* no output */
                               : "a" (cpcmd_buf), "d" (cmdlen)
diff -Nru a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
--- a/arch/s390/kernel/debug.c	2004-12-24 13:36:18 -08:00
+++ b/arch/s390/kernel/debug.c	2004-12-24 13:36:18 -08:00
@@ -16,6 +16,7 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/ctype.h>
+#include <linux/sysctl.h>
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 
@@ -708,6 +709,70 @@
 		proceed_active_area(id);
 }
 
+static int debug_stoppable=1;
+static int debug_active=1;
+
+#define CTL_S390DBF 5677
+#define CTL_S390DBF_STOPPABLE 5678
+#define CTL_S390DBF_ACTIVE 5679
+
+/*
+ * proc handler for the running debug_active sysctl
+ * always allow read, allow write only if debug_stoppable is set or
+ * if debug_active is already off
+ */
+static int s390dbf_procactive(ctl_table *table, int write, struct file *filp,
+                     void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+	if (!write || debug_stoppable || !debug_active)
+		return proc_dointvec(table, write, filp, buffer, lenp, ppos);
+	else
+		return 0;
+}
+
+
+static struct ctl_table s390dbf_table[] = {
+	{
+		.ctl_name       = CTL_S390DBF_STOPPABLE,
+		.procname       = "debug_stoppable",
+		.data		= &debug_stoppable,
+		.maxlen		= sizeof(int),
+		.mode           = S_IRUGO | S_IWUSR,
+		.proc_handler   = &proc_dointvec,
+		.strategy	= &sysctl_intvec,
+	},
+	 {
+		.ctl_name       = CTL_S390DBF_ACTIVE,
+		.procname       = "debug_active",
+		.data		= &debug_active,
+		.maxlen		= sizeof(int),
+		.mode           = S_IRUGO | S_IWUSR,
+		.proc_handler   = &s390dbf_procactive,
+		.strategy	= &sysctl_intvec,
+	},
+	{ .ctl_name = 0 }
+};
+
+static struct ctl_table s390dbf_dir_table[] = {
+	{
+		.ctl_name       = CTL_S390DBF,
+		.procname       = "s390dbf",
+		.maxlen         = 0,
+		.mode           = S_IRUGO | S_IXUGO,
+		.child          = s390dbf_table,
+	},
+	{ .ctl_name = 0 }
+};
+
+struct ctl_table_header *s390dbf_sysctl_header;
+
+void debug_stop_all(void)
+{
+	if (debug_stoppable)
+		debug_active = 0;
+}
+
+
 /*
  * debug_event_common:
  * - write debug entry with given size
@@ -719,6 +784,8 @@
 	unsigned long flags;
 	debug_entry_t *active;
 
+	if (!debug_active)
+		return NULL;
 	spin_lock_irqsave(&id->lock, flags);
 	active = get_active_entry(id);
 	memset(DEBUG_DATA(active), 0, id->buf_size);
@@ -740,6 +807,8 @@
 	unsigned long flags;
 	debug_entry_t *active;
 
+	if (!debug_active)
+		return NULL;
 	spin_lock_irqsave(&id->lock, flags);
 	active = get_active_entry(id);
 	memset(DEBUG_DATA(active), 0, id->buf_size);
@@ -780,7 +849,8 @@
 
 	if((!id) || (level > id->level))
 		return NULL;
-
+	if (!debug_active)
+		return NULL;
 	numargs=debug_count_numargs(string);
 
 	spin_lock_irqsave(&id->lock, flags);
@@ -812,6 +882,8 @@
 
 	if((!id) || (level > id->level))
 		return NULL;
+	if (!debug_active)
+		return NULL;
 
 	numargs=debug_count_numargs(string);
 
@@ -838,6 +910,7 @@
 {
 	int rc = 0;
 
+	s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table, 1);
 	down(&debug_lock);
 #ifdef CONFIG_PROC_FS
 	debug_proc_root_entry = proc_mkdir(DEBUG_DIR_ROOT, NULL);
@@ -1186,6 +1259,7 @@
 #ifdef CONFIG_PROC_FS
 	remove_proc_entry(debug_proc_root_entry->name, NULL);
 #endif /* CONFIG_PROC_FS */
+	unregister_sysctl_table(s390dbf_sysctl_header);
 	return;
 }
 
@@ -1199,6 +1273,7 @@
 EXPORT_SYMBOL(debug_register);
 EXPORT_SYMBOL(debug_unregister); 
 EXPORT_SYMBOL(debug_set_level);
+EXPORT_SYMBOL(debug_stop_all);
 EXPORT_SYMBOL(debug_register_view);
 EXPORT_SYMBOL(debug_unregister_view);
 EXPORT_SYMBOL(debug_event_common);
diff -Nru a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
--- a/arch/s390/kernel/entry.S	2004-12-24 13:36:19 -08:00
+++ b/arch/s390/kernel/entry.S	2004-12-24 13:36:19 -08:00
@@ -144,6 +144,7 @@
 	l	%r15,__THREAD_ksp(%r3)	# load kernel stack from next->tss.ksp
 	lm	%r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
 	st	%r3,__LC_CURRENT	# __LC_CURRENT = current task struct
+	lctl	%c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
 	l	%r3,__THREAD_info(%r3)  # load thread_info from task struct
 	st	%r3,__LC_THREAD_INFO
 	ahi	%r3,STACK_SIZE
@@ -228,6 +229,8 @@
 	basr	%r14,%r1               # call do_signal
 	tm	__TI_flags+3(%r9),_TIF_RESTART_SVC
 	bo	BASED(sysc_restart)
+	tm	__TI_flags+3(%r9),_TIF_SINGLE_STEP
+	bo	BASED(sysc_singlestep)
 	b	BASED(sysc_leave)      # out of here, do NOT recheck
 
 #
diff -Nru a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
--- a/arch/s390/kernel/entry64.S	2004-12-24 13:36:19 -08:00
+++ b/arch/s390/kernel/entry64.S	2004-12-24 13:36:19 -08:00
@@ -141,6 +141,7 @@
 	lg	%r15,__THREAD_ksp(%r3)	# load kernel stack from next->tss.ksp
         lmg     %r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
 	stg	%r3,__LC_CURRENT	# __LC_CURRENT = current task struct
+	lctl	%c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
 	lg	%r3,__THREAD_info(%r3)  # load thread_info from task struct
 	stg	%r3,__LC_THREAD_INFO
 	aghi	%r3,STACK_SIZE
@@ -230,6 +231,8 @@
 	brasl	%r14,do_signal    # call do_signal
 	tm	__TI_flags+7(%r9),_TIF_RESTART_SVC
 	jo	sysc_restart
+	tm	__TI_flags+7(%r9),_TIF_SINGLE_STEP
+	jo	sysc_singlestep
 	j	sysc_leave        # out of here, do NOT recheck
 
 #
diff -Nru a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
--- a/arch/s390/kernel/irq.c	2004-12-24 13:36:59 -08:00
+++ b/arch/s390/kernel/irq.c	2004-12-24 13:36:59 -08:00
@@ -86,7 +86,7 @@
 				     "   la    15,0(%1)\n"
 				     : : "a" (new), "a" (old),
 				         "a" (__do_softirq)
-				     : "0", "1", "2", "3", "4", "5",
+				     : "0", "1", "2", "3", "4", "5", "14",
 				       "cc", "memory" );
 		} else
 			/* We are already on the async stack. */
diff -Nru a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
--- a/arch/s390/kernel/process.c	2004-12-24 13:37:18 -08:00
+++ b/arch/s390/kernel/process.c	2004-12-24 13:37:18 -08:00
@@ -238,7 +238,6 @@
         frame = ((struct fake_frame *)
 		 (THREAD_SIZE + (unsigned long) p->thread_info)) - 1;
         p->thread.ksp = (unsigned long) frame;
-	p->set_child_tid = p->clear_child_tid = NULL;
 	/* Store access registers to kernel stack of new process. */
         frame->childregs = *regs;
 	frame->childregs.gprs[2] = 0;	/* child returns 0 on fork. */
@@ -340,7 +339,9 @@
         error = do_execve(filename, (char __user * __user *) regs.gprs[3],
 			  (char __user * __user *) regs.gprs[4], &regs);
 	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
 		current->thread.fp_regs.fpc = 0;
 		if (MACHINE_HAS_IEEE)
 			asm volatile("sfpc %0,%0" : : "d" (0));
diff -Nru a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
--- a/arch/s390/kernel/ptrace.c	2004-12-24 13:37:19 -08:00
+++ b/arch/s390/kernel/ptrace.c	2004-12-24 13:37:19 -08:00
@@ -626,7 +626,7 @@
 		 * perhaps it should be put in the status that it wants to 
 		 * exit.
 		 */
-		if (child->state == TASK_ZOMBIE) /* already dead */
+		if (child->exit_state == EXIT_ZOMBIE) /* already dead */
 			return 0;
 		child->exit_code = SIGKILL;
 		/* make sure the single step bit is not set. */
@@ -640,7 +640,10 @@
 			return -EIO;
 		clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
 		child->exit_code = data;
-		set_single_step(child);
+		if (data)
+			set_tsk_thread_flag(child, TIF_SINGLE_STEP);
+		else
+			set_single_step(child);
 		/* give it a chance to run. */
 		wake_up_process(child);
 		return 0;
diff -Nru a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
--- a/arch/s390/kernel/syscalls.S	2004-12-24 13:36:18 -08:00
+++ b/arch/s390/kernel/syscalls.S	2004-12-24 13:36:18 -08:00
@@ -283,5 +283,6 @@
 SYSCALL(sys_mq_unlink,sys_mq_unlink,sys32_mq_unlink_wrapper)
 SYSCALL(sys_mq_timedsend,sys_mq_timedsend,compat_sys_mq_timedsend_wrapper)
 SYSCALL(sys_mq_timedreceive,sys_mq_timedreceive,compat_sys_mq_timedreceive_wrapper)
-SYSCALL(sys_mq_notify,sys_mq_notify,compat_sys_mq_notify_wrapper)
+SYSCALL(sys_mq_notify,sys_mq_notify,compat_sys_mq_notify_wrapper) /* 275 */
 SYSCALL(sys_mq_getsetattr,sys_mq_getsetattr,compat_sys_mq_getsetattr_wrapper)
+NI_SYSCALL							/* reserved for kexec */
diff -Nru a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
--- a/arch/s390/kernel/time.c	2004-12-24 13:36:16 -08:00
+++ b/arch/s390/kernel/time.c	2004-12-24 13:36:17 -08:00
@@ -233,8 +233,10 @@
 	while (ticks--)
 		update_process_times(user_mode(regs));
 #else
-	while (ticks--)
+	while (ticks--) {
 		do_timer(regs);
+		update_process_times(user_mode(regs));
+	}
 #endif
 	s390_do_profile(regs);
 }
@@ -258,18 +260,21 @@
 	if (sysctl_hz_timer != 0)
 		return;
 
+	cpu_set(smp_processor_id(), nohz_cpu_mask);
+
 	/*
 	 * Leave the clock comparator set up for the next timer
 	 * tick if either rcu or a softirq is pending.
 	 */
-	if (rcu_pending(smp_processor_id()) || local_softirq_pending())
+	if (rcu_pending(smp_processor_id()) || local_softirq_pending()) {
+		cpu_clear(smp_processor_id(), nohz_cpu_mask);
 		return;
+	}
 
 	/*
 	 * This cpu is going really idle. Set up the clock comparator
 	 * for the next event.
 	 */
-	cpu_set(smp_processor_id(), nohz_cpu_mask);
 	timer = (__u64) (next_timer_interrupt() - jiffies) + jiffies_64;
 	timer = jiffies_timer_cc + timer * CLK_TICKS_PER_JIFFY;
 	asm volatile ("SCKC %0" : : "m" (timer));
diff -Nru a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
--- a/arch/s390/kernel/traps.c	2004-12-24 13:36:47 -08:00
+++ b/arch/s390/kernel/traps.c	2004-12-24 13:36:47 -08:00
@@ -38,6 +38,7 @@
 #include <asm/cpcmd.h>
 #include <asm/s390_ext.h>
 #include <asm/lowcore.h>
+#include <asm/debug.h>
 
 /* Called from entry.S only */
 extern void handle_per_exception(struct pt_regs *regs);
@@ -277,8 +278,10 @@
 void die(const char * str, struct pt_regs * regs, long err)
 {
 	static int die_counter;
-        console_verbose();
-        spin_lock_irq(&die_lock);
+
+	debug_stop_all();
+	console_verbose();
+	spin_lock_irq(&die_lock);
 	bust_spinlocks(1);
 	printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
         show_regs(regs);
@@ -291,6 +294,20 @@
         do_exit(SIGSEGV);
 }
 
+static void inline
+report_user_fault(long interruption_code, struct pt_regs *regs)
+{
+#if defined(CONFIG_SYSCTL)
+	if (!sysctl_userprocess_debug)
+		return;
+#endif
+#if defined(CONFIG_SYSCTL) || defined(CONFIG_PROCESS_DEBUG)
+	printk("User process fault: interruption code 0x%lX\n",
+	       interruption_code);
+	show_regs(regs);
+#endif
+}
+
 static void inline do_trap(long interruption_code, int signr, char *str,
                            struct pt_regs *regs, siginfo_t *info)
 {
@@ -305,23 +322,8 @@
                 struct task_struct *tsk = current;
 
                 tsk->thread.trap_no = interruption_code & 0xffff;
-		if (info)
-			force_sig_info(signr, info, tsk);
-		else
-                	force_sig(signr, tsk);
-#ifndef CONFIG_SYSCTL
-#ifdef CONFIG_PROCESS_DEBUG
-                printk("User process fault: interruption code 0x%lX\n",
-                       interruption_code);
-                show_regs(regs);
-#endif
-#else
-		if (sysctl_userprocess_debug) {
-			printk("User process fault: interruption code 0x%lX\n",
-			       interruption_code);
-			show_regs(regs);
-		}
-#endif
+		force_sig_info(signr, info, tsk);
+		report_user_fault(interruption_code, regs);
         } else {
                 const struct exception_table_entry *fixup;
                 fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN);
@@ -343,10 +345,15 @@
 		force_sig(SIGTRAP, current);
 }
 
-#define DO_ERROR(signr, str, name) \
-asmlinkage void name(struct pt_regs * regs, long interruption_code) \
-{ \
-	do_trap(interruption_code, signr, str, regs, NULL); \
+asmlinkage void
+default_trap_handler(struct pt_regs * regs, long interruption_code)
+{
+        if (regs->psw.mask & PSW_MASK_PSTATE) {
+		local_irq_enable();
+		do_exit(SIGSEGV);
+		report_user_fault(interruption_code, regs);
+	} else
+		die("Unknown program exception", regs, interruption_code);
 }
 
 #define DO_ERROR_INFO(signr, str, name, sicode, siaddr) \
@@ -360,8 +367,6 @@
         do_trap(interruption_code, signr, str, regs, &info); \
 }
 
-DO_ERROR(SIGSEGV, "Unknown program exception", default_trap_handler)
-
 DO_ERROR_INFO(SIGILL, "addressing exception", addressing_exception,
 	      ILL_ILLADR, get_check_address(regs))
 DO_ERROR_INFO(SIGILL,  "execute exception", execute_exception,
@@ -420,6 +425,7 @@
 
 asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code)
 {
+	siginfo_t info;
         __u8 opcode[6];
 	__u16 *location;
 	int signal = 0;
@@ -463,12 +469,27 @@
 	} else
 		signal = SIGILL;
 
+#ifdef CONFIG_MATHEMU
         if (signal == SIGFPE)
 		do_fp_trap(regs, location,
                            current->thread.fp_regs.fpc, interruption_code);
-        else if (signal)
+        else if (signal == SIGSEGV) {
+		info.si_signo = signal;
+		info.si_errno = 0;
+		info.si_code = SEGV_MAPERR;
+		info.si_addr = (void *) location;
+		do_trap(interruption_code, signal,
+			"user address fault", regs, &info);
+	} else
+#endif
+        if (signal) {
+		info.si_signo = signal;
+		info.si_errno = 0;
+		info.si_code = ILL_ILLOPC;
+		info.si_addr = (void *) location;
 		do_trap(interruption_code, signal,
-			"illegal operation", regs, NULL);
+			"illegal operation", regs, &info);
+	}
 }
 
 
@@ -630,6 +651,21 @@
 	}
 }
 
+asmlinkage void space_switch_exception(struct pt_regs * regs, long int_code)
+{
+        siginfo_t info;
+
+	/* Set user psw back to home space mode. */
+	if (regs->psw.mask & PSW_MASK_PSTATE)
+		regs->psw.mask |= PSW_ASC_HOME;
+	/* Send SIGILL. */
+        info.si_signo = SIGILL;
+        info.si_errno = 0;
+        info.si_code = ILL_PRVOPC;
+        info.si_addr = get_check_address(regs);
+        do_trap(int_code, SIGILL, "space switch event", regs, &info);
+}
+
 asmlinkage void kernel_stack_overflow(struct pt_regs * regs)
 {
 	die("Kernel stack overflow", regs, 0);
@@ -673,7 +709,7 @@
         pgm_check_table[0x3B] = &do_dat_exception;
 #endif /* CONFIG_ARCH_S390X */
         pgm_check_table[0x15] = &operand_exception;
-        pgm_check_table[0x1C] = &privileged_op;
+        pgm_check_table[0x1C] = &space_switch_exception;
         pgm_check_table[0x1D] = &hfp_sqrt_exception;
 	pgm_check_table[0x40] = &do_monitor_call;
 
diff -Nru a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
--- a/arch/s390/mm/extmem.c	2004-12-24 13:37:04 -08:00
+++ b/arch/s390/mm/extmem.c	2004-12-24 13:37:04 -08:00
@@ -1,11 +1,10 @@
 /*
- * File...........: arch/s390/mm/dcss.c
- * Author(s)......: Steven Shultz <shultzss@us.ibm.com>
- *                  Carsten Otte <cotte@de.ibm.com>
+ * File...........: arch/s390/mm/extmem.c
+ * Author(s)......: Carsten Otte <cotte@de.ibm.com>
+ * 		    Rob M van der Heij <rvdheij@nl.ibm.com>
+ * 		    Steven Shultz <shultzss@us.ibm.com>
  * Bugreports.to..: <Linux390@de.ibm.com>
- * thanks to Rob M van der Heij
- * - he wrote the diag64 function
- * (C) IBM Corporation 2002
+ * (C) IBM Corporation 2002-2004
  */
 
 #include <linux/kernel.h>
@@ -41,20 +40,48 @@
 #define DCSS_FINDSEG    0x0c
 #define DCSS_LOADNOLY   0x10
 #define DCSS_SEGEXT     0x18
-#define DCSS_QACTV      0x0c
+#define DCSS_FINDSEGA   0x0c
+
+struct qrange {
+	unsigned int  start; // 3byte start address, 1 byte type
+	unsigned int  end;   // 3byte end address, 1 byte reserved
+};
+
+struct qout64 {
+	int segstart;
+	int segend;
+	int segcnt;
+	int segrcnt;
+	struct qrange range[6];
+};
+
+struct qin64 {
+	char qopcode;
+	char rsrv1[3];
+	char qrcode;
+	char rsrv2[3];
+	char qname[8];
+	unsigned int qoutptr;
+	short int qoutlen;
+};
 
 struct dcss_segment {
-        struct list_head list;
-        char dcss_name[8];
-        unsigned long start_addr;
-        unsigned long end;
-        atomic_t ref_count;
-        int dcss_attr;
-	int shared_attr;
+	struct list_head list;
+	char dcss_name[8];
+	unsigned long start_addr;
+	unsigned long end;
+	atomic_t ref_count;
+	int do_nonshared;
+	unsigned int vm_segtype;
+	struct qrange range[6];
+	int segcnt;
 };
 
 static spinlock_t dcss_lock = SPIN_LOCK_UNLOCKED;
 static struct list_head dcss_list = LIST_HEAD_INIT(dcss_list);
+static char *segtype_string[] = { "SW", "EW", "SR", "ER", "SN", "EN", "SC",
+					"EW/EN-MIXED" };
+
 extern struct {
 	unsigned long addr, size, type;
 } memory_chunk[MEMORY_CHUNKS];
@@ -63,20 +90,46 @@
  * Create the 8 bytes, ebcdic VM segment name from
  * an ascii name.
  */
-static void inline dcss_mkname(char *name, char *dcss_name)
+static void inline
+dcss_mkname(char *name, char *dcss_name)
 {
-        int i;
+	int i;
+
+	for (i = 0; i < 8; i++) {
+		if (name[i] == '\0')
+			break;
+		dcss_name[i] = toupper(name[i]);
+	};
+	for (; i < 8; i++)
+		dcss_name[i] = ' ';
+	ASCEBC(dcss_name, 8);
+}
 
-        for (i = 0; i <= 8; i++) {
-                if (name[i] == '\0')
-                        break;
-                dcss_name[i] = toupper(name[i]);
-        };
-        for (; i <= 8; i++)
-                dcss_name[i] = ' ';
-        ASCEBC(dcss_name, 8);
+
+/*
+ * search all segments in dcss_list, and return the one
+ * namend *name. If not found, return NULL.
+ */
+static struct dcss_segment *
+segment_by_name (char *name)
+{
+	char dcss_name[9];
+	struct list_head *l;
+	struct dcss_segment *tmp, *retval = NULL;
+
+	BUG_ON (!spin_is_locked(&dcss_lock));
+	dcss_mkname (name, dcss_name);
+	list_for_each (l, &dcss_list) {
+		tmp = list_entry (l, struct dcss_segment, list);
+		if (memcmp(tmp->dcss_name, dcss_name, 8) == 0) {
+			retval = tmp;
+			break;
+		}
+	}
+	return retval;
 }
 
+
 /*
  * Perform a function on a dcss segment.
  */
@@ -84,337 +137,378 @@
 dcss_diag (__u8 func, void *parameter,
            unsigned long *ret1, unsigned long *ret2)
 {
-        unsigned long rx, ry;
-        int rc;
+	unsigned long rx, ry;
+	int rc;
 
-        rx = (unsigned long) parameter;
-        ry = (unsigned long) func;
-        __asm__ __volatile__(
+	rx = (unsigned long) parameter;
+	ry = (unsigned long) func;
+	__asm__ __volatile__(
 #ifdef CONFIG_ARCH_S390X
-                             "   sam31\n" // switch to 31 bit
-                             "   diag    %0,%1,0x64\n"
-                             "   sam64\n" // switch back to 64 bit
+		"   sam31\n" // switch to 31 bit
+		"   diag    %0,%1,0x64\n"
+		"   sam64\n" // switch back to 64 bit
 #else
-                             "   diag    %0,%1,0x64\n"
+		"   diag    %0,%1,0x64\n"
 #endif
-                             "   ipm     %2\n"
-                             "   srl     %2,28\n"
-                             : "+d" (rx), "+d" (ry), "=d" (rc) : : "cc" );
-        *ret1 = rx;
-        *ret2 = ry;
-        return rc;
+		"   ipm     %2\n"
+		"   srl     %2,28\n"
+		: "+d" (rx), "+d" (ry), "=d" (rc) : : "cc" );
+	*ret1 = rx;
+	*ret2 = ry;
+	return rc;
+}
+
+static inline int
+dcss_diag_translate_rc (int vm_rc) {
+	if (vm_rc == 44)
+		return -ENOENT;
+	return -EIO;
 }
 
 
-/* use to issue "extended" dcss query */
+/* do a diag to get info about a segment.
+ * fills start_address, end and vm_segtype fields
+ */
+static int
+query_segment_type (struct dcss_segment *seg)
+{
+	struct qin64  *qin = kmalloc (sizeof(struct qin64), GFP_DMA);
+	struct qout64 *qout = kmalloc (sizeof(struct qout64), GFP_DMA);
+
+	int diag_cc, rc, i;
+	unsigned long dummy, vmrc;
+
+	if ((qin == NULL) || (qout == NULL)) {
+		rc = -ENOMEM;
+		goto out_free;
+	}
+
+	/* initialize diag input parameters */
+	qin->qopcode = DCSS_FINDSEGA;
+	qin->qoutptr = (unsigned long) qout;
+	qin->qoutlen = sizeof(struct qout64);
+	memcpy (qin->qname, seg->dcss_name, 8);
+
+	diag_cc = dcss_diag (DCSS_SEGEXT, qin, &dummy, &vmrc);
+
+	if (diag_cc > 1) {
+		rc = dcss_diag_translate_rc (vmrc);
+		goto out_free;
+	}
+
+	if (qout->segcnt > 6) {
+		rc = -ENOTSUPP;
+		goto out_free;
+	}
+
+	if (qout->segcnt == 1) {
+		seg->vm_segtype = qout->range[0].start & 0xff;
+	} else {
+		/* multi-part segment. only one type supported here:
+		    - all parts are contiguous
+		    - all parts are either EW or EN type
+		    - maximum 6 parts allowed */
+		unsigned long start = qout->segstart >> PAGE_SHIFT;
+		for (i=0; i<qout->segcnt; i++) {
+			if (((qout->range[i].start & 0xff) != SEG_TYPE_EW) &&
+			    ((qout->range[i].start & 0xff) != SEG_TYPE_EN)) {
+				rc = -ENOTSUPP;
+				goto out_free;
+			}
+			if (start != qout->range[i].start >> PAGE_SHIFT) {
+				rc = -ENOTSUPP;
+				goto out_free;
+			}
+			start = (qout->range[i].end >> PAGE_SHIFT) + 1;
+		}
+		seg->vm_segtype = SEG_TYPE_EWEN;
+	}
+
+	/* analyze diag output and update seg */
+	seg->start_addr = qout->segstart;
+	seg->end = qout->segend;
+
+	memcpy (seg->range, qout->range, 6*sizeof(struct qrange));
+	seg->segcnt = qout->segcnt;
+
+	rc = 0;
+
+ out_free:
+	if (qin) kfree(qin);
+	if (qout) kfree(qout);
+	return rc;
+}
+
+/*
+ * check if the given segment collides with guest storage.
+ * returns 1 if this is the case, 0 if no collision was found
+ */
+static int
+segment_overlaps_storage(struct dcss_segment *seg)
+{
+	int i;
+
+	for (i=0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
+		if (memory_chunk[i].type != 0)
+			continue;
+		if ((memory_chunk[i].addr >> 20) > (seg->end >> 20))
+			continue;
+		if (((memory_chunk[i].addr + memory_chunk[i].size - 1) >> 20)
+				< (seg->start_addr >> 20))
+			continue;
+		return 1;
+	}
+	return 0;
+}
+
+/*
+ * check if segment collides with other segments that are currently loaded
+ * returns 1 if this is the case, 0 if no collision was found
+ */
+static int
+segment_overlaps_others (struct dcss_segment *seg)
+{
+	struct list_head *l;
+	struct dcss_segment *tmp;
+
+	BUG_ON (!spin_is_locked(&dcss_lock));
+	list_for_each(l, &dcss_list) {
+		tmp = list_entry(l, struct dcss_segment, list);
+		if ((tmp->start_addr >> 20) > (seg->end >> 20))
+			continue;
+		if ((tmp->end >> 20) < (seg->start_addr >> 20))
+			continue;
+		if (seg == tmp)
+			continue;
+		return 1;
+	}
+	return 0;
+}
+
+/*
+ * check if segment exceeds the kernel mapping range (detected or set via mem=)
+ * returns 1 if this is the case, 0 if segment fits into the range
+ */
 static inline int
-dcss_diag_query(char *name, int *rwattr, int *shattr, unsigned long *segstart, unsigned long *segend)
+segment_exceeds_range (struct dcss_segment *seg)
 {
-        int i,j,rc;
-        unsigned long  rx, ry;
+	int seg_last_pfn = (seg->end) >> PAGE_SHIFT;
+	if (seg_last_pfn > max_pfn)
+		return 1;
+	return 0;
+}
 
-        typedef struct segentry {
-                char thisseg[8];
-        } segentry;
-
-        struct qout64 {
-                int segstart;
-                int segend;
-                int segcnt;
-                int segrcnt;
-                segentry segout[6];
-        };
-
-        struct qin64 {
-                char qopcode;
-                char rsrv1[3];
-                char qrcode;
-                char rsrv2[3];
-                char qname[8];
-                unsigned int qoutptr;
-                short int qoutlen;
-        };
-
-
-        struct qin64  *qinarea;
-        struct qout64 *qoutarea;
-
-        qinarea = (struct qin64*) get_zeroed_page (GFP_DMA);
-        if (!qinarea) {
-                rc =-ENOMEM;
-                goto out;
-        }
-        qoutarea = (struct qout64*) get_zeroed_page (GFP_DMA);
-        if (!qoutarea) {
-                rc = -ENOMEM;
-                free_page ((unsigned long) qinarea);
-                goto out;
-        }
-        memset (qinarea,0,PAGE_SIZE);
-        memset (qoutarea,0,PAGE_SIZE);
-
-        qinarea->qopcode = DCSS_QACTV; /* do a query for active
-                                          segments */
-        qinarea->qoutptr = (unsigned long) qoutarea;
-        qinarea->qoutlen = sizeof(struct qout64);
-
-        /* Move segment name into double word aligned
-           field and pad with blanks to 8 long.
-         */
-
-        for (i = j = 0 ; i < 8; i++) {
-                qinarea->qname[i] = (name[j] == '\0') ? ' ' : name[j++];
-        }
-
-        /* name already in EBCDIC */
-        /* ASCEBC ((void *)&qinarea.qname, 8); */
-
-        /* set the assembler variables */
-        rx = (unsigned long) qinarea;
-        ry = DCSS_SEGEXT; /* this is extended function */
+/*
+ * get info about a segment
+ * possible return values:
+ * -ENOSYS  : we are not running on VM
+ * -EIO     : could not perform query diagnose
+ * -ENOENT  : no such segment
+ * -ENOTSUPP: multi-part segment cannot be used with linux
+ * -ENOSPC  : segment cannot be used (overlaps with storage)
+ * -ENOMEM  : out of memory
+ * 0 .. 6   : type of segment as defined in include/asm-s390/extmem.h
+ */
+int
+segment_type (char* name)
+{
+	int rc;
+	struct dcss_segment seg;
 
-        /* issue diagnose x'64' */
-        __asm__ __volatile__(
-#ifdef CONFIG_ARCH_S390X
-                             "   sam31\n" // switch to 31 bit
-                             "   diag    %0,%1,0x64\n"
-                             "   sam64\n" // switch back to 64 bit
-#else
-                             "   diag    %0,%1,0x64\n"
-#endif
-                             "   ipm     %2\n"
-                             "   srl     %2,28\n"
-                             : "+d" (rx), "+d" (ry), "=d" (rc) : : "cc" );
-
-        /* parse the query output area */
-	*segstart=qoutarea->segstart;
-	*segend=qoutarea->segend;
-
-        if (rc > 1)
-                {
-                        *rwattr = 2;
-                        *shattr = 2;
-                        rc = 0;
-                        goto free;
-                }
-
-        if (qoutarea->segcnt > 6)
-                {
-                        *rwattr = 3;
-                        *shattr = 3;
-                        rc = 0;
-                        goto free;
-                }
-
-        *rwattr = 1;
-        *shattr = 1;
-
-        for (i=0; i < qoutarea->segrcnt; i++) {
-                if (qoutarea->segout[i].thisseg[3] == 2 ||
-                    qoutarea->segout[i].thisseg[3] == 3 ||
-                    qoutarea->segout[i].thisseg[3] == 6 )
-                        *rwattr = 0;
-                if (qoutarea->segout[i].thisseg[3] == 1 ||
-                    qoutarea->segout[i].thisseg[3] == 3 ||
-                    qoutarea->segout[i].thisseg[3] == 5 )
-                        *shattr = 0;
-        } /* end of for statement */
-        rc = 0;
- free:
-        free_page ((unsigned long) qoutarea);
-        free_page ((unsigned long) qinarea);
+	if (!MACHINE_IS_VM)
+		return -ENOSYS;
+
+	dcss_mkname(name, seg.dcss_name);
+	rc = query_segment_type (&seg);
+	if (rc < 0)
+		return rc;
+	return seg.vm_segtype;
+}
+
+/*
+ * real segment loading function, called from segment_load
+ */
+static int
+__segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long *end)
+{
+	struct dcss_segment *seg = kmalloc(sizeof(struct dcss_segment),
+			GFP_DMA);
+	int dcss_command, rc, diag_cc;
+
+	if (seg == NULL) {
+		rc = -ENOMEM;
+		goto out;
+	}
+	dcss_mkname (name, seg->dcss_name);
+	rc = query_segment_type (seg);
+	if (rc < 0)
+		goto out_free;
+	if (segment_exceeds_range(seg)) {
+		PRINT_WARN ("segment_load: not loading segment %s - exceeds"
+				" kernel mapping range\n",name);
+		rc = -ERANGE;
+		goto out_free;
+	}
+	if (segment_overlaps_storage(seg)) {
+		PRINT_WARN ("segment_load: not loading segment %s - overlaps"
+				" storage\n",name);
+		rc = -ENOSPC;
+		goto out_free;
+	}
+	if (segment_overlaps_others(seg)) {
+		PRINT_WARN ("segment_load: not loading segment %s - overlaps"
+				" other segments\n",name);
+		rc = -EBUSY;
+		goto out_free;
+	}
+	if (do_nonshared)
+		dcss_command = DCSS_LOADNSR;
+	else
+		dcss_command = DCSS_LOADNOLY;
+
+	diag_cc = dcss_diag(dcss_command, seg->dcss_name,
+			&seg->start_addr, &seg->end);
+	if (diag_cc > 1) {
+		PRINT_WARN ("segment_load: could not load segment %s - "
+				"diag returned error (%ld)\n",name,seg->end);
+		rc = dcss_diag_translate_rc (seg->end);
+		dcss_diag(DCSS_PURGESEG, seg->dcss_name,
+				&seg->start_addr, &seg->end);
+		goto out_free;
+	}
+	seg->do_nonshared = do_nonshared;
+	atomic_set(&seg->ref_count, 1);
+	list_add(&seg->list, &dcss_list);
+	rc = seg->vm_segtype;
+	*addr = seg->start_addr;
+	*end  = seg->end;
+	if (do_nonshared)
+		PRINT_INFO ("segment_load: loaded segment %s range %p .. %p "
+				"type %s in non-shared mode\n", name,
+				(void*)seg->start_addr, (void*)seg->end,
+				segtype_string[seg->vm_segtype]);
+	else
+		PRINT_INFO ("segment_load: loaded segment %s range %p .. %p "
+				"type %s in shared mode\n", name,
+				(void*)seg->start_addr, (void*)seg->end,
+				segtype_string[seg->vm_segtype]);
+	goto out;
+ out_free:
+	kfree (seg);
  out:
-        return rc;
+	return rc;
 }
 
 /*
- * Load a DCSS segment via the diag 0x64.
+ * this function loads a DCSS segment
+ * name         : name of the DCSS
+ * do_nonshared : 0 indicates that the dcss should be shared with other linux images
+ *                1 indicates that the dcss should be exclusive for this linux image
+ * addr         : will be filled with start address of the segment
+ * end          : will be filled with end address of the segment
+ * return values:
+ * -ENOSYS  : we are not running on VM
+ * -EIO     : could not perform query or load diagnose
+ * -ENOENT  : no such segment
+ * -ENOTSUPP: multi-part segment cannot be used with linux
+ * -ENOSPC  : segment cannot be used (overlaps with storage)
+ * -EBUSY   : segment can temporarily not be used (overlaps with dcss)
+ * -ERANGE  : segment cannot be used (exceeds kernel mapping range)
+ * -EPERM   : segment is currently loaded with incompatible permissions
+ * -ENOMEM  : out of memory
+ * 0 .. 6   : type of segment as defined in include/asm-s390/extmem.h
  */
-int segment_load(char *name, int segtype, unsigned long *addr,
-                 unsigned long *end)
+int
+segment_load (char *name, int do_nonshared, unsigned long *addr,
+		unsigned long *end)
 {
-        char dcss_name[8];
-        struct list_head *l;
-        struct dcss_segment *seg, *tmp;
-	unsigned long dummy;
-	unsigned long segstart, segend;
-        int rc = 0,i;
-        int rwattr, shattr;
-
-        if (!MACHINE_IS_VM)
-                return -ENOSYS;
-        dcss_mkname(name, dcss_name);
-	/* search for the dcss in list of currently loaded segments */
-        spin_lock(&dcss_lock);
-        seg = NULL;
-        list_for_each(l, &dcss_list) {
-                tmp = list_entry(l, struct dcss_segment, list);
-                if (memcmp(tmp->dcss_name, dcss_name, 8) == 0) {
-                        seg = tmp;
-                        break;
-                }
-        }
-
-        if (seg == NULL) {
-                /* find out the attributes of this
-                   shared segment */
-                dcss_diag_query(dcss_name, &rwattr, &shattr, &segstart, &segend);
-		/* does segment collide with main memory? */
-		for (i=0; i < MEMORY_CHUNKS; i++) {
-			if (memory_chunk[i].type != 0)
-				continue;
-			if (memory_chunk[i].addr > segend)
-				continue;
-			if (memory_chunk[i].addr + memory_chunk[i].size <= segstart)
-				continue;
-			spin_unlock(&dcss_lock);
-			return -ENOENT;
-		}
-		/* or does it collide with other (loaded) segments? */
-        	list_for_each(l, &dcss_list) {
-                	tmp = list_entry(l, struct dcss_segment, list);
-	                if ((segstart <= tmp->end && segstart >= tmp->start_addr) ||
-				(segend <= tmp->end && segend >= tmp->start_addr) ||
-				(segstart <= tmp->start_addr && segend >= tmp->end)) {
-				PRINT_ERR("Segment Overlap!\n");
-			        spin_unlock(&dcss_lock);
-				return -ENOENT;
-	                }
-        	}
-
-                /* do case statement on segtype */
-                /* if asking for shared ro,
-                   shared rw works */
-                /* if asking for exclusive ro,
-                   exclusive rw works */
-
-                switch(segtype) {
-                case SEGMENT_SHARED_RO:
-                        if (shattr > 1 || rwattr > 1) {
-                                spin_unlock(&dcss_lock);
-                                return -ENOENT;
-                        } else {
-                                if (shattr == 0 && rwattr == 0)
-                                        rc = SEGMENT_EXCLUSIVE_RO;
-                                if (shattr == 0 && rwattr == 1)
-                                        rc = SEGMENT_EXCLUSIVE_RW;
-                                if (shattr == 1 && rwattr == 0)
-                                        rc = SEGMENT_SHARED_RO;
-                                if (shattr == 1 && rwattr == 1)
-                                        rc = SEGMENT_SHARED_RW;
-                        }
-                        break;
-                case SEGMENT_SHARED_RW:
-                        if (shattr > 1 || rwattr != 1) {
-                                spin_unlock(&dcss_lock);
-                                return -ENOENT;
-                        } else {
-                                if (shattr == 0)
-                                        rc = SEGMENT_EXCLUSIVE_RW;
-                                if (shattr == 1)
-                                        rc = SEGMENT_SHARED_RW;
-                        }
-                        break;
-
-                case SEGMENT_EXCLUSIVE_RO:
-                        if (shattr > 0 || rwattr > 1) {
-                                spin_unlock(&dcss_lock);
-                                return -ENOENT;
-                        } else {
-                                if (rwattr == 0)
-                                        rc = SEGMENT_EXCLUSIVE_RO;
-                                if (rwattr == 1)
-                                        rc = SEGMENT_EXCLUSIVE_RW;
-                        }
-                        break;
-
-                case SEGMENT_EXCLUSIVE_RW:
-/*                        if (shattr != 0 || rwattr != 1) {
-                                spin_unlock(&dcss_lock);
-                                return -ENOENT;
-                        } else {
-*/
-                                rc = SEGMENT_EXCLUSIVE_RW;
-//                        }
-                        break;
-
-                default:
-                        spin_unlock(&dcss_lock);
-                        return -ENOENT;
-                } /* end switch */
-
-                seg = kmalloc(sizeof(struct dcss_segment), GFP_DMA);
-                if (seg != NULL) {
-                        memcpy(seg->dcss_name, dcss_name, 8);
-			if (rc == SEGMENT_EXCLUSIVE_RW) {
-				if (dcss_diag(DCSS_LOADNSR, seg->dcss_name,
-						&seg->start_addr, &seg->end) == 0) {
-					if (seg->end < max_low_pfn*PAGE_SIZE ) {
-						atomic_set(&seg->ref_count, 1);
-						list_add(&seg->list, &dcss_list);
-						*addr = seg->start_addr;
-						*end = seg->end;
-						seg->dcss_attr = rc;
-						if (shattr == 1 && rwattr == 1)
-							seg->shared_attr = SEGMENT_SHARED_RW;
-						else if (shattr == 1 && rwattr == 0)
-							seg->shared_attr = SEGMENT_SHARED_RO;
-						else
-							seg->shared_attr = SEGMENT_EXCLUSIVE_RW;
-					} else {
-						dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy);
-						kfree (seg);
-						rc = -ENOENT;
-					}
-				} else {
-					kfree(seg);
-					rc = -ENOENT;
-			        }
-				goto out;
-                        }
-			if (dcss_diag(DCSS_LOADNOLY, seg->dcss_name,
-                                      &seg->start_addr, &seg->end) == 0) {
-				if (seg->end < max_low_pfn*PAGE_SIZE ) {
-		                        atomic_set(&seg->ref_count, 1);
-					list_add(&seg->list, &dcss_list);
-					*addr = seg->start_addr;
-					*end = seg->end;
-					seg->dcss_attr = rc;
-					seg->shared_attr = rc;
-				} else {
-					dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy);
-					kfree (seg);
-					rc = -ENOENT;
-				}
-                        } else {
-                                kfree(seg);
-                                rc = -ENOENT;
-                        }
-                } else rc = -ENOMEM;
-        } else {
-		/* found */
-		if ((segtype == SEGMENT_EXCLUSIVE_RW) && (seg->dcss_attr != SEGMENT_EXCLUSIVE_RW)) {
-			PRINT_ERR("Segment already loaded in other mode than EXCLUSIVE_RW!\n");
-			rc = -EPERM;
-			goto out;
-			/* reload segment in exclusive mode */
-/*			dcss_diag(DCSS_LOADNSR, seg->dcss_name,
-				  &seg->start_addr, &seg->end);
-			seg->dcss_attr = SEGMENT_EXCLUSIVE_RW;*/
-		}
-		if ((segtype != SEGMENT_EXCLUSIVE_RW) && (seg->dcss_attr == SEGMENT_EXCLUSIVE_RW)) {
-			PRINT_ERR("Segment already loaded in EXCLUSIVE_RW mode!\n");
-			rc = -EPERM;
-			goto out;
+	struct dcss_segment *seg;
+	int rc;
+
+	if (!MACHINE_IS_VM)
+		return -ENOSYS;
+
+	spin_lock (&dcss_lock);
+	seg = segment_by_name (name);
+	if (seg == NULL)
+		rc = __segment_load (name, do_nonshared, addr, end);
+	else {
+		if (do_nonshared == seg->do_nonshared) {
+			atomic_inc(&seg->ref_count);
+			*addr = seg->start_addr;
+			*end  = seg->end;
+			rc    = seg->vm_segtype;
+		} else {
+			*addr = *end = 0;
+			rc    = -EPERM;
 		}
-                atomic_inc(&seg->ref_count);
-                *addr = seg->start_addr;
-                *end = seg->end;
-                rc = seg->dcss_attr;
-        }
-out:
-        spin_unlock(&dcss_lock);
-        return rc;
+	}
+	spin_unlock (&dcss_lock);
+	return rc;
+}
+
+/*
+ * this function modifies the shared state of a DCSS segment. note that
+ * name         : name of the DCSS
+ * do_nonshared : 0 indicates that the dcss should be shared with other linux images
+ *                1 indicates that the dcss should be exclusive for this linux image
+ * return values:
+ * -EIO     : could not perform load diagnose (segment gone!)
+ * -ENOENT  : no such segment (segment gone!)
+ * -EAGAIN  : segment is in use by other exploiters, try later
+ * -EINVAL  : no segment with the given name is currently loaded - name invalid
+ * 0	    : operation succeeded
+ */
+int
+segment_modify_shared (char *name, int do_nonshared)
+{
+	struct dcss_segment *seg;
+	unsigned long dummy;
+	int dcss_command, rc, diag_cc;
+
+	spin_lock (&dcss_lock);
+	seg = segment_by_name (name);
+	if (seg == NULL) {
+		rc = -EINVAL;
+		goto out_unlock;
+	}
+	if (do_nonshared == seg->do_nonshared) {
+		PRINT_INFO ("segment_modify_shared: not reloading segment %s"
+				" - already in requested mode\n",name);
+		rc = 0;
+		goto out_unlock;
+	}
+	if (atomic_read (&seg->ref_count) != 1) {
+		PRINT_WARN ("segment_modify_shared: not reloading segment %s - "
+				"segment is in use by other driver(s)\n",name);
+		rc = -EAGAIN;
+		goto out_unlock;
+	}
+	dcss_diag(DCSS_PURGESEG, seg->dcss_name,
+		  &dummy, &dummy);
+	if (do_nonshared)
+		dcss_command = DCSS_LOADNSR;
+	else
+	dcss_command = DCSS_LOADNOLY;
+	diag_cc = dcss_diag(dcss_command, seg->dcss_name,
+			&seg->start_addr, &seg->end);
+	if (diag_cc > 1) {
+		PRINT_WARN ("segment_modify_shared: could not reload segment %s"
+				" - diag returned error (%ld)\n",name,seg->end);
+		rc = dcss_diag_translate_rc (seg->end);
+		goto out_del;
+	}
+	seg->do_nonshared = do_nonshared;
+	rc = 0;
+	goto out_unlock;
+ out_del:
+	list_del(&seg->list);
+	dcss_diag(DCSS_PURGESEG, seg->dcss_name,
+		  &dummy, &dummy);
+	kfree (seg);
+ out_unlock:
+	spin_unlock(&dcss_lock);
+	return rc;
 }
 
 /*
@@ -422,84 +516,72 @@
  * it from the address space if nobody is using it
  * any longer.
  */
-void segment_unload(char *name)
+void
+segment_unload(char *name)
 {
-        char dcss_name[8];
-        unsigned long dummy;
-        struct list_head *l,*l_tmp;
-        struct dcss_segment *seg;
-
-        if (!MACHINE_IS_VM)
-                return;
-        dcss_mkname(name, dcss_name);
-        spin_lock(&dcss_lock);
-        list_for_each_safe(l, l_tmp, &dcss_list) {
-                seg = list_entry(l, struct dcss_segment, list);
-                if (memcmp(seg->dcss_name, dcss_name, 8) == 0) {
-                        if (atomic_dec_return(&seg->ref_count) == 0) {
-                                /* Last user of the segment is
-                                   gone. */
-                                list_del(&seg->list);
-                                dcss_diag(DCSS_PURGESEG, seg->dcss_name,
-                                          &dummy, &dummy);
-				kfree(seg);
-                        }
-                        break;
-                }
-        }
-        spin_unlock(&dcss_lock);
-}
-
-/*
- * Replace an existing DCSS segment, so that machines
- * that load it anew will see the new version.
- */
-void segment_replace(char *name)
-{
-        char dcss_name[8];
-        struct list_head *l;
-        struct dcss_segment *seg;
-        int mybeg = 0;
-        int myend = 0;
-        char mybuff1[80];
-        char mybuff2[80];
-
-        if (!MACHINE_IS_VM)
-                return;
-        dcss_mkname(name, dcss_name);
-
-        memset (mybuff1, 0, sizeof(mybuff1));
-        memset (mybuff2, 0, sizeof(mybuff2));
-
-        spin_lock(&dcss_lock);
-        list_for_each(l, &dcss_list) {
-                seg = list_entry(l, struct dcss_segment, list);
-                if (memcmp(seg->dcss_name, dcss_name, 8) == 0) {
-                        mybeg = seg->start_addr >> 12;
-                        myend = (seg->end) >> 12;
-                        if (seg->shared_attr == SEGMENT_EXCLUSIVE_RW)
-                                sprintf(mybuff1, "DEFSEG %s %X-%X EW",
-                                        name, mybeg, myend);
-                        if (seg->shared_attr == SEGMENT_EXCLUSIVE_RO)
-                                sprintf(mybuff1, "DEFSEG %s %X-%X RO",
-                                        name, mybeg, myend);
-                        if (seg->shared_attr == SEGMENT_SHARED_RW)
-                                sprintf(mybuff1, "DEFSEG %s %X-%X SW",
-                                        name, mybeg, myend);
-                        if (seg->shared_attr == SEGMENT_SHARED_RO)
-                                sprintf(mybuff1, "DEFSEG %s %X-%X SR",
-                                        name, mybeg, myend);
-                        spin_unlock(&dcss_lock);
-                        sprintf(mybuff2, "SAVESEG %s", name);
-                        cpcmd(mybuff1, NULL, 80);
-                        cpcmd(mybuff2, NULL, 80);
-                        break;
-                }
+	unsigned long dummy;
+	struct dcss_segment *seg;
 
-        }
-        if (myend == 0) spin_unlock(&dcss_lock);
+	if (!MACHINE_IS_VM)
+		return;
+
+	spin_lock(&dcss_lock);
+	seg = segment_by_name (name);
+	if (seg == NULL) {
+		PRINT_ERR ("could not find segment %s in segment_unload, "
+				"please report to linux390@de.ibm.com\n",name);
+		goto out_unlock;
+	}
+	if (atomic_dec_return(&seg->ref_count) == 0) {
+		list_del(&seg->list);
+		dcss_diag(DCSS_PURGESEG, seg->dcss_name,
+			  &dummy, &dummy);
+		kfree(seg);
+	}
+out_unlock:
+	spin_unlock(&dcss_lock);
+}
+
+/*
+ * save segment content permanently
+ */
+void segment_save(char *name)
+{
+	struct dcss_segment *seg;
+	int startpfn = 0;
+	int endpfn = 0;
+	char cmd1[160];
+	char cmd2[80];
+	int i;
+
+	if (!MACHINE_IS_VM)
+		return;
+
+	spin_lock(&dcss_lock);
+	seg = segment_by_name (name);
+
+	if (seg == NULL) {
+		PRINT_ERR ("could not find segment %s in segment_save, please report to linux390@de.ibm.com\n",name);
+		return;
+	}
+
+	startpfn = seg->start_addr >> PAGE_SHIFT;
+	endpfn = (seg->end) >> PAGE_SHIFT;
+	sprintf(cmd1, "DEFSEG %s", name);
+	for (i=0; i<seg->segcnt; i++) {
+		sprintf(cmd1+strlen(cmd1), " %X-%X %s",
+			seg->range[i].start >> PAGE_SHIFT,
+			seg->range[i].end >> PAGE_SHIFT,
+			segtype_string[seg->range[i].start & 0xff]);
+	}
+	sprintf(cmd2, "SAVESEG %s", name);
+	cpcmd(cmd1, NULL, 80);
+	cpcmd(cmd2, NULL, 80);
+	spin_unlock(&dcss_lock);
 }
 
 EXPORT_SYMBOL(segment_load);
 EXPORT_SYMBOL(segment_unload);
-EXPORT_SYMBOL(segment_replace);
+EXPORT_SYMBOL(segment_save);
+EXPORT_SYMBOL(segment_type);
+EXPORT_SYMBOL(segment_modify_shared);
diff -Nru a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
--- a/arch/s390/mm/mmap.c	2004-12-24 13:36:16 -08:00
+++ b/arch/s390/mm/mmap.c	2004-12-24 13:36:16 -08:00
@@ -37,7 +37,7 @@
 
 static inline unsigned long mmap_base(void)
 {
-	unsigned long gap = current->rlim[RLIMIT_STACK].rlim_cur;
+	unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
 
 	if (gap < MIN_GAP)
 		gap = MIN_GAP;
@@ -58,7 +58,7 @@
 #endif
 	return sysctl_legacy_va_layout ||
 	    (current->personality & ADDR_COMPAT_LAYOUT) ||
-	    current->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY;
+	    current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY;
 }
 
 /*
diff -Nru a/arch/sh/Kconfig b/arch/sh/Kconfig
--- a/arch/sh/Kconfig	2004-12-24 13:37:30 -08:00
+++ b/arch/sh/Kconfig	2004-12-24 13:37:30 -08:00
@@ -51,6 +51,12 @@
 	  Select 7300 SolutionEngine if configuring for a Hitachi SH7300(SH-Mobile V)
 	  evalutation board.
 
+config SH_73180_SOLUTION_ENGINE
+       bool "SolutionEngine73180"
+       help
+         Select 73180 SolutionEngine if configuring for a Hitachi SH73180(SH-Mobile 3)
+         evalutation board.
+
 config SH_7751_SYSTEMH
 	bool "SystemH7751R"
 	help
@@ -137,6 +143,16 @@
 config SH_MPC1211
 	bool "MPC1211"
 
+config SH_SH03
+	bool "SH03"
+	help
+	  CTP/PCI-SH03 is a CPU module computer that produced
+	  by Interface Corporation.
+	  It is compact and excellent in durability.
+	  It will play an active part in your factory or laboratory
+	  as a FA computer.
+	  More information at <http://www.interface.co.jp>
+
 config SH_SECUREEDGE5410
 	bool "SecureEdge5410"
 	help
@@ -156,6 +172,15 @@
 	  Select RTS7751R2D if configuring for a Renesas Technology
 	  Sales SH-Graphics board.
 
+config SH_EDOSK7705
+	bool "EDOSK7705"
+
+config SH_SH4202_MICRODEV
+	bool "SH4-202 MicroDev"
+	help
+	  Select SH4-202 MicroDev if configuring for a SuperH MicroDev board
+	  with an SH4-202 CPU.
+
 config SH_UNKNOWN
 	bool "BareCPU"
 	help
@@ -245,6 +270,10 @@
 	bool "SH7760"
 	depends on CPU_SH4
 
+config CPU_SUBTYPE_SH73180
+       bool "SH73180"
+       depends on CPU_SH4
+
 config CPU_SUBTYPE_ST40STB1
        bool "ST40STB1 / ST40RA"
        depends on CPU_SH4
@@ -258,8 +287,17 @@
        help
          Select ST40GX1 if you have a ST40GX1 CPU.
 
+config CPU_SUBTYPE_SH4_202
+	bool "SH4-202"
+	depends on CPU_SH4
+
 endchoice
 
+config SH7705_CACHE_32KB
+    bool "Enable 32KB cache size for SH7705"
+    depends on CPU_SUBTYPE_SH7705
+    default y
+
 config MMU
         bool "Support for memory management hardware"
 	depends on !CPU_SH2
@@ -296,8 +334,8 @@
 # Platform-specific memory start and size definitions
 config MEMORY_START
 	hex "Physical memory start address" if !MEMORY_SET || MEMORY_OVERRIDE
-	default "0x08000000" if !MEMORY_SET || MEMORY_OVERRIDE || !MEMORY_OVERRIDE && SH_ADX || SH_MPC1211 || SH_SECUREEDGE5410
-	default "0x0c000000" if !MEMORY_OVERRIDE && (SH_DREAMCAST || SH_HP600 || SH_BIGSUR || SH_SH2000 || SH_7751_SOLUTION_ENGINE || SH_SOLUTION_ENGINE || SH_HS7751RVOIP || SH_RTS7751R2D)
+	default "0x08000000" if !MEMORY_SET || MEMORY_OVERRIDE || !MEMORY_OVERRIDE && SH_ADX || SH_MPC1211 || SH_SH03 || SH_SECUREEDGE5410 || SH_SH4202_MICRODEV
+	default "0x0c000000" if !MEMORY_OVERRIDE && (SH_DREAMCAST || SH_HP600 || SH_BIGSUR || SH_SH2000 || SH_73180_SOLUTION_ENGINE || SH_7300_SOLUTION_ENGINE || SH_7751_SOLUTION_ENGINE || SH_SOLUTION_ENGINE || SH_HS7751RVOIP || SH_RTS7751R2D || SH_EDOSK7705)
 	---help---
 	  Computers built with Hitachi SuperH processors always
 	  map the ROM starting at address zero.  But the processor
@@ -315,10 +353,10 @@
 config MEMORY_SIZE
 	hex "Physical memory size" if !MEMORY_SET || MEMORY_OVERRIDE
 	default "0x00400000" if !MEMORY_SET || MEMORY_OVERRIDE || !MEMORY_OVERRIDE && SH_ADX || !MEMORY_OVERRIDE && (SH_HP600 || SH_BIGSUR || SH_SH2000)
-	default "0x01000000" if !MEMORY_OVERRIDE && SH_DREAMCAST || SH_SECUREEDGE5410
-	default "0x04000000" if !MEMORY_OVERRIDE && (SH_7751_SOLUTION_ENGINE || SH_HS7751RVOIP || SH_RTS7751R2D)
-	default "0x02000000" if !MEMORY_OVERRIDE && SH_SOLUTION_ENGINE
-	default "0x08000000" if SH_MPC1211
+	default "0x01000000" if !MEMORY_OVERRIDE && SH_DREAMCAST || SH_SECUREEDGE5410 || SH_EDOSK7705
+        default "0x02000000" if !MEMORY_OVERRIDE && (SH_73180_SOLUTION_ENGINE || SH_SOLUTION_ENGINE)
+        default "0x04000000" if !MEMORY_OVERRIDE && (SH_7300_SOLUTION_ENGINE || SH_7751_SOLUTION_ENGINE || SH_HS7751RVOIP || SH_RTS7751R2D || SH_SH4202_MICRODEV)
+	default "0x08000000" if SH_MPC1211 || SH_SH03
 	help
 	  This sets the default memory size assumed by your SH kernel. It can
 	  be overridden as normal by the 'mem=' argument on the kernel command
@@ -328,7 +366,7 @@
 
 config MEMORY_SET
 	bool
-	depends on !MEMORY_OVERRIDE && (SH_MPC1211 || SH_ADX || SH_DREAMCAST || SH_HP600 || SH_BIGSUR || SH_SH2000 || SH_7751_SOLUTION_ENGINE || SH_SOLUTION_ENGINE || SH_SECUREEDGE5410 || SH_HS7751RVOIP || SH_RTS7751R2D)
+	depends on !MEMORY_OVERRIDE && (SH_MPC1211 || SH_SH03 || SH_ADX || SH_DREAMCAST || SH_HP600 || SH_BIGSUR || SH_SH2000 || SH_7751_SOLUTION_ENGINE || SH_SOLUTION_ENGINE || SH_SECUREEDGE5410 || SH_HS7751RVOIP || SH_RTS7751R2D || SH_SH4202_MICRODEV || SH_EDOSK7705)
 	default y
 	help
 	  This is an option about which you will never be asked a question.
@@ -343,7 +381,7 @@
 # XXX: break these out into the board-specific configs below
 config CF_ENABLER
 	bool "Compact Flash Enabler support"
-	depends on SH_ADX || SH_SOLUTION_ENGINE || SH_UNKNOWN || SH_CAT68701
+	depends on SH_ADX || SH_SOLUTION_ENGINE || SH_UNKNOWN || SH_CAT68701 || SH_SH03
 	---help---
 	  Compact Flash is a small, removable mass storage device introduced
 	  in 1994 originally as a PCMCIA device.  If you say `Y' here, you
@@ -387,7 +425,7 @@
 # The SH7750 RTC module is disabled in the Dreamcast
 config SH_RTC
 	bool
-	depends on !SH_DREAMCAST && !SH_SATURN && !SH_7300_SOLUTION_ENGINE
+	depends on !SH_DREAMCAST && !SH_SATURN && !SH_7300_SOLUTION_ENGINE && !SH_73180_SOLUTION_ENGINE
 	default y
 	help
 	  Selecting this option will allow the Linux kernel to emulate
@@ -395,6 +433,16 @@
 
 	  If unsure, say N.
 
+config SH_FPU
+	bool "FPU support"
+	depends on !CPU_SH3
+	default y
+	help
+	  Selecting this option will enable support for SH processors that
+	  have FPU units (ie, SH77xx).
+
+	  This option must be set in order to enable the FPU.
+
 config SH_DSP
 	bool "DSP support"
 	depends on !CPU_SH4
@@ -438,8 +486,8 @@
 
 config ZERO_PAGE_OFFSET
 	hex "Zero page offset"
-	default "0x00001000" if !SH_MPC1211
-	default "0x00004000" if SH_MPC1211
+	default "0x00001000" if !(SH_MPC1211 || SH_SH03)
+	default "0x00004000" if SH_MPC1211 || SH_SH03
 	help
 	  This sets the default offset of zero page.
 
@@ -572,7 +620,7 @@
 
 config SH_PCLK_CALC
 	bool
-	default n if CPU_SUBTYPE_SH7300
+	default n if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH73180
 	default y
 	help
 	  This option will cause the PCLK value to be probed at run-time. It
@@ -581,9 +629,11 @@
 
 config SH_PCLK_FREQ
 	int "Peripheral clock frequency (in Hz)"
-	default "49876504" if CPU_SUBTYPE_SH7750
-	default "60013568" if CPU_SUBTYPE_SH7751
+	default "50000000" if CPU_SUBTYPE_SH7750
+	default "60000000" if CPU_SUBTYPE_SH7751
 	default "33333333" if CPU_SUBTYPE_SH7300
+	default "27000000" if CPU_SUBTYPE_SH73180
+	default "66000000" if CPU_SUBTYPE_SH4_202
 	default "1193182"
 	help
 	  This option is used to specify the peripheral clock frequency. This
@@ -595,16 +645,6 @@
 
 menu "CPU Frequency scaling"
 
-config CPU_FREQ
-	bool "CPU Frequency scaling"
-	help
-	  CPU clock scaling allows you to change the clock speed of the
-	  running CPU on the fly.
-
-	  For details, take a look at <file:Documentation/cpu-freq>.
-
-	  If unsure, say N.
-
 source "drivers/cpufreq/Kconfig"
 
 config CPU_FREQ_TABLE
@@ -636,7 +676,7 @@
 
 config HEARTBEAT
 	bool "Heartbeat LED"
-	depends on SH_MPC1211 || SH_CAT68701 || SH_STB1_HARP || SH_STB1_OVERDRIVE || SH_BIGSUR || SH_7751_SOLUTION_ENGINE || SH_7300_SOLUTION_ENGINE || SH_SOLUTION_ENGINE || SH_RTS7751R2D
+	depends on SH_MPC1211 || SH_SH03 || SH_CAT68701 || SH_STB1_HARP || SH_STB1_OVERDRIVE || SH_BIGSUR || SH_7751_SOLUTION_ENGINE || SH_7300_SOLUTION_ENGINE || SH_73180_SOLUTION_ENGINE || SH_SOLUTION_ENGINE || SH_RTS7751R2D || SH_SH4202_MICRODEV
 	help
 	  Use the power-on LED on your machine as a load meter.  The exact
 	  behavior is platform-dependent, but normally the flash frequency is
@@ -662,7 +702,7 @@
 # PCMCIA outright. -- PFM.
 config ISA
 	bool
-	default y if PCMCIA
+	default y if PCMCIA || SMC91X
 	help
 	  Find out whether you have ISA slots on your motherboard.  ISA is the
 	  name of a bus system, i.e. the way the CPU talks to the other stuff
@@ -711,6 +751,7 @@
 
 endmenu
 
+
 menu "Executable file formats"
 
 source "fs/Kconfig.binfmt"
@@ -729,7 +770,7 @@
 	default "ramdisk.gz"
 	help
 	  This is the filename of the ramdisk image to be built into the
-	  kernel.  Relative pathnames are relative to arch/mips/ramdisk/.
+	  kernel.  Relative pathnames are relative to arch/sh/ramdisk/.
 	  The ramdisk image is not part of the kernel distribution; you must
 	  provide one yourself.
 
diff -Nru a/arch/sh/Makefile b/arch/sh/Makefile
--- a/arch/sh/Makefile	2004-12-24 13:37:01 -08:00
+++ b/arch/sh/Makefile	2004-12-24 13:37:01 -08:00
@@ -14,17 +14,6 @@
 # this architecture
 #
 
-#
-# We don't necessarily agree with the top-level Makefile with regards to what
-# does and does not qualify as a noconfig_targets rule. In this case, we're
-# still dependant on .config settings in order for core-y (machdir-y in
-# particular) to resolve the proper directory. So we just manually include it
-# if it hasn't been already..
-# 
-ifndef include_config
--include .config
-endif
-
 cflags-y				:= -mb
 cflags-$(CONFIG_CPU_LITTLE_ENDIAN)	:= -ml
 
@@ -76,6 +65,7 @@
 machdir-$(CONFIG_SH_SOLUTION_ENGINE)		:= se/770x
 machdir-$(CONFIG_SH_7751_SOLUTION_ENGINE)	:= se/7751
 machdir-$(CONFIG_SH_7300_SOLUTION_ENGINE)	:= se/7300
+machdir-$(CONFIG_SH_73180_SOLUTION_ENGINE)	:= se/73180
 machdir-$(CONFIG_SH_STB1_HARP)			:= harp
 machdir-$(CONFIG_SH_STB1_OVERDRIVE)		:= overdrive
 machdir-$(CONFIG_SH_HP620)			:= hp6xx/hp620
@@ -91,10 +81,13 @@
 machdir-$(CONFIG_SH_SH2000)			:= sh2000
 machdir-$(CONFIG_SH_ADX)			:= adx
 machdir-$(CONFIG_SH_MPC1211)			:= mpc1211
+machdir-$(CONFIG_SH_SH03)			:= sh03
 machdir-$(CONFIG_SH_SECUREEDGE5410)		:= snapgear
 machdir-$(CONFIG_SH_HS7751RVOIP)		:= renesas/hs7751rvoip
 machdir-$(CONFIG_SH_RTS7751R2D)			:= renesas/rts7751r2d
 machdir-$(CONFIG_SH_7751_SYSTEMH)		:= renesas/systemh
+machdir-$(CONFIG_SH_EDOSK7705)			:= renesas/edosk7705
+machdir-$(CONFIG_SH_SH4202_MICRODEV)		:= superh/microdev
 machdir-$(CONFIG_SH_UNKNOWN)			:= unknown
 
 incdir-y			:= $(notdir $(machdir-y))
@@ -102,9 +95,12 @@
 incdir-$(CONFIG_SH_SOLUTION_ENGINE)		:= se
 incdir-$(CONFIG_SH_7751_SOLUTION_ENGINE)	:= se7751
 incdir-$(CONFIG_SH_7300_SOLUTION_ENGINE)        := se7300
+incdir-$(CONFIG_SH_73180_SOLUTION_ENGINE)	:= se73180
 incdir-$(CONFIG_SH_HP600)			:= hp6xx
 
+ifneq ($(machdir-y),)
 core-y				+= arch/sh/boards/$(machdir-y)/
+endif
 
 # Companion chips
 core-$(CONFIG_HD64461)		+= arch/sh/cchips/hd6446x/hd64461/
@@ -124,23 +120,39 @@
 
 CPPFLAGS_vmlinux.lds := -traditional
 
-prepare: target_links
+#	Update machine arch and proc symlinks if something which affects
+#	them changed.  We use .arch and .mach to indicate when they were
+#	updated last, otherwise make uses the target directory mtime.
+
+include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) include/config/MARKER
+	@echo '  SYMLINK include/asm-sh/cpu -> include/asm-sh/$(cpuincdir-y)'
+ifneq ($(KBUILD_SRC),)
+	$(Q)mkdir -p include/asm-sh
+	$(Q)ln -fsn $(srctree)/include/asm-sh/$(cpuincdir-y) include/asm-sh/cpu
+else
+	$(Q)ln -fsn $(cpuincdir-y) include/asm-sh/cpu
+endif
+	@touch $@
 
-.PHONY: target_links FORCE
+include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/MARKER
+	@echo '  SYMLINK include/asm-sh/mach -> include/asm-sh/$(incdir-y)'
+ifneq ($(KBUILD_SRC),)
+	$(Q)mkdir -p include/asm-sh
+	$(Q)ln -fsn $(srctree)/include/asm-sh/$(incdir-y) include/asm-sh/mach
+else
+	$(Q)ln -fsn $(incdir-y) include/asm-sh/mach
+endif
+	@touch $@
 
-all: zImage
 
-target_links:
-	@echo '  Making asm-sh/cpu -> asm-sh/$(cpuincdir-y) link'
-	@rm -f include/asm-sh/cpu
-	@ln -sf $(cpuincdir-y) include/asm-sh/cpu
-
-	@echo '  Making asm-sh/mach -> asm-sh/$(incdir-y) link'
-	@rm -f include/asm-sh/mach
-	@ln -sf $(incdir-y) include/asm-sh/mach
+prepare: maketools include/asm-sh/.cpu include/asm-sh/.mach
 
+.PHONY: maketools FORCE
+maketools: include/asm-sh/asm-offsets.h include/linux/version.h FORCE
 	$(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
 
+all: zImage
+
 zImage: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
@@ -148,6 +160,15 @@
 
 archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
+
+CLEAN_FILES += include/asm-sh/machtypes.h include/asm-sh/asm-offsets.h
+
+arch/sh/kernel/asm-offsets.s: include/asm include/linux/version.h \
+			      include/asm-sh/.cpu include/asm-sh/.mach
+
+include/asm-sh/asm-offsets.h: arch/sh/kernel/asm-offsets.s
+	$(call filechk,gen-asm-offsets)
+
 
 define archhelp
 	@echo '  zImage 	           - Compressed kernel image (arch/sh/boot/zImage)'
diff -Nru a/arch/sh/boards/bigsur/irq.c b/arch/sh/boards/bigsur/irq.c
--- a/arch/sh/boards/bigsur/irq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/sh/boards/bigsur/irq.c	2004-12-24 13:37:18 -08:00
@@ -29,10 +29,10 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/irq.h>
+#include <linux/bitops.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 
 #include <asm/bigsur/io.h>
 #include <asm/hd64465/hd64465.h>
diff -Nru a/arch/sh/boards/bigsur/setup.c b/arch/sh/boards/bigsur/setup.c
--- a/arch/sh/boards/bigsur/setup.c	2004-12-24 13:37:19 -08:00
+++ b/arch/sh/boards/bigsur/setup.c	2004-12-24 13:37:19 -08:00
@@ -29,10 +29,10 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/irq.h>
+#include <linux/bitops.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/machvec.h>
 #include <asm/bigsur/io.h>
 #include <asm/hd64465/hd64465.h>
diff -Nru a/arch/sh/boards/dreamcast/setup.c b/arch/sh/boards/dreamcast/setup.c
--- a/arch/sh/boards/dreamcast/setup.c	2004-12-24 13:36:17 -08:00
+++ b/arch/sh/boards/dreamcast/setup.c	2004-12-24 13:36:17 -08:00
@@ -1,15 +1,15 @@
-/* 
+/*
  * arch/sh/boards/dreamcast/setup.c
  *
  * Hardware support for the Sega Dreamcast.
  *
  * Copyright (c) 2001, 2002 M. R. Brown <mrbrown@linuxdc.org>
- * Copyright (c) 2002, 2003 Paul Mundt <lethal@linux-sh.org>
+ * Copyright (c) 2002, 2003, 2004 Paul Mundt <lethal@linux-sh.org>
  *
  * This file is part of the LinuxDC project (www.linuxdc.org)
  *
  * Released under the terms of the GNU GPL v2.0.
- * 
+ *
  * 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
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/irq.h>
+#include <linux/device.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -34,6 +35,10 @@
 extern void aica_time_init(void);
 extern int gapspci_init(void);
 extern int systemasic_irq_demux(int);
+
+void *dreamcast_consistent_alloc(struct device *, size_t, dma_addr_t *, int);
+int dreamcast_consistent_free(struct device *, size_t, void *, dma_addr_t);
+
 const char *get_system_type(void)
 {
 	return "Sega Dreamcast";
@@ -43,6 +48,11 @@
 	.mv_nr_irqs		= NR_IRQS,
 
 	.mv_irq_demux		= systemasic_irq_demux,
+
+#ifdef CONFIG_PCI
+	.mv_consistent_alloc	= dreamcast_consistent_alloc,
+	.mv_consistent_free	= dreamcast_consistent_free,
+#endif
 };
 ALIAS_MV(dreamcast)
 
diff -Nru a/arch/sh/boards/harp/setup.c b/arch/sh/boards/harp/setup.c
--- a/arch/sh/boards/harp/setup.c	2004-12-24 13:36:31 -08:00
+++ b/arch/sh/boards/harp/setup.c	2004-12-24 13:36:31 -08:00
@@ -54,3 +54,38 @@
 
 	return 0;
 }
+
+/*
+ * pcibios_map_platform_irq
+ *
+ * This is board specific and returns the IRQ for a given PCI device.
+ * It is used by the PCI code (arch/sh/kernel/st40_pci*)
+ *
+ */
+
+#define HARP_PCI_IRQ    1
+#define HARP_BRIDGE_IRQ 2
+#define OVERDRIVE_SLOT0_IRQ 0
+
+
+int __init pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+	switch (slot) {
+#ifdef CONFIG_SH_STB1_HARP
+	case 2:		/*This is the PCI slot on the */
+		return HARP_PCI_IRQ;
+	case 1:		/* this is the bridge */
+		return HARP_BRIDGE_IRQ;
+#elif defined(CONFIG_SH_STB1_OVERDRIVE)
+	case 1:
+	case 2:
+	case 3:
+		return slot - 1;
+#else
+#error Unknown board
+#endif
+	default:
+		return -1;
+	}
+}
+
diff -Nru a/arch/sh/boards/overdrive/pcidma.c b/arch/sh/boards/overdrive/pcidma.c
--- a/arch/sh/boards/overdrive/pcidma.c	2004-12-24 13:37:32 -08:00
+++ b/arch/sh/boards/overdrive/pcidma.c	2004-12-24 13:37:32 -08:00
@@ -25,7 +25,7 @@
 
         printk("BUG: pci_alloc_consistent() called - not yet supported\n");
 	/* We ALWAYS need DMA memory on the overdrive hardware,
-	 * due to it's extreme wierdness
+	 * due to it's extreme weirdness
 	 * Need to flush the cache here as well, since the memory
 	 * can still be seen through the cache!
 	 */
diff -Nru a/arch/sh/boards/renesas/edosk7705/Makefile b/arch/sh/boards/renesas/edosk7705/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/renesas/edosk7705/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,10 @@
+#
+# Makefile for the EDOSK7705 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).
+#
+
+obj-y	 := setup.o io.o
+
diff -Nru a/arch/sh/boards/renesas/edosk7705/io.c b/arch/sh/boards/renesas/edosk7705/io.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/renesas/edosk7705/io.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,94 @@
+/*
+ * arch/sh/boards/renesas/edosk7705/io.c
+ *
+ * Copyright (C) 2001  Ian da Silva, Jeremy Siegel
+ * Based largely on io_se.c.
+ *
+ * I/O routines for Hitachi EDOSK7705 board.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <asm/io.h>
+#include <asm/edosk7705/io.h>
+#include <asm/addrspace.h>
+
+#define SMC_IOADDR	0xA2000000
+
+#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))
+
+/* Map the Ethernet addresses as if it is at 0x300 - 0x320 */
+unsigned long sh_edosk7705_isa_port2addr(unsigned long port)
+{
+     if (port >= 0x300 && port < 0x320) {
+	  /* SMC91C96 registers are 4 byte aligned rather than the
+	   * usual 2 byte!
+	   */
+	  return SMC_IOADDR + ( (port - 0x300) * 2);
+     }
+
+     maybebadio(sh_edosk7705_isa_port2addr, port);
+     return port;
+}
+
+/* Trying to read / write bytes on odd-byte boundaries to the Ethernet
+ * registers causes problems. So we bit-shift the value and read / write
+ * in 2 byte chunks. Setting the low byte to 0 does not cause problems
+ * now as odd byte writes are only made on the bit mask / interrupt
+ * register. This may not be the case in future Mar-2003 SJD
+ */
+unsigned char sh_edosk7705_inb(unsigned long port)
+{
+	if (port >= 0x300 && port < 0x320 && port & 0x01) {
+		return (volatile unsigned char)(generic_inw(port -1) >> 8);
+	}
+	return *(volatile unsigned char *)sh_edosk7705_isa_port2addr(port);
+}
+
+unsigned int sh_edosk7705_inl(unsigned long port)
+{
+	return *(volatile unsigned long *)port;
+}
+
+void sh_edosk7705_outb(unsigned char value, unsigned long port)
+{
+	if (port >= 0x300 && port < 0x320 && port & 0x01) {
+		generic_outw(((unsigned short)value << 8), port -1);
+		return;
+	}
+	*(volatile unsigned char *)sh_edosk7705_isa_port2addr(port) = value;
+}
+
+void sh_edosk7705_outl(unsigned int value, unsigned long port)
+{
+	*(volatile unsigned long *)port = value;
+}
+
+void sh_edosk7705_insb(unsigned long port, void *addr, unsigned long count)
+{
+	unsigned char *p = addr;
+	while (count--) *p++ = sh_edosk7705_inb(port);
+}
+
+void sh_edosk7705_insl(unsigned long port, void *addr, unsigned long count)
+{
+	unsigned long *p = (unsigned long*)addr;
+	while (count--)
+		*p++ = *(volatile unsigned long *)port;
+}
+
+void sh_edosk7705_outsb(unsigned long port, const void *addr, unsigned long count)
+{
+	unsigned char *p = (unsigned char*)addr;
+	while (count--) sh_edosk7705_outb(*p++, port);
+}
+
+void sh_edosk7705_outsl(unsigned long port, const void *addr, unsigned long count)
+{
+	unsigned long *p = (unsigned long*)addr;
+	while (count--) sh_edosk7705_outl(*p++, port);
+}
+
diff -Nru a/arch/sh/boards/renesas/edosk7705/setup.c b/arch/sh/boards/renesas/edosk7705/setup.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/renesas/edosk7705/setup.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,60 @@
+/*
+ * arch/sh/boards/renesas/edosk7705/setup.c
+ *
+ * Copyright (C) 2000  Kazumoto Kojima
+ *
+ * Hitachi SolutionEngine Support.
+ *
+ * Modified for edosk7705 development
+ * board by S. Dunn, 2003.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <asm/machvec.h>
+#include <asm/machvec_init.h>
+#include <asm/edosk7705/io.h>
+
+static void init_edosk7705(void);
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_edosk7705 __initmv = {
+	.mv_nr_irqs		= 80,
+
+	.mv_inb			= sh_edosk7705_inb,
+	.mv_inl			= sh_edosk7705_inl,
+	.mv_outb		= sh_edosk7705_outb,
+	.mv_outl		= sh_edosk7705_outl,
+
+	.mv_inl_p		= sh_edosk7705_inl,
+	.mv_outl_p		= sh_edosk7705_outl,
+
+	.mv_insb		= sh_edosk7705_insb,
+	.mv_insl		= sh_edosk7705_insl,
+	.mv_outsb		= sh_edosk7705_outsb,
+	.mv_outsl		= sh_edosk7705_outsl,
+
+	.mv_isa_port2addr	= sh_edosk7705_isa_port2addr,
+	.mv_init_irq		= init_edosk7705,
+};
+ALIAS_MV(edosk7705)
+
+static void __init init_edosk7705(void)
+{
+	/* This is the Ethernet interrupt */
+	make_imask_irq(0x09);
+}
+
+const char *get_system_type(void)
+{
+	return "EDOSK7705";
+}
+
+void __init platform_setup(void)
+{
+	/* Nothing .. */
+}
+
diff -Nru a/arch/sh/boards/renesas/rts7751r2d/mach.c b/arch/sh/boards/renesas/rts7751r2d/mach.c
--- a/arch/sh/boards/renesas/rts7751r2d/mach.c	2004-12-24 13:36:18 -08:00
+++ b/arch/sh/boards/renesas/rts7751r2d/mach.c	2004-12-24 13:36:18 -08:00
@@ -24,7 +24,7 @@
 extern int rts7751r2d_irq_demux(int irq);
 
 extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, int);
-extern void voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t);
+extern int voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t);
 
 /*
  * The Machine Vector
@@ -62,7 +62,9 @@
 #endif
 	.mv_irq_demux		= rts7751r2d_irq_demux,
 
+#ifdef CONFIG_USB_OHCI_HCD
 	.mv_consistent_alloc	= voyagergx_consistent_alloc,
 	.mv_consistent_free	= voyagergx_consistent_free,
+#endif
 };
 ALIAS_MV(rts7751r2d)
diff -Nru a/arch/sh/boards/se/73180/Makefile b/arch/sh/boards/se/73180/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/se/73180/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,7 @@
+#
+# Makefile for the 73180 SolutionEngine specific parts of the kernel
+#
+
+obj-y	 := setup.o io.o irq.o
+
+obj-$(CONFIG_HEARTBEAT) += led.o
diff -Nru a/arch/sh/boards/se/73180/io.c b/arch/sh/boards/se/73180/io.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/se/73180/io.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,265 @@
+/*
+ * arch/sh/boards/se/73180/io.c
+ *
+ * Copyright (C) 2003 YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
+ * Based on arch/sh/boards/se/7300/io.c
+ *
+ * I/O routine for SH-Mobile3 73180 SolutionEngine.
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <asm/mach/se73180.h>
+#include <asm/io.h>
+
+#define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
+
+struct iop {
+	unsigned long start, end;
+	unsigned long base;
+	struct iop *(*check) (struct iop * p, unsigned long port);
+	unsigned char (*inb) (struct iop * p, unsigned long port);
+	unsigned short (*inw) (struct iop * p, unsigned long port);
+	void (*outb) (struct iop * p, unsigned char value, unsigned long port);
+	void (*outw) (struct iop * p, unsigned short value, unsigned long port);
+};
+
+struct iop *
+simple_check(struct iop *p, unsigned long port)
+{
+	if ((p->start <= port) && (port <= p->end))
+		return p;
+	else
+		badio(check, port);
+}
+
+struct iop *
+ide_check(struct iop *p, unsigned long port)
+{
+	if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
+		return p;
+	return NULL;
+}
+
+unsigned char
+simple_inb(struct iop *p, unsigned long port)
+{
+	return *(unsigned char *) (p->base + port);
+}
+
+unsigned short
+simple_inw(struct iop *p, unsigned long port)
+{
+	return *(unsigned short *) (p->base + port);
+}
+
+void
+simple_outb(struct iop *p, unsigned char value, unsigned long port)
+{
+	*(unsigned char *) (p->base + port) = value;
+}
+
+void
+simple_outw(struct iop *p, unsigned short value, unsigned long port)
+{
+	*(unsigned short *) (p->base + port) = value;
+}
+
+unsigned char
+pcc_inb(struct iop *p, unsigned long port)
+{
+	unsigned long addr = p->base + port + 0x40000;
+	unsigned long v;
+
+	if (port & 1)
+		addr += 0x00400000;
+	v = *(volatile unsigned char *) addr;
+	return v;
+}
+
+void
+pcc_outb(struct iop *p, unsigned char value, unsigned long port)
+{
+	unsigned long addr = p->base + port + 0x40000;
+
+	if (port & 1)
+		addr += 0x00400000;
+	*(volatile unsigned char *) addr = value;
+}
+
+unsigned char
+bad_inb(struct iop *p, unsigned long port)
+{
+	badio(inb, port);
+}
+
+void
+bad_outb(struct iop *p, unsigned char value, unsigned long port)
+{
+	badio(inw, port);
+}
+
+/* MSTLANEX01 LAN at 0xb400:0000 */
+static struct iop laniop = {
+	.start = 0x300,
+	.end = 0x30f,
+	.base = 0xb4000000,
+	.check = simple_check,
+	.inb = simple_inb,
+	.inw = simple_inw,
+	.outb = simple_outb,
+	.outw = simple_outw,
+};
+
+/* NE2000 pc card NIC */
+static struct iop neiop = {
+	.start = 0x280,
+	.end = 0x29f,
+	.base = 0xb0600000 + 0x80,	/* soft 0x280 -> hard 0x300 */
+	.check = simple_check,
+	.inb = pcc_inb,
+	.inw = simple_inw,
+	.outb = pcc_outb,
+	.outw = simple_outw,
+};
+
+/* CF in CF slot */
+static struct iop cfiop = {
+	.base = 0xb0600000,
+	.check = ide_check,
+	.inb = pcc_inb,
+	.inw = simple_inw,
+	.outb = pcc_outb,
+	.outw = simple_outw,
+};
+
+static __inline__ struct iop *
+port2iop(unsigned long port)
+{
+	if (0) ;
+#if defined(CONFIG_SMC91111)
+	else if (laniop.check(&laniop, port))
+		return &laniop;
+#endif
+#if defined(CONFIG_NE2000)
+	else if (neiop.check(&neiop, port))
+		return &neiop;
+#endif
+#if defined(CONFIG_IDE)
+	else if (cfiop.check(&cfiop, port))
+		return &cfiop;
+#endif
+	else
+		return &neiop;	/* fallback */
+}
+
+static inline void
+delay(void)
+{
+	ctrl_inw(0xac000000);
+	ctrl_inw(0xac000000);
+}
+
+unsigned char
+sh73180se_inb(unsigned long port)
+{
+	struct iop *p = port2iop(port);
+	return (p->inb) (p, port);
+}
+
+unsigned char
+sh73180se_inb_p(unsigned long port)
+{
+	unsigned char v = sh73180se_inb(port);
+	delay();
+	return v;
+}
+
+unsigned short
+sh73180se_inw(unsigned long port)
+{
+	struct iop *p = port2iop(port);
+	return (p->inw) (p, port);
+}
+
+unsigned int
+sh73180se_inl(unsigned long port)
+{
+	badio(inl, port);
+}
+
+void
+sh73180se_outb(unsigned char value, unsigned long port)
+{
+	struct iop *p = port2iop(port);
+	(p->outb) (p, value, port);
+}
+
+void
+sh73180se_outb_p(unsigned char value, unsigned long port)
+{
+	sh73180se_outb(value, port);
+	delay();
+}
+
+void
+sh73180se_outw(unsigned short value, unsigned long port)
+{
+	struct iop *p = port2iop(port);
+	(p->outw) (p, value, port);
+}
+
+void
+sh73180se_outl(unsigned int value, unsigned long port)
+{
+	badio(outl, port);
+}
+
+void
+sh73180se_insb(unsigned long port, void *addr, unsigned long count)
+{
+	unsigned char *a = addr;
+	struct iop *p = port2iop(port);
+	while (count--)
+		*a++ = (p->inb) (p, port);
+}
+
+void
+sh73180se_insw(unsigned long port, void *addr, unsigned long count)
+{
+	unsigned short *a = addr;
+	struct iop *p = port2iop(port);
+	while (count--)
+		*a++ = (p->inw) (p, port);
+}
+
+void
+sh73180se_insl(unsigned long port, void *addr, unsigned long count)
+{
+	badio(insl, port);
+}
+
+void
+sh73180se_outsb(unsigned long port, const void *addr, unsigned long count)
+{
+	unsigned char *a = (unsigned char *) addr;
+	struct iop *p = port2iop(port);
+	while (count--)
+		(p->outb) (p, *a++, port);
+}
+
+void
+sh73180se_outsw(unsigned long port, const void *addr, unsigned long count)
+{
+	unsigned short *a = (unsigned short *) addr;
+	struct iop *p = port2iop(port);
+	while (count--)
+		(p->outw) (p, *a++, port);
+}
+
+void
+sh73180se_outsl(unsigned long port, const void *addr, unsigned long count)
+{
+	badio(outsw, port);
+}
diff -Nru a/arch/sh/boards/se/73180/irq.c b/arch/sh/boards/se/73180/irq.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/se/73180/irq.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,137 @@
+/*
+ * arch/sh/boards/se/73180/irq.c
+ *
+ * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
+ * Based on arch/sh/boards/se/7300/irq.c
+ *
+ * Modified for SH-Mobile SolutionEngine 73180 Support
+ *              by YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
+ *
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/mach/se73180.h>
+
+static int
+intreq2irq(int i)
+{
+	if (i == 5)
+		return 10;
+	return 32 + 7 - i;
+}
+
+static int
+irq2intreq(int irq)
+{
+	if (irq == 10)
+		return 5;
+	return 7 - (irq - 32);
+}
+
+static void
+disable_intreq_irq(unsigned int irq)
+{
+	ctrl_outb(1 << (7 - irq2intreq(irq)), INTMSK0);
+}
+
+static void
+enable_intreq_irq(unsigned int irq)
+{
+	ctrl_outb(1 << (7 - irq2intreq(irq)), INTMSKCLR0);
+}
+
+static void
+mask_and_ack_intreq_irq(unsigned int irq)
+{
+	disable_intreq_irq(irq);
+}
+
+static unsigned int
+startup_intreq_irq(unsigned int irq)
+{
+	enable_intreq_irq(irq);
+	return 0;
+}
+
+static void
+shutdown_intreq_irq(unsigned int irq)
+{
+	disable_intreq_irq(irq);
+}
+
+static void
+end_intreq_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
+		enable_intreq_irq(irq);
+}
+
+static struct hw_interrupt_type intreq_irq_type = {
+	.typename = "intreq",
+	.startup = startup_intreq_irq,
+	.shutdown = shutdown_intreq_irq,
+	.enable = enable_intreq_irq,
+	.disable = disable_intreq_irq,
+	.ack = mask_and_ack_intreq_irq,
+	.end = end_intreq_irq
+};
+
+void
+make_intreq_irq(unsigned int irq)
+{
+	disable_irq_nosync(irq);
+	irq_desc[irq].handler = &intreq_irq_type;
+	disable_intreq_irq(irq);
+}
+
+int
+shmse_irq_demux(int irq)
+{
+	if (irq == IRQ5_IRQ)
+		return 10;
+	return irq;
+}
+
+/*
+ * Initialize IRQ setting
+ */
+void __init
+init_73180se_IRQ(void)
+{
+	make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
+
+	ctrl_outw(0x2000, 0xb03fffec);	/* mrshpc irq enable */
+	ctrl_outw(0x2000, 0xb07fffec);	/* mrshpc irq enable */
+	ctrl_outl(3 << ((7 - 5) * 4), INTC_INTPRI0);	/* irq5 pri=3 */
+	ctrl_outw(2 << ((7 - 5) * 2), INTC_ICR1);	/* low-level irq */
+	make_intreq_irq(10);
+
+	make_ipr_irq(VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8);
+
+	ctrl_outb(0x0f, INTC_IMCR5);	/* enable SCIF IRQ */
+
+	make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
+	make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
+	make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
+	make_ipr_irq(IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
+	make_ipr_irq(IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
+		     IIC0_PRIORITY);
+	make_ipr_irq(IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
+		     IIC0_PRIORITY);
+	make_ipr_irq(IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
+	make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
+	make_ipr_irq(SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY);
+
+	/* VIO interrupt */
+	make_ipr_irq(CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
+	make_ipr_irq(BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
+	make_ipr_irq(VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
+
+	make_ipr_irq(LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY);
+	ctrl_outw(0x2000, PA_MRSHPC + 0x0c);	/* mrshpc irq enable */
+}
diff -Nru a/arch/sh/boards/se/73180/led.c b/arch/sh/boards/se/73180/led.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/se/73180/led.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,67 @@
+/*
+ * arch/sh/boards/se/73180/led.c
+ *
+ * Derived from arch/sh/boards/se/770x/led.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 <linux/sched.h>
+#include <asm/mach/se73180.h>
+
+static void
+mach_led(int position, int value)
+{
+	volatile unsigned short *p = (volatile unsigned short *) PA_LED;
+
+	if (value) {
+		*p |= (1 << LED_SHIFT);
+	} else {
+		*p &= ~(1 << LED_SHIFT);
+	}
+}
+
+/* Cycle the LED's in the clasic Knightrider/Sun pattern */
+void
+heartbeat_73180se(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 + LED_SHIFT);
+
+}
diff -Nru a/arch/sh/boards/se/73180/setup.c b/arch/sh/boards/se/73180/setup.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/se/73180/setup.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,68 @@
+/*
+ * arch/sh/boards/se/73180/setup.c
+ *
+ * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
+ * Based on arch/sh/setup_shmse.c
+ *
+ * Modified for 73180 SolutionEngine
+ *           by YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <asm/machvec.h>
+#include <asm/machvec_init.h>
+#include <asm/mach/io.h>
+
+void heartbeat_73180se(void);
+void init_73180se_IRQ(void);
+
+const char *
+get_system_type(void)
+{
+	return "SolutionEngine 73180";
+}
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_73180se __initmv = {
+	.mv_nr_irqs = 108,
+	.mv_inb = sh73180se_inb,
+	.mv_inw = sh73180se_inw,
+	.mv_inl = sh73180se_inl,
+	.mv_outb = sh73180se_outb,
+	.mv_outw = sh73180se_outw,
+	.mv_outl = sh73180se_outl,
+
+	.mv_inb_p = sh73180se_inb_p,
+	.mv_inw_p = sh73180se_inw,
+	.mv_inl_p = sh73180se_inl,
+	.mv_outb_p = sh73180se_outb_p,
+	.mv_outw_p = sh73180se_outw,
+	.mv_outl_p = sh73180se_outl,
+
+	.mv_insb = sh73180se_insb,
+	.mv_insw = sh73180se_insw,
+	.mv_insl = sh73180se_insl,
+	.mv_outsb = sh73180se_outsb,
+	.mv_outsw = sh73180se_outsw,
+	.mv_outsl = sh73180se_outsl,
+
+	.mv_init_irq = init_73180se_IRQ,
+#ifdef CONFIG_HEARTBEAT
+	.mv_heartbeat = heartbeat_73180se,
+#endif
+};
+
+ALIAS_MV(73180se)
+/*
+ * Initialize the board
+ */
+void __init
+platform_setup(void)
+{
+
+}
diff -Nru a/arch/sh/boards/se/770x/irq.c b/arch/sh/boards/se/770x/irq.c
--- a/arch/sh/boards/se/770x/irq.c	2004-12-24 13:37:30 -08:00
+++ b/arch/sh/boards/se/770x/irq.c	2004-12-24 13:37:30 -08:00
@@ -1,5 +1,4 @@
-/* $Id: irq.c,v 1.4 2004/02/22 22:44:36 kkojima Exp $
- * 
+/*
  * linux/arch/sh/boards/se/770x/irq.c
  *
  * Copyright (C) 2000  Kazumoto Kojima
@@ -12,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <asm/irq.h>
+#include <asm/io.h>
 #include <asm/se/se.h>
 
 /*
@@ -30,6 +30,32 @@
          * 12: mouse
          * 14: ide0
          */
+#if defined(CONFIG_CPU_SUBTYPE_SH7705)
+	/* Disable all interrupts */
+	ctrl_outw(0, BCR_ILCRA);
+	ctrl_outw(0, BCR_ILCRB);
+	ctrl_outw(0, BCR_ILCRC);
+	ctrl_outw(0, BCR_ILCRD);
+	ctrl_outw(0, BCR_ILCRE);
+	ctrl_outw(0, BCR_ILCRF);
+	ctrl_outw(0, BCR_ILCRG);
+	/* This is default value */
+	make_ipr_irq(0xf-0x2, BCR_ILCRA, 2, 0x2);
+	make_ipr_irq(0xf-0xa, BCR_ILCRA, 1, 0xa);
+	make_ipr_irq(0xf-0x5, BCR_ILCRB, 0, 0x5);
+	make_ipr_irq(0xf-0x8, BCR_ILCRC, 1, 0x8);
+	make_ipr_irq(0xf-0xc, BCR_ILCRC, 0, 0xc);
+	make_ipr_irq(0xf-0xe, BCR_ILCRD, 3, 0xe);
+	make_ipr_irq(0xf-0x3, BCR_ILCRD, 1, 0x3); /* LAN */
+	make_ipr_irq(0xf-0xd, BCR_ILCRE, 2, 0xd);
+	make_ipr_irq(0xf-0x9, BCR_ILCRE, 1, 0x9);
+	make_ipr_irq(0xf-0x1, BCR_ILCRE, 0, 0x1);
+	make_ipr_irq(0xf-0xf, BCR_ILCRF, 3, 0xf);
+	make_ipr_irq(0xf-0xb, BCR_ILCRF, 1, 0xb);
+	make_ipr_irq(0xf-0x7, BCR_ILCRG, 3, 0x7);
+	make_ipr_irq(0xf-0x6, BCR_ILCRG, 2, 0x6);
+	make_ipr_irq(0xf-0x4, BCR_ILCRG, 1, 0x4);
+#else
         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);
@@ -50,4 +76,5 @@
         /* 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 */
+#endif
 }
diff -Nru a/arch/sh/boards/se/770x/mach.c b/arch/sh/boards/se/770x/mach.c
--- a/arch/sh/boards/se/770x/mach.c	2004-12-24 13:37:19 -08:00
+++ b/arch/sh/boards/se/770x/mach.c	2004-12-24 13:37:19 -08:00
@@ -33,6 +33,8 @@
 	.mv_nr_irqs		= 32,
 #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
 	.mv_nr_irqs		= 61,
+#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
+	.mv_nr_irqs		= 86,
 #endif
 
 	.mv_inb			= se_inb,
diff -Nru a/arch/sh/boards/se/7751/io.c b/arch/sh/boards/se/7751/io.c
--- a/arch/sh/boards/se/7751/io.c	2004-12-24 13:36:17 -08:00
+++ b/arch/sh/boards/se/7751/io.c	2004-12-24 13:36:17 -08:00
@@ -18,7 +18,7 @@
 #include <asm/addrspace.h>
 
 #include <linux/pci.h>
-#include <asm/pci-sh7751.h>
+#include "../../../drivers/pci/pci-sh7751.h"
 
 #if 0
 /******************************************************************
diff -Nru a/arch/sh/boards/se/7751/pci.c b/arch/sh/boards/se/7751/pci.c
--- a/arch/sh/boards/se/7751/pci.c	2004-12-24 13:36:17 -08:00
+++ b/arch/sh/boards/se/7751/pci.c	2004-12-24 13:36:17 -08:00
@@ -19,7 +19,7 @@
 #include <linux/pci.h>
 
 #include <asm/io.h>
-#include <asm/pci-sh7751.h>
+#include "../../../drivers/pci/pci-sh7751.h"
 
 #define PCIMCR_MRSET_OFF	0xBFFFFFFF
 #define PCIMCR_RFSH_OFF		0xFFFFFFFB
diff -Nru a/arch/sh/boards/sh03/Makefile b/arch/sh/boards/sh03/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/sh03/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,6 @@
+#
+# Makefile for the Interface (CTP/PCI-SH03) specific parts of the kernel
+#
+
+obj-y	 := setup.o rtc.o
+obj-$(CONFIG_HEARTBEAT) += led.o
diff -Nru a/arch/sh/boards/sh03/led.c b/arch/sh/boards/sh03/led.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/sh03/led.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,49 @@
+/*
+ * linux/arch/sh/boards/sh03/led.c
+ *
+ * Copyright (C) 2004  Saito.K Interface Corporation.
+ *
+ * This file contains Interface CTP/PCI-SH03 specific LED code.
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+
+/* Cycle the LED's in the clasic Knightrider/Sun pattern */
+void heartbeat_sh03(void)
+{
+	static unsigned int cnt = 0, period = 0;
+	volatile unsigned char* p = (volatile unsigned char*)0xa0800000;
+	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;
+
+}
diff -Nru a/arch/sh/boards/sh03/rtc.c b/arch/sh/boards/sh03/rtc.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/sh03/rtc.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,146 @@
+/*
+ * linux/arch/sh/boards/sh03/rtc.c -- CTP/PCI-SH03 on-chip RTC support
+ *
+ *  Copyright (C) 2004  Saito.K & Jeanne(ksaito@interface.co.jp)
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/time.h>
+#include <asm/io.h>
+#include <linux/rtc.h>
+#include <linux/spinlock.h>
+
+#define RTC_BASE	0xb0000000
+#define RTC_SEC1	(RTC_BASE + 0)
+#define RTC_SEC10	(RTC_BASE + 1)
+#define RTC_MIN1	(RTC_BASE + 2)
+#define RTC_MIN10	(RTC_BASE + 3)
+#define RTC_HOU1	(RTC_BASE + 4)
+#define RTC_HOU10	(RTC_BASE + 5)
+#define RTC_WEE1	(RTC_BASE + 6)
+#define RTC_DAY1	(RTC_BASE + 7)
+#define RTC_DAY10	(RTC_BASE + 8)
+#define RTC_MON1	(RTC_BASE + 9)
+#define RTC_MON10	(RTC_BASE + 10)
+#define RTC_YEA1	(RTC_BASE + 11)
+#define RTC_YEA10	(RTC_BASE + 12)
+#define RTC_YEA100	(RTC_BASE + 13)
+#define RTC_YEA1000	(RTC_BASE + 14)
+#define RTC_CTL		(RTC_BASE + 15)
+#define RTC_BUSY	1
+#define RTC_STOP	2
+
+#ifndef BCD_TO_BIN
+#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
+#endif
+
+#ifndef BIN_TO_BCD
+#define BIN_TO_BCD(val)	((val)=(((val)/10)<<4) + (val)%10)
+#endif
+
+extern void (*rtc_get_time)(struct timespec *);
+extern int (*rtc_set_time)(const time_t);
+extern spinlock_t rtc_lock;
+
+unsigned long get_cmos_time(void)
+{
+	unsigned int year, mon, day, hour, min, sec;
+	int i;
+
+	spin_lock(&rtc_lock);
+ again:
+	for (i = 0 ; i < 1000000 ; i++)	/* may take up to 1 second... */
+		if (!(ctrl_inb(RTC_CTL) & RTC_BUSY))
+			break;
+	do {
+		sec  = (ctrl_inb(RTC_SEC1) & 0xf) + (ctrl_inb(RTC_SEC10) & 0x7) * 10;
+		min  = (ctrl_inb(RTC_MIN1) & 0xf) + (ctrl_inb(RTC_MIN10) & 0xf) * 10;
+		hour = (ctrl_inb(RTC_HOU1) & 0xf) + (ctrl_inb(RTC_HOU10) & 0xf) * 10;
+		day  = (ctrl_inb(RTC_DAY1) & 0xf) + (ctrl_inb(RTC_DAY10) & 0xf) * 10;
+		mon  = (ctrl_inb(RTC_MON1) & 0xf) + (ctrl_inb(RTC_MON10) & 0xf) * 10;
+		year = (ctrl_inb(RTC_YEA1) & 0xf) + (ctrl_inb(RTC_YEA10) & 0xf) * 10
+		     + (ctrl_inb(RTC_YEA100 ) & 0xf) * 100
+		     + (ctrl_inb(RTC_YEA1000) & 0xf) * 1000;
+	} while (sec != (ctrl_inb(RTC_SEC1) & 0xf) + (ctrl_inb(RTC_SEC10) & 0x7) * 10);
+	if (year == 0 || mon < 1 || mon > 12 || day > 31 || day < 1 ||
+	    hour > 23 || min > 59 || sec > 59) {
+		printk(KERN_ERR
+		       "SH-03 RTC: invalid value, resetting to 1 Jan 2000\n");
+		printk("year=%d, mon=%d, day=%d, hour=%d, min=%d, sec=%d\n",
+		       year, mon, day, hour, min, sec);
+
+		ctrl_outb(0, RTC_SEC1); ctrl_outb(0, RTC_SEC10);
+		ctrl_outb(0, RTC_MIN1); ctrl_outb(0, RTC_MIN10);
+		ctrl_outb(0, RTC_HOU1); ctrl_outb(0, RTC_HOU10);
+		ctrl_outb(6, RTC_WEE1);
+		ctrl_outb(1, RTC_DAY1); ctrl_outb(0, RTC_DAY10);
+		ctrl_outb(1, RTC_MON1); ctrl_outb(0, RTC_MON10);
+		ctrl_outb(0, RTC_YEA1); ctrl_outb(0, RTC_YEA10);
+		ctrl_outb(0, RTC_YEA100);
+		ctrl_outb(2, RTC_YEA1000);
+		ctrl_outb(0, RTC_CTL);
+		goto again;
+	}
+
+	spin_unlock(&rtc_lock);
+	return mktime(year, mon, day, hour, min, sec);
+}
+
+void sh03_rtc_gettimeofday(struct timespec *tv)
+{
+
+	tv->tv_sec = get_cmos_time();
+	tv->tv_nsec = 0;
+}
+
+static int set_rtc_mmss(unsigned long nowtime)
+{
+	int retval = 0;
+	int real_seconds, real_minutes, cmos_minutes;
+	int i;
+
+	/* gets recalled with irq locally disabled */
+	spin_lock(&rtc_lock);
+	for (i = 0 ; i < 1000000 ; i++)	/* may take up to 1 second... */
+		if (!(ctrl_inb(RTC_CTL) & RTC_BUSY))
+			break;
+	cmos_minutes = (ctrl_inb(RTC_MIN1) & 0xf) + (ctrl_inb(RTC_MIN10) & 0xf) * 10;
+	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) {
+		BIN_TO_BCD(real_seconds);
+		BIN_TO_BCD(real_minutes);
+		ctrl_outb(real_seconds % 10, RTC_SEC1);
+		ctrl_outb(real_seconds / 10, RTC_SEC10);
+		ctrl_outb(real_minutes % 10, RTC_MIN1);
+		ctrl_outb(real_minutes / 10, RTC_MIN10);
+	} else {
+		printk(KERN_WARNING
+		       "set_rtc_mmss: can't update from %d to %d\n",
+		       cmos_minutes, real_minutes);
+		retval = -1;
+	}
+	spin_unlock(&rtc_lock);
+
+	return retval;
+}
+
+int sh03_rtc_settimeofday(const time_t secs)
+{
+	unsigned long nowtime = secs;
+
+	return set_rtc_mmss(nowtime);
+}
+
+void sh03_time_init(void)
+{
+	rtc_get_time = sh03_rtc_gettimeofday;
+	rtc_set_time = sh03_rtc_settimeofday;
+}
diff -Nru a/arch/sh/boards/sh03/setup.c b/arch/sh/boards/sh03/setup.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/sh03/setup.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,72 @@
+/*
+ * linux/arch/sh/boards/sh03/setup.c
+ *
+ * Copyright (C) 2004  Interface Co.,Ltd. Saito.K
+ *
+ */
+
+#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/sh03/io.h>
+#include <asm/sh03/sh03.h>
+#include <asm/addrspace.h>
+#include "../../drivers/pci/pci-sh7751.h"
+
+extern void (*board_time_init)(void);
+
+const char *get_system_type(void)
+{
+	return "Interface CTP/PCI-SH03)";
+}
+
+void init_sh03_IRQ(void)
+{
+	ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
+
+	make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY);
+	make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
+	make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
+	make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
+}
+
+extern void *cf_io_base;
+
+unsigned long sh03_isa_port2addr(unsigned long port)
+{
+	if (PXSEG(port))
+		return port;
+	/* CompactFlash (IDE) */
+	if (((port >= 0x1f0) && (port <= 0x1f7)) || (port == 0x3f6)) {
+		return (unsigned long)cf_io_base + port;
+	}
+        return port + SH7751_PCI_IO_BASE;
+}
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_sh03 __initmv = {
+	.mv_nr_irqs		= 48,
+	.mv_isa_port2addr	= sh03_isa_port2addr,
+	.mv_init_irq		= init_sh03_IRQ,
+
+#ifdef CONFIG_HEARTBEAT
+	.mv_heartbeat		= heartbeat_sh03,
+#endif
+};
+
+ALIAS_MV(sh03)
+
+/* arch/sh/boards/sh03/rtc.c */
+void sh03_time_init(void);
+
+int __init platform_setup(void)
+{
+	board_time_init = sh03_time_init;
+	return 0;
+}
diff -Nru a/arch/sh/boards/superh/microdev/Makefile b/arch/sh/boards/superh/microdev/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/superh/microdev/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,8 @@
+#
+# Makefile for the SuperH MicroDev specific parts of the kernel
+#
+
+obj-y	 := setup.o irq.o io.o
+
+obj-$(CONFIG_HEARTBEAT)	+= led.o
+
diff -Nru a/arch/sh/boards/superh/microdev/io.c b/arch/sh/boards/superh/microdev/io.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/superh/microdev/io.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,370 @@
+/*
+ * linux/arch/sh/kernel/io_microdev.c
+ *
+ * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
+ * Copyright (C) 2003, 2004 SuperH, Inc.
+ * Copyright (C) 2004 Paul Mundt
+ *
+ * SuperH SH4-202 MicroDev board support.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/wait.h>
+#include <asm/io.h>
+#include <asm/mach/io.h>
+
+	/*
+	 *	we need to have a 'safe' address to re-direct all I/O requests
+	 *	that we do not explicitly wish to handle. This safe address
+	 *	must have the following properies:
+	 *
+	 *		* writes are ignored (no exception)
+	 *		* reads are benign (no side-effects)
+	 *		* accesses of width 1, 2 and 4-bytes are all valid.
+	 *
+	 *	The Processor Version Register (PVR) has these properties.
+	 */
+#define	PVR	0xff000030	/* Processor Version Register */
+
+
+#define	IO_IDE2_BASE		0x170ul	/* I/O base for SMSC FDC37C93xAPM IDE #2 */
+#define	IO_IDE1_BASE		0x1f0ul	/* I/O base for SMSC FDC37C93xAPM IDE #1 */
+#define IO_ISP1161_BASE		0x290ul /* I/O port for Philips ISP1161x USB chip */
+#define IO_SERIAL2_BASE		0x2f8ul /* I/O base for SMSC FDC37C93xAPM Serial #2 */
+#define	IO_LAN91C111_BASE	0x300ul	/* I/O base for SMSC LAN91C111 Ethernet chip */
+#define	IO_IDE2_MISC		0x376ul	/* I/O misc for SMSC FDC37C93xAPM IDE #2 */
+#define IO_SUPERIO_BASE		0x3f0ul /* I/O base for SMSC FDC37C93xAPM SuperIO chip */
+#define	IO_IDE1_MISC		0x3f6ul	/* I/O misc for SMSC FDC37C93xAPM IDE #1 */
+#define IO_SERIAL1_BASE		0x3f8ul /* I/O base for SMSC FDC37C93xAPM Serial #1 */
+
+#define	IO_ISP1161_EXTENT	0x04ul	/* I/O extent for Philips ISP1161x USB chip */
+#define	IO_LAN91C111_EXTENT	0x10ul	/* I/O extent for SMSC LAN91C111 Ethernet chip */
+#define	IO_SUPERIO_EXTENT	0x02ul	/* I/O extent for SMSC FDC37C93xAPM SuperIO chip */
+#define	IO_IDE_EXTENT		0x08ul	/* I/O extent for IDE Task Register set */
+#define IO_SERIAL_EXTENT	0x10ul
+
+#define	IO_LAN91C111_PHYS	0xa7500000ul	/* Physical address of SMSC LAN91C111 Ethernet chip */
+#define	IO_ISP1161_PHYS		0xa7700000ul	/* Physical address of Philips ISP1161x USB chip */
+#define	IO_SUPERIO_PHYS		0xa7800000ul	/* Physical address of SMSC FDC37C93xAPM SuperIO chip */
+
+#define PORT2ADDR(x) (microdev_isa_port2addr(x))
+
+
+static inline void delay(void)
+{
+#if defined(CONFIG_PCI)
+	/* System board present, just make a dummy SRAM access.  (CS0 will be
+	   mapped to PCI memory, probably good to avoid it.) */
+	ctrl_inw(0xa6800000);
+#else
+	/* CS0 will be mapped to flash, ROM etc so safe to access it. */
+	ctrl_inw(0xa0000000);
+#endif
+}
+
+unsigned char microdev_inb(unsigned long port)
+{
+#ifdef CONFIG_PCI
+	if (port >= PCIBIOS_MIN_IO)
+		return microdev_pci_inb(port);
+#endif
+	return *(volatile unsigned char*)PORT2ADDR(port);
+}
+
+unsigned short microdev_inw(unsigned long port)
+{
+#ifdef CONFIG_PCI
+	if (port >= PCIBIOS_MIN_IO)
+		return microdev_pci_inw(port);
+#endif
+	return *(volatile unsigned short*)PORT2ADDR(port);
+}
+
+unsigned int microdev_inl(unsigned long port)
+{
+#ifdef CONFIG_PCI
+	if (port >= PCIBIOS_MIN_IO)
+		return microdev_pci_inl(port);
+#endif
+	return *(volatile unsigned int*)PORT2ADDR(port);
+}
+
+void microdev_outb(unsigned char b, unsigned long port)
+{
+#ifdef CONFIG_PCI
+	if (port >= PCIBIOS_MIN_IO) {
+		microdev_pci_outb(b, port);
+		return;
+	}
+#endif
+
+	/*
+	 *	There is a board feature with the current SH4-202 MicroDev in
+	 *	that the 2 byte enables (nBE0 and nBE1) are tied together (and
+	 *	to the Chip Select Line (Ethernet_CS)). Due to this conectivity,
+	 *	it is not possible to safely perform 8-bit writes to the
+	 *	Ethernet registers, as 16-bits will be consumed from the Data
+	 *	lines (corrupting the other byte).  Hence, this function is
+	 *	written to impliment 16-bit read/modify/write for all byte-wide
+	 *	acceses.
+	 *
+	 *	Note: there is no problem with byte READS (even or odd).
+	 *
+	 *			Sean McGoogan - 16th June 2003.
+	 */
+	if ((port >= IO_LAN91C111_BASE) &&
+	    (port <  IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) {
+			/*
+			 * Then are trying to perform a byte-write to the
+			 * LAN91C111.  This needs special care.
+			 */
+		if (port % 2 == 1) {	/* is the port odd ? */
+			/* unset bit-0, i.e. make even */
+			const unsigned long evenPort = port-1;
+			unsigned short word;
+
+			/*
+			 * do a 16-bit read/write to write to 'port',
+			 * preserving even byte.
+			 *
+			 *	Even addresses are bits 0-7
+			 *	Odd  addresses are bits 8-15
+			 */
+			word = microdev_inw(evenPort);
+			word = (word & 0xffu) | (b << 8);
+			microdev_outw(word, evenPort);
+		} else {
+			/* else, we are trying to do an even byte write */
+			unsigned short word;
+
+			/*
+			 * do a 16-bit read/write to write to 'port',
+			 * preserving odd byte.
+			 *
+			 *	Even addresses are bits 0-7
+			 *	Odd  addresses are bits 8-15
+			 */
+			word = microdev_inw(port);
+			word = (word & 0xff00u) | (b);
+			microdev_outw(word, port);
+		}
+	} else {
+		*(volatile unsigned char*)PORT2ADDR(port) = b;
+	}
+}
+
+void microdev_outw(unsigned short b, unsigned long port)
+{
+#ifdef CONFIG_PCI
+	if (port >= PCIBIOS_MIN_IO) {
+		microdev_pci_outw(b, port);
+		return;
+	}
+#endif
+	*(volatile unsigned short*)PORT2ADDR(port) = b;
+}
+
+void microdev_outl(unsigned int b, unsigned long port)
+{
+#ifdef CONFIG_PCI
+	if (port >= PCIBIOS_MIN_IO) {
+		microdev_pci_outl(b, port);
+		return;
+	}
+#endif
+	*(volatile unsigned int*)PORT2ADDR(port) = b;
+}
+
+unsigned char microdev_inb_p(unsigned long port)
+{
+	unsigned char v = microdev_inb(port);
+	delay();
+	return v;
+}
+
+unsigned short microdev_inw_p(unsigned long port)
+{
+	unsigned short v = microdev_inw(port);
+	delay();
+	return v;
+}
+
+unsigned int microdev_inl_p(unsigned long port)
+{
+	unsigned int v = microdev_inl(port);
+	delay();
+	return v;
+}
+
+void microdev_outb_p(unsigned char b, unsigned long port)
+{
+	microdev_outb(b, port);
+	delay();
+}
+
+void microdev_outw_p(unsigned short b, unsigned long port)
+{
+	microdev_outw(b, port);
+	delay();
+}
+
+void microdev_outl_p(unsigned int b, unsigned long port)
+{
+	microdev_outl(b, port);
+	delay();
+}
+
+void microdev_insb(unsigned long port, void *buffer, unsigned long count)
+{
+	volatile unsigned char *port_addr;
+	unsigned char *buf = buffer;
+
+	port_addr = (volatile unsigned char *)PORT2ADDR(port);
+
+	while (count--)
+		*buf++ = *port_addr;
+}
+
+void microdev_insw(unsigned long port, void *buffer, unsigned long count)
+{
+	volatile unsigned short *port_addr;
+	unsigned short *buf = buffer;
+
+	port_addr = (volatile unsigned short *)PORT2ADDR(port);
+
+	while (count--)
+		*buf++ = *port_addr;
+}
+
+void microdev_insl(unsigned long port, void *buffer, unsigned long count)
+{
+	volatile unsigned long *port_addr;
+	unsigned int *buf = buffer;
+
+	port_addr = (volatile unsigned long *)PORT2ADDR(port);
+
+	while (count--)
+		*buf++ = *port_addr;
+}
+
+void microdev_outsb(unsigned long port, const void *buffer, unsigned long count)
+{
+	volatile unsigned char *port_addr;
+	const unsigned char *buf = buffer;
+
+	port_addr = (volatile unsigned char *)PORT2ADDR(port);
+
+	while (count--)
+		*port_addr = *buf++;
+}
+
+void microdev_outsw(unsigned long port, const void *buffer, unsigned long count)
+{
+	volatile unsigned short *port_addr;
+	const unsigned short *buf = buffer;
+
+	port_addr = (volatile unsigned short *)PORT2ADDR(port);
+
+	while (count--)
+		*port_addr = *buf++;
+}
+
+void microdev_outsl(unsigned long port, const void *buffer, unsigned long count)
+{
+	volatile unsigned long *port_addr;
+	const unsigned int *buf = buffer;
+
+	port_addr = (volatile unsigned long *)PORT2ADDR(port);
+
+	while (count--)
+		*port_addr = *buf++;
+}
+
+/*
+ * map I/O ports to memory-mapped addresses
+ */
+unsigned long microdev_isa_port2addr(unsigned long offset)
+{
+	unsigned long result;
+
+	if ((offset >= IO_LAN91C111_BASE) &&
+	    (offset <  IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) {
+			/*
+			 *	SMSC LAN91C111 Ethernet chip
+			 */
+		result = IO_LAN91C111_PHYS + offset - IO_LAN91C111_BASE;
+	} else if ((offset >= IO_SUPERIO_BASE) &&
+		   (offset <  IO_SUPERIO_BASE + IO_SUPERIO_EXTENT)) {
+			/*
+			 *	SMSC FDC37C93xAPM SuperIO chip
+			 *
+			 *	Configuration Registers
+			 */
+		result = IO_SUPERIO_PHYS + (offset << 1);
+#if 0
+	} else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG ||
+		   offset == KBD_STATUS_REG) {
+			/*
+			 *	SMSC FDC37C93xAPM SuperIO chip
+			 *
+			 *	PS/2 Keyboard + Mouse (ports 0x60 and 0x64).
+			 */
+	        result = IO_SUPERIO_PHYS + (offset << 1);
+#endif
+	} else if (((offset >= IO_IDE1_BASE) &&
+		    (offset <  IO_IDE1_BASE + IO_IDE_EXTENT)) ||
+		    (offset == IO_IDE1_MISC)) {
+			/*
+			 *	SMSC FDC37C93xAPM SuperIO chip
+			 *
+			 *	IDE #1
+			 */
+	        result = IO_SUPERIO_PHYS + (offset << 1);
+	} else if (((offset >= IO_IDE2_BASE) &&
+		    (offset <  IO_IDE2_BASE + IO_IDE_EXTENT)) ||
+		    (offset == IO_IDE2_MISC)) {
+			/*
+			 *	SMSC FDC37C93xAPM SuperIO chip
+			 *
+			 *	IDE #2
+			 */
+	        result = IO_SUPERIO_PHYS + (offset << 1);
+	} else if ((offset >= IO_SERIAL1_BASE) &&
+		   (offset <  IO_SERIAL1_BASE + IO_SERIAL_EXTENT)) {
+			/*
+			 *	SMSC FDC37C93xAPM SuperIO chip
+			 *
+			 *	Serial #1
+			 */
+		result = IO_SUPERIO_PHYS + (offset << 1);
+	} else if ((offset >= IO_SERIAL2_BASE) &&
+		   (offset <  IO_SERIAL2_BASE + IO_SERIAL_EXTENT)) {
+			/*
+			 *	SMSC FDC37C93xAPM SuperIO chip
+			 *
+			 *	Serial #2
+			 */
+		result = IO_SUPERIO_PHYS + (offset << 1);
+	} else if ((offset >= IO_ISP1161_BASE) &&
+		   (offset < IO_ISP1161_BASE + IO_ISP1161_EXTENT)) {
+			/*
+			 *	Philips USB ISP1161x chip
+			 */
+		result = IO_ISP1161_PHYS + offset - IO_ISP1161_BASE;
+	} else {
+			/*
+			 *	safe default.
+			 */
+		printk("Warning: unexpected port in %s( offset = 0x%lx )\n",
+		       __FUNCTION__, offset);
+		result = PVR;
+	}
+
+	return result;
+}
+
diff -Nru a/arch/sh/boards/superh/microdev/irq.c b/arch/sh/boards/superh/microdev/irq.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/superh/microdev/irq.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,200 @@
+/*
+ * arch/sh/boards/superh/microdev/irq.c
+ *
+ * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
+ *
+ * SuperH SH4-202 MicroDev board support.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/mach/irq.h>
+
+#define NUM_EXTERNAL_IRQS 16	/* IRL0 .. IRL15 */
+
+
+static const struct {
+	unsigned char fpgaIrq;
+	unsigned char mapped;
+	const char *name;
+} fpgaIrqTable[NUM_EXTERNAL_IRQS] = {
+	{ 0,				0,	"unused"   },		/* IRQ #0	IRL=15	0x200  */
+	{ MICRODEV_FPGA_IRQ_KEYBOARD,	1,	"keyboard" },		/* IRQ #1	IRL=14	0x220  */
+	{ MICRODEV_FPGA_IRQ_SERIAL1,	1,	"Serial #1"},		/* IRQ #2	IRL=13	0x240  */
+	{ MICRODEV_FPGA_IRQ_ETHERNET,	1,	"Ethernet" },		/* IRQ #3	IRL=12	0x260  */
+	{ MICRODEV_FPGA_IRQ_SERIAL2,	0,	"Serial #2"},		/* IRQ #4	IRL=11	0x280  */
+	{ 0,				0,	"unused"   },		/* IRQ #5	IRL=10	0x2a0  */
+	{ 0,				0,	"unused"   },		/* IRQ #6	IRL=9	0x2c0  */
+	{ MICRODEV_FPGA_IRQ_USB_HC,	1,	"USB"	   },		/* IRQ #7	IRL=8	0x2e0  */
+	{ MICRODEV_IRQ_PCI_INTA,	1,	"PCI INTA" },		/* IRQ #8	IRL=7	0x300  */
+	{ MICRODEV_IRQ_PCI_INTB,	1,	"PCI INTB" },		/* IRQ #9	IRL=6	0x320  */
+	{ MICRODEV_IRQ_PCI_INTC,	1,	"PCI INTC" },		/* IRQ #10	IRL=5	0x340  */
+	{ MICRODEV_IRQ_PCI_INTD,	1,	"PCI INTD" },		/* IRQ #11	IRL=4	0x360  */
+	{ MICRODEV_FPGA_IRQ_MOUSE,	1,	"mouse"    },		/* IRQ #12	IRL=3	0x380  */
+	{ MICRODEV_FPGA_IRQ_IDE2,	1,	"IDE #2"   },		/* IRQ #13	IRL=2	0x3a0  */
+	{ MICRODEV_FPGA_IRQ_IDE1,	1,	"IDE #1"   },		/* IRQ #14	IRL=1	0x3c0  */
+	{ 0,				0,	"unused"   },		/* IRQ #15	IRL=0	0x3e0  */
+};
+
+#if (MICRODEV_LINUX_IRQ_KEYBOARD != 1)
+#  error Inconsistancy in defining the IRQ# for Keyboard!
+#endif
+
+#if (MICRODEV_LINUX_IRQ_ETHERNET != 3)
+#  error Inconsistancy in defining the IRQ# for Ethernet!
+#endif
+
+#if (MICRODEV_LINUX_IRQ_USB_HC != 7)
+#  error Inconsistancy in defining the IRQ# for USB!
+#endif
+
+#if (MICRODEV_LINUX_IRQ_MOUSE != 12)
+#  error Inconsistancy in defining the IRQ# for PS/2 Mouse!
+#endif
+
+#if (MICRODEV_LINUX_IRQ_IDE2 != 13)
+#  error Inconsistancy in defining the IRQ# for secondary IDE!
+#endif
+
+#if (MICRODEV_LINUX_IRQ_IDE1 != 14)
+#  error Inconsistancy in defining the IRQ# for primary IDE!
+#endif
+
+static void enable_microdev_irq(unsigned int irq);
+static void disable_microdev_irq(unsigned int irq);
+
+	/* shutdown is same as "disable" */
+#define shutdown_microdev_irq disable_microdev_irq
+
+static void mask_and_ack_microdev(unsigned int);
+static void end_microdev_irq(unsigned int irq);
+
+static unsigned int startup_microdev_irq(unsigned int irq)
+{
+	enable_microdev_irq(irq);
+	return 0;		/* never anything pending */
+}
+
+static struct hw_interrupt_type microdev_irq_type = {
+	"MicroDev-IRQ",
+	startup_microdev_irq,
+	shutdown_microdev_irq,
+	enable_microdev_irq,
+	disable_microdev_irq,
+	mask_and_ack_microdev,
+	end_microdev_irq
+};
+
+static void disable_microdev_irq(unsigned int irq)
+{
+	unsigned int flags;
+	unsigned int fpgaIrq;
+
+	if (irq >= NUM_EXTERNAL_IRQS) return;
+	if (!fpgaIrqTable[irq].mapped) return;
+
+	fpgaIrq = fpgaIrqTable[irq].fpgaIrq;
+
+		/* disable interrupts */
+	local_irq_save(flags);
+
+		/* disable interupts on the FPGA INTC register */
+	ctrl_outl(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG);
+
+		/* restore interrupts */
+	local_irq_restore(flags);
+}
+
+static void enable_microdev_irq(unsigned int irq)
+{
+	unsigned long priorityReg, priorities, pri;
+	unsigned int flags;
+	unsigned int fpgaIrq;
+
+
+	if (irq >= NUM_EXTERNAL_IRQS) return;
+	if (!fpgaIrqTable[irq].mapped) return;
+
+	pri = 15 - irq;
+
+	fpgaIrq = fpgaIrqTable[irq].fpgaIrq;
+	priorityReg = MICRODEV_FPGA_INTPRI_REG(fpgaIrq);
+
+		/* disable interrupts */
+	local_irq_save(flags);
+
+		/* set priority for the interrupt */
+	priorities = ctrl_inl(priorityReg);
+	priorities &= ~MICRODEV_FPGA_INTPRI_MASK(fpgaIrq);
+	priorities |= MICRODEV_FPGA_INTPRI_LEVEL(fpgaIrq, pri);
+	ctrl_outl(priorities, priorityReg);
+
+		/* enable interupts on the FPGA INTC register */
+	ctrl_outl(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG);
+
+		/* restore interrupts */
+	local_irq_restore(flags);
+}
+
+	/* This functions sets the desired irq handler to be a MicroDev type */
+static void __init make_microdev_irq(unsigned int irq)
+{
+	disable_irq_nosync(irq);
+	irq_desc[irq].handler = &microdev_irq_type;
+	disable_microdev_irq(irq);
+}
+
+static void mask_and_ack_microdev(unsigned int irq)
+{
+	disable_microdev_irq(irq);
+}
+
+static void end_microdev_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+	{
+		enable_microdev_irq(irq);
+	}
+}
+
+extern void __init init_microdev_irq(void)
+{
+	int i;
+
+		/* disable interupts on the FPGA INTC register */
+	ctrl_outl(~0ul, MICRODEV_FPGA_INTDSB_REG);
+
+	for (i = 0; i < NUM_EXTERNAL_IRQS; i++)
+	{
+		make_microdev_irq(i);
+	}
+}
+
+extern void microdev_print_fpga_intc_status(void)
+{
+	volatile unsigned int * const intenb = (unsigned int*)MICRODEV_FPGA_INTENB_REG;
+	volatile unsigned int * const intdsb = (unsigned int*)MICRODEV_FPGA_INTDSB_REG;
+	volatile unsigned int * const intpria = (unsigned int*)MICRODEV_FPGA_INTPRI_REG(0);
+	volatile unsigned int * const intprib = (unsigned int*)MICRODEV_FPGA_INTPRI_REG(8);
+	volatile unsigned int * const intpric = (unsigned int*)MICRODEV_FPGA_INTPRI_REG(16);
+	volatile unsigned int * const intprid = (unsigned int*)MICRODEV_FPGA_INTPRI_REG(24);
+	volatile unsigned int * const intsrc = (unsigned int*)MICRODEV_FPGA_INTSRC_REG;
+	volatile unsigned int * const intreq = (unsigned int*)MICRODEV_FPGA_INTREQ_REG;
+
+	printk("-------------------------- microdev_print_fpga_intc_status() ------------------\n");
+	printk("FPGA_INTENB = 0x%08x\n", *intenb);
+	printk("FPGA_INTDSB = 0x%08x\n", *intdsb);
+	printk("FPGA_INTSRC = 0x%08x\n", *intsrc);
+	printk("FPGA_INTREQ = 0x%08x\n", *intreq);
+	printk("FPGA_INTPRI[3..0] = %08x:%08x:%08x:%08x\n", *intprid, *intpric, *intprib, *intpria);
+	printk("-------------------------------------------------------------------------------\n");
+}
+
+
diff -Nru a/arch/sh/boards/superh/microdev/led.c b/arch/sh/boards/superh/microdev/led.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/superh/microdev/led.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,102 @@
+/*
+ * linux/arch/sh/kernel/led_microdev.c
+ *
+ * Copyright (C) 2002 Stuart Menefy <stuart.menefy@st.com>
+ * Copyright (C) 2003 Richard Curnow (Richard.Curnow@superh.com)
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ */
+
+#include <linux/config.h>
+#include <asm/io.h>
+
+#define LED_REGISTER 0xa6104d20
+
+static void mach_led_d9(int value)
+{
+	unsigned long reg;
+	reg = ctrl_inl(LED_REGISTER);
+	reg &= ~1;
+	reg |= (value & 1);
+	ctrl_outl(reg, LED_REGISTER);
+	return;
+}
+
+static void mach_led_d10(int value)
+{
+	unsigned long reg;
+	reg = ctrl_inl(LED_REGISTER);
+	reg &= ~2;
+	reg |= ((value & 1) << 1);
+	ctrl_outl(reg, LED_REGISTER);
+	return;
+}
+
+
+#ifdef CONFIG_HEARTBEAT
+#include <linux/sched.h>
+
+static unsigned char banner_table[] = {
+	0x11, 0x01, 0x11, 0x01, 0x11, 0x03,
+	0x11, 0x01, 0x11, 0x01, 0x13, 0x03,
+	0x11, 0x01, 0x13, 0x01, 0x13, 0x01, 0x11, 0x03,
+	0x11, 0x03,
+	0x11, 0x01, 0x13, 0x01, 0x11, 0x03,
+	0x11, 0x01, 0x11, 0x01, 0x11, 0x01, 0x11, 0x07,
+	0x13, 0x01, 0x13, 0x03,
+	0x11, 0x01, 0x11, 0x03,
+	0x13, 0x01, 0x11, 0x01, 0x13, 0x01, 0x11, 0x03,
+	0x11, 0x01, 0x13, 0x01, 0x11, 0x03,
+	0x13, 0x01, 0x13, 0x01, 0x13, 0x03,
+	0x13, 0x01, 0x11, 0x01, 0x11, 0x03,
+	0x11, 0x03,
+	0x11, 0x01, 0x11, 0x01, 0x11, 0x01, 0x13, 0x07,
+	0xff
+};
+
+static void banner(void)
+{
+	static int pos = 0;
+	static int count = 0;
+
+	if (count) {
+		count--;
+	} else {
+		int val = banner_table[pos];
+		if (val == 0xff) {
+			pos = 0;
+			val = banner_table[pos];
+		}
+		pos++;
+		mach_led_d10((val >> 4) & 1);
+		count = 10 * (val & 0xf);
+	}
+}
+
+/* From heartbeat_harp in the stboards directory */
+/* acts like an actual heart beat -- ie thump-thump-pause... */
+void microdev_heartbeat(void)
+{
+	static unsigned cnt = 0, period = 0, dist = 0;
+
+	if (cnt == 0 || cnt == dist)
+		mach_led_d9(1);
+	else if (cnt == 7 || cnt == dist+7)
+		mach_led_d9(0);
+
+	if (++cnt > period) {
+		cnt = 0;
+		/* The hyperbolic function below modifies the heartbeat period
+		 * length in dependency of the current (5min) load. It goes
+		 * through the points f(0)=126, f(1)=86, f(5)=51,
+		 * f(inf)->30. */
+		period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
+		dist = period / 4;
+	}
+
+	banner();
+}
+
+#endif
diff -Nru a/arch/sh/boards/superh/microdev/setup.c b/arch/sh/boards/superh/microdev/setup.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/boards/superh/microdev/setup.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,278 @@
+/*
+ * arch/sh/boards/superh/microdev/setup.c
+ *
+ * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
+ * Copyright (C) 2003, 2004 SuperH, Inc.
+ * Copyright (C) 2004 Paul Mundt
+ *
+ * SuperH SH4-202 MicroDev board support.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/ioport.h>
+#include <asm/io.h>
+#include <asm/mach/irq.h>
+#include <asm/mach/io.h>
+#include <asm/machvec.h>
+#include <asm/machvec_init.h>
+
+extern void microdev_heartbeat(void);
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_sh4202_microdev __initmv = {
+	.mv_nr_irqs		= 72,		/* QQQ need to check this - use the MACRO */
+
+	.mv_inb			= microdev_inb,
+	.mv_inw			= microdev_inw,
+	.mv_inl			= microdev_inl,
+	.mv_outb		= microdev_outb,
+	.mv_outw		= microdev_outw,
+	.mv_outl		= microdev_outl,
+
+	.mv_inb_p		= microdev_inb_p,
+	.mv_inw_p		= microdev_inw_p,
+	.mv_inl_p		= microdev_inl_p,
+	.mv_outb_p		= microdev_outb_p,
+	.mv_outw_p		= microdev_outw_p,
+	.mv_outl_p		= microdev_outl_p,
+
+	.mv_insb		= microdev_insb,
+	.mv_insw		= microdev_insw,
+	.mv_insl		= microdev_insl,
+	.mv_outsb		= microdev_outsb,
+	.mv_outsw		= microdev_outsw,
+	.mv_outsl		= microdev_outsl,
+
+	.mv_isa_port2addr	= microdev_isa_port2addr,
+
+	.mv_init_irq		= init_microdev_irq,
+
+#ifdef CONFIG_HEARTBEAT
+	.mv_heartbeat		= microdev_heartbeat,
+#endif
+};
+ALIAS_MV(sh4202_microdev)
+
+/****************************************************************************/
+
+
+	/*
+	 * Setup for the SMSC FDC37C93xAPM
+	 */
+#define SMSC_CONFIG_PORT_ADDR	 (0x3F0)
+#define SMSC_INDEX_PORT_ADDR	 SMSC_CONFIG_PORT_ADDR
+#define SMSC_DATA_PORT_ADDR	 (SMSC_INDEX_PORT_ADDR + 1)
+
+#define SMSC_ENTER_CONFIG_KEY	 0x55
+#define SMSC_EXIT_CONFIG_KEY	 0xaa
+
+#define SMCS_LOGICAL_DEV_INDEX 	 0x07	/* Logical Device Number */
+#define SMSC_DEVICE_ID_INDEX	 0x20	/* Device ID */
+#define SMSC_DEVICE_REV_INDEX	 0x21	/* Device Revision */
+#define SMSC_ACTIVATE_INDEX	 0x30	/* Activate */
+#define SMSC_PRIMARY_BASE_INDEX	 0x60	/* Primary Base Address */
+#define SMSC_SECONDARY_BASE_INDEX 0x62	/* Secondary Base Address */
+#define SMSC_PRIMARY_INT_INDEX	 0x70	/* Primary Interrupt Select */
+#define SMSC_SECONDARY_INT_INDEX 0x72	/* Secondary Interrupt Select */
+#define SMSC_HDCS0_INDEX	 0xf0	/* HDCS0 Address Decoder */
+#define SMSC_HDCS1_INDEX	 0xf1	/* HDCS1 Address Decoder */
+
+#define SMSC_IDE1_DEVICE	1	/* IDE #1 logical device */
+#define SMSC_IDE2_DEVICE	2	/* IDE #2 logical device */
+#define SMSC_PARALLEL_DEVICE	3	/* Parallel Port logical device */
+#define SMSC_SERIAL1_DEVICE	4	/* Serial #1 logical device */
+#define SMSC_SERIAL2_DEVICE	5	/* Serial #2 logical device */
+#define SMSC_KEYBOARD_DEVICE	7	/* Keyboard logical device */
+#define SMSC_CONFIG_REGISTERS	8	/* Configuration Registers (Aux I/O) */
+
+#define SMSC_READ_INDEXED(index) ({ \
+	outb((index), SMSC_INDEX_PORT_ADDR); \
+	inb(SMSC_DATA_PORT_ADDR); })
+#define SMSC_WRITE_INDEXED(val, index) ({ \
+	outb((index), SMSC_INDEX_PORT_ADDR); \
+	outb((val),   SMSC_DATA_PORT_ADDR); })
+
+#define	IDE1_PRIMARY_BASE	0x01f0	/* Task File Registe base for IDE #1 */
+#define	IDE1_SECONDARY_BASE	0x03f6	/* Miscellaneous AT registers for IDE #1 */
+#define	IDE2_PRIMARY_BASE	0x0170	/* Task File Registe base for IDE #2 */
+#define	IDE2_SECONDARY_BASE	0x0376	/* Miscellaneous AT registers for IDE #2 */
+
+#define SERIAL1_PRIMARY_BASE	0x03f8
+#define SERIAL2_PRIMARY_BASE	0x02f8
+
+#define	MSB(x)		( (x) >> 8 )
+#define	LSB(x)		( (x) & 0xff )
+
+	/* General-Purpose base address on CPU-board FPGA */
+#define	MICRODEV_FPGA_GP_BASE		0xa6100000ul
+
+	/* assume a Keyboard Controller is present */
+int microdev_kbd_controller_present = 1;
+
+const char *get_system_type(void)
+{
+	return "SH4-202 MicroDev";
+}
+
+static struct resource smc91x_resources[] = {
+	[0] = {
+		.start		= 0x300,
+		.end		= 0x300 + 0x0001000 - 1,
+		.flags		= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start		= MICRODEV_LINUX_IRQ_ETHERNET,
+		.end		= MICRODEV_LINUX_IRQ_ETHERNET,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device smc91x_device = {
+	.name		= "smc91x",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(smc91x_resources),
+	.resource	= smc91x_resources,
+};
+
+static int __init smc91x_setup(void)
+{
+	return platform_device_register(&smc91x_device);
+}
+
+__initcall(smc91x_setup);
+
+	/*
+	 * Initialize the board
+	 */
+void __init platform_setup(void)
+{
+	int * const fpgaRevisionRegister = (int*)(MICRODEV_FPGA_GP_BASE + 0x8ul);
+	const int fpgaRevision = *fpgaRevisionRegister;
+	int * const CacheControlRegister = (int*)CCR;
+
+	printk("SuperH %s board (FPGA rev: 0x%0x, CCR: 0x%0x)\n",
+		get_system_type(), fpgaRevision, *CacheControlRegister);
+}
+
+
+/****************************************************************************/
+
+
+	/*
+	 * Setup for the SMSC FDC37C93xAPM
+	 */
+static int __init smsc_superio_setup(void)
+{
+
+	unsigned char devid, devrev;
+
+		/* Initially the chip is in run state */
+		/* Put it into configuration state */
+	outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
+
+		/* Read device ID info */
+	devid  = SMSC_READ_INDEXED(SMSC_DEVICE_ID_INDEX);
+	devrev = SMSC_READ_INDEXED(SMSC_DEVICE_REV_INDEX);
+	if ( (devid==0x30) && (devrev==0x01) )
+	{
+  		printk("SMSC FDC37C93xAPM SuperIO device detected\n");
+	}
+	else
+	{		/* not the device identity we expected */
+		printk("Not detected a SMSC FDC37C93xAPM SuperIO device (devid=0x%02x, rev=0x%02x)\n",
+			devid, devrev);
+			/* inform the keyboard driver that we have no keyboard controller */
+		microdev_kbd_controller_present = 0;
+			/* little point in doing anything else in this functon */
+		return 0;
+	}
+
+		/* Select the keyboard device */
+	SMSC_WRITE_INDEXED(SMSC_KEYBOARD_DEVICE, SMCS_LOGICAL_DEV_INDEX);
+		/* enable it */
+	SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
+		/* enable the interrupts */
+	SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_KEYBOARD, SMSC_PRIMARY_INT_INDEX);
+	SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_MOUSE, SMSC_SECONDARY_INT_INDEX);
+
+		/* Select the Serial #1 device */
+	SMSC_WRITE_INDEXED(SMSC_SERIAL1_DEVICE, SMCS_LOGICAL_DEV_INDEX);
+		/* enable it */
+	SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
+		/* program with port addresses */
+	SMSC_WRITE_INDEXED(MSB(SERIAL1_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+0);
+	SMSC_WRITE_INDEXED(LSB(SERIAL1_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+1);
+	SMSC_WRITE_INDEXED(0x00, SMSC_HDCS0_INDEX);
+		/* enable the interrupts */
+	SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_SERIAL1, SMSC_PRIMARY_INT_INDEX);
+
+		/* Select the Serial #2 device */
+	SMSC_WRITE_INDEXED(SMSC_SERIAL2_DEVICE, SMCS_LOGICAL_DEV_INDEX);
+		/* enable it */
+	SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
+		/* program with port addresses */
+	SMSC_WRITE_INDEXED(MSB(SERIAL2_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+0);
+	SMSC_WRITE_INDEXED(LSB(SERIAL2_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+1);
+	SMSC_WRITE_INDEXED(0x00, SMSC_HDCS0_INDEX);
+		/* enable the interrupts */
+	SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_SERIAL2, SMSC_PRIMARY_INT_INDEX);
+
+		/* Select the IDE#1 device */
+	SMSC_WRITE_INDEXED(SMSC_IDE1_DEVICE, SMCS_LOGICAL_DEV_INDEX);
+		/* enable it */
+	SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
+		/* program with port addresses */
+	SMSC_WRITE_INDEXED(MSB(IDE1_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+0);
+	SMSC_WRITE_INDEXED(LSB(IDE1_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+1);
+	SMSC_WRITE_INDEXED(MSB(IDE1_SECONDARY_BASE), SMSC_SECONDARY_BASE_INDEX+0);
+	SMSC_WRITE_INDEXED(LSB(IDE1_SECONDARY_BASE), SMSC_SECONDARY_BASE_INDEX+1);
+	SMSC_WRITE_INDEXED(0x0c, SMSC_HDCS0_INDEX);
+	SMSC_WRITE_INDEXED(0x00, SMSC_HDCS1_INDEX);
+		/* select the interrupt */
+	SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_IDE1, SMSC_PRIMARY_INT_INDEX);
+
+		/* Select the IDE#2 device */
+	SMSC_WRITE_INDEXED(SMSC_IDE2_DEVICE, SMCS_LOGICAL_DEV_INDEX);
+		/* enable it */
+	SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
+		/* program with port addresses */
+	SMSC_WRITE_INDEXED(MSB(IDE2_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+0);
+	SMSC_WRITE_INDEXED(LSB(IDE2_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+1);
+	SMSC_WRITE_INDEXED(MSB(IDE2_SECONDARY_BASE), SMSC_SECONDARY_BASE_INDEX+0);
+	SMSC_WRITE_INDEXED(LSB(IDE2_SECONDARY_BASE), SMSC_SECONDARY_BASE_INDEX+1);
+		/* select the interrupt */
+	SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_IDE2, SMSC_PRIMARY_INT_INDEX);
+
+		/* Select the configuration registers */
+	SMSC_WRITE_INDEXED(SMSC_CONFIG_REGISTERS, SMCS_LOGICAL_DEV_INDEX);
+		/* enable the appropriate GPIO pins for IDE functionality:
+		 * bit[0]   In/Out		1==input;  0==output
+		 * bit[1]   Polarity		1==invert; 0==no invert
+		 * bit[2]   Int Enb #1		1==Enable Combined IRQ #1; 0==disable
+		 * bit[3:4] Function Select	00==original; 01==Alternate Function #1
+		 */
+	SMSC_WRITE_INDEXED(0x00, 0xc2);	/* GP42 = nIDE1_OE */
+	SMSC_WRITE_INDEXED(0x01, 0xc5);	/* GP45 = IDE1_IRQ */
+	SMSC_WRITE_INDEXED(0x00, 0xc6);	/* GP46 = nIOROP */
+	SMSC_WRITE_INDEXED(0x00, 0xc7);	/* GP47 = nIOWOP */
+	SMSC_WRITE_INDEXED(0x08, 0xe8);	/* GP20 = nIDE2_OE */
+
+		/* Exit the configuraton state */
+	outb(SMSC_EXIT_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
+
+	return 0;
+}
+
+
+/* This is grotty, but, because kernel is always referenced on the link line
+ * before any devices, this is safe.
+ */
+__initcall(smsc_superio_setup);
diff -Nru a/arch/sh/cchips/voyagergx/consistent.c b/arch/sh/cchips/voyagergx/consistent.c
--- a/arch/sh/cchips/voyagergx/consistent.c	2004-12-24 13:37:19 -08:00
+++ b/arch/sh/cchips/voyagergx/consistent.c	2004-12-24 13:37:19 -08:00
@@ -49,13 +49,13 @@
 	if (!dev || dev->bus != &sh_bus_types[SH_BUS_VIRT] ||
 		   (dev->bus == &sh_bus_types[SH_BUS_VIRT] &&
 		    shdev->dev_id != SH_DEV_ID_USB_OHCI))
-		return consistent_alloc(flag, size, handle);
+		return NULL;
 
 	start = OHCI_SRAM_START + OHCI_HCCA_SIZE;
 
 	entry = kmalloc(sizeof(struct voya_alloc_entry), GFP_ATOMIC);
 	if (!entry)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	entry->len = (size + 15) & ~15;
 
@@ -91,11 +91,11 @@
 	kfree(entry);
 	spin_unlock_irqrestore(&voya_list_lock, flags);
 
-	return NULL;
+	return ERR_PTR(-EINVAL);
 }
 
-void voyagergx_consistent_free(struct device *dev, size_t size,
-			       void *vaddr, dma_addr_t handle)
+int voyagergx_consistent_free(struct device *dev, size_t size,
+			      void *vaddr, dma_addr_t handle)
 {
 	struct voya_alloc_entry *entry;
 	struct sh_dev *shdev = to_sh_dev(dev);
@@ -103,10 +103,8 @@
 
 	if (!dev || dev->bus != &sh_bus_types[SH_BUS_VIRT] ||
 		   (dev->bus == &sh_bus_types[SH_BUS_VIRT] &&
-		    shdev->dev_id != SH_DEV_ID_USB_OHCI)) {
-		consistent_free(vaddr, size);
-		return;
-	}
+		    shdev->dev_id != SH_DEV_ID_USB_OHCI))
+		return -EINVAL;
 
 	spin_lock_irqsave(&voya_list_lock, flags);
 	list_for_each_entry(entry, &voya_alloc_list, list) {
@@ -119,6 +117,8 @@
 		break;
 	}
 	spin_unlock_irqrestore(&voya_list_lock, flags);
+
+	return 0;
 }
 
 EXPORT_SYMBOL(voyagergx_consistent_alloc);
diff -Nru a/arch/sh/configs/microdev_defconfig b/arch/sh/configs/microdev_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/configs/microdev_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,680 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_SUPERH=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+# CONFIG_SYSVIPC is not set
+# CONFIG_POSIX_MQUEUE is not set
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_HOTPLUG=y
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# System type
+#
+# CONFIG_SH_SOLUTION_ENGINE is not set
+# CONFIG_SH_7751_SOLUTION_ENGINE is not set
+# CONFIG_SH_7300_SOLUTION_ENGINE is not set
+# CONFIG_SH_73180_SOLUTION_ENGINE is not set
+# CONFIG_SH_7751_SYSTEMH is not set
+# CONFIG_SH_STB1_HARP is not set
+# CONFIG_SH_STB1_OVERDRIVE is not set
+# CONFIG_SH_HP620 is not set
+# CONFIG_SH_HP680 is not set
+# CONFIG_SH_HP690 is not set
+# CONFIG_SH_CQREEK is not set
+# CONFIG_SH_DMIDA is not set
+# CONFIG_SH_EC3104 is not set
+# CONFIG_SH_SATURN is not set
+# CONFIG_SH_DREAMCAST is not set
+# CONFIG_SH_CAT68701 is not set
+# CONFIG_SH_BIGSUR is not set
+# CONFIG_SH_SH2000 is not set
+# CONFIG_SH_ADX is not set
+# CONFIG_SH_MPC1211 is not set
+# CONFIG_SH_SH03 is not set
+# CONFIG_SH_SECUREEDGE5410 is not set
+# CONFIG_SH_HS7751RVOIP is not set
+# CONFIG_SH_RTS7751R2D is not set
+# CONFIG_SH_EDOSK7705 is not set
+CONFIG_SH_SH4202_MICRODEV=y
+# CONFIG_SH_UNKNOWN is not set
+# CONFIG_CPU_SH2 is not set
+# CONFIG_CPU_SH3 is not set
+CONFIG_CPU_SH4=y
+# CONFIG_CPU_SUBTYPE_SH7604 is not set
+# CONFIG_CPU_SUBTYPE_SH7300 is not set
+# CONFIG_CPU_SUBTYPE_SH7705 is not set
+# CONFIG_CPU_SUBTYPE_SH7707 is not set
+# CONFIG_CPU_SUBTYPE_SH7708 is not set
+# CONFIG_CPU_SUBTYPE_SH7709 is not set
+# CONFIG_CPU_SUBTYPE_SH7750 is not set
+# CONFIG_CPU_SUBTYPE_SH7751 is not set
+# CONFIG_CPU_SUBTYPE_SH7760 is not set
+# CONFIG_CPU_SUBTYPE_SH73180 is not set
+# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
+# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
+CONFIG_CPU_SUBTYPE_SH4_202=y
+CONFIG_MMU=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttySC0,115200"
+CONFIG_MEMORY_START=0x08000000
+CONFIG_MEMORY_SIZE=0x04000000
+CONFIG_MEMORY_SET=y
+# CONFIG_MEMORY_OVERRIDE is not set
+CONFIG_SH_RTC=y
+CONFIG_SH_FPU=y
+CONFIG_ZERO_PAGE_OFFSET=0x00001000
+CONFIG_BOOT_LINK_OFFSET=0x00800000
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_PREEMPT=y
+# CONFIG_UBC_WAKEUP is not set
+# CONFIG_SH_WRITETHROUGH is not set
+# CONFIG_SH_OCRAM is not set
+# CONFIG_SH_STORE_QUEUES is not set
+# CONFIG_SMP is not set
+CONFIG_SH_PCLK_CALC=y
+CONFIG_SH_PCLK_FREQ=65986048
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+
+#
+# DMA support
+#
+CONFIG_SH_DMA=y
+CONFIG_NR_ONCHIP_DMA_CHANNELS=4
+# CONFIG_NR_DMA_CHANNELS_BOOL is not set
+
+#
+# Companion Chips
+#
+# CONFIG_HD6446X_SERIES is not set
+CONFIG_HEARTBEAT=y
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_ISA=y
+# CONFIG_PCI is not set
+
+#
+# PCMCIA/CardBus support
+#
+# CONFIG_PCMCIA is not set
+CONFIG_PCMCIA_PROBE=y
+
+#
+# PCI Hotplug Support
+#
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_FLAT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# SH initrd options
+#
+# CONFIG_EMBEDDED_RAMDISK is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+# CONFIG_PNP is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_LBD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=1
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECD=y
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+# CONFIG_IDE_TASKFILE_IO is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+CONFIG_IDE_SH=y
+# CONFIG_IDE_ARM is not set
+# CONFIG_IDE_CHIPSETS is not set
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_PACKET is not set
+# CONFIG_NETLINK_DEV is not set
+# CONFIG_UNIX is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# 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_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_STNIC is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+CONFIG_SMC91X=y
+# 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)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+# CONFIG_INPUT is not set
+
+#
+# Userland interfaces
+#
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+# CONFIG_SERIO is not set
+# CONFIG_SERIO_I8042 is not set
+
+#
+# Input Device Drivers
+#
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_QIC02_TAPE is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_RTC=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+# CONFIG_MSDOS_FS is not set
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS_XATTR=y
+# CONFIG_DEVPTS_FS_SECURITY is not set
+CONFIG_TMPFS=y
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+# CONFIG_NFSD is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_SH_STANDARD_BIOS is not set
+# CONFIG_EARLY_SCIF_CONSOLE is not set
+# CONFIG_KGDB is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
diff -Nru a/arch/sh/configs/rts7751r2d_defconfig b/arch/sh/configs/rts7751r2d_defconfig
--- a/arch/sh/configs/rts7751r2d_defconfig	2004-12-24 13:37:02 -08:00
+++ b/arch/sh/configs/rts7751r2d_defconfig	2004-12-24 13:37:02 -08:00
@@ -18,9 +18,12 @@
 #
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=14
+CONFIG_HOTPLUG=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
@@ -29,6 +32,8 @@
 CONFIG_IOSCHED_NOOP=y
 CONFIG_IOSCHED_AS=y
 CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 
 #
 # Loadable module support
@@ -44,6 +49,7 @@
 #
 # CONFIG_SH_SOLUTION_ENGINE is not set
 # CONFIG_SH_7751_SOLUTION_ENGINE is not set
+# CONFIG_SH_7300_SOLUTION_ENGINE is not set
 # CONFIG_SH_7751_SYSTEMH is not set
 # CONFIG_SH_STB1_HARP is not set
 # CONFIG_SH_STB1_OVERDRIVE is not set
@@ -61,6 +67,7 @@
 # CONFIG_SH_ADX is not set
 # CONFIG_SH_MPC1211 is not set
 # CONFIG_SH_SECUREEDGE5410 is not set
+# CONFIG_SH_HS7751RVOIP is not set
 CONFIG_SH_RTS7751R2D=y
 # CONFIG_SH_UNKNOWN is not set
 # CONFIG_CPU_SH2 is not set
@@ -68,6 +75,7 @@
 CONFIG_CPU_SH4=y
 # CONFIG_CPU_SUBTYPE_SH7604 is not set
 # CONFIG_CPU_SUBTYPE_SH7300 is not set
+# CONFIG_CPU_SUBTYPE_SH7705 is not set
 # CONFIG_CPU_SUBTYPE_SH7707 is not set
 # CONFIG_CPU_SUBTYPE_SH7708 is not set
 # CONFIG_CPU_SUBTYPE_SH7709 is not set
@@ -75,6 +83,7 @@
 CONFIG_CPU_SUBTYPE_SH7751=y
 # CONFIG_CPU_SUBTYPE_SH7760 is not set
 # CONFIG_CPU_SUBTYPE_ST40STB1 is not set
+# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
 CONFIG_MMU=y
 CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="mem=64M console=ttySC0,115200 root=/dev/hda1"
@@ -92,14 +101,29 @@
 # CONFIG_SH_OCRAM is not set
 # CONFIG_SH_STORE_QUEUES is not set
 # CONFIG_SMP is not set
-CONFIG_VOYAGERGX=y
 CONFIG_RTS7751R2D_REV11=y
+CONFIG_SH_PCLK_CALC=y
 CONFIG_SH_PCLK_FREQ=60000000
+
+#
+# CPU Frequency scaling
+#
 # CONFIG_CPU_FREQ is not set
+
+#
+# DMA support
+#
 CONFIG_SH_DMA=y
 CONFIG_NR_ONCHIP_DMA_CHANNELS=8
 # CONFIG_NR_DMA_CHANNELS_BOOL is not set
-# CONFIG_DMA_PAGE_OPS is not set
+
+#
+# Companion Chips
+#
+CONFIG_VOYAGERGX=y
+# CONFIG_HD6446X_SERIES is not set
+CONFIG_HEARTBEAT=y
+CONFIG_RTC_9701JE=y
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
@@ -109,15 +133,14 @@
 CONFIG_SH_PCIDMA_NONCOHERENT=y
 CONFIG_PCI_AUTO=y
 CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
-CONFIG_PCI_DMA=y
 # CONFIG_PCI_LEGACY_PROC is not set
 CONFIG_PCI_NAMES=y
-CONFIG_HOTPLUG=y
 
 #
 # PCMCIA/CardBus support
 #
 CONFIG_PCMCIA=m
+# CONFIG_PCMCIA_DEBUG is not set
 CONFIG_YENTA=m
 CONFIG_CARDBUS=y
 # CONFIG_I82092 is not set
@@ -131,6 +154,8 @@
 CONFIG_HOTPLUG_PCI=y
 # CONFIG_HOTPLUG_PCI_FAKE is not set
 # CONFIG_HOTPLUG_PCI_CPCI is not set
+# CONFIG_HOTPLUG_PCI_PCIE is not set
+# CONFIG_HOTPLUG_PCI_SHPC is not set
 
 #
 # Executable file formats
@@ -140,6 +165,10 @@
 # CONFIG_BINFMT_MISC is not set
 
 #
+# Device Drivers
+#
+
+#
 # Generic Driver Options
 #
 # CONFIG_FW_LOADER is not set
@@ -155,6 +184,11 @@
 # CONFIG_PARPORT is not set
 
 #
+# Plug and Play support
+#
+# CONFIG_PNP is not set
+
+#
 # Block devices
 #
 # CONFIG_BLK_DEV_FD is not set
@@ -165,6 +199,7 @@
 # CONFIG_BLK_DEV_UMEM is not set
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_CARMEL is not set
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
@@ -174,6 +209,7 @@
 # ATA/ATAPI/MFM/RLL support
 #
 CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=y
 
 #
@@ -181,7 +217,6 @@
 #
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_IDEDISK_STROKE is not set
 CONFIG_BLK_DEV_IDECS=m
 # CONFIG_BLK_DEV_IDECD is not set
 # CONFIG_BLK_DEV_IDETAPE is not set
@@ -192,11 +227,13 @@
 #
 # IDE chipset support/bugfixes
 #
+CONFIG_IDE_GENERIC=y
 # CONFIG_BLK_DEV_IDEPCI is not set
+CONFIG_IDE_SH=y
+# CONFIG_IDE_ARM is not set
 # CONFIG_IDE_CHIPSETS is not set
 # CONFIG_BLK_DEV_IDEDMA is not set
 # CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_HD is not set
 
 #
@@ -215,11 +252,20 @@
 # CONFIG_MD is not set
 
 #
-# IEEE 1394 (FireWire) support (EXPERIMENTAL)
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
 #
 # CONFIG_IEEE1394 is not set
 
 #
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
 # Networking support
 #
 CONFIG_NET=y
@@ -239,23 +285,21 @@
 # CONFIG_NET_IPIP is not set
 # CONFIG_NET_IPGRE is not set
 # CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
 # CONFIG_SYN_COOKIES is not set
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
 # CONFIG_IPV6 is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
 # CONFIG_NETFILTER is not set
 
 #
 # SCTP Configuration (EXPERIMENTAL)
 #
-CONFIG_IPV6_SCTP__=y
 # CONFIG_IP_SCTP is not set
 # CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
 # CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
 # CONFIG_LLC2 is not set
 # CONFIG_IPX is not set
 # CONFIG_ATALK is not set
@@ -264,6 +308,7 @@
 # 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
 
 #
@@ -275,16 +320,21 @@
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
 
 #
 # 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)
@@ -325,6 +375,7 @@
 # CONFIG_AC3200 is not set
 # CONFIG_APRICOT is not set
 # CONFIG_B44 is not set
+# CONFIG_FORCEDETH is not set
 # CONFIG_CS89x0 is not set
 # CONFIG_DGRS is not set
 # CONFIG_EEPRO100 is not set
@@ -355,7 +406,6 @@
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_TIGON3 is not set
 
@@ -363,10 +413,12 @@
 # Ethernet (10000 Mbit)
 #
 # CONFIG_IXGB is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
+# CONFIG_S2IO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
 
 #
 # Wireless LAN (non-hamradio)
@@ -395,27 +447,20 @@
 # CONFIG_PLX_HERMES is not set
 # CONFIG_TMD_HERMES is not set
 # CONFIG_PCI_HERMES is not set
+# CONFIG_ATMEL is not set
 
 #
 # Wireless 802.11b Pcmcia/Cardbus cards support
 #
 CONFIG_PCMCIA_HERMES=m
 # CONFIG_AIRO_CS is not set
-# CONFIG_PCMCIA_ATMEL is not set
 # CONFIG_PCMCIA_WL3501 is not set
-CONFIG_NET_WIRELESS=y
 
 #
-# Token Ring devices
+# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
 #
-# CONFIG_TR is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
+# CONFIG_PRISM54 is not set
+CONFIG_NET_WIRELESS=y
 
 #
 # PCMCIA network device support
@@ -423,24 +468,20 @@
 # CONFIG_NET_PCMCIA is not set
 
 #
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Bluetooth support
+# Wan interfaces
 #
-# CONFIG_BT is not set
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # ISDN subsystem
 #
-# CONFIG_ISDN_BOOL is not set
+# CONFIG_ISDN is not set
 
 #
 # Telephony Support
@@ -472,28 +513,7 @@
 # Character devices
 #
 # CONFIG_VT is not set
-# CONFIG_SERIAL is not set
-CONFIG_SH_SCI=y
-CONFIG_SERIAL_CONSOLE=y
-CONFIG_RTC_9701JE=y
-
-#
-# Unix 98 PTY support
-#
-# CONFIG_UNIX98_PTYS is not set
-CONFIG_HEARTBEAT=y
-# CONFIG_PSMOUSE is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_RTC is not set
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
 
 #
 # Serial drivers
@@ -504,142 +524,47 @@
 # Non-8250 serial port support
 #
 # CONFIG_SERIAL_SH_SCI is not set
+# CONFIG_UNIX98_PTYS is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_QIC02_TAPE is not set
 
 #
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Algorithms
-#
-
-#
-# I2C Hardware Bus support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-CONFIG_MINIX_FS=y
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
+# IPMI
 #
-CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
-CONFIG_VFAT_FS=y
-# CONFIG_NTFS_FS is not set
+# CONFIG_IPMI_HANDLER is not set
 
 #
-# Pseudo filesystems
+# Watchdog Cards
 #
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_TMPFS is not set
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
+# CONFIG_WATCHDOG is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
 
 #
-# Miscellaneous filesystems
+# Ftape, the floppy tape device driver
 #
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
 
 #
-# Network File Systems
+# PCMCIA character devices
 #
-# CONFIG_NFS_FS is not set
-# CONFIG_NFSD is not set
-# CONFIG_EXPORTFS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
+# CONFIG_SYNCLINK_CS is not set
+# CONFIG_RAW_DRIVER is not set
 
 #
-# Partition Types
+# I2C support
 #
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-CONFIG_NLS=y
+# CONFIG_I2C is not set
 
 #
-# Native Language Support
+# Misc devices
 #
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-CONFIG_NLS_CODEPAGE_932=y
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
 
 #
 # Multimedia devices
@@ -665,14 +590,21 @@
 # Advanced Linux Sound Architecture
 #
 CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
 # CONFIG_SND_SEQUENCER is not set
-# CONFIG_SND_OSSEMUL is not set
+# CONFIG_SND_MIXER_OSS is not set
+# CONFIG_SND_PCM_OSS is not set
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
 
 #
 # Generic devices
 #
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
 # CONFIG_SND_DUMMY is not set
 # CONFIG_SND_MTPAV is not set
 # CONFIG_SND_SERIAL_U16550 is not set
@@ -707,12 +639,19 @@
 #
 # PCI devices
 #
+CONFIG_SND_AC97_CODEC=m
 # CONFIG_SND_ALI5451 is not set
+# CONFIG_SND_ATIIXP is not set
+# CONFIG_SND_AU8810 is not set
+# CONFIG_SND_AU8820 is not set
+# CONFIG_SND_AU8830 is not set
 # CONFIG_SND_AZT3328 is not set
+# CONFIG_SND_BT87X is not set
 # CONFIG_SND_CS46XX is not set
 # CONFIG_SND_CS4281 is not set
 # CONFIG_SND_EMU10K1 is not set
 # CONFIG_SND_KORG1212 is not set
+# CONFIG_SND_MIXART is not set
 # CONFIG_SND_NM256 is not set
 # CONFIG_SND_RME32 is not set
 # CONFIG_SND_RME96 is not set
@@ -731,6 +670,7 @@
 # CONFIG_SND_ICE1712 is not set
 # CONFIG_SND_ICE1724 is not set
 # CONFIG_SND_INTEL8X0 is not set
+# CONFIG_SND_INTEL8X0M is not set
 # CONFIG_SND_SONICVIBES is not set
 # CONFIG_SND_VIA82XX is not set
 # CONFIG_SND_VX222 is not set
@@ -740,6 +680,7 @@
 #
 # CONFIG_SND_VXPOCKET is not set
 # CONFIG_SND_VXP440 is not set
+# CONFIG_SND_PDAUDIOCF is not set
 
 #
 # Open Sound System
@@ -747,10 +688,6 @@
 CONFIG_SOUND_PRIME=m
 # CONFIG_SOUND_BT878 is not set
 CONFIG_SOUND_CMPCI=m
-# CONFIG_SOUND_CMPCI_FM is not set
-# CONFIG_SOUND_CMPCI_MIDI is not set
-# CONFIG_SOUND_CMPCI_JOYSTICK is not set
-# CONFIG_SOUND_CMPCI_CM8738 is not set
 # CONFIG_SOUND_EMU10K1 is not set
 # CONFIG_SOUND_FUSION is not set
 # CONFIG_SOUND_CS4281 is not set
@@ -776,19 +713,146 @@
 # USB support
 #
 # CONFIG_USB is not set
+
+#
+# USB Gadget Support
+#
 # CONFIG_USB_GADGET is not set
 
 #
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_TMPFS is not set
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_EXPORTFS is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+CONFIG_NLS_CODEPAGE_932=y
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
 # Profiling support
 #
-# CONFIG_PROFILING is not set
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y
 
 #
 # Kernel hacking
 #
 # CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_INFO is not set
 # CONFIG_SH_STANDARD_BIOS is not set
+# CONFIG_EARLY_SCIF_CONSOLE is not set
 # CONFIG_KGDB is not set
 # CONFIG_FRAME_POINTER is not set
 
@@ -806,3 +870,4 @@
 # Library routines
 #
 CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
diff -Nru a/arch/sh/configs/se73180_defconfig b/arch/sh/configs/se73180_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/configs/se73180_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,430 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_SUPERH=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_STANDALONE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+# CONFIG_SYSVIPC is not set
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+# CONFIG_KALLSYMS is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+# CONFIG_MODULE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_KMOD is not set
+
+#
+# System type
+#
+# CONFIG_SH_SOLUTION_ENGINE is not set
+# CONFIG_SH_7751_SOLUTION_ENGINE is not set
+# CONFIG_SH_7300_SOLUTION_ENGINE is not set
+CONFIG_SH_73180_SOLUTION_ENGINE=y
+# CONFIG_SH_7751_SYSTEMH is not set
+# CONFIG_SH_STB1_HARP is not set
+# CONFIG_SH_STB1_OVERDRIVE is not set
+# CONFIG_SH_HP620 is not set
+# CONFIG_SH_HP680 is not set
+# CONFIG_SH_HP690 is not set
+# CONFIG_SH_CQREEK is not set
+# CONFIG_SH_DMIDA is not set
+# CONFIG_SH_EC3104 is not set
+# CONFIG_SH_SATURN is not set
+# CONFIG_SH_DREAMCAST is not set
+# CONFIG_SH_CAT68701 is not set
+# CONFIG_SH_BIGSUR is not set
+# CONFIG_SH_SH2000 is not set
+# CONFIG_SH_ADX is not set
+# CONFIG_SH_MPC1211 is not set
+# CONFIG_SH_SECUREEDGE5410 is not set
+# CONFIG_SH_HS7751RVOIP is not set
+# CONFIG_SH_RTS7751R2D is not set
+# CONFIG_SH_UNKNOWN is not set
+# CONFIG_CPU_SH2 is not set
+# CONFIG_CPU_SH3 is not set
+CONFIG_CPU_SH4=y
+# CONFIG_CPU_SUBTYPE_SH7604 is not set
+# CONFIG_CPU_SUBTYPE_SH7300 is not set
+# CONFIG_CPU_SUBTYPE_SH7705 is not set
+# CONFIG_CPU_SUBTYPE_SH7707 is not set
+# CONFIG_CPU_SUBTYPE_SH7708 is not set
+# CONFIG_CPU_SUBTYPE_SH7709 is not set
+# CONFIG_CPU_SUBTYPE_SH7750 is not set
+# CONFIG_CPU_SUBTYPE_SH7751 is not set
+# CONFIG_CPU_SUBTYPE_SH7760 is not set
+CONFIG_CPU_SUBTYPE_SH73180=y
+# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
+# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
+CONFIG_MMU=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttySC0,38400 root=/dev/ram"
+CONFIG_MEMORY_START=0x0c000000
+CONFIG_MEMORY_SIZE=0x02000000
+# CONFIG_MEMORY_OVERRIDE is not set
+# CONFIG_SH_FPU is not set
+CONFIG_ZERO_PAGE_OFFSET=0x00010000
+CONFIG_BOOT_LINK_OFFSET=0x00800000
+CONFIG_CPU_LITTLE_ENDIAN=y
+# CONFIG_PREEMPT is not set
+# CONFIG_UBC_WAKEUP is not set
+# CONFIG_SH_WRITETHROUGH is not set
+# CONFIG_SH_OCRAM is not set
+# CONFIG_SH_STORE_QUEUES is not set
+# CONFIG_SMP is not set
+# CONFIG_SH_PCLK_CALC is not set
+CONFIG_SH_PCLK_FREQ=27000000
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+
+#
+# DMA support
+#
+# CONFIG_SH_DMA is not set
+
+#
+# Companion Chips
+#
+# CONFIG_HD6446X_SERIES is not set
+CONFIG_HEARTBEAT=y
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+# CONFIG_PCI is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_FLAT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# SH initrd options
+#
+CONFIG_EMBEDDED_RAMDISK=y
+CONFIG_EMBEDDED_RAMDISK_IMAGE="ramdisk.gz"
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_LBD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+# CONFIG_NET is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+# CONFIG_INPUT is not set
+
+#
+# Userland interfaces
+#
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+# CONFIG_SERIO is not set
+# CONFIG_SERIO_I8042 is not set
+
+#
+# Input Device Drivers
+#
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_UNIX98_PTYS is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_QIC02_TAPE is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+# CONFIG_SH_WDT is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_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
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_FAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+# CONFIG_SYSFS is not set
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_TMPFS=y
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+# CONFIG_NLS is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_INFO is not set
+CONFIG_SH_STANDARD_BIOS=y
+# CONFIG_EARLY_SCIF_CONSOLE is not set
+# CONFIG_EARLY_PRINTK is not set
+# CONFIG_KGDB is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
diff -Nru a/arch/sh/configs/se7705_defconfig b/arch/sh/configs/se7705_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/configs/se7705_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,645 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_SUPERH=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+# CONFIG_SWAP is not set
+# CONFIG_SYSVIPC is not set
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+# CONFIG_KALLSYMS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+# CONFIG_IOSCHED_NOOP is not set
+CONFIG_IOSCHED_AS=y
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+# CONFIG_MODULE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+CONFIG_KMOD=y
+
+#
+# System type
+#
+CONFIG_SH_SOLUTION_ENGINE=y
+# CONFIG_SH_7751_SOLUTION_ENGINE is not set
+# CONFIG_SH_7300_SOLUTION_ENGINE is not set
+# CONFIG_SH_73180_SOLUTION_ENGINE is not set
+# CONFIG_SH_7751_SYSTEMH is not set
+# CONFIG_SH_STB1_HARP is not set
+# CONFIG_SH_STB1_OVERDRIVE is not set
+# CONFIG_SH_HP620 is not set
+# CONFIG_SH_HP680 is not set
+# CONFIG_SH_HP690 is not set
+# CONFIG_SH_CQREEK is not set
+# CONFIG_SH_DMIDA is not set
+# CONFIG_SH_EC3104 is not set
+# CONFIG_SH_SATURN is not set
+# CONFIG_SH_DREAMCAST is not set
+# CONFIG_SH_CAT68701 is not set
+# CONFIG_SH_BIGSUR is not set
+# CONFIG_SH_SH2000 is not set
+# CONFIG_SH_ADX is not set
+# CONFIG_SH_MPC1211 is not set
+# CONFIG_SH_SECUREEDGE5410 is not set
+# CONFIG_SH_HS7751RVOIP is not set
+# CONFIG_SH_RTS7751R2D is not set
+# CONFIG_SH_EDOSK7705 is not set
+# CONFIG_SH_SH4202_MICRODEV is not set
+# CONFIG_SH_UNKNOWN is not set
+# CONFIG_CPU_SH2 is not set
+CONFIG_CPU_SH3=y
+# CONFIG_CPU_SH4 is not set
+# CONFIG_CPU_SUBTYPE_SH7604 is not set
+# CONFIG_CPU_SUBTYPE_SH7300 is not set
+CONFIG_CPU_SUBTYPE_SH7705=y
+# CONFIG_CPU_SUBTYPE_SH7707 is not set
+# CONFIG_CPU_SUBTYPE_SH7708 is not set
+# CONFIG_CPU_SUBTYPE_SH7709 is not set
+# CONFIG_CPU_SUBTYPE_SH7750 is not set
+# CONFIG_CPU_SUBTYPE_SH7751 is not set
+# CONFIG_CPU_SUBTYPE_SH7760 is not set
+# CONFIG_CPU_SUBTYPE_SH73180 is not set
+# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
+# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
+# CONFIG_CPU_SUBTYPE_SH4_202 is not set
+CONFIG_SH7705_CACHE_32KB=y
+CONFIG_MMU=y
+# CONFIG_CMDLINE_BOOL is not set
+CONFIG_MEMORY_START=0x0c000000
+CONFIG_MEMORY_SIZE=0x02000000
+CONFIG_MEMORY_SET=y
+# CONFIG_MEMORY_OVERRIDE is not set
+# CONFIG_CF_ENABLER is not set
+CONFIG_SH_RTC=y
+# CONFIG_SH_DSP is not set
+# CONFIG_SH_ADC is not set
+CONFIG_ZERO_PAGE_OFFSET=0x00001000
+CONFIG_BOOT_LINK_OFFSET=0x00800000
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_PREEMPT=y
+# CONFIG_UBC_WAKEUP is not set
+# CONFIG_SH_WRITETHROUGH is not set
+# CONFIG_SH_OCRAM is not set
+# CONFIG_SMP is not set
+CONFIG_SH_PCLK_CALC=y
+CONFIG_SH_PCLK_FREQ=33333333
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+
+#
+# DMA support
+#
+# CONFIG_SH_DMA is not set
+
+#
+# Companion Chips
+#
+# CONFIG_HD6446X_SERIES is not set
+CONFIG_HEARTBEAT=y
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+# CONFIG_PCI is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_FLAT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# SH initrd options
+#
+# CONFIG_EMBEDDED_RAMDISK is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_CONCAT is not set
+# CONFIG_MTD_REDBOOT_PARTS is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_CFI_AMDSTD_RETRY=0
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_SOLUTIONENGINE=y
+CONFIG_MTD_SUPERH_RESERVE=0x300000
+# CONFIG_MTD_MPC1211 is not set
+# CONFIG_MTD_RTS7751R2D is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLKMTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD 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=8192
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_LBD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_MII is not set
+CONFIG_STNIC=y
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=y
+# CONFIG_PPP_MULTILINK is not set
+# CONFIG_PPP_FILTER is not set
+CONFIG_PPP_ASYNC=y
+# CONFIG_PPP_SYNC_TTY is not set
+CONFIG_PPP_DEFLATE=y
+# CONFIG_PPP_BSDCOMP is not set
+# CONFIG_PPPOE is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_CT82C710 is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_QIC02_TAPE is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+# CONFIG_SYSFS is not set
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+# CONFIG_TMPFS is not set
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+# CONFIG_JFFS2_FS_NAND is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+# CONFIG_NFS_V3 is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+# CONFIG_NFSD is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+# CONFIG_NLS is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_SH_STANDARD_BIOS is not set
+# CONFIG_KGDB is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=y
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/sh/configs/se7751_defconfig b/arch/sh/configs/se7751_defconfig
--- a/arch/sh/configs/se7751_defconfig	2004-12-24 13:36:48 -08:00
+++ b/arch/sh/configs/se7751_defconfig	2004-12-24 13:36:48 -08:00
@@ -284,6 +284,7 @@
 # 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
 
 #
diff -Nru a/arch/sh/configs/sh03_defconfig b/arch/sh/configs/sh03_defconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/configs/sh03_defconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,936 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_SUPERH=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+# CONFIG_CLEAN_COMPILE is not set
+CONFIG_BROKEN=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_HOTPLUG=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_OBSOLETE_MODPARM=y
+CONFIG_MODVERSIONS=y
+CONFIG_KMOD=y
+
+#
+# System type
+#
+# CONFIG_SH_SOLUTION_ENGINE is not set
+# CONFIG_SH_7751_SOLUTION_ENGINE is not set
+# CONFIG_SH_7300_SOLUTION_ENGINE is not set
+# CONFIG_SH_73180_SOLUTION_ENGINE is not set
+# CONFIG_SH_7751_SYSTEMH is not set
+# CONFIG_SH_STB1_HARP is not set
+# CONFIG_SH_STB1_OVERDRIVE is not set
+# CONFIG_SH_HP620 is not set
+# CONFIG_SH_HP680 is not set
+# CONFIG_SH_HP690 is not set
+# CONFIG_SH_CQREEK is not set
+# CONFIG_SH_DMIDA is not set
+# CONFIG_SH_EC3104 is not set
+# CONFIG_SH_SATURN is not set
+# CONFIG_SH_DREAMCAST is not set
+# CONFIG_SH_CAT68701 is not set
+# CONFIG_SH_BIGSUR is not set
+# CONFIG_SH_SH2000 is not set
+# CONFIG_SH_ADX is not set
+# CONFIG_SH_MPC1211 is not set
+CONFIG_SH_SH03=y
+# CONFIG_SH_SECUREEDGE5410 is not set
+# CONFIG_SH_HS7751RVOIP is not set
+# CONFIG_SH_RTS7751R2D is not set
+# CONFIG_SH_EDOSK7705 is not set
+# CONFIG_SH_SH4202_MICRODEV is not set
+# CONFIG_SH_UNKNOWN is not set
+# CONFIG_CPU_SH2 is not set
+# CONFIG_CPU_SH3 is not set
+CONFIG_CPU_SH4=y
+# CONFIG_CPU_SUBTYPE_SH7604 is not set
+# CONFIG_CPU_SUBTYPE_SH7300 is not set
+# CONFIG_CPU_SUBTYPE_SH7705 is not set
+# CONFIG_CPU_SUBTYPE_SH7707 is not set
+# CONFIG_CPU_SUBTYPE_SH7708 is not set
+# CONFIG_CPU_SUBTYPE_SH7709 is not set
+# CONFIG_CPU_SUBTYPE_SH7750 is not set
+CONFIG_CPU_SUBTYPE_SH7751=y
+# CONFIG_CPU_SUBTYPE_SH7760 is not set
+# CONFIG_CPU_SUBTYPE_SH73180 is not set
+# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
+# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
+# CONFIG_CPU_SUBTYPE_SH4_202 is not set
+CONFIG_MMU=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttySC1,115200 mem=64M root=/dev/nfs"
+CONFIG_MEMORY_START=0x08000000
+CONFIG_MEMORY_SIZE=0x08000000
+CONFIG_MEMORY_SET=y
+# CONFIG_MEMORY_OVERRIDE is not set
+CONFIG_CF_ENABLER=y
+CONFIG_CF_AREA5=y
+# CONFIG_CF_AREA6 is not set
+CONFIG_CF_BASE_ADDR=0xb4000000
+CONFIG_SH_RTC=y
+CONFIG_SH_FPU=y
+CONFIG_ZERO_PAGE_OFFSET=0x00004000
+CONFIG_BOOT_LINK_OFFSET=0x00800000
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_PREEMPT=y
+# CONFIG_UBC_WAKEUP is not set
+# CONFIG_SH_WRITETHROUGH is not set
+# CONFIG_SH_OCRAM is not set
+# CONFIG_SH_STORE_QUEUES is not set
+# CONFIG_SMP is not set
+CONFIG_SH_PCLK_CALC=y
+CONFIG_SH_PCLK_FREQ=49876504
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+
+#
+# DMA support
+#
+# CONFIG_SH_DMA is not set
+
+#
+# Companion Chips
+#
+# CONFIG_HD6446X_SERIES is not set
+CONFIG_HEARTBEAT=y
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_ISA=y
+CONFIG_PCI=y
+CONFIG_SH_PCIDMA_NONCOHERENT=y
+CONFIG_PCI_AUTO=y
+CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
+CONFIG_PCI_LEGACY_PROC=y
+CONFIG_PCI_NAMES=y
+
+#
+# PCMCIA/CardBus support
+#
+CONFIG_PCMCIA=m
+# CONFIG_PCMCIA_DEBUG is not set
+# CONFIG_YENTA is not set
+# CONFIG_PD6729 is not set
+# CONFIG_I82092 is not set
+# CONFIG_I82365 is not set
+# CONFIG_TCIC is not set
+CONFIG_PCMCIA_PROBE=y
+
+#
+# PCI Hotplug Support
+#
+CONFIG_HOTPLUG_PCI=m
+# CONFIG_HOTPLUG_PCI_FAKE is not set
+# CONFIG_HOTPLUG_PCI_CPCI is not set
+# CONFIG_HOTPLUG_PCI_PCIE is not set
+# CONFIG_HOTPLUG_PCI_SHPC is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_FLAT is not set
+CONFIG_BINFMT_MISC=y
+
+#
+# SH initrd options
+#
+# CONFIG_EMBEDDED_RAMDISK is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+# CONFIG_PNP is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD 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_UMEM is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=y
+# CONFIG_BLK_DEV_SX8 is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_LBD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_IDECD=m
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+# CONFIG_IDE_TASKFILE_IO is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_BLK_DEV_IDEPCI is not set
+CONFIG_IDE_SH=y
+# CONFIG_IDE_ARM is not set
+# CONFIG_IDE_CHIPSETS is not set
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=m
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_3W_9XXX 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_AACRAID is not set
+# CONFIG_SCSI_AIC7XXX is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_AIC79XX is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_SCSI_ADVANSYS is not set
+# CONFIG_SCSI_IN2000 is not set
+# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_SCSI_SATA 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_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_GENERIC_NCR5380_MMIO is not set
+# CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_SYM53C8XX_2 is not set
+# CONFIG_SCSI_IPR 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_QLA2XXX=m
+# CONFIG_SCSI_QLA21XX is not set
+# CONFIG_SCSI_QLA22XX is not set
+# CONFIG_SCSI_QLA2300 is not set
+# CONFIG_SCSI_QLA2322 is not set
+# CONFIG_SCSI_QLA6312 is not set
+# CONFIG_SCSI_QLA6322 is not set
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_DC395x is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# PCMCIA SCSI adapter support
+#
+# CONFIG_PCMCIA_AHA152X is not set
+# CONFIG_PCMCIA_FDOMAIN is not set
+# CONFIG_PCMCIA_NINJA_SCSI is not set
+# CONFIG_PCMCIA_QLOGIC is not set
+# CONFIG_PCMCIA_SYM53C500 is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_STNIC is not set
+# CONFIG_HAPPYMEAL 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
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP 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_AMD8111_ETH is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_AC3200 is not set
+# CONFIG_APRICOT is not set
+# CONFIG_B44 is not set
+# CONFIG_FORCEDETH is not set
+# CONFIG_CS89x0 is not set
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+# CONFIG_E100 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+CONFIG_8139CP=y
+# CONFIG_8139TOO 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_VIA_VELOCITY is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+# CONFIG_SERIO is not set
+# CONFIG_SERIO_I8042 is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=m
+# CONFIG_SERIAL_8250_CS is not set
+CONFIG_SERIAL_8250_NR_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_QIC02_TAPE is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_SH_WDT=m
+
+#
+# ISA-based Watchdog Cards
+#
+# CONFIG_PCWATCHDOG is not set
+# CONFIG_MIXCOMWD is not set
+# CONFIG_WDT is not set
+
+#
+# PCI-based Watchdog Cards
+#
+# CONFIG_PCIPCWATCHDOG is not set
+# CONFIG_WDTPCI is not set
+# CONFIG_RTC is not set
+CONFIG_SH03_RTC=y
+# CONFIG_GEN_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_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+# CONFIG_MDA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+# CONFIG_EXT2_FS_POSIX_ACL is not set
+# CONFIG_EXT2_FS_SECURITY is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+CONFIG_AUTOFS_FS=y
+CONFIG_AUTOFS4_FS=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=m
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_NFSD=y
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V4 is not set
+CONFIG_NFSD_TCP=y
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=y
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_RPCSEC_GSS_KRB5=y
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS 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 is not set
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_EFI_PARTITION is not set
+
+#
+# Native Language Support
+#
+CONFIG_NLS=m
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Profiling support
+#
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=m
+
+#
+# Kernel hacking
+#
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_SH_STANDARD_BIOS=y
+# CONFIG_EARLY_SCIF_CONSOLE is not set
+# CONFIG_EARLY_PRINTK is not set
+# CONFIG_KGDB is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_HMAC=y
+# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=y
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=y
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
diff -Nru a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
--- a/arch/sh/drivers/dma/dma-api.c	2004-12-24 13:37:18 -08:00
+++ b/arch/sh/drivers/dma/dma-api.c	2004-12-24 13:37:18 -08:00
@@ -211,8 +211,9 @@
 
 	INIT_LIST_HEAD(&info->list);
 
-	printk(KERN_INFO "DMA: Registering %s handler (%d channels).\n",
-	       info->name, info->nr_channels);
+	printk(KERN_INFO "DMA: Registering %s handler (%d channel%s).\n",
+	       info->name, info->nr_channels,
+	       info->nr_channels > 1 ? "s" : "");
 
 	BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels);
 
@@ -282,7 +283,6 @@
 EXPORT_SYMBOL(request_dma);
 EXPORT_SYMBOL(free_dma);
 EXPORT_SYMBOL(register_dmac);
-EXPORT_SYMBOL(unregister_dmac);
 EXPORT_SYMBOL(get_dma_residue);
 EXPORT_SYMBOL(get_dma_info);
 EXPORT_SYMBOL(get_dma_channel);
diff -Nru a/arch/sh/drivers/dma/dma-g2.c b/arch/sh/drivers/dma/dma-g2.c
--- a/arch/sh/drivers/dma/dma-g2.c	2004-12-24 13:36:30 -08:00
+++ b/arch/sh/drivers/dma/dma-g2.c	2004-12-24 13:36:30 -08:00
@@ -3,7 +3,7 @@
  *
  * G2 bus DMA support
  *
- * Copyright (C) 2003  Paul Mundt
+ * Copyright (C) 2003, 2004  Paul Mundt
  *
  * 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
@@ -59,104 +59,102 @@
 	.flags		= SA_INTERRUPT,
 };
 
-static int g2_enable_dma(struct dma_info *info)
+static int g2_enable_dma(struct dma_channel *chan)
 {
-	unsigned int chan = info->chan;
+	unsigned int chan_nr = chan->chan;
 
-	g2_dma->channel[chan].chan_enable = 1;
-	g2_dma->channel[chan].xfer_enable = 1;
+	g2_dma->channel[chan_nr].chan_enable = 1;
+	g2_dma->channel[chan_nr].xfer_enable = 1;
 
 	return 0;
 }
 
-static int g2_disable_dma(struct dma_info *info)
+static int g2_disable_dma(struct dma_channel *chan)
 {
-	unsigned int chan = info->chan;
+	unsigned int chan_nr = chan->chan;
 
-	g2_dma->channel[chan].chan_enable = 0;
-	g2_dma->channel[chan].xfer_enable = 0;
+	g2_dma->channel[chan_nr].chan_enable = 0;
+	g2_dma->channel[chan_nr].xfer_enable = 0;
 
 	return 0;
 }
 
-static int g2_xfer_dma(struct dma_info *info)
+static int g2_xfer_dma(struct dma_channel *chan)
 {
-	unsigned int chan = info->chan;
+	unsigned int chan_nr = chan->chan;
 
-	if (info->sar & 31) {
-		printk("g2dma: unaligned source 0x%lx\n", info->sar);
+	if (chan->sar & 31) {
+		printk("g2dma: unaligned source 0x%lx\n", chan->sar);
 		return -EINVAL;
 	}
 
-	if (info->dar & 31) {
-		printk("g2dma: unaligned dest 0x%lx\n", info->dar);
+	if (chan->dar & 31) {
+		printk("g2dma: unaligned dest 0x%lx\n", chan->dar);
 		return -EINVAL;
 	}
 
 	/* Align the count */
-	if (info->count & 31)
-		info->count = (info->count + (32 - 1)) & ~(32 - 1);
+	if (chan->count & 31)
+		chan->count = (chan->count + (32 - 1)) & ~(32 - 1);
 
 	/* Fixup destination */
-	info->dar += 0xa0800000;
+	chan->dar += 0xa0800000;
 
 	/* Fixup direction */
-	info->mode = !info->mode;
+	chan->mode = !chan->mode;
 
-	flush_icache_range((unsigned long)info->sar, info->count);
+	flush_icache_range((unsigned long)chan->sar, chan->count);
 
-	g2_disable_dma(info);
+	g2_disable_dma(chan);
 
-	g2_dma->channel[chan].g2_addr	= info->dar & 0x1fffffe0;
-	g2_dma->channel[chan].root_addr = info->sar & 0x1fffffe0;
-	g2_dma->channel[chan].size	= (info->count & ~31) | 0x80000000;
-	g2_dma->channel[chan].direction = info->mode;
+	g2_dma->channel[chan_nr].g2_addr   = chan->dar & 0x1fffffe0;
+	g2_dma->channel[chan_nr].root_addr = chan->sar & 0x1fffffe0;
+	g2_dma->channel[chan_nr].size	   = (chan->count & ~31) | 0x80000000;
+	g2_dma->channel[chan_nr].direction = chan->mode;
 
 	/*
 	 * bit 0 - ???
 	 * bit 1 - if set, generate a hardware event on transfer completion
 	 * bit 2 - ??? something to do with suspend?
 	 */
-	g2_dma->channel[chan].ctrl	= 5; /* ?? */
+	g2_dma->channel[chan_nr].ctrl	= 5; /* ?? */
+
+	g2_enable_dma(chan);
 
-	g2_enable_dma(info);
-	
 	/* debug cruft */
 	pr_debug("count, sar, dar, mode, ctrl, chan, xfer: %ld, 0x%08lx, "
 		 "0x%08lx, %ld, %ld, %ld, %ld\n",
-		 g2_dma->channel[chan].size,
-		 g2_dma->channel[chan].root_addr,
-		 g2_dma->channel[chan].g2_addr,
-		 g2_dma->channel[chan].direction,
-		 g2_dma->channel[chan].ctrl,
-		 g2_dma->channel[chan].chan_enable,
-		 g2_dma->channel[chan].xfer_enable);
+		 g2_dma->channel[chan_nr].size,
+		 g2_dma->channel[chan_nr].root_addr,
+		 g2_dma->channel[chan_nr].g2_addr,
+		 g2_dma->channel[chan_nr].direction,
+		 g2_dma->channel[chan_nr].ctrl,
+		 g2_dma->channel[chan_nr].chan_enable,
+		 g2_dma->channel[chan_nr].xfer_enable);
 
 	return 0;
 }
 
 static struct dma_ops g2_dma_ops = {
-	.name		= "G2 DMA",
 	.xfer		= g2_xfer_dma,
 };
 
+static struct dma_info g2_dma_info = {
+	.name		= "G2 DMA",
+	.nr_channels	= 4,
+	.ops		= &g2_dma_ops,
+	.flags		= DMAC_CHANNELS_TEI_CAPABLE,
+};
+
 static int __init g2_dma_init(void)
 {
-	int i, base;
-
 	setup_irq(HW_EVENT_G2_DMA, &g2_dma_irq);
 
 	/* Magic */
 	g2_dma->wait_state	= 27;
 	g2_dma->magic		= 0x4659404f;
 
-	/* G2 channels come after on-chip and pvr2 */
-	base = ONCHIP_NR_DMA_CHANNELS + PVR2_NR_DMA_CHANNELS;
-
-	for (i = 0; i < G2_NR_DMA_CHANNELS; i++)
-		dma_info[base + i].ops = &g2_dma_ops;
-	
-	return register_dmac(&g2_dma_ops);
+	return register_dmac(&g2_dma_info);
 }
 
 static void __exit g2_dma_exit(void)
diff -Nru a/arch/sh/drivers/dma/dma-pvr2.c b/arch/sh/drivers/dma/dma-pvr2.c
--- a/arch/sh/drivers/dma/dma-pvr2.c	2004-12-24 13:36:48 -08:00
+++ b/arch/sh/drivers/dma/dma-pvr2.c	2004-12-24 13:36:48 -08:00
@@ -3,7 +3,7 @@
  *
  * NEC PowerVR 2 (Dreamcast) DMA support
  *
- * Copyright (C) 2003  Paul Mundt
+ * Copyright (C) 2003, 2004  Paul Mundt
  *
  * 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
@@ -38,7 +38,7 @@
 	return IRQ_HANDLED;
 }
 
-static int pvr2_request_dma(struct dma_info *info)
+static int pvr2_request_dma(struct dma_channel *chan)
 {
 	if (ctrl_inl(PVR2_DMA_MODE) != 0)
 		return -EBUSY;
@@ -48,21 +48,21 @@
 	return 0;
 }
 
-static int pvr2_get_dma_residue(struct dma_info *info)
+static int pvr2_get_dma_residue(struct dma_channel *chan)
 {
 	return xfer_complete == 0;
 }
 
-static int pvr2_xfer_dma(struct dma_info *info)
+static int pvr2_xfer_dma(struct dma_channel *chan)
 {
-	if (info->sar || !info->dar)
+	if (chan->sar || !chan->dar)
 		return -EINVAL;
 
 	xfer_complete = 0;
 
-	ctrl_outl(info->dar, PVR2_DMA_ADDR);
-	ctrl_outl(info->count, PVR2_DMA_COUNT);
-	ctrl_outl(info->mode & DMA_MODE_MASK, PVR2_DMA_MODE);
+	ctrl_outl(chan->dar, PVR2_DMA_ADDR);
+	ctrl_outl(chan->count, PVR2_DMA_COUNT);
+	ctrl_outl(chan->mode & DMA_MODE_MASK, PVR2_DMA_MODE);
 
 	return 0;
 }
@@ -74,26 +74,24 @@
 };
 
 static struct dma_ops pvr2_dma_ops = {
-	.name		= "PowerVR 2 DMA",
 	.request	= pvr2_request_dma,
 	.get_residue	= pvr2_get_dma_residue,
 	.xfer		= pvr2_xfer_dma,
 };
 
+static struct dma_info pvr2_dma_info = {
+	.name		= "PowerVR 2 DMA",
+	.nr_channels	= 1,
+	.ops		= &pvr2_dma_ops,
+	.flags		= DMAC_CHANNELS_TEI_CAPABLE,
+};
+
 static int __init pvr2_dma_init(void)
 {
-	int i, base;
-
 	setup_irq(HW_EVENT_PVR2_DMA, &pvr2_dma_irq);
 	request_dma(PVR2_CASCADE_CHAN, "pvr2 cascade");
 
-	/* PVR2 cascade comes after on-chip DMAC */
-	base = ONCHIP_NR_DMA_CHANNELS;
-
-	for (i = 0; i < PVR2_NR_DMA_CHANNELS; i++)
-		dma_info[base + i].ops = &pvr2_dma_ops;
-
-	return register_dmac(&pvr2_dma_ops);
+	return register_dmac(&pvr2_dma_info);
 }
 
 static void __exit pvr2_dma_exit(void)
diff -Nru a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
--- a/arch/sh/drivers/pci/Makefile	2004-12-24 13:36:48 -08:00
+++ b/arch/sh/drivers/pci/Makefile	2004-12-24 13:36:48 -08:00
@@ -13,4 +13,4 @@
 obj-$(CONFIG_SH_SECUREEDGE5410)		+= ops-snapgear.o
 obj-$(CONFIG_SH_BIGSUR)			+= ops-bigsur.o
 obj-$(CONFIG_SH_RTS7751R2D)		+= ops-rts7751r2d.o fixups-rts7751r2d.o
-
+obj-$(CONFIG_SH_SH03)			+= ops-sh03.o fixups-sh03.o
diff -Nru a/arch/sh/drivers/pci/dma-dreamcast.c b/arch/sh/drivers/pci/dma-dreamcast.c
--- a/arch/sh/drivers/pci/dma-dreamcast.c	2004-12-24 13:37:32 -08:00
+++ b/arch/sh/drivers/pci/dma-dreamcast.c	2004-12-24 13:37:32 -08:00
@@ -23,6 +23,8 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/pci.h>
+#include <linux/dma-mapping.h>
+#include <linux/device.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -30,18 +32,21 @@
 
 static int gapspci_dma_used = 0;
 
-void *__pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-			   dma_addr_t * dma_handle)
+void *dreamcast_consistent_alloc(struct device *dev, size_t size,
+				 dma_addr_t *dma_handle, int flag)
 {
 	unsigned long buf;
 
-	if (gapspci_dma_used+size > GAPSPCI_DMA_SIZE)
+	if (dev && dev->bus != &pci_bus_type)
 		return NULL;
 
-	buf = GAPSPCI_DMA_BASE+gapspci_dma_used;
+	if (gapspci_dma_used + size > GAPSPCI_DMA_SIZE)
+		return ERR_PTR(-EINVAL);
+
+	buf = GAPSPCI_DMA_BASE + gapspci_dma_used;
 
 	gapspci_dma_used = PAGE_ALIGN(gapspci_dma_used+size);
-	
+
 	*dma_handle = (dma_addr_t)buf;
 
 	buf = P2SEGADDR(buf);
@@ -52,10 +57,15 @@
 	return (void *)buf;
 }
 
-void __pci_free_consistent(struct pci_dev *hwdev, size_t size,
+int dreamcast_consistent_free(struct device *dev, size_t size,
 			 void *vaddr, dma_addr_t dma_handle)
 {
+	if (dev && dev->bus != &pci_bus_type)
+		return -EINVAL;
+
 	/* XXX */
 	gapspci_dma_used = 0;
+
+	return 0;
 }
 
diff -Nru a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c
--- a/arch/sh/drivers/pci/fixups-dreamcast.c	2004-12-24 13:37:29 -08:00
+++ b/arch/sh/drivers/pci/fixups-dreamcast.c	2004-12-24 13:37:29 -08:00
@@ -62,7 +62,7 @@
 {
 	struct pci_dev *dev = 0;
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		/*
 		 * The interrupt routing semantics here are quite trivial.
 		 *
diff -Nru a/arch/sh/drivers/pci/fixups-rts7751r2d.c b/arch/sh/drivers/pci/fixups-rts7751r2d.c
--- a/arch/sh/drivers/pci/fixups-rts7751r2d.c	2004-12-24 13:36:33 -08:00
+++ b/arch/sh/drivers/pci/fixups-rts7751r2d.c	2004-12-24 13:36:33 -08:00
@@ -18,15 +18,26 @@
 
 int pci_fixup_pcic(void)
 {
-	unsigned long mcr;
+	unsigned long bcr1, mcr;
 
-	outl(0xfb900047, SH7751_PCICONF1);
-	outl(0xab000001, SH7751_PCICONF4);
+	bcr1 = inl(SH7751_BCR1);
+	bcr1 |= 0x40080000;	/* Enable Bit 19 BREQEN, set PCIC to slave */
+	outl(bcr1, PCI_REG(SH7751_PCIBCR1));
+
+	/* Enable all interrupts, so we known what to fix */
+	outl(0x0000c3ff, PCI_REG(SH7751_PCIINTM));
+	outl(0x0000380f, PCI_REG(SH7751_PCIAINTM));
+
+	outl(0xfb900047, PCI_REG(SH7751_PCICONF1));
+	outl(0xab000001, PCI_REG(SH7751_PCICONF4));
 
 	mcr = inl(SH7751_MCR);
 	mcr = (mcr & PCIMCR_MRSET_OFF) & PCIMCR_RFSH_OFF;
-	outl(mcr, SH7751_PCIMCR);
+	outl(mcr, PCI_REG(SH7751_PCIMCR));
 
+	outl(0x0c000000, PCI_REG(SH7751_PCICONF5));
+	outl(0xd0000000, PCI_REG(SH7751_PCICONF6));
+	outl(0x0c000000, PCI_REG(SH7751_PCILAR0));
+	outl(0x00000000, PCI_REG(SH7751_PCILAR1));
 	return 0;
 }
-
diff -Nru a/arch/sh/drivers/pci/fixups-sh03.c b/arch/sh/drivers/pci/fixups-sh03.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/drivers/pci/fixups-sh03.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,61 @@
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+/*
+ * 	IRQ functions
+ */
+
+int __init pcibios_map_platform_irq(u8 slot, u8 pin, struct pci_dev *dev)
+{
+	int irq;
+
+	if (dev->bus->number == 0) {
+		switch (slot) {
+		case 4: return 5;	/* eth0       */
+		case 8: return 5;	/* eth1       */
+		case 6: return 2;	/* PCI bridge */
+		default:
+                	printk("PCI: Bad IRQ mapping request for slot %d\n", slot);
+                	return 2;
+		}
+	} else {
+		switch (pin) {
+		case 0:   irq =  2; break;
+		case 1:   irq =  2; break;
+		case 2:   irq =  2; break;
+		case 3:   irq =  2; break;
+		case 4:   irq =  2; break;
+		default:  irq = -1; break;
+		}
+	}
+	return irq;
+}
+
+static u8 __init sh03_no_swizzle(struct pci_dev *dev, u8 *pin)
+{
+	/* no swizzling */
+	return PCI_SLOT(dev->devfn);
+}
+
+static int sh03_pci_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+	int irq = -1;
+
+	/* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
+	irq = pcibios_map_platform_irq(slot, pin, dev);
+	if( irq < 0 ) {
+		pr_debug("PCI: Error mapping IRQ on device %s\n", dev->slot_name);
+		return irq;
+	}
+
+	pr_debug("Setting IRQ for slot %s to %d\n", dev->slot_name, irq);
+
+	return irq;
+}
+
+void __init pcibios_fixup_irqs(void)
+{
+	pci_fixup_irqs(sh03_no_swizzle, sh03_pci_lookup_irq);
+}
diff -Nru a/arch/sh/drivers/pci/ops-rts7751r2d.c b/arch/sh/drivers/pci/ops-rts7751r2d.c
--- a/arch/sh/drivers/pci/ops-rts7751r2d.c	2004-12-24 13:36:56 -08:00
+++ b/arch/sh/drivers/pci/ops-rts7751r2d.c	2004-12-24 13:36:56 -08:00
@@ -61,7 +61,12 @@
 static struct sh7751_pci_address_map sh7751_pci_map = {
 	.window0	= {
 		.base	= SH7751_CS3_BASE_ADDR,
-		.size	= 0x03f00000,
+		.size	= 0x04000000,
+	},
+
+	.window1	= {
+		.base	= 0x00000000,	/* Unused */
+		.size	= 0x00000000,	/* Unused */
 	},
 
 	.flags	= SH7751_PCIC_NO_RESET,
diff -Nru a/arch/sh/drivers/pci/ops-sh03.c b/arch/sh/drivers/pci/ops-sh03.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/drivers/pci/ops-sh03.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,45 @@
+/*
+ * linux/arch/sh/drivers/pci/ops-sh03.c
+ *
+ * PCI initialization for the Interface CTP/PCI-SH03 board
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+#include "pci-sh7751.h"
+
+/*
+ * Description:  This function sets up and initializes the pcic, sets
+ * up the BARS, maps the DRAM into the address space etc, etc.
+ */
+int __init pcibios_init_platform(void)
+{
+   return 1;
+}
+
+static struct resource sh7751_io_resource = {
+	.name   = "SH03 IO",
+	.start  = SH7751_PCI_IO_BASE,
+	.end    = SH7751_PCI_IO_BASE + SH7751_PCI_IO_SIZE - 1,
+	.flags  = IORESOURCE_IO
+};
+
+static struct resource sh7751_mem_resource = {
+	.name   = "SH03 mem",
+	.start  = SH7751_PCI_MEMORY_BASE,
+	.end    = SH7751_PCI_MEMORY_BASE + SH7751_PCI_MEM_SIZE - 1,
+	.flags  = IORESOURCE_MEM
+};
+
+extern struct pci_ops sh7751_pci_ops;
+
+struct pci_channel board_pci_channels[] = {
+	{ &sh7751_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
+	{ NULL, NULL, NULL, 0, 0 },
+};
+
diff -Nru a/arch/sh/drivers/pci/pci-auto.c b/arch/sh/drivers/pci/pci-auto.c
--- a/arch/sh/drivers/pci/pci-auto.c	2004-12-24 13:37:29 -08:00
+++ b/arch/sh/drivers/pci/pci-auto.c	2004-12-24 13:37:29 -08:00
@@ -524,8 +524,10 @@
 					 PCI_COMMAND, cmdstat | PCI_COMMAND_IO |
 					 PCI_COMMAND_MEMORY |
 					 PCI_COMMAND_MASTER);
+#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
 		early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
 					PCI_LATENCY_TIMER, 0x80);
+#endif
 
 		/* Allocate PCI I/O and/or memory space */
 		pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_5);
diff -Nru a/arch/sh/drivers/pci/pci-sh7751.c b/arch/sh/drivers/pci/pci-sh7751.c
--- a/arch/sh/drivers/pci/pci-sh7751.c	2004-12-24 13:37:18 -08:00
+++ b/arch/sh/drivers/pci/pci-sh7751.c	2004-12-24 13:37:18 -08:00
@@ -33,6 +33,8 @@
 static unsigned int pci_probe = PCI_PROBE_CONF1;
 extern int pci_fixup_pcic(void);
 
+void pcibios_fixup_irqs(void) __attribute__ ((weak));
+
 /*
  * Direct access to PCI hardware...
  */
@@ -158,7 +160,6 @@
  *  Handle bus scanning and fixups ....
  */
 
-#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
 static void __init pci_fixup_ide_bases(struct pci_dev *d)
 {
 	int i;
@@ -256,7 +257,7 @@
 	outl(0, PCI_REG(SH7751_PCICLKR));
 	/* Clear Powerdown IRQ's (not done in reset) */
 	word = SH7751_PCIPINT_D3 | SH7751_PCIPINT_D0;
-	outl(word, PCI_REG(SH7751_PCICLKR));
+	outl(word, PCI_REG(SH7751_PCIPINT));
 
 	/*
 	 * This code is unused for some boards as it is done in the
@@ -361,7 +362,7 @@
 	 * TODO: add support for the internal error interrupts and
 	 * DMA interrupts...
 	 */
-	 
+
 #ifdef CONFIG_SH_RTS7751R2D
 	pci_fixup_pcic();
 #endif
diff -Nru a/arch/sh/drivers/pci/pci-st40.c b/arch/sh/drivers/pci/pci-st40.c
--- a/arch/sh/drivers/pci/pci-st40.c	2004-12-24 13:37:00 -08:00
+++ b/arch/sh/drivers/pci/pci-st40.c	2004-12-24 13:37:00 -08:00
@@ -18,6 +18,7 @@
 #include <linux/types.h>
 #include <asm/pci.h>
 #include <linux/irq.h>
+#include <linux/interrupt.h>	/* irqreturn_t */
 
 #include "pci-st40.h"
 
@@ -28,24 +29,22 @@
 #define ST40PCI_REG_ADDRESS      (ST40PCI_BASE_ADDRESS+0x07000000)
 
 #define ST40PCI_REG(x) (ST40PCI_REG_ADDRESS+(ST40PCI_##x))
+#define ST40PCI_REG_INDEXED(reg, index) 				\
+	(ST40PCI_REG(reg##0) +					\
+	  ((ST40PCI_REG(reg##1) - ST40PCI_REG(reg##0))*index))
 
 #define ST40PCI_WRITE(reg,val) writel((val),ST40PCI_REG(reg))
 #define ST40PCI_WRITE_SHORT(reg,val) writew((val),ST40PCI_REG(reg))
 #define ST40PCI_WRITE_BYTE(reg,val) writeb((val),ST40PCI_REG(reg))
+#define ST40PCI_WRITE_INDEXED(reg, index, val)				\
+	 writel((val), ST40PCI_REG_INDEXED(reg, index));
 
 #define ST40PCI_READ(reg) readl(ST40PCI_REG(reg))
 #define ST40PCI_READ_SHORT(reg) readw(ST40PCI_REG(reg))
 #define ST40PCI_READ_BYTE(reg) readb(ST40PCI_REG(reg))
 
-#define ST40PCI_SERR_IRQ        64
-#define ST40PCI_SERR_INT_GROUP  0
-#define ST40PCI_SERR_INT_POS    0
-#define ST40PCI_SERR_INT_PRI    15
-
-#define ST40PCI_ERR_IRQ        65
-#define ST40PCI_ERR_INT_GROUP   1
-#define ST40PCI_ERR_INT_POS     1
-#define ST40PCI_ERR_INT_PRI     14
+#define ST40PCI_SERR_IRQ	64
+#define ST40PCI_ERR_IRQ        	65
 
 
 /* Macros to extract PLL params */
@@ -69,47 +68,143 @@
 #define PLL_25MHZ 0x793c8512
 #define PLL_33MHZ PLL_SET(18,88,3,295)
 
+static void pci_set_rbar_region(unsigned int region,     unsigned long localAddr,
+			 unsigned long pciOffset, unsigned long regionSize);
+
+/*
+ * The pcibios_map_platform_irq function is defined in the appropriate
+ * board specific code and referenced here
+ */
+extern int __init pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin);
 
 static __init void SetPCIPLL(void)
 {
-	/* Stop the PLL */
-	writel(0, PLLPCICR);
+	{
+		/* Lets play with the PLL values */
+		unsigned long pll1cr1;
+		unsigned long mdiv, ndiv, pdiv;
+		unsigned long muxcr;
+		unsigned int muxcr_ratios[4] = { 8, 16, 21, 1 };
+		unsigned int freq;
+
+#define CLKGENA            0xbb040000
+#define CLKGENA_PLL2_MUXCR CLKGENA + 0x48
+		pll1cr1 = ctrl_inl(PLLPCICR);
+		printk("PLL1CR1 %08lx\n", pll1cr1);
+		mdiv = PLL_MDIV(pll1cr1);
+		ndiv = PLL_NDIV(pll1cr1);
+		pdiv = PLL_PDIV(pll1cr1);
+		printk("mdiv %02lx ndiv %02lx pdiv %02lx\n", mdiv, ndiv, pdiv);
+		freq = ((2*27*ndiv)/mdiv) / (1 << pdiv);
+		printk("PLL freq %dMHz\n", freq);
+		muxcr = ctrl_inl(CLKGENA_PLL2_MUXCR);
+		printk("PCI freq %dMhz\n", freq / muxcr_ratios[muxcr & 3]);
+	}
+}
 
-	/* Always run at 33Mhz. The PCI clock is totally async 
-	 * to the rest of the system
-	 */
-	writel(PLL_33MHZ | PLLPCICR_POWERON, PLLPCICR);
 
-	printk("ST40PCI: Waiting for PCI PLL to lock\n");
-	while ((readl(PLLPCICR) & PLLPCICR_LOCK) == 0);
-	writel(readl(PLLPCICR) | PLLPCICR_OUT_EN, PLLPCICR);
+struct pci_err {
+  unsigned mask;
+  const char *error_string;
+};
+
+static struct pci_err int_error[]={
+  { INT_MNLTDIM,"MNLTDIM: Master non-lock transfer"},
+  { INT_TTADI,  "TTADI: Illegal byte enable in I/O transfer"},
+  { INT_TMTO,   "TMTO: Target memory read/write timeout"},
+  { INT_MDEI,   "MDEI: Master function disable error"},
+  { INT_APEDI,  "APEDI: Address parity error"},
+  { INT_SDI,    "SDI: SERR detected"},
+  { INT_DPEITW, "DPEITW: Data parity error target write"},
+  { INT_PEDITR, "PEDITR: PERR detected"},
+  { INT_TADIM,  "TADIM: Target abort detected"},
+  { INT_MADIM,  "MADIM: Master abort detected"},
+  { INT_MWPDI,  "MWPDI: PERR from target at data write"},
+  { INT_MRDPEI, "MRDPEI: Master read data parity error"}
+};
+#define NUM_PCI_INT_ERRS (sizeof(int_error)/sizeof(struct pci_err))
+
+static struct pci_err aint_error[]={
+  { AINT_MBI,   "MBI: Master broken"},
+  { AINT_TBTOI, "TBTOI: Target bus timeout"},
+  { AINT_MBTOI, "MBTOI: Master bus timeout"},
+  { AINT_TAI,   "TAI: Target abort"},
+  { AINT_MAI,   "MAI: Master abort"},
+  { AINT_RDPEI, "RDPEI: Read data parity"},
+  { AINT_WDPE,  "WDPE: Write data parity"}
+};
+
+#define NUM_PCI_AINT_ERRS (sizeof(aint_error)/sizeof(struct pci_err))
+
+static void print_pci_errors(unsigned reg,struct pci_err *error,int num_errors)
+{
+  int i;
+
+  for(i=0;i<num_errors;i++) {
+    if(reg & error[i].mask) {
+      printk("%s\n",error[i].error_string);
+    }
+  }
+
 }
 
 
+static char * pci_commands[16]={
+	"Int Ack",
+	"Special Cycle",
+	"I/O Read",
+	"I/O Write",
+	"Reserved",
+	"Reserved",
+	"Memory Read",
+	"Memory Write",
+	"Reserved",
+	"Reserved",
+	"Configuration Read",
+	"Configuration Write",
+	"Memory Read Multiple",
+	"Dual Address Cycle",
+	"Memory Read Line",
+	"Memory Write-and-Invalidate"
+};
+
 static irqreturn_t st40_pci_irq(int irq, void *dev_instance, struct pt_regs *regs)
 {
-
 	unsigned pci_int, pci_air, pci_cir, pci_aint;
+	static int count=0;
+
+
+	pci_int = ST40PCI_READ(INT);pci_aint = ST40PCI_READ(AINT);
+	pci_cir = ST40PCI_READ(CIR);pci_air = ST40PCI_READ(AIR);
+
+	/* Reset state to stop multiple interrupts */
+        ST40PCI_WRITE(INT, ~0); ST40PCI_WRITE(AINT, ~0);
+
+
+	if(++count>1) return IRQ_HANDLED;
+
+	printk("** PCI ERROR **\n");
+
+        if(pci_int) {
+		printk("** INT register status\n");
+		print_pci_errors(pci_int,int_error,NUM_PCI_INT_ERRS);
+	}
+
+        if(pci_aint) {
+		printk("** AINT register status\n");
+		print_pci_errors(pci_aint,aint_error,NUM_PCI_AINT_ERRS);
+	}
+
+	printk("** Address and command info\n");
 
-	pci_int = ST40PCI_READ(INT);
-	pci_cir = ST40PCI_READ(CIR);
-	pci_air = ST40PCI_READ(AIR);
-
-	if (pci_int) {
-		printk("PCI INTERRUPT!\n");
-		printk("PCI INT -> 0x%x\n", pci_int & 0xffff);
-		printk("PCI AIR -> 0x%x\n", pci_air);
-		printk("PCI CIR -> 0x%x\n", pci_cir);
-		ST40PCI_WRITE(INT, ~0);
-	}
-
-	pci_aint = ST40PCI_READ(AINT);
-	if (pci_aint) {
-		printk("PCI ARB INTERRUPT!\n");
-		printk("PCI AINT -> 0x%x\n", pci_aint);
-		printk("PCI AIR -> 0x%x\n", pci_air);
-		printk("PCI CIR -> 0x%x\n", pci_cir);
-		ST40PCI_WRITE(AINT, ~0);
+	printk("** Command  %s : Address 0x%x\n",
+	       pci_commands[pci_cir&0xf],pci_air);
+
+	if(pci_cir&CIR_PIOTEM) {
+		printk("CIR_PIOTEM:PIO transfer error for master\n");
+	}
+        if(pci_cir&CIR_RWTET) {
+		printk("CIR_RWTET:Read/Write transfer error for target\n");
 	}
 
 	return IRQ_HANDLED;
@@ -119,7 +214,7 @@
 /* Rounds a number UP to the nearest power of two. Used for
  * sizing the PCI window.
  */
-static u32 __init r2p2(u32 num)
+static u32 r2p2(u32 num)
 {
 	int i = 31;
 	u32 tmp = num;
@@ -179,12 +274,16 @@
 	/* Loop while core resets */
 	while (ST40PCI_READ(CR) & CR_SOFT_RESET);
 
+	/* Switch off interrupts */
+	ST40PCI_WRITE(INTM, 0);
+	ST40PCI_WRITE(AINT, 0);
+
 	/* Now, lets reset all the cards on the bus with extreme prejudice */
 	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_RSTCTL);
 	udelay(250);
 
 	/* Set bus active, take it out of reset */
-	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_CFINT | CR_PFCS | CR_PFE);
+	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_BMAM | CR_CFINT | CR_PFCS | CR_PFE);
 
 	/* The PCI spec says that no access must be made to the bus until 1 second
 	 * after reset. This seem ludicrously long, but some delay is needed here
@@ -219,37 +318,20 @@
 	/* Set up the 64K window */
 	ST40PCI_WRITE(IOBMR, 0x0);
 
-	/* Now we set up the mbars so the PCI bus can see the memory of the machine */
-
-	if (memSize < (64 * 1024)) {
-		printk("Ridiculous memory size of 0x%x?\n",memSize);
-		return 0;
-	}
-
-	lsr0 =
-	    (memSize >
-	     (512 * 1024 * 1024)) ? 0x1fff0001 : ((r2p2(memSize) -
-						   0x10000) | 0x1);
+	/* Now we set up the mbars so the PCI bus can see the local memory */
+	/* Expose a 256M window starting at PCI address 0... */
+	ST40PCI_WRITE(CSR_MBAR0, 0);
+	ST40PCI_WRITE(LSR0, 0x0fff0001);
 
-	ST40PCI_WRITE(LSR0, lsr0);
-
-	ST40PCI_WRITE(CSR_MBAR0, memStart);
-	ST40PCI_WRITE(LAR0, memStart);
+	/* ... and set up the initial incomming window to expose all of RAM */
+	pci_set_rbar_region(7, memStart, memStart, memSize);
 
 	/* Maximise timeout values */
 	ST40PCI_WRITE_BYTE(CSR_TRDY, 0xff);
 	ST40PCI_WRITE_BYTE(CSR_RETRY, 0xff);
 	ST40PCI_WRITE_BYTE(CSR_MIT, 0xff);
 
-
-	/* Install the pci interrupt handlers */
-	make_intc2_irq(ST40PCI_SERR_IRQ, INTC2_BASE0,
-		       ST40PCI_SERR_INT_GROUP, ST40PCI_SERR_INT_POS,
-		       ST40PCI_SERR_INT_PRI);
-
-	make_intc2_irq(ST40PCI_ERR_IRQ, INTC2_BASE0, ST40PCI_ERR_INT_GROUP,
-		       ST40PCI_ERR_INT_POS, ST40PCI_ERR_INT_PRI);
-
+	ST40PCI_WRITE_BYTE(PERF,PERF_MASTER_WRITE_POSTING);
 
 	return 1;
 }
@@ -332,7 +414,7 @@
 	return PCIBIOS_SUCCESSFUL;
 }
 
-static struct pci_ops pci_config_ops = {
+struct pci_ops st40pci_config_ops = {
 	.read = 	st40pci_read,
 	.write = 	st40pci_write,
 };
@@ -348,36 +430,12 @@
 }
 
 
-/* This needs to be shunted out of here into the board specific bit */
-#define HARP_PCI_IRQ    1
-#define HARP_BRIDGE_IRQ 2
-#define OVERDRIVE_SLOT0_IRQ 0
-
-static int __init map_harp_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
-	switch (slot) {
-#ifdef CONFIG_SH_STB1_HARP
-	case 2:		/*This is the PCI slot on the */
-		return HARP_PCI_IRQ;
-	case 1:		/* this is the bridge */
-		return HARP_BRIDGE_IRQ;
-#elif defined(CONFIG_SH_STB1_OVERDRIVE)
-	case 1:
-	case 2:
-	case 3:
-		return slot - 1;
-#else
-#error Unknown board
-#endif
-	default:
-		return -1;
-	}
-}
-
-void __init pcibios_init(void)
+static int __init pcibios_init(void)
 {
 	extern unsigned long memory_start, memory_end;
 
+	printk(KERN_ALERT "pci-st40.c: pcibios_init\n");
+
 	if (sh_mv.mv_init_pci != NULL) {
 		sh_mv.mv_init_pci();
 	}
@@ -392,7 +450,7 @@
 	if (request_irq(ST40PCI_ERR_IRQ, st40_pci_irq, 
                         SA_INTERRUPT, "st40pci", NULL)) {
 		printk(KERN_ERR "st40pci: Cannot hook interrupt\n");
-		return;
+		return -EIO;
 	}
 
 	/* Enable the PCI interrupts on the device */
@@ -406,12 +464,46 @@
 #endif
 
 	/* ok, do the scan man */
-	pci_root_bus = pci_scan_bus(0, &pci_config_ops, NULL);
+	pci_root_bus = pci_scan_bus(0, &st40pci_config_ops, NULL);
 	pci_assign_unassigned_resources();
-	pci_fixup_irqs(no_swizzle, map_harp_irq);
+	pci_fixup_irqs(no_swizzle, pcibios_map_platform_irq);
 
+	return 0;
 }
 
+subsys_initcall(pcibios_init);
+
 void __init pcibios_fixup_bus(struct pci_bus *bus)
 {
 }
+
+/*
+ * Publish a region of local address space over the PCI bus
+ * to other devices.
+ */
+static void pci_set_rbar_region(unsigned int region,     unsigned long localAddr,
+			 unsigned long pciOffset, unsigned long regionSize)
+{
+	unsigned long mask;
+
+	if (region > 7)
+		return;
+
+	if (regionSize > (512 * 1024 * 1024))
+		return;
+
+	mask = r2p2(regionSize) - 0x10000;
+
+	/* Diable the region (in case currently in use, should never happen) */
+	ST40PCI_WRITE_INDEXED(RSR, region, 0);
+
+	/* Start of local address space to publish */
+	ST40PCI_WRITE_INDEXED(RLAR, region, PHYSADDR(localAddr) );
+
+	/* Start of region in PCI address space as an offset from MBAR0 */
+	ST40PCI_WRITE_INDEXED(RBAR, region, pciOffset);
+
+	/* Size of region */
+	ST40PCI_WRITE_INDEXED(RSR, region, mask | 1);
+}
+
diff -Nru a/arch/sh/drivers/pci/pci-st40.h b/arch/sh/drivers/pci/pci-st40.h
--- a/arch/sh/drivers/pci/pci-st40.h	2004-12-24 13:36:31 -08:00
+++ b/arch/sh/drivers/pci/pci-st40.h	2004-12-24 13:36:31 -08:00
@@ -33,13 +33,36 @@
 #define ST40PCI_LAR0          0x1c
 
 #define ST40PCI_INT           0x24
+#define INT_MNLTDIM           (1<<15)
+#define INT_TTADI             (1<<14)
+#define INT_TMTO              (1<<9)
+#define INT_MDEI              (1<<8)
+#define INT_APEDI             (1<<7)
+#define INT_SDI               (1<<6)
+#define INT_DPEITW            (1<<5)
+#define INT_PEDITR            (1<<4)
+#define INT_TADIM             (1<<3)
 #define INT_MADIM             (1<<2)
+#define INT_MWPDI             (1<<1)
+#define INT_MRDPEI            (1<<0)
 
 
 #define ST40PCI_INTM          0x28
 #define ST40PCI_AIR           0x2c
+
 #define ST40PCI_CIR           0x30
+#define CIR_PIOTEM            (1<<31)
+#define CIR_RWTET             (1<<26)
+
 #define ST40PCI_AINT          0x40
+#define AINT_MBI              (1<<13)
+#define AINT_TBTOI            (1<<12)
+#define AINT_MBTOI            (1<<11)
+#define AINT_TAI              (1<<3)
+#define AINT_MAI              (1<<2)
+#define AINT_RDPEI            (1<<1)
+#define AINT_WDPE             (1<<0)
+
 #define ST40PCI_AINTM         0x44
 #define ST40PCI_BMIR          0x48
 #define ST40PCI_PAR           0x4c
@@ -50,6 +73,53 @@
 #define ST40PCI_MBMR          0x70
 #define ST40PCI_IOBMR         0x74
 #define ST40PCI_PDR           0x78
+
+/* H8 specific registers start here */
+#define ST40PCI_WCBAR         0x7c
+#define ST40PCI_LOCCFG_UNLOCK 0x34
+
+#define ST40PCI_RBAR0         0x100
+#define ST40PCI_RSR0          0x104
+#define ST40PCI_RLAR0         0x108
+
+#define ST40PCI_RBAR1         0x110
+#define ST40PCI_RSR1          0x114
+#define ST40PCI_RLAR1         0x118
+
+
+#define ST40PCI_RBAR2         0x120
+#define ST40PCI_RSR2          0x124
+#define ST40PCI_RLAR2         0x128
+
+#define ST40PCI_RBAR3         0x130
+#define ST40PCI_RSR3          0x134
+#define ST40PCI_RLAR3         0x138
+
+#define ST40PCI_RBAR4         0x140
+#define ST40PCI_RSR4          0x144
+#define ST40PCI_RLAR4         0x148
+
+#define ST40PCI_RBAR5         0x150
+#define ST40PCI_RSR5          0x154
+#define ST40PCI_RLAR5         0x158
+
+#define ST40PCI_RBAR6         0x160
+#define ST40PCI_RSR6          0x164
+#define ST40PCI_RLAR6         0x168
+
+#define ST40PCI_RBAR7         0x170
+#define ST40PCI_RSR7          0x174
+#define ST40PCI_RLAR7         0x178
+
+
+#define ST40PCI_RBAR(n)      (0x100+(0x10*(n)))
+#define ST40PCI_RSR(n)       (0x104+(0x10*(n)))
+#define ST40PCI_RLAR(n)      (0x108+(0x10*(n)))
+
+#define ST40PCI_PERF               0x80
+#define PERF_MASTER_WRITE_POSTING  (1<<4)
+/* H8 specific registers end here */
+
 
 /* These are configs space registers */
 #define ST40PCI_CSR_VID               0x10000
diff -Nru a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
--- a/arch/sh/drivers/pci/pci.c	2004-12-24 13:37:44 -08:00
+++ b/arch/sh/drivers/pci/pci.c	2004-12-24 13:37:44 -08:00
@@ -106,6 +106,8 @@
 	pci_read_config_word(dev, PCI_COMMAND, &cmd);
 	old_cmd = cmd;
 	for(idx=0; idx<6; idx++) {
+		if (!(mask & (1 << idx)))
+			continue;
 		r = &dev->resource[idx];
 		if (!r->start && r->end) {
 			printk(KERN_ERR "PCI: Device %s not available because "
diff -Nru a/arch/sh/kernel/asm-offsets.c b/arch/sh/kernel/asm-offsets.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/kernel/asm-offsets.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,32 @@
+/*
+ * This program is used to generate definitions needed by
+ * assembly language modules.
+ *
+ * We use the technique used in the OSF Mach kernel code:
+ * generate asm statements containing #defines,
+ * compile this file to assembler, and then extract the
+ * #defines from the assembly-language output.
+ */
+
+#include <linux/stddef.h>
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <asm/thread_info.h>
+
+#define DEFINE(sym, val) \
+        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+
+#define BLANK() asm volatile("\n->" : : )
+
+int main(void)
+{
+	/* offsets into the thread_info struct */
+	DEFINE(TI_TASK,		offsetof(struct thread_info, task));
+	DEFINE(TI_EXEC_DOMAIN,	offsetof(struct thread_info, exec_domain));
+	DEFINE(TI_FLAGS,	offsetof(struct thread_info, flags));
+	DEFINE(TI_CPU,		offsetof(struct thread_info, cpu));
+	DEFINE(TI_PRE_COUNT,	offsetof(struct thread_info, preempt_count));
+	DEFINE(TI_RESTART_BLOCK,offsetof(struct thread_info, restart_block));
+
+	return 0;
+}
diff -Nru a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c
--- a/arch/sh/kernel/cpu/init.c	2004-12-24 13:37:43 -08:00
+++ b/arch/sh/kernel/cpu/init.c	2004-12-24 13:37:43 -08:00
@@ -24,8 +24,8 @@
  * Generic wrapper for command line arguments to disable on-chip
  * peripherals (nofpu, nodsp, and so forth).
  */
-#define onchip_setup(x) 			\
-static int x##_disabled __initdata = 0; 	\
+#define onchip_setup(x)				\
+static int x##_disabled __initdata = 0;		\
 						\
 static int __init x##_setup(char *opts)		\
 {						\
@@ -88,7 +88,7 @@
 		} while (--ways);
 	}
 
-	/* 
+	/*
 	 * Default CCR values .. enable the caches
 	 * and invalidate them immediately..
 	 */
@@ -160,7 +160,7 @@
 }
 #endif /* CONFIG_SH_DSP */
 
-/*
+/**
  * sh_cpu_init
  *
  * This is our initial entry point for each CPU, and is invoked on the boot
@@ -200,7 +200,7 @@
 #ifdef CONFIG_SH_DSP
 	/* Probe for DSP */
 	dsp_init();
-	
+
 	/* Disable the DSP */
 	if (dsp_disabled) {
 		printk("DSP Disabled\n");
diff -Nru a/arch/sh/kernel/cpu/irq_imask.c b/arch/sh/kernel/cpu/irq_imask.c
--- a/arch/sh/kernel/cpu/irq_imask.c	2004-12-24 13:36:55 -08:00
+++ b/arch/sh/kernel/cpu/irq_imask.c	2004-12-24 13:36:55 -08:00
@@ -18,10 +18,10 @@
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 
 #include <linux/spinlock.h>
 #include <linux/cache.h>
diff -Nru a/arch/sh/kernel/cpu/irq_ipr.c b/arch/sh/kernel/cpu/irq_ipr.c
--- a/arch/sh/kernel/cpu/irq_ipr.c	2004-12-24 13:36:31 -08:00
+++ b/arch/sh/kernel/cpu/irq_ipr.c	2004-12-24 13:36:31 -08:00
@@ -19,6 +19,7 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/irq.h>
+#include <linux/module.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -41,7 +42,7 @@
 static void end_ipr_irq(unsigned int irq);
 
 static unsigned int startup_ipr_irq(unsigned int irq)
-{ 
+{
 	enable_ipr_irq(irq);
 	return 0; /* never anything pending */
 }
@@ -281,6 +282,10 @@
 #endif /* !CONFIG_CPU_SUBTYPE_SH7300 */
 #endif /* CONFIG_CPU_SUBTYPE_SH7707 || CONFIG_CPU_SUBTYPE_SH7709  || CONFIG_CPU_SUBTYPE_SH7300*/
 
+#ifdef CONFIG_CPU_SUBTYPE_ST40
+	init_IRQ_intc2();
+#endif
+
 	/* Perform the machine specific initialisation */
 	if (sh_mv.mv_init_irq != NULL) {
 		sh_mv.mv_init_irq();
@@ -329,3 +334,6 @@
 	return irq;
 }
 #endif
+
+EXPORT_SYMBOL(make_ipr_irq);
+
diff -Nru a/arch/sh/kernel/cpu/sh2/Makefile b/arch/sh/kernel/cpu/sh2/Makefile
--- a/arch/sh/kernel/cpu/sh2/Makefile	2004-12-24 13:36:49 -08:00
+++ b/arch/sh/kernel/cpu/sh2/Makefile	2004-12-24 13:36:49 -08:00
@@ -2,3 +2,5 @@
 # Makefile for the Linux/SuperH SH-2 backends.
 #
 
+obj-y	:= probe.o
+
diff -Nru a/arch/sh/kernel/cpu/sh2/probe.c b/arch/sh/kernel/cpu/sh2/probe.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/kernel/cpu/sh2/probe.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,39 @@
+/*
+ * arch/sh/kernel/cpu/sh2/probe.c
+ *
+ * CPU Subtype Probing for SH-2.
+ *
+ * Copyright (C) 2002 Paul Mundt
+ *
+ * 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 <linux/init.h>
+#include <asm/processor.h>
+#include <asm/cache.h>
+
+int __init detect_cpu_and_cache_system(void)
+{
+	/*
+	 * For now, assume SH7604 .. fix this later.
+	 */
+	cpu_data->type			= CPU_SH7604;
+	cpu_data->dcache.ways		= 4;
+	cpu_data->dcache.way_shift	= 6;
+	cpu_data->dcache.sets		= 64;
+	cpu_data->dcache.entry_shift	= 4;
+	cpu_data->dcache.linesz		= L1_CACHE_BYTES;
+	cpu_data->dcache.flags		= 0;
+
+	/*
+	 * SH-2 doesn't have separate caches
+	 */
+	cpu_data->dcache.flags |= SH_CACHE_COMBINED;
+	cpu_data->icache = cpu_data->dcache;
+
+	return 0;
+}
+
diff -Nru a/arch/sh/kernel/cpu/sh3/Makefile b/arch/sh/kernel/cpu/sh3/Makefile
--- a/arch/sh/kernel/cpu/sh3/Makefile	2004-12-24 13:36:32 -08:00
+++ b/arch/sh/kernel/cpu/sh3/Makefile	2004-12-24 13:36:32 -08:00
@@ -2,5 +2,5 @@
 # Makefile for the Linux/SuperH SH-3 backends.
 #
 
-obj-y	:= ex.o
+obj-y	:= ex.o probe.o
 
diff -Nru a/arch/sh/kernel/cpu/sh3/probe.c b/arch/sh/kernel/cpu/sh3/probe.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/kernel/cpu/sh3/probe.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,97 @@
+/*
+ * arch/sh/kernel/cpu/sh3/probe.c
+ *
+ * CPU Subtype Probing for SH-3.
+ *
+ * Copyright (C) 1999, 2000  Niibe Yutaka
+ * Copyright (C) 2002  Paul Mundt
+ *
+ * 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 <linux/init.h>
+#include <asm/processor.h>
+#include <asm/cache.h>
+#include <asm/io.h>
+
+int __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&~(SH_CACHE_VALID|SH_CACHE_UPDATED), addr0);
+	data1  = ctrl_inl(addr1);
+	ctrl_outl(data1&~(SH_CACHE_VALID|SH_CACHE_UPDATED), addr1);
+
+	/* Next, check if there's shadow or not */
+	data0 = ctrl_inl(addr0);
+	data0 ^= SH_CACHE_VALID;
+	ctrl_outl(data0, addr0);
+	data1 = ctrl_inl(addr1);
+	data2 = data1 ^ SH_CACHE_VALID;
+	ctrl_outl(data2, addr1);
+	data3 = ctrl_inl(addr0);
+
+	/* Lastly, invaliate them. */
+	ctrl_outl(data0&~SH_CACHE_VALID, addr0);
+	ctrl_outl(data2&~SH_CACHE_VALID, addr1);
+
+	back_to_P1();
+
+	cpu_data->dcache.ways		= 4;
+	cpu_data->dcache.entry_shift	= 4;
+	cpu_data->dcache.linesz		= L1_CACHE_BYTES;
+	cpu_data->dcache.flags		= 0;
+
+	/*
+	 * 7709A/7729 has 16K cache (256-entry), while 7702 has only
+	 * 2K(direct) 7702 is not supported (yet)
+	 */
+	if (data0 == data1 && data2 == data3) {	/* Shadow */
+		cpu_data->dcache.way_incr	= (1 << 11);
+		cpu_data->dcache.entry_mask	= 0x7f0;
+		cpu_data->dcache.sets		= 128;
+		cpu_data->type = CPU_SH7708;
+
+		cpu_data->flags |= CPU_HAS_MMU_PAGE_ASSOC;
+	} else {				/* 7709A or 7729  */
+		cpu_data->dcache.way_incr	= (1 << 12);
+		cpu_data->dcache.entry_mask	= 0xff0;
+		cpu_data->dcache.sets		= 256;
+		cpu_data->type = CPU_SH7729;
+
+#if defined(CONFIG_CPU_SUBTYPE_SH7705)
+		cpu_data->type = CPU_SH7705;
+
+#if defined(CONFIG_SH7705_CACHE_32KB)
+		cpu_data->dcache.way_incr	= (1 << 13);
+		cpu_data->dcache.entry_mask	= 0x1ff0;
+		cpu_data->dcache.sets		= 512;
+		ctrl_outl(CCR_CACHE_32KB, CCR3);
+#else
+		ctrl_outl(CCR_CACHE_16KB, CCR3);
+#endif
+#endif
+	}
+
+	/*
+	 * SH-3 doesn't have separate caches
+	 */
+	cpu_data->dcache.flags |= SH_CACHE_COMBINED;
+	cpu_data->icache = cpu_data->dcache;
+
+	return 0;
+}
+
diff -Nru a/arch/sh/kernel/cpu/sh4/Makefile b/arch/sh/kernel/cpu/sh4/Makefile
--- a/arch/sh/kernel/cpu/sh4/Makefile	2004-12-24 13:36:18 -08:00
+++ b/arch/sh/kernel/cpu/sh4/Makefile	2004-12-24 13:36:18 -08:00
@@ -2,8 +2,9 @@
 # Makefile for the Linux/SuperH SH-4 backends.
 #
 
-obj-y	:= fpu.o ex.o
+obj-y	:= ex.o probe.o
 
+obj-$(CONFIG_SH_FPU)                    += fpu.o
 obj-$(CONFIG_CPU_SUBTYPE_ST40STB1)	+= irq_intc2.o
 obj-$(CONFIG_SH_STORE_QUEUES)		+= sq.o
 
diff -Nru a/arch/sh/kernel/cpu/sh4/ex.S b/arch/sh/kernel/cpu/sh4/ex.S
--- a/arch/sh/kernel/cpu/sh4/ex.S	2004-12-24 13:36:31 -08:00
+++ b/arch/sh/kernel/cpu/sh4/ex.S	2004-12-24 13:36:31 -08:00
@@ -37,8 +37,11 @@
 	.long	exception_error	! address error load
 	.long	exception_error	! address error store	/* 100 */
 #endif
-
+#if defined(CONFIG_SH_FPU)
 	.long	do_fpu_error		/* 120 */
+#else
+	.long	exception_error		/* 120 */
+#endif
 	.long	exception_error		/* 140 */
 	.long	system_call	! Unconditional Trap	 /* 160 */
 	.long	exception_error	! reserved_instruction (filled by trap_init) /* 180 */
@@ -126,8 +129,13 @@
 	.long	exception_error			! 46
 	.long	exception_error			! 47
 #endif
+#if defined(CONFIG_SH_FPU)
 	.long	do_fpu_state_restore	! 48	/* 800 */
 	.long	do_fpu_state_restore	! 49	/* 820 */
+#else
+	.long	exception_error
+	.long	exception_error
+#endif
 #if defined(CONFIG_CPU_SUBTYPE_SH7751)
 	.long	exception_error			/* 840 */
 	.long	exception_error
@@ -217,6 +225,66 @@
 	.long	exception_error
 	.long	do_IRQ	! ADC	adi
 	.long	do_IRQ	! CMT	cmti	/* FA0 */
+#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
+	.long	do_IRQ	!  50 0x840
+	.long	do_IRQ	!  51 0x860
+	.long	do_IRQ	!  52 0x880
+	.long	do_IRQ	!  53 0x8a0
+	.long	do_IRQ	!  54 0x8c0
+	.long	do_IRQ	!  55 0x8e0
+	.long	do_IRQ	!  56 0x900
+	.long	do_IRQ	!  57 0x920
+	.long	do_IRQ	!  58 0x940
+	.long	do_IRQ	!  59 0x960
+	.long	do_IRQ	!  60 0x980
+	.long	do_IRQ	!  61 0x9a0
+	.long	do_IRQ	!  62 0x9c0
+	.long	do_IRQ	!  63 0x9e0
+	.long	do_IRQ	!  64 0xa00
+	.long	do_IRQ	!  65 0xa20
+	.long	do_IRQ	!  66 0xa40
+	.long	do_IRQ	!  67 0xa60
+	.long	do_IRQ	!  68 0xa80
+	.long	do_IRQ	!  69 0xaa0
+	.long	do_IRQ	!  70 0xac0
+	.long	do_IRQ	!  71 0xae0
+	.long	do_IRQ	!  72 0xb00
+	.long	do_IRQ	!  73 0xb20
+	.long	do_IRQ	!  74 0xb40
+	.long	do_IRQ	!  75 0xb60
+	.long	do_IRQ	!  76 0xb80
+	.long	do_IRQ	!  77 0xba0
+	.long	do_IRQ	!  78 0xbc0
+	.long	do_IRQ	!  79 0xbe0
+	.long	do_IRQ	!  80 0xc00
+	.long	do_IRQ	!  81 0xc20
+	.long	do_IRQ	!  82 0xc40
+	.long	do_IRQ	!  83 0xc60
+	.long	do_IRQ	!  84 0xc80
+	.long	do_IRQ	!  85 0xca0
+	.long	do_IRQ	!  86 0xcc0
+	.long	do_IRQ	!  87 0xce0
+	.long	do_IRQ	!  88 0xd00
+	.long	do_IRQ	!  89 0xd20
+	.long	do_IRQ	!  90 0xd40
+	.long	do_IRQ	!  91 0xd60
+	.long	do_IRQ	!  92 0xd80
+	.long	do_IRQ	!  93 0xda0
+	.long	do_IRQ	!  94 0xdc0
+	.long	do_IRQ	!  95 0xde0
+	.long	do_IRQ	!  96 0xe00
+	.long	do_IRQ	!  97 0xe20
+	.long	do_IRQ	!  98 0xe40
+	.long	do_IRQ	!  99 0xe60
+	.long	do_IRQ	! 100 0xe80
+	.long	do_IRQ	! 101 0xea0
+	.long	do_IRQ	! 102 0xec0
+	.long	do_IRQ	! 103 0xee0
+	.long	do_IRQ	! 104 0xf00
+	.long	do_IRQ	! 105 0xf20
+	.long	do_IRQ	! 106 0xf40
+	.long	do_IRQ	! 107 0xf60
+	.long	do_IRQ	! 108 0xf80
 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
 	.long	exception_error			!  50 0x840
 	.long	exception_error			!  51 0x860
diff -Nru a/arch/sh/kernel/cpu/sh4/irq_intc2.c b/arch/sh/kernel/cpu/sh4/irq_intc2.c
--- a/arch/sh/kernel/cpu/sh4/irq_intc2.c	2004-12-24 13:37:31 -08:00
+++ b/arch/sh/kernel/cpu/sh4/irq_intc2.c	2004-12-24 13:37:31 -08:00
@@ -22,8 +22,11 @@
 
 
 struct intc2_data {
-	unsigned int addr;	/* Address of Interrupt Priority Register */
-	int mask; /*Mask to apply */
+	unsigned char msk_offset;
+	unsigned char msk_shift;
+#ifdef CONFIG_CPU_SUBTYPE_ST40
+	int (*clear_irq) (int);
+#endif
 };
 
 
@@ -56,33 +59,34 @@
 
 static void disable_intc2_irq(unsigned int irq)
 {
-	unsigned addr;
-	int offset=irq-INTC2_FIRST_IRQ;
-	unsigned val,flags;
+	int irq_offset = irq - INTC2_FIRST_IRQ;
+	int msk_shift, msk_offset;
 
 	// Sanity check
-	if(offset<0 || offset>=NR_INTC2_IRQS) return;
-
-	addr=intc2_data[offset].addr+INTC2_INTMSK_OFFSET;
+	if((irq_offset<0) || (irq_offset>=NR_INTC2_IRQS))
+		return;
 
-	local_irq_save(flags);
-	val=ctrl_inl(addr);
-	val|=intc2_data[offset].mask;
-	ctrl_outl(val,addr);
+	msk_shift = intc2_data[irq_offset].msk_shift;
+	msk_offset = intc2_data[irq_offset].msk_offset;
 
-	local_irq_restore(flags);
+	ctrl_outl(1<<msk_shift,
+		  INTC2_BASE+INTC2_INTMSK_OFFSET+msk_offset);
 }
 
 static void enable_intc2_irq(unsigned int irq)
 {
-	int offset=irq-INTC2_FIRST_IRQ;
+	int irq_offset = irq - INTC2_FIRST_IRQ;
+	int msk_shift, msk_offset;
 
-	// Sanity check
-	if(offset<0 || offset>=NR_INTC2_IRQS) return;
+	/* Sanity check */
+	if((irq_offset<0) || (irq_offset>=NR_INTC2_IRQS))
+		return;
 
-	ctrl_outl(intc2_data[offset].mask,
-		  intc2_data[offset].addr+INTC2_INTMSKCLR_OFFSET);
+	msk_shift = intc2_data[irq_offset].msk_shift;
+	msk_offset = intc2_data[irq_offset].msk_offset;
 
+	ctrl_outl(1<<msk_shift,
+		  INTC2_BASE+INTC2_INTMSKCLR_OFFSET+msk_offset);
 }
 
 static void mask_and_ack_intc2(unsigned int irq)
@@ -94,28 +98,52 @@
 {
 	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
 		enable_intc2_irq(irq);
-}
 
-void make_intc2_irq(unsigned int irq, unsigned int addr, 
-		    unsigned int group,int pos, int priority)
+#ifdef CONFIG_CPU_SUBTYPE_ST40
+	if (intc2_data[irq - INTC2_FIRST_IRQ].clear_irq)
+		intc2_data[irq - INTC2_FIRST_IRQ].clear_irq (irq);
+#endif
+}
+
+/*
+ * Setup an INTC2 style interrupt.
+ * NOTE: Unlike IPR interrupts, parameters are not shifted by this code,
+ * allowing the use of the numbers straight out of the datasheet.
+ * For example:
+ *    PIO1 which is INTPRI00[19,16] and INTMSK00[13]
+ * would be:               ^     ^             ^  ^
+ *                         |     |             |  |
+ *    make_intc2_irq(84,   0,   16,            0, 13);
+ */
+void make_intc2_irq(unsigned int irq,
+		    unsigned int ipr_offset, unsigned int ipr_shift,
+		    unsigned int msk_offset, unsigned int msk_shift,
+		    unsigned int priority)
 {
-	int offset=irq-INTC2_FIRST_IRQ;
-	unsigned flags,val;
+	int irq_offset = irq - INTC2_FIRST_IRQ;
+	unsigned int flags;
+	unsigned long ipr;
 
-	if(offset<0 || offset>=NR_INTC2_IRQS) {
+	if((irq_offset<0) || (irq_offset>=NR_INTC2_IRQS))
 		return;
-	}
 
 	disable_irq_nosync(irq);
+
 	/* Fill the data we need */
-	intc2_data[offset].addr=addr;
-	intc2_data[offset].mask=1<<pos;
+	intc2_data[irq_offset].msk_offset = msk_offset;
+	intc2_data[irq_offset].msk_shift  = msk_shift;
+#ifdef CONFIG_CPU_SUBTYPE_ST40
+	intc2_data[irq_offset].clear_irq = NULL;
+#endif
 		
 	/* Set the priority level */
 	local_irq_save(flags);
-	val=ctrl_inl(addr+INTC2_INTPRI_OFFSET);
-	val|=(priority)<< (group<<4);
-	ctrl_outl(val,addr+INTC2_INTPRI_OFFSET);
+
+	ipr=ctrl_inl(INTC2_BASE+INTC2_INTPRI_OFFSET+ipr_offset);
+	ipr&=~(0xf<<ipr_shift);
+	ipr|=(priority)<<ipr_shift;
+	ctrl_outl(ipr, INTC2_BASE+INTC2_INTPRI_OFFSET+ipr_offset);
+
 	local_irq_restore(flags);
 
 	irq_desc[irq].handler=&intc2_irq_type;
@@ -123,5 +151,72 @@
 	disable_intc2_irq(irq);
 }
 
+#ifdef CONFIG_CPU_SUBTYPE_ST40
+
+struct intc2_init {
+	unsigned short irq;
+	unsigned char ipr_offset, ipr_shift;
+	unsigned char msk_offset, msk_shift;
+};
 
+static struct intc2_init intc2_init_data[]  __initdata = {
+	{64,  0,  0, 0,  0},	/* PCI serr */
+	{65,  0,  4, 0,  1},	/* PCI err */
+	{66,  0,  4, 0,  2},	/* PCI ad */
+	{67,  0,  4, 0,  3},	/* PCI pwd down */
+	{72,  0,  8, 0,  5},	/* DMAC INT0 */
+	{73,  0,  8, 0,  6},	/* DMAC INT1 */
+	{74,  0,  8, 0,  7},	/* DMAC INT2 */
+	{75,  0,  8, 0,  8},	/* DMAC INT3 */
+	{76,  0,  8, 0,  9},	/* DMAC INT4 */
+	{78,  0,  8, 0, 11},	/* DMAC ERR */
+	{80,  0, 12, 0, 12},	/* PIO0 */
+	{84,  0, 16, 0, 13},	/* PIO1 */
+	{88,  0, 20, 0, 14},	/* PIO2 */
+	{112, 4,  0, 4,  0},	/* Mailbox */
+#ifdef CONFIG_CPU_SUBTYPE_ST40GX1
+	{116, 4,  4, 4,  4},	/* SSC0 */
+	{120, 4,  8, 4,  8},	/* IR Blaster */
+	{124, 4, 12, 4, 12},	/* USB host */
+	{128, 4, 16, 4, 16},	/* Video processor BLITTER */
+	{132, 4, 20, 4, 20},	/* UART0 */
+	{134, 4, 20, 4, 22},	/* UART2 */
+	{136, 4, 24, 4, 24},	/* IO_PIO0 */
+	{140, 4, 28, 4, 28},	/* EMPI */
+	{144, 8,  0, 8,  0},	/* MAFE */
+	{148, 8,  4, 8,  4},	/* PWM */
+	{152, 8,  8, 8,  8},	/* SSC1 */
+	{156, 8, 12, 8, 12},	/* IO_PIO1 */
+	{160, 8, 16, 8, 16},	/* USB target */
+	{164, 8, 20, 8, 20},	/* UART1 */
+	{168, 8, 24, 8, 24},	/* Teletext */
+	{172, 8, 28, 8, 28},	/* VideoSync VTG */
+	{173, 8, 28, 8, 29},	/* VideoSync DVP0 */
+	{174, 8, 28, 8, 30},	/* VideoSync DVP1 */
+#endif
+};
+
+void __init init_IRQ_intc2(void)
+{
+	struct intc2_init *p;
+
+	printk(KERN_ALERT "init_IRQ_intc2\n");
+
+	for (p = intc2_init_data;
+	     p<intc2_init_data+ARRAY_SIZE(intc2_init_data);
+	     p++) {
+		make_intc2_irq(p->irq, p->ipr_offset, p->ipr_shift,
+			       p-> msk_offset, p->msk_shift, 13);
+	}
+}
+
+/* Adds a termination callback to the interrupt */
+void intc2_add_clear_irq(int irq, int (*fn)(int))
+{
+	if (irq < INTC2_FIRST_IRQ)
+		return;
+
+	intc2_data[irq - INTC2_FIRST_IRQ].clear_irq = fn;
+}
 
+#endif /* CONFIG_CPU_SUBTYPE_ST40 */
diff -Nru a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/kernel/cpu/sh4/probe.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,138 @@
+/*
+ * arch/sh/kernel/cpu/sh4/probe.c
+ *
+ * CPU Subtype Probing for SH-4.
+ *
+ * Copyright (C) 2001, 2002, 2003, 2004  Paul Mundt
+ * Copyright (C) 2003  Richard Curnow
+ *
+ * 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 <linux/init.h>
+#include <asm/processor.h>
+#include <asm/cache.h>
+#include <asm/io.h>
+
+int __init detect_cpu_and_cache_system(void)
+{
+	unsigned long pvr, prr, cvr;
+	unsigned long size;
+
+	static unsigned long sizes[16] = {
+		[1] = (1 << 12),
+		[2] = (1 << 13),
+		[4] = (1 << 14),
+		[8] = (1 << 15),
+		[9] = (1 << 16)
+	};
+
+	pvr = (ctrl_inl(CCN_PVR) >> 8) & 0xffff;
+	prr = (ctrl_inl(CCN_PRR) >> 4) & 0xff;
+	cvr = (ctrl_inl(CCN_CVR));
+
+	/*
+	 * Setup some sane SH-4 defaults for the icache
+	 */
+	cpu_data->icache.way_incr	= (1 << 13);
+	cpu_data->icache.entry_shift	= 5;
+	cpu_data->icache.entry_mask	= 0x1fe0;
+	cpu_data->icache.sets		= 256;
+	cpu_data->icache.ways		= 1;
+	cpu_data->icache.linesz		= L1_CACHE_BYTES;
+
+	/*
+	 * And again for the dcache ..
+	 */
+	cpu_data->dcache.way_incr	= (1 << 14);
+	cpu_data->dcache.entry_shift	= 5;
+	cpu_data->dcache.entry_mask	= 0x3fe0;
+	cpu_data->dcache.sets		= 512;
+	cpu_data->dcache.ways		= 1;
+	cpu_data->dcache.linesz		= L1_CACHE_BYTES;
+
+	/* Set the FPU flag, virtually all SH-4's have one */
+	cpu_data->flags |= CPU_HAS_FPU;
+
+	/*
+	 * Probe the underlying processor version/revision and
+	 * adjust cpu_data setup accordingly.
+	 */
+	switch (pvr) {
+	case 0x205:
+		cpu_data->type = CPU_SH7750;
+		cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_PERF_COUNTER;
+		break;
+	case 0x206:
+		cpu_data->type = CPU_SH7750S;
+		cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_PERF_COUNTER;
+		break;
+	case 0x1100:
+		cpu_data->type = CPU_SH7751;
+		break;
+	case 0x2000:
+		cpu_data->type = CPU_SH73180;
+		cpu_data->icache.ways = 4;
+		cpu_data->dcache.ways = 4;
+		cpu_data->flags &= ~CPU_HAS_FPU;
+		break;
+	case 0x8000:
+		cpu_data->type = CPU_ST40RA;
+		break;
+	case 0x8100:
+		cpu_data->type = CPU_ST40GX1;
+		break;
+	case 0x700:
+		cpu_data->type = CPU_SH4_501;
+		cpu_data->icache.ways = 2;
+		cpu_data->dcache.ways = 2;
+
+		/* No FPU on the SH4-500 series.. */
+		cpu_data->flags &= ~CPU_HAS_FPU;
+		break;
+	case 0x600:
+		cpu_data->type = CPU_SH4_202;
+		cpu_data->icache.ways = 2;
+		cpu_data->dcache.ways = 2;
+		break;
+	case 0x500 ... 0x501:
+		switch (prr) {
+		    case 0x10: cpu_data->type = CPU_SH7750R; break;
+		    case 0x11: cpu_data->type = CPU_SH7751R; break;
+		    case 0x50: cpu_data->type = CPU_SH7760;  break;
+		}
+
+		cpu_data->icache.ways = 2;
+		cpu_data->dcache.ways = 2;
+
+		break;
+	default:
+		cpu_data->type = CPU_SH_NONE;
+		break;
+	}
+
+	/*
+	 * On anything that's not a direct-mapped cache, look to the CVR
+	 * for I/D-cache specifics.
+	 */
+	if (cpu_data->icache.ways > 1) {
+		size = sizes[(cvr >> 20) & 0xf];
+		cpu_data->icache.way_incr	= (size >> 1);
+		cpu_data->icache.sets		= (size >> 6);
+		cpu_data->icache.entry_mask	=
+			(cpu_data->icache.way_incr - (1 << 5));
+	}
+
+	if (cpu_data->dcache.ways > 1) {
+		size = sizes[(cvr >> 16) & 0xf];
+		cpu_data->dcache.way_incr	= (size >> 1);
+		cpu_data->dcache.sets		= (size >> 6);
+		cpu_data->dcache.entry_mask	=
+			(cpu_data->dcache.way_incr - (1 << 5));
+	}
+
+	return 0;
+}
+
diff -Nru a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
--- a/arch/sh/kernel/cpu/sh4/sq.c	2004-12-24 13:36:48 -08:00
+++ b/arch/sh/kernel/cpu/sh4/sq.c	2004-12-24 13:36:48 -08:00
@@ -36,7 +36,6 @@
 
 /**
  * sq_flush - Flush (prefetch) the store queue cache
- *
  * @addr: the store queue address to flush
  *
  * Executes a prefetch instruction on the specified store queue cache,
@@ -49,7 +48,6 @@
 
 /**
  * sq_flush_range - Flush (prefetch) a specific SQ range
- *
  * @start: the store queue address to start flushing from
  * @len: the length to flush
  *
@@ -99,7 +97,7 @@
 {
 	if (!list_empty(&sq_mapping_list)) {
 		struct list_head *pos, *tmp;
-		
+
 		/*
 		 * Read one off the list head, as it will have the highest
 		 * mapped allocation. Set the next one up right above it.
@@ -126,11 +124,10 @@
 
 /**
  * __sq_remap - Perform a translation from the SQ to a phys addr
+ * @map: sq mapping containing phys and store queue addresses.
  *
- * @phys: Physical address to map store queues too.
- * @virt: Associated store queue address.
- *
- * Maps the store queue address @virt to the physical address @phys.
+ * Maps the store queue address specified in the mapping to the physical
+ * address specified in the mapping.
  */
 static struct sq_mapping *__sq_remap(struct sq_mapping *map)
 {
@@ -210,7 +207,6 @@
 
 /**
  * sq_remap - Map a physical address through the Store Queues
- *
  * @phys: Physical address of mapping.
  * @size: Length of mapping.
  * @name: User invoking mapping.
@@ -254,7 +250,6 @@
 
 /**
  * sq_unmap - Unmap a Store Queue allocation
- *
  * @map: Pre-allocated Store Queue mapping.
  *
  * Unmaps the store queue allocation @map that was previously created by
@@ -272,7 +267,6 @@
 
 /**
  * sq_clear - Clear a store queue range
- *
  * @addr: Address to start clearing from.
  * @len: Length to clear.
  *
@@ -282,7 +276,7 @@
 void sq_clear(unsigned long addr, unsigned int len)
 {
 	int i;
-	
+
 	/* Clear out both queues linearly */
 	for (i = 0; i < 8; i++) {
 		ctrl_outl(0, addr + i + 0);
@@ -294,7 +288,6 @@
 
 /**
  * sq_vma_unmap - Unmap a VMA range
- *
  * @area: VMA containing range.
  * @addr: Start of range.
  * @len: Length of range.
@@ -314,25 +307,24 @@
 		entry = list_entry(pos, typeof(*entry), list);
 
 		if (entry->sq_addr == addr) {
-			/* 
+			/*
 			 * We could probably get away without doing the tlb flush
 			 * here, as generic code should take care of most of this
 			 * when unmapping the rest of the VMA range for us. Leave
 			 * it in for added sanity for the time being..
 			 */
 			__flush_tlb_page(get_asid(), entry->sq_addr & PAGE_MASK);
-			
+
 			list_del(&entry->list);
 			kfree(entry);
 
 			return;
-		}	
+		}
 	}
 }
 
 /**
  * sq_vma_sync - Sync a VMA range
- *
  * @area: VMA containing range.
  * @start: Start of range.
  * @len: Length of range.
@@ -359,7 +351,6 @@
 
 /**
  * sq_mmap - mmap() for /dev/cpu/sq
- *
  * @file: unused.
  * @vma: VMA to remap.
  *
@@ -373,7 +364,7 @@
 	unsigned long size = vma->vm_end - vma->vm_start;
 	struct sq_mapping *map;
 
-	/* 
+	/*
 	 * We're not interested in any arbitrary virtual address that has
 	 * been stuck in the VMA, as we already know what addresses we
 	 * want. Save off the size, and reposition the VMA to begin at
@@ -391,7 +382,7 @@
 	if (io_remap_page_range(vma, map->sq_addr, map->addr,
 				size, vma->vm_page_prot))
 		return -EAGAIN;
-	
+
 	vma->vm_ops = &sq_vma_ops;
 
 	return 0;
@@ -406,7 +397,7 @@
 
 	list_for_each_prev(pos, &sq_mapping_list) {
 		struct sq_mapping *entry;
-		
+
 		entry = list_entry(pos, typeof(*entry), list);
 
 		p += sprintf(p, "%08lx-%08lx [%08lx]: %s\n", entry->sq_addr,
diff -Nru a/arch/sh/kernel/early_printk.c b/arch/sh/kernel/early_printk.c
--- a/arch/sh/kernel/early_printk.c	2004-12-24 13:37:44 -08:00
+++ b/arch/sh/kernel/early_printk.c	2004-12-24 13:37:44 -08:00
@@ -3,6 +3,7 @@
  *
  *  Copyright (C) 1999, 2000  Niibe Yutaka
  *  Copyright (C) 2002  M. R. Brown
+ *  Copyright (C) 2004  Paul Mundt
  *
  * 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
@@ -109,7 +110,8 @@
 	ctrl_outw(0, SCIF_REG);
 
 	/* Set baud rate */
-	ctrl_outb((50000000 / (32 * baud)) - 1, SCIF_REG + 4);
+	ctrl_outb((CONFIG_SH_PCLK_FREQ + 16 * baud) /
+		  (32 * baud) - 1, SCIF_REG + 4);
 
 	ctrl_outw(12, SCIF_REG + 24);
 	ctrl_outw(8, SCIF_REG + 24);
diff -Nru a/arch/sh/kernel/entry.S b/arch/sh/kernel/entry.S
--- a/arch/sh/kernel/entry.S	2004-12-24 13:36:47 -08:00
+++ b/arch/sh/kernel/entry.S	2004-12-24 13:36:47 -08:00
@@ -14,6 +14,7 @@
 #include <linux/sys.h>
 #include <linux/linkage.h>
 #include <linux/config.h>
+#include <asm/asm-offsets.h>
 #include <asm/thread_info.h>
 #include <asm/unistd.h>
 
@@ -1139,5 +1140,10 @@
 	.long sys_mq_timedreceive       /* 280 */
 	.long sys_mq_notify
 	.long sys_mq_getsetattr
+	.long sys_ni_syscall	/* Reserved for kexec */
+	.long sys_waitid
+	.long sys_add_key		/* 285 */
+	.long sys_request_key
+	.long sys_keyctl
 
 /* End of entry.S */
diff -Nru a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
--- a/arch/sh/kernel/irq.c	2004-12-24 13:36:47 -08:00
+++ b/arch/sh/kernel/irq.c	2004-12-24 13:36:47 -08:00
@@ -31,10 +31,10 @@
 #include <linux/init.h>
 #include <linux/seq_file.h>
 #include <linux/kallsyms.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/pgalloc.h>
 #include <asm/delay.h>
 #include <asm/irq.h>
diff -Nru a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
--- a/arch/sh/kernel/process.c	2004-12-24 13:37:03 -08:00
+++ b/arch/sh/kernel/process.c	2004-12-24 13:37:03 -08:00
@@ -199,7 +199,7 @@
 
 void flush_thread(void)
 {
-#if defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_SH_FPU)
 	struct task_struct *tsk = current;
 	struct pt_regs *regs = (struct pt_regs *)
 				((unsigned long)tsk->thread_info
@@ -222,7 +222,7 @@
 {
 	int fpvalid = 0;
 
-#if defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_SH_FPU)
 	struct task_struct *tsk = current;
 
 	fpvalid = tsk->used_math;
@@ -259,7 +259,7 @@
 {
 	int fpvalid = 0;
 
-#if defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_SH_FPU)
 	fpvalid = tsk->used_math;
 	if (fpvalid) {
 		struct pt_regs *regs = (struct pt_regs *)
@@ -281,7 +281,7 @@
 		struct task_struct *p, struct pt_regs *regs)
 {
 	struct pt_regs *childregs;
-#if defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_SH_FPU)
 	struct task_struct *tsk = current;
 
 	unlazy_fpu(tsk, regs);
@@ -306,7 +306,6 @@
 		childregs->gbr = childregs->regs[0];
 	}
 	childregs->regs[0] = 0; /* Set return value for child */
-	p->set_child_tid = p->clear_child_tid = NULL;
 
 	p->thread.sp = (unsigned long) childregs;
 	p->thread.pc = (unsigned long) ret_from_fork;
@@ -363,7 +362,7 @@
  */
 struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next)
 {
-#if defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_SH_FPU)
 	struct pt_regs *regs = (struct pt_regs *)
 				((unsigned long)prev->thread_info
 				 + THREAD_SIZE - sizeof(struct pt_regs)
@@ -481,8 +480,11 @@
 			  (char __user * __user *)uargv,
 			  (char __user * __user *)uenvp,
 			  &regs);
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 out:
 	return error;
diff -Nru a/arch/sh/kernel/ptrace.c b/arch/sh/kernel/ptrace.c
--- a/arch/sh/kernel/ptrace.c	2004-12-24 13:36:18 -08:00
+++ b/arch/sh/kernel/ptrace.c	2004-12-24 13:36:18 -08:00
@@ -217,7 +217,7 @@
  */
 	case PTRACE_KILL: {
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		wake_up_process(child);
diff -Nru a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
--- a/arch/sh/kernel/setup.c	2004-12-24 13:37:00 -08:00
+++ b/arch/sh/kernel/setup.c	2004-12-24 13:37:00 -08:00
@@ -443,6 +443,7 @@
 	[CPU_SH7751]	= "SH7751",
 	[CPU_SH7751R]	= "SH7751R",
 	[CPU_SH7760]	= "SH7760",
+	[CPU_SH73180]	= "SH73180",
 	[CPU_ST40RA]	= "ST40RA",
 	[CPU_ST40GX1]	= "ST40GX1",
 	[CPU_SH4_202]	= "SH4-202",
@@ -457,7 +458,7 @@
 
 #ifdef CONFIG_PROC_FS
 static const char *cpu_flags[] = {
-	"none", "fpu", "p2flush", "mmuassoc", "dsp",
+	"none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr",
 };
 
 static void show_cpuflags(struct seq_file *m)
diff -Nru a/arch/sh/kernel/sh_bios.c b/arch/sh/kernel/sh_bios.c
--- a/arch/sh/kernel/sh_bios.c	2004-12-24 13:37:19 -08:00
+++ b/arch/sh/kernel/sh_bios.c	2004-12-24 13:37:19 -08:00
@@ -1,5 +1,4 @@
-/* $Id: sh_bios.c,v 1.2 2003/05/04 19:29:53 lethal Exp $
- *
+/*
  *  linux/arch/sh/kernel/sh_bios.c
  *  C interface for trapping into the standard LinuxSH BIOS.
  *
diff -Nru a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
--- a/arch/sh/kernel/sh_ksyms.c	2004-12-24 13:36:30 -08:00
+++ b/arch/sh/kernel/sh_ksyms.c	2004-12-24 13:36:30 -08:00
@@ -19,6 +19,7 @@
 #include <asm/delay.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
+#include <asm/checksum.h>
 
 extern void dump_thread(struct pt_regs *, struct user *);
 extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
@@ -86,7 +87,9 @@
 EXPORT_SYMBOL(__ndelay);
 EXPORT_SYMBOL(__const_udelay);
 
-#define DECLARE_EXPORT(name) extern void name(void);EXPORT_SYMBOL(name)
+EXPORT_SYMBOL(__div64_32);
+
+#define DECLARE_EXPORT(name) extern void name(void);EXPORT_SYMBOL_NOVERS(name)
 
 /* These symbols are generated by the compiler itself */
 DECLARE_EXPORT(__udivsi3);
@@ -97,8 +100,9 @@
 DECLARE_EXPORT(__lshrdi3);
 DECLARE_EXPORT(__movstr);
 
+EXPORT_SYMBOL_NOVERS(strcpy);
+
 #ifdef CONFIG_CPU_SH4
- 
 DECLARE_EXPORT(__movstr_i4_even);
 DECLARE_EXPORT(__movstr_i4_odd);
 DECLARE_EXPORT(__movstrSI12_i4);
@@ -109,6 +113,14 @@
 EXPORT_SYMBOL(flush_dcache_page);
 EXPORT_SYMBOL(__flush_purge_region);
 #endif
+
+#if defined(CONFIG_SH7705_CACHE_32KB)
+EXPORT_SYMBOL(flush_cache_all);
+EXPORT_SYMBOL(flush_cache_range);
+EXPORT_SYMBOL(flush_dcache_page);
+EXPORT_SYMBOL(__flush_purge_region);
+#endif
+
 EXPORT_SYMBOL(flush_tlb_page);
 EXPORT_SYMBOL(__down_trylock);
 
@@ -117,4 +129,6 @@
 #endif
 
 EXPORT_SYMBOL(csum_partial);
+EXPORT_SYMBOL(csum_ipv6_magic);
 EXPORT_SYMBOL(consistent_sync);
+EXPORT_SYMBOL(clear_page);
diff -Nru a/arch/sh/kernel/signal.c b/arch/sh/kernel/signal.c
--- a/arch/sh/kernel/signal.c	2004-12-24 13:37:43 -08:00
+++ b/arch/sh/kernel/signal.c	2004-12-24 13:37:43 -08:00
@@ -1,4 +1,4 @@
-/* $Id: signal.c,v 1.20 2004/01/13 05:52:11 kkojima Exp $
+/* $Id: signal.c,v 1.21 2004/06/28 13:18:44 doyu Exp $
  *
  *  linux/arch/sh/kernel/signal.c
  *
@@ -155,7 +155,7 @@
 	u16 retcode[8];
 };
 
-#ifdef CONFIG_CPU_SH4
+#ifdef CONFIG_SH_FPU
 static inline int restore_sigcontext_fpu(struct sigcontext __user *sc)
 {
 	struct task_struct *tsk = current;
@@ -192,7 +192,7 @@
 	return __copy_to_user(&sc->sc_fpregs[0], &tsk->thread.fpu.hard,
 			      sizeof(long)*(16*2+2));
 }
-#endif /* CONFIG_CPU_SH4 */
+#endif /* CONFIG_SH_FPU */
 
 static int
 restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
@@ -213,7 +213,7 @@
 	COPY(sr);	COPY(pc);
 #undef COPY
 
-#ifdef CONFIG_CPU_SH4
+#ifdef CONFIG_SH_FPU
 	if (cpu_data->flags & CPU_HAS_FPU) {
 		int owned_fp;
 		struct task_struct *tsk = current;
@@ -326,7 +326,7 @@
 	COPY(sr);	COPY(pc);
 #undef COPY
 
-#ifdef CONFIG_CPU_SH4
+#ifdef CONFIG_SH_FPU
 	err |= save_sigcontext_fpu(sc, regs);
 #endif
 
@@ -493,14 +493,12 @@
 
 /*
  * OK, we're invoking a handler
- */	
+ */
 
 static void
-handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset,
-	struct pt_regs * regs)
+handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
+	      sigset_t *oldset, struct pt_regs *regs)
 {
-	struct k_sigaction *ka = &current->sighand->action[sig-1];
-
 	/* Are we from a system call? */
 	if (regs->tra >= 0) {
 		/* If so, check system call restarting.. */
@@ -570,6 +568,7 @@
 {
 	siginfo_t info;
 	int signr;
+	struct k_sigaction ka;
 
 	/*
 	 * We want the common case to go fast, which
@@ -588,10 +587,10 @@
 	if (!oldset)
 		oldset = &current->blocked;
 
-	signr = get_signal_to_deliver(&info, regs, NULL);
+	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
 	if (signr > 0) {
 		/* Whee!  Actually deliver the signal.  */
-		handle_signal(signr, &info, oldset, regs);
+		handle_signal(signr, &ka, &info, oldset, regs);
 		return 1;
 	}
 
diff -Nru a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
--- a/arch/sh/kernel/time.c	2004-12-24 13:36:16 -08:00
+++ b/arch/sh/kernel/time.c	2004-12-24 13:36:16 -08:00
@@ -1,6 +1,5 @@
-/* $Id: time.c,v 1.21 2004/04/21 00:09:15 lethal Exp $
- *
- *  linux/arch/sh/kernel/time.c
+/*
+ *  arch/sh/kernel/time.c
  *
  *  Copyright (C) 1999  Tetsuya Okada & Niibe Yutaka
  *  Copyright (C) 2000  Philipp Rumpf <prumpf@tux.org>
@@ -96,8 +95,8 @@
 void (*rtc_get_time)(struct timespec *) = sh_rtc_gettimeofday;
 int (*rtc_set_time)(const time_t) = sh_rtc_settimeofday;
 #else
-void (*rtc_get_time)(struct timespec *) = 0;
-int (*rtc_set_time)(const time_t) = 0;
+void (*rtc_get_time)(struct timespec *);
+int (*rtc_set_time)(const time_t);
 #endif
 
 #if defined(CONFIG_CPU_SUBTYPE_SH7300)
@@ -113,12 +112,21 @@
 static int pfc_divisors[]    = { 1, 2, 3, 4, 6, 1, 1, 1 };
 static int pfc_values[]      = { 0, 1, 4, 2, 5, 0, 0, 0 };
 #elif defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_CPU_SUBTYPE_SH73180)
+static int ifc_divisors[] = { 1, 2, 3, 4, 6, 8, 12, 16 };
+static int ifc_values[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+#define bfc_divisors ifc_divisors	/* Same */
+#define bfc_values ifc_values
+#define pfc_divisors ifc_divisors	/* Same */
+#define pfc_values ifc_values
+#else
 static int ifc_divisors[] = { 1, 2, 3, 4, 6, 8, 1, 1 };
 static int ifc_values[]   = { 0, 1, 2, 3, 0, 4, 0, 5 };
 #define bfc_divisors ifc_divisors	/* Same */
 #define bfc_values ifc_values
 static int pfc_divisors[] = { 2, 3, 4, 6, 8, 2, 2, 2 };
 static int pfc_values[]   = { 0, 0, 1, 2, 0, 3, 0, 4 };
+#endif
 #else
 #error "Unknown ifc/bfc/pfc/stc values for this processor"
 #endif
@@ -140,7 +148,7 @@
 	static unsigned long jiffies_p = 0;
 
 	/*
-	 * cache volatile jiffies temporarily; we have IRQs turned off. 
+	 * cache volatile jiffies temporarily; we have IRQs turned off.
 	 */
 	unsigned long jiffies_t;
 
@@ -148,7 +156,7 @@
 	/* timer count may underflow right here */
 	count = ctrl_inl(TMU0_TCNT);	/* read the latched count */
 
- 	jiffies_t = jiffies;
+	jiffies_t = jiffies;
 
 	/*
 	 * avoiding timer inconsistencies (they are rare, but they happen)...
@@ -162,7 +170,7 @@
 
 			if(ctrl_inw(TMU0_TCR) & 0x100) { /* Check UNF bit */
 				/*
-				 * We cannot detect lost timer interrupts ... 
+				 * We cannot detect lost timer interrupts ...
 				 * well, that's why we call them lost, don't we? :)
 				 * [hmm, on the Pentium and Alpha we can ... sort of]
 				 */
@@ -192,7 +200,7 @@
 	do {
 		seq = read_seqbegin(&xtime_lock);
 		usec = do_gettimeoffset();
-		
+
 		lost = jiffies - wall_jiffies;
 		if (lost)
 			usec += lost * (1000000 / HZ);
@@ -258,6 +266,9 @@
 static inline void do_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	profile_tick(CPU_PROFILING, regs);
 
 #ifdef CONFIG_HEARTBEAT
@@ -363,8 +374,8 @@
 	return freq * factor;
 }
 
-void (*board_time_init)(void) = 0;
-void (*board_timer_setup)(struct irqaction *irq) = 0;
+void (*board_time_init)(void);
+void (*board_timer_setup)(struct irqaction *irq);
 
 static unsigned int sh_pclk_freq __initdata = CONFIG_SH_PCLK_FREQ;
 
@@ -408,10 +419,16 @@
 	*pfc = pfc_divisors[tmp];
 #endif
 #elif defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_CPU_SUBTYPE_SH73180)
+	*ifc = ifc_divisors[(frqcr>> 20) & 0x0007];
+	*bfc = bfc_divisors[(frqcr>> 12) & 0x0007];
+	*pfc = pfc_divisors[frqcr & 0x0007];
+#else
 	*ifc = ifc_divisors[(frqcr >> 6) & 0x0007];
 	*bfc = bfc_divisors[(frqcr >> 3) & 0x0007];
 	*pfc = pfc_divisors[frqcr & 0x0007];
 #endif
+#endif
 }
 
 /*
@@ -419,7 +436,7 @@
  * the divisors and the physical values.
  */
 #define _FREQ_TABLE(x) \
-	unsigned int get_##x##_divisor(unsigned int value) 	\
+	unsigned int get_##x##_divisor(unsigned int value)	\
 		{ return x##_divisors[value]; }			\
 								\
 	unsigned int get_##x##_value(unsigned int divisor)	\
@@ -431,109 +448,120 @@
 
 #ifdef CONFIG_CPU_SUBTYPE_ST40STB1
 
-/* The ST40 divisors are totally different so we set the cpu data
-** clocks using a different algorithm
-**
-** I've just plugged this from the 2.4 code - Alex Bennee <kernel-hacker@bennee.com>
-*/
+/*
+ * The ST40 divisors are totally different so we set the cpu data
+ * clocks using a different algorithm
+ *
+ * I've just plugged this from the 2.4 code
+ *	- Alex Bennee <kernel-hacker@bennee.com>
+ */
 #define CCN_PVR_CHIP_SHIFT 24
 #define CCN_PVR_CHIP_MASK  0xff
 #define CCN_PVR_CHIP_ST40STB1 0x4
 
 
 struct frqcr_data {
-    unsigned short frqcr;
-    struct {
-	unsigned char multiplier;
-	unsigned char divisor;
-    } factor[3];
+	unsigned short frqcr;
+
+	struct {
+		unsigned char multiplier;
+		unsigned char divisor;
+	} factor[3];
 };
 
 static struct frqcr_data st40_frqcr_table[] = {
-    { 0x000, {{1,1}, {1,1}, {1,2}}},
-    { 0x002, {{1,1}, {1,1}, {1,4}}},
-    { 0x004, {{1,1}, {1,1}, {1,8}}},
-    { 0x008, {{1,1}, {1,2}, {1,2}}},
-    { 0x00A, {{1,1}, {1,2}, {1,4}}},
-    { 0x00C, {{1,1}, {1,2}, {1,8}}},
-    { 0x011, {{1,1}, {2,3}, {1,6}}},
-    { 0x013, {{1,1}, {2,3}, {1,3}}},
-    { 0x01A, {{1,1}, {1,2}, {1,4}}},
-    { 0x01C, {{1,1}, {1,2}, {1,8}}},
-    { 0x023, {{1,1}, {2,3}, {1,3}}},
-    { 0x02C, {{1,1}, {1,2}, {1,8}}},
-    { 0x048, {{1,2}, {1,2}, {1,4}}},
-    { 0x04A, {{1,2}, {1,2}, {1,6}}},
-    { 0x04C, {{1,2}, {1,2}, {1,8}}},
-    { 0x05A, {{1,2}, {1,3}, {1,6}}},
-    { 0x05C, {{1,2}, {1,3}, {1,6}}},
-    { 0x063, {{1,2}, {1,4}, {1,4}}},
-    { 0x06C, {{1,2}, {1,4}, {1,8}}},
-    { 0x091, {{1,3}, {1,3}, {1,6}}},
-    { 0x093, {{1,3}, {1,3}, {1,6}}},
-    { 0x0A3, {{1,3}, {1,6}, {1,6}}},
-    { 0x0DA, {{1,4}, {1,4}, {1,8}}},
-    { 0x0DC, {{1,4}, {1,4}, {1,8}}},
-    { 0x0EC, {{1,4}, {1,8}, {1,8}}},
-    { 0x123, {{1,4}, {1,4}, {1,8}}},
-    { 0x16C, {{1,4}, {1,8}, {1,8}}},
+	{ 0x000, {{1,1}, {1,1}, {1,2}}},
+	{ 0x002, {{1,1}, {1,1}, {1,4}}},
+	{ 0x004, {{1,1}, {1,1}, {1,8}}},
+	{ 0x008, {{1,1}, {1,2}, {1,2}}},
+	{ 0x00A, {{1,1}, {1,2}, {1,4}}},
+	{ 0x00C, {{1,1}, {1,2}, {1,8}}},
+	{ 0x011, {{1,1}, {2,3}, {1,6}}},
+	{ 0x013, {{1,1}, {2,3}, {1,3}}},
+	{ 0x01A, {{1,1}, {1,2}, {1,4}}},
+	{ 0x01C, {{1,1}, {1,2}, {1,8}}},
+	{ 0x023, {{1,1}, {2,3}, {1,3}}},
+	{ 0x02C, {{1,1}, {1,2}, {1,8}}},
+	{ 0x048, {{1,2}, {1,2}, {1,4}}},
+	{ 0x04A, {{1,2}, {1,2}, {1,6}}},
+	{ 0x04C, {{1,2}, {1,2}, {1,8}}},
+	{ 0x05A, {{1,2}, {1,3}, {1,6}}},
+	{ 0x05C, {{1,2}, {1,3}, {1,6}}},
+	{ 0x063, {{1,2}, {1,4}, {1,4}}},
+	{ 0x06C, {{1,2}, {1,4}, {1,8}}},
+	{ 0x091, {{1,3}, {1,3}, {1,6}}},
+	{ 0x093, {{1,3}, {1,3}, {1,6}}},
+	{ 0x0A3, {{1,3}, {1,6}, {1,6}}},
+	{ 0x0DA, {{1,4}, {1,4}, {1,8}}},
+	{ 0x0DC, {{1,4}, {1,4}, {1,8}}},
+	{ 0x0EC, {{1,4}, {1,8}, {1,8}}},
+	{ 0x123, {{1,4}, {1,4}, {1,8}}},
+	{ 0x16C, {{1,4}, {1,8}, {1,8}}},
 };
 
 struct memclk_data {
-    unsigned char multiplier;
-    unsigned char divisor;
+	unsigned char multiplier;
+	unsigned char divisor;
 };
+
 static struct memclk_data st40_memclk_table[8] = {
-    {1,1},	// 000
-    {1,2},	// 001
-    {1,3},	// 010
-    {2,3},	// 011
-    {1,4},	// 100
-    {1,6},	// 101
-    {1,8},	// 110
-    {1,8}	// 111
+	{1,1},	// 000
+	{1,2},	// 001
+	{1,3},	// 010
+	{2,3},	// 011
+	{1,4},	// 100
+	{1,6},	// 101
+	{1,8},	// 110
+	{1,8}	// 111
 };
 
 static void st40_specific_time_init(unsigned int module_clock, unsigned short frqcr)
 {
-    unsigned int cpu_clock, master_clock, bus_clock, memory_clock;
-    struct frqcr_data *d;
-    int a;
-    unsigned long memclkcr;
-    struct memclk_data *e;
-
-    for (a=0; a<ARRAY_SIZE(st40_frqcr_table); a++) {
-	d = &st40_frqcr_table[a];
-	if (d->frqcr == (frqcr & 0x1ff))
-	    break;
-    }
-    if (a == ARRAY_SIZE(st40_frqcr_table)) {
-	d = st40_frqcr_table;
-	printk("ERROR: Unrecognised FRQCR value (0x%x), using default multipliers\n",frqcr);
-    }
-
-    memclkcr = ctrl_inl(CLOCKGEN_MEMCLKCR);
-    e = &st40_memclk_table[memclkcr & MEMCLKCR_RATIO_MASK];
-
-    printk("Clock multipliers: CPU: %d/%d Bus: %d/%d Mem: %d/%d Periph: %d/%d\n",
-	    d->factor[0].multiplier, d->factor[0].divisor,
-	    d->factor[1].multiplier, d->factor[1].divisor,
-	    e->multiplier,           e->divisor,
-	    d->factor[2].multiplier, d->factor[2].divisor);
-
-    master_clock = module_clock * d->factor[2].divisor    / d->factor[2].multiplier;
-    bus_clock    = master_clock * d->factor[1].multiplier / d->factor[1].divisor;
-    memory_clock = master_clock * e->multiplier           / e->divisor;
-    cpu_clock    = master_clock * d->factor[0].multiplier / d->factor[0].divisor;
-
-    current_cpu_data.cpu_clock    = cpu_clock;
-    current_cpu_data.master_clock = master_clock;
-    current_cpu_data.bus_clock    = bus_clock;
-    current_cpu_data.memory_clock = memory_clock;
-    current_cpu_data.module_clock = module_clock;
+	unsigned int cpu_clock, master_clock, bus_clock, memory_clock;
+	struct frqcr_data *d;
+	int a;
+	unsigned long memclkcr;
+	struct memclk_data *e;
 
-}
+	for (a = 0; a < ARRAY_SIZE(st40_frqcr_table); a++) {
+		d = &st40_frqcr_table[a];
+
+		if (d->frqcr == (frqcr & 0x1ff))
+			break;
+	}
+
+	if (a == ARRAY_SIZE(st40_frqcr_table)) {
+		d = st40_frqcr_table;
+
+		printk("ERROR: Unrecognised FRQCR value (0x%x), "
+		       "using default multipliers\n", frqcr);
+	}
 
+	memclkcr = ctrl_inl(CLOCKGEN_MEMCLKCR);
+	e = &st40_memclk_table[memclkcr & MEMCLKCR_RATIO_MASK];
+
+	printk(KERN_INFO "Clock multipliers: CPU: %d/%d Bus: %d/%d "
+	       "Mem: %d/%d Periph: %d/%d\n",
+	       d->factor[0].multiplier, d->factor[0].divisor,
+	       d->factor[1].multiplier, d->factor[1].divisor,
+	       e->multiplier,           e->divisor,
+	       d->factor[2].multiplier, d->factor[2].divisor);
+
+	master_clock = module_clock * d->factor[2].divisor
+				    / d->factor[2].multiplier;
+	bus_clock    = master_clock * d->factor[1].multiplier
+				    / d->factor[1].divisor;
+	memory_clock = master_clock * e->multiplier
+				    / e->divisor;
+	cpu_clock    = master_clock * d->factor[0].multiplier
+				    / d->factor[0].divisor;
+
+	current_cpu_data.cpu_clock    = cpu_clock;
+	current_cpu_data.master_clock = master_clock;
+	current_cpu_data.bus_clock    = bus_clock;
+	current_cpu_data.memory_clock = memory_clock;
+	current_cpu_data.module_clock = module_clock;
+}
 #endif
 
 void __init time_init(void)
@@ -549,7 +577,6 @@
 	if (board_time_init)
 		board_time_init();
 
-
 	/*
 	 * If we don't have an RTC (such as with the SH7300), don't attempt to
 	 * probe the timer frequency. Rely on an either hardcoded peripheral
@@ -564,15 +591,10 @@
 	{
 		unsigned int freq;
 
-		/* 
+		/*
 		 * If we've specified a peripheral clock frequency, and we have
 		 * an RTC, compare it against the autodetected value. Complain
 		 * if there's a mismatch.
-		 *
-		 * Note: We should allow for some high and low watermarks for
-		 * the frequency here (compensating for potential drift), as
-		 * otherwise we'll likely end up triggering this essentially
-		 * on every boot.
 		 */
 		timer_freq = get_timer_frequency();
 		freq = timer_freq * 4;
@@ -587,20 +609,22 @@
 #endif
 
 #ifdef CONFIG_CPU_SUBTYPE_ST40STB1
+	/* XXX: Update ST40 code to use board_time_init() */
 	pvr = ctrl_inl(CCN_PVR);
 	frqcr = ctrl_inw(FRQCR);
 	printk("time.c ST40 Probe: PVR %08lx, FRQCR %04hx\n", pvr, frqcr);
-	if (((pvr >>CCN_PVR_CHIP_SHIFT) & CCN_PVR_CHIP_MASK) == CCN_PVR_CHIP_ST40STB1)
-	    st40_specific_time_init(current_cpu_data.module_clock, frqcr);
+
+	if (((pvr >> CCN_PVR_CHIP_SHIFT) & CCN_PVR_CHIP_MASK) == CCN_PVR_CHIP_ST40STB1)
+		st40_specific_time_init(current_cpu_data.module_clock, frqcr);
 	else
 #endif
-	    get_current_frequency_divisors(&ifc, &bfc, &pfc);
+		get_current_frequency_divisors(&ifc, &bfc, &pfc);
 
-	if (rtc_get_time)
+	if (rtc_get_time) {
 		rtc_get_time(&xtime);
-	else {
-         	xtime.tv_sec = mktime(2000, 1, 1, 0, 0, 0);
-         	xtime.tv_nsec = 0;
+	} else {
+		xtime.tv_sec = mktime(2000, 1, 1, 0, 0, 0);
+		xtime.tv_nsec = 0;
 	}
 
         set_normalized_timespec(&wall_to_monotonic,
@@ -613,9 +637,9 @@
 	}
 
 	/*
-	** for ST40 chips the current_cpu_data should already be set
-	** so not having valid pfc/bfc/ifc shouldn't be a problem
-	*/
+	 * for ST40 chips the current_cpu_data should already be set
+	 * so not having valid pfc/bfc/ifc shouldn't be a problem
+	 */
 	if (!current_cpu_data.master_clock)
 		current_cpu_data.master_clock = current_cpu_data.module_clock * pfc;
 	if (!current_cpu_data.bus_clock)
@@ -637,11 +661,8 @@
 	printk("Module clock: %d.%02dMHz\n",
 	       (current_cpu_data.module_clock / 1000000),
 	       (current_cpu_data.module_clock % 1000000)/10000);
-#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
-	interval = ((current_cpu_data.module_clock/4 + HZ/2) / HZ) - 1;
-#else
+
 	interval = (current_cpu_data.module_clock/4 + HZ/2) / HZ;
-#endif
 
 	printk("Interval = %ld\n", interval);
 
diff -Nru a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c
--- a/arch/sh/kernel/traps.c	2004-12-24 13:36:17 -08:00
+++ b/arch/sh/kernel/traps.c	2004-12-24 13:36:17 -08:00
@@ -438,7 +438,7 @@
 		case 0x0F00: /* bf/s lab */
 			ret = handle_unaligned_delayslot(regs);
 			if (ret==0) {
-#if defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
 				if ((regs->sr & 0x00000001) != 0)
 					regs->pc += 4; /* next after slot */
 				else
@@ -451,7 +451,7 @@
 		case 0x0D00: /* bt/s lab */
 			ret = handle_unaligned_delayslot(regs);
 			if (ret==0) {
-#if defined(CONFIG_CPU_SH4)
+#if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
 				if ((regs->sr & 0x00000001) == 0)
 					regs->pc += 4; /* next after slot */
 				else
diff -Nru a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile
--- a/arch/sh/lib/Makefile	2004-12-24 13:36:49 -08:00
+++ b/arch/sh/lib/Makefile	2004-12-24 13:36:49 -08:00
@@ -2,6 +2,12 @@
 # Makefile for SuperH-specific library files..
 #
 
-lib-y  = delay.o memcpy.o memset.o memmove.o memchr.o \
+lib-y  = delay.o memset.o memmove.o memchr.o \
 	 checksum.o strcasecmp.o strlen.o div64.o udivdi3.o \
 	 div64-generic.o
+
+memcpy-y			:= memcpy.o
+memcpy-$(CONFIG_CPU_SH4)	:= memcpy-sh4.o
+
+lib-y	+= $(memcpy-y)
+
diff -Nru a/arch/sh/lib/memcpy-sh4.S b/arch/sh/lib/memcpy-sh4.S
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/lib/memcpy-sh4.S	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,800 @@
+/*
+ * "memcpy" implementation of SuperH
+ *
+ * Copyright (C) 1999  Niibe Yutaka
+ * Copyright (c) 2002  STMicroelectronics Ltd
+ *   Modified from memcpy.S and micro-optimised for SH4
+ *   Stuart Menefy (stuart.menefy@st.com)
+ *
+ */
+#include <linux/linkage.h>
+#include <linux/config.h>
+
+/*
+ * void *memcpy(void *dst, const void *src, size_t n);
+ *
+ * It is assumed that there is no overlap between src and dst.
+ * If there is an overlap, then the results are undefined.
+ */
+
+	!
+	!	GHIJ KLMN OPQR -->  ...G HIJK LMNO PQR.
+	!
+
+	! Size is 16 or greater, and may have trailing bytes
+
+	.balign	32
+.Lcase1:
+	! Read a long word and write a long word at once
+	! At the start of each iteration, r7 contains last long load
+	add	#-1,r5		!  79 EX
+	mov	r4,r2		!   5 MT (0 cycles latency)
+
+	mov.l	@(r0,r5),r7	!  21 LS (2 cycles latency)
+	add	#-4,r5		!  50 EX
+
+	add	#7,r2		!  79 EX
+	!
+#ifdef CONFIG_CPU_LITTLE_ENDIAN
+	! 6 cycles, 4 bytes per iteration
+3:	mov.l	@(r0,r5),r1	!  21 LS (latency=2)	! NMLK
+	mov	r7, r3		!   5 MT (latency=0)	! RQPO
+
+	cmp/hi	r2,r0		!  57 MT
+	shll16	r3		! 103 EX
+
+	mov	r1,r6		!   5 MT (latency=0)
+	shll8	r3		! 102 EX		! Oxxx
+
+	shlr8	r6		! 106 EX		! xNML
+	mov	r1, r7		!   5 MT (latency=0)
+
+	or	r6,r3		!  82 EX		! ONML
+	bt/s	3b		! 109 BR
+
+	 mov.l	r3,@-r0		!  30 LS
+#else
+3:	mov.l	@(r0,r5),r1	!  21 LS (latency=2)	! KLMN
+	mov	r7,r3		!   5 MT (latency=0)	! OPQR
+
+	cmp/hi	r2,r0		!  57 MT
+	shlr16	r3		! 107 EX
+
+	shlr8	r3		! 106 EX		! xxxO
+	mov	r1,r6		!   5 MT (latency=0)
+
+	shll8	r6		! 102 EX		! LMNx
+	mov	r1,r7		!   5 MT (latency=0)
+
+	or	r6,r3		!  82 EX		! LMNO
+	bt/s	3b		! 109 BR
+
+	 mov.l	r3,@-r0		!  30 LS
+#endif
+	! Finally, copy a byte at once, if necessary
+
+	add	#4,r5		!  50 EX
+	cmp/eq	r4,r0		!  54 MT
+
+	add	#-6,r2		!  50 EX
+	bt	9f		! 109 BR
+
+8:	cmp/hi	r2,r0		!  57 MT
+	mov.b	@(r0,r5),r1	!  20 LS (latency=2)
+
+	bt/s	8b		! 109 BR
+
+	 mov.b	r1,@-r0		!  29 LS
+
+9:	rts
+	 nop
+
+
+	!
+	!	GHIJ KLMN OPQR -->  .GHI JKLM NOPQ R...
+	!
+
+	! Size is 16 or greater, and may have trailing bytes
+
+	.balign	32
+.Lcase3:
+	! Read a long word and write a long word at once
+	! At the start of each iteration, r7 contains last long load
+	add	#-3,r5		! 79 EX
+	mov	r4,r2		!  5 MT (0 cycles latency)
+
+	mov.l	@(r0,r5),r7	! 21 LS (2 cycles latency)
+	add	#-4,r5		! 50 EX
+
+	add	#7,r2		!  79 EX
+	!
+#ifdef CONFIG_CPU_LITTLE_ENDIAN
+	! 6 cycles, 4 bytes per iteration
+3:	mov.l	@(r0,r5),r1	!  21 LS (latency=2)	! NMLK
+	mov	r7, r3		!   5 MT (latency=0)	! RQPO
+
+	cmp/hi	r2,r0		!  57 MT
+	shll8	r3		! 102 EX		! QPOx
+
+	mov	r1,r6		!   5 MT (latency=0)
+	shlr16	r6		! 107 EX
+
+	shlr8	r6		! 106 EX		! xxxN
+	mov	r1, r7		!   5 MT (latency=0)
+
+	or	r6,r3		!  82 EX		! QPON
+	bt/s	3b		! 109 BR
+
+	 mov.l	r3,@-r0		!  30 LS
+#else
+3:	mov	r1,r3		! OPQR
+	shlr8	r3		! xOPQ
+	mov.l	@(r0,r5),r1	! KLMN
+	mov	r1,r6
+	shll16	r6
+	shll8	r6		! Nxxx
+	or	r6,r3		! NOPQ
+	cmp/hi	r2,r0
+	bt/s	3b
+	 mov.l	r3,@-r0
+#endif
+
+	! Finally, copy a byte at once, if necessary
+
+	add	#6,r5		!  50 EX
+	cmp/eq	r4,r0		!  54 MT
+
+	add	#-6,r2		!  50 EX
+	bt	9f		! 109 BR
+
+8:	cmp/hi	r2,r0		!  57 MT
+	mov.b	@(r0,r5),r1	!  20 LS (latency=2)
+
+	bt/s	8b		! 109 BR
+
+	 mov.b	r1,@-r0		!  29 LS
+
+9:	rts
+	 nop
+
+ENTRY(memcpy)
+
+	! Calculate the invariants which will be used in the remainder
+	! of the code:
+	!
+	!      r4   -->  [ ...  ] DST             [ ...  ] SRC
+	!	         [ ...  ]                 [ ...  ]
+	!	           :                        :
+	!      r0   -->  [ ...  ]       r0+r5 --> [ ...  ]
+	!
+	!
+
+	! Short circuit the common case of src, dst and len being 32 bit aligned
+	! and test for zero length move
+
+	mov	r6, r0		!   5 MT (0 cycle latency)
+	or	r4, r0		!  82 EX
+
+	or	r5, r0		!  82 EX
+	tst	r6, r6		!  86 MT
+
+	bt/s	99f		! 111 BR		(zero len)
+	 tst	#3, r0		!  87 MT
+
+	mov	r4, r0		!   5 MT (0 cycle latency)
+	add	r6, r0		!  49 EX
+
+	mov	#16, r1		!   6 EX
+	bt/s	.Lcase00	! 111 BR		(aligned)
+
+	 sub	r4, r5		!  75 EX
+
+	! Arguments are not nicely long word aligned or zero len.
+	! Check for small copies, and if so do a simple byte at a time copy.
+	!
+	! Deciding on an exact value of 'small' is not easy, as the point at which
+	! using the optimised routines become worthwhile varies (these are the
+	! cycle counts for differnet sizes using byte-at-a-time vs. optimised):
+	!	size	byte-at-time	long	word	byte
+	!	16	42		39-40	46-50	50-55
+	!	24	58		43-44	54-58	62-67
+	!	36	82		49-50	66-70	80-85
+	! However the penalty for getting it 'wrong' is much higher for long word
+	! aligned data (and this is more common), so use a value of 16.
+
+	cmp/gt	r6,r1		!  56 MT
+
+	add	#-1,r5		!  50 EX
+	bf/s	6f		! 108 BR		(not small)
+
+	 mov	r5, r3		!   5 MT (latency=0)
+	shlr	r6		! 104 EX
+
+	mov.b	@(r0,r5),r1	!  20 LS (latency=2)
+	bf/s	4f		! 111 BR
+
+	 add	#-1,r3		!  50 EX
+	tst	r6, r6		!  86 MT
+
+	bt/s	98f		! 110 BR
+	 mov.b	r1,@-r0		!  29 LS
+
+	! 4 cycles, 2 bytes per iteration
+3:	mov.b	@(r0,r5),r1	!  20 LS (latency=2)
+
+4:	mov.b	@(r0,r3),r2	!  20 LS (latency=2)
+	dt	r6		!  67 EX
+
+	mov.b	r1,@-r0		!  29 LS
+	bf/s	3b		! 111 BR
+
+	 mov.b	r2,@-r0		!  29 LS
+98:
+	rts
+	 nop
+
+99:	rts
+	 mov	r4, r0
+
+	! Size is not small, so its worthwhile looking for optimisations.
+	! First align destination to a long word boundary.
+	!
+	! r5 = normal value -1
+
+6:	tst	#3, r0		!  87 MT
+        mov	#3, r3		!   6 EX
+
+	bt/s	2f		! 111 BR
+	 and	r0,r3		!  78 EX
+
+	! 3 cycles, 1 byte per iteration
+1:	dt	r3		!  67 EX
+	mov.b	@(r0,r5),r1	!  19 LS (latency=2)
+
+	add	#-1, r6		!  79 EX
+	bf/s	1b		! 109 BR
+
+	 mov.b	r1,@-r0		!  28 LS
+
+2:	add	#1, r5		!  79 EX
+
+	! Now select the appropriate bulk transfer code based on relative
+	! alignment of src and dst.
+
+	mov	r0, r3		!   5 MT (latency=0)
+
+	mov	r5, r0		!   5 MT (latency=0)
+	tst	#1, r0		!  87 MT
+
+	bf/s	1f		! 111 BR
+	 mov	#64, r7		!   6 EX
+
+	! bit 0 clear
+
+	cmp/ge	r7, r6		!  55 MT
+
+	bt/s	2f		! 111 BR
+	 tst	#2, r0		!  87 MT
+
+	! small
+	bt/s	.Lcase0
+	 mov	r3, r0
+
+	bra	.Lcase2
+	 nop
+
+	! big
+2:	bt/s	.Lcase0b
+	 mov	r3, r0
+
+	bra	.Lcase2b
+	 nop
+
+	! bit 0 set
+1:	tst	#2, r0		! 87 MT
+
+	bt/s	.Lcase1
+	 mov	r3, r0
+
+	bra	.Lcase3
+	 nop
+
+
+	!
+	!	GHIJ KLMN OPQR -->  GHIJ KLMN OPQR
+	!
+
+	! src, dst and size are all long word aligned
+	! size is non-zero
+
+	.balign	32
+.Lcase00:
+	mov	#64, r1		!   6 EX
+	mov	r5, r3		!   5 MT (latency=0)
+
+	cmp/gt	r6, r1		!  56 MT
+	add	#-4, r5		!  50 EX
+
+	bf	.Lcase00b	! 108 BR		(big loop)
+	shlr2	r6		! 105 EX
+
+	shlr	r6		! 104 EX
+	mov.l	@(r0, r5), r1	!  21 LS (latency=2)
+
+	bf/s	4f		! 111 BR
+	 add	#-8, r3		!  50 EX
+
+	tst	r6, r6		!  86 MT
+	bt/s	5f		! 110 BR
+
+	 mov.l	r1,@-r0		!  30 LS
+
+	! 4 cycles, 2 long words per iteration
+3:	mov.l	@(r0, r5), r1	!  21 LS (latency=2)
+
+4:	mov.l	@(r0, r3), r2	!  21 LS (latency=2)
+	dt	r6		!  67 EX
+
+	mov.l	r1, @-r0	!  30 LS
+	bf/s	3b		! 109 BR
+
+	 mov.l	r2, @-r0	!  30 LS
+
+5:	rts
+	 nop
+
+
+	! Size is 16 or greater and less than 64, but may have trailing bytes
+
+	.balign	32
+.Lcase0:
+	add	#-4, r5		!  50 EX
+	mov	r4, r7		!   5 MT (latency=0)
+
+	mov.l	@(r0, r5), r1	!  21 LS (latency=2)
+	mov	#4, r2		!   6 EX
+
+	add	#11, r7		!  50 EX
+	tst	r2, r6		!  86 MT
+
+	mov	r5, r3		!   5 MT (latency=0)
+	bt/s	4f		! 111 BR
+
+	 add	#-4, r3		!  50 EX
+	mov.l	r1,@-r0		!  30 LS
+
+	! 4 cycles, 2 long words per iteration
+3:	mov.l	@(r0, r5), r1	!  21 LS (latency=2)
+
+4:	mov.l	@(r0, r3), r2	!  21 LS (latency=2)
+	cmp/hi	r7, r0
+
+	mov.l	r1, @-r0	!  30 LS
+	bt/s	3b		! 109 BR
+
+	 mov.l	r2, @-r0	!  30 LS
+
+	! Copy the final 0-3 bytes
+
+	add	#3,r5		!  50 EX
+
+	cmp/eq	r0, r4		!  54 MT
+	add	#-10, r7	!  50 EX
+
+	bt	9f		! 110 BR
+
+	! 3 cycles, 1 byte per iteration
+1:	mov.b	@(r0,r5),r1	!  19 LS
+	cmp/hi	r7,r0		!  57 MT
+
+	bt/s	1b		! 111 BR
+	 mov.b	r1,@-r0		!  28 LS
+
+9:	rts
+	 nop
+
+	! Size is at least 64 bytes, so will be going round the big loop at least once.
+	!
+	!   r2 = rounded up r4
+	!   r3 = rounded down r0
+
+	.balign	32
+.Lcase0b:
+	add	#-4, r5		!  50 EX
+
+.Lcase00b:
+	mov	r0, r3		!   5 MT (latency=0)
+	mov	#(~0x1f), r1	!   6 EX
+
+	and	r1, r3		!  78 EX
+	mov	r4, r2		!   5 MT (latency=0)
+
+	cmp/eq	r3, r0		!  54 MT
+	add	#0x1f, r2	!  50 EX
+
+	bt/s	1f		! 110 BR
+	 and	r1, r2		!  78 EX
+
+	! copy initial words until cache line aligned
+
+	mov.l	@(r0, r5), r1	!  21 LS (latency=2)
+	tst	#4, r0		!  87 MT
+
+	mov	r5, r6		!   5 MT (latency=0)
+	add	#-4, r6		!  50 EX
+
+	bt/s	4f		! 111 BR
+	 add	#8, r3		!  50 EX
+
+	tst	#0x18, r0	!  87 MT
+
+	bt/s	1f		! 109 BR
+	 mov.l	r1,@-r0		!  30 LS
+
+	! 4 cycles, 2 long words per iteration
+3:	mov.l	@(r0, r5), r1	!  21 LS (latency=2)
+
+4:	mov.l	@(r0, r6), r7	!  21 LS (latency=2)
+	cmp/eq	r3, r0		!  54 MT
+
+	mov.l	r1, @-r0	!  30 LS
+	bf/s	3b		! 109 BR
+
+	 mov.l	r7, @-r0	!  30 LS
+
+	! Copy the cache line aligned blocks
+	!
+	! In use: r0, r2, r4, r5
+	! Scratch: r1, r3, r6, r7
+	!
+	! We could do this with the four scratch registers, but if src
+	! and dest hit the same cache line, this will thrash, so make
+	! use of additional registers.
+	!
+	! We also need r0 as a temporary (for movca), so 'undo' the invariant:
+	!   r5:	 src (was r0+r5)
+	!   r1:	 dest (was r0)
+	! this can be reversed at the end, so we don't need to save any extra
+	! state.
+	!
+1:	mov.l	r8, @-r15	!  30 LS
+	add	r0, r5		!  49 EX
+
+	mov.l	r9, @-r15	!  30 LS
+	mov	r0, r1		!   5 MT (latency=0)
+
+	mov.l	r10, @-r15	!  30 LS
+	add	#-0x1c, r5	!  50 EX
+
+	mov.l	r11, @-r15	!  30 LS
+
+	! 16 cycles, 32 bytes per iteration
+2:	mov.l	@(0x00,r5),r0	! 18 LS (latency=2)
+	add	#-0x20, r1	! 50 EX
+	mov.l	@(0x04,r5),r3	! 18 LS (latency=2)
+	mov.l	@(0x08,r5),r6	! 18 LS (latency=2)
+	mov.l	@(0x0c,r5),r7	! 18 LS (latency=2)
+	mov.l	@(0x10,r5),r8	! 18 LS (latency=2)
+	mov.l	@(0x14,r5),r9	! 18 LS (latency=2)
+	mov.l	@(0x18,r5),r10	! 18 LS (latency=2)
+	mov.l	@(0x1c,r5),r11	! 18 LS (latency=2)
+	movca.l	r0,@r1		! 40 LS (latency=3-7)
+	mov.l	r3,@(0x04,r1)	! 33 LS
+	mov.l	r6,@(0x08,r1)	! 33 LS
+	mov.l	r7,@(0x0c,r1)	! 33 LS
+
+	mov.l	r8,@(0x10,r1)	! 33 LS
+	add	#-0x20, r5	! 50 EX
+
+	mov.l	r9,@(0x14,r1)	! 33 LS
+	cmp/eq	r2,r1		! 54 MT
+
+	mov.l	r10,@(0x18,r1)	!  33 LS
+	bf/s	2b		! 109 BR
+
+	 mov.l	r11,@(0x1c,r1)	!  33 LS
+
+	mov	r1, r0		!   5 MT (latency=0)
+
+	mov.l	@r15+, r11	!  15 LS
+	sub	r1, r5		!  75 EX
+
+	mov.l	@r15+, r10	!  15 LS
+	cmp/eq	r4, r0		!  54 MT
+
+	bf/s	1f		! 109 BR
+	 mov.l	 @r15+, r9	!  15 LS
+
+	rts
+1:	 mov.l	@r15+, r8	!  15 LS
+	sub	r4, r1		!  75 EX		(len remaining)
+
+	! number of trailing bytes is non-zero
+	!
+	! invariants restored (r5 already decremented by 4)
+	! also r1=num bytes remaining
+
+	mov	#4, r2		!   6 EX
+	mov	r4, r7		!   5 MT (latency=0)
+
+	add	#0x1c, r5	!  50 EX		(back to -4)
+	cmp/hs	r2, r1		!  58 MT
+
+	bf/s	5f		! 108 BR
+	 add	 #11, r7	!  50 EX
+
+	mov.l	@(r0, r5), r6	!  21 LS (latency=2)
+	tst	r2, r1		!  86 MT
+
+	mov	r5, r3		!   5 MT (latency=0)
+	bt/s	4f		! 111 BR
+
+	 add	#-4, r3		!  50 EX
+	cmp/hs	r2, r1		!  58 MT
+
+	bt/s	5f		! 111 BR
+	 mov.l	r6,@-r0		!  30 LS
+
+	! 4 cycles, 2 long words per iteration
+3:	mov.l	@(r0, r5), r6	!  21 LS (latency=2)
+
+4:	mov.l	@(r0, r3), r2	!  21 LS (latency=2)
+	cmp/hi	r7, r0
+
+	mov.l	r6, @-r0	!  30 LS
+	bt/s	3b		! 109 BR
+
+	 mov.l	r2, @-r0	!  30 LS
+
+	! Copy the final 0-3 bytes
+
+5:	cmp/eq	r0, r4		!  54 MT
+	add	#-10, r7	!  50 EX
+
+	bt	9f		! 110 BR
+	add	#3,r5		!  50 EX
+
+	! 3 cycles, 1 byte per iteration
+1:	mov.b	@(r0,r5),r1	!  19 LS
+	cmp/hi	r7,r0		!  57 MT
+
+	bt/s	1b		! 111 BR
+	 mov.b	r1,@-r0		!  28 LS
+
+9:	rts
+	 nop
+
+	!
+	!	GHIJ KLMN OPQR -->  ..GH IJKL MNOP QR..
+	!
+
+	.balign	32
+.Lcase2:
+	! Size is 16 or greater and less then 64, but may have trailing bytes
+
+2:	mov	r5, r6		!   5 MT (latency=0)
+	add	#-2,r5		!  50 EX
+
+	mov	r4,r2		!   5 MT (latency=0)
+	add	#-4,r6		!  50 EX
+
+	add	#7,r2		!  50 EX
+3:	mov.w	@(r0,r5),r1	!  20 LS (latency=2)
+
+	mov.w	@(r0,r6),r3	!  20 LS (latency=2)
+	cmp/hi	r2,r0		!  57 MT
+
+	mov.w	r1,@-r0		!  29 LS
+	bt/s	3b		! 111 BR
+
+	 mov.w	r3,@-r0		!  29 LS
+
+	bra	10f
+	 nop
+
+
+	.balign	32
+.Lcase2b:
+	! Size is at least 64 bytes, so will be going round the big loop at least once.
+	!
+	!   r2 = rounded up r4
+	!   r3 = rounded down r0
+
+	mov	r0, r3		!   5 MT (latency=0)
+	mov	#(~0x1f), r1	!   6 EX
+
+	and	r1, r3		!  78 EX
+	mov	r4, r2		!   5 MT (latency=0)
+
+	cmp/eq	r3, r0		!  54 MT
+	add	#0x1f, r2	!  50 EX
+
+	add	#-2, r5		!  50 EX
+	bt/s	1f		! 110 BR
+	 and	r1, r2		!  78 EX
+
+	! Copy a short word one at a time until we are cache line aligned
+	!   Normal values: r0, r2, r3, r4
+	!   Unused: r1, r6, r7
+	!   Mod: r5 (=r5-2)
+	!
+	add	#2, r3		!  50 EX
+
+2:	mov.w	@(r0,r5),r1	!  20 LS (latency=2)
+	cmp/eq	r3,r0		!  54 MT
+
+	bf/s	2b		! 111 BR
+
+	 mov.w	r1,@-r0		!  29 LS
+
+	! Copy the cache line aligned blocks
+	!
+	! In use: r0, r2, r4, r5 (=r5-2)
+	! Scratch: r1, r3, r6, r7
+	!
+	! We could do this with the four scratch registers, but if src
+	! and dest hit the same cache line, this will thrash, so make
+	! use of additional registers.
+	!
+	! We also need r0 as a temporary (for movca), so 'undo' the invariant:
+	!   r5:	 src (was r0+r5)
+	!   r1:	 dest (was r0)
+	! this can be reversed at the end, so we don't need to save any extra
+	! state.
+	!
+1:	mov.l	r8, @-r15	!  30 LS
+	add	r0, r5		!  49 EX
+
+	mov.l	r9, @-r15	!  30 LS
+	mov	r0, r1		!   5 MT (latency=0)
+
+	mov.l	r10, @-r15	!  30 LS
+	add	#-0x1e, r5	!  50 EX
+
+	mov.l	r11, @-r15	!  30 LS
+
+	mov.l	r12, @-r15	!  30 LS
+
+	! 17 cycles, 32 bytes per iteration
+#ifdef CONFIG_CPU_LITTLE_ENDIAN
+2:	mov.w	@r5+, r0	!  14 LS (latency=2)		..JI
+	add	#-0x20, r1	!  50 EX
+
+	mov.l	@r5+, r3	!  15 LS (latency=2)		NMLK
+
+	mov.l	@r5+, r6	!  15 LS (latency=2)		RQPO
+	shll16	r0		! 103 EX			JI..
+
+	mov.l	@r5+, r7	!  15 LS (latency=2)
+	xtrct	r3, r0		!  48 EX			LKJI
+
+	mov.l	@r5+, r8	!  15 LS (latency=2)
+	xtrct	r6, r3		!  48 EX			PONM
+
+	mov.l	@r5+, r9	!  15 LS (latency=2)
+	xtrct	r7, r6		!  48 EX
+
+	mov.l	@r5+, r10	!  15 LS (latency=2)
+	xtrct	r8, r7		!  48 EX
+
+	mov.l	@r5+, r11	!  15 LS (latency=2)
+	xtrct	r9, r8		!  48 EX
+
+	mov.w	@r5+, r12	!  15 LS (latency=2)
+	xtrct	r10, r9		!  48 EX
+
+	movca.l	r0,@r1		!  40 LS (latency=3-7)
+	xtrct	r11, r10	!  48 EX
+
+	mov.l	r3, @(0x04,r1)	!  33 LS
+	xtrct	r12, r11	!  48 EX
+
+	mov.l	r6, @(0x08,r1)	!  33 LS
+
+	mov.l	r7, @(0x0c,r1)	!  33 LS
+
+	mov.l	r8, @(0x10,r1)	!  33 LS
+	add	#-0x40, r5	!  50 EX
+
+	mov.l	r9, @(0x14,r1)	!  33 LS
+	cmp/eq	r2,r1		!  54 MT
+
+	mov.l	r10, @(0x18,r1)	!  33 LS
+	bf/s	2b		! 109 BR
+
+	 mov.l	r11, @(0x1c,r1)	!  33 LS
+#else
+2:	mov.w	@(0x1e,r5), r0	!  17 LS (latency=2)
+	add	#-2, r5		!  50 EX
+
+	mov.l	@(0x1c,r5), r3	!  18 LS (latency=2)
+	add	#-4, r1		!  50 EX
+
+	mov.l	@(0x18,r5), r6	!  18 LS (latency=2)
+	shll16	r0		! 103 EX
+
+	mov.l	@(0x14,r5), r7	!  18 LS (latency=2)
+	xtrct	r3, r0		!  48 EX
+
+	mov.l	@(0x10,r5), r8	!  18 LS (latency=2)
+	xtrct	r6, r3		!  48 EX
+
+	mov.l	@(0x0c,r5), r9	!  18 LS (latency=2)
+	xtrct	r7, r6		!  48 EX
+
+	mov.l	@(0x08,r5), r10	!  18 LS (latency=2)
+	xtrct	r8, r7		!  48 EX
+
+	mov.l	@(0x04,r5), r11	!  18 LS (latency=2)
+	xtrct	r9, r8		!  48 EX
+
+	mov.w	@(0x02,r5), r12	!  18 LS (latency=2)
+	xtrct	r10, r9		!  48 EX
+
+	movca.l	r0,@r1		!  40 LS (latency=3-7)
+	add	#-0x1c, r1	!  50 EX
+
+	mov.l	r3, @(0x1c,r1)	!  33 LS
+	xtrct	r11, r10	!  48 EX
+
+	mov.l	r6, @(0x18,r1)	!  33 LS
+	xtrct	r12, r11	!  48 EX
+
+	mov.l	r7, @(0x14,r1)	!  33 LS
+
+	mov.l	r8, @(0x10,r1)	!  33 LS
+	add	#-0x3e, r5	!  50 EX
+
+	mov.l	r9, @(0x0c,r1)	!  33 LS
+	cmp/eq	r2,r1		!  54 MT
+
+	mov.l	r10, @(0x08,r1)	!  33 LS
+	bf/s	2b		! 109 BR
+
+	 mov.l	r11, @(0x04,r1)	!  33 LS
+#endif
+
+	mov.l	@r15+, r12
+	mov	r1, r0		!   5 MT (latency=0)
+
+	mov.l	@r15+, r11	!  15 LS
+	sub	r1, r5		!  75 EX
+
+	mov.l	@r15+, r10	!  15 LS
+	cmp/eq	r4, r0		!  54 MT
+
+	bf/s	1f		! 109 BR
+	 mov.l	 @r15+, r9	!  15 LS
+
+	rts
+1:	 mov.l	@r15+, r8	!  15 LS
+
+	add	#0x1e, r5	!  50 EX
+
+	! Finish off a short word at a time
+	! r5 must be invariant - 2
+10:	mov	r4,r2		!   5 MT (latency=0)
+	add	#1,r2		!  50 EX
+
+	cmp/hi	r2, r0		!  57 MT
+	bf/s	1f		! 109 BR
+
+	 add	#2, r2		!  50 EX
+
+3:	mov.w	@(r0,r5),r1	!  20 LS
+	cmp/hi	r2,r0		!  57 MT
+
+	bt/s	3b		! 109 BR
+
+	 mov.w	r1,@-r0		!  29 LS
+1:
+
+	!
+	! Finally, copy the last byte if necessary
+	cmp/eq	r4,r0		!  54 MT
+	bt/s	9b
+	 add	#1,r5
+	mov.b	@(r0,r5),r1
+	rts
+	 mov.b	r1,@-r0
+
diff -Nru a/arch/sh/mm/Makefile b/arch/sh/mm/Makefile
--- a/arch/sh/mm/Makefile	2004-12-24 13:37:19 -08:00
+++ b/arch/sh/mm/Makefile	2004-12-24 13:37:19 -08:00
@@ -19,5 +19,7 @@
 ifdef CONFIG_MMU
 obj-$(CONFIG_CPU_SH3)	+= tlb-sh3.o
 obj-$(CONFIG_CPU_SH4)	+= tlb-sh4.o ioremap.o
+obj-$(CONFIG_SH7705_CACHE_32KB) += pg-sh7705.o
 endif
 
+obj-$(CONFIG_SH7705_CACHE_32KB) += cache-sh7705.o
diff -Nru a/arch/sh/mm/cache-sh2.c b/arch/sh/mm/cache-sh2.c
--- a/arch/sh/mm/cache-sh2.c	2004-12-24 13:36:48 -08:00
+++ b/arch/sh/mm/cache-sh2.c	2004-12-24 13:36:48 -08:00
@@ -24,7 +24,7 @@
 unsigned long __get_oc_addr(unsigned long set, unsigned long way)
 {
 	unsigned long ccr;
-	
+
 	/*
 	 * On SH-2 the way bit isn't tracked in the address field
 	 * if we're doing address array access .. instead, we need
@@ -46,27 +46,5 @@
 	ctrl_outl(ccr, CCR);
 
 	return CACHE_OC_ADDRESS_ARRAY | (set << cpu_data->dcache.entry_shift);
-}
-
-int __init detect_cpu_and_cache_system(void)
-{
-	/*
-	 * For now, assume SH7604 .. fix this later.
-	 */
-	cpu_data->type			= CPU_SH7604;
-	cpu_data->dcache.ways		= 4;
-	cpu_data->dcache.way_shift	= 6;
-	cpu_data->dcache.sets		= 64;
-	cpu_data->dcache.entry_shift	= 4;
-	cpu_data->dcache.linesz		= L1_CACHE_BYTES;
-	cpu_data->dcache.flags		= 0;
-
-	/*
-	 * SH-2 doesn't have separate caches
-	 */
-	cpu_data->dcache.flags |= SH_CACHE_COMBINED;
-	cpu_data->icache = cpu_data->dcache;
-
-	return 0;
 }
 
diff -Nru a/arch/sh/mm/cache-sh3.c b/arch/sh/mm/cache-sh3.c
--- a/arch/sh/mm/cache-sh3.c	2004-12-24 13:36:17 -08:00
+++ b/arch/sh/mm/cache-sh3.c	2004-12-24 13:36:17 -08:00
@@ -1,9 +1,10 @@
-/* $Id: cache-sh3.c,v 1.9 2004/05/02 01:46:30 sugioka Exp $
- *
- *  linux/arch/sh/mm/cache-sh3.c
+/*
+ * arch/sh/mm/cache-sh3.c
  *
  * Copyright (C) 1999, 2000  Niibe Yutaka
  * Copyright (C) 2002 Paul Mundt
+ *
+ * Released under the terms of the GNU GPL v2.0.
  */
 
 #include <linux/init.h>
@@ -21,72 +22,6 @@
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
 
-int __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&~(SH_CACHE_VALID|SH_CACHE_UPDATED), addr0);
-	data1  = ctrl_inl(addr1);
-	ctrl_outl(data1&~(SH_CACHE_VALID|SH_CACHE_UPDATED), addr1);
-
-	/* Next, check if there's shadow or not */
-	data0 = ctrl_inl(addr0);
-	data0 ^= SH_CACHE_VALID;
-	ctrl_outl(data0, addr0);
-	data1 = ctrl_inl(addr1);
-	data2 = data1 ^ SH_CACHE_VALID;
-	ctrl_outl(data2, addr1);
-	data3 = ctrl_inl(addr0);
-
-	/* Lastly, invaliate them. */
-	ctrl_outl(data0&~SH_CACHE_VALID, addr0);
-	ctrl_outl(data2&~SH_CACHE_VALID, addr1);
-
-	back_to_P1();
-
-	cpu_data->dcache.ways		= 4;
-	cpu_data->dcache.entry_shift	= 4;
-	cpu_data->dcache.linesz		= L1_CACHE_BYTES;
-	cpu_data->dcache.flags		= 0;
-
-	/*
-	 * 7709A/7729 has 16K cache (256-entry), while 7702 has only
-	 * 2K(direct) 7702 is not supported (yet)
-	 */
-	if (data0 == data1 && data2 == data3) {	/* Shadow */
-		cpu_data->dcache.way_incr	= (1 << 11);
-		cpu_data->dcache.entry_mask	= 0x7f0;
-		cpu_data->dcache.sets		= 128;
-		cpu_data->type = CPU_SH7708;
-
-		cpu_data->flags |= CPU_HAS_MMU_PAGE_ASSOC;
-	} else {				/* 7709A or 7729  */
-		cpu_data->dcache.way_incr	= (1 << 12);
-		cpu_data->dcache.entry_mask	= 0xff0;
-		cpu_data->dcache.sets		= 256;
-		cpu_data->type = CPU_SH7729;
-	}
-
-	/*
-	 * SH-3 doesn't have separate caches
-	 */
-	cpu_data->dcache.flags |= SH_CACHE_COMBINED;
-	cpu_data->icache = cpu_data->dcache;
-
-	return 0;
-}
-
 /*
  * Write back the dirty D-caches, but not invalidate them.
  *
@@ -116,7 +51,7 @@
 			addr = addrstart | (v & cpu_data->dcache.entry_mask);
 			local_irq_save(flags);
 			data = ctrl_inl(addr);
-			
+
 			if ((data & CACHE_PHYSADDR_MASK) ==
 			    (p & CACHE_PHYSADDR_MASK)) {
 				data &= ~SH_CACHE_UPDATED;
diff -Nru a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
--- a/arch/sh/mm/cache-sh4.c	2004-12-24 13:36:31 -08:00
+++ b/arch/sh/mm/cache-sh4.c	2004-12-24 13:36:31 -08:00
@@ -1,10 +1,13 @@
-/* $Id: cache-sh4.c,v 1.26 2004/02/19 12:47:24 lethal Exp $
- *
- *  linux/arch/sh/mm/cache-sh4.c
+/*
+ * arch/sh/mm/cache-sh4.c
  *
  * Copyright (C) 1999, 2000, 2002  Niibe Yutaka
  * Copyright (C) 2001, 2002, 2003, 2004  Paul Mundt
  * Copyright (C) 2003  Richard Curnow
+ *
+ * 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 <linux/config.h>
@@ -27,126 +30,6 @@
 static void __flush_cache_4096_all_ex(unsigned long start);
 extern void __flush_dcache_all(void);
 static void __flush_dcache_all_ex(void);
-
-int __init detect_cpu_and_cache_system(void)
-{
-	unsigned long pvr, prr, cvr;
-	unsigned long size;
-
-	static unsigned long sizes[16] = {
-		[1] = (1 << 12),
-		[2] = (1 << 13),
-		[4] = (1 << 14),
-		[8] = (1 << 15),
-		[9] = (1 << 16)
-	};
-
-	pvr = (ctrl_inl(CCN_PVR) >> 8) & 0xffff;
-	prr = (ctrl_inl(CCN_PRR) >> 4) & 0xff;
-	cvr = (ctrl_inl(CCN_CVR));
-
-	/*
-	 * Setup some sane SH-4 defaults for the icache
-	 */
-	cpu_data->icache.way_incr	= (1 << 13);
-	cpu_data->icache.entry_shift	= 5;
-	cpu_data->icache.entry_mask	= 0x1fe0;
-	cpu_data->icache.sets		= 256;
-	cpu_data->icache.ways		= 1;
-	cpu_data->icache.linesz		= L1_CACHE_BYTES;
-
-	/*
-	 * And again for the dcache ..
-	 */
-	cpu_data->dcache.way_incr	= (1 << 14);
-	cpu_data->dcache.entry_shift	= 5;
-	cpu_data->dcache.entry_mask	= 0x3fe0;
-	cpu_data->dcache.sets		= 512;
-	cpu_data->dcache.ways		= 1;
-	cpu_data->dcache.linesz		= L1_CACHE_BYTES;
-
-	/* Set the FPU flag, virtually all SH-4's have one */
-	cpu_data->flags |= CPU_HAS_FPU;
-
-	/*
-	 * Probe the underlying processor version/revision and
-	 * adjust cpu_data setup accordingly.
-	 */
-	switch (pvr) {
-	case 0x205:
-		cpu_data->type = CPU_SH7750;
-		cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG;
-		break;
-	case 0x206:
-		cpu_data->type = CPU_SH7750S;
-
-		/* 
-		 * FIXME: This is needed for 7750, but do we need it for the
-		 * 7750S too? For now, assume we do.. -- PFM
-		 */
-		cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG;
-
-		break;
-	case 0x1100:
-		cpu_data->type = CPU_SH7751;
-		break;
-	case 0x8000:
-		cpu_data->type = CPU_ST40RA;
-		break;
-	case 0x8100:
-		cpu_data->type = CPU_ST40GX1;
-		break;
-	case 0x700:
-		cpu_data->type = CPU_SH4_501;
-		cpu_data->icache.ways = 2;
-		cpu_data->dcache.ways = 2;
-
-		/* No FPU on the SH4-500 series.. */
-		cpu_data->flags &= ~CPU_HAS_FPU;
-		break;
-	case 0x600:
-		cpu_data->type = CPU_SH4_202;
-		cpu_data->icache.ways = 2;
-		cpu_data->dcache.ways = 2;
-		break;
-	case 0x500 ... 0x501:
-		switch (prr) {
-		    case 0x10: cpu_data->type = CPU_SH7750R; break;
-		    case 0x11: cpu_data->type = CPU_SH7751R; break;
-		    case 0x50: cpu_data->type = CPU_SH7760;  break;
-		}
-
-		cpu_data->icache.ways = 2;
-		cpu_data->dcache.ways = 2;
-
-		break;
-	default:
-		cpu_data->type = CPU_SH_NONE;
-		break;
-	}
-
-	/*
-	 * On anything that's not a direct-mapped cache, look to the CVR
-	 * for I/D-cache specifics.
-	 */
-	if (cpu_data->icache.ways > 1) {
-		size = sizes[(cvr >> 20) & 0xf];
-		cpu_data->icache.way_incr	= size / cpu_data->icache.ways;
-		cpu_data->icache.sets		= (size >> 6);
-		cpu_data->icache.entry_mask	=
-			((size / cpu_data->icache.ways) - (1 << 5));
-	}
-
-	if (cpu_data->dcache.ways > 1) {
-		size = sizes[(cvr >> 16) & 0xf];
-		cpu_data->dcache.way_incr	= size / cpu_data->dcache.ways;
-		cpu_data->dcache.sets		= (size >> 6);
-		cpu_data->dcache.entry_mask	=
-			((size / cpu_data->dcache.ways) - (1 << 5));
-	}
-
-	return 0;
-}
 
 /*
  * SH-4 has virtually indexed and physically tagged cache.
diff -Nru a/arch/sh/mm/cache-sh7705.c b/arch/sh/mm/cache-sh7705.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/mm/cache-sh7705.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,222 @@
+/*
+ * arch/sh/mm/cache-sh7705.c
+ *
+ * Copyright (C) 1999, 2000  Niibe Yutaka
+ * Copyright (C) 2004  Alex Song
+ *
+ * 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 <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>
+#include <asm/cacheflush.h>
+
+/* The 32KB cache on the SH7705 suffers from the same synonym problem
+ * as SH4 CPUs */
+
+#define __pte_offset(address) \
+		((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
+#define pte_offset(dir, address) ((pte_t *) pmd_page_kernel(*(dir)) + \
+		__pte_offset(address))
+
+static inline void cache_wback_all(void)
+{
+	unsigned long ways, waysize, addrstart;
+
+	ways = cpu_data->dcache.ways;
+	waysize = cpu_data->dcache.sets;
+	waysize <<= cpu_data->dcache.entry_shift;
+
+	addrstart = CACHE_OC_ADDRESS_ARRAY;
+
+	do {
+		unsigned long addr;
+
+		for (addr = addrstart;
+		     addr < addrstart + waysize;
+		     addr += cpu_data->dcache.linesz) {
+			unsigned long data;
+			int v = SH_CACHE_UPDATED | SH_CACHE_VALID;
+
+			data = ctrl_inl(addr);
+
+			if ((data & v) == v)
+				ctrl_outl(data & ~v, addr);
+
+		}
+
+		addrstart += cpu_data->dcache.way_incr;
+	} while (--ways);
+}
+
+/*
+ * 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_wback_region((void *)start, end - start);
+}
+
+
+/*
+ * Writeback&Invalidate the D-cache of the page
+ */
+static void __flush_dcache_page(unsigned long phys)
+{
+	unsigned long ways, waysize, addrstart;
+	unsigned long flags;
+
+	phys |= SH_CACHE_VALID;
+
+	/*
+	 * Here, phys is the physical address of the page. We check all the
+	 * tags in the cache for those with the same page number as this page
+	 * (by masking off the lowest 2 bits of the 19-bit tag; these bits are
+	 * derived from the offset within in the 4k page). Matching valid
+	 * entries are invalidated.
+	 *
+	 * Since 2 bits of the cache index are derived from the virtual page
+	 * number, knowing this would reduce the number of cache entries to be
+	 * searched by a factor of 4. However this function exists to deal with
+	 * potential cache aliasing, therefore the optimisation is probably not
+	 * possible.
+	 */
+	local_irq_save(flags);
+	jump_to_P2();
+
+	ways = cpu_data->dcache.ways;
+	waysize = cpu_data->dcache.sets;
+	waysize <<= cpu_data->dcache.entry_shift;
+
+	addrstart = CACHE_OC_ADDRESS_ARRAY;
+
+	do {
+		unsigned long addr;
+
+		for (addr = addrstart;
+		     addr < addrstart + waysize;
+		     addr += cpu_data->dcache.linesz) {
+			unsigned long data;
+
+			data = ctrl_inl(addr) & (0x1ffffC00 | SH_CACHE_VALID);
+		        if (data == phys) {
+				data &= ~(SH_CACHE_VALID | SH_CACHE_UPDATED);
+				ctrl_outl(data, addr);
+			}
+		}
+
+		addrstart += cpu_data->dcache.way_incr;
+	} while (--ways);
+
+	back_to_P1();
+	local_irq_restore(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)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	jump_to_P2();
+
+	cache_wback_all();
+	back_to_P1();
+	local_irq_restore(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 vm_area_struct *vma, 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.
+ *
+ * ADDRESS: 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;
+
+	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;
+	__flush_dcache_page(phys);
+}
+
+/*
+ * This is called when a page-cache page is about to be mapped into a
+ * user process' address space.  It offers an opportunity for a
+ * port to ensure d-cache/i-cache coherency if necessary.
+ *
+ * Not entirely sure why this is necessary on SH3 with 32K cache but
+ * without it we get occasional "Memory fault" when loading a program.
+ */
+void flush_icache_page(struct vm_area_struct *vma, struct page *page)
+{
+	__flush_purge_region(page_address(page), PAGE_SIZE);
+}
+
diff -Nru a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
--- a/arch/sh/mm/consistent.c	2004-12-24 13:37:43 -08:00
+++ b/arch/sh/mm/consistent.c	2004-12-24 13:37:43 -08:00
@@ -78,4 +78,8 @@
 		BUG();
 	}
 }
+
+EXPORT_SYMBOL(consistent_alloc);
+EXPORT_SYMBOL(consistent_free);
 EXPORT_SYMBOL(consistent_sync);
+
diff -Nru a/arch/sh/mm/extable.c b/arch/sh/mm/extable.c
--- a/arch/sh/mm/extable.c	2004-12-24 13:37:43 -08:00
+++ b/arch/sh/mm/extable.c	2004-12-24 13:37:43 -08:00
@@ -1,5 +1,4 @@
-/* $Id: extable.c,v 1.3 2003/05/06 23:28:50 lethal Exp $
- *
+/*
  * linux/arch/sh/mm/extable.c
  *  Taken from:
  *   linux/arch/i386/mm/extable.c
diff -Nru a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c
--- a/arch/sh/mm/ioremap.c	2004-12-24 13:37:00 -08:00
+++ b/arch/sh/mm/ioremap.c	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,4 @@
-/* $Id: ioremap.c,v 1.9 2004/02/25 04:59:10 lethal Exp $
- *
+/*
  * arch/sh/mm/ioremap.c
  *
  * Re-map IO memory to kernel address space so that we can access it.
diff -Nru a/arch/sh/mm/pg-sh7705.c b/arch/sh/mm/pg-sh7705.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/mm/pg-sh7705.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,137 @@
+/*
+ * arch/sh/mm/pg-sh7705.c
+ *
+ * Copyright (C) 1999, 2000  Niibe Yutaka
+ * Copyright (C) 2004  Alex Song
+ *
+ * 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 <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>
+#include <asm/cacheflush.h>
+
+static inline void __flush_purge_virtual_region(void *p1, void *virt, int size)
+{
+	unsigned long v;
+	unsigned long begin, end;
+	unsigned long p1_begin;
+
+
+	begin = L1_CACHE_ALIGN((unsigned long)virt);
+	end = L1_CACHE_ALIGN((unsigned long)virt + size);
+
+	p1_begin = (unsigned long)p1 & ~(L1_CACHE_BYTES - 1);
+
+	/* do this the slow way as we may not have TLB entries
+	 * for virt yet. */
+	for (v = begin; v < end; v += L1_CACHE_BYTES) {
+		unsigned long p;
+	        unsigned long ways, addr;
+
+		p = __pa(p1_begin);
+
+	        ways = cpu_data->dcache.ways;
+		addr = CACHE_OC_ADDRESS_ARRAY;
+
+		do {
+			unsigned long data;
+
+			addr |= (v & cpu_data->dcache.entry_mask);
+
+			data = ctrl_inl(addr);
+			if ((data & CACHE_PHYSADDR_MASK) ==
+			       (p & CACHE_PHYSADDR_MASK)) {
+				data &= ~(SH_CACHE_UPDATED|SH_CACHE_VALID);
+				ctrl_outl(data, addr);
+			}
+
+			addr += cpu_data->dcache.way_incr;
+		} while (--ways);
+
+		p1_begin += L1_CACHE_BYTES;
+	}
+}
+
+/*
+ * clear_user_page
+ * @to: P1 address
+ * @address: U0 address to be mapped
+ */
+void clear_user_page(void *to, unsigned long address, struct page *pg)
+{
+	struct page *page = virt_to_page(to);
+
+	__set_bit(PG_mapped, &page->flags);
+	if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) {
+		clear_page(to);
+		__flush_wback_region(to, PAGE_SIZE);
+	} else {
+		__flush_purge_virtual_region(to,
+					     (void *)(address & 0xfffff000),
+					     PAGE_SIZE);
+		clear_page(to);
+		__flush_wback_region(to, PAGE_SIZE);
+	}
+}
+
+/*
+ * 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 *pg)
+{
+	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);
+		__flush_wback_region(to, PAGE_SIZE);
+	} else {
+		__flush_purge_virtual_region(to,
+					     (void *)(address & 0xfffff000),
+					     PAGE_SIZE);
+		copy_page(to, from);
+		__flush_wback_region(to, PAGE_SIZE);
+	}
+}
+
+/*
+ * For SH7705, we have our own implementation for ptep_get_and_clear
+ * Copied from pg-sh4.c
+ */
+inline pte_t ptep_get_and_clear(pte_t *ptep)
+{
+	pte_t pte = *ptep;
+
+	pte_clear(ptep);
+	if (!pte_not_present(pte)) {
+		unsigned long pfn = pte_pfn(pte);
+		if (pfn_valid(pfn)) {
+			struct page *page = pfn_to_page(pfn);
+			struct address_space *mapping = page_mapping(page);
+			if (!mapping || !mapping_writably_mapped(mapping))
+				__clear_bit(PG_mapped, &page->flags);
+		}
+	}
+
+	return pte;
+}
+
diff -Nru a/arch/sh/mm/tlb-sh3.c b/arch/sh/mm/tlb-sh3.c
--- a/arch/sh/mm/tlb-sh3.c	2004-12-24 13:36:47 -08:00
+++ b/arch/sh/mm/tlb-sh3.c	2004-12-24 13:36:47 -08:00
@@ -39,6 +39,16 @@
 	if (vma && current->active_mm != vma->vm_mm)
 		return;
 
+#if defined(CONFIG_SH7705_CACHE_32KB)
+	struct page *page;
+	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
+
 	local_irq_save(flags);
 
 	/* Set PTEH register */
diff -Nru a/arch/sh/oprofile/Makefile b/arch/sh/oprofile/Makefile
--- a/arch/sh/oprofile/Makefile	2004-12-24 13:37:04 -08:00
+++ b/arch/sh/oprofile/Makefile	2004-12-24 13:37:04 -08:00
@@ -7,7 +7,7 @@
 		timer_int.o )
 
 profdrvr-y				:= op_model_null.o
-profdrvr-$(CONFIG_SH_DREAMCAST)		:= op_model_dreamcast.o
+profdrvr-$(CONFIG_CPU_SUBTYPE_SH7750)	:= op_model_sh7750.o
 
 oprofile-y				:= $(DRIVER_OBJS) $(profdrvr-y)
 
diff -Nru a/arch/sh/oprofile/op_model_sh7750.c b/arch/sh/oprofile/op_model_sh7750.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/oprofile/op_model_sh7750.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,286 @@
+/*
+ * arch/sh/oprofile/op_model_sh7750.c
+ *
+ * OProfile support for SH7750/SH7750S Performance Counters
+ *
+ * Copyright (C) 2003, 2004  Paul Mundt
+ *
+ * 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 <linux/kernel.h>
+#include <linux/oprofile.h>
+#include <linux/profile.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/fs.h>
+#include <linux/notifier.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+
+#define PM_CR_BASE	0xff000084	/* 16-bit */
+#define PM_CTR_BASE	0xff100004	/* 32-bit */
+
+#define PMCR1		(PM_CR_BASE  + 0x00)
+#define PMCR2		(PM_CR_BASE  + 0x04)
+#define PMCTR1H		(PM_CTR_BASE + 0x00)
+#define PMCTR1L		(PM_CTR_BASE + 0x04)
+#define PMCTR2H		(PM_CTR_BASE + 0x08)
+#define PMCTR2L		(PM_CTR_BASE + 0x0c)
+
+#define PMCR_PMM_MASK	0x0000003f
+
+#define PMCR_CLKF	0x00000100
+#define PMCR_PMCLR	0x00002000
+#define PMCR_PMST	0x00004000
+#define PMCR_PMEN	0x00008000
+
+#define PMCR_ENABLE	(PMCR_PMST | PMCR_PMEN)
+
+/*
+ * SH7750/SH7750S have 2 perf counters
+ */
+#define NR_CNTRS	2
+
+extern const char *get_cpu_subtype(void);
+
+struct op_counter_config {
+	unsigned long enabled;
+	unsigned long event;
+	unsigned long count;
+
+	/* Dummy values for userspace tool compliance */
+	unsigned long kernel;
+	unsigned long user;
+	unsigned long unit_mask;
+};
+
+static struct op_counter_config ctr[NR_CNTRS];
+
+/*
+ * There are a number of events supported by each counter (33 in total).
+ * Since we have 2 counters, each counter will take the event code as it
+ * corresponds to the PMCR PMM setting. Each counter can be configured
+ * independently.
+ *
+ *	Event Code	Description
+ *	----------	-----------
+ *
+ *	0x01		Operand read access
+ *	0x02		Operand write access
+ *	0x03		UTLB miss
+ *	0x04		Operand cache read miss
+ *	0x05		Operand cache write miss
+ *	0x06		Instruction fetch (w/ cache)
+ *	0x07		Instruction TLB miss
+ *	0x08		Instruction cache miss
+ *	0x09		All operand accesses
+ *	0x0a		All instruction accesses
+ *	0x0b		OC RAM operand access
+ *	0x0d		On-chip I/O space access
+ *	0x0e		Operand access (r/w)
+ *	0x0f		Operand cache miss (r/w)
+ *	0x10		Branch instruction
+ *	0x11		Branch taken
+ *	0x12		BSR/BSRF/JSR
+ *	0x13		Instruction execution
+ *	0x14		Instruction execution in parallel
+ *	0x15		FPU Instruction execution
+ *	0x16		Interrupt
+ *	0x17		NMI
+ *	0x18		trapa instruction execution
+ *	0x19		UBCA match
+ *	0x1a		UBCB match
+ *	0x21		Instruction cache fill
+ *	0x22		Operand cache fill
+ *	0x23		Elapsed time
+ *	0x24		Pipeline freeze by I-cache miss
+ *	0x25		Pipeline freeze by D-cache miss
+ *	0x27		Pipeline freeze by branch instruction
+ *	0x28		Pipeline freeze by CPU register
+ *	0x29		Pipeline freeze by FPU
+ *
+ * Unfortunately we don't have a native exception or interrupt for counter
+ * overflow (although since these counters can run for 16.3 days without
+ * overflowing, it's not really necessary).
+ *
+ * OProfile on the other hand likes to have samples taken periodically, so
+ * for now we just piggyback the timer interrupt to get the expected
+ * behavior.
+ */
+
+static int sh7750_timer_notify(struct notifier_block *self,
+			       unsigned long val, void *data)
+{
+	struct pt_regs *regs = data;
+	unsigned long pc;
+
+	pc = instruction_pointer(regs);
+	oprofile_add_sample(pc, !user_mode(regs), 0, smp_processor_id());
+
+	return 0;
+}
+
+static struct notifier_block sh7750_timer_notifier = {
+	.notifier_call		= sh7750_timer_notify,
+};
+
+static u64 sh7750_read_counter(int counter)
+{
+	u32 hi, lo;
+
+	hi = (counter == 0) ? ctrl_inl(PMCTR1H) : ctrl_inl(PMCTR2H);
+	lo = (counter == 0) ? ctrl_inl(PMCTR1L) : ctrl_inl(PMCTR2L);
+
+	return (u64)((u64)(hi & 0xffff) << 32) | lo;
+}
+
+/*
+ * Files will be in a path like:
+ *
+ *  /<oprofilefs mount point>/<counter number>/<file>
+ *
+ * So when dealing with <file>, we look to the parent dentry for the counter
+ * number.
+ */
+static inline int to_counter(struct file *file)
+{
+	const unsigned char *name = file->f_dentry->d_parent->d_name.name;
+
+	return (int)simple_strtol(name, NULL, 10);
+}
+
+/*
+ * XXX: We have 48-bit counters, so we're probably going to want something
+ * more along the lines of oprofilefs_ullong_to_user().. Truncating to
+ * unsigned long works fine for now though, as long as we don't attempt to
+ * profile for too horribly long.
+ */
+static ssize_t sh7750_read_count(struct file *file, char __user *buf,
+				 size_t count, loff_t *ppos)
+{
+	int counter = to_counter(file);
+	u64 val = sh7750_read_counter(counter);
+
+	return oprofilefs_ulong_to_user((unsigned long)val, buf, count, ppos);
+}
+
+static ssize_t sh7750_write_count(struct file *file, const char __user *buf,
+				  size_t count, loff_t *ppos)
+{
+	int counter = to_counter(file);
+	unsigned long val;
+
+	if (oprofilefs_ulong_from_user(&val, buf, count))
+		return -EFAULT;
+
+	/*
+	 * Any write will clear the counter, although only 0 should be
+	 * written for this purpose, as we do not support setting the
+	 * counter to an arbitrary value.
+	 */
+	WARN_ON(val != 0);
+
+	if (counter == 0) {
+		ctrl_outw(ctrl_inw(PMCR1) | PMCR_PMCLR, PMCR1);
+	} else {
+		ctrl_outw(ctrl_inw(PMCR2) | PMCR_PMCLR, PMCR2);
+	}
+
+	return count;
+}
+
+static struct file_operations count_fops = {
+	.read		= sh7750_read_count,
+	.write		= sh7750_write_count,
+};
+
+static int sh7750_perf_counter_create_files(struct super_block *sb, struct dentry *root)
+{
+	int i;
+
+	for (i = 0; i < NR_CNTRS; i++) {
+		struct dentry *dir;
+		char buf[3];
+
+		snprintf(buf, sizeof(buf), "%d", i);
+		dir = oprofilefs_mkdir(sb, root, buf);
+
+		oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled);
+		oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event);
+		oprofilefs_create_file(sb, dir, "count", &count_fops);
+
+		/* Dummy entries */
+		oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel);
+		oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user);
+		oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask);
+	}
+
+	return 0;
+}
+
+static int sh7750_perf_counter_start(void)
+{
+	u16 pmcr;
+
+	/* Enable counter 1 */
+	if (ctr[0].enabled) {
+		pmcr = ctrl_inw(PMCR1);
+		WARN_ON(pmcr & PMCR_PMEN);
+
+		pmcr &= ~PMCR_PMM_MASK;
+		pmcr |= ctr[0].event;
+		ctrl_outw(pmcr | PMCR_ENABLE, PMCR1);
+	}
+
+	/* Enable counter 2 */
+	if (ctr[1].enabled) {
+		pmcr = ctrl_inw(PMCR2);
+		WARN_ON(pmcr & PMCR_PMEN);
+
+		pmcr &= ~PMCR_PMM_MASK;
+		pmcr |= ctr[1].event;
+		ctrl_outw(pmcr | PMCR_ENABLE, PMCR2);
+	}
+
+	return register_profile_notifier(&sh7750_timer_notifier);
+}
+
+static void sh7750_perf_counter_stop(void)
+{
+	ctrl_outw(ctrl_inw(PMCR1) & ~PMCR_PMEN, PMCR1);
+	ctrl_outw(ctrl_inw(PMCR2) & ~PMCR_PMEN, PMCR2);
+
+	unregister_profile_notifier(&sh7750_timer_notifier);
+}
+
+static struct oprofile_operations sh7750_perf_counter_ops = {
+	.create_files	= sh7750_perf_counter_create_files,
+	.start		= sh7750_perf_counter_start,
+	.stop		= sh7750_perf_counter_stop,
+};
+
+int __init oprofile_arch_init(struct oprofile_operations **ops)
+{
+	if (!(cpu_data->flags & CPU_HAS_PERF_COUNTER))
+		return -ENODEV;
+
+	sh7750_perf_counter_ops.cpu_type = (char *)get_cpu_subtype();
+	*ops = &sh7750_perf_counter_ops;
+
+	printk(KERN_INFO "oprofile: using SH-4 (%s) performance monitoring.\n",
+	       sh7750_perf_counter_ops.cpu_type);
+
+	/* Clear the counters */
+	ctrl_outw(ctrl_inw(PMCR1) | PMCR_PMCLR, PMCR1);
+	ctrl_outw(ctrl_inw(PMCR2) | PMCR_PMCLR, PMCR2);
+
+	return 0;
+}
+
+void oprofile_arch_exit(void)
+{
+}
+
diff -Nru a/arch/sh/ramdisk/Makefile b/arch/sh/ramdisk/Makefile
--- a/arch/sh/ramdisk/Makefile	2004-12-24 13:36:49 -08:00
+++ b/arch/sh/ramdisk/Makefile	2004-12-24 13:36:49 -08:00
@@ -12,8 +12,9 @@
 
 quiet_cmd_ramdisk = LD      $@
 define cmd_ramdisk
-	$(LD) -T $(src)/ld.script -b binary --oformat $(O_FORMAT) -o $@ $(img)
+	$(LD) -T $(srctree)/$(src)/ld.script -b binary --oformat $(O_FORMAT) \
+		-o $@ $(img)
 endef
 
-$(obj)/ramdisk.o: $(img) $(src)/ld.script
+$(obj)/ramdisk.o: $(img) $(srctree)/$(src)/ld.script
 	$(call cmd,ramdisk)
diff -Nru a/arch/sh/tools/Makefile b/arch/sh/tools/Makefile
--- a/arch/sh/tools/Makefile	2004-12-24 13:36:56 -08:00
+++ b/arch/sh/tools/Makefile	2004-12-24 13:36:56 -08:00
@@ -10,7 +10,6 @@
 # Shamelessly cloned from ARM.
 #
 
-include/asm-sh/machtypes.h: $(obj)/machgen.sh $(obj)/mach-types
+include/asm-sh/machtypes.h: $(src)/gen-mach-types $(src)/mach-types
 	@echo '  Generating $@'
-	@$(CONFIG_SHELL) $(obj)/machgen.sh $(obj)/mach-types > $@
-
+	$(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
diff -Nru a/arch/sh/tools/gen-mach-types b/arch/sh/tools/gen-mach-types
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/sh/tools/gen-mach-types	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,49 @@
+#!/bin/awk
+#
+# Awk script to generate include/asm-sh/machtypes.h
+# Heavily based on arch/arm/tools/gen-mach-types
+#
+BEGIN	{ nr = 0 }
+/^#/	{ next }
+/^[ 	]*$/ { next }
+
+NF == 2 {
+	  mach[nr] = $1;
+	  config[nr] = "CONFIG_"$2;
+	  nr++;
+	}
+
+END	{
+	  printf("/*\n");
+	  printf(" * Automagically generated, don't touch.\n");
+	  printf(" */\n");
+	  printf("#ifndef __ASM_SH_MACHTYPES_H\n");
+	  printf("#define __ASM_SH_MACHTYPES_H\n");
+	  printf("\n");
+	  printf("#include <linux/config.h>\n");
+	  printf("\n");
+	  printf("/*\n");
+	  printf(" * We'll use the following MACH_xxx defs for placeholders for the time\n");
+	  printf(" * being .. these will all go away once sh_machtype is assigned per-board.\n");
+	  printf(" *\n");
+	  printf(" * For now we leave things the way they are for backwards compatibility.\n");
+	  printf(" */\n");
+	  printf("\n");
+	  printf("/* Mach types */\n");
+
+	  for (i = 0; i < nr; i++) {
+	      printf("#ifdef %s\n", config[i]);
+	      printf("  #define MACH_%s\t\t1\n", mach[i]);
+	      printf("#else\n");
+	      printf("  #define MACH_%s\t\t0\n", mach[i]);
+	      printf("#endif\n");
+	    }
+
+	  printf("\n");
+	  printf("/* Machtype checks */\n");
+	  for (i = 0; i < nr; i++)
+	      printf("#define mach_is_%s()\t\t\t(MACH_%s)\n",
+	     	 tolower(mach[i]), mach[i]);
+	  printf("\n");
+	  printf("#endif /* __ASM_SH_MACHTYPES_H */\n");
+	}
diff -Nru a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
--- a/arch/sh/tools/mach-types	2004-12-24 13:37:30 -08:00
+++ b/arch/sh/tools/mach-types	2004-12-24 13:37:30 -08:00
@@ -8,6 +8,7 @@
 SE			SH_SOLUTION_ENGINE
 7751SE			SH_7751_SOLUTION_ENGINE		
 7300SE			SH_7300_SOLUTION_ENGINE
+73180SE			SH_73180_SOLUTION_ENGINE
 7751SYSTEMH		SH_7751_SYSTEMH
 HP600			SH_HP600
 HP620			SH_HP620
@@ -24,4 +25,7 @@
 SNAPGEAR		SH_SECUREEDGE5410
 HS7751RVOIP		SH_HS7751RVOIP
 RTS7751R2D		SH_RTS7751R2D
+EDOSK7705		SH_EDOSK7705
+SH4202_MICRODEV		SH_SH4202_MICRODEV
+SH03			SH_SH03
 
diff -Nru a/arch/sh/tools/machgen.sh b/arch/sh/tools/machgen.sh
--- a/arch/sh/tools/machgen.sh	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,71 +0,0 @@
-#!/bin/sh
-#
-# include/asm-sh/machtype.h header generation script for SuperH
-#
-# Copyright (C) 2003 Paul Mundt
-#
-# This is pretty much a quick and dirty hack based off of the awk
-# script written by rmk that ARM uses to achieve the same sort of
-# thing.
-#
-# Unfortunately this script has a dependance on bash/sed/cut/tr,
-# though they should be prevalent enough for this dependancy not
-# to matter overly much.
-#
-# As a note for anyone attempting to manually invoke this script,
-# it expects to be run straight out of the arch/sh/tools/ directory
-# as it doesn't look at TOPDIR to figure out where asm-sh is
-# located.
-#
-# See the note at the top of the generated header for additional
-# information.
-#
-# Released under the terms of the GNU GPL v2.0.
-#
-
-[ $# -ne 1 ] && echo "Usage: $0 <mach defs>" && exit 1
-
-cat << EOF > tmp.h
-/*
- * Automagically generated, don't touch.
- */
-#ifndef __ASM_SH_MACHTYPES_H
-#define __ASM_SH_MACHTYPES_H
-
-#include <linux/config.h>
-
-/*
- * We'll use the following MACH_xxx defs for placeholders for the time
- * being .. these will all go away once sh_machtype is assigned per-board.
- *
- * For now we leave things the way they are for backwards compatibility.
- */
-
-/* Mach types */
-EOF
-
-newline='
-'
-IFS=$newline
-
-rm -f tmp2.h
-
-for entry in `cat $1 | sed -e 's/\#.*$//g;/^$/d' | tr '\t' ' ' | tr -s ' '`; do
-	board=`echo $entry | cut -f1 -d' '`
-
-	printf "#ifdef CONFIG_`echo $entry | cut -f2 -d' '`\n" >> tmp.h
-	printf "  #define MACH_$board\t\t1\n#else\n  #define MACH_$board\t\t0\n#endif\n" >> tmp.h
-	printf "#define mach_is_`echo $board | tr '[A-Z]' '[a-z]'`()\t\t\t(MACH_$board)\n" >> tmp2.h
-done
-
-printf "\n/* Machtype checks */\n" >> tmp.h
-cat tmp2.h >> tmp.h && rm -f tmp2.h
-
-cat << EOF >> tmp.h
-
-#endif /* __ASM_SH_MACHTYPES_H */
-EOF
-
-cat tmp.h
-rm -f tmp.h
-
diff -Nru a/arch/sh64/kernel/irq.c b/arch/sh64/kernel/irq.c
--- a/arch/sh64/kernel/irq.c	2004-12-24 13:36:19 -08:00
+++ b/arch/sh64/kernel/irq.c	2004-12-24 13:36:19 -08:00
@@ -30,9 +30,9 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/smp.h>
 #include <asm/pgalloc.h>
 #include <asm/delay.h>
diff -Nru a/arch/sh64/kernel/irq_intc.c b/arch/sh64/kernel/irq_intc.c
--- a/arch/sh64/kernel/irq_intc.c	2004-12-24 13:37:30 -08:00
+++ b/arch/sh64/kernel/irq_intc.c	2004-12-24 13:37:30 -08:00
@@ -20,12 +20,12 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/stddef.h>
+#include <linux/bitops.h>       /* this includes also <asm/registers.h */
+                                /* which is required to remap register */
+                                /* names used into __asm__ blocks...   */
 
 #include <asm/hardware.h>
 #include <asm/platform.h>
-#include <asm/bitops.h>		/* this includes also <asm/registers.h */
-				/* which is required to remap register */
-				/* names used into __asm__ blocks...   */
 #include <asm/page.h>
 #include <asm/io.h>
 #include <asm/irq.h>
diff -Nru a/arch/sh64/kernel/pci_sh5.c b/arch/sh64/kernel/pci_sh5.c
--- a/arch/sh64/kernel/pci_sh5.c	2004-12-24 13:37:32 -08:00
+++ b/arch/sh64/kernel/pci_sh5.c	2004-12-24 13:37:32 -08:00
@@ -517,7 +517,7 @@
 		bus->resource[0]->flags |= IORESOURCE_IO;
 		bus->resource[1]->flags |= IORESOURCE_MEM;
 
-		/* For now, propogate host limits to the bus;
+		/* For now, propagate host limits to the bus;
 		 * we'll adjust them later. */
 
 #if 1
diff -Nru a/arch/sh64/kernel/process.c b/arch/sh64/kernel/process.c
--- a/arch/sh64/kernel/process.c	2004-12-24 13:37:43 -08:00
+++ b/arch/sh64/kernel/process.c	2004-12-24 13:37:43 -08:00
@@ -765,9 +765,6 @@
 	childregs->regs[9] = 0; /* Set return value for child */
 	childregs->sr |= SR_FD; /* Invalidate FPU flag */
 
-	/* From sh */
-	p->set_child_tid = p->clear_child_tid = NULL;
-
 	p->thread.sp = (unsigned long) childregs;
 	p->thread.pc = (unsigned long) ret_from_fork;
 
@@ -862,8 +859,11 @@
 			  (char __user * __user *)uargv,
 			  (char __user * __user *)uenvp,
 			  pregs);
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 out:
 	unlock_kernel();
diff -Nru a/arch/sh64/kernel/ptrace.c b/arch/sh64/kernel/ptrace.c
--- a/arch/sh64/kernel/ptrace.c	2004-12-24 13:37:02 -08:00
+++ b/arch/sh64/kernel/ptrace.c	2004-12-24 13:37:02 -08:00
@@ -257,7 +257,7 @@
  */
 	case PTRACE_KILL: {
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		wake_up_process(child);
diff -Nru a/arch/sh64/kernel/time.c b/arch/sh64/kernel/time.c
--- a/arch/sh64/kernel/time.c	2004-12-24 13:36:55 -08:00
+++ b/arch/sh64/kernel/time.c	2004-12-24 13:36:55 -08:00
@@ -309,6 +309,9 @@
 	ctc_last_interrupt = (unsigned long) current_ctc;
 
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	profile_tick(CPU_PROFILING, regs);
 
 #ifdef CONFIG_HEARTBEAT
diff -Nru a/arch/sparc/Kconfig b/arch/sparc/Kconfig
--- a/arch/sparc/Kconfig	2004-12-24 13:36:16 -08:00
+++ b/arch/sparc/Kconfig	2004-12-24 13:36:16 -08:00
@@ -27,6 +27,7 @@
 
 config VT
 	bool
+	select INPUT
 	default y
 	---help---
 	  If you say Y here, you will get support for terminal devices with
@@ -85,8 +86,8 @@
 	depends on BROKEN
 	---help---
 	  This enables support for systems with more than one CPU. If you have
-	  a system with only one CPU, like most personal computers, say N. If
-	  you have a system with more than one CPU, say Y.
+	  a system with only one CPU, say N. If you have a system with more
+	  than one CPU, say Y.
 
 	  If you say N here, the kernel will run on single and multiprocessor
 	  machines, but will use only one CPU of a multiprocessor machine. If
@@ -94,17 +95,11 @@
 	  singleprocessor machines. On a singleprocessor machine, the kernel
 	  will run faster if you say N here.
 
-	  Note that if you say Y here and choose architecture "586" or
-	  "Pentium" under "Processor family", the kernel will not work on 486
-	  architectures. Similarly, multiprocessor kernels for the "PPro"
-	  architecture may not work on all Pentium based boards.
-
 	  People using multiprocessor machines who say Y here should also say
 	  Y to "Enhanced Real Time Clock Support", below. The "Advanced Power
 	  Management" code will be disabled if you say Y here.
 
 	  See also the <file:Documentation/smp.txt>,
-	  <file:Documentation/i386/IO-APIC.txt>,
 	  <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
 	  <http://www.tldp.org/docs.html#howto>.
 
@@ -188,10 +183,10 @@
 	  (/dev/tty0) will still be used as the system console by default, but
 	  you can alter that using a kernel command line option such as
 	  "console=ttyS1". (Try "man bootparam" or see the documentation of
-	  your boot loader (lilo or loadlin) about how to pass options to the
-	  kernel at boot time.)
+	  your boot loader (silo) about how to pass options to the kernel at
+	  boot time.)
 
-	  If you don't have a VGA card installed and you say Y here, the
+	  If you don't have a graphics card installed and you say Y here, the
 	  kernel will automatically use the first serial line, /dev/ttyS0, as
 	  system console.
 
@@ -222,6 +217,7 @@
 config SUN4
 	bool "Support for SUN4 machines (disables SUN4[CDM] support)"
 	depends on !SMP
+	default n
 	help
 	  Say Y here if, and only if, your machine is a sun4. Note that
 	  a kernel compiled with this option will run only on sun4.
@@ -248,7 +244,10 @@
 	  -t openpromfs none /proc/openprom".
 
 	  To compile the /proc/openprom support as a module, choose M here: the
-	  module will be called openpromfs.  If unsure, choose M.
+	  module will be called openpromfs.
+
+	  Only choose N if you know in advance that you will not need to modify
+	  OpenPROM settings on the running system.
 
 source "fs/Kconfig.binfmt"
 
@@ -281,9 +280,9 @@
 
 	  If you have several parallel ports, you can specify which ports to
 	  use with the "lp" kernel command line option.  (Try "man bootparam"
-	  or see the documentation of your boot loader (lilo or loadlin) about
-	  how to pass options to the kernel at boot time.)  The syntax of the
-	  "lp" command line option can be found in <file:drivers/char/lp.c>.
+	  or see the documentation of your boot loader (silo) about how to pass
+	  options to the kernel at boot time.)  The syntax of the "lp" command
+	  line option can be found in <file:drivers/char/lp.c>.
 
 	  If you have more than 8 printers, you need to increase the LP_NO
 	  macro in lp.c and the PARPORT_MAX macro in parport.h.
diff -Nru a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
--- a/arch/sparc/kernel/apc.c	2004-12-24 13:37:30 -08:00
+++ b/arch/sparc/kernel/apc.c	2004-12-24 13:37:30 -08:00
@@ -28,7 +28,7 @@
 #define APC_OBPNAME	"power-management"
 #define APC_DEVNAME "apc"
 
-volatile static u8 *regs; 
+volatile static u8 __iomem *regs; 
 static int apc_regsize;
 static int apc_no_idle __initdata = 0;
 
@@ -70,7 +70,7 @@
 
 static inline void apc_free(void)
 {
-	sbus_iounmap((unsigned long)regs, apc_regsize);
+	sbus_iounmap(regs, apc_regsize);
 }
 
 static int apc_open(struct inode *inode, struct file *f)
@@ -155,9 +155,9 @@
 	}
 
 	apc_regsize = sdev->reg_addrs[0].reg_size;
-	regs = (u8*) sbus_ioremap(&sdev->resource[0], 0, 
+	regs = sbus_ioremap(&sdev->resource[0], 0, 
 				   apc_regsize, APC_OBPNAME);
-	if(NULL == regs) {
+	if(!regs) {
 		printk(KERN_ERR "%s: unable to map registers\n", APC_DEVNAME);
 		return -ENODEV;
 	}
diff -Nru a/arch/sparc/kernel/auxio.c b/arch/sparc/kernel/auxio.c
--- a/arch/sparc/kernel/auxio.c	2004-12-24 13:37:02 -08:00
+++ b/arch/sparc/kernel/auxio.c	2004-12-24 13:37:02 -08:00
@@ -17,7 +17,7 @@
 /* auxio_register is not static because it is referenced 
  * in entry.S::floppy_tdone
  */
-unsigned long auxio_register = 0UL;
+void __iomem *auxio_register = NULL;
 static spinlock_t auxio_lock = SPIN_LOCK_UNLOCKED;
 
 void __init auxio_probe(void)
@@ -63,7 +63,7 @@
 	/* Fix the address on sun4m and sun4c. */
 	if((((unsigned long) auxregs[0].phys_addr) & 3) == 3 ||
 	   sparc_cpu_model == sun4c)
-		auxio_register |= 3;
+		auxio_register += (3 - ((unsigned long)auxio_register & 3));
 
 	set_auxio(AUXIO_LED, 0);
 }
diff -Nru a/arch/sparc/kernel/ebus.c b/arch/sparc/kernel/ebus.c
--- a/arch/sparc/kernel/ebus.c	2004-12-24 13:37:29 -08:00
+++ b/arch/sparc/kernel/ebus.c	2004-12-24 13:37:29 -08:00
@@ -275,7 +275,7 @@
 		}
 	}
 
-	pdev = pci_find_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, 0);
+	pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, 0);
 	if (!pdev) {
 		return;
 	}
@@ -342,7 +342,7 @@
 		}
 
 	next_ebus:
-		pdev = pci_find_device(PCI_VENDOR_ID_SUN,
+		pdev = pci_get_device(PCI_VENDOR_ID_SUN,
 				       PCI_DEVICE_ID_SUN_EBUS, pdev);
 		if (!pdev)
 			break;
@@ -356,4 +356,6 @@
 		ebus->next = 0;
 		++num_ebus;
 	}
+	if (pdev)
+		pci_dev_put(pdev);
 }
diff -Nru a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
--- a/arch/sparc/kernel/entry.S	2004-12-24 13:36:48 -08:00
+++ b/arch/sparc/kernel/entry.S	2004-12-24 13:36:48 -08:00
@@ -38,7 +38,7 @@
 
 #define curptr      g6
 
-#define NR_SYSCALLS 283      /* Each OS is different... */
+#define NR_SYSCALLS 284      /* Each OS is different... */
 
 /* These are just handy. */
 #define _SV	save	%sp, -STACKFRAME_SZ, %sp
@@ -1508,7 +1508,7 @@
 	.globl	ret_sys_call
 ret_sys_call:
 	ld	[%curptr + TI_FLAGS], %l6
-	cmp	%o0, -ENOIOCTLCMD
+	cmp	%o0, -ERESTART_RESTARTBLOCK
 	ld	[%sp + STACKFRAME_SZ + PT_PSR], %g3
 	set	PSR_C, %g2
 	bgeu	1f
@@ -1587,7 +1587,7 @@
 
 	st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 	set	PSR_C, %g2
-	cmp	%o0, -ENOIOCTLCMD
+	cmp	%o0, -ERESTART_RESTARTBLOCK
 	bgeu	1f
 	 ld	[%sp + STACKFRAME_SZ + PT_PSR], %g3
 
@@ -1678,7 +1678,7 @@
 
 	st	%o0, [%sp + STACKFRAME_SZ + PT_I0]
 	set	PSR_C, %g2
-	cmp	%o0, -ENOIOCTLCMD
+	cmp	%o0, -ERESTART_RESTARTBLOCK
 	bgeu	1f
 	 ld	[%sp + STACKFRAME_SZ + PT_PSR], %g3
 
diff -Nru a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
--- a/arch/sparc/kernel/ioport.c	2004-12-24 13:37:30 -08:00
+++ b/arch/sparc/kernel/ioport.c	2004-12-24 13:37:30 -08:00
@@ -47,8 +47,8 @@
 
 struct resource *_sparc_find_resource(struct resource *r, unsigned long);
 
-static void *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz);
-static void *_sparc_alloc_io(unsigned int busno, unsigned long phys,
+static void __iomem *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz);
+static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
     unsigned long size, char *name);
 static void _sparc_free_io(struct resource *res);
 
@@ -103,7 +103,7 @@
  *
  * Bus type is always zero on IIep.
  */
-void *ioremap(unsigned long offset, unsigned long size)
+void __iomem *ioremap(unsigned long offset, unsigned long size)
 {
 	char name[14];
 
@@ -114,7 +114,7 @@
 /*
  * Comlimentary to ioremap().
  */
-void iounmap(void *virtual)
+void iounmap(volatile void __iomem *virtual)
 {
 	unsigned long vaddr = (unsigned long) virtual & PAGE_MASK;
 	struct resource *res;
@@ -134,24 +134,24 @@
 
 /*
  */
-unsigned long sbus_ioremap(struct resource *phyres, unsigned long offset,
+void __iomem *sbus_ioremap(struct resource *phyres, unsigned long offset,
     unsigned long size, char *name)
 {
-	return (unsigned long) _sparc_alloc_io(phyres->flags & 0xF,
+	return _sparc_alloc_io(phyres->flags & 0xF,
 	    phyres->start + offset, size, name);
 }
 
 /*
  */
-void sbus_iounmap(unsigned long addr, unsigned long size)
+void sbus_iounmap(volatile void __iomem *addr, unsigned long size)
 {
-	iounmap((void *)addr);
+	iounmap(addr);
 }
 
 /*
  * Meat of mapping
  */
-static void *_sparc_alloc_io(unsigned int busno, unsigned long phys,
+static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
     unsigned long size, char *name)
 {
 	static int printed_full;
@@ -159,7 +159,7 @@
 	struct resource *res;
 	char *tack;
 	int tlen;
-	void *va;	/* P3 diag */
+	void __iomem *va;	/* P3 diag */
 
 	if (name == NULL) name = "???";
 
@@ -189,7 +189,7 @@
 
 /*
  */
-static void *
+static void __iomem *
 _sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz)
 {
 	unsigned long offset = ((unsigned long) pa) & (~PAGE_MASK);
@@ -206,7 +206,7 @@
 	pa &= PAGE_MASK;
 	sparc_mapiorange(bus, pa, res->start, res->end - res->start + 1);
 
-	return (void *) (res->start + offset);
+	return (void __iomem *) (res->start + offset);
 }
 
 /*
diff -Nru a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
--- a/arch/sparc/kernel/pcic.c	2004-12-24 13:36:55 -08:00
+++ b/arch/sparc/kernel/pcic.c	2004-12-24 13:36:55 -08:00
@@ -603,7 +603,7 @@
  */
 void __init pcibios_fixup_bus(struct pci_bus *bus)
 {
-	struct list_head *walk;
+	struct pci_dev *dev;
 	int i, has_io, has_mem;
 	unsigned int cmd;
 	struct linux_pcic *pcic;
@@ -625,9 +625,7 @@
 		return;
 	}
 
-	walk = &bus->devices;
-	for (walk = walk->next; walk != &bus->devices; walk = walk->next) {
-		struct pci_dev *dev = pci_dev_b(walk);
+	list_for_each_entry(dev, &bus->devices, bus_list) {
 
 		/*
 		 * Comment from i386 branch:
@@ -716,6 +714,9 @@
 	write_seqlock(&xtime_lock);	/* Dummy, to show that we remember */
 	pcic_clear_clock_irq();
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	write_sequnlock(&xtime_lock);
 	return IRQ_HANDLED;
 }
diff -Nru a/arch/sparc/kernel/pmc.c b/arch/sparc/kernel/pmc.c
--- a/arch/sparc/kernel/pmc.c	2004-12-24 13:37:18 -08:00
+++ b/arch/sparc/kernel/pmc.c	2004-12-24 13:37:18 -08:00
@@ -30,7 +30,7 @@
 #define PMC_IDLE_REG	0x00
 #define PMC_IDLE_ON		0x01
 
-volatile static u8 *regs; 
+volatile static u8 __iomem *regs; 
 static int pmc_regsize;
 
 #define pmc_readb(offs)			(sbus_readb(regs+offs))
@@ -55,7 +55,7 @@
 
 static inline void pmc_free(void)
 {
-	sbus_iounmap((unsigned long)regs, pmc_regsize);
+	sbus_iounmap(regs, pmc_regsize);
 }
 
 static int __init pmc_probe(void)
@@ -76,9 +76,9 @@
 	}
 
 	pmc_regsize = sdev->reg_addrs[0].reg_size;
-	regs = (u8*) sbus_ioremap(&sdev->resource[0], 0, 
+	regs = sbus_ioremap(&sdev->resource[0], 0, 
 				   pmc_regsize, PMC_OBPNAME);
-	if(NULL == regs) {
+	if (!regs) {
 		printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME);
 		return -ENODEV;
 	}
diff -Nru a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c
--- a/arch/sparc/kernel/process.c	2004-12-24 13:36:18 -08:00
+++ b/arch/sparc/kernel/process.c	2004-12-24 13:36:18 -08:00
@@ -45,7 +45,7 @@
 
 /* 
  * Power management idle function 
- * Set in pm platform drivers
+ * Set in pm platform drivers (apc.c and pmc.c)
  */
 void (*pm_idle)(void);
 
@@ -122,7 +122,7 @@
 		}
 
 		while((!need_resched()) && pm_idle) {
-			(*pm_idle)();		/* XXX Huh? On sparc?! */
+			(*pm_idle)();
 		}
 
 		schedule();
@@ -480,8 +480,6 @@
 #endif
 	}
 
-	p->set_child_tid = p->clear_child_tid = NULL;
-
 	/*
 	 *  p->thread_info         new_stack   childregs
 	 *  !                      !           !             {if(PSR_PS) }
@@ -670,8 +668,11 @@
 			  (char __user * __user *)regs->u_regs[base + UREG_I2],
 			  regs);
 	putname(filename);
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 out:
 	return error;
 }
diff -Nru a/arch/sparc/kernel/ptrace.c b/arch/sparc/kernel/ptrace.c
--- a/arch/sparc/kernel/ptrace.c	2004-12-24 13:37:31 -08:00
+++ b/arch/sparc/kernel/ptrace.c	2004-12-24 13:37:31 -08:00
@@ -567,7 +567,7 @@
  * exit.
  */
 	case PTRACE_KILL: {
-		if (child->state == TASK_ZOMBIE) {	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE) {	/* already dead */
 			pt_succ_return(regs, 0);
 			goto out_tsk;
 		}
diff -Nru a/arch/sparc/kernel/signal.c b/arch/sparc/kernel/signal.c
--- a/arch/sparc/kernel/signal.c	2004-12-24 13:37:02 -08:00
+++ b/arch/sparc/kernel/signal.c	2004-12-24 13:37:02 -08:00
@@ -20,9 +20,9 @@
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/binfmts.h>	/* do_coredum */
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/ptrace.h>
 #include <asm/svr4.h>
 #include <asm/pgalloc.h>
diff -Nru a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c
--- a/arch/sparc/kernel/sys_sunos.c	2004-12-24 13:36:48 -08:00
+++ b/arch/sparc/kernel/sys_sunos.c	2004-12-24 13:36:48 -08:00
@@ -178,7 +178,7 @@
 	 * Check against rlimit and stack..
 	 */
 	retval = -ENOMEM;
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim >= RLIM_INFINITY)
 		rlim = ~0;
 	if (brk - current->mm->end_code > rlim)
diff -Nru a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
--- a/arch/sparc/kernel/systbls.S	2004-12-24 13:36:49 -08:00
+++ b/arch/sparc/kernel/systbls.S	2004-12-24 13:36:49 -08:00
@@ -75,7 +75,7 @@
 /*265*/	.long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
 /*270*/	.long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
 /*275*/	.long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
-/*280*/	.long sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
+/*280*/	.long sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl
 
 #ifdef CONFIG_SUNOS_EMUL
 	/* Now the SunOS syscall table. */
@@ -181,5 +181,6 @@
 	.long sunos_nosys, sunos_nosys, sunos_nosys
 	.long sunos_nosys
 /*280*/	.long sunos_nosys, sunos_nosys, sunos_nosys
+	.long sunos_nosys
 
 #endif
diff -Nru a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
--- a/arch/sparc/kernel/time.c	2004-12-24 13:37:43 -08:00
+++ b/arch/sparc/kernel/time.c	2004-12-24 13:37:43 -08:00
@@ -53,7 +53,7 @@
 spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
 enum sparc_clock_type sp_clock_typ;
 spinlock_t mostek_lock = SPIN_LOCK_UNLOCKED;
-unsigned long mstk48t02_regs = 0UL;
+void __iomem *mstk48t02_regs = NULL;
 static struct mostek48t08 *mstk48t08_regs = NULL;
 static int set_rtc_mmss(unsigned long);
 static int sbus_do_settimeofday(struct timespec *tv);
@@ -134,6 +134,10 @@
 	clear_clock_irq();
 
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
+
 
 	/* Determine when to update the Mostek clock. */
 	if ((time_status & STA_UNSYNC) == 0 &&
@@ -346,7 +350,7 @@
 		mstk48t08_regs = (struct mostek48t08 *) sbus_ioremap(&r, 0,
 		    sizeof(struct mostek48t08), "mk48t08");
 
-		mstk48t02_regs = (unsigned long)&mstk48t08_regs->regs;
+		mstk48t02_regs = &mstk48t08_regs->regs;
 	} else {
 		prom_printf("CLOCK: Unknown model name '%s'\n",model);
 		prom_halt();
diff -Nru a/arch/sparc/lib/bitext.c b/arch/sparc/lib/bitext.c
--- a/arch/sparc/lib/bitext.c	2004-12-24 13:36:48 -08:00
+++ b/arch/sparc/lib/bitext.c	2004-12-24 13:36:48 -08:00
@@ -10,9 +10,9 @@
  */
 
 #include <linux/smp_lock.h>
+#include <linux/bitops.h>
 
 #include <asm/bitext.h>
-#include <asm/bitops.h>
 
 /**
  * bit_map_string_get - find and set a bit string in bit map.
diff -Nru a/arch/sparc/mm/generic.c b/arch/sparc/mm/generic.c
--- a/arch/sparc/mm/generic.c	2004-12-24 13:37:19 -08:00
+++ b/arch/sparc/mm/generic.c	2004-12-24 13:37:19 -08:00
@@ -41,7 +41,7 @@
 #endif
 }
 
-/* Remap IO memory, the same way as remap_page_range(), but use
+/* Remap IO memory, the same way as remap_pfn_range(), but use
  * the obio memory space.
  *
  * They use a pgprot that sets PAGE_IO and does not check the
diff -Nru a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
--- a/arch/sparc/mm/io-unit.c	2004-12-24 13:36:48 -08:00
+++ b/arch/sparc/mm/io-unit.c	2004-12-24 13:36:48 -08:00
@@ -11,6 +11,7 @@
 #include <linux/spinlock.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>	/* pte_offset_map => kmap_atomic */
+#include <linux/bitops.h>
 
 #include <asm/scatterlist.h>
 #include <asm/pgalloc.h>
@@ -19,7 +20,6 @@
 #include <asm/io.h>
 #include <asm/io-unit.h>
 #include <asm/mxcc.h>
-#include <asm/bitops.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 #include <asm/dma.h>
diff -Nru a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
--- a/arch/sparc/mm/iommu.c	2004-12-24 13:37:30 -08:00
+++ b/arch/sparc/mm/iommu.c	2004-12-24 13:37:30 -08:00
@@ -173,6 +173,7 @@
 	}
 
 	iommu_viking_flush_iotlb(iopte0, npages);
+	flush_cache_all(); // hack to fix dma errors with hypersparc
 
 	return busa0;
 }
diff -Nru a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
--- a/arch/sparc/mm/srmmu.c	2004-12-24 13:36:59 -08:00
+++ b/arch/sparc/mm/srmmu.c	2004-12-24 13:36:59 -08:00
@@ -1463,6 +1463,7 @@
 static void __init init_hypersparc(void)
 {
 	srmmu_name = "ROSS HyperSparc";
+	srmmu_modtype = HyperSparc;
 
 	init_vac_layout();
 
diff -Nru a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
--- a/arch/sparc64/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/arch/sparc64/Kconfig	2004-12-24 13:37:19 -08:00
@@ -135,16 +135,7 @@
 	depends on SMP
 	default "32"
 
-config CPU_FREQ
-	bool "CPU Frequency scaling"
-	help
-	  Clock scaling allows you to change the clock speed of CPUs on the
-	  fly.  Currently there are only sparc64 drivers for UltraSPARC-III
-	  and UltraSPARC-IIe processors.
-
-	  For details, take a look at <file:Documentation/cpu-freq>.
-
-	  If in doubt, say N.
+source "drivers/cpufreq/Kconfig"
 
 config CPU_FREQ_TABLE
        tristate "CPU frequency table helpers"
@@ -175,8 +166,6 @@
 	  For details, take a look at <file:Documentation/cpu-freq>.
 
 	  If in doubt, say N.
-
-source "drivers/cpufreq/Kconfig"
 
 # Identify this as a Sparc64 build
 config SPARC64
diff -Nru a/arch/sparc64/Makefile b/arch/sparc64/Makefile
--- a/arch/sparc64/Makefile	2004-12-24 13:37:30 -08:00
+++ b/arch/sparc64/Makefile	2004-12-24 13:37:30 -08:00
@@ -8,7 +8,7 @@
 # Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
 #
 
-CHECKFLAGS	+= -D__sparc__ -D__sparc_v9__
+CHECKFLAGS	+= -D__sparc__ -D__sparc_v9__ -m64
 
 CPPFLAGS_vmlinux.lds += -Usparc
 
diff -Nru a/arch/sparc64/defconfig b/arch/sparc64/defconfig
--- a/arch/sparc64/defconfig	2004-12-24 13:36:47 -08:00
+++ b/arch/sparc64/defconfig	2004-12-24 13:36:47 -08:00
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-rc3
-# Sun Oct  3 14:28:53 2004
+# Linux kernel version: 2.6.10-rc3
+# Wed Dec  8 21:14:26 2004
 #
 CONFIG_64BIT=y
 CONFIG_MMU=y
@@ -12,6 +12,7 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
@@ -25,6 +26,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=15
 CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
@@ -32,12 +34,12 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_TINY_SHMEM is not set
 
 #
@@ -48,6 +50,7 @@
 CONFIG_MODULE_FORCE_UNLOAD=y
 CONFIG_OBSOLETE_MODPARM=y
 CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
@@ -62,17 +65,18 @@
 # CONFIG_PREEMPT is not set
 CONFIG_NR_CPUS=4
 CONFIG_CPU_FREQ=y
-CONFIG_CPU_FREQ_TABLE=y
-CONFIG_US3_FREQ=m
-CONFIG_US2E_FREQ=m
+# CONFIG_CPU_FREQ_DEBUG is not set
 CONFIG_CPU_FREQ_PROC_INTF=y
 CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
 # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
 CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
 CONFIG_CPU_FREQ_GOV_POWERSAVE=m
 CONFIG_CPU_FREQ_GOV_USERSPACE=m
-CONFIG_CPU_FREQ_GOV_ONDEMAND=m
 # CONFIG_CPU_FREQ_24_API is not set
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_TABLE=y
+CONFIG_US3_FREQ=m
+CONFIG_US2E_FREQ=m
 CONFIG_SPARC64=y
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
 CONFIG_HUGETLB_PAGE_SIZE_4MB=y
@@ -126,6 +130,7 @@
 #
 CONFIG_FB=y
 CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
 # CONFIG_FB_CIRRUS is not set
 CONFIG_FB_PM2=y
 # CONFIG_FB_PM2_FIFO_DISCONNECT is not set
@@ -141,8 +146,10 @@
 # CONFIG_FB_ATY128 is not set
 CONFIG_FB_ATY=y
 CONFIG_FB_ATY_CT=y
-CONFIG_FB_ATY_GX=y
+# CONFIG_FB_ATY_GENERIC_LCD is not set
 # CONFIG_FB_ATY_XL_INIT is not set
+CONFIG_FB_ATY_GX=y
+# CONFIG_FB_SAVAGE is not set
 # CONFIG_FB_SIS is not set
 # CONFIG_FB_NEOMAGIC is not set
 # CONFIG_FB_KYRO is not set
@@ -226,6 +233,19 @@
 CONFIG_BLK_DEV_SX8=m
 CONFIG_BLK_DEV_UB=m
 # CONFIG_BLK_DEV_RAM is not set
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -244,7 +264,6 @@
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_BLK_DEV_IDESCSI is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
 
 #
 # IDE chipset support/bugfixes
@@ -338,6 +357,7 @@
 # CONFIG_MEGARAID_NEWGEN is not set
 # CONFIG_MEGARAID_LEGACY is not set
 CONFIG_SCSI_SATA=y
+CONFIG_SCSI_SATA_AHCI=m
 CONFIG_SCSI_SATA_SVW=m
 CONFIG_SCSI_ATA_PIIX=m
 CONFIG_SCSI_SATA_NV=m
@@ -345,12 +365,14 @@
 CONFIG_SCSI_SATA_SX4=m
 CONFIG_SCSI_SATA_SIL=m
 CONFIG_SCSI_SATA_SIS=m
+CONFIG_SCSI_SATA_ULI=m
 CONFIG_SCSI_SATA_VIA=m
 CONFIG_SCSI_SATA_VITESSE=m
 CONFIG_SCSI_DMX3191D=m
 CONFIG_SCSI_EATA_PIO=m
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
 CONFIG_SCSI_INIA100=m
 CONFIG_SCSI_PPA=m
 CONFIG_SCSI_IMM=m
@@ -408,6 +430,7 @@
 CONFIG_MD_RAID5=m
 CONFIG_MD_RAID6=m
 CONFIG_MD_MULTIPATH=m
+# CONFIG_MD_FAULTY is not set
 CONFIG_BLK_DEV_DM=m
 CONFIG_DM_CRYPT=m
 CONFIG_DM_SNAPSHOT=m
@@ -482,6 +505,8 @@
 CONFIG_INET_ESP=y
 CONFIG_INET_IPCOMP=y
 CONFIG_INET_TUNNEL=y
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 
 #
 # IP: Virtual Server Configuration
@@ -532,6 +557,7 @@
 #
 CONFIG_IP_NF_CONNTRACK=m
 CONFIG_IP_NF_CT_ACCT=y
+CONFIG_IP_NF_CONNTRACK_MARK=y
 CONFIG_IP_NF_CT_PROTO_SCTP=m
 CONFIG_IP_NF_FTP=m
 CONFIG_IP_NF_IRC=m
@@ -562,6 +588,8 @@
 CONFIG_IP_NF_MATCH_REALM=m
 CONFIG_IP_NF_MATCH_SCTP=m
 CONFIG_IP_NF_MATCH_COMMENT=m
+CONFIG_IP_NF_MATCH_CONNMARK=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
 CONFIG_IP_NF_TARGET_LOG=m
@@ -585,6 +613,8 @@
 CONFIG_IP_NF_TARGET_DSCP=m
 CONFIG_IP_NF_TARGET_MARK=m
 CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_CONNMARK=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_RAW=m
 CONFIG_IP_NF_TARGET_NOTRACK=m
 CONFIG_IP_NF_ARPTABLES=m
@@ -667,7 +697,6 @@
 CONFIG_BRIDGE=m
 CONFIG_VLAN_8021Q=m
 CONFIG_DECNET=m
-CONFIG_DECNET_SIOCGIFCONF=y
 CONFIG_DECNET_ROUTER=y
 CONFIG_DECNET_ROUTE_FWMARK=y
 CONFIG_LLC=m
@@ -681,7 +710,6 @@
 CONFIG_NET_DIVERT=y
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -719,6 +747,9 @@
 CONFIG_NET_ACT_POLICE=m
 CONFIG_NET_ACT_GACT=m
 CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_PEDIT=m
 
 #
 # Network testing
@@ -880,7 +911,6 @@
 CONFIG_SUNDANCE_MMIO=y
 CONFIG_VIA_RHINE=m
 # CONFIG_VIA_RHINE_MMIO is not set
-CONFIG_VIA_VELOCITY=m
 
 #
 # Ethernet (1000 Mbit)
@@ -897,6 +927,7 @@
 CONFIG_R8169=m
 CONFIG_R8169_NAPI=y
 CONFIG_SK98LIN=m
+CONFIG_VIA_VELOCITY=m
 CONFIG_TIGON3=m
 
 #
@@ -1014,6 +1045,11 @@
 # Active AVM cards
 #
 CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
 
 #
 # Active Eicon DIVA Server cards
@@ -1121,6 +1157,7 @@
 CONFIG_I2C_ALI1563=m
 CONFIG_I2C_ALI15X3=m
 CONFIG_I2C_AMD756=m
+# CONFIG_I2C_AMD756_S4882 is not set
 CONFIG_I2C_AMD8111=m
 CONFIG_I2C_I801=m
 CONFIG_I2C_I810=m
@@ -1134,6 +1171,7 @@
 CONFIG_I2C_SIS5595=m
 CONFIG_I2C_SIS630=m
 CONFIG_I2C_SIS96X=m
+CONFIG_I2C_STUB=m
 CONFIG_I2C_VIA=m
 CONFIG_I2C_VIAPRO=m
 CONFIG_I2C_VOODOO3=m
@@ -1145,20 +1183,24 @@
 CONFIG_I2C_SENSOR=m
 CONFIG_SENSORS_ADM1021=m
 CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
 CONFIG_SENSORS_ADM1031=m
 CONFIG_SENSORS_ASB100=m
 CONFIG_SENSORS_DS1621=m
 CONFIG_SENSORS_FSCHER=m
 CONFIG_SENSORS_GL518SM=m
 CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
 CONFIG_SENSORS_LM75=m
 CONFIG_SENSORS_LM77=m
 CONFIG_SENSORS_LM78=m
 CONFIG_SENSORS_LM80=m
 CONFIG_SENSORS_LM83=m
 CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
 CONFIG_SENSORS_LM90=m
 CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_PC87360=m
 CONFIG_SENSORS_SMSC47M1=m
 CONFIG_SENSORS_VIA686A=m
 CONFIG_SENSORS_W83781D=m
@@ -1206,6 +1248,7 @@
 CONFIG_ROMFS_FS=m
 # CONFIG_QUOTA is not set
 CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
 CONFIG_AUTOFS_FS=m
 CONFIG_AUTOFS4_FS=m
 
@@ -1240,6 +1283,8 @@
 CONFIG_DEVPTS_FS_XATTR=y
 # CONFIG_DEVPTS_FS_SECURITY is not set
 CONFIG_TMPFS=y
+CONFIG_TMPFS_XATTR=y
+CONFIG_TMPFS_SECURITY=y
 CONFIG_HUGETLBFS=y
 CONFIG_HUGETLB_PAGE=y
 CONFIG_RAMFS=y
@@ -1378,7 +1423,7 @@
 CONFIG_TUNER_3036=m
 # CONFIG_VIDEO_STRADIS is not set
 # CONFIG_VIDEO_ZORAN is not set
-CONFIG_VIDEO_SAA7134=m
+# CONFIG_VIDEO_SAA7134 is not set
 CONFIG_VIDEO_MXB=m
 CONFIG_VIDEO_DPC=m
 CONFIG_VIDEO_HEXIUM_ORION=m
@@ -1400,26 +1445,6 @@
 CONFIG_DVB_CORE=m
 
 #
-# Supported Frontend Modules
-#
-CONFIG_DVB_TWINHAN_DST=m
-CONFIG_DVB_STV0299=m
-CONFIG_DVB_SP887X=m
-CONFIG_DVB_SP887X_FIRMWARE_FILE="/etc/dvb/sc_main.mc"
-CONFIG_DVB_ALPS_TDLB7=m
-CONFIG_DVB_ALPS_TDMB7=m
-CONFIG_DVB_ATMEL_AT76C651=m
-CONFIG_DVB_CX24110=m
-CONFIG_DVB_GRUNDIG_29504_491=m
-CONFIG_DVB_GRUNDIG_29504_401=m
-CONFIG_DVB_MT312=m
-CONFIG_DVB_VES1820=m
-CONFIG_DVB_VES1X93=m
-CONFIG_DVB_TDA1004X=m
-CONFIG_DVB_TDA1004X_FIRMWARE_FILE="/usr/lib/hotplug/firmware/tda1004x.bin"
-CONFIG_DVB_NXT6000=m
-
-#
 # Supported SAA7146 based PCI Adapters
 #
 CONFIG_DVB_AV7110=m
@@ -1434,6 +1459,11 @@
 #
 # CONFIG_DVB_TTUSB_BUDGET is not set
 CONFIG_DVB_TTUSB_DEC=m
+CONFIG_DVB_DIBUSB=m
+CONFIG_DVB_DIBUSB_MISDESIGNED_AN2235=y
+CONFIG_DVB_DIBCOM_DEBUG=y
+CONFIG_DVB_CINERGYT2=m
+# CONFIG_DVB_CINERGYT2_TUNING is not set
 
 #
 # Supported FlexCopII (B2C2) Adapters
@@ -1444,6 +1474,45 @@
 # Supported BT878 Adapters
 #
 CONFIG_DVB_BT8XX=m
+
+#
+# Supported DVB Frontends
+#
+
+#
+# Customise DVB Frontends
+#
+
+#
+# DVB-S (satellite) frontends
+#
+CONFIG_DVB_STV0299=m
+CONFIG_DVB_CX24110=m
+CONFIG_DVB_TDA8083=m
+CONFIG_DVB_TDA80XX=m
+CONFIG_DVB_MT312=m
+CONFIG_DVB_VES1X93=m
+
+#
+# DVB-T (terrestrial) frontends
+#
+CONFIG_DVB_SP8870=m
+CONFIG_DVB_SP887X=m
+CONFIG_DVB_CX22700=m
+CONFIG_DVB_CX22702=m
+CONFIG_DVB_L64781=m
+CONFIG_DVB_TDA1004X=m
+CONFIG_DVB_NXT6000=m
+CONFIG_DVB_MT352=m
+CONFIG_DVB_DIB3000MB=m
+
+#
+# DVB-C (cable) frontends
+#
+CONFIG_DVB_ATMEL_AT76C651=m
+CONFIG_DVB_VES1820=m
+CONFIG_DVB_TDA10021=m
+CONFIG_DVB_STV0297=m
 CONFIG_VIDEO_SAA7146=m
 CONFIG_VIDEO_SAA7146_VV=m
 CONFIG_VIDEO_VIDEOBUF=m
@@ -1500,6 +1569,7 @@
 CONFIG_SND_AU8830=m
 CONFIG_SND_AZT3328=m
 CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
 CONFIG_SND_CS46XX=m
 # CONFIG_SND_CS46XX_NEW_DSP is not set
 CONFIG_SND_CS4281=m
@@ -1531,7 +1601,7 @@
 CONFIG_SND_VX222=m
 
 #
-# ALSA USB devices
+# USB devices
 #
 # CONFIG_SND_USB_AUDIO is not set
 CONFIG_SND_USB_USX2Y=m
@@ -1555,6 +1625,8 @@
 # CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_OTG is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Host Controller Drivers
@@ -1576,6 +1648,10 @@
 # CONFIG_USB_MIDI is not set
 CONFIG_USB_ACM=m
 CONFIG_USB_PRINTER=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
 CONFIG_USB_STORAGE=m
 # CONFIG_USB_STORAGE_DEBUG is not set
 CONFIG_USB_STORAGE_RW_DETECT=y
@@ -1589,7 +1665,7 @@
 # CONFIG_USB_STORAGE_JUMPSHOT is not set
 
 #
-# USB Human Interface Devices (HID)
+# USB Input Devices
 #
 CONFIG_USB_HID=y
 CONFIG_USB_HIDINPUT=y
@@ -1626,7 +1702,7 @@
 CONFIG_USB_W9968CF=m
 
 #
-# USB Network adaptors
+# USB Network Adapters
 #
 CONFIG_USB_CATC=m
 CONFIG_USB_KAWETH=m
@@ -1643,6 +1719,7 @@
 CONFIG_USB_GENESYS=y
 CONFIG_USB_NET1080=y
 CONFIG_USB_PL2301=y
+CONFIG_USB_KC2190=y
 
 #
 # Intelligent USB Devices/Gadgets
@@ -1669,6 +1746,7 @@
 CONFIG_USB_SERIAL_GENERIC=y
 CONFIG_USB_SERIAL_BELKIN=m
 CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
 CONFIG_USB_SERIAL_EMPEG=m
 CONFIG_USB_SERIAL_FTDI_SIO=m
 # CONFIG_USB_SERIAL_VISOR is not set
@@ -1676,6 +1754,7 @@
 # CONFIG_USB_SERIAL_IR is not set
 CONFIG_USB_SERIAL_EDGEPORT=m
 # CONFIG_USB_SERIAL_EDGEPORT_TI is not set
+CONFIG_USB_SERIAL_IPW=m
 CONFIG_USB_SERIAL_KEYSPAN_PDA=m
 CONFIG_USB_SERIAL_KEYSPAN=m
 # CONFIG_USB_SERIAL_KEYSPAN_MPR is not set
@@ -1712,11 +1791,17 @@
 CONFIG_USB_LCD=m
 CONFIG_USB_LED=m
 CONFIG_USB_CYTHERM=m
-CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_PHIDGETKIT=m
 CONFIG_USB_PHIDGETSERVO=m
 CONFIG_USB_TEST=m
 
 #
+# USB ATM/DSL drivers
+#
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+
+#
 # USB Gadget Support
 #
 # CONFIG_USB_GADGET is not set
@@ -1757,9 +1842,11 @@
 #
 CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
+CONFIG_SCHEDSTATS=y
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
 # CONFIG_DEBUG_BUGVERBOSE is not set
 # CONFIG_DEBUG_INFO is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
@@ -1772,6 +1859,8 @@
 #
 # Security options
 #
+CONFIG_KEYS=y
+# CONFIG_KEYS_DEBUG_PROC_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
@@ -1796,6 +1885,7 @@
 CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_ARC4=m
 CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_CRC32C=m
diff -Nru a/arch/sparc64/kernel/binfmt_aout32.c b/arch/sparc64/kernel/binfmt_aout32.c
--- a/arch/sparc64/kernel/binfmt_aout32.c	2004-12-24 13:36:49 -08:00
+++ b/arch/sparc64/kernel/binfmt_aout32.c	2004-12-24 13:36:49 -08:00
@@ -102,12 +102,12 @@
 /* If the size of the dump file exceeds the rlimit, then see what would happen
    if we wrote the stack, but not the data area.  */
 	if ((dump.u_dsize+dump.u_ssize) >
-	    current->rlim[RLIMIT_CORE].rlim_cur)
+	    current->signal->rlim[RLIMIT_CORE].rlim_cur)
 		dump.u_dsize = 0;
 
 /* Make sure we have enough room to write the stack and data areas. */
 	if ((dump.u_ssize) >
-	    current->rlim[RLIMIT_CORE].rlim_cur)
+	    current->signal->rlim[RLIMIT_CORE].rlim_cur)
 		dump.u_ssize = 0;
 
 /* make sure we actually have a data and stack area to dump */
@@ -218,7 +218,7 @@
 	 * size limits imposed on them by creating programs with large
 	 * arrays in the data or bss.
 	 */
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim >= RLIM_INFINITY)
 		rlim = ~0;
 	if (ex.a_data + ex.a_bss > rlim)
diff -Nru a/arch/sparc64/kernel/binfmt_elf32.c b/arch/sparc64/kernel/binfmt_elf32.c
--- a/arch/sparc64/kernel/binfmt_elf32.c	2004-12-24 13:37:18 -08:00
+++ b/arch/sparc64/kernel/binfmt_elf32.c	2004-12-24 13:37:18 -08:00
@@ -79,7 +79,7 @@
 
 #define elf_check_arch(x)	(((x)->e_machine == EM_SPARC) || ((x)->e_machine == EM_SPARC32PLUS))
 
-#define ELF_ET_DYN_BASE         0x08000000
+#define ELF_ET_DYN_BASE         0x70000000
 
 
 #include <asm/processor.h>
diff -Nru a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
--- a/arch/sparc64/kernel/entry.S	2004-12-24 13:36:16 -08:00
+++ b/arch/sparc64/kernel/entry.S	2004-12-24 13:36:16 -08:00
@@ -26,7 +26,7 @@
 
 #define curptr      g6
 
-#define NR_SYSCALLS 283      /* Each OS is different... */
+#define NR_SYSCALLS 284      /* Each OS is different... */
 
 	.text
 	.align		32
@@ -1778,7 +1778,7 @@
 	 stx		%l0, [%curptr + TI_FLAGS]
 
 1:
-	cmp		%o0, -ENOIOCTLCMD
+	cmp		%o0, -ERESTART_RESTARTBLOCK
 	bgeu,pn		%xcc, 1f
 	 andcc		%l0, _TIF_SYSCALL_TRACE, %l6	
 80:
diff -Nru a/arch/sparc64/kernel/isa.c b/arch/sparc64/kernel/isa.c
--- a/arch/sparc64/kernel/isa.c	2004-12-24 13:36:34 -08:00
+++ b/arch/sparc64/kernel/isa.c	2004-12-24 13:36:34 -08:00
@@ -262,7 +262,7 @@
 	device = PCI_DEVICE_ID_AL_M1533;
 
 	pdev = NULL;
-	while ((pdev = pci_find_device(vendor, device, pdev)) != NULL) {
+	while ((pdev = pci_get_device(vendor, device, pdev)) != NULL) {
 		struct pcidev_cookie *pdev_cookie;
 		struct pci_pbm_info *pbm;
 		struct sparc_isa_bridge *isa_br;
diff -Nru a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c
--- a/arch/sparc64/kernel/kprobes.c	2004-12-24 13:37:19 -08:00
+++ b/arch/sparc64/kernel/kprobes.c	2004-12-24 13:37:19 -08:00
@@ -15,7 +15,7 @@
  * traps.  The top-level scheme is similar to that used
  * in the x86 kprobes implementation.
  *
- * In the kprobe->insn[] array we store the original
+ * In the kprobe->ainsn.insn[] array we store the original
  * instruction at index zero and a break instruction at
  * index one.
  *
@@ -24,12 +24,12 @@
  * - Remember "regs->tnpc" and interrupt level stored in
  *   "regs->tstate" so we can restore them later
  * - Disable PIL interrupts
- * - Set regs->tpc to point to kprobe->insn[0]
- * - Set regs->tnpc to point to kprobe->insn[1]
+ * - Set regs->tpc to point to kprobe->ainsn.insn[0]
+ * - Set regs->tnpc to point to kprobe->ainsn.insn[1]
  * - Mark that we are actively in a kprobe
  *
  * At this point we wait for the second breakpoint at
- * kprobe->insn[1] to hit.  When it does we:
+ * kprobe->ainsn.insn[1] to hit.  When it does we:
  * - Run the post-handler
  * - Set regs->tpc to "remembered" regs->tnpc stored above,
  *   restore the PIL interrupt level in "regs->tstate" as well
@@ -38,10 +38,15 @@
  * - Mark that we are no longer actively in a kprobe.
  */
 
-void arch_prepare_kprobe(struct kprobe *p)
+int arch_prepare_kprobe(struct kprobe *p)
+{
+	p->ainsn.insn[0] = *p->addr;
+	p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2;
+	return 0;
+}
+
+void arch_remove_kprobe(struct kprobe *p)
 {
-	p->insn[0] = *p->addr;
-	p->insn[1] = BREAKPOINT_INSTRUCTION_2;
 }
 
 /* kprobe_status settings */
@@ -59,8 +64,8 @@
 	current_kprobe_orig_tstate_pil = (regs->tstate & TSTATE_PIL);
 	regs->tstate |= TSTATE_PIL;
 
-	regs->tpc = (unsigned long) &p->insn[0];
-	regs->tnpc = (unsigned long) &p->insn[1];
+	regs->tpc = (unsigned long) &p->ainsn.insn[0];
+	regs->tnpc = (unsigned long) &p->ainsn.insn[1];
 }
 
 static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
@@ -199,19 +204,19 @@
  * instruction.  To avoid the SMP problems that can occur when we
  * temporarily put back the original opcode to single-step, we
  * single-stepped a copy of the instruction.  The address of this
- * copy is p->insn.
+ * copy is p->ainsn.insn.
  *
  * This function prepares to return from the post-single-step
  * breakpoint trap.
  */
 static void resume_execution(struct kprobe *p, struct pt_regs *regs)
 {
-	u32 insn = p->insn[0];
+	u32 insn = p->ainsn.insn[0];
 
 	regs->tpc = current_kprobe_orig_tnpc;
 	regs->tnpc = relbranch_fixup(insn,
 				     (unsigned long) p->addr,
-				     (unsigned long) &p->insn[0],
+				     (unsigned long) &p->ainsn.insn[0],
 				     regs->tnpc);
 	retpc_fixup(regs, insn, (unsigned long) p->addr);
 
diff -Nru a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
--- a/arch/sparc64/kernel/pci.c	2004-12-24 13:36:16 -08:00
+++ b/arch/sparc64/kernel/pci.c	2004-12-24 13:36:16 -08:00
@@ -725,7 +725,7 @@
 static void __pci_mmap_set_flags(struct pci_dev *dev, struct vm_area_struct *vma,
 					    enum pci_mmap_state mmap_state)
 {
-	vma->vm_flags |= (VM_SHM | VM_LOCKED);
+	vma->vm_flags |= (VM_IO | VM_RESERVED);
 }
 
 /* Set vm_page_prot of VMA, as appropriate for this architecture, for a pci
diff -Nru a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
--- a/arch/sparc64/kernel/pci_iommu.c	2004-12-24 13:36:18 -08:00
+++ b/arch/sparc64/kernel/pci_iommu.c	2004-12-24 13:36:18 -08:00
@@ -814,7 +814,7 @@
 	/* ALI sound chips generate 31-bits of DMA, a special register
 	 * determines what bit 31 is emitted as.
 	 */
-	ali_isa_bridge = pci_find_device(PCI_VENDOR_ID_AL,
+	ali_isa_bridge = pci_get_device(PCI_VENDOR_ID_AL,
 					 PCI_DEVICE_ID_AL_M1533,
 					 NULL);
 
@@ -824,6 +824,7 @@
 	else
 		val &= ~0x01;
 	pci_write_config_byte(ali_isa_bridge, 0x7e, val);
+	pci_dev_put(ali_isa_bridge);
 }
 
 int pci_dma_supported(struct pci_dev *pdev, u64 device_mask)
diff -Nru a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
--- a/arch/sparc64/kernel/process.c	2004-12-24 13:36:48 -08:00
+++ b/arch/sparc64/kernel/process.c	2004-12-24 13:36:48 -08:00
@@ -621,8 +621,6 @@
 	p->thread.smp_lock_pc = 0;
 #endif
 
-	p->set_child_tid = p->clear_child_tid = NULL;
-
 	/* Calculate offset to stack_frame & pt_regs */
 	child_trap_frame = ((char *)t) + (THREAD_SIZE - (TRACEREG_SZ+STACKFRAME_SZ));
 	memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ));
@@ -829,7 +827,9 @@
 		current_thread_info()->xfsr[0] = 0;
 		current_thread_info()->fpsaved[0] = 0;
 		regs->tstate &= ~TSTATE_PEF;
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
 	}
 out:
 	return error;
diff -Nru a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
--- a/arch/sparc64/kernel/ptrace.c	2004-12-24 13:37:29 -08:00
+++ b/arch/sparc64/kernel/ptrace.c	2004-12-24 13:37:29 -08:00
@@ -559,7 +559,7 @@
  * exit.
  */
 	case PTRACE_KILL: {
-		if (child->state == TASK_ZOMBIE) {	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE) {	/* already dead */
 			pt_succ_return(regs, 0);
 			goto out_tsk;
 		}
diff -Nru a/arch/sparc64/kernel/signal.c b/arch/sparc64/kernel/signal.c
--- a/arch/sparc64/kernel/signal.c	2004-12-24 13:37:43 -08:00
+++ b/arch/sparc64/kernel/signal.c	2004-12-24 13:37:43 -08:00
@@ -23,9 +23,9 @@
 #include <linux/tty.h>
 #include <linux/smp_lock.h>
 #include <linux/binfmts.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/ptrace.h>
 #include <asm/svr4.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c
--- a/arch/sparc64/kernel/signal32.c	2004-12-24 13:36:16 -08:00
+++ b/arch/sparc64/kernel/signal32.c	2004-12-24 13:36:16 -08:00
@@ -20,9 +20,9 @@
 #include <linux/smp_lock.h>
 #include <linux/binfmts.h>
 #include <linux/compat.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/ptrace.h>
 #include <asm/svr4.h>
 #include <asm/pgtable.h>
diff -Nru a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
--- a/arch/sparc64/kernel/smp.c	2004-12-24 13:36:16 -08:00
+++ b/arch/sparc64/kernel/smp.c	2004-12-24 13:36:16 -08:00
@@ -103,15 +103,6 @@
 void __init smp_callin(void)
 {
 	int cpuid = hard_smp_processor_id();
-	extern int bigkernel;
-	extern unsigned long kern_locked_tte_data;
-
-	if (bigkernel) {
-		prom_dtlb_load(sparc64_highest_locked_tlbent()-1, 
-			kern_locked_tte_data + 0x400000, KERNBASE + 0x400000);
-		prom_itlb_load(sparc64_highest_locked_tlbent()-1, 
-			kern_locked_tte_data + 0x400000, KERNBASE + 0x400000);
-	}
 
 	inherit_locked_prom_mappings(0);
 
diff -Nru a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
--- a/arch/sparc64/kernel/sparc64_ksyms.c	2004-12-24 13:37:18 -08:00
+++ b/arch/sparc64/kernel/sparc64_ksyms.c	2004-12-24 13:37:18 -08:00
@@ -177,7 +177,7 @@
 EXPORT_SYMBOL(__atomic64_add);
 EXPORT_SYMBOL(__atomic64_sub);
 #ifdef CONFIG_SMP
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
 #endif
 
 /* Atomic bit operations. */
diff -Nru a/arch/sparc64/kernel/sys32.S b/arch/sparc64/kernel/sys32.S
--- a/arch/sparc64/kernel/sys32.S	2004-12-24 13:36:19 -08:00
+++ b/arch/sparc64/kernel/sys32.S	2004-12-24 13:36:19 -08:00
@@ -84,9 +84,9 @@
 SIGN2(sys32_bdflush, sys_bdflush, %o0, %o1)
 SIGN1(sys32_mlockall, sys_mlockall, %o0)
 SIGN1(sys32_nfsservctl, compat_sys_nfsservctl, %o0)
-SIGN1(sys32_clock_settime, compat_clock_settime, %o1)
-SIGN1(sys32_clock_nanosleep, compat_clock_nanosleep, %o1)
-SIGN1(sys32_timer_settime, compat_timer_settime, %o1)
+SIGN1(sys32_clock_settime, compat_sys_clock_settime, %o1)
+SIGN1(sys32_clock_nanosleep, compat_sys_clock_nanosleep, %o1)
+SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1)
 SIGN1(sys32_io_submit, compat_sys_io_submit, %o1)
 SIGN1(sys32_mq_open, compat_sys_mq_open, %o1)
 SIGN1(sys32_select, compat_sys_select, %o0)
diff -Nru a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
--- a/arch/sparc64/kernel/sys_sparc32.c	2004-12-24 13:37:00 -08:00
+++ b/arch/sparc64/kernel/sys_sparc32.c	2004-12-24 13:37:00 -08:00
@@ -1274,7 +1274,9 @@
 		current_thread_info()->xfsr[0] = 0;
 		current_thread_info()->fpsaved[0] = 0;
 		regs->tstate &= ~TSTATE_PEF;
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
 	}
 out:
 	return error;
diff -Nru a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c
--- a/arch/sparc64/kernel/sys_sunos32.c	2004-12-24 13:37:00 -08:00
+++ b/arch/sparc64/kernel/sys_sunos32.c	2004-12-24 13:37:00 -08:00
@@ -142,7 +142,7 @@
 	}
 	/* Check against rlimit and stack.. */
 	retval = -ENOMEM;
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim >= RLIM_INFINITY)
 		rlim = ~0;
 	if (brk - current->mm->end_code > rlim)
diff -Nru a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
--- a/arch/sparc64/kernel/systbls.S	2004-12-24 13:36:48 -08:00
+++ b/arch/sparc64/kernel/systbls.S	2004-12-24 13:36:48 -08:00
@@ -60,23 +60,23 @@
 	.word sys32_setpgid, sys32_fremovexattr, sys32_tkill, sys32_exit_group, sparc64_newuname
 /*190*/	.word sys32_init_module, sparc64_personality, sys_remap_file_pages, sys32_epoll_create, sys32_epoll_ctl
 	.word sys32_epoll_wait, sys_nis_syscall, sys_getppid, sys32_sigaction, sys_sgetmask
-/*200*/	.word sys32_ssetmask, sys_sigsuspend, compat_sys_newlstat, sys_uselib, compat_old_readdir
+/*200*/	.word sys32_ssetmask, sys_sigsuspend, compat_sys_newlstat, sys_uselib, compat_sys_old_readdir
 	.word sys32_readahead, sys32_socketcall, sys32_syslog, sys32_lookup_dcookie, sys32_fadvise64
 /*210*/	.word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, sys32_sysinfo
 	.word sys32_ipc, sys32_sigreturn, sys_clone, sys_nis_syscall, sys32_adjtimex
 /*220*/	.word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid
 	.word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys32_setfsuid16, sys32_setfsgid16
-/*230*/	.word sys32_select, sys_time, sys_nis_syscall, sys_stime, compat_statfs64
-	.word compat_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys32_mlockall
+/*230*/	.word sys32_select, sys_time, sys_nis_syscall, sys_stime, compat_sys_statfs64
+	.word compat_sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys32_mlockall
 /*240*/	.word sys_munlockall, sys32_sched_setparam, sys32_sched_getparam, sys32_sched_setscheduler, sys32_sched_getscheduler
 	.word sys_sched_yield, sys32_sched_get_priority_max, sys32_sched_get_priority_min, sys32_sched_rr_get_interval, compat_sys_nanosleep
 /*250*/	.word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
-	.word sys_ni_syscall, sys32_clock_settime, compat_clock_gettime, compat_clock_getres, sys32_clock_nanosleep
-/*260*/	.word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_timer_gettime, sys_timer_getoverrun
+	.word sys_ni_syscall, sys32_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
+/*260*/	.word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
 	.word sys_timer_delete, sys32_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
 /*270*/	.word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
 	.word sys_mq_timedsend, sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
-/*280*/	.word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
+/*280*/	.word sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl
 
 #endif /* CONFIG_COMPAT */
 
@@ -142,7 +142,7 @@
 	.word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
 /*270*/	.word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
 	.word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
-/*280*/	.word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
+/*280*/	.word sys_nis_syscall, sys_add_key, sys_request_key, sys_keyctl
 
 #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
     defined(CONFIG_SOLARIS_EMUL_MODULE)
@@ -247,5 +247,5 @@
 	.word sunos_nosys, sunos_nosys, sunos_nosys
 	.word sunos_nosys, sunos_nosys, sunos_nosys
 	.word sunos_nosys, sunos_nosys, sunos_nosys
-
+	.word sunos_nosys
 #endif
diff -Nru a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
--- a/arch/sparc64/kernel/time.c	2004-12-24 13:36:49 -08:00
+++ b/arch/sparc64/kernel/time.c	2004-12-24 13:36:49 -08:00
@@ -64,7 +64,16 @@
 
 static int set_rtc_mmss(unsigned long);
 
-struct sparc64_tick_ops *tick_ops;
+static __init unsigned long dummy_get_tick(void)
+{
+	return 0;
+}
+
+static __initdata struct sparc64_tick_ops dummy_tick_ops = {
+	.get_tick	= dummy_get_tick,
+};
+
+struct sparc64_tick_ops *tick_ops = &dummy_tick_ops;
 
 #define TICK_PRIV_BIT	(1UL << 63)
 
@@ -462,6 +471,7 @@
 	do {
 #ifndef CONFIG_SMP
 		profile_tick(CPU_PROFILING, regs);
+		update_process_times(user_mode(regs));
 #endif
 		do_timer(regs);
 
@@ -1036,6 +1046,7 @@
 static struct time_interpolator sparc64_cpu_interpolator = {
 	.source		=	TIME_SOURCE_CPU,
 	.shift		=	16,
+	.mask		=	0xffffffffffffffffLL
 };
 
 /* The quotient formula is taken from the IA64 port. */
diff -Nru a/arch/sparc64/kernel/trampoline.S b/arch/sparc64/kernel/trampoline.S
--- a/arch/sparc64/kernel/trampoline.S	2004-12-24 13:36:47 -08:00
+++ b/arch/sparc64/kernel/trampoline.S	2004-12-24 13:36:47 -08:00
@@ -90,7 +90,9 @@
 	sllx		%g2, 32, %g2
 	wr		%g2, 0, %tick_cmpr
 
-	/* Call OBP by hand to lock KERNBASE into i/d tlbs. */
+	/* Call OBP by hand to lock KERNBASE into i/d tlbs.
+	 * We lock 2 consequetive entries if we are 'bigkernel'.
+	 */
 	mov		%o0, %l0
 
 	sethi		%hi(prom_entry_lock), %g2
@@ -136,6 +138,46 @@
 	call		%o1
 	 add		%sp, (2047 + 128), %o0
 
+	sethi		%hi(bigkernel), %g2
+	lduw		[%g2 + %lo(bigkernel)], %g2
+	cmp		%g2, 0
+	be,pt		%icc, do_dtlb
+	 nop
+
+	sethi		%hi(call_method), %g2
+	or		%g2, %lo(call_method), %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x00]
+	mov		5, %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x08]
+	mov		1, %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x10]
+	sethi		%hi(itlb_load), %g2
+	or		%g2, %lo(itlb_load), %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x18]
+	sethi		%hi(mmu_ihandle_cache), %g2
+	lduw		[%g2 + %lo(mmu_ihandle_cache)], %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x20]
+	sethi		%hi(KERNBASE + 0x400000), %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x28]
+	sethi		%hi(kern_locked_tte_data), %g2
+	ldx		[%g2 + %lo(kern_locked_tte_data)], %g2
+	sethi		%hi(0x400000), %g1
+	add		%g2, %g1, %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x30]
+
+	mov		14, %g2
+	BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
+
+	mov		62, %g2
+1:
+	stx		%g2, [%sp + 2047 + 128 + 0x38]
+	sethi		%hi(p1275buf), %g2
+	or		%g2, %lo(p1275buf), %g2
+	ldx		[%g2 + 0x08], %o1
+	call		%o1
+	 add		%sp, (2047 + 128), %o0
+
+do_dtlb:
 	sethi		%hi(call_method), %g2
 	or		%g2, %lo(call_method), %g2
 	stx		%g2, [%sp + 2047 + 128 + 0x00]
@@ -168,6 +210,47 @@
 	call		%o1
 	 add		%sp, (2047 + 128), %o0
 
+	sethi		%hi(bigkernel), %g2
+	lduw		[%g2 + %lo(bigkernel)], %g2
+	cmp		%g2, 0
+	be,pt		%icc, do_unlock
+	 nop
+
+	sethi		%hi(call_method), %g2
+	or		%g2, %lo(call_method), %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x00]
+	mov		5, %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x08]
+	mov		1, %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x10]
+	sethi		%hi(dtlb_load), %g2
+	or		%g2, %lo(dtlb_load), %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x18]
+	sethi		%hi(mmu_ihandle_cache), %g2
+	lduw		[%g2 + %lo(mmu_ihandle_cache)], %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x20]
+	sethi		%hi(KERNBASE + 0x400000), %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x28]
+	sethi		%hi(kern_locked_tte_data), %g2
+	ldx		[%g2 + %lo(kern_locked_tte_data)], %g2
+	sethi		%hi(0x400000), %g1
+	add		%g2, %g1, %g2
+	stx		%g2, [%sp + 2047 + 128 + 0x30]
+
+	mov		14, %g2
+	BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
+
+	mov		62, %g2
+1:
+
+	stx		%g2, [%sp + 2047 + 128 + 0x38]
+	sethi		%hi(p1275buf), %g2
+	or		%g2, %lo(p1275buf), %g2
+	ldx		[%g2 + 0x08], %o1
+	call		%o1
+	 add		%sp, (2047 + 128), %o0
+
+do_unlock:
 	sethi		%hi(prom_entry_lock), %g2
 	stb		%g0, [%g2 + %lo(prom_entry_lock)]
 	membar		#StoreStore | #StoreLoad
diff -Nru a/arch/sparc64/kernel/unaligned.c b/arch/sparc64/kernel/unaligned.c
--- a/arch/sparc64/kernel/unaligned.c	2004-12-24 13:36:35 -08:00
+++ b/arch/sparc64/kernel/unaligned.c	2004-12-24 13:36:35 -08:00
@@ -19,8 +19,8 @@
 #include <asm/uaccess.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
+#include <linux/bitops.h>
 #include <asm/fpumacro.h>
-#include <asm/bitops.h>
 
 /* #define DEBUG_MNA */
 
diff -Nru a/arch/sparc64/lib/Makefile b/arch/sparc64/lib/Makefile
--- a/arch/sparc64/lib/Makefile	2004-12-24 13:36:17 -08:00
+++ b/arch/sparc64/lib/Makefile	2004-12-24 13:36:17 -08:00
@@ -12,7 +12,9 @@
 	 U1memcpy.o U1copy_from_user.o U1copy_to_user.o \
 	 U3memcpy.o U3copy_from_user.o U3copy_to_user.o U3patch.o \
 	 copy_in_user.o user_fixup.o memmove.o \
-	 mcount.o ipcsum.o rwsem.o xor.o find_bit.o delay.o iomap.o
+	 mcount.o ipcsum.o rwsem.o xor.o find_bit.o delay.o
 
 lib-$(CONFIG_DEBUG_SPINLOCK) += debuglocks.o
 lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o
+
+obj-y += iomap.o
diff -Nru a/arch/sparc64/lib/dec_and_lock.S b/arch/sparc64/lib/dec_and_lock.S
--- a/arch/sparc64/lib/dec_and_lock.S	2004-12-24 13:36:49 -08:00
+++ b/arch/sparc64/lib/dec_and_lock.S	2004-12-24 13:36:49 -08:00
@@ -25,8 +25,8 @@
 	 * }
 	 */
 
-	.globl	atomic_dec_and_lock
-atomic_dec_and_lock:	/* %o0 = counter, %o1 = lock */
+	.globl	_atomic_dec_and_lock
+_atomic_dec_and_lock:	/* %o0 = counter, %o1 = lock */
 loop1:	lduw	[%o0], %g5
 	subcc	%g5, 1, %g7
 	be,pn	%icc, start_to_zero
diff -Nru a/arch/sparc64/lib/find_bit.c b/arch/sparc64/lib/find_bit.c
--- a/arch/sparc64/lib/find_bit.c	2004-12-24 13:36:56 -08:00
+++ b/arch/sparc64/lib/find_bit.c	2004-12-24 13:36:56 -08:00
@@ -1,4 +1,4 @@
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 /**
  * find_next_bit - find the next set bit in a memory region
diff -Nru a/arch/sparc64/mm/fault.c b/arch/sparc64/mm/fault.c
--- a/arch/sparc64/mm/fault.c	2004-12-24 13:37:29 -08:00
+++ b/arch/sparc64/mm/fault.c	2004-12-24 13:37:29 -08:00
@@ -352,7 +352,7 @@
 	 * If we're in an interrupt or have no user
 	 * context, we must not take the fault..
 	 */
-	if (in_interrupt() || !mm)
+	if (in_atomic() || !mm)
 		goto intr_or_no_mm;
 
 	if (test_thread_flag(TIF_32BIT)) {
@@ -361,7 +361,15 @@
 		address &= 0xffffffff;
 	}
 
-	down_read(&mm->mmap_sem);
+	if (!down_read_trylock(&mm->mmap_sem)) {
+		if ((regs->tstate & TSTATE_PRIV) &&
+		    !search_exception_tables(regs->tpc)) {
+			insn = get_fault_insn(regs, insn);
+			goto handle_kernel_fault;
+		}
+		down_read(&mm->mmap_sem);
+	}
+
 	vma = find_vma(mm, address);
 	if (!vma)
 		goto bad_area;
@@ -446,16 +454,18 @@
 	}
 
 	switch (handle_mm_fault(mm, vma, address, (fault_code & FAULT_CODE_WRITE))) {
-	case 1:
+	case VM_FAULT_MINOR:
 		current->min_flt++;
 		break;
-	case 2:
+	case VM_FAULT_MAJOR:
 		current->maj_flt++;
 		break;
-	case 0:
+	case VM_FAULT_SIGBUS:
 		goto do_sigbus;
-	default:
+	case VM_FAULT_OOM:
 		goto out_of_memory;
+	default:
+		BUG();
 	}
 
 	up_read(&mm->mmap_sem);
diff -Nru a/arch/sparc64/mm/generic.c b/arch/sparc64/mm/generic.c
--- a/arch/sparc64/mm/generic.c	2004-12-24 13:37:18 -08:00
+++ b/arch/sparc64/mm/generic.c	2004-12-24 13:37:18 -08:00
@@ -15,15 +15,7 @@
 #include <asm/page.h>
 #include <asm/tlbflush.h>
 
-static inline void forget_pte(pte_t page)
-{
-	if (!pte_none(page)) {
-		printk("forget_pte: old mapping existed!\n");
-		BUG();
-	}
-}
-
-/* Remap IO memory, the same way as remap_page_range(), but use
+/* Remap IO memory, the same way as remap_pfn_range(), but use
  * the obio memory space.
  *
  * They use a pgprot that sets PAGE_IO and does not check the
@@ -43,7 +35,6 @@
 	if (end > PMD_SIZE)
 		end = PMD_SIZE;
 	do {
-		pte_t oldpage;
 		pte_t entry;
 		unsigned long curend = address + PAGE_SIZE;
 		
@@ -75,10 +66,8 @@
 		if (offset & 0x1UL)
 			pte_val(entry) &= ~(_PAGE_E);
 		do {
-			oldpage = *pte;
-			pte_clear(pte);
+			BUG_ON(!pte_none(*pte));
 			set_pte(pte, entry);
-			forget_pte(oldpage);
 			address += PAGE_SIZE;
 			pte++;
 		} while (address < curend);
@@ -132,8 +121,8 @@
 		from = (from + PGDIR_SIZE) & PGDIR_MASK;
 		dir++;
 	}
+	flush_tlb_range(vma, beg, end);
 	spin_unlock(&mm->page_table_lock);
 
-	flush_tlb_range(vma, beg, end);
 	return error;
 }
diff -Nru a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
--- a/arch/sparc64/mm/init.c	2004-12-24 13:36:47 -08:00
+++ b/arch/sparc64/mm/init.c	2004-12-24 13:36:47 -08:00
@@ -1745,6 +1745,7 @@
 		page = (addr +
 			((unsigned long) __va(kern_base)) -
 			((unsigned long) KERNBASE));
+		memset((void *)addr, 0xcc, PAGE_SIZE);
 		p = virt_to_page(page);
 
 		ClearPageReserved(p);
diff -Nru a/arch/sparc64/solaris/entry64.S b/arch/sparc64/solaris/entry64.S
--- a/arch/sparc64/solaris/entry64.S	2004-12-24 13:36:16 -08:00
+++ b/arch/sparc64/solaris/entry64.S	2004-12-24 13:36:16 -08:00
@@ -109,7 +109,7 @@
 	sra		%o0, 0, %o0
 	mov		%ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
 	ldx		[%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
-	cmp		%o0, -ENOIOCTLCMD
+	cmp		%o0, -ERESTART_RESTARTBLOCK
 	sllx		%g2, 32, %g2
 	bgeu,pn		%xcc, 1f
 	 andcc		%l6, _TIF_SYSCALL_TRACE, %l6	
diff -Nru a/arch/sparc64/solaris/fs.c b/arch/sparc64/solaris/fs.c
--- a/arch/sparc64/solaris/fs.c	2004-12-24 13:36:31 -08:00
+++ b/arch/sparc64/solaris/fs.c	2004-12-24 13:36:31 -08:00
@@ -600,23 +600,23 @@
 {
 	switch (cmd) {
 	case 1: /* UL_GETFSIZE - in 512B chunks */
-		return current->rlim[RLIMIT_FSIZE].rlim_cur >> 9;
+		return current->signal->rlim[RLIMIT_FSIZE].rlim_cur >> 9;
 	case 2: /* UL_SETFSIZE */
 		if ((unsigned long)val > (LONG_MAX>>9)) return -ERANGE;
 		val <<= 9;
-		lock_kernel();
-		if (val > current->rlim[RLIMIT_FSIZE].rlim_max) {
+		task_lock(current->group_leader);
+		if (val > current->signal->rlim[RLIMIT_FSIZE].rlim_max) {
 			if (!capable(CAP_SYS_RESOURCE)) {
-				unlock_kernel();
+				task_unlock(current->group_leader);
 				return -EPERM;
 			}
-			current->rlim[RLIMIT_FSIZE].rlim_max = val;
+			current->signal->rlim[RLIMIT_FSIZE].rlim_max = val;
 		}
-		current->rlim[RLIMIT_FSIZE].rlim_cur = val;
-		unlock_kernel();
+		current->signal->rlim[RLIMIT_FSIZE].rlim_cur = val;
+		task_unlock(current->group_leader);
 		return 0;
 	case 3: /* UL_GMEMLIM */
-		return current->rlim[RLIMIT_DATA].rlim_cur;
+		return current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	case 4: /* UL_GDESLIM */
 		return NR_OPEN;
 	}
diff -Nru a/arch/sparc64/solaris/systbl.S b/arch/sparc64/solaris/systbl.S
--- a/arch/sparc64/solaris/systbl.S	2004-12-24 13:36:16 -08:00
+++ b/arch/sparc64/solaris/systbl.S	2004-12-24 13:36:16 -08:00
@@ -295,4 +295,20 @@
 	.word solaris_unimplemented	/* 			265	*/
 	.word solaris_unimplemented	/* 			266	*/
 	.word solaris_unimplemented	/* 			267	*/
+	.word solaris_unimplemented	/* 			268	*/
+	.word solaris_unimplemented	/* 			269	*/
+	.word solaris_unimplemented	/* 			270	*/
+	.word solaris_unimplemented	/* 			271	*/
+	.word solaris_unimplemented	/* 			272	*/
+	.word solaris_unimplemented	/* 			273	*/
+	.word solaris_unimplemented	/* 			274	*/
+	.word solaris_unimplemented	/* 			275	*/
+	.word solaris_unimplemented	/* 			276	*/
+	.word solaris_unimplemented	/* 			277	*/
+	.word solaris_unimplemented	/* 			278	*/
+	.word solaris_unimplemented	/* 			279	*/
+	.word solaris_unimplemented	/* 			280	*/
+	.word solaris_unimplemented	/* 			281	*/
+	.word solaris_unimplemented	/* 			282	*/
+	.word solaris_unimplemented	/* 			283	*/
 
diff -Nru a/arch/um/Kconfig b/arch/um/Kconfig
--- a/arch/um/Kconfig	2004-12-24 13:36:49 -08:00
+++ b/arch/um/Kconfig	2004-12-24 13:36:49 -08:00
@@ -1,3 +1,8 @@
+# UML uses the generic IRQ sugsystem
+config GENERIC_HARDIRQS
+	bool
+	default y
+
 config USERMODE
 	bool
 	default y
@@ -100,7 +105,8 @@
         say Y or M here; otherwise say N.
 
 config HPPFS
-	tristate "HoneyPot ProcFS"
+	tristate "HoneyPot ProcFS (EXPERIMENTAL)"
+	depends on BROKEN
 	help
 	hppfs (HoneyPot ProcFS) is a filesystem which allows UML /proc
 	entries to be overridden, removed, or fabricated from the host.
@@ -113,8 +119,12 @@
 	You only need this if you are setting up a UML honeypot.  Otherwise,
 	it is safe to say 'N' here.
 
+	If you are actively using it, please ask for it to be fixed. In this
+	moment, it does not work on 2.6 (it works somehow on 2.4).
+
 config MCONSOLE
 	bool "Management console"
+	default y
 	help
         The user mode linux management console is a low-level interface to
         the kernel, somewhat like the i386 SysRq interface.  Since there is
@@ -131,19 +141,40 @@
 
 config HOST_2G_2G
 	bool "2G/2G host address space split"
+	default n
+	help
+	This is needed when the host on which you run has a 2G/2G memory
+	split, instead of the customary 3G/1G.
+
+	Note that to enable such a host
+	configuration, which makes sense only in some cases, you need special
+	host patches.
+
+	So, if you do not know what to do here, say 'N'.
 
 config SMP
-	bool "Symmetric multi-processing support"
+	bool "Symmetric multi-processing support (EXPERIMENTAL)"
 	default n
+	depends on MODE_TT && EXPERIMENTAL
 	help
-        This option enables UML SMP support.  UML implements virtual SMP by
-        allowing as many processes to run simultaneously on the host as
-        there are virtual processors configured.  Obviously, if the host is
-        a uniprocessor, those processes will timeshare, but, inside UML,
-        will appear to be running simultaneously.  If the host is a
-        multiprocessor, then UML processes may run simultaneously, depending
-        on the host scheduler.
-        It is safe to leave this unchanged.
+	This option enables UML SMP support.
+	It is NOT related to having a real SMP box. Not directly, at least.
+
+	UML implements virtual SMP by allowing as many processes to run
+	simultaneously on the host as there are virtual processors configured.
+
+	Obviously, if the host is a uniprocessor, those processes will
+	timeshare, but, inside UML, will appear to be running simultaneously.
+	If the host is a multiprocessor, then UML processes may run
+	simultaneously, depending on the host scheduler.
+
+	This, however, is supported only in TT mode. So, if you use the SKAS
+	patch on your host, switching to TT mode and enabling SMP usually gives
+	you worse performances.
+	Also, since the support for SMP has been under-developed, there could
+	be some bugs being exposed by enabling SMP.
+
+	If you don't know what to do, say N.
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-32)"
@@ -246,5 +277,9 @@
 if BROKEN
 	source "drivers/mtd/Kconfig"
 endif
+
+config INPUT
+	bool
+	default n
 
 source "arch/um/Kconfig.debug"
diff -Nru a/arch/um/Kconfig_block b/arch/um/Kconfig_block
--- a/arch/um/Kconfig_block	2004-12-24 13:37:01 -08:00
+++ b/arch/um/Kconfig_block	2004-12-24 13:37:01 -08:00
@@ -43,6 +43,10 @@
 config BLK_DEV_RAM
 	tristate "RAM disk support"
 
+config BLK_DEV_RAM_COUNT
+	int "Default number of RAM disks" if BLK_DEV_RAM
+	default "16"
+
 config BLK_DEV_RAM_SIZE
 	int "Default RAM disk size"
 	depends on BLK_DEV_RAM
@@ -52,6 +56,33 @@
 	bool "Initial RAM disk (initrd) support"
 	depends on BLK_DEV_RAM=y
 
+#Copied directly from drivers/block/Kconfig
+config INITRAMFS_SOURCE
+	string "Source directory of cpio_list"
+	default ""
+	help
+	  This can be set to either a directory containing files, etc to be
+	  included in the initramfs archive, or a file containing newline
+	  separated entries.
+
+	  If it is a file, it should be in the following format:
+	    # a comment
+	    file <name> <location> <mode> <uid> <gid>
+	    dir <name> <mode> <uid> <gid>
+	    nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>
+
+	  Where:
+	    <name>      name of the file/dir/nod in the archive
+	    <location>  location of the file in the current filesystem
+	    <mode>      mode/permissions of the file
+	    <uid>       user id (0=root)
+	    <gid>       group id (0=root)
+	    <dev_type>  device type (b=block, c=character)
+	    <maj>       major number of nod
+	    <min>       minor number of nod
+
+	  If you are not sure, leave it blank.
+
 config MMAPPER
 	tristate "Example IO memory driver"
 	depends on BROKEN
@@ -69,5 +100,6 @@
         If you'd like to be able to provide a simulated IO port space for
         User-Mode Linux processes, say Y.  If unsure, say N.
 
-endmenu
+source "drivers/block/Kconfig.iosched"
 
+endmenu
diff -Nru a/arch/um/Makefile b/arch/um/Makefile
--- a/arch/um/Makefile	2004-12-24 13:37:00 -08:00
+++ b/arch/um/Makefile	2004-12-24 13:37:00 -08:00
@@ -5,7 +5,8 @@
 
 ARCH_DIR = arch/um
 OS := $(shell uname -s)
-#We require it or things break.
+# We require bash because the vmlinux link and loader script cpp use bash
+# features.
 SHELL := /bin/bash
 
 filechk_gen_header = $<
@@ -28,14 +29,14 @@
 MAKEFILE-$(CONFIG_MODE_SKAS) += Makefile-skas
 
 ifneq ($(MAKEFILE-y),)
-  include $(addprefix $(ARCH_DIR)/,$(MAKEFILE-y))
+  include $(addprefix $(srctree)/$(ARCH_DIR)/,$(MAKEFILE-y))
 endif
 
 ARCH_INCLUDE	:= -I$(ARCH_DIR)/include
 SYS_DIR		:= $(ARCH_DIR)/include/sysdep-$(SUBARCH)
 
-include $(ARCH_DIR)/Makefile-$(SUBARCH)
-include $(ARCH_DIR)/Makefile-os-$(OS)
+include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
+include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
 
 # -Derrno=kernel_errno - This turns all kernel references to errno into
 # kernel_errno to separate them from the libc errno.  This allows -fno-common
@@ -62,6 +63,20 @@
 $(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h
 endif
 
+.PHONY: linux
+
+all: linux
+
+linux: vmlinux
+	ln -f $< $@
+
+define archhelp
+  echo '* linux		- Binary kernel image (./linux) - for backward'
+  echo '		   compatibility only, this creates a hard link to the'
+  echo '		   real kernel binary, the the "vmlinux" binary you'
+  echo '		   find in the kernel root.'
+endef
+
 prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) \
 	$(ARCH_DIR)/kernel/vmlinux.lds.S
 
@@ -105,7 +120,8 @@
 	-Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
 	-Wl,--start-group $(vmlinux-main) -Wl,--end-group \
 	-L/usr/lib -lutil \
-	$(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) FORCE ,$^)
+	$(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) \
+	FORCE ,$^) ; rm -f linux
 endef
 
 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
@@ -113,6 +129,7 @@
 USER_CFLAGS := $(patsubst -Dsigprocmask=kernel_sigprocmask,,$(USER_CFLAGS))
 USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
 	$(MODE_INCLUDE)
+USER_CFLAGS += $(ARCH_USER_CFLAGS)
 
 # To get a definition of F_SETSIG
 USER_CFLAGS += -D_GNU_SOURCE
diff -Nru a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
--- a/arch/um/Makefile-i386	2004-12-24 13:37:18 -08:00
+++ b/arch/um/Makefile-i386	2004-12-24 13:37:18 -08:00
@@ -11,6 +11,7 @@
 endif
 
 CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH)
+ARCH_USER_CFLAGS :=
 
 ifneq ($(CONFIG_GPROF),y)
 ARCH_CFLAGS += -DUM_FASTCALL
diff -Nru a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/Makefile-x86_64	2004-12-24 13:37:44 -08:00
@@ -0,0 +1 @@
+ARCH_USER_CFLAGS := -D__x86_64__
diff -Nru a/arch/um/defconfig b/arch/um/defconfig
--- a/arch/um/defconfig	2004-12-24 13:37:01 -08:00
+++ b/arch/um/defconfig	2004-12-24 13:37:01 -08:00
@@ -1,12 +1,14 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-rc2-mm1
-# Thu Sep 16 23:44:48 2004
+# Linux kernel version: 2.6.10-rc1-mm5
+# Sun Nov 14 15:27:58 2004
 #
+CONFIG_GENERIC_HARDIRQS=y
 CONFIG_USERMODE=y
 CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
 
 #
 # UML-specific options
@@ -15,15 +17,13 @@
 CONFIG_MODE_SKAS=y
 CONFIG_NET=y
 CONFIG_BINFMT_ELF=y
-CONFIG_BINFMT_MISC=y
+CONFIG_BINFMT_MISC=m
 CONFIG_HOSTFS=y
-CONFIG_HPPFS=y
 CONFIG_MCONSOLE=y
 # CONFIG_HOST_2G_2G is not set
 # CONFIG_SMP is not set
 CONFIG_NEST_LEVEL=0
 CONFIG_KERNEL_HALF_GIGS=1
-# CONFIG_HIGHMEM is not set
 CONFIG_KERNEL_STACK_ORDER=2
 CONFIG_UML_REAL_TIME_CLOCK=y
 
@@ -40,7 +40,7 @@
 CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
+CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
 CONFIG_SYSCTL=y
@@ -48,25 +48,32 @@
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
 CONFIG_KOBJECT_UEVENT=y
-# CONFIG_IKCONFIG is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_ALL is not set
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_KALLSYMS_EXTRA_PASS=y
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_TINY_SHMEM is not set
 
 #
 # Loadable module support
 #
-# CONFIG_MODULES is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
 
 #
 # Generic Driver Options
@@ -86,6 +93,7 @@
 CONFIG_PTY_CHAN=y
 CONFIG_TTY_CHAN=y
 CONFIG_XTERM_CHAN=y
+# CONFIG_NOCONFIG_CHAN is not set
 CONFIG_CON_ZERO_CHAN="fd:0,fd:1"
 CONFIG_CON_CHAN="xterm"
 CONFIG_SSL_CHAN="pty"
@@ -93,22 +101,30 @@
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
 # CONFIG_WATCHDOG is not set
-CONFIG_UML_SOUND=y
-CONFIG_SOUND=y
-CONFIG_HOSTAUDIO=y
+CONFIG_UML_SOUND=m
+CONFIG_SOUND=m
+CONFIG_HOSTAUDIO=m
 
 #
 # Block Devices
 #
 CONFIG_BLK_DEV_UBD=y
-# CONFIG_BLK_DEV_UBD_SYNC is not set
+CONFIG_BLK_DEV_UBD_SYNC=y
 CONFIG_BLK_DEV_COW_COMMON=y
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_BLK_DEV_NBD=y
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
-# CONFIG_MMAPPER is not set
+CONFIG_INITRAMFS_SOURCE=""
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 CONFIG_NETDEVICES=y
 
 #
@@ -120,7 +136,6 @@
 CONFIG_UML_NET_SLIP=y
 CONFIG_UML_NET_DAEMON=y
 CONFIG_UML_NET_MCAST=y
-# CONFIG_UML_NET_PCAP is not set
 CONFIG_UML_NET_SLIRP=y
 
 #
@@ -147,6 +162,8 @@
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
 # CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
 # CONFIG_IPV6 is not set
 # CONFIG_NETFILTER is not set
 
@@ -166,7 +183,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -186,10 +202,10 @@
 # CONFIG_HAMRADIO is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-CONFIG_DUMMY=y
+CONFIG_DUMMY=m
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
-CONFIG_TUN=y
+CONFIG_TUN=m
 
 #
 # Ethernet (10 or 100Mbit)
@@ -217,7 +233,7 @@
 # Wan interfaces
 #
 # CONFIG_WAN is not set
-CONFIG_PPP=y
+CONFIG_PPP=m
 # CONFIG_PPP_MULTILINK is not set
 # CONFIG_PPP_FILTER is not set
 # CONFIG_PPP_ASYNC is not set
@@ -225,7 +241,7 @@
 # CONFIG_PPP_DEFLATE is not set
 # CONFIG_PPP_BSDCOMP is not set
 # CONFIG_PPPOE is not set
-CONFIG_SLIP=y
+CONFIG_SLIP=m
 # CONFIG_SLIP_COMPRESSED is not set
 # CONFIG_SLIP_SMART is not set
 # CONFIG_SLIP_MODE_SLIP6 is not set
@@ -237,47 +253,45 @@
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-CONFIG_REISER4_FS=y
-CONFIG_REISER4_LARGE_KEY=y
-# CONFIG_REISER4_CHECK is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISER4_FS is not set
 CONFIG_REISERFS_FS=y
 # CONFIG_REISERFS_CHECK is not set
 # CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_REISERFS_FS_XATTR is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_XFS_FS is not set
-CONFIG_MINIX_FS=y
+# CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 CONFIG_QUOTA=y
 # CONFIG_QFMT_V1 is not set
 # CONFIG_QFMT_V2 is not set
 CONFIG_QUOTACTL=y
-CONFIG_AUTOFS_FS=y
-CONFIG_AUTOFS4_FS=y
+CONFIG_DNOTIFY=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
 
 #
 # Caches
 #
-# CONFIG_CACHEFS is not set
+# CONFIG_FSCACHE is not set
 
 #
 # CD-ROM/DVD Filesystems
 #
-CONFIG_ISO9660_FS=y
-# CONFIG_JOLIET is not set
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
 # CONFIG_ZISOFS is not set
 # CONFIG_UDF_FS is not set
 
 #
 # DOS/FAT/NT Filesystems
 #
-CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
-CONFIG_VFAT_FS=y
-CONFIG_FAT_DEFAULT_CODEPAGE=437
-CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -286,11 +300,10 @@
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -304,10 +317,6 @@
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-CONFIG_JFFS_FS=y
-CONFIG_JFFS_FS_VERBOSE=0
-# CONFIG_JFFS_PROC_FS is not set
-# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -396,82 +405,21 @@
 # CONFIG_LIBCRC32C is not set
 
 #
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
 # Multi-device support (RAID and LVM)
 #
 # CONFIG_MD is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_PARTITIONS is not set
-# CONFIG_MTD_CONCAT is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-# CONFIG_MTD_CFI is not set
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_MAP_BANK_WIDTH_1=y
-CONFIG_MTD_MAP_BANK_WIDTH_2=y
-CONFIG_MTD_MAP_BANK_WIDTH_4=y
-# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
-CONFIG_MTD_CFI_I1=y
-CONFIG_MTD_CFI_I2=y
-# CONFIG_MTD_CFI_I4 is not set
-# CONFIG_MTD_CFI_I8 is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_PHRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-CONFIG_MTD_BLKMTD=y
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
+# CONFIG_INPUT is not set
 
 #
 # Kernel hacking
 #
 CONFIG_DEBUG_KERNEL=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_INFO=y
 CONFIG_FRAME_POINTER=y
 CONFIG_PT_PROXY=y
diff -Nru a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
--- a/arch/um/drivers/chan_user.c	2004-12-24 13:36:17 -08:00
+++ b/arch/um/drivers/chan_user.c	2004-12-24 13:36:17 -08:00
@@ -27,14 +27,26 @@
 	int err;
 
 	if(isatty(fd)){
-		tcgetattr(fd, &save);
+		CATCH_EINTR(err = tcgetattr(fd, &save));
+		if (err)
+			goto error;
 		new = save;
+		/* The terminal becomes a bit less raw, to handle \n also as
+		 * "Carriage Return", not only as "New Line". Otherwise, the new
+		 * line won't start at the first column.*/
 		new.c_oflag |= OPOST;
-		tcsetattr(fd, TCSAFLUSH, &new);
+		CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &new));
+		if (err)
+			goto error;
 	}
 	err = generic_write(fd, buf, n, NULL);
-	if(isatty(fd)) tcsetattr(fd, TCSAFLUSH, &save);
+	/* Restore raw mode, in any case; we *must* ignore any error apart
+	 * EINTR, except for debug.*/
+	if(isatty(fd))
+		CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save));
 	return(err);
+error:
+	return(-errno);
 }
 
 static void winch_handler(int sig)
diff -Nru a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
--- a/arch/um/drivers/cow_user.c	2004-12-24 13:36:59 -08:00
+++ b/arch/um/drivers/cow_user.c	2004-12-24 13:36:59 -08:00
@@ -67,7 +67,7 @@
 struct cow_header_v3 {
 	__u32 magic;
 	__u32 version;
-	time_t mtime;
+	__u32 mtime;
 	__u64 size;
 	__u32 sectorsize;
 	__u32 alignment;
diff -Nru a/arch/um/drivers/line.c b/arch/um/drivers/line.c
--- a/arch/um/drivers/line.c	2004-12-24 13:37:19 -08:00
+++ b/arch/um/drivers/line.c	2004-12-24 13:37:19 -08:00
@@ -107,30 +107,14 @@
 	return(line->head == line->tail);
 }
 
-int line_write(struct line *lines, struct tty_struct *tty, int from_user,
-	       const char *buf, int len)
+int line_write(struct line *lines, struct tty_struct *tty, const char *buf, int len)
 {
 	struct line *line;
-	char *new;
 	unsigned long flags;
 	int n, err, i, ret = 0;
 
 	if(tty->stopped) return 0;
 
-	if(from_user){
-		new = kmalloc(len, GFP_KERNEL);
-		if(new == NULL)
-			return(0);
-		n = copy_from_user(new, buf, len);
-		buf = new;
-		if(n == len){
-			len = -EFAULT;
-			goto out_free;
-		}
-
-		len -= n;
-	}
-
 	i = tty->index;
 	line = &lines[i];
 
@@ -158,9 +142,6 @@
 	}
  out_up:
 	up(&line->sem);
- out_free:
-	if(from_user)
-		kfree(buf);
 	return(ret);
 }
 
@@ -220,13 +201,17 @@
 
 	if(line->driver->read_irq == current_irq)
 		free_irq_later(line->driver->read_irq, line);
-	else
+	else {
+		free_irq_by_irq_and_dev(line->driver->read_irq, line);
 		free_irq(line->driver->read_irq, line);
+	}
 
 	if(line->driver->write_irq == current_irq)
 		free_irq_later(line->driver->write_irq, line);
-	else
+	else {
+		free_irq_by_irq_and_dev(line->driver->write_irq, line);
 		free_irq(line->driver->write_irq, line);
+	}
 
 	line->have_irq = 0;
 }
diff -Nru a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
--- a/arch/um/drivers/mconsole_kern.c	2004-12-24 13:36:17 -08:00
+++ b/arch/um/drivers/mconsole_kern.c	2004-12-24 13:36:17 -08:00
@@ -19,6 +19,7 @@
 #include "linux/fs.h"
 #include "linux/namei.h"
 #include "linux/proc_fs.h"
+#include "linux/syscalls.h"
 #include "asm/irq.h"
 #include "asm/uaccess.h"
 #include "user_util.h"
@@ -118,6 +119,11 @@
 	mconsole_reply(req, "", 0, 0);
 }
 
+/* This is a more convoluted version of mconsole_proc, which has some stability
+ * problems; however, we need it fixed, because it is expected that UML users
+ * mount HPPFS instead of procfs on /proc. And we want mconsole_proc to still
+ * show the real procfs content, not the ones from hppfs.*/
+#if 0
 void mconsole_proc(struct mc_request *req)
 {
 	struct nameidata nd;
@@ -149,6 +155,9 @@
 	nd.flags = O_RDONLY + 1;
 	nd.last_type = LAST_ROOT;
 
+	/* START: it was experienced that the stability problems are closed
+	 * if commenting out these two calls + the below read cycle. To
+	 * make UML crash again, it was enough to readd either one.*/
 	err = link_path_walk(ptr, &nd);
 	if(err){
 		mconsole_reply(req, "Failed to look up file", 1, 0);
@@ -160,6 +169,7 @@
 		mconsole_reply(req, "Failed to open file", 1, 0);
 		goto out_kill;
 	}
+	/*END*/
 
 	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if(buf == NULL){
@@ -191,6 +201,62 @@
  out_kill:
 	deactivate_super(super);
  out: ;
+}
+#endif
+
+void mconsole_proc(struct mc_request *req)
+{
+	char path[64];
+	char *buf;
+	int len;
+	int fd;
+	int first_chunk = 1;
+	char *ptr = req->request.data;
+
+	ptr += strlen("proc");
+	while(isspace(*ptr)) ptr++;
+	snprintf(path, sizeof(path), "/proc/%s", ptr);
+
+	fd = sys_open(path, 0, 0);
+	if (fd < 0) {
+		mconsole_reply(req, "Failed to open file", 1, 0);
+		printk("open %s: %d\n",path,fd);
+		goto out;
+	}
+
+	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if(buf == NULL){
+		mconsole_reply(req, "Failed to allocate buffer", 1, 0);
+		goto out_close;
+	}
+
+	for (;;) {
+		len = sys_read(fd, buf, PAGE_SIZE-1);
+		if (len < 0) {
+			mconsole_reply(req, "Read of file failed", 1, 0);
+			goto out_free;
+		}
+		/*Begin the file content on his own line.*/
+		if (first_chunk) {
+			mconsole_reply(req, "\n", 0, 1);
+			first_chunk = 0;
+		}
+		if (len == PAGE_SIZE-1) {
+			buf[len] = '\0';
+			mconsole_reply(req, buf, 0, 1);
+		} else {
+			buf[len] = '\0';
+			mconsole_reply(req, buf, 0, 0);
+			break;
+		}
+	}
+
+ out_free:
+	kfree(buf);
+ out_close:
+	sys_close(fd);
+ out:
+	/* nothing */;
 }
 
 #define UML_MCONSOLE_HELPTEXT \
diff -Nru a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
--- a/arch/um/drivers/mmapper_kern.c	2004-12-24 13:36:18 -08:00
+++ b/arch/um/drivers/mmapper_kern.c	2004-12-24 13:36:18 -08:00
@@ -81,10 +81,10 @@
 	size = vma->vm_end - vma->vm_start;
 	if(size > mmapper_size) return(-EFAULT);
 
-	/* XXX A comment above remap_page_range says it should only be
+	/* XXX A comment above remap_pfn_range says it should only be
 	 * called when the mm semaphore is held
 	 */
-	if (remap_page_range(vma, vma->vm_start, p_buf, size, 
+	if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
 			     vma->vm_page_prot))
 		goto out;
 	ret = 0;
diff -Nru a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
--- a/arch/um/drivers/net_kern.c	2004-12-24 13:36:48 -08:00
+++ b/arch/um/drivers/net_kern.c	2004-12-24 13:36:48 -08:00
@@ -148,6 +148,7 @@
 	netif_stop_queue(dev);
 	spin_lock(&lp->lock);
 
+	free_irq_by_irq_and_dev(dev->irq, dev);
 	free_irq(dev->irq, dev);
 	if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
 	lp->fd = -1;
diff -Nru a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
--- a/arch/um/drivers/port_kern.c	2004-12-24 13:36:17 -08:00
+++ b/arch/um/drivers/port_kern.c	2004-12-24 13:36:17 -08:00
@@ -242,6 +242,7 @@
 		 * connection.  Then we loop here throwing out failed 
 		 * connections until a good one is found.
 		 */
+		free_irq_by_irq_and_dev(TELNETD_IRQ, conn);
 		free_irq(TELNETD_IRQ, conn);
 
 		if(conn->fd >= 0) break;
diff -Nru a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
--- a/arch/um/drivers/port_user.c	2004-12-24 13:37:00 -08:00
+++ b/arch/um/drivers/port_user.c	2004-12-24 13:37:00 -08:00
@@ -123,11 +123,17 @@
 int port_listen_fd(int port)
 {
 	struct sockaddr_in addr;
-	int fd, err;
+	int fd, err, arg;
 
 	fd = socket(PF_INET, SOCK_STREAM, 0);
 	if(fd == -1) 
 		return(-errno);
+
+	arg = 1;
+	if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){
+		err = -errno;
+		goto out;
+	}
 
 	addr.sin_family = AF_INET;
 	addr.sin_port = htons(port);
diff -Nru a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
--- a/arch/um/drivers/ssl.c	2004-12-24 13:36:49 -08:00
+++ b/arch/um/drivers/ssl.c	2004-12-24 13:36:49 -08:00
@@ -111,15 +111,15 @@
 	line_close(serial_lines, tty);
 }
 
-static int ssl_write(struct tty_struct * tty, int from_user,
+static int ssl_write(struct tty_struct * tty,
 		     const unsigned char *buf, int count)
 {
-	return(line_write(serial_lines, tty, from_user, buf, count));
+	return(line_write(serial_lines, tty, buf, count));
 }
 
 static void ssl_put_char(struct tty_struct *tty, unsigned char ch)
 {
-	line_write(serial_lines, tty, 0, &ch, sizeof(ch));
+	line_write(serial_lines, tty, &ch, sizeof(ch));
 }
 
 static void ssl_flush_chars(struct tty_struct *tty)
diff -Nru a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
--- a/arch/um/drivers/stdio_console.c	2004-12-24 13:36:31 -08:00
+++ b/arch/um/drivers/stdio_console.c	2004-12-24 13:36:31 -08:00
@@ -143,10 +143,10 @@
 	line_close(vts, tty);
 }
 
-static int con_write(struct tty_struct *tty, int from_user, 
+static int con_write(struct tty_struct *tty, 
 		     const unsigned char *buf, int count)
 {
-	 return(line_write(vts, tty, from_user, buf, count));
+	 return(line_write(vts, tty, buf, count));
 }
 
 static void set_termios(struct tty_struct *tty, struct termios * old)
diff -Nru a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c
--- a/arch/um/drivers/xterm_kern.c	2004-12-24 13:37:03 -08:00
+++ b/arch/um/drivers/xterm_kern.c	2004-12-24 13:37:03 -08:00
@@ -63,6 +63,7 @@
 	}
 	down(&data->sem);
 
+	free_irq_by_irq_and_dev(XTERM_IRQ, data);
 	free_irq(XTERM_IRQ, data);
 
 	ret = data->new_fd;
diff -Nru a/arch/um/include/frame_kern.h b/arch/um/include/frame_kern.h
--- a/arch/um/include/frame_kern.h	2004-12-24 13:36:55 -08:00
+++ b/arch/um/include/frame_kern.h	2004-12-24 13:36:55 -08:00
@@ -10,13 +10,11 @@
 #include "sysdep/frame_kern.h"
 
 extern int setup_signal_stack_sc(unsigned long stack_top, int sig, 
-				 unsigned long handler,
-				 void (*restorer)(void), 
+				 struct k_sigaction *ka,
 				 struct pt_regs *regs, 
 				 sigset_t *mask);
 extern int setup_signal_stack_si(unsigned long stack_top, int sig, 
-				 unsigned long handler, 
-				 void (*restorer)(void), 
+				 struct k_sigaction *ka,
 				 struct pt_regs *regs, siginfo_t *info, 
 				 sigset_t *mask);
 
diff -Nru a/arch/um/include/irq_user.h b/arch/um/include/irq_user.h
--- a/arch/um/include/irq_user.h	2004-12-24 13:37:00 -08:00
+++ b/arch/um/include/irq_user.h	2004-12-24 13:37:00 -08:00
@@ -10,7 +10,7 @@
 
 extern void sigio_handler(int sig, union uml_pt_regs *regs);
 extern int activate_fd(int irq, int fd, int type, void *dev_id);
-extern void free_irq_by_irq_and_dev(int irq, void *dev_id);
+extern void free_irq_by_irq_and_dev(unsigned int irq, void *dev_id);
 extern void free_irq_by_fd(int fd);
 extern void reactivate_fd(int fd, int irqnum);
 extern void deactivate_fd(int fd, int irqnum);
diff -Nru a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
--- a/arch/um/include/kern_util.h	2004-12-24 13:36:47 -08:00
+++ b/arch/um/include/kern_util.h	2004-12-24 13:36:47 -08:00
@@ -29,7 +29,7 @@
 extern void syscall_segv(int sig);
 extern int current_pid(void);
 extern unsigned long alloc_stack(int order, int atomic);
-extern int do_signal(int error);
+extern int do_signal(void);
 extern int is_stack_fault(unsigned long sp);
 extern unsigned long segv(unsigned long address, unsigned long ip, 
 			  int is_write, int is_user, void *sc);
@@ -41,7 +41,7 @@
 extern int segv_syscall(void);
 extern void kern_finish_exec(void *task, int new_pid, unsigned long stack);
 extern int page_size(void);
-extern int page_mask(void);
+extern unsigned long page_mask(void);
 extern int need_finish_fork(void);
 extern void free_stack(unsigned long stack, int order);
 extern void add_input_request(int op, void (*proc)(int), void *arg);
@@ -110,7 +110,6 @@
 extern void free_irq(unsigned int, void *);
 extern int um_in_interrupt(void);
 extern int cpu(void);
-extern unsigned long long time_stamp(void);
 
 #endif
 
diff -Nru a/arch/um/include/line.h b/arch/um/include/line.h
--- a/arch/um/include/line.h	2004-12-24 13:37:04 -08:00
+++ b/arch/um/include/line.h	2004-12-24 13:37:04 -08:00
@@ -74,8 +74,7 @@
 		     struct chan_opts *opts);
 extern int line_setup(struct line *lines, int num, char *init, 
 		      int all_allowed);
-extern int line_write(struct line *line, struct tty_struct *tty, int from_user,
-		      const char *buf, int len);
+extern int line_write(struct line *line, struct tty_struct *tty, const char *buf, int len);
 extern int line_write_room(struct tty_struct *tty);
 extern char *add_xterm_umid(char *base);
 extern int line_setup_irq(int fd, int input, int output, void *data);
diff -Nru a/arch/um/include/mem_user.h b/arch/um/include/mem_user.h
--- a/arch/um/include/mem_user.h	2004-12-24 13:37:01 -08:00
+++ b/arch/um/include/mem_user.h	2004-12-24 13:37:01 -08:00
@@ -67,6 +67,7 @@
 extern int protect_memory(unsigned long addr, unsigned long len, 
 			  int r, int w, int x, int must_succeed);
 extern unsigned long get_kmem_end(void);
+extern void check_tmpexec(void);
 
 #endif
 
diff -Nru a/arch/um/include/mode.h b/arch/um/include/mode.h
--- a/arch/um/include/mode.h	2004-12-24 13:37:00 -08:00
+++ b/arch/um/include/mode.h	2004-12-24 13:37:00 -08:00
@@ -9,11 +9,11 @@
 #include "uml-config.h"
 
 #ifdef UML_CONFIG_MODE_TT
-#include "../kernel/tt/include/mode.h"
+#include "mode-tt.h"
 #endif
 
 #ifdef UML_CONFIG_MODE_SKAS
-#include "../kernel/skas/include/mode.h"
+#include "mode-skas.h"
 #endif
 
 #endif
diff -Nru a/arch/um/include/mode_kern.h b/arch/um/include/mode_kern.h
--- a/arch/um/include/mode_kern.h	2004-12-24 13:36:48 -08:00
+++ b/arch/um/include/mode_kern.h	2004-12-24 13:36:48 -08:00
@@ -9,11 +9,11 @@
 #include "linux/config.h"
 
 #ifdef CONFIG_MODE_TT
-#include "../kernel/tt/include/mode_kern.h"
+#include "mode_kern-tt.h"
 #endif
 
 #ifdef CONFIG_MODE_SKAS
-#include "../kernel/skas/include/mode_kern.h"
+#include "mode_kern-skas.h"
 #endif
 
 #endif
diff -Nru a/arch/um/include/os.h b/arch/um/include/os.h
--- a/arch/um/include/os.h	2004-12-24 13:36:31 -08:00
+++ b/arch/um/include/os.h	2004-12-24 13:36:31 -08:00
@@ -157,6 +157,7 @@
 extern int os_process_parent(int pid);
 extern void os_stop_process(int pid);
 extern void os_kill_process(int pid, int reap_child);
+extern void os_kill_ptraced_process(int pid, int reap_child);
 extern void os_usr1_process(int pid);
 extern int os_getpid(void);
 
diff -Nru a/arch/um/include/ptrace_user.h b/arch/um/include/ptrace_user.h
--- a/arch/um/include/ptrace_user.h	2004-12-24 13:36:18 -08:00
+++ b/arch/um/include/ptrace_user.h	2004-12-24 13:36:18 -08:00
@@ -15,4 +15,15 @@
 extern void arch_leave_kernel(void *task, int pid);
 extern void ptrace_pokeuser(unsigned long addr, unsigned long data);
 
+
+/* syscall emulation path in ptrace */
+
+#ifndef PTRACE_SYSEMU
+#define PTRACE_SYSEMU 31
+#endif
+
+void set_using_sysemu(int value);
+int get_using_sysemu(void);
+extern int sysemu_supported;
+
 #endif
diff -Nru a/arch/um/include/syscall_user.h b/arch/um/include/syscall_user.h
--- a/arch/um/include/syscall_user.h	2004-12-24 13:36:47 -08:00
+++ b/arch/um/include/syscall_user.h	2004-12-24 13:36:47 -08:00
@@ -7,7 +7,7 @@
 #define __SYSCALL_USER_H
 
 extern int record_syscall_start(int syscall);
-extern void record_syscall_end(int index, int result);
+extern void record_syscall_end(int index, long result);
 
 #endif
 
diff -Nru a/arch/um/include/um_mmu.h b/arch/um/include/um_mmu.h
--- a/arch/um/include/um_mmu.h	2004-12-24 13:37:04 -08:00
+++ b/arch/um/include/um_mmu.h	2004-12-24 13:37:04 -08:00
@@ -10,11 +10,11 @@
 #include "choose-mode.h"
 
 #ifdef CONFIG_MODE_TT
-#include "../kernel/tt/include/mmu.h"
+#include "mmu-tt.h"
 #endif
 
 #ifdef CONFIG_MODE_SKAS
-#include "../kernel/skas/include/mmu.h"
+#include "mmu-skas.h"
 #endif
 
 typedef union {
diff -Nru a/arch/um/include/um_uaccess.h b/arch/um/include/um_uaccess.h
--- a/arch/um/include/um_uaccess.h	2004-12-24 13:37:02 -08:00
+++ b/arch/um/include/um_uaccess.h	2004-12-24 13:37:02 -08:00
@@ -10,11 +10,11 @@
 #include "choose-mode.h"
 
 #ifdef CONFIG_MODE_TT
-#include "../kernel/tt/include/uaccess.h"
+#include "uaccess-tt.h"
 #endif
 
 #ifdef CONFIG_MODE_SKAS
-#include "../kernel/skas/include/uaccess.h"
+#include "uaccess-skas.h"
 #endif
 
 #define access_ok(type, addr, size) \
diff -Nru a/arch/um/include/user_util.h b/arch/um/include/user_util.h
--- a/arch/um/include/user_util.h	2004-12-24 13:36:18 -08:00
+++ b/arch/um/include/user_util.h	2004-12-24 13:36:18 -08:00
@@ -8,7 +8,7 @@
 
 #include "sysdep/ptrace.h"
 
-#define CATCH_EINTR(expr) while (((expr) < 0) && (errno == EINTR))
+#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))
 
 extern int mode_tt;
 
diff -Nru a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
--- a/arch/um/kernel/dyn.lds.S	2004-12-24 13:36:55 -08:00
+++ b/arch/um/kernel/dyn.lds.S	2004-12-24 13:36:55 -08:00
@@ -59,6 +59,8 @@
   .text           : {
     *(.text)
     SCHED_TEXT
+    LOCK_TEXT
+    *(.fixup)
     *(.stub .text.* .gnu.linkonce.t.*)
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)
diff -Nru a/arch/um/kernel/exec_kern.c b/arch/um/kernel/exec_kern.c
--- a/arch/um/kernel/exec_kern.c	2004-12-24 13:36:31 -08:00
+++ b/arch/um/kernel/exec_kern.c	2004-12-24 13:36:31 -08:00
@@ -34,34 +34,36 @@
 
 extern void log_exec(char **argv, void *tty);
 
-static int execve1(char *file, char **argv, char **env)
+static long execve1(char *file, char **argv, char **env)
 {
-        int error;
+        long error;
 
 #ifdef CONFIG_TTY_LOG
 	log_exec(argv, current->tty);
 #endif
         error = do_execve(file, argv, env, &current->thread.regs);
         if (error == 0){
+		task_lock(current);
                 current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
                 set_cmdline(current_cmd());
         }
         return(error);
 }
 
-int um_execve(char *file, char **argv, char **env)
+long um_execve(char *file, char **argv, char **env)
 {
-	int err;
+	long err;
 
 	err = execve1(file, argv, env);
-	if(!err) 
+	if(!err)
 		do_longjmp(current->thread.exec_buf, 1);
 	return(err);
 }
 
-int sys_execve(char *file, char **argv, char **env)
+long sys_execve(char *file, char **argv, char **env)
 {
-	int error;
+	long error;
 	char *filename;
 
 	lock_kernel();
diff -Nru a/arch/um/kernel/frame.c b/arch/um/kernel/frame.c
--- a/arch/um/kernel/frame.c	2004-12-24 13:36:47 -08:00
+++ b/arch/um/kernel/frame.c	2004-12-24 13:36:47 -08:00
@@ -140,7 +140,7 @@
 	}
 	if(sigaltstack(&ss, NULL) < 0){
 		printf("sigaltstack failed - errno = %d\n", errno);
-		kill(getpid(), SIGKILL);
+		kill(os_getpid(), SIGKILL);
 	}
 
 	if(restorer){
@@ -162,7 +162,7 @@
 	
 	if(err < 0){
 		printf("sigaction failed - errno = %d\n", errno);
-		kill(getpid(), SIGKILL);
+		kill(os_getpid(), SIGKILL);
 	}
 
 	os_stop_process(os_getpid());
@@ -191,7 +191,7 @@
 	setup_arch_frame_raw(&raw_sc->common.arch, &sc + 1, raw_sc->common.sr);
 
 	os_stop_process(os_getpid());
-	kill(getpid(), SIGKILL);
+	kill(os_getpid(), SIGKILL);
 }
 
 static int sc_child(void *arg)
@@ -229,7 +229,7 @@
 			     ucontext->uc_mcontext.fpregs, raw_si->common.sr);
 	
 	os_stop_process(os_getpid());
-	kill(getpid(), SIGKILL);
+	kill(os_getpid(), SIGKILL);
 }
 
 static int si_child(void *arg)
diff -Nru a/arch/um/kernel/frame_kern.c b/arch/um/kernel/frame_kern.c
--- a/arch/um/kernel/frame_kern.c	2004-12-24 13:37:43 -08:00
+++ b/arch/um/kernel/frame_kern.c	2004-12-24 13:37:43 -08:00
@@ -56,11 +56,11 @@
 }
 
 int setup_signal_stack_si(unsigned long stack_top, int sig, 
-			  unsigned long handler, void (*restorer)(void), 
-			  struct pt_regs *regs, siginfo_t *info, 
-			  sigset_t *mask)
+			  struct k_sigaction *ka, struct pt_regs *regs,
+			  siginfo_t *info, sigset_t *mask)
 {
 	unsigned long start;
+	void *restorer;
 	void *sip, *ucp, *fp;
 
 	start = stack_top - signal_frame_si.common.len;
@@ -68,6 +68,10 @@
 	ucp = (void *) (start + signal_frame_si.uc_index);
 	fp = (void *) (((unsigned long) ucp) + sizeof(struct ucontext));
 
+	restorer = NULL;
+	if(ka->sa.sa_flags & SA_RESTORER)
+		restorer = ka->sa.sa_restorer;
+
 	if(restorer == NULL)
 		panic("setup_signal_stack_si - no restorer");
 
@@ -85,21 +89,26 @@
 			 signal_frame_si.common.sr_relative))
 		return(1);
 	
-	PT_REGS_IP(regs) = handler;
+	PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
 	PT_REGS_SP(regs) = start + signal_frame_si.common.sp_index;
 	return(0);
 }
 
 int setup_signal_stack_sc(unsigned long stack_top, int sig, 
-			  unsigned long handler, void (*restorer)(void), 
-			  struct pt_regs *regs, sigset_t *mask)
+			  struct k_sigaction *ka, struct pt_regs *regs,
+			  sigset_t *mask)
 {
 	struct frame_common *frame = &signal_frame_sc_sr.common;
+	void *restorer;
 	void *user_sc;
 	int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
 	unsigned long sigs, sr;
 	unsigned long start = stack_top - frame->len - sig_size;
 
+	restorer = NULL;
+	if(ka->sa.sa_flags & SA_RESTORER)
+		restorer = ka->sa.sa_restorer;
+
 	user_sc = (void *) (start + signal_frame_sc_sr.sc_index);
 	if(restorer == NULL){
 		frame = &signal_frame_sc.common;
@@ -121,7 +130,7 @@
 	   copy_restorer(restorer, start, frame->sr_index, frame->sr_relative))
 		return(1);
 
-	PT_REGS_IP(regs) = handler;
+	PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
 	PT_REGS_SP(regs) = start + frame->sp_index;
 
 	return(0);
diff -Nru a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
--- a/arch/um/kernel/irq.c	2004-12-24 13:37:18 -08:00
+++ b/arch/um/kernel/irq.c	2004-12-24 13:37:18 -08:00
@@ -32,58 +32,6 @@
 #include "irq_user.h"
 #include "irq_kern.h"
 
-static void register_irq_proc (unsigned int irq);
-
-irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
-	[0 ... NR_IRQS-1] = {
-		.handler = &no_irq_type,
-		.lock = SPIN_LOCK_UNLOCKED
-	}
-};
-
-/*
- * Generic no controller code
- */
-
-static void enable_none(unsigned int irq) { }
-static unsigned int startup_none(unsigned int irq) { return 0; }
-static void disable_none(unsigned int irq) { }
-static void ack_none(unsigned int irq)
-{
-/*
- * 'what should we do if we get a hw irq event on an illegal vector'.
- * each architecture has to answer this themselves, it doesn't deserve
- * a generic callback i think.
- */
-#ifdef CONFIG_X86
-	printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq);
-#ifdef CONFIG_X86_LOCAL_APIC
-	/*
-	 * Currently unexpected vectors happen only on SMP and APIC.
-	 * We _must_ ack these because every local APIC has only N
-	 * irq slots per priority level, and a 'hanging, unacked' IRQ
-	 * holds up an irq slot - in excessive cases (when multiple
-	 * unexpected vectors occur) that might lock up the APIC
-	 * completely.
-	 */
-	ack_APIC_irq();
-#endif
-#endif
-}
-
-/* startup is the same as "enable", shutdown is same as "disable" */
-#define shutdown_none	disable_none
-#define end_none	enable_none
-
-struct hw_interrupt_type no_irq_type = {
-	"none",
-	startup_none,
-	shutdown_none,
-	enable_none,
-	disable_none,
-	ack_none,
-	end_none
-};
 
 /*
  * Generic, controller-independent functions:
@@ -126,10 +74,6 @@
 skip:
 		spin_unlock_irqrestore(&irq_desc[i].lock, flags);
 	} else if (i == NR_IRQS) {
-		seq_printf(p, "NMI: ");
-		for (j = 0; j < NR_CPUS; j++)
-			if (cpu_online(j))
-				seq_printf(p, "%10u ", nmi_count(j));
 		seq_putc(p, '\n');
 	}
 
@@ -137,295 +81,18 @@
 }
 
 /*
- * This should really return information about whether
- * we should do bottom half handling etc. Right now we
- * end up _always_ checking the bottom half, which is a
- * waste of time and is not what some drivers would
- * prefer.
- */
-int handle_IRQ_event(unsigned int irq, struct pt_regs * regs, 
-		     struct irqaction * action)
-{
-	int status = 1;	/* Force the "do bottom halves" bit */
-	int ret, retval = 0;
-
-	if (!(action->flags & SA_INTERRUPT))
-		local_irq_enable();
-
-	do {
-		ret = action->handler(irq, action->dev_id, regs);
-		if (ret == IRQ_HANDLED)
-			status |= action->flags;
-		retval |= ret;
-		action = action->next;
-	} while (action);
-	if (status & SA_SAMPLE_RANDOM)
-		add_interrupt_randomness(irq);
-
-	local_irq_disable();
-
-	return retval;
-}
-
-/*
- * Generic enable/disable code: this just calls
- * down into the PIC-specific version for the actual
- * hardware disable after having gotten the irq
- * controller lock. 
- */
- 
-/**
- *	disable_irq_nosync - disable an irq without waiting
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line. Disables of an interrupt
- *	stack. Unlike disable_irq(), this function does not ensure existing
- *	instances of the IRQ handler have completed before returning.
- *
- *	This function may be called from IRQ context.
- */
- 
-inline void disable_irq_nosync(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	if (!desc->depth++) {
-		desc->status |= IRQ_DISABLED;
-		desc->handler->disable(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-#ifdef CONFIG_SMP
-inline void synchronize_irq(unsigned int irq)
-{
-	/* is there anything to synchronize with? */
-	if (!irq_desc[irq].action)
-		return;
- 
-	while (irq_desc[irq].status & IRQ_INPROGRESS)
-		cpu_relax();
-}
-#endif
-
-/**
- *	disable_irq - disable an irq and wait for completion
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line. Disables of an interrupt
- *	stack. That is for two disables you need two enables. This
- *	function waits for any pending IRQ handlers for this interrupt
- *	to complete before returning. If you use this function while
- *	holding a resource the IRQ handler may need you will deadlock.
- *
- *	This function may be called - with care - from IRQ context.
- */
- 
-void disable_irq(unsigned int irq)
-{
-	disable_irq_nosync(irq);
-	synchronize_irq(irq);
-}
-
-/**
- *	enable_irq - enable interrupt handling on an irq
- *	@irq: Interrupt to enable
- *
- *	Re-enables the processing of interrupts on this IRQ line
- *	providing no disable_irq calls are now in effect.
- *
- *	This function may be called from IRQ context.
- */
- 
-void enable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	switch (desc->depth) {
-	case 1: {
-		unsigned int status = desc->status & ~IRQ_DISABLED;
-		desc->status = status;
-		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
-			desc->status = status | IRQ_REPLAY;
-			hw_resend_irq(desc->handler,irq);
-		}
-		desc->handler->enable(irq);
-		/* fall-through */
-	}
-	default:
-		desc->depth--;
-		break;
-	case 0:
-		printk(KERN_ERR "enable_irq() unbalanced from %p\n",
-		       __builtin_return_address(0));
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-/*
  * do_IRQ handles all normal device IRQ's (the special
  * SMP cross-CPU interrupts have their own specific
  * handlers).
  */
 unsigned int do_IRQ(int irq, union uml_pt_regs *regs)
-{	
-	/* 
-	 * 0 return value means that this irq is already being
-	 * handled by some other CPU. (or is disabled)
-	 */
-	irq_desc_t *desc = irq_desc + irq;
-	struct irqaction * action;
-	unsigned int status;
-
-	irq_enter();
-	kstat_this_cpu.irqs[irq]++;
-	spin_lock(&desc->lock);
-	desc->handler->ack(irq);
-	/*
-	   REPLAY is when Linux resends an IRQ that was dropped earlier
-	   WAITING is used by probe to mark irqs that are being tested
-	   */
-	status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
-	status |= IRQ_PENDING; /* we _want_ to handle it */
-
-	/*
-	 * If the IRQ is disabled for whatever reason, we cannot
-	 * use the action we have.
-	 */
-	action = NULL;
-	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
-		action = desc->action;
-		status &= ~IRQ_PENDING; /* we commit to handling */
-		status |= IRQ_INPROGRESS; /* we are handling it */
-	}
-	desc->status = status;
-
-	/*
-	 * If there is no IRQ handler or it was disabled, exit early.
-	   Since we set PENDING, if another processor is handling
-	   a different instance of this same irq, the other processor
-	   will take care of it.
-	 */
-	if (!action)
-		goto out;
-
-	/*
-	 * Edge triggered interrupts need to remember
-	 * pending events.
-	 * This applies to any hw interrupts that allow a second
-	 * instance of the same irq to arrive while we are in do_IRQ
-	 * or in the handler. But the code here only handles the _second_
-	 * instance of the irq, not the third or fourth. So it is mostly
-	 * useful for irq hardware that does not mask cleanly in an
-	 * SMP environment.
-	 */
-	for (;;) {
-		spin_unlock(&desc->lock);
-		handle_IRQ_event(irq, (struct pt_regs *) regs, action);
-		spin_lock(&desc->lock);
-		
-		if (!(desc->status & IRQ_PENDING))
-			break;
-		desc->status &= ~IRQ_PENDING;
-	}
-	desc->status &= ~IRQ_INPROGRESS;
-out:
-	/*
-	 * The ->end() handler has to deal with interrupts which got
-	 * disabled while the handler was running.
-	 */
-	desc->handler->end(irq);
-	spin_unlock(&desc->lock);
-
-	irq_exit();
-
-	return 1;
-}
-
-/**
- *	request_irq - allocate an interrupt line
- *	@irq: Interrupt line to allocate
- *	@handler: Function to be called when the IRQ occurs
- *	@irqflags: Interrupt type flags
- *	@devname: An ascii name for the claiming device
- *	@dev_id: A cookie passed back to the handler function
- *
- *	This call allocates interrupt resources and enables the
- *	interrupt line and IRQ handling. From the point this
- *	call is made your handler function may be invoked. Since
- *	your handler function must clear any interrupt the board 
- *	raises, you must take care both to initialise your hardware
- *	and to set up the interrupt handler in the right order.
- *
- *	Dev_id must be globally unique. Normally the address of the
- *	device data structure is used as the cookie. Since the handler
- *	receives this value it makes sense to use it.
- *
- *	If your interrupt is shared you must pass a non NULL dev_id
- *	as this is required when freeing the interrupt.
- *
- *	Flags:
- *
- *	SA_SHIRQ		Interrupt is shared
- *
- *	SA_INTERRUPT		Disable local interrupts while processing
- *
- *	SA_SAMPLE_RANDOM	The interrupt can be used for entropy
- *
- */
- 
-int request_irq(unsigned int irq,
-		irqreturn_t (*handler)(int, void *, struct pt_regs *),
-		unsigned long irqflags, 
-		const char * devname,
-		void *dev_id)
 {
-	int retval;
-	struct irqaction * action;
-
-#if 1
-	/*
-	 * Sanity-check: shared interrupts should REALLY pass in
-	 * a real dev-ID, otherwise we'll have trouble later trying
-	 * to figure out which interrupt is which (messes up the
-	 * interrupt freeing logic etc).
-	 */
-	if (irqflags & SA_SHIRQ) {
-		if (!dev_id)
-			printk(KERN_ERR "Bad boy: %s (at 0x%x) called us "
-			       "without a dev_id!\n", devname, (&irq)[-1]);
-	}
-#endif
-
-	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;
-	cpus_clear(action->mask);
-	action->name = devname;
-	action->next = NULL;
-	action->dev_id = dev_id;
-
-	retval = setup_irq(irq, action);
-	if (retval)
-		kfree(action);
-	return retval;
+       irq_enter();
+       __do_IRQ(irq, (struct pt_regs *) regs);
+       irq_exit();
+       return 1;
 }
 
-EXPORT_SYMBOL(request_irq);
-
 int um_request_irq(unsigned int irq, int fd, int type,
 		   irqreturn_t (*handler)(int, void *, struct pt_regs *),
 		   unsigned long irqflags, const char * devname,
@@ -444,222 +111,6 @@
 EXPORT_SYMBOL(um_request_irq);
 EXPORT_SYMBOL(reactivate_fd);
 
-/* this was setup_x86_irq but it seems pretty generic */
-int setup_irq(unsigned int irq, struct irqaction * new)
-{
-	int shared = 0;
-	unsigned long flags;
-	struct irqaction *old, **p;
-	irq_desc_t *desc = irq_desc + irq;
-
-	/*
-	 * Some drivers like serial.c use request_irq() heavily,
-	 * so we have to be careful not to interfere with a
-	 * running system.
-	 */
-	if (new->flags & SA_SAMPLE_RANDOM) {
-		/*
-		 * This function might sleep, we want to call it first,
-		 * outside of the atomic block.
-		 * Yes, this might clear the entropy pool if the wrong
-		 * driver is attempted to be loaded, without actually
-		 * installing a new handler, but is this really a problem,
-		 * only the sysadmin is able to do this.
-		 */
-		rand_initialize_irq(irq);
-	}
-
-	/*
-	 * The following block of code has to be executed atomically
-	 */
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	old = *p;
-	if (old != NULL) {
-		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
-			spin_unlock_irqrestore(&desc->lock,flags);
-			return -EBUSY;
-		}
-
-		/* add new interrupt at end of irq queue */
-		do {
-			p = &old->next;
-			old = *p;
-		} while (old);
-		shared = 1;
-	}
-
-	*p = new;
-
-	if (!shared) {
-		desc->depth = 0;
-		desc->status &= ~IRQ_DISABLED;
-		desc->handler->startup(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock,flags);
-
-	register_irq_proc(irq);
-	return 0;
-}
-
-/**
- *	free_irq - free an interrupt
- *	@irq: Interrupt line to free
- *	@dev_id: Device identity to free
- *
- *	Remove an interrupt handler. The handler is removed and if the
- *	interrupt line is no longer in use by any driver it is disabled.
- *	On a shared IRQ the caller must ensure the interrupt is disabled
- *	on the card it drives before calling this function. The function
- *	does not return until any executing interrupts for this IRQ
- *	have completed.
- *
- *	This function may be called from interrupt context. 
- *
- *	Bugs: Attempting to free an irq in a handler for the same irq hangs
- *	      the machine.
- */
- 
-void free_irq(unsigned int irq, void *dev_id)
-{
-	irq_desc_t *desc;
-	struct irqaction **p;
-	unsigned long flags;
-
-	if (irq >= NR_IRQS)
-		return;
-
-	desc = irq_desc + irq;
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	for (;;) {
-		struct irqaction * action = *p;
-		if (action) {
-			struct irqaction **pp = p;
-			p = &action->next;
-			if (action->dev_id != dev_id)
-				continue;
-
-			/* Found it - now remove it from the list of entries */
-			*pp = action->next;
-			if (!desc->action) {
-				desc->status |= IRQ_DISABLED;
-				desc->handler->shutdown(irq);
-			}
-			free_irq_by_irq_and_dev(irq, dev_id);
-			spin_unlock_irqrestore(&desc->lock,flags);
-
-			/* Wait to make sure it's not being used on another CPU */
-			synchronize_irq(irq);
-			kfree(action);
-			return;
-		}
-		printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
-		spin_unlock_irqrestore(&desc->lock,flags);
-		return;
-	}
-}
-
-EXPORT_SYMBOL(free_irq);
-
-/* These are initialized by sysctl_init, which is called from init/main.c */
-static struct proc_dir_entry * root_irq_dir;
-static struct proc_dir_entry * irq_dir [NR_IRQS];
-static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
-
-/* These are read and written as longs, so a read won't see a partial write
- * even during a race.
- */
-static cpumask_t irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
-
-static int irq_affinity_read_proc (char *page, char **start, off_t off,
-			int count, int *eof, void *data)
-{
-	int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
-	if (count - len < 2)
-		return -EINVAL;
-	len += sprintf(page + len, "\n");
-	return len;
-}
-
-static int irq_affinity_write_proc (struct file *file, const char *buffer,
-					unsigned long count, void *data)
-{
-	int irq = (long) data, full_count = count, err;
-	cpumask_t new_value;
-
-	if (!irq_desc[irq].handler->set_affinity)
-		return -EIO;
-
-	err = cpumask_parse(buffer, count, new_value);
-	if(err)
-		return(err);
-
-#ifdef CONFIG_SMP
-	/*
-	 * Do not allow disabling IRQs completely - it's a too easy
-	 * way to make the system unusable accidentally :-) At least
-	 * one online CPU still has to be targeted.
-	 */
-	{ cpumask_t tmp;
-	  cpus_and(tmp, new_value, cpu_online_map);
-	  if (cpus_empty(tmp))
-		  return -EINVAL;
-	}
-#endif
-
-	irq_affinity[irq] = new_value;
-	irq_desc[irq].handler->set_affinity(irq, new_value);
-
-	return full_count;
-}
-
-#define MAX_NAMELEN 10
-
-static void register_irq_proc (unsigned int irq)
-{
-	struct proc_dir_entry *entry;
-	char name [MAX_NAMELEN];
-
-	if (!root_irq_dir || (irq_desc[irq].handler == &no_irq_type) ||
-	    irq_dir[irq])
-		return;
-
-	memset(name, 0, MAX_NAMELEN);
-	sprintf(name, "%d", irq);
-
-	/* create /proc/irq/1234 */
-	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
-
-	/* create /proc/irq/1234/smp_affinity */
-	entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
-
-	entry->nlink = 1;
-	entry->data = (void *)(long)irq;
-	entry->read_proc = irq_affinity_read_proc;
-	entry->write_proc = irq_affinity_write_proc;
-
-	smp_affinity_entry[irq] = entry;
-}
-
-void __init init_irq_proc (void)
-{
-	int i;
-
-	/* create /proc/irq */
-	root_irq_dir = proc_mkdir("irq", 0);
-
-	/* create /proc/irq/prof_cpu_mask */
-	create_prof_cpu_mask(root_irq_dir);
-
-	/*
-	 * Create entries for all existing IRQs.
-	 */
-	for (i = 0; i < NR_IRQS; i++)
-		register_irq_proc(i);
-}
-
 static spinlock_t irq_spinlock = SPIN_LOCK_UNLOCKED;
 
 unsigned long irq_lock(void)
@@ -675,90 +126,27 @@
 	spin_unlock_irqrestore(&irq_spinlock, flags);
 }
 
-unsigned long probe_irq_on(void)
-{
-	return(0);
-}
-
-EXPORT_SYMBOL(probe_irq_on);
-
-int probe_irq_off(unsigned long val)
-{
-	return(0);
-}
-
-EXPORT_SYMBOL(probe_irq_off);
-
-static unsigned int startup_SIGIO_irq(unsigned int irq)
-{
-	return(0);
-}
-
-static void shutdown_SIGIO_irq(unsigned int irq)
-{
-}
-
-static void enable_SIGIO_irq(unsigned int irq)
-{
-}
-
-static void disable_SIGIO_irq(unsigned int irq)
-{
-}
-
-static void mask_and_ack_SIGIO(unsigned int irq)
-{
-}
-
-static void end_SIGIO_irq(unsigned int irq)
-{
-}
-
-static unsigned int startup_SIGVTALRM_irq(unsigned int irq)
-{
-	return(0);
-}
-
-static void shutdown_SIGVTALRM_irq(unsigned int irq)
-{
-}
-
-static void enable_SIGVTALRM_irq(unsigned int irq)
-{
-}
-
-static void disable_SIGVTALRM_irq(unsigned int irq)
-{
-}
-
-static void mask_and_ack_SIGVTALRM(unsigned int irq)
-{
-}
-
-static void end_SIGVTALRM_irq(unsigned int irq)
+/*  presently hw_interrupt_type must define (startup || enable) &&
+ *  disable && end */
+static void dummy(unsigned int irq)
 {
 }
 
 static struct hw_interrupt_type SIGIO_irq_type = {
-	"SIGIO",
-	startup_SIGIO_irq,
-	shutdown_SIGIO_irq,
-	enable_SIGIO_irq,
-	disable_SIGIO_irq,
-	mask_and_ack_SIGIO,
-	end_SIGIO_irq,
-	NULL
+	.typename = "SIGIO",
+	.disable = dummy,
+	.enable = dummy,
+	.ack = dummy,
+	.end = dummy
 };
 
 static struct hw_interrupt_type SIGVTALRM_irq_type = {
-	"SIGVTALRM",
-	startup_SIGVTALRM_irq,
-	shutdown_SIGVTALRM_irq,
-	enable_SIGVTALRM_irq,
-	disable_SIGVTALRM_irq,
-	mask_and_ack_SIGVTALRM,
-	end_SIGVTALRM_irq,
-	NULL
+	.typename = "SIGVTALRM",
+	.shutdown = dummy, /* never called */
+	.disable = dummy,
+	.enable = dummy,
+	.ack = dummy,
+	.end = dummy
 };
 
 void __init init_IRQ(void)
diff -Nru a/arch/um/kernel/irq_user.c b/arch/um/kernel/irq_user.c
--- a/arch/um/kernel/irq_user.c	2004-12-24 13:36:48 -08:00
+++ b/arch/um/kernel/irq_user.c	2004-12-24 13:36:48 -08:00
@@ -263,7 +263,7 @@
 	return((irq->irq == data->irq) && (irq->id == data->dev));
 }
 
-void free_irq_by_irq_and_dev(int irq, void *dev)
+void free_irq_by_irq_and_dev(unsigned int irq, void *dev)
 {
 	struct irq_and_dev data = ((struct irq_and_dev) { .irq  = irq,
 							  .dev  = dev });
diff -Nru a/arch/um/kernel/main.c b/arch/um/kernel/main.c
--- a/arch/um/kernel/main.c	2004-12-24 13:37:18 -08:00
+++ b/arch/um/kernel/main.c	2004-12-24 13:37:18 -08:00
@@ -17,11 +17,16 @@
 #include "kern_util.h"
 #include "mem_user.h"
 #include "signal_user.h"
+#include "time_user.h"
+#include "irq_user.h"
 #include "user.h"
 #include "init.h"
 #include "mode.h"
 #include "choose-mode.h"
 #include "uml-config.h"
+#include "irq_user.h"
+#include "time_user.h"
+#include "os.h"
 
 /* Set in set_stklim, which is called from main and __wrap_malloc.
  * __wrap_malloc only calls it if main hasn't started.
@@ -171,7 +176,7 @@
 }
 
 #define CAN_KMALLOC() \
-	(kmalloc_ok && CHOOSE_MODE((getpid() != tracing_pid), 1))
+	(kmalloc_ok && CHOOSE_MODE((os_getpid() != tracing_pid), 1))
 
 extern void *__real_malloc(int);
 
diff -Nru a/arch/um/kernel/mem_user.c b/arch/um/kernel/mem_user.c
--- a/arch/um/kernel/mem_user.c	2004-12-24 13:36:55 -08:00
+++ b/arch/um/kernel/mem_user.c	2004-12-24 13:36:55 -08:00
@@ -83,6 +83,26 @@
 	return(fd);
 }
 
+void check_tmpexec(void)
+{
+	void *addr;
+	int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE);
+
+	addr = mmap(NULL, UM_KERN_PAGE_SIZE,
+		    PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
+	printf("Checking PROT_EXEC mmap in /tmp...");
+	fflush(stdout);
+	if(addr == MAP_FAILED){
+		err = errno;
+		perror("failed");
+		if(err == EPERM)
+			printf("/tmp must be not mounted noexec\n");
+		exit(1);
+	}
+	printf("OK\n");
+	munmap(addr, UM_KERN_PAGE_SIZE);
+}
+
 static int have_devanon = 0;
 
 void check_devanon(void)
@@ -111,7 +131,7 @@
 		exit(1);
 	}
 
-	addr = mmap(NULL, len, PROT_READ | PROT_WRITE , MAP_PRIVATE, fd, 0);
+	addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
 	if(addr == MAP_FAILED){
 		os_print_error((int) addr, "mapping physmem file");
 		exit(1);
@@ -207,6 +227,39 @@
 	}
 	return(0);
 }
+
+#if 0
+/* Debugging facility for dumping stuff out to the host, avoiding the timing
+ * problems that come with printf and breakpoints.
+ * Enable in case of emergency.
+ */
+
+int logging = 1;
+int logging_fd = -1;
+
+int logging_line = 0;
+char logging_buf[512];
+
+void log(char *fmt, ...)
+{
+        va_list ap;
+        struct timeval tv;
+        struct openflags flags;
+
+        if(logging == 0) return;
+        if(logging_fd < 0){
+                flags = of_create(of_trunc(of_rdwr(OPENFLAGS())));
+                logging_fd = os_open_file("log", flags, 0644);
+        }
+        gettimeofday(&tv, NULL);
+        sprintf(logging_buf, "%d\t %u.%u  ", logging_line++, tv.tv_sec,
+                tv.tv_usec);
+        va_start(ap, fmt);
+        vsprintf(&logging_buf[strlen(logging_buf)], fmt, ap);
+        va_end(ap);
+        write(logging_fd, logging_buf, strlen(logging_buf));
+}
+#endif
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
diff -Nru a/arch/um/kernel/process.c b/arch/um/kernel/process.c
--- a/arch/um/kernel/process.c	2004-12-24 13:37:18 -08:00
+++ b/arch/um/kernel/process.c	2004-12-24 13:37:18 -08:00
@@ -137,14 +137,31 @@
 
 static int ptrace_child(void *arg)
 {
-	int pid = os_getpid();
+	int ret;
+	int pid = os_getpid(), ppid = getppid();
+	int sc_result;
 
 	if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
 		perror("ptrace");
 		os_kill_process(pid, 0);
 	}
 	os_stop_process(pid);
-	_exit(os_getpid() == pid);
+
+	/*This syscall will be intercepted by the parent. Don't call more than
+	 * once, please.*/
+	sc_result = os_getpid();
+
+	if (sc_result == pid)
+		ret = 1; /*Nothing modified by the parent, we are running
+			   normally.*/
+	else if (sc_result == ppid)
+		ret = 0; /*Expected in check_ptrace and check_sysemu when they
+			   succeed in modifying the stack frame*/
+	else
+		ret = 2; /*Serious trouble! This could be caused by a bug in
+			   host 2.6 SKAS3/2.6 patch before release -V6, together
+			   with a bug in the UML code itself.*/
+	_exit(ret);
 }
 
 static int start_ptraced_child(void **stack_out)
@@ -172,18 +189,36 @@
 	return(pid);
 }
 
-static void stop_ptraced_child(int pid, void *stack, int exitcode)
+/* When testing for SYSEMU support, if it is one of the broken versions, we must
+ * just avoid using sysemu, not panic, but only if SYSEMU features are broken.
+ * So only for SYSEMU features we test mustpanic, while normal host features
+ * must work anyway!*/
+static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic)
 {
-	int status, n;
+	int status, n, ret = 0;
 
 	if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
 		panic("check_ptrace : ptrace failed, errno = %d", errno);
 	CATCH_EINTR(n = waitpid(pid, &status, 0));
-	if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode))
-		panic("check_ptrace : child exited with status 0x%x", status);
+	if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
+		int exit_with = WEXITSTATUS(status);
+		if (exit_with == 2)
+			printk("check_ptrace : child exited with status 2. "
+			       "Serious trouble happening! Try updating your "
+			       "host skas patch!\nDisabling SYSEMU support.");
+		printk("check_ptrace : child exited with exitcode %d, while "
+		      "expecting %d; status 0x%x", exit_with,
+		      exitcode, status);
+		if (mustpanic)
+			panic("\n");
+		else
+			printk("\n");
+		ret = -1;
+	}
 
 	if(munmap(stack, PAGE_SIZE) < 0)
 		panic("check_ptrace : munmap failed, errno = %d", errno);
+	return ret;
 }
 
 static int force_sysemu_disabled = 0;
@@ -200,50 +235,46 @@
 		"    SYSEMU is a performance-patch introduced by Laurent Vivier. It changes\n"
 		"    behaviour of ptrace() and helps reducing host context switch rate.\n"
 		"    To make it working, you need a kernel patch for your host, too.\n"
-		"    See http://perso.wanadoo.fr/laurent.vivier/UML/ for further information.\n");
+		"    See http://perso.wanadoo.fr/laurent.vivier/UML/ for further information.\n\n");
 
 static void __init check_sysemu(void)
 {
 	void *stack;
 	int pid, n, status;
 
-	if (mode_tt)
-		return;
-
 	printk("Checking syscall emulation patch for ptrace...");
 	sysemu_supported = 0;
 	pid = start_ptraced_child(&stack);
-	if(ptrace(PTRACE_SYSEMU, pid, 0, 0) >= 0) {
-		struct user_regs_struct regs;
 
-		CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
-		if (n < 0)
-			panic("check_ptrace : wait failed, errno = %d", errno);
-		if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
-			panic("check_ptrace : expected SIGTRAP, "
-			      "got status = %d", status);
+	if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0)
+		goto fail;
 
-		if (ptrace(PTRACE_GETREGS, pid, 0, &regs) < 0)
-			panic("check_ptrace : failed to read child "
-			      "registers, errno = %d", errno);
-		regs.orig_eax = pid;
-		if (ptrace(PTRACE_SETREGS, pid, 0, &regs) < 0)
-			panic("check_ptrace : failed to modify child "
-			      "registers, errno = %d", errno);
+	CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
+	if (n < 0)
+		panic("check_sysemu : wait failed, errno = %d", errno);
+	if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
+		panic("check_sysemu : expected SIGTRAP, "
+		      "got status = %d", status);
 
-		stop_ptraced_child(pid, stack, 0);
+	n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET,
+		   os_getpid());
+	if(n < 0)
+		panic("check_sysemu : failed to modify system "
+		      "call return, errno = %d", errno);
 
-		sysemu_supported = 1;
-		printk("found\n");
-	}
-	else
-	{
-		stop_ptraced_child(pid, stack, 1);
-		sysemu_supported = 0;
-		printk("missing\n");
-	}
+	if (stop_ptraced_child(pid, stack, 0, 0) < 0)
+		goto fail_stopped;
 
+	sysemu_supported = 1;
+	printk("OK\n");
 	set_using_sysemu(!force_sysemu_disabled);
+	return;
+
+fail:
+	stop_ptraced_child(pid, stack, 1, 0);
+fail_stopped:
+	sysemu_supported = 0;
+	printk("missing\n");
 }
 
 void __init check_ptrace(void)
@@ -276,7 +307,7 @@
 			break;
 		}
 	}
-	stop_ptraced_child(pid, stack, 0);
+	stop_ptraced_child(pid, stack, 0, 1);
 	printk("OK\n");
 	check_sysemu();
 }
@@ -324,7 +355,7 @@
 	else printf("found\n");
 
 	init_registers(pid);
-	stop_ptraced_child(pid, stack, 1);
+	stop_ptraced_child(pid, stack, 1, 1);
 
 	printf("Checking for /proc/mm...");
 	if(os_access("/proc/mm", OS_ACC_W_OK) < 0){
diff -Nru a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
--- a/arch/um/kernel/process_kern.c	2004-12-24 13:36:55 -08:00
+++ b/arch/um/kernel/process_kern.c	2004-12-24 13:36:55 -08:00
@@ -1,5 +1,6 @@
 /* 
  * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright 2003 PathScale, Inc.
  * Licensed under the GPL
  */
 
@@ -18,6 +19,8 @@
 #include "linux/capability.h"
 #include "linux/vmalloc.h"
 #include "linux/spinlock.h"
+#include "linux/proc_fs.h"
+#include "linux/ptrace.h"
 #include "asm/unistd.h"
 #include "asm/mman.h"
 #include "asm/segment.h"
@@ -138,7 +141,7 @@
 void interrupt_end(void)
 {
 	if(need_resched()) schedule();
-	if(test_tsk_thread_flag(current, TIF_SIGPENDING)) do_signal(0);
+	if(test_tsk_thread_flag(current, TIF_SIGPENDING)) do_signal();
 }
 
 void release_thread(struct task_struct *task)
@@ -206,7 +209,6 @@
 		 * although we are an idle CPU, we do not want to
 		 * get into the scheduler unnecessarily.
 		 */
-		irq_stat[smp_processor_id()].idle_timestamp = jiffies;
 		if(need_resched())
 			schedule();
 		
@@ -224,7 +226,7 @@
 	return(PAGE_SIZE);
 }
 
-int page_mask(void)
+unsigned long page_mask(void)
 {
 	return(PAGE_MASK);
 }
@@ -397,6 +399,74 @@
 int cpu(void)
 {
 	return(current_thread->cpu);
+}
+
+static atomic_t using_sysemu = ATOMIC_INIT(0);
+int sysemu_supported;
+
+void set_using_sysemu(int value)
+{
+	atomic_set(&using_sysemu, sysemu_supported && value);
+}
+
+int get_using_sysemu(void)
+{
+	return atomic_read(&using_sysemu);
+}
+
+static int proc_read_sysemu(char *buf, char **start, off_t offset, int size,int *eof, void *data)
+{
+	if (snprintf(buf, size, "%d\n", get_using_sysemu()) < size) /*No overflow*/
+		*eof = 1;
+
+	return strlen(buf);
+}
+
+static int proc_write_sysemu(struct file *file,const char *buf, unsigned long count,void *data)
+{
+	char tmp[2];
+
+	if (copy_from_user(tmp, buf, 1))
+		return -EFAULT;
+
+	if (tmp[0] == '0' || tmp[0] == '1')
+		set_using_sysemu(tmp[0] - '0');
+	return count; /*We use the first char, but pretend to write everything*/
+}
+
+int __init make_proc_sysemu(void)
+{
+	struct proc_dir_entry *ent;
+	if (!sysemu_supported)
+		return 0;
+
+	ent = create_proc_entry("sysemu", 0600, &proc_root);
+
+	if (ent == NULL)
+	{
+		printk("Failed to register /proc/sysemu\n");
+		return(0);
+	}
+
+	ent->read_proc  = proc_read_sysemu;
+	ent->write_proc = proc_write_sysemu;
+
+	return 0;
+}
+
+late_initcall(make_proc_sysemu);
+
+int singlestepping(void * t)
+{
+	struct task_struct *task = t ? t : current;
+
+	if ( ! (task->ptrace & PT_DTRACE) )
+		return(0);
+
+	if (task->thread.singlestep_syscall)
+		return(0);
+
+	return 1;
 }
 
 /*
diff -Nru a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
--- a/arch/um/kernel/ptrace.c	2004-12-24 13:37:43 -08:00
+++ b/arch/um/kernel/ptrace.c	2004-12-24 13:37:43 -08:00
@@ -22,9 +22,11 @@
  */
 void ptrace_disable(struct task_struct *child)
 { 
+	child->ptrace &= ~PT_DTRACE;
+	child->thread.singlestep_syscall = 0;
 }
 
-int sys_ptrace(long request, long pid, long addr, long data)
+long sys_ptrace(long request, long pid, long addr, long data)
 {
 	struct task_struct *child;
 	int i, ret;
@@ -139,6 +141,9 @@
 		ret = -EIO;
 		if ((unsigned long) data > _NSIG)
 			break;
+
+		child->ptrace &= ~PT_DTRACE;
+		child->thread.singlestep_syscall = 0;
 		if (request == PTRACE_SYSCALL) {
 			set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
 		}
@@ -158,8 +163,11 @@
  */
 	case PTRACE_KILL: {
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
+
+		child->ptrace &= ~PT_DTRACE;
+		child->thread.singlestep_syscall = 0;
 		child->exit_code = SIGKILL;
 		wake_up_process(child);
 		break;
@@ -171,6 +179,7 @@
 			break;
 		clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
 		child->ptrace |= PT_DTRACE;
+		child->thread.singlestep_syscall = 0;
 		child->exit_code = data;
 		/* give it a chance to run. */
 		wake_up_process(child);
@@ -299,6 +308,9 @@
 
 void syscall_trace(union uml_pt_regs *regs, int entryexit)
 {
+	int is_singlestep = (current->ptrace & PT_DTRACE) && entryexit;
+	int tracesysgood;
+
 	if (unlikely(current->audit_context)) {
 		if (!entryexit)
 			audit_syscall_entry(current, regs->orig_eax,
@@ -308,18 +320,20 @@
 			audit_syscall_exit(current, regs->eax);
 	}
 
-	if (!test_thread_flag(TIF_SYSCALL_TRACE))
+	if (!test_thread_flag(TIF_SYSCALL_TRACE) && !is_singlestep)
 		return;
 	if (!(current->ptrace & PT_PTRACED))
 		return;
 
 	/* the 0x80 provides a way for the tracing parent to distinguish
 	   between a syscall stop and SIGTRAP delivery */
-	ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
-				 ? 0x80 : 0));
+	tracesysgood = (current->ptrace & PT_TRACESYSGOOD) && !is_singlestep;
+	ptrace_notify(SIGTRAP | (tracesysgood ? 0x80 : 0));
+
+	/* force do_signal() --> is_syscall() */
+	set_thread_flag(TIF_SIGPENDING);
 
-	/*
-	 * this isn't the same as continuing with a signal, but it will do
+	/* this isn't the same as continuing with a signal, but it will do
 	 * for normal use.  strace only continues with a signal if the
 	 * stopping signal is not SIGTRAP.  -brl
 	 */
diff -Nru a/arch/um/kernel/sigio_kern.c b/arch/um/kernel/sigio_kern.c
--- a/arch/um/kernel/sigio_kern.c	2004-12-24 13:36:31 -08:00
+++ b/arch/um/kernel/sigio_kern.c	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -28,7 +28,7 @@
 	int err;
 
 	err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
-			  SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", 
+			     SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio",
 			     NULL);
 	if(err){
 		printk("write_sigio_irq : um_request_irq failed, err = %d\n",
diff -Nru a/arch/um/kernel/signal_kern.c b/arch/um/kernel/signal_kern.c
--- a/arch/um/kernel/signal_kern.c	2004-12-24 13:36:58 -08:00
+++ b/arch/um/kernel/signal_kern.c	2004-12-24 13:36:58 -08:00
@@ -38,53 +38,55 @@
 /*
  * OK, we're invoking a handler
  */	
-static int handle_signal(struct pt_regs *regs, unsigned long signr, 
-			 struct k_sigaction *ka, siginfo_t *info, 
-			 sigset_t *oldset, int error)
+static int handle_signal(struct pt_regs *regs, unsigned long signr,
+			 struct k_sigaction *ka, siginfo_t *info,
+			 sigset_t *oldset)
 {
-        __sighandler_t handler;
-	void (*restorer)(void);
 	unsigned long sp;
-	sigset_t save;
-	int err, ret;
+	int err;
 
-	ret = 0;
 	/* Always make any pending restarted system calls return -EINTR */
 	current_thread_info()->restart_block.fn = do_no_restart_syscall;
-	switch(error){
-	case -ERESTART_RESTARTBLOCK:
-	case -ERESTARTNOHAND:
-		ret = -EINTR;
-		break;
-
-	case -ERESTARTSYS:
-		if (!(ka->sa.sa_flags & SA_RESTART)) {
-			ret = -EINTR;
+
+	/* Did we come from a system call? */
+	if(PT_REGS_SYSCALL_NR(regs) >= 0){
+		/* If so, check system call restarting.. */
+		switch(PT_REGS_SYSCALL_RET(regs)){
+		case -ERESTART_RESTARTBLOCK:
+		case -ERESTARTNOHAND:
+			PT_REGS_SYSCALL_RET(regs) = -EINTR;
 			break;
-		}
+
+		case -ERESTARTSYS:
+			if (!(ka->sa.sa_flags & SA_RESTART)) {
+				PT_REGS_SYSCALL_RET(regs) = -EINTR;
+				break;
+			}
 		/* fallthrough */
-	case -ERESTARTNOINTR:
-		PT_REGS_RESTART_SYSCALL(regs);
-		PT_REGS_ORIG_SYSCALL(regs) = PT_REGS_SYSCALL_NR(regs);
-
-		/* This is because of the UM_SET_SYSCALL_RETURN and the fact
-		 * that on i386 the system call number and return value are
-		 * in the same register.  When the system call restarts, %eax
-		 * had better have the system call number in it.  Since the
-		 * return value doesn't matter (except that it shouldn't be
-		 * -ERESTART*), we'll stick the system call number there.
-		 */
-		ret = PT_REGS_SYSCALL_NR(regs);
-		break;
+		case -ERESTARTNOINTR:
+			PT_REGS_RESTART_SYSCALL(regs);
+			PT_REGS_ORIG_SYSCALL(regs) = PT_REGS_SYSCALL_NR(regs);
+			break;
+		}
 	}
 
-	handler = ka->sa.sa_handler;
-	save = *oldset;
+	sp = PT_REGS_SP(regs);
+	if((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0))
+		sp = current->sas_ss_sp + current->sas_ss_size;
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
+	if(ka->sa.sa_flags & SA_SIGINFO)
+		err = setup_signal_stack_si(sp, signr, ka, regs, info, oldset);
+	else
+		err = setup_signal_stack_sc(sp, signr, ka, regs, oldset);
 
-	if (!(ka->sa.sa_flags & SA_NODEFER)) {
+	if(err){
+		spin_lock_irq(&current->sighand->siglock);
+		current->blocked = *oldset;
+		recalc_sigpending();
+		spin_unlock_irq(&current->sighand->siglock);
+		force_sigsegv(signr, current);
+	}
+	else if(!(ka->sa.sa_flags & SA_NODEFER)){
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked, &current->blocked, 
 			  &ka->sa.sa_mask);
@@ -93,50 +95,24 @@
 		spin_unlock_irq(&current->sighand->siglock);
 	}
 
-	sp = PT_REGS_SP(regs);
-
-	if((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0))
-		sp = current->sas_ss_sp + current->sas_ss_size;
-	
-	if(error != 0) PT_REGS_SET_SYSCALL_RETURN(regs, ret);
-
-	if (ka->sa.sa_flags & SA_RESTORER) restorer = ka->sa.sa_restorer;
-	else restorer = NULL;
-
-	if(ka->sa.sa_flags & SA_SIGINFO)
-		err = setup_signal_stack_si(sp, signr, (unsigned long) handler,
-					    restorer, regs, info, &save);
-	else
-		err = setup_signal_stack_sc(sp, signr, (unsigned long) handler,
-					    restorer, regs, &save);
-	if(err) goto segv;
-
-	return(0);
- segv:
-	force_sigsegv(signr, current);
-	return(1);
+	return err;
 }
 
-static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset, int error)
+static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset)
 {
 	struct k_sigaction ka_copy;
 	siginfo_t info;
-	int err, sig;
-
-	if (!oldset)
-		oldset = &current->blocked;
+	int sig, handled_sig = 0;
 
-	sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL);
-	if(sig == 0)
-		return(0);
-
-	/* Whee!  Actually deliver the signal.  */
-	err = handle_signal(regs, sig, &ka_copy, &info, oldset, error);
-	if(!err)
-		return(1);
+	while((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0){
+		handled_sig = 1;
+		/* Whee!  Actually deliver the signal.  */
+		if(!handle_signal(regs, sig, &ka_copy, &info, oldset))
+			break;
+	}
 
 	/* Did we come from a system call? */
-	if(PT_REGS_SYSCALL_NR(regs) >= 0){
+	if(!handled_sig && (PT_REGS_SYSCALL_NR(regs) >= 0)){
 		/* Restart the system call - no handlers present */
 		if(PT_REGS_SYSCALL_RET(regs) == -ERESTARTNOHAND ||
 		   PT_REGS_SYSCALL_RET(regs) == -ERESTARTSYS ||
@@ -157,21 +133,21 @@
 	 * on the host.  The tracing thread will check this flag and 
 	 * PTRACE_SYSCALL if necessary.
 	 */
-	if((current->ptrace & PT_DTRACE) && 
-	   is_syscall(PT_REGS_IP(&current->thread.regs)))
- 		(void) CHOOSE_MODE(current->thread.mode.tt.singlestep_syscall = 1, 0);
-	return(0);
+	if(current->ptrace & PT_DTRACE)
+		current->thread.singlestep_syscall =
+			is_syscall(PT_REGS_IP(&current->thread.regs));
+	return(handled_sig);
 }
 
-int do_signal(int error)
+int do_signal(void)
 {
-	return(kern_do_signal(&current->thread.regs, NULL, error));
+	return(kern_do_signal(&current->thread.regs, &current->blocked));
 }
 
 /*
  * Atomically swap in the new signal mask, and wait for a signal.
  */
-int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
+long sys_sigsuspend(int history0, int history1, old_sigset_t mask)
 {
 	sigset_t saveset;
 
@@ -182,15 +158,16 @@
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
+	PT_REGS_SYSCALL_RET(&current->thread.regs) = -EINTR;
 	while (1) {
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();
-		if(kern_do_signal(&current->thread.regs, &saveset, -EINTR))
+		if(kern_do_signal(&current->thread.regs, &saveset))
 			return(-EINTR);
 	}
 }
 
-int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
+long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
 {
 	sigset_t saveset, newset;
 
@@ -208,10 +185,11 @@
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
+	PT_REGS_SYSCALL_RET(&current->thread.regs) = -EINTR;
 	while (1) {
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();
-		if (kern_do_signal(&current->thread.regs, &saveset, -EINTR))
+		if (kern_do_signal(&current->thread.regs, &saveset))
 			return(-EINTR);
 	}
 }
@@ -247,7 +225,7 @@
 	return ret;
 }
 
-int sys_sigaltstack(const stack_t *uss, stack_t *uoss)
+long sys_sigaltstack(const stack_t *uss, stack_t *uoss)
 {
 	return(do_sigaltstack(uss, uoss, PT_REGS_SP(&current->thread.regs)));
 }
@@ -265,7 +243,7 @@
 	return(ret);
 }
 
-int sys_sigreturn(struct pt_regs regs)
+long sys_sigreturn(struct pt_regs regs)
 {
 	void __user *sc = sp_to_sc(PT_REGS_SP(&current->thread.regs));
 	void __user *mask = sp_to_mask(PT_REGS_SP(&current->thread.regs));
@@ -283,7 +261,7 @@
 	return(PT_REGS_SYSCALL_RET(&current->thread.regs));
 }
 
-int sys_rt_sigreturn(struct pt_regs regs)
+long sys_rt_sigreturn(struct pt_regs regs)
 {
 	unsigned long sp = PT_REGS_SP(&current->thread.regs);
 	struct ucontext __user *uc = sp_to_uc(sp);
diff -Nru a/arch/um/kernel/signal_user.c b/arch/um/kernel/signal_user.c
--- a/arch/um/kernel/signal_user.c	2004-12-24 13:37:02 -08:00
+++ b/arch/um/kernel/signal_user.c	2004-12-24 13:37:02 -08:00
@@ -57,6 +57,10 @@
 	return(!sigismember(&old, signal));
 }
 
+/* Both here and in set/get_signal we don't touch SIGPROF, because we must not
+ * disable profiling; it's safe because the profiling code does not interact
+ * with the kernel code at all.*/
+
 static void change_signals(int type)
 {
 	sigset_t mask;
@@ -65,7 +69,6 @@
 	sigaddset(&mask, SIGVTALRM);
 	sigaddset(&mask, SIGALRM);
 	sigaddset(&mask, SIGIO);
-	sigaddset(&mask, SIGPROF);
 	if(sigprocmask(type, &mask, NULL) < 0)
 		panic("Failed to change signal mask - errno = %d", errno);
 }
diff -Nru a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile
--- a/arch/um/kernel/skas/Makefile	2004-12-24 13:36:33 -08:00
+++ b/arch/um/kernel/skas/Makefile	2004-12-24 13:36:33 -08:00
@@ -1,11 +1,11 @@
 # 
-# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+# Copyright (C) 2002 - 2004 Jeff Dike (jdike@addtoit.com)
 # Licensed under the GPL
 #
 
-obj-y := exec_kern.o exec_user.o mem.o mem_user.o mmu.o process.o \
-	process_kern.o syscall_kern.o syscall_user.o time.o tlb.o trap_user.o \
-	uaccess.o sys-$(SUBARCH)/
+obj-y := exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \
+	syscall_kern.o syscall_user.o time.o tlb.o trap_user.o uaccess.o \
+	sys-$(SUBARCH)/
 
 subdir-y := util
 
diff -Nru a/arch/um/kernel/skas/exec_kern.c b/arch/um/kernel/skas/exec_kern.c
--- a/arch/um/kernel/skas/exec_kern.c	2004-12-24 13:37:43 -08:00
+++ b/arch/um/kernel/skas/exec_kern.c	2004-12-24 13:37:43 -08:00
@@ -12,7 +12,7 @@
 #include "asm/mmu_context.h"
 #include "tlb.h"
 #include "skas.h"
-#include "mmu.h"
+#include "um_mmu.h"
 #include "os.h"
 
 void flush_thread_skas(void)
diff -Nru a/arch/um/kernel/skas/exec_user.c b/arch/um/kernel/skas/exec_user.c
--- a/arch/um/kernel/skas/exec_user.c	2004-12-24 13:36:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,63 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <signal.h>
-#include <sched.h>
-#include <sys/wait.h>
-#include <sys/ptrace.h>
-#include "user.h"
-#include "kern_util.h"
-#include "user_util.h"
-#include "os.h"
-#include "time_user.h"
-
-static int user_thread_tramp(void *arg)
-{
-	if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0)
-		panic("user_thread_tramp - PTRACE_TRACEME failed, "
-		      "errno = %d\n", errno);
-	enable_timer();
-	os_stop_process(os_getpid());
-	return(0);
-}
-
-int user_thread(unsigned long stack, int flags)
-{
-	int pid, status, err;
-
-	pid = clone(user_thread_tramp, (void *) stack_sp(stack), 
-		    flags | CLONE_FILES | SIGCHLD, NULL);
-	if(pid < 0){
-		printk("user_thread - clone failed, errno = %d\n", errno);
-		return(pid);
-	}
-
-	CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
-	if(err < 0){
-		printk("user_thread - waitpid failed, errno = %d\n", errno);
-		return(-errno);
-	}
-
-	if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)){
-		printk("user_thread - trampoline didn't stop, status = %d\n", 
-		       status);
-		return(-EINVAL);
-	}
-
-	return(pid);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/skas/include/mmu-skas.h b/arch/um/kernel/skas/include/mmu-skas.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/kernel/skas/include/mmu-skas.h	2004-12-24 13:37:18 -08:00
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __SKAS_MMU_H
+#define __SKAS_MMU_H
+
+struct mmu_context_skas {
+	int mm_fd;
+};
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
diff -Nru a/arch/um/kernel/skas/include/mmu.h b/arch/um/kernel/skas/include/mmu.h
--- a/arch/um/kernel/skas/include/mmu.h	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,27 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __SKAS_MMU_H
-#define __SKAS_MMU_H
-
-#include "linux/list.h"
-#include "linux/spinlock.h"
-
-struct mmu_context_skas {
-	int mm_fd;
-};
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/skas/include/mode-skas.h b/arch/um/kernel/skas/include/mode-skas.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/kernel/skas/include/mode-skas.h	2004-12-24 13:36:56 -08:00
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __MODE_SKAS_H__
+#define __MODE_SKAS_H__
+
+#include <sysdep/ptrace.h>
+
+extern unsigned long exec_regs[];
+extern unsigned long exec_fp_regs[];
+extern unsigned long exec_fpx_regs[];
+extern int have_fpx_regs;
+
+extern void user_time_init_skas(void);
+extern int copy_sc_from_user_skas(int pid, union uml_pt_regs *regs,
+				  void *from_ptr);
+extern int copy_sc_to_user_skas(int pid, void *to_ptr, void *fp,
+				union uml_pt_regs *regs,
+				unsigned long fault_addr, int fault_type);
+extern void sig_handler_common_skas(int sig, void *sc_ptr);
+extern void halt_skas(void);
+extern void reboot_skas(void);
+extern void kill_off_processes_skas(void);
+extern int is_skas_winch(int pid, int fd, void *data);
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
diff -Nru a/arch/um/kernel/skas/include/mode.h b/arch/um/kernel/skas/include/mode.h
--- a/arch/um/kernel/skas/include/mode.h	2004-12-24 13:36:56 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,37 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __MODE_SKAS_H__
-#define __MODE_SKAS_H__
-
-extern unsigned long exec_regs[];
-extern unsigned long exec_fp_regs[];
-extern unsigned long exec_fpx_regs[];
-extern int have_fpx_regs;
-
-extern void user_time_init_skas(void);
-extern int copy_sc_from_user_skas(int pid, union uml_pt_regs *regs,
-				  void *from_ptr);
-extern int copy_sc_to_user_skas(int pid, void *to_ptr, void *fp,
-				union uml_pt_regs *regs, 
-				unsigned long fault_addr, int fault_type);
-extern void sig_handler_common_skas(int sig, void *sc_ptr);
-extern void halt_skas(void);
-extern void reboot_skas(void);
-extern void kill_off_processes_skas(void);
-extern int is_skas_winch(int pid, int fd, void *data);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/skas/include/mode_kern-skas.h b/arch/um/kernel/skas/include/mode_kern-skas.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/kernel/skas/include/mode_kern-skas.h	2004-12-24 13:36:49 -08:00
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __SKAS_MODE_KERN_H__
+#define __SKAS_MODE_KERN_H__
+
+#include "linux/sched.h"
+#include "asm/page.h"
+#include "asm/ptrace.h"
+
+extern void flush_thread_skas(void);
+extern void *switch_to_skas(void *prev, void *next);
+extern void start_thread_skas(struct pt_regs *regs, unsigned long eip,
+			      unsigned long esp);
+extern int copy_thread_skas(int nr, unsigned long clone_flags,
+			    unsigned long sp, unsigned long stack_top,
+			    struct task_struct *p, struct pt_regs *regs);
+extern void release_thread_skas(struct task_struct *task);
+extern void exit_thread_skas(void);
+extern void initial_thread_cb_skas(void (*proc)(void *), void *arg);
+extern void init_idle_skas(void);
+extern void flush_tlb_kernel_range_skas(unsigned long start,
+					unsigned long end);
+extern void flush_tlb_kernel_vm_skas(void);
+extern void __flush_tlb_one_skas(unsigned long addr);
+extern void flush_tlb_range_skas(struct vm_area_struct *vma,
+				 unsigned long start, unsigned long end);
+extern void flush_tlb_mm_skas(struct mm_struct *mm);
+extern void force_flush_all_skas(void);
+extern long execute_syscall_skas(void *r);
+extern void before_mem_skas(unsigned long unused);
+extern unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out,
+					 unsigned long *task_size_out);
+extern int start_uml_skas(void);
+extern int external_pid_skas(struct task_struct *task);
+extern int thread_pid_skas(struct task_struct *task);
+
+#define kmem_end_skas (host_task_size - 1024 * 1024)
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
diff -Nru a/arch/um/kernel/skas/include/mode_kern.h b/arch/um/kernel/skas/include/mode_kern.h
--- a/arch/um/kernel/skas/include/mode_kern.h	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,53 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __SKAS_MODE_KERN_H__
-#define __SKAS_MODE_KERN_H__
-
-#include "linux/sched.h"
-#include "asm/page.h"
-#include "asm/ptrace.h"
-
-extern void flush_thread_skas(void);
-extern void *switch_to_skas(void *prev, void *next);
-extern void start_thread_skas(struct pt_regs *regs, unsigned long eip, 
-			      unsigned long esp);
-extern int copy_thread_skas(int nr, unsigned long clone_flags, 
-			    unsigned long sp, unsigned long stack_top, 
-			    struct task_struct *p, struct pt_regs *regs);
-extern void release_thread_skas(struct task_struct *task);
-extern void exit_thread_skas(void);
-extern void initial_thread_cb_skas(void (*proc)(void *), void *arg);
-extern void init_idle_skas(void);
-extern void flush_tlb_kernel_range_skas(unsigned long start, 
-					unsigned long end);
-extern void flush_tlb_kernel_vm_skas(void);
-extern void __flush_tlb_one_skas(unsigned long addr);
-extern void flush_tlb_range_skas(struct vm_area_struct *vma, 
-				 unsigned long start, unsigned long end);
-extern void flush_tlb_mm_skas(struct mm_struct *mm);
-extern void force_flush_all_skas(void);
-extern long execute_syscall_skas(void *r);
-extern void before_mem_skas(unsigned long unused);
-extern unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out,
-					 unsigned long *task_size_out);
-extern int start_uml_skas(void);
-extern int external_pid_skas(struct task_struct *task);
-extern int thread_pid_skas(struct task_struct *task);
-
-#define kmem_end_skas (host_task_size - 1024 * 1024)
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/skas/include/ptrace-skas.h b/arch/um/kernel/skas/include/ptrace-skas.h
--- a/arch/um/kernel/skas/include/ptrace-skas.h	2004-12-24 13:36:18 -08:00
+++ b/arch/um/kernel/skas/include/ptrace-skas.h	2004-12-24 13:36:18 -08:00
@@ -10,16 +10,6 @@
 
 #ifdef UML_CONFIG_MODE_SKAS
 
-/* syscall emulation path in ptrace */
-
-#ifndef PTRACE_SYSEMU
-#define PTRACE_SYSEMU 31
-#endif
-
-void set_using_sysemu(int value);
-int get_using_sysemu(void);
-extern int sysemu_supported;
-
 #include "skas_ptregs.h"
 
 #define HOST_FRAME_SIZE 17
diff -Nru a/arch/um/kernel/skas/include/skas.h b/arch/um/kernel/skas/include/skas.h
--- a/arch/um/kernel/skas/include/skas.h	2004-12-24 13:36:32 -08:00
+++ b/arch/um/kernel/skas/include/skas.h	2004-12-24 13:36:32 -08:00
@@ -28,7 +28,6 @@
 extern int protect(int fd, unsigned long addr, unsigned long len, 
 		   int r, int w, int x, int must_succeed);
 extern void user_signal(int sig, union uml_pt_regs *regs);
-extern int singlestepping_skas(void);
 extern int new_mm(int from);
 extern void save_registers(union uml_pt_regs *regs);
 extern void restore_registers(union uml_pt_regs *regs);
diff -Nru a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/kernel/skas/include/uaccess-skas.h	2004-12-24 13:36:48 -08:00
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __SKAS_UACCESS_H
+#define __SKAS_UACCESS_H
+
+#include "asm/errno.h"
+
+#define access_ok_skas(type, addr, size) \
+	((segment_eq(get_fs(), KERNEL_DS)) || \
+	 (((unsigned long) (addr) < TASK_SIZE) && \
+	  ((unsigned long) (addr) + (size) <= TASK_SIZE)))
+
+static inline int verify_area_skas(int type, const void * addr,
+				   unsigned long size)
+{
+	return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
+}
+
+extern int copy_from_user_skas(void *to, const void *from, int n);
+extern int copy_to_user_skas(void *to, const void *from, int n);
+extern int strncpy_from_user_skas(char *dst, const char *src, int count);
+extern int __clear_user_skas(void *mem, int len);
+extern int clear_user_skas(void *mem, int len);
+extern int strnlen_user_skas(const void *str, int len);
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
diff -Nru a/arch/um/kernel/skas/include/uaccess.h b/arch/um/kernel/skas/include/uaccess.h
--- a/arch/um/kernel/skas/include/uaccess.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,40 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __SKAS_UACCESS_H
-#define __SKAS_UACCESS_H
-
-#include "asm/errno.h"
-
-#define access_ok_skas(type, addr, size) \
-	((segment_eq(get_fs(), KERNEL_DS)) || \
-	 (((unsigned long) (addr) < TASK_SIZE) && \
-	  ((unsigned long) (addr) + (size) <= TASK_SIZE)))
-
-static inline int verify_area_skas(int type, const void * addr, 
-				   unsigned long size)
-{
-	return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
-}
-
-extern int copy_from_user_skas(void *to, const void *from, int n);
-extern int copy_to_user_skas(void *to, const void *from, int n);
-extern int strncpy_from_user_skas(char *dst, const char *src, int count);
-extern int __clear_user_skas(void *mem, int len);
-extern int clear_user_skas(void *mem, int len);
-extern int strnlen_user_skas(const void *str, int len);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
--- a/arch/um/kernel/skas/process.c	2004-12-24 13:37:29 -08:00
+++ b/arch/um/kernel/skas/process.c	2004-12-24 13:37:29 -08:00
@@ -30,7 +30,7 @@
 
 int is_skas_winch(int pid, int fd, void *data)
 {
-	if(pid != getpid())
+	if(pid != os_getpid())
 		return(0);
 
 	register_winch_irq(-1, fd, -1, data);
@@ -64,7 +64,7 @@
 
 	syscall_nr = PT_SYSCALL_NR(regs->skas.regs);
 	UPT_SYSCALL_NR(regs) = syscall_nr;
-	if(syscall_nr < 1){
+	if(syscall_nr < 0){
 		relay_signal(SIGTRAP, regs);
 		return;
 	}
@@ -139,17 +139,16 @@
 
 void userspace(union uml_pt_regs *regs)
 {
-	int err, status, op, pid = userspace_pid[0];
+	int err, status, op, pt_syscall_parm, pid = userspace_pid[0];
 	int local_using_sysemu; /*To prevent races if using_sysemu changes under us.*/
 
 	restore_registers(regs);
 		
 	local_using_sysemu = get_using_sysemu();
 
-	if (local_using_sysemu)
-		err = ptrace(PTRACE_SYSEMU, pid, 0, 0);
-	else
-		err = ptrace(PTRACE_SYSCALL, pid, 0, 0);
+	pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
+	err = ptrace(pt_syscall_parm, pid, 0, 0);
+
 	if(err)
 		panic("userspace - PTRACE_%s failed, errno = %d\n",
 		       local_using_sysemu ? "SYSEMU" : "SYSCALL", errno);
@@ -189,13 +188,10 @@
 
 		/*Now we ended the syscall, so re-read local_using_sysemu.*/
 		local_using_sysemu = get_using_sysemu();
+		pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
 
-		if (local_using_sysemu)
-			op = singlestepping_skas() ? PTRACE_SINGLESTEP :
-				PTRACE_SYSEMU;
-		else
-			op = singlestepping_skas() ? PTRACE_SINGLESTEP :
-				PTRACE_SYSCALL;
+		op = singlestepping(NULL) ? PTRACE_SINGLESTEP :
+			pt_syscall_parm;
 
 		err = ptrace(op, pid, 0, 0);
 		if(err)
@@ -389,7 +385,7 @@
 void kill_off_processes_skas(void)
 {
 #warning need to loop over userspace_pids in kill_off_processes_skas
-	os_kill_process(userspace_pid[0], 1);
+	os_kill_ptraced_process(userspace_pid[0], 1);
 }
 
 void init_registers(int pid)
diff -Nru a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
--- a/arch/um/kernel/skas/process_kern.c	2004-12-24 13:37:43 -08:00
+++ b/arch/um/kernel/skas/process_kern.c	2004-12-24 13:37:43 -08:00
@@ -24,69 +24,6 @@
 #include "mode.h"
 #include "proc_mm.h"
 
-static atomic_t using_sysemu;
-int sysemu_supported;
-
-void set_using_sysemu(int value)
-{
-	atomic_set(&using_sysemu, sysemu_supported && value);
-}
-
-int get_using_sysemu(void)
-{
-	return atomic_read(&using_sysemu);
-}
-
-int proc_read_sysemu(char *buf, char **start, off_t offset, int size,int *eof, void *data)
-{
-	if (snprintf(buf, size, "%d\n", get_using_sysemu()) < size) /*No overflow*/
-		*eof = 1;
-
-	return strlen(buf);
-}
-
-int proc_write_sysemu(struct file *file,const char *buf, unsigned long count,void *data)
-{
-	char tmp[2];
-
-	if (copy_from_user(tmp, buf, 1))
-		return -EFAULT;
-
-	if (tmp[0] == '0' || tmp[0] == '1')
-		set_using_sysemu(tmp[0] - '0');
-	return count; /*We use the first char, but pretend to write everything*/
-}
-
-int __init make_proc_sysemu(void)
-{
-	struct proc_dir_entry *ent;
-	if (mode_tt || !sysemu_supported)
-		return 0;
-
-	ent = create_proc_entry("sysemu", 0600, &proc_root);
-
-	if (ent == NULL)
-	{
-		printk("Failed to register /proc/sysemu\n");
-		return(0);
-	}
-
-	ent->read_proc  = proc_read_sysemu;
-	ent->write_proc = proc_write_sysemu;
-
-	return 0;
-}
-
-late_initcall(make_proc_sysemu);
-
-int singlestepping_skas(void)
-{
-	int ret = current->ptrace & PT_DTRACE;
-
-	current->ptrace &= ~PT_DTRACE;
-	return(ret);
-}
-
 void *switch_to_skas(void *prev, void *next)
 {
 	struct task_struct *from, *to;
diff -Nru a/arch/um/kernel/skas/syscall_kern.c b/arch/um/kernel/skas/syscall_kern.c
--- a/arch/um/kernel/skas/syscall_kern.c	2004-12-24 13:37:00 -08:00
+++ b/arch/um/kernel/skas/syscall_kern.c	2004-12-24 13:37:00 -08:00
@@ -4,6 +4,7 @@
  */
 
 #include "linux/sys.h"
+#include "linux/ptrace.h"
 #include "asm/errno.h"
 #include "asm/unistd.h"
 #include "asm/ptrace.h"
diff -Nru a/arch/um/kernel/skas/syscall_user.c b/arch/um/kernel/skas/syscall_user.c
--- a/arch/um/kernel/skas/syscall_user.c	2004-12-24 13:37:29 -08:00
+++ b/arch/um/kernel/skas/syscall_user.c	2004-12-24 13:37:29 -08:00
@@ -10,10 +10,6 @@
 #include "sysdep/ptrace.h"
 #include "sysdep/sigcontext.h"
 
-/* XXX Bogus */
-#define ERESTARTSYS	512
-#define ERESTARTNOINTR	513
-#define ERESTARTNOHAND	514
 
 void handle_syscall(union uml_pt_regs *regs)
 {
@@ -22,15 +18,12 @@
 
 	index = record_syscall_start(UPT_SYSCALL_NR(regs));
 
-	syscall_trace(regs, 1);
+	syscall_trace(regs, 0);
 	result = execute_syscall(regs);
 
 	REGS_SET_SYSCALL_RETURN(regs->skas.regs, result);
-	if((result == -ERESTARTNOHAND) || (result == -ERESTARTSYS) || 
-	   (result == -ERESTARTNOINTR))
-		do_signal(result);
 
-	syscall_trace(regs, 0);
+	syscall_trace(regs, 1);
 	record_syscall_end(index, result);
 }
 
diff -Nru a/arch/um/kernel/syscall_kern.c b/arch/um/kernel/syscall_kern.c
--- a/arch/um/kernel/syscall_kern.c	2004-12-24 13:37:02 -08:00
+++ b/arch/um/kernel/syscall_kern.c	2004-12-24 13:37:02 -08:00
@@ -104,11 +104,11 @@
 	unsigned long offset;
 };
 
-int old_mmap(unsigned long addr, unsigned long len,
+long old_mmap(unsigned long addr, unsigned long len,
 	     unsigned long prot, unsigned long flags,
 	     unsigned long fd, unsigned long offset)
 {
-	int err = -EINVAL;
+	long err = -EINVAL;
 	if (offset & ~PAGE_MASK)
 		goto out;
 
@@ -120,10 +120,10 @@
  * sys_pipe() is the normal C calling standard for creating
  * a pipe. It's not the way unix traditionally does this, though.
  */
-int sys_pipe(unsigned long * fildes)
+long sys_pipe(unsigned long * fildes)
 {
         int fd[2];
-        int error;
+        long error;
 
         error = do_pipe(fd);
         if (!error) {
@@ -218,9 +218,9 @@
 	}
 }
 
-int sys_uname(struct old_utsname * name)
+long sys_uname(struct old_utsname * name)
 {
-	int err;
+	long err;
 	if (!name)
 		return -EFAULT;
 	down_read(&uts_sem);
@@ -229,9 +229,9 @@
 	return err?-EFAULT:0;
 }
 
-int sys_olduname(struct oldold_utsname * name)
+long sys_olduname(struct oldold_utsname * name)
 {
-	int error;
+	long error;
 
 	if (!name)
 		return -EFAULT;
diff -Nru a/arch/um/kernel/syscall_user.c b/arch/um/kernel/syscall_user.c
--- a/arch/um/kernel/syscall_user.c	2004-12-24 13:37:04 -08:00
+++ b/arch/um/kernel/syscall_user.c	2004-12-24 13:37:04 -08:00
@@ -11,7 +11,7 @@
 struct {
 	int syscall;
 	int pid;
-	int result;
+	long result;
 	struct timeval start;
 	struct timeval end;
 } syscall_record[1024];
@@ -30,7 +30,7 @@
 	return(index);
 }
 
-void record_syscall_end(int index, int result)
+void record_syscall_end(int index, long result)
 {
 	syscall_record[index].result = result;
 	gettimeofday(&syscall_record[index].end, NULL);
diff -Nru a/arch/um/kernel/sysrq.c b/arch/um/kernel/sysrq.c
--- a/arch/um/kernel/sysrq.c	2004-12-24 13:36:47 -08:00
+++ b/arch/um/kernel/sysrq.c	2004-12-24 13:36:47 -08:00
@@ -6,6 +6,7 @@
 #include "linux/sched.h"
 #include "linux/kernel.h"
 #include "linux/module.h"
+#include "linux/kallsyms.h"
 #include "asm/page.h"
 #include "asm/processor.h"
 #include "sysrq.h"
@@ -13,21 +14,20 @@
 
 void show_trace(unsigned long * stack)
 {
-        int i;
+	/* XXX: Copy the CONFIG_FRAME_POINTER stack-walking backtrace from
+	 * arch/i386/kernel/traps.c. */
         unsigned long addr;
 
         if (!stack)
                 stack = (unsigned long*) &stack;
 
-        printk("Call Trace: ");
-        i = 1;
+        printk("Call Trace: \n");
         while (((long) stack & (THREAD_SIZE-1)) != 0) {
                 addr = *stack++;
 		if (__kernel_text_address(addr)) {
-			if (i && ((i % 6) == 0))
-				printk("\n   ");
-			printk("[<%08lx>] ", addr);
-			i++;
+			printk(" [<%08lx>]", addr);
+			print_symbol(" %s", addr);
+			printk("\n");
                 }
         }
         printk("\n");
@@ -48,14 +48,3 @@
 {
 	show_trace(sp);
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/time_kern.c b/arch/um/kernel/time_kern.c
--- a/arch/um/kernel/time_kern.c	2004-12-24 13:37:00 -08:00
+++ b/arch/um/kernel/time_kern.c	2004-12-24 13:37:00 -08:00
@@ -169,11 +169,9 @@
 
 void timer_handler(int sig, union uml_pt_regs *regs)
 {
-#ifdef CONFIG_SMP
 	local_irq_disable();
 	update_process_times(user_context(UPT_SP(regs)));
 	local_irq_enable();
-#endif
 	if(current_thread->cpu == 0)
 		timer_irq(regs);
 }
diff -Nru a/arch/um/kernel/tt/Makefile b/arch/um/kernel/tt/Makefile
--- a/arch/um/kernel/tt/Makefile	2004-12-24 13:36:55 -08:00
+++ b/arch/um/kernel/tt/Makefile	2004-12-24 13:36:55 -08:00
@@ -4,6 +4,7 @@
 #
 
 extra-y := unmap_fin.o
+clean-files := unmap_tmp.o
 
 obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
 	syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \
@@ -20,10 +21,9 @@
 $(USER_OBJS) : %.o: %.c
 	$(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
 
-$(O_TARGET) : $(obj)/unmap_fin.o
-
 $(obj)/unmap.o: $(src)/unmap.c
 	$(CC) $(UNMAP_CFLAGS) -c -o $@ $<
 
-$(obj)/unmap_fin.o : $(src)/unmap.o
-	ld -r -o $@ $< -lc -L/usr/lib
+$(obj)/unmap_fin.o : $(obj)/unmap.o
+	ld -r -o $(obj)/unmap_tmp.o  $< -lc -L/usr/lib
+	objcopy $(obj)/unmap_tmp.o $@ -G switcheroo
diff -Nru a/arch/um/kernel/tt/include/mmu-tt.h b/arch/um/kernel/tt/include/mmu-tt.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/kernel/tt/include/mmu-tt.h	2004-12-24 13:36:48 -08:00
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __TT_MMU_H
+#define __TT_MMU_H
+
+struct mmu_context_tt {
+};
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
diff -Nru a/arch/um/kernel/tt/include/mmu.h b/arch/um/kernel/tt/include/mmu.h
--- a/arch/um/kernel/tt/include/mmu.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,23 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __TT_MMU_H
-#define __TT_MMU_H
-
-struct mmu_context_tt {
-};
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/tt/include/mode-tt.h b/arch/um/kernel/tt/include/mode-tt.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/kernel/tt/include/mode-tt.h	2004-12-24 13:37:00 -08:00
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __MODE_TT_H__
+#define __MODE_TT_H__
+
+#include "sysdep/ptrace.h"
+
+enum { OP_NONE, OP_EXEC, OP_FORK, OP_TRACE_ON, OP_REBOOT, OP_HALT, OP_CB };
+
+extern int tracing_pid;
+
+extern int tracer(int (*init_proc)(void *), void *sp);
+extern void user_time_init_tt(void);
+extern int copy_sc_from_user_tt(void *to_ptr, void *from_ptr, void *data);
+extern int copy_sc_to_user_tt(void *to_ptr, void *fp, void *from_ptr,
+			      void *data);
+extern void sig_handler_common_tt(int sig, void *sc);
+extern void syscall_handler_tt(int sig, union uml_pt_regs *regs);
+extern void reboot_tt(void);
+extern void halt_tt(void);
+extern int is_tracer_winch(int pid, int fd, void *data);
+extern void kill_off_processes_tt(void);
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
diff -Nru a/arch/um/kernel/tt/include/mode.h b/arch/um/kernel/tt/include/mode.h
--- a/arch/um/kernel/tt/include/mode.h	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,38 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __MODE_TT_H__
-#define __MODE_TT_H__
-
-#include "sysdep/ptrace.h"
-
-enum { OP_NONE, OP_EXEC, OP_FORK, OP_TRACE_ON, OP_REBOOT, OP_HALT, OP_CB };
-
-extern int tracing_pid;
-
-extern int tracer(int (*init_proc)(void *), void *sp);
-extern void user_time_init_tt(void);
-extern int copy_sc_from_user_tt(void *to_ptr, void *from_ptr, void *data);
-extern int copy_sc_to_user_tt(void *to_ptr, void *fp, void *from_ptr, 
-			      void *data);
-extern void sig_handler_common_tt(int sig, void *sc);
-extern void syscall_handler_tt(int sig, union uml_pt_regs *regs);
-extern void reboot_tt(void);
-extern void halt_tt(void);
-extern int is_tracer_winch(int pid, int fd, void *data);
-extern void kill_off_processes_tt(void);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/tt/include/mode_kern-tt.h b/arch/um/kernel/tt/include/mode_kern-tt.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/kernel/tt/include/mode_kern-tt.h	2004-12-24 13:36:31 -08:00
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __TT_MODE_KERN_H__
+#define __TT_MODE_KERN_H__
+
+#include "linux/sched.h"
+#include "asm/page.h"
+#include "asm/ptrace.h"
+#include "asm/uaccess.h"
+
+extern void *switch_to_tt(void *prev, void *next);
+extern void flush_thread_tt(void);
+extern void start_thread_tt(struct pt_regs *regs, unsigned long eip,
+			   unsigned long esp);
+extern int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
+			  unsigned long stack_top, struct task_struct *p,
+			  struct pt_regs *regs);
+extern void release_thread_tt(struct task_struct *task);
+extern void exit_thread_tt(void);
+extern void initial_thread_cb_tt(void (*proc)(void *), void *arg);
+extern void init_idle_tt(void);
+extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end);
+extern void flush_tlb_kernel_vm_tt(void);
+extern void __flush_tlb_one_tt(unsigned long addr);
+extern void flush_tlb_range_tt(struct vm_area_struct *vma,
+			       unsigned long start, unsigned long end);
+extern void flush_tlb_mm_tt(struct mm_struct *mm);
+extern void force_flush_all_tt(void);
+extern long execute_syscall_tt(void *r);
+extern void before_mem_tt(unsigned long brk_start);
+extern unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out,
+				       unsigned long *task_size_out);
+extern int start_uml_tt(void);
+extern int external_pid_tt(struct task_struct *task);
+extern int thread_pid_tt(struct task_struct *task);
+
+#define kmem_end_tt (host_task_size - ABOVE_KMEM)
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
diff -Nru a/arch/um/kernel/tt/include/mode_kern.h b/arch/um/kernel/tt/include/mode_kern.h
--- a/arch/um/kernel/tt/include/mode_kern.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,53 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __TT_MODE_KERN_H__
-#define __TT_MODE_KERN_H__
-
-#include "linux/sched.h"
-#include "asm/page.h"
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-
-extern void *switch_to_tt(void *prev, void *next);
-extern void flush_thread_tt(void);
-extern void start_thread_tt(struct pt_regs *regs, unsigned long eip, 
-			   unsigned long esp);
-extern int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
-			  unsigned long stack_top, struct task_struct *p, 
-			  struct pt_regs *regs);
-extern void release_thread_tt(struct task_struct *task);
-extern void exit_thread_tt(void);
-extern void initial_thread_cb_tt(void (*proc)(void *), void *arg);
-extern void init_idle_tt(void);
-extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end);
-extern void flush_tlb_kernel_vm_tt(void);
-extern void __flush_tlb_one_tt(unsigned long addr);
-extern void flush_tlb_range_tt(struct vm_area_struct *vma, 
-			       unsigned long start, unsigned long end);
-extern void flush_tlb_mm_tt(struct mm_struct *mm);
-extern void force_flush_all_tt(void);
-extern long execute_syscall_tt(void *r);
-extern void before_mem_tt(unsigned long brk_start);
-extern unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, 
-				       unsigned long *task_size_out);
-extern int start_uml_tt(void);
-extern int external_pid_tt(struct task_struct *task);
-extern int thread_pid_tt(struct task_struct *task);
-
-#define kmem_end_tt (host_task_size - ABOVE_KMEM)
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/tt/include/tt.h b/arch/um/kernel/tt/include/tt.h
--- a/arch/um/kernel/tt/include/tt.h	2004-12-24 13:36:56 -08:00
+++ b/arch/um/kernel/tt/include/tt.h	2004-12-24 13:36:56 -08:00
@@ -24,11 +24,9 @@
 extern int set_user_mode(void *task);
 extern void set_tracing(void *t, int tracing);
 extern int is_tracing(void *task);
-extern int singlestepping_tt(void *t);
-extern void clear_singlestep(void *t);
 extern void syscall_handler(int sig, union uml_pt_regs *regs);
 extern void exit_kernel(int pid, void *task);
-extern int do_syscall(void *task, int pid);
+extern int do_syscall(void *task, int pid, int local_using_sysemu);
 extern int is_valid_pid(int pid);
 extern void remap_data(void *segment_start, void *segment_end, int w);
 
diff -Nru a/arch/um/kernel/tt/include/uaccess-tt.h b/arch/um/kernel/tt/include/uaccess-tt.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/um/kernel/tt/include/uaccess-tt.h	2004-12-24 13:37:01 -08:00
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __TT_UACCESS_H
+#define __TT_UACCESS_H
+
+#include "linux/string.h"
+#include "linux/sched.h"
+#include "asm/processor.h"
+#include "asm/errno.h"
+#include "asm/current.h"
+#include "asm/a.out.h"
+#include "uml_uaccess.h"
+
+#define ABOVE_KMEM (16 * 1024 * 1024)
+
+extern unsigned long end_vm;
+extern unsigned long uml_physmem;
+
+#define under_task_size(addr, size) \
+	(((unsigned long) (addr) < TASK_SIZE) && \
+         (((unsigned long) (addr) + (size)) < TASK_SIZE))
+
+#define is_stack(addr, size) \
+	(((unsigned long) (addr) < STACK_TOP) && \
+	 ((unsigned long) (addr) >= STACK_TOP - ABOVE_KMEM) && \
+	 (((unsigned long) (addr) + (size)) <= STACK_TOP))
+
+#define access_ok_tt(type, addr, size) \
+	((type == VERIFY_READ) || (segment_eq(get_fs(), KERNEL_DS)) || \
+         (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \
+          (under_task_size(addr, size) || is_stack(addr, size))))
+
+static inline int verify_area_tt(int type, const void * addr,
+				 unsigned long size)
+{
+	return(access_ok_tt(type, addr, size) ? 0 : -EFAULT);
+}
+
+extern unsigned long get_fault_addr(void);
+
+extern int __do_copy_from_user(void *to, const void *from, int n,
+			       void **fault_addr, void **fault_catcher);
+extern int __do_strncpy_from_user(char *dst, const char *src, size_t n,
+				  void **fault_addr, void **fault_catcher);
+extern int __do_clear_user(void *mem, size_t len, void **fault_addr,
+			   void **fault_catcher);
+extern int __do_strnlen_user(const char *str, unsigned long n,
+			     void **fault_addr, void **fault_catcher);
+
+extern int copy_from_user_tt(void *to, const void *from, int n);
+extern int copy_to_user_tt(void *to, const void *from, int n);
+extern int strncpy_from_user_tt(char *dst, const char *src, int count);
+extern int __clear_user_tt(void *mem, int len);
+extern int clear_user_tt(void *mem, int len);
+extern int strnlen_user_tt(const void *str, int len);
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
diff -Nru a/arch/um/kernel/tt/include/uaccess.h b/arch/um/kernel/tt/include/uaccess.h
--- a/arch/um/kernel/tt/include/uaccess.h	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,71 +0,0 @@
-/* 
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#ifndef __TT_UACCESS_H
-#define __TT_UACCESS_H
-
-#include "linux/string.h"
-#include "linux/sched.h"
-#include "asm/processor.h"
-#include "asm/errno.h"
-#include "asm/current.h"
-#include "asm/a.out.h"
-#include "uml_uaccess.h"
-
-#define ABOVE_KMEM (16 * 1024 * 1024)
-
-extern unsigned long end_vm;
-extern unsigned long uml_physmem;
-
-#define under_task_size(addr, size) \
-	(((unsigned long) (addr) < TASK_SIZE) && \
-         (((unsigned long) (addr) + (size)) < TASK_SIZE))
-
-#define is_stack(addr, size) \
-	(((unsigned long) (addr) < STACK_TOP) && \
-	 ((unsigned long) (addr) >= STACK_TOP - ABOVE_KMEM) && \
-	 (((unsigned long) (addr) + (size)) <= STACK_TOP))
-
-#define access_ok_tt(type, addr, size) \
-	((type == VERIFY_READ) || (segment_eq(get_fs(), KERNEL_DS)) || \
-         (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \
-          (under_task_size(addr, size) || is_stack(addr, size))))
-
-static inline int verify_area_tt(int type, const void * addr, 
-				 unsigned long size)
-{
-	return(access_ok_tt(type, addr, size) ? 0 : -EFAULT);
-}
-
-extern unsigned long get_fault_addr(void);
-
-extern int __do_copy_from_user(void *to, const void *from, int n,
-			       void **fault_addr, void **fault_catcher);
-extern int __do_strncpy_from_user(char *dst, const char *src, size_t n,
-				  void **fault_addr, void **fault_catcher);
-extern int __do_clear_user(void *mem, size_t len, void **fault_addr,
-			   void **fault_catcher);
-extern int __do_strnlen_user(const char *str, unsigned long n,
-			     void **fault_addr, void **fault_catcher);
-
-extern int copy_from_user_tt(void *to, const void *from, int n);
-extern int copy_to_user_tt(void *to, const void *from, int n);
-extern int strncpy_from_user_tt(char *dst, const char *src, int count);
-extern int __clear_user_tt(void *mem, int len);
-extern int clear_user_tt(void *mem, int len);
-extern int strnlen_user_tt(const void *str, int len);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
--- a/arch/um/kernel/tt/process_kern.c	2004-12-24 13:37:18 -08:00
+++ b/arch/um/kernel/tt/process_kern.c	2004-12-24 13:37:18 -08:00
@@ -65,7 +65,7 @@
 		panic("write of switch_pipe failed, err = %d", -err);
 
 	reading = 1;
-	if((from->state == TASK_ZOMBIE) || (from->state == TASK_DEAD))
+	if((from->exit_state == EXIT_ZOMBIE) || (from->exit_state == EXIT_DEAD))
 		os_kill_process(os_getpid(), 0);
 
 	err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c));
@@ -80,9 +80,9 @@
 	 * in case it has not already killed itself.
 	 */
 	prev_sched = current->thread.prev_sched;
-	if((prev_sched->state == TASK_ZOMBIE) ||
-	   (prev_sched->state == TASK_DEAD))
-		os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1);
+	if((prev_sched->exit_state == EXIT_ZOMBIE) ||
+	   (prev_sched->exit_state == EXIT_DEAD))
+		os_kill_ptraced_process(prev_sched->thread.mode.tt.extern_pid, 1);
 
 	/* This works around a nasty race with 'jail'.  If we are switching
 	 * between two threads of a threaded app and the incoming process 
@@ -305,7 +305,6 @@
 
 	change_sig(SIGUSR1, 0);
 	err = 0;
- out:
 	return(err);
 }
 
@@ -522,22 +521,6 @@
 	if(err)
 		panic("Can't create switch pipe for init_task, errno = %d",
 		      -err);
-}
-
-int singlestepping_tt(void *t)
-{
-	struct task_struct *task = t;
-
-	if(task->thread.mode.tt.singlestep_syscall)
-		return(0);
-	return(task->ptrace & PT_DTRACE);
-}
-
-void clear_singlestep(void *t)
-{
-	struct task_struct *task = t;
-
-	task->ptrace &= ~PT_DTRACE;
 }
 
 int start_uml_tt(void)
diff -Nru a/arch/um/kernel/tt/syscall_kern.c b/arch/um/kernel/tt/syscall_kern.c
--- a/arch/um/kernel/tt/syscall_kern.c	2004-12-24 13:36:16 -08:00
+++ b/arch/um/kernel/tt/syscall_kern.c	2004-12-24 13:36:16 -08:00
@@ -123,12 +123,6 @@
 
 	set_fs(USER_DS);
 
-	if(current->thread.mode.tt.singlestep_syscall){
-		current->thread.mode.tt.singlestep_syscall = 0;
-		current->ptrace &= ~PT_DTRACE;
-		force_sig(SIGTRAP, current);
-	}
-
 	return(res);
 }
 
diff -Nru a/arch/um/kernel/tt/syscall_user.c b/arch/um/kernel/tt/syscall_user.c
--- a/arch/um/kernel/tt/syscall_user.c	2004-12-24 13:37:01 -08:00
+++ b/arch/um/kernel/tt/syscall_user.c	2004-12-24 13:37:01 -08:00
@@ -17,10 +17,6 @@
 #include "syscall_user.h"
 #include "tt.h"
 
-/* XXX Bogus */
-#define ERESTARTSYS	512
-#define ERESTARTNOINTR	513
-#define ERESTARTNOHAND	514
 
 void syscall_handler_tt(int sig, union uml_pt_regs *regs)
 {
@@ -33,7 +29,7 @@
 	SC_START_SYSCALL(sc);
 
 	index = record_syscall_start(syscall);
-	syscall_trace(regs, 1);
+	syscall_trace(regs, 0);
 	result = execute_syscall(regs);
 
 	/* regs->sc may have changed while the system call ran (there may
@@ -42,15 +38,12 @@
 	UPT_SC(regs) = sc;
 
 	SC_SET_SYSCALL_RETURN(sc, result);
-	if((result == -ERESTARTNOHAND) || (result == -ERESTARTSYS) || 
-	   (result == -ERESTARTNOINTR))
-		do_signal(result);
 
-	syscall_trace(regs, 0);
+	syscall_trace(regs, 1);
 	record_syscall_end(index, result);
 }
 
-int do_syscall(void *task, int pid)
+int do_syscall(void *task, int pid, int local_using_sysemu)
 {
 	unsigned long proc_regs[FRAME_SIZE];
 	union uml_pt_regs *regs;
@@ -63,12 +56,16 @@
 	regs = TASK_REGS(task);
 	UPT_SYSCALL_NR(regs) = syscall;
 
-	if(syscall < 1) return(0);
+	if(syscall < 0)
+		return(0);
 
 	if((syscall != __NR_sigreturn) &&
 	   ((unsigned long *) PT_IP(proc_regs) >= &_stext) && 
 	   ((unsigned long *) PT_IP(proc_regs) <= &_etext))
 		tracer_panic("I'm tracing myself and I can't get out");
+
+	if(local_using_sysemu)
+		return(1);
 
 	if(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, 
 		  __NR_getpid) < 0)
diff -Nru a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c
--- a/arch/um/kernel/tt/tracer.c	2004-12-24 13:36:17 -08:00
+++ b/arch/um/kernel/tt/tracer.c	2004-12-24 13:36:17 -08:00
@@ -184,6 +184,7 @@
 	unsigned long eip = 0;
 	int status, pid = 0, sig = 0, cont_type, tracing = 0, op = 0;
 	int last_index, proc_id = 0, n, err, old_tracing = 0, strace = 0;
+	int pt_syscall_parm, local_using_sysemu;
 
 	capture_signal_stack();
 	signal(SIGPIPE, SIG_IGN);
@@ -297,6 +298,9 @@
 			tracing = is_tracing(task);
 			old_tracing = tracing;
 
+			local_using_sysemu = get_using_sysemu();
+			pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
+
 			switch(sig){
 			case SIGUSR1:
 				sig = 0;
@@ -330,9 +334,8 @@
 					continue;
 				}
 				tracing = 0;
-				if(do_syscall(task, pid))
+				if(do_syscall(task, pid, local_using_sysemu))
 					sig = SIGUSR2;
-				else clear_singlestep(task);
 				break;
 			case SIGPROF:
 				if(tracing) sig = 0;
@@ -349,6 +352,7 @@
 			case SIGBUS:
 			case SIGILL:
 			case SIGWINCH:
+
 			default:
 				tracing = 0;
 				break;
@@ -368,9 +372,9 @@
 			}
 
 			if(tracing){
-				if(singlestepping_tt(task))
+				if(singlestepping(task))
 					cont_type = PTRACE_SINGLESTEP;
-				else cont_type = PTRACE_SYSCALL;
+				else cont_type = pt_syscall_parm;
 			}
 			else cont_type = PTRACE_CONT;
 
diff -Nru a/arch/um/kernel/tt/trap_user.c b/arch/um/kernel/tt/trap_user.c
--- a/arch/um/kernel/tt/trap_user.c	2004-12-24 13:36:59 -08:00
+++ b/arch/um/kernel/tt/trap_user.c	2004-12-24 13:36:59 -08:00
@@ -30,6 +30,13 @@
 	if(sig == SIGSEGV)
 		change_sig(SIGSEGV, 1);
 
+	/* This is done because to allow SIGSEGV to be delivered inside a SEGV
+	 * handler.  This can happen in copy_user, and if SEGV is disabled,
+	 * the process will die.
+	 */
+	if(sig == SIGSEGV)
+		change_sig(SIGSEGV, 1);
+
 	r = &TASK_REGS(get_current())->tt;
 	save_regs = *r;
 	is_user = user_context(SC_SP(sc));
diff -Nru a/arch/um/kernel/tty_log.c b/arch/um/kernel/tty_log.c
--- a/arch/um/kernel/tty_log.c	2004-12-24 13:37:00 -08:00
+++ b/arch/um/kernel/tty_log.c	2004-12-24 13:37:00 -08:00
@@ -205,6 +205,8 @@
 		printf("set_tty_log_fd - strtoul failed on '%s'\n", name);
 		tty_log_fd = -1;
 	}
+
+	*add = 0;
 	return 0;
 }
 
diff -Nru a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
--- a/arch/um/kernel/um_arch.c	2004-12-24 13:37:18 -08:00
+++ b/arch/um/kernel/um_arch.c	2004-12-24 13:37:18 -08:00
@@ -321,6 +321,11 @@
 	uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
 				     &host_task_size, &task_size);
 
+	/* Need to check this early because mmapping happens before the
+	 * kernel is running.
+	 */
+	check_tmpexec();
+
 	brk_start = (unsigned long) sbrk(0);
 	CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start);
 	/* Increase physical memory size for exec-shield users
@@ -400,9 +405,9 @@
 static int panic_exit(struct notifier_block *self, unsigned long unused1,
 		      void *unused2)
 {
-#ifdef CONFIG_MAGIC_SYSRQ
-	handle_sysrq('p', &current->thread.regs, NULL);
-#endif
+	bust_spinlocks(1);
+	show_regs(&(current->thread.regs));
+	bust_spinlocks(0);
 	uml_exitcode = 1;
 	machine_halt();
 	return(0);
diff -Nru a/arch/um/kernel/umid.c b/arch/um/kernel/umid.c
--- a/arch/um/kernel/umid.c	2004-12-24 13:37:19 -08:00
+++ b/arch/um/kernel/umid.c	2004-12-24 13:37:19 -08:00
@@ -54,6 +54,7 @@
 
 static int __init set_umid_arg(char *name, int *add)
 {
+	*add = 0;
 	return(set_umid(name, 0, printf));
 }
 
diff -Nru a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
--- a/arch/um/kernel/uml.lds.S	2004-12-24 13:36:48 -08:00
+++ b/arch/um/kernel/uml.lds.S	2004-12-24 13:36:48 -08:00
@@ -35,6 +35,8 @@
   {
     *(.text)
     SCHED_TEXT
+    LOCK_TEXT
+    *(.fixup)
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)
     *(.gnu.linkonce.t*)
diff -Nru a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
--- a/arch/um/os-Linux/file.c	2004-12-24 13:37:30 -08:00
+++ b/arch/um/os-Linux/file.c	2004-12-24 13:37:30 -08:00
@@ -308,7 +308,8 @@
 	__u64 actual;
 
 	actual = lseek64(fd, offset, SEEK_SET);
-	if(actual != offset) return(-errno);
+	if(actual != offset)
+		return(-errno);
 	return(0);
 }
 
diff -Nru a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
--- a/arch/um/os-Linux/process.c	2004-12-24 13:36:18 -08:00
+++ b/arch/um/os-Linux/process.c	2004-12-24 13:36:18 -08:00
@@ -8,6 +8,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <linux/unistd.h>
+#include <sys/ptrace.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include "os.h"
@@ -94,10 +95,21 @@
 		
 }
 
+void os_kill_ptraced_process(int pid, int reap_child)
+{
+	ptrace(PTRACE_KILL, pid);
+	if(reap_child)
+		CATCH_EINTR(waitpid(pid, NULL, 0));
+}
+
 void os_usr1_process(int pid)
 {
 	kill(pid, SIGUSR1);
 }
+
+/*Don't use the glibc version, which caches the result in TLS. It misses some
+ * syscalls, and also breaks with clone(), which does not unshare the TLS.*/
+inline _syscall0(pid_t, getpid)
 
 int os_getpid(void)
 {
diff -Nru a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c
--- a/arch/um/sys-i386/ptrace.c	2004-12-24 13:37:02 -08:00
+++ b/arch/um/sys-i386/ptrace.c	2004-12-24 13:37:02 -08:00
@@ -7,6 +7,7 @@
 #include "asm/elf.h"
 #include "asm/ptrace.h"
 #include "asm/uaccess.h"
+#include "asm/unistd.h"
 #include "ptrace_user.h"
 #include "sysdep/sigcontext.h"
 #include "sysdep/sc.h"
@@ -23,11 +24,12 @@
 
 	n = copy_from_user(&instr, (void *) addr, sizeof(instr));
 	if(n){
-		printk("is_syscall : failed to read instruction from 0x%lu\n", 
+		printk("is_syscall : failed to read instruction from 0x%lx\n",
 		       addr);
 		return(0);
 	}
-	return(instr == 0x80cd);
+	/* int 0x80 or sysenter */
+	return((instr == 0x80cd) || (instr == 0x340f));
 }
 
 /* determines which flags the user has access to. */
diff -Nru a/arch/um/sys-i386/sysrq.c b/arch/um/sys-i386/sysrq.c
--- a/arch/um/sys-i386/sysrq.c	2004-12-24 13:36:17 -08:00
+++ b/arch/um/sys-i386/sysrq.c	2004-12-24 13:36:17 -08:00
@@ -1,3 +1,8 @@
+/*
+ * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Licensed under the GPL
+ */
+
 #include "linux/kernel.h"
 #include "linux/smp.h"
 #include "linux/sched.h"
diff -Nru a/arch/v850/kernel/fpga85e2c.c b/arch/v850/kernel/fpga85e2c.c
--- a/arch/v850/kernel/fpga85e2c.c	2004-12-24 13:37:19 -08:00
+++ b/arch/v850/kernel/fpga85e2c.c	2004-12-24 13:37:19 -08:00
@@ -20,11 +20,11 @@
 #include <linux/swap.h>
 #include <linux/bootmem.h>
 #include <linux/irq.h>
+#include <linux/bitops.h>
 
 #include <asm/atomic.h>
 #include <asm/page.h>
 #include <asm/machdep.h>
-#include <asm/bitops.h>
 
 #include "mach.h"
 
diff -Nru a/arch/v850/kernel/memcons.c b/arch/v850/kernel/memcons.c
--- a/arch/v850/kernel/memcons.c	2004-12-24 13:37:29 -08:00
+++ b/arch/v850/kernel/memcons.c	2004-12-24 13:37:29 -08:00
@@ -88,8 +88,7 @@
 	return 0;
 }
 
-int memcons_tty_write (struct tty_struct *tty, int from_user,
-		       const unsigned char *buf, int len)
+int memcons_tty_write (struct tty_struct *tty, const unsigned char *buf, int len)
 {
 	return write (buf, len);
 }
diff -Nru a/arch/v850/kernel/ptrace.c b/arch/v850/kernel/ptrace.c
--- a/arch/v850/kernel/ptrace.c	2004-12-24 13:36:55 -08:00
+++ b/arch/v850/kernel/ptrace.c	2004-12-24 13:36:55 -08:00
@@ -1,8 +1,8 @@
 /*
  * arch/v850/kernel/ptrace.c -- `ptrace' system call
  *
- *  Copyright (C) 2002,03  NEC Electronics Corporation
- *  Copyright (C) 2002,03  Miles Bader <miles@gnu.org>
+ *  Copyright (C) 2002,03,04  NEC Electronics Corporation
+ *  Copyright (C) 2002,03,04  Miles Bader <miles@gnu.org>
  *
  * Derived from arch/mips/kernel/ptrace.c:
  *
@@ -147,8 +147,8 @@
 		rval = ptrace_attach(child);
 		goto out_tsk;
 	}
-	ret = ptrace_check_attach(child, request == PTRACE_KILL);
-	if (ret < 0)
+	rval = ptrace_check_attach(child, request == PTRACE_KILL);
+	if (rval < 0)
 		goto out_tsk;
 
 	switch (request) {
@@ -232,7 +232,7 @@
 	 */
 	case PTRACE_KILL:
 		rval = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		child->exit_code = SIGKILL;
 		wake_up_process(child);
diff -Nru a/arch/v850/kernel/rte_mb_a_pci.c b/arch/v850/kernel/rte_mb_a_pci.c
--- a/arch/v850/kernel/rte_mb_a_pci.c	2004-12-24 13:36:31 -08:00
+++ b/arch/v850/kernel/rte_mb_a_pci.c	2004-12-24 13:36:31 -08:00
@@ -254,7 +254,7 @@
 	struct pci_dev *dev = NULL;
 	struct resource *r;
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		unsigned di_num;
 		unsigned class = dev->class >> 8;
 
diff -Nru a/arch/v850/kernel/signal.c b/arch/v850/kernel/signal.c
--- a/arch/v850/kernel/signal.c	2004-12-24 13:37:32 -08:00
+++ b/arch/v850/kernel/signal.c	2004-12-24 13:37:32 -08:00
@@ -427,11 +427,9 @@
  */	
 
 static void
-handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset,
-	struct pt_regs * regs)
+handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
+	      sigset_t *oldset,	struct pt_regs * regs)
 {
-	struct k_sigaction *ka = &current->sighand->action[sig-1];
-
 	/* Are we from a system call? */
 	if (PT_REGS_SYSCALL (regs)) {
 		/* If so, check system call restarting.. */
@@ -464,9 +462,6 @@
 	else
 		setup_frame(sig, ka, oldset, regs);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
-
 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
@@ -489,6 +484,7 @@
 {
 	siginfo_t info;
 	int signr;
+	struct k_sigaction ka;
 
 	/*
 	 * We want the common case to go fast, which
@@ -502,10 +498,10 @@
 	if (!oldset)
 		oldset = &current->blocked;
 
-	signr = get_signal_to_deliver(&info, regs, NULL);
+	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
 	if (signr > 0) {
 		/* Whee!  Actually deliver the signal.  */
-		handle_signal(signr, &info, oldset, regs);
+		handle_signal(signr, &info, &ka, oldset, regs);
 		return 1;
 	}
 
diff -Nru a/arch/v850/kernel/simcons.c b/arch/v850/kernel/simcons.c
--- a/arch/v850/kernel/simcons.c	2004-12-24 13:37:18 -08:00
+++ b/arch/v850/kernel/simcons.c	2004-12-24 13:37:18 -08:00
@@ -59,7 +59,7 @@
 	return 0;
 }
 
-int simcons_tty_write (struct tty_struct *tty, int from_user,
+int simcons_tty_write (struct tty_struct *tty,
 		       const unsigned char *buf, int count)
 {
 	return V850_SIM_SYSCALL (write, 1, buf, count);
diff -Nru a/arch/v850/kernel/time.c b/arch/v850/kernel/time.c
--- a/arch/v850/kernel/time.c	2004-12-24 13:37:00 -08:00
+++ b/arch/v850/kernel/time.c	2004-12-24 13:37:00 -08:00
@@ -56,6 +56,9 @@
 	  mach_tick ();
 
 	do_timer (regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	profile_tick(CPU_PROFILING, regs);
 #if 0
 	/*
diff -Nru a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S
--- a/arch/v850/kernel/vmlinux.lds.S	2004-12-24 13:37:00 -08:00
+++ b/arch/v850/kernel/vmlinux.lds.S	2004-12-24 13:37:00 -08:00
@@ -60,6 +60,11 @@
 		___start___kcrctab_gpl = .;				      \
 			*(__kcrctab_gpl)				      \
 		___stop___kcrctab_gpl = .;				      \
+		/* Built-in module parameters */			      \
+		___start___param = .;					      \
+		*(__param)						      \
+		___stop___param = .;
+
 
 /* Kernel text segment, and some constant data areas.  */
 #define TEXT_CONTENTS							      \
diff -Nru a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
--- a/arch/x86_64/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/arch/x86_64/Kconfig	2004-12-24 13:37:18 -08:00
@@ -72,7 +72,8 @@
 	  If unsure, say Y.
 
 config HPET_EMULATE_RTC
-	def_bool HPET_TIMER && RTC=y
+	bool "Provide RTC interrupt"
+	depends on HPET_TIMER && RTC=y
 
 config GENERIC_ISA_DMA
 	bool
@@ -255,6 +256,7 @@
 
 config K8_NUMA
        bool "K8 NUMA support"
+       select NUMA
        depends on SMP
        help
 	  Enable NUMA (Non Unified Memory Architecture) support for
@@ -264,15 +266,23 @@
 	  This code is recommended on all multiprocessor Opteron systems
 	  and normally doesn't hurt on others.
 
+config NUMA_EMU
+	bool "NUMA emulation support"
+	select NUMA
+	depends on SMP
+	help
+	  Enable NUMA emulation. A flat machine will be split
+	  into virtual nodes when booted with "numa=fake=N", where N is the
+	  number of nodes. This is only useful for debugging.
+
 config DISCONTIGMEM
        bool
-       depends on K8_NUMA
+       depends on NUMA
        default y
 
 config NUMA
        bool
-       depends on K8_NUMA
-       default y
+       default n
 
 config HAVE_DEC_LOCK
 	bool
@@ -296,6 +306,7 @@
 
 config GART_IOMMU
 	bool "IOMMU support"
+	depends on PCI
 	help
 	  Support the K8 IOMMU. Needed to run systems with more than 4GB of memory
 	  properly with 32-bit PCI devices that do not support DAC (Double Address
@@ -329,6 +340,16 @@
 
 endmenu
 
+#
+# Use the generic interrupt handling code in kernel/irq/:
+#
+config GENERIC_HARDIRQS
+	bool
+	default y
+
+config GENERIC_IRQ_PROBE
+	bool
+	default y
 
 menu "Power management options"
 
diff -Nru a/arch/x86_64/Kconfig.debug b/arch/x86_64/Kconfig.debug
--- a/arch/x86_64/Kconfig.debug	2004-12-24 13:36:19 -08:00
+++ b/arch/x86_64/Kconfig.debug	2004-12-24 13:36:19 -08:00
@@ -18,18 +18,6 @@
 	  Fill __init and __initdata at the end of boot. This helps debugging
 	  illegal uses of __init and __initdata after initialization.
 
-config SCHEDSTATS
-	bool "Collect scheduler statistics"
-	depends on DEBUG_KERNEL && PROC_FS
-	help
-	  If you say Y here, additional code will be inserted into the
-	  scheduler and related routines to collect statistics about
-	  scheduler behavior and provide them in /proc/schedstat.  These
-	  stats may be useful for both tuning and debugging the scheduler
-	  If you aren't debugging the scheduler or trying to tune a specific
-	  application, you can say N to avoid the very slight overhead
-	  this adds.
-
 config IOMMU_DEBUG
        depends on GART_IOMMU && DEBUG_KERNEL
        bool "Enable IOMMU debugging"
@@ -44,6 +32,16 @@
 	 be set more finegrained using the iommu= command line
 	 options. See Documentation/x86_64/boot-options.txt for more
 	 details.
+
+config KPROBES
+	bool "Kprobes"
+	depends on DEBUG_KERNEL
+	help
+	  Kprobes allows you to trap at almost any kernel address and
+	  execute a callback function.  register_kprobe() establishes
+	  a probepoint and specifies the callback.  Kprobes is useful
+	  for kernel debugging, non-intrusive instrumentation and testing.
+	  If in doubt, say "N".
 
 config IOMMU_LEAK
        bool "IOMMU leak tracing"
diff -Nru a/arch/x86_64/boot/Makefile b/arch/x86_64/boot/Makefile
--- a/arch/x86_64/boot/Makefile	2004-12-24 13:36:47 -08:00
+++ b/arch/x86_64/boot/Makefile	2004-12-24 13:36:47 -08:00
@@ -31,6 +31,7 @@
 EXTRA_CFLAGS := -m32
 
 hostprogs-y	:= tools/build
+HOST_EXTRACFLAGS += $(LINUXINCLUDE)
 subdir-		:= compressed/	#Let make clean descend in compressed/
 # ---------------------------------------------------------------------------
 
diff -Nru a/arch/x86_64/boot/compressed/Makefile b/arch/x86_64/boot/compressed/Makefile
--- a/arch/x86_64/boot/compressed/Makefile	2004-12-24 13:36:47 -08:00
+++ b/arch/x86_64/boot/compressed/Makefile	2004-12-24 13:36:47 -08:00
@@ -11,7 +11,7 @@
 
 # cannot use EXTRA_CFLAGS because base CFLAGS contains -mkernel which conflicts with
 # -m32
-CFLAGS := -m32 -D__KERNEL__ -Iinclude -O2  
+CFLAGS := -m32 -D__KERNEL__ -Iinclude -O2  -fno-strict-aliasing
 LDFLAGS := -m elf_i386
 
 LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32 -m elf_i386
diff -Nru a/arch/x86_64/boot/video.S b/arch/x86_64/boot/video.S
--- a/arch/x86_64/boot/video.S	2004-12-24 13:36:56 -08:00
+++ b/arch/x86_64/boot/video.S	2004-12-24 13:36:56 -08:00
@@ -1936,7 +1936,7 @@
 
 	movl	$0x13131313, %eax		# memset block with 0x13
 	movw    $32, %cx
-	movw	$0x440, %di
+	movw	$0x140, %di
 	cld
 	rep
 	stosl
@@ -1945,7 +1945,7 @@
 	movw	$0x01, %bx
 	movw	$0x00, %cx
 	movw    $0x01, %dx
-	movw	$0x440, %di
+	movw	$0x140, %di
 	int	$0x10
 
 	popw	%di				# restore all registers
diff -Nru a/arch/x86_64/defconfig b/arch/x86_64/defconfig
--- a/arch/x86_64/defconfig	2004-12-24 13:37:02 -08:00
+++ b/arch/x86_64/defconfig	2004-12-24 13:37:02 -08:00
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-rc1-bk19
-# Sun Sep 12 23:13:23 2004
+# Linux kernel version: 2.6.10-rc1-bk6
+# Thu Oct 28 00:07:32 2004
 #
 CONFIG_X86_64=y
 CONFIG_64BIT=y
@@ -13,12 +13,14 @@
 CONFIG_HPET_TIMER=y
 CONFIG_HPET_EMULATE_RTC=y
 CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
 
 #
 # General setup
@@ -32,6 +34,7 @@
 # CONFIG_AUDIT is not set
 CONFIG_LOG_BUF_SHIFT=18
 # CONFIG_HOTPLUG is not set
+CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_EMBEDDED is not set
@@ -40,10 +43,6 @@
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
 # CONFIG_TINY_SHMEM is not set
@@ -56,6 +55,7 @@
 CONFIG_MODULE_FORCE_UNLOAD=y
 CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
 # CONFIG_KMOD is not set
 CONFIG_STOP_MACHINE=y
 
@@ -80,6 +80,7 @@
 # CONFIG_PREEMPT is not set
 CONFIG_SCHED_SMT=y
 CONFIG_K8_NUMA=y
+# CONFIG_NUMA_EMU is not set
 CONFIG_DISCONTIGMEM=y
 CONFIG_NUMA=y
 CONFIG_HAVE_DEC_LOCK=y
@@ -87,12 +88,16 @@
 CONFIG_GART_IOMMU=y
 CONFIG_SWIOTLB=y
 CONFIG_X86_MCE=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
 
 #
 # Power management options
 #
 CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
 CONFIG_SOFTWARE_SUSPEND=y
+CONFIG_PM_STD_PARTITION=""
 
 #
 # ACPI (Advanced Configuration and Power Interface) Support
@@ -110,6 +115,7 @@
 CONFIG_ACPI_THERMAL=y
 # CONFIG_ACPI_ASUS is not set
 CONFIG_ACPI_TOSHIBA=y
+CONFIG_ACPI_BLACKLIST_YEAR=2001
 CONFIG_ACPI_DEBUG=y
 CONFIG_ACPI_BUS=y
 CONFIG_ACPI_EC=y
@@ -185,7 +191,17 @@
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
 CONFIG_LBD=y
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -205,7 +221,6 @@
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_BLK_DEV_IDESCSI is not set
 # CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
 
 #
 # IDE chipset support/bugfixes
@@ -222,7 +237,6 @@
 # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
 CONFIG_IDEDMA_PCI_AUTO=y
 # CONFIG_IDEDMA_ONLYDISK is not set
-CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_AEC62XX is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 CONFIG_BLK_DEV_AMD74XX=y
@@ -298,6 +312,7 @@
 # CONFIG_MEGARAID_NEWGEN is not set
 # CONFIG_MEGARAID_LEGACY is not set
 CONFIG_SCSI_SATA=y
+# CONFIG_SCSI_SATA_AHCI is not set
 # CONFIG_SCSI_SATA_SVW is not set
 CONFIG_SCSI_ATA_PIIX=y
 # CONFIG_SCSI_SATA_NV is not set
@@ -305,6 +320,7 @@
 # CONFIG_SCSI_SATA_SX4 is not set
 # CONFIG_SCSI_SATA_SIL is not set
 # CONFIG_SCSI_SATA_SIS is not set
+# CONFIG_SCSI_SATA_ULI is not set
 CONFIG_SCSI_SATA_VIA=y
 # CONFIG_SCSI_SATA_VITESSE is not set
 # CONFIG_SCSI_BUSLOGIC is not set
@@ -314,12 +330,14 @@
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
 # CONFIG_SCSI_GDTH is not set
 # CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_SYM53C8XX_2 is not set
 # CONFIG_SCSI_IPR 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_QLOGIC_1280_1040 is not set
 CONFIG_SCSI_QLA2XXX=y
 # CONFIG_SCSI_QLA21XX is not set
 # CONFIG_SCSI_QLA22XX is not set
@@ -404,7 +422,6 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
 # QoS and/or fair queueing
@@ -471,7 +488,6 @@
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -485,6 +501,7 @@
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 CONFIG_TIGON3=y
 
 #
@@ -552,6 +569,7 @@
 # CONFIG_SERIO_SERPORT is not set
 # CONFIG_SERIO_CT82C710 is not set
 # CONFIG_SERIO_PCIPS2 is not set
+# CONFIG_SERIO_RAW is not set
 
 #
 # Input Device Drivers
@@ -714,6 +732,8 @@
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_SUSPEND is not set
 # CONFIG_USB_OTG is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 
 #
 # USB Host Controller Drivers
@@ -722,7 +742,7 @@
 # CONFIG_USB_EHCI_SPLIT_ISO is not set
 # CONFIG_USB_EHCI_ROOT_HUB_TT is not set
 CONFIG_USB_OHCI_HCD=y
-# CONFIG_USB_UHCI_HCD is not set
+CONFIG_USB_UHCI_HCD=y
 
 #
 # USB Device Class drivers
@@ -745,7 +765,7 @@
 # CONFIG_USB_STORAGE_JUMPSHOT is not set
 
 #
-# USB Human Interface Devices (HID)
+# USB Input Devices
 #
 CONFIG_USB_HID=y
 CONFIG_USB_HIDINPUT=y
@@ -806,10 +826,15 @@
 # CONFIG_USB_LCD is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
 # CONFIG_USB_PHIDGETSERVO is not set
 # CONFIG_USB_TEST is not set
 
 #
+# USB ATM/DSL drivers
+#
+
+#
 # USB Gadget Support
 #
 # CONFIG_USB_GADGET is not set
@@ -872,6 +897,7 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 CONFIG_HUGETLBFS=y
 CONFIG_HUGETLB_PAGE=y
 CONFIG_RAMFS=y
@@ -938,18 +964,19 @@
 #
 CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
 # CONFIG_DEBUG_INFO is not set
-# CONFIG_FRAME_POINTER is not set
-# CONFIG_INIT_DEBUG is not set
-# CONFIG_SCHEDSTATS is not set
+CONFIG_INIT_DEBUG=y
 # CONFIG_IOMMU_DEBUG is not set
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
diff -Nru a/arch/x86_64/ia32/ia32_aout.c b/arch/x86_64/ia32/ia32_aout.c
--- a/arch/x86_64/ia32/ia32_aout.c	2004-12-24 13:37:31 -08:00
+++ b/arch/x86_64/ia32/ia32_aout.c	2004-12-24 13:37:31 -08:00
@@ -31,6 +31,7 @@
 #include <asm/pgalloc.h>
 #include <asm/cacheflush.h>
 #include <asm/user32.h>
+#include <asm/ia32.h>
 
 #undef WARN_OLD
 #undef CORE_DUMP /* probably broken */
@@ -168,12 +169,12 @@
 /* If the size of the dump file exceeds the rlimit, then see what would happen
    if we wrote the stack, but not the data area.  */
 	if ((dump.u_dsize+dump.u_ssize+1) * PAGE_SIZE >
-	    current->rlim[RLIMIT_CORE].rlim_cur)
+	    current->signal->rlim[RLIMIT_CORE].rlim_cur)
 		dump.u_dsize = 0;
 
 /* Make sure we have enough room to write the stack and data areas. */
 	if ((dump.u_ssize+1) * PAGE_SIZE >
-	    current->rlim[RLIMIT_CORE].rlim_cur)
+	    current->signal->rlim[RLIMIT_CORE].rlim_cur)
 		dump.u_ssize = 0;
 
 /* make sure we actually have a data and stack area to dump */
@@ -281,7 +282,7 @@
 	 * size limits imposed on them by creating programs with large
 	 * arrays in the data or bss.
 	 */
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim >= RLIM_INFINITY)
 		rlim = ~0;
 	if (ex.a_data + ex.a_bss > rlim)
diff -Nru a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
--- a/arch/x86_64/ia32/ia32_binfmt.c	2004-12-24 13:36:17 -08:00
+++ b/arch/x86_64/ia32/ia32_binfmt.c	2004-12-24 13:36:17 -08:00
@@ -182,6 +182,7 @@
 #define user user32
 
 #define __ASM_X86_64_ELF_H 1
+#define elf_read_implies_exec(ex, have_pt_gnu_stack)	(!(have_pt_gnu_stack))
 //#include <asm/ia32.h>
 #include <linux/elf.h>
 
@@ -333,7 +334,7 @@
 	unsigned long stack_base;
 	struct vm_area_struct *mpnt;
 	struct mm_struct *mm = current->mm;
-	int i;
+	int i, ret;
 
 	stack_base = IA32_STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE;
 	mm->arg_start = bprm->p + stack_base;
@@ -360,14 +361,18 @@
 		mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p;
 		mpnt->vm_end = IA32_STACK_TOP;
 		if (executable_stack == EXSTACK_ENABLE_X)
-			mpnt->vm_flags = vm_stack_flags32 |  VM_EXEC;
+			mpnt->vm_flags = VM_STACK_FLAGS |  VM_EXEC;
 		else if (executable_stack == EXSTACK_DISABLE_X)
-			mpnt->vm_flags = vm_stack_flags32 & ~VM_EXEC;
+			mpnt->vm_flags = VM_STACK_FLAGS & ~VM_EXEC;
 		else
-			mpnt->vm_flags = vm_stack_flags32;
+			mpnt->vm_flags = VM_STACK_FLAGS;
  		mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC) ? 
  			PAGE_COPY_EXEC : PAGE_COPY;
-		insert_vm_struct(mm, mpnt);
+		if ((ret = insert_vm_struct(mm, mpnt))) {
+			up_write(&mm->mmap_sem);
+			kmem_cache_free(vm_area_cachep, mpnt);
+			return ret;
+		}
 		mm->stack_vm = mm->total_vm = vma_pages(mpnt);
 	} 
 
@@ -389,9 +394,6 @@
 {
 	unsigned long map_addr;
 	struct task_struct *me = current; 
-
-	if (prot & PROT_READ) 
-		prot |= vm_force_exec32;
 
 	down_write(&me->mm->mmap_sem);
 	map_addr = do_mmap(filep, ELF_PAGESTART(addr),
diff -Nru a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
--- a/arch/x86_64/ia32/ia32entry.S	2004-12-24 13:36:48 -08:00
+++ b/arch/x86_64/ia32/ia32entry.S	2004-12-24 13:36:48 -08:00
@@ -391,7 +391,7 @@
 	.quad sys_uselib
 	.quad sys_swapon
 	.quad sys_reboot
-	.quad sys32_oldreaddir
+	.quad compat_sys_old_readdir
 	.quad sys32_mmap		/* 90 */
 	.quad sys_munmap
 	.quad sys_truncate
@@ -433,7 +433,7 @@
 	.quad sys_init_module
 	.quad sys_delete_module
 	.quad quiet_ni_syscall		/* 130  get_kernel_syms */
-	.quad sys32_quotactl		/* quotactl */ 
+	.quad sys_quotactl
 	.quad sys_getpgid
 	.quad sys_fchdir
 	.quad quiet_ni_syscall	/* bdflush */
@@ -443,7 +443,7 @@
 	.quad sys_setfsuid16
 	.quad sys_setfsgid16
 	.quad sys_llseek		/* 140 */
-	.quad sys32_getdents
+	.quad compat_sys_getdents
 	.quad compat_sys_select
 	.quad sys_flock
 	.quad sys_msync
@@ -522,7 +522,7 @@
 	.quad sys_pivot_root
 	.quad sys_mincore
 	.quad sys_madvise
-	.quad sys_getdents64	/* 220 getdents64 */ 
+	.quad compat_sys_getdents64	/* 220 getdents64 */
 	.quad compat_sys_fcntl64	
 	.quad quiet_ni_syscall		/* tux */
 	.quad quiet_ni_syscall    	/* security */
@@ -547,10 +547,10 @@
 	.quad compat_sys_sched_getaffinity
 	.quad sys32_set_thread_area
 	.quad sys32_get_thread_area
-	.quad sys32_io_setup		/* 245 */
+	.quad compat_sys_io_setup	/* 245 */
 	.quad sys_io_destroy
-	.quad sys32_io_getevents
-	.quad sys32_io_submit
+	.quad compat_sys_io_getevents
+	.quad compat_sys_io_submit
 	.quad sys_io_cancel
 	.quad sys_fadvise64		/* 250 */
 	.quad quiet_ni_syscall 	/* free_huge_pages */
@@ -562,22 +562,22 @@
 	.quad sys_remap_file_pages
 	.quad sys_set_tid_address
 	.quad sys32_timer_create
-	.quad compat_timer_settime	/* 260 */
-	.quad compat_timer_gettime
+	.quad compat_sys_timer_settime	/* 260 */
+	.quad compat_sys_timer_gettime
 	.quad sys_timer_getoverrun
 	.quad sys_timer_delete
-	.quad compat_clock_settime
-	.quad compat_clock_gettime	/* 265 */
-	.quad compat_clock_getres
-	.quad compat_clock_nanosleep
-	.quad compat_statfs64
-	.quad compat_fstatfs64
+	.quad compat_sys_clock_settime
+	.quad compat_sys_clock_gettime	/* 265 */
+	.quad compat_sys_clock_getres
+	.quad compat_sys_clock_nanosleep
+	.quad compat_sys_statfs64
+	.quad compat_sys_fstatfs64
 	.quad sys_tgkill		/* 270 */
 	.quad compat_sys_utimes
 	.quad sys32_fadvise64_64
 	.quad quiet_ni_syscall	/* sys_vserver */
 	.quad sys_mbind
-	.quad compat_get_mempolicy	/* 275 */
+	.quad compat_sys_get_mempolicy	/* 275 */
 	.quad sys_set_mempolicy
 	.quad compat_sys_mq_open
 	.quad sys_mq_unlink
diff -Nru a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
--- a/arch/x86_64/ia32/ptrace32.c	2004-12-24 13:36:31 -08:00
+++ b/arch/x86_64/ia32/ptrace32.c	2004-12-24 13:36:31 -08:00
@@ -109,7 +109,8 @@
 
 	case offsetof(struct user32, u_debugreg[7]):
 		val &= ~DR_CONTROL_RESERVED;
-		/* You are not expected to understand this ... I don't neither. */
+		/* See arch/i386/kernel/ptrace.c for an explanation of
+		 * this awkward check.*/
 		for(i=0; i<4; i++)
 			if ((0x5454 >> ((val >> (16 + 4*i)) & 0xf)) & 1)
 			       return -EIO;
diff -Nru a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
--- a/arch/x86_64/ia32/sys_ia32.c	2004-12-24 13:36:48 -08:00
+++ b/arch/x86_64/ia32/sys_ia32.c	2004-12-24 13:36:48 -08:00
@@ -218,9 +218,6 @@
 			return -EBADF;
 	}
 	
-	if (a.prot & PROT_READ) 
-		a.prot |= vm_force_exec32;
-
 	mm = current->mm; 
 	down_write(&mm->mmap_sem); 
 	retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, a.offset>>PAGE_SHIFT);
@@ -235,8 +232,6 @@
 asmlinkage long 
 sys32_mprotect(unsigned long start, size_t len, unsigned long prot)
 {
-	if (prot & PROT_READ) 
-		prot |= vm_force_exec32;
 	return sys_mprotect(start,len,prot); 
 }
 
@@ -478,134 +473,6 @@
 	return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
 }
 
-struct linux32_dirent {
-	u32	d_ino;
-	u32	d_off;
-	u16	d_reclen;
-	char	d_name[1];
-};
-
-struct old_linux32_dirent {
-	u32	d_ino;
-	u32	d_offset;
-	u16	d_namlen;
-	char	d_name[1];
-};
-
-struct getdents32_callback {
-	struct linux32_dirent __user * current_dir;
-	struct linux32_dirent __user * previous;
-	int count;
-	int error;
-};
-
-struct readdir32_callback {
-	struct old_linux32_dirent __user * dirent;
-	int count;
-};
-
-static int
-filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino,
-	   unsigned int d_type)
-{
-	struct linux32_dirent __user * dirent;
-	struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
-	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 2, 4);
-
-	buf->error = -EINVAL;	/* only used if we fail.. */
-	if (reclen > buf->count)
-		return -EINVAL;
-	dirent = buf->previous;
-	if (dirent)
-		put_user(offset, &dirent->d_off);
-	dirent = buf->current_dir;
-	buf->previous = dirent;
-	put_user(ino, &dirent->d_ino);
-	put_user(reclen, &dirent->d_reclen);
-	copy_to_user(dirent->d_name, name, namlen);
-	put_user(0, dirent->d_name + namlen);
-	put_user(d_type, (char __user *)dirent + reclen - 1); 
-	dirent = ((void __user *)dirent) + reclen;
-	buf->current_dir = dirent;
-	buf->count -= reclen;
-	return 0;
-}
-
-asmlinkage long
-sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count)
-{
-	struct file * file;
-	struct linux32_dirent __user * lastdirent;
-	struct getdents32_callback buf;
-	int error;
-
-	error = -EBADF;
-	file = fget(fd);
-	if (!file)
-		goto out;
-
-	buf.current_dir = (struct linux32_dirent __user *) dirent;
-	buf.previous = NULL;
-	buf.count = count;
-	buf.error = 0;
-
-	error = vfs_readdir(file, filldir32, &buf);
-	if (error < 0)
-		goto out_putf;
-	error = buf.error;
-	lastdirent = buf.previous;
-	if (lastdirent) {
-		put_user(file->f_pos, &lastdirent->d_off);
-		error = count - buf.count;
-	}
-
-out_putf:
-	fput(file);
-out:
-	return error;
-}
-
-static int
-fillonedir32 (void * __buf, const char * name, int namlen, loff_t offset, ino_t ino, unsigned d_type)
-{
-	struct readdir32_callback * buf = (struct readdir32_callback *) __buf;
-	struct old_linux32_dirent __user * dirent;
-
-	if (buf->count)
-		return -EINVAL;
-	buf->count++;
-	dirent = buf->dirent;
-	put_user(ino, &dirent->d_ino);
-	put_user(offset, &dirent->d_offset);
-	put_user(namlen, &dirent->d_namlen);
-	copy_to_user(dirent->d_name, name, namlen);
-	put_user(0, dirent->d_name + namlen);
-	return 0;
-}
-
-asmlinkage long
-sys32_oldreaddir (unsigned int fd, void __user * dirent, unsigned int count)
-{
-	int error;
-	struct file * file;
-	struct readdir32_callback buf;
-
-	error = -EBADF;
-	file = fget(fd);
-	if (!file)
-		goto out;
-
-	buf.count = 0;
-	buf.dirent = dirent;
-
-	error = vfs_readdir(file, fillonedir32, &buf);
-	if (error >= 0)
-		error = buf.count;
-	fput(file);
-out:
-	return error;
-}
-
 struct sel_arg_struct {
 	unsigned int n;
 	unsigned int inp;
@@ -658,11 +525,12 @@
 int sys32_ni_syscall(int call)
 { 
 	struct task_struct *me = current;
-	static char lastcomm[8];
-	if (strcmp(lastcomm, me->comm)) {
-	printk(KERN_INFO "IA32 syscall %d from %s not implemented\n", call,
-	       current->comm);
-		strcpy(lastcomm, me->comm); 
+	static char lastcomm[sizeof(me->comm)];
+
+	if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
+		printk(KERN_INFO "IA32 syscall %d from %s not implemented\n",
+		       call, me->comm);
+		strncpy(lastcomm, me->comm, sizeof(lastcomm));
 	} 
 	return -ENOSYS;	       
 } 
@@ -1044,9 +912,6 @@
 			return -EBADF;
 	}
 
-	if (prot & PROT_READ)
-		prot |= vm_force_exec32;
-
 	down_write(&mm->mmap_sem);
 	error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
 	up_write(&mm->mmap_sem);
@@ -1135,8 +1000,11 @@
 	if (IS_ERR(filename))
 		return error;
 	error = compat_do_execve(filename, argv, envp, regs);
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 	return error;
 }
@@ -1191,90 +1059,6 @@
 	return sys_kill(pid, sig);
 }
  
-
-long sys32_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
-{ 
-	long ret; 
-	aio_context_t ctx64;
-	mm_segment_t oldfs = get_fs(); 	
-	set_fs(KERNEL_DS); 
-	ret = sys_io_setup(nr_reqs, &ctx64); 
-	set_fs(oldfs); 
-	/* truncating is ok because it's a user address */
-	if (!ret) 
-		ret = put_user((u32)ctx64, ctx32p);
-	return ret;
-} 
-
-asmlinkage long sys32_io_submit(aio_context_t ctx_id, int nr,
-		   compat_uptr_t __user *iocbpp)
-{
-	struct kioctx *ctx;
-	long ret = 0;
-	int i;
-	
-	if (unlikely(nr < 0))
-		return -EINVAL;
-
-	if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp)))))
-		return -EFAULT;
-
-	ctx = lookup_ioctx(ctx_id);
-	if (unlikely(!ctx)) {
-		pr_debug("EINVAL: io_submit: invalid context id\n");
-		return -EINVAL; 
-	} 
-
-	for (i=0; i<nr; i++) {
-		compat_uptr_t p32;
-		struct iocb __user *user_iocb;
-		struct iocb tmp;
-
-		if (unlikely(__get_user(p32, iocbpp + i))) {
-			ret = -EFAULT;
-			break;
-		} 
-		user_iocb = compat_ptr(p32);
-
-		if (unlikely(copy_from_user(&tmp, user_iocb, sizeof(tmp)))) {
-			ret = -EFAULT;
-			break;
-		}
-
-		ret = io_submit_one(ctx, user_iocb, &tmp);
-		if (ret)
-			break;
-	}
-
-	put_ioctx(ctx);
-	return i ? i : ret;
-}
-
-
-asmlinkage long sys32_io_getevents(aio_context_t ctx_id,
-				 unsigned long min_nr,
-				 unsigned long nr,
-				 struct io_event __user *events,
-				 struct compat_timespec __user *timeout)
-{ 	
-	long ret;
-	mm_segment_t oldfs; 
-	struct timespec t;
-	/* Harden against bogus ptrace */
-	if (nr >= 0xffffffff || 
-	    !access_ok(VERIFY_WRITE, events, nr * sizeof(struct io_event)))
-		return -EFAULT;
-	if (timeout && get_compat_timespec(&t, timeout))
-		return -EFAULT; 
-	oldfs = get_fs();
-	set_fs(KERNEL_DS); 
-	ret = sys_io_getevents(ctx_id,min_nr,nr,events,timeout ? &t : NULL); 
-	set_fs(oldfs); 
-	if (!ret && timeout && put_compat_timespec(&t, timeout))
-		return -EFAULT; 		
-	return ret;
-} 
-
 asmlinkage long sys32_open(const char __user * filename, int flags, int mode)
 {
 	char * tmp;
@@ -1342,23 +1126,11 @@
 long sys32_vm86_warning(void)
 { 
 	struct task_struct *me = current;
-	static char lastcomm[8];
-	if (strcmp(lastcomm, me->comm)) {
+	static char lastcomm[sizeof(me->comm)];
+	if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
 		printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
 		       me->comm);
-		strcpy(lastcomm, me->comm); 
-	} 
-	return -ENOSYS;
-} 
-
-long sys32_quotactl(void)
-{ 
-	struct task_struct *me = current;
-	static char lastcomm[8];
-	if (strcmp(lastcomm, me->comm)) {
-		printk(KERN_INFO "%s: 32bit quotactl not supported on 64 bit kernel\n",
-		       me->comm);
-		strcpy(lastcomm, me->comm); 
+		strncpy(lastcomm, me->comm, sizeof(lastcomm));
 	} 
 	return -ENOSYS;
 } 
diff -Nru a/arch/x86_64/ia32/syscall32.c b/arch/x86_64/ia32/syscall32.c
--- a/arch/x86_64/ia32/syscall32.c	2004-12-24 13:37:00 -08:00
+++ b/arch/x86_64/ia32/syscall32.c	2004-12-24 13:37:00 -08:00
@@ -28,7 +28,7 @@
 extern int sysctl_vsyscall32;
 
 char *syscall32_page; 
-static int use_sysenter __initdata = -1;
+static int use_sysenter = -1;
 
 /*
  * Map the 32bit vsyscall page on demand.
diff -Nru a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
--- a/arch/x86_64/kernel/Makefile	2004-12-24 13:37:04 -08:00
+++ b/arch/x86_64/kernel/Makefile	2004-12-24 13:37:04 -08:00
@@ -5,11 +5,11 @@
 extra-y 	:= head.o head64.o init_task.o vmlinux.lds
 EXTRA_AFLAGS	:= -traditional
 obj-y	:= process.o semaphore.o signal.o entry.o traps.o irq.o \
-		ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_x86_64.o \
+		ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_x86_64.o \
 		x8664_ksyms.o i387.o syscall.o vsyscall.o \
-		setup64.o bootflag.o e820.o reboot.o warmreboot.o
-obj-y += mce.o
+		setup64.o bootflag.o e820.o reboot.o warmreboot.o quirks.o
 
+obj-$(CONFIG_X86_MCE)         += mce.o
 obj-$(CONFIG_MTRR)		+= ../../i386/kernel/cpu/mtrr/
 obj-$(CONFIG_ACPI_BOOT)		+= acpi/
 obj-$(CONFIG_X86_MSR)		+= msr.o
@@ -17,7 +17,8 @@
 obj-$(CONFIG_X86_CPUID)		+= cpuid.o
 obj-$(CONFIG_SMP)		+= smp.o smpboot.o trampoline.o
 obj-$(CONFIG_X86_LOCAL_APIC)	+= apic.o  nmi.o
-obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o mpparse.o
+obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o mpparse.o \
+		genapic.o genapic_cluster.o genapic_flat.o
 obj-$(CONFIG_PM)		+= suspend.o
 obj-$(CONFIG_SOFTWARE_SUSPEND)	+= suspend_asm.o
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
@@ -25,13 +26,17 @@
 obj-$(CONFIG_GART_IOMMU)	+= pci-gart.o aperture.o
 obj-$(CONFIG_DUMMY_IOMMU)	+= pci-nommu.o pci-dma.o
 obj-$(CONFIG_SWIOTLB)		+= swiotlb.o
+obj-$(CONFIG_KPROBES)		+= kprobes.o
 
 obj-$(CONFIG_MODULES)		+= module.o
 
 obj-y				+= topology.o
+obj-y				+= intel_cacheinfo.o
 
 bootflag-y			+= ../../i386/kernel/bootflag.o
 cpuid-$(subst m,y,$(CONFIG_X86_CPUID))  += ../../i386/kernel/cpuid.o
 topology-y                     += ../../i386/mach-default/topology.o
 swiotlb-$(CONFIG_SWIOTLB)      += ../../ia64/lib/swiotlb.o
 microcode-$(subst m,y,$(CONFIG_MICROCODE))  += ../../i386/kernel/microcode.o
+intel_cacheinfo-y		+= ../../i386/kernel/cpu/intel_cacheinfo.o
+quirks-y			+= ../../i386/kernel/quirks.o
diff -Nru a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
--- a/arch/x86_64/kernel/apic.c	2004-12-24 13:36:18 -08:00
+++ b/arch/x86_64/kernel/apic.c	2004-12-24 13:36:18 -08:00
@@ -32,6 +32,7 @@
 #include <asm/mtrr.h>
 #include <asm/mpspec.h>
 #include <asm/pgalloc.h>
+#include <asm/mach_apic.h>
 
 int apic_verbosity;
 
@@ -300,8 +301,7 @@
 	 * Double-check whether this APIC is really registered.
 	 * This is meaningless in clustered apic mode, so we skip it.
 	 */
-	if (!clustered_apic_mode &&
-		!physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
+	if (!apic_id_registered())
 		BUG();
 
 	/*
@@ -309,23 +309,7 @@
 	 * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
 	 * document number 292116).  So here it goes...
 	 */
-
-	if (!clustered_apic_mode) {
-		/*
-		 * In clustered apic mode, the firmware does this for us 
-		 * Put the APIC into flat delivery mode.
-		 * Must be "all ones" explicitly for 82489DX.
-		 */
-		apic_write_around(APIC_DFR, 0xffffffff);
-
-		/*
-		 * Set up the logical destination ID.
-		 */
-		value = apic_read(APIC_LDR);
-		value &= ~APIC_LDR_MASK;
-		value |= (1<<(smp_processor_id()+24));
-		apic_write_around(APIC_LDR, value);
-	}
+	init_apic_ldr();
 
 	/*
 	 * Set Task Priority to 'accept all'. We never change this
@@ -919,6 +903,54 @@
 	irq_enter();
 	smp_local_timer_interrupt(regs);
 	irq_exit();
+}
+
+/*
+ * oem_force_hpet_timer -- force HPET mode for some boxes.
+ *
+ * Thus far, the major user of this is IBM's Summit2 series:
+ *
+ * Clustered boxes may have unsynced TSC problems if they are
+ * multi-chassis. Use available data to take a good guess.
+ * If in doubt, go HPET.
+ */
+__init int oem_force_hpet_timer(void)
+{
+	int i, clusters, zeros;
+	unsigned id;
+	DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
+
+	bitmap_empty(clustermap, NUM_APIC_CLUSTERS);
+
+	for (i = 0; i < NR_CPUS; i++) {
+		id = bios_cpu_apicid[i];
+		if (id != BAD_APICID)
+			__set_bit(APIC_CLUSTERID(id), clustermap);
+	}
+
+	/* Problem:  Partially populated chassis may not have CPUs in some of
+	 * the APIC clusters they have been allocated.  Only present CPUs have
+	 * bios_cpu_apicid entries, thus causing zeroes in the bitmap.  Since
+	 * clusters are allocated sequentially, count zeros only if they are
+	 * bounded by ones.
+	 */
+	clusters = 0;
+	zeros = 0;
+	for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
+		if (test_bit(i, clustermap)) {
+			clusters += 1 + zeros;
+			zeros = 0;
+		} else
+			++zeros;
+	}
+
+	/*
+	 * If clusters > 2, then should be multi-chassis.  Return 1 for HPET.
+	 * Else return 0 to use TSC.
+	 * May have to revisit this when multi-core + hyperthreaded CPUs come
+	 * out, but AFAIK this will work even for them.
+	 */
+	return (clusters > 2);
 }
 
 /*
diff -Nru a/arch/x86_64/kernel/cpufreq/Kconfig b/arch/x86_64/kernel/cpufreq/Kconfig
--- a/arch/x86_64/kernel/cpufreq/Kconfig	2004-12-24 13:37:29 -08:00
+++ b/arch/x86_64/kernel/cpufreq/Kconfig	2004-12-24 13:37:29 -08:00
@@ -4,18 +4,6 @@
 
 menu "CPU Frequency scaling"
 
-config CPU_FREQ
-	bool "CPU Frequency scaling"
-	help
-	  Clock scaling allows you to change the clock speed of CPUs on the
-	  fly. This is a nice method to save battery power on notebooks,
-	  because the lower the clock speed, the less power the CPU consumes.
-
-	  For more information, take a look at <file:Documentation/cpu-freq/>
-	  or at <http://www.codemonkey.org.uk/projects/cpufreq/>
-
-	  If in doubt, say N.
-
 source "drivers/cpufreq/Kconfig"
 
 config CPU_FREQ_TABLE
@@ -48,7 +36,7 @@
 
 config X86_SPEEDSTEP_CENTRINO
 	tristate "Intel Enhanced SpeedStep"
-	depends on CPU_FREQ_TABLE
+	depends on CPU_FREQ_TABLE && ACPI_PROCESSOR
 	help
 	  This adds the CPUFreq driver for Enhanced SpeedStep enabled
 	  mobile CPUs.  This means Intel Pentium M (Centrino) CPUs
@@ -58,21 +46,11 @@
 
 	  If in doubt, say N.
 
-config X86_SPEEDSTEP_CENTRINO_TABLE
+config X86_SPEEDSTEP_CENTRINO_ACPI
 	bool
 	depends on X86_SPEEDSTEP_CENTRINO
 	default y
 
-config X86_SPEEDSTEP_CENTRINO_ACPI
-	bool "Use ACPI tables to decode valid frequency/voltage pairs (EXPERIMENTAL)"
-	depends on EXPERIMENTAL
-	depends on ((X86_SPEEDSTEP_CENTRINO = "m" && ACPI_PROCESSOR) || (X86_SPEEDSTEP_CENTRINO = "y" && ACPI_PROCESSOR = "y"))
-	help
-	  Use primarily the information provided in the BIOS ACPI tables
-	  to determine valid CPU frequency and voltage pairings.
-
-	  If in doubt, say Y.
-
 config X86_ACPI_CPUFREQ
 	tristate "ACPI Processor P-States driver"
 	depends on CPU_FREQ_TABLE && ACPI_PROCESSOR
@@ -84,15 +62,43 @@
 
 	  If in doubt, say N.
 
+comment "shared options"
+	depends on CPU_FREQ
+
 config X86_ACPI_CPUFREQ_PROC_INTF
         bool "/proc/acpi/processor/../performance interface (deprecated)"
-	depends on X86_ACPI_CPUFREQ && PROC_FS
+	depends on PROC_FS
+	depends on X86_ACPI_CPUFREQ || X86_SPEEDSTEP_CENTRINO_ACPI || X86_POWERNOW_K8_ACPI
 	help
 	  This enables the deprecated /proc/acpi/processor/../performance
 	  interface. While it is helpful for debugging, the generic,
 	  cross-architecture cpufreq interfaces should be used.
 
 	  If in doubt, say N.
+
+config X86_P4_CLOCKMOD
+	tristate "Intel Pentium 4 clock modulation"
+	depends on CPU_FREQ_TABLE && EMBEDDED
+	help
+	  This adds the clock modulation driver for Intel Pentium 4 / XEON
+	  processors.  When enabled it will lower CPU temperature by skipping
+	  clocks.
+
+	  This driver should be only used in exceptional
+	  circumstances when very low power is needed because it causes severe
+	  slowdowns and noticeable latencies.  Normally Speedstep should be used
+	  instead.
+
+	  For details, take a look at <file:Documentation/cpu-freq/>.
+
+	  Unless you are absolutely sure say N.
+
+
+config X86_SPEEDSTEP_LIB
+        tristate
+        depends on (X86_P4_CLOCKMOD)
+        default (X86_P4_CLOCKMOD)
+
 
 endmenu
 
diff -Nru a/arch/x86_64/kernel/cpufreq/Makefile b/arch/x86_64/kernel/cpufreq/Makefile
--- a/arch/x86_64/kernel/cpufreq/Makefile	2004-12-24 13:36:47 -08:00
+++ b/arch/x86_64/kernel/cpufreq/Makefile	2004-12-24 13:36:47 -08:00
@@ -6,8 +6,12 @@
 
 obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o
 obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
-obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi.o
+obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o
+obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o
+obj-$(CONFIG_X86_SPEEDSTEP_LIB) += speedstep-lib.o
 
 powernow-k8-objs := ${SRCDIR}/powernow-k8.o
 speedstep-centrino-objs := ${SRCDIR}/speedstep-centrino.o
-acpi-objs := ${SRCDIR}/acpi.o
+acpi-cpufreq-objs := ${SRCDIR}/acpi-cpufreq.o
+p4-clockmod-objs := ${SRCDIR}/p4-clockmod.o
+speedstep-lib-objs := ${SRCDIR}/speedstep-lib.o
diff -Nru a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
--- a/arch/x86_64/kernel/early_printk.c	2004-12-24 13:37:02 -08:00
+++ b/arch/x86_64/kernel/early_printk.c	2004-12-24 13:37:02 -08:00
@@ -10,7 +10,7 @@
 #ifdef __i386__
 #define VGABASE		(__ISA_IO_base + 0xb8000)
 #else
-#define VGABASE		0xffffffff800b8000UL
+#define VGABASE		((void *)0xffffffff800b8000UL)
 #endif
 
 #define MAX_YPOS	25
diff -Nru a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
--- a/arch/x86_64/kernel/entry.S	2004-12-24 13:36:47 -08:00
+++ b/arch/x86_64/kernel/entry.S	2004-12-24 13:36:47 -08:00
@@ -907,6 +907,7 @@
 ENTRY(spurious_interrupt_bug)
 	zeroentry do_spurious_interrupt_bug
 
+#ifdef CONFIG_X86_MCE
 	/* runs on exception stack */
 ENTRY(machine_check)
 	CFI_STARTPROC
@@ -915,6 +916,7 @@
 	paranoidentry do_machine_check
 	jmp paranoid_exit
 	CFI_ENDPROC
+#endif
 
 ENTRY(call_debug)
        zeroentry do_call_debug
diff -Nru a/arch/x86_64/kernel/genapic.c b/arch/x86_64/kernel/genapic.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/x86_64/kernel/genapic.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004 James Cleverdon, IBM.
+ * Subject to the GNU Public License, v.2
+ *
+ * Generic APIC sub-arch probe layer.
+ *
+ * Hacked for x86-64 by James Cleverdon from i386 architecture code by
+ * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
+ * James Cleverdon.
+ */
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/cpumask.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/ctype.h>
+#include <linux/init.h>
+#include <linux/module.h>
+
+#include <asm/smp.h>
+#include <asm/ipi.h>
+
+/* which logical CPU number maps to which CPU (physical APIC ID) */
+u8 x86_cpu_to_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
+EXPORT_SYMBOL(x86_cpu_to_apicid);
+u8 x86_cpu_to_log_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
+
+extern struct genapic apic_cluster;
+extern struct genapic apic_flat;
+
+struct genapic *genapic = &apic_flat;
+
+
+/*
+ * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
+ */
+void __init clustered_apic_check(void)
+{
+	long i;
+	u8 clusters, max_cluster;
+	u8 id;
+	u8 cluster_cnt[NUM_APIC_CLUSTERS];
+
+	memset(cluster_cnt, 0, sizeof(cluster_cnt));
+
+	for (i = 0; i < NR_CPUS; i++) {
+		id = bios_cpu_apicid[i];
+		if (id != BAD_APICID)
+			cluster_cnt[APIC_CLUSTERID(id)]++;
+	}
+
+	clusters = 0;
+	max_cluster = 0;
+	for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
+		if (cluster_cnt[i] > 0) {
+			++clusters;
+			if (cluster_cnt[i] > max_cluster)
+				max_cluster = cluster_cnt[i];
+		}
+	}
+
+	/*
+	 * If we have clusters <= 1 and CPUs <= 8 in cluster 0, then flat mode,
+	 * else if max_cluster <= 4 and cluster_cnt[15] == 0, clustered logical
+	 * else physical mode.
+	 * (We don't use lowest priority delivery + HW APIC IRQ steering, so
+	 * can ignore the clustered logical case and go straight to physical.)
+	 */
+	if (clusters <= 1 && max_cluster <= 8 && cluster_cnt[0] == max_cluster)
+		genapic = &apic_flat;
+	else
+		genapic = &apic_cluster;
+
+	printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
+}
+
+/* Same for both flat and clustered. */
+
+void send_IPI_self(int vector)
+{
+	__send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
+}
diff -Nru a/arch/x86_64/kernel/genapic_cluster.c b/arch/x86_64/kernel/genapic_cluster.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/x86_64/kernel/genapic_cluster.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2004 James Cleverdon, IBM.
+ * Subject to the GNU Public License, v.2
+ *
+ * Clustered APIC subarch code.  Up to 255 CPUs, physical delivery.
+ * (A more realistic maximum is around 230 CPUs.)
+ *
+ * Hacked for x86-64 by James Cleverdon from i386 architecture code by
+ * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
+ * James Cleverdon.
+ */
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/cpumask.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/ctype.h>
+#include <linux/init.h>
+#include <asm/smp.h>
+#include <asm/ipi.h>
+
+
+/*
+ * Set up the logical destination ID.
+ *
+ * Intel recommends to set DFR, LDR and TPR before enabling
+ * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
+ * document number 292116).  So here it goes...
+ */
+static void cluster_init_apic_ldr(void)
+{
+	unsigned long val, id;
+	long i, count;
+	u8 lid;
+	u8 my_id = hard_smp_processor_id();
+	u8 my_cluster = APIC_CLUSTER(my_id);
+
+	/* Create logical APIC IDs by counting CPUs already in cluster. */
+	for (count = 0, i = NR_CPUS; --i >= 0; ) {
+		lid = x86_cpu_to_log_apicid[i];
+		if (lid != BAD_APICID && APIC_CLUSTER(lid) == my_cluster)
+			++count;
+	}
+	/*
+	 * We only have a 4 wide bitmap in cluster mode.  There's no way
+	 * to get above 60 CPUs and still give each one it's own bit.
+	 * But, we're using physical IRQ delivery, so we don't care.
+	 * Use bit 3 for the 4th through Nth CPU in each cluster.
+	 */
+	if (count >= XAPIC_DEST_CPUS_SHIFT)
+		count = 3;
+	id = my_cluster | (1UL << count);
+	x86_cpu_to_log_apicid[smp_processor_id()] = id;
+	apic_write_around(APIC_DFR, APIC_DFR_CLUSTER);
+	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
+	val |= SET_APIC_LOGICAL_ID(id);
+	apic_write_around(APIC_LDR, val);
+}
+
+/* Start with all IRQs pointing to boot CPU.  IRQ balancing will shift them. */
+
+static cpumask_t cluster_target_cpus(void)
+{
+	return cpumask_of_cpu(0);
+}
+
+static void cluster_send_IPI_mask(cpumask_t mask, int vector)
+{
+	send_IPI_mask_sequence(mask, vector);
+}
+
+static void cluster_send_IPI_allbutself(int vector)
+{
+	cpumask_t mask = cpu_online_map;
+	cpu_clear(smp_processor_id(), mask);
+
+	if (!cpus_empty(mask))
+		cluster_send_IPI_mask(mask, vector);
+}
+
+static void cluster_send_IPI_all(int vector)
+{
+	cluster_send_IPI_mask(cpu_online_map, vector);
+}
+
+static int cluster_apic_id_registered(void)
+{
+	return 1;
+}
+
+static unsigned int cluster_cpu_mask_to_apicid(cpumask_t cpumask)
+{
+	int cpu;
+
+	/*
+	 * We're using fixed IRQ delivery, can only return one phys APIC ID.
+	 * May as well be the first.
+	 */
+	cpu = first_cpu(cpumask);
+	if ((unsigned)cpu < NR_CPUS)
+		return x86_cpu_to_apicid[cpu];
+	else
+		return BAD_APICID;
+}
+
+/* cpuid returns the value latched in the HW at reset, not the APIC ID
+ * register's value.  For any box whose BIOS changes APIC IDs, like
+ * clustered APIC systems, we must use hard_smp_processor_id.
+ *
+ * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID.
+ */
+static unsigned int phys_pkg_id(int index_msb)
+{
+	return hard_smp_processor_id() >> index_msb;
+}
+
+struct genapic apic_cluster = {
+	.name = "clustered",
+	.int_delivery_mode = dest_Fixed,
+	.int_dest_mode = (APIC_DEST_PHYSICAL != 0),
+	.int_delivery_dest = APIC_DEST_PHYSICAL | APIC_DM_FIXED,
+	.target_cpus = cluster_target_cpus,
+	.apic_id_registered = cluster_apic_id_registered,
+	.init_apic_ldr = cluster_init_apic_ldr,
+	.send_IPI_all = cluster_send_IPI_all,
+	.send_IPI_allbutself = cluster_send_IPI_allbutself,
+	.send_IPI_mask = cluster_send_IPI_mask,
+	.cpu_mask_to_apicid = cluster_cpu_mask_to_apicid,
+	.phys_pkg_id = phys_pkg_id,
+};
diff -Nru a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/x86_64/kernel/genapic_flat.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2004 James Cleverdon, IBM.
+ * Subject to the GNU Public License, v.2
+ *
+ * Flat APIC subarch code.  Maximum 8 CPUs, logical delivery.
+ *
+ * Hacked for x86-64 by James Cleverdon from i386 architecture code by
+ * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
+ * James Cleverdon.
+ */
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/cpumask.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/ctype.h>
+#include <linux/init.h>
+#include <asm/smp.h>
+#include <asm/ipi.h>
+
+
+static cpumask_t flat_target_cpus(void)
+{
+	return cpu_online_map;
+}
+
+/*
+ * Set up the logical destination ID.
+ *
+ * Intel recommends to set DFR, LDR and TPR before enabling
+ * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
+ * document number 292116).  So here it goes...
+ */
+static void flat_init_apic_ldr(void)
+{
+	unsigned long val;
+	unsigned long num, id;
+
+	num = smp_processor_id();
+	id = 1UL << num;
+	x86_cpu_to_log_apicid[num] = id;
+	apic_write_around(APIC_DFR, APIC_DFR_FLAT);
+	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
+	val |= SET_APIC_LOGICAL_ID(id);
+	apic_write_around(APIC_LDR, val);
+}
+
+static void flat_send_IPI_allbutself(int vector)
+{
+	/*
+	 * if there are no other CPUs in the system then
+	 * we get an APIC send error if we try to broadcast.
+	 * thus we have to avoid sending IPIs in this case.
+	 */
+	if (num_online_cpus() > 1)
+		__send_IPI_shortcut(APIC_DEST_ALLBUT, vector, APIC_DEST_LOGICAL);
+}
+
+static void flat_send_IPI_all(int vector)
+{
+	__send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
+}
+
+static void flat_send_IPI_mask(cpumask_t cpumask, int vector)
+{
+	unsigned long mask = cpus_addr(cpumask)[0];
+	unsigned long cfg;
+	unsigned long flags;
+
+	local_save_flags(flags);
+	local_irq_disable();
+
+	/*
+	 * Wait for idle.
+	 */
+	apic_wait_icr_idle();
+
+	/*
+	 * prepare target chip field
+	 */
+	cfg = __prepare_ICR2(mask);
+	apic_write_around(APIC_ICR2, cfg);
+
+	/*
+	 * program the ICR
+	 */
+	cfg = __prepare_ICR(0, vector, APIC_DEST_LOGICAL);
+
+	/*
+	 * Send the IPI. The write to APIC_ICR fires this off.
+	 */
+	apic_write_around(APIC_ICR, cfg);
+	local_irq_restore(flags);
+}
+
+static int flat_apic_id_registered(void)
+{
+	return physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map);
+}
+
+static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask)
+{
+	return cpus_addr(cpumask)[0] & APIC_ALL_CPUS;
+}
+
+static unsigned int phys_pkg_id(int index_msb)
+{
+	u32 ebx;
+
+	ebx = cpuid_ebx(1);
+	return ((ebx >> 24) & 0xFF) >> index_msb;
+}
+
+struct genapic apic_flat =  {
+	.name = "flat",
+	.int_delivery_mode = dest_LowestPrio,
+	.int_dest_mode = (APIC_DEST_LOGICAL != 0),
+	.int_delivery_dest = APIC_DEST_LOGICAL | APIC_DM_LOWEST,
+	.target_cpus = flat_target_cpus,
+	.apic_id_registered = flat_apic_id_registered,
+	.init_apic_ldr = flat_init_apic_ldr,
+	.send_IPI_all = flat_send_IPI_all,
+	.send_IPI_allbutself = flat_send_IPI_allbutself,
+	.send_IPI_mask = flat_send_IPI_mask,
+	.cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
+	.phys_pkg_id = phys_pkg_id,
+};
diff -Nru a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
--- a/arch/x86_64/kernel/head.S	2004-12-24 13:37:01 -08:00
+++ b/arch/x86_64/kernel/head.S	2004-12-24 13:37:01 -08:00
@@ -176,6 +176,18 @@
 init_rsp:
 	.quad  init_thread_union+THREAD_SIZE-8
 
+ENTRY(early_idt_handler)
+	xorl %eax,%eax
+	movq 8(%rsp),%rsi	# get rip
+	movq (%rsp),%rdx
+	movq %cr2,%rcx
+	leaq early_idt_msg(%rip),%rdi
+	call early_printk
+1:	hlt
+	jmp 1b
+
+early_idt_msg:
+	.asciz "PANIC: early exception rip %lx error %lx cr2 %lx\n"
 
 .code32
 ENTRY(no_long_mode)
diff -Nru a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
--- a/arch/x86_64/kernel/head64.c	2004-12-24 13:36:48 -08:00
+++ b/arch/x86_64/kernel/head64.c	2004-12-24 13:36:48 -08:00
@@ -11,12 +11,14 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/percpu.h>
 
 #include <asm/processor.h>
 #include <asm/proto.h>
 #include <asm/smp.h>
 #include <asm/bootsetup.h>
 #include <asm/setup.h>
+#include <asm/desc.h>
 
 /* Don't add a printk in there. printk relies on the PDA which is not initialized 
    yet. */
@@ -79,7 +81,11 @@
 void __init x86_64_start_kernel(char * real_mode_data)
 {
 	char *s;
+	int i;
 
+	for (i = 0; i < 256; i++)
+		set_intr_gate(i, early_idt_handler);
+	asm volatile("lidt %0" :: "m" (idt_descr));
 	clear_bss();
 	pda_init(0);
 	copy_bootdata(real_mode_data);
diff -Nru a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
--- a/arch/x86_64/kernel/i8259.c	2004-12-24 13:36:19 -08:00
+++ b/arch/x86_64/kernel/i8259.c	2004-12-24 13:36:19 -08:00
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
+#include <linux/bitops.h>
 
 #include <asm/acpi.h>
 #include <asm/atomic.h>
@@ -19,7 +20,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/hw_irq.h>
-#include <asm/bitops.h>
 #include <asm/pgtable.h>
 #include <asm/delay.h>
 #include <asm/desc.h>
diff -Nru a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
--- a/arch/x86_64/kernel/io_apic.c	2004-12-24 13:36:54 -08:00
+++ b/arch/x86_64/kernel/io_apic.c	2004-12-24 13:36:54 -08:00
@@ -36,15 +36,12 @@
 #include <asm/smp.h>
 #include <asm/desc.h>
 #include <asm/proto.h>
+#include <asm/mach_apic.h>
 
 #define __apicdebuginit  __init
 
 int sis_apic_bug; /* not actually supported, dummy for compile */
 
-#undef APIC_LOCKUP_DEBUG
-
-#define APIC_LOCKUP_DEBUG
-
 static spinlock_t ioapic_lock = SPIN_LOCK_UNLOCKED;
 
 /*
@@ -83,7 +80,7 @@
  * shared ISA-space IRQs, so we have to support them. We are super
  * fast in the common case, and fast for shared ISA-space IRQs.
  */
-static void __init add_pin_to_irq(unsigned int irq, int apic, int pin)
+static void add_pin_to_irq(unsigned int irq, int apic, int pin)
 {
 	static int first_free_entry = NR_IRQS;
 	struct irq_pin_list *entry = irq_2_pin + irq;
@@ -131,10 +128,6 @@
 						/* mask = 1 */
 DO_ACTION( __unmask,           0, &= 0xfffeffff, )
 						/* mask = 0 */
-DO_ACTION( __mask_and_edge,    0, = (reg & 0xffff7fff) | 0x00010000, )
-						/* mask = 1, trigger = 0 */
-DO_ACTION( __unmask_and_level, 0, = (reg & 0xfffeffff) | 0x00008000, )
-						/* mask = 0, trigger = 1 */
 
 static void mask_IO_APIC_irq (unsigned int irq)
 {
@@ -265,12 +258,14 @@
 #endif
 					return;
 				case PCI_VENDOR_ID_NVIDIA:
-#ifndef CONFIG_SMP
+#ifdef CONFIG_ACPI
+					/* All timer overrides on Nvidia
+				           seem to be wrong. Skip them. */
+					acpi_skip_timer_override = 1;
 					printk(KERN_INFO 
-     "PCI bridge %02x:%02x from %x found. Setting \"noapic\". Overwrite with \"apic\"\n",
-					       num,slot,vendor); 
-					skip_ioapic_setup = 1;
+	     "Nvidia board detected. Ignoring ACPI timer override.\n");
 #endif
+					/* RED-PEN skip them on mptables too? */
 					return;
 				} 
 
@@ -315,7 +310,7 @@
 /*
  * Find the IRQ entry number of a certain pin.
  */
-static int __init find_irq_entry(int apic, int pin, int type)
+static int find_irq_entry(int apic, int pin, int type)
 {
 	int i;
 
@@ -399,7 +394,7 @@
 /*
  * EISA Edge/Level control register, ELCR
  */
-static int __init EISA_ELCR(unsigned int irq)
+static int EISA_ELCR(unsigned int irq)
 {
 	if (irq < 16) {
 		unsigned int port = 0x4d0 + (irq >> 3);
@@ -504,7 +499,7 @@
 	return polarity;
 }
 
-static int __init MPBIOS_trigger(int idx)
+static int MPBIOS_trigger(int idx)
 {
 	int bus = mp_irqs[idx].mpc_srcbus;
 	int trigger;
@@ -659,11 +654,7 @@
 /* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */
 u8 irq_vector[NR_IRQ_VECTORS] = { FIRST_DEVICE_VECTOR , 0 };
 
-#ifdef CONFIG_PCI_MSI
 int assign_irq_vector(int irq)
-#else
-int __init assign_irq_vector(int irq)
-#endif
 {
 	static int current_vector = FIRST_DEVICE_VECTOR, offset = 0;
 
@@ -732,8 +723,8 @@
 		 */
 		memset(&entry,0,sizeof(entry));
 
-		entry.delivery_mode = dest_LowestPrio;
-		entry.dest_mode = INT_DELIVERY_MODE;
+		entry.delivery_mode = INT_DELIVERY_MODE;
+		entry.dest_mode = INT_DEST_MODE;
 		entry.mask = 0;				/* enable IRQ */
 		entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
 
@@ -801,10 +792,10 @@
 	 * We use logical delivery to get the timer IRQ
 	 * to the first CPU.
 	 */
-	entry.dest_mode = INT_DELIVERY_MODE;
+	entry.dest_mode = INT_DEST_MODE;
 	entry.mask = 0;					/* unmask IRQ now */
 	entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
-	entry.delivery_mode = dest_LowestPrio;
+	entry.delivery_mode = INT_DELIVERY_MODE;
 	entry.polarity = 0;
 	entry.trigger = 0;
 	entry.vector = vector;
@@ -1152,7 +1143,6 @@
 static void __init setup_ioapic_ids_from_mpc (void)
 {
 	union IO_APIC_reg_00 reg_00;
-	physid_mask_t phys_id_present_map = phys_cpu_present_map;
 	int apic;
 	int i;
 	unsigned char old_id;
@@ -1178,28 +1168,7 @@
 			mp_ioapics[apic].mpc_apicid = reg_00.bits.ID;
 		}
 
-		/*
-		 * Sanity check, is the ID really free? Every APIC in a
-		 * system must have a unique ID or we get lots of nice
-		 * 'stuck on smp_invalidate_needed IPI wait' messages.
-	 	 */
-		if (physid_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
-			printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
-				apic, mp_ioapics[apic].mpc_apicid);
-			for (i = 0; i < 0xf; i++)
-				if (!physid_isset(i, phys_id_present_map))
-					break;
-			if (i >= 0xf)
-				panic("Max APIC ID exceeded!\n");
-			printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
-				i);
-			physid_set(i, phys_id_present_map);
-			mp_ioapics[apic].mpc_apicid = i;
-		} else {
-			printk(KERN_INFO 
-			       "Using IO-APIC %d\n", mp_ioapics[apic].mpc_apicid);
-			physid_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
-		}
+		printk(KERN_INFO "Using IO-APIC %d\n", mp_ioapics[apic].mpc_apicid);
 
 
 		/*
@@ -1343,61 +1312,7 @@
 
 static void end_level_ioapic_irq (unsigned int irq)
 {
-	unsigned long v;
-	int i;
-
-/*
- * It appears there is an erratum which affects at least version 0x11
- * of I/O APIC (that's the 82093AA and cores integrated into various
- * chipsets).  Under certain conditions a level-triggered interrupt is
- * erroneously delivered as edge-triggered one but the respective IRR
- * bit gets set nevertheless.  As a result the I/O unit expects an EOI
- * message but it will never arrive and further interrupts are blocked
- * from the source.  The exact reason is so far unknown, but the
- * phenomenon was observed when two consecutive interrupt requests
- * from a given source get delivered to the same CPU and the source is
- * temporarily disabled in between.
- *
- * A workaround is to simulate an EOI message manually.  We achieve it
- * by setting the trigger mode to edge and then to level when the edge
- * trigger mode gets detected in the TMR of a local APIC for a
- * level-triggered interrupt.  We mask the source for the time of the
- * operation to prevent an edge-triggered interrupt escaping meanwhile.
- * The idea is from Manfred Spraul.  --macro
- */
-	i = IO_APIC_VECTOR(irq);
-	v = apic_read(APIC_TMR + ((i & ~0x1f) >> 1));
-
 	ack_APIC_irq();
-
-	if (!(v & (1 << (i & 0x1f)))) {
-#ifdef APIC_LOCKUP_DEBUG
-		struct irq_pin_list *entry;
-#endif
-
-#ifdef APIC_MISMATCH_DEBUG
-		atomic_inc(&irq_mis_count);
-#endif
-		spin_lock(&ioapic_lock);
-		__mask_and_edge_IO_APIC_irq(irq);
-#ifdef APIC_LOCKUP_DEBUG
-		for (entry = irq_2_pin + irq;;) {
-			unsigned int reg;
-
-			if (entry->pin == -1)
-				break;
-			reg = io_apic_read(entry->apic, 0x10 + entry->pin * 2);
-			if (reg & 0x00004000)
-				printk(KERN_CRIT "Aieee!!!  Remote IRR"
-					" still set after unlock!\n");
-			if (!entry->next)
-				break;
-			entry = irq_2_pin + entry->next;
-		}
-#endif
-		__unmask_and_level_IO_APIC_irq(irq);
-		spin_unlock(&ioapic_lock);
-	}
 }
 
 static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask)
@@ -1408,9 +1323,9 @@
 	dest = cpu_mask_to_apicid(mask);
 
 	/*
-	 * Only the first 8 bits are valid.
+	 * Only the high 8 bits are valid.
 	 */
-	dest = dest << 24;
+	dest = SET_APIC_LOGICAL_ID(dest);
 
 	spin_lock_irqsave(&ioapic_lock, flags);
 	__DO_ACTION(1, = dest, )
@@ -1892,7 +1807,7 @@
 
 #ifdef CONFIG_ACPI_BOOT
 
-#define IO_APIC_MAX_ID		15
+#define IO_APIC_MAX_ID		0xFE
 
 int __init io_apic_get_unique_id (int ioapic, int apic_id)
 {
@@ -2009,8 +1924,8 @@
 
 	memset(&entry,0,sizeof(entry));
 
-	entry.delivery_mode = dest_LowestPrio;
-	entry.dest_mode = INT_DELIVERY_MODE;
+	entry.delivery_mode = INT_DELIVERY_MODE;
+	entry.dest_mode = INT_DEST_MODE;
 	entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
 	entry.trigger = edge_level;
 	entry.polarity = active_high_low;
@@ -2043,24 +1958,6 @@
 }
 
 #endif /*CONFIG_ACPI_BOOT*/
-
-#ifndef CONFIG_SMP
-void send_IPI_self(int vector)
-{
-	unsigned int cfg;
-
-       /*
-        * Wait for idle.
-        */
-	apic_wait_icr_idle();
-	cfg = APIC_DM_FIXED | APIC_DEST_SELF | vector | APIC_DEST_LOGICAL;
-
-	/*
-	 * Send the IPI. The write to APIC_ICR fires this off.
-	 */
-	apic_write_around(APIC_ICR, cfg);
-}
-#endif
 
 
 /*
diff -Nru a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
--- a/arch/x86_64/kernel/irq.c	2004-12-24 13:36:48 -08:00
+++ b/arch/x86_64/kernel/irq.c	2004-12-24 13:36:48 -08:00
@@ -3,127 +3,19 @@
  *
  *	Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  *
- * This file contains the code used by various IRQ handling routines:
- * asking for different IRQ's should be done through these routines
- * instead of just grabbing them. Thus setups with different IRQ numbers
- * shouldn't result in any weird surprises, and installing new handlers
- * should be easier.
+ * This file contains the lowest level x86_64-specific interrupt
+ * entry and irq statistics code. All the remaining irq logic is
+ * done by the generic kernel/irq/ code and in the
+ * x86_64-specific irq controller code. (e.g. i8259.c and
+ * io_apic.c.)
  */
 
-/*
- * (mostly architecture independent, will move to kernel/irq.c in 2.5.)
- *
- * IRQs are in fact implemented a bit like signal handlers for the kernel.
- * Naturally it's not a 1:1 relation, but there are similarities.
- */
-
-#include <linux/config.h>
-#include <linux/errno.h>
-#include <linux/module.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
-#include <linux/interrupt.h>
-#include <linux/timex.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-#include <linux/smp_lock.h>
-#include <linux/init.h>
 #include <linux/kernel_stat.h>
-#include <linux/irq.h>
-#include <linux/proc_fs.h>
+#include <linux/interrupt.h>
 #include <linux/seq_file.h>
-
-#include <asm/atomic.h>
-#include <asm/io.h>
-#include <asm/smp.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/module.h>
 #include <asm/uaccess.h>
-#include <asm/pgalloc.h>
-#include <asm/delay.h>
-#include <asm/desc.h>
-#include <asm/irq.h>
-
-
-
-/*
- * Linux has a controller-independent x86 interrupt architecture.
- * every controller has a 'controller-template', that is used
- * by the main code to do the right thing. Each driver-visible
- * interrupt source is transparently wired to the appropriate
- * controller. Thus drivers need not be aware of the
- * interrupt-controller.
- *
- * Various interrupt controllers we handle: 8259 PIC, SMP IO-APIC,
- * PIIX4's internal 8259 PIC and SGI's Visual Workstation Cobalt (IO-)APIC.
- * (IO-APICs assumed to be messaging to Pentium local-APICs)
- *
- * the code is designed to be easily extended with new/different
- * interrupt controllers, without having to do assembly magic.
- */
-
-/*
- * Controller mappings for all interrupt sources:
- */
-irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
-	[0 ... NR_IRQS-1] = {
-		.handler = &no_irq_type,
-		.lock = SPIN_LOCK_UNLOCKED
-	}
-};
-
-static void register_irq_proc (unsigned int irq);
-
-/*
- * Special irq handlers.
- */
-
-irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs) { return IRQ_NONE; }
-
-/*
- * Generic no controller code
- */
-
-static void enable_none(unsigned int irq) { }
-static unsigned int startup_none(unsigned int irq) { return 0; }
-static void disable_none(unsigned int irq) { }
-static void ack_none(unsigned int irq)
-{
-/*
- * 'what should we do if we get a hw irq event on an illegal vector'.
- * each architecture has to answer this themselves, it doesn't deserve
- * a generic callback i think.
- */
-#ifdef CONFIG_X86
-	printk("unexpected IRQ trap at vector %02x\n", irq);
-#ifdef CONFIG_X86_LOCAL_APIC
-	/*
-	 * Currently unexpected vectors happen only on SMP and APIC.
-	 * We _must_ ack these because every local APIC has only N
-	 * irq slots per priority level, and a 'hanging, unacked' IRQ
-	 * holds up an irq slot - in excessive cases (when multiple
-	 * unexpected vectors occur) that might lock up the APIC
-	 * completely.
-	 */
-	ack_APIC_irq();
-#endif
-#endif
-}
-
-/* startup is the same as "enable", shutdown is same as "disable" */
-#define shutdown_none	disable_none
-#define end_none	enable_none
-
-struct hw_interrupt_type no_irq_type = {
-	"none",
-	startup_none,
-	shutdown_none,
-	enable_none,
-	disable_none,
-	ack_none,
-	end_none
-};
+#include <asm/io_apic.h>
 
 atomic_t irq_err_count;
 #ifdef CONFIG_X86_IO_APIC
@@ -195,131 +87,6 @@
 	return 0;
 }
 
-#ifdef CONFIG_SMP
-inline void synchronize_irq(unsigned int irq)
-{
-	while (irq_desc[irq].status & IRQ_INPROGRESS)
-		cpu_relax();
-}
-#endif
-
-/*
- * This should really return information about whether
- * we should do bottom half handling etc. Right now we
- * end up _always_ checking the bottom half, which is a
- * waste of time and is not what some drivers would
- * prefer.
- */
-int handle_IRQ_event(unsigned int irq, struct pt_regs * regs, struct irqaction * action)
-{
-	int status = 1; /* Force the "do bottom halves" bit */
-	int ret;
-
-	if (!(action->flags & SA_INTERRUPT))
-		local_irq_enable();
-
-	do {
-		ret = action->handler(irq, action->dev_id, regs);
-		if (ret == IRQ_HANDLED)
-			status |= action->flags;
-		action = action->next;
-	} while (action);
-	if (status & SA_SAMPLE_RANDOM)
-		add_interrupt_randomness(irq);
-	local_irq_disable();
-
-	return status;
-}
-
-/*
- * Generic enable/disable code: this just calls
- * down into the PIC-specific version for the actual
- * hardware disable after having gotten the irq
- * controller lock. 
- */
- 
-/**
- *	disable_irq_nosync - disable an irq without waiting
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line.  Disables and Enables are
- *	nested.
- *	Unlike disable_irq(), this function does not ensure existing
- *	instances of the IRQ handler have completed before returning.
- *
- *	This function must not be called from IRQ context.
- */
- 
-inline void disable_irq_nosync(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	if (!desc->depth++) {
-		desc->status |= IRQ_DISABLED;
-		desc->handler->disable(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-/**
- *	disable_irq - disable an irq and wait for completion
- *	@irq: Interrupt to disable
- *
- *	Disable the selected interrupt line.  Enables and Disables are
- *	nested.
- *	This function waits for any pending IRQ handlers for this interrupt
- *	to complete before returning. If you use this function while
- *	holding a resource the IRQ handler may need you will deadlock.
- *
- *	This function may be called - with care - from IRQ context.
- */
- 
-void disable_irq(unsigned int irq)
-{
-	disable_irq_nosync(irq);
-	synchronize_irq(irq);
-}
-
-/**
- *	enable_irq - enable handling of an irq
- *	@irq: Interrupt to enable
- *
- *	Undoes the effect of one call to disable_irq().  If this
- *	matches the last disable, processing of interrupts on this
- *	IRQ line is re-enabled.
- *
- *	This function may be called from IRQ context.
- */
- 
-void enable_irq(unsigned int irq)
-{
-	irq_desc_t *desc = irq_desc + irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&desc->lock, flags);
-	switch (desc->depth) {
-	case 1: {
-		unsigned int status = desc->status & ~IRQ_DISABLED;
-		desc->status = status;
-		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
-			desc->status = status | IRQ_REPLAY;
-			hw_resend_irq(desc->handler,irq);
-		}
-		desc->handler->enable(irq);
-		/* fall-through */
-	}
-	default:
-		desc->depth--;
-		break;
-	case 0:
-		printk("enable_irq(%u) unbalanced from %p\n", irq,
-		       __builtin_return_address(0));
-	}
-	spin_unlock_irqrestore(&desc->lock, flags);
-}
-
 /*
  * do_IRQ handles all normal device IRQ's (the special
  * SMP cross-CPU interrupts have their own specific
@@ -327,591 +94,15 @@
  */
 asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
 {	
-	/* 
-	 * We 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).
-	 *
-	 * 0 return value means that this irq is already being
-	 * handled by some other CPU. (or is disabled)
-	 */
-	unsigned irq = regs->orig_rax & 0xff; /* high bits used in ret_from_ code  */
-	int cpu = smp_processor_id();
-	irq_desc_t *desc = irq_desc + irq;
-	struct irqaction * action;
-	unsigned int status;
+	/* high bits used in ret_from_ code  */
+	unsigned irq = regs->orig_rax & 0xff;
 
-	if (irq > 256) BUG();
-
-	irq_enter(); 
-	kstat_cpu(cpu).irqs[irq]++;
-	spin_lock(&desc->lock);
-	desc->handler->ack(irq);
-	/*
-	   REPLAY is when Linux resends an IRQ that was dropped earlier
-	   WAITING is used by probe to mark irqs that are being tested
-	   */
-	status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
-	status |= IRQ_PENDING; /* we _want_ to handle it */
-
-	/*
-	 * If the IRQ is disabled for whatever reason, we cannot
-	 * use the action we have.
-	 */
-	action = NULL;
-	if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
-		action = desc->action;
-		status &= ~IRQ_PENDING; /* we commit to handling */
-		status |= IRQ_INPROGRESS; /* we are handling it */
-	}
-	desc->status = status;
-
-	/*
-	 * If there is no IRQ handler or it was disabled, exit early.
-	   Since we set PENDING, if another processor is handling
-	   a different instance of this same irq, the other processor
-	   will take care of it.
-	 */
-	if (unlikely(!action))
-		goto out;
-
-	/*
-	 * Edge triggered interrupts need to remember
-	 * pending events.
-	 * This applies to any hw interrupts that allow a second
-	 * instance of the same irq to arrive while we are in do_IRQ
-	 * or in the handler. But the code here only handles the _second_
-	 * instance of the irq, not the third or fourth. So it is mostly
-	 * useful for irq hardware that does not mask cleanly in an
-	 * SMP environment.
-	 */
-	for (;;) {
-		spin_unlock(&desc->lock);
-		handle_IRQ_event(irq, regs, action);
-		spin_lock(&desc->lock);
-		
-		if (unlikely(!(desc->status & IRQ_PENDING)))
-			break;
-		desc->status &= ~IRQ_PENDING;
-	}
-	desc->status &= ~IRQ_INPROGRESS;
-out:
-	/*
-	 * The ->end() handler has to deal with interrupts which got
-	 * disabled while the handler was running.
-	 */
-	if (irq > 256) BUG();
-	desc->handler->end(irq);
-	spin_unlock(&desc->lock);
+	irq_enter();
+	BUG_ON(irq > 256);
 
+	__do_IRQ(irq, regs);
 	irq_exit();
-	return 1;
-}
-
-int can_request_irq(unsigned int irq, unsigned long irqflags)
-{
-	struct irqaction *action;
-
-	if (irq >= NR_IRQS)
-		return 0;
-	action = irq_desc[irq].action;
-	if (action) {
-		if (irqflags & action->flags & SA_SHIRQ)
-			action = NULL;
-	}
-	return !action;
-}
-
-/**
- *	request_irq - allocate an interrupt line
- *	@irq: Interrupt line to allocate
- *	@handler: Function to be called when the IRQ occurs
- *	@irqflags: Interrupt type flags
- *	@devname: An ascii name for the claiming device
- *	@dev_id: A cookie passed back to the handler function
- *
- *	This call allocates interrupt resources and enables the
- *	interrupt line and IRQ handling. From the point this
- *	call is made your handler function may be invoked. Since
- *	your handler function must clear any interrupt the board 
- *	raises, you must take care both to initialise your hardware
- *	and to set up the interrupt handler in the right order.
- *
- *	Dev_id must be globally unique. Normally the address of the
- *	device data structure is used as the cookie. Since the handler
- *	receives this value it makes sense to use it.
- *
- *	If your interrupt is shared you must pass a non NULL dev_id
- *	as this is required when freeing the interrupt.
- *
- *	Flags:
- *
- *	SA_SHIRQ		Interrupt is shared
- *
- *	SA_INTERRUPT		Disable local interrupts while processing
- *
- *	SA_SAMPLE_RANDOM	The interrupt can be used for entropy
- *
- */
- 
-int request_irq(unsigned int irq, 
-		irqreturn_t (*handler)(int, void *, struct pt_regs *),
-		unsigned long irqflags, 
-		const char * devname,
-		void *dev_id)
-{
-	int retval;
-	struct irqaction * action;
-
-#if 1
-	/*
-	 * Sanity-check: shared interrupts should REALLY pass in
-	 * a real dev-ID, otherwise we'll have trouble later trying
-	 * to figure out which interrupt is which (messes up the
-	 * interrupt freeing logic etc).
-	 */
-	if (irqflags & SA_SHIRQ) {
-		if (!dev_id)
-			printk("Bad boy: %s (at 0x%x) called us without a dev_id!\n", devname, (&irq)[-1]);
-	}
-#endif
-
-	if (irq >= NR_IRQS)
-		return -EINVAL;
-	if (!handler)
-		return -EINVAL;
-
-	action = (struct irqaction *)
-			kmalloc(sizeof(struct irqaction), GFP_ATOMIC);
-	if (!action)
-		return -ENOMEM;
-
-	action->handler = handler;
-	action->flags = irqflags;
-	cpus_clear(action->mask);
-	action->name = devname;
-	action->next = NULL;
-	action->dev_id = dev_id;
-
-	retval = setup_irq(irq, action);
-	if (retval)
-		kfree(action);
-	return retval;
-}
-
-EXPORT_SYMBOL(request_irq);
-
-/**
- *	free_irq - free an interrupt
- *	@irq: Interrupt line to free
- *	@dev_id: Device identity to free
- *
- *	Remove an interrupt handler. The handler is removed and if the
- *	interrupt line is no longer in use by any driver it is disabled.
- *	On a shared IRQ the caller must ensure the interrupt is disabled
- *	on the card it drives before calling this function. The function
- *	does not return until any executing interrupts for this IRQ
- *	have completed.
- *
- *	This function may be called from interrupt context. 
- *
- *	Bugs: Attempting to free an irq in a handler for the same irq hangs
- *	      the machine.
- */
- 
-void free_irq(unsigned int irq, void *dev_id)
-{
-	irq_desc_t *desc;
-	struct irqaction **p;
-	unsigned long flags;
-
-	if (irq >= NR_IRQS)
-		return;
-
-	desc = irq_desc + irq;
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	for (;;) {
-		struct irqaction * action = *p;
-		if (action) {
-			struct irqaction **pp = p;
-			p = &action->next;
-			if (action->dev_id != dev_id)
-				continue;
-
-			/* Found it - now remove it from the list of entries */
-			*pp = action->next;
-			if (!desc->action) {
-				desc->status |= IRQ_DISABLED;
-				desc->handler->shutdown(irq);
-			}
-			spin_unlock_irqrestore(&desc->lock,flags);
-
-			synchronize_irq(irq);
-			kfree(action);
-			return;
-		}
-		printk("Trying to free free IRQ%d\n",irq);
-		spin_unlock_irqrestore(&desc->lock,flags);
-		return;
-	}
-}
-
-EXPORT_SYMBOL(free_irq);
-
-/*
- * IRQ autodetection code..
- *
- * This depends on the fact that any interrupt that
- * comes in on to an unassigned handler will get stuck
- * with "IRQ_WAITING" cleared and the interrupt
- * disabled.
- */
-
-static DECLARE_MUTEX(probe_sem);
-
-/**
- *	probe_irq_on	- begin an interrupt autodetect
- *
- *	Commence probing for an interrupt. The interrupts are scanned
- *	and a mask of potential interrupt lines is returned.
- *
- */
- 
-unsigned long probe_irq_on(void)
-{
-	unsigned int i;
-	irq_desc_t *desc;
-	unsigned long val;
-	unsigned long delay;
-
-	down(&probe_sem);
-	/* 
-	 * something may have generated an irq long ago and we want to
-	 * flush such a longstanding irq before considering it as spurious. 
-	 */
-	for (i = NR_IRQS-1; i > 0; i--)  {
-		desc = irq_desc + i;
-
-		spin_lock_irq(&desc->lock);
-		if (!irq_desc[i].action) 
-			irq_desc[i].handler->startup(i);
-		spin_unlock_irq(&desc->lock);
-	}
-
-	/* Wait for longstanding interrupts to trigger. */
-	for (delay = jiffies + HZ/50; time_after(delay, jiffies); )
-		/* about 20ms delay */ barrier();
-
-	/*
-	 * enable any unassigned irqs
-	 * (we must startup again here because if a longstanding irq
-	 * happened in the previous stage, it may have masked itself)
-	 */
-	for (i = NR_IRQS-1; i > 0; i--) {
-		desc = irq_desc + i;
-
-		spin_lock_irq(&desc->lock);
-		if (!desc->action) {
-			desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
-			if (desc->handler->startup(i))
-				desc->status |= IRQ_PENDING;
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-
-	/*
-	 * Wait for spurious interrupts to trigger
-	 */
-	for (delay = jiffies + HZ/10; time_after(delay, jiffies); )
-		/* about 100ms delay */ barrier();
-
-	/*
-	 * Now filter out any obviously spurious interrupts
-	 */
-	val = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			/* It triggered already - consider it spurious. */
-			if (!(status & IRQ_WAITING)) {
-				desc->status = status & ~IRQ_AUTODETECT;
-				desc->handler->shutdown(i);
-			} else
-				if (i < 32)
-					val |= 1 << i;
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-
-	return val;
-}
-
-EXPORT_SYMBOL(probe_irq_on);
-
-/*
- * Return a mask of triggered interrupts (this
- * can handle only legacy ISA interrupts).
- */
- 
-/**
- *	probe_irq_mask - scan a bitmap of interrupt lines
- *	@val:	mask of interrupts to consider
- *
- *	Scan the ISA bus interrupt lines and return a bitmap of
- *	active interrupts. The interrupt probe logic state is then
- *	returned to its previous value.
- *
- *	Note: we need to scan all the irq's even though we will
- *	only return ISA irq numbers - just so that we reset them
- *	all to a known state.
- */
-unsigned int probe_irq_mask(unsigned long val)
-{
-	int i;
-	unsigned int mask;
-
-	mask = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			if (i < 16 && !(status & IRQ_WAITING))
-				mask |= 1 << i;
-
-			desc->status = status & ~IRQ_AUTODETECT;
-			desc->handler->shutdown(i);
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-	up(&probe_sem);
-
-	return mask & val;
-}
-
-/*
- * Return the one interrupt that triggered (this can
- * handle any interrupt source).
- */
-
-/**
- *	probe_irq_off	- end an interrupt autodetect
- *	@val: mask of potential interrupts (unused)
- *
- *	Scans the unused interrupt lines and returns the line which
- *	appears to have triggered the interrupt. If no interrupt was
- *	found then zero is returned. If more than one interrupt is
- *	found then minus the first candidate is returned to indicate
- *	their is doubt.
- *
- *	The interrupt probe logic state is returned to its previous
- *	value.
- *
- *	BUGS: When used in a module (which arguably shouldn't happen)
- *	nothing prevents two IRQ probe callers from overlapping. The
- *	results of this are non-optimal.
- */
- 
-int probe_irq_off(unsigned long val)
-{
-	int i, irq_found, nr_irqs;
-
-	nr_irqs = 0;
-	irq_found = 0;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc_t *desc = irq_desc + i;
-		unsigned int status;
-
-		spin_lock_irq(&desc->lock);
-		status = desc->status;
-
-		if (status & IRQ_AUTODETECT) {
-			if (!(status & IRQ_WAITING)) {
-				if (!nr_irqs)
-					irq_found = i;
-				nr_irqs++;
-			}
-			desc->status = status & ~IRQ_AUTODETECT;
-			desc->handler->shutdown(i);
-		}
-		spin_unlock_irq(&desc->lock);
-	}
-	up(&probe_sem);
-
-	if (nr_irqs > 1)
-		irq_found = -irq_found;
-	return irq_found;
-}
-
-EXPORT_SYMBOL(probe_irq_off);
-
-/* this was setup_x86_irq but it seems pretty generic */
-int setup_irq(unsigned int irq, struct irqaction * new)
-{
-	int shared = 0;
-	unsigned long flags;
-	struct irqaction *old, **p;
-	irq_desc_t *desc = irq_desc + irq;
-
-	if (desc->handler == &no_irq_type)
-		return -ENOSYS;
-
-	/*
-	 * Some drivers like serial.c use request_irq() heavily,
-	 * so we have to be careful not to interfere with a
-	 * running system.
-	 */
-	if (new->flags & SA_SAMPLE_RANDOM) {
-		/*
-		 * This function might sleep, we want to call it first,
-		 * outside of the atomic block.
-		 * Yes, this might clear the entropy pool if the wrong
-		 * driver is attempted to be loaded, without actually
-		 * installing a new handler, but is this really a problem,
-		 * only the sysadmin is able to do this.
-		 */
-		rand_initialize_irq(irq);
-	}
-
-	/*
-	 * The following block of code has to be executed atomically
-	 */
-	spin_lock_irqsave(&desc->lock,flags);
-	p = &desc->action;
-	if ((old = *p) != NULL) {
-		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
-			spin_unlock_irqrestore(&desc->lock,flags);
-			return -EBUSY;
-		}
-
-		/* add new interrupt at end of irq queue */
-		do {
-			p = &old->next;
-			old = *p;
-		} while (old);
-		shared = 1;
-	}
-
-	*p = new;
-
-	if (!shared) {
-		desc->depth = 0;
-		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING);
-		desc->handler->startup(irq);
-	}
-	spin_unlock_irqrestore(&desc->lock,flags);
-
-	register_irq_proc(irq);
-	return 0;
-}
-
-static struct proc_dir_entry * root_irq_dir;
-static struct proc_dir_entry * irq_dir [NR_IRQS];
-
-#ifdef CONFIG_SMP
-
-static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
-
-static cpumask_t irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
-static int irq_affinity_read_proc (char *page, char **start, off_t off,
-			int count, int *eof, void *data)
-{
-	int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
-	if (count - len < 2)
-		return -EINVAL;
-	len += sprintf(page + len, "\n");
-	return len;
-}
-
-static int irq_affinity_write_proc (struct file *file,
-					const char __user *buffer,
-					unsigned long count, void *data)
-{
-	int irq = (long) data, full_count = count, err;
-	cpumask_t tmp, new_value;
-
-	if (!irq_desc[irq].handler->set_affinity)
-		return -EIO;
-
-	err = cpumask_parse(buffer, count, new_value);
-
-	/*
-	 * Do not allow disabling IRQs completely - it's a too easy
-	 * way to make the system unusable accidentally :-) At least
-	 * one online CPU still has to be targeted.
-	 */
-	cpus_and(tmp, new_value, cpu_online_map);
-	if (cpus_empty(tmp))
-		return -EINVAL;
 
-	irq_affinity[irq] = new_value;
-	irq_desc[irq].handler->set_affinity(irq, new_value);
-
-	return full_count;
-}
-
-#endif
-
-#define MAX_NAMELEN 10
-
-static void register_irq_proc (unsigned int irq)
-{
-	char name [MAX_NAMELEN];
-
-	if (!root_irq_dir || (irq_desc[irq].handler == &no_irq_type) ||
-			irq_dir[irq])
-		return;
-
-	memset(name, 0, MAX_NAMELEN);
-	sprintf(name, "%d", irq);
-
-	/* create /proc/irq/1234 */
-	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
-
-#ifdef CONFIG_SMP
-	{
-		struct proc_dir_entry *entry;
-
-		/* create /proc/irq/1234/smp_affinity */
-		entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
-
-		if (entry) {
-			entry->nlink = 1;
-			entry->data = (void *)(long)irq;
-			entry->read_proc = irq_affinity_read_proc;
-			entry->write_proc = irq_affinity_write_proc;
-		}
-
-		smp_affinity_entry[irq] = entry;
-	}
-#endif
+	return 1;
 }
 
-void init_irq_proc (void)
-{
-	int i;
-
-	/* create /proc/irq */
-	root_irq_dir = proc_mkdir("irq", NULL);
-
-	/* create /proc/irq/prof_cpu_mask */
-	create_prof_cpu_mask(root_irq_dir);
-
-	/*
-	 * Create entries for all existing IRQs.
-	 */
-	for (i = 0; i < NR_IRQS; i++)
-		register_irq_proc(i);
-}
diff -Nru a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/arch/x86_64/kernel/kprobes.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,481 @@
+/*
+ *  Kernel Probes (KProbes)
+ *  arch/x86_64/kernel/kprobes.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2002, 2004
+ *
+ * 2002-Oct	Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
+ *		Probes initial implementation ( includes contributions from
+ *		Rusty Russell).
+ * 2004-July	Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
+ *		interface to access function arguments.
+ * 2004-Oct	Jim Keniston <kenistoj@us.ibm.com> and Prasanna S Panchamukhi
+ *		<prasanna@in.ibm.com> adapted for x86_64
+ */
+
+#include <linux/config.h>
+#include <linux/kprobes.h>
+#include <linux/ptrace.h>
+#include <linux/spinlock.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/preempt.h>
+#include <linux/vmalloc.h>
+
+#include <asm/pgtable.h>
+#include <asm/kdebug.h>
+
+/* kprobe_status settings */
+#define KPROBE_HIT_ACTIVE	0x00000001
+#define KPROBE_HIT_SS		0x00000002
+
+static struct kprobe *current_kprobe;
+static unsigned long kprobe_status, kprobe_old_rflags, kprobe_saved_rflags;
+static struct pt_regs jprobe_saved_regs;
+static long *jprobe_saved_rsp;
+static kprobe_opcode_t *get_insn_slot(void);
+static void free_insn_slot(kprobe_opcode_t *slot);
+void jprobe_return_end(void);
+
+/* copy of the kernel stack at the probe fire time */
+static kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
+
+/*
+ * returns non-zero if opcode modifies the interrupt flag.
+ */
+static inline int is_IF_modifier(kprobe_opcode_t *insn)
+{
+	switch (*insn) {
+	case 0xfa:		/* cli */
+	case 0xfb:		/* sti */
+	case 0xcf:		/* iret/iretd */
+	case 0x9d:		/* popf/popfd */
+		return 1;
+	}
+
+	if (*insn  >= 0x40 && *insn <= 0x4f && *++insn == 0xcf)
+		return 1;
+	return 0;
+}
+
+int arch_prepare_kprobe(struct kprobe *p)
+{
+	/* insn: must be on special executable page on x86_64. */
+	p->ainsn.insn = get_insn_slot();
+	if (!p->ainsn.insn) {
+		return -ENOMEM;
+	}
+	memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE);
+	return 0;
+}
+
+void arch_remove_kprobe(struct kprobe *p)
+{
+	free_insn_slot(p->ainsn.insn);
+}
+
+static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
+{
+	*p->addr = p->opcode;
+	regs->rip = (unsigned long)p->addr;
+}
+
+static void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
+{
+	regs->eflags |= TF_MASK;
+	regs->eflags &= ~IF_MASK;
+
+	regs->rip = (unsigned long)p->ainsn.insn;
+}
+
+/*
+ * Interrupts are disabled on entry as trap3 is an interrupt gate and they
+ * remain disabled thorough out this function.
+ */
+int kprobe_handler(struct pt_regs *regs)
+{
+	struct kprobe *p;
+	int ret = 0;
+	kprobe_opcode_t *addr = (kprobe_opcode_t *)(regs->rip - sizeof(kprobe_opcode_t));
+
+	/* We're in an interrupt, but this is clear and BUG()-safe. */
+	preempt_disable();
+
+	/* Check we're not actually recursing */
+	if (kprobe_running()) {
+		/* We *are* holding lock here, so this is safe.
+		   Disarm the probe we just hit, and ignore it. */
+		p = get_kprobe(addr);
+		if (p) {
+			disarm_kprobe(p, regs);
+			ret = 1;
+		} else {
+			p = current_kprobe;
+			if (p->break_handler && p->break_handler(p, regs)) {
+				goto ss_probe;
+			}
+		}
+		/* If it's not ours, can't be delete race, (we hold lock). */
+		goto no_kprobe;
+	}
+
+	lock_kprobes();
+	p = get_kprobe(addr);
+	if (!p) {
+		unlock_kprobes();
+		if (*addr != BREAKPOINT_INSTRUCTION) {
+			/*
+			 * The breakpoint instruction was removed right
+			 * after we hit it.  Another cpu has removed
+			 * either a probepoint or a debugger breakpoint
+			 * at this address.  In either case, no further
+			 * handling of this interrupt is appropriate.
+			 */
+			ret = 1;
+		}
+		/* Not one of ours: let kernel handle it */
+		goto no_kprobe;
+	}
+
+	kprobe_status = KPROBE_HIT_ACTIVE;
+	current_kprobe = p;
+	kprobe_saved_rflags = kprobe_old_rflags
+	    = (regs->eflags & (TF_MASK | IF_MASK));
+	if (is_IF_modifier(p->ainsn.insn))
+		kprobe_saved_rflags &= ~IF_MASK;
+
+	if (p->pre_handler(p, regs)) {
+		/* handler has already set things up, so skip ss setup */
+		return 1;
+	}
+
+      ss_probe:
+	prepare_singlestep(p, regs);
+	kprobe_status = KPROBE_HIT_SS;
+	return 1;
+
+      no_kprobe:
+	preempt_enable_no_resched();
+	return ret;
+}
+
+/*
+ * Called after single-stepping.  p->addr is the address of the
+ * instruction whose first byte has been replaced by the "int 3"
+ * instruction.  To avoid the SMP problems that can occur when we
+ * temporarily put back the original opcode to single-step, we
+ * single-stepped a copy of the instruction.  The address of this
+ * copy is p->ainsn.insn.
+ *
+ * This function prepares to return from the post-single-step
+ * interrupt.  We have to fix up the stack as follows:
+ *
+ * 0) Except in the case of absolute or indirect jump or call instructions,
+ * the new rip is relative to the copied instruction.  We need to make
+ * it relative to the original instruction.
+ *
+ * 1) If the single-stepped instruction was pushfl, then the TF and IF
+ * flags are set in the just-pushed eflags, and may need to be cleared.
+ *
+ * 2) If the single-stepped instruction was a call, the return address
+ * that is atop the stack is the address following the copied instruction.
+ * We need to make it the address following the original instruction.
+ */
+static void resume_execution(struct kprobe *p, struct pt_regs *regs)
+{
+	unsigned long *tos = (unsigned long *)regs->rsp;
+	unsigned long next_rip = 0;
+	unsigned long copy_rip = (unsigned long)p->ainsn.insn;
+	unsigned long orig_rip = (unsigned long)p->addr;
+	kprobe_opcode_t *insn = p->ainsn.insn;
+
+	/*skip the REX prefix*/
+	if (*insn >= 0x40 && *insn <= 0x4f)
+		insn++;
+
+	switch (*insn) {
+	case 0x9c:		/* pushfl */
+		*tos &= ~(TF_MASK | IF_MASK);
+		*tos |= kprobe_old_rflags;
+		break;
+	case 0xe8:		/* call relative - Fix return addr */
+		*tos = orig_rip + (*tos - copy_rip);
+		break;
+	case 0xff:
+		if ((*insn & 0x30) == 0x10) {
+			/* call absolute, indirect */
+			/* Fix return addr; rip is correct. */
+			next_rip = regs->rip;
+			*tos = orig_rip + (*tos - copy_rip);
+		} else if (((*insn & 0x31) == 0x20) ||	/* jmp near, absolute indirect */
+			   ((*insn & 0x31) == 0x21)) {	/* jmp far, absolute indirect */
+			/* rip is correct. */
+			next_rip = regs->rip;
+		}
+		break;
+	case 0xea:		/* jmp absolute -- rip is correct */
+		next_rip = regs->rip;
+		break;
+	default:
+		break;
+	}
+
+	regs->eflags &= ~TF_MASK;
+	if (next_rip) {
+		regs->rip = next_rip;
+	} else {
+		regs->rip = orig_rip + (regs->rip - copy_rip);
+	}
+}
+
+/*
+ * Interrupts are disabled on entry as trap1 is an interrupt gate and they
+ * remain disabled thoroughout this function.  And we hold kprobe lock.
+ */
+int post_kprobe_handler(struct pt_regs *regs)
+{
+	if (!kprobe_running())
+		return 0;
+
+	if (current_kprobe->post_handler)
+		current_kprobe->post_handler(current_kprobe, regs, 0);
+
+	resume_execution(current_kprobe, regs);
+	regs->eflags |= kprobe_saved_rflags;
+
+	unlock_kprobes();
+	preempt_enable_no_resched();
+
+	/*
+	 * if somebody else is singlestepping across a probe point, eflags
+	 * will have TF set, in which case, continue the remaining processing
+	 * of do_debug, as if this is not a probe hit.
+	 */
+	if (regs->eflags & TF_MASK)
+		return 0;
+
+	return 1;
+}
+
+/* Interrupts disabled, kprobe_lock held. */
+int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
+{
+	if (current_kprobe->fault_handler
+	    && current_kprobe->fault_handler(current_kprobe, regs, trapnr))
+		return 1;
+
+	if (kprobe_status & KPROBE_HIT_SS) {
+		resume_execution(current_kprobe, regs);
+		regs->eflags |= kprobe_old_rflags;
+
+		unlock_kprobes();
+		preempt_enable_no_resched();
+	}
+	return 0;
+}
+
+/*
+ * Wrapper routine for handling exceptions.
+ */
+int kprobe_exceptions_notify(struct notifier_block *self, unsigned long val,
+			     void *data)
+{
+	struct die_args *args = (struct die_args *)data;
+	switch (val) {
+	case DIE_INT3:
+		if (kprobe_handler(args->regs))
+			return NOTIFY_STOP;
+		break;
+	case DIE_DEBUG:
+		if (post_kprobe_handler(args->regs))
+			return NOTIFY_STOP;
+		break;
+	case DIE_GPF:
+		if (kprobe_running() &&
+		    kprobe_fault_handler(args->regs, args->trapnr))
+			return NOTIFY_STOP;
+		break;
+	case DIE_PAGE_FAULT:
+		if (kprobe_running() &&
+		    kprobe_fault_handler(args->regs, args->trapnr))
+			return NOTIFY_STOP;
+		break;
+	default:
+		break;
+	}
+	return NOTIFY_DONE;
+}
+
+int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
+{
+	struct jprobe *jp = container_of(p, struct jprobe, kp);
+	unsigned long addr;
+
+	jprobe_saved_regs = *regs;
+	jprobe_saved_rsp = (long *) regs->rsp;
+	addr = (unsigned long)jprobe_saved_rsp;
+	/*
+	 * As Linus pointed out, gcc assumes that the callee
+	 * owns the argument space and could overwrite it, e.g.
+	 * tailcall optimization. So, to be absolutely safe
+	 * we also save and restore enough stack bytes to cover
+	 * the argument area.
+	 */
+	memcpy(jprobes_stack, (kprobe_opcode_t *) addr, MIN_STACK_SIZE(addr));
+	regs->eflags &= ~IF_MASK;
+	regs->rip = (unsigned long)(jp->entry);
+	return 1;
+}
+
+void jprobe_return(void)
+{
+	preempt_enable_no_resched();
+	asm volatile ("       xchg   %%rbx,%%rsp     \n"
+		      "       int3			\n"
+		      "       .globl jprobe_return_end	\n"
+		      "       jprobe_return_end:	\n"
+		      "       nop			\n"::"b"
+		      (jprobe_saved_rsp):"memory");
+}
+
+int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
+{
+	u8 *addr = (u8 *) (regs->rip - 1);
+	unsigned long stack_addr = (unsigned long)jprobe_saved_rsp;
+	struct jprobe *jp = container_of(p, struct jprobe, kp);
+
+	if ((addr > (u8 *) jprobe_return) && (addr < (u8 *) jprobe_return_end)) {
+		if ((long *)regs->rsp != jprobe_saved_rsp) {
+			struct pt_regs *saved_regs =
+			    container_of(jprobe_saved_rsp, struct pt_regs, rsp);
+			printk("current rsp %p does not match saved rsp %p\n",
+			       (long *)regs->rsp, jprobe_saved_rsp);
+			printk("Saved registers for jprobe %p\n", jp);
+			show_registers(saved_regs);
+			printk("Current registers\n");
+			show_registers(regs);
+			BUG();
+		}
+		*regs = jprobe_saved_regs;
+		memcpy((kprobe_opcode_t *) stack_addr, jprobes_stack,
+		       MIN_STACK_SIZE(stack_addr));
+		return 1;
+	}
+	return 0;
+}
+
+/*
+ * kprobe->ainsn.insn points to the copy of the instruction to be single-stepped.
+ * By default on x86_64, pages we get from kmalloc or vmalloc are not
+ * executable.  Single-stepping an instruction on such a page yields an
+ * oops.  So instead of storing the instruction copies in their respective
+ * kprobe objects, we allocate a page, map it executable, and store all the
+ * instruction copies there.  (We can allocate additional pages if somebody
+ * inserts a huge number of probes.)  Each page can hold up to INSNS_PER_PAGE
+ * instruction slots, each of which is MAX_INSN_SIZE*sizeof(kprobe_opcode_t)
+ * bytes.
+ */
+#define INSNS_PER_PAGE (PAGE_SIZE/(MAX_INSN_SIZE*sizeof(kprobe_opcode_t)))
+struct kprobe_insn_page {
+	struct hlist_node hlist;
+	kprobe_opcode_t *insns;		/* page of instruction slots */
+	char slot_used[INSNS_PER_PAGE];
+	int nused;
+};
+
+static struct hlist_head kprobe_insn_pages;
+
+/**
+ * get_insn_slot() - Find a slot on an executable page for an instruction.
+ * We allocate an executable page if there's no room on existing ones.
+ */
+static kprobe_opcode_t *get_insn_slot(void)
+{
+	struct kprobe_insn_page *kip;
+	struct hlist_node *pos;
+
+	hlist_for_each(pos, &kprobe_insn_pages) {
+		kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
+		if (kip->nused < INSNS_PER_PAGE) {
+			int i;
+			for (i = 0; i < INSNS_PER_PAGE; i++) {
+				if (!kip->slot_used[i]) {
+					kip->slot_used[i] = 1;
+					kip->nused++;
+					return kip->insns + (i*MAX_INSN_SIZE);
+				}
+			}
+			/* Surprise!  No unused slots.  Fix kip->nused. */
+			kip->nused = INSNS_PER_PAGE;
+		}
+	}
+
+	/* All out of space.  Need to allocate a new page. Use slot 0.*/
+	kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_ATOMIC);
+	if (!kip) {
+		return NULL;
+	}
+	kip->insns = (kprobe_opcode_t*) __vmalloc(PAGE_SIZE,
+		GFP_ATOMIC|__GFP_HIGHMEM, __pgprot(__PAGE_KERNEL_EXEC));
+	if (!kip->insns) {
+		kfree(kip);
+		return NULL;
+	}
+	INIT_HLIST_NODE(&kip->hlist);
+	hlist_add_head(&kip->hlist, &kprobe_insn_pages);
+	memset(kip->slot_used, 0, INSNS_PER_PAGE);
+	kip->slot_used[0] = 1;
+	kip->nused = 1;
+	return kip->insns;
+}
+
+/**
+ * free_insn_slot() - Free instruction slot obtained from get_insn_slot().
+ */
+static void free_insn_slot(kprobe_opcode_t *slot)
+{
+	struct kprobe_insn_page *kip;
+	struct hlist_node *pos;
+
+	hlist_for_each(pos, &kprobe_insn_pages) {
+		kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
+		if (kip->insns <= slot
+		    && slot < kip->insns+(INSNS_PER_PAGE*MAX_INSN_SIZE)) {
+			int i = (slot - kip->insns) / MAX_INSN_SIZE;
+			kip->slot_used[i] = 0;
+			kip->nused--;
+			if (kip->nused == 0) {
+				/*
+				 * Page is no longer in use.  Free it unless
+				 * it's the last one.  We keep the last one
+				 * so as not to have to set it up again the
+				 * next time somebody inserts a probe.
+				 */
+				hlist_del(&kip->hlist);
+				if (hlist_empty(&kprobe_insn_pages)) {
+					INIT_HLIST_NODE(&kip->hlist);
+					hlist_add_head(&kip->hlist,
+						&kprobe_insn_pages);
+				} else {
+					vfree(kip->insns);
+					kfree(kip);
+				}
+			}
+			return;
+		}
+	}
+}
diff -Nru a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
--- a/arch/x86_64/kernel/mce.c	2004-12-24 13:36:32 -08:00
+++ b/arch/x86_64/kernel/mce.c	2004-12-24 13:36:32 -08:00
@@ -191,6 +191,8 @@
 			panicm = m;
 			panicm_found = 1;
 		}
+
+		tainted |= TAINT_MACHINE_CHECK;
 	}
 
 	/* Never do anything final in the polling timer */
@@ -359,8 +361,7 @@
 
 	memset(mcelog.entry, 0, next * sizeof(struct mce));
 	mcelog.next = 0;
-	smp_wmb(); 
-	
+
 	synchronize_kernel();	
 
 	/* Collect entries that were still getting written before the synchronize. */
diff -Nru a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
--- a/arch/x86_64/kernel/mpparse.c	2004-12-24 13:36:34 -08:00
+++ b/arch/x86_64/kernel/mpparse.c	2004-12-24 13:36:34 -08:00
@@ -330,6 +330,7 @@
 			}
 		}
 	}
+	clustered_apic_check();
 	if (!num_processors)
 		printk(KERN_ERR "SMP mptable: no processors registered!\n");
 	return num_processors;
@@ -895,25 +896,25 @@
 	return;
 }
 
-void mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
+int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
 {
 	int			ioapic = -1;
 	int			ioapic_pin = 0;
 	int			idx, bit = 0;
 
 	if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
-		return;
+		return gsi;
 
 #ifdef CONFIG_ACPI_BUS
 	/* Don't set up the ACPI SCI because it's already set up */
 	if (acpi_fadt.sci_int == gsi)
-		return;
+		return gsi;
 #endif
 
 	ioapic = mp_find_ioapic(gsi);
 	if (ioapic < 0) {
 		printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
-		return;
+		return gsi;
 	}
 
 	ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_start;
@@ -929,12 +930,12 @@
 		printk(KERN_ERR "Invalid reference to IOAPIC pin "
 			"%d-%d\n", mp_ioapic_routing[ioapic].apic_id, 
 			ioapic_pin);
-		return;
+		return gsi;
 	}
 	if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
 		Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
 			mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
-		return;
+		return gsi;
 	}
 
 	mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
@@ -942,6 +943,7 @@
 	io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
 		edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1,
 		active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1);
+	return gsi;
 }
 
 #endif /*CONFIG_X86_IO_APIC*/
diff -Nru a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
--- a/arch/x86_64/kernel/nmi.c	2004-12-24 13:36:48 -08:00
+++ b/arch/x86_64/kernel/nmi.c	2004-12-24 13:36:48 -08:00
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/sysdev.h>
 #include <linux/nmi.h>
+#include <linux/sysctl.h>
 
 #include <asm/smp.h>
 #include <asm/mtrr.h>
@@ -54,7 +55,7 @@
  * -1: the lapic NMI watchdog is disabled, but can be enabled
  */
 int nmi_active;		/* oprofile uses this */
-static int panic_on_timeout;
+int panic_on_timeout;
 
 unsigned int nmi_watchdog = NMI_DEFAULT;
 static unsigned int nmi_hz = HZ;
@@ -344,8 +345,6 @@
 	nmi_active = 1;
 }
 
-static spinlock_t nmi_print_lock = SPIN_LOCK_UNLOCKED;
-
 /*
  * the best way to detect whether a CPU has a 'hard lockup' problem
  * is to check it's local APIC timer IRQ counts. If they are not
@@ -395,21 +394,7 @@
 				alert_counter[cpu] = 0; 
 				return;
 			} 
-			spin_lock(&nmi_print_lock);
-			/*
-			 * We are in trouble anyway, lets at least try
-			 * to get a message out.
-			 */
-			bust_spinlocks(1);
-			printk("NMI Watchdog detected LOCKUP on CPU%d, registers:\n", cpu);
-			show_registers(regs);
-			if (panic_on_timeout || panic_on_oops)
-				panic("nmi watchdog");
-			printk("console shuts up ...\n");
-			console_silent();
-			spin_unlock(&nmi_print_lock);
-			bust_spinlocks(0);
-			do_exit(SIGSEGV);
+			die_nmi("NMI Watchdog detected LOCKUP on CPU%d", regs);
 		}
 	} else {
 		last_irq_sums[cpu] = sum;
@@ -446,6 +431,49 @@
 {
 	nmi_callback = dummy_nmi_callback;
 }
+
+#ifdef CONFIG_SYSCTL
+
+static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu)
+{
+	unsigned char reason = get_nmi_reason();
+	char buf[64];
+
+	if (!(reason & 0xc0)) {
+		sprintf(buf, "NMI received for unknown reason %02x\n", reason);
+		die_nmi(buf,regs);
+	}
+	return 0;
+}
+
+/*
+ * proc handler for /proc/sys/kernel/unknown_nmi_panic
+ */
+int proc_unknown_nmi_panic(struct ctl_table *table, int write, struct file *file,
+			void __user *buffer, size_t *length, loff_t *ppos)
+{
+	int old_state;
+
+	old_state = unknown_nmi_panic;
+	proc_dointvec(table, write, file, buffer, length, ppos);
+	if (!!old_state == !!unknown_nmi_panic)
+		return 0;
+
+	if (unknown_nmi_panic) {
+		if (reserve_lapic_nmi() < 0) {
+			unknown_nmi_panic = 0;
+			return -EBUSY;
+		} else {
+			set_nmi_callback(unknown_nmi_panic_callback);
+		}
+	} else {
+		release_lapic_nmi();
+		unset_nmi_callback();
+	}
+	return 0;
+}
+
+#endif
 
 EXPORT_SYMBOL(nmi_active);
 EXPORT_SYMBOL(nmi_watchdog);
diff -Nru a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
--- a/arch/x86_64/kernel/pci-gart.c	2004-12-24 13:36:48 -08:00
+++ b/arch/x86_64/kernel/pci-gart.c	2004-12-24 13:36:48 -08:00
@@ -22,10 +22,10 @@
 #include <linux/module.h>
 #include <linux/topology.h>
 #include <linux/interrupt.h>
+#include <linux/bitops.h>
 #include <asm/atomic.h>
 #include <asm/io.h>
 #include <asm/mtrr.h>
-#include <asm/bitops.h>
 #include <asm/pgtable.h>
 #include <asm/proto.h>
 #include <asm/cacheflush.h>
@@ -81,7 +81,7 @@
 
 #define for_all_nb(dev) \
 	dev = NULL;	\
-	while ((dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL)\
+	while ((dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL)\
 	     if (dev->bus->number == 0 && 				     \
 		    (PCI_SLOT(dev->devfn) >= 24) && (PCI_SLOT(dev->devfn) <= 31))
 
@@ -236,11 +236,21 @@
 			mmu = 1;
 		if (no_iommu || dma_mask < 0xffffffffUL) { 
 			if (high) {
+				free_pages((unsigned long)memory,
+					   get_order(size));
+
+				if (swiotlb) {
+					return
+					swiotlb_alloc_coherent(dev, size,
+							       dma_handle,
+							       gfp);
+				}
+
 				if (!(gfp & GFP_DMA)) { 
 					gfp |= GFP_DMA; 
 					goto again;
 				}
-				goto free;
+				return NULL;
 			}
 			mmu = 0; 
 		} 	
@@ -260,9 +270,7 @@
 error:
 	if (panic_on_overflow)
 		panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n", size);
-free:
 	free_pages((unsigned long)memory, get_order(size)); 
-	/* XXX Could use the swiotlb pool here too */
 	return NULL; 
 }
 
@@ -273,6 +281,11 @@
 void dma_free_coherent(struct device *dev, size_t size,
 			 void *vaddr, dma_addr_t bus)
 {
+	if (swiotlb) {
+		swiotlb_free_coherent(dev, size, vaddr, bus);
+		return;
+	}
+
 	dma_unmap_single(dev, bus, size, 0);
 	free_pages((unsigned long)vaddr, get_order(size)); 		
 }
diff -Nru a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
--- a/arch/x86_64/kernel/process.c	2004-12-24 13:36:56 -08:00
+++ b/arch/x86_64/kernel/process.c	2004-12-24 13:36:56 -08:00
@@ -54,6 +54,9 @@
 
 atomic_t hlt_counter = ATOMIC_INIT(0);
 
+unsigned long boot_option_idle_override = 0;
+EXPORT_SYMBOL(boot_option_idle_override);
+
 /*
  * Powermanagement idle function, if any..
  */
@@ -196,6 +199,7 @@
 		pm_idle = poll_idle;
 	}
 
+	boot_option_idle_override = 1;
 	return 1;
 }
 
@@ -359,7 +363,6 @@
 	if (rsp == ~0UL) {
 		childregs->rsp = (unsigned long)childregs;
 	}
-	p->set_child_tid = p->clear_child_tid = NULL;
 
 	p->thread.rsp = (unsigned long) childregs;
 	p->thread.rsp0 = (unsigned long) (childregs+1);
@@ -542,8 +545,11 @@
 	if (IS_ERR(filename)) 
 		return error;
 	error = do_execve(filename, argv, envp, &regs); 
-	if (error == 0)
+	if (error == 0) {
+		task_lock(current);
 		current->ptrace &= ~PT_DTRACE;
+		task_unlock(current);
+	}
 	putname(filename);
 	return error;
 }
diff -Nru a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
--- a/arch/x86_64/kernel/ptrace.c	2004-12-24 13:36:33 -08:00
+++ b/arch/x86_64/kernel/ptrace.c	2004-12-24 13:36:33 -08:00
@@ -323,6 +323,8 @@
 			ret = 0;
 			break;
 		case offsetof(struct user, u_debugreg[7]):
+			/* See arch/i386/kernel/ptrace.c for an explanation of
+			 * this awkward check.*/
 				  data &= ~DR_CONTROL_RESERVED;
 				  for(i=0; i<4; i++)
 					  if ((0x5454 >> ((data >> (16 + 4*i)) & 0xf)) & 1)
@@ -395,7 +397,7 @@
 		long tmp;
 
 		ret = 0;
-		if (child->state == TASK_ZOMBIE)	/* already dead */
+		if (child->exit_state == EXIT_ZOMBIE)	/* already dead */
 			break;
 		clear_tsk_thread_flag(child, TIF_SINGLESTEP);
 		child->exit_code = SIGKILL;
diff -Nru a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
--- a/arch/x86_64/kernel/setup.c	2004-12-24 13:36:17 -08:00
+++ b/arch/x86_64/kernel/setup.c	2004-12-24 13:36:17 -08:00
@@ -56,6 +56,7 @@
 #include <asm/smp.h>
 #include <asm/proto.h>
 #include <asm/setup.h>
+#include <asm/mach_apic.h>
 
 /*
  * Machine setup..
@@ -710,7 +711,6 @@
 #ifdef CONFIG_SMP
 	u32 	eax, ebx, ecx, edx;
 	int 	index_lsb, index_msb, tmp;
-	int	initial_apic_id;
 	int 	cpu = smp_processor_id();
 	
 	if (!cpu_has(c, X86_FEATURE_HT))
@@ -745,8 +745,7 @@
 		}
 		if (index_lsb != index_msb )
 			index_msb++;
-		initial_apic_id = hard_smp_processor_id();
-		phys_proc_id[cpu] = initial_apic_id >> index_msb;
+		phys_proc_id[cpu] = phys_pkg_id(index_msb);
 		
 		printk(KERN_INFO  "CPU: Physical Processor ID: %d\n",
 		       phys_proc_id[cpu]);
@@ -754,134 +753,12 @@
 #endif
 }
 	
-#define LVL_1_INST	1
-#define LVL_1_DATA	2
-#define LVL_2		3
-#define LVL_3		4
-#define LVL_TRACE	5
-
-struct _cache_table
-{
-	unsigned char descriptor;
-	char cache_type;
-	short size;
-};
-
-/* all the cache descriptor types we care about (no TLB or trace cache entries) */
-static struct _cache_table cache_table[] __initdata =
-{
-	{ 0x06, LVL_1_INST, 8 },
-	{ 0x08, LVL_1_INST, 16 },
-	{ 0x0a, LVL_1_DATA, 8 },
-	{ 0x0c, LVL_1_DATA, 16 },
-	{ 0x22, LVL_3,      512 },
-	{ 0x23, LVL_3,      1024 },
-	{ 0x25, LVL_3,      2048 },
-	{ 0x29, LVL_3,      4096 },
-	{ 0x2c, LVL_1_DATA, 32 },
-	{ 0x30, LVL_1_INST, 32 },
-	{ 0x39, LVL_2,      128 },
-	{ 0x3b, LVL_2,      128 },
-	{ 0x3c, LVL_2,      256 },
-	{ 0x41, LVL_2,      128 },
-	{ 0x42, LVL_2,      256 },
-	{ 0x43, LVL_2,      512 },
-	{ 0x44, LVL_2,      1024 },
-	{ 0x45, LVL_2,      2048 },
-	{ 0x60, LVL_1_DATA, 16 },
-	{ 0x66, LVL_1_DATA, 8 },
-	{ 0x67, LVL_1_DATA, 16 },
-	{ 0x68, LVL_1_DATA, 32 },
-	{ 0x70, LVL_TRACE,  12 },
-	{ 0x71, LVL_TRACE,  16 },
-	{ 0x72, LVL_TRACE,  32 },
-	{ 0x79, LVL_2,      128 },
-	{ 0x7a, LVL_2,      256 },
-	{ 0x7b, LVL_2,      512 },
-	{ 0x7c, LVL_2,      1024 },
-	{ 0x82, LVL_2,      256 },
-	{ 0x83, LVL_2,      512 },
-	{ 0x84, LVL_2,      1024 },
-	{ 0x85, LVL_2,      2048 },
-	{ 0x86, LVL_2,      512 },
-	{ 0x87, LVL_2,      1024 },
-	{ 0x00, 0, 0}
-};
-
 static void __init init_intel(struct cpuinfo_x86 *c)
 {
 	/* Cache sizes */
-	unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; 
 	unsigned n;
 
-	if (c->cpuid_level > 1) {
-		/* supports eax=2  call */
-		int i, j, n;
-		int regs[4];
-		unsigned char *dp = (unsigned char *)regs;
-
-		/* Number of times to iterate */
-		n = cpuid_eax(2) & 0xFF;
-
-		for ( i = 0 ; i < n ; i++ ) {
-			cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]);
-			
-			/* If bit 31 is set, this is an unknown format */
-			for ( j = 0 ; j < 3 ; j++ ) {
-				if ( regs[j] < 0 ) regs[j] = 0;
-			}
-
-			/* Byte 0 is level count, not a descriptor */
-			for ( j = 1 ; j < 16 ; j++ ) {
-				unsigned char des = dp[j];
-				unsigned char k = 0;
-
-				/* look up this descriptor in the table */
-				while (cache_table[k].descriptor != 0)
-				{
-					if (cache_table[k].descriptor == des) {
-						switch (cache_table[k].cache_type) {
-						case LVL_1_INST:
-							l1i += cache_table[k].size;
-							break;
-						case LVL_1_DATA:
-							l1d += cache_table[k].size;
-							break;
-						case LVL_2:
-							l2 += cache_table[k].size;
-							break;
-						case LVL_3:
-							l3 += cache_table[k].size;
-							break;
-						case LVL_TRACE:
-							trace += cache_table[k].size;
-							break;
-						}
-
-						break;
-					}
-
-					k++;
-				}
-			}
-		}
-
-		if (trace)
-			printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
-		else if (l1i)
-			printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
-		if (l1d)
-			printk(", L1 D cache: %dK\n", l1d);
-		else
-			printk("\n"); 
-		if (l2)
-			printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
-		if (l3)
-			printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
-
-		c->x86_cache_size = l2 ? l2 : (l1i+l1d);
-	}
-
+	init_intel_cacheinfo(c);
 	n = cpuid_eax(0x80000000);
 	if (n >= 0x80000008) {
 		unsigned eax = cpuid_eax(0x80000008);
@@ -1031,7 +908,9 @@
 			boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
 	}
 
+#ifdef CONFIG_X86_MCE
 	mcheck_init(c);
+#endif
 }
  
 
@@ -1070,10 +949,10 @@
 	        "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL,
 
 		/* AMD-defined */
-		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+		"pni", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL,
-		NULL, NULL, NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
+		NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
 
 		/* Transmeta-defined */
 		"recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
@@ -1092,6 +971,12 @@
 		"tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+
+		/* AMD-defined (#2) */
+		"lahf_lm", "htvalid", 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
 	};
 	static char *x86_power_flags[] = { 
 		"ts",	/* temperature sensor */
@@ -1132,7 +1017,7 @@
 		seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
 	
 #ifdef CONFIG_X86_HT
-	if (cpu_has_ht) {
+	if (smp_num_siblings > 1) {
 		seq_printf(m, "physical id\t: %d\n", phys_proc_id[c - cpu_data]);
 		seq_printf(m, "siblings\t: %d\n", smp_num_siblings);
 	}
diff -Nru a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
--- a/arch/x86_64/kernel/setup64.c	2004-12-24 13:36:31 -08:00
+++ b/arch/x86_64/kernel/setup64.c	2004-12-24 13:36:31 -08:00
@@ -11,11 +11,11 @@
 #include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
+#include <linux/bitops.h>
 #include <asm/pda.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/desc.h>
-#include <asm/bitops.h>
 #include <asm/atomic.h>
 #include <asm/mmu_context.h>
 #include <asm/smp.h>
@@ -43,80 +43,27 @@
 
 unsigned long __supported_pte_mask = ~0UL;
 static int do_not_nx __initdata = 0;
-unsigned long vm_stack_flags = __VM_STACK_FLAGS; 
-unsigned long vm_stack_flags32 = __VM_STACK_FLAGS; 
-unsigned long vm_data_default_flags = __VM_DATA_DEFAULT_FLAGS; 
-unsigned long vm_data_default_flags32 = __VM_DATA_DEFAULT_FLAGS; 
-unsigned long vm_force_exec32 = PROT_EXEC; 
 
 /* noexec=on|off
 Control non executable mappings for 64bit processes.
 
-on	Enable
+on	Enable(default)
 off	Disable
-noforce (default) Don't enable by default for heap/stack/data, 
-	but allow PROT_EXEC to be effective
-
 */ 
 static int __init nonx_setup(char *str)
 {
 	if (!strcmp(str, "on")) {
                 __supported_pte_mask |= _PAGE_NX; 
  		do_not_nx = 0; 
- 		vm_data_default_flags &= ~VM_EXEC; 
- 		vm_stack_flags &= ~VM_EXEC;  
-	} else if (!strcmp(str, "noforce") || !strcmp(str, "off")) {
-		do_not_nx = (str[0] == 'o');
-		if (do_not_nx)
-			__supported_pte_mask &= ~_PAGE_NX; 
-		vm_data_default_flags |= VM_EXEC; 
-		vm_stack_flags |= VM_EXEC;
+	} else if (!strcmp(str, "off")) {
+		do_not_nx = 1;
+		__supported_pte_mask &= ~_PAGE_NX;
         } 
         return 1;
 } 
 
 __setup("noexec=", nonx_setup); 
 
-/* noexec32=opt{,opt} 
-
-Control the no exec default for 32bit processes. Can be also overwritten
-per executable using ELF header flags (e.g. needed for the X server)
-Requires noexec=on or noexec=noforce to be effective.
-
-Valid options: 
-   all,on    Heap,stack,data is non executable. 	
-   off       (default) Heap,stack,data is executable
-   stack     Stack is non executable, heap/data is.
-   force     Don't imply PROT_EXEC for PROT_READ 
-   compat    (default) Imply PROT_EXEC for PROT_READ
-
-*/
- static int __init nonx32_setup(char *s)
- {
-	 while (*s) {
-		if (!strncmp(s, "all", 3) || !strncmp(s,"on",2)) {
-			vm_data_default_flags32 &= ~VM_EXEC; 
-			vm_stack_flags32 &= ~VM_EXEC;  
-		} else if (!strncmp(s, "off",3)) {
-			vm_data_default_flags32 |= VM_EXEC; 
-			vm_stack_flags32 |= VM_EXEC;  
-		} else if (!strncmp(s, "stack", 5)) {
-			vm_data_default_flags32 |= VM_EXEC; 
-			vm_stack_flags32 &= ~VM_EXEC;  		
-		} else if (!strncmp(s, "force",5)) {
-			vm_force_exec32 = 0; 
-		} else if (!strncmp(s, "compat",5)) {
-			vm_force_exec32 = PROT_EXEC;
-		} 
-		s += strcspn(s, ",");
-		if (*s == ',')
-			++s;
-	 }
-	 return 1;
-} 
-
-__setup("noexec32=", nonx32_setup); 
-
 /*
  * Great future plan:
  * Declare PDA itself and support (irqstack,tss,pml4) as per cpu data.
@@ -269,8 +216,8 @@
 
 	cpu_gdt_descr[cpu].size = GDT_SIZE;
 	cpu_gdt_descr[cpu].address = (unsigned long)cpu_gdt_table[cpu];
-	__asm__ __volatile__("lgdt %0": "=m" (cpu_gdt_descr[cpu]));
-	__asm__ __volatile__("lidt %0": "=m" (idt_descr));
+	asm volatile("lgdt %0" :: "m" (cpu_gdt_descr[cpu]));
+	asm volatile("lidt %0" :: "m" (idt_descr));
 
 	memcpy(me->thread.tls_array, cpu_gdt_table[cpu], GDT_ENTRY_TLS_ENTRIES * 8);
 
diff -Nru a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
--- a/arch/x86_64/kernel/signal.c	2004-12-24 13:37:02 -08:00
+++ b/arch/x86_64/kernel/signal.c	2004-12-24 13:37:02 -08:00
@@ -325,7 +325,7 @@
 
 	set_fs(USER_DS);
 	if (regs->eflags & TF_MASK) {
-		if (current->ptrace & PT_PTRACED) {
+		if ((current->ptrace & (PT_PTRACED | PT_DTRACE)) == (PT_PTRACED | PT_DTRACE)) {
 			ptrace_notify(SIGTRAP);
 		} else {
 			regs->eflags &= ~TF_MASK;
@@ -357,7 +357,7 @@
 #endif
 
 	/* Are we from a system call? */
-	if (regs->orig_rax >= 0) {
+	if ((long)regs->orig_rax >= 0) {
 		/* If so, check system call restarting.. */
 		switch (regs->rax) {
 		        case -ERESTART_RESTARTBLOCK:
@@ -442,7 +442,7 @@
 
  no_signal:
 	/* Did we come from a system call? */
-	if (regs->orig_rax >= 0) {
+	if ((long)regs->orig_rax >= 0) {
 		/* Restart the system call - no handlers present */
 		long res = regs->rax;
 		if (res == -ERESTARTNOHAND ||
diff -Nru a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
--- a/arch/x86_64/kernel/smp.c	2004-12-24 13:37:43 -08:00
+++ b/arch/x86_64/kernel/smp.c	2004-12-24 13:37:43 -08:00
@@ -24,105 +24,7 @@
 #include <asm/mtrr.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
-
-/*
- * the following functions deal with sending IPIs between CPUs.
- *
- * We use 'broadcast', CPU->CPU IPIs and self-IPIs too.
- */
-
-static inline unsigned int __prepare_ICR (unsigned int shortcut, int vector)
-{
-	unsigned int icr =  APIC_DM_FIXED | shortcut | vector | APIC_DEST_LOGICAL;
-	if (vector == KDB_VECTOR) 
-		icr = (icr & (~APIC_VECTOR_MASK)) | APIC_DM_NMI; 		
-	return icr;
-}
-
-static inline int __prepare_ICR2 (unsigned int mask)
-{
-	return SET_APIC_DEST_FIELD(mask);
-}
-
-static inline void __send_IPI_shortcut(unsigned int shortcut, int vector)
-{
-	/*
-	 * Subtle. In the case of the 'never do double writes' workaround
-	 * we have to lock out interrupts to be safe.  As we don't care
-	 * of the value read we use an atomic rmw access to avoid costly
-	 * cli/sti.  Otherwise we use an even cheaper single atomic write
-	 * to the APIC.
-	 */
-	unsigned int cfg;
-
-	/*
-	 * Wait for idle.
-	 */
-	apic_wait_icr_idle();
-
-	/*
-	 * No need to touch the target chip field
-	 */
-	cfg = __prepare_ICR(shortcut, vector);
-
-	/*
-	 * Send the IPI. The write to APIC_ICR fires this off.
-	 */
-	apic_write_around(APIC_ICR, cfg);
-}
-
-static inline void send_IPI_allbutself(int vector)
-{
-	/*
-	 * if there are no other CPUs in the system then
-	 * we get an APIC send error if we try to broadcast.
-	 * thus we have to avoid sending IPIs in this case.
-	 */
-	if (num_online_cpus() > 1)
-		__send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
-}
-
-static inline void send_IPI_all(int vector)
-{
-	__send_IPI_shortcut(APIC_DEST_ALLINC, vector);
-}
-
-void send_IPI_self(int vector)
-{
-	__send_IPI_shortcut(APIC_DEST_SELF, vector);
-}
-
-static inline void send_IPI_mask(cpumask_t cpumask, int vector)
-{
-	unsigned long mask = cpus_addr(cpumask)[0];
-	unsigned long cfg;
-	unsigned long flags;
-
-	local_save_flags(flags);
-	local_irq_disable();
-
-	/*
-	 * Wait for idle.
-	 */
-	apic_wait_icr_idle();
-
-	/*
-	 * prepare target chip field
-	 */
-	cfg = __prepare_ICR2(mask);
-	apic_write_around(APIC_ICR2, cfg);
-
-	/*
-	 * program the ICR 
-	 */
-	cfg = __prepare_ICR(0, vector);
-	
-	/*
-	 * Send the IPI. The write to APIC_ICR fires this off.
-	 */
-	apic_write_around(APIC_ICR, cfg);
-	local_irq_restore(flags);
-}
+#include <asm/mach_apic.h>
 
 /*
  *	Smarter SMP flushing macros. 
@@ -405,11 +307,13 @@
 
 	/* Wait for response */
 	while (atomic_read(&data.started) != cpus)
-		barrier();
+		cpu_relax();
 
-	if (wait)
-		while (atomic_read(&data.finished) != cpus)
-			barrier();
+	if (!wait)
+		return;
+
+	while (atomic_read(&data.finished) != cpus)
+		cpu_relax();
 }
 
 /*
@@ -459,11 +363,10 @@
 	int nolock = 0;
 	/* Don't deadlock on the call lock in panic */
 	if (!spin_trylock(&call_lock)) {
-		udelay(100);
 		/* ignore locking because we have paniced anyways */
 		nolock = 1;
 	}
-	__smp_call_function(smp_really_stop_cpu, NULL, 1, 0);
+	__smp_call_function(smp_really_stop_cpu, NULL, 0, 0);
 	if (!nolock)
 		spin_unlock(&call_lock);
 	smp_stop_cpu();
diff -Nru a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
--- a/arch/x86_64/kernel/smpboot.c	2004-12-24 13:37:33 -08:00
+++ b/arch/x86_64/kernel/smpboot.c	2004-12-24 13:37:33 -08:00
@@ -56,15 +56,12 @@
 
 /* Number of siblings per CPU package */
 int smp_num_siblings = 1;
-char phys_proc_id[NR_CPUS]; /* Package ID of each logical CPU */
+/* Package ID of each logical CPU */
+u8 phys_proc_id[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
 
 /* Bitmask of currently online CPUs */
 cpumask_t cpu_online_map;
 
-/* which logical CPU number maps to which CPU (physical APIC ID) */
-volatile char x86_cpu_to_apicid[NR_CPUS];
-EXPORT_SYMBOL(x86_cpu_to_apicid);
-
 static cpumask_t cpu_callin_map;
 cpumask_t cpu_callout_map;
 static cpumask_t smp_commenced_mask;
@@ -658,6 +655,8 @@
 		cpu_clear(cpu, cpu_callout_map); /* was set here (do_boot_cpu()) */
 		clear_bit(cpu, &cpu_initialized); /* was set by cpu_init() */
 		cpucount--;
+		x86_cpu_to_apicid[cpu] = BAD_APICID;
+		x86_cpu_to_log_apicid[cpu] = BAD_APICID;
 	}
 }
 
diff -Nru a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
--- a/arch/x86_64/kernel/time.c	2004-12-24 13:37:01 -08:00
+++ b/arch/x86_64/kernel/time.c	2004-12-24 13:37:01 -08:00
@@ -34,6 +34,7 @@
 #include <asm/hpet.h>
 #include <asm/sections.h>
 #include <linux/cpufreq.h>
+#include <linux/hpet.h>
 #ifdef CONFIG_X86_LOCAL_APIC
 #include <asm/apic.h>
 #endif
@@ -52,10 +53,10 @@
 spinlock_t i8253_lock = SPIN_LOCK_UNLOCKED;
 
 static int nohpet __initdata = 0;
+static int notsc __initdata = 0;
 
 #undef HPET_HACK_ENABLE_DANGEROUS
 
-
 unsigned int cpu_khz;					/* TSC clocks / usec, not used here */
 unsigned long hpet_period;				/* fsecs / HPET clock */
 unsigned long hpet_tick;				/* HPET clocks / interrupt */
@@ -330,7 +331,7 @@
 	    print_symbol("rip %s)\n", regs->rip);
     }
 
-    if (lost_count == 100 && !warned) {
+    if (lost_count == 1000 && !warned) {
 	    printk(KERN_WARNING
 		   "warning: many lost ticks.\n"
 		   KERN_WARNING "Your time source seems to be instable or "
@@ -427,6 +428,9 @@
  */
 
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 
 /*
  * In the SMP case we use the local APIC timer interrupt to do the profiling,
@@ -723,31 +727,59 @@
 	return (end - start) / 50;
 }
 
-static int hpet_init(void)
+#ifdef	CONFIG_HPET
+static __init int late_hpet_init(void)
 {
-	unsigned int cfg, id;
+	struct hpet_data	hd;
+	unsigned int 		ntimer;
 
 	if (!vxtime.hpet_address)
-		return -1;
-	set_fixmap_nocache(FIX_HPET_BASE, vxtime.hpet_address);
-	__set_fixmap(VSYSCALL_HPET, vxtime.hpet_address, PAGE_KERNEL_VSYSCALL_NOCACHE);
+          return -1;
 
-/*
- * Read the period, compute tick and quotient.
- */
+	memset(&hd, 0, sizeof (hd));
 
-	id = hpet_readl(HPET_ID);
+	ntimer = hpet_readl(HPET_ID);
+	ntimer = (ntimer & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT;
+	ntimer++;
 
-	if (!(id & HPET_ID_VENDOR) || !(id & HPET_ID_NUMBER) ||
-	    !(id & HPET_ID_LEGSUP))
-		return -1;
+	/*
+	 * Register with driver.
+	 * Timer0 and Timer1 is used by platform.
+	 */
+	hd.hd_phys_address = vxtime.hpet_address;
+	hd.hd_address = (void *)fix_to_virt(FIX_HPET_BASE);
+	hd.hd_nirqs = ntimer;
+	hd.hd_flags = HPET_DATA_PLATFORM;
+	hpet_reserve_timer(&hd, 0);
+#ifdef	CONFIG_HPET_EMULATE_RTC
+	hpet_reserve_timer(&hd, 1);
+#endif
+	hd.hd_irq[0] = HPET_LEGACY_8254;
+	hd.hd_irq[1] = HPET_LEGACY_RTC;
+	if (ntimer > 2) {
+		struct hpet		*hpet;
+		struct hpet_timer	*timer;
+		int			i;
 
-	hpet_period = hpet_readl(HPET_PERIOD);
-	if (hpet_period < 100000 || hpet_period > 100000000)
-		return -1;
+		hpet = (struct hpet *) fix_to_virt(FIX_HPET_BASE);
 
-	hpet_tick = (1000000000L * (USEC_PER_SEC / HZ) + hpet_period / 2) /
-		hpet_period;
+		for (i = 2, timer = &hpet->hpet_timers[2]; i < ntimer;
+		     timer++, i++)
+			hd.hd_irq[i] = (timer->hpet_config &
+					Tn_INT_ROUTE_CNF_MASK) >>
+				Tn_INT_ROUTE_CNF_SHIFT;
+
+	}
+
+	hpet_alloc(&hd);
+	return 0;
+}
+fs_initcall(late_hpet_init);
+#endif
+
+static int hpet_timer_stop_set_go(unsigned long tick)
+{
+	unsigned int cfg;
 
 /*
  * Stop the timers and reset the main counter.
@@ -779,6 +811,40 @@
 	return 0;
 }
 
+static int hpet_init(void)
+{
+	unsigned int id;
+
+	if (!vxtime.hpet_address)
+		return -1;
+	set_fixmap_nocache(FIX_HPET_BASE, vxtime.hpet_address);
+	__set_fixmap(VSYSCALL_HPET, vxtime.hpet_address, PAGE_KERNEL_VSYSCALL_NOCACHE);
+
+/*
+ * Read the period, compute tick and quotient.
+ */
+
+	id = hpet_readl(HPET_ID);
+
+	if (!(id & HPET_ID_VENDOR) || !(id & HPET_ID_NUMBER) ||
+	    !(id & HPET_ID_LEGSUP))
+		return -1;
+
+	hpet_period = hpet_readl(HPET_PERIOD);
+	if (hpet_period < 100000 || hpet_period > 100000000)
+		return -1;
+
+	hpet_tick = (1000000000L * (USEC_PER_SEC / HZ) + hpet_period / 2) /
+		hpet_period;
+
+	return hpet_timer_stop_set_go(hpet_tick);
+}
+
+static int hpet_reenable(void)
+{
+	return hpet_timer_stop_set_go(hpet_tick);
+}
+
 void __init pit_init(void)
 {
 	unsigned long flags;
@@ -856,15 +922,34 @@
 {
 	char *timetype;
 
-	if (vxtime.hpet_address) {
+	/*
+	 * AMD systems with more than one CPU don't have fully synchronized
+	 * TSCs. Always use HPET gettimeofday for these, although it is slower.
+	 * Intel SMP systems usually have synchronized TSCs, so use always
+	 * the TSC.
+	 *
+	 * Exceptions:
+	 * IBM Summit2 checked by oem_force_hpet_timer().
+ 	 * AMD dual core may also not need HPET. Check me.
+	 *
+	 * Can be turned off with "notsc".
+	 */
+	if (num_online_cpus() > 1 &&
+	    boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+		notsc = 1;
+	/* Some systems will want to disable TSC and use HPET. */
+	if (oem_force_hpet_timer())
+		notsc = 1;
+	if (vxtime.hpet_address && notsc) {
 		timetype = "HPET";
 		vxtime.last = hpet_readl(HPET_T0_CMP) - hpet_tick;
 		vxtime.mode = VXTIME_HPET;
 		do_gettimeoffset = do_gettimeoffset_hpet;
 	} else {
-		timetype = "PIT/TSC";
+		timetype = vxtime.hpet_address ? "HPET/TSC" : "PIT/TSC";
 		vxtime.mode = VXTIME_TSC;
 	}
+
 	printk(KERN_INFO "time.c: Using %s based timekeeping.\n", timetype);
 }
 
@@ -872,7 +957,7 @@
 
 static long clock_cmos_diff;
 
-static int time_suspend(struct sys_device *dev, u32 state)
+static int timer_suspend(struct sys_device *dev, u32 state)
 {
 	/*
 	 * Estimate time zone so that set_time can update the clock
@@ -882,10 +967,15 @@
 	return 0;
 }
 
-static int time_resume(struct sys_device *dev)
+static int timer_resume(struct sys_device *dev)
 {
 	unsigned long flags;
-	unsigned long sec = get_cmos_time() + clock_cmos_diff;
+	unsigned long sec;
+
+	if (vxtime.hpet_address)
+		hpet_reenable();
+
+	sec = get_cmos_time() + clock_cmos_diff;
 	write_seqlock_irqsave(&xtime_lock,flags);
 	xtime.tv_sec = sec;
 	xtime.tv_nsec = 0;
@@ -893,24 +983,24 @@
 	return 0;
 }
 
-static struct sysdev_class pit_sysclass = {
-	.resume = time_resume,
-	.suspend = time_suspend,
-	set_kset_name("pit"),
+static struct sysdev_class timer_sysclass = {
+	.resume = timer_resume,
+	.suspend = timer_suspend,
+	set_kset_name("timer"),
 };
 
 
 /* XXX this driverfs stuff should probably go elsewhere later -john */
-static struct sys_device device_i8253 = {
+static struct sys_device device_timer = {
 	.id	= 0,
-	.cls	= &pit_sysclass,
+	.cls	= &timer_sysclass,
 };
 
 static int time_init_device(void)
 {
-	int error = sysdev_class_register(&pit_sysclass);
+	int error = sysdev_class_register(&timer_sysclass);
 	if (!error)
-		error = sysdev_register(&device_i8253);
+		error = sysdev_register(&device_timer);
 	return error;
 }
 
@@ -1151,3 +1241,14 @@
 } 
 
 __setup("nohpet", nohpet_setup);
+
+
+static int __init notsc_setup(char *s)
+{
+	notsc = 1;
+	return 0;
+}
+
+__setup("notsc", notsc_setup);
+
+
diff -Nru a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
--- a/arch/x86_64/kernel/traps.c	2004-12-24 13:36:17 -08:00
+++ b/arch/x86_64/kernel/traps.c	2004-12-24 13:36:17 -08:00
@@ -43,9 +43,11 @@
 #include <asm/pgalloc.h>
 #include <asm/pda.h>
 #include <asm/proto.h>
+#include <asm/nmi.h>
 
 #include <linux/irq.h>
 
+
 extern struct gate_struct idt_table[256]; 
 
 asmlinkage void divide_error(void);
@@ -72,6 +74,17 @@
 asmlinkage void call_debug(void);
 
 struct notifier_block *die_chain;
+static spinlock_t die_notifier_lock = SPIN_LOCK_UNLOCKED;
+
+int register_die_notifier(struct notifier_block *nb)
+{
+	int err = 0;
+	unsigned long flags;
+	spin_lock_irqsave(&die_notifier_lock, flags);
+	err = notifier_chain_register(&die_chain, nb);
+	spin_unlock_irqrestore(&die_notifier_lock, flags);
+	return err;
+}
 
 static inline void conditional_sti(struct pt_regs *regs)
 {
@@ -376,6 +389,22 @@
 		die(str, regs, err);
 }
 
+void die_nmi(char *str, struct pt_regs *regs)
+{
+	oops_begin();
+	/*
+	 * We are in trouble anyway, lets at least try
+	 * to get a message out.
+	 */
+	printk(str, safe_smp_processor_id());
+	show_registers(regs);
+	if (panic_on_timeout || panic_on_oops)
+		panic("nmi watchdog");
+	printk("console shuts up ...\n");
+	oops_end();
+	do_exit(SIGSEGV);
+}
+
 static inline unsigned long get_cr2(void)
 {
 	unsigned long address;
@@ -458,7 +487,6 @@
 }
 
 DO_ERROR_INFO( 0, SIGFPE,  "divide error", divide_error, FPE_INTDIV, regs->rip)
-DO_ERROR( 3, SIGTRAP, "int3", int3);
 DO_ERROR( 4, SIGSEGV, "overflow", overflow)
 DO_ERROR( 5, SIGSEGV, "bounds", bounds)
 DO_ERROR_INFO( 6, SIGILL,  "invalid operand", invalid_op, ILL_ILLOPN, regs->rip)
@@ -563,9 +591,13 @@
 	printk("Do you have a strange power saving mode enabled?\n");
 }
 
-asmlinkage void default_do_nmi(struct pt_regs * regs)
+asmlinkage void default_do_nmi(struct pt_regs *regs)
 {
-	unsigned char reason = inb(0x61);
+	unsigned char reason = 0;
+
+	/* Only the BSP gets external NMIs from the system.  */
+	if (!smp_processor_id())
+		reason = get_nmi_reason();
 
 	if (!(reason & 0xc0)) {
 		if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 0, SIGINT)
@@ -586,6 +618,9 @@
 	}
 	if (notify_die(DIE_NMI, "nmi", regs, reason, 0, SIGINT) == NOTIFY_STOP)
 		return; 
+
+	/* AK: following checks seem to be broken on modern chipsets. FIXME */
+
 	if (reason & 0x80)
 		mem_parity_error(reason, regs);
 	if (reason & 0x40)
@@ -601,6 +636,15 @@
 	inb(0x71);		/* dummy */
 }
 
+asmlinkage void do_int3(struct pt_regs * regs, long error_code)
+{
+	if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) == NOTIFY_STOP) {
+		return;
+	}
+	do_trap(3, SIGTRAP, "int3", regs, error_code, NULL);
+	return;
+}
+
 /* runs on IST stack. */
 asmlinkage void *do_debug(struct pt_regs * regs, unsigned long error_code)
 {
@@ -630,6 +674,10 @@
 
 	asm("movq %%db6,%0" : "=r" (condition));
 
+	if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
+						SIGTRAP) == NOTIFY_STOP) {
+		return regs;
+	}
 	conditional_sti(regs);
 
 	/* Mask out spurious debug traps due to lazy DR7 setting */
@@ -862,8 +910,8 @@
 	set_intr_gate(0,&divide_error);
 	set_intr_gate_ist(1,&debug,DEBUG_STACK);
 	set_intr_gate_ist(2,&nmi,NMI_STACK);
-	set_system_gate(3,&int3);	/* int3-5 can be called from all */
-	set_system_gate(4,&overflow);
+	set_intr_gate(3,&int3);
+	set_system_gate(4,&overflow);	/* int4-5 can be called from all */
 	set_system_gate(5,&bounds);
 	set_intr_gate(6,&invalid_op);
 	set_intr_gate(7,&device_not_available);
@@ -877,7 +925,9 @@
 	set_intr_gate(15,&spurious_interrupt_bug);
 	set_intr_gate(16,&coprocessor_error);
 	set_intr_gate(17,&alignment_check);
+#ifdef CONFIG_X86_MCE
 	set_intr_gate_ist(18,&machine_check, MCE_STACK); 
+#endif
 	set_intr_gate(19,&simd_coprocessor_error);
 
 #ifdef CONFIG_IA32_EMULATION
@@ -900,3 +950,11 @@
 	return -1; 
 } 
 __setup("oops=", oops_dummy); 
+
+static int __init kstack_setup(char *s)
+{
+	kstack_depth_to_print = simple_strtoul(s,NULL,0);
+	return 0;
+}
+__setup("kstack=", kstack_setup);
+
diff -Nru a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
--- a/arch/x86_64/kernel/vmlinux.lds.S	2004-12-24 13:36:17 -08:00
+++ b/arch/x86_64/kernel/vmlinux.lds.S	2004-12-24 13:36:17 -08:00
@@ -45,32 +45,31 @@
 	}
   __bss_end = .;
 
-  . = ALIGN(64);
+  . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
   .data.cacheline_aligned : { *(.data.cacheline_aligned) }
 
+#define AFTER(x)      BINALIGN(LOADADDR(x) + SIZEOF(x), 16)
+#define BINALIGN(x,y) (((x) + (y) - 1)  & ~((y) - 1))
+#define CACHE_ALIGN(x) BINALIGN(x, CONFIG_X86_L1_CACHE_BYTES)
+
   .vsyscall_0 -10*1024*1024: AT ((LOADADDR(.data.cacheline_aligned) + SIZEOF(.data.cacheline_aligned) + 4095) & ~(4095)) { *(.vsyscall_0) }
   __vsyscall_0 = LOADADDR(.vsyscall_0);
-  . = ALIGN(64);
-  .xtime_lock : AT ((LOADADDR(.vsyscall_0) + SIZEOF(.vsyscall_0) + 63) & ~(63)) { *(.xtime_lock) }
+  . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
+  .xtime_lock : AT CACHE_ALIGN(AFTER(.vsyscall_0)) { *(.xtime_lock) }
   xtime_lock = LOADADDR(.xtime_lock);
-  . = ALIGN(16);
-  .vxtime : AT ((LOADADDR(.xtime_lock) + SIZEOF(.xtime_lock) + 15) & ~(15)) { *(.vxtime) }
+  .vxtime : AT AFTER(.xtime_lock) { *(.vxtime) }
   vxtime = LOADADDR(.vxtime);
-  . = ALIGN(16);
-  .wall_jiffies : AT ((LOADADDR(.vxtime) + SIZEOF(.vxtime) + 15) & ~(15)) { *(.wall_jiffies) }
+  .wall_jiffies : AT AFTER(.vxtime) { *(.wall_jiffies) }
   wall_jiffies = LOADADDR(.wall_jiffies);
-  . = ALIGN(16);
-  .sys_tz : AT ((LOADADDR(.wall_jiffies) + SIZEOF(.wall_jiffies) + 15) & ~(15)) { *(.sys_tz) }
+  .sys_tz : AT AFTER(.wall_jiffies) { *(.sys_tz) }
   sys_tz = LOADADDR(.sys_tz);
-  . = ALIGN(16);
-  .sysctl_vsyscall : AT ((LOADADDR(.sys_tz) + SIZEOF(.sys_tz) + 15) & ~(15)) { *(.sysctl_vsyscall) }
-  sysctl_vsyscall = LOADADDR(.sysctl_vsyscall);
-  . = ALIGN(16);
-  .jiffies : AT ((LOADADDR(.sysctl_vsyscall) + SIZEOF(.sysctl_vsyscall) + 15) & ~(15)) { *(.jiffies) }
-  jiffies = LOADADDR(.jiffies);
-  . = ALIGN(16);
-  .xtime : AT ((LOADADDR(.jiffies) + SIZEOF(.jiffies) + 15) & ~(15)) { *(.xtime) }
+  .sysctl_vsyscall : AT AFTER(.sys_tz) { *(.sysctl_vsyscall) }
+  sysctl_vsyscall = LOADADDR(.sysctl_vsyscall); 
+  .xtime : AT AFTER(.sysctl_vsyscall) { *(.xtime) }
   xtime = LOADADDR(.xtime);
+  . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
+  .jiffies : AT CACHE_ALIGN(AFTER(.xtime)) { *(.jiffies) }
+  jiffies = LOADADDR(.jiffies);
   .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT (LOADADDR(.vsyscall_0) + 1024) { *(.vsyscall_1) }
   . = LOADADDR(.vsyscall_0) + 4096;
 
@@ -87,7 +86,9 @@
 	*(.init.text)
 	_einittext = .;
   }
+  __initdata_begin = .;
   .init.data : { *(.init.data) }
+  __initdata_end = .;
   . = ALIGN(16);
   __setup_start = .;
   .init.setup : { *(.init.setup) }
diff -Nru a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
--- a/arch/x86_64/kernel/vsyscall.c	2004-12-24 13:37:18 -08:00
+++ b/arch/x86_64/kernel/vsyscall.c	2004-12-24 13:37:18 -08:00
@@ -40,6 +40,7 @@
 #include <linux/kernel.h>
 #include <linux/timer.h>
 #include <linux/seqlock.h>
+#include <linux/jiffies.h>
 
 #include <asm/vsyscall.h>
 #include <asm/pgtable.h>
@@ -88,7 +89,7 @@
 				 __vxtime.tsc_quot) >> 32;
 			/* See comment in x86_64 do_gettimeofday. */ 
 		} else {
-			usec += ((readl(fix_to_virt(VSYSCALL_HPET) + 0xf0) -
+			usec += ((readl((void *)fix_to_virt(VSYSCALL_HPET) + 0xf0) -
 				  __vxtime.last) * __vxtime.quot) >> 32;
 		}
 	} while (read_seqretry(&__xtime_lock, sequence));
@@ -165,14 +166,12 @@
 
 static int __init vsyscall_init(void)
 {
-	if ((unsigned long) &vgettimeofday != VSYSCALL_ADDR(__NR_vgettimeofday))
-		panic("vgettimeofday link addr broken");
-	if ((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime))
-		panic("vtime link addr broken");
-	if (VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE))
-		panic("fixmap first vsyscall %lx should be %lx", __fix_to_virt(VSYSCALL_FIRST_PAGE),
-		      VSYSCALL_ADDR(0));
+        BUG_ON(((unsigned long) &vgettimeofday != 
+		      VSYSCALL_ADDR(__NR_vgettimeofday)));
+	BUG_ON((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime));
+	BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
 	map_vsyscall();
+	sysctl_vsyscall = 1; 
 
 	return 0;
 }
diff -Nru a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
--- a/arch/x86_64/kernel/x8664_ksyms.c	2004-12-24 13:36:19 -08:00
+++ b/arch/x86_64/kernel/x8664_ksyms.c	2004-12-24 13:36:19 -08:00
@@ -32,6 +32,7 @@
 #include <asm/unistd.h>
 #include <asm/delay.h>
 #include <asm/tlbflush.h>
+#include <asm/kdebug.h>
 
 extern spinlock_t rtc_lock;
 
@@ -193,10 +194,11 @@
 EXPORT_SYMBOL(empty_zero_page);
 
 #ifdef CONFIG_HAVE_DEC_LOCK
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
 #endif
 
 EXPORT_SYMBOL(die_chain);
+EXPORT_SYMBOL(register_die_notifier);
 
 #ifdef CONFIG_SMP
 EXPORT_SYMBOL(cpu_sibling_map);
diff -Nru a/arch/x86_64/lib/bitops.c b/arch/x86_64/lib/bitops.c
--- a/arch/x86_64/lib/bitops.c	2004-12-24 13:36:30 -08:00
+++ b/arch/x86_64/lib/bitops.c	2004-12-24 13:36:30 -08:00
@@ -1,5 +1,5 @@
 #include <linux/module.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 #undef find_first_zero_bit
 #undef find_next_zero_bit
diff -Nru a/arch/x86_64/lib/bitstr.c b/arch/x86_64/lib/bitstr.c
--- a/arch/x86_64/lib/bitstr.c	2004-12-24 13:36:48 -08:00
+++ b/arch/x86_64/lib/bitstr.c	2004-12-24 13:36:48 -08:00
@@ -1,5 +1,5 @@
 #include <linux/module.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 /* Find string of zero bits in a bitmap */ 
 unsigned long 
diff -Nru a/arch/x86_64/lib/copy_user.S b/arch/x86_64/lib/copy_user.S
--- a/arch/x86_64/lib/copy_user.S	2004-12-24 13:37:00 -08:00
+++ b/arch/x86_64/lib/copy_user.S	2004-12-24 13:37:00 -08:00
@@ -73,7 +73,7 @@
  * rdx count
  *
  * Output:		
- * eax uncopied bytes or 0 if successfull. 
+ * eax uncopied bytes or 0 if successful.
  */
 	.globl copy_user_generic	
 	.p2align 4
@@ -179,9 +179,9 @@
 	movl $8,%r9d
 	subl %ecx,%r9d
 	movl %r9d,%ecx
-	subq %r9,%rdx
-	jz   .Lsmall_align
-	js   .Lsmall_align
+	cmpq %r9,%rdx
+	jz   .Lhandle_7
+	js   .Lhandle_7
 .Lalign_1:		
 .Ls11:	movb (%rsi),%bl
 .Ld11:	movb %bl,(%rdi)
@@ -189,10 +189,8 @@
 	incq %rdi
 	decl %ecx
 	jnz .Lalign_1
+	subq %r9,%rdx
 	jmp .Lafter_bad_alignment
-.Lsmall_align:
-	addq %r9,%rdx
-	jmp .Lhandle_7
 #endif
 	
 	/* table sorted by exception address */	
@@ -219,8 +217,8 @@
 	.quad .Ls10,.Le_byte
 	.quad .Ld10,.Le_byte
 #ifdef FIX_ALIGNMENT	
-	.quad .Ls11,.Le_byte
-	.quad .Ld11,.Le_byte
+	.quad .Ls11,.Lzero_rest
+	.quad .Ld11,.Lzero_rest
 #endif
 	.quad .Le5,.Le_zero
 	.previous
diff -Nru a/arch/x86_64/lib/dec_and_lock.c b/arch/x86_64/lib/dec_and_lock.c
--- a/arch/x86_64/lib/dec_and_lock.c	2004-12-24 13:36:49 -08:00
+++ b/arch/x86_64/lib/dec_and_lock.c	2004-12-24 13:36:49 -08:00
@@ -10,7 +10,7 @@
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
 
-int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
+int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
 {
 	int counter;
 	int newcount;
diff -Nru a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
--- a/arch/x86_64/mm/fault.c	2004-12-24 13:36:17 -08:00
+++ b/arch/x86_64/mm/fault.c	2004-12-24 13:36:17 -08:00
@@ -23,6 +23,7 @@
 #include <linux/vt_kern.h>		/* For unblank_screen() */
 #include <linux/compiler.h>
 #include <linux/module.h>
+#include <linux/kprobes.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -32,6 +33,7 @@
 #include <asm/proto.h>
 #include <asm/kdebug.h>
 #include <asm-generic/sections.h>
+#include <asm/kdebug.h>
 
 void bust_spinlocks(int yes)
 {
@@ -268,6 +270,9 @@
 
 	/* get the address */
 	__asm__("movq %%cr2,%0":"=r" (address));
+	if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
+					SIGSEGV) == NOTIFY_STOP)
+		return;
 
 	if (likely(regs->eflags & X86_EFLAGS_IF))
 		local_irq_enable();
diff -Nru a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
--- a/arch/x86_64/mm/init.c	2004-12-24 13:36:30 -08:00
+++ b/arch/x86_64/mm/init.c	2004-12-24 13:36:30 -08:00
@@ -484,6 +484,8 @@
 #endif
 }
 
+extern char __initdata_begin[], __initdata_end[];
+
 void free_initmem(void)
 {
 	unsigned long addr;
@@ -492,12 +494,11 @@
 	for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
 		ClearPageReserved(virt_to_page(addr));
 		set_page_count(virt_to_page(addr), 1);
-#ifdef CONFIG_INIT_DEBUG
 		memset((void *)(addr & ~(PAGE_SIZE-1)), 0xcc, PAGE_SIZE); 
-#endif
 		free_page(addr);
 		totalram_pages++;
 	}
+	memset(__initdata_begin, 0xba, __initdata_end - __initdata_begin);
 	printk ("Freeing unused kernel memory: %luk freed\n", (&__init_end - &__init_begin) >> 10);
 }
 
diff -Nru a/arch/x86_64/mm/ioremap.c b/arch/x86_64/mm/ioremap.c
--- a/arch/x86_64/mm/ioremap.c	2004-12-24 13:37:19 -08:00
+++ b/arch/x86_64/mm/ioremap.c	2004-12-24 13:37:19 -08:00
@@ -212,7 +212,7 @@
 	return p;					
 }
 
-void iounmap(void __iomem *addr)
+void iounmap(volatile void __iomem *addr)
 {
 	struct vm_struct *p;
 	if (addr <= high_memory) 
diff -Nru a/arch/x86_64/mm/k8topology.c b/arch/x86_64/mm/k8topology.c
--- a/arch/x86_64/mm/k8topology.c	2004-12-24 13:37:29 -08:00
+++ b/arch/x86_64/mm/k8topology.c	2004-12-24 13:37:29 -08:00
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/module.h>
+#include <linux/nodemask.h>
 #include <asm/io.h>
 #include <linux/pci_ids.h>
 #include <asm/types.h>
diff -Nru a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
--- a/arch/x86_64/mm/numa.c	2004-12-24 13:37:18 -08:00
+++ b/arch/x86_64/mm/numa.c	2004-12-24 13:37:18 -08:00
@@ -10,6 +10,8 @@
 #include <linux/mmzone.h>
 #include <linux/ctype.h>
 #include <linux/module.h>
+#include <linux/nodemask.h>
+
 #include <asm/e820.h>
 #include <asm/proto.h>
 #include <asm/dma.h>
@@ -151,9 +153,9 @@
 	for (i = 0; i < MAXNODE; i++) {
 		if (node_online(i))
 			continue;
-		rr = find_next_bit(node_online_map, MAX_NUMNODES, rr);
+		rr = next_node(rr, node_online_map);
 		if (rr == MAX_NUMNODES)
-			rr = find_first_bit(node_online_map, MAX_NUMNODES);
+			rr = first_node(node_online_map);
 		node_data[i] = node_data[rr];
 		cpu_to_node[i] = rr;
 		rr++; 
@@ -162,6 +164,7 @@
 	set_bit(0, &node_to_cpumask[cpu_to_node(0)]);
 }
 
+#ifdef CONFIG_NUMA_EMU
 int numa_fake __initdata = 0;
 
 /* Numa emulation */
@@ -206,13 +209,16 @@
  	numa_init_array();
  	return 0;
 }
+#endif
 
 void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
 { 
 	int i;
 
+#ifdef CONFIG_NUMA_EMU
 	if (numa_fake && !numa_emulation(start_pfn, end_pfn))
  		return;
+#endif
 
 #ifdef CONFIG_K8_NUMA
 	if (!numa_off && !k8_scan_nodes(start_pfn<<PAGE_SHIFT, end_pfn<<PAGE_SHIFT))
@@ -264,11 +270,13 @@
 { 
 	if (!strcmp(opt,"off"))
 		numa_off = 1;
+#ifdef CONFIG_NUMA_EMU
 	if(!strncmp(opt, "fake=", 5)) {
 		numa_fake = simple_strtoul(opt+5,NULL,0); ;
 		if (numa_fake >= MAX_NUMNODES)
 			numa_fake = MAX_NUMNODES;
 	}
+#endif
 	return 1;
 } 
 
diff -Nru a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
--- a/arch/x86_64/pci/mmconfig.c	2004-12-24 13:36:19 -08:00
+++ b/arch/x86_64/pci/mmconfig.c	2004-12-24 13:36:19 -08:00
@@ -63,9 +63,6 @@
 		break;
 	}
 
-	/* Dummy read to flush PCI write */
-	readl(addr);
-
 	return 0;
 }
 
@@ -80,6 +77,13 @@
 		return 0;
 	if (!pci_mmcfg_base_addr)
 		return 0;
+
+	/* Kludge for now. Don't use mmconfig on AMD systems because
+	   those have some busses where mmconfig doesn't work,
+	   and we don't parse ACPI MCFG well enough to handle that. 
+	   Remove when proper handling is added. */
+	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+		return 0; 
 
 	/* RED-PEN i386 doesn't do _nocache right now */
 	pci_mmcfg_virt = ioremap_nocache(pci_mmcfg_base_addr, MMCONFIG_APER_SIZE);
diff -Nru a/crypto/Kconfig b/crypto/Kconfig
--- a/crypto/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/crypto/Kconfig	2004-12-24 13:37:19 -08:00
@@ -73,7 +73,7 @@
 	help
 	  Whirlpool hash algorithm 512, 384 and 256-bit hashes
 
-	  Whirlpool-512 is part of the NESSIE cryptographic primtives.
+	  Whirlpool-512 is part of the NESSIE cryptographic primitives.
 	  Whirlpool will be part of the ISO/IEC 10118-3:2003(E) standard
 
 	  See also:
@@ -125,7 +125,8 @@
 	  Serpent cipher algorithm, by Anderson, Biham & Knudsen.
 
 	  Keys are allowed to be from 0 to 256 bits in length, in steps
-	  of 8 bits.
+	  of 8 bits.  Also includes the 'Tnepres' algorithm, a reversed
+	  variant of Serpent for compatibility with old kerneli code.
 
 	  See also:
 	  http://www.cl.cam.ac.uk/~rja14/serpent.html
@@ -221,6 +222,21 @@
 
 	  See also:
 	  http://planeta.terra.com.br/informatica/paulobarreto/KhazadPage.html
+
+config CRYPTO_ANUBIS
+	tristate "Anubis cipher algorithm"
+	depends on CRYPTO
+	help
+	  Anubis cipher algorithm.
+
+	  Anubis is a variable key length cipher which can use keys from 
+	  128 bits to 320 bits in length.  It was evaluated as a entrant
+	  in the NESSIE competition.
+	  
+	  See also:
+	  https://www.cosic.esat.kuleuven.ac.be/nessie/reports/
+	  http://planeta.terra.com.br/informatica/paulobarreto/AnubisPage.html
+
 
 config CRYPTO_DEFLATE
 	tristate "Deflate compression algorithm"
diff -Nru a/crypto/Makefile b/crypto/Makefile
--- a/crypto/Makefile	2004-12-24 13:37:29 -08:00
+++ b/crypto/Makefile	2004-12-24 13:37:29 -08:00
@@ -25,6 +25,7 @@
 obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
 obj-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
+obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
 obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
diff -Nru a/crypto/anubis.c b/crypto/anubis.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/crypto/anubis.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,719 @@
+/*
+ * Cryptographic API.
+ *
+ * Anubis Algorithm
+ *
+ * The Anubis algorithm was developed by Paulo S. L. M. Barreto and
+ * Vincent Rijmen.
+ *
+ * See
+ *
+ *	P.S.L.M. Barreto, V. Rijmen,
+ *	``The Anubis block cipher,''
+ *	NESSIE submission, 2000.
+ *
+ * This software implements the "tweaked" version of Anubis.
+ * Only the S-box and (consequently) the rounds constants have been
+ * changed.
+ *
+ * The original authors have disclaimed all copyright interest in this
+ * code and thus put it in the public domain. The subsequent authors
+ * have put this under the GNU General Public License.
+ *
+ * By Aaron Grothe ajgrothe@yahoo.com, October 28, 2004
+ *
+ * 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/module.h>
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+#include <linux/crypto.h>
+
+#define ANUBIS_MIN_KEY_SIZE	16
+#define ANUBIS_MAX_KEY_SIZE	40
+#define ANUBIS_BLOCK_SIZE	16
+#define ANUBIS_MAX_N		10
+#define ANUBIS_MAX_ROUNDS	(8 + ANUBIS_MAX_N)
+
+struct anubis_ctx {
+	int key_len; // in bits
+	int R;
+	u32 E[ANUBIS_MAX_ROUNDS + 1][4];
+	u32 D[ANUBIS_MAX_ROUNDS + 1][4];
+};
+
+static const u32 T0[256] = {
+	0xba69d2bbU, 0x54a84de5U, 0x2f5ebce2U, 0x74e8cd25U,
+	0x53a651f7U, 0xd3bb6bd0U, 0xd2b96fd6U, 0x4d9a29b3U,
+	0x50a05dfdU, 0xac458acfU, 0x8d070e09U, 0xbf63c6a5U,
+	0x70e0dd3dU, 0x52a455f1U, 0x9a29527bU, 0x4c982db5U,
+	0xeac98f46U, 0xd5b773c4U, 0x97336655U, 0xd1bf63dcU,
+	0x3366ccaaU, 0x51a259fbU, 0x5bb671c7U, 0xa651a2f3U,
+	0xdea15ffeU, 0x48903dadU, 0xa84d9ad7U, 0x992f5e71U,
+	0xdbab4be0U, 0x3264c8acU, 0xb773e695U, 0xfce5d732U,
+	0xe3dbab70U, 0x9e214263U, 0x913f7e41U, 0x9b2b567dU,
+	0xe2d9af76U, 0xbb6bd6bdU, 0x4182199bU, 0x6edca579U,
+	0xa557aef9U, 0xcb8b0b80U, 0x6bd6b167U, 0x95376e59U,
+	0xa15fbee1U, 0xf3fbeb10U, 0xb17ffe81U, 0x0204080cU,
+	0xcc851792U, 0xc49537a2U, 0x1d3a744eU, 0x14285078U,
+	0xc39b2bb0U, 0x63c69157U, 0xdaa94fe6U, 0x5dba69d3U,
+	0x5fbe61dfU, 0xdca557f2U, 0x7dfae913U, 0xcd871394U,
+	0x7ffee11fU, 0x5ab475c1U, 0x6cd8ad75U, 0x5cb86dd5U,
+	0xf7f3fb08U, 0x264c98d4U, 0xffe3db38U, 0xedc79354U,
+	0xe8cd874aU, 0x9d274e69U, 0x6fdea17fU, 0x8e010203U,
+	0x19326456U, 0xa05dbae7U, 0xf0fde71aU, 0x890f1e11U,
+	0x0f1e3c22U, 0x070e1c12U, 0xaf4386c5U, 0xfbebcb20U,
+	0x08102030U, 0x152a547eU, 0x0d1a342eU, 0x04081018U,
+	0x01020406U, 0x64c88d45U, 0xdfa35bf8U, 0x76ecc529U,
+	0x79f2f90bU, 0xdda753f4U, 0x3d7af48eU, 0x162c5874U,
+	0x3f7efc82U, 0x376edcb2U, 0x6ddaa973U, 0x3870e090U,
+	0xb96fdeb1U, 0x73e6d137U, 0xe9cf834cU, 0x356ad4beU,
+	0x55aa49e3U, 0x71e2d93bU, 0x7bf6f107U, 0x8c050a0fU,
+	0x72e4d531U, 0x880d1a17U, 0xf6f1ff0eU, 0x2a54a8fcU,
+	0x3e7cf884U, 0x5ebc65d9U, 0x274e9cd2U, 0x468c0589U,
+	0x0c183028U, 0x65ca8943U, 0x68d0bd6dU, 0x61c2995bU,
+	0x03060c0aU, 0xc19f23bcU, 0x57ae41efU, 0xd6b17fceU,
+	0xd9af43ecU, 0x58b07dcdU, 0xd8ad47eaU, 0x66cc8549U,
+	0xd7b37bc8U, 0x3a74e89cU, 0xc88d078aU, 0x3c78f088U,
+	0xfae9cf26U, 0x96316253U, 0xa753a6f5U, 0x982d5a77U,
+	0xecc59752U, 0xb86ddab7U, 0xc7933ba8U, 0xae4182c3U,
+	0x69d2b96bU, 0x4b9631a7U, 0xab4b96ddU, 0xa94f9ed1U,
+	0x67ce814fU, 0x0a14283cU, 0x478e018fU, 0xf2f9ef16U,
+	0xb577ee99U, 0x224488ccU, 0xe5d7b364U, 0xeec19f5eU,
+	0xbe61c2a3U, 0x2b56acfaU, 0x811f3e21U, 0x1224486cU,
+	0x831b362dU, 0x1b366c5aU, 0x0e1c3824U, 0x23468ccaU,
+	0xf5f7f304U, 0x458a0983U, 0x214284c6U, 0xce811f9eU,
+	0x499239abU, 0x2c58b0e8U, 0xf9efc32cU, 0xe6d1bf6eU,
+	0xb671e293U, 0x2850a0f0U, 0x172e5c72U, 0x8219322bU,
+	0x1a34685cU, 0x8b0b161dU, 0xfee1df3eU, 0x8a09121bU,
+	0x09122436U, 0xc98f038cU, 0x87132635U, 0x4e9c25b9U,
+	0xe1dfa37cU, 0x2e5cb8e4U, 0xe4d5b762U, 0xe0dda77aU,
+	0xebcb8b40U, 0x903d7a47U, 0xa455aaffU, 0x1e3c7844U,
+	0x85172e39U, 0x60c09d5dU, 0x00000000U, 0x254a94deU,
+	0xf4f5f702U, 0xf1ffe31cU, 0x94356a5fU, 0x0b162c3aU,
+	0xe7d3bb68U, 0x75eac923U, 0xefc39b58U, 0x3468d0b8U,
+	0x3162c4a6U, 0xd4b577c2U, 0xd0bd67daU, 0x86112233U,
+	0x7efce519U, 0xad478ec9U, 0xfde7d334U, 0x2952a4f6U,
+	0x3060c0a0U, 0x3b76ec9aU, 0x9f234665U, 0xf8edc72aU,
+	0xc6913faeU, 0x13264c6aU, 0x060c1814U, 0x050a141eU,
+	0xc59733a4U, 0x11224466U, 0x77eec12fU, 0x7cf8ed15U,
+	0x7af4f501U, 0x78f0fd0dU, 0x366cd8b4U, 0x1c387048U,
+	0x3972e496U, 0x59b279cbU, 0x18306050U, 0x56ac45e9U,
+	0xb37bf68dU, 0xb07dfa87U, 0x244890d8U, 0x204080c0U,
+	0xb279f28bU, 0x9239724bU, 0xa35bb6edU, 0xc09d27baU,
+	0x44880d85U, 0x62c49551U, 0x10204060U, 0xb475ea9fU,
+	0x84152a3fU, 0x43861197U, 0x933b764dU, 0xc2992fb6U,
+	0x4a9435a1U, 0xbd67cea9U, 0x8f030605U, 0x2d5ab4eeU,
+	0xbc65caafU, 0x9c254a6fU, 0x6ad4b561U, 0x40801d9dU,
+	0xcf831b98U, 0xa259b2ebU, 0x801d3a27U, 0x4f9e21bfU,
+	0x1f3e7c42U, 0xca890f86U, 0xaa4992dbU, 0x42841591U,
+};
+
+static const u32 T1[256] = {
+	0x69babbd2U, 0xa854e54dU, 0x5e2fe2bcU, 0xe87425cdU,
+	0xa653f751U, 0xbbd3d06bU, 0xb9d2d66fU, 0x9a4db329U,
+	0xa050fd5dU, 0x45accf8aU, 0x078d090eU, 0x63bfa5c6U,
+	0xe0703dddU, 0xa452f155U, 0x299a7b52U, 0x984cb52dU,
+	0xc9ea468fU, 0xb7d5c473U, 0x33975566U, 0xbfd1dc63U,
+	0x6633aaccU, 0xa251fb59U, 0xb65bc771U, 0x51a6f3a2U,
+	0xa1defe5fU, 0x9048ad3dU, 0x4da8d79aU, 0x2f99715eU,
+	0xabdbe04bU, 0x6432acc8U, 0x73b795e6U, 0xe5fc32d7U,
+	0xdbe370abU, 0x219e6342U, 0x3f91417eU, 0x2b9b7d56U,
+	0xd9e276afU, 0x6bbbbdd6U, 0x82419b19U, 0xdc6e79a5U,
+	0x57a5f9aeU, 0x8bcb800bU, 0xd66b67b1U, 0x3795596eU,
+	0x5fa1e1beU, 0xfbf310ebU, 0x7fb181feU, 0x04020c08U,
+	0x85cc9217U, 0x95c4a237U, 0x3a1d4e74U, 0x28147850U,
+	0x9bc3b02bU, 0xc6635791U, 0xa9dae64fU, 0xba5dd369U,
+	0xbe5fdf61U, 0xa5dcf257U, 0xfa7d13e9U, 0x87cd9413U,
+	0xfe7f1fe1U, 0xb45ac175U, 0xd86c75adU, 0xb85cd56dU,
+	0xf3f708fbU, 0x4c26d498U, 0xe3ff38dbU, 0xc7ed5493U,
+	0xcde84a87U, 0x279d694eU, 0xde6f7fa1U, 0x018e0302U,
+	0x32195664U, 0x5da0e7baU, 0xfdf01ae7U, 0x0f89111eU,
+	0x1e0f223cU, 0x0e07121cU, 0x43afc586U, 0xebfb20cbU,
+	0x10083020U, 0x2a157e54U, 0x1a0d2e34U, 0x08041810U,
+	0x02010604U, 0xc864458dU, 0xa3dff85bU, 0xec7629c5U,
+	0xf2790bf9U, 0xa7ddf453U, 0x7a3d8ef4U, 0x2c167458U,
+	0x7e3f82fcU, 0x6e37b2dcU, 0xda6d73a9U, 0x703890e0U,
+	0x6fb9b1deU, 0xe67337d1U, 0xcfe94c83U, 0x6a35bed4U,
+	0xaa55e349U, 0xe2713bd9U, 0xf67b07f1U, 0x058c0f0aU,
+	0xe47231d5U, 0x0d88171aU, 0xf1f60effU, 0x542afca8U,
+	0x7c3e84f8U, 0xbc5ed965U, 0x4e27d29cU, 0x8c468905U,
+	0x180c2830U, 0xca654389U, 0xd0686dbdU, 0xc2615b99U,
+	0x06030a0cU, 0x9fc1bc23U, 0xae57ef41U, 0xb1d6ce7fU,
+	0xafd9ec43U, 0xb058cd7dU, 0xadd8ea47U, 0xcc664985U,
+	0xb3d7c87bU, 0x743a9ce8U, 0x8dc88a07U, 0x783c88f0U,
+	0xe9fa26cfU, 0x31965362U, 0x53a7f5a6U, 0x2d98775aU,
+	0xc5ec5297U, 0x6db8b7daU, 0x93c7a83bU, 0x41aec382U,
+	0xd2696bb9U, 0x964ba731U, 0x4babdd96U, 0x4fa9d19eU,
+	0xce674f81U, 0x140a3c28U, 0x8e478f01U, 0xf9f216efU,
+	0x77b599eeU, 0x4422cc88U, 0xd7e564b3U, 0xc1ee5e9fU,
+	0x61bea3c2U, 0x562bfaacU, 0x1f81213eU, 0x24126c48U,
+	0x1b832d36U, 0x361b5a6cU, 0x1c0e2438U, 0x4623ca8cU,
+	0xf7f504f3U, 0x8a458309U, 0x4221c684U, 0x81ce9e1fU,
+	0x9249ab39U, 0x582ce8b0U, 0xeff92cc3U, 0xd1e66ebfU,
+	0x71b693e2U, 0x5028f0a0U, 0x2e17725cU, 0x19822b32U,
+	0x341a5c68U, 0x0b8b1d16U, 0xe1fe3edfU, 0x098a1b12U,
+	0x12093624U, 0x8fc98c03U, 0x13873526U, 0x9c4eb925U,
+	0xdfe17ca3U, 0x5c2ee4b8U, 0xd5e462b7U, 0xdde07aa7U,
+	0xcbeb408bU, 0x3d90477aU, 0x55a4ffaaU, 0x3c1e4478U,
+	0x1785392eU, 0xc0605d9dU, 0x00000000U, 0x4a25de94U,
+	0xf5f402f7U, 0xfff11ce3U, 0x35945f6aU, 0x160b3a2cU,
+	0xd3e768bbU, 0xea7523c9U, 0xc3ef589bU, 0x6834b8d0U,
+	0x6231a6c4U, 0xb5d4c277U, 0xbdd0da67U, 0x11863322U,
+	0xfc7e19e5U, 0x47adc98eU, 0xe7fd34d3U, 0x5229f6a4U,
+	0x6030a0c0U, 0x763b9aecU, 0x239f6546U, 0xedf82ac7U,
+	0x91c6ae3fU, 0x26136a4cU, 0x0c061418U, 0x0a051e14U,
+	0x97c5a433U, 0x22116644U, 0xee772fc1U, 0xf87c15edU,
+	0xf47a01f5U, 0xf0780dfdU, 0x6c36b4d8U, 0x381c4870U,
+	0x723996e4U, 0xb259cb79U, 0x30185060U, 0xac56e945U,
+	0x7bb38df6U, 0x7db087faU, 0x4824d890U, 0x4020c080U,
+	0x79b28bf2U, 0x39924b72U, 0x5ba3edb6U, 0x9dc0ba27U,
+	0x8844850dU, 0xc4625195U, 0x20106040U, 0x75b49feaU,
+	0x15843f2aU, 0x86439711U, 0x3b934d76U, 0x99c2b62fU,
+	0x944aa135U, 0x67bda9ceU, 0x038f0506U, 0x5a2deeb4U,
+	0x65bcafcaU, 0x259c6f4aU, 0xd46a61b5U, 0x80409d1dU,
+	0x83cf981bU, 0x59a2ebb2U, 0x1d80273aU, 0x9e4fbf21U,
+	0x3e1f427cU, 0x89ca860fU, 0x49aadb92U, 0x84429115U,
+};
+
+static const u32 T2[256] = {
+	0xd2bbba69U, 0x4de554a8U, 0xbce22f5eU, 0xcd2574e8U,
+	0x51f753a6U, 0x6bd0d3bbU, 0x6fd6d2b9U, 0x29b34d9aU,
+	0x5dfd50a0U, 0x8acfac45U, 0x0e098d07U, 0xc6a5bf63U,
+	0xdd3d70e0U, 0x55f152a4U, 0x527b9a29U, 0x2db54c98U,
+	0x8f46eac9U, 0x73c4d5b7U, 0x66559733U, 0x63dcd1bfU,
+	0xccaa3366U, 0x59fb51a2U, 0x71c75bb6U, 0xa2f3a651U,
+	0x5ffedea1U, 0x3dad4890U, 0x9ad7a84dU, 0x5e71992fU,
+	0x4be0dbabU, 0xc8ac3264U, 0xe695b773U, 0xd732fce5U,
+	0xab70e3dbU, 0x42639e21U, 0x7e41913fU, 0x567d9b2bU,
+	0xaf76e2d9U, 0xd6bdbb6bU, 0x199b4182U, 0xa5796edcU,
+	0xaef9a557U, 0x0b80cb8bU, 0xb1676bd6U, 0x6e599537U,
+	0xbee1a15fU, 0xeb10f3fbU, 0xfe81b17fU, 0x080c0204U,
+	0x1792cc85U, 0x37a2c495U, 0x744e1d3aU, 0x50781428U,
+	0x2bb0c39bU, 0x915763c6U, 0x4fe6daa9U, 0x69d35dbaU,
+	0x61df5fbeU, 0x57f2dca5U, 0xe9137dfaU, 0x1394cd87U,
+	0xe11f7ffeU, 0x75c15ab4U, 0xad756cd8U, 0x6dd55cb8U,
+	0xfb08f7f3U, 0x98d4264cU, 0xdb38ffe3U, 0x9354edc7U,
+	0x874ae8cdU, 0x4e699d27U, 0xa17f6fdeU, 0x02038e01U,
+	0x64561932U, 0xbae7a05dU, 0xe71af0fdU, 0x1e11890fU,
+	0x3c220f1eU, 0x1c12070eU, 0x86c5af43U, 0xcb20fbebU,
+	0x20300810U, 0x547e152aU, 0x342e0d1aU, 0x10180408U,
+	0x04060102U, 0x8d4564c8U, 0x5bf8dfa3U, 0xc52976ecU,
+	0xf90b79f2U, 0x53f4dda7U, 0xf48e3d7aU, 0x5874162cU,
+	0xfc823f7eU, 0xdcb2376eU, 0xa9736ddaU, 0xe0903870U,
+	0xdeb1b96fU, 0xd13773e6U, 0x834ce9cfU, 0xd4be356aU,
+	0x49e355aaU, 0xd93b71e2U, 0xf1077bf6U, 0x0a0f8c05U,
+	0xd53172e4U, 0x1a17880dU, 0xff0ef6f1U, 0xa8fc2a54U,
+	0xf8843e7cU, 0x65d95ebcU, 0x9cd2274eU, 0x0589468cU,
+	0x30280c18U, 0x894365caU, 0xbd6d68d0U, 0x995b61c2U,
+	0x0c0a0306U, 0x23bcc19fU, 0x41ef57aeU, 0x7fced6b1U,
+	0x43ecd9afU, 0x7dcd58b0U, 0x47ead8adU, 0x854966ccU,
+	0x7bc8d7b3U, 0xe89c3a74U, 0x078ac88dU, 0xf0883c78U,
+	0xcf26fae9U, 0x62539631U, 0xa6f5a753U, 0x5a77982dU,
+	0x9752ecc5U, 0xdab7b86dU, 0x3ba8c793U, 0x82c3ae41U,
+	0xb96b69d2U, 0x31a74b96U, 0x96ddab4bU, 0x9ed1a94fU,
+	0x814f67ceU, 0x283c0a14U, 0x018f478eU, 0xef16f2f9U,
+	0xee99b577U, 0x88cc2244U, 0xb364e5d7U, 0x9f5eeec1U,
+	0xc2a3be61U, 0xacfa2b56U, 0x3e21811fU, 0x486c1224U,
+	0x362d831bU, 0x6c5a1b36U, 0x38240e1cU, 0x8cca2346U,
+	0xf304f5f7U, 0x0983458aU, 0x84c62142U, 0x1f9ece81U,
+	0x39ab4992U, 0xb0e82c58U, 0xc32cf9efU, 0xbf6ee6d1U,
+	0xe293b671U, 0xa0f02850U, 0x5c72172eU, 0x322b8219U,
+	0x685c1a34U, 0x161d8b0bU, 0xdf3efee1U, 0x121b8a09U,
+	0x24360912U, 0x038cc98fU, 0x26358713U, 0x25b94e9cU,
+	0xa37ce1dfU, 0xb8e42e5cU, 0xb762e4d5U, 0xa77ae0ddU,
+	0x8b40ebcbU, 0x7a47903dU, 0xaaffa455U, 0x78441e3cU,
+	0x2e398517U, 0x9d5d60c0U, 0x00000000U, 0x94de254aU,
+	0xf702f4f5U, 0xe31cf1ffU, 0x6a5f9435U, 0x2c3a0b16U,
+	0xbb68e7d3U, 0xc92375eaU, 0x9b58efc3U, 0xd0b83468U,
+	0xc4a63162U, 0x77c2d4b5U, 0x67dad0bdU, 0x22338611U,
+	0xe5197efcU, 0x8ec9ad47U, 0xd334fde7U, 0xa4f62952U,
+	0xc0a03060U, 0xec9a3b76U, 0x46659f23U, 0xc72af8edU,
+	0x3faec691U, 0x4c6a1326U, 0x1814060cU, 0x141e050aU,
+	0x33a4c597U, 0x44661122U, 0xc12f77eeU, 0xed157cf8U,
+	0xf5017af4U, 0xfd0d78f0U, 0xd8b4366cU, 0x70481c38U,
+	0xe4963972U, 0x79cb59b2U, 0x60501830U, 0x45e956acU,
+	0xf68db37bU, 0xfa87b07dU, 0x90d82448U, 0x80c02040U,
+	0xf28bb279U, 0x724b9239U, 0xb6eda35bU, 0x27bac09dU,
+	0x0d854488U, 0x955162c4U, 0x40601020U, 0xea9fb475U,
+	0x2a3f8415U, 0x11974386U, 0x764d933bU, 0x2fb6c299U,
+	0x35a14a94U, 0xcea9bd67U, 0x06058f03U, 0xb4ee2d5aU,
+	0xcaafbc65U, 0x4a6f9c25U, 0xb5616ad4U, 0x1d9d4080U,
+	0x1b98cf83U, 0xb2eba259U, 0x3a27801dU, 0x21bf4f9eU,
+	0x7c421f3eU, 0x0f86ca89U, 0x92dbaa49U, 0x15914284U,
+};
+
+static const u32 T3[256] = {
+	0xbbd269baU, 0xe54da854U, 0xe2bc5e2fU, 0x25cde874U,
+	0xf751a653U, 0xd06bbbd3U, 0xd66fb9d2U, 0xb3299a4dU,
+	0xfd5da050U, 0xcf8a45acU, 0x090e078dU, 0xa5c663bfU,
+	0x3ddde070U, 0xf155a452U, 0x7b52299aU, 0xb52d984cU,
+	0x468fc9eaU, 0xc473b7d5U, 0x55663397U, 0xdc63bfd1U,
+	0xaacc6633U, 0xfb59a251U, 0xc771b65bU, 0xf3a251a6U,
+	0xfe5fa1deU, 0xad3d9048U, 0xd79a4da8U, 0x715e2f99U,
+	0xe04babdbU, 0xacc86432U, 0x95e673b7U, 0x32d7e5fcU,
+	0x70abdbe3U, 0x6342219eU, 0x417e3f91U, 0x7d562b9bU,
+	0x76afd9e2U, 0xbdd66bbbU, 0x9b198241U, 0x79a5dc6eU,
+	0xf9ae57a5U, 0x800b8bcbU, 0x67b1d66bU, 0x596e3795U,
+	0xe1be5fa1U, 0x10ebfbf3U, 0x81fe7fb1U, 0x0c080402U,
+	0x921785ccU, 0xa23795c4U, 0x4e743a1dU, 0x78502814U,
+	0xb02b9bc3U, 0x5791c663U, 0xe64fa9daU, 0xd369ba5dU,
+	0xdf61be5fU, 0xf257a5dcU, 0x13e9fa7dU, 0x941387cdU,
+	0x1fe1fe7fU, 0xc175b45aU, 0x75add86cU, 0xd56db85cU,
+	0x08fbf3f7U, 0xd4984c26U, 0x38dbe3ffU, 0x5493c7edU,
+	0x4a87cde8U, 0x694e279dU, 0x7fa1de6fU, 0x0302018eU,
+	0x56643219U, 0xe7ba5da0U, 0x1ae7fdf0U, 0x111e0f89U,
+	0x223c1e0fU, 0x121c0e07U, 0xc58643afU, 0x20cbebfbU,
+	0x30201008U, 0x7e542a15U, 0x2e341a0dU, 0x18100804U,
+	0x06040201U, 0x458dc864U, 0xf85ba3dfU, 0x29c5ec76U,
+	0x0bf9f279U, 0xf453a7ddU, 0x8ef47a3dU, 0x74582c16U,
+	0x82fc7e3fU, 0xb2dc6e37U, 0x73a9da6dU, 0x90e07038U,
+	0xb1de6fb9U, 0x37d1e673U, 0x4c83cfe9U, 0xbed46a35U,
+	0xe349aa55U, 0x3bd9e271U, 0x07f1f67bU, 0x0f0a058cU,
+	0x31d5e472U, 0x171a0d88U, 0x0efff1f6U, 0xfca8542aU,
+	0x84f87c3eU, 0xd965bc5eU, 0xd29c4e27U, 0x89058c46U,
+	0x2830180cU, 0x4389ca65U, 0x6dbdd068U, 0x5b99c261U,
+	0x0a0c0603U, 0xbc239fc1U, 0xef41ae57U, 0xce7fb1d6U,
+	0xec43afd9U, 0xcd7db058U, 0xea47add8U, 0x4985cc66U,
+	0xc87bb3d7U, 0x9ce8743aU, 0x8a078dc8U, 0x88f0783cU,
+	0x26cfe9faU, 0x53623196U, 0xf5a653a7U, 0x775a2d98U,
+	0x5297c5ecU, 0xb7da6db8U, 0xa83b93c7U, 0xc38241aeU,
+	0x6bb9d269U, 0xa731964bU, 0xdd964babU, 0xd19e4fa9U,
+	0x4f81ce67U, 0x3c28140aU, 0x8f018e47U, 0x16eff9f2U,
+	0x99ee77b5U, 0xcc884422U, 0x64b3d7e5U, 0x5e9fc1eeU,
+	0xa3c261beU, 0xfaac562bU, 0x213e1f81U, 0x6c482412U,
+	0x2d361b83U, 0x5a6c361bU, 0x24381c0eU, 0xca8c4623U,
+	0x04f3f7f5U, 0x83098a45U, 0xc6844221U, 0x9e1f81ceU,
+	0xab399249U, 0xe8b0582cU, 0x2cc3eff9U, 0x6ebfd1e6U,
+	0x93e271b6U, 0xf0a05028U, 0x725c2e17U, 0x2b321982U,
+	0x5c68341aU, 0x1d160b8bU, 0x3edfe1feU, 0x1b12098aU,
+	0x36241209U, 0x8c038fc9U, 0x35261387U, 0xb9259c4eU,
+	0x7ca3dfe1U, 0xe4b85c2eU, 0x62b7d5e4U, 0x7aa7dde0U,
+	0x408bcbebU, 0x477a3d90U, 0xffaa55a4U, 0x44783c1eU,
+	0x392e1785U, 0x5d9dc060U, 0x00000000U, 0xde944a25U,
+	0x02f7f5f4U, 0x1ce3fff1U, 0x5f6a3594U, 0x3a2c160bU,
+	0x68bbd3e7U, 0x23c9ea75U, 0x589bc3efU, 0xb8d06834U,
+	0xa6c46231U, 0xc277b5d4U, 0xda67bdd0U, 0x33221186U,
+	0x19e5fc7eU, 0xc98e47adU, 0x34d3e7fdU, 0xf6a45229U,
+	0xa0c06030U, 0x9aec763bU, 0x6546239fU, 0x2ac7edf8U,
+	0xae3f91c6U, 0x6a4c2613U, 0x14180c06U, 0x1e140a05U,
+	0xa43397c5U, 0x66442211U, 0x2fc1ee77U, 0x15edf87cU,
+	0x01f5f47aU, 0x0dfdf078U, 0xb4d86c36U, 0x4870381cU,
+	0x96e47239U, 0xcb79b259U, 0x50603018U, 0xe945ac56U,
+	0x8df67bb3U, 0x87fa7db0U, 0xd8904824U, 0xc0804020U,
+	0x8bf279b2U, 0x4b723992U, 0xedb65ba3U, 0xba279dc0U,
+	0x850d8844U, 0x5195c462U, 0x60402010U, 0x9fea75b4U,
+	0x3f2a1584U, 0x97118643U, 0x4d763b93U, 0xb62f99c2U,
+	0xa135944aU, 0xa9ce67bdU, 0x0506038fU, 0xeeb45a2dU,
+	0xafca65bcU, 0x6f4a259cU, 0x61b5d46aU, 0x9d1d8040U,
+	0x981b83cfU, 0xebb259a2U, 0x273a1d80U, 0xbf219e4fU,
+	0x427c3e1fU, 0x860f89caU, 0xdb9249aaU, 0x91158442U,
+};
+
+static const u32 T4[256] = {
+	0xbabababaU, 0x54545454U, 0x2f2f2f2fU, 0x74747474U,
+	0x53535353U, 0xd3d3d3d3U, 0xd2d2d2d2U, 0x4d4d4d4dU,
+	0x50505050U, 0xacacacacU, 0x8d8d8d8dU, 0xbfbfbfbfU,
+	0x70707070U, 0x52525252U, 0x9a9a9a9aU, 0x4c4c4c4cU,
+	0xeaeaeaeaU, 0xd5d5d5d5U, 0x97979797U, 0xd1d1d1d1U,
+	0x33333333U, 0x51515151U, 0x5b5b5b5bU, 0xa6a6a6a6U,
+	0xdedededeU, 0x48484848U, 0xa8a8a8a8U, 0x99999999U,
+	0xdbdbdbdbU, 0x32323232U, 0xb7b7b7b7U, 0xfcfcfcfcU,
+	0xe3e3e3e3U, 0x9e9e9e9eU, 0x91919191U, 0x9b9b9b9bU,
+	0xe2e2e2e2U, 0xbbbbbbbbU, 0x41414141U, 0x6e6e6e6eU,
+	0xa5a5a5a5U, 0xcbcbcbcbU, 0x6b6b6b6bU, 0x95959595U,
+	0xa1a1a1a1U, 0xf3f3f3f3U, 0xb1b1b1b1U, 0x02020202U,
+	0xccccccccU, 0xc4c4c4c4U, 0x1d1d1d1dU, 0x14141414U,
+	0xc3c3c3c3U, 0x63636363U, 0xdadadadaU, 0x5d5d5d5dU,
+	0x5f5f5f5fU, 0xdcdcdcdcU, 0x7d7d7d7dU, 0xcdcdcdcdU,
+	0x7f7f7f7fU, 0x5a5a5a5aU, 0x6c6c6c6cU, 0x5c5c5c5cU,
+	0xf7f7f7f7U, 0x26262626U, 0xffffffffU, 0xededededU,
+	0xe8e8e8e8U, 0x9d9d9d9dU, 0x6f6f6f6fU, 0x8e8e8e8eU,
+	0x19191919U, 0xa0a0a0a0U, 0xf0f0f0f0U, 0x89898989U,
+	0x0f0f0f0fU, 0x07070707U, 0xafafafafU, 0xfbfbfbfbU,
+	0x08080808U, 0x15151515U, 0x0d0d0d0dU, 0x04040404U,
+	0x01010101U, 0x64646464U, 0xdfdfdfdfU, 0x76767676U,
+	0x79797979U, 0xddddddddU, 0x3d3d3d3dU, 0x16161616U,
+	0x3f3f3f3fU, 0x37373737U, 0x6d6d6d6dU, 0x38383838U,
+	0xb9b9b9b9U, 0x73737373U, 0xe9e9e9e9U, 0x35353535U,
+	0x55555555U, 0x71717171U, 0x7b7b7b7bU, 0x8c8c8c8cU,
+	0x72727272U, 0x88888888U, 0xf6f6f6f6U, 0x2a2a2a2aU,
+	0x3e3e3e3eU, 0x5e5e5e5eU, 0x27272727U, 0x46464646U,
+	0x0c0c0c0cU, 0x65656565U, 0x68686868U, 0x61616161U,
+	0x03030303U, 0xc1c1c1c1U, 0x57575757U, 0xd6d6d6d6U,
+	0xd9d9d9d9U, 0x58585858U, 0xd8d8d8d8U, 0x66666666U,
+	0xd7d7d7d7U, 0x3a3a3a3aU, 0xc8c8c8c8U, 0x3c3c3c3cU,
+	0xfafafafaU, 0x96969696U, 0xa7a7a7a7U, 0x98989898U,
+	0xececececU, 0xb8b8b8b8U, 0xc7c7c7c7U, 0xaeaeaeaeU,
+	0x69696969U, 0x4b4b4b4bU, 0xababababU, 0xa9a9a9a9U,
+	0x67676767U, 0x0a0a0a0aU, 0x47474747U, 0xf2f2f2f2U,
+	0xb5b5b5b5U, 0x22222222U, 0xe5e5e5e5U, 0xeeeeeeeeU,
+	0xbebebebeU, 0x2b2b2b2bU, 0x81818181U, 0x12121212U,
+	0x83838383U, 0x1b1b1b1bU, 0x0e0e0e0eU, 0x23232323U,
+	0xf5f5f5f5U, 0x45454545U, 0x21212121U, 0xcecececeU,
+	0x49494949U, 0x2c2c2c2cU, 0xf9f9f9f9U, 0xe6e6e6e6U,
+	0xb6b6b6b6U, 0x28282828U, 0x17171717U, 0x82828282U,
+	0x1a1a1a1aU, 0x8b8b8b8bU, 0xfefefefeU, 0x8a8a8a8aU,
+	0x09090909U, 0xc9c9c9c9U, 0x87878787U, 0x4e4e4e4eU,
+	0xe1e1e1e1U, 0x2e2e2e2eU, 0xe4e4e4e4U, 0xe0e0e0e0U,
+	0xebebebebU, 0x90909090U, 0xa4a4a4a4U, 0x1e1e1e1eU,
+	0x85858585U, 0x60606060U, 0x00000000U, 0x25252525U,
+	0xf4f4f4f4U, 0xf1f1f1f1U, 0x94949494U, 0x0b0b0b0bU,
+	0xe7e7e7e7U, 0x75757575U, 0xefefefefU, 0x34343434U,
+	0x31313131U, 0xd4d4d4d4U, 0xd0d0d0d0U, 0x86868686U,
+	0x7e7e7e7eU, 0xadadadadU, 0xfdfdfdfdU, 0x29292929U,
+	0x30303030U, 0x3b3b3b3bU, 0x9f9f9f9fU, 0xf8f8f8f8U,
+	0xc6c6c6c6U, 0x13131313U, 0x06060606U, 0x05050505U,
+	0xc5c5c5c5U, 0x11111111U, 0x77777777U, 0x7c7c7c7cU,
+	0x7a7a7a7aU, 0x78787878U, 0x36363636U, 0x1c1c1c1cU,
+	0x39393939U, 0x59595959U, 0x18181818U, 0x56565656U,
+	0xb3b3b3b3U, 0xb0b0b0b0U, 0x24242424U, 0x20202020U,
+	0xb2b2b2b2U, 0x92929292U, 0xa3a3a3a3U, 0xc0c0c0c0U,
+	0x44444444U, 0x62626262U, 0x10101010U, 0xb4b4b4b4U,
+	0x84848484U, 0x43434343U, 0x93939393U, 0xc2c2c2c2U,
+	0x4a4a4a4aU, 0xbdbdbdbdU, 0x8f8f8f8fU, 0x2d2d2d2dU,
+	0xbcbcbcbcU, 0x9c9c9c9cU, 0x6a6a6a6aU, 0x40404040U,
+	0xcfcfcfcfU, 0xa2a2a2a2U, 0x80808080U, 0x4f4f4f4fU,
+	0x1f1f1f1fU, 0xcacacacaU, 0xaaaaaaaaU, 0x42424242U,
+};
+
+static const u32 T5[256] = {
+	0x00000000U, 0x01020608U, 0x02040c10U, 0x03060a18U,
+	0x04081820U, 0x050a1e28U, 0x060c1430U, 0x070e1238U,
+	0x08103040U, 0x09123648U, 0x0a143c50U, 0x0b163a58U,
+	0x0c182860U, 0x0d1a2e68U, 0x0e1c2470U, 0x0f1e2278U,
+	0x10206080U, 0x11226688U, 0x12246c90U, 0x13266a98U,
+	0x142878a0U, 0x152a7ea8U, 0x162c74b0U, 0x172e72b8U,
+	0x183050c0U, 0x193256c8U, 0x1a345cd0U, 0x1b365ad8U,
+	0x1c3848e0U, 0x1d3a4ee8U, 0x1e3c44f0U, 0x1f3e42f8U,
+	0x2040c01dU, 0x2142c615U, 0x2244cc0dU, 0x2346ca05U,
+	0x2448d83dU, 0x254ade35U, 0x264cd42dU, 0x274ed225U,
+	0x2850f05dU, 0x2952f655U, 0x2a54fc4dU, 0x2b56fa45U,
+	0x2c58e87dU, 0x2d5aee75U, 0x2e5ce46dU, 0x2f5ee265U,
+	0x3060a09dU, 0x3162a695U, 0x3264ac8dU, 0x3366aa85U,
+	0x3468b8bdU, 0x356abeb5U, 0x366cb4adU, 0x376eb2a5U,
+	0x387090ddU, 0x397296d5U, 0x3a749ccdU, 0x3b769ac5U,
+	0x3c7888fdU, 0x3d7a8ef5U, 0x3e7c84edU, 0x3f7e82e5U,
+	0x40809d3aU, 0x41829b32U, 0x4284912aU, 0x43869722U,
+	0x4488851aU, 0x458a8312U, 0x468c890aU, 0x478e8f02U,
+	0x4890ad7aU, 0x4992ab72U, 0x4a94a16aU, 0x4b96a762U,
+	0x4c98b55aU, 0x4d9ab352U, 0x4e9cb94aU, 0x4f9ebf42U,
+	0x50a0fdbaU, 0x51a2fbb2U, 0x52a4f1aaU, 0x53a6f7a2U,
+	0x54a8e59aU, 0x55aae392U, 0x56ace98aU, 0x57aeef82U,
+	0x58b0cdfaU, 0x59b2cbf2U, 0x5ab4c1eaU, 0x5bb6c7e2U,
+	0x5cb8d5daU, 0x5dbad3d2U, 0x5ebcd9caU, 0x5fbedfc2U,
+	0x60c05d27U, 0x61c25b2fU, 0x62c45137U, 0x63c6573fU,
+	0x64c84507U, 0x65ca430fU, 0x66cc4917U, 0x67ce4f1fU,
+	0x68d06d67U, 0x69d26b6fU, 0x6ad46177U, 0x6bd6677fU,
+	0x6cd87547U, 0x6dda734fU, 0x6edc7957U, 0x6fde7f5fU,
+	0x70e03da7U, 0x71e23bafU, 0x72e431b7U, 0x73e637bfU,
+	0x74e82587U, 0x75ea238fU, 0x76ec2997U, 0x77ee2f9fU,
+	0x78f00de7U, 0x79f20befU, 0x7af401f7U, 0x7bf607ffU,
+	0x7cf815c7U, 0x7dfa13cfU, 0x7efc19d7U, 0x7ffe1fdfU,
+	0x801d2774U, 0x811f217cU, 0x82192b64U, 0x831b2d6cU,
+	0x84153f54U, 0x8517395cU, 0x86113344U, 0x8713354cU,
+	0x880d1734U, 0x890f113cU, 0x8a091b24U, 0x8b0b1d2cU,
+	0x8c050f14U, 0x8d07091cU, 0x8e010304U, 0x8f03050cU,
+	0x903d47f4U, 0x913f41fcU, 0x92394be4U, 0x933b4decU,
+	0x94355fd4U, 0x953759dcU, 0x963153c4U, 0x973355ccU,
+	0x982d77b4U, 0x992f71bcU, 0x9a297ba4U, 0x9b2b7dacU,
+	0x9c256f94U, 0x9d27699cU, 0x9e216384U, 0x9f23658cU,
+	0xa05de769U, 0xa15fe161U, 0xa259eb79U, 0xa35bed71U,
+	0xa455ff49U, 0xa557f941U, 0xa651f359U, 0xa753f551U,
+	0xa84dd729U, 0xa94fd121U, 0xaa49db39U, 0xab4bdd31U,
+	0xac45cf09U, 0xad47c901U, 0xae41c319U, 0xaf43c511U,
+	0xb07d87e9U, 0xb17f81e1U, 0xb2798bf9U, 0xb37b8df1U,
+	0xb4759fc9U, 0xb57799c1U, 0xb67193d9U, 0xb77395d1U,
+	0xb86db7a9U, 0xb96fb1a1U, 0xba69bbb9U, 0xbb6bbdb1U,
+	0xbc65af89U, 0xbd67a981U, 0xbe61a399U, 0xbf63a591U,
+	0xc09dba4eU, 0xc19fbc46U, 0xc299b65eU, 0xc39bb056U,
+	0xc495a26eU, 0xc597a466U, 0xc691ae7eU, 0xc793a876U,
+	0xc88d8a0eU, 0xc98f8c06U, 0xca89861eU, 0xcb8b8016U,
+	0xcc85922eU, 0xcd879426U, 0xce819e3eU, 0xcf839836U,
+	0xd0bddaceU, 0xd1bfdcc6U, 0xd2b9d6deU, 0xd3bbd0d6U,
+	0xd4b5c2eeU, 0xd5b7c4e6U, 0xd6b1cefeU, 0xd7b3c8f6U,
+	0xd8adea8eU, 0xd9afec86U, 0xdaa9e69eU, 0xdbabe096U,
+	0xdca5f2aeU, 0xdda7f4a6U, 0xdea1febeU, 0xdfa3f8b6U,
+	0xe0dd7a53U, 0xe1df7c5bU, 0xe2d97643U, 0xe3db704bU,
+	0xe4d56273U, 0xe5d7647bU, 0xe6d16e63U, 0xe7d3686bU,
+	0xe8cd4a13U, 0xe9cf4c1bU, 0xeac94603U, 0xebcb400bU,
+	0xecc55233U, 0xedc7543bU, 0xeec15e23U, 0xefc3582bU,
+	0xf0fd1ad3U, 0xf1ff1cdbU, 0xf2f916c3U, 0xf3fb10cbU,
+	0xf4f502f3U, 0xf5f704fbU, 0xf6f10ee3U, 0xf7f308ebU,
+	0xf8ed2a93U, 0xf9ef2c9bU, 0xfae92683U, 0xfbeb208bU,
+	0xfce532b3U, 0xfde734bbU, 0xfee13ea3U, 0xffe338abU,
+};
+
+static const u32 rc[] = {
+	0xba542f74U, 0x53d3d24dU, 0x50ac8dbfU, 0x70529a4cU,
+	0xead597d1U, 0x33515ba6U, 0xde48a899U, 0xdb32b7fcU,
+	0xe39e919bU, 0xe2bb416eU, 0xa5cb6b95U, 0xa1f3b102U,
+	0xccc41d14U, 0xc363da5dU, 0x5fdc7dcdU, 0x7f5a6c5cU,
+	0xf726ffedU, 0xe89d6f8eU, 0x19a0f089U,
+};
+
+static int anubis_setkey(void *ctx_arg, const u8 *in_key,
+			 unsigned int key_len, u32 *flags)
+{
+
+	int N, R, i, pos, r;
+	u32 kappa[ANUBIS_MAX_N];
+	u32 inter[ANUBIS_MAX_N];
+
+	struct anubis_ctx *ctx = ctx_arg;
+
+	switch (key_len)
+	{
+		case 16: case 20: case 24: case 28:
+		case 32: case 36: case 40:
+			break;
+		default:
+			*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+			return - EINVAL;
+	}
+
+	ctx->key_len = key_len * 8;
+	N = ctx->key_len >> 5;
+	ctx->R = R = 8 + N;
+
+	/* * map cipher key to initial key state (mu): */
+		for (i = 0, pos = 0; i < N; i++, pos += 4) {
+		kappa[i] =
+			(in_key[pos    ] << 24) ^
+			(in_key[pos + 1] << 16) ^
+			(in_key[pos + 2] <<  8) ^
+			(in_key[pos + 3]      );
+	}
+
+	/*
+	 * generate R + 1 round keys:
+	 */
+	for (r = 0; r <= R; r++) {
+		u32 K0, K1, K2, K3;
+		/*
+		 * generate r-th round key K^r:
+		 */
+		K0 = T4[(kappa[N - 1] >> 24)       ];
+		K1 = T4[(kappa[N - 1] >> 16) & 0xff];
+		K2 = T4[(kappa[N - 1] >>  8) & 0xff];
+		K3 = T4[(kappa[N - 1]      ) & 0xff];
+		for (i = N - 2; i >= 0; i--) {
+			K0 = T4[(kappa[i] >> 24)       ] ^
+				(T5[(K0 >> 24)       ] & 0xff000000U) ^
+				(T5[(K0 >> 16) & 0xff] & 0x00ff0000U) ^
+				(T5[(K0 >>  8) & 0xff] & 0x0000ff00U) ^
+				(T5[(K0      ) & 0xff] & 0x000000ffU);
+			K1 = T4[(kappa[i] >> 16) & 0xff] ^
+				(T5[(K1 >> 24)       ] & 0xff000000U) ^
+				(T5[(K1 >> 16) & 0xff] & 0x00ff0000U) ^
+				(T5[(K1 >>  8) & 0xff] & 0x0000ff00U) ^
+				(T5[(K1      ) & 0xff] & 0x000000ffU);
+			K2 = T4[(kappa[i] >>  8) & 0xff] ^
+				(T5[(K2 >> 24)       ] & 0xff000000U) ^
+				(T5[(K2 >> 16) & 0xff] & 0x00ff0000U) ^
+				(T5[(K2 >>  8) & 0xff] & 0x0000ff00U) ^
+				(T5[(K2      ) & 0xff] & 0x000000ffU);
+			K3 = T4[(kappa[i]      ) & 0xff] ^
+				(T5[(K3 >> 24)       ] & 0xff000000U) ^
+				(T5[(K3 >> 16) & 0xff] & 0x00ff0000U) ^
+				(T5[(K3 >>  8) & 0xff] & 0x0000ff00U) ^
+				(T5[(K3      ) & 0xff] & 0x000000ffU);
+		}
+
+		ctx->E[r][0] = K0;
+		ctx->E[r][1] = K1;
+		ctx->E[r][2] = K2;
+		ctx->E[r][3] = K3;
+
+		/*
+		 * compute kappa^{r+1} from kappa^r:
+		 */
+		if (r == R) {
+			break;
+		}
+		for (i = 0; i < N; i++) {
+			int j = i;
+			inter[i]  = T0[(kappa[j--] >> 24)       ];
+			if (j < 0) j = N - 1;
+			inter[i] ^= T1[(kappa[j--] >> 16) & 0xff];
+			if (j < 0) j = N - 1;
+			inter[i] ^= T2[(kappa[j--] >>  8) & 0xff];
+			if (j < 0) j = N - 1;
+			inter[i] ^= T3[(kappa[j  ]      ) & 0xff];
+		}
+		kappa[0] = inter[0] ^ rc[r];
+		for (i = 1; i < N; i++) {
+			kappa[i] = inter[i];
+		}
+	}
+
+	/*
+	 * generate inverse key schedule: K'^0 = K^R, K'^R =
+	 * 				  K^0, K'^r = theta(K^{R-r}):
+	 */
+	for (i = 0; i < 4; i++) {
+		ctx->D[0][i] = ctx->E[R][i];
+		ctx->D[R][i] = ctx->E[0][i];
+	}
+	for (r = 1; r < R; r++) {
+		for (i = 0; i < 4; i++) {
+			u32 v = ctx->E[R - r][i];
+			ctx->D[r][i] =
+				T0[T4[(v >> 24)       ] & 0xff] ^
+				T1[T4[(v >> 16) & 0xff] & 0xff] ^
+				T2[T4[(v >>  8) & 0xff] & 0xff] ^
+				T3[T4[(v      ) & 0xff] & 0xff];
+		}
+	}
+
+	return 0;
+}
+
+static void anubis_crypt(u32 roundKey[ANUBIS_MAX_ROUNDS + 1][4],
+		u8 *ciphertext, const u8 *plaintext, const int R)
+{
+	int i, pos, r;
+	u32 state[4];
+	u32 inter[4];
+
+	/*
+	 * map plaintext block to cipher state (mu)
+	 * and add initial round key (sigma[K^0]):
+	 */
+	for (i = 0, pos = 0; i < 4; i++, pos += 4) {
+		state[i] =
+			(plaintext[pos    ] << 24) ^
+			(plaintext[pos + 1] << 16) ^
+			(plaintext[pos + 2] <<  8) ^
+			(plaintext[pos + 3]      ) ^
+			roundKey[0][i];
+	}
+
+	/*
+	 * R - 1 full rounds:
+	 */
+
+	for (r = 1; r < R; r++) {
+		inter[0] =
+			T0[(state[0] >> 24)       ] ^
+			T1[(state[1] >> 24)       ] ^
+			T2[(state[2] >> 24)       ] ^
+			T3[(state[3] >> 24)       ] ^
+			roundKey[r][0];
+		inter[1] =
+			T0[(state[0] >> 16) & 0xff] ^
+			T1[(state[1] >> 16) & 0xff] ^
+			T2[(state[2] >> 16) & 0xff] ^
+			T3[(state[3] >> 16) & 0xff] ^
+			roundKey[r][1];
+		inter[2] =
+			T0[(state[0] >>  8) & 0xff] ^
+			T1[(state[1] >>  8) & 0xff] ^
+			T2[(state[2] >>  8) & 0xff] ^
+			T3[(state[3] >>  8) & 0xff] ^
+			roundKey[r][2];
+		inter[3] =
+			T0[(state[0]      ) & 0xff] ^
+			T1[(state[1]      ) & 0xff] ^
+			T2[(state[2]      ) & 0xff] ^
+			T3[(state[3]      ) & 0xff] ^
+			roundKey[r][3];
+		state[0] = inter[0];
+		state[1] = inter[1];
+		state[2] = inter[2];
+		state[3] = inter[3];
+	}
+
+	/*
+	 * last round:
+	 */
+
+	inter[0] =
+		(T0[(state[0] >> 24)       ] & 0xff000000U) ^
+		(T1[(state[1] >> 24)       ] & 0x00ff0000U) ^
+		(T2[(state[2] >> 24)       ] & 0x0000ff00U) ^
+		(T3[(state[3] >> 24)       ] & 0x000000ffU) ^
+		roundKey[R][0];
+	inter[1] =
+		(T0[(state[0] >> 16) & 0xff] & 0xff000000U) ^
+		(T1[(state[1] >> 16) & 0xff] & 0x00ff0000U) ^
+		(T2[(state[2] >> 16) & 0xff] & 0x0000ff00U) ^
+		(T3[(state[3] >> 16) & 0xff] & 0x000000ffU) ^
+		roundKey[R][1];
+	inter[2] =
+		(T0[(state[0] >>  8) & 0xff] & 0xff000000U) ^
+		(T1[(state[1] >>  8) & 0xff] & 0x00ff0000U) ^
+		(T2[(state[2] >>  8) & 0xff] & 0x0000ff00U) ^
+		(T3[(state[3] >>  8) & 0xff] & 0x000000ffU) ^
+		roundKey[R][2];
+	inter[3] =
+		(T0[(state[0]      ) & 0xff] & 0xff000000U) ^
+		(T1[(state[1]      ) & 0xff] & 0x00ff0000U) ^
+		(T2[(state[2]      ) & 0xff] & 0x0000ff00U) ^
+		(T3[(state[3]      ) & 0xff] & 0x000000ffU) ^
+		roundKey[R][3];
+
+	/*
+	 * map cipher state to ciphertext block (mu^{-1}):
+	 */
+
+	for (i = 0, pos = 0; i < 4; i++, pos += 4) {
+		u32 w = inter[i];
+		ciphertext[pos    ] = (u8)(w >> 24);
+		ciphertext[pos + 1] = (u8)(w >> 16);
+		ciphertext[pos + 2] = (u8)(w >>  8);
+		ciphertext[pos + 3] = (u8)(w      );
+	}
+}
+
+static void anubis_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
+{
+	struct anubis_ctx *ctx = ctx_arg;
+	anubis_crypt(ctx->E, dst, src, ctx->R);
+}
+
+static void anubis_decrypt(void *ctx_arg, u8 *dst, const u8 *src)
+{
+	struct anubis_ctx *ctx = ctx_arg;
+	anubis_crypt(ctx->D, dst, src, ctx->R);
+}
+
+static struct crypto_alg anubis_alg = {
+	.cra_name		=	"anubis",
+	.cra_flags		=	CRYPTO_ALG_TYPE_CIPHER,
+	.cra_blocksize		=	ANUBIS_BLOCK_SIZE,
+	.cra_ctxsize		=	sizeof (struct anubis_ctx),
+	.cra_module		=	THIS_MODULE,
+	.cra_list		=	LIST_HEAD_INIT(anubis_alg.cra_list),
+	.cra_u			=	{ .cipher = {
+	.cia_min_keysize	=	ANUBIS_MIN_KEY_SIZE,
+	.cia_max_keysize	=	ANUBIS_MAX_KEY_SIZE,
+	.cia_setkey		= 	anubis_setkey,
+	.cia_encrypt		=	anubis_encrypt,
+	.cia_decrypt		=	anubis_decrypt } }
+};
+
+static int __init init(void)
+{
+	int ret = 0;
+	
+	ret = crypto_register_alg(&anubis_alg);
+	return ret;
+}
+
+static void __exit fini(void)
+{
+	crypto_unregister_alg(&anubis_alg);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Anubis Cryptographic Algorithm");
diff -Nru a/crypto/blowfish.c b/crypto/blowfish.c
--- a/crypto/blowfish.c	2004-12-24 13:36:30 -08:00
+++ b/crypto/blowfish.c	2004-12-24 13:36:30 -08:00
@@ -316,7 +316,7 @@
  * The blowfish encipher, processes 64-bit blocks.
  * NOTE: This function MUSTN'T respect endianess 
  */
-static inline void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src)
+static void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src)
 {
 	const u32 *P = bctx->p;
 	const u32 *S = bctx->s;
diff -Nru a/crypto/serpent.c b/crypto/serpent.c
--- a/crypto/serpent.c	2004-12-24 13:36:32 -08:00
+++ b/crypto/serpent.c	2004-12-24 13:36:32 -08:00
@@ -4,6 +4,10 @@
  * Serpent Cipher Algorithm.
  *
  * Copyright (C) 2002 Dag Arne Osvik <osvik@ii.uib.no>
+ *               2003 Herbert Valerio Riedel <hvr@gnu.org>
+ *
+ * Added tnepres support: Ruben Jesus Garcia Hernandez <ruben@ugr.es>, 18.10.2004
+ *               Based on code by hvr
  *
  * 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
@@ -212,7 +216,8 @@
 	u32 expkey[SERPENT_EXPKEY_WORDS];
 };
 
-static int setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags)
+
+static int serpent_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags)
 {
 	u32 *k = ((struct serpent_ctx *)ctx)->expkey;
 	u8  *k8 = (u8 *)k;
@@ -362,7 +367,7 @@
 	return 0;
 }
 
-static void encrypt(void *ctx, u8 *dst, const u8 *src)
+static void serpent_encrypt(void *ctx, u8 *dst, const u8 *src)
 {
 	const u32
 		*k = ((struct serpent_ctx *)ctx)->expkey,
@@ -420,7 +425,7 @@
 	d[3] = cpu_to_le32(r3);
 }
 
-static void decrypt(void *ctx, u8 *dst, const u8 *src)
+static void serpent_decrypt(void *ctx, u8 *dst, const u8 *src)
 {
 	const u32
 		*k = ((struct serpent_ctx *)ctx)->expkey,
@@ -483,18 +488,101 @@
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	SERPENT_MIN_KEY_SIZE,
 	.cia_max_keysize	=	SERPENT_MAX_KEY_SIZE,
-	.cia_setkey   		= 	setkey,
-	.cia_encrypt 		=	encrypt,
-	.cia_decrypt  		=	decrypt } }
+	.cia_setkey   		= 	serpent_setkey,
+	.cia_encrypt 		=	serpent_encrypt,
+	.cia_decrypt  		=	serpent_decrypt } }
+};
+
+static int tnepres_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags)
+{
+	u8 rev_key[SERPENT_MAX_KEY_SIZE];
+	int i;
+
+	if ((keylen < SERPENT_MIN_KEY_SIZE)
+	    || (keylen > SERPENT_MAX_KEY_SIZE)) {
+		*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+		return -EINVAL;
+	} 
+
+	for (i = 0; i < keylen; ++i)
+		rev_key[keylen - i - 1] = key[i];
+ 
+	return serpent_setkey(ctx, rev_key, keylen, flags);
+}
+
+static void tnepres_encrypt(void *ctx, u8 *dst, const u8 *src)
+{
+	const u32 * const s = (const u32 * const)src;
+	u32 * const d = (u32 * const)dst;
+
+	u32 rs[4], rd[4];
+
+	rs[0] = swab32(s[3]);
+	rs[1] = swab32(s[2]);
+	rs[2] = swab32(s[1]);
+	rs[3] = swab32(s[0]);
+
+	serpent_encrypt(ctx, (u8 *)rd, (u8 *)rs);
+
+	d[0] = swab32(rd[3]);
+	d[1] = swab32(rd[2]);
+	d[2] = swab32(rd[1]);
+	d[3] = swab32(rd[0]);
+}
+
+static void tnepres_decrypt(void *ctx, u8 *dst, const u8 *src)
+{
+	const u32 * const s = (const u32 * const)src;
+	u32 * const d = (u32 * const)dst;
+
+	u32 rs[4], rd[4];
+
+	rs[0] = swab32(s[3]);
+	rs[1] = swab32(s[2]);
+	rs[2] = swab32(s[1]);
+	rs[3] = swab32(s[0]);
+
+	serpent_decrypt(ctx, (u8 *)rd, (u8 *)rs);
+
+	d[0] = swab32(rd[3]);
+	d[1] = swab32(rd[2]);
+	d[2] = swab32(rd[1]);
+	d[3] = swab32(rd[0]);
+}
+
+static struct crypto_alg tnepres_alg = {
+	.cra_name		=	"tnepres",
+	.cra_flags		=	CRYPTO_ALG_TYPE_CIPHER,
+	.cra_blocksize		=	SERPENT_BLOCK_SIZE,
+	.cra_ctxsize		=	sizeof(struct serpent_ctx),
+	.cra_module		=	THIS_MODULE,
+	.cra_list		=	LIST_HEAD_INIT(serpent_alg.cra_list),
+	.cra_u			=	{ .cipher = {
+	.cia_min_keysize	=	SERPENT_MIN_KEY_SIZE,
+	.cia_max_keysize	=	SERPENT_MAX_KEY_SIZE,
+	.cia_setkey   		= 	tnepres_setkey,
+	.cia_encrypt 		=	tnepres_encrypt,
+	.cia_decrypt  		=	tnepres_decrypt } }
 };
 
 static int __init init(void)
 {
-	return crypto_register_alg(&serpent_alg);
+	int ret = crypto_register_alg(&serpent_alg);
+
+	if (ret)
+		return ret;
+
+	ret = crypto_register_alg(&tnepres_alg);
+
+	if (ret)
+		crypto_unregister_alg(&serpent_alg);
+
+	return ret;
 }
 
 static void __exit fini(void)
 {
+	crypto_unregister_alg(&tnepres_alg);
 	crypto_unregister_alg(&serpent_alg);
 }
 
@@ -502,5 +590,6 @@
 module_exit(fini);
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Serpent Cipher Algorithm");
+MODULE_DESCRIPTION("Serpent and tnepres (kerneli compatible serpent reversed) Cipher Algorithm");
 MODULE_AUTHOR("Dag Arne Osvik <osvik@ii.uib.no>");
+MODULE_ALIAS("tnepres");
diff -Nru a/crypto/sha256.c b/crypto/sha256.c
--- a/crypto/sha256.c	2004-12-24 13:36:47 -08:00
+++ b/crypto/sha256.c	2004-12-24 13:36:47 -08:00
@@ -63,15 +63,7 @@
 
 static inline void LOAD_OP(int I, u32 *W, const u8 *input)
 {
-	u32 t1 = input[(4 * I)] & 0xff;
-
-	t1 <<= 8;
-	t1 |= input[(4 * I) + 1] & 0xff;
-	t1 <<= 8;
-	t1 |= input[(4 * I) + 2] & 0xff;
-	t1 <<= 8;
-	t1 |= input[(4 * I) + 3] & 0xff;
-	W[I] = t1;
+	W[I] = __be32_to_cpu( ((u32*)(input))[I] );
 }
 
 static inline void BLEND_OP(int I, u32 *W)
diff -Nru a/crypto/sha512.c b/crypto/sha512.c
--- a/crypto/sha512.c	2004-12-24 13:37:29 -08:00
+++ b/crypto/sha512.c	2004-12-24 13:37:29 -08:00
@@ -30,6 +30,7 @@
 	u64 state[8];
 	u32 count[4];
 	u8 buf[128];
+	u64 W[80];
 };
 
 static inline u64 Ch(u64 x, u64 y, u64 z)
@@ -104,34 +105,18 @@
 
 static inline void LOAD_OP(int I, u64 *W, const u8 *input)
 {
-        u64 t1  = input[(8*I)  ] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+1] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+2] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+3] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+4] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+5] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+6] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+7] & 0xff;
-        W[I] = t1;
+	W[I] = __be64_to_cpu( ((u64*)(input))[I] );
 }
 
 static inline void BLEND_OP(int I, u64 *W)
 {
-        W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
+	W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
 }
 
 static void
-sha512_transform(u64 *state, const u8 *input)
+sha512_transform(u64 *state, u64 *W, const u8 *input)
 {
 	u64 a, b, c, d, e, f, g, h, t1, t2;
-	u64 W[80];
 
 	int i;
 
@@ -172,7 +157,6 @@
 
 	/* erase our data */
 	a = b = c = d = e = f = g = h = t1 = t2 = 0;
-	memset(W, 0, 80 * sizeof(u64));
 }
 
 static void
@@ -230,10 +214,10 @@
 	/* Transform as many times as possible. */
 	if (len >= part_len) {
 		memcpy(&sctx->buf[index], data, part_len);
-		sha512_transform(sctx->state, sctx->buf);
+		sha512_transform(sctx->state, sctx->W, sctx->buf);
 
 		for (i = part_len; i + 127 < len; i+=128)
-			sha512_transform(sctx->state, &data[i]);
+			sha512_transform(sctx->state, sctx->W, &data[i]);
 
 		index = 0;
 	} else {
@@ -242,6 +226,9 @@
 
 	/* Buffer remaining input */
 	memcpy(&sctx->buf[index], &data[i], len - i);
+
+	/* erase our data */
+	memset(sctx->W, 0, sizeof(sctx->W));
 }
 
 static void
diff -Nru a/crypto/tcrypt.c b/crypto/tcrypt.c
--- a/crypto/tcrypt.c	2004-12-24 13:37:18 -08:00
+++ b/crypto/tcrypt.c	2004-12-24 13:37:18 -08:00
@@ -63,7 +63,7 @@
 	"des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish",
 	"twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", 
 	"arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", 
-	"wp512", "wp384", "wp256", NULL
+	"khazad", "wp512", "wp384", "wp256", "tnepres", NULL
 };
 
 static void
@@ -651,6 +651,10 @@
 		test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS);
 		test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS);
 		
+		//TNEPRES
+		test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS);
+		test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS);
+
 		//AES
 		test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS);
 		test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS);
@@ -680,6 +684,12 @@
 		test_cipher ("khazad", MODE_ECB, ENCRYPT, khazad_enc_tv_template, KHAZAD_ENC_TEST_VECTORS);
 		test_cipher ("khazad", MODE_ECB, DECRYPT, khazad_dec_tv_template, KHAZAD_DEC_TEST_VECTORS);
 
+		//ANUBIS
+		test_cipher ("anubis", MODE_ECB, ENCRYPT, anubis_enc_tv_template, ANUBIS_ENC_TEST_VECTORS);
+		test_cipher ("anubis", MODE_ECB, DECRYPT, anubis_dec_tv_template, ANUBIS_DEC_TEST_VECTORS);
+		test_cipher ("anubis", MODE_CBC, ENCRYPT, anubis_cbc_enc_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
+		test_cipher ("anubis", MODE_CBC, DECRYPT, anubis_cbc_dec_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
+
 		test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
 		test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
 		test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
@@ -739,6 +749,8 @@
 		break;
 		
 	case 9:
+		test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS);
+		test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS);
 		break;
 
 	case 10:
@@ -808,6 +820,17 @@
 		test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS);
 		break;
 
+	case 25:
+		test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS);
+		test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS);
+		break;
+
+	case 26:
+		test_cipher ("anubis", MODE_ECB, ENCRYPT, anubis_enc_tv_template, ANUBIS_ENC_TEST_VECTORS);
+		test_cipher ("anubis", MODE_ECB, DECRYPT, anubis_dec_tv_template, ANUBIS_DEC_TEST_VECTORS);
+		test_cipher ("anubis", MODE_CBC, ENCRYPT, anubis_cbc_enc_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
+		test_cipher ("anubis", MODE_CBC, DECRYPT, anubis_cbc_dec_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
+		break;
 
 #ifdef CONFIG_CRYPTO_HMAC
 	case 100:
diff -Nru a/crypto/tcrypt.h b/crypto/tcrypt.h
--- a/crypto/tcrypt.h	2004-12-24 13:37:19 -08:00
+++ b/crypto/tcrypt.h	2004-12-24 13:37:19 -08:00
@@ -1444,6 +1444,9 @@
 #define SERPENT_ENC_TEST_VECTORS	4
 #define SERPENT_DEC_TEST_VECTORS	4
 
+#define TNEPRES_ENC_TEST_VECTORS	4
+#define TNEPRES_DEC_TEST_VECTORS	4
+
 struct cipher_testvec serpent_enc_tv_template[] = 
 {
 	{
@@ -1486,6 +1489,57 @@
 	},
 };
 
+struct cipher_testvec tnepres_enc_tv_template[] = 
+{
+	{ /* KeySize=128, PT=0, I=1 */
+		.input	= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+		.key    = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+		.klen   = 16,
+		.ilen	= 16,
+		.result	= { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05, 
+			    0x2c, 0xd8, 0xff, 0xa5, 0x98, 0x6b, 0xd2, 0xdd },
+		.rlen	= 16,
+	}, { /* KeySize=192, PT=0, I=1 */
+		.key	= { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+		.klen	= 24,
+		.input	= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+		.ilen	= 16,
+		.result	= { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68, 
+			    0xac, 0x36, 0x78, 0xf7, 0xa3, 0xf6, 0x0c, 0x66 },
+		.rlen	= 16,
+	}, { /* KeySize=256, PT=0, I=1 */
+		.key	= { 0x80, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+		.klen	= 32,
+		.input	= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+		.ilen	= 16,
+		.result	= { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb, 
+			    0xc0, 0xeb, 0xd2, 0x1a, 0x82, 0xef, 0x08, 0x19 },
+		.rlen	= 16,
+	}, { /* KeySize=256, I=257 */
+	        .key	= { 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
+			    0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
+			    0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
+			    0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
+		.klen	= 32,
+		.input	= { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
+			    0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
+		.ilen	= 16,
+		.result	= { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b, 
+			    0xb8, 0x32, 0xe4, 0x33, 0xf8, 0x9f, 0x26, 0xde },
+		.rlen	= 16,
+	},
+};
+
+
 struct cipher_testvec serpent_dec_tv_template[] = 
 {
 	{
@@ -1528,6 +1582,49 @@
 	},
 };
 
+struct cipher_testvec tnepres_dec_tv_template[] =
+{
+	{
+		.input	= { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97,
+			    0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 },
+		.ilen	= 16,
+		.result	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+			    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+		.rlen	= 16,
+	}, {
+		.key	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+			    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+		.klen	= 16,
+		.input	= { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47, 
+			    0x81, 0x45, 0x0b, 0xfa, 0x0c, 0xd6, 0xad, 0x6e },
+		.ilen	= 16,
+		.result	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+			    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+		.rlen	= 16,
+	}, {
+		.key	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+			    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+			    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+			    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
+		.klen	= 32,
+		.input	= { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49, 
+			    0xa8, 0x4e, 0x76, 0xd6, 0xf5, 0x0d, 0x78, 0xee },
+		.ilen	= 16,
+		.result	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+			    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+		.rlen	= 16,
+	}, { /* KeySize=128, I=121 */
+		.key	= { [15] = 0x80 },
+		.klen	= 16,
+		.input	= { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06, 
+			    0x46, 0x2a, 0xf4, 0xef, 0x81, 0x54, 0x4e, 0x26 },
+		.ilen	= 16,
+		.result	= { [0 ... 15] = 0x00 },
+		.rlen	= 16,
+	},
+};
+
+
 /* Cast6 test vectors from RFC 2612 */
 #define CAST6_ENC_TEST_VECTORS	3
 #define CAST6_DEC_TEST_VECTORS  3
@@ -2166,6 +2263,211 @@
 		.result	= { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
 			    0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
 		.rlen	= 16,
+	},
+};
+
+/*
+ * Anubis test vectors.
+ */
+
+#define ANUBIS_ENC_TEST_VECTORS			5
+#define ANUBIS_DEC_TEST_VECTORS			5
+#define ANUBIS_CBC_ENC_TEST_VECTORS		2
+#define ANUBIS_CBC_DEC_TEST_VECTORS		2
+
+struct cipher_testvec anubis_enc_tv_template[] = {
+	{
+		.key	= { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
+		.klen	= 16,
+		.input	= { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
+		.ilen	= 16,
+		.result	= { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
+			    0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
+		.rlen	= 16,
+	}, {
+
+		.key	= { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+			    0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+			    0x03, 0x03, 0x03, 0x03 },
+		.klen	= 20,
+		.input	= { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+			    0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
+		.ilen	= 16,
+		.result	= { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
+			    0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
+		.rlen	= 16,
+	}, {
+		.key	= { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+			    0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+			    0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+			    0x24, 0x24, 0x24, 0x24 },
+		.klen	= 28,
+		.input	= { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+			    0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
+		.ilen	= 16,
+		.result	= { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
+			    0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
+		.rlen	= 16,
+	}, {
+		.key	= { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
+			    0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
+			    0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
+			    0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
+		.klen	= 32,
+		.input	= { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
+			    0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
+		.ilen	= 16,
+		.result	= { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
+		            0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
+		.rlen	= 16,
+	}, {
+		.key	= { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
+		.klen	= 40,
+		.input	= { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
+		.ilen	= 16,
+		.result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
+			    0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
+		.rlen	= 16,
+	},
+};
+
+struct cipher_testvec anubis_dec_tv_template[] = {
+	{
+		.key	= { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
+		.klen	= 16,
+		.input	= { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
+			    0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
+		.ilen	= 16,
+		.result	= { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
+		.rlen	= 16,
+	}, {
+
+		.key	= { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+			    0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+			    0x03, 0x03, 0x03, 0x03 },
+		.klen	= 20,
+		.input	= { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
+			    0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
+		.ilen	= 16,
+		.result	= { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+			    0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
+		.rlen	= 16,
+	}, {
+		.key	= { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+			    0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+			    0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+			    0x24, 0x24, 0x24, 0x24 },
+		.klen	= 28,
+		.input	= { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
+			    0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
+		.ilen	= 16,
+		.result	= { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+			    0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
+		.rlen	= 16,
+	}, {
+		.key	= { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
+			    0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
+			    0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
+			    0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
+		.klen	= 32,
+		.input	= { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
+		            0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
+		.ilen	= 16,
+		.result	= { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
+			    0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
+		.rlen	= 16,
+	}, {
+		.key	= { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
+		.input = {  0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
+			    0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
+		.klen	= 40,
+		.ilen	= 16,
+		.result	= { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
+		.rlen	= 16,
+	},
+};
+
+struct cipher_testvec anubis_cbc_enc_tv_template[] = {
+	{
+		.key	= { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
+		.klen	= 16,
+		.input	= { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
+		.ilen	= 32,
+		.result	= { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
+			    0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
+			    0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
+			    0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
+		.rlen	= 32,
+	}, {
+		.key	= { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
+		.klen	= 40,
+		.input	= { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
+		.ilen	= 32,
+		.result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
+			    0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
+			    0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
+			    0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
+		.rlen	= 32,
+	},
+};
+
+struct cipher_testvec anubis_cbc_dec_tv_template[] = {
+	{
+		.key	= { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
+		.klen	= 16,
+		.input	= { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
+			    0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
+			    0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
+			    0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
+		.ilen	= 32,
+		.result	= { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+			    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
+		.rlen	= 32,
+	}, {
+		.key	= { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
+		.klen	= 40,
+		.input = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
+			    0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
+			    0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
+			    0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
+		.ilen	= 32,
+		.result	= { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
+			    0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
+		.rlen	= 32,
 	},
 };
 
diff -Nru a/drivers/Kconfig b/drivers/Kconfig
--- a/drivers/Kconfig	2004-12-24 13:37:29 -08:00
+++ b/drivers/Kconfig	2004-12-24 13:37:29 -08:00
@@ -54,4 +54,6 @@
 
 source "drivers/usb/Kconfig"
 
+source "drivers/mmc/Kconfig"
+
 endmenu
diff -Nru a/drivers/Makefile b/drivers/Makefile
--- a/drivers/Makefile	2004-12-24 13:37:44 -08:00
+++ b/drivers/Makefile	2004-12-24 13:37:44 -08:00
@@ -17,8 +17,9 @@
 # default.
 obj-y				+= char/
 
-# i810fb depends on char/agp/
+# i810fb and intelfb depend on char/agp/
 obj-$(CONFIG_FB_I810)           += video/i810/
+obj-$(CONFIG_FB_INTEL)          += video/intelfb/
 
 # we also need input/serio early so serio bus is initialized by the time
 # serial drivers start registering their serio ports
@@ -36,7 +37,7 @@
 obj-$(CONFIG_IEEE1394)		+= ieee1394/
 obj-y				+= cdrom/
 obj-$(CONFIG_MTD)		+= mtd/
-obj-$(CONFIG_PCMCIA)		+= pcmcia/
+obj-$(CONFIG_PCCARD)		+= pcmcia/
 obj-$(CONFIG_DIO)		+= dio/
 obj-$(CONFIG_SBUS)		+= sbus/
 obj-$(CONFIG_ZORRO)		+= zorro/
diff -Nru a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c
--- a/drivers/acorn/block/fd1772.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/acorn/block/fd1772.c	2004-12-24 13:36:47 -08:00
@@ -138,9 +138,9 @@
 #include <linux/types.h>
 #include <linux/delay.h>
 #include <linux/mm.h>
+#include <linux/bitops.h>
 
 #include <asm/arch/oldlatches.h>
-#include <asm/bitops.h>
 #include <asm/dma.h>
 #include <asm/hardware.h>
 #include <asm/hardware/ioc.h>
diff -Nru a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
--- a/drivers/acpi/Kconfig	2004-12-24 13:37:31 -08:00
+++ b/drivers/acpi/Kconfig	2004-12-24 13:37:31 -08:00
@@ -110,6 +110,21 @@
 	  down the system.  Until then, you can cat it, and see output when
 	  a button is pressed.
 
+config ACPI_VIDEO
+	tristate "Video"
+	depends on ACPI_INTERPRETER
+	depends on EXPERIMENTAL
+	depends on !IA64_SGI_SN
+	default m
+	help
+	  This driver implement the ACPI Extensions For Display Adapters
+	  for integrated graphics devices on motherboard, as specified in
+	  ACPI 2.0 Specification, Appendix B, allowing to perform some basic
+	  control like defining the video POST device, retrieving EDID information
+	  or to setup a video output, etc.
+	  Note that this is an ref. implementation only.  It may or may not work
+	  for your integrated video device.
+
 config ACPI_FAN
 	tristate "Fan"
 	depends on ACPI_INTERPRETER
@@ -176,6 +191,20 @@
           something works not quite as expected, please use the mailing list
           available on the above page (acpi4asus-user@lists.sourceforge.net)
           
+config ACPI_IBM
+	tristate "IBM ThinkPad Laptop Extras"
+	depends on X86
+	depends on ACPI_INTERPRETER
+	default m
+	---help---
+	  This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds
+	  support for Fn-Fx key combinations, Bluetooth control, video
+	  output switching, ThinkLight control, UltraBay eject and more.
+	  For more information about this driver see Documentation/ibm-acpi.txt
+	  and http://ibm-acpi.sf.net/ .
+
+	  If you have an IBM ThinkPad laptop, say Y or M here.
+
 config ACPI_TOSHIBA
 	tristate "Toshiba Laptop Extras"
 	depends on X86
@@ -206,7 +235,7 @@
 
 config ACPI_CUSTOM_DSDT
 	bool "Include Custom DSDT"
-	depends on X86 && ACPI_INTERPRETER && !STANDALONE
+	depends on ACPI_INTERPRETER && !STANDALONE
 	default n 
 	help
 	  Thist option is to load a custom ACPI DSDT
diff -Nru a/drivers/acpi/Makefile b/drivers/acpi/Makefile
--- a/drivers/acpi/Makefile	2004-12-24 13:37:29 -08:00
+++ b/drivers/acpi/Makefile	2004-12-24 13:37:29 -08:00
@@ -12,8 +12,6 @@
 
 EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
 
-obj-$(CONFIG_ACPI)		:= acpi_ksyms.o 
-
 #
 # ACPI Boot-Time Table Parsing
 #
@@ -38,6 +36,7 @@
 obj-$(CONFIG_ACPI_BUTTON)	+= button.o
 obj-$(CONFIG_ACPI_EC)		+= ec.o
 obj-$(CONFIG_ACPI_FAN)		+= fan.o
+obj-$(CONFIG_ACPI_VIDEO)	+= video.o
 obj-$(CONFIG_ACPI_PCI)		+= pci_root.o pci_link.o pci_irq.o pci_bind.o
 obj-$(CONFIG_ACPI_POWER)	+= power.o
 obj-$(CONFIG_ACPI_PROCESSOR)	+= processor.o
@@ -46,5 +45,6 @@
 obj-$(CONFIG_ACPI_DEBUG)	+= debug.o
 obj-$(CONFIG_ACPI_NUMA)		+= numa.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
+obj-$(CONFIG_ACPI_IBM)		+= ibm_acpi.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
 obj-$(CONFIG_ACPI_BUS)		+= scan.o motherboard.o
diff -Nru a/drivers/acpi/ac.c b/drivers/acpi/ac.c
--- a/drivers/acpi/ac.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/acpi/ac.c	2004-12-24 13:36:48 -08:00
@@ -117,11 +117,11 @@
 	ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
 
 	if (!ac)
-		return 0;
+		return_VALUE(0);
 
 	if (acpi_ac_get_state(ac)) {
 		seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
-		return 0;
+		return_VALUE(0);
 	}
 
 	seq_puts(seq, "state:                   ");
@@ -137,7 +137,7 @@
 		break;
 	}
 
-	return 0;
+	return_VALUE(0);
 }
 	
 static int acpi_ac_open_fs(struct inode *inode, struct file *file)
@@ -212,7 +212,7 @@
 	ACPI_FUNCTION_TRACE("acpi_ac_notify");
 
 	if (!ac)
-		return;
+		return_VOID;
 
 	if (acpi_bus_get_device(ac->handle, &device))
 		return_VOID;
diff -Nru a/drivers/acpi/acpi_ksyms.c b/drivers/acpi/acpi_ksyms.c
--- a/drivers/acpi/acpi_ksyms.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,159 +0,0 @@
-/*
- *  acpi_ksyms.c - ACPI Kernel Symbols ($Revision: 16 $)
- *
- *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
- *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.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 program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-#include <linux/module.h>
-#include <linux/acpi.h>
-#include <acpi/acpi.h>
-#include <acpi/acpi_bus.h>
-
-
-#ifdef CONFIG_ACPI_INTERPRETER
-
-/* ACPI Debugger */
-
-#ifdef ENABLE_DEBUGGER
-
-extern int			acpi_in_debugger;
-
-EXPORT_SYMBOL(acpi_in_debugger);
-EXPORT_SYMBOL(acpi_db_user_commands);
-
-#endif /* ENABLE_DEBUGGER */
-
-/* ACPI Core Subsystem */
-
-#ifdef ACPI_DEBUG_OUTPUT
-EXPORT_SYMBOL(acpi_dbg_layer);
-EXPORT_SYMBOL(acpi_dbg_level);
-EXPORT_SYMBOL(acpi_ut_debug_print_raw);
-EXPORT_SYMBOL(acpi_ut_debug_print);
-EXPORT_SYMBOL(acpi_ut_status_exit);
-EXPORT_SYMBOL(acpi_ut_value_exit);
-EXPORT_SYMBOL(acpi_ut_exit);
-EXPORT_SYMBOL(acpi_ut_trace);
-#endif /*ACPI_DEBUG_OUTPUT*/
-
-EXPORT_SYMBOL(acpi_get_handle);
-EXPORT_SYMBOL(acpi_get_parent);
-EXPORT_SYMBOL(acpi_get_type);
-EXPORT_SYMBOL(acpi_get_name);
-EXPORT_SYMBOL(acpi_get_object_info);
-EXPORT_SYMBOL(acpi_get_next_object);
-EXPORT_SYMBOL(acpi_evaluate_object);
-EXPORT_SYMBOL(acpi_get_table);
-EXPORT_SYMBOL(acpi_get_firmware_table);
-EXPORT_SYMBOL(acpi_install_notify_handler);
-EXPORT_SYMBOL(acpi_remove_notify_handler);
-EXPORT_SYMBOL(acpi_install_gpe_handler);
-EXPORT_SYMBOL(acpi_remove_gpe_handler);
-EXPORT_SYMBOL(acpi_install_address_space_handler);
-EXPORT_SYMBOL(acpi_remove_address_space_handler);
-EXPORT_SYMBOL(acpi_install_fixed_event_handler);
-EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
-EXPORT_SYMBOL(acpi_acquire_global_lock);
-EXPORT_SYMBOL(acpi_release_global_lock);
-EXPORT_SYMBOL(acpi_install_gpe_block);
-EXPORT_SYMBOL(acpi_remove_gpe_block);
-EXPORT_SYMBOL(acpi_get_current_resources);
-EXPORT_SYMBOL(acpi_get_possible_resources);
-EXPORT_SYMBOL(acpi_walk_resources);
-EXPORT_SYMBOL(acpi_set_current_resources);
-EXPORT_SYMBOL(acpi_resource_to_address64);
-EXPORT_SYMBOL(acpi_enable_event);
-EXPORT_SYMBOL(acpi_disable_event);
-EXPORT_SYMBOL(acpi_clear_event);
-EXPORT_SYMBOL(acpi_set_gpe_type);
-EXPORT_SYMBOL(acpi_enable_gpe);
-EXPORT_SYMBOL(acpi_get_timer_duration);
-EXPORT_SYMBOL(acpi_get_timer);
-EXPORT_SYMBOL(acpi_get_sleep_type_data);
-EXPORT_SYMBOL(acpi_get_register);
-EXPORT_SYMBOL(acpi_set_register);
-EXPORT_SYMBOL(acpi_enter_sleep_state);
-EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
-EXPORT_SYMBOL(acpi_get_system_info);
-EXPORT_SYMBOL(acpi_get_devices);
-
-/* ACPI OS Services Layer (acpi_osl.c) */
-
-EXPORT_SYMBOL(acpi_os_free);
-EXPORT_SYMBOL(acpi_os_printf);
-EXPORT_SYMBOL(acpi_os_sleep);
-EXPORT_SYMBOL(acpi_os_stall);
-EXPORT_SYMBOL(acpi_os_signal);
-EXPORT_SYMBOL(acpi_os_queue_for_execution);
-EXPORT_SYMBOL(acpi_os_signal_semaphore);
-EXPORT_SYMBOL(acpi_os_create_semaphore);
-EXPORT_SYMBOL(acpi_os_delete_semaphore);
-EXPORT_SYMBOL(acpi_os_wait_semaphore);
-EXPORT_SYMBOL(acpi_os_wait_events_complete);
-EXPORT_SYMBOL(acpi_os_read_pci_configuration);
-
-/* ACPI Utilities (acpi_utils.c) */
-
-EXPORT_SYMBOL(acpi_extract_package);
-EXPORT_SYMBOL(acpi_evaluate_integer);
-EXPORT_SYMBOL(acpi_evaluate_reference);
-
-#endif /*CONFIG_ACPI_INTERPRETER*/
-
-
-/* ACPI Bus Driver (acpi_bus.c) */
-
-#ifdef CONFIG_ACPI_BUS
-
-EXPORT_SYMBOL(acpi_fadt);
-EXPORT_SYMBOL(acpi_walk_namespace);
-EXPORT_SYMBOL(acpi_root_dir);
-EXPORT_SYMBOL(acpi_bus_get_device);
-EXPORT_SYMBOL(acpi_bus_get_status);
-EXPORT_SYMBOL(acpi_bus_get_power);
-EXPORT_SYMBOL(acpi_bus_set_power);
-EXPORT_SYMBOL(acpi_bus_generate_event);
-EXPORT_SYMBOL(acpi_bus_receive_event);
-EXPORT_SYMBOL(acpi_bus_register_driver);
-EXPORT_SYMBOL(acpi_bus_unregister_driver);
-
-#endif /*CONFIG_ACPI_BUS*/
-
-
-/* ACPI PCI Driver (pci_irq.c) */
-
-#ifdef CONFIG_ACPI_PCI
-
-#include <linux/pci.h>
-extern int acpi_pci_irq_enable(struct pci_dev *dev);
-EXPORT_SYMBOL(acpi_pci_irq_enable);
-EXPORT_SYMBOL(acpi_pci_register_driver);
-EXPORT_SYMBOL(acpi_pci_unregister_driver);
-#endif /*CONFIG_ACPI_PCI */
-
-#ifdef CONFIG_ACPI_EC
-/* ACPI EC driver (ec.c) */
-
-EXPORT_SYMBOL(ec_read);
-EXPORT_SYMBOL(ec_write);
-#endif
-
diff -Nru a/drivers/acpi/battery.c b/drivers/acpi/battery.c
--- a/drivers/acpi/battery.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/acpi/battery.c	2004-12-24 13:37:04 -08:00
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <asm/uaccess.h>
 
 #include <acpi/acpi_bus.h>
@@ -341,32 +342,22 @@
    -------------------------------------------------------------------------- */
 
 struct proc_dir_entry		*acpi_battery_dir;
-
-static int
-acpi_battery_read_info (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*data)
+static int acpi_battery_read_info(struct seq_file *seq, void *offset)
 {
 	int			result = 0;
-	struct acpi_battery	*battery = (struct acpi_battery *) data;
+	struct acpi_battery	*battery = (struct acpi_battery *) seq->private;
 	struct acpi_battery_info *bif = NULL;
 	char			*units = "?";
-	char			*p = page;
-	int			len = 0;
 
 	ACPI_FUNCTION_TRACE("acpi_battery_read_info");
 
-	if (!battery || (off != 0))
+	if (!battery)
 		goto end;
 
 	if (battery->flags.present)
-		p += sprintf(p, "present:                 yes\n");
+		seq_printf(seq, "present:                 yes\n");
 	else {
-		p += sprintf(p, "present:                 no\n");
+		seq_printf(seq, "present:                 no\n");
 		goto end;
 	}
 
@@ -374,98 +365,88 @@
 
 	result = acpi_battery_get_info(battery, &bif);
 	if (result || !bif) {
-		p += sprintf(p, "ERROR: Unable to read battery information\n");
+		seq_printf(seq, "ERROR: Unable to read battery information\n");
 		goto end;
 	}
 
 	units = bif->power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
 					
 	if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
-		p += sprintf(p, "design capacity:         unknown\n");
+		seq_printf(seq, "design capacity:         unknown\n");
 	else
-		p += sprintf(p, "design capacity:         %d %sh\n",
+		seq_printf(seq, "design capacity:         %d %sh\n",
 			(u32) bif->design_capacity, units);
 
 	if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
-		p += sprintf(p, "last full capacity:      unknown\n");
+		seq_printf(seq, "last full capacity:      unknown\n");
 	else
-		p += sprintf(p, "last full capacity:      %d %sh\n",
+		seq_printf(seq, "last full capacity:      %d %sh\n",
 			(u32) bif->last_full_capacity, units);
 
 	switch ((u32) bif->battery_technology) {
 	case 0:
-		p += sprintf(p, "battery technology:      non-rechargeable\n");
+		seq_printf(seq, "battery technology:      non-rechargeable\n");
 		break;
 	case 1:
-		p += sprintf(p, "battery technology:      rechargeable\n");
+		seq_printf(seq, "battery technology:      rechargeable\n");
 		break;
 	default:
-		p += sprintf(p, "battery technology:      unknown\n");
+		seq_printf(seq, "battery technology:      unknown\n");
 		break;
 	}
 
 	if (bif->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
-		p += sprintf(p, "design voltage:          unknown\n");
+		seq_printf(seq, "design voltage:          unknown\n");
 	else
-		p += sprintf(p, "design voltage:          %d mV\n",
+		seq_printf(seq, "design voltage:          %d mV\n",
 			(u32) bif->design_voltage);
 	
-	p += sprintf(p, "design capacity warning: %d %sh\n",
+	seq_printf(seq, "design capacity warning: %d %sh\n",
 		(u32) bif->design_capacity_warning, units);
-	p += sprintf(p, "design capacity low:     %d %sh\n",
+	seq_printf(seq, "design capacity low:     %d %sh\n",
 		(u32) bif->design_capacity_low, units);
-	p += sprintf(p, "capacity granularity 1:  %d %sh\n",
+	seq_printf(seq, "capacity granularity 1:  %d %sh\n",
 		(u32) bif->battery_capacity_granularity_1, units);
-	p += sprintf(p, "capacity granularity 2:  %d %sh\n",
+	seq_printf(seq, "capacity granularity 2:  %d %sh\n",
 		(u32) bif->battery_capacity_granularity_2, units);
-	p += sprintf(p, "model number:            %s\n",
+	seq_printf(seq, "model number:            %s\n",
 		bif->model_number);
-	p += sprintf(p, "serial number:           %s\n",
+	seq_printf(seq, "serial number:           %s\n",
 		bif->serial_number);
-	p += sprintf(p, "battery type:            %s\n",
+	seq_printf(seq, "battery type:            %s\n",
 		bif->battery_type);
-	p += sprintf(p, "OEM info:                %s\n",
+	seq_printf(seq, "OEM info:                %s\n",
 		bif->oem_info);
 
 end:
 	kfree(bif);
 
-	len = (p - page);
-	if (len <= off+count) *eof = 1;
-	*start = page + off;
-	len -= off;
-	if (len>count) len = count;
-	if (len<0) len = 0;
+	return_VALUE(0);
+}
 
-	return_VALUE(len);
+static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_battery_read_info, PDE(inode)->data);
 }
 
 
 static int
-acpi_battery_read_state (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*data)
+acpi_battery_read_state (struct seq_file *seq, void *offset)
 {
 	int			result = 0;
-	struct acpi_battery	*battery = (struct acpi_battery *) data;
+	struct acpi_battery	*battery = (struct acpi_battery *) seq->private;
 	struct acpi_battery_status *bst = NULL;
 	char			*units = "?";
-	char			*p = page;
-	int			len = 0;
 
 	ACPI_FUNCTION_TRACE("acpi_battery_read_state");
 
-	if (!battery || (off != 0))
+	if (!battery)
 		goto end;
 
 	if (battery->flags.present)
-		p += sprintf(p, "present:                 yes\n");
+		seq_printf(seq, "present:                 yes\n");
 	else {
-		p += sprintf(p, "present:                 no\n");
+		seq_printf(seq, "present:                 no\n");
 		goto end;
 	}
 
@@ -477,81 +458,71 @@
 
 	result = acpi_battery_get_status(battery, &bst);
 	if (result || !bst) {
-		p += sprintf(p, "ERROR: Unable to read battery status\n");
+		seq_printf(seq, "ERROR: Unable to read battery status\n");
 		goto end;
 	}
 
 	if (!(bst->state & 0x04))
-		p += sprintf(p, "capacity state:          ok\n");
+		seq_printf(seq, "capacity state:          ok\n");
 	else
-		p += sprintf(p, "capacity state:          critical\n");
+		seq_printf(seq, "capacity state:          critical\n");
 
 	if ((bst->state & 0x01) && (bst->state & 0x02)){
-		p += sprintf(p, "charging state:          charging/discharging\n");
+		seq_printf(seq, "charging state:          charging/discharging\n");
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 					"Battery Charging and Discharging?\n"));
 	}
 	else if (bst->state & 0x01)
-		p += sprintf(p, "charging state:          discharging\n");
+		seq_printf(seq, "charging state:          discharging\n");
 	else if (bst->state & 0x02)
-		p += sprintf(p, "charging state:          charging\n");
+		seq_printf(seq, "charging state:          charging\n");
 	else {
-		p += sprintf(p, "charging state:          charged\n");
+		seq_printf(seq, "charging state:          charged\n");
 	}
 
 	if (bst->present_rate == ACPI_BATTERY_VALUE_UNKNOWN)
-		p += sprintf(p, "present rate:            unknown\n");
+		seq_printf(seq, "present rate:            unknown\n");
 	else
-		p += sprintf(p, "present rate:            %d %s\n",
+		seq_printf(seq, "present rate:            %d %s\n",
 			(u32) bst->present_rate, units);
 
 	if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
-		p += sprintf(p, "remaining capacity:      unknown\n");
+		seq_printf(seq, "remaining capacity:      unknown\n");
 	else
-		p += sprintf(p, "remaining capacity:      %d %sh\n",
+		seq_printf(seq, "remaining capacity:      %d %sh\n",
 			(u32) bst->remaining_capacity, units);
 
 	if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
-		p += sprintf(p, "present voltage:         unknown\n");
+		seq_printf(seq, "present voltage:         unknown\n");
 	else
-		p += sprintf(p, "present voltage:         %d mV\n",
+		seq_printf(seq, "present voltage:         %d mV\n",
 			(u32) bst->present_voltage);
 
 end:
 	kfree(bst);
 
-	len = (p - page);
-	if (len <= off+count) *eof = 1;
-	*start = page + off;
-	len -= off;
-	if (len>count) len = count;
-	if (len<0) len = 0;
+	return_VALUE(0);
+}
 
-	return_VALUE(len);
+static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_battery_read_state, PDE(inode)->data);
 }
 
 
 static int
-acpi_battery_read_alarm (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*data)
+acpi_battery_read_alarm (struct seq_file *seq, void *offset)
 {
-	struct acpi_battery	*battery = (struct acpi_battery *) data;
+	struct acpi_battery	*battery = (struct acpi_battery *) seq->private;
 	char			*units = "?";
-	char			*p = page;
-	int			len = 0;
 
 	ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
 
-	if (!battery || (off != 0))
+	if (!battery)
 		goto end;
 
 	if (!battery->flags.present) {
-		p += sprintf(p, "present:                 no\n");
+		seq_printf(seq, "present:                 no\n");
 		goto end;
 	}
 
@@ -561,34 +532,28 @@
 
 	/* Battery Alarm */
 
-	p += sprintf(p, "alarm:                   ");
+	seq_printf(seq, "alarm:                   ");
 	if (!battery->alarm)
-		p += sprintf(p, "unsupported\n");
+		seq_printf(seq, "unsupported\n");
 	else
-		p += sprintf(p, "%d %sh\n", (u32) battery->alarm, units);
+		seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);
 
 end:
-	len = (p - page);
-	if (len <= off+count) *eof = 1;
-	*start = page + off;
-	len -= off;
-	if (len>count) len = count;
-	if (len<0) len = 0;
-
-	return_VALUE(len);
+	return_VALUE(0);
 }
 
 
-static int
+static ssize_t
 acpi_battery_write_alarm (
-	struct file		*file,
-	const char		__user *buffer,
-	unsigned long		count,
-	void			*data)
+	struct file	*file,
+	const char	__user *buffer,
+	size_t		count,
+	loff_t		*ppos)
 {
 	int			result = 0;
-	struct acpi_battery	*battery = (struct acpi_battery *) data;
 	char			alarm_string[12] = {'\0'};
+	struct seq_file		*m = (struct seq_file *)file->private_data;
+	struct acpi_battery	*battery = (struct acpi_battery *)m->private;
 
 	ACPI_FUNCTION_TRACE("acpi_battery_write_alarm");
 
@@ -611,6 +576,35 @@
 	return_VALUE(count);
 }
 
+static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
+}
+
+static struct file_operations acpi_battery_info_ops = {
+	.open		= acpi_battery_info_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.owner = THIS_MODULE,
+};
+
+static struct file_operations acpi_battery_state_ops = {
+	.open		= acpi_battery_state_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.owner = THIS_MODULE,
+};
+
+static struct file_operations acpi_battery_alarm_ops = {
+	.open		= acpi_battery_alarm_open_fs,
+	.read		= seq_read,
+	.write		= acpi_battery_write_alarm,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.owner = THIS_MODULE,
+};
 
 static int
 acpi_battery_add_fs (
@@ -636,7 +630,7 @@
 			"Unable to create '%s' fs entry\n",
 			ACPI_BATTERY_FILE_INFO));
 	else {
-		entry->read_proc = acpi_battery_read_info;
+		entry->proc_fops = &acpi_battery_info_ops; 
 		entry->data = acpi_driver_data(device);
 		entry->owner = THIS_MODULE;
 	}
@@ -649,7 +643,7 @@
 			"Unable to create '%s' fs entry\n",
 			ACPI_BATTERY_FILE_STATUS));
 	else {
-		entry->read_proc = acpi_battery_read_state;
+		entry->proc_fops = &acpi_battery_state_ops;
 		entry->data = acpi_driver_data(device);
 		entry->owner = THIS_MODULE;
 	}
@@ -662,8 +656,7 @@
 			"Unable to create '%s' fs entry\n",
 			ACPI_BATTERY_FILE_ALARM));
 	else {
-		entry->read_proc = acpi_battery_read_alarm;
-		entry->write_proc = acpi_battery_write_alarm;
+		entry->proc_fops = &acpi_battery_alarm_ops;
 		entry->data = acpi_driver_data(device);
 		entry->owner = THIS_MODULE;
 	}
diff -Nru a/drivers/acpi/bus.c b/drivers/acpi/bus.c
--- a/drivers/acpi/bus.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/acpi/bus.c	2004-12-24 13:37:00 -08:00
@@ -22,6 +22,7 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/list.h>
@@ -44,8 +45,11 @@
 #endif
 
 FADT_DESCRIPTOR			acpi_fadt;
+EXPORT_SYMBOL(acpi_fadt);
+
 struct acpi_device		*acpi_root;
 struct proc_dir_entry		*acpi_root_dir;
+EXPORT_SYMBOL(acpi_root_dir);
 
 #define STRUCT_TO_INT(s)	(*((int*)&s))
 
@@ -80,6 +84,7 @@
 
 	return_VALUE(0);
 }
+EXPORT_SYMBOL(acpi_bus_get_device);
 
 int
 acpi_bus_get_status (
@@ -125,6 +130,7 @@
 
 	return_VALUE(0);
 }
+EXPORT_SYMBOL(acpi_bus_get_status);
 
 
 /* --------------------------------------------------------------------------
@@ -182,6 +188,7 @@
 
 	return_VALUE(0);
 }
+EXPORT_SYMBOL(acpi_bus_get_power);
 
 
 int
@@ -270,6 +277,7 @@
 
 	return_VALUE(result);
 }
+EXPORT_SYMBOL(acpi_bus_set_power);
 
 
 
@@ -319,6 +327,7 @@
 
 	return_VALUE(0);
 }
+EXPORT_SYMBOL(acpi_bus_generate_event);
 
 int
 acpi_bus_receive_event (
@@ -332,7 +341,7 @@
 	ACPI_FUNCTION_TRACE("acpi_bus_receive_event");
 
 	if (!event)
-		return -EINVAL;
+		return_VALUE(-EINVAL);
 
 	if (list_empty(&acpi_bus_event_list)) {
 
@@ -364,6 +373,7 @@
 
 	return_VALUE(0);
 }
+EXPORT_SYMBOL(acpi_bus_receive_event);
 
 
 /* --------------------------------------------------------------------------
@@ -599,7 +609,7 @@
 	ACPI_FUNCTION_TRACE("acpi_early_init");
 
 	if (acpi_disabled)
-		return;
+		return_VOID;
 
 	/* enable workarounds, unless strict ACPI spec. compliance */
 	if (!acpi_strict)
@@ -652,11 +662,11 @@
 		goto error0;
 	}
 
-	return;
+	return_VOID;
 
 error0:
 	disable_acpi();
-	return;
+	return_VOID;
 }
 
 static int __init
@@ -743,7 +753,7 @@
 
 	if (acpi_disabled) {
 		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
-		return -ENODEV;
+		return_VALUE(-ENODEV);
 	}
 
 	firmware_register(&acpi_subsys);
diff -Nru a/drivers/acpi/button.c b/drivers/acpi/button.c
--- a/drivers/acpi/button.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/acpi/button.c	2004-12-24 13:36:17 -08:00
@@ -116,12 +116,12 @@
 	ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
 
 	if (!button || !button->device)
-		return 0;
+		return_VALUE(0);
 
 	seq_printf(seq, "type:                    %s\n", 
 		acpi_device_name(button->device));
 
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
@@ -138,7 +138,7 @@
 	ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
 
 	if (!button || !button->device)
-		return 0;
+		return_VALUE(0);
 
 	status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state);
 	if (ACPI_FAILURE(status)) {
@@ -148,7 +148,7 @@
 		seq_printf(seq, "state:      %s\n", (state ? "open" : "closed")); 
 	}
 
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
diff -Nru a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
--- a/drivers/acpi/dispatcher/dsmthdat.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/acpi/dispatcher/dsmthdat.c	2004-12-24 13:36:47 -08:00
@@ -312,7 +312,7 @@
 
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-		"obj %p op %X, ref count = %d [%s]\n", object,
+		"new_obj %p Opcode %X, Refs=%d [%s]\n", object,
 		opcode, object->common.reference_count,
 		acpi_ut_get_type_name (object->common.type)));
 
@@ -350,7 +350,7 @@
  * RETURN:      Data type of current value of the selected Arg or Local
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_object_type
 acpi_ds_method_data_get_type (
 	u16                             opcode,
@@ -385,6 +385,7 @@
 
 	return_VALUE (ACPI_GET_OBJECT_TYPE (object));
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
@@ -448,7 +449,22 @@
 		 * was referenced by the method (via the ASL)
 		 * before it was initialized.  Either case is an error.
 		 */
-		switch (opcode) {
+
+		/* If slack enabled, init the local_x/arg_x to an Integer of value zero */
+
+		if (acpi_gbl_enable_interpreter_slack) {
+			object = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+			if (!object) {
+				return_ACPI_STATUS (AE_NO_MEMORY);
+			}
+
+			object->integer.value = 0;
+			node->object = object;
+		}
+
+		/* Otherwise, return the error */
+
+		else switch (opcode) {
 		case AML_ARG_OP:
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n",
@@ -572,7 +588,7 @@
 
 
 	ACPI_FUNCTION_TRACE ("ds_store_object_to_local");
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n",
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n",
 		opcode, index, obj_desc));
 
 	/* Parameter validation */
diff -Nru a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c
--- a/drivers/acpi/dispatcher/dsutils.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/acpi/dispatcher/dsutils.c	2004-12-24 13:36:48 -08:00
@@ -333,7 +333,7 @@
 	u32                             i;
 
 
-	ACPI_FUNCTION_TRACE_PTR ("acpi_ds_clear_operands", walk_state);
+	ACPI_FUNCTION_TRACE_PTR ("ds_clear_operands", walk_state);
 
 
 	/*
diff -Nru a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
--- a/drivers/acpi/dispatcher/dswexec.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/acpi/dispatcher/dswexec.c	2004-12-24 13:37:29 -08:00
@@ -60,17 +60,18 @@
  * Dispatch table for opcode classes
  */
 static ACPI_EXECUTE_OP      acpi_gbl_op_type_dispatch [] = {
-			 acpi_ex_opcode_1A_0T_0R,
-			 acpi_ex_opcode_1A_0T_1R,
-			 acpi_ex_opcode_1A_1T_0R,
-			 acpi_ex_opcode_1A_1T_1R,
-			 acpi_ex_opcode_2A_0T_0R,
-			 acpi_ex_opcode_2A_0T_1R,
-			 acpi_ex_opcode_2A_1T_1R,
-			 acpi_ex_opcode_2A_2T_1R,
-			 acpi_ex_opcode_3A_0T_0R,
-			 acpi_ex_opcode_3A_1T_1R,
-			 acpi_ex_opcode_6A_0T_1R};
+			  acpi_ex_opcode_0A_0T_1R,
+			  acpi_ex_opcode_1A_0T_0R,
+			  acpi_ex_opcode_1A_0T_1R,
+			  acpi_ex_opcode_1A_1T_0R,
+			  acpi_ex_opcode_1A_1T_1R,
+			  acpi_ex_opcode_2A_0T_0R,
+			  acpi_ex_opcode_2A_0T_1R,
+			  acpi_ex_opcode_2A_1T_1R,
+			  acpi_ex_opcode_2A_2T_1R,
+			  acpi_ex_opcode_3A_0T_0R,
+			  acpi_ex_opcode_3A_1T_1R,
+			  acpi_ex_opcode_6A_0T_1R};
 
 /*****************************************************************************
  *
@@ -413,7 +414,7 @@
 			 * routine.  There is one routine per opcode "type" based upon the
 			 * number of opcode arguments and return type.
 			 */
-			status = acpi_gbl_op_type_dispatch [op_type] (walk_state);
+			status = acpi_gbl_op_type_dispatch[op_type] (walk_state);
 		}
 		else {
 			/*
@@ -425,7 +426,9 @@
 				(walk_state->operands[0]->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
 				(walk_state->operands[1]->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
 				(walk_state->operands[0]->reference.opcode ==
-				 walk_state->operands[1]->reference.opcode)) {
+				 walk_state->operands[1]->reference.opcode) &&
+				(walk_state->operands[0]->reference.offset ==
+				 walk_state->operands[1]->reference.offset)) {
 				status = AE_OK;
 			}
 			else {
@@ -639,7 +642,8 @@
 	 * conditional predicate
 	 */
 
-	if ((walk_state->control_state) &&
+	if ((ACPI_SUCCESS (status)) &&
+		(walk_state->control_state) &&
 		(walk_state->control_state->common.state ==
 			ACPI_CONTROL_PREDICATE_EXECUTING) &&
 		(walk_state->control_state->control.predicate_op == op)) {
@@ -649,6 +653,19 @@
 
 
 cleanup:
+
+	/* Invoke exception handler on error */
+
+	if (ACPI_FAILURE (status) &&
+		acpi_gbl_exception_handler &&
+		!(status & AE_CODE_CONTROL)) {
+		acpi_ex_exit_interpreter ();
+		status = acpi_gbl_exception_handler (status,
+				 walk_state->method_node->name.integer, walk_state->opcode,
+				 walk_state->aml_offset, NULL);
+		acpi_ex_enter_interpreter ();
+	}
+
 	if (walk_state->result_obj) {
 		/* Break to debugger to display result */
 
diff -Nru a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
--- a/drivers/acpi/dispatcher/dswload.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/dispatcher/dswload.c	2004-12-24 13:36:18 -08:00
@@ -182,18 +182,20 @@
 		 */
 		status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
 				  ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
-		if (ACPI_FAILURE (status)) {
 #ifdef _ACPI_ASL_COMPILER
-			if (status == AE_NOT_FOUND) {
-				acpi_dm_add_to_external_list (path);
-				status = AE_OK;
-			}
-			else {
-				ACPI_REPORT_NSERROR (path, status);
-			}
-#else
-			ACPI_REPORT_NSERROR (path, status);
+		if (status == AE_NOT_FOUND) {
+			/*
+			 * Table disassembly:
+			 * Target of Scope() not found.  Generate an External for it, and
+			 * insert the name into the namespace.
+			 */
+			acpi_dm_add_to_external_list (path);
+			status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
+					   ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
+		}
 #endif
+		if (ACPI_FAILURE (status)) {
+			ACPI_REPORT_NSERROR (path, status);
 			return (status);
 		}
 
diff -Nru a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
--- a/drivers/acpi/dispatcher/dswstate.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/acpi/dispatcher/dswstate.c	2004-12-24 13:37:19 -08:00
@@ -51,6 +51,8 @@
 	 ACPI_MODULE_NAME    ("dswstate")
 
 
+#ifdef ACPI_FUTURE_USAGE
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ds_result_insert
@@ -174,6 +176,8 @@
 	return (AE_OK);
 }
 
+#endif  /*  ACPI_FUTURE_USAGE  */
+
 
 /*******************************************************************************
  *
@@ -445,7 +449,7 @@
  *              Should be used with great care, if at all!
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_ds_obj_stack_delete_all (
 	struct acpi_walk_state          *walk_state)
@@ -467,6 +471,7 @@
 
 	return_ACPI_STATUS (AE_OK);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
@@ -687,7 +692,7 @@
  *              be within the range of the current stack pointer.
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 void *
 acpi_ds_obj_stack_get_value (
 	u32                             index,
@@ -712,6 +717,7 @@
 	return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) -
 			  index]);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
@@ -867,6 +873,7 @@
 
 	status = acpi_ds_result_stack_push (walk_state);
 	if (ACPI_FAILURE (status)) {
+		acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state);
 		return_PTR (NULL);
 	}
 
diff -Nru a/drivers/acpi/ec.c b/drivers/acpi/ec.c
--- a/drivers/acpi/ec.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/acpi/ec.c	2004-12-24 13:36:56 -08:00
@@ -1,6 +1,7 @@
 /*
  *  acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 38 $)
  *
+ *  Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
  *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  *
@@ -29,6 +30,7 @@
 #include <linux/types.h>
 #include <linux/delay.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <asm/io.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
@@ -262,6 +264,7 @@
 	else
 		return err;
 }
+EXPORT_SYMBOL(ec_read);
 
 int
 ec_write(u8 addr, u8 val)
@@ -278,6 +281,7 @@
 
 	return err;
 }
+EXPORT_SYMBOL(ec_write);
 
 
 static int
@@ -441,9 +445,15 @@
 
 	ACPI_FUNCTION_TRACE("acpi_ec_space_handler");
 
-	if ((address > 0xFF) || (bit_width != 8) || !value || !handler_context)
+	if ((address > 0xFF) || !value || !handler_context)
 		return_VALUE(AE_BAD_PARAMETER);
 
+	if(bit_width != 8) {
+		printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n");
+		if (acpi_strict)
+			return_VALUE(AE_BAD_PARAMETER);
+	}
+
 	ec = (struct acpi_ec *) handler_context;
 
 	switch (function) {
@@ -484,41 +494,38 @@
 
 
 static int
-acpi_ec_read_info (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*data)
+acpi_ec_read_info (struct seq_file *seq, void *offset)
 {
-	struct acpi_ec		*ec = (struct acpi_ec *) data;
-	char			*p = page;
-	int			len = 0;
+	struct acpi_ec		*ec = (struct acpi_ec *) seq->private;
 
 	ACPI_FUNCTION_TRACE("acpi_ec_read_info");
 
-	if (!ec || (off != 0))
+	if (!ec)
 		goto end;
 
-	p += sprintf(p, "gpe bit:                 0x%02x\n",
+	seq_printf(seq, "gpe bit:                 0x%02x\n",
 		(u32) ec->gpe_bit);
-	p += sprintf(p, "ports:                   0x%02x, 0x%02x\n",
+	seq_printf(seq, "ports:                   0x%02x, 0x%02x\n",
 		(u32) ec->status_addr.address, (u32) ec->data_addr.address);
-	p += sprintf(p, "use global lock:         %s\n",
+	seq_printf(seq, "use global lock:         %s\n",
 		ec->global_lock?"yes":"no");
 
 end:
-	len = (p - page);
-	if (len <= off+count) *eof = 1;
-	*start = page + off;
-	len -= off;
-	if (len>count) len = count;
-	if (len<0) len = 0;
+	return_VALUE(0);
+}
 
-	return_VALUE(len);
+static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_ec_read_info, PDE(inode)->data);
 }
 
+static struct file_operations acpi_ec_info_ops = {
+	.open		= acpi_ec_info_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.owner = THIS_MODULE,
+};
 
 static int
 acpi_ec_add_fs (
@@ -535,13 +542,17 @@
 			return_VALUE(-ENODEV);
 	}
 
-	entry = create_proc_read_entry(ACPI_EC_FILE_INFO, S_IRUGO,
-		acpi_device_dir(device), acpi_ec_read_info,
-		acpi_driver_data(device));
+	entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
+		acpi_device_dir(device));
 	if (!entry)
 		ACPI_DEBUG_PRINT((ACPI_DB_WARN,
 			"Unable to create '%s' fs entry\n",
 			ACPI_EC_FILE_INFO));
+	else {
+		entry->proc_fops = &acpi_ec_info_ops;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
 
 	return_VALUE(0);
 }
diff -Nru a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
--- a/drivers/acpi/events/evgpe.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/acpi/events/evgpe.c	2004-12-24 13:37:43 -08:00
@@ -434,13 +434,8 @@
 			}
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
-				"GPE pair: Status %8.8X%8.8X = %02X, Enable %8.8X%8.8X = %02X\n",
-				ACPI_FORMAT_UINT64 (
-					gpe_register_info->status_address.address),
-					status_reg,
-				ACPI_FORMAT_UINT64 (
-					gpe_register_info->enable_address.address),
-					enable_reg));
+				"Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
+				gpe_register_info->base_gpe_number, status_reg, enable_reg));
 
 			/* First check if there is anything active at all in this register */
 
diff -Nru a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
--- a/drivers/acpi/events/evgpeblk.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/acpi/events/evgpeblk.c	2004-12-24 13:36:55 -08:00
@@ -970,15 +970,13 @@
 	/* Dump info about this GPE block */
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
-		"GPE %02X to %02X [%4.4s] %u regs at %8.8X%8.8X on int 0x%X\n",
+		"GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
 		(u32) gpe_block->block_base_number,
 		(u32) (gpe_block->block_base_number +
 				((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)),
 		gpe_device->name.ascii,
 		gpe_block->register_count,
-		ACPI_FORMAT_UINT64 (gpe_block->block_address.address),
 		interrupt_level));
-
 
 	/* Enable all valid GPEs found above */
 
diff -Nru a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
--- a/drivers/acpi/events/evxface.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/acpi/events/evxface.c	2004-12-24 13:36:59 -08:00
@@ -41,6 +41,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
@@ -53,6 +54,52 @@
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_install_exception_handler
+ *
+ * PARAMETERS:  Handler         - Pointer to the handler function for the
+ *                                event
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Saves the pointer to the handler function
+ *
+ ******************************************************************************/
+#ifdef ACPI_FUTURE_USAGE
+acpi_status
+acpi_install_exception_handler (
+	acpi_exception_handler          handler)
+{
+	acpi_status                     status;
+
+
+	ACPI_FUNCTION_TRACE ("acpi_install_exception_handler");
+
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Don't allow two handlers. */
+
+	if (acpi_gbl_exception_handler) {
+		status = AE_ALREADY_EXISTS;
+		goto cleanup;
+	}
+
+	/* Install the handler */
+
+	acpi_gbl_exception_handler = handler;
+
+cleanup:
+	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+	return_ACPI_STATUS (status);
+}
+#endif  /*  ACPI_FUTURE_USAGE  */
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_install_fixed_event_handler
  *
  * PARAMETERS:  Event           - Event type to enable.
@@ -121,6 +168,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_install_fixed_event_handler);
 
 
 /*******************************************************************************
@@ -178,6 +226,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_remove_fixed_event_handler);
 
 
 /*******************************************************************************
@@ -347,6 +396,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_install_notify_handler);
 
 
 /*******************************************************************************
@@ -505,6 +555,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_remove_notify_handler);
 
 
 /*******************************************************************************
@@ -602,6 +653,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_install_gpe_handler);
 
 
 /*******************************************************************************
@@ -704,6 +756,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_remove_gpe_handler);
 
 
 /*******************************************************************************
@@ -746,6 +799,7 @@
 
 	return (status);
 }
+EXPORT_SYMBOL(acpi_acquire_global_lock);
 
 
 /*******************************************************************************
@@ -774,5 +828,5 @@
 	status = acpi_ev_release_global_lock ();
 	return (status);
 }
-
+EXPORT_SYMBOL(acpi_release_global_lock);
 
diff -Nru a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
--- a/drivers/acpi/events/evxfevnt.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/acpi/events/evxfevnt.c	2004-12-24 13:36:31 -08:00
@@ -41,6 +41,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acevents.h>
@@ -200,6 +201,7 @@
 
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_enable_event);
 
 
 /*******************************************************************************
@@ -248,6 +250,7 @@
 unlock_and_exit:
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_set_gpe_type);
 
 
 /*******************************************************************************
@@ -305,6 +308,7 @@
 	}
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_enable_gpe);
 
 
 /*******************************************************************************
@@ -417,6 +421,7 @@
 
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_disable_event);
 
 
 /*******************************************************************************
@@ -430,7 +435,7 @@
  * DESCRIPTION: Clear an ACPI event (fixed)
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_clear_event (
 	u32                             event)
@@ -456,6 +461,8 @@
 
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_clear_event);
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
@@ -512,6 +519,8 @@
 }
 
 
+#ifdef ACPI_FUTURE_USAGE
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_get_event_status
@@ -613,6 +622,7 @@
 	}
 	return_ACPI_STATUS (status);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
@@ -705,6 +715,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_install_gpe_block);
 
 
 /*******************************************************************************
@@ -765,4 +776,4 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
-
+EXPORT_SYMBOL(acpi_remove_gpe_block);
diff -Nru a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c
--- a/drivers/acpi/events/evxfregn.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/acpi/events/evxfregn.c	2004-12-24 13:36:19 -08:00
@@ -42,6 +42,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
@@ -116,6 +117,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_install_address_space_handler);
 
 
 /*******************************************************************************
@@ -241,5 +243,5 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
-
+EXPORT_SYMBOL(acpi_remove_address_space_handler);
 
diff -Nru a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
--- a/drivers/acpi/executer/exconvrt.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/acpi/executer/exconvrt.c	2004-12-24 13:36:17 -08:00
@@ -58,7 +58,7 @@
  * PARAMETERS:  obj_desc        - Object to be converted.  Must be an
  *                                Integer, Buffer, or String
  *              result_desc     - Where the new Integer object is returned
- *              walk_state      - Current method state
+ *              Flags           - Used for string conversion
  *
  * RETURN:      Status
  *
@@ -70,13 +70,13 @@
 acpi_ex_convert_to_integer (
 	union acpi_operand_object       *obj_desc,
 	union acpi_operand_object       **result_desc,
-	struct acpi_walk_state          *walk_state)
+	u32                             flags)
 {
-	u32                             i;
-	union acpi_operand_object       *ret_desc;
-	u32                             count;
+	union acpi_operand_object       *return_desc;
 	u8                              *pointer;
 	acpi_integer                    result;
+	u32                             i;
+	u32                             count;
 	acpi_status                     status;
 
 
@@ -85,15 +85,17 @@
 
 	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
 	case ACPI_TYPE_INTEGER:
+
+		/* No conversion necessary */
+
 		*result_desc = obj_desc;
 		return_ACPI_STATUS (AE_OK);
 
+	case ACPI_TYPE_BUFFER:
 	case ACPI_TYPE_STRING:
-		pointer = (u8 *) obj_desc->string.pointer;
-		count   = obj_desc->string.length;
-		break;
 
-	case ACPI_TYPE_BUFFER:
+		/* Note: Takes advantage of common buffer/string fields */
+
 		pointer = obj_desc->buffer.pointer;
 		count   = obj_desc->buffer.length;
 		break;
@@ -126,10 +128,12 @@
 	case ACPI_TYPE_STRING:
 
 		/*
-		 * Convert string to an integer
-		 * String must be hexadecimal as per the ACPI specification
+		 * Convert string to an integer - for most cases, the string must be
+		 * hexadecimal as per the ACPI specification.  The only exception (as
+		 * of ACPI 3.0) is that the to_integer() operator allows both decimal
+		 * and hexadecimal strings (hex prefixed with "0x").
 		 */
-		status = acpi_ut_strtoul64 ((char *) pointer, 16, &result);
+		status = acpi_ut_strtoul64 ((char *) pointer, flags, &result);
 		if (ACPI_FAILURE (status)) {
 			return_ACPI_STATUS (status);
 		}
@@ -139,8 +143,8 @@
 	case ACPI_TYPE_BUFFER:
 
 		/*
-		 * Buffer conversion - we simply grab enough raw data from the
-		 * buffer to fill an integer
+		 * Convert buffer to an integer - we simply grab enough raw data
+		 * from the buffer to fill an integer
 		 */
 		for (i = 0; i < count; i++) {
 			/*
@@ -161,27 +165,15 @@
 	/*
 	 * Create a new integer
 	 */
-	ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
-	if (!ret_desc) {
+	return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+	if (!return_desc) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
 	/* Save the Result */
 
-	ret_desc->integer.value = result;
-
-	/*
-	 * If we are about to overwrite the original object on the operand stack,
-	 * we must remove a reference on the original object because we are
-	 * essentially removing it from the stack.
-	 */
-	if (*result_desc == obj_desc) {
-		if (walk_state->opcode != AML_STORE_OP) {
-			acpi_ut_remove_reference (obj_desc);
-		}
-	}
-
-	*result_desc = ret_desc;
+	return_desc->integer.value = result;
+	*result_desc = return_desc;
 	return_ACPI_STATUS (AE_OK);
 }
 
@@ -193,7 +185,6 @@
  * PARAMETERS:  obj_desc        - Object to be converted.  Must be an
  *                                Integer, Buffer, or String
  *              result_desc     - Where the new buffer object is returned
- *              walk_state      - Current method state
  *
  * RETURN:      Status
  *
@@ -204,11 +195,9 @@
 acpi_status
 acpi_ex_convert_to_buffer (
 	union acpi_operand_object       *obj_desc,
-	union acpi_operand_object       **result_desc,
-	struct acpi_walk_state          *walk_state)
+	union acpi_operand_object       **result_desc)
 {
-	union acpi_operand_object       *ret_desc;
-	u32                             i;
+	union acpi_operand_object       *return_desc;
 	u8                              *new_buf;
 
 
@@ -230,17 +219,17 @@
 		 * Create a new Buffer object.
 		 * Need enough space for one integer
 		 */
-		ret_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width);
-		if (!ret_desc) {
+		return_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width);
+		if (!return_desc) {
 			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-		/* Copy the integer to the buffer */
+		/* Copy the integer to the buffer, LSB first */
 
-		new_buf = ret_desc->buffer.pointer;
-		for (i = 0; i < acpi_gbl_integer_byte_width; i++) {
-			new_buf[i] = (u8) (obj_desc->integer.value >> (i * 8));
-		}
+		new_buf = return_desc->buffer.pointer;
+		ACPI_MEMCPY (new_buf,
+				  &obj_desc->integer.value,
+				  acpi_gbl_integer_byte_width);
 		break;
 
 
@@ -250,14 +239,14 @@
 		 * Create a new Buffer object
 		 * Size will be the string length
 		 */
-		ret_desc = acpi_ut_create_buffer_object ((acpi_size) obj_desc->string.length);
-		if (!ret_desc) {
+		return_desc = acpi_ut_create_buffer_object ((acpi_size) obj_desc->string.length);
+		if (!return_desc) {
 			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
 		/* Copy the string to the buffer */
 
-		new_buf = ret_desc->buffer.pointer;
+		new_buf = return_desc->buffer.pointer;
 		ACPI_STRNCPY ((char *) new_buf, (char *) obj_desc->string.pointer,
 			obj_desc->string.length);
 		break;
@@ -269,32 +258,20 @@
 
 	/* Mark buffer initialized */
 
-	ret_desc->common.flags |= AOPOBJ_DATA_VALID;
-
-	/*
-	 * If we are about to overwrite the original object on the operand stack,
-	 * we must remove a reference on the original object because we are
-	 * essentially removing it from the stack.
-	 */
-	if (*result_desc == obj_desc) {
-		if (walk_state->opcode != AML_STORE_OP) {
-			acpi_ut_remove_reference (obj_desc);
-		}
-	}
-
-	*result_desc = ret_desc;
+	return_desc->common.flags |= AOPOBJ_DATA_VALID;
+	*result_desc = return_desc;
 	return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_ex_convert_ascii
+ * FUNCTION:    acpi_ex_convert_to_ascii
  *
  * PARAMETERS:  Integer         - Value to be converted
- *              Base            - 10 or 16
+ *              Base            - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
  *              String          - Where the string is returned
- *              data_width      - Size of data item to be converted
+ *              data_width      - Size of data item to be converted, in bytes
  *
  * RETURN:      Actual string length
  *
@@ -305,79 +282,81 @@
 u32
 acpi_ex_convert_to_ascii (
 	acpi_integer                    integer,
-	u32                             base,
+	u16                             base,
 	u8                              *string,
 	u8                              data_width)
 {
-	u32                             i;
-	u32                             j;
-	u32                             k = 0;
-	char                            hex_digit;
 	acpi_integer                    digit;
+	acpi_native_uint                i;
+	acpi_native_uint                j;
+	acpi_native_uint                k = 0;
+	acpi_native_uint                hex_length;
+	acpi_native_uint                decimal_length;
 	u32                             remainder;
-	u32                             length;
-	u8                              leading_zero;
+	u8                              supress_zeros;
 
 
 	ACPI_FUNCTION_ENTRY ();
 
 
-	if (data_width < sizeof (acpi_integer)) {
-		leading_zero = FALSE;
-		length = data_width;
-	}
-	else {
-		leading_zero = TRUE;
-		length = sizeof (acpi_integer);
-	}
-
 	switch (base) {
 	case 10:
 
+		/* Setup max length for the decimal number */
+
+		switch (data_width) {
+		case 1:
+			decimal_length = ACPI_MAX8_DECIMAL_DIGITS;
+			break;
+
+		case 4:
+			decimal_length = ACPI_MAX32_DECIMAL_DIGITS;
+			break;
+
+		case 8:
+		default:
+			decimal_length = ACPI_MAX64_DECIMAL_DIGITS;
+			break;
+		}
+
+		supress_zeros = TRUE;    /* No leading zeros */
 		remainder = 0;
-		for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0; i--) {
+
+		for (i = decimal_length; i > 0; i--) {
 			/* Divide by nth factor of 10 */
 
 			digit = integer;
 			for (j = 0; j < i; j++) {
-				(void) acpi_ut_short_divide (&digit, 10, &digit, &remainder);
+				(void) acpi_ut_short_divide (digit, 10, &digit, &remainder);
 			}
 
-			/* Create the decimal digit */
+			/* Handle leading zeros */
 
 			if (remainder != 0) {
-				leading_zero = FALSE;
+				supress_zeros = FALSE;
 			}
 
-			if (!leading_zero) {
+			if (!supress_zeros) {
 				string[k] = (u8) (ACPI_ASCII_ZERO + remainder);
 				k++;
 			}
 		}
 		break;
 
-
 	case 16:
 
-		/* Copy the integer to the buffer */
+		hex_length = ACPI_MUL_2 (data_width); /* 2 ascii hex chars per data byte */
 
-		for (i = 0, j = ((length * 2) -1); i < (length * 2); i++, j--) {
+		for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) {
+			/* Get one hex digit, most significant digits first */
 
-			hex_digit = acpi_ut_hex_to_ascii_char (integer, (j * 4));
-			if (hex_digit != ACPI_ASCII_ZERO) {
-				leading_zero = FALSE;
-			}
-
-			if (!leading_zero) {
-				string[k] = (u8) hex_digit;
-				k++;
-			}
+			string[k] = (u8) acpi_ut_hex_to_ascii_char (integer, ACPI_MUL_4 (j));
+			k++;
 		}
 		break;
 
-
 	default:
-		break;
+		return (0);
 	}
 
 	/*
@@ -392,7 +371,7 @@
 	}
 
 	string [k] = 0;
-	return (k);
+	return ((u32) k);
 }
 
 
@@ -401,11 +380,9 @@
  * FUNCTION:    acpi_ex_convert_to_string
  *
  * PARAMETERS:  obj_desc        - Object to be converted.  Must be an
- *                                  Integer, Buffer, or String
+ *                                Integer, Buffer, or String
  *              result_desc     - Where the string object is returned
- *              Base            - 10 or 16
- *              max_length      - Max length of the returned string
- *              walk_state      - Current method state
+ *              Type            - String flags (base and conversion type)
  *
  * RETURN:      Status
  *
@@ -417,15 +394,14 @@
 acpi_ex_convert_to_string (
 	union acpi_operand_object       *obj_desc,
 	union acpi_operand_object       **result_desc,
-	u32                             base,
-	u32                             max_length,
-	struct acpi_walk_state          *walk_state)
+	u32                             type)
 {
-	union acpi_operand_object       *ret_desc;
+	union acpi_operand_object       *return_desc;
 	u8                              *new_buf;
-	u8                              *pointer;
-	u32                             string_length;
+	u32                             string_length = 0;
+	u16                             base = 16;
 	u32                             i;
+	u8                              separator = ',';
 
 
 	ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_string", obj_desc);
@@ -434,130 +410,129 @@
 	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
 	case ACPI_TYPE_STRING:
 
-		if (max_length >= obj_desc->string.length) {
-			*result_desc = obj_desc;
-			return_ACPI_STATUS (AE_OK);
-		}
-		else {
-			/* Must copy the string first and then truncate it */
+		/* No conversion necessary */
 
-			return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
-		}
+		*result_desc = obj_desc;
+		return_ACPI_STATUS (AE_OK);
 
 
 	case ACPI_TYPE_INTEGER:
 
-		string_length = acpi_gbl_integer_byte_width * 2;
-		if (base == 10) {
+		switch (type) {
+		case ACPI_EXPLICIT_CONVERT_DECIMAL:
+
+			/* Make room for maximum decimal number */
+
 			string_length = ACPI_MAX_DECIMAL_DIGITS;
+			base = 10;
+			break;
+
+		default:
+
+			/* Two hex string characters for each integer byte */
+
+			string_length = ACPI_MUL_2 (acpi_gbl_integer_byte_width);
+			break;
 		}
 
 		/*
 		 * Create a new String
+		 * Need enough space for one ASCII integer (plus null terminator)
 		 */
-		ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
-		if (!ret_desc) {
+		return_desc = acpi_ut_create_string_object ((acpi_size) string_length);
+		if (!return_desc) {
 			return_ACPI_STATUS (AE_NO_MEMORY);
 		}
 
-		/* Need enough space for one ASCII integer plus null terminator */
+		new_buf = return_desc->buffer.pointer;
 
-		new_buf = ACPI_MEM_CALLOCATE ((acpi_size) string_length + 1);
-		if (!new_buf) {
-			ACPI_REPORT_ERROR
-				(("ex_convert_to_string: Buffer allocation failure\n"));
-			acpi_ut_remove_reference (ret_desc);
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
+		/* Convert integer to string */
 
-		/* Convert */
-
-		i = acpi_ex_convert_to_ascii (obj_desc->integer.value, base, new_buf, sizeof (acpi_integer));
+		string_length = acpi_ex_convert_to_ascii (obj_desc->integer.value, base,
+				   new_buf, acpi_gbl_integer_byte_width);
 
 		/* Null terminate at the correct place */
 
-		if (max_length < i) {
-			new_buf[max_length] = 0;
-			ret_desc->string.length = max_length;
-		}
-		else {
-			new_buf [i] = 0;
-			ret_desc->string.length = i;
-		}
-
-		ret_desc->buffer.pointer = new_buf;
+		return_desc->string.length = string_length;
+		new_buf [string_length] = 0;
 		break;
 
 
 	case ACPI_TYPE_BUFFER:
 
-		/* Find the string length */
+		switch (type) {
+		case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string operator */
+			/*
+			 * From ACPI: "If Data is a buffer, it is converted to a string of
+			 * decimal values separated by commas."
+			 */
+			base = 10;
+			string_length = obj_desc->buffer.length; /* 4 chars for each decimal */
 
-		pointer = obj_desc->buffer.pointer;
-		for (string_length = 0; string_length < obj_desc->buffer.length; string_length++) {
-			/* Exit on null terminator */
+			/*lint -fallthrough */
 
-			if (!pointer[string_length]) {
-				break;
+		case ACPI_IMPLICIT_CONVERT_HEX:
+			/*
+			 * From the ACPI spec:
+			 *"The entire contents of the buffer are converted to a string of
+			 * two-character hexadecimal numbers, each separated by a space."
+			 */
+			if (type == ACPI_IMPLICIT_CONVERT_HEX) {
+				separator = ' ';
 			}
-		}
 
-		if (max_length > ACPI_MAX_STRING_CONVERSION) {
-			if (string_length > ACPI_MAX_STRING_CONVERSION) {
+			/*lint -fallthrough */
+
+		case ACPI_EXPLICIT_CONVERT_HEX:     /* Used by to_hex_string operator */
+			/*
+			 * From ACPI: "If Data is a buffer, it is converted to a string of
+			 * hexadecimal values separated by commas."
+			 */
+			string_length += (obj_desc->buffer.length * 3);
+			if (string_length > ACPI_MAX_STRING_CONVERSION) /* ACPI limit */ {
 				return_ACPI_STATUS (AE_AML_STRING_LIMIT);
 			}
-		}
 
-		/*
-		 * Create a new string object
-		 */
-		ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
-		if (!ret_desc) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
+			/* Create a new string object and string buffer */
 
-		/* String length is the lesser of the Max or the actual length */
+			return_desc = acpi_ut_create_string_object ((acpi_size) string_length -1);
+			if (!return_desc) {
+				return_ACPI_STATUS (AE_NO_MEMORY);
+			}
 
-		if (max_length < string_length) {
-			string_length = max_length;
-		}
+			new_buf = return_desc->buffer.pointer;
 
-		new_buf = ACPI_MEM_CALLOCATE ((acpi_size) string_length + 1);
-		if (!new_buf) {
-			ACPI_REPORT_ERROR
-				(("ex_convert_to_string: Buffer allocation failure\n"));
-			acpi_ut_remove_reference (ret_desc);
-			return_ACPI_STATUS (AE_NO_MEMORY);
-		}
+			/*
+			 * Convert buffer bytes to hex or decimal values
+			 * (separated by commas)
+			 */
+			for (i = 0; i < obj_desc->buffer.length; i++) {
+				new_buf += acpi_ex_convert_to_ascii (
+						 (acpi_integer) obj_desc->buffer.pointer[i], base,
+						 new_buf, 1);
+				*new_buf++ = separator; /* each separated by a comma or space */
+			}
 
-		/* Copy the appropriate number of buffer characters */
+			/* Null terminate the string (overwrites final comma from above) */
 
-		ACPI_MEMCPY (new_buf, pointer, string_length);
+			new_buf--;
+			*new_buf = 0;
 
-		/* Null terminate */
+			/* Recalculate length */
 
-		new_buf [string_length] = 0;
-		ret_desc->buffer.pointer = new_buf;
-		ret_desc->string.length = string_length;
-		break;
+			return_desc->string.length = ACPI_STRLEN (return_desc->string.pointer);
+			break;
 
+		default:
+			return_ACPI_STATUS (AE_BAD_PARAMETER);
+		}
+		break;
 
 	default:
 		return_ACPI_STATUS (AE_TYPE);
 	}
 
-	/*
-	 * If we are about to overwrite the original object on the operand stack,
-	 * we must remove a reference on the original object because we are
-	 * essentially removing it from the stack.
-	 */
-	if (*result_desc == obj_desc) {
-		if (walk_state->opcode != AML_STORE_OP) {
-			acpi_ut_remove_reference (obj_desc);
-		}
-	}
-
-	*result_desc = ret_desc;
+	*result_desc = return_desc;
 	return_ACPI_STATUS (AE_OK);
 }
 
@@ -635,7 +610,8 @@
 			 * These types require an Integer operand.  We can convert
 			 * a Buffer or a String to an Integer if necessary.
 			 */
-			status = acpi_ex_convert_to_integer (source_desc, result_desc, walk_state);
+			status = acpi_ex_convert_to_integer (source_desc, result_desc,
+					 16);
 			break;
 
 
@@ -645,7 +621,8 @@
 			 * The operand must be a String.  We can convert an
 			 * Integer or Buffer if necessary
 			 */
-			status = acpi_ex_convert_to_string (source_desc, result_desc, 16, ACPI_UINT32_MAX, walk_state);
+			status = acpi_ex_convert_to_string (source_desc, result_desc,
+					 ACPI_IMPLICIT_CONVERT_HEX);
 			break;
 
 
@@ -655,7 +632,7 @@
 			 * The operand must be a Buffer.  We can convert an
 			 * Integer or String if necessary
 			 */
-			status = acpi_ex_convert_to_buffer (source_desc, result_desc, walk_state);
+			status = acpi_ex_convert_to_buffer (source_desc, result_desc);
 			break;
 
 
diff -Nru a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
--- a/drivers/acpi/executer/exdump.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/executer/exdump.c	2004-12-24 13:36:18 -08:00
@@ -55,7 +55,6 @@
 /*
  * The following routines are used for debug output only
  */
-
 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 
 /*****************************************************************************
@@ -64,7 +63,7 @@
  *
  * PARAMETERS:  *obj_desc         - Pointer to entry to be dumped
  *
- * RETURN:      Status
+ * RETURN:      None
  *
  * DESCRIPTION: Dump an operand object
  *
@@ -72,12 +71,11 @@
 
 void
 acpi_ex_dump_operand (
-	union acpi_operand_object       *obj_desc)
+	union acpi_operand_object       *obj_desc,
+	u32                             depth)
 {
-	u8                              *buf = NULL;
 	u32                             length;
-	union acpi_operand_object       **element;
-	u16                             element_index;
+	u32                             index;
 
 
 	ACPI_FUNCTION_NAME ("ex_dump_operand")
@@ -89,9 +87,9 @@
 
 	if (!obj_desc) {
 		/*
-		 * This usually indicates that something serious is wrong
+		 * This could be a null element of a package
 		 */
-		acpi_os_printf ("Null Object Descriptor\n");
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
 		return;
 	}
 
@@ -103,15 +101,19 @@
 
 	if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-				"%p is not a node or operand object: [%s]\n",
-				obj_desc, acpi_ut_get_descriptor_name (obj_desc)));
+			"%p is not a node or operand object: [%s]\n",
+			obj_desc, acpi_ut_get_descriptor_name (obj_desc)));
 		ACPI_DUMP_BUFFER (obj_desc, sizeof (union acpi_operand_object));
 		return;
 	}
 
 	/* obj_desc is a valid object */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc));
+	if (depth > 0) {
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "%*s[%u] ", depth, " ", depth));
+	}
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "%p ", obj_desc));
+
 
 	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
 	case ACPI_TYPE_LOCAL_REFERENCE:
@@ -125,8 +127,8 @@
 
 		case AML_NAME_OP:
 
-			ACPI_DUMP_PATHNAME (obj_desc->reference.object, "Reference: Name: ",
-					  ACPI_LV_INFO, _COMPONENT);
+			ACPI_DUMP_PATHNAME (obj_desc->reference.object,
+				"Reference: Name: ", ACPI_LV_INFO, _COMPONENT);
 			ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO);
 			break;
 
@@ -134,27 +136,27 @@
 		case AML_INDEX_OP:
 
 			acpi_os_printf ("Reference: Index %p\n",
-					 obj_desc->reference.object);
+				obj_desc->reference.object);
 			break;
 
 
 		case AML_REF_OF_OP:
 
 			acpi_os_printf ("Reference: (ref_of) %p\n",
-					 obj_desc->reference.object);
+				obj_desc->reference.object);
 			break;
 
 
 		case AML_ARG_OP:
 
 			acpi_os_printf ("Reference: Arg%d",
-					 obj_desc->reference.offset);
+				obj_desc->reference.offset);
 
 			if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
 				/* Value is an Integer */
 
 				acpi_os_printf (" value is [%8.8X%8.8x]",
-						 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
+					ACPI_FORMAT_UINT64 (obj_desc->integer.value));
 			}
 
 			acpi_os_printf ("\n");
@@ -164,14 +166,14 @@
 		case AML_LOCAL_OP:
 
 			acpi_os_printf ("Reference: Local%d",
-					 obj_desc->reference.offset);
+				obj_desc->reference.offset);
 
 			if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
 
 				/* Value is an Integer */
 
 				acpi_os_printf (" value is [%8.8X%8.8x]",
-						 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
+					ACPI_FORMAT_UINT64 (obj_desc->integer.value));
 			}
 
 			acpi_os_printf ("\n");
@@ -181,7 +183,7 @@
 		case AML_INT_NAMEPATH_OP:
 
 			acpi_os_printf ("Reference.Node->Name %X\n",
-					 obj_desc->reference.node->name.integer);
+				obj_desc->reference.node->name.integer);
 			break;
 
 
@@ -194,18 +196,15 @@
 			break;
 
 		}
-
 		break;
 
 
 	case ACPI_TYPE_BUFFER:
 
 		acpi_os_printf ("Buffer len %X @ %p \n",
-				 obj_desc->buffer.length,
-				 obj_desc->buffer.pointer);
+			obj_desc->buffer.length, obj_desc->buffer.pointer);
 
 		length = obj_desc->buffer.length;
-
 		if (length > 64) {
 			length = 64;
 		}
@@ -215,41 +214,37 @@
 		if (obj_desc->buffer.pointer) {
 			acpi_os_printf ("Buffer Contents: ");
 
-			for (buf = obj_desc->buffer.pointer; length--; ++buf) {
-				acpi_os_printf (" %02x", *buf);
+			for (index = 0; index < length; index++) {
+				acpi_os_printf (" %02x", obj_desc->buffer.pointer[index]);
 			}
 			acpi_os_printf ("\n");
 		}
-
 		break;
 
 
 	case ACPI_TYPE_INTEGER:
 
 		acpi_os_printf ("Integer %8.8X%8.8X\n",
-				 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
+			ACPI_FORMAT_UINT64 (obj_desc->integer.value));
 		break;
 
 
 	case ACPI_TYPE_PACKAGE:
 
-		acpi_os_printf ("Package count %X @ %p\n",
-				 obj_desc->package.count, obj_desc->package.elements);
+		acpi_os_printf ("Package [Len %X] element_array %p\n",
+			obj_desc->package.count, obj_desc->package.elements);
 
 		/*
-		 * If elements exist, package vector pointer is valid,
+		 * If elements exist, package element pointer is valid,
 		 * and debug_level exceeds 1, dump package's elements.
 		 */
 		if (obj_desc->package.count &&
 			obj_desc->package.elements &&
 			acpi_dbg_level > 1) {
-			for (element_index = 0, element = obj_desc->package.elements;
-				  element_index < obj_desc->package.count;
-				  ++element_index, ++element) {
-				acpi_ex_dump_operand (*element);
+			for (index = 0; index < obj_desc->package.count; index++) {
+				acpi_ex_dump_operand (obj_desc->package.elements[index], depth+1);
 			}
 		}
-		acpi_os_printf ("\n");
 		break;
 
 
@@ -277,7 +272,7 @@
 	case ACPI_TYPE_STRING:
 
 		acpi_os_printf ("String length %X @ %p ",
-				 obj_desc->string.length, obj_desc->string.pointer);
+			obj_desc->string.length, obj_desc->string.pointer);
 		acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
 		acpi_os_printf ("\n");
 		break;
@@ -297,7 +292,7 @@
 			obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
 			obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
 			obj_desc->field.base_byte_offset, obj_desc->field.start_field_bit_offset);
-		ACPI_DUMP_STACK_ENTRY (obj_desc->field.region_obj);
+		acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1);
 		break;
 
 
@@ -321,9 +316,8 @@
 			acpi_os_printf ("*not a Buffer* \n");
 		}
 		else {
-			ACPI_DUMP_STACK_ENTRY (obj_desc->buffer_field.buffer_obj);
+			acpi_ex_dump_operand (obj_desc->buffer_field.buffer_obj, depth+1);
 		}
-
 		break;
 
 
@@ -387,10 +381,13 @@
  *
  * FUNCTION:    acpi_ex_dump_operands
  *
- * PARAMETERS:  interpreter_mode     - Load or Exec
- *              *Ident              - Identification
+ * PARAMETERS:  Operands            - Operand list
+ *              interpreter_mode    - Load or Exec
+ *              Ident               - Identification
  *              num_levels          - # of stack entries to dump above line
- *              *Note               - Output notation
+ *              Note                - Output notation
+ *              module_name         - Caller's module name
+ *              line_number         - Caller's invocation line number
  *
  * DESCRIPTION: Dump the object stack
  *
@@ -407,7 +404,6 @@
 	u32                             line_number)
 {
 	acpi_native_uint                i;
-	union acpi_operand_object       **obj_desc;
 
 
 	ACPI_FUNCTION_NAME ("ex_dump_operands");
@@ -432,8 +428,7 @@
 	/* Dump the operand stack starting at the top */
 
 	for (i = 0; num_levels > 0; i--, num_levels--) {
-		obj_desc = &operands[i];
-		acpi_ex_dump_operand (*obj_desc);
+		acpi_ex_dump_operand (operands[i], 0);
 	}
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
@@ -443,6 +438,8 @@
 }
 
 
+#ifdef ACPI_FUTURE_USAGE
+
 /*****************************************************************************
  *
  * FUNCTION:    acpi_ex_out*
@@ -489,8 +486,7 @@
 #if ACPI_MACHINE_WIDTH == 16
 	acpi_os_printf ("%20s : %p\n", title, value);
 #else
-	acpi_os_printf ("%20s : %8.8X%8.8X\n", title,
-			 ACPI_FORMAT_UINT64 (value));
+	acpi_os_printf ("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64 (value));
 #endif
 }
 
@@ -499,7 +495,7 @@
  *
  * FUNCTION:    acpi_ex_dump_node
  *
- * PARAMETERS:  *Node           - Descriptor to dump
+ * PARAMETERS:  *Node               - Descriptor to dump
  *              Flags               - Force display
  *
  * DESCRIPTION: Dumps the members of the given.Node
@@ -563,22 +559,25 @@
 
 	if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
 		acpi_ex_dump_node ((struct acpi_namespace_node *) obj_desc, flags);
-		acpi_os_printf ("\nAttached Object (%p):\n", ((struct acpi_namespace_node *) obj_desc)->object);
-		acpi_ex_dump_object_descriptor (((struct acpi_namespace_node *) obj_desc)->object, flags);
-		return;
+		acpi_os_printf ("\nAttached Object (%p):\n",
+			((struct acpi_namespace_node *) obj_desc)->object);
+		acpi_ex_dump_object_descriptor (
+			((struct acpi_namespace_node *) obj_desc)->object, flags);
+		return_VOID;
 	}
 
 	if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
-		acpi_os_printf ("ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n",
-				obj_desc, acpi_ut_get_descriptor_name (obj_desc));
+		acpi_os_printf (
+			"ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n",
+			obj_desc, acpi_ut_get_descriptor_name (obj_desc));
 		return_VOID;
 	}
 
 	/* Common Fields */
 
-	acpi_ex_out_string ("Type",          acpi_ut_get_object_type_name (obj_desc));
+	acpi_ex_out_string ("Type",             acpi_ut_get_object_type_name (obj_desc));
 	acpi_ex_out_integer ("Reference Count", obj_desc->common.reference_count);
-	acpi_ex_out_integer ("Flags",        obj_desc->common.flags);
+	acpi_ex_out_integer ("Flags",           obj_desc->common.flags);
 
 	/* Object-specific Fields */
 
@@ -592,7 +591,7 @@
 
 	case ACPI_TYPE_STRING:
 
-		acpi_ex_out_integer ("Length",       obj_desc->string.length);
+		acpi_ex_out_integer ("Length",      obj_desc->string.length);
 
 		acpi_os_printf ("%20s : %p ", "Pointer", obj_desc->string.pointer);
 		acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
@@ -602,17 +601,17 @@
 
 	case ACPI_TYPE_BUFFER:
 
-		acpi_ex_out_integer ("Length",       obj_desc->buffer.length);
-		acpi_ex_out_pointer ("Pointer",      obj_desc->buffer.pointer);
+		acpi_ex_out_integer ("Length",      obj_desc->buffer.length);
+		acpi_ex_out_pointer ("Pointer",     obj_desc->buffer.pointer);
 		ACPI_DUMP_BUFFER (obj_desc->buffer.pointer, obj_desc->buffer.length);
 		break;
 
 
 	case ACPI_TYPE_PACKAGE:
 
-		acpi_ex_out_integer ("Flags",        obj_desc->package.flags);
-		acpi_ex_out_integer ("Count",        obj_desc->package.count);
-		acpi_ex_out_pointer ("Elements",     obj_desc->package.elements);
+		acpi_ex_out_integer ("Flags",       obj_desc->package.flags);
+		acpi_ex_out_integer ("Count",       obj_desc->package.count);
+		acpi_ex_out_pointer ("Elements",    obj_desc->package.elements);
 
 		/* Dump the package contents */
 
@@ -621,7 +620,8 @@
 			for (i = 0; i < obj_desc->package.count; i++) {
 				acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
 				if (obj_desc->package.elements[i]) {
-					acpi_os_printf (" %s", acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
+					acpi_os_printf (" %s",
+						acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
 				}
 				acpi_os_printf ("\n");
 			}
@@ -639,38 +639,38 @@
 
 	case ACPI_TYPE_EVENT:
 
-		acpi_ex_out_pointer ("Semaphore",    obj_desc->event.semaphore);
+		acpi_ex_out_pointer ("Semaphore",   obj_desc->event.semaphore);
 		break;
 
 
 	case ACPI_TYPE_METHOD:
 
-		acpi_ex_out_integer ("param_count",  obj_desc->method.param_count);
-		acpi_ex_out_integer ("Concurrency",  obj_desc->method.concurrency);
-		acpi_ex_out_pointer ("Semaphore",    obj_desc->method.semaphore);
-		acpi_ex_out_integer ("owning_id",    obj_desc->method.owning_id);
-		acpi_ex_out_integer ("aml_length",   obj_desc->method.aml_length);
-		acpi_ex_out_pointer ("aml_start",    obj_desc->method.aml_start);
+		acpi_ex_out_integer ("param_count", obj_desc->method.param_count);
+		acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency);
+		acpi_ex_out_pointer ("Semaphore",   obj_desc->method.semaphore);
+		acpi_ex_out_integer ("owning_id",   obj_desc->method.owning_id);
+		acpi_ex_out_integer ("aml_length",  obj_desc->method.aml_length);
+		acpi_ex_out_pointer ("aml_start",   obj_desc->method.aml_start);
 		break;
 
 
 	case ACPI_TYPE_MUTEX:
 
-		acpi_ex_out_integer ("sync_level",   obj_desc->mutex.sync_level);
+		acpi_ex_out_integer ("sync_level",  obj_desc->mutex.sync_level);
 		acpi_ex_out_pointer ("owner_thread", obj_desc->mutex.owner_thread);
-		acpi_ex_out_integer ("acquisition_depth",obj_desc->mutex.acquisition_depth);
-		acpi_ex_out_pointer ("Semaphore",    obj_desc->mutex.semaphore);
+		acpi_ex_out_integer ("acquire_depth", obj_desc->mutex.acquisition_depth);
+		acpi_ex_out_pointer ("Semaphore",   obj_desc->mutex.semaphore);
 		break;
 
 
 	case ACPI_TYPE_REGION:
 
-		acpi_ex_out_integer ("space_id",     obj_desc->region.space_id);
-		acpi_ex_out_integer ("Flags",        obj_desc->region.flags);
-		acpi_ex_out_address ("Address",      obj_desc->region.address);
-		acpi_ex_out_integer ("Length",       obj_desc->region.length);
-		acpi_ex_out_pointer ("Handler",      obj_desc->region.handler);
-		acpi_ex_out_pointer ("Next",         obj_desc->region.next);
+		acpi_ex_out_integer ("space_id",    obj_desc->region.space_id);
+		acpi_ex_out_integer ("Flags",       obj_desc->region.flags);
+		acpi_ex_out_address ("Address",     obj_desc->region.address);
+		acpi_ex_out_integer ("Length",      obj_desc->region.length);
+		acpi_ex_out_pointer ("Handler",     obj_desc->region.handler);
+		acpi_ex_out_pointer ("Next",        obj_desc->region.next);
 		break;
 
 
@@ -686,11 +686,11 @@
 	case ACPI_TYPE_PROCESSOR:
 
 		acpi_ex_out_integer ("Processor ID", obj_desc->processor.proc_id);
-		acpi_ex_out_integer ("Length",       obj_desc->processor.length);
-		acpi_ex_out_address ("Address",      (acpi_physical_address) obj_desc->processor.address);
+		acpi_ex_out_integer ("Length",      obj_desc->processor.length);
+		acpi_ex_out_address ("Address",     (acpi_physical_address) obj_desc->processor.address);
 		acpi_ex_out_pointer ("system_notify", obj_desc->processor.system_notify);
 		acpi_ex_out_pointer ("device_notify", obj_desc->processor.device_notify);
-		acpi_ex_out_pointer ("Handler",      obj_desc->processor.handler);
+		acpi_ex_out_pointer ("Handler",     obj_desc->processor.handler);
 		break;
 
 
@@ -698,7 +698,7 @@
 
 		acpi_ex_out_pointer ("system_notify", obj_desc->thermal_zone.system_notify);
 		acpi_ex_out_pointer ("device_notify", obj_desc->thermal_zone.device_notify);
-		acpi_ex_out_pointer ("Handler",      obj_desc->thermal_zone.handler);
+		acpi_ex_out_pointer ("Handler",     obj_desc->thermal_zone.handler);
 		break;
 
 
@@ -707,35 +707,35 @@
 	case ACPI_TYPE_LOCAL_BANK_FIELD:
 	case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
-		acpi_ex_out_integer ("field_flags",  obj_desc->common_field.field_flags);
-		acpi_ex_out_integer ("access_byte_width", obj_desc->common_field.access_byte_width);
-		acpi_ex_out_integer ("bit_length",   obj_desc->common_field.bit_length);
+		acpi_ex_out_integer ("field_flags", obj_desc->common_field.field_flags);
+		acpi_ex_out_integer ("access_byte_width",obj_desc->common_field.access_byte_width);
+		acpi_ex_out_integer ("bit_length",  obj_desc->common_field.bit_length);
 		acpi_ex_out_integer ("fld_bit_offset", obj_desc->common_field.start_field_bit_offset);
 		acpi_ex_out_integer ("base_byte_offset", obj_desc->common_field.base_byte_offset);
 		acpi_ex_out_integer ("datum_valid_bits", obj_desc->common_field.datum_valid_bits);
-		acpi_ex_out_integer ("end_fld_valid_bits", obj_desc->common_field.end_field_valid_bits);
-		acpi_ex_out_integer ("end_buf_valid_bits", obj_desc->common_field.end_buffer_valid_bits);
-		acpi_ex_out_pointer ("parent_node",  obj_desc->common_field.node);
+		acpi_ex_out_integer ("end_fld_valid_bits",obj_desc->common_field.end_field_valid_bits);
+		acpi_ex_out_integer ("end_buf_valid_bits",obj_desc->common_field.end_buffer_valid_bits);
+		acpi_ex_out_pointer ("parent_node", obj_desc->common_field.node);
 
 		switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
 		case ACPI_TYPE_BUFFER_FIELD:
-			acpi_ex_out_pointer ("buffer_obj",   obj_desc->buffer_field.buffer_obj);
+			acpi_ex_out_pointer ("buffer_obj", obj_desc->buffer_field.buffer_obj);
 			break;
 
 		case ACPI_TYPE_LOCAL_REGION_FIELD:
-			acpi_ex_out_pointer ("region_obj",   obj_desc->field.region_obj);
+			acpi_ex_out_pointer ("region_obj", obj_desc->field.region_obj);
 			break;
 
 		case ACPI_TYPE_LOCAL_BANK_FIELD:
-			acpi_ex_out_integer ("Value",        obj_desc->bank_field.value);
-			acpi_ex_out_pointer ("region_obj",   obj_desc->bank_field.region_obj);
-			acpi_ex_out_pointer ("bank_obj",     obj_desc->bank_field.bank_obj);
+			acpi_ex_out_integer ("Value",   obj_desc->bank_field.value);
+			acpi_ex_out_pointer ("region_obj", obj_desc->bank_field.region_obj);
+			acpi_ex_out_pointer ("bank_obj", obj_desc->bank_field.bank_obj);
 			break;
 
 		case ACPI_TYPE_LOCAL_INDEX_FIELD:
-			acpi_ex_out_integer ("Value",        obj_desc->index_field.value);
-			acpi_ex_out_pointer ("Index",        obj_desc->index_field.index_obj);
-			acpi_ex_out_pointer ("Data",         obj_desc->index_field.data_obj);
+			acpi_ex_out_integer ("Value",   obj_desc->index_field.value);
+			acpi_ex_out_pointer ("Index",   obj_desc->index_field.index_obj);
+			acpi_ex_out_pointer ("Data",    obj_desc->index_field.data_obj);
 			break;
 
 		default:
@@ -747,29 +747,29 @@
 
 	case ACPI_TYPE_LOCAL_REFERENCE:
 
-		acpi_ex_out_integer ("target_type",  obj_desc->reference.target_type);
-		acpi_ex_out_string ("Opcode",        (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name);
-		acpi_ex_out_integer ("Offset",       obj_desc->reference.offset);
-		acpi_ex_out_pointer ("obj_desc",     obj_desc->reference.object);
-		acpi_ex_out_pointer ("Node",         obj_desc->reference.node);
-		acpi_ex_out_pointer ("Where",        obj_desc->reference.where);
+		acpi_ex_out_integer ("target_type", obj_desc->reference.target_type);
+		acpi_ex_out_string ("Opcode",       (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name);
+		acpi_ex_out_integer ("Offset",      obj_desc->reference.offset);
+		acpi_ex_out_pointer ("obj_desc",    obj_desc->reference.object);
+		acpi_ex_out_pointer ("Node",        obj_desc->reference.node);
+		acpi_ex_out_pointer ("Where",       obj_desc->reference.where);
 		break;
 
 
 	case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
 
-		acpi_ex_out_integer ("space_id",     obj_desc->address_space.space_id);
-		acpi_ex_out_pointer ("Next",         obj_desc->address_space.next);
-		acpi_ex_out_pointer ("region_list",  obj_desc->address_space.region_list);
-		acpi_ex_out_pointer ("Node",         obj_desc->address_space.node);
-		acpi_ex_out_pointer ("Context",      obj_desc->address_space.context);
+		acpi_ex_out_integer ("space_id",    obj_desc->address_space.space_id);
+		acpi_ex_out_pointer ("Next",        obj_desc->address_space.next);
+		acpi_ex_out_pointer ("region_list", obj_desc->address_space.region_list);
+		acpi_ex_out_pointer ("Node",        obj_desc->address_space.node);
+		acpi_ex_out_pointer ("Context",     obj_desc->address_space.context);
 		break;
 
 
 	case ACPI_TYPE_LOCAL_NOTIFY:
 
-		acpi_ex_out_pointer ("Node",         obj_desc->notify.node);
-		acpi_ex_out_pointer ("Context",      obj_desc->notify.context);
+		acpi_ex_out_pointer ("Node",        obj_desc->notify.node);
+		acpi_ex_out_pointer ("Context",     obj_desc->notify.context);
 		break;
 
 
@@ -779,13 +779,16 @@
 	case ACPI_TYPE_LOCAL_DATA:
 	default:
 
-		acpi_os_printf ("ex_dump_object_descriptor: Display not implemented for object type %s\n",
+		acpi_os_printf (
+			"ex_dump_object_descriptor: Display not implemented for object type %s\n",
 			acpi_ut_get_object_type_name (obj_desc));
 		break;
 	}
 
 	return_VOID;
 }
+
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 #endif
 
diff -Nru a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
--- a/drivers/acpi/executer/exfldio.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/acpi/executer/exfldio.c	2004-12-24 13:36:34 -08:00
@@ -139,7 +139,7 @@
 			if (ACPI_ROUND_UP (rgn_desc->region.length,
 					   obj_desc->common_field.access_byte_width) >=
 				(obj_desc->common_field.base_byte_offset +
-				 obj_desc->common_field.access_byte_width +
+				 (acpi_native_uint) obj_desc->common_field.access_byte_width +
 				 field_datum_byte_offset)) {
 				return_ACPI_STATUS (AE_OK);
 			}
diff -Nru a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
--- a/drivers/acpi/executer/exmisc.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/acpi/executer/exmisc.c	2004-12-24 13:37:18 -08:00
@@ -149,8 +149,9 @@
  *
  * FUNCTION:    acpi_ex_concat_template
  *
- * PARAMETERS:  *obj_desc           - Object to be converted.  Must be an
- *                                    Integer, Buffer, or String
+ * PARAMETERS:  Operand0            - First source object
+ *              Operand1            - Second source object
+ *              actual_return_desc  - Where to place the return object
  *              walk_state          - Current walk state
  *
  * RETURN:      Status
@@ -161,8 +162,8 @@
 
 acpi_status
 acpi_ex_concat_template (
-	union acpi_operand_object       *obj_desc1,
-	union acpi_operand_object       *obj_desc2,
+	union acpi_operand_object       *operand0,
+	union acpi_operand_object       *operand1,
 	union acpi_operand_object       **actual_return_desc,
 	struct acpi_walk_state          *walk_state)
 {
@@ -179,16 +180,16 @@
 
 	/* Find the end_tags in each resource template */
 
-	end_tag1 = acpi_ut_get_resource_end_tag (obj_desc1);
-	end_tag2 = acpi_ut_get_resource_end_tag (obj_desc2);
+	end_tag1 = acpi_ut_get_resource_end_tag (operand0);
+	end_tag2 = acpi_ut_get_resource_end_tag (operand1);
 	if (!end_tag1 || !end_tag2) {
 		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 	}
 
 	/* Compute the length of each part */
 
-	length1 = ACPI_PTR_DIFF (end_tag1, obj_desc1->buffer.pointer);
-	length2 = ACPI_PTR_DIFF (end_tag2, obj_desc2->buffer.pointer) +
+	length1 = ACPI_PTR_DIFF (end_tag1, operand0->buffer.pointer);
+	length2 = ACPI_PTR_DIFF (end_tag2, operand1->buffer.pointer) +
 			  2; /* Size of END_TAG */
 
 	/* Create a new buffer object for the result */
@@ -201,8 +202,8 @@
 	/* Copy the templates to the new descriptor */
 
 	new_buf = return_desc->buffer.pointer;
-	ACPI_MEMCPY (new_buf, obj_desc1->buffer.pointer, length1);
-	ACPI_MEMCPY (new_buf + length1, obj_desc2->buffer.pointer, length2);
+	ACPI_MEMCPY (new_buf, operand0->buffer.pointer, length1);
+	ACPI_MEMCPY (new_buf + length1, operand1->buffer.pointer, length2);
 
 	/* Compute the new checksum */
 
@@ -221,8 +222,8 @@
  *
  * FUNCTION:    acpi_ex_do_concatenate
  *
- * PARAMETERS:  obj_desc1           - First source object
- *              obj_desc2           - Second source object
+ * PARAMETERS:  Operand0            - First source object
+ *              Operand1            - Second source object
  *              actual_return_desc  - Where to place the return object
  *              walk_state          - Current walk state
  *
@@ -234,20 +235,57 @@
 
 acpi_status
 acpi_ex_do_concatenate (
-	union acpi_operand_object       *obj_desc1,
-	union acpi_operand_object       *obj_desc2,
+	union acpi_operand_object       *operand0,
+	union acpi_operand_object       *operand1,
 	union acpi_operand_object       **actual_return_desc,
 	struct acpi_walk_state          *walk_state)
 {
-	acpi_status                     status;
-	u32                             i;
-	acpi_integer                    this_integer;
+	union acpi_operand_object       *local_operand1 = operand1;
 	union acpi_operand_object       *return_desc;
 	char                            *new_buf;
+	acpi_status                     status;
+	acpi_size                       new_length;
 
 
-	ACPI_FUNCTION_ENTRY ();
+	ACPI_FUNCTION_TRACE ("ex_do_concatenate");
+
+
+	/*
+	 * Convert the second operand if necessary.  The first operand
+	 * determines the type of the second operand, (See the Data Types
+	 * section of the ACPI specification.)  Both object types are
+	 * guaranteed to be either Integer/String/Buffer by the operand
+	 * resolution mechanism.
+	 */
+	switch (ACPI_GET_OBJECT_TYPE (operand0)) {
+	case ACPI_TYPE_INTEGER:
+		status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16);
+		break;
+
+	case ACPI_TYPE_STRING:
+		status = acpi_ex_convert_to_string (operand1, &local_operand1,
+				 ACPI_IMPLICIT_CONVERT_HEX);
+		break;
+
+	case ACPI_TYPE_BUFFER:
+		status = acpi_ex_convert_to_buffer (operand1, &local_operand1);
+		break;
+
+	default:
+		ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n",
+				ACPI_GET_OBJECT_TYPE (operand0)));
+		status = AE_AML_INTERNAL;
+	}
 
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
+
+	/*
+	 * Both operands are now known to be the same object type
+	 * (Both are Integer, String, or Buffer), and we can now perform the
+	 * concatenation.
+	 */
 
 	/*
 	 * There are three cases to handle:
@@ -256,113 +294,102 @@
 	 * 2) Two Strings concatenated to produce a new String
 	 * 3) Two Buffers concatenated to produce a new Buffer
 	 */
-	switch (ACPI_GET_OBJECT_TYPE (obj_desc1)) {
+	switch (ACPI_GET_OBJECT_TYPE (operand0)) {
 	case ACPI_TYPE_INTEGER:
 
 		/* Result of two Integers is a Buffer */
 		/* Need enough buffer space for two integers */
 
-		return_desc = acpi_ut_create_buffer_object (acpi_gbl_integer_byte_width * 2);
+		return_desc = acpi_ut_create_buffer_object (
+				   ACPI_MUL_2 (acpi_gbl_integer_byte_width));
 		if (!return_desc) {
-			return (AE_NO_MEMORY);
+			status = AE_NO_MEMORY;
+			goto cleanup;
 		}
 
 		new_buf = (char *) return_desc->buffer.pointer;
 
-		/* Convert the first integer */
-
-		this_integer = obj_desc1->integer.value;
-		for (i = 0; i < acpi_gbl_integer_byte_width; i++) {
-			new_buf[i] = (char) this_integer;
-			this_integer >>= 8;
-		}
+		/* Copy the first integer, LSB first */
 
-		/* Convert the second integer */
+		ACPI_MEMCPY (new_buf,
+				  &operand0->integer.value,
+				  acpi_gbl_integer_byte_width);
 
-		this_integer = obj_desc2->integer.value;
-		for (; i < (ACPI_MUL_2 (acpi_gbl_integer_byte_width)); i++) {
-			new_buf[i] = (char) this_integer;
-			this_integer >>= 8;
-		}
+		/* Copy the second integer (LSB first) after the first */
 
+		ACPI_MEMCPY (new_buf + acpi_gbl_integer_byte_width,
+				  &local_operand1->integer.value,
+				  acpi_gbl_integer_byte_width);
 		break;
 
-
 	case ACPI_TYPE_STRING:
 
 		/* Result of two Strings is a String */
 
-		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
-		if (!return_desc) {
-			return (AE_NO_MEMORY);
+		new_length = (acpi_size) operand0->string.length +
+				 (acpi_size) local_operand1->string.length;
+		if (new_length > ACPI_MAX_STRING_CONVERSION) {
+			status = AE_AML_STRING_LIMIT;
+			goto cleanup;
 		}
 
-		/* Operand0 is string  */
-
-		new_buf = ACPI_MEM_CALLOCATE ((acpi_size) obj_desc1->string.length +
-				   (acpi_size) obj_desc2->string.length + 1);
-		if (!new_buf) {
-			ACPI_REPORT_ERROR
-				(("ex_do_concatenate: String allocation failure\n"));
+		return_desc = acpi_ut_create_string_object (new_length);
+		if (!return_desc) {
 			status = AE_NO_MEMORY;
 			goto cleanup;
 		}
 
+		new_buf = return_desc->string.pointer;
+
 		/* Concatenate the strings */
 
-		ACPI_STRCPY (new_buf, obj_desc1->string.pointer);
-		ACPI_STRCPY (new_buf + obj_desc1->string.length,
-				  obj_desc2->string.pointer);
-
-		/* Complete the String object initialization */
-
-		return_desc->string.pointer = new_buf;
-		return_desc->string.length = obj_desc1->string.length +
-				   obj_desc2->string.length;
+		ACPI_STRCPY (new_buf,
+				  operand0->string.pointer);
+		ACPI_STRCPY (new_buf + operand0->string.length,
+				  local_operand1->string.pointer);
 		break;
 
-
 	case ACPI_TYPE_BUFFER:
 
 		/* Result of two Buffers is a Buffer */
 
 		return_desc = acpi_ut_create_buffer_object (
-				   (acpi_size) obj_desc1->buffer.length +
-				   (acpi_size) obj_desc2->buffer.length);
+				   (acpi_size) operand0->buffer.length +
+				   (acpi_size) local_operand1->buffer.length);
 		if (!return_desc) {
-			return (AE_NO_MEMORY);
+			status = AE_NO_MEMORY;
+			goto cleanup;
 		}
 
 		new_buf = (char *) return_desc->buffer.pointer;
 
 		/* Concatenate the buffers */
 
-		ACPI_MEMCPY (new_buf, obj_desc1->buffer.pointer,
-				  obj_desc1->buffer.length);
-		ACPI_MEMCPY (new_buf + obj_desc1->buffer.length, obj_desc2->buffer.pointer,
-				   obj_desc2->buffer.length);
-
+		ACPI_MEMCPY (new_buf,
+				  operand0->buffer.pointer,
+				  operand0->buffer.length);
+		ACPI_MEMCPY (new_buf + operand0->buffer.length,
+				  local_operand1->buffer.pointer,
+				  local_operand1->buffer.length);
 		break;
 
-
 	default:
 
 		/* Invalid object type, should not happen here */
 
-		ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n",
-				ACPI_GET_OBJECT_TYPE (obj_desc1)));
-		status = AE_AML_INTERNAL;
-		return_desc = NULL;
+		ACPI_REPORT_ERROR (("Concatenate - Invalid object type: %X\n",
+				ACPI_GET_OBJECT_TYPE (operand0)));
+		status =AE_AML_INTERNAL;
+		goto cleanup;
 	}
 
 	*actual_return_desc = return_desc;
-	return (AE_OK);
-
 
 cleanup:
-
-	acpi_ut_remove_reference (return_desc);
-	return (status);
+	if (local_operand1 != operand1) {
+		acpi_ut_remove_reference (local_operand1);
+	}
+	return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -371,8 +398,8 @@
  * FUNCTION:    acpi_ex_do_math_op
  *
  * PARAMETERS:  Opcode              - AML opcode
- *              Operand0            - Integer operand #0
- *              Operand1            - Integer operand #1
+ *              Integer0            - Integer operand #0
+ *              Integer1            - Integer operand #1
  *
  * RETURN:      Integer result of the operation
  *
@@ -385,62 +412,62 @@
 acpi_integer
 acpi_ex_do_math_op (
 	u16                             opcode,
-	acpi_integer                    operand0,
-	acpi_integer                    operand1)
+	acpi_integer                    integer0,
+	acpi_integer                    integer1)
 {
 
 	ACPI_FUNCTION_ENTRY ();
 
 
 	switch (opcode) {
-	case AML_ADD_OP:                /* Add (Operand0, Operand1, Result) */
+	case AML_ADD_OP:                /* Add (Integer0, Integer1, Result) */
 
-		return (operand0 + operand1);
+		return (integer0 + integer1);
 
 
-	case AML_BIT_AND_OP:            /* And (Operand0, Operand1, Result) */
+	case AML_BIT_AND_OP:            /* And (Integer0, Integer1, Result) */
 
-		return (operand0 & operand1);
+		return (integer0 & integer1);
 
 
-	case AML_BIT_NAND_OP:           /* NAnd (Operand0, Operand1, Result) */
+	case AML_BIT_NAND_OP:           /* NAnd (Integer0, Integer1, Result) */
 
-		return (~(operand0 & operand1));
+		return (~(integer0 & integer1));
 
 
-	case AML_BIT_OR_OP:             /* Or (Operand0, Operand1, Result) */
+	case AML_BIT_OR_OP:             /* Or (Integer0, Integer1, Result) */
 
-		return (operand0 | operand1);
+		return (integer0 | integer1);
 
 
-	case AML_BIT_NOR_OP:            /* NOr (Operand0, Operand1, Result) */
+	case AML_BIT_NOR_OP:            /* NOr (Integer0, Integer1, Result) */
 
-		return (~(operand0 | operand1));
+		return (~(integer0 | integer1));
 
 
-	case AML_BIT_XOR_OP:            /* XOr (Operand0, Operand1, Result) */
+	case AML_BIT_XOR_OP:            /* XOr (Integer0, Integer1, Result) */
 
-		return (operand0 ^ operand1);
+		return (integer0 ^ integer1);
 
 
-	case AML_MULTIPLY_OP:           /* Multiply (Operand0, Operand1, Result) */
+	case AML_MULTIPLY_OP:           /* Multiply (Integer0, Integer1, Result) */
 
-		return (operand0 * operand1);
+		return (integer0 * integer1);
 
 
 	case AML_SHIFT_LEFT_OP:         /* shift_left (Operand, shift_count, Result) */
 
-		return (operand0 << operand1);
+		return (integer0 << integer1);
 
 
 	case AML_SHIFT_RIGHT_OP:        /* shift_right (Operand, shift_count, Result) */
 
-		return (operand0 >> operand1);
+		return (integer0 >> integer1);
 
 
-	case AML_SUBTRACT_OP:           /* Subtract (Operand0, Operand1, Result) */
+	case AML_SUBTRACT_OP:           /* Subtract (Integer0, Integer1, Result) */
 
-		return (operand0 - operand1);
+		return (integer0 - integer1);
 
 	default:
 
@@ -451,20 +478,84 @@
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_ex_do_logical_numeric_op
+ *
+ * PARAMETERS:  Opcode              - AML opcode
+ *              Integer0            - Integer operand #0
+ *              Integer1            - Integer operand #1
+ *              logical_result      - TRUE/FALSE result of the operation
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
+ *              operators (LAnd and LOr), both operands must be integers.
+ *
+ *              Note: cleanest machine code seems to be produced by the code
+ *              below, rather than using statements of the form:
+ *                  Result = (Integer0 && Integer1);
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_do_logical_numeric_op (
+	u16                             opcode,
+	acpi_integer                    integer0,
+	acpi_integer                    integer1,
+	u8                              *logical_result)
+{
+	acpi_status                     status = AE_OK;
+	u8                              local_result = FALSE;
+
+
+	ACPI_FUNCTION_TRACE ("ex_do_logical_numeric_op");
+
+
+	switch (opcode) {
+	case AML_LAND_OP:               /* LAnd (Integer0, Integer1) */
+
+		if (integer0 && integer1) {
+			local_result = TRUE;
+		}
+		break;
+
+	case AML_LOR_OP:                /* LOr (Integer0, Integer1) */
+
+		if (integer0 || integer1) {
+			local_result = TRUE;
+		}
+		break;
+
+	default:
+		status = AE_AML_INTERNAL;
+		break;
+	}
+
+	/* Return the logical result and status */
+
+	*logical_result = local_result;
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_ex_do_logical_op
  *
  * PARAMETERS:  Opcode              - AML opcode
- *              obj_desc0           - operand #0
- *              obj_desc1           - operand #1
+ *              Operand0            - operand #0
+ *              Operand1            - operand #1
+ *              logical_result      - TRUE/FALSE result of the operation
  *
- * RETURN:      TRUE/FALSE result of the operation
+ * RETURN:      Status
  *
  * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
  *              functions here is to prevent a lot of pointer dereferencing
  *              to obtain the operands and to simplify the generation of the
- *              logical value.  Both operands must already be validated as
- *              1) Both the same type, and
- *              2) Either Integer, Buffer, or String type.
+ *              logical value. For the Numeric operators (LAnd and LOr), both
+ *              operands must be integers. For the other logical operators,
+ *              operands can be any combination of Integer/String/Buffer. The
+ *              first operand determines the type to which the second operand
+ *              will be converted.
  *
  *              Note: cleanest machine code seems to be produced by the code
  *              below, rather than using statements of the form:
@@ -472,143 +563,175 @@
  *
  ******************************************************************************/
 
-u8
+acpi_status
 acpi_ex_do_logical_op (
 	u16                             opcode,
-	union acpi_operand_object       *obj_desc0,
-	union acpi_operand_object       *obj_desc1)
+	union acpi_operand_object       *operand0,
+	union acpi_operand_object       *operand1,
+	u8                              *logical_result)
 {
-	acpi_integer                    operand0;
-	acpi_integer                    operand1;
-	u8                              *ptr0;
-	u8                              *ptr1;
+	union acpi_operand_object       *local_operand1 = operand1;
+	acpi_integer                    integer0;
+	acpi_integer                    integer1;
 	u32                             length0;
 	u32                             length1;
-	u32                             i;
+	acpi_status                     status = AE_OK;
+	u8                              local_result = FALSE;
+	int                             compare;
 
 
-	ACPI_FUNCTION_ENTRY ();
+	ACPI_FUNCTION_TRACE ("ex_do_logical_op");
 
 
-	if (ACPI_GET_OBJECT_TYPE (obj_desc0) == ACPI_TYPE_INTEGER) {
-		/* Both operands are of type integer */
+	/*
+	 * Convert the second operand if necessary.  The first operand
+	 * determines the type of the second operand, (See the Data Types
+	 * section of the ACPI 3.0+ specification.)  Both object types are
+	 * guaranteed to be either Integer/String/Buffer by the operand
+	 * resolution mechanism.
+	 */
+	switch (ACPI_GET_OBJECT_TYPE (operand0)) {
+	case ACPI_TYPE_INTEGER:
+		status = acpi_ex_convert_to_integer (operand1, &local_operand1, 16);
+		break;
 
-		operand0 = obj_desc0->integer.value;
-		operand1 = obj_desc1->integer.value;
+	case ACPI_TYPE_STRING:
+		status = acpi_ex_convert_to_string (operand1, &local_operand1,
+				 ACPI_IMPLICIT_CONVERT_HEX);
+		break;
 
-		switch (opcode) {
-		case AML_LAND_OP:               /* LAnd (Operand0, Operand1) */
+	case ACPI_TYPE_BUFFER:
+		status = acpi_ex_convert_to_buffer (operand1, &local_operand1);
+		break;
 
-			if (operand0 && operand1) {
-				return (TRUE);
-			}
-			break;
+	default:
+		status = AE_AML_INTERNAL;
+		break;
+	}
+
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
+
+	/*
+	 * Two cases: 1) Both Integers, 2) Both Strings or Buffers
+	 */
+	if (ACPI_GET_OBJECT_TYPE (operand0) == ACPI_TYPE_INTEGER) {
+		/*
+		 * 1) Both operands are of type integer
+		 *    Note: local_operand1 may have changed above
+		 */
+		integer0 = operand0->integer.value;
+		integer1 = local_operand1->integer.value;
 
+		switch (opcode) {
 		case AML_LEQUAL_OP:             /* LEqual (Operand0, Operand1) */
 
-			if (operand0 == operand1) {
-				return (TRUE);
+			if (integer0 == integer1) {
+				local_result = TRUE;
 			}
 			break;
 
 		case AML_LGREATER_OP:           /* LGreater (Operand0, Operand1) */
 
-			if (operand0 > operand1) {
-				return (TRUE);
+			if (integer0 > integer1) {
+				local_result = TRUE;
 			}
 			break;
 
 		case AML_LLESS_OP:              /* LLess (Operand0, Operand1) */
 
-			if (operand0 < operand1) {
-				return (TRUE);
-			}
-			break;
-
-		case AML_LOR_OP:                 /* LOr (Operand0, Operand1) */
-
-			if (operand0 || operand1) {
-				return (TRUE);
+			if (integer0 < integer1) {
+				local_result = TRUE;
 			}
 			break;
 
 		default:
+			status = AE_AML_INTERNAL;
 			break;
 		}
 	}
 	else {
 		/*
-		 * Case for Buffer/String objects.
-		 * NOTE: takes advantage of common Buffer/String object fields
+		 * 2) Both operands are Strings or both are Buffers
+		 *    Note: Code below takes advantage of common Buffer/String
+		 *          object fields. local_operand1 may have changed above. Use
+		 *          memcmp to handle nulls in buffers.
 		 */
-		length0 = obj_desc0->buffer.length;
-		ptr0    = obj_desc0->buffer.pointer;
+		length0 = operand0->buffer.length;
+		length1 = local_operand1->buffer.length;
+
+		/* Lexicographic compare: compare the data bytes */
 
-		length1 = obj_desc1->buffer.length;
-		ptr1    = obj_desc1->buffer.pointer;
+		compare = ACPI_MEMCMP ((const char * ) operand0->buffer.pointer,
+				 (const char * ) local_operand1->buffer.pointer,
+				 (length0 > length1) ? length1 : length0);
 
 		switch (opcode) {
 		case AML_LEQUAL_OP:             /* LEqual (Operand0, Operand1) */
 
 			/* Length and all bytes must be equal */
 
-			if (length0 != length1) {
-				return (FALSE);
-			}
+			if ((length0 == length1) &&
+				(compare == 0)) {
+				/* Length and all bytes match ==> TRUE */
 
-			for (i = 0; i < length0; i++) {
-				if (ptr0[i] != ptr1[i]) {
-					return (FALSE);
-				}
+				local_result = TRUE;
 			}
-			return (TRUE);
+			break;
 
 		case AML_LGREATER_OP:           /* LGreater (Operand0, Operand1) */
 
-			/* Lexicographic compare:  Scan the 1-to-1 data */
-
-			for (i = 0; (i < length0) && (i < length1); i++) {
-				if (ptr0[i] > ptr1[i]) {
-					return (TRUE);
-				}
+			if (compare > 0) {
+				local_result = TRUE;
+				goto cleanup;   /* TRUE */
+			}
+			if (compare < 0) {
+				goto cleanup;   /* FALSE */
 			}
 
-			/* Bytes match, now check lengths */
+			/* Bytes match (to shortest length), compare lengths */
 
 			if (length0 > length1) {
-				return (TRUE);
+				local_result = TRUE;
 			}
-
-			/* Length0 <= Length1 */
-
-			return (FALSE);
+			break;
 
 		case AML_LLESS_OP:              /* LLess (Operand0, Operand1) */
 
-			/* Lexicographic compare:  Scan the 1-to-1 data */
-
-			for (i = 0; (i < length0) && (i < length1); i++) {
-				if (ptr0[i] < ptr1[i]) {
-					return (TRUE);
-				}
+			if (compare > 0) {
+				goto cleanup;   /* FALSE */
+			}
+			if (compare < 0) {
+				local_result = TRUE;
+				goto cleanup;   /* TRUE */
 			}
 
-			/* Bytes match, now check lengths */
+			/* Bytes match (to shortest length), compare lengths */
 
 			if (length0 < length1) {
-				return (TRUE);
+				local_result = TRUE;
 			}
-
-			/* Length0 >= Length1 */
-
-			return (FALSE);
+			break;
 
 		default:
+			status = AE_AML_INTERNAL;
 			break;
 		}
 	}
 
-	return (FALSE);
+cleanup:
+
+	/* New object was created if implicit conversion performed - delete */
+
+	if (local_operand1 != operand1) {
+		acpi_ut_remove_reference (local_operand1);
+	}
+
+	/* Return the logical result and status */
+
+	*logical_result = local_result;
+	return_ACPI_STATUS (status);
 }
 
 
diff -Nru a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
--- a/drivers/acpi/executer/exoparg1.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/acpi/executer/exoparg1.c	2004-12-24 13:37:19 -08:00
@@ -67,7 +67,7 @@
  * Where:
  *
  * xA - ARGUMENTS:    The number of arguments (input operands) that are
- *                    required for this opcode type (1 through 6 args).
+ *                    required for this opcode type (0 through 6 args).
  * yT - TARGETS:      The number of targets (output operands) that are required
  *                    for this opcode type (0, 1, or 2 targets).
  * zR - RETURN VALUE: Indicates whether this opcode type returns a value
@@ -79,6 +79,69 @@
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_ex_opcode_0A_0T_1R
+ *
+ * PARAMETERS:  walk_state          - Current state (contains AML opcode)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Execute operator with no operands, one return value
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_opcode_0A_0T_1R (
+	struct acpi_walk_state          *walk_state)
+{
+	acpi_status                     status = AE_OK;
+	union acpi_operand_object       *return_desc = NULL;
+
+
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+
+
+	/* Examine the AML opcode */
+
+	switch (walk_state->opcode) {
+	case AML_TIMER_OP:      /*  Timer () */
+
+		/* Create a return object of type Integer */
+
+		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+		if (!return_desc) {
+			status = AE_NO_MEMORY;
+			goto cleanup;
+		}
+
+		return_desc->integer.value = acpi_os_get_timer ();
+		break;
+
+	default:                /*  Unknown opcode  */
+
+		ACPI_REPORT_ERROR (("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n",
+			walk_state->opcode));
+		status = AE_AML_BAD_OPCODE;
+		break;
+	}
+
+cleanup:
+
+	if (!walk_state->result_obj) {
+		walk_state->result_obj = return_desc;
+	}
+
+	/* Delete return object on error */
+
+	if (ACPI_FAILURE (status)) {
+		acpi_ut_remove_reference (return_desc);
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_ex_opcode_1A_0T_0R
  *
  * PARAMETERS:  walk_state          - Current state (contains AML opcode)
@@ -124,7 +187,7 @@
 
 	case AML_SLEEP_OP:      /*  Sleep (msec_time) */
 
-		status = acpi_ex_system_do_suspend ((u32) operand[0]->integer.value);
+		status = acpi_ex_system_do_suspend (operand[0]->integer.value);
 		break;
 
 
@@ -222,7 +285,7 @@
 	union acpi_operand_object       *return_desc2 = NULL;
 	u32                             temp32;
 	u32                             i;
-	u32                             power_of_ten;
+	acpi_integer                    power_of_ten;
 	acpi_integer                    digit;
 
 
@@ -262,7 +325,8 @@
 			 * Acpi specification describes Integer type as a little
 			 * endian unsigned value, so this boundary condition is valid.
 			 */
-			for (temp32 = 0; return_desc->integer.value && temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
+			for (temp32 = 0; return_desc->integer.value &&
+					   temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
 				return_desc->integer.value >>= 1;
 			}
 
@@ -278,13 +342,15 @@
 			 * The Acpi specification describes Integer type as a little
 			 * endian unsigned value, so this boundary condition is valid.
 			 */
-			for (temp32 = 0; return_desc->integer.value && temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
+			for (temp32 = 0; return_desc->integer.value &&
+					   temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
 				return_desc->integer.value <<= 1;
 			}
 
 			/* Since the bit position is one-based, subtract from 33 (65) */
 
-			return_desc->integer.value = temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
+			return_desc->integer.value = temp32 == 0 ? 0 :
+					  (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
 			break;
 
 
@@ -319,7 +385,8 @@
 
 				/* Sum the digit into the result with the current power of 10 */
 
-				return_desc->integer.value += (((acpi_integer) temp32) * power_of_ten);
+				return_desc->integer.value += (((acpi_integer) temp32) *
+						 power_of_ten);
 
 				/* Shift to next BCD digit */
 
@@ -340,18 +407,20 @@
 			/* Each BCD digit is one nybble wide */
 
 			for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
-				(void) acpi_ut_short_divide (&digit, 10, &digit, &temp32);
+				(void) acpi_ut_short_divide (digit, 10, &digit, &temp32);
 
 				/* Insert the BCD digit that resides in the remainder from above */
 
-				return_desc->integer.value |= (((acpi_integer) temp32) << (i * 4));
+				return_desc->integer.value |= (((acpi_integer) temp32) <<
+						   ACPI_MUL_4 (i));
 			}
 
 			/* Overflow if there is any data left in Digit */
 
 			if (digit > 0) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Integer too large to convert to BCD: %8.8X%8.8X\n",
-						ACPI_FORMAT_UINT64 (operand[0]->integer.value)));
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"Integer too large to convert to BCD: %8.8X%8.8X\n",
+					ACPI_FORMAT_UINT64 (operand[0]->integer.value)));
 				status = AE_AML_NUMERIC_OVERFLOW;
 				goto cleanup;
 			}
@@ -429,42 +498,47 @@
 	 */
 	case AML_COPY_OP:               /* Copy (Source, Target) */
 
-		status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc, walk_state);
+		status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc,
+				 walk_state);
 		break;
 
 
 	case AML_TO_DECSTRING_OP:       /* to_decimal_string (Data, Result) */
 
-		status = acpi_ex_convert_to_string (operand[0], &return_desc, 10, ACPI_UINT32_MAX, walk_state);
+		status = acpi_ex_convert_to_string (operand[0], &return_desc,
+				 ACPI_EXPLICIT_CONVERT_DECIMAL);
 		break;
 
 
 	case AML_TO_HEXSTRING_OP:       /* to_hex_string (Data, Result) */
 
-		status = acpi_ex_convert_to_string (operand[0], &return_desc, 16, ACPI_UINT32_MAX, walk_state);
+		status = acpi_ex_convert_to_string (operand[0], &return_desc,
+				 ACPI_EXPLICIT_CONVERT_HEX);
 		break;
 
 
 	case AML_TO_BUFFER_OP:          /* to_buffer (Data, Result) */
 
-		status = acpi_ex_convert_to_buffer (operand[0], &return_desc, walk_state);
+		status = acpi_ex_convert_to_buffer (operand[0], &return_desc);
 		break;
 
 
 	case AML_TO_INTEGER_OP:         /* to_integer (Data, Result) */
 
-		status = acpi_ex_convert_to_integer (operand[0], &return_desc, walk_state);
+		status = acpi_ex_convert_to_integer (operand[0], &return_desc,
+				 ACPI_ANY_BASE);
 		break;
 
 
-	case AML_SHIFT_LEFT_BIT_OP:     /*  shift_left_bit (Source, bit_num) */
-	case AML_SHIFT_RIGHT_BIT_OP:    /*  shift_right_bit (Source, bit_num) */
+	case AML_SHIFT_LEFT_BIT_OP:     /* shift_left_bit (Source, bit_num) */
+	case AML_SHIFT_RIGHT_BIT_OP:    /* shift_right_bit (Source, bit_num) */
 
 		/*
 		 * These are two obsolete opcodes
 		 */
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n",
-				  acpi_ps_get_opcode_name (walk_state->opcode)));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"%s is obsolete and not implemented\n",
+			acpi_ps_get_opcode_name (walk_state->opcode)));
 		status = AE_SUPPORT;
 		goto cleanup;
 
@@ -537,7 +611,13 @@
 			goto cleanup;
 		}
 
-		return_desc->integer.value = !operand[0]->integer.value;
+		/*
+		 * Set result to ONES (TRUE) if Value == 0.  Note:
+		 * return_desc->Integer.Value is initially == 0 (FALSE) from above.
+		 */
+		if (!operand[0]->integer.value) {
+			return_desc->integer.value = ACPI_INTEGER_MAX;
+		}
 		break;
 
 
@@ -545,54 +625,80 @@
 	case AML_INCREMENT_OP:          /* Increment (Operand)  */
 
 		/*
-		 * Since we are expecting a Reference operand, it
-		 * can be either a NS Node or an internal object.
+		 * Create a new integer.  Can't just get the base integer and
+		 * increment it because it may be an Arg or Field.
+		 */
+		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+		if (!return_desc) {
+			status = AE_NO_MEMORY;
+			goto cleanup;
+		}
+
+		/*
+		 * Since we are expecting a Reference operand, it can be either a
+		 * NS Node or an internal object.
 		 */
-		return_desc = operand[0];
-		if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_OPERAND) {
+		temp_desc = operand[0];
+		if (ACPI_GET_DESCRIPTOR_TYPE (temp_desc) == ACPI_DESC_TYPE_OPERAND) {
 			/* Internal reference object - prevent deletion */
 
-			acpi_ut_add_reference (return_desc);
+			acpi_ut_add_reference (temp_desc);
 		}
 
 		/*
-		 * Convert the return_desc Reference to a Number
-		 * (This removes a reference on the return_desc object)
+		 * Convert the Reference operand to an Integer (This removes a
+		 * reference on the Operand[0] object)
+		 *
+		 * NOTE:  We use LNOT_OP here in order to force resolution of the
+		 * reference operand to an actual integer.
 		 */
-		status = acpi_ex_resolve_operands (AML_LNOT_OP, &return_desc, walk_state);
+		status = acpi_ex_resolve_operands (AML_LNOT_OP, &temp_desc, walk_state);
 		if (ACPI_FAILURE (status)) {
 			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n",
-				acpi_ps_get_opcode_name (walk_state->opcode), acpi_format_exception(status)));
+				acpi_ps_get_opcode_name (walk_state->opcode),
+				acpi_format_exception(status)));
 
 			goto cleanup;
 		}
 
 		/*
-		 * return_desc is now guaranteed to be an Integer object
-		 * Do the actual increment or decrement
+		 * temp_desc is now guaranteed to be an Integer object --
+		 * Perform the actual increment or decrement
 		 */
-		if (AML_INCREMENT_OP == walk_state->opcode) {
-			return_desc->integer.value++;
+		if (walk_state->opcode == AML_INCREMENT_OP) {
+			return_desc->integer.value = temp_desc->integer.value +1;
 		}
 		else {
-			return_desc->integer.value--;
+			return_desc->integer.value = temp_desc->integer.value -1;
 		}
 
-		/* Store the result back in the original descriptor */
+		/* Finished with this Integer object */
+
+		acpi_ut_remove_reference (temp_desc);
 
+		/*
+		 * Store the result back (indirectly) through the original
+		 * Reference object
+		 */
 		status = acpi_ex_store (return_desc, operand[0], walk_state);
 		break;
 
 
 	case AML_TYPE_OP:               /* object_type (source_object) */
 
+		/*
+		 * Note: The operand is not resolved at this point because we want to
+		 * get the associated object, not its value.  For example, we don't want
+		 * to resolve a field_unit to its value, we want the actual field_unit
+		 * object.
+		 */
+
 		/* Get the type of the base object */
 
 		status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, NULL);
 		if (ACPI_FAILURE (status)) {
 			goto cleanup;
 		}
-
 		/* Allocate a descriptor to hold the type. */
 
 		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
@@ -607,6 +713,11 @@
 
 	case AML_SIZE_OF_OP:            /* size_of (source_object) */
 
+		/*
+		 * Note: The operand is not resolved at this point because we want to
+		 * get the associated object, not its value.
+		 */
+
 		/* Get the base object */
 
 		status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, &temp_desc);
@@ -615,11 +726,19 @@
 		}
 
 		/*
-		 * Type is guaranteed to be a buffer, string, or package at this
-		 * point (even if the original operand was an object reference, it
-		 * will be resolved and typechecked during operand resolution.)
+		 * The type of the base object must be integer, buffer, string, or
+		 * package.  All others are not supported.
+		 *
+		 * NOTE: Integer is not specifically supported by the ACPI spec,
+		 * but is supported implicitly via implicit operand conversion.
+		 * rather than bother with conversion, we just use the byte width
+		 * global (4 or 8 bytes).
 		 */
 		switch (type) {
+		case ACPI_TYPE_INTEGER:
+			value = acpi_gbl_integer_byte_width;
+			break;
+
 		case ACPI_TYPE_BUFFER:
 			value = temp_desc->buffer.length;
 			break;
@@ -633,7 +752,8 @@
 			break;
 
 		default:
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "size_of, Not Buf/Str/Pkg - found type %s\n",
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n",
 				acpi_ut_get_type_name (type)));
 			status = AE_AML_OPERAND_TYPE;
 			goto cleanup;
@@ -803,7 +923,8 @@
 						 * an uninitialized package element and is thus a
 						 * severe error.
 						 */
-						ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "NULL package element obj %p\n",
+						ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+							"NULL package element obj %p\n",
 							operand[0]));
 						status = AE_AML_UNINITIALIZED_ELEMENT;
 						goto cleanup;
@@ -815,7 +936,8 @@
 
 				default:
 
-					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Index target_type %X in obj %p\n",
+					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+						"Unknown Index target_type %X in obj %p\n",
 						operand[0]->reference.target_type, operand[0]));
 					status = AE_AML_OPERAND_TYPE;
 					goto cleanup;
@@ -839,7 +961,8 @@
 
 
 			default:
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n",
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"Unknown opcode in ref(%p) - %X\n",
 					operand[0], operand[0]->reference.opcode));
 
 				status = AE_TYPE;
diff -Nru a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c
--- a/drivers/acpi/executer/exoparg2.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/acpi/executer/exoparg2.c	2004-12-24 13:36:55 -08:00
@@ -199,7 +199,8 @@
 	acpi_status                     status;
 
 
-	ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_2T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_2T_1R",
+		acpi_ps_get_opcode_name (walk_state->opcode));
 
 
 	/*
@@ -222,8 +223,10 @@
 
 		/* Quotient to return_desc1, remainder to return_desc2 */
 
-		status = acpi_ut_divide (&operand[0]->integer.value, &operand[1]->integer.value,
-				   &return_desc1->integer.value, &return_desc2->integer.value);
+		status = acpi_ut_divide (operand[0]->integer.value,
+				   operand[1]->integer.value,
+				   &return_desc1->integer.value,
+				   &return_desc2->integer.value);
 		if (ACPI_FAILURE (status)) {
 			goto cleanup;
 		}
@@ -292,13 +295,13 @@
 {
 	union acpi_operand_object       **operand = &walk_state->operands[0];
 	union acpi_operand_object       *return_desc = NULL;
-	union acpi_operand_object       *temp_desc = NULL;
 	u32                             index;
 	acpi_status                     status = AE_OK;
 	acpi_size                       length;
 
 
-	ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_1T_1R",
+		acpi_ps_get_opcode_name (walk_state->opcode));
 
 
 	/*
@@ -331,52 +334,17 @@
 
 		/* return_desc will contain the remainder */
 
-		status = acpi_ut_divide (&operand[0]->integer.value, &operand[1]->integer.value,
-				  NULL, &return_desc->integer.value);
+		status = acpi_ut_divide (operand[0]->integer.value,
+				   operand[1]->integer.value,
+				   NULL,
+				   &return_desc->integer.value);
 		break;
 
 
 	case AML_CONCAT_OP:             /* Concatenate (Data1, Data2, Result) */
 
-		/*
-		 * Convert the second operand if necessary.  The first operand
-		 * determines the type of the second operand, (See the Data Types
-		 * section of the ACPI specification.)  Both object types are
-		 * guaranteed to be either Integer/String/Buffer by the operand
-		 * resolution mechanism above.
-		 */
-		switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
-		case ACPI_TYPE_INTEGER:
-			status = acpi_ex_convert_to_integer (operand[1], &temp_desc, walk_state);
-			break;
-
-		case ACPI_TYPE_STRING:
-			status = acpi_ex_convert_to_string (operand[1], &temp_desc, 16, ACPI_UINT32_MAX, walk_state);
-			break;
-
-		case ACPI_TYPE_BUFFER:
-			status = acpi_ex_convert_to_buffer (operand[1], &temp_desc, walk_state);
-			break;
-
-		default:
-			ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n",
-					ACPI_GET_OBJECT_TYPE (operand[0])));
-			status = AE_AML_INTERNAL;
-		}
-
-		if (ACPI_FAILURE (status)) {
-			goto cleanup;
-		}
-
-		/*
-		 * Both operands are now known to be the same object type
-		 * (Both are Integer, String, or Buffer), and we can now perform the
-		 * concatenation.
-		 */
-		status = acpi_ex_do_concatenate (operand[0], temp_desc, &return_desc, walk_state);
-		if (temp_desc != operand[1]) {
-			acpi_ut_remove_reference (temp_desc);
-		}
+		status = acpi_ex_do_concatenate (operand[0], operand[1],
+				 &return_desc, walk_state);
 		break;
 
 
@@ -387,55 +355,45 @@
 		 * been converted.)  Copy the raw buffer data to a new object of type String.
 		 */
 
-		/* Get the length of the new string */
-
+		/*
+		 * Get the length of the new string. It is the smallest of:
+		 * 1) Length of the input buffer
+		 * 2) Max length as specified in the to_string operator
+		 * 3) Length of input buffer up to a zero byte (null terminator)
+		 *
+		 * NOTE: A length of zero is ok, and will create a zero-length, null
+		 *       terminated string.
+		 */
 		length = 0;
-		if (operand[1]->integer.value == 0) {
-			/* Handle optional length value */
-
-			operand[1]->integer.value = ACPI_INTEGER_MAX;
-		}
-
 		while ((length < operand[0]->buffer.length) &&
 			   (length < operand[1]->integer.value) &&
 			   (operand[0]->buffer.pointer[length])) {
 			length++;
+			if (length > ACPI_MAX_STRING_CONVERSION) {
+				status = AE_AML_STRING_LIMIT;
+				goto cleanup;
+			}
 		}
 
-		if (length > ACPI_MAX_STRING_CONVERSION) {
-			status = AE_AML_STRING_LIMIT;
-			goto cleanup;
-		}
-
-		/* Create the internal return object */
+		/* Allocate a new string object */
 
-		return_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
+		return_desc = acpi_ut_create_string_object (length);
 		if (!return_desc) {
 			status = AE_NO_MEMORY;
 			goto cleanup;
 		}
 
-		/* Allocate a new string buffer (Length + 1 for null terminator) */
-
-		return_desc->string.pointer = ACPI_MEM_CALLOCATE (length + 1);
-		if (!return_desc->string.pointer) {
-			status = AE_NO_MEMORY;
-			goto cleanup;
-		}
+		/* Copy the raw buffer data with no transform. NULL terminated already. */
 
-		/* Copy the raw buffer data with no transform */
-
-		ACPI_MEMCPY (return_desc->string.pointer, operand[0]->buffer.pointer, length);
-
-		/* Set the string length */
-
-		return_desc->string.length = (u32) length;
+		ACPI_MEMCPY (return_desc->string.pointer,
+			operand[0]->buffer.pointer, length);
 		break;
 
 
 	case AML_CONCAT_RES_OP:         /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
 
-		status = acpi_ex_concat_template (operand[0], operand[1], &return_desc, walk_state);
+		status = acpi_ex_concat_template (operand[0], operand[1],
+				 &return_desc, walk_state);
 		break;
 
 
@@ -458,7 +416,8 @@
 			/* Object to be indexed is a Package */
 
 			if (index >= operand[0]->package.count) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value (%X) beyond package end (%X)\n",
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"Index value (%X) beyond package end (%X)\n",
 					index, operand[0]->package.count));
 				status = AE_AML_PACKAGE_LIMIT;
 				goto cleanup;
@@ -472,7 +431,8 @@
 			/* Object to be indexed is a Buffer */
 
 			if (index >= operand[0]->buffer.length) {
-				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value (%X) beyond end of buffer (%X)\n",
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"Index value (%X) beyond end of buffer (%X)\n",
 					index, operand[0]->buffer.length));
 				status = AE_AML_BUFFER_LIMIT;
 				goto cleanup;
@@ -558,7 +518,8 @@
 	u8                              logical_result = FALSE;
 
 
-	ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+	ACPI_FUNCTION_TRACE_STR ("ex_opcode_2A_0T_1R",
+		acpi_ps_get_opcode_name (walk_state->opcode));
 
 
 	/* Create the internal return object */
@@ -572,18 +533,15 @@
 	/*
 	 * Execute the Opcode
 	 */
-	if (walk_state->op_info->flags & AML_LOGICAL) /* logical_op (Operand0, Operand1) */ {
-		/* Both operands must be of the same type */
-
-		if (ACPI_GET_OBJECT_TYPE (operand[0]) !=
-			ACPI_GET_OBJECT_TYPE (operand[1])) {
-			status = AE_AML_OPERAND_TYPE;
-			goto cleanup;
-		}
-
-		logical_result = acpi_ex_do_logical_op (walk_state->opcode,
-				 operand[0],
-				 operand[1]);
+	if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) /* logical_op (Operand0, Operand1) */ {
+		status = acpi_ex_do_logical_numeric_op (walk_state->opcode,
+				  operand[0]->integer.value, operand[1]->integer.value,
+				  &logical_result);
+		goto store_logical_result;
+	}
+	else if (walk_state->op_info->flags & AML_LOGICAL)  /* logical_op (Operand0, Operand1) */ {
+		status = acpi_ex_do_logical_op (walk_state->opcode, operand[0],
+				 operand[1], &logical_result);
 		goto store_logical_result;
 	}
 
diff -Nru a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c
--- a/drivers/acpi/executer/exprep.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/acpi/executer/exprep.c	2004-12-24 13:36:30 -08:00
@@ -508,6 +508,7 @@
 
 		if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) {
 			ACPI_REPORT_ERROR (("Null Index Object during field prep\n"));
+			acpi_ut_delete_object_desc (obj_desc);
 			return_ACPI_STATUS (AE_AML_INTERNAL);
 		}
 
diff -Nru a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
--- a/drivers/acpi/executer/exregion.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/executer/exregion.c	2004-12-24 13:36:18 -08:00
@@ -121,7 +121,7 @@
 	 * Hardware does not support non-aligned data transfers, we must verify
 	 * the request.
 	 */
-	(void) acpi_ut_short_divide ((acpi_integer *) &address, length, NULL, &remainder);
+	(void) acpi_ut_short_divide ((acpi_integer) address, length, NULL, &remainder);
 	if (remainder != 0) {
 		return_ACPI_STATUS (AE_AML_ALIGNMENT);
 	}
diff -Nru a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c
--- a/drivers/acpi/executer/exresolv.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/acpi/executer/exresolv.c	2004-12-24 13:36:47 -08:00
@@ -327,12 +327,45 @@
 	union acpi_operand_object       *obj_desc = (void *) operand;
 	struct acpi_namespace_node      *node;
 	acpi_object_type                type;
+	acpi_status                     status;
 
 
 	ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple");
 
 
 	/*
+	 * Operand can be either a namespace node or an operand descriptor
+	 */
+	switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
+	case ACPI_DESC_TYPE_OPERAND:
+		type = obj_desc->common.type;
+		break;
+
+	case ACPI_DESC_TYPE_NAMED:
+		type = ((struct acpi_namespace_node *) obj_desc)->type;
+		obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc);
+
+		/* If we had an Alias node, use the attached object for type info */
+
+		if (type == ACPI_TYPE_LOCAL_ALIAS) {
+			type = ((struct acpi_namespace_node *) obj_desc)->type;
+			obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc);
+		}
+		break;
+
+	default:
+		return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+	}
+
+
+	/*
+	 * If type is anything other than a reference, we are done
+	 */
+	if (type != ACPI_TYPE_LOCAL_REFERENCE) {
+		goto exit;
+	}
+
+	/*
 	 * For reference objects created via the ref_of or Index operators,
 	 * we need to get to the base object (as per the ACPI specification
 	 * of the object_type and size_of operators). This means traversing
@@ -420,6 +453,33 @@
 
 			if (obj_desc == operand) {
 				return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
+			}
+			break;
+
+
+		case AML_LOCAL_OP:
+		case AML_ARG_OP:
+
+			if (return_desc) {
+				status = acpi_ds_method_data_get_value (obj_desc->reference.opcode,
+						  obj_desc->reference.offset, walk_state, &obj_desc);
+				if (ACPI_FAILURE (status)) {
+					return_ACPI_STATUS (status);
+				}
+				acpi_ut_remove_reference (obj_desc);
+			}
+			else {
+				status = acpi_ds_method_data_get_node (obj_desc->reference.opcode,
+						 obj_desc->reference.offset, walk_state, &node);
+				if (ACPI_FAILURE (status)) {
+					return_ACPI_STATUS (status);
+				}
+
+				obj_desc = acpi_ns_get_attached_object (node);
+				if (!obj_desc) {
+					type = ACPI_TYPE_ANY;
+					goto exit;
+				}
 			}
 			break;
 
diff -Nru a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
--- a/drivers/acpi/executer/exresop.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/acpi/executer/exresop.c	2004-12-24 13:37:19 -08:00
@@ -160,7 +160,7 @@
 		return_ACPI_STATUS (AE_AML_INTERNAL);
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] operand_types=%X \n",
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] required_operand_types=%8.8X \n",
 		opcode, op_info->name, arg_types));
 
 	/*
@@ -227,12 +227,13 @@
 				case AML_LOAD_OP:   /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
 
 					ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-						"Reference Opcode: %s\n", op_info->name)));
+						"Operand is a Reference, ref_opcode [%s]\n",
+						(acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name)));
 					break;
 
 				default:
 					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-						"Unknown Reference Opcode %X [%s]\n",
+						"Operand is a Reference, Unknown Reference Opcode %X [%s]\n",
 						obj_desc->reference.opcode,
 						(acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name));
 
@@ -398,7 +399,7 @@
 			 * But we can implicitly convert from a STRING or BUFFER
 			 * Aka - "Implicit Source Operand Conversion"
 			 */
-			status = acpi_ex_convert_to_integer (obj_desc, stack_ptr, walk_state);
+			status = acpi_ex_convert_to_integer (obj_desc, stack_ptr, 16);
 			if (ACPI_FAILURE (status)) {
 				if (status == AE_TYPE) {
 					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -420,7 +421,7 @@
 			 * But we can implicitly convert from a STRING or INTEGER
 			 * Aka - "Implicit Source Operand Conversion"
 			 */
-			status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr, walk_state);
+			status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr);
 			if (ACPI_FAILURE (status)) {
 				if (status == AE_TYPE) {
 					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -442,7 +443,8 @@
 			 * But we can implicitly convert from a BUFFER or INTEGER
 			 * Aka - "Implicit Source Operand Conversion"
 			 */
-			status = acpi_ex_convert_to_string (obj_desc, stack_ptr, 16, ACPI_UINT32_MAX, walk_state);
+			status = acpi_ex_convert_to_string (obj_desc, stack_ptr,
+					 ACPI_IMPLICIT_CONVERT_HEX);
 			if (ACPI_FAILURE (status)) {
 				if (status == AE_TYPE) {
 					ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -494,7 +496,7 @@
 
 				/* Highest priority conversion is to type Buffer */
 
-				status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr, walk_state);
+				status = acpi_ex_convert_to_buffer (obj_desc, stack_ptr);
 				if (ACPI_FAILURE (status)) {
 					return_ACPI_STATUS (status);
 				}
diff -Nru a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
--- a/drivers/acpi/executer/exstore.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/acpi/executer/exstore.c	2004-12-24 13:36:48 -08:00
@@ -129,7 +129,8 @@
 		/* Destination is not a Reference object */
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Destination is not a Reference or Constant object [%p]\n", dest_desc));
+			"Target is not a Reference or Constant object - %s [%p]\n",
+			acpi_ut_get_object_type_name (dest_desc), dest_desc));
 
 		ACPI_DUMP_STACK_ENTRY (source_desc);
 		ACPI_DUMP_STACK_ENTRY (dest_desc);
@@ -182,23 +183,37 @@
 		 * Storing to the Debug object causes the value stored to be
 		 * displayed and otherwise has no effect -- see ACPI Specification
 		 */
-		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Write to Debug Object: ****:\n\n"));
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+			"**** Write to Debug Object: Object %p %s ****:\n\n",
+			source_desc, acpi_ut_get_object_type_name (source_desc)));
 
 		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ",
-				  acpi_ut_get_object_type_name (source_desc)));
+			acpi_ut_get_object_type_name (source_desc)));
+
+		if (!acpi_ut_valid_internal_object (source_desc)) {
+		   ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
+			   "%p, Invalid Internal Object!\n", source_desc));
+		   break;
+		}
 
 		switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
 		case ACPI_TYPE_INTEGER:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
+			if (acpi_gbl_integer_byte_width == 4) {
+				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
+					(u32) source_desc->integer.value));
+			}
+			else {
+				ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
 					ACPI_FORMAT_UINT64 (source_desc->integer.value)));
+			}
 			break;
 
 
 		case ACPI_TYPE_BUFFER:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X",
-					(u32) source_desc->buffer.length));
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]",
+				(u32) source_desc->buffer.length));
 			ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
 				(source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
 			break;
@@ -206,22 +221,22 @@
 
 		case ACPI_TYPE_STRING:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n",
-					source_desc->string.length, source_desc->string.pointer));
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
+				source_desc->string.length, source_desc->string.pointer));
 			break;
 
 
 		case ACPI_TYPE_PACKAGE:
 
-			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Size 0x%.2X Elements Ptr - %p\n",
-					source_desc->package.count, source_desc->package.elements));
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] Elements Ptr - %p\n",
+				source_desc->package.count, source_desc->package.elements));
 			break;
 
 
 		default:
 
 			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n",
-					source_desc));
+				source_desc));
 			break;
 		}
 
diff -Nru a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
--- a/drivers/acpi/executer/exsystem.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/acpi/executer/exsystem.c	2004-12-24 13:37:01 -08:00
@@ -167,7 +167,7 @@
 
 acpi_status
 acpi_ex_system_do_suspend (
-	u32                             how_long)
+	acpi_integer                    how_long)
 {
 	acpi_status                     status;
 
@@ -179,8 +179,7 @@
 
 	acpi_ex_exit_interpreter ();
 
-	acpi_os_sleep ((u16) (how_long / (u32) 1000),
-			  (u16) (how_long % (u32) 1000));
+	acpi_os_sleep (how_long);
 
 	/* And now we must get the interpreter again */
 
diff -Nru a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
--- a/drivers/acpi/executer/exutils.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/acpi/executer/exutils.c	2004-12-24 13:36:30 -08:00
@@ -280,25 +280,25 @@
 {
 	u32                             num_digits;
 	acpi_integer                    current_value;
-	acpi_integer                    quotient;
 
 
 	ACPI_FUNCTION_TRACE ("ex_digits_needed");
 
 
-	/*
-	 * acpi_integer is unsigned, so we don't worry about a '-'
-	 */
-	if ((current_value = value) == 0) {
+	/* acpi_integer is unsigned, so we don't worry about a '-' prefix */
+
+	if (value == 0) {
 		return_VALUE (1);
 	}
 
+	current_value = value;
 	num_digits = 0;
 
+	/* Count the digits in the requested base */
+
 	while (current_value) {
-		(void) acpi_ut_short_divide (&current_value, base, &quotient, NULL);
+		(void) acpi_ut_short_divide (current_value, base, &current_value, NULL);
 		num_digits++;
-		current_value = quotient;
 	}
 
 	return_VALUE (num_digits);
@@ -361,7 +361,6 @@
 	u32                             count;
 	u32                             digits_needed;
 	u32                             remainder;
-	acpi_integer                    quotient;
 
 
 	ACPI_FUNCTION_ENTRY ();
@@ -371,9 +370,8 @@
 	out_string[digits_needed] = 0;
 
 	for (count = digits_needed; count > 0; count--) {
-		(void) acpi_ut_short_divide (&value, 10, &quotient, &remainder);
+		(void) acpi_ut_short_divide (value, 10, &value, &remainder);
 		out_string[count-1] = (char) ('0' + remainder);\
-		value = quotient;
 	}
 }
 
diff -Nru a/drivers/acpi/fan.c b/drivers/acpi/fan.c
--- a/drivers/acpi/fan.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/acpi/fan.c	2004-12-24 13:36:17 -08:00
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <asm/uaccess.h>
 
 #include <acpi/acpi_bus.h>
@@ -75,51 +76,41 @@
 
 
 static int
-acpi_fan_read_state (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*data)
+acpi_fan_read_state (struct seq_file *seq, void *offset)
 {
-	struct acpi_fan		*fan = (struct acpi_fan *) data;
-	char			*p = page;
-	int			len = 0;
+	struct acpi_fan		*fan = (struct acpi_fan *) seq->private;
 	int			state = 0;
 
 	ACPI_FUNCTION_TRACE("acpi_fan_read_state");
 
-	if (!fan || (off != 0))
+	if (!fan)
 		goto end;
 
 	if (acpi_bus_get_power(fan->handle, &state))
 		goto end;
 
-	p += sprintf(p, "status:                  %s\n",
+	seq_printf(seq, "status:                  %s\n",
 		!state?"on":"off");
 
 end:
-	len = (p - page);
-	if (len <= off+count) *eof = 1;
-	*start = page + off;
-	len -= off;
-	if (len>count) len = count;
-	if (len<0) len = 0;
-
-	return_VALUE(len);
+	return_VALUE(0);
 }
 
+static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_fan_read_state, PDE(inode)->data);
+}
 
-static int
+static ssize_t
 acpi_fan_write_state (
 	struct file		*file,
 	const char		__user *buffer,
-	unsigned long		count,
-	void			*data)
+	size_t			count,
+	loff_t			*ppos)
 {
 	int			result = 0;
-	struct acpi_fan		*fan = (struct acpi_fan *) data;
+	struct seq_file		*m = (struct seq_file *)file->private_data;
+	struct acpi_fan		*fan = (struct acpi_fan *) m->private;
 	char			state_string[12] = {'\0'};
 
 	ACPI_FUNCTION_TRACE("acpi_fan_write_state");
@@ -140,6 +131,14 @@
 	return_VALUE(count);
 }
 
+static struct file_operations acpi_fan_state_ops = {
+	.open		= acpi_fan_state_open_fs,
+	.read		= seq_read,
+	.write		= acpi_fan_write_state,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.owner = THIS_MODULE,
+};
 
 static int
 acpi_fan_add_fs (
@@ -168,8 +167,7 @@
 			"Unable to create '%s' fs entry\n",
 			ACPI_FAN_FILE_STATE));
 	else {
-		entry->read_proc = acpi_fan_read_state;
-		entry->write_proc = acpi_fan_write_state;
+		entry->proc_fops = &acpi_fan_state_ops;
 		entry->data = acpi_driver_data(device);
 		entry->owner = THIS_MODULE;
 	}
diff -Nru a/drivers/acpi/hardware/Makefile b/drivers/acpi/hardware/Makefile
--- a/drivers/acpi/hardware/Makefile	2004-12-24 13:37:19 -08:00
+++ b/drivers/acpi/hardware/Makefile	2004-12-24 13:37:19 -08:00
@@ -2,6 +2,8 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-obj-y := hwacpi.o  hwgpe.o  hwregs.o  hwsleep.o  hwtimer.o
+obj-y := hwacpi.o  hwgpe.o  hwregs.o  hwsleep.o
+
+obj-$(ACPI_FUTURE_USAGE) += hwtimer.o
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
--- a/drivers/acpi/hardware/hwgpe.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/acpi/hardware/hwgpe.c	2004-12-24 13:36:17 -08:00
@@ -135,7 +135,7 @@
  * DESCRIPTION: Return the status of a single GPE.
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_hw_get_gpe_status (
 	struct acpi_gpe_event_info      *gpe_event_info,
@@ -194,6 +194,7 @@
 unlock_and_exit:
 	return (status);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /******************************************************************************
diff -Nru a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
--- a/drivers/acpi/hardware/hwregs.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/acpi/hardware/hwregs.c	2004-12-24 13:37:18 -08:00
@@ -43,6 +43,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
@@ -211,6 +212,7 @@
 	acpi_ut_remove_reference (info.return_object);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_get_sleep_type_data);
 
 
 /*******************************************************************************
@@ -307,6 +309,7 @@
 
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_get_register);
 
 
 /*******************************************************************************
@@ -457,6 +460,7 @@
 			value, register_value, bit_reg_info->parent_register));
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_set_register);
 
 
 /******************************************************************************
@@ -709,6 +713,7 @@
 	u32                             *value,
 	struct acpi_generic_address     *reg)
 {
+	u64                             address;
 	acpi_status                     status;
 
 
@@ -720,8 +725,14 @@
 	 * a non-zero address within. However, don't return an error
 	 * because the PM1A/B code must not fail if B isn't present.
 	 */
-	if ((!reg) ||
-		(!reg->address)) {
+	if (!reg) {
+		return (AE_OK);
+	}
+
+	/* Get a local copy of the address.  Handles possible alignment issues */
+
+	ACPI_MOVE_64_TO_64 (&address, &reg->address);
+	if (!address) {
 		return (AE_OK);
 	}
 	*value = 0;
@@ -734,14 +745,14 @@
 	case ACPI_ADR_SPACE_SYSTEM_MEMORY:
 
 		status = acpi_os_read_memory (
-				 (acpi_physical_address) reg->address,
+				 (acpi_physical_address) address,
 				 value, width);
 		break;
 
 
 	case ACPI_ADR_SPACE_SYSTEM_IO:
 
-		status = acpi_os_read_port ((acpi_io_address) reg->address,
+		status = acpi_os_read_port ((acpi_io_address) address,
 				 value, width);
 		break;
 
@@ -754,7 +765,7 @@
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read:  %8.8X width %2d from %8.8X%8.8X (%s)\n",
 			*value, width,
-			ACPI_FORMAT_UINT64 (reg->address),
+			ACPI_FORMAT_UINT64 (address),
 			acpi_ut_get_region_name (reg->address_space_id)));
 
 	return (status);
@@ -781,6 +792,7 @@
 	u32                             value,
 	struct acpi_generic_address     *reg)
 {
+	u64                             address;
 	acpi_status                     status;
 
 
@@ -792,8 +804,14 @@
 	 * a non-zero address within. However, don't return an error
 	 * because the PM1A/B code must not fail if B isn't present.
 	 */
-	if ((!reg) ||
-		(!reg->address)) {
+	if (!reg) {
+		return (AE_OK);
+	}
+
+	/* Get a local copy of the address.  Handles possible alignment issues */
+
+	ACPI_MOVE_64_TO_64 (&address, &reg->address);
+	if (!address) {
 		return (AE_OK);
 	}
 
@@ -805,14 +823,14 @@
 	case ACPI_ADR_SPACE_SYSTEM_MEMORY:
 
 		status = acpi_os_write_memory (
-				 (acpi_physical_address) reg->address,
+				 (acpi_physical_address) address,
 				 value, width);
 		break;
 
 
 	case ACPI_ADR_SPACE_SYSTEM_IO:
 
-		status = acpi_os_write_port ((acpi_io_address) reg->address,
+		status = acpi_os_write_port ((acpi_io_address) address,
 				 value, width);
 		break;
 
@@ -825,7 +843,7 @@
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d   to %8.8X%8.8X (%s)\n",
 			value, width,
-			ACPI_FORMAT_UINT64 (reg->address),
+			ACPI_FORMAT_UINT64 (address),
 			acpi_ut_get_region_name (reg->address_space_id)));
 
 	return (status);
diff -Nru a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
--- a/drivers/acpi/hardware/hwsleep.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/hardware/hwsleep.c	2004-12-24 13:36:18 -08:00
@@ -42,6 +42,8 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
+
 #include <acpi/acpi.h>
 
 #define _COMPONENT          ACPI_HARDWARE
@@ -110,7 +112,7 @@
  * DESCRIPTION: Access function for firmware_waking_vector field in FACS
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_get_firmware_waking_vector (
 	acpi_physical_address *physical_address)
@@ -136,6 +138,7 @@
 
 	return_ACPI_STATUS (AE_OK);
 }
+#endif
 
 
 /******************************************************************************
@@ -391,6 +394,7 @@
 
 	return_ACPI_STATUS (AE_OK);
 }
+EXPORT_SYMBOL(acpi_enter_sleep_state);
 
 
 /******************************************************************************
@@ -456,6 +460,7 @@
 
 	return_ACPI_STATUS (AE_OK);
 }
+EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
 
 
 /******************************************************************************
diff -Nru a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c
--- a/drivers/acpi/hardware/hwtimer.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/hardware/hwtimer.c	2004-12-24 13:36:18 -08:00
@@ -42,6 +42,8 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
+
 #include <acpi/acpi.h>
 
 #define _COMPONENT          ACPI_HARDWARE
@@ -112,6 +114,7 @@
 
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_get_timer);
 
 
 /******************************************************************************
@@ -149,10 +152,9 @@
 	u32                             end_ticks,
 	u32                             *time_elapsed)
 {
-	u32                             delta_ticks = 0;
-	union uint64_overlay            normalized_ticks;
 	acpi_status                     status;
-	acpi_integer                    out_quotient;
+	u32                             delta_ticks;
+	acpi_integer                    quotient;
 
 
 	ACPI_FUNCTION_TRACE ("acpi_get_timer_duration");
@@ -164,7 +166,7 @@
 
 	/*
 	 * Compute Tick Delta:
-	 * Handle (max one) timer rollovers on 24- versus 32-bit timers.
+	 * Handle (max one) timer rollovers on 24-bit versus 32-bit timers.
 	 */
 	if (start_ticks < end_ticks) {
 		delta_ticks = end_ticks - start_ticks;
@@ -181,23 +183,21 @@
 			delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks;
 		}
 	}
-	else {
+	else /* start_ticks == end_ticks */ {
 		*time_elapsed = 0;
 		return_ACPI_STATUS (AE_OK);
 	}
 
 	/*
-	 * Compute Duration (Requires a 64-bit divide):
+	 * Compute Duration (Requires a 64-bit multiply and divide):
 	 *
 	 * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY;
 	 */
-	normalized_ticks.full = ((u64) delta_ticks) * 1000000;
+	status = acpi_ut_short_divide (((u64) delta_ticks) * 1000000,
+			 PM_TIMER_FREQUENCY, &quotient, NULL);
 
-	status = acpi_ut_short_divide (&normalized_ticks.full, PM_TIMER_FREQUENCY,
-			   &out_quotient, NULL);
-
-	*time_elapsed = (u32) out_quotient;
+	*time_elapsed = (u32) quotient;
 	return_ACPI_STATUS (status);
 }
-
+EXPORT_SYMBOL(acpi_get_timer_duration);
 
diff -Nru a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/acpi/ibm_acpi.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1242 @@
+/*
+ *  ibm_acpi.c - IBM ThinkPad ACPI Extras
+ *
+ *
+ *  Copyright (C) 2004 Borislav Deianov
+ *
+ *  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
+ *
+ *  Changelog:
+ *
+ *  2004-08-09	0.1	initial release, support for X series
+ *  2004-08-14	0.2	support for T series, X20
+ *			bluetooth enable/disable
+ *			hotkey events disabled by default
+ *			removed fan control, currently useless
+ *  2004-08-17	0.3	support for R40
+ *			lcd off, brightness control
+ *			thinklight on/off
+ *  2004-09-16	0.4	support for module parameters
+ *			hotkey mask can be prefixed by 0x
+ *			video output switching
+ *			video expansion control
+ *			ultrabay eject support
+ *			removed lcd brightness/on/off control, didn't work
+ *  2004-10-18	0.5	thinklight support on A21e, G40, R32, T20, T21, X20
+ *			proc file format changed
+ *			video_switch command
+ *			experimental cmos control
+ *			experimental led control
+ *			experimental acpi sounds
+ *  2004-10-19	0.6	use acpi_bus_register_driver() to claim HKEY device
+ *  2004-10-23	0.7	fix module loading on A21e, A22p, T20, T21, X20
+ *			fix LED control on A21e
+ *  2004-11-08	0.8	fix init error case, don't return from a macro
+ *				thanks to Chris Wright <chrisw@osdl.org>
+ */
+
+#define IBM_VERSION "0.8"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
+
+#include <acpi/acpi_drivers.h>
+#include <acpi/acnamesp.h>
+
+#define IBM_NAME "ibm"
+#define IBM_DESC "IBM ThinkPad ACPI Extras"
+#define IBM_FILE "ibm_acpi"
+#define IBM_URL "http://ibm-acpi.sf.net/"
+
+#define IBM_DIR IBM_NAME
+
+#define IBM_LOG IBM_FILE ": "
+#define IBM_ERR	   KERN_ERR    IBM_LOG
+#define IBM_NOTICE KERN_NOTICE IBM_LOG
+#define IBM_INFO   KERN_INFO   IBM_LOG
+#define IBM_DEBUG  KERN_DEBUG  IBM_LOG
+
+#define IBM_MAX_ACPI_ARGS 3
+
+#define __unused __attribute__ ((unused))
+
+static int experimental;
+module_param(experimental, int, 0);
+
+static acpi_handle root_handle = NULL;
+
+#define IBM_HANDLE(object, parent, paths...)			\
+	static acpi_handle  object##_handle;			\
+	static acpi_handle *object##_parent = &parent##_handle;	\
+	static char        *object##_paths[] = { paths }
+
+IBM_HANDLE(ec, root,
+	   "\\_SB.PCI0.ISA.EC",    /* A21e, A22p, T20, T21, X20 */
+	   "\\_SB.PCI0.LPC.EC",    /* all others */
+);
+
+IBM_HANDLE(vid, root, 
+	   "\\_SB.PCI0.VID",       /* A21e, G40, X30, X40 */
+	   "\\_SB.PCI0.AGP.VID",   /* all others */
+);
+
+IBM_HANDLE(cmos, root,
+	   "\\UCMS",               /* R50, R50p, R51, T4x, X31, X40 */
+	   "\\CMOS",               /* A3x, G40, R32, T23, T30, X22, X24, X30 */
+	   "\\CMS",                /* R40, R40e */
+);                                 /* A21e, A22p, T20, T21, X20 */
+
+IBM_HANDLE(dock, root,
+	   "\\_SB.GDCK",           /* X30, X31, X40 */
+	   "\\_SB.PCI0.DOCK",      /* A22p, T20, T21, X20 */
+	   "\\_SB.PCI0.PCI1.DOCK", /* all others */
+);                                 /* A21e, G40, R32, R40, R40e */
+
+IBM_HANDLE(bay, root,
+	   "\\_SB.PCI0.IDE0.SCND.MSTR");      /* all except A21e */
+IBM_HANDLE(bayej, root,
+	   "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */
+
+IBM_HANDLE(lght, root, "\\LGHT");  /* A21e, A22p, T20, T21, X20 */
+IBM_HANDLE(hkey, ec,   "HKEY");    /* all */
+IBM_HANDLE(led,  ec,   "LED");     /* all except A21e, A22p, T20, T21, X20 */
+IBM_HANDLE(sysl, ec,   "SYSL");    /* A21e, A22p, T20, T21, X20 */
+IBM_HANDLE(bled, ec,   "BLED");    /* A22p, T20, T21, X20 */
+IBM_HANDLE(beep, ec,   "BEEP");    /* all models */
+
+struct ibm_struct {
+	char *name;
+
+	char *hid;
+	struct acpi_driver *driver;
+	
+	int  (*init)   (struct ibm_struct *);
+	int  (*read)   (struct ibm_struct *, char *);
+	int  (*write)  (struct ibm_struct *, char *);
+	void (*exit)   (struct ibm_struct *);
+
+	void (*notify) (struct ibm_struct *, u32);	
+	acpi_handle *handle;
+	int type;
+	struct acpi_device *device;
+
+	int driver_registered;
+	int proc_created;
+	int init_called;
+	int notify_installed;
+
+	int supported;
+	union {
+		struct {
+			int status;
+			int mask;
+		} hotkey;
+		struct {
+			int autoswitch;
+		} video;
+	} state;
+
+	int experimental;
+};
+
+struct proc_dir_entry *proc_dir = NULL;
+
+#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")
+#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
+#define strlencmp(a,b) (strncmp((a), (b), strlen(b)))
+
+static int acpi_evalf(acpi_handle handle,
+		      void *res, char *method, char *fmt, ...)
+{
+	char *fmt0 = fmt;
+        struct acpi_object_list	params;
+        union acpi_object	in_objs[IBM_MAX_ACPI_ARGS];
+        struct acpi_buffer	result;
+        union acpi_object	out_obj;
+        acpi_status		status;
+	va_list			ap;
+	char			res_type;
+	int			success;
+	int			quiet;
+
+	if (!*fmt) {
+		printk(IBM_ERR "acpi_evalf() called with empty format\n");
+		return 0;
+	}
+
+	if (*fmt == 'q') {
+		quiet = 1;
+		fmt++;
+	} else
+		quiet = 0;
+
+	res_type = *(fmt++);
+
+	params.count = 0;
+	params.pointer = &in_objs[0];
+
+	va_start(ap, fmt);
+	while (*fmt) {
+		char c = *(fmt++);
+		switch (c) {
+		case 'd':	/* int */
+			in_objs[params.count].integer.value = va_arg(ap, int);
+			in_objs[params.count++].type = ACPI_TYPE_INTEGER;
+			break;
+		/* add more types as needed */
+		default:
+			printk(IBM_ERR "acpi_evalf() called "
+			       "with invalid format character '%c'\n", c);
+			return 0;
+		}
+	}
+	va_end(ap);
+
+	result.length = sizeof(out_obj);
+	result.pointer = &out_obj;
+
+	status = acpi_evaluate_object(handle, method, &params, &result);
+
+	switch (res_type) {
+	case 'd':	/* int */
+		if (res)
+			*(int *)res = out_obj.integer.value;
+		success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER;
+		break;
+	case 'v':	/* void */
+		success = status == AE_OK;
+		break;
+	/* add more types as needed */
+	default:
+		printk(IBM_ERR "acpi_evalf() called "
+		       "with invalid format character '%c'\n", res_type);
+		return 0;
+	}
+
+	if (!success && !quiet)
+		printk(IBM_ERR "acpi_evalf(%s, %s, ...) failed: %d\n",
+		       method, fmt0, status);
+
+	return success;
+}
+
+static void __unused acpi_print_int(acpi_handle handle, char *method)
+{
+	int i;
+
+	if (acpi_evalf(handle, &i, method, "d"))
+		printk(IBM_INFO "%s = 0x%x\n", method, i);
+	else
+		printk(IBM_ERR "error calling %s\n", method);
+}
+
+static char *next_cmd(char **cmds)
+{
+	char *start = *cmds;
+	char *end;
+
+	while ((end = strchr(start, ',')) && end == start)
+		start = end + 1;
+
+	if (!end)
+		return NULL;
+
+	*end = 0;
+	*cmds = end + 1;
+	return start;
+}
+
+static int driver_init(struct ibm_struct *ibm)
+{
+	printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION);
+	printk(IBM_INFO "%s\n", IBM_URL);
+
+	return 0;
+}
+
+static int driver_read(struct ibm_struct *ibm, char *p)
+{
+	int len = 0;
+
+	len += sprintf(p + len, "driver:\t\t%s\n", IBM_DESC);
+	len += sprintf(p + len, "version:\t%s\n", IBM_VERSION);
+
+	return len;
+}
+
+static int hotkey_get(struct ibm_struct *ibm, int *status, int *mask)
+{
+	if (!acpi_evalf(hkey_handle, status, "DHKC", "d"))
+		return -EIO;
+	if (ibm->supported) {
+		if (!acpi_evalf(hkey_handle, mask, "DHKN", "qd"))
+			return -EIO;
+	} else {
+		*mask = ibm->state.hotkey.mask;
+	}
+	return 0;
+}
+
+static int hotkey_set(struct ibm_struct *ibm, int status, int mask)
+{
+	int i;
+
+	if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status))
+		return -EIO;
+
+	if (!ibm->supported)
+		return 0;
+
+	for (i=0; i<32; i++) {
+		int bit = ((1 << i) & mask) != 0;
+		if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i+1, bit))
+			return -EIO;
+	}
+
+	return 0;
+}
+
+static int hotkey_init(struct ibm_struct *ibm)
+{
+	int ret;
+
+	ibm->supported = 1;
+	ret = hotkey_get(ibm,
+			 &ibm->state.hotkey.status,
+			 &ibm->state.hotkey.mask);
+	if (ret < 0) {
+		/* mask not supported on A21e, A22p, T20, T21, X20, X22, X24 */
+		ibm->supported = 0;
+		ret = hotkey_get(ibm,
+				 &ibm->state.hotkey.status,
+				 &ibm->state.hotkey.mask);
+	}
+
+	return ret;
+}	
+
+static int hotkey_read(struct ibm_struct *ibm, char *p)
+{
+	int status, mask;
+	int len = 0;
+
+	if (hotkey_get(ibm, &status, &mask) < 0)
+		return -EIO;
+
+	len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
+	if (ibm->supported) {
+		len += sprintf(p + len, "mask:\t\t0x%04x\n", mask);
+		len += sprintf(p + len,
+			       "commands:\tenable, disable, reset, <mask>\n");
+	} else {
+		len += sprintf(p + len, "mask:\t\tnot supported\n");
+		len += sprintf(p + len, "commands:\tenable, disable, reset\n");
+	}
+
+	return len;
+}
+
+static int hotkey_write(struct ibm_struct *ibm, char *buf)
+{
+	int status, mask;
+	char *cmd;
+	int do_cmd = 0;
+
+	if (hotkey_get(ibm, &status, &mask) < 0)
+		return -ENODEV;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (strlencmp(cmd, "enable") == 0) {
+			status = 1;
+		} else if (strlencmp(cmd, "disable") == 0) {
+			status = 0;
+		} else if (strlencmp(cmd, "reset") == 0) {
+			status = ibm->state.hotkey.status;
+			mask   = ibm->state.hotkey.mask;
+		} else if (sscanf(cmd, "0x%x", &mask) == 1) {
+			/* mask set */
+		} else if (sscanf(cmd, "%x", &mask) == 1) {
+			/* mask set */
+		} else
+			return -EINVAL;
+		do_cmd = 1;
+	}
+
+	if (do_cmd && hotkey_set(ibm, status, mask) < 0)
+		return -EIO;
+
+	return 0;
+}	
+
+static void hotkey_exit(struct ibm_struct *ibm)
+{
+	hotkey_set(ibm, ibm->state.hotkey.status, ibm->state.hotkey.mask);
+}
+
+static void hotkey_notify(struct ibm_struct *ibm, u32 event)
+{
+	int hkey;
+
+	if (acpi_evalf(hkey_handle, &hkey, "MHKP", "d"))
+		acpi_bus_generate_event(ibm->device, event, hkey);
+	else {
+		printk(IBM_ERR "unknown hotkey event %d\n", event);
+		acpi_bus_generate_event(ibm->device, event, 0);
+	}	
+}
+
+static int bluetooth_init(struct ibm_struct *ibm)
+{
+	/* bluetooth not supported on A21e, G40, T20, T21, X20 */
+	ibm->supported = acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
+
+	return 0;
+}
+
+static int bluetooth_status(struct ibm_struct *ibm)
+{
+	int status;
+
+	if (!ibm->supported || !acpi_evalf(hkey_handle, &status, "GBDC", "d"))
+		status = 0;
+
+	return status;
+}
+
+static int bluetooth_read(struct ibm_struct *ibm, char *p)
+{
+	int len = 0;
+	int status = bluetooth_status(ibm);
+
+	if (!ibm->supported)
+		len += sprintf(p + len, "status:\t\tnot supported\n");
+	else if (!(status & 1))
+		len += sprintf(p + len, "status:\t\tnot installed\n");
+	else {
+		len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 1));
+		len += sprintf(p + len, "commands:\tenable, disable\n");
+	}
+
+	return len;
+}
+
+static int bluetooth_write(struct ibm_struct *ibm, char *buf)
+{
+	int status = bluetooth_status(ibm);
+	char *cmd;
+	int do_cmd = 0;
+
+	if (!ibm->supported)
+		return -EINVAL;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (strlencmp(cmd, "enable") == 0) {
+			status |= 2;
+		} else if (strlencmp(cmd, "disable") == 0) {
+			status &= ~2;
+		} else
+			return -EINVAL;
+		do_cmd = 1;
+	}
+
+	if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
+	    return -EIO;
+
+	return 0;
+}
+
+static int video_init(struct ibm_struct *ibm)
+{
+	if (!acpi_evalf(vid_handle,
+			&ibm->state.video.autoswitch, "^VDEE", "d"))
+		return -ENODEV;
+
+	return 0;
+}
+
+static int video_status(struct ibm_struct *ibm)
+{
+	int status = 0;
+	int i;
+
+	acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1);
+	if (acpi_evalf(NULL, &i, "\\VCDC", "d"))
+		status |= 0x02 * i;
+
+	acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0);
+	if (acpi_evalf(NULL, &i, "\\VCDL", "d"))
+		status |= 0x01 * i;
+	if (acpi_evalf(NULL, &i, "\\VCDD", "d"))
+		status |= 0x08 * i;
+
+	if (acpi_evalf(vid_handle, &i, "^VDEE", "d"))
+		status |= 0x10 * (i & 1);
+
+	return status;
+}
+
+static int video_read(struct ibm_struct *ibm, char *p)
+{
+	int status = video_status(ibm);
+	int len = 0;
+
+	len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0));
+	len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1));
+	len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3));
+	len += sprintf(p + len, "auto:\t\t%s\n", enabled(status, 4));
+	len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable, "
+		       "crt_enable, crt_disable\n");
+	len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable, "
+		       "auto_enable, auto_disable\n");
+	len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n");
+
+	return len;
+}
+
+static int video_write(struct ibm_struct *ibm, char *buf)
+{
+	char *cmd;
+	int enable, disable, status;
+
+	enable = disable = 0;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (strlencmp(cmd, "lcd_enable") == 0) {
+			enable |= 0x01;
+		} else if (strlencmp(cmd, "lcd_disable") == 0) {
+			disable |= 0x01;
+		} else if (strlencmp(cmd, "crt_enable") == 0) {
+			enable |= 0x02;
+		} else if (strlencmp(cmd, "crt_disable") == 0) {
+			disable |= 0x02;
+		} else if (strlencmp(cmd, "dvi_enable") == 0) {
+			enable |= 0x08;
+		} else if (strlencmp(cmd, "dvi_disable") == 0) {
+			disable |= 0x08;
+		} else if (strlencmp(cmd, "auto_enable") == 0) {
+			if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
+				return -EIO;
+		} else if (strlencmp(cmd, "auto_disable") == 0) {
+			if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 0))
+				return -EIO;
+		} else if (strlencmp(cmd, "video_switch") == 0) {
+			int autoswitch;
+			if (!acpi_evalf(vid_handle, &autoswitch, "^VDEE", "d"))
+				return -EIO;
+			if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
+				return -EIO;
+			if (!acpi_evalf(vid_handle, NULL, "VSWT", "v"))
+				return -EIO;
+			if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd",
+					autoswitch))
+				return -EIO;
+		} else if (strlencmp(cmd, "expand_toggle") == 0) {
+			if (!acpi_evalf(NULL, NULL, "\\VEXP", "v"))
+				return -EIO;
+		} else
+			return -EINVAL;
+	}
+
+	if (enable || disable) {
+		status = (video_status(ibm) & 0x0f & ~disable) | enable;
+		if (!acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0x80))
+			return -EIO;
+		if (!acpi_evalf(NULL, NULL, "\\VSDS", "vdd", status, 1))
+			return -EIO;
+	}
+
+	return 0;
+}
+
+static void video_exit(struct ibm_struct *ibm)
+{
+	acpi_evalf(vid_handle, NULL, "_DOS", "vd",
+		   ibm->state.video.autoswitch);
+}
+
+static int light_init(struct ibm_struct *ibm)
+{
+	/* kblt not supported on G40, R32, X20 */
+	ibm->supported = acpi_evalf(ec_handle, NULL, "KBLT", "qv");
+
+	return 0;
+}
+
+static int light_read(struct ibm_struct *ibm, char *p)
+{
+	int len = 0;
+	int status = 0;
+
+	if (ibm->supported) {
+		if (!acpi_evalf(ec_handle, &status, "KBLT", "d"))
+			return -EIO;
+		len += sprintf(p + len, "status:\t\t%s\n", onoff(status, 0));
+	} else
+		len += sprintf(p + len, "status:\t\tunknown\n");
+
+	len += sprintf(p + len, "commands:\ton, off\n");
+
+	return len;
+}
+
+static int light_write(struct ibm_struct *ibm, char *buf)
+{
+	int cmos_cmd, lght_cmd;
+	char *cmd;
+	int success;
+	
+	while ((cmd = next_cmd(&buf))) {
+		if (strlencmp(cmd, "on") == 0) {
+			cmos_cmd = 0x0c;
+			lght_cmd = 1;
+		} else if (strlencmp(cmd, "off") == 0) {
+			cmos_cmd = 0x0d;
+			lght_cmd = 0;
+		} else
+			return -EINVAL;
+		
+		success = cmos_handle ?
+			acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) :
+			acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd);
+		if (!success)
+			return -EIO;
+	}
+
+	return 0;
+}
+
+static int _sta(acpi_handle handle)
+{
+	int status;
+
+	if (!handle || !acpi_evalf(handle, &status, "_STA", "d"))
+		status = 0;
+
+	return status;
+}
+
+#define dock_docked() (_sta(dock_handle) & 1)
+
+static int dock_read(struct ibm_struct *ibm, char *p)
+{
+	int len = 0;
+	int docked = dock_docked();
+
+	if (!dock_handle)
+		len += sprintf(p + len, "status:\t\tnot supported\n");
+	else if (!docked)
+		len += sprintf(p + len, "status:\t\tundocked\n");
+	else {
+		len += sprintf(p + len, "status:\t\tdocked\n");
+		len += sprintf(p + len, "commands:\tdock, undock\n");
+	}
+
+	return len;
+}
+
+static int dock_write(struct ibm_struct *ibm, char *buf)
+{
+	char *cmd;
+
+	if (!dock_docked())
+		return -EINVAL;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (strlencmp(cmd, "undock") == 0) {
+			if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 0))
+				return -EIO;
+			if (!acpi_evalf(dock_handle, NULL, "_EJ0", "vd", 1))
+				return -EIO;
+		} else if (strlencmp(cmd, "dock") == 0) {
+			if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 1))
+				return -EIO;
+		} else
+			return -EINVAL;
+	}
+
+	return 0;
+}	
+
+static void dock_notify(struct ibm_struct *ibm, u32 event)
+{
+	int docked = dock_docked();
+
+	if (event == 3 && docked)
+		acpi_bus_generate_event(ibm->device, event, 1); /* button */
+	else if (event == 3 && !docked)
+		acpi_bus_generate_event(ibm->device, event, 2); /* undock */
+	else if (event == 0 && docked)
+		acpi_bus_generate_event(ibm->device, event, 3); /* dock */
+	else {
+		printk(IBM_ERR "unknown dock event %d, status %d\n",
+		       event, _sta(dock_handle));
+		acpi_bus_generate_event(ibm->device, event, 0); /* unknown */
+	}
+}
+
+#define bay_occupied() (_sta(bay_handle) & 1)
+
+static int bay_init(struct ibm_struct *ibm)
+{
+	/* bay not supported on A21e, A22p, A31, A31p, G40, R32, R40e */
+	ibm->supported = bay_handle && bayej_handle &&
+		acpi_evalf(bay_handle, NULL, "_STA", "qv");
+
+	return 0;
+}
+
+static int bay_read(struct ibm_struct *ibm, char *p)
+{
+	int len = 0;
+	int occupied = bay_occupied();
+	
+	if (!ibm->supported)
+		len += sprintf(p + len, "status:\t\tnot supported\n");
+	else if (!occupied)
+		len += sprintf(p + len, "status:\t\tunoccupied\n");
+	else {
+		len += sprintf(p + len, "status:\t\toccupied\n");
+		len += sprintf(p + len, "commands:\teject\n");
+	}
+
+	return len;
+}
+
+static int bay_write(struct ibm_struct *ibm, char *buf)
+{
+	char *cmd;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (strlencmp(cmd, "eject") == 0) {
+			if (!ibm->supported ||
+			    !acpi_evalf(bay_handle, NULL, "_EJ0", "vd", 1))
+				return -EIO;
+		} else
+			return -EINVAL;
+	}
+
+	return 0;
+}	
+
+static void bay_notify(struct ibm_struct *ibm, u32 event)
+{
+	acpi_bus_generate_event(ibm->device, event, 0);
+}
+
+static int cmos_read(struct ibm_struct *ibm, char *p)
+{
+	int len = 0;
+
+	/* cmos not supported on A21e, A22p, T20, T21, X20 */
+	if (!cmos_handle)
+		len += sprintf(p + len, "status:\t\tnot supported\n");
+	else {
+		len += sprintf(p + len, "status:\t\tsupported\n");
+		len += sprintf(p + len, "commands:\t<int>\n");
+	}
+
+	return len;
+}
+
+static int cmos_write(struct ibm_struct *ibm, char *buf)
+{
+	char *cmd;
+	int cmos_cmd;
+
+	if (!cmos_handle)
+		return -EINVAL;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (sscanf(cmd, "%u", &cmos_cmd) == 1) {
+			/* cmos_cmd set */
+		} else
+			return -EINVAL;
+
+		if (!acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd))
+			return -EIO;
+	}
+
+	return 0;
+}	
+		
+static int led_read(struct ibm_struct *ibm, char *p)
+{
+	int len = 0;
+
+	len += sprintf(p + len, "commands:\t"
+		       "<int> on, <int> off, <int> blink\n");
+
+	return len;
+}
+
+static int led_write(struct ibm_struct *ibm, char *buf)
+{
+	char *cmd;
+	unsigned int led;
+	int led_cmd, sysl_cmd, bled_a, bled_b;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (sscanf(cmd, "%u", &led) != 1)
+			return -EINVAL;
+
+		if (strstr(cmd, "blink")) {
+			led_cmd = 0xc0;
+			sysl_cmd = 2;
+			bled_a = 2;
+			bled_b = 1;
+		} else if (strstr(cmd, "on")) {
+			led_cmd = 0x80;
+			sysl_cmd = 1;
+			bled_a = 2;
+			bled_b = 0;
+		} else if (strstr(cmd, "off")) {
+			led_cmd = sysl_cmd = bled_a = bled_b = 0;
+		} else
+			return -EINVAL;
+		
+		if (led_handle) {
+			if (!acpi_evalf(led_handle, NULL, NULL, "vdd",
+					led, led_cmd))
+				return -EIO;
+		} else if (led < 2) {
+			if (acpi_evalf(sysl_handle, NULL, NULL, "vdd",
+				       led, sysl_cmd))
+				return -EIO;
+		} else if (led == 2 && bled_handle) {
+			if (acpi_evalf(bled_handle, NULL, NULL, "vdd",
+				       bled_a, bled_b))
+				return -EIO;
+		} else
+			return -EINVAL;
+	}
+
+	return 0;
+}	
+		
+static int beep_read(struct ibm_struct *ibm, char *p)
+{
+	int len = 0;
+
+	len += sprintf(p + len, "commands:\t<int>\n");
+
+	return len;
+}
+
+static int beep_write(struct ibm_struct *ibm, char *buf)
+{
+	char *cmd;
+	int beep_cmd;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (sscanf(cmd, "%u", &beep_cmd) == 1) {
+			/* beep_cmd set */
+		} else
+			return -EINVAL;
+
+		if (!acpi_evalf(beep_handle, NULL, NULL, "vd", beep_cmd))
+			return -EIO;
+	}
+
+	return 0;
+}	
+		
+struct ibm_struct ibms[] = {
+	{
+		.name	= "driver",
+		.init	= driver_init,
+		.read	= driver_read,
+	},
+	{
+		.name	= "hotkey",
+		.hid	= "IBM0068",
+		.init	= hotkey_init,
+		.read	= hotkey_read,
+		.write	= hotkey_write,
+		.exit	= hotkey_exit,
+		.notify	= hotkey_notify,
+		.handle	= &hkey_handle,
+		.type	= ACPI_DEVICE_NOTIFY,
+	},
+	{
+		.name	= "bluetooth",
+		.init	= bluetooth_init,
+		.read	= bluetooth_read,
+		.write	= bluetooth_write,
+	},
+	{
+		.name	= "video",
+		.init	= video_init,
+		.read	= video_read,
+		.write	= video_write,
+		.exit	= video_exit,
+	},
+	{
+		.name	= "light",
+		.init	= light_init,
+		.read	= light_read,
+		.write	= light_write,
+	},
+	{
+		.name	= "dock",
+		.read	= dock_read,
+		.write	= dock_write,
+		.notify	= dock_notify,
+		.handle	= &dock_handle,
+		.type	= ACPI_SYSTEM_NOTIFY,
+	},
+	{
+		.name	= "bay",
+		.init	= bay_init,
+		.read	= bay_read,
+		.write	= bay_write,
+		.notify	= bay_notify,
+		.handle	= &bay_handle,
+		.type	= ACPI_SYSTEM_NOTIFY,
+	},
+	{
+		.name	= "cmos",
+		.read	= cmos_read,
+		.write	= cmos_write,
+		.experimental = 1,
+	},
+	{
+		.name	= "led",
+		.read	= led_read,
+		.write	= led_write,
+		.experimental = 1,
+	},
+	{
+		.name	= "beep",
+		.read	= beep_read,
+		.write	= beep_write,
+		.experimental = 1,
+	},
+};
+#define NUM_IBMS (sizeof(ibms)/sizeof(ibms[0]))
+
+static int dispatch_read(char *page, char **start, off_t off, int count,
+			 int *eof, void *data)
+{
+	struct ibm_struct *ibm = (struct ibm_struct *)data;
+	int len;
+	
+	if (!ibm || !ibm->read)
+		return -EINVAL;
+
+	len = ibm->read(ibm, page);
+	if (len < 0)
+		return len;
+
+	if (len <= off + count)
+		*eof = 1;
+	*start = page + off;
+	len -= off;
+	if (len > count)
+		len = count;
+	if (len < 0)
+		len = 0;
+
+	return len;
+}
+
+static int dispatch_write(struct file *file, const char __user *userbuf,
+			  unsigned long count, void *data)
+{
+	struct ibm_struct *ibm = (struct ibm_struct *)data;
+	char *kernbuf;
+	int ret;
+
+	if (!ibm || !ibm->write)
+		return -EINVAL;
+
+	kernbuf = kmalloc(count + 2, GFP_KERNEL);
+	if (!kernbuf)
+		return -ENOMEM;
+
+        if (copy_from_user(kernbuf, userbuf, count)) {
+		kfree(kernbuf);
+                return -EFAULT;
+	}
+
+	kernbuf[count] = 0;
+	strcat(kernbuf, ",");
+	ret = ibm->write(ibm, kernbuf);
+	if (ret == 0)
+		ret = count;
+
+	kfree(kernbuf);
+
+        return ret;
+}
+
+static void dispatch_notify(acpi_handle handle, u32 event, void *data)
+{
+	struct ibm_struct *ibm = (struct ibm_struct *)data;
+
+	if (!ibm || !ibm->notify)
+		return;
+
+	ibm->notify(ibm, event);
+}
+
+static int setup_notify(struct ibm_struct *ibm)
+{
+	acpi_status status;
+	int ret;
+
+	if (!*ibm->handle)
+		return 0;
+
+	ret = acpi_bus_get_device(*ibm->handle, &ibm->device);
+	if (ret < 0) {
+		printk(IBM_ERR "%s device not present\n", ibm->name);
+		return 0;
+	}
+
+	acpi_driver_data(ibm->device) = ibm;
+	sprintf(acpi_device_class(ibm->device), "%s/%s", IBM_NAME, ibm->name);
+
+	status = acpi_install_notify_handler(*ibm->handle, ibm->type,
+					     dispatch_notify, ibm);
+	if (ACPI_FAILURE(status)) {
+		printk(IBM_ERR "acpi_install_notify_handler(%s) failed: %d\n",
+		       ibm->name, status);
+		return -ENODEV;
+	}
+
+	ibm->notify_installed = 1;
+
+	return 0;
+}
+
+static int device_add(struct acpi_device *device)
+{
+	return 0;
+}
+
+static int register_driver(struct ibm_struct *ibm)
+{
+	int ret;
+
+	ibm->driver = kmalloc(sizeof(struct acpi_driver), GFP_KERNEL);
+	if (!ibm->driver) {
+		printk(IBM_ERR "kmalloc(ibm->driver) failed\n");
+		return -1;
+	}
+
+	memset(ibm->driver, 0, sizeof(struct acpi_driver));
+	sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name);
+	ibm->driver->ids = ibm->hid;
+	ibm->driver->ops.add = &device_add;
+
+	ret = acpi_bus_register_driver(ibm->driver);
+	if (ret < 0) {
+		printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
+		       ibm->hid, ret);
+		kfree(ibm->driver);
+	}
+
+	return ret;
+}
+
+static int ibm_init(struct ibm_struct *ibm)
+{
+	int ret;
+	struct proc_dir_entry *entry;
+
+	if (ibm->experimental && !experimental)
+		return 0;
+
+	if (ibm->hid) {
+		ret = register_driver(ibm);
+		if (ret < 0)
+			return ret;
+		ibm->driver_registered = 1;
+	}
+
+	if (ibm->init) {
+		ret = ibm->init(ibm);
+		if (ret != 0)
+			return ret;
+		ibm->init_called = 1;
+	}
+
+	entry = create_proc_entry(ibm->name, S_IFREG | S_IRUGO | S_IWUSR,
+				  proc_dir);
+	if (!entry) {
+		printk(IBM_ERR "unable to create proc entry %s\n", ibm->name);
+		return -ENODEV;
+	}
+	entry->owner = THIS_MODULE;
+	ibm->proc_created = 1;
+	
+	entry->data = ibm;
+	if (ibm->read)
+		entry->read_proc = &dispatch_read;
+	if (ibm->write)
+		entry->write_proc = &dispatch_write;
+
+	if (ibm->notify) {
+		ret = setup_notify(ibm);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
+
+static void ibm_exit(struct ibm_struct *ibm)
+{
+	if (ibm->notify_installed)
+		acpi_remove_notify_handler(*ibm->handle, ibm->type,
+					   dispatch_notify);
+
+	if (ibm->proc_created)
+		remove_proc_entry(ibm->name, proc_dir);
+
+	if (ibm->init_called && ibm->exit)
+		ibm->exit(ibm);
+
+	if (ibm->driver_registered) {
+		acpi_bus_unregister_driver(ibm->driver);
+		kfree(ibm->driver);
+	}
+}
+
+static int ibm_handle_init(char *name,
+			   acpi_handle *handle, acpi_handle parent,
+			   char **paths, int num_paths, int required)
+{
+	int i;
+	acpi_status status;
+
+	for (i=0; i<num_paths; i++) {
+		status = acpi_get_handle(parent, paths[i], handle);
+		if (ACPI_SUCCESS(status))
+			return 0;
+	}
+	
+	*handle = NULL;
+
+	if (required) {
+		printk(IBM_ERR "%s object not found\n", name);
+		return -1;
+	}
+
+	return 0;
+}
+
+#define IBM_HANDLE_INIT(object, required)				\
+	ibm_handle_init(#object, &object##_handle, *object##_parent,	\
+		object##_paths, sizeof(object##_paths)/sizeof(char*), required)
+
+
+static int set_ibm_param(const char *val, struct kernel_param *kp)
+{
+	unsigned int i;
+	char arg_with_comma[32];
+
+	if (strlen(val) > 30)
+		return -ENOSPC;
+
+	strcpy(arg_with_comma, val);
+	strcat(arg_with_comma, ",");
+
+	for (i=0; i<NUM_IBMS; i++)
+		if (strcmp(ibms[i].name, kp->name) == 0)
+			return ibms[i].write(&ibms[i], arg_with_comma);
+	BUG();
+	return -EINVAL;
+}
+
+#define IBM_PARAM(feature) \
+	module_param_call(feature, set_ibm_param, NULL, NULL, 0)
+
+static void __exit acpi_ibm_exit(void)
+{
+	int i;
+
+	for (i=NUM_IBMS-1; i>=0; i--)
+		ibm_exit(&ibms[i]);
+
+	remove_proc_entry(IBM_DIR, acpi_root_dir);
+}
+
+static int __init acpi_ibm_init(void)
+{
+	int ret, i;
+
+	if (acpi_disabled)
+		return -ENODEV;
+
+	/* these handles are required */
+	if (IBM_HANDLE_INIT(ec,	  1) < 0 ||
+	    IBM_HANDLE_INIT(hkey, 1) < 0 ||
+	    IBM_HANDLE_INIT(vid,  1) < 0 ||
+	    IBM_HANDLE_INIT(beep, 1) < 0)
+		return -ENODEV;
+
+	/* these handles have alternatives */
+	IBM_HANDLE_INIT(lght, 0);
+	if (IBM_HANDLE_INIT(cmos, !lght_handle) < 0)
+		return -ENODEV;
+	IBM_HANDLE_INIT(sysl, 0);
+	if (IBM_HANDLE_INIT(led, !sysl_handle) < 0)
+		return -ENODEV;
+
+	/* these handles are not required */
+	IBM_HANDLE_INIT(dock,  0);
+	IBM_HANDLE_INIT(bay,   0);
+	IBM_HANDLE_INIT(bayej, 0);
+	IBM_HANDLE_INIT(bled,  0);
+
+	proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
+	if (!proc_dir) {
+		printk(IBM_ERR "unable to create proc dir %s", IBM_DIR);
+		return -ENODEV;
+	}
+	proc_dir->owner = THIS_MODULE;
+	
+	for (i=0; i<NUM_IBMS; i++) {
+		ret = ibm_init(&ibms[i]);
+		if (ret < 0) {
+			acpi_ibm_exit();
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+module_init(acpi_ibm_init);
+module_exit(acpi_ibm_exit);
+
+MODULE_AUTHOR("Borislav Deianov");
+MODULE_DESCRIPTION(IBM_DESC);
+MODULE_LICENSE("GPL");
+
+IBM_PARAM(hotkey);
+IBM_PARAM(bluetooth);
+IBM_PARAM(video);
+IBM_PARAM(light);
+IBM_PARAM(dock);
+IBM_PARAM(bay);
+IBM_PARAM(cmos);
+IBM_PARAM(led);
+IBM_PARAM(beep);
diff -Nru a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
--- a/drivers/acpi/motherboard.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/acpi/motherboard.c	2004-12-24 13:37:02 -08:00
@@ -62,7 +62,7 @@
 		struct acpi_resource_io *io_res = &res->data.io;
 
 		if (io_res->min_base_address != io_res->max_base_address)
-			return AE_OK;
+			return_VALUE(AE_OK);
 		if (IS_RESERVED_ADDR(io_res->min_base_address, io_res->range_length)) {
 			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n",
 				io_res->min_base_address, 
@@ -86,7 +86,7 @@
 
 	if (requested_res)
 		requested_res->flags &= ~IORESOURCE_BUSY;
-	return AE_OK;
+	return_VALUE(AE_OK);
 }
 
 static int acpi_motherboard_add (struct acpi_device *device)
diff -Nru a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile
--- a/drivers/acpi/namespace/Makefile	2004-12-24 13:37:02 -08:00
+++ b/drivers/acpi/namespace/Makefile	2004-12-24 13:37:02 -08:00
@@ -2,9 +2,11 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-obj-y := nsaccess.o  nsdumpdv.o  nsload.o    nssearch.o  nsxfeval.o \
+obj-y := nsaccess.o  nsload.o    nssearch.o  nsxfeval.o \
 	 nsalloc.o   nseval.o    nsnames.o   nsutils.o   nsxfname.o \
 	 nsdump.o    nsinit.o    nsobject.o  nswalk.o    nsxfobj.o  \
 	 nsparse.o
+
+obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
--- a/drivers/acpi/namespace/nsaccess.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/acpi/namespace/nsaccess.c	2004-12-24 13:37:29 -08:00
@@ -161,8 +161,10 @@
 
 #if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_App)
 
-				/* i_aSL Compiler cheats by putting parameter count in the owner_iD */
-
+				/*
+				 * i_aSL Compiler cheats by putting parameter count
+				 * in the owner_iD
+				 */
 				new_node->owner_id = obj_desc->method.param_count;
 #else
 				/* Mark this as a very SPECIAL method */
@@ -204,6 +206,7 @@
 					status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT,
 							 1, &obj_desc->mutex.semaphore);
 					if (ACPI_FAILURE (status)) {
+						acpi_ut_remove_reference (obj_desc);
 						goto unlock_and_exit;
 					}
 
@@ -219,6 +222,7 @@
 					status = acpi_os_create_semaphore (1, 1,
 							   &obj_desc->mutex.semaphore);
 					if (ACPI_FAILURE (status)) {
+						acpi_ut_remove_reference (obj_desc);
 						goto unlock_and_exit;
 					}
 				}
@@ -236,7 +240,8 @@
 
 			/* Store pointer to value descriptor in the Node */
 
-			status = acpi_ns_attach_object (new_node, obj_desc, ACPI_GET_OBJECT_TYPE (obj_desc));
+			status = acpi_ns_attach_object (new_node, obj_desc,
+					 ACPI_GET_OBJECT_TYPE (obj_desc));
 
 			/* Remove local reference to the object */
 
@@ -462,7 +467,8 @@
 			type = this_node->type;
 
 			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-				"Prefix-only Pathname (Zero name segments), Flags=%X\n", flags));
+				"Prefix-only Pathname (Zero name segments), Flags=%X\n",
+				flags));
 			break;
 
 		case AML_DUAL_NAME_PREFIX:
@@ -554,7 +560,7 @@
 		/* Try to find the single (4 character) ACPI name */
 
 		status = acpi_ns_search_and_enter (simple_name, walk_state, current_node,
-				  interpreter_mode, this_search_type, local_flags, &this_node);
+				 interpreter_mode, this_search_type, local_flags, &this_node);
 		if (ACPI_FAILURE (status)) {
 			if (status == AE_NOT_FOUND) {
 				/* Name not found in ACPI namespace */
diff -Nru a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
--- a/drivers/acpi/namespace/nsalloc.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/acpi/namespace/nsalloc.c	2004-12-24 13:36:55 -08:00
@@ -502,8 +502,8 @@
 				 * visit the node
 				 */
 				level++;
-				parent_node   = child_node;
-				child_node    = NULL;
+				parent_node = child_node;
+				child_node = NULL;
 			}
 		}
 		else {
@@ -650,8 +650,8 @@
 				 * visit the node
 				 */
 				level++;
-				parent_node   = child_node;
-				child_node    = NULL;
+				parent_node = child_node;
+				child_node = NULL;
 			}
 			else if (child_node->owner_id == owner_id) {
 				deletion_node = child_node;
diff -Nru a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
--- a/drivers/acpi/namespace/nsdump.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/acpi/namespace/nsdump.c	2004-12-24 13:37:19 -08:00
@@ -198,7 +198,8 @@
 	}
 
 	if (!acpi_ut_valid_acpi_name (this_node->name.integer)) {
-		ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", this_node->name.integer));
+		ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
+			this_node->name.integer));
 	}
 
 	/*
@@ -226,9 +227,8 @@
 		case ACPI_TYPE_PROCESSOR:
 
 			acpi_os_printf ("ID %X Len %.4X Addr %p\n",
-					 obj_desc->processor.proc_id,
-					 obj_desc->processor.length,
-					 (char *) obj_desc->processor.address);
+				obj_desc->processor.proc_id, obj_desc->processor.length,
+				(char *) obj_desc->processor.address);
 			break;
 
 
@@ -241,16 +241,15 @@
 		case ACPI_TYPE_METHOD:
 
 			acpi_os_printf ("Args %X Len %.4X Aml %p\n",
-					 (u32) obj_desc->method.param_count,
-					 obj_desc->method.aml_length,
-					 obj_desc->method.aml_start);
+				(u32) obj_desc->method.param_count,
+				obj_desc->method.aml_length, obj_desc->method.aml_start);
 			break;
 
 
 		case ACPI_TYPE_INTEGER:
 
 			acpi_os_printf ("= %8.8X%8.8X\n",
-					 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
+				ACPI_FORMAT_UINT64 (obj_desc->integer.value));
 			break;
 
 
@@ -258,7 +257,7 @@
 
 			if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
 				acpi_os_printf ("Elements %.2X\n",
-						 obj_desc->package.count);
+					obj_desc->package.count);
 			}
 			else {
 				acpi_os_printf ("[Length not yet evaluated]\n");
@@ -298,11 +297,12 @@
 
 		case ACPI_TYPE_REGION:
 
-			acpi_os_printf ("[%s]", acpi_ut_get_region_name (obj_desc->region.space_id));
+			acpi_os_printf ("[%s]",
+				acpi_ut_get_region_name (obj_desc->region.space_id));
 			if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
 				acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n",
-						 ACPI_FORMAT_UINT64 (obj_desc->region.address),
-						 obj_desc->region.length);
+					ACPI_FORMAT_UINT64 (obj_desc->region.address),
+					obj_desc->region.length);
 			}
 			else {
 				acpi_os_printf (" [Address/Length not yet evaluated]\n");
@@ -313,7 +313,7 @@
 		case ACPI_TYPE_LOCAL_REFERENCE:
 
 			acpi_os_printf ("[%s]\n",
-					acpi_ps_get_opcode_name (obj_desc->reference.opcode));
+				acpi_ps_get_opcode_name (obj_desc->reference.opcode));
 			break;
 
 
@@ -322,7 +322,7 @@
 			if (obj_desc->buffer_field.buffer_obj &&
 				obj_desc->buffer_field.buffer_obj->buffer.node) {
 				acpi_os_printf ("Buf [%4.4s]",
-						acpi_ut_get_node_name (obj_desc->buffer_field.buffer_obj->buffer.node));
+					acpi_ut_get_node_name (obj_desc->buffer_field.buffer_obj->buffer.node));
 			}
 			break;
 
@@ -330,30 +330,31 @@
 		case ACPI_TYPE_LOCAL_REGION_FIELD:
 
 			acpi_os_printf ("Rgn [%4.4s]",
-					acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node));
+				acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node));
 			break;
 
 
 		case ACPI_TYPE_LOCAL_BANK_FIELD:
 
 			acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]",
-					acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node),
-					acpi_ut_get_node_name (obj_desc->bank_field.bank_obj->common_field.node));
+				acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node),
+				acpi_ut_get_node_name (obj_desc->bank_field.bank_obj->common_field.node));
 			break;
 
 
 		case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
 			acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]",
-					acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node),
-					acpi_ut_get_node_name (obj_desc->index_field.data_obj->common_field.node));
+				acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node),
+				acpi_ut_get_node_name (obj_desc->index_field.data_obj->common_field.node));
 			break;
 
 
 		case ACPI_TYPE_LOCAL_ALIAS:
 		case ACPI_TYPE_LOCAL_METHOD_ALIAS:
 
-			acpi_os_printf ("Target %4.4s (%p)\n", acpi_ut_get_node_name (obj_desc), obj_desc);
+			acpi_os_printf ("Target %4.4s (%p)\n",
+				acpi_ut_get_node_name (obj_desc), obj_desc);
 			break;
 
 		default:
@@ -371,10 +372,10 @@
 		case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
 			acpi_os_printf (" Off %.3X Len %.2X Acc %.2hd\n",
-					(obj_desc->common_field.base_byte_offset * 8)
-						+ obj_desc->common_field.start_field_bit_offset,
-					obj_desc->common_field.bit_length,
-					obj_desc->common_field.access_byte_width);
+				(obj_desc->common_field.base_byte_offset * 8)
+					+ obj_desc->common_field.start_field_bit_offset,
+				obj_desc->common_field.bit_length,
+				obj_desc->common_field.access_byte_width);
 			break;
 
 		default:
@@ -471,12 +472,13 @@
 			obj_type = ACPI_GET_OBJECT_TYPE (obj_desc);
 
 			if (obj_type > ACPI_TYPE_LOCAL_MAX) {
-				acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", obj_type);
+				acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n",
+					obj_type);
 				bytes_to_dump = 32;
 			}
 			else {
 				acpi_os_printf ("(Ptr to ACPI Object type %s, %X)\n",
-						   acpi_ut_get_type_name (obj_type), obj_type);
+					acpi_ut_get_type_name (obj_type), obj_type);
 				bytes_to_dump = sizeof (union acpi_operand_object);
 			}
 			break;
@@ -484,8 +486,9 @@
 
 		default:
 
-			acpi_os_printf ("(String or Buffer ptr - not an object descriptor) [%s]\n",
-					acpi_ut_get_descriptor_name (obj_desc));
+			acpi_os_printf (
+				"(String or Buffer ptr - not an object descriptor) [%s]\n",
+				acpi_ut_get_descriptor_name (obj_desc));
 			bytes_to_dump = 16;
 			break;
 		}
@@ -547,12 +550,14 @@
 }
 
 
+#ifdef ACPI_FUTURE_USAGE
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ns_dump_objects
  *
  * PARAMETERS:  Type                - Object type to be dumped
- *              max_depth           - Maximum depth of dump.  Use ACPI_UINT32_MAX
+ *              max_depth           - Maximum depth of dump. Use ACPI_UINT32_MAX
  *                                    for an effectively unlimited depth.
  *              owner_id            - Dump only objects owned by this ID.  Use
  *                                    ACPI_UINT32_MAX to match all owners.
@@ -631,6 +636,8 @@
 			ACPI_UINT32_MAX, search_handle);
 	return_VOID;
 }
+
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
diff -Nru a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
--- a/drivers/acpi/namespace/nsdumpdv.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/acpi/namespace/nsdumpdv.c	2004-12-24 13:36:16 -08:00
@@ -91,10 +91,10 @@
 			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
 		}
 
-		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "    HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
-				  info->hardware_id.value,
-				  ACPI_FORMAT_UINT64 (info->address),
-				  info->current_status));
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES,
+			"    HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
+			info->hardware_id.value, ACPI_FORMAT_UINT64 (info->address),
+			info->current_status));
 		ACPI_MEM_FREE (info);
 	}
 
@@ -133,7 +133,8 @@
 		return;
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n"));
+	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
+		"Display of all devices in the namespace:\n"));
 
 	status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, sys_bus_handle,
 			 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
diff -Nru a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
--- a/drivers/acpi/namespace/nseval.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/acpi/namespace/nseval.c	2004-12-24 13:36:48 -08:00
@@ -57,14 +57,9 @@
  *
  * FUNCTION:    acpi_ns_evaluate_relative
  *
- * PARAMETERS:  Handle              - The relative containing object
- *              Pathname            - Name of method to execute, If NULL, the
+ * PARAMETERS:  Pathname            - Name of method to execute, If NULL, the
  *                                    handle is the object to execute
- *              Params              - List of parameters to pass to the method,
- *                                    terminated by NULL.  Params itself may be
- *                                    NULL if no parameters are being passed.
- *              return_object       - Where to put method's return value (if
- *                                    any).  If NULL, no value is returned.
+ *              Info                - Method info block
  *
  * RETURN:      Status
  *
@@ -138,8 +133,7 @@
 	}
 
 	/*
-	 * Now that we have a handle to the object, we can attempt
-	 * to evaluate it.
+	 * Now that we have a handle to the object, we can attempt to evaluate it.
 	 */
 	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
 		pathname, node, acpi_ns_get_attached_object (node)));
@@ -165,9 +159,9 @@
  *
  * PARAMETERS:  Pathname            - Fully qualified pathname to the object
  *              Info                - Contains:
- *              return_object       - Where to put method's return value (if
+ *                  return_object   - Where to put method's return value (if
  *                                    any).  If NULL, no value is returned.
- *              Params              - List of parameters to pass to the method,
+ *                  Params          - List of parameters to pass to the method,
  *                                    terminated by NULL.  Params itself may be
  *                                    NULL if no parameters are being passed.
  *
@@ -213,14 +207,14 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 
 	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object at [%s] was not found, status=%.4X\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+			"Object at [%s] was not found, status=%.4X\n",
 			pathname, status));
 		goto cleanup;
 	}
 
 	/*
-	 * Now that we have a handle to the object, we can attempt
-	 * to evaluate it.
+	 * Now that we have a handle to the object, we can attempt to evaluate it.
 	 */
 	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
 		pathname, info->node, acpi_ns_get_attached_object (info->node)));
@@ -303,9 +297,8 @@
 	}
 
 	/*
-	 * For a method alias, we must grab the actual method node
-	 * so that proper scoping context will be established
-	 * before execution.
+	 * For a method alias, we must grab the actual method node so that proper
+	 * scoping context will be established before execution.
 	 */
 	if (acpi_ns_get_type (info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) {
 		info->node = ACPI_CAST_PTR (struct acpi_namespace_node, info->node->object);
@@ -314,11 +307,9 @@
 	/*
 	 * Two major cases here:
 	 * 1) The object is an actual control method -- execute it.
-	 * 2) The object is not a method -- just return it's current
-	 *      value
+	 * 2) The object is not a method -- just return it's current value
 	 *
-	 * In both cases, the namespace is unlocked by the
-	 *  acpi_ns* procedure
+	 * In both cases, the namespace is unlocked by the acpi_ns* procedure
 	 */
 	if (acpi_ns_get_type (info->node) == ACPI_TYPE_METHOD) {
 		/*
@@ -328,15 +319,13 @@
 	}
 	else {
 		/*
-		 * Case 2) Object is NOT a method, just return its
-		 * current value
+		 * Case 2) Object is NOT a method, just return its current value
 		 */
 		status = acpi_ns_get_object_value (info);
 	}
 
 	/*
-	 * Check if there is a return value on the stack that must
-	 * be dealt with
+	 * Check if there is a return value on the stack that must be dealt with
 	 */
 	if (status == AE_CTRL_RETURN_VALUE) {
 		/* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
@@ -345,8 +334,8 @@
 	}
 
 	/*
-	 * Namespace was unlocked by the handling acpi_ns* function,
-	 * so we just return
+	 * Namespace was unlocked by the handling acpi_ns* function, so we
+	 * just return
 	 */
 	return_ACPI_STATUS (status);
 }
@@ -356,12 +345,7 @@
  *
  * FUNCTION:    acpi_ns_execute_control_method
  *
- * PARAMETERS:  method_node         - The method to execute
- *              Params              - List of parameters to pass to the method,
- *                                    terminated by NULL.  Params itself may be
- *                                    NULL if no parameters are being passed.
- *              return_obj_desc     - List of result objects to be returned
- *                                    from the method.
+ * PARAMETERS:  Info            - Method info block (w/params)
  *
  * RETURN:      Status
  *
@@ -430,8 +414,7 @@
  *
  * FUNCTION:    acpi_ns_get_object_value
  *
- * PARAMETERS:  Node                - The object
- *              return_obj_desc     - Where the objects value is returned
+ * PARAMETERS:  Info            - Method info block (w/params)
  *
  * RETURN:      Status
  *
@@ -453,28 +436,25 @@
 
 
 	/*
-	 * Objects require additional resolution steps (e.g., the
-	 * Node may be a field that must be read, etc.) -- we can't just grab
-	 * the object out of the node.
+	 * Objects require additional resolution steps (e.g., the Node may be a
+	 * field that must be read, etc.) -- we can't just grab the object out of
+	 * the node.
 	 */
 
 	/*
-	 * Use resolve_node_to_value() to get the associated value. This call
-	 * always deletes obj_desc (allocated above).
+	 * Use resolve_node_to_value() to get the associated value. This call always
+	 * deletes obj_desc (allocated above).
 	 *
-	 * NOTE: we can get away with passing in NULL for a walk state
-	 * because obj_desc is guaranteed to not be a reference to either
-	 * a method local or a method argument (because this interface can only be
-	 * called from the acpi_evaluate external interface, never called from
-	 * a running control method.)
+	 * NOTE: we can get away with passing in NULL for a walk state because
+	 * obj_desc is guaranteed to not be a reference to either a method local or
+	 * a method argument (because this interface can only be called from the
+	 * acpi_evaluate external interface, never called from a running method.)
 	 *
-	 * Even though we do not directly invoke the interpreter
-	 * for this, we must enter it because we could access an opregion.
-	 * The opregion access code assumes that the interpreter
-	 * is locked.
+	 * Even though we do not directly invoke the interpreter for this, we must
+	 * enter it because we could access an opregion. The opregion access code
+	 * assumes that the interpreter is locked.
 	 *
-	 * We must release the namespace lock before entering the
-	 * intepreter.
+	 * We must release the namespace lock before entering the intepreter.
 	 */
 	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	if (ACPI_FAILURE (status)) {
@@ -485,16 +465,18 @@
 	if (ACPI_SUCCESS (status)) {
 		status = acpi_ex_resolve_node_to_value (&resolved_node, NULL);
 		/*
-		 * If acpi_ex_resolve_node_to_value() succeeded, the return value was
-		 * placed in resolved_node.
+		 * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed
+		 * in resolved_node.
 		 */
 		acpi_ex_exit_interpreter ();
 
 		if (ACPI_SUCCESS (status)) {
 			status = AE_CTRL_RETURN_VALUE;
-			info->return_object = ACPI_CAST_PTR (union acpi_operand_object, resolved_node);
+			info->return_object = ACPI_CAST_PTR
+					 (union acpi_operand_object, resolved_node);
 			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n",
-				info->return_object, acpi_ut_get_object_type_name (info->return_object)));
+				info->return_object,
+				acpi_ut_get_object_type_name (info->return_object)));
 		}
 	}
 
diff -Nru a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
--- a/drivers/acpi/namespace/nsinit.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/acpi/namespace/nsinit.c	2004-12-24 13:36:47 -08:00
@@ -77,7 +77,8 @@
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 		"**** Starting initialization of namespace objects ****\n"));
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Completing Region/Field/Buffer/Package initialization:"));
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+		"Completing Region/Field/Buffer/Package initialization:"));
 
 	/* Set all init info to zero */
 
@@ -142,7 +143,8 @@
 	info.num_STA = 0;
 	info.num_INI = 0;
 
-	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Executing all Device _STA and_INI methods:"));
+	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+		"Executing all Device _STA and_INI methods:"));
 
 	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
 	if (ACPI_FAILURE (status)) {
@@ -257,8 +259,8 @@
 	}
 
 	/*
-	 * Each of these types can contain executable AML code within
-	 * the declaration.
+	 * Each of these types can contain executable AML code within the
+	 * declaration.
 	 */
 	switch (type) {
 	case ACPI_TYPE_REGION:
@@ -267,21 +269,18 @@
 		status = acpi_ds_get_region_arguments (obj_desc);
 		break;
 
-
 	case ACPI_TYPE_BUFFER_FIELD:
 
 		info->field_init++;
 		status = acpi_ds_get_buffer_field_arguments (obj_desc);
 		break;
 
-
 	case ACPI_TYPE_BUFFER:
 
 		info->buffer_init++;
 		status = acpi_ds_get_buffer_arguments (obj_desc);
 		break;
 
-
 	case ACPI_TYPE_PACKAGE:
 
 		info->package_init++;
@@ -301,15 +300,17 @@
 				acpi_format_exception (status)));
 	}
 
-	/* Print a dot for each object unless we are going to print the entire pathname */
-
+	/*
+	 * Print a dot for each object unless we are going to print the entire
+	 * pathname
+	 */
 	if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
 		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
 	}
 
 	/*
-	 * We ignore errors from above, and always return OK, since
-	 * we don't want to abort the walk on any single error.
+	 * We ignore errors from above, and always return OK, since we don't want
+	 * to abort the walk on any single error.
 	 */
 	acpi_ex_exit_interpreter ();
 	return (AE_OK);
@@ -363,7 +364,8 @@
 		return_ACPI_STATUS (AE_OK);
 	}
 
-	if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) && (!(acpi_dbg_level & ACPI_LV_INFO))) {
+	if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) &&
+		(!(acpi_dbg_level & ACPI_LV_INFO))) {
 		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
 	}
 
@@ -428,7 +430,6 @@
 
 		status = acpi_gbl_init_handler (pinfo.node, ACPI_INIT_DEVICE_INI);
 	}
-
 
 	return_ACPI_STATUS (status);
 }
diff -Nru a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
--- a/drivers/acpi/namespace/nsload.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/acpi/namespace/nsload.c	2004-12-24 13:37:19 -08:00
@@ -92,12 +92,14 @@
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", table_desc->aml_start));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n",
+		table_desc->aml_start));
 
 	/* Ignore table if there is no AML contained within */
 
 	if (!table_desc->aml_length) {
-		ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", table_desc->pointer->signature));
+		ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n",
+			table_desc->pointer->signature));
 		return_ACPI_STATUS (AE_OK);
 	}
 
@@ -110,7 +112,8 @@
 	 * to another control method, we can't continue parsing
 	 * because we don't know how many arguments to parse next!
 	 */
-	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n"));
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+		"**** Loading table into namespace ****\n"));
 
 	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
 	if (ACPI_FAILURE (status)) {
@@ -196,7 +199,6 @@
 		if (ACPI_SUCCESS (status)) {
 			table_desc->loaded_into_namespace = TRUE;
 		}
-
 		break;
 
 
@@ -252,7 +254,6 @@
 
 			table_desc = table_desc->next;
 		}
-
 		break;
 
 
@@ -320,6 +321,8 @@
 }
 
 
+#ifdef ACPI_FUTURE_USAGE
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ns_delete_subtree
@@ -450,6 +453,8 @@
 
 	return_ACPI_STATUS (status);
 }
+
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 #endif
 
diff -Nru a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
--- a/drivers/acpi/namespace/nsnames.c	2004-12-24 13:37:33 -08:00
+++ b/drivers/acpi/namespace/nsnames.c	2004-12-24 13:37:33 -08:00
@@ -202,7 +202,11 @@
 		next_node = acpi_ns_get_parent_node (next_node);
 	}
 
-	return (size + 1);
+	if (!size) {
+		size = 1;       /* Root node case */
+	}
+
+	return (size + 1);  /* +1 for null string terminator */
 }
 
 
@@ -253,7 +257,8 @@
 
 	acpi_ns_build_external_path (node, required_size, buffer->pointer);
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", (char *) buffer->pointer, (u32) required_size));
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n",
+		(char *) buffer->pointer, (u32) required_size));
 	return_ACPI_STATUS (AE_OK);
 }
 
diff -Nru a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
--- a/drivers/acpi/namespace/nssearch.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/acpi/namespace/nssearch.c	2004-12-24 13:37:29 -08:00
@@ -96,8 +96,10 @@
 
 		scope_name = acpi_ns_get_external_pathname (node);
 		if (scope_name) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s (%p) For [%4.4s] (%s)\n",
-				scope_name, node, (char *) &target_name, acpi_ut_get_type_name (type)));
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+				"Searching %s (%p) For [%4.4s] (%s)\n",
+				scope_name, node, (char *) &target_name,
+				acpi_ut_get_type_name (type)));
 
 			ACPI_MEM_FREE (scope_name);
 		}
@@ -164,7 +166,7 @@
  * PARAMETERS:  *target_name        - Ascii ACPI name to search for
  *              *Node               - Starting node where search will begin
  *              Type                - Object type to match
- *              **return_node       - Where the matched Named Obj is returned
+ *              **return_node       - Where the matched Node is returned
  *
  * RETURN:      Status
  *
@@ -199,13 +201,13 @@
 	parent_node = acpi_ns_get_parent_node (node);
 
 	/*
-	 * If there is no parent (i.e., we are at the root) or
-	 * type is "local", we won't be searching the parent tree.
+	 * If there is no parent (i.e., we are at the root) or type is "local",
+	 * we won't be searching the parent tree.
 	 */
 	if (!parent_node) {
 		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
 			(char *) &target_name));
-		 return_ACPI_STATUS (AE_NOT_FOUND);
+		return_ACPI_STATUS (AE_NOT_FOUND);
 	}
 
 	if (acpi_ns_local (type)) {
@@ -217,11 +219,12 @@
 
 	/* Search the parent tree */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching parent for %4.4s\n", (char *) &target_name));
+	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+		"Searching parent [%4.4s] for [%4.4s]\n",
+		acpi_ut_get_node_name (parent_node), (char *) &target_name));
 
 	/*
-	 * Search parents until found the target or we have backed up to
-	 * the root
+	 * Search parents until target is found or we have backed up to the root
 	 */
 	while (parent_node) {
 		/*
@@ -230,7 +233,7 @@
 		 * the actual name we are searching for.  Typechecking comes later.
 		 */
 		status = acpi_ns_search_node (target_name, parent_node,
-				   ACPI_TYPE_ANY, return_node);
+				  ACPI_TYPE_ANY, return_node);
 		if (ACPI_SUCCESS (status)) {
 			return_ACPI_STATUS (status);
 		}
@@ -293,7 +296,8 @@
 	/* Parameter validation */
 
 	if (!node || !target_name || !return_node) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null param: Node %p Name %X return_node %p\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Null param: Node %p Name %X return_node %p\n",
 			node, target_name, return_node));
 
 		ACPI_REPORT_ERROR (("ns_search_and_enter: Null parameter\n"));
@@ -330,22 +334,20 @@
 	}
 
 	/*
-	 * The name was not found.  If we are NOT performing the
-	 * first pass (name entry) of loading the namespace, search
-	 * the parent tree (all the way to the root if necessary.)
-	 * We don't want to perform the parent search when the
-	 * namespace is actually being loaded.  We want to perform
-	 * the search when namespace references are being resolved
-	 * (load pass 2) and during the execution phase.
+	 * The name was not found.  If we are NOT performing the first pass
+	 * (name entry) of loading the namespace, search the parent tree (all the
+	 * way to the root if necessary.) We don't want to perform the parent
+	 * search when the namespace is actually being loaded.  We want to perform
+	 * the search when namespace references are being resolved (load pass 2)
+	 * and during the execution phase.
 	 */
 	if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) &&
 		(flags & ACPI_NS_SEARCH_PARENT)) {
 		/*
-		 * Not found at this level - search parent tree according
-		 * to ACPI specification
+		 * Not found at this level - search parent tree according to the
+		 * ACPI specification
 		 */
-		status = acpi_ns_search_parent_tree (target_name, node,
-				 type, return_node);
+		status = acpi_ns_search_parent_tree (target_name, node, type, return_node);
 		if (ACPI_SUCCESS (status)) {
 			return_ACPI_STATUS (status);
 		}
@@ -355,7 +357,8 @@
 	 * In execute mode, just search, never add names.  Exit now.
 	 */
 	if (interpreter_mode == ACPI_IMODE_EXECUTE) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s Not found in %p [Not adding]\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+			"%4.4s Not found in %p [Not adding]\n",
 			(char *) &target_name, node));
 
 		return_ACPI_STATUS (AE_NOT_FOUND);
diff -Nru a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
--- a/drivers/acpi/namespace/nsutils.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/acpi/namespace/nsutils.c	2004-12-24 13:36:49 -08:00
@@ -85,12 +85,14 @@
 	if (lookup_status == AE_BAD_CHARACTER) {
 		/* There is a non-ascii character in the name */
 
-		acpi_os_printf ("[0x%4.4X] (NON-ASCII)\n", *(ACPI_CAST_PTR (u32, internal_name)));
+		acpi_os_printf ("[0x%4.4X] (NON-ASCII)\n",
+			*(ACPI_CAST_PTR (u32, internal_name)));
 	}
 	else {
 		/* Convert path to external format */
 
-		status = acpi_ns_externalize_name (ACPI_UINT32_MAX, internal_name, NULL, &name);
+		status = acpi_ns_externalize_name (ACPI_UINT32_MAX,
+				 internal_name, NULL, &name);
 
 		/* Print target name */
 
@@ -141,7 +143,8 @@
 
 
 	if (path) {
-		status = acpi_ns_get_node_by_path (path, prefix_node, ACPI_NS_NO_UPSEARCH, &node);
+		status = acpi_ns_get_node_by_path (path, prefix_node,
+				 ACPI_NS_NO_UPSEARCH, &node);
 		if (ACPI_FAILURE (status)) {
 			acpi_os_printf ("report_method_error: Could not get node\n");
 			return;
@@ -180,7 +183,7 @@
 		return;
 	}
 
-	/* Convert handle to a full pathname and print it (with supplied message) */
+	/* Convert handle to full pathname and print it (with supplied message) */
 
 	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
 
@@ -324,13 +327,11 @@
 	info->fully_qualified = FALSE;
 
 	/*
-	 * For the internal name, the required length is 4 bytes
-	 * per segment, plus 1 each for root_prefix, multi_name_prefix_op,
-	 * segment count, trailing null (which is not really needed,
-	 * but no there's harm in putting it there)
+	 * For the internal name, the required length is 4 bytes per segment, plus
+	 * 1 each for root_prefix, multi_name_prefix_op, segment count, trailing null
+	 * (which is not really needed, but no there's harm in putting it there)
 	 *
-	 * strlen() + 1 covers the first name_seg, which has no
-	 * path separator
+	 * strlen() + 1 covers the first name_seg, which has no path separator
 	 */
 	if (acpi_ns_valid_root_prefix (next_external_char[0])) {
 		info->fully_qualified = TRUE;
@@ -347,10 +348,9 @@
 	}
 
 	/*
-	 * Determine the number of ACPI name "segments" by counting
-	 * the number of path separators within the string.  Start
-	 * with one segment since the segment count is (# separators)
-	 * + 1, and zero separators is ok.
+	 * Determine the number of ACPI name "segments" by counting the number of
+	 * path separators within the string. Start with one segment since the
+	 * segment count is [(# separators) + 1], and zero separators is ok.
 	 */
 	if (*next_external_char) {
 		info->num_segments = 1;
@@ -625,7 +625,8 @@
 			/* <count> 4-byte names */
 
 			names_index = prefix_length + 2;
-			num_segments = (acpi_native_uint) (u8) internal_name[(acpi_native_uint) (prefix_length + 1)];
+			num_segments = (acpi_native_uint) (u8)
+					   internal_name[(acpi_native_uint) (prefix_length + 1)];
 			break;
 
 		case AML_DUAL_NAME_PREFIX:
@@ -672,7 +673,7 @@
 	}
 
 	/*
-	 * Build converted_name...
+	 * Build converted_name
 	 */
 	*converted_name = ACPI_MEM_CALLOCATE (required_length);
 	if (!(*converted_name)) {
@@ -756,7 +757,7 @@
  *
  * PARAMETERS:  Node          - Node to be converted to a Handle
  *
- * RETURN:      An USER acpi_handle
+ * RETURN:      A user handle
  *
  * DESCRIPTION: Convert a real Node to a namespace handle
  *
@@ -960,7 +961,7 @@
  *              (which "should not happen").
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_name
 acpi_ns_find_parent_name (
 	struct acpi_namespace_node      *child_node)
@@ -976,7 +977,8 @@
 
 		parent_node = acpi_ns_get_parent_node (child_node);
 		if (parent_node) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Parent of %p [%4.4s] is %p [%4.4s]\n",
+			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+				"Parent of %p [%4.4s] is %p [%4.4s]\n",
 				child_node, acpi_ut_get_node_name (child_node),
 				parent_node, acpi_ut_get_node_name (parent_node)));
 
@@ -985,12 +987,14 @@
 			}
 		}
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n",
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+			"Unable to find parent of %p (%4.4s)\n",
 			child_node, acpi_ut_get_node_name (child_node)));
 	}
 
 	return_VALUE (ACPI_UNKNOWN_NAME);
 }
+#endif
 
 
 /*******************************************************************************
@@ -1018,11 +1022,9 @@
 	}
 
 	/*
-	 * Walk to the end of this peer list.
-	 * The last entry is marked with a flag and the peer
-	 * pointer is really a pointer back to the parent.
-	 * This saves putting a parent back pointer in each and
-	 * every named object!
+	 * Walk to the end of this peer list. The last entry is marked with a flag
+	 * and the peer pointer is really a pointer back to the parent. This saves
+	 * putting a parent back pointer in each and every named object!
 	 */
 	while (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {
 		node = node->peer;
@@ -1039,8 +1041,8 @@
  *
  * PARAMETERS:  Node       - Current table entry
  *
- * RETURN:      Next valid Node in the linked node list.  NULL if no more valid
- *              nodess
+ * RETURN:      Next valid Node in the linked node list. NULL if no more valid
+ *              nodes.
  *
  * DESCRIPTION: Find the next valid node within a name table.
  *              Useful for implementing NULL-end-of-list loops.
diff -Nru a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
--- a/drivers/acpi/namespace/nswalk.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/acpi/namespace/nswalk.c	2004-12-24 13:37:32 -08:00
@@ -264,8 +264,8 @@
 					 * node, visit the onde
 					 */
 					level++;
-					parent_node   = child_node;
-					child_node    = NULL;
+					parent_node = child_node;
+					child_node = NULL;
 				}
 			}
 		}
diff -Nru a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
--- a/drivers/acpi/namespace/nsxfeval.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/acpi/namespace/nsxfeval.c	2004-12-24 13:37:30 -08:00
@@ -42,6 +42,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
@@ -72,7 +73,7 @@
  *              be valid (non-null)
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_evaluate_object_typed (
 	acpi_handle                     handle,
@@ -143,6 +144,7 @@
 	return_buffer->length = 0;
 	return_ACPI_STATUS (AE_TYPE);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
@@ -354,6 +356,7 @@
 
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_evaluate_object);
 
 
 /*******************************************************************************
@@ -426,6 +429,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_walk_namespace);
 
 
 /*******************************************************************************
@@ -599,6 +603,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_get_devices);
 
 
 /*******************************************************************************
diff -Nru a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
--- a/drivers/acpi/namespace/nsxfname.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/acpi/namespace/nsxfname.c	2004-12-24 13:37:43 -08:00
@@ -42,6 +42,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
@@ -129,6 +130,7 @@
 
 	return (status);
 }
+EXPORT_SYMBOL(acpi_get_handle);
 
 
 /******************************************************************************
@@ -210,6 +212,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return (status);
 }
+EXPORT_SYMBOL(acpi_get_name);
 
 
 /******************************************************************************
@@ -359,4 +362,5 @@
 	}
 	return (status);
 }
+EXPORT_SYMBOL(acpi_get_object_info);
 
diff -Nru a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
--- a/drivers/acpi/namespace/nsxfobj.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/acpi/namespace/nsxfobj.c	2004-12-24 13:36:16 -08:00
@@ -42,6 +42,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
@@ -106,6 +107,7 @@
 	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return (status);
 }
+EXPORT_SYMBOL(acpi_get_type);
 
 
 /*******************************************************************************
@@ -171,6 +173,7 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return (status);
 }
+EXPORT_SYMBOL(acpi_get_parent);
 
 
 /*******************************************************************************
@@ -255,5 +258,5 @@
 	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return (status);
 }
-
+EXPORT_SYMBOL(acpi_get_next_object);
 
diff -Nru a/drivers/acpi/osl.c b/drivers/acpi/osl.c
--- a/drivers/acpi/osl.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/acpi/osl.c	2004-12-24 13:37:18 -08:00
@@ -26,6 +26,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
@@ -61,8 +62,11 @@
 
 #ifdef ENABLE_DEBUGGER
 #include <linux/kdb.h>
+
 /* stuff for debugger support */
 int acpi_in_debugger;
+EXPORT_SYMBOL(acpi_in_debugger);
+
 extern char line_buf[80];
 #endif /*ENABLE_DEBUGGER*/
 
@@ -117,6 +121,7 @@
 	acpi_os_vprintf(fmt, args);
 	va_end(args);
 }
+EXPORT_SYMBOL(acpi_os_printf);
 
 void
 acpi_os_vprintf(const char *fmt, va_list args)
@@ -147,6 +152,7 @@
 {
 	kfree(ptr);
 }
+EXPORT_SYMBOL(acpi_os_free);
 
 acpi_status
 acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
@@ -205,6 +211,7 @@
 	iounmap(virt);
 }
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_os_get_physical_address(void *virt, acpi_physical_address *phys)
 {
@@ -215,6 +222,7 @@
 
 	return AE_OK;
 }
+#endif
 
 #define ACPI_MAX_OVERRIDE_LEN 100
 
@@ -229,7 +237,7 @@
 
 	*new_val = NULL;
 	if (!memcmp (init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
-		printk(KERN_INFO PREFIX "Overriding _OS definition %s\n",
+		printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
 			acpi_os_name);
 		*new_val = acpi_os_name;
 	}
@@ -306,11 +314,12 @@
  */
 
 void
-acpi_os_sleep(u32 sec, u32 ms)
+acpi_os_sleep(acpi_integer ms)
 {
 	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(HZ * sec + (ms * HZ) / 1000);
+	schedule_timeout(((signed long) ms * HZ) / 1000);
 }
+EXPORT_SYMBOL(acpi_os_sleep);
 
 void
 acpi_os_stall(u32 us)
@@ -325,6 +334,30 @@
 		us -= delay;
 	}
 }
+EXPORT_SYMBOL(acpi_os_stall);
+
+/*
+ * Support ACPI 3.0 AML Timer operand
+ * Returns 64-bit free-running, monotonically increasing timer
+ * with 100ns granularity
+ */
+u64
+acpi_os_get_timer (void)
+{
+	static u64 t;
+
+#ifdef	CONFIG_HPET
+	/* TBD: use HPET if available */
+#endif
+
+#ifdef	CONFIG_X86_PM_TIMER
+	/* TBD: default to PM timer if HPET was not available */
+#endif
+	if (!t)
+		printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
+
+	return(++t);
+}
 
 acpi_status
 acpi_os_read_port(
@@ -354,6 +387,7 @@
 
 	return AE_OK;
 }
+EXPORT_SYMBOL(acpi_os_read_port);
 
 acpi_status
 acpi_os_write_port(
@@ -378,6 +412,7 @@
 
 	return AE_OK;
 }
+EXPORT_SYMBOL(acpi_os_write_port);
 
 acpi_status
 acpi_os_read_memory(
@@ -496,6 +531,7 @@
 
 	return (result ? AE_ERROR : AE_OK);
 }
+EXPORT_SYMBOL(acpi_os_read_pci_configuration);
 
 acpi_status
 acpi_os_write_pci_configuration (struct acpi_pci_id *pci_id, u32 reg, acpi_integer value, u32 width)
@@ -689,6 +725,7 @@
 
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_os_queue_for_execution);
 
 void
 acpi_os_wait_events_complete(
@@ -696,6 +733,7 @@
 {
 	flush_workqueue(kacpid_wq);
 }
+EXPORT_SYMBOL(acpi_os_wait_events_complete);
 
 /*
  * Allocate the memory for a spinlock and initialize it.
@@ -807,6 +845,7 @@
 
 	return_ACPI_STATUS (AE_OK);
 }
+EXPORT_SYMBOL(acpi_os_create_semaphore);
 
 
 /*
@@ -833,6 +872,7 @@
 
 	return_ACPI_STATUS (AE_OK);
 }
+EXPORT_SYMBOL(acpi_os_delete_semaphore);
 
 
 /*
@@ -922,6 +962,7 @@
 
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_os_wait_semaphore);
 
 
 /*
@@ -948,7 +989,9 @@
 
 	return_ACPI_STATUS (AE_OK);
 }
+EXPORT_SYMBOL(acpi_os_signal_semaphore);
 
+#ifdef ACPI_FUTURE_USAGE
 u32
 acpi_os_get_line(char *buffer)
 {
@@ -967,6 +1010,7 @@
 
 	return 0;
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 /* Assumes no unreadable holes inbetween */
 u8
@@ -979,6 +1023,7 @@
 	return 1;
 }
 
+#ifdef ACPI_FUTURE_USAGE
 u8
 acpi_os_writable(void *ptr, acpi_size len)
 {
@@ -986,6 +1031,7 @@
 	   The later may be difficult at early boot when kmap doesn't work yet. */
 	return 1;
 }
+#endif
 
 u32
 acpi_os_get_thread_id (void)
@@ -1007,17 +1053,22 @@
 		printk(KERN_ERR PREFIX "Fatal opcode executed\n");
 		break;
 	case ACPI_SIGNAL_BREAKPOINT:
-		{
-			char *bp_info = (char*) info;
-
-			printk(KERN_ERR "ACPI breakpoint: %s\n", bp_info);
-		}
+		/*
+		 * AML Breakpoint
+		 * ACPI spec. says to treat it as a NOP unless
+		 * you are debugging.  So if/when we integrate
+		 * AML debugger into the kernel debugger its
+		 * hook will go here.  But until then it is
+		 * not useful to print anything on breakpoints.
+		 */
+		break;
 	default:
 		break;
 	}
 
 	return AE_OK;
 }
+EXPORT_SYMBOL(acpi_os_signal);
 
 int __init
 acpi_os_name_setup(char *str)
@@ -1100,3 +1151,11 @@
 
 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
 
+/*
+ * max_cstate is defined in the base kernel so modules can
+ * change it w/o depending on the state of the processor module.
+ */
+unsigned int max_cstate = ACPI_C_STATES_MAX;
+
+
+EXPORT_SYMBOL(max_cstate);
diff -Nru a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
--- a/drivers/acpi/parser/psopcode.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/acpi/parser/psopcode.c	2004-12-24 13:36:19 -08:00
@@ -194,6 +194,7 @@
 #define ARGP_STRING_OP                  ARGP_LIST1 (ARGP_CHARLIST)
 #define ARGP_SUBTRACT_OP                ARGP_LIST3 (ARGP_TERMARG,    ARGP_TERMARG,       ARGP_TARGET)
 #define ARGP_THERMAL_ZONE_OP            ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_NAME,          ARGP_OBJLIST)
+#define ARGP_TIMER_OP                   ARG_NONE
 #define ARGP_TO_BCD_OP                  ARGP_LIST2 (ARGP_TERMARG,    ARGP_TARGET)
 #define ARGP_TO_BUFFER_OP               ARGP_LIST2 (ARGP_TERMARG,    ARGP_TARGET)
 #define ARGP_TO_DEC_STR_OP              ARGP_LIST2 (ARGP_TERMARG,    ARGP_TARGET)
@@ -317,7 +318,7 @@
 #define ARGI_SHIFT_LEFT_OP              ARGI_LIST3 (ARGI_INTEGER,    ARGI_INTEGER,       ARGI_TARGETREF)
 #define ARGI_SHIFT_RIGHT_OP             ARGI_LIST3 (ARGI_INTEGER,    ARGI_INTEGER,       ARGI_TARGETREF)
 #define ARGI_SIGNAL_OP                  ARGI_LIST1 (ARGI_EVENT)
-#define ARGI_SIZE_OF_OP                 ARGI_LIST1 (ARGI_DATAOBJECT)
+#define ARGI_SIZE_OF_OP                 ARGI_LIST1 (ARGI_REFERENCE) /* Force delay of operand resolution */
 #define ARGI_SLEEP_OP                   ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_STALL_OP                   ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_STATICSTRING_OP            ARGI_INVALID_OPCODE
@@ -325,13 +326,14 @@
 #define ARGI_STRING_OP                  ARGI_INVALID_OPCODE
 #define ARGI_SUBTRACT_OP                ARGI_LIST3 (ARGI_INTEGER,    ARGI_INTEGER,       ARGI_TARGETREF)
 #define ARGI_THERMAL_ZONE_OP            ARGI_INVALID_OPCODE
+#define ARGI_TIMER_OP                   ARG_NONE
 #define ARGI_TO_BCD_OP                  ARGI_LIST2 (ARGI_INTEGER,    ARGI_FIXED_TARGET)
 #define ARGI_TO_BUFFER_OP               ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
 #define ARGI_TO_DEC_STR_OP              ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
 #define ARGI_TO_HEX_STR_OP              ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
 #define ARGI_TO_INTEGER_OP              ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
 #define ARGI_TO_STRING_OP               ARGI_LIST3 (ARGI_BUFFER,     ARGI_INTEGER,       ARGI_FIXED_TARGET)
-#define ARGI_TYPE_OP                    ARGI_LIST1 (ARGI_ANYTYPE)
+#define ARGI_TYPE_OP                    ARGI_LIST1 (ARGI_REFERENCE) /* Force delay of operand resolution */
 #define ARGI_UNLOAD_OP                  ARGI_LIST1 (ARGI_DDBHANDLE)
 #define ARGI_VAR_PACKAGE_OP             ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_WAIT_OP                    ARGI_LIST2 (ARGI_EVENT,      ARGI_INTEGER)
@@ -527,8 +529,8 @@
 /* 35 */ ACPI_OP ("CreateByteField",    ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP,  ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
 /* 36 */ ACPI_OP ("CreateBitField",     ARGP_CREATE_BIT_FIELD_OP,  ARGI_CREATE_BIT_FIELD_OP,   ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
 /* 37 */ ACPI_OP ("ObjectType",         ARGP_TYPE_OP,              ARGI_TYPE_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 38 */ ACPI_OP ("LAnd",               ARGP_LAND_OP,              ARGI_LAND_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
-/* 39 */ ACPI_OP ("LOr",                ARGP_LOR_OP,               ARGI_LOR_OP,                ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
+/* 38 */ ACPI_OP ("LAnd",               ARGP_LAND_OP,              ARGI_LAND_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
+/* 39 */ ACPI_OP ("LOr",                ARGP_LOR_OP,               ARGI_LOR_OP,                ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
 /* 3A */ ACPI_OP ("LNot",               ARGP_LNOT_OP,              ARGI_LNOT_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
 /* 3B */ ACPI_OP ("LEqual",             ARGP_LEQUAL_OP,            ARGI_LEQUAL_OP,             ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
 /* 3C */ ACPI_OP ("LGreater",           ARGP_LGREATER_OP,          ARGI_LGREATER_OP,           ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
@@ -588,7 +590,6 @@
 /* 6C */ ACPI_OP ("-ASCII_ONLY-",       ARG_NONE,                  ARG_NONE,                   ACPI_TYPE_ANY,               AML_CLASS_ASCII,           AML_TYPE_BOGUS,           AML_HAS_ARGS),
 /* 6D */ ACPI_OP ("-PREFIX_ONLY-",      ARG_NONE,                  ARG_NONE,                   ACPI_TYPE_ANY,               AML_CLASS_PREFIX,          AML_TYPE_BOGUS,           AML_HAS_ARGS),
 
-
 /* ACPI 2.0 opcodes */
 
 /* 6E */ ACPI_OP ("QwordConst",         ARGP_QWORD_OP,             ARGI_QWORD_OP,              ACPI_TYPE_INTEGER,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_CONSTANT),
@@ -606,7 +607,11 @@
 /* 7A */ ACPI_OP ("Continue",           ARGP_CONTINUE_OP,          ARGI_CONTINUE_OP,           ACPI_TYPE_ANY,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
 /* 7B */ ACPI_OP ("LoadTable",          ARGP_LOAD_TABLE_OP,        ARGI_LOAD_TABLE_OP,         ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_6A_0T_1R,   AML_FLAGS_EXEC_6A_0T_1R),
 /* 7C */ ACPI_OP ("DataTableRegion",    ARGP_DATA_REGION_OP,       ARGI_DATA_REGION_OP,        ACPI_TYPE_REGION,            AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 7D */ ACPI_OP ("[EvalSubTree]",      ARGP_SCOPE_OP,             ARGI_SCOPE_OP,              ACPI_TYPE_ANY,               AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE)
+/* 7D */ ACPI_OP ("[EvalSubTree]",      ARGP_SCOPE_OP,             ARGI_SCOPE_OP,              ACPI_TYPE_ANY,               AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE),
+
+/* ACPI 3.0 opcodes */
+
+/* 7E */ ACPI_OP ("Timer",              ARGP_TIMER_OP,             ARGI_TIMER_OP,              ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_0A_0T_1R,   AML_FLAGS_EXEC_0A_0T_1R)
 
 /*! [End] no source code translation !*/
 };
@@ -615,7 +620,6 @@
  * This table is directly indexed by the opcodes, and returns an
  * index into the table above
  */
-
 static const u8 acpi_gbl_short_op_index[256] =
 {
 /*              0     1     2     3     4     5     6     7  */
@@ -654,7 +658,10 @@
 /* 0xF8 */	_UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
 };
 
-
+/*
+ * This table is indexed by the second opcode of the extended opcode
+ * pair.  It returns an index into the opcode table (acpi_gbl_aml_op_info)
+ */
 static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] =
 {
 /*              0     1     2     3     4     5     6     7  */
@@ -665,7 +672,7 @@
 /* 0x18 */	_UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
 /* 0x20 */	0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
 /* 0x28 */	0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x30 */	0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x30 */	0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
 /* 0x38 */	_UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
 /* 0x40 */	_UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
 /* 0x48 */	_UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
@@ -724,7 +731,7 @@
 
 	default:
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown extended opcode [%X]\n", opcode));
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown AML opcode [%4.4X]\n", opcode));
 		break;
 	}
 
diff -Nru a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
--- a/drivers/acpi/parser/psparse.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/acpi/parser/psparse.c	2004-12-24 13:36:19 -08:00
@@ -164,123 +164,125 @@
 
 	/* Delete this op and the subtree below it if asked to */
 
-	if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) &&
-		(walk_state->op_info->class != AML_CLASS_ARGUMENT)) {
-		/* Make sure that we only delete this subtree */
+	if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
+		 (walk_state->op_info->class == AML_CLASS_ARGUMENT)) {
+		return_VOID;
+	}
+
+	/* Make sure that we only delete this subtree */
+
+	if (op->common.parent) {
+		/*
+		 * Check if we need to replace the operator and its subtree
+		 * with a return value op (placeholder op)
+		 */
+		parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
+
+		switch (parent_info->class) {
+		case AML_CLASS_CONTROL:
+			break;
+
+		case AML_CLASS_CREATE:
 
-		if (op->common.parent) {
 			/*
-			 * Check if we need to replace the operator and its subtree
-			 * with a return value op (placeholder op)
+			 * These opcodes contain term_arg operands. The current
+			 * op must be replaced by a placeholder return op
 			 */
-			parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
-
-			switch (parent_info->class) {
-			case AML_CLASS_CONTROL:
-				break;
+			replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
+			if (!replacement_op) {
+				goto cleanup;
+			}
+			break;
 
-			case AML_CLASS_CREATE:
+		case AML_CLASS_NAMED_OBJECT:
 
-				/*
-				 * These opcodes contain term_arg operands. The current
-				 * op must be replaced by a placeholder return op
-				 */
+			/*
+			 * These opcodes contain term_arg operands. The current
+			 * op must be replaced by a placeholder return op
+			 */
+			if ((op->common.parent->common.aml_opcode == AML_REGION_OP)      ||
+				(op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) ||
+				(op->common.parent->common.aml_opcode == AML_BUFFER_OP)      ||
+				(op->common.parent->common.aml_opcode == AML_PACKAGE_OP)     ||
+				(op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
 				replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
 				if (!replacement_op) {
-					return_VOID;
+					goto cleanup;
 				}
-				break;
-
-			case AML_CLASS_NAMED_OBJECT:
+			}
 
-				/*
-				 * These opcodes contain term_arg operands. The current
-				 * op must be replaced by a placeholder return op
-				 */
-				if ((op->common.parent->common.aml_opcode == AML_REGION_OP)      ||
-					(op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) ||
-					(op->common.parent->common.aml_opcode == AML_BUFFER_OP)      ||
-					(op->common.parent->common.aml_opcode == AML_PACKAGE_OP)     ||
-					(op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
-					replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
+			if ((op->common.parent->common.aml_opcode == AML_NAME_OP) &&
+				(walk_state->descending_callback != acpi_ds_exec_begin_op)) {
+				if ((op->common.aml_opcode == AML_BUFFER_OP) ||
+					(op->common.aml_opcode == AML_PACKAGE_OP) ||
+					(op->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
+					replacement_op = acpi_ps_alloc_op (op->common.aml_opcode);
 					if (!replacement_op) {
-						return_VOID;
+						goto cleanup;
 					}
+
+					replacement_op->named.data = op->named.data;
+					replacement_op->named.length = op->named.length;
 				}
+			}
+			break;
 
-				if ((op->common.parent->common.aml_opcode == AML_NAME_OP) &&
-					(walk_state->descending_callback != acpi_ds_exec_begin_op)) {
-					if ((op->common.aml_opcode == AML_BUFFER_OP) ||
-						(op->common.aml_opcode == AML_PACKAGE_OP) ||
-						(op->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
-						replacement_op = acpi_ps_alloc_op (op->common.aml_opcode);
-						if (!replacement_op) {
-							return_VOID;
-						}
+		default:
+			replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
+			if (!replacement_op) {
+				goto cleanup;
+			}
+		}
 
-						replacement_op->named.data = op->named.data;
-						replacement_op->named.length = op->named.length;
-					}
-				}
-				break;
+		/* We must unlink this op from the parent tree */
 
-			default:
-				replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
-				if (!replacement_op) {
-					return_VOID;
-				}
+		prev = op->common.parent->common.value.arg;
+		if (prev == op) {
+			/* This op is the first in the list */
+
+			if (replacement_op) {
+				replacement_op->common.parent       = op->common.parent;
+				replacement_op->common.value.arg    = NULL;
+				replacement_op->common.node         = op->common.node;
+				op->common.parent->common.value.arg = replacement_op;
+				replacement_op->common.next         = op->common.next;
+			}
+			else {
+				op->common.parent->common.value.arg = op->common.next;
 			}
+		}
 
-			/* We must unlink this op from the parent tree */
+		/* Search the parent list */
 
-			prev = op->common.parent->common.value.arg;
-			if (prev == op) {
-				/* This op is the first in the list */
+		else while (prev) {
+			/* Traverse all siblings in the parent's argument list */
 
+			next = prev->common.next;
+			if (next == op) {
 				if (replacement_op) {
-					replacement_op->common.parent       = op->common.parent;
-					replacement_op->common.value.arg    = NULL;
-					replacement_op->common.node         = op->common.node;
-					op->common.parent->common.value.arg = replacement_op;
-					replacement_op->common.next         = op->common.next;
+					replacement_op->common.parent   = op->common.parent;
+					replacement_op->common.value.arg = NULL;
+					replacement_op->common.node     = op->common.node;
+					prev->common.next               = replacement_op;
+					replacement_op->common.next     = op->common.next;
+					next = NULL;
 				}
 				else {
-					op->common.parent->common.value.arg    = op->common.next;
+					prev->common.next = op->common.next;
+					next = NULL;
 				}
 			}
 
-			/* Search the parent list */
-
-			else while (prev) {
-				/* Traverse all siblings in the parent's argument list */
-
-				next = prev->common.next;
-				if (next == op) {
-					if (replacement_op) {
-						replacement_op->common.parent   = op->common.parent;
-						replacement_op->common.value.arg = NULL;
-						replacement_op->common.node     = op->common.node;
-						prev->common.next               = replacement_op;
-						replacement_op->common.next     = op->common.next;
-						next = NULL;
-					}
-					else {
-						prev->common.next = op->common.next;
-						next = NULL;
-					}
-				}
-
-				prev = next;
-			}
+			prev = next;
 		}
+	}
 
-		/* Now we can actually delete the subtree rooted at op */
 
-		acpi_ps_delete_parse_tree (op);
+cleanup:
 
-		return_VOID;
-	}
+	/* Now we can actually delete the subtree rooted at op */
 
+	acpi_ps_delete_parse_tree (op);
 	return_VOID;
 }
 
@@ -552,7 +554,8 @@
 				if (!pre_op) {
 					pre_op = acpi_ps_alloc_op (walk_state->opcode);
 					if (!pre_op) {
-						return_ACPI_STATUS (AE_NO_MEMORY);
+						status = AE_NO_MEMORY;
+						goto close_this_op;
 					}
 				}
 
@@ -578,7 +581,8 @@
 				/* Make sure that we found a NAME and didn't run out of arguments */
 
 				if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) {
-					return_ACPI_STATUS (AE_AML_NO_OPERAND);
+					status = AE_AML_NO_OPERAND;
+					goto close_this_op;
 				}
 
 				/* We know that this arg is a name, move to next arg */
@@ -638,7 +642,8 @@
 				walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode);
 				op = acpi_ps_alloc_op (walk_state->opcode);
 				if (!op) {
-					return_ACPI_STATUS (AE_NO_MEMORY);
+					status = AE_NO_MEMORY;
+					goto close_this_op;
 				}
 
 				if (walk_state->op_info->flags & AML_CREATE) {
@@ -801,7 +806,7 @@
 			status = acpi_ps_push_scope (parser_state, op,
 					 walk_state->arg_types, walk_state->arg_count);
 			if (ACPI_FAILURE (status)) {
-				return_ACPI_STATUS (status);
+				goto close_this_op;
 			}
 			op = NULL;
 			continue;
@@ -1128,7 +1133,7 @@
 		else if (status == AE_CTRL_TERMINATE) {
 			status = AE_OK;
 		}
-		else if (status != AE_OK) {
+		else if ((status != AE_OK) && (walk_state->method_desc)) {
 			ACPI_REPORT_METHOD_ERROR ("Method execution failed",
 				walk_state->method_node, NULL, status);
 
diff -Nru a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c
--- a/drivers/acpi/parser/pstree.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/acpi/parser/pstree.c	2004-12-24 13:36:32 -08:00
@@ -181,6 +181,8 @@
 }
 
 
+#ifdef ACPI_FUTURE_USAGE
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ps_get_child
@@ -192,7 +194,6 @@
  * DESCRIPTION: Get op's children or NULL if none
  *
  ******************************************************************************/
-
 union acpi_parse_object *
 acpi_ps_get_child (
 	union acpi_parse_object         *op)
@@ -322,4 +323,5 @@
 	return (next);
 }
 
+#endif  /*  ACPI_FUTURE_USAGE  */
 
diff -Nru a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
--- a/drivers/acpi/parser/psutils.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/acpi/parser/psutils.c	2004-12-24 13:36:59 -08:00
@@ -129,10 +129,9 @@
 acpi_ps_alloc_op (
 	u16                             opcode)
 {
-	union acpi_parse_object         *op = NULL;
-	u32                             size;
-	u8                              flags;
+	union acpi_parse_object         *op;
 	const struct acpi_opcode_info   *op_info;
+	u8                              flags = ACPI_PARSEOP_GENERIC;
 
 
 	ACPI_FUNCTION_ENTRY ();
@@ -140,32 +139,28 @@
 
 	op_info = acpi_ps_get_opcode_info (opcode);
 
-	/* Allocate the minimum required size object */
+	/* Determine type of parse_op required */
 
 	if (op_info->flags & AML_DEFER) {
-		size = sizeof (struct acpi_parse_obj_named);
 		flags = ACPI_PARSEOP_DEFERRED;
 	}
 	else if (op_info->flags & AML_NAMED) {
-		size = sizeof (struct acpi_parse_obj_named);
 		flags = ACPI_PARSEOP_NAMED;
 	}
 	else if (opcode == AML_INT_BYTELIST_OP) {
-		size = sizeof (struct acpi_parse_obj_named);
 		flags = ACPI_PARSEOP_BYTELIST;
 	}
-	else {
-		size = sizeof (struct acpi_parse_obj_common);
-		flags = ACPI_PARSEOP_GENERIC;
-	}
 
-	if (size == sizeof (struct acpi_parse_obj_common)) {
-		/*
-		 * The generic op is by far the most common (16 to 1)
-		 */
+	/* Allocate the minimum required size object */
+
+	if (flags == ACPI_PARSEOP_GENERIC) {
+		/* The generic op (default) is by far the most common (16 to 1) */
+
 		op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE);
 	}
 	else {
+		/* Extended parseop */
+
 		op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT);
 	}
 
@@ -272,6 +267,7 @@
 /*
  * Get op's name (4-byte name segment) or 0 if unnamed
  */
+#ifdef ACPI_FUTURE_USAGE
 u32
 acpi_ps_get_name (
 	union acpi_parse_object         *op)
@@ -288,6 +284,7 @@
 
 	return (op->named.name);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*
diff -Nru a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
--- a/drivers/acpi/pci_bind.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/acpi/pci_bind.c	2004-12-24 13:37:18 -08:00
@@ -67,6 +67,7 @@
  * to resolve PCI information for ACPI-PCI devices defined in the namespace.
  * This typically occurs when resolving PCI operation region information.
  */
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_os_get_pci_id (
 	acpi_handle		handle,
@@ -114,6 +115,7 @@
 
 	return_ACPI_STATUS(AE_OK);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 	
 int
diff -Nru a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
--- a/drivers/acpi/pci_irq.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/acpi/pci_irq.c	2004-12-24 13:36:48 -08:00
@@ -227,6 +227,11 @@
                           PCI Interrupt Routing Support
    -------------------------------------------------------------------------- */
 
+/*
+ * acpi_pci_irq_lookup
+ * success: return IRQ >= 0
+ * failure: return -1
+ */
 static int
 acpi_pci_irq_lookup (
 	struct pci_bus		*bus,
@@ -249,14 +254,14 @@
 	entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); 
 	if (!entry) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
-		return_VALUE(0);
+		return_VALUE(-1);
 	}
 	
 	if (entry->link.handle) {
 		irq = acpi_pci_link_get_irq(entry->link.handle, entry->link.index, edge_level, active_high_low);
-		if (!irq) {
+		if (irq < 0) {
 			ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n"));
-			return_VALUE(0);
+			return_VALUE(-1);
 		}
 	} else {
 		irq = entry->link.index;
@@ -269,6 +274,11 @@
 	return_VALUE(irq);
 }
 
+/*
+ * acpi_pci_irq_derive
+ * success: return IRQ >= 0
+ * failure: return < 0
+ */
 static int
 acpi_pci_irq_derive (
 	struct pci_dev		*dev,
@@ -277,7 +287,7 @@
 	int			*active_high_low)
 {
 	struct pci_dev		*bridge = dev;
-	int			irq = 0;
+	int			irq = -1;
 	u8			bridge_pin = 0;
 
 	ACPI_FUNCTION_TRACE("acpi_pci_irq_derive");
@@ -289,7 +299,7 @@
 	 * Attempt to derive an IRQ for this device from a parent bridge's
 	 * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge).
 	 */
-	while (!irq && bridge->bus->self) {
+	while (irq < 0 && bridge->bus->self) {
 		pin = (pin + PCI_SLOT(bridge->devfn)) % 4;
 		bridge = bridge->bus->self;
 
@@ -299,7 +309,7 @@
 			if (!bridge_pin) {
 				ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
 					"No interrupt pin configured for device %s\n", pci_name(bridge)));
-				return_VALUE(0);
+				return_VALUE(-1);
 			}
 			/* Pin is from 0 to 3 */
 			bridge_pin --;
@@ -310,9 +320,9 @@
 			pin, edge_level, active_high_low);
 	}
 
-	if (!irq) {
+	if (irq < 0) {
 		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Unable to derive IRQ for device %s\n", pci_name(dev)));
-		return_VALUE(0);
+		return_VALUE(-1);
 	}
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n",
@@ -321,6 +331,11 @@
 	return_VALUE(irq);
 }
 
+/*
+ * acpi_pci_irq_enable
+ * success: return 0
+ * failure: return < 0
+ */
 
 int
 acpi_pci_irq_enable (
@@ -358,20 +373,20 @@
 	 * If no PRT entry was found, we'll try to derive an IRQ from the
 	 * device's parent bridge.
 	 */
-	if (!irq)
+	if (irq < 0)
  		irq = acpi_pci_irq_derive(dev, pin, &edge_level, &active_high_low);
  
 	/*
 	 * No IRQ known to the ACPI subsystem - maybe the BIOS / 
 	 * driver reported one, then use it. Exit in any case.
 	 */
-	if (!irq) {
+	if (irq < 0) {
 		printk(KERN_WARNING PREFIX "PCI interrupt %s[%c]: no GSI",
 			pci_name(dev), ('A' + pin));
 		/* Interrupt Line values above 0xF are forbidden */
-		if (dev->irq && (dev->irq <= 0xF)) {
+		if (dev->irq >= 0 && (dev->irq <= 0xF)) {
 			printk(" - using IRQ %d\n", dev->irq);
-			return_VALUE(dev->irq);
+			return_VALUE(0);
 		}
 		else {
 			printk("\n");
@@ -388,5 +403,7 @@
 		(active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high",
 		dev->irq);
 
-	return_VALUE(dev->irq);
+	return_VALUE(0);
 }
+EXPORT_SYMBOL(acpi_pci_irq_enable);
+
diff -Nru a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
--- a/drivers/acpi/pci_link.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/pci_link.c	2004-12-24 13:36:18 -08:00
@@ -110,13 +110,13 @@
 
 	switch (resource->id) {
 	case ACPI_RSTYPE_START_DPF:
-		return AE_OK;
+		return_ACPI_STATUS(AE_OK);
 	case ACPI_RSTYPE_IRQ:
 	{
 		struct acpi_resource_irq *p = &resource->data.irq;
 		if (!p || !p->number_of_interrupts) {
 			ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Blank IRQ resource\n"));
-			return AE_OK;
+			return_ACPI_STATUS(AE_OK);
 		}
 		for (i = 0; (i<p->number_of_interrupts && i<ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
 			if (!p->interrupts[i]) {
@@ -137,7 +137,7 @@
 		if (!p || !p->number_of_interrupts) {
 			ACPI_DEBUG_PRINT((ACPI_DB_WARN, 
 				"Blank EXT IRQ resource\n"));
-			return AE_OK;
+			return_ACPI_STATUS(AE_OK);
 		}
 		for (i = 0; (i<p->number_of_interrupts && i<ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
 			if (!p->interrupts[i]) {
@@ -155,10 +155,10 @@
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
 			"Resource is not an IRQ entry\n"));
-		return AE_OK;
+		return_ACPI_STATUS(AE_OK);
 	}
 
-	return AE_CTRL_TERMINATE;
+	return_ACPI_STATUS(AE_CTRL_TERMINATE);
 }
 
 
@@ -207,7 +207,7 @@
 			 */
 			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 				"Blank IRQ resource\n")); 
-			return AE_OK;
+			return_ACPI_STATUS(AE_OK);
 		}
 		*irq = p->interrupts[0];
 		break;
@@ -222,7 +222,7 @@
 			 */
 			ACPI_DEBUG_PRINT((ACPI_DB_WARN,
 				"Blank EXT IRQ resource\n"));
-			return AE_OK;
+			return_ACPI_STATUS(AE_OK);
 		}
 		*irq = p->interrupts[0];
 		break;
@@ -230,9 +230,9 @@
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
 			"Resource isn't an IRQ\n"));
-		return AE_OK;
+		return_ACPI_STATUS(AE_OK);
 	}
-	return AE_CTRL_TERMINATE;
+	return_ACPI_STATUS(AE_CTRL_TERMINATE);
 }
 
 /*
@@ -577,6 +577,11 @@
 	return_VALUE(0);
 }
 
+/*
+ * acpi_pci_link_get_irq
+ * success: return IRQ >= 0
+ * failure: return -1
+ */
 
 int
 acpi_pci_link_get_irq (
@@ -594,27 +599,27 @@
 	result = acpi_bus_get_device(handle, &device);
 	if (result) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
-		return_VALUE(0);
+		return_VALUE(-1);
 	}
 
 	link = (struct acpi_pci_link *) acpi_driver_data(device);
 	if (!link) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
-		return_VALUE(0);
+		return_VALUE(-1);
 	}
 
 	/* TBD: Support multiple index (IRQ) entries per Link Device */
 	if (index) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index));
-		return_VALUE(0);
+		return_VALUE(-1);
 	}
 
 	if (acpi_pci_link_allocate(link))
-		return_VALUE(0);
+		return_VALUE(-1);
 	   
 	if (!link->irq.active) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n"));
-		return_VALUE(0);
+		return_VALUE(-1);
 	}
 
 	if (edge_level) *edge_level = link->irq.edge_level;
@@ -787,6 +792,18 @@
 }
 
 /*
+ * We'd like PNP to call this routine for the
+ * single ISA_USED value for each legacy device.
+ * But instead it calls us with each POSSIBLE setting.
+ * There is no ISA_POSSIBLE weight, so we simply use
+ * the (small) PCI_USING penalty.
+ */
+void acpi_penalize_isa_irq(int irq)
+{
+	acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+}
+
+/*
  * Over-ride default table to reserve additional IRQs for use by ISA
  * e.g. acpi_irq_isa=5
  * Useful for telling ACPI how not to interfere with your ISA sound card.
@@ -811,14 +828,14 @@
 static int __init acpi_irq_nobalance_set(char *str)
 {
 	acpi_irq_balance = 0;
-	return(1);
+	return 1;
 }
 __setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
 
 int __init acpi_irq_balance_set(char *str)
 {
 	acpi_irq_balance = 1;
-	return(1);
+	return 1;
 }
 __setup("acpi_irq_balance", acpi_irq_balance_set);
 
diff -Nru a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
--- a/drivers/acpi/pci_root.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/acpi/pci_root.c	2004-12-24 13:36:31 -08:00
@@ -90,6 +90,7 @@
 
 	return n;
 }
+EXPORT_SYMBOL(acpi_pci_register_driver);
 
 void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
 {
@@ -112,6 +113,7 @@
 		driver->remove(root->handle);
 	}
 }
+EXPORT_SYMBOL(acpi_pci_unregister_driver);
 
 static acpi_status
 get_root_bridge_busnr_callback (struct acpi_resource *resource, void *data)
diff -Nru a/drivers/acpi/power.c b/drivers/acpi/power.c
--- a/drivers/acpi/power.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/acpi/power.c	2004-12-24 13:36:55 -08:00
@@ -303,7 +303,7 @@
 
 	ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power");
 	if (!dev || !dev->wakeup.flags.valid)
-		return -1;
+		return_VALUE(-1);
 
 	arg.integer.value = 1;
 	/* Open power resource */
@@ -313,7 +313,7 @@
 			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
 				"Error transition power state\n"));
 			dev->wakeup.flags.valid = 0;
-			return -1;
+			return_VALUE(-1);
 		}
 	}
 
@@ -325,7 +325,7 @@
 		ret = -1;
 	}
 
-	return ret;
+	return_VALUE(ret);
 }
 
 /*
@@ -344,7 +344,7 @@
 	ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power");
 
 	if (!dev || !dev->wakeup.flags.valid)
-		return -1;
+		return_VALUE(-1);
 
 	arg.integer.value = 0;	
 	/* Execute PSW */
@@ -352,7 +352,7 @@
 	if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n"));
 		dev->wakeup.flags.valid = 0;
-		return -1;
+		return_VALUE(-1);
 	}
 
 	/* Close power resource */
@@ -362,11 +362,11 @@
 			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
 				"Error transition power state\n"));
 			dev->wakeup.flags.valid = 0;
-			return -1;
+			return_VALUE(-1);
 		}
 	}
 
-	return ret;
+	return_VALUE(ret);
 }
 
 /* --------------------------------------------------------------------------
@@ -513,7 +513,7 @@
 			resource->references);
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_power_open_fs(struct inode *inode, struct file *file)
diff -Nru a/drivers/acpi/processor.c b/drivers/acpi/processor.c
--- a/drivers/acpi/processor.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/acpi/processor.c	2004-12-24 13:37:02 -08:00
@@ -39,6 +39,8 @@
 #include <linux/cpufreq.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/dmi.h>
+#include <linux/moduleparam.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
@@ -213,11 +215,13 @@
 		 * each IDE controller's DMA status to make sure we catch all
 		 * DMA activity.
 		 */
-		dev = pci_find_subsys(PCI_VENDOR_ID_INTEL,
+		dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
 		           PCI_DEVICE_ID_INTEL_82371AB, 
                            PCI_ANY_ID, PCI_ANY_ID, NULL);
-		if (dev)
+		if (dev) {
 			errata.piix4.bmisx = pci_resource_start(dev, 4);
+			pci_dev_put(dev);
+		}
 
 		/* 
 		 * Type-F DMA
@@ -228,7 +232,7 @@
 		 * disable C3 support if this is enabled, as some legacy 
 		 * devices won't operate well if fast DMA is disabled.
 		 */
-		dev = pci_find_subsys(PCI_VENDOR_ID_INTEL, 
+		dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 
 			PCI_DEVICE_ID_INTEL_82371AB_0, 
 			PCI_ANY_ID, PCI_ANY_ID, NULL);
 		if (dev) {
@@ -236,6 +240,7 @@
 			pci_read_config_byte(dev, 0x77, &value2);
 			if ((value1 & 0x80) || (value2 & 0x80))
 				errata.piix4.fdma = 1;
+			pci_dev_put(dev);
 		}
 
 		break;
@@ -267,10 +272,12 @@
 	/*
 	 * PIIX4
 	 */
-	dev = pci_find_subsys(PCI_VENDOR_ID_INTEL, 
+	dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 
 		PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, PCI_ANY_ID, NULL);
-	if (dev)
+	if (dev) {
 		result = acpi_processor_errata_piix4(dev);
+		pci_dev_put(dev);
+	}
 
 	return_VALUE(result);
 }
@@ -332,8 +339,8 @@
 {
 	struct acpi_processor	*pr = NULL;
 	struct acpi_processor_cx *cx = NULL;
-	int			next_state = 0;
-	int			sleep_ticks = 0;
+	unsigned int			next_state = 0;
+	unsigned int		sleep_ticks = 0;
 	u32			t1, t2 = 0;
 
 	pr = processors[smp_processor_id()];
@@ -346,6 +353,15 @@
 	 */
 	local_irq_disable();
 
+	/*
+	 * Check whether we truly need to go idle, or should
+	 * reschedule:
+	 */
+	if (unlikely(need_resched())) {
+		local_irq_enable();
+		return;
+	}
+
 	cx = &(pr->power.states[pr->power.state]);
 
 	/*
@@ -405,8 +421,15 @@
 	switch (pr->power.state) {
 
 	case ACPI_STATE_C1:
-		/* Invoke C1. */
-		safe_halt();
+		/*
+		 * Invoke C1.
+		 * Use the appropriate idle routine, the one that would
+		 * be used without acpi C-states.
+		 */
+		if (pm_idle_save)
+			pm_idle_save();
+		else
+			safe_halt();
 		/*
                  * TBD: Can't get time duration while in C1, as resumes
 		 *      go to an ISR rather than here.  Need to instrument
@@ -462,8 +485,9 @@
 	 * Track the number of longs (time asleep is greater than threshold)
 	 * and promote when the count threshold is reached.  Note that bus
 	 * mastering activity may prevent promotions.
+	 * Do not promote above max_cstate.
 	 */
-	if (cx->promotion.state) {
+	if (cx->promotion.state && (cx->promotion.state <= max_cstate)) {
 		if (sleep_ticks > cx->promotion.threshold.ticks) {
 			cx->promotion.count++;
  			cx->demotion.count = 0;
@@ -501,6 +525,13 @@
 
 end:
 	/*
+	 * Demote if current state exceeds max_cstate
+	 */
+	if (pr->power.state > max_cstate) {
+		next_state = max_cstate;
+	}
+
+	/*
 	 * New Cx State?
 	 * -------------
 	 * If we're going to start using a new Cx state we must clean up
@@ -762,7 +793,10 @@
  * policy is adjusted accordingly.
  */
 
-static int acpi_processor_ppc_is_init = 0;
+#define PPC_REGISTERED   1
+#define PPC_IN_USE       2
+
+static int acpi_processor_ppc_status = 0;
 
 static int acpi_processor_ppc_notifier(struct notifier_block *nb, 
 	unsigned long event,
@@ -820,6 +854,10 @@
 	 * (e.g. 0 = states 0..n; 1 = states 1..n; etc.
 	 */
 	status = acpi_evaluate_integer(pr->handle, "_PPC", NULL, &ppc);
+
+	if (status != AE_NOT_FOUND)
+		acpi_processor_ppc_status |= PPC_IN_USE;
+
 	if(ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n"));
 		return_VALUE(-ENODEV);
@@ -844,17 +882,17 @@
 
 static void acpi_processor_ppc_init(void) {
 	if (!cpufreq_register_notifier(&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER))
-		acpi_processor_ppc_is_init = 1;
+		acpi_processor_ppc_status |= PPC_REGISTERED;
 	else
 		printk(KERN_DEBUG "Warning: Processor Platform Limit not supported.\n");
 }
 
 
 static void acpi_processor_ppc_exit(void) {
-	if (acpi_processor_ppc_is_init)
+	if (acpi_processor_ppc_status & PPC_REGISTERED)
 		cpufreq_unregister_notifier(&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER);
 
-	acpi_processor_ppc_is_init = 0;
+	acpi_processor_ppc_status &= ~PPC_REGISTERED;
 }
 
 /*
@@ -966,7 +1004,7 @@
 	struct acpi_buffer	format = {sizeof("NNNNNN"), "NNNNNN"};
 	struct acpi_buffer	state = {0, NULL};
 	union acpi_object 	*pss = NULL;
-	int			i = 0;
+	unsigned int		i;
 
 	ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states");
 
@@ -1074,6 +1112,73 @@
 }
 
 
+int acpi_processor_notify_smm(struct module *calling_module) {
+	acpi_status		status;
+	static int		is_done = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_processor_notify_smm");
+
+	if (!(acpi_processor_ppc_status & PPC_REGISTERED))
+		return_VALUE(-EBUSY);
+
+	if (!try_module_get(calling_module))
+		return_VALUE(-EINVAL);
+
+	/* is_done is set to negative if an error occured,
+	 * and to postitive if _no_ error occured, but SMM
+	 * was already notified. This avoids double notification
+	 * which might lead to unexpected results...
+	 */
+	if (is_done > 0) {
+		module_put(calling_module);
+		return_VALUE(0);
+	}
+	else if (is_done < 0) {
+		module_put(calling_module);
+		return_VALUE(is_done);
+	}
+
+	is_done = -EIO;
+
+	/* Can't write pstate_cnt to smi_cmd if either value is zero */
+	if ((!acpi_fadt.smi_cmd) ||
+	    (!acpi_fadt.pstate_cnt)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"No SMI port or pstate_cnt\n"));
+		module_put(calling_module);
+		return_VALUE(0);
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Writing pstate_cnt [0x%x] to smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd));
+
+	/* FADT v1 doesn't support pstate_cnt, many BIOS vendors use
+	 * it anyway, so we need to support it... */
+	if (acpi_fadt_is_v1) {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Using v1.0 FADT reserved value for pstate_cnt\n"));
+	}
+
+	status = acpi_os_write_port (acpi_fadt.smi_cmd,
+				     (u32) acpi_fadt.pstate_cnt, 8);
+	if (ACPI_FAILURE (status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+				  "Failed to write pstate_cnt [0x%x] to "
+				  "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd));
+		module_put(calling_module);
+		return_VALUE(status);
+	}
+
+	/* Success. If there's no _PPC, we need to fear nothing, so
+	 * we can allow the cpufreq driver to be rmmod'ed. */
+	is_done = 1;
+
+	if (!(acpi_processor_ppc_status & PPC_IN_USE))
+		module_put(calling_module);
+
+	return_VALUE(0);
+}
+EXPORT_SYMBOL(acpi_processor_notify_smm);
+
+
 #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
 /* /proc/acpi/processor/../performance interface (DEPRECATED) */
 
@@ -1088,7 +1193,7 @@
 static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
 {
 	struct acpi_processor	*pr = (struct acpi_processor *)seq->private;
-	int			i = 0;
+	unsigned int		i;
 
 	ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");
 
@@ -1114,7 +1219,7 @@
 			(u32) pr->performance->states[i].transition_latency);
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
@@ -1230,7 +1335,7 @@
 
 	ACPI_FUNCTION_TRACE("acpi_processor_register_performance");
 
-	if (!acpi_processor_ppc_is_init)
+	if (!(acpi_processor_ppc_status & PPC_REGISTERED))
 		return_VALUE(-EINVAL);
 
 	down(&performance_sem);
@@ -1271,9 +1376,6 @@
 
 	ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance");
 
-	if (!acpi_processor_ppc_is_init)
-		return_VOID;
-
 	down(&performance_sem);
 
 	pr = processors[cpu];
@@ -1839,7 +1941,7 @@
 			pr->flags.limit ? "yes" : "no");
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
@@ -1851,7 +1953,7 @@
 static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
 {
 	struct acpi_processor	*pr = (struct acpi_processor *)seq->private;
-	int			i = 0;
+	unsigned int		i;
 
 	ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show");
 
@@ -1860,9 +1962,11 @@
 
 	seq_printf(seq, "active state:            C%d\n"
 			"default state:           C%d\n"
+			"max_cstate:              C%d\n"
 			"bus master activity:     %08x\n",
 			pr->power.state,
 			pr->power.default_state,
+			max_cstate,
 			pr->power.bm_activity);
 
 	seq_puts(seq, "states:\n");
@@ -1894,7 +1998,7 @@
 	}
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
@@ -1938,7 +2042,7 @@
 			(pr->throttling.states[i].performance?pr->throttling.states[i].performance/10:0));
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_processor_throttling_open_fs(struct inode *inode, struct file *file)
@@ -1999,7 +2103,7 @@
 			pr->limit.thermal.px, pr->limit.thermal.tx);
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
@@ -2374,22 +2478,28 @@
 
 	/*
 	 * Install the idle handler if processor power management is supported.
-	 * Note that the default idle handler (default_idle) will be used on 
+	 * Note that we use previously set idle handler will be used on 
 	 * platforms that only support C1.
 	 */
-	if ((pr->id == 0) && (pr->flags.power)) {
-		pm_idle_save = pm_idle;
-		pm_idle = acpi_processor_idle;
+	if ((pr->flags.power) && (!boot_option_idle_override)) {
+		printk(KERN_INFO PREFIX "%s [%s] (supports",
+			acpi_device_name(device), acpi_device_bid(device));
+		for (i = 1; i < ACPI_C_STATE_COUNT; i++)
+			if (pr->power.states[i].valid)
+				printk(" C%d", i);
+		printk(")\n");
+		if (pr->id == 0) {
+			pm_idle_save = pm_idle;
+			pm_idle = acpi_processor_idle;
+		}
 	}
 	
-	printk(KERN_INFO PREFIX "%s [%s] (supports",
-		acpi_device_name(device), acpi_device_bid(device));
-	for (i=1; i<ACPI_C_STATE_COUNT; i++)
-		if (pr->power.states[i].valid)
-			printk(" C%d", i);
-	if (pr->flags.throttling)
-		printk(", %d throttling states", pr->throttling.state_count);
-	printk(")\n");
+	if (pr->flags.throttling) {
+		printk(KERN_INFO PREFIX "%s [%s] (supports",
+			acpi_device_name(device), acpi_device_bid(device));
+		printk(" %d throttling states", pr->throttling.state_count);
+		printk(")\n");
+	}
 
 end:
 	if (result) {
@@ -2443,6 +2553,38 @@
 	return_VALUE(0);
 }
 
+/*
+ * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. 
+ * For now disable this. Probably a bug somewhere else.
+ *
+ * To skip this limit, boot/load with a large max_cstate limit.
+ */
+static int no_c2c3(struct dmi_system_id *id)
+{
+	if (max_cstate > ACPI_C_STATES_MAX)
+		return 0;
+
+	printk(KERN_NOTICE PREFIX "%s detected - C2,C3 disabled."
+		" Override with \"processor.max_cstate=9\"\n", id->ident);
+
+	max_cstate = 1;
+
+	return 0;
+}
+
+static struct dmi_system_id __initdata processor_dmi_table[] = { 
+	{ no_c2c3, "IBM ThinkPad R40e", {
+	  DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
+	  DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }},
+	{ no_c2c3, "Medion 41700", {
+	  DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
+	  DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J") }},
+	{},
+};
+
+/* We keep the driver loaded even when ACPI is not running. 
+   This is needed for the powernow-k8 driver, that works even without
+   ACPI, but needs symbols from this driver */
 
 static int __init
 acpi_processor_init (void)
@@ -2456,19 +2598,24 @@
 
 	acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
 	if (!acpi_processor_dir)
-		return_VALUE(-ENODEV);
+		return_VALUE(0);
 	acpi_processor_dir->owner = THIS_MODULE;
 
 	result = acpi_bus_register_driver(&acpi_processor_driver);
 	if (result < 0) {
 		remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
-		return_VALUE(-ENODEV);
+		return_VALUE(0);
 	}
 
 	acpi_thermal_cpufreq_init();
 
 	acpi_processor_ppc_init();
 
+	dmi_check_system(processor_dmi_table); 
+
+	if (max_cstate < ACPI_C_STATES_MAX)
+		printk(KERN_NOTICE "ACPI: processor limited to max C-state %d\n", max_cstate);
+
 	return_VALUE(0);
 }
 
@@ -2492,5 +2639,6 @@
 
 module_init(acpi_processor_init);
 module_exit(acpi_processor_exit);
+module_param_named(max_cstate, max_cstate, uint, 0);
 
 EXPORT_SYMBOL(acpi_processor_set_thermal_limit);
diff -Nru a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile
--- a/drivers/acpi/resources/Makefile	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/resources/Makefile	2004-12-24 13:36:18 -08:00
@@ -3,6 +3,8 @@
 #
 
 obj-y := rsaddr.o  rscreate.o  rsio.o   rslist.o    rsmisc.o   rsxface.o \
-	 rscalc.o  rsdump.o    rsirq.o  rsmemory.o  rsutils.o
+	 rscalc.o  rsirq.o  rsmemory.o  rsutils.o
+
+obj-$(ACPI_FUTURE_USAGE) += rsdump.o
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
--- a/drivers/acpi/resources/rscalc.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/acpi/resources/rscalc.c	2004-12-24 13:36:55 -08:00
@@ -74,7 +74,6 @@
 {
 	acpi_size                       byte_stream_size_needed = 0;
 	acpi_size                       segment_size;
-	struct acpi_resource_ext_irq    *ex_irq = NULL;
 	u8                              done = FALSE;
 
 
@@ -91,8 +90,8 @@
 		case ACPI_RSTYPE_IRQ:
 			/*
 			 * IRQ Resource
-			 * For an IRQ Resource, Byte 3, although optional, will
-			 * always be created - it holds IRQ information.
+			 * For an IRQ Resource, Byte 3, although optional, will always be
+			 * created - it holds IRQ information.
 			 */
 			segment_size = 4;
 			break;
@@ -108,8 +107,8 @@
 		case ACPI_RSTYPE_START_DPF:
 			/*
 			 * Start Dependent Functions Resource
-			 * For a start_dependent_functions Resource, Byte 1,
-			 * although optional, will always be created.
+			 * For a start_dependent_functions Resource, Byte 1, although
+			 * optional, will always be created.
 			 */
 			segment_size = 2;
 			break;
@@ -141,10 +140,9 @@
 		case ACPI_RSTYPE_VENDOR:
 			/*
 			 * Vendor Defined Resource
-			 * For a Vendor Specific resource, if the Length is
-			 * between 1 and 7 it will be created as a Small
-			 * Resource data type, otherwise it is a Large
-			 * Resource data type.
+			 * For a Vendor Specific resource, if the Length is between 1 and 7
+			 * it will be created as a Small Resource data type, otherwise it
+			 * is a Large Resource data type.
 			 */
 			if (linked_list->data.vendor_specific.length > 7) {
 				segment_size = 3;
@@ -191,10 +189,9 @@
 		case ACPI_RSTYPE_ADDRESS16:
 			/*
 			 * 16-Bit Address Resource
-			 * The base size of this byte stream is 16. If a
-			 * Resource Source string is not NULL, add 1 for
-			 * the Index + the length of the null terminated
-			 * string Resource Source + 1 for the null.
+			 * The base size of this byte stream is 16. If a Resource Source
+			 * string is not NULL, add 1 for the Index + the length of the null
+			 * terminated string Resource Source + 1 for the null.
 			 */
 			segment_size = 16;
 
@@ -223,10 +220,9 @@
 		case ACPI_RSTYPE_ADDRESS64:
 			/*
 			 * 64-Bit Address Resource
-			 * The base size of this byte stream is 46. If a Resource
-			 * Source string is not NULL, add 1 for the Index + the
-			 * length of the null terminated string Resource Source +
-			 * 1 for the null.
+			 * The base size of this byte stream is 46. If a resource_source
+			 * string is not NULL, add 1 for the Index + the length of the null
+			 * terminated string Resource Source + 1 for the null.
 			 */
 			segment_size = 46;
 
@@ -239,9 +235,8 @@
 		case ACPI_RSTYPE_EXT_IRQ:
 			/*
 			 * Extended IRQ Resource
-			 * The base size of this byte stream is 9. This is for an
-			 * Interrupt table length of 1.  For each additional
-			 * interrupt, add 4.
+			 * The base size of this byte stream is 9. This is for an Interrupt
+			 * table length of 1.  For each additional interrupt, add 4.
 			 * If a Resource Source string is not NULL, add 1 for the
 			 * Index + the length of the null terminated string
 			 * Resource Source + 1 for the null.
@@ -249,7 +244,7 @@
 			segment_size = 9 +
 				(((acpi_size) linked_list->data.extended_irq.number_of_interrupts - 1) * 4);
 
-			if (ex_irq && ex_irq->resource_source.string_ptr) {
+			if (linked_list->data.extended_irq.resource_source.string_ptr) {
 				segment_size += linked_list->data.extended_irq.resource_source.string_length;
 				segment_size++;
 			}
@@ -257,8 +252,7 @@
 
 		default:
 			/*
-			 * If we get here, everything is out of sync,
-			 * so exit with an error
+			 * If we get here, everything is out of sync, exit with error
 			 */
 			return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
 
@@ -366,7 +360,6 @@
 			/*
 			 * 32-Bit Memory Range Resource
 			 */
-
 			bytes_consumed = 20;
 
 			structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32);
@@ -395,14 +388,12 @@
 			bytes_consumed = temp16 + 3;
 
 			/*
-			 * Resource Source Index and Resource Source are
-			 * optional elements.  Check the length of the
-			 * Bytestream.  If it is greater than 43, that
-			 * means that an Index exists and is followed by
-			 * a null termininated string.  Therefore, set
-			 * the temp variable to the length minus the minimum
-			 * byte stream length plus the byte for the Index to
-			 * determine the size of the NULL terminiated string.
+			 * Resource Source Index and Resource Source are optional elements.
+			 * Check the length of the Bytestream.  If it is greater than 43,
+			 * that means that an Index exists and is followed by a null
+			 * terminated string.  Therefore, set the temp variable to the
+			 * length minus the minimum byte stream length plus the byte for
+			 * the Index to determine the size of the NULL terminated string.
 			 */
 			if (43 < temp16) {
 				temp8 = (u8) (temp16 - 44);
@@ -433,14 +424,12 @@
 			bytes_consumed = temp16 + 3;
 
 			/*
-			 * Resource Source Index and Resource Source are
-			 * optional elements.  Check the length of the
-			 * Bytestream.  If it is greater than 23, that
-			 * means that an Index exists and is followed by
-			 * a null termininated string.  Therefore, set
-			 * the temp variable to the length minus the minimum
-			 * byte stream length plus the byte for the Index to
-			 * determine the size of the NULL terminiated string.
+			 * Resource Source Index and Resource Source are optional elements.
+			 * Check the length of the Bytestream.  If it is greater than 23,
+			 * that means that an Index exists and is followed by a null
+			 * terminated string.  Therefore, set the temp variable to the
+			 * length minus the minimum byte stream length plus the byte for
+			 * the Index to determine the size of the NULL terminated string.
 			 */
 			if (23 < temp16) {
 				temp8 = (u8) (temp16 - 24);
@@ -471,14 +460,12 @@
 			bytes_consumed = temp16 + 3;
 
 			/*
-			 * Resource Source Index and Resource Source are
-			 * optional elements.  Check the length of the
-			 * Bytestream.  If it is greater than 13, that
-			 * means that an Index exists and is followed by
-			 * a null termininated string.  Therefore, set
-			 * the temp variable to the length minus the minimum
-			 * byte stream length plus the byte for the Index to
-			 * determine the size of the NULL terminiated string.
+			 * Resource Source Index and Resource Source are optional elements.
+			 * Check the length of the Bytestream.  If it is greater than 13,
+			 * that means that an Index exists and is followed by a null
+			 * terminated string.  Therefore, set the temp variable to the
+			 * length minus the minimum byte stream length plus the byte for
+			 * the Index to determine the size of the NULL terminated string.
 			 */
 			if (13 < temp16) {
 				temp8 = (u8) (temp16 - 14);
@@ -509,9 +496,8 @@
 			bytes_consumed = temp16 + 3;
 
 			/*
-			 * Point past the length field and the
-			 * Interrupt vector flags to save off the
-			 * Interrupt table length to the Temp8 variable.
+			 * Point past the length field and the Interrupt vector flags to
+			 * save off the Interrupt table length to the Temp8 variable.
 			 */
 			buffer += 3;
 			temp8 = *buffer;
@@ -523,14 +509,12 @@
 			additional_bytes = (u8) ((temp8 - 1) * 4);
 
 			/*
-			 * Resource Source Index and Resource Source are
-			 * optional elements.  Check the length of the
-			 * Bytestream.  If it is greater than 9, that
-			 * means that an Index exists and is followed by
-			 * a null termininated string.  Therefore, set
-			 * the temp variable to the length minus the minimum
-			 * byte stream length plus the byte for the Index to
-			 * determine the size of the NULL terminiated string.
+			 * Resource Source Index and Resource Source are optional elements.
+			 * Check the length of the Bytestream.  If it is greater than 9,
+			 * that means that an Index exists and is followed by a null
+			 * terminated string.  Therefore, set the temp variable to the
+			 * length minus the minimum byte stream length plus the byte for
+			 * the Index to determine the size of the NULL terminated string.
 			 */
 			if (9 + additional_bytes < temp16) {
 				temp8 = (u8) (temp16 - (9 + additional_bytes));
@@ -565,9 +549,8 @@
 				bytes_consumed = 3;
 			}
 
-			/*
-			 * Point past the descriptor
-			 */
+			/* Point past the descriptor */
+
 			++buffer;
 
 			/*
@@ -595,9 +578,8 @@
 			buffer = byte_stream_buffer;
 			bytes_consumed = 3;
 
-			/*
-			 * Point past the descriptor
-			 */
+			/* Point past the descriptor */
+
 			++buffer;
 
 			/*
diff -Nru a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
--- a/drivers/acpi/resources/rsutils.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/resources/rsutils.c	2004-12-24 13:36:18 -08:00
@@ -175,7 +175,7 @@
  *              and the contents of the callers buffer is undefined.
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_rs_get_prs_method_data (
 	acpi_handle                     handle,
@@ -210,6 +210,7 @@
 	acpi_ut_remove_reference (obj_desc);
 	return_ACPI_STATUS (status);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
diff -Nru a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
--- a/drivers/acpi/resources/rsxface.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/acpi/resources/rsxface.c	2004-12-24 13:37:02 -08:00
@@ -41,6 +41,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acresrc.h>
@@ -156,6 +157,7 @@
 	status = acpi_rs_get_crs_method_data (device_handle, ret_buffer);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_get_current_resources);
 
 
 /*******************************************************************************
@@ -178,7 +180,7 @@
  *              and the value of ret_buffer is undefined.
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_get_possible_resources (
 	acpi_handle                     device_handle,
@@ -208,6 +210,8 @@
 	status = acpi_rs_get_prs_method_data (device_handle, ret_buffer);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_get_possible_resources);
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
@@ -310,6 +314,7 @@
 	acpi_os_free (buffer.pointer);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_walk_resources);
 
 
 /*******************************************************************************
@@ -354,6 +359,7 @@
 	status = acpi_rs_set_srs_method_data (device_handle, in_buffer);
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_set_current_resources);
 
 
 #define ACPI_COPY_FIELD(out, in, field)  ((out)->field = (in)->field)
@@ -427,3 +433,5 @@
 
 	return (AE_OK);
 }
+EXPORT_SYMBOL(acpi_resource_to_address64);
+
diff -Nru a/drivers/acpi/scan.c b/drivers/acpi/scan.c
--- a/drivers/acpi/scan.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/acpi/scan.c	2004-12-24 13:36:48 -08:00
@@ -4,6 +4,7 @@
 
 #include <linux/init.h>
 #include <linux/acpi.h>
+#include <linux/module.h>
 
 #include <acpi/acpi_drivers.h>
 #include <acpi/acinterp.h>	/* for acpi_ex_eisa_id_to_string() */
@@ -158,10 +159,10 @@
 
 	device->power.state = ACPI_STATE_UNKNOWN;
 
-	return 0;
+	return_VALUE(0);
 }
 
-static int
+int
 acpi_match_ids (
 	struct acpi_device	*device,
 	char			*ids)
@@ -280,7 +281,7 @@
 end:
 	if (ACPI_FAILURE(status))
 		device->flags.wake_capable = 0;
-	return 0;
+	return_VALUE(0);
 }
 
 /* --------------------------------------------------------------------------
@@ -314,6 +315,8 @@
 	struct acpi_device	*device,
 	struct acpi_driver	*driver)
 {
+	if (driver && driver->ops.match)
+		return driver->ops.match(device, driver);
 	return acpi_match_ids(device, driver->ids);
 }
 
@@ -451,6 +454,7 @@
 
 	return_VALUE(count);
 }
+EXPORT_SYMBOL(acpi_bus_register_driver);
 
 
 /**
@@ -479,6 +483,7 @@
 		error = -EINVAL;
 	return_VALUE(error);
 }
+EXPORT_SYMBOL(acpi_bus_unregister_driver);
 
 /**
  * acpi_bus_find_driver 
@@ -495,9 +500,6 @@
 
 	ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
 
-	if (!device->flags.hardware_id && !device->flags.compatible_ids)
-		goto Done;
-
 	spin_lock(&acpi_device_lock);
 	list_for_each_safe(node,next,&acpi_bus_drivers) {
 		struct acpi_driver * driver = container_of(node,struct acpi_driver,node);
@@ -762,7 +764,7 @@
 #endif /*CONFIG_ACPI_DEBUG_OUTPUT*/
 }
 
-static int 
+int 
 acpi_bus_add (
 	struct acpi_device	**child,
 	struct acpi_device	*parent,
@@ -906,7 +908,7 @@
 
 	return_VALUE(result);
 }
-
+EXPORT_SYMBOL(acpi_bus_add);
 
 
 static int acpi_bus_scan (struct acpi_device	*start)
@@ -1010,6 +1012,7 @@
 
 	return_VALUE(0);
 }
+EXPORT_SYMBOL(acpi_bus_scan);
 
 
 static int
diff -Nru a/drivers/acpi/sleep/Makefile b/drivers/acpi/sleep/Makefile
--- a/drivers/acpi/sleep/Makefile	2004-12-24 13:37:18 -08:00
+++ b/drivers/acpi/sleep/Makefile	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,5 @@
-obj-y					:= poweroff.o
-obj-$(CONFIG_ACPI_SLEEP)		+= main.o wakeup.o
+obj-y					:= poweroff.o wakeup.o
+obj-$(CONFIG_ACPI_SLEEP)		+= main.o
 obj-$(CONFIG_ACPI_SLEEP_PROC_FS)	+= proc.o
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -Nru a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
--- a/drivers/acpi/sleep/main.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/acpi/sleep/main.c	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,7 @@
 /*
  * sleep.c - ACPI sleep support.
  *
+ * Copyright (c) 2004 David Shaohua Li <shaohua.li@intel.com>
  * Copyright (c) 2000-2003 Patrick Mochel
  * Copyright (c) 2003 Open Source Development Lab
  *
@@ -13,6 +14,7 @@
 #include <linux/dmi.h>
 #include <linux/device.h>
 #include <linux/suspend.h>
+#include <asm/io.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 #include "sleep.h"
@@ -42,7 +44,7 @@
  *	wakeup code to the waking vector. 
  */
 
-static int acpi_pm_prepare(u32 pm_state)
+static int acpi_pm_prepare(suspend_state_t pm_state)
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
 
@@ -56,7 +58,8 @@
 		if (!acpi_wakeup_address)
 			return -EFAULT;
 		acpi_set_firmware_waking_vector(
-			(acpi_physical_address) acpi_wakeup_address);
+			(acpi_physical_address) virt_to_phys(
+				(void *)acpi_wakeup_address));
 	}
 	ACPI_FLUSH_CPU_CACHE();
 	acpi_enable_wakeup_device_prep(acpi_state);
@@ -74,7 +77,7 @@
  *	It's unfortunate, but it works. Please fix if you're feeling frisky.
  */
 
-static int acpi_pm_enter(u32 pm_state)
+static int acpi_pm_enter(suspend_state_t pm_state)
 {
 	acpi_status status = AE_OK;
 	unsigned long flags = 0;
@@ -136,7 +139,7 @@
  *	failed). 
  */
 
-static int acpi_pm_finish(u32 pm_state)
+static int acpi_pm_finish(suspend_state_t pm_state)
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
 
diff -Nru a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
--- a/drivers/acpi/sleep/poweroff.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/acpi/sleep/poweroff.c	2004-12-24 13:37:29 -08:00
@@ -9,6 +9,7 @@
 #include <linux/init.h>
 #include <acpi/acpi_bus.h>
 #include <linux/sched.h>
+#include "sleep.h"
 
 static void
 acpi_power_off (void)
@@ -16,6 +17,7 @@
 	printk("%s called\n",__FUNCTION__);
 	/* Some SMP machines only can poweroff in boot CPU */
 	set_cpus_allowed(current, cpumask_of_cpu(0));
+	acpi_wakeup_gpe_poweroff_prepare();
 	acpi_enter_sleep_state_prep(ACPI_STATE_S5);
 	ACPI_DISABLE_IRQS();
 	acpi_enter_sleep_state(ACPI_STATE_S5);
diff -Nru a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
--- a/drivers/acpi/sleep/proc.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/acpi/sleep/proc.c	2004-12-24 13:37:01 -08:00
@@ -70,7 +70,7 @@
 	state = simple_strtoul(str, NULL, 0);
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	if (state == 4) {
-		software_suspend();
+		error = software_suspend();
 		goto Done;
 	}
 #endif
diff -Nru a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep/sleep.h
--- a/drivers/acpi/sleep/sleep.h	2004-12-24 13:37:04 -08:00
+++ b/drivers/acpi/sleep/sleep.h	2004-12-24 13:37:04 -08:00
@@ -5,3 +5,4 @@
 extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
 extern void acpi_enable_wakeup_device(u8 sleep_state);
 extern void acpi_disable_wakeup_device(u8 sleep_state);
+extern void acpi_wakeup_gpe_poweroff_prepare(void);
diff -Nru a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c
--- a/drivers/acpi/sleep/wakeup.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/acpi/sleep/wakeup.c	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,6 @@
 /*
  * wakeup.c - support wakeup devices
+ * Copyright (C) 2004 Li Shaohua <shaohua.li@intel.com>
  */
 
 #include <linux/init.h>
@@ -13,14 +14,16 @@
 #define _COMPONENT		ACPI_SYSTEM_COMPONENT
 ACPI_MODULE_NAME		("wakeup_devices")
 
+extern struct list_head	acpi_wakeup_device_list;
+extern spinlock_t acpi_device_lock;
+
+#ifdef CONFIG_ACPI_SLEEP
 /**
  * acpi_enable_wakeup_device_prep - prepare wakeup devices
  *	@sleep_state:	ACPI state
  * Enable all wakup devices power if the devices' wakeup level
  * is higher than requested sleep level
  */
-extern struct list_head	acpi_wakeup_device_list;
-extern spinlock_t acpi_device_lock;
 
 void
 acpi_enable_wakeup_device_prep(
@@ -179,3 +182,28 @@
 }
 
 late_initcall(acpi_wakeup_device_init);
+#endif
+
+/*
+ * Disable all wakeup GPEs before power off.
+ * 
+ * Since acpi_enter_sleep_state() will disable all
+ * RUNTIME GPEs, we simply mark all GPES that
+ * are not enabled for wakeup from S5 as RUNTIME.
+ */
+void acpi_wakeup_gpe_poweroff_prepare(void)
+{
+	struct list_head * node, * next;
+
+	list_for_each_safe(node, next, &acpi_wakeup_device_list) {
+		struct acpi_device * dev = container_of(node,
+			struct acpi_device, wakeup_list);
+
+		/* The GPE can wakeup system from S5, don't touch it */
+		if ((u32)dev->wakeup.sleep_state == ACPI_STATE_S5)
+			continue;
+		/* acpi_set_gpe_type will automatically disable GPE */
+		acpi_set_gpe_type(dev->wakeup.gpe_device,
+			dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME);
+	}
+}
diff -Nru a/drivers/acpi/system.c b/drivers/acpi/system.c
--- a/drivers/acpi/system.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/acpi/system.c	2004-12-24 13:37:00 -08:00
@@ -24,6 +24,7 @@
  */
 
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
 
@@ -48,35 +49,26 @@
    -------------------------------------------------------------------------- */
 
 static int
-acpi_system_read_info (
-	char			*page,
-	char			**start,
-	off_t			off,
-	int 			count,
-	int 			*eof,
-	void			*data)
+acpi_system_read_info (struct seq_file *seq, void *offset)
 {
-	char			*p = page;
-	int			size = 0;
-
 	ACPI_FUNCTION_TRACE("acpi_system_read_info");
 
-	if (off != 0)
-		goto end;
-
-	p += sprintf(p, "version:                 %x\n", ACPI_CA_VERSION);
-
-end:
-	size = (p - page);
-	if (size <= off+count) *eof = 1;
-	*start = page + off;
-	size -= off;
-	if (size>count) size = count;
-	if (size<0) size = 0;
+	seq_printf(seq, "version:                 %x\n", ACPI_CA_VERSION);
+	return_VALUE(0);
+}
 
-	return_VALUE(size);
+static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_system_read_info, PDE(inode)->data);
 }
 
+static struct file_operations acpi_system_info_ops = {
+	.open		= acpi_system_info_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 static ssize_t acpi_system_read_dsdt (struct file*, char __user *, size_t, loff_t*);
 
 static struct file_operations acpi_system_dsdt_ops = {
@@ -152,10 +144,13 @@
 
 	/* 'info' [R] */
 	name = ACPI_SYSTEM_FILE_INFO;
-	entry = create_proc_read_entry(name,
-		S_IRUGO, acpi_root_dir, acpi_system_read_info,NULL);
+	entry = create_proc_entry(name,
+		S_IRUGO, acpi_root_dir);
 	if (!entry)
 		goto Error;
+	else {
+		entry->proc_fops = &acpi_system_info_ops;
+	}
 
 	/* 'dsdt' [R] */
 	name = ACPI_SYSTEM_FILE_DSDT;
diff -Nru a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
--- a/drivers/acpi/tables/tbconvrt.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/acpi/tables/tbconvrt.c	2004-12-24 13:36:48 -08:00
@@ -41,6 +41,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/actables.h>
@@ -50,6 +51,9 @@
 	 ACPI_MODULE_NAME    ("tbconvrt")
 
 
+u8 acpi_fadt_is_v1;
+EXPORT_SYMBOL(acpi_fadt_is_v1);
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_tb_get_table_count
@@ -212,6 +216,7 @@
 
 	/* ACPI 1.0 FACS */
 	/* The BIOS stored FADT should agree with Revision 1.0 */
+	acpi_fadt_is_v1 = 1;
 
 	/*
 	 * Copy the table header and the common part of the tables.
@@ -240,9 +245,12 @@
 	/*
 	 * Processor Performance State Control. This is the value OSPM writes to
 	 * the SMI_CMD register to assume processor performance state control
-	 * responsibility. There isn't any equivalence in 1.0, leave it zeroed.
+	 * responsibility. There isn't any equivalence in 1.0, but as many 1.x
+	 * ACPI tables contain _PCT and _PSS we also keep this value, unless
+	 * acpi_strict is set.
 	 */
-	local_fadt->pstate_cnt = 0;
+	if (acpi_strict)
+		local_fadt->pstate_cnt = 0;
 
 	/*
 	 * Support for the _CST object and C States change notification.
@@ -251,10 +259,26 @@
 	local_fadt->cst_cnt = 0;
 
 	/*
-	 * Since there isn't any equivalence in 1.0 and since it highly likely
-	 * that a 1.0 system has legacy support.
+	 * FADT Rev 2 was an interim FADT released between ACPI 1.0 and ACPI 2.0.
+	 * It primarily adds the FADT reset mechanism.
 	 */
-	local_fadt->iapc_boot_arch = BAF_LEGACY_DEVICES;
+	if ((original_fadt->revision == 2) &&
+		(original_fadt->length == sizeof (struct fadt_descriptor_rev2_minus))) {
+		/*
+		 * Grab the entire generic address struct, plus the 1-byte reset value
+		 * that immediately follows.
+		 */
+		ACPI_MEMCPY (&local_fadt->reset_register,
+			&((struct fadt_descriptor_rev2_minus *) original_fadt)->reset_register,
+			sizeof (struct acpi_generic_address) + 1);
+	}
+	else {
+		/*
+		 * Since there isn't any equivalence in 1.0 and since it is highly
+		 * likely that a 1.0 system has legacy support.
+		 */
+		local_fadt->iapc_boot_arch = BAF_LEGACY_DEVICES;
+	}
 
 	/*
 	 * Convert the V1.0 block addresses to V2.0 GAS structures
@@ -418,21 +442,19 @@
 
 
 	/*
-	 * acpi_gbl_FADT is valid
-	 * Allocate and zero the 2.0 FADT buffer
-	 */
-	local_fadt = ACPI_MEM_CALLOCATE (sizeof (struct fadt_descriptor_rev2));
-	if (local_fadt == NULL) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
-	}
-
-	/*
-	 * FADT length and version validation.  The table must be at least as
-	 * long as the version 1.0 FADT
+	 * acpi_gbl_FADT is valid. Validate the FADT length. The table must be
+	 * at least as long as the version 1.0 FADT
 	 */
 	if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) {
-		ACPI_REPORT_ERROR (("Invalid FADT table length: 0x%X\n", acpi_gbl_FADT->length));
+		ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", acpi_gbl_FADT->length));
 		return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+	}
+
+	/* Allocate buffer for the ACPI 2.0(+) FADT */
+
+	local_fadt = ACPI_MEM_CALLOCATE (sizeof (struct fadt_descriptor_rev2));
+	if (!local_fadt) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
 	if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
diff -Nru a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
--- a/drivers/acpi/tables/tbget.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/acpi/tables/tbget.c	2004-12-24 13:37:01 -08:00
@@ -167,6 +167,9 @@
 		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n",
+		return_header->signature));
+
 	return_ACPI_STATUS (AE_OK);
 }
 
diff -Nru a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
--- a/drivers/acpi/tables/tbinstal.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/acpi/tables/tbinstal.c	2004-12-24 13:36:31 -08:00
@@ -266,9 +266,10 @@
 	if (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags)) {
 		/*
 		 * Only one table allowed, and a table has alread been installed
-		 *  at this location, so return an error.
+		 * at this location, so return an error.
 		 */
 		if (list_head->next) {
+			ACPI_MEM_FREE (table_desc);
 			return_ACPI_STATUS (AE_ALREADY_EXISTS);
 		}
 
diff -Nru a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
--- a/drivers/acpi/tables/tbutils.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/acpi/tables/tbutils.c	2004-12-24 13:37:18 -08:00
@@ -62,7 +62,7 @@
  *              return a pointer to that table descriptor.
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_tb_handle_to_object (
 	u16                             table_id,
@@ -90,6 +90,7 @@
 	ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id));
 	return (AE_BAD_PARAMETER);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
diff -Nru a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
--- a/drivers/acpi/tables/tbxface.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/acpi/tables/tbxface.c	2004-12-24 13:37:19 -08:00
@@ -42,6 +42,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
@@ -137,6 +138,8 @@
 }
 
 
+#ifdef ACPI_FUTURE_USAGE
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_load_table
@@ -343,6 +346,8 @@
 }
 
 
+#endif  /*  ACPI_FUTURE_USAGE  */
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_get_table
@@ -439,5 +444,5 @@
 	ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length);
 	return_ACPI_STATUS (AE_OK);
 }
-
+EXPORT_SYMBOL(acpi_get_table);
 
diff -Nru a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
--- a/drivers/acpi/tables/tbxfroot.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/acpi/tables/tbxfroot.c	2004-12-24 13:37:04 -08:00
@@ -41,6 +41,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/actables.h>
@@ -87,12 +88,28 @@
 		return_ACPI_STATUS (AE_AML_STRING_LIMIT);
 	}
 
-	/* Find the table */
+	if (!ACPI_STRNCMP (signature, DSDT_SIG, ACPI_NAME_SIZE)) {
+		/*
+		 * The DSDT pointer is contained in the FADT, not the RSDT.
+		 * This code should suffice, because the only code that would perform
+		 * a "find" on the DSDT is the data_table_region() AML opcode -- in
+		 * which case, the DSDT is guaranteed to be already loaded.
+		 * If this becomes insufficient, the FADT will have to be found first.
+		 */
+		if (!acpi_gbl_DSDT) {
+			return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+		}
 
-	status = acpi_get_firmware_table (signature, 1,
-			   ACPI_LOGICAL_ADDRESSING, &table);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
+		table = acpi_gbl_DSDT;
+	}
+	else {
+		/* Find the table */
+
+		status = acpi_get_firmware_table (signature, 1,
+				   ACPI_LOGICAL_ADDRESSING, &table);
+		if (ACPI_FAILURE (status)) {
+			return_ACPI_STATUS (status);
+		}
 	}
 
 	/* Check oem_id and oem_table_id */
@@ -102,6 +119,7 @@
 		return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
 	}
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", table->signature));
 	*table_ptr = table;
 	return_ACPI_STATUS (AE_OK);
 }
@@ -304,6 +322,7 @@
 	}
 	return_ACPI_STATUS (status);
 }
+EXPORT_SYMBOL(acpi_get_firmware_table);
 
 
 /* TBD: Move to a new file */
diff -Nru a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
--- a/drivers/acpi/thermal.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/acpi/thermal.c	2004-12-24 13:37:19 -08:00
@@ -60,7 +60,7 @@
 #define ACPI_THERMAL_NOTIFY_HOT		0xF1
 #define ACPI_THERMAL_MODE_ACTIVE	0x00
 #define ACPI_THERMAL_MODE_PASSIVE	0x01
-#define ACPI_THERMAL_MODE_CRT   	0xff
+#define ACPI_THERMAL_MODE_CRITICAL   	0xff
 #define ACPI_THERMAL_PATH_POWEROFF	"/sbin/poweroff"
 
 #define ACPI_THERMAL_MAX_ACTIVE	10
@@ -76,7 +76,7 @@
 MODULE_LICENSE("GPL");
 
 static int tzp;
-MODULE_PARM(tzp, "i");
+module_param(tzp, int, 0);
 MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n");
 
 
@@ -226,7 +226,7 @@
 
 	status = acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature);
 	if (ACPI_FAILURE(status))
-		return -ENODEV;
+		return_VALUE(-ENODEV);
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", tz->temperature));
 
@@ -328,7 +328,7 @@
 	if (ACPI_FAILURE(status)) {
 		tz->trips.critical.flags.valid = 0;
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n"));
-		return -ENODEV;
+		return_VALUE(-ENODEV);
 	}
 	else {
 		tz->trips.critical.flags.valid = 1;
@@ -801,7 +801,7 @@
 	}
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
@@ -828,7 +828,7 @@
 		KELVIN_TO_CELSIUS(tz->temperature));
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
@@ -881,7 +881,7 @@
 	}
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
@@ -953,14 +953,14 @@
 		seq_puts(seq, "<setting not supported>\n");
 	}
 
-	if ( tz->cooling_mode == ACPI_THERMAL_MODE_CRT )
+	if ( tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL )
 		seq_printf(seq, "cooling mode:	critical\n");
 	else
 		seq_printf(seq, "cooling mode:	%s\n",
 			tz->cooling_mode?"passive":"active");
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
@@ -1023,7 +1023,7 @@
 		(tz->polling_frequency / 10));
 
 end:
-	return 0;
+	return_VALUE(0);
 }
 
 static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
@@ -1262,7 +1262,7 @@
 			tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE;
 		} else {
 			/* _ACx and _PSV are optional, but _CRT is required */
-			tz->cooling_mode = ACPI_THERMAL_MODE_CRT;
+			tz->cooling_mode = ACPI_THERMAL_MODE_CRITICAL;
 		}
 	}
 
diff -Nru a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
--- a/drivers/acpi/utilities/utalloc.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/utilities/utalloc.c	2004-12-24 13:36:18 -08:00
@@ -265,7 +265,7 @@
  * RETURN:      Status
  *
  * DESCRIPTION: Validate that the buffer is of the required length or
- *              allocate a new buffer.
+ *              allocate a new buffer.  Returned buffer is always zeroed.
  *
  ******************************************************************************/
 
@@ -305,24 +305,25 @@
 
 		/* Allocate a new buffer with local interface to allow tracking */
 
-		buffer->pointer = ACPI_MEM_ALLOCATE (required_length);
+		buffer->pointer = ACPI_MEM_CALLOCATE (required_length);
 		if (!buffer->pointer) {
 			return (AE_NO_MEMORY);
 		}
-
-		/* Clear the buffer */
-
-		ACPI_MEMSET (buffer->pointer, 0, required_length);
 		break;
 
 
 	default:
 
-		/* Validate the size of the buffer */
+		/* Existing buffer: Validate the size of the buffer */
 
 		if (buffer->length < required_length) {
 			status = AE_BUFFER_OVERFLOW;
+			break;
 		}
+
+		/* Clear the buffer */
+
+		ACPI_MEMSET (buffer->pointer, 0, required_length);
 		break;
 	}
 
@@ -472,7 +473,7 @@
 	acpi_status                     status;
 
 
-	allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_block), component,
+	allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header), component,
 			  module, line);
 	if (!allocation) {
 		return (NULL);
@@ -518,7 +519,7 @@
 	acpi_status                     status;
 
 
-	allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_block), component,
+	allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header), component,
 			  module, line);
 	if (!allocation) {
 		/* Report allocation error */
@@ -712,6 +713,7 @@
 	allocation->line      = line;
 
 	ACPI_STRNCPY (allocation->module, module, ACPI_MAX_MODULE_NAME);
+	allocation->module[ACPI_MAX_MODULE_NAME-1] = 0;
 
 	/* Insert at list head */
 
@@ -816,7 +818,7 @@
  * DESCRIPTION: Print some info about the outstanding allocations.
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 void
 acpi_ut_dump_allocation_info (
 	void)
@@ -862,6 +864,7 @@
 */
 	return_VOID;
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
diff -Nru a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
--- a/drivers/acpi/utilities/utcopy.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/acpi/utilities/utcopy.c	2004-12-24 13:36:48 -08:00
@@ -424,23 +424,21 @@
 		break;
 
 	default:
-		/*
-		 * Whatever other type -- it is not supported
-		 */
+		/* All other types are not supported */
+
 		return_ACPI_STATUS (AE_SUPPORT);
 	}
 
 
-	switch (external_object->type) {
-
 	/* Must COPY string and buffer contents */
 
+	switch (external_object->type) {
 	case ACPI_TYPE_STRING:
 
 		internal_object->string.pointer =
 			ACPI_MEM_CALLOCATE ((acpi_size) external_object->string.length + 1);
 		if (!internal_object->string.pointer) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
+			goto error_exit;
 		}
 
 		ACPI_MEMCPY (internal_object->string.pointer,
@@ -456,7 +454,7 @@
 		internal_object->buffer.pointer =
 			ACPI_MEM_CALLOCATE (external_object->buffer.length);
 		if (!internal_object->buffer.pointer) {
-			return_ACPI_STATUS (AE_NO_MEMORY);
+			goto error_exit;
 		}
 
 		ACPI_MEMCPY (internal_object->buffer.pointer,
@@ -479,6 +477,11 @@
 
 	*ret_internal_object = internal_object;
 	return_ACPI_STATUS (AE_OK);
+
+
+error_exit:
+	acpi_ut_remove_reference (internal_object);
+	return_ACPI_STATUS (AE_NO_MEMORY);
 }
 
 
@@ -747,7 +750,7 @@
 
 			status = acpi_ut_copy_simple_object (source_object, target_object);
 			if (ACPI_FAILURE (status)) {
-				return (status);
+				goto error_exit;
 			}
 
 			*this_target_ptr = target_object;
@@ -781,8 +784,8 @@
 			ACPI_MEM_CALLOCATE (((acpi_size) source_object->package.count + 1) *
 					 sizeof (void *));
 		if (!target_object->package.elements) {
-			ACPI_MEM_FREE (target_object);
-			return (AE_NO_MEMORY);
+			status = AE_NO_MEMORY;
+			goto error_exit;
 		}
 
 		/*
@@ -801,6 +804,10 @@
 		return (AE_BAD_PARAMETER);
 	}
 
+	return (status);
+
+error_exit:
+	acpi_ut_remove_reference (target_object);
 	return (status);
 }
 
diff -Nru a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
--- a/drivers/acpi/utilities/utdebug.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/acpi/utilities/utdebug.c	2004-12-24 13:37:00 -08:00
@@ -41,6 +41,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 
@@ -178,6 +179,7 @@
 	va_start (args, format);
 	acpi_os_vprintf (format, args);
 }
+EXPORT_SYMBOL(acpi_ut_debug_print);
 
 
 /*****************************************************************************
@@ -219,6 +221,7 @@
 	va_start (args, format);
 	acpi_os_vprintf (format, args);
 }
+EXPORT_SYMBOL(acpi_ut_debug_print_raw);
 
 
 /*****************************************************************************
@@ -250,6 +253,7 @@
 	acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info,
 			"%s\n", acpi_gbl_fn_entry_str);
 }
+EXPORT_SYMBOL(acpi_ut_trace);
 
 
 /*****************************************************************************
@@ -378,6 +382,7 @@
 
 	acpi_gbl_nesting_level--;
 }
+EXPORT_SYMBOL(acpi_ut_exit);
 
 
 /*****************************************************************************
@@ -418,6 +423,7 @@
 
 	acpi_gbl_nesting_level--;
 }
+EXPORT_SYMBOL(acpi_ut_status_exit);
 
 
 /*****************************************************************************
@@ -451,6 +457,7 @@
 
 	acpi_gbl_nesting_level--;
 }
+EXPORT_SYMBOL(acpi_ut_value_exit);
 
 
 /*****************************************************************************
diff -Nru a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
--- a/drivers/acpi/utilities/utdelete.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/acpi/utilities/utdelete.c	2004-12-24 13:36:49 -08:00
@@ -621,6 +621,10 @@
 		return_VOID;
 	}
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+		"Obj %p Current Refs=%X [To Be Incremented]\n",
+		object, object->common.reference_count));
+
 	/* Increment the reference count */
 
 	(void) acpi_ut_update_object_reference (object, REF_INCREMENT);
@@ -664,8 +668,9 @@
 		return_VOID;
 	}
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X\n",
-			object, object->common.reference_count));
+	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+		"Obj %p Current Refs=%X [To Be Decremented]\n",
+		object, object->common.reference_count));
 
 	/*
 	 * Decrement the reference count, and only actually delete the object
diff -Nru a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
--- a/drivers/acpi/utilities/utglobal.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/utilities/utglobal.c	2004-12-24 13:36:18 -08:00
@@ -43,6 +43,8 @@
 
 #define DEFINE_ACPI_GLOBALS
 
+#include <linux/module.h>
+
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
 
@@ -142,11 +144,13 @@
  */
 
 /* Debug switch - level and trace mask */
-u32                                 acpi_dbg_level = 0;
+u32                                 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
+EXPORT_SYMBOL(acpi_dbg_level);
 
 /* Debug switch - layer (component) mask */
 
-u32                                 acpi_dbg_layer = 0;
+u32                                 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
+EXPORT_SYMBOL(acpi_dbg_layer);
 u32                                 acpi_gbl_nesting_level = 0;
 
 
@@ -861,6 +865,7 @@
 
 	acpi_gbl_system_notify.handler      = NULL;
 	acpi_gbl_device_notify.handler      = NULL;
+	acpi_gbl_exception_handler          = NULL;
 	acpi_gbl_init_handler               = NULL;
 
 	/* Global "typed" ACPI table pointers */
diff -Nru a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c
--- a/drivers/acpi/utilities/utmath.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/acpi/utilities/utmath.c	2004-12-24 13:37:29 -08:00
@@ -59,7 +59,7 @@
  *
  * FUNCTION:    acpi_ut_short_divide
  *
- * PARAMETERS:  in_dividend         - Pointer to the dividend
+ * PARAMETERS:  Dividend            - 64-bit dividend
  *              Divisor             - 32-bit divisor
  *              out_quotient        - Pointer to where the quotient is returned
  *              out_remainder       - Pointer to where the remainder is returned
@@ -74,19 +74,18 @@
 
 acpi_status
 acpi_ut_short_divide (
-	acpi_integer                    *in_dividend,
+	acpi_integer                    dividend,
 	u32                             divisor,
 	acpi_integer                    *out_quotient,
 	u32                             *out_remainder)
 {
-	union uint64_overlay            dividend;
+	union uint64_overlay            dividend_ovl;
 	union uint64_overlay            quotient;
 	u32                             remainder32;
 
 
 	ACPI_FUNCTION_TRACE ("ut_short_divide");
 
-	dividend.full = *in_dividend;
 
 	/* Always check for a zero divisor */
 
@@ -95,13 +94,15 @@
 		return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
 	}
 
+	dividend_ovl.full = dividend;
+
 	/*
 	 * The quotient is 64 bits, the remainder is always 32 bits,
 	 * and is generated by the second divide.
 	 */
-	ACPI_DIV_64_BY_32 (0, dividend.part.hi, divisor,
+	ACPI_DIV_64_BY_32 (0, dividend_ovl.part.hi, divisor,
 			  quotient.part.hi, remainder32);
-	ACPI_DIV_64_BY_32 (remainder32, dividend.part.lo,  divisor,
+	ACPI_DIV_64_BY_32 (remainder32, dividend_ovl.part.lo, divisor,
 			  quotient.part.lo, remainder32);
 
 	/* Return only what was requested */
@@ -121,8 +122,8 @@
  *
  * FUNCTION:    acpi_ut_divide
  *
- * PARAMETERS:  in_dividend         - Pointer to the dividend
- *              in_divisor          - Pointer to the divisor
+ * PARAMETERS:  in_dividend         - Dividend
+ *              in_divisor          - Divisor
  *              out_quotient        - Pointer to where the quotient is returned
  *              out_remainder       - Pointer to where the remainder is returned
  *
@@ -134,8 +135,8 @@
 
 acpi_status
 acpi_ut_divide (
-	acpi_integer                    *in_dividend,
-	acpi_integer                    *in_divisor,
+	acpi_integer                    in_dividend,
+	acpi_integer                    in_divisor,
 	acpi_integer                    *out_quotient,
 	acpi_integer                    *out_remainder)
 {
@@ -155,13 +156,13 @@
 
 	/* Always check for a zero divisor */
 
-	if (*in_divisor == 0) {
+	if (in_divisor == 0) {
 		ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n"));
 		return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
 	}
 
-	divisor.full  = *in_divisor;
-	dividend.full = *in_dividend;
+	divisor.full  = in_divisor;
+	dividend.full = in_dividend;
 	if (divisor.part.hi == 0) {
 		/*
 		 * 1) Simplest case is where the divisor is 32 bits, we can
@@ -269,7 +270,7 @@
 
 acpi_status
 acpi_ut_short_divide (
-	acpi_integer                    *in_dividend,
+	acpi_integer                    in_dividend,
 	u32                             divisor,
 	acpi_integer                    *out_quotient,
 	u32                             *out_remainder)
@@ -288,10 +289,10 @@
 	/* Return only what was requested */
 
 	if (out_quotient) {
-		*out_quotient = *in_dividend / divisor;
+		*out_quotient = in_dividend / divisor;
 	}
 	if (out_remainder) {
-		*out_remainder = (u32) *in_dividend % divisor;
+		*out_remainder = (u32) in_dividend % divisor;
 	}
 
 	return_ACPI_STATUS (AE_OK);
@@ -299,8 +300,8 @@
 
 acpi_status
 acpi_ut_divide (
-	acpi_integer                    *in_dividend,
-	acpi_integer                    *in_divisor,
+	acpi_integer                    in_dividend,
+	acpi_integer                    in_divisor,
 	acpi_integer                    *out_quotient,
 	acpi_integer                    *out_remainder)
 {
@@ -309,7 +310,7 @@
 
 	/* Always check for a zero divisor */
 
-	if (*in_divisor == 0) {
+	if (in_divisor == 0) {
 		ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n"));
 		return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
 	}
@@ -318,10 +319,10 @@
 	/* Return only what was requested */
 
 	if (out_quotient) {
-		*out_quotient = *in_dividend / *in_divisor;
+		*out_quotient = in_dividend / in_divisor;
 	}
 	if (out_remainder) {
-		*out_remainder = *in_dividend % *in_divisor;
+		*out_remainder = in_dividend % in_divisor;
 	}
 
 	return_ACPI_STATUS (AE_OK);
diff -Nru a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
--- a/drivers/acpi/utilities/utmisc.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/utilities/utmisc.c	2004-12-24 13:36:18 -08:00
@@ -356,16 +356,15 @@
  * FUNCTION:    acpi_ut_strtoul64
  *
  * PARAMETERS:  String          - Null terminated string
- *              Terminater      - Where a pointer to the terminating byte is returned
- *              Base            - Radix of the string
+ *              Base            - Radix of the string: 10, 16, or ACPI_ANY_BASE
+ *              ret_integer     - Where the converted integer is returned
  *
- * RETURN:      Converted value
+ * RETURN:      Status and Converted value
  *
  * DESCRIPTION: Convert a string into an unsigned value.
+ *              NOTE: Does not support Octal strings, not needed.
  *
  ******************************************************************************/
-#define NEGATIVE    1
-#define POSITIVE    0
 
 acpi_status
 acpi_ut_strtoul64 (
@@ -373,50 +372,40 @@
 	u32                             base,
 	acpi_integer                    *ret_integer)
 {
-	u32                             index;
+	u32                             this_digit;
 	acpi_integer                    return_value = 0;
-	acpi_status                     status = AE_OK;
-	acpi_integer                    dividend;
 	acpi_integer                    quotient;
 
 
-	*ret_integer = 0;
+	ACPI_FUNCTION_TRACE ("ut_stroul64");
+
 
 	switch (base) {
-	case 0:
-	case 8:
+	case ACPI_ANY_BASE:
 	case 10:
 	case 16:
 		break;
 
 	default:
-		/*
-		 * The specified Base parameter is not in the domain of
-		 * this function:
-		 */
-		return (AE_BAD_PARAMETER);
+		/* Invalid Base */
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
-	/*
-	 * skip over any white space in the buffer:
-	 */
+	/* Skip over any white space in the buffer */
+
 	while (ACPI_IS_SPACE (*string) || *string == '\t') {
 		++string;
 	}
 
 	/*
 	 * If the input parameter Base is zero, then we need to
-	 * determine if it is octal, decimal, or hexadecimal:
+	 * determine if it is decimal or hexadecimal:
 	 */
 	if (base == 0) {
-		if (*string == '0') {
-			if (ACPI_TOLOWER (*(++string)) == 'x') {
-				base = 16;
-				++string;
-			}
-			else {
-				base = 8;
-			}
+		if ((*string == '0') &&
+			(ACPI_TOLOWER (*(++string)) == 'x')) {
+			base = 16;
+			++string;
 		}
 		else {
 			base = 10;
@@ -424,76 +413,67 @@
 	}
 
 	/*
-	 * For octal and hexadecimal bases, skip over the leading
+	 * For hexadecimal base, skip over the leading
 	 * 0 or 0x, if they are present.
 	 */
-	if (base == 8 && *string == '0') {
-		string++;
-	}
-
 	if (base == 16 &&
 		*string == '0' &&
 		ACPI_TOLOWER (*(++string)) == 'x') {
 		string++;
 	}
 
-	/* Main loop: convert the string to an unsigned long */
+	/* Main loop: convert the string to a 64-bit integer */
 
 	while (*string) {
 		if (ACPI_IS_DIGIT (*string)) {
-			index = ((u8) *string) - '0';
+			/* Convert ASCII 0-9 to Decimal value */
+
+			this_digit = ((u8) *string) - '0';
 		}
 		else {
-			index = (u8) ACPI_TOUPPER (*string);
-			if (ACPI_IS_UPPER ((char) index)) {
-				index = index - 'A' + 10;
+			this_digit = (u8) ACPI_TOUPPER (*string);
+			if (ACPI_IS_UPPER ((char) this_digit)) {
+				/* Convert ASCII Hex char to value */
+
+				this_digit = this_digit - 'A' + 10;
 			}
 			else {
 				goto error_exit;
 			}
 		}
 
-		if (index >= base) {
+		/* Check to see if digit is out of range */
+
+		if (this_digit >= base) {
 			goto error_exit;
 		}
 
-		/* Check to see if value is out of range: */
+		/* Divide the digit into the correct position */
 
-		dividend = ACPI_INTEGER_MAX - (acpi_integer) index;
-		(void) acpi_ut_short_divide (&dividend, base, &quotient, NULL);
+		(void) acpi_ut_short_divide ((ACPI_INTEGER_MAX - (acpi_integer) this_digit),
+				 base, &quotient, NULL);
 		if (return_value > quotient) {
 			goto error_exit;
 		}
 
 		return_value *= base;
-		return_value += index;
+		return_value += this_digit;
 		++string;
 	}
 
 	*ret_integer = return_value;
-	return (status);
+	return_ACPI_STATUS (AE_OK);
 
 
 error_exit:
-	switch (base) {
-	case 8:
-		status = AE_BAD_OCTAL_CONSTANT;
-		break;
+	/* Base was set/validated above */
 
-	case 10:
-		status = AE_BAD_DECIMAL_CONSTANT;
-		break;
-
-	case 16:
-		status = AE_BAD_HEX_CONSTANT;
-		break;
-
-	default:
-		/* Base validated above */
-		break;
+	if (base == 10) {
+		return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
+	}
+	else {
+		return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
 	}
-
-	return (status);
 }
 
 
@@ -508,7 +488,7 @@
  * DESCRIPTION: Convert string to uppercase
  *
  ******************************************************************************/
-
+#ifdef ACPI_FUTURE_USAGE
 char *
 acpi_ut_strupr (
 	char                            *src_string)
@@ -528,6 +508,7 @@
 
 	return (src_string);
 }
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*******************************************************************************
diff -Nru a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
--- a/drivers/acpi/utilities/utobject.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/acpi/utilities/utobject.c	2004-12-24 13:37:01 -08:00
@@ -155,9 +155,8 @@
 	ACPI_FUNCTION_TRACE_U32 ("ut_create_buffer_object", buffer_size);
 
 
-	/*
-	 * Create a new Buffer object
-	 */
+	/* Create a new Buffer object */
+
 	buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
 	if (!buffer_desc) {
 		return_PTR (NULL);
@@ -186,6 +185,61 @@
 	/* Return the new buffer descriptor */
 
 	return_PTR (buffer_desc);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_create_string_object
+ *
+ * PARAMETERS:  string_size            - Size of string to be created.  Does not
+ *                                       include NULL terminator, this is added
+ *                                       automatically.
+ *
+ * RETURN:      Pointer to a new String object
+ *
+ * DESCRIPTION: Create a fully initialized string object
+ *
+ ******************************************************************************/
+
+union acpi_operand_object *
+acpi_ut_create_string_object (
+	acpi_size                       string_size)
+{
+	union acpi_operand_object       *string_desc;
+	char                            *string;
+
+
+	ACPI_FUNCTION_TRACE_U32 ("ut_create_string_object", string_size);
+
+
+	/* Create a new String object */
+
+	string_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
+	if (!string_desc) {
+		return_PTR (NULL);
+	}
+
+	/*
+	 * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
+	 * NOTE: Zero-length strings are NULL terminated
+	 */
+	string = ACPI_MEM_CALLOCATE (string_size + 1);
+	if (!string) {
+		ACPI_REPORT_ERROR (("create_string: could not allocate size %X\n",
+			(u32) string_size));
+		acpi_ut_remove_reference (string_desc);
+		return_PTR (NULL);
+	}
+
+	/* Complete string object initialization */
+
+	string_desc->string.pointer = string;
+	string_desc->string.length = (u32) string_size;
+
+	/* Return the new string descriptor */
+
+	return_PTR (string_desc);
 }
 
 
diff -Nru a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
--- a/drivers/acpi/utilities/utxface.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/acpi/utilities/utxface.c	2004-12-24 13:36:18 -08:00
@@ -41,6 +41,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include <linux/module.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acevents.h>
@@ -342,6 +343,8 @@
 }
 
 
+#ifdef ACPI_FUTURE_USAGE
+
 /*****************************************************************************
  *
  * FUNCTION:    acpi_subsystem_status
@@ -455,6 +458,7 @@
 
 	return_ACPI_STATUS (AE_OK);
 }
+EXPORT_SYMBOL(acpi_get_system_info);
 
 
 /*****************************************************************************
@@ -488,6 +492,8 @@
 	acpi_gbl_init_handler = handler;
 	return AE_OK;
 }
+
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /*****************************************************************************
diff -Nru a/drivers/acpi/utils.c b/drivers/acpi/utils.c
--- a/drivers/acpi/utils.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/acpi/utils.c	2004-12-24 13:37:31 -08:00
@@ -233,6 +233,7 @@
 
 	return_ACPI_STATUS(AE_OK);
 }
+EXPORT_SYMBOL(acpi_extract_package);
 
 
 acpi_status
@@ -268,6 +269,7 @@
 
 	return_ACPI_STATUS(AE_OK);
 }
+EXPORT_SYMBOL(acpi_evaluate_integer);
 
 
 #if 0
@@ -373,7 +375,7 @@
 	}
 
 	if (package->package.count > ACPI_MAX_HANDLES) {
-		return AE_NO_MEMORY;
+		return_ACPI_STATUS(AE_NO_MEMORY);
 	}
 	list->count = package->package.count;
 
@@ -409,5 +411,5 @@
 
 	return_ACPI_STATUS(status);
 }
-
+EXPORT_SYMBOL(acpi_evaluate_reference);
 
diff -Nru a/drivers/acpi/video.c b/drivers/acpi/video.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/acpi/video.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1988 @@
+/*
+ *  video.c - ACPI Video Driver ($Revision:$)
+ *
+ *  Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
+ *  Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.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 program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+#include <asm/uaccess.h>
+
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+#define ACPI_VIDEO_COMPONENT		0x08000000
+#define ACPI_VIDEO_CLASS		"video"
+#define ACPI_VIDEO_DRIVER_NAME		"ACPI Video Driver"
+#define ACPI_VIDEO_BUS_NAME		"Video Bus"
+#define ACPI_VIDEO_DEVICE_NAME		"Video Device"
+#define ACPI_VIDEO_NOTIFY_SWITCH	0x80
+#define ACPI_VIDEO_NOTIFY_PROBE		0x81
+#define ACPI_VIDEO_NOTIFY_CYCLE		0x82
+#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT	0x83
+#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT	0x84
+
+#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS	0x82
+#define	ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS	0x83
+#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS	0x84
+#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS	0x85
+#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF		0x86
+
+
+#define ACPI_VIDEO_HEAD_INVALID		(~0u - 1)
+#define ACPI_VIDEO_HEAD_END		(~0u)
+
+
+#define _COMPONENT		ACPI_VIDEO_COMPONENT
+ACPI_MODULE_NAME		("acpi_video")
+
+MODULE_AUTHOR("Bruno Ducrot");
+MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+static int acpi_video_bus_add (struct acpi_device *device);
+static int acpi_video_bus_remove (struct acpi_device *device, int type);
+static int acpi_video_bus_match (struct acpi_device *device, struct acpi_driver *driver);
+
+static struct acpi_driver acpi_video_bus = {
+	.name = ACPI_VIDEO_DRIVER_NAME,
+	.class = ACPI_VIDEO_CLASS,
+	.ops = {
+		.add = acpi_video_bus_add,
+		.remove = acpi_video_bus_remove,
+		.match = acpi_video_bus_match,
+	},
+};
+
+struct acpi_video_bus_flags {
+	u8	multihead:1;	/* can switch video heads */
+	u8	rom:1;		/* can retrieve a video rom */
+	u8	post:1;		/* can configure the head to */
+	u8	reserved:5;
+};
+
+struct acpi_video_bus_cap {
+	u8	_DOS:1; /*Enable/Disable output switching*/
+	u8	_DOD:1; /*Enumerate all devices attached to display adapter*/
+	u8	_ROM:1; /*Get ROM Data*/
+	u8	_GPD:1; /*Get POST Device*/
+	u8	_SPD:1; /*Set POST Device*/
+	u8	_VPO:1; /*Video POST Options*/
+	u8	reserved:2;
+};
+
+struct acpi_video_device_attrib{
+	u32	display_index:4; /* A zero-based instance of the Display*/
+	u32	display_port_attachment:4; /*This field differenates displays type*/
+	u32	display_type:4;	/*Describe the specific type in use*/
+	u32	vendor_specific:4; /*Chipset Vendor Specifi*/ 
+	u32	bios_can_detect:1; /*BIOS can detect the device*/
+	u32	depend_on_vga:1; /*Non-VGA output device whose power is related to 
+				   the VGA device.*/
+	u32	pipe_id:3; /*For VGA multiple-head devices.*/
+	u32	reserved:10; /*Must be 0*/
+	u32	device_id_scheme:1; /*Device ID Scheme*/
+};
+
+struct acpi_video_enumerated_device {
+	union {
+		u32 int_val;
+		struct acpi_video_device_attrib	attrib;
+	} value;
+	struct acpi_video_device *bind_info;
+};
+
+struct acpi_video_bus {
+	acpi_handle	handle;
+	u8	dos_setting;
+	struct acpi_video_enumerated_device *attached_array;
+	u8			attached_count;
+	struct acpi_video_bus_cap	cap;
+	struct acpi_video_bus_flags flags;
+	struct semaphore	sem;
+	struct list_head	video_device_list;
+	struct proc_dir_entry 	*dir;
+};
+
+struct acpi_video_device_flags {
+	u8	crt:1;
+	u8	lcd:1;
+	u8	tvout:1;
+	u8	bios:1;
+	u8	unknown:1;
+	u8	reserved:3;
+};
+
+struct acpi_video_device_cap {
+	u8	_ADR:1;	/*Return the unique ID */
+	u8	_BCL:1; /*Query list of brightness control levels supported*/
+	u8	_BCM:1; /*Set the brightness level*/
+	u8	_DDC:1; /*Return the EDID for this device*/
+	u8	_DCS:1; /*Return status of output device*/
+	u8	_DGS:1; /*Query graphics state*/
+	u8	_DSS:1; /*Device state set*/
+	u8	_reserved:1;
+};
+
+struct acpi_video_device_brightness {
+	int	curr;
+	int	count;
+	int	*levels;
+};
+
+struct acpi_video_device {
+	acpi_handle		handle;
+	unsigned long		device_id;
+	struct acpi_video_device_flags	flags;
+	struct acpi_video_device_cap	cap;
+	struct list_head	entry;
+	struct acpi_video_bus	*video;
+	struct acpi_device	*dev;
+	struct acpi_video_device_brightness *brightness;
+};
+
+
+/* bus */
+static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_bus_info_fops = {
+	.open		= acpi_video_bus_info_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_bus_ROM_fops = {
+	.open		= acpi_video_bus_ROM_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_bus_POST_info_fops = {
+	.open		= acpi_video_bus_POST_info_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_bus_POST_fops = {
+	.open		= acpi_video_bus_POST_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+
+static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_bus_DOS_fops = {
+	.open		= acpi_video_bus_DOS_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+/* device */
+static int acpi_video_device_info_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_device_info_fops = {
+	.open		= acpi_video_device_info_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int acpi_video_device_state_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_device_state_fops = {
+	.open		= acpi_video_device_state_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_device_brightness_fops = {
+	.open		= acpi_video_device_brightness_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file);
+static struct file_operations acpi_video_device_EDID_fops = {
+	.open		= acpi_video_device_EDID_open_fs,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static void acpi_video_device_notify ( acpi_handle handle, u32 event, void *data);
+static void acpi_video_device_rebind( struct acpi_video_bus *video);
+static void acpi_video_device_bind( struct acpi_video_bus *video, struct acpi_video_device *device);
+static int acpi_video_device_enumerate(struct acpi_video_bus *video);
+static int acpi_video_switch_output( struct acpi_video_bus *video, int	event);
+static int acpi_video_get_next_level( struct acpi_video_device *device, u32 level_current,u32 event);
+static void acpi_video_switch_brightness ( struct acpi_video_device *device, int event);
+
+
+/* --------------------------------------------------------------------------
+                               Video Management
+   -------------------------------------------------------------------------- */
+
+/* device */
+
+static int
+acpi_video_device_query (
+	struct acpi_video_device	*device,
+	unsigned long			*state)
+{
+	int			status;
+	ACPI_FUNCTION_TRACE("acpi_video_device_query");
+	status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
+
+	return_VALUE(status);
+}
+
+static int
+acpi_video_device_get_state (
+	struct acpi_video_device	*device,
+	unsigned long 		*state)
+{
+	int			status;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
+
+	status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state);
+
+	return_VALUE(status);
+}
+
+static int
+acpi_video_device_set_state (
+	struct acpi_video_device	*device,
+	int			state)
+{
+	int			status;
+	union acpi_object	arg0 = {ACPI_TYPE_INTEGER};
+	struct acpi_object_list	args = {1, &arg0};
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
+
+	arg0.integer.value = state;
+	status = acpi_evaluate_integer(device->handle, "_DSS", &args, NULL);
+
+	return_VALUE(status);
+}
+
+static int
+acpi_video_device_lcd_query_levels (
+	struct acpi_video_device	*device,
+	union acpi_object		**levels)
+{
+	int			status;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	union acpi_object	*obj;
+
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
+
+	*levels = NULL;
+
+	status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
+	if (!ACPI_SUCCESS(status))
+		return_VALUE(status);
+	obj = (union acpi_object *) buffer.pointer;
+	if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n"));
+		status = -EFAULT;
+		goto err;
+	}
+
+	*levels = obj;
+
+	return_VALUE(0);
+
+err:
+	if (buffer.pointer)
+		kfree(buffer.pointer);
+
+	return_VALUE(status);
+}
+
+static int
+acpi_video_device_lcd_set_level (
+	struct acpi_video_device	*device,
+	int				level)
+{
+	int			status;
+	union acpi_object	arg0 = {ACPI_TYPE_INTEGER};
+	struct acpi_object_list	args = {1, &arg0};
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
+
+	arg0.integer.value = level;
+	status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL);
+
+	printk(KERN_DEBUG "set_level status: %x\n", status);
+	return_VALUE(status);
+}
+
+static int
+acpi_video_device_lcd_get_level_current (
+	struct acpi_video_device	*device,
+	unsigned long 	*level)
+{
+	int			status;
+	ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
+
+	status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
+
+	return_VALUE(status);
+}
+
+static int
+acpi_video_device_EDID (
+	struct acpi_video_device	*device,
+	union acpi_object		**edid,
+	ssize_t				length)
+{
+	int			status;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	union acpi_object	*obj;
+	union acpi_object	arg0 = {ACPI_TYPE_INTEGER};
+	struct acpi_object_list	args = {1, &arg0};
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
+
+	*edid = NULL;
+
+	if (!device)
+		return_VALUE(-ENODEV);
+	if (length == 128)
+		arg0.integer.value = 1;
+	else if (length == 256)
+		arg0.integer.value = 2;
+	else
+		return_VALUE(-EINVAL);
+
+	status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer);
+	if (ACPI_FAILURE(status))
+		return_VALUE(-ENODEV);
+
+	obj = (union acpi_object *) buffer.pointer;
+
+	if (obj && obj->type == ACPI_TYPE_BUFFER)
+		*edid = obj;
+	else {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n"));
+		status = -EFAULT;
+		kfree(obj);
+	}
+
+	return_VALUE(status);
+}
+
+
+/* bus */
+
+static int
+acpi_video_bus_set_POST (
+	struct acpi_video_bus	*video,
+	unsigned long		option)
+{
+	int			status;
+	unsigned long		tmp;
+	union acpi_object	arg0 = {ACPI_TYPE_INTEGER};
+	struct acpi_object_list	args = {1, &arg0};
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
+
+	arg0.integer.value = option;
+
+	status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp);
+	if (ACPI_SUCCESS(status))
+		status = tmp ? (-EINVAL):(AE_OK);
+
+	return_VALUE(status);
+}
+
+static int
+acpi_video_bus_get_POST (
+	struct acpi_video_bus	*video,
+	unsigned long		*id)
+{
+	int status;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST");
+
+	status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id);
+
+	return_VALUE(status);
+}
+
+static int
+acpi_video_bus_POST_options (
+	struct acpi_video_bus	*video,
+	unsigned long		*options)
+{
+	int			status;
+	ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
+
+	status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
+	*options &= 3;
+
+	return_VALUE(status);
+}
+
+/*
+ *  Arg:
+ *  	video		: video bus device pointer
+ *	bios_flag	: 
+ *		0.	The system BIOS should NOT automatically switch(toggle)
+ *			the active display output.
+ *		1.	The system BIOS should automatically switch (toggle) the
+ *			active display output. No swich event.
+ *		2.	The _DGS value should be locked.
+ *		3.	The system BIOS should not automatically switch (toggle) the
+ *			active display output, but instead generate the display switch
+ *			event notify code.
+ *	lcd_flag	:
+ *		0.	The system BIOS should automatically control the brightness level
+ *			of the LCD, when the power changes from AC to DC
+ *		1. 	The system BIOS should NOT automatically control the brightness 
+ *			level of the LCD, when the power changes from AC to DC.
+ * Return Value:
+ * 		-1	wrong arg.
+ */
+
+static int
+acpi_video_bus_DOS(
+	struct acpi_video_bus	*video,
+	int			bios_flag,
+	int			lcd_flag)
+{
+	acpi_integer		status = 0;
+	union acpi_object	arg0 = {ACPI_TYPE_INTEGER};
+	struct acpi_object_list	args = {1, &arg0};
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
+
+	if (bios_flag < 0 || bios_flag >3 || lcd_flag < 0 || lcd_flag > 1){
+		status = -1;
+		goto Failed;
+	}
+	arg0.integer.value = (lcd_flag << 2) | bios_flag;
+	video->dos_setting = arg0.integer.value;
+	acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
+
+Failed:
+	return_VALUE(status);
+}
+
+/*
+ *  Arg:	
+ *  	device	: video output device (LCD, CRT, ..)
+ *
+ *  Return Value:
+ *  	None
+ *
+ *  Find out all required AML method defined under the output
+ *  device.
+ */
+
+static void
+acpi_video_device_find_cap (struct acpi_video_device *device)
+{
+	acpi_integer		status;
+	acpi_handle h_dummy1;
+	int i;
+	union acpi_object *obj = NULL;
+	struct acpi_video_device_brightness *br = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
+
+	memset( &device->cap, 0, 4);
+
+    	if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) {
+		device->cap._ADR = 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) {
+		device->cap._BCL= 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) {
+		device->cap._BCM= 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) {
+		device->cap._DDC= 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) {
+		device->cap._DCS = 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) {
+		device->cap._DGS = 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) {
+		device->cap._DSS = 1;
+	}
+
+	status = acpi_video_device_lcd_query_levels(device, &obj);
+
+	if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
+		int count = 0;
+		union acpi_object *o;
+		
+		br = kmalloc(sizeof &br, GFP_KERNEL);
+		if (!br) {
+			printk(KERN_ERR "can't allocate memory\n");
+		} else {
+			memset(br, 0, sizeof &br);
+			br->levels = kmalloc(obj->package.count * sizeof &br->levels, GFP_KERNEL);
+			if (!br->levels)
+				goto out;
+
+			for (i = 0; i < obj->package.count; i++) {
+				o = (union acpi_object *) &obj->package.elements[i];
+				if (o->type != ACPI_TYPE_INTEGER) {
+					ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
+					continue;
+				}
+				br->levels[count] = (u32) o->integer.value;
+				count++;
+			}
+out:
+			if (count < 2) {
+				if (br->levels)
+					kfree(br->levels);
+				kfree(br);
+			} else {
+				br->count = count;
+				device->brightness = br;
+				ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count));
+			}
+		}
+	}
+
+	if (obj)
+		kfree(obj);
+
+	return_VOID;
+}
+
+/*
+ *  Arg:	
+ *  	device	: video output device (VGA)
+ *
+ *  Return Value:
+ *  	None
+ *
+ *  Find out all required AML method defined under the video bus device.
+ */
+
+static void 
+acpi_video_bus_find_cap (struct acpi_video_bus *video)
+{
+	acpi_handle	h_dummy1;
+
+	memset(&video->cap ,0, 4);
+    	if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) {
+		video->cap._DOS = 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) {
+		video->cap._DOD = 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) {
+		video->cap._ROM = 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) {
+		video->cap._GPD = 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) {
+		video->cap._SPD = 1;
+	}
+    	if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) {
+		video->cap._VPO = 1;
+	}
+}
+
+/*
+ * Check whether the video bus device has required AML method to
+ * support the desired features
+ */
+
+static int
+acpi_video_bus_check (
+	struct acpi_video_bus	*video)
+{
+	acpi_status		status = -ENOENT;
+
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_check");
+
+	if (!video)
+		return_VALUE(-EINVAL);
+
+	/* Since there is no HID, CID and so on for VGA driver, we have
+	 * to check well known required nodes.
+	 */
+
+	/* Does this device able to support video switching ? */
+	if(video->cap._DOS){
+		video->flags.multihead = 1;
+		status = 0;
+	}
+
+	/* Does this device able to retrieve a retrieve a video ROM ? */
+	if(video->cap._ROM){
+		video->flags.rom = 1;
+		status = 0;
+	}
+
+	/* Does this device able to configure which video device to POST ? */
+	if(video->cap._GPD && video->cap._SPD && video->cap._VPO){
+		video->flags.post = 1;
+		status = 0;
+	}
+
+	return_VALUE(status);
+}
+
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+struct proc_dir_entry		*acpi_video_dir;
+
+/* video devices */
+
+static int
+acpi_video_device_info_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	struct acpi_video_device	*dev = (struct acpi_video_device *) seq->private;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
+
+	if (!dev)
+		goto end;
+
+	seq_printf(seq, "device_id:    0x%04x\n", (u32) dev->device_id);
+	seq_printf(seq, "type:         ");
+	if (dev->flags.crt)
+		seq_printf(seq, "CRT\n");
+	else if (dev->flags.lcd)
+		seq_printf(seq, "LCD\n");
+	else if (dev->flags.tvout)
+		seq_printf(seq, "TVOUT\n");
+	else
+		seq_printf(seq, "UNKNOWN\n");
+
+	seq_printf(seq,"known by bios: %s\n",
+		   dev->flags.bios ? "yes":"no");
+
+end:
+	return_VALUE(0);
+}
+
+static int
+acpi_video_device_info_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_device_info_seq_show,
+			   PDE(inode)->data);
+}
+
+static int  
+acpi_video_device_state_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	int			status;
+	struct acpi_video_device	*dev = (struct acpi_video_device *) seq->private;
+	unsigned long	state;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
+
+	if (!dev)
+		goto end;
+
+	status = acpi_video_device_get_state(dev, &state);
+	seq_printf(seq, "state:     ");
+	if (ACPI_SUCCESS(status))
+		seq_printf(seq, "0x%02lx\n", state);
+	else
+		seq_printf(seq, "<not supported>\n");
+
+	status = acpi_video_device_query(dev, &state);
+	seq_printf(seq, "query:     ");
+	if (ACPI_SUCCESS(status))
+		seq_printf(seq, "0x%02lx\n", state);
+	else
+		seq_printf(seq, "<not supported>\n");
+
+end:
+	return_VALUE(0);
+}
+
+static int
+acpi_video_device_state_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_device_state_seq_show,
+			   PDE(inode)->data);
+}
+
+static ssize_t
+acpi_video_device_write_state (
+	struct file		*file,
+	const char		__user *buffer,
+	size_t			count,
+	loff_t			*data)
+{
+	int			status;
+	struct seq_file		*m = (struct seq_file *) file->private_data;
+	struct acpi_video_device	*dev = (struct acpi_video_device *) m->private;
+	char			str[12] = {0};
+	u32			state = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
+
+	if (!dev || count + 1 > sizeof str)
+		return_VALUE(-EINVAL);
+
+	if (copy_from_user(str, buffer, count))
+		return_VALUE(-EFAULT);
+
+	str[count] = 0;
+	state = simple_strtoul(str, NULL, 0);
+	state &= ((1ul<<31) | (1ul<<30) | (1ul<<0));
+
+	status = acpi_video_device_set_state(dev, state);
+
+	if (status)
+		return_VALUE(-EFAULT);
+
+	return_VALUE(count);
+}
+
+static int
+acpi_video_device_brightness_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	struct acpi_video_device	*dev = (struct acpi_video_device *) seq->private;
+	int			i;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
+
+	if (!dev || !dev->brightness) {
+		seq_printf(seq, "<not supported>\n");
+		return_VALUE(0);
+	}
+
+	seq_printf(seq, "levels: ");
+	for (i = 0; i < dev->brightness->count; i++)
+		seq_printf(seq, " %d", dev->brightness->levels[i]);
+	seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
+
+	return_VALUE(0);
+}
+
+static int
+acpi_video_device_brightness_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_device_brightness_seq_show,
+			   PDE(inode)->data);
+}
+
+static ssize_t
+acpi_video_device_write_brightness (
+	struct file		*file,
+	const char		__user *buffer,
+	size_t			count,
+	loff_t			*data)
+{
+	struct seq_file		*m = (struct seq_file *) file->private_data;
+	struct acpi_video_device	*dev = (struct acpi_video_device *) m->private;
+	char			str[4] = {0};
+	unsigned int		level = 0;
+	int			i;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
+
+	if (!dev || count + 1 > sizeof str)
+		return_VALUE(-EINVAL);
+
+	if (copy_from_user(str, buffer, count))
+		return_VALUE(-EFAULT);
+
+	str[count] = 0;
+	level = simple_strtoul(str, NULL, 0);
+	
+	if (level > 100)
+		return_VALUE(-EFAULT);
+
+	/* validate though the list of available levels */
+	for (i = 0; i < dev->brightness->count; i++)
+		if (level == dev->brightness->levels[i]) {
+			if (ACPI_SUCCESS(acpi_video_device_lcd_set_level(dev, level)))
+				dev->brightness->curr = level;
+			break;
+		}
+
+	return_VALUE(count);
+}
+
+static int
+acpi_video_device_EDID_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	struct acpi_video_device	*dev = (struct acpi_video_device *) seq->private;
+	int			status;
+	int			i;
+	union acpi_object	*edid = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
+
+	if (!dev)
+		goto out;
+
+	status = acpi_video_device_EDID (dev, &edid, 128);
+	if (ACPI_FAILURE(status)) {
+		status = acpi_video_device_EDID (dev, &edid, 256);
+	}
+
+	if (ACPI_FAILURE(status)) {
+		goto out;
+	}
+
+	if (edid && edid->type == ACPI_TYPE_BUFFER) {
+		for (i = 0; i < edid->buffer.length; i++)
+			seq_putc(seq, edid->buffer.pointer[i]);
+	}
+
+out:
+	if (!edid)
+		seq_printf(seq, "<not supported>\n");
+	else
+		kfree(edid);
+
+	return_VALUE(0);
+}
+
+static int
+acpi_video_device_EDID_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_device_EDID_seq_show,
+			   PDE(inode)->data);
+}
+
+
+static int
+acpi_video_device_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+	struct acpi_video_device *vid_dev;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
+
+	if (!device)
+		return_VALUE(-ENODEV);
+
+	vid_dev = (struct acpi_video_device *) acpi_driver_data(device);
+	if (!vid_dev)
+		return_VALUE(-ENODEV);
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+				vid_dev->video->dir);
+		if (!acpi_device_dir(device))
+			return_VALUE(-ENODEV);
+		acpi_device_dir(device)->owner = THIS_MODULE;
+	}
+
+	/* 'info' [R] */
+	entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create 'info' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_device_info_fops;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	/* 'state' [R/W] */
+	entry = create_proc_entry("state", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create 'state' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_device_state_fops;
+		entry->proc_fops->write = acpi_video_device_write_state;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	/* 'brightness' [R/W] */
+	entry = create_proc_entry("brightness", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create 'brightness' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_device_brightness_fops;
+		entry->proc_fops->write = acpi_video_device_write_brightness;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	/* 'EDID' [R] */
+	entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Unable to create 'brightness' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_device_EDID_fops;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	return_VALUE(0);
+}
+
+static int
+acpi_video_device_remove_fs (
+	struct acpi_device	*device)
+{
+	struct acpi_video_device *vid_dev;
+	ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
+
+	vid_dev = (struct acpi_video_device *) acpi_driver_data(device);
+	if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
+		return_VALUE(-ENODEV);
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry("info", acpi_device_dir(device));
+		remove_proc_entry("state", acpi_device_dir(device));
+		remove_proc_entry("brightness", acpi_device_dir(device));
+		remove_proc_entry("EDID", acpi_device_dir(device));
+		remove_proc_entry(acpi_device_bid(device),
+				 vid_dev->video->dir);
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+
+/* video bus */
+static int
+acpi_video_bus_info_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	struct acpi_video_bus	*video = (struct acpi_video_bus *) seq->private;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
+
+	if (!video)
+		goto end;
+
+	seq_printf(seq, "Switching heads:              %s\n",
+			video->flags.multihead ? "yes":"no");
+	seq_printf(seq, "Video ROM:                    %s\n",
+			video->flags.rom ? "yes":"no");
+	seq_printf(seq, "Device to be POSTed on boot:  %s\n",
+			video->flags.post ? "yes":"no");
+
+end:
+	return_VALUE(0);
+}
+
+static int
+acpi_video_bus_info_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_bus_info_seq_show, PDE(inode)->data);
+}
+
+static int
+acpi_video_bus_ROM_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	struct acpi_video_bus	*video = (struct acpi_video_bus *) seq->private;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
+
+	if (!video)
+		goto end;
+
+	printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
+	seq_printf(seq, "<TODO>\n");
+
+end:
+	return_VALUE(0);
+}
+
+static int
+acpi_video_bus_ROM_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
+}
+
+static int
+acpi_video_bus_POST_info_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	struct acpi_video_bus	*video = (struct acpi_video_bus *) seq->private;
+	unsigned long		options;
+	int			status;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
+
+	if (!video)
+		goto end;
+
+	status = acpi_video_bus_POST_options(video, &options);
+	if (ACPI_SUCCESS(status)) {
+		if (!(options & 1)) {
+			printk(KERN_WARNING PREFIX "The motherboard VGA device is not listed as a possible POST device.\n");
+			printk(KERN_WARNING PREFIX "This indicate a BIOS bug.  Please contact the manufacturer.\n");
+		}
+		printk("%lx\n", options);
+		seq_printf(seq, "can POST: <intgrated video>");
+		if (options & 2)
+			seq_printf(seq, " <PCI video>");
+		if (options & 4)
+			seq_printf(seq, " <AGP video>");
+		seq_putc(seq, '\n');
+	} else
+		seq_printf(seq, "<not supported>\n");
+end:
+	return_VALUE(0);
+}
+
+static int
+acpi_video_bus_POST_info_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_bus_POST_info_seq_show, PDE(inode)->data);
+}
+
+static int
+acpi_video_bus_POST_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	struct acpi_video_bus	*video = (struct acpi_video_bus *) seq->private;
+	int			status;
+	unsigned long		id;
+	char			device_decode[][30] = {
+					"motherboard VGA device",
+					"PCI VGA device",
+					"AGP VGA device",
+					"UNKNOWN",
+	};
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
+
+	if (!video)
+		goto end;
+
+	status = acpi_video_bus_get_POST (video, &id);
+	if (!ACPI_SUCCESS(status)) {
+		seq_printf(seq, "<not supported>\n");
+		goto end;
+	}
+	seq_printf(seq, "device posted is <%s>\n",  device_decode[id & 3]);
+
+end:
+	return_VALUE(0);
+}
+
+static int
+acpi_video_bus_DOS_seq_show (
+	struct seq_file		*seq,
+	void			*offset)
+{
+	struct acpi_video_bus	*video = (struct acpi_video_bus *) seq->private;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
+
+	seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting );
+
+	return_VALUE(0);
+}
+
+static int
+acpi_video_bus_POST_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_bus_POST_seq_show, PDE(inode)->data);
+}
+
+static int
+acpi_video_bus_DOS_open_fs (
+	struct inode		*inode,
+	struct file		*file)
+{
+	return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
+}
+
+static ssize_t
+acpi_video_bus_write_POST (
+	struct file		*file,
+	const char		__user *buffer,
+	size_t			count,
+	loff_t			*data)
+{
+	int			status;
+	struct seq_file		*m = (struct seq_file *) file->private_data;
+	struct acpi_video_bus	*video = (struct acpi_video_bus *) m->private;
+	char			str[12] = {0};
+	unsigned long		opt, options;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
+
+
+	if (!video || count + 1 > sizeof str)
+		return_VALUE(-EINVAL);
+
+	status = acpi_video_bus_POST_options(video, &options);
+	if (!ACPI_SUCCESS(status))
+		return_VALUE(-EINVAL);
+
+	if (copy_from_user(str, buffer, count))
+		return_VALUE(-EFAULT);
+
+	str[count] = 0;
+	opt = strtoul(str, NULL, 0);
+	if (opt > 3)
+		return_VALUE(-EFAULT);
+
+	/* just in case an OEM 'forget' the motherboard... */
+	options |= 1;
+
+	if (options & (1ul << opt)) {
+		status = acpi_video_bus_set_POST (video, opt);
+		if (!ACPI_SUCCESS(status))
+			return_VALUE(-EFAULT);
+
+	}
+
+
+	return_VALUE(count);
+}
+
+static ssize_t
+acpi_video_bus_write_DOS (
+	struct file		*file,
+	const char		__user *buffer,
+	size_t			count,
+	loff_t			*data)
+{
+	int			status;
+	struct seq_file		*m = (struct seq_file *) file->private_data;
+	struct acpi_video_bus	*video = (struct acpi_video_bus *) m->private;
+	char			str[12] = {0};
+	unsigned long		opt;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
+
+
+	if (!video || count + 1 > sizeof str)
+		return_VALUE(-EINVAL);
+
+	if (copy_from_user(str, buffer, count))
+		return_VALUE(-EFAULT);
+
+	str[count] = 0;
+	opt = strtoul(str, NULL, 0);
+	if (opt > 7)
+		return_VALUE(-EFAULT);
+
+	status = acpi_video_bus_DOS (video, opt & 0x3, (opt & 0x4)>>2);
+
+	if (!ACPI_SUCCESS(status))
+		return_VALUE(-EFAULT);
+
+	return_VALUE(count);
+}
+
+static int
+acpi_video_bus_add_fs (
+	struct acpi_device	*device)
+{
+	struct proc_dir_entry	*entry = NULL;
+	struct acpi_video_bus	*video;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
+
+	video = (struct acpi_video_bus *) acpi_driver_data(device);
+
+	if (!acpi_device_dir(device)) {
+		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
+				acpi_video_dir);
+		if (!acpi_device_dir(device))
+			return_VALUE(-ENODEV);
+		video->dir = acpi_device_dir(device);
+		acpi_device_dir(device)->owner = THIS_MODULE;
+	}
+
+	/* 'info' [R] */
+	entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'info' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_bus_info_fops;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	/* 'ROM' [R] */
+	entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'ROM' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_bus_ROM_fops;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	/* 'POST_info' [R] */
+	entry = create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST_info' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_bus_POST_info_fops;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	/* 'POST' [R/W] */
+	entry = create_proc_entry("POST", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_bus_POST_fops;
+		entry->proc_fops->write = acpi_video_bus_write_POST;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	/* 'DOS' [R/W] */
+	entry = create_proc_entry("DOS", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device));
+	if (!entry)
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'DOS' fs entry\n"));
+	else {
+		entry->proc_fops = &acpi_video_bus_DOS_fops;
+		entry->proc_fops->write = acpi_video_bus_write_DOS;
+		entry->data = acpi_driver_data(device);
+		entry->owner = THIS_MODULE;
+	}
+
+	return_VALUE(0);
+}
+
+static int
+acpi_video_bus_remove_fs (
+	struct acpi_device	*device)
+{
+	struct acpi_video_bus	*video;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
+
+	video = (struct acpi_video_bus *) acpi_driver_data(device);
+
+	if (acpi_device_dir(device)) {
+		remove_proc_entry("info", acpi_device_dir(device));
+		remove_proc_entry("ROM", acpi_device_dir(device));
+		remove_proc_entry("POST_info", acpi_device_dir(device));
+		remove_proc_entry("POST", acpi_device_dir(device));
+		remove_proc_entry("DOS", acpi_device_dir(device));
+		remove_proc_entry(acpi_device_bid(device),
+				acpi_video_dir); 
+		acpi_device_dir(device) = NULL;
+	}
+
+	return_VALUE(0);
+}
+
+/* --------------------------------------------------------------------------
+                                 Driver Interface
+   -------------------------------------------------------------------------- */
+
+/* device interface */
+
+static int
+acpi_video_bus_get_one_device (
+	struct acpi_device	*device,
+	struct acpi_video_bus	*video)
+{
+	unsigned long		device_id;
+	int			status, result;
+	struct acpi_video_device	*data;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
+
+	if (!device || !video)
+		return_VALUE(-EINVAL);
+
+	status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
+	if (ACPI_SUCCESS(status)) {
+
+		data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
+		if (!data)
+			return_VALUE(-ENOMEM);
+
+		memset(data, 0, sizeof(struct acpi_video_device));
+
+		data->handle = device->handle;
+		strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
+		strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
+		acpi_driver_data(device) = data;
+
+		data->device_id = device_id;
+		data->video = video;
+		data->dev = device;
+
+		switch (device_id & 0xffff) {
+		case 0x0100:
+			data->flags.crt = 1;
+			break;
+		case 0x0400:
+			data->flags.lcd = 1;
+			break;
+		case 0x0200:
+			data->flags.tvout = 1;
+			break;
+		default:
+			data->flags.unknown = 1;
+			break;
+		}
+		
+		acpi_video_device_bind(video, data);
+		acpi_video_device_find_cap(data);
+
+		status = acpi_install_notify_handler(data->handle,
+			ACPI_DEVICE_NOTIFY, acpi_video_device_notify, data);
+		if (ACPI_FAILURE(status)) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+				"Error installing notify handler\n"));
+			result = -ENODEV;
+			goto end;
+		}
+
+		down(&video->sem);
+		list_add_tail(&data->entry, &video->video_device_list);
+		up(&video->sem);
+
+		acpi_video_device_add_fs(device);
+
+		return_VALUE(0);
+	}
+
+end:
+	return_VALUE(-ENOENT);
+}
+
+/*
+ *  Arg:
+ *  	video	: video bus device 
+ *
+ *  Return:
+ *  	none
+ *  
+ *  Enumerate the video device list of the video bus, 
+ *  bind the ids with the corresponding video devices
+ *  under the video bus.
+ */  
+
+static void
+acpi_video_device_rebind( struct acpi_video_bus *video)
+{
+	struct list_head * node, * next;
+	list_for_each_safe(node, next, &video->video_device_list) {
+		struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry);
+		acpi_video_device_bind( video, dev);
+	}
+}
+
+/*
+ *  Arg:
+ *  	video	: video bus device 
+ *  	device	: video output device under the video 
+ *  		bus
+ *
+ *  Return:
+ *  	none
+ *  
+ *  Bind the ids with the corresponding video devices
+ *  under the video bus.
+ */  
+
+static void
+acpi_video_device_bind( struct acpi_video_bus *video,
+			struct acpi_video_device *device)
+{
+	int	i;
+	ACPI_FUNCTION_TRACE("acpi_video_device_bind");
+
+#define IDS_VAL(i) video->attached_array[i].value.int_val
+#define IDS_BIND(i) video->attached_array[i].bind_info
+	
+	for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID && 
+		i < video->attached_count; i++) {
+		if (device->device_id == (IDS_VAL(i)& 0xffff)) {
+			IDS_BIND(i) = device;
+			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
+		}
+	}
+#undef IDS_VAL
+#undef IDS_BIND
+}
+
+/*
+ *  Arg:
+ *  	video	: video bus device 
+ *
+ *  Return:
+ *  	< 0	: error
+ *  
+ *  Call _DOD to enumerate all devices attached to display adapter
+ *
+ */  
+
+static int acpi_video_device_enumerate(struct acpi_video_bus *video)
+{
+	int			status;
+	int			count;
+	int			i;
+	struct acpi_video_enumerated_device *active_device_list;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	union acpi_object	*dod = NULL;
+	union acpi_object	*obj;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
+
+	status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer);
+	if (!ACPI_SUCCESS(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _DOD\n"));
+		return_VALUE(status);
+	}
+
+	dod = (union acpi_object *) buffer.pointer;
+	if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
+		status = -EFAULT;
+		goto out;
+	}
+
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
+		dod->package.count));
+
+	active_device_list= kmalloc(
+ 		dod->package.count*sizeof(struct acpi_video_enumerated_device),
+	       	GFP_KERNEL);
+
+	if (!active_device_list) {
+		status = -ENOMEM;
+		goto out;
+	}
+
+	count = 0;
+	for (i = 0; i < dod->package.count; i++) {
+		obj = (union acpi_object *) &dod->package.elements[i];
+
+		if (obj->type != ACPI_TYPE_INTEGER) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
+			active_device_list[i].value.int_val = ACPI_VIDEO_HEAD_INVALID;
+		}
+		active_device_list[i].value.int_val = obj->integer.value;
+		active_device_list[i].bind_info = NULL;
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, (int) obj->integer.value));
+		count++;
+	}
+	active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
+
+	if(video->attached_array)
+		kfree(video->attached_array);
+	
+	video->attached_array = active_device_list;
+	video->attached_count = count;
+out:
+	acpi_os_free(buffer.pointer);
+	return_VALUE(status);
+}
+
+/*
+ *  Arg:
+ *  	video	: video bus device 
+ *  	event	: Nontify Event
+ *
+ *  Return:
+ *  	< 0	: error
+ *  
+ *	1. Find out the current active output device.
+ *	2. Identify the next output device to switch
+ *	3. call _DSS to do actual switch.
+ */  
+
+static int 
+acpi_video_switch_output(
+	struct acpi_video_bus *video, 
+	int	event)
+{
+	struct list_head * node, * next;
+	struct acpi_video_device *dev=NULL;
+       	struct acpi_video_device *dev_next=NULL;
+	struct acpi_video_device *dev_prev=NULL;
+	unsigned long state;
+	int status = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_video_switch_output");
+
+	list_for_each_safe(node, next, &video->video_device_list) {
+		struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry);
+		status = acpi_video_device_get_state(dev, &state);
+		if (state & 0x2){
+			dev_next = container_of(node->next, struct acpi_video_device, entry);
+			dev_prev = container_of(node->prev, struct acpi_video_device, entry);
+			goto out;
+		}
+	}
+	dev_next = container_of(node->next, struct acpi_video_device, entry);
+	dev_prev = container_of(node->prev, struct acpi_video_device, entry);
+out:	
+	switch (event) {
+	case ACPI_VIDEO_NOTIFY_CYCLE:
+	case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
+		acpi_video_device_set_state(dev, 0);
+		acpi_video_device_set_state(dev_next, 0x80000001);
+		break;
+	case ACPI_VIDEO_NOTIFY_PREV_OUTPUT:
+		acpi_video_device_set_state(dev, 0);
+		acpi_video_device_set_state(dev_prev, 0x80000001);
+	default:
+		break;
+	}
+
+	return_VALUE(status);
+}
+
+static int 
+acpi_video_get_next_level(
+	struct acpi_video_device *device,
+	u32	level_current,
+	u32	event)
+{
+	/*Fix me*/
+	return level_current;
+}
+
+
+static void
+acpi_video_switch_brightness (
+	struct acpi_video_device *device, 
+	int	event)
+{
+	unsigned long level_current, level_next;
+	acpi_video_device_lcd_get_level_current(device, &level_current);
+	level_next = acpi_video_get_next_level(device, level_current, event);
+	acpi_video_device_lcd_set_level(device, level_next);
+}
+
+static int
+acpi_video_bus_get_devices (
+	struct acpi_video_bus	*video,
+	struct acpi_device	*device)
+{
+	int			status = 0;
+	struct list_head	*node, *next;
+
+	ACPI_FUNCTION_TRACE("acpi_video_get_devices");
+
+	acpi_video_device_enumerate(video);
+
+	list_for_each_safe(node, next, &device->children) {
+		struct acpi_device *dev = list_entry(node, struct acpi_device, node);
+
+		if (!dev)
+			continue;
+
+		status = acpi_video_bus_get_one_device(dev, video);
+		if (ACPI_FAILURE(status)) {
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Cant attach device\n"));
+			continue;
+		}
+
+	}
+	return_VALUE(status);
+}
+
+static int
+acpi_video_bus_put_one_device(
+	struct acpi_video_device	*device)
+{
+	struct acpi_video_bus *video;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device");
+
+	if (!device || !device->video)
+		return_VALUE(-ENOENT);
+
+	video = device->video;
+
+	down(&video->sem);
+	list_del(&device->entry);
+	up(&video->sem);
+	acpi_video_device_remove_fs(device->dev);
+
+	return_VALUE(0);
+}
+
+static int
+acpi_video_bus_put_devices (
+	struct acpi_video_bus	*video)
+{
+	int			status;
+	struct list_head	*node, *next;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
+
+	list_for_each_safe(node, next, &video->video_device_list) {
+		struct acpi_video_device *data = list_entry(node, struct acpi_video_device, entry);
+		if (!data)
+			continue;
+
+		status = acpi_video_bus_put_one_device(data);
+		if(ACPI_FAILURE(status))
+			printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n");
+
+		if (data->brightness)
+			kfree(data->brightness);
+
+		kfree(data);
+	}
+
+	return_VALUE(0);
+}
+
+/* acpi_video interface */
+
+static int
+acpi_video_bus_start_devices(
+	struct acpi_video_bus	*video)
+{
+	return acpi_video_bus_DOS(video, 1, 0);
+}
+
+static int
+acpi_video_bus_stop_devices(
+	struct acpi_video_bus	*video)
+{
+	return acpi_video_bus_DOS(video, 0, 1);
+}
+
+static void
+acpi_video_bus_notify (
+	acpi_handle		handle,
+	u32			event,
+	void			*data)
+{
+	struct acpi_video_bus	*video = (struct acpi_video_bus *) data;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
+	printk("video bus notify\n");
+
+	if (!video)
+		return_VOID;
+
+	if (acpi_bus_get_device(handle, &device))
+		return_VOID;
+
+	switch (event) {
+	case ACPI_VIDEO_NOTIFY_SWITCH:	/* User request that a switch occur,
+					 * most likely via hotkey. */
+		acpi_bus_generate_event(device, event, 0);
+		break;
+
+	case ACPI_VIDEO_NOTIFY_PROBE:	/* User plug or remove a video
+					 * connector. */
+		acpi_video_device_enumerate(video);
+		acpi_video_device_rebind(video);
+		acpi_video_switch_output(video, event);
+		acpi_bus_generate_event(device, event, 0);
+		break;
+
+	case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed.*/
+	case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
+	case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
+		acpi_video_switch_output(video, event);
+		acpi_bus_generate_event(device, event, 0);
+		break;
+
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"Unsupported event [0x%x]\n", event));
+		break;
+	}
+
+	return_VOID;
+}
+
+static void
+acpi_video_device_notify (
+	acpi_handle		handle,
+	u32			event,
+	void			*data)
+{
+	struct acpi_video_device	*video_device = (struct acpi_video_device *) data;
+	struct acpi_device	*device = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_video_device_notify");
+
+	printk("video device notify\n");
+	if (!video_device)
+		return_VOID;
+
+	if (acpi_bus_get_device(handle, &device))
+		return_VOID;
+
+	switch (event) {
+	case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
+	case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
+		acpi_bus_generate_event(device, event, 0);
+		break;
+	case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
+	case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
+	case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
+	case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
+	case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
+		acpi_video_switch_brightness (video_device, event);
+		acpi_bus_generate_event(device, event, 0);
+		break;
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+			"Unsupported event [0x%x]\n", event));
+		break;
+	}
+	return_VOID;
+}
+
+static int
+acpi_video_bus_add (
+	struct acpi_device	*device)
+{
+	int			result = 0;
+	acpi_status		status = 0;
+	struct acpi_video_bus	*video = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_add");
+	
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
+	if (!video)
+		return_VALUE(-ENOMEM);
+	memset(video, 0, sizeof(struct acpi_video_bus));
+
+	video->handle = device->handle;
+	strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
+	strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
+	acpi_driver_data(device) = video;
+
+	acpi_video_bus_find_cap(video);
+	result = acpi_video_bus_check(video);
+	if (result)
+		goto end;
+
+	result = acpi_video_bus_add_fs(device);
+	if (result)
+		goto end;
+
+	init_MUTEX(&video->sem);
+	INIT_LIST_HEAD(&video->video_device_list);
+
+	acpi_video_bus_get_devices(video, device);
+	acpi_video_bus_start_devices(video);
+
+	status = acpi_install_notify_handler(video->handle,
+		ACPI_DEVICE_NOTIFY, acpi_video_bus_notify, video);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error installing notify handler\n"));
+		result = -ENODEV;
+		goto end;
+	}
+
+	printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
+		ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
+		video->flags.multihead ? "yes":"no",
+		video->flags.rom ? "yes":"no",
+		video->flags.post ? "yes":"no");
+
+end:
+	if (result) {
+		acpi_video_bus_remove_fs(device);
+		kfree(video);
+	}
+
+	return_VALUE(result);
+}
+
+static int
+acpi_video_bus_remove (
+	struct acpi_device	*device,
+	int			type)
+{
+	acpi_status		status = 0;
+	struct acpi_video_bus	*video = NULL;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
+
+	if (!device || !acpi_driver_data(device))
+		return_VALUE(-EINVAL);
+
+	video = (struct acpi_video_bus *) acpi_driver_data(device);
+
+	acpi_video_bus_stop_devices(video);
+
+	status = acpi_remove_notify_handler(video->handle,
+		ACPI_DEVICE_NOTIFY, acpi_video_bus_notify);
+	if (ACPI_FAILURE(status))
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+			"Error removing notify handler\n"));
+
+	acpi_video_bus_put_devices(video);
+	acpi_video_bus_remove_fs(device);
+
+	if (video->attached_array)
+		kfree(video->attached_array);
+	kfree(video);
+
+	return_VALUE(0);
+}
+
+
+static int
+acpi_video_bus_match (
+	struct acpi_device	*device,
+	struct acpi_driver	*driver)
+{
+	acpi_handle		h_dummy1;
+	acpi_handle		h_dummy2;
+	acpi_handle		h_dummy3;
+
+	ACPI_FUNCTION_TRACE("acpi_video_bus_match");
+
+	if (!device || !driver)
+		return_VALUE(-EINVAL);
+
+	/* Since there is no HID, CID for ACPI Video drivers, we have
+	 * to check well known required nodes for each feature we support.
+	 */
+
+	/* Does this device able to support video switching ? */
+	if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) &&
+	    ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2)))
+		return_VALUE(0);
+
+	/* Does this device able to retrieve a video ROM ? */
+	if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1)))
+		return_VALUE(0);
+
+	/* Does this device able to configure which video head to be POSTed ? */
+	if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) &&
+	    ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) &&
+	    ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
+		return_VALUE(0);
+
+
+	return_VALUE(-ENODEV);
+}
+
+
+static int __init
+acpi_video_init (void)
+{
+	int			result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_video_init");
+
+	/*
+	acpi_dbg_level = 0xFFFFFFFF;
+	acpi_dbg_layer = 0x08000000;
+	*/
+
+	acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
+	if (!acpi_video_dir)
+		return_VALUE(-ENODEV);
+	acpi_video_dir->owner = THIS_MODULE;
+
+	result = acpi_bus_register_driver(&acpi_video_bus);
+	if (result < 0) {
+		remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
+		return_VALUE(-ENODEV);
+	}
+
+	return_VALUE(0);
+}
+
+static void __exit
+acpi_video_exit (void)
+{
+	ACPI_FUNCTION_TRACE("acpi_video_exit");
+
+	acpi_bus_unregister_driver(&acpi_video_bus);
+
+	remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
+
+	return_VOID;
+}
+
+module_init(acpi_video_init);
+module_exit(acpi_video_exit);
diff -Nru a/drivers/atm/Makefile b/drivers/atm/Makefile
--- a/drivers/atm/Makefile	2004-12-24 13:36:17 -08:00
+++ b/drivers/atm/Makefile	2004-12-24 13:36:17 -08:00
@@ -68,4 +68,4 @@
 # deal with the various suffixes of the binary firmware images
 $(obj)/%.bin $(obj)/%.bin1 $(obj)/%.bin2: $(src)/%.data
 	objcopy -Iihex $< -Obinary $@.gz
-	gzip -df $@.gz
+	gzip -n -df $@.gz
diff -Nru a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
--- a/drivers/atm/ambassador.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/atm/ambassador.c	2004-12-24 13:36:18 -08:00
@@ -313,9 +313,6 @@
 static void do_housekeeping (unsigned long arg);
 /********** globals **********/
 
-static amb_dev * amb_devs = NULL;
-static struct timer_list housekeeping = TIMER_INITIALIZER(do_housekeeping, 0, 1);
-
 static unsigned short debug = 0;
 static unsigned int cmds = 8;
 static unsigned int txs = 32;
@@ -870,7 +867,7 @@
 
 static irqreturn_t interrupt_handler(int irq, void *dev_id,
 					struct pt_regs *pt_regs) {
-  amb_dev * dev = amb_devs;
+  amb_dev * dev = (amb_dev *) dev_id;
   (void) pt_regs;
   
   PRINTD (DBG_IRQ|DBG_FLOW, "interrupt_handler: %p", dev_id);
@@ -879,24 +876,6 @@
     PRINTD (DBG_IRQ|DBG_ERR, "irq with NULL dev_id: %d", irq);
     return IRQ_NONE;
   }
-  // Did one of our cards generate the interrupt?
-  while (dev) {
-    if (dev == dev_id)
-      break;
-    dev = dev->prev;
-  }
-  // impossible - unless we add the device to our list after both
-  // registering the IRQ handler for it and enabling interrupts, AND
-  // the card generates an IRQ at startup - should not happen again
-  if (!dev) {
-    PRINTD (DBG_IRQ, "irq for unknown device: %d", irq);
-    return IRQ_NONE;
-  }
-  // impossible - unless we have memory corruption of dev or kernel
-  if (irq != dev->irq) {
-    PRINTD (DBG_IRQ|DBG_ERR, "irq mismatch: %d", irq);
-    return IRQ_NONE;
-  }
   
   {
     u32 interrupt = rd_plain (dev, offsetof(amb_mem, interrupt));
@@ -1554,22 +1533,13 @@
 
 /********** housekeeping **********/
 static void do_housekeeping (unsigned long arg) {
-  amb_dev * dev = amb_devs;
-  // data is set to zero at module unload
-  (void) arg;
+  amb_dev * dev = (amb_dev *) arg;
   
-  if (housekeeping.data) {
-    while (dev) {
-      
-      // could collect device-specific (not driver/atm-linux) stats here
+  // could collect device-specific (not driver/atm-linux) stats here
       
-      // last resort refill once every ten seconds
-      fill_rx_pools (dev);
-      
-      dev = dev->prev;
-    }
-    mod_timer(&housekeeping, jiffies + 10*HZ);
-  }
+  // last resort refill once every ten seconds
+  fill_rx_pools (dev);
+  mod_timer(&dev->housekeeping, jiffies + 10*HZ);
   
   return;
 }
@@ -2225,6 +2195,7 @@
       
       // set up known dev items straight away
       dev->pci_dev = pci_dev; 
+      pci_set_drvdata(pci_dev, dev);
       
       dev->iobase = pci_resource_start (pci_dev, 1);
       dev->irq = pci_dev->irq; 
@@ -2284,16 +2255,22 @@
 	return ret;
 }
 
-static int __init do_pci_device(struct pci_dev *pci_dev)
+static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
 {
 	amb_dev * dev;
 	int err;
 
 	// read resources from PCI configuration space
-	u8 irq = pci_dev->irq;
+	unsigned int irq = pci_dev->irq;
+
+	if (pci_dev->device == PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD) {
+		PRINTK (KERN_ERR, "skipped broken (PLX rev 2) card");
+		err = -EINVAL;
+		goto out;
+	}
 
 	PRINTD (DBG_INFO, "found Madge ATM adapter (amb) at"
-		" IO %x, IRQ %u, MEM %p", pci_resource_start(pci_dev, 1),
+		" IO %lx, IRQ %u, MEM %p", pci_resource_start(pci_dev, 1),
 		irq, bus_to_virt(pci_resource_start(pci_dev, 0)));
 
 	// check IO region
@@ -2347,9 +2324,10 @@
 	dev->atm_dev->ci_range.vpi_bits = NUM_VPI_BITS;
 	dev->atm_dev->ci_range.vci_bits = NUM_VCI_BITS;
 
-	// update linked list
-	dev->prev = amb_devs;
-	amb_devs = dev;
+	init_timer(&dev->housekeeping);
+	dev->housekeeping.function = do_housekeeping;
+	dev->housekeeping.data = (unsigned long) dev;
+	mod_timer(&dev->housekeeping, jiffies);
 
 	// enable host interrupts
 	interrupts_on (dev);
@@ -2370,29 +2348,25 @@
 	goto out;
 }
 
-static int __init amb_probe (void) {
-  struct pci_dev * pci_dev;
-  int devs;
-  
-  PRINTD (DBG_FLOW, "amb_probe");
-  
-  devs = 0;
-  pci_dev = NULL;
-  while ((pci_dev = pci_find_device
-          (PCI_VENDOR_ID_MADGE, PCI_DEVICE_ID_MADGE_AMBASSADOR, pci_dev)
-          )) {
-	if (do_pci_device(pci_dev) == 0)
-		devs++;
-  }
 
-  
-  pci_dev = NULL;
-  while ((pci_dev = pci_find_device
-          (PCI_VENDOR_ID_MADGE, PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD, pci_dev)
-          ))
-    PRINTK (KERN_ERR, "skipped broken (PLX rev 2) card");
-  
-  return devs;
+static void __devexit amb_remove_one(struct pci_dev *pci_dev)
+{
+	struct amb_dev *dev;
+
+	dev = pci_get_drvdata(pci_dev);
+
+	PRINTD(DBG_INFO|DBG_INIT, "closing %p (atm_dev = %p)", dev, dev->atm_dev);
+	del_timer_sync(&dev->housekeeping);
+	// the drain should not be necessary
+	drain_rx_pools(dev);
+	interrupts_off(dev);
+	amb_reset(dev, 0);
+	free_irq(dev->irq, dev);
+	pci_disable_device(pci_dev);
+	destroy_queues(dev);
+	atm_dev_deregister(dev->atm_dev);
+	kfree(dev);
+	pci_release_region(pci_dev, 1);
 }
 
 static void __init amb_check_args (void) {
@@ -2440,13 +2414,13 @@
 MODULE_AUTHOR(maintainer_string);
 MODULE_DESCRIPTION(description_string);
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug,   "h");
-MODULE_PARM(cmds,    "i");
-MODULE_PARM(txs,     "i");
-MODULE_PARM(rxs,     __MODULE_STRING(NUM_RX_POOLS) "i");
-MODULE_PARM(rxs_bs,  __MODULE_STRING(NUM_RX_POOLS) "i");
-MODULE_PARM(rx_lats, "i");
-MODULE_PARM(pci_lat, "b");
+module_param(debug,   ushort, 0644);
+module_param(cmds,    uint, 0);
+module_param(txs,     uint, 0);
+module_param_array(rxs,     uint, NULL, 0);
+module_param_array(rxs_bs,  uint, NULL, 0);
+module_param(rx_lats, uint, 0);
+module_param(pci_lat, byte, 0);
 MODULE_PARM_DESC(debug,   "debug bitmap, see .h file");
 MODULE_PARM_DESC(cmds,    "number of command queue entries");
 MODULE_PARM_DESC(txs,     "number of TX queue entries");
@@ -2457,9 +2431,25 @@
 
 /********** module entry **********/
 
-static int __init amb_module_init (void) {
-  int devs;
-  
+static struct pci_device_id amb_pci_tbl[] = {
+	{ PCI_VENDOR_ID_MADGE, PCI_DEVICE_ID_MADGE_AMBASSADOR, PCI_ANY_ID, PCI_ANY_ID,
+	  0, 0, 0 },
+	{ PCI_VENDOR_ID_MADGE, PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD, PCI_ANY_ID, PCI_ANY_ID,
+	  0, 0, 0 },
+	{ 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, amb_pci_tbl);
+
+static struct pci_driver amb_driver = {
+	.name =		"amb",
+	.probe =	amb_probe,
+	.remove =	__devexit_p(amb_remove_one),
+	.id_table =	amb_pci_tbl,
+};
+
+static int __init amb_module_init (void)
+{
   PRINTD (DBG_FLOW|DBG_INIT, "init_module");
   
   // sanity check - cast needed as printk does not support %Zu
@@ -2474,49 +2464,16 @@
   amb_check_args();
   
   // get the juice
-  devs = amb_probe();
-  
-  if (devs) {
-    mod_timer (&housekeeping, jiffies);
-  } else {
-    PRINTK (KERN_INFO, "no (usable) adapters found");
-  }
-  
-  return devs ? 0 : -ENODEV;
+  return pci_module_init(&amb_driver);
 }
 
 /********** module exit **********/
 
-static void __exit amb_module_exit (void) {
-  amb_dev * dev;
-  
+static void __exit amb_module_exit (void)
+{
   PRINTD (DBG_FLOW|DBG_INIT, "cleanup_module");
   
-  // paranoia
-  housekeeping.data = 0;
-  del_timer_sync(&housekeeping);
-  
-  while (amb_devs) {
-    struct pci_dev *pdev;
-
-    dev = amb_devs;
-    pdev = dev->pci_dev;
-    amb_devs = dev->prev;
-    
-    PRINTD (DBG_INFO|DBG_INIT, "closing %p (atm_dev = %p)", dev, dev->atm_dev);
-    // the drain should not be necessary
-    drain_rx_pools (dev);
-    interrupts_off (dev);
-    amb_reset (dev, 0);
-    free_irq (dev->irq, dev);
-    pci_disable_device (pdev);
-    destroy_queues (dev);
-    atm_dev_deregister (dev->atm_dev);
-    kfree (dev);
-    pci_release_region (pdev, 1);
-  }
-  
-  return;
+  return pci_unregister_driver(&amb_driver);
 }
 
 module_init(amb_module_init);
diff -Nru a/drivers/atm/ambassador.h b/drivers/atm/ambassador.h
--- a/drivers/atm/ambassador.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/atm/ambassador.h	2004-12-24 13:37:31 -08:00
@@ -649,7 +649,7 @@
   
   struct atm_dev * atm_dev;
   struct pci_dev * pci_dev;
-  struct amb_dev * prev;
+  struct timer_list housekeeping;
 };
 
 typedef struct amb_dev amb_dev;
diff -Nru a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
--- a/drivers/atm/atmtcp.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/atm/atmtcp.c	2004-12-24 13:37:01 -08:00
@@ -271,6 +271,28 @@
 		}
 	}
 	read_unlock(&vcc_sklist_lock);
+	module_put(THIS_MODULE);
+}
+
+
+static struct atm_vcc *find_vcc(struct atm_dev *dev, short vpi, int vci)
+{
+        struct hlist_head *head;
+        struct atm_vcc *vcc;
+        struct hlist_node *node;
+        struct sock *s;
+
+        head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)];
+
+        sk_for_each(s, node, head) {
+                vcc = atm_sk(s);
+                if (vcc->dev == dev &&
+                    vcc->vci == vci && vcc->vpi == vpi &&
+                    vcc->qos.rxtp.traffic_class != ATM_NONE) {
+                                return vcc;
+                }
+        }
+        return NULL;
 }
 
 
@@ -278,11 +300,9 @@
 {
 	struct atm_dev *dev;
 	struct atmtcp_hdr *hdr;
-	struct sock *s;
-	struct hlist_node *node;
-	struct atm_vcc *out_vcc = NULL;
+	struct atm_vcc *out_vcc;
 	struct sk_buff *new_skb;
-	int i, result = 0;
+	int result = 0;
 
 	if (!skb->len) return 0;
 	dev = vcc->dev_data;
@@ -293,19 +313,7 @@
 		goto done;
 	}
 	read_lock(&vcc_sklist_lock);
-	for(i = 0; i < VCC_HTABLE_SIZE; ++i) {
-		struct hlist_head *head = &vcc_hash[i];
-
-		sk_for_each(s, node, head) {
-			out_vcc = atm_sk(s);
-			if (out_vcc->dev != dev)
-				continue;
-			if (out_vcc->vpi == ntohs(hdr->vpi) &&
-			    out_vcc->vci == ntohs(hdr->vci) &&
-			    out_vcc->qos.rxtp.traffic_class != ATM_NONE)
-				break;
-		}
-	}
+	out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
 	read_unlock(&vcc_sklist_lock);
 	if (!out_vcc) {
 		atomic_inc(&vcc->stats->tx_err);
diff -Nru a/drivers/atm/eni.c b/drivers/atm/eni.c
--- a/drivers/atm/eni.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/atm/eni.c	2004-12-24 13:36:31 -08:00
@@ -245,7 +245,7 @@
 	list = eni_dev->free_list;
 	len = eni_dev->free_len;
 	if (*size < MID_MIN_BUF_SIZE) *size = MID_MIN_BUF_SIZE;
-	if (*size > MID_MAX_BUF_SIZE) return 0;
+	if (*size > MID_MAX_BUF_SIZE) return NULL;
 	for (order = 0; (1 << order) < *size; order++);
 	DPRINTK("trying: %ld->%d\n",*size,order);
 	best_order = 65; /* we don't have more than 2^64 of anything ... */
@@ -260,7 +260,7 @@
 				best_order = list[i].order;
 				index = i;
 			}
-	if (best_order == 65) return 0;
+	if (best_order == 65) return NULL;
 	start = list[index].start-eni_dev->base_diff;
 	list[index] = list[--len];
 	eni_dev->free_len = len;
@@ -1315,7 +1315,7 @@
 		size = UBR_BUFFER;
 	}
 	new_tx = !eni_vcc->tx;
-	mem = 0; /* for gcc */
+	mem = NULL; /* for gcc */
 	if (!new_tx) tx = eni_vcc->tx;
 	else {
 		mem = eni_alloc_mem(eni_dev,&size);
@@ -1349,7 +1349,7 @@
 		error = -EINVAL;
 	if (error) {
 		if (new_tx) {
-			tx->send = 0;
+			tx->send = NULL;
 			eni_free_mem(eni_dev,mem,size);
 		}
 		return error;
@@ -1423,7 +1423,7 @@
 		    eni_in(MID_TX_DESCRSTART(eni_vcc->tx->index)))
 			schedule();
 		eni_free_mem(eni_dev,eni_vcc->tx->send,eni_vcc->tx->words << 2);
-		eni_vcc->tx->send = 0;
+		eni_vcc->tx->send = NULL;
 		eni_dev->tx_bw += eni_vcc->tx->reserved;
 	}
 	eni_vcc->tx = NULL;
@@ -1444,7 +1444,7 @@
 	skb_queue_head_init(&eni_dev->tx_queue);
 	eni_out(0,MID_DMA_WR_TX);
 	for (i = 0; i < NR_CHAN; i++) {
-		eni_dev->tx[i].send = 0;
+		eni_dev->tx[i].send = NULL;
 		eni_dev->tx[i].index = i;
 	}
 	return 0;
@@ -1702,7 +1702,7 @@
 
 static int __devinit eni_do_init(struct atm_dev *dev)
 {
-	struct midway_eprom *eprom;
+	struct midway_eprom __iomem *eprom;
 	struct eni_dev *eni_dev;
 	struct pci_dev *pci_dev;
 	unsigned long real_base;
@@ -1742,8 +1742,7 @@
 	eni_dev->base_diff = real_base - (unsigned long) base;
 	/* id may not be present in ASIC Tonga boards - check this @@@ */
 	if (!eni_dev->asic) {
-		eprom = (struct midway_eprom *) (base+EPROM_SIZE-sizeof(struct
-		    midway_eprom));
+		eprom = (base+EPROM_SIZE-sizeof(struct midway_eprom));
 		if (readl(&eprom->magic) != ENI155_MAGIC) {
 			printk("\n");
 			printk(KERN_ERR KERN_ERR DEV_LABEL "(itf %d): bad "
@@ -2290,9 +2289,7 @@
 		    sizeof(skb->cb),sizeof(struct eni_skb_prv));
 		return -EIO;
 	}
-	if (pci_register_driver(&eni_driver) > 0) return 0;
-	pci_unregister_driver (&eni_driver);
-	return -ENODEV;
+	return pci_register_driver(&eni_driver);
 }
 
 
diff -Nru a/drivers/atm/firestream.c b/drivers/atm/firestream.c
--- a/drivers/atm/firestream.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/atm/firestream.c	2004-12-24 13:36:18 -08:00
@@ -306,11 +306,11 @@
 
 #ifdef MODULE
 #ifdef DEBUG 
-MODULE_PARM(fs_debug, "i");
+module_param(fs_debug, int, 0644);
 #endif
-MODULE_PARM(loopback, "i");
-MODULE_PARM(num, "i");
-MODULE_PARM(fs_keystream, "i");
+module_param(loopback, int, 0);
+module_param(num, int, 0);
+module_param(fs_keystream, int, 0);
 /* XXX Add rx_buf_sizes, and rx_pool_sizes As per request Amar. -- REW */
 #endif
 
@@ -2012,66 +2012,6 @@
 	func_exit ();
 }
 
-
-#if 0
-int __init fs_detect(void)
-{
-	struct pci_dev  *pci_dev;
-	int devs = 0;
-
-	func_enter ();
-	pci_dev = NULL;
-	while ((pci_dev = pci_find_device(PCI_VENDOR_ID_FUJITSU_ME,
-					  PCI_DEVICE_ID_FUJITSU_FS50, 
-					  pci_dev))) {
-		if (fs_register_and_init (pci_dev, &fs_pci_tbl[0]))
-			break;
-		devs++;
-	}
-
-	while ((pci_dev = pci_find_device(PCI_VENDOR_ID_FUJITSU_ME,
-					  PCI_DEVICE_ID_FUJITSU_FS155, 
-					  pci_dev))) {
-		if (fs_register_and_init (pci_dev, FS_IS155)) 
-			break;
-		devs++;
-	}
-	func_exit ();
-	return devs;
-}
-#else
-
-#if 0
-int __init init_PCI (void)
-{ /* Begin init_PCI */
-	
-	int pci_count;
-	printk ("init_PCI\n");
-	/*
-	  memset (&firestream_driver, 0, sizeof (firestream_driver));
-	  firestream_driver.name = "firestream";
-	  firestream_driver.id_table = firestream_pci_tbl;
-	  firestream_driver.probe = fs_register_and_init;
-	*/
-	pci_count = pci_register_driver (&firestream_driver);
-	
-	if (pci_count <= 0) {
-		pci_unregister_driver (&firestream_driver);
-		pci_count = 0;
-	}
-
-	return(pci_count);
-
-} /* End init_PCI */
-#endif
-#endif
-
-/*
-#ifdef MODULE
-#define firestream_init init_module
-#endif 
-*/
-
 static struct pci_device_id firestream_pci_tbl[] = {
 	{ PCI_VENDOR_ID_FUJITSU_ME, PCI_DEVICE_ID_FUJITSU_FS50, 
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, FS_IS50},
@@ -2108,5 +2048,6 @@
 module_exit(firestream_cleanup_module);
 
 MODULE_LICENSE("GPL");
+
 
 
diff -Nru a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
--- a/drivers/atm/fore200e.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/atm/fore200e.c	2004-12-24 13:37:31 -08:00
@@ -275,7 +275,7 @@
 
 
 static int
-fore200e_io_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int msecs)
+fore200e_io_poll(struct fore200e* fore200e, volatile u32 __iomem *addr, u32 val, int msecs)
 {
     unsigned long timeout = jiffies + MSECS(msecs);
     int           ok;
@@ -347,7 +347,7 @@
 {
     int ok;
 
-    fore200e->cp_monitor = (struct cp_monitor*)(fore200e->virt_base + FORE200E_CP_MONITOR_OFFSET);
+    fore200e->cp_monitor = fore200e->virt_base + FORE200E_CP_MONITOR_OFFSET;
     
     fore200e->bus->write(BSTAT_COLD_START, &fore200e->cp_monitor->bstat);
 
@@ -440,7 +440,7 @@
 
 #ifdef CONFIG_ATM_FORE200E_PCA
 
-static u32 fore200e_pca_read(volatile u32* addr)
+static u32 fore200e_pca_read(volatile u32 __iomem *addr)
 {
     /* on big-endian hosts, the board is configured to convert
        the endianess of slave RAM accesses  */
@@ -448,7 +448,7 @@
 }
 
 
-static void fore200e_pca_write(u32 val, volatile u32* addr)
+static void fore200e_pca_write(u32 val, volatile u32 __iomem *addr)
 {
     /* on big-endian hosts, the board is configured to convert
        the endianess of slave RAM accesses  */
@@ -576,9 +576,9 @@
     DPRINTK(1, "device %s mapped to 0x%p\n", fore200e->name, fore200e->virt_base);
 
     /* gain access to the PCA specific registers  */
-    fore200e->regs.pca.hcr = (u32*)(fore200e->virt_base + PCA200E_HCR_OFFSET);
-    fore200e->regs.pca.imr = (u32*)(fore200e->virt_base + PCA200E_IMR_OFFSET);
-    fore200e->regs.pca.psr = (u32*)(fore200e->virt_base + PCA200E_PSR_OFFSET);
+    fore200e->regs.pca.hcr = fore200e->virt_base + PCA200E_HCR_OFFSET;
+    fore200e->regs.pca.imr = fore200e->virt_base + PCA200E_IMR_OFFSET;
+    fore200e->regs.pca.psr = fore200e->virt_base + PCA200E_PSR_OFFSET;
 
     fore200e->state = FORE200E_STATE_MAP;
     return 0;
@@ -689,7 +689,7 @@
     
     *entry->status = STATUS_PENDING;
 
-    fore200e->bus->write(*(u32*)&opcode, (u32*)&entry->cp_entry->cmd.prom_block.opcode);
+    fore200e->bus->write(*(u32*)&opcode, (u32 __iomem *)&entry->cp_entry->cmd.prom_block.opcode);
 
     ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400);
 
@@ -730,14 +730,14 @@
 #ifdef CONFIG_ATM_FORE200E_SBA
 
 static u32
-fore200e_sba_read(volatile u32* addr)
+fore200e_sba_read(volatile u32 __iomem *addr)
 {
     return sbus_readl(addr);
 }
 
 
 static void
-fore200e_sba_write(u32 val, volatile u32* addr)
+fore200e_sba_write(u32 val, volatile u32 __iomem *addr)
 {
     sbus_writel(val, addr);
 }
@@ -856,10 +856,10 @@
     unsigned int bursts;
 
     /* gain access to the SBA specific registers  */
-    fore200e->regs.sba.hcr = (u32*)sbus_ioremap(&sbus_dev->resource[0], 0, SBA200E_HCR_LENGTH, "SBA HCR");
-    fore200e->regs.sba.bsr = (u32*)sbus_ioremap(&sbus_dev->resource[1], 0, SBA200E_BSR_LENGTH, "SBA BSR");
-    fore200e->regs.sba.isr = (u32*)sbus_ioremap(&sbus_dev->resource[2], 0, SBA200E_ISR_LENGTH, "SBA ISR");
-    fore200e->virt_base    = (u32*)sbus_ioremap(&sbus_dev->resource[3], 0, SBA200E_RAM_LENGTH, "SBA RAM");
+    fore200e->regs.sba.hcr = sbus_ioremap(&sbus_dev->resource[0], 0, SBA200E_HCR_LENGTH, "SBA HCR");
+    fore200e->regs.sba.bsr = sbus_ioremap(&sbus_dev->resource[1], 0, SBA200E_BSR_LENGTH, "SBA BSR");
+    fore200e->regs.sba.isr = sbus_ioremap(&sbus_dev->resource[2], 0, SBA200E_ISR_LENGTH, "SBA ISR");
+    fore200e->virt_base    = sbus_ioremap(&sbus_dev->resource[3], 0, SBA200E_RAM_LENGTH, "SBA RAM");
 
     if (fore200e->virt_base == NULL) {
 	printk(FORE200E "unable to map RAM of device %s\n", fore200e->name);
@@ -884,10 +884,10 @@
 static void
 fore200e_sba_unmap(struct fore200e* fore200e)
 {
-    sbus_iounmap((ulong)fore200e->regs.sba.hcr, SBA200E_HCR_LENGTH);
-    sbus_iounmap((ulong)fore200e->regs.sba.bsr, SBA200E_BSR_LENGTH);
-    sbus_iounmap((ulong)fore200e->regs.sba.isr, SBA200E_ISR_LENGTH);
-    sbus_iounmap((ulong)fore200e->virt_base,    SBA200E_RAM_LENGTH);
+    sbus_iounmap(fore200e->regs.sba.hcr, SBA200E_HCR_LENGTH);
+    sbus_iounmap(fore200e->regs.sba.bsr, SBA200E_BSR_LENGTH);
+    sbus_iounmap(fore200e->regs.sba.isr, SBA200E_ISR_LENGTH);
+    sbus_iounmap(fore200e->virt_base,    SBA200E_RAM_LENGTH);
 }
 
 
@@ -1477,12 +1477,12 @@
 #endif
 	/* the MTU is not used by the cp, except in the case of AAL0 */
 	fore200e->bus->write(mtu,                        &entry->cp_entry->cmd.activate_block.mtu);
-	fore200e->bus->write(*(u32*)&vpvc,         (u32*)&entry->cp_entry->cmd.activate_block.vpvc);
-	fore200e->bus->write(*(u32*)&activ_opcode, (u32*)&entry->cp_entry->cmd.activate_block.opcode);
+	fore200e->bus->write(*(u32*)&vpvc,         (u32 __iomem *)&entry->cp_entry->cmd.activate_block.vpvc);
+	fore200e->bus->write(*(u32*)&activ_opcode, (u32 __iomem *)&entry->cp_entry->cmd.activate_block.opcode);
     }
     else {
-	fore200e->bus->write(*(u32*)&vpvc,           (u32*)&entry->cp_entry->cmd.deactivate_block.vpvc);
-	fore200e->bus->write(*(u32*)&deactiv_opcode, (u32*)&entry->cp_entry->cmd.deactivate_block.opcode);
+	fore200e->bus->write(*(u32*)&vpvc,         (u32 __iomem *)&entry->cp_entry->cmd.deactivate_block.vpvc);
+	fore200e->bus->write(*(u32*)&deactiv_opcode, (u32 __iomem *)&entry->cp_entry->cmd.deactivate_block.opcode);
     }
 
     ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400);
@@ -1858,7 +1858,7 @@
     tpd_haddr.haddr = entry->tpd_dma >> TPD_HADDR_SHIFT;          /* shift the address, as we are in a bitfield */
 
     *entry->status = STATUS_PENDING;
-    fore200e->bus->write(*(u32*)&tpd_haddr, (u32*)&entry->cp_entry->tpd_haddr);
+    fore200e->bus->write(*(u32*)&tpd_haddr, (u32 __iomem *)&entry->cp_entry->tpd_haddr);
 
     spin_unlock_irqrestore(&fore200e->q_lock, flags);
 
@@ -1893,7 +1893,7 @@
     
     *entry->status = STATUS_PENDING;
 
-    fore200e->bus->write(*(u32*)&opcode, (u32*)&entry->cp_entry->cmd.stats_block.opcode);
+    fore200e->bus->write(*(u32*)&opcode, (u32 __iomem *)&entry->cp_entry->cmd.stats_block.opcode);
 
     ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400);
 
@@ -1996,7 +1996,7 @@
     
     *entry->status = STATUS_PENDING;
 
-    fore200e->bus->write(*(u32*)&opcode, (u32*)&entry->cp_entry->cmd.oc3_block.opcode);
+    fore200e->bus->write(*(u32*)&opcode, (u32 __iomem *)&entry->cp_entry->cmd.oc3_block.opcode);
 
     ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400);
 
@@ -2291,7 +2291,7 @@
     int scheme, magn, i;
 
     struct host_bsq*     bsq;
-    struct cp_bsq_entry* cp_entry;
+    struct cp_bsq_entry __iomem * cp_entry;
 
     for (scheme = 0; scheme < BUFFER_SCHEME_NBR; scheme++) {
 	for (magn = 0; magn < BUFFER_MAGN_NBR; magn++) {
@@ -2321,8 +2321,8 @@
 	    }
 	    
 	    /* get the base address of the cp resident buffer supply queue entries */
-	    cp_entry = (struct cp_bsq_entry*)(fore200e->virt_base + 
-		       fore200e->bus->read(&fore200e->cp_queues->cp_bsq[ scheme ][ magn ]));
+	    cp_entry = fore200e->virt_base + 
+		       fore200e->bus->read(&fore200e->cp_queues->cp_bsq[ scheme ][ magn ]);
 	    
 	    /* fill the host resident and cp resident buffer supply queue entries */
 	    for (i = 0; i < QUEUE_SIZE_BS; i++) {
@@ -2352,7 +2352,7 @@
 fore200e_init_rx_queue(struct fore200e* fore200e)
 {
     struct host_rxq*     rxq =  &fore200e->host_rxq;
-    struct cp_rxq_entry* cp_entry;
+    struct cp_rxq_entry __iomem * cp_entry;
     int i;
 
     DPRINTK(2, "receive queue is being initialized\n");
@@ -2378,8 +2378,7 @@
     }
 
     /* get the base address of the cp resident rx queue entries */
-    cp_entry = (struct cp_rxq_entry*)(fore200e->virt_base + 
-				      fore200e->bus->read(&fore200e->cp_queues->cp_rxq));
+    cp_entry = fore200e->virt_base + fore200e->bus->read(&fore200e->cp_queues->cp_rxq);
 
     /* fill the host resident and cp resident rx entries */
     for (i=0; i < QUEUE_SIZE_RX; i++) {
@@ -2413,7 +2412,7 @@
 fore200e_init_tx_queue(struct fore200e* fore200e)
 {
     struct host_txq*     txq =  &fore200e->host_txq;
-    struct cp_txq_entry* cp_entry;
+    struct cp_txq_entry __iomem * cp_entry;
     int i;
 
     DPRINTK(2, "transmit queue is being initialized\n");
@@ -2439,8 +2438,7 @@
     }
 
     /* get the base address of the cp resident tx queue entries */
-    cp_entry = (struct cp_txq_entry*)(fore200e->virt_base + 
-				      fore200e->bus->read(&fore200e->cp_queues->cp_txq));
+    cp_entry = fore200e->virt_base + fore200e->bus->read(&fore200e->cp_queues->cp_txq);
 
     /* fill the host resident and cp resident tx entries */
     for (i=0; i < QUEUE_SIZE_TX; i++) {
@@ -2477,7 +2475,7 @@
 fore200e_init_cmd_queue(struct fore200e* fore200e)
 {
     struct host_cmdq*     cmdq =  &fore200e->host_cmdq;
-    struct cp_cmdq_entry* cp_entry;
+    struct cp_cmdq_entry __iomem * cp_entry;
     int i;
 
     DPRINTK(2, "command queue is being initialized\n");
@@ -2492,8 +2490,7 @@
     }
     
     /* get the base address of the cp resident cmd queue entries */
-    cp_entry = (struct cp_cmdq_entry*)(fore200e->virt_base + 
-				       fore200e->bus->read(&fore200e->cp_queues->cp_cmdq));
+    cp_entry = fore200e->virt_base + fore200e->bus->read(&fore200e->cp_queues->cp_cmdq);
 
     /* fill the host resident and cp resident cmd entries */
     for (i=0; i < QUEUE_SIZE_CMD; i++) {
@@ -2521,7 +2518,7 @@
 			enum buffer_scheme scheme, enum buffer_magn magn,
 			int queue_length, int pool_size, int supply_blksize)
 {
-    struct bs_spec* bs_spec = &fore200e->cp_queues->init.bs_spec[ scheme ][ magn ];
+    struct bs_spec __iomem * bs_spec = &fore200e->cp_queues->init.bs_spec[ scheme ][ magn ];
 
     fore200e->bus->write(queue_length,                           &bs_spec->queue_length);
     fore200e->bus->write(fore200e_rx_buf_size[ scheme ][ magn ], &bs_spec->buffer_size);
@@ -2533,7 +2530,7 @@
 static int __init
 fore200e_initialize(struct fore200e* fore200e)
 {
-    struct cp_queues* cpq;
+    struct cp_queues __iomem * cpq;
     int               ok, scheme, magn;
 
     DPRINTK(2, "device %s being initialized\n", fore200e->name);
@@ -2541,7 +2538,7 @@
     init_MUTEX(&fore200e->rate_sf);
     spin_lock_init(&fore200e->q_lock);
 
-    cpq = fore200e->cp_queues = (struct cp_queues*) (fore200e->virt_base + FORE200E_CP_QUEUES_OFFSET);
+    cpq = fore200e->cp_queues = fore200e->virt_base + FORE200E_CP_QUEUES_OFFSET;
 
     /* enable cp to host interrupts */
     fore200e->bus->write(1, &cpq->imask);
@@ -2585,7 +2582,7 @@
 static void __init
 fore200e_monitor_putc(struct fore200e* fore200e, char c)
 {
-    struct cp_monitor* monitor = fore200e->cp_monitor;
+    struct cp_monitor __iomem * monitor = fore200e->cp_monitor;
 
 #if 0
     printk("%c", c);
@@ -2597,7 +2594,7 @@
 static int __init
 fore200e_monitor_getc(struct fore200e* fore200e)
 {
-    struct cp_monitor* monitor = fore200e->cp_monitor;
+    struct cp_monitor __iomem * monitor = fore200e->cp_monitor;
     unsigned long      timeout = jiffies + MSECS(50);
     int                c;
 
@@ -2673,7 +2670,7 @@
 
     struct fw_header* fw_header = (struct fw_header*) fw_data;
 
-    u32* load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset);
+    u32 __iomem *load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset);
 
     DPRINTK(2, "device %s firmware being loaded at 0x%p (%d words)\n", 
 	    fore200e->name, load_addr, fw_size);
@@ -2854,7 +2851,7 @@
 		"   board serial number:\t\t%d\n\n",
 		fore200e_irq_itoa(fore200e->irq),
 		(void*)fore200e->phys_base,
-		(void*)fore200e->virt_base,
+		fore200e->virt_base,
 		fore200e->esi[0], fore200e->esi[1], fore200e->esi[2],
 		fore200e->esi[3], fore200e->esi[4], fore200e->esi[5],
 		fore200e->esi[4] * 256 + fore200e->esi[5]);
@@ -2938,7 +2935,7 @@
     }
 
     if (!left--) {
-	struct cp_monitor* cp_monitor = fore200e->cp_monitor;
+	struct cp_monitor __iomem * cp_monitor = fore200e->cp_monitor;
 
 	return sprintf(page,
 		       "\n\n"
diff -Nru a/drivers/atm/fore200e.h b/drivers/atm/fore200e.h
--- a/drivers/atm/fore200e.h	2004-12-24 13:36:55 -08:00
+++ b/drivers/atm/fore200e.h	2004-12-24 13:36:55 -08:00
@@ -520,7 +520,7 @@
 /* host resident transmit queue entry */
 
 typedef struct host_txq_entry {
-    struct cp_txq_entry*    cp_entry;    /* addr of cp resident tx queue entry       */
+    struct cp_txq_entry __iomem *cp_entry;    /* addr of cp resident tx queue entry       */
     enum   status*          status;      /* addr of host resident status             */
     struct tpd*             tpd;         /* addr of transmit PDU descriptor          */
     u32                     tpd_dma;     /* DMA address of tpd                       */
@@ -535,7 +535,7 @@
 /* host resident receive queue entry */
 
 typedef struct host_rxq_entry {
-    struct cp_rxq_entry* cp_entry;    /* addr of cp resident rx queue entry */
+    struct cp_rxq_entry __iomem *cp_entry;    /* addr of cp resident rx queue entry */
     enum   status*       status;      /* addr of host resident status       */
     struct rpd*          rpd;         /* addr of receive PDU descriptor     */
     u32                  rpd_dma;     /* DMA address of rpd                 */
@@ -545,7 +545,7 @@
 /* host resident buffer supply queue entry */
 
 typedef struct host_bsq_entry {
-    struct cp_bsq_entry* cp_entry;         /* addr of cp resident buffer supply queue entry */
+    struct cp_bsq_entry __iomem *cp_entry;         /* addr of cp resident buffer supply queue entry */
     enum   status*       status;           /* addr of host resident status                  */
     struct rbd_block*    rbd_block;        /* addr of receive buffer descriptor block       */
     u32                  rbd_block_dma;    /* DMA address od rdb                            */
@@ -555,7 +555,7 @@
 /* host resident command queue entry */
 
 typedef struct host_cmdq_entry {
-    struct cp_cmdq_entry* cp_entry;    /* addr of cp resident cmd queue entry */
+    struct cp_cmdq_entry __iomem *cp_entry;    /* addr of cp resident cmd queue entry */
     enum status *status;	       /* addr of host resident status        */
 } host_cmdq_entry_t;
 
@@ -645,7 +645,7 @@
 
 typedef struct fw_header {
     u32 magic;           /* magic number                               */
-    u32 version;         /* firware version id                         */
+    u32 version;         /* firmware version id                        */
     u32 load_offset;     /* fw load offset in board memory             */
     u32 start_offset;    /* fw execution start address in board memory */
 } fw_header_t;
@@ -772,18 +772,18 @@
 /* PCA-200E registers */
 
 typedef struct fore200e_pca_regs {
-    volatile u32* hcr;    /* address of host control register        */
-    volatile u32* imr;    /* address of host interrupt mask register */
-    volatile u32* psr;    /* address of PCI specific register        */
+    volatile u32 __iomem * hcr;    /* address of host control register        */
+    volatile u32 __iomem * imr;    /* address of host interrupt mask register */
+    volatile u32 __iomem * psr;    /* address of PCI specific register        */
 } fore200e_pca_regs_t;
 
 
 /* SBA-200E registers */
 
 typedef struct fore200e_sba_regs {
-    volatile u32* hcr;    /* address of host control register              */
-    volatile u32* bsr;    /* address of burst transfer size register       */
-    volatile u32* isr;    /* address of interrupt level selection register */
+    volatile u32 __iomem *hcr;    /* address of host control register              */
+    volatile u32 __iomem *bsr;    /* address of burst transfer size register       */
+    volatile u32 __iomem *isr;    /* address of interrupt level selection register */
 } fore200e_sba_regs_t;
 
 
@@ -807,8 +807,8 @@
     int                  status_alignment;    /* status words DMA alignment requirement */
     const unsigned char* fw_data;             /* address of firmware data start         */
     const unsigned int*  fw_size;             /* address of firmware data size          */
-    u32                  (*read)(volatile u32*);
-    void                 (*write)(u32, volatile u32*);
+    u32                  (*read)(volatile u32 __iomem *);
+    void                 (*write)(u32, volatile u32 __iomem *);
     u32                  (*dma_map)(struct fore200e*, void*, int, int);
     void                 (*dma_unmap)(struct fore200e*, u32, int, int);
     void                 (*dma_sync_for_cpu)(struct fore200e*, u32, int, int);
@@ -852,12 +852,12 @@
     void*                      bus_dev;                /* bus-specific kernel data           */
     int                        irq;                    /* irq number                         */
     unsigned long              phys_base;              /* physical base address              */
-    void*                      virt_base;              /* virtual base address               */
+    void __iomem *             virt_base;              /* virtual base address               */
     
     unsigned char              esi[ ESI_LEN ];         /* end system identifier              */
 
-    struct cp_monitor*         cp_monitor;             /* i960 monitor address               */
-    struct cp_queues*          cp_queues;              /* cp resident queues                 */
+    struct cp_monitor __iomem *         cp_monitor;    /* i960 monitor address               */
+    struct cp_queues __iomem *          cp_queues;              /* cp resident queues                 */
     struct host_cmdq           host_cmdq;              /* host resident cmd queue            */
     struct host_txq            host_txq;               /* host resident tx queue             */
     struct host_rxq            host_rxq;               /* host resident rx queue             */
diff -Nru a/drivers/atm/he.c b/drivers/atm/he.c
--- a/drivers/atm/he.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/atm/he.c	2004-12-24 13:36:19 -08:00
@@ -148,12 +148,12 @@
 /* globals */
 
 struct he_dev *he_devs = NULL;
-static short disable64 = -1;
+static int disable64 = 0;
 static short nvpibits = -1;
 static short nvcibits = -1;
 static short rx_skb_reserve = 16;
-static short irq_coalesce = 1;
-static short sdh = 0;
+static int irq_coalesce = 1;
+static int sdh = 0;
 
 static struct atmdev_ops he_ops =
 {
@@ -1701,7 +1701,7 @@
 	}
 	
 	if (he_dev->membase)
-		iounmap((void *) he_dev->membase);
+		iounmap(he_dev->membase);
 }
 
 static struct he_tpd *
@@ -3032,17 +3032,17 @@
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("chas williams <chas@cmf.nrl.navy.mil>");
 MODULE_DESCRIPTION("ForeRunnerHE ATM Adapter driver");
-MODULE_PARM(disable64, "h");
+module_param(disable64, bool, 0);
 MODULE_PARM_DESC(disable64, "disable 64-bit pci bus transfers");
-MODULE_PARM(nvpibits, "i");
+module_param(nvpibits, short, 0);
 MODULE_PARM_DESC(nvpibits, "numbers of bits for vpi (default 0)");
-MODULE_PARM(nvcibits, "i");
+module_param(nvcibits, short, 0);
 MODULE_PARM_DESC(nvcibits, "numbers of bits for vci (default 12)");
-MODULE_PARM(rx_skb_reserve, "i");
+module_param(rx_skb_reserve, short, 0);
 MODULE_PARM_DESC(rx_skb_reserve, "padding for receive skb (default 16)");
-MODULE_PARM(irq_coalesce, "i");
+module_param(irq_coalesce, bool, 0);
 MODULE_PARM_DESC(irq_coalesce, "use interrupt coalescing (default 1)");
-MODULE_PARM(sdh, "i");
+module_param(sdh, bool, 0);
 MODULE_PARM_DESC(sdh, "use SDH framing (default 0)");
 
 static struct pci_device_id he_pci_tbl[] = {
@@ -3050,6 +3050,8 @@
 	  0, 0, 0 },
 	{ 0, }
 };
+
+MODULE_DEVICE_TABLE(pci, he_pci_tbl);
 
 static struct pci_driver he_driver = {
 	.name =		"he",
diff -Nru a/drivers/atm/horizon.c b/drivers/atm/horizon.c
--- a/drivers/atm/horizon.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/atm/horizon.c	2004-12-24 13:36:16 -08:00
@@ -354,8 +354,7 @@
 
 /********** globals **********/
 
-static hrz_dev * hrz_devs = NULL;
-static struct timer_list housekeeping;
+static void do_housekeeping (unsigned long arg);
 
 static unsigned short debug = 0;
 static unsigned short vpi_bits = 0;
@@ -1386,7 +1385,7 @@
 
 static irqreturn_t interrupt_handler(int irq, void *dev_id,
 					struct pt_regs *pt_regs) {
-  hrz_dev * dev = hrz_devs;
+  hrz_dev * dev = (hrz_dev *) dev_id;
   u32 int_source;
   unsigned int irq_ok;
   (void) pt_regs;
@@ -1397,16 +1396,6 @@
     PRINTD (DBG_IRQ|DBG_ERR, "irq with NULL dev_id: %d", irq);
     return IRQ_NONE;
   }
-  // Did one of our cards generate the interrupt?
-  while (dev) {
-    if (dev == dev_id)
-      break;
-    dev = dev->prev;
-  }
-  if (!dev) {
-    PRINTD (DBG_IRQ, "irq not for me: %d", irq);
-    return IRQ_NONE;
-  }
   if (irq != dev->irq) {
     PRINTD (DBG_IRQ|DBG_ERR, "irq mismatch: %d", irq);
     return IRQ_NONE;
@@ -1462,28 +1451,18 @@
 
 /********** housekeeping **********/
 
-static void set_timer (struct timer_list * timer, unsigned int delay) {
-  timer->expires = jiffies + delay;
-  add_timer (timer);
-  return;
-}
-
 static void do_housekeeping (unsigned long arg) {
   // just stats at the moment
-  hrz_dev * dev = hrz_devs;
-  (void) arg;
-  // data is set to zero at module unload
-  if (housekeeping.data) {
-    while (dev) {
-      // collect device-specific (not driver/atm-linux) stats here
-      dev->tx_cell_count += rd_regw (dev, TX_CELL_COUNT_OFF);
-      dev->rx_cell_count += rd_regw (dev, RX_CELL_COUNT_OFF);
-      dev->hec_error_count += rd_regw (dev, HEC_ERROR_COUNT_OFF);
-      dev->unassigned_cell_count += rd_regw (dev, UNASSIGNED_CELL_COUNT_OFF);
-      dev = dev->prev;
-    }
-    set_timer (&housekeeping, HZ/10);
-  }
+  hrz_dev * dev = (hrz_dev *) arg;
+
+  // collect device-specific (not driver/atm-linux) stats here
+  dev->tx_cell_count += rd_regw (dev, TX_CELL_COUNT_OFF);
+  dev->rx_cell_count += rd_regw (dev, RX_CELL_COUNT_OFF);
+  dev->hec_error_count += rd_regw (dev, HEC_ERROR_COUNT_OFF);
+  dev->unassigned_cell_count += rd_regw (dev, UNASSIGNED_CELL_COUNT_OFF);
+
+  mod_timer (&dev->housekeeping, jiffies + HZ/10);
+
   return;
 }
 
@@ -2719,157 +2698,176 @@
   .owner	= THIS_MODULE,
 };
 
-static int __init hrz_probe (void) {
-  struct pci_dev * pci_dev;
-  int devs;
-  
-  PRINTD (DBG_FLOW, "hrz_probe");
-  
-  devs = 0;
-  pci_dev = NULL;
-  while ((pci_dev = pci_find_device
-	  (PCI_VENDOR_ID_MADGE, PCI_DEVICE_ID_MADGE_HORIZON, pci_dev)
-	  )) {
-    hrz_dev * dev;
-    
-    // adapter slot free, read resources from PCI configuration space
-    u32 iobase = pci_resource_start (pci_dev, 0);
-    u32 * membase = bus_to_virt (pci_resource_start (pci_dev, 1));
-    u8 irq = pci_dev->irq;
-    
-    /* XXX DEV_LABEL is a guess */
-    if (!request_region (iobase, HRZ_IO_EXTENT, DEV_LABEL))
-  	  continue;
-
-    if (pci_enable_device (pci_dev))
-      continue;
-    
-    dev = kmalloc (sizeof(hrz_dev), GFP_KERNEL);
-    if (!dev) {
-      // perhaps we should be nice: deregister all adapters and abort?
-      PRINTD (DBG_ERR, "out of memory");
-      continue;
-    }
-    
-    memset (dev, 0, sizeof(hrz_dev));
-    
-    // grab IRQ and install handler - move this someplace more sensible
-    if (request_irq (irq,
-		     interrupt_handler,
-		     SA_SHIRQ, /* irqflags guess */
-		     DEV_LABEL, /* name guess */
-		     dev)) {
-      PRINTD (DBG_WARN, "request IRQ failed!");
-      // free_irq is at "endif"
-    } else {
-      
-      PRINTD (DBG_INFO, "found Madge ATM adapter (hrz) at: IO %x, IRQ %u, MEM %p",
-	      iobase, irq, membase);
-      
-      dev->atm_dev = atm_dev_register (DEV_LABEL, &hrz_ops, -1, NULL);
-      if (!(dev->atm_dev)) {
-	PRINTD (DBG_ERR, "failed to register Madge ATM adapter");
-      } else {
+static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
+{
+	hrz_dev * dev;
+	int err = 0;
+
+	// adapter slot free, read resources from PCI configuration space
+	u32 iobase = pci_resource_start (pci_dev, 0);
+	u32 * membase = bus_to_virt (pci_resource_start (pci_dev, 1));
+	u8 irq = pci_dev->irq;
 	unsigned char lat;
-	
-	PRINTD (DBG_INFO, "registered Madge ATM adapter (no. %d) (%p) at %p",
-		dev->atm_dev->number, dev, dev->atm_dev);
+
+	PRINTD (DBG_FLOW, "hrz_probe");
+
+	/* XXX DEV_LABEL is a guess */
+	if (!request_region(iobase, HRZ_IO_EXTENT, DEV_LABEL))
+		return -EINVAL;
+
+	if (pci_enable_device(pci_dev)) {
+		err = -EINVAL;
+		goto out_release;
+	}
+
+	dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
+	if (!dev) {
+		// perhaps we should be nice: deregister all adapters and abort?
+		PRINTD(DBG_ERR, "out of memory");
+		err = -ENOMEM;
+		goto out_disable;
+	}
+
+	memset(dev, 0, sizeof(hrz_dev));
+
+	pci_set_drvdata(pci_dev, dev);
+
+	// grab IRQ and install handler - move this someplace more sensible
+	if (request_irq(irq,
+			interrupt_handler,
+			SA_SHIRQ, /* irqflags guess */
+			DEV_LABEL, /* name guess */
+			dev)) {
+		PRINTD(DBG_WARN, "request IRQ failed!");
+		err = -EINVAL;
+		goto out_free;
+	}
+
+	PRINTD(DBG_INFO, "found Madge ATM adapter (hrz) at: IO %x, IRQ %u, MEM %p",
+	       iobase, irq, membase);
+
+	dev->atm_dev = atm_dev_register(DEV_LABEL, &hrz_ops, -1, NULL);
+	if (!(dev->atm_dev)) {
+		PRINTD(DBG_ERR, "failed to register Madge ATM adapter");
+		err = -EINVAL;
+		goto out_free_irq;
+	}
+
+	PRINTD(DBG_INFO, "registered Madge ATM adapter (no. %d) (%p) at %p",
+	       dev->atm_dev->number, dev, dev->atm_dev);
 	dev->atm_dev->dev_data = (void *) dev;
 	dev->pci_dev = pci_dev; 
-	
+
 	// enable bus master accesses
-	pci_set_master (pci_dev);
-	
+	pci_set_master(pci_dev);
+
 	// frobnicate latency (upwards, usually)
-	pci_read_config_byte (pci_dev, PCI_LATENCY_TIMER, &lat);
+	pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &lat);
 	if (pci_lat) {
-	  PRINTD (DBG_INFO, "%s PCI latency timer from %hu to %hu",
-		  "changing", lat, pci_lat);
-	  pci_write_config_byte (pci_dev, PCI_LATENCY_TIMER, pci_lat);
+		PRINTD(DBG_INFO, "%s PCI latency timer from %hu to %hu",
+		       "changing", lat, pci_lat);
+		pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, pci_lat);
 	} else if (lat < MIN_PCI_LATENCY) {
-	  PRINTK (KERN_INFO, "%s PCI latency timer from %hu to %hu",
-		  "increasing", lat, MIN_PCI_LATENCY);
-	  pci_write_config_byte (pci_dev, PCI_LATENCY_TIMER, MIN_PCI_LATENCY);
+		PRINTK(KERN_INFO, "%s PCI latency timer from %hu to %hu",
+		       "increasing", lat, MIN_PCI_LATENCY);
+		pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, MIN_PCI_LATENCY);
 	}
-	
+
 	dev->iobase = iobase;
 	dev->irq = irq; 
 	dev->membase = membase; 
-	
+
 	dev->rx_q_entry = dev->rx_q_reset = &memmap->rx_q_entries[0];
 	dev->rx_q_wrap  = &memmap->rx_q_entries[RX_CHANS-1];
-	
+
 	// these next three are performance hacks
 	dev->last_vc = -1;
 	dev->tx_last = -1;
 	dev->tx_idle = 0;
-	
+
 	dev->tx_regions = 0;
 	dev->tx_bytes = 0;
 	dev->tx_skb = NULL;
 	dev->tx_iovec = NULL;
-	
+
 	dev->tx_cell_count = 0;
 	dev->rx_cell_count = 0;
 	dev->hec_error_count = 0;
 	dev->unassigned_cell_count = 0;
-	
+
 	dev->noof_spare_buffers = 0;
-	
+
 	{
-	  unsigned int i;
-	  for (i = 0; i < TX_CHANS; ++i)
-	    dev->tx_channel_record[i] = -1;
+		unsigned int i;
+		for (i = 0; i < TX_CHANS; ++i)
+			dev->tx_channel_record[i] = -1;
 	}
-	
+
 	dev->flags = 0;
-	
+
 	// Allocate cell rates and remember ASIC version
 	// Fibre: ATM_OC3_PCR = 1555200000/8/270*260/53 - 29/53
 	// Copper: (WRONG) we want 6 into the above, close to 25Mb/s
 	// Copper: (plagarise!) 25600000/8/270*260/53 - n/53
-	
-	if (hrz_init (dev)) {
-	  // to be really pedantic, this should be ATM_OC3c_PCR
-	  dev->tx_avail = ATM_OC3_PCR;
-	  dev->rx_avail = ATM_OC3_PCR;
-	  set_bit (ultra, &dev->flags); // NOT "|= ultra" !
+
+	if (hrz_init(dev)) {
+		// to be really pedantic, this should be ATM_OC3c_PCR
+		dev->tx_avail = ATM_OC3_PCR;
+		dev->rx_avail = ATM_OC3_PCR;
+		set_bit(ultra, &dev->flags); // NOT "|= ultra" !
 	} else {
-	  dev->tx_avail = ((25600000/8)*26)/(27*53);
-	  dev->rx_avail = ((25600000/8)*26)/(27*53);
-	  PRINTD (DBG_WARN, "Buggy ASIC: no TX bus-mastering.");
+		dev->tx_avail = ((25600000/8)*26)/(27*53);
+		dev->rx_avail = ((25600000/8)*26)/(27*53);
+		PRINTD(DBG_WARN, "Buggy ASIC: no TX bus-mastering.");
 	}
-	
+
 	// rate changes spinlock
-	spin_lock_init (&dev->rate_lock);
-	
+	spin_lock_init(&dev->rate_lock);
+
 	// on-board memory access spinlock; we want atomic reads and
 	// writes to adapter memory (handles IRQ and SMP)
-	spin_lock_init (&dev->mem_lock);
-	
-	init_waitqueue_head (&dev->tx_queue);
-	
+	spin_lock_init(&dev->mem_lock);
+
+	init_waitqueue_head(&dev->tx_queue);
+
 	// vpi in 0..4, vci in 6..10
 	dev->atm_dev->ci_range.vpi_bits = vpi_bits;
 	dev->atm_dev->ci_range.vci_bits = 10-vpi_bits;
-	
-	// update count and linked list
-	++devs;
-	dev->prev = hrz_devs;
-	hrz_devs = dev;
-	// success
-	continue;
-	
-	/* not currently reached */
-	atm_dev_deregister (dev->atm_dev);
-      } /* atm_dev_register */
-      free_irq (irq, dev);
-	
-    } /* request_irq */
-    kfree (dev);
-    release_region(iobase, HRZ_IO_EXTENT);
-  } /* kmalloc and while */
-  return devs;
+
+	init_timer(&dev->housekeeping);
+	dev->housekeeping.function = do_housekeeping;
+	dev->housekeeping.data = (unsigned long) dev;
+	mod_timer(&dev->housekeeping, jiffies);
+
+out:
+	return err;
+
+out_free_irq:
+	free_irq(dev->irq, dev);
+out_free:
+	kfree(dev);
+out_disable:
+	pci_disable_device(pci_dev);
+out_release:
+	release_region(iobase, HRZ_IO_EXTENT);
+	goto out;
+}
+
+static void __devexit hrz_remove_one(struct pci_dev *pci_dev)
+{
+	hrz_dev *dev;
+
+	dev = pci_get_drvdata(pci_dev);
+
+	PRINTD(DBG_INFO, "closing %p (atm_dev = %p)", dev, dev->atm_dev);
+	del_timer_sync(&dev->housekeeping);
+	hrz_reset(dev);
+	atm_dev_deregister(dev->atm_dev);
+	free_irq(dev->irq, dev);
+	release_region(dev->iobase, HRZ_IO_EXTENT);
+	kfree(dev);
+
+	pci_disable_device(pci_dev);
 }
 
 static void __init hrz_check_args (void) {
@@ -2898,22 +2896,35 @@
 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, "i");
-MODULE_PARM(max_rx_size, "i");
-MODULE_PARM(pci_lat, "b");
+module_param(debug, ushort, 0644);
+module_param(vpi_bits, ushort, 0);
+module_param(max_tx_size, int, 0);
+module_param(max_rx_size, int, 0);
+module_param(pci_lat, byte, 0);
 MODULE_PARM_DESC(debug, "debug bitmap, see .h file");
 MODULE_PARM_DESC(vpi_bits, "number of bits (0..4) to allocate to VPIs");
 MODULE_PARM_DESC(max_tx_size, "maximum size of TX AAL5 frames");
 MODULE_PARM_DESC(max_rx_size, "maximum size of RX AAL5 frames");
 MODULE_PARM_DESC(pci_lat, "PCI latency in bus cycles");
 
+static struct pci_device_id hrz_pci_tbl[] = {
+	{ PCI_VENDOR_ID_MADGE, PCI_DEVICE_ID_MADGE_HORIZON, PCI_ANY_ID, PCI_ANY_ID,
+	  0, 0, 0 },
+	{ 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, hrz_pci_tbl);
+
+static struct pci_driver hrz_driver = {
+	.name =		"horizon",
+	.probe =	hrz_probe,
+	.remove =	__devexit_p(hrz_remove_one),
+	.id_table =	hrz_pci_tbl,
+};
+
 /********** module entry **********/
 
 static int __init hrz_module_init (void) {
-  int devs;
-  
   // sanity check - cast is needed since printk does not support %Zu
   if (sizeof(struct MEMMAP) != 128*1024/4) {
     PRINTK (KERN_ERR, "Fix struct MEMMAP (is %lu fakewords).",
@@ -2927,44 +2938,15 @@
   hrz_check_args();
   
   // get the juice
-  devs = hrz_probe();
-  
-  if (devs) {
-    init_timer (&housekeeping);
-    housekeeping.function = do_housekeeping;
-    // paranoia
-    housekeeping.data = 1;
-    set_timer (&housekeeping, 0);
-  } else {
-    PRINTK (KERN_ERR, "no (usable) adapters found");
-  }
-  
-  return devs ? 0 : -ENODEV;
+  return pci_module_init(&hrz_driver);
 }
 
 /********** module exit **********/
 
 static void __exit hrz_module_exit (void) {
-  hrz_dev * dev;
   PRINTD (DBG_FLOW, "cleanup_module");
   
-  // paranoia
-  housekeeping.data = 0;
-  del_timer (&housekeeping);
-  
-  while (hrz_devs) {
-    dev = hrz_devs;
-    hrz_devs = dev->prev;
-    
-    PRINTD (DBG_INFO, "closing %p (atm_dev = %p)", dev, dev->atm_dev);
-    hrz_reset (dev);
-    atm_dev_deregister (dev->atm_dev);
-    free_irq (dev->irq, dev);
-    release_region (dev->iobase, HRZ_IO_EXTENT);
-    kfree (dev);
-  }
-  
-  return;
+  return pci_unregister_driver(&hrz_driver);
 }
 
 module_init(hrz_module_init);
diff -Nru a/drivers/atm/horizon.h b/drivers/atm/horizon.h
--- a/drivers/atm/horizon.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/atm/horizon.h	2004-12-24 13:37:19 -08:00
@@ -457,7 +457,7 @@
   unsigned long    unassigned_cell_count;
 
   struct pci_dev * pci_dev;
-  struct hrz_dev * prev;
+  struct timer_list housekeeping;
 };
 
 typedef struct hrz_dev hrz_dev;
diff -Nru a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
--- a/drivers/atm/idt77252.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/atm/idt77252.c	2004-12-24 13:36:49 -08:00
@@ -1266,8 +1266,9 @@
 	head = IDT77252_PRV_PADDR(queue) + (queue->data - queue->head - 16);
 	tail = readl(SAR_REG_RAWCT);
 
-	pci_dma_sync_single(card->pcidev, IDT77252_PRV_PADDR(queue),
-			    queue->end - queue->head - 16, PCI_DMA_FROMDEVICE);
+	pci_dma_sync_single_for_cpu(card->pcidev, IDT77252_PRV_PADDR(queue),
+				    queue->end - queue->head - 16,
+				    PCI_DMA_FROMDEVICE);
 
 	while (head != tail) {
 		unsigned int vpi, vci, pti;
@@ -1360,10 +1361,10 @@
 			if (next) {
 				card->raw_cell_head = next;
 				queue = card->raw_cell_head;
-				pci_dma_sync_single(card->pcidev,
-						    IDT77252_PRV_PADDR(queue),
-						    queue->end - queue->data,
-						    PCI_DMA_FROMDEVICE);
+				pci_dma_sync_single_for_cpu(card->pcidev,
+							    IDT77252_PRV_PADDR(queue),
+							    queue->end - queue->data,
+							    PCI_DMA_FROMDEVICE);
 			} else {
 				card->raw_cell_head = NULL;
 				printk("%s: raw cell queue overrun\n",
@@ -3168,7 +3169,7 @@
 	}
 
 	if (card->membase)
-		iounmap((void *) card->membase);
+		iounmap(card->membase);
 
 	clear_bit(IDT77252_BIT_INIT, &card->flags);
 	DIPRINTK("%s: Card deinitialized.\n", card->name);
@@ -3684,9 +3685,9 @@
 	int i, err;
 
 
-	if (pci_enable_device(pcidev)) {
+	if ((err = pci_enable_device(pcidev))) {
 		printk("idt77252: can't enable PCI device at %s\n", pci_name(pcidev));
-		return -ENODEV;
+		return err;
 	}
 
 	if (pci_read_config_word(pcidev, PCI_REVISION_ID, &revision)) {
@@ -3802,7 +3803,7 @@
 	deinit_card(card);
 
 err_out_iounmap:
-	iounmap((void *) card->membase);
+	iounmap(card->membase);
 
 err_out_free_card:
 	kfree(card);
@@ -3819,6 +3820,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE(pci, idt77252_pci_tbl);
+
 static struct pci_driver idt77252_driver = {
 	.name		= "idt77252",
 	.id_table	= idt77252_pci_tbl,
@@ -3840,11 +3843,7 @@
 		return -EIO;
 	}
 
-	if (pci_register_driver(&idt77252_driver) > 0)
-		return 0;
-
-	pci_unregister_driver(&idt77252_driver);
-	return -ENODEV;
+	return pci_register_driver(&idt77252_driver);
 }
 
 static void __exit idt77252_exit(void)
@@ -3874,10 +3873,10 @@
 
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(vpibits, "i");
+module_param(vpibits, uint, 0);
 MODULE_PARM_DESC(vpibits, "number of VPI bits supported (0, 1, or 2)");
 #ifdef CONFIG_ATM_IDT77252_DEBUG
-MODULE_PARM(debug, "i");
+module_param(debug, ulong, 0644);
 MODULE_PARM_DESC(debug,   "debug bitmap, see drivers/atm/idt77252.h");
 #endif
 
diff -Nru a/drivers/atm/iphase.c b/drivers/atm/iphase.c
--- a/drivers/atm/iphase.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/atm/iphase.c	2004-12-24 13:37:29 -08:00
@@ -81,14 +81,14 @@
 struct atm_vcc *vcc_close_que[100];
 static int IA_TX_BUF = DFL_TX_BUFFERS, IA_TX_BUF_SZ = DFL_TX_BUF_SZ;
 static int IA_RX_BUF = DFL_RX_BUFFERS, IA_RX_BUF_SZ = DFL_RX_BUF_SZ;
-static u32 IADebugFlag = /* IF_IADBG_ERR | IF_IADBG_CBR| IF_IADBG_INIT_ADAPTER
+static uint IADebugFlag = /* IF_IADBG_ERR | IF_IADBG_CBR| IF_IADBG_INIT_ADAPTER
             |IF_IADBG_ABR | IF_IADBG_EVENT*/ 0; 
 
-MODULE_PARM(IA_TX_BUF, "i");
-MODULE_PARM(IA_TX_BUF_SZ, "i");
-MODULE_PARM(IA_RX_BUF, "i");
-MODULE_PARM(IA_RX_BUF_SZ, "i");
-MODULE_PARM(IADebugFlag, "i");
+module_param(IA_TX_BUF, int, 0);
+module_param(IA_TX_BUF_SZ, int, 0);
+module_param(IA_RX_BUF, int, 0);
+module_param(IA_RX_BUF_SZ, int, 0);
+module_param(IADebugFlag, uint, 0644);
 
 MODULE_LICENSE("GPL");
 
@@ -615,12 +615,13 @@
    return tmp;
 }    
 
+static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb);
+
 static int ia_que_tx (IADEV *iadev) { 
    struct sk_buff *skb;
    int num_desc;
    struct atm_vcc *vcc;
    struct ia_vcc *iavcc;
-   static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb);
    num_desc = ia_avail_descs(iadev);
 
    while (num_desc && (skb = skb_dequeue(&iadev->tx_backlog))) {
@@ -1010,7 +1011,8 @@
 void desc_dbg(IADEV *iadev) {
 
   u_short tcq_wr_ptr, tcq_st_ptr, tcq_ed_ptr;
-  u32 tmp, i;
+  u32 i;
+  void __iomem *tmp;
   // regval = readl((u32)ia_cmds->maddr);
   tcq_wr_ptr =  readw(iadev->seg_reg+TCQ_WR_PTR);
   printk("B_tcq_wr = 0x%x desc = %d last desc = %d\n",
@@ -1024,7 +1026,7 @@
   i = 0;
   while (tcq_st_ptr != tcq_ed_ptr) {
       tmp = iadev->seg_ram+tcq_st_ptr;
-      printk("TCQ slot %d desc = %d  Addr = 0x%x\n", i++, readw(tmp), tmp);
+      printk("TCQ slot %d desc = %d  Addr = %p\n", i++, readw(tmp), tmp);
       tcq_st_ptr += 2;
   }
   for(i=0; i <iadev->num_tx_desc; i++)
@@ -1080,7 +1082,7 @@
 	IADEV *iadev;  
 	struct atm_vcc *vcc;  
 	unsigned short status;  
-	struct rx_buf_desc *buf_desc_ptr;  
+	struct rx_buf_desc __iomem *buf_desc_ptr;  
 	int desc;   
 	struct dle* wr_ptr;  
 	int len;  
@@ -1095,7 +1097,7 @@
 	}  
 	/* mask 1st 3 bits to get the actual descno. */  
 	desc = readw(iadev->reass_ram+iadev->rfL.pcq_rd) & 0x1fff;  
-        IF_RX(printk("reass_ram = 0x%x iadev->rfL.pcq_rd = 0x%x desc = %d\n", 
+        IF_RX(printk("reass_ram = %p iadev->rfL.pcq_rd = 0x%x desc = %d\n", 
                                     iadev->reass_ram, iadev->rfL.pcq_rd, desc);
               printk(" pcq_wr_ptr = 0x%x\n",
                                readw(iadev->reass_reg+PCQ_WR_PTR)&0xffff);)
@@ -1109,7 +1111,7 @@
 	/* get the buffer desc entry.  
 		update stuff. - doesn't seem to be any update necessary  
 	*/  
-	buf_desc_ptr = (struct rx_buf_desc *)iadev->RX_DESC_BASE_ADDR;
+	buf_desc_ptr = iadev->RX_DESC_BASE_ADDR;
 	/* make the ptr point to the corresponding buffer desc entry */  
 	buf_desc_ptr += desc;	  
         if (!desc || (desc > iadev->num_rx_desc) || 
@@ -1358,8 +1360,8 @@
 static int open_rx(struct atm_vcc *vcc)  
 {  
 	IADEV *iadev;  
-	u_short *vc_table;  
-	u_short *reass_ptr;  
+	u_short __iomem *vc_table;  
+	u_short __iomem *reass_ptr;  
 	IF_EVENT(printk("iadev: open_rx %d.%d\n", vcc->vpi, vcc->vci);)
 
 	if (vcc->qos.rxtp.traffic_class == ATM_NONE) return 0;    
@@ -1372,8 +1374,8 @@
         }
 	/* Make only this VCI in the vc table valid and let all   
 		others be invalid entries */  
-	vc_table = (u_short *)(iadev->reass_ram+RX_VC_TABLE*iadev->memSize);  
-	vc_table += vcc->vci;  
+	vc_table = iadev->reass_ram+RX_VC_TABLE*iadev->memSize;
+	vc_table += vcc->vci;
 	/* mask the last 6 bits and OR it with 3 for 1K VCs */  
 
         *vc_table = vcc->vci << 6;
@@ -1387,9 +1389,8 @@
                 ia_open_abr_vc(iadev, &srv_p, vcc, 0);
 	} 
        	else {  /* for UBR  later may need to add CBR logic */
-        	reass_ptr = (u_short *)
-                           (iadev->reass_ram+REASS_TABLE*iadev->memSize);
-           	reass_ptr += vcc->vci;  
+        	reass_ptr = iadev->reass_ram+REASS_TABLE*iadev->memSize;
+           	reass_ptr += vcc->vci;
            	*reass_ptr = NO_AAL5_PKT;
        	}
 	
@@ -1403,7 +1404,7 @@
 static int rx_init(struct atm_dev *dev)  
 {  
 	IADEV *iadev;  
-	struct rx_buf_desc *buf_desc_ptr;  
+	struct rx_buf_desc __iomem *buf_desc_ptr;  
 	unsigned long rx_pkt_start = 0;  
 	void *dle_addr;  
 	struct abr_vc_table  *abr_vc_table; 
@@ -1465,13 +1466,13 @@
   
 	/* Initialize each entry in the Buffer Descriptor Table */  
         iadev->RX_DESC_BASE_ADDR = iadev->reass_ram+RX_DESC_BASE*iadev->memSize;
-	buf_desc_ptr =(struct rx_buf_desc *)iadev->RX_DESC_BASE_ADDR;
-	memset((caddr_t)buf_desc_ptr, 0, sizeof(*buf_desc_ptr));  
+	buf_desc_ptr = iadev->RX_DESC_BASE_ADDR;
+	memset_io(buf_desc_ptr, 0, sizeof(*buf_desc_ptr));
 	buf_desc_ptr++;  
 	rx_pkt_start = iadev->rx_pkt_ram;  
 	for(i=1; i<=iadev->num_rx_desc; i++)  
 	{  
-		memset((caddr_t)buf_desc_ptr, 0, sizeof(*buf_desc_ptr));  
+		memset_io(buf_desc_ptr, 0, sizeof(*buf_desc_ptr));  
 		buf_desc_ptr->buf_start_hi = rx_pkt_start >> 16;  
 		buf_desc_ptr->buf_start_lo = rx_pkt_start & 0x0000ffff;  
 		buf_desc_ptr++;		  
@@ -2053,10 +2054,9 @@
         IF_INIT(printk("CBR_TAB_BEG = 0x%x, CBR_TAB_END = 0x%x, CBR_PTR = 0x%x\n",
           readw(iadev->seg_reg+CBR_TAB_BEG), readw(iadev->seg_reg+CBR_TAB_END),
           readw(iadev->seg_reg+CBR_TAB_END+1));)
-        tmp16 = (iadev->seg_ram+CBR_SCHED_TABLE*iadev->memSize);
 
         /* Initialize the CBR Schedualing Table */
-        memset((caddr_t)(iadev->seg_ram+CBR_SCHED_TABLE*iadev->memSize), 
+        memset_io(iadev->seg_ram+CBR_SCHED_TABLE*iadev->memSize, 
                                                           0, iadev->num_vc*6); 
         iadev->CbrRemEntries = iadev->CbrTotEntries = iadev->num_vc*3;
         iadev->CbrEntryPt = 0;
@@ -2287,7 +2287,8 @@
 static int __init ia_init(struct atm_dev *dev)
 {  
 	IADEV *iadev;  
-	unsigned long real_base, base;  
+	unsigned long real_base;
+	void __iomem *base;
 	unsigned short command;  
 	unsigned char revision;  
 	int error, i; 
@@ -2343,7 +2344,7 @@
 	udelay(10);  
 	  
 	/* mapping the physical address to a virtual address in address space */  
-	base=(unsigned long)ioremap((unsigned long)real_base,iadev->pci_map_size);  /* ioremap is not resolved ??? */  
+	base = ioremap(real_base,iadev->pci_map_size);  /* ioremap is not resolved ??? */  
 	  
 	if (!base)  
 	{  
@@ -2351,39 +2352,38 @@
 			    dev->number);  
 		return error;  
 	}  
-	IF_INIT(printk(DEV_LABEL " (itf %d): rev.%d,base=0x%lx,irq=%d\n",  
+	IF_INIT(printk(DEV_LABEL " (itf %d): rev.%d,base=%p,irq=%d\n",  
 			dev->number, revision, base, iadev->irq);)  
 	  
 	/* filling the iphase dev structure */  
 	iadev->mem = iadev->pci_map_size /2;  
-	iadev->base_diff = real_base - base;  
 	iadev->real_base = real_base;  
 	iadev->base = base;  
 		  
 	/* Bus Interface Control Registers */  
-	iadev->reg = (u32 *) (base + REG_BASE);  
+	iadev->reg = base + REG_BASE;
 	/* Segmentation Control Registers */  
-	iadev->seg_reg = (u32 *) (base + SEG_BASE);  
+	iadev->seg_reg = base + SEG_BASE;
 	/* Reassembly Control Registers */  
-	iadev->reass_reg = (u32 *) (base + REASS_BASE);  
+	iadev->reass_reg = base + REASS_BASE;  
 	/* Front end/ DMA control registers */  
-	iadev->phy = (u32 *) (base + PHY_BASE);  
-	iadev->dma = (u32 *) (base + PHY_BASE);  
+	iadev->phy = base + PHY_BASE;  
+	iadev->dma = base + PHY_BASE;  
 	/* RAM - Segmentation RAm and Reassembly RAM */  
-	iadev->ram = (u32 *) (base + ACTUAL_RAM_BASE);  
-	iadev->seg_ram =  (base + ACTUAL_SEG_RAM_BASE);  
-	iadev->reass_ram = (base + ACTUAL_REASS_RAM_BASE);  
+	iadev->ram = base + ACTUAL_RAM_BASE;  
+	iadev->seg_ram = base + ACTUAL_SEG_RAM_BASE;  
+	iadev->reass_ram = base + ACTUAL_REASS_RAM_BASE;  
   
 	/* lets print out the above */  
-	IF_INIT(printk("Base addrs: %08x %08x %08x \n %08x %08x %08x %08x\n", 
-          (u32)iadev->reg,(u32)iadev->seg_reg,(u32)iadev->reass_reg, 
-          (u32)iadev->phy, (u32)iadev->ram, (u32)iadev->seg_ram, 
-          (u32)iadev->reass_ram);) 
+	IF_INIT(printk("Base addrs: %p %p %p \n %p %p %p %p\n", 
+          iadev->reg,iadev->seg_reg,iadev->reass_reg, 
+          iadev->phy, iadev->ram, iadev->seg_ram, 
+          iadev->reass_ram);) 
 	  
 	/* lets try reading the MAC address */  
 	error = get_esi(dev);  
 	if (error) {
-	  iounmap((void *) iadev->base);
+	  iounmap(iadev->base);
 	  return error;  
 	}
         printk("IA: ");
@@ -2393,7 +2393,7 @@
   
         /* reset SAR */  
         if (reset_sar(dev)) {
-	   iounmap((void *) iadev->base);
+	   iounmap(iadev->base);
            printk("IA: reset SAR fail, please try again\n");
            return 1;
         }
@@ -2659,7 +2659,7 @@
            vc_table += vcc->vci;
            *vc_table = (vcc->vci << 6) | 15;
            if (vcc->qos.rxtp.traffic_class == ATM_ABR) {
-              struct abr_vc_table *abr_vc_table = (struct abr_vc_table *)
+              struct abr_vc_table __iomem *abr_vc_table = 
                                 (iadev->reass_ram+ABR_VC_TABLE*iadev->memSize);
               abr_vc_table +=  vcc->vci;
               abr_vc_table->rdf = 0x0003;
@@ -2890,7 +2890,7 @@
 static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
         IADEV *iadev;
         struct dle *wr_ptr;
-        struct tx_buf_desc *buf_desc_ptr;
+        struct tx_buf_desc __iomem *buf_desc_ptr;
         int desc;
         int comp_code;
         int total_len;
@@ -2994,7 +2994,7 @@
         printk("\n");)
 
 	/* Build the buffer descriptor */  
-	buf_desc_ptr = (struct tx_buf_desc *)(iadev->seg_ram+TX_DESC_BASE);  
+	buf_desc_ptr = iadev->seg_ram+TX_DESC_BASE;
 	buf_desc_ptr += desc;	/* points to the corresponding entry */  
 	buf_desc_ptr->desc_mode = AAL5 | EOM_EN | APP_CRC32 | CMPL_INT;   
 	/* Huh ? p.115 of users guide describes this as a read-only register */
@@ -3252,7 +3252,7 @@
 	atm_dev_deregister(dev);
 	IF_EVENT(printk("iav deregistered at (itf:%d)\n", dev->number);)
 
-      	iounmap((void *) iadev->base);  
+      	iounmap(iadev->base);  
 	pci_disable_device(pdev);
 
 	ia_free_rx(iadev);
diff -Nru a/drivers/atm/iphase.h b/drivers/atm/iphase.h
--- a/drivers/atm/iphase.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/atm/iphase.h	2004-12-24 13:36:31 -08:00
@@ -996,18 +996,18 @@
 
 typedef struct iadev_t {  
 	/*-----base pointers into (i)chipSAR+ address space */   
-	u32 *phy;			/* base pointer into phy(SUNI) */  
-	u32 *dma;			/* base pointer into DMA control   
+	u32 __iomem *phy;		/* base pointer into phy(SUNI) */  
+	u32 __iomem *dma;		/* base pointer into DMA control   
 						registers */  
-	u32 *reg;			/* base pointer to SAR registers  
+	u32 __iomem *reg;		/* base pointer to SAR registers  
 					   - Bus Interface Control Regs */  
-	u32 *seg_reg;			/* base pointer to segmentation engine  
+	u32 __iomem *seg_reg;		/* base pointer to segmentation engine  
 						internal registers */  
-	u32 *reass_reg;			/* base pointer to reassemble engine  
+	u32 __iomem *reass_reg;		/* base pointer to reassemble engine  
 						internal registers */  
-	u32 *ram;			/* base pointer to SAR RAM */  
-	unsigned int seg_ram;  
-	unsigned int reass_ram;  
+	u32 __iomem *ram;		/* base pointer to SAR RAM */  
+	void __iomem *seg_ram;  
+	void __iomem *reass_ram;  
 	struct dle_q tx_dle_q;  
 	struct free_desc_q *tx_free_desc_qhead;  
 	struct sk_buff_head tx_dma_q, tx_backlog;  
@@ -1019,7 +1019,7 @@
 	struct cpcs_trailer_desc *tx_buf;
         u16 num_tx_desc, tx_buf_sz, rate_limit;
         u32 tx_cell_cnt, tx_pkt_cnt;
-        u32 MAIN_VC_TABLE_ADDR, EXT_VC_TABLE_ADDR, ABR_SCHED_TABLE_ADDR;
+        void __iomem *MAIN_VC_TABLE_ADDR, *EXT_VC_TABLE_ADDR, *ABR_SCHED_TABLE_ADDR;
 	struct dle_q rx_dle_q;  
 	struct free_desc_q *rx_free_desc_qhead;  
 	struct sk_buff_head rx_dma_q;  
@@ -1027,13 +1027,13 @@
 	struct atm_vcc **rx_open;	/* list of all open VCs */  
         u16 num_rx_desc, rx_buf_sz, rxing;
         u32 rx_pkt_ram, rx_tmp_cnt, rx_tmp_jif;
-        u32 RX_DESC_BASE_ADDR;
+        void __iomem *RX_DESC_BASE_ADDR;
         u32 drop_rxpkt, drop_rxcell, rx_cell_cnt, rx_pkt_cnt;
 	struct atm_dev *next_board;	/* other iphase devices */  
 	struct pci_dev *pci;  
 	int mem;  
-	unsigned long base_diff;	/* virtual - real base address */  
-	unsigned int real_base, base;	/* real and virtual base address */  
+	unsigned int real_base;	/* real and virtual base address */  
+	void __iomem *base;
 	unsigned int pci_map_size;	/*pci map size of board */  
 	unsigned char irq;  
 	unsigned char bus;  
diff -Nru a/drivers/atm/lanai.c b/drivers/atm/lanai.c
--- a/drivers/atm/lanai.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/atm/lanai.c	2004-12-24 13:36:31 -08:00
@@ -1481,7 +1481,7 @@
 	struct lanai_vcc *lvcc;
 	lvcc = (struct lanai_vcc *) kmalloc(sizeof(*lvcc), GFP_KERNEL);
 	if (likely(lvcc != NULL)) {
-		lvcc->vbase = 0;
+		lvcc->vbase = NULL;
 		lvcc->rx.atmvcc = lvcc->tx.atmvcc = NULL;
 		lvcc->nref = 0;
 		memset(&lvcc->stats, 0, sizeof lvcc->stats);
@@ -1565,7 +1565,7 @@
 	if (lvcc->vbase == 0)
 		return;	/* This vcc was never bound */
 	DPRINTK("Unbinding vci %d\n", lvcc->vci);
-	lvcc->vbase = 0;
+	lvcc->vbase = NULL;
 	lanai->vccs[lvcc->vci] = NULL;
 #ifdef USE_POWERDOWN
 	if (--lanai->nbound == 0) {
@@ -2279,7 +2279,7 @@
 	lanai->conf1 = reg_read(lanai, Config1_Reg) | CONFIG1_POWERDOWN;
 	conf1_write(lanai);
 #endif
-	iounmap((void *) lanai->base);
+	iounmap(lanai->base);
     error_pci:
 	pci_disable_device(lanai->pci);
     error:
@@ -2309,7 +2309,7 @@
 	pci_disable_device(lanai->pci);
 	vcc_table_deallocate(lanai);
 	service_buffer_deallocate(lanai);
-	iounmap((void *) lanai->base);
+	iounmap(lanai->base);
 	kfree(lanai);
 }
 
diff -Nru a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
--- a/drivers/atm/nicstar.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/atm/nicstar.c	2004-12-24 13:36:31 -08:00
@@ -267,7 +267,7 @@
 };
 static struct timer_list ns_timer;
 static char *mac[NS_MAX_CARDS];
-MODULE_PARM(mac, "1-" __MODULE_STRING(NS_MAX_CARDS) "s");
+module_param_array(mac, charp, NULL, 0);
 MODULE_LICENSE("GPL");
 
 
diff -Nru a/drivers/atm/zatm.c b/drivers/atm/zatm.c
--- a/drivers/atm/zatm.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/atm/zatm.c	2004-12-24 13:36:31 -08:00
@@ -46,6 +46,8 @@
  *  - OAM
  */
 
+#define ZATM_COPPER	1
+
 #if 0
 #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
 #else
@@ -1577,51 +1579,77 @@
 	.change_qos	= zatm_change_qos,
 };
 
-static int __init zatm_module_init(void)
+static int __devinit zatm_init_one(struct pci_dev *pci_dev,
+				   const struct pci_device_id *ent)
 {
 	struct atm_dev *dev;
 	struct zatm_dev *zatm_dev;
-	int devs,type;
+	int ret = -ENOMEM;
 
-	zatm_dev = (struct zatm_dev *) kmalloc(sizeof(struct zatm_dev),
-	    GFP_KERNEL);
-	if (!zatm_dev) return -ENOMEM;
-	devs = 0;
-	for (type = 0; type < 2; type++) {
-		struct pci_dev *pci_dev;
-
-		pci_dev = NULL;
-		while ((pci_dev = pci_find_device(PCI_VENDOR_ID_ZEITNET,type ?
-		    PCI_DEVICE_ID_ZEITNET_1225 : PCI_DEVICE_ID_ZEITNET_1221,
-		    pci_dev))) {
-			if (pci_enable_device(pci_dev)) break;
-			dev = atm_dev_register(DEV_LABEL,&ops,-1,NULL);
-			if (!dev) break;
-			zatm_dev->pci_dev = pci_dev;
-			dev->dev_data = zatm_dev;
-			zatm_dev->copper = type;
-			if (zatm_init(dev) || zatm_start(dev)) {
-				atm_dev_deregister(dev);
-				break;
-			}
-			zatm_dev->more = zatm_boards;
-			zatm_boards = dev;
-			devs++;
-			zatm_dev = (struct zatm_dev *) kmalloc(sizeof(struct
-			    zatm_dev),GFP_KERNEL);
-			if (!zatm_dev) {
-				printk(KERN_EMERG "zatm.c: memory shortage\n");
-				goto out;
-			}
-		}
-	}
+	zatm_dev = (struct zatm_dev *) kmalloc(sizeof(*zatm_dev), GFP_KERNEL);
+	if (!zatm_dev) {
+		printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL);
+		goto out;
+	}
+
+	dev = atm_dev_register(DEV_LABEL, &ops, -1, NULL);
+	if (!dev)
+		goto out_free;
+
+	ret = pci_enable_device(pci_dev);
+	if (ret < 0)
+		goto out_deregister;
+
+	ret = pci_request_regions(pci_dev, DEV_LABEL);
+	if (ret < 0)
+		goto out_disable;
+
+	zatm_dev->pci_dev = pci_dev;
+	dev = (struct atm_dev *)zatm_dev;
+	zatm_dev->copper = (int)ent->driver_data;
+	if ((ret = zatm_init(dev)) || (ret = zatm_start(dev)))
+		goto out_release;
+
+	pci_set_drvdata(pci_dev, dev);
+	zatm_dev->more = zatm_boards;
+	zatm_boards = dev;
+	ret = 0;
 out:
-	kfree(zatm_dev);
+	return ret;
 
-	return 0;
+out_release:
+	pci_release_regions(pci_dev);
+out_disable:
+	pci_disable_device(pci_dev);
+out_deregister:
+	atm_dev_deregister(dev);
+out_free:
+	kfree(zatm_dev);
+	goto out;
 }
 
+
 MODULE_LICENSE("GPL");
 
-module_init(zatm_module_init);
+static struct pci_device_id zatm_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_ZEITNET, PCI_DEVICE_ID_ZEITNET_1221,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, ZATM_COPPER },
+	{ PCI_VENDOR_ID_ZEITNET, PCI_DEVICE_ID_ZEITNET_1225,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ 0, }
+};
+MODULE_DEVICE_TABLE(pci, zatm_pci_tbl);
+
+static struct pci_driver zatm_driver = {
+	.name =		DEV_LABEL,
+	.id_table =	zatm_pci_tbl,
+	.probe =	zatm_init_one,
+};
+
+static int __init zatm_init_module(void)
+{
+	return pci_module_init(&zatm_driver);
+}
+
+module_init(zatm_init_module);
 /* module_exit not defined so not unloadable */
diff -Nru a/drivers/base/Kconfig b/drivers/base/Kconfig
--- a/drivers/base/Kconfig	2004-12-24 13:36:19 -08:00
+++ b/drivers/base/Kconfig	2004-12-24 13:36:19 -08:00
@@ -14,7 +14,7 @@
 	default y
 	help
 	  Say yes to avoid building firmware. Firmware is usually shipped
-	  with the driver, and only when updating the firware a rebuild
+	  with the driver, and only when updating the firmware a rebuild
 	  should be made.
 	  If unsure say Y here.
 
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/base/bus.c	2004-12-24 13:36:31 -08:00
@@ -135,6 +135,52 @@
 
 decl_subsys(bus, &ktype_bus, NULL);
 
+static int __bus_for_each_dev(struct bus_type *bus, struct device *start,
+			      void *data, int (*fn)(struct device *, void *))
+{
+	struct list_head *head;
+	struct device *dev;
+	int error = 0;
+
+	if (!(bus = get_bus(bus)))
+		return -EINVAL;
+
+	head = &bus->devices.list;
+	dev = list_prepare_entry(start, head, bus_list);
+	list_for_each_entry_continue(dev, head, bus_list) {
+		get_device(dev);
+		error = fn(dev, data);
+		put_device(dev);
+		if (error)
+			break;
+	}
+	put_bus(bus);
+	return error;
+}
+
+static int __bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
+			      void * data, int (*fn)(struct device_driver *, void *))
+{
+	struct list_head *head;
+	struct device_driver *drv;
+	int error = 0;
+
+	if (!(bus = get_bus(bus)))
+		return -EINVAL;
+
+	head = &bus->drivers.list;
+	drv = list_prepare_entry(start, head, kobj.entry);
+	list_for_each_entry_continue(drv, head, kobj.entry) {
+		get_driver(drv);
+		error = fn(drv, data);
+		put_driver(drv);
+		if (error)
+			break;
+	}
+	put_bus(bus);
+	return error;
+}
+
 /**
  *	bus_for_each_dev - device iterator.
  *	@bus:	bus type.
@@ -154,30 +200,16 @@
  *	to retain this data, it should do, and increment the reference
  *	count in the supplied callback.
  */
+
 int bus_for_each_dev(struct bus_type * bus, struct device * start,
 		     void * data, int (*fn)(struct device *, void *))
 {
-	struct device *dev;
-	struct list_head * head;
-	int error = 0;
-
-	if (!(bus = get_bus(bus)))
-		return -EINVAL;
-
-	head = &bus->devices.list;
-	dev = list_prepare_entry(start, head, bus_list);
+	int ret;
 
 	down_read(&bus->subsys.rwsem);
-	list_for_each_entry_continue(dev, head, bus_list) {
-		get_device(dev);
-		error = fn(dev, data);
-		put_device(dev);
-		if (error)
-			break;
-	}
+	ret = __bus_for_each_dev(bus, start, data, fn);
 	up_read(&bus->subsys.rwsem);
-	put_bus(bus);
-	return error;
+	return ret;
 }
 
 /**
@@ -203,34 +235,19 @@
 int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
 		     void * data, int (*fn)(struct device_driver *, void *))
 {
-	struct list_head * head;
-	struct device_driver *drv;
-	int error = 0;
-
-	if(!(bus = get_bus(bus)))
-		return -EINVAL;
-
-	head = &bus->drivers.list;
-	drv = list_prepare_entry(start, head, kobj.entry);
+	int ret;
 
 	down_read(&bus->subsys.rwsem);
-	list_for_each_entry_continue(drv, head, kobj.entry) {
-		get_driver(drv);
-		error = fn(drv, data);
-		put_driver(drv);
-		if(error)
-			break;
-	}
+	ret = __bus_for_each_drv(bus, start, data, fn);
 	up_read(&bus->subsys.rwsem);
-	put_bus(bus);
-	return error;
+	return ret;
 }
 
 /**
  *	device_bind_driver - bind a driver to one device.
  *	@dev:	device.
  *
- *	Allow manual attachment of a driver to a deivce.
+ *	Allow manual attachment of a driver to a device.
  *	Caller must have already set @dev->driver.
  *
  *	Note that this does not modify the bus reference count
@@ -246,38 +263,40 @@
 	list_add_tail(&dev->driver_list, &dev->driver->devices);
 	sysfs_create_link(&dev->driver->kobj, &dev->kobj,
 			  kobject_name(&dev->kobj));
+	sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver");
 }
 
 
 /**
- *	bus_match - check compatibility between device & driver.
- *	@dev:	device.
+ *	driver_probe_device - attempt to bind device & driver.
  *	@drv:	driver.
+ *	@dev:	device.
  *
- *	First, we call the bus's match function, which should compare
- *	the device IDs the driver supports with the device IDs of the
- *	device. Note we don't do this ourselves because we don't know
- *	the format of the ID structures, nor what is to be considered
- *	a match and what is not.
+ *	First, we call the bus's match function, if one present, which
+ *	should compare the device IDs the driver supports with the
+ *	device IDs of the device. Note we don't do this ourselves
+ *	because we don't know the format of the ID structures, nor what
+ *	is to be considered a match and what is not.
  *
  *	If we find a match, we call @drv->probe(@dev) if it exists, and
- *	call attach() above.
+ *	call device_bind_driver() above.
  */
-static int bus_match(struct device * dev, struct device_driver * drv)
+int driver_probe_device(struct device_driver * drv, struct device * dev)
 {
-	int error = -ENODEV;
-	if (dev->bus->match(dev, drv)) {
-		dev->driver = drv;
-		if (drv->probe) {
-			if ((error = drv->probe(dev))) {
-				dev->driver = NULL;
-				return error;
-			}
+	if (drv->bus->match && !drv->bus->match(dev, drv))
+		return -ENODEV;
+
+	dev->driver = drv;
+	if (drv->probe) {
+		int error = drv->probe(dev);
+		if (error) {
+			dev->driver = NULL;
+			return error;
 		}
-		device_bind_driver(dev);
-		error = 0;
 	}
-	return error;
+
+	device_bind_driver(dev);
+	return 0;
 }
 
 
@@ -285,10 +304,11 @@
  *	device_attach - try to attach device to a driver.
  *	@dev:	device.
  *
- *	Walk the list of drivers that the bus has and call bus_match()
- *	for each pair. If a compatible pair is found, break out and return.
+ *	Walk the list of drivers that the bus has and call
+ *	driver_probe_device() for each pair. If a compatible
+ *	pair is found, break out and return.
  */
-static int device_attach(struct device * dev)
+int device_attach(struct device * dev)
 {
  	struct bus_type * bus = dev->bus;
 	struct list_head * entry;
@@ -302,7 +322,7 @@
 	if (bus->match) {
 		list_for_each(entry, &bus->drivers.list) {
 			struct device_driver * drv = to_drv(entry);
-			error = bus_match(dev, drv);
+			error = driver_probe_device(drv, dev);
 			if (!error)
 				/* success, driver matched */
 				return 1;
@@ -322,13 +342,13 @@
  *	driver_attach - try to bind driver to devices.
  *	@drv:	driver.
  *
- *	Walk the list of devices that the bus has on it and try to match
- *	the driver with each one.
- *	If bus_match() returns 0 and the @dev->driver is set, we've found
- *	a compatible pair.
+ *	Walk the list of devices that the bus has on it and try to
+ *	match the driver with each one.  If driver_probe_device()
+ *	returns 0 and the @dev->driver is set, we've found a
+ *	compatible pair.
  *
- *	Note that we ignore the -ENODEV error from bus_match(), since it's
- *	perfectly valid for a driver not to bind to any devices.
+ *	Note that we ignore the -ENODEV error from driver_probe_device(),
+ *	since it's perfectly valid for a driver not to bind to any devices.
  */
 void driver_attach(struct device_driver * drv)
 {
@@ -342,7 +362,7 @@
 	list_for_each(entry, &bus->devices.list) {
 		struct device * dev = container_of(entry, struct device, bus_list);
 		if (!dev->driver) {
-			error = bus_match(dev, drv);
+			error = driver_probe_device(drv, dev);
 			if (error && (error != -ENODEV))
 				/* driver matched but the probe failed */
 				printk(KERN_WARNING
@@ -368,6 +388,7 @@
 	struct device_driver * drv = dev->driver;
 	if (drv) {
 		sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
+		sysfs_remove_link(&dev->kobj, "driver");
 		list_del_init(&dev->driver_list);
 		device_detach_shutdown(dev);
 		if (drv->remove)
@@ -515,7 +536,7 @@
 
 	if (bus) {
 		pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
-		error = kobject_set_name(&drv->kobj, drv->name);
+		error = kobject_set_name(&drv->kobj, "%s", drv->name);
 		if (error) {
 			put_bus(bus);
 			return error;
@@ -529,6 +550,7 @@
 		down_write(&bus->subsys.rwsem);
 		driver_attach(drv);
 		up_write(&bus->subsys.rwsem);
+		module_add_driver(drv->owner, drv);
 
 		driver_add_attrs(bus, drv);
 	}
@@ -553,6 +575,7 @@
 		pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
 		driver_detach(drv);
 		up_write(&drv->bus->subsys.rwsem);
+		module_remove_driver(drv);
 		kobject_unregister(&drv->kobj);
 		put_bus(drv->bus);
 	}
@@ -584,7 +607,9 @@
 {
 	int count = 0;
 
-	bus_for_each_dev(bus, NULL, &count, bus_rescan_devices_helper);
+	down_write(&bus->subsys.rwsem);
+	__bus_for_each_dev(bus, NULL, &count, bus_rescan_devices_helper);
+	up_write(&bus->subsys.rwsem);
 
 	return count;
 }
@@ -664,7 +689,7 @@
 {
 	int retval;
 
-	retval = kobject_set_name(&bus->subsys.kset.kobj, bus->name);
+	retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name);
 	if (retval)
 		goto out;
 
@@ -721,20 +746,23 @@
 }
 
 
-EXPORT_SYMBOL(bus_for_each_dev);
-EXPORT_SYMBOL(bus_for_each_drv);
-
-EXPORT_SYMBOL(device_bind_driver);
-EXPORT_SYMBOL(device_release_driver);
+EXPORT_SYMBOL_GPL(bus_for_each_dev);
+EXPORT_SYMBOL_GPL(bus_for_each_drv);
 
-EXPORT_SYMBOL(bus_add_device);
-EXPORT_SYMBOL(bus_remove_device);
-EXPORT_SYMBOL(bus_register);
-EXPORT_SYMBOL(bus_unregister);
-EXPORT_SYMBOL(bus_rescan_devices);
-EXPORT_SYMBOL(get_bus);
-EXPORT_SYMBOL(put_bus);
-EXPORT_SYMBOL(find_bus);
+EXPORT_SYMBOL_GPL(driver_probe_device);
+EXPORT_SYMBOL_GPL(device_bind_driver);
+EXPORT_SYMBOL_GPL(device_release_driver);
+EXPORT_SYMBOL_GPL(device_attach);
+EXPORT_SYMBOL_GPL(driver_attach);
+
+EXPORT_SYMBOL_GPL(bus_add_device);
+EXPORT_SYMBOL_GPL(bus_remove_device);
+EXPORT_SYMBOL_GPL(bus_register);
+EXPORT_SYMBOL_GPL(bus_unregister);
+EXPORT_SYMBOL_GPL(bus_rescan_devices);
+EXPORT_SYMBOL_GPL(get_bus);
+EXPORT_SYMBOL_GPL(put_bus);
+EXPORT_SYMBOL_GPL(find_bus);
 
-EXPORT_SYMBOL(bus_create_file);
-EXPORT_SYMBOL(bus_remove_file);
+EXPORT_SYMBOL_GPL(bus_create_file);
+EXPORT_SYMBOL_GPL(bus_remove_file);
diff -Nru a/drivers/base/class.c b/drivers/base/class.c
--- a/drivers/base/class.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/base/class.c	2004-12-24 13:37:30 -08:00
@@ -139,7 +139,7 @@
 
 	INIT_LIST_HEAD(&cls->children);
 	INIT_LIST_HEAD(&cls->interfaces);
-	error = kobject_set_name(&cls->subsys.kset.kobj, cls->name);
+	error = kobject_set_name(&cls->subsys.kset.kobj, "%s", cls->name);
 	if (error)
 		return error;
 
@@ -283,8 +283,40 @@
 {
 	struct class_device *class_dev = to_class_dev(kobj);
 	int retval = 0;
+	int i = 0;
+	int length = 0;
 
 	pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
+
+	if (class_dev->dev) {
+		/* add physical device, backing this device  */
+		struct device *dev = class_dev->dev;
+		char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
+
+		add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
+				    &length, "PHYSDEVPATH=%s", path);
+		kfree(path);
+
+		/* add bus name of physical device */
+		if (dev->bus)
+			add_hotplug_env_var(envp, num_envp, &i,
+					    buffer, buffer_size, &length,
+					    "PHYSDEVBUS=%s", dev->bus->name);
+
+		/* add driver name of physical device */
+		if (dev->driver)
+			add_hotplug_env_var(envp, num_envp, &i,
+					    buffer, buffer_size, &length,
+					    "PHYSDEVDRIVER=%s", dev->driver->name);
+
+		/* terminate, set to next free slot, shrink available space */
+		envp[i] = NULL;
+		envp = &envp[i];
+		num_envp -= i;
+		buffer = &buffer[length];
+		buffer_size -= length;
+	}
+
 	if (class_dev->class->hotplug) {
 		/* have the bus specific function add its stuff */
 		retval = class_dev->class->hotplug (class_dev, envp, num_envp,
@@ -368,7 +400,7 @@
 		 class_dev->class_id);
 
 	/* first, register with generic layer. */
-	kobject_set_name(&class_dev->kobj, class_dev->class_id);
+	kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id);
 	if (parent)
 		class_dev->kobj.parent = &parent->subsys.kset.kobj;
 
@@ -528,22 +560,22 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(class_create_file);
-EXPORT_SYMBOL(class_remove_file);
-EXPORT_SYMBOL(class_register);
-EXPORT_SYMBOL(class_unregister);
-EXPORT_SYMBOL(class_get);
-EXPORT_SYMBOL(class_put);
-
-EXPORT_SYMBOL(class_device_register);
-EXPORT_SYMBOL(class_device_unregister);
-EXPORT_SYMBOL(class_device_initialize);
-EXPORT_SYMBOL(class_device_add);
-EXPORT_SYMBOL(class_device_del);
-EXPORT_SYMBOL(class_device_get);
-EXPORT_SYMBOL(class_device_put);
-EXPORT_SYMBOL(class_device_create_file);
-EXPORT_SYMBOL(class_device_remove_file);
+EXPORT_SYMBOL_GPL(class_create_file);
+EXPORT_SYMBOL_GPL(class_remove_file);
+EXPORT_SYMBOL_GPL(class_register);
+EXPORT_SYMBOL_GPL(class_unregister);
+EXPORT_SYMBOL_GPL(class_get);
+EXPORT_SYMBOL_GPL(class_put);
+
+EXPORT_SYMBOL_GPL(class_device_register);
+EXPORT_SYMBOL_GPL(class_device_unregister);
+EXPORT_SYMBOL_GPL(class_device_initialize);
+EXPORT_SYMBOL_GPL(class_device_add);
+EXPORT_SYMBOL_GPL(class_device_del);
+EXPORT_SYMBOL_GPL(class_device_get);
+EXPORT_SYMBOL_GPL(class_device_put);
+EXPORT_SYMBOL_GPL(class_device_create_file);
+EXPORT_SYMBOL_GPL(class_device_remove_file);
 
-EXPORT_SYMBOL(class_interface_register);
-EXPORT_SYMBOL(class_interface_unregister);
+EXPORT_SYMBOL_GPL(class_interface_register);
+EXPORT_SYMBOL_GPL(class_interface_unregister);
diff -Nru a/drivers/base/class_simple.c b/drivers/base/class_simple.c
--- a/drivers/base/class_simple.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/base/class_simple.c	2004-12-24 13:36:48 -08:00
@@ -122,7 +122,7 @@
  * be created, showing the dev_t for the device.  The pointer to the struct
  * class_device will be returned from the call.  Any further sysfs files that
  * might be required can be created using this pointer.
- * Note: the struct class_device passed to this function must have previously been
+ * Note: the struct class_simple passed to this function must have previously been
  * created with a call to class_simple_create().
  */
 struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...)
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
--- a/drivers/base/core.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/base/core.c	2004-12-24 13:36:17 -08:00
@@ -116,8 +116,29 @@
 			int num_envp, char *buffer, int buffer_size)
 {
 	struct device *dev = to_dev(kobj);
+	int i = 0;
+	int length = 0;
 	int retval = 0;
 
+	/* add bus name of physical device */
+	if (dev->bus)
+		add_hotplug_env_var(envp, num_envp, &i,
+				    buffer, buffer_size, &length,
+				    "PHYSDEVBUS=%s", dev->bus->name);
+
+	/* add driver name of physical device */
+	if (dev->driver)
+		add_hotplug_env_var(envp, num_envp, &i,
+				    buffer, buffer_size, &length,
+				    "PHYSDEVDRIVER=%s", dev->driver->name);
+
+	/* terminate, set to next free slot, shrink available space */
+	envp[i] = NULL;
+	envp = &envp[i];
+	num_envp -= i;
+	buffer = &buffer[length];
+	buffer_size -= length;
+
 	if (dev->bus->hotplug) {
 		/* have the bus specific function add its stuff */
 		retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size);
@@ -209,19 +230,19 @@
  */
 int device_add(struct device *dev)
 {
-	struct device * parent;
-	int error;
+	struct device *parent = NULL;
+	int error = -EINVAL;
 
 	dev = get_device(dev);
 	if (!dev || !strlen(dev->bus_id))
-		return -EINVAL;
+		goto Error;
 
 	parent = get_device(dev->parent);
 
 	pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id);
 
 	/* first, register with generic layer. */
-	kobject_set_name(&dev->kobj, dev->bus_id);
+	kobject_set_name(&dev->kobj, "%s", dev->bus_id);
 	if (parent)
 		dev->kobj.parent = &parent->kobj;
 
@@ -293,7 +314,8 @@
  */
 void put_device(struct device * dev)
 {
-	kobject_put(&dev->kobj);
+	if (dev)
+		kobject_put(&dev->kobj);
 }
 
 
@@ -401,17 +423,17 @@
 	return subsystem_register(&devices_subsys);
 }
 
-EXPORT_SYMBOL(device_for_each_child);
+EXPORT_SYMBOL_GPL(device_for_each_child);
 
-EXPORT_SYMBOL(device_initialize);
-EXPORT_SYMBOL(device_add);
-EXPORT_SYMBOL(device_register);
-
-EXPORT_SYMBOL(device_del);
-EXPORT_SYMBOL(device_unregister);
-EXPORT_SYMBOL(get_device);
-EXPORT_SYMBOL(put_device);
-EXPORT_SYMBOL(device_find);
+EXPORT_SYMBOL_GPL(device_initialize);
+EXPORT_SYMBOL_GPL(device_add);
+EXPORT_SYMBOL_GPL(device_register);
+
+EXPORT_SYMBOL_GPL(device_del);
+EXPORT_SYMBOL_GPL(device_unregister);
+EXPORT_SYMBOL_GPL(get_device);
+EXPORT_SYMBOL_GPL(put_device);
+EXPORT_SYMBOL_GPL(device_find);
 
-EXPORT_SYMBOL(device_create_file);
-EXPORT_SYMBOL(device_remove_file);
+EXPORT_SYMBOL_GPL(device_create_file);
+EXPORT_SYMBOL_GPL(device_remove_file);
diff -Nru a/drivers/base/cpu.c b/drivers/base/cpu.c
--- a/drivers/base/cpu.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/base/cpu.c	2004-12-24 13:36:34 -08:00
@@ -32,6 +32,8 @@
 	switch (buf[0]) {
 	case '0':
 		ret = cpu_down(cpu->sysdev.id);
+		if (!ret)
+			kobject_hotplug(&dev->kobj, KOBJ_OFFLINE);
 		break;
 	case '1':
 		ret = cpu_up(cpu->sysdev.id);
diff -Nru a/drivers/base/driver.c b/drivers/base/driver.c
--- a/drivers/base/driver.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/base/driver.c	2004-12-24 13:37:19 -08:00
@@ -129,11 +129,11 @@
 	return NULL;
 }
 
-EXPORT_SYMBOL(driver_register);
-EXPORT_SYMBOL(driver_unregister);
-EXPORT_SYMBOL(get_driver);
-EXPORT_SYMBOL(put_driver);
-EXPORT_SYMBOL(driver_find);
+EXPORT_SYMBOL_GPL(driver_register);
+EXPORT_SYMBOL_GPL(driver_unregister);
+EXPORT_SYMBOL_GPL(get_driver);
+EXPORT_SYMBOL_GPL(put_driver);
+EXPORT_SYMBOL_GPL(driver_find);
 
-EXPORT_SYMBOL(driver_create_file);
-EXPORT_SYMBOL(driver_remove_file);
+EXPORT_SYMBOL_GPL(driver_create_file);
+EXPORT_SYMBOL_GPL(driver_remove_file);
diff -Nru a/drivers/base/firmware.c b/drivers/base/firmware.c
--- a/drivers/base/firmware.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/base/firmware.c	2004-12-24 13:36:55 -08:00
@@ -30,5 +30,5 @@
 	return subsystem_register(&firmware_subsys);
 }
 
-EXPORT_SYMBOL(firmware_register);
-EXPORT_SYMBOL(firmware_unregister);
+EXPORT_SYMBOL_GPL(firmware_register);
+EXPORT_SYMBOL_GPL(firmware_unregister);
diff -Nru a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
--- a/drivers/base/firmware_class.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/base/firmware_class.c	2004-12-24 13:36:16 -08:00
@@ -94,19 +94,17 @@
 		       int num_envp, char *buffer, int buffer_size)
 {
 	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-	int i = 0;
-	char *scratch = buffer;
+	int i = 0, len = 0;
 
 	if (!test_bit(FW_STATUS_READY, &fw_priv->status))
 		return -ENODEV;
 
-	if (buffer_size < (FIRMWARE_NAME_MAX + 10))
-		return -ENOMEM;
-	if (num_envp < 1)
+	if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len,
+			"FIRMWARE=%s", fw_priv->fw_id))
 		return -ENOMEM;
 
-	envp[i++] = scratch;
-	scratch += sprintf(scratch, "FIRMWARE=%s", fw_priv->fw_id) + 1;
+	envp[i] = NULL;
+
 	return 0;
 }
 
@@ -422,7 +420,7 @@
 		add_timer(&fw_priv->timeout);
 	}
 
-	kobject_hotplug("add", &class_dev->kobj);
+	kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
 	wait_for_completion(&fw_priv->completion);
 	set_bit(FW_STATUS_DONE, &fw_priv->status);
 
@@ -441,6 +439,7 @@
 
 error_kfree_fw:
 	kfree(firmware);
+	*firmware_p = NULL;
 out:
 	return retval;
 }
@@ -582,4 +581,3 @@
 EXPORT_SYMBOL(request_firmware);
 EXPORT_SYMBOL(request_firmware_nowait);
 EXPORT_SYMBOL(register_firmware);
-EXPORT_SYMBOL(firmware_class);
diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/base/platform.c	2004-12-24 13:36:18 -08:00
@@ -298,13 +298,13 @@
 	}
 	return mask & *dev->dma_mask;
 }
-EXPORT_SYMBOL(dma_get_required_mask);
+EXPORT_SYMBOL_GPL(dma_get_required_mask);
 #endif
 
-EXPORT_SYMBOL(platform_bus);
-EXPORT_SYMBOL(platform_bus_type);
-EXPORT_SYMBOL(platform_device_register);
-EXPORT_SYMBOL(platform_device_register_simple);
-EXPORT_SYMBOL(platform_device_unregister);
-EXPORT_SYMBOL(platform_get_irq);
-EXPORT_SYMBOL(platform_get_resource);
+EXPORT_SYMBOL_GPL(platform_bus);
+EXPORT_SYMBOL_GPL(platform_bus_type);
+EXPORT_SYMBOL_GPL(platform_device_register);
+EXPORT_SYMBOL_GPL(platform_device_register_simple);
+EXPORT_SYMBOL_GPL(platform_device_unregister);
+EXPORT_SYMBOL_GPL(platform_get_irq);
+EXPORT_SYMBOL_GPL(platform_get_resource);
diff -Nru a/drivers/base/power/main.c b/drivers/base/power/main.c
--- a/drivers/base/power/main.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/base/power/main.c	2004-12-24 13:37:18 -08:00
@@ -28,6 +28,7 @@
 LIST_HEAD(dpm_off_irq);
 
 DECLARE_MUTEX(dpm_sem);
+DECLARE_MUTEX(dpm_list_sem);
 
 /*
  * PM Reference Counting.
@@ -66,7 +67,7 @@
 	dev->power.pm_parent = parent;
 	device_pm_hold(parent);
 }
-EXPORT_SYMBOL(device_pm_set_parent);
+EXPORT_SYMBOL_GPL(device_pm_set_parent);
 
 int device_pm_add(struct device * dev)
 {
@@ -75,12 +76,12 @@
 	pr_debug("PM: Adding info for %s:%s\n",
 		 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
 	atomic_set(&dev->power.pm_users, 0);
-	down(&dpm_sem);
+	down(&dpm_list_sem);
 	list_add_tail(&dev->power.entry, &dpm_active);
 	device_pm_set_parent(dev, dev->parent);
 	if ((error = dpm_sysfs_add(dev)))
 		list_del(&dev->power.entry);
-	up(&dpm_sem);
+	up(&dpm_list_sem);
 	return error;
 }
 
@@ -88,11 +89,11 @@
 {
 	pr_debug("PM: Removing info for %s:%s\n",
 		 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
-	down(&dpm_sem);
+	down(&dpm_list_sem);
 	dpm_sysfs_remove(dev);
 	device_pm_release(dev->power.pm_parent);
-	list_del(&dev->power.entry);
-	up(&dpm_sem);
+	list_del_init(&dev->power.entry);
+	up(&dpm_list_sem);
 }
 
 
diff -Nru a/drivers/base/power/power.h b/drivers/base/power/power.h
--- a/drivers/base/power/power.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/base/power/power.h	2004-12-24 13:37:43 -08:00
@@ -28,6 +28,11 @@
 extern struct semaphore dpm_sem;
 
 /*
+ * Used to serialize changes to the dpm_* lists.
+ */
+extern struct semaphore dpm_list_sem;
+
+/*
  * The PM lists.
  */
 extern struct list_head dpm_active;
diff -Nru a/drivers/base/power/resume.c b/drivers/base/power/resume.c
--- a/drivers/base/power/resume.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/base/power/resume.c	2004-12-24 13:37:18 -08:00
@@ -31,16 +31,22 @@
 
 void dpm_resume(void)
 {
+	down(&dpm_list_sem);
 	while(!list_empty(&dpm_off)) {
 		struct list_head * entry = dpm_off.next;
 		struct device * dev = to_device(entry);
+
+		get_device(dev);
 		list_del_init(entry);
+		list_add_tail(entry, &dpm_active);
 
+		up(&dpm_list_sem);
 		if (!dev->power.prev_state)
 			resume_device(dev);
-
-		list_add_tail(entry, &dpm_active);
+		down(&dpm_list_sem);
+		put_device(dev);
 	}
+	up(&dpm_list_sem);
 }
 
 
@@ -58,7 +64,7 @@
 	up(&dpm_sem);
 }
 
-EXPORT_SYMBOL(device_resume);
+EXPORT_SYMBOL_GPL(device_resume);
 
 
 /**
@@ -76,9 +82,13 @@
 {
 	while(!list_empty(&dpm_off_irq)) {
 		struct list_head * entry = dpm_off_irq.next;
+		struct device * dev = to_device(entry);
+
+		get_device(dev);
 		list_del_init(entry);
-		resume_device(to_device(entry));
 		list_add_tail(entry, &dpm_active);
+		resume_device(dev);
+		put_device(dev);
 	}
 }
 
@@ -97,6 +107,6 @@
 	dpm_power_up();
 }
 
-EXPORT_SYMBOL(device_power_up);
+EXPORT_SYMBOL_GPL(device_power_up);
 
 
diff -Nru a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
--- a/drivers/base/power/suspend.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/base/power/suspend.c	2004-12-24 13:37:19 -08:00
@@ -63,11 +63,6 @@
  *	If we hit a failure with any of the devices, call device_resume()
  *	above to bring the suspended devices back to life.
  *
- *	Note this function leaves dpm_sem held to
- *	a) block other devices from registering.
- *	b) prevent other PM operations from happening after we've begun.
- *	c) make sure we're exclusive when we disable interrupts.
- *
  */
 
 int device_suspend(u32 state)
@@ -75,32 +70,43 @@
 	int error = 0;
 
 	down(&dpm_sem);
-	while(!list_empty(&dpm_active)) {
+	down(&dpm_list_sem);
+	while (!list_empty(&dpm_active) && error == 0) {
 		struct list_head * entry = dpm_active.prev;
 		struct device * dev = to_device(entry);
+
+		get_device(dev);
+		up(&dpm_list_sem);
+
 		error = suspend_device(dev, state);
 
-		if (!error) {
-			list_del(&dev->power.entry);
-			list_add(&dev->power.entry, &dpm_off);
-		} else if (error == -EAGAIN) {
-			list_del(&dev->power.entry);
-			list_add(&dev->power.entry, &dpm_off_irq);
-		} else {
+		down(&dpm_list_sem);
+
+		/* Check if the device got removed */
+		if (!list_empty(&dev->power.entry)) {
+			/* Move it to the dpm_off or dpm_off_irq list */
+			if (!error) {
+				list_del(&dev->power.entry);
+				list_add(&dev->power.entry, &dpm_off);
+			} else if (error == -EAGAIN) {
+				list_del(&dev->power.entry);
+				list_add(&dev->power.entry, &dpm_off_irq);
+				error = 0;
+			}
+		}
+		if (error)
 			printk(KERN_ERR "Could not suspend device %s: "
 				"error %d\n", kobject_name(&dev->kobj), error);
-			goto Error;
-		}
+		put_device(dev);
 	}
- Done:
+	up(&dpm_list_sem);
+	if (error)
+		dpm_resume();
 	up(&dpm_sem);
 	return error;
- Error:
-	dpm_resume();
-	goto Done;
 }
 
-EXPORT_SYMBOL(device_suspend);
+EXPORT_SYMBOL_GPL(device_suspend);
 
 
 /**
@@ -132,5 +138,5 @@
 	goto Done;
 }
 
-EXPORT_SYMBOL(device_power_down);
+EXPORT_SYMBOL_GPL(device_power_down);
 
diff -Nru a/drivers/base/sys.c b/drivers/base/sys.c
--- a/drivers/base/sys.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/base/sys.c	2004-12-24 13:36:16 -08:00
@@ -73,8 +73,8 @@
 	sysfs_remove_file(&s->kobj, &a->attr);
 }
 
-EXPORT_SYMBOL(sysdev_create_file);
-EXPORT_SYMBOL(sysdev_remove_file);
+EXPORT_SYMBOL_GPL(sysdev_create_file);
+EXPORT_SYMBOL_GPL(sysdev_remove_file);
 
 /*
  * declare system_subsys
@@ -98,8 +98,8 @@
 	kset_unregister(&cls->kset);
 }
 
-EXPORT_SYMBOL(sysdev_class_register);
-EXPORT_SYMBOL(sysdev_class_unregister);
+EXPORT_SYMBOL_GPL(sysdev_class_register);
+EXPORT_SYMBOL_GPL(sysdev_class_unregister);
 
 
 static LIST_HEAD(global_drivers);
@@ -157,8 +157,8 @@
 	up_write(&system_subsys.rwsem);
 }
 
-EXPORT_SYMBOL(sysdev_driver_register);
-EXPORT_SYMBOL(sysdev_driver_unregister);
+EXPORT_SYMBOL_GPL(sysdev_driver_register);
+EXPORT_SYMBOL_GPL(sysdev_driver_unregister);
 
 
 
@@ -392,5 +392,5 @@
 	return subsystem_register(&system_subsys);
 }
 
-EXPORT_SYMBOL(sysdev_register);
-EXPORT_SYMBOL(sysdev_unregister);
+EXPORT_SYMBOL_GPL(sysdev_register);
+EXPORT_SYMBOL_GPL(sysdev_unregister);
diff -Nru a/drivers/block/DAC960.c b/drivers/block/DAC960.c
--- a/drivers/block/DAC960.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/block/DAC960.c	2004-12-24 13:37:18 -08:00
@@ -2678,7 +2678,7 @@
   DAC960_Controller_T *Controller = NULL;
   unsigned char DeviceFunction = PCI_Device->devfn;
   unsigned char ErrorStatus, Parameter0, Parameter1;
-  unsigned int IRQ_Channel = PCI_Device->irq;
+  unsigned int IRQ_Channel;
   void __iomem *BaseAddress;
   int i;
 
@@ -2958,6 +2958,7 @@
   /*
      Acquire shared access to the IRQ Channel.
   */
+  IRQ_Channel = PCI_Device->irq;
   if (request_irq(IRQ_Channel, InterruptHandler, SA_SHIRQ,
 		      Controller->FullModelName, Controller) < 0)
   {
diff -Nru a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig	2004-12-24 13:36:31 -08:00
+++ b/drivers/block/Kconfig	2004-12-24 13:36:31 -08:00
@@ -308,6 +308,8 @@
 	  This driver supports certain USB attached storage devices
 	  such as flash keys.
 
+	  Warning: Enabling this cripples the usb-storage driver.
+
 	  If unsure, say N.
 
 config BLK_DEV_RAM
@@ -329,6 +331,14 @@
 	  Most normal users won't need the RAM disk functionality, and can
 	  thus say N here.
 
+config BLK_DEV_RAM_COUNT
+	int "Default number of RAM disks" if BLK_DEV_RAM
+	default "16"
+	help
+	  The default value is 16 RAM disks. Change this if you know what
+	  are doing. If you boot from a filesystem that needs to be extracted
+	  in memory, you will need at least one RAM disk (e.g. root on cramfs).
+
 config BLK_DEV_RAM_SIZE
 	int "Default RAM disk size (kbytes)"
 	depends on BLK_DEV_RAM
@@ -348,6 +358,32 @@
 	  "real" root file system, etc. See <file:Documentation/initrd.txt>
 	  for details.
 
+config INITRAMFS_SOURCE
+	string "Source directory of cpio_list"
+	default ""
+	help
+	  This can be set to either a directory containing files, etc to be
+	  included in the initramfs archive, or a file containing newline
+	  separated entries.
+
+	  If it is a file, it should be in the following format:
+	    # a comment
+	    file <name> <location> <mode> <uid> <gid>
+	    dir <name> <mode> <uid> <gid>
+	    nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>
+
+	  Where:
+	    <name>      name of the file/dir/nod in the archive
+	    <location>  location of the file in the current filesystem
+	    <mode>      mode/permissions of the file
+	    <uid>       user id (0=root)
+	    <gid>       group id (0=root)
+	    <dev_type>  device type (b=block, c=character)
+	    <maj>       major number of nod
+	    <min>       minor number of nod
+
+	  If you are not sure, leave it blank.
+
 config LBD
 	bool "Support for Large Block Devices"
 	depends on X86 || MIPS32 || PPC32 || ARCH_S390_31 || SUPERH
@@ -356,6 +392,41 @@
 	  your machine, or if you want to have a raid or loopback device
 	  bigger than 2TB.  Otherwise say N.
 
+config CDROM_PKTCDVD
+	tristate "Packet writing on CD/DVD media"
+	help
+	  If you have a CDROM drive that supports packet writing, say Y to
+	  include preliminary support. It should work with any MMC/Mt Fuji
+	  compliant ATAPI or SCSI drive, which is just about any newer CD
+	  writer.
+
+	  Currently only writing to CD-RW, DVD-RW and DVD+RW discs is possible.
+	  DVD-RW disks must be in restricted overwrite mode.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called pktcdvd.
+
+config CDROM_PKTCDVD_BUFFERS
+	int "Free buffers for data gathering"
+	depends on CDROM_PKTCDVD
+	default "8"
+	help
+	  This controls the maximum number of active concurrent packets. More
+	  concurrent packets can increase write performance, but also require
+	  more memory. Each concurrent packet will require approximately 64Kb
+	  of non-swappable kernel memory, memory which will be allocated at
+	  pktsetup time.
+
+config CDROM_PKTCDVD_WCACHE
+	bool "Enable write caching"
+	depends on CDROM_PKTCDVD
+	help
+	  If enabled, write caching will be set for the CD-R/W device. For now
+	  this option is dangerous unless the CD-RW media is known good, as we
+	  don't do deferred write error handling yet.
+
 source "drivers/s390/block/Kconfig"
+
+source "drivers/block/Kconfig.iosched"
 
 endmenu
diff -Nru a/drivers/block/Kconfig.iosched b/drivers/block/Kconfig.iosched
--- a/drivers/block/Kconfig.iosched	2004-12-24 13:36:17 -08:00
+++ b/drivers/block/Kconfig.iosched	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,8 @@
+
+menu "IO Schedulers"
+
 config IOSCHED_NOOP
-	bool "No-op I/O scheduler" if EMBEDDED
+	bool
 	default y
 	---help---
 	  The no-op I/O scheduler is a minimal scheduler that does basic merging
@@ -9,7 +12,7 @@
 	  the kernel.
 
 config IOSCHED_AS
-	bool "Anticipatory I/O scheduler" if EMBEDDED
+	tristate "Anticipatory I/O scheduler"
 	default y
 	---help---
 	  The anticipatory I/O scheduler is the default disk scheduler. It is
@@ -18,7 +21,7 @@
 	  slower in some cases especially some database loads.
 
 config IOSCHED_DEADLINE
-	bool "Deadline I/O scheduler" if EMBEDDED
+	tristate "Deadline I/O scheduler"
 	default y
 	---help---
 	  The deadline I/O scheduler is simple and compact, and is often as
@@ -28,9 +31,11 @@
 	  anticipatory I/O scheduler and so is a good choice.
 
 config IOSCHED_CFQ
-	bool "CFQ I/O scheduler" if EMBEDDED
+	tristate "CFQ I/O scheduler"
 	default y
 	---help---
 	  The CFQ I/O scheduler tries to distribute bandwidth equally
 	  among all processes in the system. It should provide a fair
 	  working environment, suitable for desktop systems.
+
+endmenu
diff -Nru a/drivers/block/Makefile b/drivers/block/Makefile
--- a/drivers/block/Makefile	2004-12-24 13:37:18 -08:00
+++ b/drivers/block/Makefile	2004-12-24 13:37:18 -08:00
@@ -35,6 +35,7 @@
 obj-$(CONFIG_BLK_CPQ_DA)	+= cpqarray.o
 obj-$(CONFIG_BLK_CPQ_CISS_DA)  += cciss.o
 obj-$(CONFIG_BLK_DEV_DAC960)	+= DAC960.o
+obj-$(CONFIG_CDROM_PKTCDVD)	+= pktcdvd.o
 
 obj-$(CONFIG_BLK_DEV_UMEM)	+= umem.o
 obj-$(CONFIG_BLK_DEV_NBD)	+= nbd.o
diff -Nru a/drivers/block/amiflop.c b/drivers/block/amiflop.c
--- a/drivers/block/amiflop.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/block/amiflop.c	2004-12-24 13:36:48 -08:00
@@ -105,9 +105,9 @@
 #define FD_HD_3 	0x55555555  /* high-density 3.5" (1760K) drive */
 #define FD_DD_5 	0xaaaaaaaa  /* double-density 5.25" (440K) drive */
 
-static long int fd_def_df0 = FD_DD_3;     /* default for df0 if it doesn't identify */
+static unsigned long int fd_def_df0 = FD_DD_3;     /* default for df0 if it doesn't identify */
 
-MODULE_PARM(fd_def_df0,"l");
+module_param(fd_def_df0, ulong, 0);
 MODULE_LICENSE("GPL");
 
 static struct request_queue *floppy_queue;
diff -Nru a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c
--- a/drivers/block/as-iosched.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/block/as-iosched.c	2004-12-24 13:36:16 -08:00
@@ -614,7 +614,7 @@
 static void as_antic_timeout(unsigned long data)
 {
 	struct request_queue *q = (struct request_queue *)data;
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	unsigned long flags;
 
 	spin_lock_irqsave(q->queue_lock, flags);
@@ -945,7 +945,7 @@
  */
 static void as_completed_request(request_queue_t *q, struct request *rq)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct as_rq *arq = RQ_DATA(rq);
 
 	WARN_ON(!list_empty(&rq->queuelist));
@@ -1030,7 +1030,7 @@
 {
 	struct as_rq *arq = RQ_DATA(rq);
 	const int data_dir = arq->is_sync;
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 
 	WARN_ON(arq->state != AS_RQ_QUEUED);
 
@@ -1361,7 +1361,7 @@
 
 static struct request *as_next_request(request_queue_t *q)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct request *rq = NULL;
 
 	/*
@@ -1469,7 +1469,7 @@
  */
 static void as_requeue_request(request_queue_t *q, struct request *rq)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct as_rq *arq = RQ_DATA(rq);
 
 	if (arq) {
@@ -1509,7 +1509,7 @@
 static void
 as_insert_request(request_queue_t *q, struct request *rq, int where)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct as_rq *arq = RQ_DATA(rq);
 
 	if (arq) {
@@ -1562,7 +1562,7 @@
  */
 static int as_queue_empty(request_queue_t *q)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 
 	if (!list_empty(&ad->fifo_list[REQ_ASYNC])
 		|| !list_empty(&ad->fifo_list[REQ_SYNC])
@@ -1601,7 +1601,7 @@
 static int
 as_merge(request_queue_t *q, struct request **req, struct bio *bio)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	sector_t rb_key = bio->bi_sector + bio_sectors(bio);
 	struct request *__rq;
 	int ret;
@@ -1656,7 +1656,7 @@
 
 static void as_merged_request(request_queue_t *q, struct request *req)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct as_rq *arq = RQ_DATA(req);
 
 	/*
@@ -1701,7 +1701,7 @@
 as_merged_requests(request_queue_t *q, struct request *req,
 			 struct request *next)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct as_rq *arq = RQ_DATA(req);
 	struct as_rq *anext = RQ_DATA(next);
 
@@ -1788,7 +1788,7 @@
 
 static void as_put_request(request_queue_t *q, struct request *rq)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct as_rq *arq = RQ_DATA(rq);
 
 	if (!arq) {
@@ -1807,7 +1807,7 @@
 
 static int as_set_request(request_queue_t *q, struct request *rq, int gfp_mask)
 {
-	struct as_data *ad = q->elevator.elevator_data;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct as_rq *arq = mempool_alloc(ad->arq_pool, gfp_mask);
 
 	if (arq) {
@@ -1828,21 +1828,21 @@
 
 static int as_may_queue(request_queue_t *q, int rw)
 {
-	int ret = 0;
-	struct as_data *ad = q->elevator.elevator_data;
+	int ret = ELV_MQUEUE_MAY;
+	struct as_data *ad = q->elevator->elevator_data;
 	struct io_context *ioc;
 	if (ad->antic_status == ANTIC_WAIT_REQ ||
 			ad->antic_status == ANTIC_WAIT_NEXT) {
 		ioc = as_get_io_context();
 		if (ad->io_context == ioc)
-			ret = 1;
+			ret = ELV_MQUEUE_MUST;
 		put_io_context(ioc);
 	}
 
 	return ret;
 }
 
-static void as_exit(request_queue_t *q, elevator_t *e)
+static void as_exit_queue(elevator_t *e)
 {
 	struct as_data *ad = e->elevator_data;
 
@@ -1862,7 +1862,7 @@
  * initialize elevator private data (as_data), and alloc a arq for
  * each request on the free lists
  */
-static int as_init(request_queue_t *q, elevator_t *e)
+static int as_init_queue(request_queue_t *q, elevator_t *e)
 {
 	struct as_data *ad;
 	int i;
@@ -1962,10 +1962,10 @@
 	return pos;
 }
 
-#define SHOW_FUNCTION(__FUNC, __VAR)					\
+#define SHOW_FUNCTION(__FUNC, __VAR)				\
 static ssize_t __FUNC(struct as_data *ad, char *page)		\
-{									\
-	return as_var_show(__VAR, (page));			\
+{								\
+	return as_var_show(jiffies_to_msecs((__VAR)), (page));	\
 }
 SHOW_FUNCTION(as_readexpire_show, ad->fifo_expire[REQ_SYNC]);
 SHOW_FUNCTION(as_writeexpire_show, ad->fifo_expire[REQ_ASYNC]);
@@ -1982,6 +1982,7 @@
 		*(__PTR) = (MIN);					\
 	else if (*(__PTR) > (MAX))					\
 		*(__PTR) = (MAX);					\
+	*(__PTR) = msecs_to_jiffies(*(__PTR));				\
 	return ret;							\
 }
 STORE_FUNCTION(as_readexpire_store, &ad->fifo_expire[REQ_SYNC], 0, INT_MAX);
@@ -2070,39 +2071,64 @@
 	.default_attrs	= default_attrs,
 };
 
-static int __init as_slab_setup(void)
+static struct elevator_type iosched_as = {
+	.ops = {
+		.elevator_merge_fn = 		as_merge,
+		.elevator_merged_fn =		as_merged_request,
+		.elevator_merge_req_fn =	as_merged_requests,
+		.elevator_next_req_fn =		as_next_request,
+		.elevator_add_req_fn =		as_insert_request,
+		.elevator_remove_req_fn =	as_remove_request,
+		.elevator_requeue_req_fn = 	as_requeue_request,
+		.elevator_queue_empty_fn =	as_queue_empty,
+		.elevator_completed_req_fn =	as_completed_request,
+		.elevator_former_req_fn =	as_former_request,
+		.elevator_latter_req_fn =	as_latter_request,
+		.elevator_set_req_fn =		as_set_request,
+		.elevator_put_req_fn =		as_put_request,
+		.elevator_may_queue_fn =	as_may_queue,
+		.elevator_init_fn =		as_init_queue,
+		.elevator_exit_fn =		as_exit_queue,
+	},
+
+	.elevator_ktype = &as_ktype,
+	.elevator_name = "anticipatory",
+	.elevator_owner = THIS_MODULE,
+};
+
+static int __init as_init(void)
 {
+	int ret;
+
 	arq_pool = kmem_cache_create("as_arq", sizeof(struct as_rq),
 				     0, 0, NULL, NULL);
-
 	if (!arq_pool)
-		panic("as: can't init slab pool\n");
+		return -ENOMEM;
 
-	return 0;
-}
+	ret = elv_register(&iosched_as);
+	if (!ret) {
+		/*
+		 * don't allow AS to get unregistered, since we would have
+		 * to browse all tasks in the system and release their
+		 * as_io_context first
+		 */
+		__module_get(THIS_MODULE);
+		return 0;
+	}
 
-subsys_initcall(as_slab_setup);
+	kmem_cache_destroy(arq_pool);
+	return ret;
+}
 
-elevator_t iosched_as = {
-	.elevator_merge_fn = 		as_merge,
-	.elevator_merged_fn =		as_merged_request,
-	.elevator_merge_req_fn =	as_merged_requests,
-	.elevator_next_req_fn =		as_next_request,
-	.elevator_add_req_fn =		as_insert_request,
-	.elevator_remove_req_fn =	as_remove_request,
-	.elevator_requeue_req_fn = 	as_requeue_request,
-	.elevator_queue_empty_fn =	as_queue_empty,
-	.elevator_completed_req_fn =	as_completed_request,
-	.elevator_former_req_fn =	as_former_request,
-	.elevator_latter_req_fn =	as_latter_request,
-	.elevator_set_req_fn =		as_set_request,
-	.elevator_put_req_fn =		as_put_request,
-	.elevator_may_queue_fn =	as_may_queue,
-	.elevator_init_fn =		as_init,
-	.elevator_exit_fn =		as_exit,
+static void __exit as_exit(void)
+{
+	kmem_cache_destroy(arq_pool);
+	elv_unregister(&iosched_as);
+}
 
-	.elevator_ktype =		&as_ktype,
-	.elevator_name =		"anticipatory",
-};
+module_init(as_init);
+module_exit(as_exit);
 
-EXPORT_SYMBOL(iosched_as);
+MODULE_AUTHOR("Nick Piggin");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("anticipatory IO scheduler");
diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c
--- a/drivers/block/cciss.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/block/cciss.c	2004-12-24 13:37:29 -08:00
@@ -185,10 +185,11 @@
         }
         return c;
 }
-#ifdef CONFIG_PROC_FS
 
 #include "cciss_scsi.c"		/* For SCSI tape support */
 
+#ifdef CONFIG_PROC_FS
+
 /*
  * Report information about this controller.
  */
@@ -438,13 +439,22 @@
 
 	/*
 	 * Root is allowed to open raw volume zero even if it's not configured
-	 * so array config can still work.  I don't think I really like this,
+	 * so array config can still work. Root is also allowed to open any
+	 * volume that has a LUN ID, so it can issue IOCTL to reread the
+	 * disk information.  I don't think I really like this
 	 * but I'm already using way to many device nodes to claim another one
 	 * for "raw controller".
 	 */
 	if (drv->nr_blocks == 0) {
-		if (iminor(inode) != 0)
+		if (iminor(inode) != 0)	{ 	/* not node 0? */
+			/* if not node 0 make sure it is a partition = 0 */
+			if (iminor(inode) & 0x0f) {
 			return -ENXIO;
+				/* if it is, make sure we have a LUN ID */
+			} else if (drv->LunID == 0) {
+				return -ENXIO;
+			}
+		}
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 	}
@@ -799,7 +809,7 @@
  		luninfo.num_opens = drv->usage_count;
  		luninfo.num_parts = 0;
  		/* count partitions 1 to 15 with sizes > 0 */
- 		for(i=1; i <MAX_PART; i++) {
+ 		for (i = 0; i < MAX_PART - 1; i++) {
 			if (!disk->part[i])
 				continue;
 			if (disk->part[i]->nr_sects != 0)
@@ -1090,18 +1100,11 @@
 		return(status);
 	}
 	default:
-		return -EBADRQC;
+		return -ENOTTY;
 	}
 	
 }
 
-static int cciss_revalidate(struct gendisk *disk)
-{
-	drive_info_struct *drv = disk->private_data;
-	set_capacity(disk, drv->nr_blocks);
-	return 0;
-}
-
 /*
  * revalidate_allvol is for online array config utilities.  After a
  * utility reconfigures the drives in the array, it can use this function
@@ -1153,7 +1156,9 @@
 	for (i = 0; i < NWD; i++) {
 		struct gendisk *disk = host->gendisk[i];
 		drive_info_struct *drv = &(host->drv[i]);
-		if (!drv->nr_blocks)
+		/* we must register the controller even if no disks exist */
+		/* this is for the online array utilities */
+		if (!drv->heads && i)
 			continue;
 		blk_queue_hardsect_size(host->queue, drv->block_size);
 		set_capacity(disk, drv->nr_blocks);
@@ -1485,13 +1490,7 @@
 			}
 		}
 	} else { /* Get geometry failed */
-		printk(KERN_WARNING "cciss: reading geometry failed, "
-			"continuing with default geometry\n");
-		drv->block_size = block_size;
-		drv->nr_blocks = total_size;
-		drv->heads = 255;
-		drv->sectors = 32; // Sectors per track
-		drv->cylinders = total_size / 255 / 32;
+		printk(KERN_WARNING "cciss: reading geometry failed\n");
 	}
 	printk(KERN_INFO "      heads= %d, sectors= %d, cylinders= %d\n\n",
 		drv->heads, drv->sectors, drv->cylinders);
@@ -1520,6 +1519,7 @@
 		*total_size, *block_size);
 	return;
 }
+
 static int register_new_disk(ctlr_info_t *h)
 {
         struct gendisk *disk;
@@ -1663,7 +1663,9 @@
 	/* setup partitions per disk */
         disk = h->gendisk[logvol];
 	set_capacity(disk, h->drv[logvol].nr_blocks);
-	add_disk(disk);
+	/* if it's the controller it's already added */
+	if(logvol)
+		add_disk(disk);
 freeret:
 	kfree(ld_buff);
 	kfree(size_buff);
@@ -1675,6 +1677,53 @@
 	logvol = -1;
 	goto freeret;
 }
+
+static int cciss_revalidate(struct gendisk *disk)
+{
+	ctlr_info_t *h = get_host(disk);
+	drive_info_struct *drv = get_drv(disk);
+	int logvol;
+	int FOUND=0;
+	unsigned int block_size;
+	unsigned int total_size;
+	ReadCapdata_struct *size_buff = NULL;
+	InquiryData_struct *inq_buff = NULL;
+
+	for(logvol=0; logvol < CISS_MAX_LUN; logvol++)
+	{
+		if(h->drv[logvol].LunID == drv->LunID) {
+			FOUND=1;
+			break;
+		}
+	}
+
+	if (!FOUND) return 1;
+
+	size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL);
+        if (size_buff == NULL)
+        {
+                printk(KERN_WARNING "cciss: out of memory\n");
+                return 1;
+        }
+	inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL);
+        if (inq_buff == NULL)
+        {
+                printk(KERN_WARNING "cciss: out of memory\n");
+		kfree(size_buff);
+                return 1;
+        }
+
+	cciss_read_capacity(h->ctlr, logvol, size_buff, 1, &total_size, &block_size);
+	cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, inq_buff, drv);
+
+	blk_queue_hardsect_size(h->queue, drv->block_size);
+	set_capacity(disk, drv->nr_blocks);
+
+	kfree(size_buff);
+	kfree(inq_buff);
+	return 0;
+}
+
 /*
  *   Wait polling for a command to complete.
  *   The memory mapped FIFO is polled for the completion.
@@ -2762,7 +2811,9 @@
 		disk->fops = &cciss_fops;
 		disk->queue = hba[i]->queue;
 		disk->private_data = drv;
-		if( !(drv->nr_blocks))
+		/* we must register the controller even if no disks exist */
+		/* this is for the online array utilities */
+		if(!drv->heads && j)
 			continue;
 		blk_queue_hardsect_size(hba[i]->queue, drv->block_size);
 		set_capacity(disk, drv->nr_blocks);
diff -Nru a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
--- a/drivers/block/cciss_scsi.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/block/cciss_scsi.c	2004-12-24 13:36:31 -08:00
@@ -28,7 +28,9 @@
    through the array controller.  Note in particular, neither 
    physical nor logical disks are presented through the scsi layer. */
 
-#include "../scsi/scsi.h" 
+#include <scsi/scsi.h> 
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h> 
 #include <asm/atomic.h>
 #include <linux/timer.h>
@@ -61,15 +63,8 @@
 		int length, 	   /* length of data in buffer */
 		int func);	   /* 0 == read, 1 == write */
 
-int cciss_scsi_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *));
-#if 0
-int cciss_scsi_abort(Scsi_Cmnd *cmd);
-#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS
-int cciss_scsi_reset(Scsi_Cmnd *cmd, unsigned int reset_flags);
-#else
-int cciss_scsi_reset(Scsi_Cmnd *cmd);
-#endif
-#endif
+int cciss_scsi_queue_command (struct scsi_cmnd *cmd, 
+		void (* done)(struct scsi_cmnd *));
 
 static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = {
 	{ .name = "cciss0", .ndevices = 0 },
@@ -82,7 +77,7 @@
 	{ .name = "cciss7", .ndevices = 0 },
 };
 
-static Scsi_Host_Template cciss_driver_template = {
+static struct scsi_host_template cciss_driver_template = {
 	.module			= THIS_MODULE,
 	.name			= "cciss",
 	.proc_name		= "cciss",
@@ -552,7 +547,7 @@
 static void
 complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag)
 {
-	Scsi_Cmnd *cmd;
+	struct scsi_cmnd *cmd;
 	ctlr_info_t *ctlr;
 	u64bit addr64;
 	ErrorInfo_struct *ei;
@@ -565,7 +560,7 @@
 		return;
 	}
 
-	cmd = (Scsi_Cmnd *) cp->scsi_cmd;	
+	cmd = (struct scsi_cmnd *) cp->scsi_cmd;	
 	ctlr = hba[cp->ctlr];
 
 	/* undo the DMA mappings */
@@ -573,14 +568,14 @@
 	if (cmd->use_sg) {
 		pci_unmap_sg(ctlr->pdev,
 			cmd->buffer, cmd->use_sg,
-				scsi_to_pci_dma_dir(cmd->sc_data_direction)); 
+				cmd->sc_data_direction); 
 	}
 	else if (cmd->request_bufflen) {
 		addr64.val32.lower = cp->SG[0].Addr.lower;
                 addr64.val32.upper = cp->SG[0].Addr.upper;
                 pci_unmap_single(ctlr->pdev, (dma_addr_t) addr64.val,
                 	cmd->request_bufflen, 
-				scsi_to_pci_dma_dir(cmd->sc_data_direction));
+				cmd->sc_data_direction);
 	}
 
 	cmd->result = (DID_OK << 16); 		/* host byte */
@@ -783,9 +778,8 @@
 	cp->Request.Type.Direction = direction;
 
 	/* Fill in the SG list and do dma mapping */
-	cciss_map_one(c->pdev, cp, 
-			(unsigned char *) buf, bufsize,
-			scsi_to_pci_dma_dir(SCSI_DATA_READ)); 
+	cciss_map_one(c->pdev, cp, (unsigned char *) buf,
+			bufsize, DMA_FROM_DEVICE); 
 
 	cp->waiting = &wait;
 
@@ -799,9 +793,7 @@
 	wait_for_completion(&wait);
 
 	/* undo the dma mapping */
-	cciss_unmap_one(c->pdev, cp, bufsize,
-				scsi_to_pci_dma_dir(SCSI_DATA_READ)); 
-
+	cciss_unmap_one(c->pdev, cp, bufsize, DMA_FROM_DEVICE);
 	return(0);
 }
 
@@ -1180,14 +1172,14 @@
 }
 
 
-/* cciss_scatter_gather takes a Scsi_Cmnd, (cmd), and does the pci 
+/* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci 
    dma mapping  and fills in the scatter gather entries of the 
    cciss command, cp. */
 
 static void
 cciss_scatter_gather(struct pci_dev *pdev, 
 		CommandList_struct *cp,	
-		Scsi_Cmnd *cmd)
+		struct scsi_cmnd *cmd)
 {
 	unsigned int use_sg, nsegs=0, len;
 	struct scatterlist *scatter = (struct scatterlist *) cmd->buffer;
@@ -1200,7 +1192,7 @@
 			addr64 = (__u64) pci_map_single(pdev, 
 				cmd->request_buffer, 
 				cmd->request_bufflen, 
-				scsi_to_pci_dma_dir(cmd->sc_data_direction)); 
+				cmd->sc_data_direction); 
 	
 			cp->SG[0].Addr.lower = 
 			  (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF);
@@ -1213,7 +1205,7 @@
 	else if (cmd->use_sg <= MAXSGENTRIES) {	/* not too many addrs? */
 
 		use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, 
-			scsi_to_pci_dma_dir(cmd->sc_data_direction));
+			cmd->sc_data_direction);
 
 		for (nsegs=0; nsegs < use_sg; nsegs++) {
 			addr64 = (__u64) sg_dma_address(&scatter[nsegs]);
@@ -1234,7 +1226,7 @@
 
 
 int 
-cciss_scsi_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *))
+cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
 {
 	ctlr_info_t **c;
 	int ctlr, rc;
@@ -1302,11 +1294,10 @@
 	cp->Request.Type.Attribute = ATTR_SIMPLE;
 	switch(cmd->sc_data_direction)
 	{
-	  case SCSI_DATA_WRITE: cp->Request.Type.Direction = XFER_WRITE; break;
-	  case SCSI_DATA_READ: cp->Request.Type.Direction = XFER_READ; break;
-	  case SCSI_DATA_NONE: cp->Request.Type.Direction = XFER_NONE; break;
-
-	  case SCSI_DATA_UNKNOWN:
+	  case DMA_TO_DEVICE: cp->Request.Type.Direction = XFER_WRITE; break;
+	  case DMA_FROM_DEVICE: cp->Request.Type.Direction = XFER_READ; break;
+	  case DMA_NONE: cp->Request.Type.Direction = XFER_NONE; break;
+	  case DMA_BIDIRECTIONAL:
 		// This can happen if a buggy application does a scsi passthru
 		// and sets both inlen and outlen to non-zero. ( see
 		// ../scsi/scsi_ioctl.c:scsi_ioctl_send_command() )
diff -Nru a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c
--- a/drivers/block/cfq-iosched.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/block/cfq-iosched.c	2004-12-24 13:37:01 -08:00
@@ -22,96 +22,211 @@
 #include <linux/rbtree.h>
 #include <linux/mempool.h>
 
+static unsigned long max_elapsed_crq;
+static unsigned long max_elapsed_dispatch;
+
 /*
  * tunables
  */
-static int cfq_quantum = 4;
-static int cfq_queued = 8;
+static int cfq_quantum = 4;		/* max queue in one round of service */
+static int cfq_queued = 8;		/* minimum rq allocate limit per-queue*/
+static int cfq_service = HZ;		/* period over which service is avg */
+static int cfq_fifo_expire_r = HZ / 2;	/* fifo timeout for sync requests */
+static int cfq_fifo_expire_w = 5 * HZ;	/* fifo timeout for async requests */
+static int cfq_fifo_rate = HZ / 8;	/* fifo expiry rate */
+static int cfq_back_max = 16 * 1024;	/* maximum backwards seek, in KiB */
+static int cfq_back_penalty = 2;	/* penalty of a backwards seek */
 
+/*
+ * for the hash of cfqq inside the cfqd
+ */
 #define CFQ_QHASH_SHIFT		6
 #define CFQ_QHASH_ENTRIES	(1 << CFQ_QHASH_SHIFT)
-#define list_entry_qhash(entry)	list_entry((entry), struct cfq_queue, cfq_hash)
+#define list_entry_qhash(entry)	hlist_entry((entry), struct cfq_queue, cfq_hash)
 
-#define CFQ_MHASH_SHIFT		8
+/*
+ * for the hash of crq inside the cfqq
+ */
+#define CFQ_MHASH_SHIFT		6
 #define CFQ_MHASH_BLOCK(sec)	((sec) >> 3)
 #define CFQ_MHASH_ENTRIES	(1 << CFQ_MHASH_SHIFT)
-#define CFQ_MHASH_FN(sec)	(hash_long(CFQ_MHASH_BLOCK((sec)),CFQ_MHASH_SHIFT))
-#define ON_MHASH(crq)		!list_empty(&(crq)->hash)
+#define CFQ_MHASH_FN(sec)	hash_long(CFQ_MHASH_BLOCK(sec), CFQ_MHASH_SHIFT)
 #define rq_hash_key(rq)		((rq)->sector + (rq)->nr_sectors)
-#define list_entry_hash(ptr)	list_entry((ptr), struct cfq_rq, hash)
+#define list_entry_hash(ptr)	hlist_entry((ptr), struct cfq_rq, hash)
 
 #define list_entry_cfqq(ptr)	list_entry((ptr), struct cfq_queue, cfq_list)
 
-#define RQ_DATA(rq)		((struct cfq_rq *) (rq)->elevator_private)
+#define RQ_DATA(rq)		(rq)->elevator_private
+
+/*
+ * rb-tree defines
+ */
+#define RB_NONE			(2)
+#define RB_EMPTY(node)		((node)->rb_node == NULL)
+#define RB_CLEAR_COLOR(node)	(node)->rb_color = RB_NONE
+#define RB_CLEAR(node)		do {	\
+	(node)->rb_parent = NULL;	\
+	RB_CLEAR_COLOR((node));		\
+	(node)->rb_right = NULL;	\
+	(node)->rb_left = NULL;		\
+} while (0)
+#define RB_CLEAR_ROOT(root)	((root)->rb_node = NULL)
+#define ON_RB(node)		((node)->rb_color != RB_NONE)
+#define rb_entry_crq(node)	rb_entry((node), struct cfq_rq, rb_node)
+#define rq_rb_key(rq)		(rq)->sector
+
+/*
+ * threshold for switching off non-tag accounting
+ */
+#define CFQ_MAX_TAG		(4)
+
+/*
+ * sort key types and names
+ */
+enum {
+	CFQ_KEY_PGID,
+	CFQ_KEY_TGID,
+	CFQ_KEY_UID,
+	CFQ_KEY_GID,
+	CFQ_KEY_LAST,
+};
+
+static char *cfq_key_types[] = { "pgid", "tgid", "uid", "gid", NULL };
 
 static kmem_cache_t *crq_pool;
 static kmem_cache_t *cfq_pool;
-static mempool_t *cfq_mpool;
+static kmem_cache_t *cfq_ioc_pool;
 
 struct cfq_data {
 	struct list_head rr_list;
-	struct list_head *dispatch;
-	struct list_head *cfq_hash;
+	struct list_head empty_list;
 
-	struct list_head *crq_hash;
+	struct hlist_head *cfq_hash;
+	struct hlist_head *crq_hash;
 
+	/* queues on rr_list (ie they have pending requests */
 	unsigned int busy_queues;
+
 	unsigned int max_queued;
 
+	atomic_t ref;
+
+	int key_type;
+
 	mempool_t *crq_pool;
 
 	request_queue_t *queue;
 
+	sector_t last_sector;
+
+	int rq_in_driver;
+
 	/*
-	 * tunables
+	 * tunables, see top of file
 	 */
 	unsigned int cfq_quantum;
 	unsigned int cfq_queued;
+	unsigned int cfq_fifo_expire_r;
+	unsigned int cfq_fifo_expire_w;
+	unsigned int cfq_fifo_batch_expire;
+	unsigned int cfq_back_penalty;
+	unsigned int cfq_back_max;
+	unsigned int find_best_crq;
+
+	unsigned int cfq_tagged;
 };
 
 struct cfq_queue {
-	struct list_head cfq_hash;
+	/* reference count */
+	atomic_t ref;
+	/* parent cfq_data */
+	struct cfq_data *cfqd;
+	/* hash of mergeable requests */
+	struct hlist_node cfq_hash;
+	/* hash key */
+	unsigned long key;
+	/* whether queue is on rr (or empty) list */
+	int on_rr;
+	/* on either rr or empty list of cfqd */
 	struct list_head cfq_list;
+	/* sorted list of pending requests */
 	struct rb_root sort_list;
-	int pid;
+	/* if fifo isn't expired, next request to serve */
+	struct cfq_rq *next_crq;
+	/* requests queued in sort_list */
 	int queued[2];
-#if 0
-	/*
-	 * with a simple addition like this, we can do io priorities. almost.
-	 * does need a split request free list, too.
-	 */
-	int io_prio
-#endif
+	/* currently allocated requests */
+	int allocated[2];
+	/* fifo list of requests in sort_list */
+	struct list_head fifo[2];
+	/* last time fifo expired */
+	unsigned long last_fifo_expire;
+
+	int key_type;
+
+	unsigned long service_start;
+	unsigned long service_used;
+
+	unsigned int max_rate;
+
+	/* number of requests that have been handed to the driver */
+	int in_flight;
+	/* number of currently allocated requests */
+	int alloc_limit[2];
 };
 
 struct cfq_rq {
 	struct rb_node rb_node;
 	sector_t rb_key;
-
 	struct request *request;
+	struct hlist_node hash;
 
 	struct cfq_queue *cfq_queue;
+	struct cfq_io_context *io_context;
+
+	unsigned long service_start;
+	unsigned long queue_start;
 
-	struct list_head hash;
+	unsigned int in_flight : 1;
+	unsigned int accounted : 1;
+	unsigned int is_sync   : 1;
+	unsigned int is_write  : 1;
 };
 
-static void cfq_put_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq);
-static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *cfqd, int pid);
-static void cfq_dispatch_sort(struct cfq_data *cfqd, struct cfq_queue *cfqq,
-			      struct cfq_rq *crq);
+static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned long);
+static void cfq_dispatch_sort(request_queue_t *, struct cfq_rq *);
+static void cfq_update_next_crq(struct cfq_rq *);
+static void cfq_put_cfqd(struct cfq_data *cfqd);
 
 /*
- * lots of deadline iosched dupes, can be abstracted later...
+ * what the fairness is based on (ie how processes are grouped and
+ * differentiated)
  */
-static inline void __cfq_del_crq_hash(struct cfq_rq *crq)
+static inline unsigned long
+cfq_hash_key(struct cfq_data *cfqd, struct task_struct *tsk)
 {
-	list_del_init(&crq->hash);
+	/*
+	 * optimize this so that ->key_type is the offset into the struct
+	 */
+	switch (cfqd->key_type) {
+		case CFQ_KEY_PGID:
+			return process_group(tsk);
+		default:
+		case CFQ_KEY_TGID:
+			return tsk->tgid;
+		case CFQ_KEY_UID:
+			return tsk->uid;
+		case CFQ_KEY_GID:
+			return tsk->gid;
+	}
 }
 
+/*
+ * lots of deadline iosched dupes, can be abstracted later...
+ */
 static inline void cfq_del_crq_hash(struct cfq_rq *crq)
 {
-	if (ON_MHASH(crq))
-		__cfq_del_crq_hash(crq);
+	hlist_del_init(&crq->hash);
 }
 
 static void cfq_remove_merge_hints(request_queue_t *q, struct cfq_rq *crq)
@@ -120,32 +235,32 @@
 
 	if (q->last_merge == crq->request)
 		q->last_merge = NULL;
+
+	cfq_update_next_crq(crq);
 }
 
 static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq)
 {
-	struct request *rq = crq->request;
+	const int hash_idx = CFQ_MHASH_FN(rq_hash_key(crq->request));
 
-	BUG_ON(ON_MHASH(crq));
+	BUG_ON(!hlist_unhashed(&crq->hash));
 
-	list_add(&crq->hash, &cfqd->crq_hash[CFQ_MHASH_FN(rq_hash_key(rq))]);
+	hlist_add_head(&crq->hash, &cfqd->crq_hash[hash_idx]);
 }
 
 static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset)
 {
-	struct list_head *hash_list = &cfqd->crq_hash[CFQ_MHASH_FN(offset)];
-	struct list_head *entry, *next = hash_list->next;
+	struct hlist_head *hash_list = &cfqd->crq_hash[CFQ_MHASH_FN(offset)];
+	struct hlist_node *entry, *next;
 
-	while ((entry = next) != hash_list) {
+	hlist_for_each_safe(entry, next, hash_list) {
 		struct cfq_rq *crq = list_entry_hash(entry);
 		struct request *__rq = crq->request;
 
-		next = entry->next;
-
-		BUG_ON(!ON_MHASH(crq));
+		BUG_ON(hlist_unhashed(&crq->hash));
 
 		if (!rq_mergeable(__rq)) {
-			__cfq_del_crq_hash(crq);
+			cfq_del_crq_hash(crq);
 			continue;
 		}
 
@@ -157,29 +272,257 @@
 }
 
 /*
- * rb tree support functions
+ * Lifted from AS - choose which of crq1 and crq2 that is best served now.
+ * We choose the request that is closest to the head right now. Distance
+ * behind the head are penalized and only allowed to a certain extent.
  */
-#define RB_NONE		(2)
-#define RB_EMPTY(node)	((node)->rb_node == NULL)
-#define RB_CLEAR(node)	((node)->rb_color = RB_NONE)
-#define RB_CLEAR_ROOT(root)	((root)->rb_node = NULL)
-#define ON_RB(node)	((node)->rb_color != RB_NONE)
-#define rb_entry_crq(node)	rb_entry((node), struct cfq_rq, rb_node)
-#define rq_rb_key(rq)		(rq)->sector
+static struct cfq_rq *
+cfq_choose_req(struct cfq_data *cfqd, struct cfq_rq *crq1, struct cfq_rq *crq2)
+{
+	sector_t last, s1, s2, d1 = 0, d2 = 0;
+	int r1_wrap = 0, r2_wrap = 0;	/* requests are behind the disk head */
+	unsigned long back_max;
 
-static inline void cfq_del_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
+	if (crq1 == NULL || crq1 == crq2)
+		return crq2;
+	if (crq2 == NULL)
+		return crq1;
+
+	s1 = crq1->request->sector;
+	s2 = crq2->request->sector;
+
+	last = cfqd->last_sector;
+
+#if 0
+	if (!list_empty(&cfqd->queue->queue_head)) {
+		struct list_head *entry = &cfqd->queue->queue_head;
+		unsigned long distance = ~0UL;
+		struct request *rq;
+
+		while ((entry = entry->prev) != &cfqd->queue->queue_head) {
+			rq = list_entry_rq(entry);
+
+			if (blk_barrier_rq(rq))
+				break;
+
+			if (distance < abs(s1 - rq->sector + rq->nr_sectors)) {
+				distance = abs(s1 - rq->sector +rq->nr_sectors);
+				last = rq->sector + rq->nr_sectors;
+			}
+			if (distance < abs(s2 - rq->sector + rq->nr_sectors)) {
+				distance = abs(s2 - rq->sector +rq->nr_sectors);
+				last = rq->sector + rq->nr_sectors;
+			}
+		}
+	}
+#endif
+
+	/*
+	 * by definition, 1KiB is 2 sectors
+	 */
+	back_max = cfqd->cfq_back_max * 2;
+
+	/*
+	 * Strict one way elevator _except_ in the case where we allow
+	 * short backward seeks which are biased as twice the cost of a
+	 * similar forward seek.
+	 */
+	if (s1 >= last)
+		d1 = s1 - last;
+	else if (s1 + back_max >= last)
+		d1 = (last - s1) * cfqd->cfq_back_penalty;
+	else
+		r1_wrap = 1;
+
+	if (s2 >= last)
+		d2 = s2 - last;
+	else if (s2 + back_max >= last)
+		d2 = (last - s2) * cfqd->cfq_back_penalty;
+	else
+		r2_wrap = 1;
+
+	/* Found required data */
+	if (!r1_wrap && r2_wrap)
+		return crq1;
+	else if (!r2_wrap && r1_wrap)
+		return crq2;
+	else if (r1_wrap && r2_wrap) {
+		/* both behind the head */
+		if (s1 <= s2)
+			return crq1;
+		else
+			return crq2;
+	}
+
+	/* Both requests in front of the head */
+	if (d1 < d2)
+		return crq1;
+	else if (d2 < d1)
+		return crq2;
+	else {
+		if (s1 >= s2)
+			return crq1;
+		else
+			return crq2;
+	}
+}
+
+/*
+ * would be nice to take fifo expire time into account as well
+ */
+static struct cfq_rq *
+cfq_find_next_crq(struct cfq_data *cfqd, struct cfq_queue *cfqq,
+		  struct cfq_rq *last)
+{
+	struct cfq_rq *crq_next = NULL, *crq_prev = NULL;
+	struct rb_node *rbnext, *rbprev;
+
+	if (!ON_RB(&last->rb_node))
+		return NULL;
+
+	if ((rbnext = rb_next(&last->rb_node)) == NULL)
+		rbnext = rb_first(&cfqq->sort_list);
+
+	rbprev = rb_prev(&last->rb_node);
+
+	if (rbprev)
+		crq_prev = rb_entry_crq(rbprev);
+	if (rbnext)
+		crq_next = rb_entry_crq(rbnext);
+
+	return cfq_choose_req(cfqd, crq_next, crq_prev);
+}
+
+static void cfq_update_next_crq(struct cfq_rq *crq)
 {
+	struct cfq_queue *cfqq = crq->cfq_queue;
+
+	if (cfqq->next_crq == crq)
+		cfqq->next_crq = cfq_find_next_crq(cfqq->cfqd, cfqq, crq);
+}
+
+static int cfq_check_sort_rr_list(struct cfq_queue *cfqq)
+{
+	struct list_head *head = &cfqq->cfqd->rr_list;
+	struct list_head *next, *prev;
+
+	/*
+	 * list might still be ordered
+	 */
+	next = cfqq->cfq_list.next;
+	if (next != head) {
+		struct cfq_queue *cnext = list_entry_cfqq(next);
+
+		if (cfqq->service_used > cnext->service_used)
+			return 1;
+	}
+
+	prev = cfqq->cfq_list.prev;
+	if (prev != head) {
+		struct cfq_queue *cprev = list_entry_cfqq(prev);
+
+		if (cfqq->service_used < cprev->service_used)
+			return 1;
+	}
+
+	return 0;
+}
+
+static void cfq_sort_rr_list(struct cfq_queue *cfqq, int new_queue)
+{
+	struct list_head *entry = &cfqq->cfqd->rr_list;
+
+	if (!cfqq->on_rr)
+		return;
+	if (!new_queue && !cfq_check_sort_rr_list(cfqq))
+		return;
+
+	list_del(&cfqq->cfq_list);
+
+	/*
+	 * sort by our mean service_used, sub-sort by in-flight requests
+	 */
+	while ((entry = entry->prev) != &cfqq->cfqd->rr_list) {
+		struct cfq_queue *__cfqq = list_entry_cfqq(entry);
+
+		if (cfqq->service_used > __cfqq->service_used)
+			break;
+		else if (cfqq->service_used == __cfqq->service_used) {
+			struct list_head *prv;
+
+			while ((prv = entry->prev) != &cfqq->cfqd->rr_list) {
+				__cfqq = list_entry_cfqq(prv);
+
+				WARN_ON(__cfqq->service_used > cfqq->service_used);
+				if (cfqq->service_used != __cfqq->service_used)
+					break;
+				if (cfqq->in_flight > __cfqq->in_flight)
+					break;
+
+				entry = prv;
+			}
+		}
+	}
+
+	list_add(&cfqq->cfq_list, entry);
+}
+
+/*
+ * add to busy list of queues for service, trying to be fair in ordering
+ * the pending list according to requests serviced
+ */
+static inline void
+cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+{
+	/*
+	 * it's currently on the empty list
+	 */
+	cfqq->on_rr = 1;
+	cfqd->busy_queues++;
+
+	if (time_after(jiffies, cfqq->service_start + cfq_service))
+		cfqq->service_used >>= 3;
+
+	cfq_sort_rr_list(cfqq, 1);
+}
+
+static inline void
+cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+{
+	list_move(&cfqq->cfq_list, &cfqd->empty_list);
+	cfqq->on_rr = 0;
+
+	BUG_ON(!cfqd->busy_queues);
+	cfqd->busy_queues--;
+}
+
+/*
+ * rb tree support functions
+ */
+static inline void cfq_del_crq_rb(struct cfq_rq *crq)
+{
+	struct cfq_queue *cfqq = crq->cfq_queue;
+
 	if (ON_RB(&crq->rb_node)) {
-		cfqq->queued[rq_data_dir(crq->request)]--;
+		struct cfq_data *cfqd = cfqq->cfqd;
+
+		BUG_ON(!cfqq->queued[crq->is_sync]);
+
+		cfq_update_next_crq(crq);
+
+		cfqq->queued[crq->is_sync]--;
 		rb_erase(&crq->rb_node, &cfqq->sort_list);
-		crq->cfq_queue = NULL;
+		RB_CLEAR_COLOR(&crq->rb_node);
+
+		if (RB_EMPTY(&cfqq->sort_list) && cfqq->on_rr)
+			cfq_del_cfqq_rr(cfqd, cfqq);
 	}
 }
 
 static struct cfq_rq *
-__cfq_add_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
+__cfq_add_crq_rb(struct cfq_rq *crq)
 {
-	struct rb_node **p = &cfqq->sort_list.rb_node;
+	struct rb_node **p = &crq->cfq_queue->sort_list.rb_node;
 	struct rb_node *parent = NULL;
 	struct cfq_rq *__crq;
 
@@ -199,30 +542,50 @@
 	return NULL;
 }
 
-static void
-cfq_add_crq_rb(struct cfq_data *cfqd, struct cfq_queue *cfqq,struct cfq_rq *crq)
+static void cfq_add_crq_rb(struct cfq_rq *crq)
 {
+	struct cfq_queue *cfqq = crq->cfq_queue;
+	struct cfq_data *cfqd = cfqq->cfqd;
 	struct request *rq = crq->request;
 	struct cfq_rq *__alias;
 
 	crq->rb_key = rq_rb_key(rq);
-	cfqq->queued[rq_data_dir(rq)]++;
-retry:
-	__alias = __cfq_add_crq_rb(cfqq, crq);
-	if (!__alias) {
-		rb_insert_color(&crq->rb_node, &cfqq->sort_list);
-		crq->cfq_queue = cfqq;
-		return;
+	cfqq->queued[crq->is_sync]++;
+
+	/*
+	 * looks a little odd, but the first insert might return an alias.
+	 * if that happens, put the alias on the dispatch list
+	 */
+	while ((__alias = __cfq_add_crq_rb(crq)) != NULL)
+		cfq_dispatch_sort(cfqd->queue, __alias);
+
+	rb_insert_color(&crq->rb_node, &cfqq->sort_list);
+
+	if (!cfqq->on_rr)
+		cfq_add_cfqq_rr(cfqd, cfqq);
+
+	/*
+	 * check if this request is a better next-serve candidate
+	 */
+	cfqq->next_crq = cfq_choose_req(cfqd, cfqq->next_crq, crq);
+}
+
+static inline void
+cfq_reposition_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
+{
+	if (ON_RB(&crq->rb_node)) {
+		rb_erase(&crq->rb_node, &cfqq->sort_list);
+		cfqq->queued[crq->is_sync]--;
 	}
 
-	cfq_dispatch_sort(cfqd, cfqq, __alias);
-	goto retry;
+	cfq_add_crq_rb(crq);
 }
 
 static struct request *
 cfq_find_rq_rb(struct cfq_data *cfqd, sector_t sector)
 {
-	struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, current->tgid);
+	const unsigned long key = cfq_hash_key(cfqd, current);
+	struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, key);
 	struct rb_node *n;
 
 	if (!cfqq)
@@ -244,30 +607,44 @@
 	return NULL;
 }
 
-static void cfq_remove_request(request_queue_t *q, struct request *rq)
+/*
+ * make sure the service time gets corrected on reissue of this request
+ */
+static void cfq_requeue_request(request_queue_t *q, struct request *rq)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
 	struct cfq_rq *crq = RQ_DATA(rq);
 
 	if (crq) {
 		struct cfq_queue *cfqq = crq->cfq_queue;
 
+		if (cfqq->cfqd->cfq_tagged) {
+			cfqq->service_used--;
+			cfq_sort_rr_list(cfqq, 0);
+		}
+
+		crq->accounted = 0;
+		cfqq->cfqd->rq_in_driver--;
+	}
+	list_add(&rq->queuelist, &q->queue_head);
+}
+
+static void cfq_remove_request(request_queue_t *q, struct request *rq)
+{
+	struct cfq_rq *crq = RQ_DATA(rq);
+
+	if (crq) {
 		cfq_remove_merge_hints(q, crq);
 		list_del_init(&rq->queuelist);
 
-		if (cfqq) {
-			cfq_del_crq_rb(cfqq, crq);
-
-			if (RB_EMPTY(&cfqq->sort_list))
-				cfq_put_queue(cfqd, cfqq);
-		}
+		if (crq->cfq_queue)
+			cfq_del_crq_rb(crq);
 	}
 }
 
 static int
 cfq_merge(request_queue_t *q, struct request **req, struct bio *bio)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct request *__rq;
 	int ret;
 
@@ -305,7 +682,7 @@
 
 static void cfq_merged_request(request_queue_t *q, struct request *req)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct cfq_rq *crq = RQ_DATA(req);
 
 	cfq_del_crq_hash(crq);
@@ -314,234 +691,570 @@
 	if (ON_RB(&crq->rb_node) && (rq_rb_key(req) != crq->rb_key)) {
 		struct cfq_queue *cfqq = crq->cfq_queue;
 
-		cfq_del_crq_rb(cfqq, crq);
-		cfq_add_crq_rb(cfqd, cfqq, crq);
+		cfq_update_next_crq(crq);
+		cfq_reposition_crq_rb(cfqq, crq);
 	}
 
 	q->last_merge = req;
 }
 
 static void
-cfq_merged_requests(request_queue_t *q, struct request *req,
+cfq_merged_requests(request_queue_t *q, struct request *rq,
 		    struct request *next)
 {
-	cfq_merged_request(q, req);
+	struct cfq_rq *crq = RQ_DATA(rq);
+	struct cfq_rq *cnext = RQ_DATA(next);
+
+	cfq_merged_request(q, rq);
+
+	if (!list_empty(&rq->queuelist) && !list_empty(&next->queuelist)) {
+		if (time_before(cnext->queue_start, crq->queue_start)) {
+			list_move(&rq->queuelist, &next->queuelist);
+			crq->queue_start = cnext->queue_start;
+		}
+	}
+
+	cfq_update_next_crq(cnext);
 	cfq_remove_request(q, next);
 }
 
-static void
-cfq_dispatch_sort(struct cfq_data *cfqd, struct cfq_queue *cfqq,
-		  struct cfq_rq *crq)
+/*
+ * we dispatch cfqd->cfq_quantum requests in total from the rr_list queues,
+ * this function sector sorts the selected request to minimize seeks. we start
+ * at cfqd->last_sector, not 0.
+ */
+static void cfq_dispatch_sort(request_queue_t *q, struct cfq_rq *crq)
 {
-	struct list_head *head = cfqd->dispatch, *entry = head;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
+	struct cfq_queue *cfqq = crq->cfq_queue;
+	struct list_head *head = &q->queue_head, *entry = head;
 	struct request *__rq;
+	sector_t last;
 
-	cfq_del_crq_rb(cfqq, crq);
-	cfq_remove_merge_hints(cfqd->queue, crq);
+	cfq_del_crq_rb(crq);
+	cfq_remove_merge_hints(q, crq);
+	list_del(&crq->request->queuelist);
+
+	last = cfqd->last_sector;
+	while ((entry = entry->prev) != head) {
+		__rq = list_entry_rq(entry);
 
-	if (!list_empty(head)) {
-		__rq = list_entry_rq(head->next);
+		if (blk_barrier_rq(crq->request))
+			break;
+		if (!blk_fs_request(crq->request))
+			break;
 
-		if (crq->request->sector < __rq->sector) {
-			entry = head->prev;
-			goto link;
+		if (crq->request->sector > __rq->sector)
+			break;
+		if (__rq->sector > last && crq->request->sector < last) {
+			last = crq->request->sector;
+			break;
 		}
 	}
 
-	while ((entry = entry->prev) != head) {
-		__rq = list_entry_rq(entry);
+	cfqd->last_sector = last;
+	crq->in_flight = 1;
+	cfqq->in_flight++;
+	list_add(&crq->request->queuelist, entry);
+}
 
-		if (crq->request->sector <= __rq->sector)
-			break;
+/*
+ * return expired entry, or NULL to just start from scratch in rbtree
+ */
+static inline struct cfq_rq *cfq_check_fifo(struct cfq_queue *cfqq)
+{
+	struct cfq_data *cfqd = cfqq->cfqd;
+	const int reads = !list_empty(&cfqq->fifo[0]);
+	const int writes = !list_empty(&cfqq->fifo[1]);
+	unsigned long now = jiffies;
+	struct cfq_rq *crq;
+
+	if (time_before(now, cfqq->last_fifo_expire + cfqd->cfq_fifo_batch_expire))
+		return NULL;
+
+	crq = RQ_DATA(list_entry(cfqq->fifo[0].next, struct request, queuelist));
+	if (reads && time_after(now, crq->queue_start + cfqd->cfq_fifo_expire_r)) {
+		cfqq->last_fifo_expire = now;
+		return crq;
 	}
 
-link:
-	list_add_tail(&crq->request->queuelist, entry);
+	crq = RQ_DATA(list_entry(cfqq->fifo[1].next, struct request, queuelist));
+	if (writes && time_after(now, crq->queue_start + cfqd->cfq_fifo_expire_w)) {
+		cfqq->last_fifo_expire = now;
+		return crq;
+	}
+
+	return NULL;
 }
 
+/*
+ * dispatch a single request from given queue
+ */
 static inline void
-__cfq_dispatch_requests(request_queue_t *q, struct cfq_data *cfqd,
-			struct cfq_queue *cfqq)
+cfq_dispatch_request(request_queue_t *q, struct cfq_data *cfqd,
+		     struct cfq_queue *cfqq)
 {
-	struct cfq_rq *crq = rb_entry_crq(rb_first(&cfqq->sort_list));
+	struct cfq_rq *crq;
 
-	cfq_dispatch_sort(cfqd, cfqq, crq);
+	/*
+	 * follow expired path, else get first next available
+	 */
+	if ((crq = cfq_check_fifo(cfqq)) == NULL) {
+		if (cfqd->find_best_crq)
+			crq = cfqq->next_crq;
+		else
+			crq = rb_entry_crq(rb_first(&cfqq->sort_list));
+	}
+
+	cfqd->last_sector = crq->request->sector + crq->request->nr_sectors;
+
+	/*
+	 * finally, insert request into driver list
+	 */
+	cfq_dispatch_sort(q, crq);
 }
 
-static int cfq_dispatch_requests(request_queue_t *q, struct cfq_data *cfqd)
+static int cfq_dispatch_requests(request_queue_t *q, int max_dispatch)
 {
+	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct cfq_queue *cfqq;
 	struct list_head *entry, *tmp;
-	int ret, queued, good_queues;
+	int queued, busy_queues, first_round;
 
 	if (list_empty(&cfqd->rr_list))
 		return 0;
 
-	queued = ret = 0;
+	queued = 0;
+	first_round = 1;
 restart:
-	good_queues = 0;
+	busy_queues = 0;
 	list_for_each_safe(entry, tmp, &cfqd->rr_list) {
-		cfqq = list_entry_cfqq(cfqd->rr_list.next);
+		cfqq = list_entry_cfqq(entry);
 
 		BUG_ON(RB_EMPTY(&cfqq->sort_list));
 
-		__cfq_dispatch_requests(q, cfqd, cfqq);
+		/*
+		 * first round of queueing, only select from queues that
+		 * don't already have io in-flight
+		 */
+		if (first_round && cfqq->in_flight)
+			continue;
 
-		if (RB_EMPTY(&cfqq->sort_list))
-			cfq_put_queue(cfqd, cfqq);
-		else
-			good_queues++;
+		cfq_dispatch_request(q, cfqd, cfqq);
+
+		if (!RB_EMPTY(&cfqq->sort_list))
+			busy_queues++;
 
 		queued++;
-		ret = 1;
 	}
 
-	if ((queued < cfqd->cfq_quantum) && good_queues)
+	if ((queued < max_dispatch) && (busy_queues || first_round)) {
+		first_round = 0;
 		goto restart;
+	}
 
-	return ret;
+	return queued;
+}
+
+static inline void cfq_account_dispatch(struct cfq_rq *crq)
+{
+	struct cfq_queue *cfqq = crq->cfq_queue;
+	struct cfq_data *cfqd = cfqq->cfqd;
+	unsigned long now, elapsed;
+
+	if (!blk_fs_request(crq->request))
+		return;
+
+	/*
+	 * accounted bit is necessary since some drivers will call
+	 * elv_next_request() many times for the same request (eg ide)
+	 */
+	if (crq->accounted)
+		return;
+
+	now = jiffies;
+	if (cfqq->service_start == ~0UL)
+		cfqq->service_start = now;
+
+	/*
+	 * on drives with tagged command queueing, command turn-around time
+	 * doesn't necessarily reflect the time spent processing this very
+	 * command inside the drive. so do the accounting differently there,
+	 * by just sorting on the number of requests
+	 */
+	if (cfqd->cfq_tagged) {
+		if (time_after(now, cfqq->service_start + cfq_service)) {
+			cfqq->service_start = now;
+			cfqq->service_used /= 10;
+		}
+
+		cfqq->service_used++;
+		cfq_sort_rr_list(cfqq, 0);
+	}
+
+	elapsed = now - crq->queue_start;
+	if (elapsed > max_elapsed_dispatch)
+		max_elapsed_dispatch = elapsed;
+
+	crq->accounted = 1;
+	crq->service_start = now;
+
+	if (++cfqd->rq_in_driver >= CFQ_MAX_TAG && !cfqd->cfq_tagged) {
+		cfqq->cfqd->cfq_tagged = 1;
+		printk("cfq: depth %d reached, tagging now on\n", CFQ_MAX_TAG);
+	}
+}
+
+static inline void
+cfq_account_completion(struct cfq_queue *cfqq, struct cfq_rq *crq)
+{
+	struct cfq_data *cfqd = cfqq->cfqd;
+
+	if (!crq->accounted)
+		return;
+
+	WARN_ON(!cfqd->rq_in_driver);
+	cfqd->rq_in_driver--;
+
+	if (!cfqd->cfq_tagged) {
+		unsigned long now = jiffies;
+		unsigned long duration = now - crq->service_start;
+
+		if (time_after(now, cfqq->service_start + cfq_service)) {
+			cfqq->service_start = now;
+			cfqq->service_used >>= 3;
+		}
+
+		cfqq->service_used += duration;
+		cfq_sort_rr_list(cfqq, 0);
+
+		if (duration > max_elapsed_crq)
+			max_elapsed_crq = duration;
+	}
 }
 
 static struct request *cfq_next_request(request_queue_t *q)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct request *rq;
 
-	if (!list_empty(cfqd->dispatch)) {
+	if (!list_empty(&q->queue_head)) {
 		struct cfq_rq *crq;
 dispatch:
-		rq = list_entry_rq(cfqd->dispatch->next);
+		rq = list_entry_rq(q->queue_head.next);
 
-		crq = RQ_DATA(rq);
-		if (crq)
+		if ((crq = RQ_DATA(rq)) != NULL) {
 			cfq_remove_merge_hints(q, crq);
+			cfq_account_dispatch(crq);
+		}
 
 		return rq;
 	}
 
-	if (cfq_dispatch_requests(q, cfqd))
+	if (cfq_dispatch_requests(q, cfqd->cfq_quantum))
 		goto dispatch;
 
 	return NULL;
 }
 
+/*
+ * task holds one reference to the queue, dropped when task exits. each crq
+ * in-flight on this queue also holds a reference, dropped when crq is freed.
+ *
+ * queue lock must be held here.
+ */
+static void cfq_put_queue(struct cfq_queue *cfqq)
+{
+	BUG_ON(!atomic_read(&cfqq->ref));
+
+	if (!atomic_dec_and_test(&cfqq->ref))
+		return;
+
+	BUG_ON(rb_first(&cfqq->sort_list));
+	BUG_ON(cfqq->on_rr);
+
+	cfq_put_cfqd(cfqq->cfqd);
+
+	/*
+	 * it's on the empty list and still hashed
+	 */
+	list_del(&cfqq->cfq_list);
+	hlist_del(&cfqq->cfq_hash);
+	kmem_cache_free(cfq_pool, cfqq);
+}
+
 static inline struct cfq_queue *
-__cfq_find_cfq_hash(struct cfq_data *cfqd, int pid, const int hashval)
+__cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned long key, const int hashval)
 {
-	struct list_head *hash_list = &cfqd->cfq_hash[hashval];
-	struct list_head *entry;
+	struct hlist_head *hash_list = &cfqd->cfq_hash[hashval];
+	struct hlist_node *entry, *next;
 
-	list_for_each(entry, hash_list) {
+	hlist_for_each_safe(entry, next, hash_list) {
 		struct cfq_queue *__cfqq = list_entry_qhash(entry);
 
-		if (__cfqq->pid == pid)
+		if (__cfqq->key == key)
 			return __cfqq;
 	}
 
 	return NULL;
 }
 
-static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *cfqd, int pid)
+static struct cfq_queue *
+cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned long key)
 {
-	const int hashval = hash_long(current->tgid, CFQ_QHASH_SHIFT);
+	return __cfq_find_cfq_hash(cfqd, key, hash_long(key, CFQ_QHASH_SHIFT));
+}
 
-	return __cfq_find_cfq_hash(cfqd, pid, hashval);
+static inline void
+cfq_rehash_cfqq(struct cfq_data *cfqd, struct cfq_queue **cfqq,
+		struct cfq_io_context *cic)
+{
+	unsigned long hashkey = cfq_hash_key(cfqd, current);
+	unsigned long hashval = hash_long(hashkey, CFQ_QHASH_SHIFT);
+	struct cfq_queue *__cfqq;
+	unsigned long flags;
+
+	spin_lock_irqsave(cfqd->queue->queue_lock, flags);
+
+	hlist_del(&(*cfqq)->cfq_hash);
+
+	__cfqq = __cfq_find_cfq_hash(cfqd, hashkey, hashval);
+	if (!__cfqq || __cfqq == *cfqq) {
+		__cfqq = *cfqq;
+		hlist_add_head(&__cfqq->cfq_hash, &cfqd->cfq_hash[hashval]);
+		__cfqq->key_type = cfqd->key_type;
+	} else {
+		atomic_inc(&__cfqq->ref);
+		cic->cfqq = __cfqq;
+		cfq_put_queue(*cfqq);
+		*cfqq = __cfqq;
+	}
+
+	cic->cfqq = __cfqq;
+	spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
 }
 
-static void cfq_put_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+static void cfq_free_io_context(struct cfq_io_context *cic)
 {
-	cfqd->busy_queues--;
-	list_del(&cfqq->cfq_list);
-	list_del(&cfqq->cfq_hash);
-	mempool_free(cfqq, cfq_mpool);
+	kmem_cache_free(cfq_ioc_pool, cic);
 }
 
-static struct cfq_queue *__cfq_get_queue(struct cfq_data *cfqd, int pid,
-					 int gfp_mask)
+/*
+ * locking hierarchy is: io_context lock -> queue locks
+ */
+static void cfq_exit_io_context(struct cfq_io_context *cic)
+{
+	struct cfq_queue *cfqq = cic->cfqq;
+	struct list_head *entry = &cic->list;
+	request_queue_t *q;
+	unsigned long flags;
+
+	/*
+	 * put the reference this task is holding to the various queues
+	 */
+	spin_lock_irqsave(&cic->ioc->lock, flags);
+	while ((entry = cic->list.next) != &cic->list) {
+		struct cfq_io_context *__cic;
+
+		__cic = list_entry(entry, struct cfq_io_context, list);
+		list_del(entry);
+
+		q = __cic->cfqq->cfqd->queue;
+		spin_lock(q->queue_lock);
+		cfq_put_queue(__cic->cfqq);
+		spin_unlock(q->queue_lock);
+	}
+
+	q = cfqq->cfqd->queue;
+	spin_lock(q->queue_lock);
+	cfq_put_queue(cfqq);
+	spin_unlock(q->queue_lock);
+
+	cic->cfqq = NULL;
+	spin_unlock_irqrestore(&cic->ioc->lock, flags);
+}
+
+static struct cfq_io_context *cfq_alloc_io_context(int gfp_flags)
+{
+	struct cfq_io_context *cic = kmem_cache_alloc(cfq_ioc_pool, gfp_flags);
+
+	if (cic) {
+		cic->dtor = cfq_free_io_context;
+		cic->exit = cfq_exit_io_context;
+		INIT_LIST_HEAD(&cic->list);
+		cic->cfqq = NULL;
+	}
+
+	return cic;
+}
+
+/*
+ * Setup general io context and cfq io context. There can be several cfq
+ * io contexts per general io context, if this process is doing io to more
+ * than one device managed by cfq. Note that caller is holding a reference to
+ * cfqq, so we don't need to worry about it disappearing
+ */
+static struct cfq_io_context *
+cfq_get_io_context(struct cfq_queue **cfqq, int gfp_flags)
 {
-	const int hashval = hash_long(current->tgid, CFQ_QHASH_SHIFT);
+	struct cfq_data *cfqd = (*cfqq)->cfqd;
+	struct cfq_queue *__cfqq = *cfqq;
+	struct cfq_io_context *cic;
+	struct io_context *ioc;
+
+	might_sleep_if(gfp_flags & __GFP_WAIT);
+
+	ioc = get_io_context(gfp_flags);
+	if (!ioc)
+		return NULL;
+
+	if ((cic = ioc->cic) == NULL) {
+		cic = cfq_alloc_io_context(gfp_flags);
+
+		if (cic == NULL)
+			goto err;
+
+		ioc->cic = cic;
+		cic->ioc = ioc;
+		cic->cfqq = __cfqq;
+		atomic_inc(&__cfqq->ref);
+	} else {
+		struct cfq_io_context *__cic;
+		unsigned long flags;
+
+		/*
+		 * since the first cic on the list is actually the head
+		 * itself, need to check this here or we'll duplicate an
+		 * cic per ioc for no reason
+		 */
+		if (cic->cfqq == __cfqq)
+			goto out;
+
+		/*
+		 * cic exists, check if we already are there. linear search
+		 * should be ok here, the list will usually not be more than
+		 * 1 or a few entries long
+		 */
+		spin_lock_irqsave(&ioc->lock, flags);
+		list_for_each_entry(__cic, &cic->list, list) {
+			/*
+			 * this process is already holding a reference to
+			 * this queue, so no need to get one more
+			 */
+			if (__cic->cfqq == __cfqq) {
+				cic = __cic;
+				spin_unlock_irqrestore(&ioc->lock, flags);
+				goto out;
+			}
+		}
+		spin_unlock_irqrestore(&ioc->lock, flags);
+
+		/*
+		 * nope, process doesn't have a cic assoicated with this
+		 * cfqq yet. get a new one and add to list
+		 */
+		__cic = cfq_alloc_io_context(gfp_flags);
+		if (__cic == NULL)
+			goto err;
+
+		__cic->ioc = ioc;
+		__cic->cfqq = __cfqq;
+		atomic_inc(&__cfqq->ref);
+		spin_lock_irqsave(&ioc->lock, flags);
+		list_add(&__cic->list, &cic->list);
+		spin_unlock_irqrestore(&ioc->lock, flags);
+
+		cic = __cic;
+		*cfqq = __cfqq;
+	}
+
+out:
+	/*
+	 * if key_type has been changed on the fly, we lazily rehash
+	 * each queue at lookup time
+	 */
+	if ((*cfqq)->key_type != cfqd->key_type)
+		cfq_rehash_cfqq(cfqd, cfqq, cic);
+
+	return cic;
+err:
+	put_io_context(ioc);
+	return NULL;
+}
+
+static struct cfq_queue *
+__cfq_get_queue(struct cfq_data *cfqd, unsigned long key, int gfp_mask)
+{
+	const int hashval = hash_long(key, CFQ_QHASH_SHIFT);
 	struct cfq_queue *cfqq, *new_cfqq = NULL;
-	request_queue_t *q = cfqd->queue;
 
 retry:
-	cfqq = __cfq_find_cfq_hash(cfqd, pid, hashval);
+	cfqq = __cfq_find_cfq_hash(cfqd, key, hashval);
 
 	if (!cfqq) {
 		if (new_cfqq) {
 			cfqq = new_cfqq;
 			new_cfqq = NULL;
 		} else if (gfp_mask & __GFP_WAIT) {
-			spin_unlock_irq(q->queue_lock);
-			new_cfqq = mempool_alloc(cfq_mpool, gfp_mask);
-			spin_lock_irq(q->queue_lock);
+			spin_unlock_irq(cfqd->queue->queue_lock);
+			new_cfqq = kmem_cache_alloc(cfq_pool, gfp_mask);
+			spin_lock_irq(cfqd->queue->queue_lock);
 			goto retry;
 		} else
-			return NULL;
+			goto out;
 
-		INIT_LIST_HEAD(&cfqq->cfq_hash);
+		memset(cfqq, 0, sizeof(*cfqq));
+
+		INIT_HLIST_NODE(&cfqq->cfq_hash);
 		INIT_LIST_HEAD(&cfqq->cfq_list);
 		RB_CLEAR_ROOT(&cfqq->sort_list);
+		INIT_LIST_HEAD(&cfqq->fifo[0]);
+		INIT_LIST_HEAD(&cfqq->fifo[1]);
 
-		cfqq->pid = pid;
-		cfqq->queued[0] = cfqq->queued[1] = 0;
-		list_add(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]);
+		cfqq->key = key;
+		hlist_add_head(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]);
+		atomic_set(&cfqq->ref, 0);
+		cfqq->cfqd = cfqd;
+		atomic_inc(&cfqd->ref);
+		cfqq->key_type = cfqd->key_type;
+		cfqq->service_start = ~0UL;
 	}
 
 	if (new_cfqq)
-		mempool_free(new_cfqq, cfq_mpool);
-
-	return cfqq;
-}
-
-static struct cfq_queue *cfq_get_queue(struct cfq_data *cfqd, int pid,
-				       int gfp_mask)
-{
-	request_queue_t *q = cfqd->queue;
-	struct cfq_queue *cfqq;
-
-	spin_lock_irq(q->queue_lock);
-	cfqq = __cfq_get_queue(cfqd, pid, gfp_mask);
-	spin_unlock_irq(q->queue_lock);
+		kmem_cache_free(cfq_pool, new_cfqq);
 
+	atomic_inc(&cfqq->ref);
+out:
+	WARN_ON((gfp_mask & __GFP_WAIT) && !cfqq);
 	return cfqq;
 }
 
 static void cfq_enqueue(struct cfq_data *cfqd, struct cfq_rq *crq)
 {
-	struct cfq_queue *cfqq;
+	crq->is_sync = 0;
+	if (rq_data_dir(crq->request) == READ || current->flags & PF_SYNCWRITE)
+		crq->is_sync = 1;
 
-	cfqq = __cfq_get_queue(cfqd, current->tgid, GFP_ATOMIC);
-	if (cfqq) {
-		cfq_add_crq_rb(cfqd, cfqq, crq);
+	cfq_add_crq_rb(crq);
+	crq->queue_start = jiffies;
 
-		if (list_empty(&cfqq->cfq_list)) {
-			list_add(&cfqq->cfq_list, &cfqd->rr_list);
-			cfqd->busy_queues++;
-		}
-	} else {
-		/*
-		 * should can only happen if the request wasn't allocated
-		 * through blk_alloc_request(), eg stack requests from ide-cd
-		 * (those should be removed) _and_ we are in OOM.
-		 */
-		list_add_tail(&crq->request->queuelist, cfqd->dispatch);
-	}
+	list_add_tail(&crq->request->queuelist, &crq->cfq_queue->fifo[crq->is_sync]);
 }
 
 static void
 cfq_insert_request(request_queue_t *q, struct request *rq, int where)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct cfq_rq *crq = RQ_DATA(rq);
 
 	switch (where) {
 		case ELEVATOR_INSERT_BACK:
-			while (cfq_dispatch_requests(q, cfqd))
+			while (cfq_dispatch_requests(q, cfqd->cfq_quantum))
 				;
-			list_add_tail(&rq->queuelist, cfqd->dispatch);
+			list_add_tail(&rq->queuelist, &q->queue_head);
 			break;
 		case ELEVATOR_INSERT_FRONT:
-			list_add(&rq->queuelist, cfqd->dispatch);
+			list_add(&rq->queuelist, &q->queue_head);
 			break;
 		case ELEVATOR_INSERT_SORT:
 			BUG_ON(!blk_fs_request(rq));
@@ -562,12 +1275,27 @@
 
 static int cfq_queue_empty(request_queue_t *q)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
 
-	if (list_empty(cfqd->dispatch) && list_empty(&cfqd->rr_list))
-		return 1;
+	return list_empty(&q->queue_head) && list_empty(&cfqd->rr_list);
+}
+
+static void cfq_completed_request(request_queue_t *q, struct request *rq)
+{
+	struct cfq_rq *crq = RQ_DATA(rq);
+
+	if (unlikely(!blk_fs_request(rq)))
+		return;
+
+	if (crq->in_flight) {
+		struct cfq_queue *cfqq = crq->cfq_queue;
+
+		WARN_ON(!cfqq->in_flight);
+		cfqq->in_flight--;
+
+		cfq_account_completion(cfqq, crq);
+	}
 
-	return 0;
 }
 
 static struct request *
@@ -596,101 +1324,171 @@
 
 static int cfq_may_queue(request_queue_t *q, int rw)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct cfq_queue *cfqq;
-	int ret = 1;
+	int ret = ELV_MQUEUE_MAY;
 
-	if (!cfqd->busy_queues)
-		goto out;
+	if (current->flags & PF_MEMALLOC)
+		return ELV_MQUEUE_MAY;
 
-	cfqq = cfq_find_cfq_hash(cfqd, current->tgid);
+	cfqq = cfq_find_cfq_hash(cfqd, cfq_hash_key(cfqd, current));
 	if (cfqq) {
-		int limit = (q->nr_requests - cfqd->cfq_queued) / cfqd->busy_queues;
+		int limit = cfqd->max_queued;
 
-		if (limit < 3)
-			limit = 3;
+		if (cfqq->allocated[rw] < cfqd->cfq_queued)
+			return ELV_MQUEUE_MUST;
+
+		if (cfqd->busy_queues)
+			limit = q->nr_requests / cfqd->busy_queues;
+
+		if (limit < cfqd->cfq_queued)
+			limit = cfqd->cfq_queued;
 		else if (limit > cfqd->max_queued)
 			limit = cfqd->max_queued;
 
-		if (cfqq->queued[rw] > limit)
-			ret = 0;
+		if (cfqq->allocated[rw] >= limit) {
+			if (limit > cfqq->alloc_limit[rw])
+				cfqq->alloc_limit[rw] = limit;
+
+			ret = ELV_MQUEUE_NO;
+		}
 	}
-out:
+
 	return ret;
 }
 
+static void cfq_check_waiters(request_queue_t *q, struct cfq_queue *cfqq)
+{
+	struct request_list *rl = &q->rq;
+	const int write = waitqueue_active(&rl->wait[WRITE]);
+	const int read = waitqueue_active(&rl->wait[READ]);
+
+	if (read && cfqq->allocated[READ] < cfqq->alloc_limit[READ])
+		wake_up(&rl->wait[READ]);
+	if (write && cfqq->allocated[WRITE] < cfqq->alloc_limit[WRITE])
+		wake_up(&rl->wait[WRITE]);
+}
+
+/*
+ * queue lock held here
+ */
 static void cfq_put_request(request_queue_t *q, struct request *rq)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct cfq_rq *crq = RQ_DATA(rq);
-	struct request_list *rl;
-	int other_rw;
 
 	if (crq) {
+		struct cfq_queue *cfqq = crq->cfq_queue;
+
 		BUG_ON(q->last_merge == rq);
-		BUG_ON(ON_MHASH(crq));
+		BUG_ON(!hlist_unhashed(&crq->hash));
+
+		if (crq->io_context)
+			put_io_context(crq->io_context->ioc);
+
+		BUG_ON(!cfqq->allocated[crq->is_write]);
+		cfqq->allocated[crq->is_write]--;
 
 		mempool_free(crq, cfqd->crq_pool);
 		rq->elevator_private = NULL;
-	}
 
-	/*
-	 * work-around for may_queue "bug": if a read gets issued and refused
-	 * to queue because writes ate all the allowed slots and no other
-	 * reads are pending for this queue, it could get stuck infinitely
-	 * since freed_request() only checks the waitqueue for writes when
-	 * freeing them. or vice versa for a single write vs many reads.
-	 * so check here whether "the other" data direction might be able
-	 * to queue and wake them
-	 */
-	rl = &q->rq;
-	other_rw = rq_data_dir(rq) ^ 1;
-	if (rl->count[other_rw] <= q->nr_requests) {
 		smp_mb();
-		if (waitqueue_active(&rl->wait[other_rw]))
-			wake_up(&rl->wait[other_rw]);
+		cfq_check_waiters(q, cfqq);
+		cfq_put_queue(cfqq);
 	}
 }
 
+/*
+ * Allocate cfq data structures associated with this request. A queue and
+ */
 static int cfq_set_request(request_queue_t *q, struct request *rq, int gfp_mask)
 {
-	struct cfq_data *cfqd = q->elevator.elevator_data;
-	struct cfq_queue *cfqq;
+	struct cfq_data *cfqd = q->elevator->elevator_data;
+	struct cfq_io_context *cic;
+	const int rw = rq_data_dir(rq);
+	struct cfq_queue *cfqq, *saved_cfqq;
 	struct cfq_rq *crq;
+	unsigned long flags;
+
+	might_sleep_if(gfp_mask & __GFP_WAIT);
+
+	spin_lock_irqsave(q->queue_lock, flags);
+
+	cfqq = __cfq_get_queue(cfqd, cfq_hash_key(cfqd, current), gfp_mask);
+	if (!cfqq)
+		goto out_lock;
+
+repeat:
+	if (cfqq->allocated[rw] >= cfqd->max_queued)
+		goto out_lock;
+
+	cfqq->allocated[rw]++;
+	spin_unlock_irqrestore(q->queue_lock, flags);
 
 	/*
-	 * prepare a queue up front, so cfq_enqueue() doesn't have to
+	 * if hashing type has changed, the cfq_queue might change here.
 	 */
-	cfqq = cfq_get_queue(cfqd, current->tgid, gfp_mask);
-	if (!cfqq)
-		return 1;
+	saved_cfqq = cfqq;
+	cic = cfq_get_io_context(&cfqq, gfp_mask);
+	if (!cic)
+		goto err;
+
+	/*
+	 * repeat allocation checks on queue change
+	 */
+	if (unlikely(saved_cfqq != cfqq)) {
+		spin_lock_irqsave(q->queue_lock, flags);
+		saved_cfqq->allocated[rw]--;
+		goto repeat;
+	}
 
 	crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
 	if (crq) {
-		memset(crq, 0, sizeof(*crq));
 		RB_CLEAR(&crq->rb_node);
+		crq->rb_key = 0;
 		crq->request = rq;
-		crq->cfq_queue = NULL;
-		INIT_LIST_HEAD(&crq->hash);
+		INIT_HLIST_NODE(&crq->hash);
+		crq->cfq_queue = cfqq;
+		crq->io_context = cic;
+		crq->service_start = crq->queue_start = 0;
+		crq->in_flight = crq->accounted = crq->is_sync = 0;
+		crq->is_write = rw;
 		rq->elevator_private = crq;
+		cfqq->alloc_limit[rw] = 0;
 		return 0;
 	}
 
+	put_io_context(cic->ioc);
+err:
+	spin_lock_irqsave(q->queue_lock, flags);
+	cfqq->allocated[rw]--;
+	cfq_put_queue(cfqq);
+out_lock:
+	spin_unlock_irqrestore(q->queue_lock, flags);
 	return 1;
 }
 
-static void cfq_exit(request_queue_t *q, elevator_t *e)
+static void cfq_put_cfqd(struct cfq_data *cfqd)
 {
-	struct cfq_data *cfqd = e->elevator_data;
+	request_queue_t *q = cfqd->queue;
+
+	if (!atomic_dec_and_test(&cfqd->ref))
+		return;
+
+	blk_put_queue(q);
 
-	e->elevator_data = NULL;
 	mempool_destroy(cfqd->crq_pool);
 	kfree(cfqd->crq_hash);
 	kfree(cfqd->cfq_hash);
 	kfree(cfqd);
 }
 
-static int cfq_init(request_queue_t *q, elevator_t *e)
+static void cfq_exit_queue(elevator_t *e)
+{
+	cfq_put_cfqd(e->elevator_data);
+}
+
+static int cfq_init_queue(request_queue_t *q, elevator_t *e)
 {
 	struct cfq_data *cfqd;
 	int i;
@@ -701,12 +1499,13 @@
 
 	memset(cfqd, 0, sizeof(*cfqd));
 	INIT_LIST_HEAD(&cfqd->rr_list);
+	INIT_LIST_HEAD(&cfqd->empty_list);
 
-	cfqd->crq_hash = kmalloc(sizeof(struct list_head) * CFQ_MHASH_ENTRIES, GFP_KERNEL);
+	cfqd->crq_hash = kmalloc(sizeof(struct hlist_head) * CFQ_MHASH_ENTRIES, GFP_KERNEL);
 	if (!cfqd->crq_hash)
 		goto out_crqhash;
 
-	cfqd->cfq_hash = kmalloc(sizeof(struct list_head) * CFQ_QHASH_ENTRIES, GFP_KERNEL);
+	cfqd->cfq_hash = kmalloc(sizeof(struct hlist_head) * CFQ_QHASH_ENTRIES, GFP_KERNEL);
 	if (!cfqd->cfq_hash)
 		goto out_cfqhash;
 
@@ -715,23 +1514,33 @@
 		goto out_crqpool;
 
 	for (i = 0; i < CFQ_MHASH_ENTRIES; i++)
-		INIT_LIST_HEAD(&cfqd->crq_hash[i]);
+		INIT_HLIST_HEAD(&cfqd->crq_hash[i]);
 	for (i = 0; i < CFQ_QHASH_ENTRIES; i++)
-		INIT_LIST_HEAD(&cfqd->cfq_hash[i]);
+		INIT_HLIST_HEAD(&cfqd->cfq_hash[i]);
 
-	cfqd->dispatch = &q->queue_head;
 	e->elevator_data = cfqd;
+
 	cfqd->queue = q;
+	atomic_inc(&q->refcnt);
 
 	/*
 	 * just set it to some high value, we want anyone to be able to queue
 	 * some requests. fairness is handled differently
 	 */
-	cfqd->max_queued = q->nr_requests;
-	q->nr_requests = 8192;
+	q->nr_requests = 1024;
+	cfqd->max_queued = q->nr_requests / 16;
+	q->nr_batching = cfq_queued;
+	cfqd->key_type = CFQ_KEY_TGID;
+	cfqd->find_best_crq = 1;
+	atomic_set(&cfqd->ref, 1);
 
 	cfqd->cfq_queued = cfq_queued;
 	cfqd->cfq_quantum = cfq_quantum;
+	cfqd->cfq_fifo_expire_r = cfq_fifo_expire_r;
+	cfqd->cfq_fifo_expire_w = cfq_fifo_expire_w;
+	cfqd->cfq_fifo_batch_expire = cfq_fifo_rate;
+	cfqd->cfq_back_max = cfq_back_max;
+	cfqd->cfq_back_penalty = cfq_back_penalty;
 
 	return 0;
 out_crqpool:
@@ -743,29 +1552,39 @@
 	return -ENOMEM;
 }
 
+static void cfq_slab_kill(void)
+{
+	if (crq_pool)
+		kmem_cache_destroy(crq_pool);
+	if (cfq_pool)
+		kmem_cache_destroy(cfq_pool);
+	if (cfq_ioc_pool)
+		kmem_cache_destroy(cfq_ioc_pool);
+}
+
 static int __init cfq_slab_setup(void)
 {
 	crq_pool = kmem_cache_create("crq_pool", sizeof(struct cfq_rq), 0, 0,
 					NULL, NULL);
-
 	if (!crq_pool)
-		panic("cfq_iosched: can't init crq pool\n");
+		goto fail;
 
 	cfq_pool = kmem_cache_create("cfq_pool", sizeof(struct cfq_queue), 0, 0,
 					NULL, NULL);
-
 	if (!cfq_pool)
-		panic("cfq_iosched: can't init cfq pool\n");
+		goto fail;
 
-	cfq_mpool = mempool_create(64, mempool_alloc_slab, mempool_free_slab, cfq_pool);
-
-	if (!cfq_mpool)
-		panic("cfq_iosched: can't init cfq mpool\n");
+	cfq_ioc_pool = kmem_cache_create("cfq_ioc_pool",
+			sizeof(struct cfq_io_context), 0, 0, NULL, NULL);
+	if (!cfq_ioc_pool)
+		goto fail;
 
 	return 0;
+fail:
+	cfq_slab_kill();
+	return -ENOMEM;
 }
 
-subsys_initcall(cfq_slab_setup);
 
 /*
  * sysfs parts below -->
@@ -791,27 +1610,86 @@
 	return count;
 }
 
-#define SHOW_FUNCTION(__FUNC, __VAR)					\
+static ssize_t
+cfq_clear_elapsed(struct cfq_data *cfqd, const char *page, size_t count)
+{
+	max_elapsed_dispatch = max_elapsed_crq = 0;
+	return count;
+}
+
+static ssize_t
+cfq_set_key_type(struct cfq_data *cfqd, const char *page, size_t count)
+{
+	spin_lock_irq(cfqd->queue->queue_lock);
+	if (!strncmp(page, "pgid", 4))
+		cfqd->key_type = CFQ_KEY_PGID;
+	else if (!strncmp(page, "tgid", 4))
+		cfqd->key_type = CFQ_KEY_TGID;
+	else if (!strncmp(page, "uid", 3))
+		cfqd->key_type = CFQ_KEY_UID;
+	else if (!strncmp(page, "gid", 3))
+		cfqd->key_type = CFQ_KEY_GID;
+	spin_unlock_irq(cfqd->queue->queue_lock);
+	return count;
+}
+
+static ssize_t
+cfq_read_key_type(struct cfq_data *cfqd, char *page)
+{
+	ssize_t len = 0;
+	int i;
+
+	for (i = CFQ_KEY_PGID; i < CFQ_KEY_LAST; i++) {
+		if (cfqd->key_type == i)
+			len += sprintf(page+len, "[%s] ", cfq_key_types[i]);
+		else
+			len += sprintf(page+len, "%s ", cfq_key_types[i]);
+	}
+	len += sprintf(page+len, "\n");
+	return len;
+}
+
+#define SHOW_FUNCTION(__FUNC, __VAR, __CONV)				\
 static ssize_t __FUNC(struct cfq_data *cfqd, char *page)		\
 {									\
-	return cfq_var_show(__VAR, (page));				\
-}
-SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum);
-SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued);
+	unsigned int __data = __VAR;					\
+	if (__CONV)							\
+		__data = jiffies_to_msecs(__data);			\
+	return cfq_var_show(__data, (page));				\
+}
+SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum, 0);
+SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued, 0);
+SHOW_FUNCTION(cfq_fifo_expire_r_show, cfqd->cfq_fifo_expire_r, 1);
+SHOW_FUNCTION(cfq_fifo_expire_w_show, cfqd->cfq_fifo_expire_w, 1);
+SHOW_FUNCTION(cfq_fifo_batch_expire_show, cfqd->cfq_fifo_batch_expire, 1);
+SHOW_FUNCTION(cfq_find_best_show, cfqd->find_best_crq, 0);
+SHOW_FUNCTION(cfq_back_max_show, cfqd->cfq_back_max, 0);
+SHOW_FUNCTION(cfq_back_penalty_show, cfqd->cfq_back_penalty, 0);
 #undef SHOW_FUNCTION
 
-#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX)				\
+#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV)			\
 static ssize_t __FUNC(struct cfq_data *cfqd, const char *page, size_t count)	\
 {									\
-	int ret = cfq_var_store(__PTR, (page), count);			\
-	if (*(__PTR) < (MIN))						\
-		*(__PTR) = (MIN);					\
-	else if (*(__PTR) > (MAX))					\
-		*(__PTR) = (MAX);					\
+	unsigned int __data;						\
+	int ret = cfq_var_store(&__data, (page), count);		\
+	if (__data < (MIN))						\
+		__data = (MIN);						\
+	else if (__data > (MAX))					\
+		__data = (MAX);						\
+	if (__CONV)							\
+		*(__PTR) = msecs_to_jiffies(__data);			\
+	else								\
+		*(__PTR) = __data;					\
 	return ret;							\
 }
-STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, INT_MAX);
-STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, INT_MAX);
+STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0);
+STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, UINT_MAX, 0);
+STORE_FUNCTION(cfq_fifo_expire_r_store, &cfqd->cfq_fifo_expire_r, 1, UINT_MAX, 1);
+STORE_FUNCTION(cfq_fifo_expire_w_store, &cfqd->cfq_fifo_expire_w, 1, UINT_MAX, 1);
+STORE_FUNCTION(cfq_fifo_batch_expire_store, &cfqd->cfq_fifo_batch_expire, 0, UINT_MAX, 1);
+STORE_FUNCTION(cfq_find_best_store, &cfqd->find_best_crq, 0, 1, 0);
+STORE_FUNCTION(cfq_back_max_store, &cfqd->cfq_back_max, 0, UINT_MAX, 0);
+STORE_FUNCTION(cfq_back_penalty_store, &cfqd->cfq_back_penalty, 1, UINT_MAX, 0);
 #undef STORE_FUNCTION
 
 static struct cfq_fs_entry cfq_quantum_entry = {
@@ -824,10 +1702,57 @@
 	.show = cfq_queued_show,
 	.store = cfq_queued_store,
 };
+static struct cfq_fs_entry cfq_fifo_expire_r_entry = {
+	.attr = {.name = "fifo_expire_sync", .mode = S_IRUGO | S_IWUSR },
+	.show = cfq_fifo_expire_r_show,
+	.store = cfq_fifo_expire_r_store,
+};
+static struct cfq_fs_entry cfq_fifo_expire_w_entry = {
+	.attr = {.name = "fifo_expire_async", .mode = S_IRUGO | S_IWUSR },
+	.show = cfq_fifo_expire_w_show,
+	.store = cfq_fifo_expire_w_store,
+};
+static struct cfq_fs_entry cfq_fifo_batch_expire_entry = {
+	.attr = {.name = "fifo_batch_expire", .mode = S_IRUGO | S_IWUSR },
+	.show = cfq_fifo_batch_expire_show,
+	.store = cfq_fifo_batch_expire_store,
+};
+static struct cfq_fs_entry cfq_find_best_entry = {
+	.attr = {.name = "find_best_crq", .mode = S_IRUGO | S_IWUSR },
+	.show = cfq_find_best_show,
+	.store = cfq_find_best_store,
+};
+static struct cfq_fs_entry cfq_back_max_entry = {
+	.attr = {.name = "back_seek_max", .mode = S_IRUGO | S_IWUSR },
+	.show = cfq_back_max_show,
+	.store = cfq_back_max_store,
+};
+static struct cfq_fs_entry cfq_back_penalty_entry = {
+	.attr = {.name = "back_seek_penalty", .mode = S_IRUGO | S_IWUSR },
+	.show = cfq_back_penalty_show,
+	.store = cfq_back_penalty_store,
+};
+static struct cfq_fs_entry cfq_clear_elapsed_entry = {
+	.attr = {.name = "clear_elapsed", .mode = S_IWUSR },
+	.store = cfq_clear_elapsed,
+};
+static struct cfq_fs_entry cfq_key_type_entry = {
+	.attr = {.name = "key_type", .mode = S_IRUGO | S_IWUSR },
+	.show = cfq_read_key_type,
+	.store = cfq_set_key_type,
+};
 
 static struct attribute *default_attrs[] = {
 	&cfq_quantum_entry.attr,
 	&cfq_queued_entry.attr,
+	&cfq_fifo_expire_r_entry.attr,
+	&cfq_fifo_expire_w_entry.attr,
+	&cfq_fifo_batch_expire_entry.attr,
+	&cfq_key_type_entry.attr,
+	&cfq_find_best_entry.attr,
+	&cfq_back_max_entry.attr,
+	&cfq_back_penalty_entry.attr,
+	&cfq_clear_elapsed_entry.attr,
 	NULL,
 };
 
@@ -868,23 +1793,56 @@
 	.default_attrs	= default_attrs,
 };
 
-elevator_t iosched_cfq = {
-	.elevator_name =		"cfq",
-	.elevator_ktype =		&cfq_ktype,
-	.elevator_merge_fn = 		cfq_merge,
-	.elevator_merged_fn =		cfq_merged_request,
-	.elevator_merge_req_fn =	cfq_merged_requests,
-	.elevator_next_req_fn =		cfq_next_request,
-	.elevator_add_req_fn =		cfq_insert_request,
-	.elevator_remove_req_fn =	cfq_remove_request,
-	.elevator_queue_empty_fn =	cfq_queue_empty,
-	.elevator_former_req_fn =	cfq_former_request,
-	.elevator_latter_req_fn =	cfq_latter_request,
-	.elevator_set_req_fn =		cfq_set_request,
-	.elevator_put_req_fn =		cfq_put_request,
-	.elevator_may_queue_fn =	cfq_may_queue,
-	.elevator_init_fn =		cfq_init,
-	.elevator_exit_fn =		cfq_exit,
+static struct elevator_type iosched_cfq = {
+	.ops = {
+		.elevator_merge_fn = 		cfq_merge,
+		.elevator_merged_fn =		cfq_merged_request,
+		.elevator_merge_req_fn =	cfq_merged_requests,
+		.elevator_next_req_fn =		cfq_next_request,
+		.elevator_add_req_fn =		cfq_insert_request,
+		.elevator_remove_req_fn =	cfq_remove_request,
+		.elevator_requeue_req_fn =	cfq_requeue_request,
+		.elevator_queue_empty_fn =	cfq_queue_empty,
+		.elevator_completed_req_fn =	cfq_completed_request,
+		.elevator_former_req_fn =	cfq_former_request,
+		.elevator_latter_req_fn =	cfq_latter_request,
+		.elevator_set_req_fn =		cfq_set_request,
+		.elevator_put_req_fn =		cfq_put_request,
+		.elevator_may_queue_fn =	cfq_may_queue,
+		.elevator_init_fn =		cfq_init_queue,
+		.elevator_exit_fn =		cfq_exit_queue,
+	},
+	.elevator_ktype =	&cfq_ktype,
+	.elevator_name =	"cfq",
+	.elevator_owner =	THIS_MODULE,
 };
 
-EXPORT_SYMBOL(iosched_cfq);
+int cfq_init(void)
+{
+	int ret;
+
+	if (cfq_slab_setup())
+		return -ENOMEM;
+
+	ret = elv_register(&iosched_cfq);
+	if (!ret) {
+		__module_get(THIS_MODULE);
+		return 0;
+	}
+
+	cfq_slab_kill();
+	return ret;
+}
+
+static void __exit cfq_exit(void)
+{
+	cfq_slab_kill();
+	elv_unregister(&iosched_cfq);
+}
+
+module_init(cfq_init);
+module_exit(cfq_exit);
+
+MODULE_AUTHOR("Jens Axboe");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Completely Fair Queueing IO scheduler");
diff -Nru a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
--- a/drivers/block/cpqarray.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/block/cpqarray.c	2004-12-24 13:36:18 -08:00
@@ -21,7 +21,6 @@
  */
 #include <linux/config.h>	/* CONFIG_PROC_FS */
 #include <linux/module.h>
-#include <linux/version.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/bio.h>
@@ -569,9 +568,9 @@
 
 	/* detect controllers */
 	printk(DRIVER_NAME "\n");
-/* TODO: If it's an eisa only system, will rc return negative? */
+
 	rc = pci_register_driver(&cpqarray_pci_driver);
-	if (rc < 0)
+	if (rc)
 		return rc;
 	cpqarray_eisa_detect();
 	
@@ -732,7 +731,6 @@
 }
 
 #ifndef MODULE
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
 /*
  * Config string is a comma separated set of i/o addresses of EISA cards.
  */
@@ -749,18 +747,6 @@
 
 __setup("smart2=", cpqarray_setup);
 
-#else
-
-/*
- * Copy the contents of the ints[] array passed to us by init.
- */
-void cpqarray_setup(char *str, int *ints)
-{
-	int i;
-	for(i=0; i<ints[0] && i<8; i++)
-		eisa[i] = ints[i+1];
-}
-#endif
 #endif
 
 /*
diff -Nru a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c
--- a/drivers/block/deadline-iosched.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/block/deadline-iosched.c	2004-12-24 13:37:18 -08:00
@@ -289,7 +289,7 @@
 static inline void
 deadline_add_request(struct request_queue *q, struct request *rq)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 	struct deadline_rq *drq = RQ_DATA(rq);
 
 	const int data_dir = rq_data_dir(drq->request);
@@ -317,7 +317,7 @@
 	struct deadline_rq *drq = RQ_DATA(rq);
 
 	if (drq) {
-		struct deadline_data *dd = q->elevator.elevator_data;
+		struct deadline_data *dd = q->elevator->elevator_data;
 
 		list_del_init(&drq->fifo);
 		deadline_remove_merge_hints(q, drq);
@@ -328,7 +328,7 @@
 static int
 deadline_merge(request_queue_t *q, struct request **req, struct bio *bio)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 	struct request *__rq;
 	int ret;
 
@@ -383,7 +383,7 @@
 
 static void deadline_merged_request(request_queue_t *q, struct request *req)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 	struct deadline_rq *drq = RQ_DATA(req);
 
 	/*
@@ -407,7 +407,7 @@
 deadline_merged_requests(request_queue_t *q, struct request *req,
 			 struct request *next)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 	struct deadline_rq *drq = RQ_DATA(req);
 	struct deadline_rq *dnext = RQ_DATA(next);
 
@@ -604,7 +604,7 @@
 
 static struct request *deadline_next_request(request_queue_t *q)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 	struct request *rq;
 
 	/*
@@ -625,7 +625,7 @@
 static void
 deadline_insert_request(request_queue_t *q, struct request *rq, int where)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 
 	/* barriers must flush the reorder queue */
 	if (unlikely(rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)
@@ -653,7 +653,7 @@
 
 static int deadline_queue_empty(request_queue_t *q)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 
 	if (!list_empty(&dd->fifo_list[WRITE])
 	    || !list_empty(&dd->fifo_list[READ])
@@ -687,7 +687,7 @@
 	return NULL;
 }
 
-static void deadline_exit(request_queue_t *q, elevator_t *e)
+static void deadline_exit_queue(elevator_t *e)
 {
 	struct deadline_data *dd = e->elevator_data;
 
@@ -703,7 +703,7 @@
  * initialize elevator private data (deadline_data), and alloc a drq for
  * each request on the free lists
  */
-static int deadline_init(request_queue_t *q, elevator_t *e)
+static int deadline_init_queue(request_queue_t *q, elevator_t *e)
 {
 	struct deadline_data *dd;
 	int i;
@@ -748,7 +748,7 @@
 
 static void deadline_put_request(request_queue_t *q, struct request *rq)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 	struct deadline_rq *drq = RQ_DATA(rq);
 
 	if (drq) {
@@ -760,7 +760,7 @@
 static int
 deadline_set_request(request_queue_t *q, struct request *rq, int gfp_mask)
 {
-	struct deadline_data *dd = q->elevator.elevator_data;
+	struct deadline_data *dd = q->elevator->elevator_data;
 	struct deadline_rq *drq;
 
 	drq = mempool_alloc(dd->drq_pool, gfp_mask);
@@ -805,33 +805,41 @@
 	return count;
 }
 
-#define SHOW_FUNCTION(__FUNC, __VAR)					\
+#define SHOW_FUNCTION(__FUNC, __VAR, __CONV)				\
 static ssize_t __FUNC(struct deadline_data *dd, char *page)		\
 {									\
-	return deadline_var_show(__VAR, (page));			\
-}
-SHOW_FUNCTION(deadline_readexpire_show, dd->fifo_expire[READ]);
-SHOW_FUNCTION(deadline_writeexpire_show, dd->fifo_expire[WRITE]);
-SHOW_FUNCTION(deadline_writesstarved_show, dd->writes_starved);
-SHOW_FUNCTION(deadline_frontmerges_show, dd->front_merges);
-SHOW_FUNCTION(deadline_fifobatch_show, dd->fifo_batch);
+	unsigned int __data = __VAR;					\
+	if (__CONV)							\
+		__data = jiffies_to_msecs(__data);			\
+	return deadline_var_show(__data, (page));			\
+}
+SHOW_FUNCTION(deadline_readexpire_show, dd->fifo_expire[READ], 1);
+SHOW_FUNCTION(deadline_writeexpire_show, dd->fifo_expire[WRITE], 1);
+SHOW_FUNCTION(deadline_writesstarved_show, dd->writes_starved, 0);
+SHOW_FUNCTION(deadline_frontmerges_show, dd->front_merges, 0);
+SHOW_FUNCTION(deadline_fifobatch_show, dd->fifo_batch, 0);
 #undef SHOW_FUNCTION
 
-#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX)				\
+#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV)			\
 static ssize_t __FUNC(struct deadline_data *dd, const char *page, size_t count)	\
 {									\
-	int ret = deadline_var_store(__PTR, (page), count);		\
-	if (*(__PTR) < (MIN))						\
-		*(__PTR) = (MIN);					\
-	else if (*(__PTR) > (MAX))					\
-		*(__PTR) = (MAX);					\
+	unsigned int __data;						\
+	int ret = deadline_var_store(&__data, (page), count);		\
+	if (__data < (MIN))						\
+		__data = (MIN);						\
+	else if (__data > (MAX))					\
+		__data = (MAX);						\
+	if (__CONV)							\
+		*(__PTR) = msecs_to_jiffies(__data);			\
+	else								\
+		*(__PTR) = __data;					\
 	return ret;							\
 }
-STORE_FUNCTION(deadline_readexpire_store, &dd->fifo_expire[READ], 0, INT_MAX);
-STORE_FUNCTION(deadline_writeexpire_store, &dd->fifo_expire[WRITE], 0, INT_MAX);
-STORE_FUNCTION(deadline_writesstarved_store, &dd->writes_starved, INT_MIN, INT_MAX);
-STORE_FUNCTION(deadline_frontmerges_store, &dd->front_merges, 0, 1);
-STORE_FUNCTION(deadline_fifobatch_store, &dd->fifo_batch, 0, INT_MAX);
+STORE_FUNCTION(deadline_readexpire_store, &dd->fifo_expire[READ], 0, INT_MAX, 1);
+STORE_FUNCTION(deadline_writeexpire_store, &dd->fifo_expire[WRITE], 0, INT_MAX, 1);
+STORE_FUNCTION(deadline_writesstarved_store, &dd->writes_starved, INT_MIN, INT_MAX, 0);
+STORE_FUNCTION(deadline_frontmerges_store, &dd->front_merges, 0, 1, 0);
+STORE_FUNCTION(deadline_fifobatch_store, &dd->fifo_batch, 0, INT_MAX, 0);
 #undef STORE_FUNCTION
 
 static struct deadline_fs_entry deadline_readexpire_entry = {
@@ -906,36 +914,54 @@
 	.default_attrs	= default_attrs,
 };
 
-static int __init deadline_slab_setup(void)
+static struct elevator_type iosched_deadline = {
+	.ops = {
+		.elevator_merge_fn = 		deadline_merge,
+		.elevator_merged_fn =		deadline_merged_request,
+		.elevator_merge_req_fn =	deadline_merged_requests,
+		.elevator_next_req_fn =		deadline_next_request,
+		.elevator_add_req_fn =		deadline_insert_request,
+		.elevator_remove_req_fn =	deadline_remove_request,
+		.elevator_queue_empty_fn =	deadline_queue_empty,
+		.elevator_former_req_fn =	deadline_former_request,
+		.elevator_latter_req_fn =	deadline_latter_request,
+		.elevator_set_req_fn =		deadline_set_request,
+		.elevator_put_req_fn = 		deadline_put_request,
+		.elevator_init_fn =		deadline_init_queue,
+		.elevator_exit_fn =		deadline_exit_queue,
+	},
+
+	.elevator_ktype = &deadline_ktype,
+	.elevator_name = "deadline",
+	.elevator_owner = THIS_MODULE,
+};
+
+static int __init deadline_init(void)
 {
+	int ret;
+
 	drq_pool = kmem_cache_create("deadline_drq", sizeof(struct deadline_rq),
 				     0, 0, NULL, NULL);
 
 	if (!drq_pool)
-		panic("deadline: can't init slab pool\n");
+		return -ENOMEM;
 
-	return 0;
-}
+	ret = elv_register(&iosched_deadline);
+	if (ret)
+		kmem_cache_destroy(drq_pool);
 
-subsys_initcall(deadline_slab_setup);
+	return ret;
+}
 
-elevator_t iosched_deadline = {
-	.elevator_merge_fn = 		deadline_merge,
-	.elevator_merged_fn =		deadline_merged_request,
-	.elevator_merge_req_fn =	deadline_merged_requests,
-	.elevator_next_req_fn =		deadline_next_request,
-	.elevator_add_req_fn =		deadline_insert_request,
-	.elevator_remove_req_fn =	deadline_remove_request,
-	.elevator_queue_empty_fn =	deadline_queue_empty,
-	.elevator_former_req_fn =	deadline_former_request,
-	.elevator_latter_req_fn =	deadline_latter_request,
-	.elevator_set_req_fn =		deadline_set_request,
-	.elevator_put_req_fn = 		deadline_put_request,
-	.elevator_init_fn =		deadline_init,
-	.elevator_exit_fn =		deadline_exit,
+static void __exit deadline_exit(void)
+{
+	kmem_cache_destroy(drq_pool);
+	elv_unregister(&iosched_deadline);
+}
 
-	.elevator_ktype =		&deadline_ktype,
-	.elevator_name =		"deadline",
-};
+module_init(deadline_init);
+module_exit(deadline_exit);
 
-EXPORT_SYMBOL(iosched_deadline);
+MODULE_AUTHOR("Jens Axboe");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("deadline IO scheduler");
diff -Nru a/drivers/block/elevator.c b/drivers/block/elevator.c
--- a/drivers/block/elevator.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/block/elevator.c	2004-12-24 13:37:18 -08:00
@@ -37,6 +37,9 @@
 
 #include <asm/uaccess.h>
 
+static spinlock_t elv_list_lock = SPIN_LOCK_UNLOCKED;
+static LIST_HEAD(elv_list);
+
 /*
  * can we safely merge with this request?
  */
@@ -60,6 +63,7 @@
 
 	return 0;
 }
+EXPORT_SYMBOL(elv_rq_merge_ok);
 
 inline int elv_try_merge(struct request *__rq, struct bio *bio)
 {
@@ -77,6 +81,7 @@
 
 	return ret;
 }
+EXPORT_SYMBOL(elv_try_merge);
 
 inline int elv_try_last_merge(request_queue_t *q, struct bio *bio)
 {
@@ -85,31 +90,136 @@
 
 	return ELEVATOR_NO_MERGE;
 }
+EXPORT_SYMBOL(elv_try_last_merge);
 
-/*
- * general block -> elevator interface starts here
- */
-int elevator_init(request_queue_t *q, elevator_t *type)
+struct elevator_type *elevator_find(const char *name)
+{
+	struct elevator_type *e = NULL;
+	struct list_head *entry;
+
+	spin_lock_irq(&elv_list_lock);
+	list_for_each(entry, &elv_list) {
+		struct elevator_type *__e;
+
+		__e = list_entry(entry, struct elevator_type, list);
+
+		if (!strcmp(__e->elevator_name, name)) {
+			e = __e;
+			break;
+		}
+	}
+	spin_unlock_irq(&elv_list_lock);
+
+	return e;
+}
+
+static void elevator_put(struct elevator_type *e)
+{
+	module_put(e->elevator_owner);
+}
+
+static struct elevator_type *elevator_get(const char *name)
+{
+	struct elevator_type *e = elevator_find(name);
+
+	if (!e)
+		return NULL;
+	if (!try_module_get(e->elevator_owner))
+		return NULL;
+
+	return e;
+}
+
+static int elevator_attach(request_queue_t *q, struct elevator_type *e,
+			   struct elevator_queue *eq)
 {
-	elevator_t *e = &q->elevator;
+	int ret = 0;
 
-	memcpy(e, type, sizeof(*e));
+	memset(eq, 0, sizeof(*eq));
+	eq->ops = &e->ops;
+	eq->elevator_type = e;
 
 	INIT_LIST_HEAD(&q->queue_head);
 	q->last_merge = NULL;
+	q->elevator = eq;
+
+	if (eq->ops->elevator_init_fn)
+		ret = eq->ops->elevator_init_fn(q, eq);
+
+	return ret;
+}
+
+static char chosen_elevator[16];
+
+static void elevator_setup_default(void)
+{
+	/*
+	 * check if default is set and exists
+	 */
+	if (chosen_elevator[0] && elevator_find(chosen_elevator))
+		return;
 
-	if (e->elevator_init_fn)
-		return e->elevator_init_fn(q, e);
+#if defined(CONFIG_IOSCHED_AS)
+	strcpy(chosen_elevator, "anticipatory");
+#elif defined(CONFIG_IOSCHED_DEADLINE)
+	strcpy(chosen_elevator, "deadline");
+#elif defined(CONFIG_IOSCHED_CFQ)
+	strcpy(chosen_elevator, "cfq");
+#elif defined(CONFIG_IOSCHED_NOOP)
+	strcpy(chosen_elevator, "noop");
+#else
+#error "You must build at least 1 IO scheduler into the kernel"
+#endif
+	printk(KERN_INFO "elevator: using %s as default io scheduler\n",
+							chosen_elevator);
+}
 
+static int __init elevator_setup(char *str)
+{
+	strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
 	return 0;
 }
 
-void elevator_exit(request_queue_t *q)
+__setup("elevator=", elevator_setup);
+
+int elevator_init(request_queue_t *q, char *name)
+{
+	struct elevator_type *e = NULL;
+	struct elevator_queue *eq;
+	int ret = 0;
+
+	elevator_setup_default();
+
+	if (!name)
+		name = chosen_elevator;
+
+	e = elevator_get(name);
+	if (!e)
+		return -EINVAL;
+
+	eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL);
+	if (!eq) {
+		elevator_put(e->elevator_type);
+		return -ENOMEM;
+	}
+
+	ret = elevator_attach(q, e, eq);
+	if (ret) {
+		kfree(eq);
+		elevator_put(e->elevator_type);
+	}
+
+	return ret;
+}
+
+void elevator_exit(elevator_t *e)
 {
-	elevator_t *e = &q->elevator;
+	if (e->ops->elevator_exit_fn)
+		e->ops->elevator_exit_fn(e);
 
-	if (e->elevator_exit_fn)
-		e->elevator_exit_fn(q, e);
+	elevator_put(e->elevator_type);
+	e->elevator_type = NULL;
+	kfree(e);
 }
 
 int elevator_global_init(void)
@@ -119,32 +229,32 @@
 
 int elv_merge(request_queue_t *q, struct request **req, struct bio *bio)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
-	if (e->elevator_merge_fn)
-		return e->elevator_merge_fn(q, req, bio);
+	if (e->ops->elevator_merge_fn)
+		return e->ops->elevator_merge_fn(q, req, bio);
 
 	return ELEVATOR_NO_MERGE;
 }
 
 void elv_merged_request(request_queue_t *q, struct request *rq)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
-	if (e->elevator_merged_fn)
-		e->elevator_merged_fn(q, rq);
+	if (e->ops->elevator_merged_fn)
+		e->ops->elevator_merged_fn(q, rq);
 }
 
 void elv_merge_requests(request_queue_t *q, struct request *rq,
 			     struct request *next)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
 	if (q->last_merge == next)
 		q->last_merge = NULL;
 
-	if (e->elevator_merge_req_fn)
-		e->elevator_merge_req_fn(q, rq, next);
+	if (e->ops->elevator_merge_req_fn)
+		e->ops->elevator_merge_req_fn(q, rq, next);
 }
 
 void elv_requeue_request(request_queue_t *q, struct request *rq)
@@ -160,8 +270,8 @@
 	 * if iosched has an explicit requeue hook, then use that. otherwise
 	 * just put the request at the front of the queue
 	 */
-	if (q->elevator.elevator_requeue_req_fn)
-		q->elevator.elevator_requeue_req_fn(q, rq);
+	if (q->elevator->ops->elevator_requeue_req_fn)
+		q->elevator->ops->elevator_requeue_req_fn(q, rq);
 	else
 		__elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
 }
@@ -180,15 +290,24 @@
 		blk_plug_device(q);
 
 	rq->q = q;
-	q->elevator.elevator_add_req_fn(q, rq, where);
 
-	if (blk_queue_plugged(q)) {
-		int nrq = q->rq.count[READ] + q->rq.count[WRITE] - q->in_flight;
+	if (!test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags)) {
+		q->elevator->ops->elevator_add_req_fn(q, rq, where);
 
-		if (nrq == q->unplug_thresh)
-			__generic_unplug_device(q);
-	}
+		if (blk_queue_plugged(q)) {
+			int nrq = q->rq.count[READ] + q->rq.count[WRITE]
+				  - q->in_flight;
 
+			if (nrq == q->unplug_thresh)
+				__generic_unplug_device(q);
+		}
+	} else
+		/*
+		 * if drain is set, store the request "locally". when the drain
+		 * is finished, the requests will be handed ordered to the io
+		 * scheduler
+		 */
+		list_add_tail(&rq->queuelist, &q->drain_list);
 }
 
 void elv_add_request(request_queue_t *q, struct request *rq, int where,
@@ -203,7 +322,7 @@
 
 static inline struct request *__elv_next_request(request_queue_t *q)
 {
-	return q->elevator.elevator_next_req_fn(q);
+	return q->elevator->ops->elevator_next_req_fn(q);
 }
 
 struct request *elv_next_request(request_queue_t *q)
@@ -242,7 +361,8 @@
 			end_that_request_chunk(rq, 0, nr_bytes);
 			end_that_request_last(rq);
 		} else {
-			printk("%s: bad return=%d\n", __FUNCTION__, ret);
+			printk(KERN_ERR "%s: bad return=%d\n", __FUNCTION__,
+								ret);
 			break;
 		}
 	}
@@ -252,7 +372,7 @@
 
 void elv_remove_request(request_queue_t *q, struct request *rq)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
 	/*
 	 * the time frame between a request being removed from the lists
@@ -274,16 +394,16 @@
 	if (rq == q->last_merge)
 		q->last_merge = NULL;
 
-	if (e->elevator_remove_req_fn)
-		e->elevator_remove_req_fn(q, rq);
+	if (e->ops->elevator_remove_req_fn)
+		e->ops->elevator_remove_req_fn(q, rq);
 }
 
 int elv_queue_empty(request_queue_t *q)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
-	if (e->elevator_queue_empty_fn)
-		return e->elevator_queue_empty_fn(q);
+	if (e->ops->elevator_queue_empty_fn)
+		return e->ops->elevator_queue_empty_fn(q);
 
 	return list_empty(&q->queue_head);
 }
@@ -292,10 +412,10 @@
 {
 	struct list_head *next;
 
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
-	if (e->elevator_latter_req_fn)
-		return e->elevator_latter_req_fn(q, rq);
+	if (e->ops->elevator_latter_req_fn)
+		return e->ops->elevator_latter_req_fn(q, rq);
 
 	next = rq->queuelist.next;
 	if (next != &q->queue_head && next != &rq->queuelist)
@@ -308,10 +428,10 @@
 {
 	struct list_head *prev;
 
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
-	if (e->elevator_former_req_fn)
-		return e->elevator_former_req_fn(q, rq);
+	if (e->ops->elevator_former_req_fn)
+		return e->ops->elevator_former_req_fn(q, rq);
 
 	prev = rq->queuelist.prev;
 	if (prev != &q->queue_head && prev != &rq->queuelist)
@@ -322,10 +442,10 @@
 
 int elv_set_request(request_queue_t *q, struct request *rq, int gfp_mask)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
-	if (e->elevator_set_req_fn)
-		return e->elevator_set_req_fn(q, rq, gfp_mask);
+	if (e->ops->elevator_set_req_fn)
+		return e->ops->elevator_set_req_fn(q, rq, gfp_mask);
 
 	rq->elevator_private = NULL;
 	return 0;
@@ -333,25 +453,25 @@
 
 void elv_put_request(request_queue_t *q, struct request *rq)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
-	if (e->elevator_put_req_fn)
-		e->elevator_put_req_fn(q, rq);
+	if (e->ops->elevator_put_req_fn)
+		e->ops->elevator_put_req_fn(q, rq);
 }
 
 int elv_may_queue(request_queue_t *q, int rw)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
-	if (e->elevator_may_queue_fn)
-		return e->elevator_may_queue_fn(q, rw);
+	if (e->ops->elevator_may_queue_fn)
+		return e->ops->elevator_may_queue_fn(q, rw);
 
-	return 0;
+	return ELV_MQUEUE_MAY;
 }
 
 void elv_completed_request(request_queue_t *q, struct request *rq)
 {
-	elevator_t *e = &q->elevator;
+	elevator_t *e = q->elevator;
 
 	/*
 	 * request is released from the driver, io must be done
@@ -359,22 +479,20 @@
 	if (blk_account_rq(rq))
 		q->in_flight--;
 
-	if (e->elevator_completed_req_fn)
-		e->elevator_completed_req_fn(q, rq);
+	if (e->ops->elevator_completed_req_fn)
+		e->ops->elevator_completed_req_fn(q, rq);
 }
 
 int elv_register_queue(struct request_queue *q)
 {
-	elevator_t *e;
-
-	e = &q->elevator;
+	elevator_t *e = q->elevator;
 
 	e->kobj.parent = kobject_get(&q->kobj);
 	if (!e->kobj.parent)
 		return -EBUSY;
 
 	snprintf(e->kobj.name, KOBJ_NAME_LEN, "%s", "iosched");
-	e->kobj.ktype = e->elevator_ktype;
+	e->kobj.ktype = e->elevator_type->elevator_ktype;
 
 	return kobject_register(&e->kobj);
 }
@@ -382,10 +500,155 @@
 void elv_unregister_queue(struct request_queue *q)
 {
 	if (q) {
-		elevator_t * e = &q->elevator;
+		elevator_t *e = q->elevator;
 		kobject_unregister(&e->kobj);
 		kobject_put(&q->kobj);
 	}
+}
+
+int elv_register(struct elevator_type *e)
+{
+	if (elevator_find(e->elevator_name))
+		BUG();
+
+	spin_lock_irq(&elv_list_lock);
+	list_add_tail(&e->list, &elv_list);
+	spin_unlock_irq(&elv_list_lock);
+
+	printk(KERN_INFO "io scheduler %s registered\n", e->elevator_name);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(elv_register);
+
+void elv_unregister(struct elevator_type *e)
+{
+	spin_lock_irq(&elv_list_lock);
+	list_del_init(&e->list);
+	spin_unlock_irq(&elv_list_lock);
+}
+EXPORT_SYMBOL_GPL(elv_unregister);
+
+/*
+ * switch to new_e io scheduler. be careful not to introduce deadlocks -
+ * we don't free the old io scheduler, before we have allocated what we
+ * need for the new one. this way we have a chance of going back to the old
+ * one, if the new one fails init for some reason. we also do an intermediate
+ * switch to noop to ensure safety with stack-allocated requests, since they
+ * don't originate from the block layer allocator. noop is safe here, because
+ * it never needs to touch the elevator itself for completion events. DRAIN
+ * flags will make sure we don't touch it for additions either.
+ */
+static void elevator_switch(request_queue_t *q, struct elevator_type *new_e)
+{
+	elevator_t *e = kmalloc(sizeof(elevator_t), GFP_KERNEL);
+	struct elevator_type *noop_elevator = NULL;
+	elevator_t *old_elevator;
+
+	if (!e)
+		goto error;
+
+	/*
+	 * first step, drain requests from the block freelist
+	 */
+	blk_wait_queue_drained(q, 0);
+
+	/*
+	 * unregister old elevator data
+	 */
+	elv_unregister_queue(q);
+	old_elevator = q->elevator;
+
+	/*
+ 	 * next step, switch to noop since it uses no private rq structures
+	 * and doesn't allocate any memory for anything. then wait for any
+	 * non-fs requests in-flight
+ 	 */
+	noop_elevator = elevator_get("noop");
+	spin_lock_irq(q->queue_lock);
+	elevator_attach(q, noop_elevator, e);
+	spin_unlock_irq(q->queue_lock);
+
+	blk_wait_queue_drained(q, 1);
+
+	/*
+	 * attach and start new elevator
+	 */
+	if (elevator_attach(q, new_e, e))
+		goto fail;
+
+	if (elv_register_queue(q))
+		goto fail_register;
+
+	/*
+	 * finally exit old elevator and start queue again
+	 */
+	elevator_exit(old_elevator);
+	blk_finish_queue_drain(q);
+	elevator_put(noop_elevator);
+	return;
+
+fail_register:
+	/*
+	 * switch failed, exit the new io scheduler and reattach the old
+	 * one again (along with re-adding the sysfs dir)
+	 */
+	elevator_exit(e);
+fail:
+	q->elevator = old_elevator;
+	elv_register_queue(q);
+	blk_finish_queue_drain(q);
+error:
+	if (noop_elevator)
+		elevator_put(noop_elevator);
+	elevator_put(new_e);
+	printk(KERN_ERR "elevator: switch to %s failed\n",new_e->elevator_name);
+}
+
+ssize_t elv_iosched_store(request_queue_t *q, const char *name, size_t count)
+{
+	char elevator_name[ELV_NAME_MAX];
+	struct elevator_type *e;
+
+	memset(elevator_name, 0, sizeof(elevator_name));
+	strncpy(elevator_name, name, sizeof(elevator_name));
+
+	if (elevator_name[strlen(elevator_name) - 1] == '\n')
+		elevator_name[strlen(elevator_name) - 1] = '\0';
+
+	e = elevator_get(elevator_name);
+	if (!e) {
+		printk(KERN_ERR "elevator: type %s not found\n", elevator_name);
+		return -EINVAL;
+	}
+
+	if (!strcmp(elevator_name, q->elevator->elevator_type->elevator_name))
+		return count;
+
+	elevator_switch(q, e);
+	return count;
+}
+
+ssize_t elv_iosched_show(request_queue_t *q, char *name)
+{
+	elevator_t *e = q->elevator;
+	struct elevator_type *elv = e->elevator_type;
+	struct list_head *entry;
+	int len = 0;
+
+	spin_lock_irq(q->queue_lock);
+	list_for_each(entry, &elv_list) {
+		struct elevator_type *__e;
+
+		__e = list_entry(entry, struct elevator_type, list);
+		if (!strcmp(elv->elevator_name, __e->elevator_name))
+			len += sprintf(name+len, "[%s] ", elv->elevator_name);
+		else
+			len += sprintf(name+len, "%s ", __e->elevator_name);
+	}
+	spin_unlock_irq(q->queue_lock);
+
+	len += sprintf(len+name, "\n");
+	return len;
 }
 
 module_init(elevator_global_init);
diff -Nru a/drivers/block/floppy.c b/drivers/block/floppy.c
--- a/drivers/block/floppy.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/block/floppy.c	2004-12-24 13:36:19 -08:00
@@ -1787,10 +1787,11 @@
 		} while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2
 			 && max_sensei);
 	}
-	if (handler)
-		schedule_bh(handler);
-	else
+	if (!handler) {
 		FDCS->reset = 1;
+		return IRQ_NONE;
+	}
+	schedule_bh(handler);
 	is_alive("normal interrupt end");
 
 	/* FIXME! Was it really for us? */
@@ -4124,7 +4125,7 @@
 	int *var;
 	int def_param;
 	int param2;
-} config_params[] = {
+} config_params[] __initdata = {
 	{"allowed_drive_mask", NULL, &allowed_drive_mask, 0xff, 0}, /* obsolete */
 	{"all_drives", NULL, &allowed_drive_mask, 0xff, 0},	/* obsolete */
 	{"asus_pci", NULL, &allowed_drive_mask, 0x33, 0},
@@ -4286,6 +4287,13 @@
 	}
 
 	use_virtual_dma = can_use_virtual_dma & 1;
+#if defined(CONFIG_PPC64)
+	if (check_legacy_ioport(FDC1)) {
+		del_timer(&fd_timeout);
+		err = -ENODEV;
+		goto out_unreg_region;
+	}
+#endif
 	fdc_state[0].address = FDC1;
 	if (fdc_state[0].address == -1) {
 		del_timer(&fd_timeout);
@@ -4315,6 +4323,12 @@
 		floppy_track_buffer = NULL;
 		max_buffer_sectors = 0;
 	}
+	/*
+	 * Small 10 msec delay to let through any interrupt that
+	 * initialization might have triggered, to not
+	 * confuse detection:
+	 */
+	msleep(10);
 
 	for (i = 0; i < N_FDC; i++) {
 		fdc = i;
@@ -4623,9 +4637,9 @@
 	wait_for_completion(&device_release);
 }
 
-MODULE_PARM(floppy, "s");
-MODULE_PARM(FLOPPY_IRQ, "i");
-MODULE_PARM(FLOPPY_DMA, "i");
+module_param(floppy, charp, 0);
+module_param(FLOPPY_IRQ, int, 0);
+module_param(FLOPPY_DMA, int, 0);
 MODULE_AUTHOR("Alain L. Knaff");
 MODULE_SUPPORTED_DEVICE("fd");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c
--- a/drivers/block/genhd.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/block/genhd.c	2004-12-24 13:36:48 -08:00
@@ -438,8 +438,52 @@
 	return ((ktype == &ktype_block) || (ktype == &ktype_part));
 }
 
+static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
+			 int num_envp, char *buffer, int buffer_size)
+{
+	struct device *dev = NULL;
+	struct kobj_type *ktype = get_ktype(kobj);
+	int length = 0;
+	int i = 0;
+
+	/* get physical device backing disk or partition */
+	if (ktype == &ktype_block) {
+		struct gendisk *disk = container_of(kobj, struct gendisk, kobj);
+		dev = disk->driverfs_dev;
+	} else if (ktype == &ktype_part) {
+		struct gendisk *disk = container_of(kobj->parent, struct gendisk, kobj);
+		dev = disk->driverfs_dev;
+	}
+
+	if (dev) {
+		/* add physical device, backing this device  */
+		char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
+
+		add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
+				    &length, "PHYSDEVPATH=%s", path);
+		kfree(path);
+
+		/* add bus name of physical device */
+		if (dev->bus)
+			add_hotplug_env_var(envp, num_envp, &i,
+					    buffer, buffer_size, &length,
+					    "PHYSDEVBUS=%s", dev->bus->name);
+
+		/* add driver name of physical device */
+		if (dev->driver)
+			add_hotplug_env_var(envp, num_envp, &i,
+					    buffer, buffer_size, &length,
+					    "PHYSDEVDRIVER=%s", dev->driver->name);
+
+		envp[i] = NULL;
+	}
+
+	return 0;
+}
+
 static struct kset_hotplug_ops block_hotplug_ops = {
-	.filter	= block_hotplug_filter,
+	.filter		= block_hotplug_filter,
+	.hotplug	= block_hotplug,
 };
 
 /* declare block_subsys. */
diff -Nru a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
--- a/drivers/block/ll_rw_blk.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/block/ll_rw_blk.c	2004-12-24 13:36:18 -08:00
@@ -100,7 +100,7 @@
 		nr = q->nr_requests;
 	q->nr_congestion_on = nr;
 
-	nr = q->nr_requests - (q->nr_requests / 8) - 1;
+	nr = q->nr_requests - (q->nr_requests / 8) - (q->nr_requests / 16) - 1;
 	if (nr < 1)
 		nr = 1;
 	q->nr_congestion_off = nr;
@@ -243,6 +243,7 @@
 	blk_queue_hardsect_size(q, 512);
 	blk_queue_dma_alignment(q, 511);
 	blk_queue_congestion_threshold(q);
+	q->nr_batching = BLK_BATCH_REQ;
 
 	q->unplug_thresh = 4;		/* hmm */
 	q->unplug_delay = (3 * HZ) / 1000;	/* 3 milliseconds */
@@ -260,6 +261,8 @@
 	blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
 
 	blk_queue_activity_fn(q, NULL, NULL);
+
+	INIT_LIST_HEAD(&q->drain_list);
 }
 
 EXPORT_SYMBOL(blk_queue_make_request);
@@ -1354,10 +1357,30 @@
 	blk_remove_plug(q);
 	set_bit(QUEUE_FLAG_STOPPED, &q->queue_flags);
 }
-
 EXPORT_SYMBOL(blk_stop_queue);
 
 /**
+ * blk_sync_queue - cancel any pending callbacks on a queue
+ * @q: the queue
+ *
+ * Description:
+ *     The block layer may perform asynchronous callback activity
+ *     on a queue, such as calling the unplug function after a timeout.
+ *     A block device may call blk_sync_queue to ensure that any
+ *     such activity is cancelled, thus allowing it to release resources
+ *     the the callbacks might use. The caller must already have made sure
+ *     that its ->make_request_fn will not re-add plugging prior to calling
+ *     this function.
+ *
+ */
+void blk_sync_queue(struct request_queue *q)
+{
+	del_timer_sync(&q->unplug_timer);
+	kblockd_flush();
+}
+EXPORT_SYMBOL(blk_sync_queue);
+
+/**
  * blk_run_queue - run a single device queue
  * @q:	The queue to run
  */
@@ -1370,7 +1393,6 @@
 	q->request_fn(q);
 	spin_unlock_irqrestore(q->queue_lock, flags);
 }
-
 EXPORT_SYMBOL(blk_run_queue);
 
 /**
@@ -1395,10 +1417,10 @@
 	if (!atomic_dec_and_test(&q->refcnt))
 		return;
 
-	elevator_exit(q);
+	if (q->elevator)
+		elevator_exit(q->elevator);
 
-	del_timer_sync(&q->unplug_timer);
-	kblockd_flush();
+	blk_sync_queue(q);
 
 	if (rl->rq_pool)
 		mempool_destroy(rl->rq_pool);
@@ -1418,6 +1440,7 @@
 	rl->count[READ] = rl->count[WRITE] = 0;
 	init_waitqueue_head(&rl->wait[READ]);
 	init_waitqueue_head(&rl->wait[WRITE]);
+	init_waitqueue_head(&rl->drain);
 
 	rl->rq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, request_cachep);
 
@@ -1429,45 +1452,6 @@
 
 static int __make_request(request_queue_t *, struct bio *);
 
-static elevator_t *chosen_elevator =
-#if defined(CONFIG_IOSCHED_AS)
-	&iosched_as;
-#elif defined(CONFIG_IOSCHED_DEADLINE)
-	&iosched_deadline;
-#elif defined(CONFIG_IOSCHED_CFQ)
-	&iosched_cfq;
-#elif defined(CONFIG_IOSCHED_NOOP)
-	&elevator_noop;
-#else
-	NULL;
-#error "You must have at least 1 I/O scheduler selected"
-#endif
-
-#if defined(CONFIG_IOSCHED_AS) || defined(CONFIG_IOSCHED_DEADLINE) || defined (CONFIG_IOSCHED_NOOP)
-static int __init elevator_setup(char *str)
-{
-#ifdef CONFIG_IOSCHED_DEADLINE
-	if (!strcmp(str, "deadline"))
-		chosen_elevator = &iosched_deadline;
-#endif
-#ifdef CONFIG_IOSCHED_AS
-	if (!strcmp(str, "as"))
-		chosen_elevator = &iosched_as;
-#endif
-#ifdef CONFIG_IOSCHED_CFQ
-	if (!strcmp(str, "cfq"))
-		chosen_elevator = &iosched_cfq;
-#endif
-#ifdef CONFIG_IOSCHED_NOOP
-	if (!strcmp(str, "noop"))
-		chosen_elevator = &elevator_noop;
-#endif
-	return 1;
-}
-
-__setup("elevator=", elevator_setup);
-#endif /* CONFIG_IOSCHED_AS || CONFIG_IOSCHED_DEADLINE || CONFIG_IOSCHED_NOOP */
-
 request_queue_t *blk_alloc_queue(int gfp_mask)
 {
 	request_queue_t *q = kmem_cache_alloc(requestq_cachep, gfp_mask);
@@ -1520,21 +1504,14 @@
  **/
 request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock)
 {
-	request_queue_t *q;
-	static int printed;
+	request_queue_t *q = blk_alloc_queue(GFP_KERNEL);
 
-	q = blk_alloc_queue(GFP_KERNEL);
 	if (!q)
 		return NULL;
 
 	if (blk_init_free_list(q))
 		goto out_init;
 
-	if (!printed) {
-		printed = 1;
-		printk("Using %s io scheduler\n", chosen_elevator->elevator_name);
-	}
-
 	q->request_fn		= rfn;
 	q->back_merge_fn       	= ll_back_merge_fn;
 	q->front_merge_fn      	= ll_front_merge_fn;
@@ -1555,8 +1532,10 @@
 	/*
 	 * all done
 	 */
-	if (!elevator_init(q, chosen_elevator))
+	if (!elevator_init(q, NULL)) {
+		blk_queue_congestion_threshold(q);
 		return q;
+	}
 
 	blk_cleanup_queue(q);
 out_init:
@@ -1584,13 +1563,20 @@
 	mempool_free(rq, q->rq.rq_pool);
 }
 
-static inline struct request *blk_alloc_request(request_queue_t *q,int gfp_mask)
+static inline struct request *blk_alloc_request(request_queue_t *q, int rw,
+						int gfp_mask)
 {
 	struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask);
 
 	if (!rq)
 		return NULL;
 
+	/*
+	 * first three bits are identical in rq->flags and bio->bi_rw,
+	 * see bio.h and blkdev.h
+	 */
+	rq->flags = rw;
+
 	if (!elv_set_request(q, rq, gfp_mask))
 		return rq;
 
@@ -1602,7 +1588,7 @@
  * ioc_batching returns true if the ioc is a valid batching request and
  * should be given priority access to a request.
  */
-static inline int ioc_batching(struct io_context *ioc)
+static inline int ioc_batching(request_queue_t *q, struct io_context *ioc)
 {
 	if (!ioc)
 		return 0;
@@ -1612,7 +1598,7 @@
 	 * even if the batch times out, otherwise we could theoretically
 	 * lose wakeups.
 	 */
-	return ioc->nr_batch_requests == BLK_BATCH_REQ ||
+	return ioc->nr_batch_requests == q->nr_batching ||
 		(ioc->nr_batch_requests > 0
 		&& time_before(jiffies, ioc->last_waited + BLK_BATCH_TIME));
 }
@@ -1623,12 +1609,12 @@
  * is the behaviour we want though - once it gets a wakeup it should be given
  * a nice run.
  */
-void ioc_set_batching(struct io_context *ioc)
+void ioc_set_batching(request_queue_t *q, struct io_context *ioc)
 {
-	if (!ioc || ioc_batching(ioc))
+	if (!ioc || ioc_batching(q, ioc))
 		return;
 
-	ioc->nr_batch_requests = BLK_BATCH_REQ;
+	ioc->nr_batch_requests = q->nr_batching;
 	ioc->last_waited = jiffies;
 }
 
@@ -1644,11 +1630,14 @@
 	if (rl->count[rw] < queue_congestion_off_threshold(q))
 		clear_queue_congested(q, rw);
 	if (rl->count[rw]+1 <= q->nr_requests) {
+		smp_mb();
 		if (waitqueue_active(&rl->wait[rw]))
 			wake_up(&rl->wait[rw]);
-		if (!waitqueue_active(&rl->wait[rw]))
-			blk_clear_queue_full(q, rw);
+		blk_clear_queue_full(q, rw);
 	}
+	if (unlikely(waitqueue_active(&rl->drain)) &&
+	    !rl->count[READ] && !rl->count[WRITE])
+		wake_up(&rl->drain);
 }
 
 #define blkdev_free_rq(list) list_entry((list)->next, struct request, queuelist)
@@ -1661,6 +1650,9 @@
 	struct request_list *rl = &q->rq;
 	struct io_context *ioc = get_io_context(gfp_mask);
 
+	if (unlikely(test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags)))
+		goto out;
+
 	spin_lock_irq(q->queue_lock);
 	if (rl->count[rw]+1 >= q->nr_requests) {
 		/*
@@ -1670,13 +1662,22 @@
 		 * will be blocked.
 		 */
 		if (!blk_queue_full(q, rw)) {
-			ioc_set_batching(ioc);
+			ioc_set_batching(q, ioc);
 			blk_set_queue_full(q, rw);
 		}
 	}
 
-	if (blk_queue_full(q, rw)
-			&& !ioc_batching(ioc) && !elv_may_queue(q, rw)) {
+	switch (elv_may_queue(q, rw)) {
+		case ELV_MQUEUE_NO:
+			spin_unlock_irq(q->queue_lock);
+			goto out;
+		case ELV_MQUEUE_MAY:
+			break;
+		case ELV_MQUEUE_MUST:
+			goto get_rq;
+	}
+
+	if (blk_queue_full(q, rw) && !ioc_batching(q, ioc)) {
 		/*
 		 * The queue is full and the allocating process is not a
 		 * "batcher", and not exempted by the IO scheduler
@@ -1685,12 +1686,13 @@
 		goto out;
 	}
 
+get_rq:
 	rl->count[rw]++;
 	if (rl->count[rw] >= queue_congestion_on_threshold(q))
 		set_queue_congested(q, rw);
 	spin_unlock_irq(q->queue_lock);
 
-	rq = blk_alloc_request(q, gfp_mask);
+	rq = blk_alloc_request(q, rw, gfp_mask);
 	if (!rq) {
 		/*
 		 * Allocation failed presumably due to memory. Undo anything
@@ -1705,17 +1707,11 @@
 		goto out;
 	}
 
-	if (ioc_batching(ioc))
+	if (ioc_batching(q, ioc))
 		ioc->nr_batch_requests--;
 	
 	INIT_LIST_HEAD(&rq->queuelist);
 
-	/*
-	 * first three bits are identical in rq->flags and bio->bi_rw,
-	 * see bio.h and blkdev.h
-	 */
-	rq->flags = rw;
-
 	rq->errors = 0;
 	rq->rq_status = RQ_ACTIVE;
 	rq->bio = rq->biotail = NULL;
@@ -1764,7 +1760,7 @@
 			 * See ioc_batching, ioc_set_batching
 			 */
 			ioc = get_io_context(GFP_NOIO);
-			ioc_set_batching(ioc);
+			ioc_set_batching(q, ioc);
 			put_io_context(ioc);
 		}
 		finish_wait(&rl->wait[rw], &wait);
@@ -2082,13 +2078,13 @@
 		return;
 
 	if (rw == READ) {
-		disk_stat_add(rq->rq_disk, read_sectors, nr_sectors);
+		__disk_stat_add(rq->rq_disk, read_sectors, nr_sectors);
 		if (!new_io)
-			disk_stat_inc(rq->rq_disk, read_merges);
+			__disk_stat_inc(rq->rq_disk, read_merges);
 	} else if (rw == WRITE) {
-		disk_stat_add(rq->rq_disk, write_sectors, nr_sectors);
+		__disk_stat_add(rq->rq_disk, write_sectors, nr_sectors);
 		if (!new_io)
-			disk_stat_inc(rq->rq_disk, write_merges);
+			__disk_stat_inc(rq->rq_disk, write_merges);
 	}
 	if (new_io) {
 		disk_round_stats(rq->rq_disk);
@@ -2134,12 +2130,12 @@
 {
 	unsigned long now = jiffies;
 
-	disk_stat_add(disk, time_in_queue, 
+	__disk_stat_add(disk, time_in_queue,
 			disk->in_flight * (now - disk->stamp));
 	disk->stamp = now;
 
 	if (disk->in_flight)
-		disk_stat_add(disk, io_ticks, (now - disk->stamp_idle));
+		__disk_stat_add(disk, io_ticks, (now - disk->stamp_idle));
 	disk->stamp_idle = now;
 }
 
@@ -2384,9 +2380,7 @@
 				break;
 
 			bio->bi_next = req->bio;
-			req->cbio = req->bio = bio;
-			req->nr_cbio_segments = bio_segments(bio);
-			req->nr_cbio_sectors = bio_sectors(bio);
+			req->bio = bio;
 
 			/*
 			 * may not be valid. if the low level driver said
@@ -2458,11 +2452,9 @@
 	req->current_nr_sectors = req->hard_cur_sectors = cur_nr_sectors;
 	req->nr_phys_segments = bio_phys_segments(q, bio);
 	req->nr_hw_segments = bio_hw_segments(q, bio);
-	req->nr_cbio_segments = bio_segments(bio);
-	req->nr_cbio_sectors = bio_sectors(bio);
 	req->buffer = bio_data(bio);	/* see ->buffer comment above */
 	req->waiting = NULL;
-	req->cbio = req->bio = req->biotail = bio;
+	req->bio = req->biotail = bio;
 	req->rq_disk = bio->bi_bdev->bd_disk;
 	req->start_time = jiffies;
 
@@ -2506,6 +2498,106 @@
 	}
 }
 
+void blk_finish_queue_drain(request_queue_t *q)
+{
+	struct request_list *rl = &q->rq;
+	struct request *rq;
+
+	spin_lock_irq(q->queue_lock);
+	clear_bit(QUEUE_FLAG_DRAIN, &q->queue_flags);
+
+	while (!list_empty(&q->drain_list)) {
+		rq = list_entry_rq(q->drain_list.next);
+
+		list_del_init(&rq->queuelist);
+		__elv_add_request(q, rq, ELEVATOR_INSERT_BACK, 1);
+	}
+
+	spin_unlock_irq(q->queue_lock);
+
+	wake_up(&rl->wait[0]);
+	wake_up(&rl->wait[1]);
+	wake_up(&rl->drain);
+}
+
+static int wait_drain(request_queue_t *q, struct request_list *rl, int dispatch)
+{
+	int wait = rl->count[READ] + rl->count[WRITE];
+
+	if (dispatch)
+		wait += !list_empty(&q->queue_head);
+
+	return wait;
+}
+
+/*
+ * We rely on the fact that only requests allocated through blk_alloc_request()
+ * have io scheduler private data structures associated with them. Any other
+ * type of request (allocated on stack or through kmalloc()) should not go
+ * to the io scheduler core, but be attached to the queue head instead.
+ */
+void blk_wait_queue_drained(request_queue_t *q, int wait_dispatch)
+{
+	struct request_list *rl = &q->rq;
+	DEFINE_WAIT(wait);
+
+	spin_lock_irq(q->queue_lock);
+	set_bit(QUEUE_FLAG_DRAIN, &q->queue_flags);
+
+	while (wait_drain(q, rl, wait_dispatch)) {
+		prepare_to_wait(&rl->drain, &wait, TASK_UNINTERRUPTIBLE);
+
+		if (wait_drain(q, rl, wait_dispatch)) {
+			__generic_unplug_device(q);
+			spin_unlock_irq(q->queue_lock);
+			io_schedule();
+			spin_lock_irq(q->queue_lock);
+		}
+
+		finish_wait(&rl->drain, &wait);
+	}
+
+	spin_unlock_irq(q->queue_lock);
+}
+
+/*
+ * block waiting for the io scheduler being started again.
+ */
+static inline void block_wait_queue_running(request_queue_t *q)
+{
+	DEFINE_WAIT(wait);
+
+	while (test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags)) {
+		struct request_list *rl = &q->rq;
+
+		prepare_to_wait_exclusive(&rl->drain, &wait,
+				TASK_UNINTERRUPTIBLE);
+
+		/*
+		 * re-check the condition. avoids using prepare_to_wait()
+		 * in the fast path (queue is running)
+		 */
+		if (test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags))
+			io_schedule();
+
+		finish_wait(&rl->drain, &wait);
+	}
+}
+
+static void handle_bad_sector(struct bio *bio)
+{
+	char b[BDEVNAME_SIZE];
+
+	printk(KERN_INFO "attempt to access beyond end of device\n");
+	printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n",
+			bdevname(bio->bi_bdev, b),
+			bio->bi_rw,
+			(unsigned long long)bio->bi_sector + bio_sectors(bio),
+			(long long)(bio->bi_bdev->bd_inode->i_size >> 9));
+
+	set_bit(BIO_EOF, &bio->bi_flags);
+}
+
 /**
  * generic_make_request: hand a buffer to its device driver for I/O
  * @bio:  The bio describing the location in memory and on the device.
@@ -2542,21 +2634,13 @@
 	if (maxsector) {
 		sector_t sector = bio->bi_sector;
 
-		if (maxsector < nr_sectors ||
-		    maxsector - nr_sectors < sector) {
-			char b[BDEVNAME_SIZE];
-			/* This may well happen - the kernel calls
-			 * bread() without checking the size of the
-			 * device, e.g., when mounting a device. */
-			printk(KERN_INFO
-			       "attempt to access beyond end of device\n");
-			printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n",
-			       bdevname(bio->bi_bdev, b),
-			       bio->bi_rw,
-			       (unsigned long long) sector + nr_sectors,
-			       (long long) maxsector);
-
-			set_bit(BIO_EOF, &bio->bi_flags);
+		if (maxsector < nr_sectors || maxsector - nr_sectors < sector) {
+			/*
+			 * This may well happen - the kernel calls bread()
+			 * without checking the size of the device, e.g., when
+			 * mounting a device.
+			 */
+			handle_bad_sector(bio);
 			goto end_io;
 		}
 	}
@@ -2595,6 +2679,8 @@
 		if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))
 			goto end_io;
 
+		block_wait_queue_running(q);
+
 		/*
 		 * If this device has partitions, remap block n
 		 * of partition p to block n+start(p) of the disk.
@@ -2643,103 +2729,40 @@
 
 EXPORT_SYMBOL(submit_bio);
 
-/**
- * blk_rq_next_segment
- * @rq:		the request being processed
- *
- * Description:
- *	Points to the next segment in the request if the current segment
- *	is complete. Leaves things unchanged if this segment is not over
- *	or if no more segments are left in this request.
- *
- *	Meant to be used for bio traversal during I/O submission
- *	Does not affect any I/O completions or update completion state
- *	in the request, and does not modify any bio fields.
- *
- *	Decrementing rq->nr_sectors, rq->current_nr_sectors and
- *	rq->nr_cbio_sectors as data is transferred is the caller's
- *	responsibility and should be done before calling this routine.
- **/
-void blk_rq_next_segment(struct request *rq)
-{
-	if (rq->current_nr_sectors > 0)
-		return;
-
-	if (rq->nr_cbio_sectors > 0) {
-		--rq->nr_cbio_segments;
-		rq->current_nr_sectors = blk_rq_vec(rq)->bv_len >> 9;
-	} else {
-		if ((rq->cbio = rq->cbio->bi_next)) {
-			rq->nr_cbio_segments = bio_segments(rq->cbio);
-			rq->nr_cbio_sectors = bio_sectors(rq->cbio);
- 			rq->current_nr_sectors = bio_cur_sectors(rq->cbio);
-		}
- 	}
-
-	/* remember the size of this segment before we start I/O */
-	rq->hard_cur_sectors = rq->current_nr_sectors;
-}
-
-/**
- * process_that_request_first	-	process partial request submission
- * @req:	the request being processed
- * @nr_sectors:	number of sectors I/O has been submitted on
- *
- * Description:
- *	May be used for processing bio's while submitting I/O without
- *	signalling completion. Fails if more data is requested than is
- *	available in the request in which case it doesn't advance any
- *	pointers.
- *
- *	Assumes a request is correctly set up. No sanity checks.
- *
- * Return:
- *	0 - no more data left to submit (not processed)
- *	1 - data available to submit for this request (processed)
- **/
-int process_that_request_first(struct request *req, unsigned int nr_sectors)
-{
-	unsigned int nsect;
-
-	if (req->nr_sectors < nr_sectors)
-		return 0;
-
-	req->nr_sectors -= nr_sectors;
-	req->sector += nr_sectors;
-	while (nr_sectors) {
-		nsect = min_t(unsigned, req->current_nr_sectors, nr_sectors);
-		req->current_nr_sectors -= nsect;
-		nr_sectors -= nsect;
-		if (req->cbio) {
-			req->nr_cbio_sectors -= nsect;
-			blk_rq_next_segment(req);
-		}
-	}
-	return 1;
-}
-
-EXPORT_SYMBOL(process_that_request_first);
-
 void blk_recalc_rq_segments(struct request *rq)
 {
 	struct bio *bio, *prevbio = NULL;
 	int nr_phys_segs, nr_hw_segs;
+	unsigned int phys_size, hw_size;
+	request_queue_t *q = rq->q;
 
 	if (!rq->bio)
 		return;
 
-	nr_phys_segs = nr_hw_segs = 0;
+	phys_size = hw_size = nr_phys_segs = nr_hw_segs = 0;
 	rq_for_each_bio(bio, rq) {
 		/* Force bio hw/phys segs to be recalculated. */
 		bio->bi_flags &= ~(1 << BIO_SEG_VALID);
 
-		nr_phys_segs += bio_phys_segments(rq->q, bio);
-		nr_hw_segs += bio_hw_segments(rq->q, bio);
+		nr_phys_segs += bio_phys_segments(q, bio);
+		nr_hw_segs += bio_hw_segments(q, bio);
 		if (prevbio) {
-			if (blk_phys_contig_segment(rq->q, prevbio, bio))
+			int pseg = phys_size + prevbio->bi_size + bio->bi_size;
+			int hseg = hw_size + prevbio->bi_size + bio->bi_size;
+
+			if (blk_phys_contig_segment(q, prevbio, bio) &&
+			    pseg <= q->max_segment_size) {
 				nr_phys_segs--;
-			if (blk_hw_contig_segment(rq->q, prevbio, bio))
+				phys_size += prevbio->bi_size + bio->bi_size;
+			} else
+				phys_size = 0;
+
+			if (blk_hw_contig_segment(q, prevbio, bio) &&
+			    hseg <= q->max_segment_size) {
 				nr_hw_segs--;
+				hw_size += prevbio->bi_size + bio->bi_size;
+			} else
+				hw_size = 0;
 		}
 		prevbio = bio;
 	}
@@ -2755,8 +2778,7 @@
 		rq->hard_nr_sectors -= nsect;
 
 		/*
-		 * Move the I/O submission pointers ahead if required,
-		 * i.e. for drivers not aware of rq->cbio.
+		 * Move the I/O submission pointers ahead if required.
 		 */
 		if ((rq->nr_sectors >= rq->hard_nr_sectors) &&
 		    (rq->sector <= rq->hard_sector)) {
@@ -2764,11 +2786,7 @@
 			rq->nr_sectors = rq->hard_nr_sectors;
 			rq->hard_cur_sectors = bio_cur_sectors(rq->bio);
 			rq->current_nr_sectors = rq->hard_cur_sectors;
-			rq->nr_cbio_segments = bio_segments(rq->bio);
-			rq->nr_cbio_sectors = bio_sectors(rq->bio);
 			rq->buffer = bio_data(rq->bio);
-
-			rq->cbio = rq->bio;
 		}
 
 		/*
@@ -2940,12 +2958,12 @@
 		unsigned long duration = jiffies - req->start_time;
 		switch (rq_data_dir(req)) {
 		    case WRITE:
-			disk_stat_inc(disk, writes);
-			disk_stat_add(disk, write_ticks, duration);
+			__disk_stat_inc(disk, writes);
+			__disk_stat_add(disk, write_ticks, duration);
 			break;
 		    case READ:
-			disk_stat_inc(disk, reads);
-			disk_stat_add(disk, read_ticks, duration);
+			__disk_stat_inc(disk, reads);
+			__disk_stat_add(disk, read_ticks, duration);
 			break;
 		}
 		disk_round_stats(disk);
@@ -2980,33 +2998,13 @@
 	rq->current_nr_sectors = bio_cur_sectors(bio);
 	rq->hard_cur_sectors = rq->current_nr_sectors;
 	rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio);
-	rq->nr_cbio_segments = bio_segments(bio);
-	rq->nr_cbio_sectors = bio_sectors(bio);
 	rq->buffer = bio_data(bio);
 
-	rq->cbio = rq->bio = rq->biotail = bio;
+	rq->bio = rq->biotail = bio;
 }
 
 EXPORT_SYMBOL(blk_rq_bio_prep);
 
-void blk_rq_prep_restart(struct request *rq)
-{
-	struct bio *bio;
-
-	bio = rq->cbio = rq->bio;
-	if (bio) {
-		rq->nr_cbio_segments = bio_segments(bio);
-		rq->nr_cbio_sectors = bio_sectors(bio);
-		rq->hard_cur_sectors = bio_cur_sectors(bio);
-		rq->buffer = bio_data(bio);
-	}
-	rq->sector = rq->hard_sector;
-	rq->nr_sectors = rq->hard_nr_sectors;
-	rq->current_nr_sectors = rq->hard_cur_sectors;
-}
-
-EXPORT_SYMBOL(blk_rq_prep_restart);
-
 int kblockd_schedule_work(struct work_struct *work)
 {
 	return queue_work(kblockd_workqueue, work);
@@ -3018,6 +3016,7 @@
 {
 	flush_workqueue(kblockd_workqueue);
 }
+EXPORT_SYMBOL(kblockd_flush);
 
 int __init blk_dev_init(void)
 {
@@ -3036,6 +3035,7 @@
 
 	blk_max_low_pfn = max_low_pfn;
 	blk_max_pfn = max_pfn;
+
 	return 0;
 }
 
@@ -3052,9 +3052,13 @@
 	if (atomic_dec_and_test(&ioc->refcount)) {
 		if (ioc->aic && ioc->aic->dtor)
 			ioc->aic->dtor(ioc->aic);
+		if (ioc->cic && ioc->cic->dtor)
+			ioc->cic->dtor(ioc->cic);
+
 		kmem_cache_free(iocontext_cachep, ioc);
 	}
 }
+EXPORT_SYMBOL(put_io_context);
 
 /* Called by the exitting task */
 void exit_io_context(void)
@@ -3064,14 +3068,15 @@
 
 	local_irq_save(flags);
 	ioc = current->io_context;
-	if (ioc) {
-		if (ioc->aic && ioc->aic->exit)
-			ioc->aic->exit(ioc->aic);
-		put_io_context(ioc);
-		current->io_context = NULL;
-	} else
-		WARN_ON(1);
+	current->io_context = NULL;
 	local_irq_restore(flags);
+
+	if (ioc->aic && ioc->aic->exit)
+		ioc->aic->exit(ioc->aic);
+	if (ioc->cic && ioc->cic->exit)
+		ioc->cic->exit(ioc->cic);
+
+	put_io_context(ioc);
 }
 
 /*
@@ -3090,22 +3095,42 @@
 
 	local_irq_save(flags);
 	ret = tsk->io_context;
-	if (ret == NULL) {
-		ret = kmem_cache_alloc(iocontext_cachep, GFP_ATOMIC);
-		if (ret) {
-			atomic_set(&ret->refcount, 1);
-			ret->pid = tsk->pid;
-			ret->last_waited = jiffies; /* doesn't matter... */
-			ret->nr_batch_requests = 0; /* because this is 0 */
-			ret->aic = NULL;
+	if (ret)
+		goto out;
+
+	local_irq_restore(flags);
+
+	ret = kmem_cache_alloc(iocontext_cachep, gfp_flags);
+	if (ret) {
+		atomic_set(&ret->refcount, 1);
+		ret->pid = tsk->pid;
+		ret->last_waited = jiffies; /* doesn't matter... */
+		ret->nr_batch_requests = 0; /* because this is 0 */
+		ret->aic = NULL;
+		ret->cic = NULL;
+		spin_lock_init(&ret->lock);
+
+		local_irq_save(flags);
+
+		/*
+		 * very unlikely, someone raced with us in setting up the task
+		 * io context. free new context and just grab a reference.
+		 */
+		if (!tsk->io_context)
 			tsk->io_context = ret;
+		else {
+			kmem_cache_free(iocontext_cachep, ret);
+			ret = tsk->io_context;
 		}
-	}
-	if (ret)
+
+out:
 		atomic_inc(&ret->refcount);
-	local_irq_restore(flags);
+		local_irq_restore(flags);
+	}
+
 	return ret;
 }
+EXPORT_SYMBOL(get_io_context);
 
 void copy_io_context(struct io_context **pdst, struct io_context **psrc)
 {
@@ -3119,6 +3144,7 @@
 		*pdst = src;
 	}
 }
+EXPORT_SYMBOL(copy_io_context);
 
 void swap_io_context(struct io_context **ioc1, struct io_context **ioc2)
 {
@@ -3127,7 +3153,7 @@
 	*ioc1 = *ioc2;
 	*ioc2 = temp;
 }
-
+EXPORT_SYMBOL(swap_io_context);
 
 /*
  * sysfs parts below
@@ -3285,11 +3311,18 @@
 	.show = queue_max_hw_sectors_show,
 };
 
+static struct queue_sysfs_entry queue_iosched_entry = {
+	.attr = {.name = "scheduler", .mode = S_IRUGO | S_IWUSR },
+	.show = elv_iosched_show,
+	.store = elv_iosched_store,
+};
+
 static struct attribute *default_attrs[] = {
 	&queue_requests_entry.attr,
 	&queue_ra_entry.attr,
 	&queue_max_hw_sectors_entry.attr,
 	&queue_max_sectors_entry.attr,
+	&queue_iosched_entry.attr,
 	NULL,
 };
 
diff -Nru a/drivers/block/loop.c b/drivers/block/loop.c
--- a/drivers/block/loop.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/block/loop.c	2004-12-24 13:36:59 -08:00
@@ -47,7 +47,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
-
+#include <linux/moduleparam.h>
 #include <linux/sched.h>
 #include <linux/fs.h>
 #include <linux/file.h>
@@ -1073,7 +1073,7 @@
 /*
  * And now the modules code and kernel interface.
  */
-MODULE_PARM(max_loop, "i");
+module_param(max_loop, int, 0);
 MODULE_PARM_DESC(max_loop, "Maximum number of loop devices (1-256)");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
diff -Nru a/drivers/block/noop-iosched.c b/drivers/block/noop-iosched.c
--- a/drivers/block/noop-iosched.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/block/noop-iosched.c	2004-12-24 13:37:01 -08:00
@@ -83,12 +83,31 @@
 	return NULL;
 }
 
-elevator_t elevator_noop = {
-	.elevator_merge_fn		= elevator_noop_merge,
-	.elevator_merge_req_fn		= elevator_noop_merge_requests,
-	.elevator_next_req_fn		= elevator_noop_next_request,
-	.elevator_add_req_fn		= elevator_noop_add_request,
-	.elevator_name			= "noop",
+static struct elevator_type elevator_noop = {
+	.ops = {
+		.elevator_merge_fn		= elevator_noop_merge,
+		.elevator_merge_req_fn		= elevator_noop_merge_requests,
+		.elevator_next_req_fn		= elevator_noop_next_request,
+		.elevator_add_req_fn		= elevator_noop_add_request,
+	},
+	.elevator_name = "noop",
+	.elevator_owner = THIS_MODULE,
 };
 
-EXPORT_SYMBOL(elevator_noop);
+int noop_init(void)
+{
+	return elv_register(&elevator_noop);
+}
+
+void noop_exit(void)
+{
+	elv_unregister(&elevator_noop);
+}
+
+module_init(noop_init);
+module_exit(noop_exit);
+
+
+MODULE_AUTHOR("Jens Axboe");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("No-op IO scheduler");
diff -Nru a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c
--- a/drivers/block/paride/paride.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/block/paride/paride.c	2004-12-24 13:36:18 -08:00
@@ -140,7 +140,7 @@
 #endif
 }
 
-void pi_unclaim(PIA * pi)
+static void pi_unclaim(PIA * pi)
 {
 	pi->claimed = 0;
 #ifdef CONFIG_PARPORT
@@ -148,8 +148,6 @@
 		parport_release((struct pardevice *) (pi->pardev));
 #endif
 }
-
-EXPORT_SYMBOL(pi_unclaim);
 
 void pi_connect(PIA * pi)
 {
diff -Nru a/drivers/block/paride/paride.h b/drivers/block/paride/paride.h
--- a/drivers/block/paride/paride.h	2004-12-24 13:36:33 -08:00
+++ b/drivers/block/paride/paride.h	2004-12-24 13:36:33 -08:00
@@ -88,8 +88,6 @@
 
 extern void pi_read_block(PIA *pi, char * buf, int count);
 
-extern void pi_unclaim(PIA *pi);
-
 extern void pi_connect(PIA *pi);
 
 extern void pi_disconnect(PIA *pi);
diff -Nru a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
--- a/drivers/block/paride/pg.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/block/paride/pg.c	2004-12-24 13:37:18 -08:00
@@ -262,7 +262,7 @@
 		int *parm = *drives[unit];
 		struct pg *dev = &devices[unit];
 		dev->pi = &dev->pia;
-		set_bit(0, &dev->access);
+		clear_bit(0, &dev->access);
 		dev->busy = 0;
 		dev->present = 0;
 		dev->bufptr = NULL;
diff -Nru a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/block/pktcdvd.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2679 @@
+/*
+ * Copyright (C) 2000 Jens Axboe <axboe@suse.de>
+ * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com>
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ * Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and
+ * DVD-RW devices (aka an exercise in block layer masturbation)
+ *
+ *
+ * TODO: (circa order of when I will fix it)
+ * - Only able to write on CD-RW media right now.
+ * - check host application code on media and set it in write page
+ * - interface for UDF <-> packet to negotiate a new location when a write
+ *   fails.
+ * - handle OPC, especially for -RW media
+ *
+ * Theory of operation:
+ *
+ * We use a custom make_request_fn function that forwards reads directly to
+ * the underlying CD device. Write requests are either attached directly to
+ * a live packet_data object, or simply stored sequentially in a list for
+ * later processing by the kcdrwd kernel thread. This driver doesn't use
+ * any elevator functionally as defined by the elevator_s struct, but the
+ * underlying CD device uses a standard elevator.
+ *
+ * This strategy makes it possible to do very late merging of IO requests.
+ * A new bio sent to pkt_make_request can be merged with a live packet_data
+ * object even if the object is in the data gathering state.
+ *
+ *************************************************************************/
+
+#define VERSION_CODE	"v0.2.0a 2004-07-14 Jens Axboe (axboe@suse.de) and petero2@telia.com"
+
+#include <linux/pktcdvd.h>
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/kthread.h>
+#include <linux/errno.h>
+#include <linux/spinlock.h>
+#include <linux/file.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <linux/miscdevice.h>
+#include <linux/suspend.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_ioctl.h>
+
+#include <asm/uaccess.h>
+
+#if PACKET_DEBUG
+#define DPRINTK(fmt, args...) printk(KERN_NOTICE fmt, ##args)
+#else
+#define DPRINTK(fmt, args...)
+#endif
+
+#if PACKET_DEBUG > 1
+#define VPRINTK(fmt, args...) printk(KERN_NOTICE fmt, ##args)
+#else
+#define VPRINTK(fmt, args...)
+#endif
+
+#define MAX_SPEED 0xffff
+
+#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
+
+static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
+static struct proc_dir_entry *pkt_proc;
+static int pkt_major;
+static struct semaphore ctl_mutex;	/* Serialize open/close/setup/teardown */
+static mempool_t *psd_pool;
+
+
+static void pkt_bio_finished(struct pktcdvd_device *pd)
+{
+	BUG_ON(atomic_read(&pd->cdrw.pending_bios) <= 0);
+	if (atomic_dec_and_test(&pd->cdrw.pending_bios)) {
+		VPRINTK("pktcdvd: queue empty\n");
+		atomic_set(&pd->iosched.attention, 1);
+		wake_up(&pd->wqueue);
+	}
+}
+
+static void pkt_bio_destructor(struct bio *bio)
+{
+	kfree(bio->bi_io_vec);
+	kfree(bio);
+}
+
+static struct bio *pkt_bio_alloc(int nr_iovecs)
+{
+	struct bio_vec *bvl = NULL;
+	struct bio *bio;
+
+	bio = kmalloc(sizeof(struct bio), GFP_KERNEL);
+	if (!bio)
+		goto no_bio;
+	bio_init(bio);
+
+	bvl = kmalloc(nr_iovecs * sizeof(struct bio_vec), GFP_KERNEL);
+	if (!bvl)
+		goto no_bvl;
+	memset(bvl, 0, nr_iovecs * sizeof(struct bio_vec));
+
+	bio->bi_max_vecs = nr_iovecs;
+	bio->bi_io_vec = bvl;
+	bio->bi_destructor = pkt_bio_destructor;
+
+	return bio;
+
+ no_bvl:
+	kfree(bio);
+ no_bio:
+	return NULL;
+}
+
+/*
+ * Allocate a packet_data struct
+ */
+static struct packet_data *pkt_alloc_packet_data(void)
+{
+	int i;
+	struct packet_data *pkt;
+
+	pkt = kmalloc(sizeof(struct packet_data), GFP_KERNEL);
+	if (!pkt)
+		goto no_pkt;
+	memset(pkt, 0, sizeof(struct packet_data));
+
+	pkt->w_bio = pkt_bio_alloc(PACKET_MAX_SIZE);
+	if (!pkt->w_bio)
+		goto no_bio;
+
+	for (i = 0; i < PAGES_PER_PACKET; i++) {
+		pkt->pages[i] = alloc_page(GFP_KERNEL);
+		if (!pkt->pages[i])
+			goto no_page;
+	}
+	for (i = 0; i < PAGES_PER_PACKET; i++)
+		clear_page(page_address(pkt->pages[i]));
+
+	spin_lock_init(&pkt->lock);
+
+	for (i = 0; i < PACKET_MAX_SIZE; i++) {
+		struct bio *bio = pkt_bio_alloc(1);
+		if (!bio)
+			goto no_rd_bio;
+		pkt->r_bios[i] = bio;
+	}
+
+	return pkt;
+
+no_rd_bio:
+	for (i = 0; i < PACKET_MAX_SIZE; i++) {
+		struct bio *bio = pkt->r_bios[i];
+		if (bio)
+			bio_put(bio);
+	}
+
+no_page:
+	for (i = 0; i < PAGES_PER_PACKET; i++)
+		if (pkt->pages[i])
+			__free_page(pkt->pages[i]);
+	bio_put(pkt->w_bio);
+no_bio:
+	kfree(pkt);
+no_pkt:
+	return NULL;
+}
+
+/*
+ * Free a packet_data struct
+ */
+static void pkt_free_packet_data(struct packet_data *pkt)
+{
+	int i;
+
+	for (i = 0; i < PACKET_MAX_SIZE; i++) {
+		struct bio *bio = pkt->r_bios[i];
+		if (bio)
+			bio_put(bio);
+	}
+	for (i = 0; i < PAGES_PER_PACKET; i++)
+		__free_page(pkt->pages[i]);
+	bio_put(pkt->w_bio);
+	kfree(pkt);
+}
+
+static void pkt_shrink_pktlist(struct pktcdvd_device *pd)
+{
+	struct packet_data *pkt, *next;
+
+	BUG_ON(!list_empty(&pd->cdrw.pkt_active_list));
+
+	list_for_each_entry_safe(pkt, next, &pd->cdrw.pkt_free_list, list) {
+		pkt_free_packet_data(pkt);
+	}
+}
+
+static int pkt_grow_pktlist(struct pktcdvd_device *pd, int nr_packets)
+{
+	struct packet_data *pkt;
+
+	INIT_LIST_HEAD(&pd->cdrw.pkt_free_list);
+	INIT_LIST_HEAD(&pd->cdrw.pkt_active_list);
+	spin_lock_init(&pd->cdrw.active_list_lock);
+	while (nr_packets > 0) {
+		pkt = pkt_alloc_packet_data();
+		if (!pkt) {
+			pkt_shrink_pktlist(pd);
+			return 0;
+		}
+		pkt->id = nr_packets;
+		pkt->pd = pd;
+		list_add(&pkt->list, &pd->cdrw.pkt_free_list);
+		nr_packets--;
+	}
+	return 1;
+}
+
+static void *pkt_rb_alloc(int gfp_mask, void *data)
+{
+	return kmalloc(sizeof(struct pkt_rb_node), gfp_mask);
+}
+
+static void pkt_rb_free(void *ptr, void *data)
+{
+	kfree(ptr);
+}
+
+static inline struct pkt_rb_node *pkt_rbtree_next(struct pkt_rb_node *node)
+{
+	struct rb_node *n = rb_next(&node->rb_node);
+	if (!n)
+		return NULL;
+	return rb_entry(n, struct pkt_rb_node, rb_node);
+}
+
+static inline void pkt_rbtree_erase(struct pktcdvd_device *pd, struct pkt_rb_node *node)
+{
+	rb_erase(&node->rb_node, &pd->bio_queue);
+	mempool_free(node, pd->rb_pool);
+	pd->bio_queue_size--;
+	BUG_ON(pd->bio_queue_size < 0);
+}
+
+/*
+ * Find the first node in the pd->bio_queue rb tree with a starting sector >= s.
+ */
+static struct pkt_rb_node *pkt_rbtree_find(struct pktcdvd_device *pd, sector_t s)
+{
+	struct rb_node *n = pd->bio_queue.rb_node;
+	struct rb_node *next;
+	struct pkt_rb_node *tmp;
+
+	if (!n) {
+		BUG_ON(pd->bio_queue_size > 0);
+		return NULL;
+	}
+
+	for (;;) {
+		tmp = rb_entry(n, struct pkt_rb_node, rb_node);
+		if (s <= tmp->bio->bi_sector)
+			next = n->rb_left;
+		else
+			next = n->rb_right;
+		if (!next)
+			break;
+		n = next;
+	}
+
+	if (s > tmp->bio->bi_sector) {
+		tmp = pkt_rbtree_next(tmp);
+		if (!tmp)
+			return NULL;
+	}
+	BUG_ON(s > tmp->bio->bi_sector);
+	return tmp;
+}
+
+/*
+ * Insert a node into the pd->bio_queue rb tree.
+ */
+static void pkt_rbtree_insert(struct pktcdvd_device *pd, struct pkt_rb_node *node)
+{
+	struct rb_node **p = &pd->bio_queue.rb_node;
+	struct rb_node *parent = NULL;
+	sector_t s = node->bio->bi_sector;
+	struct pkt_rb_node *tmp;
+
+	while (*p) {
+		parent = *p;
+		tmp = rb_entry(parent, struct pkt_rb_node, rb_node);
+		if (s < tmp->bio->bi_sector)
+			p = &(*p)->rb_left;
+		else
+			p = &(*p)->rb_right;
+	}
+	rb_link_node(&node->rb_node, parent, p);
+	rb_insert_color(&node->rb_node, &pd->bio_queue);
+	pd->bio_queue_size++;
+}
+
+/*
+ * Add a bio to a single linked list defined by its head and tail pointers.
+ */
+static inline void pkt_add_list_last(struct bio *bio, struct bio **list_head, struct bio **list_tail)
+{
+	bio->bi_next = NULL;
+	if (*list_tail) {
+		BUG_ON((*list_head) == NULL);
+		(*list_tail)->bi_next = bio;
+		(*list_tail) = bio;
+	} else {
+		BUG_ON((*list_head) != NULL);
+		(*list_head) = bio;
+		(*list_tail) = bio;
+	}
+}
+
+/*
+ * Remove and return the first bio from a single linked list defined by its
+ * head and tail pointers.
+ */
+static inline struct bio *pkt_get_list_first(struct bio **list_head, struct bio **list_tail)
+{
+	struct bio *bio;
+
+	if (*list_head == NULL)
+		return NULL;
+
+	bio = *list_head;
+	*list_head = bio->bi_next;
+	if (*list_head == NULL)
+		*list_tail = NULL;
+
+	bio->bi_next = NULL;
+	return bio;
+}
+
+/*
+ * Send a packet_command to the underlying block device and
+ * wait for completion.
+ */
+static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *cgc)
+{
+	char sense[SCSI_SENSE_BUFFERSIZE];
+	request_queue_t *q;
+	struct request *rq;
+	DECLARE_COMPLETION(wait);
+	int err = 0;
+
+	q = bdev_get_queue(pd->bdev);
+
+	rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ? WRITE : READ,
+			     __GFP_WAIT);
+	rq->errors = 0;
+	rq->rq_disk = pd->bdev->bd_disk;
+	rq->bio = NULL;
+	rq->buffer = NULL;
+	rq->timeout = 60*HZ;
+	rq->data = cgc->buffer;
+	rq->data_len = cgc->buflen;
+	rq->sense = sense;
+	memset(sense, 0, sizeof(sense));
+	rq->sense_len = 0;
+	rq->flags |= REQ_BLOCK_PC | REQ_HARDBARRIER;
+	if (cgc->quiet)
+		rq->flags |= REQ_QUIET;
+	memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE);
+	if (sizeof(rq->cmd) > CDROM_PACKET_SIZE)
+		memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE);
+
+	rq->ref_count++;
+	rq->flags |= REQ_NOMERGE;
+	rq->waiting = &wait;
+	elv_add_request(q, rq, ELEVATOR_INSERT_BACK, 1);
+	generic_unplug_device(q);
+	wait_for_completion(&wait);
+
+	if (rq->errors)
+		err = -EIO;
+
+	blk_put_request(rq);
+	return err;
+}
+
+/*
+ * A generic sense dump / resolve mechanism should be implemented across
+ * all ATAPI + SCSI devices.
+ */
+static void pkt_dump_sense(struct packet_command *cgc)
+{
+	static char *info[9] = { "No sense", "Recovered error", "Not ready",
+				 "Medium error", "Hardware error", "Illegal request",
+				 "Unit attention", "Data protect", "Blank check" };
+	int i;
+	struct request_sense *sense = cgc->sense;
+
+	printk("pktcdvd:");
+	for (i = 0; i < CDROM_PACKET_SIZE; i++)
+		printk(" %02x", cgc->cmd[i]);
+	printk(" - ");
+
+	if (sense == NULL) {
+		printk("no sense\n");
+		return;
+	}
+
+	printk("sense %02x.%02x.%02x", sense->sense_key, sense->asc, sense->ascq);
+
+	if (sense->sense_key > 8) {
+		printk(" (INVALID)\n");
+		return;
+	}
+
+	printk(" (%s)\n", info[sense->sense_key]);
+}
+
+/*
+ * flush the drive cache to media
+ */
+static int pkt_flush_cache(struct pktcdvd_device *pd)
+{
+	struct packet_command cgc;
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.cmd[0] = GPCMD_FLUSH_CACHE;
+	cgc.quiet = 1;
+
+	/*
+	 * the IMMED bit -- we default to not setting it, although that
+	 * would allow a much faster close, this is safer
+	 */
+#if 0
+	cgc.cmd[1] = 1 << 1;
+#endif
+	return pkt_generic_packet(pd, &cgc);
+}
+
+/*
+ * speed is given as the normal factor, e.g. 4 for 4x
+ */
+static int pkt_set_speed(struct pktcdvd_device *pd, unsigned write_speed, unsigned read_speed)
+{
+	struct packet_command cgc;
+	struct request_sense sense;
+	int ret;
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.sense = &sense;
+	cgc.cmd[0] = GPCMD_SET_SPEED;
+	cgc.cmd[2] = (read_speed >> 8) & 0xff;
+	cgc.cmd[3] = read_speed & 0xff;
+	cgc.cmd[4] = (write_speed >> 8) & 0xff;
+	cgc.cmd[5] = write_speed & 0xff;
+
+	if ((ret = pkt_generic_packet(pd, &cgc)))
+		pkt_dump_sense(&cgc);
+
+	return ret;
+}
+
+/*
+ * Queue a bio for processing by the low-level CD device. Must be called
+ * from process context.
+ */
+static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio, int high_prio_read)
+{
+	spin_lock(&pd->iosched.lock);
+	if (bio_data_dir(bio) == READ) {
+		pkt_add_list_last(bio, &pd->iosched.read_queue,
+				  &pd->iosched.read_queue_tail);
+		if (high_prio_read)
+			pd->iosched.high_prio_read = 1;
+	} else {
+		pkt_add_list_last(bio, &pd->iosched.write_queue,
+				  &pd->iosched.write_queue_tail);
+	}
+	spin_unlock(&pd->iosched.lock);
+
+	atomic_set(&pd->iosched.attention, 1);
+	wake_up(&pd->wqueue);
+}
+
+/*
+ * Process the queued read/write requests. This function handles special
+ * requirements for CDRW drives:
+ * - A cache flush command must be inserted before a read request if the
+ *   previous request was a write.
+ * - Switching between reading and writing is slow, so don't it more often
+ *   than necessary.
+ * - Set the read speed according to current usage pattern. When only reading
+ *   from the device, it's best to use the highest possible read speed, but
+ *   when switching often between reading and writing, it's better to have the
+ *   same read and write speeds.
+ * - Reads originating from user space should have higher priority than reads
+ *   originating from pkt_gather_data, because some process is usually waiting
+ *   on reads of the first kind.
+ */
+static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
+{
+	request_queue_t *q;
+
+	if (atomic_read(&pd->iosched.attention) == 0)
+		return;
+	atomic_set(&pd->iosched.attention, 0);
+
+	q = bdev_get_queue(pd->bdev);
+
+	for (;;) {
+		struct bio *bio;
+		int reads_queued, writes_queued, high_prio_read;
+
+		spin_lock(&pd->iosched.lock);
+		reads_queued = (pd->iosched.read_queue != NULL);
+		writes_queued = (pd->iosched.write_queue != NULL);
+		if (!reads_queued)
+			pd->iosched.high_prio_read = 0;
+		high_prio_read = pd->iosched.high_prio_read;
+		spin_unlock(&pd->iosched.lock);
+
+		if (!reads_queued && !writes_queued)
+			break;
+
+		if (pd->iosched.writing) {
+			if (high_prio_read || (!writes_queued && reads_queued)) {
+				if (atomic_read(&pd->cdrw.pending_bios) > 0) {
+					VPRINTK("pktcdvd: write, waiting\n");
+					break;
+				}
+				pkt_flush_cache(pd);
+				pd->iosched.writing = 0;
+			}
+		} else {
+			if (!reads_queued && writes_queued) {
+				if (atomic_read(&pd->cdrw.pending_bios) > 0) {
+					VPRINTK("pktcdvd: read, waiting\n");
+					break;
+				}
+				pd->iosched.writing = 1;
+			}
+		}
+
+		spin_lock(&pd->iosched.lock);
+		if (pd->iosched.writing) {
+			bio = pkt_get_list_first(&pd->iosched.write_queue,
+						 &pd->iosched.write_queue_tail);
+		} else {
+			bio = pkt_get_list_first(&pd->iosched.read_queue,
+						 &pd->iosched.read_queue_tail);
+		}
+		spin_unlock(&pd->iosched.lock);
+
+		if (!bio)
+			continue;
+
+		if (bio_data_dir(bio) == READ)
+			pd->iosched.successive_reads += bio->bi_size >> 10;
+		else
+			pd->iosched.successive_reads = 0;
+		if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) {
+			if (pd->read_speed == pd->write_speed) {
+				pd->read_speed = MAX_SPEED;
+				pkt_set_speed(pd, pd->write_speed, pd->read_speed);
+			}
+		} else {
+			if (pd->read_speed != pd->write_speed) {
+				pd->read_speed = pd->write_speed;
+				pkt_set_speed(pd, pd->write_speed, pd->read_speed);
+			}
+		}
+
+		atomic_inc(&pd->cdrw.pending_bios);
+		generic_make_request(bio);
+	}
+}
+
+/*
+ * Special care is needed if the underlying block device has a small
+ * max_phys_segments value.
+ */
+static int pkt_set_segment_merging(struct pktcdvd_device *pd, request_queue_t *q)
+{
+	if ((pd->settings.size << 9) / CD_FRAMESIZE <= q->max_phys_segments) {
+		/*
+		 * The cdrom device can handle one segment/frame
+		 */
+		clear_bit(PACKET_MERGE_SEGS, &pd->flags);
+		return 0;
+	} else if ((pd->settings.size << 9) / PAGE_SIZE <= q->max_phys_segments) {
+		/*
+		 * We can handle this case at the expense of some extra memory
+		 * copies during write operations
+		 */
+		set_bit(PACKET_MERGE_SEGS, &pd->flags);
+		return 0;
+	} else {
+		printk("pktcdvd: cdrom max_phys_segments too small\n");
+		return -EIO;
+	}
+}
+
+/*
+ * Copy CD_FRAMESIZE bytes from src_bio into a destination page
+ */
+static void pkt_copy_bio_data(struct bio *src_bio, int seg, int offs,
+			      struct page *dst_page, int dst_offs)
+{
+	unsigned int copy_size = CD_FRAMESIZE;
+
+	while (copy_size > 0) {
+		struct bio_vec *src_bvl = bio_iovec_idx(src_bio, seg);
+		void *vfrom = kmap_atomic(src_bvl->bv_page, KM_USER0) +
+			src_bvl->bv_offset + offs;
+		void *vto = page_address(dst_page) + dst_offs;
+		int len = min_t(int, copy_size, src_bvl->bv_len - offs);
+
+		BUG_ON(len < 0);
+		memcpy(vto, vfrom, len);
+		kunmap_atomic(vfrom, KM_USER0);
+
+		seg++;
+		offs = 0;
+		dst_offs += len;
+		copy_size -= len;
+	}
+}
+
+/*
+ * Copy all data for this packet to pkt->pages[], so that
+ * a) The number of required segments for the write bio is minimized, which
+ *    is necessary for some scsi controllers.
+ * b) The data can be used as cache to avoid read requests if we receive a
+ *    new write request for the same zone.
+ */
+static void pkt_make_local_copy(struct packet_data *pkt, struct page **pages, int *offsets)
+{
+	int f, p, offs;
+
+	/* Copy all data to pkt->pages[] */
+	p = 0;
+	offs = 0;
+	for (f = 0; f < pkt->frames; f++) {
+		if (pages[f] != pkt->pages[p]) {
+			void *vfrom = kmap_atomic(pages[f], KM_USER0) + offsets[f];
+			void *vto = page_address(pkt->pages[p]) + offs;
+			memcpy(vto, vfrom, CD_FRAMESIZE);
+			kunmap_atomic(vfrom, KM_USER0);
+			pages[f] = pkt->pages[p];
+			offsets[f] = offs;
+		} else {
+			BUG_ON(offsets[f] != offs);
+		}
+		offs += CD_FRAMESIZE;
+		if (offs >= PAGE_SIZE) {
+			BUG_ON(offs > PAGE_SIZE);
+			offs = 0;
+			p++;
+		}
+	}
+}
+
+static int pkt_end_io_read(struct bio *bio, unsigned int bytes_done, int err)
+{
+	struct packet_data *pkt = bio->bi_private;
+	struct pktcdvd_device *pd = pkt->pd;
+	BUG_ON(!pd);
+
+	if (bio->bi_size)
+		return 1;
+
+	VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
+		(unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);
+
+	if (err)
+		atomic_inc(&pkt->io_errors);
+	if (atomic_dec_and_test(&pkt->io_wait)) {
+		atomic_inc(&pkt->run_sm);
+		wake_up(&pd->wqueue);
+	}
+	pkt_bio_finished(pd);
+
+	return 0;
+}
+
+static int pkt_end_io_packet_write(struct bio *bio, unsigned int bytes_done, int err)
+{
+	struct packet_data *pkt = bio->bi_private;
+	struct pktcdvd_device *pd = pkt->pd;
+	BUG_ON(!pd);
+
+	if (bio->bi_size)
+		return 1;
+
+	VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);
+
+	pd->stats.pkt_ended++;
+
+	pkt_bio_finished(pd);
+	atomic_dec(&pkt->io_wait);
+	atomic_inc(&pkt->run_sm);
+	wake_up(&pd->wqueue);
+	return 0;
+}
+
+/*
+ * Schedule reads for the holes in a packet
+ */
+static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
+{
+	int frames_read = 0;
+	struct bio *bio;
+	int f;
+	char written[PACKET_MAX_SIZE];
+
+	BUG_ON(!pkt->orig_bios);
+
+	atomic_set(&pkt->io_wait, 0);
+	atomic_set(&pkt->io_errors, 0);
+
+	if (pkt->cache_valid) {
+		VPRINTK("pkt_gather_data: zone %llx cached\n",
+			(unsigned long long)pkt->sector);
+		goto out_account;
+	}
+
+	/*
+	 * Figure out which frames we need to read before we can write.
+	 */
+	memset(written, 0, sizeof(written));
+	spin_lock(&pkt->lock);
+	for (bio = pkt->orig_bios; bio; bio = bio->bi_next) {
+		int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9);
+		int num_frames = bio->bi_size / CD_FRAMESIZE;
+		BUG_ON(first_frame < 0);
+		BUG_ON(first_frame + num_frames > pkt->frames);
+		for (f = first_frame; f < first_frame + num_frames; f++)
+			written[f] = 1;
+	}
+	spin_unlock(&pkt->lock);
+
+	/*
+	 * Schedule reads for missing parts of the packet.
+	 */
+	for (f = 0; f < pkt->frames; f++) {
+		int p, offset;
+		if (written[f])
+			continue;
+		bio = pkt->r_bios[f];
+		bio_init(bio);
+		bio->bi_max_vecs = 1;
+		bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
+		bio->bi_bdev = pd->bdev;
+		bio->bi_end_io = pkt_end_io_read;
+		bio->bi_private = pkt;
+
+		p = (f * CD_FRAMESIZE) / PAGE_SIZE;
+		offset = (f * CD_FRAMESIZE) % PAGE_SIZE;
+		VPRINTK("pkt_gather_data: Adding frame %d, page:%p offs:%d\n",
+			f, pkt->pages[p], offset);
+		if (!bio_add_page(bio, pkt->pages[p], CD_FRAMESIZE, offset))
+			BUG();
+
+		atomic_inc(&pkt->io_wait);
+		bio->bi_rw = READ;
+		pkt_queue_bio(pd, bio, 0);
+		frames_read++;
+	}
+
+out_account:
+	VPRINTK("pkt_gather_data: need %d frames for zone %llx\n",
+		frames_read, (unsigned long long)pkt->sector);
+	pd->stats.pkt_started++;
+	pd->stats.secs_rg += frames_read * (CD_FRAMESIZE >> 9);
+	pd->stats.secs_w += pd->settings.size;
+}
+
+/*
+ * Find a packet matching zone, or the least recently used packet if
+ * there is no match.
+ */
+static struct packet_data *pkt_get_packet_data(struct pktcdvd_device *pd, int zone)
+{
+	struct packet_data *pkt;
+
+	list_for_each_entry(pkt, &pd->cdrw.pkt_free_list, list) {
+		if (pkt->sector == zone || pkt->list.next == &pd->cdrw.pkt_free_list) {
+			list_del_init(&pkt->list);
+			if (pkt->sector != zone)
+				pkt->cache_valid = 0;
+			break;
+		}
+	}
+	return pkt;
+}
+
+static void pkt_put_packet_data(struct pktcdvd_device *pd, struct packet_data *pkt)
+{
+	if (pkt->cache_valid) {
+		list_add(&pkt->list, &pd->cdrw.pkt_free_list);
+	} else {
+		list_add_tail(&pkt->list, &pd->cdrw.pkt_free_list);
+	}
+}
+
+/*
+ * recover a failed write, query for relocation if possible
+ *
+ * returns 1 if recovery is possible, or 0 if not
+ *
+ */
+static int pkt_start_recovery(struct packet_data *pkt)
+{
+	/*
+	 * FIXME. We need help from the file system to implement
+	 * recovery handling.
+	 */
+	return 0;
+#if 0
+	struct request *rq = pkt->rq;
+	struct pktcdvd_device *pd = rq->rq_disk->private_data;
+	struct block_device *pkt_bdev;
+	struct super_block *sb = NULL;
+	unsigned long old_block, new_block;
+	sector_t new_sector;
+
+	pkt_bdev = bdget(kdev_t_to_nr(pd->pkt_dev));
+	if (pkt_bdev) {
+		sb = get_super(pkt_bdev);
+		bdput(pkt_bdev);
+	}
+
+	if (!sb)
+		return 0;
+
+	if (!sb->s_op || !sb->s_op->relocate_blocks)
+		goto out;
+
+	old_block = pkt->sector / (CD_FRAMESIZE >> 9);
+	if (sb->s_op->relocate_blocks(sb, old_block, &new_block))
+		goto out;
+
+	new_sector = new_block * (CD_FRAMESIZE >> 9);
+	pkt->sector = new_sector;
+
+	pkt->bio->bi_sector = new_sector;
+	pkt->bio->bi_next = NULL;
+	pkt->bio->bi_flags = 1 << BIO_UPTODATE;
+	pkt->bio->bi_idx = 0;
+
+	BUG_ON(pkt->bio->bi_rw != (1 << BIO_RW));
+	BUG_ON(pkt->bio->bi_vcnt != pkt->frames);
+	BUG_ON(pkt->bio->bi_size != pkt->frames * CD_FRAMESIZE);
+	BUG_ON(pkt->bio->bi_end_io != pkt_end_io_packet_write);
+	BUG_ON(pkt->bio->bi_private != pkt);
+
+	drop_super(sb);
+	return 1;
+
+out:
+	drop_super(sb);
+	return 0;
+#endif
+}
+
+static inline void pkt_set_state(struct packet_data *pkt, enum packet_data_state state)
+{
+#if PACKET_DEBUG > 1
+	static const char *state_name[] = {
+		"IDLE", "WAITING", "READ_WAIT", "WRITE_WAIT", "RECOVERY", "FINISHED"
+	};
+	enum packet_data_state old_state = pkt->state;
+	VPRINTK("pkt %2d : s=%6llx %s -> %s\n", pkt->id, (unsigned long long)pkt->sector,
+		state_name[old_state], state_name[state]);
+#endif
+	pkt->state = state;
+}
+
+/*
+ * Scan the work queue to see if we can start a new packet.
+ * returns non-zero if any work was done.
+ */
+static int pkt_handle_queue(struct pktcdvd_device *pd)
+{
+	struct packet_data *pkt, *p;
+	struct bio *bio = NULL;
+	sector_t zone = 0; /* Suppress gcc warning */
+	struct pkt_rb_node *node, *first_node;
+	struct rb_node *n;
+
+	VPRINTK("handle_queue\n");
+
+	atomic_set(&pd->scan_queue, 0);
+
+	if (list_empty(&pd->cdrw.pkt_free_list)) {
+		VPRINTK("handle_queue: no pkt\n");
+		return 0;
+	}
+
+	/*
+	 * Try to find a zone we are not already working on.
+	 */
+	spin_lock(&pd->lock);
+	first_node = pkt_rbtree_find(pd, pd->current_sector);
+	if (!first_node) {
+		n = rb_first(&pd->bio_queue);
+		if (n)
+			first_node = rb_entry(n, struct pkt_rb_node, rb_node);
+	}
+	node = first_node;
+	while (node) {
+		bio = node->bio;
+		zone = ZONE(bio->bi_sector, pd);
+		list_for_each_entry(p, &pd->cdrw.pkt_active_list, list) {
+			if (p->sector == zone)
+				goto try_next_bio;
+		}
+		break;
+try_next_bio:
+		node = pkt_rbtree_next(node);
+		if (!node) {
+			n = rb_first(&pd->bio_queue);
+			if (n)
+				node = rb_entry(n, struct pkt_rb_node, rb_node);
+		}
+		if (node == first_node)
+			node = NULL;
+	}
+	spin_unlock(&pd->lock);
+	if (!bio) {
+		VPRINTK("handle_queue: no bio\n");
+		return 0;
+	}
+
+	pkt = pkt_get_packet_data(pd, zone);
+	BUG_ON(!pkt);
+
+	pd->current_sector = zone + pd->settings.size;
+	pkt->sector = zone;
+	pkt->frames = pd->settings.size >> 2;
+	BUG_ON(pkt->frames > PACKET_MAX_SIZE);
+	pkt->write_size = 0;
+
+	/*
+	 * Scan work queue for bios in the same zone and link them
+	 * to this packet.
+	 */
+	spin_lock(&pd->lock);
+	VPRINTK("pkt_handle_queue: looking for zone %llx\n", (unsigned long long)zone);
+	while ((node = pkt_rbtree_find(pd, zone)) != NULL) {
+		bio = node->bio;
+		VPRINTK("pkt_handle_queue: found zone=%llx\n",
+			(unsigned long long)ZONE(bio->bi_sector, pd));
+		if (ZONE(bio->bi_sector, pd) != zone)
+			break;
+		pkt_rbtree_erase(pd, node);
+		spin_lock(&pkt->lock);
+		pkt_add_list_last(bio, &pkt->orig_bios, &pkt->orig_bios_tail);
+		pkt->write_size += bio->bi_size / CD_FRAMESIZE;
+		spin_unlock(&pkt->lock);
+	}
+	spin_unlock(&pd->lock);
+
+	pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
+	pkt_set_state(pkt, PACKET_WAITING_STATE);
+	atomic_set(&pkt->run_sm, 1);
+
+	spin_lock(&pd->cdrw.active_list_lock);
+	list_add(&pkt->list, &pd->cdrw.pkt_active_list);
+	spin_unlock(&pd->cdrw.active_list_lock);
+
+	return 1;
+}
+
+/*
+ * Assemble a bio to write one packet and queue the bio for processing
+ * by the underlying block device.
+ */
+static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
+{
+	struct bio *bio;
+	struct page *pages[PACKET_MAX_SIZE];
+	int offsets[PACKET_MAX_SIZE];
+	int f;
+	int frames_write;
+
+	for (f = 0; f < pkt->frames; f++) {
+		pages[f] = pkt->pages[(f * CD_FRAMESIZE) / PAGE_SIZE];
+		offsets[f] = (f * CD_FRAMESIZE) % PAGE_SIZE;
+	}
+
+	/*
+	 * Fill-in pages[] and offsets[] with data from orig_bios.
+	 */
+	frames_write = 0;
+	spin_lock(&pkt->lock);
+	for (bio = pkt->orig_bios; bio; bio = bio->bi_next) {
+		int segment = bio->bi_idx;
+		int src_offs = 0;
+		int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9);
+		int num_frames = bio->bi_size / CD_FRAMESIZE;
+		BUG_ON(first_frame < 0);
+		BUG_ON(first_frame + num_frames > pkt->frames);
+		for (f = first_frame; f < first_frame + num_frames; f++) {
+			struct bio_vec *src_bvl = bio_iovec_idx(bio, segment);
+
+			while (src_offs >= src_bvl->bv_len) {
+				src_offs -= src_bvl->bv_len;
+				segment++;
+				BUG_ON(segment >= bio->bi_vcnt);
+				src_bvl = bio_iovec_idx(bio, segment);
+			}
+
+			if (src_bvl->bv_len - src_offs >= CD_FRAMESIZE) {
+				pages[f] = src_bvl->bv_page;
+				offsets[f] = src_bvl->bv_offset + src_offs;
+			} else {
+				pkt_copy_bio_data(bio, segment, src_offs,
+						  pages[f], offsets[f]);
+			}
+			src_offs += CD_FRAMESIZE;
+			frames_write++;
+		}
+	}
+	pkt_set_state(pkt, PACKET_WRITE_WAIT_STATE);
+	spin_unlock(&pkt->lock);
+
+	VPRINTK("pkt_start_write: Writing %d frames for zone %llx\n",
+		frames_write, (unsigned long long)pkt->sector);
+	BUG_ON(frames_write != pkt->write_size);
+
+	if (test_bit(PACKET_MERGE_SEGS, &pd->flags) || (pkt->write_size < pkt->frames)) {
+		pkt_make_local_copy(pkt, pages, offsets);
+		pkt->cache_valid = 1;
+	} else {
+		pkt->cache_valid = 0;
+	}
+
+	/* Start the write request */
+	bio_init(pkt->w_bio);
+	pkt->w_bio->bi_max_vecs = PACKET_MAX_SIZE;
+	pkt->w_bio->bi_sector = pkt->sector;
+	pkt->w_bio->bi_bdev = pd->bdev;
+	pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
+	pkt->w_bio->bi_private = pkt;
+	for (f = 0; f < pkt->frames; f++) {
+		if ((f + 1 < pkt->frames) && (pages[f + 1] == pages[f]) &&
+		    (offsets[f + 1] = offsets[f] + CD_FRAMESIZE)) {
+			if (!bio_add_page(pkt->w_bio, pages[f], CD_FRAMESIZE * 2, offsets[f]))
+				BUG();
+			f++;
+		} else {
+			if (!bio_add_page(pkt->w_bio, pages[f], CD_FRAMESIZE, offsets[f]))
+				BUG();
+		}
+	}
+	VPRINTK("pktcdvd: vcnt=%d\n", pkt->w_bio->bi_vcnt);
+
+	atomic_set(&pkt->io_wait, 1);
+	pkt->w_bio->bi_rw = WRITE;
+	pkt_queue_bio(pd, pkt->w_bio, 0);
+}
+
+static void pkt_finish_packet(struct packet_data *pkt, int uptodate)
+{
+	struct bio *bio, *next;
+
+	if (!uptodate)
+		pkt->cache_valid = 0;
+
+	/* Finish all bios corresponding to this packet */
+	bio = pkt->orig_bios;
+	while (bio) {
+		next = bio->bi_next;
+		bio->bi_next = NULL;
+		bio_endio(bio, bio->bi_size, uptodate ? 0 : -EIO);
+		bio = next;
+	}
+	pkt->orig_bios = pkt->orig_bios_tail = NULL;
+}
+
+static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_data *pkt)
+{
+	int uptodate;
+
+	VPRINTK("run_state_machine: pkt %d\n", pkt->id);
+
+	for (;;) {
+		switch (pkt->state) {
+		case PACKET_WAITING_STATE:
+			if ((pkt->write_size < pkt->frames) && (pkt->sleep_time > 0))
+				return;
+
+			pkt->sleep_time = 0;
+			pkt_gather_data(pd, pkt);
+			pkt_set_state(pkt, PACKET_READ_WAIT_STATE);
+			break;
+
+		case PACKET_READ_WAIT_STATE:
+			if (atomic_read(&pkt->io_wait) > 0)
+				return;
+
+			if (atomic_read(&pkt->io_errors) > 0) {
+				pkt_set_state(pkt, PACKET_RECOVERY_STATE);
+			} else {
+				pkt_start_write(pd, pkt);
+			}
+			break;
+
+		case PACKET_WRITE_WAIT_STATE:
+			if (atomic_read(&pkt->io_wait) > 0)
+				return;
+
+			if (test_bit(BIO_UPTODATE, &pkt->w_bio->bi_flags)) {
+				pkt_set_state(pkt, PACKET_FINISHED_STATE);
+			} else {
+				pkt_set_state(pkt, PACKET_RECOVERY_STATE);
+			}
+			break;
+
+		case PACKET_RECOVERY_STATE:
+			if (pkt_start_recovery(pkt)) {
+				pkt_start_write(pd, pkt);
+			} else {
+				VPRINTK("No recovery possible\n");
+				pkt_set_state(pkt, PACKET_FINISHED_STATE);
+			}
+			break;
+
+		case PACKET_FINISHED_STATE:
+			uptodate = test_bit(BIO_UPTODATE, &pkt->w_bio->bi_flags);
+			pkt_finish_packet(pkt, uptodate);
+			return;
+
+		default:
+			BUG();
+			break;
+		}
+	}
+}
+
+static void pkt_handle_packets(struct pktcdvd_device *pd)
+{
+	struct packet_data *pkt, *next;
+
+	VPRINTK("pkt_handle_packets\n");
+
+	/*
+	 * Run state machine for active packets
+	 */
+	list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
+		if (atomic_read(&pkt->run_sm) > 0) {
+			atomic_set(&pkt->run_sm, 0);
+			pkt_run_state_machine(pd, pkt);
+		}
+	}
+
+	/*
+	 * Move no longer active packets to the free list
+	 */
+	spin_lock(&pd->cdrw.active_list_lock);
+	list_for_each_entry_safe(pkt, next, &pd->cdrw.pkt_active_list, list) {
+		if (pkt->state == PACKET_FINISHED_STATE) {
+			list_del(&pkt->list);
+			pkt_put_packet_data(pd, pkt);
+			pkt_set_state(pkt, PACKET_IDLE_STATE);
+			atomic_set(&pd->scan_queue, 1);
+		}
+	}
+	spin_unlock(&pd->cdrw.active_list_lock);
+}
+
+static void pkt_count_states(struct pktcdvd_device *pd, int *states)
+{
+	struct packet_data *pkt;
+	int i;
+
+	for (i = 0; i <= PACKET_NUM_STATES; i++)
+		states[i] = 0;
+
+	spin_lock(&pd->cdrw.active_list_lock);
+	list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
+		states[pkt->state]++;
+	}
+	spin_unlock(&pd->cdrw.active_list_lock);
+}
+
+/*
+ * kcdrwd is woken up when writes have been queued for one of our
+ * registered devices
+ */
+static int kcdrwd(void *foobar)
+{
+	struct pktcdvd_device *pd = foobar;
+	struct packet_data *pkt;
+	long min_sleep_time, residue;
+
+	set_user_nice(current, -20);
+
+	for (;;) {
+		DECLARE_WAITQUEUE(wait, current);
+
+		/*
+		 * Wait until there is something to do
+		 */
+		add_wait_queue(&pd->wqueue, &wait);
+		for (;;) {
+			set_current_state(TASK_INTERRUPTIBLE);
+
+			/* Check if we need to run pkt_handle_queue */
+			if (atomic_read(&pd->scan_queue) > 0)
+				goto work_to_do;
+
+			/* Check if we need to run the state machine for some packet */
+			list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
+				if (atomic_read(&pkt->run_sm) > 0)
+					goto work_to_do;
+			}
+
+			/* Check if we need to process the iosched queues */
+			if (atomic_read(&pd->iosched.attention) != 0)
+				goto work_to_do;
+
+			/* Otherwise, go to sleep */
+			if (PACKET_DEBUG > 1) {
+				int states[PACKET_NUM_STATES];
+				pkt_count_states(pd, states);
+				VPRINTK("kcdrwd: i:%d ow:%d rw:%d ww:%d rec:%d fin:%d\n",
+					states[0], states[1], states[2], states[3],
+					states[4], states[5]);
+			}
+
+			min_sleep_time = MAX_SCHEDULE_TIMEOUT;
+			list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
+				if (pkt->sleep_time && pkt->sleep_time < min_sleep_time)
+					min_sleep_time = pkt->sleep_time;
+			}
+
+			generic_unplug_device(bdev_get_queue(pd->bdev));
+
+			VPRINTK("kcdrwd: sleeping\n");
+			residue = schedule_timeout(min_sleep_time);
+			VPRINTK("kcdrwd: wake up\n");
+
+			/* make swsusp happy with our thread */
+			if (current->flags & PF_FREEZE)
+				refrigerator(PF_FREEZE);
+
+			list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
+				if (!pkt->sleep_time)
+					continue;
+				pkt->sleep_time -= min_sleep_time - residue;
+				if (pkt->sleep_time <= 0) {
+					pkt->sleep_time = 0;
+					atomic_inc(&pkt->run_sm);
+				}
+			}
+
+			if (signal_pending(current)) {
+				flush_signals(current);
+			}
+			if (kthread_should_stop())
+				break;
+		}
+work_to_do:
+		set_current_state(TASK_RUNNING);
+		remove_wait_queue(&pd->wqueue, &wait);
+
+		if (kthread_should_stop())
+			break;
+
+		/*
+		 * if pkt_handle_queue returns true, we can queue
+		 * another request.
+		 */
+		while (pkt_handle_queue(pd))
+			;
+
+		/*
+		 * Handle packet state machine
+		 */
+		pkt_handle_packets(pd);
+
+		/*
+		 * Handle iosched queues
+		 */
+		pkt_iosched_process_queue(pd);
+	}
+
+	return 0;
+}
+
+static void pkt_print_settings(struct pktcdvd_device *pd)
+{
+	printk("pktcdvd: %s packets, ", pd->settings.fp ? "Fixed" : "Variable");
+	printk("%u blocks, ", pd->settings.size >> 2);
+	printk("Mode-%c disc\n", pd->settings.block_mode == 8 ? '1' : '2');
+}
+
+static int pkt_mode_sense(struct pktcdvd_device *pd, struct packet_command *cgc,
+			  int page_code, int page_control)
+{
+	memset(cgc->cmd, 0, sizeof(cgc->cmd));
+
+	cgc->cmd[0] = GPCMD_MODE_SENSE_10;
+	cgc->cmd[2] = page_code | (page_control << 6);
+	cgc->cmd[7] = cgc->buflen >> 8;
+	cgc->cmd[8] = cgc->buflen & 0xff;
+	cgc->data_direction = CGC_DATA_READ;
+	return pkt_generic_packet(pd, cgc);
+}
+
+static int pkt_mode_select(struct pktcdvd_device *pd, struct packet_command *cgc)
+{
+	memset(cgc->cmd, 0, sizeof(cgc->cmd));
+	memset(cgc->buffer, 0, 2);
+	cgc->cmd[0] = GPCMD_MODE_SELECT_10;
+	cgc->cmd[1] = 0x10;		/* PF */
+	cgc->cmd[7] = cgc->buflen >> 8;
+	cgc->cmd[8] = cgc->buflen & 0xff;
+	cgc->data_direction = CGC_DATA_WRITE;
+	return pkt_generic_packet(pd, cgc);
+}
+
+static int pkt_get_disc_info(struct pktcdvd_device *pd, disc_information *di)
+{
+	struct packet_command cgc;
+	int ret;
+
+	/* set up command and get the disc info */
+	init_cdrom_command(&cgc, di, sizeof(*di), CGC_DATA_READ);
+	cgc.cmd[0] = GPCMD_READ_DISC_INFO;
+	cgc.cmd[8] = cgc.buflen = 2;
+	cgc.quiet = 1;
+
+	if ((ret = pkt_generic_packet(pd, &cgc)))
+		return ret;
+
+	/* not all drives have the same disc_info length, so requeue
+	 * packet with the length the drive tells us it can supply
+	 */
+	cgc.buflen = be16_to_cpu(di->disc_information_length) +
+		     sizeof(di->disc_information_length);
+
+	if (cgc.buflen > sizeof(disc_information))
+		cgc.buflen = sizeof(disc_information);
+
+	cgc.cmd[8] = cgc.buflen;
+	return pkt_generic_packet(pd, &cgc);
+}
+
+static int pkt_get_track_info(struct pktcdvd_device *pd, __u16 track, __u8 type, track_information *ti)
+{
+	struct packet_command cgc;
+	int ret;
+
+	init_cdrom_command(&cgc, ti, 8, CGC_DATA_READ);
+	cgc.cmd[0] = GPCMD_READ_TRACK_RZONE_INFO;
+	cgc.cmd[1] = type & 3;
+	cgc.cmd[4] = (track & 0xff00) >> 8;
+	cgc.cmd[5] = track & 0xff;
+	cgc.cmd[8] = 8;
+	cgc.quiet = 1;
+
+	if ((ret = pkt_generic_packet(pd, &cgc)))
+		return ret;
+
+	cgc.buflen = be16_to_cpu(ti->track_information_length) +
+		     sizeof(ti->track_information_length);
+
+	if (cgc.buflen > sizeof(track_information))
+		cgc.buflen = sizeof(track_information);
+
+	cgc.cmd[8] = cgc.buflen;
+	return pkt_generic_packet(pd, &cgc);
+}
+
+static int pkt_get_last_written(struct pktcdvd_device *pd, long *last_written)
+{
+	disc_information di;
+	track_information ti;
+	__u32 last_track;
+	int ret = -1;
+
+	if ((ret = pkt_get_disc_info(pd, &di)))
+		return ret;
+
+	last_track = (di.last_track_msb << 8) | di.last_track_lsb;
+	if ((ret = pkt_get_track_info(pd, last_track, 1, &ti)))
+		return ret;
+
+	/* if this track is blank, try the previous. */
+	if (ti.blank) {
+		last_track--;
+		if ((ret = pkt_get_track_info(pd, last_track, 1, &ti)))
+			return ret;
+	}
+
+	/* if last recorded field is valid, return it. */
+	if (ti.lra_v) {
+		*last_written = be32_to_cpu(ti.last_rec_address);
+	} else {
+		/* make it up instead */
+		*last_written = be32_to_cpu(ti.track_start) +
+				be32_to_cpu(ti.track_size);
+		if (ti.free_blocks)
+			*last_written -= (be32_to_cpu(ti.free_blocks) + 7);
+	}
+	return 0;
+}
+
+/*
+ * write mode select package based on pd->settings
+ */
+static int pkt_set_write_settings(struct pktcdvd_device *pd)
+{
+	struct packet_command cgc;
+	struct request_sense sense;
+	write_param_page *wp;
+	char buffer[128];
+	int ret, size;
+
+	/* doesn't apply to DVD+RW */
+	if (pd->mmc3_profile == 0x1a)
+		return 0;
+
+	memset(buffer, 0, sizeof(buffer));
+	init_cdrom_command(&cgc, buffer, sizeof(*wp), CGC_DATA_READ);
+	cgc.sense = &sense;
+	if ((ret = pkt_mode_sense(pd, &cgc, GPMODE_WRITE_PARMS_PAGE, 0))) {
+		pkt_dump_sense(&cgc);
+		return ret;
+	}
+
+	size = 2 + ((buffer[0] << 8) | (buffer[1] & 0xff));
+	pd->mode_offset = (buffer[6] << 8) | (buffer[7] & 0xff);
+	if (size > sizeof(buffer))
+		size = sizeof(buffer);
+
+	/*
+	 * now get it all
+	 */
+	init_cdrom_command(&cgc, buffer, size, CGC_DATA_READ);
+	cgc.sense = &sense;
+	if ((ret = pkt_mode_sense(pd, &cgc, GPMODE_WRITE_PARMS_PAGE, 0))) {
+		pkt_dump_sense(&cgc);
+		return ret;
+	}
+
+	/*
+	 * write page is offset header + block descriptor length
+	 */
+	wp = (write_param_page *) &buffer[sizeof(struct mode_page_header) + pd->mode_offset];
+
+	wp->fp = pd->settings.fp;
+	wp->track_mode = pd->settings.track_mode;
+	wp->write_type = pd->settings.write_type;
+	wp->data_block_type = pd->settings.block_mode;
+
+	wp->multi_session = 0;
+
+#ifdef PACKET_USE_LS
+	wp->link_size = 7;
+	wp->ls_v = 1;
+#endif
+
+	if (wp->data_block_type == PACKET_BLOCK_MODE1) {
+		wp->session_format = 0;
+		wp->subhdr2 = 0x20;
+	} else if (wp->data_block_type == PACKET_BLOCK_MODE2) {
+		wp->session_format = 0x20;
+		wp->subhdr2 = 8;
+#if 0
+		wp->mcn[0] = 0x80;
+		memcpy(&wp->mcn[1], PACKET_MCN, sizeof(wp->mcn) - 1);
+#endif
+	} else {
+		/*
+		 * paranoia
+		 */
+		printk("pktcdvd: write mode wrong %d\n", wp->data_block_type);
+		return 1;
+	}
+	wp->packet_size = cpu_to_be32(pd->settings.size >> 2);
+
+	cgc.buflen = cgc.cmd[8] = size;
+	if ((ret = pkt_mode_select(pd, &cgc))) {
+		pkt_dump_sense(&cgc);
+		return ret;
+	}
+
+	pkt_print_settings(pd);
+	return 0;
+}
+
+/*
+ * 0 -- we can write to this track, 1 -- we can't
+ */
+static int pkt_good_track(track_information *ti)
+{
+	/*
+	 * only good for CD-RW at the moment, not DVD-RW
+	 */
+
+	/*
+	 * FIXME: only for FP
+	 */
+	if (ti->fp == 0)
+		return 0;
+
+	/*
+	 * "good" settings as per Mt Fuji.
+	 */
+	if (ti->rt == 0 && ti->blank == 0 && ti->packet == 1)
+		return 0;
+
+	if (ti->rt == 0 && ti->blank == 1 && ti->packet == 1)
+		return 0;
+
+	if (ti->rt == 1 && ti->blank == 0 && ti->packet == 1)
+		return 0;
+
+	printk("pktcdvd: bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet);
+	return 1;
+}
+
+/*
+ * 0 -- we can write to this disc, 1 -- we can't
+ */
+static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di)
+{
+	switch (pd->mmc3_profile) {
+		case 0x0a: /* CD-RW */
+		case 0xffff: /* MMC3 not supported */
+			break;
+		case 0x1a: /* DVD+RW */
+		case 0x13: /* DVD-RW */
+			return 0;
+		default:
+			printk("pktcdvd: Wrong disc profile (%x)\n", pd->mmc3_profile);
+			return 1;
+	}
+
+	/*
+	 * for disc type 0xff we should probably reserve a new track.
+	 * but i'm not sure, should we leave this to user apps? probably.
+	 */
+	if (di->disc_type == 0xff) {
+		printk("pktcdvd: Unknown disc. No track?\n");
+		return 1;
+	}
+
+	if (di->disc_type != 0x20 && di->disc_type != 0) {
+		printk("pktcdvd: Wrong disc type (%x)\n", di->disc_type);
+		return 1;
+	}
+
+	if (di->erasable == 0) {
+		printk("pktcdvd: Disc not erasable\n");
+		return 1;
+	}
+
+	if (di->border_status == PACKET_SESSION_RESERVED) {
+		printk("pktcdvd: Can't write to last track (reserved)\n");
+		return 1;
+	}
+
+	return 0;
+}
+
+static int pkt_probe_settings(struct pktcdvd_device *pd)
+{
+	struct packet_command cgc;
+	unsigned char buf[12];
+	disc_information di;
+	track_information ti;
+	int ret, track;
+
+	init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ);
+	cgc.cmd[0] = GPCMD_GET_CONFIGURATION;
+	cgc.cmd[8] = 8;
+	ret = pkt_generic_packet(pd, &cgc);
+	pd->mmc3_profile = ret ? 0xffff : buf[6] << 8 | buf[7];
+
+	memset(&di, 0, sizeof(disc_information));
+	memset(&ti, 0, sizeof(track_information));
+
+	if ((ret = pkt_get_disc_info(pd, &di))) {
+		printk("failed get_disc\n");
+		return ret;
+	}
+
+	if (pkt_good_disc(pd, &di))
+		return -ENXIO;
+
+	switch (pd->mmc3_profile) {
+		case 0x1a: /* DVD+RW */
+			printk("pktcdvd: inserted media is DVD+RW\n");
+			break;
+		case 0x13: /* DVD-RW */
+			printk("pktcdvd: inserted media is DVD-RW\n");
+			break;
+		default:
+			printk("pktcdvd: inserted media is CD-R%s\n", di.erasable ? "W" : "");
+			break;
+	}
+	pd->type = di.erasable ? PACKET_CDRW : PACKET_CDR;
+
+	track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */
+	if ((ret = pkt_get_track_info(pd, track, 1, &ti))) {
+		printk("pktcdvd: failed get_track\n");
+		return ret;
+	}
+
+	if (pkt_good_track(&ti)) {
+		printk("pktcdvd: can't write to this track\n");
+		return -ENXIO;
+	}
+
+	/*
+	 * we keep packet size in 512 byte units, makes it easier to
+	 * deal with request calculations.
+	 */
+	pd->settings.size = be32_to_cpu(ti.fixed_packet_size) << 2;
+	if (pd->settings.size == 0) {
+		printk("pktcdvd: detected zero packet size!\n");
+		pd->settings.size = 128;
+	}
+	pd->settings.fp = ti.fp;
+	pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
+
+	if (ti.nwa_v) {
+		pd->nwa = be32_to_cpu(ti.next_writable);
+		set_bit(PACKET_NWA_VALID, &pd->flags);
+	}
+
+	/*
+	 * in theory we could use lra on -RW media as well and just zero
+	 * blocks that haven't been written yet, but in practice that
+	 * is just a no-go. we'll use that for -R, naturally.
+	 */
+	if (ti.lra_v) {
+		pd->lra = be32_to_cpu(ti.last_rec_address);
+		set_bit(PACKET_LRA_VALID, &pd->flags);
+	} else {
+		pd->lra = 0xffffffff;
+		set_bit(PACKET_LRA_VALID, &pd->flags);
+	}
+
+	/*
+	 * fine for now
+	 */
+	pd->settings.link_loss = 7;
+	pd->settings.write_type = 0;	/* packet */
+	pd->settings.track_mode = ti.track_mode;
+
+	/*
+	 * mode1 or mode2 disc
+	 */
+	switch (ti.data_mode) {
+		case PACKET_MODE1:
+			pd->settings.block_mode = PACKET_BLOCK_MODE1;
+			break;
+		case PACKET_MODE2:
+			pd->settings.block_mode = PACKET_BLOCK_MODE2;
+			break;
+		default:
+			printk("pktcdvd: unknown data mode\n");
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ * enable/disable write caching on drive
+ */
+static int pkt_write_caching(struct pktcdvd_device *pd, int set)
+{
+	struct packet_command cgc;
+	struct request_sense sense;
+	unsigned char buf[64];
+	int ret;
+
+	memset(buf, 0, sizeof(buf));
+	init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ);
+	cgc.sense = &sense;
+	cgc.buflen = pd->mode_offset + 12;
+
+	/*
+	 * caching mode page might not be there, so quiet this command
+	 */
+	cgc.quiet = 1;
+
+	if ((ret = pkt_mode_sense(pd, &cgc, GPMODE_WCACHING_PAGE, 0)))
+		return ret;
+
+	buf[pd->mode_offset + 10] |= (!!set << 2);
+
+	cgc.buflen = cgc.cmd[8] = 2 + ((buf[0] << 8) | (buf[1] & 0xff));
+	ret = pkt_mode_select(pd, &cgc);
+	if (ret) {
+		printk("pktcdvd: write caching control failed\n");
+		pkt_dump_sense(&cgc);
+	} else if (!ret && set)
+		printk("pktcdvd: enabled write caching on %s\n", pd->name);
+	return ret;
+}
+
+static int pkt_lock_door(struct pktcdvd_device *pd, int lockflag)
+{
+	struct packet_command cgc;
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
+	cgc.cmd[4] = lockflag ? 1 : 0;
+	return pkt_generic_packet(pd, &cgc);
+}
+
+/*
+ * Returns drive maximum write speed
+ */
+static int pkt_get_max_speed(struct pktcdvd_device *pd, unsigned *write_speed)
+{
+	struct packet_command cgc;
+	struct request_sense sense;
+	unsigned char buf[256+18];
+	unsigned char *cap_buf;
+	int ret, offset;
+
+	memset(buf, 0, sizeof(buf));
+	cap_buf = &buf[sizeof(struct mode_page_header) + pd->mode_offset];
+	init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_UNKNOWN);
+	cgc.sense = &sense;
+
+	ret = pkt_mode_sense(pd, &cgc, GPMODE_CAPABILITIES_PAGE, 0);
+	if (ret) {
+		cgc.buflen = pd->mode_offset + cap_buf[1] + 2 +
+			     sizeof(struct mode_page_header);
+		ret = pkt_mode_sense(pd, &cgc, GPMODE_CAPABILITIES_PAGE, 0);
+		if (ret) {
+			pkt_dump_sense(&cgc);
+			return ret;
+		}
+	}
+
+	offset = 20;			    /* Obsoleted field, used by older drives */
+	if (cap_buf[1] >= 28)
+		offset = 28;		    /* Current write speed selected */
+	if (cap_buf[1] >= 30) {
+		/* If the drive reports at least one "Logical Unit Write
+		 * Speed Performance Descriptor Block", use the information
+		 * in the first block. (contains the highest speed)
+		 */
+		int num_spdb = (cap_buf[30] << 8) + cap_buf[31];
+		if (num_spdb > 0)
+			offset = 34;
+	}
+
+	*write_speed = (cap_buf[offset] << 8) | cap_buf[offset + 1];
+	return 0;
+}
+
+/* These tables from cdrecord - I don't have orange book */
+/* standard speed CD-RW (1-4x) */
+static char clv_to_speed[16] = {
+	/* 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 */
+	   0, 2, 4, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+/* high speed CD-RW (-10x) */
+static char hs_clv_to_speed[16] = {
+	/* 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 */
+	   0, 2, 4, 6, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+/* ultra high speed CD-RW */
+static char us_clv_to_speed[16] = {
+	/* 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 */
+	   0, 2, 4, 8, 0, 0,16, 0,24,32,40,48, 0, 0, 0, 0
+};
+
+/*
+ * reads the maximum media speed from ATIP
+ */
+static int pkt_media_speed(struct pktcdvd_device *pd, unsigned *speed)
+{
+	struct packet_command cgc;
+	struct request_sense sense;
+	unsigned char buf[64];
+	unsigned int size, st, sp;
+	int ret;
+
+	init_cdrom_command(&cgc, buf, 2, CGC_DATA_READ);
+	cgc.sense = &sense;
+	cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
+	cgc.cmd[1] = 2;
+	cgc.cmd[2] = 4; /* READ ATIP */
+	cgc.cmd[8] = 2;
+	ret = pkt_generic_packet(pd, &cgc);
+	if (ret) {
+		pkt_dump_sense(&cgc);
+		return ret;
+	}
+	size = ((unsigned int) buf[0]<<8) + buf[1] + 2;
+	if (size > sizeof(buf))
+		size = sizeof(buf);
+
+	init_cdrom_command(&cgc, buf, size, CGC_DATA_READ);
+	cgc.sense = &sense;
+	cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
+	cgc.cmd[1] = 2;
+	cgc.cmd[2] = 4;
+	cgc.cmd[8] = size;
+	ret = pkt_generic_packet(pd, &cgc);
+	if (ret) {
+		pkt_dump_sense(&cgc);
+		return ret;
+	}
+
+	if (!buf[6] & 0x40) {
+		printk("pktcdvd: Disc type is not CD-RW\n");
+		return 1;
+	}
+	if (!buf[6] & 0x4) {
+		printk("pktcdvd: A1 values on media are not valid, maybe not CDRW?\n");
+		return 1;
+	}
+
+	st = (buf[6] >> 3) & 0x7; /* disc sub-type */
+
+	sp = buf[16] & 0xf; /* max speed from ATIP A1 field */
+
+	/* Info from cdrecord */
+	switch (st) {
+		case 0: /* standard speed */
+			*speed = clv_to_speed[sp];
+			break;
+		case 1: /* high speed */
+			*speed = hs_clv_to_speed[sp];
+			break;
+		case 2: /* ultra high speed */
+			*speed = us_clv_to_speed[sp];
+			break;
+		default:
+			printk("pktcdvd: Unknown disc sub-type %d\n",st);
+			return 1;
+	}
+	if (*speed) {
+		printk("pktcdvd: Max. media speed: %d\n",*speed);
+		return 0;
+	} else {
+		printk("pktcdvd: Unknown speed %d for sub-type %d\n",sp,st);
+		return 1;
+	}
+}
+
+static int pkt_perform_opc(struct pktcdvd_device *pd)
+{
+	struct packet_command cgc;
+	struct request_sense sense;
+	int ret;
+
+	VPRINTK("pktcdvd: Performing OPC\n");
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.sense = &sense;
+	cgc.timeout = 60*HZ;
+	cgc.cmd[0] = GPCMD_SEND_OPC;
+	cgc.cmd[1] = 1;
+	if ((ret = pkt_generic_packet(pd, &cgc)))
+		pkt_dump_sense(&cgc);
+	return ret;
+}
+
+static int pkt_open_write(struct pktcdvd_device *pd)
+{
+	int ret;
+	unsigned int write_speed, media_write_speed, read_speed;
+
+	if ((ret = pkt_probe_settings(pd))) {
+		DPRINTK("pktcdvd: %s failed probe\n", pd->name);
+		return -EIO;
+	}
+
+	if ((ret = pkt_set_write_settings(pd))) {
+		DPRINTK("pktcdvd: %s failed saving write settings\n", pd->name);
+		return -EIO;
+	}
+
+	pkt_write_caching(pd, USE_WCACHING);
+
+	if ((ret = pkt_get_max_speed(pd, &write_speed)))
+		write_speed = 16 * 177;
+	switch (pd->mmc3_profile) {
+		case 0x13: /* DVD-RW */
+		case 0x1a: /* DVD+RW */
+			DPRINTK("pktcdvd: write speed %ukB/s\n", write_speed);
+			break;
+		default:
+			if ((ret = pkt_media_speed(pd, &media_write_speed)))
+				media_write_speed = 16;
+			write_speed = min(write_speed, media_write_speed * 177);
+			DPRINTK("pktcdvd: write speed %ux\n", write_speed / 176);
+			break;
+	}
+	read_speed = write_speed;
+
+	if ((ret = pkt_set_speed(pd, write_speed, read_speed))) {
+		DPRINTK("pktcdvd: %s couldn't set write speed\n", pd->name);
+		return -EIO;
+	}
+	pd->write_speed = write_speed;
+	pd->read_speed = read_speed;
+
+	if ((ret = pkt_perform_opc(pd))) {
+		DPRINTK("pktcdvd: %s Optimum Power Calibration failed\n", pd->name);
+	}
+
+	return 0;
+}
+
+/*
+ * called at open time.
+ */
+static int pkt_open_dev(struct pktcdvd_device *pd, int write)
+{
+	int ret;
+	long lba;
+	request_queue_t *q;
+
+	/*
+	 * We need to re-open the cdrom device without O_NONBLOCK to be able
+	 * to read/write from/to it. It is already opened in O_NONBLOCK mode
+	 * so bdget() can't fail.
+	 */
+	bdget(pd->bdev->bd_dev);
+	if ((ret = blkdev_get(pd->bdev, FMODE_READ, O_RDONLY)))
+		goto out;
+
+	if ((ret = pkt_get_last_written(pd, &lba))) {
+		printk("pktcdvd: pkt_get_last_written failed\n");
+		goto out_putdev;
+	}
+
+	set_capacity(pd->disk, lba << 2);
+	set_capacity(pd->bdev->bd_disk, lba << 2);
+	bd_set_size(pd->bdev, (loff_t)lba << 11);
+
+	q = bdev_get_queue(pd->bdev);
+	if (write) {
+		if ((ret = pkt_open_write(pd)))
+			goto out_putdev;
+		/*
+		 * Some CDRW drives can not handle writes larger than one packet,
+		 * even if the size is a multiple of the packet size.
+		 */
+		spin_lock_irq(q->queue_lock);
+		blk_queue_max_sectors(q, pd->settings.size);
+		spin_unlock_irq(q->queue_lock);
+		set_bit(PACKET_WRITABLE, &pd->flags);
+	} else {
+		pkt_set_speed(pd, MAX_SPEED, MAX_SPEED);
+		clear_bit(PACKET_WRITABLE, &pd->flags);
+	}
+
+	if ((ret = pkt_set_segment_merging(pd, q)))
+		goto out_putdev;
+
+	if (write)
+		printk("pktcdvd: %lukB available on disc\n", lba << 1);
+
+	return 0;
+
+out_putdev:
+	blkdev_put(pd->bdev);
+out:
+	return ret;
+}
+
+/*
+ * called when the device is closed. makes sure that the device flushes
+ * the internal cache before we close.
+ */
+static void pkt_release_dev(struct pktcdvd_device *pd, int flush)
+{
+	if (flush && pkt_flush_cache(pd))
+		DPRINTK("pktcdvd: %s not flushing cache\n", pd->name);
+
+	pkt_lock_door(pd, 0);
+
+	pkt_set_speed(pd, MAX_SPEED, MAX_SPEED);
+	blkdev_put(pd->bdev);
+}
+
+static struct pktcdvd_device *pkt_find_dev_from_minor(int dev_minor)
+{
+	if (dev_minor >= MAX_WRITERS)
+		return NULL;
+	return pkt_devs[dev_minor];
+}
+
+static int pkt_open(struct inode *inode, struct file *file)
+{
+	struct pktcdvd_device *pd = NULL;
+	int ret;
+
+	VPRINTK("pktcdvd: entering open\n");
+
+	down(&ctl_mutex);
+	pd = pkt_find_dev_from_minor(iminor(inode));
+	if (!pd) {
+		ret = -ENODEV;
+		goto out;
+	}
+	BUG_ON(pd->refcnt < 0);
+
+	pd->refcnt++;
+	if (pd->refcnt == 1) {
+		if (pkt_open_dev(pd, file->f_mode & FMODE_WRITE)) {
+			ret = -EIO;
+			goto out_dec;
+		}
+		/*
+		 * needed here as well, since ext2 (among others) may change
+		 * the blocksize at mount time
+		 */
+		set_blocksize(inode->i_bdev, CD_FRAMESIZE);
+	}
+
+	up(&ctl_mutex);
+	return 0;
+
+out_dec:
+	pd->refcnt--;
+out:
+	VPRINTK("pktcdvd: failed open (%d)\n", ret);
+	up(&ctl_mutex);
+	return ret;
+}
+
+static int pkt_close(struct inode *inode, struct file *file)
+{
+	struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data;
+	int ret = 0;
+
+	down(&ctl_mutex);
+	pd->refcnt--;
+	BUG_ON(pd->refcnt < 0);
+	if (pd->refcnt == 0) {
+		int flush = test_bit(PACKET_WRITABLE, &pd->flags);
+		pkt_release_dev(pd, flush);
+	}
+	up(&ctl_mutex);
+	return ret;
+}
+
+
+static void *psd_pool_alloc(int gfp_mask, void *data)
+{
+	return kmalloc(sizeof(struct packet_stacked_data), gfp_mask);
+}
+
+static void psd_pool_free(void *ptr, void *data)
+{
+	kfree(ptr);
+}
+
+static int pkt_end_io_read_cloned(struct bio *bio, unsigned int bytes_done, int err)
+{
+	struct packet_stacked_data *psd = bio->bi_private;
+	struct pktcdvd_device *pd = psd->pd;
+
+	if (bio->bi_size)
+		return 1;
+
+	bio_put(bio);
+	bio_endio(psd->bio, psd->bio->bi_size, err);
+	mempool_free(psd, psd_pool);
+	pkt_bio_finished(pd);
+	return 0;
+}
+
+static int pkt_make_request(request_queue_t *q, struct bio *bio)
+{
+	struct pktcdvd_device *pd;
+	char b[BDEVNAME_SIZE];
+	sector_t zone;
+	struct packet_data *pkt;
+	int was_empty, blocked_bio;
+	struct pkt_rb_node *node;
+
+	pd = q->queuedata;
+	if (!pd) {
+		printk("pktcdvd: %s incorrect request queue\n", bdevname(bio->bi_bdev, b));
+		goto end_io;
+	}
+
+	/*
+	 * Clone READ bios so we can have our own bi_end_io callback.
+	 */
+	if (bio_data_dir(bio) == READ) {
+		struct bio *cloned_bio = bio_clone(bio, GFP_NOIO);
+		struct packet_stacked_data *psd = mempool_alloc(psd_pool, GFP_NOIO);
+
+		psd->pd = pd;
+		psd->bio = bio;
+		cloned_bio->bi_bdev = pd->bdev;
+		cloned_bio->bi_private = psd;
+		cloned_bio->bi_end_io = pkt_end_io_read_cloned;
+		pd->stats.secs_r += bio->bi_size >> 9;
+		pkt_queue_bio(pd, cloned_bio, 1);
+		return 0;
+	}
+
+	if (!test_bit(PACKET_WRITABLE, &pd->flags)) {
+		printk("pktcdvd: WRITE for ro device %s (%llu)\n",
+			pd->name, (unsigned long long)bio->bi_sector);
+		goto end_io;
+	}
+
+	if (!bio->bi_size || (bio->bi_size % CD_FRAMESIZE)) {
+		printk("pktcdvd: wrong bio size\n");
+		goto end_io;
+	}
+
+	blk_queue_bounce(q, &bio);
+
+	zone = ZONE(bio->bi_sector, pd);
+	VPRINTK("pkt_make_request: start = %6llx stop = %6llx\n",
+		(unsigned long long)bio->bi_sector,
+		(unsigned long long)(bio->bi_sector + bio_sectors(bio)));
+
+	/* Check if we have to split the bio */
+	{
+		struct bio_pair *bp;
+		sector_t last_zone;
+		int first_sectors;
+
+		last_zone = ZONE(bio->bi_sector + bio_sectors(bio) - 1, pd);
+		if (last_zone != zone) {
+			BUG_ON(last_zone != zone + pd->settings.size);
+			first_sectors = last_zone - bio->bi_sector;
+			bp = bio_split(bio, bio_split_pool, first_sectors);
+			BUG_ON(!bp);
+			pkt_make_request(q, &bp->bio1);
+			pkt_make_request(q, &bp->bio2);
+			bio_pair_release(bp);
+			return 0;
+		}
+	}
+
+	/*
+	 * If we find a matching packet in state WAITING or READ_WAIT, we can
+	 * just append this bio to that packet.
+	 */
+	spin_lock(&pd->cdrw.active_list_lock);
+	blocked_bio = 0;
+	list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
+		if (pkt->sector == zone) {
+			spin_lock(&pkt->lock);
+			if ((pkt->state == PACKET_WAITING_STATE) ||
+			    (pkt->state == PACKET_READ_WAIT_STATE)) {
+				pkt_add_list_last(bio, &pkt->orig_bios,
+						  &pkt->orig_bios_tail);
+				pkt->write_size += bio->bi_size / CD_FRAMESIZE;
+				if ((pkt->write_size >= pkt->frames) &&
+				    (pkt->state == PACKET_WAITING_STATE)) {
+					atomic_inc(&pkt->run_sm);
+					wake_up(&pd->wqueue);
+				}
+				spin_unlock(&pkt->lock);
+				spin_unlock(&pd->cdrw.active_list_lock);
+				return 0;
+			} else {
+				blocked_bio = 1;
+			}
+			spin_unlock(&pkt->lock);
+		}
+	}
+	spin_unlock(&pd->cdrw.active_list_lock);
+
+	/*
+	 * No matching packet found. Store the bio in the work queue.
+	 */
+	node = mempool_alloc(pd->rb_pool, GFP_NOIO);
+	BUG_ON(!node);
+	node->bio = bio;
+	spin_lock(&pd->lock);
+	BUG_ON(pd->bio_queue_size < 0);
+	was_empty = (pd->bio_queue_size == 0);
+	pkt_rbtree_insert(pd, node);
+	spin_unlock(&pd->lock);
+
+	/*
+	 * Wake up the worker thread.
+	 */
+	atomic_set(&pd->scan_queue, 1);
+	if (was_empty) {
+		/* This wake_up is required for correct operation */
+		wake_up(&pd->wqueue);
+	} else if (!list_empty(&pd->cdrw.pkt_free_list) && !blocked_bio) {
+		/*
+		 * This wake up is not required for correct operation,
+		 * but improves performance in some cases.
+		 */
+		wake_up(&pd->wqueue);
+	}
+	return 0;
+end_io:
+	bio_io_error(bio, bio->bi_size);
+	return 0;
+}
+
+
+
+static int pkt_merge_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *bvec)
+{
+	struct pktcdvd_device *pd = q->queuedata;
+	sector_t zone = ZONE(bio->bi_sector, pd);
+	int used = ((bio->bi_sector - zone) << 9) + bio->bi_size;
+	int remaining = (pd->settings.size << 9) - used;
+	int remaining2;
+
+	/*
+	 * A bio <= PAGE_SIZE must be allowed. If it crosses a packet
+	 * boundary, pkt_make_request() will split the bio.
+	 */
+	remaining2 = PAGE_SIZE - bio->bi_size;
+	remaining = max(remaining, remaining2);
+
+	BUG_ON(remaining < 0);
+	return remaining;
+}
+
+static void pkt_init_queue(struct pktcdvd_device *pd)
+{
+	request_queue_t *q = pd->disk->queue;
+
+	blk_queue_make_request(q, pkt_make_request);
+	blk_queue_hardsect_size(q, CD_FRAMESIZE);
+	blk_queue_max_sectors(q, PACKET_MAX_SECTORS);
+	blk_queue_merge_bvec(q, pkt_merge_bvec);
+	q->queuedata = pd;
+}
+
+static int pkt_seq_show(struct seq_file *m, void *p)
+{
+	struct pktcdvd_device *pd = m->private;
+	char *msg;
+	char bdev_buf[BDEVNAME_SIZE];
+	int states[PACKET_NUM_STATES];
+
+	seq_printf(m, "Writer %s mapped to %s:\n", pd->name,
+		   bdevname(pd->bdev, bdev_buf));
+
+	seq_printf(m, "\nSettings:\n");
+	seq_printf(m, "\tpacket size:\t\t%dkB\n", pd->settings.size / 2);
+
+	if (pd->settings.write_type == 0)
+		msg = "Packet";
+	else
+		msg = "Unknown";
+	seq_printf(m, "\twrite type:\t\t%s\n", msg);
+
+	seq_printf(m, "\tpacket type:\t\t%s\n", pd->settings.fp ? "Fixed" : "Variable");
+	seq_printf(m, "\tlink loss:\t\t%d\n", pd->settings.link_loss);
+
+	seq_printf(m, "\ttrack mode:\t\t%d\n", pd->settings.track_mode);
+
+	if (pd->settings.block_mode == PACKET_BLOCK_MODE1)
+		msg = "Mode 1";
+	else if (pd->settings.block_mode == PACKET_BLOCK_MODE2)
+		msg = "Mode 2";
+	else
+		msg = "Unknown";
+	seq_printf(m, "\tblock mode:\t\t%s\n", msg);
+
+	seq_printf(m, "\nStatistics:\n");
+	seq_printf(m, "\tpackets started:\t%lu\n", pd->stats.pkt_started);
+	seq_printf(m, "\tpackets ended:\t\t%lu\n", pd->stats.pkt_ended);
+	seq_printf(m, "\twritten:\t\t%lukB\n", pd->stats.secs_w >> 1);
+	seq_printf(m, "\tread gather:\t\t%lukB\n", pd->stats.secs_rg >> 1);
+	seq_printf(m, "\tread:\t\t\t%lukB\n", pd->stats.secs_r >> 1);
+
+	seq_printf(m, "\nMisc:\n");
+	seq_printf(m, "\treference count:\t%d\n", pd->refcnt);
+	seq_printf(m, "\tflags:\t\t\t0x%lx\n", pd->flags);
+	seq_printf(m, "\tread speed:\t\t%ukB/s\n", pd->read_speed);
+	seq_printf(m, "\twrite speed:\t\t%ukB/s\n", pd->write_speed);
+	seq_printf(m, "\tstart offset:\t\t%lu\n", pd->offset);
+	seq_printf(m, "\tmode page offset:\t%u\n", pd->mode_offset);
+
+	seq_printf(m, "\nQueue state:\n");
+	seq_printf(m, "\tbios queued:\t\t%d\n", pd->bio_queue_size);
+	seq_printf(m, "\tbios pending:\t\t%d\n", atomic_read(&pd->cdrw.pending_bios));
+	seq_printf(m, "\tcurrent sector:\t\t0x%llx\n", (unsigned long long)pd->current_sector);
+
+	pkt_count_states(pd, states);
+	seq_printf(m, "\tstate:\t\t\ti:%d ow:%d rw:%d ww:%d rec:%d fin:%d\n",
+		   states[0], states[1], states[2], states[3], states[4], states[5]);
+
+	return 0;
+}
+
+static int pkt_seq_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, pkt_seq_show, PDE(inode)->data);
+}
+
+static struct file_operations pkt_proc_fops = {
+	.open	= pkt_seq_open,
+	.read	= seq_read,
+	.llseek	= seq_lseek,
+	.release = single_release
+};
+
+static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
+{
+	int i;
+	int ret = 0;
+	char b[BDEVNAME_SIZE];
+	struct proc_dir_entry *proc;
+	struct block_device *bdev;
+
+	if (pd->pkt_dev == dev) {
+		printk("pktcdvd: Recursive setup not allowed\n");
+		return -EBUSY;
+	}
+	for (i = 0; i < MAX_WRITERS; i++) {
+		struct pktcdvd_device *pd2 = pkt_devs[i];
+		if (!pd2)
+			continue;
+		if (pd2->bdev->bd_dev == dev) {
+			printk("pktcdvd: %s already setup\n", bdevname(pd2->bdev, b));
+			return -EBUSY;
+		}
+		if (pd2->pkt_dev == dev) {
+			printk("pktcdvd: Can't chain pktcdvd devices\n");
+			return -EBUSY;
+		}
+	}
+
+	bdev = bdget(dev);
+	if (!bdev)
+		return -ENOMEM;
+	ret = blkdev_get(bdev, FMODE_READ, O_RDONLY | O_NONBLOCK);
+	if (ret)
+		return ret;
+
+	/* This is safe, since we have a reference from open(). */
+	__module_get(THIS_MODULE);
+
+	if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) {
+		printk("pktcdvd: not enough memory for buffers\n");
+		ret = -ENOMEM;
+		goto out_mem;
+	}
+
+	pd->bdev = bdev;
+	set_blocksize(bdev, CD_FRAMESIZE);
+
+	pkt_init_queue(pd);
+
+	atomic_set(&pd->cdrw.pending_bios, 0);
+	pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name);
+	if (IS_ERR(pd->cdrw.thread)) {
+		printk("pktcdvd: can't start kernel thread\n");
+		ret = -ENOMEM;
+		goto out_thread;
+	}
+
+	proc = create_proc_entry(pd->name, 0, pkt_proc);
+	if (proc) {
+		proc->data = pd;
+		proc->proc_fops = &pkt_proc_fops;
+	}
+	DPRINTK("pktcdvd: writer %s mapped to %s\n", pd->name, bdevname(bdev, b));
+	return 0;
+
+out_thread:
+	pkt_shrink_pktlist(pd);
+out_mem:
+	blkdev_put(bdev);
+	/* This is safe: open() is still holding a reference. */
+	module_put(THIS_MODULE);
+	return ret;
+}
+
+static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data;
+
+	VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode));
+	BUG_ON(!pd);
+
+	switch (cmd) {
+	/*
+	 * forward selected CDROM ioctls to CD-ROM, for UDF
+	 */
+	case CDROMMULTISESSION:
+	case CDROMREADTOCENTRY:
+	case CDROM_LAST_WRITTEN:
+	case CDROM_SEND_PACKET:
+	case SCSI_IOCTL_SEND_COMMAND:
+		return ioctl_by_bdev(pd->bdev, cmd, arg);
+
+	case CDROMEJECT:
+		/*
+		 * The door gets locked when the device is opened, so we
+		 * have to unlock it or else the eject command fails.
+		 */
+		pkt_lock_door(pd, 0);
+		return ioctl_by_bdev(pd->bdev, cmd, arg);
+
+	default:
+		printk("pktcdvd: Unknown ioctl for %s (%x)\n", pd->name, cmd);
+		return -ENOTTY;
+	}
+
+	return 0;
+}
+
+static int pkt_media_changed(struct gendisk *disk)
+{
+	struct pktcdvd_device *pd = disk->private_data;
+	struct gendisk *attached_disk;
+
+	if (!pd)
+		return 0;
+	if (!pd->bdev)
+		return 0;
+	attached_disk = pd->bdev->bd_disk;
+	if (!attached_disk)
+		return 0;
+	return attached_disk->fops->media_changed(attached_disk);
+}
+
+static struct block_device_operations pktcdvd_ops = {
+	.owner =		THIS_MODULE,
+	.open =			pkt_open,
+	.release =		pkt_close,
+	.ioctl =		pkt_ioctl,
+	.media_changed =	pkt_media_changed,
+};
+
+/*
+ * Set up mapping from pktcdvd device to CD-ROM device.
+ */
+static int pkt_setup_dev(struct pkt_ctrl_command *ctrl_cmd)
+{
+	int idx;
+	int ret = -ENOMEM;
+	struct pktcdvd_device *pd;
+	struct gendisk *disk;
+	dev_t dev = new_decode_dev(ctrl_cmd->dev);
+
+	for (idx = 0; idx < MAX_WRITERS; idx++)
+		if (!pkt_devs[idx])
+			break;
+	if (idx == MAX_WRITERS) {
+		printk("pktcdvd: max %d writers supported\n", MAX_WRITERS);
+		return -EBUSY;
+	}
+
+	pd = kmalloc(sizeof(struct pktcdvd_device), GFP_KERNEL);
+	if (!pd)
+		return ret;
+	memset(pd, 0, sizeof(struct pktcdvd_device));
+
+	pd->rb_pool = mempool_create(PKT_RB_POOL_SIZE, pkt_rb_alloc, pkt_rb_free, NULL);
+	if (!pd->rb_pool)
+		goto out_mem;
+
+	disk = alloc_disk(1);
+	if (!disk)
+		goto out_mem;
+	pd->disk = disk;
+
+	spin_lock_init(&pd->lock);
+	spin_lock_init(&pd->iosched.lock);
+	sprintf(pd->name, "pktcdvd%d", idx);
+	init_waitqueue_head(&pd->wqueue);
+	pd->bio_queue = RB_ROOT;
+
+	disk->major = pkt_major;
+	disk->first_minor = idx;
+	disk->fops = &pktcdvd_ops;
+	disk->flags = GENHD_FL_REMOVABLE;
+	sprintf(disk->disk_name, "pktcdvd%d", idx);
+	disk->private_data = pd;
+	disk->queue = blk_alloc_queue(GFP_KERNEL);
+	if (!disk->queue)
+		goto out_mem2;
+
+	pd->pkt_dev = MKDEV(disk->major, disk->first_minor);
+	ret = pkt_new_dev(pd, dev);
+	if (ret)
+		goto out_new_dev;
+
+	add_disk(disk);
+	pkt_devs[idx] = pd;
+	ctrl_cmd->pkt_dev = new_encode_dev(pd->pkt_dev);
+	return 0;
+
+out_new_dev:
+	blk_put_queue(disk->queue);
+out_mem2:
+	put_disk(disk);
+out_mem:
+	if (pd->rb_pool)
+		mempool_destroy(pd->rb_pool);
+	kfree(pd);
+	return ret;
+}
+
+/*
+ * Tear down mapping from pktcdvd device to CD-ROM device.
+ */
+static int pkt_remove_dev(struct pkt_ctrl_command *ctrl_cmd)
+{
+	struct pktcdvd_device *pd;
+	int idx;
+	dev_t pkt_dev = new_decode_dev(ctrl_cmd->pkt_dev);
+
+	for (idx = 0; idx < MAX_WRITERS; idx++) {
+		pd = pkt_devs[idx];
+		if (pd && (pd->pkt_dev == pkt_dev))
+			break;
+	}
+	if (idx == MAX_WRITERS) {
+		DPRINTK("pktcdvd: dev not setup\n");
+		return -ENXIO;
+	}
+
+	if (pd->refcnt > 0)
+		return -EBUSY;
+
+	if (!IS_ERR(pd->cdrw.thread))
+		kthread_stop(pd->cdrw.thread);
+
+	blkdev_put(pd->bdev);
+
+	pkt_shrink_pktlist(pd);
+
+	remove_proc_entry(pd->name, pkt_proc);
+	DPRINTK("pktcdvd: writer %s unmapped\n", pd->name);
+
+	del_gendisk(pd->disk);
+	blk_put_queue(pd->disk->queue);
+	put_disk(pd->disk);
+
+	pkt_devs[idx] = NULL;
+	mempool_destroy(pd->rb_pool);
+	kfree(pd);
+
+	/* This is safe: open() is still holding a reference. */
+	module_put(THIS_MODULE);
+	return 0;
+}
+
+static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
+{
+	struct pktcdvd_device *pd = pkt_find_dev_from_minor(ctrl_cmd->dev_index);
+	if (pd) {
+		ctrl_cmd->dev = new_encode_dev(pd->bdev->bd_dev);
+		ctrl_cmd->pkt_dev = new_encode_dev(pd->pkt_dev);
+	} else {
+		ctrl_cmd->dev = 0;
+		ctrl_cmd->pkt_dev = 0;
+	}
+	ctrl_cmd->num_devices = MAX_WRITERS;
+}
+
+static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+	void __user *argp = (void __user *)arg;
+	struct pkt_ctrl_command ctrl_cmd;
+	int ret = 0;
+
+	if (cmd != PACKET_CTRL_CMD)
+		return -ENOTTY;
+
+	if (copy_from_user(&ctrl_cmd, argp, sizeof(struct pkt_ctrl_command)))
+		return -EFAULT;
+
+	switch (ctrl_cmd.command) {
+	case PKT_CTRL_CMD_SETUP:
+		if (!capable(CAP_SYS_ADMIN))
+			return -EPERM;
+		down(&ctl_mutex);
+		ret = pkt_setup_dev(&ctrl_cmd);
+		up(&ctl_mutex);
+		break;
+	case PKT_CTRL_CMD_TEARDOWN:
+		if (!capable(CAP_SYS_ADMIN))
+			return -EPERM;
+		down(&ctl_mutex);
+		ret = pkt_remove_dev(&ctrl_cmd);
+		up(&ctl_mutex);
+		break;
+	case PKT_CTRL_CMD_STATUS:
+		down(&ctl_mutex);
+		pkt_get_status(&ctrl_cmd);
+		up(&ctl_mutex);
+		break;
+	default:
+		return -ENOTTY;
+	}
+
+	if (copy_to_user(argp, &ctrl_cmd, sizeof(struct pkt_ctrl_command)))
+		return -EFAULT;
+	return ret;
+}
+
+
+static struct file_operations pkt_ctl_fops = {
+	.ioctl	 = pkt_ctl_ioctl,
+	.owner	 = THIS_MODULE,
+};
+
+static struct miscdevice pkt_misc = {
+	.minor 		= MISC_DYNAMIC_MINOR,
+	.name  		= "pktcdvd",
+	.devfs_name 	= "pktcdvd/control",
+	.fops  		= &pkt_ctl_fops
+};
+
+int pkt_init(void)
+{
+	int ret;
+
+	psd_pool = mempool_create(PSD_POOL_SIZE, psd_pool_alloc, psd_pool_free, NULL);
+	if (!psd_pool)
+		return -ENOMEM;
+
+	ret = register_blkdev(pkt_major, "pktcdvd");
+	if (ret < 0) {
+		printk("pktcdvd: Unable to register block device\n");
+		goto out2;
+	}
+	if (!pkt_major)
+		pkt_major = ret;
+
+	ret = misc_register(&pkt_misc);
+	if (ret) {
+		printk("pktcdvd: Unable to register misc device\n");
+		goto out;
+	}
+
+	init_MUTEX(&ctl_mutex);
+
+	pkt_proc = proc_mkdir("pktcdvd", proc_root_driver);
+
+	DPRINTK("pktcdvd: %s\n", VERSION_CODE);
+	return 0;
+
+out:
+	unregister_blkdev(pkt_major, "pktcdvd");
+out2:
+	mempool_destroy(psd_pool);
+	return ret;
+}
+
+void pkt_exit(void)
+{
+	remove_proc_entry("pktcdvd", proc_root_driver);
+	misc_deregister(&pkt_misc);
+	unregister_blkdev(pkt_major, "pktcdvd");
+	mempool_destroy(psd_pool);
+}
+
+MODULE_DESCRIPTION("Packet writing layer for CD/DVD drives");
+MODULE_AUTHOR("Jens Axboe <axboe@suse.de>");
+MODULE_LICENSE("GPL");
+
+module_init(pkt_init);
+module_exit(pkt_exit);
diff -Nru a/drivers/block/rd.c b/drivers/block/rd.c
--- a/drivers/block/rd.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/block/rd.c	2004-12-24 13:37:00 -08:00
@@ -48,6 +48,7 @@
 #include <asm/atomic.h>
 #include <linux/bio.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/pagemap.h>
@@ -60,15 +61,12 @@
 
 #include <asm/uaccess.h>
 
-/* The RAM disk size is now a parameter */
-#define NUM_RAMDISKS 16		/* This cannot be overridden (yet) */
-
 /* Various static variables go here.  Most are used only in the RAM disk code.
  */
 
-static struct gendisk *rd_disks[NUM_RAMDISKS];
-static struct block_device *rd_bdev[NUM_RAMDISKS];/* Protected device data */
-static struct request_queue *rd_queue[NUM_RAMDISKS];
+static struct gendisk *rd_disks[CONFIG_BLK_DEV_RAM_COUNT];
+static struct block_device *rd_bdev[CONFIG_BLK_DEV_RAM_COUNT];/* Protected device data */
+static struct request_queue *rd_queue[CONFIG_BLK_DEV_RAM_COUNT];
 
 /*
  * Parameters for the boot-loading of the RAM disk.  These are set by
@@ -402,7 +400,7 @@
 {
 	int i;
 
-	for (i = 0; i < NUM_RAMDISKS; i++) {
+	for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
 		struct block_device *bdev = rd_bdev[i];
 		rd_bdev[i] = NULL;
 		if (bdev) {
@@ -432,7 +430,7 @@
 		rd_blocksize = BLOCK_SIZE;
 	}
 
-	for (i = 0; i < NUM_RAMDISKS; i++) {
+	for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
 		rd_disks[i] = alloc_disk(1);
 		if (!rd_disks[i])
 			goto out;
@@ -445,7 +443,7 @@
 
 	devfs_mk_dir("rd");
 
-	for (i = 0; i < NUM_RAMDISKS; i++) {
+	for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
 		struct gendisk *disk = rd_disks[i];
 
 		rd_queue[i] = blk_alloc_queue(GFP_KERNEL);
@@ -470,7 +468,7 @@
 	/* rd_size is given in kB */
 	printk("RAMDISK driver initialized: "
 		"%d RAM disks of %dK size %d blocksize\n",
-		NUM_RAMDISKS, rd_size, rd_blocksize);
+		CONFIG_BLK_DEV_RAM_COUNT, rd_size, rd_blocksize);
 
 	return 0;
 out_queue:
@@ -508,9 +506,10 @@
 #endif
 
 /* options - modular */
-MODULE_PARM     (rd_size, "1i");
+module_param(rd_size, int, 0);
 MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
-MODULE_PARM     (rd_blocksize, "i");
+module_param(rd_blocksize, int, 0);
 MODULE_PARM_DESC(rd_blocksize, "Blocksize of each RAM disk in bytes.");
+MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
 
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c
--- a/drivers/block/scsi_ioctl.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/block/scsi_ioctl.c	2004-12-24 13:37:31 -08:00
@@ -107,12 +107,13 @@
 
 #define CMD_READ_SAFE	0x01
 #define CMD_WRITE_SAFE	0x02
+#define CMD_WARNED	0x04
 #define safe_for_read(cmd)	[cmd] = CMD_READ_SAFE
 #define safe_for_write(cmd)	[cmd] = CMD_WRITE_SAFE
 
 static int verify_command(struct file *file, unsigned char *cmd)
 {
-	static const unsigned char cmd_type[256] = {
+	static unsigned char cmd_type[256] = {
 
 		/* Basic read-only commands */
 		safe_for_read(TEST_UNIT_READY),
@@ -126,10 +127,10 @@
 		safe_for_read(INQUIRY),
 		safe_for_read(MODE_SENSE),
 		safe_for_read(MODE_SENSE_10),
+		safe_for_read(LOG_SENSE),
 		safe_for_read(START_STOP),
 		safe_for_read(GPCMD_VERIFY_10),
 		safe_for_read(VERIFY_16),
-		safe_for_read(READ_BUFFER),
 
 		/* Audio CD commands */
 		safe_for_read(GPCMD_PLAY_CD),
@@ -139,6 +140,7 @@
 		safe_for_read(GPCMD_PAUSE_RESUME),
 
 		/* CD/DVD data reading */
+		safe_for_read(GPCMD_READ_BUFFER_CAPACITY),
 		safe_for_read(GPCMD_READ_CD),
 		safe_for_read(GPCMD_READ_CD_MSF),
 		safe_for_read(GPCMD_READ_DISC_INFO),
@@ -168,6 +170,7 @@
 		safe_for_write(ERASE),
 		safe_for_write(GPCMD_MODE_SELECT_10),
 		safe_for_write(MODE_SELECT),
+		safe_for_write(LOG_SELECT),
 		safe_for_write(GPCMD_BLANK),
 		safe_for_write(GPCMD_CLOSE_TRACK),
 		safe_for_write(GPCMD_FLUSH_CACHE),
@@ -196,6 +199,11 @@
 			return 0;
 	}
 
+	if (!(type & CMD_WARNED)) {
+		cmd_type[cmd[0]] = CMD_WARNED;
+		printk(KERN_WARNING "scsi: unknown opcode 0x%02x\n", cmd[0]);
+	}
+
 	/* And root can do any command.. */
 	if (capable(CAP_SYS_RAWIO))
 		return 0;
@@ -293,11 +301,11 @@
 	blk_execute_rq(q, bd_disk, rq);
 
 	/* write to all output members */
-	hdr->status = rq->errors;	
-	hdr->masked_status = (hdr->status >> 1) & 0x1f;
-	hdr->msg_status = 0;
-	hdr->host_status = 0;
-	hdr->driver_status = 0;
+	hdr->status = 0xff & rq->errors;
+	hdr->masked_status = status_byte(rq->errors);
+	hdr->msg_status = msg_byte(rq->errors);
+	hdr->host_status = host_byte(rq->errors);
+	hdr->driver_status = driver_byte(rq->errors);
 	hdr->info = 0;
 	if (hdr->masked_status || hdr->host_status || hdr->driver_status)
 		hdr->info |= SG_INFO_CHECK;
diff -Nru a/drivers/block/swim3.c b/drivers/block/swim3.c
--- a/drivers/block/swim3.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/block/swim3.c	2004-12-24 13:36:47 -08:00
@@ -176,8 +176,8 @@
 
 struct floppy_state {
 	enum swim_state	state;
-	volatile struct swim3 *swim3;	/* hardware registers */
-	struct dbdma_regs *dma;	/* DMA controller registers */
+	struct swim3 __iomem *swim3;	/* hardware registers */
+	struct dbdma_regs __iomem *dma;	/* DMA controller registers */
 	int	swim3_intr;	/* interrupt number for SWIM3 */
 	int	dma_intr;	/* interrupt number for DMA channel */
 	int	cur_cyl;	/* cylinder head is on, or -1 */
@@ -259,7 +259,7 @@
 
 static void swim3_select(struct floppy_state *fs, int sel)
 {
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 
 	out_8(&sw->select, RELAX);
 	if (sel & 8)
@@ -271,7 +271,7 @@
 
 static void swim3_action(struct floppy_state *fs, int action)
 {
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 
 	swim3_select(fs, action);
 	udelay(1);
@@ -283,7 +283,7 @@
 
 static int swim3_readbit(struct floppy_state *fs, int bit)
 {
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 	int stat;
 
 	swim3_select(fs, bit);
@@ -381,7 +381,7 @@
 
 static inline void scan_track(struct floppy_state *fs)
 {
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 
 	swim3_select(fs, READ_DATA_0);
 	in_8(&sw->intr);		/* clear SEEN_SECTOR bit */
@@ -394,7 +394,7 @@
 
 static inline void seek_track(struct floppy_state *fs, int n)
 {
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 
 	if (n >= 0) {
 		swim3_action(fs, SEEK_POSITIVE);
@@ -425,9 +425,9 @@
 static inline void setup_transfer(struct floppy_state *fs)
 {
 	int n;
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 	struct dbdma_cmd *cp = fs->dma_cmd;
-	struct dbdma_regs *dr = fs->dma;
+	struct dbdma_regs __iomem *dr = fs->dma;
 
 	if (fd_req->current_nr_sectors <= 0) {
 		printk(KERN_ERR "swim3: transfer 0 sectors?\n");
@@ -445,7 +445,7 @@
 	out_8(&sw->sector, fs->req_sector);
 	out_8(&sw->nsect, n);
 	out_8(&sw->gap3, 0);
-	st_le32(&dr->cmdptr, virt_to_bus(cp));
+	out_le32(&dr->cmdptr, virt_to_bus(cp));
 	if (rq_data_dir(fd_req) == WRITE) {
 		/* Set up 3 dma commands: write preamble, data, postamble */
 		init_dma(cp, OUTPUT_MORE, write_preamble, sizeof(write_preamble));
@@ -537,7 +537,7 @@
 static void scan_timeout(unsigned long data)
 {
 	struct floppy_state *fs = (struct floppy_state *) data;
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 
 	fs->timeout_pending = 0;
 	out_8(&sw->control_bic, DO_ACTION | WRITE_SECTORS);
@@ -557,7 +557,7 @@
 static void seek_timeout(unsigned long data)
 {
 	struct floppy_state *fs = (struct floppy_state *) data;
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 
 	fs->timeout_pending = 0;
 	out_8(&sw->control_bic, DO_SEEK);
@@ -572,7 +572,7 @@
 static void settle_timeout(unsigned long data)
 {
 	struct floppy_state *fs = (struct floppy_state *) data;
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 
 	fs->timeout_pending = 0;
 	if (swim3_readbit(fs, SEEK_COMPLETE)) {
@@ -596,14 +596,14 @@
 static void xfer_timeout(unsigned long data)
 {
 	struct floppy_state *fs = (struct floppy_state *) data;
-	volatile struct swim3 *sw = fs->swim3;
-	struct dbdma_regs *dr = fs->dma;
+	struct swim3 __iomem *sw = fs->swim3;
+	struct dbdma_regs __iomem *dr = fs->dma;
 	struct dbdma_cmd *cp = fs->dma_cmd;
 	unsigned long s;
 	int n;
 
 	fs->timeout_pending = 0;
-	st_le32(&dr->control, RUN << 16);
+	out_le32(&dr->control, RUN << 16);
 	/* We must wait a bit for dbdma to stop */
 	for (n = 0; (in_le32(&dr->status) & ACTIVE) && n < 1000; n++)
 		udelay(1);
@@ -628,10 +628,10 @@
 static irqreturn_t swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct floppy_state *fs = (struct floppy_state *) dev_id;
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 	int intr, err, n;
 	int stat, resid;
-	struct dbdma_regs *dr;
+	struct dbdma_regs __iomem *dr;
 	struct dbdma_cmd *cp;
 
 	intr = in_8(&sw->intr);
@@ -866,7 +866,7 @@
 		err = fd_eject(fs);
 		return err;
 	case FDGETPRM:
-	        if (copy_to_user((void *) param, (void *)&floppy_type,
+	        if (copy_to_user((void __user *) param, &floppy_type,
 				 sizeof(struct floppy_struct)))
 			return -EFAULT;
 		return 0;
@@ -877,7 +877,7 @@
 static int floppy_open(struct inode *inode, struct file *filp)
 {
 	struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 	int n, err = 0;
 
 	if (fs->ref_count == 0) {
@@ -946,7 +946,7 @@
 static int floppy_release(struct inode *inode, struct file *filp)
 {
 	struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
-	volatile struct swim3 *sw = fs->swim3;
+	struct swim3 __iomem *sw = fs->swim3;
 	if (fs->ref_count > 0 && --fs->ref_count == 0) {
 		swim3_action(fs, MOTOR_OFF);
 		out_8(&sw->control_bic, 0xff);
@@ -964,7 +964,7 @@
 static int floppy_revalidate(struct gendisk *disk)
 {
 	struct floppy_state *fs = disk->private_data;
-	volatile struct swim3 *sw;
+	struct swim3 __iomem *sw;
 	int ret, n;
 
 	if (fs->media_bay && check_media_bay(fs->media_bay, MB_FD))
@@ -1105,8 +1105,10 @@
 	
 	memset(fs, 0, sizeof(*fs));
 	fs->state = idle;
-	fs->swim3 = (volatile struct swim3 *) ioremap(swim->addrs[0].address, 0x200);
-	fs->dma = (struct dbdma_regs *) ioremap(swim->addrs[1].address, 0x200);
+	fs->swim3 = (struct swim3 __iomem *)
+		ioremap(swim->addrs[0].address, 0x200);
+	fs->dma = (struct dbdma_regs __iomem *)
+		ioremap(swim->addrs[1].address, 0x200);
 	fs->swim3_intr = swim->intrs[0].line;
 	fs->dma_intr = swim->intrs[1].line;
 	fs->cur_cyl = -1;
diff -Nru a/drivers/block/ub.c b/drivers/block/ub.c
--- a/drivers/block/ub.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/block/ub.c	2004-12-24 13:37:29 -08:00
@@ -8,13 +8,11 @@
  * and is not licensed separately. See file COPYING for details.
  *
  * TODO (sorted by decreasing priority)
- *  -- ZIP does "ub: resid 18 len 0 act 0" and whole transport quits (toggles?)
+ *  -- Do resets with usb_device_reset (needs a thread context, use khubd)
  *  -- set readonly flag for CDs, set removable flag for CF readers
  *  -- do inquiry and verify we got a disk and not a tape (for LUN mismatch)
  *  -- support pphaneuf's SDDR-75 with two LUNs (also broken capacity...)
  *  -- special case some senses, e.g. 3a/0 -> no media present, reduce retries
- *  -- do something about spin-down devices, they are extremely dangerous
- *     (ZIP is one. Needs spin-up command as well.)
  *  -- verify the 13 conditions and do bulk resets
  *  -- normal pool of commands instead of cmdv[]?
  *  -- kill last_pipe and simply do two-state clearing on both pipes
@@ -25,6 +23,7 @@
  *  -- prune comments, they are too volumnous
  *  -- Exterminate P3 printks
  *  -- Resove XXX's
+ *  -- Redo "benh's retries", perhaps have spin-up code to handle them. V:D=?
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -37,7 +36,7 @@
 #define DRV_NAME "ub"
 #define DEVFS_NAME DRV_NAME
 
-#define UB_MAJOR 125	/* Stolen from Experimental range for a week - XXX */
+#define UB_MAJOR 180
 
 /*
  * Definitions which have to be scattered once we understand the layout better.
@@ -62,9 +61,9 @@
 
 /* command block wrapper */
 struct bulk_cb_wrap {
-	u32	Signature;		/* contains 'USBC' */
+	__le32	Signature;		/* contains 'USBC' */
 	u32	Tag;			/* unique per command id */
-	u32	DataTransferLength;	/* size of data */
+	__le32	DataTransferLength;	/* size of data */
 	u8	Flags;			/* direction in bit 0 */
 	u8	Lun;			/* LUN normally 0 */
 	u8	Length;			/* of of the CDB */
@@ -78,9 +77,9 @@
 
 /* command status wrapper */
 struct bulk_cs_wrap {
-	u32	Signature;		/* should = 'USBS' */
+	__le32	Signature;		/* should = 'USBS' */
 	u32	Tag;			/* same as original command */
-	u32	Residue;		/* amount not transferred */
+	__le32	Residue;		/* amount not transferred */
 	u8	Status;			/* see below */
 };
 
@@ -104,13 +103,11 @@
 #define UB_MAX_SECTORS 64
 
 /*
- * A second ought to be enough for a 32K transfer (UB_MAX_SECTORS)
- * even if a webcam hogs the bus (famous last words).
- * Some CDs need a second to spin up though.
- * ZIP drive rejects commands when it's not spinning,
- * so it does not need long timeouts either.
+ * A second is more than enough for a 32K transfer (UB_MAX_SECTORS)
+ * even if a webcam hogs the bus, but some devices need time to spin up.
  */
 #define UB_URB_TIMEOUT	(HZ*2)
+#define UB_DATA_TIMEOUT	(HZ*5)	/* ZIP does spin-ups in the data phase */
 #define UB_CTRL_TIMEOUT	(HZ/2) /* 500ms ought to be enough to clear a stall */
 
 /*
@@ -157,7 +154,8 @@
 	struct ub_scsi_cmd *next;
 
 	int error;			/* Return code - valid upon done */
-	int act_len;			/* Return size */
+	unsigned int act_len;		/* Return size */
+	unsigned char key, asc, ascq;	/* May be valid if error==-EIO */
 
 	int stat_count;			/* Retries getting status. */
 
@@ -186,7 +184,7 @@
  */
 
 #define SCMD_ST_HIST_SZ   8
-#define SCMD_TRACE_SZ    15	/* No more than 256 (trace_index) */
+#define SCMD_TRACE_SZ    63		/* Less than 4KB of 61-byte lines */
 
 struct ub_scsi_cmd_trace {
 	int hcur;
@@ -265,6 +263,7 @@
 	int changed;			/* Media was changed */
 	int removable;
 	int readonly;
+	int first_open;			/* Kludge. See ub_bd_open. */
 	char name[8];
 	struct usb_device *dev;
 	struct usb_interface *intf;
@@ -490,6 +489,18 @@
  */
 static void ub_cleanup(struct ub_dev *sc)
 {
+
+	/*
+	 * If we zero disk->private_data BEFORE put_disk, we have to check
+	 * for NULL all over the place in open, release, check_media and
+	 * revalidate, because the block level semaphore is well inside the
+	 * put_disk. But we cannot zero after the call, because *disk is gone.
+	 * The sd.c is blatantly racy in this area.
+	 */
+	/* disk->private_data = NULL; */
+	put_disk(sc->disk);
+	sc->disk = NULL;
+
 	ub_id_put(sc->id);
 	kfree(sc);
 }
@@ -661,9 +672,12 @@
 
 	/*
 	 * build the command
+	 *
+	 * The call to blk_queue_hardsect_size() guarantees that request
+	 * is aligned, but it is given in terms of 512 byte units, always.
 	 */
-	block = rq->sector;
-	nblks = rq->nr_sectors;
+	block = rq->sector >> sc->capacity.bshift;
+	nblks = rq->nr_sectors >> sc->capacity.bshift;
 
 	memset(cmd, 0, sizeof(struct ub_scsi_cmd));
 	cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10;
@@ -678,7 +692,7 @@
 	cmd->dir = ub_dir;
 	cmd->state = UB_CMDST_INIT;
 	cmd->data = rq->buffer;
-	cmd->len = nblks * 512;
+	cmd->len = rq->nr_sectors * 512;
 	cmd->done = ub_rw_cmd_done;
 	cmd->back = rq;
 
@@ -786,17 +800,16 @@
 	sc->work_urb.error_count = 0;
 	sc->work_urb.status = 0;
 
-	sc->work_timer.expires = jiffies + UB_URB_TIMEOUT;
-	add_timer(&sc->work_timer);
-
 	if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) {
 		/* XXX Clear stalls */
 		printk("ub: cmd #%d start failed (%d)\n", cmd->tag, rc); /* P3 */
-		del_timer(&sc->work_timer);
 		ub_complete(&sc->work_done);
 		return rc;
 	}
 
+	sc->work_timer.expires = jiffies + UB_URB_TIMEOUT;
+	add_timer(&sc->work_timer);
+
 	cmd->state = UB_CMDST_CMD;
 	ub_cmdtr_state(sc, cmd);
 	return 0;
@@ -836,6 +849,7 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(&sc->lock, flags);
+	del_timer(&sc->work_timer);
 	ub_scsi_dispatch(sc);
 	spin_unlock_irqrestore(&sc->lock, flags);
 }
@@ -871,9 +885,6 @@
 	int pipe;
 	int rc;
 
-/* P3 */ /** printk("ub: urb status %d pipe 0x%08x len %d act %d\n",
- urb->status, urb->pipe, urb->transfer_buffer_length, urb->actual_length); **/
-
 	if (atomic_read(&sc->poison)) {
 		/* A little too simplistic, I feel... */
 		goto Bad_End;
@@ -942,9 +953,12 @@
 			ub_cmdtr_state(sc, cmd);
 			return;
 		}
-		if (urb->status != 0)
+		if (urb->status != 0) {
+			printk("ub: cmd #%d cmd status (%d)\n", cmd->tag, urb->status); /* P3 */
 			goto Bad_End;
+		}
 		if (urb->actual_length != US_BULK_CB_WRAP_LEN) {
+			printk("ub: cmd #%d xferred %d\n", cmd->tag, urb->actual_length); /* P3 */
 			/* XXX Must do reset here to unconfuse the device */
 			goto Bad_End;
 		}
@@ -968,18 +982,17 @@
 		sc->work_urb.error_count = 0;
 		sc->work_urb.status = 0;
 
-		sc->work_timer.expires = jiffies + UB_URB_TIMEOUT;
-		add_timer(&sc->work_timer);
-
 		if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) {
 			/* XXX Clear stalls */
 			printk("ub: data #%d submit failed (%d)\n", cmd->tag, rc); /* P3 */
-			del_timer(&sc->work_timer);
 			ub_complete(&sc->work_done);
 			ub_state_done(sc, cmd, rc);
 			return;
 		}
 
+		sc->work_timer.expires = jiffies + UB_DATA_TIMEOUT;
+		add_timer(&sc->work_timer);
+
 		cmd->state = UB_CMDST_DATA;
 		ub_cmdtr_state(sc, cmd);
 
@@ -1063,19 +1076,18 @@
 			sc->work_urb.error_count = 0;
 			sc->work_urb.status = 0;
 
-			sc->work_timer.expires = jiffies + UB_URB_TIMEOUT;
-			add_timer(&sc->work_timer);
-
 			rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC);
 			if (rc != 0) {
 				/* XXX Clear stalls */
 				printk("%s: CSW #%d submit failed (%d)\n",
 				   sc->name, cmd->tag, rc); /* P3 */
-				del_timer(&sc->work_timer);
 				ub_complete(&sc->work_done);
 				ub_state_done(sc, cmd, rc);
 				return;
 			}
+
+			sc->work_timer.expires = jiffies + UB_URB_TIMEOUT;
+			add_timer(&sc->work_timer);
 			return;
 		}
 
@@ -1132,16 +1144,8 @@
 		(*cmd->done)(sc, cmd);
 
 	} else if (cmd->state == UB_CMDST_SENSE) {
-		/* 
-		 * We do not look at sense, because even if there was no sense,
-		 * we get into UB_CMDST_SENSE from a STALL or CSW FAIL only.
-		 * We request sense because we want to clear CHECK CONDITION
-		 * on devices with delusions of SCSI, and not because we
-		 * are curious in any way about the sense itself.
-		 */
-		/* if ((cmd->top_sense[2] & 0x0F) == NO_SENSE) { foo } */
-
 		ub_state_done(sc, cmd, -EIO);
+
 	} else {
 		printk(KERN_WARNING "%s: "
 		    "wrong command state %d on device %u\n",
@@ -1186,18 +1190,17 @@
 	sc->work_urb.error_count = 0;
 	sc->work_urb.status = 0;
 
-	sc->work_timer.expires = jiffies + UB_URB_TIMEOUT;
-	add_timer(&sc->work_timer);
-
 	if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) {
 		/* XXX Clear stalls */
 		printk("ub: CSW #%d submit failed (%d)\n", cmd->tag, rc); /* P3 */
-		del_timer(&sc->work_timer);
 		ub_complete(&sc->work_done);
 		ub_state_done(sc, cmd, rc);
 		return;
 	}
 
+	sc->work_timer.expires = jiffies + UB_URB_TIMEOUT;
+	add_timer(&sc->work_timer);
+
 	cmd->stat_count = 0;
 	cmd->state = UB_CMDST_STAT;
 	ub_cmdtr_state(sc, cmd);
@@ -1217,9 +1220,17 @@
 		goto error;
 	}
 
+	/*
+	 * ``If the allocation length is eighteen or greater, and a device
+	 * server returns less than eithteen bytes of data, the application
+	 * client should assume that the bytes not transferred would have been
+	 * zeroes had the device server returned those bytes.''
+	 */
 	memset(&sc->top_sense, 0, UB_SENSE_SIZE);
+
 	scmd = &sc->top_rqs_cmd;
 	scmd->cdb[0] = REQUEST_SENSE;
+	scmd->cdb[4] = UB_SENSE_SIZE;
 	scmd->cdb_len = 6;
 	scmd->dir = UB_DIR_READ;
 	scmd->state = UB_CMDST_INIT;
@@ -1271,14 +1282,13 @@
 	sc->work_urb.error_count = 0;
 	sc->work_urb.status = 0;
 
-	sc->work_timer.expires = jiffies + UB_CTRL_TIMEOUT;
-	add_timer(&sc->work_timer);
-
 	if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) {
-		del_timer(&sc->work_timer);
 		ub_complete(&sc->work_done);
 		return rc;
 	}
+
+	sc->work_timer.expires = jiffies + UB_CTRL_TIMEOUT;
+	add_timer(&sc->work_timer);
 	return 0;
 }
 
@@ -1289,8 +1299,15 @@
 	unsigned char *sense = scmd->data;
 	struct ub_scsi_cmd *cmd;
 
+	/*
+	 * Ignoring scmd->act_len, because the buffer was pre-zeroed.
+	 */
 	ub_cmdtr_sense(sc, scmd, sense);
 
+	/*
+	 * Find the command which triggered the unit attention or a check,
+	 * save the sense into it, and advance its state machine.
+	 */
 	if ((cmd = ub_cmdq_peek(sc)) == NULL) {
 		printk(KERN_WARNING "%s: sense done while idle\n", sc->name);
 		return;
@@ -1308,6 +1325,10 @@
 		return;
 	}
 
+	cmd->key = sense[2] & 0x0F;
+	cmd->asc = sense[12];
+	cmd->ascq = sense[13];
+
 	ub_scsi_urb_compl(sc, cmd);
 }
 
@@ -1355,12 +1376,7 @@
 
 	sc->readonly = 0;	/* XXX Query this from the device */
 
-	/*
-	 * XXX sd.c sets capacity to zero in such case. However, it doesn't
-	 * work for us. In case of zero capacity, block layer refuses to
-	 * have the /dev/uba opened (why?) Set capacity to some random value.
-	 */
-	sc->capacity.nsec = 50;
+	sc->capacity.nsec = 0;
 	sc->capacity.bsize = 512;
 	sc->capacity.bshift = 0;
 
@@ -1375,7 +1391,7 @@
 		 * We keep this because sd.c has retries for capacity.
 		 */
 		if (ub_sync_read_cap(sc, &sc->capacity) != 0) {
-			sc->capacity.nsec = 100;
+			sc->capacity.nsec = 0;
 			sc->capacity.bsize = 512;
 			sc->capacity.bshift = 0;
 		}
@@ -1404,10 +1420,38 @@
 	sc->openc++;
 	spin_unlock_irqrestore(&ub_lock, flags);
 
+	/*
+	 * This is a workaround for a specific problem in our block layer.
+	 * In 2.6.9, register_disk duplicates the code from rescan_partitions.
+	 * However, if we do add_disk with a device which persistently reports
+	 * a changed media, add_disk calls register_disk, which does do_open,
+	 * which will call rescan_paritions for changed media. After that,
+	 * register_disk attempts to do it all again and causes double kobject
+	 * registration and a eventually an oops on module removal.
+	 *
+	 * The bottom line is, Al Viro says that we should not allow
+	 * bdev->bd_invalidated to be set when doing add_disk no matter what.
+	 */
+	if (sc->first_open) {
+		if (sc->changed) {
+			sc->first_open = 0;
+			rc = -ENOMEDIUM;
+			goto err_open;
+		}
+	}
+
 	if (sc->removable || sc->readonly)
 		check_disk_change(inode->i_bdev);
 
-	/* XXX sd.c and floppy.c bail on open if media is not present. */
+	/*
+	 * The sd.c considers ->media_present and ->changed not equivalent,
+	 * under some pretty murky conditions (a failure of READ CAPACITY).
+	 * We may need it one day.
+	 */
+	if (sc->removable && sc->changed && !(filp->f_flags & O_NDELAY)) {
+		rc = -ENOMEDIUM;
+		goto err_open;
+	}
 
 	if (sc->readonly && (filp->f_mode & FMODE_WRITE)) {
 		rc = -EROFS;
@@ -1435,6 +1479,8 @@
 
 	spin_lock_irqsave(&ub_lock, flags);
 	--sc->openc;
+	if (sc->openc == 0)
+		sc->first_open = 0;
 	if (sc->openc == 0 && atomic_read(&sc->poison))
 		ub_cleanup(sc);
 	spin_unlock_irqrestore(&ub_lock, flags);
@@ -1489,11 +1535,17 @@
 
 	ub_revalidate(sc);
 	/* This is pretty much a long term P3 */
-	printk(KERN_INFO "%s: device %u capacity nsec %ld bsize %u\n",
-	    sc->name, sc->dev->devnum, sc->capacity.nsec, sc->capacity.bsize);
+	if (!atomic_read(&sc->poison)) {		/* Cover sc->dev */
+		printk(KERN_INFO "%s: device %u capacity nsec %ld bsize %u\n",
+		    sc->name, sc->dev->devnum,
+		    sc->capacity.nsec, sc->capacity.bsize);
+	}
 
+	/* XXX Support sector size switching like in sr.c */
+	blk_queue_hardsect_size(disk->queue, sc->capacity.bsize);
 	set_capacity(disk, sc->capacity.nsec);
 	// set_disk_ro(sdkp->disk, sc->readonly);
+
 	return 0;
 }
 
@@ -1524,13 +1576,9 @@
 	 */
 	if (ub_sync_tur(sc) != 0) {
 		sc->changed = 1;
-		/* P3 */ printk("%s: made changed\n", sc->name);
 		return 1;
 	}
 
-	/* The sd.c clears this before returning (one-shot flag). Why? */
-	/* P3 */ printk("%s: %s changed\n", sc->name,
-	    sc->changed? "is": "was not");
 	return sc->changed;
 }
 
@@ -1592,6 +1640,9 @@
 
 	rc = cmd->error;
 
+	if (rc == -EIO && cmd->key != 0)	/* Retries for benh's key */
+		rc = cmd->key;
+
 err_submit:
 	kfree(cmd);
 err_alloc:
@@ -1654,8 +1705,8 @@
 	}
 
 	/* sd.c special-cases sector size of 0 to mean 512. Needed? Safe? */
-	nsec = be32_to_cpu(*(u32 *)p) + 1;
-	bsize = be32_to_cpu(*(u32 *)(p + 4));
+	nsec = be32_to_cpu(*(__be32 *)p) + 1;
+	bsize = be32_to_cpu(*(__be32 *)(p + 4));
 	switch (bsize) {
 	case 512:	shift = 0;	break;
 	case 1024:	shift = 1;	break;
@@ -1725,28 +1776,22 @@
 	sc->work_urb.error_count = 0;
 	sc->work_urb.status = 0;
 
-	init_timer(&timer);
-	timer.function = ub_probe_timeout;
-	timer.data = (unsigned long) &compl;
-	timer.expires = jiffies + UB_CTRL_TIMEOUT;
-	add_timer(&timer);
-
 	if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) {
 		printk(KERN_WARNING
 		     "%s: Unable to submit a probe clear (%d)\n", sc->name, rc);
-		del_timer_sync(&timer);
 		return rc;
 	}
 
+	init_timer(&timer);
+	timer.function = ub_probe_timeout;
+	timer.data = (unsigned long) &compl;
+	timer.expires = jiffies + UB_CTRL_TIMEOUT;
+	add_timer(&timer);
+
 	wait_for_completion(&compl);
 
 	del_timer_sync(&timer);
-	/*
-	 * Most of the time, URB was done and dev set to NULL, and so
-	 * the unlink bounces out with ENODEV. We do not call usb_kill_urb
-	 * because we still think about a backport to 2.4.
-	 */
-	usb_unlink_urb(&sc->work_urb);
+	usb_kill_urb(&sc->work_urb);
 
 	/* reset the endpoint toggle */
 	usb_settoggle(sc->dev, endp, usb_pipeout(sc->last_pipe), 0);
@@ -1813,6 +1858,7 @@
 	request_queue_t *q;
 	struct gendisk *disk;
 	int rc;
+	int i;
 
 	rc = -ENOMEM;
 	if ((sc = kmalloc(sizeof(struct ub_dev), GFP_KERNEL)) == NULL)
@@ -1879,9 +1925,15 @@
 	 * has to succeed, so we clear checks with an additional one here.
 	 * In any case it's not our business how revaliadation is implemented.
 	 */
-	ub_sync_tur(sc);
+	for (i = 0; i < 3; i++) {	/* Retries for benh's key */
+		if ((rc = ub_sync_tur(sc)) <= 0) break;
+		if (rc != 0x6) break;
+		msleep(10);
+	}
 
 	sc->removable = 1;		/* XXX Query this from the device */
+	sc->changed = 1;		/* ub_revalidate clears only */
+	sc->first_open = 1;
 
 	ub_revalidate(sc);
 	/* This is pretty much a long term P3 */
@@ -1915,7 +1967,7 @@
 	blk_queue_max_phys_segments(q, UB_MAX_REQ_SG);
 	// blk_queue_segment_boundary(q, CARM_SG_BOUNDARY);
 	blk_queue_max_sectors(q, UB_MAX_SECTORS);
-	// blk_queue_hardsect_size(q, xxxxx);
+	blk_queue_hardsect_size(q, sc->capacity.bsize);
 
 	/*
 	 * This is a serious infraction, caused by a deficiency in the
@@ -2006,17 +2058,6 @@
 		blk_cleanup_queue(q);
 
 	/*
-	 * If we zero disk->private_data BEFORE put_disk, we have to check
-	 * for NULL all over the place in open, release, check_media and
-	 * revalidate, because the block level semaphore is well inside the
-	 * put_disk. But we cannot zero after the call, because *disk is gone.
-	 * The sd.c is blatantly racy in this area.
-	 */
-	/* disk->private_data = NULL; */
-	put_disk(disk);
-	sc->disk = NULL;
-
-	/*
 	 * We really expect blk_cleanup_queue() to wait, so no amount
 	 * of paranoya is too much.
 	 *
@@ -2033,6 +2074,13 @@
 		    "URB is active after disconnect\n", sc->name);
 	}
 	spin_unlock_irqrestore(&sc->lock, flags);
+
+	/*
+	 * There is virtually no chance that other CPU runs times so long
+	 * after ub_urb_complete should have called del_timer, but only if HCD
+	 * didn't forget to deliver a callback on unlink.
+	 */
+	del_timer_sync(&sc->work_timer);
 
 	/*
 	 * At this point there must be no commands coming from anyone
diff -Nru a/drivers/block/umem.c b/drivers/block/umem.c
--- a/drivers/block/umem.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/block/umem.c	2004-12-24 13:37:31 -08:00
@@ -83,15 +83,15 @@
 #define DEBUG_LED_ON_TRANSFER	0x01
 #define DEBUG_BATTERY_POLLING	0x02
 
-MODULE_PARM(debug, "i");
+module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Debug bitmask");
 
 static int pci_read_cmd = 0x0C;		/* Read Multiple */
-MODULE_PARM(pci_read_cmd, "i");
+module_param(pci_read_cmd, int, 0);
 MODULE_PARM_DESC(pci_read_cmd, "PCI read command");
 
 static int pci_write_cmd = 0x0F;	/* Write and Invalidate */
-MODULE_PARM(pci_write_cmd, "i");
+module_param(pci_write_cmd, int, 0);
 MODULE_PARM_DESC(pci_write_cmd, "PCI write command");
 
 static int pci_cmds;
diff -Nru a/drivers/block/viodasd.c b/drivers/block/viodasd.c
--- a/drivers/block/viodasd.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/block/viodasd.c	2004-12-24 13:36:31 -08:00
@@ -764,8 +764,8 @@
 	d = &viodasd_devices[vdev->unit_address];
 	if (d->disk) {
 		del_gendisk(d->disk);
-		put_disk(d->disk);
 		blk_cleanup_queue(d->disk->queue);
+		put_disk(d->disk);
 		d->disk = NULL;
 	}
 	d->dev = NULL;
diff -Nru a/drivers/block/xd.c b/drivers/block/xd.c
--- a/drivers/block/xd.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/block/xd.c	2004-12-24 13:37:18 -08:00
@@ -266,7 +266,7 @@
 /* xd_detect: scan the possible BIOS ROM locations for the signature strings */
 static u_char __init xd_detect (u_char *controller, unsigned int *address)
 {
-	u_char i,j,found = 0;
+	int i, j;
 
 	if (xd_override)
 	{
@@ -275,15 +275,23 @@
 		return(1);
 	}
 
-	for (i = 0; i < (sizeof(xd_bases) / sizeof(xd_bases[0])) && !found; i++)
-		for (j = 1; j < (sizeof(xd_sigs) / sizeof(xd_sigs[0])) && !found; j++)
-			if (isa_check_signature(xd_bases[i] + xd_sigs[j].offset,xd_sigs[j].string,strlen(xd_sigs[j].string))) {
+	for (i = 0; i < (sizeof(xd_bases) / sizeof(xd_bases[0])); i++) {
+		void __iomem *p = ioremap(xd_bases[i], 0x2000);
+		if (!p)
+			continue;
+		for (j = 1; j < (sizeof(xd_sigs) / sizeof(xd_sigs[0])); j++) {
+			const char *s = xd_sigs[j].string;
+			if (check_signature(p + xd_sigs[j].offset, s, strlen(s))) {
 				*controller = j;
 				xd_type = j;
 				*address = xd_bases[i];
-				found++;
+				iounmap(p);
+				return 1;
 			}
-	return (found);
+		}
+		iounmap(p);
+	}
+	return 0;
 }
 
 /* do_xd_request: handle an incoming request */
diff -Nru a/drivers/block/z2ram.c b/drivers/block/z2ram.c
--- a/drivers/block/z2ram.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/block/z2ram.c	2004-12-24 13:37:01 -08:00
@@ -32,9 +32,9 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
+#include <linux/bitops.h>
 
 #include <asm/setup.h>
-#include <asm/bitops.h>
 #include <asm/amigahw.h>
 #include <asm/pgtable.h>
 
diff -Nru a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
--- a/drivers/bluetooth/bcm203x.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/bluetooth/bcm203x.c	2004-12-24 13:36:17 -08:00
@@ -2,6 +2,7 @@
  *
  *  Broadcom Blutonium firmware driver
  *
+ *  Copyright (C) 2003  Maxim Krasnyansky <maxk@qualcomm.com>
  *  Copyright (C) 2003  Marcel Holtmann <marcel@holtmann.org>
  *
  *
@@ -264,7 +265,7 @@
 
 	BT_DBG("intf %p", intf);
 
-	usb_unlink_urb(data->urb);
+	usb_kill_urb(data->urb);
 
 	usb_set_intfdata(intf, NULL);
 
diff -Nru a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
--- a/drivers/bluetooth/bfusb.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/bluetooth/bfusb.c	2004-12-24 13:37:02 -08:00
@@ -123,7 +123,7 @@
 
 	while ((skb = skb_dequeue(&bfusb->pending_q))) {
 		urb = ((struct bfusb_scb *) skb->cb)->urb;
-		usb_unlink_urb(urb);
+		usb_kill_urb(urb);
 		skb_queue_tail(&bfusb->completed_q, skb);
 	}
 
@@ -680,7 +680,7 @@
 	bfusb->bulk_out_ep   = bulk_out_ep->desc.bEndpointAddress;
 	bfusb->bulk_pkt_size = bulk_out_ep->desc.wMaxPacketSize;
 
-	bfusb->lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&bfusb->lock);
 
 	bfusb->reassembly = NULL;
 
diff -Nru a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
--- a/drivers/bluetooth/bluecard_cs.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/bluetooth/bluecard_cs.c	2004-12-24 13:36:49 -08:00
@@ -34,6 +34,8 @@
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/spinlock.h>
+#include <linux/moduleparam.h>
+
 #include <linux/skbuff.h>
 #include <asm/io.h>
 
@@ -54,11 +56,11 @@
 
 
 /* Bit map of interrupts to choose from */
-static u_int irq_mask = 0x86bc;
+static unsigned int irq_mask = 0x86bc;
 static int irq_list[4] = { -1 };
 
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-4i");
+module_param(irq_mask, uint, 0);
+module_param_array(irq_list, int, NULL, 0);
 
 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Bluetooth driver for the Anycom BlueCard (LSE039/LSE041)");
@@ -90,14 +92,14 @@
 } bluecard_info_t;
 
 
-void bluecard_config(dev_link_t *link);
-void bluecard_release(dev_link_t *link);
-int bluecard_event(event_t event, int priority, event_callback_args_t *args);
+static void bluecard_config(dev_link_t *link);
+static void bluecard_release(dev_link_t *link);
+static int bluecard_event(event_t event, int priority, event_callback_args_t *args);
 
 static dev_info_t dev_info = "bluecard_cs";
 
-dev_link_t *bluecard_attach(void);
-void bluecard_detach(dev_link_t *);
+static dev_link_t *bluecard_attach(void);
+static void bluecard_detach(dev_link_t *);
 
 static dev_link_t *dev_list = NULL;
 
@@ -170,7 +172,7 @@
 /* ======================== LED handling routines ======================== */
 
 
-void bluecard_activity_led_timeout(u_long arg)
+static void bluecard_activity_led_timeout(u_long arg)
 {
 	bluecard_info_t *info = (bluecard_info_t *)arg;
 	unsigned int iobase = info->link.io.BasePort1;
@@ -719,7 +721,7 @@
 /* ======================== Card services HCI interaction ======================== */
 
 
-int bluecard_open(bluecard_info_t *info)
+static int bluecard_open(bluecard_info_t *info)
 {
 	unsigned int iobase = info->link.io.BasePort1;
 	struct hci_dev *hdev;
@@ -837,7 +839,7 @@
 }
 
 
-int bluecard_close(bluecard_info_t *info)
+static int bluecard_close(bluecard_info_t *info)
 {
 	unsigned int iobase = info->link.io.BasePort1;
 	struct hci_dev *hdev = info->hdev;
@@ -864,7 +866,7 @@
 	return 0;
 }
 
-dev_link_t *bluecard_attach(void)
+static dev_link_t *bluecard_attach(void)
 {
 	bluecard_info_t *info;
 	client_reg_t client_reg;
@@ -922,7 +924,7 @@
 }
 
 
-void bluecard_detach(dev_link_t *link)
+static void bluecard_detach(dev_link_t *link)
 {
 	bluecard_info_t *info = link->priv;
 	dev_link_t **linkp;
@@ -967,7 +969,7 @@
 	return pcmcia_parse_tuple(handle, tuple, parse);
 }
 
-void bluecard_config(dev_link_t *link)
+static void bluecard_config(dev_link_t *link)
 {
 	client_handle_t handle = link->handle;
 	bluecard_info_t *info = link->priv;
@@ -1042,7 +1044,7 @@
 }
 
 
-void bluecard_release(dev_link_t *link)
+static void bluecard_release(dev_link_t *link)
 {
 	bluecard_info_t *info = link->priv;
 
@@ -1061,7 +1063,7 @@
 }
 
 
-int bluecard_event(event_t event, int priority, event_callback_args_t *args)
+static int bluecard_event(event_t event, int priority, event_callback_args_t *args)
 {
 	dev_link_t *link = args->client_data;
 	bluecard_info_t *info = link->priv;
diff -Nru a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
--- a/drivers/bluetooth/bt3c_cs.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/bluetooth/bt3c_cs.c	2004-12-24 13:37:30 -08:00
@@ -34,13 +34,14 @@
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/spinlock.h>
+#include <linux/moduleparam.h>
 
 #include <linux/skbuff.h>
 #include <linux/string.h>
 #include <linux/serial.h>
 #include <linux/serial_reg.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include <linux/device.h>
@@ -63,11 +64,11 @@
 
 
 /* Bit map of interrupts to choose from */
-static u_int irq_mask = 0xffff;
+static unsigned int irq_mask = 0xffff;
 static int irq_list[4] = { -1 };
 
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-4i");
+module_param(irq_mask, uint, 0);
+module_param_array(irq_list, int, NULL, 0);
 
 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>, Jose Orlando Pereira <jop@di.uminho.pt>");
 MODULE_DESCRIPTION("Bluetooth driver for the 3Com Bluetooth PCMCIA card");
@@ -95,14 +96,14 @@
 } bt3c_info_t;
 
 
-void bt3c_config(dev_link_t *link);
-void bt3c_release(dev_link_t *link);
-int bt3c_event(event_t event, int priority, event_callback_args_t *args);
+static void bt3c_config(dev_link_t *link);
+static void bt3c_release(dev_link_t *link);
+static int bt3c_event(event_t event, int priority, event_callback_args_t *args);
 
 static dev_info_t dev_info = "bt3c_cs";
 
-dev_link_t *bt3c_attach(void);
-void bt3c_detach(dev_link_t *);
+static dev_link_t *bt3c_attach(void);
+static void bt3c_detach(dev_link_t *);
 
 static dev_link_t *dev_list = NULL;
 
@@ -131,28 +132,28 @@
 #define CONTROL  4
 
 
-inline void bt3c_address(unsigned int iobase, unsigned short addr)
+static inline void bt3c_address(unsigned int iobase, unsigned short addr)
 {
 	outb(addr & 0xff, iobase + ADDR_L);
 	outb((addr >> 8) & 0xff, iobase + ADDR_H);
 }
 
 
-inline void bt3c_put(unsigned int iobase, unsigned short value)
+static inline void bt3c_put(unsigned int iobase, unsigned short value)
 {
 	outb(value & 0xff, iobase + DATA_L);
 	outb((value >> 8) & 0xff, iobase + DATA_H);
 }
 
 
-inline void bt3c_io_write(unsigned int iobase, unsigned short addr, unsigned short value)
+static inline void bt3c_io_write(unsigned int iobase, unsigned short addr, unsigned short value)
 {
 	bt3c_address(iobase, addr);
 	bt3c_put(iobase, value);
 }
 
 
-inline unsigned short bt3c_get(unsigned int iobase)
+static inline unsigned short bt3c_get(unsigned int iobase)
 {
 	unsigned short value = inb(iobase + DATA_L);
 
@@ -162,7 +163,7 @@
 }
 
 
-inline unsigned short bt3c_read(unsigned int iobase, unsigned short addr)
+static inline unsigned short bt3c_read(unsigned int iobase, unsigned short addr)
 {
 	bt3c_address(iobase, addr);
 
@@ -489,13 +490,10 @@
 
 static struct device *bt3c_device(void)
 {
-	static char *kobj_name = "bt3c";
-
 	static struct device dev = {
 		.bus_id = "pcmcia",
 	};
-	dev.kobj.k_name = kmalloc(strlen(kobj_name) + 1, GFP_KERNEL);
-	strcpy(dev.kobj.k_name, kobj_name);
+	kobject_set_name(&dev.kobj, "bt3c");
 	kobject_init(&dev.kobj);
 
 	return &dev;
@@ -586,7 +584,7 @@
 }
 
 
-int bt3c_open(bt3c_info_t *info)
+static int bt3c_open(bt3c_info_t *info)
 {
 	const struct firmware *firmware;
 	struct hci_dev *hdev;
@@ -656,7 +654,7 @@
 }
 
 
-int bt3c_close(bt3c_info_t *info)
+static int bt3c_close(bt3c_info_t *info)
 {
 	struct hci_dev *hdev = info->hdev;
 
@@ -673,7 +671,7 @@
 	return 0;
 }
 
-dev_link_t *bt3c_attach(void)
+static dev_link_t *bt3c_attach(void)
 {
 	bt3c_info_t *info;
 	client_reg_t client_reg;
@@ -731,7 +729,7 @@
 }
 
 
-void bt3c_detach(dev_link_t *link)
+static void bt3c_detach(dev_link_t *link)
 {
 	bt3c_info_t *info = link->priv;
 	dev_link_t **linkp;
@@ -785,7 +783,7 @@
 	return get_tuple(handle, tuple, parse);
 }
 
-void bt3c_config(dev_link_t *link)
+static void bt3c_config(dev_link_t *link)
 {
 	static ioaddr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
 	client_handle_t handle = link->handle;
@@ -898,7 +896,7 @@
 }
 
 
-void bt3c_release(dev_link_t *link)
+static void bt3c_release(dev_link_t *link)
 {
 	bt3c_info_t *info = link->priv;
 
@@ -915,7 +913,7 @@
 }
 
 
-int bt3c_event(event_t event, int priority, event_callback_args_t *args)
+static int bt3c_event(event_t event, int priority, event_callback_args_t *args)
 {
 	dev_link_t *link = args->client_data;
 	bt3c_info_t *info = link->priv;
diff -Nru a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
--- a/drivers/bluetooth/btuart_cs.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/bluetooth/btuart_cs.c	2004-12-24 13:37:30 -08:00
@@ -33,13 +33,14 @@
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/spinlock.h>
+#include <linux/moduleparam.h>
 
 #include <linux/skbuff.h>
 #include <linux/string.h>
 #include <linux/serial.h>
 #include <linux/serial_reg.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include <pcmcia/version.h>
@@ -59,11 +60,11 @@
 
 
 /* Bit map of interrupts to choose from */
-static u_int irq_mask = 0xffff;
+static unsigned int irq_mask = 0xffff;
 static int irq_list[4] = { -1 };
 
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-4i");
+module_param(irq_mask, uint, 0);
+module_param_array(irq_list, int, NULL, 0);
 
 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Bluetooth driver for Bluetooth PCMCIA cards with HCI UART interface");
@@ -91,14 +92,14 @@
 } btuart_info_t;
 
 
-void btuart_config(dev_link_t *link);
-void btuart_release(dev_link_t *link);
-int btuart_event(event_t event, int priority, event_callback_args_t *args);
+static void btuart_config(dev_link_t *link);
+static void btuart_release(dev_link_t *link);
+static int btuart_event(event_t event, int priority, event_callback_args_t *args);
 
 static dev_info_t dev_info = "btuart_cs";
 
-dev_link_t *btuart_attach(void);
-void btuart_detach(dev_link_t *);
+static dev_link_t *btuart_attach(void);
+static void btuart_detach(dev_link_t *);
 
 static dev_link_t *dev_list = NULL;
 
@@ -491,7 +492,7 @@
 /* ======================== Card services HCI interaction ======================== */
 
 
-int btuart_open(btuart_info_t *info)
+static int btuart_open(btuart_info_t *info)
 {
 	unsigned long flags;
 	unsigned int iobase = info->link.io.BasePort1;
@@ -560,7 +561,7 @@
 }
 
 
-int btuart_close(btuart_info_t *info)
+static int btuart_close(btuart_info_t *info)
 {
 	unsigned long flags;
 	unsigned int iobase = info->link.io.BasePort1;
@@ -589,7 +590,7 @@
 	return 0;
 }
 
-dev_link_t *btuart_attach(void)
+static dev_link_t *btuart_attach(void)
 {
 	btuart_info_t *info;
 	client_reg_t client_reg;
@@ -647,7 +648,7 @@
 }
 
 
-void btuart_detach(dev_link_t *link)
+static void btuart_detach(dev_link_t *link)
 {
 	btuart_info_t *info = link->priv;
 	dev_link_t **linkp;
@@ -701,7 +702,7 @@
 	return get_tuple(handle, tuple, parse);
 }
 
-void btuart_config(dev_link_t *link)
+static void btuart_config(dev_link_t *link)
 {
 	static ioaddr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
 	client_handle_t handle = link->handle;
@@ -815,7 +816,7 @@
 }
 
 
-void btuart_release(dev_link_t *link)
+static void btuart_release(dev_link_t *link)
 {
 	btuart_info_t *info = link->priv;
 
@@ -832,7 +833,7 @@
 }
 
 
-int btuart_event(event_t event, int priority, event_callback_args_t *args)
+static int btuart_event(event_t event, int priority, event_callback_args_t *args)
 {
 	dev_link_t *link = args->client_data;
 	btuart_info_t *info = link->priv;
diff -Nru a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
--- a/drivers/bluetooth/dtl1_cs.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/bluetooth/dtl1_cs.c	2004-12-24 13:36:48 -08:00
@@ -33,13 +33,14 @@
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/spinlock.h>
+#include <linux/moduleparam.h>
 
 #include <linux/skbuff.h>
 #include <linux/string.h>
 #include <linux/serial.h>
 #include <linux/serial_reg.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include <pcmcia/version.h>
@@ -59,11 +60,11 @@
 
 
 /* Bit map of interrupts to choose from */
-static u_int irq_mask = 0xffff;
+static unsigned int irq_mask = 0xffff;
 static int irq_list[4] = { -1 };
 
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-4i");
+module_param(irq_mask, uint, 0);
+module_param_array(irq_list, int, NULL, 0);
 
 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Bluetooth driver for Nokia Connectivity Card DTL-1");
@@ -94,14 +95,14 @@
 } dtl1_info_t;
 
 
-void dtl1_config(dev_link_t *link);
-void dtl1_release(dev_link_t *link);
-int dtl1_event(event_t event, int priority, event_callback_args_t *args);
+static void dtl1_config(dev_link_t *link);
+static void dtl1_release(dev_link_t *link);
+static int dtl1_event(event_t event, int priority, event_callback_args_t *args);
 
 static dev_info_t dev_info = "dtl1_cs";
 
-dev_link_t *dtl1_attach(void);
-void dtl1_detach(dev_link_t *);
+static dev_link_t *dtl1_attach(void);
+static void dtl1_detach(dev_link_t *);
 
 static dev_link_t *dev_list = NULL;
 
@@ -468,7 +469,7 @@
 /* ======================== Card services HCI interaction ======================== */
 
 
-int dtl1_open(dtl1_info_t *info)
+static int dtl1_open(dtl1_info_t *info)
 {
 	unsigned long flags;
 	unsigned int iobase = info->link.io.BasePort1;
@@ -539,7 +540,7 @@
 }
 
 
-int dtl1_close(dtl1_info_t *info)
+static int dtl1_close(dtl1_info_t *info)
 {
 	unsigned long flags;
 	unsigned int iobase = info->link.io.BasePort1;
@@ -568,7 +569,7 @@
 	return 0;
 }
 
-dev_link_t *dtl1_attach(void)
+static dev_link_t *dtl1_attach(void)
 {
 	dtl1_info_t *info;
 	client_reg_t client_reg;
@@ -626,7 +627,7 @@
 }
 
 
-void dtl1_detach(dev_link_t *link)
+static void dtl1_detach(dev_link_t *link)
 {
 	dtl1_info_t *info = link->priv;
 	dev_link_t **linkp;
@@ -680,7 +681,7 @@
 	return get_tuple(handle, tuple, parse);
 }
 
-void dtl1_config(dev_link_t *link)
+static void dtl1_config(dev_link_t *link)
 {
 	client_handle_t handle = link->handle;
 	dtl1_info_t *info = link->priv;
@@ -767,7 +768,7 @@
 }
 
 
-void dtl1_release(dev_link_t *link)
+static void dtl1_release(dev_link_t *link)
 {
 	dtl1_info_t *info = link->priv;
 
@@ -784,7 +785,7 @@
 }
 
 
-int dtl1_event(event_t event, int priority, event_callback_args_t *args)
+static int dtl1_event(event_t event, int priority, event_callback_args_t *args)
 {
 	dev_link_t *link = args->client_data;
 	dtl1_info_t *info = link->priv;
diff -Nru a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
--- a/drivers/bluetooth/hci_ldisc.c	2004-12-24 13:37:17 -08:00
+++ b/drivers/bluetooth/hci_ldisc.c	2004-12-24 13:37:17 -08:00
@@ -143,7 +143,7 @@
 		int len;
 	
 		set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-		len = tty->driver->write(tty, 0, skb->data, skb->len);
+		len = tty->driver->write(tty, skb->data, skb->len);
 		hdev->stat.byte_tx += len;
 
 		skb_pull(skb, len);
@@ -502,7 +502,7 @@
 {
 	return 0;
 }
-static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, const unsigned char __user *data, size_t count)
+static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, const unsigned char *data, size_t count)
 {
 	return 0;
 }
diff -Nru a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
--- a/drivers/bluetooth/hci_usb.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/bluetooth/hci_usb.c	2004-12-24 13:37:19 -08:00
@@ -40,6 +40,7 @@
 #include <linux/unistd.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
+#include <linux/moduleparam.h>
 
 #include <linux/slab.h>
 #include <linux/errno.h>
@@ -65,6 +66,10 @@
 #define URB_ZERO_PACKET 0
 #endif
 
+#ifdef CONFIG_BT_HCIUSB_SCO
+static int isoc = 2;
+#endif
+
 #define VERSION "2.7"
 
 static struct usb_driver hci_usb_driver; 
@@ -96,13 +101,18 @@
 	{ USB_DEVICE(0x0a5c, 0x2033), .driver_info = HCI_IGNORE },
 
 	/* Broadcom BCM2035 */
+	{ USB_DEVICE(0x0a5c, 0x2009), .driver_info = HCI_RESET | HCI_BROKEN_ISOC },
 	{ USB_DEVICE(0x0a5c, 0x200a), .driver_info = HCI_RESET | HCI_BROKEN_ISOC },
 
+	/* Microsoft Wireless Transceiver for Bluetooth 2.0 */
+	{ USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET | HCI_BROKEN_ISOC },
+
 	/* ISSC Bluetooth Adapter v3.1 */
 	{ USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET },
 
-	/* Digianswer device */
+	/* Digianswer devices */
 	{ USB_DEVICE(0x08fd, 0x0001), .driver_info = HCI_DIGIANSWER },
+	{ USB_DEVICE(0x08fd, 0x0002), .driver_info = HCI_IGNORE },
 
 	/* RTX Telecom based adapter with buggy SCO support */
 	{ USB_DEVICE(0x0400, 0x0807), .driver_info = HCI_BROKEN_ISOC },
@@ -110,7 +120,7 @@
 	{ }	/* Terminating entry */
 };
 
-struct _urb *_urb_alloc(int isoc, int gfp)
+static struct _urb *_urb_alloc(int isoc, int gfp)
 {
 	struct _urb *_urb = kmalloc(sizeof(struct _urb) +
 				sizeof(struct usb_iso_packet_descriptor) * isoc, gfp);
@@ -121,7 +131,7 @@
 	return _urb;
 }
 
-struct _urb *_urb_dequeue(struct _urb_queue *q)
+static struct _urb *_urb_dequeue(struct _urb_queue *q)
 {
 	struct _urb *_urb = NULL;
 	unsigned long flags;
@@ -790,7 +800,12 @@
 	kfree(husb);
 }
 
-int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
+static void hci_usb_notify(struct hci_dev *hdev, unsigned int evt)
+{
+	BT_DBG("%s evt %d", hdev->name, evt);
+}
+
+static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_host_endpoint *bulk_out_ep = NULL;
@@ -856,9 +871,9 @@
 	husb->intr_in_ep  = intr_in_ep;
 
 	if (id->driver_info & HCI_DIGIANSWER)
-		husb->ctrl_req = HCI_DIGI_REQ;
+		husb->ctrl_req = USB_TYPE_VENDOR;
 	else
-		husb->ctrl_req = HCI_CTRL_REQ;
+		husb->ctrl_req = USB_TYPE_CLASS;
 
 	/* Find isochronous endpoints that we can use */
 	size = 0; 
@@ -867,7 +882,7 @@
 	isoc_ifnum = 1;
 
 #ifdef CONFIG_BT_HCIUSB_SCO
-	if (!(id->driver_info & HCI_BROKEN_ISOC))
+	if (isoc && !(id->driver_info & HCI_BROKEN_ISOC))
 		isoc_iface = usb_ifnum_to_if(udev, isoc_ifnum);
 
 	if (isoc_iface) {
@@ -883,7 +898,7 @@
 				switch (ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
 				case USB_ENDPOINT_XFER_ISOC:
 					if (ep->desc.wMaxPacketSize < size ||
-							uif->desc.bAlternateSetting > 2)
+							uif->desc.bAlternateSetting != isoc)
 						break;
 					size = ep->desc.wMaxPacketSize;
 
@@ -906,7 +921,9 @@
 				BT_ERR("Can't claim isoc interface");
 			else if (usb_set_interface(udev, isoc_ifnum, isoc_alts)) {
 				BT_ERR("Can't set isoc interface settings");
+				husb->isoc_iface = isoc_iface;
 				usb_driver_release_interface(&hci_usb_driver, isoc_iface);
+				husb->isoc_iface = NULL;
 			} else {
 				husb->isoc_iface  = isoc_iface;
 				husb->isoc_in_ep  = isoc_in_ep;
@@ -916,7 +933,7 @@
 	}
 #endif
 
-	husb->completion_lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&husb->completion_lock);
 
 	for (i = 0; i < 4; i++) {
 		skb_queue_head_init(&husb->transmit_q[i]);
@@ -942,6 +959,7 @@
 	hdev->flush    = hci_usb_flush;
 	hdev->send     = hci_usb_send_frame;
 	hdev->destruct = hci_usb_destruct;
+	hdev->notify   = hci_usb_notify;
 
 	hdev->owner = THIS_MODULE;
 
@@ -1017,6 +1035,11 @@
 
 module_init(hci_usb_init);
 module_exit(hci_usb_exit);
+
+#ifdef CONFIG_BT_HCIUSB_SCO
+module_param(isoc, int, 0644);
+MODULE_PARM_DESC(isoc, "Set isochronous transfers for SCO over HCI support");
+#endif
 
 MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Bluetooth HCI USB driver ver " VERSION);
diff -Nru a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h
--- a/drivers/bluetooth/hci_usb.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/bluetooth/hci_usb.h	2004-12-24 13:37:18 -08:00
@@ -28,9 +28,6 @@
 #define HCI_DEV_SUBCLASS	0x01	/* RF subclass */
 #define HCI_DEV_PROTOCOL	0x01	/* Bluetooth programming protocol */
 
-#define HCI_CTRL_REQ		0x20
-#define HCI_DIGI_REQ		0x40
-
 #define HCI_IGNORE		0x01
 #define HCI_RESET		0x02
 #define HCI_DIGIANSWER		0x04
@@ -59,8 +56,6 @@
 	struct urb        urb;
 };
 
-struct _urb *_urb_alloc(int isoc, int gfp);
-
 static inline void _urb_free(struct _urb *_urb)
 {
 	kfree(_urb);
@@ -98,8 +93,6 @@
 		spin_unlock_irqrestore(&q->lock, flags);
 	}
 }
-
-struct _urb *_urb_dequeue(struct _urb_queue *q);
 
 struct hci_usb {
 	struct hci_dev		*hdev;
diff -Nru a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
--- a/drivers/bluetooth/hci_vhci.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/bluetooth/hci_vhci.c	2004-12-24 13:37:29 -08:00
@@ -338,7 +338,7 @@
         &hci_vhci_fops
 };
 
-int __init hci_vhci_init(void)
+static int __init hci_vhci_init(void)
 {
 	BT_INFO("VHCI driver ver %s", VERSION);
 
@@ -350,7 +350,7 @@
 	return 0;
 }
 
-void hci_vhci_cleanup(void)
+static void hci_vhci_cleanup(void)
 {
 	misc_deregister(&hci_vhci_miscdev);
 }
diff -Nru a/drivers/cdrom/Makefile b/drivers/cdrom/Makefile
--- a/drivers/cdrom/Makefile	2004-12-24 13:36:48 -08:00
+++ b/drivers/cdrom/Makefile	2004-12-24 13:36:48 -08:00
@@ -8,6 +8,7 @@
 obj-$(CONFIG_BLK_DEV_IDECD)	+=              cdrom.o
 obj-$(CONFIG_BLK_DEV_SR)	+=              cdrom.o
 obj-$(CONFIG_PARIDE_PCD)	+=		cdrom.o
+obj-$(CONFIG_CDROM_PKTCDVD)	+=		cdrom.o
 
 obj-$(CONFIG_AZTCD)		+= aztcd.o
 obj-$(CONFIG_CDU31A)		+= cdu31a.o     cdrom.o
diff -Nru a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
--- a/drivers/cdrom/cdrom.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/cdrom/cdrom.c	2004-12-24 13:36:19 -08:00
@@ -234,6 +234,12 @@
   -- Mt Rainier support
   -- DVD-RAM write open fixes
 
+  Nov 5 2001, Aug 8 2002. Modified by Andy Polyakov
+  <appro@fy.chalmers.se> to support MMC-3 compliant DVD+RW units.
+
+  Modified by Nigel Kukard <nkukard@lbsd.net> - support DVD+RW
+  2.4.x patch by Andy Polyakov <appro@fy.chalmers.se>
+
 -------------------------------------------------------------------------*/
 
 #define REVISION "Revision: 3.20"
@@ -290,12 +296,12 @@
 static int check_media_type;
 /* automatically restart mrw format */
 static int mrw_format_restart = 1;
-MODULE_PARM(debug, "i");
-MODULE_PARM(autoclose, "i");
-MODULE_PARM(autoeject, "i");
-MODULE_PARM(lockdoor, "i");
-MODULE_PARM(check_media_type, "i");
-MODULE_PARM(mrw_format_restart, "i");
+module_param(debug, bool, 0);
+module_param(autoclose, bool, 0);
+module_param(autoeject, bool, 0);
+module_param(lockdoor, bool, 0);
+module_param(check_media_type, bool, 0);
+module_param(mrw_format_restart, bool, 0);
 
 static spinlock_t cdrom_lock = SPIN_LOCK_UNLOCKED;
 
@@ -540,6 +546,8 @@
 		return ret;
 
 	mfd = (struct mrw_feature_desc *)&buffer[sizeof(struct feature_header)];
+	if (be16_to_cpu(mfd->feature_code) != CDF_MRW)
+		return 1;
 	*write = mfd->write;
 
 	if ((ret = cdrom_mrw_probe_pc(cdi))) {
@@ -848,6 +856,39 @@
 	return ret;
 }
 
+static void cdrom_mmc3_profile(struct cdrom_device_info *cdi)
+{
+	struct packet_command cgc;
+	char buffer[32];
+	int ret, mmc3_profile;
+
+	init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);
+
+	cgc.cmd[0] = GPCMD_GET_CONFIGURATION;
+	cgc.cmd[1] = 0;
+	cgc.cmd[2] = cgc.cmd[3] = 0;		/* Starting Feature Number */
+	cgc.cmd[8] = sizeof(buffer);		/* Allocation Length */
+	cgc.quiet = 1;
+
+	if ((ret = cdi->ops->generic_packet(cdi, &cgc)))
+		mmc3_profile = 0xffff;
+	else
+		mmc3_profile = (buffer[6] << 8) | buffer[7];
+
+	cdi->mmc3_profile = mmc3_profile;
+}
+
+static int cdrom_is_dvd_rw(struct cdrom_device_info *cdi)
+{
+	switch (cdi->mmc3_profile) {
+	case 0x12:	/* DVD-RAM	*/
+	case 0x1A:	/* DVD+RW	*/
+		return 0;
+	default:
+		return 1;
+	}
+}
+
 /*
  * returns 0 for ok to open write, non-0 to disallow
  */
@@ -889,10 +930,50 @@
  		ret = cdrom_ram_open_write(cdi);
 	else if (CDROM_CAN(CDC_MO_DRIVE))
 		ret = mo_open_write(cdi);
+	else if (!cdrom_is_dvd_rw(cdi))
+		ret = 0;
 
 	return ret;
 }
 
+static void cdrom_dvd_rw_close_write(struct cdrom_device_info *cdi)
+{
+	struct packet_command cgc;
+
+	if (cdi->mmc3_profile != 0x1a) {
+		cdinfo(CD_CLOSE, "%s: No DVD+RW\n", cdi->name);
+		return;
+	}
+
+	if (!cdi->media_written) {
+		cdinfo(CD_CLOSE, "%s: DVD+RW media clean\n", cdi->name);
+		return;
+	}
+
+	printk(KERN_INFO "cdrom: %s: dirty DVD+RW media, \"finalizing\"\n",
+	       cdi->name);
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.cmd[0] = GPCMD_FLUSH_CACHE;
+	cgc.timeout = 30*HZ;
+	cdi->ops->generic_packet(cdi, &cgc);
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.cmd[0] = GPCMD_CLOSE_TRACK;
+	cgc.timeout = 3000*HZ;
+	cgc.quiet = 1;
+	cdi->ops->generic_packet(cdi, &cgc);
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.cmd[0] = GPCMD_CLOSE_TRACK;
+	cgc.cmd[2] = 2;	 /* Close session */
+	cgc.quiet = 1;
+	cgc.timeout = 3000*HZ;
+	cdi->ops->generic_packet(cdi, &cgc);
+
+	cdi->media_written = 0;
+}
+
 static int cdrom_close_write(struct cdrom_device_info *cdi)
 {
 #if 0
@@ -925,6 +1006,7 @@
 		ret = open_for_data(cdi);
 		if (ret)
 			goto err;
+		cdrom_mmc3_profile(cdi);
 		if (fp->f_mode & FMODE_WRITE) {
 			ret = -EROFS;
 			if (cdrom_open_write(cdi))
@@ -932,6 +1014,7 @@
 			if (!CDROM_CAN(CDC_RAM))
 				goto err;
 			ret = 0;
+			cdi->media_written = 0;
 		}
 	}
 
@@ -1123,6 +1206,8 @@
 		cdi->use_count--;
 	if (cdi->use_count == 0)
 		cdinfo(CD_CLOSE, "Use count for \"/dev/%s\" now zero\n", cdi->name);
+	if (cdi->use_count == 0)
+		cdrom_dvd_rw_close_write(cdi);
 	if (cdi->use_count == 0 &&
 	    (cdo->capability & CDC_LOCK) && !keeplocked) {
 		cdinfo(CD_CLOSE, "Unlocking door!\n");
@@ -1329,6 +1414,7 @@
 	if (cdi->ops->media_changed(cdi, CDSL_CURRENT)) {
 		cdi->mc_flags = 0x3;    /* set bit on both queues */
 		ret |= 1;
+		cdi->media_written = 0;
 	}
 	cdi->mc_flags &= ~mask;         /* clear bit */
 	return ret;
@@ -1790,7 +1876,7 @@
 	s->manufact.len = buf[0] << 8 | buf[1];
 	if (s->manufact.len < 0 || s->manufact.len > 2048) {
 		cdinfo(CD_WARNING, "Received invalid manufacture info length"
-				   " (%d)\n", s->bca.len);
+				   " (%d)\n", s->manufact.len);
 		ret = -EIO;
 	} else {
 		memcpy(s->manufact.value, &buf[4], s->manufact.len);
@@ -3250,7 +3336,6 @@
 
 /* Make sure that /proc/sys/dev is there */
 ctl_table cdrom_root_table[] = {
-#ifdef CONFIG_PROC_FS
 	{
 		.ctl_name	= CTL_DEV,
 		.procname	= "dev",
@@ -3258,7 +3343,6 @@
 		.mode		= 0555,
 		.child		= cdrom_cdrom_table,
 	},
-#endif /* CONFIG_PROC_FS */
 	{ .ctl_name = 0 }
 };
 static struct ctl_table_header *cdrom_sysctl_header;
diff -Nru a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
--- a/drivers/cdrom/cdu31a.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/cdrom/cdu31a.c	2004-12-24 13:37:02 -08:00
@@ -65,14 +65,6 @@
  * This section describes features beyond the normal audio and CD-ROM
  * functions of the drive.
  *
- * 2048 byte buffer mode
- *
- * If a disk is mounted with -o block=2048, data is copied straight
- * from the drive data port to the buffer.  Otherwise, the readahead
- * buffer must be involved to hold the other 1K of data when a 1K
- * block operation is done.  Note that with 2048 byte blocks you
- * cannot execute files from the CD.
- *
  * XA compatibility
  *
  * The driver should support XA disks for both the CDU31A and CDU33A.
@@ -147,6 +139,13 @@
  *	               Removed init_module & cleanup_module in favor of 
  *		       module_init & module_exit.
  *		       Torben Mathiasen <tmm@image.dk>
+ *
+ * 22 October 2004 -- Make the driver work in 2.6.X
+ *		      Added workaround to fix hard lockups on eject
+ *		      Fixed door locking problem after mounting empty drive
+ *		      Set double-speed drives to double speed by default
+ *		      Removed all readahead things - not needed anymore
+ *			Ondrej Zary <rainbow@rainbow-software.org>
 */
 
 #include <linux/major.h>
@@ -179,10 +178,9 @@
 #define MAJOR_NR CDU31A_CDROM_MAJOR
 #include <linux/blkdev.h>
 
-#define CDU31A_READAHEAD 4	/* 128 sector, 64kB, 32 reads read-ahead */
 #define CDU31A_MAX_CONSECUTIVE_ATTENTIONS 10
 
-#define DEBUG 0
+#define DEBUG 1
 
 /* Define the following if you have data corruption problems. */
 #undef SONY_POLL_EACH_BYTE
@@ -222,7 +220,7 @@
 /* The base I/O address of the Sony Interface.  This is a variable (not a
    #define) so it can be easily changed via some future ioctl() */
 static unsigned int cdu31a_port = 0;
-MODULE_PARM(cdu31a_port, "i");
+module_param(cdu31a_port, uint, 0);
 
 /*
  * The following are I/O addresses of the various registers for the drive.  The
@@ -279,7 +277,6 @@
 						   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_auto_eject = 1;	/* Door has been locked? 1=No/0=Yes */
 
@@ -301,7 +298,7 @@
 
 /* What IRQ is the drive using?  0 if none. */
 static int cdu31a_irq = 0;
-MODULE_PARM(cdu31a_irq, "i");
+module_param(cdu31a_irq, int, 0);
 
 /* The interrupt handler will wake this queue up when it gets an
    interrupts. */
@@ -314,12 +311,8 @@
    it will be cleared. */
 static char disk_changed;
 
-/* Variable for using the readahead buffer.  The readahead buffer
-   is used for raw sector reads and for blocksizes that are smaller
-   than 2048 bytes. */
-static char readahead_buffer[CD_FRAMESIZE_RAW];
-static int readahead_dataleft = 0;
-static int readahead_bad = 0;
+/* This was readahead_buffer once... Now it's used only for audio reads */
+static char audio_buffer[CD_FRAMESIZE_RAW];
 
 /* Used to time a short period to abort an operation after the
    drive has been idle for a while.  This keeps the light on
@@ -440,7 +433,6 @@
 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);
 }
@@ -556,82 +548,47 @@
 	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 ";
+		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;
@@ -696,8 +653,7 @@
  */
 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 */
+	if (lock == 0) {
 		is_auto_eject = 1;
 	} else {
 		is_auto_eject = 0;
@@ -1143,10 +1099,9 @@
    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)
+start_request(unsigned int sector, unsigned int nsect)
 {
 	unsigned char params[6];
-	unsigned int read_size;
 	unsigned long retry_count;
 
 
@@ -1154,22 +1109,7 @@
 	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]);
+	size_to_buf(nsect, &params[3]);
 
 	/*
 	 * Clear any outstanding attentions and wait for the drive to
@@ -1198,10 +1138,8 @@
 		write_params(params, 6);
 		write_cmd(SONY_READ_BLKERR_STAT_CMD);
 
-		sony_blocks_left = read_size * 4;
+		sony_blocks_left = nsect * 4;
 		sony_next_block = sector * 4;
-		readahead_dataleft = 0;
-		readahead_bad = 0;
 #if DEBUG
 		printk("Leaving start_request at %d\n", __LINE__);
 #endif
@@ -1212,8 +1150,7 @@
 #endif
 }
 
-/* Abort a pending read operation.  Clear all the drive status and
-   readahead variables. */
+/* Abort a pending read operation.  Clear all the drive status variables. */
 static void abort_read(void)
 {
 	unsigned char result_reg[2];
@@ -1238,8 +1175,6 @@
 	}
 
 	sony_blocks_left = 0;
-	readahead_dataleft = 0;
-	readahead_bad = 0;
 }
 
 /* Called when the timer times out.  This will abort the
@@ -1264,8 +1199,6 @@
 		write_cmd(SONY_ABORT_CMD);
 
 		sony_blocks_left = 0;
-		readahead_dataleft = 0;
-		readahead_bad = 0;
 		abort_read_started = 1;
 	}
 	restore_flags(flags);
@@ -1274,60 +1207,30 @@
 #endif
 }
 
-/* Actually get data and status from the drive. */
+/* Actually get one sector of data from the drive. */
 static void
-input_data(char *buffer,
-	   unsigned int bytesleft,
-	   unsigned int nblocks, unsigned int offset, unsigned int skip)
+input_data_sector(char *buffer)
 {
-	int i;
-	volatile unsigned char val;
-
-
 #if DEBUG
-	printk("Entering input_data\n");
+	printk("Entering input_data_sector\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();
-		}
-	}
+	   the disk.  The real data is after that. We can use audio_buffer. */
+	if (sony_xa_mode)
+		insb(sony_cd_read_reg, audio_buffer, CD_XA_HEAD);
 
 	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;
+	insb(sony_cd_read_reg, buffer, 2048);
 
 	/* 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();
-		}
-	}
+	   error correction data. We can use audio_buffer for that. */
+	if (sony_xa_mode)
+		insb(sony_cd_read_reg, audio_buffer, CD_XA_TAIL);
+
 #if DEBUG
-	printk("Leaving input_data at %d\n", __LINE__);
+	printk("Leaving input_data_sector\n");
 #endif
 }
 
@@ -1339,10 +1242,6 @@
 		unsigned char res_reg[], int *res_size)
 {
 	unsigned long retry_count;
-	unsigned int bytesleft;
-	unsigned int offset;
-	unsigned int skip;
-
 
 #if DEBUG
 	printk("Entering read_data_block\n");
@@ -1351,67 +1250,6 @@
 	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);
-			bytesleft -= readahead_dataleft;
-			offset += readahead_dataleft;
-			readahead_dataleft = 0;
-		} 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;
@@ -1442,7 +1280,9 @@
 			abort_read();
 		}
 	} else {
-		input_data(buffer, bytesleft, nblocks, offset, skip);
+		input_data_sector(buffer);
+		sony_blocks_left -= nblocks;
+		sony_next_block += nblocks;
 
 		/* Wait for the status from the drive. */
 		retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
@@ -1473,16 +1313,7 @@
 					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;
-					}
+					/* nothing here */
 				} else {
 					printk
 					    ("CDU31A: Data block error: 0x%x\n",
@@ -1490,12 +1321,6 @@
 					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. */
@@ -1531,11 +1356,9 @@
 static void do_cdu31a_request(request_queue_t * q)
 {
 	struct request *req;
-	int block;
-	int nblock;
+	int block, nblock, num_retries;
 	unsigned char res_reg[12];
 	unsigned int res_size;
-	int num_retries;
 	unsigned long flags;
 
 
@@ -1591,7 +1414,10 @@
 
 		block = req->sector;
 		nblock = req->nr_sectors;
-
+#if DEBUG
+		printk("CDU31A: request at block %d, length %d blocks\n",
+			block, nblock);
+#endif
 		if (!sony_toc_read) {
 			printk("CDU31A: TOC not read\n");
 			end_request(req, 0);
@@ -1611,17 +1437,14 @@
 		 * If the block address is invalid or the request goes beyond the end of
 		 * the media, return an error.
 		 */
-		if ((block / 4) >= sony_toc.lead_out_start_lba) {
-			printk("CDU31A: Request past end of media\n");
-			end_request(req, 0);
-			continue;
-		}
 		if (((block + nblock) / 4) >= sony_toc.lead_out_start_lba) {
 			printk("CDU31A: Request past end of media\n");
 			end_request(req, 0);
 			continue;
 		}
 
+		if (nblock > 4)
+			nblock = 4;
 		num_retries = 0;
 
 	try_read_again:
@@ -1636,7 +1459,7 @@
 		/* 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)) {
+			if (start_request(block / 4, nblock / 4)) {
 				end_request(req, 0);
 				continue;
 			}
@@ -1655,7 +1478,7 @@
 				end_request(req, 0);
 				continue;
 			}
-			if (start_request(block / 4, CDU31A_READAHEAD / 4, 0)) {
+			if (start_request(block / 4, nblock / 4)) {
 				printk("CDU31a: start request failed\n");
 				end_request(req, 0);
 				continue;
@@ -1665,7 +1488,12 @@
 		read_data_block(req->buffer, block, nblock, res_reg, &res_size);
 
 		if (res_reg[0] != 0x20) {
-			end_request(req, 1);
+			if (!end_that_request_first(req, 1, nblock)) {
+				spin_lock_irq(q->queue_lock);
+				blkdev_dequeue_request(req);
+				end_that_request_last(req);
+				spin_unlock_irq(q->queue_lock);
+			}
 			continue;
 		}
 
@@ -1774,7 +1602,7 @@
 /* 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
+#if DEBUG
 			printk("cdu31a: Trying session %d\n", session);
 #endif
 			parms[0] = session;
@@ -2529,8 +2357,7 @@
 	   return. */
 
 	retval = 0;
-	/* start_request clears out any readahead data, so it should be safe. */
-	if (start_request(ra->addr.lba, ra->nframes, 1)) {
+	if (start_request(ra->addr.lba, ra->nframes)) {
 		retval = -EIO;
 		goto exit_read_audio;
 	}
@@ -2538,7 +2365,7 @@
 	/* For every requested frame. */
 	cframe = 0;
 	while (cframe < ra->nframes) {
-		read_audio_data(readahead_buffer, res_reg, &res_size);
+		read_audio_data(audio_buffer, res_reg, &res_size);
 		if ((res_reg[0] & 0xf0) == 0x20) {
 			if (res_reg[1] == SONY_BAD_DATA_ERR) {
 				printk
@@ -2567,7 +2394,7 @@
 				/* Restart the request on the current frame. */
 				if (start_request
 				    (ra->addr.lba + cframe,
-				     ra->nframes - cframe, 1)) {
+				     ra->nframes - cframe)) {
 					retval = -EIO;
 					goto exit_read_audio;
 				}
@@ -2575,7 +2402,7 @@
 				/* 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,
+				read_audio_data(audio_buffer, res_reg,
 						&res_size);
 				if ((res_reg[0] & 0xf0) == 0x20) {
 					if (res_reg[1] ==
@@ -2596,7 +2423,7 @@
 				} else if (copy_to_user(ra->buf +
 							       (CD_FRAMESIZE_RAW
 								* cframe),
-						        readahead_buffer,
+						        audio_buffer,
 							CD_FRAMESIZE_RAW)) {
 					retval = -EFAULT;
 					goto exit_read_audio;
@@ -2610,7 +2437,7 @@
 				goto exit_read_audio;
 			}
 		} else if (copy_to_user(ra->buf + (CD_FRAMESIZE_RAW * cframe),
-					(char *)readahead_buffer,
+					(char *)audio_buffer,
 					CD_FRAMESIZE_RAW)) {
 			retval = -EFAULT;
 			goto exit_read_audio;
@@ -3061,12 +2888,18 @@
  * 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 purpose)
 {
 	unsigned char res_reg[12];
 	unsigned int res_size;
 	unsigned char params[2];
 
+	if (purpose == 1) {
+		/* Open for IOCTLs only - no media check */
+		sony_usage++;
+		return 0;
+	}
+
 	if (sony_usage == 0) {
 		if (scd_spinup() != 0)
 			return -EIO;
@@ -3151,8 +2984,7 @@
 	.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_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO |
 				  CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS,
 	.n_minors		= 1,
 };
@@ -3177,7 +3009,19 @@
 static int scd_block_ioctl(struct inode *inode, struct file *file,
 				unsigned cmd, unsigned long arg)
 {
-	return cdrom_ioctl(file, &scd_info, inode, cmd, arg);
+	/* The eject and close commands should be handled by Uniform CD-ROM
+	 * driver - but I always got hard lockup instead of eject
+	 * until I put this here.
+	 */
+	switch (cmd) {
+		case CDROMEJECT:
+			scd_lock_door(&scd_info, 0);
+			return scd_tray_move(&scd_info, 1);
+		case CDROMCLOSETRAY:
+			return scd_tray_move(&scd_info, 0);
+		default:
+			return cdrom_ioctl(file, &scd_info, inode, cmd, arg);
+	}
 }
 
 static int scd_block_media_changed(struct gendisk *disk)
@@ -3372,6 +3216,7 @@
 	tmp_irq = cdu31a_irq;	/* Need IRQ 0 because we can't sleep here. */
 	cdu31a_irq = 0;
 
+	sony_speed = is_double_speed; /* Set 2X drives to 2X by default */
 	set_drive_params(sony_speed);
 
 	cdu31a_irq = tmp_irq;
@@ -3417,13 +3262,12 @@
 		strcat(msg, buf);
 	}
 	strcat(msg, "\n");
-
-	is_a_cdu31a =
-	    strcmp("CD-ROM CDU31A", drive_config.product_id) == 0;
-
+	printk("%s",msg);
+	
 	cdu31a_queue = blk_init_queue(do_cdu31a_request, &cdu31a_lock);
 	if (!cdu31a_queue)
 		goto errout0;
+	blk_queue_hardsect_size(cdu31a_queue, 2048);
 
 	init_timer(&cdu31a_abort_timer);
 	cdu31a_abort_timer.function = handle_abort_timeout;
diff -Nru a/drivers/cdrom/cdu31a.h b/drivers/cdrom/cdu31a.h
--- a/drivers/cdrom/cdu31a.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/cdrom/cdu31a.h	2004-12-24 13:36:18 -08:00
@@ -72,10 +72,10 @@
                                            from drive (in 1/100th's
                                            of seconds). */
  
-#define SONY_JIFFIES_TIMEOUT    1000	/* Maximum number of times the
+#define SONY_JIFFIES_TIMEOUT    (10*HZ)	/* Maximum number of times the
                                            drive will wait/try for an
                                            operation */
-#define SONY_RESET_TIMEOUT      100	/* Maximum number of times the
+#define SONY_RESET_TIMEOUT      HZ	/* Maximum number of times the
                                            drive will wait/try a reset
                                            operation */
 #define SONY_READY_RETRIES      20000   /* How many times to retry a
diff -Nru a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
--- a/drivers/cdrom/sbpcd.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/cdrom/sbpcd.c	2004-12-24 13:36:19 -08:00
@@ -1161,11 +1161,11 @@
 	return;
 }
 /*==========================================================================*/
+static int cmd_out_T(void);
+
 static int get_state_T(void)
 {
 	int i;
-	
-	static int cmd_out_T(void);
 
 	clr_cmdbuf();
 	current_drive->n_bytes=1;
@@ -1308,13 +1308,14 @@
 	return (i);
 }
 /*==========================================================================*/
+static int cc_DriveReset(void);
+
 static int cmd_out_T(void)
 {
 #undef CMDT_TRIES
 #define CMDT_TRIES 1000
 #define TEST_FALSE_FF 1
-	
-	static int cc_DriveReset(void);
+
 	int i, j, l=0, m, ntries;
 	unsigned long flags;
 
diff -Nru a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
--- a/drivers/cdrom/viocd.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/cdrom/viocd.c	2004-12-24 13:37:32 -08:00
@@ -154,7 +154,6 @@
 
 #define DEVICE_NR(di)	((di) - &viocd_diskinfo[0])
 
-static request_queue_t *viocd_queue;
 static spinlock_t viocd_reqlock;
 
 #define MAX_CD_REQ	1
@@ -503,6 +502,18 @@
 	return ret;
 }
 
+static void restart_all_queues(int first_index)
+{
+	int i;
+
+	for (i = first_index + 1; i < viocd_numdev; i++)
+		if (viocd_diskinfo[i].viocd_disk)
+			blk_run_queue(viocd_diskinfo[i].viocd_disk->queue);
+	for (i = 0; i <= first_index; i++)
+		if (viocd_diskinfo[i].viocd_disk)
+			blk_run_queue(viocd_diskinfo[i].viocd_disk->queue);
+}
+
 /* This routine handles incoming CD LP events */
 static void vio_handle_cd_event(struct HvLpEvent *event)
 {
@@ -532,7 +543,7 @@
 	case viocdopen:
 		if (event->xRc == 0) {
 			di = &viocd_diskinfo[bevent->disk];
-			blk_queue_hardsect_size(viocd_queue,
+			blk_queue_hardsect_size(di->viocd_disk->queue,
 					bevent->block_size);
 			set_capacity(di->viocd_disk,
 					bevent->media_size *
@@ -584,7 +595,7 @@
 
 		/* restart handling of incoming requests */
 		spin_unlock_irqrestore(&viocd_reqlock, flags);
-		blk_run_queue(viocd_queue);
+		restart_all_queues(bevent->disk);
 		break;
 
 	default:
@@ -624,6 +635,7 @@
 	struct disk_info *d;
 	struct cdrom_device_info *c;
 	struct cdrom_info *ci;
+	struct request_queue *q;
 
 	deviceno = vdev->unit_address;
 	if (deviceno >= viocd_numdev)
@@ -643,17 +655,22 @@
 	if (register_cdrom(c) != 0) {
 		printk(VIOCD_KERN_WARNING "Cannot register viocd CD-ROM %s!\n",
 				c->name);
-		return 0;
+		goto out;
 	}
 	printk(VIOCD_KERN_INFO "cd %s is iSeries resource %10.10s "
 			"type %4.4s, model %3.3s\n",
 			c->name, ci->rsrcname, ci->type, ci->model);
+	q = blk_init_queue(do_viocd_request, &viocd_reqlock);
+	if (q == NULL) {
+		printk(VIOCD_KERN_WARNING "Cannot allocate queue for %s!\n",
+				c->name);
+		goto out_unregister_cdrom;
+	}
 	gendisk = alloc_disk(1);
 	if (gendisk == NULL) {
 		printk(VIOCD_KERN_WARNING "Cannot create gendisk for %s!\n",
 				c->name);
-		unregister_cdrom(c);
-		return 0;
+		goto out_cleanup_queue;
 	}
 	gendisk->major = VIOCD_MAJOR;
 	gendisk->first_minor = deviceno;
@@ -661,7 +678,10 @@
 			sizeof(gendisk->disk_name));
 	snprintf(gendisk->devfs_name, sizeof(gendisk->devfs_name),
 			VIOCD_DEVICE_DEVFS "%d", deviceno);
-	gendisk->queue = viocd_queue;
+	blk_queue_max_hw_segments(q, 1);
+	blk_queue_max_phys_segments(q, 1);
+	blk_queue_max_sectors(q, 4096 / 512);
+	gendisk->queue = q;
 	gendisk->fops = &viocd_fops;
 	gendisk->flags = GENHD_FL_CD|GENHD_FL_REMOVABLE;
 	set_capacity(gendisk, 0);
@@ -670,8 +690,14 @@
 	d->dev = &vdev->dev;
 	gendisk->driverfs_dev = d->dev;
 	add_disk(gendisk);
-
 	return 0;
+
+out_cleanup_queue:
+	blk_cleanup_queue(q);
+out_unregister_cdrom:
+	unregister_cdrom(c);
+out:
+	return -ENODEV;
 }
 
 static int viocd_remove(struct vio_dev *vdev)
@@ -683,6 +709,7 @@
 				"Cannot unregister viocd CD-ROM %s!\n",
 				d->viocd_info.name);
 	del_gendisk(d->viocd_disk);
+	blk_cleanup_queue(d->viocd_disk->queue);
 	put_disk(d->viocd_disk);
 	return 0;
 }
@@ -742,18 +769,10 @@
 		goto out_undo_vio;
 
 	spin_lock_init(&viocd_reqlock);
-	viocd_queue = blk_init_queue(do_viocd_request, &viocd_reqlock);
-	if (viocd_queue == NULL) {
-		ret = -ENOMEM;
-		goto out_free_info;
-	}
-	blk_queue_max_hw_segments(viocd_queue, 1);
-	blk_queue_max_phys_segments(viocd_queue, 1);
-	blk_queue_max_sectors(viocd_queue, 4096 / 512);
 
 	ret = vio_register_driver(&viocd_driver);
 	if (ret)
-		goto out_cleanup_queue;
+		goto out_free_info;
 
 	e = create_proc_entry("iSeries/viocd", S_IFREG|S_IRUGO, NULL);
 	if (e) {
@@ -763,8 +782,6 @@
 
 	return 0;
 
-out_cleanup_queue:
-	blk_cleanup_queue(viocd_queue);
 out_free_info:
 	dma_free_coherent(iSeries_vio_dev,
 			sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
@@ -781,7 +798,6 @@
 {
 	remove_proc_entry("iSeries/viocd", NULL);
 	vio_unregister_driver(&viocd_driver);
-	blk_cleanup_queue(viocd_queue);
 	if (viocd_unitinfo != NULL)
 		dma_free_coherent(iSeries_vio_dev,
 				sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
diff -Nru a/drivers/char/Kconfig b/drivers/char/Kconfig
--- a/drivers/char/Kconfig	2004-12-24 13:36:17 -08:00
+++ b/drivers/char/Kconfig	2004-12-24 13:36:17 -08:00
@@ -192,7 +192,7 @@
 
 config MOXA_SMARTIO
 	tristate "Moxa SmartIO support"
-	depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
+	depends on SERIAL_NONSTANDARD
 	help
 	  Say Y here if you have a Moxa SmartIO multiport serial card.
 
@@ -478,6 +478,7 @@
 config LEGACY_PTY_COUNT
 	int "Maximum number of legacy PTY in use"
 	depends on LEGACY_PTYS
+	range 1 256
 	default "256"
 	---help---
 	  The maximum number of legacy PTYs that can be used at any one time.
@@ -780,6 +781,23 @@
 	bool "EFI Real Time Clock Services"
 	depends on IA64
 
+config DS1302
+	tristate "DS1302 RTC support"
+	depends on M32R && (PLAT_M32700UT || PLAT_OPSPUT)
+	help
+	  If you say Y here and create a character special file /dev/rtc with
+	  major number 121 and minor number 0 using mknod ("man mknod"), you
+	  will get access to the real time clock (or hardware clock) built
+	  into your computer.
+
+config S3C2410_RTC
+	bool "S3C2410 RTC Driver"
+	depends on ARCH_S3C2410
+	help
+	  RTC (Realtime Clock) driver for the clock inbuilt into the
+	  Samsung S3C2410. This can provide periodic interrupt rates
+	  from 1Hz to 64Hz for user programs, and wakeup from Alarm.
+
 config COBALT_LCD
 	bool "Support for Cobalt LCD"
 	depends on MIPS_COBALT
@@ -826,7 +844,7 @@
 
 config SONYPI
 	tristate "Sony Vaio Programmable I/O Control Device support (EXPERIMENTAL)"
-	depends on EXPERIMENTAL && X86 && PCI && !64BIT
+	depends on EXPERIMENTAL && X86 && PCI && INPUT && !64BIT
 	---help---
 	  This driver enables access to the Sony Programmable I/O Control
 	  Device which can be found in many (all ?) Sony Vaio laptops.
diff -Nru a/drivers/char/Makefile b/drivers/char/Makefile
--- a/drivers/char/Makefile	2004-12-24 13:37:29 -08:00
+++ b/drivers/char/Makefile	2004-12-24 13:37:29 -08:00
@@ -63,6 +63,8 @@
 obj-$(CONFIG_EFI_RTC) += efirtc.o
 obj-$(CONFIG_SGI_DS1286) += ds1286.o
 obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o
+obj-$(CONFIG_DS1302) += ds1302.o
+obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o
 ifeq ($(CONFIG_GENERIC_NVRAM),y)
   obj-$(CONFIG_NVRAM) += generic_nvram.o
 else
diff -Nru a/drivers/char/README.computone b/drivers/char/README.computone
--- a/drivers/char/README.computone	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,10 +0,0 @@
-Computone Intelliport II/Plus Multiport Serial Driver
------------------------------------------------------
-
-Release Notes For Linux Kernel 2.2 and higher
-
-This file is now deprecated and will be removed at some point.
-
-Please refer to the file Documentation/computone.txt instead.
-
-Michael H. Warfield 08/12/2001
diff -Nru a/drivers/char/README.cyclomY b/drivers/char/README.cyclomY
--- a/drivers/char/README.cyclomY	2004-12-24 13:36:34 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,23 +0,0 @@
-
-NOTE: Earlier versions of the driver mapped ttyC0 to minor
-number 32, but this is changed in this distribution.  Port ttyC0
-now maps to minor number 0.)  The following patch should be
-applied to /dev/MAKEDEV and the script should then be re-run
-to create new entries for the ports.
---------------------------- CUT HERE ----------------------------
---- /dev/MAKEDEV	Sun Aug 20 10:51:55 1995
-+++ MAKEDEV.new	Fri Apr 19 06:48:12 1996
-@@ -206,8 +206,8 @@
- 		major2=`Major cub` || continue
- 		for i in 0 1 2 3 4 5 6 7 # 8 9 10 11 12 13 14 15
- 		do
--			makedev ttyC$i c $major1 `expr 32 + $i` $tty
--			makedev cub$i c $major2 `expr 32 + $i` $dialout
-+			makedev ttyC$i c $major1 $i $tty
-+			makedev cub$i c $major2 $i $dialout
- 		done
- 		;;
- 	par[0-2])
---------------------------- CUT HERE ----------------------------
-
-
diff -Nru a/drivers/char/README.epca b/drivers/char/README.epca
--- a/drivers/char/README.epca	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,532 +0,0 @@
-user.doc
-Digi International driver package for the PC/Xe, PC/Xi, PC/Xr, PC/Xem as well
-the EISA and PCI variants of these boards where applicable.
-Copyright (C) 1996 Digi International.  Written by Ronnie Sanford digilnux@dgii.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 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. 
-
-
-This document describes the software used with the Digi/Linux driver package.
-The four user programs listed below are described in this document:
-
-  1.  digiConfig   -> Application that configures the Digi driver.
-
-  2.  digiDload    -> Application which initializes the Digi hardware.
-
-  3.  buildPCI     -> Application which provides the user a method of
-                      building device nodes for PCI devices. 
-
-  4.  ditty        -> Application which provides the user a method of
-                      configuring terminal options on Digi hardware.
-
-
-
---------------------------------------------------------------------------
-1.  Configuring driver/kernel for Digi products
---------------------------------------------------------------------------
-
-   The Digi driver must be configured each time Digi hardware is added
-   or removed.  There are two supported methods of doing this.  The
-   first method configures the driver dynamically at boot time but requires
-   the user to utilize the lilo loader.  This method is the preffered method
-   as it does not require the rebuilding of the kernel.  In order to use lilo
-   to configure Digi boards at boot time an appropriate append command should
-   be added to /etc/lilo.conf below the appropriate label decleration.  
-   See footer 4.  The append commands format is a string of comma separated
-   identifiers or integers used to configure supported boards.  These six
-   values in order are:
-
-     Enable/Disable this card or Override,
-     Type of card: PC/Xe (AccelePort) (0), PC/Xeve (1), PC/Xem or PC/Xr (2),
-                   EISA/Xem (3), PC/Xe (64K) (4), PC/Xi (5).
-     Enable/Disable alternate pin arrangement,
-     Number of ports on this card,
-     I/O Port where card is configured (in HEX if using string identifiers),
-     Base of memory window (in HEX if using string identifiers) 
-
-   A sample append command is given below which if used would configure and 
-   enable a PC/Xe with 8 ports, at i/o address 200, memory address 0xd0000 
-   with alt pin turned off.  The lilo.conf file should look like this:
-
-     image = /vmlinuz
-       root = /dev/hda2
-       label = vmlinuz
-       append="digiepca=E,PC/Xe,D,8,200,D0000"
-
-   likewise the below will perform the same function:
-
-     image = /vmlinuz
-       root = /dev/hda2
-       label = vmlinuz
-       append="digiepca=1,0,0,8,512,851968"
-
-   Note:
-
-     PCI boards are auto-detected and configured (Hence their codes are
-     not given here).  Do not attempt to configure PCI boards with the lilo 
-     append command.
-
-     If configuration data has been specified by using digiConfig (Described
-     below), and you wish to override this configuration using lilo without
-     specifying a specific card (Example if there are PCI cards in the system)
-     the following override command will accomplish this:
-
-     -> append="digiepca=2"
-   
-   If lilo is not enabled, the second method of configuring Digi hardware 
-   will have to be used.  digiConfig is an application that can be used 
-   to inform the system of any additions, deletions, or modifications
-   involving Digi hardware.  To use this method the operator executes  
-   digiConfig anytime an EISA or ISA card is added that he wishes to use. 
-   This routine is also used to remove cards from the system, and to modify 
-   parameters of those cards already present in the system.  Upon being 
-   executed digiConfig modifies files accessed by the Digi driver.  To make 
-   these changes permanent; the operating system must be recompiled.  After 
-   the operating system has been recompiled and booted, the changes made with
-   digiConfig will be introduced to the user.  This program MUST be executed
-   every time Digi EISA/ISA hardware configuration changes.  Note, it is not
-   necessary to execute digiConfig in order to configure the Digi PCI cards.
-   These cards are self-identifying and will be recognized by the driver.  
-   They cannot be displayed using digiConfig nor will digiConfig build the 
-   device nodes their device nodes. See footer 1.
-
-   To execute digiConfig; simply type: digiConfig
-
-   The application will query you for the type, memory address, port 
-   address, number of ports, alt pin disposition and status of each board
-   that exist on the system.  Note, currently this driver only supports 
-   PC/Xe, PC/Xeve, PC/Xi, PC/Xr, and PC/Xem as well as their EISA and PCI 
-   implementations if applicable.  All supported cards (Other than PCI) that
-   are present should be registered via digiConfig.  See footer 2.
-
-   After all cards have been configured select exit.  The system will then
-   inform you if any changes have been made, and ask you if it is okay to
-   make these changes permanent.  If the data entered is correct, select okay.
-   Selecting cancel will prevent the changes from becoming active.  digiConfig
-   can then be re-executed to configure the system again.
-
---------------------------------------------------------------------------
-2.  Initializing Digi hardware with digiDload
---------------------------------------------------------------------------
-
-   digiDload is the application executed after the Digi driver has been
-   loaded.  It is responsible for initializing the hardware and leaving
-   it in a state such that the Digi board may be operated by the user.
-   The application may be placed anywhere on the path, but its related
-   support files must be located in /etc/digi.  The related files are:
-
-         sxfep.bin
-         sxbios.bin
-         xxfep.bin
-         xxbios.bin
-
-   The format for this command is "digiDload [v]".  If given the "v"
-   option turns on verbosity.  If not given the application runs in quite
-   mode.  To execute the program simply type:
-
-        digiDload 
-
-   Upon completion digiDload will generate the below message:
-
-        "digiDload complete: Card initialized"
-
-   At this point the card is configured and ready for normal usage.  See
-   technotes.doc for information on how how ports are determined and 
-   assigned.
-
---------------------------------------------------------------------------
-3.  Build PCI device nodes with buildPCI 
---------------------------------------------------------------------------
-
-   buildPCI is an application useful for building the necessary device nodes
-   for Digi PCI cards.  It is reccomended that this tool be used because the
-   current digiConfig application does not provide this function for PCI cards
-   (Though it does build device nodes for non-PCI cards).  To use this program
-   execute the following:first install the driver, and execute digiDload (See above).  After digiDload
-   has successfully loaded, execute the following:
-
-        buildPCI <arg1> <arg2>
-
-   Where arg1 is the number of ports connected to Digi cards that are not PCI 
-   (As shown by the digiConfig utility), and arg2 is the number of ports 
-   connected to Digi cards that are PCI.
-
-   Note, buildPCI only has to be ran once to build the necessary device 
-   nodes.  Though this program may be executed at anytime, we reccomend 
-   delaying execution until the first time you install the package and after 
-   digiDload has been executed.
-
---------------------------------------------------------------------------
-4.  Setting Terminal Options with ditty
---------------------------------------------------------------------------
-
-ditty is a utility program that sets and displays the terminal options 
-for Digi intelligent serial products.  See man ditty for detailed information.
-
-
-Footnotes:
-
-1.  The 1.2.x kernel does not provide a method of mapping the high 
-    addresses (Normally higher than RAM) associated with PCI.  For this
-    reason, this driver disables PCI support while running under the 1.2.x
-    kernels.
-
-2.  PCI cards should not and cannot be registered with digiConfig.  After
-    the driver has been loaded buildPCI may be executed to construct the 
-    necessary device nodes.  This step is not necessary for system not 
-    having Digi PCI cards.
-
-3.  This is because we forsee a time when buildPCI may auto-detect the
-    available Digi PCI cards and this would only work if the program is 
-    executed after digiDload.
-
-4.  A complete example is given in install.doc.
-
--------------CHANGES--------------------
-
-All changes should be recorded here.  All changes should be explained in 
-verbose detail.  
------------------------------------------------------------------------
-Programmer            : Ronnie Sanford
-Date                  : June 1, 1996
-Description (Verbose) : Initial release of driver package.
-Files affected        : all
-Release version       : 1.0.0f  (BETA)
------------------------------------------------------------------------
------------------------------------------------------------------------
-Programmer            : Ronnie Sanford
-Date                  : August 7, 1996
-Description (Verbose) : Made several modifications to provide PCI and EISA
-                        support:
-
-                        1.  We now allocate the termios structures based on
-                            the maximum number of channels that COULD be 
-                            available to the system.  We no longer use the
-                            number of channels declared in epcaconfig.h 
-                            (NBDEVS) as the total channel number.  This is 
-                            because this value does not represent channels
-                            available to potential PCI cards.  This new 
-                            larger value is also passed back to the os in
-                            the num field of tty_driver. 
-
-                        2.  Added code to copy the previous board structure
-                            (Now called static_boards) into a new local 
-                            copy of the boards structure.  This has been 
-                            done so that PCI cards may be added to this 
-                            board array and later referenced (And even 
-                            queried.). 
-
-                        3.  Added code to pc_init that checks for supported
-                            PCI cards.  If found this code initializes a new
-                            entry into the drivers local board structure 
-                            with the PCI cards address, and type, etc..  It 
-                            also bumps the card count (num_cards).
-
-                        4.  Modified code in post_fep_init so that when this
-                            routine is executed the number of ports supported
-                            by a particular PCI card will be determined and
-                            loaded into the board structure.  It would be 
-                            much better if this code was placed in pc_init
-                            (Because we could then report to the os the true
-                            number of ports available; not just the max), but
-                            since the card has to be booted to determine the
-                            number of ports it supports, we are forced to do it
-                            after DIGI_INIT has called post_fep_init.  In the 
-                            future we may attempt to read the num ports 
-                            attached directly (address 0x1ac).
-
-                        5.  Added board types to epca.h in support of various
-                            PCI boards (Some of which do not exist yet).  
-                            Added procedures for these boards throughout the
-                            code.  Note, windowing is not necessary for PCI
-                            boards.  
-
-                        6.  Added code supporting the EISA/XEM.  This included
-                            modifying epca.h with the new board type and 
-                            adding this type into the driver.  The EISA/XEM
-                            is basically identical to the PC/XEM, other than
-                            it's base address does not have to be (And cannot
-                            be configured directly).
-
-                        7.  Modified digiConfig to prompt for EISA/XEM cards.
-                             
-Files affected        : epca.c, epca.h, digi1.h, digiConfig
-Release version       : 1.0.0g  (BETA)
------------------------------------------------------------------------
------------------------------------------------------------------------
-Programmer            : Ronnie Sanford
-Date                  : August 21, 1996
-Description (Verbose) : Made the following modifications:
-
-                        1.  A problem affecting hard flow control was found 
-                            in the termios2digi_h routine.  Specifically,
-                            when the user activated hard flow control using
-                            the CRTSCTS specification, the values used to 
-                            program hard flow control on the board were 
-                            incorrect.  The solution was to change a line
-                            that read "res |= ((ch->m_dtr) | (ch->m_rts));"
-                            to "res |= ((ch->m_cts) | (ch->m_rts));"  This 
-                            line only applies if cflag & CRTSCTS.  Special
-                            thanks to Matt Robinson (matt@mania.com.au) who
-                            found and fixed this problem.
-
-                        2.  In previous betas the cud device was set to  CLOCAL
-                            on driver boot up.  Likewise the ttyD device was
-                            set to ~CLOCAL.  This has been fixed in this driver.
-                            Now ttyD is CLOCAL and cud is ~CLOCAL.  The fix
-                            for this can be found in pc_init.
-
-                        3.  In ditty.c many changes were made to eliminate bugs
-                            and warning messages.  Two ioctl calls were eliminated
-                            as well a problem involving using the returned baud
-                            index to determine the drivers baud rate.  Newer 
-                            Linux kernels support higher baud rates by using
-                            0x1000 bit.  When the returned value (ored with
-                            0x1000) was used to reference our fbaud table a 
-                            serious memory problem occurred.  This has been fixed.
-
-                        4.  Added a request_region call to post_fep_init.  This
-                            should cause the i/o ports being used to be 
-                            registered with proc.
- 
-                        5.  Modified digiConfig to set all cud and ttyD devices
-                            to read/write all permission.
-
-                        6.  Developed a new apps called buildPCI that provides 
-                            an easy way to build device nodes for PCI cards.
-         
-                        7.  Modified user.doc and technotes.doc document the
-                            use of buildPCI.
-
-Files affected        : epca.c, ditty.c, digiConfig, user.doc, technotes.doc 
-Release version       : 1.0.0 (Official release)
------------------------------------------------------------------------
-Programmer            : Ronnie Sanford
-Date                  : August 21, 1996
-Description (Verbose) : Made the following modifications:
-
-                        1.  Removed code from pc_close which closes the 
-                            drivers line discipline and restores its original
-                            line discipline.  This is currently unnecessary,
-                            though future fast cook enhancements may require
-                            this.
-
-                        2.  Removed code in block_til_ready that set the 
-                            asyncflags to either ASYNC_CALLOUT_ACTIVE, or
-                            ASYNC_NORMAL_ACTIVE.  This code was redundant
-                            as it already existed in block_til_ready.
-
-                        3.  Added code in block_til_ready to cause a return
-                            prior to schedule being called if the device 
-                            was a CALLOUT device.  CALLOUT devices never
-                            block on CD. (This was a serious bug that 
-                            prevented the CALLOUT devices (ttyD) from 
-                            functioning properly in some instances.
-
-                            Make a change in the MODEMCHG_IND case of doevent
-                            such that it does not require ASYNC_CALLOUT_ACTIVE
-                            or ASYNC_NORMAL_ACTIVE to be set in order to 
-                            unblock an open (Using wait_interruptible).
-
-                            Thanks to Mike McLagan (mike.mclagan@linux.org)
-                            for diagnosing and fixing this problem. 
-
-                        4.  Made changes to the disposition of CLOCAL on 
-                            both SERIAL NORMAL and CALLOUT devices.  Both
-                            device types now have CLOCAL active at default.
-                            This may be changed with a stty command.
-
-                        5.  Made changes to digiConfig such that it checks
-                            major.h (If valid) for the correct major
-                            numbers to use.
-
-Files affected        : epca.c, digiConfig 
-Release version       : 1.0.1a 
-
-
------------------------------------------------------------------------
-Programmer            : Ronnie Sanford
-Date                  : September 17, 1996
-Description (Verbose) : Made the following modifications:
-	
-                        1. Modified pc_open such that it no longer checks 
-                           the cflag value returned by termios2digi_c for
-                           CLOCAL.  Digi hardware does not use this value
-                           and thus termios2digi_c rightly screens this 
-                           value out.  This driver checks for CLOCAL using
-                           the drivers cflag value as known by the Linux OS.
-                           (The value passed into termios2digi_c)
-
-                        2. Modified termios2digi_c to screen out the 
-                           CBAUDEX in CBAUD.  This error caused parity to
-                           automaticaly be enabled on at higher baud rates.
-		
-
-                        3. Added the "disable_bh()" call to the shutdown
-                           subroutine.  Hopefully this will allow the driver
-                           to correctly clean up after itself when used as a
-                           module. 
-
-                        4. Added support for the PC/XI and 64K PC/XE cards.
-                           This involved primarily modifying digiDload to
-                           initialize and boot the new cards; however 
-                           driver modifications were also required to 
-                           provide the proper windowing for the newly 
-                           supported cards. (Code was also added to 
-                           determine the memory segment of the XI card as
-                           that card may have more than 64K.  Currently
-                           digiDload assumes a 64K XI card.)
-
-                        5. Added subroutine called epca_setup that can be 
-                           called during LILO boot up.  This provides the 
-                           user an easy way to change cards; without 
-                           running digiConfig and without recompiling the
-                           kernel.  Added code in pc_init and pc_open to
-                           support the epca_setup routine.  pc_init checks
-                           the liloconfig flag (Which is set by epca_setup)
-                           to determine if the driver is using the LILO 
-                           arguments.  If not pc_init loads the board data 
-                           found in epcaconfig.h; if so it DOESN'T load
-                           epcaconfig data depending on epca_setup to handle 
-                           board configuration.  pc_open has been modified 
-                           such that it checks to ensure that no errors
-                           occurred during the LILO boot process.  If a 
-                           user attempts to boot the driver (via. LILO)
-                           with incorrect data, the open will fail. 
-
-                        6. Modified the windowing routines pcxe_rxwinon
-                           and pcxe_txwinon routines.  A bug existed such
-                           that those routines checked to see if the rxwin 
-                           and txwin flags were reset.  If so they assumed 
-                           the board was an XI or 64K XE.  Furthermore since
-                           these flags were never initialized in our driver
-                           sometimes they were 0 and therefore caused a 
-                           memory fault (Or at least a window overrun).  This
-                           code has been removed since the pcxe shares 
-                           nothing in common with the 64K XI and XE. 
-
-                        7. Added code in pc_init to set the memory_seg for
-                           the various boards.  This code was necessary to
-                           correct a bug in the PCXE, PCXEVE code where 
-                           receive and transmit pointers were being calculated
-                           from an uninitialized variable (memory_seg). 
-
-                        8. Modified digiConfig to allow 64K PC/XI and 64K
-                           PC/XE cards to be configured.
-                           
-                        9. Made changes to support the new 2.1.x development 
-                           kernel.  In particular this required changing all
-                           references to vremap to ioremap. 
-
-                       10. Modified digiConfig such that it now generates 
-                           node names corresponding to their internal 
-                           as opposed to the label on the port itself.  Nodes
-                           (ttyD?? and cud??) now start at 0.  Example:
-                           ttyD0 and cud0 represent port 1 on any supported
-                           Digi product.  A similar change has been made
-                           in buildPCI.c. 
-
-                       12. At the early portion of post_fep_init if a PCI
-                           card is detected a warning message could be given
-                           incorrectly if 64 ports were attached to a PCI 
-                           card.  The below line :
-
-                           epcaassert(bd->numports > 64,"PCI returned a invalid number of ports"); 
-    
-                           was changed to :
-
-                           epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); 
-
-                           Remember that epcaassert checks for NOT true.
-                           Special thanks to Daniel Taylor for fixing this.
-
-                       13. Modified the epcaparam routine.  In version 100
-                           and 101a there was a line that looked like the 
-                           below:
-
-                             if (ch->omodem != mval)
-                           
-                           The problem with this line was that the first time
-                           through omodem was not initialized.  Secondly, since
-                           many TIOC commands did not alter mval (They use
-                           a different variable) changes made by these commands
-                           could be lost.  This line was changed to:
-
-                             mval ^= ch->modemfake & (mval ^ ch->modem);
-
-                             if (ch->omodem ^ mval)
-
-                       14. Modified digiConfig in such a way that it checks 
-                           the version number of the kernel and if it finds
-                           a 2.x.x kernel or higher it reads the necessary 
-                           major numbers for cud and ttyD devices from major.h.
-                           This was also done in prior versions but these
-                           versions required a #define which identified the 
-                           kernel as a version which did not have major numbers
-                           assigned to Digi systems.  This #define is no 
-                           longer required allowing the same source tree for
-                           multiple kernel releases.
-
-                       15. Used macros to replace kernel specific calls such
-                           as put_fs_long, get_fs_long, put_user, and get_user
-                           the kernel version is now detected and the macro
-                           is defined as to correspond with the kernel it
-                           is being compiled into.  Again this was done to
-                           allow one source tree for multiple kernel releases. 
-
-                       16. Added support for the new 2.1.x development kernels
-                           to digiInstall.
-
-Files affected        : epca.c, digiConfig 
-Release version       : 1.1.0
------------------------------------------------------------------------
-Programmer            : Daniel Taylor
-Date                  : April 25, 1997
-Description (Verbose) : Updated driver:
-                        1.  Fixed DCD bug. (&tq scheduler)
-                        2.  Removed BH handler code, as it was only handling
-                            hangups, and not being called for that.
-                        3.  Namespace cleanup (DIGI_TIMER2 => DIGI_TIMER)
-                        4.  Updated to 2.1.36, removed #ifdefs for earlier
-                            kernel revisions.
-Files affected        : epca.c
-Release version       : 1.1.1  (BETA)
------------------------------------------------------------------------
-Programmer            : Daniel Taylor
-Date                  : March 11, 1999
-Description (Verbose) : Updated driver:
-                        1.  Simultaneous data and modem change events were
-			    resulting in the modem change events not being
-			    recognized. Fixed.
-                        2.  Modified pc_info device name to work better
-			    with devfs.
-Files affected        : epca.c
-Release version       : 1.3.0-K 
------------------------------------------------------------------------
-Programmer            : Jeff Garzik
-Date                  : February 26, 2000
-Description (Verbose) : Updated driver:
-			1.  Use new kernel PCI interfaces.
-			2.  Updated list of includes.
-Files affected        : epca.c
-Release version       : 1.3.0.1-LK
------------------------------------------------------------------------
-Programmer            : Arjan van de Ven <adve@oce.nl>
-Date                  : March 10, 2000
-Description (Verbose) : Fixed includes to make it actually compile
-			for kernel 2.3.51
-Files affected        : epca.c
-Release version       : 1.3.0.2-LK
------------------------------------------------------------------------
diff -Nru a/drivers/char/README.scc b/drivers/char/README.scc
--- a/drivers/char/README.scc	2004-12-24 13:36:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,5 +0,0 @@
-The z8530drv is now a network device driver, you can find it in
-	../net/scc.c
-
-A subset of the documentation is in
-	Documentation/networking/z8530drv.txt
diff -Nru a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
--- a/drivers/char/agp/frontend.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/char/agp/frontend.c	2004-12-24 13:36:18 -08:00
@@ -627,8 +627,8 @@
 		DBG("client vm_ops=%p", kerninfo.vm_ops);
 		if (kerninfo.vm_ops) {
 			vma->vm_ops = kerninfo.vm_ops;
-		} else if (remap_page_range(vma, vma->vm_start, 
-					    (kerninfo.aper_base + offset),
+		} else if (remap_pfn_range(vma, vma->vm_start,
+				(kerninfo.aper_base + offset) >> PAGE_SHIFT,
 					    size, vma->vm_page_prot)) {
 			goto out_again;
 		}
@@ -643,8 +643,8 @@
 		DBG("controller vm_ops=%p", kerninfo.vm_ops);
 		if (kerninfo.vm_ops) {
 			vma->vm_ops = kerninfo.vm_ops;
-		} else if (remap_page_range(vma, vma->vm_start, 
-					    kerninfo.aper_base,
+		} else if (remap_pfn_range(vma, vma->vm_start,
+					    kerninfo.aper_base >> PAGE_SHIFT,
 					    size, vma->vm_page_prot)) {
 			goto out_again;
 		}
diff -Nru a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
--- a/drivers/char/agp/intel-agp.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/char/agp/intel-agp.c	2004-12-24 13:36:49 -08:00
@@ -1723,7 +1723,7 @@
 {
 	struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
 
-	pci_restore_state(pdev, pdev->saved_config_space);
+	pci_restore_state(pdev);
 
 	if (bridge->driver == &intel_generic_driver)
 		intel_configure();
@@ -1782,16 +1782,8 @@
 	.resume		= agp_intel_resume,
 };
 
-/* intel_agp_init() must not be declared static for explicit
-   early initialization to work (ie i810fb) */
-int __init agp_intel_init(void)
+static int __init agp_intel_init(void)
 {
-	static int agp_initialised=0;
-
-	if (agp_initialised == 1)
-		return 0;
-	agp_initialised=1;
-
 	return pci_module_init(&agp_intel_pci_driver);
 }
 
diff -Nru a/drivers/char/agp/intel-mch-agp.c b/drivers/char/agp/intel-mch-agp.c
--- a/drivers/char/agp/intel-mch-agp.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/char/agp/intel-mch-agp.c	2004-12-24 13:36:18 -08:00
@@ -573,7 +573,7 @@
 {
 	struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
 	
-	pci_restore_state(pdev, pdev->saved_config_space);
+	pci_restore_state(pdev);
 
 	if (bridge->driver == &intel_845_driver)
 		intel_845_configure();
diff -Nru a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
--- a/drivers/char/agp/sis-agp.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/char/agp/sis-agp.c	2004-12-24 13:36:17 -08:00
@@ -6,6 +6,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/agp_backend.h>
+#include <linux/delay.h>
 #include "agp.h"
 
 #define SIS_ATTBASE	0x90
@@ -85,7 +86,7 @@
 	command |= AGPSTAT_AGP_ENABLE;
 	rate = (command & 0x7) << 2;
 
-	while ((device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, device)) != NULL) {
+	for_each_pci_dev(device) {
 		u8 agp = pci_find_capability(device, PCI_CAP_ID_AGP);
 		if (!agp)
 			continue;
@@ -102,8 +103,7 @@
 		 */
 		if (device->device == agp_bridge->dev->device) {
 			printk(KERN_INFO PFX "SiS delay workaround: giving bridge time to recover.\n");
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout (1+(HZ*10)/1000);
+			msleep(10);
 		}
 	}
 }
diff -Nru a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
--- a/drivers/char/agp/via-agp.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/char/agp/via-agp.c	2004-12-24 13:37:18 -08:00
@@ -442,7 +442,7 @@
 
 static int agp_via_suspend(struct pci_dev *pdev, u32 state)
 {
-	pci_save_state (pdev, pdev->saved_config_space);
+	pci_save_state (pdev);
 	pci_set_power_state (pdev, 3);
 
 	return 0;
@@ -453,7 +453,7 @@
 	struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
 
 	pci_set_power_state (pdev, 0);
-	pci_restore_state(pdev, pdev->saved_config_space);
+	pci_restore_state(pdev);
 
 	if (bridge->driver == &via_agp3_driver)
 		return via_configure_agp3();
diff -Nru a/drivers/char/amiserial.c b/drivers/char/amiserial.c
--- a/drivers/char/amiserial.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/char/amiserial.c	2004-12-24 13:37:32 -08:00
@@ -32,6 +32,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/delay.h>
 
 #undef SERIAL_PARANOIA_CHECK
 #define SERIAL_DO_RESTART
@@ -83,14 +84,13 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/init.h>
-#include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/setup.h>
 
 #include <asm/system.h>
 
 #include <asm/irq.h>
-#include <asm/bitops.h>
 
 #include <asm/amigahw.h>
 #include <asm/amigaints.h>
@@ -645,7 +645,7 @@
 	/*
 	 * and set the speed of the serial port
 	 */
-	change_speed(info, 0);
+	change_speed(info, NULL);
 
 	info->flags |= ASYNC_INITIALIZED;
 	local_irq_restore(flags);
@@ -691,7 +691,7 @@
 
 	if (info->xmit.buf) {
 		free_page((unsigned long) info->xmit.buf);
-		info->xmit.buf = 0;
+		info->xmit.buf = NULL;
 	}
 
 	info->IER = 0;
@@ -907,8 +907,7 @@
 	local_irq_restore(flags);
 }
 
-static int rs_write(struct tty_struct * tty, int from_user,
-		    const unsigned char *buf, int count)
+static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count)
 {
 	int	c, ret = 0;
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
@@ -921,57 +920,25 @@
 		return 0;
 
 	local_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;
-
-			c -= copy_from_user(tmp_buf, buf, c);
-			if (!c) {
-				if (!ret)
-					ret = -EFAULT;
-				break;
-			}
-			local_irq_disable();
-			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));
-			local_irq_restore(flags);
-			buf += c;
-			count -= c;
-			ret += c;
-		}
-		up(&tmp_buf_sem);
-	} else {
-		local_irq_disable();
-		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;
+	local_irq_disable();
+	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;
 		}
-		local_irq_restore(flags);
+		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;
 	}
+	local_irq_restore(flags);
+
 	if (info->xmit.head != info->xmit.tail
 	    && !tty->stopped
 	    && !tty->hw_stopped
@@ -1205,7 +1172,7 @@
 				info->tty->alt_speed = 230400;
 			if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
 				info->tty->alt_speed = 460800;
-			change_speed(info, 0);
+			change_speed(info, NULL);
 		}
 	} else
 		retval = startup(info);
@@ -1560,11 +1527,10 @@
 	tty_ldisc_flush(tty);
 	tty->closing = 0;
 	info->event = 0;
-	info->tty = 0;
+	info->tty = NULL;
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -1622,8 +1588,7 @@
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
 		printk("serdatr = %d (jiff=%lu)...", lsr, jiffies);
 #endif
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(char_time);
+		msleep_interruptible(jiffies_to_msecs(char_time));
 		if (signal_pending(current))
 			break;
 		if (timeout && time_after(jiffies, orig_jiffies + timeout))
@@ -1653,7 +1618,7 @@
 	info->event = 0;
 	state->count = 0;
 	info->flags &= ~ASYNC_NORMAL_ACTIVE;
-	info->tty = 0;
+	info->tty = NULL;
 	wake_up_interruptible(&info->open_wait);
 }
 
@@ -1909,7 +1874,7 @@
 		info->magic = SERIAL_MAGIC;
 		info->flags = state->flags;
 		info->quot = 0;
-		info->tty = 0;
+		info->tty = NULL;
 	}
 	local_irq_save(flags);
 	status = ciab.pra;
diff -Nru a/drivers/char/applicom.c b/drivers/char/applicom.c
--- a/drivers/char/applicom.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/char/applicom.c	2004-12-24 13:37:19 -08:00
@@ -200,7 +200,7 @@
 
 	/* No mem and irq given - check for a PCI card */
 
-	while ( (dev = pci_find_class(PCI_CLASS_OTHERS << 16, dev))) {
+	while ( (dev = pci_get_class(PCI_CLASS_OTHERS << 16, dev))) {
 
 		if (dev->vendor != PCI_VENDOR_ID_APPLICOM)
 			continue;
diff -Nru a/drivers/char/cyclades.c b/drivers/char/cyclades.c
--- a/drivers/char/cyclades.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/char/cyclades.c	2004-12-24 13:36:31 -08:00
@@ -652,12 +652,12 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 
 #define	CY_LOCK(info,flags)					\
 		do {						\
@@ -729,8 +729,8 @@
 static long maddr[NR_CARDS] = { 0, };
 static int irq[NR_CARDS]  = { 0, };
 
-MODULE_PARM(maddr, "1-" __MODULE_STRING(NR_CARDS) "l");
-MODULE_PARM(irq, "1-" __MODULE_STRING(NR_CARDS) "i");
+module_param_array(maddr, long, NULL, 0);
+module_param_array(irq, int, NULL, 0);
 #endif
 
 #endif /* CONFIG_ISA */
@@ -2690,20 +2690,16 @@
 #ifdef CY_DEBUG_WAIT_UNTIL_SENT
 	    printk("Not clean (jiff=%lu)...", jiffies);
 #endif
-	    current->state = TASK_INTERRUPTIBLE;
-	    schedule_timeout(char_time);
-	    if (signal_pending(current))
+	    if (msleep_interruptible(jiffies_to_msecs(char_time)))
 		break;
 	    if (timeout && time_after(jiffies, orig_jiffies + timeout))
 		break;
 	}
-	current->state = TASK_RUNNING;
     } else {
 	// Nothing to do!
     }
     /* Run one more char cycle */
-    current->state = TASK_INTERRUPTIBLE;
-    schedule_timeout(char_time * 5);
+    msleep_interruptible(jiffies_to_msecs(char_time * 5));
 #ifdef CY_DEBUG_WAIT_UNTIL_SENT
     printk("Clean (jiff=%lu)...done\n", jiffies);
 #endif
@@ -2828,8 +2824,7 @@
     if (info->blocked_open) {
 	CY_UNLOCK(info, flags);
         if (info->close_delay) {
-            current->state = TASK_INTERRUPTIBLE;
-            schedule_timeout(info->close_delay);
+            msleep_interruptible(jiffies_to_msecs(info->close_delay));
         }
         wake_up_interruptible(&info->open_wait);
 	CY_LOCK(info, flags);
@@ -2860,8 +2855,7 @@
  *
  */
 static int
-cy_write(struct tty_struct * tty, int from_user,
-           const unsigned char *buf, int count)
+cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
 {
   struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
   unsigned long flags;
@@ -2879,56 +2873,22 @@
         return 0;
     }
 
-    if (from_user) {
-	down(&tmp_buf_sem);
-	while (1) {
-	    int c1;
-	    
-	    c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1),
-				(int)(SERIAL_XMIT_SIZE - info->xmit_head)));
-	    if (c <= 0)
-		break;
-
-	    c -= copy_from_user(tmp_buf, buf, c);
-	    if (!c) {
-		if (!ret) {
-		    ret = -EFAULT;
-		}
-		break;
-	    }
-	    CY_LOCK(info, flags);
-	    c1 = min(c, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1),
-			(int)(SERIAL_XMIT_SIZE - info->xmit_head)));
-			
-	    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));
-	    info->xmit_cnt += c;
-            CY_UNLOCK(info, flags);
-	    buf += c;
-	    count -= c;
-	    ret += c;
-	}
-	up(&tmp_buf_sem);
-    } else {
-	CY_LOCK(info, flags);
-	while (1) {
-	    c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1),
+    CY_LOCK(info, flags);
+    while (1) {
+	c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1),
 			(int)(SERIAL_XMIT_SIZE - info->xmit_head)));
 	        
-	    if (c <= 0)
-		break;
+	if (c <= 0)
+	    break;
 
-	    memcpy(info->xmit_buf + info->xmit_head, buf, c);
-	    info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-	    info->xmit_cnt += c;
-	    buf += c;
-	    count -= c;
-	    ret += c;
-	}
-        CY_UNLOCK(info, flags);
+	memcpy(info->xmit_buf + info->xmit_head, buf, c);
+	info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
+	info->xmit_cnt += c;
+	buf += c;
+	count -= c;
+	ret += c;
     }
+    CY_UNLOCK(info, flags);
 
     info->idle_stats.xmit_bytes += ret;
     info->idle_stats.xmit_idle   = jiffies;
@@ -4765,7 +4725,7 @@
         for (i = 0; i < NR_CARDS; i++) {
                 /* look for a Cyclades card by vendor and device id */
                 while((device_id = cy_pci_dev_id[dev_index]) != 0) {
-                        if((pdev = pci_find_device(PCI_VENDOR_ID_CYCLADES,
+                        if((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
                                         device_id, pdev)) == NULL) {
                                 dev_index++;    /* try next device id */
                         } else {
@@ -5591,7 +5551,7 @@
     }
     for (j = 1; j <= ints[0]; j++){
         if ( i < NR_ISA_ADDRS ){
-            cy_isa_addresses[i++] = (unsigned char *)(ints[j]);
+            cy_isa_addresses[i++] = ints[j];
         }
     }
 #endif /* CONFIG_ISA */
diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
--- a/drivers/char/drm/drm_drv.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/char/drm/drm_drv.h	2004-12-24 13:37:18 -08:00
@@ -556,9 +556,8 @@
 
 	DRM(mem_init)();
 
-	while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
+	for_each_pci_dev(pdev) 
 		DRM(probe)(pdev);
-	}
 	return 0;
 }
 
diff -Nru a/drivers/char/drm/drm_fops.h b/drivers/char/drm/drm_fops.h
--- a/drivers/char/drm/drm_fops.h	2004-12-24 13:36:56 -08:00
+++ b/drivers/char/drm/drm_fops.h	2004-12-24 13:36:56 -08:00
@@ -99,8 +99,11 @@
 	 */
 	if (!dev->hose) {
 		struct pci_dev *pci_dev;
-		pci_dev = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
-		if (pci_dev) dev->hose = pci_dev->sysdata;
+		pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
+		if (pci_dev) {
+			dev->hose = pci_dev->sysdata;
+			pci_dev_put(pci_dev);
+		}
 		if (!dev->hose) {
 			struct pci_bus *b = pci_bus_b(pci_root_buses.next);
 			if (b) dev->hose = b->sysdata;
diff -Nru a/drivers/char/drm/drm_vm.h b/drivers/char/drm/drm_vm.h
--- a/drivers/char/drm/drm_vm.h	2004-12-24 13:37:32 -08:00
+++ b/drivers/char/drm/drm_vm.h	2004-12-24 13:37:32 -08:00
@@ -620,8 +620,8 @@
 					vma->vm_end - vma->vm_start,
 					vma->vm_page_prot, 0))
 #else
-		if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
-				     VM_OFFSET(vma) + offset,
+		if (remap_pfn_range(DRM_RPR_ARG(vma) vma->vm_start,
+				     (VM_OFFSET(vma) + offset) >> PAGE_SHIFT,
 				     vma->vm_end - vma->vm_start,
 				     vma->vm_page_prot))
 #endif
diff -Nru a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
--- a/drivers/char/drm/i810_dma.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/char/drm/i810_dma.c	2004-12-24 13:36:47 -08:00
@@ -138,8 +138,8 @@
    	buf_priv->currently_mapped = I810_BUF_MAPPED;
 	unlock_kernel();
 
-	if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
-			     VM_OFFSET(vma),
+	if (remap_pfn_range(DRM_RPR_ARG(vma) vma->vm_start,
+			     VM_OFFSET(vma) >> PAGE_SHIFT,
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot)) return -EAGAIN;
 	return 0;
diff -Nru a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
--- a/drivers/char/drm/i830_dma.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/char/drm/i830_dma.c	2004-12-24 13:36:18 -08:00
@@ -139,8 +139,8 @@
    	buf_priv->currently_mapped = I830_BUF_MAPPED;
 	unlock_kernel();
 
-	if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
-			     VM_OFFSET(vma),
+	if (remap_pfn_range(DRM_RPR_ARG(vma) vma->vm_start,
+			     VM_OFFSET(vma) >> PAGE_SHIFT,
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot)) return -EAGAIN;
 	return 0;
diff -Nru a/drivers/char/drm/radeon_mem.c b/drivers/char/drm/radeon_mem.c
--- a/drivers/char/drm/radeon_mem.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/char/drm/radeon_mem.c	2004-12-24 13:37:19 -08:00
@@ -85,7 +85,7 @@
 	struct mem_block *p;
 	int mask = (1 << align2)-1;
 
-	for (p = heap->next ; p != heap ; p = p->next) {
+	list_for_each(p, heap) {
 		int start = (p->start + mask) & ~mask;
 		if (p->filp == 0 && start + size <= p->start + p->size)
 			return split_block( p, start, size, filp );
@@ -98,7 +98,7 @@
 {
 	struct mem_block *p;
 
-	for (p = heap->next ; p != heap ; p = p->next) 
+	list_for_each(p, heap)
 		if (p->start == start)
 			return p;
 
@@ -166,7 +166,7 @@
 	if (!heap || !heap->next)
 		return;
 
-	for (p = heap->next ; p != heap ; p = p->next) {
+	list_for_each(p, heap) {
 		if (p->filp == filp) 
 			p->filp = NULL;
 	}
@@ -174,7 +174,7 @@
 	/* Assumes a single contiguous range.  Needs a special filp in
 	 * 'heap' to stop it being subsumed.
 	 */
-	for (p = heap->next ; p != heap ; p = p->next) {
+	list_for_each(p, heap) {
 		while (p->filp == 0 && p->next->filp == 0) {
 			struct mem_block *q = p->next;
 			p->size += q->size;
diff -Nru a/drivers/char/ds1302.c b/drivers/char/ds1302.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/char/ds1302.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,354 @@
+/*!***************************************************************************
+*!
+*! FILE NAME  : ds1302.c
+*!
+*! DESCRIPTION: Implements an interface for the DS1302 RTC
+*!
+*! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init, get_rtc_status
+*!
+*! ---------------------------------------------------------------------------
+*!
+*! (C) Copyright 1999, 2000, 2001  Axis Communications AB, LUND, SWEDEN
+*!
+*!***************************************************************************/
+
+#include <linux/config.h>
+
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/miscdevice.h>
+#include <linux/delay.h>
+#include <linux/bcd.h>
+
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/rtc.h>
+#if defined(CONFIG_M32R)
+#include <asm/m32r.h>
+#endif
+
+#define RTC_MAJOR_NR 121 /* local major, change later */
+
+static const char ds1302_name[] = "ds1302";
+
+/* Send 8 bits. */
+static void
+out_byte_rtc(unsigned int reg_addr, unsigned char x)
+{
+	//RST H
+	outw(0x0001,(unsigned long)PLD_RTCRSTODT);
+	//write data
+	outw(((x<<8)|(reg_addr&0xff)),(unsigned long)PLD_RTCWRDATA);
+	//WE
+	outw(0x0002,(unsigned long)PLD_RTCCR);
+	//wait
+	while(inw((unsigned long)PLD_RTCCR));
+
+	//RST L
+	outw(0x0000,(unsigned long)PLD_RTCRSTODT);
+
+}
+
+static unsigned char
+in_byte_rtc(unsigned int reg_addr)
+{
+	unsigned char retval;
+
+	//RST H
+	outw(0x0001,(unsigned long)PLD_RTCRSTODT);
+	//write data
+	outw((reg_addr&0xff),(unsigned long)PLD_RTCRDDATA);
+	//RE
+	outw(0x0001,(unsigned long)PLD_RTCCR);
+	//wait
+	while(inw((unsigned long)PLD_RTCCR));
+
+	//read data
+	retval=(inw((unsigned long)PLD_RTCRDDATA) & 0xff00)>>8;
+
+	//RST L
+	outw(0x0000,(unsigned long)PLD_RTCRSTODT);
+
+	return retval;
+}
+
+/* Enable writing. */
+
+static void
+ds1302_wenable(void)
+{
+	out_byte_rtc(0x8e,0x00);
+}
+
+/* Disable writing. */
+
+static void
+ds1302_wdisable(void)
+{
+	out_byte_rtc(0x8e,0x80);
+}
+
+
+
+/* Read a byte from the selected register in the DS1302. */
+
+unsigned char
+ds1302_readreg(int reg)
+{
+	unsigned char x;
+
+	x=in_byte_rtc((0x81 | (reg << 1))); /* read register */
+
+	return x;
+}
+
+/* Write a byte to the selected register. */
+
+void
+ds1302_writereg(int reg, unsigned char val)
+{
+	ds1302_wenable();
+	out_byte_rtc((0x80 | (reg << 1)),val);
+	ds1302_wdisable();
+}
+
+void
+get_rtc_time(struct rtc_time *rtc_tm)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	local_irq_disable();
+
+	rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);
+	rtc_tm->tm_min = CMOS_READ(RTC_MINUTES);
+	rtc_tm->tm_hour = CMOS_READ(RTC_HOURS);
+	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);
+
+	local_irq_restore(flags);
+
+	BCD_TO_BIN(rtc_tm->tm_sec);
+	BCD_TO_BIN(rtc_tm->tm_min);
+	BCD_TO_BIN(rtc_tm->tm_hour);
+	BCD_TO_BIN(rtc_tm->tm_mday);
+	BCD_TO_BIN(rtc_tm->tm_mon);
+	BCD_TO_BIN(rtc_tm->tm_year);
+
+	/*
+	 * Account for differences between how the RTC uses the values
+	 * and how they are defined in a struct rtc_time;
+	 */
+
+	if (rtc_tm->tm_year <= 69)
+		rtc_tm->tm_year += 100;
+
+	rtc_tm->tm_mon--;
+}
+
+static unsigned char days_in_mo[] =
+    {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+/* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */
+
+static int
+rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+	  unsigned long arg)
+{
+	unsigned long flags;
+
+	switch(cmd) {
+		case RTC_RD_TIME:	/* read the time/date from RTC	*/
+		{
+			struct rtc_time rtc_tm;
+
+			memset(&rtc_tm, 0, sizeof (struct rtc_time));
+			get_rtc_time(&rtc_tm);
+			if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
+				return -EFAULT;
+			return 0;
+		}
+
+		case RTC_SET_TIME:	/* set the RTC */
+		{
+			struct rtc_time rtc_tm;
+			unsigned char mon, day, hrs, min, sec, leap_yr;
+			unsigned int yrs;
+
+			if (!capable(CAP_SYS_TIME))
+				return -EPERM;
+
+			if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, sizeof(struct rtc_time)))
+				return -EFAULT;
+
+			yrs = rtc_tm.tm_year + 1900;
+			mon = rtc_tm.tm_mon + 1;   /* tm_mon starts at zero */
+			day = rtc_tm.tm_mday;
+			hrs = rtc_tm.tm_hour;
+			min = rtc_tm.tm_min;
+			sec = rtc_tm.tm_sec;
+
+
+			if ((yrs < 1970) || (yrs > 2069))
+				return -EINVAL;
+
+			leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400));
+
+			if ((mon > 12) || (day == 0))
+				return -EINVAL;
+
+			if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr)))
+				return -EINVAL;
+
+			if ((hrs >= 24) || (min >= 60) || (sec >= 60))
+				return -EINVAL;
+
+			if (yrs >= 2000)
+				yrs -= 2000;	/* RTC (0, 1, ... 69) */
+			else
+				yrs -= 1900;	/* RTC (70, 71, ... 99) */
+
+			BIN_TO_BCD(sec);
+			BIN_TO_BCD(min);
+			BIN_TO_BCD(hrs);
+			BIN_TO_BCD(day);
+			BIN_TO_BCD(mon);
+			BIN_TO_BCD(yrs);
+
+			local_irq_save(flags);
+			local_irq_disable();
+			CMOS_WRITE(yrs, RTC_YEAR);
+			CMOS_WRITE(mon, RTC_MONTH);
+			CMOS_WRITE(day, RTC_DAY_OF_MONTH);
+			CMOS_WRITE(hrs, RTC_HOURS);
+			CMOS_WRITE(min, RTC_MINUTES);
+			CMOS_WRITE(sec, RTC_SECONDS);
+			local_irq_restore(flags);
+
+			/* Notice that at this point, the RTC is updated but
+			 * the kernel is still running with the old time.
+			 * You need to set that separately with settimeofday
+			 * or adjtimex.
+			 */
+			return 0;
+		}
+
+		case RTC_SET_CHARGE: /* set the RTC TRICKLE CHARGE register */
+		{
+			int tcs_val;
+
+			if (!capable(CAP_SYS_TIME))
+				return -EPERM;
+
+			if(copy_from_user(&tcs_val, (int*)arg, sizeof(int)))
+				return -EFAULT;
+
+			tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F);
+			ds1302_writereg(RTC_TRICKLECHARGER, tcs_val);
+			return 0;
+		}
+		default:
+			return -EINVAL;
+	}
+}
+
+int
+get_rtc_status(char *buf)
+{
+	char *p;
+	struct rtc_time tm;
+
+	p = buf;
+
+	get_rtc_time(&tm);
+
+	/*
+	 * There is no way to tell if the luser has the RTC set for local
+	 * time or for Universal Standard Time (GMT). Probably local though.
+	 */
+
+	p += sprintf(p,
+		"rtc_time\t: %02d:%02d:%02d\n"
+		"rtc_date\t: %04d-%02d-%02d\n",
+		tm.tm_hour, tm.tm_min, tm.tm_sec,
+		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
+
+	return  p - buf;
+}
+
+
+/* The various file operations we support. */
+
+static struct file_operations rtc_fops = {
+	.owner		= THIS_MODULE,
+	.ioctl		= rtc_ioctl,
+};
+
+/* Probe for the chip by writing something to its RAM and try reading it back. */
+
+#define MAGIC_PATTERN 0x42
+
+static int __init
+ds1302_probe(void)
+{
+	int retval, res, baur;
+
+	baur=(boot_cpu_data.bus_clock/(2*1000*1000));
+
+	printk("%s: Set PLD_RTCBAUR = %d\n", ds1302_name,baur);
+
+	outw(0x0000,(unsigned long)PLD_RTCCR);
+	outw(0x0000,(unsigned long)PLD_RTCRSTODT);
+	outw(baur,(unsigned long)PLD_RTCBAUR);
+
+	/* Try to talk to timekeeper. */
+
+	ds1302_wenable();
+	/* write RAM byte 0 */
+	/* write something magic */
+	out_byte_rtc(0xc0,MAGIC_PATTERN);
+
+	/* read RAM byte 0 */
+	if((res = in_byte_rtc(0xc1)) == MAGIC_PATTERN) {
+		char buf[100];
+		ds1302_wdisable();
+		printk("%s: RTC found.\n", ds1302_name);
+		get_rtc_status(buf);
+		printk(buf);
+		retval = 1;
+	} else {
+		printk("%s: RTC not found.\n", ds1302_name);
+		retval = 0;
+	}
+
+	return retval;
+}
+
+
+/* Just probe for the RTC and register the device to handle the ioctl needed. */
+
+int __init
+ds1302_init(void)
+{
+	if (!ds1302_probe()) {
+		return -1;
+  	}
+	return 0;
+}
+
+static int __init ds1302_register(void)
+{
+	ds1302_init();
+	if (register_chrdev(RTC_MAJOR_NR, ds1302_name, &rtc_fops)) {
+		printk(KERN_INFO "%s: unable to get major %d for rtc\n",
+		       ds1302_name, RTC_MAJOR_NR);
+		return -1;
+	}
+	return 0;
+}
+
+module_init(ds1302_register);
diff -Nru a/drivers/char/dtlk.c b/drivers/char/dtlk.c
--- a/drivers/char/dtlk.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/char/dtlk.c	2004-12-24 13:36:48 -08:00
@@ -107,7 +107,6 @@
 };
 
 /* local prototypes */
-static void dtlk_delay(int ms);
 static int dtlk_dev_probe(void);
 static struct dtlk_settings *dtlk_interrogate(void);
 static int dtlk_readable(void);
@@ -146,7 +145,7 @@
 			return i;
 		if (file->f_flags & O_NONBLOCK)
 			break;
-		dtlk_delay(100);
+		msleep_interruptible(100);
 	}
 	if (retries == loops_per_jiffy)
 		printk(KERN_ERR "dtlk_read times out\n");
@@ -191,7 +190,7 @@
 				   rate to 500 bytes/sec, but that's
 				   still enough to keep up with the
 				   speech synthesizer. */
-				dtlk_delay(1);
+				msleep_interruptible(1);
 			else {
 				/* the RDY bit goes zero 2-3 usec
 				   after writing, and goes 1 again
@@ -212,7 +211,7 @@
 		if (file->f_flags & O_NONBLOCK)
 			break;
 
-		dtlk_delay(1);
+		msleep_interruptible(1);
 
 		if (++retries > 10 * HZ) { /* wait no more than 10 sec
 					      from last write */
@@ -351,8 +350,7 @@
 static void __exit dtlk_cleanup (void)
 {
 	dtlk_write_bytes("goodbye", 8);
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(5 * HZ / 10);		/* nap 0.50 sec but
+	msleep_interruptible(500);		/* nap 0.50 sec but
 						   could be awakened
 						   earlier by
 						   signals... */
@@ -368,13 +366,6 @@
 
 /* ------------------------------------------------------------------------ */
 
-/* sleep for ms milliseconds */
-static void dtlk_delay(int ms)
-{
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout((ms * HZ + 1000 - HZ) / 1000);
-}
-
 static int dtlk_readable(void)
 {
 #ifdef TRACING
@@ -431,7 +422,7 @@
 			/* posting an index takes 18 msec.  Here, we
 			   wait up to 100 msec to see whether it
 			   appears. */
-			dtlk_delay(100);
+			msleep_interruptible(100);
 			dtlk_has_indexing = dtlk_readable();
 #ifdef TRACING
 			printk(", indexing %d\n", dtlk_has_indexing);
diff -Nru a/drivers/char/ec3104_keyb.c b/drivers/char/ec3104_keyb.c
--- a/drivers/char/ec3104_keyb.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/char/ec3104_keyb.c	2004-12-24 13:36:48 -08:00
@@ -43,9 +43,9 @@
 #include <linux/slab.h>
 #include <linux/kbd_kern.h>
 #include <linux/smp_lock.h>
+#include <linux/bitops.h>
 
 #include <asm/keyboard.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/irq.h>
 #include <asm/system.h>
diff -Nru a/drivers/char/epca.c b/drivers/char/epca.c
--- a/drivers/char/epca.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/char/epca.c	2004-12-24 13:36:59 -08:00
@@ -218,7 +218,7 @@
 void console_print(const char *);
 
 static int get_termio(struct tty_struct *, struct termio __user *);
-static int pc_write(struct tty_struct *, int, const unsigned char *, int);
+static int pc_write(struct tty_struct *, const unsigned char *, int);
 int pc_init(void);
 
 #ifdef ENABLE_PCI
@@ -561,8 +561,7 @@
 
 			if (ch->close_delay) 
 			{
-				current->state = TASK_INTERRUPTIBLE;
-				schedule_timeout(ch->close_delay);
+				msleep_interruptible(jiffies_to_msecs(ch->close_delay));
 			}
 
 			wake_up_interruptible(&ch->open_wait);
@@ -670,7 +669,7 @@
 
 /* ------------------ Begin pc_write  ------------------------- */
 
-static int pc_write(struct tty_struct * tty, int from_user,
+static int pc_write(struct tty_struct * tty,
                     const unsigned char *buf, int bytesAvailable)
 { /* Begin pc_write */
 
@@ -708,162 +707,6 @@
 	bc   = ch->brdchan;
 	size = ch->txbufsize;
 
-	if (from_user) 
-	{ /* Begin from_user */
-
-		save_flags(flags);
-		cli();
-
-		globalwinon(ch);
-
-		/* -----------------------------------------------------------------	
-			Anding against size will wrap the pointer back to its beginning 
-			position if it is necessary.  This will only work if size is
-			a power of 2 which should always be the case.  Size is determined 
-			by the cards on board FEP/OS.
-		-------------------------------------------------------------------- */	
-
-		/* head refers to the next empty location in which data may be stored */ 
-
-		head = bc->tin & (size - 1);
-
-		/* tail refers to the next data byte to be transmitted */ 
-
-		tail = bc->tout;
-
-		/* Consider changing this to a do statement to make sure */
-
-		if (tail != bc->tout)
-			tail = bc->tout;
-
-		/* ------------------------------------------------------------------	
-			Anding against size will wrap the pointer back to its beginning 
-			position if it is necessary.  This will only work if size is
-			a power of 2 which should always be the case.  Size is determined 
-			by the cards on board FEP/OS.
-		--------------------------------------------------------------------- */	
-
-		tail &= (size - 1);
-
-		/* -----------------------------------------------------------------
-			Two situations can affect how space in the transmit buffer
-			is calculated.  You can have a situation where the transmit
-			in pointer (tin) head has wrapped around and actually has a 
-			lower address than the transmit out pointer (tout) tail; or
-			the transmit in pointer (tin) head will not be wrapped around
-			yet, and have a higher address than the transmit out pointer
-			(tout) tail.  Obviously space available in the transmit buffer
-			is calculated differently for each case.
-
-			Example 1:
-			
-			Consider a 10 byte buffer where head is a pointer to the next
-			empty location in the buffer and tail is a pointer to the next 
-			byte to transmit.  In this example head will not have wrapped 
-			around and therefore head > tail.  
-
-			0      1      2      3      4      5      6      7      8      9   
-		                tail                               head
-
-			The above diagram shows that buffer locations 2,3,4,5 and 6 have
-			data to be transmitted, while head points at the next empty
-			location.  To calculate how much space is available first we have
-			to determine if the head pointer (tin) has wrapped.  To do this
-			compare the head pointer to the tail pointer,  If head is equal
-			or greater than tail; then it has not wrapped; and the space may
-			be calculated by subtracting tail from head and then subtracting
-			that value from the buffers size.  A one is subtracted from the
-			new value to indicate how much space is available between the 
-			head pointer and end of buffer; as well as the space between the
-			beginning of the buffer and the tail.  If the head is not greater
-			or equal to the tail this indicates that the head has wrapped
-			around to the beginning of the buffer.  To calculate the space 
-			available in this case simply subtract head from tail.  This new 
-			value minus one represents the space available betwwen the head 
-			and tail pointers.  In this example head (7) is greater than tail (2)
-			and therefore has not wrapped around.  We find the space by first
-			subtracting tail from head (7-2=5).  We then subtract this value
-			from the buffer size of ten and subtract one (10-5-1=4).  The space
-			remaining is 4 bytes. 
-
-			Example 2:
-			
-			Consider a 10 byte buffer where head is a pointer to the next
-			empty location in the buffer and tail is a pointer to the next 
-			byte to transmit.  In this example head will wrapped around and 
-			therefore head < tail.  
-
-			0      1      2      3      4      5      6      7      8      9   
-		                head                               tail
-
-			The above diagram shows that buffer locations 7,8,9,0 and 1 have
-			data to be transmitted, while head points at the next empty
-			location.  To find the space available we compare head to tail.  If
-			head is not equal to, or greater than tail this indicates that head
-			has wrapped around. In this case head (2) is not equal to, or
-			greater than tail (7) and therefore has already wrapped around.  To
-			calculate the available space between the two pointers we subtract
-			head from tail (7-2=5).  We then subtract one from this new value
-			(5-1=4).  We have 5 bytes empty remaining in the buffer.  Unlike the
-			previous example these five bytes are located between the head and
-			tail pointers. 
-
-		----------------------------------------------------------------------- */
-
-		dataLen = (head >= tail) ? (size - (head - tail) - 1) : (tail - head - 1);
-
-		/* ----------------------------------------------------------------------
-			In this case bytesAvailable has been passed into pc_write and
-			represents the amount of data that needs to be written.  dataLen
-			represents the amount of space available on the card.  Whichever
-			value is smaller will be the amount actually written. 
-			bytesAvailable will then take on this newly calculated value.
-		---------------------------------------------------------------------- */
-
-		bytesAvailable = min(dataLen, bytesAvailable);
-
-		/* First we read the data in from the file system into a temp buffer */
-
-		memoff(ch);
-		restore_flags(flags);
-
-		if (bytesAvailable) 
-		{ /* Begin bytesAvailable */
-			/* ---------------------------------------------------------------
-				The below function reads data from user memory.  This routine
-				can not be used in an interrupt routine. (Because it may 
-				generate a page fault)  It can only be called while we can the
-				user context is accessible. 
-
-				The prototype is :
-				inline void copy_from_user(void * to, const void * from,
-							  unsigned long count);
-
-				I also think (Check hackers guide) that optimization must
-				be turned ON.  (Which sounds strange to me...)
-
-				Remember copy_from_user WILL generate a page fault if the
-				user memory being accessed has been swapped out.  This can
-				cause this routine to temporarily sleep while this page
-				fault is occurring.
-			
-			----------------------------------------------------------------- */
-
-			if (copy_from_user(ch->tmp_buf, buf,
-					   bytesAvailable))
-				return -EFAULT;
-		} /* End bytesAvailable */
-
-		/* ------------------------------------------------------------------ 
-			Set buf to this address for the moment.  tmp_buf was allocated in
-			post_fep_init.
-		--------------------------------------------------------------------- */
-		buf = ch->tmp_buf;
-
-	} /* End from_user */
-
-	/* All data is now local */
-
 	amountCopied = 0;
 	save_flags(flags);
 	cli();
@@ -954,7 +797,7 @@
 { /* Begin pc_put_char */
 
    
-	pc_write(tty, 0, &c, 1);
+	pc_write(tty, &c, 1);
 	return;
 
 } /* End pc_put_char */
@@ -3933,23 +3776,12 @@
 
 int __init init_PCI (void)
 { /* Begin init_PCI */
-	
-	int pci_count;
-	
 	memset (&epca_driver, 0, sizeof (epca_driver));
 	epca_driver.name = "epca";
 	epca_driver.id_table = epca_pci_tbl;
 	epca_driver.probe = epca_init_one;
 
-	pci_count = pci_register_driver (&epca_driver);
-	
-	if (pci_count <= 0) {
-		pci_unregister_driver (&epca_driver);
-		pci_count = 0;
-	}
-
-	return(pci_count);
-
+	return pci_register_driver(&epca_driver);
 } /* End init_PCI */
 
 #endif /* ENABLE_PCI */
diff -Nru a/drivers/char/epca.h b/drivers/char/epca.h
--- a/drivers/char/epca.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/char/epca.h	2004-12-24 13:37:43 -08:00
@@ -149,7 +149,7 @@
 	ushort numports;
 	unchar *port;
 	unchar *membase;
-	unchar *re_map_port;
+	unchar __iomem *re_map_port;
 	unchar *re_map_membase;
 	ulong  memory_seg;
 	void ( * memwinon )	(struct board_info *, unsigned int) ;
diff -Nru a/drivers/char/esp.c b/drivers/char/esp.c
--- a/drivers/char/esp.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/char/esp.c	2004-12-24 13:36:16 -08:00
@@ -57,6 +57,7 @@
 #include <linux/ioport.h>
 #include <linux/mm.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -70,6 +71,7 @@
 
 #define NR_PORTS 64	/* maximum number of ports */
 #define NR_PRIMARY 8	/* maximum number of primary ports */
+#define REGION_SIZE 8   /* size of io region to request */
 
 /* The following variables can be set by giving module options */
 static int irq[NR_PRIMARY];	/* IRQ for each base port */
@@ -84,15 +86,15 @@
 
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(irq, "1-8i");
-MODULE_PARM(divisor, "1-8i");
-MODULE_PARM(dma, "i");
-MODULE_PARM(rx_trigger, "i");
-MODULE_PARM(tx_trigger, "i");
-MODULE_PARM(flow_off, "i");
-MODULE_PARM(flow_on, "i");
-MODULE_PARM(rx_timeout, "i");
-MODULE_PARM(pio_threshold, "i");
+module_param_array(irq, int, NULL, 0);
+module_param_array(divisor, uint, NULL, 0);
+module_param(dma, uint, 0);
+module_param(rx_trigger, uint, 0);
+module_param(tx_trigger, uint, 0);
+module_param(flow_off, uint, 0);
+module_param(flow_on, uint, 0);
+module_param(rx_timeout, uint, 0);
+module_param(pio_threshold, uint, 0);
 
 /* END */
 
@@ -1263,7 +1265,7 @@
 	restore_flags(flags);
 }
 
-static int rs_write(struct tty_struct * tty, int from_user,
+static int rs_write(struct tty_struct * tty,
 		    const unsigned char *buf, int count)
 {
 	int	c, t, ret = 0;
@@ -1276,9 +1278,6 @@
 	if (!tty || !info->xmit_buf || !tmp_buf)
 		return 0;
 	    
-	if (from_user)
-		down(&tmp_buf_sem);
-
 	while (1) {
 		/* Thanks to R. Wolff for suggesting how to do this with */
 		/* interrupts enabled */
@@ -1297,18 +1296,7 @@
 		if (c <= 0)
 			break;
 
-		if (from_user) {
-			c -= copy_from_user(tmp_buf, buf, c);
-
-			if (!c) {
-				if (!ret)
-					ret = -EFAULT;
-				break;
-			}
-
-			memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
-		} else
-			memcpy(info->xmit_buf + info->xmit_head, buf, c);
+		memcpy(info->xmit_buf + info->xmit_head, buf, c);
 
 		info->xmit_head = (info->xmit_head + c) & (ESP_XMIT_SIZE-1);
 		info->xmit_cnt += c;
@@ -1317,9 +1305,6 @@
 		ret += c;
 	}
 
-	if (from_user)
-		up(&tmp_buf_sem);
-	
 	save_flags(flags); cli();
 
 	if (info->xmit_cnt && !tty->stopped && !(info->IER & UART_IER_THRI)) {
@@ -2066,8 +2051,7 @@
 
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -2098,8 +2082,7 @@
 
 	while ((serial_in(info, UART_ESI_STAT1) != 0x03) ||
 		(serial_in(info, UART_ESI_STAT2) != 0xff)) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(char_time);
+		msleep_interruptible(jiffies_to_msecs(char_time));
 
 		if (signal_pending(current))
 			break;
@@ -2344,19 +2327,21 @@
  * This routine is called by espserial_init() to initialize a specific serial
  * port.
  */
-static _INLINE_ int autoconfig(struct esp_struct * info, int *region_start)
+static _INLINE_ int autoconfig(struct esp_struct * info)
 {
 	int port_detected = 0;
 	unsigned long flags;
 
+	if (!request_region(info->port, REGION_SIZE, "esp serial"))
+		return -EIO;
+
 	save_flags(flags); cli();
 	
 	/*
 	 * Check for ESP card
 	 */
 
-	if (!check_region(info->port, 8) && 
-	    serial_in(info, UART_ESI_BASE) == 0xf3) {
+	if (serial_in(info, UART_ESI_BASE) == 0xf3) {
 		serial_out(info, UART_ESI_CMD1, 0x00);
 		serial_out(info, UART_ESI_CMD1, 0x01);
 
@@ -2372,19 +2357,6 @@
 					info->irq = 4;
 			}
 
-			if (ports && (ports->port == (info->port - 8))) {
-				release_region(*region_start,
-					       info->port - *region_start);
-			} else
-				*region_start = info->port;
-
-			if (!request_region(*region_start,
-				       info->port - *region_start + 8,
-				       "esp serial"))
-			{
-				restore_flags(flags);
-				return -EIO;
-			}
 
 			/* put card in enhanced mode */
 			/* this prevents access through */
@@ -2397,6 +2369,8 @@
 			serial_out(info, UART_ESI_CMD2, 0x00);
 		}
 	}
+	if (!port_detected)
+		release_region(info->port, REGION_SIZE);
 
 	restore_flags(flags);
 	return (port_detected);
@@ -2430,7 +2404,6 @@
 int __init espserial_init(void)
 {
 	int i, offset;
-	int region_start;
 	struct esp_struct * info;
 	struct esp_struct *last_primary = NULL;
 	int esp[] = {0x100,0x140,0x180,0x200,0x240,0x280,0x300,0x380};
@@ -2516,7 +2489,7 @@
 		info->irq = irq[i];
 		info->line = (i * 8) + (offset / 8);
 
-		if (!autoconfig(info, &region_start)) {
+		if (!autoconfig(info)) {
 			i++;
 			offset = 0;
 			continue;
@@ -2592,7 +2565,6 @@
 {
 	unsigned long flags;
 	int e1;
-	unsigned int region_start, region_end;
 	struct esp_struct *temp_async;
 	struct esp_pio_buffer *pio_buf;
 
@@ -2607,27 +2579,8 @@
 
 	while (ports) {
 		if (ports->port) {
-			region_start = region_end = ports->port;
-			temp_async = ports;
-
-			while (temp_async) {
-				if ((region_start - temp_async->port) == 8) {
-					region_start = temp_async->port;
-					temp_async->port = 0;
-					temp_async = ports;
-				} else if ((temp_async->port - region_end)
-					   == 8) {
-					region_end = temp_async->port;
-					temp_async->port = 0;
-					temp_async = ports;
-				} else
-					temp_async = temp_async->next_port;
-			}
-			
-			release_region(region_start,
-				       region_end - region_start + 8);
+			release_region(ports->port, REGION_SIZE);
 		}
-
 		temp_async = ports->next_port;
 		kfree(ports);
 		ports = temp_async;
diff -Nru a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c
--- a/drivers/char/ftape/lowlevel/fdc-io.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/char/ftape/lowlevel/fdc-io.c	2004-12-24 13:37:43 -08:00
@@ -389,7 +389,7 @@
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
-	current->state = TASK_INTERRUPTIBLE;
+	set_current_state(TASK_INTERRUPTIBLE);
 	add_wait_queue(&ftape_wait_intr, &wait);
 	while (!ft_interrupt_seen && (current->state == TASK_INTERRUPTIBLE)) {
 		timeout = schedule_timeout(timeout);
diff -Nru a/drivers/char/ftape/lowlevel/ftape-ctl.c b/drivers/char/ftape/lowlevel/ftape-ctl.c
--- a/drivers/char/ftape/lowlevel/ftape-ctl.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/char/ftape/lowlevel/ftape-ctl.c	2004-12-24 13:37:29 -08:00
@@ -726,9 +726,12 @@
 		ftape_reset_buffer();
 	}
 	for (i = 0; i < num_buffers; i++) {
-		TRACE_CATCH(remap_page_range(vma, vma->vm_start +
+		unsigned long pfn;
+
+		pfn = virt_to_phys(ft_buffer[i]->address) >> PAGE_SHIFT;
+		TRACE_CATCH(remap_pfn_range(vma, vma->vm_start +
 					     i * FT_BUFF_SIZE,
-					     virt_to_phys(ft_buffer[i]->address),
+					     pfn,
 					     FT_BUFF_SIZE,
 					     vma->vm_page_prot),
 			    _res = -EAGAIN);
diff -Nru a/drivers/char/ftape/lowlevel/ftape-init.c b/drivers/char/ftape/lowlevel/ftape-init.c
--- a/drivers/char/ftape/lowlevel/ftape-init.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/char/ftape/lowlevel/ftape-init.c	2004-12-24 13:37:18 -08:00
@@ -122,20 +122,29 @@
 #endif
 	TRACE_EXIT 0;
 }
-#define FT_MOD_PARM(var,type,desc) \
-	MODULE_PARM(var,type); MODULE_PARM_DESC(var,desc)
 
-FT_MOD_PARM(ft_fdc_base,       "i", "Base address of FDC controller.");
-FT_MOD_PARM(ft_fdc_irq,        "i", "IRQ (interrupt channel) to use.");
-FT_MOD_PARM(ft_fdc_dma,        "i", "DMA channel to use.");
-FT_MOD_PARM(ft_fdc_threshold,  "i", "Threshold of the FDC Fifo.");
-FT_MOD_PARM(ft_fdc_rate_limit, "i", "Maximal data rate for FDC.");
-FT_MOD_PARM(ft_probe_fc10,     "i", 
+module_param(ft_fdc_base,       uint, 0);
+MODULE_PARM_DESC(ft_fdc_base,  "Base address of FDC controller.");
+module_param(ft_fdc_irq,        uint, 0);
+MODULE_PARM_DESC(ft_fdc_irq,   "IRQ (interrupt channel) to use.");
+module_param(ft_fdc_dma,        uint, 0);
+MODULE_PARM_DESC(ft_fdc_dma,   "DMA channel to use.");
+module_param(ft_fdc_threshold,  uint, 0);
+MODULE_PARM_DESC(ft_fdc_threshold,  "Threshold of the FDC Fifo.");
+module_param(ft_fdc_rate_limit, uint, 0);
+MODULE_PARM_DESC(ft_fdc_rate_limit, "Maximal data rate for FDC.");
+module_param(ft_probe_fc10,     bool, 0);
+MODULE_PARM_DESC(ft_probe_fc10,
 	    "If non-zero, probe for a Colorado FC-10/FC-20 controller.");
-FT_MOD_PARM(ft_mach2,          "i",
+module_param(ft_mach2,          bool, 0);
+MODULE_PARM_DESC(ft_mach2,
 	    "If non-zero, probe for a Mountain MACH-2 controller.");
-FT_MOD_PARM(ft_tracing,        "i", 
+#if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
+module_param(ft_tracing,        int, 0644);
+MODULE_PARM_DESC(ft_tracing,
 	    "Amount of debugging output, 0 <= tracing <= 8, default 3.");
+#endif
+
 MODULE_AUTHOR(
 	"(c) 1993-1996 Bas Laarhoven (bas@vimec.nl), "
 	"(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no), "
diff -Nru a/drivers/char/ftape/lowlevel/ftape-io.c b/drivers/char/ftape/lowlevel/ftape-io.c
--- a/drivers/char/ftape/lowlevel/ftape-io.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/char/ftape/lowlevel/ftape-io.c	2004-12-24 13:36:47 -08:00
@@ -32,6 +32,7 @@
 #include <asm/system.h>
 #include <linux/ioctl.h>
 #include <linux/mtio.h>
+#include <linux/delay.h>
 
 #include <linux/ftape.h>
 #include <linux/qic117.h>
@@ -96,19 +97,12 @@
 		timeout = ticks;
 		save_flags(flags);
 		sti();
-		set_current_state(TASK_INTERRUPTIBLE);
-		do {
-			/*  Mmm. Isn't current->blocked == 0xffffffff ?
-			 */
-			if (signal_pending(current)) {
-				TRACE(ft_t_err,
-				      "awoken by non-blocked signal :-(");
-				break;	/* exit on signal */
-			}
-			while (current->state != TASK_RUNNING) {
-				timeout = schedule_timeout(timeout);
-			}
-		} while (timeout);
+		msleep_interruptible(jiffies_to_msecs(timeout));
+		/*  Mmm. Isn't current->blocked == 0xffffffff ?
+		 */
+		if (signal_pending(current)) {
+			TRACE(ft_t_err, "awoken by non-blocked signal :-(");
+		}
 		restore_flags(flags);
 	}
 	TRACE_EXIT;
diff -Nru a/drivers/char/ftape/zftape/zftape-buffers.c b/drivers/char/ftape/zftape/zftape-buffers.c
--- a/drivers/char/ftape/zftape/zftape-buffers.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/char/ftape/zftape/zftape-buffers.c	2004-12-24 13:36:16 -08:00
@@ -27,6 +27,7 @@
 #include <linux/errno.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 
 #include <linux/zftape.h>
 
@@ -119,8 +120,7 @@
 	void *new;
 
 	while ((new = kmalloc(size, GFP_KERNEL)) == NULL) {
-		current->state   = TASK_INTERRUPTIBLE;
-		schedule_timeout(HZ/10);
+		msleep_interruptible(100);
 	}
 	memset(new, 0, size);
 	used_memory += size;
diff -Nru a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
--- a/drivers/char/generic_serial.c	2004-12-24 13:36:54 -08:00
+++ b/drivers/char/generic_serial.c	2004-12-24 13:36:54 -08:00
@@ -26,6 +26,7 @@
 #include <linux/mm.h>
 #include <linux/generic_serial.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 #include <asm/semaphore.h>
 #include <asm/uaccess.h>
 
@@ -57,7 +58,7 @@
 
 #define RS_EVENT_WRITE_WAKEUP	1
 
-MODULE_PARM(gs_debug, "i");
+module_param(gs_debug, int, 0644);
 
 
 void gs_put_char(struct tty_struct * tty, unsigned char ch)
@@ -102,7 +103,7 @@
 >       -3- Other processes that are also trying to do a "write". 
 */
 
-int gs_write(struct tty_struct * tty, int from_user, 
+int gs_write(struct tty_struct * tty, 
                     const unsigned char *buf, int count)
 {
 	struct gs_port *port;
@@ -143,15 +144,8 @@
  
 		/* Can't copy more? break out! */
 		if (c <= 0) break;
-		if (from_user) {
-			if (copy_from_user (port->xmit_buf + port->xmit_head, 
-					    buf, c)) {
-				up (& port->port_write_sem);
-				return -EFAULT;
-			}
 
-		} else
-			memcpy (port->xmit_buf + port->xmit_head, buf, c);
+		memcpy (port->xmit_buf + port->xmit_head, buf, c);
 
 		port -> xmit_cnt += c;
 		port -> xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE -1);
@@ -182,7 +176,7 @@
 >       -3- Other processes that are also trying to do a "write". 
 */
 
-int gs_write(struct tty_struct * tty, int from_user, 
+int gs_write(struct tty_struct * tty,
                     const unsigned char *buf, int count)
 {
 	struct gs_port *port;
@@ -215,79 +209,35 @@
 		return -EIO;
 
 	save_flags(flags);
-	if (from_user) {
-		down(&tmp_buf_sem);
-		while (1) {
-			c = count;
-
-			/* This is safe because we "OWN" the "head". Noone else can 
-			   change the "head": we own the port_write_sem. */
-			/* Don't overrun the end of the buffer */
-			t = SERIAL_XMIT_SIZE - port->xmit_head;
-			if (t < c) c = t;
- 
-			/* This is safe because the xmit_cnt can only decrease. This 
-			   would increase "t", so we might copy too little chars. */
-			/* Don't copy past the "head" of the buffer */
-			t = SERIAL_XMIT_SIZE - 1 - port->xmit_cnt;
-			if (t < c) c = t;	 
-
-			/* Can't copy more? break out! */
-			if (c <= 0) break;
-
-			c -= copy_from_user(tmp_buf, buf, c);
-			if (!c) {
-				if (!total)
-					total = -EFAULT;
-				break;
-			}
-			cli();
-			t = SERIAL_XMIT_SIZE - port->xmit_head;
-			if (t < c) c = t;
-			t = SERIAL_XMIT_SIZE - 1 - port->xmit_cnt;
-			if (t < c) c = t;
-
-			memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c);
-			port->xmit_head = ((port->xmit_head + c) &
-			                   (SERIAL_XMIT_SIZE-1));
-			port->xmit_cnt += c;
-			restore_flags(flags);
-			buf += c;
-			count -= c;
-			total += c;
-		}
-		up(&tmp_buf_sem);
-	} else {
-		while (1) {
-			cli();
-			c = count;
-
-			/* This is safe because we "OWN" the "head". Noone else can 
-			   change the "head": we own the port_write_sem. */
-			/* Don't overrun the end of the buffer */
-			t = SERIAL_XMIT_SIZE - port->xmit_head;
-			if (t < c) c = t;
- 
-			/* This is safe because the xmit_cnt can only decrease. This 
-			   would increase "t", so we might copy too little chars. */
-			/* Don't copy past the "head" of the buffer */
-			t = SERIAL_XMIT_SIZE - 1 - port->xmit_cnt;
-			if (t < c) c = t;
- 
-			/* Can't copy more? break out! */
-			if (c <= 0) {
-				restore_flags(flags);
-				break;
-			}
-			memcpy(port->xmit_buf + port->xmit_head, buf, c);
-			port->xmit_head = ((port->xmit_head + c) &
-			                   (SERIAL_XMIT_SIZE-1));
-			port->xmit_cnt += c;
+	while (1) {
+		cli();
+		c = count;
+
+		/* This is safe because we "OWN" the "head". Noone else can 
+		   change the "head": we own the port_write_sem. */
+		/* Don't overrun the end of the buffer */
+		t = SERIAL_XMIT_SIZE - port->xmit_head;
+		if (t < c) c = t;
+
+		/* This is safe because the xmit_cnt can only decrease. This 
+		   would increase "t", so we might copy too little chars. */
+		/* Don't copy past the "head" of the buffer */
+		t = SERIAL_XMIT_SIZE - 1 - port->xmit_cnt;
+		if (t < c) c = t;
+
+		/* Can't copy more? break out! */
+		if (c <= 0) {
 			restore_flags(flags);
-			buf += c;
-			count -= c;
-			total += c;
+			break;
 		}
+		memcpy(port->xmit_buf + port->xmit_head, buf, c);
+		port->xmit_head = ((port->xmit_head + c) &
+		                   (SERIAL_XMIT_SIZE-1));
+		port->xmit_cnt += c;
+		restore_flags(flags);
+		buf += c;
+		count -= c;
+		total += c;
 	}
 
 	if (port->xmit_cnt && 
@@ -399,8 +349,7 @@
 		gs_dprintk (GS_DEBUG_FLUSH, "Expect to finish in %d jiffies "
 			    "(%d chars).\n", jiffies_to_transmit, charsleft); 
 
-		set_current_state (TASK_INTERRUPTIBLE);
-		schedule_timeout(jiffies_to_transmit);
+		msleep_interruptible(jiffies_to_msecs(jiffies_to_transmit));
 		if (signal_pending (current)) {
 			gs_dprintk (GS_DEBUG_FLUSH, "Signal pending. Bombing out: "); 
 			rv = -EINTR;
@@ -767,8 +716,7 @@
 
 	if (port->blocked_open) {
 		if (port->close_delay) {
-			set_current_state (TASK_INTERRUPTIBLE);
-			schedule_timeout(port->close_delay);
+			msleep_interruptible(jiffies_to_msecs(port->close_delay));
 		}
 		wake_up_interruptible(&port->open_wait);
 	}
diff -Nru a/drivers/char/hpet.c b/drivers/char/hpet.c
--- a/drivers/char/hpet.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/char/hpet.c	2004-12-24 13:36:59 -08:00
@@ -28,13 +28,13 @@
 #include <linux/wait.h>
 #include <linux/bcd.h>
 #include <linux/seq_file.h>
+#include <linux/bitops.h>
 
 #include <asm/current.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/div64.h>
 
 #include <linux/acpi.h>
@@ -76,6 +76,7 @@
 struct hpets {
 	struct hpets *hp_next;
 	struct hpet __iomem *hp_hpet;
+	struct time_interpolator *hp_interpolator;
 	unsigned long hp_period;
 	unsigned long hp_delta;
 	unsigned int hp_ntimer;
@@ -273,9 +274,9 @@
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 	addr = __pa(addr);
 
-	if (remap_page_range
-	    (vma, vma->vm_start, addr, PAGE_SIZE, vma->vm_page_prot)) {
-		printk(KERN_ERR "remap_page_range failed in hpet.c\n");
+	if (remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT,
+					PAGE_SIZE, vma->vm_page_prot)) {
+		printk(KERN_ERR "remap_pfn_range failed in hpet.c\n");
 		return -EAGAIN;
 	}
 
@@ -660,15 +661,6 @@
 	return hpet_ioctl_common(devp, cmd, arg, 1);
 }
 
-#ifdef	CONFIG_TIME_INTERPOLATION
-
-static struct time_interpolator hpet_interpolator = {
-	.source = TIME_SOURCE_MMIO64,
-	.shift = 10
-};
-
-#endif
-
 static ctl_table hpet_table[] = {
 	{
 	 .ctl_name = 1,
@@ -705,6 +697,28 @@
 
 static struct ctl_table_header *sysctl_header;
 
+static void hpet_register_interpolator(struct hpets *hpetp)
+{
+#ifdef	CONFIG_TIME_INTERPOLATION
+	struct time_interpolator *ti;
+
+	ti = kmalloc(sizeof(*ti), GFP_KERNEL);
+	if (!ti)
+		return;
+
+	memset(ti, 0, sizeof(*ti));
+	ti->source = TIME_SOURCE_MMIO64;
+	ti->shift = 10;
+	ti->addr = &hpetp->hp_hpet->hpet_mc;
+	ti->frequency = hpet_time_div(hpets->hp_period);
+	ti->drift = ti->frequency * HPET_DRIFT / 1000000;
+	ti->mask = -1;
+
+	hpetp->hp_interpolator = ti;
+	register_time_interpolator(ti);
+#endif
+}
+
 /*
  * Adjustment for when arming the timer with
  * initial conditions.  That is, main counter
@@ -712,7 +726,7 @@
  */
 #define	TICK_CALIBRATE	(1000UL)
 
-static unsigned long __init hpet_calibrate(struct hpets *hpetp)
+static unsigned long hpet_calibrate(struct hpets *hpetp)
 {
 	struct hpet_timer __iomem *timer = NULL;
 	unsigned long t, m, count, i, flags, start;
@@ -749,7 +763,7 @@
 	return (m - start) / i;
 }
 
-int __init hpet_alloc(struct hpet_data *hdp)
+int hpet_alloc(struct hpet_data *hdp)
 {
 	u64 cap, mcfg;
 	struct hpet_dev *devp;
@@ -757,7 +771,7 @@
 	struct hpets *hpetp;
 	size_t siz;
 	struct hpet __iomem *hpet;
-	static struct hpets *last __initdata = (struct hpets *)0;
+	static struct hpets *last = (struct hpets *)0;
 	unsigned long ns;
 
 	/*
@@ -810,8 +824,9 @@
 	hpetp->hp_period = (cap & HPET_COUNTER_CLK_PERIOD_MASK) >>
 	    HPET_COUNTER_CLK_PERIOD_SHIFT;
 
-	printk(KERN_INFO "hpet%d: at MMIO 0x%p, IRQ%s",
-		hpetp->hp_which, hpet, hpetp->hp_ntimer > 1 ? "s" : "");
+	printk(KERN_INFO "hpet%d: at MMIO 0x%lx, IRQ%s",
+		hpetp->hp_which, hdp->hd_phys_address,
+		hpetp->hp_ntimer > 1 ? "s" : "");
 	for (i = 0; i < hpetp->hp_ntimer; i++)
 		printk("%s %d", i > 0 ? "," : "", hdp->hd_irq[i]);
 	printk("\n");
@@ -854,11 +869,12 @@
 	}
 
 	hpetp->hp_delta = hpet_calibrate(hpetp);
+	hpet_register_interpolator(hpetp);
 
 	return 0;
 }
 
-static acpi_status __init hpet_resources(struct acpi_resource *res, void *data)
+static acpi_status hpet_resources(struct acpi_resource *res, void *data)
 {
 	struct hpet_data *hdp;
 	acpi_status status;
@@ -873,6 +889,7 @@
 		unsigned long size;
 
 		size = addr.max_address_range - addr.min_address_range + 1;
+		hdp->hd_phys_address = addr.min_address_range;
 		hdp->hd_address = ioremap(addr.min_address_range, size);
 
 		for (hpetp = hpets; hpetp; hpetp = hpetp->hp_next)
@@ -898,7 +915,7 @@
 	return AE_OK;
 }
 
-static int __init hpet_acpi_add(struct acpi_device *device)
+static int hpet_acpi_add(struct acpi_device *device)
 {
 	acpi_status result;
 	struct hpet_data data;
@@ -920,9 +937,10 @@
 	return hpet_alloc(&data);
 }
 
-static int __init hpet_acpi_remove(struct acpi_device *device, int type)
+static int hpet_acpi_remove(struct acpi_device *device, int type)
 {
-	return 0;
+	/* XXX need to unregister interpolator, dealloc mem, etc */
+	return -EINVAL;
 }
 
 static struct acpi_driver hpet_acpi_driver = {
@@ -938,37 +956,32 @@
 
 static int __init hpet_init(void)
 {
-	(void)acpi_bus_register_driver(&hpet_acpi_driver);
+	int result;
 
-	if (hpets) {
-		if (misc_register(&hpet_misc))
-			return -ENODEV;
+	result = misc_register(&hpet_misc);
+	if (result < 0)
+		return -ENODEV;
 
-		sysctl_header = register_sysctl_table(dev_root, 0);
+	sysctl_header = register_sysctl_table(dev_root, 0);
 
-#ifdef	CONFIG_TIME_INTERPOLATION
-		{
-			struct hpet *hpet;
+	result = acpi_bus_register_driver(&hpet_acpi_driver);
+	if (result < 0) {
+		if (sysctl_header)
+			unregister_sysctl_table(sysctl_header);
+		misc_deregister(&hpet_misc);
+		return result;
+	}
 
-			hpet = hpets->hp_hpet;
-			hpet_interpolator.addr = &hpets->hp_hpet->hpet_mc;
-			hpet_interpolator.frequency = hpet_time_div(hpets->hp_period);
-			hpet_interpolator.drift = hpet_interpolator.frequency *
-			    HPET_DRIFT / 1000000;
-			register_time_interpolator(&hpet_interpolator);
-		}
-#endif
-		return 0;
-	} else
-		return -ENODEV;
+	return 0;
 }
 
 static void __exit hpet_exit(void)
 {
 	acpi_bus_unregister_driver(&hpet_acpi_driver);
 
-	if (hpets)
+	if (sysctl_header)
 		unregister_sysctl_table(sysctl_header);
+	misc_deregister(&hpet_misc);
 
 	return;
 }
diff -Nru a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
--- a/drivers/char/hvc_console.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/char/hvc_console.c	2004-12-24 13:37:18 -08:00
@@ -37,6 +37,7 @@
 #include <linux/tty_flip.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
+#include <linux/delay.h>
 #include <asm/uaccess.h>
 #include <asm/hvconsole.h>
 #include <asm/vio.h>
@@ -44,7 +45,7 @@
 #define HVC_MAJOR	229
 #define HVC_MINOR	0
 
-#define TIMEOUT		((HZ + 99) / 100)
+#define TIMEOUT		(10)
 
 /*
  * Wait this long per iteration while trying to push buffered data to the
@@ -220,6 +221,7 @@
 		spin_unlock_irqrestore(&hp->lock, flags);
 		tty->driver_data = NULL;
 		kobject_put(kobjp);
+		printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc);
 	}
 	/* Force wakeup of the polling thread */
 	hvc_kick();
@@ -239,7 +241,7 @@
 
 	/*
 	 * No driver_data means that this close was issued after a failed
-	 * hvcs_open by the tty layer's release_dev() function and we can just
+	 * hvc_open by the tty layer's release_dev() function and we can just
 	 * exit cleanly because the kobject reference wasn't made.
 	 */
 	if (!tty->driver_data)
@@ -265,13 +267,6 @@
 		 */
 		tty_wait_until_sent(tty, HVC_CLOSE_WAIT);
 
-		/*
-		 * Since the line disc doesn't block writes during tty close
-		 * operations we'll set driver_data to NULL and then make sure
-		 * to check tty->driver_data for NULL in hvc_write().
-		 */
-		tty->driver_data = NULL;
-
 		if (irq != NO_IRQ)
 			free_irq(irq, hp);
 
@@ -293,7 +288,21 @@
 	int temp_open_count;
 	struct kobject *kobjp;
 
+	if (!hp)
+		return;
+
 	spin_lock_irqsave(&hp->lock, flags);
+
+	/*
+	 * The N_TTY line discipline has problems such that in a close vs
+	 * open->hangup case this can be called after the final close so prevent
+	 * that from happening for now.
+	 */
+	if (hp->count <= 0) {
+		spin_unlock_irqrestore(&hp->lock, flags);
+		return;
+	}
+
 	kobjp = &hp->kobj;
 	temp_open_count = hp->count;
 	hp->count = 0;
@@ -335,62 +344,6 @@
 		hp->do_wakeup = 1;
 }
 
-static inline int __hvc_write_user(struct hvc_struct *hp,
-				   const unsigned char *buf, int count)
-{
-	char *tbuf, *p;
-	int tbsize, rsize, written = 0;
-	unsigned long flags;
-
-	tbsize = min(count, (int)PAGE_SIZE);
-	if (!(tbuf = kmalloc(tbsize, GFP_KERNEL)))
-		return -ENOMEM;
-
-	while ((rsize = count - written) > 0) {
-		int wsize;
-		if (rsize > tbsize)
-			rsize = tbsize;
-
-		p = tbuf;
-		rsize -= copy_from_user(p, buf, rsize);
-		if (!rsize) {
-			if (written == 0)
-				written = -EFAULT;
-			break;
-		}
-		buf += rsize;
-
-		spin_lock_irqsave(&hp->lock, flags);
-
-		/* Push pending writes: make some room in buffer */
-		if (hp->n_outbuf > 0)
-			hvc_push(hp);
-
-		for (wsize = N_OUTBUF - hp->n_outbuf; rsize && wsize;
-		     wsize = N_OUTBUF - hp->n_outbuf) {
-			if (wsize > rsize)
-				wsize = rsize;
-			memcpy(hp->outbuf + hp->n_outbuf, p, wsize);
-			hp->n_outbuf += wsize;
-			hvc_push(hp);
-			rsize -= wsize;
-			p += wsize;
-			written += wsize;
-		}
-		spin_unlock_irqrestore(&hp->lock, flags);
-
-		if (rsize)
-			break;
-
-		if (count < tbsize)
-			tbsize = count;
-	}
-
-	kfree(tbuf);
-
-	return written;
-}
-
 static inline int __hvc_write_kernel(struct hvc_struct *hp,
 				   const unsigned char *buf, int count)
 {
@@ -417,8 +370,7 @@
 
 	return written;
 }
-static int hvc_write(struct tty_struct *tty, int from_user,
-		     const unsigned char *buf, int count)
+static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	struct hvc_struct *hp = tty->driver_data;
 	int written;
@@ -427,10 +379,10 @@
 	if (!hp)
 		return -EPIPE;
 
-	if (from_user)
-		written = __hvc_write_user(hp, buf, count);
-	else
-		written = __hvc_write_kernel(hp, buf, count);
+	if (hp->count <= 0)
+		return -EIO;
+
+	written = __hvc_write_kernel(hp, buf, count);
 
 	/*
 	 * Racy, but harmless, kick thread if there is still pending data.
@@ -607,7 +559,7 @@
 			if (poll_mask == 0)
 				schedule();
 			else
-				schedule_timeout(TIMEOUT);
+				msleep_interruptible(TIMEOUT);
 		}
 		__set_current_state(TASK_RUNNING);
 	} while (!kthread_should_stop());
@@ -629,7 +581,7 @@
 
 static struct vio_device_id hvc_driver_table[] __devinitdata= {
 	{"serial", "hvterm1"},
-	{ 0, }
+	{ NULL, }
 };
 MODULE_DEVICE_TABLE(vio, hvc_driver_table);
 
diff -Nru a/drivers/char/hvcs.c b/drivers/char/hvcs.c
--- a/drivers/char/hvcs.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/char/hvcs.c	2004-12-24 13:37:43 -08:00
@@ -315,7 +315,7 @@
 static irqreturn_t hvcs_handle_interrupt(int irq, void *dev_instance,
 		struct pt_regs *regs);
 
-static int hvcs_write(struct tty_struct *tty, int from_user,
+static int hvcs_write(struct tty_struct *tty,
 		const unsigned char *buf, int count);
 static int hvcs_write_room(struct tty_struct *tty);
 static int hvcs_chars_in_buffer(struct tty_struct *tty);
@@ -527,7 +527,7 @@
 
 static struct vio_device_id hvcs_driver_table[] __devinitdata= {
 	{"serial-server", "hvterm2"},
-	{ 0, }
+	{ NULL, }
 };
 MODULE_DEVICE_TABLE(vio, hvcs_driver_table);
 
@@ -1183,12 +1183,12 @@
  * tty_hangup will allow hvcs_write time to complete execution before it
  * terminates our device.
  */
-static int hvcs_write(struct tty_struct *tty, int from_user,
+static int hvcs_write(struct tty_struct *tty,
 		const unsigned char *buf, int count)
 {
 	struct hvcs_struct *hvcsd = tty->driver_data;
 	unsigned int unit_address;
-	unsigned char *charbuf;
+	const unsigned char *charbuf;
 	unsigned long flags;
 	int total_sent = 0;
 	int tosend = 0;
@@ -1208,21 +1208,7 @@
 		count = HVCS_MAX_FROM_USER;
 	}
 
-	if (!from_user)
-		charbuf = (unsigned char *)buf;
-	else {
-		charbuf = kmalloc(count, GFP_KERNEL);
-		if (!charbuf) {
-			printk(KERN_WARNING "HVCS: write -ENOMEM.\n");
-			return -ENOMEM;
-		}
-
-		if (copy_from_user(charbuf, buf, count)) {
-			kfree(charbuf);
-			printk(KERN_WARNING "HVCS: write -EFAULT.\n");
-			return -EFAULT;
-		}
-	}
+	charbuf = buf;
 
 	spin_lock_irqsave(&hvcsd->lock, flags);
 
@@ -1234,8 +1220,6 @@
 	 */
 	if (hvcsd->open_count <= 0) {
 		spin_unlock_irqrestore(&hvcsd->lock, flags);
-		if (from_user)
-			kfree(charbuf);
 		return -ENODEV;
 	}
 
@@ -1292,8 +1276,6 @@
 	}
 
 	spin_unlock_irqrestore(&hvcsd->lock, flags);
-	if (from_user)
-		kfree(charbuf);
 
 	if (result == -1)
 		return -EIO;
diff -Nru a/drivers/char/hvsi.c b/drivers/char/hvsi.c
--- a/drivers/char/hvsi.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/char/hvsi.c	2004-12-24 13:37:01 -08:00
@@ -29,11 +29,6 @@
  * the OS cannot change the speed of the port through this protocol.
  */
 
-/* TODO:
- * test FSP reset
- * add udbg support for xmon/kdb
- */
-
 #undef DEBUG
 
 #include <linux/console.h>
@@ -54,6 +49,7 @@
 #include <asm/prom.h>
 #include <asm/uaccess.h>
 #include <asm/vio.h>
+#include <asm/param.h>
 
 #define HVSI_MAJOR	229
 #define HVSI_MINOR	128
@@ -74,6 +70,7 @@
 
 struct hvsi_struct {
 	struct work_struct writer;
+	struct work_struct handshaker;
 	wait_queue_head_t emptyq; /* woken when outbuf is emptied */
 	wait_queue_head_t stateq; /* woken when HVSI state changes */
 	spinlock_t lock;
@@ -109,6 +106,7 @@
 	HVSI_WAIT_FOR_VER_QUERY,
 	HVSI_OPEN,
 	HVSI_WAIT_FOR_MCTRL_RESPONSE,
+	HVSI_FSP_DIED,
 };
 #define HVSI_CONSOLE 0x1
 
@@ -172,6 +170,13 @@
 	} u;
 } __attribute__((packed));
 
+
+
+static inline int is_console(struct hvsi_struct *hp)
+{
+	return hp->flags & HVSI_CONSOLE;
+}
+
 static inline int is_open(struct hvsi_struct *hp)
 {
 	/* if we're waiting for an mctrl then we're already open */
@@ -188,6 +193,7 @@
 		"HVSI_WAIT_FOR_VER_QUERY",
 		"HVSI_OPEN",
 		"HVSI_WAIT_FOR_MCTRL_RESPONSE",
+		"HVSI_FSP_DIED",
 	};
 	const char *name = state_names[hp->state];
 
@@ -296,14 +302,9 @@
 	return 0;
 }
 
-/*
- * we can't call tty_hangup() directly here because we need to call that
- * outside of our lock
- */
-static struct tty_struct *hvsi_recv_control(struct hvsi_struct *hp,
-		uint8_t *packet)
+static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet,
+	struct tty_struct **to_hangup, struct hvsi_struct **to_handshake)
 {
-	struct tty_struct *to_hangup = NULL;
 	struct hvsi_control *header = (struct hvsi_control *)packet;
 
 	switch (header->verb) {
@@ -313,15 +314,14 @@
 				pr_debug("hvsi%i: CD dropped\n", hp->index);
 				hp->mctrl &= TIOCM_CD;
 				if (!(hp->tty->flags & CLOCAL))
-					to_hangup = hp->tty;
+					*to_hangup = hp->tty;
 			}
 			break;
 		case VSV_CLOSE_PROTOCOL:
-			printk(KERN_DEBUG
-				"hvsi%i: service processor closed connection!\n", hp->index);
-			__set_state(hp, HVSI_CLOSED);
-			to_hangup = hp->tty;
-			hp->tty = NULL;
+			pr_debug("hvsi%i: service processor came back\n", hp->index);
+			if (hp->state != HVSI_CLOSED) {
+				*to_handshake = hp;
+			}
 			break;
 		default:
 			printk(KERN_WARNING "hvsi%i: unknown HVSI control packet: ",
@@ -329,8 +329,6 @@
 			dump_packet(packet);
 			break;
 	}
-
-	return to_hangup;
 }
 
 static void hvsi_recv_response(struct hvsi_struct *hp, uint8_t *packet)
@@ -388,8 +386,8 @@
 
 	switch (hp->state) {
 		case HVSI_WAIT_FOR_VER_QUERY:
-			__set_state(hp, HVSI_OPEN);
 			hvsi_version_respond(hp, query->seqno);
+			__set_state(hp, HVSI_OPEN);
 			break;
 		default:
 			printk(KERN_ERR "hvsi%i: unexpected query: ", hp->index);
@@ -467,17 +465,20 @@
  * incoming data).
  */
 static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
-		struct tty_struct **hangup)
+		struct tty_struct **hangup, struct hvsi_struct **handshake)
 {
 	uint8_t *packet = hp->inbuf;
 	int chunklen;
 
 	*flip = NULL;
 	*hangup = NULL;
+	*handshake = NULL;
 
 	chunklen = hvsi_read(hp, hp->inbuf_end, HVSI_MAX_READ);
-	if (chunklen == 0)
+	if (chunklen == 0) {
+		pr_debug("%s: 0-length read\n", __FUNCTION__);
 		return 0;
+	}
 
 	pr_debug("%s: got %i bytes\n", __FUNCTION__, chunklen);
 	dbg_dump_hex(hp->inbuf_end, chunklen);
@@ -509,7 +510,7 @@
 				*flip = hvsi_recv_data(hp, packet);
 				break;
 			case VS_CONTROL_PACKET_HEADER:
-				*hangup = hvsi_recv_control(hp, packet);
+				hvsi_recv_control(hp, packet, hangup, handshake);
 				break;
 			case VS_QUERY_RESPONSE_PACKET_HEADER:
 				hvsi_recv_response(hp, packet);
@@ -526,8 +527,8 @@
 
 		packet += len_packet(packet);
 
-		if (*hangup) {
-			pr_debug("%s: hangup\n", __FUNCTION__);
+		if (*hangup || *handshake) {
+			pr_debug("%s: hangup or handshake\n", __FUNCTION__);
 			/*
 			 * we need to send the hangup now before receiving any more data.
 			 * If we get "data, hangup, data", we can't deliver the second
@@ -560,16 +561,15 @@
 	struct hvsi_struct *hp = (struct hvsi_struct *)arg;
 	struct tty_struct *flip;
 	struct tty_struct *hangup;
+	struct hvsi_struct *handshake;
 	unsigned long flags;
-	irqreturn_t handled = IRQ_NONE;
 	int again = 1;
 
 	pr_debug("%s\n", __FUNCTION__);
 
 	while (again) {
 		spin_lock_irqsave(&hp->lock, flags);
-		again = hvsi_load_chunk(hp, &flip, &hangup);
-		handled = IRQ_HANDLED;
+		again = hvsi_load_chunk(hp, &flip, &hangup, &handshake);
 		spin_unlock_irqrestore(&hp->lock, flags);
 
 		/*
@@ -587,6 +587,11 @@
 		if (hangup) {
 			tty_hangup(hangup);
 		}
+
+		if (handshake) {
+			pr_debug("hvsi%i: attempting re-handshake\n", handshake->index);
+			schedule_work(&handshake->handshaker);
+		}
 	}
 
 	spin_lock_irqsave(&hp->lock, flags);
@@ -603,7 +608,7 @@
 		tty_flip_buffer_push(flip);
 	}
 
-	return handled;
+	return IRQ_HANDLED;
 }
 
 /* for boot console, before the irq handler is running */
@@ -757,6 +762,23 @@
 	return 0;
 }
 
+static void hvsi_handshaker(void *arg)
+{
+	struct hvsi_struct *hp = (struct hvsi_struct *)arg;
+
+	if (hvsi_handshake(hp) >= 0)
+		return;
+
+	printk(KERN_ERR "hvsi%i: re-handshaking failed\n", hp->index);
+	if (is_console(hp)) {
+		/*
+		 * ttys will re-attempt the handshake via hvsi_open, but
+		 * the console will not.
+		 */
+		printk(KERN_ERR "hvsi%i: lost console!\n", hp->index);
+	}
+}
+
 static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
 {
 	struct hvsi_data packet __ALIGNED__;
@@ -808,6 +830,10 @@
 	tty->driver_data = hp;
 	tty->low_latency = 1; /* avoid throttle/tty_flip_buffer_push race */
 
+	mb();
+	if (hp->state == HVSI_FSP_DIED)
+		return -EIO;
+
 	spin_lock_irqsave(&hp->lock, flags);
 	hp->tty = tty;
 	hp->count++;
@@ -815,7 +841,7 @@
 	h_vio_signal(hp->vtermno, VIO_IRQ_ENABLE);
 	spin_unlock_irqrestore(&hp->lock, flags);
 
-	if (hp->flags & HVSI_CONSOLE)
+	if (is_console(hp))
 		return 0; /* this has already been handshaked as the console */
 
 	ret = hvsi_handshake(hp);
@@ -889,7 +915,7 @@
 		hp->inbuf_end = hp->inbuf; /* discard remaining partial packets */
 
 		/* only close down connection if it is not the console */
-		if (!(hp->flags & HVSI_CONSOLE)) {
+		if (!is_console(hp)) {
 			h_vio_signal(hp->vtermno, VIO_IRQ_DISABLE); /* no more irqs */
 			__set_state(hp, HVSI_CLOSED);
 			/*
@@ -927,11 +953,17 @@
 static void hvsi_hangup(struct tty_struct *tty)
 {
 	struct hvsi_struct *hp = tty->driver_data;
+	unsigned long flags;
 
 	pr_debug("%s\n", __FUNCTION__);
 
+	spin_lock_irqsave(&hp->lock, flags);
+
 	hp->count = 0;
+	hp->n_outbuf = 0;
 	hp->tty = NULL;
+
+	spin_unlock_irqrestore(&hp->lock, flags);
 }
 
 /* called with hp->lock held */
@@ -943,12 +975,13 @@
 		return;
 
 	n = hvsi_put_chars(hp, hp->outbuf, hp->n_outbuf);
-	if (n != 0) {
-		/*
-		 * either all data was sent or there was an error, and we throw away
-		 * data on error.
-		 */
+	if (n > 0) {
+		/* success */
+		pr_debug("%s: wrote %i chars\n", __FUNCTION__, n);
 		hp->n_outbuf = 0;
+	} else if (n == -EIO) {
+		__set_state(hp, HVSI_FSP_DIED);
+		printk(KERN_ERR "hvsi%i: service processor died\n", hp->index);
 	}
 }
 
@@ -966,6 +999,19 @@
 
 	spin_lock_irqsave(&hp->lock, flags);
 
+	pr_debug("%s: %i chars in buffer\n", __FUNCTION__, hp->n_outbuf);
+
+	if (!is_open(hp)) {
+		/*
+		 * We could have a non-open connection if the service processor died
+		 * while we were busily scheduling ourselves. In that case, it could
+		 * be minutes before the service processor comes back, so only try
+		 * again once a second.
+		 */
+		schedule_delayed_work(&hp->writer, HZ);
+		goto out;
+	}
+
 	hvsi_push(hp);
 	if (hp->n_outbuf > 0)
 		schedule_delayed_work(&hp->writer, 10);
@@ -982,6 +1028,7 @@
 		wake_up_interruptible(&hp->tty->write_wait);
 	}
 
+out:
 	spin_unlock_irqrestore(&hp->lock, flags);
 }
 
@@ -999,29 +1046,19 @@
 	return hp->n_outbuf;
 }
 
-static int hvsi_write(struct tty_struct *tty, int from_user,
+static int hvsi_write(struct tty_struct *tty,
 		     const unsigned char *buf, int count)
 {
 	struct hvsi_struct *hp = tty->driver_data;
 	const char *source = buf;
-	char *kbuf = NULL;
 	unsigned long flags;
 	int total = 0;
 	int origcount = count;
 
-	if (from_user) {
-		kbuf = kmalloc(count, GFP_KERNEL);
-		if (kbuf == NULL)
-			return -ENOMEM;
-		if (copy_from_user(kbuf, buf, count)) {
-			kfree(kbuf);
-			return -EFAULT;
-		}
-		source = kbuf;
-	}
-
 	spin_lock_irqsave(&hp->lock, flags);
 
+	pr_debug("%s: %i chars in buffer\n", __FUNCTION__, hp->n_outbuf);
+
 	if (!is_open(hp)) {
 		/* we're either closing or not yet open; don't accept data */
 		pr_debug("%s: not open\n", __FUNCTION__);
@@ -1057,9 +1094,6 @@
 out:
 	spin_unlock_irqrestore(&hp->lock, flags);
 
-	if (from_user)
-		kfree(kbuf);
-
 	if (total != origcount)
 		pr_debug("%s: wanted %i, only wrote %i\n", __FUNCTION__, origcount,
 			total);
@@ -1294,6 +1328,7 @@
 
 		hp = &hvsi_ports[hvsi_count];
 		INIT_WORK(&hp->writer, hvsi_write_worker, hp);
+		INIT_WORK(&hp->handshaker, hvsi_handshaker, hp);
 		init_waitqueue_head(&hp->emptyq);
 		init_waitqueue_head(&hp->stateq);
 		hp->lock = SPIN_LOCK_UNLOCKED;
diff -Nru a/drivers/char/hw_random.c b/drivers/char/hw_random.c
--- a/drivers/char/hw_random.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/char/hw_random.c	2004-12-24 13:36:47 -08:00
@@ -191,7 +191,7 @@
 #define INTEL_RNG_ADDR_LEN			3
 
 /* token to our ioremap'd RNG register area */
-static void *rng_mem;
+static void __iomem *rng_mem;
 
 static inline u8 intel_hwstatus (void)
 {
@@ -581,7 +581,7 @@
 	DPRINTK ("ENTER\n");
 
 	/* Probe for Intel, AMD RNGs */
-	while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
+	for_each_pci_dev(pdev) {
 		ent = pci_match_device (rng_pci_tbl, pdev);
 		if (ent) {
 			rng_ops = &rng_vendor_ops[ent->driver_data];
diff -Nru a/drivers/char/i8k.c b/drivers/char/i8k.c
--- a/drivers/char/i8k.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/char/i8k.c	2004-12-24 13:36:31 -08:00
@@ -65,18 +65,20 @@
 static char bios_version [4]  = "?";
 static char serial_number[16] = "?";
 
-static int force = 0;
-static int restricted = 0;
-static int power_status = 0;
-
 MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)");
 MODULE_DESCRIPTION("Driver for accessing SMM BIOS on Dell laptops");
 MODULE_LICENSE("GPL");
-MODULE_PARM(force, "i");
-MODULE_PARM(restricted, "i");
-MODULE_PARM(power_status, "i");
+
+static int force;
+module_param(force, bool, 0);
 MODULE_PARM_DESC(force, "Force loading without checking for supported models");
+
+static int restricted;
+module_param(restricted, bool, 0);
 MODULE_PARM_DESC(restricted, "Allow fan control if SYS_ADMIN capability set");
+
+static int power_status;
+module_param(power_status, bool, 0600);
 MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k");
 
 static ssize_t i8k_read(struct file *, char __user *, size_t, loff_t *);
diff -Nru a/drivers/char/ip2.c b/drivers/char/ip2.c
--- a/drivers/char/ip2.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/char/ip2.c	2004-12-24 13:36:49 -08:00
@@ -38,11 +38,11 @@
 
 MODULE_AUTHOR("Doug McNash");
 MODULE_DESCRIPTION("Computone IntelliPort Plus Driver");
-MODULE_PARM(irq,"1-"__MODULE_STRING(IP2_MAX_BOARDS) "i");
+module_param_array(irq, int, NULL, 0);
 MODULE_PARM_DESC(irq,"Interrupts for IntelliPort Cards");
-MODULE_PARM(io,"1-"__MODULE_STRING(IP2_MAX_BOARDS) "i");
+module_param_array(io, int, NULL, 0);
 MODULE_PARM_DESC(io,"I/O ports for IntelliPort Cards");
-MODULE_PARM(poll_only,"1i");
+module_param(poll_only, bool, 0);
 MODULE_PARM_DESC(poll_only,"Do not use card interrupts");
 
 
diff -Nru a/drivers/char/ip2main.c b/drivers/char/ip2main.c
--- a/drivers/char/ip2main.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/char/ip2main.c	2004-12-24 13:37:43 -08:00
@@ -112,11 +112,11 @@
 #include <linux/cdk.h>
 #include <linux/comstats.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 
 #include <linux/vmalloc.h>
 #include <linux/init.h>
@@ -1632,8 +1632,7 @@
 
 	if (pCh->wopen) {
 		if (pCh->ClosingDelay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(pCh->ClosingDelay);
+			msleep_interruptible(jiffies_to_msecs(pCh->ClosingDelay));
 		}
 		wake_up_interruptible(&pCh->open_wait);
 	}
diff -Nru a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
--- a/drivers/char/ipmi/ipmi_si_intf.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/char/ipmi/ipmi_si_intf.c	2004-12-24 13:36:18 -08:00
@@ -923,34 +923,34 @@
 		 " interface separated by commas.  The types are 'kcs',"
 		 " 'smic', and 'bt'.  For example si_type=kcs,bt will set"
 		 " the first interface to kcs and the second to bt");
-module_param_array(addrs, long, num_addrs, 0);
+module_param_array(addrs, long, &num_addrs, 0);
 MODULE_PARM_DESC(addrs, "Sets the memory address of each interface, the"
 		 " addresses separated by commas.  Only use if an interface"
 		 " is in memory.  Otherwise, set it to zero or leave"
 		 " it blank.");
-module_param_array(ports, int, num_ports, 0);
+module_param_array(ports, int, &num_ports, 0);
 MODULE_PARM_DESC(ports, "Sets the port address of each interface, the"
 		 " addresses separated by commas.  Only use if an interface"
 		 " is a port.  Otherwise, set it to zero or leave"
 		 " it blank.");
-module_param_array(irqs, int, num_irqs, 0);
+module_param_array(irqs, int, &num_irqs, 0);
 MODULE_PARM_DESC(irqs, "Sets the interrupt of each interface, the"
 		 " addresses separated by commas.  Only use if an interface"
 		 " has an interrupt.  Otherwise, set it to zero or leave"
 		 " it blank.");
-module_param_array(regspacings, int, num_regspacings, 0);
+module_param_array(regspacings, int, &num_regspacings, 0);
 MODULE_PARM_DESC(regspacings, "The number of bytes between the start address"
 		 " and each successive register used by the interface.  For"
 		 " instance, if the start address is 0xca2 and the spacing"
 		 " is 2, then the second address is at 0xca4.  Defaults"
 		 " to 1.");
-module_param_array(regsizes, int, num_regsizes, 0);
+module_param_array(regsizes, int, &num_regsizes, 0);
 MODULE_PARM_DESC(regsizes, "The size of the specific IPMI register in bytes."
 		 " This should generally be 1, 2, 4, or 8 for an 8-bit,"
 		 " 16-bit, 32-bit, or 64-bit register.  Use this if you"
 		 " the 8-bit IPMI register has to be read from a larger"
 		 " register.");
-module_param_array(regshifts, int, num_regshifts, 0);
+module_param_array(regshifts, int, &num_regshifts, 0);
 MODULE_PARM_DESC(regshifts, "The amount to shift the data read from the."
 		 " IPMI register, in bits.  For instance, if the data"
 		 " is read from a 32-bit word and the IPMI data is in"
@@ -1370,7 +1370,7 @@
 	status = acpi_install_gpe_handler(NULL,
 					  info->irq,
 					  ACPI_GPE_LEVEL_TRIGGERED,
-					  ipmi_acpi_gpe,
+					  &ipmi_acpi_gpe,
 					  info);
 	if (status != AE_OK) {
 		printk(KERN_WARNING
@@ -1390,7 +1390,7 @@
 	if (!info->irq)
 		return;
 
-	acpi_remove_gpe_handler(NULL, info->irq, ipmi_acpi_gpe);
+	acpi_remove_gpe_handler(NULL, info->irq, &ipmi_acpi_gpe);
 }
 
 /*
@@ -1777,10 +1777,10 @@
 
 	pci_smic_checked = 1;
 
-	if ((pci_dev = pci_find_device(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID,
+	if ((pci_dev = pci_get_device(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID,
 				       NULL)))
 		;
-	else if ((pci_dev = pci_find_class(PCI_ERMC_CLASSCODE, NULL)) &&
+	else if ((pci_dev = pci_get_class(PCI_ERMC_CLASSCODE, NULL)) &&
 		 pci_dev->subsystem_vendor == PCI_HP_VENDOR_ID)
 		fe_rmc = 1;
 	else
@@ -1789,6 +1789,7 @@
 	error = pci_read_config_word(pci_dev, PCI_MMC_ADDR_CW, &base_addr);
 	if (error)
 	{
+		pci_dev_put(pci_dev);
 		printk(KERN_ERR
 		       "ipmi_si: pci_read_config_word() failed (%d).\n",
 		       error);
@@ -1798,6 +1799,7 @@
 	/* Bit 0: 1 specifies programmed I/O, 0 specifies memory mapped I/O */
 	if (!(base_addr & 0x0001))
 	{
+		pci_dev_put(pci_dev);
 		printk(KERN_ERR
 		       "ipmi_si: memory mapped I/O not supported for PCI"
 		       " smic.\n");
@@ -1809,11 +1811,14 @@
 		/* Data register starts at base address + 1 in eRMC */
 		++base_addr;
 
-	if (!is_new_interface(-1, IPMI_IO_ADDR_SPACE, base_addr))
-	    return -ENODEV;
+	if (!is_new_interface(-1, IPMI_IO_ADDR_SPACE, base_addr)) {
+		pci_dev_put(pci_dev);
+		return -ENODEV;
+	}
 
 	info = kmalloc(sizeof(*info), GFP_KERNEL);
 	if (!info) {
+		pci_dev_put(pci_dev);
 		printk(KERN_ERR "ipmi_si: Could not allocate SI data (5)\n");
 		return -ENOMEM;
 	}
@@ -1836,6 +1841,7 @@
 	printk("ipmi_si: Found PCI SMIC at I/O address 0x%lx\n",
 		(long unsigned int) base_addr);
 
+	pci_dev_put(pci_dev);
 	return 0;
 }
 #endif /* CONFIG_PCI */
@@ -2283,6 +2289,7 @@
 	   interface is in a clean state. */
 	while ((to_clean->curr_msg) || (to_clean->si_state != SI_NORMAL)) {
 		poll(to_clean);
+		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
 	}
 
diff -Nru a/drivers/char/isicom.c b/drivers/char/isicom.c
--- a/drivers/char/isicom.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/char/isicom.c	2004-12-24 13:36:17 -08:00
@@ -1124,11 +1124,10 @@
 	port->tty = NULL;
 	if (port->blocked_open) {
 		if (port->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
 #ifdef ISICOM_DEBUG			
 			printk(KERN_DEBUG "ISICOM: scheduling until time out.\n");
 #endif			
-			schedule_timeout(port->close_delay);
+			msleep_interruptible(jiffies_to_msecs(port->close_delay));
 		}
 		wake_up_interruptible(&port->open_wait);
 	}	
@@ -1141,7 +1140,7 @@
 }
 
 /* write et all */
-static int isicom_write(struct tty_struct * tty, int from_user,
+static int isicom_write(struct tty_struct * tty,
 			const unsigned char * buf, int count)
 {
 	struct isi_port * port = (struct isi_port *) tty->driver_data;
@@ -1156,8 +1155,6 @@
 	
 	if (!tty || !port->xmit_buf || !tmp_buf)
 		return 0;
-	if (from_user)
-		down(&tmp_buf_sem); /* acquire xclusive access to tmp_buf */
 		
 	save_flags(flags);
 	while(1) {	
@@ -1167,24 +1164,7 @@
 		if (cnt <= 0) 
 			break;
 		
-		if (from_user) {
-			/* the following may block for paging... hence 
-			   enabling interrupts but tx routine may have 
-			   created more space in xmit_buf when the ctrl 
-			   gets back here  */
-			sti(); 
-			if (copy_from_user(tmp_buf, buf, cnt)) {
-				up(&tmp_buf_sem);
-				restore_flags(flags);
-				return -EFAULT;
-			}
-			cli();
-			cnt = min_t(int, cnt, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-						  SERIAL_XMIT_SIZE - port->xmit_head));
-			memcpy(port->xmit_buf + port->xmit_head, tmp_buf, cnt);
-		}	
-		else
-			memcpy(port->xmit_buf + port->xmit_head, buf, cnt);
+		memcpy(port->xmit_buf + port->xmit_head, buf, cnt);
 		port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE - 1);
 		port->xmit_cnt += cnt;
 		restore_flags(flags);
@@ -1192,8 +1172,6 @@
 		count -= cnt;
 		total += cnt;
 	}		
-	if (from_user)
-		up(&tmp_buf_sem);
 	if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped)
 		port->status |= ISI_TXOK;
 	restore_flags(flags);
@@ -1795,9 +1773,9 @@
 MODULE_AUTHOR("MultiTech");
 MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech");
 MODULE_LICENSE("GPL");
-MODULE_PARM(io, "1-4i");
+module_param_array(io, int, NULL, 0);
 MODULE_PARM_DESC(io, "I/O ports for the cards");
-MODULE_PARM(irq, "1-4i");
+module_param_array(irq, int, NULL, 0);
 MODULE_PARM_DESC(irq, "Interrupts for the cards");
 
 int init_module(void)
diff -Nru a/drivers/char/istallion.c b/drivers/char/istallion.c
--- a/drivers/char/istallion.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/char/istallion.c	2004-12-24 13:37:00 -08:00
@@ -660,7 +660,7 @@
 int		stli_init(void);
 static int	stli_open(struct tty_struct *tty, struct file *filp);
 static void	stli_close(struct tty_struct *tty, struct file *filp);
-static int	stli_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count);
+static int	stli_write(struct tty_struct *tty, const unsigned char *buf, int count);
 static void	stli_putchar(struct tty_struct *tty, unsigned char ch);
 static void	stli_flushchars(struct tty_struct *tty);
 static int	stli_writeroom(struct tty_struct *tty);
@@ -691,7 +691,6 @@
 static int	stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
 static int	stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp);
 static void	stli_dohangup(void *arg);
-static void	stli_delay(int len);
 static int	stli_setport(stliport_t *portp);
 static int	stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
 static void	stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
@@ -1180,7 +1179,7 @@
 
 	if (portp->openwaitcnt) {
 		if (portp->close_delay)
-			stli_delay(portp->close_delay);
+			msleep_interruptible(jiffies_to_msecs(portp->close_delay));
 		wake_up_interruptible(&portp->open_wait);
 	}
 
@@ -1478,25 +1477,6 @@
 /*****************************************************************************/
 
 /*
- *	Wait for a specified delay period, this is not a busy-loop. It will
- *	give up the processor while waiting. Unfortunately this has some
- *	rather intimate knowledge of the process management stuff.
- */
-
-static void stli_delay(int len)
-{
-#ifdef DEBUG
-	printk("stli_delay(len=%d)\n", len);
-#endif
-	if (len > 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(len);
-	}
-}
-
-/*****************************************************************************/
-
-/*
  *	Possibly need to wait for carrier (DCD signal) to come high. Say
  *	maybe because if we are clocal then we don't need to wait...
  */
@@ -1563,7 +1543,7 @@
  *	service bits for this port.
  */
 
-static int stli_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
+static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	volatile cdkasy_t	*ap;
 	volatile cdkhdr_t	*hdrp;
@@ -1575,8 +1555,8 @@
 	unsigned long		flags;
 
 #ifdef DEBUG
-	printk("stli_write(tty=%x,from_user=%d,buf=%x,count=%d)\n",
-		(int) tty, from_user, (int) buf, count);
+	printk("stli_write(tty=%x,buf=%x,count=%d)\n",
+		(int) tty, (int) buf, count);
 #endif
 
 	if ((tty == (struct tty_struct *) NULL) ||
@@ -1595,38 +1575,6 @@
 	chbuf = (unsigned char *) buf;
 
 /*
- *	If copying direct from user space we need to be able to handle page
- *	faults while we are copying. To do this copy as much as we can now
- *	into a kernel buffer. From there we copy it into shared memory. The
- *	big problem is that we do not want shared memory enabled when we are
- *	sleeping (other boards may be serviced while asleep). Something else
- *	to note here is the reading of the tail twice. Since the boards
- *	shared memory can be on an 8-bit bus then we need to be very careful
- *	reading 16 bit quantities - since both the board (slave) and host
- *	could be writing and reading at the same time.
- */
-	if (from_user) {
-		save_flags(flags);
-		cli();
-		EBRDENABLE(brdp);
-		ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
-		head = (unsigned int) ap->txq.head;
-		tail = (unsigned int) ap->txq.tail;
-		if (tail != ((unsigned int) ap->txq.tail))
-			tail = (unsigned int) ap->txq.tail;
-		len = (head >= tail) ? (portp->txsize - (head - tail) - 1) :
-			(tail - head - 1);
-		count = MIN(len, count);
-		EBRDDISABLE(brdp);
-		restore_flags(flags);
-
-		down(&stli_tmpwritesem);
-		if (copy_from_user(stli_tmpwritebuf, chbuf, count)) 
-			return -EFAULT;
-		chbuf = &stli_tmpwritebuf[0];
-	}
-
-/*
  *	All data is now local, shove as much as possible into shared memory.
  */
 	save_flags(flags);
@@ -1676,8 +1624,6 @@
 	set_bit(ST_TXBUSY, &portp->state);
 	EBRDDISABLE(brdp);
 
-	if (from_user)
-		up(&stli_tmpwritesem);
 	restore_flags(flags);
 
 	return(count);
@@ -2504,7 +2450,7 @@
 	while (test_bit(ST_TXBUSY, &portp->state)) {
 		if (signal_pending(current))
 			break;
-		stli_delay(2);
+		msleep_interruptible(20);
 		if (time_after_eq(jiffies, tend))
 			break;
 	}
diff -Nru a/drivers/char/lcd.c b/drivers/char/lcd.c
--- a/drivers/char/lcd.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/char/lcd.c	2004-12-24 13:36:48 -08:00
@@ -24,6 +24,7 @@
 #include <linux/mc146818rtc.h>
 #include <linux/netdevice.h>
 #include <linux/sched.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -583,8 +584,7 @@
 	lcd_waiters++;
 	while (((buttons_now = (long) button_pressed()) == 0) &&
 	       !(signal_pending(current))) {
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(2 * HZ);
+		msleep_interruptible(2000);
 	}
 	lcd_waiters--;
 
diff -Nru a/drivers/char/lp.c b/drivers/char/lp.c
--- a/drivers/char/lp.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/char/lp.c	2004-12-24 13:36:17 -08:00
@@ -749,8 +749,8 @@
 static char *parport[LP_NO] = { NULL,  };
 static int reset = 0;
 
-MODULE_PARM(parport, "1-" __MODULE_STRING(LP_NO) "s");
-MODULE_PARM(reset, "i");
+module_param_array(parport, charp, NULL, 0);
+module_param(reset, bool, 0);
 
 #ifndef MODULE
 static int __init lp_setup (char *str)
diff -Nru a/drivers/char/mem.c b/drivers/char/mem.c
--- a/drivers/char/mem.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/char/mem.c	2004-12-24 13:36:55 -08:00
@@ -192,26 +192,21 @@
 
 static int mmap_mem(struct file * file, struct vm_area_struct * vma)
 {
+#ifdef pgprot_noncached
 	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
 	int uncached;
 
 	uncached = uncached_access(file, offset);
-#ifdef pgprot_noncached
 	if (uncached)
 		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 #endif
 
-	/* Don't try to swap out physical pages.. */
-	vma->vm_flags |= VM_RESERVED;
-
-	/*
-	 * Don't dump addresses that are not real memory to a core file.
-	 */
-	if (uncached)
-		vma->vm_flags |= VM_IO;
-
-	if (remap_page_range(vma, vma->vm_start, offset, vma->vm_end-vma->vm_start,
-			     vma->vm_page_prot))
+	/* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */
+	if (remap_pfn_range(vma,
+			    vma->vm_start,
+			    vma->vm_pgoff,
+			    vma->vm_end-vma->vm_start,
+			    vma->vm_page_prot))
 		return -EAGAIN;
 	return 0;
 }
diff -Nru a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
--- a/drivers/char/mmtimer.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/char/mmtimer.c	2004-12-24 13:37:02 -08:00
@@ -13,6 +13,9 @@
  *
  * 11/01/01 - jbarnes - initial revision
  * 9/10/04 - Christoph Lameter - remove interrupt support for kernel inclusion
+ * 10/1/04 - Christoph Lameter - provide posix clock CLOCK_SGI_CYCLE
+ * 10/13/04 - Christoph Lameter, Dimitri Sivanich - provide timer interrupt
+ *		support via the posix timer interface
  */
 
 #include <linux/types.h>
@@ -25,21 +28,35 @@
 #include <linux/devfs_fs_kernel.h>
 #include <linux/mmtimer.h>
 #include <linux/miscdevice.h>
+#include <linux/posix-timers.h>
+#include <linux/interrupt.h>
+
 #include <asm/uaccess.h>
 #include <asm/sn/addrs.h>
-#include <asm/sn/clksupport.h>
+#include <asm/sn/intr.h>
+#include <asm/sn/shub_mmr.h>
+#include <asm/sn/nodepda.h>
+
+/* This is ugly and jbarnes has promised me to fix this later */
+#include "../../arch/ia64/sn/include/shubio.h"
 
 MODULE_AUTHOR("Jesse Barnes <jbarnes@sgi.com>");
-MODULE_DESCRIPTION("Multimedia timer support");
+MODULE_DESCRIPTION("SGI Altix RTC Timer");
 MODULE_LICENSE("GPL");
 
 /* name of the device, usually in /dev */
 #define MMTIMER_NAME "mmtimer"
-#define MMTIMER_DESC "IA-PC Multimedia Timer"
-#define MMTIMER_VERSION "1.0"
+#define MMTIMER_DESC "SGI Altix RTC Timer"
+#define MMTIMER_VERSION "2.0"
 
 #define RTC_BITS 55 /* 55 bits for this implementation */
 
+extern unsigned long sn_rtc_cycles_per_second;
+
+#define RTC_COUNTER_ADDR        ((long *)LOCAL_MMR_ADDR(SH_RTC))
+
+#define rtc_time()              (*RTC_COUNTER_ADDR)
+
 static int mmtimer_ioctl(struct inode *inode, struct file *file,
 			 unsigned int cmd, unsigned long arg);
 static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma);
@@ -55,6 +72,180 @@
 	.ioctl =	mmtimer_ioctl,
 };
 
+/*
+ * Comparators and their associated info.  Shub has
+ * three comparison registers.
+ */
+
+/*
+ * We only have comparison registers RTC1-4 currently available per
+ * node.  RTC0 is used by SAL.
+ */
+#define NUM_COMPARATORS 3
+/* Check for an RTC interrupt pending */
+static int inline mmtimer_int_pending(int comparator)
+{
+	if (HUB_L((unsigned long *)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED)) &
+			SH_EVENT_OCCURRED_RTC1_INT_MASK << comparator)
+		return 1;
+	else
+		return 0;
+}
+/* Clear the RTC interrupt pending bit */
+static void inline mmtimer_clr_int_pending(int comparator)
+{
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED_ALIAS),
+		SH_EVENT_OCCURRED_RTC1_INT_MASK << comparator);
+}
+
+/* Setup timer on comparator RTC1 */
+static void inline mmtimer_setup_int_0(u64 expires)
+{
+	u64 val;
+
+	/* Disable interrupt */
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC1_INT_ENABLE), 0UL);
+
+	/* Initialize comparator value */
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_INT_CMPB), -1L);
+
+	/* Clear pending bit */
+	mmtimer_clr_int_pending(0);
+
+	val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC1_INT_CONFIG_IDX_SHFT) |
+		((u64)cpu_physical_id(smp_processor_id()) <<
+			SH_RTC1_INT_CONFIG_PID_SHFT);
+
+	/* Set configuration */
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC1_INT_CONFIG), val);
+
+	/* Enable RTC interrupts */
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC1_INT_ENABLE), 1UL);
+
+	/* Initialize comparator value */
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_INT_CMPB), expires);
+
+
+}
+
+/* Setup timer on comparator RTC2 */
+static void inline mmtimer_setup_int_1(u64 expires)
+{
+	u64 val;
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC2_INT_ENABLE), 0UL);
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_INT_CMPC), -1L);
+
+	mmtimer_clr_int_pending(1);
+
+	val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC2_INT_CONFIG_IDX_SHFT) |
+		((u64)cpu_physical_id(smp_processor_id()) <<
+			SH_RTC2_INT_CONFIG_PID_SHFT);
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC2_INT_CONFIG), val);
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC2_INT_ENABLE), 1UL);
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_INT_CMPC), expires);
+}
+
+/* Setup timer on comparator RTC3 */
+static void inline mmtimer_setup_int_2(u64 expires)
+{
+	u64 val;
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC3_INT_ENABLE), 0UL);
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_INT_CMPD), -1L);
+
+	mmtimer_clr_int_pending(2);
+
+	val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC3_INT_CONFIG_IDX_SHFT) |
+		((u64)cpu_physical_id(smp_processor_id()) <<
+			SH_RTC3_INT_CONFIG_PID_SHFT);
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC3_INT_CONFIG), val);
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC3_INT_ENABLE), 1UL);
+
+	HUB_S((u64 *)LOCAL_MMR_ADDR(SH_INT_CMPD), expires);
+}
+
+/*
+ * This function must be called with interrupts disabled and preemption off
+ * in order to insure that the setup succeeds in a deterministic time frame.
+ * It will check if the interrupt setup succeeded.
+ * mmtimer_setup will return the cycles that we were too late if the
+ * initialization failed.
+ */
+static int inline mmtimer_setup(int comparator, unsigned long expires)
+{
+
+	long diff;
+
+	switch (comparator) {
+	case 0:
+		mmtimer_setup_int_0(expires);
+		break;
+	case 1:
+		mmtimer_setup_int_1(expires);
+		break;
+	case 2:
+		mmtimer_setup_int_2(expires);
+		break;
+	}
+	/* We might've missed our expiration time */
+        diff = rtc_time() - expires;
+	if (diff > 0) {
+		if (mmtimer_int_pending(comparator)) {
+			/* We'll get an interrupt for this once we're done */
+                        return 0;
+		}
+		/* Looks like we missed it */
+		return diff;
+        }
+
+	return 0;
+}
+
+static int inline mmtimer_disable_int(long nasid, int comparator)
+{
+	switch (comparator) {
+	case 0:
+		nasid == -1 ? HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC1_INT_ENABLE),
+			0UL) : REMOTE_HUB_S(nasid, SH_RTC1_INT_ENABLE, 0UL);
+		break;
+	case 1:
+		nasid == -1 ? HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC2_INT_ENABLE),
+			0UL) : REMOTE_HUB_S(nasid, SH_RTC2_INT_ENABLE, 0UL);
+		break;
+	case 2:
+		nasid == -1 ? HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC3_INT_ENABLE),
+			0UL) : REMOTE_HUB_S(nasid, SH_RTC3_INT_ENABLE, 0UL);
+		break;
+	default:
+		return -EFAULT;
+	}
+	return 0;
+}
+
+#define TIMER_OFF 0xbadcabLL
+
+/* There is one of these for each comparator */
+typedef struct mmtimer {
+	spinlock_t lock ____cacheline_aligned;
+	struct k_itimer *timer;
+	int i;
+	int cpu;
+	struct tasklet_struct tasklet;
+} mmtimer_t;
+
+/*
+ * Total number of comparators is comparators/node * MAX nodes/running kernel
+ */
+static mmtimer_t timers[NUM_COMPARATORS*MAX_COMPACT_NODES];
+
 /**
  * mmtimer_ioctl - ioctl interface for /dev/mmtimer
  * @inode: inode of the device
@@ -100,13 +291,13 @@
 		break;
 
 	case MMTIMER_GETRES: /* resolution of the clock in 10^-15 s */
-		if(copy_to_user((unsigned long *)arg, &mmtimer_femtoperiod,
-				sizeof(unsigned long)))
+		if(copy_to_user((unsigned long __user *)arg,
+				&mmtimer_femtoperiod, sizeof(unsigned long)))
 			return -EFAULT;
 		break;
 
 	case MMTIMER_GETFREQ: /* frequency in Hz */
-		if(copy_to_user((unsigned long *)arg,
+		if(copy_to_user((unsigned long __user *)arg,
 				&sn_rtc_cycles_per_second,
 				sizeof(unsigned long)))
 			return -EFAULT;
@@ -122,8 +313,8 @@
 		break;
 
 	case MMTIMER_GETCOUNTER:
-		if(copy_to_user((unsigned long *)arg, RTC_COUNTER_ADDR,
-				sizeof(unsigned long)))
+		if(copy_to_user((unsigned long __user *)arg,
+				RTC_COUNTER_ADDR, sizeof(unsigned long)))
 			return -EFAULT;
 		break;
 	default:
@@ -139,7 +330,7 @@
  * @file: file structure for the device
  * @vma: VMA to map the registers into
  *
- * Calls remap_page_range() to map the clock's registers into
+ * Calls remap_pfn_range() to map the clock's registers into
  * the calling process' address space.
  */
 static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma)
@@ -162,9 +353,9 @@
 	mmtimer_addr &= ~(PAGE_SIZE - 1);
 	mmtimer_addr &= 0xfffffffffffffffUL;
 
-	if (remap_page_range(vma, vma->vm_start, mmtimer_addr, PAGE_SIZE,
-			     vma->vm_page_prot)) {
-		printk(KERN_ERR "remap_page_range failed in mmtimer.c\n");
+	if (remap_pfn_range(vma, vma->vm_start, mmtimer_addr >> PAGE_SHIFT,
+					PAGE_SIZE, vma->vm_page_prot)) {
+		printk(KERN_ERR "remap_pfn_range failed in mmtimer.c\n");
 		return -EAGAIN;
 	}
 
@@ -177,6 +368,313 @@
 	&mmtimer_fops
 };
 
+static struct timespec sgi_clock_offset;
+static int sgi_clock_period;
+
+/*
+ * Posix Timer Interface
+ */
+
+static struct timespec sgi_clock_offset;
+static int sgi_clock_period;
+
+static int sgi_clock_get(struct timespec *tp)
+{
+	u64 nsec;
+
+	nsec = rtc_time() * sgi_clock_period
+			+ sgi_clock_offset.tv_nsec;
+	tp->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &tp->tv_nsec)
+			+ sgi_clock_offset.tv_sec;
+	return 0;
+};
+
+static int sgi_clock_set(struct timespec *tp)
+{
+
+	u64 nsec;
+	u64 rem;
+
+	nsec = rtc_time() * sgi_clock_period;
+
+	sgi_clock_offset.tv_sec = tp->tv_sec - div_long_long_rem(nsec, NSEC_PER_SEC, &rem);
+
+	if (rem <= tp->tv_nsec)
+		sgi_clock_offset.tv_nsec = tp->tv_sec - rem;
+	else {
+		sgi_clock_offset.tv_nsec = tp->tv_sec + NSEC_PER_SEC - rem;
+		sgi_clock_offset.tv_sec--;
+	}
+	return 0;
+}
+
+/*
+ * Schedule the next periodic interrupt. This function will attempt
+ * to schedule a periodic interrupt later if necessary. If the scheduling
+ * of an interrupt fails then the time to skip is lengthened
+ * exponentially in order to ensure that the next interrupt
+ * can be properly scheduled..
+ */
+static int inline reschedule_periodic_timer(mmtimer_t *x)
+{
+	int n;
+	struct k_itimer *t = x->timer;
+
+	t->it_timer.magic = x->i;
+	t->it_overrun--;
+
+	n = 0;
+	do {
+
+		t->it_timer.expires += t->it_incr << n;
+		t->it_overrun += 1 << n;
+		n++;
+		if (n > 20)
+			return 1;
+
+	} while (mmtimer_setup(x->i, t->it_timer.expires));
+
+	return 0;
+}
+
+/**
+ * mmtimer_interrupt - timer interrupt handler
+ * @irq: irq received
+ * @dev_id: device the irq came from
+ * @regs: register state upon receipt of the interrupt
+ *
+ * Called when one of the comarators matches the counter, This
+ * routine will send signals to processes that have requested
+ * them.
+ *
+ * This interrupt is run in an interrupt context
+ * by the SHUB. It is therefore safe to locally access SHub
+ * registers.
+ */
+static irqreturn_t
+mmtimer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	int i;
+	mmtimer_t *base = timers + cpuid_to_cnodeid(smp_processor_id()) *
+						NUM_COMPARATORS;
+	unsigned long expires = 0;
+	int result = IRQ_NONE;
+
+	/*
+	 * Do this once for each comparison register
+	 */
+	for (i = 0; i < NUM_COMPARATORS; i++) {
+		/* Make sure this doesn't get reused before tasklet_sched */
+		spin_lock(&base[i].lock);
+		if (base[i].cpu == smp_processor_id()) {
+			if (base[i].timer)
+				expires = base[i].timer->it_timer.expires;
+			/* expires test won't work with shared irqs */
+			if ((mmtimer_int_pending(i) > 0) ||
+				(expires && (expires < rtc_time()))) {
+				mmtimer_clr_int_pending(i);
+				tasklet_schedule(&base[i].tasklet);
+				result = IRQ_HANDLED;
+			}
+		}
+		spin_unlock(&base[i].lock);
+		expires = 0;
+	}
+	return result;
+}
+
+void mmtimer_tasklet(unsigned long data) {
+	mmtimer_t *x = (mmtimer_t *)data;
+	struct k_itimer *t = x->timer;
+	unsigned long flags;
+
+	if (t == NULL)
+		return;
+
+	/* Send signal and deal with periodic signals */
+	spin_lock_irqsave(&t->it_lock, flags);
+	spin_lock(&x->lock);
+	/* If timer was deleted between interrupt and here, leave */
+	if (t != x->timer)
+		goto out;
+	t->it_overrun = 0;
+
+	if (tasklist_lock.write_lock || posix_timer_event(t, 0) != 0) {
+
+		// printk(KERN_WARNING "mmtimer: cannot deliver signal.\n");
+
+		t->it_overrun++;
+	}
+	if(t->it_incr) {
+		/* Periodic timer */
+		if (reschedule_periodic_timer(x)) {
+			printk(KERN_WARNING "mmtimer: unable to reschedule\n");
+			x->timer = NULL;
+		}
+	} else {
+		/* Ensure we don't false trigger in mmtimer_interrupt */
+		t->it_timer.expires = 0;
+	}
+	t->it_overrun_last = t->it_overrun;
+out:
+	spin_unlock(&x->lock);
+	spin_unlock_irqrestore(&t->it_lock, flags);
+}
+
+static int sgi_timer_create(struct k_itimer *timer)
+{
+	/* Insure that a newly created timer is off */
+	timer->it_timer.magic = TIMER_OFF;
+	return 0;
+}
+
+/* This does not really delete a timer. It just insures
+ * that the timer is not active
+ *
+ * Assumption: it_lock is already held with irq's disabled
+ */
+static int sgi_timer_del(struct k_itimer *timr)
+{
+	int i = timr->it_timer.magic;
+	cnodeid_t nodeid = timr->it_timer.data;
+	mmtimer_t *t = timers + nodeid * NUM_COMPARATORS +i;
+	unsigned long irqflags;
+
+	if (i != TIMER_OFF) {
+		spin_lock_irqsave(&t->lock, irqflags);
+		mmtimer_disable_int(cnodeid_to_nasid(nodeid),i);
+		t->timer = NULL;
+		timr->it_timer.magic = TIMER_OFF;
+		timr->it_timer.expires = 0;
+		spin_unlock_irqrestore(&t->lock, irqflags);
+	}
+	return 0;
+}
+
+#define timespec_to_ns(x) ((x).tv_nsec + (x).tv_sec * NSEC_PER_SEC)
+#define ns_to_timespec(ts, nsec) (ts).tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &(ts).tv_nsec)
+
+/* Assumption: it_lock is already held with irq's disabled */
+static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
+{
+
+	if (timr->it_timer.magic == TIMER_OFF) {
+		cur_setting->it_interval.tv_nsec = 0;
+		cur_setting->it_interval.tv_sec = 0;
+		cur_setting->it_value.tv_nsec = 0;
+		cur_setting->it_value.tv_sec =0;
+		return;
+	}
+
+	ns_to_timespec(cur_setting->it_interval, timr->it_incr * sgi_clock_period);
+	ns_to_timespec(cur_setting->it_value, (timr->it_timer.expires - rtc_time())* sgi_clock_period);
+	return;
+}
+
+
+static int sgi_timer_set(struct k_itimer *timr, int flags,
+	struct itimerspec * new_setting,
+	struct itimerspec * old_setting)
+{
+
+	int i;
+	unsigned long when, period, irqflags;
+	int err = 0;
+	cnodeid_t nodeid;
+	mmtimer_t *base;
+
+	if (old_setting)
+		sgi_timer_get(timr, old_setting);
+
+	sgi_timer_del(timr);
+	when = timespec_to_ns(new_setting->it_value);
+	period = timespec_to_ns(new_setting->it_interval);
+
+	if (when == 0)
+		/* Clear timer */
+		return 0;
+
+	if (flags & TIMER_ABSTIME) {
+		struct timespec n;
+
+		getnstimeofday(&n);
+		when -= timespec_to_ns(n);
+	}
+
+	/*
+	 * Convert to sgi clock period. Need to keep rtc_time() as near as possible
+	 * to getnstimeofday() in order to be as faithful as possible to the time
+	 * specified.
+	 */
+	when = (when + sgi_clock_period - 1) / sgi_clock_period + rtc_time();
+	period = (period + sgi_clock_period - 1)  / sgi_clock_period;
+
+	/*
+	 * We are allocating a local SHub comparator. If we would be moved to another
+	 * cpu then another SHub may be local to us. Prohibit that by switching off
+	 * preemption.
+	 */
+	preempt_disable();
+
+	nodeid =  cpuid_to_cnodeid(smp_processor_id());
+	base = timers + nodeid * NUM_COMPARATORS;
+retry:
+	/* Don't use an allocated timer, or a deleted one that's pending */
+	for(i = 0; i< NUM_COMPARATORS; i++) {
+		if (!base[i].timer && !base[i].tasklet.state) {
+			break;
+		}
+	}
+
+	if (i == NUM_COMPARATORS) {
+		preempt_enable();
+		return -EBUSY;
+	}
+
+	spin_lock_irqsave(&base[i].lock, irqflags);
+
+	if (base[i].timer || base[i].tasklet.state != 0) {
+		spin_unlock_irqrestore(&base[i].lock, irqflags);
+		goto retry;
+	}
+	base[i].timer = timr;
+	base[i].cpu = smp_processor_id();
+
+	timr->it_timer.magic = i;
+	timr->it_timer.data = nodeid;
+	timr->it_incr = period;
+	timr->it_timer.expires = when;
+
+	if (period == 0) {
+		if (mmtimer_setup(i, when)) {
+			mmtimer_disable_int(-1, i);
+			posix_timer_event(timr, 0);
+			timr->it_timer.expires = 0;
+		}
+	} else {
+		timr->it_timer.expires -= period;
+		if (reschedule_periodic_timer(base+i))
+			err = -EINVAL;
+	}
+
+	spin_unlock_irqrestore(&base[i].lock, irqflags);
+
+	preempt_enable();
+
+	return err;
+}
+
+static struct k_clock sgi_clock = {
+	.res = 0,
+	.clock_set = sgi_clock_set,
+	.clock_get = sgi_clock_get,
+	.timer_create = sgi_timer_create,
+	.nsleep = do_posix_clock_nonanosleep,
+	.timer_set = sgi_timer_set,
+	.timer_del = sgi_timer_del,
+	.timer_get = sgi_timer_get
+};
+
 /**
  * mmtimer_init - device initialization routine
  *
@@ -184,6 +682,8 @@
  */
 static int __init mmtimer_init(void)
 {
+	unsigned i;
+
 	if (!ia64_platform_is("sn2"))
 		return -1;
 
@@ -199,12 +699,29 @@
 	mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second /
 			       2) / sn_rtc_cycles_per_second;
 
+	for (i=0; i< NUM_COMPARATORS*MAX_COMPACT_NODES; i++) {
+		spin_lock_init(&timers[i].lock);
+		timers[i].timer = NULL;
+		timers[i].cpu = 0;
+		timers[i].i = i % NUM_COMPARATORS;
+		tasklet_init(&timers[i].tasklet, mmtimer_tasklet, (unsigned long) (timers+i));
+	}
+
+	if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, SA_PERCPU_IRQ, MMTIMER_NAME, NULL)) {
+		printk(KERN_WARNING "%s: unable to allocate interrupt.",
+			MMTIMER_NAME);
+		return -1;
+	}
+
 	strcpy(mmtimer_miscdev.devfs_name, MMTIMER_NAME);
 	if (misc_register(&mmtimer_miscdev)) {
 		printk(KERN_ERR "%s: failed to register device\n",
 		       MMTIMER_NAME);
 		return -1;
 	}
+
+	sgi_clock_period = sgi_clock.res = NSEC_PER_SEC / sn_rtc_cycles_per_second;
+	register_posix_clock(CLOCK_SGI_CYCLE, &sgi_clock);
 
 	printk(KERN_INFO "%s: v%s, %ld MHz\n", MMTIMER_DESC, MMTIMER_VERSION,
 	       sn_rtc_cycles_per_second/(unsigned long)1E6);
diff -Nru a/drivers/char/moxa.c b/drivers/char/moxa.c
--- a/drivers/char/moxa.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/char/moxa.c	2004-12-24 13:37:19 -08:00
@@ -50,10 +50,10 @@
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 #define		MOXA_VERSION		"5.1k"
@@ -142,7 +142,7 @@
 } moxa_board_conf;
 
 static moxa_board_conf moxa_boards[MAX_BOARDS];
-static unsigned long moxaBaseAddr[MAX_BOARDS];
+static void __iomem *moxaBaseAddr[MAX_BOARDS];
 
 struct moxa_str {
 	int type;
@@ -201,11 +201,13 @@
 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");
-MODULE_PARM(ttymajor, "i");
-MODULE_PARM(verbose, "i");
+#ifdef MODULE
+module_param_array(type, int, NULL, 0);
+module_param_array(baseaddr, int, NULL, 0);
+module_param_array(numports, int, NULL, 0);
+#endif
+module_param(ttymajor, int, 0);
+module_param(verbose, bool, 0644);
 
 static struct tty_driver *moxaDriver;
 static struct moxa_str moxaChannels[MAX_PORTS];
@@ -222,7 +224,7 @@
 static void do_moxa_softint(void *);
 static int moxa_open(struct tty_struct *, struct file *);
 static void moxa_close(struct tty_struct *, struct file *);
-static int moxa_write(struct tty_struct *, int, const unsigned char *, int);
+static int moxa_write(struct tty_struct *, const unsigned char *, int);
 static int moxa_write_room(struct tty_struct *);
 static void moxa_flush_buffer(struct tty_struct *);
 static int moxa_chars_in_buffer(struct tty_struct *);
@@ -467,7 +469,7 @@
 	}
 #endif
 	for (i = 0; i < numBoards; i++) {
-		moxaBaseAddr[i] = (unsigned long) ioremap((unsigned long) moxa_boards[i].baseAddr, 0x4000);
+		moxaBaseAddr[i] = ioremap((unsigned long) moxa_boards[i].baseAddr, 0x4000);
 	}
 
 	return (0);
@@ -492,7 +494,6 @@
 	put_tty_driver(moxaDriver);
 	if (verbose)
 		printk("Done\n");
-
 }
 
 module_init(moxa_init);
@@ -625,8 +626,7 @@
 	ch->tty = NULL;
 	if (ch->blocked_open) {
 		if (ch->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(ch->close_delay);
+			msleep_interruptible(jiffies_to_msecs(ch->close_delay));
 		}
 		wake_up_interruptible(&ch->open_wait);
 	}
@@ -634,7 +634,7 @@
 	wake_up_interruptible(&ch->close_wait);
 }
 
-static int moxa_write(struct tty_struct *tty, int from_user,
+static int moxa_write(struct tty_struct *tty,
 		      const unsigned char *buf, int count)
 {
 	struct moxa_str *ch;
@@ -646,25 +646,9 @@
 		return (0);
 	port = ch->port;
 	save_flags(flags);
-	if (from_user) {
-		if (count > PAGE_SIZE)
-			count = PAGE_SIZE;
-		down(&moxaBuffSem);
-		if (copy_from_user(moxaXmitBuff, buf, count)) {
-			len = -EFAULT;
-		} else {
-			cli();
-			len = MoxaPortWriteData(port, moxaXmitBuff, count);
-			restore_flags(flags);
-		}
-		up(&moxaBuffSem);
-		if (len < 0)
-			return len;
-	} else {
-		cli();
-		len = MoxaPortWriteData(port, (unsigned char *) buf, count);
-		restore_flags(flags);
-	}
+	cli();
+	len = MoxaPortWriteData(port, (unsigned char *) buf, count);
+	restore_flags(flags);
 
 	/*********************************************
 	if ( !(ch->statusflags & LOWWAIT) &&
@@ -694,7 +678,6 @@
 		return;
 	MoxaPortFlushData(ch->port, 1);
 	tty_wakeup(tty);
-	wake_up_interruptible(&tty->write_wait);
 }
 
 static int moxa_chars_in_buffer(struct tty_struct *tty)
@@ -953,7 +936,6 @@
 					if (!tp->stopped) {
 						ch->statusflags &= ~LOWWAIT;
 						tty_wakeup(tp);
-						wake_up_interruptible(&tp->write_wait);
 					}
 				}
 			}
@@ -1120,7 +1102,6 @@
 		if (MoxaPortTxQueue(ch->port) == 0) {
 			ch->statusflags &= ~EMPTYWAIT;
 			tty_wakeup(ch->tty);
-			wake_up_interruptible(&ch->tty->write_wait);
 			return;
 		}
 		moxaEmptyTimer[ch->port].expires = jiffies + HZ;
@@ -1498,12 +1479,12 @@
 #define 	DCD_oldstate	0x80
 
 static unsigned char moxaBuff[10240];
-static unsigned long moxaIntNdx[MAX_BOARDS];
-static unsigned long moxaIntPend[MAX_BOARDS];
-static unsigned long moxaIntTable[MAX_BOARDS];
+static void __iomem *moxaIntNdx[MAX_BOARDS];
+static void __iomem *moxaIntPend[MAX_BOARDS];
+static void __iomem *moxaIntTable[MAX_BOARDS];
 static char moxaChkPort[MAX_PORTS];
 static char moxaLineCtrl[MAX_PORTS];
-static unsigned long moxaTableAddr[MAX_PORTS];
+static void __iomem *moxaTableAddr[MAX_PORTS];
 static long moxaCurBaud[MAX_PORTS];
 static char moxaDCDState[MAX_PORTS];
 static char moxaLowChkFlag[MAX_PORTS];
@@ -1514,15 +1495,15 @@
 static ushort moxaBreakCnt[MAX_PORTS];
 
 static void moxadelay(int);
-static void moxafunc(unsigned long, int, ushort);
-static void wait_finish(unsigned long);
-static void low_water_check(unsigned long);
+static void moxafunc(void __iomem *, int, ushort);
+static void wait_finish(void __iomem *);
+static void low_water_check(void __iomem *);
 static int moxaloadbios(int, unsigned char __user *, int);
 static int moxafindcard(int);
 static int moxaload320b(int, unsigned char __user *, int);
 static int moxaloadcode(int, unsigned char __user *, int);
-static int moxaloadc218(int, unsigned long, int);
-static int moxaloadc320(int, unsigned long, int, int *);
+static int moxaloadc218(int, void __iomem *, int);
+static int moxaloadc320(int, void __iomem *, int, int *);
 
 /*****************************************************************************
  *	Driver level functions: 					     *
@@ -1580,7 +1561,7 @@
 
 void MoxaPortFlushData(int port, int mode)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	if ((mode < 0) || (mode > 2))
 		return;
 	ofsAddr = moxaTableAddr[port];
@@ -1712,7 +1693,8 @@
 {
 	register ushort temp;
 	register int card;
-	unsigned long ip, ofsAddr;
+	void __iomem *ofsAddr;
+	void __iomem *ip;
 	int port, p, ports;
 
 	if (moxaCard == 0)
@@ -2145,7 +2127,7 @@
 
 void MoxaPortEnable(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	int MoxaPortLineStatus(int);
 	short lowwater = 512;
 
@@ -2168,9 +2150,8 @@
 
 void MoxaPortDisable(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr = moxaTableAddr[port];
 
-	ofsAddr = moxaTableAddr[port];
 	moxafunc(ofsAddr, FC_SetFlowCtl, 0);	/* disable flow control */
 	moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code);
 	writew(0, ofsAddr + HostStat);
@@ -2189,7 +2170,7 @@
 
 long MoxaPortSetBaud(int port, long baud)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	long max, clock;
 	unsigned int val;
 
@@ -2213,7 +2194,7 @@
 
 int MoxaPortSetTermio(int port, struct termios *termio)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	tcflag_t cflag;
 	long baud;
 	tcflag_t mode = 0;
@@ -2358,7 +2339,7 @@
 
 void MoxaPortLineCtrl(int port, int dtr, int rts)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	int mode;
 
 	ofsAddr = moxaTableAddr[port];
@@ -2373,7 +2354,7 @@
 
 void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int txany)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	int mode;
 
 	ofsAddr = moxaTableAddr[port];
@@ -2393,7 +2374,7 @@
 
 int MoxaPortLineStatus(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	int val;
 
 	ofsAddr = moxaTableAddr[port];
@@ -2466,7 +2447,7 @@
 	int cnt;
 	ushort head, tx_mask, spage, epage;
 	ushort pageno, pageofs, bufhead;
-	unsigned long baseAddr, ofsAddr, ofs;
+	void __iomem *baseAddr, *ofsAddr, *ofs;
 
 	ofsAddr = moxaTableAddr[port];
 	baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
@@ -2529,7 +2510,7 @@
 	int i, count, cnt, len, total, remain;
 	ushort tail, rx_mask, spage, epage;
 	ushort pageno, bufhead;
-	unsigned long baseAddr, ofsAddr, ofs;
+	void __iomem *baseAddr, *ofsAddr, *ofs;
 
 	ofsAddr = moxaTableAddr[port];
 	baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
@@ -2595,7 +2576,7 @@
 
 int MoxaPortTxQueue(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	ushort rptr, wptr, mask;
 	int len;
 
@@ -2609,7 +2590,7 @@
 
 int MoxaPortTxFree(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	ushort rptr, wptr, mask;
 	int len;
 
@@ -2623,7 +2604,7 @@
 
 int MoxaPortRxQueue(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	ushort rptr, wptr, mask;
 	int len;
 
@@ -2638,7 +2619,7 @@
 
 void MoxaPortTxDisable(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 
 	ofsAddr = moxaTableAddr[port];
 	moxafunc(ofsAddr, FC_SetXoffState, Magic_code);
@@ -2646,7 +2627,7 @@
 
 void MoxaPortTxEnable(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 
 	ofsAddr = moxaTableAddr[port];
 	moxafunc(ofsAddr, FC_SetXonState, Magic_code);
@@ -2664,7 +2645,7 @@
 
 void MoxaPortSendBreak(int port, int ms100)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 
 	ofsAddr = moxaTableAddr[port];
 	if (ms100) {
@@ -2753,7 +2734,7 @@
 	while (time_before(jiffies, et));
 }
 
-static void moxafunc(unsigned long ofsAddr, int cmd, ushort arg)
+static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg)
 {
 
 	writew(arg, ofsAddr + FuncArg);
@@ -2761,7 +2742,7 @@
 	wait_finish(ofsAddr);
 }
 
-static void wait_finish(unsigned long ofsAddr)
+static void wait_finish(void __iomem *ofsAddr)
 {
 	unsigned long i, j;
 
@@ -2774,7 +2755,7 @@
 	}
 }
 
-static void low_water_check(unsigned long ofsAddr)
+static void low_water_check(void __iomem *ofsAddr)
 {
 	int len;
 	ushort rptr, wptr, mask;
@@ -2791,7 +2772,7 @@
 
 static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
 {
-	unsigned long baseAddr;
+	void __iomem *baseAddr;
 	int i;
 
 	if(copy_from_user(moxaBuff, tmp, len))
@@ -2809,7 +2790,7 @@
 
 static int moxafindcard(int cardno)
 {
-	unsigned long baseAddr;
+	void __iomem *baseAddr;
 	ushort tmp;
 
 	baseAddr = moxaBaseAddr[cardno];
@@ -2838,7 +2819,7 @@
 
 static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
 {
-	unsigned long baseAddr;
+	void __iomem *baseAddr;
 	int i;
 
 	if(len > sizeof(moxaBuff))
@@ -2858,7 +2839,7 @@
 
 static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
 {
-	unsigned long baseAddr, ofsAddr;
+	void __iomem *baseAddr, *ofsAddr;
 	int retval, port, i;
 
 	if(copy_from_user(moxaBuff, tmp, len))
@@ -2938,7 +2919,7 @@
 	return (0);
 }
 
-static int moxaloadc218(int cardno, unsigned long baseAddr, int len)
+static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
 {
 	char retry;
 	int i, j, len1, len2;
@@ -3014,7 +2995,7 @@
 	return (0);
 }
 
-static int moxaloadc320(int cardno, unsigned long baseAddr, int len, int *numPorts)
+static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPorts)
 {
 	ushort usum;
 	int i, j, wlen, len2, retry;
@@ -3119,7 +3100,7 @@
 
 static void MoxaSetFifo(int port, int enable)
 {
-	unsigned long ofsAddr = moxaTableAddr[port];
+	void __iomem *ofsAddr = moxaTableAddr[port];
 
 	if (!enable) {
 		moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0);
@@ -3133,7 +3114,7 @@
 #if 0
 int MoxaPortSetMode(int port, int databits, int stopbits, int parity)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	int val;
 
 	val = 0;
@@ -3192,7 +3173,7 @@
 
 int MoxaPortTxBufSize(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	int size;
 
 	ofsAddr = moxaTableAddr[port];
@@ -3202,7 +3183,7 @@
 
 int MoxaPortRxBufSize(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	int size;
 
 	ofsAddr = moxaTableAddr[port];
@@ -3212,7 +3193,7 @@
 
 int MoxaPortRxFree(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	ushort rptr, wptr, mask;
 	int len;
 
@@ -3230,7 +3211,7 @@
 
 void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 
 	ofsAddr = moxaTableAddr[port];
 	writew(xonValue, ofsAddr + FuncArg);
@@ -3241,7 +3222,7 @@
 
 int MoxaPortIsTxHold(int port)
 {
-	unsigned long ofsAddr;
+	void __iomem *ofsAddr;
 	int val;
 
 	ofsAddr = moxaTableAddr[port];
diff -Nru a/drivers/char/mwave/3780i.c b/drivers/char/mwave/3780i.c
--- a/drivers/char/mwave/3780i.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/char/mwave/3780i.c	2004-12-24 13:37:19 -08:00
@@ -52,11 +52,11 @@
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include "smapi.h"
 #include "mwavedd.h"
 #include "3780i.h"
diff -Nru a/drivers/char/mxser.c b/drivers/char/mxser.c
--- a/drivers/char/mxser.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/char/mxser.c	2004-12-24 13:37:01 -08:00
@@ -1,8 +1,7 @@
-/*****************************************************************************/
 /*
- *          mxser.c  -- MOXA Smartio family multiport serial driver.
+ *          mxser.c  -- MOXA Smartio/Industio family multiport serial driver.
  *
- *      Copyright (C) 1999-2000  Moxa Technologies (support@moxa.com.tw).
+ *      Copyright (C) 1999-2001  Moxa Technologies (support@moxa.com.tw).
  *
  *      This code is loosely based on the Linux serial driver, written by
  *      Linus Torvalds, Theodore T'so and others.
@@ -10,7 +9,7 @@
  *      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.
+*      (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
@@ -20,27 +19,27 @@
  *      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.
- */
-
-/*
- *    MOXA Smartio Family Serial Driver
  *
- *      Copyright (C) 1999,2000  Moxa Technologies Co., LTD.
+ *	Original release	10/26/00
  *
- *      for             : LINUX 2.0.X, 2.2.X, 2.4.X
- *      date            : 2001/05/01
- *      version         : 1.2 
- *      
- *    Fixes for C104H/PCI by Tim Hockin <thockin@sun.com>
- *    Added support for: C102, CI-132, CI-134, CP-132, CP-114, CT-114 cards
- *                        by Damian Wrobel <dwrobel@ertel.com.pl>
+ *	02/06/01	Support MOXA Industio family boards.
+ *	02/06/01	Support TIOCGICOUNT.
+ *	02/06/01	Fix the problem for connecting to serial mouse.
+ *	02/06/01	Fix the problem for H/W flow control.
+ *	02/06/01	Fix the compling warning when CONFIG_PCI
+ *			don't be defined.
  *
- *    Added support for serial card CP104
- *			  by James Nelson Provident Solutions <linux-info@provident-solutions.com>
+ *	Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox
+ *	<alan@redhat.com>. The original 1.8 code is available on www.moxa.com.
+ *	- Fixed x86_64 cleanness
+ *	- Fixed sleep with spinlock held in mxser_send_break
  */
 
+
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/version.h>
+#include <linux/autoconf.h>
 #include <linux/errno.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
@@ -54,178 +53,235 @@
 #include <linux/string.h>
 #include <linux/fcntl.h>
 #include <linux/ptrace.h>
+#include <linux/gfp.h>
 #include <linux/ioport.h>
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
+#include <linux/delay.h>
 #include <linux/pci.h>
-#include <linux/init.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
+#include <asm/segment.h>
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
 
-#define		MXSER_VERSION			"1.2.1"
-
-#define		MXSERMAJOR	 	174
-#define		MXSERCUMAJOR		175
+#include "mxser.h"
 
+#define	MXSER_VERSION	"1.8"
+#define	MXSERMAJOR	 174
+#define	MXSERCUMAJOR	 175
 
 #define	MXSER_EVENT_TXLOW	 1
 #define	MXSER_EVENT_HANGUP	 2
 
+#define MXSER_BOARDS		4	/* Max. boards */
+#define MXSER_PORTS		32	/* Max. ports */
+#define MXSER_PORTS_PER_BOARD	8	/* Max. ports per board */
+#define MXSER_ISR_PASS_LIMIT	256
 
-#define 	SERIAL_DO_RESTART
-
-#define 	MXSER_BOARDS		4	/* Max. boards */
-#define 	MXSER_PORTS		32	/* Max. ports */
-#define 	MXSER_PORTS_PER_BOARD	8	/* Max. ports per board */
-#define 	MXSER_ISR_PASS_LIMIT	256
-
-#define		MXSER_ERR_IOADDR	-1
-#define		MXSER_ERR_IRQ		-2
-#define		MXSER_ERR_IRQ_CONFLIT	-3
-#define		MXSER_ERR_VECTOR	-4
+#define	MXSER_ERR_IOADDR	-1
+#define	MXSER_ERR_IRQ		-2
+#define	MXSER_ERR_IRQ_CONFLIT	-3
+#define	MXSER_ERR_VECTOR	-4
 
-#define 	SERIAL_TYPE_NORMAL	1
+#define SERIAL_TYPE_NORMAL	1
+#define SERIAL_TYPE_CALLOUT	2
 
-#define 	WAKEUP_CHARS		256
+#define WAKEUP_CHARS		256
 
-#define 	UART_MCR_AFE		0x20
-#define 	UART_LSR_SPECIAL	0x1E
+#define UART_MCR_AFE		0x20
+#define UART_LSR_SPECIAL	0x1E
 
-#define PORTNO(x)		((x)->index)
-
-#define RELEVANT_IFLAG(iflag)	(iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
+#define RELEVANT_IFLAG(iflag)	(iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|IXON|IXOFF))
 
 #define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
 
-/*
- *    Define the Moxa PCI vendor and device IDs.
- */
-
-#ifndef	PCI_VENDOR_ID_MOXA
-#define	PCI_VENDOR_ID_MOXA	0x1393
-#endif
-#ifndef PCI_DEVICE_ID_C168
-#define PCI_DEVICE_ID_C168	0x1680
-#endif
-#ifndef PCI_DEVICE_ID_C104
-#define PCI_DEVICE_ID_C104	0x1040
-#endif
-#ifndef PCI_DEVICE_ID_CP104
-#define PCI_DEVICE_ID_CP104	0x1041
-#endif
-#ifndef PCI_DEVICE_ID_CP132
-#define PCI_DEVICE_ID_CP132	0x1320
-#endif
-#ifndef PCI_DEVICE_ID_CP114
-#define PCI_DEVICE_ID_CP114	0x1141
-#endif
-#ifndef PCI_DEVICE_ID_CT114
-#define PCI_DEVICE_ID_CT114	0x1140
-#endif
-
 #define C168_ASIC_ID    1
 #define C104_ASIC_ID    2
-#define CI134_ASIC_ID   3
-#define CI132_ASIC_ID   4
-#define CI104J_ASIC_ID  5
 #define C102_ASIC_ID	0xB
+#define CI132_ASIC_ID	4
+#define CI134_ASIC_ID	3
+#define CI104J_ASIC_ID  5
 
 enum {
-	MXSER_BOARD_C168_ISA = 0,
+	MXSER_BOARD_C168_ISA = 1,
 	MXSER_BOARD_C104_ISA,
 	MXSER_BOARD_CI104J,
 	MXSER_BOARD_C168_PCI,
 	MXSER_BOARD_C104_PCI,
-	MXSER_BOARD_CP104_PCI,
 	MXSER_BOARD_C102_ISA,
 	MXSER_BOARD_CI132,
 	MXSER_BOARD_CI134,
-	MXSER_BOARD_CP132_PCI,
-	MXSER_BOARD_CP114_PCI,
-	MXSER_BOARD_CT114_PCI
+	MXSER_BOARD_CP132,
+	MXSER_BOARD_CP114,
+	MXSER_BOARD_CT114,
+	MXSER_BOARD_CP102,
+	MXSER_BOARD_CP104U,
+	MXSER_BOARD_CP168U,
+	MXSER_BOARD_CP132U,
+	MXSER_BOARD_CP134U,
+	MXSER_BOARD_CP104JU,
+	MXSER_BOARD_RC7000,
+	MXSER_BOARD_CP118U,
+	MXSER_BOARD_CP102UL,
+	MXSER_BOARD_CP102U,
 };
 
-static char *mxser_brdname[] =
-{
+static char *mxser_brdname[] = {
 	"C168 series",
 	"C104 series",
 	"CI-104J series",
 	"C168H/PCI series",
 	"C104H/PCI series",
-	"CP104/PCI series",
 	"C102 series",
 	"CI-132 series",
 	"CI-134 series",
 	"CP-132 series",
 	"CP-114 series",
-	"CT-114 series"
+	"CT-114 series",
+	"CP-102 series",
+	"CP-104U series",
+	"CP-168U series",
+	"CP-132U series",
+	"CP-134U series",
+	"CP-104JU series",
+	"Moxa UC7000 Serial",
+	"CP-118U series",
+	"CP-102UL series",
+	"CP-102U series",
 };
 
-static int mxser_numports[] =
-{
-	8,
-	4,
-	4,
-	8,
-	4,
-	4,
-	2,
-	2,
-	4,
-	2,
-	4,
-	4
+static int mxser_numports[] = {
+	8,			// C168-ISA
+	4,			// C104-ISA
+	4,			// CI104J
+	8,			// C168-PCI
+	4,			// C104-PCI
+	2,			// C102-ISA
+	2,			// CI132
+	4,			// CI134
+	2,			// CP132
+	4,			// CP114
+	4,			// CT114
+	2,			// CP102
+	4,			// CP104U
+	8,			// CP168U
+	2,			// CP132U
+	4,			// CP134U
+	4,			// CP104JU
+	8,			// RC7000
+	8,			// CP118U 
+	2,			// CP102UL 
+	2,			// CP102U
+};
+
+#define UART_TYPE_NUM	2
+
+unsigned int Gmoxa_uart_id[UART_TYPE_NUM] = {
+	MOXA_MUST_MU150_HWID,
+	MOXA_MUST_MU860_HWID
+};
+
+// This is only for PCI
+#define UART_INFO_NUM	3
+struct mxpciuart_info {
+	int type;
+	int tx_fifo;
+	int rx_fifo;
+	int xmit_fifo_size;
+	int rx_high_water;
+	int rx_trigger;
+	int rx_low_water;
+	long max_baud;
+};
+
+struct mxpciuart_info Gpci_uart_info[UART_INFO_NUM] = {
+	{MOXA_OTHER_UART, 16, 16, 16, 14, 14, 1, 921600L},
+	{MOXA_MUST_MU150_HWID, 64, 64, 64, 48, 48, 16, 230400L},
+	{MOXA_MUST_MU860_HWID, 128, 128, 128, 96, 96, 32, 921600L}
 };
 
-/*
- *    MOXA ioctls
- */
-#define 	MOXA		0x400
-#define 	MOXA_GETDATACOUNT     (MOXA + 23)
-#define		MOXA_GET_CONF         (MOXA + 35)
-#define 	MOXA_DIAGNOSE         (MOXA + 50)
-#define 	MOXA_CHKPORTENABLE    (MOXA + 60)
-#define 	MOXA_HighSpeedOn      (MOXA + 61)
-#define         MOXA_GET_MAJOR        (MOXA + 63)
-#define         MOXA_GET_CUMAJOR      (MOXA + 64)
-#define         MOXA_GETMSTATUS       (MOXA + 65)
 
 #ifdef CONFIG_PCI
+
 static struct pci_device_id mxser_pcibrds[] = {
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_C168, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
-	  MXSER_BOARD_C168_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_C104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
-	  MXSER_BOARD_C104_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_CP104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
-	  MXSER_BOARD_CP104_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_CP132, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-	  MXSER_BOARD_CP132_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_CP114, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-	  MXSER_BOARD_CP114_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_CT114, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-	  MXSER_BOARD_CT114_PCI },
-	{ 0 }
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_C168_PCI},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_C104_PCI},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP132},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP114},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CT114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CT114},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP102},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104U, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP104U},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168U, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP168U},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132U, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP132U},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP134U, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP134U},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104JU, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP104JU},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_RC7000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_RC7000},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118U, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP118U},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102UL, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP102UL},
+	{PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102U, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MXSER_BOARD_CP102U},
+	{0}
 };
+
 MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
-#endif /* CONFIG_PCI */
 
-static int ioaddr[MXSER_BOARDS];
+
+#endif
+
+typedef struct _moxa_pci_info {
+	unsigned short busNum;
+	unsigned short devNum;
+	struct pci_dev *pdev;	// add by Victor Yu. 06-23-2003
+} moxa_pci_info;
+
+static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
 static int ttymajor = MXSERMAJOR;
-static int verbose;
+static int calloutmajor = MXSERCUMAJOR;
+static int verbose = 0;
 
 /* Variables for insmod */
 
-MODULE_AUTHOR("William Chen");
-MODULE_DESCRIPTION("MOXA Smartio Family Multiport Board Device Driver");
-MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Casper Yang");
+MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver");
 MODULE_PARM(ioaddr, "1-4i");
 MODULE_PARM(ttymajor, "i");
+MODULE_PARM(calloutmajor, "i");
 MODULE_PARM(verbose, "i");
+MODULE_LICENSE("GPL");
 
+struct mxser_log {
+	int tick;
+	unsigned long rxcnt[MXSER_PORTS];
+	unsigned long txcnt[MXSER_PORTS];
+};
+
+
+struct mxser_mon {
+	unsigned long rxcnt;
+	unsigned long txcnt;
+	unsigned long up_rxcnt;
+	unsigned long up_txcnt;
+	int modem_status;
+	unsigned char hold_reason;
+};
+
+struct mxser_mon_ext {
+	unsigned long rx_cnt[32];
+	unsigned long tx_cnt[32];
+	unsigned long up_rxcnt[32];
+	unsigned long up_txcnt[32];
+	int modem_status[32];
+
+	long baudrate[32];
+	int databits[32];
+	int stopbits[32];
+	int parity[32];
+	int flowctrl[32];
+	int fifo[32];
+	int iftype[32];
+};
 struct mxser_hwconf {
 	int board_type;
 	int ports;
@@ -235,7 +291,10 @@
 	int uart_type;
 	int ioaddr[MXSER_PORTS_PER_BOARD];
 	int baud_base[MXSER_PORTS_PER_BOARD];
-	struct pci_dev *pdev;
+	moxa_pci_info pciInfo;
+	int IsMoxaMustChipFlag;	// add by Victor Yu. 08-30-2002
+	int MaxCanSetBaudRate[MXSER_PORTS_PER_BOARD];	// add by Victor Yu. 09-04-2002
+	int opmode_ioaddr[MXSER_PORTS_PER_BOARD];	// add by Victor Yu. 01-05-2004
 };
 
 struct mxser_struct {
@@ -244,7 +303,9 @@
 	int irq;		/* port using irq no. */
 	int vector;		/* port irq vector */
 	int vectormask;		/* port vector mask */
+	int rx_high_water;
 	int rx_trigger;		/* Rx fifo trigger level */
+	int rx_low_water;
 	int baud_base;		/* max. speed */
 	int flags;		/* defined in tty.h */
 	int type;		/* UART type */
@@ -261,23 +322,31 @@
 	unsigned long event;
 	int count;		/* # of fd on device */
 	int blocked_open;	/* # of blocked opens */
+	long session;		/* Session of opening process */
+	long pgrp;		/* pgrp of opening process */
 	unsigned char *xmit_buf;
 	int xmit_head;
 	int xmit_tail;
 	int xmit_cnt;
 	struct work_struct tqueue;
-	int cflag;
+	struct termios normal_termios;
+	struct termios callout_termios;
 	wait_queue_head_t open_wait;
 	wait_queue_head_t close_wait;
 	wait_queue_head_t delta_msr_wait;
 	struct async_icount icount;	/* kernel counters for the 4 input interrupts */
+	int timeout;
+	int IsMoxaMustChipFlag;	// add by Victor Yu. 08-30-2002
+	int MaxCanSetBaudRate;	// add by Victor Yu. 09-04-2002
+	int opmode_ioaddr;	// add by Victor Yu. 01-05-2004
+	unsigned char stop_rx;
+	unsigned char ldisc_stop_rx;
+	long realbaud;
+	struct mxser_mon mon_data;
+	unsigned char err_shadow;
+	spinlock_t slock;
 };
 
-struct mxser_log {
-	int tick;
-	int rxcnt[MXSER_PORTS];
-	int txcnt[MXSER_PORTS];
-};
 
 struct mxser_mstatus {
 	tcflag_t cflag;
@@ -289,49 +358,43 @@
 
 static struct mxser_mstatus GMStatus[MXSER_PORTS];
 
-static int mxserBoardCAP[MXSER_BOARDS] =
-{
+static int mxserBoardCAP[MXSER_BOARDS] = {
 	0, 0, 0, 0
-       /*  0x180, 0x280, 0x200, 0x320   */
+	    /*  0x180, 0x280, 0x200, 0x320   */
 };
 
-
 static struct tty_driver *mxvar_sdriver;
 static struct mxser_struct mxvar_table[MXSER_PORTS];
+static struct tty_struct *mxvar_tty[MXSER_PORTS + 1];
+static struct termios *mxvar_termios[MXSER_PORTS + 1];
+static struct termios *mxvar_termios_locked[MXSER_PORTS + 1];
 static struct mxser_log mxvar_log;
 static int mxvar_diagflag;
-/*
- * mxvar_tmp_buf is used as a temporary buffer by serial_write. We need
- * to lock it in case the memcpy_fromfs 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 *mxvar_tmp_buf;
-static struct semaphore mxvar_tmp_buf_sem;
+static unsigned char mxser_msr[MXSER_PORTS + 1];
+static struct mxser_mon_ext mon_data_ext;
+static int mxser_set_baud_method[MXSER_PORTS + 1];
+static spinlock_t gm_lock;
 
 /*
  * This is used to figure out the divisor speeds and the timeouts
  */
-static int mxvar_baud_table[] =
-{
-	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
-	9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600, 0};
 
-struct mxser_hwconf mxsercfg[MXSER_BOARDS];
+static struct mxser_hwconf mxsercfg[MXSER_BOARDS];
 
 /*
  * static functions:
  */
 
 static void mxser_getcfg(int board, struct mxser_hwconf *hwconf);
+static int mxser_init(void);
+
+//static void   mxser_poll(unsigned long);
 static int mxser_get_ISA_conf(int, struct mxser_hwconf *);
+static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
 static void mxser_do_softint(void *);
 static int mxser_open(struct tty_struct *, struct file *);
 static void mxser_close(struct tty_struct *, struct file *);
-static int mxser_write(struct tty_struct *, int, const unsigned char *, int);
+static int mxser_write(struct tty_struct *, const unsigned char *, int);
 static int mxser_write_room(struct tty_struct *);
 static void mxser_flush_buffer(struct tty_struct *);
 static int mxser_chars_in_buffer(struct tty_struct *);
@@ -345,109 +408,218 @@
 static void mxser_stop(struct tty_struct *);
 static void mxser_start(struct tty_struct *);
 static void mxser_hangup(struct tty_struct *);
-static inline void mxser_receive_chars(struct mxser_struct *, int *);
-static inline void mxser_transmit_chars(struct mxser_struct *);
-static inline void mxser_check_modem_status(struct mxser_struct *, int);
+static void mxser_rs_break(struct tty_struct *, int);
 static irqreturn_t mxser_interrupt(int, void *, struct pt_regs *);
+static void mxser_receive_chars(struct mxser_struct *, int *);
+static void mxser_transmit_chars(struct mxser_struct *);
+static void mxser_check_modem_status(struct mxser_struct *, int);
 static int mxser_block_til_ready(struct tty_struct *, struct file *, struct mxser_struct *);
 static int mxser_startup(struct mxser_struct *);
 static void mxser_shutdown(struct mxser_struct *);
 static int mxser_change_speed(struct mxser_struct *, struct termios *old_termios);
-static int mxser_get_serial_info(struct mxser_struct *, struct serial_struct __user *);
-static int mxser_set_serial_info(struct mxser_struct *, struct serial_struct __user *);
-static int mxser_get_lsr_info(struct mxser_struct *, unsigned int __user *);
+static int mxser_get_serial_info(struct mxser_struct *, struct serial_struct *);
+static int mxser_set_serial_info(struct mxser_struct *, struct serial_struct *);
+static int mxser_get_lsr_info(struct mxser_struct *, unsigned int *);
 static void mxser_send_break(struct mxser_struct *, int);
 static int mxser_tiocmget(struct tty_struct *, struct file *);
 static int mxser_tiocmset(struct tty_struct *, struct file *, unsigned int, unsigned int);
+static int mxser_set_baud(struct mxser_struct *info, long newspd);
+static void mxser_wait_until_sent(struct tty_struct *tty, int timeout);
+
+static void mxser_startrx(struct tty_struct *tty);
+static void mxser_stoprx(struct tty_struct *tty);
+
+
+static int CheckIsMoxaMust(int io)
+{
+	u8 oldmcr, hwid;
+	int i;
+
+	outb(0, io + UART_LCR);
+	DISABLE_MOXA_MUST_ENCHANCE_MODE(io);
+	oldmcr = inb(io + UART_MCR);
+	outb(0, io + UART_MCR);
+	SET_MOXA_MUST_XON1_VALUE(io, 0x11);
+	if ((hwid = inb(io + UART_MCR)) != 0) {
+		outb(oldmcr, io + UART_MCR);
+		return (MOXA_OTHER_UART);
+	}
+
+	GET_MOXA_MUST_HARDWARE_ID(io, &hwid);
+	for (i = 0; i < UART_TYPE_NUM; i++) {
+		if (hwid == Gmoxa_uart_id[i])
+			return (int) hwid;
+	}
+	return MOXA_OTHER_UART;
+}
+
+// above is modified by Victor Yu. 08-15-2002
+
+static struct tty_operations mxser_ops = {
+	.open = mxser_open,
+	.close = mxser_close,
+	.write = mxser_write,
+	.put_char = mxser_put_char,
+	.flush_chars = mxser_flush_chars,
+	.write_room = mxser_write_room,
+	.chars_in_buffer = mxser_chars_in_buffer,
+	.flush_buffer = mxser_flush_buffer,
+	.ioctl = mxser_ioctl,
+	.throttle = mxser_throttle,
+	.unthrottle = mxser_unthrottle,
+	.set_termios = mxser_set_termios,
+	.stop = mxser_stop,
+	.start = mxser_start,
+	.hangup = mxser_hangup,
+	.tiocmget = mxser_tiocmget,
+	.tiocmset = mxser_tiocmset,
+};
 
 /*
- * The MOXA C168/C104 serial driver boot-time initialization code!
+ * The MOXA Smartio/Industio serial driver boot-time initialization code!
  */
 
+static int __init mxser_module_init(void)
+{
+	int ret;
+
+	if (verbose)
+		printk(KERN_DEBUG "Loading module mxser ...\n");
+	ret = mxser_init();
+	if (verbose)
+		printk(KERN_DEBUG "Done.\n");
+	return ret;
+}
+
 static void __exit mxser_module_exit(void)
 {
 	int i, err = 0;
 
-
 	if (verbose)
-		printk("Unloading module mxser ...\n");
+		printk(KERN_DEBUG "Unloading module mxser ...\n");
+
 	if ((err |= tty_unregister_driver(mxvar_sdriver)))
-		printk("Couldn't unregister MOXA Smartio family serial driver\n");
-	put_tty_driver(mxvar_sdriver);
+		printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n");
 
 	for (i = 0; i < MXSER_BOARDS; i++) {
+		struct pci_dev *pdev;
+
 		if (mxsercfg[i].board_type == -1)
 			continue;
 		else {
+			pdev = mxsercfg[i].pciInfo.pdev;
 			free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]);
+			if (pdev != NULL) {	//PCI
+				release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
+				release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3));
+			} else {
+				release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports);
+				release_region(mxsercfg[i].vector, 1);
+			}
 		}
 	}
-
 	if (verbose)
-		printk("Done.\n");
+		printk(KERN_DEBUG "Done.\n");
 
 }
 
-int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
+static void process_txrx_fifo(struct mxser_struct *info)
+{
+	int i;
+
+	if ((info->type == PORT_16450) || (info->type == PORT_8250)) {
+		info->rx_trigger = 1;
+		info->rx_high_water = 1;
+		info->rx_low_water = 1;
+		info->xmit_fifo_size = 1;
+	} else {
+		for (i = 0; i < UART_INFO_NUM; i++) {
+			if (info->IsMoxaMustChipFlag == Gpci_uart_info[i].type) {
+				info->rx_trigger = Gpci_uart_info[i].rx_trigger;
+				info->rx_low_water = Gpci_uart_info[i].rx_low_water;
+				info->rx_high_water = Gpci_uart_info[i].rx_high_water;
+				info->xmit_fifo_size = Gpci_uart_info[i].xmit_fifo_size;
+				break;
+			}
+		}
+	}
+}
+
+static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
 {
 	struct mxser_struct *info;
 	unsigned long flags;
 	int retval;
 	int i, n;
 
-	init_MUTEX(&mxvar_tmp_buf_sem);
-	
 	n = board * MXSER_PORTS_PER_BOARD;
 	info = &mxvar_table[n];
+	/*if (verbose) */  {
+		printk(KERN_DEBUG "        ttyM%d - ttyM%d ", n, n + hwconf->ports - 1);
+		printk(KERN_DEBUG " max. baud rate = %d bps.\n", hwconf->MaxCanSetBaudRate[0]);
+	}
+
 	for (i = 0; i < hwconf->ports; i++, n++, info++) {
-		if (verbose) {
-			printk("        ttyM%d/cum%d at 0x%04x ", n, n, hwconf->ioaddr[i]);
-			if (hwconf->baud_base[i] == 115200)
-				printk(" max. baud rate up to 115200 bps.\n");
-			else
-				printk(" max. baud rate up to 921600 bps.\n");
-		}
 		info->port = n;
 		info->base = hwconf->ioaddr[i];
 		info->irq = hwconf->irq;
 		info->vector = hwconf->vector;
 		info->vectormask = hwconf->vector_mask;
-		info->rx_trigger = 14;
-		info->baud_base = hwconf->baud_base[i];
+		info->opmode_ioaddr = hwconf->opmode_ioaddr[i];	// add by Victor Yu. 01-05-2004
+		info->stop_rx = 0;
+		info->ldisc_stop_rx = 0;
+
+		info->IsMoxaMustChipFlag = hwconf->IsMoxaMustChipFlag;
+		//Enhance mode enabled here
+		if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) {
+			ENABLE_MOXA_MUST_ENCHANCE_MODE(info->base);
+		}
+
 		info->flags = ASYNC_SHARE_IRQ;
 		info->type = hwconf->uart_type;
-		if ((info->type == PORT_16450) || (info->type == PORT_8250))
-			info->xmit_fifo_size = 1;
-		else
-			info->xmit_fifo_size = 16;
+		info->baud_base = hwconf->baud_base[i];
+
+		info->MaxCanSetBaudRate = hwconf->MaxCanSetBaudRate[i];
+
+		process_txrx_fifo(info);
+
+
 		info->custom_divisor = hwconf->baud_base[i] * 16;
 		info->close_delay = 5 * HZ / 10;
 		info->closing_wait = 30 * HZ;
 		INIT_WORK(&info->tqueue, mxser_do_softint, info);
-		info->cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+		info->normal_termios = mxvar_sdriver->init_termios;
 		init_waitqueue_head(&info->open_wait);
 		init_waitqueue_head(&info->close_wait);
 		init_waitqueue_head(&info->delta_msr_wait);
+		memset(&info->mon_data, 0, sizeof(struct mxser_mon));
+		info->err_shadow = 0;
+		spin_lock_init(&info->slock);
 	}
-
 	/*
 	 * Allocate the IRQ if necessary
 	 */
-	save_flags(flags);
+
+
+	/* before set INT ISR, disable all int */
+	for (i = 0; i < hwconf->ports; i++) {
+		outb(inb(hwconf->ioaddr[i] + UART_IER) & 0xf0, hwconf->ioaddr[i] + UART_IER);
+	}
 
 	n = board * MXSER_PORTS_PER_BOARD;
 	info = &mxvar_table[n];
 
-	cli();
-	retval = request_irq(hwconf->irq, mxser_interrupt, IRQ_T(info),
-			     "mxser", info);
+	spin_lock_irqsave(&info->slock, flags);
+	retval = request_irq(hwconf->irq, mxser_interrupt, IRQ_T(info), "mxser", info);
 	if (retval) {
-		restore_flags(flags);
-		printk("Board %d: %s", board, mxser_brdname[hwconf->board_type]);
+		spin_unlock_irqrestore(&info->slock, flags);
+		printk(KERN_ERR "Board %d: %s", board, mxser_brdname[hwconf->board_type - 1]);
 		printk("  Request irq fail,IRQ (%d) may be conflit with another device.\n", info->irq);
-		return (retval);
+		return retval;
 	}
-	restore_flags(flags);
+
+	spin_unlock_irqrestore(&info->slock, flags);
+
 
 	return 0;
 }
@@ -459,82 +631,131 @@
 }
 
 #ifdef CONFIG_PCI
-static int mxser_get_PCI_conf(struct pci_dev *pdev, int board_type, struct mxser_hwconf *hwconf)
+static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxser_hwconf *hwconf)
 {
-	int i;
+	int i, j;
+//      unsigned int    val;
 	unsigned int ioaddress;
+	struct pci_dev *pdev = hwconf->pciInfo.pdev;
 
+	//io address
 	hwconf->board_type = board_type;
-	hwconf->ports = mxser_numports[board_type];
-	ioaddress = pci_resource_start (pdev, 2);
-	for (i = 0; i < hwconf->ports; i++)
+	hwconf->ports = mxser_numports[board_type - 1];
+	ioaddress = pci_resource_start(pdev, 2);
+	request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2), "mxser(IO)");
+
+	for (i = 0; i < hwconf->ports; i++) {
 		hwconf->ioaddr[i] = ioaddress + 8 * i;
+	}
 
-	ioaddress = pci_resource_start (pdev, 3);
+	//vector
+	ioaddress = pci_resource_start(pdev, 3);
+	request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3), "mxser(vector)");
 	hwconf->vector = ioaddress;
 
-	hwconf->irq = pdev->irq;
+	//irq
+	hwconf->irq = hwconf->pciInfo.pdev->irq;
 
+	hwconf->IsMoxaMustChipFlag = CheckIsMoxaMust(hwconf->ioaddr[0]);
 	hwconf->uart_type = PORT_16550A;
 	hwconf->vector_mask = 0;
+
+
+	for (i = 0; i < hwconf->ports; i++) {
+		for (j = 0; j < UART_INFO_NUM; j++) {
+			if (Gpci_uart_info[j].type == hwconf->IsMoxaMustChipFlag) {
+				hwconf->MaxCanSetBaudRate[i] = Gpci_uart_info[j].max_baud;
+
+				//exception....CP-102
+				if (board_type == MXSER_BOARD_CP102)
+					hwconf->MaxCanSetBaudRate[i] = 921600;
+				break;
+			}
+		}
+	}
+
+	if (hwconf->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID) {
+		for (i = 0; i < hwconf->ports; i++) {
+			if (i < 4)
+				hwconf->opmode_ioaddr[i] = ioaddress + 4;
+			else
+				hwconf->opmode_ioaddr[i] = ioaddress + 0x0c;
+		}
+		outb(0, ioaddress + 4);	// default set to RS232 mode
+		outb(0, ioaddress + 0x0c);	//default set to RS232 mode
+	}
+
 	for (i = 0; i < hwconf->ports; i++) {
 		hwconf->vector_mask |= (1 << i);
 		hwconf->baud_base[i] = 921600;
 	}
 	return (0);
 }
-#endif /* CONFIG_PCI */
-
-static struct tty_operations mxser_ops = {
-	.open = mxser_open,
-	.close = mxser_close,
-	.write = mxser_write,
-	.put_char = mxser_put_char,
-	.flush_chars = mxser_flush_chars,
-	.write_room = mxser_write_room,
-	.chars_in_buffer = mxser_chars_in_buffer,
-	.flush_buffer = mxser_flush_buffer,
-	.ioctl = mxser_ioctl,
-	.throttle = mxser_throttle,
-	.unthrottle = mxser_unthrottle,
-	.set_termios = mxser_set_termios,
-	.stop = mxser_stop,
-	.start = mxser_start,
-	.hangup = mxser_hangup,
-	.tiocmget = mxser_tiocmget,
-	.tiocmset = mxser_tiocmset,
-};
+#endif
 
-static int __init mxser_module_init(void)
+static int mxser_init(void)
 {
-	int i, m, retval, b;
+	int i, m, retval, b, n;
+	int ret1;
+	struct pci_dev *pdev = NULL;
+	int index;
+	unsigned char busnum, devnum;
 	struct mxser_hwconf hwconf;
 
 	mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);
 	if (!mxvar_sdriver)
 		return -ENOMEM;
+	spin_lock_init(&gm_lock);
 
-	printk("MOXA Smartio family driver version %s\n", MXSER_VERSION);
+	for (i = 0; i < MXSER_BOARDS; i++) {
+		mxsercfg[i].board_type = -1;
+	}
 
-	/* Initialize the tty_driver structure */
+	printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", MXSER_VERSION);
 
-	mxvar_sdriver->owner = THIS_MODULE;
+	/* Initialize the tty_driver structure */
+	memset(mxvar_sdriver, 0, sizeof(struct tty_driver));
+	mxvar_sdriver->magic = TTY_DRIVER_MAGIC;
 	mxvar_sdriver->name = "ttyM";
-	mxvar_sdriver->devfs_name = "tts/M";
 	mxvar_sdriver->major = ttymajor;
 	mxvar_sdriver->minor_start = 0;
+	mxvar_sdriver->num = MXSER_PORTS + 1;
 	mxvar_sdriver->type = TTY_DRIVER_TYPE_SERIAL;
 	mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
 	mxvar_sdriver->init_termios = tty_std_termios;
 	mxvar_sdriver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
 	mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(mxvar_sdriver, &mxser_ops);
-	printk("Tty devices major number = %d\n", ttymajor);
+	mxvar_sdriver->ttys = mxvar_tty;
+	mxvar_sdriver->termios = mxvar_termios;
+	mxvar_sdriver->termios_locked = mxvar_termios_locked;
+
+	mxvar_sdriver->open = mxser_open;
+	mxvar_sdriver->close = mxser_close;
+	mxvar_sdriver->write = mxser_write;
+	mxvar_sdriver->put_char = mxser_put_char;
+	mxvar_sdriver->flush_chars = mxser_flush_chars;
+	mxvar_sdriver->write_room = mxser_write_room;
+	mxvar_sdriver->chars_in_buffer = mxser_chars_in_buffer;
+	mxvar_sdriver->flush_buffer = mxser_flush_buffer;
+	mxvar_sdriver->ioctl = mxser_ioctl;
+	mxvar_sdriver->throttle = mxser_throttle;
+	mxvar_sdriver->unthrottle = mxser_unthrottle;
+	mxvar_sdriver->set_termios = mxser_set_termios;
+	mxvar_sdriver->stop = mxser_stop;
+	mxvar_sdriver->start = mxser_start;
+	mxvar_sdriver->hangup = mxser_hangup;
+	mxvar_sdriver->break_ctl = mxser_rs_break;
+	mxvar_sdriver->wait_until_sent = mxser_wait_until_sent;
 
 	mxvar_diagflag = 0;
 	memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct));
 	memset(&mxvar_log, 0, sizeof(struct mxser_log));
 
+	memset(&mxser_msr, 0, sizeof(unsigned char) * (MXSER_PORTS + 1));
+	memset(&mon_data_ext, 0, sizeof(struct mxser_mon_ext));
+	memset(&mxser_set_baud_method, 0, sizeof(int) * (MXSER_PORTS + 1));
+	memset(&hwconf, 0, sizeof(struct mxser_hwconf));
 
 	m = 0;
 	/* Start finding ISA boards here */
@@ -546,28 +767,31 @@
 		retval = mxser_get_ISA_conf(cap, &hwconf);
 
 		if (retval != 0)
-			printk("Found MOXA %s board (CAP=0x%x)\n",
-			       mxser_brdname[hwconf.board_type],
-			       ioaddr[b]);
+			printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", mxser_brdname[hwconf.board_type - 1], ioaddr[b]);
 
 		if (retval <= 0) {
 			if (retval == MXSER_ERR_IRQ)
-				printk("Invalid interrupt number,board not configured\n");
+				printk(KERN_ERR "Invalid interrupt number,board not configured\n");
 			else if (retval == MXSER_ERR_IRQ_CONFLIT)
-				printk("Invalid interrupt number,board not configured\n");
+				printk(KERN_ERR "Invalid interrupt number,board not configured\n");
 			else if (retval == MXSER_ERR_VECTOR)
-				printk("Invalid interrupt vector,board not configured\n");
+				printk(KERN_ERR "Invalid interrupt vector,board not configured\n");
 			else if (retval == MXSER_ERR_IOADDR)
-				printk("Invalid I/O address,board not configured\n");
+				printk(KERN_ERR "Invalid I/O address,board not configured\n");
 
 			continue;
 		}
-		hwconf.pdev = NULL;
 
+		hwconf.pciInfo.busNum = 0;
+		hwconf.pciInfo.devNum = 0;
+		hwconf.pciInfo.pdev = NULL;
+
+		mxser_getcfg(m, &hwconf);
+		//init mxsercfg first, or mxsercfg data is not correct on ISR.
+		//mxser_initbrd will hook ISR.
 		if (mxser_initbrd(m, &hwconf) < 0)
 			continue;
 
-		mxser_getcfg(m, &hwconf);
 
 		m++;
 	}
@@ -581,89 +805,97 @@
 		retval = mxser_get_ISA_conf(cap, &hwconf);
 
 		if (retval != 0)
-			printk("Found MOXA %s board (CAP=0x%x)\n",
-			       mxser_brdname[hwconf.board_type],
-			       ioaddr[b]);
+			printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", mxser_brdname[hwconf.board_type - 1], ioaddr[b]);
 
 		if (retval <= 0) {
 			if (retval == MXSER_ERR_IRQ)
-				printk("Invalid interrupt number,board not configured\n");
+				printk(KERN_ERR "Invalid interrupt number,board not configured\n");
 			else if (retval == MXSER_ERR_IRQ_CONFLIT)
-				printk("Invalid interrupt number,board not configured\n");
+				printk(KERN_ERR "Invalid interrupt number,board not configured\n");
 			else if (retval == MXSER_ERR_VECTOR)
-				printk("Invalid interrupt vector,board not configured\n");
+				printk(KERN_ERR "Invalid interrupt vector,board not configured\n");
 			else if (retval == MXSER_ERR_IOADDR)
-				printk("Invalid I/O address,board not configured\n");
+				printk(KERN_ERR "Invalid I/O address,board not configured\n");
 
 			continue;
 		}
-		hwconf.pdev = NULL;
 
-		if (mxser_initbrd(m, &hwconf) < 0)
-			continue;
+		hwconf.pciInfo.busNum = 0;
+		hwconf.pciInfo.devNum = 0;
+		hwconf.pciInfo.pdev = NULL;
 
 		mxser_getcfg(m, &hwconf);
+		//init mxsercfg first, or mxsercfg data is not correct on ISR.
+		//mxser_initbrd will hook ISR.
+		if (mxser_initbrd(m, &hwconf) < 0)
+			continue;
 
 		m++;
 	}
 
 	/* start finding PCI board here */
-
-#ifdef CONFIG_PCI
-	{
-		struct pci_dev *pdev = NULL;
-		int n = (sizeof(mxser_pcibrds) / sizeof(mxser_pcibrds[0])) - 1;
-		for (b = 0; b < n; b++) {
-			while ((pdev = pci_find_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev)))
-			{
-				if (pci_enable_device(pdev))
-					continue;
-				hwconf.pdev = pdev;
-				printk("Found MOXA %s board(BusNo=%d,DevNo=%d)\n",
-					mxser_brdname[mxser_pcibrds[b].driver_data],
-				pdev->bus->number, PCI_SLOT(pdev->devfn));
-				if (m >= MXSER_BOARDS) {
-					printk("Too many Smartio family boards found (maximum %d),board not configured\n", MXSER_BOARDS);
-				} else {
-					retval = mxser_get_PCI_conf(pdev, mxser_pcibrds[b].driver_data, &hwconf);
-					if (retval < 0) {
-						if (retval == MXSER_ERR_IRQ)
-							printk("Invalid interrupt number,board not configured\n");
-						else if (retval == MXSER_ERR_IRQ_CONFLIT)
-							printk("Invalid interrupt number,board not configured\n");	
-						else if (retval == MXSER_ERR_VECTOR)
-							printk("Invalid interrupt vector,board not configured\n");
-						else if (retval == MXSER_ERR_IOADDR)
-							printk("Invalid I/O address,board not configured\n");
-						continue;
-					}
-					if (mxser_initbrd(m, &hwconf) < 0)
-						continue;
-					mxser_getcfg(m, &hwconf);
-					m++;
-				}
+	n = (sizeof(mxser_pcibrds) / sizeof(mxser_pcibrds[0])) - 1;
+	index = 0;
+	b = 0;
+	while (b < n) {
+		pdev = pci_find_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev);
+			if (pdev == NULL) {
+			b++;
+			continue;
+		}
+		hwconf.pciInfo.busNum = busnum = pdev->bus->number;
+		hwconf.pciInfo.devNum = devnum = PCI_SLOT(pdev->devfn) << 3;
+		hwconf.pciInfo.pdev = pdev;
+		printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1], busnum, devnum >> 3);
+		index++;
+		if (m >= MXSER_BOARDS) {
+			printk(KERN_ERR "Too many Smartio/Industio family boards find (maximum %d),board not configured\n", MXSER_BOARDS);
+		} else {
+			if (pci_enable_device(pdev)) {
+				printk(KERN_ERR "Moxa SmartI/O PCI enable fail !\n");
+				continue;
 			}
+			retval = mxser_get_PCI_conf(busnum, devnum, (int) mxser_pcibrds[b].driver_data, &hwconf);
+			if (retval < 0) {
+				if (retval == MXSER_ERR_IRQ)
+					printk(KERN_ERR "Invalid interrupt number,board not configured\n");
+				else if (retval == MXSER_ERR_IRQ_CONFLIT)
+					printk(KERN_ERR "Invalid interrupt number,board not configured\n");
+				else if (retval == MXSER_ERR_VECTOR)
+					printk(KERN_ERR "Invalid interrupt vector,board not configured\n");
+				else if (retval == MXSER_ERR_IOADDR)
+					printk(KERN_ERR "Invalid I/O address,board not configured\n");
+				continue;
+			}
+			mxser_getcfg(m, &hwconf);
+			//init mxsercfg first, or mxsercfg data is not correct on ISR.
+			//mxser_initbrd will hook ISR.
+			if (mxser_initbrd(m, &hwconf) < 0)
+				continue;
+			m++;
 		}
 	}
-#endif
-
-	for (i = m; i < MXSER_BOARDS; i++) {
-		mxsercfg[i].board_type = -1;
-	}
 
-
-	if (!tty_register_driver(mxvar_sdriver))
+	ret1 = 0;
+	if (!(ret1 = tty_register_driver(mxvar_sdriver))) {
 		return 0;
+	} else
+		printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n");
 
-	put_tty_driver(mxvar_sdriver);
-	printk("Couldn't install MOXA Smartio family driver !\n");
 
-	for (i = 0; i < MXSER_BOARDS; i++) {
-		if (mxsercfg[i].board_type == -1)
-			continue;
-		free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]);
+	if (ret1) {
+		for (i = 0; i < MXSER_BOARDS; i++) {
+			if (mxsercfg[i].board_type == -1)
+				continue;
+			else {
+				free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]);
+				//todo: release io, vector
+			}
+		}
+		return -1;
 	}
-	return -1;
+
+	return (0);
 }
 
 static void mxser_do_softint(void *private_)
@@ -672,52 +904,52 @@
 	struct tty_struct *tty;
 
 	tty = info->tty;
+
 	if (tty) {
-		if (test_and_clear_bit(MXSER_EVENT_TXLOW, &info->event)) {
+		if (test_and_clear_bit(MXSER_EVENT_TXLOW, &info->event))
 			tty_wakeup(tty);
-			wake_up_interruptible(&tty->write_wait);
-		}
-		if (test_and_clear_bit(MXSER_EVENT_HANGUP, &info->event)) {
-			tty_hangup(tty);	/* FIXME: module removal race here - AKPM */
-		}
+		if (test_and_clear_bit(MXSER_EVENT_HANGUP, &info->event))
+			tty_hangup(tty);
 	}
 }
 
+static unsigned char mxser_get_msr(int baseaddr, int mode, int port, struct mxser_struct *info)
+{
+	unsigned char status = 0;
+
+	status = inb(baseaddr + UART_MSR);
+
+	mxser_msr[port] &= 0x0F;
+	mxser_msr[port] |= status;
+	status = mxser_msr[port];
+	if (mode)
+		mxser_msr[port] = 0;
+
+	return status;
+}
+
 /*
  * 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 mxser_open(struct tty_struct *tty, struct file *filp)
 {
 	struct mxser_struct *info;
 	int retval, line;
-	unsigned long page;
 
-	line = PORTNO(tty);
+	line = tty->index;
 	if (line == MXSER_PORTS)
-		return (0);
-	if ((line < 0) || (line > MXSER_PORTS))
-		return (-ENODEV);
+		return 0;
+	if (line < 0 || line > MXSER_PORTS)
+		return -ENODEV;
 	info = mxvar_table + line;
 	if (!info->base)
 		return (-ENODEV);
 
-	info->count++;
 	tty->driver_data = info;
 	info->tty = tty;
-
-	if (!mxvar_tmp_buf) {
-		page = get_zeroed_page(GFP_KERNEL);
-		if (!page)
-			return (-ENOMEM);
-		if (mxvar_tmp_buf)
-			free_page(page);
-		else
-			mxvar_tmp_buf = (unsigned char *) page;
-	}
 	/*
 	 * Start up serial port
 	 */
@@ -725,7 +957,31 @@
 	if (retval)
 		return (retval);
 
-	return mxser_block_til_ready(tty, filp, info);
+	retval = mxser_block_til_ready(tty, filp, info);
+	if (retval)
+		return (retval);
+
+	info->count++;
+
+	if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
+		if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
+			*tty->termios = info->normal_termios;
+		else
+			*tty->termios = info->callout_termios;
+		mxser_change_speed(info, 0);
+	}
+
+	info->session = current->signal->session;
+	info->pgrp = process_group(current);
+	clear_bit(TTY_DONT_FLIP, &tty->flags);
+
+	//status = mxser_get_msr(info->base, 0, info->port);
+	//mxser_check_modem_status(info, status);
+
+/* unmark here for very high baud rate (ex. 921600 bps) used
+*/
+	tty->low_latency = 1;
+	return 0;
 }
 
 /*
@@ -734,48 +990,52 @@
  * async structure from the interrupt chain if necessary, and we free
  * that IRQ if nothing is left in the chain.
  */
-
 static void mxser_close(struct tty_struct *tty, struct file *filp)
 {
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
-	unsigned long flags;
+
 	unsigned long timeout;
+	unsigned long flags;
+	struct tty_ldisc *ld;
 
-	if (PORTNO(tty) == MXSER_PORTS)
+	if (tty->index == MXSER_PORTS)
 		return;
 	if (!info)
-		return;
+		BUG();
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&info->slock, flags);
 
 	if (tty_hung_up_p(filp)) {
-		restore_flags(flags);
+		spin_unlock_irqrestore(&info->slock, flags);
 		return;
 	}
 	if ((tty->count == 1) && (info->count != 1)) {
 		/*
-		 * Uh, oh.        tty->count is 1, which means that the tty
+		 * 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("mxser_close: bad serial port count; tty->count is 1, "
-		       "info->count is %d\n", info->count);
+		printk(KERN_ERR "mxser_close: bad serial port count; tty->count is 1, " "info->count is %d\n", info->count);
 		info->count = 1;
 	}
 	if (--info->count < 0) {
-		printk("mxser_close: bad serial port count for ttys%d: %d\n",
-		       info->port, info->count);
+		printk(KERN_ERR "mxser_close: bad serial port count for ttys%d: %d\n", info->port, info->count);
 		info->count = 0;
 	}
 	if (info->count) {
-		restore_flags(flags);
+		spin_unlock_irqrestore(&info->slock, flags);
 		return;
 	}
 	info->flags |= ASYNC_CLOSING;
-	info->cflag = tty->termios->c_cflag;
+	spin_unlock_irqrestore(&info->slock, flags);
+	/*
+	 * Save the termios structure, since this port may have
+	 * separate termios for callout and dialin.
+	 */
+	if (info->flags & ASYNC_NORMAL_ACTIVE)
+		info->normal_termios = *tty->termios;
 	/*
 	 * Now we wait for the transmit buffer to clear; and we notify
 	 * the line discipline to only process XON/XOFF characters.
@@ -790,9 +1050,11 @@
 	 * line status register.
 	 */
 	info->IER &= ~UART_IER_RLSI;
-	/* by William
-	   info->read_status_mask &= ~UART_LSR_DR;
-	 */
+	if (info->IsMoxaMustChipFlag)
+		info->IER &= ~MOXA_MUST_RECV_ISR;
+/* by William
+	info->read_status_mask &= ~UART_LSR_DR;
+*/
 	if (info->flags & ASYNC_INITIALIZED) {
 		outb(info->IER, info->base + UART_IER);
 		/*
@@ -809,13 +1071,20 @@
 		}
 	}
 	mxser_shutdown(info);
+
 	if (tty->driver->flush_buffer)
 		tty->driver->flush_buffer(tty);
-	tty_ldisc_flush(tty);
-
+		
+	ld = tty_ldisc_ref(tty);
+	if (ld) {
+		if(ld->flush_buffer)
+			ld->flush_buffer(tty);
+		tty_ldisc_deref(ld);
+	}
+		
 	tty->closing = 0;
 	info->event = 0;
-	info->tty = NULL;
+	info->tty = 0;
 	if (info->blocked_open) {
 		if (info->close_delay) {
 			set_current_state(TASK_INTERRUPTIBLE);
@@ -823,80 +1092,47 @@
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
+
 	info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
 	wake_up_interruptible(&info->close_wait);
-	restore_flags(flags);
 
 }
 
-static int mxser_write(struct tty_struct *tty, int from_user,
-		       const unsigned char *buf, int count)
+static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	int c, total = 0;
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
 	unsigned long flags;
 
-	if (!tty || !info->xmit_buf || !mxvar_tmp_buf)
+	if (!tty || !info->xmit_buf)
 		return (0);
 
-	save_flags(flags);
-	if (from_user) {
-		down(&mxvar_tmp_buf_sem);
-		while (1) {
-			c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					   SERIAL_XMIT_SIZE - info->xmit_head));
-			if (c <= 0)
-				break;
-
-			c -= copy_from_user(mxvar_tmp_buf, buf, c);
-			if (!c) {
-				if (!total)
-					total = -EFAULT;
-				break;
-			}
+	while (1) {
+		c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, SERIAL_XMIT_SIZE - info->xmit_head));
+		if (c <= 0)
+			break;
 
-			cli();
-			c = min_t(int, c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-				       SERIAL_XMIT_SIZE - info->xmit_head));
-			memcpy(info->xmit_buf + info->xmit_head, mxvar_tmp_buf, c);
-			info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1);
-			info->xmit_cnt += c;
-			restore_flags(flags);
-
-			buf += c;
-			count -= c;
-			total += c;
-		}
-		up(&mxvar_tmp_buf_sem);
-	} else {
-		while (1) {
-			cli();
-			c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					   SERIAL_XMIT_SIZE - info->xmit_head));
-			if (c <= 0) {
-				restore_flags(flags);
-				break;
-			}
+		memcpy(info->xmit_buf + info->xmit_head, buf, c);
+		spin_lock_irqsave(&info->slock, flags);
+		info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1);
+		info->xmit_cnt += c;
+		spin_unlock_irqrestore(&info->slock, flags);
+
+		buf += c;
+		count -= c;
+		total += c;
 
-			memcpy(info->xmit_buf + info->xmit_head, buf, c);
-			info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1);
-			info->xmit_cnt += c;
-			restore_flags(flags);
-
-			buf += c;
-			count -= c;
-			total += c;
-		}
 	}
 
-	cli();
-	if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
-	    !(info->IER & UART_IER_THRI)) {
-		info->IER |= UART_IER_THRI;
-		outb(info->IER, info->base + UART_IER);
+	if (info->xmit_cnt && !tty->stopped && !(info->IER & UART_IER_THRI)) {
+		if (!tty->hw_stopped || (info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) {
+			spin_lock_irqsave(&info->slock, flags);
+			info->IER |= UART_IER_THRI;
+			outb(info->IER, info->base + UART_IER);
+			spin_unlock_irqrestore(&info->slock, flags);
+		}
 	}
-	restore_flags(flags);
-	return (total);
+	return total;
 }
 
 static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
@@ -907,39 +1143,39 @@
 	if (!tty || !info->xmit_buf)
 		return;
 
-	save_flags(flags);
-	cli();
-	if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1) {
-		restore_flags(flags);
+	if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
 		return;
-	}
+
+	spin_lock_irqsave(&info->slock, flags);
 	info->xmit_buf[info->xmit_head++] = ch;
 	info->xmit_head &= SERIAL_XMIT_SIZE - 1;
 	info->xmit_cnt++;
-	/********************************************** why ??? ***********
-	if ( !tty->stopped && !tty->hw_stopped &&
-	     !(info->IER & UART_IER_THRI) ) {
-	    info->IER |= UART_IER_THRI;
-	    outb(info->IER, info->base + UART_IER);
+	spin_unlock_irqrestore(&info->slock, flags);
+	if (!tty->stopped && !(info->IER & UART_IER_THRI)) {
+		if (!tty->hw_stopped || (info->type == PORT_16550A) || info->IsMoxaMustChipFlag) {
+			spin_lock_irqsave(&info->slock, flags);
+			info->IER |= UART_IER_THRI;
+			outb(info->IER, info->base + UART_IER);
+			spin_unlock_irqrestore(&info->slock, flags);
+		}
 	}
-	*****************************************************************/
-	restore_flags(flags);
 }
 
+
 static void mxser_flush_chars(struct tty_struct *tty)
 {
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
 	unsigned long flags;
 
-	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
-	    !info->xmit_buf)
+	if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf || (tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)))
 		return;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&info->slock, flags);
+
 	info->IER |= UART_IER_THRI;
 	outb(info->IER, info->base + UART_IER);
-	restore_flags(flags);
+
+	spin_unlock_irqrestore(&info->slock, flags);
 }
 
 static int mxser_write_room(struct tty_struct *tty)
@@ -956,38 +1192,75 @@
 static int mxser_chars_in_buffer(struct tty_struct *tty)
 {
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
-
-	return (info->xmit_cnt);
+	return info->xmit_cnt;
 }
 
 static void mxser_flush_buffer(struct tty_struct *tty)
 {
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
+	char fcr;
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+
+	spin_lock_irqsave(&info->slock, flags);
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-	restore_flags(flags);
+
+	/* below added by shinhay */
+	fcr = inb(info->base + UART_FCR);
+	outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR);
+	outb(fcr, info->base + UART_FCR);
+
+	spin_unlock_irqrestore(&info->slock, flags);
+	/* above added by shinhay */
+
 	wake_up_interruptible(&tty->write_wait);
-	tty_wakeup(tty);
+	if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
+		(tty->ldisc.write_wakeup) (tty);
 }
 
-static int mxser_ioctl(struct tty_struct *tty, struct file *file,
-		       unsigned int cmd, unsigned long arg)
+static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 {
-	unsigned long flags;
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
 	int retval;
 	struct async_icount cprev, cnow;	/* kernel counter temps */
-	struct serial_icounter_struct __user *p_cuser;
+	struct serial_icounter_struct *p_cuser;	/* user space */
 	unsigned long templ;
-	void __user *argp = (void __user *)arg;
+	unsigned long flags;
 
-	if (PORTNO(tty) == MXSER_PORTS)
+	if (tty->index == MXSER_PORTS)
 		return (mxser_ioctl_special(cmd, arg));
-	if ((cmd != TIOCGSERIAL) && (cmd != TIOCMIWAIT) &&
-	    (cmd != TIOCGICOUNT)) {
+
+	// following add by Victor Yu. 01-05-2004
+	if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) {
+		int opmode, p;
+		static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f };
+		int shiftbit;
+		unsigned char val, mask;
+
+		p = info->port % 4;
+		if (cmd == MOXA_SET_OP_MODE) {
+			if (get_user(opmode, (int *) arg))
+				return -EFAULT;
+			if (opmode != RS232_MODE && opmode != RS485_2WIRE_MODE && opmode != RS422_MODE && opmode != RS485_4WIRE_MODE)
+				return -EFAULT;
+			mask = ModeMask[p];
+			shiftbit = p * 2;
+			val = inb(info->opmode_ioaddr);
+			val &= mask;
+			val |= (opmode << shiftbit);
+			outb(val, info->opmode_ioaddr);
+		} else {
+			shiftbit = p * 2;
+			opmode = inb(info->opmode_ioaddr) >> shiftbit;
+			opmode &= OP_MODE_MASK;
+			if (copy_to_user((int *) arg, &opmode, sizeof(int)))
+				return -EFAULT;
+		}
+		return 0;
+	}
+	// above add by Victor Yu. 01-05-2004
+
+	if ((cmd != TIOCGSERIAL) && (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
 		if (tty->flags & (1 << TTY_IO_ERROR))
 			return (-EIO);
 	}
@@ -998,7 +1271,7 @@
 			return (retval);
 		tty_wait_until_sent(tty, 0);
 		if (!arg)
-			mxser_send_break(info, HZ / 4);		/* 1/4 second */
+			mxser_send_break(info, HZ / 4);	/* 1/4 second */
 		return (0);
 	case TCSBRKP:		/* support for POSIX tcsendbreak() */
 		retval = tty_check_change(tty);
@@ -1008,50 +1281,53 @@
 		mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
 		return (0);
 	case TIOCGSOFTCAR:
-		return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp);
+		return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg);
 	case TIOCSSOFTCAR:
-		if(get_user(templ, (unsigned long __user *) arg))
+		if (get_user(templ, (unsigned long *) arg))
 			return -EFAULT;
 		arg = templ;
-		tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) |
-					 (arg ? CLOCAL : 0));
+		tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
 		return (0);
 	case TIOCGSERIAL:
-		return mxser_get_serial_info(info, argp);
+		return (mxser_get_serial_info(info, (struct serial_struct *) arg));
 	case TIOCSSERIAL:
-		return mxser_set_serial_info(info, argp);
+		return (mxser_set_serial_info(info, (struct serial_struct *) arg));
 	case TIOCSERGETLSR:	/* Get line status register */
-		return mxser_get_lsr_info(info, argp);
+		return (mxser_get_lsr_info(info, (unsigned int *) arg));
 		/*
 		 * 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();
-		cprev = info->icount;	/* note the counters on entry */
-		restore_flags(flags);
-		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->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);
+	case TIOCMIWAIT:{
+			DECLARE_WAITQUEUE(wait, current);
+			int ret;
+			spin_lock_irqsave(&info->slock, flags);
+			cprev = info->icount;	/* note the counters on entry */
+			spin_unlock_irqrestore(&info->slock, flags);
+
+			add_wait_queue(&info->delta_msr_wait, &wait);
+			while (1) {
+				spin_lock_irqsave(&info->slock, flags);
+				cnow = info->icount;	/* atomic copy */
+				spin_unlock_irqrestore(&info->slock, flags);
+
+				set_current_state(TASK_INTERRUPTIBLE);
+				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))) {
+					ret = 0;
+					break;
+				}
+				/* see if a signal did it */
+				if (signal_pending(current)) {
+					ret = -ERESTARTSYS;
+					break;
+				}
+				cprev = cnow;
 			}
-			cprev = cnow;
+			current->state = TASK_RUNNING;
+			remove_wait_queue(&info->delta_msr_wait, &wait);
+			break;
 		}
 		/* NOTREACHED */
 		/*
@@ -1061,45 +1337,139 @@
 		 *     RI where only 0->1 is counted.
 		 */
 	case TIOCGICOUNT:
-		save_flags(flags);
-		cli();
+		spin_lock_irqsave(&info->slock, flags);
 		cnow = info->icount;
-		restore_flags(flags);
-		p_cuser = argp;
-		if(put_user(cnow.cts, &p_cuser->cts))
+		spin_unlock_irqrestore(&info->slock, flags);
+		p_cuser = (struct serial_icounter_struct *) arg;
+		/* modified by casper 1/11/2000 */
+		if (put_user(cnow.frame, &p_cuser->frame))
+			return -EFAULT;
+		if (put_user(cnow.brk, &p_cuser->brk))
+			return -EFAULT;
+		if (put_user(cnow.overrun, &p_cuser->overrun))
 			return -EFAULT;
-		if(put_user(cnow.dsr, &p_cuser->dsr))
+		if (put_user(cnow.buf_overrun, &p_cuser->buf_overrun))
 			return -EFAULT;
-		if(put_user(cnow.rng, &p_cuser->rng))
+		if (put_user(cnow.parity, &p_cuser->parity))
 			return -EFAULT;
-		return put_user(cnow.dcd, &p_cuser->dcd);
+		if (put_user(cnow.rx, &p_cuser->rx))
+			return -EFAULT;
+		if (put_user(cnow.tx, &p_cuser->tx))
+			return -EFAULT;
+		put_user(cnow.cts, &p_cuser->cts);
+		put_user(cnow.dsr, &p_cuser->dsr);
+		put_user(cnow.rng, &p_cuser->rng);
+		put_user(cnow.dcd, &p_cuser->dcd);
+
+/* */
+		return 0;
 	case MOXA_HighSpeedOn:
-		return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
+		return put_user(info->baud_base != 115200 ? 1 : 0, (int *) arg);
+
+	case MOXA_SDS_RSTICOUNTER:{
+			info->mon_data.rxcnt = 0;
+			info->mon_data.txcnt = 0;
+			return 0;
+		}
+// (above) added by James.
+	case MOXA_ASPP_SETBAUD:{
+			long baud;
+			if (get_user(baud, (long *) arg))
+				return -EFAULT;
+			mxser_set_baud(info, baud);
+			return 0;
+		}
+	case MOXA_ASPP_GETBAUD:
+		if (copy_to_user((long *) arg, &info->realbaud, sizeof(long)))
+			return -EFAULT;
+
+		return 0;
+
+	case MOXA_ASPP_OQUEUE:{
+			int len, lsr;
+
+			len = mxser_chars_in_buffer(tty);
+
+			lsr = inb(info->base + UART_LSR) & UART_LSR_TEMT;
+
+			len += (lsr ? 0 : 1);
+
+			if (copy_to_user((int *) arg, &len, sizeof(int)))
+				return -EFAULT;
+
+			return 0;
+		}
+	case MOXA_ASPP_MON:{
+			int mcr, status;
+//      info->mon_data.ser_param = tty->termios->c_cflag;
+
+			status = mxser_get_msr(info->base, 1, info->port, info);
+			mxser_check_modem_status(info, status);
+
+			mcr = inb(info->base + UART_MCR);
+			if (mcr & MOXA_MUST_MCR_XON_FLAG)
+				info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD;
+			else
+				info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFHOLD;
+
+			if (mcr & MOXA_MUST_MCR_TX_XON)
+				info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFXENT;
+			else
+				info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFXENT;
+
+			if (info->tty->hw_stopped)
+				info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD;
+			else
+				info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
+
+
+			if (copy_to_user((struct mxser_mon *) arg, &(info->mon_data), sizeof(struct mxser_mon)))
+				return -EFAULT;
+
+			return 0;
+
+		}
+
+	case MOXA_ASPP_LSTATUS:{
+			if (copy_to_user((struct mxser_mon *) arg, &(info->err_shadow), sizeof(unsigned char)))
+				return -EFAULT;
+
+			info->err_shadow = 0;
+			return 0;
+
+		}
+	case MOXA_SET_BAUD_METHOD:{
+			int method;
+			if (get_user(method, (int *) arg))
+				return -EFAULT;
+			mxser_set_baud_method[info->port] = method;
+			if (copy_to_user((int *) arg, &method, sizeof(int)))
+				return -EFAULT;
+
+			return 0;
+		}
 	default:
-		return (-ENOIOCTLCMD);
+		return -ENOIOCTLCMD;
 	}
-	return (0);
+	return 0;
 }
 
 static int mxser_ioctl_special(unsigned int cmd, unsigned long arg)
 {
 	int i, result, status;
-	void __user *argp = (void __user *)arg;
 
 	switch (cmd) {
 	case MOXA_GET_CONF:
-		if(copy_to_user(argp, mxsercfg,
-			     sizeof(struct mxser_hwconf) * 4))
-			     	return -EFAULT;
+		if (copy_to_user((struct mxser_hwconf *) arg, mxsercfg, sizeof(struct mxser_hwconf) * 4))
+			return -EFAULT;
 		return 0;
 	case MOXA_GET_MAJOR:
-		if(copy_to_user(argp, &ttymajor, sizeof(int)))
+		if (copy_to_user((int *) arg, &ttymajor, sizeof(int)))
 			return -EFAULT;
 		return 0;
 
 	case MOXA_GET_CUMAJOR:
-		result = 0;
-		if(copy_to_user(argp, &result, sizeof(int)))
+		if (copy_to_user((int *) arg, &calloutmajor, sizeof(int)))
 			return -EFAULT;
 		return 0;
 
@@ -1109,9 +1479,9 @@
 			if (mxvar_table[i].base)
 				result |= (1 << i);
 		}
-		return put_user(result, (unsigned long __user *) argp);
+		return put_user(result, (unsigned long *) arg);
 	case MOXA_GETDATACOUNT:
-		if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
+		if (copy_to_user((struct mxser_log *) arg, &mxvar_log, sizeof(mxvar_log)))
 			return -EFAULT;
 		return (0);
 	case MOXA_GETMSTATUS:
@@ -1123,8 +1493,9 @@
 				GMStatus[i].cts = 0;
 				continue;
 			}
+
 			if (!mxvar_table[i].tty || !mxvar_table[i].tty->termios)
-				GMStatus[i].cflag = mxvar_table[i].cflag;
+				GMStatus[i].cflag = mxvar_table[i].normal_termios.c_cflag;
 			else
 				GMStatus[i].cflag = mxvar_table[i].tty->termios->c_cflag;
 
@@ -1145,105 +1516,207 @@
 			else
 				GMStatus[i].cts = 0;
 		}
-		if(copy_to_user(argp, GMStatus,
-			     sizeof(struct mxser_mstatus) * MXSER_PORTS))
+		if (copy_to_user((struct mxser_mstatus *) arg, GMStatus, sizeof(struct mxser_mstatus) * MXSER_PORTS))
 			return -EFAULT;
 		return 0;
+	case MOXA_ASPP_MON_EXT:{
+			int status;
+			int opmode, p;
+			int shiftbit;
+			unsigned cflag, iflag;
+
+			for (i = 0; i < MXSER_PORTS; i++) {
+
+				if (!mxvar_table[i].base)
+					continue;
+
+				status = mxser_get_msr(mxvar_table[i].base, 0, i, &(mxvar_table[i]));
+//                      mxser_check_modem_status(&mxvar_table[i], status);
+				if (status & UART_MSR_TERI)
+					mxvar_table[i].icount.rng++;
+				if (status & UART_MSR_DDSR)
+					mxvar_table[i].icount.dsr++;
+				if (status & UART_MSR_DDCD)
+					mxvar_table[i].icount.dcd++;
+				if (status & UART_MSR_DCTS)
+					mxvar_table[i].icount.cts++;
+
+				mxvar_table[i].mon_data.modem_status = status;
+				mon_data_ext.rx_cnt[i] = mxvar_table[i].mon_data.rxcnt;
+				mon_data_ext.tx_cnt[i] = mxvar_table[i].mon_data.txcnt;
+				mon_data_ext.up_rxcnt[i] = mxvar_table[i].mon_data.up_rxcnt;
+				mon_data_ext.up_txcnt[i] = mxvar_table[i].mon_data.up_txcnt;
+				mon_data_ext.modem_status[i] = mxvar_table[i].mon_data.modem_status;
+				mon_data_ext.baudrate[i] = mxvar_table[i].realbaud;
+
+				if (!mxvar_table[i].tty || !mxvar_table[i].tty->termios) {
+					cflag = mxvar_table[i].normal_termios.c_cflag;
+					iflag = mxvar_table[i].normal_termios.c_iflag;
+				} else {
+					cflag = mxvar_table[i].tty->termios->c_cflag;
+					iflag = mxvar_table[i].tty->termios->c_iflag;
+				}
+
+				mon_data_ext.databits[i] = cflag & CSIZE;
+
+				mon_data_ext.stopbits[i] = cflag & CSTOPB;
+
+				mon_data_ext.parity[i] = cflag & (PARENB | PARODD | CMSPAR);
+
+				mon_data_ext.flowctrl[i] = 0x00;
+
+				if (cflag & CRTSCTS)
+					mon_data_ext.flowctrl[i] |= 0x03;
+
+				if (iflag & (IXON | IXOFF))
+					mon_data_ext.flowctrl[i] |= 0x0C;
+
+				if (mxvar_table[i].type == PORT_16550A)
+					mon_data_ext.fifo[i] = 1;
+				else
+					mon_data_ext.fifo[i] = 0;
+
+				p = i % 4;
+				shiftbit = p * 2;
+				opmode = inb(mxvar_table[i].opmode_ioaddr) >> shiftbit;
+				opmode &= OP_MODE_MASK;
+
+				mon_data_ext.iftype[i] = opmode;
+
+			}
+			if (copy_to_user((struct mxser_mon_ext *) arg, &mon_data_ext, sizeof(struct mxser_mon_ext)))
+				return -EFAULT;
+
+			return 0;
+
+		}
 	default:
-		return (-ENOIOCTLCMD);
+		return -ENOIOCTLCMD;
 	}
-	return (0);
+	return 0;
 }
 
-/*
- * This routine is called by the upper-layer tty layer to signal that
- * incoming characters should be throttled.
- */
-static void mxser_throttle(struct tty_struct *tty)
+
+static void mxser_stoprx(struct tty_struct *tty)
 {
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
-	unsigned long flags;
+	//unsigned long flags;
+
 
+	info->ldisc_stop_rx = 1;
 	if (I_IXOFF(tty)) {
-		info->x_char = STOP_CHAR(tty);
-		save_flags(flags);
-		cli();
-		outb(info->IER, 0);
-		info->IER |= UART_IER_THRI;
-		outb(info->IER, info->base + UART_IER);		/* force Tx interrupt */
-		restore_flags(flags);
+
+		//MX_LOCK(&info->slock);
+		// following add by Victor Yu. 09-02-2002
+		if (info->IsMoxaMustChipFlag) {
+			info->IER &= ~MOXA_MUST_RECV_ISR;
+			outb(info->IER, info->base + UART_IER);
+		} else {
+			// above add by Victor Yu. 09-02-2002
+
+			info->x_char = STOP_CHAR(tty);
+			//      outb(info->IER, 0); // mask by Victor Yu. 09-02-2002
+			outb(0, info->base + UART_IER);
+			info->IER |= UART_IER_THRI;
+			outb(info->IER, info->base + UART_IER);	/* force Tx interrupt */
+		}		// add by Victor Yu. 09-02-2002
+		//MX_UNLOCK(&info->slock);
 	}
+
 	if (info->tty->termios->c_cflag & CRTSCTS) {
+		//MX_LOCK(&info->slock);
 		info->MCR &= ~UART_MCR_RTS;
-		save_flags(flags);
-		cli();
 		outb(info->MCR, info->base + UART_MCR);
-		restore_flags(flags);
+		//MX_UNLOCK(&info->slock);
 	}
 }
 
-static void mxser_unthrottle(struct tty_struct *tty)
+static void mxser_startrx(struct tty_struct *tty)
 {
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
-	unsigned long flags;
+	//unsigned long flags;
 
+	info->ldisc_stop_rx = 0;
 	if (I_IXOFF(tty)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else {
-			info->x_char = START_CHAR(tty);
-			save_flags(flags);
-			cli();
-			outb(info->IER, 0);
-			info->IER |= UART_IER_THRI;	/* force Tx interrupt */
-			outb(info->IER, info->base + UART_IER);
-			restore_flags(flags);
+			//MX_LOCK(&info->slock);
+
+			// following add by Victor Yu. 09-02-2002
+			if (info->IsMoxaMustChipFlag) {
+				info->IER |= MOXA_MUST_RECV_ISR;
+				outb(info->IER, info->base + UART_IER);
+			} else {
+				// above add by Victor Yu. 09-02-2002
+
+				info->x_char = START_CHAR(tty);
+				//          outb(info->IER, 0); // mask by Victor Yu. 09-02-2002
+				outb(0, info->base + UART_IER);	// add by Victor Yu. 09-02-2002
+				info->IER |= UART_IER_THRI;	/* force Tx interrupt */
+				outb(info->IER, info->base + UART_IER);
+			}	// add by Victor Yu. 09-02-2002
+			//MX_UNLOCK(&info->slock);
 		}
 	}
+
 	if (info->tty->termios->c_cflag & CRTSCTS) {
+		//MX_LOCK(&info->slock);
 		info->MCR |= UART_MCR_RTS;
-		save_flags(flags);
-		cli();
 		outb(info->MCR, info->base + UART_MCR);
-		restore_flags(flags);
+		//MX_UNLOCK(&info->slock);
 	}
 }
 
-static void mxser_set_termios(struct tty_struct *tty,
-			      struct termios *old_termios)
+/*
+ * This routine is called by the upper-layer tty layer to signal that
+ * incoming characters should be throttled.
+ */
+static void mxser_throttle(struct tty_struct *tty)
+{
+	//struct mxser_struct *info = (struct mxser_struct *)tty->driver_data;
+	//unsigned long flags;
+	//MX_LOCK(&info->slock);
+	mxser_stoprx(tty);
+	//MX_UNLOCK(&info->slock);
+}
+
+static void mxser_unthrottle(struct tty_struct *tty)
+{
+	//struct mxser_struct *info = (struct mxser_struct *)tty->driver_data;
+	//unsigned long flags;
+	//MX_LOCK(&info->slock);
+	mxser_startrx(tty);
+	//MX_UNLOCK(&info->slock);
+}
+
+static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios)
 {
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
+	unsigned long flags;
 
-/* 8-2-99 by William
-   if ( (tty->termios->c_cflag == old_termios->c_cflag) &&
-   (RELEVANT_IFLAG(tty->termios->c_iflag) ==
-   RELEVANT_IFLAG(old_termios->c_iflag)) )
-   return;
-
-   mxser_change_speed(info, old_termios);
-
-   if ( (old_termios->c_cflag & CRTSCTS) &&
-   !(tty->termios->c_cflag & CRTSCTS) ) {
-   tty->hw_stopped = 0;
-   mxser_start(tty);
-   }
- */
-	if ((tty->termios->c_cflag != old_termios->c_cflag) ||
-	    (RELEVANT_IFLAG(tty->termios->c_iflag) !=
-	     RELEVANT_IFLAG(old_termios->c_iflag))) {
+	if ((tty->termios->c_cflag != old_termios->c_cflag) || (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
 
 		mxser_change_speed(info, old_termios);
 
-		if ((old_termios->c_cflag & CRTSCTS) &&
-		    !(tty->termios->c_cflag & CRTSCTS)) {
+		if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios->c_cflag & CRTSCTS)) {
 			tty->hw_stopped = 0;
 			mxser_start(tty);
 		}
 	}
+
 /* Handle sw stopped */
-	if ((old_termios->c_iflag & IXON) &&
-	    !(tty->termios->c_iflag & IXON)) {
+	if ((old_termios->c_iflag & IXON) && !(tty->termios->c_iflag & IXON)) {
 		tty->stopped = 0;
+
+		// following add by Victor Yu. 09-02-2002
+		if (info->IsMoxaMustChipFlag) {
+			spin_lock_irqsave(&info->slock, flags);
+			DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base);
+			spin_unlock_irqrestore(&info->slock, flags);
+		}
+		// above add by Victor Yu. 09-02-2002
+
 		mxser_start(tty);
 	}
 }
@@ -1259,13 +1732,12 @@
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&info->slock, flags);
 	if (info->IER & UART_IER_THRI) {
 		info->IER &= ~UART_IER_THRI;
 		outb(info->IER, info->base + UART_IER);
 	}
-	restore_flags(flags);
+	spin_unlock_irqrestore(&info->slock, flags);
 }
 
 static void mxser_start(struct tty_struct *tty)
@@ -1273,17 +1745,79 @@
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
-	if (info->xmit_cnt && info->xmit_buf &&
-	    !(info->IER & UART_IER_THRI)) {
+	spin_lock_irqsave(&info->slock, flags);
+	if (info->xmit_cnt && info->xmit_buf && !(info->IER & UART_IER_THRI)) {
 		info->IER |= UART_IER_THRI;
 		outb(info->IER, info->base + UART_IER);
 	}
-	restore_flags(flags);
+	spin_unlock_irqrestore(&info->slock, flags);
 }
 
 /*
+ * mxser_wait_until_sent() --- wait until the transmitter is empty
+ */
+static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
+	unsigned long orig_jiffies, char_time;
+	int lsr;
+
+	if (info->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(KERN_DEBUG "In rs_wait_until_sent(%d) check=%lu...", timeout, char_time);
+	printk("jiff=%lu...", jiffies);
+#endif
+	while (!((lsr = inb(info->base + 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
+}
+
+
+/*
  * This routine is called by tty_hangup() when a hangup is signaled.
  */
 void mxser_hangup(struct tty_struct *tty)
@@ -1295,68 +1829,353 @@
 	info->event = 0;
 	info->count = 0;
 	info->flags &= ~ASYNC_NORMAL_ACTIVE;
-	info->tty = NULL;
+	info->tty = 0;
 	wake_up_interruptible(&info->open_wait);
 }
 
-static inline void mxser_receive_chars(struct mxser_struct *info,
-					 int *status)
+
+// added by James 03-12-2004.
+/*
+ * mxser_rs_break() --- routine which turns the break handling on or off
+ */
+static void mxser_rs_break(struct tty_struct *tty, int break_state)
+{
+	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
+	unsigned long flags;
+
+	spin_lock_irqsave(&info->slock, flags);
+	if (break_state == -1)
+		outb(inb(info->base + UART_LCR) | UART_LCR_SBC, info->base + UART_LCR);
+	else
+		outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, info->base + UART_LCR);
+	spin_unlock_irqrestore(&info->slock, flags);
+}
+
+// (above) added by James.
+
+
+/*
+ * This is the serial driver's generic interrupt routine
+ */
+static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	int status, iir, i;
+	struct mxser_struct *info;
+	struct mxser_struct *port;
+	int max, irqbits, bits, msr;
+	int pass_counter = 0;
+	int handled = IRQ_NONE;
+
+	port = 0;
+	//spin_lock(&gm_lock);
+
+	for (i = 0; i < MXSER_BOARDS; i++) {
+		if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) {
+			port = dev_id;
+			break;
+		}
+	}
+
+	if (i == MXSER_BOARDS) {
+		goto irq_stop;
+	}
+	if (port == 0) {
+		goto irq_stop;
+	}
+	max = mxser_numports[mxsercfg[i].board_type - 1];
+	while (1) {
+		irqbits = inb(port->vector) & port->vectormask;
+		if (irqbits == port->vectormask) {
+			break;
+		}
+
+		handled = IRQ_HANDLED;
+		for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
+			if (irqbits == port->vectormask) {
+				break;
+			}
+			if (bits & irqbits)
+				continue;
+			info = port + i;
+
+			// following add by Victor Yu. 09-13-2002
+			iir = inb(info->base + UART_IIR);
+			if (iir & UART_IIR_NO_INT)
+				continue;
+			iir &= MOXA_MUST_IIR_MASK;
+			if (!info->tty) {
+				status = inb(info->base + UART_LSR);
+				outb(0x27, info->base + UART_FCR);
+				inb(info->base + UART_MSR);
+				continue;
+			}
+			// above add by Victor Yu. 09-13-2002
+			/*
+			   if ( info->tty->flip.count < TTY_FLIPBUF_SIZE/4 ){
+			   info->IER |= MOXA_MUST_RECV_ISR;
+			   outb(info->IER, info->base + UART_IER);
+			   }
+			 */
+
+
+			/* mask by Victor Yu. 09-13-2002
+			   if ( !info->tty ||
+			   (inb(info->base + UART_IIR) & UART_IIR_NO_INT) )
+			   continue;
+			 */
+			/* mask by Victor Yu. 09-02-2002
+			   status = inb(info->base + UART_LSR) & info->read_status_mask;
+			 */
+
+			// following add by Victor Yu. 09-02-2002
+			status = inb(info->base + UART_LSR);
+
+			if (status & UART_LSR_PE) {
+				info->err_shadow |= NPPI_NOTIFY_PARITY;
+			}
+			if (status & UART_LSR_FE) {
+				info->err_shadow |= NPPI_NOTIFY_FRAMING;
+			}
+			if (status & UART_LSR_OE) {
+				info->err_shadow |= NPPI_NOTIFY_HW_OVERRUN;
+			}
+			if (status & UART_LSR_BI)
+				info->err_shadow |= NPPI_NOTIFY_BREAK;
+
+			if (info->IsMoxaMustChipFlag) {
+				/*
+				   if ( (status & 0x02) && !(status & 0x01) ) {
+				   outb(info->base+UART_FCR,  0x23);
+				   continue;
+				   }
+				 */
+				if (iir == MOXA_MUST_IIR_GDA || iir == MOXA_MUST_IIR_RDA || iir == MOXA_MUST_IIR_RTO || iir == MOXA_MUST_IIR_LSR)
+					mxser_receive_chars(info, &status);
+
+			} else {
+				// above add by Victor Yu. 09-02-2002
+
+				status &= info->read_status_mask;
+				if (status & UART_LSR_DR)
+					mxser_receive_chars(info, &status);
+			}
+			msr = inb(info->base + UART_MSR);
+			if (msr & UART_MSR_ANY_DELTA) {
+				mxser_check_modem_status(info, msr);
+			}
+			// following add by Victor Yu. 09-13-2002
+			if (info->IsMoxaMustChipFlag) {
+				if ((iir == 0x02) && (status & UART_LSR_THRE)) {
+					mxser_transmit_chars(info);
+				}
+			} else {
+				// above add by Victor Yu. 09-13-2002
+
+				if (status & UART_LSR_THRE) {
+/* 8-2-99 by William
+			    if ( info->x_char || (info->xmit_cnt > 0) )
+*/
+					mxser_transmit_chars(info);
+				}
+			}
+		}
+		if (pass_counter++ > MXSER_ISR_PASS_LIMIT) {
+			break;	/* Prevent infinite loops */
+		}
+	}
+
+      irq_stop:
+	//spin_unlock(&gm_lock);
+	return handled;
+}
+
+static void mxser_receive_chars(struct mxser_struct *info, int *status)
 {
 	struct tty_struct *tty = info->tty;
-	unsigned char ch;
+	unsigned char ch, gdl;
 	int ignored = 0;
 	int cnt = 0;
+	unsigned char *cp;
+	char *fp;
+	int count;
+	int recv_room;
+	int max = 256;
+	unsigned long flags;
+
+	spin_lock_irqsave(&info->slock, flags);
+
+	recv_room = tty->ldisc.receive_room(tty);
+	if ((recv_room == 0) && (!info->ldisc_stop_rx)) {
+		//mxser_throttle(tty);
+		mxser_stoprx(tty);
+		//return;
+	}
+
+	cp = tty->flip.char_buf;
+	fp = tty->flip.flag_buf;
+	count = 0;
+
+	// following add by Victor Yu. 09-02-2002
+	if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) {
+
+		if (*status & UART_LSR_SPECIAL) {
+			goto intr_old;
+		}
+		// following add by Victor Yu. 02-11-2004
+		if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID && (*status & MOXA_MUST_LSR_RERR))
+			goto intr_old;
+		// above add by Victor Yu. 02-14-2004
+		if (*status & MOXA_MUST_LSR_RERR)
+			goto intr_old;
+
+		gdl = inb(info->base + MOXA_MUST_GDL_REGISTER);
+
+		if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID)	// add by Victor Yu. 02-11-2004
+			gdl &= MOXA_MUST_GDL_MASK;
+		if (gdl >= recv_room) {
+			if (!info->ldisc_stop_rx) {
+				//mxser_throttle(tty);
+				mxser_stoprx(tty);
+			}
+			//return;
+		}
+		while (gdl--) {
+			ch = inb(info->base + UART_RX);
+			count++;
+			*cp++ = ch;
+			*fp++ = 0;
+			cnt++;
+			/*
+			   if((count>=HI_WATER) && (info->stop_rx==0)){
+			   mxser_stoprx(tty);
+			   info->stop_rx=1;
+			   break;
+			   } */
+		}
+		goto end_intr;
+	}
+intr_old:
+	// above add by Victor Yu. 09-02-2002
 
 	do {
+		if (max-- < 0)
+			break;
+		/*
+		   if((count>=HI_WATER) && (info->stop_rx==0)){
+		   mxser_stoprx(tty);
+		   info->stop_rx=1;
+		   break;
+		   }
+		 */
+
 		ch = inb(info->base + UART_RX);
+		// following add by Victor Yu. 09-02-2002
+		if (info->IsMoxaMustChipFlag && (*status & UART_LSR_OE) /*&& !(*status&UART_LSR_DR) */ )
+			outb(0x23, info->base + UART_FCR);
+		*status &= info->read_status_mask;
+		// above add by Victor Yu. 09-02-2002
 		if (*status & info->ignore_status_mask) {
 			if (++ignored > 100)
 				break;
 		} else {
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-				break;
-			tty->flip.count++;
+			count++;
 			if (*status & UART_LSR_SPECIAL) {
 				if (*status & UART_LSR_BI) {
-					*tty->flip.flag_buf_ptr++ = TTY_BREAK;
+					*fp++ = TTY_BREAK;
+/* added by casper 1/11/2000 */
+					info->icount.brk++;
+
+/* */
 					if (info->flags & ASYNC_SAK)
 						do_SAK(tty);
 				} else if (*status & UART_LSR_PE) {
-					*tty->flip.flag_buf_ptr++ = TTY_PARITY;
+					*fp++ = TTY_PARITY;
+/* added by casper 1/11/2000 */
+					info->icount.parity++;
+/* */
 				} else if (*status & UART_LSR_FE) {
-					*tty->flip.flag_buf_ptr++ = TTY_FRAME;
+					*fp++ = TTY_FRAME;
+/* added by casper 1/11/2000 */
+					info->icount.frame++;
+/* */
 				} else if (*status & UART_LSR_OE) {
-					*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
+					*fp++ = TTY_OVERRUN;
+/* added by casper 1/11/2000 */
+					info->icount.overrun++;
+/* */
 				} else
-					*tty->flip.flag_buf_ptr++ = 0;
+					*fp++ = 0;
 			} else
-				*tty->flip.flag_buf_ptr++ = 0;
-			*tty->flip.char_buf_ptr++ = ch;
+				*fp++ = 0;
+			*cp++ = ch;
 			cnt++;
+			if (cnt >= recv_room) {
+				if (!info->ldisc_stop_rx) {
+					//mxser_throttle(tty);
+					mxser_stoprx(tty);
+				}
+				break;
+			}
+
 		}
-		*status = inb(info->base + UART_LSR) & info->read_status_mask;
+
+		// following add by Victor Yu. 09-02-2002
+		if (info->IsMoxaMustChipFlag)
+			break;
+		// above add by Victor Yu. 09-02-2002
+
+		/* mask by Victor Yu. 09-02-2002
+		 *status = inb(info->base + UART_LSR) & info->read_status_mask;
+		 */
+		// following add by Victor Yu. 09-02-2002
+		*status = inb(info->base + UART_LSR);
+		// above add by Victor Yu. 09-02-2002
 	} while (*status & UART_LSR_DR);
+
+      end_intr:		// add by Victor Yu. 09-02-2002
+
 	mxvar_log.rxcnt[info->port] += cnt;
-	schedule_delayed_work(&tty->flip.work, 1);
+	info->mon_data.rxcnt += cnt;
+	info->mon_data.up_rxcnt += cnt;
+
+	tty->ldisc.receive_buf(tty, tty->flip.char_buf, tty->flip.flag_buf, count);
+	spin_unlock_irqrestore(&info->slock, flags);
 
 }
 
-static inline void mxser_transmit_chars(struct mxser_struct *info)
+static void mxser_transmit_chars(struct mxser_struct *info)
 {
 	int count, cnt;
+	unsigned long flags;
+
+	spin_lock_irqsave(&info->slock, flags);
 
 	if (info->x_char) {
 		outb(info->x_char, info->base + UART_TX);
 		info->x_char = 0;
 		mxvar_log.txcnt[info->port]++;
+		info->mon_data.txcnt++;
+		info->mon_data.up_txcnt++;
+
+/* added by casper 1/11/2000 */
+		info->icount.tx++;
+/* */
+		spin_unlock_irqrestore(&info->slock, flags);
+		return;
+	}
+
+	if (info->xmit_buf == 0) {
+		spin_unlock_irqrestore(&info->slock, flags);
 		return;
 	}
-	if ((info->xmit_cnt <= 0) || info->tty->stopped ||
-	    info->tty->hw_stopped) {
+
+	if ((info->xmit_cnt <= 0) || info->tty->stopped || (info->tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag))) {
 		info->IER &= ~UART_IER_THRI;
 		outb(info->IER, info->base + UART_IER);
+		spin_unlock_irqrestore(&info->slock, flags);
 		return;
 	}
+
 	cnt = info->xmit_cnt;
 	count = info->xmit_fifo_size;
 	do {
@@ -1367,6 +2186,15 @@
 	} while (--count > 0);
 	mxvar_log.txcnt[info->port] += (cnt - info->xmit_cnt);
 
+// added by James 03-12-2004.
+	info->mon_data.txcnt += (cnt - info->xmit_cnt);
+	info->mon_data.up_txcnt += (cnt - info->xmit_cnt);
+// (above) added by James.
+
+/* added by casper 1/11/2000 */
+	info->icount.tx += (cnt - info->xmit_cnt);
+/* */
+
 	if (info->xmit_cnt < WAKEUP_CHARS) {
 		set_bit(MXSER_EVENT_TXLOW, &info->event);
 		schedule_work(&info->tqueue);
@@ -1375,12 +2203,11 @@
 		info->IER &= ~UART_IER_THRI;
 		outb(info->IER, info->base + UART_IER);
 	}
+	spin_unlock_irqrestore(&info->slock, flags);
 }
 
-static inline void mxser_check_modem_status(struct mxser_struct *info,
-					      int status)
+static void mxser_check_modem_status(struct mxser_struct *info, int status)
 {
-
 	/* update input line counters */
 	if (status & UART_MSR_TERI)
 		info->icount.rng++;
@@ -1390,131 +2217,55 @@
 		info->icount.dcd++;
 	if (status & UART_MSR_DCTS)
 		info->icount.cts++;
+	info->mon_data.modem_status = status;
 	wake_up_interruptible(&info->delta_msr_wait);
 
+
 	if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
 		if (status & UART_MSR_DCD)
 			wake_up_interruptible(&info->open_wait);
-		else
-			set_bit(MXSER_EVENT_HANGUP, &info->event);
 		schedule_work(&info->tqueue);
 	}
+
 	if (info->flags & ASYNC_CTS_FLOW) {
 		if (info->tty->hw_stopped) {
 			if (status & UART_MSR_CTS) {
 				info->tty->hw_stopped = 0;
-				info->IER |= UART_IER_THRI;
-				outb(info->IER, info->base + UART_IER);
 
+				if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) {
+					info->IER |= UART_IER_THRI;
+					outb(info->IER, info->base + UART_IER);
+				}
 				set_bit(MXSER_EVENT_TXLOW, &info->event);
-				schedule_work(&info->tqueue);
-			}
+				schedule_work(&info->tqueue);			}
 		} else {
 			if (!(status & UART_MSR_CTS)) {
 				info->tty->hw_stopped = 1;
-				info->IER &= ~UART_IER_THRI;
-				outb(info->IER, info->base + UART_IER);
-			}
-		}
-	}
-}
-
-/*
- * This is the serial driver's generic interrupt routine
- */
-static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-	int status, i;
-	struct mxser_struct *info;
-	struct mxser_struct *port;
-	int max, irqbits, bits, msr;
-	int pass_counter = 0;
-	int handled = 0;
-
-	port = NULL;
-	for (i = 0; i < MXSER_BOARDS; i++) {
-		if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) {
-			port = dev_id;
-			break;
-		}
-	}
-
-	if (i == MXSER_BOARDS)
-		return IRQ_NONE;
-	if (port == 0)
-		return IRQ_NONE;
-	max = mxser_numports[mxsercfg[i].board_type];
-
-	while (1) {
-		irqbits = inb(port->vector) & port->vectormask;
-		if (irqbits == port->vectormask)
-			break;
-		handled = 1;
-		for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
-			if (irqbits == port->vectormask)
-				break;
-			if (bits & irqbits)
-				continue;
-			info = port + i;
-			if (!info->tty ||
-			  (inb(info->base + UART_IIR) & UART_IIR_NO_INT))
-				continue;
-			status = inb(info->base + UART_LSR) & info->read_status_mask;
-			if (status & UART_LSR_DR)
-				mxser_receive_chars(info, &status);
-			msr = inb(info->base + UART_MSR);
-			if (msr & UART_MSR_ANY_DELTA)
-				mxser_check_modem_status(info, msr);
-			if (status & UART_LSR_THRE) {
-/* 8-2-99 by William
-   if ( info->x_char || (info->xmit_cnt > 0) )
- */
-				mxser_transmit_chars(info);
+				if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) {
+					info->IER &= ~UART_IER_THRI;
+					outb(info->IER, info->base + UART_IER);
+				}
 			}
 		}
-		if (pass_counter++ > MXSER_ISR_PASS_LIMIT) {
-#if 0
-			printk("MOXA Smartio/Indusrtio family driver interrupt loop break\n");
-#endif
-			break;	/* Prevent infinite loops */
-		}
 	}
-	return IRQ_RETVAL(handled);
 }
 
-static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
-				 struct mxser_struct *info)
+static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, struct mxser_struct *info)
 {
 	DECLARE_WAITQUEUE(wait, current);
-	unsigned long flags;
 	int retval;
 	int do_clocal = 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
-		if (info->flags & ASYNC_HUP_NOTIFY)
-			return (-EAGAIN);
-		else
-			return (-ERESTARTSYS);
-#else
-		return (-EAGAIN);
-#endif
-	}
-	/*
 	 * 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 ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) {
 		info->flags |= ASYNC_NORMAL_ACTIVE;
 		return (0);
 	}
+
 	if (tty->termios->c_cflag & CLOCAL)
 		do_clocal = 1;
 
@@ -1527,32 +2278,25 @@
 	 */
 	retval = 0;
 	add_wait_queue(&info->open_wait, &wait);
-	save_flags(flags);
-	cli();
+
+	spin_lock_irqsave(&info->slock, flags);
 	if (!tty_hung_up_p(filp))
 		info->count--;
-	restore_flags(flags);
+	spin_unlock_irqrestore(&info->slock, flags);
 	info->blocked_open++;
 	while (1) {
-		save_flags(flags);
-		cli();
-		outb(inb(info->base + UART_MCR) | UART_MCR_DTR | UART_MCR_RTS,
-		     info->base + UART_MCR);
-		restore_flags(flags);
+		spin_lock_irqsave(&info->slock, flags);
+		outb(inb(info->base + UART_MCR) | UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR);
+		spin_unlock_irqrestore(&info->slock, 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_CLOSING) &&
-		    (do_clocal || (inb(info->base + UART_MSR) & UART_MSR_DCD)))
+		if (!(info->flags & ASYNC_CLOSING) && (do_clocal || (inb(info->base + UART_MSR) & UART_MSR_DCD)))
 			break;
 		if (signal_pending(current)) {
 			retval = -ERESTARTSYS;
@@ -1573,26 +2317,27 @@
 
 static int mxser_startup(struct mxser_struct *info)
 {
-	unsigned long flags;
+
 	unsigned long page;
+	unsigned long flags;
 
-	page = get_zeroed_page(GFP_KERNEL);
+	page = __get_free_page(GFP_KERNEL);
 	if (!page)
 		return (-ENOMEM);
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&info->slock, flags);
 
 	if (info->flags & ASYNC_INITIALIZED) {
 		free_page(page);
-		restore_flags(flags);
+		spin_unlock_irqrestore(&info->slock, flags);
 		return (0);
 	}
+
 	if (!info->base || !info->type) {
 		if (info->tty)
 			set_bit(TTY_IO_ERROR, &info->tty->flags);
 		free_page(page);
-		restore_flags(flags);
+		spin_unlock_irqrestore(&info->slock, flags);
 		return (0);
 	}
 	if (info->xmit_buf)
@@ -1604,9 +2349,10 @@
 	 * Clear the FIFO buffers and disable them
 	 * (they will be reenabled in mxser_change_speed())
 	 */
-	if (info->xmit_fifo_size == 16)
-		outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
-		     info->base + UART_FCR);
+	if (info->IsMoxaMustChipFlag)
+		outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR);
+	else
+		outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR);
 
 	/*
 	 * At this point there's no way the LSR could still be 0xFF;
@@ -1614,7 +2360,7 @@
 	 * here.
 	 */
 	if (inb(info->base + UART_LSR) == 0xff) {
-		restore_flags(flags);
+		spin_unlock_irqrestore(&info->slock, flags);
 		if (capable(CAP_SYS_ADMIN)) {
 			if (info->tty)
 				set_bit(TTY_IO_ERROR, &info->tty->flags);
@@ -1622,6 +2368,7 @@
 		} else
 			return (-ENODEV);
 	}
+
 	/*
 	 * Clear the interrupt registers.
 	 */
@@ -1641,7 +2388,13 @@
 	 * Finally, enable interrupts
 	 */
 	info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI;
-	outb(info->IER, info->base + UART_IER);		/* enable interrupts */
+//      info->IER = UART_IER_RLSI | UART_IER_RDI;
+
+	// following add by Victor Yu. 08-30-2002
+	if (info->IsMoxaMustChipFlag)
+		info->IER |= MOXA_MUST_IER_EGDAI;
+	// above add by Victor Yu. 08-30-2002
+	outb(info->IER, info->base + UART_IER);	/* enable interrupts */
 
 	/*
 	 * And clear the interrupt registers again for luck.
@@ -1652,17 +2405,16 @@
 	(void) inb(info->base + UART_MSR);
 
 	if (info->tty)
-		test_and_clear_bit(TTY_IO_ERROR, &info->tty->flags);
-
+		clear_bit(TTY_IO_ERROR, &info->tty->flags);
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 
 	/*
 	 * and set the speed of the serial port
 	 */
-	mxser_change_speed(info, NULL);
+	spin_unlock_irqrestore(&info->slock, flags);
+	mxser_change_speed(info, 0);
 
 	info->flags |= ASYNC_INITIALIZED;
-	restore_flags(flags);
 	return (0);
 }
 
@@ -1677,8 +2429,7 @@
 	if (!(info->flags & ASYNC_INITIALIZED))
 		return;
 
-	save_flags(flags);
-	cli();			/* Disable interrupts */
+	spin_lock_irqsave(&info->slock, flags);
 
 	/*
 	 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
@@ -1691,17 +2442,24 @@
 	 */
 	if (info->xmit_buf) {
 		free_page((unsigned long) info->xmit_buf);
-		info->xmit_buf = NULL;
+		info->xmit_buf = 0;
 	}
+
 	info->IER = 0;
-	outb(0x00, info->base + UART_IER);	/* disable all intrs */
+	outb(0x00, info->base + UART_IER);
 
 	if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
 		info->MCR &= ~(UART_MCR_DTR | UART_MCR_RTS);
 	outb(info->MCR, info->base + UART_MCR);
 
 	/* clear Rx/Tx FIFO's */
-	outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR);
+	// following add by Victor Yu. 08-30-2002
+	if (info->IsMoxaMustChipFlag)
+		outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR);
+	else
+		// above add by Victor Yu. 08-30-2002
+		outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR);
+
 	/* read data port to reset things */
 	(void) inb(info->base + UART_RX);
 
@@ -1709,229 +2467,108 @@
 		set_bit(TTY_IO_ERROR, &info->tty->flags);
 
 	info->flags &= ~ASYNC_INITIALIZED;
-	restore_flags(flags);
+
+	// following add by Victor Yu. 09-23-2002
+	if (info->IsMoxaMustChipFlag) {
+		SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->base);
+	}
+	// above add by Victor Yu. 09-23-2002
+
+	spin_unlock_irqrestore(&info->slock, flags);
 }
 
 /*
  * This routine is called to set the UART divisor registers to match
  * the specified baud rate for a serial port.
  */
-static int mxser_change_speed(struct mxser_struct *info,
-			      struct termios *old_termios)
+static int mxser_change_speed(struct mxser_struct *info, struct termios *old_termios)
 {
-	int quot = 0;
 	unsigned cflag, cval, fcr;
-	int i;
 	int ret = 0;
+	unsigned char status;
+	long baud;
 	unsigned long flags;
 
+
 	if (!info->tty || !info->tty->termios)
 		return ret;
 	cflag = info->tty->termios->c_cflag;
 	if (!(info->base))
 		return ret;
 
+
 #ifndef B921600
 #define B921600 (B460800 +1)
 #endif
-	switch (cflag & (CBAUD | CBAUDEX)) {
-	case B921600:
-		i = 20;
-		break;
-	case B460800:
-		i = 19;
-		break;
-	case B230400:
-		i = 18;
-		break;
-	case B115200:
-		i = 17;
-		break;
-	case B57600:
-		i = 16;
-		break;
-	case B38400:
-		i = 15;
-		break;
-	case B19200:
-		i = 14;
-		break;
-	case B9600:
-		i = 13;
-		break;
-	case B4800:
-		i = 12;
-		break;
-	case B2400:
-		i = 11;
-		break;
-	case B1800:
-		i = 10;
-		break;
-	case B1200:
-		i = 9;
-		break;
-	case B600:
-		i = 8;
-		break;
-	case B300:
-		i = 7;
-		break;
-	case B200:
-		i = 6;
-		break;
-	case B150:
-		i = 5;
-		break;
-	case B134:
-		i = 4;
-		break;
-	case B110:
-		i = 3;
-		break;
-	case B75:
-		i = 2;
-		break;
-	case B50:
-		i = 1;
-		break;
-	default:
-		i = 0;
-		break;
-	}
-
-	if (i == 15) {
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
-			i = 16;	/* 57600 bps */
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
-			i = 17;	/* 115200 bps */
-
-#ifdef ASYNC_SPD_SHI
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
-			i = 18;
-#endif
-
-#ifdef ASYNC_SPD_WARP
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
-			i = 19;
-#endif
-	}
-	if (mxvar_baud_table[i] == 134) {
-		quot = (2 * info->baud_base / 269);
-	} else if (mxvar_baud_table[i]) {
-		quot = info->baud_base / mxvar_baud_table[i];
-		if (!quot && old_termios) {
-			/* re-calculate */
-			info->tty->termios->c_cflag &= ~CBAUD;
-			info->tty->termios->c_cflag |= (old_termios->c_cflag & CBAUD);
-			switch (info->tty->termios->c_cflag & (CBAUD | CBAUDEX)) {
-			case B921600:
-				i = 20;
-				break;
-			case B460800:
-				i = 19;
-				break;
-			case B230400:
-				i = 18;
-				break;
-			case B115200:
-				i = 17;
-				break;
-			case B57600:
-				i = 16;
-				break;
-			case B38400:
-				i = 15;
-				break;
-			case B19200:
-				i = 14;
-				break;
-			case B9600:
-				i = 13;
-				break;
-			case B4800:
-				i = 12;
-				break;
-			case B2400:
-				i = 11;
-				break;
-			case B1800:
-				i = 10;
-				break;
-			case B1200:
-				i = 9;
-				break;
-			case B600:
-				i = 8;
-				break;
-			case B300:
-				i = 7;
-				break;
-			case B200:
-				i = 6;
-				break;
-			case B150:
-				i = 5;
-				break;
-			case B134:
-				i = 4;
-				break;
-			case B110:
-				i = 3;
-				break;
-			case B75:
-				i = 2;
-				break;
-			case B50:
-				i = 1;
-				break;
-			default:
-				i = 0;
-				break;
-			}
-			if (i == 15) {
-				if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
-					i = 16;		/* 57600 bps */
-				if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
-					i = 17;		/* 115200 bps */
-#ifdef ASYNC_SPD_SHI
-				if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
-					i = 18;
-#endif
-#ifdef ASYNC_SPD_WARP
-				if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
-					i = 19;
-#endif
-			}
-			if (mxvar_baud_table[i] == 134) {
-				quot = (2 * info->baud_base / 269);
-			} else if (mxvar_baud_table[i]) {
-				quot = info->baud_base / mxvar_baud_table[i];
-				if (quot == 0)
-					quot = 1;
-			} else {
-				quot = 0;
-			}
-		} else if (quot == 0)
-			quot = 1;
-	} else {
-		quot = 0;
+	if (mxser_set_baud_method[info->port] == 0) {
+		switch (cflag & (CBAUD | CBAUDEX)) {
+		case B921600:
+			baud = 921600;
+			break;
+		case B460800:
+			baud = 460800;
+			break;
+		case B230400:
+			baud = 230400;
+			break;
+		case B115200:
+			baud = 115200;
+			break;
+		case B57600:
+			baud = 57600;
+			break;
+		case B38400:
+			baud = 38400;
+			break;
+		case B19200:
+			baud = 19200;
+			break;
+		case B9600:
+			baud = 9600;
+			break;
+		case B4800:
+			baud = 4800;
+			break;
+		case B2400:
+			baud = 2400;
+			break;
+		case B1800:
+			baud = 1800;
+			break;
+		case B1200:
+			baud = 1200;
+			break;
+		case B600:
+			baud = 600;
+			break;
+		case B300:
+			baud = 300;
+			break;
+		case B200:
+			baud = 200;
+			break;
+		case B150:
+			baud = 150;
+			break;
+		case B134:
+			baud = 134;
+			break;
+		case B110:
+			baud = 110;
+			break;
+		case B75:
+			baud = 75;
+			break;
+		case B50:
+			baud = 50;
+			break;
+		default:
+			baud = 0;
+			break;
+		}
+		mxser_set_baud(info, baud);
 	}
 
-	if (quot) {
-		info->MCR |= UART_MCR_DTR;
-		save_flags(flags);
-		cli();
-		outb(info->MCR, info->base + UART_MCR);
-		restore_flags(flags);
-	} else {
-		info->MCR &= ~UART_MCR_DTR;
-		save_flags(flags);
-		cli();
-		outb(info->MCR, info->base + UART_MCR);
-		restore_flags(flags);
-		return ret;
-	}
 	/* byte size and parity */
 	switch (cflag & CSIZE) {
 	case CS5:
@@ -1954,24 +2591,45 @@
 		cval |= 0x04;
 	if (cflag & PARENB)
 		cval |= UART_LCR_PARITY;
-	if (!(cflag & PARODD))
+#ifndef CMSPAR
+#define	CMSPAR 010000000000
+#endif
+	if (!(cflag & PARODD)) {
 		cval |= UART_LCR_EPAR;
+	}
+	if (cflag & CMSPAR)
+		cval |= UART_LCR_SPAR;
+
 	if ((info->type == PORT_8250) || (info->type == PORT_16450)) {
-		fcr = 0;
+		if (info->IsMoxaMustChipFlag) {
+			fcr = UART_FCR_ENABLE_FIFO;
+			fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
+			SET_MOXA_MUST_FIFO_VALUE(info);
+		} else
+			fcr = 0;
 	} else {
 		fcr = UART_FCR_ENABLE_FIFO;
-		switch (info->rx_trigger) {
-		case 1:
-			fcr |= UART_FCR_TRIGGER_1;
-			break;
-		case 4:
-			fcr |= UART_FCR_TRIGGER_4;
-			break;
-		case 8:
-			fcr |= UART_FCR_TRIGGER_8;
-			break;
-		default:
-			fcr |= UART_FCR_TRIGGER_14;
+		// following add by Victor Yu. 08-30-2002
+		if (info->IsMoxaMustChipFlag) {
+			fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
+			SET_MOXA_MUST_FIFO_VALUE(info);
+		} else {
+			// above add by Victor Yu. 08-30-2002
+
+			switch (info->rx_trigger) {
+			case 1:
+				fcr |= UART_FCR_TRIGGER_1;
+				break;
+			case 4:
+				fcr |= UART_FCR_TRIGGER_4;
+				break;
+			case 8:
+				fcr |= UART_FCR_TRIGGER_8;
+				break;
+			default:
+				fcr |= UART_FCR_TRIGGER_14;
+				break;
+			}
 		}
 	}
 
@@ -1981,15 +2639,46 @@
 	if (cflag & CRTSCTS) {
 		info->flags |= ASYNC_CTS_FLOW;
 		info->IER |= UART_IER_MSI;
-		if (info->type == PORT_16550A)
+		if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) {
 			info->MCR |= UART_MCR_AFE;
+			//status = mxser_get_msr(info->base, 0, info->port);
+/*	save_flags(flags);
+	cli();
+	status = inb(baseaddr + UART_MSR);
+	restore_flags(flags);*/
+			//mxser_check_modem_status(info, status);
+		} else {
+			//status = mxser_get_msr(info->base, 0, info->port);
+
+			//MX_LOCK(&info->slock);
+			status = inb(info->base + UART_MSR);
+			//MX_UNLOCK(&info->slock);
+			if (info->tty->hw_stopped) {
+				if (status & UART_MSR_CTS) {
+					info->tty->hw_stopped = 0;
+					if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) {
+						info->IER |= UART_IER_THRI;
+						outb(info->IER, info->base + UART_IER);
+					}
+					set_bit(MXSER_EVENT_TXLOW, &info->event);
+					schedule_work(&info->tqueue);				}
+			} else {
+				if (!(status & UART_MSR_CTS)) {
+					info->tty->hw_stopped = 1;
+					if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) {
+						info->IER &= ~UART_IER_THRI;
+						outb(info->IER, info->base + UART_IER);
+					}
+				}
+			}
+		}
 	} else {
 		info->flags &= ~ASYNC_CTS_FLOW;
 	}
 	outb(info->MCR, info->base + UART_MCR);
-	if (cflag & CLOCAL)
+	if (cflag & CLOCAL) {
 		info->flags &= ~ASYNC_CHECK_CD;
-	else {
+	} else {
 		info->flags |= ASYNC_CHECK_CD;
 		info->IER |= UART_IER_MSI;
 	}
@@ -2005,13 +2694,7 @@
 		info->read_status_mask |= UART_LSR_BI;
 
 	info->ignore_status_mask = 0;
-#if 0
-	/* This should be safe, but for some broken bits of hardware... */
-	if (I_IGNPAR(info->tty)) {
-		info->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
-		info->read_status_mask |= UART_LSR_PE | UART_LSR_FE;
-	}
-#endif
+
 	if (I_IGNBRK(info->tty)) {
 		info->ignore_status_mask |= UART_LSR_BI;
 		info->read_status_mask |= UART_LSR_BI;
@@ -2024,25 +2707,107 @@
 			info->read_status_mask |= UART_LSR_OE | UART_LSR_PE | UART_LSR_FE;
 		}
 	}
-	save_flags(flags);
-	cli();
+	// following add by Victor Yu. 09-02-2002
+	if (info->IsMoxaMustChipFlag) {
+		spin_lock_irqsave(&info->slock, flags);
+		SET_MOXA_MUST_XON1_VALUE(info->base, START_CHAR(info->tty));
+		SET_MOXA_MUST_XOFF1_VALUE(info->base, STOP_CHAR(info->tty));
+		if (I_IXON(info->tty)) {
+			ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base);
+		} else {
+			DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base);
+		}
+		if (I_IXOFF(info->tty)) {
+			ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->base);
+		} else {
+			DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->base);
+		}
+		/*
+		   if ( I_IXANY(info->tty) ) {
+		   info->MCR |= MOXA_MUST_MCR_XON_ANY;
+		   ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->base);
+		   } else {
+		   info->MCR &= ~MOXA_MUST_MCR_XON_ANY;
+		   DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(info->base);
+		   }
+		 */
+		spin_unlock_irqrestore(&info->slock, flags);
+	}
+	// above add by Victor Yu. 09-02-2002
+
+
+	outb(fcr, info->base + UART_FCR);	/* set fcr */
+	outb(cval, info->base + UART_LCR);
+
+	return ret;
+}
+
+
+static int mxser_set_baud(struct mxser_struct *info, long newspd)
+{
+	int quot = 0;
+	unsigned char cval;
+	int ret = 0;
+	unsigned long flags;
+
+	if (!info->tty || !info->tty->termios)
+		return ret;
+
+	if (!(info->base))
+		return ret;
+
+	if (newspd > info->MaxCanSetBaudRate)
+		return 0;
+
+	info->realbaud = newspd;
+	if (newspd == 134) {
+		quot = (2 * info->baud_base / 269);
+	} else if (newspd) {
+		quot = info->baud_base / newspd;
+
+		if (quot == 0)
+			quot = 1;
+
+	} else {
+		quot = 0;
+	}
+
+	info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
+	info->timeout += HZ / 50;	/* Add .02 seconds of slop */
+
+	if (quot) {
+		spin_lock_irqsave(&info->slock, flags);
+		info->MCR |= UART_MCR_DTR;
+		outb(info->MCR, info->base + UART_MCR);
+		spin_unlock_irqrestore(&info->slock, flags);
+	} else {
+		spin_lock_irqsave(&info->slock, flags);
+		info->MCR &= ~UART_MCR_DTR;
+		outb(info->MCR, info->base + UART_MCR);
+		spin_unlock_irqrestore(&info->slock, flags);
+		return ret;
+	}
+
+	cval = inb(info->base + UART_LCR);
+
 	outb(cval | UART_LCR_DLAB, info->base + UART_LCR);	/* set DLAB */
+
 	outb(quot & 0xff, info->base + UART_DLL);	/* LS of divisor */
-	outb(quot >> 8, info->base + UART_DLM);		/* MS of divisor */
+	outb(quot >> 8, info->base + UART_DLM);	/* MS of divisor */
 	outb(cval, info->base + UART_LCR);	/* reset DLAB */
-	outb(fcr, info->base + UART_FCR);	/* set fcr */
-	restore_flags(flags);
+
 
 	return ret;
 }
 
+
+
 /*
  * ------------------------------------------------------------
  * friends of mxser_ioctl()
  * ------------------------------------------------------------
  */
-static int mxser_get_serial_info(struct mxser_struct *info,
-				 struct serial_struct __user *retinfo)
+static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct *retinfo)
 {
 	struct serial_struct tmp;
 
@@ -2059,11 +2824,12 @@
 	tmp.closing_wait = info->closing_wait;
 	tmp.custom_divisor = info->custom_divisor;
 	tmp.hub6 = 0;
-	return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
+	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
+		return -EFAULT;
+	return (0);
 }
 
-static int mxser_set_serial_info(struct mxser_struct *info,
-				 struct serial_struct __user *new_info)
+static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct *new_info)
 {
 	struct serial_struct new_serial;
 	unsigned int flags;
@@ -2074,40 +2840,40 @@
 	if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
 		return -EFAULT;
 
-	if ((new_serial.irq != info->irq) ||
-	    (new_serial.port != info->base) ||
-	    (new_serial.type != info->type) ||
-	    (new_serial.custom_divisor != info->custom_divisor) ||
-	    (new_serial.baud_base != info->baud_base))
+	if ((new_serial.irq != info->irq) || (new_serial.port != info->base) || (new_serial.custom_divisor != info->custom_divisor) || (new_serial.baud_base != info->baud_base))
 		return (-EPERM);
 
 	flags = info->flags & ASYNC_SPD_MASK;
 
 	if (!capable(CAP_SYS_ADMIN)) {
-		if ((new_serial.baud_base != info->baud_base) ||
-		    (new_serial.close_delay != info->close_delay) ||
-		    ((new_serial.flags & ~ASYNC_USR_MASK) !=
-		     (info->flags & ~ASYNC_USR_MASK)))
+		if ((new_serial.baud_base != info->baud_base) || (new_serial.close_delay != info->close_delay) || ((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK)))
 			return (-EPERM);
-		info->flags = ((info->flags & ~ASYNC_USR_MASK) |
-			       (new_serial.flags & ASYNC_USR_MASK));
+		info->flags = ((info->flags & ~ASYNC_USR_MASK) | (new_serial.flags & ASYNC_USR_MASK));
 	} else {
 		/*
 		 * OK, past this point, all the error checking has been done.
 		 * At this point, we start making changes.....
 		 */
-		info->flags = ((info->flags & ~ASYNC_FLAGS) |
-			       (new_serial.flags & ASYNC_FLAGS));
+		info->flags = ((info->flags & ~ASYNC_FLAGS) | (new_serial.flags & ASYNC_FLAGS));
 		info->close_delay = new_serial.close_delay * HZ / 100;
 		info->closing_wait = new_serial.closing_wait * HZ / 100;
+		info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+		info->tty->low_latency = 0;	//(info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 	}
 
+	/* added by casper, 3/17/2000, for mouse */
+	info->type = new_serial.type;
+
+	process_txrx_fifo(info);
+
+	/* */
 	if (info->flags & ASYNC_INITIALIZED) {
 		if (flags != (info->flags & ASYNC_SPD_MASK)) {
-			mxser_change_speed(info, NULL);
+			mxser_change_speed(info, 0);
 		}
-	} else
+	} else {
 		retval = mxser_startup(info);
+	}
 	return (retval);
 }
 
@@ -2115,22 +2881,21 @@
  * mxser_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.
+ *	    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 mxser_get_lsr_info(struct mxser_struct *info, unsigned int __user *value)
+static int mxser_get_lsr_info(struct mxser_struct *info, unsigned int *value)
 {
 	unsigned char status;
 	unsigned int result;
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&info->slock, flags);
 	status = inb(info->base + UART_LSR);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&info->slock, flags);
 	result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
 	return put_user(result, value);
 }
@@ -2141,15 +2906,17 @@
 static void mxser_send_break(struct mxser_struct *info, int duration)
 {
 	unsigned long flags;
+
 	if (!info->base)
 		return;
 	set_current_state(TASK_INTERRUPTIBLE);
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&info->slock, flags);
 	outb(inb(info->base + UART_LCR) | UART_LCR_SBC, info->base + UART_LCR);
+	spin_unlock_irqrestore(&info->slock, flags);
 	schedule_timeout(duration);
+	spin_lock_irqsave(&info->slock, flags);
 	outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, info->base + UART_LCR);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&info->slock, flags);
 }
 
 static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
@@ -2158,39 +2925,36 @@
 	unsigned char control, status;
 	unsigned long flags;
 
-	if (PORTNO(tty) == MXSER_PORTS)
+
+	if (tty->index == MXSER_PORTS)
 		return (-ENOIOCTLCMD);
 	if (tty->flags & (1 << TTY_IO_ERROR))
 		return (-EIO);
 
 	control = info->MCR;
-	save_flags(flags);
-	cli();
+
+	spin_lock_irqsave(&info->slock, flags);
 	status = inb(info->base + UART_MSR);
 	if (status & UART_MSR_ANY_DELTA)
 		mxser_check_modem_status(info, status);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&info->slock, flags);
 	return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) |
-	    ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) |
-	    ((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);
+	    ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) | ((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);
 }
 
-static int mxser_tiocmset(struct tty_struct *tty, struct file *file,
-			  unsigned int set, unsigned int clear)
+static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear)
 {
 	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;
 	unsigned long flags;
 
-	if (PORTNO(tty) == MXSER_PORTS)
-		return (-ENOIOCTLCMD);
+
+	if (tty->index == MXSER_PORTS)
+		return -ENOIOCTLCMD;
 	if (tty->flags & (1 << TTY_IO_ERROR))
-		return (-EIO);
+		return -EIO;
+
+	spin_lock_irqsave(&info->slock, flags);
 
-	save_flags(flags);
-	cli();
 	if (set & TIOCM_RTS)
 		info->MCR |= UART_MCR_RTS;
 	if (set & TIOCM_DTR)
@@ -2202,10 +2966,11 @@
 		info->MCR &= ~UART_MCR_DTR;
 
 	outb(info->MCR, info->base + UART_MCR);
-	restore_flags(flags);
-	return (0);
+	spin_unlock_irqrestore(&info->slock, flags);
+	return 0;
 }
 
+
 static int mxser_read_register(int, unsigned short *);
 static int mxser_program_mode(int);
 static void mxser_normal_mode(int);
@@ -2216,33 +2981,56 @@
 	unsigned short regs[16], irq;
 	unsigned char scratch, scratch2;
 
+	hwconf->IsMoxaMustChipFlag = MOXA_OTHER_UART;
+
 	id = mxser_read_register(cap, regs);
-	if (id == C168_ASIC_ID)
+	if (id == C168_ASIC_ID) {
 		hwconf->board_type = MXSER_BOARD_C168_ISA;
-	else if (id == C104_ASIC_ID)
+		hwconf->ports = 8;
+	} else if (id == C104_ASIC_ID) {
 		hwconf->board_type = MXSER_BOARD_C104_ISA;
-	else if (id == C102_ASIC_ID)
+		hwconf->ports = 4;
+	} else if (id == C102_ASIC_ID) {
 		hwconf->board_type = MXSER_BOARD_C102_ISA;
-	else if (id == CI132_ASIC_ID)
+		hwconf->ports = 2;
+	} else if (id == CI132_ASIC_ID) {
 		hwconf->board_type = MXSER_BOARD_CI132;
-	else if (id == CI134_ASIC_ID)
+		hwconf->ports = 2;
+	} else if (id == CI134_ASIC_ID) {
 		hwconf->board_type = MXSER_BOARD_CI134;
-	else if (id == CI104J_ASIC_ID)
+		hwconf->ports = 4;
+	} else if (id == CI104J_ASIC_ID) {
 		hwconf->board_type = MXSER_BOARD_CI104J;
-	else
+		hwconf->ports = 4;
+	} else
 		return (0);
-	irq = regs[9] & 0x0F;
-	irq = irq | (irq << 4);
-	irq = irq | (irq << 8);
-	if ((irq != regs[9]) || ((id == 1) && (irq != regs[10]))) {
-		return (MXSER_ERR_IRQ_CONFLIT);
+
+	irq = 0;
+	if (hwconf->ports == 2) {
+		irq = regs[9] & 0xF000;
+		irq = irq | (irq >> 4);
+		if (irq != (regs[9] & 0xFF00))
+			return (MXSER_ERR_IRQ_CONFLIT);
+	} else if (hwconf->ports == 4) {
+		irq = regs[9] & 0xF000;
+		irq = irq | (irq >> 4);
+		irq = irq | (irq >> 8);
+		if (irq != regs[9])
+			return (MXSER_ERR_IRQ_CONFLIT);
+	} else if (hwconf->ports == 8) {
+		irq = regs[9] & 0xF000;
+		irq = irq | (irq >> 4);
+		irq = irq | (irq >> 8);
+		if ((irq != regs[9]) || (irq != regs[10]))
+			return (MXSER_ERR_IRQ_CONFLIT);
 	}
+
 	if (!irq) {
 		return (MXSER_ERR_IRQ);
 	}
+	hwconf->irq = ((int) (irq & 0xF000) >> 12);
 	for (i = 0; i < 8; i++)
 		hwconf->ioaddr[i] = (int) regs[i + 1] & 0xFFF8;
-	hwconf->irq = (int) (irq & 0x0F);
 	if ((regs[12] & 0x80) == 0) {
 		return (MXSER_ERR_VECTOR);
 	}
@@ -2252,10 +3040,13 @@
 	else
 		hwconf->vector_mask = 0x000F;
 	for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) {
-		if (regs[12] & bits)
+		if (regs[12] & bits) {
 			hwconf->baud_base[i] = 921600;
-		else
+			hwconf->MaxCanSetBaudRate[i] = 921600;	// add by Victor Yu. 09-04-2002
+		} else {
 			hwconf->baud_base[i] = 115200;
+			hwconf->MaxCanSetBaudRate[i] = 115200;	// add by Victor Yu. 09-04-2002
+		}
 	}
 	scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB);
 	outb(scratch2 | UART_LCR_DLAB, cap + UART_LCR);
@@ -2263,6 +3054,7 @@
 	outb(scratch2, cap + UART_LCR);
 	outb(UART_FCR_ENABLE_FIFO, cap + UART_FCR);
 	scratch = inb(cap + UART_IIR);
+
 	if (scratch & 0xC0)
 		hwconf->uart_type = PORT_16550A;
 	else
@@ -2271,6 +3063,8 @@
 		hwconf->ports = 8;
 	else
 		hwconf->ports = 4;
+	request_region(hwconf->ioaddr[0], 8 * hwconf->ports, "mxser(IO)");
+	request_region(hwconf->vector, 1, "mxser(vector)");
 	return (hwconf->ports);
 }
 
@@ -2325,10 +3119,9 @@
 static int mxser_program_mode(int port)
 {
 	int id, i, j, n;
-	unsigned long flags;
+	//unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock(&gm_lock);
 	outb(0, port);
 	outb(0, port);
 	outb(0, port);
@@ -2336,10 +3129,11 @@
 	(void) inb(port);
 	outb(0, port);
 	(void) inb(port);
-	restore_flags(flags);
+	//restore_flags(flags);
+	spin_unlock(&gm_lock);
+
 	id = inb(port + 1) & 0x1F;
-	if ((id != C168_ASIC_ID) && (id != C104_ASIC_ID) && (id != CI104J_ASIC_ID) &&
-		(id != C102_ASIC_ID) &&	(id != CI132_ASIC_ID) && (id != CI134_ASIC_ID))
+	if ((id != C168_ASIC_ID) && (id != C104_ASIC_ID) && (id != C102_ASIC_ID) && (id != CI132_ASIC_ID) && (id != CI134_ASIC_ID) && (id != CI104J_ASIC_ID))
 		return (-1);
 	for (i = 0, j = 0; i < 4; i++) {
 		n = inb(port + 2);
@@ -2374,6 +3168,23 @@
 			(void) inb(port);
 	}
 	outb(0x00, port + 4);
+}
+
+// added by James 03-05-2004.
+// for secure device server:
+// stat = 1, the port8 DTR is set to ON.
+// stat = 0, the port8 DTR is set to OFF.
+void SDS_PORT8_DTR(int stat)
+{
+	int _sds_oldmcr;
+	_sds_oldmcr = inb(mxvar_table[7].base + UART_MCR);	// get old MCR
+	if (stat == 1) {
+		outb(_sds_oldmcr | 0x01, mxvar_table[7].base + UART_MCR);	// set DTR ON
+	}
+	if (stat == 0) {
+		outb(_sds_oldmcr & 0xfe, mxvar_table[7].base + UART_MCR);	// set DTR OFF
+	}
+	return;
 }
 
 module_init(mxser_module_init);
diff -Nru a/drivers/char/mxser.h b/drivers/char/mxser.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/char/mxser.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,450 @@
+#ifndef _MXSER_H
+#define _MXSER_H
+
+/*
+ *	Semi-public control interfaces
+ */
+ 
+/*
+ *	MOXA ioctls
+ */
+
+#define MOXA			0x400
+#define MOXA_GETDATACOUNT	(MOXA + 23)
+#define	MOXA_GET_CONF		(MOXA + 35)
+#define MOXA_DIAGNOSE		(MOXA + 50)
+#define MOXA_CHKPORTENABLE	(MOXA + 60)
+#define MOXA_HighSpeedOn	(MOXA + 61)
+#define MOXA_GET_MAJOR		(MOXA + 63)
+#define MOXA_GET_CUMAJOR	(MOXA + 64)
+#define MOXA_GETMSTATUS		(MOXA + 65)
+#define MOXA_SET_OP_MODE	(MOXA + 66)
+#define MOXA_GET_OP_MODE	(MOXA + 67)
+
+#define RS232_MODE		0
+#define RS485_2WIRE_MODE	1
+#define RS422_MODE		2
+#define RS485_4WIRE_MODE	3
+#define OP_MODE_MASK		3
+// above add by Victor Yu. 01-05-2004
+
+#define TTY_THRESHOLD_THROTTLE  128
+
+#define LO_WATER	 	(TTY_FLIPBUF_SIZE)
+#define HI_WATER		(TTY_FLIPBUF_SIZE*2*3/4)
+
+// added by James. 03-11-2004.
+#define MOXA_SDS_GETICOUNTER  	(MOXA + 68)
+#define MOXA_SDS_RSTICOUNTER  	(MOXA + 69)
+// (above) added by James.
+
+#define MOXA_ASPP_OQUEUE  	(MOXA + 70)
+#define MOXA_ASPP_SETBAUD 	(MOXA + 71)
+#define MOXA_ASPP_GETBAUD 	(MOXA + 72)
+#define MOXA_ASPP_MON     	(MOXA + 73)
+#define MOXA_ASPP_LSTATUS 	(MOXA + 74)
+#define MOXA_ASPP_MON_EXT 	(MOXA + 75)
+#define MOXA_SET_BAUD_METHOD	(MOXA + 76)
+
+
+/* --------------------------------------------------- */
+
+#define NPPI_NOTIFY_PARITY	0x01
+#define NPPI_NOTIFY_FRAMING	0x02
+#define NPPI_NOTIFY_HW_OVERRUN	0x04
+#define NPPI_NOTIFY_SW_OVERRUN	0x08
+#define NPPI_NOTIFY_BREAK	0x10
+
+#define NPPI_NOTIFY_CTSHOLD         0x01	// Tx hold by CTS low
+#define NPPI_NOTIFY_DSRHOLD         0x02	// Tx hold by DSR low
+#define NPPI_NOTIFY_XOFFHOLD        0x08	// Tx hold by Xoff received
+#define NPPI_NOTIFY_XOFFXENT        0x10	// Xoff Sent
+
+//CheckIsMoxaMust return value
+#define MOXA_OTHER_UART			0x00
+#define MOXA_MUST_MU150_HWID		0x01
+#define MOXA_MUST_MU860_HWID		0x02
+
+// follow just for Moxa Must chip define.
+//
+// when LCR register (offset 0x03) write following value,
+// the Must chip will enter enchance mode. And write value
+// on EFR (offset 0x02) bit 6,7 to change bank.
+#define MOXA_MUST_ENTER_ENCHANCE	0xBF
+
+// when enhance mode enable, access on general bank register
+#define MOXA_MUST_GDL_REGISTER		0x07
+#define MOXA_MUST_GDL_MASK		0x7F
+#define MOXA_MUST_GDL_HAS_BAD_DATA	0x80
+
+#define MOXA_MUST_LSR_RERR		0x80	// error in receive FIFO
+// enchance register bank select and enchance mode setting register
+// when LCR register equal to 0xBF
+#define MOXA_MUST_EFR_REGISTER		0x02
+// enchance mode enable
+#define MOXA_MUST_EFR_EFRB_ENABLE	0x10
+// enchance reister bank set 0, 1, 2
+#define MOXA_MUST_EFR_BANK0		0x00
+#define MOXA_MUST_EFR_BANK1		0x40
+#define MOXA_MUST_EFR_BANK2		0x80
+#define MOXA_MUST_EFR_BANK3		0xC0
+#define MOXA_MUST_EFR_BANK_MASK		0xC0
+
+// set XON1 value register, when LCR=0xBF and change to bank0
+#define MOXA_MUST_XON1_REGISTER		0x04
+
+// set XON2 value register, when LCR=0xBF and change to bank0
+#define MOXA_MUST_XON2_REGISTER		0x05
+
+// set XOFF1 value register, when LCR=0xBF and change to bank0
+#define MOXA_MUST_XOFF1_REGISTER	0x06
+
+// set XOFF2 value register, when LCR=0xBF and change to bank0
+#define MOXA_MUST_XOFF2_REGISTER	0x07
+
+#define MOXA_MUST_RBRTL_REGISTER	0x04
+#define MOXA_MUST_RBRTH_REGISTER	0x05
+#define MOXA_MUST_RBRTI_REGISTER	0x06
+#define MOXA_MUST_THRTL_REGISTER	0x07
+#define MOXA_MUST_ENUM_REGISTER		0x04
+#define MOXA_MUST_HWID_REGISTER		0x05
+#define MOXA_MUST_ECR_REGISTER		0x06
+#define MOXA_MUST_CSR_REGISTER		0x07
+
+// good data mode enable
+#define MOXA_MUST_FCR_GDA_MODE_ENABLE	0x20
+// only good data put into RxFIFO
+#define MOXA_MUST_FCR_GDA_ONLY_ENABLE	0x10
+
+// enable CTS interrupt
+#define MOXA_MUST_IER_ECTSI		0x80
+// eanble RTS interrupt
+#define MOXA_MUST_IER_ERTSI		0x40
+// enable Xon/Xoff interrupt
+#define MOXA_MUST_IER_XINT		0x20
+// enable GDA interrupt
+#define MOXA_MUST_IER_EGDAI		0x10
+
+#define MOXA_MUST_RECV_ISR		(UART_IER_RDI | MOXA_MUST_IER_EGDAI)
+
+// GDA interrupt pending
+#define MOXA_MUST_IIR_GDA		0x1C
+#define MOXA_MUST_IIR_RDA		0x04
+#define MOXA_MUST_IIR_RTO		0x0C
+#define MOXA_MUST_IIR_LSR		0x06
+
+// recieved Xon/Xoff or specical interrupt pending
+#define MOXA_MUST_IIR_XSC		0x10
+
+// RTS/CTS change state interrupt pending
+#define MOXA_MUST_IIR_RTSCTS		0x20
+#define MOXA_MUST_IIR_MASK		0x3E
+
+#define MOXA_MUST_MCR_XON_FLAG		0x40
+#define MOXA_MUST_MCR_XON_ANY		0x80
+#define MOXA_MUST_MCR_TX_XON		0x08
+
+
+// software flow control on chip mask value
+#define MOXA_MUST_EFR_SF_MASK		0x0F
+// send Xon1/Xoff1
+#define MOXA_MUST_EFR_SF_TX1		0x08
+// send Xon2/Xoff2
+#define MOXA_MUST_EFR_SF_TX2		0x04
+// send Xon1,Xon2/Xoff1,Xoff2
+#define MOXA_MUST_EFR_SF_TX12		0x0C
+// don't send Xon/Xoff
+#define MOXA_MUST_EFR_SF_TX_NO		0x00
+// Tx software flow control mask
+#define MOXA_MUST_EFR_SF_TX_MASK	0x0C
+// don't receive Xon/Xoff
+#define MOXA_MUST_EFR_SF_RX_NO		0x00
+// receive Xon1/Xoff1
+#define MOXA_MUST_EFR_SF_RX1		0x02
+// receive Xon2/Xoff2
+#define MOXA_MUST_EFR_SF_RX2		0x01
+// receive Xon1,Xon2/Xoff1,Xoff2
+#define MOXA_MUST_EFR_SF_RX12		0x03
+// Rx software flow control mask
+#define MOXA_MUST_EFR_SF_RX_MASK	0x03
+
+//#define MOXA_MUST_MIN_XOFFLIMIT               66
+//#define MOXA_MUST_MIN_XONLIMIT                20
+//#define ID1_RX_TRIG                   120
+
+
+#define CHECK_MOXA_MUST_XOFFLIMIT(info) { 	\
+	if ( (info)->IsMoxaMustChipFlag && 	\
+	 (info)->HandFlow.XoffLimit < MOXA_MUST_MIN_XOFFLIMIT ) {	\
+		(info)->HandFlow.XoffLimit = MOXA_MUST_MIN_XOFFLIMIT;	\
+		(info)->HandFlow.XonLimit = MOXA_MUST_MIN_XONLIMIT;	\
+	}	\
+}
+
+#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) { \
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr |= MOXA_MUST_EFR_EFRB_ENABLE;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_EFRB_ENABLE;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK0;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_XON1_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_XON2_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK0;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_XON2_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK0;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_XOFF1_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_XOFF2_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK0;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_XOFF2_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_RBRTL_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK1;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_RBRTL_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_RBRTH_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK1;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_RBRTH_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_RBRTI_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK1;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_RBRTI_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_THRTL_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK1;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_THRTL_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+//#define MOXA_MUST_RBRL_VALUE  4
+#define SET_MOXA_MUST_FIFO_VALUE(info) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((info)->base+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (info)->base+UART_LCR);	\
+	__efr = inb((info)->base+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK1;	\
+	outb(__efr, (info)->base+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)((info)->rx_high_water), (info)->base+MOXA_MUST_RBRTH_REGISTER);	\
+	outb((u8)((info)->rx_trigger), (info)->base+MOXA_MUST_RBRTI_REGISTER);	\
+	outb((u8)((info)->rx_low_water), (info)->base+MOXA_MUST_RBRTL_REGISTER);	\
+	outb(__oldlcr, (info)->base+UART_LCR);	\
+}
+
+
+
+#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK2;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb((u8)(Value), (baseio)+MOXA_MUST_ENUM_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_BANK_MASK;	\
+	__efr |= MOXA_MUST_EFR_BANK2;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	*pId = inb((baseio)+MOXA_MUST_HWID_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_SF_MASK;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_JUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_SF_MASK;	\
+	__efr |= MOXA_MUST_EFR_SF_TX1;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_SF_TX_MASK;	\
+	__efr |= MOXA_MUST_EFR_SF_TX1;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_SF_TX_MASK;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define SET_MOXA_MUST_JUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_SF_MASK;	\
+	__efr |= MOXA_MUST_EFR_SF_RX1;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_SF_RX_MASK;	\
+	__efr |= MOXA_MUST_EFR_SF_RX1;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_SF_RX_MASK;	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define ENABLE_MOXA_MUST_TX_RX_SOFTWARE_FLOW_CONTROL(baseio) {	\
+	u8	__oldlcr, __efr;	\
+	__oldlcr = inb((baseio)+UART_LCR);	\
+	outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);	\
+	__efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);	\
+	__efr &= ~MOXA_MUST_EFR_SF_MASK;	\
+	__efr |= (MOXA_MUST_EFR_SF_RX1|MOXA_MUST_EFR_SF_TX1);	\
+	outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);	\
+	outb(__oldlcr, (baseio)+UART_LCR);	\
+}
+
+#define ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(baseio) {	\
+	u8	__oldmcr;	\
+	__oldmcr = inb((baseio)+UART_MCR);	\
+	__oldmcr |= MOXA_MUST_MCR_XON_ANY;	\
+	outb(__oldmcr, (baseio)+UART_MCR);	\
+}
+
+#define DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(baseio) {	\
+	u8	__oldmcr;	\
+	__oldmcr = inb((baseio)+UART_MCR);	\
+	__oldmcr &= ~MOXA_MUST_MCR_XON_ANY;	\
+	outb(__oldmcr, (baseio)+UART_MCR);	\
+}
+
+#define READ_MOXA_MUST_GDL(baseio)	inb((baseio)+MOXA_MUST_GDL_REGISTER)
+
+
+#ifndef INIT_WORK
+#define INIT_WORK(_work, _func, _data){	\
+	_data->tqueue.routine = _func;\
+	_data->tqueue.data = _data;\
+	}
+#endif
+
+#endif
diff -Nru a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
--- a/drivers/char/n_hdlc.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/char/n_hdlc.c	2004-12-24 13:36:31 -08:00
@@ -103,9 +103,9 @@
 #include <linux/string.h>	/* used in new tty drivers */
 #include <linux/signal.h>	/* used in new tty drivers */
 #include <linux/if.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/termios.h>
 #include <asm/uaccess.h>
 
@@ -184,7 +184,7 @@
 static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
 			   __u8 __user *buf, size_t nr);
 static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
-			    const __u8 __user *buf, size_t nr);
+			    const unsigned char *buf, size_t nr);
 static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
 			    unsigned int cmd, unsigned long arg);
 static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
@@ -402,7 +402,7 @@
 			
 		/* Send the next block of data to device */
 		tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-		actual = tty->driver->write(tty, 0, tbuf->buf, tbuf->count);
+		actual = tty->driver->write(tty, tbuf->buf, tbuf->count);
 		    
 		/* if transmit error, throw frame away by */
 		/* pretending it was accepted by driver */
@@ -649,7 +649,7 @@
  * Returns the number of bytes written (or error code).
  */
 static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
-			    const __u8 __user *data, size_t count)
+			    const unsigned char *data, size_t count)
 {
 	struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
 	int error = 0;
@@ -704,16 +704,12 @@
 
 	if (!error) {		
 		/* Retrieve the user's buffer */
-		if (copy_from_user(tbuf->buf, data, count)) {
-			/* return tx buffer to free list */
-			n_hdlc_buf_put(&n_hdlc->tx_free_buf_list,tbuf);
-			error = -EFAULT;
-		} else {
-			/* Send the data */
-			tbuf->count = error = count;
-			n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
-			n_hdlc_send_frames(n_hdlc,tty);
-		}
+		memcpy(tbuf->buf, data, count);
+
+		/* Send the data */
+		tbuf->count = error = count;
+		n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
+		n_hdlc_send_frames(n_hdlc,tty);
 	}
 
 	return error;
diff -Nru a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
--- a/drivers/char/n_r3964.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/char/n_r3964.c	2004-12-24 13:37:29 -08:00
@@ -139,7 +139,7 @@
 static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
                      unsigned char __user *buf, size_t nr);
 static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
-                      const unsigned char __user * buf, size_t nr);
+                      const unsigned char * buf, size_t nr);
 static int r3964_ioctl(struct tty_struct * tty, struct file * file,
                        unsigned int cmd, unsigned long arg);
 static void r3964_set_termios(struct tty_struct *tty, struct termios * old);
@@ -1246,13 +1246,12 @@
 }
 
 static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
-			   const unsigned char __user *data, size_t count)
+			   const unsigned char *data, size_t count)
 {
    struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data;
    struct r3964_block_header *pHeader;
    struct r3964_client_info *pClient;
    unsigned char *new_data;
-   int status;
    int pid;
    
    TRACE_L("write request, %d characters", count);
@@ -1263,12 +1262,6 @@
    if(!pInfo)
       return -EIO;
 
-   status = verify_area (VERIFY_READ, data, count);
-   if (status != 0) 
-   {
-      return status;
-   }
-
 /*
  * Ensure that the caller does not wish to send too much.
  */
@@ -1283,7 +1276,7 @@
       count = R3964_MTU;
    }
 /*
- * Allocate a buffer for the data and fetch it from the user space.
+ * Allocate a buffer for the data and copy it from the buffer with header prepended
  */
    new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL);
    TRACE_M("r3964_write - kmalloc %x",(int)new_data);
@@ -1310,7 +1303,7 @@
       pHeader->owner = pClient;
    }
 
-   __copy_from_user(pHeader->data, data, count); /* We already verified this */
+   memcpy(pHeader->data, data, count); /* We already verified this */
 
    if(pInfo->flags & R3964_DEBUG)
    {
diff -Nru a/drivers/char/n_tty.c b/drivers/char/n_tty.c
--- a/drivers/char/n_tty.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/char/n_tty.c	2004-12-24 13:36:17 -08:00
@@ -44,10 +44,10 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/poll.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 /* number of characters left in xmit buffer before select has we have room */
 #define WAKEUP_CHARS 256
@@ -270,7 +270,7 @@
 				if (space < spaces)
 					return -1;
 				tty->column += spaces;
-				tty->driver->write(tty, 0, "        ", spaces);
+				tty->driver->write(tty, "        ", spaces);
 				return 0;
 			}
 			tty->column += spaces;
@@ -306,12 +306,11 @@
  */
  
 static ssize_t opost_block(struct tty_struct * tty,
-		       const unsigned char __user * inbuf, unsigned int nr)
+		       const unsigned char * buf, unsigned int nr)
 {
-	char	buf[80];
 	int	space;
 	int 	i;
-	char	*cp;
+	const unsigned char *cp;
 
 	space = tty->driver->write_room(tty);
 	if (!space)
@@ -321,9 +320,6 @@
 	if (nr > sizeof(buf))
 	    nr = sizeof(buf);
 
-	if (copy_from_user(buf, inbuf, nr))
-		return -EFAULT;
-
 	for (i = 0, cp = buf; i < nr; i++, cp++) {
 		switch (*cp) {
 		case '\n':
@@ -336,12 +332,8 @@
 		case '\r':
 			if (O_ONOCR(tty) && tty->column == 0)
 				goto break_out;
-			if (O_OCRNL(tty)) {
-				*cp = '\n';
-				if (O_ONLRET(tty))
-					tty->canon_column = tty->column = 0;
-				break;
-			}
+			if (O_OCRNL(tty))
+				goto break_out;
 			tty->canon_column = tty->column = 0;
 			break;
 		case '\t':
@@ -352,7 +344,7 @@
 			break;
 		default:
 			if (O_OLCUC(tty))
-				*cp = toupper(*cp);
+				goto break_out;
 			if (!iscntrl(*cp))
 				tty->column++;
 			break;
@@ -361,7 +353,7 @@
 break_out:
 	if (tty->driver->flush_chars)
 		tty->driver->flush_chars(tty);
-	i = tty->driver->write(tty, 0, buf, i);	
+	i = tty->driver->write(tty, buf, i);	
 	return i;
 }
 
@@ -1435,9 +1427,9 @@
  */
  
 static ssize_t write_chan(struct tty_struct * tty, struct file * file,
-			  const unsigned char __user * buf, size_t nr)
+			  const unsigned char * buf, size_t nr)
 {
-	const unsigned char __user *b = buf;
+	const unsigned char *b = buf;
 	DECLARE_WAITQUEUE(wait, current);
 	int c;
 	ssize_t retval = 0;
@@ -1473,7 +1465,7 @@
 				nr -= num;
 				if (nr == 0)
 					break;
-				get_user(c, b);
+				c = *b;
 				if (opost(c, tty) < 0)
 					break;
 				b++; nr--;
@@ -1481,7 +1473,7 @@
 			if (tty->driver->flush_chars)
 				tty->driver->flush_chars(tty);
 		} else {
-			c = tty->driver->write(tty, 1, b, nr);
+			c = tty->driver->write(tty, b, nr);
 			if (c < 0) {
 				retval = c;
 				goto break_out;
diff -Nru a/drivers/char/nwflash.c b/drivers/char/nwflash.c
--- a/drivers/char/nwflash.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/char/nwflash.c	2004-12-24 13:37:32 -08:00
@@ -696,7 +696,7 @@
 
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(flashdebug, "i");
+module_param(flashdebug, bool, 0644);
 
 module_init(nwflash_init);
 module_exit(nwflash_exit);
diff -Nru a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
--- a/drivers/char/pcmcia/synclink_cs.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/char/pcmcia/synclink_cs.c	2004-12-24 13:36:47 -08:00
@@ -65,7 +65,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/dma.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/types.h>
 #include <linux/termios.h>
 #include <linux/workqueue.h>
@@ -1744,16 +1744,15 @@
  * Arguments:
  * 
  * tty        pointer to tty information structure
- * from_user  flag: 1 = from user process
  * buf	      pointer to buffer containing send data
  * count      size of send data in bytes
  * 	
  * Returns: number of characters written
  */
-static int mgslpc_write(struct tty_struct * tty, int from_user,
+static int mgslpc_write(struct tty_struct * tty,
 			const unsigned char *buf, int count)
 {
-	int c, ret = 0, err;
+	int c, ret = 0;
 	MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
 	unsigned long flags;
 	
@@ -1783,15 +1782,7 @@
 		if (c <= 0)
 			break;
 			
-		if (from_user) {
-			COPY_FROM_USER(err, info->tx_buf + info->tx_put, buf, c);
-			if (err) {
-				if (!ret)
-					ret = -EFAULT;
-				break;
-			}
-		} else
-			memcpy(info->tx_buf + info->tx_put, buf, c);
+		memcpy(info->tx_buf + info->tx_put, buf, c);
 
 		spin_lock_irqsave(&info->lock,flags);
 		info->tx_put = (info->tx_put + c) & (TXBUFSIZE-1);
@@ -2609,8 +2600,7 @@
 	
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -2665,8 +2655,7 @@
 		
 	if (info->params.mode == MGSL_MODE_HDLC) {
 		while (info->tx_active) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(char_time);
+			msleep_interruptible(jiffies_to_msecs(char_time));
 			if (signal_pending(current))
 				break;
 			if (timeout && time_after(jiffies, orig_jiffies + timeout))
@@ -2675,8 +2664,7 @@
 	} else {
 		while ((info->tx_count || info->tx_active) &&
 			info->tx_enabled) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(char_time);
+			msleep_interruptible(jiffies_to_msecs(char_time));
 			if (signal_pending(current))
 				break;
 			if (timeout && time_after(jiffies, orig_jiffies + timeout))
@@ -4129,8 +4117,7 @@
 
 	end_time=100;
 	while(end_time-- && !info->irq_occurred) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(msecs_to_jiffies(10));
+		msleep_interruptible(10);
 	}
 	
 	info->testing_irq = FALSE;
@@ -4570,9 +4557,7 @@
 
 	memcpy(skb_put(skb, size),buf,size);
 
-	skb->dev      = info->netdev;
-	skb->mac.raw  = skb->data;
-	skb->protocol = hdlc_type_trans(skb, skb->dev);
+	skb->protocol = hdlc_type_trans(skb, info->netdev);
 
 	stats->rx_packets++;
 	stats->rx_bytes += size;
diff -Nru a/drivers/char/pcxx.c b/drivers/char/pcxx.c
--- a/drivers/char/pcxx.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/char/pcxx.c	2004-12-24 13:37:00 -08:00
@@ -65,6 +65,7 @@
 #include <linux/tty_driver.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #ifndef MODULE
 #include <linux/ctype.h> /* We only need it for parsing the "digi="-line */
@@ -73,7 +74,6 @@
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/semaphore.h>
 
 #define VERSION 	"1.6.3"
@@ -112,13 +112,13 @@
 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");
-MODULE_PARM(membase,     "1-4i");
-MODULE_PARM(memsize,     "1-4i");
-MODULE_PARM(altpin,      "1-4i");
-MODULE_PARM(numports,    "1-4i");
+module_param(verbose,     bool, 0644);
+module_param(debug,       bool, 0644);
+module_param_array(io,          int, NULL, 0);
+module_param_array(membase,     int, NULL, 0);
+module_param_array(memsize,     int, NULL, 0);
+module_param_array(altpin,      int, NULL, 0);
+module_param_array(numports,    int, NULL, 0);
 
 #endif /* MODULE */
 
@@ -148,7 +148,7 @@
 static void pcxe_close(struct tty_struct *, struct file *);
 static int pcxe_ioctl(struct tty_struct *, struct file *, unsigned int, unsigned long);
 static void pcxe_set_termios(struct tty_struct *, struct termios *);
-static int pcxe_write(struct tty_struct *, int, const unsigned char *, int);
+static int pcxe_write(struct tty_struct *, const unsigned char *, int);
 static int pcxe_write_room(struct tty_struct *);
 static int pcxe_chars_in_buffer(struct tty_struct *);
 static void pcxe_flush_buffer(struct tty_struct *);
@@ -538,8 +538,7 @@
 		info->tty = NULL;
 		if(info->blocked_open) {
 			if(info->close_delay) {
-				current->state = TASK_INTERRUPTIBLE;
-				schedule_timeout(info->close_delay);
+				msleep_interruptible(jiffies_to_msecs(info->close_delay));
 			}
 			wake_up_interruptible(&info->open_wait);
 		}
@@ -571,7 +570,7 @@
 
 
 
-static int pcxe_write(struct tty_struct * tty, int from_user, const unsigned char *buf, int count)
+static int pcxe_write(struct tty_struct * tty, const unsigned char *buf, int count)
 {
 	struct channel *ch;
 	volatile struct board_chan *bc;
@@ -586,33 +585,6 @@
 	bc = ch->brdchan;
 	size = ch->txbufsize;
 
-	if (from_user) {
-
-		down(&ch->tmp_buf_sem);
-		save_flags(flags);
-		cli();
-		globalwinon(ch);
-		head = bc->tin & (size - 1);
-		/* It seems to be necessary to make sure that the value is stable here somehow
-		   This is a rather odd pice of code here. */
-		do
-		{
-			tail = bc->tout;
-		} while (tail != bc->tout);
-		
-		tail &= (size - 1);
-		stlen = (head >= tail) ? (size - (head - tail) - 1) : (tail - head - 1);
-		count = min(stlen, count);
-		memoff(ch);
-		restore_flags(flags);
-
-		if (count)
-			if (copy_from_user(ch->tmp_buf, buf, count))
-				count = 0;
-
-		buf = ch->tmp_buf;
-	}
-
 	/*
 	 * All data is now local
 	 */
@@ -659,16 +631,13 @@
 	memoff(ch);
 	restore_flags(flags);
 	
-	if(from_user)
-		up(&ch->tmp_buf_sem);
-
 	return(total);
 }
 
 
 static void pcxe_put_char(struct tty_struct *tty, unsigned char c)
 {
-	pcxe_write(tty, 0, &c, 1);
+	pcxe_write(tty, &c, 1);
 	return;
 }
 
diff -Nru a/drivers/char/pty.c b/drivers/char/pty.c
--- a/drivers/char/pty.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/char/pty.c	2004-12-24 13:36:33 -08:00
@@ -29,7 +29,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/devpts_fs.h>
 
 /* These are global because they are accessed in tty_io.c */
@@ -55,9 +55,9 @@
 	if (!tty->link)
 		return;
 	tty->link->packet = 0;
+	set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
 	wake_up_interruptible(&tty->link->read_wait);
 	wake_up_interruptible(&tty->link->write_wait);
-	set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
 	if (tty->driver->subtype == PTY_TYPE_MASTER) {
 		set_bit(TTY_OTHER_CLOSED, &tty->flags);
 #ifdef CONFIG_UNIX98_PTYS
@@ -103,51 +103,18 @@
  * not our partners. We can't just take the other one blindly without
  * risking deadlocks.  There is also the small matter of TTY_DONT_FLIP
  */
-static int pty_write(struct tty_struct * tty, int from_user,
-		       const unsigned char *buf, int count)
+static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count)
 {
 	struct tty_struct *to = tty->link;
-	int	c=0, n, room;
-	char	*temp_buffer;
+	int	c;
 
 	if (!to || tty->stopped)
 		return 0;
 
-	if (from_user) {
-		down(&tty->flip.pty_sem);
-		temp_buffer = &tty->flip.char_buf[0];
-		while (count > 0) {
-			/* check space so we don't copy needlessly */ 
-			n = to->ldisc.receive_room(to);
-			if (n > count)
-				n = count;
-			if (!n) break;
-
-			n  = min(n, PTY_BUF_SIZE);
-			n -= copy_from_user(temp_buffer, buf, n);
-			if (!n) {
-				if (!c)
-					c = -EFAULT;
-				break;
-			}
-
-			/* check again in case the buffer filled up */
-			room = to->ldisc.receive_room(to);
-			if (n > room)
-				n = room;
-			if (!n) break;
-			buf   += n; 
-			c     += n;
-			count -= n;
-			to->ldisc.receive_buf(to, temp_buffer, NULL, n);
-		}
-		up(&tty->flip.pty_sem);
-	} else {
-		c = to->ldisc.receive_room(to);
-		if (c > count)
-			c = count;
-		to->ldisc.receive_buf(to, buf, NULL, c);
-	}
+	c = to->ldisc.receive_room(to);
+	if (c > count)
+		c = count;
+	to->ldisc.receive_buf(to, buf, NULL, c);
 	
 	return c;
 }
diff -Nru a/drivers/char/qtronix.c b/drivers/char/qtronix.c
--- a/drivers/char/qtronix.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/char/qtronix.c	2004-12-24 13:36:47 -08:00
@@ -79,7 +79,7 @@
 #include <linux/pc_keyb.h>
 
 #include <asm/keyboard.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/irq.h>
 #include <asm/system.h>
diff -Nru a/drivers/char/random.c b/drivers/char/random.c
--- a/drivers/char/random.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/char/random.c	2004-12-24 13:36:18 -08:00
@@ -572,8 +572,8 @@
  * it's cheap to do so and helps slightly in the expected case where
  * the entropy is concentrated in the low-order bits.
  */
-static void add_entropy_words(struct entropy_store *r, const __u32 *in,
-			      int nwords)
+static void __add_entropy_words(struct entropy_store *r, const __u32 *in,
+				int nwords, __u32 out[16])
 {
 	static __u32 const twist_table[8] = {
 		         0, 0x3b6e20c8, 0x76dc4190, 0x4db26158,
@@ -626,9 +626,23 @@
 	r->input_rotate = input_rotate;
 	r->add_ptr = add_ptr;
 
+	if (out) {
+		for (i = 0; i < 16; i++) {
+			out[i] = r->pool[add_ptr];
+			add_ptr = (add_ptr - 1) & wordmask;
+		}
+	}
+
 	spin_unlock_irqrestore(&r->lock, flags);
 }
 
+static inline void add_entropy_words(struct entropy_store *r, const __u32 *in,
+				     int nwords)
+{
+	__add_entropy_words(r, in, nwords, NULL);
+}
+
+
 /*
  * Credit (or debit) the entropy store with n bits of entropy
  */
@@ -698,7 +712,7 @@
  * hashing calculations during an interrupt in add_timer_randomness().
  * Instead, the entropy is only added to the pool by keventd.
  */
-void batch_entropy_store(u32 a, u32 b, int num)
+static void batch_entropy_store(u32 a, u32 b, int num)
 {
 	int new;
 	unsigned long flags;
@@ -729,8 +743,6 @@
 	spin_unlock_irqrestore(&batch_lock, flags);
 }
 
-EXPORT_SYMBOL(batch_entropy_store);
-
 /*
  * Flush out the accumulated entropy operations, adding entropy to the passed
  * store (normally random_state).  If that store has enough entropy, alternate
@@ -818,12 +830,10 @@
 	 * jiffies.
 	 */
 	time = get_cycles();
-	if (time != 0) {
-		if (sizeof(time) > 4)
-			num ^= (u32)(time >> 32);
-	} else {
+	if (time)
+		num ^= (u32)((time >> 31) >> 1);
+	else
 		time = jiffies;
-	}
 
 	/*
 	 * Calculate number of bits of randomness we probably added.
@@ -876,8 +886,6 @@
 	}
 }
 
-EXPORT_SYMBOL(add_keyboard_randomness);
-
 void add_mouse_randomness(__u32 mouse_data)
 {
 	add_timer_randomness(&mouse_timer_state, mouse_data);
@@ -893,8 +901,6 @@
 	add_timer_randomness(irq_timer_state[irq], 0x100+irq);
 }
 
-EXPORT_SYMBOL(add_interrupt_randomness);
-
 void add_disk_randomness(struct gendisk *disk)
 {
 	if (!disk || !disk->random)
@@ -1350,7 +1356,7 @@
 			       size_t nbytes, int flags)
 {
 	ssize_t ret, i;
-	__u32 tmp[TMP_BUF_SIZE];
+	__u32 tmp[TMP_BUF_SIZE], data[16];
 	__u32 x;
 	unsigned long cpuflags;
 
@@ -1430,7 +1436,15 @@
 			HASH_TRANSFORM(tmp, r->pool+i);
 			add_entropy_words(r, &tmp[x%HASH_BUFFER_SIZE], 1);
 		}
-		
+
+		/*
+		 * To avoid duplicates, we atomically extract a
+		 * portion of the pool while mixing, and hash one
+		 * final time.
+		 */
+		__add_entropy_words(r, &tmp[x%HASH_BUFFER_SIZE], 1, data);
+		HASH_TRANSFORM(tmp, data);
+
 		/*
 		 * In case the hash function has some recognizable
 		 * output pattern, we fold it in half.
@@ -2054,6 +2068,7 @@
  *
  ********************************************************************/
 
+#ifdef CONFIG_INET
 /*
  * TCP initial sequence number picking.  This uses the random number
  * generator to pick an initial secret value.  This value is hashed
@@ -2453,3 +2468,4 @@
 	return (cookie - tmp[17]) & COOKIEMASK;	/* Leaving the data behind */
 }
 #endif
+#endif /* CONFIG_INET */
diff -Nru a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
--- a/drivers/char/rio/rio_linux.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/char/rio/rio_linux.c	2004-12-24 13:37:00 -08:00
@@ -236,9 +236,9 @@
 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");
+module_param(rio_poll, int, 0);
+module_param(rio_debug, int, 0644);
+module_param(rio_irqmask, long, 0);
 
 static struct real_driver rio_real_driver = {
   rio_disable_tx_interrupts,
@@ -330,8 +330,7 @@
   func_enter ();
 
   rio_dprintk (RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies);  
-  current->state = TASK_INTERRUPTIBLE;
-  schedule_timeout(njiffies);
+  msleep_interruptible(jiffies_to_msecs(njiffies));
   func_exit();
 
   if (signal_pending(current))
@@ -347,8 +346,7 @@
   func_enter ();
 
   rio_dprintk (RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies);  
-  current->state = TASK_UNINTERRUPTIBLE;
-  schedule_timeout(njiffies);
+  msleep(jiffies_to_msecs(njiffies));
   func_exit();
   return !RIO_FAIL;
 }
diff -Nru a/drivers/char/riscom8.c b/drivers/char/riscom8.c
--- a/drivers/char/riscom8.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/char/riscom8.c	2004-12-24 13:36:48 -08:00
@@ -45,6 +45,7 @@
 #include <linux/fcntl.h>
 #include <linux/major.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 
 #include <asm/uaccess.h>
 
@@ -1114,8 +1115,7 @@
 		 */
 		timeout = jiffies+HZ;
 		while(port->IER & IER_TXEMPTY)  {
-			current->state = TASK_INTERRUPTIBLE;
- 			schedule_timeout(port->timeout);
+			msleep_interruptible(jiffies_to_msecs(port->timeout));
 			if (time_after(jiffies, timeout))
 				break;
 		}
@@ -1130,8 +1130,7 @@
 	port->tty = NULL;
 	if (port->blocked_open) {
 		if (port->close_delay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(port->close_delay);
+			msleep_interruptible(jiffies_to_msecs(port->close_delay));
 		}
 		wake_up_interruptible(&port->open_wait);
 	}
@@ -1140,7 +1139,7 @@
 out:	restore_flags(flags);
 }
 
-static int rc_write(struct tty_struct * tty, int from_user, 
+static int rc_write(struct tty_struct * tty, 
 		    const unsigned char *buf, int count)
 {
 	struct riscom_port *port = (struct riscom_port *)tty->driver_data;
@@ -1157,54 +1156,23 @@
 		return 0;
 
 	save_flags(flags);
-	if (from_user) {
-		down(&tmp_buf_sem);
-		while (1) {
-			cli();		
-			c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-						  SERIAL_XMIT_SIZE - port->xmit_head));
-			if (c <= 0)
-				break;
-
-			c -= copy_from_user(tmp_buf, buf, c);
-			if (!c) {
-				if (!total)
-					total = -EFAULT;
-				break;
-			}
-
-			cli();
-			c = min_t(int, c, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-					 SERIAL_XMIT_SIZE - port->xmit_head));
-			memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c);
-			port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-			port->xmit_cnt += c;
+	while (1) {
+		cli();		
+		c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
+					  SERIAL_XMIT_SIZE - port->xmit_head));
+		if (c <= 0) {
 			restore_flags(flags);
-
-			buf += c;
-			count -= c;
-			total += c;
+			break;
 		}
-		up(&tmp_buf_sem);
-	} else {
-		while (1) {
-			cli();		
-			c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-						  SERIAL_XMIT_SIZE - port->xmit_head));
-			if (c <= 0) {
-				restore_flags(flags);
-				break;
-			}
 
-			memcpy(port->xmit_buf + port->xmit_head, buf, c);
-			port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-			port->xmit_cnt += c;
-			restore_flags(flags);
-
-			buf += c;
-			count -= c;
-			total += c;
-		}
+		memcpy(port->xmit_buf + port->xmit_head, buf, c);
+		port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
+		port->xmit_cnt += c;
+		restore_flags(flags);
+
+		buf += c;
+		count -= c;
+		total += c;
 	}
 
 	cli();
diff -Nru a/drivers/char/rocket.c b/drivers/char/rocket.c
--- a/drivers/char/rocket.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/char/rocket.c	2004-12-24 13:37:02 -08:00
@@ -91,7 +91,7 @@
 #include <linux/pci.h>
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/spinlock.h>
 #include <asm/semaphore.h>
 #include <linux/init.h>
@@ -123,7 +123,7 @@
 static unsigned long board3;
 static unsigned long board4;
 static unsigned long controller;
-static unsigned long support_low_speed;
+static int support_low_speed;
 static unsigned long modem1;
 static unsigned long modem2;
 static unsigned long modem3;
@@ -181,33 +181,33 @@
 #ifdef MODULE
 MODULE_AUTHOR("Theodore Ts'o");
 MODULE_DESCRIPTION("Comtrol RocketPort driver");
-MODULE_PARM(board1, "i");
+module_param(board1, ulong, 0);
 MODULE_PARM_DESC(board1, "I/O port for (ISA) board #1");
-MODULE_PARM(board2, "i");
+module_param(board2, ulong, 0);
 MODULE_PARM_DESC(board2, "I/O port for (ISA) board #2");
-MODULE_PARM(board3, "i");
+module_param(board3, ulong, 0);
 MODULE_PARM_DESC(board3, "I/O port for (ISA) board #3");
-MODULE_PARM(board4, "i");
+module_param(board4, ulong, 0);
 MODULE_PARM_DESC(board4, "I/O port for (ISA) board #4");
-MODULE_PARM(controller, "i");
+module_param(controller, ulong, 0);
 MODULE_PARM_DESC(controller, "I/O port for (ISA) rocketport controller");
-MODULE_PARM(support_low_speed, "i");
+module_param(support_low_speed, bool, 0);
 MODULE_PARM_DESC(support_low_speed, "1 means support 50 baud, 0 means support 460400 baud");
-MODULE_PARM(modem1, "i");
+module_param(modem1, ulong, 0);
 MODULE_PARM_DESC(modem1, "1 means (ISA) board #1 is a RocketModem");
-MODULE_PARM(modem2, "i");
+module_param(modem2, ulong, 0);
 MODULE_PARM_DESC(modem2, "1 means (ISA) board #2 is a RocketModem");
-MODULE_PARM(modem3, "i");
+module_param(modem3, ulong, 0);
 MODULE_PARM_DESC(modem3, "1 means (ISA) board #3 is a RocketModem");
-MODULE_PARM(modem4, "i");
+module_param(modem4, ulong, 0);
 MODULE_PARM_DESC(modem4, "1 means (ISA) board #4 is a RocketModem");
-MODULE_PARM(pc104_1, "1-8i");
+module_param_array(pc104_1, ulong, NULL, 0);
 MODULE_PARM_DESC(pc104_1, "set interface types for ISA(PC104) board #1 (e.g. pc104_1=232,232,485,485,...");
-MODULE_PARM(pc104_2, "1-8i");
+module_param_array(pc104_2, ulong, NULL, 0);
 MODULE_PARM_DESC(pc104_2, "set interface types for ISA(PC104) board #2 (e.g. pc104_2=232,232,485,485,...");
-MODULE_PARM(pc104_3, "1-8i");
+module_param_array(pc104_3, ulong, NULL, 0);
 MODULE_PARM_DESC(pc104_3, "set interface types for ISA(PC104) board #3 (e.g. pc104_3=232,232,485,485,...");
-MODULE_PARM(pc104_4, "1-8i");
+module_param_array(pc104_4, ulong, NULL, 0);
 MODULE_PARM_DESC(pc104_4, "set interface types for ISA(PC104) board #4 (e.g. pc104_4=232,232,485,485,...");
 
 int rp_init(void);
@@ -1112,8 +1112,7 @@
 
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	} else {
@@ -1538,8 +1537,7 @@
 #ifdef ROCKET_DEBUG_WAIT_UNTIL_SENT
 		printk(KERN_INFO "txcnt = %d (jiff=%lu,check=%d)...", txcnt, jiffies, check_time);
 #endif
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(check_time);
+		msleep_interruptible(jiffies_to_msecs(check_time));
 		if (signal_pending(current))
 			break;
 	}
@@ -1635,7 +1633,7 @@
  *  or get control of the CPU if the copy_from_user() blocks due to a page fault (swapped out). 
  *  Spinlocks protect the info xmit members.
  */
-static int rp_write(struct tty_struct *tty, int from_user,
+static int rp_write(struct tty_struct *tty,
 		    const unsigned char *buf, int count)
 {
 	struct r_port *info = (struct r_port *) tty->driver_data;
@@ -1664,16 +1662,6 @@
 	if (!tty->stopped && !tty->hw_stopped && info->xmit_cnt == 0 && info->xmit_fifo_room > 0) {
 		c = min(count, info->xmit_fifo_room);
 		b = buf;
-		if (from_user) {
-			if (copy_from_user(info->xmit_buf, buf, c)) {
-				retval = -EFAULT;
-				goto end;
-			}
-			if (info->tty == 0)
-				goto end;
-			b = info->xmit_buf;
-			c = min(c, info->xmit_fifo_room);
-		}
 
 		/*  Push data into FIFO, 2 bytes at a time */
 		sOutStrW(sGetTxRxDataIO(cp), (unsigned short *) b, c / 2);
@@ -1705,14 +1693,7 @@
 			break;
 
 		b = buf;
-		if (from_user) {
-			if (copy_from_user(info->xmit_buf + info->xmit_head, b, c)) {
-				retval = -EFAULT;
-				goto end_intr;
-			} else {
-				memcpy(info->xmit_buf + info->xmit_head, b, c);
-			}
-		}
+		memcpy(info->xmit_buf + info->xmit_head, b, c);
 
 		spin_lock_irqsave(&info->slock, flags);
 		info->xmit_head =
@@ -1725,7 +1706,6 @@
 		retval += c;
 	}
 
-end_intr:
 	if ((retval > 0) && !tty->stopped && !tty->hw_stopped)
 		set_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
 	
@@ -2472,30 +2452,6 @@
 		release_region(controller, 4);
 }
 #endif
-
-/***********************************************************************
-		Copyright 1994 Comtrol Corporation.
-			All Rights Reserved.
-
-The following source code is subject to Comtrol Corporation's
-Developer's License Agreement.
-
-This source code is protected by United States copyright law and 
-international copyright treaties.
-
-This source code may only be used to develop software products that
-will operate with Comtrol brand hardware.
-
-You may not reproduce nor distribute this source code in its original
-form but must produce a derivative work which includes portions of
-this source code only.
-
-The portions of this source code which you use in your derivative
-work must bear Comtrol's copyright notice:
-
-		Copyright 1994 Comtrol Corporation.
-
-***********************************************************************/
 
 #ifndef TRUE
 #define TRUE 1
diff -Nru a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/char/s3c2410-rtc.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,587 @@
+/* drivers/char/s3c2410_rtc.c
+ *
+ * Copyright (c) 2004 Simtec Electronics <linux@simtec.co.uk>
+ *		      http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * S3C2410 Internal RTC Driver
+ *
+ *  Changelog:
+ *	08-Nov-2004	BJD	Initial creation
+ *	12-Nov-2004	BJD	Added periodic IRQ and PM code
+ *	22-Nov-2004	BJD	Sign-test on alarm code to check for <0
+*/
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+#include <linux/rtc.h>
+#include <linux/bcd.h>
+
+#include <asm/hardware.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/rtc.h>
+
+#include <asm/mach/time.h>
+
+#include <asm/hardware/clock.h>
+#include <asm/arch/regs-rtc.h>
+
+/* need this for the RTC_AF definitions */
+#include <linux/mc146818rtc.h>
+
+#undef S3C2410_VA_RTC
+#define S3C2410_VA_RTC s3c2410_rtc_base
+
+static struct resource *s3c2410_rtc_mem;
+
+static void __iomem *s3c2410_rtc_base;
+static int s3c2410_rtc_alarmno = NO_IRQ;
+static int s3c2410_rtc_tickno  = NO_IRQ;
+static int s3c2410_rtc_freq    = 1;
+
+static spinlock_t s3c2410_rtc_pie_lock = SPIN_LOCK_UNLOCKED;
+
+/* IRQ Handlers */
+
+static irqreturn_t s3c2410_rtc_alarmirq(int irq, void *id, struct pt_regs *r)
+{
+	rtc_update(1, RTC_AF | RTC_IRQF);
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t s3c2410_rtc_tickirq(int irq, void *id, struct pt_regs *r)
+{
+	rtc_update(1, RTC_PF | RTC_IRQF);
+	return IRQ_HANDLED;
+}
+
+/* Update control registers */
+static void s3c2410_rtc_setaie(int to)
+{
+	unsigned int tmp;
+
+	pr_debug("%s: aie=%d\n", __FUNCTION__, to);
+
+	tmp = readb(S3C2410_RTCALM);
+
+	if (to)
+		tmp |= S3C2410_RTCALM_ALMEN;
+	else
+		tmp &= ~S3C2410_RTCALM_ALMEN;
+
+
+	writeb(tmp, S3C2410_RTCALM);
+}
+
+static void s3c2410_rtc_setpie(int to)
+{
+	unsigned int tmp;
+
+	pr_debug("%s: pie=%d\n", __FUNCTION__, to);
+
+	spin_lock_irq(&s3c2410_rtc_pie_lock);
+	tmp = readb(S3C2410_TICNT) & ~S3C2410_TICNT_ENABLE;
+
+	if (to)
+		tmp |= S3C2410_TICNT_ENABLE;
+
+	writeb(tmp, S3C2410_TICNT);
+	spin_unlock_irq(&s3c2410_rtc_pie_lock);
+}
+
+static void s3c2410_rtc_setfreq(int freq)
+{
+	unsigned int tmp;
+
+	spin_lock_irq(&s3c2410_rtc_pie_lock);
+	tmp = readb(S3C2410_TICNT) & S3C2410_TICNT_ENABLE;
+
+	s3c2410_rtc_freq = freq;
+
+	tmp |= (128 / freq)-1;
+
+	writeb(tmp, S3C2410_TICNT);
+	spin_unlock_irq(&s3c2410_rtc_pie_lock);
+}
+
+/* Time read/write */
+
+static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm)
+{
+	unsigned int have_retried = 0;
+
+ retry_get_time:
+	rtc_tm->tm_min  = readb(S3C2410_RTCMIN);
+	rtc_tm->tm_hour = readb(S3C2410_RTCHOUR);
+	rtc_tm->tm_mday = readb(S3C2410_RTCDATE);
+	rtc_tm->tm_mon  = readb(S3C2410_RTCMON);
+	rtc_tm->tm_year = readb(S3C2410_RTCYEAR);
+	rtc_tm->tm_sec  = readb(S3C2410_RTCSEC);
+
+	/* the only way to work out wether the system was mid-update
+	 * when we read it is to check the second counter, and if it
+	 * is zero, then we re-try the entire read
+	 */
+
+	if (rtc_tm->tm_sec == 0 && !have_retried) {
+		have_retried = 1;
+		goto retry_get_time;
+	}
+
+	pr_debug("read time %02x.%02x.%02x %02x/%02x/%02x\n",
+		 rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday,
+		 rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec);
+
+	BCD_TO_BIN(rtc_tm->tm_sec);
+	BCD_TO_BIN(rtc_tm->tm_min);
+	BCD_TO_BIN(rtc_tm->tm_hour);
+	BCD_TO_BIN(rtc_tm->tm_mday);
+	BCD_TO_BIN(rtc_tm->tm_mon);
+	BCD_TO_BIN(rtc_tm->tm_year);
+
+	rtc_tm->tm_year += 100;
+	rtc_tm->tm_mon -= 1;
+}
+
+
+static int s3c2410_rtc_settime(struct rtc_time *tm)
+{
+	/* the rtc gets round the y2k problem by just not supporting it */
+
+	if (tm->tm_year < 100)
+		return -EINVAL;
+
+	writeb(BIN2BCD(tm->tm_sec),  S3C2410_RTCSEC);
+	writeb(BIN2BCD(tm->tm_min),  S3C2410_RTCMIN);
+	writeb(BIN2BCD(tm->tm_hour), S3C2410_RTCHOUR);
+	writeb(BIN2BCD(tm->tm_mday), S3C2410_RTCDATE);
+	writeb(BIN2BCD(tm->tm_mon + 1), S3C2410_RTCMON);
+	writeb(BIN2BCD(tm->tm_year - 100), S3C2410_RTCYEAR);
+
+	return 0;
+}
+
+static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm)
+{
+	struct rtc_time *alm_tm = &alrm->time;
+	unsigned int alm_en;
+
+	alm_tm->tm_sec  = readb(S3C2410_ALMSEC);
+	alm_tm->tm_min  = readb(S3C2410_ALMMIN);
+	alm_tm->tm_hour = readb(S3C2410_ALMHOUR);
+	alm_tm->tm_mon  = readb(S3C2410_ALMMON);
+	alm_tm->tm_mday = readb(S3C2410_ALMDATE);
+	alm_tm->tm_year = readb(S3C2410_ALMYEAR);
+
+	alm_en = readb(S3C2410_RTCALM);
+
+	pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
+		 alm_en,
+		 alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
+		 alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec);
+
+
+	/* decode the alarm enable field */
+
+	if (alm_en & S3C2410_RTCALM_SECEN) {
+		BCD_TO_BIN(alm_tm->tm_sec);
+	} else {
+		alm_tm->tm_sec = 0xff;
+	}
+
+	if (alm_en & S3C2410_RTCALM_MINEN) {
+		BCD_TO_BIN(alm_tm->tm_min);
+	} else {
+		alm_tm->tm_min = 0xff;
+	}
+
+	if (alm_en & S3C2410_RTCALM_HOUREN) {
+		BCD_TO_BIN(alm_tm->tm_hour);
+	} else {
+		alm_tm->tm_hour = 0xff;
+	}
+
+	if (alm_en & S3C2410_RTCALM_DAYEN) {
+		BCD_TO_BIN(alm_tm->tm_mday);
+	} else {
+		alm_tm->tm_mday = 0xff;
+	}
+
+	if (alm_en & S3C2410_RTCALM_MONEN) {
+		BCD_TO_BIN(alm_tm->tm_mon);
+		alm_tm->tm_mon -= 1;
+	} else {
+		alm_tm->tm_mon = 0xff;
+	}
+
+	if (alm_en & S3C2410_RTCALM_YEAREN) {
+		BCD_TO_BIN(alm_tm->tm_year);
+	} else {
+		alm_tm->tm_year = 0xffff;
+	}
+
+	/* todo - set alrm->enabled ? */
+}
+
+static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm)
+{
+	struct rtc_time *tm = &alrm->time;
+	unsigned int alrm_en;
+
+	pr_debug("s3c2410_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n",
+		 alrm->enabled,
+		 tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff,
+		 tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec);
+
+	if (alrm->enabled || 1) {
+		alrm_en = readb(S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN;
+		writeb(0x00, S3C2410_RTCALM);
+
+		if (tm->tm_sec < 60 && tm->tm_sec >= 0) {
+			alrm_en |= S3C2410_RTCALM_SECEN;
+			writeb(BIN2BCD(tm->tm_sec), S3C2410_ALMSEC);
+		}
+
+		if (tm->tm_min < 60 && tm->tm_min >= 0) {
+			alrm_en |= S3C2410_RTCALM_MINEN;
+			writeb(BIN2BCD(tm->tm_min), S3C2410_ALMMIN);
+		}
+
+		if (tm->tm_hour < 24 && tm->tm_hour >= 0) {
+			alrm_en |= S3C2410_RTCALM_HOUREN;
+			writeb(BIN2BCD(tm->tm_hour), S3C2410_ALMHOUR);
+		}
+
+		pr_debug("setting S3C2410_RTCALM to %08x\n", alrm_en);
+
+		writeb(alrm_en, S3C2410_RTCALM);
+		enable_irq_wake(s3c2410_rtc_alarmno);
+	} else {
+		alrm_en = readb(S3C2410_RTCALM);
+		alrm_en &= ~S3C2410_RTCALM_ALMEN;
+		writeb(alrm_en, S3C2410_RTCALM);
+		disable_irq_wake(s3c2410_rtc_alarmno);
+	}
+
+	return 0;
+}
+
+static int s3c2410_rtc_ioctl(unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case RTC_AIE_OFF:
+	case RTC_AIE_ON:
+		s3c2410_rtc_setaie((cmd == RTC_AIE_ON) ? 1 : 0);
+		return 0;
+
+	case RTC_PIE_OFF:
+	case RTC_PIE_ON:
+		s3c2410_rtc_setpie((cmd == RTC_PIE_ON) ? 1 : 0);
+		return 0;
+
+	case RTC_IRQP_READ:
+		return put_user(s3c2410_rtc_freq, (unsigned long __user *)arg);
+
+	case RTC_IRQP_SET:
+		if (arg < 1 || arg > 64)
+			return -EINVAL;
+
+		if (!capable(CAP_SYS_RESOURCE))
+			return -EACCES;
+
+		/* check for power of 2 */
+
+		if ((arg & (arg-1)) != 0)
+			return -EINVAL;
+
+		pr_debug("s3c2410_rtc: setting frequency %ld\n", arg);
+
+		s3c2410_rtc_setfreq(arg);
+		return 0;
+
+	case RTC_UIE_ON:
+	case RTC_UIE_OFF:
+		return -EINVAL;
+	}
+
+	return -EINVAL;
+}
+
+static int s3c2410_rtc_proc(char *buf)
+{
+	unsigned int rtcalm = readb(S3C2410_RTCALM);
+	unsigned int ticnt = readb (S3C2410_TICNT);
+	char *p = buf;
+
+	p += sprintf(p, "alarm_IRQ\t: %s\n",
+		     (rtcalm & S3C2410_RTCALM_ALMEN) ? "yes" : "no" );
+	p += sprintf(p, "periodic_IRQ\t: %s\n",
+		     (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" );
+	p += sprintf(p, "periodic_freq\t: %d\n", s3c2410_rtc_freq);
+
+	return p - buf;
+}
+
+static int s3c2410_rtc_open(void)
+{
+	int ret;
+
+	ret = request_irq(s3c2410_rtc_alarmno, s3c2410_rtc_alarmirq,
+			  SA_INTERRUPT,  "s3c2410-rtc alarm", NULL);
+
+	if (ret)
+		printk(KERN_ERR "IRQ%d already in use\n", s3c2410_rtc_alarmno);
+
+	ret = request_irq(s3c2410_rtc_tickno, s3c2410_rtc_tickirq,
+			  SA_INTERRUPT,  "s3c2410-rtc tick", NULL);
+
+	if (ret) {
+		printk(KERN_ERR "IRQ%d already in use\n", s3c2410_rtc_tickno);
+		goto tick_err;
+	}
+
+	return ret;
+
+ tick_err:
+	free_irq(s3c2410_rtc_alarmno, NULL);
+	return ret;
+}
+
+static void s3c2410_rtc_release(void)
+{
+	/* do not clear AIE here, it may be needed for wake */
+
+	s3c2410_rtc_setpie(0);
+	free_irq(s3c2410_rtc_alarmno, NULL);
+	free_irq(s3c2410_rtc_tickno, NULL);
+}
+
+static struct rtc_ops s3c2410_rtcops = {
+	.owner		= THIS_MODULE,
+	.open		= s3c2410_rtc_open,
+	.release	= s3c2410_rtc_release,
+	.ioctl		= s3c2410_rtc_ioctl,
+	.read_time	= s3c2410_rtc_gettime,
+	.set_time	= s3c2410_rtc_settime,
+	.read_alarm	= s3c2410_rtc_getalarm,
+	.set_alarm	= s3c2410_rtc_setalarm,
+	.proc	        = s3c2410_rtc_proc,
+};
+
+static void s3c2410_rtc_enable(struct device *dev, int en)
+{
+	unsigned int tmp;
+
+	if (s3c2410_rtc_base == NULL)
+		return;
+
+	if (!en) {
+		tmp = readb(S3C2410_RTCCON);
+		writeb(tmp & ~S3C2410_RTCCON_RTCEN, S3C2410_RTCCON);
+
+		tmp = readb(S3C2410_TICNT);
+		writeb(tmp & ~S3C2410_TICNT_ENABLE, S3C2410_TICNT);
+	} else {
+		/* re-enable the device, and check it is ok */
+
+		if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_RTCEN) == 0){
+			dev_info(dev, "rtc disabled, re-enabling\n");
+
+			tmp = readb(S3C2410_RTCCON);
+			writeb(tmp | S3C2410_RTCCON_RTCEN , S3C2410_RTCCON);
+		}
+
+		if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_CNTSEL)){
+			dev_info(dev, "removing S3C2410_RTCCON_CNTSEL\n");
+
+			tmp = readb(S3C2410_RTCCON);
+			writeb(tmp& ~S3C2410_RTCCON_CNTSEL , S3C2410_RTCCON);
+		}
+
+		if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_CLKRST)){
+			dev_info(dev, "removing S3C2410_RTCCON_CLKRST\n");
+
+			tmp = readb(S3C2410_RTCCON);
+			writeb(tmp & ~S3C2410_RTCCON_CLKRST, S3C2410_RTCCON);
+		}
+	}
+}
+
+static int s3c2410_rtc_remove(struct device *dev)
+{
+	unregister_rtc(&s3c2410_rtcops);
+
+	s3c2410_rtc_setpie(0);
+	s3c2410_rtc_setaie(0);
+
+	if (s3c2410_rtc_mem != NULL) {
+		pr_debug("s3c2410_rtc: releasing s3c2410_rtc_mem\n");
+		iounmap(s3c2410_rtc_base);
+		release_resource(s3c2410_rtc_mem);
+		kfree(s3c2410_rtc_mem);
+	}
+
+	return 0;
+}
+
+static int s3c2410_rtc_probe(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct resource *res;
+	int ret;
+
+	pr_debug("%s: probe=%p, device=%p\n", __FUNCTION__, pdev, dev);
+
+	/* find the IRQs */
+
+	s3c2410_rtc_tickno = platform_get_irq(pdev, 1);
+	if (s3c2410_rtc_tickno <= 0) {
+		dev_err(dev, "no irq for rtc tick\n");
+		return -ENOENT;
+	}
+
+	s3c2410_rtc_alarmno = platform_get_irq(pdev, 0);
+	if (s3c2410_rtc_alarmno <= 0) {
+		dev_err(dev, "no irq for alarm\n");
+		return -ENOENT;
+	}
+
+	pr_debug("s3c2410_rtc: tick irq %d, alarm irq %d\n",
+		 s3c2410_rtc_tickno, s3c2410_rtc_alarmno);
+
+	/* get the memory region */
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(dev, "failed to get memory region resource\n");
+		return -ENOENT;
+	}
+
+	s3c2410_rtc_mem = request_mem_region(res->start, res->end-res->start+1,
+				     pdev->name);
+
+	if (s3c2410_rtc_mem == NULL) {
+		dev_err(dev, "failed to reserve memory region\n");
+		ret = -ENOENT;
+		goto exit_err;
+	}
+
+	s3c2410_rtc_base = ioremap(res->start, res->end - res->start + 1);
+	if (s3c2410_rtc_base == NULL) {
+		dev_err(dev, "failed ioremap()\n");
+		ret = -EINVAL;
+		goto exit_err;
+	}
+
+	s3c2410_rtc_mem = res;
+	pr_debug("s3c2410_rtc_base=%p\n", s3c2410_rtc_base);
+
+ 	pr_debug("s3c2410_rtc: RTCCON=%02x\n", readb(S3C2410_RTCCON));
+
+	/* check to see if everything is setup correctly */
+
+	s3c2410_rtc_enable(dev, 1);
+
+ 	pr_debug("s3c2410_rtc: RTCCON=%02x\n", readb(S3C2410_RTCCON));
+
+	s3c2410_rtc_setfreq(s3c2410_rtc_freq);
+
+	/* register RTC and exit */
+
+	register_rtc(&s3c2410_rtcops);
+	return 0;
+
+ exit_err:
+	dev_err(dev, "error %d during initialisation\n", ret);
+
+	return ret;
+}
+
+#ifdef CONFIG_PM
+
+/* S3C2410 RTC Power management control */
+
+static struct timespec s3c2410_rtc_delta;
+
+static int ticnt_save;
+
+static int s3c2410_rtc_suspend(struct device *dev, u32 state, u32 level)
+{
+	struct rtc_time tm;
+	struct timespec time;
+
+	time.tv_nsec = 0;
+
+	if (level == SUSPEND_POWER_DOWN) {
+		/* save TICNT for anyone using periodic interrupts */
+
+		ticnt_save = readb(S3C2410_TICNT);
+
+		/* calculate time delta for suspend */
+
+		s3c2410_rtc_gettime(&tm);
+		rtc_tm_to_time(&tm, &time.tv_sec);
+		save_time_delta(&s3c2410_rtc_delta, &time);
+		s3c2410_rtc_enable(dev, 0);
+	}
+
+	return 0;
+}
+
+static int s3c2410_rtc_resume(struct device *dev, u32 level)
+{
+	struct rtc_time tm;
+	struct timespec time;
+
+	time.tv_nsec = 0;
+
+	s3c2410_rtc_enable(dev, 1);
+	s3c2410_rtc_gettime(&tm);
+	rtc_tm_to_time(&tm, &time.tv_sec);
+	restore_time_delta(&s3c2410_rtc_delta, &time);
+
+	writeb(ticnt_save, S3C2410_TICNT);
+	return 0;
+}
+#else
+#define s3c2410_rtc_suspend NULL
+#define s3c2410_rtc_resume  NULL
+#endif
+
+static struct device_driver s3c2410_rtcdrv = {
+	.name		= "s3c2410-rtc",
+	.bus		= &platform_bus_type,
+	.probe		= s3c2410_rtc_probe,
+	.remove		= s3c2410_rtc_remove,
+	.suspend	= s3c2410_rtc_suspend,
+	.resume		= s3c2410_rtc_resume,
+};
+
+static char __initdata banner[] = "S3C2410 RTC, (c) 2004 Simtec Electronics\n";
+
+static int __init s3c2410_rtc_init(void)
+{
+	printk(banner);
+	return driver_register(&s3c2410_rtcdrv);
+}
+
+static void __exit s3c2410_rtc_exit(void)
+{
+	driver_unregister(&s3c2410_rtcdrv);
+}
+
+module_init(s3c2410_rtc_init);
+module_exit(s3c2410_rtc_exit);
+
+MODULE_DESCRIPTION("S3C24XX RTC Driver");
+MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/char/selection.c b/drivers/char/selection.c
--- a/drivers/char/selection.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/char/selection.c	2004-12-24 13:37:29 -08:00
@@ -304,6 +304,3 @@
 	tty_ldisc_deref(ld);
 	return 0;
 }
-
-EXPORT_SYMBOL(set_selection);
-EXPORT_SYMBOL(paste_selection);
diff -Nru a/drivers/char/serial167.c b/drivers/char/serial167.c
--- a/drivers/char/serial167.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/char/serial167.c	2004-12-24 13:36:48 -08:00
@@ -39,6 +39,9 @@
  * - don't use the panic function in serial167_init
  * - do resource release on failure on serial167_init
  * - include missing restore_flags in mvme167_serial_console_setup
+ *
+ * Kars de Jong <jongk@linux-m68k.org> - 2004/09/06
+ * - replace bottom half handler with task queue handler
  */
 
 #include <linux/config.h>
@@ -59,10 +62,10 @@
 #include <linux/mm.h>
 #include <linux/console.h>
 #include <linux/module.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/mvme16xhw.h>
 #include <asm/bootinfo.h>
 #include <asm/setup.h>
@@ -89,8 +92,6 @@
 
 #define SERIAL_TYPE_NORMAL  1
 
-DECLARE_TASK_QUEUE(tq_cyclades);
-
 static struct tty_driver *cy_serial_driver;
 extern int serial_console;
 static struct cyclades_port *serial_console_info = NULL;
@@ -373,8 +374,7 @@
 cy_sched_event(struct cyclades_port *info, int event)
 {
     info->event |= 1 << event; /* remember what kind of event and who */
-    queue_task(&info->tqueue, &tq_cyclades); /* it belongs to */
-    mark_bh(CYCLADES_BH);                       /* then trigger event */
+    schedule_work(&info->tqueue);
 } /* cy_sched_event */
 
 
@@ -467,7 +467,7 @@
 	       and nothing could be done about it!!! */
 	}
     }
-    queue_task(&tty->flip.tqueue, &tq_timer);
+    schedule_delayed_work(&tty->flip.work, 1);
     /* end of service */
     base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
     return IRQ_HANDLED;
@@ -702,7 +702,7 @@
 	    udelay(10L);
 #endif
         }
-	queue_task(&tty->flip.tqueue, &tq_timer);
+	schedule_delayed_work(&tty->flip.work, 1);
     }
     /* end of service */
     base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS;
@@ -713,7 +713,7 @@
  * 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
- * cy_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON.  This
+ * cy#/_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 cy_sched_event(), and they get done here.
@@ -721,9 +721,7 @@
  * This is done through one level of indirection--the task queue.
  * When a hardware interrupt service routine wants service by the
  * driver's bottom half, it enqueues the appropriate tq_struct (one
- * per port) to the tq_cyclades work queue and sets a request flag
- * via mark_bh for processing that queue.  When the time is right,
- * do_cyclades_bh is called (because of the mark_bh) and it requests
+ * per port) to the keventd work queue and sets a request flag
  * that the work queue be processed.
  *
  * Although this may seem unwieldy, it gives the system a way to
@@ -732,12 +730,6 @@
  * had to poll every port to see if that port needed servicing.
  */
 static void
-do_cyclades_bh(void)
-{
-    run_task_queue(&tq_cyclades);
-} /* do_cyclades_bh */
-
-static void
 do_softint(void *private_)
 {
   struct cyclades_port *info = (struct cyclades_port *) private_;
@@ -1208,7 +1200,7 @@
     port is already active, there is no need to kick it.
  */
 static int
-cy_write(struct tty_struct * tty, int from_user,
+cy_write(struct tty_struct * tty,
            const unsigned char *buf, int count)
 {
   struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
@@ -1227,53 +1219,23 @@
         return 0;
     }
 
-    if (from_user) {
-	    down(&tmp_buf_sem);
-	    while (1) {
-		    c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					      SERIAL_XMIT_SIZE - info->xmit_head));
-		    if (c <= 0)
-			    break;
-
-		    c -= copy_from_user(tmp_buf, buf, c);
-		    if (!c) {
-			    if (!total)
-				    total = -EFAULT;
-			    break;
-		    }
-
-		    local_irq_save(flags);
-		    c = min_t(int, c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					  SERIAL_XMIT_SIZE - info->xmit_head));
-		    memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
-		    info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-		    info->xmit_cnt += c;
+    while (1) {
+	    local_irq_save(flags);
+	    c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
+				      SERIAL_XMIT_SIZE - info->xmit_head));
+	    if (c <= 0) {
 		    local_irq_restore(flags);
-
-		    buf += c;
-		    count -= c;
-		    total += c;
+		    break;
 	    }
-	    up(&tmp_buf_sem);
-    } else {
-	    while (1) {
-		    local_irq_save(flags);
-		    c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					      SERIAL_XMIT_SIZE - info->xmit_head));
-		    if (c <= 0) {
-			    local_irq_restore(flags);
-			    break;
-		    }
 
-		    memcpy(info->xmit_buf + info->xmit_head, buf, c);
-		    info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-		    info->xmit_cnt += c;
-		    local_irq_restore(flags);
+	    memcpy(info->xmit_buf + info->xmit_head, buf, c);
+	    info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
+	    info->xmit_cnt += c;
+	    local_irq_restore(flags);
 
-		    buf += c;
-		    count -= c;
-		    total += c;
-	    }
+	    buf += c;
+	    count -= c;
+	    total += c;
     }
 
     if (info->xmit_cnt
@@ -1840,8 +1802,7 @@
     info->tty = 0;
     if (info->blocked_open) {
 	if (info->close_delay) {
-	    current->state = TASK_INTERRUPTIBLE;
-	    schedule_timeout(info->close_delay);
+	    msleep_interruptible(jiffies_to_msecs(info->close_delay));
 	}
 	wake_up_interruptible(&info->open_wait);
     }
@@ -2309,8 +2270,6 @@
 	    return ret;
     }
 
-    init_bh(CYCLADES_BH, do_cyclades_bh);
-
     port_num = 0;
     info = cy_port;
     for (index = 0; index < 1; index++) {
@@ -2348,8 +2307,7 @@
 		info->blocked_open = 0;
 		info->default_threshold = 0;
 		info->default_timeout = 0;
-		info->tqueue.routine = do_softint;
-		info->tqueue.data = info;
+		INIT_WORK(&info->tqueue, do_softint, info);
 		init_waitqueue_head(&info->open_wait);
 		init_waitqueue_head(&info->close_wait);
 		/* info->session */
diff -Nru a/drivers/char/snsc.c b/drivers/char/snsc.c
--- a/drivers/char/snsc.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/char/snsc.c	2004-12-24 13:37:29 -08:00
@@ -21,7 +21,10 @@
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <asm/sn/io.h>
 #include <asm/sn/sn_sal.h>
+#include <asm/sn/module.h>
+#include <asm/sn/geo.h>
 #include <asm/sn/nodepda.h>
 #include "snsc.h"
 
@@ -364,17 +367,15 @@
 scdrv_init(void)
 {
 	geoid_t geoid;
-	cmoduleid_t cmod;
-	int i;
+	cnodeid_t cnode;
 	char devname[32];
 	char *devnamep;
-	module_t *m;
 	struct sysctl_data_s *scd;
 	void *salbuf;
 	struct class_simple *snsc_class;
 	dev_t first_dev, dev;
 
-	if (alloc_chrdev_region(&first_dev, 0, (MAX_SLABS*nummodules),
+	if (alloc_chrdev_region(&first_dev, 0, numionodes,
 				SYSCTL_BASENAME) < 0) {
 		printk("%s: failed to register SN system controller device\n",
 		       __FUNCTION__);
@@ -382,16 +383,8 @@
 	}
 	snsc_class = class_simple_create(THIS_MODULE, SYSCTL_BASENAME);
 
-	for (cmod = 0; cmod < nummodules; cmod++) {
-		m = sn_modules[cmod];
-		for (i = 0; i <= MAX_SLABS; i++) {
-
-			if (m->nodes[i] == -1) {
-				/* node is not alive in module */
-				continue;
-			}
-
-			geoid = m->geoid[i];
+	for (cnode = 0; cnode < numionodes; cnode++) {
+			geoid = cnodeid_get_geoid(cnode);
 			devnamep = devname;
 			format_module_id(devnamep, geo_module(geoid),
 					 MODULE_FORMAT_BRIEF);
@@ -410,7 +403,7 @@
 			memset(scd, 0, sizeof (struct sysctl_data_s));
 
 			/* initialize sysctl device data fields */
-			scd->scd_nasid = cnodeid_to_nasid(m->nodes[i]);
+			scd->scd_nasid = cnodeid_to_nasid(cnode);
 			if (!(salbuf = kmalloc(SCDRV_BUFSZ, GFP_KERNEL))) {
 				printk("%s: failed to allocate driver buffer"
 				       "(%s%s)\n", __FUNCTION__,
@@ -431,7 +424,7 @@
 				continue;
 			}
 
-			dev = first_dev + m->nodes[i];
+			dev = first_dev + cnode;
 			cdev_init(&scd->scd_cdev, &scdrv_fops);
 			if (cdev_add(&scd->scd_cdev, dev, 1)) {
 				printk("%s: failed to register system"
@@ -448,7 +441,6 @@
 			ia64_sn_irtr_intr_enable(scd->scd_nasid,
 						 0 /*ignored */ ,
 						 SAL_IROUTER_INTR_RECV);
-		}
 	}
 	return 0;
 }
diff -Nru a/drivers/char/sonypi.c b/drivers/char/sonypi.c
--- a/drivers/char/sonypi.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/char/sonypi.c	2004-12-24 13:37:03 -08:00
@@ -1,7 +1,7 @@
 /*
  * Sony Programmable I/O Control Device driver for VAIO
  *
- * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
+ * Copyright (C) 2001-2004 Stelian Pop <stelian@popies.net>
  *
  * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
  *
@@ -19,12 +19,12 @@
  * 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.
@@ -44,84 +44,89 @@
 #include <linux/wait.h>
 #include <linux/acpi.h>
 #include <linux/dmi.h>
-#include <linux/sysdev.h>
+#include <linux/err.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/system.h>
 
-static int verbose; /* = 0 */
-
 #include "sonypi.h"
 #include <linux/sonypi.h>
 
-static struct sonypi_device sonypi_device;
+MODULE_AUTHOR("Stelian Pop <stelian@popies.net>");
+MODULE_DESCRIPTION("Sony Programmable I/O Control Device driver");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(SONYPI_DRIVER_VERSION);
+
 static int minor = -1;
-static int fnkeyinit; /* = 0 */
-static int camera; /* = 0 */
-static int compat; /* = 0 */
-static int useinput = 1;
+module_param(minor, int, 0);
+MODULE_PARM_DESC(minor,
+		 "minor number of the misc device, default is -1 (automatic)");
+
+static int verbose;		/* = 0 */
+module_param(verbose, int, 0644);
+MODULE_PARM_DESC(verbose, "be verbose, default is 0 (no)");
+
+static int fnkeyinit;		/* = 0 */
+module_param(fnkeyinit, int, 0444);
+MODULE_PARM_DESC(fnkeyinit,
+		 "set this if your Fn keys do not generate any event");
+
+static int camera;		/* = 0 */
+module_param(camera, int, 0444);
+MODULE_PARM_DESC(camera,
+		 "set this if you have a MotionEye camera (PictureBook series)");
+
+static int compat;		/* = 0 */
+module_param(compat, int, 0444);
+MODULE_PARM_DESC(compat,
+		 "set this if you want to enable backward compatibility mode");
+
 static unsigned long mask = 0xffffffff;
+module_param(mask, ulong, 0644);
+MODULE_PARM_DESC(mask,
+		 "set this to the mask of event you want to enable (see doc)");
 
-/* Inits the queue */
-static inline void sonypi_initq(void) {
-        sonypi_device.queue.head = sonypi_device.queue.tail = 0;
-	sonypi_device.queue.len = 0;
-	sonypi_device.queue.s_lock = SPIN_LOCK_UNLOCKED;
-	init_waitqueue_head(&sonypi_device.queue.proc_list);
-}
-
-/* Pulls an event from the queue */
-static inline unsigned char sonypi_pullq(void) {
-        unsigned char result;
-	unsigned long flags;
-
-	spin_lock_irqsave(&sonypi_device.queue.s_lock, flags);
-	if (!sonypi_device.queue.len) {
-		spin_unlock_irqrestore(&sonypi_device.queue.s_lock, flags);
-		return 0;
-	}
-	result = sonypi_device.queue.buf[sonypi_device.queue.head];
-        sonypi_device.queue.head++;
-	sonypi_device.queue.head &= (SONYPI_BUF_SIZE - 1);
-	sonypi_device.queue.len--;
-	spin_unlock_irqrestore(&sonypi_device.queue.s_lock, flags);
-        return result;
-}
-
-/* Pushes an event into the queue */
-static inline void sonypi_pushq(unsigned char event) {
-	unsigned long flags;
-
-	spin_lock_irqsave(&sonypi_device.queue.s_lock, flags);
-	if (sonypi_device.queue.len == SONYPI_BUF_SIZE) {
-		/* remove the first element */
-        	sonypi_device.queue.head++;
-		sonypi_device.queue.head &= (SONYPI_BUF_SIZE - 1);
-		sonypi_device.queue.len--;
-	}
-	sonypi_device.queue.buf[sonypi_device.queue.tail] = event;
-	sonypi_device.queue.tail++;
-	sonypi_device.queue.tail &= (SONYPI_BUF_SIZE - 1);
-	sonypi_device.queue.len++;
-
-	kill_fasync(&sonypi_device.queue.fasync, SIGIO, POLL_IN);
-	wake_up_interruptible(&sonypi_device.queue.proc_list);
-	spin_unlock_irqrestore(&sonypi_device.queue.s_lock, flags);
-}
-
-/* Tests if the queue is empty */
-static inline int sonypi_emptyq(void) {
-        int result;
-	unsigned long flags;
-
-	spin_lock_irqsave(&sonypi_device.queue.s_lock, flags);
-        result = (sonypi_device.queue.len == 0);
-	spin_unlock_irqrestore(&sonypi_device.queue.s_lock, flags);
-        return result;
+static int useinput = 1;
+module_param(useinput, int, 0444);
+MODULE_PARM_DESC(useinput,
+		 "set this if you would like sonypi to feed events to the input subsystem");
+
+static struct sonypi_device sonypi_device;
+
+static int sonypi_ec_write(u8 addr, u8 value)
+{
+#ifdef CONFIG_ACPI_EC
+	if (SONYPI_ACPI_ACTIVE)
+		return ec_write(addr, value);
+#endif
+	wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3, ITERATIONS_LONG);
+	outb_p(0x81, SONYPI_CST_IOPORT);
+	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
+	outb_p(addr, SONYPI_DATA_IOPORT);
+	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
+	outb_p(value, SONYPI_DATA_IOPORT);
+	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
+	return 0;
 }
 
-static int ec_read16(u8 addr, u16 *value) {
+static int sonypi_ec_read(u8 addr, u8 *value)
+{
+#ifdef CONFIG_ACPI_EC
+	if (SONYPI_ACPI_ACTIVE)
+		return ec_read(addr, value);
+#endif
+	wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3, ITERATIONS_LONG);
+	outb_p(0x80, SONYPI_CST_IOPORT);
+	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
+	outb_p(addr, SONYPI_DATA_IOPORT);
+	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
+	*value = inb_p(SONYPI_DATA_IOPORT);
+	return 0;
+}
+
+static int ec_read16(u8 addr, u16 *value)
+{
 	u8 val_lb, val_hb;
 	if (sonypi_ec_read(addr, &val_lb))
 		return -1;
@@ -132,21 +137,22 @@
 }
 
 /* Initializes the device - this comes from the AML code in the ACPI bios */
-static void sonypi_type1_srs(void) {
+static void sonypi_type1_srs(void)
+{
 	u32 v;
 
 	pci_read_config_dword(sonypi_device.dev, SONYPI_G10A, &v);
-	v = (v & 0xFFFF0000) | ((u32)sonypi_device.ioport1);
+	v = (v & 0xFFFF0000) | ((u32) sonypi_device.ioport1);
 	pci_write_config_dword(sonypi_device.dev, SONYPI_G10A, v);
 
 	pci_read_config_dword(sonypi_device.dev, SONYPI_G10A, &v);
-	v = (v & 0xFFF0FFFF) | 
-	    (((u32)sonypi_device.ioport1 ^ sonypi_device.ioport2) << 16);
+	v = (v & 0xFFF0FFFF) |
+	    (((u32) sonypi_device.ioport1 ^ sonypi_device.ioport2) << 16);
 	pci_write_config_dword(sonypi_device.dev, SONYPI_G10A, v);
 
 	v = inl(SONYPI_IRQ_PORT);
-	v &= ~(((u32)0x3) << SONYPI_IRQ_SHIFT);
-	v |= (((u32)sonypi_device.bits) << SONYPI_IRQ_SHIFT);
+	v &= ~(((u32) 0x3) << SONYPI_IRQ_SHIFT);
+	v |= (((u32) sonypi_device.bits) << SONYPI_IRQ_SHIFT);
 	outl(v, SONYPI_IRQ_PORT);
 
 	pci_read_config_dword(sonypi_device.dev, SONYPI_G10A, &v);
@@ -154,18 +160,20 @@
 	pci_write_config_dword(sonypi_device.dev, SONYPI_G10A, v);
 }
 
-static void sonypi_type2_srs(void) {
+static void sonypi_type2_srs(void)
+{
 	if (sonypi_ec_write(SONYPI_SHIB, (sonypi_device.ioport1 & 0xFF00) >> 8))
 		printk(KERN_WARNING "ec_write failed\n");
-	if (sonypi_ec_write(SONYPI_SLOB,  sonypi_device.ioport1 & 0x00FF))
+	if (sonypi_ec_write(SONYPI_SLOB, sonypi_device.ioport1 & 0x00FF))
 		printk(KERN_WARNING "ec_write failed\n");
-	if (sonypi_ec_write(SONYPI_SIRQ,  sonypi_device.bits))
+	if (sonypi_ec_write(SONYPI_SIRQ, sonypi_device.bits))
 		printk(KERN_WARNING "ec_write failed\n");
 	udelay(10);
 }
 
 /* Disables the device - this comes from the AML code in the ACPI bios */
-static void sonypi_type1_dis(void) {
+static void sonypi_type1_dis(void)
+{
 	u32 v;
 
 	pci_read_config_dword(sonypi_device.dev, SONYPI_G10A, &v);
@@ -177,7 +185,8 @@
 	outl(v, SONYPI_IRQ_PORT);
 }
 
-static void sonypi_type2_dis(void) {
+static void sonypi_type2_dis(void)
+{
 	if (sonypi_ec_write(SONYPI_SHIB, 0))
 		printk(KERN_WARNING "ec_write failed\n");
 	if (sonypi_ec_write(SONYPI_SLOB, 0))
@@ -186,7 +195,8 @@
 		printk(KERN_WARNING "ec_write failed\n");
 }
 
-static u8 sonypi_call1(u8 dev) {
+static u8 sonypi_call1(u8 dev)
+{
 	u8 v1, v2;
 
 	wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
@@ -196,7 +206,8 @@
 	return v2;
 }
 
-static u8 sonypi_call2(u8 dev, u8 fn) {
+static u8 sonypi_call2(u8 dev, u8 fn)
+{
 	u8 v1;
 
 	wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
@@ -207,7 +218,8 @@
 	return v1;
 }
 
-static u8 sonypi_call3(u8 dev, u8 fn, u8 v) {
+static u8 sonypi_call3(u8 dev, u8 fn, u8 v)
+{
 	u8 v1;
 
 	wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
@@ -220,7 +232,10 @@
 	return v1;
 }
 
-static u8 sonypi_read(u8 fn) {
+#if 0
+/* Get brightness, hue etc. Unreliable... */
+static u8 sonypi_read(u8 fn)
+{
 	u8 v1, v2;
 	int n = 100;
 
@@ -232,15 +247,17 @@
 	}
 	return 0xff;
 }
+#endif
 
 /* Set brightness, hue etc */
-static void sonypi_set(u8 fn, u8 v) {
-	
+static void sonypi_set(u8 fn, u8 v)
+{
 	wait_on_command(0, sonypi_call3(0x90, fn, v), ITERATIONS_SHORT);
 }
 
 /* Tests if the camera is ready */
-static int sonypi_camera_ready(void) {
+static int sonypi_camera_ready(void)
+{
 	u8 v;
 
 	v = sonypi_call2(0x8f, SONYPI_CAMERA_STATUS);
@@ -248,19 +265,20 @@
 }
 
 /* Turns the camera off */
-static void sonypi_camera_off(void) {
-
+static void sonypi_camera_off(void)
+{
 	sonypi_set(SONYPI_CAMERA_PICTURE, SONYPI_CAMERA_MUTE_MASK);
 
 	if (!sonypi_device.camera_power)
 		return;
 
-	sonypi_call2(0x91, 0); 
+	sonypi_call2(0x91, 0);
 	sonypi_device.camera_power = 0;
 }
 
 /* Turns the camera on */
-static void sonypi_camera_on(void) {
+static void sonypi_camera_on(void)
+{
 	int i, j;
 
 	if (sonypi_device.camera_power)
@@ -283,7 +301,7 @@
 		if (i)
 			break;
 	}
-	
+
 	if (j == 0) {
 		printk(KERN_WARNING "sonypi: failed to power on camera\n");
 		return;
@@ -294,19 +312,42 @@
 }
 
 /* sets the bluetooth subsystem power state */
-static void sonypi_setbluetoothpower(u8 state) {
-
+static void sonypi_setbluetoothpower(u8 state)
+{
 	state = !!state;
-	if (sonypi_device.bluetooth_power == state) 
+
+	if (sonypi_device.bluetooth_power == state)
 		return;
-	
+
 	sonypi_call2(0x96, state);
 	sonypi_call1(0x82);
 	sonypi_device.bluetooth_power = state;
 }
 
+static void input_keyrelease(void *data)
+{
+	struct input_dev *input_dev;
+	int key;
+
+	while (1) {
+		if (kfifo_get(sonypi_device.input_fifo,
+			      (unsigned char *)&input_dev,
+			      sizeof(input_dev)) != sizeof(input_dev))
+			return;
+		if (kfifo_get(sonypi_device.input_fifo,
+			      (unsigned char *)&key,
+			      sizeof(key)) != sizeof(key))
+			return;
+
+		msleep(10);
+		input_report_key(input_dev, key, 0);
+		input_sync(input_dev);
+	}
+}
+
 /* Interrupt handler: some event is available */
-static irqreturn_t sonypi_irq(int irq, void *dev_id, struct pt_regs *regs) {
+static irqreturn_t sonypi_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
 	u8 v1, v2, event = 0;
 	int i, j;
 
@@ -316,9 +357,10 @@
 	for (i = 0; sonypi_eventtypes[i].model; i++) {
 		if (sonypi_device.model != sonypi_eventtypes[i].model)
 			continue;
-		if ((v2 & sonypi_eventtypes[i].data) != sonypi_eventtypes[i].data)
+		if ((v2 & sonypi_eventtypes[i].data) !=
+		    sonypi_eventtypes[i].data)
 			continue;
-		if (! (mask & sonypi_eventtypes[i].mask))
+		if (!(mask & sonypi_eventtypes[i].mask))
 			continue;
 		for (j = 0; sonypi_eventtypes[i].events[j].event; j++) {
 			if (v1 == sonypi_eventtypes[i].events[j].data) {
@@ -329,124 +371,131 @@
 	}
 
 	if (verbose)
-		printk(KERN_WARNING 
-		       "sonypi: unknown event port1=0x%02x,port2=0x%02x\n",v1,v2);
+		printk(KERN_WARNING
+		       "sonypi: unknown event port1=0x%02x,port2=0x%02x\n",
+		       v1, v2);
 	/* We need to return IRQ_HANDLED here because there *are*
-	 * events belonging to the sonypi device we don't know about, 
+	 * events belonging to the sonypi device we don't know about,
 	 * but we still don't want those to pollute the logs... */
 	return IRQ_HANDLED;
 
 found:
 	if (verbose > 1)
-		printk(KERN_INFO 
+		printk(KERN_INFO
 		       "sonypi: event port1=0x%02x,port2=0x%02x\n", v1, v2);
 
-#ifdef SONYPI_USE_INPUT
 	if (useinput) {
-		struct input_dev *jog_dev = &sonypi_device.jog_dev;
-		if (event == SONYPI_EVENT_JOGDIAL_PRESSED)
-			input_report_key(jog_dev, BTN_MIDDLE, 1);
-		else if (event == SONYPI_EVENT_ANYBUTTON_RELEASED)
-			input_report_key(jog_dev, BTN_MIDDLE, 0);
-		else if ((event == SONYPI_EVENT_JOGDIAL_UP) ||
-			 (event == SONYPI_EVENT_JOGDIAL_UP_PRESSED))
-			input_report_rel(jog_dev, REL_WHEEL, 1);
-		else if ((event == SONYPI_EVENT_JOGDIAL_DOWN) ||
-			 (event == SONYPI_EVENT_JOGDIAL_DOWN_PRESSED))
-			input_report_rel(jog_dev, REL_WHEEL, -1);
-		input_sync(jog_dev);
-	}
-#endif /* SONYPI_USE_INPUT */
-	sonypi_pushq(event);
+		struct input_dev *input_jog_dev = &sonypi_device.input_jog_dev;
+		struct input_dev *input_key_dev = &sonypi_device.input_key_dev;
+		switch (event) {
+		case SONYPI_EVENT_JOGDIAL_UP:
+		case SONYPI_EVENT_JOGDIAL_UP_PRESSED:
+			input_report_rel(input_jog_dev, REL_WHEEL, 1);
+			break;
+		case SONYPI_EVENT_JOGDIAL_DOWN:
+		case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED:
+			input_report_rel(input_jog_dev, REL_WHEEL, -1);
+			break;
+		case SONYPI_EVENT_JOGDIAL_PRESSED: {
+			int key = BTN_MIDDLE;
+			input_report_key(input_jog_dev, key, 1);
+			kfifo_put(sonypi_device.input_fifo,
+				  (unsigned char *)&input_jog_dev,
+				  sizeof(input_jog_dev));
+			kfifo_put(sonypi_device.input_fifo,
+				  (unsigned char *)&key, sizeof(key));
+			break;
+		}
+		case SONYPI_EVENT_FNKEY_RELEASED:
+			/* Nothing, not all VAIOs generate this event */
+			break;
+		}
+		input_sync(input_jog_dev);
+
+		for (i = 0; sonypi_inputkeys[i].sonypiev; i++) {
+			int key;
+
+			if (event != sonypi_inputkeys[i].sonypiev)
+				continue;
+
+			key = sonypi_inputkeys[i].inputev;
+			input_report_key(input_key_dev, key, 1);
+			kfifo_put(sonypi_device.input_fifo,
+				  (unsigned char *)&input_key_dev,
+				  sizeof(input_key_dev));
+			kfifo_put(sonypi_device.input_fifo,
+				  (unsigned char *)&key, sizeof(key));
+		}
+		input_sync(input_key_dev);
+		schedule_work(&sonypi_device.input_work);
+	}
+
+	kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event));
+	kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
+	wake_up_interruptible(&sonypi_device.fifo_proc_list);
+
 	return IRQ_HANDLED;
 }
 
 /* External camera command (exported to the motion eye v4l driver) */
-u8 sonypi_camera_command(int command, u8 value) {
-	u8 ret = 0;
-
+int sonypi_camera_command(int command, u8 value)
+{
 	if (!camera)
-		return 0;
+		return -EIO;
 
 	down(&sonypi_device.lock);
 
-	switch(command) {
-		case SONYPI_COMMAND_GETCAMERA:
-			ret = sonypi_camera_ready();
-			break;
-		case SONYPI_COMMAND_SETCAMERA:
-			if (value)
-				sonypi_camera_on();
-			else
-				sonypi_camera_off();
-			break;
-		case SONYPI_COMMAND_GETCAMERABRIGHTNESS:
-			ret = sonypi_read(SONYPI_CAMERA_BRIGHTNESS);
-			break;
-		case SONYPI_COMMAND_SETCAMERABRIGHTNESS:
-			sonypi_set(SONYPI_CAMERA_BRIGHTNESS, value);
-			break;
-		case SONYPI_COMMAND_GETCAMERACONTRAST:
-			ret = sonypi_read(SONYPI_CAMERA_CONTRAST);
-			break;
-		case SONYPI_COMMAND_SETCAMERACONTRAST:
-			sonypi_set(SONYPI_CAMERA_CONTRAST, value);
-			break;
-		case SONYPI_COMMAND_GETCAMERAHUE:
-			ret = sonypi_read(SONYPI_CAMERA_HUE);
-			break;
-		case SONYPI_COMMAND_SETCAMERAHUE:
-			sonypi_set(SONYPI_CAMERA_HUE, value);
-			break;
-		case SONYPI_COMMAND_GETCAMERACOLOR:
-			ret = sonypi_read(SONYPI_CAMERA_COLOR);
-			break;
-		case SONYPI_COMMAND_SETCAMERACOLOR:
-			sonypi_set(SONYPI_CAMERA_COLOR, value);
-			break;
-		case SONYPI_COMMAND_GETCAMERASHARPNESS:
-			ret = sonypi_read(SONYPI_CAMERA_SHARPNESS);
-			break;
-		case SONYPI_COMMAND_SETCAMERASHARPNESS:
-			sonypi_set(SONYPI_CAMERA_SHARPNESS, value);
-			break;
-		case SONYPI_COMMAND_GETCAMERAPICTURE:
-			ret = sonypi_read(SONYPI_CAMERA_PICTURE);
-			break;
-		case SONYPI_COMMAND_SETCAMERAPICTURE:
-			sonypi_set(SONYPI_CAMERA_PICTURE, value);
-			break;
-		case SONYPI_COMMAND_GETCAMERAAGC:
-			ret = sonypi_read(SONYPI_CAMERA_AGC);
-			break;
-		case SONYPI_COMMAND_SETCAMERAAGC:
-			sonypi_set(SONYPI_CAMERA_AGC, value);
-			break;
-		case SONYPI_COMMAND_GETCAMERADIRECTION:
-			ret = sonypi_read(SONYPI_CAMERA_STATUS);
-			ret &= SONYPI_DIRECTION_BACKWARDS;
-			break;
-		case SONYPI_COMMAND_GETCAMERAROMVERSION:
-			ret = sonypi_read(SONYPI_CAMERA_ROMVERSION);
-			break;
-		case SONYPI_COMMAND_GETCAMERAREVISION:
-			ret = sonypi_read(SONYPI_CAMERA_REVISION);
-			break;
+	switch (command) {
+	case SONYPI_COMMAND_SETCAMERA:
+		if (value)
+			sonypi_camera_on();
+		else
+			sonypi_camera_off();
+		break;
+	case SONYPI_COMMAND_SETCAMERABRIGHTNESS:
+		sonypi_set(SONYPI_CAMERA_BRIGHTNESS, value);
+		break;
+	case SONYPI_COMMAND_SETCAMERACONTRAST:
+		sonypi_set(SONYPI_CAMERA_CONTRAST, value);
+		break;
+	case SONYPI_COMMAND_SETCAMERAHUE:
+		sonypi_set(SONYPI_CAMERA_HUE, value);
+		break;
+	case SONYPI_COMMAND_SETCAMERACOLOR:
+		sonypi_set(SONYPI_CAMERA_COLOR, value);
+		break;
+	case SONYPI_COMMAND_SETCAMERASHARPNESS:
+		sonypi_set(SONYPI_CAMERA_SHARPNESS, value);
+		break;
+	case SONYPI_COMMAND_SETCAMERAPICTURE:
+		sonypi_set(SONYPI_CAMERA_PICTURE, value);
+		break;
+	case SONYPI_COMMAND_SETCAMERAAGC:
+		sonypi_set(SONYPI_CAMERA_AGC, value);
+		break;
+	default:
+		printk(KERN_ERR "sonypi: sonypi_camera_command invalid: %d\n",
+		       command);
+		break;
 	}
 	up(&sonypi_device.lock);
-	return ret;
+	return 0;
 }
 
-static int sonypi_misc_fasync(int fd, struct file *filp, int on) {
+EXPORT_SYMBOL(sonypi_camera_command);
+
+static int sonypi_misc_fasync(int fd, struct file *filp, int on)
+{
 	int retval;
 
-	retval = fasync_helper(fd, filp, on, &sonypi_device.queue.fasync);
+	retval = fasync_helper(fd, filp, on, &sonypi_device.fifo_async);
 	if (retval < 0)
 		return retval;
 	return 0;
 }
 
-static int sonypi_misc_release(struct inode * inode, struct file * file) {
+static int sonypi_misc_release(struct inode *inode, struct file *file)
+{
 	sonypi_misc_fasync(-1, file, 0);
 	down(&sonypi_device.lock);
 	sonypi_device.open_count--;
@@ -454,59 +503,56 @@
 	return 0;
 }
 
-static int sonypi_misc_open(struct inode * inode, struct file * file) {
+static int sonypi_misc_open(struct inode *inode, struct file *file)
+{
 	down(&sonypi_device.lock);
 	/* Flush input queue on first open */
 	if (!sonypi_device.open_count)
-		sonypi_initq();
+		kfifo_reset(sonypi_device.fifo);
 	sonypi_device.open_count++;
 	up(&sonypi_device.lock);
 	return 0;
 }
 
-static ssize_t sonypi_misc_read(struct file * file, char __user * buf,
-			size_t count, loff_t *pos)
+static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
+				size_t count, loff_t *pos)
 {
-	DECLARE_WAITQUEUE(wait, current);
-	ssize_t i = count;
+	ssize_t ret;
 	unsigned char c;
 
-	if (sonypi_emptyq()) {
-		if (file->f_flags & O_NONBLOCK)
-			return -EAGAIN;
-		add_wait_queue(&sonypi_device.queue.proc_list, &wait);
-repeat:
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (sonypi_emptyq() && !signal_pending(current)) {
-			schedule();
-			goto repeat;
-		}
-		current->state = TASK_RUNNING;
-		remove_wait_queue(&sonypi_device.queue.proc_list, &wait);
-	}
-	while (i > 0 && !sonypi_emptyq()) {
-		c = sonypi_pullq();
-		put_user(c, buf++);
-		i--;
-        }
-	if (count - i) {
-		file->f_dentry->d_inode->i_atime = CURRENT_TIME;
-		return count-i;
+	if ((kfifo_len(sonypi_device.fifo) == 0) &&
+	    (file->f_flags & O_NONBLOCK))
+		return -EAGAIN;
+
+	ret = wait_event_interruptible(sonypi_device.fifo_proc_list,
+				       kfifo_len(sonypi_device.fifo) != 0);
+	if (ret)
+		return ret;
+
+	while (ret < count &&
+	       (kfifo_get(sonypi_device.fifo, &c, sizeof(c)) == sizeof(c))) {
+		if (put_user(c, buf++))
+			return -EFAULT;
+		ret++;
 	}
-	if (signal_pending(current))
-		return -ERESTARTSYS;
-	return 0;
+
+	if (ret > 0)
+		file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+
+	return ret;
 }
 
-static unsigned int sonypi_misc_poll(struct file *file, poll_table * wait) {
-	poll_wait(file, &sonypi_device.queue.proc_list, wait);
-	if (!sonypi_emptyq())
+static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait)
+{
+	poll_wait(file, &sonypi_device.fifo_proc_list, wait);
+	if (kfifo_len(sonypi_device.fifo))
 		return POLLIN | POLLRDNORM;
 	return 0;
 }
 
-static int sonypi_misc_ioctl(struct inode *ip, struct file *fp, 
-			     unsigned int cmd, unsigned long arg) {
+static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
+			     unsigned int cmd, unsigned long arg)
+{
 	int ret = 0;
 	void __user *argp = (void __user *)arg;
 	u8 val8;
@@ -601,99 +647,119 @@
 };
 
 struct miscdevice sonypi_misc_device = {
-	-1, "sonypi", &sonypi_misc_fops
+	.minor		= -1,
+	.name		= "sonypi",
+	.fops		= &sonypi_misc_fops,
 };
 
-#ifdef CONFIG_PM
-static int old_camera_power;
-
-static int sonypi_suspend(struct sys_device *dev, u32 state) {
-	sonypi_call2(0x81, 0); /* make sure we don't get any more events */
-	if (camera) {
-		old_camera_power = sonypi_device.camera_power;
-		sonypi_camera_off();
-	}
+static void sonypi_enable(unsigned int camera_on)
+{
 	if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2)
-		sonypi_type2_dis();
+		sonypi_type2_srs();
 	else
-		sonypi_type1_dis();
-	/* disable ACPI mode */
-	if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
-		outb(0xf1, 0xb2);
-	return 0;
-}
+		sonypi_type1_srs();
+
+	sonypi_call1(0x82);
+	sonypi_call2(0x81, 0xff);
+	sonypi_call1(compat ? 0x92 : 0x82);
 
-static int sonypi_resume(struct sys_device *dev) {
 	/* Enable ACPI mode to get Fn key events */
 	if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
 		outb(0xf0, 0xb2);
+
+	if (camera && camera_on)
+		sonypi_camera_on();
+}
+
+static int sonypi_disable(void)
+{
+	sonypi_call2(0x81, 0);	/* make sure we don't get any more events */
+	if (camera)
+		sonypi_camera_off();
+
+	/* disable ACPI mode */
+	if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
+		outb(0xf1, 0xb2);
+
 	if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2)
-		sonypi_type2_srs();
-	else
-		sonypi_type1_srs();
-	sonypi_call1(0x82);
-	sonypi_call2(0x81, 0xff);
-	if (compat)
-		sonypi_call1(0x92); 
+		sonypi_type2_dis();
 	else
-		sonypi_call1(0x82);
-	if (camera && old_camera_power)
-		sonypi_camera_on();
+		sonypi_type1_dis();
 	return 0;
 }
 
-/* Old PM scheme */
-static int sonypi_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data) {
+#ifdef CONFIG_PM
+static int old_camera_power;
 
-	switch (rqst) {
-		case PM_SUSPEND:
-			sonypi_suspend(NULL, 0);
-			break;
-		case PM_RESUME:
-			sonypi_resume(NULL);
-			break;
+static int sonypi_suspend(struct device *dev, u32 state, u32 level)
+{
+	if (level == SUSPEND_DISABLE) {
+		old_camera_power = sonypi_device.camera_power;
+		sonypi_disable();
 	}
 	return 0;
 }
 
-/* New PM scheme (device model) */
-static struct sysdev_class sonypi_sysclass = {
-	set_kset_name("sonypi"),
-	.suspend = sonypi_suspend,
-	.resume = sonypi_resume,
-};
+static int sonypi_resume(struct device *dev, u32 level)
+{
+	if (level == RESUME_ENABLE)
+		sonypi_enable(old_camera_power);
+	return 0;
+}
+#endif
 
-static struct sys_device sonypi_sysdev = {
-	.id = 0,
-	.cls = &sonypi_sysclass,
-};
+static void sonypi_shutdown(struct device *dev)
+{
+	sonypi_disable();
+}
+
+static struct device_driver sonypi_driver = {
+	.name		= "sonypi",
+	.bus		= &platform_bus_type,
+#ifdef CONFIG_PM
+	.suspend	= sonypi_suspend,
+	.resume		= sonypi_resume,
 #endif
+	.shutdown	= sonypi_shutdown,
+};
 
-static int __devinit sonypi_probe(struct pci_dev *pcidev) {
+static int __devinit sonypi_probe(void)
+{
 	int i, ret;
 	struct sonypi_ioport_list *ioport_list;
 	struct sonypi_irq_list *irq_list;
+	struct pci_dev *pcidev;
+
+	pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
+				PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
 
 	sonypi_device.dev = pcidev;
-	if (pcidev)
-		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE1;
-	else
-		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2;
-	sonypi_initq();
+	sonypi_device.model = pcidev ?
+		SONYPI_DEVICE_MODEL_TYPE1 : SONYPI_DEVICE_MODEL_TYPE2;
+
+	sonypi_device.fifo_lock = SPIN_LOCK_UNLOCKED;
+	sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
+					 &sonypi_device.fifo_lock);
+	if (IS_ERR(sonypi_device.fifo)) {
+		printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
+		ret = PTR_ERR(sonypi_device.fifo);
+		goto out_fifo;
+	}
+
+	init_waitqueue_head(&sonypi_device.fifo_proc_list);
 	init_MUTEX(&sonypi_device.lock);
-	sonypi_device.bluetooth_power = 0;
-	
+	sonypi_device.bluetooth_power = -1;
+
 	if (pcidev && pci_enable_device(pcidev)) {
 		printk(KERN_ERR "sonypi: pci_enable_device failed\n");
 		ret = -EIO;
-		goto out1;
+		goto out_pcienable;
 	}
 
-	sonypi_misc_device.minor = (minor == -1) ? 
-		MISC_DYNAMIC_MINOR : minor;
+	sonypi_misc_device.minor = (minor == -1) ? MISC_DYNAMIC_MINOR : minor;
 	if ((ret = misc_register(&sonypi_misc_device))) {
 		printk(KERN_ERR "sonypi: misc_register failed\n");
-		goto out1;
+		goto out_miscreg;
 	}
 
 	if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) {
@@ -701,8 +767,7 @@
 		sonypi_device.region_size = SONYPI_TYPE2_REGION_SIZE;
 		sonypi_device.evtype_offset = SONYPI_TYPE2_EVTYPE_OFFSET;
 		irq_list = sonypi_type2_irq_list;
-	}
-	else {
+	} else {
 		ioport_list = sonypi_type1_ioport_list;
 		sonypi_device.region_size = SONYPI_TYPE1_REGION_SIZE;
 		sonypi_device.evtype_offset = SONYPI_TYPE1_EVTYPE_OFFSET;
@@ -710,8 +775,8 @@
 	}
 
 	for (i = 0; ioport_list[i].port1; i++) {
-		if (request_region(ioport_list[i].port1, 
-				   sonypi_device.region_size, 
+		if (request_region(ioport_list[i].port1,
+				   sonypi_device.region_size,
 				   "Sony Programable I/O Device")) {
 			/* get the ioport */
 			sonypi_device.ioport1 = ioport_list[i].port1;
@@ -722,7 +787,7 @@
 	if (!sonypi_device.ioport1) {
 		printk(KERN_ERR "sonypi: request_region failed\n");
 		ret = -ENODEV;
-		goto out2;
+		goto out_reqreg;
 	}
 
 	for (i = 0; irq_list[i].irq; i++) {
@@ -730,59 +795,85 @@
 		sonypi_device.irq = irq_list[i].irq;
 		sonypi_device.bits = irq_list[i].bits;
 
-		/* Enable sonypi IRQ settings */
-		if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2)
-			sonypi_type2_srs();
-		else
-			sonypi_type1_srs();
-
-		sonypi_call1(0x82);
-		sonypi_call2(0x81, 0xff);
-		if (compat)
-			sonypi_call1(0x92); 
-		else
-			sonypi_call1(0x82);
-
-		/* Now try requesting the irq from the system */
-		if (!request_irq(sonypi_device.irq, sonypi_irq, 
+		if (!request_irq(sonypi_device.irq, sonypi_irq,
 				 SA_SHIRQ, "sonypi", sonypi_irq))
 			break;
-
-		/* If request_irq failed, disable sonypi IRQ settings */
-		if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2)
-			sonypi_type2_dis();
-		else
-			sonypi_type1_dis();
 	}
 
 	if (!irq_list[i].irq) {
 		printk(KERN_ERR "sonypi: request_irq failed\n");
 		ret = -ENODEV;
-		goto out3;
+		goto out_reqirq;
 	}
 
-#ifdef CONFIG_PM
-	sonypi_device.pm = pm_register(PM_PCI_DEV, 0, sonypi_pm_callback);
-
-	if (sysdev_class_register(&sonypi_sysclass) != 0) {
-		printk(KERN_ERR "sonypi: sysdev_class_register failed\n");
-		ret = -ENODEV;
-		goto out4;
-	}
-	if (sysdev_register(&sonypi_sysdev) != 0) {
-		printk(KERN_ERR "sonypi: sysdev_register failed\n");
-		ret = -ENODEV;
-		goto out5;
+	if (useinput) {
+		/* Initialize the Input Drivers: jogdial */
+		int i;
+		sonypi_device.input_jog_dev.evbit[0] =
+			BIT(EV_KEY) | BIT(EV_REL);
+		sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] =
+			BIT(BTN_MIDDLE);
+		sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL);
+		sonypi_device.input_jog_dev.name =
+			kmalloc(sizeof(SONYPI_JOG_INPUTNAME), GFP_KERNEL);
+		if (!sonypi_device.input_jog_dev.name) {
+			printk(KERN_ERR "sonypi: kmalloc failed\n");
+			ret = -ENOMEM;
+			goto out_inkmallocinput1;
+		}
+		sprintf(sonypi_device.input_jog_dev.name, SONYPI_JOG_INPUTNAME);
+		sonypi_device.input_jog_dev.id.bustype = BUS_ISA;
+		sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY;
+
+		input_register_device(&sonypi_device.input_jog_dev);
+		printk(KERN_INFO "%s input method installed.\n",
+		       sonypi_device.input_jog_dev.name);
+
+		/* Initialize the Input Drivers: special keys */
+		sonypi_device.input_key_dev.evbit[0] = BIT(EV_KEY);
+		for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
+			if (sonypi_inputkeys[i].inputev)
+				set_bit(sonypi_inputkeys[i].inputev,
+					sonypi_device.input_key_dev.keybit);
+		sonypi_device.input_key_dev.name =
+			kmalloc(sizeof(SONYPI_KEY_INPUTNAME), GFP_KERNEL);
+		if (!sonypi_device.input_key_dev.name) {
+			printk(KERN_ERR "sonypi: kmalloc failed\n");
+			ret = -ENOMEM;
+			goto out_inkmallocinput2;
+		}
+		sprintf(sonypi_device.input_key_dev.name, SONYPI_KEY_INPUTNAME);
+		sonypi_device.input_key_dev.id.bustype = BUS_ISA;
+		sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY;
+
+		input_register_device(&sonypi_device.input_key_dev);
+		printk(KERN_INFO "%s input method installed.\n",
+		       sonypi_device.input_key_dev.name);
+
+		sonypi_device.input_fifo_lock = SPIN_LOCK_UNLOCKED;
+		sonypi_device.input_fifo =
+			kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
+				    &sonypi_device.input_fifo_lock);
+		if (IS_ERR(sonypi_device.input_fifo)) {
+			printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
+			ret = PTR_ERR(sonypi_device.input_fifo);
+			goto out_infifo;
+		}
+
+		INIT_WORK(&sonypi_device.input_work, input_keyrelease, NULL);
+	}
+
+	sonypi_device.pdev = platform_device_register_simple("sonypi", -1,
+							     NULL, 0);
+	if (IS_ERR(sonypi_device.pdev)) {
+		ret = PTR_ERR(sonypi_device.pdev);
+		goto out_platformdev;
 	}
-#endif
 
-	/* Enable ACPI mode to get Fn key events */
-	if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
-		outb(0xf0, 0xb2);
+	sonypi_enable(0);
 
-	printk(KERN_INFO "sonypi: Sony Programmable I/O Controller Driver v%d.%d.\n",
-	       SONYPI_DRIVER_MAJORVERSION,
-	       SONYPI_DRIVER_MINORVERSION);
+	printk(KERN_INFO "sonypi: Sony Programmable I/O Controller Driver"
+	       "v%s.\n", SONYPI_DRIVER_VERSION);
 	printk(KERN_INFO "sonypi: detected %s model, "
 	       "verbose = %d, fnkeyinit = %s, camera = %s, "
 	       "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n",
@@ -796,76 +887,60 @@
 	       useinput ? "on" : "off",
 	       SONYPI_ACPI_ACTIVE ? "on" : "off");
 	printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n",
-	       sonypi_device.irq, 
+	       sonypi_device.irq,
 	       sonypi_device.ioport1, sonypi_device.ioport2);
 
 	if (minor == -1)
 		printk(KERN_INFO "sonypi: device allocated minor is %d\n",
 		       sonypi_misc_device.minor);
 
-#ifdef SONYPI_USE_INPUT
-	if (useinput) {
-		/* Initialize the Input Drivers: */
-		sonypi_device.jog_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
-		sonypi_device.jog_dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE);
-		sonypi_device.jog_dev.relbit[0] = BIT(REL_WHEEL);
-		sonypi_device.jog_dev.name = (char *) kmalloc(
-			sizeof(SONYPI_INPUTNAME), GFP_KERNEL);
-		sprintf(sonypi_device.jog_dev.name, SONYPI_INPUTNAME);
-		sonypi_device.jog_dev.id.bustype = BUS_ISA;
-		sonypi_device.jog_dev.id.vendor = PCI_VENDOR_ID_SONY;
-	  
-		input_register_device(&sonypi_device.jog_dev);
-		printk(KERN_INFO "%s installed.\n", sonypi_device.jog_dev.name);
-	}
-#endif /* SONYPI_USE_INPUT */
-
 	return 0;
 
-#ifdef CONFIG_PM
-out5:
-	sysdev_class_unregister(&sonypi_sysclass);
-out4:
+out_platformdev:
+	kfifo_free(sonypi_device.input_fifo);
+out_infifo:
+	input_unregister_device(&sonypi_device.input_key_dev);
+	kfree(sonypi_device.input_key_dev.name);
+out_inkmallocinput2:
+	input_unregister_device(&sonypi_device.input_jog_dev);
+	kfree(sonypi_device.input_jog_dev.name);
+out_inkmallocinput1:
 	free_irq(sonypi_device.irq, sonypi_irq);
-#endif
-out3:
+out_reqirq:
 	release_region(sonypi_device.ioport1, sonypi_device.region_size);
-out2:
+out_reqreg:
 	misc_deregister(&sonypi_misc_device);
-out1:
+out_miscreg:
+	if (pcidev)
+		pci_disable_device(pcidev);
+out_pcienable:
+	kfifo_free(sonypi_device.fifo);
+out_fifo:
+	pci_dev_put(sonypi_device.dev);
 	return ret;
 }
 
-static void __devexit sonypi_remove(void) {
-
-#ifdef CONFIG_PM
-	pm_unregister(sonypi_device.pm);
+static void __devexit sonypi_remove(void)
+{
+	sonypi_disable();
 
-	sysdev_unregister(&sonypi_sysdev);
-	sysdev_class_unregister(&sonypi_sysclass);
-#endif
+	platform_device_unregister(sonypi_device.pdev);
 
-	sonypi_call2(0x81, 0); /* make sure we don't get any more events */
-	
-#ifdef SONYPI_USE_INPUT
 	if (useinput) {
-		input_unregister_device(&sonypi_device.jog_dev);
-		kfree(sonypi_device.jog_dev.name);
+		input_unregister_device(&sonypi_device.input_key_dev);
+		kfree(sonypi_device.input_key_dev.name);
+		input_unregister_device(&sonypi_device.input_jog_dev);
+		kfree(sonypi_device.input_jog_dev.name);
+		kfifo_free(sonypi_device.input_fifo);
 	}
-#endif /* SONYPI_USE_INPUT */
 
-	if (camera)
-		sonypi_camera_off();
-	if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2)
-		sonypi_type2_dis();
-	else
-		sonypi_type1_dis();
-	/* disable ACPI mode */
-	if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
-		outb(0xf1, 0xb2);
 	free_irq(sonypi_device.irq, sonypi_irq);
 	release_region(sonypi_device.ioport1, sonypi_device.region_size);
 	misc_deregister(&sonypi_misc_device);
+	if (sonypi_device.dev)
+		pci_disable_device(sonypi_device.dev);
+	kfifo_free(sonypi_device.fifo);
+	pci_dev_put(sonypi_device.dev);
 	printk(KERN_INFO "sonypi: removed.\n");
 }
 
@@ -887,78 +962,29 @@
 	{ }
 };
 
-static int __init sonypi_init_module(void)
+static int __init sonypi_init(void)
 {
-	struct pci_dev *pcidev = NULL;
-	if (dmi_check_system(sonypi_dmi_table)) {
-		pcidev = pci_find_device(PCI_VENDOR_ID_INTEL, 
-					 PCI_DEVICE_ID_INTEL_82371AB_3, 
-					 NULL);
-		return sonypi_probe(pcidev);
-	}
-	else
+	int ret;
+
+	if (!dmi_check_system(sonypi_dmi_table))
 		return -ENODEV;
+
+	ret = driver_register(&sonypi_driver);
+	if (ret)
+		return ret;
+
+	ret = sonypi_probe();
+	if (ret)
+		driver_unregister(&sonypi_driver);
+
+	return ret;
 }
 
-static void __exit sonypi_cleanup_module(void) {
+static void __exit sonypi_exit(void)
+{
+	driver_unregister(&sonypi_driver);
 	sonypi_remove();
 }
 
-#ifndef MODULE
-static int __init sonypi_setup(char *str)  {
-	int ints[8];
-
-	str = get_options(str, ARRAY_SIZE(ints), ints);
-	if (ints[0] <= 0) 
-		goto out;
-	minor = ints[1];
-	if (ints[0] == 1)
-		goto out;
-	verbose = ints[2];
-	if (ints[0] == 2)
-		goto out;
-	fnkeyinit = ints[3];
-	if (ints[0] == 3)
-		goto out;
-	camera = ints[4];
-	if (ints[0] == 4)
-		goto out;
-	compat = ints[5];
-	if (ints[0] == 5)
-		goto out;
-	mask = ints[6];
-	if (ints[0] == 6)
-		goto out;
-	useinput = ints[7];
-out:
-	return 1;
-}
-
-__setup("sonypi=", sonypi_setup);
-#endif /* !MODULE */
-	
-/* Module entry points */
-module_init(sonypi_init_module);
-module_exit(sonypi_cleanup_module);
-
-MODULE_AUTHOR("Stelian Pop <stelian@popies.net>");
-MODULE_DESCRIPTION("Sony Programmable I/O Control Device driver");
-MODULE_LICENSE("GPL");
-
-
-MODULE_PARM(minor,"i");
-MODULE_PARM_DESC(minor, "minor number of the misc device, default is -1 (automatic)");
-MODULE_PARM(verbose,"i");
-MODULE_PARM_DESC(verbose, "be verbose, default is 0 (no)");
-MODULE_PARM(fnkeyinit,"i");
-MODULE_PARM_DESC(fnkeyinit, "set this if your Fn keys do not generate any event");
-MODULE_PARM(camera,"i");
-MODULE_PARM_DESC(camera, "set this if you have a MotionEye camera (PictureBook series)");
-MODULE_PARM(compat,"i");
-MODULE_PARM_DESC(compat, "set this if you want to enable backward compatibility mode");
-MODULE_PARM(mask, "i");
-MODULE_PARM_DESC(mask, "set this to the mask of event you want to enable (see doc)");
-MODULE_PARM(useinput, "i");
-MODULE_PARM_DESC(useinput, "if you have a jogdial, set this if you would like it to use the modern Linux Input Driver system");
-
-EXPORT_SYMBOL(sonypi_camera_command);
+module_init(sonypi_init);
+module_exit(sonypi_exit);
diff -Nru a/drivers/char/sonypi.h b/drivers/char/sonypi.h
--- a/drivers/char/sonypi.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/char/sonypi.h	2004-12-24 13:37:00 -08:00
@@ -1,7 +1,7 @@
-/* 
+/*
  * Sony Programmable I/O Control Device driver for VAIO
  *
- * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
+ * Copyright (C) 2001-2004 Stelian Pop <stelian@popies.net>
  *
  * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
  *
@@ -14,30 +14,29 @@
  * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
  *
  * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
- * 
+ *
  * 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.
  *
  */
 
-#ifndef _SONYPI_PRIV_H_ 
+#ifndef _SONYPI_PRIV_H_
 #define _SONYPI_PRIV_H_
 
 #ifdef __KERNEL__
 
-#define SONYPI_DRIVER_MAJORVERSION	 1
-#define SONYPI_DRIVER_MINORVERSION	23
+#define SONYPI_DRIVER_VERSION	 "1.25"
 
 #define SONYPI_DEVICE_MODEL_TYPE1	1
 #define SONYPI_DEVICE_MODEL_TYPE2	2
@@ -46,9 +45,9 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/input.h>
-#include <linux/pm.h>
 #include <linux/acpi.h>
-#include "linux/sonypi.h"
+#include <linux/kfifo.h>
+#include <linux/sonypi.h>
 
 /* type1 models use those */
 #define SONYPI_IRQ_PORT			0x8034
@@ -223,6 +222,7 @@
 	{ 0x1a, SONYPI_EVENT_FNKEY_F10 },
 	{ 0x1b, SONYPI_EVENT_FNKEY_F11 },
 	{ 0x1c, SONYPI_EVENT_FNKEY_F12 },
+	{ 0x1f, SONYPI_EVENT_FNKEY_RELEASED },
 	{ 0x21, SONYPI_EVENT_FNKEY_1 },
 	{ 0x22, SONYPI_EVENT_FNKEY_2 },
 	{ 0x31, SONYPI_EVENT_FNKEY_D },
@@ -340,30 +340,53 @@
 };
 
 #define SONYPI_BUF_SIZE	128
-struct sonypi_queue {
-	unsigned long head;
-	unsigned long tail;
-	unsigned long len;
-	spinlock_t s_lock;
-	wait_queue_head_t proc_list;
-	struct fasync_struct *fasync;
-	unsigned char buf[SONYPI_BUF_SIZE];
-};
-
-/* We enable input subsystem event forwarding if the input 
- * subsystem is compiled in, but only if sonypi is not into the
- * kernel and input as a module... */
-#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
-#if ! (defined(CONFIG_SONYPI) && defined(CONFIG_INPUT_MODULE))
-#define SONYPI_USE_INPUT
-#endif
-#endif
 
-/* The name of the Jog Dial for the input device drivers */
-#define SONYPI_INPUTNAME	"Sony VAIO Jog Dial"
+/* The name of the devices for the input device drivers */
+#define SONYPI_JOG_INPUTNAME	"Sony Vaio Jogdial"
+#define SONYPI_KEY_INPUTNAME	"Sony Vaio Keys"
+
+/* Correspondance table between sonypi events and input layer events */
+struct {
+	int sonypiev;
+	int inputev;
+} sonypi_inputkeys[] = {
+	{ SONYPI_EVENT_CAPTURE_PRESSED,	 	KEY_CAMERA },
+	{ SONYPI_EVENT_FNKEY_ONLY, 		KEY_FN },
+	{ SONYPI_EVENT_FNKEY_ESC, 		KEY_FN_ESC },
+	{ SONYPI_EVENT_FNKEY_F1, 		KEY_FN_F1 },
+	{ SONYPI_EVENT_FNKEY_F2, 		KEY_FN_F2 },
+	{ SONYPI_EVENT_FNKEY_F3, 		KEY_FN_F3 },
+	{ SONYPI_EVENT_FNKEY_F4, 		KEY_FN_F4 },
+	{ SONYPI_EVENT_FNKEY_F5, 		KEY_FN_F5 },
+	{ SONYPI_EVENT_FNKEY_F6, 		KEY_FN_F6 },
+	{ SONYPI_EVENT_FNKEY_F7, 		KEY_FN_F7 },
+	{ SONYPI_EVENT_FNKEY_F8, 		KEY_FN_F8 },
+	{ SONYPI_EVENT_FNKEY_F9,		KEY_FN_F9 },
+	{ SONYPI_EVENT_FNKEY_F10,		KEY_FN_F10 },
+	{ SONYPI_EVENT_FNKEY_F11, 		KEY_FN_F11 },
+	{ SONYPI_EVENT_FNKEY_F12,		KEY_FN_F12 },
+	{ SONYPI_EVENT_FNKEY_1, 		KEY_FN_1 },
+	{ SONYPI_EVENT_FNKEY_2, 		KEY_FN_2 },
+	{ SONYPI_EVENT_FNKEY_D,			KEY_FN_D },
+	{ SONYPI_EVENT_FNKEY_E,			KEY_FN_E },
+	{ SONYPI_EVENT_FNKEY_F,			KEY_FN_F },
+	{ SONYPI_EVENT_FNKEY_S,			KEY_FN_S },
+	{ SONYPI_EVENT_FNKEY_B,			KEY_FN_B },
+	{ SONYPI_EVENT_BLUETOOTH_PRESSED, 	KEY_BLUE },
+	{ SONYPI_EVENT_BLUETOOTH_ON, 		KEY_BLUE },
+	{ SONYPI_EVENT_PKEY_P1, 		KEY_PROG1 },
+	{ SONYPI_EVENT_PKEY_P2, 		KEY_PROG2 },
+	{ SONYPI_EVENT_PKEY_P3, 		KEY_PROG3 },
+	{ SONYPI_EVENT_BACK_PRESSED, 		KEY_BACK },
+	{ SONYPI_EVENT_HELP_PRESSED, 		KEY_HELP },
+	{ SONYPI_EVENT_ZOOM_PRESSED, 		KEY_ZOOM },
+	{ SONYPI_EVENT_THUMBPHRASE_PRESSED, 	BTN_THUMB },
+	{ 0, 0 },
+};
 
 struct sonypi_device {
 	struct pci_dev *dev;
+	struct platform_device *pdev;
 	u16 irq;
 	u16 bits;
 	u16 ioport1;
@@ -373,15 +396,17 @@
 	int camera_power;
 	int bluetooth_power;
 	struct semaphore lock;
-	struct sonypi_queue queue;
+	struct kfifo *fifo;
+	spinlock_t fifo_lock;
+	wait_queue_head_t fifo_proc_list;
+	struct fasync_struct *fifo_async;
 	int open_count;
 	int model;
-#ifdef SONYPI_USE_INPUT
-	struct input_dev jog_dev;
-#endif
-#ifdef CONFIG_PM
-	struct pm_dev *pm;
-#endif
+	struct input_dev input_jog_dev;
+	struct input_dev input_key_dev;
+	struct work_struct input_work;
+	struct kfifo *input_fifo;
+	spinlock_t input_fifo_lock;
 };
 
 #define ITERATIONS_LONG		10000
@@ -399,37 +424,8 @@
 #define SONYPI_ACPI_ACTIVE (!acpi_disabled)
 #else
 #define SONYPI_ACPI_ACTIVE 0
-#endif /* CONFIG_ACPI */
-
-static inline int sonypi_ec_write(u8 addr, u8 value) {
-#ifdef CONFIG_ACPI_EC
-	if (SONYPI_ACPI_ACTIVE)
-		return ec_write(addr, value);
-#endif
-	wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3, ITERATIONS_LONG);
-	outb_p(0x81, SONYPI_CST_IOPORT);
-	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
-	outb_p(addr, SONYPI_DATA_IOPORT);
-	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
-	outb_p(value, SONYPI_DATA_IOPORT);
-	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
-	return 0;
-}
-
-static inline int sonypi_ec_read(u8 addr, u8 *value) {
-#ifdef CONFIG_ACPI_EC
-	if (SONYPI_ACPI_ACTIVE)
-		return ec_read(addr, value);
-#endif
-	wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3, ITERATIONS_LONG);
-	outb_p(0x80, SONYPI_CST_IOPORT);
-	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
-	outb_p(addr, SONYPI_DATA_IOPORT);
-	wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
-	*value = inb_p(SONYPI_DATA_IOPORT);
-	return 0;
-}
+#endif				/* CONFIG_ACPI */
 
-#endif /* __KERNEL__ */
+#endif				/* __KERNEL__ */
 
-#endif /* _SONYPI_PRIV_H_ */
+#endif				/* _SONYPI_PRIV_H_ */
diff -Nru a/drivers/char/specialix.c b/drivers/char/specialix.c
--- a/drivers/char/specialix.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/char/specialix.c	2004-12-24 13:37:19 -08:00
@@ -1452,8 +1452,7 @@
 		 */
 		timeout = jiffies+HZ;
 		while(port->IER & IER_TXEMPTY) {
-			current->state = TASK_INTERRUPTIBLE;
- 			schedule_timeout(port->timeout);
+			msleep_interruptible(jiffies_to_msecs(port->timeout));
 			if (time_after(jiffies, timeout)) {
 				printk (KERN_INFO "Timeout waiting for close\n");
 				break;
@@ -1470,8 +1469,7 @@
 	port->tty = NULL;
 	if (port->blocked_open) {
 		if (port->close_delay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(port->close_delay);
+			msleep_interruptible(jiffies_to_msecs(port->close_delay));
 		}
 		wake_up_interruptible(&port->open_wait);
 	}
@@ -1481,7 +1479,7 @@
 }
 
 
-static int sx_write(struct tty_struct * tty, int from_user, 
+static int sx_write(struct tty_struct * tty, 
                     const unsigned char *buf, int count)
 {
 	struct specialix_port *port = (struct specialix_port *)tty->driver_data;
@@ -1498,52 +1496,22 @@
 		return 0;
 
 	save_flags(flags);
-	if (from_user) {
-		down(&tmp_buf_sem);
-		while (1) {
-			c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-					   SERIAL_XMIT_SIZE - port->xmit_head));
-			if (c <= 0)
-				break;
-
-			c -= copy_from_user(tmp_buf, buf, c);
-			if (!c) {
-				if (!total)
-					total = -EFAULT;
-				break;
-			}
-
-			cli();
-			c = min_t(int, c, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-				       SERIAL_XMIT_SIZE - port->xmit_head));
-			memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c);
-			port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-			port->xmit_cnt += c;
+	while (1) {
+		cli();
+		c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
+				   SERIAL_XMIT_SIZE - port->xmit_head));
+		if (c <= 0) {
 			restore_flags(flags);
-
-			buf += c;
-			count -= c;
-			total += c;
+			break;
 		}
-		up(&tmp_buf_sem);
-	} else {
-		while (1) {
-			cli();
-			c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-					   SERIAL_XMIT_SIZE - port->xmit_head));
-			if (c <= 0) {
-				restore_flags(flags);
-				break;
-			}
-			memcpy(port->xmit_buf + port->xmit_head, buf, c);
-			port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-			port->xmit_cnt += c;
-			restore_flags(flags);
+		memcpy(port->xmit_buf + port->xmit_head, buf, c);
+		port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
+		port->xmit_cnt += c;
+		restore_flags(flags);
 
-			buf += c;
-			count -= c;
-			total += c;
-		}
+		buf += c;
+		count -= c;
+		total += c;
 	}
 
 	cli();
@@ -2218,8 +2186,8 @@
 
 int irq [SX_NBOARD] = {0,};
 
-MODULE_PARM(iobase,"1-" __MODULE_STRING(SX_NBOARD) "i");
-MODULE_PARM(irq,"1-" __MODULE_STRING(SX_NBOARD) "i");
+module_param_array(iobase, int, NULL, 0);
+module_param_array(irq, int, NULL, 0);
 
 /*
  * You can setup up to 4 boards.
diff -Nru a/drivers/char/stallion.c b/drivers/char/stallion.c
--- a/drivers/char/stallion.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/char/stallion.c	2004-12-24 13:37:04 -08:00
@@ -42,6 +42,7 @@
 #include <linux/smp_lock.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/device.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -481,7 +482,7 @@
 int		stl_init(void);
 static int	stl_open(struct tty_struct *tty, struct file *filp);
 static void	stl_close(struct tty_struct *tty, struct file *filp);
-static int	stl_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count);
+static int	stl_write(struct tty_struct *tty, const unsigned char *buf, int count);
 static void	stl_putchar(struct tty_struct *tty, unsigned char ch);
 static void	stl_flushchars(struct tty_struct *tty);
 static int	stl_writeroom(struct tty_struct *tty);
@@ -512,7 +513,6 @@
 static int	stl_getportstruct(stlport_t __user *arg);
 static int	stl_getbrdstruct(stlbrd_t __user *arg);
 static int	stl_waitcarrier(stlport_t *portp, struct file *filp);
-static void	stl_delay(int len);
 static void	stl_eiointr(stlbrd_t *brdp);
 static void	stl_echatintr(stlbrd_t *brdp);
 static void	stl_echmcaintr(stlbrd_t *brdp);
@@ -1204,7 +1204,7 @@
 
 	if (portp->openwaitcnt) {
 		if (portp->close_delay)
-			stl_delay(portp->close_delay);
+			msleep_interruptible(jiffies_to_msecs(portp->close_delay));
 		wake_up_interruptible(&portp->open_wait);
 	}
 
@@ -1216,30 +1216,11 @@
 /*****************************************************************************/
 
 /*
- *	Wait for a specified delay period, this is not a busy-loop. It will
- *	give up the processor while waiting. Unfortunately this has some
- *	rather intimate knowledge of the process management stuff.
- */
-
-static void stl_delay(int len)
-{
-#ifdef DEBUG
-	printk("stl_delay(len=%d)\n", len);
-#endif
-	if (len > 0) {
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(len);
-	}
-}
-
-/*****************************************************************************/
-
-/*
  *	Write routine. Take data and stuff it in to the TX ring queue.
  *	If transmit interrupts are not running then start them.
  */
 
-static int stl_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
+static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	stlport_t	*portp;
 	unsigned int	len, stlen;
@@ -1247,8 +1228,8 @@
 	char		*head, *tail;
 
 #ifdef DEBUG
-	printk("stl_write(tty=%x,from_user=%d,buf=%x,count=%d)\n",
-		(int) tty, from_user, (int) buf, count);
+	printk("stl_write(tty=%x,buf=%x,count=%d)\n",
+		(int) tty, (int) buf, count);
 #endif
 
 	if ((tty == (struct tty_struct *) NULL) ||
@@ -1267,18 +1248,6 @@
  *	copy it into the TX buffer.
  */
 	chbuf = (unsigned char *) buf;
-	if (from_user) {
-		head = portp->tx.head;
-		tail = portp->tx.tail;
-		len = (head >= tail) ? (STL_TXBUFSIZE - (head - tail) - 1) :
-			(tail - head - 1);
-		count = MIN(len, count);
-		
-		down(&stl_tmpwritesem);
-		if (copy_from_user(stl_tmpwritebuf, chbuf, count)) 
-			return -EFAULT;
-		chbuf = &stl_tmpwritebuf[0];
-	}
 
 	head = portp->tx.head;
 	tail = portp->tx.tail;
@@ -1309,9 +1278,6 @@
 	clear_bit(ASYI_TXLOW, &portp->istate);
 	stl_startrxtx(portp, -1, 1);
 
-	if (from_user)
-		up(&stl_tmpwritesem);
-
 	return(count);
 }
 
@@ -1854,7 +1820,7 @@
 	while (stl_datastate(portp)) {
 		if (signal_pending(current))
 			break;
-		stl_delay(2);
+		msleep_interruptible(20);
 		if (time_after_eq(jiffies, tend))
 			break;
 	}
diff -Nru a/drivers/char/sx.c b/drivers/char/sx.c
--- a/drivers/char/sx.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/char/sx.c	2004-12-24 13:36:48 -08:00
@@ -460,9 +460,27 @@
 
 
 #ifdef DEBUG
-static void my_hd (unsigned char *addr, int len)
+static void my_hd_io(void __iomem *p, int len)
 {
 	int i, j, ch;
+	unsigned char __iomem *addr = p;
+
+	for (i=0;i<len;i+=16) {
+		printk ("%p ", addr+i);
+		for (j=0;j<16;j++) {
+			printk ("%02x %s", readb(addr+j+i), (j==7)?" ":"");
+		}
+		for (j=0;j<16;j++) {
+			ch = readb(addr+j+i);
+			printk ("%c", (ch < 0x20)?'.':((ch > 0x7f)?'.':ch));
+		}
+		printk ("\n");
+	}
+}
+static void my_hd(void *p, int len)
+{
+	int i, j, ch;
+	unsigned char *addr = p;
 
 	for (i=0;i<len;i+=16) {
 		printk ("%p ", addr+i);
@@ -1452,11 +1470,10 @@
 
 #if 0
 	if (sx_debug & SX_DEBUG_OPEN)
-		my_hd ((unsigned char *)port, sizeof (*port));
+		my_hd (port, sizeof (*port));
 #else
 	if (sx_debug & SX_DEBUG_OPEN)
-		my_hd ((unsigned char *)port->board->base + port->ch_base, 
-		       sizeof (*port));
+		my_hd_io (port->board->base + port->ch_base, sizeof (*port));
 #endif
 
 	if (sx_send_command (port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) {
@@ -1499,7 +1516,7 @@
 	sx_send_command (port, HS_CLOSE, 0, 0);
 
 	while (to-- && (sx_read_channel_byte (port, hi_hstat) != HS_IDLE_CLOSED)) {
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout (1);
 		if (signal_pending (current))
 				break;
@@ -1675,7 +1692,7 @@
 					kfree (tmp);
 					return -EFAULT;
 				}
-				memcpy_toio    ((char *) (board->base2 + offset + i), tmp, 
+				memcpy_toio(board->base2 + offset + i, tmp, 
 				                (i+SX_CHUNK_SIZE>nbytes)?nbytes-i:SX_CHUNK_SIZE);
 			}
 
@@ -1892,9 +1909,9 @@
 	/* Ok. So now the processor on the card is running. It gathered
 	   some info for us... */
 	sx_dprintk (SX_DEBUG_INIT, "The sxcard structure:\n");
-	if (sx_debug & SX_DEBUG_INIT) my_hd ((char *)(board->base), 0x10);
+	if (sx_debug & SX_DEBUG_INIT) my_hd_io (board->base, 0x10);
 	sx_dprintk (SX_DEBUG_INIT, "the first sx_module structure:\n");
-	if (sx_debug & SX_DEBUG_INIT) my_hd ((char *)(board->base + 0x80), 0x30);
+	if (sx_debug & SX_DEBUG_INIT) my_hd_io (board->base + 0x80, 0x30);
 
 	sx_dprintk (SX_DEBUG_INIT, 
 	            "init_status: %x, %dk memory, firmware V%x.%02x,\n", 
@@ -2047,18 +2064,18 @@
 	func_enter();
 
 	if (!IS_CF_BOARD (board)) {    
-		sx_dprintk (SX_DEBUG_PROBE, "Going to verify vpd prom at %lx.\n", 
+		sx_dprintk (SX_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", 
 		            board->base + SX_VPD_ROM);
 
 		if (sx_debug & SX_DEBUG_PROBE)
-			my_hd ((char *)(board->base + SX_VPD_ROM), 0x40);
+			my_hd_io(board->base + SX_VPD_ROM, 0x40);
 
 		p = (char *) &vpdp;
 		for (i=0;i< sizeof (struct vpd_prom);i++)
 			*p++ = read_sx_byte (board, SX_VPD_ROM + i*2);
 
 		if (sx_debug & SX_DEBUG_PROBE)
-			my_hd ((char *)&vpdp, 0x20);
+			my_hd (&vpdp, 0x20);
 
 		sx_dprintk (SX_DEBUG_PROBE, "checking identifier...\n");
 
@@ -2088,8 +2105,8 @@
 		}
 
 		if (((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) == SX_ISA_UNIQUEID1) {
-			if (board->base & 0x8000) {
-				printk (KERN_WARNING "sx: Warning: There may be hardware problems with the card at %lx.\n", board->base);
+			if (board->hw_base & 0x8000) {
+				printk (KERN_WARNING "sx: Warning: There may be hardware problems with the card at %lx.\n", board->hw_base);
 				printk (KERN_WARNING "sx: Read sx.txt for more info.\n");
 			}
 		}
@@ -2121,11 +2138,11 @@
 	int i;
 
 	func_enter();
-	sx_dprintk (SX_DEBUG_PROBE, "Going to verify SI signature hw %lx at %lx.\n", board->hw_base,
+	sx_dprintk (SX_DEBUG_PROBE, "Going to verify SI signature hw %lx at %p.\n", board->hw_base,
 	            board->base + SI2_ISA_ID_BASE);
 
 	if (sx_debug & SX_DEBUG_PROBE)
-		my_hd ((char *)(board->base + SI2_ISA_ID_BASE), 0x8);
+		my_hd_io(board->base + SI2_ISA_ID_BASE, 0x8);
 
 	if (!IS_EISA_BOARD(board)) {
 	  if( IS_SI1_BOARD(board) ) 
@@ -2359,7 +2376,7 @@
 static void fix_sx_pci (struct pci_dev *pdev, struct sx_board *board)
 {
 	unsigned int hwbase;
-	unsigned long rebase;
+	void __iomem *rebase;
 	unsigned int t;
 
 #define CNTRL_REG_OFFSET        0x50
@@ -2367,13 +2384,13 @@
 
 	pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
 	hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
-	rebase = (ulong) ioremap(hwbase, 0x80);
+	rebase = ioremap(hwbase, 0x80);
 	t = readl (rebase + CNTRL_REG_OFFSET);
 	if (t != CNTRL_REG_GOODVALUE) {
 		printk (KERN_DEBUG "sx: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); 
 		writel (CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
 	}
-	iounmap ((char *) rebase);
+	iounmap(rebase);
 }
 #endif
 
@@ -2441,7 +2458,7 @@
 		else
 			board->hw_base = pci_resource_start (pdev, 2);
 		board->base2 = 
-		board->base = (ulong) ioremap(board->hw_base, WINDOW_LEN (board));
+		board->base = ioremap(board->hw_base, WINDOW_LEN (board));
 		if (!board->base) {
 			printk(KERN_ERR "ioremap failed\n");
 			/* XXX handle error */
@@ -2453,14 +2470,14 @@
 
 		board->irq = pdev->irq;
 
-		sx_dprintk (SX_DEBUG_PROBE, "Got a specialix card: %x/%lx(%d) %x.\n", 
+		sx_dprintk (SX_DEBUG_PROBE, "Got a specialix card: %x/%p(%d) %x.\n", 
 			    tint, boards[found].base, board->irq, board->flags);
 
 		if (probe_sx (board)) {
 			found++;
 			fix_sx_pci (pdev, board);
 		} else 
-			iounmap ((char *) (board->base));
+			iounmap(board->base);
 	}
 #endif
 
@@ -2468,7 +2485,7 @@
 		board = &boards[found];
 		board->hw_base = sx_probe_addrs[i];
 		board->base2 =
-		board->base = (ulong) ioremap(board->hw_base, SX_WINDOW_LEN);
+		board->base = ioremap(board->hw_base, SX_WINDOW_LEN);
 		board->flags &= ~SX_BOARD_TYPE;
 		board->flags |=	SX_ISA_BOARD;
 		board->irq = sx_irqmask?-1:0;
@@ -2476,7 +2493,7 @@
 		if (probe_sx (board)) {
 			found++;
 		} else {
-			iounmap ((char *) (board->base));
+			iounmap(board->base);
 		}
 	}
 
@@ -2484,7 +2501,7 @@
 		board = &boards[found];
 		board->hw_base = si_probe_addrs[i];
 		board->base2 =
-		board->base = (ulong) ioremap(board->hw_base, SI2_ISA_WINDOW_LEN);
+		board->base = ioremap(board->hw_base, SI2_ISA_WINDOW_LEN);
 		board->flags &= ~SX_BOARD_TYPE;
 		board->flags |=  SI_ISA_BOARD;
 		board->irq = sx_irqmask ?-1:0;
@@ -2492,14 +2509,14 @@
 		if (probe_si (board)) {
 			found++;
 		} else {
-			iounmap ((char *) (board->base));
+			iounmap (board->base);
 		}
 	}
 	for (i=0;i<NR_SI1_ADDRS;i++) {
 		board = &boards[found];
 		board->hw_base = si1_probe_addrs[i];
 		board->base2 =
-		board->base = (ulong) ioremap(board->hw_base, SI1_ISA_WINDOW_LEN);
+		board->base = ioremap(board->hw_base, SI1_ISA_WINDOW_LEN);
 		board->flags &= ~SX_BOARD_TYPE;
 		board->flags |=  SI1_ISA_BOARD;
 		board->irq = sx_irqmask ?-1:0;
@@ -2507,7 +2524,7 @@
 		if (probe_si (board)) {
 			found++;
 		} else {
-			iounmap ((char *) (board->base));
+			iounmap (board->base);
 		}
 	}
 
@@ -2527,10 +2544,10 @@
 
 			board->hw_base = (((inb(0xc01+eisa_slot) << 8) + inb(0xc00+eisa_slot)) << 16);
 			board->base2 =
-			board->base = (ulong) ioremap(board->hw_base, SI2_EISA_WINDOW_LEN);
+			board->base = ioremap(board->hw_base, SI2_EISA_WINDOW_LEN);
 
 			sx_dprintk(SX_DEBUG_PROBE, "IO hw_base address: %lx\n", board->hw_base);
-			sx_dprintk(SX_DEBUG_PROBE, "base: %lx\n", board->base);
+			sx_dprintk(SX_DEBUG_PROBE, "base: %p\n", board->base);
 			board->irq = inb(board->eisa_base+0xc02)>>4; 
 			sx_dprintk(SX_DEBUG_PROBE, "IRQ: %d\n", board->irq);
 			
@@ -2559,7 +2576,7 @@
 	for (i = 0; i < SX_NBOARDS; i++) {
 		board = &boards[i];
 		if (board->flags & SX_BOARD_INITIALIZED) {
-			sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up board at %lx\n", board->base);
+			sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up board at %p\n", board->base);
 			/* The board should stop messing with us.
 			   (actually I mean the interrupt) */
 			sx_reset (board);
@@ -2568,11 +2585,11 @@
 
 			/* It is safe/allowed to del_timer a non-active timer */
 			del_timer (& board->timer);
-			iounmap ((char *) (board->base));
+			iounmap(board->base);
 		}
 	}
 	if (misc_deregister(&sx_fw_device) < 0) {
-		printk (KERN_INFO "sx: couldn't deregister firmware loader device\n");
+		printk (KERN_INFO "sx: couldn't deregister firmware loader devic\n");
 	}
 	sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized);
 	if (sx_initialized)
diff -Nru a/drivers/char/sx.h b/drivers/char/sx.h
--- a/drivers/char/sx.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/char/sx.h	2004-12-24 13:36:31 -08:00
@@ -32,8 +32,8 @@
 
 struct sx_board {
   int magic;
-  unsigned long base;
-  unsigned long base2;
+  void __iomem *base;
+  void __iomem *base2;
   unsigned long hw_base;
   int eisa_base;
   int port_base; /* Number of the first port */
diff -Nru a/drivers/char/synclink.c b/drivers/char/synclink.c
--- a/drivers/char/synclink.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/char/synclink.c	2004-12-24 13:36:47 -08:00
@@ -82,6 +82,7 @@
 #include <linux/ioport.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 
 #include <linux/netdevice.h>
 
@@ -96,7 +97,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/dma.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/types.h>
 #include <linux/termios.h>
 #include <linux/workqueue.h>
@@ -2139,16 +2140,15 @@
  * Arguments:
  * 
  * 	tty		pointer to tty information structure
- * 	from_user	flag: 1 = from user process
  * 	buf		pointer to buffer containing send data
  * 	count		size of send data in bytes
  * 	
  * Return Value:	number of characters written
  */
-static int mgsl_write(struct tty_struct * tty, int from_user,
+static int mgsl_write(struct tty_struct * tty,
 		    const unsigned char *buf, int count)
 {
-	int	c, ret = 0, err;
+	int	c, ret = 0;
 	struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
 	unsigned long flags;
 	
@@ -2185,20 +2185,7 @@
 
 			/* queue transmit frame request */
 			ret = count;
-			if (from_user) {
-				down(&tmp_buf_sem);
-				COPY_FROM_USER(err,tmp_buf, buf, count);
-				if (err) {
-					if ( debug_level >= DEBUG_LEVEL_INFO )
-						printk( "%s(%d):mgsl_write(%s) sync user buf copy failed\n",
-							__FILE__,__LINE__,info->device_name);
-					ret = -EFAULT;
-				} else
-					save_tx_buffer_request(info,tmp_buf,count);
-				up(&tmp_buf_sem);
-			}
-			else
-				save_tx_buffer_request(info,buf,count);
+			save_tx_buffer_request(info,buf,count);
 
 			/* if we have sufficient tx dma buffers,
 			 * load the next buffered tx request
@@ -2238,70 +2225,26 @@
 					__FILE__,__LINE__,info->device_name);
 			ret = count;
 			info->xmit_cnt = count;
-			if (from_user) {
-				down(&tmp_buf_sem);
-				COPY_FROM_USER(err,tmp_buf, buf, count);
-				if (err) {
-					if ( debug_level >= DEBUG_LEVEL_INFO )
-						printk( "%s(%d):mgsl_write(%s) sync user buf copy failed\n",
-							__FILE__,__LINE__,info->device_name);
-					ret = -EFAULT;
-				} else
-					mgsl_load_tx_dma_buffer(info,tmp_buf,count);
-				up(&tmp_buf_sem);
-			}
-			else
-				mgsl_load_tx_dma_buffer(info,buf,count);
+			mgsl_load_tx_dma_buffer(info,buf,count);
 		}
 	} else {
-		if (from_user) {
-			down(&tmp_buf_sem);
-			while (1) {
-				c = min_t(int, count,
-					min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					    SERIAL_XMIT_SIZE - info->xmit_head));
-				if (c <= 0)
-					break;
-
-				COPY_FROM_USER(err,tmp_buf, buf, c);
-				c -= err;
-				if (!c) {
-					if (!ret)
-						ret = -EFAULT;
-					break;
-				}
-				spin_lock_irqsave(&info->irq_spinlock,flags);
-				c = min_t(int, c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					       SERIAL_XMIT_SIZE - info->xmit_head));
-				memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
-				info->xmit_head = ((info->xmit_head + c) &
-						   (SERIAL_XMIT_SIZE-1));
-				info->xmit_cnt += c;
-				spin_unlock_irqrestore(&info->irq_spinlock,flags);
-				buf += c;
-				count -= c;
-				ret += c;
-			}
-			up(&tmp_buf_sem);
-		} else {
-			while (1) {
-				spin_lock_irqsave(&info->irq_spinlock,flags);
-				c = min_t(int, count,
-					min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					    SERIAL_XMIT_SIZE - info->xmit_head));
-				if (c <= 0) {
-					spin_unlock_irqrestore(&info->irq_spinlock,flags);
-					break;
-				}
-				memcpy(info->xmit_buf + info->xmit_head, buf, c);
-				info->xmit_head = ((info->xmit_head + c) &
-						   (SERIAL_XMIT_SIZE-1));
-				info->xmit_cnt += c;
+		while (1) {
+			spin_lock_irqsave(&info->irq_spinlock,flags);
+			c = min_t(int, count,
+				min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
+				    SERIAL_XMIT_SIZE - info->xmit_head));
+			if (c <= 0) {
 				spin_unlock_irqrestore(&info->irq_spinlock,flags);
-				buf += c;
-				count -= c;
-				ret += c;
+				break;
 			}
+			memcpy(info->xmit_buf + info->xmit_head, buf, c);
+			info->xmit_head = ((info->xmit_head + c) &
+					   (SERIAL_XMIT_SIZE-1));
+			info->xmit_cnt += c;
+			spin_unlock_irqrestore(&info->irq_spinlock,flags);
+			buf += c;
+			count -= c;
+			ret += c;
 		}
 	}	
 	
@@ -3259,8 +3202,7 @@
 	
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -3326,8 +3268,7 @@
 	if ( info->params.mode == MGSL_MODE_HDLC ||
 		info->params.mode == MGSL_MODE_RAW ) {
 		while (info->tx_active) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(char_time);
+			msleep_interruptible(jiffies_to_msecs(char_time));
 			if (signal_pending(current))
 				break;
 			if (timeout && time_after(jiffies, orig_jiffies + timeout))
@@ -3336,8 +3277,7 @@
 	} else {
 		while (!(usc_InReg(info,TCSR) & TXSTATUS_ALL_SENT) &&
 			info->tx_enabled) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(char_time);
+			msleep_interruptible(jiffies_to_msecs(char_time));
 			if (signal_pending(current))
 				break;
 			if (timeout && time_after(jiffies, orig_jiffies + timeout))
@@ -7200,8 +7140,7 @@
 
 	EndTime=100;
 	while( EndTime-- && !info->irq_occurred ) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(msecs_to_jiffies(10));
+		msleep_interruptible(10);
 	}
 	
 	spin_lock_irqsave(&info->irq_spinlock,flags);
@@ -8150,9 +8089,7 @@
 
 	memcpy(skb_put(skb, size),buf,size);
 
-	skb->dev      = info->netdev;
-	skb->mac.raw  = skb->data;
-	skb->protocol = hdlc_type_trans(skb, skb->dev);
+	skb->protocol = hdlc_type_trans(skb, info->netdev);
 
 	stats->rx_packets++;
 	stats->rx_bytes += size;
diff -Nru a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
--- a/drivers/char/synclinkmp.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/char/synclinkmp.c	2004-12-24 13:36:31 -08:00
@@ -63,7 +63,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/dma.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/types.h>
 #include <linux/termios.h>
 #include <linux/workqueue.h>
@@ -521,7 +521,7 @@
 static void hangup(struct tty_struct *tty);
 static void set_termios(struct tty_struct *tty, struct termios *old_termios);
 
-static int  write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count);
+static int  write(struct tty_struct *tty, const unsigned char *buf, int count);
 static void put_char(struct tty_struct *tty, unsigned char ch);
 static void send_xchar(struct tty_struct *tty, char ch);
 static void wait_until_sent(struct tty_struct *tty, int timeout);
@@ -878,8 +878,7 @@
 
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -972,16 +971,15 @@
  * Arguments:
  *
  * 	tty		pointer to tty information structure
- * 	from_user	flag: 1 = from user process
  * 	buf		pointer to buffer containing send data
  * 	count		size of send data in bytes
  *
  * Return Value:	number of characters written
  */
-static int write(struct tty_struct *tty, int from_user,
+static int write(struct tty_struct *tty,
 		 const unsigned char *buf, int count)
 {
-	int	c, ret = 0, err;
+	int	c, ret = 0;
 	SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
 	unsigned long flags;
 
@@ -1008,11 +1006,9 @@
 			tx_load_dma_buffer(info, info->tx_buf, info->tx_count);
 			goto start;
 		}
-		if (!from_user) {
-			ret = info->tx_count = count;
-			tx_load_dma_buffer(info, buf, count);
-			goto start;
-		}
+		ret = info->tx_count = count;
+		tx_load_dma_buffer(info, buf, count);
+		goto start;
 	}
 
 	for (;;) {
@@ -1022,15 +1018,7 @@
 		if (c <= 0)
 			break;
 			
-		if (from_user) {
-			COPY_FROM_USER(err, info->tx_buf + info->tx_put, buf, c);
-			if (err) {
-				if (!ret)
-					ret = -EFAULT;
-				break;
-			}
-		} else
-			memcpy(info->tx_buf + info->tx_put, buf, c);
+		memcpy(info->tx_buf + info->tx_put, buf, c);
 
 		spin_lock_irqsave(&info->lock,flags);
 		info->tx_put += c;
@@ -1164,8 +1152,7 @@
 
 	if ( info->params.mode == MGSL_MODE_HDLC ) {
 		while (info->tx_active) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(char_time);
+			msleep_interruptible(jiffies_to_msecs(char_time));
 			if (signal_pending(current))
 				break;
 			if (timeout && time_after(jiffies, orig_jiffies + timeout))
@@ -1175,8 +1162,7 @@
 		//TODO: determine if there is something similar to USC16C32
 		// 	TXSTATUS_ALL_SENT status
 		while ( info->tx_active && info->tx_enabled) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(char_time);
+			msleep_interruptible(jiffies_to_msecs(char_time));
 			if (signal_pending(current))
 				break;
 			if (timeout && time_after(jiffies, orig_jiffies + timeout))
@@ -1968,9 +1954,7 @@
 
 	memcpy(skb_put(skb, size),buf,size);
 
-	skb->dev      = info->netdev;
-	skb->mac.raw  = skb->data;
-	skb->protocol = hdlc_type_trans(skb, skb->dev);
+	skb->protocol = hdlc_type_trans(skb, info->netdev);
 
 	stats->rx_packets++;
 	stats->rx_bytes += size;
@@ -5209,8 +5193,7 @@
 
 	timeout=100;
 	while( timeout-- && !info->irq_occurred ) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(msecs_to_jiffies(10));
+		msleep_interruptible(10);
 	}
 
 	spin_lock_irqsave(&info->lock,flags);
@@ -5360,8 +5343,7 @@
 	/* wait for receive complete */
 	/* Set a timeout for waiting for interrupt. */
 	for ( timeout = 100; timeout; --timeout ) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(msecs_to_jiffies(10));
+		msleep_interruptible(10);
 
 		if (rx_get_frame(info)) {
 			rc = TRUE;
diff -Nru a/drivers/char/sysrq.c b/drivers/char/sysrq.c
--- a/drivers/char/sysrq.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/char/sysrq.c	2004-12-24 13:37:18 -08:00
@@ -216,6 +216,16 @@
 
 /* END SIGNAL SYSRQ HANDLERS BLOCK */
 
+static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs,
+				struct tty_struct *tty)
+{
+	normalize_rt_tasks();
+}
+static struct sysrq_key_op sysrq_unrt_op = {
+	.handler	= sysrq_handle_unrt,
+	.help_msg	= "Nice",
+	.action_msg	= "Nice All RT Tasks"
+};
 
 /* Key Operations table and lock */
 static spinlock_t sysrq_key_table_lock = SPIN_LOCK_UNLOCKED;
@@ -250,7 +260,7 @@
 #endif
 /* l */	NULL,
 /* m */	&sysrq_showmem_op,
-/* n */	NULL,
+/* n */	&sysrq_unrt_op,
 /* o */	NULL, /* This will often be registered
 		 as 'Off' at init time */
 /* p */	&sysrq_showregs_op,
@@ -284,14 +294,6 @@
 }
 
 /*
- * table lock and unlocking functions, exposed to modules
- */
-
-void __sysrq_lock_table (void) { spin_lock(&sysrq_key_table_lock); }
-
-void __sysrq_unlock_table (void) { spin_unlock(&sysrq_key_table_lock); }
-
-/*
  * get and put functions for the table, exposed to modules.
  */
 
@@ -323,8 +325,9 @@
 	struct sysrq_key_op *op_p;
 	int orig_log_level;
 	int i, j;
+	unsigned long flags;
 
-	__sysrq_lock_table();
+	spin_lock_irqsave(&sysrq_key_table_lock, flags);
 	orig_log_level = console_loglevel;
 	console_loglevel = 7;
 	printk(KERN_INFO "SysRq : ");
@@ -346,7 +349,7 @@
 		printk ("\n");
 		console_loglevel = orig_log_level;
 	}
-	__sysrq_unlock_table();
+	spin_unlock_irqrestore(&sysrq_key_table_lock, flags);
 }
 
 /*
@@ -361,8 +364,34 @@
 	__handle_sysrq(key, pt_regs, tty);
 }
 
+int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
+                                struct sysrq_key_op *remove_op_p) {
+
+	int retval;
+	unsigned long flags;
+
+	spin_lock_irqsave(&sysrq_key_table_lock, flags);
+	if (__sysrq_get_key_op(key) == remove_op_p) {
+		__sysrq_put_key_op(key, insert_op_p);
+		retval = 0;
+	} else {
+		retval = -1;
+	}
+	spin_unlock_irqrestore(&sysrq_key_table_lock, flags);
+
+	return retval;
+}
+
+int register_sysrq_key(int key, struct sysrq_key_op *op_p)
+{
+	return __sysrq_swap_key_ops(key, op_p, NULL);
+}
+
+int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
+{
+	return __sysrq_swap_key_ops(key, NULL, op_p);
+}
+
 EXPORT_SYMBOL(handle_sysrq);
-EXPORT_SYMBOL(__sysrq_lock_table);
-EXPORT_SYMBOL(__sysrq_unlock_table);
-EXPORT_SYMBOL(__sysrq_get_key_op);
-EXPORT_SYMBOL(__sysrq_put_key_op);
+EXPORT_SYMBOL(register_sysrq_key);
+EXPORT_SYMBOL(unregister_sysrq_key);
diff -Nru a/drivers/char/tipar.c b/drivers/char/tipar.c
--- a/drivers/char/tipar.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/char/tipar.c	2004-12-24 13:37:03 -08:00
@@ -55,7 +55,7 @@
 #include <asm/uaccess.h>
 #include <linux/ioport.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/devfs_fs_kernel.h>	/* DevFs support */
 #include <linux/parport.h>	/* Our code depend on parport */
 #include <linux/device.h>
diff -Nru a/drivers/char/tpqic02.c b/drivers/char/tpqic02.c
--- a/drivers/char/tpqic02.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/char/tpqic02.c	2004-12-24 13:36:49 -08:00
@@ -554,10 +554,9 @@
 	    /* 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);
+		msleep_interruptible(300);
 	}
 
 	/* don't use jiffies for this test because it may have changed by now */
diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
--- a/drivers/char/tty_io.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/char/tty_io.c	2004-12-24 13:37:00 -08:00
@@ -93,10 +93,10 @@
 #include <linux/device.h>
 #include <linux/idr.h>
 #include <linux/wait.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 #include <linux/kbd_kern.h>
 #include <linux/vt_kern.h>
@@ -136,6 +136,7 @@
 extern int pty_limit;		/* Config limit on Unix98 ptys */
 static DEFINE_IDR(allocated_ptys);
 static DECLARE_MUTEX(allocated_ptys_lock);
+static int ptmx_open(struct inode *, struct file *);
 #endif
 
 extern void disable_early_printk(void);
@@ -147,7 +148,6 @@
 ssize_t redirected_tty_write(struct file *, const char __user *, size_t, loff_t *);
 static unsigned int tty_poll(struct file *, poll_table *);
 static int tty_open(struct inode *, struct file *);
-static int ptmx_open(struct inode *, struct file *);
 static int tty_release(struct inode *, struct file *);
 int tty_ioctl(struct inode * inode, struct file * file,
 	      unsigned int cmd, unsigned long arg);
@@ -168,6 +168,7 @@
 
 static inline void free_tty_struct(struct tty_struct *tty)
 {
+	kfree(tty->write_buf);
 	kfree(tty);
 }
 
@@ -1019,41 +1020,72 @@
  * denial-of-service type attacks
  */
 static inline ssize_t do_tty_write(
-	ssize_t (*write)(struct tty_struct *, struct file *, const unsigned char __user *, size_t),
+	ssize_t (*write)(struct tty_struct *, struct file *, const unsigned char *, size_t),
 	struct tty_struct *tty,
 	struct file *file,
-	const unsigned char __user *buf,
+	const char __user *buf,
 	size_t count)
 {
 	ssize_t ret = 0, written = 0;
+	unsigned int chunk;
 	
 	if (down_interruptible(&tty->atomic_write)) {
 		return -ERESTARTSYS;
 	}
-	if ( test_bit(TTY_NO_WRITE_SPLIT, &tty->flags) ) {
+
+	/*
+	 * We chunk up writes into a temporary buffer. This
+	 * simplifies low-level drivers immensely, since they
+	 * don't have locking issues and user mode accesses.
+	 *
+	 * But if TTY_NO_WRITE_SPLIT is set, we should use a
+	 * big chunk-size..
+	 */
+	chunk = 4096;
+	if (test_bit(TTY_NO_WRITE_SPLIT, &tty->flags))
+		chunk = 65536;
+	if (count < chunk)
+		chunk = count;
+
+	/* write_buf/write_cnt is protected by the atomic_write semaphore */
+	if (tty->write_cnt < chunk) {
+		unsigned char *buf;
+
+		if (chunk < 1024)
+			chunk = 1024;
+
+		buf = kmalloc(chunk, GFP_KERNEL);
+		if (!buf) {
+			up(&tty->atomic_write);
+			return -ENOMEM;
+		}
+		kfree(tty->write_buf);
+		tty->write_cnt = chunk;
+		tty->write_buf = buf;
+	}
+
+	/* Do the write .. */
+	for (;;) {
+		size_t size = count;
+		if (size > chunk)
+			size = chunk;
+		ret = -EFAULT;
+		if (copy_from_user(tty->write_buf, buf, size))
+			break;
 		lock_kernel();
-		written = write(tty, file, buf, count);
+		ret = write(tty, file, tty->write_buf, size);
 		unlock_kernel();
-	} else {
-		for (;;) {
-			unsigned long size = max((unsigned long)PAGE_SIZE*2, 16384UL);
-			if (size > count)
-				size = count;
-			lock_kernel();
-			ret = write(tty, file, buf, size);
-			unlock_kernel();
-			if (ret <= 0)
-				break;
-			written += ret;
-			buf += ret;
-			count -= ret;
-			if (!count)
-				break;
-			ret = -ERESTARTSYS;
-			if (signal_pending(current))
-				break;
-			cond_resched();
-		}
+		if (ret <= 0)
+			break;
+		written += ret;
+		buf += ret;
+		count -= ret;
+		if (!count)
+			break;
+		ret = -ERESTARTSYS;
+		if (signal_pending(current))
+			break;
+		cond_resched();
 	}
 	if (written) {
 		file->f_dentry->d_inode->i_mtime = CURRENT_TIME;
@@ -1082,8 +1114,7 @@
 	if (!ld->write)
 		ret = -EIO;
 	else
-		ret = do_tty_write(ld->write, tty, file,
-			    (const unsigned char __user *)buf, count);
+		ret = do_tty_write(ld->write, tty, file, buf, count);
 	tty_ldisc_deref(ld);
 	return ret;
 }
@@ -1981,10 +2012,10 @@
 
 static int tioccons(struct file *file)
 {
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
 	if (file->f_op->write == redirected_tty_write) {
 		struct file *f;
-		if (!capable(CAP_SYS_ADMIN))
-			return -EPERM;
 		spin_lock(&redirect_lock);
 		f = redirect;
 		redirect = NULL;
@@ -2117,11 +2148,11 @@
 
 static int send_break(struct tty_struct *tty, int duration)
 {
-	set_current_state(TASK_INTERRUPTIBLE);
-
 	tty->driver->break_ctl(tty, -1);
-	if (!signal_pending(current))
+	if (!signal_pending(current)) {
+		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(duration);
+	}
 	tty->driver->break_ctl(tty, 0);
 	if (signal_pending(current))
 		return -EINTR;
@@ -2618,7 +2649,7 @@
  */
 static void tty_default_put_char(struct tty_struct *tty, unsigned char ch)
 {
-	tty->driver->write(tty, 0, &ch, 1);
+	tty->driver->write(tty, &ch, 1);
 }
 
 static struct class_simple *tty_class;
diff -Nru a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
--- a/drivers/char/tty_ioctl.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/char/tty_ioctl.c	2004-12-24 13:37:32 -08:00
@@ -19,9 +19,9 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/bitops.h>
 
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
@@ -382,7 +382,7 @@
 	}
 	if (was_stopped)
 		start_tty(tty);
-	tty->driver->write(tty, 0, &ch, 1);
+	tty->driver->write(tty, &ch, 1);
 	if (was_stopped)
 		stop_tty(tty);
 }
diff -Nru a/drivers/char/viocons.c b/drivers/char/viocons.c
--- a/drivers/char/viocons.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/char/viocons.c	2004-12-24 13:36:16 -08:00
@@ -83,15 +83,6 @@
 	u8 data[VIOCHAR_MAX_DATA];
 };
 
-/*
- * This is a place where we handle the distribution of memory
- * for copy_from_user() calls.  The buffer_available array is to
- * help us determine which buffer to use.
- */
-#define VIOCHAR_NUM_CFU_BUFFERS	7
-static struct viocharlpevent viocons_cfu_buffer[VIOCHAR_NUM_CFU_BUFFERS];
-static atomic_t viocons_cfu_buffer_available[VIOCHAR_NUM_CFU_BUFFERS];
-
 #define VIOCHAR_WINDOW		10
 #define VIOCHAR_HIGHWATERMARK	3
 
@@ -207,50 +198,6 @@
 }
 
 /*
- * This function should ONLY be called once from viocons_init2
- */
-static void viocons_init_cfu_buffer(void)
-{
-	int i;
-
-	for (i = 1; i < VIOCHAR_NUM_CFU_BUFFERS; i++)
-		atomic_set(&viocons_cfu_buffer_available[i], 1);
-}
-
-static struct viocharlpevent *viocons_get_cfu_buffer(void)
-{
-	int i;
-
-	/*
-	 * Grab the first available buffer.  It doesn't matter if we
-	 * are interrupted during this array traversal as long as we
-	 * get an available space.
-	 */
-	for (i = 0; i < VIOCHAR_NUM_CFU_BUFFERS; i++)
-		if (atomic_dec_if_positive(&viocons_cfu_buffer_available[i])
-				== 0 )
-			return &viocons_cfu_buffer[i];
-	hvlog("\n\rviocons: viocons_get_cfu_buffer : no free buffers found");
-	return NULL;
-}
-
-static void viocons_free_cfu_buffer(struct viocharlpevent *buffer)
-{
-	int i;
-
-	i = buffer - &viocons_cfu_buffer[0];
-	if (i >= (sizeof(viocons_cfu_buffer) / sizeof(viocons_cfu_buffer[0]))) {
-		hvlog("\n\rviocons: viocons_free_cfu_buffer : buffer pointer not found in list.");
-		return;
-	}
-	if (atomic_read(&viocons_cfu_buffer_available[i]) != 0) {
-		hvlog("\n\rviocons: WARNING : returning unallocated cfu buffer.");
-		return;
-	}
-	atomic_set(&viocons_cfu_buffer_available[i], 1);
-}
-
-/*
  * Add data to our pending-send buffers.  
  *
  * NOTE: Don't use printk in here because it gets nastily recursive.
@@ -438,15 +385,14 @@
  * NOTE: Don't use printk in here because it gets nastily recursive.  hvlog
  * can be used to log to the hypervisor buffer
  */
-static int internal_write(struct port_info *pi, const char *buf,
-			  size_t len, struct viocharlpevent *viochar)
+static int internal_write(struct port_info *pi, const char *buf, size_t len)
 {
 	HvLpEvent_Rc hvrc;
 	size_t bleft;
 	size_t curlen;
 	const char *curbuf;
 	unsigned long flags;
-	int copy_needed = (viochar == NULL);
+	struct viocharlpevent *viochar;
 
 	/*
 	 * Write to the hvlog of inbound data are now done prior to
@@ -462,25 +408,13 @@
 
 	spin_lock_irqsave(&consolelock, flags);
 
-	/*
-	 * If the internal_write() was passed a pointer to a
-	 * viocharlpevent then we don't need to allocate a new one
-	 * (this is the case where we are internal_writing user space
-	 * data).  If we aren't writing user space data then we need
-	 * to get an event from viopath.
-	 */
-	if (copy_needed) {
-		/* This one is fetched from the viopath data structure */
-		viochar = (struct viocharlpevent *)
-			vio_get_event_buffer(viomajorsubtype_chario);
-		/* Make sure we got a buffer */
-		if (viochar == NULL) {
-			spin_unlock_irqrestore(&consolelock, flags);
-			hvlog("\n\rviocons: Can't get viochar buffer in internal_write().");
-			return -EAGAIN;
-		}
-		initDataEvent(viochar, pi->lp);
+	viochar = vio_get_event_buffer(viomajorsubtype_chario);
+	if (viochar == NULL) {
+		spin_unlock_irqrestore(&consolelock, flags);
+		hvlog("\n\rviocons: Can't get vio buffer in internal_write().");
+		return -EAGAIN;
 	}
+	initDataEvent(viochar, pi->lp);
 
 	curbuf = buf;
 	bleft = len;
@@ -493,25 +427,16 @@
 			curlen = bleft;
 
 		viochar->event.xCorrelationToken = pi->seq++;
-
-		if (copy_needed) {
-			memcpy(viochar->data, curbuf, curlen);
-			viochar->len = curlen;
-		}
-
+		memcpy(viochar->data, curbuf, curlen);
+		viochar->len = curlen;
 		viochar->event.xSizeMinus1 =
 		    offsetof(struct viocharlpevent, data) + curlen;
 
 		hvrc = HvCallEvent_signalLpEvent(&viochar->event);
 		if (hvrc) {
-			spin_unlock_irqrestore(&consolelock, flags);
-			if (copy_needed)
-				vio_free_event_buffer(viomajorsubtype_chario, viochar);
-
 			hvlog("viocons: error sending event! %d\n", (int)hvrc);
-			return len - bleft;
+			goto out;
 		}
-
 		curbuf += curlen;
 		bleft -= curlen;
 	}
@@ -519,14 +444,9 @@
 	/* If we didn't send it all, buffer as much of it as we can. */
 	if (bleft > 0)
 		bleft -= buffer_add(pi, curbuf, bleft);
-	/*
-	 * Since we grabbed it from the viopath data structure, return
-	 * it to the data structure.
-	 */
-	if (copy_needed)
-		vio_free_event_buffer(viomajorsubtype_chario, viochar);
+out:
+	vio_free_event_buffer(viomajorsubtype_chario, viochar);
 	spin_unlock_irqrestore(&consolelock, flags);
-
 	return len - bleft;
 }
 
@@ -603,18 +523,8 @@
 
 	hvlogOutput(s, count);
 
-	if (!viopath_isactive(pi->lp)) {
-		/*
-		 * This is a VERY noisy trace message in the case where the
-		 * path manager is not active or in the case where this
-		 * function is called prior to viocons initialization.  It is
-		 * being commented out for the sake of a clear trace buffer.
-		 */
-#if 0
-		 hvlog("\n\rviocons_write: path not active to lp %d", pi->lp);
-#endif
+	if (!viopath_isactive(pi->lp))
 		return;
-	}
 
 	/* 
 	 * Any newline character found will cause a
@@ -627,17 +537,16 @@
 			 * Newline found. Print everything up to and 
 			 * including the newline
 			 */
-			internal_write(pi, &s[begin], index - begin + 1,
-					NULL);
+			internal_write(pi, &s[begin], index - begin + 1);
 			begin = index + 1;
 			/* Emit a carriage return as well */
-			internal_write(pi, &cr, 1, NULL);
+			internal_write(pi, &cr, 1);
 		}
 	}
 
 	/* If any characters left to write, write them now */
 	if ((index - begin) > 0)
-		internal_write(pi, &s[begin], index - begin, NULL);
+		internal_write(pi, &s[begin], index - begin);
 }
 
 /*
@@ -721,11 +630,9 @@
 /*
  * TTY Write method
  */
-static int viotty_write(struct tty_struct *tty, int from_user,
-			const unsigned char *buf, int count)
+static int viotty_write(struct tty_struct *tty, const unsigned char *buf,
+		int count)
 {
-	int ret;
-	int total = 0;
 	struct port_info *pi;
 
 	pi = get_port_data(tty);
@@ -746,53 +653,10 @@
 	 * viotty_write call and, since the viopath isn't active to this
 	 * partition, return count.
 	 */
-	if (!viopath_isactive(pi->lp)) {
-		/* Noisy trace.  Commented unless needed. */
-#if 0
-		 hvlog("\n\rviotty_write: viopath NOT active for lp %d.",pi->lp);
-#endif
+	if (!viopath_isactive(pi->lp))
 		return count;
-	}
 
-	/*
-	 * If the viotty_write is invoked from user space we want to do the
-	 * copy_from_user() into an event buffer from the cfu buffer before
-	 * internal_write() is called because internal_write may need to buffer
-	 * data which will need to grab a spin_lock and we shouldn't
-	 * copy_from_user() while holding a spin_lock.  Should internal_write()
-	 * not need to buffer data then it'll just use the event we created here
-	 * rather than checking one out from vio_get_event_buffer().
-	 */
-	if (from_user) {
-		struct viocharlpevent *viochar;
-		int curlen;
-		const char *curbuf = buf;
-
-		viochar = viocons_get_cfu_buffer();
-		if (viochar == NULL)
-			return -EAGAIN;
-		initDataEvent(viochar, pi->lp);
-		while (count > 0) {
-			if (count > VIOCHAR_MAX_DATA)
-				curlen = VIOCHAR_MAX_DATA;
-			else
-				curlen = count;
-			viochar->len = curlen;
-			ret = copy_from_user(viochar->data, curbuf, curlen);
-			if (ret)
-				break;
-			ret = internal_write(pi, viochar->data,
-					viochar->len, viochar);
-			total += ret;
-			if (ret != curlen)
-				break;
-			count -= curlen;
-			curbuf += curlen;
-		}
-		viocons_free_cfu_buffer(viochar);
-	} else
-		total = internal_write(pi, buf, count, NULL);
-	return total;
+	return internal_write(pi, buf, count);
 }
 
 /*
@@ -811,7 +675,7 @@
 		hvlogOutput(&ch, 1);
 
 	if (viopath_isactive(pi->lp))
-		internal_write(pi, &ch, 1, NULL);
+		internal_write(pi, &ch, 1);
 }
 
 /*
@@ -920,7 +784,7 @@
 			atomic_set(aptr, 1);
 		} else
 			printk(VIOCONS_KERN_WARN
-			       "wierd...got open ack without atomic\n");
+			       "weird...got open ack without atomic\n");
 		return;
 	}
 
@@ -1306,8 +1170,6 @@
 		put_tty_driver(viotty_driver);
 		viotty_driver = NULL;
 	}
-
-	viocons_init_cfu_buffer();
 
 	unregister_console(&viocons_early);
 	register_console(&viocons);
diff -Nru a/drivers/char/viotape.c b/drivers/char/viotape.c
--- a/drivers/char/viotape.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/char/viotape.c	2004-12-24 13:37:18 -08:00
@@ -938,7 +938,7 @@
 		}
 		break;
 	default:
-		printk(VIOTAPE_KERN_WARN "wierd ack\n");
+		printk(VIOTAPE_KERN_WARN "weird ack\n");
 	}
 }
 
diff -Nru a/drivers/char/vt.c b/drivers/char/vt.c
--- a/drivers/char/vt.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/char/vt.c	2004-12-24 13:37:18 -08:00
@@ -101,11 +101,11 @@
 #include <linux/bootmem.h>
 #include <linux/pm.h>
 #include <linux/font.h>
+#include <linux/bitops.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 
 #include "console_macros.h"
 
@@ -768,6 +768,8 @@
  * [this is to be used together with some user program
  * like resize that changes the hardware videomode]
  */
+#define VC_RESIZE_MAXCOL (32767)
+#define VC_RESIZE_MAXROW (32767)
 int vc_resize(int currcons, unsigned int cols, unsigned int lines)
 {
 	unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0;
@@ -780,6 +782,9 @@
 	if (!vc_cons_allocated(currcons))
 		return -ENXIO;
 
+	if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW)
+		return -EINVAL;
+
 	new_cols = (cols ? cols : video_num_columns);
 	new_rows = (lines ? lines : video_num_lines);
 	new_row_size = new_cols << 1;
@@ -1889,8 +1894,7 @@
 DECLARE_MUTEX(con_buf_sem);
 
 /* acquires console_sem */
-static int do_con_write(struct tty_struct *tty, int from_user,
-			const unsigned char *buf, int count)
+static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 #ifdef VT_BUF_VRAM_ONLY
 #define FLUSH do { } while(0);
@@ -1938,22 +1942,6 @@
 	orig_buf = buf;
 	orig_count = count;
 
-	if (from_user) {
-
-		down(&con_buf_sem);
-
-again:
-		if (count > CON_BUF_SIZE)
-			count = CON_BUF_SIZE;
-		console_conditional_schedule();
-		if (copy_from_user(con_buf, buf, count)) {
-			n = 0; /* ?? are error codes legal here ?? */
-			goto out;
-		}
-
-		buf = con_buf;
-	}
-
 	/* At this point 'buf' is guaranteed to be a kernel buffer
 	 * and therefore no access to userspace (and therefore sleeping)
 	 * will be needed.  The con_buf_sem serializes all tty based
@@ -2094,22 +2082,6 @@
 	release_console_sem();
 
 out:
-	if (from_user) {
-		/* If the user requested something larger than
-		 * the CON_BUF_SIZE, and the tty is not stopped,
-		 * keep going.
-		 */
-		if ((orig_count > CON_BUF_SIZE) && !tty->stopped) {
-			orig_count -= CON_BUF_SIZE;
-			orig_buf += CON_BUF_SIZE;
-			count = orig_count;
-			buf = orig_buf;
-			goto again;
-		}
-
-		up(&con_buf_sem);
-	}
-
 	return n;
 #undef FLUSH
 }
@@ -2186,8 +2158,6 @@
 	if (!printable || test_and_set_bit(0, &printing))
 		return;
 
-	pm_access(pm_con);
-
 	if (kmsg_redirect && vc_cons_allocated(kmsg_redirect - 1))
 		currcons = kmsg_redirect - 1;
 
@@ -2382,13 +2352,11 @@
  * /dev/ttyN handling
  */
 
-static int con_write(struct tty_struct *tty, int from_user,
-		     const unsigned char *buf, int count)
+static int con_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	int	retval;
 
-	pm_access(pm_con);
-	retval = do_con_write(tty, from_user, buf, count);
+	retval = do_con_write(tty, buf, count);
 	con_flush_chars(tty);
 
 	return retval;
@@ -2398,8 +2366,7 @@
 {
 	if (in_interrupt())
 		return;	/* n_r3964 calls put_char() from interrupt context */
-	pm_access(pm_con);
-	do_con_write(tty, 0, &ch, 1);
+	do_con_write(tty, &ch, 1);
 }
 
 static int con_write_room(struct tty_struct *tty)
@@ -2467,8 +2434,6 @@
 	if (in_interrupt())	/* from flush_to_ldisc */
 		return;
 
-	pm_access(pm_con);
-	
 	/* if we race with con_close(), vt may be null */
 	acquire_console_sem();
 	vt = tty->driver_data;
@@ -3077,6 +3042,10 @@
 	if (rc)
 		goto out;
 
+	op->height = font.height;
+	op->width = font.width;
+	op->charcount = font.charcount;
+
 	if (op->data && copy_to_user(op->data, font.data, c))
 		rc = -EFAULT;
 
@@ -3285,7 +3254,6 @@
 EXPORT_SYMBOL(default_red);
 EXPORT_SYMBOL(default_grn);
 EXPORT_SYMBOL(default_blu);
-EXPORT_SYMBOL(vc_cons_allocated);
 EXPORT_SYMBOL(update_region);
 EXPORT_SYMBOL(redraw_screen);
 EXPORT_SYMBOL(vc_resize);
diff -Nru a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
--- a/drivers/char/watchdog/Kconfig	2004-12-24 13:37:01 -08:00
+++ b/drivers/char/watchdog/Kconfig	2004-12-24 13:37:01 -08:00
@@ -106,6 +106,22 @@
 
 	  Say N if you are unsure.
 
+config S3C2410_WATCHDOG
+	tristate "S3C2410 Watchdog"
+	depends on WATCHDOG && ARCH_S3C2410
+	help
+	  Watchdog timer block in the Samsung S3C2410 chips. This will
+	  reboot the system when the timer expires with the watchdog
+	  enabled.
+
+	  The driver is limited by the speed of the system's PCLK
+	  signal, so with reasonbaly fast systems (PCLK around 50-66MHz)
+	  then watchdog intervals of over approximately 20seconds are
+	  unavailable.
+
+	  The driver can be built as a module by choosing M, and will
+	  be called s3c2410_wdt
+
 config SA1100_WATCHDOG
 	tristate "SA1100/PXA2xx watchdog"
 	depends on WATCHDOG && ( ARCH_SA1100 || ARCH_PXA )
@@ -335,6 +351,20 @@
 	  watchdog timer that will reboot the machine after a 60 second
 	  timer expired and no process has written to /dev/watchdog during
 	  that time.
+
+# S390 Architecture
+
+config ZVM_WATCHDOG
+	tristate "z/VM Watchdog Timer"
+	depends on WATCHDOG && ARCH_S390
+	help
+	  IBM s/390 and zSeries machines running under z/VM 5.1 or later
+	  provide a virtual watchdog timer to their guest that cause a
+	  user define Control Program command to be executed after a
+	  timeout.
+
+	  To compile this driver as a module, choose M here. The module
+	  will be called vmwatchdog.
 
 # SUPERH Architecture
 
diff -Nru a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
--- a/drivers/char/watchdog/Makefile	2004-12-24 13:37:03 -08:00
+++ b/drivers/char/watchdog/Makefile	2004-12-24 13:37:03 -08:00
@@ -21,6 +21,7 @@
 obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o
 obj-$(CONFIG_MACHZ_WDT) += machzwd.o
 obj-$(CONFIG_SH_WDT) += shwdt.o
+obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
 obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
 obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
diff -Nru a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c
--- a/drivers/char/watchdog/i8xx_tco.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/char/watchdog/i8xx_tco.c	2004-12-24 13:36:17 -08:00
@@ -415,12 +415,15 @@
 			}
 		}
 		/* Set the TCO_EN bit in SMI_EN register */
+		if (!request_region (SMI_EN + 1, 1, "i8xx TCO")) {
+			printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
+				SMI_EN + 1);
+			return 0;
+		}
 		val1 = inb (SMI_EN + 1);
 		val1 &= 0xdf;
 		outb (val1, SMI_EN + 1);
-		/* Clear out the (probably old) status */
-		outb (0, TCO1_STS);
-		outb (3, TCO2_STS);
+		release_region (SMI_EN + 1, 1);
 		return 1;
 	}
 	return 0;
@@ -443,6 +446,10 @@
 		goto out;
 	}
 
+	/* Clear out the (probably old) status */
+	outb (0, TCO1_STS);
+	outb (3, TCO2_STS);
+
 	/* Check that the heartbeat value is within it's range ; if not reset to the default */
 	if (tco_timer_set_heartbeat (heartbeat)) {
 		heartbeat = WATCHDOG_HEARTBEAT;
@@ -465,7 +472,7 @@
 		goto unreg_notifier;
 	}
 
-	tco_timer_keepalive ();
+	tco_timer_stop ();
 
 	printk (KERN_INFO PFX "initialized (0x%04x). heartbeat=%d sec (nowayout=%d)\n",
 		TCOBASE, heartbeat, nowayout);
diff -Nru a/drivers/char/watchdog/ixp2000_wdt.c b/drivers/char/watchdog/ixp2000_wdt.c
--- a/drivers/char/watchdog/ixp2000_wdt.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/char/watchdog/ixp2000_wdt.c	2004-12-24 13:36:19 -08:00
@@ -25,9 +25,9 @@
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/hardware.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 #ifdef CONFIG_WATCHDOG_NOWAYOUT
diff -Nru a/drivers/char/watchdog/ixp4xx_wdt.c b/drivers/char/watchdog/ixp4xx_wdt.c
--- a/drivers/char/watchdog/ixp4xx_wdt.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/char/watchdog/ixp4xx_wdt.c	2004-12-24 13:37:18 -08:00
@@ -22,9 +22,9 @@
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/hardware.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 #ifdef CONFIG_WATCHDOG_NOWAYOUT
@@ -216,7 +216,7 @@
 module_init(ixp4xx_wdt_init);
 module_exit(ixp4xx_wdt_exit);
 
-MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net">);
+MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
 MODULE_DESCRIPTION("IXP4xx Network Processor Watchdog");
 
 module_param(heartbeat, int, 0);
diff -Nru a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/char/watchdog/s3c2410_wdt.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,516 @@
+/* linux/drivers/char/watchdog/s3c2410_wdt.c
+ *
+ * Copyright (c) 2004 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C2410 Watchdog Timer Support
+ *
+ * Based on, softdog.c by Alan Cox,
+ *     (c) Copyright 1996 Alan Cox <alan@redhat.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 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
+ *
+ * Changelog:
+ *	05-Oct-2004	BJD	Added semaphore init to stop crashes on open
+ *				Fixed tmr_count / wdt_count confusion
+ *				Added configurable debug
+*/
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/timer.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/fs.h>
+#include <linux/notifier.h>
+#include <linux/reboot.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+
+#include <asm/uaccess.h>
+#include <asm/io.h>
+
+#include <asm/arch/map.h>
+#include <asm/hardware/clock.h>
+
+#undef S3C2410_VA_WATCHDOG
+#define S3C2410_VA_WATCHDOG (0)
+
+#include <asm/arch/regs-watchdog.h>
+
+#define PFX "s3c2410-wdt: "
+
+#define CONFIG_S3C2410_WATCHDOG_ATBOOT		(0)
+#define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME	(15)
+
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
+static int nowayout = 1;
+#else
+static int nowayout = 0;
+#endif
+
+static int tmr_margin	= CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME;
+static int tmr_atboot	= CONFIG_S3C2410_WATCHDOG_ATBOOT;
+static int soft_noboot	= 0;
+static int debug	= 0;
+
+module_param(tmr_margin,  int, 0);
+module_param(tmr_atboot,  int, 0);
+module_param(nowayout,    int, 0);
+module_param(soft_noboot, int, 0);
+module_param(debug,	  int, 0);
+
+MODULE_PARM_DESC(tmr_margin, "Watchdog tmr_margin in seconds. default=" __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME) ")");
+
+MODULE_PARM_DESC(tmr_atboot, "Watchdog is started at boot time if set to 1, default=" __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT));
+
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
+
+MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)");
+
+MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug, (default 0)");
+
+
+typedef enum close_state {
+	CLOSE_STATE_NOT,
+	CLOSE_STATE_ALLOW=0x4021
+} close_state_t;
+
+static DECLARE_MUTEX(open_lock);
+
+static struct resource	*wdt_mem;
+static struct resource	*wdt_irq;
+static struct clk	*wdt_clock;
+static void __iomem	*wdt_base;
+static unsigned int	 wdt_count;
+static close_state_t	 allow_close;
+
+/* watchdog control routines */
+
+#define DBG(msg...) do { \
+	if (debug) \
+		printk(KERN_INFO msg); \
+	} while(0)
+
+/* functions */
+
+static int s3c2410wdt_keepalive(void)
+{
+	writel(wdt_count, wdt_base + S3C2410_WTCNT);
+	return 0;
+}
+
+static int s3c2410wdt_stop(void)
+{
+	unsigned long wtcon;
+
+	wtcon = readl(wdt_base + S3C2410_WTCON);
+	wtcon &= ~(S3C2410_WTCON_ENABLE | S3C2410_WTCON_RSTEN);
+	writel(wtcon, wdt_base + S3C2410_WTCON);
+
+	return 0;
+}
+
+static int s3c2410wdt_start(void)
+{
+	unsigned long wtcon;
+
+	s3c2410wdt_stop();
+
+	wtcon = readl(wdt_base + S3C2410_WTCON);
+	wtcon |= S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128;
+
+	if (soft_noboot) {
+		wtcon |= S3C2410_WTCON_INTEN;
+		wtcon &= ~S3C2410_WTCON_RSTEN;
+	} else {
+		wtcon &= ~S3C2410_WTCON_INTEN;
+		wtcon |= S3C2410_WTCON_RSTEN;
+	}
+
+	DBG("%s: wdt_count=0x%08x, wtcon=%08lx\n",
+	    __FUNCTION__, wdt_count, wtcon);
+
+	writel(wdt_count, wdt_base + S3C2410_WTDAT);
+	writel(wdt_count, wdt_base + S3C2410_WTCNT);
+	writel(wtcon, wdt_base + S3C2410_WTCON);
+
+	return 0;
+}
+
+static int s3c2410wdt_set_heartbeat(int timeout)
+{
+	unsigned int freq = clk_get_rate(wdt_clock);
+	unsigned int count;
+	unsigned int divisor = 1;
+	unsigned long wtcon;
+
+	if (timeout < 1)
+		return -EINVAL;
+
+	/* I think someone must have missed a divide-by-2 in the 2410,
+	 * as a divisor of 128 gives half the calculated delay...
+	 */
+
+	freq /= 128/2;
+	count = timeout * freq;
+
+	DBG("%s: count=%d, timeout=%d, freq=%d\n",
+	    __FUNCTION__, count, timeout, freq);
+
+	/* if the count is bigger than the watchdog register,
+	   then work out what we need to do (and if) we can
+	   actually make this value
+	*/
+
+	if (count >= 0x10000) {
+		for (divisor = 1; divisor <= 0x100; divisor++) {
+			if ((count / divisor) < 0x10000)
+				break;
+		}
+
+		if ((count / divisor) >= 0x10000) {
+			printk(KERN_ERR PFX "timeout %d too big\n", timeout);
+			return -EINVAL;
+		}
+	}
+
+	tmr_margin = timeout;
+
+	DBG("%s: timeout=%d, divisor=%d, count=%d (%08x)\n",
+	    __FUNCTION__, timeout, divisor, count, count/divisor);
+
+	count /= divisor;
+	wdt_count = count;
+
+	/* update the pre-scaler */
+	wtcon = readl(wdt_base + S3C2410_WTCON);
+	wtcon &= ~S3C2410_WTCON_PRESCALE_MASK;
+	wtcon |= S3C2410_WTCON_PRESCALE(divisor-1);
+
+	writel(count, wdt_base + S3C2410_WTDAT);
+	writel(wtcon, wdt_base + S3C2410_WTCON);
+
+	return 0;
+}
+
+/*
+ *	/dev/watchdog handling
+ */
+
+static int s3c2410wdt_open(struct inode *inode, struct file *file)
+{
+	if(down_trylock(&open_lock))
+		return -EBUSY;
+
+	if (nowayout) {
+		__module_get(THIS_MODULE);
+	} else {
+		allow_close = CLOSE_STATE_ALLOW;
+	}
+
+	/* start the timer */
+	s3c2410wdt_start();
+	return nonseekable_open(inode, file);
+}
+
+static int s3c2410wdt_release(struct inode *inode, struct file *file)
+{
+	/*
+	 *	Shut off the timer.
+	 * 	Lock it in if it's a module and we set nowayout
+	 */
+	if (allow_close == CLOSE_STATE_ALLOW) {
+		s3c2410wdt_stop();
+	} else {
+		printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
+		s3c2410wdt_keepalive();
+	}
+
+	allow_close = CLOSE_STATE_NOT;
+	up(&open_lock);
+	return 0;
+}
+
+static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
+				size_t len, loff_t *ppos)
+{
+	/*
+	 *	Refresh the timer.
+	 */
+	if(len) {
+		if (!nowayout) {
+			size_t i;
+
+			/* In case it was set long ago */
+			allow_close = CLOSE_STATE_NOT;
+
+			for (i = 0; i != len; i++) {
+				char c;
+
+				if (get_user(c, data + i))
+					return -EFAULT;
+				if (c == 'V')
+					allow_close = CLOSE_STATE_ALLOW;
+			}
+		}
+
+		s3c2410wdt_keepalive();
+	}
+	return len;
+}
+
+#define OPTIONS WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE
+
+static struct watchdog_info s3c2410_wdt_ident = {
+	.options          =     OPTIONS,
+	.firmware_version =	0,
+	.identity         =	"S3C2410 Watchdog",
+};
+
+
+static int s3c2410wdt_ioctl(struct inode *inode, struct file *file,
+	unsigned int cmd, unsigned long arg)
+{
+	void __user *argp = (void __user *)arg;
+	int __user *p = argp;
+	int new_margin;
+
+	switch (cmd) {
+		default:
+			return -ENOIOCTLCMD;
+
+		case WDIOC_GETSUPPORT:
+			return copy_to_user(argp, &s3c2410_wdt_ident,
+				sizeof(s3c2410_wdt_ident)) ? -EFAULT : 0;
+
+		case WDIOC_GETSTATUS:
+		case WDIOC_GETBOOTSTATUS:
+			return put_user(0, p);
+
+		case WDIOC_KEEPALIVE:
+			s3c2410wdt_keepalive();
+			return 0;
+
+		case WDIOC_SETTIMEOUT:
+			if (get_user(new_margin, p))
+				return -EFAULT;
+
+			if (s3c2410wdt_set_heartbeat(new_margin))
+				return -EINVAL;
+
+			s3c2410wdt_keepalive();
+			return put_user(tmr_margin, p);
+
+		case WDIOC_GETTIMEOUT:
+			return put_user(tmr_margin, p);
+	}
+}
+
+/*
+ *	Notifier for system down
+ */
+
+static int s3c2410wdt_notify_sys(struct notifier_block *this, unsigned long code,
+			      void *unused)
+{
+	if(code==SYS_DOWN || code==SYS_HALT) {
+		/* Turn the WDT off */
+		s3c2410wdt_stop();
+	}
+	return NOTIFY_DONE;
+}
+
+/* kernel interface */
+
+static struct file_operations s3c2410wdt_fops = {
+	.owner		= THIS_MODULE,
+	.llseek		= no_llseek,
+	.write		= s3c2410wdt_write,
+	.ioctl		= s3c2410wdt_ioctl,
+	.open		= s3c2410wdt_open,
+	.release	= s3c2410wdt_release,
+};
+
+static struct miscdevice s3c2410wdt_miscdev = {
+	.minor		= WATCHDOG_MINOR,
+	.name		= "watchdog",
+	.fops		= &s3c2410wdt_fops,
+};
+
+static struct notifier_block s3c2410wdt_notifier = {
+	.notifier_call	= s3c2410wdt_notify_sys,
+};
+
+/* interrupt handler code */
+
+static irqreturn_t s3c2410wdt_irq(int irqno, void *param,
+				  struct pt_regs *regs)
+{
+	printk(KERN_INFO PFX "Watchdog timer expired!\n");
+
+	s3c2410wdt_keepalive();
+	return IRQ_HANDLED;
+}
+/* device interface */
+
+static int s3c2410wdt_probe(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct resource *res;
+	int started = 0;
+	int ret;
+	int size;
+
+	DBG("%s: probe=%p, device=%p\n", __FUNCTION__, pdev, dev);
+
+	/* get the memory region for the watchdog timer */
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		printk(KERN_INFO PFX "failed to get memory region resouce\n");
+		return -ENOENT;
+	}
+
+	size = (res->end-res->start)+1;
+	wdt_mem = request_mem_region(res->start, size, pdev->name);
+	if (wdt_mem == NULL) {
+		printk(KERN_INFO PFX "failed to get memory region\n");
+		return -ENOENT;
+	}
+
+	wdt_base = ioremap(res->start, size);
+	if (wdt_base == 0) {
+		printk(KERN_INFO PFX "failed to ioremap() region\n");
+		return -EINVAL;
+	}
+
+	DBG("probe: mapped wdt_base=%p\n", wdt_base);
+
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (res == NULL) {
+		printk(KERN_INFO PFX "failed to get irq resource\n");
+		return -ENOENT;
+	}
+
+	ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, dev);
+	if (ret != 0) {
+		printk(KERN_INFO PFX "failed to install irq (%d)\n", ret);
+		return ret;
+	}
+
+	wdt_clock = clk_get(dev, "watchdog");
+	if (wdt_clock == NULL) {
+		printk(KERN_INFO PFX "failed to find watchdog clock source\n");
+		return -ENOENT;
+	}
+
+	clk_use(wdt_clock);
+	clk_enable(wdt_clock);
+
+	/* see if we can actually set the requested timer margin, and if
+	 * not, try the default value */
+
+	if (s3c2410wdt_set_heartbeat(tmr_margin)) {
+		started = s3c2410wdt_set_heartbeat(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME);
+
+		if (started == 0) {
+			printk(KERN_INFO PFX "tmr_margin value out of range, default %d used\n",
+			       CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME);
+		} else {
+			printk(KERN_INFO PFX "default timer value is out of range, cannot start\n");
+		}
+	}
+
+	ret = register_reboot_notifier(&s3c2410wdt_notifier);
+	if (ret) {
+		printk (KERN_ERR PFX "cannot register reboot notifier (%d)\n",
+			ret);
+		return ret;
+	}
+
+	ret = misc_register(&s3c2410wdt_miscdev);
+	if (ret) {
+		printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n",
+			WATCHDOG_MINOR, ret);
+		unregister_reboot_notifier(&s3c2410wdt_notifier);
+		return ret;
+	}
+
+	if (tmr_atboot && started == 0) {
+		printk(KERN_INFO PFX "Starting Watchdog Timer\n");
+		s3c2410wdt_start();
+	}
+
+	return 0;
+}
+
+static int s3c2410wdt_remove(struct device *dev)
+{
+	if (wdt_mem != NULL) {
+		release_resource(wdt_mem);
+		kfree(wdt_mem);
+		wdt_mem = NULL;
+	}
+
+	if (wdt_irq != NULL) {
+		free_irq(wdt_irq->start, dev);
+		wdt_irq = NULL;
+	}
+
+	if (wdt_clock != NULL) {
+		clk_disable(wdt_clock);
+		clk_unuse(wdt_clock);
+		clk_put(wdt_clock);
+		wdt_clock = NULL;
+	}
+
+	misc_deregister(&s3c2410wdt_miscdev);
+	return 0;
+}
+
+static struct device_driver s3c2410wdt_driver = {
+	.name		= "s3c2410-wdt",
+	.bus		= &platform_bus_type,
+	.probe		= s3c2410wdt_probe,
+	.remove		= s3c2410wdt_remove,
+};
+
+
+
+static char banner[] __initdata = KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n";
+
+static int __init watchdog_init(void)
+{
+	printk(banner);
+	return driver_register(&s3c2410wdt_driver);
+}
+
+static void __exit watchdog_exit(void)
+{
+	driver_unregister(&s3c2410wdt_driver);
+	unregister_reboot_notifier(&s3c2410wdt_notifier);
+}
+
+module_init(watchdog_init);
+module_exit(watchdog_exit);
+
+MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
+MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff -Nru a/drivers/char/watchdog/sc520_wdt.c b/drivers/char/watchdog/sc520_wdt.c
--- a/drivers/char/watchdog/sc520_wdt.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/char/watchdog/sc520_wdt.c	2004-12-24 13:36:49 -08:00
@@ -122,7 +122,7 @@
 #define WDT_WRST_ENB	0x4000	/* [14] Watchdog Timer Reset Enable */
 #define WDT_ENB		0x8000	/* [15] Watchdog Timer Enable */
 
-static __u16 *wdtmrctl;
+static __u16 __iomem *wdtmrctl;
 
 static void wdt_timer_ping(unsigned long);
 static struct timer_list timer;
diff -Nru a/drivers/char/watchdog/scx200_wdt.c b/drivers/char/watchdog/scx200_wdt.c
--- a/drivers/char/watchdog/scx200_wdt.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/char/watchdog/scx200_wdt.c	2004-12-24 13:37:01 -08:00
@@ -217,6 +217,11 @@
 static int __init scx200_wdt_init(void)
 {
 	int r;
+	static struct pci_device_id ns_sc[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) },
+		{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) },
+		{ },
+	};
 
 	printk(KERN_DEBUG NAME ": NatSemi SCx200 Watchdog Driver\n");
 
@@ -224,12 +229,7 @@
 	 * First check that this really is a NatSemi SCx200 CPU or a Geode
 	 * SC1100 processor
 	 */
-	if ((pci_find_device(PCI_VENDOR_ID_NS,
-			     PCI_DEVICE_ID_NS_SCx200_BRIDGE,
-			     NULL)) == NULL
-	    && (pci_find_device(PCI_VENDOR_ID_NS,
-				PCI_DEVICE_ID_NS_SC1100_BRIDGE,
-				NULL)) == NULL)
+	if (!pci_dev_present(ns_sc))
 		return -ENODEV;
 
 	/* More sanity checks, verify that the configuration block is there */
diff -Nru a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
--- a/drivers/cpufreq/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/drivers/cpufreq/Kconfig	2004-12-24 13:37:19 -08:00
@@ -1,3 +1,32 @@
+config CPU_FREQ
+	bool "CPU Frequency scaling"
+	help
+	  CPU Frequency scaling allows you to change the clock speed of 
+	  CPUs on the fly. This is a nice method to save power, because 
+	  the lower the CPU clock speed, the less power the CPU consumes.
+
+	  Note that this driver doesn't automatically change the CPU
+	  clock speed, you need to either enable a dynamic cpufreq governor
+	  (see below) after boot, or use a userspace tool.
+
+	  For details, take a look at <file:Documentation/cpu-freq>.
+
+	  If in doubt, say N.
+
+config CPU_FREQ_DEBUG
+	bool "Enable CPUfreq debugging"
+	depends on CPU_FREQ
+	help
+	  Say Y here to enable CPUfreq subsystem (including drivers)
+	  debugging. You will need to activate it via the kernel
+	  command line by passing
+	     cpufreq.debug=<value>
+
+	  To get <value>, add 
+	       1 to activate CPUfreq core debugging,
+	       2 to activate CPUfreq drivers debugging, and
+	       4 to activate CPUfreq governor debugging
+
 config CPU_FREQ_PROC_INTF
 	tristate "/proc/cpufreq interface (deprecated)"
 	depends on CPU_FREQ && PROC_FS
@@ -33,7 +62,7 @@
 	help
 	  Use the CPUFreq governor 'userspace' as default. This allows
 	  you to set the CPU frequency manually or when an userspace 
-	  programm shall be able to set the CPU dynamically without having
+	  program shall be able to set the CPU dynamically without having
 	  to enable the userspace governor manually.
 
 endchoice
@@ -42,7 +71,7 @@
        tristate "'performance' governor"
        depends on CPU_FREQ
        help
-	  This cpufreq governors set the frequency statically to the
+	  This cpufreq governor sets the frequency statically to the
 	  highest available CPU frequency.
 
 	  If in doubt, say Y.
@@ -51,7 +80,7 @@
        tristate "'powersave' governor"
        depends on CPU_FREQ
        help
-	  Theis cpufreq governors set the frequency statically to the
+	  This cpufreq governor sets the frequency statically to the
 	  lowest available CPU frequency.
 
 	  If in doubt, say Y.
@@ -61,14 +90,29 @@
        depends on CPU_FREQ 
        help
 	  Enable this cpufreq governor when you either want to set the
-	  CPU frequency manually or when an userspace programm shall
-          be able to set the CPU dynamically, like on LART 
+	  CPU frequency manually or when an userspace program shall
+	  be able to set the CPU dynamically, like on LART 
 	  <http://www.lart.tudelft.nl/>
 
 	  For details, take a look at <file:Documentation/cpu-freq/>.
 
 	  If in doubt, say Y.
 
+config CPU_FREQ_24_API
+	bool "/proc/sys/cpu/ interface (2.4. / OLD)"
+	depends on CPU_FREQ_GOV_USERSPACE
+	depends on SYSCTL
+	help
+	  This enables the /proc/sys/cpu/ sysctl interface for controlling
+	  the CPUFreq,"userspace" governor. This is the same interface
+	  as known from the 2.4.-kernel patches for CPUFreq, and offers
+	  the same functionality as long as "userspace" is the
+	  selected governor for the specified CPU.
+	
+	  For details, take a look at <file:Documentation/cpu-freq/>.
+
+	  If in doubt, say N.
+
 config CPU_FREQ_GOV_ONDEMAND
 	tristate "'ondemand' cpufreq policy governor"
 	depends on CPU_FREQ
@@ -81,19 +125,5 @@
 	  transitions). 
 
 	  For details, take a look at linux/Documentation/cpu-freq.
-
-	  If in doubt, say N.
-
-config CPU_FREQ_24_API
-	bool "/proc/sys/cpu/ interface (2.4. / OLD)"
-	depends on CPU_FREQ && SYSCTL && CPU_FREQ_GOV_USERSPACE
-	help
-	  This enables the /proc/sys/cpu/ sysctl interface for controlling
-	  the CPUFreq,"userspace" governor. This is the same interface
-	  as known from the 2.4.-kernel patches for CPUFreq, and offers
-	  the same functionality as long as "userspace" is the
-	  selected governor for the specified CPU.
-	
-	  For details, take a look at <file:Documentation/cpu-freq/>.
 
 	  If in doubt, say N.
diff -Nru a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
--- a/drivers/cpufreq/cpufreq.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/cpufreq/cpufreq.c	2004-12-24 13:36:31 -08:00
@@ -24,6 +24,8 @@
 #include <linux/cpu.h>
 #include <linux/completion.h>
 
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "cpufreq-core", msg)
+
 /**
  * The "cpufreq driver" - the arch- or hardware-dependend low
  * level driver of CPUFreq support, and its spinlock. This lock
@@ -33,6 +35,14 @@
 static struct cpufreq_policy	*cpufreq_cpu_data[NR_CPUS];
 static spinlock_t		cpufreq_driver_lock = SPIN_LOCK_UNLOCKED;
 
+
+/* we keep a copy of all ->add'ed CPU's struct sys_device here;
+ * as it is only accessed in ->add and ->remove, no lock or reference
+ * count is necessary.
+ */
+static struct sys_device	*cpu_sys_devices[NR_CPUS];
+
+
 /* internal prototypes */
 static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
 static void handle_update(void *data);
@@ -99,6 +109,90 @@
 	module_put(cpufreq_driver->owner);
 }
 
+
+/*********************************************************************
+ *                     UNIFIED DEBUG HELPERS                         *
+ *********************************************************************/
+#ifdef CONFIG_CPU_FREQ_DEBUG
+
+/* what part(s) of the CPUfreq subsystem are debugged? */
+static unsigned int debug;
+
+/* is the debug output ratelimit'ed using printk_ratelimit? User can
+ * set or modify this value.
+ */
+static unsigned int debug_ratelimit = 1;
+
+/* is the printk_ratelimit'ing enabled? It's enabled after a successful
+ * loading of a cpufreq driver, temporarily disabled when a new policy
+ * is set, and disabled upon cpufreq driver removal
+ */
+static unsigned int disable_ratelimit = 1;
+static spinlock_t disable_ratelimit_lock = SPIN_LOCK_UNLOCKED;
+
+static inline void cpufreq_debug_enable_ratelimit(void)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&disable_ratelimit_lock, flags);
+	if (disable_ratelimit)
+		disable_ratelimit--;
+	spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
+}
+
+static inline void cpufreq_debug_disable_ratelimit(void)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&disable_ratelimit_lock, flags);
+	disable_ratelimit++;
+	spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
+}
+
+void cpufreq_debug_printk(unsigned int type, const char *prefix, const char *fmt, ...)
+{
+	char s[256];
+	va_list args;
+	unsigned int len;
+	unsigned long flags;
+	
+	WARN_ON(!prefix);
+	if (type & debug) {
+		spin_lock_irqsave(&disable_ratelimit_lock, flags);
+		if (!disable_ratelimit && debug_ratelimit && !printk_ratelimit()) {
+			spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
+			return;
+		}
+		spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
+
+		len = snprintf(s, 256, KERN_DEBUG "%s: ", prefix);
+
+		va_start(args, fmt);
+		len += vsnprintf(&s[len], (256 - len), fmt, args);
+		va_end(args);
+
+		printk(s);
+
+		WARN_ON(len < 5);
+	}
+}
+EXPORT_SYMBOL(cpufreq_debug_printk);
+
+
+module_param(debug, uint, 0644);
+MODULE_PARM_DESC(debug, "CPUfreq debugging: add 1 to debug core, 2 to debug drivers, and 4 to debug governors.");
+
+module_param(debug_ratelimit, uint, 0644);
+MODULE_PARM_DESC(debug_ratelimit, "CPUfreq debugging: set to 0 to disable ratelimiting.");
+
+#else /* !CONFIG_CPU_FREQ_DEBUG */
+
+static inline void cpufreq_debug_enable_ratelimit(void) { return; }
+static inline void cpufreq_debug_disable_ratelimit(void) { return; }
+
+#endif /* CONFIG_CPU_FREQ_DEBUG */
+
+
 /*********************************************************************
  *            EXTERNALLY AFFECTING FREQUENCY CHANGES                 *
  *********************************************************************/
@@ -123,11 +217,14 @@
 	if (!l_p_j_ref_freq) {
 		l_p_j_ref = loops_per_jiffy;
 		l_p_j_ref_freq = ci->old;
+		dprintk("saving %lu as reference value for loops_per_jiffy; freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq);
 	}
 	if ((val == CPUFREQ_PRECHANGE  && ci->old < ci->new) ||
 	    (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) ||
-	    (val == CPUFREQ_RESUMECHANGE))
+	    (val == CPUFREQ_RESUMECHANGE)) {
 		loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, ci->new);
+		dprintk("scaling loops_per_jiffy to %lu for frequency %u kHz\n", loops_per_jiffy, ci->new);
+	}
 }
 #else
 static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) { return; }
@@ -145,6 +242,7 @@
 	BUG_ON(irqs_disabled());
 
 	freqs->flags = cpufreq_driver->flags;
+	dprintk("notification %u of frequency transition to %u kHz\n", state, freqs->new);
 
 	down_read(&cpufreq_notifier_rwsem);
 	switch (state) {
@@ -154,6 +252,7 @@
 		 */
 		if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) {
 			if ((likely(cpufreq_cpu_data[freqs->cpu])) &&
+			    (likely(cpufreq_cpu_data[freqs->cpu]->cpu == freqs->cpu)) &&
 			    (likely(cpufreq_cpu_data[freqs->cpu]->cur)) &&
 			    (unlikely(freqs->old != cpufreq_cpu_data[freqs->cpu]->cur)))
 			{
@@ -168,7 +267,8 @@
 	case CPUFREQ_POSTCHANGE:
 		adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
 		notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs);
-		if (likely(cpufreq_cpu_data[freqs->cpu]))
+		if ((likely(cpufreq_cpu_data[freqs->cpu])) && 
+		    (likely(cpufreq_cpu_data[freqs->cpu]->cpu == freqs->cpu)))
 			cpufreq_cpu_data[freqs->cpu]->cur = freqs->new;
 		break;
 	}
@@ -353,26 +453,37 @@
 	i += sprintf(&buf[i], "\n");
 	return i;
 }
+/**
+ * show_affected_cpus - show the CPUs affected by each transition
+ */
+static ssize_t show_affected_cpus (struct cpufreq_policy * policy, char *buf)
+{
+	ssize_t i = 0;
+	unsigned int cpu;
+
+	for_each_cpu_mask(cpu, policy->cpus) {
+		if (i)
+			i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " ");
+		i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u", cpu);
+		if (i >= (PAGE_SIZE - 5))
+		    break;
+	}
+	i += sprintf(&buf[i], "\n");
+	return i;
+}
 
 
 #define define_one_ro(_name) \
-struct freq_attr _name = { \
-	.attr = { .name = __stringify(_name), .mode = 0444 }, \
-	.show = show_##_name, \
-}
+static struct freq_attr _name = \
+__ATTR(_name, 0444, show_##_name, NULL)
 
 #define define_one_ro0400(_name) \
-struct freq_attr _name = { \
-	.attr = { .name = __stringify(_name), .mode = 0400 }, \
-	.show = show_##_name, \
-}
+static struct freq_attr _name = \
+__ATTR(_name, 0400, show_##_name, NULL)
 
 #define define_one_rw(_name) \
-struct freq_attr _name = { \
-	.attr = { .name = __stringify(_name), .mode = 0644 }, \
-	.show = show_##_name, \
-	.store = store_##_name, \
-}
+static struct freq_attr _name = \
+__ATTR(_name, 0644, show_##_name, store_##_name)
 
 define_one_ro0400(cpuinfo_cur_freq);
 define_one_ro(cpuinfo_min_freq);
@@ -380,6 +491,7 @@
 define_one_ro(scaling_available_governors);
 define_one_ro(scaling_driver);
 define_one_ro(scaling_cur_freq);
+define_one_ro(affected_cpus);
 define_one_rw(scaling_min_freq);
 define_one_rw(scaling_max_freq);
 define_one_rw(scaling_governor);
@@ -389,6 +501,7 @@
 	&cpuinfo_max_freq.attr,
 	&scaling_min_freq.attr,
 	&scaling_max_freq.attr,
+	&affected_cpus.attr,
 	&scaling_governor.attr,
 	&scaling_driver.attr,
 	&scaling_available_governors.attr,
@@ -428,6 +541,7 @@
 static void cpufreq_sysfs_release(struct kobject * kobj)
 {
 	struct cpufreq_policy * policy = to_policy(kobj);
+	dprintk("last reference is dropped\n");
 	complete(&policy->kobj_unregister);
 }
 
@@ -456,9 +570,28 @@
 	struct cpufreq_policy *policy;
 	struct freq_attr **drv_attr;
 	unsigned long flags;
+	unsigned int j;
 
-	if (!try_module_get(cpufreq_driver->owner))
-		return -EINVAL;
+	cpufreq_debug_disable_ratelimit();
+	dprintk("adding CPU %u\n", cpu);
+
+#ifdef CONFIG_SMP
+	/* check whether a different CPU already registered this
+	 * CPU because it is in the same boat. */
+	policy = cpufreq_cpu_get(cpu);
+	if (unlikely(policy)) {
+		cpu_sys_devices[cpu] = sys_dev;
+		dprintk("CPU already managed, adding link\n");
+		sysfs_create_link(&sys_dev->kobj, &policy->kobj, "cpufreq");
+		cpufreq_debug_enable_ratelimit();
+		return 0;
+	}
+#endif
+
+	if (!try_module_get(cpufreq_driver->owner)) {
+		ret = -EINVAL;
+		goto module_out;
+	}
 
 	policy = kmalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
 	if (!policy) {
@@ -468,6 +601,8 @@
 	memset(policy, 0, sizeof(struct cpufreq_policy));
 
 	policy->cpu = cpu;
+	policy->cpus = cpumask_of_cpu(cpu);
+
 	init_MUTEX_LOCKED(&policy->lock);
 	init_completion(&policy->kobj_unregister);
 	INIT_WORK(&policy->update, handle_update, (void *)(long)cpu);
@@ -476,8 +611,10 @@
 	 * to accept all calls to ->verify and ->setpolicy for this CPU
 	 */
 	ret = cpufreq_driver->init(policy);
-	if (ret)
+	if (ret) {
+		dprintk("initialization failed\n");
 		goto err_out;
+	}
 
 	memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
 
@@ -502,7 +639,8 @@
 		sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
 
 	spin_lock_irqsave(&cpufreq_driver_lock, flags);
-	cpufreq_cpu_data[cpu] = policy;
+	for_each_cpu_mask(j, policy->cpus)
+		cpufreq_cpu_data[j] = policy;
 	spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
 	policy->governor = NULL; /* to assure that the starting sequence is
 				  * run in cpufreq_set_policy */
@@ -511,16 +649,23 @@
 	/* set default policy */
 	
 	ret = cpufreq_set_policy(&new_policy);
-	if (ret)
+	if (ret) {
+		dprintk("setting policy failed\n");
 		goto err_out_unregister;
+	}
 
 	module_put(cpufreq_driver->owner);
+	cpu_sys_devices[cpu] = sys_dev;
+	dprintk("initialization complete\n");
+	cpufreq_debug_enable_ratelimit();
+	
 	return 0;
 
 
 err_out_unregister:
 	spin_lock_irqsave(&cpufreq_driver_lock, flags);
-	cpufreq_cpu_data[cpu] = NULL;
+	for_each_cpu_mask(j, policy->cpus)
+		cpufreq_cpu_data[j] = NULL;
 	spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
 	kobject_unregister(&policy->kobj);
@@ -531,6 +676,8 @@
 
 nomem_out:
 	module_put(cpufreq_driver->owner);
+ module_out:
+	cpufreq_debug_enable_ratelimit();
 	return ret;
 }
 
@@ -545,19 +692,76 @@
 	unsigned int cpu = sys_dev->id;
 	unsigned long flags;
 	struct cpufreq_policy *data;
+#ifdef CONFIG_SMP
+	unsigned int j;
+#endif
+
+	cpufreq_debug_disable_ratelimit();
+	dprintk("unregistering CPU %u\n", cpu);
 
 	spin_lock_irqsave(&cpufreq_driver_lock, flags);
 	data = cpufreq_cpu_data[cpu];
 
 	if (!data) {
 		spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+		cpu_sys_devices[cpu] = NULL;
+		cpufreq_debug_enable_ratelimit();
 		return -EINVAL;
 	}
 	cpufreq_cpu_data[cpu] = NULL;
+
+
+#ifdef CONFIG_SMP
+	/* if this isn't the CPU which is the parent of the kobj, we
+	 * only need to unlink, put and exit 
+	 */
+	if (unlikely(cpu != data->cpu)) {
+		dprintk("removing link\n");
+		spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+		sysfs_remove_link(&sys_dev->kobj, "cpufreq");
+		cpu_sys_devices[cpu] = NULL;
+		cpufreq_cpu_put(data);
+		cpufreq_debug_enable_ratelimit();
+		return 0;
+	}
+#endif
+
+	cpu_sys_devices[cpu] = NULL;
+
+	if (!kobject_get(&data->kobj)) {
+		spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+		cpufreq_debug_enable_ratelimit();
+ 		return -EFAULT;
+	}
+
+#ifdef CONFIG_SMP
+	/* if we have other CPUs still registered, we need to unlink them,
+	 * or else wait_for_completion below will lock up. Clean the
+	 * cpufreq_cpu_data[] while holding the lock, and remove the sysfs
+	 * links afterwards.
+	 */
+	if (unlikely(cpus_weight(data->cpus) > 1)) {
+		for_each_cpu_mask(j, data->cpus) {
+			if (j == cpu)
+				continue;
+			cpufreq_cpu_data[j] = NULL;
+		}
+	}
+
 	spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
-	if (!kobject_get(&data->kobj))
-		return -EFAULT;
+	if (unlikely(cpus_weight(data->cpus) > 1)) {
+		for_each_cpu_mask(j, data->cpus) {
+			if (j == cpu)
+				continue;
+			dprintk("removing link for cpu %u\n", j);
+			sysfs_remove_link(&cpu_sys_devices[j]->kobj, "cpufreq");
+			cpufreq_cpu_put(data);
+		}
+	}
+#else
+	spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+#endif
 
 	if (cpufreq_driver->target)
 		__cpufreq_governor(data, CPUFREQ_GOV_STOP);
@@ -570,13 +774,17 @@
 	 * not referenced anymore by anybody before we proceed with 
 	 * unloading.
 	 */
+	dprintk("waiting for dropping of refcount\n");
 	wait_for_completion(&data->kobj_unregister);
+	dprintk("wait complete\n");
 
 	if (cpufreq_driver->exit)
 		cpufreq_driver->exit(data);
 
 	kfree(data);
 
+	cpufreq_debug_enable_ratelimit();
+
 	return 0;
 }
 
@@ -584,6 +792,7 @@
 static void handle_update(void *data)
 {
 	unsigned int cpu = (unsigned int)(long)data;
+	dprintk("handle_update for cpu %u called\n", cpu);
 	cpufreq_update_policy(cpu);
 }
 
@@ -664,6 +873,8 @@
 	unsigned int ret = 0;
 	struct cpufreq_policy *cpu_policy;
 
+	dprintk("resuming cpu %u\n", cpu);
+
 	if (!cpu_online(cpu))
 		return 0;
 
@@ -676,6 +887,12 @@
 	if (!cpu_policy)
 		return -EINVAL;
 
+	/* only handle each CPU group once */
+	if (unlikely(cpu_policy->cpu != cpu)) {
+		cpufreq_cpu_put(cpu_policy);
+		return 0;
+	}
+
 	if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) {
 		unsigned int cur_freq = 0;
 
@@ -799,6 +1016,8 @@
 {
 	int retval = -EINVAL;
 	lock_cpu_hotplug();
+	dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
+		target_freq, relation);
 	if (cpu_online(policy->cpu))
 		retval = cpufreq_driver->target(policy, target_freq, relation);
 	unlock_cpu_hotplug();
@@ -837,6 +1056,7 @@
 	if (!try_module_get(policy->governor->owner))
 		return -EINVAL;
 
+	dprintk("__cpufreq_governor for CPU %u, event %u\n", policy->cpu, event);
 	ret = policy->governor->governor(policy, event);
 
 	/* we keep one module reference alive for each CPU governed by this CPU */
@@ -941,6 +1161,10 @@
 {
 	int ret = 0;
 
+	cpufreq_debug_disable_ratelimit();
+	dprintk("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu,
+		policy->min, policy->max);
+
 	memcpy(&policy->cpuinfo, 
 	       &data->cpuinfo, 
 	       sizeof(struct cpufreq_cpuinfo));
@@ -977,14 +1201,19 @@
 	data->min    = policy->min;
 	data->max    = policy->max;
 
+	dprintk("new min and max freqs are %u - %u kHz\n", data->min, data->max);
+
 	if (cpufreq_driver->setpolicy) {
 		data->policy = policy->policy;
+		dprintk("setting range\n");
 		ret = cpufreq_driver->setpolicy(policy);
 	} else {
 		if (policy->governor != data->governor) {
 			/* save old, working values */
 			struct cpufreq_governor *old_gov = data->governor;
 
+			dprintk("governor switch\n");
+
 			/* end old governor */
 			if (data->governor)
 				__cpufreq_governor(data, CPUFREQ_GOV_STOP);
@@ -993,6 +1222,7 @@
 			data->governor = policy->governor;
 			if (__cpufreq_governor(data, CPUFREQ_GOV_START)) {
 				/* new governor failed, so re-start old one */
+				dprintk("starting governor %s failed\n", data->governor->name);
 				if (old_gov) {
 					data->governor = old_gov;
 					__cpufreq_governor(data, CPUFREQ_GOV_START);
@@ -1002,10 +1232,12 @@
 			}
 			/* might be a policy change, too, so fall through */
 		}
+		dprintk("governor: change or update limits\n");
 		__cpufreq_governor(data, CPUFREQ_GOV_LIMITS);
 	}
 
  error_out:
+	cpufreq_debug_enable_ratelimit();
 	return ret;
 }
 
@@ -1062,6 +1294,7 @@
 
 	down(&data->lock);
 
+	dprintk("updating policy for CPU %u\n", cpu);
 	memcpy(&policy, 
 	       data,
 	       sizeof(struct cpufreq_policy));
@@ -1103,6 +1336,8 @@
 	    ((!driver_data->setpolicy) && (!driver_data->target)))
 		return -EINVAL;
 
+	dprintk("trying to register driver %s\n", driver_data->name);
+
 	if (driver_data->setpolicy)
 		driver_data->flags |= CPUFREQ_CONST_LOOPS;
 
@@ -1127,6 +1362,7 @@
 
 		/* if all ->init() calls failed, unregister */
 		if (ret) {
+			dprintk("no CPU initialized for driver %s\n", driver_data->name);
 			sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver);
 
 			spin_lock_irqsave(&cpufreq_driver_lock, flags);
@@ -1135,6 +1371,11 @@
 		}
 	}
 
+	if (!ret) {
+		dprintk("driver %s up and running\n", driver_data->name);
+		cpufreq_debug_enable_ratelimit();
+	}
+
 	return (ret);
 }
 EXPORT_SYMBOL_GPL(cpufreq_register_driver);
@@ -1152,8 +1393,14 @@
 {
 	unsigned long flags;
 
-	if (!cpufreq_driver || (driver != cpufreq_driver))
+	cpufreq_debug_disable_ratelimit();
+
+	if (!cpufreq_driver || (driver != cpufreq_driver)) {
+		cpufreq_debug_enable_ratelimit();
 		return -EINVAL;
+	}
+
+	dprintk("unregistering driver %s\n", driver->name);
 
 	sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver);
 
diff -Nru a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
--- a/drivers/cpufreq/cpufreq_ondemand.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/cpufreq/cpufreq_ondemand.c	2004-12-24 13:37:29 -08:00
@@ -10,7 +10,6 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/smp.h>
@@ -26,7 +25,6 @@
 #include <linux/kmod.h>
 #include <linux/workqueue.h>
 #include <linux/jiffies.h>
-#include <linux/config.h>
 #include <linux/kernel_stat.h>
 #include <linux/percpu.h>
 
@@ -83,7 +81,7 @@
 	unsigned int		down_threshold;
 };
 
-struct dbs_tuners dbs_tuners_ins = {
+static struct dbs_tuners dbs_tuners_ins = {
 	.up_threshold 		= DEF_FREQUENCY_UP_THRESHOLD,
 	.down_threshold 	= DEF_FREQUENCY_DOWN_THRESHOLD,
 	.sampling_down_factor 	= DEF_SAMPLING_DOWN_FACTOR,
@@ -101,10 +99,8 @@
 }
 
 #define define_one_ro(_name) 					\
-static struct freq_attr _name = { 				\
-	.attr = { .name = __stringify(_name), .mode = 0444 }, 	\
-	.show = show_##_name, 					\
-}
+static struct freq_attr _name =  				\
+__ATTR(_name, 0444, show_##_name, NULL)
 
 define_one_ro(sampling_rate_max);
 define_one_ro(sampling_rate_min);
@@ -127,13 +123,13 @@
 	unsigned int input;
 	int ret;
 	ret = sscanf (buf, "%u", &input);
-	down(&dbs_sem);
 	if (ret != 1 )
-		goto out;
+		return -EINVAL;
 
+	down(&dbs_sem);
 	dbs_tuners_ins.sampling_down_factor = input;
-out:
 	up(&dbs_sem);
+
 	return count;
 }
 
@@ -143,13 +139,16 @@
 	unsigned int input;
 	int ret;
 	ret = sscanf (buf, "%u", &input);
+
 	down(&dbs_sem);
-	if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE)
-		goto out;
+	if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) {
+		up(&dbs_sem);
+		return -EINVAL;
+	}
 
 	dbs_tuners_ins.sampling_rate = input;
-out:
 	up(&dbs_sem);
+
 	return count;
 }
 
@@ -159,15 +158,18 @@
 	unsigned int input;
 	int ret;
 	ret = sscanf (buf, "%u", &input);
+
 	down(&dbs_sem);
 	if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || 
 			input < MIN_FREQUENCY_UP_THRESHOLD ||
-			input <= dbs_tuners_ins.down_threshold)
-		goto out;
+			input <= dbs_tuners_ins.down_threshold) {
+		up(&dbs_sem);
+		return -EINVAL;
+	}
 
 	dbs_tuners_ins.up_threshold = input;
-out:
 	up(&dbs_sem);
+
 	return count;
 }
 
@@ -177,24 +179,24 @@
 	unsigned int input;
 	int ret;
 	ret = sscanf (buf, "%u", &input);
+
 	down(&dbs_sem);
 	if (ret != 1 || input > MAX_FREQUENCY_DOWN_THRESHOLD || 
 			input < MIN_FREQUENCY_DOWN_THRESHOLD ||
-			input >= dbs_tuners_ins.up_threshold)
-		goto out;
+			input >= dbs_tuners_ins.up_threshold) {
+		up(&dbs_sem);
+		return -EINVAL;
+	}
 
 	dbs_tuners_ins.down_threshold = input;
-out:
 	up(&dbs_sem);
+
 	return count;
 }
 
-#define define_one_rw(_name) 					\
-static struct freq_attr _name = { 				\
-	.attr = { .name = __stringify(_name), .mode = 0644 }, 	\
-	.show = show_##_name, 					\
-	.store = store_##_name, 				\
-}
+#define define_one_rw(_name) \
+static struct freq_attr _name = \
+__ATTR(_name, 0644, show_##_name, store_##_name)
 
 define_one_rw(sampling_rate);
 define_one_rw(sampling_down_factor);
diff -Nru a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c
--- a/drivers/cpufreq/cpufreq_performance.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/cpufreq/cpufreq_performance.c	2004-12-24 13:37:18 -08:00
@@ -15,12 +15,16 @@
 #include <linux/cpufreq.h>
 #include <linux/init.h>
 
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "performance", msg)
+
+
 static int cpufreq_governor_performance(struct cpufreq_policy *policy,
 					unsigned int event)
 {
 	switch (event) {
 	case CPUFREQ_GOV_START:
 	case CPUFREQ_GOV_LIMITS:
+		dprintk("setting to %u kHz because of event %u\n", policy->max, event);
 		__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
 		break;
 	default:
diff -Nru a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c
--- a/drivers/cpufreq/cpufreq_powersave.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/cpufreq/cpufreq_powersave.c	2004-12-24 13:36:17 -08:00
@@ -15,12 +15,15 @@
 #include <linux/cpufreq.h>
 #include <linux/init.h>
 
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "powersave", msg)
+
 static int cpufreq_governor_powersave(struct cpufreq_policy *policy,
 					unsigned int event)
 {
 	switch (event) {
 	case CPUFREQ_GOV_START:
 	case CPUFREQ_GOV_LIMITS:
+		dprintk("setting to %u kHz because of event %u\n", policy->min, event);
 		__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
 		break;
 	default:
diff -Nru a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c
--- a/drivers/cpufreq/cpufreq_userspace.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/cpufreq/cpufreq_userspace.c	2004-12-24 13:36:18 -08:00
@@ -68,12 +68,14 @@
  */
 static unsigned int	cpu_max_freq[NR_CPUS];
 static unsigned int	cpu_min_freq[NR_CPUS];
-static unsigned int	cpu_cur_freq[NR_CPUS];
+static unsigned int	cpu_cur_freq[NR_CPUS]; /* current CPU freq */
+static unsigned int	cpu_set_freq[NR_CPUS]; /* CPU freq desired by userspace */
 static unsigned int	cpu_is_managed[NR_CPUS];
 static struct cpufreq_policy current_policy[NR_CPUS];
 
 static DECLARE_MUTEX	(userspace_sem); 
 
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg)
 
 /* keep track of frequency transitions */
 static int 
@@ -82,13 +84,7 @@
 {
         struct cpufreq_freqs *freq = data;
 
-	/* Don't update cur_freq if CPU is managed and we're
-	 * waking up: else we won't remember what frequency 
-	 * we need to set the CPU to.
-	 */
-	if (cpu_is_managed[freq->cpu] && (val == CPUFREQ_RESUMECHANGE))
-		return 0;
-
+	dprintk("saving cpu_cur_freq of cpu %u to be %u kHz\n", freq->cpu, freq->new);
 	cpu_cur_freq[freq->cpu] = freq->new;
 
         return 0;
@@ -100,20 +96,24 @@
 
 
 /** 
- * cpufreq_set - set the CPU frequency
+ * _cpufreq_set - set the CPU frequency
  * @freq: target frequency in kHz
  * @cpu: CPU for which the frequency is to be set
  *
  * Sets the CPU frequency to freq.
  */
-int cpufreq_set(unsigned int freq, unsigned int cpu)
+static int _cpufreq_set(unsigned int freq, unsigned int cpu)
 {
 	int ret = -EINVAL;
 
+	dprintk("_cpufreq_set for cpu %u, freq %u kHz\n", cpu, freq);
+
 	down(&userspace_sem);
 	if (!cpu_is_managed[cpu])
 		goto err;
 
+	cpu_set_freq[cpu] = freq;
+
 	if (freq < cpu_min_freq[cpu])
 		freq = cpu_min_freq[cpu];
 	if (freq > cpu_max_freq[cpu])
@@ -133,6 +133,18 @@
 	up(&userspace_sem);
 	return ret;
 }
+
+
+#ifdef CONFIG_CPU_FREQ_24_API
+
+#warning The /proc/sys/cpu/ and sysctl interface to cpufreq will be removed from the 2.6. kernel series soon after 2005-01-01
+
+static unsigned int warning_print = 0;
+
+int __deprecated cpufreq_set(unsigned int freq, unsigned int cpu)
+{
+	return _cpufreq_set(freq, cpu);
+}
 EXPORT_SYMBOL_GPL(cpufreq_set);
 
 
@@ -143,21 +155,14 @@
  * Sets the CPU frequency to the maximum frequency supported by
  * this CPU.
  */
-int cpufreq_setmax(unsigned int cpu)
+int __deprecated cpufreq_setmax(unsigned int cpu)
 {
 	if (!cpu_is_managed[cpu] || !cpu_online(cpu))
 		return -EINVAL;
-	return cpufreq_set(cpu_max_freq[cpu], cpu);
+	return _cpufreq_set(cpu_max_freq[cpu], cpu);
 }
 EXPORT_SYMBOL_GPL(cpufreq_setmax);
 
-
-#ifdef CONFIG_CPU_FREQ_24_API
-
-#warning The /proc/sys/cpu/ and sysctl interface to cpufreq will be removed from the 2.6. kernel series soon after 2005-01-01
-
-static unsigned int warning_print = 0;
-
 /*********************** cpufreq_sysctl interface ********************/
 static int
 cpufreq_procctl(ctl_table *ctl, int write, struct file *filp,
@@ -190,7 +195,7 @@
 		buf[sizeof(buf) - 1] = '\0';
 
 		freq = simple_strtoul(buf, &p, 0);
-		cpufreq_set(freq, cpu);
+		_cpufreq_set(freq, cpu);
 	} else {
 		len = sprintf(buf, "%d\n", cpufreq_get(cpu));
 		if (len > left)
@@ -243,7 +248,7 @@
 		if (get_user(freq, (unsigned int __user *)newval))
 			return -EFAULT;
 
-		cpufreq_set(freq, cpu);
+		_cpufreq_set(freq, cpu);
 	}
 	return 1;
 }
@@ -464,7 +469,7 @@
 	}
 };
 
-struct ctl_table_header *cpufreq_sysctl_table;
+static struct ctl_table_header *cpufreq_sysctl_table;
 
 static inline void cpufreq_sysctl_init(void)
 {
@@ -498,13 +503,14 @@
 	if (ret != 1)
 		return -EINVAL;
 
-	cpufreq_set(freq, policy->cpu);
+	_cpufreq_set(freq, policy->cpu);
 
 	return count;
 }
 
-static struct freq_attr freq_attr_scaling_setspeed = {
-	.attr = { .name = "scaling_setspeed", .mode = 0644 },
+static struct freq_attr freq_attr_scaling_setspeed = 
+{
+	.attr = { .name = "scaling_setspeed", .mode = 0644, .owner = THIS_MODULE },
 	.show = show_speed,
 	.store = store_speed,
 };
@@ -515,7 +521,7 @@
 	unsigned int cpu = policy->cpu;
 	switch (event) {
 	case CPUFREQ_GOV_START:
-		if ((!cpu_online(cpu)) || (!try_module_get(THIS_MODULE)))
+		if (!cpu_online(cpu))
 			return -EINVAL;
 		BUG_ON(!policy->cur);
 		down(&userspace_sem);
@@ -523,8 +529,10 @@
 		cpu_min_freq[cpu] = policy->min;
 		cpu_max_freq[cpu] = policy->max;
 		cpu_cur_freq[cpu] = policy->cur;
+		cpu_set_freq[cpu] = policy->cur;
 		sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
 		memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy));
+		dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]);
 		up(&userspace_sem);
 		break;
 	case CPUFREQ_GOV_STOP:
@@ -532,23 +540,26 @@
 		cpu_is_managed[cpu] = 0;
 		cpu_min_freq[cpu] = 0;
 		cpu_max_freq[cpu] = 0;
+		cpu_set_freq[cpu] = 0;
 		sysfs_remove_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
+		dprintk("managing cpu %u stopped\n", cpu);
 		up(&userspace_sem);
-		module_put(THIS_MODULE);
 		break;
 	case CPUFREQ_GOV_LIMITS:
 		down(&userspace_sem);
 		cpu_min_freq[cpu] = policy->min;
 		cpu_max_freq[cpu] = policy->max;
-		if (policy->max < cpu_cur_freq[cpu])
+		dprintk("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu], cpu_set_freq[cpu]);
+		if (policy->max < cpu_set_freq[cpu]) {
 			__cpufreq_driver_target(&current_policy[cpu], policy->max, 
 			      CPUFREQ_RELATION_H);
-		else if (policy->min > cpu_cur_freq[cpu])
+		} else if (policy->min > cpu_set_freq[cpu]) {
 			__cpufreq_driver_target(&current_policy[cpu], policy->min, 
 			      CPUFREQ_RELATION_L);
-		else
-			__cpufreq_driver_target(&current_policy[cpu], cpu_cur_freq[cpu],
+		} else {
+			__cpufreq_driver_target(&current_policy[cpu], cpu_set_freq[cpu],
 			      CPUFREQ_RELATION_L);
+		}
 		memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy));
 		up(&userspace_sem);
 		break;
diff -Nru a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
--- a/drivers/cpufreq/freq_table.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/cpufreq/freq_table.c	2004-12-24 13:37:19 -08:00
@@ -9,6 +9,8 @@
 #include <linux/init.h>
 #include <linux/cpufreq.h>
 
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "freq-table", msg)
+
 /*********************************************************************
  *                     FREQUENCY TABLE HELPERS                       *
  *********************************************************************/
@@ -22,8 +24,12 @@
 
 	for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
 		unsigned int freq = table[i].frequency;
-		if (freq == CPUFREQ_ENTRY_INVALID)
+		if (freq == CPUFREQ_ENTRY_INVALID) {
+			dprintk("table entry %u is invalid, skipping\n", i);
+
 			continue;
+		}
+		dprintk("table entry %u: %u kHz, %u index\n", i, freq, table[i].index);
 		if (freq < min_freq)
 			min_freq = freq;
 		if (freq > max_freq)
@@ -48,6 +54,8 @@
 	unsigned int i = 0;
 	unsigned int count = 0;
 
+	dprintk("request for verification of policy (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu);
+
 	if (!cpu_online(policy->cpu))
 		return -EINVAL;
 
@@ -72,6 +80,8 @@
 				     policy->cpuinfo.min_freq, 
 				     policy->cpuinfo.max_freq);
 
+	dprintk("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify);
@@ -87,6 +97,8 @@
 	struct cpufreq_frequency_table suboptimal = { .index = ~0, };
 	unsigned int i;
 
+	dprintk("request for target %u kHz (relation: %u) for cpu %u\n", target_freq, relation, policy->cpu);
+
 	switch (relation) {
 	case CPUFREQ_RELATION_H:
 		optimal.frequency = 0;
@@ -142,7 +154,10 @@
 		*index = suboptimal.index;
 	} else
 		*index = optimal.index;
-	
+
+	dprintk("target is %u (%u kHz, %u)\n", *index, table[*index].frequency,
+		table[*index].index);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);
@@ -175,7 +190,7 @@
 }
 
 struct freq_attr cpufreq_freq_attr_scaling_available_freqs = {
-	.attr = { .name = "scaling_available_frequencies", .mode = 0444 },
+	.attr = { .name = "scaling_available_frequencies", .mode = 0444, .owner=THIS_MODULE },
 	.show = show_available_freqs,
 };
 EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs);
@@ -187,12 +202,14 @@
 void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, 
 				      unsigned int cpu)
 {
+	dprintk("setting show_table for cpu %u to %p\n", cpu, table);
 	show_table[cpu] = table;
 }
 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr);
 
 void cpufreq_frequency_table_put_attr(unsigned int cpu)
 {
+	dprintk("clearing show_table for cpu %u\n", cpu);
 	show_table[cpu] = NULL;
 }
 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);
diff -Nru a/drivers/dio/Makefile b/drivers/dio/Makefile
--- a/drivers/dio/Makefile	2004-12-24 13:36:31 -08:00
+++ b/drivers/dio/Makefile	2004-12-24 13:36:31 -08:00
@@ -2,4 +2,4 @@
 # Makefile for the linux kernel.
 #
 
-obj-y := dio.o
+obj-y := dio.o dio-driver.o dio-sysfs.o
diff -Nru a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/dio/dio-driver.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,163 @@
+/*
+ *  DIO Driver Services
+ *
+ *  Copyright (C) 2004 Jochen Friedrich
+ *
+ *  Loosely based on drivers/pci/pci-driver.c and drivers/zorro/zorro-driver.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.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/dio.h>
+
+
+	/**
+	 *  dio_match_device - Tell if a DIO device structure has a matching
+	 *                     DIO device id structure
+	 *  @ids: array of DIO device id structures to search in
+	 *  @dev: the DIO device structure to match against
+	 *
+	 *  Used by a driver to check whether a DIO device present in the
+	 *  system is in its list of supported devices. Returns the matching
+	 *  dio_device_id structure or %NULL if there is no match.
+	 */
+
+const struct dio_device_id *
+dio_match_device(const struct dio_device_id *ids,
+		   const struct dio_dev *d)
+{
+	while (ids->id) {
+		if (ids->id == DIO_WILDCARD)
+			return ids;
+		if (DIO_NEEDSSECID(ids->id & 0xff)) {
+			if (ids->id == d->id)
+				return ids;
+		} else {
+			if ((ids->id & 0xff) == (d->id & 0xff))
+				return ids;
+		}
+		ids++;
+	}
+	return NULL;
+}
+
+static int dio_device_probe(struct device *dev)
+{
+	int error = 0;
+	struct dio_driver *drv = to_dio_driver(dev->driver);
+	struct dio_dev *d = to_dio_dev(dev);
+
+	if (!d->driver && drv->probe) {
+		const struct dio_device_id *id;
+
+		id = dio_match_device(drv->id_table, d);
+		if (id)
+			error = drv->probe(d, id);
+		if (error >= 0) {
+			d->driver = drv;
+			error = 0;
+		}
+	}
+	return error;
+}
+
+
+	/**
+	 *  dio_register_driver - register a new DIO driver
+	 *  @drv: the driver structure to register
+	 *
+	 *  Adds the driver structure to the list of registered drivers
+	 *  Returns the number of DIO devices which were claimed by the driver
+	 *  during registration.  The driver remains registered even if the
+	 *  return value is zero.
+	 */
+
+int dio_register_driver(struct dio_driver *drv)
+{
+	int count = 0;
+
+	/* initialize common driver fields */
+	drv->driver.name = drv->name;
+	drv->driver.bus = &dio_bus_type;
+	drv->driver.probe = dio_device_probe;
+
+	/* register with core */
+	count = driver_register(&drv->driver);
+	return count ? count : 1;
+}
+
+
+	/**
+	 *  dio_unregister_driver - unregister a DIO driver
+	 *  @drv: the driver structure to unregister
+	 *
+	 *  Deletes the driver structure from the list of registered DIO drivers,
+	 *  gives it a chance to clean up by calling its remove() function for
+	 *  each device it was responsible for, and marks those devices as
+	 *  driverless.
+	 */
+
+void dio_unregister_driver(struct dio_driver *drv)
+{
+	driver_unregister(&drv->driver);
+}
+
+
+	/**
+	 *  dio_bus_match - Tell if a DIO device structure has a matching DIO
+	 *                  device id structure
+	 *  @ids: array of DIO device id structures to search in
+	 *  @dev: the DIO device structure to match against
+	 *
+	 *  Used by a driver to check whether a DIO device present in the
+	 *  system is in its list of supported devices. Returns the matching
+	 *  dio_device_id structure or %NULL if there is no match.
+	 */
+
+static int dio_bus_match(struct device *dev, struct device_driver *drv)
+{
+	struct dio_dev *d = to_dio_dev(dev);
+	struct dio_driver *dio_drv = to_dio_driver(drv);
+	const struct dio_device_id *ids = dio_drv->id_table;
+
+	if (!ids)
+		return 0;
+
+	while (ids->id) {
+		if (ids->id == DIO_WILDCARD)
+			return 1;
+		if (DIO_NEEDSSECID(ids->id & 0xff)) {
+			if (ids->id == d->id)
+				return 1;
+		} else {
+			if ((ids->id & 0xff) == (d->id & 0xff))
+				return 1;
+		}
+		ids++;
+	}
+	return 0;
+}
+
+
+struct bus_type dio_bus_type = {
+	.name	= "dio",
+	.match	= dio_bus_match
+};
+
+
+static int __init dio_driver_init(void)
+{
+	return bus_register(&dio_bus_type);
+}
+
+postcore_initcall(dio_driver_init);
+
+EXPORT_SYMBOL(dio_match_device);
+EXPORT_SYMBOL(dio_register_driver);
+EXPORT_SYMBOL(dio_unregister_driver);
+EXPORT_SYMBOL(dio_dev_driver);
+EXPORT_SYMBOL(dio_bus_type);
diff -Nru a/drivers/dio/dio-sysfs.c b/drivers/dio/dio-sysfs.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/dio/dio-sysfs.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,77 @@
+/*
+ *  File Attributes for DIO Devices
+ *
+ *  Copyright (C) 2004 Jochen Friedrich
+ *
+ *  Loosely based on drivers/pci/pci-sysfs.c and drivers/zorro/zorro-sysfs.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.
+ */
+
+
+#include <linux/kernel.h>
+#include <linux/dio.h>
+#include <linux/stat.h>
+
+/* show configuration fields */
+
+static ssize_t dio_show_id(struct device *dev, char *buf)
+{
+	struct dio_dev *d;
+
+	d = to_dio_dev(dev);
+	return sprintf(buf, "0x%02x\n", (d->id & 0xff));
+}
+static DEVICE_ATTR(id, S_IRUGO, dio_show_id, NULL);
+
+static ssize_t dio_show_ipl(struct device *dev, char *buf)
+{
+	struct dio_dev *d;
+
+	d = to_dio_dev(dev);
+	return sprintf(buf, "0x%02x\n", d->ipl);
+}
+static DEVICE_ATTR(ipl, S_IRUGO, dio_show_ipl, NULL);
+
+static ssize_t dio_show_secid(struct device *dev, char *buf)
+{
+	struct dio_dev *d;
+
+	d = to_dio_dev(dev);
+	return sprintf(buf, "0x%02x\n", ((d->id >> 8)& 0xff));
+}
+static DEVICE_ATTR(secid, S_IRUGO, dio_show_secid, NULL);
+
+static ssize_t dio_show_name(struct device *dev, char *buf)
+{
+	struct dio_dev *d;
+
+	d = to_dio_dev(dev);
+	return sprintf(buf, "%s\n", d->name);
+}
+static DEVICE_ATTR(name, S_IRUGO, dio_show_name, NULL);
+
+static ssize_t dio_show_resource(struct device *dev, char *buf)
+{
+	struct dio_dev *d = to_dio_dev(dev);
+
+	return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
+		       dio_resource_start(d), dio_resource_end(d),
+		       dio_resource_flags(d));
+}
+static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL);
+
+void dio_create_sysfs_dev_files(struct dio_dev *d)
+{
+	struct device *dev = &d->dev;
+
+	/* current configuration's attributes */
+	device_create_file(dev, &dev_attr_id);
+	device_create_file(dev, &dev_attr_ipl);
+	device_create_file(dev, &dev_attr_secid);
+	device_create_file(dev, &dev_attr_name);
+	device_create_file(dev, &dev_attr_resource);
+}
+
diff -Nru a/drivers/dio/dio.c b/drivers/dio/dio.c
--- a/drivers/dio/dio.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/dio/dio.c	2004-12-24 13:37:03 -08:00
@@ -1,5 +1,6 @@
-/* Code to support devices on the DIO (and eventually DIO-II) bus
+/* Code to support devices on the DIO and DIO-II bus
  * Copyright (C) 05/1998 Peter Maydell <pmaydell@chiark.greenend.org.uk>
+ * Copyright (C) 2004 Jochen Friedrich <jochen@scram.de>
  * 
  * This code has basically these routines at the moment:
  * int dio_find(u_int deviceid)
@@ -9,9 +10,8 @@
  *    This means that framebuffers should pass it as 
  *    DIO_ENCODE_ID(DIO_ID_FBUFFER,DIO_ID2_TOPCAT)
  *    (or whatever); everybody else just uses DIO_ID_FOOBAR.
- * void *dio_scodetoviraddr(int scode)
- *    Return the virtual address corresponding to the given select code.
- *    NB: DIO-II devices will have to be mapped in in this routine!
+ * unsigned long dio_scodetophysaddr(int scode)
+ *    Return the physical address corresponding to the given select code.
  * int dio_scodetoipl(int scode)
  *    Every DIO card has a fixed interrupt priority level. This function 
  *    returns it, whatever it is.
@@ -24,14 +24,26 @@
  * This file is based on the way the Amiga port handles Zorro II cards, 
  * although we aren't so complicated...
  */
-#include <linux/config.h>
-#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
 #include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
 #include <linux/dio.h>
 #include <linux/slab.h>                         /* kmalloc() */
-#include <linux/init.h>
-#include <asm/hwtest.h>                           /* hwreg_present() */
-#include <asm/io.h>                               /* readb() */
+#include <asm/uaccess.h>
+#include <asm/io.h>                             /* readb() */
+
+struct dio_bus dio_bus = {
+	.resources = {
+		/* DIO range */
+		{ .name = "DIO mem", .start = 0x00600000, .end = 0x007fffff },
+		/* DIO-II range */
+		{ .name = "DIO-II mem", .start = 0x01000000, .end = 0x1fffffff }
+	},
+	.name = "DIO bus"
+};
+
 /* not a real config option yet! */
 #define CONFIG_DIO_CONSTANTS
 
@@ -59,7 +71,7 @@
         DIONAME(DCA0), DIONAME(DCA0REM), DIONAME(DCA1), DIONAME(DCA1REM),
         DIONAME(DCM), DIONAME(DCMREM),
         DIONAME(LAN),
-        DIONAME(FHPIB), DIONAME(NHPIB), DIONAME(IHPIB),
+        DIONAME(FHPIB), DIONAME(NHPIB),
         DIONAME(SCSI0), DIONAME(SCSI1), DIONAME(SCSI2), DIONAME(SCSI3),
         DIONAME(FBUFFER),
         DIONAME(PARALLEL), DIONAME(VME), DIONAME(DCL), DIONAME(DCLREM),
@@ -79,7 +91,7 @@
 #define NUMNAMES (sizeof(names) / sizeof(struct dioname))
 
 static const char *unknowndioname 
-        = "unknown DIO board -- please email <pmaydell@chiark.greenend.org.uk>!";
+        = "unknown DIO board -- please email <linux-m68k@lists.linux-m68k.org>!";
 
 static const char *dio_getname(int id)
 {
@@ -88,7 +100,7 @@
         for (i = 0; i < NUMNAMES; i++)
                 if (names[i].id == id) 
                         return names[i].name;
-        
+
         return unknowndioname;
 }
 
@@ -99,70 +111,59 @@
 
 #endif /* CONFIG_DIO_CONSTANTS */
 
-/* We represent all the DIO boards in the system with a linked list of these structs. */
-struct dioboard
+int __init dio_find(int deviceid)
 {
-        struct dioboard *next;                    /* link to next struct in list */
-        int ipl;                                  /* IPL of this board */
-        int configured;                           /* has this board been configured? */
-        int scode;                                /* select code of this board */
-        int id;                                   /* encoded ID */
-        const char *name;
-};
-
-static struct dioboard *blist = NULL;
-
-static int __init dio_find_slow(int deviceid)
-{
-	/* Called to find a DIO device before the full bus scan has run.  Basically
-         * only used by the console driver.
-         * We don't do the primary+secondary ID encoding thing here. Maybe we should.
-         * (that would break the topcat detection, though. I need to think about
-         * the whole primary/secondary ID thing.)
-         */
-	int scode;
-        u_char prid;
+	/* Called to find a DIO device before the full bus scan has run.
+	 * Only used by the console driver.
+	 */
+	int scode, id;
+	u_char prid, secid, i;
+	mm_segment_t fs;
 
-	for (scode = 0; scode < DIO_SCMAX; scode++)
-	{
+	for (scode = 0; scode < DIO_SCMAX; scode++) {
 		void *va;
+		unsigned long pa;
 
                 if (DIO_SCINHOLE(scode))
                         continue;
-                
-                va = dio_scodetoviraddr(scode);
-                if (!va || !hwreg_present(va + DIO_IDOFF))
+
+                pa = dio_scodetophysaddr(scode);
+
+		if (!pa)
+			continue;
+
+		if (scode < DIOII_SCBASE)
+			va = (void *)(pa + DIO_VIRADDRBASE);
+		else
+			va = ioremap(pa, PAGE_SIZE);
+
+		fs = get_fs();
+		set_fs(KERNEL_DS);
+
+                if (get_user(i, (unsigned char *)va + DIO_IDOFF)) {
+			set_fs(fs);
+			if (scode >= DIOII_SCBASE)
+				iounmap(va);
                         continue;             /* no board present at that select code */
+		}
 
-                /* We aren't very likely to want to use this to get at the IHPIB,
-                 * but maybe it's returning the same ID as the card we do want...
-                 */
-                if (!DIO_ISIHPIB(scode))
-                        prid = DIO_ID(va);
-                else
-                        prid = DIO_ID_IHPIB;
+		set_fs(fs);
+		prid = DIO_ID(va);
 
-		if (prid == deviceid)
+                if (DIO_NEEDSSECID(prid)) {
+                        secid = DIO_SECID(va);
+                        id = DIO_ENCODE_ID(prid, secid);
+                } else
+			id = prid;
+
+		if (id == deviceid) {
+			if (scode >= DIOII_SCBASE)
+				iounmap(va);
 			return scode;
+		}
 	}
-	return 0;
-}
 
-/* Aargh: we use 0 for an error return code, but select code 0 exists!
- * FIXME (trivial, use -1, but requires changes to all the drivers :-< )
- */
-int dio_find(int deviceid)
-{
-	if (blist) 
-	{
-		/* fast way */
-		struct dioboard *b;
-		for (b = blist; b; b = b->next)
-			if (b->id == deviceid && b->configured == 0)
-				return b->scode;
-		return 0;
-	}
-	return dio_find_slow(deviceid);
+	return -1;
 }
 
 /* This is the function that scans the DIO space and works out what
@@ -170,58 +171,92 @@
  */
 static int __init dio_init(void)
 {
-        int scode;
-        struct dioboard *b, *bprev = NULL;
-   
-        printk("Scanning for DIO devices...\n");
-        
+	int scode;
+	mm_segment_t fs;
+	int i;
+	struct dio_dev *dev;
+
+	if (!MACH_IS_HP300)
+		return 0;
+
+        printk(KERN_INFO "Scanning for DIO devices...\n");
+
+	/* Initialize the DIO bus */ 
+	INIT_LIST_HEAD(&dio_bus.devices);
+	strcpy(dio_bus.dev.bus_id, "dio");
+	device_register(&dio_bus.dev);
+
+	/* Request all resources */
+	dio_bus.num_resources = (hp300_model == HP_320 ? 1 : 2);
+	for (i = 0; i < dio_bus.num_resources; i++)
+		request_resource(&iomem_resource, &dio_bus.resources[i]);
+
+	/* Register all devices */
         for (scode = 0; scode < DIO_SCMAX; ++scode)
         {
                 u_char prid, secid = 0;        /* primary, secondary ID bytes */
                 u_char *va;
+		unsigned long pa;
                 
                 if (DIO_SCINHOLE(scode))
                         continue;
-                
-                va = dio_scodetoviraddr(scode);
-                if (!va || !hwreg_present(va + DIO_IDOFF))
+
+		pa = dio_scodetophysaddr(scode);
+
+		if (!pa)
+			continue;
+
+		if (scode < DIOII_SCBASE)
+			va = (void *)(pa + DIO_VIRADDRBASE);
+		else
+			va = ioremap(pa, PAGE_SIZE);
+
+		fs = get_fs();
+		set_fs(KERNEL_DS);
+
+                if (get_user(i, (unsigned char *)va + DIO_IDOFF)) {
+			set_fs(fs);
+			if (scode >= DIOII_SCBASE)
+				iounmap(va);
                         continue;              /* no board present at that select code */
+		}
+
+		set_fs(fs);
 
                 /* Found a board, allocate it an entry in the list */
-                b = kmalloc(sizeof(struct dioboard), GFP_KERNEL);
-                
-                /* read the ID byte(s) and encode if necessary. Note workaround 
-                 * for broken internal HPIB devices...
-                 */
-                if (!DIO_ISIHPIB(scode))
-                        prid = DIO_ID(va);
-                else 
-                        prid = DIO_ID_IHPIB;
-                
-                if (DIO_NEEDSSECID(prid))
-                {
+		dev = kmalloc(sizeof(struct dio_dev), GFP_KERNEL);
+		if (!dev)
+			return 0;
+
+		memset(dev, 0, sizeof(struct dio_dev));
+		dev->bus = &dio_bus;
+		dev->dev.parent = &dio_bus.dev;
+		dev->dev.bus = &dio_bus_type;
+		dev->scode = scode;
+		dev->resource.start = pa;
+		dev->resource.end = pa + DIO_SIZE(scode, va);
+		sprintf(dev->dev.bus_id,"%02x", scode);
+
+                /* read the ID byte(s) and encode if necessary. */
+		prid = DIO_ID(va);
+
+                if (DIO_NEEDSSECID(prid)) {
                         secid = DIO_SECID(va);
-                        b->id = DIO_ENCODE_ID(prid, secid);
-                }
-                else
-                        b->id = prid;
-      
-                b->configured = 0;
-                b->scode = scode;
-                b->ipl = DIO_IPL(va);
-                b->name = dio_getname(b->id);
-                printk("select code %3d: ipl %d: ID %02X", scode, b->ipl, prid);
-                if (DIO_NEEDSSECID(b->id))
+                        dev->id = DIO_ENCODE_ID(prid, secid);
+                } else
+                        dev->id = prid;
+
+                dev->ipl = DIO_IPL(va);
+                strcpy(dev->name,dio_getname(dev->id));
+                printk(KERN_INFO "select code %3d: ipl %d: ID %02X", dev->scode, dev->ipl, prid);
+                if (DIO_NEEDSSECID(prid))
                         printk(":%02X", secid);
-                printk(": %s\n", b->name);
-                
-                b->next = NULL;
+                printk(": %s\n", dev->name);
 
-                if (bprev)
-                        bprev->next = b;
-                else
-                        blist = b;
-                bprev = b;
+		if (scode >= DIOII_SCBASE)
+			iounmap(va);
+		device_register(&dev->dev);
+		dio_create_sysfs_dev_files(dev);
         }
 	return 0;
 }
@@ -229,84 +264,16 @@
 subsys_initcall(dio_init);
 
 /* Bear in mind that this is called in the very early stages of initialisation
- * in order to get the virtual address of the serial port for the console...
+ * in order to get the address of the serial port for the console...
  */
-void *dio_scodetoviraddr(int scode)
+unsigned long dio_scodetophysaddr(int scode)
 {
-        if (scode > DIOII_SCBASE)
-        {
-                printk("dio_scodetoviraddr: don't support DIO-II yet!\n");
-                return 0;
-        }
-        else if (scode > DIO_SCMAX || scode < 0)
+        if (scode >= DIOII_SCBASE) {
+                return (DIOII_BASE + (scode - 132) * DIOII_DEVSIZE);
+        } else if (scode > DIO_SCMAX || scode < 0)
                 return 0;
         else if (DIO_SCINHOLE(scode))
                 return 0;
-        else if (DIO_ISIHPIB(scode))
-                return (void*)DIO_IHPIBADDR;
-
-        return (void*)(DIO_VIRADDRBASE + DIO_BASE + scode * 0x10000);
-}
 
-int dio_scodetoipl(int scode)
-{
-        struct dioboard *b;
-        for (b = blist; b; b = b->next)
-                if (b->scode == scode) 
-                        break;
-        
-        if (!b)
-        {
-                printk("dio_scodetoipl: bad select code %d\n", scode);
-                return 0;
-        }
-        else
-                return b->ipl;
-}
-
-const char *dio_scodetoname(int scode)
-{
-        struct dioboard *b;
-        for (b = blist; b; b = b->next)
-                if (b->scode == scode) 
-                        break;
-        
-        if (!b)
-        {
-                printk("dio_scodetoname: bad select code %d\n", scode);
-                return NULL;
-        }
-        else
-                return b->name;
-}
-
-void dio_config_board(int scode)
-{
-        struct dioboard *b;
-        for (b = blist; b; b = b->next)
-                if (b->scode == scode)
-                        break;
-   
-        if (!b) 
-                printk("dio_config_board: bad select code %d\n", scode);
-        else if (b->configured)
-                printk("dio_config_board: board at select code %d already configured\n", scode);
-        else
-                b->configured = 1;
-}
-
-void dio_unconfig_board(int scode)
-{
-        struct dioboard *b;
-        for (b = blist; b; b = b->next)
-                if (b->scode == scode) 
-                        break;
-   
-        if (!b) 
-                printk("dio_unconfig_board: bad select code %d\n", scode);
-        else if (!b->configured)
-                printk("dio_unconfig_board: board at select code %d not configured\n", 
-		       scode);
-        else 
-                b->configured = 0;
+        return (DIO_BASE + scode * DIO_DEVSIZE);
 }
diff -Nru a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
--- a/drivers/eisa/eisa-bus.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/eisa/eisa-bus.c	2004-12-24 13:36:31 -08:00
@@ -418,8 +418,8 @@
 	return 0;
 }
 
-module_param_array(enable_dev, int, enable_dev_count, 0444);
-module_param_array(disable_dev, int, disable_dev_count, 0444);
+module_param_array(enable_dev, int, &enable_dev_count, 0444);
+module_param_array(disable_dev, int, &disable_dev_count, 0444);
 
 postcore_initcall (eisa_init);
 
diff -Nru a/drivers/fc4/soc.c b/drivers/fc4/soc.c
--- a/drivers/fc4/soc.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/fc4/soc.c	2004-12-24 13:36:18 -08:00
@@ -32,7 +32,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <linux/errno.h>
@@ -671,10 +671,10 @@
 	cq[0].address = s->req_dvma;
 	s->req[1].pool = s->req[0].pool + SOC_CQ_REQ0_SIZE;
 	
-	s->req[0].hw_cq = (soc_hw_cq *)(s->xram + SOC_CQ_REQ_OFFSET);
-	s->req[1].hw_cq = (soc_hw_cq *)(s->xram + SOC_CQ_REQ_OFFSET + sizeof(soc_hw_cq));
-	s->rsp[0].hw_cq = (soc_hw_cq *)(s->xram + SOC_CQ_RSP_OFFSET);
-	s->rsp[1].hw_cq = (soc_hw_cq *)(s->xram + SOC_CQ_RSP_OFFSET + sizeof(soc_hw_cq));
+	s->req[0].hw_cq = (soc_hw_cq __iomem *)(s->xram + SOC_CQ_REQ_OFFSET);
+	s->req[1].hw_cq = (soc_hw_cq __iomem *)(s->xram + SOC_CQ_REQ_OFFSET + sizeof(soc_hw_cq));
+	s->rsp[0].hw_cq = (soc_hw_cq __iomem *)(s->xram + SOC_CQ_RSP_OFFSET);
+	s->rsp[1].hw_cq = (soc_hw_cq __iomem *)(s->xram + SOC_CQ_RSP_OFFSET + sizeof(soc_hw_cq));
 	
 	cq[1].address = cq[0].address + (SOC_CQ_REQ0_SIZE * sizeof(soc_req));
 	cq[4].address = 1;
diff -Nru a/drivers/fc4/soc.h b/drivers/fc4/soc.h
--- a/drivers/fc4/soc.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/fc4/soc.h	2004-12-24 13:36:16 -08:00
@@ -260,7 +260,7 @@
 } soc_port; 
 
 typedef struct {
-	soc_hw_cq		*hw_cq;	/* Related XRAM cq */
+	soc_hw_cq		__iomem *hw_cq;	/* Related XRAM cq */
 	soc_req			*pool;
 	u8			in;
 	u8			out;
diff -Nru a/drivers/fc4/socal.c b/drivers/fc4/socal.c
--- a/drivers/fc4/socal.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/fc4/socal.c	2004-12-24 13:36:48 -08:00
@@ -27,8 +27,8 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <linux/errno.h>
@@ -800,11 +800,11 @@
 	s->rsp[1].pool = s->rsp[0].pool + SOCAL_CQ_RSP0_SIZE;
 	s->rsp[2].pool = s->rsp[1].pool + SOCAL_CQ_RSP1_SIZE;
 	
-	s->req[0].hw_cq = (socal_hw_cq *)(s->xram + SOCAL_CQ_REQ_OFFSET);
-	s->req[1].hw_cq = (socal_hw_cq *)(s->xram + SOCAL_CQ_REQ_OFFSET + sizeof(socal_hw_cq));
-	s->rsp[0].hw_cq = (socal_hw_cq *)(s->xram + SOCAL_CQ_RSP_OFFSET);
-	s->rsp[1].hw_cq = (socal_hw_cq *)(s->xram + SOCAL_CQ_RSP_OFFSET + sizeof(socal_hw_cq));
-	s->rsp[2].hw_cq = (socal_hw_cq *)(s->xram + SOCAL_CQ_RSP_OFFSET + 2 * sizeof(socal_hw_cq));
+	s->req[0].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_REQ_OFFSET);
+	s->req[1].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_REQ_OFFSET + sizeof(socal_hw_cq));
+	s->rsp[0].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_RSP_OFFSET);
+	s->rsp[1].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_RSP_OFFSET + sizeof(socal_hw_cq));
+	s->rsp[2].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_RSP_OFFSET + 2 * sizeof(socal_hw_cq));
 	
 	cq[1].address = cq[0].address + (SOCAL_CQ_REQ0_SIZE * sizeof(socal_req));
 	cq[4].address = cq[1].address + (SOCAL_CQ_REQ1_SIZE * sizeof(socal_req));
diff -Nru a/drivers/fc4/socal.h b/drivers/fc4/socal.h
--- a/drivers/fc4/socal.h	2004-12-24 13:36:49 -08:00
+++ b/drivers/fc4/socal.h	2004-12-24 13:36:49 -08:00
@@ -281,7 +281,7 @@
 } socal_port; 
 
 typedef struct {
-	socal_hw_cq		*hw_cq;	/* Related XRAM cq */
+	socal_hw_cq		__iomem *hw_cq;	/* Related XRAM cq */
 	socal_req		*pool;
 	u8			in;
 	u8			out;
diff -Nru a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
--- a/drivers/firmware/Kconfig	2004-12-24 13:36:16 -08:00
+++ b/drivers/firmware/Kconfig	2004-12-24 13:36:16 -08:00
@@ -48,7 +48,11 @@
 	  use the first serial port it describes as the Linux console,
 	  say Y here.  If your EFI ConOut path contains only a UART
 	  device, it will become the console automatically.  Otherwise,
-	  you must specify the "console=ttyS0" kernel boot argument.
+	  you must specify the "console=hcdp" kernel boot argument.
+
+	  Neither the PCDP nor the HCDP affects naming of serial devices,
+	  so a serial console may be /dev/ttyS0, /dev/ttyS1, etc, depending
+	  on how the driver discovers devices.
 
 	  You must also enable the appropriate drivers (serial, VGA, etc.)
 
diff -Nru a/drivers/firmware/edd.c b/drivers/firmware/edd.c
--- a/drivers/firmware/edd.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/firmware/edd.c	2004-12-24 13:36:47 -08:00
@@ -70,7 +70,7 @@
 static int edd_dev_is_type(struct edd_device *edev, const char *type);
 static struct pci_dev *edd_get_pci_dev(struct edd_device *edev);
 
-static struct edd_device *edd_devices[EDDMAXNR];
+static struct edd_device *edd_devices[EDD_MBR_SIG_MAX];
 
 #define EDD_DEVICE_ATTR(_name,_mode,_show,_test) \
 struct edd_attribute edd_attr_##_name = { 	\
@@ -728,9 +728,9 @@
 
 static inline int edd_num_devices(void)
 {
-	return min_t(unsigned char,
-		     max_t(unsigned char, edd.edd_info_nr, edd.mbr_signature_nr),
-		     max_t(unsigned char, EDD_MBR_SIG_MAX, EDDMAXNR));
+	return max_t(unsigned char,
+		     min_t(unsigned char, EDD_MBR_SIG_MAX, edd.mbr_signature_nr),
+		     min_t(unsigned char, EDDMAXNR, edd.edd_info_nr));
 }
 
 /**
diff -Nru a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
--- a/drivers/firmware/efivars.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/firmware/efivars.c	2004-12-24 13:37:19 -08:00
@@ -640,7 +640,7 @@
 	*(short_name + strlen(short_name)) = '-';
 	efi_guid_unparse(vendor_guid, short_name + strlen(short_name));
 
-	kobject_set_name(&new_efivar->kobj, short_name);
+	kobject_set_name(&new_efivar->kobj, "%s", short_name);
 	kobj_set_kset_s(new_efivar, vars_subsys);
 	kobject_register(&new_efivar->kobj);
 
diff -Nru a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c
--- a/drivers/firmware/pcdp.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/firmware/pcdp.c	2004-12-24 13:36:33 -08:00
@@ -14,127 +14,45 @@
 #include <linux/acpi.h>
 #include <linux/console.h>
 #include <linux/efi.h>
-#include <linux/tty.h>
 #include <linux/serial.h>
-#include <linux/serial_core.h>
-#include <asm/io.h>
-#include <asm/serial.h>
 #include "pcdp.h"
 
-static inline int
-uart_irq_supported(int rev, struct pcdp_uart *uart)
-{
-	if (rev < 3)
-		return uart->pci_func & PCDP_UART_IRQ;
-	return uart->flags & PCDP_UART_IRQ;
-}
-
-static inline int
-uart_pci(int rev, struct pcdp_uart *uart)
-{
-	if (rev < 3)
-		return uart->pci_func & PCDP_UART_PCI;
-	return uart->flags & PCDP_UART_PCI;
-}
-
-static inline int
-uart_active_high_low(int rev, struct pcdp_uart *uart)
-{
-	if (uart_pci(rev, uart) || uart->flags & PCDP_UART_ACTIVE_LOW)
-		return ACPI_ACTIVE_LOW;
-	return ACPI_ACTIVE_HIGH;
-}
-
-static inline int
-uart_edge_level(int rev, struct pcdp_uart *uart)
-{
-	if (uart_pci(rev, uart))
-		return ACPI_LEVEL_SENSITIVE;
-	if (rev < 3 || uart->flags & PCDP_UART_EDGE_SENSITIVE)
-		return ACPI_EDGE_SENSITIVE;
-	return ACPI_LEVEL_SENSITIVE;
-}
-
-static void __init
-setup_serial_console(int rev, struct pcdp_uart *uart)
+static int __init
+setup_serial_console(struct pcdp_uart *uart)
 {
 #ifdef CONFIG_SERIAL_8250_CONSOLE
-	struct uart_port port;
-	static char options[16];
-	int mapsize = 64;
-
-	memset(&port, 0, sizeof(port));
-	port.uartclk = uart->clock_rate;
-	if (!port.uartclk)	/* some FW doesn't supply this */
-		port.uartclk = BASE_BAUD * 16;
-
-	if (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
-		port.mapbase = uart->addr.address;
-		port.membase = ioremap(port.mapbase, mapsize);
-		if (!port.membase) {
-			printk(KERN_ERR "%s: couldn't ioremap 0x%lx-0x%lx\n",
-				__FUNCTION__, port.mapbase, port.mapbase + mapsize);
-			return;
-		}
-		port.iotype = UPIO_MEM;
-	} else if (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
-		port.iobase = uart->addr.address;
-		port.iotype = UPIO_PORT;
-	} else
-		return;
-
-	switch (uart->pci_prog_intfc) {
-		case 0x0: port.type = PORT_8250;    break;
-		case 0x1: port.type = PORT_16450;   break;
-		case 0x2: port.type = PORT_16550;   break;
-		case 0x3: port.type = PORT_16650;   break;
-		case 0x4: port.type = PORT_16750;   break;
-		case 0x5: port.type = PORT_16850;   break;
-		case 0x6: port.type = PORT_16C950;  break;
-		default:  port.type = PORT_UNKNOWN; break;
-	}
-
-	port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
-
-	if (uart_irq_supported(rev, uart)) {
-		port.irq = acpi_register_gsi(uart->gsi,
-			uart_active_high_low(rev, uart),
-			uart_edge_level(rev, uart));
-		port.flags |= UPF_AUTO_IRQ;  /* some FW reported wrong GSI */
-		if (uart_pci(rev, uart))
-			port.flags |= UPF_SHARE_IRQ;
-	}
-
-	if (early_serial_setup(&port) < 0)
-		return;
+	int mmio;
+	static char options[64];
 
-	snprintf(options, sizeof(options), "%lun%d", uart->baud,
+	mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY);
+	snprintf(options, sizeof(options), "console=uart,%s,0x%lx,%lun%d",
+		mmio ? "mmio" : "io", uart->addr.address, uart->baud,
 		uart->bits ? uart->bits : 8);
-	add_preferred_console("ttyS", port.line, options);
 
-	printk(KERN_INFO "PCDP: serial console at %s 0x%lx (ttyS%d, options %s)\n",
-		port.iotype == UPIO_MEM ? "MMIO" : "I/O",
-		uart->addr.address, port.line, options);
+	return early_serial_console_init(options);
+#else
+	return -ENODEV;
 #endif
 }
 
-static void __init
+static int __init
 setup_vga_console(struct pcdp_vga *vga)
 {
-#ifdef CONFIG_VT
-#ifdef CONFIG_VGA_CONSOLE
+#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
 	if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) {
 		printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n");
-		return;
+		return -ENODEV;
 	}
 
 	conswitchp = &vga_con;
 	printk(KERN_INFO "PCDP: VGA console\n");
-#endif
+	return 0;
+#else
+	return -ENODEV;
 #endif
 }
 
-void __init
+int __init
 efi_setup_pcdp_console(char *cmdline)
 {
 	struct pcdp *pcdp;
@@ -144,20 +62,25 @@
 
 	pcdp = efi.hcdp;
 	if (!pcdp)
-		return;
+		return -ENODEV;
 
-	printk(KERN_INFO "PCDP: v%d at 0x%p\n", pcdp->rev, pcdp);
+	printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, __pa(pcdp));
 
-	if (pcdp->rev < 3) {
-		if (strstr(cmdline, "console=ttyS0") || efi_uart_console_only())
+	if (strstr(cmdline, "console=hcdp")) {
+		if (pcdp->rev < 3)
 			serial = 1;
+	} else if (strstr(cmdline, "console=")) {
+		printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n");
+		return -ENODEV;
 	}
 
+	if (pcdp->rev < 3 && efi_uart_console_only())
+		serial = 1;
+
 	for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
 		if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) {
 			if (uart->type == PCDP_CONSOLE_UART) {
-				setup_serial_console(pcdp->rev, uart);
-				return;
+				return setup_serial_console(uart);
 			}
 		}
 	}
@@ -168,11 +91,12 @@
 	     dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) {
 		if (dev->flags & PCDP_PRIMARY_CONSOLE) {
 			if (dev->type == PCDP_CONSOLE_VGA) {
-				setup_vga_console((struct pcdp_vga *) dev);
-				return;
+				return setup_vga_console((struct pcdp_vga *) dev);
 			}
 		}
 	}
+
+	return -ENODEV;
 }
 
 #ifdef CONFIG_IA64_EARLY_PRINTK_UART
diff -Nru a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c
--- a/drivers/i2c/algos/i2c-algo-ite.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/i2c/algos/i2c-algo-ite.c	2004-12-24 13:37:19 -08:00
@@ -107,14 +107,6 @@
 	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.
diff -Nru a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
--- a/drivers/i2c/algos/i2c-algo-pca.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/i2c/algos/i2c-algo-pca.c	2004-12-24 13:37:02 -08:00
@@ -249,7 +249,7 @@
 			break;
 
 		case 0x20: /* SLA+W has been transmitted; NOT ACK has been received */
-			DEB2("NOT ACK recieved after SLA+W\n");
+			DEB2("NOT ACK received after SLA+W\n");
 			pca_stop(adap);
 			return -EREMOTEIO;
 
@@ -277,7 +277,7 @@
 			return -EREMOTEIO;
 
 		case 0x30: /* Data byte in I2CDAT has been transmitted; NOT ACK has been received */
-			DEB2("NOT ACK recieved after data byte\n");
+			DEB2("NOT ACK received after data byte\n");
 			return -EREMOTEIO;
 
 		case 0x38: /* Arbitration lost during SLA+W, SLA+R or data bytes */
diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
--- a/drivers/i2c/busses/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/drivers/i2c/busses/Kconfig	2004-12-24 13:37:18 -08:00
@@ -40,21 +40,36 @@
 	  will be called i2c-ali15x3.
 
 config I2C_AMD756
-	tristate "AMD 756/766"
-	depends on I2C && EXPERIMENTAL
+	tristate "AMD 756/766/768/8111 and nVidia nForce"
+	depends on I2C && PCI && EXPERIMENTAL
 	help
 	  If you say yes to this option, support will be included for the AMD
-	  756/766/768 mainboard I2C interfaces.
+	  756/766/768 mainboard I2C interfaces.  The driver also includes
+	  support for the first (SMBus 1.0) I2C interface of the AMD 8111 and
+	  the nVidia nForce I2C interface.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-amd756.
 
+config I2C_AMD756_S4882
+	tristate "SMBus multiplexing on the Tyan S4882"
+	depends on I2C_AMD756 && EXPERIMENTAL
+	help
+	  Enabling this option will add specific SMBus support for the Tyan
+	  S4882 motherboard.  On this 4-CPU board, the SMBus is multiplexed
+	  over 8 different channels, where the various memory module EEPROMs
+	  and temperature sensors live.  Saying yes here will give you access
+	  to these in addition to the trunk.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-amd756-s4882.
+
 config I2C_AMD8111
 	tristate "AMD 8111"
-	depends on I2C && EXPERIMENTAL
+	depends on I2C && PCI && EXPERIMENTAL
 	help
-	  If you say yes to this option, support will be included for the AMD
-	  8111 mainboard I2C interfaces.
+	  If you say yes to this option, support will be included for the
+	  second (SMBus 2.0) AMD 8111 mainboard I2C interface.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-amd8111.
@@ -203,6 +218,7 @@
 	help
 	  If you say yes to this option, support will be included for the Nvidia
 	  Nforce2 family of mainboard I2C interfaces.
+	  This driver also supports the nForce3 Pro 150 MCP.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-nforce2.
@@ -289,6 +305,13 @@
 	depends on (RPXLITE || RPXCLASSIC) && I2C
 	select I2C_ALGO8XX
 
+config I2C_S3C2410
+	tristate "S3C2410 I2C Driver"
+	depends on I2C && ARCH_S3C2410
+	help
+	  Say Y here to include support for I2C controller in the
+	  Samsung S3C2410 based System-on-Chip devices.
+
 config I2C_SAVAGE4
 	tristate "S3 Savage 4"
 	depends on I2C && PCI && EXPERIMENTAL
@@ -330,7 +353,7 @@
 
 config SCx200_ACB
 	tristate "NatSemi SCx200 ACCESS.bus"
-	depends on I2C
+	depends on I2C && PCI
 	help
 	  Enable the use of the ACCESS.bus controllers of a SCx200 processor.
 
@@ -375,6 +398,19 @@
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-sis96x.
+
+config I2C_STUB
+	tristate "I2C/SMBus Test Stub"
+	depends on I2C && EXPERIMENTAL && 'm'
+	default 'n'
+	help
+	  This module may be useful to developers of SMBus client drivers,
+	  especially for certain kinds of sensor chips.
+
+	  If you do build this module, be sure to read the notes and warnings
+	  in Documentation/i2c/i2c-stub.
+
+	  If you don't know what to do here, definitely say N.
 
 config I2C_VIA
 	tristate "VIA 82C586B"
diff -Nru a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
--- a/drivers/i2c/busses/Makefile	2004-12-24 13:36:18 -08:00
+++ b/drivers/i2c/busses/Makefile	2004-12-24 13:36:18 -08:00
@@ -6,6 +6,7 @@
 obj-$(CONFIG_I2C_ALI1563)	+= i2c-ali1563.o
 obj-$(CONFIG_I2C_ALI15X3)	+= i2c-ali15x3.o
 obj-$(CONFIG_I2C_AMD756)	+= i2c-amd756.o
+obj-$(CONFIG_I2C_AMD756_S4882)	+= i2c-amd756-s4882.o
 obj-$(CONFIG_I2C_AMD8111)	+= i2c-amd8111.o
 obj-$(CONFIG_I2C_ELEKTOR)	+= i2c-elektor.o
 obj-$(CONFIG_I2C_HYDRA)		+= i2c-hydra.o
@@ -26,10 +27,12 @@
 obj-$(CONFIG_I2C_PIIX4)		+= i2c-piix4.o
 obj-$(CONFIG_I2C_PROSAVAGE)	+= i2c-prosavage.o
 obj-$(CONFIG_I2C_RPXLITE)	+= i2c-rpx.o
+obj-$(CONFIG_I2C_S3C2410)	+= i2c-s3c2410.o
 obj-$(CONFIG_I2C_SAVAGE4)	+= i2c-savage4.o
 obj-$(CONFIG_I2C_SIS5595)	+= i2c-sis5595.o
 obj-$(CONFIG_I2C_SIS630)	+= i2c-sis630.o
 obj-$(CONFIG_I2C_SIS96X)	+= i2c-sis96x.o
+obj-$(CONFIG_I2C_STUB)		+= i2c-stub.o
 obj-$(CONFIG_I2C_VIA)		+= i2c-via.o
 obj-$(CONFIG_I2C_VIAPRO)	+= i2c-viapro.o
 obj-$(CONFIG_I2C_VOODOO3)	+= i2c-voodoo3.o
diff -Nru a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
--- a/drivers/i2c/busses/i2c-ali1535.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/i2c/busses/i2c-ali1535.c	2004-12-24 13:37:18 -08:00
@@ -137,7 +137,7 @@
 
 
 static unsigned short ali1535_smba;
-DECLARE_MUTEX(i2c_ali1535_sem);
+static DECLARE_MUTEX(i2c_ali1535_sem);
 
 /* Detect whether a ALI1535 can be found, and initialize it, where necessary.
    Note the differences between kernels with the old PCI BIOS interface and
@@ -465,7 +465,7 @@
 }
 
 
-u32 ali1535_func(struct i2c_adapter *adapter)
+static u32 ali1535_func(struct i2c_adapter *adapter)
 {
 	return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
 	    I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
@@ -496,6 +496,8 @@
 	{ },
 };
 
+MODULE_DEVICE_TABLE (pci, ali1535_ids);
+
 static int __devinit ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	if (ali1535_setup(dev)) {
@@ -527,7 +529,7 @@
 
 static int __init i2c_ali1535_init(void)
 {
-	return pci_module_init(&ali1535_driver);
+	return pci_register_driver(&ali1535_driver);
 }
 
 static void __exit i2c_ali1535_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
--- a/drivers/i2c/busses/i2c-ali1563.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/i2c/busses/i2c-ali1563.c	2004-12-24 13:37:01 -08:00
@@ -394,6 +394,8 @@
 	{},
 };
 
+MODULE_DEVICE_TABLE (pci, ali1563_id_table);
+
 static struct pci_driver ali1563_pci_driver = {
  	.name		= "ali1563_i2c",
 	.id_table	= ali1563_id_table,
@@ -403,7 +405,7 @@
 
 static int __init ali1563_init(void)
 {
-	return pci_module_init(&ali1563_pci_driver);
+	return pci_register_driver(&ali1563_pci_driver);
 }
 
 module_init(ali1563_init);
diff -Nru a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
--- a/drivers/i2c/busses/i2c-ali15x3.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/i2c/busses/i2c-ali15x3.c	2004-12-24 13:36:55 -08:00
@@ -486,6 +486,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, ali15x3_ids);
+
 static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	if (ali15x3_setup(dev)) {
@@ -517,7 +519,7 @@
 
 static int __init i2c_ali15x3_init(void)
 {
-	return pci_module_init(&ali15x3_driver);
+	return pci_register_driver(&ali15x3_driver);
 }
 
 static void __exit i2c_ali15x3_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,264 @@
+/*
+ * i2c-amd756-s4882.c - i2c-amd756 extras for the Tyan S4882 motherboard
+ *
+ * Copyright (C) 2004 Jean Delvare <khali@linux-fr.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 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.
+ */
+ 
+/*
+ * We select the channels by sending commands to the Philips
+ * PCA9556 chip at I2C address 0x18. The main adapter is used for
+ * the non-multiplexed part of the bus, and 4 virtual adapters
+ * are defined for the multiplexed addresses: 0x50-0x53 (memory
+ * module EEPROM) located on channels 1-4, and 0x4c (LM63)
+ * located on multiplexed channels 0 and 5-7. We define one
+ * virtual adapter per CPU, which corresponds to two multiplexed
+ * channels:
+ *   CPU0: virtual adapter 1, channels 1 and 0
+ *   CPU1: virtual adapter 2, channels 2 and 5
+ *   CPU2: virtual adapter 3, channels 3 and 6
+ *   CPU3: virtual adapter 4, channels 4 and 7
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+
+extern struct i2c_adapter amd756_smbus;
+
+static struct i2c_adapter *s4882_adapter;
+static struct i2c_algorithm *s4882_algo;
+
+/* Wrapper access functions for multiplexed SMBus */
+static struct semaphore amd756_lock;
+
+static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
+			       unsigned short flags, char read_write,
+			       u8 command, int size,
+			       union i2c_smbus_data * data)
+{
+	int error;
+
+	/* We exclude the multiplexed addresses */
+	if (addr == 0x4c || (addr & 0xfc) == 0x50 || (addr & 0xfc) == 0x30
+	 || addr == 0x18)
+		return -1;
+
+	down(&amd756_lock);
+
+	error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write,
+					      command, size, data);
+
+	up(&amd756_lock);
+
+	return error;
+}
+
+/* We remember the last used channels combination so as to only switch
+   channels when it is really needed. This greatly reduces the SMBus
+   overhead, but also assumes that nobody will be writing to the PCA9556
+   in our back. */
+static u8 last_channels;
+
+static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
+					unsigned short flags, char read_write,
+					u8 command, int size,
+					union i2c_smbus_data * data,
+					u8 channels)
+{
+	int error;
+
+	/* We exclude the non-multiplexed addresses */
+	if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30)
+		return -1;
+
+	down(&amd756_lock);
+
+	if (last_channels != channels) {
+		union i2c_smbus_data mplxdata;
+		mplxdata.byte = channels;
+
+		error = amd756_smbus.algo->smbus_xfer(adap, 0x18, 0,
+						      I2C_SMBUS_WRITE, 0x01,
+						      I2C_SMBUS_BYTE_DATA,
+						      &mplxdata);
+		if (error)
+			goto UNLOCK;
+		last_channels = channels;
+	}
+	error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write,
+					      command, size, data);
+
+UNLOCK:
+	up(&amd756_lock);
+	return error;
+}
+
+static s32 amd756_access_virt1(struct i2c_adapter * adap, u16 addr,
+			       unsigned short flags, char read_write,
+			       u8 command, int size,
+			       union i2c_smbus_data * data)
+{
+	/* CPU0: channels 1 and 0 enabled */
+	return amd756_access_channel(adap, addr, flags, read_write, command,
+				     size, data, 0x03);
+}
+
+static s32 amd756_access_virt2(struct i2c_adapter * adap, u16 addr,
+			       unsigned short flags, char read_write,
+			       u8 command, int size,
+			       union i2c_smbus_data * data)
+{
+	/* CPU1: channels 2 and 5 enabled */
+	return amd756_access_channel(adap, addr, flags, read_write, command,
+				     size, data, 0x24);
+}
+
+static s32 amd756_access_virt3(struct i2c_adapter * adap, u16 addr,
+			       unsigned short flags, char read_write,
+			       u8 command, int size,
+			       union i2c_smbus_data * data)
+{
+	/* CPU2: channels 3 and 6 enabled */
+	return amd756_access_channel(adap, addr, flags, read_write, command,
+				     size, data, 0x48);
+}
+
+static s32 amd756_access_virt4(struct i2c_adapter * adap, u16 addr,
+			       unsigned short flags, char read_write,
+			       u8 command, int size,
+			       union i2c_smbus_data * data)
+{
+	/* CPU3: channels 4 and 7 enabled */
+	return amd756_access_channel(adap, addr, flags, read_write, command,
+				     size, data, 0x90);
+}
+
+static int __init amd756_s4882_init(void)
+{
+	int i, error;
+	union i2c_smbus_data ioconfig;
+
+	/* Unregister physical bus */
+	error = i2c_del_adapter(&amd756_smbus);
+	if (error) {
+		if (error == -EINVAL)
+			error = -ENODEV;
+		else
+			dev_err(&amd756_smbus.dev, "Physical bus removal "
+				"failed\n");
+		goto ERROR0;
+	}
+
+	printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n");
+	init_MUTEX(&amd756_lock);
+
+	/* Define the 5 virtual adapters and algorithms structures */
+	if (!(s4882_adapter = kmalloc(5 * sizeof(struct i2c_adapter),
+				      GFP_KERNEL))) {
+		error = -ENOMEM;
+		goto ERROR1;
+	}
+	if (!(s4882_algo = kmalloc(5 * sizeof(struct i2c_algorithm),
+				   GFP_KERNEL))) {
+		error = -ENOMEM;
+		goto ERROR2;
+	}
+
+	/* Fill in the new structures */
+	s4882_algo[0] = *(amd756_smbus.algo);
+	s4882_algo[0].smbus_xfer = amd756_access_virt0;
+	s4882_adapter[0] = amd756_smbus;
+	s4882_adapter[0].algo = s4882_algo;
+	for (i = 1; i < 5; i++) {
+		s4882_algo[i] = *(amd756_smbus.algo);
+		s4882_adapter[i] = amd756_smbus;
+		sprintf(s4882_adapter[i].name,
+			"SMBus 8111 adapter (CPU%d)", i-1);
+		s4882_adapter[i].algo = s4882_algo+i;
+	}
+	s4882_algo[1].smbus_xfer = amd756_access_virt1;
+	s4882_algo[2].smbus_xfer = amd756_access_virt2;
+	s4882_algo[3].smbus_xfer = amd756_access_virt3;
+	s4882_algo[4].smbus_xfer = amd756_access_virt4;
+
+	/* Configure the PCA9556 multiplexer */
+	ioconfig.byte = 0x00; /* All I/O to output mode */
+	error = amd756_smbus.algo->smbus_xfer(&amd756_smbus, 0x18, 0,
+					      I2C_SMBUS_WRITE, 0x03,
+					      I2C_SMBUS_BYTE_DATA, &ioconfig);
+	if (error) {
+		dev_err(&amd756_smbus.dev, "PCA9556 configuration failed\n");
+		error = -EIO;
+		goto ERROR3;
+	}
+
+	/* Register virtual adapters */
+	for (i = 0; i < 5; i++) {
+		error = i2c_add_adapter(s4882_adapter+i);
+		if (error) {
+			dev_err(&amd756_smbus.dev,
+			       "Virtual adapter %d registration "
+			       "failed, module not inserted\n", i);
+			for (i--; i >= 0; i--)
+				i2c_del_adapter(s4882_adapter+i);
+			goto ERROR3;
+		}
+	}
+
+	return 0;
+
+ERROR3:
+	kfree(s4882_algo);
+	s4882_algo = NULL;
+ERROR2:
+	kfree(s4882_adapter);
+	s4882_adapter = NULL;
+ERROR1:
+	i2c_del_adapter(&amd756_smbus);
+ERROR0:
+	return error;
+}
+
+static void __exit amd756_s4882_exit(void)
+{
+	if (s4882_adapter) {
+		int i;
+
+		for (i = 0; i < 5; i++)
+			i2c_del_adapter(s4882_adapter+i);
+		kfree(s4882_adapter);
+		s4882_adapter = NULL;
+	}
+	if (s4882_algo) {
+		kfree(s4882_algo);
+		s4882_algo = NULL;
+	}
+
+	/* Restore physical bus */
+	if (i2c_add_adapter(&amd756_smbus))
+		dev_err(&amd756_smbus.dev, "Physical bus restoration "
+			"failed\n");
+}
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("S4882 SMBus multiplexing");
+MODULE_LICENSE("GPL");
+
+module_init(amd756_s4882_init);
+module_exit(amd756_s4882_exit);
diff -Nru a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
--- a/drivers/i2c/busses/i2c-amd756.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/i2c/busses/i2c-amd756.c	2004-12-24 13:37:18 -08:00
@@ -116,14 +116,14 @@
 	int result = 0;
 	int timeout = 0;
 
-	dev_dbg(&adap->dev, ": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, "
+	dev_dbg(&adap->dev, "Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, "
 		"DAT=%04x\n", inw_p(SMB_GLOBAL_STATUS),
 		inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_HOST_ADDRESS),
 		inb_p(SMB_HOST_DATA));
 
 	/* Make sure the SMBus host is ready to start transmitting */
 	if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) {
-		dev_dbg(&adap->dev, ": SMBus busy (%04x). Waiting... \n", temp);
+		dev_dbg(&adap->dev, "SMBus busy (%04x). Waiting...\n", temp);
 		do {
 			msleep(1);
 			temp = inw_p(SMB_GLOBAL_STATUS);
@@ -131,7 +131,7 @@
 		         (timeout++ < MAX_TIMEOUT));
 		/* If the SMBus is still busy, we give up */
 		if (timeout >= MAX_TIMEOUT) {
-			dev_dbg(&adap->dev, ": Busy wait timeout (%04x)\n", temp);
+			dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp);
 			goto abort;
 		}
 		timeout = 0;
@@ -148,46 +148,46 @@
 
 	/* If the SMBus is still busy, we give up */
 	if (timeout >= MAX_TIMEOUT) {
-		dev_dbg(&adap->dev, ": Completion timeout!\n");
+		dev_dbg(&adap->dev, "Completion timeout!\n");
 		goto abort;
 	}
 
 	if (temp & GS_PRERR_STS) {
 		result = -1;
-		dev_dbg(&adap->dev, ": SMBus Protocol error (no response)!\n");
+		dev_dbg(&adap->dev, "SMBus Protocol error (no response)!\n");
 	}
 
 	if (temp & GS_COL_STS) {
 		result = -1;
-		dev_warn(&adap->dev, " SMBus collision!\n");
+		dev_warn(&adap->dev, "SMBus collision!\n");
 	}
 
 	if (temp & GS_TO_STS) {
 		result = -1;
-		dev_dbg(&adap->dev, ": SMBus protocol timeout!\n");
+		dev_dbg(&adap->dev, "SMBus protocol timeout!\n");
 	}
 
 	if (temp & GS_HCYC_STS)
-		dev_dbg(&adap->dev, " SMBus protocol success!\n");
+		dev_dbg(&adap->dev, "SMBus protocol success!\n");
 
 	outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
 
 #ifdef DEBUG
 	if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) {
 		dev_dbg(&adap->dev,
-			": Failed reset at end of transaction (%04x)\n", temp);
+			"Failed reset at end of transaction (%04x)\n", temp);
 	}
 #endif
 
 	dev_dbg(&adap->dev,
-		": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
+		"Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
 		inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE),
 		inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA));
 
 	return result;
 
  abort:
-	dev_warn(&adap->dev, ": Sending abort.\n");
+	dev_warn(&adap->dev, "Sending abort\n");
 	outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
 	msleep(100);
 	outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
@@ -204,7 +204,7 @@
 	/** TODO: Should I supporte the 10-bit transfers? */
 	switch (size) {
 	case I2C_SMBUS_PROC_CALL:
-		dev_dbg(&adap->dev, ": I2C_SMBUS_PROC_CALL not supported!\n");
+		dev_dbg(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
 		/* TODO: Well... It is supported, I'm just not sure what to do here... */
 		return -1;
 	case I2C_SMBUS_QUICK:
@@ -302,7 +302,7 @@
 	.functionality	= amd756_func,
 };
 
-static struct i2c_adapter amd756_adapter = {
+struct i2c_adapter amd756_smbus = {
 	.owner		= THIS_MODULE,
 	.class          = I2C_CLASS_HWMON,
 	.algo		= &smbus_algorithm,
@@ -310,6 +310,10 @@
 };
 
 enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 };
+static const char* chipname[] = {
+	"AMD756", "AMD766", "AMD768",
+	"nVidia nForce", "AMD8111",
+};
 
 static struct pci_device_id amd756_ids[] = {
 	{PCI_VENDOR_ID_AMD, 0x740B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD756 },
@@ -320,6 +324,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, amd756_ids);
+
 static int __devinit amd756_probe(struct pci_dev *pdev,
 				  const struct pci_device_id *id)
 {
@@ -328,8 +334,8 @@
 	u8 temp;
 	
 	if (amd756_ioport) {
-		dev_err(&pdev->dev, ": Only one device supported. "
-		       "(you have a strange motherboard, btw..)\n");
+		dev_err(&pdev->dev, "Only one device supported "
+		       "(you have a strange motherboard, btw)\n");
 		return -ENODEV;
 	}
 
@@ -346,7 +352,7 @@
 		pci_read_config_byte(pdev, SMBGCFG, &temp);
 		if ((temp & 128) == 0) {
 			dev_err(&pdev->dev,
-				": Error: SMBus controller I/O not enabled!\n");
+				"Error: SMBus controller I/O not enabled!\n");
 			return -ENODEV;
 		}
 
@@ -358,25 +364,25 @@
 	}
 
 	if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) {
-		dev_err(&pdev->dev, ": SMB region 0x%x already in use!\n",
+		dev_err(&pdev->dev, "SMB region 0x%x already in use!\n",
 			amd756_ioport);
 		return -ENODEV;
 	}
 
 	pci_read_config_byte(pdev, SMBREV, &temp);
-	dev_dbg(&pdev->dev, ": SMBREV = 0x%X\n", temp);
-	dev_dbg(&pdev->dev, ": AMD756_smba = 0x%X\n", amd756_ioport);
+	dev_dbg(&pdev->dev, "SMBREV = 0x%X\n", temp);
+	dev_dbg(&pdev->dev, "AMD756_smba = 0x%X\n", amd756_ioport);
 
 	/* set up the driverfs linkage to our parent device */
-	amd756_adapter.dev.parent = &pdev->dev;
+	amd756_smbus.dev.parent = &pdev->dev;
 
-	snprintf(amd756_adapter.name, I2C_NAME_SIZE,
-		"SMBus AMD756 adapter at %04x", amd756_ioport);
+	sprintf(amd756_smbus.name, "SMBus %s adapter at %04x",
+		chipname[id->driver_data], amd756_ioport);
 
-	error = i2c_add_adapter(&amd756_adapter);
+	error = i2c_add_adapter(&amd756_smbus);
 	if (error) {
 		dev_err(&pdev->dev,
-			": Adapter registration failed, module not inserted.\n");
+			"Adapter registration failed, module not inserted\n");
 		goto out_err;
 	}
 
@@ -389,7 +395,7 @@
 
 static void __devexit amd756_remove(struct pci_dev *dev)
 {
-	i2c_del_adapter(&amd756_adapter);
+	i2c_del_adapter(&amd756_smbus);
 	release_region(amd756_ioport, SMB_IOSIZE);
 }
 
@@ -402,7 +408,7 @@
 
 static int __init amd756_init(void)
 {
-	return pci_module_init(&amd756_driver);
+	return pci_register_driver(&amd756_driver);
 }
 
 static void __exit amd756_exit(void)
@@ -413,6 +419,8 @@
 MODULE_AUTHOR("Merlin Hughes <merlin@merlin.org>");
 MODULE_DESCRIPTION("AMD756/766/768/8111 and nVidia nForce SMBus driver");
 MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(amd756_smbus);
 
 module_init(amd756_init)
 module_exit(amd756_exit)
diff -Nru a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
--- a/drivers/i2c/busses/i2c-amd8111.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/i2c/busses/i2c-amd8111.c	2004-12-24 13:37:18 -08:00
@@ -67,7 +67,7 @@
  * ACPI 2.0 chapter 13 access of registers of the EC
  */
 
-unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
+static unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
 {
 	int timeout = 500;
 
@@ -82,7 +82,7 @@
 	return 0;
 }
 
-unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
+static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
 {
 	int timeout = 500;
 
@@ -97,7 +97,7 @@
 	return 0;
 }
 
-unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, unsigned char *data)
+static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, unsigned char *data)
 {
 	if (amd_ec_wait_write(smbus))
 		return -1;
@@ -114,7 +114,7 @@
 	return 0;
 }
 
-unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, unsigned char data)
+static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, unsigned char data)
 {
 	if (amd_ec_wait_write(smbus))
 		return -1;
@@ -174,7 +174,7 @@
 #define AMD_SMB_PRTCL_PEC		0x80
 
 
-s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
+static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
 		char read_write, u8 command, int size, union i2c_smbus_data * data)
 {
 	struct amd_smbus *smbus = adap->algo_data;
@@ -315,7 +315,7 @@
 }
 
 
-u32 amd8111_func(struct i2c_adapter *adapter)
+static u32 amd8111_func(struct i2c_adapter *adapter)
 {
 	return	I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
 		I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA |
@@ -336,6 +336,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, amd8111_ids);
+
 static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	struct amd_smbus *smbus;
@@ -400,7 +402,7 @@
 
 static int __init i2c_amd8111_init(void)
 {
-	return pci_module_init(&amd8111_driver);
+	return pci_register_driver(&amd8111_driver);
 }
 
 
diff -Nru a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
--- a/drivers/i2c/busses/i2c-elektor.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/i2c/busses/i2c-elektor.c	2004-12-24 13:36:17 -08:00
@@ -59,6 +59,7 @@
 
 static wait_queue_head_t pcf_wait;
 static int pcf_pending;
+static spinlock_t lock;
 
 /* ----- local functions ----------------------------------------------	*/
 
@@ -79,10 +80,10 @@
 		break;
 	case 2: /* double mapped I/O needed for UP2000 board,
                    I don't know why this... */
-		writeb(val, address);
+		writeb(val, (void *)address);
 		/* fall */
 	case 1: /* memory mapped I/O */
-		writeb(val, address);
+		writeb(val, (void *)address);
 		break;
 	}
 }
@@ -90,7 +91,7 @@
 static int pcf_isa_getbyte(void *data, int ctl)
 {
 	int address = ctl ? (base + 1) : base;
-	int val = mmapped ? readb(address) : inb(address);
+	int val = mmapped ? readb((void *)address) : inb(address);
 
 	pr_debug("i2c-elektor: Read 0x%X 0x%02X\n", address, val);
 
@@ -111,14 +112,24 @@
 static void pcf_isa_waitforpin(void) {
 
 	int timeout = 2;
+	long flags;
 
 	if (irq > 0) {
-		cli();
+		spin_lock_irqsave(&lock, flags);
 		if (pcf_pending == 0) {
-			interruptible_sleep_on_timeout(&pcf_wait, timeout*HZ );
-		} else
+			spin_unlock_irqrestore(&lock, flags);
+			if (interruptible_sleep_on_timeout(&pcf_wait,
+								timeout*HZ)) {
+				spin_lock_irqsave(&lock, flags);
+				if (pcf_pending == 1) {
+					pcf_pending = 0;
+				}
+				spin_unlock_irqrestore(&lock, flags);
+			}
+		} else {
 			pcf_pending = 0;
-		sti();
+			spin_unlock_irqrestore(&lock, flags);
+		}
 	} else {
 		udelay(100);
 	}
@@ -126,7 +137,9 @@
 
 
 static irqreturn_t pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
+	spin_lock(&lock);
 	pcf_pending = 1;
+	spin_unlock(&lock);
 	wake_up_interruptible(&pcf_wait);
 	return IRQ_HANDLED;
 }
@@ -134,6 +147,7 @@
 
 static int pcf_isa_init(void)
 {
+	spin_lock_init(&lock);
 	if (!mmapped) {
 		if (!request_region(base, 2, "i2c (isa bus adapter)")) {
 			printk(KERN_ERR
@@ -180,11 +194,10 @@
 	/* check to see we have memory mapped PCF8584 connected to the 
 	Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
 	if (base == 0) {
+		struct pci_dev *cy693_dev;
 		
-		struct pci_dev *cy693_dev =
-                    pci_find_device(PCI_VENDOR_ID_CONTAQ, 
-		                    PCI_DEVICE_ID_CONTAQ_82C693, NULL);
-
+		cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, 
+					   PCI_DEVICE_ID_CONTAQ_82C693, NULL);
 		if (cy693_dev) {
 			char config;
 			/* yeap, we've found cypress, let's check config */
@@ -215,6 +228,7 @@
 					printk(KERN_INFO "i2c-elektor: found API UP2000 like board, will probe PCF8584 later.\n");
 				}
 			}
+			pci_dev_put(cy693_dev);
 		}
 	}
 #endif
diff -Nru a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
--- a/drivers/i2c/busses/i2c-hydra.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/i2c/busses/i2c-hydra.c	2004-12-24 13:36:47 -08:00
@@ -120,6 +120,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, hydra_ids);
+
 static int __devinit hydra_probe(struct pci_dev *dev,
 				 const struct pci_device_id *id)
 {
@@ -166,7 +168,7 @@
 
 static int __init i2c_hydra_init(void)
 {
-	return pci_module_init(&hydra_driver);
+	return pci_register_driver(&hydra_driver);
 }
 
 
diff -Nru a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
--- a/drivers/i2c/busses/i2c-i801.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/i2c/busses/i2c-i801.c	2004-12-24 13:36:49 -08:00
@@ -599,6 +599,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, i801_ids);
+
 static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 
@@ -631,7 +633,7 @@
 
 static int __init i2c_i801_init(void)
 {
-	return pci_module_init(&i801_driver);
+	return pci_register_driver(&i801_driver);
 }
 
 static void __exit i2c_i801_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c
--- a/drivers/i2c/busses/i2c-i810.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/i2c/busses/i2c-i810.c	2004-12-24 13:36:19 -08:00
@@ -70,7 +70,7 @@
 #define CYCLE_DELAY		10
 #define TIMEOUT			(HZ / 2)
 
-static void *ioaddr;
+static void __iomem *ioaddr;
 
 /* The i810 GPIO registers have individual masks for each bit
    so we never have to read before writing. Nice. */
@@ -201,6 +201,8 @@
 	{ 0, },
 };
 
+MODULE_DEVICE_TABLE (pci, i810_ids);
+
 static int __devinit i810_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	int retval;
@@ -239,7 +241,7 @@
 
 static int __init i2c_i810_init(void)
 {
-	return pci_module_init(&i810_driver);
+	return pci_register_driver(&i810_driver);
 }
 
 static void __exit i2c_i810_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
--- a/drivers/i2c/busses/i2c-ibm_iic.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/i2c/busses/i2c-ibm_iic.c	2004-12-24 13:37:03 -08:00
@@ -81,7 +81,7 @@
 #if DBG_LEVEL > 2
 static void dump_iic_regs(const char* header, struct ibm_iic_private* dev)
 {
-	volatile struct iic_regs *iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	printk(KERN_DEBUG "ibm-iic%d: %s\n", dev->idx, header);
 	printk(KERN_DEBUG "  cntl     = 0x%02x, mdcntl = 0x%02x\n"
 	       KERN_DEBUG "  sts      = 0x%02x, extsts = 0x%02x\n"
@@ -132,7 +132,7 @@
  */
 static void iic_dev_init(struct ibm_iic_private* dev)
 {
-	volatile struct iic_regs *iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 
 	DBG("%d: init\n", dev->idx);
 	
@@ -177,7 +177,7 @@
  */
 static void iic_dev_reset(struct ibm_iic_private* dev)
 {
-	volatile struct iic_regs *iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	int i;
 	u8 dc;
 	
@@ -225,7 +225,7 @@
  */
 
 /* Wait for SCL and/or SDA to be high */
-static int iic_dc_wait(volatile struct iic_regs *iic, u8 mask)
+static int iic_dc_wait(volatile struct iic_regs __iomem *iic, u8 mask)
 {
 	unsigned long x = jiffies + HZ / 28 + 2;
 	while ((in_8(&iic->directcntl) & mask) != mask){
@@ -238,7 +238,7 @@
 
 static int iic_smbus_quick(struct ibm_iic_private* dev, const struct i2c_msg* p)
 {
-	volatile struct iic_regs* iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	const struct i2c_timings* t = &timings[dev->fast_mode ? 1 : 0];
 	u8 mask, v, sda;
 	int i, res;
@@ -324,7 +324,7 @@
 static irqreturn_t iic_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct ibm_iic_private* dev = (struct ibm_iic_private*)dev_id;
-	volatile struct iic_regs* iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	
 	DBG2("%d: irq handler, STS = 0x%02x, EXTSTS = 0x%02x\n", 
 	     dev->idx, in_8(&iic->sts), in_8(&iic->extsts));
@@ -342,7 +342,7 @@
  */
 static int iic_xfer_result(struct ibm_iic_private* dev)
 {
-	volatile struct iic_regs *iic = dev->vaddr;	
+	volatile struct iic_regs __iomem *iic = dev->vaddr;	
 	
 	if (unlikely(in_8(&iic->sts) & STS_ERR)){
 		DBG("%d: xfer error, EXTSTS = 0x%02x\n", dev->idx, 
@@ -375,7 +375,7 @@
  */
 static void iic_abort_xfer(struct ibm_iic_private* dev)
 {
-	volatile struct iic_regs *iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	unsigned long x;
 	
 	DBG("%d: iic_abort_xfer\n", dev->idx);
@@ -407,25 +407,17 @@
  */
 static int iic_wait_for_tc(struct ibm_iic_private* dev){
 	
-	volatile struct iic_regs *iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	int ret = 0;
 	
 	if (dev->irq >= 0){
 		/* Interrupt mode */
-		wait_queue_t wait;
-    		init_waitqueue_entry(&wait, current);
-		
-		add_wait_queue(&dev->wq, &wait);
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (in_8(&iic->sts) & STS_PT)
-			schedule_timeout(dev->adap.timeout * HZ);
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&dev->wq, &wait);
-		
-		if (unlikely(signal_pending(current))){
+		ret = wait_event_interruptible_timeout(dev->wq, 
+			!(in_8(&iic->sts) & STS_PT), dev->adap.timeout * HZ);
+
+		if (unlikely(ret < 0))
 			DBG("%d: wait interrupted\n", dev->idx);
-			ret = -ERESTARTSYS;
-		} else if (unlikely(in_8(&iic->sts) & STS_PT)){
+		else if (unlikely(in_8(&iic->sts) & STS_PT)){
 			DBG("%d: wait timeout\n", dev->idx);
 			ret = -ETIMEDOUT;
 		}
@@ -466,7 +458,7 @@
 static int iic_xfer_bytes(struct ibm_iic_private* dev, struct i2c_msg* pm, 
 			  int combined_xfer)
 {
-	volatile struct iic_regs *iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	char* buf = pm->buf;
 	int i, j, loops, ret = 0;
 	int len = pm->len;
@@ -482,7 +474,7 @@
 		
 		if (!(cntl & CNTL_RW))
 			for (j = 0; j < count; ++j)
-				out_8((volatile u8*)&iic->mdbuf, *buf++);
+				out_8((void __iomem *)&iic->mdbuf, *buf++);
 		
 		if (i < loops - 1)
 			cmd |= CNTL_CHT;
@@ -513,7 +505,7 @@
 		
 		if (cntl & CNTL_RW)
 			for (j = 0; j < count; ++j)
-				*buf++ = in_8((volatile u8*)&iic->mdbuf);
+				*buf++ = in_8((void __iomem *)&iic->mdbuf);
 	}
 	
 	return ret > 0 ? 0 : ret;
@@ -524,7 +516,7 @@
  */
 static inline void iic_address(struct ibm_iic_private* dev, struct i2c_msg* msg)
 {
-	volatile struct iic_regs *iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	u16 addr = msg->addr;
 	
 	DBG2("%d: iic_address, 0x%03x (%d-bit)\n", dev->idx, 
@@ -560,7 +552,7 @@
 static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 {
     	struct ibm_iic_private* dev = (struct ibm_iic_private*)(i2c_get_adapdata(adap));
-	volatile struct iic_regs *iic = dev->vaddr;
+	volatile struct iic_regs __iomem *iic = dev->vaddr;
 	int i, ret = 0;
 	
 	DBG2("%d: iic_xfer, %d msg(s)\n", dev->idx, num);
@@ -763,9 +755,9 @@
 		free_irq(dev->irq, dev);
 	}	
 
-	iounmap((void*)dev->vaddr);
+	iounmap(dev->vaddr);
 fail2:	
-	ocp_set_drvdata(ocp, 0);
+	ocp_set_drvdata(ocp, NULL);
 	kfree(dev);	
 	return ret;
 }
@@ -791,7 +783,7 @@
 		    iic_interrupt_mode(dev, 0);	
 		    free_irq(dev->irq, dev);
 		}
-		iounmap((void*)dev->vaddr);
+		iounmap(dev->vaddr);
 		kfree(dev);
 	}
 }
diff -Nru a/drivers/i2c/busses/i2c-ibm_iic.h b/drivers/i2c/busses/i2c-ibm_iic.h
--- a/drivers/i2c/busses/i2c-ibm_iic.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/i2c/busses/i2c-ibm_iic.h	2004-12-24 13:36:31 -08:00
@@ -45,7 +45,7 @@
 
 struct ibm_iic_private {
 	struct i2c_adapter adap;
-	volatile struct iic_regs *vaddr;
+	volatile struct iic_regs __iomem *vaddr;
 	wait_queue_head_t wq;
 	int idx;
 	int irq;
diff -Nru a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c
--- a/drivers/i2c/busses/i2c-ite.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/i2c/busses/i2c-ite.c	2004-12-24 13:36:31 -08:00
@@ -62,6 +62,7 @@
 static struct iic_ite gpi;
 static wait_queue_head_t iic_wait;
 static int iic_pending;
+static spinlock_t lock;
 
 /* ----- local functions ----------------------------------------------	*/
 
@@ -108,6 +109,7 @@
 static void iic_ite_waitforpin(void) {
 
    int timeout = 2;
+   long flags;
 
    /* If interrupts are enabled (which they are), then put the process to
     * sleep.  This process will be awakened by two events -- either the
@@ -116,24 +118,36 @@
     * of time and return.
     */
    if (gpi.iic_irq > 0) {
-	cli();
+	spin_lock_irqsave(&lock, flags);
 	if (iic_pending == 0) {
-		interruptible_sleep_on_timeout(&iic_wait, timeout*HZ );
-	} else
+		spin_unlock_irqrestore(&lock, flags);
+		if (interruptible_sleep_on_timeout(&iic_wait, timeout*HZ)) {
+			spin_lock_irqsave(&lock, flags);
+			if (iic_pending == 1) {
+				iic_pending = 0;
+			}
+			spin_unlock_irqrestore(&lock, flags);
+		}
+	} else {
 		iic_pending = 0;
-	sti();
+		spin_unlock_irqrestore(&lock, flags);
+	}
    } else {
       udelay(100);
    }
 }
 
 
-static void iic_ite_handler(int this_irq, void *dev_id, struct pt_regs *regs) 
+static irqreturn_t iic_ite_handler(int this_irq, void *dev_id,
+							struct pt_regs *regs)
 {
-	
-   iic_pending = 1;
+	spin_lock(&lock);
+	iic_pending = 1;
+	spin_unlock(&lock);
+
+	wake_up_interruptible(&iic_wait);
 
-   wake_up_interruptible(&iic_wait);
+	return IRQ_HANDLED;
 }
 
 
@@ -221,6 +235,7 @@
 
 	iic_ite_data.data = (void *)piic;
 	init_waitqueue_head(&iic_wait);
+	spin_lock_init(&lock);
 	if (iic_hw_resrc_init() == 0) {
 		if (i2c_iic_add_bus(&iic_ite_ops) < 0)
 			return -ENODEV;
diff -Nru a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
--- a/drivers/i2c/busses/i2c-keywest.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/i2c/busses/i2c-keywest.c	2004-12-24 13:37:02 -08:00
@@ -552,9 +552,9 @@
 	iface->irq = np->intrs[0].line;
 	iface->channels = (struct keywest_chan *)
 		(((unsigned long)(iface + 1) + 3UL) & ~3UL);
-	iface->base = (unsigned long)ioremap(np->addrs[0].address + addroffset,
+	iface->base = ioremap(np->addrs[0].address + addroffset,
 						np->addrs[0].size);
-	if (iface->base == 0) {
+	if (!iface->base) {
 		printk(KERN_ERR "i2c-keywest: can't map inteface !\n");
 		kfree(iface);
 		pmac_low_i2c_unlock(np);
@@ -600,7 +600,7 @@
 	rc = request_irq(iface->irq, keywest_irq, SA_INTERRUPT, "keywest i2c", iface);
 	if (rc) {
 		printk(KERN_ERR "i2c-keywest: can't get IRQ %d !\n", iface->irq);
-		iounmap((void *)iface->base);
+		iounmap(iface->base);
 		kfree(iface);
 		pmac_low_i2c_unlock(np);
 		return -ENODEV;
@@ -685,7 +685,7 @@
 		if (rc)
 			printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
 	}
-	iounmap((void *)iface->base);
+	iounmap(iface->base);
 	dev_set_drvdata(dev, NULL);
 	of_node_put(iface->node);
 	kfree(iface);
diff -Nru a/drivers/i2c/busses/i2c-keywest.h b/drivers/i2c/busses/i2c-keywest.h
--- a/drivers/i2c/busses/i2c-keywest.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/i2c/busses/i2c-keywest.h	2004-12-24 13:37:19 -08:00
@@ -52,7 +52,7 @@
 struct keywest_iface
 {
 	struct device_node	*node;
-	unsigned long		base;
+	void __iomem *		base;
 	unsigned		bsteps;
 	int			irq;
 	spinlock_t		lock;
@@ -89,13 +89,13 @@
 
 static inline u8 __read_reg(struct keywest_iface *iface, reg_t reg)
 {
-	return in_8(((volatile u8 *)iface->base)
+	return in_8(iface->base
 		+ (((unsigned)reg) << iface->bsteps));
 }
 
 static inline void __write_reg(struct keywest_iface *iface, reg_t reg, u8 val)
 {
-	out_8(((volatile u8 *)iface->base)
+	out_8(iface->base
 		+ (((unsigned)reg) << iface->bsteps), val);
 	(void)__read_reg(iface, reg_subaddr);
 }
diff -Nru a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
--- a/drivers/i2c/busses/i2c-mpc.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/i2c/busses/i2c-mpc.c	2004-12-24 13:36:48 -08:00
@@ -23,6 +23,7 @@
 #include <asm/ocp.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #define MPC_I2C_ADDR  0x00
 #define MPC_I2C_FDR 	0x04
@@ -91,9 +92,9 @@
 		x = readb(i2c->base + MPC_I2C_SR);
 		writeb(0, i2c->base + MPC_I2C_SR);
 	} else {
+		set_current_state(TASK_INTERRUPTIBLE);
 		add_wait_queue(&i2c->queue, &wait);
 		while (!(i2c->interrupt & CSR_MIF)) {
-			set_current_state(TASK_INTERRUPTIBLE);
 			if (signal_pending(current)) {
 				pr_debug("I2C: Interrupted\n");
 				result = -EINTR;
@@ -104,9 +105,9 @@
 				result = -EIO;
 				break;
 			}
-			schedule_timeout(timeout);
+			msleep_interruptible(jiffies_to_msecs(timeout));
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&i2c->queue, &wait);
 		x = i2c->interrupt;
 		i2c->interrupt = 0;
diff -Nru a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
--- a/drivers/i2c/busses/i2c-nforce2.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/i2c/busses/i2c-nforce2.c	2004-12-24 13:36:19 -08:00
@@ -1,6 +1,7 @@
 /*
     SMBus driver for nVidia nForce2 MCP
 
+    Added nForce3 Pro 150  Thomas Leibold <thomas@plx.com>,
 	Ported to 2.5 Patrick Dreker <patrick@dreker.de>,
     Copyright (c) 2003  Hans-Frieder Vogt <hfvogt@arcor.de>,
     Based on
@@ -23,8 +24,10 @@
 */
 
 /*
-    SUPPORTED DEVICES	PCI ID
-    nForce2 MCP		0064
+    SUPPORTED DEVICES		PCI ID
+    nForce2 MCP			0064
+    nForce2 Ultra 400 MCP	0084
+    nForce3 Pro150 MCP		00D4
 
     This driver supports the 2 SMBuses that are included in the MCP2 of the
     nForce2 chipset.
@@ -49,11 +52,6 @@
 MODULE_DESCRIPTION("nForce2 SMBus driver");
 
 
-#ifndef PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS
-#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS   0x0064
-#endif
-
-
 struct nforce2_smbus {
 	struct pci_dev *dev;
 	struct i2c_adapter adapter;
@@ -294,10 +292,17 @@
 static struct pci_device_id nforce2_ids[] = {
 	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS,
 	       	PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS,
+	       	PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS,
+	       	PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
 	{ 0 }
 };
 
 
+MODULE_DEVICE_TABLE (pci, nforce2_ids);
+
+
 static int __devinit nforce2_probe_smb (struct pci_dev *dev, int reg,
 	struct nforce2_smbus *smbus, char *name)
 {
@@ -391,7 +396,7 @@
 
 static int __init nforce2_init(void)
 {
-	return pci_module_init(&nforce2_driver);
+	return pci_register_driver(&nforce2_driver);
 }
 
 static void __exit nforce2_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
--- a/drivers/i2c/busses/i2c-piix4.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/i2c/busses/i2c-piix4.c	2004-12-24 13:36:32 -08:00
@@ -459,6 +459,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, piix4_ids);
+
 static int __devinit piix4_probe(struct pci_dev *dev,
 				const struct pci_device_id *id)
 {
@@ -501,7 +503,7 @@
 
 static int __init i2c_piix4_init(void)
 {
-	return pci_module_init(&piix4_driver);
+	return pci_register_driver(&piix4_driver);
 }
 
 static void __exit i2c_piix4_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c
--- a/drivers/i2c/busses/i2c-prosavage.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/i2c/busses/i2c-prosavage.c	2004-12-24 13:36:47 -08:00
@@ -68,7 +68,7 @@
 #define MAX_BUSSES	2
 
 struct s_i2c_bus {
-	void	*mmvga;
+	void __iomem *mmvga;
 	int	i2c_reg;
 	int	adap_ok;
 	struct i2c_adapter		adap;
@@ -76,7 +76,7 @@
 };
 
 struct s_i2c_chip {
-	void	*mmio;
+	void __iomem *mmio;
 	struct s_i2c_bus	i2c_bus[MAX_BUSSES];
 };
 
@@ -181,7 +181,7 @@
 /*
  * adapter initialisation
  */
-static int i2c_register_bus(struct pci_dev *dev, struct s_i2c_bus *p, u8 *mmvga, u32 i2c_reg)
+static int i2c_register_bus(struct pci_dev *dev, struct s_i2c_bus *p, void __iomem *mmvga, u32 i2c_reg)
 {
 	int ret;
 	p->adap.owner	  = THIS_MODULE;
@@ -228,7 +228,7 @@
 
 		ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap);
 	        if (ret) {
-			dev_err(&dev->dev, ": %s not removed\n",
+			dev_err(&dev->dev, "%s not removed\n",
 				chip->i2c_bus[i].adap.name);
 		}
 	}
@@ -298,7 +298,7 @@
 	}
 	return 0;
 err_adap:
-	dev_err(&dev->dev, ": %s failed\n", bus->adap.name);
+	dev_err(&dev->dev, "%s failed\n", bus->adap.name);
 	prosavage_remove(dev);
 	return ret;
 }
@@ -313,6 +313,8 @@
 	{ 0, },
 };
 
+MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl);
+
 static struct pci_driver prosavage_driver = {
 	.name		=	"prosavage_smbus",
 	.id_table	=	prosavage_pci_tbl,
@@ -322,7 +324,7 @@
 
 static int __init i2c_prosavage_init(void)
 {
-	return pci_module_init(&prosavage_driver);
+	return pci_register_driver(&prosavage_driver);
 }
 
 static void __exit i2c_prosavage_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/i2c/busses/i2c-s3c2410.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,926 @@
+/* linux/drivers/i2c/busses/i2c-s3c2410.c
+ *
+ * Copyright (C) 2004 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C2410 I2C 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-id.h>
+#include <linux/init.h>
+#include <linux/time.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/device.h>
+
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+
+#include <asm/hardware/clock.h>
+#include <asm/arch/regs-gpio.h>
+#include <asm/arch/regs-iic.h>
+#include <asm/arch/iic.h>
+
+/* i2c controller state */
+
+enum s3c24xx_i2c_state {
+	STATE_IDLE,
+	STATE_START,
+	STATE_READ,
+	STATE_WRITE,
+	STATE_STOP
+};
+
+struct s3c24xx_i2c {
+	spinlock_t		lock;
+	wait_queue_head_t	wait;
+
+	struct i2c_msg		*msg;
+	unsigned int		msg_num;
+	unsigned int		msg_idx;
+	unsigned int		msg_ptr;
+
+	enum s3c24xx_i2c_state	state;
+
+	void __iomem		*regs;
+	struct clk		*clk;
+	struct device		*dev;
+	struct resource		*irq;
+	struct resource		*ioarea;
+	struct i2c_adapter	adap;
+};
+
+/* default platform data to use if not supplied in the platform_device
+*/
+
+static struct s3c2410_platform_i2c s3c24xx_i2c_default_platform = {
+	.flags		= 0,
+	.slave_addr	= 0x10,
+	.bus_freq	= 100*1000,
+	.max_freq	= 400*1000,
+	.sda_delay	= S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
+};
+
+/* s3c24xx_i2c_is2440()
+ *
+ * return true is this is an s3c2440
+*/
+
+static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
+{
+	struct platform_device *pdev = to_platform_device(i2c->dev);
+
+	return !strcmp(pdev->name, "s3c2440-i2c");
+}
+
+
+/* s3c24xx_i2c_get_platformdata
+ *
+ * get the platform data associated with the given device, or return
+ * the default if there is none
+*/
+
+static inline struct s3c2410_platform_i2c *s3c24xx_i2c_get_platformdata(struct device *dev)
+{
+	if (dev->platform_data != NULL)
+		return (struct s3c2410_platform_i2c *)dev->platform_data;
+
+	return &s3c24xx_i2c_default_platform;
+}
+
+/* s3c24xx_i2c_master_complete
+ *
+ * complete the message and wake up the caller, using the given return code,
+ * or zero to mean ok.
+*/
+
+static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
+{
+	dev_dbg(i2c->dev, "master_complete %d\n", ret);
+
+	i2c->msg_ptr = 0;
+	i2c->msg = NULL;
+	i2c->msg_idx ++;
+	i2c->msg_num = 0;
+	if (ret)
+		i2c->msg_idx = ret;
+
+	wake_up(&i2c->wait);
+}
+
+static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c)
+{
+	unsigned long tmp;
+	
+	tmp = readl(i2c->regs + S3C2410_IICCON);
+	writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
+
+}
+
+static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)
+{
+	unsigned long tmp;
+	
+	tmp = readl(i2c->regs + S3C2410_IICCON);
+	writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
+
+}
+
+/* irq enable/disable functions */
+
+static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
+{
+	unsigned long tmp;
+	
+	tmp = readl(i2c->regs + S3C2410_IICCON);
+	writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
+}
+
+static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)
+{
+	unsigned long tmp;
+	
+	tmp = readl(i2c->regs + S3C2410_IICCON);
+	writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
+}
+
+
+/* s3c24xx_i2c_message_start
+ *
+ * put the start of a message onto the bus 
+*/
+
+static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, 
+				      struct i2c_msg *msg)
+{
+	unsigned int addr = (msg->addr & 0x7f) << 1;
+	unsigned long stat;
+	unsigned long iiccon;
+
+	stat = 0;
+	stat |=  S3C2410_IICSTAT_TXRXEN;
+
+	if (msg->flags & I2C_M_RD) {
+		stat |= S3C2410_IICSTAT_MASTER_RX;
+		addr |= 1;
+	} else
+		stat |= S3C2410_IICSTAT_MASTER_TX;
+
+	// todo - check for wether ack wanted or not
+	s3c24xx_i2c_enable_ack(i2c);
+
+	iiccon = readl(i2c->regs + S3C2410_IICCON);
+	writel(stat, i2c->regs + S3C2410_IICSTAT);
+	
+	dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr);
+	writeb(addr, i2c->regs + S3C2410_IICDS);
+	
+	// delay a bit and reset iiccon before setting start (per samsung)
+	udelay(1);
+	dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon);
+	writel(iiccon, i2c->regs + S3C2410_IICCON);
+	
+	stat |=  S3C2410_IICSTAT_START;
+	writel(stat, i2c->regs + S3C2410_IICSTAT);
+}
+
+static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
+{
+	unsigned long iicstat = readl(i2c->regs + S3C2410_IICSTAT);
+
+	dev_dbg(i2c->dev, "STOP\n");
+
+	/* stop the transfer */
+	iicstat &= ~ S3C2410_IICSTAT_START;
+	writel(iicstat, i2c->regs + S3C2410_IICSTAT);
+	
+	i2c->state = STATE_STOP;
+	
+	s3c24xx_i2c_master_complete(i2c, ret);
+	s3c24xx_i2c_disable_irq(i2c);
+}
+
+/* helper functions to determine the current state in the set of
+ * messages we are sending */
+
+/* is_lastmsg()
+ *
+ * returns TRUE if the current message is the last in the set 
+*/
+
+static inline int is_lastmsg(struct s3c24xx_i2c *i2c)
+{
+	return i2c->msg_idx >= (i2c->msg_num - 1);
+}
+
+/* is_msglast
+ *
+ * returns TRUE if we this is the last byte in the current message
+*/
+
+static inline int is_msglast(struct s3c24xx_i2c *i2c)
+{
+	return i2c->msg_ptr == i2c->msg->len-1;
+}
+
+/* is_msgend
+ *
+ * returns TRUE if we reached the end of the current message
+*/
+
+static inline int is_msgend(struct s3c24xx_i2c *i2c)
+{
+	return i2c->msg_ptr >= i2c->msg->len;
+}
+
+/* i2s_s3c_irq_nextbyte
+ *
+ * process an interrupt and work out what to do
+ */
+
+static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
+{
+	unsigned long tmp;
+	unsigned char byte;
+	int ret = 0;
+
+	switch (i2c->state) {
+
+	case STATE_IDLE:
+		dev_err(i2c->dev, "%s: called in STATE_IDLE\n", __FUNCTION__);
+		goto out;
+		break;
+
+	case STATE_STOP:
+		dev_err(i2c->dev, "%s: called in STATE_STOP\n", __FUNCTION__);
+		s3c24xx_i2c_disable_irq(i2c);		
+		goto out_ack;
+
+	case STATE_START:
+		/* last thing we did was send a start condition on the
+		 * bus, or started a new i2c message
+		 */
+		
+		if (iicstat  & S3C2410_IICSTAT_LASTBIT &&
+		    !(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
+			/* ack was not received... */
+
+			dev_err(i2c->dev, "ack was not received\n" );
+			s3c24xx_i2c_stop(i2c, -EREMOTEIO);
+			goto out_ack;
+		}
+
+		if (i2c->msg->flags & I2C_M_RD)
+			i2c->state = STATE_READ;
+		else
+			i2c->state = STATE_WRITE;
+
+		/* terminate the transfer if there is nothing to do
+		 * (used by the i2c probe to find devices */
+
+		if (is_lastmsg(i2c) && i2c->msg->len == 0) {
+			s3c24xx_i2c_stop(i2c, 0);
+			goto out_ack;
+		}
+
+		if (i2c->state == STATE_READ)
+			goto prepare_read;
+
+		/* fall through to the write state, as we will need to 
+		 * send a byte as well */
+
+	case STATE_WRITE:
+		/* we are writing data to the device... check for the
+		 * end of the message, and if so, work out what to do
+		 */
+
+	retry_write:
+		if (!is_msgend(i2c)) {
+			byte = i2c->msg->buf[i2c->msg_ptr++];
+			writeb(byte, i2c->regs + S3C2410_IICDS);
+			
+		} else if (!is_lastmsg(i2c)) {
+			/* we need to go to the next i2c message */
+
+			dev_dbg(i2c->dev, "WRITE: Next Message\n");
+
+			i2c->msg_ptr = 0;
+			i2c->msg_idx ++;
+			i2c->msg++;
+			
+			/* check to see if we need to do another message */
+			if (i2c->msg->flags & I2C_M_NOSTART) {
+
+				if (i2c->msg->flags & I2C_M_RD) {
+					/* cannot do this, the controller
+					 * forces us to send a new START
+					 * when we change direction */
+
+					s3c24xx_i2c_stop(i2c, -EINVAL);
+				}
+
+				goto retry_write;
+			} else {
+			
+				/* send the new start */
+				s3c24xx_i2c_message_start(i2c, i2c->msg);
+				i2c->state = STATE_START;
+			}
+
+		} else {
+			/* send stop */
+
+			s3c24xx_i2c_stop(i2c, 0);
+		}
+		break;
+
+	case STATE_READ:
+		/* we have a byte of data in the data register, do 
+		 * something with it, and then work out wether we are
+		 * going to do any more read/write
+		 */
+
+		if (!(i2c->msg->flags & I2C_M_IGNORE_NAK) &&
+		    !(is_msglast(i2c) && is_lastmsg(i2c))) {
+
+			if (iicstat & S3C2410_IICSTAT_LASTBIT) {
+				dev_dbg(i2c->dev, "READ: No Ack\n");
+
+				s3c24xx_i2c_stop(i2c, -ECONNREFUSED);
+				goto out_ack;
+			}
+		}
+
+		byte = readb(i2c->regs + S3C2410_IICDS);
+		i2c->msg->buf[i2c->msg_ptr++] = byte;
+
+	prepare_read:
+		if (is_msglast(i2c)) {
+			/* last byte of buffer */
+
+			if (is_lastmsg(i2c))
+				s3c24xx_i2c_disable_ack(i2c);
+			
+		} else if (is_msgend(i2c)) {
+			/* ok, we've read the entire buffer, see if there
+			 * is anything else we need to do */
+
+			if (is_lastmsg(i2c)) {
+				/* last message, send stop and complete */
+				dev_dbg(i2c->dev, "READ: Send Stop\n");
+
+				s3c24xx_i2c_stop(i2c, 0);
+			} else {
+				/* go to the next transfer */
+				dev_dbg(i2c->dev, "READ: Next Transfer\n");
+
+				i2c->msg_ptr = 0;
+				i2c->msg_idx++;
+				i2c->msg++;
+			}
+		}
+
+		break;
+	}
+
+	/* acknowlegde the IRQ and get back on with the work */
+
+ out_ack:
+	tmp = readl(i2c->regs + S3C2410_IICCON);	
+	tmp &= ~S3C2410_IICCON_IRQPEND;
+	writel(tmp, i2c->regs + S3C2410_IICCON);
+ out:
+	return ret;
+}
+
+/* s3c24xx_i2c_irq
+ *
+ * top level IRQ servicing routine
+*/
+
+static irqreturn_t s3c24xx_i2c_irq(int irqno, void *dev_id,
+				   struct pt_regs *regs)
+{
+	struct s3c24xx_i2c *i2c = dev_id;
+	unsigned long status;
+	unsigned long tmp;
+
+	status = readl(i2c->regs + S3C2410_IICSTAT);
+
+	if (status & S3C2410_IICSTAT_ARBITR) {
+		// deal with arbitration loss
+		dev_err(i2c->dev, "deal with arbitration loss\n");
+	}
+
+	if (i2c->state == STATE_IDLE) {
+		dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n");
+
+		tmp = readl(i2c->regs + S3C2410_IICCON);	
+		tmp &= ~S3C2410_IICCON_IRQPEND;
+		writel(tmp, i2c->regs +  S3C2410_IICCON);
+		goto out;
+	}
+	
+	/* pretty much this leaves us with the fact that we've
+	 * transmitted or received whatever byte we last sent */
+
+	i2s_s3c_irq_nextbyte(i2c, status);
+
+ out:
+	return IRQ_HANDLED;
+}
+
+
+/* s3c24xx_i2c_set_master
+ *
+ * get the i2c bus for a master transaction
+*/
+
+static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
+{
+	unsigned long iicstat;
+	int timeout = 400;
+
+	while (timeout-- > 0) {
+		iicstat = readl(i2c->regs + S3C2410_IICSTAT);
+		
+		if (!(iicstat & S3C2410_IICSTAT_BUSBUSY))
+			return 0;
+
+		msleep(1);
+	}
+
+	dev_dbg(i2c->dev, "timeout: GPEDAT is %08x\n",
+		__raw_readl(S3C2410_GPEDAT));
+
+	return -ETIMEDOUT;
+}
+
+/* s3c24xx_i2c_doxfer
+ *
+ * this starts an i2c transfer
+*/
+
+static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg msgs[], int num)
+{
+	unsigned long timeout;
+	int ret;
+
+	ret = s3c24xx_i2c_set_master(i2c);
+	if (ret != 0) {
+		dev_err(i2c->dev, "cannot get bus (error %d)\n", ret);
+		ret = -EAGAIN;
+		goto out;
+	}
+
+	spin_lock_irq(&i2c->lock);
+
+	i2c->msg     = msgs;
+	i2c->msg_num = num;
+	i2c->msg_ptr = 0;
+	i2c->msg_idx = 0;
+	i2c->state   = STATE_START;
+
+	s3c24xx_i2c_enable_irq(i2c);
+	s3c24xx_i2c_message_start(i2c, msgs);
+	spin_unlock_irq(&i2c->lock);
+	
+	timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
+
+	ret = i2c->msg_idx;
+
+	/* having these next two as dev_err() makes life very 
+	 * noisy when doing an i2cdetect */
+
+	if (timeout == 0)
+		dev_dbg(i2c->dev, "timeout\n");
+	else if (ret != num)
+		dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret);
+
+	/* ensure the stop has been through the bus */
+
+	msleep(1);
+
+ out:
+	return ret;
+}
+
+/* s3c24xx_i2c_xfer
+ *
+ * first port of call from the i2c bus code when an message needs
+ * transfering across the i2c bus.
+*/
+
+static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
+			struct i2c_msg msgs[], int num)
+{
+	struct s3c24xx_i2c *i2c = (struct s3c24xx_i2c *)adap->algo_data;
+	int retry;
+	int ret;
+
+	for (retry = 0; retry < adap->retries; retry++) {
+
+		ret = s3c24xx_i2c_doxfer(i2c, msgs, num);
+
+		if (ret != -EAGAIN)
+			return ret;
+
+		dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry);
+
+		udelay(100);
+	}
+
+	return -EREMOTEIO;
+}
+
+/* i2c bus registration info */
+
+static struct i2c_algorithm s3c24xx_i2c_algorithm = {
+	.name			= "S3C2410-I2C-Algorithm",
+	.master_xfer		= s3c24xx_i2c_xfer,
+};
+
+static struct s3c24xx_i2c s3c24xx_i2c = {
+	.lock	= SPIN_LOCK_UNLOCKED,
+	.wait	= __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait),
+	.adap	= {
+		.name			= "s3c2410-i2c",
+		.algo			= &s3c24xx_i2c_algorithm,
+		.retries		= 2,
+	},
+};
+
+/* s3c24xx_i2c_calcdivisor
+ *
+ * return the divisor settings for a given frequency
+*/
+
+static int s3c24xx_i2c_calcdivisor(unsigned long clkin, unsigned int wanted,
+				   unsigned int *div1, unsigned int *divs)
+{
+	unsigned int calc_divs = clkin / wanted;
+	unsigned int calc_div1;
+
+	if (calc_divs > (16*16))
+		calc_div1 = 512;
+	else
+		calc_div1 = 16;
+
+	calc_divs += calc_div1-1;
+	calc_divs /= calc_div1;
+
+	if (calc_divs == 0)
+		calc_divs = 1;
+	if (calc_divs > 17)
+		calc_divs = 17;
+
+	*divs = calc_divs;
+	*div1 = calc_div1;
+
+	return clkin / (calc_divs * calc_div1);
+}
+
+/* freq_acceptable
+ *
+ * test wether a frequency is within the acceptable range of error
+*/
+
+static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
+{
+	int diff = freq - wanted;
+
+	return (diff >= -2 && diff <= 2);
+}
+
+/* s3c24xx_i2c_getdivisor
+ *
+ * work out a divisor for the user requested frequency setting,
+ * either by the requested frequency, or scanning the acceptable
+ * range of frequencies until something is found
+*/
+
+static int s3c24xx_i2c_getdivisor(struct s3c24xx_i2c *i2c,
+				  struct s3c2410_platform_i2c *pdata,
+				  unsigned long *iicon,
+				  unsigned int *got)
+{
+	unsigned long clkin = clk_get_rate(i2c->clk);
+	
+	unsigned int divs, div1;
+	int freq;
+	int start, end;
+
+	clkin /= 1000;		/* clkin now in KHz */
+     
+	dev_dbg(i2c->dev,  "pdata %p, freq %lu %lu..%lu\n",
+		 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq);
+
+	if (pdata->bus_freq != 0) {
+		freq = s3c24xx_i2c_calcdivisor(clkin, pdata->bus_freq/1000,
+					       &div1, &divs);
+		if (freq_acceptable(freq, pdata->bus_freq/1000))
+			goto found;
+	}
+
+	/* ok, we may have to search for something suitable... */
+
+	start = (pdata->max_freq == 0) ? pdata->bus_freq : pdata->max_freq;
+	end = pdata->min_freq;
+
+	start /= 1000;
+	end /= 1000;
+
+	/* search loop... */
+
+	for (; start > end; start--) {
+		freq = s3c24xx_i2c_calcdivisor(clkin, start, &div1, &divs);
+		if (freq_acceptable(freq, start))
+			goto found;
+	}
+
+	/* cannot find frequency spec */
+
+	return -EINVAL;
+
+ found:
+	*got = freq;
+	*iicon |= (divs-1);
+	*iicon |= (div1 == 512) ? S3C2410_IICCON_TXDIV_512 : 0;
+	return 0;
+}
+
+/* s3c24xx_i2c_init
+ *
+ * initialise the controller, set the IO lines and frequency 
+*/
+
+static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
+{
+	unsigned long iicon = S3C2410_IICCON_IRQEN | S3C2410_IICCON_ACKEN;
+	struct s3c2410_platform_i2c *pdata;
+	unsigned int freq;
+
+	/* get the plafrom data */
+
+	pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
+
+	/* inititalise the gpio */
+
+	s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_IICSDA);
+	s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL);
+
+	/* write slave address */
+	
+	writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD);
+
+	dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);
+
+	/* we need to work out the divisors for the clock... */
+
+	if (s3c24xx_i2c_getdivisor(i2c, pdata, &iicon, &freq) != 0) {
+		dev_err(i2c->dev, "cannot meet bus frequency required\n");
+		return -EINVAL;
+	}
+
+	/* todo - check that the i2c lines aren't being dragged anywhere */
+
+	dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq);
+	dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02lx\n", iicon);
+	
+	writel(iicon, i2c->regs + S3C2410_IICCON);
+
+	/* check for s3c2440 i2c controller  */
+
+	if (s3c24xx_i2c_is2440(i2c)) {
+		dev_dbg(i2c->dev, "S3C2440_IICLC=%08x\n", pdata->sda_delay);
+
+		writel(pdata->sda_delay, i2c->regs + S3C2440_IICLC);
+	}
+
+	return 0;
+}
+
+static void s3c24xx_i2c_free(struct s3c24xx_i2c *i2c)
+{
+	if (i2c->clk != NULL && !IS_ERR(i2c->clk)) {
+		clk_disable(i2c->clk);
+		clk_unuse(i2c->clk);
+		clk_put(i2c->clk);
+		i2c->clk = NULL;
+	}
+
+	if (i2c->regs != NULL) {
+		iounmap(i2c->regs);
+		i2c->regs = NULL;
+	}
+
+	if (i2c->ioarea != NULL) {
+		release_resource(i2c->ioarea);
+		kfree(i2c->ioarea);
+		i2c->ioarea = NULL;
+	}
+}
+
+/* s3c24xx_i2c_probe
+ *
+ * called by the bus driver when a suitable device is found
+*/
+
+static int s3c24xx_i2c_probe(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
+	struct resource *res;
+	int ret;
+
+	/* find the clock and enable it */
+
+	i2c->dev = dev;
+	i2c->clk = clk_get(dev, "i2c");
+	if (IS_ERR(i2c->clk)) {
+		dev_err(dev, "cannot get clock\n");
+		ret = -ENOENT;
+		goto out;
+	}
+
+	dev_dbg(dev, "clock source %p\n", i2c->clk);
+
+	clk_use(i2c->clk);
+	clk_enable(i2c->clk);
+
+	/* map the registers */
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(dev, "cannot find IO resource\n");
+		ret = -ENOENT;
+		goto out;
+	}
+
+	i2c->ioarea = request_mem_region(res->start, (res->end-res->start)+1,
+					 pdev->name);
+
+	if (i2c->ioarea == NULL) {
+		dev_err(dev, "cannot request IO\n");
+		ret = -ENXIO;
+		goto out;
+	}
+
+	i2c->regs = ioremap(res->start, (res->end-res->start)+1);
+
+	if (i2c->regs == NULL) {
+		dev_err(dev, "cannot map IO\n");
+		ret = -ENXIO;
+		goto out;
+	}
+
+	dev_dbg(dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);
+
+	/* setup info block for the i2c core */
+
+	i2c->adap.algo_data = i2c;
+	i2c->adap.dev.parent = dev;
+
+	/* initialise the i2c controller */
+
+	ret = s3c24xx_i2c_init(i2c);
+	if (ret != 0)
+		goto out;
+
+	/* find the IRQ for this unit (note, this relies on the init call to
+	 * ensure no current IRQs pending 
+	 */
+
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (res == NULL) {
+		dev_err(dev, "cannot find IRQ\n");
+		ret = -ENOENT;
+		goto out;
+	}
+
+	ret = request_irq(res->start, s3c24xx_i2c_irq, SA_INTERRUPT,
+			  pdev->name, i2c);
+
+	if (ret != 0) {
+		dev_err(dev, "cannot claim IRQ\n");
+		goto out;
+	}
+
+	i2c->irq = res;
+		
+	dev_dbg(dev, "irq resource %p (%ld)\n", res, res->start);
+
+	ret = i2c_add_adapter(&i2c->adap);
+	if (ret < 0) {
+		dev_err(dev, "failed to add bus to i2c core\n");
+		goto out;
+	}
+
+	dev_set_drvdata(dev, i2c);
+
+	dev_info(dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);
+
+ out:
+	if (ret < 0)
+		s3c24xx_i2c_free(i2c);
+
+	return ret;
+}
+
+/* s3c24xx_i2c_remove
+ *
+ * called when device is removed from the bus
+*/
+
+static int s3c24xx_i2c_remove(struct device *dev)
+{
+	struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
+	
+	if (i2c != NULL) {
+		s3c24xx_i2c_free(i2c);
+		dev_set_drvdata(dev, NULL);
+	}
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int s3c24xx_i2c_resume(struct device *dev, u32 level)
+{
+	struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
+	
+	if (i2c != NULL && level == RESUME_ENABLE) {
+		dev_dbg(dev, "resume: level %d\n", level);
+		s3c24xx_i2c_init(i2c);
+	}
+
+	return 0;
+}
+
+#else
+#define s3c24xx_i2c_resume NULL
+#endif
+
+/* device driver for platform bus bits */
+
+static struct device_driver s3c2410_i2c_driver = {
+	.name		= "s3c2410-i2c",
+	.bus		= &platform_bus_type,
+	.probe		= s3c24xx_i2c_probe,
+	.remove		= s3c24xx_i2c_remove,
+	.resume		= s3c24xx_i2c_resume,
+};
+
+static struct device_driver s3c2440_i2c_driver = {
+	.name		= "s3c2440-i2c",
+	.bus		= &platform_bus_type,
+	.probe		= s3c24xx_i2c_probe,
+	.remove		= s3c24xx_i2c_remove,
+	.resume		= s3c24xx_i2c_resume,
+};
+
+static int __init i2c_adap_s3c_init(void)
+{
+	int ret;
+
+	ret = driver_register(&s3c2410_i2c_driver);
+	if (ret == 0)
+		ret = driver_register(&s3c2440_i2c_driver); 
+
+	return ret;
+}
+
+static void __exit i2c_adap_s3c_exit(void)
+{
+	driver_unregister(&s3c2410_i2c_driver);
+	driver_unregister(&s3c2440_i2c_driver);
+}
+
+module_init(i2c_adap_s3c_init);
+module_exit(i2c_adap_s3c_exit);
+
+MODULE_DESCRIPTION("S3C24XX I2C Bus driver");
+MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
--- a/drivers/i2c/busses/i2c-savage4.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/i2c/busses/i2c-savage4.c	2004-12-24 13:36:49 -08:00
@@ -73,7 +73,7 @@
 #define TIMEOUT			(HZ / 2)
 
 
-static void *ioaddr;
+static void __iomem *ioaddr;
 
 /* The sav GPIO registers don't have individual masks for each bit
    so we always have to read before writing. */
@@ -157,6 +157,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, savage4_ids);
+
 static int __devinit savage4_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	int retval;
@@ -186,7 +188,7 @@
 
 static int __init i2c_savage4_init(void)
 {
-	return pci_module_init(&savage4_driver);
+	return pci_register_driver(&savage4_driver);
 }
 
 static void __exit i2c_savage4_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
--- a/drivers/i2c/busses/i2c-sis5595.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/i2c/busses/i2c-sis5595.c	2004-12-24 13:36:47 -08:00
@@ -371,6 +371,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, sis5595_ids);
+
 static int __devinit sis5595_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	if (sis5595_setup(dev)) {
@@ -401,7 +403,7 @@
 
 static int __init i2c_sis5595_init(void)
 {
-	return pci_module_init(&sis5595_driver);
+	return pci_register_driver(&sis5595_driver);
 }
 
 static void __exit i2c_sis5595_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
--- a/drivers/i2c/busses/i2c-sis630.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/i2c/busses/i2c-sis630.c	2004-12-24 13:36:31 -08:00
@@ -468,6 +468,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, sis630_ids);
+
 static int __devinit sis630_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	if (sis630_setup(dev)) {
@@ -503,7 +505,7 @@
 
 static int __init i2c_sis630_init(void)
 {
-	return pci_module_init(&sis630_driver);
+	return pci_register_driver(&sis630_driver);
 }
 
 
diff -Nru a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
--- a/drivers/i2c/busses/i2c-sis96x.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/i2c/busses/i2c-sis96x.c	2004-12-24 13:36:32 -08:00
@@ -278,6 +278,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, sis96x_ids);
+
 static int __devinit sis96x_probe(struct pci_dev *dev,
 				const struct pci_device_id *id)
 {
@@ -348,7 +350,7 @@
 static int __init i2c_sis96x_init(void)
 {
 	printk(KERN_INFO "i2c-sis96x version %s\n", SIS96x_VERSION);
-	return pci_module_init(&sis96x_driver);
+	return pci_register_driver(&sis96x_driver);
 }
 
 static void __exit i2c_sis96x_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/i2c/busses/i2c-stub.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,125 @@
+/*
+    i2c-stub.c - Part of lm_sensors, Linux kernel modules for hardware
+              monitoring
+
+    Copyright (c) 2004 Mark M. Hoffman <mhoffman@lightlink.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 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.
+*/
+
+#define DEBUG 1
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/i2c.h>
+
+static u8  stub_bytes[256];
+static u16 stub_words[256];
+
+/* Return -1 on error. */
+static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
+	char read_write, u8 command, int size, union i2c_smbus_data * data)
+{
+	s32 ret;
+
+	switch (size) {
+
+	case I2C_SMBUS_QUICK:
+		dev_dbg(&adap->dev, "smbus quick - addr 0x%02x\n", addr);
+		ret = 0;
+		break;
+
+	case I2C_SMBUS_BYTE_DATA:
+		if (read_write == I2C_SMBUS_WRITE) {
+			stub_bytes[command] = data->byte;
+			dev_dbg(&adap->dev, "smbus byte data - addr 0x%02x, "
+					"wrote 0x%02x at 0x%02x.\n",
+					addr, data->byte, command);
+		} else {
+			data->byte = stub_bytes[command];
+			dev_dbg(&adap->dev, "smbus byte data - addr 0x%02x, "
+					"read  0x%02x at 0x%02x.\n",
+					addr, data->byte, command);
+		}
+
+		ret = 0;
+		break;
+
+	case I2C_SMBUS_WORD_DATA:
+		if (read_write == I2C_SMBUS_WRITE) {
+			stub_words[command] = data->word;
+			dev_dbg(&adap->dev, "smbus word data - addr 0x%02x, "
+					"wrote 0x%04x at 0x%02x.\n",
+					addr, data->word, command);
+		} else {
+			data->word = stub_words[command];
+			dev_dbg(&adap->dev, "smbus word data - addr 0x%02x, "
+					"read  0x%04x at 0x%02x.\n",
+					addr, data->word, command);
+		}
+
+		ret = 0;
+		break;
+
+	default:
+		dev_dbg(&adap->dev, "Unsupported I2C/SMBus command\n");
+		ret = -1;
+		break;
+	} /* switch (size) */
+
+	return ret;
+}
+
+static u32 stub_func(struct i2c_adapter *adapter)
+{
+	return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE_DATA |
+		I2C_FUNC_SMBUS_WORD_DATA;
+}
+
+static struct i2c_algorithm smbus_algorithm = {
+	.name		= "Non-I2C SMBus adapter",
+	.id		= I2C_ALGO_SMBUS,
+	.functionality	= stub_func,
+	.smbus_xfer	= stub_xfer,
+};
+
+static struct i2c_adapter stub_adapter = {
+	.owner		= THIS_MODULE,
+	.class		= I2C_CLASS_HWMON,
+	.algo		= &smbus_algorithm,
+	.name		= "SMBus stub driver",
+};
+
+static int __init i2c_stub_init(void)
+{
+	printk(KERN_INFO "i2c-stub loaded\n");
+	return i2c_add_adapter(&stub_adapter);
+}
+
+static void __exit i2c_stub_exit(void)
+{
+	i2c_del_adapter(&stub_adapter);
+}
+
+MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
+MODULE_DESCRIPTION("I2C stub driver");
+MODULE_LICENSE("GPL");
+
+module_init(i2c_stub_init);
+module_exit(i2c_stub_exit);
+
diff -Nru a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
--- a/drivers/i2c/busses/i2c-via.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/i2c/busses/i2c-via.c	2004-12-24 13:36:55 -08:00
@@ -99,6 +99,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, vt586b_ids);
+
 static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	u16 base;
@@ -166,7 +168,7 @@
 
 static int __init i2c_vt586b_init(void)
 {
-	return pci_module_init(&vt586b_driver);
+	return pci_register_driver(&vt586b_driver);
 }
 
 static void __exit i2c_vt586b_exit(void)
diff -Nru a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
--- a/drivers/i2c/busses/i2c-viapro.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/i2c/busses/i2c-viapro.c	2004-12-24 13:37:03 -08:00
@@ -454,6 +454,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, vt596_ids);
+
 static struct pci_driver vt596_driver = {
 	.name		= "vt596_smbus",
 	.id_table	= vt596_ids,
@@ -463,7 +465,7 @@
 
 static int __init i2c_vt596_init(void)
 {
-	return pci_module_init(&vt596_driver);
+	return pci_register_driver(&vt596_driver);
 }
 
 
diff -Nru a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
--- a/drivers/i2c/busses/i2c-voodoo3.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/i2c/busses/i2c-voodoo3.c	2004-12-24 13:36:48 -08:00
@@ -61,7 +61,7 @@
 #define TIMEOUT		(HZ / 2)
 
 
-static void *ioaddr;
+static void __iomem *ioaddr;
 
 /* The voo GPIO registers don't have individual masks for each bit
    so we always have to read before writing. */
@@ -195,6 +195,8 @@
 	{ 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, voodoo3_ids);
+
 static int __devinit voodoo3_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	int retval;
@@ -232,7 +234,7 @@
 
 static int __init i2c_voodoo3_init(void)
 {
-	return pci_module_init(&voodoo3_driver);
+	return pci_register_driver(&voodoo3_driver);
 }
 
 static void __exit i2c_voodoo3_exit(void)
diff -Nru a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
--- a/drivers/i2c/busses/scx200_acb.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/i2c/busses/scx200_acb.c	2004-12-24 13:36:49 -08:00
@@ -45,8 +45,7 @@
 
 #define MAX_DEVICES 4
 static int base[MAX_DEVICES] = { 0x820, 0x840 };
-static int num_base;
-module_param_array(base, int, num_base, 0);
+module_param_array(base, int, NULL, 0);
 MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
 
 #ifdef DEBUG
@@ -403,9 +402,9 @@
 	.functionality	= scx200_acb_func,
 };
 
-struct scx200_acb_iface *scx200_acb_list;
+static struct scx200_acb_iface *scx200_acb_list;
 
-int scx200_acb_probe(struct scx200_acb_iface *iface)
+static int scx200_acb_probe(struct scx200_acb_iface *iface)
 {
 	u8 val;
 
@@ -503,6 +502,12 @@
 	return rc;
 }
 
+static struct pci_device_id scx200[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) },
+	{ },
+};
+
 static int __init scx200_acb_init(void)
 {
 	int i;
@@ -511,12 +516,7 @@
 	pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n");
 
 	/* Verify that this really is a SCx200 processor */
-	if (pci_find_device(PCI_VENDOR_ID_NS,
-			    PCI_DEVICE_ID_NS_SCx200_BRIDGE,
-			    NULL) == NULL
-	    && pci_find_device(PCI_VENDOR_ID_NS,
-			       PCI_DEVICE_ID_NS_SC1100_BRIDGE,
-			       NULL) == NULL)
+	if (pci_dev_present(scx200) == 0)
 		return -ENODEV;
 
 	rc = -ENXIO;
diff -Nru a/drivers/i2c/busses/scx200_i2c.c b/drivers/i2c/busses/scx200_i2c.c
--- a/drivers/i2c/busses/scx200_i2c.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/i2c/busses/scx200_i2c.c	2004-12-24 13:36:49 -08:00
@@ -86,7 +86,7 @@
 	.name	= "NatSemi SCx200 I2C",
 };
 
-int scx200_i2c_init(void)
+static int scx200_i2c_init(void)
 {
 	pr_debug(NAME ": NatSemi SCx200 I2C Driver\n");
 
@@ -115,7 +115,7 @@
 	return 0;
 }
 
-void scx200_i2c_cleanup(void)
+static void scx200_i2c_cleanup(void)
 {
 	i2c_bit_del_bus(&scx200_i2c_ops);
 }
diff -Nru a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
--- a/drivers/i2c/chips/Kconfig	2004-12-24 13:36:56 -08:00
+++ b/drivers/i2c/chips/Kconfig	2004-12-24 13:36:56 -08:00
@@ -32,6 +32,15 @@
 	  This driver can also be built as a module.  If so, the module
 	  will be called adm1025.
 
+config SENSORS_ADM1026
+	tristate "Analog Devices ADM1026 and compatibles"
+	depends on I2C && EXPERIMENTAL
+	select I2C_SENSOR
+	help
+	  If you say yes here you get support for Analog Devices ADM1026
+	  This driver can also be built as a module.  If so, the module
+	  will be called adm1026.
+
 config SENSORS_ADM1031
 	tristate "Analog Devices ADM1031 and compatibles"
 	depends on I2C && EXPERIMENTAL
@@ -97,6 +106,19 @@
 	  This driver can also be built as a module.  If so, the module
 	  will be called it87.
 
+config SENSORS_LM63
+	tristate "National Semiconductor LM63"
+	depends on I2C && EXPERIMENTAL
+	select I2C_SENSOR
+	help
+	  If you say yes here you get support for the National Semiconductor
+	  LM63 remote diode digital temperature sensor with integrated fan
+	  control.  Such chips are found on the Tyan S4882 (Thunder K8QS Pro)
+	  motherboard, among others.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called lm63.
+
 config SENSORS_LM75
 	tristate "National Semiconductor LM75 and compatibles"
 	depends on I2C && EXPERIMENTAL
@@ -169,6 +191,17 @@
 	  This driver can also be built as a module.  If so, the module
 	  will be called lm85.
 
+config SENSORS_LM87
+	tristate "National Semiconductor LM87"
+	depends on I2C && EXPERIMENTAL
+	select I2C_SENSOR
+	help
+	  If you say yes here you get support for National Semiconductor LM87
+	  sensor chips.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called lm87.
+
 config SENSORS_LM90
 	tristate "National Semiconductor LM90 and compatibles"
 	depends on I2C
@@ -190,6 +223,21 @@
 	  
 	  This driver can also be built as a module.  If so, the module
 	  will be called max1619.
+
+config SENSORS_PC87360
+	tristate "National Semiconductor PC87360 family"
+	depends on I2C && EXPERIMENTAL
+	select I2C_SENSOR
+	select I2C_ISA
+	help
+	  If you say yes here you get access to the hardware monitoring
+	  functions of the National Semiconductor PC8736x Super-I/O chips.
+	  The PC87360, PC87363 and PC87364 only have fan monitoring and
+	  control.  The PC87365 and PC87366 additionally have voltage and
+	  temperature monitoring.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called pc87360.
 
 config SENSORS_SMSC47M1
 	tristate "SMSC LPC47M10x and compatibles"
diff -Nru a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
--- a/drivers/i2c/chips/Makefile	2004-12-24 13:37:43 -08:00
+++ b/drivers/i2c/chips/Makefile	2004-12-24 13:37:43 -08:00
@@ -9,20 +9,24 @@
 
 obj-$(CONFIG_SENSORS_ADM1021)	+= adm1021.o
 obj-$(CONFIG_SENSORS_ADM1025)	+= adm1025.o
+obj-$(CONFIG_SENSORS_ADM1026)	+= adm1026.o
 obj-$(CONFIG_SENSORS_ADM1031)	+= adm1031.o
 obj-$(CONFIG_SENSORS_DS1621)	+= ds1621.o
 obj-$(CONFIG_SENSORS_EEPROM)	+= eeprom.o
 obj-$(CONFIG_SENSORS_FSCHER)	+= fscher.o
 obj-$(CONFIG_SENSORS_GL518SM)	+= gl518sm.o
 obj-$(CONFIG_SENSORS_IT87)	+= it87.o
+obj-$(CONFIG_SENSORS_LM63)	+= lm63.o
 obj-$(CONFIG_SENSORS_LM75)	+= lm75.o
 obj-$(CONFIG_SENSORS_LM77)	+= lm77.o
 obj-$(CONFIG_SENSORS_LM78)	+= lm78.o
 obj-$(CONFIG_SENSORS_LM80)	+= lm80.o
 obj-$(CONFIG_SENSORS_LM83)	+= lm83.o
 obj-$(CONFIG_SENSORS_LM85)	+= lm85.o
+obj-$(CONFIG_SENSORS_LM87)	+= lm87.o
 obj-$(CONFIG_SENSORS_LM90)	+= lm90.o
 obj-$(CONFIG_SENSORS_MAX1619)	+= max1619.o
+obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
 obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
 obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
 obj-$(CONFIG_SENSORS_RTC8564)	+= rtc8564.o
diff -Nru a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c
--- a/drivers/i2c/chips/adm1021.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/i2c/chips/adm1021.c	2004-12-24 13:36:17 -08:00
@@ -40,12 +40,11 @@
 #define ADM1021_ALARM_RTEMP_NA		0x04
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b,
-	0x4c, 0x4e, I2C_CLIENT_END
-};
+static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
+					0x29, 0x2a, 0x2b,
+					0x4c, 0x4d, 0x4e, 
+					I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);
@@ -148,7 +147,7 @@
 	.detach_client	= adm1021_detach_client,
 };
 
-static int adm1021_id = 0;
+static int adm1021_id;
 
 #define show(value)	\
 static ssize_t show_##value(struct device *dev, char *buf)		\
diff -Nru a/drivers/i2c/chips/adm1025.c b/drivers/i2c/chips/adm1025.c
--- a/drivers/i2c/chips/adm1025.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/i2c/chips/adm1025.c	2004-12-24 13:36:16 -08:00
@@ -59,10 +59,8 @@
  * NE1619 has two possible addresses: 0x2c and 0x2d.
  */
 
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x2c, 0x2e, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
@@ -153,7 +151,7 @@
  * Internal variables
  */
 
-static int adm1025_id = 0;
+static int adm1025_id;
 
 /*
  * Sysfs stuff
@@ -212,8 +210,8 @@
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct adm1025_data *data = i2c_get_clientdata(client); \
-	data->in_min[offset] = IN_TO_REG(simple_strtol(buf, NULL, 10), \
-			       in_scale[offset]); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \
 	i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \
 				  data->in_min[offset]); \
 	return count; \
@@ -223,8 +221,8 @@
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct adm1025_data *data = i2c_get_clientdata(client); \
-	data->in_max[offset] = IN_TO_REG(simple_strtol(buf, NULL, 10), \
-			       in_scale[offset]); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \
 	i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \
 				  data->in_max[offset]); \
 	return count; \
@@ -246,7 +244,8 @@
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct adm1025_data *data = i2c_get_clientdata(client); \
-	data->temp_min[offset-1] = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->temp_min[offset-1] = TEMP_TO_REG(val); \
 	i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \
 				  data->temp_min[offset-1]); \
 	return count; \
@@ -256,7 +255,8 @@
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct adm1025_data *data = i2c_get_clientdata(client); \
-	data->temp_max[offset-1] = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->temp_max[offset-1] = TEMP_TO_REG(val); \
 	i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \
 				  data->temp_max[offset-1]); \
 	return count; \
diff -Nru a/drivers/i2c/chips/adm1026.c b/drivers/i2c/chips/adm1026.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/i2c/chips/adm1026.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1779 @@
+/*
+    adm1026.c - Part of lm_sensors, Linux kernel modules for hardware
+	     monitoring
+    Copyright (C) 2002, 2003  Philip Pokorny <ppokorny@penguincomputing.com>
+    Copyright (C) 2004 Justin Thiessen <jthiessen@penguincomputing.com>
+
+    Chip details at:
+
+    <http://www.analog.com/UploadedFiles/Data_Sheets/779263102ADM1026_a.pdf>
+
+    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.
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+#include <linux/i2c-vid.h>
+
+/* Addresses to scan */
+static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+
+/* Insmod parameters */
+SENSORS_INSMOD_1(adm1026);
+
+static int gpio_input[17]  = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
+				-1, -1, -1, -1, -1, -1, -1, -1 }; 
+static int gpio_output[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
+				-1, -1, -1, -1, -1, -1, -1, -1 };
+static int gpio_inverted[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
+				-1, -1, -1, -1, -1, -1, -1, -1 };
+static int gpio_normal[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
+				-1, -1, -1, -1, -1, -1, -1, -1 };
+static int gpio_fan[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };
+module_param_array(gpio_input,int,NULL,0);
+MODULE_PARM_DESC(gpio_input,"List of GPIO pins (0-16) to program as inputs");
+module_param_array(gpio_output,int,NULL,0);
+MODULE_PARM_DESC(gpio_output,"List of GPIO pins (0-16) to program as "
+	"outputs");
+module_param_array(gpio_inverted,int,NULL,0);
+MODULE_PARM_DESC(gpio_inverted,"List of GPIO pins (0-16) to program as "
+	"inverted");
+module_param_array(gpio_normal,int,NULL,0);
+MODULE_PARM_DESC(gpio_normal,"List of GPIO pins (0-16) to program as "
+	"normal/non-inverted");
+module_param_array(gpio_fan,int,NULL,0);
+MODULE_PARM_DESC(gpio_fan,"List of GPIO pins (0-7) to program as fan tachs");
+
+/* Many ADM1026 constants specified below */
+
+/* The ADM1026 registers */
+#define ADM1026_REG_CONFIG1  0x00
+#define CFG1_MONITOR     0x01
+#define CFG1_INT_ENABLE  0x02
+#define CFG1_INT_CLEAR   0x04
+#define CFG1_AIN8_9      0x08
+#define CFG1_THERM_HOT   0x10
+#define CFG1_DAC_AFC     0x20
+#define CFG1_PWM_AFC     0x40
+#define CFG1_RESET       0x80
+#define ADM1026_REG_CONFIG2  0x01
+/* CONFIG2 controls FAN0/GPIO0 through FAN7/GPIO7 */
+#define ADM1026_REG_CONFIG3  0x07
+#define CFG3_GPIO16_ENABLE  0x01
+#define CFG3_CI_CLEAR  0x02
+#define CFG3_VREF_250  0x04
+#define CFG3_GPIO16_DIR  0x40
+#define CFG3_GPIO16_POL  0x80
+#define ADM1026_REG_E2CONFIG  0x13
+#define E2CFG_READ  0x01
+#define E2CFG_WRITE  0x02
+#define E2CFG_ERASE  0x04
+#define E2CFG_ROM  0x08
+#define E2CFG_CLK_EXT  0x80
+
+/* There are 10 general analog inputs and 7 dedicated inputs
+ * They are:
+ *    0 - 9  =  AIN0 - AIN9
+ *       10  =  Vbat
+ *       11  =  3.3V Standby
+ *       12  =  3.3V Main
+ *       13  =  +5V
+ *       14  =  Vccp (CPU core voltage)
+ *       15  =  +12V
+ *       16  =  -12V
+ */
+static u16 ADM1026_REG_IN[] = {
+		0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
+		0x36, 0x37, 0x27, 0x29, 0x26, 0x2a,
+		0x2b, 0x2c, 0x2d, 0x2e, 0x2f
+	};
+static u16 ADM1026_REG_IN_MIN[] = {
+		0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d,
+		0x5e, 0x5f, 0x6d, 0x49, 0x6b, 0x4a,
+		0x4b, 0x4c, 0x4d, 0x4e, 0x4f
+	};
+static u16 ADM1026_REG_IN_MAX[] = {
+		0x50, 0x51, 0x52, 0x53, 0x54, 0x55,
+		0x56, 0x57, 0x6c, 0x41, 0x6a, 0x42,
+		0x43, 0x44, 0x45, 0x46, 0x47
+	};
+
+/* Temperatures are:
+ *    0 - Internal
+ *    1 - External 1
+ *    2 - External 2
+ */
+static u16 ADM1026_REG_TEMP[] = { 0x1f, 0x28, 0x29 };
+static u16 ADM1026_REG_TEMP_MIN[] = { 0x69, 0x48, 0x49 };
+static u16 ADM1026_REG_TEMP_MAX[] = { 0x68, 0x40, 0x41 };
+static u16 ADM1026_REG_TEMP_TMIN[] = { 0x10, 0x11, 0x12 };
+static u16 ADM1026_REG_TEMP_THERM[] = { 0x0d, 0x0e, 0x0f };
+static u16 ADM1026_REG_TEMP_OFFSET[] = { 0x1e, 0x6e, 0x6f };
+
+#define ADM1026_REG_FAN(nr) (0x38 + (nr))
+#define ADM1026_REG_FAN_MIN(nr) (0x60 + (nr))
+#define ADM1026_REG_FAN_DIV_0_3 0x02
+#define ADM1026_REG_FAN_DIV_4_7 0x03
+
+#define ADM1026_REG_DAC  0x04
+#define ADM1026_REG_PWM  0x05
+
+#define ADM1026_REG_GPIO_CFG_0_3 0x08
+#define ADM1026_REG_GPIO_CFG_4_7 0x09
+#define ADM1026_REG_GPIO_CFG_8_11 0x0a
+#define ADM1026_REG_GPIO_CFG_12_15 0x0b
+/* CFG_16 in REG_CFG3 */
+#define ADM1026_REG_GPIO_STATUS_0_7 0x24
+#define ADM1026_REG_GPIO_STATUS_8_15 0x25
+/* STATUS_16 in REG_STATUS4 */
+#define ADM1026_REG_GPIO_MASK_0_7 0x1c
+#define ADM1026_REG_GPIO_MASK_8_15 0x1d
+/* MASK_16 in REG_MASK4 */
+
+#define ADM1026_REG_COMPANY 0x16
+#define ADM1026_REG_VERSTEP 0x17
+/* These are the recognized values for the above regs */
+#define ADM1026_COMPANY_ANALOG_DEV 0x41
+#define ADM1026_VERSTEP_GENERIC 0x40
+#define ADM1026_VERSTEP_ADM1026 0x44
+
+#define ADM1026_REG_MASK1 0x18
+#define ADM1026_REG_MASK2 0x19
+#define ADM1026_REG_MASK3 0x1a
+#define ADM1026_REG_MASK4 0x1b
+
+#define ADM1026_REG_STATUS1 0x20
+#define ADM1026_REG_STATUS2 0x21
+#define ADM1026_REG_STATUS3 0x22
+#define ADM1026_REG_STATUS4 0x23
+
+#define ADM1026_FAN_ACTIVATION_TEMP_HYST -6
+#define ADM1026_FAN_CONTROL_TEMP_RANGE 20
+#define ADM1026_PWM_MAX 255
+
+/* Conversions. Rounding and limit checking is only done on the TO_REG 
+ * variants. Note that you should be a bit careful with which arguments
+ * these macros are called: arguments may be evaluated more than once.
+ */
+
+/* IN are scaled acording to built-in resistors.  These are the
+ *   voltages corresponding to 3/4 of full scale (192 or 0xc0)
+ *   NOTE: The -12V input needs an additional factor to account
+ *      for the Vref pullup resistor.
+ *      NEG12_OFFSET = SCALE * Vref / V-192 - Vref
+ *                   = 13875 * 2.50 / 1.875 - 2500
+ *                   = 16000
+ *
+ * The values in this table are based on Table II, page 15 of the
+ *    datasheet.
+ */
+static int adm1026_scaling[] = {  /* .001 Volts */
+		2250, 2250, 2250, 2250, 2250, 2250, 
+		1875, 1875, 1875, 1875, 3000, 3330, 
+		3330, 4995, 2250, 12000, 13875
+	};
+#define NEG12_OFFSET  16000
+#define SCALE(val,from,to) (((val)*(to) + ((from)/2))/(from))
+#define INS_TO_REG(n,val)  (SENSORS_LIMIT(SCALE(val,adm1026_scaling[n],192),\
+	0,255))
+#define INS_FROM_REG(n,val) (SCALE(val,192,adm1026_scaling[n]))
+
+/* FAN speed is measured using 22.5kHz clock and counts for 2 pulses
+ *   and we assume a 2 pulse-per-rev fan tach signal
+ *      22500 kHz * 60 (sec/min) * 2 (pulse) / 2 (pulse/rev) == 1350000
+ */
+#define FAN_TO_REG(val,div)  ((val)<=0 ? 0xff : SENSORS_LIMIT(1350000/((val)*\
+	(div)),1,254)) 
+#define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==0xff ? 0 : 1350000/((val)*\
+	(div)))
+#define DIV_FROM_REG(val) (1<<(val))
+#define DIV_TO_REG(val) ((val)>=8 ? 3 : (val)>=4 ? 2 : (val)>=2 ? 1 : 0)
+
+/* Temperature is reported in 1 degC increments */
+#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\
+	-127,127))
+#define TEMP_FROM_REG(val) ((val) * 1000)
+#define OFFSET_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\
+	-127,127))
+#define OFFSET_FROM_REG(val) ((val) * 1000)
+
+#define PWM_TO_REG(val) (SENSORS_LIMIT(val,0,255))
+#define PWM_FROM_REG(val) (val)
+
+#define PWM_MIN_TO_REG(val) ((val) & 0xf0)
+#define PWM_MIN_FROM_REG(val) (((val) & 0xf0) + ((val) >> 4))
+
+/* Analog output is a voltage, and scaled to millivolts.  The datasheet 
+ *   indicates that the DAC could be used to drive the fans, but in our 
+ *   example board (Arima HDAMA) it isn't connected to the fans at all.
+ */
+#define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500),0,255)) 
+#define DAC_FROM_REG(val) (((val)*2500)/255)
+
+/* Typically used with systems using a v9.1 VRM spec ? */
+#define ADM1026_INIT_VRM  91
+
+/* Chip sampling rates
+ *
+ * Some sensors are not updated more frequently than once per second
+ *    so it doesn't make sense to read them more often than that.
+ *    We cache the results and return the saved data if the driver
+ *    is called again before a second has elapsed.
+ *
+ * Also, there is significant configuration data for this chip
+ *    So, we keep the config data up to date in the cache
+ *    when it is written and only sample it once every 5 *minutes*
+ */
+#define ADM1026_DATA_INTERVAL  (1 * HZ)
+#define ADM1026_CONFIG_INTERVAL  (5 * 60 * HZ)
+
+/* We allow for multiple chips in a single system.
+ *
+ * For each registered ADM1026, we need to keep state information
+ * at client->data. The adm1026_data structure is dynamically
+ * allocated, when a new client structure is allocated. */
+
+struct pwm_data {
+	u8 pwm;
+	u8 enable;
+	u8 auto_pwm_min;
+};
+
+struct adm1026_data {
+	struct i2c_client client;
+	struct semaphore lock;
+	enum chips type;
+
+	struct semaphore update_lock;
+	int valid;		/* !=0 if following fields are valid */
+	unsigned long last_reading;	/* In jiffies */
+	unsigned long last_config;	/* In jiffies */
+
+	u8 in[17];              /* Register value */
+	u8 in_max[17];          /* Register value */
+	u8 in_min[17];          /* Register value */
+	s8 temp[3];             /* Register value */
+	s8 temp_min[3];         /* Register value */
+	s8 temp_max[3];         /* Register value */
+	s8 temp_tmin[3];        /* Register value */
+	s8 temp_crit[3];        /* Register value */
+	s8 temp_offset[3];      /* Register value */
+	u8 fan[8];              /* Register value */
+	u8 fan_min[8];          /* Register value */
+	u8 fan_div[8];          /* Decoded value */
+	struct pwm_data pwm1;   /* Pwm control values */
+	int vid;                /* Decoded value */
+	u8 vrm;                 /* VRM version */
+	u8 analog_out;		/* Register value (DAC) */
+	long alarms;            /* Register encoding, combined */
+	long alarm_mask;        /* Register encoding, combined */
+	long gpio;              /* Register encoding, combined */
+	long gpio_mask;         /* Register encoding, combined */
+	u8 gpio_config[17];     /* Decoded value */
+	u8 config1;             /* Register value */
+	u8 config2;             /* Register value */
+	u8 config3;             /* Register value */
+};
+
+static int adm1026_attach_adapter(struct i2c_adapter *adapter);
+static int adm1026_detect(struct i2c_adapter *adapter, int address,
+	int kind);
+static int adm1026_detach_client(struct i2c_client *client);
+static int adm1026_read_value(struct i2c_client *client, u8 register);
+static int adm1026_write_value(struct i2c_client *client, u8 register,
+	int value); 
+static void adm1026_print_gpio(struct i2c_client *client);
+static void adm1026_fixup_gpio(struct i2c_client *client); 
+static struct adm1026_data *adm1026_update_device(struct device *dev);
+static void adm1026_init_client(struct i2c_client *client);
+
+
+static struct i2c_driver adm1026_driver = {
+	.owner          = THIS_MODULE,
+	.name           = "adm1026",
+	.flags          = I2C_DF_NOTIFY,
+	.attach_adapter = adm1026_attach_adapter,
+	.detach_client  = adm1026_detach_client,
+};
+
+static int adm1026_id;
+
+int adm1026_attach_adapter(struct i2c_adapter *adapter)
+{
+	if (!(adapter->class & I2C_CLASS_HWMON)) {
+		return 0;
+	}
+	return i2c_detect(adapter, &addr_data, adm1026_detect);
+}
+
+int adm1026_detach_client(struct i2c_client *client)
+{
+	i2c_detach_client(client);
+	kfree(client);
+	return 0;
+}
+
+int adm1026_read_value(struct i2c_client *client, u8 reg)
+{
+	int res;
+
+	if (reg < 0x80) {
+		/* "RAM" locations */
+		res = i2c_smbus_read_byte_data(client, reg) & 0xff;
+	} else {
+		/* EEPROM, do nothing */
+		res = 0;
+	}
+	return res;
+}
+
+int adm1026_write_value(struct i2c_client *client, u8 reg, int value)
+{
+	int res;
+
+	if (reg < 0x80) {
+		/* "RAM" locations */
+		res = i2c_smbus_write_byte_data(client, reg, value);
+	} else {
+		/* EEPROM, do nothing */
+		res = 0;
+	}
+	return res;
+}
+
+void adm1026_init_client(struct i2c_client *client)
+{
+	int value, i;
+	struct adm1026_data *data = i2c_get_clientdata(client);
+
+        dev_dbg(&client->dev,"(%d): Initializing device\n", client->id);
+	/* Read chip config */
+	data->config1 = adm1026_read_value(client, ADM1026_REG_CONFIG1);
+	data->config2 = adm1026_read_value(client, ADM1026_REG_CONFIG2);
+	data->config3 = adm1026_read_value(client, ADM1026_REG_CONFIG3);
+
+	/* Inform user of chip config */
+	dev_dbg(&client->dev, "(%d): ADM1026_REG_CONFIG1 is: 0x%02x\n",
+		client->id, data->config1);
+	if ((data->config1 & CFG1_MONITOR) == 0) {
+		dev_dbg(&client->dev, "(%d): Monitoring not currently "
+			"enabled.\n", client->id);
+	}
+	if (data->config1 & CFG1_INT_ENABLE) {
+		dev_dbg(&client->dev, "(%d): SMBALERT interrupts are "
+			"enabled.\n", client->id);
+	}
+	if (data->config1 & CFG1_AIN8_9) {
+		dev_dbg(&client->dev, "(%d): in8 and in9 enabled. "
+			"temp3 disabled.\n", client->id);
+	} else {
+		dev_dbg(&client->dev, "(%d): temp3 enabled.  in8 and "
+			"in9 disabled.\n", client->id);
+	}
+	if (data->config1 & CFG1_THERM_HOT) {
+		dev_dbg(&client->dev, "(%d): Automatic THERM, PWM, "
+			"and temp limits enabled.\n", client->id);
+	}
+
+	value = data->config3;
+	if (data->config3 & CFG3_GPIO16_ENABLE) {
+		dev_dbg(&client->dev, "(%d): GPIO16 enabled.  THERM"
+			"pin disabled.\n", client->id);
+	} else {
+		dev_dbg(&client->dev, "(%d): THERM pin enabled.  "
+			"GPIO16 disabled.\n", client->id);
+	}
+	if (data->config3 & CFG3_VREF_250) {
+		dev_dbg(&client->dev, "(%d): Vref is 2.50 Volts.\n",
+			client->id);
+	} else {
+		dev_dbg(&client->dev, "(%d): Vref is 1.82 Volts.\n",
+			client->id);
+	}
+	/* Read and pick apart the existing GPIO configuration */
+	value = 0;
+	for (i = 0;i <= 15;++i) {
+		if ((i & 0x03) == 0) {
+			value = adm1026_read_value(client,
+					ADM1026_REG_GPIO_CFG_0_3 + i/4);
+		}
+		data->gpio_config[i] = value & 0x03;
+		value >>= 2;
+	}
+	data->gpio_config[16] = (data->config3 >> 6) & 0x03;
+
+	/* ... and then print it */
+	adm1026_print_gpio(client);
+
+	/* If the user asks us to reprogram the GPIO config, then
+	 *   do it now.  But only if this is the first ADM1026.
+	 */
+	if (client->id == 0
+	    && (gpio_input[0] != -1 || gpio_output[0] != -1
+		|| gpio_inverted[0] != -1 || gpio_normal[0] != -1
+		|| gpio_fan[0] != -1)) {
+		adm1026_fixup_gpio(client);
+	}
+
+	/* WE INTENTIONALLY make no changes to the limits,
+	 *   offsets, pwms, fans and zones.  If they were
+	 *   configured, we don't want to mess with them.
+	 *   If they weren't, the default is 100% PWM, no
+	 *   control and will suffice until 'sensors -s'
+	 *   can be run by the user.  We DO set the default 
+	 *   value for pwm1.auto_pwm_min to its maximum
+	 *   so that enabling automatic pwm fan control
+	 *   without first setting a value for pwm1.auto_pwm_min 
+	 *   will not result in potentially dangerous fan speed decrease.
+	 */
+	data->pwm1.auto_pwm_min=255;
+	/* Start monitoring */
+	value = adm1026_read_value(client, ADM1026_REG_CONFIG1);
+	/* Set MONITOR, clear interrupt acknowledge and s/w reset */
+	value = (value | CFG1_MONITOR) & (~CFG1_INT_CLEAR & ~CFG1_RESET);
+	dev_dbg(&client->dev, "(%d): Setting CONFIG to: 0x%02x\n",
+		client->id, value);
+	data->config1 = value;
+	adm1026_write_value(client, ADM1026_REG_CONFIG1, value);
+}
+
+void adm1026_print_gpio(struct i2c_client *client)
+{
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int  i;
+
+	dev_dbg(&client->dev, "(%d): GPIO config is:",
+			    client->id);
+	for (i = 0;i <= 7;++i) {
+		if (data->config2 & (1 << i)) {
+			dev_dbg(&client->dev, "\t(%d): %sGP%s%d\n", client->id,
+				data->gpio_config[i] & 0x02 ? "" : "!",
+				data->gpio_config[i] & 0x01 ? "OUT" : "IN",
+				i);
+		} else {
+			dev_dbg(&client->dev, "\t(%d): FAN%d\n",
+				client->id, i);
+		}
+	}
+	for (i = 8;i <= 15;++i) {
+		dev_dbg(&client->dev, "\t(%d): %sGP%s%d\n", client->id,
+			data->gpio_config[i] & 0x02 ? "" : "!",
+			data->gpio_config[i] & 0x01 ? "OUT" : "IN",
+			i);
+	}
+	if (data->config3 & CFG3_GPIO16_ENABLE) {
+		dev_dbg(&client->dev, "\t(%d): %sGP%s16\n", client->id,
+			data->gpio_config[16] & 0x02 ? "" : "!",
+			data->gpio_config[16] & 0x01 ? "OUT" : "IN");
+	} else {
+		/* GPIO16 is THERM  */
+		dev_dbg(&client->dev, "\t(%d): THERM\n", client->id);
+	}
+}
+
+void adm1026_fixup_gpio(struct i2c_client *client)
+{
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int  i;
+	int  value;
+
+	/* Make the changes requested. */
+	/* We may need to unlock/stop monitoring or soft-reset the
+	 *    chip before we can make changes.  This hasn't been
+	 *    tested much.  FIXME
+	 */
+
+	/* Make outputs */
+	for (i = 0;i <= 16;++i) {
+		if (gpio_output[i] >= 0 && gpio_output[i] <= 16) {
+			data->gpio_config[gpio_output[i]] |= 0x01;
+		}
+		/* if GPIO0-7 is output, it isn't a FAN tach */
+		if (gpio_output[i] >= 0 && gpio_output[i] <= 7) {
+			data->config2 |= 1 << gpio_output[i];
+		}
+	}
+
+	/* Input overrides output */
+	for (i = 0;i <= 16;++i) {
+		if (gpio_input[i] >= 0 && gpio_input[i] <= 16) {
+			data->gpio_config[gpio_input[i]] &= ~ 0x01;
+		}
+		/* if GPIO0-7 is input, it isn't a FAN tach */
+		if (gpio_input[i] >= 0 && gpio_input[i] <= 7) {
+			data->config2 |= 1 << gpio_input[i];
+		}
+	}
+
+	/* Inverted  */
+	for (i = 0;i <= 16;++i) {
+		if (gpio_inverted[i] >= 0 && gpio_inverted[i] <= 16) {
+			data->gpio_config[gpio_inverted[i]] &= ~ 0x02;
+		}
+	}
+
+	/* Normal overrides inverted  */
+	for (i = 0;i <= 16;++i) {
+		if (gpio_normal[i] >= 0 && gpio_normal[i] <= 16) {
+			data->gpio_config[gpio_normal[i]] |= 0x02;
+		}
+	}
+
+	/* Fan overrides input and output */
+	for (i = 0;i <= 7;++i) {
+		if (gpio_fan[i] >= 0 && gpio_fan[i] <= 7) {
+			data->config2 &= ~(1 << gpio_fan[i]);
+		}
+	}
+
+	/* Write new configs to registers */
+	adm1026_write_value(client, ADM1026_REG_CONFIG2, data->config2);
+	data->config3 = (data->config3 & 0x3f)
+			| ((data->gpio_config[16] & 0x03) << 6);
+	adm1026_write_value(client, ADM1026_REG_CONFIG3, data->config3);
+	for (i = 15, value = 0;i >= 0;--i) {
+		value <<= 2;
+		value |= data->gpio_config[i] & 0x03;
+		if ((i & 0x03) == 0) {
+			adm1026_write_value(client,
+					ADM1026_REG_GPIO_CFG_0_3 + i/4,
+					value);
+			value = 0;
+		}
+	}
+
+	/* Print the new config */
+	adm1026_print_gpio(client);
+}
+
+
+static struct adm1026_data *adm1026_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int i;
+	long value, alarms, gpio;
+
+	down(&data->update_lock);
+	if (!data->valid
+	    || (jiffies - data->last_reading > ADM1026_DATA_INTERVAL)) {
+		/* Things that change quickly */
+		dev_dbg(&client->dev,"(%d): Reading sensor values\n", 
+			client->id);
+		for (i = 0;i <= 16;++i) {
+			data->in[i] =
+			    adm1026_read_value(client, ADM1026_REG_IN[i]);
+		}
+
+		for (i = 0;i <= 7;++i) {
+			data->fan[i] =
+			    adm1026_read_value(client, ADM1026_REG_FAN(i));
+		}
+
+		for (i = 0;i <= 2;++i) {
+			/* NOTE: temp[] is s8 and we assume 2's complement
+			 *   "conversion" in the assignment   */
+			data->temp[i] =
+			    adm1026_read_value(client, ADM1026_REG_TEMP[i]);
+		}
+
+		data->pwm1.pwm = adm1026_read_value(client, 
+			ADM1026_REG_PWM);
+		data->analog_out = adm1026_read_value(client, 
+			ADM1026_REG_DAC);
+		/* GPIO16 is MSbit of alarms, move it to gpio */
+		alarms = adm1026_read_value(client, ADM1026_REG_STATUS4);
+		gpio = alarms & 0x80 ? 0x0100 : 0;  /* GPIO16 */
+		alarms &= 0x7f;
+		alarms <<= 8;
+		alarms |= adm1026_read_value(client, ADM1026_REG_STATUS3);
+		alarms <<= 8;
+		alarms |= adm1026_read_value(client, ADM1026_REG_STATUS2);
+		alarms <<= 8;
+		alarms |= adm1026_read_value(client, ADM1026_REG_STATUS1);
+		data->alarms = alarms;
+
+		/* Read the GPIO values */
+		gpio |= adm1026_read_value(client, 
+			ADM1026_REG_GPIO_STATUS_8_15);
+		gpio <<= 8;
+		gpio |= adm1026_read_value(client, 
+			ADM1026_REG_GPIO_STATUS_0_7);
+		data->gpio = gpio;
+
+		data->last_reading = jiffies;
+	};  /* last_reading */
+
+	if (!data->valid || (jiffies - data->last_config > 
+		ADM1026_CONFIG_INTERVAL)) {
+		/* Things that don't change often */
+		dev_dbg(&client->dev, "(%d): Reading config values\n", 
+			client->id);
+		for (i = 0;i <= 16;++i) {
+			data->in_min[i] = adm1026_read_value(client, 
+				ADM1026_REG_IN_MIN[i]);
+			data->in_max[i] = adm1026_read_value(client, 
+				ADM1026_REG_IN_MAX[i]);
+		}
+
+		value = adm1026_read_value(client, ADM1026_REG_FAN_DIV_0_3)
+			| (adm1026_read_value(client, ADM1026_REG_FAN_DIV_4_7)
+			<< 8);
+		for (i = 0;i <= 7;++i) {
+			data->fan_min[i] = adm1026_read_value(client, 
+				ADM1026_REG_FAN_MIN(i));
+			data->fan_div[i] = DIV_FROM_REG(value & 0x03);
+			value >>= 2;
+		}
+
+		for (i = 0; i <= 2; ++i) {
+			/* NOTE: temp_xxx[] are s8 and we assume 2's 
+			 *    complement "conversion" in the assignment
+			 */
+			data->temp_min[i] = adm1026_read_value(client, 
+				ADM1026_REG_TEMP_MIN[i]);
+			data->temp_max[i] = adm1026_read_value(client, 
+				ADM1026_REG_TEMP_MAX[i]);
+			data->temp_tmin[i] = adm1026_read_value(client, 
+				ADM1026_REG_TEMP_TMIN[i]);
+			data->temp_crit[i] = adm1026_read_value(client, 
+				ADM1026_REG_TEMP_THERM[i]);
+			data->temp_offset[i] = adm1026_read_value(client, 
+				ADM1026_REG_TEMP_OFFSET[i]);
+		}
+
+		/* Read the STATUS/alarm masks */
+		alarms  = adm1026_read_value(client, ADM1026_REG_MASK4);
+		gpio    = alarms & 0x80 ? 0x0100 : 0;  /* GPIO16 */
+		alarms  = (alarms & 0x7f) << 8;
+		alarms |= adm1026_read_value(client, ADM1026_REG_MASK3);
+		alarms <<= 8;
+		alarms |= adm1026_read_value(client, ADM1026_REG_MASK2);
+		alarms <<= 8;
+		alarms |= adm1026_read_value(client, ADM1026_REG_MASK1);
+		data->alarm_mask = alarms;
+
+		/* Read the GPIO values */
+		gpio |= adm1026_read_value(client, 
+			ADM1026_REG_GPIO_MASK_8_15);
+		gpio <<= 8;
+		gpio |= adm1026_read_value(client, ADM1026_REG_GPIO_MASK_0_7);
+		data->gpio_mask = gpio;
+
+		/* Read various values from CONFIG1 */
+		data->config1 = adm1026_read_value(client, 
+			ADM1026_REG_CONFIG1);
+		if (data->config1 & CFG1_PWM_AFC) {
+			data->pwm1.enable = 2;
+			data->pwm1.auto_pwm_min = 
+				PWM_MIN_FROM_REG(data->pwm1.pwm);
+		}
+		/* Read the GPIO config */
+		data->config2 = adm1026_read_value(client, 
+			ADM1026_REG_CONFIG2);
+		data->config3 = adm1026_read_value(client, 
+			ADM1026_REG_CONFIG3);
+		data->gpio_config[16] = (data->config3 >> 6) & 0x03;
+
+		value = 0;
+		for (i = 0;i <= 15;++i) {
+			if ((i & 0x03) == 0) {
+				value = adm1026_read_value(client,
+					    ADM1026_REG_GPIO_CFG_0_3 + i/4);
+			}
+			data->gpio_config[i] = value & 0x03;
+			value >>= 2;
+		}
+
+		data->last_config = jiffies;
+	};  /* last_config */
+
+	dev_dbg(&client->dev, "(%d): Setting VID from GPIO11-15.\n", 
+		client->id);
+	data->vid = (data->gpio >> 11) & 0x1f;
+	data->valid = 1;
+	up(&data->update_lock);
+	return data;
+}
+
+static ssize_t show_in(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in[nr]));
+}
+static ssize_t show_in_min(struct device *dev, char *buf, int nr) 
+{
+	struct adm1026_data *data = adm1026_update_device(dev); 
+	return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr]));
+}
+static ssize_t set_in_min(struct device *dev, const char *buf, 
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->in_min[nr] = INS_TO_REG(nr, val);
+	adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]);
+	up(&data->update_lock);
+	return count; 
+}
+static ssize_t show_in_max(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr]));
+}
+static ssize_t set_in_max(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->in_max[nr] = INS_TO_REG(nr, val);
+	adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]);
+	up(&data->update_lock);
+	return count;
+}
+
+#define in_reg(offset)                                                    \
+static ssize_t show_in##offset (struct device *dev, char *buf)            \
+{                                                                         \
+	return show_in(dev, buf, offset);                                 \
+}                                                                         \
+static ssize_t show_in##offset##_min (struct device *dev, char *buf)      \
+{                                                                         \
+	return show_in_min(dev, buf, offset);                             \
+}                                                                         \
+static ssize_t set_in##offset##_min (struct device *dev,                  \
+	const char *buf, size_t count)                                    \
+{                                                                         \
+	return set_in_min(dev, buf, count, offset);                       \
+}                                                                         \
+static ssize_t show_in##offset##_max (struct device *dev, char *buf)      \
+{                                                                         \
+	return show_in_max(dev, buf, offset);                             \
+}                                                                         \
+static ssize_t set_in##offset##_max (struct device *dev,                  \
+	const char *buf, size_t count)                                    \
+{                                                                         \
+	return set_in_max(dev, buf, count, offset);                       \
+}                                                                         \
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);   \
+static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR,                   \
+		show_in##offset##_min, set_in##offset##_min);             \
+static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR,                   \
+		show_in##offset##_max, set_in##offset##_max);
+
+
+in_reg(0);
+in_reg(1);
+in_reg(2);
+in_reg(3);
+in_reg(4);
+in_reg(5);
+in_reg(6);
+in_reg(7);
+in_reg(8);
+in_reg(9);
+in_reg(10);
+in_reg(11);
+in_reg(12);
+in_reg(13);
+in_reg(14);
+in_reg(15);
+
+static ssize_t show_in16(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in[16]) -
+		NEG12_OFFSET);
+}
+static ssize_t show_in16_min(struct device *dev, char *buf) 
+{
+	struct adm1026_data *data = adm1026_update_device(dev); 
+	return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_min[16])
+		- NEG12_OFFSET);
+}
+static ssize_t set_in16_min(struct device *dev, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET);
+	adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]);
+	up(&data->update_lock);
+	return count; 
+}
+static ssize_t show_in16_max(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_max[16])
+			- NEG12_OFFSET);
+}
+static ssize_t set_in16_max(struct device *dev, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET);
+	adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]);
+	up(&data->update_lock);
+	return count;
+}
+
+static DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL);
+static DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min, set_in16_min);
+static DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max, set_in16_max);
+
+
+
+
+/* Now add fan read/write functions */
+
+static ssize_t show_fan(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr],
+		data->fan_div[nr]));
+}
+static ssize_t show_fan_min(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr],
+		data->fan_div[nr]));
+}
+static ssize_t set_fan_min(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]);
+	adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr),
+		data->fan_min[nr]);
+	up(&data->update_lock);
+	return count;
+}
+
+#define fan_offset(offset)                                                  \
+static ssize_t show_fan_##offset (struct device *dev, char *buf)            \
+{                                                                           \
+	return show_fan(dev, buf, offset - 1);                              \
+}                                                                           \
+static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)      \
+{                                                                           \
+	return show_fan_min(dev, buf, offset - 1);                          \
+}                                                                           \
+static ssize_t set_fan_##offset##_min (struct device *dev,                  \
+	const char *buf, size_t count)                                      \
+{                                                                           \
+	return set_fan_min(dev, buf, count, offset - 1);                    \
+}                                                                           \
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);  \
+static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR,                    \
+		show_fan_##offset##_min, set_fan_##offset##_min);
+
+fan_offset(1);
+fan_offset(2);
+fan_offset(3);
+fan_offset(4);
+fan_offset(5);
+fan_offset(6);
+fan_offset(7);
+fan_offset(8);
+
+/* Adjust fan_min to account for new fan divisor */
+static void fixup_fan_min(struct device *dev, int fan, int old_div)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int    new_min;
+	int    new_div = data->fan_div[fan];
+
+	/* 0 and 0xff are special.  Don't adjust them */
+	if (data->fan_min[fan] == 0 || data->fan_min[fan] == 0xff) {
+		return;
+	}
+
+	new_min = data->fan_min[fan] * old_div / new_div;
+	new_min = SENSORS_LIMIT(new_min, 1, 254);
+	data->fan_min[fan] = new_min;
+	adm1026_write_value(client, ADM1026_REG_FAN_MIN(fan), new_min);
+}
+
+/* Now add fan_div read/write functions */
+static ssize_t show_fan_div(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", data->fan_div[nr]);
+}
+static ssize_t set_fan_div(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int    val,orig_div,new_div,shift;
+
+	val = simple_strtol(buf, NULL, 10);
+	new_div = DIV_TO_REG(val); 
+	if (new_div == 0) {
+		return -EINVAL;
+	}
+	down(&data->update_lock);
+	orig_div = data->fan_div[nr];
+	data->fan_div[nr] = DIV_FROM_REG(new_div);
+
+	if (nr < 4) { /* 0 <= nr < 4 */
+		shift = 2 * nr;
+		adm1026_write_value(client, ADM1026_REG_FAN_DIV_0_3,
+			((DIV_TO_REG(orig_div) & (~(0x03 << shift))) |
+			(new_div << shift)));
+	} else { /* 3 < nr < 8 */
+		shift = 2 * (nr - 4);
+		adm1026_write_value(client, ADM1026_REG_FAN_DIV_4_7,
+			((DIV_TO_REG(orig_div) & (~(0x03 << (2 * shift)))) |
+			(new_div << shift)));
+	}
+
+	if (data->fan_div[nr] != orig_div) {
+		fixup_fan_min(dev,nr,orig_div);
+	}
+	up(&data->update_lock);
+	return count;
+}
+
+#define fan_offset_div(offset)                                          \
+static ssize_t show_fan_##offset##_div (struct device *dev, char *buf)  \
+{                                                                       \
+	return show_fan_div(dev, buf, offset - 1);                      \
+}                                                                       \
+static ssize_t set_fan_##offset##_div (struct device *dev,              \
+	const char *buf, size_t count)                                  \
+{                                                                       \
+	return set_fan_div(dev, buf, count, offset - 1);                \
+}                                                                       \
+static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR,                \
+		show_fan_##offset##_div, set_fan_##offset##_div);
+
+fan_offset_div(1);
+fan_offset_div(2);
+fan_offset_div(3);
+fan_offset_div(4);
+fan_offset_div(5);
+fan_offset_div(6);
+fan_offset_div(7);
+fan_offset_div(8);
+
+/* Temps */
+static ssize_t show_temp(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp[nr]));
+}
+static ssize_t show_temp_min(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr]));
+}
+static ssize_t set_temp_min(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->temp_min[nr] = TEMP_TO_REG(val);
+	adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr],
+		data->temp_min[nr]);
+	up(&data->update_lock);
+	return count;
+}
+static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr]));
+}
+static ssize_t set_temp_max(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->temp_max[nr] = TEMP_TO_REG(val);
+	adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr],
+		data->temp_max[nr]);
+	up(&data->update_lock);
+	return count;
+}
+#define temp_reg(offset)                                                      \
+static ssize_t show_temp_##offset (struct device *dev, char *buf)             \
+{                                                                             \
+	return show_temp(dev, buf, offset - 1);                               \
+}                                                                             \
+static ssize_t show_temp_##offset##_min (struct device *dev, char *buf)       \
+{                                                                             \
+	return show_temp_min(dev, buf, offset - 1);                           \
+}                                                                             \
+static ssize_t show_temp_##offset##_max (struct device *dev, char *buf)       \
+{                                                                             \
+	return show_temp_max(dev, buf, offset - 1);                           \
+}                                                                             \
+static ssize_t set_temp_##offset##_min (struct device *dev,                   \
+	const char *buf, size_t count)                                        \
+{                                                                             \
+	return set_temp_min(dev, buf, count, offset - 1);                     \
+}                                                                             \
+static ssize_t set_temp_##offset##_max (struct device *dev,                   \
+	const char *buf, size_t count)                                        \
+{                                                                             \
+	return set_temp_max(dev, buf, count, offset - 1);                     \
+}                                                                             \
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);  \
+static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR,                     \
+		show_temp_##offset##_min, set_temp_##offset##_min);           \
+static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR,                     \
+		show_temp_##offset##_max, set_temp_##offset##_max);
+
+
+temp_reg(1);
+temp_reg(2);
+temp_reg(3);
+
+static ssize_t show_temp_offset(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_offset[nr]));
+}
+static ssize_t set_temp_offset(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->temp_offset[nr] = TEMP_TO_REG(val);
+	adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr],
+		data->temp_offset[nr]);
+	up(&data->update_lock);
+	return count;
+}
+
+#define temp_offset_reg(offset)                                             \
+static ssize_t show_temp_##offset##_offset (struct device *dev, char *buf)  \
+{                                                                           \
+	return show_temp_offset(dev, buf, offset - 1);                      \
+}                                                                           \
+static ssize_t set_temp_##offset##_offset (struct device *dev,              \
+	const char *buf, size_t count)                                      \
+{                                                                           \
+	return set_temp_offset(dev, buf, count, offset - 1);                \
+}                                                                           \
+static DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR,                \
+		show_temp_##offset##_offset, set_temp_##offset##_offset);
+
+temp_offset_reg(1);
+temp_offset_reg(2);
+temp_offset_reg(3);
+
+static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev, char *buf,
+		int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(
+		ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr]));
+}
+static ssize_t show_temp_auto_point2_temp(struct device *dev, char *buf,
+		int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr] +
+		ADM1026_FAN_CONTROL_TEMP_RANGE));
+}
+static ssize_t show_temp_auto_point1_temp(struct device *dev, char *buf,
+		int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr]));
+}
+static ssize_t set_temp_auto_point1_temp(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->temp_tmin[nr] = TEMP_TO_REG(val);
+	adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr],
+		data->temp_tmin[nr]);
+	up(&data->update_lock);
+	return count;
+}
+
+#define temp_auto_point(offset)                                             \
+static ssize_t show_temp##offset##_auto_point1_temp (struct device *dev,    \
+	char *buf)                                                          \
+{                                                                           \
+	return show_temp_auto_point1_temp(dev, buf, offset - 1);            \
+}                                                                           \
+static ssize_t set_temp##offset##_auto_point1_temp (struct device *dev,     \
+	const char *buf, size_t count)                                      \
+{                                                                           \
+	return set_temp_auto_point1_temp(dev, buf, count, offset - 1);      \
+}                                                                           \
+static ssize_t show_temp##offset##_auto_point1_temp_hyst (struct device     \
+	*dev, char *buf)                                                    \
+{                                                                           \
+	return show_temp_auto_point1_temp_hyst(dev, buf, offset - 1);       \
+}                                                                           \
+static ssize_t show_temp##offset##_auto_point2_temp (struct device *dev,    \
+	 char *buf)                                                         \
+{                                                                           \
+	return show_temp_auto_point2_temp(dev, buf, offset - 1);            \
+}                                                                           \
+static DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR,      \
+		show_temp##offset##_auto_point1_temp,                       \
+		set_temp##offset##_auto_point1_temp);                       \
+static DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO,           \
+		show_temp##offset##_auto_point1_temp_hyst, NULL);           \
+static DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO,                \
+		show_temp##offset##_auto_point2_temp, NULL);
+
+temp_auto_point(1);
+temp_auto_point(2);
+temp_auto_point(3);
+
+static ssize_t show_temp_crit_enable(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", (data->config1 & CFG1_THERM_HOT) >> 4);
+}
+static ssize_t set_temp_crit_enable(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	val = simple_strtol(buf, NULL, 10);
+	if ((val == 1) || (val==0)) {
+		down(&data->update_lock);
+		data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4);
+		adm1026_write_value(client, ADM1026_REG_CONFIG1, 
+			data->config1);
+		up(&data->update_lock);
+	}
+	return count;
+}
+
+static DEVICE_ATTR(temp1_crit_enable, S_IRUGO | S_IWUSR, 
+	show_temp_crit_enable, set_temp_crit_enable);
+
+static DEVICE_ATTR(temp2_crit_enable, S_IRUGO | S_IWUSR, 
+	show_temp_crit_enable, set_temp_crit_enable);
+
+static DEVICE_ATTR(temp3_crit_enable, S_IRUGO | S_IWUSR, 
+	show_temp_crit_enable, set_temp_crit_enable);
+
+
+static ssize_t show_temp_crit(struct device *dev, char *buf, int nr)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_crit[nr]));
+}
+static ssize_t set_temp_crit(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->temp_crit[nr] = TEMP_TO_REG(val);
+	adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr],
+		data->temp_crit[nr]);
+	up(&data->update_lock);
+	return count;
+}
+
+#define temp_crit_reg(offset)                                             \
+static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf)  \
+{                                                                         \
+	return show_temp_crit(dev, buf, offset - 1);                      \
+}                                                                         \
+static ssize_t set_temp_##offset##_crit (struct device *dev,              \
+	const char *buf, size_t count)                                    \
+{                                                                         \
+	return set_temp_crit(dev, buf, count, offset - 1);                \
+}                                                                         \
+static DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR,                \
+		show_temp_##offset##_crit, set_temp_##offset##_crit);
+
+temp_crit_reg(1);
+temp_crit_reg(2);
+temp_crit_reg(3);
+
+static ssize_t show_analog_out_reg(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", DAC_FROM_REG(data->analog_out));
+}
+static ssize_t set_analog_out_reg(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->analog_out = DAC_TO_REG(val);
+	adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out);
+	up(&data->update_lock);
+	return count;
+}
+
+static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, 
+	set_analog_out_reg);
+
+static ssize_t show_vid_reg(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm));
+}
+
+static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL);
+
+static ssize_t show_vrm_reg(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", data->vrm);
+}
+static ssize_t store_vrm_reg(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+
+	data->vrm = simple_strtol(buf, NULL, 10);
+	return count;
+}
+
+static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
+
+static ssize_t show_alarms_reg(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf, "%ld\n", (long) (data->alarms));
+}
+
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
+
+static ssize_t show_alarm_mask(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%ld\n", data->alarm_mask);
+}
+static ssize_t set_alarm_mask(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+	unsigned long mask;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->alarm_mask = val & 0x7fffffff;
+	mask = data->alarm_mask
+		| (data->gpio_mask & 0x10000 ? 0x80000000 : 0);
+	adm1026_write_value(client, ADM1026_REG_MASK1,
+		mask & 0xff);
+	mask >>= 8;
+	adm1026_write_value(client, ADM1026_REG_MASK2,
+		mask & 0xff);
+	mask >>= 8;
+	adm1026_write_value(client, ADM1026_REG_MASK3,
+		mask & 0xff);
+	mask >>= 8;
+	adm1026_write_value(client, ADM1026_REG_MASK4,
+		mask & 0xff);
+	up(&data->update_lock);
+	return count;
+}
+
+static DEVICE_ATTR(alarm_mask, S_IRUGO | S_IWUSR, show_alarm_mask,
+	set_alarm_mask);
+
+
+static ssize_t show_gpio(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%ld\n", data->gpio);
+}
+static ssize_t set_gpio(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+	long   gpio;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->gpio = val & 0x1ffff;
+	gpio = data->gpio;
+	adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff);
+	gpio >>= 8;
+	adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff);
+	gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f);
+	adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff);
+	up(&data->update_lock);
+	return count;
+}
+
+static DEVICE_ATTR(gpio, S_IRUGO | S_IWUSR, show_gpio, set_gpio);
+
+
+static ssize_t show_gpio_mask(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%ld\n", data->gpio_mask);
+}
+static ssize_t set_gpio_mask(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+	long   mask;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->gpio_mask = val & 0x1ffff;
+	mask = data->gpio_mask;
+	adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff);
+	mask >>= 8;
+	adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff);
+	mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f);
+	adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff);
+	up(&data->update_lock);
+	return count;
+}
+
+static DEVICE_ATTR(gpio_mask, S_IRUGO | S_IWUSR, show_gpio_mask, set_gpio_mask);
+
+static ssize_t show_pwm_reg(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm1.pwm));
+}
+static ssize_t set_pwm_reg(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	if (data->pwm1.enable == 1) {
+		down(&data->update_lock);
+		val = simple_strtol(buf, NULL, 10);
+		data->pwm1.pwm = PWM_TO_REG(val);
+		adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm);
+		up(&data->update_lock);
+	}
+	return count;
+}
+static ssize_t show_auto_pwm_min(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", data->pwm1.auto_pwm_min);
+}
+static ssize_t set_auto_pwm_min(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255);
+	if (data->pwm1.enable == 2) { /* apply immediately */
+		data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) |
+			PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); 
+		adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm);
+	}
+	up(&data->update_lock);
+	return count;
+}
+static ssize_t show_auto_pwm_max(struct device *dev, char *buf)
+{
+	return sprintf(buf,"%d\n", ADM1026_PWM_MAX);
+}
+static ssize_t show_pwm_enable(struct device *dev, char *buf)
+{
+	struct adm1026_data *data = adm1026_update_device(dev);
+	return sprintf(buf,"%d\n", data->pwm1.enable);
+}
+static ssize_t set_pwm_enable(struct device *dev, const char *buf,
+		size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adm1026_data *data = i2c_get_clientdata(client);
+	int     val;
+	int     old_enable;
+
+	val = simple_strtol(buf, NULL, 10);
+	if ((val >= 0) && (val < 3)) {
+		down(&data->update_lock);
+		old_enable = data->pwm1.enable;
+		data->pwm1.enable = val;
+		data->config1 = (data->config1 & ~CFG1_PWM_AFC)
+				| ((val == 2) ? CFG1_PWM_AFC : 0);
+		adm1026_write_value(client, ADM1026_REG_CONFIG1,
+			data->config1);
+		if (val == 2) {  /* apply pwm1_auto_pwm_min to pwm1 */
+			data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) |
+				PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); 
+			adm1026_write_value(client, ADM1026_REG_PWM, 
+				data->pwm1.pwm);
+		} else if (!((old_enable == 1) && (val == 1))) {
+			/* set pwm to safe value */
+			data->pwm1.pwm = 255;
+			adm1026_write_value(client, ADM1026_REG_PWM, 
+				data->pwm1.pwm);
+		}
+		up(&data->update_lock);
+	}
+	return count;
+}
+
+/* enable PWM fan control */
+static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); 
+static DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); 
+static DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); 
+static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, 
+	set_pwm_enable);
+static DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, 
+	set_pwm_enable);
+static DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable, 
+	set_pwm_enable);
+static DEVICE_ATTR(temp1_auto_point1_pwm, S_IRUGO | S_IWUSR, 
+	show_auto_pwm_min, set_auto_pwm_min);
+static DEVICE_ATTR(temp2_auto_point1_pwm, S_IRUGO | S_IWUSR, 
+	show_auto_pwm_min, set_auto_pwm_min);
+static DEVICE_ATTR(temp3_auto_point1_pwm, S_IRUGO | S_IWUSR, 
+	show_auto_pwm_min, set_auto_pwm_min);
+
+static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL);
+static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL);
+static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL);
+
+int adm1026_detect(struct i2c_adapter *adapter, int address,
+		int kind)
+{
+	int company, verstep;
+	struct i2c_client *new_client;
+	struct adm1026_data *data;
+	int err = 0;
+	const char *type_name = "";
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
+		/* We need to be able to do byte I/O */
+		goto exit;
+	};
+
+	/* OK. For now, we presume we have a valid client. We now create the
+	   client structure, even though we cannot fill it completely yet.
+	   But it allows us to access adm1026_{read,write}_value. */
+
+	if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) {
+		err = -ENOMEM;
+		goto exit;
+	}
+
+	memset(data, 0, sizeof(struct adm1026_data));
+
+	new_client = &data->client;
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	new_client->adapter = adapter;
+	new_client->driver = &adm1026_driver;
+	new_client->flags = 0;
+
+	/* Now, we do the remaining detection. */
+
+	company = adm1026_read_value(new_client, ADM1026_REG_COMPANY);
+	verstep = adm1026_read_value(new_client, ADM1026_REG_VERSTEP);
+
+	dev_dbg(&new_client->dev, "Detecting device at %d,0x%02x with"
+		" COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
+		i2c_adapter_id(new_client->adapter), new_client->addr,
+		company, verstep);
+
+	/* If auto-detecting, Determine the chip type. */
+	if (kind <= 0) {
+		dev_dbg(&new_client->dev, "Autodetecting device at %d,0x%02x "
+			"...\n", i2c_adapter_id(adapter), address);
+		if (company == ADM1026_COMPANY_ANALOG_DEV
+		    && verstep == ADM1026_VERSTEP_ADM1026) {
+			kind = adm1026;
+		} else if (company == ADM1026_COMPANY_ANALOG_DEV
+			&& (verstep & 0xf0) == ADM1026_VERSTEP_GENERIC) {
+			dev_err(&adapter->dev, ": Unrecognized stepping "
+				"0x%02x. Defaulting to ADM1026.\n", verstep);
+			kind = adm1026;
+		} else if ((verstep & 0xf0) == ADM1026_VERSTEP_GENERIC) {
+			dev_err(&adapter->dev, ": Found version/stepping "
+				"0x%02x. Assuming generic ADM1026.\n",
+				verstep);
+			kind = any_chip;
+		} else {
+			dev_dbg(&new_client->dev, ": Autodetection "
+				"failed\n");
+			/* Not an ADM1026 ... */
+			if (kind == 0)  { /* User used force=x,y */
+				dev_err(&adapter->dev, "Generic ADM1026 not "
+					"found at %d,0x%02x.  Try "
+					"force_adm1026.\n",
+					i2c_adapter_id(adapter), address);
+			}
+			err = 0;
+			goto exitfree;
+		}
+	}
+
+	/* Fill in the chip specific driver values */
+	switch (kind) {
+	case any_chip :
+		type_name = "adm1026";
+		break;
+	case adm1026 :
+		type_name = "adm1026";
+		break;
+	default :
+		dev_err(&adapter->dev, ": Internal error, invalid "
+			"kind (%d)!", kind);
+		err = -EFAULT;
+		goto exitfree;
+	}
+	strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
+
+	/* Fill in the remaining client fields */
+	new_client->id = adm1026_id++;
+	data->type = kind;
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	dev_dbg(&new_client->dev, "(%d): Assigning ID %d to %s at %d,0x%02x\n",
+		new_client->id, new_client->id, new_client->name,
+		i2c_adapter_id(new_client->adapter),
+		new_client->addr);
+
+	/* Tell the I2C layer a new client has arrived */
+	if ((err = i2c_attach_client(new_client)))
+		goto exitfree;
+
+	/* Set the VRM version */
+	data->vrm = i2c_which_vrm();
+
+	/* Initialize the ADM1026 chip */
+	adm1026_init_client(new_client);
+
+	/* Register sysfs hooks */
+	device_create_file(&new_client->dev, &dev_attr_in0_input);
+	device_create_file(&new_client->dev, &dev_attr_in0_max);
+	device_create_file(&new_client->dev, &dev_attr_in0_min);
+	device_create_file(&new_client->dev, &dev_attr_in1_input);
+	device_create_file(&new_client->dev, &dev_attr_in1_max);
+	device_create_file(&new_client->dev, &dev_attr_in1_min);
+	device_create_file(&new_client->dev, &dev_attr_in2_input);
+	device_create_file(&new_client->dev, &dev_attr_in2_max);
+	device_create_file(&new_client->dev, &dev_attr_in2_min);
+	device_create_file(&new_client->dev, &dev_attr_in3_input);
+	device_create_file(&new_client->dev, &dev_attr_in3_max);
+	device_create_file(&new_client->dev, &dev_attr_in3_min);
+	device_create_file(&new_client->dev, &dev_attr_in4_input);
+	device_create_file(&new_client->dev, &dev_attr_in4_max);
+	device_create_file(&new_client->dev, &dev_attr_in4_min);
+	device_create_file(&new_client->dev, &dev_attr_in5_input);
+	device_create_file(&new_client->dev, &dev_attr_in5_max);
+	device_create_file(&new_client->dev, &dev_attr_in5_min);
+	device_create_file(&new_client->dev, &dev_attr_in6_input);
+	device_create_file(&new_client->dev, &dev_attr_in6_max);
+	device_create_file(&new_client->dev, &dev_attr_in6_min);
+	device_create_file(&new_client->dev, &dev_attr_in7_input);
+	device_create_file(&new_client->dev, &dev_attr_in7_max);
+	device_create_file(&new_client->dev, &dev_attr_in7_min);
+	device_create_file(&new_client->dev, &dev_attr_in8_input);
+	device_create_file(&new_client->dev, &dev_attr_in8_max);
+	device_create_file(&new_client->dev, &dev_attr_in8_min);
+	device_create_file(&new_client->dev, &dev_attr_in9_input);
+	device_create_file(&new_client->dev, &dev_attr_in9_max);
+	device_create_file(&new_client->dev, &dev_attr_in9_min);
+	device_create_file(&new_client->dev, &dev_attr_in10_input);
+	device_create_file(&new_client->dev, &dev_attr_in10_max);
+	device_create_file(&new_client->dev, &dev_attr_in10_min);
+	device_create_file(&new_client->dev, &dev_attr_in11_input);
+	device_create_file(&new_client->dev, &dev_attr_in11_max);
+	device_create_file(&new_client->dev, &dev_attr_in11_min);
+	device_create_file(&new_client->dev, &dev_attr_in12_input);
+	device_create_file(&new_client->dev, &dev_attr_in12_max);
+	device_create_file(&new_client->dev, &dev_attr_in12_min);
+	device_create_file(&new_client->dev, &dev_attr_in13_input);
+	device_create_file(&new_client->dev, &dev_attr_in13_max);
+	device_create_file(&new_client->dev, &dev_attr_in13_min);
+	device_create_file(&new_client->dev, &dev_attr_in14_input);
+	device_create_file(&new_client->dev, &dev_attr_in14_max);
+	device_create_file(&new_client->dev, &dev_attr_in14_min);
+	device_create_file(&new_client->dev, &dev_attr_in15_input);
+	device_create_file(&new_client->dev, &dev_attr_in15_max);
+	device_create_file(&new_client->dev, &dev_attr_in15_min);
+	device_create_file(&new_client->dev, &dev_attr_in16_input);
+	device_create_file(&new_client->dev, &dev_attr_in16_max);
+	device_create_file(&new_client->dev, &dev_attr_in16_min);
+	device_create_file(&new_client->dev, &dev_attr_fan1_input);
+	device_create_file(&new_client->dev, &dev_attr_fan1_div);
+	device_create_file(&new_client->dev, &dev_attr_fan1_min);
+	device_create_file(&new_client->dev, &dev_attr_fan2_input);
+	device_create_file(&new_client->dev, &dev_attr_fan2_div);
+	device_create_file(&new_client->dev, &dev_attr_fan2_min);
+	device_create_file(&new_client->dev, &dev_attr_fan3_input);
+	device_create_file(&new_client->dev, &dev_attr_fan3_div);
+	device_create_file(&new_client->dev, &dev_attr_fan3_min);
+	device_create_file(&new_client->dev, &dev_attr_fan4_input);
+	device_create_file(&new_client->dev, &dev_attr_fan4_div);
+	device_create_file(&new_client->dev, &dev_attr_fan4_min);
+	device_create_file(&new_client->dev, &dev_attr_fan5_input);
+	device_create_file(&new_client->dev, &dev_attr_fan5_div);
+	device_create_file(&new_client->dev, &dev_attr_fan5_min);
+	device_create_file(&new_client->dev, &dev_attr_fan6_input);
+	device_create_file(&new_client->dev, &dev_attr_fan6_div);
+	device_create_file(&new_client->dev, &dev_attr_fan6_min);
+	device_create_file(&new_client->dev, &dev_attr_fan7_input);
+	device_create_file(&new_client->dev, &dev_attr_fan7_div);
+	device_create_file(&new_client->dev, &dev_attr_fan7_min);
+	device_create_file(&new_client->dev, &dev_attr_fan8_input);
+	device_create_file(&new_client->dev, &dev_attr_fan8_div);
+	device_create_file(&new_client->dev, &dev_attr_fan8_min);
+	device_create_file(&new_client->dev, &dev_attr_temp1_input);
+	device_create_file(&new_client->dev, &dev_attr_temp1_max);
+	device_create_file(&new_client->dev, &dev_attr_temp1_min);
+	device_create_file(&new_client->dev, &dev_attr_temp2_input);
+	device_create_file(&new_client->dev, &dev_attr_temp2_max);
+	device_create_file(&new_client->dev, &dev_attr_temp2_min);
+	device_create_file(&new_client->dev, &dev_attr_temp3_input);
+	device_create_file(&new_client->dev, &dev_attr_temp3_max);
+	device_create_file(&new_client->dev, &dev_attr_temp3_min);
+	device_create_file(&new_client->dev, &dev_attr_temp1_offset);
+	device_create_file(&new_client->dev, &dev_attr_temp2_offset);
+	device_create_file(&new_client->dev, &dev_attr_temp3_offset);
+	device_create_file(&new_client->dev, 
+		&dev_attr_temp1_auto_point1_temp);
+	device_create_file(&new_client->dev, 
+		&dev_attr_temp2_auto_point1_temp);
+	device_create_file(&new_client->dev, 
+		&dev_attr_temp3_auto_point1_temp);
+	device_create_file(&new_client->dev,
+		&dev_attr_temp1_auto_point1_temp_hyst);
+	device_create_file(&new_client->dev,
+		&dev_attr_temp2_auto_point1_temp_hyst);
+	device_create_file(&new_client->dev,
+		&dev_attr_temp3_auto_point1_temp_hyst);
+	device_create_file(&new_client->dev, 
+		&dev_attr_temp1_auto_point2_temp);
+	device_create_file(&new_client->dev, 
+		&dev_attr_temp2_auto_point2_temp);
+	device_create_file(&new_client->dev, 
+		&dev_attr_temp3_auto_point2_temp);
+	device_create_file(&new_client->dev, &dev_attr_temp1_crit);
+	device_create_file(&new_client->dev, &dev_attr_temp2_crit);
+	device_create_file(&new_client->dev, &dev_attr_temp3_crit);
+	device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable);
+	device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable);
+	device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable);
+	device_create_file(&new_client->dev, &dev_attr_vid);
+	device_create_file(&new_client->dev, &dev_attr_vrm);
+	device_create_file(&new_client->dev, &dev_attr_alarms);
+	device_create_file(&new_client->dev, &dev_attr_alarm_mask);
+	device_create_file(&new_client->dev, &dev_attr_gpio);
+	device_create_file(&new_client->dev, &dev_attr_gpio_mask);
+	device_create_file(&new_client->dev, &dev_attr_pwm1);
+	device_create_file(&new_client->dev, &dev_attr_pwm2);
+	device_create_file(&new_client->dev, &dev_attr_pwm3);
+	device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
+	device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
+	device_create_file(&new_client->dev, &dev_attr_pwm3_enable);
+	device_create_file(&new_client->dev, &dev_attr_temp1_auto_point1_pwm);
+	device_create_file(&new_client->dev, &dev_attr_temp2_auto_point1_pwm);
+	device_create_file(&new_client->dev, &dev_attr_temp3_auto_point1_pwm);
+	device_create_file(&new_client->dev, &dev_attr_temp1_auto_point2_pwm);
+	device_create_file(&new_client->dev, &dev_attr_temp2_auto_point2_pwm);
+	device_create_file(&new_client->dev, &dev_attr_temp3_auto_point2_pwm);
+	device_create_file(&new_client->dev, &dev_attr_analog_out);
+	return 0;
+
+	/* Error out and cleanup code */
+exitfree:
+	kfree(new_client);
+exit:
+	return err;
+}
+static int __init sm_adm1026_init(void)
+{
+	return i2c_add_driver(&adm1026_driver);
+}
+
+static void  __exit sm_adm1026_exit(void)
+{
+	i2c_del_driver(&adm1026_driver);
+}
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, "
+              "Justin Thiessen <jthiessen@penguincomputing.com>");
+MODULE_DESCRIPTION("ADM1026 driver");
+
+module_init(sm_adm1026_init);
+module_exit(sm_adm1026_exit);
diff -Nru a/drivers/i2c/chips/adm1031.c b/drivers/i2c/chips/adm1031.c
--- a/drivers/i2c/chips/adm1031.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/i2c/chips/adm1031.c	2004-12-24 13:36:48 -08:00
@@ -57,10 +57,8 @@
 #define ADM1031_CONF2_TEMP_ENABLE(chan)	(0x10 << (chan))
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x2c, 0x2e, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_2(adm1030, adm1031);
@@ -298,12 +296,12 @@
 #define fan_auto_channel_offset(offset)						\
 static ssize_t show_fan_auto_channel_##offset (struct device *dev, char *buf)	\
 {										\
-	return show_fan_auto_channel(dev, buf, 0x##offset - 1);			\
+	return show_fan_auto_channel(dev, buf, offset - 1);			\
 }										\
 static ssize_t set_fan_auto_channel_##offset (struct device *dev,		\
 	const char *buf, size_t count)						\
 {										\
-	return set_fan_auto_channel(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_auto_channel(dev, buf, count, offset - 1);		\
 }										\
 static DEVICE_ATTR(auto_fan##offset##_channel, S_IRUGO | S_IWUSR,		\
 		   show_fan_auto_channel_##offset,				\
@@ -365,25 +363,25 @@
 #define auto_temp_reg(offset)							\
 static ssize_t show_auto_temp_##offset##_off (struct device *dev, char *buf)	\
 {										\
-	return show_auto_temp_off(dev, buf, 0x##offset - 1);			\
+	return show_auto_temp_off(dev, buf, offset - 1);			\
 }										\
 static ssize_t show_auto_temp_##offset##_min (struct device *dev, char *buf)	\
 {										\
-	return show_auto_temp_min(dev, buf, 0x##offset - 1);			\
+	return show_auto_temp_min(dev, buf, offset - 1);			\
 }										\
 static ssize_t show_auto_temp_##offset##_max (struct device *dev, char *buf)	\
 {										\
-	return show_auto_temp_max(dev, buf, 0x##offset - 1);			\
+	return show_auto_temp_max(dev, buf, offset - 1);			\
 }										\
 static ssize_t set_auto_temp_##offset##_min (struct device *dev,		\
 					     const char *buf, size_t count)	\
 {										\
-	return set_auto_temp_min(dev, buf, count, 0x##offset - 1);		\
+	return set_auto_temp_min(dev, buf, count, offset - 1);		\
 }										\
 static ssize_t set_auto_temp_##offset##_max (struct device *dev,		\
 					     const char *buf, size_t count)	\
 {										\
-	return set_auto_temp_max(dev, buf, count, 0x##offset - 1);		\
+	return set_auto_temp_max(dev, buf, count, offset - 1);		\
 }										\
 static DEVICE_ATTR(auto_temp##offset##_off, S_IRUGO,				\
 		   show_auto_temp_##offset##_off, NULL);			\
@@ -429,14 +427,14 @@
 #define pwm_reg(offset)							\
 static ssize_t show_pwm_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_pwm(dev, buf, 0x##offset - 1);			\
+	return show_pwm(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_pwm_##offset (struct device *dev,			\
 				 const char *buf, size_t count)		\
 {									\
-	return set_pwm(dev, buf, count, 0x##offset - 1);		\
+	return set_pwm(dev, buf, count, offset - 1);		\
 }									\
-static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR,		\
+static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR,			\
 		   show_pwm_##offset, set_pwm_##offset)
 
 pwm_reg(1);
@@ -565,25 +563,25 @@
 #define fan_offset(offset)						\
 static ssize_t show_fan_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_fan(dev, buf, 0x##offset - 1);			\
+	return show_fan(dev, buf, offset - 1);			\
 }									\
 static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)	\
 {									\
-	return show_fan_min(dev, buf, 0x##offset - 1);			\
+	return show_fan_min(dev, buf, offset - 1);			\
 }									\
 static ssize_t show_fan_##offset##_div (struct device *dev, char *buf)	\
 {									\
-	return show_fan_div(dev, buf, 0x##offset - 1);			\
+	return show_fan_div(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_fan_##offset##_min (struct device *dev,		\
 	const char *buf, size_t count)					\
 {									\
-	return set_fan_min(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_min(dev, buf, count, offset - 1);		\
 }									\
 static ssize_t set_fan_##offset##_div (struct device *dev,		\
 	const char *buf, size_t count)					\
 {									\
-	return set_fan_div(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_div(dev, buf, count, offset - 1);		\
 }									\
 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset,	\
 		   NULL);						\
@@ -675,34 +673,34 @@
 #define temp_reg(offset)							\
 static ssize_t show_temp_##offset (struct device *dev, char *buf)		\
 {										\
-	return show_temp(dev, buf, 0x##offset - 1);				\
+	return show_temp(dev, buf, offset - 1);				\
 }										\
 static ssize_t show_temp_##offset##_min (struct device *dev, char *buf)		\
 {										\
-	return show_temp_min(dev, buf, 0x##offset - 1);				\
+	return show_temp_min(dev, buf, offset - 1);				\
 }										\
 static ssize_t show_temp_##offset##_max (struct device *dev, char *buf)		\
 {										\
-	return show_temp_max(dev, buf, 0x##offset - 1);				\
+	return show_temp_max(dev, buf, offset - 1);				\
 }										\
 static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf)	\
 {										\
-	return show_temp_crit(dev, buf, 0x##offset - 1);			\
+	return show_temp_crit(dev, buf, offset - 1);			\
 }										\
 static ssize_t set_temp_##offset##_min (struct device *dev,			\
 					const char *buf, size_t count)		\
 {										\
-	return set_temp_min(dev, buf, count, 0x##offset - 1);			\
+	return set_temp_min(dev, buf, count, offset - 1);			\
 }										\
 static ssize_t set_temp_##offset##_max (struct device *dev,			\
 					const char *buf, size_t count)		\
 {										\
-	return set_temp_max(dev, buf, count, 0x##offset - 1);			\
+	return set_temp_max(dev, buf, count, offset - 1);			\
 }										\
 static ssize_t set_temp_##offset##_crit (struct device *dev,			\
 					 const char *buf, size_t count)		\
 {										\
-	return set_temp_crit(dev, buf, count, 0x##offset - 1);			\
+	return set_temp_crit(dev, buf, count, offset - 1);			\
 }										\
 static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset,		\
 		   NULL);							\
@@ -799,7 +797,7 @@
 	device_create_file(&new_client->dev, &dev_attr_fan1_input);
 	device_create_file(&new_client->dev, &dev_attr_fan1_div);
 	device_create_file(&new_client->dev, &dev_attr_fan1_min);
-	device_create_file(&new_client->dev, &dev_attr_fan1_pwm);
+	device_create_file(&new_client->dev, &dev_attr_pwm1);
 	device_create_file(&new_client->dev, &dev_attr_auto_fan1_channel);
 	device_create_file(&new_client->dev, &dev_attr_temp1_input);
 	device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -826,7 +824,7 @@
 		device_create_file(&new_client->dev, &dev_attr_fan2_input);
 		device_create_file(&new_client->dev, &dev_attr_fan2_div);
 		device_create_file(&new_client->dev, &dev_attr_fan2_min);
-		device_create_file(&new_client->dev, &dev_attr_fan2_pwm);
+		device_create_file(&new_client->dev, &dev_attr_pwm2);
 		device_create_file(&new_client->dev,
 				   &dev_attr_auto_fan2_channel);
 		device_create_file(&new_client->dev, &dev_attr_temp3_input);
diff -Nru a/drivers/i2c/chips/asb100.c b/drivers/i2c/chips/asb100.c
--- a/drivers/i2c/chips/asb100.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/i2c/chips/asb100.c	2004-12-24 13:36:56 -08:00
@@ -56,12 +56,11 @@
 #define ASB100_VERSION "1.0.0"
 
 /* I2C addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x28, 0x2f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
+					0x2e, 0x2f, I2C_CLIENT_END };
 
 /* ISA addresses to scan (none) */
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(asb100);
@@ -266,29 +265,29 @@
 static ssize_t \
 	show_in##offset (struct device *dev, char *buf) \
 { \
-	return show_in(dev, buf, 0x##offset); \
+	return show_in(dev, buf, offset); \
 } \
 static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
 		show_in##offset, NULL); \
 static ssize_t \
 	show_in##offset##_min (struct device *dev, char *buf) \
 { \
-	return show_in_min(dev, buf, 0x##offset); \
+	return show_in_min(dev, buf, offset); \
 } \
 static ssize_t \
 	show_in##offset##_max (struct device *dev, char *buf) \
 { \
-	return show_in_max(dev, buf, 0x##offset); \
+	return show_in_max(dev, buf, offset); \
 } \
 static ssize_t set_in##offset##_min (struct device *dev, \
 		const char *buf, size_t count) \
 { \
-	return set_in_min(dev, buf, count, 0x##offset); \
+	return set_in_min(dev, buf, count, offset); \
 } \
 static ssize_t set_in##offset##_max (struct device *dev, \
 		const char *buf, size_t count) \
 { \
-	return set_in_max(dev, buf, count, 0x##offset); \
+	return set_in_max(dev, buf, count, offset); \
 } \
 static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
 		show_in##offset##_min, set_in##offset##_min); \
@@ -591,12 +590,12 @@
 	return count;
 }
 
-static DEVICE_ATTR(fan1_pwm, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1);
-static DEVICE_ATTR(fan1_pwm_enable, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1);
+static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
 		show_pwm_enable1, set_pwm_enable1);
 #define device_create_file_pwm1(client) do { \
-	device_create_file(&new_client->dev, &dev_attr_fan1_pwm); \
-	device_create_file(&new_client->dev, &dev_attr_fan1_pwm_enable); \
+	device_create_file(&new_client->dev, &dev_attr_pwm1); \
+	device_create_file(&new_client->dev, &dev_attr_pwm1_enable); \
 } while (0)
 
 /* This function is called when:
diff -Nru a/drivers/i2c/chips/ds1621.c b/drivers/i2c/chips/ds1621.c
--- a/drivers/i2c/chips/ds1621.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/i2c/chips/ds1621.c	2004-12-24 13:37:31 -08:00
@@ -29,10 +29,9 @@
 #include "lm75.h"
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x48, 0x4f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
+					0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(ds1621);
@@ -96,7 +95,7 @@
 	.detach_client	= ds1621_detach_client,
 };
 
-static int ds1621_id = 0;
+static int ds1621_id;
 
 /* All registers are word-sized, except for the configuration register.
    DS1621 uses a high-byte first convention, which is exactly opposite to
diff -Nru a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
--- a/drivers/i2c/chips/eeprom.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/i2c/chips/eeprom.c	2004-12-24 13:36:47 -08:00
@@ -36,10 +36,9 @@
 #include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x50, 0x57, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
+					0x55, 0x56, 0x57, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(eeprom);
@@ -86,7 +85,7 @@
 	.detach_client	= eeprom_detach_client,
 };
 
-static int eeprom_id = 0;
+static int eeprom_id;
 
 static void eeprom_update_client(struct i2c_client *client, u8 slice)
 {
diff -Nru a/drivers/i2c/chips/fscher.c b/drivers/i2c/chips/fscher.c
--- a/drivers/i2c/chips/fscher.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/i2c/chips/fscher.c	2004-12-24 13:36:49 -08:00
@@ -38,9 +38,7 @@
  */
 
 static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
@@ -156,7 +154,7 @@
  * Internal variables
  */
 
-static int fscher_id = 0;
+static int fscher_id;
 
 /*
  * Sysfs stuff
diff -Nru a/drivers/i2c/chips/gl518sm.c b/drivers/i2c/chips/gl518sm.c
--- a/drivers/i2c/chips/gl518sm.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/i2c/chips/gl518sm.c	2004-12-24 13:37:29 -08:00
@@ -45,9 +45,7 @@
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_2(gl518sm_r00, gl518sm_r80);
@@ -164,7 +162,7 @@
  * Internal variables
  */
 
-static int gl518_id = 0;
+static int gl518_id;
 
 /*
  * Sysfs stuff
@@ -217,7 +215,8 @@
 {									\
 	struct i2c_client *client = to_i2c_client(dev);			\
 	struct gl518_data *data = i2c_get_clientdata(client);		\
-	data->value = type##_TO_REG(simple_strtol(buf, NULL, 10));	\
+	long val = simple_strtol(buf, NULL, 10);			\
+	data->value = type##_TO_REG(val);				\
 	gl518_write_value(client, reg, data->value);			\
 	return count;							\
 }
@@ -229,7 +228,8 @@
 	struct i2c_client *client = to_i2c_client(dev);			\
 	struct gl518_data *data = i2c_get_clientdata(client);		\
 	int regvalue = gl518_read_value(client, reg);			\
-	data->value = type##_TO_REG(simple_strtoul(buf, NULL, 10));	\
+	unsigned long val = simple_strtoul(buf, NULL, 10);		\
+	data->value = type##_TO_REG(val);				\
 	regvalue = (regvalue & ~mask) | (data->value << shift);		\
 	gl518_write_value(client, reg, regvalue);			\
 	return count;							\
diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/i2c/chips/it87.c	2004-12-24 13:37:18 -08:00
@@ -42,10 +42,11 @@
 
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x20, 0x2f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24,
+					0x25, 0x26, 0x27, 0x28, 0x29,
+					0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
+					0x2f, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_2(it87, it8712);
@@ -56,13 +57,6 @@
 #define PME	0x04	/* The device with the fan registers in it */
 #define	DEVID	0x20	/* Register: Device ID */
 
-static inline void
-superio_outb(int reg, int val)
-{
-	outb(reg, REG);
-	outb(val, VAL);
-}
-
 static inline int
 superio_inb(int reg)
 {
@@ -105,6 +99,10 @@
 /* Reset the registers on init if true */
 static int reset;
 
+/* Chip Type */
+
+static u16 chip_type;
+
 /* Many IT87 constants specified below */
 
 /* Length of ISA address segment */
@@ -226,7 +224,7 @@
 	.detach_client	= it87_detach_client,
 };
 
-static int it87_id = 0;
+static int it87_id;
 
 static ssize_t show_in(struct device *dev, char *buf, int nr)
 {
@@ -273,7 +271,7 @@
 static ssize_t							\
 	show_in##offset (struct device *dev, char *buf)		\
 {								\
-	return show_in(dev, buf, 0x##offset);			\
+	return show_in(dev, buf, offset);			\
 }								\
 static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
 
@@ -281,22 +279,22 @@
 static ssize_t							\
 	show_in##offset##_min (struct device *dev, char *buf)	\
 {								\
-	return show_in_min(dev, buf, 0x##offset);		\
+	return show_in_min(dev, buf, offset);			\
 }								\
 static ssize_t							\
 	show_in##offset##_max (struct device *dev, char *buf)	\
 {								\
-	return show_in_max(dev, buf, 0x##offset);		\
+	return show_in_max(dev, buf, offset);			\
 }								\
 static ssize_t set_in##offset##_min (struct device *dev, 	\
 		const char *buf, size_t count) 			\
 {								\
-	return set_in_min(dev, buf, count, 0x##offset);		\
+	return set_in_min(dev, buf, count, offset);		\
 }								\
 static ssize_t set_in##offset##_max (struct device *dev,	\
 			const char *buf, size_t count)		\
 {								\
-	return set_in_max(dev, buf, count, 0x##offset);		\
+	return set_in_max(dev, buf, count, offset);		\
 }								\
 static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, 	\
 		show_in##offset##_min, set_in##offset##_min);	\
@@ -360,27 +358,27 @@
 #define show_temp_offset(offset)					\
 static ssize_t show_temp_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_temp(dev, buf, 0x##offset - 1);			\
+	return show_temp(dev, buf, offset - 1);				\
 }									\
 static ssize_t								\
 show_temp_##offset##_max (struct device *dev, char *buf)		\
 {									\
-	return show_temp_max(dev, buf, 0x##offset - 1);			\
+	return show_temp_max(dev, buf, offset - 1);			\
 }									\
 static ssize_t								\
 show_temp_##offset##_min (struct device *dev, char *buf)		\
 {									\
-	return show_temp_min(dev, buf, 0x##offset - 1);			\
+	return show_temp_min(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_temp_##offset##_max (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_temp_max(dev, buf, count, 0x##offset - 1);		\
+	return set_temp_max(dev, buf, count, offset - 1);		\
 }									\
 static ssize_t set_temp_##offset##_min (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_temp_min(dev, buf, count, 0x##offset - 1);		\
+	return set_temp_min(dev, buf, count, offset - 1);		\
 }									\
 static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
 static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, 		\
@@ -423,12 +421,12 @@
 #define show_sensor_offset(offset)					\
 static ssize_t show_sensor_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_sensor(dev, buf, 0x##offset - 1);			\
+	return show_sensor(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_sensor_##offset (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_sensor(dev, buf, count, 0x##offset - 1);		\
+	return set_sensor(dev, buf, count, offset - 1);			\
 }									\
 static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, 		\
 		show_sensor_##offset, set_sensor_##offset);
@@ -505,25 +503,25 @@
 #define show_fan_offset(offset)						\
 static ssize_t show_fan_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_fan(dev, buf, 0x##offset - 1);			\
+	return show_fan(dev, buf, offset - 1);				\
 }									\
 static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)	\
 {									\
-	return show_fan_min(dev, buf, 0x##offset - 1);			\
+	return show_fan_min(dev, buf, offset - 1);			\
 }									\
 static ssize_t show_fan_##offset##_div (struct device *dev, char *buf)	\
 {									\
-	return show_fan_div(dev, buf, 0x##offset - 1);			\
+	return show_fan_div(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_fan_##offset##_min (struct device *dev, 		\
 	const char *buf, size_t count) 					\
 {									\
-	return set_fan_min(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_min(dev, buf, count, offset - 1);		\
 }									\
 static ssize_t set_fan_##offset##_div (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_fan_div(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_div(dev, buf, count, offset - 1);		\
 }									\
 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, 		\
@@ -592,9 +590,9 @@
 	u16 val;
 
 	superio_enter();
-	val = (superio_inb(DEVID) << 8) |
+	chip_type = (superio_inb(DEVID) << 8) |
 	       superio_inb(DEVID + 1);
-	if (val != IT8712F_DEVID) {
+	if (chip_type != IT8712F_DEVID) {
 		superio_exit();
 		return -ENODEV;
 	}
@@ -691,11 +689,9 @@
 	if (kind <= 0) {
 		i = it87_read_value(new_client, IT87_REG_CHIPID);
 		if (i == 0x90) {
-			u16 val;
 			kind = it87;
-			val = (superio_inb(DEVID) << 8) |
-			superio_inb(DEVID + 1);
-			if (val == IT8712F_DEVID) kind = it8712;
+			if ((is_isa) && (chip_type == IT8712F_DEVID))
+				kind = it8712;
 		}
 		else {
 			if (kind == 0)
diff -Nru a/drivers/i2c/chips/lm63.c b/drivers/i2c/chips/lm63.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/i2c/chips/lm63.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,567 @@
+/*
+ * lm63.c - driver for the National Semiconductor LM63 temperature sensor
+ *          with integrated fan control
+ * Copyright (C) 2004  Jean Delvare <khali@linux-fr.org>
+ * Based on the lm90 driver.
+ *
+ * The LM63 is a sensor chip made by National Semiconductor. It measures
+ * two temperatures (its own and one external one) and the speed of one
+ * fan, those speed it can additionally control. Complete datasheet can be
+ * obtained from National's website at:
+ *   http://www.national.com/pf/LM/LM63.html
+ *
+ * The LM63 is basically an LM86 with fan speed monitoring and control
+ * capabilities added. It misses some of the LM86 features though:
+ *  - No low limit for local temperature.
+ *  - No critical limit for local temperature.
+ *  - Critical limit for remote temperature can be changed only once. We
+ *    will consider that the critical limit is read-only.
+ *
+ * The datasheet isn't very clear about what the tachometer reading is.
+ * I had a explanation from National Semiconductor though. The two lower
+ * bits of the read value have to be masked out. The value is still 16 bit
+ * in width.
+ *
+ * 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.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+
+/*
+ * Addresses to scan
+ * Address is fully defined internally and cannot be changed.
+ */
+
+static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+
+/*
+ * Insmod parameters
+ */
+
+SENSORS_INSMOD_1(lm63);
+
+/*
+ * The LM63 registers
+ */
+
+#define LM63_REG_CONFIG1		0x03
+#define LM63_REG_CONFIG2		0xBF
+#define LM63_REG_CONFIG_FAN		0x4A
+
+#define LM63_REG_TACH_COUNT_MSB		0x47
+#define LM63_REG_TACH_COUNT_LSB		0x46
+#define LM63_REG_TACH_LIMIT_MSB		0x49
+#define LM63_REG_TACH_LIMIT_LSB		0x48
+
+#define LM63_REG_PWM_VALUE		0x4C
+#define LM63_REG_PWM_FREQ		0x4D
+
+#define LM63_REG_LOCAL_TEMP		0x00
+#define LM63_REG_LOCAL_HIGH		0x05
+
+#define LM63_REG_REMOTE_TEMP_MSB	0x01
+#define LM63_REG_REMOTE_TEMP_LSB	0x10
+#define LM63_REG_REMOTE_OFFSET_MSB	0x11
+#define LM63_REG_REMOTE_OFFSET_LSB	0x12
+#define LM63_REG_REMOTE_HIGH_MSB	0x07
+#define LM63_REG_REMOTE_HIGH_LSB	0x13
+#define LM63_REG_REMOTE_LOW_MSB		0x08
+#define LM63_REG_REMOTE_LOW_LSB		0x14
+#define LM63_REG_REMOTE_TCRIT		0x19
+#define LM63_REG_REMOTE_TCRIT_HYST	0x21
+
+#define LM63_REG_ALERT_STATUS		0x02
+#define LM63_REG_ALERT_MASK		0x16
+
+#define LM63_REG_MAN_ID			0xFE
+#define LM63_REG_CHIP_ID		0xFF
+
+/*
+ * Conversions and various macros
+ * For tachometer counts, the LM63 uses 16-bit values.
+ * For local temperature and high limit, remote critical limit and hysteresis
+ * value, it uses signed 8-bit values with LSB = 1 degree Celcius.
+ * For remote temperature, low and high limits, it uses signed 11-bit values
+ * with LSB = 0.125 degree Celcius, left-justified in 16-bit registers.
+ */
+
+#define FAN_FROM_REG(reg)	((reg) == 0xFFFC || (reg) == 0 ? 0 : \
+				 5400000 / (reg))
+#define FAN_TO_REG(val)		((val) <= 82 ? 0xFFFC : \
+				 (5400000 / (val)) & 0xFFFC)
+#define TEMP8_FROM_REG(reg)	((reg) * 1000)
+#define TEMP8_TO_REG(val)	((val) <= -128000 ? -128 : \
+				 (val) >= 127000 ? 127 : \
+				 (val) < 0 ? ((val) - 500) / 1000 : \
+				 ((val) + 500) / 1000)
+#define TEMP11_FROM_REG(reg)	((reg) / 32 * 125)
+#define TEMP11_TO_REG(val)	((val) <= -128000 ? 0x8000 : \
+				 (val) >= 127875 ? 0x7FE0 : \
+				 (val) < 0 ? ((val) - 62) / 125 * 32 : \
+				 ((val) + 62) / 125 * 32)
+#define HYST_TO_REG(val)	((val) <= 0 ? 0 : \
+				 (val) >= 127000 ? 127 : \
+				 ((val) + 500) / 1000)
+
+/*
+ * Functions declaration
+ */
+
+static int lm63_attach_adapter(struct i2c_adapter *adapter);
+static int lm63_detach_client(struct i2c_client *client);
+
+static struct lm63_data *lm63_update_device(struct device *dev);
+
+static int lm63_detect(struct i2c_adapter *adapter, int address, int kind);
+static void lm63_init_client(struct i2c_client *client);
+
+/*
+ * Driver data (common to all clients)
+ */
+
+static struct i2c_driver lm63_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "lm63",
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= lm63_attach_adapter,
+	.detach_client	= lm63_detach_client,
+};
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct lm63_data {
+	struct i2c_client client;
+	struct semaphore update_lock;
+	char valid; /* zero until following fields are valid */
+	unsigned long last_updated; /* in jiffies */
+
+	/* registers values */
+	u8 config, config_fan;
+	u16 fan1_input;
+	u16 fan1_low;
+	u8 pwm1_freq;
+	u8 pwm1_value;
+	s8 temp1_input;
+	s8 temp1_high;
+	s16 temp2_input;
+	s16 temp2_high;
+	s16 temp2_low;
+	s8 temp2_crit;
+	u8 temp2_crit_hyst;
+	u8 alarms;
+};
+
+/*
+ * Sysfs callback functions and files
+ */
+
+#define show_fan(value) \
+static ssize_t show_##value(struct device *dev, char *buf) \
+{ \
+	struct lm63_data *data = lm63_update_device(dev); \
+	return sprintf(buf, "%d\n", FAN_FROM_REG(data->value)); \
+}
+show_fan(fan1_input);
+show_fan(fan1_low);
+
+static ssize_t set_fan1_low(struct device *dev, const char *buf,
+	size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm63_data *data = i2c_get_clientdata(client);
+	unsigned long val = simple_strtoul(buf, NULL, 10);
+	data->fan1_low = FAN_TO_REG(val);
+	i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
+				  data->fan1_low & 0xFF);
+	i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB,
+				  data->fan1_low >> 8);
+	return count;
+}
+
+static ssize_t show_pwm1(struct device *dev, char *buf)
+{
+	struct lm63_data *data = lm63_update_device(dev);
+	return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ?
+		       255 : (data->pwm1_value * 255 + data->pwm1_freq) /
+		       (2 * data->pwm1_freq));
+}
+
+static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm63_data *data = i2c_get_clientdata(client);
+	unsigned long val;
+	
+	if (!(data->config_fan & 0x20)) /* register is read-only */
+		return -EPERM;
+
+	val = simple_strtoul(buf, NULL, 10);
+	data->pwm1_value = val <= 0 ? 0 :
+			   val >= 255 ? 2 * data->pwm1_freq :
+			   (val * data->pwm1_freq * 2 + 127) / 255;
+	i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value);
+	return count;
+}
+
+static ssize_t show_pwm1_enable(struct device *dev, char *buf)
+{
+	struct lm63_data *data = lm63_update_device(dev);
+	return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2);
+}
+
+#define show_temp8(value) \
+static ssize_t show_##value(struct device *dev, char *buf) \
+{ \
+	struct lm63_data *data = lm63_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->value)); \
+}
+#define show_temp11(value) \
+static ssize_t show_##value(struct device *dev, char *buf) \
+{ \
+	struct lm63_data *data = lm63_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->value)); \
+}
+show_temp8(temp1_input);
+show_temp8(temp1_high);
+show_temp11(temp2_input);
+show_temp11(temp2_high);
+show_temp11(temp2_low);
+show_temp8(temp2_crit);
+
+#define set_temp8(value, reg) \
+static ssize_t set_##value(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct lm63_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->value = TEMP8_TO_REG(val); \
+	i2c_smbus_write_byte_data(client, reg, data->value); \
+	return count; \
+}
+#define set_temp11(value, reg_msb, reg_lsb) \
+static ssize_t set_##value(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct lm63_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->value = TEMP11_TO_REG(val); \
+	i2c_smbus_write_byte_data(client, reg_msb, data->value >> 8); \
+	i2c_smbus_write_byte_data(client, reg_lsb, data->value & 0xff); \
+	return count; \
+}
+set_temp8(temp1_high, LM63_REG_LOCAL_HIGH);
+set_temp11(temp2_high, LM63_REG_REMOTE_HIGH_MSB, LM63_REG_REMOTE_HIGH_LSB);
+set_temp11(temp2_low, LM63_REG_REMOTE_LOW_MSB, LM63_REG_REMOTE_LOW_LSB);
+
+/* Hysteresis register holds a relative value, while we want to present
+   an absolute to user-space */
+static ssize_t show_temp2_crit_hyst(struct device *dev, char *buf)
+{
+	struct lm63_data *data = lm63_update_device(dev);
+	return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp2_crit)
+		       - TEMP8_FROM_REG(data->temp2_crit_hyst));
+}
+
+/* And now the other way around, user-space provides an absolute
+   hysteresis value and we have to store a relative one */
+static ssize_t set_temp2_crit_hyst(struct device *dev, const char *buf,
+	size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm63_data *data = i2c_get_clientdata(client);
+	int hyst = TEMP8_FROM_REG(data->temp2_crit) -
+		   simple_strtol(buf, NULL, 10);
+	i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
+				  HYST_TO_REG(hyst));
+	return count;
+}
+
+static ssize_t show_alarms(struct device *dev, char *buf)
+{
+	struct lm63_data *data = lm63_update_device(dev);
+	return sprintf(buf, "%u\n", data->alarms);
+}
+
+static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan1_input, NULL);
+static DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan1_low,
+	set_fan1_low);
+
+static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1);
+static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL);
+
+static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL);
+static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_high,
+	set_temp1_high);
+
+static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp2_input, NULL);
+static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp2_low,
+	set_temp2_low);
+static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp2_high,
+	set_temp2_high);
+static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp2_crit, NULL);
+static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst,
+	set_temp2_crit_hyst);
+
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
+
+/*
+ * Real code
+ */
+
+static int lm63_attach_adapter(struct i2c_adapter *adapter)
+{
+	if (!(adapter->class & I2C_CLASS_HWMON))
+		return 0;
+	return i2c_detect(adapter, &addr_data, lm63_detect);
+}
+
+/*
+ * The following function does more than just detection. If detection
+ * succeeds, it also registers the new chip.
+ */
+static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+	struct i2c_client *new_client;
+	struct lm63_data *data;
+	int err = 0;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		goto exit;
+
+	if (!(data = kmalloc(sizeof(struct lm63_data), GFP_KERNEL))) {
+		err = -ENOMEM;
+		goto exit;
+	}
+	memset(data, 0, sizeof(struct lm63_data));
+
+	/* The common I2C client data is placed right before the
+	   LM63-specific data. */
+	new_client = &data->client;
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	new_client->adapter = adapter;
+	new_client->driver = &lm63_driver;
+	new_client->flags = 0;
+
+	/* Default to an LM63 if forced */
+	if (kind == 0)
+		kind = lm63;
+
+	if (kind < 0) { /* must identify */
+		u8 man_id, chip_id, reg_config1, reg_config2;
+		u8 reg_alert_status, reg_alert_mask;
+
+		man_id = i2c_smbus_read_byte_data(new_client,
+			 LM63_REG_MAN_ID);
+		chip_id = i2c_smbus_read_byte_data(new_client,
+			  LM63_REG_CHIP_ID);
+		reg_config1 = i2c_smbus_read_byte_data(new_client,
+			      LM63_REG_CONFIG1);
+		reg_config2 = i2c_smbus_read_byte_data(new_client,
+			      LM63_REG_CONFIG2);
+		reg_alert_status = i2c_smbus_read_byte_data(new_client,
+				   LM63_REG_ALERT_STATUS);
+		reg_alert_mask = i2c_smbus_read_byte_data(new_client,
+				 LM63_REG_ALERT_MASK);
+
+		if (man_id == 0x01 /* National Semiconductor */
+		 && chip_id == 0x41 /* LM63 */
+		 && (reg_config1 & 0x18) == 0x00
+		 && (reg_config2 & 0xF8) == 0x00
+		 && (reg_alert_status & 0x20) == 0x00
+		 && (reg_alert_mask & 0xA4) == 0xA4) {
+			kind = lm63;
+		} else { /* failed */
+			dev_dbg(&adapter->dev, "Unsupported chip "
+				"(man_id=0x%02X, chip_id=0x%02X).\n",
+				man_id, chip_id);
+			goto exit_free;
+		}
+	}
+
+	strlcpy(new_client->name, "lm63", I2C_NAME_SIZE);
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	/* Tell the I2C layer a new client has arrived */
+	if ((err = i2c_attach_client(new_client)))
+		goto exit_free;
+
+	/* Initialize the LM63 chip */
+	lm63_init_client(new_client);
+
+	/* Register sysfs hooks */
+	if (data->config & 0x04) { /* tachometer enabled */
+		device_create_file(&new_client->dev, &dev_attr_fan1_input);
+		device_create_file(&new_client->dev, &dev_attr_fan1_min);
+	}
+	device_create_file(&new_client->dev, &dev_attr_pwm1);
+	device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
+	device_create_file(&new_client->dev, &dev_attr_temp1_input);
+	device_create_file(&new_client->dev, &dev_attr_temp2_input);
+	device_create_file(&new_client->dev, &dev_attr_temp2_min);
+	device_create_file(&new_client->dev, &dev_attr_temp1_max);
+	device_create_file(&new_client->dev, &dev_attr_temp2_max);
+	device_create_file(&new_client->dev, &dev_attr_temp2_crit);
+	device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst);
+	device_create_file(&new_client->dev, &dev_attr_alarms);
+
+	return 0;
+
+exit_free:
+	kfree(data);
+exit:
+	return err;
+}
+
+/* Idealy we shouldn't have to initialize anything, since the BIOS
+   should have taken care of everything */
+static void lm63_init_client(struct i2c_client *client)
+{
+	struct lm63_data *data = i2c_get_clientdata(client);
+
+	data->config = i2c_smbus_read_byte_data(client, LM63_REG_CONFIG1);
+	data->config_fan = i2c_smbus_read_byte_data(client,
+						    LM63_REG_CONFIG_FAN);
+
+	/* Start converting if needed */
+	if (data->config & 0x40) { /* standby */
+		dev_dbg(&client->dev, "Switching to operational mode");
+		data->config &= 0xA7;
+		i2c_smbus_write_byte_data(client, LM63_REG_CONFIG1,
+					  data->config);
+	}
+
+	/* We may need pwm1_freq before ever updating the client data */
+	data->pwm1_freq = i2c_smbus_read_byte_data(client, LM63_REG_PWM_FREQ);
+	if (data->pwm1_freq == 0)
+		data->pwm1_freq = 1;
+
+	/* Show some debug info about the LM63 configuration */
+	dev_dbg(&client->dev, "Alert/tach pin configured for %s\n",
+		(data->config & 0x04) ? "tachometer input" :
+		"alert output");
+	dev_dbg(&client->dev, "PWM clock %s kHz, output frequency %u Hz\n",
+		(data->config_fan & 0x04) ? "1.4" : "360",
+		((data->config_fan & 0x04) ? 700 : 180000) / data->pwm1_freq);
+	dev_dbg(&client->dev, "PWM output active %s, %s mode\n",
+		(data->config_fan & 0x10) ? "low" : "high",
+		(data->config_fan & 0x20) ? "manual" : "auto");
+}
+
+static int lm63_detach_client(struct i2c_client *client)
+{
+	int err;
+
+	if ((err = i2c_detach_client(client))) {
+		dev_err(&client->dev, "Client deregistration failed, "
+			"client not detached\n");
+		return err;
+	}
+
+	kfree(i2c_get_clientdata(client));
+	return 0;
+}
+
+static struct lm63_data *lm63_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm63_data *data = i2c_get_clientdata(client);
+
+	down(&data->update_lock);
+
+	if ((jiffies - data->last_updated > HZ) ||
+	    (jiffies < data->last_updated) ||
+	    !data->valid) {
+		if (data->config & 0x04) { /* tachometer enabled  */
+			/* order matters for fan1_input */
+			data->fan1_input = i2c_smbus_read_byte_data(client,
+					   LM63_REG_TACH_COUNT_LSB) & 0xFC;
+			data->fan1_input |= i2c_smbus_read_byte_data(client,
+					    LM63_REG_TACH_COUNT_MSB) << 8;
+			data->fan1_low = (i2c_smbus_read_byte_data(client,
+					  LM63_REG_TACH_LIMIT_LSB) & 0xFC)
+				       | (i2c_smbus_read_byte_data(client,
+					  LM63_REG_TACH_LIMIT_MSB) << 8);
+		}
+
+		data->pwm1_freq = i2c_smbus_read_byte_data(client,
+				  LM63_REG_PWM_FREQ);
+		if (data->pwm1_freq == 0)
+			data->pwm1_freq = 1;
+		data->pwm1_value = i2c_smbus_read_byte_data(client,
+				   LM63_REG_PWM_VALUE);
+
+		data->temp1_input = i2c_smbus_read_byte_data(client,
+				    LM63_REG_LOCAL_TEMP);
+		data->temp1_high = i2c_smbus_read_byte_data(client,
+				   LM63_REG_LOCAL_HIGH);
+
+		/* order matters for temp2_input */
+		data->temp2_input = i2c_smbus_read_byte_data(client,
+				    LM63_REG_REMOTE_TEMP_MSB) << 8;
+		data->temp2_input |= i2c_smbus_read_byte_data(client,
+				     LM63_REG_REMOTE_TEMP_LSB);
+		data->temp2_high = (i2c_smbus_read_byte_data(client,
+				   LM63_REG_REMOTE_HIGH_MSB) << 8)
+				 | i2c_smbus_read_byte_data(client,
+				   LM63_REG_REMOTE_HIGH_LSB);
+		data->temp2_low = (i2c_smbus_read_byte_data(client,
+				  LM63_REG_REMOTE_LOW_MSB) << 8)
+				| i2c_smbus_read_byte_data(client,
+				  LM63_REG_REMOTE_LOW_LSB);
+		data->temp2_crit = i2c_smbus_read_byte_data(client,
+				   LM63_REG_REMOTE_TCRIT);
+		data->temp2_crit_hyst = i2c_smbus_read_byte_data(client,
+					LM63_REG_REMOTE_TCRIT_HYST);
+
+		data->alarms = i2c_smbus_read_byte_data(client,
+			       LM63_REG_ALERT_STATUS) & 0x7F;
+
+		data->last_updated = jiffies;
+		data->valid = 1;
+	}
+
+	up(&data->update_lock);
+
+	return data;
+}
+
+static int __init sensors_lm63_init(void)
+{
+	return i2c_add_driver(&lm63_driver);
+}
+
+static void __exit sensors_lm63_exit(void)
+{
+	i2c_del_driver(&lm63_driver);
+}
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("LM63 driver");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_lm63_init);
+module_exit(sensors_lm63_exit);
diff -Nru a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c
--- a/drivers/i2c/chips/lm75.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/i2c/chips/lm75.c	2004-12-24 13:36:16 -08:00
@@ -28,10 +28,9 @@
 
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x48, 0x4f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
+					0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(lm75);
@@ -74,7 +73,7 @@
 	.detach_client	= lm75_detach_client,
 };
 
-static int lm75_id = 0;
+static int lm75_id;
 
 #define show(value)	\
 static ssize_t show_##value(struct device *dev, char *buf)		\
diff -Nru a/drivers/i2c/chips/lm77.c b/drivers/i2c/chips/lm77.c
--- a/drivers/i2c/chips/lm77.c	2004-12-24 13:37:44 -08:00
+++ b/drivers/i2c/chips/lm77.c	2004-12-24 13:37:44 -08:00
@@ -34,10 +34,8 @@
 
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x48, 0x4b, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(lm77);
@@ -83,7 +81,7 @@
 	.detach_client	= lm77_detach_client,
 };
 
-static int lm77_id = 0;
+static int lm77_id;
 
 /* straight from the datasheet */
 #define LM77_TEMP_MIN (-55000)
diff -Nru a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c
--- a/drivers/i2c/chips/lm78.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/i2c/chips/lm78.c	2004-12-24 13:37:18 -08:00
@@ -27,10 +27,11 @@
 #include <asm/io.h>
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x20, 0x2f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24,
+					0x25, 0x26, 0x27, 0x28, 0x29,
+					0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
+					0x2f, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_3(lm78, lm78j, lm79);
@@ -229,29 +230,29 @@
 static ssize_t							\
 	show_in##offset (struct device *dev, char *buf)		\
 {								\
-	return show_in(dev, buf, 0x##offset);			\
+	return show_in(dev, buf, offset);			\
 }								\
 static DEVICE_ATTR(in##offset##_input, S_IRUGO, 		\
 		show_in##offset, NULL);				\
 static ssize_t							\
 	show_in##offset##_min (struct device *dev, char *buf)   \
 {								\
-	return show_in_min(dev, buf, 0x##offset);		\
+	return show_in_min(dev, buf, offset);			\
 }								\
 static ssize_t							\
 	show_in##offset##_max (struct device *dev, char *buf)   \
 {								\
-	return show_in_max(dev, buf, 0x##offset);		\
+	return show_in_max(dev, buf, offset);			\
 }								\
 static ssize_t set_in##offset##_min (struct device *dev,	\
 		const char *buf, size_t count)			\
 {								\
-	return set_in_min(dev, buf, count, 0x##offset);		\
+	return set_in_min(dev, buf, count, offset);		\
 }								\
 static ssize_t set_in##offset##_max (struct device *dev,	\
 		const char *buf, size_t count)			\
 {								\
-	return set_in_max(dev, buf, count, 0x##offset);		\
+	return set_in_max(dev, buf, count, offset);		\
 }								\
 static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR,		\
 		show_in##offset##_min, set_in##offset##_min);	\
@@ -375,20 +376,20 @@
 #define show_fan_offset(offset)						\
 static ssize_t show_fan_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_fan(dev, buf, 0x##offset - 1);			\
+	return show_fan(dev, buf, offset - 1);				\
 }									\
 static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)  \
 {									\
-	return show_fan_min(dev, buf, 0x##offset - 1);			\
+	return show_fan_min(dev, buf, offset - 1);			\
 }									\
 static ssize_t show_fan_##offset##_div (struct device *dev, char *buf)  \
 {									\
-	return show_fan_div(dev, buf, 0x##offset - 1);			\
+	return show_fan_div(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_fan_##offset##_min (struct device *dev,		\
 		const char *buf, size_t count)				\
 {									\
-	return set_fan_min(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_min(dev, buf, count, offset - 1);		\
 }									\
 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR,		\
@@ -692,26 +693,12 @@
 /* Called when we have found a new LM78. It should set limits, etc. */
 static void lm78_init_client(struct i2c_client *client)
 {
-	struct lm78_data *data = i2c_get_clientdata(client);
-	int vid;
-
-	/* Reset all except Watchdog values and last conversion values
-	   This sets fan-divs to 2, among others */
-	lm78_write_value(client, LM78_REG_CONFIG, 0x80);
-
-	vid = lm78_read_value(client, LM78_REG_VID_FANDIV) & 0x0f;
-	if (data->type == lm79)
-		vid |=
-		    (lm78_read_value(client, LM78_REG_CHIPID) & 0x01) << 4;
-	else
-		vid |= 0x10;
-	vid = VID_FROM_REG(vid);
+	u8 config = lm78_read_value(client, LM78_REG_CONFIG);
 
 	/* Start monitoring */
-	lm78_write_value(client, LM78_REG_CONFIG,
-			 (lm78_read_value(client, LM78_REG_CONFIG) & 0xf7)
-			 | 0x01);
-
+	if (!(config & 0x01))
+		lm78_write_value(client, LM78_REG_CONFIG,
+				 (config & 0xf7) | 0x01);
 }
 
 static struct lm78_data *lm78_update_device(struct device *dev)
diff -Nru a/drivers/i2c/chips/lm80.c b/drivers/i2c/chips/lm80.c
--- a/drivers/i2c/chips/lm80.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/i2c/chips/lm80.c	2004-12-24 13:36:18 -08:00
@@ -29,10 +29,9 @@
 #include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x28, 0x2f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
+					0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(lm80);
@@ -145,7 +144,7 @@
  * Internal variables
  */
 
-static int lm80_id = 0;
+static int lm80_id;
 
 /*
  * Driver data (common to all clients)
@@ -262,14 +261,15 @@
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm80_data *data = i2c_get_clientdata(client);
-	unsigned long min;
+	unsigned long min, val;
 	u8 reg;
 
 	/* Save fan_min */
 	min = FAN_FROM_REG(data->fan_min[nr],
 			   DIV_FROM_REG(data->fan_div[nr]));
 
-	data->fan_div[nr] = DIV_TO_REG(simple_strtoul(buf, NULL, 10));
+	val = simple_strtoul(buf, NULL, 10);
+	data->fan_div[nr] = DIV_TO_REG(val);
 
 	reg = (lm80_read_value(client, LM80_REG_FANDIV) & ~(3 << (2 * (nr + 1))))
 	    | (data->fan_div[nr] << (2 * (nr + 1)));
diff -Nru a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c
--- a/drivers/i2c/chips/lm83.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/i2c/chips/lm83.c	2004-12-24 13:36:48 -08:00
@@ -40,11 +40,11 @@
  * addresses.
  */
 
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b,
-	0x4c, 0x4e, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
+					0x29, 0x2a, 0x2b,
+					0x4c, 0x4d, 0x4e,
+					I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
@@ -80,13 +80,14 @@
 
 /*
  * Conversions and various macros
- * The LM83 uses signed 8-bit values.
+ * The LM83 uses signed 8-bit values with LSB = 1 degree Celcius.
  */
 
-#define TEMP_FROM_REG(val)	(((val) > 127 ? (val) - 0x100 : (val)) * 1000)
-#define TEMP_TO_REG(val)	((val) <= -50000 ? -50 + 0x100 : (val) >= 127000 ? 127 : \
-				 (val) > -500 ? ((val)+500) / 1000 : \
-				 ((val)-500) / 1000 + 0x100)
+#define TEMP_FROM_REG(val)	((val) * 1000)
+#define TEMP_TO_REG(val)	((val) <= -128000 ? -128 : \
+				 (val) >= 127000 ? 127 : \
+				 (val) < 0 ? ((val) - 500) / 1000 : \
+				 ((val) + 500) / 1000)
 
 static const u8 LM83_REG_R_TEMP[] = {
 	LM83_REG_R_LOCAL_TEMP,
@@ -142,9 +143,9 @@
 	unsigned long last_updated; /* in jiffies */
 
 	/* registers values */
-	u8 temp_input[4];
-	u8 temp_high[4];
-	u8 temp_crit;
+	s8 temp_input[4];
+	s8 temp_high[4];
+	s8 temp_crit;
 	u16 alarms; /* bitvector, combined */
 };
 
@@ -152,7 +153,7 @@
  * Internal variables
  */
 
-static int lm83_id = 0;
+static int lm83_id;
 
 /*
  * Sysfs stuff
@@ -180,7 +181,8 @@
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct lm83_data *data = i2c_get_clientdata(client); \
-	data->value = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->value = TEMP_TO_REG(val); \
 	i2c_smbus_write_byte_data(client, reg, data->value); \
 	return count; \
 }
diff -Nru a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c
--- a/drivers/i2c/chips/lm85.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/i2c/chips/lm85.c	2004-12-24 13:36:47 -08:00
@@ -4,6 +4,7 @@
     Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl> 
     Copyright (c) 2002, 2003  Philip Pokorny <ppokorny@penguincomputing.com>
     Copyright (c) 2003        Margit Schubert-While <margitsw@t-online.de>
+    Copyright (c) 2004        Justin Thiessen <jthiessen@penguincomputing.com>
 
     Chip details at	      <http://www.national.com/ds/LM/LM85.pdf>
 
@@ -29,17 +30,10 @@
 #include <linux/i2c.h>
 #include <linux/i2c-sensor.h>
 #include <linux/i2c-vid.h>
-/*
-#include <asm/io.h>
-*/
-
-#undef	LM85EXTENDEDFUNC	/* Extended functionality */
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_4(lm85b, lm85c, adm1027, adt7463);
@@ -163,8 +157,6 @@
 
 #define EXT_FROM_REG(val,sensor)	(((val)>>(sensor * 2))&0x03)
 
-#ifdef	LM85EXTENDEDFUNC	/* Extended functionality */
-
 /* ZONEs have the following parameters:
  *    Limit (low) temp,           1. degC
  *    Hysteresis (below limit),   1. degC (0-15)
@@ -183,20 +175,32 @@
  *    Filter constant (or disabled)   .1 seconds
  */
 
-/* These are the zone temperature range encodings */
-static int lm85_range_map[] = {   /* .1 degC */
-		 20,  25,  33,  40,  50,  66,
-		 80, 100, 133, 160, 200, 266,
-		320, 400, 533, 800
+/* These are the zone temperature range encodings in .001 degree C */
+static int lm85_range_map[] = {   
+		2000,  2500,  3300,  4000,  5000,  6600,
+		8000, 10000, 13300, 16000, 20000, 26600,
+		32000, 40000, 53300, 80000
 	};
 static int RANGE_TO_REG( int range )
 {
 	int i;
 
-	if( range >= lm85_range_map[15] ) { return 15 ; }
-	for( i = 0 ; i < 15 ; ++i )
-		if( range <= lm85_range_map[i] )
-			break ;
+	if ( range < lm85_range_map[0] ) { 
+		return 0 ;
+	} else if ( range > lm85_range_map[15] ) {
+		return 15 ;
+	} else {  /* find closest match */
+		for ( i = 14 ; i >= 0 ; --i ) {
+			if ( range > lm85_range_map[i] ) { /* range bracketed */
+				if ((lm85_range_map[i+1] - range) < 
+					(range - lm85_range_map[i])) {
+					i++;
+					break;
+				}
+				break;
+			}
+		}
+	}
 	return( i & 0x0f );
 }
 #define RANGE_FROM_REG(val) (lm85_range_map[(val)&0x0f])
@@ -206,41 +210,9 @@
  *       MSB (bit 3, value 8).  If the enable bit is 0, the encoded value
  *       is ignored, or set to 0.
  */
-static int lm85_smooth_map[] = {  /* .1 sec */
-		350, 176, 118,  70,  44,   30,   16,    8
-/*    35.4 *    1/1, 1/2, 1/3, 1/5, 1/8, 1/12, 1/24, 1/48  */
-	};
-static int SMOOTH_TO_REG( int smooth )
-{
-	int i;
-
-	if( smooth <= 0 ) { return 0 ; }  /* Disabled */
-	for( i = 0 ; i < 7 ; ++i )
-		if( smooth >= lm85_smooth_map[i] )
-			break ;
-	return( (i & 0x07) | 0x08 );
-}
-#define SMOOTH_FROM_REG(val) ((val)&0x08?lm85_smooth_map[(val)&0x07]:0)
-
-/* These are the fan spinup delay time encodings */
-static int lm85_spinup_map[] = {  /* .1 sec */
-		0, 1, 2, 4, 7, 10, 20, 40
-	};
-static int SPINUP_TO_REG( int spinup )
-{
-	int i;
-
-	if( spinup >= lm85_spinup_map[7] ) { return 7 ; }
-	for( i = 0 ; i < 7 ; ++i )
-		if( spinup <= lm85_spinup_map[i] )
-			break ;
-	return( i & 0x07 );
-}
-#define SPINUP_FROM_REG(val) (lm85_spinup_map[(val)&0x07])
-
 /* These are the PWM frequency encodings */
 static int lm85_freq_map[] = { /* .1 Hz */
-		100, 150, 230, 300, 380, 470, 620, 980
+		100, 150, 230, 300, 380, 470, 620, 940
 	};
 static int FREQ_TO_REG( int freq )
 {
@@ -266,13 +238,9 @@
  *     -2 -- PWM responds to manual control
  */
 
-#endif		/* Extended functionality */
-
 static int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 };
 #define ZONE_FROM_REG(val) (lm85_zone_map[((val)>>5)&0x07])
 
-#ifdef	LM85EXTENDEDFUNC	/* Extended functionality */
-
 static int ZONE_TO_REG( int zone )
 {
 	int i;
@@ -285,10 +253,8 @@
 	return( (i & 0x07)<<5 );
 }
 
-#endif		/* Extended functionality */
-
-#define HYST_TO_REG(val) (SENSORS_LIMIT((-(val)+5)/10,0,15))
-#define HYST_FROM_REG(val) (-(val)*10)
+#define HYST_TO_REG(val) (SENSORS_LIMIT(((val)+500)/1000,0,15))
+#define HYST_FROM_REG(val) ((val)*1000)
 
 #define OFFSET_TO_REG(val) (SENSORS_LIMIT((val)/25,-127,127))
 #define OFFSET_FROM_REG(val) ((val)*25)
@@ -338,6 +304,14 @@
 	u8 hyst;	/* Low limit hysteresis. (0-15) */
 	u8 range;	/* Temp range, encoded */
 	s8 critical;	/* "All fans ON" temp limit */
+	u8 off_desired; /* Actual "off" temperature specified.  Preserved 
+			 * to prevent "drift" as other autofan control
+			 * values change.
+			 */
+	u8 max_desired; /* Actual "max" temperature specified.  Preserved 
+			 * to prevent "drift" as other autofan control
+			 * values change.
+			 */
 };
 
 struct lm85_autofan {
@@ -405,7 +379,7 @@
 };
 
 /* Unique ID assigned to each LM85 detected */
-static int lm85_id = 0;
+static int lm85_id;
 
 
 /* 4 Fans */
@@ -437,18 +411,19 @@
 #define show_fan_offset(offset)						\
 static ssize_t show_fan_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_fan(dev, buf, 0x##offset - 1);			\
+	return show_fan(dev, buf, offset - 1);				\
 }									\
 static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)	\
 {									\
-	return show_fan_min(dev, buf, 0x##offset - 1);			\
+	return show_fan_min(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_fan_##offset##_min (struct device *dev, 		\
 	const char *buf, size_t count) 					\
 {									\
-	return set_fan_min(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_min(dev, buf, count, offset - 1);		\
 }									\
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset,	\
+		NULL);							\
 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, 		\
 		show_fan_##offset##_min, set_fan_##offset##_min);
 
@@ -527,20 +502,21 @@
 #define show_pwm_reg(offset)						\
 static ssize_t show_pwm_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_pwm(dev, buf, 0x##offset - 1);			\
+	return show_pwm(dev, buf, offset - 1);				\
 }									\
 static ssize_t set_pwm_##offset (struct device *dev,			\
 				 const char *buf, size_t count)		\
 {									\
-	return set_pwm(dev, buf, count, 0x##offset - 1);		\
+	return set_pwm(dev, buf, count, offset - 1);			\
 }									\
 static ssize_t show_pwm_enable##offset (struct device *dev, char *buf)	\
 {									\
-	return show_pwm_enable(dev, buf, 0x##offset - 1);			\
+	return show_pwm_enable(dev, buf, offset - 1);			\
 }									\
-static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, 			\
+static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, 			\
 		show_pwm_##offset, set_pwm_##offset);			\
-static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO, show_pwm_enable##offset, NULL);
+static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO, 			\
+		show_pwm_enable##offset, NULL);
 
 show_pwm_reg(1);
 show_pwm_reg(2);
@@ -594,27 +570,28 @@
 #define show_in_reg(offset)						\
 static ssize_t show_in_##offset (struct device *dev, char *buf)		\
 {									\
-	return show_in(dev, buf, 0x##offset);				\
+	return show_in(dev, buf, offset);				\
 }									\
 static ssize_t show_in_##offset##_min (struct device *dev, char *buf)	\
 {									\
-	return show_in_min(dev, buf, 0x##offset);			\
+	return show_in_min(dev, buf, offset);				\
 }									\
 static ssize_t show_in_##offset##_max (struct device *dev, char *buf)	\
 {									\
-	return show_in_max(dev, buf, 0x##offset);			\
+	return show_in_max(dev, buf, offset);				\
 }									\
 static ssize_t set_in_##offset##_min (struct device *dev, 		\
 	const char *buf, size_t count) 					\
 {									\
-	return set_in_min(dev, buf, count, 0x##offset);			\
+	return set_in_min(dev, buf, count, offset);			\
 }									\
 static ssize_t set_in_##offset##_max (struct device *dev, 		\
 	const char *buf, size_t count) 					\
 {									\
-	return set_in_max(dev, buf, count, 0x##offset);			\
+	return set_in_max(dev, buf, count, offset);			\
 }									\
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in_##offset, NULL);	\
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in_##offset, 	\
+		NULL);							\
 static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, 		\
 		show_in_##offset##_min, set_in_##offset##_min);		\
 static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, 		\
@@ -674,27 +651,28 @@
 #define show_temp_reg(offset)						\
 static ssize_t show_temp_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_temp(dev, buf, 0x##offset - 1);			\
+	return show_temp(dev, buf, offset - 1);				\
 }									\
 static ssize_t show_temp_##offset##_min (struct device *dev, char *buf)	\
 {									\
-	return show_temp_min(dev, buf, 0x##offset - 1);			\
+	return show_temp_min(dev, buf, offset - 1);			\
 }									\
 static ssize_t show_temp_##offset##_max (struct device *dev, char *buf)	\
 {									\
-	return show_temp_max(dev, buf, 0x##offset - 1);			\
+	return show_temp_max(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_temp_##offset##_min (struct device *dev, 		\
 	const char *buf, size_t count) 					\
 {									\
-	return set_temp_min(dev, buf, count, 0x##offset - 1);		\
+	return set_temp_min(dev, buf, count, offset - 1);		\
 }									\
 static ssize_t set_temp_##offset##_max (struct device *dev, 		\
 	const char *buf, size_t count) 					\
 {									\
-	return set_temp_max(dev, buf, count, 0x##offset - 1);		\
+	return set_temp_max(dev, buf, count, offset - 1);		\
 }									\
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);	\
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset,	\
+		NULL);							\
 static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, 		\
 		show_temp_##offset##_min, set_temp_##offset##_min);	\
 static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, 		\
@@ -705,8 +683,334 @@
 show_temp_reg(3);
 
 
+/* Automatic PWM control */
+
+static ssize_t show_pwm_auto_channels(struct device *dev, char *buf, int nr)
+{
+	struct lm85_data *data = lm85_update_device(dev);
+	return sprintf(buf,"%d\n", ZONE_FROM_REG(data->autofan[nr].config));
+}
+static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf,
+	size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm85_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
+		| ZONE_TO_REG(val) ;
+	lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
+		data->autofan[nr].config);
+	up(&data->update_lock);
+	return count;
+}
+static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr)
+{
+	struct lm85_data *data = lm85_update_device(dev);
+	return sprintf(buf,"%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm));
+}
+static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf,
+	size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm85_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->autofan[nr].min_pwm = PWM_TO_REG(val);
+	lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr),
+		data->autofan[nr].min_pwm);
+	up(&data->update_lock);
+	return count;
+}
+static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr)
+{
+	struct lm85_data *data = lm85_update_device(dev);
+	return sprintf(buf,"%d\n", data->autofan[nr].min_off);
+}
+static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
+	size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm85_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->autofan[nr].min_off = val;
+	lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0]
+		| data->syncpwm3
+		| (data->autofan[0].min_off ? 0x20 : 0)
+		| (data->autofan[1].min_off ? 0x40 : 0)
+		| (data->autofan[2].min_off ? 0x80 : 0)
+	);
+	up(&data->update_lock);
+	return count;
+}
+static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr)
+{
+	struct lm85_data *data = lm85_update_device(dev);
+	return sprintf(buf,"%d\n", FREQ_FROM_REG(data->autofan[nr].freq));
+}
+static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm85_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->autofan[nr].freq = FREQ_TO_REG(val);
+	lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
+		(data->zone[nr].range << 4)
+		| data->autofan[nr].freq
+	); 
+	up(&data->update_lock);
+	return count;
+}
+#define pwm_auto(offset)						\
+static ssize_t show_pwm##offset##_auto_channels (struct device *dev,	\
+	char *buf)							\
+{									\
+	return show_pwm_auto_channels(dev, buf, offset - 1);		\
+}									\
+static ssize_t set_pwm##offset##_auto_channels (struct device *dev,	\
+	const char *buf, size_t count)					\
+{									\
+	return set_pwm_auto_channels(dev, buf, count, offset - 1);	\
+}									\
+static ssize_t show_pwm##offset##_auto_pwm_min (struct device *dev,	\
+	char *buf)							\
+{									\
+	return show_pwm_auto_pwm_min(dev, buf, offset - 1);		\
+}									\
+static ssize_t set_pwm##offset##_auto_pwm_min (struct device *dev,	\
+	const char *buf, size_t count)					\
+{									\
+	return set_pwm_auto_pwm_min(dev, buf, count, offset - 1);	\
+}									\
+static ssize_t show_pwm##offset##_auto_pwm_minctl (struct device *dev,	\
+	char *buf)							\
+{									\
+	return show_pwm_auto_pwm_minctl(dev, buf, offset - 1);		\
+}									\
+static ssize_t set_pwm##offset##_auto_pwm_minctl (struct device *dev,	\
+	const char *buf, size_t count)					\
+{									\
+	return set_pwm_auto_pwm_minctl(dev, buf, count, offset - 1);	\
+}									\
+static ssize_t show_pwm##offset##_auto_pwm_freq (struct device *dev,	\
+	char *buf)							\
+{									\
+	return show_pwm_auto_pwm_freq(dev, buf, offset - 1);		\
+}									\
+static ssize_t set_pwm##offset##_auto_pwm_freq(struct device *dev,	\
+	const char *buf, size_t count)					\
+{									\
+	return set_pwm_auto_pwm_freq(dev, buf, count, offset - 1);	\
+}									\
+static DEVICE_ATTR(pwm##offset##_auto_channels, S_IRUGO | S_IWUSR,	\
+		show_pwm##offset##_auto_channels,			\
+		set_pwm##offset##_auto_channels);			\
+static DEVICE_ATTR(pwm##offset##_auto_pwm_min, S_IRUGO | S_IWUSR,	\
+		show_pwm##offset##_auto_pwm_min,			\
+		set_pwm##offset##_auto_pwm_min);			\
+static DEVICE_ATTR(pwm##offset##_auto_pwm_minctl, S_IRUGO | S_IWUSR,	\
+		show_pwm##offset##_auto_pwm_minctl,			\
+		set_pwm##offset##_auto_pwm_minctl);			\
+static DEVICE_ATTR(pwm##offset##_auto_pwm_freq, S_IRUGO | S_IWUSR,	\
+		show_pwm##offset##_auto_pwm_freq,			\
+		set_pwm##offset##_auto_pwm_freq);              
+pwm_auto(1);
+pwm_auto(2);
+pwm_auto(3);
+
+/* Temperature settings for automatic PWM control */
+
+static ssize_t show_temp_auto_temp_off(struct device *dev, char *buf, int nr)
+{
+	struct lm85_data *data = lm85_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) -
+		HYST_FROM_REG(data->zone[nr].hyst));
+}
+static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
+	size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm85_data *data = i2c_get_clientdata(client);
+	int    min, val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	min = TEMP_FROM_REG(data->zone[nr].limit);
+	data->zone[nr].off_desired = TEMP_TO_REG(val);
+	data->zone[nr].hyst = HYST_TO_REG(min - val);
+	if ( nr == 0 || nr == 1 ) {
+		lm85_write_value(client, LM85_REG_AFAN_HYST1,
+			(data->zone[0].hyst << 4)
+			| data->zone[1].hyst
+			);
+	} else {
+		lm85_write_value(client, LM85_REG_AFAN_HYST2,
+			(data->zone[2].hyst << 4)
+		);
+	}
+	up(&data->update_lock);
+	return count;
+}
+static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr)
+{
+	struct lm85_data *data = lm85_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) );
+}
+static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
+	size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm85_data *data = i2c_get_clientdata(client);
+	int    val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->zone[nr].limit = TEMP_TO_REG(val);
+	lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr),
+		data->zone[nr].limit);
+
+/* Update temp_auto_max and temp_auto_range */
+	data->zone[nr].range = RANGE_TO_REG(
+		TEMP_FROM_REG(data->zone[nr].max_desired) -
+		TEMP_FROM_REG(data->zone[nr].limit));
+	lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
+		((data->zone[nr].range & 0x0f) << 4)
+		| (data->autofan[nr].freq & 0x07));
+
+/* Update temp_auto_hyst and temp_auto_off */
+	data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG(
+		data->zone[nr].limit) - TEMP_FROM_REG(
+		data->zone[nr].off_desired));
+	if ( nr == 0 || nr == 1 ) {
+		lm85_write_value(client, LM85_REG_AFAN_HYST1,
+			(data->zone[0].hyst << 4)
+			| data->zone[1].hyst
+			);
+	} else {
+		lm85_write_value(client, LM85_REG_AFAN_HYST2,
+			(data->zone[2].hyst << 4)
+		);
+	}
+	up(&data->update_lock);
+	return count;
+}
+static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr)
+{
+	struct lm85_data *data = lm85_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) +
+		RANGE_FROM_REG(data->zone[nr].range));
+}
+static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
+	size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm85_data *data = i2c_get_clientdata(client);
+	int    min, val;
+
+	down(&data->update_lock);
+	min = TEMP_FROM_REG(data->zone[nr].limit);
+	val = simple_strtol(buf, NULL, 10);
+	data->zone[nr].max_desired = TEMP_TO_REG(val);
+	data->zone[nr].range = RANGE_TO_REG(
+		val - min);
+	lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
+		((data->zone[nr].range & 0x0f) << 4)
+		| (data->autofan[nr].freq & 0x07));
+	up(&data->update_lock);
+	return count;
+}
+static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr)
+{
+	struct lm85_data *data = lm85_update_device(dev);
+	return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].critical));
+}
+static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm85_data *data = i2c_get_clientdata(client);
+	int     val;
+
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
+	data->zone[nr].critical = TEMP_TO_REG(val);
+	lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr),
+		data->zone[nr].critical);
+	up(&data->update_lock);
+	return count;
+}
+#define temp_auto(offset)						\
+static ssize_t show_temp##offset##_auto_temp_off (struct device *dev,	\
+	char *buf)							\
+{									\
+	return show_temp_auto_temp_off(dev, buf, offset - 1);		\
+}									\
+static ssize_t set_temp##offset##_auto_temp_off (struct device *dev,	\
+	const char *buf, size_t count)					\
+{									\
+	return set_temp_auto_temp_off(dev, buf, count, offset - 1);	\
+}									\
+static ssize_t show_temp##offset##_auto_temp_min (struct device *dev,	\
+	char *buf)							\
+{									\
+	return show_temp_auto_temp_min(dev, buf, offset - 1);		\
+}									\
+static ssize_t set_temp##offset##_auto_temp_min (struct device *dev,	\
+	const char *buf, size_t count)					\
+{									\
+	return set_temp_auto_temp_min(dev, buf, count, offset - 1);	\
+}									\
+static ssize_t show_temp##offset##_auto_temp_max (struct device *dev,	\
+	char *buf)							\
+{									\
+	return show_temp_auto_temp_max(dev, buf, offset - 1);		\
+}									\
+static ssize_t set_temp##offset##_auto_temp_max (struct device *dev,	\
+	const char *buf, size_t count)					\
+{									\
+	return set_temp_auto_temp_max(dev, buf, count, offset - 1);	\
+}									\
+static ssize_t show_temp##offset##_auto_temp_crit (struct device *dev,	\
+	char *buf)							\
+{									\
+	return show_temp_auto_temp_crit(dev, buf, offset - 1);		\
+}									\
+static ssize_t set_temp##offset##_auto_temp_crit (struct device *dev,	\
+	const char *buf, size_t count)					\
+{									\
+	return set_temp_auto_temp_crit(dev, buf, count, offset - 1);	\
+}									\
+static DEVICE_ATTR(temp##offset##_auto_temp_off, S_IRUGO | S_IWUSR,	\
+		show_temp##offset##_auto_temp_off,			\
+		set_temp##offset##_auto_temp_off);			\
+static DEVICE_ATTR(temp##offset##_auto_temp_min, S_IRUGO | S_IWUSR,	\
+		show_temp##offset##_auto_temp_min,			\
+		set_temp##offset##_auto_temp_min);			\
+static DEVICE_ATTR(temp##offset##_auto_temp_max, S_IRUGO | S_IWUSR,	\
+		show_temp##offset##_auto_temp_max,			\
+		set_temp##offset##_auto_temp_max);			\
+static DEVICE_ATTR(temp##offset##_auto_temp_crit, S_IRUGO | S_IWUSR,	\
+		show_temp##offset##_auto_temp_crit,			\
+		set_temp##offset##_auto_temp_crit);
+temp_auto(1);
+temp_auto(2);
+temp_auto(3);
+
 int lm85_attach_adapter(struct i2c_adapter *adapter)
 {
+	if (!(adapter->class & I2C_CLASS_HWMON))
+		return 0;
 	return i2c_detect(adapter, &addr_data, lm85_detect);
 }
 
@@ -843,12 +1147,12 @@
 	device_create_file(&new_client->dev, &dev_attr_fan2_min);
 	device_create_file(&new_client->dev, &dev_attr_fan3_min);
 	device_create_file(&new_client->dev, &dev_attr_fan4_min);
-	device_create_file(&new_client->dev, &dev_attr_fan1_pwm);
-	device_create_file(&new_client->dev, &dev_attr_fan2_pwm);
-	device_create_file(&new_client->dev, &dev_attr_fan3_pwm);
-	device_create_file(&new_client->dev, &dev_attr_fan1_pwm_enable);
-	device_create_file(&new_client->dev, &dev_attr_fan2_pwm_enable);
-	device_create_file(&new_client->dev, &dev_attr_fan3_pwm_enable);
+	device_create_file(&new_client->dev, &dev_attr_pwm1);
+	device_create_file(&new_client->dev, &dev_attr_pwm2);
+	device_create_file(&new_client->dev, &dev_attr_pwm3);
+	device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
+	device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
+	device_create_file(&new_client->dev, &dev_attr_pwm3_enable);
 	device_create_file(&new_client->dev, &dev_attr_in0_input);
 	device_create_file(&new_client->dev, &dev_attr_in1_input);
 	device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -876,6 +1180,30 @@
 	device_create_file(&new_client->dev, &dev_attr_vrm);
 	device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
 	device_create_file(&new_client->dev, &dev_attr_alarms);
+	device_create_file(&new_client->dev, &dev_attr_pwm1_auto_channels);
+	device_create_file(&new_client->dev, &dev_attr_pwm2_auto_channels);
+	device_create_file(&new_client->dev, &dev_attr_pwm3_auto_channels);
+	device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_min);
+	device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_min);
+	device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_min);
+	device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_minctl);
+	device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_minctl);
+	device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_minctl);
+	device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_freq);
+	device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_freq);
+	device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_freq);
+	device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_off);
+	device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_off);
+	device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_off);
+	device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_min);
+	device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_min);
+	device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_min);
+	device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_max);
+	device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_max);
+	device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_max);
+	device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_crit);
+	device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_crit);
+	device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_crit);
 
 	return 0;
 
@@ -1159,7 +1487,7 @@
  *     post 2.7.0 CVS changes.
  */
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, Margit Schubert-While <margitsw@t-online.de>");
+MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, Margit Schubert-While <margitsw@t-online.de>, Justin Thiessen <jthiessen@penguincomputing.com");
 MODULE_DESCRIPTION("LM85-B, LM85-C driver");
 
 module_init(sm_lm85_init);
diff -Nru a/drivers/i2c/chips/lm87.c b/drivers/i2c/chips/lm87.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/i2c/chips/lm87.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,812 @@
+/*
+ * lm87.c
+ *
+ * Copyright (C) 2000       Frodo Looijaard <frodol@dds.nl>
+ *                          Philip Edelbrock <phil@netroedge.com>
+ *                          Stephen Rousset <stephen.rousset@rocketlogix.com>
+ *                          Dan Eaton <dan.eaton@rocketlogix.com>
+ * Copyright (C) 2004       Jean Delvare <khali@linux-fr.org>
+ *
+ * Original port to Linux 2.6 by Jeff Oliver.
+ *
+ * The LM87 is a sensor chip made by National Semiconductor. It monitors up
+ * to 8 voltages (including its own power source), up to three temperatures
+ * (its own plus up to two external ones) and up to two fans. The default
+ * configuration is 6 voltages, two temperatures and two fans (see below).
+ * Voltages are scaled internally with ratios such that the nominal value of
+ * each voltage correspond to a register value of 192 (which means a
+ * resolution of about 0.5% of the nominal value). Temperature values are
+ * reported with a 1 deg resolution and a 3-4 deg accuracy. Complete
+ * datasheet can be obtained from National's website at:
+ *   http://www.national.com/pf/LM/LM87.html
+ *
+ * Some functions share pins, so not all functions are available at the same
+ * time. Which are depends on the hardware setup. This driver assumes that
+ * the BIOS configured the chip correctly. In that respect, it  differs from
+ * the original driver (from lm_sensors for Linux 2.4), which would force the
+ * LM87 to an arbitrary, compile-time chosen mode, regardless of the actual
+ * chipset wiring.
+ * For reference, here is the list of exclusive functions:
+ *  - in0+in5 (default) or temp3
+ *  - fan1 (default) or in6
+ *  - fan2 (default) or in7
+ *  - VID lines (default) or IRQ lines (not handled by this driver)
+ *
+ * The LM87 additionally features an analog output, supposedly usable to
+ * control the speed of a fan. All new chips use pulse width modulation
+ * instead. The LM87 is the only hardware monitoring chipset I know of
+ * which uses amplitude modulation. Be careful when using this feature.
+ *
+ * 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.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+#include <linux/i2c-vid.h>
+
+/*
+ * Addresses to scan
+ * LM87 has three possible addresses: 0x2c, 0x2d and 0x2e.
+ */
+
+static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+
+/*
+ * Insmod parameters
+ */
+
+SENSORS_INSMOD_1(lm87);
+
+/*
+ * The LM87 registers
+ */
+
+/* nr in 0..5 */
+#define LM87_REG_IN(nr)			(0x20 + (nr))
+#define LM87_REG_IN_MAX(nr)		(0x2B + (nr) * 2)
+#define LM87_REG_IN_MIN(nr)		(0x2C + (nr) * 2)
+/* nr in 0..1 */
+#define LM87_REG_AIN(nr)		(0x28 + (nr))
+#define LM87_REG_AIN_MIN(nr)		(0x1A + (nr))
+#define LM87_REG_AIN_MAX(nr)		(0x3B + (nr))
+
+static u8 LM87_REG_TEMP[3] = { 0x27, 0x26, 0x20 };
+static u8 LM87_REG_TEMP_HIGH[3] = { 0x39, 0x37, 0x2B };
+static u8 LM87_REG_TEMP_LOW[3] = { 0x3A, 0x38, 0x2C };
+
+#define LM87_REG_TEMP_HW_INT_LOCK	0x13
+#define LM87_REG_TEMP_HW_EXT_LOCK	0x14
+#define LM87_REG_TEMP_HW_INT		0x17
+#define LM87_REG_TEMP_HW_EXT		0x18
+
+/* nr in 0..1 */
+#define LM87_REG_FAN(nr)		(0x28 + (nr))
+#define LM87_REG_FAN_MIN(nr)		(0x3B + (nr))
+#define LM87_REG_AOUT			0x19
+
+#define LM87_REG_CONFIG			0x40
+#define LM87_REG_CHANNEL_MODE		0x16
+#define LM87_REG_VID_FAN_DIV		0x47
+#define LM87_REG_VID4			0x49
+
+#define LM87_REG_ALARMS1		0x41
+#define LM87_REG_ALARMS2		0x42
+
+#define LM87_REG_COMPANY_ID		0x3E
+#define LM87_REG_REVISION		0x3F
+
+/*
+ * Conversions and various macros
+ * The LM87 uses signed 8-bit values for temperatures.
+ */
+
+#define IN_FROM_REG(reg,scale)	(((reg) * (scale) + 96) / 192)
+#define IN_TO_REG(val,scale)	((val) <= 0 ? 0 : \
+				 (val) * 192 >= (scale) * 255 ? 255 : \
+				 ((val) * 192 + (scale)/2) / (scale))
+
+#define TEMP_FROM_REG(reg)	((reg) * 1000)
+#define TEMP_TO_REG(val)	((val) <= -127500 ? -128 : \
+				 (val) >= 126500 ? 127 : \
+				 (((val) < 0 ? (val)-500 : (val)+500) / 1000))
+
+#define FAN_FROM_REG(reg,div)	((reg) == 255 || (reg) == 0 ? 0 : \
+				 1350000 + (reg)*(div) / 2) / ((reg)*(div))
+#define FAN_TO_REG(val,div)	((val)*(div) * 255 <= 1350000 ? 255 : \
+				 (1350000 + (val)*(div) / 2) / ((val)*(div)))
+
+#define FAN_DIV_FROM_REG(reg)	(1 << (reg))
+
+/* analog out is 9.80mV/LSB */
+#define AOUT_FROM_REG(reg)	(((reg) * 98 + 5) / 10)
+#define AOUT_TO_REG(val)	((val) <= 0 ? 0 : \
+				 (val) >= 2500 ? 255 : \
+				 ((val) * 10 + 49) / 98)
+
+/* nr in 0..1 */
+#define CHAN_NO_FAN(nr)		(1 << (nr))
+#define CHAN_TEMP3		(1 << 2)
+#define CHAN_VCC_5V		(1 << 3)
+#define CHAN_NO_VID		(1 << 8)
+
+/*
+ * Functions declaration
+ */
+
+static int lm87_attach_adapter(struct i2c_adapter *adapter);
+static int lm87_detect(struct i2c_adapter *adapter, int address, int kind);
+static void lm87_init_client(struct i2c_client *client);
+static int lm87_detach_client(struct i2c_client *client);
+static struct lm87_data *lm87_update_device(struct device *dev);
+
+/*
+ * Driver data (common to all clients)
+ */
+
+static struct i2c_driver lm87_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "lm87",
+	.id		= I2C_DRIVERID_LM87,
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= lm87_attach_adapter,
+	.detach_client	= lm87_detach_client,
+};
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct lm87_data {
+	struct i2c_client client;
+	struct semaphore update_lock;
+	char valid; /* zero until following fields are valid */
+	unsigned long last_updated; /* In jiffies */
+
+	u8 channel;		/* register value */
+
+	u8 in[8];		/* register value */
+	u8 in_max[8];		/* register value */
+	u8 in_min[8];		/* register value */
+	u16 in_scale[8];
+
+	s8 temp[3];		/* register value */
+	s8 temp_high[3];	/* register value */
+	s8 temp_low[3];		/* register value */
+	s8 temp_crit_int;	/* min of two register values */
+	s8 temp_crit_ext;	/* min of two register values */
+
+	u8 fan[2];		/* register value */
+	u8 fan_min[2];		/* register value */
+	u8 fan_div[2];		/* register value, shifted right */
+	u8 aout;		/* register value */
+
+	u16 alarms;		/* register values, combined */
+	u8 vid;			/* register values, combined */
+	u8 vrm;
+};
+
+/*
+ * Internal variables
+ */
+
+static int lm87_id;
+
+/*
+ * Sysfs stuff
+ */
+
+static inline int lm87_read_value(struct i2c_client *client, u8 reg)
+{
+	return i2c_smbus_read_byte_data(client, reg);
+}
+
+static inline int lm87_write_value(struct i2c_client *client, u8 reg, u8 value)
+{
+	return i2c_smbus_write_byte_data(client, reg, value);
+}
+
+#define show_in(offset) \
+static ssize_t show_in##offset##_input(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \
+		       data->in_scale[offset])); \
+} \
+static ssize_t show_in##offset##_min(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \
+		       data->in_scale[offset])); \
+} \
+static ssize_t show_in##offset##_max(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \
+		       data->in_scale[offset])); \
+} \
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
+		show_in##offset##_input, NULL);
+show_in(0);
+show_in(1);
+show_in(2);
+show_in(3);
+show_in(4);
+show_in(5);
+show_in(6);
+show_in(7);
+
+static void set_in_min(struct device *dev, const char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm87_data *data = i2c_get_clientdata(client);
+	long val = simple_strtol(buf, NULL, 10);
+	data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]);
+	lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) :
+			 LM87_REG_AIN_MIN(nr-6), data->in_min[nr]);
+}
+
+static void set_in_max(struct device *dev, const char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm87_data *data = i2c_get_clientdata(client);
+	long val = simple_strtol(buf, NULL, 10);
+	data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]);
+	lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) :
+			 LM87_REG_AIN_MAX(nr-6), data->in_max[nr]);
+}
+
+#define set_in(offset) \
+static ssize_t set_in##offset##_min(struct device *dev, \
+		const char *buf, size_t count) \
+{ \
+	set_in_min(dev, buf, offset); \
+	return count; \
+} \
+static ssize_t set_in##offset##_max(struct device *dev, \
+		const char *buf, size_t count) \
+{ \
+	set_in_max(dev, buf, offset); \
+	return count; \
+} \
+static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
+		show_in##offset##_min, set_in##offset##_min); \
+static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
+		show_in##offset##_max, set_in##offset##_max);
+set_in(0);
+set_in(1);
+set_in(2);
+set_in(3);
+set_in(4);
+set_in(5);
+set_in(6);
+set_in(7);
+
+#define show_temp(offset) \
+static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \
+} \
+static ssize_t show_temp##offset##_low(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[offset-1])); \
+} \
+static ssize_t show_temp##offset##_high(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[offset-1])); \
+}\
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
+		show_temp##offset##_input, NULL);
+show_temp(1);
+show_temp(2);
+show_temp(3);
+
+static void set_temp_low(struct device *dev, const char *buf, int nr)
+{
+    struct i2c_client *client = to_i2c_client(dev);
+    struct lm87_data *data = i2c_get_clientdata(client);
+    long val = simple_strtol(buf, NULL, 10);
+    data->temp_low[nr] = TEMP_TO_REG(val);
+    lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]);
+}
+
+static void set_temp_high(struct device *dev, const char *buf, int nr)
+{
+    struct i2c_client *client = to_i2c_client(dev);
+    struct lm87_data *data = i2c_get_clientdata(client);
+    long val = simple_strtol(buf, NULL, 10);
+    data->temp_high[nr] = TEMP_TO_REG(val);
+    lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]);
+}
+
+#define set_temp(offset) \
+static ssize_t set_temp##offset##_low(struct device *dev, \
+		const char *buf, size_t count) \
+{ \
+	set_temp_low(dev, buf, offset-1); \
+	return count; \
+} \
+static ssize_t set_temp##offset##_high(struct device *dev, \
+		const char *buf, size_t count) \
+{ \
+	set_temp_high(dev, buf, offset-1); \
+	return count; \
+} \
+static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
+		show_temp##offset##_high, set_temp##offset##_high); \
+static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
+		show_temp##offset##_low, set_temp##offset##_low);
+set_temp(1);
+set_temp(2);
+set_temp(3);
+
+static ssize_t show_temp_crit_int(struct device *dev, char *buf)
+{
+	struct lm87_data *data = lm87_update_device(dev);
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_int));
+}
+
+static ssize_t show_temp_crit_ext(struct device *dev, char *buf)
+{
+	struct lm87_data *data = lm87_update_device(dev);
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_ext));
+}
+
+static DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit_int, NULL);
+static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit_ext, NULL);
+static DEVICE_ATTR(temp3_crit, S_IRUGO, show_temp_crit_ext, NULL);
+
+#define show_fan(offset) \
+static ssize_t show_fan##offset##_input(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[offset-1], \
+		       FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \
+} \
+static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[offset-1], \
+		       FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \
+} \
+static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \
+{ \
+	struct lm87_data *data = lm87_update_device(dev); \
+	return sprintf(buf, "%d\n", FAN_DIV_FROM_REG(data->fan_div[offset-1])); \
+} \
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
+		show_fan##offset##_input, NULL);
+show_fan(1);
+show_fan(2);
+
+static void set_fan_min(struct device *dev, const char *buf, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm87_data *data = i2c_get_clientdata(client);
+	long val = simple_strtol(buf, NULL, 10);
+	data->fan_min[nr] = FAN_TO_REG(val,
+			    FAN_DIV_FROM_REG(data->fan_div[nr]));
+	lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]);
+}
+
+/* Note: we save and restore the fan minimum here, because its value is
+   determined in part by the fan clock divider.  This follows the principle
+   of least suprise; the user doesn't expect the fan minimum to change just
+   because the divider changed. */
+static ssize_t set_fan_div(struct device *dev, const char *buf,
+		size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm87_data *data = i2c_get_clientdata(client);
+	long val = simple_strtol(buf, NULL, 10);
+	unsigned long min = FAN_FROM_REG(data->fan_min[nr],
+			    FAN_DIV_FROM_REG(data->fan_div[nr]));
+	u8 reg;
+
+	switch (val) {
+	case 1: data->fan_div[nr] = 0; break;
+	case 2: data->fan_div[nr] = 1; break;
+	case 4: data->fan_div[nr] = 2; break;
+	case 8: data->fan_div[nr] = 3; break;
+	default: return -EINVAL;
+	}
+
+	reg = lm87_read_value(client, LM87_REG_VID_FAN_DIV);
+	switch (nr) {
+	case 0:
+	    reg = (reg & 0xCF) | (data->fan_div[0] << 4);
+	    break;
+	case 1:
+	    reg = (reg & 0x3F) | (data->fan_div[1] << 6);
+	    break;
+	}
+	lm87_write_value(client, LM87_REG_VID_FAN_DIV, reg);
+
+	data->fan_min[nr] = FAN_TO_REG(min, val);
+	lm87_write_value(client, LM87_REG_FAN_MIN(nr),
+			 data->fan_min[nr]);
+	return count;
+}
+
+#define set_fan(offset) \
+static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \
+		size_t count) \
+{ \
+	set_fan_min(dev, buf, offset-1); \
+	return count; \
+} \
+static ssize_t set_fan##offset##_div(struct device *dev, const char *buf, \
+		size_t count) \
+{ \
+	return set_fan_div(dev, buf, count, offset-1); \
+} \
+static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
+		show_fan##offset##_min, set_fan##offset##_min); \
+static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
+		show_fan##offset##_div, set_fan##offset##_div);
+set_fan(1);
+set_fan(2);
+
+static ssize_t show_alarms(struct device *dev, char *buf)
+{
+	struct lm87_data *data = lm87_update_device(dev);
+	return sprintf(buf, "%d\n", data->alarms);
+}
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
+
+static ssize_t show_vid(struct device *dev, char *buf)
+{
+	struct lm87_data *data = lm87_update_device(dev);
+	return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
+}
+static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
+
+static ssize_t show_vrm(struct device *dev, char *buf)
+{
+	struct lm87_data *data = lm87_update_device(dev);
+	return sprintf(buf, "%d\n", data->vrm);
+}
+static ssize_t set_vrm(struct device *dev, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm87_data *data = i2c_get_clientdata(client);
+	data->vrm = simple_strtoul(buf, NULL, 10);
+	return count;
+}
+static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
+
+static ssize_t show_aout(struct device *dev, char *buf)
+{
+	struct lm87_data *data = lm87_update_device(dev);
+	return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout));
+}
+static ssize_t set_aout(struct device *dev, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm87_data *data = i2c_get_clientdata(client);
+	long val = simple_strtol(buf, NULL, 10);
+	data->aout = AOUT_TO_REG(val);
+	lm87_write_value(client, LM87_REG_AOUT, data->aout);
+	return count;
+}
+static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
+
+/*
+ * Real code
+ */
+
+static int lm87_attach_adapter(struct i2c_adapter *adapter)
+{
+	if (!(adapter->class & I2C_CLASS_HWMON))
+		return 0;
+	return i2c_detect(adapter, &addr_data, lm87_detect);
+}
+
+/*
+ * The following function does more than just detection. If detection
+ * succeeds, it also registers the new chip.
+ */
+static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+	struct i2c_client *new_client;
+	struct lm87_data *data;
+	int err = 0;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		goto exit;
+
+	if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) {
+		err = -ENOMEM;
+		goto exit;
+	}
+	memset(data, 0, sizeof(struct lm87_data));
+
+	/* The common I2C client data is placed right before the
+	   LM87-specific data. */
+	new_client = &data->client;
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	new_client->adapter = adapter;
+	new_client->driver = &lm87_driver;
+	new_client->flags = 0;
+
+	/* Default to an LM87 if forced */
+	if (kind == 0)
+		kind = lm87;
+
+	/* Now, we do the remaining detection. */
+	if (kind < 0) {
+		u8 rev = lm87_read_value(new_client, LM87_REG_REVISION);
+
+		if (rev < 0x01 || rev > 0x08
+		 || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)
+		 || lm87_read_value(new_client, LM87_REG_COMPANY_ID) != 0x02) {
+			dev_dbg(&adapter->dev,
+				"LM87 detection failed at 0x%02x.\n",
+				address);
+			goto exit_free;
+		}
+	}
+
+	/* We can fill in the remaining client fields */
+	strlcpy(new_client->name, "lm87", I2C_NAME_SIZE);
+	new_client->id = lm87_id++;
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	/* Tell the I2C layer a new client has arrived */
+	if ((err = i2c_attach_client(new_client)))
+		goto exit_free;
+
+	/* Initialize the LM87 chip */
+	lm87_init_client(new_client);
+
+	data->in_scale[0] = 2500;
+	data->in_scale[1] = 2700;
+	data->in_scale[2] = (data->channel & CHAN_VCC_5V) ? 5000 : 3300;
+	data->in_scale[3] = 5000;
+	data->in_scale[4] = 12000;
+	data->in_scale[5] = 2700;
+	data->in_scale[6] = 1875;
+	data->in_scale[7] = 1875;
+
+	/* Register sysfs hooks */
+	device_create_file(&new_client->dev, &dev_attr_in1_input);
+	device_create_file(&new_client->dev, &dev_attr_in1_min);
+	device_create_file(&new_client->dev, &dev_attr_in1_max);
+	device_create_file(&new_client->dev, &dev_attr_in2_input);
+	device_create_file(&new_client->dev, &dev_attr_in2_min);
+	device_create_file(&new_client->dev, &dev_attr_in2_max);
+	device_create_file(&new_client->dev, &dev_attr_in3_input);
+	device_create_file(&new_client->dev, &dev_attr_in3_min);
+	device_create_file(&new_client->dev, &dev_attr_in3_max);
+	device_create_file(&new_client->dev, &dev_attr_in4_input);
+	device_create_file(&new_client->dev, &dev_attr_in4_min);
+	device_create_file(&new_client->dev, &dev_attr_in4_max);
+
+	if (data->channel & CHAN_NO_FAN(0)) {
+		device_create_file(&new_client->dev, &dev_attr_in6_input);
+		device_create_file(&new_client->dev, &dev_attr_in6_min);
+		device_create_file(&new_client->dev, &dev_attr_in6_max);
+	} else {
+		device_create_file(&new_client->dev, &dev_attr_fan1_input);
+		device_create_file(&new_client->dev, &dev_attr_fan1_min);
+		device_create_file(&new_client->dev, &dev_attr_fan1_div);
+	}
+	if (data->channel & CHAN_NO_FAN(1)) {
+		device_create_file(&new_client->dev, &dev_attr_in7_input);
+		device_create_file(&new_client->dev, &dev_attr_in7_min);
+		device_create_file(&new_client->dev, &dev_attr_in7_max);
+	} else {
+		device_create_file(&new_client->dev, &dev_attr_fan2_input);
+		device_create_file(&new_client->dev, &dev_attr_fan2_min);
+		device_create_file(&new_client->dev, &dev_attr_fan2_div);
+	}
+
+	device_create_file(&new_client->dev, &dev_attr_temp1_input);
+	device_create_file(&new_client->dev, &dev_attr_temp1_max);
+	device_create_file(&new_client->dev, &dev_attr_temp1_min);
+	device_create_file(&new_client->dev, &dev_attr_temp1_crit);
+	device_create_file(&new_client->dev, &dev_attr_temp2_input);
+	device_create_file(&new_client->dev, &dev_attr_temp2_max);
+	device_create_file(&new_client->dev, &dev_attr_temp2_min);
+	device_create_file(&new_client->dev, &dev_attr_temp2_crit);
+
+	if (data->channel & CHAN_TEMP3) {
+		device_create_file(&new_client->dev, &dev_attr_temp3_input);
+		device_create_file(&new_client->dev, &dev_attr_temp3_max);
+		device_create_file(&new_client->dev, &dev_attr_temp3_min);
+		device_create_file(&new_client->dev, &dev_attr_temp3_crit);
+	} else {
+		device_create_file(&new_client->dev, &dev_attr_in0_input);
+		device_create_file(&new_client->dev, &dev_attr_in0_min);
+		device_create_file(&new_client->dev, &dev_attr_in0_max);
+		device_create_file(&new_client->dev, &dev_attr_in5_input);
+		device_create_file(&new_client->dev, &dev_attr_in5_min);
+		device_create_file(&new_client->dev, &dev_attr_in5_max);
+	}
+
+	if (!(data->channel & CHAN_NO_VID)) {
+		device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
+		device_create_file(&new_client->dev, &dev_attr_vrm);
+	}
+
+	device_create_file(&new_client->dev, &dev_attr_alarms);
+	device_create_file(&new_client->dev, &dev_attr_aout_output);
+
+	return 0;
+
+exit_free:
+	kfree(data);
+exit:
+	return err;
+}
+
+static void lm87_init_client(struct i2c_client *client)
+{
+	struct lm87_data *data = i2c_get_clientdata(client);
+	u8 config;
+
+	data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
+	data->vrm = i2c_which_vrm();
+
+	config = lm87_read_value(client, LM87_REG_CONFIG);
+	if (!(config & 0x01)) {
+		int i;
+
+		/* Limits are left uninitialized after power-up */
+		for (i = 1; i < 6; i++) {
+			lm87_write_value(client, LM87_REG_IN_MIN(i), 0x00);
+			lm87_write_value(client, LM87_REG_IN_MAX(i), 0xFF);
+		}
+		for (i = 0; i < 2; i++) {
+			lm87_write_value(client, LM87_REG_TEMP_HIGH[i], 0x7F);
+			lm87_write_value(client, LM87_REG_TEMP_LOW[i], 0x00);
+			lm87_write_value(client, LM87_REG_AIN_MIN(i), 0x00);
+			lm87_write_value(client, LM87_REG_AIN_MAX(i), 0xFF);
+		}
+		if (data->channel & CHAN_TEMP3) {
+			lm87_write_value(client, LM87_REG_TEMP_HIGH[2], 0x7F);
+			lm87_write_value(client, LM87_REG_TEMP_LOW[2], 0x00);
+		} else {
+			lm87_write_value(client, LM87_REG_IN_MIN(0), 0x00);
+			lm87_write_value(client, LM87_REG_IN_MAX(0), 0xFF);
+		}
+	}
+	if ((config & 0x81) != 0x01) {
+		/* Start monitoring */
+		lm87_write_value(client, LM87_REG_CONFIG,
+				 (config & 0xF7) | 0x01);
+	}
+}
+
+static int lm87_detach_client(struct i2c_client *client)
+{
+	int err;
+
+	if ((err = i2c_detach_client(client))) {
+		dev_err(&client->dev, "Client deregistration failed, "
+			"client not detached.\n");
+		return err;
+	}
+
+	kfree(i2c_get_clientdata(client));
+	return 0;
+}
+
+static struct lm87_data *lm87_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm87_data *data = i2c_get_clientdata(client);
+
+	down(&data->update_lock);
+
+	if (jiffies - data->last_updated > HZ
+	  || jiffies < data->last_updated
+	  || !data->valid) {
+		int i, j;
+
+		dev_dbg(&client->dev, "Updating data.\n");
+
+		i = (data->channel & CHAN_TEMP3) ? 1 : 0;
+		j = (data->channel & CHAN_TEMP3) ? 5 : 6;
+		for (; i < j; i++) {
+			data->in[i] = lm87_read_value(client,
+				      LM87_REG_IN(i));
+			data->in_min[i] = lm87_read_value(client,
+					  LM87_REG_IN_MIN(i));
+			data->in_max[i] = lm87_read_value(client,
+					  LM87_REG_IN_MAX(i));
+		}
+
+		for (i = 0; i < 2; i++) {
+			if (data->channel & CHAN_NO_FAN(i)) {
+				data->in[6+i] = lm87_read_value(client,
+						LM87_REG_AIN(i));
+				data->in_max[6+i] = lm87_read_value(client,
+						    LM87_REG_AIN_MAX(i));
+				data->in_min[6+i] = lm87_read_value(client,
+						    LM87_REG_AIN_MIN(i));
+
+			} else {
+				data->fan[i] = lm87_read_value(client,
+					       LM87_REG_FAN(i));
+				data->fan_min[i] = lm87_read_value(client,
+						   LM87_REG_FAN_MIN(i));
+			}
+		}
+
+		j = (data->channel & CHAN_TEMP3) ? 3 : 2;
+		for (i = 0 ; i < j; i++) {
+			data->temp[i] = lm87_read_value(client,
+					LM87_REG_TEMP[i]);
+			data->temp_high[i] = lm87_read_value(client,
+					     LM87_REG_TEMP_HIGH[i]);
+			data->temp_low[i] = lm87_read_value(client,
+					    LM87_REG_TEMP_LOW[i]);
+		}
+
+		i = lm87_read_value(client, LM87_REG_TEMP_HW_INT_LOCK);
+		j = lm87_read_value(client, LM87_REG_TEMP_HW_INT);
+		data->temp_crit_int = min(i, j);
+
+		i = lm87_read_value(client, LM87_REG_TEMP_HW_EXT_LOCK);
+		j = lm87_read_value(client, LM87_REG_TEMP_HW_EXT);
+		data->temp_crit_ext = min(i, j);
+
+		i = lm87_read_value(client, LM87_REG_VID_FAN_DIV);
+		data->fan_div[0] = (i >> 4) & 0x03;
+		data->fan_div[1] = (i >> 6) & 0x03;
+		data->vid = (i & 0x0F)
+			  | (lm87_read_value(client, LM87_REG_VID4) & 0x01)
+			     << 4;
+
+		data->alarms = lm87_read_value(client, LM87_REG_ALARMS1)
+			     | (lm87_read_value(client, LM87_REG_ALARMS2)
+				<< 8);
+		data->aout = lm87_read_value(client, LM87_REG_AOUT);
+
+		data->last_updated = jiffies;
+		data->valid = 1;
+	}
+
+	up(&data->update_lock);
+
+	return data;
+}
+
+static int __init sensors_lm87_init(void)
+{
+	return i2c_add_driver(&lm87_driver);
+}
+
+static void __exit sensors_lm87_exit(void)
+{
+	i2c_del_driver(&lm87_driver);
+}
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org> and others");
+MODULE_DESCRIPTION("LM87 driver");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_lm87_init);
+module_exit(sensors_lm87_exit);
diff -Nru a/drivers/i2c/chips/lm90.c b/drivers/i2c/chips/lm90.c
--- a/drivers/i2c/chips/lm90.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/i2c/chips/lm90.c	2004-12-24 13:36:17 -08:00
@@ -76,9 +76,7 @@
  */
 
 static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
@@ -127,19 +125,24 @@
 
 /*
  * Conversions and various macros
- * The LM90 uses signed 8-bit values for the local temperatures,
- * and signed 11-bit values for the remote temperatures (except
- * T_CRIT). Note that TEMP2_TO_REG does not round values, but
- * stick to the nearest lower value instead. Fixing it is just
- * not worth it.
- */
-
-#define TEMP1_FROM_REG(val)	((val & 0x80 ? val-0x100 : val) * 1000)
-#define TEMP1_TO_REG(val)	((val < 0 ? val+0x100*1000 : val) / 1000)
-#define TEMP2_FROM_REG(val)	(((val & 0x8000 ? val-0x10000 : val) >> 5) * 125)
-#define TEMP2_TO_REG(val)	((((val / 125) << 5) + (val < 0 ? 0x10000 : 0)) & 0xFFE0)
-#define HYST_FROM_REG(val)	(val * 1000)
-#define HYST_TO_REG(val)	(val <= 0 ? 0 : val >= 31000 ? 31 : val / 1000)
+ * For local temperatures and limits, critical limits and the hysteresis
+ * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celcius.
+ * For remote temperatures and limits, it uses signed 11-bit values with
+ * LSB = 0.125 degree Celcius, left-justified in 16-bit registers.
+ */
+
+#define TEMP1_FROM_REG(val)	((val) * 1000)
+#define TEMP1_TO_REG(val)	((val) <= -128000 ? -128 : \
+				 (val) >= 127000 ? 127 : \
+				 (val) < 0 ? ((val) - 500) / 1000 : \
+				 ((val) + 500) / 1000)
+#define TEMP2_FROM_REG(val)	((val) / 32 * 125)
+#define TEMP2_TO_REG(val)	((val) <= -128000 ? 0x8000 : \
+				 (val) >= 127875 ? 0x7FE0 : \
+				 (val) < 0 ? ((val) - 62) / 125 * 32 : \
+				 ((val) + 62) / 125 * 32)
+#define HYST_TO_REG(val)	((val) <= 0 ? 0 : (val) >= 30500 ? 31 : \
+				 ((val) + 500) / 1000)
 
 /*
  * Functions declaration
@@ -176,18 +179,18 @@
 	unsigned long last_updated; /* in jiffies */
 
 	/* registers values */
-	u8 temp_input1, temp_low1, temp_high1; /* local */
-	u16 temp_input2, temp_low2, temp_high2; /* remote, combined */
-	u8 temp_crit1, temp_crit2;
+	s8 temp_input1, temp_low1, temp_high1; /* local */
+	s16 temp_input2, temp_low2, temp_high2; /* remote, combined */
+	s8 temp_crit1, temp_crit2;
 	u8 temp_hyst;
-	u16 alarms; /* bitvector, combined */
+	u8 alarms; /* bitvector */
 };
 
 /*
  * Internal variables
  */
 
-static int lm90_id = 0;
+static int lm90_id;
 
 /*
  * Sysfs stuff
@@ -214,7 +217,8 @@
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct lm90_data *data = i2c_get_clientdata(client); \
-	data->value = TEMP1_TO_REG(simple_strtol(buf, NULL, 10)); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->value = TEMP1_TO_REG(val); \
 	i2c_smbus_write_byte_data(client, reg, data->value); \
 	return count; \
 }
@@ -224,7 +228,8 @@
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct lm90_data *data = i2c_get_clientdata(client); \
-	data->value = TEMP2_TO_REG(simple_strtol(buf, NULL, 10)); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->value = TEMP2_TO_REG(val); \
 	i2c_smbus_write_byte_data(client, regh, data->value >> 8); \
 	i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \
 	return count; \
@@ -241,7 +246,7 @@
 { \
 	struct lm90_data *data = lm90_update_device(dev); \
 	return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \
-		       - HYST_FROM_REG(data->temp_hyst)); \
+		       - TEMP1_FROM_REG(data->temp_hyst)); \
 }
 show_temp_hyst(temp_hyst1, temp_crit1);
 show_temp_hyst(temp_hyst2, temp_crit2);
diff -Nru a/drivers/i2c/chips/max1619.c b/drivers/i2c/chips/max1619.c
--- a/drivers/i2c/chips/max1619.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/i2c/chips/max1619.c	2004-12-24 13:37:18 -08:00
@@ -34,11 +34,11 @@
 #include <linux/i2c-sensor.h>
 
 
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b,
-						0x4c, 0x4e, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
+					0x29, 0x2a, 0x2b,
+					0x4c, 0x4d, 0x4e,
+					I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
@@ -120,7 +120,7 @@
  * Internal variables
  */
 
-static int max1619_id = 0;
+static int max1619_id;
 
 /*
  * Sysfs stuff
@@ -145,7 +145,8 @@
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct max1619_data *data = i2c_get_clientdata(client); \
-	data->value = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->value = TEMP_TO_REG(val); \
 	i2c_smbus_write_byte_data(client, reg, data->value); \
 	return count; \
 }
diff -Nru a/drivers/i2c/chips/pc87360.c b/drivers/i2c/chips/pc87360.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/i2c/chips/pc87360.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1298 @@
+/*
+ *  pc87360.c - Part of lm_sensors, Linux kernel modules
+ *              for hardware monitoring
+ *  Copyright (C) 2004 Jean Delvare <khali@linux-fr.org>
+ *
+ *  Copied from smsc47m1.c:
+ *  Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.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 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.
+ *
+ *  Supports the following chips:
+ *
+ *  Chip        #vin    #fan    #pwm    #temp   devid
+ *  PC87360     -       2       2       -       0xE1
+ *  PC87363     -       2       2       -       0xE8
+ *  PC87364     -       3       3       -       0xE4
+ *  PC87365     11      3       3       2       0xE5
+ *  PC87366     11      3       3       3-4     0xE9
+ *
+ *  This driver assumes that no more than one chip is present, and one of
+ *  the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F).
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+#include <linux/i2c-vid.h>
+#include <asm/io.h>
+
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
+static struct i2c_force_data forces[] = {{ NULL }};
+static u8 devid;
+static unsigned int extra_isa[3];
+static u8 confreg[4];
+
+enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 };
+static struct i2c_address_data addr_data = {
+	.normal_i2c		= normal_i2c,
+	.normal_isa		= normal_isa,
+	.forces			= forces,
+};
+
+static int init = 1;
+module_param(init, int, 0);
+MODULE_PARM_DESC(init,
+ "Chip initialization level:\n"
+ " 0: None\n"
+ "*1: Forcibly enable internal voltage and temperature channels, except in9\n"
+ " 2: Forcibly enable all voltage and temperature channels, except in9\n"
+ " 3: Forcibly enable all voltage and temperature channels, including in9");
+
+/*
+ * Super-I/O registers and operations
+ */
+
+#define DEV	0x07	/* Register: Logical device select */
+#define DEVID	0x20	/* Register: Device ID */
+#define ACT	0x30	/* Register: Device activation */
+#define BASE	0x60	/* Register: Base address */
+
+#define FSCM	0x09	/* Logical device: fans */
+#define VLM	0x0d	/* Logical device: voltages */
+#define TMS	0x0e	/* Logical device: temperatures */
+static const u8 logdev[3] = { FSCM, VLM, TMS };
+
+#define LD_FAN		0
+#define LD_IN		1
+#define LD_TEMP		2
+
+static inline void superio_outb(int sioaddr, int reg, int val)
+{
+	outb(reg, sioaddr);
+	outb(val, sioaddr+1);
+}
+
+static inline int superio_inb(int sioaddr, int reg)
+{
+	outb(reg, sioaddr);
+	return inb(sioaddr+1);
+}
+
+static inline void superio_exit(int sioaddr)
+{
+	outb(0x02, sioaddr);
+	outb(0x02, sioaddr+1);
+}
+
+/*
+ * Logical devices
+ */
+
+#define PC87360_EXTENT		0x10
+#define PC87365_REG_BANK	0x09
+#define NO_BANK			0xff
+
+/*
+ * Fan registers and conversions
+ */
+
+/* nr has to be 0 or 1 (PC87360/87363) or 2 (PC87364/87365/87366) */
+#define PC87360_REG_PRESCALE(nr)	(0x00 + 2 * (nr))
+#define PC87360_REG_PWM(nr)		(0x01 + 2 * (nr))
+#define PC87360_REG_FAN_MIN(nr)		(0x06 + 3 * (nr))
+#define PC87360_REG_FAN(nr)		(0x07 + 3 * (nr))
+#define PC87360_REG_FAN_STATUS(nr)	(0x08 + 3 * (nr))
+
+#define FAN_FROM_REG(val,div)		((val) == 0 ? 0: \
+					 480000 / ((val)*(div)))
+#define FAN_TO_REG(val,div)		((val) <= 100 ? 0 : \
+					 480000 / ((val)*(div)))
+#define FAN_DIV_FROM_REG(val)		(1 << ((val >> 5) & 0x03))
+#define FAN_STATUS_FROM_REG(val)	((val) & 0x07)
+
+#define FAN_CONFIG_MONITOR(val,nr)	(((val) >> (2 + nr * 3)) & 1)
+#define FAN_CONFIG_CONTROL(val,nr)	(((val) >> (3 + nr * 3)) & 1)
+#define FAN_CONFIG_INVERT(val,nr)	(((val) >> (4 + nr * 3)) & 1)
+
+#define PWM_FROM_REG(val,inv)		((inv) ? 255 - (val) : (val))
+static inline u8 PWM_TO_REG(int val, int inv)
+{
+	if (inv)
+		val = 255 - val;
+	if (val < 0)
+		return 0;
+	if (val > 255)
+		return 255;
+	return val;
+}
+
+/*
+ * Voltage registers and conversions
+ */
+
+#define PC87365_REG_IN_CONVRATE		0x07
+#define PC87365_REG_IN_CONFIG		0x08
+#define PC87365_REG_IN			0x0B
+#define PC87365_REG_IN_MIN		0x0D
+#define PC87365_REG_IN_MAX		0x0C
+#define PC87365_REG_IN_STATUS		0x0A
+#define PC87365_REG_IN_ALARMS1		0x00
+#define PC87365_REG_IN_ALARMS2		0x01
+#define PC87365_REG_VID			0x06
+
+#define IN_FROM_REG(val,ref)		(((val) * (ref) + 128) / 256)
+#define IN_TO_REG(val,ref)		((val) < 0 ? 0 : \
+					 (val)*256 >= (ref)*255 ? 255: \
+					 ((val) * 256 + (ref)/2) / (ref))
+
+/*
+ * Temperature registers and conversions
+ */
+
+#define PC87365_REG_TEMP_CONFIG		0x08
+#define PC87365_REG_TEMP		0x0B
+#define PC87365_REG_TEMP_MIN		0x0D
+#define PC87365_REG_TEMP_MAX		0x0C
+#define PC87365_REG_TEMP_CRIT		0x0E
+#define PC87365_REG_TEMP_STATUS		0x0A
+#define PC87365_REG_TEMP_ALARMS		0x00
+
+#define TEMP_FROM_REG(val)		((val) * 1000)
+#define TEMP_TO_REG(val)		((val) < -55000 ? -55 : \
+					 (val) > 127000 ? 127 : \
+					 (val) < 0 ? ((val) - 500) / 1000 : \
+					 ((val) + 500) / 1000)
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct pc87360_data {
+	struct i2c_client client;
+	struct semaphore lock;
+	struct semaphore update_lock;
+	char valid;		/* !=0 if following fields are valid */
+	unsigned long last_updated;	/* In jiffies */
+
+	int address[3];
+
+	u8 fannr, innr, tempnr;
+
+	u8 fan[3];		/* Register value */
+	u8 fan_min[3];		/* Register value */
+	u8 fan_status[3];	/* Register value */
+	u8 pwm[3];		/* Register value */
+	u16 fan_conf;		/* Configuration register values, combined */
+
+	u16 in_vref;		/* 1 mV/bit */
+	u8 in[14];		/* Register value */
+	u8 in_min[14];		/* Register value */
+	u8 in_max[14];		/* Register value */
+	u8 in_crit[3];		/* Register value */
+	u8 in_status[14];	/* Register value */
+	u16 in_alarms;		/* Register values, combined, masked */
+	u8 vid_conf;		/* Configuration register value */
+	u8 vrm;
+	u8 vid;			/* Register value */
+
+	s8 temp[3];		/* Register value */
+	s8 temp_min[3];		/* Register value */
+	s8 temp_max[3];		/* Register value */
+	s8 temp_crit[3];	/* Register value */
+	u8 temp_status[3];	/* Register value */
+	u8 temp_alarms;		/* Register value, masked */
+};
+
+/*
+ * Functions declaration
+ */
+
+static int pc87360_attach_adapter(struct i2c_adapter *adapter);
+static int pc87360_detect(struct i2c_adapter *adapter, int address, int kind);
+static int pc87360_detach_client(struct i2c_client *client);
+
+static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
+			      u8 reg);
+static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank,
+				u8 reg, u8 value);
+static void pc87360_init_client(struct i2c_client *client, int use_thermistors);
+static struct pc87360_data *pc87360_update_device(struct device *dev);
+
+/*
+ * Driver data (common to all clients)
+ */
+
+static struct i2c_driver pc87360_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "pc87360",
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= pc87360_attach_adapter,
+	.detach_client	= pc87360_detach_client,
+};
+
+/*
+ * Sysfs stuff
+ */
+
+static ssize_t set_fan_min(struct device *dev, const char *buf,
+	size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct pc87360_data *data = i2c_get_clientdata(client);
+	long fan_min = simple_strtol(buf, NULL, 10);
+
+	fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[nr]));
+
+	/* If it wouldn't fit, change clock divisor */
+	while (fan_min > 255
+	    && (data->fan_status[nr] & 0x60) != 0x60) {
+		fan_min >>= 1;
+		data->fan[nr] >>= 1;
+		data->fan_status[nr] += 0x20;
+	}
+	data->fan_min[nr] = fan_min > 255 ? 255 : fan_min;
+	pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(nr),
+			    data->fan_min[nr]);
+
+	/* Write new divider, preserve alarm bits */
+	pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(nr),
+			    data->fan_status[nr] & 0xF9);
+
+	return count;
+}
+
+#define show_and_set_fan(offset) \
+static ssize_t show_fan##offset##_input(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[offset-1], \
+		       FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \
+} \
+static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[offset-1], \
+		       FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \
+} \
+static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", \
+		       FAN_DIV_FROM_REG(data->fan_status[offset-1])); \
+} \
+static ssize_t show_fan##offset##_status(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", \
+		       FAN_STATUS_FROM_REG(data->fan_status[offset-1])); \
+} \
+static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	return set_fan_min(dev, buf, count, offset-1); \
+} \
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
+	show_fan##offset##_input, NULL); \
+static DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \
+	show_fan##offset##_min, set_fan##offset##_min); \
+static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
+	show_fan##offset##_div, NULL); \
+static DEVICE_ATTR(fan##offset##_status, S_IRUGO, \
+	show_fan##offset##_status, NULL);
+show_and_set_fan(1)
+show_and_set_fan(2)
+show_and_set_fan(3)
+
+#define show_and_set_pwm(offset) \
+static ssize_t show_pwm##offset(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", \
+		       PWM_FROM_REG(data->pwm[offset-1], \
+				    FAN_CONFIG_INVERT(data->fan_conf, \
+						      offset-1))); \
+} \
+static ssize_t set_pwm##offset(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->pwm[offset-1] = PWM_TO_REG(val, \
+			      FAN_CONFIG_INVERT(data->fan_conf, offset-1)); \
+	pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(offset-1), \
+			    data->pwm[offset-1]); \
+	return count; \
+} \
+static DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \
+	show_pwm##offset, set_pwm##offset);
+show_and_set_pwm(1)
+show_and_set_pwm(2)
+show_and_set_pwm(3)
+
+#define show_and_set_in(offset) \
+static ssize_t show_in##offset##_input(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \
+		       data->in_vref)); \
+} \
+static ssize_t show_in##offset##_min(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \
+		       data->in_vref)); \
+} \
+static ssize_t show_in##offset##_max(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \
+		       data->in_vref)); \
+} \
+static ssize_t show_in##offset##_status(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", data->in_status[offset]); \
+} \
+static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->in_min[offset] = IN_TO_REG(val, data->in_vref); \
+	pc87360_write_value(data, LD_IN, offset, PC87365_REG_IN_MIN, \
+			    data->in_min[offset]); \
+	return count; \
+} \
+static ssize_t set_in##offset##_max(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->in_max[offset] = IN_TO_REG(val, \
+			       data->in_vref); \
+	pc87360_write_value(data, LD_IN, offset, PC87365_REG_IN_MAX, \
+			    data->in_max[offset]); \
+	return count; \
+} \
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
+	show_in##offset##_input, NULL); \
+static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
+	show_in##offset##_min, set_in##offset##_min); \
+static DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
+	show_in##offset##_max, set_in##offset##_max); \
+static DEVICE_ATTR(in##offset##_status, S_IRUGO, \
+	show_in##offset##_status, NULL);
+show_and_set_in(0)
+show_and_set_in(1)
+show_and_set_in(2)
+show_and_set_in(3)
+show_and_set_in(4)
+show_and_set_in(5)
+show_and_set_in(6)
+show_and_set_in(7)
+show_and_set_in(8)
+show_and_set_in(9)
+show_and_set_in(10)
+
+#define show_and_set_therm(offset) \
+static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset+7], \
+		       data->in_vref)); \
+} \
+static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset+7], \
+		       data->in_vref)); \
+} \
+static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset+7], \
+		       data->in_vref)); \
+} \
+static ssize_t show_temp##offset##_crit(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[offset-4], \
+		       data->in_vref)); \
+} \
+static ssize_t show_temp##offset##_status(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%u\n", data->in_status[offset+7]); \
+} \
+static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->in_min[offset+7] = IN_TO_REG(val, data->in_vref); \
+	pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_MIN, \
+			    data->in_min[offset+7]); \
+	return count; \
+} \
+static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->in_max[offset+7] = IN_TO_REG(val, data->in_vref); \
+	pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_MAX, \
+			    data->in_max[offset+7]); \
+	return count; \
+} \
+static ssize_t set_temp##offset##_crit(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->in_crit[offset-4] = IN_TO_REG(val, data->in_vref); \
+	pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_CRIT, \
+			    data->in_crit[offset-4]); \
+	return count; \
+} \
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
+	show_temp##offset##_input, NULL); \
+static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
+	show_temp##offset##_min, set_temp##offset##_min); \
+static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
+	show_temp##offset##_max, set_temp##offset##_max); \
+static DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
+	show_temp##offset##_crit, set_temp##offset##_crit); \
+static DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
+	show_temp##offset##_status, NULL);
+show_and_set_therm(4)
+show_and_set_therm(5)
+show_and_set_therm(6)
+
+static ssize_t show_vid(struct device *dev, char *buf)
+{
+	struct pc87360_data *data = pc87360_update_device(dev);
+	return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
+}
+static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
+
+static ssize_t show_vrm(struct device *dev, char *buf)
+{
+	struct pc87360_data *data = pc87360_update_device(dev);
+	return sprintf(buf, "%u\n", data->vrm);
+}
+static ssize_t set_vrm(struct device *dev, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct pc87360_data *data = i2c_get_clientdata(client);
+	data->vrm = simple_strtoul(buf, NULL, 10);
+	return count;
+}
+static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
+
+static ssize_t show_in_alarms(struct device *dev, char *buf)
+{
+	struct pc87360_data *data = pc87360_update_device(dev);
+	return sprintf(buf, "%u\n", data->in_alarms);
+}
+static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL);
+
+#define show_and_set_temp(offset) \
+static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \
+} \
+static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \
+} \
+static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \
+}\
+static ssize_t show_temp##offset##_crit(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[offset-1])); \
+}\
+static ssize_t show_temp##offset##_status(struct device *dev, char *buf) \
+{ \
+	struct pc87360_data *data = pc87360_update_device(dev); \
+	return sprintf(buf, "%d\n", data->temp_status[offset-1]); \
+}\
+static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->temp_min[offset-1] = TEMP_TO_REG(val); \
+	pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_MIN, \
+			    data->temp_min[offset-1]); \
+	return count; \
+} \
+static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->temp_max[offset-1] = TEMP_TO_REG(val); \
+	pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_MAX, \
+			    data->temp_max[offset-1]); \
+	return count; \
+} \
+static ssize_t set_temp##offset##_crit(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct pc87360_data *data = i2c_get_clientdata(client); \
+	long val = simple_strtol(buf, NULL, 10); \
+	data->temp_crit[offset-1] = TEMP_TO_REG(val); \
+	pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_CRIT, \
+			    data->temp_crit[offset-1]); \
+	return count; \
+} \
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
+	show_temp##offset##_input, NULL); \
+static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
+	show_temp##offset##_min, set_temp##offset##_min); \
+static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
+	show_temp##offset##_max, set_temp##offset##_max); \
+static DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
+	show_temp##offset##_crit, set_temp##offset##_crit); \
+static DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
+	show_temp##offset##_status, NULL);
+show_and_set_temp(1)
+show_and_set_temp(2)
+show_and_set_temp(3)
+
+static ssize_t show_temp_alarms(struct device *dev, char *buf)
+{
+	struct pc87360_data *data = pc87360_update_device(dev);
+	return sprintf(buf, "%u\n", data->temp_alarms);
+}
+static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL);
+
+/*
+ * Device detection, registration and update
+ */
+
+static int pc87360_attach_adapter(struct i2c_adapter *adapter)
+{
+	return i2c_detect(adapter, &addr_data, pc87360_detect);
+}
+
+static int pc87360_find(int sioaddr, u8 *devid, int *address)
+{
+	u16 val;
+	int i;
+	int nrdev; /* logical device count */
+
+	/* No superio_enter */
+
+	/* Identify device */
+	val = superio_inb(sioaddr, DEVID);
+	switch (val) {
+	case 0xE1: /* PC87360 */
+	case 0xE8: /* PC87363 */
+	case 0xE4: /* PC87364 */
+		nrdev = 1;
+		break;
+	case 0xE5: /* PC87365 */
+	case 0xE9: /* PC87366 */
+		nrdev = 3;
+		break;
+	default:
+		superio_exit(sioaddr);
+		return -ENODEV;
+	}
+	/* Remember the device id */
+	*devid = val;
+
+	for (i = 0; i < nrdev; i++) {
+		/* select logical device */
+		superio_outb(sioaddr, DEV, logdev[i]);
+
+		val = superio_inb(sioaddr, ACT);
+		if (!(val & 0x01)) {
+			printk(KERN_INFO "pc87360: Device 0x%02x not "
+			       "activated\n", logdev[i]);
+			continue;
+		}
+
+		val = (superio_inb(sioaddr, BASE) << 8)
+		    | superio_inb(sioaddr, BASE + 1);
+		if (!val) {
+			printk(KERN_INFO "pc87360: Base address not set for "
+			       "device 0x%02x\n", logdev[i]);
+			continue;
+		}
+
+		address[i] = val;
+
+		if (i==0) { /* Fans */
+			confreg[0] = superio_inb(sioaddr, 0xF0);
+			confreg[1] = superio_inb(sioaddr, 0xF1);
+
+#ifdef DEBUG
+			printk(KERN_DEBUG "pc87360: Fan 1: mon=%d "
+			       "ctrl=%d inv=%d\n", (confreg[0]>>2)&1,
+			       (confreg[0]>>3)&1, (confreg[0]>>4)&1);
+			printk(KERN_DEBUG "pc87360: Fan 2: mon=%d "
+			       "ctrl=%d inv=%d\n", (confreg[0]>>5)&1,
+			       (confreg[0]>>6)&1, (confreg[0]>>7)&1);
+			printk(KERN_DEBUG "pc87360: Fan 3: mon=%d "
+			       "ctrl=%d inv=%d\n", confreg[1]&1,
+			       (confreg[1]>>1)&1, (confreg[1]>>2)&1);
+#endif
+		} else if (i==1) { /* Voltages */
+			/* Are we using thermistors? */
+			if (*devid == 0xE9) { /* PC87366 */
+				/* These registers are not logical-device
+				   specific, just that we won't need them if
+				   we don't use the VLM device */
+				confreg[2] = superio_inb(sioaddr, 0x2B);
+				confreg[3] = superio_inb(sioaddr, 0x25);
+
+				if (confreg[2] & 0x40) {
+					printk(KERN_INFO "pc87360: Using "
+					       "thermistors for temperature "
+					       "monitoring\n");
+				}
+				if (confreg[3] & 0xE0) {
+					printk(KERN_INFO "pc87360: VID "
+					       "inputs routed (mode %u)\n",
+					       confreg[3] >> 5);
+				}
+			}
+		}
+	}
+
+	superio_exit(sioaddr);
+	return 0;
+}
+
+/* We don't really care about the address.
+   Read from extra_isa instead. */
+int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+	int i;
+	struct i2c_client *new_client;
+	struct pc87360_data *data;
+	int err = 0;
+	const char *name = "pc87360";
+	int use_thermistors = 0;
+
+	if (!i2c_is_isa_adapter(adapter))
+		return -ENODEV;
+
+	if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
+		return -ENOMEM;
+	memset(data, 0x00, sizeof(struct pc87360_data));
+
+	new_client = &data->client;
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	init_MUTEX(&data->lock);
+	new_client->adapter = adapter;
+	new_client->driver = &pc87360_driver;
+	new_client->flags = 0;
+
+	data->fannr = 2;
+	data->innr = 0;
+	data->tempnr = 0;
+
+	switch (devid) {
+	case 0xe8:
+		name = "pc87363";
+		break;
+	case 0xe4:
+		name = "pc87364";
+		data->fannr = 3;
+		break;
+	case 0xe5:
+		name = "pc87365";
+		data->fannr = extra_isa[0] ? 3 : 0;
+		data->innr = extra_isa[1] ? 11 : 0;
+		data->tempnr = extra_isa[2] ? 2 : 0;
+		break;
+	case 0xe9:
+		name = "pc87366";
+		data->fannr = extra_isa[0] ? 3 : 0;
+		data->innr = extra_isa[1] ? 14 : 0;
+		data->tempnr = extra_isa[2] ? 3 : 0;
+		break;
+	}
+
+	strcpy(new_client->name, name);
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	for (i = 0; i < 3; i++) {
+		if (((data->address[i] = extra_isa[i]))
+		 && !request_region(extra_isa[i], PC87360_EXTENT, "pc87360")) {
+			dev_err(&new_client->dev, "Region 0x%x-0x%x already "
+				"in use!\n", extra_isa[i],
+				extra_isa[i]+PC87360_EXTENT-1);
+			for (i--; i >= 0; i--)
+				release_region(extra_isa[i], PC87360_EXTENT);
+			err = -EBUSY;
+			goto ERROR1;
+		}
+	}
+
+	/* Retrieve the fans configuration from Super-I/O space */
+	if (data->fannr)
+		data->fan_conf = confreg[0] | (confreg[1] << 8);
+
+	if ((err = i2c_attach_client(new_client)))
+		goto ERROR2;
+
+	/* Use the correct reference voltage
+	   Unless both the VLM and the TMS logical devices agree to
+	   use an external Vref, the internal one is used. */
+	if (data->innr) {
+		i = pc87360_read_value(data, LD_IN, NO_BANK,
+				       PC87365_REG_IN_CONFIG);
+		if (data->tempnr) {
+			i &= pc87360_read_value(data, LD_TEMP, NO_BANK,
+						PC87365_REG_TEMP_CONFIG);
+		}
+		data->in_vref = (i&0x02) ? 3025 : 2966;
+		dev_dbg(&new_client->dev, "Using %s reference voltage\n",
+			(i&0x02) ? "external" : "internal");
+
+		data->vid_conf = confreg[3];
+		data->vrm = 90;
+	}
+
+	/* Fan clock dividers may be needed before any data is read */
+	for (i = 0; i < data->fannr; i++) {
+		data->fan_status[i] = pc87360_read_value(data, LD_FAN,
+				      NO_BANK, PC87360_REG_FAN_STATUS(i));
+	}
+
+	if (init > 0) {
+		if (devid == 0xe9 && data->address[1]) /* PC87366 */
+			use_thermistors = confreg[2] & 0x40;
+
+		pc87360_init_client(new_client, use_thermistors);
+	}
+
+	/* Register sysfs hooks */
+	if (data->innr) {
+		device_create_file(&new_client->dev, &dev_attr_in0_input);
+		device_create_file(&new_client->dev, &dev_attr_in1_input);
+		device_create_file(&new_client->dev, &dev_attr_in2_input);
+		device_create_file(&new_client->dev, &dev_attr_in3_input);
+		device_create_file(&new_client->dev, &dev_attr_in4_input);
+		device_create_file(&new_client->dev, &dev_attr_in5_input);
+		device_create_file(&new_client->dev, &dev_attr_in6_input);
+		device_create_file(&new_client->dev, &dev_attr_in7_input);
+		device_create_file(&new_client->dev, &dev_attr_in8_input);
+		device_create_file(&new_client->dev, &dev_attr_in9_input);
+		device_create_file(&new_client->dev, &dev_attr_in10_input);
+		device_create_file(&new_client->dev, &dev_attr_in0_min);
+		device_create_file(&new_client->dev, &dev_attr_in1_min);
+		device_create_file(&new_client->dev, &dev_attr_in2_min);
+		device_create_file(&new_client->dev, &dev_attr_in3_min);
+		device_create_file(&new_client->dev, &dev_attr_in4_min);
+		device_create_file(&new_client->dev, &dev_attr_in5_min);
+		device_create_file(&new_client->dev, &dev_attr_in6_min);
+		device_create_file(&new_client->dev, &dev_attr_in7_min);
+		device_create_file(&new_client->dev, &dev_attr_in8_min);
+		device_create_file(&new_client->dev, &dev_attr_in9_min);
+		device_create_file(&new_client->dev, &dev_attr_in10_min);
+		device_create_file(&new_client->dev, &dev_attr_in0_max);
+		device_create_file(&new_client->dev, &dev_attr_in1_max);
+		device_create_file(&new_client->dev, &dev_attr_in2_max);
+		device_create_file(&new_client->dev, &dev_attr_in3_max);
+		device_create_file(&new_client->dev, &dev_attr_in4_max);
+		device_create_file(&new_client->dev, &dev_attr_in5_max);
+		device_create_file(&new_client->dev, &dev_attr_in6_max);
+		device_create_file(&new_client->dev, &dev_attr_in7_max);
+		device_create_file(&new_client->dev, &dev_attr_in8_max);
+		device_create_file(&new_client->dev, &dev_attr_in9_max);
+		device_create_file(&new_client->dev, &dev_attr_in10_max);
+		device_create_file(&new_client->dev, &dev_attr_in0_status);
+		device_create_file(&new_client->dev, &dev_attr_in1_status);
+		device_create_file(&new_client->dev, &dev_attr_in2_status);
+		device_create_file(&new_client->dev, &dev_attr_in3_status);
+		device_create_file(&new_client->dev, &dev_attr_in4_status);
+		device_create_file(&new_client->dev, &dev_attr_in5_status);
+		device_create_file(&new_client->dev, &dev_attr_in6_status);
+		device_create_file(&new_client->dev, &dev_attr_in7_status);
+		device_create_file(&new_client->dev, &dev_attr_in8_status);
+		device_create_file(&new_client->dev, &dev_attr_in9_status);
+		device_create_file(&new_client->dev, &dev_attr_in10_status);
+
+		device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
+		device_create_file(&new_client->dev, &dev_attr_vrm);
+		device_create_file(&new_client->dev, &dev_attr_alarms_in);
+	}
+
+	if (data->tempnr) {
+		device_create_file(&new_client->dev, &dev_attr_temp1_input);
+		device_create_file(&new_client->dev, &dev_attr_temp2_input);
+		device_create_file(&new_client->dev, &dev_attr_temp1_min);
+		device_create_file(&new_client->dev, &dev_attr_temp2_min);
+		device_create_file(&new_client->dev, &dev_attr_temp1_max);
+		device_create_file(&new_client->dev, &dev_attr_temp2_max);
+		device_create_file(&new_client->dev, &dev_attr_temp1_crit);
+		device_create_file(&new_client->dev, &dev_attr_temp2_crit);
+		device_create_file(&new_client->dev, &dev_attr_temp1_status);
+		device_create_file(&new_client->dev, &dev_attr_temp2_status);
+
+		device_create_file(&new_client->dev, &dev_attr_alarms_temp);
+	}
+	if (data->tempnr == 3) {
+		device_create_file(&new_client->dev, &dev_attr_temp3_input);
+		device_create_file(&new_client->dev, &dev_attr_temp3_min);
+		device_create_file(&new_client->dev, &dev_attr_temp3_max);
+		device_create_file(&new_client->dev, &dev_attr_temp3_crit);
+		device_create_file(&new_client->dev, &dev_attr_temp3_status);
+	}
+	if (data->innr == 14) {
+		device_create_file(&new_client->dev, &dev_attr_temp4_input);
+		device_create_file(&new_client->dev, &dev_attr_temp5_input);
+		device_create_file(&new_client->dev, &dev_attr_temp6_input);
+		device_create_file(&new_client->dev, &dev_attr_temp4_min);
+		device_create_file(&new_client->dev, &dev_attr_temp5_min);
+		device_create_file(&new_client->dev, &dev_attr_temp6_min);
+		device_create_file(&new_client->dev, &dev_attr_temp4_max);
+		device_create_file(&new_client->dev, &dev_attr_temp5_max);
+		device_create_file(&new_client->dev, &dev_attr_temp6_max);
+		device_create_file(&new_client->dev, &dev_attr_temp4_crit);
+		device_create_file(&new_client->dev, &dev_attr_temp5_crit);
+		device_create_file(&new_client->dev, &dev_attr_temp6_crit);
+		device_create_file(&new_client->dev, &dev_attr_temp4_status);
+		device_create_file(&new_client->dev, &dev_attr_temp5_status);
+		device_create_file(&new_client->dev, &dev_attr_temp6_status);
+	}
+
+	if (data->fannr) {
+		device_create_file(&new_client->dev, &dev_attr_fan1_input);
+		device_create_file(&new_client->dev, &dev_attr_fan2_input);
+		device_create_file(&new_client->dev, &dev_attr_fan1_min);
+		device_create_file(&new_client->dev, &dev_attr_fan2_min);
+		device_create_file(&new_client->dev, &dev_attr_fan1_div);
+		device_create_file(&new_client->dev, &dev_attr_fan2_div);
+		device_create_file(&new_client->dev, &dev_attr_fan1_status);
+		device_create_file(&new_client->dev, &dev_attr_fan2_status);
+
+		if (FAN_CONFIG_CONTROL(data->fan_conf, 0))
+			device_create_file(&new_client->dev, &dev_attr_pwm1);
+		if (FAN_CONFIG_CONTROL(data->fan_conf, 1))
+			device_create_file(&new_client->dev, &dev_attr_pwm2);
+	}
+	if (data->fannr == 3) {
+		device_create_file(&new_client->dev, &dev_attr_fan3_input);
+		device_create_file(&new_client->dev, &dev_attr_fan3_min);
+		device_create_file(&new_client->dev, &dev_attr_fan3_div);
+		device_create_file(&new_client->dev, &dev_attr_fan3_status);
+
+		if (FAN_CONFIG_CONTROL(data->fan_conf, 2))
+			device_create_file(&new_client->dev, &dev_attr_pwm3);
+	}
+
+	return 0;
+
+ERROR2:
+	for (i = 0; i < 3; i++) {
+		if (data->address[i]) {
+			release_region(data->address[i], PC87360_EXTENT);
+		}
+	}
+ERROR1:
+	kfree(data);
+	return err;
+}
+
+static int pc87360_detach_client(struct i2c_client *client)
+{
+	struct pc87360_data *data = i2c_get_clientdata(client);
+	int i;
+
+	if ((i = i2c_detach_client(client))) {
+		dev_err(&client->dev, "Client deregistration failed, "
+			"client not detached.\n");
+		return i;
+	}
+
+	for (i = 0; i < 3; i++) {
+		if (data->address[i]) {
+			release_region(data->address[i], PC87360_EXTENT);
+		}
+	}
+	kfree(data);
+
+	return 0;
+}
+
+/* ldi is the logical device index
+   bank is for voltages and temperatures only */
+static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
+			      u8 reg)
+{
+	int res;
+
+	down(&(data->lock));
+	if (bank != NO_BANK)
+		outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
+	res = inb_p(data->address[ldi] + reg);
+	up(&(data->lock));
+
+	return res;
+}
+
+static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank,
+				u8 reg, u8 value)
+{
+	down(&(data->lock));
+	if (bank != NO_BANK)
+		outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
+	outb_p(value, data->address[ldi] + reg);
+	up(&(data->lock));
+}
+
+static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
+{
+	struct pc87360_data *data = i2c_get_clientdata(client);
+	int i, nr;
+	const u8 init_in[14] = { 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 1, 2, 2, 2 };
+	const u8 init_temp[3] = { 2, 2, 1 };
+	u8 reg;
+
+	if (init >= 2 && data->innr) {
+		reg = pc87360_read_value(data, LD_IN, NO_BANK,
+					 PC87365_REG_IN_CONVRATE);
+		dev_info(&client->dev, "VLM conversion set to"
+			 "1s period, 160us delay\n");
+		pc87360_write_value(data, LD_IN, NO_BANK,
+				    PC87365_REG_IN_CONVRATE,
+				    (reg & 0xC0) | 0x11);
+	}
+
+	nr = data->innr < 11 ? data->innr : 11;
+	for (i=0; i<nr; i++) {
+		if (init >= init_in[i]) {
+			/* Forcibly enable voltage channel */
+			reg = pc87360_read_value(data, LD_IN, i,
+						 PC87365_REG_IN_STATUS);
+			if (!(reg & 0x01)) {
+				dev_dbg(&client->dev, "Forcibly "
+					"enabling in%d\n", i);
+				pc87360_write_value(data, LD_IN, i,
+						    PC87365_REG_IN_STATUS,
+						    (reg & 0x68) | 0x87);
+			}
+		}
+	}
+
+	/* We can't blindly trust the Super-I/O space configuration bit,
+	   most BIOS won't set it properly */
+	for (i=11; i<data->innr; i++) {
+		reg = pc87360_read_value(data, LD_IN, i,
+					 PC87365_REG_TEMP_STATUS);
+		use_thermistors = use_thermistors || (reg & 0x01);
+	}
+
+	i = use_thermistors ? 2 : 0;
+	for (; i<data->tempnr; i++) {
+		if (init >= init_temp[i]) {
+			/* Forcibly enable temperature channel */
+			reg = pc87360_read_value(data, LD_TEMP, i,
+						 PC87365_REG_TEMP_STATUS);
+			if (!(reg & 0x01)) {
+				dev_dbg(&client->dev, "Forcibly "
+					"enabling temp%d\n", i+1);
+				pc87360_write_value(data, LD_TEMP, i,
+						    PC87365_REG_TEMP_STATUS,
+						    0xCF);
+			}
+		}
+	}
+
+	if (use_thermistors) {
+		for (i=11; i<data->innr; i++) {
+			if (init >= init_in[i]) {
+				/* The pin may already be used by thermal
+				   diodes */
+				reg = pc87360_read_value(data, LD_TEMP,
+				      (i-11)/2, PC87365_REG_TEMP_STATUS);
+				if (reg & 0x01) {
+					dev_dbg(&client->dev, "Skipping "
+						"temp%d, pin already in use "
+						"by temp%d\n", i-7, (i-11)/2);
+					continue;
+				}
+
+				/* Forcibly enable thermistor channel */
+				reg = pc87360_read_value(data, LD_IN, i,
+							 PC87365_REG_IN_STATUS);
+				if (!(reg & 0x01)) {
+					dev_dbg(&client->dev, "Forcibly "
+						"enabling temp%d\n", i-7);
+					pc87360_write_value(data, LD_IN, i,
+						PC87365_REG_TEMP_STATUS,
+						(reg & 0x60) | 0x8F);
+				}
+			}
+		}
+	}
+
+	if (data->innr) {
+		reg = pc87360_read_value(data, LD_IN, NO_BANK,
+					 PC87365_REG_IN_CONFIG);
+		if (reg & 0x01) {
+			dev_dbg(&client->dev, "Forcibly "
+				"enabling monitoring (VLM)\n");
+			pc87360_write_value(data, LD_IN, NO_BANK,
+					    PC87365_REG_IN_CONFIG,
+					    reg & 0xFE);
+		}
+	}
+
+	if (data->tempnr) {
+		reg = pc87360_read_value(data, LD_TEMP, NO_BANK,
+					 PC87365_REG_TEMP_CONFIG);
+		if (reg & 0x01) {
+			dev_dbg(&client->dev, "Forcibly enabling "
+				"monitoring (TMS)\n");
+			pc87360_write_value(data, LD_TEMP, NO_BANK,
+					    PC87365_REG_TEMP_CONFIG,
+					    reg & 0xFE);
+		}
+
+		if (init >= 2) {
+			/* Chip config as documented by National Semi. */
+			pc87360_write_value(data, LD_TEMP, 0xF, 0xA, 0x08);
+			/* We voluntarily omit the bank here, in case the
+			   sequence itself matters. It shouldn't be a problem,
+			   since nobody else is supposed to access the
+			   device at that point. */
+			pc87360_write_value(data, LD_TEMP, NO_BANK, 0xB, 0x04);
+			pc87360_write_value(data, LD_TEMP, NO_BANK, 0xC, 0x35);
+			pc87360_write_value(data, LD_TEMP, NO_BANK, 0xD, 0x05);
+			pc87360_write_value(data, LD_TEMP, NO_BANK, 0xE, 0x05);
+		}
+	}
+}
+
+static void pc87360_autodiv(struct i2c_client *client, int nr)
+{
+	struct pc87360_data *data = i2c_get_clientdata(client);
+	u8 old_min = data->fan_min[nr];
+
+	/* Increase clock divider if needed and possible */
+	if ((data->fan_status[nr] & 0x04) /* overflow flag */
+	 || (data->fan[nr] >= 224)) { /* next to overflow */
+		if ((data->fan_status[nr] & 0x60) != 0x60) {
+			data->fan_status[nr] += 0x20;
+			data->fan_min[nr] >>= 1;
+			data->fan[nr] >>= 1;
+			dev_dbg(&client->dev, "Increasing "
+				"clock divider to %d for fan %d\n",
+				FAN_DIV_FROM_REG(data->fan_status[nr]), nr+1);
+		}
+	} else {
+		/* Decrease clock divider if possible */
+		while (!(data->fan_min[nr] & 0x80) /* min "nails" divider */
+		 && data->fan[nr] < 85 /* bad accuracy */
+		 && (data->fan_status[nr] & 0x60) != 0x00) {
+			data->fan_status[nr] -= 0x20;
+			data->fan_min[nr] <<= 1;
+			data->fan[nr] <<= 1;
+			dev_dbg(&client->dev, "Decreasing "
+				"clock divider to %d for fan %d\n",
+				FAN_DIV_FROM_REG(data->fan_status[nr]),
+				nr+1);
+		}
+	}
+
+	/* Write new fan min if it changed */
+	if (old_min != data->fan_min[nr]) {
+		pc87360_write_value(data, LD_FAN, NO_BANK,
+				    PC87360_REG_FAN_MIN(nr),
+				    data->fan_min[nr]);
+	}
+}
+
+static struct pc87360_data *pc87360_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct pc87360_data *data = i2c_get_clientdata(client);
+	u8 i;
+
+	down(&data->update_lock);
+
+	if ((jiffies - data->last_updated > HZ * 2)
+	 || (jiffies < data->last_updated) || !data->valid) {
+		dev_dbg(&client->dev, "Data update\n");
+
+		/* Fans */
+		for (i = 0; i < data->fannr; i++) {
+			if (FAN_CONFIG_MONITOR(data->fan_conf, i)) {
+				data->fan_status[i] =
+					pc87360_read_value(data, LD_FAN,
+					NO_BANK, PC87360_REG_FAN_STATUS(i));
+				data->fan[i] = pc87360_read_value(data, LD_FAN,
+					       NO_BANK, PC87360_REG_FAN(i));
+				data->fan_min[i] = pc87360_read_value(data,
+						   LD_FAN, NO_BANK,
+						   PC87360_REG_FAN_MIN(i));
+				/* Change clock divider if needed */
+				pc87360_autodiv(client, i);
+				/* Clear bits and write new divider */
+				pc87360_write_value(data, LD_FAN, NO_BANK,
+						    PC87360_REG_FAN_STATUS(i),
+						    data->fan_status[i]);
+			}
+			if (FAN_CONFIG_CONTROL(data->fan_conf, i))
+				data->pwm[i] = pc87360_read_value(data, LD_FAN,
+					       NO_BANK, PC87360_REG_PWM(i));
+		}
+
+		/* Voltages */
+		for (i = 0; i < data->innr; i++) {
+			data->in_status[i] = pc87360_read_value(data, LD_IN, i,
+					     PC87365_REG_IN_STATUS);
+			/* Clear bits */
+			pc87360_write_value(data, LD_IN, i,
+					    PC87365_REG_IN_STATUS,
+					    data->in_status[i]);
+			if ((data->in_status[i] & 0x81) == 0x81) {
+				data->in[i] = pc87360_read_value(data, LD_IN,
+					      i, PC87365_REG_IN);
+			}
+			if (data->in_status[i] & 0x01) {
+				data->in_min[i] = pc87360_read_value(data,
+						  LD_IN, i,
+						  PC87365_REG_IN_MIN);
+				data->in_max[i] = pc87360_read_value(data,
+						  LD_IN, i,
+						  PC87365_REG_IN_MAX);
+				if (i >= 11)
+					data->in_crit[i-11] =
+						pc87360_read_value(data, LD_IN,
+						i, PC87365_REG_TEMP_CRIT);
+			}
+		}
+		if (data->innr) {
+			data->in_alarms = pc87360_read_value(data, LD_IN,
+					  NO_BANK, PC87365_REG_IN_ALARMS1)
+					| ((pc87360_read_value(data, LD_IN,
+					    NO_BANK, PC87365_REG_IN_ALARMS2)
+					    & 0x07) << 8);
+			data->vid = (data->vid_conf & 0xE0) ?
+				    pc87360_read_value(data, LD_IN,
+				    NO_BANK, PC87365_REG_VID) : 0x1F;
+		}
+
+		/* Temperatures */
+		for (i = 0; i < data->tempnr; i++) {
+			data->temp_status[i] = pc87360_read_value(data,
+					       LD_TEMP, i,
+					       PC87365_REG_TEMP_STATUS);
+			/* Clear bits */
+			pc87360_write_value(data, LD_TEMP, i,
+					    PC87365_REG_TEMP_STATUS,
+					    data->temp_status[i]);
+			if ((data->temp_status[i] & 0x81) == 0x81) {
+				data->temp[i] = pc87360_read_value(data,
+						LD_TEMP, i,
+						PC87365_REG_TEMP);
+			}
+			if (data->temp_status[i] & 0x01) {
+				data->temp_min[i] = pc87360_read_value(data,
+						    LD_TEMP, i,
+						    PC87365_REG_TEMP_MIN);
+				data->temp_max[i] = pc87360_read_value(data,
+						    LD_TEMP, i,
+						    PC87365_REG_TEMP_MAX);
+				data->temp_crit[i] = pc87360_read_value(data,
+						     LD_TEMP, i,
+						     PC87365_REG_TEMP_CRIT);
+			}
+		}
+		if (data->tempnr) {
+			data->temp_alarms = pc87360_read_value(data, LD_TEMP,
+					    NO_BANK, PC87365_REG_TEMP_ALARMS)
+					    & 0x3F;
+		}
+
+		data->last_updated = jiffies;
+		data->valid = 1;
+	}
+
+	up(&data->update_lock);
+
+	return data;
+}
+
+static int __init pc87360_init(void)
+{
+	int i;
+
+	if (pc87360_find(0x2e, &devid, extra_isa)
+	 && pc87360_find(0x4e, &devid, extra_isa)) {
+		printk(KERN_WARNING "pc87360: PC8736x not detected, "
+		       "module not inserted.\n");
+		return -ENODEV;
+	}
+
+	/* Arbitrarily pick one of the addresses */
+	for (i = 0; i < 3; i++) {
+		if (extra_isa[i] != 0x0000) {
+			normal_isa[0] = extra_isa[i];
+			break;
+		}
+	}
+
+	if (normal_isa[0] == 0x0000) {
+		printk(KERN_WARNING "pc87360: No active logical device, "
+		       "module not inserted.\n");
+		return -ENODEV;
+	}
+
+	return i2c_add_driver(&pc87360_driver);
+}
+
+static void __exit pc87360_exit(void)
+{
+	i2c_del_driver(&pc87360_driver);
+}
+
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("PC8736x hardware monitor");
+MODULE_LICENSE("GPL");
+
+module_init(pc87360_init);
+module_exit(pc87360_exit);
diff -Nru a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
--- a/drivers/i2c/chips/pcf8574.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/i2c/chips/pcf8574.c	2004-12-24 13:36:18 -08:00
@@ -42,10 +42,10 @@
 #include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x20, 0x27, 0x38, 0x3f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+					0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+					I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_2(pcf8574, pcf8574a);
@@ -77,7 +77,7 @@
 	.detach_client	= pcf8574_detach_client,
 };
 
-static int pcf8574_id = 0;
+static int pcf8574_id;
 
 /* following are the sysfs callback functions */
 static ssize_t show_read(struct device *dev, char *buf)
diff -Nru a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
--- a/drivers/i2c/chips/pcf8591.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/i2c/chips/pcf8591.c	2004-12-24 13:37:43 -08:00
@@ -27,10 +27,9 @@
 #include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x48, 0x4f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
+					0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(pcf8591);
@@ -99,7 +98,7 @@
 	.detach_client	= pcf8591_detach_client,
 };
 
-static int pcf8591_id = 0;
+static int pcf8591_id;
 
 /* following are the sysfs callback functions */
 #define show_in_channel(channel)					\
diff -Nru a/drivers/i2c/chips/smsc47m1.c b/drivers/i2c/chips/smsc47m1.c
--- a/drivers/i2c/chips/smsc47m1.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/i2c/chips/smsc47m1.c	2004-12-24 13:36:33 -08:00
@@ -34,22 +34,14 @@
 #include <asm/io.h>
 
 static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 /* Address is autodetected, there is no default value */
 static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 static struct i2c_force_data forces[] = {{NULL}};
 
 enum chips { any_chip, smsc47m1 };
 static struct i2c_address_data addr_data = {
 	.normal_i2c		= normal_i2c,
-	.normal_i2c_range	= normal_i2c_range,
 	.normal_isa		= normal_isa,
-	.normal_isa_range	= normal_isa_range,
-	.probe			= normal_i2c,		/* cheat */
-	.probe_range		= normal_i2c_range,	/* cheat */
-	.ignore			= normal_i2c,		/* cheat */
-	.ignore_range		= normal_i2c_range,	/* cheat */
 	.forces			= forces,
 };
 
@@ -182,13 +174,13 @@
 	return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]));
 }
 
-static ssize_t get_fan_pwm(struct device *dev, char *buf, int nr)
+static ssize_t get_pwm(struct device *dev, char *buf, int nr)
 {
 	struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
 	return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr]));
 }
 
-static ssize_t get_fan_pwm_en(struct device *dev, char *buf, int nr)
+static ssize_t get_pwm_en(struct device *dev, char *buf, int nr)
 {
 	struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
 	return sprintf(buf, "%d\n", PWM_EN_FROM_REG(data->pwm[nr]));
@@ -256,7 +248,7 @@
 	return count;
 }
 
-static ssize_t set_fan_pwm(struct device *dev, const char *buf,
+static ssize_t set_pwm(struct device *dev, const char *buf,
 		size_t count, int nr)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -275,7 +267,7 @@
 	return count;
 }
 
-static ssize_t set_fan_pwm_en(struct device *dev, const char *buf,
+static ssize_t set_pwm_en(struct device *dev, const char *buf,
 		size_t count, int nr)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -298,43 +290,43 @@
 #define fan_present(offset)						\
 static ssize_t get_fan##offset (struct device *dev, char *buf)		\
 {									\
-	return get_fan(dev, buf, 0x##offset - 1);			\
+	return get_fan(dev, buf, offset - 1);				\
 }									\
 static ssize_t get_fan##offset##_min (struct device *dev, char *buf)	\
 {									\
-	return get_fan_min(dev, buf, 0x##offset - 1);			\
+	return get_fan_min(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_fan##offset##_min (struct device *dev,		\
 		const char *buf, size_t count)				\
 {									\
-	return set_fan_min(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_min(dev, buf, count, offset - 1);		\
 }									\
 static ssize_t get_fan##offset##_div (struct device *dev, char *buf)	\
 {									\
-	return get_fan_div(dev, buf, 0x##offset - 1);			\
+	return get_fan_div(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_fan##offset##_div (struct device *dev,		\
 		const char *buf, size_t count)				\
 {									\
-	return set_fan_div(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_div(dev, buf, count, offset - 1);		\
 }									\
-static ssize_t get_fan##offset##_pwm (struct device *dev, char *buf)	\
+static ssize_t get_pwm##offset (struct device *dev, char *buf)		\
 {									\
-	return get_fan_pwm(dev, buf, 0x##offset - 1);			\
+	return get_pwm(dev, buf, offset - 1);				\
 }									\
-static ssize_t set_fan##offset##_pwm (struct device *dev,		\
+static ssize_t set_pwm##offset (struct device *dev,			\
 		const char *buf, size_t count)				\
 {									\
-	return set_fan_pwm(dev, buf, count, 0x##offset - 1);		\
+	return set_pwm(dev, buf, count, offset - 1);			\
 }									\
-static ssize_t get_fan##offset##_pwm_en (struct device *dev, char *buf)	\
+static ssize_t get_pwm##offset##_en (struct device *dev, char *buf)	\
 {									\
-	return get_fan_pwm_en(dev, buf, 0x##offset - 1);		\
+	return get_pwm_en(dev, buf, offset - 1);			\
 }									\
-static ssize_t set_fan##offset##_pwm_en (struct device *dev,		\
+static ssize_t set_pwm##offset##_en (struct device *dev,		\
 		const char *buf, size_t count)				\
 {									\
-	return set_fan_pwm_en(dev, buf, count, 0x##offset - 1);		\
+	return set_pwm_en(dev, buf, count, offset - 1);			\
 }									\
 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, get_fan##offset,	\
 		NULL);							\
@@ -342,10 +334,10 @@
 		get_fan##offset##_min, set_fan##offset##_min);		\
 static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR,		\
 		get_fan##offset##_div, set_fan##offset##_div);		\
-static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR,		\
-		get_fan##offset##_pwm, set_fan##offset##_pwm);		\
-static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO | S_IWUSR,		\
-		get_fan##offset##_pwm_en, set_fan##offset##_pwm_en);
+static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR,			\
+		get_pwm##offset, set_pwm##offset);			\
+static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR,		\
+		get_pwm##offset##_en, set_pwm##offset##_en);
 
 fan_present(1);
 fan_present(2);
@@ -402,6 +394,7 @@
 	struct i2c_client *new_client;
 	struct smsc47m1_data *data;
 	int err = 0;
+	int fan1, fan2, pwm1, pwm2;
 
 	if (!i2c_is_isa_adapter(adapter)) {
 		return 0;
@@ -431,6 +424,22 @@
 	new_client->id = smsc47m1_id++;
 	init_MUTEX(&data->update_lock);
 
+	/* If no function is properly configured, there's no point in
+	   actually registering the chip. */
+	fan1 = (smsc47m1_read_value(new_client, SMSC47M1_REG_TPIN(0)) & 0x05)
+	       == 0x05;
+	fan2 = (smsc47m1_read_value(new_client, SMSC47M1_REG_TPIN(1)) & 0x05)
+	       == 0x05;
+	pwm1 = (smsc47m1_read_value(new_client, SMSC47M1_REG_PPIN(0)) & 0x05)
+	       == 0x04;
+	pwm2 = (smsc47m1_read_value(new_client, SMSC47M1_REG_PPIN(1)) & 0x05)
+	       == 0x04;
+	if (!(fan1 || fan2 || pwm1 || pwm2)) {
+		dev_warn(&new_client->dev, "Device is not configured, will not use\n");
+		err = -ENODEV;
+		goto error_free;
+	}
+
 	if ((err = i2c_attach_client(new_client)))
 		goto error_free;
 
@@ -442,8 +451,7 @@
 	   function. */
 	smsc47m1_update_device(&new_client->dev, 1);
 
-	if ((smsc47m1_read_value(new_client, SMSC47M1_REG_TPIN(0)) & 0x05)
-	    == 0x05) {
+	if (fan1) {
 		device_create_file(&new_client->dev, &dev_attr_fan1_input);
 		device_create_file(&new_client->dev, &dev_attr_fan1_min);
 		device_create_file(&new_client->dev, &dev_attr_fan1_div);
@@ -451,8 +459,7 @@
 		dev_dbg(&new_client->dev, "Fan 1 not enabled by hardware, "
 			"skipping\n");
 
-	if ((smsc47m1_read_value(new_client, SMSC47M1_REG_TPIN(1)) & 0x05)
-	    == 0x05) {
+	if (fan2) {
 		device_create_file(&new_client->dev, &dev_attr_fan2_input);
 		device_create_file(&new_client->dev, &dev_attr_fan2_min);
 		device_create_file(&new_client->dev, &dev_attr_fan2_div);
@@ -460,17 +467,15 @@
 		dev_dbg(&new_client->dev, "Fan 2 not enabled by hardware, "
 			"skipping\n");
 
-	if ((smsc47m1_read_value(new_client, SMSC47M1_REG_PPIN(0)) & 0x05)
-	    == 0x04) {
-		device_create_file(&new_client->dev, &dev_attr_fan1_pwm);
-		device_create_file(&new_client->dev, &dev_attr_fan1_pwm_enable);
+	if (pwm1) {
+		device_create_file(&new_client->dev, &dev_attr_pwm1);
+		device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
 	} else
 		dev_dbg(&new_client->dev, "PWM 1 not enabled by hardware, "
 			"skipping\n");
-	if ((smsc47m1_read_value(new_client, SMSC47M1_REG_PPIN(1)) & 0x05)
-	    == 0x04) {
-		device_create_file(&new_client->dev, &dev_attr_fan2_pwm);
-		device_create_file(&new_client->dev, &dev_attr_fan2_pwm_enable);
+	if (pwm2) {
+		device_create_file(&new_client->dev, &dev_attr_pwm2);
+		device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
 	} else
 		dev_dbg(&new_client->dev, "PWM 2 not enabled by hardware, "
 			"skipping\n");
diff -Nru a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
--- a/drivers/i2c/chips/via686a.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/i2c/chips/via686a.c	2004-12-24 13:36:18 -08:00
@@ -52,9 +52,7 @@
    Note that we can't determine the ISA address until we have initialized
    our module */
 static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_1(via686a);
@@ -383,27 +381,27 @@
 static ssize_t 							\
 	show_in##offset (struct device *dev, char *buf)		\
 {								\
-	return show_in(dev, buf, 0x##offset);			\
+	return show_in(dev, buf, offset);			\
 }								\
 static ssize_t 							\
 	show_in##offset##_min (struct device *dev, char *buf)	\
 {								\
-	return show_in_min(dev, buf, 0x##offset);		\
+	return show_in_min(dev, buf, offset);		\
 }								\
 static ssize_t 							\
 	show_in##offset##_max (struct device *dev, char *buf)	\
 {								\
-	return show_in_max(dev, buf, 0x##offset);		\
+	return show_in_max(dev, buf, offset);		\
 }								\
 static ssize_t set_in##offset##_min (struct device *dev, 	\
 		const char *buf, size_t count) 			\
 {								\
-	return set_in_min(dev, buf, count, 0x##offset);		\
+	return set_in_min(dev, buf, count, offset);		\
 }								\
 static ssize_t set_in##offset##_max (struct device *dev,	\
 			const char *buf, size_t count)		\
 {								\
-	return set_in_max(dev, buf, count, 0x##offset);		\
+	return set_in_max(dev, buf, count, offset);		\
 }								\
 static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);\
 static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, 	\
@@ -451,27 +449,27 @@
 #define show_temp_offset(offset)					\
 static ssize_t show_temp_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_temp(dev, buf, 0x##offset - 1);			\
+	return show_temp(dev, buf, offset - 1);				\
 }									\
 static ssize_t								\
 show_temp_##offset##_over (struct device *dev, char *buf)		\
 {									\
-	return show_temp_over(dev, buf, 0x##offset - 1);			\
+	return show_temp_over(dev, buf, offset - 1);			\
 }									\
 static ssize_t								\
 show_temp_##offset##_hyst (struct device *dev, char *buf)		\
 {									\
-	return show_temp_hyst(dev, buf, 0x##offset - 1);			\
+	return show_temp_hyst(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_temp_##offset##_over (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_temp_over(dev, buf, count, 0x##offset - 1);		\
+	return set_temp_over(dev, buf, count, offset - 1);		\
 }									\
 static ssize_t set_temp_##offset##_hyst (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_temp_hyst(dev, buf, count, 0x##offset - 1);		\
+	return set_temp_hyst(dev, buf, count, offset - 1);		\
 }									\
 static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);\
 static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, 		\
@@ -522,25 +520,25 @@
 #define show_fan_offset(offset)						\
 static ssize_t show_fan_##offset (struct device *dev, char *buf)	\
 {									\
-	return show_fan(dev, buf, 0x##offset - 1);			\
+	return show_fan(dev, buf, offset - 1);				\
 }									\
 static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)	\
 {									\
-	return show_fan_min(dev, buf, 0x##offset - 1);			\
+	return show_fan_min(dev, buf, offset - 1);			\
 }									\
 static ssize_t show_fan_##offset##_div (struct device *dev, char *buf)	\
 {									\
-	return show_fan_div(dev, buf, 0x##offset - 1);			\
+	return show_fan_div(dev, buf, offset - 1);			\
 }									\
 static ssize_t set_fan_##offset##_min (struct device *dev, 		\
 	const char *buf, size_t count) 					\
 {									\
-	return set_fan_min(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_min(dev, buf, count, offset - 1);		\
 }									\
 static ssize_t set_fan_##offset##_div (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_fan_div(dev, buf, count, 0x##offset - 1);		\
+	return set_fan_div(dev, buf, count, offset - 1);		\
 }									\
 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, 		\
@@ -838,7 +836,7 @@
 
 static int __init sm_via686a_init(void)
 {
-       return pci_module_init(&via686a_pci_driver);
+       return pci_register_driver(&via686a_pci_driver);
 }
 
 static void __exit sm_via686a_exit(void)
diff -Nru a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
--- a/drivers/i2c/chips/w83627hf.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/i2c/chips/w83627hf.c	2004-12-24 13:37:04 -08:00
@@ -57,9 +57,7 @@
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_4(w83627hf, w83627thf, w83697hf, w83637hf);
@@ -369,20 +367,20 @@
 static ssize_t \
 show_regs_in_##offset (struct device *dev, char *buf) \
 { \
-        return show_in(dev, buf, 0x##offset); \
+        return show_in(dev, buf, offset); \
 } \
 static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
 
 #define sysfs_in_reg_offset(reg, offset) \
 static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
 { \
-	return show_in_##reg (dev, buf, 0x##offset); \
+	return show_in_##reg (dev, buf, offset); \
 } \
 static ssize_t \
 store_regs_in_##reg##offset (struct device *dev, \
 			    const char *buf, size_t count) \
 { \
-	return store_in_##reg (dev, buf, count, 0x##offset); \
+	return store_in_##reg (dev, buf, count, offset); \
 } \
 static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, \
 		  show_regs_in_##reg##offset, store_regs_in_##reg##offset);
@@ -521,19 +519,19 @@
 #define sysfs_fan_offset(offset) \
 static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \
 { \
-	return show_fan(dev, buf, 0x##offset); \
+	return show_fan(dev, buf, offset); \
 } \
 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
 
 #define sysfs_fan_min_offset(offset) \
 static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
 { \
-	return show_fan_min(dev, buf, 0x##offset); \
+	return show_fan_min(dev, buf, offset); \
 } \
 static ssize_t \
 store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \
 { \
-	return store_fan_min(dev, buf, count, 0x##offset); \
+	return store_fan_min(dev, buf, count, offset); \
 } \
 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
 		  show_regs_fan_min##offset, store_regs_fan_min##offset);
@@ -595,20 +593,20 @@
 static ssize_t \
 show_regs_temp_##offset (struct device *dev, char *buf) \
 { \
-	return show_temp(dev, buf, 0x##offset); \
+	return show_temp(dev, buf, offset); \
 } \
 static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
 
 #define sysfs_temp_reg_offset(reg, offset) \
 static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
 { \
-	return show_temp_##reg (dev, buf, 0x##offset); \
+	return show_temp_##reg (dev, buf, offset); \
 } \
 static ssize_t \
 store_regs_temp_##reg##offset (struct device *dev, \
 			      const char *buf, size_t count) \
 { \
-	return store_temp_##reg (dev, buf, count, 0x##offset); \
+	return store_temp_##reg (dev, buf, count, offset); \
 } \
 static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
 		  show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);
@@ -845,7 +843,7 @@
 { \
 	return store_pwm_reg(dev, buf, count, offset); \
 } \
-static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \
+static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
 		  show_regs_pwm_##offset, store_regs_pwm_##offset);
 
 sysfs_pwm(1);
@@ -854,7 +852,7 @@
 
 #define device_create_file_pwm(client, offset) \
 do { \
-device_create_file(&client->dev, &dev_attr_fan##offset##_pwm); \
+device_create_file(&client->dev, &dev_attr_pwm##offset); \
 } while (0)
 
 static ssize_t
diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
--- a/drivers/i2c/chips/w83781d.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/i2c/chips/w83781d.c	2004-12-24 13:36:16 -08:00
@@ -49,10 +49,10 @@
 #define W83781D_RT			1
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { 0x20, 0x2f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+					0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+					0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf);
@@ -318,18 +318,18 @@
 static ssize_t \
 show_regs_in_##offset (struct device *dev, char *buf) \
 { \
-        return show_in(dev, buf, 0x##offset); \
+        return show_in(dev, buf, offset); \
 } \
 static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
 
 #define sysfs_in_reg_offset(reg, offset) \
 static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
 { \
-	return show_in_##reg (dev, buf, 0x##offset); \
+	return show_in_##reg (dev, buf, offset); \
 } \
 static ssize_t store_regs_in_##reg##offset (struct device *dev, const char *buf, size_t count) \
 { \
-	return store_in_##reg (dev, buf, count, 0x##offset); \
+	return store_in_##reg (dev, buf, count, offset); \
 } \
 static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_in_##reg##offset, store_regs_in_##reg##offset);
 
@@ -384,18 +384,18 @@
 #define sysfs_fan_offset(offset) \
 static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \
 { \
-	return show_fan(dev, buf, 0x##offset); \
+	return show_fan(dev, buf, offset); \
 } \
 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
 
 #define sysfs_fan_min_offset(offset) \
 static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
 { \
-	return show_fan_min(dev, buf, 0x##offset); \
+	return show_fan_min(dev, buf, offset); \
 } \
 static ssize_t store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \
 { \
-	return store_fan_min(dev, buf, count, 0x##offset); \
+	return store_fan_min(dev, buf, count, offset); \
 } \
 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, show_regs_fan_min##offset, store_regs_fan_min##offset);
 
@@ -464,18 +464,18 @@
 static ssize_t \
 show_regs_temp_##offset (struct device *dev, char *buf) \
 { \
-	return show_temp(dev, buf, 0x##offset); \
+	return show_temp(dev, buf, offset); \
 } \
 static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
 
 #define sysfs_temp_reg_offset(reg, offset) \
 static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
 { \
-	return show_temp_##reg (dev, buf, 0x##offset); \
+	return show_temp_##reg (dev, buf, offset); \
 } \
 static ssize_t store_regs_temp_##reg##offset (struct device *dev, const char *buf, size_t count) \
 { \
-	return store_temp_##reg (dev, buf, count, 0x##offset); \
+	return store_temp_##reg (dev, buf, count, offset); \
 } \
 static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);
 
@@ -740,22 +740,26 @@
 { \
 	return show_pwm_reg(dev, buf, offset); \
 } \
-static ssize_t store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \
+static ssize_t store_regs_pwm_##offset (struct device *dev, \
+		const char *buf, size_t count) \
 { \
 	return store_pwm_reg(dev, buf, count, offset); \
 } \
-static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, show_regs_pwm_##offset, store_regs_pwm_##offset);
+static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
+		show_regs_pwm_##offset, store_regs_pwm_##offset);
 
 #define sysfs_pwmenable(offset) \
 static ssize_t show_regs_pwmenable_##offset (struct device *dev, char *buf) \
 { \
 	return show_pwmenable_reg(dev, buf, offset); \
 } \
-static ssize_t store_regs_pwmenable_##offset (struct device *dev, const char *buf, size_t count) \
+static ssize_t store_regs_pwmenable_##offset (struct device *dev, \
+		const char *buf, size_t count) \
 { \
 	return store_pwmenable_reg(dev, buf, count, offset); \
 } \
-static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO | S_IWUSR, show_regs_pwmenable_##offset, store_regs_pwmenable_##offset);
+static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
+		show_regs_pwmenable_##offset, store_regs_pwmenable_##offset);
 
 sysfs_pwm(1);
 sysfs_pwm(2);
@@ -765,12 +769,12 @@
 
 #define device_create_file_pwm(client, offset) \
 do { \
-device_create_file(&client->dev, &dev_attr_fan##offset##_pwm); \
+device_create_file(&client->dev, &dev_attr_pwm##offset); \
 } while (0)
 
 #define device_create_file_pwmenable(client, offset) \
 do { \
-device_create_file(&client->dev, &dev_attr_fan##offset##_pwm_enable); \
+device_create_file(&client->dev, &dev_attr_pwm##offset##_enable); \
 } while (0)
 
 static ssize_t
@@ -1062,6 +1066,9 @@
 	
 	if (is_isa)
 		if (!request_region(address, W83781D_EXTENT, "w83781d")) {
+			dev_dbg(&adapter->dev, "Request of region "
+				"0x%x-0x%x for w83781d failed\n", address,
+				address + W83781D_EXTENT - 1);
 			err = -EBUSY;
 			goto ERROR0;
 		}
@@ -1075,15 +1082,11 @@
 			/* We need the timeouts for at least some LM78-like
 			   chips. But only if we read 'undefined' registers. */
 			i = inb_p(address + 1);
-			if (inb_p(address + 2) != i) {
-				err = -ENODEV;
-				goto ERROR1;
-			}
-			if (inb_p(address + 3) != i) {
-				err = -ENODEV;
-				goto ERROR1;
-			}
-			if (inb_p(address + 7) != i) {
+			if (inb_p(address + 2) != i
+			 || inb_p(address + 3) != i
+			 || inb_p(address + 7) != i) {
+				dev_dbg(&adapter->dev, "Detection of w83781d "
+					"chip failed at step 1\n");
 				err = -ENODEV;
 				goto ERROR1;
 			}
@@ -1092,8 +1095,13 @@
 			/* Let's just hope nothing breaks here */
 			i = inb_p(address + 5) & 0x7f;
 			outb_p(~i & 0x7f, address + 5);
-			if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {
+			val2 = inb_p(address + 5) & 0x7f;
+			if (val2 != (~i & 0x7f)) {
 				outb_p(i, address + 5);
+				dev_dbg(&adapter->dev, "Detection of w83781d "
+					"chip failed at step 2 (0x%x != "
+					"0x%x at 0x%x)\n", val2, ~i & 0x7f,
+					address + 5);
 				err = -ENODEV;
 				goto ERROR1;
 			}
@@ -1125,7 +1133,9 @@
 	   force_*=... parameter, and the Winbond will be reset to the right
 	   bank. */
 	if (kind < 0) {
-		if (w83781d_read_value(new_client, W83781D_REG_CONFIG) & 0x80){
+		if (w83781d_read_value(new_client, W83781D_REG_CONFIG) & 0x80) {
+			dev_dbg(&new_client->dev, "Detection failed at step "
+				"3\n");
 			err = -ENODEV;
 			goto ERROR2;
 		}
@@ -1135,6 +1145,8 @@
 		if ((!(val1 & 0x07)) &&
 		    (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3))
 		     || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) {
+			dev_dbg(&new_client->dev, "Detection failed at step "
+				"4\n");
 			err = -ENODEV;
 			goto ERROR2;
 		}
@@ -1144,6 +1156,8 @@
 				  ((val1 & 0x80) && (val2 == 0x5c)))) {
 			if (w83781d_read_value
 			    (new_client, W83781D_REG_I2C_ADDR) != address) {
+				dev_dbg(&new_client->dev, "Detection failed "
+					"at step 5\n");
 				err = -ENODEV;
 				goto ERROR2;
 			}
@@ -1166,6 +1180,8 @@
 		else if (val2 == 0x12)
 			vendid = asus;
 		else {
+			dev_dbg(&new_client->dev, "Chip was made by neither "
+				"Winbond nor Asus?\n");
 			err = -ENODEV;
 			goto ERROR2;
 		}
@@ -1186,10 +1202,10 @@
 			kind = w83697hf;
 		else {
 			if (kind == 0)
-				dev_warn(&new_client->dev,
-				       "Ignoring 'force' parameter for unknown chip at"
-				       "adapter %d, address 0x%02x\n",
-				       i2c_adapter_id(adapter), address);
+				dev_warn(&new_client->dev, "Ignoring 'force' "
+					 "parameter for unknown chip at "
+					 "adapter %d, address 0x%02x\n",
+					 i2c_adapter_id(adapter), address);
 			err = -EINVAL;
 			goto ERROR2;
 		}
diff -Nru a/drivers/i2c/chips/w83l785ts.c b/drivers/i2c/chips/w83l785ts.c
--- a/drivers/i2c/chips/w83l785ts.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/i2c/chips/w83l785ts.c	2004-12-24 13:36:31 -08:00
@@ -47,9 +47,7 @@
  */
 
 static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
@@ -282,14 +280,17 @@
 	 * default value requested by the caller. */
 	for (i = 1; i <= MAX_RETRIES; i++) {
 		value = i2c_smbus_read_byte_data(client, reg);
-		if (value >= 0)
+		if (value >= 0) {
+			dev_dbg(&client->dev, "Read 0x%02x from register "
+				"0x%02x.\n", value, reg);
 			return value;
+		}
 		dev_dbg(&client->dev, "Read failed, will retry in %d.\n", i);
 		msleep(i);
 	}
 
-	dev_err(&client->dev, "Couldn't read value from register. "
-		"Please report.\n");
+	dev_err(&client->dev, "Couldn't read value from register 0x%02x. "
+		"Please report.\n", reg);
 	return defval;
 }
 
diff -Nru a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
--- a/drivers/i2c/i2c-core.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/i2c/i2c-core.c	2004-12-24 13:36:18 -08:00
@@ -177,12 +177,25 @@
 int i2c_del_adapter(struct i2c_adapter *adap)
 {
 	struct list_head  *item, *_n;
+	struct i2c_adapter *adap_from_list;
 	struct i2c_driver *driver;
 	struct i2c_client *client;
 	int res = 0;
 
 	down(&core_lists);
 
+	/* First make sure that this adapter was ever added */
+	list_for_each_entry(adap_from_list, &adapters, list) {
+		if (adap_from_list == adap)
+			break;
+	}
+	if (adap_from_list != adap) {
+		pr_debug("I2C: Attempting to delete an unregistered "
+			 "adapter\n");
+		res = -EINVAL;
+		goto out_unlock;
+	}
+
 	list_for_each(item,&drivers) {
 		driver = list_entry(item, struct i2c_driver, list);
 		if (driver->detach_adapter)
@@ -517,9 +530,29 @@
 	return 1;
 }
 
+static int i2c_bus_suspend(struct device * dev, u32 state)
+{
+	int rc = 0;
+
+	if (dev->driver && dev->driver->suspend)
+		rc = dev->driver->suspend(dev,state,0);
+	return rc;
+}
+
+static int i2c_bus_resume(struct device * dev)
+{
+	int rc = 0;
+	
+	if (dev->driver && dev->driver->resume)
+		rc = dev->driver->resume(dev,0);
+	return rc;
+}
+
 struct bus_type i2c_bus_type = {
 	.name =		"i2c",
 	.match =	i2c_device_match,
+	.suspend =      i2c_bus_suspend,
+	.resume =       i2c_bus_resume,
 };
 
 static int __init i2c_init(void)
@@ -727,7 +760,7 @@
 			if (addr == address_data->normal_i2c[i]) {
 				found = 1;
 				dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, "
-					"addr %02x", adap_id,addr);
+					"addr %02x\n", adap_id, addr);
 			}
 		}
 
@@ -988,35 +1021,8 @@
 	                      I2C_SMBUS_WORD_DATA,&data);
 }
 
-s32 i2c_smbus_process_call(struct i2c_client *client, u8 command, u16 value)
-{
-	union i2c_smbus_data data;
-	data.word = value;
-	if (i2c_smbus_xfer(client->adapter,client->addr,client->flags,
-	                   I2C_SMBUS_WRITE,command,
-	                   I2C_SMBUS_PROC_CALL, &data))
-		return -1;
-	else
-		return 0x0FFFF & data.word;
-}
-
-/* Returns the number of read bytes */
-s32 i2c_smbus_read_block_data(struct i2c_client *client, u8 command, u8 *values)
-{
-	union i2c_smbus_data data;
-	int i;
-	if (i2c_smbus_xfer(client->adapter,client->addr,client->flags,
-	                   I2C_SMBUS_READ,command,
-	                   I2C_SMBUS_BLOCK_DATA,&data))
-		return -1;
-	else {
-		for (i = 1; i <= data.block[0]; i++)
-			values[i-1] = data.block[i];
-		return data.block[0];
-	}
-}
-
-s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, u8 length, u8 *values)
+s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
+			       u8 length, u8 *values)
 {
 	union i2c_smbus_data data;
 	int i;
@@ -1026,27 +1032,8 @@
 		data.block[i] = values[i-1];
 	data.block[0] = length;
 	return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
-	                      I2C_SMBUS_WRITE,command,
-	                      I2C_SMBUS_BLOCK_DATA,&data);
-}
-
-/* Returns the number of read bytes */
-s32 i2c_smbus_block_process_call(struct i2c_client *client, u8 command, u8 length, u8 *values)
-{
-	union i2c_smbus_data data;
-	int i;
-	if (length > I2C_SMBUS_BLOCK_MAX - 1)
-		return -1;
-	data.block[0] = length;
-	for (i = 1; i <= length; i++)
-		data.block[i] = values[i-1];
-	if(i2c_smbus_xfer(client->adapter,client->addr,client->flags,
-	                  I2C_SMBUS_WRITE, command,
-	                  I2C_SMBUS_BLOCK_PROC_CALL, &data))
-		return -1;
-	for (i = 1; i <= data.block[0]; i++)
-		values[i-1] = data.block[i];
-	return data.block[0];
+			      I2C_SMBUS_WRITE,command,
+			      I2C_SMBUS_BLOCK_DATA,&data);
 }
 
 /* Returns the number of read bytes */
@@ -1065,20 +1052,6 @@
 	}
 }
 
-s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, u8 length, u8 *values)
-{
-	union i2c_smbus_data data;
-	int i;
-	if (length > I2C_SMBUS_I2C_BLOCK_MAX)
-		length = I2C_SMBUS_I2C_BLOCK_MAX;
-	for (i = 1; i <= length; i++)
-		data.block[i] = values[i-1];
-	data.block[0] = length;
-	return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
-	                      I2C_SMBUS_WRITE,command,
-	                      I2C_SMBUS_I2C_BLOCK_DATA,&data);
-}
-
 /* Simulate a SMBus command using the i2c protocol 
    No checking of parameters is done!  */
 static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, 
@@ -1302,11 +1275,8 @@
 EXPORT_SYMBOL(i2c_smbus_write_byte_data);
 EXPORT_SYMBOL(i2c_smbus_read_word_data);
 EXPORT_SYMBOL(i2c_smbus_write_word_data);
-EXPORT_SYMBOL(i2c_smbus_process_call);
-EXPORT_SYMBOL(i2c_smbus_read_block_data);
 EXPORT_SYMBOL(i2c_smbus_write_block_data);
 EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data);
-EXPORT_SYMBOL(i2c_smbus_write_i2c_block_data);
 
 EXPORT_SYMBOL(i2c_get_functionality);
 EXPORT_SYMBOL(i2c_check_functionality);
diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
--- a/drivers/i2c/i2c-dev.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/i2c/i2c-dev.c	2004-12-24 13:37:18 -08:00
@@ -539,7 +539,7 @@
 out_unreg_chrdev:
 	unregister_chrdev(I2C_MAJOR, "i2c");
 out:
-	printk(KERN_ERR "%s: Driver Initialisation failed", __FILE__);
+	printk(KERN_ERR "%s: Driver Initialisation failed\n", __FILE__);
 	return res;
 }
 
diff -Nru a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c
--- a/drivers/i2c/i2c-sensor-detect.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/i2c/i2c-sensor-detect.c	2004-12-24 13:36:55 -08:00
@@ -31,6 +31,8 @@
 #include <linux/i2c-sensor.h>
 #include <asm/uaccess.h>
 
+static unsigned short empty[] = {I2C_CLIENT_END};
+static unsigned int empty_isa[] = {I2C_CLIENT_ISA_END};
 
 /* Very inefficient for ISA detects, and won't work for 10-bit addresses! */
 int i2c_detect(struct i2c_adapter *adapter,
@@ -42,11 +44,27 @@
 	int is_isa = i2c_is_isa_adapter(adapter);
 	int adapter_id =
 	    is_isa ? ANY_I2C_ISA_BUS : i2c_adapter_id(adapter);
+	unsigned short *normal_i2c;
+	unsigned int *normal_isa;
+	unsigned short *probe;
+	unsigned short *ignore;
 
 	/* Forget it if we can't probe using SMBUS_QUICK */
 	if ((!is_isa) &&
 	    !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK))
 		return -1;
+	
+	/* Use default "empty" list if the adapter doesn't specify any */
+	normal_i2c = probe = ignore = empty;
+	normal_isa = empty_isa;
+	if (address_data->normal_i2c)
+		normal_i2c = address_data->normal_i2c;
+	if (address_data->normal_isa)
+		normal_isa = address_data->normal_isa;
+	if (address_data->probe)
+		probe = address_data->probe;
+	if (address_data->ignore)
+		ignore = address_data->ignore;
 
 	for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) {
 		if (!is_isa && i2c_check_addr(adapter, addr))
@@ -72,79 +90,44 @@
 
 		/* If this address is in one of the ignores, we can forget about it
 		   right now */
-		for (i = 0; !found && (address_data->ignore[i] != I2C_CLIENT_END); i += 2) {
-			if ( ((adapter_id == address_data->ignore[i]) ||
-			      ((address_data->ignore[i] == ANY_I2C_BUS) &&
+		for (i = 0; !found && (ignore[i] != I2C_CLIENT_END); i += 2) {
+			if ( ((adapter_id == ignore[i]) ||
+			      ((ignore[i] == ANY_I2C_BUS) &&
 			       !is_isa)) &&
-			      (addr == address_data->ignore[i + 1])) {
+			      (addr == ignore[i + 1])) {
 				dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
 				found = 1;
 			}
 		}
-		for (i = 0; !found && (address_data->ignore_range[i] != I2C_CLIENT_END); i += 3) {
-			if ( ((adapter_id == address_data->ignore_range[i]) ||
-			      ((address_data-> ignore_range[i] == ANY_I2C_BUS) & 
-			       !is_isa)) &&
-			     (addr >= address_data->ignore_range[i + 1]) &&
-			     (addr <= address_data->ignore_range[i + 2])) {
-				dev_dbg(&adapter->dev,  "found ignore_range parameter for adapter %d, addr %04x\n", adapter_id, addr);
-				found = 1;
-			}
-		}
 		if (found)
 			continue;
 
 		/* Now, we will do a detection, but only if it is in the normal or 
 		   probe entries */
 		if (is_isa) {
-			for (i = 0; !found && (address_data->normal_isa[i] != I2C_CLIENT_ISA_END); i += 1) {
-				if (addr == address_data->normal_isa[i]) {
+			for (i = 0; !found && (normal_isa[i] != I2C_CLIENT_ISA_END); i += 1) {
+				if (addr == normal_isa[i]) {
 					dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr);
 					found = 1;
 				}
 			}
-			for (i = 0; !found && (address_data->normal_isa_range[i] != I2C_CLIENT_ISA_END); i += 3) {
-				if ((addr >= address_data->normal_isa_range[i]) &&
-				    (addr <= address_data->normal_isa_range[i + 1]) &&
-				    ((addr - address_data->normal_isa_range[i]) % address_data->normal_isa_range[i + 2] == 0)) {
-					dev_dbg(&adapter->dev, "found normal isa_range entry for adapter %d, addr %04x", adapter_id, addr);
-					found = 1;
-				}
-			}
 		} else {
-			for (i = 0; !found && (address_data->normal_i2c[i] != I2C_CLIENT_END); i += 1) {
-				if (addr == address_data->normal_i2c[i]) {
-					found = 1;
-					dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x", adapter_id, addr);
-				}
-			}
-			for (i = 0; !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); i += 2) {
-				if ((addr >= address_data->normal_i2c_range[i]) &&
-				    (addr <= address_data->normal_i2c_range[i + 1])) {
-					dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, addr %04x\n", adapter_id, addr);
+			for (i = 0; !found && (normal_i2c[i] != I2C_CLIENT_END); i += 1) {
+				if (addr == normal_i2c[i]) {
 					found = 1;
+					dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x\n", adapter_id, addr);
 				}
 			}
 		}
 
 		for (i = 0;
-		     !found && (address_data->probe[i] != I2C_CLIENT_END);
+		     !found && (probe[i] != I2C_CLIENT_END);
 		     i += 2) {
-			if (((adapter_id == address_data->probe[i]) ||
-			     ((address_data->
-			       probe[i] == ANY_I2C_BUS) && !is_isa))
-			    && (addr == address_data->probe[i + 1])) {
+			if (((adapter_id == probe[i]) ||
+			     ((probe[i] == ANY_I2C_BUS) && !is_isa))
+			    && (addr == probe[i + 1])) {
 				dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
 				found = 1;
-			}
-		}
-		for (i = 0; !found && (address_data->probe_range[i] != I2C_CLIENT_END); i += 3) {
-			if ( ((adapter_id == address_data->probe_range[i]) ||
-			      ((address_data->probe_range[i] == ANY_I2C_BUS) && !is_isa)) &&
-			     (addr >= address_data->probe_range[i + 1]) &&
-			     (addr <= address_data->probe_range[i + 2])) {
-				found = 1;
-				dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, addr %04x\n", adapter_id, addr);
 			}
 		}
 		if (!found)
diff -Nru a/drivers/ide/Kconfig b/drivers/ide/Kconfig
--- a/drivers/ide/Kconfig	2004-12-24 13:36:48 -08:00
+++ b/drivers/ide/Kconfig	2004-12-24 13:36:48 -08:00
@@ -273,15 +273,6 @@
 
 	  If you are unsure, say N here.
 
-config IDE_TASKFILE_IO
-	bool 'IDE Taskfile IO (EXPERIMENTAL)'
-	depends on EXPERIMENTAL
-	default n
-	---help---
-	  Use new taskfile IO code.
-
-	  It is safe to say Y to this question, in most cases.
-
 comment "IDE chipset support/bugfixes"
 
 config IDE_GENERIC
@@ -781,17 +772,6 @@
 	  This option enables the use of the sleep LED as a hard drive
 	  activity LED.
 
-config BLK_DEV_IDEDMA_PMAC_AUTO
-	bool "Use DMA by default"
-	depends on BLK_DEV_IDEDMA_PMAC
-	help
-	  This option allows the driver for the built-in IDE controller on
-	  Power Macintoshes and PowerBooks to use DMA automatically, without
-	  it having to be explicitly enabled.  This option is provided because
-	  of concerns about a couple of cases where using DMA on buggy PC
-	  hardware may have caused damage.  Saying Y should be safe on all
-	  Apple machines.
-
 config IDE_ARM
 	def_bool ARM && (ARCH_A5K || ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK)
 
@@ -1007,19 +987,6 @@
 	  See the <file:Documentation/ide.txt> and
 	  <file:drivers/ide/legacy/ht6560b.c> files for more info.
 
-config BLK_DEV_PDC4030
-	tristate "PROMISE DC4030 support (EXPERIMENTAL)"
-	depends on BLK_DEV_IDEDISK && EXPERIMENTAL
-	help
-	  This driver provides support for the secondary IDE interface and
-	  cache of the original Promise IDE chipsets, e.g. DC4030 and DC5030.
-	  It is nothing to do with the later range of Promise UDMA chipsets -
-	  see the PDC_202XX support for these. CD-ROM and TAPE devices are not
-	  supported (and probably never will be since I don't think the cards
-	  support them). This driver is enabled at runtime using the "ide0=dc4030"
-	  or "ide1=dc4030" kernel boot parameter. See the
-	  <file:drivers/ide/legacy/pdc4030.c> file for more info.
-
 config BLK_DEV_QD65XX
 	tristate "QDI QD65xx support"
 	help
@@ -1059,7 +1026,7 @@
 	  It is normally safe to answer Y; however, the default is N.
 
 config IDEDMA_AUTO
-	def_bool IDEDMA_PCI_AUTO || BLK_DEV_IDEDMA_PMAC_AUTO || IDEDMA_ICS_AUTO
+	def_bool IDEDMA_PCI_AUTO || IDEDMA_ICS_AUTO
 
 endif
 
diff -Nru a/drivers/ide/Makefile b/drivers/ide/Makefile
--- a/drivers/ide/Makefile	2004-12-24 13:36:55 -08:00
+++ b/drivers/ide/Makefile	2004-12-24 13:36:55 -08:00
@@ -52,3 +52,4 @@
 
 obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/
 obj-$(CONFIG_BLK_DEV_HD)		+= legacy/
+obj-$(CONFIG_ETRAX_IDE)		+= cris/
diff -Nru a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
--- a/drivers/ide/arm/icside.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/ide/arm/icside.c	2004-12-24 13:36:49 -08:00
@@ -1,7 +1,9 @@
 /*
  * linux/drivers/ide/arm/icside.c
  *
- * Copyright (c) 1996-2003 Russell King.
+ * Copyright (c) 1996-2004 Russell King.
+ *
+ * Please note that this platform does not support 32-bit IDE IO.
  */
 
 #include <linux/config.h>
@@ -16,6 +18,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/device.h>
 #include <linux/init.h>
+#include <linux/scatterlist.h>
 
 #include <asm/dma.h>
 #include <asm/ecard.h>
@@ -23,21 +26,21 @@
 
 #define ICS_IDENT_OFFSET		0x2280
 
-#define ICS_ARCIN_V5_INTRSTAT		0x000
-#define ICS_ARCIN_V5_INTROFFSET		0x001
-#define ICS_ARCIN_V5_IDEOFFSET		0xa00
-#define ICS_ARCIN_V5_IDEALTOFFSET	0xae0
-#define ICS_ARCIN_V5_IDESTEPPING	4
-
-#define ICS_ARCIN_V6_IDEOFFSET_1	0x800
-#define ICS_ARCIN_V6_INTROFFSET_1	0x880
-#define ICS_ARCIN_V6_INTRSTAT_1		0x8a4
-#define ICS_ARCIN_V6_IDEALTOFFSET_1	0x8e0
-#define ICS_ARCIN_V6_IDEOFFSET_2	0xc00
-#define ICS_ARCIN_V6_INTROFFSET_2	0xc80
-#define ICS_ARCIN_V6_INTRSTAT_2		0xca4
-#define ICS_ARCIN_V6_IDEALTOFFSET_2	0xce0
-#define ICS_ARCIN_V6_IDESTEPPING	4
+#define ICS_ARCIN_V5_INTRSTAT		0x0000
+#define ICS_ARCIN_V5_INTROFFSET		0x0004
+#define ICS_ARCIN_V5_IDEOFFSET		0x2800
+#define ICS_ARCIN_V5_IDEALTOFFSET	0x2b80
+#define ICS_ARCIN_V5_IDESTEPPING	6
+
+#define ICS_ARCIN_V6_IDEOFFSET_1	0x2000
+#define ICS_ARCIN_V6_INTROFFSET_1	0x2200
+#define ICS_ARCIN_V6_INTRSTAT_1		0x2290
+#define ICS_ARCIN_V6_IDEALTOFFSET_1	0x2380
+#define ICS_ARCIN_V6_IDEOFFSET_2	0x3000
+#define ICS_ARCIN_V6_INTROFFSET_2	0x3200
+#define ICS_ARCIN_V6_INTRSTAT_2		0x3290
+#define ICS_ARCIN_V6_IDEALTOFFSET_2	0x3380
+#define ICS_ARCIN_V6_IDESTEPPING	6
 
 struct cardinfo {
 	unsigned int dataoffset;
@@ -46,28 +49,28 @@
 };
 
 static struct cardinfo icside_cardinfo_v5 = {
-	ICS_ARCIN_V5_IDEOFFSET,
-	ICS_ARCIN_V5_IDEALTOFFSET,
-	ICS_ARCIN_V5_IDESTEPPING
+	.dataoffset	= ICS_ARCIN_V5_IDEOFFSET,
+	.ctrloffset	= ICS_ARCIN_V5_IDEALTOFFSET,
+	.stepping	= ICS_ARCIN_V5_IDESTEPPING,
 };
 
 static struct cardinfo icside_cardinfo_v6_1 = {
-	ICS_ARCIN_V6_IDEOFFSET_1,
-	ICS_ARCIN_V6_IDEALTOFFSET_1,
-	ICS_ARCIN_V6_IDESTEPPING
+	.dataoffset	= ICS_ARCIN_V6_IDEOFFSET_1,
+	.ctrloffset	= ICS_ARCIN_V6_IDEALTOFFSET_1,
+	.stepping	= ICS_ARCIN_V6_IDESTEPPING,
 };
 
 static struct cardinfo icside_cardinfo_v6_2 = {
-	ICS_ARCIN_V6_IDEOFFSET_2,
-	ICS_ARCIN_V6_IDEALTOFFSET_2,
-	ICS_ARCIN_V6_IDESTEPPING
+	.dataoffset	= ICS_ARCIN_V6_IDEOFFSET_2,
+	.ctrloffset	= ICS_ARCIN_V6_IDEALTOFFSET_2,
+	.stepping	= ICS_ARCIN_V6_IDESTEPPING,
 };
 
 struct icside_state {
 	unsigned int channel;
 	unsigned int enabled;
-	unsigned long irq_port;
-	unsigned long slot_port;
+	void __iomem *irq_port;
+	void __iomem *ioc_base;
 	unsigned int type;
 	/* parent device... until the IDE core gets one of its own */
 	struct device *dev;
@@ -87,9 +90,8 @@
 static void icside_irqenable_arcin_v5 (struct expansion_card *ec, int irqnr)
 {
 	struct icside_state *state = ec->irq_data;
-	unsigned int base = state->irq_port;
 
-	outb(0, base + ICS_ARCIN_V5_INTROFFSET);
+	writeb(0, state->irq_port + ICS_ARCIN_V5_INTROFFSET);
 }
 
 /* Prototype: icside_irqdisable_arcin_v5 (struct expansion_card *ec, int irqnr)
@@ -98,9 +100,8 @@
 static void icside_irqdisable_arcin_v5 (struct expansion_card *ec, int irqnr)
 {
 	struct icside_state *state = ec->irq_data;
-	unsigned int base = state->irq_port;
 
-	inb(base + ICS_ARCIN_V5_INTROFFSET);
+	readb(state->irq_port + ICS_ARCIN_V5_INTROFFSET);
 }
 
 static const expansioncard_ops_t icside_ops_arcin_v5 = {
@@ -116,18 +117,18 @@
 static void icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr)
 {
 	struct icside_state *state = ec->irq_data;
-	unsigned int base = state->irq_port;
+	void __iomem *base = state->irq_port;
 
 	state->enabled = 1;
 
 	switch (state->channel) {
 	case 0:
-		outb(0, base + ICS_ARCIN_V6_INTROFFSET_1);
-		inb(base + ICS_ARCIN_V6_INTROFFSET_2);
+		writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1);
+		readb(base + ICS_ARCIN_V6_INTROFFSET_2);
 		break;
 	case 1:
-		outb(0, base + ICS_ARCIN_V6_INTROFFSET_2);
-		inb(base + ICS_ARCIN_V6_INTROFFSET_1);
+		writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2);
+		readb(base + ICS_ARCIN_V6_INTROFFSET_1);
 		break;
 	}
 }
@@ -141,8 +142,8 @@
 
 	state->enabled = 0;
 
-	inb (state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
-	inb (state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+	readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+	readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
 }
 
 /* Prototype: icside_irqprobe(struct expansion_card *ec)
@@ -152,8 +153,8 @@
 {
 	struct icside_state *state = ec->irq_data;
 
-	return inb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_1) & 1 ||
-	       inb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_2) & 1;
+	return readb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_1) & 1 ||
+	       readb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_2) & 1;
 }
 
 static const expansioncard_ops_t icside_ops_arcin_v6 = {
@@ -179,23 +180,28 @@
 	if (state->enabled && !mask) {
 		switch (hwif->channel) {
 		case 0:
-			outb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
-			inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+			writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+			readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
 			break;
 		case 1:
-			outb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
-			inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+			writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+			readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
 			break;
 		}
 	} else {
-		inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
-		inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+		readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+		readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
 	}
 
 	local_irq_restore(flags);
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA_ICS
+
+#ifndef CONFIG_IDEDMA_ICS_AUTO
+#warning CONFIG_IDEDMA_ICS_AUTO=n support is obsolete, and will be removed soon.
+#endif
+
 /*
  * SG-DMA support.
  *
@@ -205,44 +211,24 @@
  * here, but we rely on the main IDE driver spotting that both
  * interfaces use the same IRQ, which should guarantee this.
  */
-#define NR_ENTRIES 256
-#define TABLE_SIZE (NR_ENTRIES * 8)
 
 static void icside_build_sglist(ide_drive_t *drive, struct request *rq)
 {
 	ide_hwif_t *hwif = drive->hwif;
 	struct icside_state *state = hwif->hwif_data;
 	struct scatterlist *sg = hwif->sg_table;
-	int nents;
 
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-
-		if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
-			hwif->sg_dma_direction = DMA_TO_DEVICE;
-		else
-			hwif->sg_dma_direction = DMA_FROM_DEVICE;
-
-		memset(sg, 0, sizeof(*sg));
-		sg->page   = virt_to_page(rq->buffer);
-		sg->offset = offset_in_page(rq->buffer);
-		sg->length = rq->nr_sectors * SECTOR_SIZE;
-		nents = 1;
-	} else {
-		nents = blk_rq_map_sg(drive->queue, rq, sg);
-
-		if (rq_data_dir(rq) == READ)
-			hwif->sg_dma_direction = DMA_FROM_DEVICE;
-		else
-			hwif->sg_dma_direction = DMA_TO_DEVICE;
-	}
+	ide_map_sg(drive, rq);
 
-	nents = dma_map_sg(state->dev, sg, nents, hwif->sg_dma_direction);
+	if (rq_data_dir(rq) == READ)
+		hwif->sg_dma_direction = DMA_FROM_DEVICE;
+	else
+		hwif->sg_dma_direction = DMA_TO_DEVICE;
 
-	hwif->sg_nents = nents;
+	hwif->sg_nents = dma_map_sg(state->dev, sg, hwif->sg_nents,
+				    hwif->sg_dma_direction);
 }
 
-
 /*
  * Configure the IOMD to give the appropriate timings for the transfer
  * mode being requested.  We take the advice of the ATA standards, and
@@ -402,14 +388,13 @@
 	return get_dma_residue(hwif->hw.dma) != 0;
 }
 
-static int icside_dma_begin(ide_drive_t *drive)
+static void icside_dma_start(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 
 	/* We can not enable DMA on both channels simultaneously. */
 	BUG_ON(dma_channel_active(hwif->hw.dma));
 	enable_dma(hwif->hw.dma);
-	return 0;
 }
 
 /*
@@ -441,11 +426,16 @@
 	return DRIVER(drive)->error(drive, __FUNCTION__, stat);
 }
 
-static int
-icside_dma_common(ide_drive_t *drive, struct request *rq,
-		  unsigned int dma_mode)
+static int icside_dma_setup(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
+	struct request *rq = hwif->hwgroup->rq;
+	unsigned int dma_mode;
+
+	if (rq_data_dir(rq))
+		dma_mode = DMA_MODE_WRITE;
+	else
+		dma_mode = DMA_MODE_READ;
 
 	/*
 	 * We can not enable DMA on both channels.
@@ -462,7 +452,7 @@
 	/*
 	 * Route the DMA signals to the correct interface.
 	 */
-	outb(hwif->select_data, hwif->config_data);
+	writeb(hwif->select_data, hwif->config_data);
 
 	/*
 	 * Select the correct timing for this drive.
@@ -481,79 +471,10 @@
 	return 0;
 }
 
-static int icside_dma_read(ide_drive_t *drive)
+static void icside_dma_exec_cmd(ide_drive_t *drive, u8 cmd)
 {
-	struct request *rq = HWGROUP(drive)->rq;
-	task_ioreg_t cmd;
-
-	if (icside_dma_common(drive, rq, DMA_MODE_READ))
-		return 1;
-
-	if (drive->media != ide_disk)
-		return 0;
-
-	BUG_ON(HWGROUP(drive)->handler != NULL);
-
-	/*
-	 * FIX ME to use only ACB ide_task_t args Struct
-	 */
-#if 0
-	{
-		ide_task_t *args = rq->special;
-		cmd = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-#else
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-		cmd = args->tfRegister[IDE_COMMAND_OFFSET];
-	} else if (drive->addressing == 1) {
-		cmd = WIN_READDMA_EXT;
-	} else {
-		cmd = WIN_READDMA;
-	}
-#endif
 	/* issue cmd to drive */
 	ide_execute_command(drive, cmd, icside_dmaintr, 2*WAIT_CMD, NULL);
-
-	return icside_dma_begin(drive);
-}
-
-static int icside_dma_write(ide_drive_t *drive)
-{
-	struct request *rq = HWGROUP(drive)->rq;
-	task_ioreg_t cmd;
-
-	if (icside_dma_common(drive, rq, DMA_MODE_WRITE))
-		return 1;
-
-	if (drive->media != ide_disk)
-		return 0;
-
-	BUG_ON(HWGROUP(drive)->handler != NULL);
-
-	/*
-	 * FIX ME to use only ACB ide_task_t args Struct
-	 */
-#if 0
-	{
-		ide_task_t *args = rq->special;
-		cmd = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-#else
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-		cmd = args->tfRegister[IDE_COMMAND_OFFSET];
-	} else if (drive->addressing == 1) {
-		cmd = WIN_WRITEDMA_EXT;
-	} else {
-		cmd = WIN_WRITEDMA;
-	}
-#endif
-
-	/* issue cmd to drive */
-	ide_execute_command(drive, cmd, icside_dmaintr, 2*WAIT_CMD, NULL);
-
-	return icside_dma_begin(drive);
 }
 
 static int icside_dma_test_irq(ide_drive_t *drive)
@@ -561,20 +482,12 @@
 	ide_hwif_t *hwif = HWIF(drive);
 	struct icside_state *state = hwif->hwif_data;
 
-	return inb(state->irq_port +
-		   (hwif->channel ?
+	return readb(state->irq_port +
+		     (hwif->channel ?
 			ICS_ARCIN_V6_INTRSTAT_2 :
 			ICS_ARCIN_V6_INTRSTAT_1)) & 1;
 }
 
-static int icside_dma_verbose(ide_drive_t *drive)
-{
-	printk(", %s (peak %dMB/s)",
-		ide_xfer_verbose(drive->current_speed),
-		2000 / drive->drive_data);
-	return 1;
-}
-
 static int icside_dma_timeout(ide_drive_t *drive)
 {
 	printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name);
@@ -594,7 +507,7 @@
 	return 1;
 }
 
-static int icside_dma_init(ide_hwif_t *hwif)
+static void icside_dma_init(ide_hwif_t *hwif)
 {
 	int autodma = 0;
 
@@ -604,11 +517,6 @@
 
 	printk("    %s: SG-DMA", hwif->name);
 
-	hwif->sg_table = kmalloc(sizeof(struct scatterlist) * NR_ENTRIES,
-				 GFP_KERNEL);
-	if (!hwif->sg_table)
-		goto failed;
-
 	hwif->atapi_dma		= 1;
 	hwif->mwdma_mask	= 7; /* MW0..2 */
 	hwif->swdma_mask	= 7; /* SW0..2 */
@@ -623,12 +531,11 @@
 	hwif->ide_dma_off_quietly = icside_dma_off_quietly;
 	hwif->ide_dma_host_on	= icside_dma_host_on;
 	hwif->ide_dma_on	= icside_dma_on;
-	hwif->ide_dma_read	= icside_dma_read;
-	hwif->ide_dma_write	= icside_dma_write;
-	hwif->ide_dma_begin	= icside_dma_begin;
+	hwif->dma_setup		= icside_dma_setup;
+	hwif->dma_exec_cmd	= icside_dma_exec_cmd;
+	hwif->dma_start		= icside_dma_start;
 	hwif->ide_dma_end	= icside_dma_end;
 	hwif->ide_dma_test_irq	= icside_dma_test_irq;
-	hwif->ide_dma_verbose	= icside_dma_verbose;
 	hwif->ide_dma_timeout	= icside_dma_timeout;
 	hwif->ide_dma_lostirq	= icside_dma_lostirq;
 
@@ -636,24 +543,9 @@
 	hwif->drives[1].autodma = hwif->autodma;
 
 	printk(" capable%s\n", hwif->autodma ? ", auto-enable" : "");
-
-	return 1;
-
-failed:
-	printk(" disabled, unable to allocate DMA table\n");
-	return 0;
-}
-
-static void icside_dma_exit(ide_hwif_t *hwif)
-{
-	if (hwif->sg_table) {
-		kfree(hwif->sg_table);
-		hwif->sg_table = NULL;
-	}
 }
 #else
 #define icside_dma_init(hwif)	(0)
-#define icside_dma_exit(hwif)	do { } while (0)
 #endif
 
 static ide_hwif_t *icside_find_hwif(unsigned long dataport)
@@ -679,24 +571,30 @@
 }
 
 static ide_hwif_t *
-icside_setup(unsigned long base, struct cardinfo *info, struct expansion_card *ec)
+icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec)
 {
-	unsigned long port = base + info->dataoffset;
+	unsigned long port = (unsigned long)base + info->dataoffset;
 	ide_hwif_t *hwif;
 
-	hwif = icside_find_hwif(base);
+	hwif = icside_find_hwif(port);
 	if (hwif) {
 		int i;
 
 		memset(&hwif->hw, 0, sizeof(hw_regs_t));
 
+		/*
+		 * Ensure we're using MMIO
+		 */
+		default_hwif_mmiops(hwif);
+		hwif->mmio = 2;
+
 		for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
 			hwif->hw.io_ports[i] = port;
 			hwif->io_ports[i] = port;
 			port += 1 << info->stepping;
 		}
-		hwif->hw.io_ports[IDE_CONTROL_OFFSET] = base + info->ctrloffset;
-		hwif->io_ports[IDE_CONTROL_OFFSET] = base + info->ctrloffset;
+		hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset;
+		hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset;
 		hwif->hw.irq  = ec->irq;
 		hwif->irq     = ec->irq;
 		hwif->noprobe = 0;
@@ -710,14 +608,17 @@
 static int __init
 icside_register_v5(struct icside_state *state, struct expansion_card *ec)
 {
-	unsigned long slot_port;
 	ide_hwif_t *hwif;
+	void __iomem *base;
 
-	slot_port = ecard_address(ec, ECARD_MEMC, 0);
+	base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
+		       ecard_resource_len(ec, ECARD_RES_MEMC));
+	if (!base)
+		return -ENOMEM;
 
-	state->irq_port = slot_port;
+	state->irq_port = base;
 
-	ec->irqaddr  = (unsigned char *)ioaddr(slot_port + ICS_ARCIN_V5_INTRSTAT);
+	ec->irqaddr  = base + ICS_ARCIN_V5_INTRSTAT;
 	ec->irqmask  = 1;
 	ec->irq_data = state;
 	ec->ops      = &icside_ops_arcin_v5;
@@ -725,61 +626,86 @@
 	/*
 	 * Be on the safe side - disable interrupts
 	 */
-	inb(slot_port + ICS_ARCIN_V5_INTROFFSET);
+	icside_irqdisable_arcin_v5(ec, 0);
 
-	hwif = icside_setup(slot_port, &icside_cardinfo_v5, ec);
+	hwif = icside_setup(base, &icside_cardinfo_v5, ec);
+	if (!hwif) {
+		iounmap(base);
+		return -ENODEV;
+	}
 
 	state->hwif[0] = hwif;
 
-	return hwif ? 0 : -ENODEV;
+	probe_hwif_init(hwif);
+	create_proc_ide_interfaces();
+
+	return 0;
 }
 
 static int __init
 icside_register_v6(struct icside_state *state, struct expansion_card *ec)
 {
-	unsigned long slot_port, port;
 	ide_hwif_t *hwif, *mate;
+	void __iomem *ioc_base, *easi_base;
 	unsigned int sel = 0;
+	int ret;
 
-	slot_port = ecard_address(ec, ECARD_IOC, ECARD_FAST);
-	port      = ecard_address(ec, ECARD_EASI, ECARD_FAST);
+	ioc_base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST),
+			   ecard_resource_len(ec, ECARD_RES_IOCFAST));
+	if (!ioc_base) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
-	if (port == 0)
-		port = slot_port;
-	else
+	easi_base = ioc_base;
+
+	if (ecard_resource_flags(ec, ECARD_RES_EASI)) {
+		easi_base = ioremap(ecard_resource_start(ec, ECARD_RES_EASI),
+				    ecard_resource_len(ec, ECARD_RES_EASI));
+		if (!easi_base) {
+			ret = -ENOMEM;
+			goto unmap_slot;
+		}
+
+		/*
+		 * Enable access to the EASI region.
+		 */
 		sel = 1 << 5;
+	}
+
+	writeb(sel, ioc_base);
 
-	outb(sel, slot_port);
+	ec->irq_data      = state;
+	ec->ops           = &icside_ops_arcin_v6;
+
+	state->irq_port   = easi_base;
+	state->ioc_base   = ioc_base;
 
 	/*
 	 * Be on the safe side - disable interrupts
 	 */
-	inb(port + ICS_ARCIN_V6_INTROFFSET_1);
-	inb(port + ICS_ARCIN_V6_INTROFFSET_2);
+	icside_irqdisable_arcin_v6(ec, 0);
 
 	/*
 	 * Find and register the interfaces.
 	 */
-	hwif = icside_setup(port, &icside_cardinfo_v6_1, ec);
-	mate = icside_setup(port, &icside_cardinfo_v6_2, ec);
+	hwif = icside_setup(easi_base, &icside_cardinfo_v6_1, ec);
+	mate = icside_setup(easi_base, &icside_cardinfo_v6_2, ec);
 
-	if (!hwif || !mate)
-		return -ENODEV;
+	if (!hwif || !mate) {
+		ret = -ENODEV;
+		goto unmap_port;
+	}
 
-	state->irq_port   = port;
-	state->slot_port  = slot_port;
 	state->hwif[0]    = hwif;
 	state->hwif[1]    = mate;
 
-	ec->irq_data      = state;
-	ec->ops           = &icside_ops_arcin_v6;
-
 	hwif->maskproc    = icside_maskproc;
 	hwif->channel     = 0;
 	hwif->hwif_data   = state;
 	hwif->mate        = mate;
 	hwif->serialized  = 1;
-	hwif->config_data = slot_port;
+	hwif->config_data = (unsigned long)ioc_base;
 	hwif->select_data = sel;
 	hwif->hw.dma      = ec->dma;
 
@@ -788,7 +714,7 @@
 	mate->hwif_data   = state;
 	mate->mate        = hwif;
 	mate->serialized  = 1;
-	mate->config_data = slot_port;
+	mate->config_data = (unsigned long)ioc_base;
 	mate->select_data = sel | 1;
 	mate->hw.dma      = ec->dma;
 
@@ -797,7 +723,19 @@
 		icside_dma_init(mate);
 	}
 
+	probe_hwif_init(hwif);
+	probe_hwif_init(mate);
+	create_proc_ide_interfaces();
+
 	return 0;
+
+ unmap_port:
+	if (easi_base != ioc_base)
+		iounmap(easi_base);
+ unmap_slot:
+	iounmap(ioc_base);
+ out:
+	return ret;
 }
 
 static int __devinit
@@ -807,10 +745,14 @@
 	void *idmem;
 	int ret;
 
+	ret = ecard_request_resources(ec);
+	if (ret)
+		goto out;
+
 	state = kmalloc(sizeof(struct icside_state), GFP_KERNEL);
 	if (!state) {
 		ret = -ENOMEM;
-		goto out;
+		goto release;
 	}
 
 	memset(state, 0, sizeof(state));
@@ -833,12 +775,12 @@
 
 	switch (state->type) {
 	case ICS_TYPE_A3IN:
-		printk(KERN_WARNING "icside: A3IN unsupported\n");
+		dev_warn(&ec->dev, "A3IN unsupported\n");
 		ret = -ENODEV;
 		break;
 
 	case ICS_TYPE_A3USER:
-		printk(KERN_WARNING "icside: A3USER unsupported\n");
+		dev_warn(&ec->dev, "A3USER unsupported\n");
 		ret = -ENODEV;
 		break;
 
@@ -851,15 +793,19 @@
 		break;
 
 	default:
-		printk(KERN_WARNING "icside: unknown interface type\n");
+		dev_warn(&ec->dev, "unknown interface type\n");
 		ret = -ENODEV;
 		break;
 	}
 
-	if (ret == 0)
+	if (ret == 0) {
 		ecard_set_drvdata(ec, state);
-	else
-		kfree(state);
+		goto out;
+	}
+
+	kfree(state);
+ release:
+	ecard_release_resources(ec);
  out:
 	return ret;
 }
@@ -873,23 +819,19 @@
 		/* FIXME: tell IDE to stop using the interface */
 
 		/* Disable interrupts */
-		inb(state->slot_port + ICS_ARCIN_V5_INTROFFSET);
+		icside_irqdisable_arcin_v5(ec, 0);
 		break;
 
 	case ICS_TYPE_V6:
 		/* FIXME: tell IDE to stop using the interface */
-		icside_dma_exit(state->hwif[1]);
-		icside_dma_exit(state->hwif[0]);
-
 		if (ec->dma != NO_DMA)
 			free_dma(ec->dma);
 
 		/* Disable interrupts */
-		inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
-		inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+		icside_irqdisable_arcin_v6(ec, 0);
 
 		/* Reset the ROM pointer/EASI selection */
-		outb(0, state->slot_port);
+		writeb(0, state->ioc_base);
 		break;
 	}
 
@@ -897,28 +839,36 @@
 	ec->ops = NULL;
 	ec->irq_data = NULL;
 
+	if (state->ioc_base)
+		iounmap(state->ioc_base);
+	if (state->ioc_base != state->irq_port)
+		iounmap(state->irq_port);
+
 	kfree(state);
+	ecard_release_resources(ec);
 }
 
 static void icside_shutdown(struct expansion_card *ec)
 {
 	struct icside_state *state = ecard_get_drvdata(ec);
+	unsigned long flags;
 
-	switch (state->type) {
-	case ICS_TYPE_V5:
-		/* Disable interrupts */
-		inb(state->slot_port + ICS_ARCIN_V5_INTROFFSET);
-		break;
-
-	case ICS_TYPE_V6:
-		/* Disable interrupts */
-		inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
-		inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+	/*
+	 * Disable interrupts from this card.  We need to do
+	 * this before disabling EASI since we may be accessing
+	 * this register via that region.
+	 */
+	local_irq_save(flags);
+	ec->ops->irqdisable(ec, 0);
+	local_irq_restore(flags);
 
-		/* Reset the ROM pointer/EASI selection */
-		outb(0, state->slot_port);
-		break;
-	}
+	/*
+	 * Reset the ROM pointer so that we can read the ROM
+	 * after a soft reboot.  This also disables access to
+	 * the IDE taskfile via the EASI region.
+	 */
+	if (state->ioc_base)
+		writeb(0, state->ioc_base);
 }
 
 static const struct ecard_id icside_ids[] = {
diff -Nru a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c
--- a/drivers/ide/arm/rapide.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/ide/arm/rapide.c	2004-12-24 13:37:18 -08:00
@@ -13,32 +13,91 @@
 
 #include <asm/ecard.h>
 
-static int __devinit
-rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
+/*
+ * Something like this really should be in generic code, but isn't.
+ */
+static ide_hwif_t *
+rapide_locate_hwif(void __iomem *base, void *ctrl, unsigned int sz, int irq)
 {
-	unsigned long port = ecard_address (ec, ECARD_MEMC, 0);
-	hw_regs_t hw;
-	int i, ret;
+	unsigned long port = (unsigned long)base;
+	ide_hwif_t *hwif;
+	int index, i;
 
-	memset(&hw, 0, sizeof(hw));
+	for (index = 0; index < MAX_HWIFS; ++index) {
+		hwif = ide_hwifs + index;
+		if (hwif->io_ports[IDE_DATA_OFFSET] == port)
+			goto found;
+	}
+
+	for (index = 0; index < MAX_HWIFS; ++index) {
+		hwif = ide_hwifs + index;
+		if (hwif->io_ports[IDE_DATA_OFFSET] == 0)
+			goto found;
+	}
 
+	return NULL;
+
+ found:
 	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-		hw.io_ports[i] = port;
-		port += 1 << 4;
+		hwif->hw.io_ports[i] = port;
+		hwif->io_ports[i] = port;
+		port += sz;
 	}
-	hw.io_ports[IDE_CONTROL_OFFSET] = port + 0x206;
-	hw.irq = ec->irq;
+	hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl;
+	hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl;
+	hwif->hw.irq = hwif->irq = irq;
+	hwif->mmio = 2;
+	default_hwif_mmiops(hwif);
+
+	return hwif;
+}
 
-	ret = ide_register_hw(&hw, NULL);
+static int __devinit
+rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
+{
+	ide_hwif_t *hwif;
+	void __iomem *base;
+	int ret;
 
+	ret = ecard_request_resources(ec);
 	if (ret)
-		ecard_release(ec);
+		goto out;
+
+	base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
+		       ecard_resource_len(ec, ECARD_RES_MEMC));
+	if (!base) {
+		ret = -ENOMEM;
+		goto release;
+	}
+
+	hwif = rapide_locate_hwif(base, base + 0x818, 1 << 6, ec->irq);
+	if (hwif) {
+		hwif->hwif_data = base;
+		hwif->gendev.parent = &ec->dev;
+		hwif->noprobe = 0;
+		probe_hwif_init(hwif);
+		create_proc_ide_interfaces();
+		ecard_set_drvdata(ec, hwif);
+		goto out;
+	}
+
+	iounmap(base);
+ release:
+	ecard_release_resources(ec);
+ out:
 	return ret;
 }
 
 static void __devexit rapide_remove(struct expansion_card *ec)
 {
-	/* need to do more */
+	ide_hwif_t *hwif = ecard_get_drvdata(ec);
+
+	ecard_set_drvdata(ec, NULL);
+
+	/* there must be a better way */
+	ide_unregister(hwif - ide_hwifs);
+	iounmap(hwif->hwif_data);
+	ecard_release_resources(ec);
 }
 
 static struct ecard_id rapide_ids[] = {
diff -Nru a/drivers/ide/cris/Makefile b/drivers/ide/cris/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/ide/cris/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,3 @@
+EXTRA_CFLAGS				+= -Idrivers/ide
+
+obj-$(CONFIG_ETRAX_ARCH_V10)		+= ide-v10.o
diff -Nru a/drivers/ide/cris/ide-v10.c b/drivers/ide/cris/ide-v10.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/ide/cris/ide-v10.c	2004-12-24 13:36:49 -08:00
@@ -0,0 +1,859 @@
+/* $Id: ide.c,v 1.4 2004/10/12 07:55:48 starvik Exp $
+ *
+ * Etrax specific IDE functions, like init and PIO-mode setting etc.
+ * Almost the entire ide.c is used for the rest of the Etrax ATA driver.
+ * Copyright (c) 2000-2004 Axis Communications AB
+ *
+ * Authors:    Bjorn Wesen        (initial version)
+ *             Mikael Starvik     (pio setup stuff, Linux 2.6 port)
+ */
+
+/* Regarding DMA:
+ *
+ * There are two forms of DMA - "DMA handshaking" between the interface and the drive,
+ * and DMA between the memory and the interface. We can ALWAYS use the latter, since it's
+ * something built-in in the Etrax. However only some drives support the DMA-mode handshaking
+ * on the ATA-bus. The normal PC driver and Triton interface disables memory-if DMA when the
+ * device can't do DMA handshaking for some stupid reason. We don't need to do that.
+ */
+
+#undef REALLY_SLOW_IO           /* most systems can safely undef this */
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/timer.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <linux/scatterlist.h>
+
+#include <asm/io.h>
+#include <asm/arch/svinto.h>
+#include <asm/dma.h>
+
+/* number of Etrax DMA descriptors */
+#define MAX_DMA_DESCRS 64
+
+/* number of times to retry busy-flags when reading/writing IDE-registers
+ * this can't be too high because a hung harddisk might cause the watchdog
+ * to trigger (sometimes INB and OUTB are called with irq's disabled)
+ */
+
+#define IDE_REGISTER_TIMEOUT 300
+
+static int e100_read_command = 0;
+
+#define LOWDB(x)
+#define D(x)
+
+static int e100_ide_build_dmatable (ide_drive_t *drive);
+static ide_startstop_t etrax_dma_intr (ide_drive_t *drive);
+
+void
+etrax100_ide_outw(unsigned short data, unsigned long reg) {
+	int timeleft;
+	LOWDB(printk("ow: data 0x%x, reg 0x%x\n", data, reg));
+
+	/* note the lack of handling any timeouts. we stop waiting, but we don't
+	 * really notify anybody.
+	 */
+
+	timeleft = IDE_REGISTER_TIMEOUT;
+	/* wait for busy flag */
+	while(timeleft && (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)))
+		timeleft--;
+
+	/*
+	 * Fall through at a timeout, so the ongoing command will be
+	 * aborted by the write below, which is expected to be a dummy
+	 * command to the command register.  This happens when a faulty
+	 * drive times out on a command.  See comment on timeout in
+	 * INB.
+	 */
+	if(!timeleft)
+		printk("ATA timeout reg 0x%lx := 0x%x\n", reg, data);
+
+	*R_ATA_CTRL_DATA = reg | data; /* write data to the drive's register */
+
+	timeleft = IDE_REGISTER_TIMEOUT;
+	/* wait for transmitter ready */
+	while(timeleft && !(*R_ATA_STATUS_DATA &
+			    IO_MASK(R_ATA_STATUS_DATA, tr_rdy)))
+		timeleft--;
+}
+
+void
+etrax100_ide_outb(unsigned char data, unsigned long reg)
+{
+	etrax100_ide_outw(data, reg);
+}
+
+void
+etrax100_ide_outbsync(ide_drive_t *drive, u8 addr, unsigned long port)
+{
+	etrax100_ide_outw(addr, port);
+}
+
+unsigned short
+etrax100_ide_inw(unsigned long reg) {
+	int status;
+	int timeleft;
+
+	timeleft = IDE_REGISTER_TIMEOUT;
+	/* wait for busy flag */
+	while(timeleft && (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)))
+		timeleft--;
+
+	if(!timeleft) {
+		/*
+		 * If we're asked to read the status register, like for
+		 * example when a command does not complete for an
+		 * extended time, but the ATA interface is stuck in a
+		 * busy state at the *ETRAX* ATA interface level (as has
+		 * happened repeatedly with at least one bad disk), then
+		 * the best thing to do is to pretend that we read
+		 * "busy" in the status register, so the IDE driver will
+		 * time-out, abort the ongoing command and perform a
+		 * reset sequence.  Note that the subsequent OUT_BYTE
+		 * call will also timeout on busy, but as long as the
+		 * write is still performed, everything will be fine.
+		 */
+		if ((reg & IO_MASK (R_ATA_CTRL_DATA, addr))
+		    == IO_FIELD (R_ATA_CTRL_DATA, addr, IDE_STATUS_OFFSET))
+			return BUSY_STAT;
+		else
+			/* For other rare cases we assume 0 is good enough.  */
+			return 0;
+	}
+
+	*R_ATA_CTRL_DATA = reg | IO_STATE(R_ATA_CTRL_DATA, rw, read); /* read data */
+
+	timeleft = IDE_REGISTER_TIMEOUT;
+	/* wait for available */
+	while(timeleft && !((status = *R_ATA_STATUS_DATA) &
+			    IO_MASK(R_ATA_STATUS_DATA, dav)))
+		timeleft--;
+
+	if(!timeleft)
+		return 0;
+
+	LOWDB(printk("inb: 0x%x from reg 0x%x\n", status & 0xff, reg));
+
+        return (unsigned short)status;
+}
+
+unsigned char
+etrax100_ide_inb(unsigned long reg)
+{
+	return (unsigned char)etrax100_ide_inw(reg);
+}
+
+/* PIO timing (in R_ATA_CONFIG)
+ *
+ *                        _____________________________
+ * ADDRESS :     ________/
+ *
+ *                            _______________
+ * DIOR    :     ____________/               \__________
+ *
+ *                               _______________
+ * DATA    :     XXXXXXXXXXXXXXXX_______________XXXXXXXX
+ *
+ *
+ * DIOR is unbuffered while address and data is buffered.
+ * This creates two problems:
+ * 1. The DIOR pulse is to early (because it is unbuffered)
+ * 2. The rise time of DIOR is long
+ *
+ * There are at least three different plausible solutions
+ * 1. Use a pad capable of larger currents in Etrax
+ * 2. Use an external buffer
+ * 3. Make the strobe pulse longer
+ *
+ * Some of the strobe timings below are modified to compensate
+ * for this. This implies a slight performance decrease.
+ *
+ * THIS SHOULD NEVER BE CHANGED!
+ *
+ * TODO: Is this true for the latest LX boards still ?
+ */
+
+#define ATA_DMA2_STROBE  4
+#define ATA_DMA2_HOLD    0
+#define ATA_DMA1_STROBE  4
+#define ATA_DMA1_HOLD    1
+#define ATA_DMA0_STROBE 12
+#define ATA_DMA0_HOLD    9
+#define ATA_PIO4_SETUP   1
+#define ATA_PIO4_STROBE  5
+#define ATA_PIO4_HOLD    0
+#define ATA_PIO3_SETUP   1
+#define ATA_PIO3_STROBE  5
+#define ATA_PIO3_HOLD    1
+#define ATA_PIO2_SETUP   1
+#define ATA_PIO2_STROBE  6
+#define ATA_PIO2_HOLD    2
+#define ATA_PIO1_SETUP   2
+#define ATA_PIO1_STROBE 11
+#define ATA_PIO1_HOLD    4
+#define ATA_PIO0_SETUP   4
+#define ATA_PIO0_STROBE 19
+#define ATA_PIO0_HOLD    4
+
+static int e100_dma_check (ide_drive_t *drive);
+static void e100_dma_start(ide_drive_t *drive);
+static int e100_dma_end (ide_drive_t *drive);
+static void e100_ide_input_data (ide_drive_t *drive, void *, unsigned int);
+static void e100_ide_output_data (ide_drive_t *drive, void *, unsigned int);
+static void e100_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int);
+static void e100_atapi_output_bytes(ide_drive_t *drive, void *, unsigned int);
+static int e100_dma_off (ide_drive_t *drive);
+
+
+/*
+ * good_dma_drives() lists the model names (from "hdparm -i")
+ * of drives which do not support mword2 DMA but which are
+ * known to work fine with this interface under Linux.
+ */
+
+const char *good_dma_drives[] = {"Micropolis 2112A",
+				 "CONNER CTMA 4000",
+				 "CONNER CTT8000-A",
+				 NULL};
+
+static void tune_e100_ide(ide_drive_t *drive, byte pio)
+{
+	pio = 4;
+	/* pio = ide_get_best_pio_mode(drive, pio, 4, NULL); */
+
+	/* set pio mode! */
+
+	switch(pio) {
+		case 0:
+			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO0_SETUP ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO0_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO0_HOLD ) );
+			break;
+		case 1:
+			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO1_SETUP ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO1_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO1_HOLD ) );
+			break;
+		case 2:
+			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO2_SETUP ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO2_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO2_HOLD ) );
+			break;
+		case 3:
+			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO3_SETUP ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO3_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO3_HOLD ) );
+			break;
+		case 4:
+			*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO4_SETUP ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO4_STROBE ) |
+					  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO4_HOLD ) );
+			break;
+	}
+}
+
+static int e100_dma_setup(ide_drive_t *drive)
+{
+	struct request *rq = drive->hwif->hwgroup->rq;
+
+	if (rq_data_dir(rq)) {
+		e100_read_command = 0;
+
+		RESET_DMA(ATA_TX_DMA_NBR); /* sometimes the DMA channel get stuck so we need to do this */
+		WAIT_DMA(ATA_TX_DMA_NBR);
+	} else {
+		e100_read_command = 1;
+
+		RESET_DMA(ATA_RX_DMA_NBR); /* sometimes the DMA channel get stuck so we need to do this */
+		WAIT_DMA(ATA_RX_DMA_NBR);
+	}
+
+	/* set up the Etrax DMA descriptors */
+	if (e100_ide_build_dmatable(drive)) {
+		ide_map_sg(drive, rq);
+		return 1;
+	}
+
+	return 0;
+}
+
+static void e100_dma_exec_cmd(ide_drive_t *drive, u8 command)
+{
+	/* set the irq handler which will finish the request when DMA is done */
+	ide_set_handler(drive, &etrax_dma_intr, WAIT_CMD, NULL);
+
+	/* issue cmd to drive */
+	etrax100_ide_outb(command, IDE_COMMAND_REG);
+}
+
+void __init
+init_e100_ide (void)
+{
+	volatile unsigned int dummy;
+	int h;
+
+	printk("ide: ETRAX 100LX built-in ATA DMA controller\n");
+
+	/* first fill in some stuff in the ide_hwifs fields */
+
+	for(h = 0; h < MAX_HWIFS; h++) {
+		ide_hwif_t *hwif = &ide_hwifs[h];
+		hwif->mmio = 2;
+		hwif->chipset = ide_etrax100;
+		hwif->tuneproc = &tune_e100_ide;
+                hwif->ata_input_data = &e100_ide_input_data;
+                hwif->ata_output_data = &e100_ide_output_data;
+                hwif->atapi_input_bytes = &e100_atapi_input_bytes;
+                hwif->atapi_output_bytes = &e100_atapi_output_bytes;
+                hwif->ide_dma_check = &e100_dma_check;
+                hwif->ide_dma_end = &e100_dma_end;
+		hwif->dma_setup = &e100_dma_setup;
+		hwif->dma_exec_cmd = &e100_dma_exec_cmd;
+		hwif->dma_start = &e100_dma_start;
+		hwif->OUTB = &etrax100_ide_outb;
+		hwif->OUTW = &etrax100_ide_outw;
+		hwif->OUTBSYNC = &etrax100_ide_outbsync;
+		hwif->INB = &etrax100_ide_inb;
+		hwif->INW = &etrax100_ide_inw;
+		hwif->ide_dma_off_quietly = &e100_dma_off;
+	}
+
+	/* actually reset and configure the etrax100 ide/ata interface */
+
+	*R_ATA_CTRL_DATA = 0;
+	*R_ATA_TRANSFER_CNT = 0;
+	*R_ATA_CONFIG = 0;
+
+	genconfig_shadow = (genconfig_shadow &
+			    ~IO_MASK(R_GEN_CONFIG, dma2) &
+			    ~IO_MASK(R_GEN_CONFIG, dma3) &
+			    ~IO_MASK(R_GEN_CONFIG, ata)) |
+		( IO_STATE( R_GEN_CONFIG, dma3, ata    ) |
+		  IO_STATE( R_GEN_CONFIG, dma2, ata    ) |
+		  IO_STATE( R_GEN_CONFIG, ata,  select ) );
+
+	*R_GEN_CONFIG = genconfig_shadow;
+
+        /* pull the chosen /reset-line low */
+
+#ifdef CONFIG_ETRAX_IDE_G27_RESET
+        REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 27, 0);
+#endif
+#ifdef CONFIG_ETRAX_IDE_CSE1_16_RESET
+        REG_SHADOW_SET(port_cse1_addr, port_cse1_shadow, 16, 0);
+#endif
+#ifdef CONFIG_ETRAX_IDE_CSP0_8_RESET
+        REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, 8, 0);
+#endif
+#ifdef CONFIG_ETRAX_IDE_PB7_RESET
+	port_pb_dir_shadow = port_pb_dir_shadow |
+		IO_STATE(R_PORT_PB_DIR, dir7, output);
+	*R_PORT_PB_DIR = port_pb_dir_shadow;
+	REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 7, 1);
+#endif
+
+	/* wait some */
+
+	udelay(25);
+
+	/* de-assert bus-reset */
+
+#ifdef CONFIG_ETRAX_IDE_CSE1_16_RESET
+	REG_SHADOW_SET(port_cse1_addr, port_cse1_shadow, 16, 1);
+#endif
+#ifdef CONFIG_ETRAX_IDE_CSP0_8_RESET
+	REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, 8, 1);
+#endif
+#ifdef CONFIG_ETRAX_IDE_G27_RESET
+	REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 27, 1);
+#endif
+
+	/* make a dummy read to set the ata controller in a proper state */
+	dummy = *R_ATA_STATUS_DATA;
+
+	*R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable,     1 ) |
+			  IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
+			  IO_FIELD( R_ATA_CONFIG, dma_hold,   ATA_DMA2_HOLD ) |
+			  IO_FIELD( R_ATA_CONFIG, pio_setup,  ATA_PIO4_SETUP ) |
+			  IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO4_STROBE ) |
+			  IO_FIELD( R_ATA_CONFIG, pio_hold,   ATA_PIO4_HOLD ) );
+
+	*R_ATA_CTRL_DATA = ( IO_STATE( R_ATA_CTRL_DATA, rw,   read) |
+			     IO_FIELD( R_ATA_CTRL_DATA, addr, 1   ) );
+
+	while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)); /* wait for busy flag*/
+
+	*R_IRQ_MASK0_SET = ( IO_STATE( R_IRQ_MASK0_SET, ata_irq0, set ) |
+			     IO_STATE( R_IRQ_MASK0_SET, ata_irq1, set ) |
+			     IO_STATE( R_IRQ_MASK0_SET, ata_irq2, set ) |
+			     IO_STATE( R_IRQ_MASK0_SET, ata_irq3, set ) );
+
+	printk("ide: waiting %d seconds for drives to regain consciousness\n",
+	       CONFIG_ETRAX_IDE_DELAY);
+
+	h = jiffies + (CONFIG_ETRAX_IDE_DELAY * HZ);
+	while(time_before(jiffies, h)) /* nothing */ ;
+
+	/* reset the dma channels we will use */
+
+	RESET_DMA(ATA_TX_DMA_NBR);
+	RESET_DMA(ATA_RX_DMA_NBR);
+	WAIT_DMA(ATA_TX_DMA_NBR);
+	WAIT_DMA(ATA_RX_DMA_NBR);
+
+}
+
+static int e100_dma_off (ide_drive_t *drive)
+{
+	return 0;
+}
+
+static etrax_dma_descr mydescr;
+
+/*
+ * The following routines are mainly used by the ATAPI drivers.
+ *
+ * These routines will round up any request for an odd number of bytes,
+ * so if an odd bytecount is specified, be sure that there's at least one
+ * extra byte allocated for the buffer.
+ */
+static void
+e100_atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
+{
+	unsigned long data_reg = IDE_DATA_REG;
+
+	D(printk("atapi_input_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
+		 data_reg, buffer, bytecount));
+
+	if(bytecount & 1) {
+		printk("warning, odd bytecount in cdrom_in_bytes = %d.\n", bytecount);
+		bytecount++; /* to round off */
+	}
+
+	/* make sure the DMA channel is available */
+	RESET_DMA(ATA_RX_DMA_NBR);
+	WAIT_DMA(ATA_RX_DMA_NBR);
+
+	/* setup DMA descriptor */
+
+	mydescr.sw_len = bytecount;
+	mydescr.ctrl   = d_eol;
+	mydescr.buf    = virt_to_phys(buffer);
+
+	/* start the dma channel */
+
+	*R_DMA_CH3_FIRST = virt_to_phys(&mydescr);
+	*R_DMA_CH3_CMD   = IO_STATE(R_DMA_CH3_CMD, cmd, start);
+
+	/* initiate a multi word dma read using PIO handshaking */
+
+	*R_ATA_TRANSFER_CNT = IO_FIELD(R_ATA_TRANSFER_CNT, count, bytecount >> 1);
+
+	*R_ATA_CTRL_DATA = data_reg |
+		IO_STATE(R_ATA_CTRL_DATA, rw,       read) |
+		IO_STATE(R_ATA_CTRL_DATA, src_dst,  dma) |
+		IO_STATE(R_ATA_CTRL_DATA, handsh,   pio) |
+		IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
+		IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
+
+	/* wait for completion */
+
+	LED_DISK_READ(1);
+	WAIT_DMA(ATA_RX_DMA_NBR);
+	LED_DISK_READ(0);
+
+#if 0
+        /* old polled transfer code
+	 * this should be moved into a new function that can do polled
+	 * transfers if DMA is not available
+	 */
+
+        /* initiate a multi word read */
+
+        *R_ATA_TRANSFER_CNT = wcount << 1;
+
+        *R_ATA_CTRL_DATA = data_reg |
+                IO_STATE(R_ATA_CTRL_DATA, rw,       read) |
+                IO_STATE(R_ATA_CTRL_DATA, src_dst,  register) |
+                IO_STATE(R_ATA_CTRL_DATA, handsh,   pio) |
+                IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
+                IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
+
+        /* svinto has a latency until the busy bit actually is set */
+
+        nop(); nop();
+        nop(); nop();
+        nop(); nop();
+        nop(); nop();
+        nop(); nop();
+
+        /* unit should be busy during multi transfer */
+        while((status = *R_ATA_STATUS_DATA) & IO_MASK(R_ATA_STATUS_DATA, busy)) {
+                while(!(status & IO_MASK(R_ATA_STATUS_DATA, dav)))
+                        status = *R_ATA_STATUS_DATA;
+                *ptr++ = (unsigned short)(status & 0xffff);
+        }
+#endif
+}
+
+static void
+e100_atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
+{
+	unsigned long data_reg = IDE_DATA_REG;
+
+	D(printk("atapi_output_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
+		 data_reg, buffer, bytecount));
+
+	if(bytecount & 1) {
+		printk("odd bytecount %d in atapi_out_bytes!\n", bytecount);
+		bytecount++;
+	}
+
+	/* make sure the DMA channel is available */
+	RESET_DMA(ATA_TX_DMA_NBR);
+	WAIT_DMA(ATA_TX_DMA_NBR);
+
+	/* setup DMA descriptor */
+
+	mydescr.sw_len = bytecount;
+	mydescr.ctrl   = d_eol;
+	mydescr.buf    = virt_to_phys(buffer);
+
+	/* start the dma channel */
+
+	*R_DMA_CH2_FIRST = virt_to_phys(&mydescr);
+	*R_DMA_CH2_CMD   = IO_STATE(R_DMA_CH2_CMD, cmd, start);
+
+	/* initiate a multi word dma write using PIO handshaking */
+
+	*R_ATA_TRANSFER_CNT = IO_FIELD(R_ATA_TRANSFER_CNT, count, bytecount >> 1);
+
+	*R_ATA_CTRL_DATA = data_reg |
+		IO_STATE(R_ATA_CTRL_DATA, rw,       write) |
+		IO_STATE(R_ATA_CTRL_DATA, src_dst,  dma) |
+		IO_STATE(R_ATA_CTRL_DATA, handsh,   pio) |
+		IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
+		IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
+
+	/* wait for completion */
+
+	LED_DISK_WRITE(1);
+	WAIT_DMA(ATA_TX_DMA_NBR);
+	LED_DISK_WRITE(0);
+
+#if 0
+        /* old polled write code - see comment in input_bytes */
+
+	/* wait for busy flag */
+        while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy));
+
+        /* initiate a multi word write */
+
+        *R_ATA_TRANSFER_CNT = bytecount >> 1;
+
+        ctrl = data_reg |
+                IO_STATE(R_ATA_CTRL_DATA, rw,       write) |
+                IO_STATE(R_ATA_CTRL_DATA, src_dst,  register) |
+                IO_STATE(R_ATA_CTRL_DATA, handsh,   pio) |
+                IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
+                IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
+
+        LED_DISK_WRITE(1);
+
+        /* Etrax will set busy = 1 until the multi pio transfer has finished
+         * and tr_rdy = 1 after each successful word transfer.
+         * When the last byte has been transferred Etrax will first set tr_tdy = 1
+         * and then busy = 0 (not in the same cycle). If we read busy before it
+         * has been set to 0 we will think that we should transfer more bytes
+         * and then tr_rdy would be 0 forever. This is solved by checking busy
+         * in the inner loop.
+         */
+
+        do {
+                *R_ATA_CTRL_DATA = ctrl | *ptr++;
+                while(!(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, tr_rdy)) &&
+                      (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)));
+        } while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy));
+
+        LED_DISK_WRITE(0);
+#endif
+
+}
+
+/*
+ * This is used for most PIO data transfers *from* the IDE interface
+ */
+static void
+e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+{
+	e100_atapi_input_bytes(drive, buffer, wcount << 2);
+}
+
+/*
+ * This is used for most PIO data transfers *to* the IDE interface
+ */
+static void
+e100_ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+{
+	e100_atapi_output_bytes(drive, buffer, wcount << 2);
+}
+
+/* we only have one DMA channel on the chip for ATA, so we can keep these statically */
+static etrax_dma_descr ata_descrs[MAX_DMA_DESCRS];
+static unsigned int ata_tot_size;
+
+/*
+ * e100_ide_build_dmatable() prepares a dma request.
+ * Returns 0 if all went okay, returns 1 otherwise.
+ */
+static int e100_ide_build_dmatable (ide_drive_t *drive)
+{
+	ide_hwif_t *hwif = HWIF(drive);
+	struct scatterlist* sg;
+	struct request *rq  = HWGROUP(drive)->rq;
+	unsigned long size, addr;
+	unsigned int count = 0;
+	int i = 0;
+
+	sg = hwif->sg_table;
+
+	ata_tot_size = 0;
+
+	ide_map_sg(drive, rq);
+
+	i = hwif->sg_nents;
+
+	while(i) {
+		/*
+		 * Determine addr and size of next buffer area.  We assume that
+		 * individual virtual buffers are always composed linearly in
+		 * physical memory.  For example, we assume that any 8kB buffer
+		 * is always composed of two adjacent physical 4kB pages rather
+		 * than two possibly non-adjacent physical 4kB pages.
+		 */
+		/* group sequential buffers into one large buffer */
+		addr = page_to_phys(sg->page) + sg->offset;
+		size = sg_dma_len(sg);
+		while (sg++, --i) {
+			if ((addr + size) != page_to_phys(sg->page) + sg->offset)
+				break;
+			size += sg_dma_len(sg);
+		}
+
+		/* did we run out of descriptors? */
+
+		if(count >= MAX_DMA_DESCRS) {
+			printk("%s: too few DMA descriptors\n", drive->name);
+			return 1;
+		}
+
+		/* however, this case is more difficult - R_ATA_TRANSFER_CNT cannot be more
+		   than 65536 words per transfer, so in that case we need to either
+		   1) use a DMA interrupt to re-trigger R_ATA_TRANSFER_CNT and continue with
+		      the descriptors, or
+		   2) simply do the request here, and get dma_intr to only ide_end_request on
+		      those blocks that were actually set-up for transfer.
+		*/
+
+		if(ata_tot_size + size > 131072) {
+			printk("too large total ATA DMA request, %d + %d!\n", ata_tot_size, (int)size);
+			return 1;
+		}
+
+		/* If size > 65536 it has to be splitted into new descriptors. Since we don't handle
+                   size > 131072 only one split is necessary */
+
+		if(size > 65536) {
+ 		        /* ok we want to do IO at addr, size bytes. set up a new descriptor entry */
+                        ata_descrs[count].sw_len = 0;  /* 0 means 65536, this is a 16-bit field */
+                        ata_descrs[count].ctrl = 0;
+                        ata_descrs[count].buf = addr;
+                        ata_descrs[count].next = virt_to_phys(&ata_descrs[count + 1]);
+                        count++;
+                        ata_tot_size += 65536;
+                        /* size and addr should refere to not handled data */
+                        size -= 65536;
+                        addr += 65536;
+                }
+		/* ok we want to do IO at addr, size bytes. set up a new descriptor entry */
+                if(size == 65536) {
+			ata_descrs[count].sw_len = 0;  /* 0 means 65536, this is a 16-bit field */
+                } else {
+			ata_descrs[count].sw_len = size;
+                }
+		ata_descrs[count].ctrl = 0;
+		ata_descrs[count].buf = addr;
+		ata_descrs[count].next = virt_to_phys(&ata_descrs[count + 1]);
+		count++;
+		ata_tot_size += size;
+	}
+
+	if (count) {
+		/* set the end-of-list flag on the last descriptor */
+		ata_descrs[count - 1].ctrl |= d_eol;
+		/* return and say all is ok */
+		return 0;
+	}
+
+	printk("%s: empty DMA table?\n", drive->name);
+	return 1;	/* let the PIO routines handle this weirdness */
+}
+
+static int config_drive_for_dma (ide_drive_t *drive)
+{
+        const char **list;
+        struct hd_driveid *id = drive->id;
+
+        if (id && (id->capability & 1)) {
+                /* Enable DMA on any drive that supports mword2 DMA */
+                if ((id->field_valid & 2) && (id->dma_mword & 0x404) == 0x404) {
+                        drive->using_dma = 1;
+                        return 0;               /* DMA enabled */
+                }
+
+                /* Consult the list of known "good" drives */
+                list = good_dma_drives;
+                while (*list) {
+                        if (!strcmp(*list++,id->model)) {
+                                drive->using_dma = 1;
+                                return 0;       /* DMA enabled */
+                        }
+                }
+        }
+        return 1;       /* DMA not enabled */
+}
+
+/*
+ * etrax_dma_intr() is the handler for disk read/write DMA interrupts
+ */
+static ide_startstop_t etrax_dma_intr (ide_drive_t *drive)
+{
+	int i, dma_stat;
+	byte stat;
+
+	LED_DISK_READ(0);
+	LED_DISK_WRITE(0);
+
+	dma_stat = HWIF(drive)->ide_dma_end(drive);
+	stat = HWIF(drive)->INB(IDE_STATUS_REG);		/* get drive status */
+	if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
+		if (!dma_stat) {
+			struct request *rq;
+			rq = HWGROUP(drive)->rq;
+			for (i = rq->nr_sectors; i > 0;) {
+				i -= rq->current_nr_sectors;
+				DRIVER(drive)->end_request(drive, 1, rq->nr_sectors);
+			}
+			return ide_stopped;
+		}
+		printk("%s: bad DMA status\n", drive->name);
+	}
+	return DRIVER(drive)->error(drive, "dma_intr", stat);
+}
+
+/*
+ * Functions below initiates/aborts DMA read/write operations on a drive.
+ *
+ * The caller is assumed to have selected the drive and programmed the drive's
+ * sector address using CHS or LBA.  All that remains is to prepare for DMA
+ * and then issue the actual read/write DMA/PIO command to the drive.
+ *
+ * Returns 0 if all went well.
+ * Returns 1 if DMA read/write could not be started, in which case
+ * the caller should revert to PIO for the current request.
+ */
+
+static int e100_dma_check(ide_drive_t *drive)
+{
+	return config_drive_for_dma (drive);
+}
+
+static int e100_dma_end(ide_drive_t *drive)
+{
+	/* TODO: check if something went wrong with the DMA */
+	return 0;
+}
+
+static void e100_dma_start(ide_drive_t *drive)
+{
+	if (e100_read_command) {
+		/* begin DMA */
+
+		/* need to do this before RX DMA due to a chip bug
+		 * it is enough to just flush the part of the cache that
+		 * corresponds to the buffers we start, but since HD transfers
+		 * usually are more than 8 kB, it is easier to optimize for the
+		 * normal case and just flush the entire cache. its the only
+		 * way to be sure! (OB movie quote)
+		 */
+		flush_etrax_cache();
+		*R_DMA_CH3_FIRST = virt_to_phys(ata_descrs);
+		*R_DMA_CH3_CMD   = IO_STATE(R_DMA_CH3_CMD, cmd, start);
+
+		/* initiate a multi word dma read using DMA handshaking */
+
+		*R_ATA_TRANSFER_CNT =
+			IO_FIELD(R_ATA_TRANSFER_CNT, count, ata_tot_size >> 1);
+
+		*R_ATA_CTRL_DATA =
+			IO_FIELD(R_ATA_CTRL_DATA, data, IDE_DATA_REG) |
+			IO_STATE(R_ATA_CTRL_DATA, rw,       read) |
+			IO_STATE(R_ATA_CTRL_DATA, src_dst,  dma)  |
+			IO_STATE(R_ATA_CTRL_DATA, handsh,   dma)  |
+			IO_STATE(R_ATA_CTRL_DATA, multi,    on)   |
+			IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
+
+		LED_DISK_READ(1);
+
+		D(printk("dma read of %d bytes.\n", ata_tot_size));
+
+	} else {
+		/* writing */
+		/* begin DMA */
+
+		*R_DMA_CH2_FIRST = virt_to_phys(ata_descrs);
+		*R_DMA_CH2_CMD   = IO_STATE(R_DMA_CH2_CMD, cmd, start);
+
+		/* initiate a multi word dma write using DMA handshaking */
+
+		*R_ATA_TRANSFER_CNT =
+			IO_FIELD(R_ATA_TRANSFER_CNT, count, ata_tot_size >> 1);
+
+		*R_ATA_CTRL_DATA =
+			IO_FIELD(R_ATA_CTRL_DATA, data,     IDE_DATA_REG) |
+			IO_STATE(R_ATA_CTRL_DATA, rw,       write) |
+			IO_STATE(R_ATA_CTRL_DATA, src_dst,  dma) |
+			IO_STATE(R_ATA_CTRL_DATA, handsh,   dma) |
+			IO_STATE(R_ATA_CTRL_DATA, multi,    on) |
+			IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
+
+		LED_DISK_WRITE(1);
+
+		D(printk("dma write of %d bytes.\n", ata_tot_size));
+	}
+}
diff -Nru a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
--- a/drivers/ide/ide-cd.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/ide/ide-cd.c	2004-12-24 13:36:48 -08:00
@@ -562,7 +562,7 @@
 /*
  * ide_error() takes action based on the error returned by the drive.
  */
-ide_startstop_t ide_cdrom_error (ide_drive_t *drive, const char *msg, byte stat)
+static ide_startstop_t ide_cdrom_error (ide_drive_t *drive, const char *msg, byte stat)
 {
 	struct request *rq;
 	byte err;
@@ -598,7 +598,7 @@
 	return ide_stopped;
 }
 
-ide_startstop_t ide_cdrom_abort (ide_drive_t *drive, const char *msg)
+static ide_startstop_t ide_cdrom_abort (ide_drive_t *drive, const char *msg)
 {
 	struct request *rq;
 
@@ -865,20 +865,14 @@
 {
 	ide_startstop_t startstop;
 	struct cdrom_info *info = drive->driver_data;
+	ide_hwif_t *hwif = drive->hwif;
 
 	/* Wait for the controller to be idle. */
 	if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY))
 		return startstop;
 
-	if (info->dma) {
-		if (info->cmd == READ) {
-			info->dma = !HWIF(drive)->ide_dma_read(drive);
-		} else if (info->cmd == WRITE) {
-			info->dma = !HWIF(drive)->ide_dma_write(drive);
-		} else {
-			printk("ide-cd: DMA set, but not allowed\n");
-		}
-	}
+	if (info->dma)
+		info->dma = !hwif->dma_setup(drive);
 
 	/* Set up the controller registers. */
 	/* FIXME: for Virtual DMA we must check harder */
@@ -896,8 +890,14 @@
 		ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry);
 		return ide_started;
 	} else {
+		unsigned long flags;
+
 		/* packet command */
-		HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG);
+		spin_lock_irqsave(&ide_lock, flags);
+		hwif->OUTBSYNC(drive, WIN_PACKETCMD, IDE_COMMAND_REG);
+		ndelay(400);
+		spin_unlock_irqrestore(&ide_lock, flags);
+
 		return (*handler) (drive);
 	}
 }
@@ -916,6 +916,7 @@
 					  struct request *rq,
 					  ide_handler_t *handler)
 {
+	ide_hwif_t *hwif = drive->hwif;
 	int cmd_len;
 	struct cdrom_info *info = drive->driver_data;
 	ide_startstop_t startstop;
@@ -947,7 +948,7 @@
 
 	/* Start the DMA if need be */
 	if (info->dma)
-		(void) HWIF(drive)->ide_dma_begin(drive);
+		hwif->dma_start(drive);
 
 	return ide_started;
 }
@@ -1932,6 +1933,8 @@
 	info->dma = drive->using_dma ? 1 : 0;
 	info->cmd = WRITE;
 
+	info->devinfo.media_written = 1;
+
 	/* Start sending the write request to the drive. */
 	return cdrom_start_packet_command(drive, 32768, cdrom_start_write_cont);
 }
@@ -1999,7 +2002,7 @@
 			}
 			CDROM_CONFIG_FLAGS(drive)->seeking = 0;
 		}
-		if (IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) {
+		if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) {
 			action = cdrom_start_seek(drive, block);
 		} else {
 			if (rq_data_dir(rq) == READ)
@@ -2356,25 +2359,31 @@
 	/* Read the multisession information. */
 	if (toc->hdr.first_track != CDROM_LEADOUT) {
 		/* Read the multisession information. */
-		stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp,
+		stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp,
 					   sizeof(ms_tmp), sense);
 		if (stat) return stat;
+
+		toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba);
 	} else {
-		ms_tmp.ent.addr.msf.minute = 0;
-		ms_tmp.ent.addr.msf.second = 2;
-		ms_tmp.ent.addr.msf.frame  = 0;
 		ms_tmp.hdr.first_track = ms_tmp.hdr.last_track = CDROM_LEADOUT;
+		toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */
 	}
 
 #if ! STANDARD_ATAPI
-	if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd)
+	if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) {
+		/* Re-read multisession information using MSF format */
+		stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp,
+					   sizeof(ms_tmp), sense);
+		if (stat)
+			return stat;
+
 		msf_from_bcd (&ms_tmp.ent.addr.msf);
+		toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute,
+					  	   ms_tmp.ent.addr.msf.second,
+						   ms_tmp.ent.addr.msf.frame);
+	}
 #endif  /* not STANDARD_ATAPI */
 
-	toc->last_session_lba = msf_to_lba (ms_tmp.ent.addr.msf.minute,
-					    ms_tmp.ent.addr.msf.second,
-					    ms_tmp.ent.addr.msf.frame);
-
 	toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track);
 
 	/* Now try to get the total cdrom capacity. */
@@ -2960,8 +2969,10 @@
 		CDROM_CONFIG_FLAGS(drive)->no_eject = 0;
 	if (cap.cd_r_write)
 		CDROM_CONFIG_FLAGS(drive)->cd_r = 1;
-	if (cap.cd_rw_write)
+	if (cap.cd_rw_write) {
 		CDROM_CONFIG_FLAGS(drive)->cd_rw = 1;
+		CDROM_CONFIG_FLAGS(drive)->ram = 1;
+	}
 	if (cap.test_write)
 		CDROM_CONFIG_FLAGS(drive)->test_write = 1;
 	if (cap.dvd_ram_read || cap.dvd_r_read || cap.dvd_rom)
@@ -3040,10 +3051,9 @@
 
 	printk(", %dkB Cache", be16_to_cpu(cap.buffer_size));
 
-#ifdef CONFIG_BLK_DEV_IDEDMA
 	if (drive->using_dma)
-		(void) HWIF(drive)->ide_dma_verbose(drive);
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+		ide_dma_verbose(drive);
+
 	printk("\n");
 
 	return nslots;
@@ -3432,9 +3442,9 @@
 };
 
 /* options */
-char *ignore = NULL;
+static char *ignore = NULL;
 
-MODULE_PARM(ignore, "s");
+module_param(ignore, charp, 0400);
 MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
 
 static int ide_cdrom_attach (ide_drive_t *drive)
diff -Nru a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
--- a/drivers/ide/ide-cd.h	2004-12-24 13:37:33 -08:00
+++ b/drivers/ide/ide-cd.h	2004-12-24 13:37:33 -08:00
@@ -519,7 +519,7 @@
 
  /* The generic packet command opcodes for CD/DVD Logical Units,
  * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 
-const struct {
+static const struct {
 	unsigned short packet_command;
 	const char * const text;
 } packet_command_texts[] = {
@@ -577,7 +577,7 @@
 
 
 /* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
-const char * const sense_key_texts[16] = {
+static const char * const sense_key_texts[16] = {
 	"No sense data",
 	"Recovered error",
 	"Not ready",
@@ -597,7 +597,7 @@
 };
 
 /* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
-const struct {
+static const struct {
 	unsigned long asc_ascq;
 	const char * const text;
 } sense_data_texts[] = {
diff -Nru a/drivers/ide/ide-default.c b/drivers/ide/ide-default.c
--- a/drivers/ide/ide-default.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/ide/ide-default.c	2004-12-24 13:37:30 -08:00
@@ -23,13 +23,13 @@
 #include <linux/slab.h>
 #include <linux/cdrom.h>
 #include <linux/ide.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/unaligned.h>
-#include <asm/bitops.h>
 
 #define IDEDEFAULT_VERSION	"0.9.newide"
 /*
diff -Nru a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
--- a/drivers/ide/ide-disk.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/ide/ide-disk.c	2004-12-24 13:36:48 -08:00
@@ -71,10 +71,6 @@
 #include <asm/io.h>
 #include <asm/div64.h>
 
-/* FIXME: some day we shouldn't need to look in here! */
-
-#include "legacy/pdc4030.h"
-
 /*
  * lba_capacity_is_ok() performs a sanity check on the claimed "lba_capacity"
  * value for this drive (from its reported identification information).
@@ -120,218 +116,6 @@
 	return 0;	/* lba_capacity value may be bad */
 }
 
-#ifndef CONFIG_IDE_TASKFILE_IO
-
-/*
- * read_intr() is the handler for disk read/multread interrupts
- */
-static ide_startstop_t read_intr (ide_drive_t *drive)
-{
-	ide_hwif_t *hwif	= HWIF(drive);
-	u32 i = 0, nsect	= 0, msect = drive->mult_count;
-	struct request *rq;
-	unsigned long flags;
-	u8 stat;
-	char *to;
-
-	/* new way for dealing with premature shared PCI interrupts */
-	if (!OK_STAT(stat=hwif->INB(IDE_STATUS_REG),DATA_READY,BAD_R_STAT)) {
-		if (stat & (ERR_STAT|DRQ_STAT)) {
-			return DRIVER(drive)->error(drive, "read_intr", stat);
-		}
-		/* no data yet, so wait for another interrupt */
-		ide_set_handler(drive, &read_intr, WAIT_CMD, NULL);
-		return ide_started;
-	}
-	
-read_next:
-	rq = HWGROUP(drive)->rq;
-	if (msect) {
-		if ((nsect = rq->current_nr_sectors) > msect)
-			nsect = msect;
-		msect -= nsect;
-	} else
-		nsect = 1;
-	to = ide_map_buffer(rq, &flags);
-	taskfile_input_data(drive, to, nsect * SECTOR_WORDS);
-#ifdef DEBUG
-	printk("%s:  read: sectors(%ld-%ld), buffer=0x%08lx, remaining=%ld\n",
-		drive->name, rq->sector, rq->sector+nsect-1,
-		(unsigned long) rq->buffer+(nsect<<9), rq->nr_sectors-nsect);
-#endif
-	ide_unmap_buffer(rq, to, &flags);
-	rq->sector += nsect;
-	rq->errors = 0;
-	i = (rq->nr_sectors -= nsect);
-	if (((long)(rq->current_nr_sectors -= nsect)) <= 0)
-		ide_end_request(drive, 1, rq->hard_cur_sectors);
-	/*
-	 * Another BH Page walker and DATA INTEGRITY Questioned on ERROR.
-	 * If passed back up on multimode read, BAD DATA could be ACKED
-	 * to FILE SYSTEMS above ...
-	 */
-	if (i > 0) {
-		if (msect)
-			goto read_next;
-		ide_set_handler(drive, &read_intr, WAIT_CMD, NULL);
-                return ide_started;
-	}
-        return ide_stopped;
-}
-
-/*
- * write_intr() is the handler for disk write interrupts
- */
-static ide_startstop_t write_intr (ide_drive_t *drive)
-{
-	ide_hwgroup_t *hwgroup	= HWGROUP(drive);
-	ide_hwif_t *hwif	= HWIF(drive);
-	struct request *rq	= hwgroup->rq;
-	u32 i = 0;
-	u8 stat;
-
-	if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),
-			DRIVE_READY, drive->bad_wstat)) {
-		printk("%s: write_intr error1: nr_sectors=%ld, stat=0x%02x\n",
-			drive->name, rq->nr_sectors, stat);
-        } else {
-#ifdef DEBUG
-		printk("%s: write: sector %ld, buffer=0x%08lx, remaining=%ld\n",
-			drive->name, rq->sector, (unsigned long) rq->buffer,
-			rq->nr_sectors-1);
-#endif
-		if ((rq->nr_sectors == 1) ^ ((stat & DRQ_STAT) != 0)) {
-			rq->sector++;
-			rq->errors = 0;
-			i = --rq->nr_sectors;
-			--rq->current_nr_sectors;
-			if (((long)rq->current_nr_sectors) <= 0)
-				ide_end_request(drive, 1, rq->hard_cur_sectors);
-			if (i > 0) {
-				unsigned long flags;
-				char *to = ide_map_buffer(rq, &flags);
-				taskfile_output_data(drive, to, SECTOR_WORDS);
-				ide_unmap_buffer(rq, to, &flags);
-				ide_set_handler(drive, &write_intr, WAIT_CMD, NULL);
-                                return ide_started;
-			}
-                        return ide_stopped;
-		}
-		/* the original code did this here (?) */
-		return ide_stopped;
-	}
-	return DRIVER(drive)->error(drive, "write_intr", stat);
-}
-
-/*
- * ide_multwrite() transfers a block of up to mcount sectors of data
- * to a drive as part of a disk multiple-sector write operation.
- *
- * Note that we may be called from two contexts - __ide_do_rw_disk() context
- * and IRQ context. The IRQ can happen any time after we've output the
- * full "mcount" number of sectors, so we must make sure we update the
- * state _before_ we output the final part of the data!
- *
- * The update and return to BH is a BLOCK Layer Fakey to get more data
- * to satisfy the hardware atomic segment.  If the hardware atomic segment
- * is shorter or smaller than the BH segment then we should be OKAY.
- * This is only valid if we can rewind the rq->current_nr_sectors counter.
- */
-static void ide_multwrite(ide_drive_t *drive, unsigned int mcount)
-{
- 	ide_hwgroup_t *hwgroup	= HWGROUP(drive);
- 	struct request *rq	= &hwgroup->wrq;
- 
-  	do {
-  		char *buffer;
-  		int nsect = rq->current_nr_sectors;
-		unsigned long flags;
- 
-		if (nsect > mcount)
-			nsect = mcount;
-		mcount -= nsect;
-		buffer = ide_map_buffer(rq, &flags);
-
-		rq->sector += nsect;
-		rq->nr_sectors -= nsect;
-		rq->current_nr_sectors -= nsect;
-
-		/* Do we move to the next bh after this? */
-		if (!rq->current_nr_sectors) {
-			struct bio *bio = rq->bio;
-
-			/*
-			 * only move to next bio, when we have processed
-			 * all bvecs in this one.
-			 */
-			if (++bio->bi_idx >= bio->bi_vcnt) {
-				bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
-				bio = bio->bi_next;
-			}
-
-			/* end early early we ran out of requests */
-			if (!bio) {
-				mcount = 0;
-			} else {
-				rq->bio = bio;
-				rq->nr_cbio_segments = bio_segments(bio);
-				rq->current_nr_sectors = bio_cur_sectors(bio);
-				rq->hard_cur_sectors = rq->current_nr_sectors;
-			}
-		}
-
-		/*
-		 * Ok, we're all setup for the interrupt
-		 * re-entering us on the last transfer.
-		 */
-		taskfile_output_data(drive, buffer, nsect<<7);
-		ide_unmap_buffer(rq, buffer, &flags);
-	} while (mcount);
-}
-
-/*
- * multwrite_intr() is the handler for disk multwrite interrupts
- */
-static ide_startstop_t multwrite_intr (ide_drive_t *drive)
-{
-	ide_hwgroup_t *hwgroup	= HWGROUP(drive);
-	ide_hwif_t *hwif	= HWIF(drive);
-	struct request *rq	= &hwgroup->wrq;
-	struct bio *bio		= rq->bio;
-	u8 stat;
-
-	stat = hwif->INB(IDE_STATUS_REG);
-	if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) {
-		if (stat & DRQ_STAT) {
-			/*
-			 *	The drive wants data. Remember rq is the copy
-			 *	of the request
-			 */
-			if (rq->nr_sectors) {
-				ide_multwrite(drive, drive->mult_count);
-				ide_set_handler(drive, &multwrite_intr, WAIT_CMD, NULL);
-				return ide_started;
-			}
-		} else {
-			/*
-			 *	If the copy has all the blocks completed then
-			 *	we can end the original request.
-			 */
-			if (!rq->nr_sectors) {	/* all done? */
-				bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
-				rq = hwgroup->rq;
-				ide_end_request(drive, 1, rq->nr_sectors);
-				return ide_stopped;
-			}
-		}
-		bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
-		/* the original code did this here (?) */
-		return ide_stopped;
-	}
-	bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
-	return DRIVER(drive)->error(drive, "multwrite_intr", stat);
-}
-
 /*
  * __ide_do_rw_disk() issues READ and WRITE commands to a disk,
  * using LBA if supported, or CHS otherwise, to address sectors.
@@ -352,9 +136,16 @@
 			dma = 0;
 	}
 
+	if (!dma) {
+		ide_init_sg_cmd(drive, rq);
+		ide_map_sg(drive, rq);
+	}
+
 	if (IDE_CONTROL_REG)
 		hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
 
+	/* FIXME: SELECT_MASK(drive, 0) ? */
+
 	if (drive->select.b.lba) {
 		if (drive->addressing == 1) {
 			task_ioreg_t tasklets[10];
@@ -419,172 +210,54 @@
 		hwif->OUTB(head|drive->select.all,IDE_SELECT_REG);
 	}
 
-	if (rq_data_dir(rq) == READ) {
-		if (dma && !hwif->ide_dma_read(drive))
-			return ide_started;
-
-		command = ((drive->mult_count) ?
-			   ((lba48) ? WIN_MULTREAD_EXT : WIN_MULTREAD) :
-			   ((lba48) ? WIN_READ_EXT : WIN_READ));
-		ide_execute_command(drive, command, &read_intr, WAIT_CMD, NULL);
-		return ide_started;
-	} else {
-		ide_startstop_t startstop;
-
-		if (dma && !hwif->ide_dma_write(drive))
+	if (dma) {
+		if (!hwif->dma_setup(drive)) {
+			if (rq_data_dir(rq)) {
+				command = lba48 ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
+				if (drive->vdma)
+					command = lba48 ? WIN_WRITE_EXT: WIN_WRITE;
+			} else {
+				command = lba48 ? WIN_READDMA_EXT : WIN_READDMA;
+				if (drive->vdma)
+					command = lba48 ? WIN_READ_EXT: WIN_READ;
+			}
+			hwif->dma_exec_cmd(drive, command);
+			hwif->dma_start(drive);
 			return ide_started;
-
-		command = ((drive->mult_count) ?
-			   ((lba48) ? WIN_MULTWRITE_EXT : WIN_MULTWRITE) :
-			   ((lba48) ? WIN_WRITE_EXT : WIN_WRITE));
-		hwif->OUTB(command, IDE_COMMAND_REG);
-
-		if (ide_wait_stat(&startstop, drive, DATA_READY,
-				drive->bad_wstat, WAIT_DRQ)) {
-			printk(KERN_ERR "%s: no DRQ after issuing %s\n",
-				drive->name,
-				drive->mult_count ? "MULTWRITE" : "WRITE");
-			return startstop;
-		}
-		if (!drive->unmask)
-			local_irq_disable();
-		if (drive->mult_count) {
-			ide_hwgroup_t *hwgroup = HWGROUP(drive);
-
-			hwgroup->wrq = *rq; /* scratchpad */
-			ide_set_handler(drive, &multwrite_intr, WAIT_CMD, NULL);
-			ide_multwrite(drive, drive->mult_count);
-		} else {
-			unsigned long flags;
-			char *to = ide_map_buffer(rq, &flags);
-			ide_set_handler(drive, &write_intr, WAIT_CMD, NULL);
-			taskfile_output_data(drive, to, SECTOR_WORDS);
-			ide_unmap_buffer(rq, to, &flags);
 		}
-		return ide_started;
-	}
-}
-EXPORT_SYMBOL_GPL(__ide_do_rw_disk);
-
-#else /* CONFIG_IDE_TASKFILE_IO */
-
-static ide_startstop_t chs_rw_disk(ide_drive_t *, struct request *, unsigned long);
-static ide_startstop_t lba_28_rw_disk(ide_drive_t *, struct request *, unsigned long);
-static ide_startstop_t lba_48_rw_disk(ide_drive_t *, struct request *, unsigned long long);
-
-/*
- * __ide_do_rw_disk() issues READ and WRITE commands to a disk,
- * using LBA if supported, or CHS otherwise, to address sectors.
- * It also takes care of issuing special DRIVE_CMDs.
- */
-ide_startstop_t __ide_do_rw_disk (ide_drive_t *drive, struct request *rq, sector_t block)
-{
-	/*
-	 * 268435455  == 137439 MB or 28bit limit
-	 *
-	 * need to add split taskfile operations based on 28bit threshold.
-	 */
-	if (drive->addressing == 1)		/* 48-bit LBA */
-		return lba_48_rw_disk(drive, rq, (unsigned long long) block);
-	if (drive->select.b.lba)		/* 28-bit LBA */
-		return lba_28_rw_disk(drive, rq, (unsigned long) block);
-
-	/* 28-bit CHS : DIE DIE DIE piece of legacy crap!!! */
-	return chs_rw_disk(drive, rq, (unsigned long) block);
-}
-EXPORT_SYMBOL_GPL(__ide_do_rw_disk);
-
-static u8 get_command(ide_drive_t *drive, struct request *rq, ide_task_t *task)
-{
-	unsigned int lba48 = (drive->addressing == 1) ? 1 : 0;
-	unsigned int dma = drive->using_dma;
-
-	if (drive->hwif->no_lba48_dma && lba48 && dma) {
-		if (rq->sector + rq->nr_sectors > 1ULL << 28)
-			dma = 0;
+		/* fallback to PIO */
+		ide_init_sg_cmd(drive, rq);
 	}
 
 	if (rq_data_dir(rq) == READ) {
-		task->command_type = IDE_DRIVE_TASK_IN;
-		if (dma)
-			return lba48 ? WIN_READDMA_EXT : WIN_READDMA;
-		task->handler = &task_in_intr;
+
 		if (drive->mult_count) {
-			task->data_phase = TASKFILE_MULTI_IN;
-			return lba48 ? WIN_MULTREAD_EXT : WIN_MULTREAD;
+			hwif->data_phase = TASKFILE_MULTI_IN;
+			command = lba48 ? WIN_MULTREAD_EXT : WIN_MULTREAD;
+		} else {
+			hwif->data_phase = TASKFILE_IN;
+			command = lba48 ? WIN_READ_EXT : WIN_READ;
 		}
-		task->data_phase = TASKFILE_IN;
-		return lba48 ? WIN_READ_EXT : WIN_READ;
+
+		ide_execute_command(drive, command, &task_in_intr, WAIT_CMD, NULL);
+		return ide_started;
 	} else {
-		task->command_type = IDE_DRIVE_TASK_RAW_WRITE;
-		if (dma)
-			return lba48 ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
-		task->prehandler = &pre_task_out_intr;
-		task->handler = &task_out_intr;
 		if (drive->mult_count) {
-			task->data_phase = TASKFILE_MULTI_OUT;
-			return lba48 ? WIN_MULTWRITE_EXT : WIN_MULTWRITE;
+			hwif->data_phase = TASKFILE_MULTI_OUT;
+			command = lba48 ? WIN_MULTWRITE_EXT : WIN_MULTWRITE;
+		} else {
+			hwif->data_phase = TASKFILE_OUT;
+			command = lba48 ? WIN_WRITE_EXT : WIN_WRITE;
 		}
-		task->data_phase = TASKFILE_OUT;
-		return lba48 ? WIN_WRITE_EXT : WIN_WRITE;
-	}
-}
 
-static ide_startstop_t chs_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block)
-{
-	ide_task_t		args;
-	int			sectors;
-	ata_nsector_t		nsectors;
-	unsigned int track	= (block / drive->sect);
-	unsigned int sect	= (block % drive->sect) + 1;
-	unsigned int head	= (track % drive->head);
-	unsigned int cyl	= (track / drive->head);
-
-	nsectors.all = (u16) rq->nr_sectors;
-
-	pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect);
-
-	memset(&args, 0, sizeof(ide_task_t));
-
-	sectors	= (rq->nr_sectors == 256) ? 0x00 : rq->nr_sectors;
-
-	args.tfRegister[IDE_NSECTOR_OFFSET]	= sectors;
-	args.tfRegister[IDE_SECTOR_OFFSET]	= sect;
-	args.tfRegister[IDE_LCYL_OFFSET]	= cyl;
-	args.tfRegister[IDE_HCYL_OFFSET]	= (cyl>>8);
-	args.tfRegister[IDE_SELECT_OFFSET]	= head;
-	args.tfRegister[IDE_SELECT_OFFSET]	|= drive->select.all;
-	args.tfRegister[IDE_COMMAND_OFFSET]	= get_command(drive, rq, &args);
-	args.rq					= (struct request *) rq;
-	rq->special				= (ide_task_t *)&args;
-	drive->hwif->data_phase = args.data_phase;
-	return do_rw_taskfile(drive, &args);
-}
-
-static ide_startstop_t lba_28_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block)
-{
-	ide_task_t		args;
-	int			sectors;
-	ata_nsector_t		nsectors;
-
-	nsectors.all = (u16) rq->nr_sectors;
-
-	memset(&args, 0, sizeof(ide_task_t));
-
-	sectors = (rq->nr_sectors == 256) ? 0x00 : rq->nr_sectors;
+		/* FIXME: ->OUTBSYNC ? */
+		hwif->OUTB(command, IDE_COMMAND_REG);
 
-	args.tfRegister[IDE_NSECTOR_OFFSET]	= sectors;
-	args.tfRegister[IDE_SECTOR_OFFSET]	= block;
-	args.tfRegister[IDE_LCYL_OFFSET]	= (block>>=8);
-	args.tfRegister[IDE_HCYL_OFFSET]	= (block>>=8);
-	args.tfRegister[IDE_SELECT_OFFSET]	= ((block>>8)&0x0f);
-	args.tfRegister[IDE_SELECT_OFFSET]	|= drive->select.all;
-	args.tfRegister[IDE_COMMAND_OFFSET]	= get_command(drive, rq, &args);
-	args.rq					= (struct request *) rq;
-	rq->special				= (ide_task_t *)&args;
-	drive->hwif->data_phase = args.data_phase;
-	return do_rw_taskfile(drive, &args);
+		pre_task_out_intr(drive, rq);
+		return ide_started;
+	}
 }
+EXPORT_SYMBOL_GPL(__ide_do_rw_disk);
 
 /*
  * 268435455  == 137439 MB or 28bit limit
@@ -592,38 +265,6 @@
  * 1073741822 == 549756 MB or 48bit addressing fake drive
  */
 
-static ide_startstop_t lba_48_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long long block)
-{
-	ide_task_t		args;
-	int			sectors;
-	ata_nsector_t		nsectors;
-
-	nsectors.all = (u16) rq->nr_sectors;
-
-	memset(&args, 0, sizeof(ide_task_t));
-
-	sectors = (rq->nr_sectors == 65536) ? 0 : rq->nr_sectors;
-
-	args.tfRegister[IDE_NSECTOR_OFFSET]	= sectors;
-	args.hobRegister[IDE_NSECTOR_OFFSET]	= sectors >> 8;
-	args.tfRegister[IDE_SECTOR_OFFSET]	= block;	/* low lba */
-	args.tfRegister[IDE_LCYL_OFFSET]	= (block>>=8);	/* mid lba */
-	args.tfRegister[IDE_HCYL_OFFSET]	= (block>>=8);	/* hi  lba */
-	args.tfRegister[IDE_SELECT_OFFSET]	= drive->select.all;
-	args.tfRegister[IDE_COMMAND_OFFSET]	= get_command(drive, rq, &args);
-	args.hobRegister[IDE_SECTOR_OFFSET]	= (block>>=8);	/* low lba */
-	args.hobRegister[IDE_LCYL_OFFSET]	= (block>>=8);	/* mid lba */
-	args.hobRegister[IDE_HCYL_OFFSET]	= (block>>=8);	/* hi  lba */
-	args.hobRegister[IDE_SELECT_OFFSET]	= drive->select.all;
-	args.hobRegister[IDE_CONTROL_OFFSET_HOB]= (drive->ctl|0x80);
-	args.rq					= (struct request *) rq;
-	rq->special				= (ide_task_t *)&args;
-	drive->hwif->data_phase = args.data_phase;
-	return do_rw_taskfile(drive, &args);
-}
-
-#endif /* CONFIG_IDE_TASKFILE_IO */
-
 static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, sector_t block)
 {
 	ide_hwif_t *hwif = HWIF(drive);
@@ -749,7 +390,7 @@
 	return err;
 }
 
-ide_startstop_t idedisk_error (ide_drive_t *drive, const char *msg, u8 stat)
+static ide_startstop_t idedisk_error (ide_drive_t *drive, const char *msg, u8 stat)
 {
 	ide_hwif_t *hwif;
 	struct request *rq;
@@ -767,10 +408,6 @@
 		ide_end_drive_cmd(drive, stat, err);
 		return ide_stopped;
 	}
-#ifdef CONFIG_IDE_TASKFILE_IO
-	/* make rq completion pointers new submission pointers */
-	blk_rq_prep_restart(rq);
-#endif
 
 	if (stat & BUSY_STAT || ((stat & WRERR_STAT) && !drive->nowerr)) {
 		/* other bits are useless when BUSY */
@@ -813,7 +450,7 @@
 	return ide_stopped;
 }
 
-ide_startstop_t idedisk_abort(ide_drive_t *drive, const char *msg)
+static ide_startstop_t idedisk_abort(ide_drive_t *drive, const char *msg)
 {
 	ide_hwif_t *hwif;
 	struct request *rq;
@@ -1006,9 +643,6 @@
 			 capacity, sectors_to_MB(capacity),
 			 set_max, sectors_to_MB(set_max));
 
-	if (!drive->stroke)
-		return;
-
 	if (lba48)
 		set_max = idedisk_set_max_address_ext(drive, set_max);
 	else
@@ -1066,6 +700,8 @@
 	return drive->capacity64 - drive->sect0;
 }
 
+#define IS_PDC4030_DRIVE	0
+
 static ide_startstop_t idedisk_special (ide_drive_t *drive)
 {
 	special_t *s = &drive->special;
@@ -1176,6 +812,7 @@
 	args.tfRegister[IDE_HCYL_OFFSET]	= SMART_HCYL_PASS;
 	args.tfRegister[IDE_COMMAND_OFFSET]	= WIN_SMART;
 	args.command_type			= IDE_DRIVE_TASK_IN;
+	args.data_phase				= TASKFILE_IN;
 	args.handler				= &task_in_intr;
 	(void) smart_enable(drive);
 	return ide_raw_taskfile(drive, &args, buf);
@@ -1605,7 +1242,7 @@
 	printk(", CHS=%d/%d/%d", 
 	       drive->bios_cyl, drive->bios_head, drive->bios_sect);
 	if (drive->using_dma)
-		(void) HWIF(drive)->ide_dma_verbose(drive);
+		ide_dma_verbose(drive);
 	printk("\n");
 
 	drive->mult_count = 0;
diff -Nru a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
--- a/drivers/ide/ide-dma.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/ide/ide-dma.c	2004-12-24 13:36:49 -08:00
@@ -85,6 +85,7 @@
 #include <linux/init.h>
 #include <linux/ide.h>
 #include <linux/delay.h>
+#include <linux/scatterlist.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -128,14 +129,11 @@
 	{ "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"           },  
 	{ NULL			,	NULL		}
@@ -206,73 +204,23 @@
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	struct scatterlist *sg = hwif->sg_table;
-	int nents;
 
-	nents = blk_rq_map_sg(drive->queue, rq, hwif->sg_table);
-		
+	if ((rq->flags & REQ_DRIVE_TASKFILE) && rq->nr_sectors > 256)
+		BUG();
+
+	ide_map_sg(drive, rq);
+
 	if (rq_data_dir(rq) == READ)
 		hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
 	else
 		hwif->sg_dma_direction = PCI_DMA_TODEVICE;
 
-	return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction);
+	return pci_map_sg(hwif->pci_dev, sg, hwif->sg_nents, hwif->sg_dma_direction);
 }
 
 EXPORT_SYMBOL_GPL(ide_build_sglist);
 
 /**
- *	ide_raw_build_sglist	-	map IDE scatter gather for DMA
- *	@drive: the drive to build the DMA table for
- *	@rq: the request holding the sg list
- *
- *	Perform the PCI mapping magic necessary to access the source or
- *	target buffers of a taskfile request via PCI DMA. The lower layers 
- *	of the  kernel provide the necessary cache management so that we can
- *	operate in a portable fashion
- */
-
-int ide_raw_build_sglist(ide_drive_t *drive, struct request *rq)
-{
-	ide_hwif_t *hwif = HWIF(drive);
-	struct scatterlist *sg = hwif->sg_table;
-	int nents = 0;
-	ide_task_t *args = rq->special;
-	u8 *virt_addr = rq->buffer;
-	int sector_count = rq->nr_sectors;
-
-	if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
-		hwif->sg_dma_direction = PCI_DMA_TODEVICE;
-	else
-		hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
-
-#if 1
-	if (sector_count > 256)
-		BUG();
-
-	if (sector_count > 128) {
-#else
-	while (sector_count > 128) {
-#endif
-		memset(&sg[nents], 0, sizeof(*sg));
-		sg[nents].page = virt_to_page(virt_addr);
-		sg[nents].offset = offset_in_page(virt_addr);
-		sg[nents].length = 128  * SECTOR_SIZE;
-		nents++;
-		virt_addr = virt_addr + (128 * SECTOR_SIZE);
-		sector_count -= 128;
-	}
-	memset(&sg[nents], 0, sizeof(*sg));
-	sg[nents].page = virt_to_page(virt_addr);
-	sg[nents].offset = offset_in_page(virt_addr);
-	sg[nents].length =  sector_count  * SECTOR_SIZE;
-	nents++;
-
-	return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction);
-}
-
-EXPORT_SYMBOL_GPL(ide_raw_build_sglist);
-
-/**
  *	ide_build_dmatable	-	build IDE DMA table
  *
  *	ide_build_dmatable() prepares a dma request. We map the command
@@ -293,10 +241,7 @@
 	int i;
 	struct scatterlist *sg;
 
-	if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE)
-		hwif->sg_nents = i = ide_raw_build_sglist(drive, rq);
-	else
-		hwif->sg_nents = i = ide_build_sglist(drive, rq);
+	hwif->sg_nents = i = ide_build_sglist(drive, rq);
 
 	if (!i)
 		return 0;
@@ -590,10 +535,8 @@
 EXPORT_SYMBOL(__ide_dma_check);
 
 /**
- *	ide_start_dma	-	begin a DMA phase
- *	@hwif: interface
+ *	ide_dma_setup	-	begin a DMA phase
  *	@drive: target device
- *	@reading: set if reading, clear if writing
  *
  *	Build an IDE DMA PRD (IDE speak for scatter gather table)
  *	and then set up the DMA transfer registers for a device
@@ -603,15 +546,24 @@
  *	Returns 0 on success. If a PIO fallback is required then 1
  *	is returned. 
  */
- 
-int ide_start_dma(ide_hwif_t *hwif, ide_drive_t *drive, int reading)
+
+int ide_dma_setup(ide_drive_t *drive)
 {
+	ide_hwif_t *hwif = drive->hwif;
 	struct request *rq = HWGROUP(drive)->rq;
+	unsigned int reading;
 	u8 dma_stat;
 
+	if (rq_data_dir(rq))
+		reading = 0;
+	else
+		reading = 1 << 3;
+
 	/* fall back to pio! */
-	if (!ide_build_dmatable(drive, rq))
+	if (!ide_build_dmatable(drive, rq)) {
+		ide_map_sg(drive, rq);
 		return 1;
+	}
 
 	/* PRD table */
 	hwif->OUTL(hwif->dmatable_dma, hwif->dma_prdtable);
@@ -628,73 +580,15 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(ide_start_dma);
+EXPORT_SYMBOL_GPL(ide_dma_setup);
 
-int __ide_dma_read (ide_drive_t *drive /*, struct request *rq */)
+static void ide_dma_exec_cmd(ide_drive_t *drive, u8 command)
 {
-	ide_hwif_t *hwif	= HWIF(drive);
-	struct request *rq	= HWGROUP(drive)->rq;
-	unsigned int reading	= 1 << 3;
-	u8 lba48		= (drive->addressing == 1) ? 1 : 0;
-	task_ioreg_t command	= WIN_NOP;
-
-	/* try pio */
-	if (ide_start_dma(hwif, drive, reading))
-		return 1;
-
-	if (drive->media != ide_disk)
-		return 0;
-
-	command = (lba48) ? WIN_READDMA_EXT : WIN_READDMA;
-	
-	if (drive->vdma)
-		command = (lba48) ? WIN_READ_EXT: WIN_READ;
-		
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-		command = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-
 	/* issue cmd to drive */
 	ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry);
-	return hwif->ide_dma_begin(drive);
 }
 
-EXPORT_SYMBOL(__ide_dma_read);
-
-int __ide_dma_write (ide_drive_t *drive /*, struct request *rq */)
-{
-	ide_hwif_t *hwif	= HWIF(drive);
-	struct request *rq	= HWGROUP(drive)->rq;
-	unsigned int reading	= 0;
-	u8 lba48		= (drive->addressing == 1) ? 1 : 0;
-	task_ioreg_t command	= WIN_NOP;
-
-	/* try PIO instead of DMA */
-	if (ide_start_dma(hwif, drive, reading))
-		return 1;
-
-	if (drive->media != ide_disk)
-		return 0;
-
-	command = (lba48) ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
-	if (drive->vdma)
-		command = (lba48) ? WIN_WRITE_EXT: WIN_WRITE;
-		
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-		command = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-
-	/* issue cmd to drive */
-	ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry);
-
-	return hwif->ide_dma_begin(drive);
-}
-
-EXPORT_SYMBOL(__ide_dma_write);
-
-int __ide_dma_begin (ide_drive_t *drive)
+void ide_dma_start(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	u8 dma_cmd		= hwif->INB(hwif->dma_command);
@@ -708,10 +602,9 @@
 	hwif->OUTB(dma_cmd|1, hwif->dma_command);
 	hwif->dma = 1;
 	wmb();
-	return 0;
 }
 
-EXPORT_SYMBOL(__ide_dma_begin);
+EXPORT_SYMBOL_GPL(ide_dma_start);
 
 /* returns 1 on error, 0 otherwise */
 int __ide_dma_end (ide_drive_t *drive)
@@ -785,17 +678,46 @@
 
 EXPORT_SYMBOL(__ide_dma_good_drive);
 
-#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
-int __ide_dma_verbose (ide_drive_t *drive)
+int ide_use_dma(ide_drive_t *drive)
+{
+	struct hd_driveid *id = drive->id;
+	ide_hwif_t *hwif = drive->hwif;
+
+	/* consult the list of known "bad" drives */
+	if (__ide_dma_bad_drive(drive))
+		return 0;
+
+	/* capable of UltraDMA modes */
+	if (id->field_valid & 4) {
+		if (hwif->ultra_mask & id->dma_ultra)
+			return 1;
+	}
+
+	/* capable of regular DMA modes */
+	if (id->field_valid & 2) {
+		if (hwif->mwdma_mask & id->dma_mword)
+			return 1;
+		if (hwif->swdma_mask & id->dma_1word)
+			return 1;
+	}
+
+	/* consult the list of known "good" drives */
+	if (__ide_dma_good_drive(drive) && id->eide_dma_time < 150)
+		return 1;
+
+	return 0;
+}
+
+EXPORT_SYMBOL_GPL(ide_use_dma);
+
+void ide_dma_verbose(ide_drive_t *drive)
 {
 	struct hd_driveid *id	= drive->id;
 	ide_hwif_t *hwif	= HWIF(drive);
 
 	if (id->field_valid & 4) {
-		if ((id->dma_ultra >> 8) && (id->dma_mword >> 8)) {
-			printk(", BUG DMA OFF");
-			return hwif->ide_dma_off_quietly(drive);
-		}
+		if ((id->dma_ultra >> 8) && (id->dma_mword >> 8))
+			goto bug_dma_off;
 		if (id->dma_ultra & ((id->dma_ultra >> 8) & hwif->ultra_mask)) {
 			if (((id->dma_ultra >> 11) & 0x1F) &&
 			    eighty_ninty_three(drive)) {
@@ -825,19 +747,22 @@
 			printk(", (U)DMA");	/* Can be BIOS-enabled! */
 		}
 	} else if (id->field_valid & 2) {
-		if ((id->dma_mword >> 8) && (id->dma_1word >> 8)) {
-			printk(", BUG DMA OFF");
-			return hwif->ide_dma_off_quietly(drive);
-		}
+		if ((id->dma_mword >> 8) && (id->dma_1word >> 8))
+			goto bug_dma_off;
 		printk(", DMA");
 	} else if (id->field_valid & 1) {
 		printk(", BUG");
 	}
-	return 1;
+	return;
+bug_dma_off:
+	printk(", BUG DMA OFF");
+	hwif->ide_dma_off_quietly(drive);
+	return;
 }
 
-EXPORT_SYMBOL(__ide_dma_verbose);
+EXPORT_SYMBOL(ide_dma_verbose);
 
+#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
 int __ide_dma_lostirq (ide_drive_t *drive)
 {
 	printk("%s: DMA interrupt recovery\n", drive->name);
@@ -869,10 +794,6 @@
 				    hwif->dmatable_dma);
 		hwif->dmatable_cpu = NULL;
 	}
-	if (hwif->sg_table) {
-		kfree(hwif->sg_table);
-		hwif->sg_table = NULL;
-	}
 	return 1;
 }
 
@@ -905,15 +826,12 @@
 	hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
 						  PRD_ENTRIES * PRD_BYTES,
 						  &hwif->dmatable_dma);
-	hwif->sg_table = kmalloc(sizeof(struct scatterlist) * PRD_ENTRIES,
-				GFP_KERNEL);
 
-	if ((hwif->dmatable_cpu) && (hwif->sg_table))
+	if (hwif->dmatable_cpu)
 		return 0;
 
-	printk(KERN_ERR "%s: -- Error, unable to allocate%s%s table(s).\n",
+	printk(KERN_ERR "%s: -- Error, unable to allocate%s DMA table(s).\n",
 		(hwif->dmatable_cpu == NULL) ? " CPU" : "",
-		(hwif->sg_table == NULL) ?  " SG DMA" : " DMA",
 		hwif->cds->name);
 
 	ide_release_dma_engine(hwif);
@@ -1009,18 +927,16 @@
 		hwif->ide_dma_host_on = &__ide_dma_host_on;
 	if (!hwif->ide_dma_check)
 		hwif->ide_dma_check = &__ide_dma_check;
-	if (!hwif->ide_dma_read)
-		hwif->ide_dma_read = &__ide_dma_read;
-	if (!hwif->ide_dma_write)
-		hwif->ide_dma_write = &__ide_dma_write;
-	if (!hwif->ide_dma_begin)
-		hwif->ide_dma_begin = &__ide_dma_begin;
+	if (!hwif->dma_setup)
+		hwif->dma_setup = &ide_dma_setup;
+	if (!hwif->dma_exec_cmd)
+		hwif->dma_exec_cmd = &ide_dma_exec_cmd;
+	if (!hwif->dma_start)
+		hwif->dma_start = &ide_dma_start;
 	if (!hwif->ide_dma_end)
 		hwif->ide_dma_end = &__ide_dma_end;
 	if (!hwif->ide_dma_test_irq)
 		hwif->ide_dma_test_irq = &__ide_dma_test_irq;
-	if (!hwif->ide_dma_verbose)
-		hwif->ide_dma_verbose = &__ide_dma_verbose;
 	if (!hwif->ide_dma_timeout)
 		hwif->ide_dma_timeout = &__ide_dma_timeout;
 	if (!hwif->ide_dma_lostirq)
diff -Nru a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
--- a/drivers/ide/ide-floppy.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/ide/ide-floppy.c	2004-12-24 13:36:49 -08:00
@@ -97,13 +97,13 @@
 #include <linux/slab.h>
 #include <linux/cdrom.h>
 #include <linux/ide.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/unaligned.h>
-#include <asm/bitops.h>
 
 /*
  *	The following are used to debug the driver.
@@ -989,12 +989,27 @@
 	return ide_started;
 }
 
+/**
+ * idefloppy_should_report_error()
+ *
+ * Supresses error messages resulting from Medium not present
+ */
+static inline int idefloppy_should_report_error(idefloppy_floppy_t *floppy)
+{
+	if (floppy->sense_key == 0x02 &&
+	    floppy->asc       == 0x3a &&
+	    floppy->ascq      == 0x00)
+		return 0;
+	return 1;
+}
+
 /*
  *	Issue a packet command
  */
 static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *pc)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
+	ide_hwif_t *hwif = drive->hwif;
 	atapi_feature_t feature;
 	atapi_bcount_t bcount;
 	ide_handler_t *pkt_xfer_routine;
@@ -1021,12 +1036,13 @@
 		 */
 		if (!test_bit(PC_ABORT, &pc->flags)) {
 			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);
+				if (idefloppy_should_report_error(floppy))
+					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);
 			}
 			/* Giving up */
 			pc->error = IDEFLOPPY_ERROR_GENERAL;
@@ -1049,13 +1065,8 @@
 	}
 	feature.all = 0;
 
-	if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) {
-		if (test_bit(PC_WRITING, &pc->flags)) {
-			feature.b.dma = !HWIF(drive)->ide_dma_write(drive);
-		} else {
-			feature.b.dma = !HWIF(drive)->ide_dma_read(drive);
-		}
-	}
+	if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma)
+		feature.b.dma = !hwif->dma_setup(drive);
 
 	if (IDE_CONTROL_REG)
 		HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG);
@@ -1067,7 +1078,7 @@
 
 	if (feature.b.dma) {	/* Begin DMA, if necessary */
 		set_bit(PC_DMA_IN_PROGRESS, &pc->flags);
-		(void) (HWIF(drive)->ide_dma_begin(drive));
+		hwif->dma_start(drive);
 	}
 
 	/* Can we transfer the packet when we get the interrupt or wait? */
@@ -1242,11 +1253,13 @@
 			rq->nr_sectors, rq->current_nr_sectors);
 
 	if (rq->errors >= ERROR_MAX) {
-		if (floppy->failed_pc != NULL)
-			printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x,"
-					" key = %2x, asc = %2x, ascq = %2x\n",
-				drive->name, floppy->failed_pc->c[0],
-				floppy->sense_key, floppy->asc, floppy->ascq);
+		if (floppy->failed_pc != NULL) {
+			if (idefloppy_should_report_error(floppy))
+				printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x,"
+				       " key = %2x, asc = %2x, ascq = %2x\n",
+				       drive->name, floppy->failed_pc->c[0],
+				       floppy->sense_key, floppy->asc, floppy->ascq);
+		}
 		else
 			printk(KERN_ERR "ide-floppy: %s: I/O error\n",
 				drive->name);
diff -Nru a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
--- a/drivers/ide/ide-io.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/ide/ide-io.c	2004-12-24 13:37:18 -08:00
@@ -47,6 +47,7 @@
 #include <linux/seq_file.h>
 #include <linux/device.h>
 #include <linux/kmod.h>
+#include <linux/scatterlist.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
@@ -542,8 +543,6 @@
 	return ide_stopped;
 }
 
-EXPORT_SYMBOL(ide_error);
-
 /**
  *	ide_abort	-	abort pending IDE operatins
  *	@drive: drive the error occurred on
@@ -584,8 +583,6 @@
 	return ide_stopped;
 }
 
-EXPORT_SYMBOL(ide_abort);
-
 /**
  *	ide_cmd		-	issue a simple drive command
  *	@drive: drive the command is for
@@ -597,7 +594,8 @@
  *	The drive must be selected beforehand.
  */
 
-void ide_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, ide_handler_t *handler)
+static void ide_cmd (ide_drive_t *drive, u8 cmd, u8 nsect,
+		ide_handler_t *handler)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	if (IDE_CONTROL_REG)
@@ -607,8 +605,6 @@
 	ide_execute_command(drive, cmd, handler, WAIT_CMD, NULL);
 }
 
-EXPORT_SYMBOL(ide_cmd);
-
 /**
  *	drive_cmd_intr		- 	drive command completion interrupt
  *	@drive: drive the completion interrupt occurred on
@@ -619,7 +615,7 @@
  *	the request
  */
  
-ide_startstop_t drive_cmd_intr (ide_drive_t *drive)
+static ide_startstop_t drive_cmd_intr (ide_drive_t *drive)
 {
 	struct request *rq = HWGROUP(drive)->rq;
 	ide_hwif_t *hwif = HWIF(drive);
@@ -644,8 +640,6 @@
 	return ide_stopped;
 }
 
-EXPORT_SYMBOL(drive_cmd_intr);
-
 /**
  *	do_special		-	issue some special commands
  *	@drive: drive the command is for
@@ -655,7 +649,7 @@
  *	back.
  */
 
-ide_startstop_t do_special (ide_drive_t *drive)
+static ide_startstop_t do_special (ide_drive_t *drive)
 {
 	special_t *s = &drive->special;
 
@@ -672,7 +666,33 @@
 		return DRIVER(drive)->special(drive);
 }
 
-EXPORT_SYMBOL(do_special);
+void ide_map_sg(ide_drive_t *drive, struct request *rq)
+{
+	ide_hwif_t *hwif = drive->hwif;
+	struct scatterlist *sg = hwif->sg_table;
+
+	if (hwif->sg_mapped)	/* needed by ide-scsi */
+		return;
+
+	if ((rq->flags & REQ_DRIVE_TASKFILE) == 0) {
+		hwif->sg_nents = blk_rq_map_sg(drive->queue, rq, sg);
+	} else {
+		sg_init_one(sg, rq->buffer, rq->nr_sectors * SECTOR_SIZE);
+		hwif->sg_nents = 1;
+	}
+}
+
+EXPORT_SYMBOL_GPL(ide_map_sg);
+
+void ide_init_sg_cmd(ide_drive_t *drive, struct request *rq)
+{
+	ide_hwif_t *hwif = drive->hwif;
+
+	hwif->nsect = hwif->nleft = rq->nr_sectors;
+	hwif->cursg = hwif->cursg_ofs = 0;
+}
+
+EXPORT_SYMBOL_GPL(ide_init_sg_cmd);
 
 /**
  *	execute_drive_command	-	issue special drive command
@@ -686,7 +706,8 @@
  *	all commands to finish. Don't do this as that is due to change
  */
 
-ide_startstop_t execute_drive_cmd (ide_drive_t *drive, struct request *rq)
+static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
+		struct request *rq)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	if (rq->flags & REQ_DRIVE_TASKFILE) {
@@ -697,6 +718,17 @@
 
 		hwif->data_phase = args->data_phase;
 
+		switch (hwif->data_phase) {
+		case TASKFILE_MULTI_OUT:
+		case TASKFILE_OUT:
+		case TASKFILE_MULTI_IN:
+		case TASKFILE_IN:
+			ide_init_sg_cmd(drive, rq);
+			ide_map_sg(drive, rq);
+		default:
+			break;
+		}
+
 		if (args->tf_out_flags.all != 0) 
 			return flagged_taskfile(drive, args);
 		return do_rw_taskfile(drive, args);
@@ -765,8 +797,6 @@
  	return ide_stopped;
 }
 
-EXPORT_SYMBOL(execute_drive_cmd);
-
 /**
  *	start_request	-	start of I/O and command issuing for IDE
  *
@@ -778,7 +808,7 @@
  *	FIXME: this function needs a rename
  */
  
-ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
+static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
 {
 	ide_startstop_t startstop;
 	sector_t block;
@@ -869,8 +899,6 @@
 	return ide_stopped;
 }
 
-EXPORT_SYMBOL(start_request);
-
 /**
  *	ide_stall_queue		-	pause an IDE device
  *	@drive: drive to stall
@@ -993,10 +1021,7 @@
  * the driver.  This makes the driver much more friendlier to shared IRQs
  * than previous designs, while remaining 100% (?) SMP safe and capable.
  */
-/* --BenH: made non-static as ide-pmac.c uses it to kick the hwgroup back
- *         into life on wakeup from machine sleep.
- */ 
-void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
+static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
 {
 	ide_drive_t	*drive;
 	ide_hwif_t	*hwif;
@@ -1128,8 +1153,6 @@
 	}
 }
 
-EXPORT_SYMBOL(ide_do_request);
-
 /*
  * Passes the stuff to ide_do_request
  */
@@ -1182,12 +1205,15 @@
 	HWGROUP(drive)->rq = NULL;
 
 	rq->errors = 0;
+
+	if (!rq->bio)
+		goto out;
+
 	rq->sector = rq->bio->bi_sector;
 	rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9;
 	rq->hard_cur_sectors = rq->current_nr_sectors;
-	if (rq->bio)
-		rq->buffer = NULL;
-
+	rq->buffer = NULL;
+out:
 	return ret;
 }
 
@@ -1291,8 +1317,6 @@
 	spin_unlock_irqrestore(&ide_lock, flags);
 }
 
-EXPORT_SYMBOL(ide_timer_expiry);
-
 /**
  *	unexpected_intr		-	handle an unexpected IDE interrupt
  *	@irq: interrupt line
@@ -1490,8 +1514,6 @@
 	return IRQ_HANDLED;
 }
 
-EXPORT_SYMBOL(ide_intr);
-
 /**
  *	ide_init_drive_cmd	-	initialize a drive command request
  *	@rq: request object
@@ -1550,18 +1572,6 @@
 	int where = ELEVATOR_INSERT_BACK, err;
 	int must_wait = (action == ide_wait || action == ide_head_wait);
 
-#ifdef CONFIG_BLK_DEV_PDC4030
-	/*
-	 *	FIXME: there should be a drive or hwif->special
-	 *	handler that points here by default, not hacks
-	 *	in the ide-io.c code
-	 *
-	 *	FIXME2: That code breaks power management if used with
-	 *	this chipset, that really doesn't belong here !
-	 */
-	if (HWIF(drive)->chipset == ide_pdc4030 && rq->buffer != NULL)
-		return -ENOSYS;  /* special drive cmds not supported */
-#endif
 	rq->errors = 0;
 	rq->rq_status = RQ_ACTIVE;
 
diff -Nru a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
--- a/drivers/ide/ide-iops.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/ide/ide-iops.c	2004-12-24 13:36:47 -08:00
@@ -23,12 +23,12 @@
 #include <linux/delay.h>
 #include <linux/hdreg.h>
 #include <linux/ide.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 
 /*
  *	Conventional PIO operations for ATA devices
@@ -221,24 +221,18 @@
 		HWIF(drive)->OUTB(drive->ctl|2, IDE_CONTROL_REG);
 }
 
-EXPORT_SYMBOL(SELECT_INTERRUPT);
-
 void SELECT_MASK (ide_drive_t *drive, int mask)
 {
 	if (HWIF(drive)->maskproc)
 		HWIF(drive)->maskproc(drive, mask);
 }
 
-EXPORT_SYMBOL(SELECT_MASK);
-
 void QUIRK_LIST (ide_drive_t *drive)
 {
 	if (HWIF(drive)->quirkproc)
 		drive->quirk_list = HWIF(drive)->quirkproc(drive);
 }
 
-EXPORT_SYMBOL(QUIRK_LIST);
-
 /*
  * Some localbus EIDE interfaces require a special access sequence
  * when using 32-bit I/O instructions to transfer data.  We call this
@@ -253,8 +247,6 @@
 	(void) HWIF(drive)->INB(port);
 }
 
-EXPORT_SYMBOL(ata_vlb_sync);
-
 /*
  * This is used for most PIO data transfers *from* the IDE interface
  */
@@ -277,8 +269,6 @@
 	}
 }
 
-EXPORT_SYMBOL(ata_input_data);
-
 /*
  * This is used for most PIO data transfers *to* the IDE interface
  */
@@ -301,8 +291,6 @@
 	}
 }
 
-EXPORT_SYMBOL(ata_output_data);
-
 /*
  * The following routines are mainly used by the ATAPI drivers.
  *
@@ -685,8 +673,6 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(ide_ata66_check);
-
 /*
  * Backside of HDIO_DRIVE_CMD call of SETFEATURES_XFER.
  * 1 : Safe to update drive->id DMA registers.
@@ -705,9 +691,8 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(set_transfer);
-
-u8 ide_auto_reduce_xfer (ide_drive_t *drive)
+#ifdef CONFIG_BLK_DEV_IDEDMA
+static u8 ide_auto_reduce_xfer (ide_drive_t *drive)
 {
 	if (!drive->crc_count)
 		return drive->current_speed;
@@ -731,8 +716,7 @@
 		default:		return XFER_PIO_4;
 	}
 }
-
-EXPORT_SYMBOL(ide_auto_reduce_xfer);
+#endif /* CONFIG_BLK_DEV_IDEDMA */
 
 /*
  * Update the 
@@ -807,8 +791,6 @@
 #endif
 }
 
-EXPORT_SYMBOL(ide_driveid_update);
-
 /*
  * Similar to ide_wait_stat(), except it never calls ide_error internally.
  * This is a kludge to handle the new ide_config_drive_speed() function,
@@ -948,7 +930,7 @@
  *
  * See also ide_execute_command
  */
-void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
+static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
 		      unsigned int timeout, ide_expiry_t *expiry)
 {
 	ide_hwgroup_t *hwgroup = HWGROUP(drive);
@@ -963,8 +945,6 @@
 	hwgroup->timer.expires	= jiffies + timeout;
 	add_timer(&hwgroup->timer);
 }
-
-EXPORT_SYMBOL(__ide_set_handler);
 
 void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
 		      unsigned int timeout, ide_expiry_t *expiry)
diff -Nru a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
--- a/drivers/ide/ide-lib.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/ide/ide-lib.c	2004-12-24 13:37:29 -08:00
@@ -15,12 +15,12 @@
 #include <linux/delay.h>
 #include <linux/hdreg.h>
 #include <linux/ide.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 
 /*
  *	IDE library routines. These are plug in code that most 
@@ -420,8 +420,6 @@
 	if (drive->queue)
 		blk_queue_bounce_limit(drive->queue, addr);
 }
-
-EXPORT_SYMBOL(ide_toggle_bounce);
 
 /**
  *	ide_set_xfer_rate	-	set transfer rate
diff -Nru a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
--- a/drivers/ide/ide-probe.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/ide/ide-probe.c	2004-12-24 13:36:59 -08:00
@@ -180,12 +180,6 @@
 	if (cmd == WIN_PIDENTIFY) {
 		u8 type = (id->config >> 8) & 0x1f;
 		printk("ATAPI ");
-#ifdef CONFIG_BLK_DEV_PDC4030
-		if (hwif->channel == 1 && hwif->chipset == ide_pdc4030) {
-			printk(" -- not supported on 2nd Promise port\n");
-			goto err_misc;
-		}
-#endif /* CONFIG_BLK_DEV_PDC4030 */
 		switch (type) {
 			case ide_floppy:
 				if (!strstr(id->model, "CD-ROM")) {
@@ -297,13 +291,9 @@
 		/* disable dma & overlap */
 		hwif->OUTB(0, IDE_FEATURE_REG);
 
-	if (hwif->identify != NULL) {
-		if (hwif->identify(drive))
-			return 1;
-	} else {
-		/* ask drive for ID */
-		hwif->OUTB(cmd, IDE_COMMAND_REG);
-	}
+	/* ask drive for ID */
+	hwif->OUTB(cmd, IDE_COMMAND_REG);
+
 	timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
 	timeout += jiffies;
 	do {
@@ -662,6 +652,43 @@
 	return rc;
 }
 
+/**
+ *	ide_undecoded_slave	-	look for bad CF adapters
+ *	@hwif: interface
+ *
+ *	Analyse the drives on the interface and attempt to decide if we
+ *	have the same drive viewed twice. This occurs with crap CF adapters
+ *	and PCMCIA sometimes.
+ */
+
+void ide_undecoded_slave(ide_hwif_t *hwif)
+{
+	ide_drive_t *drive0 = &hwif->drives[0];
+	ide_drive_t *drive1 = &hwif->drives[1];
+
+	if (drive0->present == 0 || drive1->present == 0)
+		return;
+
+	/* If the models don't match they are not the same product */
+	if (strcmp(drive0->id->model, drive1->id->model))
+		return;
+
+	/* Serial numbers do not match */
+	if (strncmp(drive0->id->serial_no, drive1->id->serial_no, 20))
+		return;
+
+	/* No serial number, thankfully very rare for CF */
+	if (drive0->id->serial_no[0] == 0)
+		return;
+
+	/* Appears to be an IDE flash adapter with decode bugs */
+	printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n");
+
+	drive1->present = 0;
+}
+
+EXPORT_SYMBOL_GPL(ide_undecoded_slave);
+
 /*
  * This routine only knows how to look for drive units 0 and 1
  * on an interface, so any setting of MAX_DRIVES > 2 won't work here.
@@ -676,9 +703,6 @@
 		return;
 
 	if ((hwif->chipset != ide_4drives || !hwif->mate || !hwif->mate->present) &&
-#ifdef CONFIG_BLK_DEV_PDC4030
-	    (hwif->chipset != ide_pdc4030 || hwif->channel == 0) &&
-#endif /* CONFIG_BLK_DEV_PDC4030 */
 	    (ide_hwif_request_regions(hwif))) {
 		u16 msgout = 0;
 		for (unit = 0; unit < MAX_DRIVES; ++unit) {
@@ -736,18 +760,6 @@
 		ide_drive_t *drive = &hwif->drives[unit];
 		drive->dn = (hwif->channel ? 2 : 0) + unit;
 		(void) probe_for_drive(drive);
-		if (drive->present && hwif->present && unit == 1) {
-			if (strcmp(hwif->drives[0].id->model, drive->id->model) == 0 &&
-			    /* Don't do this for noprobe or non ATA */
-			    strcmp(drive->id->model, "UNKNOWN") &&
-			    /* And beware of confused Maxtor drives that go "M0000000000"
-			      "The SN# is garbage in the ID block..." [Eric] */
-			    strncmp(drive->id->serial_no, "M0000000000000000000", 20) &&
-			    strncmp(hwif->drives[0].id->serial_no, drive->id->serial_no, 20) == 0) {
-				printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n");
-				drive->present = 0;
-			}
-		}
 		if (drive->present && !hwif->present) {
 			hwif->present = 1;
 			if (hwif->chipset != ide_4drives ||
@@ -821,9 +833,14 @@
 }
 
 static int hwif_init(ide_hwif_t *hwif);
-int probe_hwif_init (ide_hwif_t *hwif)
+
+int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
 {
 	probe_hwif(hwif);
+
+	if (fixup)
+		fixup(hwif);
+
 	hwif_init(hwif);
 
 	if (hwif->present) {
@@ -841,6 +858,11 @@
 	return 0;
 }
 
+int probe_hwif_init(ide_hwif_t *hwif)
+{
+	return probe_hwif_init_with_fixup(hwif, NULL);
+}
+
 EXPORT_SYMBOL(probe_hwif_init);
 
 #if MAX_HWIFS > 1
@@ -1127,7 +1149,7 @@
 
 extern ide_driver_t idedefault_driver;
 
-struct kobject *ata_probe(dev_t dev, int *part, void *data)
+static struct kobject *ata_probe(dev_t dev, int *part, void *data)
 {
 	ide_hwif_t *hwif = data;
 	int unit = *part >> PARTN_BITS;
@@ -1246,6 +1268,16 @@
 	if (register_blkdev(hwif->major, hwif->name))
 		return 0;
 
+	if (!hwif->sg_max_nents)
+		hwif->sg_max_nents = PRD_ENTRIES;
+
+	hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents,
+				 GFP_KERNEL);
+	if (!hwif->sg_table) {
+		printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name);
+		goto out;
+	}
+
 	if (alloc_disks(hwif) < 0)
 		goto out;
 	
@@ -1295,9 +1327,6 @@
 	for (index = 0; index < MAX_HWIFS; ++index)
 		probe[index] = !ide_hwifs[index].present;
 
-	/*
-	 * Probe for drives in the usual way.. CMOS/BIOS, then poke at ports
-	 */
 	for (index = 0; index < MAX_HWIFS; ++index)
 		if (probe[index])
 			probe_hwif(&ide_hwifs[index]);
diff -Nru a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
--- a/drivers/ide/ide-proc.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/ide/ide-proc.c	2004-12-24 13:36:55 -08:00
@@ -8,37 +8,6 @@
 /*
  * This is the /proc/ide/ filesystem implementation.
  *
- * The major reason this exists is to provide sufficient access
- * to driver and config data, such that user-mode programs can
- * be developed to handle chipset tuning for most PCI interfaces.
- * This should provide better utilities, and less kernel bloat.
- *
- * The entire pci config space for a PCI interface chipset can be
- * retrieved by just reading it.  e.g.    "cat /proc/ide3/config"
- *
- * To modify registers *safely*, do something like:
- *   echo "P40:88" >/proc/ide/ide3/config
- * That expression writes 0x88 to pci config register 0x40
- * on the chip which controls ide3.  Multiple tuples can be issued,
- * and the writes will be completed as an atomic set:
- *   echo "P40:88 P41:35 P42:00 P43:00" >/proc/ide/ide3/config
- *
- * All numbers must be specified using pairs of ascii hex digits.
- * It is important to note that these writes will be performed
- * after waiting for the IDE controller (both interfaces)
- * to be completely idle, to ensure no corruption of I/O in progress.
- *
- * Non-PCI registers can also be written, using "R" in place of "P"
- * in the above examples.  The size of the port transfer is determined
- * by the number of pairs of hex digits given for the data.  If a two
- * digit value is given, the write will be a byte operation; if four
- * digits are used, the write will be performed as a 16-bit operation;
- * and if eight digits are specified, a 32-bit "dword" write will be
- * performed.  Odd numbers of digits are not permitted.
- *
- * If there is an error *anywhere* in the string of registers/data
- * then *none* of the writes will be performed.
- *
  * Drive/Driver settings can be retrieved by reading the drive's
  * "settings" files.  e.g.    "cat /proc/ide0/hda/settings"
  * To write a new value "val" into a specific setting "name", use:
@@ -51,10 +20,6 @@
  * returned data as 256 16-bit words.  The "hdparm" utility will
  * be updated someday soon to use this mechanism.
  *
- * Feel free to develop and distribute fancy GUI configuration
- * utilities for your favorite PCI chipsets.  I'll be working on
- * one for the Promise 20246 someday soon.  -ml
- *
  */
 
 #include <linux/config.h>
@@ -74,227 +39,6 @@
 
 #include <asm/io.h>
 
-static int proc_ide_write_config(struct file *file, const char __user *buffer,
-				 unsigned long count, void *data)
-{
-	ide_hwif_t	*hwif = (ide_hwif_t *)data;
-	ide_hwgroup_t *mygroup = (ide_hwgroup_t *)(hwif->hwgroup);
-	ide_hwgroup_t *mategroup = NULL;
-	unsigned long timeout;
-	unsigned long flags;
-	const char *start = NULL, *msg = NULL;
-	struct entry { u32 val; u16 reg; u8 size; u8 pci; } *prog, *q, *r;
-	int want_pci = 0;
-	char *buf, *s;
-	int err;
-
-	if (hwif->mate && hwif->mate->hwgroup)
-		mategroup = (ide_hwgroup_t *)(hwif->mate->hwgroup);
-
-	if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
-		return -EACCES;
-
-	if (count >= PAGE_SIZE)
-		return -EINVAL;
-
-	s = buf = (char *)__get_free_page(GFP_USER);
-	if (!buf)
-		return -ENOMEM;
-
-	err = -ENOMEM;
-	q = prog = (struct entry *)__get_free_page(GFP_USER);
-	if (!prog)
-		goto out;
-
-	err = -EFAULT;
-	if (copy_from_user(buf, buffer, count))
-		goto out1;
-
-	buf[count] = '\0';
-
-	while (isspace(*s))
-		s++;
-
-	while (*s) {
-		char *p;
-		int digits;
-
-		start = s;
-
-		if ((char *)(q + 1) > (char *)prog + PAGE_SIZE) {
-			msg = "too many entries";
-			goto parse_error;
-		}
-
-		switch (*s++) {
-			case 'R':	q->pci = 0;
-					break;
-			case 'P':	q->pci = 1;
-					want_pci = 1;
-					break;
-			default:	msg = "expected 'R' or 'P'";
-					goto parse_error;
-		}
-
-		q->reg = simple_strtoul(s, &p, 16);
-		digits = p - s;
-		if (!digits || digits > 4 || (q->pci && q->reg > 0xff)) {
-			msg = "bad/missing register number";
-			goto parse_error;
-		}
-		if (*p++ != ':') {
-			msg = "missing ':'";
-			goto parse_error;
-		}
-		q->val = simple_strtoul(p, &s, 16);
-		digits = s - p;
-		if (digits != 2 && digits != 4 && digits != 8) {
-			msg = "bad data, 2/4/8 digits required";
-			goto parse_error;
-		}
-		q->size = digits / 2;
-
-		if (q->pci) {
-#ifdef CONFIG_BLK_DEV_IDEPCI
-			if (q->reg & (q->size - 1)) {
-				msg = "misaligned access";
-				goto parse_error;
-			}
-#else
-			msg = "not a PCI device";
-			goto parse_error;
-#endif	/* CONFIG_BLK_DEV_IDEPCI */
-		}
-
-		q++;
-
-		if (*s && !isspace(*s++)) {
-			msg = "expected whitespace after data";
-			goto parse_error;
-		}
-		while (isspace(*s))
-			s++;
-	}
-
-	/*
-	 * What follows below is fucking insane, even for IDE people.
-	 * For now I've dealt with the obvious problems on the parsing
-	 * side, but IMNSHO we should simply remove the write access
-	 * to /proc/ide/.../config, killing that FPOS completely.
-	 */
-
-	err = -EBUSY;
-	timeout = jiffies + (3 * HZ);
-	spin_lock_irqsave(&ide_lock, flags);
-	while (mygroup->busy ||
-	       (mategroup && mategroup->busy)) {
-		spin_unlock_irqrestore(&ide_lock, flags);
-		if (time_after(jiffies, timeout)) {
-			printk("/proc/ide/%s/config: channel(s) busy, cannot write\n", hwif->name);
-			goto out1;
-		}
-		spin_lock_irqsave(&ide_lock, flags);
-	}
-
-#ifdef CONFIG_BLK_DEV_IDEPCI
-	if (want_pci && (!hwif->pci_dev || hwif->pci_dev->vendor)) {
-		spin_unlock_irqrestore(&ide_lock, flags);
-		printk("proc_ide: PCI registers not accessible for %s\n",
-			hwif->name);
-		err = -EINVAL;
-		goto out1;
-	}
-#endif	/* CONFIG_BLK_DEV_IDEPCI */
-
-	for (r = prog; r < q; r++) {
-		unsigned int reg = r->reg, val = r->val;
-		if (r->pci) {
-#ifdef CONFIG_BLK_DEV_IDEPCI
-			int rc = 0;
-			struct pci_dev *dev = hwif->pci_dev;
-			switch (q->size) {
-				case 1:	msg = "byte";
-					rc = pci_write_config_byte(dev, reg, val);
-					break;
-				case 2:	msg = "word";
-					rc = pci_write_config_word(dev, reg, val);
-					break;
-				case 4:	msg = "dword";
-					rc = pci_write_config_dword(dev, reg, val);
-					break;
-			}
-			if (rc) {
-				spin_unlock_irqrestore(&ide_lock, flags);
-				printk("proc_ide_write_config: error writing %s at bus %02x dev %02x reg 0x%x value 0x%x\n",
-					msg, dev->bus->number, dev->devfn, reg, val);
-				printk("proc_ide_write_config: error %d\n", rc);
-				err = -EIO;
-				goto out1;
-			}
-#endif	/* CONFIG_BLK_DEV_IDEPCI */
-		} else {	/* not pci */
-			switch (r->size) {
-				case 1:	hwif->OUTB(val, reg);
-					break;
-				case 2:	hwif->OUTW(val, reg);
-					break;
-				case 4:	hwif->OUTL(val, reg);
-					break;
-			}
-		}
-	}
-	spin_unlock_irqrestore(&ide_lock, flags);
-	err = count;
-out1:
-	free_page((unsigned long)prog);
-out:
-	free_page((unsigned long)buf);
-	return err;
-
-parse_error:
-	printk("parse error\n");
-	printk("proc_ide: error: %s: '%s'\n", msg, start);
-	err = -EINVAL;
-	goto out1;
-}
-
-static int proc_ide_read_config
-	(char *page, char **start, off_t off, int count, int *eof, void *data)
-{
-	char		*out = page;
-	int		len;
-
-#ifdef CONFIG_BLK_DEV_IDEPCI
-	ide_hwif_t	*hwif = (ide_hwif_t *)data;
-	struct pci_dev	*dev = hwif->pci_dev;
-	if ((hwif->pci_dev && hwif->pci_dev->vendor) && dev && dev->bus) {
-		int reg = 0;
-
-		out += sprintf(out, "pci bus %02x device %02x vendor %04x "
-				"device %04x channel %d\n",
-			dev->bus->number, dev->devfn,
-			hwif->pci_dev->vendor, hwif->pci_dev->device,
-			hwif->channel);
-		do {
-			u8 val;
-			int rc = pci_read_config_byte(dev, reg, &val);
-			if (rc) {
-				printk("proc_ide_read_config: error %d reading"
-					" bus %02x dev %02x reg 0x%02x\n",
-					rc, dev->bus->number, dev->devfn, reg);
-				out += sprintf(out, "??%c",
-					(++reg & 0xf) ? ' ' : '\n');
-			} else
-				out += sprintf(out, "%02x%c",
-					val, (++reg & 0xf) ? ' ' : '\n');
-		} while (reg < 0x100);
-	} else
-#endif	/* CONFIG_BLK_DEV_IDEPCI */
-		out += sprintf(out, "(none)\n");
-	len = out - page;
-	PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
-}
-
 static int proc_ide_read_imodel
 	(char *page, char **start, off_t off, int count, int *eof, void *data)
 {
@@ -314,7 +58,6 @@
 		case ide_qd65xx:	name = "qd65xx";	break;
 		case ide_umc8672:	name = "umc8672";	break;
 		case ide_ht6560b:	name = "ht6560b";	break;
-		case ide_pdc4030:	name = "pdc4030";	break;
 		case ide_rz1000:	name = "rz1000";	break;
 		case ide_trm290:	name = "trm290";	break;
 		case ide_cmd646:	name = "cmd646";	break;
@@ -381,6 +124,18 @@
 	PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
 }
 
+static void proc_ide_settings_warn(void)
+{
+	static int warned = 0;
+
+	if (warned)
+		return;
+
+	printk(KERN_WARNING "Warning: /proc/ide/hd?/settings interface is "
+			    "obsolete, and will be removed soon!\n");
+	warned = 1;
+}
+
 static int proc_ide_read_settings
 	(char *page, char **start, off_t off, int count, int *eof, void *data)
 {
@@ -389,6 +144,8 @@
 	char		*out = page;
 	int		len, rc, mul_factor, div_factor;
 
+	proc_ide_settings_warn();
+
 	down(&ide_setting_sem);
 	out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n");
 	out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n");
@@ -428,6 +185,8 @@
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
+	proc_ide_settings_warn();
+
 	if (count >= PAGE_SIZE)
 		return -EINVAL;
 
@@ -675,7 +434,7 @@
 	}
 }
 
-void destroy_proc_ide_drives(ide_hwif_t *hwif)
+static void destroy_proc_ide_drives(ide_hwif_t *hwif)
 {
 	int	d;
 
@@ -688,7 +447,6 @@
 
 static ide_proc_entry_t hwif_entries[] = {
 	{ "channel",	S_IFREG|S_IRUGO,	proc_ide_read_channel,	NULL },
-	{ "config",	S_IFREG|S_IRUGO|S_IWUSR,proc_ide_read_config,	proc_ide_write_config },
 	{ "mate",	S_IFREG|S_IRUGO,	proc_ide_read_mate,	NULL },
 	{ "model",	S_IFREG|S_IRUGO,	proc_ide_read_imodel,	NULL },
 	{ NULL,	0, NULL, NULL }
@@ -724,28 +482,29 @@
 EXPORT_SYMBOL_GPL(ide_pci_create_host_proc);
 #endif
 
-void destroy_proc_ide_interfaces(void)
+void destroy_proc_ide_interface(ide_hwif_t *hwif)
+{
+	if (hwif->proc) {
+		destroy_proc_ide_drives(hwif);
+		ide_remove_proc_entries(hwif->proc, hwif_entries);
+		remove_proc_entry(hwif->name, proc_ide_root);
+		hwif->proc = NULL;
+	}
+}
+
+static void destroy_proc_ide_interfaces(void)
 {
 	int	h;
 
 	for (h = 0; h < MAX_HWIFS; h++) {
 		ide_hwif_t *hwif = &ide_hwifs[h];
-		int exist = (hwif->proc != NULL);
 #if 0
 		if (!hwif->present)
 			continue;
 #endif
-		if (exist) {
-			destroy_proc_ide_drives(hwif);
-			ide_remove_proc_entries(hwif->proc, hwif_entries);
-			remove_proc_entry(hwif->name, proc_ide_root);
-			hwif->proc = NULL;
-		} else
-			continue;
+		destroy_proc_ide_interface(hwif);
 	}
 }
-
-EXPORT_SYMBOL(destroy_proc_ide_interfaces);
 
 extern struct seq_operations ide_drivers_op;
 static int ide_drivers_open(struct inode *inode, struct file *file)
diff -Nru a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
--- a/drivers/ide/ide-tape.c	2004-12-24 13:36:35 -08:00
+++ b/drivers/ide/ide-tape.c	2004-12-24 13:36:35 -08:00
@@ -442,13 +442,13 @@
 #include <linux/ide.h>
 #include <linux/smp_lock.h>
 #include <linux/completion.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/unaligned.h>
-#include <asm/bitops.h>
 
 /*
  * partition
@@ -2067,7 +2067,7 @@
 #ifdef CONFIG_BLK_DEV_IDEDMA
 	/* Begin DMA, if necessary */
 	if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags))
-		(void) (HWIF(drive)->ide_dma_begin(drive));
+		hwif->dma_start(drive);
 #endif
 	/* Send the actual packet */
 	HWIF(drive)->atapi_output_bytes(drive, pc->c, 12);
@@ -2135,12 +2135,8 @@
 				"reverting to PIO\n");
 		(void)__ide_dma_off(drive);
 	}
-	if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) {
-		if (test_bit(PC_WRITING, &pc->flags))
-			dma_ok = !HWIF(drive)->ide_dma_write(drive);
-		else
-			dma_ok = !HWIF(drive)->ide_dma_read(drive);
-	}
+	if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma)
+		dma_ok = !hwif->dma_setup(drive);
 
 	if (IDE_CONTROL_REG)
 		hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
diff -Nru a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
--- a/drivers/ide/ide-taskfile.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/ide/ide-taskfile.c	2004-12-24 13:36:17 -08:00
@@ -5,7 +5,7 @@
  *  Copyright (C) 2000-2002	Andre Hedrick <andre@linux-ide.org>
  *  Copyright (C) 2001-2002	Klaus Smolin
  *					IBM Storage Technology Division
- *  Copyright (C) 2003		Bartlomiej Zolnierkiewicz
+ *  Copyright (C) 2003-2004	Bartlomiej Zolnierkiewicz
  *
  *  The big the bad and the ugly.
  *
@@ -44,12 +44,12 @@
 #include <linux/delay.h>
 #include <linux/hdreg.h>
 #include <linux/ide.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 
 #define DEBUG_TASKFILE	0	/* unset when fixed */
 
@@ -63,17 +63,14 @@
 	}
 }
 
-
-void taskfile_input_data (ide_drive_t *drive, void *buffer, u32 wcount)
+static void taskfile_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
 {
 	HWIF(drive)->ata_input_data(drive, buffer, wcount);
 	if (drive->bswap)
 		ata_bswap_data(buffer, wcount);
 }
 
-EXPORT_SYMBOL(taskfile_input_data);
-
-void taskfile_output_data (ide_drive_t *drive, void *buffer, u32 wcount)
+static void taskfile_output_data(ide_drive_t *drive, void *buffer, u32 wcount)
 {
 	if (drive->bswap) {
 		ata_bswap_data(buffer, wcount);
@@ -84,8 +81,6 @@
 	}
 }
 
-EXPORT_SYMBOL(taskfile_output_data);
-
 int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
 {
 	ide_task_t args;
@@ -101,8 +96,6 @@
 	return ide_raw_taskfile(drive, &args, buf);
 }
 
-EXPORT_SYMBOL(taskfile_lib_get_identify);
-
 ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
@@ -150,15 +143,15 @@
 		case WIN_WRITEDMA_ONCE:
 		case WIN_WRITEDMA:
 		case WIN_WRITEDMA_EXT:
-			if (!hwif->ide_dma_write(drive))
-				return ide_started;
-			break;
 		case WIN_READDMA_ONCE:
 		case WIN_READDMA:
 		case WIN_READDMA_EXT:
 		case WIN_IDENTIFY_DMA:
-			if (!hwif->ide_dma_read(drive))
+			if (!hwif->dma_setup(drive)) {
+				hwif->dma_exec_cmd(drive, taskfile->command);
+				hwif->dma_start(drive);
 				return ide_started;
+			}
 			break;
 		default:
 			if (task->handler == NULL)
@@ -253,73 +246,6 @@
 
 EXPORT_SYMBOL(task_no_data_intr);
 
-static void task_buffer_sectors(ide_drive_t *drive, struct request *rq,
-				unsigned nsect, unsigned rw)
-{
-	char *buf = rq->buffer + blk_rq_offset(rq);
-
-	rq->sector += nsect;
-	rq->current_nr_sectors -= nsect;
-	rq->nr_sectors -= nsect;
-	__task_sectors(drive, buf, nsect, rw);
-}
-
-static inline void task_buffer_multi_sectors(ide_drive_t *drive,
-					     struct request *rq, unsigned rw)
-{
-	unsigned int msect = drive->mult_count, nsect;
-
-	nsect = rq->current_nr_sectors;
-	if (nsect > msect)
-		nsect = msect;
-
-	task_buffer_sectors(drive, rq, nsect, rw);
-}
-
-#ifdef CONFIG_IDE_TASKFILE_IO
-static void task_sectors(ide_drive_t *drive, struct request *rq,
-			 unsigned nsect, unsigned rw)
-{
-	if (rq->cbio) {	/* fs request */
-		rq->errors = 0;
-		task_bio_sectors(drive, rq, nsect, rw);
-	} else		/* task request */
-		task_buffer_sectors(drive, rq, nsect, rw);
-}
-
-static inline void task_bio_multi_sectors(ide_drive_t *drive,
-					  struct request *rq, unsigned rw)
-{
-	unsigned int nsect, msect = drive->mult_count;
-
-	do {
-		nsect = rq->current_nr_sectors;
-		if (nsect > msect)
-			nsect = msect;
-
-		task_bio_sectors(drive, rq, nsect, rw);
-
-		if (!rq->nr_sectors)
-			msect = 0;
-		else
-			msect -= nsect;
-	} while (msect);
-}
-
-static void task_multi_sectors(ide_drive_t *drive,
-			       struct request *rq, unsigned rw)
-{
-	if (rq->cbio) {	/* fs request */
-		rq->errors = 0;
-		task_bio_multi_sectors(drive, rq, rw);
-	} else		/* task request */
-		task_buffer_multi_sectors(drive, rq, rw);
-}
-#else
-# define task_sectors(d, rq, nsect, rw)	task_buffer_sectors(d, rq, nsect, rw)
-# define task_multi_sectors(d, rq, rw)	task_buffer_multi_sectors(d, rq, rw)
-#endif /* CONFIG_IDE_TASKFILE_IO */
-
 static u8 wait_drive_not_busy(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
@@ -340,37 +266,92 @@
 	return stat;
 }
 
+static void ide_pio_sector(ide_drive_t *drive, unsigned int write)
+{
+	ide_hwif_t *hwif = drive->hwif;
+	struct scatterlist *sg = hwif->sg_table;
+	struct page *page;
+#ifdef CONFIG_HIGHMEM
+	unsigned long flags;
+#endif
+	unsigned int offset;
+	u8 *buf;
+
+	page = sg[hwif->cursg].page;
+	offset = sg[hwif->cursg].offset + hwif->cursg_ofs * SECTOR_SIZE;
+
+	/* get the current page and offset */
+	page = nth_page(page, (offset >> PAGE_SHIFT));
+	offset %= PAGE_SIZE;
+
+#ifdef CONFIG_HIGHMEM
+	local_irq_save(flags);
+#endif
+	buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
+
+	hwif->nleft--;
+	hwif->cursg_ofs++;
+
+	if ((hwif->cursg_ofs * SECTOR_SIZE) == sg[hwif->cursg].length) {
+		hwif->cursg++;
+		hwif->cursg_ofs = 0;
+	}
+
+	/* do the actual data transfer */
+	if (write)
+		taskfile_output_data(drive, buf, SECTOR_WORDS);
+	else
+		taskfile_input_data(drive, buf, SECTOR_WORDS);
+
+	kunmap_atomic(buf, KM_BIO_SRC_IRQ);
+#ifdef CONFIG_HIGHMEM
+	local_irq_restore(flags);
+#endif
+}
+
+static void ide_pio_multi(ide_drive_t *drive, unsigned int write)
+{
+	unsigned int nsect;
+
+	nsect = min_t(unsigned int, drive->hwif->nleft, drive->mult_count);
+	while (nsect--)
+		ide_pio_sector(drive, write);
+}
+
 static inline void ide_pio_datablock(ide_drive_t *drive, struct request *rq,
 				     unsigned int write)
 {
+	if (rq->bio)	/* fs request */
+		rq->errors = 0;
+
 	switch (drive->hwif->data_phase) {
 	case TASKFILE_MULTI_IN:
 	case TASKFILE_MULTI_OUT:
-		task_multi_sectors(drive, rq, write);
+		ide_pio_multi(drive, write);
 		break;
 	default:
-		task_sectors(drive, rq, 1, write);
+		ide_pio_sector(drive, write);
 		break;
 	}
 }
 
-#ifdef CONFIG_IDE_TASKFILE_IO
 static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq,
 				  const char *s, u8 stat)
 {
 	if (rq->bio) {
-		int sectors = rq->hard_nr_sectors - rq->nr_sectors;
+		ide_hwif_t *hwif = drive->hwif;
+		int sectors = hwif->nsect - hwif->nleft;
 
-		switch (drive->hwif->data_phase) {
+		switch (hwif->data_phase) {
 		case TASKFILE_IN:
-			if (rq->nr_sectors)
+			if (hwif->nleft)
 				break;
 			/* fall through */
 		case TASKFILE_OUT:
 			sectors--;
 			break;
 		case TASKFILE_MULTI_IN:
-			if (rq->nr_sectors)
+			if (hwif->nleft)
 				break;
 			/* fall through */
 		case TASKFILE_MULTI_OUT:
@@ -384,9 +365,6 @@
 	}
 	return drive->driver->error(drive, s, stat);
 }
-#else
-# define task_error(d, rq, s, stat) drive->driver->error(d, s, stat)
-#endif
 
 static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
 {
@@ -407,9 +385,11 @@
  */
 ide_startstop_t task_in_intr (ide_drive_t *drive)
 {
+	ide_hwif_t *hwif = drive->hwif;
 	struct request *rq = HWGROUP(drive)->rq;
-	u8 stat = HWIF(drive)->INB(IDE_STATUS_REG);
+	u8 stat = hwif->INB(IDE_STATUS_REG);
 
+	/* new way for dealing with premature shared PCI interrupts */
 	if (!OK_STAT(stat, DATA_READY, BAD_R_STAT)) {
 		if (stat & (ERR_STAT | DRQ_STAT))
 			return task_error(drive, rq, __FUNCTION__, stat);
@@ -421,7 +401,7 @@
 	ide_pio_datablock(drive, rq, 0);
 
 	/* If it was the last datablock check status and finish transfer. */
-	if (!rq->nr_sectors) {
+	if (!hwif->nleft) {
 		stat = wait_drive_not_busy(drive);
 		if (!OK_STAT(stat, 0, BAD_R_STAT))
 			return task_error(drive, rq, __FUNCTION__, stat);
@@ -439,20 +419,20 @@
 /*
  * Handler for command with PIO data-out phase (Write/Write Multiple).
  */
-ide_startstop_t task_out_intr (ide_drive_t *drive)
+static ide_startstop_t task_out_intr (ide_drive_t *drive)
 {
+	ide_hwif_t *hwif = drive->hwif;
 	struct request *rq = HWGROUP(drive)->rq;
-	u8 stat;
+	u8 stat = hwif->INB(IDE_STATUS_REG);
 
-	stat = HWIF(drive)->INB(IDE_STATUS_REG);
 	if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
 		return task_error(drive, rq, __FUNCTION__, stat);
 
 	/* Deal with unexpected ATA data phase. */
-	if (((stat & DRQ_STAT) == 0) ^ !rq->nr_sectors)
+	if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft)
 		return task_error(drive, rq, __FUNCTION__, stat);
 
-	if (!rq->nr_sectors) {
+	if (!hwif->nleft) {
 		task_end_request(drive, rq, stat);
 		return ide_stopped;
 	}
@@ -464,8 +444,6 @@
 	return ide_started;
 }
 
-EXPORT_SYMBOL(task_out_intr);
-
 ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq)
 {
 	ide_startstop_t startstop;
@@ -489,7 +467,7 @@
 }
 EXPORT_SYMBOL(pre_task_out_intr);
 
-int ide_diag_taskfile (ide_drive_t *drive, ide_task_t *args, unsigned long data_size, u8 *buf)
+static int ide_diag_taskfile(ide_drive_t *drive, ide_task_t *args, unsigned long data_size, u8 *buf)
 {
 	struct request rq;
 
@@ -517,14 +495,15 @@
 
 		rq.hard_nr_sectors = rq.nr_sectors;
 		rq.hard_cur_sectors = rq.current_nr_sectors = rq.nr_sectors;
+
+		if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
+			rq.flags |= REQ_RW;
 	}
 
 	rq.special = args;
 	return ide_do_drive_cmd(drive, &rq, ide_wait);
 }
 
-EXPORT_SYMBOL(ide_diag_taskfile);
-
 int ide_raw_taskfile (ide_drive_t *drive, ide_task_t *args, u8 *buf)
 {
 	return ide_diag_taskfile(drive, args, 0, buf);
@@ -532,10 +511,6 @@
 
 EXPORT_SYMBOL(ide_raw_taskfile);
 
-#define MAX_DMA		(256*SECTOR_WORDS)
-
-ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *);
-
 int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
 {
 	ide_task_request_t	*req_task;
@@ -686,8 +661,6 @@
 	return err;
 }
 
-EXPORT_SYMBOL(ide_taskfile_ioctl);
-
 int ide_wait_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf)
 {
 	struct request rq;
@@ -705,8 +678,6 @@
 	return ide_do_drive_cmd(drive, &rq, ide_wait);
 }
 
-EXPORT_SYMBOL(ide_wait_cmd);
-
 /*
  * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
  */
@@ -764,9 +735,7 @@
 	return err;
 }
 
-EXPORT_SYMBOL(ide_cmd_ioctl);
-
-int ide_wait_cmd_task (ide_drive_t *drive, u8 *buf)
+static int ide_wait_cmd_task(ide_drive_t *drive, u8 *buf)
 {
 	struct request rq;
 
@@ -776,8 +745,6 @@
 	return ide_do_drive_cmd(drive, &rq, ide_wait);
 }
 
-EXPORT_SYMBOL(ide_wait_cmd_task);
-
 /*
  * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
  */
@@ -796,8 +763,6 @@
 	return err;
 }
 
-EXPORT_SYMBOL(ide_task_ioctl);
-
 /*
  * NOTICE: This is additions from IBM to provide a discrete interface,
  * for selective taskregister access operations.  Nice JOB Klaus!!!
@@ -896,12 +861,11 @@
 
    	        case TASKFILE_OUT_DMAQ:
 		case TASKFILE_OUT_DMA:
-			hwif->ide_dma_write(drive);
-			break;
-
 		case TASKFILE_IN_DMAQ:
 		case TASKFILE_IN_DMA:
-			hwif->ide_dma_read(drive);
+			hwif->dma_setup(drive);
+			hwif->dma_exec_cmd(drive, taskfile->command);
+			hwif->dma_start(drive);
 			break;
 
 	        default:
@@ -919,5 +883,3 @@
 
 	return ide_started;
 }
-
-EXPORT_SYMBOL(flagged_taskfile);
diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
--- a/drivers/ide/ide.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/ide/ide.c	2004-12-24 13:36:31 -08:00
@@ -153,12 +153,12 @@
 #include <linux/cdrom.h>
 #include <linux/seq_file.h>
 #include <linux/device.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 
 
 /* default maximum number of failures */
@@ -335,11 +335,16 @@
 
 int ide_system_bus_speed (void)
 {
+	static struct pci_device_id pci_default[] = {
+		{ PCI_DEVICE(PCI_ANY_ID, PCI_ANY_ID) },
+		{ }
+	};
+
 	if (!system_bus_speed) {
 		if (idebus_parameter) {
 			/* user supplied value */
 			system_bus_speed = idebus_parameter;
-		} else if (pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL) != NULL) {
+		} else if (pci_dev_present(pci_default)) {
 			/* safe default value for PCI */
 			system_bus_speed = 33;
 		} else {
@@ -668,7 +673,6 @@
 	hwif->cds			= tmp_hwif->cds;
 #endif
 
-	hwif->identify			= tmp_hwif->identify;
 	hwif->tuneproc			= tmp_hwif->tuneproc;
 	hwif->speedproc			= tmp_hwif->speedproc;
 	hwif->selectproc		= tmp_hwif->selectproc;
@@ -685,9 +689,9 @@
 	hwif->atapi_input_bytes		= tmp_hwif->atapi_input_bytes;
 	hwif->atapi_output_bytes	= tmp_hwif->atapi_output_bytes;
 
-	hwif->ide_dma_read		= tmp_hwif->ide_dma_read;
-	hwif->ide_dma_write		= tmp_hwif->ide_dma_write;
-	hwif->ide_dma_begin		= tmp_hwif->ide_dma_begin;
+	hwif->dma_setup			= tmp_hwif->dma_setup;
+	hwif->dma_exec_cmd		= tmp_hwif->dma_exec_cmd;
+	hwif->dma_start			= tmp_hwif->dma_start;
 	hwif->ide_dma_end		= tmp_hwif->ide_dma_end;
 	hwif->ide_dma_check		= tmp_hwif->ide_dma_check;
 	hwif->ide_dma_on		= tmp_hwif->ide_dma_on;
@@ -695,7 +699,6 @@
 	hwif->ide_dma_test_irq		= tmp_hwif->ide_dma_test_irq;
 	hwif->ide_dma_host_on		= tmp_hwif->ide_dma_host_on;
 	hwif->ide_dma_host_off		= tmp_hwif->ide_dma_host_off;
-	hwif->ide_dma_verbose		= tmp_hwif->ide_dma_verbose;
 	hwif->ide_dma_lostirq		= tmp_hwif->ide_dma_lostirq;
 	hwif->ide_dma_timeout		= tmp_hwif->ide_dma_timeout;
 
@@ -712,6 +715,8 @@
 	hwif->INSW			= tmp_hwif->INSW;
 	hwif->INSL			= tmp_hwif->INSL;
 
+	hwif->sg_max_nents		= tmp_hwif->sg_max_nents;
+
 	hwif->mmio			= tmp_hwif->mmio;
 	hwif->rqsize			= tmp_hwif->rqsize;
 	hwif->no_lba48			= tmp_hwif->no_lba48;
@@ -796,9 +801,7 @@
 		DRIVER(drive)->cleanup(drive);
 	}
 
-#ifdef CONFIG_PROC_FS
-	destroy_proc_ide_drives(hwif);
-#endif
+	destroy_proc_ide_interface(hwif);
 
 	hwgroup = hwif->hwgroup;
 	/*
@@ -900,6 +903,7 @@
 		hwif->drives[i].disk = NULL;
 		put_disk(disk);
 	}
+	kfree(hwif->sg_table);
 	unregister_blkdev(hwif->major, hwif->name);
 	spin_lock_irq(&ide_lock);
 
@@ -986,9 +990,10 @@
 }
 
 /**
- *	ide_register_hw		-	register IDE interface
+ *	ide_register_hw_with_fixup	-	register IDE interface
  *	@hw: hardware registers
  *	@hwifp: pointer to returned hwif
+ *	@fixup: fixup function
  *
  *	Register an IDE interface, specifying exactly the registers etc.
  *	Set init=1 iff calling before probes have taken place.
@@ -996,7 +1001,7 @@
  *	Returns -1 on error.
  */
 
-int ide_register_hw (hw_regs_t *hw, ide_hwif_t **hwifp)
+int ide_register_hw_with_fixup(hw_regs_t *hw, ide_hwif_t **hwifp, void(*fixup)(ide_hwif_t *hwif))
 {
 	int index, retry = 1;
 	ide_hwif_t *hwif;
@@ -1035,7 +1040,7 @@
 	hwif->chipset = hw->chipset;
 
 	if (!initializing) {
-		probe_hwif_init(hwif);
+		probe_hwif_init_with_fixup(hwif, fixup);
 		create_proc_ide_interfaces();
 	}
 
@@ -1045,6 +1050,13 @@
 	return (initializing || hwif->present) ? index : -1;
 }
 
+EXPORT_SYMBOL(ide_register_hw_with_fixup);
+
+int ide_register_hw(hw_regs_t *hw, ide_hwif_t **hwifp)
+{
+	return ide_register_hw_with_fixup(hw, hwifp, NULL);
+}
+
 EXPORT_SYMBOL(ide_register_hw);
 
 /*
@@ -1775,9 +1787,6 @@
 	return 0;	/* zero = nothing matched */
 }
 
-#ifdef CONFIG_BLK_DEV_PDC4030
-static int __initdata probe_pdc4030;
-#endif
 #ifdef CONFIG_BLK_DEV_ALI14XX
 static int __initdata probe_ali14xx;
 extern int ali14xx_init(void);
@@ -1837,7 +1846,7 @@
 #endif /* CONFIG_BLK_DEV_IDEDOUBLER */
 
 	if (!strcmp(s, "ide=nodma")) {
-		printk("IDE: Prevented DMA\n");
+		printk(" : Prevented DMA\n");
 		noautodma = 1;
 		return 1;
 	}
@@ -1856,7 +1865,7 @@
 	if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) {
 		const char *hd_words[] = {
 			"none", "noprobe", "nowerr", "cdrom", "serialize",
-			"autotune", "noautotune", "stroke", "swapdata", "bswap",
+			"autotune", "noautotune", "minus8", "swapdata", "bswap",
 			"minus11", "remap", "remap63", "scsi", NULL };
 		unit = s[2] - 'a';
 		hw   = unit / MAX_DRIVES;
@@ -1886,13 +1895,10 @@
 				goto do_serialize;
 			case -6: /* "autotune" */
 				drive->autotune = IDE_TUNE_AUTO;
-				goto done;
+				goto obsolete_option;
 			case -7: /* "noautotune" */
 				drive->autotune = IDE_TUNE_NOAUTO;
-				goto done;
-			case -8: /* stroke */
-				drive->stroke = 1;
-				goto done;
+				goto obsolete_option;
 			case -9: /* "swapdata" */
 			case -10: /* "bswap" */
 				drive->bswap = 1;
@@ -1946,7 +1952,7 @@
 			"noprobe", "serialize", "autotune", "noautotune", 
 			"reset", "dma", "ata66", "minus8", "minus9",
 			"minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb",
-			"dtc2278", "umc8672", "ali14xx", "dc4030", NULL };
+			"dtc2278", "umc8672", "ali14xx", NULL };
 		hw = s[3] - '0';
 		hwif = &ide_hwifs[hw];
 		i = match_parm(&s[4], ide_words, vals, 3);
@@ -1972,11 +1978,6 @@
 		}
 
 		switch (i) {
-#ifdef CONFIG_BLK_DEV_PDC4030
-			case -18: /* "dc4030" */
-				probe_pdc4030 = 1;
-				goto done;
-#endif
 #ifdef CONFIG_BLK_DEV_ALI14XX
 			case -17: /* "ali14xx" */
 				probe_ali14xx = 1;
@@ -2029,30 +2030,30 @@
 			case -7: /* ata66 */
 #ifdef CONFIG_BLK_DEV_IDEPCI
 				hwif->udma_four = 1;
-				goto done;
+				goto obsolete_option;
 #else
 				goto bad_hwif;
 #endif
 			case -6: /* dma */
 				hwif->autodma = 1;
-				goto done;
+				goto obsolete_option;
 			case -5: /* "reset" */
 				hwif->reset = 1;
-				goto done;
+				goto obsolete_option;
 			case -4: /* "noautotune" */
 				hwif->drives[0].autotune = IDE_TUNE_NOAUTO;
 				hwif->drives[1].autotune = IDE_TUNE_NOAUTO;
-				goto done;
+				goto obsolete_option;
 			case -3: /* "autotune" */
 				hwif->drives[0].autotune = IDE_TUNE_AUTO;
 				hwif->drives[1].autotune = IDE_TUNE_AUTO;
-				goto done;
+				goto obsolete_option;
 			case -2: /* "serialize" */
 			do_serialize:
 				hwif->mate = &ide_hwifs[hw^1];
 				hwif->mate->mate = hwif;
 				hwif->serialized = hwif->mate->serialized = 1;
-				goto done;
+				goto obsolete_option;
 
 			case -1: /* "noprobe" */
 				hwif->noprobe = 1;
@@ -2069,7 +2070,7 @@
 				hwif->irq      = vals[2];
 				hwif->noprobe  = 0;
 				hwif->chipset  = ide_forced;
-				goto done;
+				goto obsolete_option;
 
 			case 0: goto bad_option;
 			default:
@@ -2080,6 +2081,9 @@
 bad_option:
 	printk(" -- BAD OPTION\n");
 	return 1;
+obsolete_option:
+	printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n");
+	return 1;
 bad_hwif:
 	printk("-- NOT SUPPORTED ON ide%d", hw);
 done:
@@ -2111,13 +2115,6 @@
 		ide_probe_for_cmd640x();
 	}
 #endif /* CONFIG_BLK_DEV_CMD640 */
-#ifdef CONFIG_BLK_DEV_PDC4030
-	{
-		extern int pdc4030_init(void);
-		if (probe_pdc4030)
-			(void)pdc4030_init();
-	}
-#endif /* CONFIG_BLK_DEV_PDC4030 */
 #ifdef CONFIG_BLK_DEV_IDE_PMAC
 	{
 		extern void pmac_ide_probe(void);
@@ -2477,7 +2474,7 @@
 
 #ifdef MODULE
 char *options = NULL;
-MODULE_PARM(options,"s");
+module_param(options, charp, 0);
 MODULE_LICENSE("GPL");
 
 static void __init parse_options (char *line)
diff -Nru a/drivers/ide/legacy/Makefile b/drivers/ide/legacy/Makefile
--- a/drivers/ide/legacy/Makefile	2004-12-24 13:36:19 -08:00
+++ b/drivers/ide/legacy/Makefile	2004-12-24 13:36:19 -08:00
@@ -2,7 +2,6 @@
 obj-$(CONFIG_BLK_DEV_ALI14XX)		+= ali14xx.o
 obj-$(CONFIG_BLK_DEV_DTC2278)		+= dtc2278.o
 obj-$(CONFIG_BLK_DEV_HT6560B)		+= ht6560b.o
-obj-$(CONFIG_BLK_DEV_PDC4030)		+= pdc4030.o
 obj-$(CONFIG_BLK_DEV_QD65XX)		+= qd65xx.o
 obj-$(CONFIG_BLK_DEV_UMC8672)		+= umc8672.o
 
diff -Nru a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
--- a/drivers/ide/legacy/ali14xx.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/ide/legacy/ali14xx.c	2004-12-24 13:36:30 -08:00
@@ -226,6 +226,8 @@
 	probe_hwif_init(hwif);
 	probe_hwif_init(mate);
 
+	create_proc_ide_interfaces();
+
 	return 0;
 }
 
diff -Nru a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c
--- a/drivers/ide/legacy/dtc2278.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/ide/legacy/dtc2278.c	2004-12-24 13:36:32 -08:00
@@ -141,6 +141,8 @@
 	probe_hwif_init(hwif);
 	probe_hwif_init(mate);
 
+	create_proc_ide_interfaces();
+
 	return 0;
 }
 
diff -Nru a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c
--- a/drivers/ide/legacy/hd.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/ide/legacy/hd.c	2004-12-24 13:37:43 -08:00
@@ -174,7 +174,7 @@
 }
 #endif
 
-void __init hd_setup(char *str, int *ints)
+static void __init hd_setup(char *str, int *ints)
 {
 	int hdind = 0;
 
@@ -239,7 +239,7 @@
 #endif
 }
 
-void check_status(void)
+static void check_status(void)
 {
 	int i = inb_p(HD_STATUS);
 
@@ -386,7 +386,7 @@
  * drive enters "idle", "standby", or "sleep" mode, so if the status looks
  * "good", we just ignore the interrupt completely.
  */
-void unexpected_hd_interrupt(void)
+static void unexpected_hd_interrupt(void)
 {
 	unsigned int stat = inb_p(HD_STATUS);
 
@@ -551,7 +551,7 @@
 	enable_irq(HD_IRQ);
 }
 
-int do_special_op(struct hd_i_struct *disk, struct request *req)
+static int do_special_op(struct hd_i_struct *disk, struct request *req)
 {
 	if (disk->recalibrate) {
 		disk->recalibrate = 0;
diff -Nru a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
--- a/drivers/ide/legacy/ht6560b.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/ide/legacy/ht6560b.c	2004-12-24 13:37:18 -08:00
@@ -352,6 +352,8 @@
 	probe_hwif_init(hwif);
 	probe_hwif_init(mate);
 
+	create_proc_ide_interfaces();
+
 	return 0;
 
 release_region:
diff -Nru a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
--- a/drivers/ide/legacy/ide-cs.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/ide/legacy/ide-cs.c	2004-12-24 13:37:02 -08:00
@@ -206,7 +206,7 @@
     ide_init_hwif_ports(&hw, io, ctl, NULL);
     hw.irq = irq;
     hw.chipset = ide_pci;
-    return ide_register_hw(&hw, NULL);
+    return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave);
 }
 
 /*======================================================================
diff -Nru a/drivers/ide/legacy/pdc4030.c b/drivers/ide/legacy/pdc4030.c
--- a/drivers/ide/legacy/pdc4030.c	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,679 +0,0 @@
-/*  -*- linux-c -*-
- *  linux/drivers/ide/legacy/pdc4030.c		Version 0.90  May 27, 1999
- *
- *  Copyright (C) 1995-2002  Linus Torvalds & authors (see below)
- */
-
-/*
- *  Principal Author/Maintainer:  Peter Denison <promise@pnd-pc.demon.co.uk>
- *
- *  This file provides support for the second port and cache of Promise
- *  IDE interfaces, e.g. DC4030VL, DC4030VL-1 and DC4030VL-2.
- *
- *  Thanks are due to Mark Lord for advice and patiently answering stupid
- *  questions, and all those mugs^H^H^H^Hbrave souls who've tested this,
- *  especially Andre Hedrick.
- *
- *  Version 0.01	Initial version, #include'd in ide.c rather than
- *                      compiled separately.
- *                      Reads use Promise commands, writes as before. Drives
- *                      on second channel are read-only.
- *  Version 0.02        Writes working on second channel, reads on both
- *                      channels. Writes fail under high load. Suspect
- *			transfers of >127 sectors don't work.
- *  Version 0.03        Brought into line with ide.c version 5.27.
- *                      Other minor changes.
- *  Version 0.04        Updated for ide.c version 5.30
- *                      Changed initialization strategy
- *  Version 0.05	Kernel integration.  -ml
- *  Version 0.06	Ooops. Add hwgroup to direct call of ide_intr() -ml
- *  Version 0.07	Added support for DC4030 variants
- *			Secondary interface autodetection
- *  Version 0.08	Renamed to pdc4030.c
- *  Version 0.09	Obsolete - never released - did manual write request
- *			splitting before max_sectors[major][minor] available.
- *  Version 0.10	Updated for 2.1 series of kernels
- *  Version 0.11	Updated for 2.3 series of kernels
- *			Autodetection code added.
- *
- *  Version 0.90	Transition to BETA code. No lost/unexpected interrupts
- */
-
-/*
- * Once you've compiled it in, you'll have to also enable the interface
- * setup routine from the kernel command line, as in 
- *
- *	'linux ide0=dc4030' or 'linux ide1=dc4030'
- *
- * It should now work as a second controller also ('ide1=dc4030') but only
- * if you DON'T have BIOS V4.44, which has a bug. If you have this version
- * and EPROM programming facilities, you need to fix 4 bytes:
- * 	2496:	81	81
- *	2497:	3E	3E
- *	2498:	22	98	*
- *	2499:	06	05	*
- *	249A:	F0	F0
- *	249B:	01	01
- *	...
- *	24A7:	81	81
- *	24A8:	3E	3E
- *	24A9:	22	98	*
- *	24AA:	06	05	*
- *	24AB:	70	70
- *	24AC:	01	01
- *
- * As of January 1999, Promise Technology Inc. have finally supplied me with
- * some technical information which has shed a glimmer of light on some of the
- * problems I was having, especially with writes. 
- *
- * There are still potential problems with the robustness and efficiency of
- * this driver because I still don't understand what the card is doing with
- * interrupts, however, it has been stable for a while with no reports of ill
- * effects.
- */
-
-#define DEBUG_READ
-#define DEBUG_WRITE
-#define __PROMISE_4030
-
-#include <linux/module.h>
-#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/ide.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#include "pdc4030.h"
-
-static ide_startstop_t promise_rw_disk (ide_drive_t *drive, struct request *rq, sector_t block);
-
-/*
- * promise_selectproc() is invoked by ide.c
- * in preparation for access to the specified drive.
- */
-static void promise_selectproc (ide_drive_t *drive)
-{
-	unsigned int number;
-
-	number = (HWIF(drive)->channel << 1) + drive->select.b.unit;
-	HWIF(drive)->OUTB(number, IDE_FEATURE_REG);
-}
-
-/*
- * pdc4030_cmd handles the set of vendor specific commands that are initiated
- * by command F0. They all have the same success/failure notification -
- * 'P' (=0x50) on success, 'p' (=0x70) on failure.
- */
-int pdc4030_cmd(ide_drive_t *drive, u8 cmd)
-{
-	unsigned long timeout;
-	u8 status_val;
-
-	promise_selectproc(drive);	/* redundant? */
-	HWIF(drive)->OUTB(0xF3, IDE_SECTOR_REG);
-	HWIF(drive)->OUTB(cmd, IDE_SELECT_REG);
-	HWIF(drive)->OUTB(PROMISE_EXTENDED_COMMAND, IDE_COMMAND_REG);
-	timeout = HZ * 10;
-	timeout += jiffies;
-	do {
-		if(time_after(jiffies, timeout)) {
-			return 2; /* device timed out */
-		}
-		/* Delays at least 10ms to give interface a chance */
-		mdelay(10);
-		status_val = HWIF(drive)->INB(IDE_SECTOR_REG);
-	} while (status_val != 0x50 && status_val != 0x70);
-
-	if(status_val == 0x50)
-		return 0; /* device returned success */
-	else
-		return 1; /* device returned failure */
-}
-
-/*
- * pdc4030_identify sends a vendor-specific IDENTIFY command to the drive
- */
-int pdc4030_identify(ide_drive_t *drive)
-{
-	return pdc4030_cmd(drive, PROMISE_IDENTIFY);
-}
-
-/*
- * setup_pdc4030()
- * Completes the setup of a Promise DC4030 controller card, once found.
- */
-int __init setup_pdc4030(ide_hwif_t *hwif)
-{
-        ide_drive_t *drive;
-	ide_hwif_t *hwif2;
-	struct dc_ident ident;
-	int i;
-	ide_startstop_t startstop;
-	
-	if (!hwif) return 0;
-
-	drive = &hwif->drives[0];
-	hwif2 = &ide_hwifs[hwif->index+1];
-	if (hwif->chipset == ide_pdc4030) /* we've already been found ! */
-		return 1;
-
-	if (hwif->INB(IDE_NSECTOR_REG) == 0xFF ||
-	    hwif->INB(IDE_SECTOR_REG) == 0xFF) {
-		return 0;
-	}
-	if (IDE_CONTROL_REG)
-		hwif->OUTB(0x08, IDE_CONTROL_REG);
-	if (pdc4030_cmd(drive,PROMISE_GET_CONFIG)) {
-		return 0;
-	}
-	if (ide_wait_stat(&startstop, drive,DATA_READY,BAD_W_STAT,WAIT_DRQ)) {
-		printk(KERN_INFO
-			"%s: Failed Promise read config!\n",hwif->name);
-		return 0;
-	}
-	hwif->ata_input_data(drive, &ident, SECTOR_WORDS);
-	if (ident.id[1] != 'P' || ident.id[0] != 'T') {
-		return 0;
-	}
-	printk(KERN_INFO "%s: Promise caching controller, ",hwif->name);
-	switch(ident.type) {
-		case 0x43:	printk("DC4030VL-2, "); break;
-		case 0x41:	printk("DC4030VL-1, "); break;
-		case 0x40:	printk("DC4030VL, "); break;
-		default:
-			printk("unknown - type 0x%02x - please report!\n"
-			       ,ident.type);
-			printk("Please e-mail the following data to "
-			       "promise@pnd-pc.demon.co.uk along with\n"
-			       "a description of your card and drives:\n");
-			for (i=0; i < 0x90; i++) {
-				printk("%02x ", ((unsigned char *)&ident)[i]);
-				if ((i & 0x0f) == 0x0f) printk("\n");
-			}
-			return 0;
-	}
-	printk("%dKB cache, ",(int)ident.cache_mem);
-	switch(ident.irq) {
-            case 0x00: hwif->irq = 14; break;
-            case 0x01: hwif->irq = 12; break;
-            default:   hwif->irq = 15; break;
-	}
-	printk("on IRQ %d\n",hwif->irq);
-
-	/*
-	 * Once found and identified, we set up the next hwif in the array
-	 * (hwif2 = ide_hwifs[hwif->index+1]) with the same io ports, irq
-	 * and other settings as the main hwif. This gives us two "mated"
-	 * hwifs pointing to the Promise card.
-	 *
-	 * We also have to shift the default values for the remaining
-	 * interfaces "up by one" to make room for the second interface on the
-	 * same set of values.
-	 */
-
-	hwif->chipset	= hwif2->chipset = ide_pdc4030;
-	hwif->mate	= hwif2;
-	hwif2->mate	= hwif;
-	hwif2->channel	= 1;
-	hwif->rqsize	= hwif2->rqsize = 127;
-	hwif->no_lba48 = hwif2->no_lba48 = 1;
-	hwif->selectproc = hwif2->selectproc = &promise_selectproc;
-	hwif->serialized = hwif2->serialized = 1;
-	/* DC4030 hosted drives need their own identify... */
-	hwif->identify = hwif2->identify = &pdc4030_identify;
-
-	/* Override the normal ide disk read/write. */
-	hwif->rw_disk = promise_rw_disk;
-	hwif2->rw_disk = promise_rw_disk;
-
-	/* Shift the remaining interfaces up by one */
-	for (i=MAX_HWIFS-1 ; i > hwif->index+1 ; i--) {
-		ide_hwif_t *h = &ide_hwifs[i];
-
-#ifdef DEBUG
-		printk(KERN_DEBUG "pdc4030: Shifting i/f %d values to i/f %d\n",i-1,i);
-#endif /* DEBUG */
-		ide_init_hwif_ports(&h->hw, (h-1)->io_ports[IDE_DATA_OFFSET], 0, NULL);
-		memcpy(h->io_ports, h->hw.io_ports, sizeof(h->io_ports));
-		h->noprobe = (h-1)->noprobe;
-	}
-	ide_init_hwif_ports(&hwif2->hw, hwif->io_ports[IDE_DATA_OFFSET], 0, NULL);
-	memcpy(hwif2->io_ports, hwif->hw.io_ports, sizeof(hwif2->io_ports));
-	hwif2->irq = hwif->irq;
-	hwif2->hw.irq = hwif->hw.irq = hwif->irq;
-	for (i=0; i<2 ; i++) {
-		hwif->drives[i].io_32bit = 3;
-		hwif2->drives[i].io_32bit = 3;
-		hwif->drives[i].keep_settings = 1;
-		hwif2->drives[i].keep_settings = 1;
-		if (!ident.current_tm[i].cyl)
-			hwif->drives[i].noprobe = 1;
-		if (!ident.current_tm[i+2].cyl)
-			hwif2->drives[i].noprobe = 1;
-	}
-
-	probe_hwif_init(&ide_hwifs[hwif->index]);
-	probe_hwif_init(&ide_hwifs[hwif2->index]);
-
-	return 1;
-}
-
-/*
- * detect_pdc4030()
- * Tests for the presence of a DC4030 Promise card on this interface
- * Returns: 1 if found, 0 if not found
- */
-int __init detect_pdc4030(ide_hwif_t *hwif)
-{
-	ide_drive_t *drive = &hwif->drives[0];
-
-	if (IDE_DATA_REG == 0) { /* Skip test for non-existent interface */
-		return 0;
-	}
-	hwif->OUTB(0xF3, IDE_SECTOR_REG);
-	hwif->OUTB(0x14, IDE_SELECT_REG);
-	hwif->OUTB(PROMISE_EXTENDED_COMMAND, IDE_COMMAND_REG);
-
-	msleep(50);
-
-	if (hwif->INB(IDE_ERROR_REG) == 'P' &&
-	    hwif->INB(IDE_NSECTOR_REG) == 'T' &&
-	    hwif->INB(IDE_SECTOR_REG) == 'I') {
-		return 1;
-	} else {
-		return 0;
-	}
-}
-
-int __init pdc4030_init(void)
-{
-	unsigned int	index;
-	ide_hwif_t	*hwif;
-
-	for (index = 0; index < MAX_HWIFS; index++) {
-		hwif = &ide_hwifs[index];
-		if (hwif->chipset == ide_unknown && detect_pdc4030(hwif)) {
-			if (!setup_pdc4030(hwif))
-				return -ENODEV;
-			return 0;
-		}
-	}
-	return -ENODEV;
-}
-
-#ifdef MODULE
-module_init(pdc4030_init);
-#endif
-
-MODULE_AUTHOR("Peter Denison");
-MODULE_DESCRIPTION("Support of Promise 4030 VLB series IDE chipsets");
-MODULE_LICENSE("GPL");
-
-/*
- * promise_read_intr() is the handler for disk read/multread interrupts
- */
-static ide_startstop_t promise_read_intr (ide_drive_t *drive)
-{
-	unsigned int sectors_left, sectors_avail, nsect;
-	struct request *rq = HWGROUP(drive)->rq;
-	ata_status_t status;
-
-	status.all = HWIF(drive)->INB(IDE_STATUS_REG);
-	if (!OK_STAT(status.all, DATA_READY, BAD_R_STAT))
-		return DRIVER(drive)->error(drive, __FUNCTION__, status.all);
-
-read_again:
-	do {
-		sectors_left = HWIF(drive)->INB(IDE_NSECTOR_REG);
-		HWIF(drive)->INB(IDE_SECTOR_REG);
-	} while (HWIF(drive)->INB(IDE_NSECTOR_REG) != sectors_left);
-	sectors_avail = rq->nr_sectors - sectors_left;
-	if (!sectors_avail)
-		goto read_again;
-
-read_next:
-	nsect = rq->current_nr_sectors;
-	if (nsect > sectors_avail)
-		nsect = sectors_avail;
-	sectors_avail -= nsect;
-
-#ifdef DEBUG_READ
-	printk(KERN_DEBUG "%s: %s: sectors(%lu-%lu), rem=%lu\n",
-			  drive->name, __FUNCTION__,
-			  (unsigned long)rq->sector,
-			  (unsigned long)rq->sector + nsect - 1,
-			  (unsigned long)rq->nr_sectors - nsect);
-#endif /* DEBUG_READ */
-
-	HWIF(drive)->ata_input_data(drive, rq->buffer, nsect * SECTOR_WORDS);
-	rq->buffer += nsect<<9;
-	rq->sector += nsect;
-	rq->errors = 0;
-	rq->nr_sectors -= nsect;
-	if (!rq->current_nr_sectors)
-		DRIVER(drive)->end_request(drive, 1, 0);
-
-/*
- * Now the data has been read in, do the following:
- * 
- * if there are still sectors left in the request, 
- *   if we know there are still sectors available from the interface,
- *     go back and read the next bit of the request.
- *   else if DRQ is asserted, there are more sectors available, so
- *     go back and find out how many, then read them in.
- *   else if BUSY is asserted, we are going to get an interrupt, so
- *     set the handler for the interrupt and just return
- */
-	if (rq->nr_sectors > 0) {
-		if (sectors_avail)
-			goto read_next;
-		status.all = HWIF(drive)->INB(IDE_STATUS_REG);
-		if (status.b.drq)
-			goto read_again;
-		if (status.b.bsy) {
-			if (HWGROUP(drive)->handler != NULL)
-				BUG();
-			ide_set_handler(drive,
-					&promise_read_intr,
-					WAIT_CMD,
-					NULL);
-#ifdef DEBUG_READ
-			printk(KERN_DEBUG "%s: promise_read: waiting for"
-			       "interrupt\n", drive->name);
-#endif /* DEBUG_READ */
-			return ide_started;
-		}
-		printk(KERN_ERR "%s: Eeek! promise_read_intr: sectors left "
-		       "!DRQ !BUSY\n", drive->name);
-		return DRIVER(drive)->error(drive,
-				"promise read intr", status.all);
-	}
-	return ide_stopped;
-}
-
-/*
- * promise_complete_pollfunc()
- * This is the polling function for waiting (nicely!) until drive stops
- * being busy. It is invoked at the end of a write, after the previous poll
- * has finished.
- *
- * Once not busy, the end request is called.
- */
-static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive)
-{
-	ide_hwgroup_t *hwgroup = HWGROUP(drive);
-	struct request *rq = &hwgroup->wrq;
-	struct bio *bio = rq->bio;
-
-	if ((HWIF(drive)->INB(IDE_STATUS_REG)) & BUSY_STAT) {
-		if (time_before(jiffies, hwgroup->poll_timeout)) {
-			if (hwgroup->handler != NULL)
-				BUG();
-			ide_set_handler(drive,
-					&promise_complete_pollfunc,
-					HZ/100,
-					NULL);
-			return ide_started; /* continue polling... */
-		}
-		hwgroup->poll_timeout = 0;
-		printk(KERN_ERR "%s: completion timeout - still busy!\n",
-		       drive->name);
-		return DRIVER(drive)->error(drive, "busy timeout",
-				HWIF(drive)->INB(IDE_STATUS_REG));
-	}
-
-	hwgroup->poll_timeout = 0;
-#ifdef DEBUG_WRITE
-	printk(KERN_DEBUG "%s: Write complete - end_request\n", drive->name);
-#endif /* DEBUG_WRITE */
-
-	bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
-	rq = hwgroup->rq;
-	DRIVER(drive)->end_request(drive, 1, rq->hard_nr_sectors);
-
-	return ide_stopped;
-}
-
-/*
- * promise_multwrite() transfers a block of up to mcount sectors of data
- * to a drive as part of a disk multiple-sector write operation.
- */
-static void promise_multwrite (ide_drive_t *drive, unsigned int mcount)
-{
-	ide_hwgroup_t *hwgroup	= HWGROUP(drive);
-	struct request *rq	= &hwgroup->wrq;
-
-	do {
-		char *buffer;
-		int nsect = rq->current_nr_sectors;
-
-		if (nsect > mcount)
-			nsect = mcount;
-		mcount -= nsect;
-		buffer = rq->buffer;
-
-		rq->sector += nsect;
-		rq->buffer += nsect << 9;
-		rq->nr_sectors -= nsect;
-		rq->current_nr_sectors -= nsect;
-
-		/* Do we move to the next bh after this? */
-		if (!rq->current_nr_sectors) {
-			struct bio *bio = rq->bio;
-
-			/*
-			 * only move to next bio, when we have processed
-			 * all bvecs in this one.
-			 */
-			if (++bio->bi_idx >= bio->bi_vcnt) {
-				bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
-				bio = bio->bi_next;
-			}
-
-			/* end early early we ran out of requests */
-			if (!bio) {
-				mcount = 0;
-			} else {
-				rq->bio = bio;
-				rq->nr_cbio_segments = bio_segments(bio);
-				rq->current_nr_sectors = bio_cur_sectors(bio);
-				rq->hard_cur_sectors = rq->current_nr_sectors;
-			}
-		}
-
-		/*
-		 * Ok, we're all setup for the interrupt
-		 * re-entering us on the last transfer.
-		 */
-		taskfile_output_data(drive, buffer, nsect<<7);
-	} while (mcount);
-}
-
-/*
- * promise_write_pollfunc() is the handler for disk write completion polling.
- */
-static ide_startstop_t promise_write_pollfunc (ide_drive_t *drive)
-{
-	ide_hwgroup_t *hwgroup = HWGROUP(drive);
-	struct request *rq = &hwgroup->wrq;
-	struct bio *bio = rq->bio;
-
-	if (HWIF(drive)->INB(IDE_NSECTOR_REG) != 0) {
-		if (time_before(jiffies, hwgroup->poll_timeout)) {
-			if (hwgroup->handler != NULL)
-				BUG();
-			ide_set_handler(drive,
-					&promise_write_pollfunc,
-					HZ/100,
-					NULL);
-			return ide_started; /* continue polling... */
-		}
-		hwgroup->poll_timeout = 0;
-		printk(KERN_ERR "%s: write timed-out!\n",drive->name);
-		bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
-		return DRIVER(drive)->error(drive, "write timeout",
-				HWIF(drive)->INB(IDE_STATUS_REG));
-	}
-
-	/*
-	 * Now write out last 4 sectors and poll for not BUSY
-	 */
-	promise_multwrite(drive, 4);
-	hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
-	if (hwgroup->handler != NULL)
-		BUG();
-	ide_set_handler(drive, &promise_complete_pollfunc, HZ/100, NULL);
-#ifdef DEBUG_WRITE
-	printk(KERN_DEBUG "%s: Done last 4 sectors - status = %02x\n",
-		drive->name, HWIF(drive)->INB(IDE_STATUS_REG));
-#endif /* DEBUG_WRITE */
-	return ide_started;
-}
-
-/*
- * promise_write() transfers a block of one or more sectors of data to a
- * drive as part of a disk write operation. All but 4 sectors are transferred
- * in the first attempt, then the interface is polled (nicely!) for completion
- * before the final 4 sectors are transferred. There is no interrupt generated
- * on writes (at least on the DC4030VL-2), we just have to poll for NOT BUSY.
- */
-static ide_startstop_t promise_write (ide_drive_t *drive)
-{
-	ide_hwgroup_t *hwgroup = HWGROUP(drive);
-	struct request *rq = &hwgroup->wrq;
-
-#ifdef DEBUG_WRITE
-	printk(KERN_DEBUG "%s: %s: sectors(%lu-%lu)\n",
-			  drive->name, __FUNCTION__,
-			  (unsigned long)rq->sector,
-			  (unsigned long)rq->sector + rq->nr_sectors - 1);
-#endif /* DEBUG_WRITE */
-
-	/*
-	 * If there are more than 4 sectors to transfer, do n-4 then go into
-	 * the polling strategy as defined above.
-	 */
-	if (rq->nr_sectors > 4) {
-		promise_multwrite(drive, rq->nr_sectors - 4);
-		hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
-		if (hwgroup->handler != NULL)	/* paranoia check */
-			BUG();
-		ide_set_handler (drive, &promise_write_pollfunc, HZ/100, NULL);
-		return ide_started;
-	} else {
-	/*
-	 * There are 4 or fewer sectors to transfer, do them all in one go
-	 * and wait for NOT BUSY.
-	 */
-		promise_multwrite(drive, rq->nr_sectors);
-		hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
-		if (hwgroup->handler != NULL)
-			BUG();
-		ide_set_handler(drive,
-				&promise_complete_pollfunc,
-				HZ/100,
-				NULL);
-
-#ifdef DEBUG_WRITE
-		printk(KERN_DEBUG "%s: promise_write: <= 4 sectors, "
-			"status = %02x\n", drive->name,
-			HWIF(drive)->INB(IDE_STATUS_REG));
-#endif /* DEBUG_WRITE */
-		return ide_started;
-	}
-}
-
-/*
- * do_pdc4030_io() is called from promise_rw_disk, having had the block number
- * already set up. It issues a READ or WRITE command to the Promise
- * controller, assuming LBA has been used to set up the block number.
- */
-ide_startstop_t do_pdc4030_io (ide_drive_t *drive, struct request *rq)
-{
-	ide_startstop_t startstop;
-	unsigned long timeout;
-	u8 stat = 0;
-
-	if (rq_data_dir(rq) == READ) {
-		HWIF(drive)->OUTB(PROMISE_READ, IDE_COMMAND_REG);
-/*
- * The card's behaviour is odd at this point. If the data is
- * available, DRQ will be true, and no interrupt will be
- * generated by the card. If this is the case, we need to call the 
- * "interrupt" handler (promise_read_intr) directly. Otherwise, if
- * an interrupt is going to occur, bit0 of the SELECT register will
- * be high, so we can set the handler the just return and be interrupted.
- * If neither of these is the case, we wait for up to 50ms (badly I'm
- * afraid!) until one of them is.
- */
-		timeout = jiffies + HZ/20; /* 50ms wait */
-		do {
-			stat = HWIF(drive)->INB(IDE_STATUS_REG);
-			if (stat & DRQ_STAT) {
-				udelay(1);
-				return promise_read_intr(drive);
-			}
-			if (HWIF(drive)->INB(IDE_SELECT_REG) & 0x01) {
-#ifdef DEBUG_READ
-				printk(KERN_DEBUG "%s: read: waiting for "
-						"interrupt\n", drive->name);
-#endif /* DEBUG_READ */
-				ide_set_handler(drive,
-						&promise_read_intr,
-						WAIT_CMD,
-						NULL);
-				return ide_started;
-			}
-			udelay(1);
-		} while (time_before(jiffies, timeout));
-
-		printk(KERN_ERR "%s: reading: No DRQ and not "
-				"waiting - Odd!\n", drive->name);
-		return ide_stopped;
-	} else {
-		HWIF(drive)->OUTB(PROMISE_WRITE, IDE_COMMAND_REG);
-		if (ide_wait_stat(&startstop, drive, DATA_READY,
-				drive->bad_wstat, WAIT_DRQ)) {
-			printk(KERN_ERR "%s: no DRQ after issuing "
-				"PROMISE_WRITE\n", drive->name);
-			return startstop;
-	    	}
-		if (!drive->unmask)
-			local_irq_disable();
-		HWGROUP(drive)->wrq = *rq; /* scratchpad */
-		return promise_write(drive);
-	}
-}
-
-static ide_startstop_t promise_rw_disk (ide_drive_t *drive, struct request *rq, sector_t block)
-{
-	/* The four drives on the two logical (one physical) interfaces
-	   are distinguished by writing the drive number (0-3) to the
-	   Feature register.
-	   FIXME: Is promise_selectproc now redundant??
-	*/
-	ide_hwif_t *hwif = HWIF(drive);
-	int drive_number = (hwif->channel << 1) + drive->select.b.unit;
-
-	BUG_ON(rq->nr_sectors > 127);
-
-	if (IDE_CONTROL_REG)
-		hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
-	hwif->OUTB(drive_number, IDE_FEATURE_REG);
-	hwif->OUTB(rq->nr_sectors, IDE_NSECTOR_REG);
-	hwif->OUTB(block,IDE_SECTOR_REG);
-	hwif->OUTB(block>>=8,IDE_LCYL_REG);
-	hwif->OUTB(block>>=8,IDE_HCYL_REG);
-	hwif->OUTB(((block>>8)&0x0f)|drive->select.all,IDE_SELECT_REG);
-
-	return do_pdc4030_io(drive, rq);
-}
diff -Nru a/drivers/ide/legacy/pdc4030.h b/drivers/ide/legacy/pdc4030.h
--- a/drivers/ide/legacy/pdc4030.h	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,70 +0,0 @@
-/*
- *  linux/drivers/ide/legacy/pdc4030.h
- *
- *  Copyright (C) 1995-1998  Linus Torvalds & authors
- */
-
-/*
- * Principal author: Peter Denison <peterd@pnd-pc.demon.co.uk>
- */
-
-#ifndef IDE_PROMISE_H
-#define IDE_PROMISE_H
-
-#include <linux/config.h>
-
-#ifndef CONFIG_BLK_DEV_PDC4030
-# ifdef _IDE_DISK
-
-# define IS_PDC4030_DRIVE (0)	/* auto-NULLs out pdc4030 code */
-
-ide_startstop_t promise_rw_disk(ide_drive_t *, struct request *, unsigned long);
-
-ide_startstop_t promise_rw_disk(ide_drive_t *drive, struct request *rq, unsigned long block)
-{
-        return ide_stopped;
-}
-# endif /* _IDE_DISK */
-#else /* CONFIG_BLK_DEV_PDC4030 */
-# ifdef _IDE_DISK
-#  define IS_PDC4030_DRIVE (HWIF(drive)->chipset == ide_pdc4030)
-
-ide_startstop_t promise_rw_disk(ide_drive_t *, struct request *, unsigned long);
-
-# endif /* _IDE_DISK */
-#endif /* CONFIG_BLK_DEV_PDC4030 */
-
-#ifdef __PROMISE_4030
-#define	PROMISE_EXTENDED_COMMAND	0xF0
-#define	PROMISE_READ			0xF2
-#define	PROMISE_WRITE			0xF3
-/* Extended commands - main command code = 0xf0 */
-#define	PROMISE_GET_CONFIG		0x10
-#define	PROMISE_IDENTIFY		0x20
-
-struct translation_mode {
-	u16	cyl;
-	u8	head;
-	u8	sect;
-};
-
-struct dc_ident {
-	u8	type;
-	u8	unknown1;
-	u8	hw_revision;
-	u8	firmware_major;
-	u8	firmware_minor;
-	u8	bios_address;
-	u8	irq;
-	u8	unknown2;
-	u16	cache_mem;
-	u16	unknown3;
-	u8	id[2];
-	u16	info;
-	struct translation_mode current_tm[4];
-	u8	pad[SECTOR_WORDS*4 - 32];
-};
-
-#endif /* __PROMISE_4030 */
-
-#endif /* IDE_PROMISE_H */
diff -Nru a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
--- a/drivers/ide/legacy/qd65xx.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/ide/legacy/qd65xx.c	2004-12-24 13:36:19 -08:00
@@ -101,7 +101,7 @@
 	spin_unlock_irqrestore(&ide_lock, flags);
 }
 
-u8 __init qd_read_reg (unsigned long reg)
+static u8 __init qd_read_reg (unsigned long reg)
 {
 	unsigned long flags;
 	u8 read;
@@ -429,6 +429,9 @@
 
 		qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA,
 			 &qd6500_tune_drive);
+
+		create_proc_ide_interfaces();
+
 		return 1;
 	}
 
@@ -459,6 +462,8 @@
 				 &qd6580_tune_drive);
 			qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
 
+			create_proc_ide_interfaces();
+
 			return 1;
 		} else {
 			ide_hwif_t *mate;
@@ -476,6 +481,8 @@
 				 QD6580_DEF_DATA2, QD6580_DEF_DATA2,
 				 &qd6580_tune_drive);
 			qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
+
+			create_proc_ide_interfaces();
 
 			return 0; /* no other qd65xx possible */
 		}
diff -Nru a/drivers/ide/legacy/qd65xx.h b/drivers/ide/legacy/qd65xx.h
--- a/drivers/ide/legacy/qd65xx.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/ide/legacy/qd65xx.h	2004-12-24 13:37:31 -08:00
@@ -46,7 +46,7 @@
 
 /* Drive specific timing taken from DOS driver v3.7 */
 
-struct qd65xx_timing_s {
+static struct qd65xx_timing_s {
 	s8	offset;   /* ofset from the beginning of Model Number" */
 	char	model[4];    /* 4 chars from Model number, no conversion */
 	s16	active;   /* active time */
diff -Nru a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c
--- a/drivers/ide/legacy/umc8672.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/ide/legacy/umc8672.c	2004-12-24 13:36:19 -08:00
@@ -161,6 +161,8 @@
 	probe_hwif_init(hwif);
 	probe_hwif_init(mate);
 
+	create_proc_ide_interfaces();
+
 	return 0;
 }
 
diff -Nru a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
--- a/drivers/ide/pci/aec62xx.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/ide/pci/aec62xx.c	2004-12-24 13:37:18 -08:00
@@ -18,52 +18,7 @@
 
 #include "aec62xx.h"
 
-#if defined(DISPLAY_AEC62XX_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 aec62xx_proc = 0;
-
-#define AEC_MAX_DEVS		5
-
-static struct pci_dev *aec_devs[AEC_MAX_DEVS];
-static int n_aec_devs;
-
-static int aec62xx_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	char *chipset_nums[] = {"error", "error", "error", "error",
-				"error", "error", "850UF",   "860",
-				 "860R",   "865",  "865R", "error"  };
-	int len;
-	int i;
-
-	for (i = 0; i < n_aec_devs; i++) {
-		struct pci_dev *dev	= aec_devs[i];
-		unsigned long iobase = pci_resource_start(dev, 4);
-		u8 c0 = 0, c1 = 0, art	= 0;
-
-		c0 = inb(iobase + 0x02);
-		c1 = inb(iobase + 0x0a);
-
-		p += sprintf(p, "\nController: %d\n", i);
-		p += sprintf(p, "Chipset: AEC%s\n", chipset_nums[dev->device]);
-
-		p += sprintf(p, "--------------- Primary Channel "
-				"---------------- Secondary Channel "
-				"-------------\n");
-		(void) pci_read_config_byte(dev, 0x4a, &art);
-		p += sprintf(p, "                %sabled ",
-			(art&0x02)?" en":"dis");
-		p += sprintf(p, "                        %sabled\n",
-			(art&0x04)?" en":"dis");
-		p += sprintf(p, "--------------- drive0 --------- drive1 "
-				"-------- drive0 ---------- drive1 ------\n");
-		p += sprintf(p, "DMA enabled:    %s              %s ",
-			(c0&0x20)?"yes":"no ",(c0&0x40)?"yes":"no ");
-		p += sprintf(p, "            %s               %s\n",
-			(c1&0x20)?"yes":"no ",(c1&0x40)?"yes":"no ");
-
+#if 0
 		if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) {
 			(void) pci_read_config_byte(dev, 0x54, &art);
 			p += sprintf(p, "DMA Mode:       %s(%s)",
@@ -79,59 +34,7 @@
 				(c1&0x40)?((art&0xc0)?"UDMA":" DMA"):" PIO",
 				(art&0x80)?"2":(art&0x40)?"1":"0");
 		} else {
-			/*
-			 * case PCI_DEVICE_ID_ARTOP_ATP860:
-			 * case PCI_DEVICE_ID_ARTOP_ATP860R:
-			 * case PCI_DEVICE_ID_ARTOP_ATP865:
-			 * case PCI_DEVICE_ID_ARTOP_ATP865R:
-			 */
-			(void) pci_read_config_byte(dev, 0x44, &art);
-			p += sprintf(p, "DMA Mode:       %s(%s)",
-				(c0&0x20)?((art&0x07)?"UDMA":" DMA"):" PIO",
-				((art&0x07)==0x07)?"6":
-				((art&0x06)==0x06)?"5":
-				((art&0x05)==0x05)?"4":
-				((art&0x04)==0x04)?"3":
-				((art&0x03)==0x03)?"2":
-				((art&0x02)==0x02)?"1":
-				((art&0x01)==0x01)?"0":"?");
-			p += sprintf(p, "          %s(%s)",
-				(c0&0x40)?((art&0x70)?"UDMA":" DMA"):" PIO",
-				((art&0x70)==0x70)?"6":
-				((art&0x60)==0x60)?"5":
-				((art&0x50)==0x50)?"4":
-				((art&0x40)==0x40)?"3":
-				((art&0x30)==0x30)?"2":
-				((art&0x20)==0x20)?"1":
-				((art&0x10)==0x10)?"0":"?");
-			(void) pci_read_config_byte(dev, 0x45, &art);
-			p += sprintf(p, "         %s(%s)",
-				(c1&0x20)?((art&0x07)?"UDMA":" DMA"):" PIO",
-				((art&0x07)==0x07)?"6":
-				((art&0x06)==0x06)?"5":
-				((art&0x05)==0x05)?"4":
-				((art&0x04)==0x04)?"3":
-				((art&0x03)==0x03)?"2":
-				((art&0x02)==0x02)?"1":
-				((art&0x01)==0x01)?"0":"?");
-			p += sprintf(p, "           %s(%s)\n",
-				(c1&0x40)?((art&0x70)?"UDMA":" DMA"):" PIO",
-				((art&0x70)==0x70)?"6":
-				((art&0x60)==0x60)?"5":
-				((art&0x50)==0x50)?"4":
-				((art&0x40)==0x40)?"3":
-				((art&0x30)==0x30)?"2":
-				((art&0x20)==0x20)?"1":
-				((art&0x10)==0x10)?"0":"?");
-		}
-	}
-	/* p - buffer must be less than 4k! */
-	len = (p - buffer) - offset;
-	*addr = buffer + offset;
-	
-	return len > count ? count : len;
-}
-#endif	/* defined(DISPLAY_AEC62xx_TIMINGS) && defined(CONFIG_PROC_FS) */
+#endif
 
 /*
  * TO DO: active tuning and correction of cards without a bios.
@@ -286,36 +189,16 @@
 	struct hd_driveid *id	= drive->id;
 
 	if ((id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		aec62xx_tune_drive(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
@@ -374,15 +257,6 @@
 		pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
 		printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
 	}
-
-#if defined(DISPLAY_AEC62XX_TIMINGS) && defined(CONFIG_PROC_FS)
-	aec_devs[n_aec_devs++] = dev;
-
-	if (!aec62xx_proc) {
-		aec62xx_proc = 1;
-		ide_pci_create_host_proc("aec62xx", aec62xx_get_info);
-	}
-#endif /* DISPLAY_AEC62XX_TIMINGS && CONFIG_PROC_FS */
 
 	if (bus_speed <= 33)
 		pci_set_drvdata(dev, (void *) aec6xxx_33_base);
diff -Nru a/drivers/ide/pci/aec62xx.h b/drivers/ide/pci/aec62xx.h
--- a/drivers/ide/pci/aec62xx.h	2004-12-24 13:36:49 -08:00
+++ b/drivers/ide/pci/aec62xx.h	2004-12-24 13:36:49 -08:00
@@ -5,15 +5,13 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
-#define DISPLAY_AEC62XX_TIMINGS
-
 struct chipset_bus_clock_list_entry {
 	byte		xfer_speed;
 	byte		chipset_settings;
 	byte		ultra_settings;
 };
 
-struct chipset_bus_clock_list_entry aec6xxx_33_base [] = {
+static struct chipset_bus_clock_list_entry aec6xxx_33_base [] = {
 	{	XFER_UDMA_6,	0x31,	0x07	},
 	{	XFER_UDMA_5,	0x31,	0x06	},
 	{	XFER_UDMA_4,	0x31,	0x05	},
@@ -33,7 +31,7 @@
 	{	0,		0x00,	0x00	}
 };
 
-struct chipset_bus_clock_list_entry aec6xxx_34_base [] = {
+static struct chipset_bus_clock_list_entry aec6xxx_34_base [] = {
 	{	XFER_UDMA_6,	0x41,	0x06	},
 	{	XFER_UDMA_5,	0x41,	0x05	},
 	{	XFER_UDMA_4,	0x41,	0x04	},
diff -Nru a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
--- a/drivers/ide/pci/alim15x3.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/ide/pci/alim15x3.c	2004-12-24 13:36:47 -08:00
@@ -8,6 +8,7 @@
  *  Copyright (C) 1998-2000 Andre Hedrick (andre@linux-ide.org)
  *  May be copied or modified under the terms of the GNU General Public License
  *  Copyright (C) 2002 Alan Cox <alan@redhat.com>
+ *  ALi (now ULi M5228) support by Clear Zhang <Clear.Zhang@ali.com.tw>
  *
  *  (U)DMA capable version of ali 1533/1543(C), 1535(D)
  *
@@ -558,18 +559,19 @@
 }
 
 /**
- *	ali15x3_dma_write	-	do a DMA IDE write
- *	@drive:	drive to issue write for
+ *	ali15x3_dma_setup	-	begin a DMA phase
+ *	@drive:	target device
  *
- *	Returns 1 if the DMA write cannot be performed, zero on 
- *	success.
+ *	Returns 1 if the DMA cannot be performed, zero on success.
  */
- 
-static int ali15x3_dma_write (ide_drive_t *drive)
+
+static int ali15x3_dma_setup(ide_drive_t *drive)
 {
-	if ((m5229_revision < 0xC2) && (drive->media != ide_disk))
-		return 1;	/* try PIO instead of DMA */
-	return __ide_dma_write(drive);
+	if (m5229_revision < 0xC2 && drive->media != ide_disk) {
+		if (rq_data_dir(drive->hwif->hwgroup->rq))
+			return 1;	/* try PIO instead of DMA */
+	}
+	return ide_dma_setup(drive);
 }
 
 /**
@@ -773,7 +775,7 @@
                  * M1543C or newer for DMAing
                  */
                 hwif->ide_dma_check = &ali15x3_config_drive_for_dma;
-                hwif->ide_dma_write = &ali15x3_dma_write;
+		hwif->dma_setup = &ali15x3_dma_setup;
 		if (!noautodma)
 			hwif->autodma = 1;
 		if (!(hwif->udma_four))
@@ -798,8 +800,9 @@
 	s8 irq_routing_table[] = { -1,  9, 3, 10, 4,  5, 7,  6,
 				      1, 11, 0, 12, 0, 14, 0, 15 };
 	int irq = -1;
-	
-	hwif->irq = hwif->channel ? 15 : 14;
+
+	if (hwif->pci_dev->device == PCI_DEVICE_ID_AL_M5229)
+		hwif->irq = hwif->channel ? 15 : 14;
 
 	if (isa_dev) {
 		/*
@@ -888,6 +891,7 @@
 
 static struct pci_device_id alim15x3_pci_tbl[] = {
 	{ PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5229, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5228, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
 	{ 0, },
 };
 MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl);
diff -Nru a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
--- a/drivers/ide/pci/amd74xx.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/ide/pci/amd74xx.c	2004-12-24 13:37:31 -08:00
@@ -416,8 +416,8 @@
 {
 	int i;
 
-	if (!hwif->irq)
-		hwif->irq = hwif->channel ? 15 : 14;
+	if (hwif->irq == 0) /* 0 is bogus but will do for now */
+		hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel);
 
 	hwif->autodma = 0;
 
diff -Nru a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
--- a/drivers/ide/pci/atiixp.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/ide/pci/atiixp.c	2004-12-24 13:36:48 -08:00
@@ -47,102 +47,6 @@
 
 static int save_mdma_mode[4];
 
-#define DISPLAY_ATIIXP_TIMINGS
-
-#if defined(DISPLAY_ATIIXP_TIMINGS) && defined(CONFIG_PROC_FS)
-
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 atiixp_proc;
-static struct pci_dev *bmide_dev;
-
-/**
- *	atiixp_get_info		-	fill in /proc for ATIIXP IDE
- *	@buffer: buffer to fill
- *	@addr: address of user start in buffer
- *	@offset: offset into 'file'
- *	@count: buffer count
- *
- *	Output summary data on the tuning.
- */
-
-static int atiixp_get_info(char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	struct pci_dev *dev = bmide_dev;
-	unsigned long bibma = pci_resource_start(dev, 4);
-	u32 mdma_timing = 0;
-	u16 udma_mode = 0, pio_mode = 0;
-	u8 c0, c1, udma_control = 0;
-
-	p += sprintf(p, "\n                          ATI ");
-	p += sprintf(p, "ATIIXP Ultra100 IDE Chipset.\n");
-
-	pci_read_config_byte(dev, ATIIXP_IDE_UDMA_CONTROL, &udma_control);
-	pci_read_config_word(dev, ATIIXP_IDE_UDMA_MODE, &udma_mode);
-	pci_read_config_word(dev, ATIIXP_IDE_PIO_MODE, &pio_mode);
-	pci_read_config_dword(dev, ATIIXP_IDE_MDMA_TIMING, &mdma_timing);
-
-	/*
-	 * at that point bibma+0x2 et bibma+0xa are byte registers
-	 * to investigate:
-	 */
-	c0 = inb(bibma + 0x02);
-	c1 = inb(bibma + 0x0a);
-
-	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 enabled:   %s              %s "
-			"            %s               %s\n",
-			(udma_control & 0x01) ? "yes" : "no ",
-			(udma_control & 0x02) ? "yes" : "no ",
-			(udma_control & 0x04) ? "yes" : "no ",
-			(udma_control & 0x08) ? "yes" : "no " );
-	p += sprintf(p, "UDMA mode:      %c                %c "
-			"              %c                 %c\n",
-			(udma_control & 0x01) ?
-			((udma_mode & 0x07) + 48) : 'X',
-			(udma_control & 0x02) ?
-			(((udma_mode >> 4) & 0x07) + 48) : 'X',
-			(udma_control & 0x04) ?
-			(((udma_mode >> 8) & 0x07) + 48) : 'X',
-			(udma_control & 0x08) ?
-			(((udma_mode >> 12) & 0x07) + 48) : 'X');
-	p += sprintf(p, "MDMA mode:      %c                %c "
-			"              %c                 %c\n",
-			(save_mdma_mode[0] && (c0 & 0x20)) ?
-			((save_mdma_mode[0] & 0xf) + 48) : 'X',
-			(save_mdma_mode[1] && (c0 & 0x40)) ?
-			((save_mdma_mode[1] & 0xf) + 48) : 'X',
-			(save_mdma_mode[2] && (c1 & 0x20)) ?
-			((save_mdma_mode[2] & 0xf) + 48) : 'X',
-			(save_mdma_mode[3] && (c1 & 0x40)) ?
-			((save_mdma_mode[3] & 0xf) + 48) : 'X');
-	p += sprintf(p, "PIO mode:       %c                %c "
-			"              %c                 %c\n",
-			(c0 & 0x20) ? 'X' : ((pio_mode & 0x07) + 48),
-			(c0 & 0x40) ? 'X' : (((pio_mode >> 4) & 0x07) + 48),
-			(c1 & 0x20) ? 'X' : (((pio_mode >> 8) & 0x07) + 48),
-			(c1 & 0x40) ? 'X' : (((pio_mode >> 12) & 0x07) + 48));
-
-	return p - buffer;	/* => must be less than 4k! */
-}
-#endif  /* defined(DISPLAY_ATIIXP_TIMINGS) && defined(CONFIG_PROC_FS) */
-
 /**
  *	atiixp_ratemask		-	compute rate mask for ATIIXP IDE
  *	@drive: IDE drive to compute for
@@ -357,36 +261,16 @@
 	drive->init_speed = 0;
 
 	if ((id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				if ((id->field_valid & 2) &&
-				    (!atiixp_config_drive_for_dma(drive)))
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!atiixp_config_drive_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!atiixp_config_drive_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (atiixp_config_drive_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		tspeed = ide_get_best_pio_mode(drive, 255, 5, NULL);
 		speed = atiixp_dma_2_pio(XFER_PIO_0 + tspeed) + XFER_PIO_0;
 		hwif->speedproc(drive, speed);
@@ -397,27 +281,6 @@
 }
 
 /**
- *	init_chipset_atiixp	-	set up the ATIIXP chipset
- *	@dev: PCI device to set up
- *	@name: Name of the device
- *
- *	Initialize the PCI device as required. For the ATIIXP this turns
- *	out to be nice and simple
- */
-
-static unsigned int __devinit init_chipset_atiixp(struct pci_dev *dev, const char *name)
-{
-#if defined(DISPLAY_ATIIXP_TIMINGS) && defined(CONFIG_PROC_FS)
-	if (!atiixp_proc) {
-		atiixp_proc = 1;
-		bmide_dev = dev;
-		ide_pci_create_host_proc("atiixp", atiixp_get_info);
-	}
-#endif /* DISPLAY_ATIIXP_TIMINGS && CONFIG_PROC_FS */
-	return 0;
-}
-
-/**
  *	init_hwif_atiixp		-	fill in the hwif for the ATIIXP
  *	@hwif: IDE interface
  *
@@ -459,7 +322,6 @@
 static ide_pci_device_t atiixp_pci_info[] __devinitdata = {
 	{	/* 0 */
 		.name		= "ATIIXP",
-		.init_chipset	= init_chipset_atiixp,
 		.init_hwif	= init_hwif_atiixp,
 		.channels	= 2,
 		.autodma	= AUTODMA,
@@ -485,6 +347,7 @@
 
 static struct pci_device_id atiixp_pci_tbl[] = {
 	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP2_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{ 0, },
 };
 MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl);
diff -Nru a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
--- a/drivers/ide/pci/cmd64x.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/ide/pci/cmd64x.c	2004-12-24 13:37:19 -08:00
@@ -441,36 +441,16 @@
 	struct hd_driveid *id	= drive->id;
 
 	if ((id != NULL) && ((id->capability & 1) != 0) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if ((id->field_valid & 4) && cmd64x_ratemask(drive)) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		config_chipset_for_pio(drive, 1);
 		return hwif->ide_dma_off_quietly(drive);
 	}
diff -Nru a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
--- a/drivers/ide/pci/cs5520.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/ide/pci/cs5520.c	2004-12-24 13:36:18 -08:00
@@ -51,57 +51,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#define DISPLAY_CS5520_TIMINGS
-
-#if defined(DISPLAY_CS5520_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 cs5520_proc = 0;
-static struct pci_dev *bmide_dev;
-
-static int cs5520_get_info(char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	unsigned long bmiba = pci_resource_start(bmide_dev, 2);
-	int len;
-	u8 c0 = 0, c1 = 0;
-	u16 reg16;
-	u32 reg32;
-
-	/*
-	 * at that point bibma+0x2 et bibma+0xa are byte registers
-	 * to investigate:
-	 */
-	c0 = inb(bmiba + 0x02);
-	c1 = inb(bmiba + 0x0a);
-	
-	p += sprintf(p, "\nCyrix CS55x0 IDE\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, "\n\nTimings: \n");
-	
-	pci_read_config_word(bmide_dev, 0x62, &reg16);
-	p += sprintf(p, "8bit CAT/CRT   : %04x\n", reg16);
-	pci_read_config_dword(bmide_dev, 0x64, &reg32);
-	p += sprintf(p, "16bit Primary  : %08x\n", reg32);
-	pci_read_config_dword(bmide_dev, 0x68, &reg32);
-	p += sprintf(p, "16bit Secondary: %08x\n", reg32);
-	
-	len = (p - buffer) - offset;
-	*addr = buffer + offset;
-	
-	return len > count ? count : len;
-}
-
-#endif
-
 struct pio_clocks
 {
 	int address;
@@ -109,7 +58,7 @@
 	int recovery;
 };
 
-struct pio_clocks cs5520_pio_clocks[]={
+static struct pio_clocks cs5520_pio_clocks[]={
 	{3, 6, 11},
 	{2, 5, 6},
 	{1, 4, 3},
@@ -144,12 +93,14 @@
 	printk("PIO clocking = %d\n", pio);
 	
 	/* FIXME: if DMA = 1 do we need to set the DMA bit here ? */
-	
-	/* 8bit command timing for channel */
+
+	/* 8bit CAT/CRT - 8bit command timing for channel */
 	pci_write_config_byte(pdev, 0x62 + controller, 
 		(cs5520_pio_clocks[pio].recovery << 4) |
 		(cs5520_pio_clocks[pio].assert));
-		
+
+	/* 0x64 - 16bit Primary, 0x68 - 16bit Secondary */
+
 	/* FIXME: should these use address ? */
 	/* Data read timing */
 	pci_write_config_byte(pdev, 0x64 + 4*controller + (drive->dn&1),
@@ -188,19 +139,6 @@
 	/* Then tell the core to use DMA operations */
 	return hwif->ide_dma_on(drive);
 }
-	
-	
-static unsigned int __devinit init_chipset_cs5520(struct pci_dev *dev, const char *name)
-{
-#if defined(DISPLAY_CS5520_TIMINGS) && defined(CONFIG_PROC_FS)
-	if (!cs5520_proc) {
-		cs5520_proc = 1;
-		bmide_dev = dev;
-		ide_pci_create_host_proc("cs5520", cs5520_get_info);
-	}
-#endif /* DISPLAY_CS5520_TIMINGS && CONFIG_PROC_FS */
-	return 0;
-}
 
 /*
  *	We provide a callback for our nonstandard DMA location
@@ -255,7 +193,6 @@
 #define DECLARE_CS_DEV(name_str)				\
 	{							\
 		.name		= name_str,			\
-		.init_chipset	= init_chipset_cs5520,		\
 		.init_setup_dma = cs5520_init_setup_dma,	\
 		.init_hwif	= init_hwif_cs5520,		\
 		.channels	= 2,				\
@@ -294,7 +231,6 @@
 		printk(KERN_WARNING "cs5520: No suitable DMA available.\n");
 		return -ENODEV;
 	}
-	init_chipset_cs5520(dev, d->name);
 
 	index.all = 0xf0f0;
 
@@ -303,10 +239,8 @@
 	 *	do all the device setup for us
 	 */
 
-	ide_pci_setup_ports(dev, d, 1, 14, &index);
+	ide_pci_setup_ports(dev, d, 14, &index);
 
-	printk("Index.b %d %d\n", index.b.low, index.b.high);
-	mdelay(2000);
 	if((index.b.low & 0xf0) != 0xf0)
 		probe_hwif_init(&ide_hwifs[index.b.low]);
 	if((index.b.high & 0xf0) != 0xf0)
diff -Nru a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
--- a/drivers/ide/pci/cs5530.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/ide/pci/cs5530.c	2004-12-24 13:36:47 -08:00
@@ -31,56 +31,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#define DISPLAY_CS5530_TIMINGS
-
-#if defined(DISPLAY_CS5530_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 cs5530_proc = 0;
-
-static struct pci_dev *bmide_dev;
-
-static int cs5530_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	unsigned long 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((u16)bibma + 0x02);
-	c1 = inb_p((u16)bibma + 0x0a);
-
-	p += sprintf(p, "\n                                "
-			"Cyrix 5530 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;
-}
-#endif /* DISPLAY_CS5530_TIMINGS && CONFIG_PROC_FS */
-
 /**
  *	cs5530_xfer_set_mode	-	set a new transfer mode at the drive
  *	@drive: drive to tune
@@ -272,14 +222,6 @@
 	struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
 	unsigned long flags;
 
-#if defined(DISPLAY_CS5530_TIMINGS) && defined(CONFIG_PROC_FS)
-	if (!cs5530_proc) {
-		cs5530_proc = 1;
-		bmide_dev = dev;
-		ide_pci_create_host_proc("cs5530", cs5530_get_info);
-	}
-#endif /* DISPLAY_CS5530_TIMINGS && CONFIG_PROC_FS */
-
 	dev = NULL;
 	while ((dev = pci_find_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) {
 		switch (dev->device) {
@@ -411,7 +353,6 @@
 	.channels	= 2,
 	.autodma	= AUTODMA,
 	.bootable	= ON_BOARD,
-	.flags		= IDEPCI_FLAG_FORCE_MASTER,
 };
 
 static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)
diff -Nru a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
--- a/drivers/ide/pci/cy82c693.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/ide/pci/cy82c693.c	2004-12-24 13:36:19 -08:00
@@ -183,7 +183,7 @@
 /* 
  * used to set DMA mode for CY82C693 (single and multi modes)
  */
-int cy82c693_ide_dma_on (ide_drive_t *drive)
+static int cy82c693_ide_dma_on (ide_drive_t *drive)
 {
 	struct hd_driveid *id = drive->id;
 
diff -Nru a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
--- a/drivers/ide/pci/generic.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/ide/pci/generic.c	2004-12-24 13:36:55 -08:00
@@ -41,12 +41,12 @@
 
 #include "generic.h"
 
-static unsigned int __init init_chipset_generic (struct pci_dev *dev, const char *name)
+static unsigned int __devinit init_chipset_generic (struct pci_dev *dev, const char *name)
 {
 	return 0;
 }
 
-static void __init init_hwif_generic (ide_hwif_t *hwif)
+static void __devinit init_hwif_generic (ide_hwif_t *hwif)
 {
 	switch(hwif->pci_dev->device) {
 		case PCI_DEVICE_ID_UMC_UM8673F:
diff -Nru a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
--- a/drivers/ide/pci/hpt34x.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/ide/pci/hpt34x.c	2004-12-24 13:36:47 -08:00
@@ -42,7 +42,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#include "hpt34x.h"
+#define HPT343_DEBUG_DRIVE_INFO		0
 
 static u8 hpt34x_ratemask (ide_drive_t *drive)
 {
@@ -69,7 +69,8 @@
 	u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0;
 	u8			hi_speed, lo_speed;
 
-	SPLIT_BYTE(speed, hi_speed, lo_speed);
+	hi_speed = speed >> 4;
+	lo_speed = speed & 0x0f;
 
 	if (hi_speed & 7) {
 		hi_speed = (hi_speed & 4) ? 0x01 : 0x10;
@@ -130,40 +131,20 @@
 	drive->init_speed = 0;
 
 	if (id && (id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
-		}
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
 #ifndef CONFIG_HPT34X_AUTODMA
-		return hwif->ide_dma_off_quietly(drive);
+				return hwif->ide_dma_off_quietly(drive);
 #else
-		return hwif->ide_dma_on(drive);
+				return hwif->ide_dma_on(drive);
 #endif
+		}
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		hpt34x_tune_drive(drive, 255);
 		return hwif->ide_dma_off_quietly(drive);
 	}
@@ -249,9 +230,19 @@
 	hwif->drives[1].autodma = hwif->autodma;
 }
 
+static ide_pci_device_t hpt34x_chipset __devinitdata = {
+	.name		= "HPT34X",
+	.init_chipset	= init_chipset_hpt34x,
+	.init_hwif	= init_hwif_hpt34x,
+	.channels	= 2,
+	.autodma	= NOAUTODMA,
+	.bootable	= NEVER_BOARD,
+	.extra		= 16
+};
+
 static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_pci_device_t *d = &hpt34x_chipsets[id->driver_data];
+	ide_pci_device_t *d = &hpt34x_chipset;
 	static char *chipset_names[] = {"HPT343", "HPT345"};
 	u16 pcicmd = 0;
 
diff -Nru a/drivers/ide/pci/hpt34x.h b/drivers/ide/pci/hpt34x.h
--- a/drivers/ide/pci/hpt34x.h	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,29 +0,0 @@
-#ifndef HPT34X_H
-#define HPT34X_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define HPT343_DEBUG_DRIVE_INFO		0
-
-#ifndef SPLIT_BYTE
-#define SPLIT_BYTE(B,H,L)	((H)=(B>>4), (L)=(B-((B>>4)<<4)))
-#endif
-
-static unsigned int init_chipset_hpt34x(struct pci_dev *, const char *);
-static void init_hwif_hpt34x(ide_hwif_t *);
-
-static ide_pci_device_t hpt34x_chipsets[] __devinitdata = {
-	{	/* 0 */
-		.name		= "HPT34X",
-		.init_chipset	= init_chipset_hpt34x,
-		.init_hwif	= init_hwif_hpt34x,
-		.channels	= 2,
-		.autodma	= NOAUTODMA,
-		.bootable	= NEVER_BOARD,
-		.extra		= 16
-	}
-};
-
-#endif /* HPT34X_H */
diff -Nru a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
--- a/drivers/ide/pci/hpt366.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/ide/pci/hpt366.c	2004-12-24 13:37:43 -08:00
@@ -72,49 +72,6 @@
 
 #include "hpt366.h"
 
-#if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-#endif  /* defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS) */
-
-static unsigned int hpt_revision(struct pci_dev *dev);
-static unsigned int hpt_minimum_revision(struct pci_dev *dev, int revision);
-
-#if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
-
-static u8 hpt366_proc = 0;
-static struct pci_dev *hpt_devs[HPT366_MAX_DEVS];
-static int n_hpt_devs;
-
-static int hpt366_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p	= buffer;
-	char *chipset_nums[] = {"366", "366",  "368",
-				"370", "370A", "372",
-				"302", "371",  "374" };
-	int i, len;
-
-	p += sprintf(p, "\n                             "
-		"HighPoint HPT366/368/370/372/374\n");
-	for (i = 0; i < n_hpt_devs; i++) {
-		struct pci_dev *dev = hpt_devs[i];
-		unsigned long iobase = dev->resource[4].start;
-		u32 class_rev = hpt_revision(dev);
-		u8 c0, c1;
-
-		p += sprintf(p, "\nController: %d\n", i);
-		p += sprintf(p, "Chipset: HPT%s\n", chipset_nums[class_rev]);
-		p += sprintf(p, "--------------- Primary Channel "
-				"--------------- Secondary Channel "
-				"--------------\n");
-
-		/* get the bus master status registers */
-		c0 = inb(iobase + 0x2);
-		c1 = inb(iobase + 0xa);
-		p += sprintf(p, "Enabled:        %s"
-				"                             %s\n",
-			(c0 & 0x80) ? "no" : "yes",
-			(c1 & 0x80) ? "no" : "yes");
 #if 0
 		if (hpt_minimum_revision(dev, 3)) {
 			u8 cbl;
@@ -128,16 +85,6 @@
 				(cbl & 0x01) ? 33 : 66);
 			p += sprintf(p, "\n");
 		}
-#endif
-		p += sprintf(p, "--------------- drive0 --------- drive1 "
-				"------- drive0 ---------- drive1 -------\n");
-		p += sprintf(p, "DMA capable:    %s              %s" 
-				"            %s               %s\n",
-			(c0 & 0x20) ? "yes" : "no ", 
-			(c0 & 0x40) ? "yes" : "no ",
-			(c1 & 0x20) ? "yes" : "no ", 
-			(c1 & 0x40) ? "yes" : "no ");
-
 		{
 			u8 c2, c3;
 			/* older revs don't have these registers mapped 
@@ -159,15 +106,7 @@
 					(c3 & 0x80) ? "PIO " : "off ");
 		}
 	}
-	p += sprintf(p, "\n");
-
-	/* p - buffer must be less than 4k! */
-	len = (p - buffer) - offset;
-	*addr = buffer + offset;
-	
-	return len > count ? count : len;
-}
-#endif  /* defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS) */
+#endif
 
 static u32 hpt_revision (struct pci_dev *dev)
 {
@@ -521,35 +460,16 @@
 	drive->init_speed = 0;
 
 	if (id && (id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if (id->dma_mword & hwif->mwdma_mask) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		hpt3xx_tune_drive(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
@@ -577,7 +497,7 @@
 	/* how about we flush and reset, mmmkay? */
 	pci_write_config_byte(dev, 0x51, 0x1F);
 	/* fall through to a reset */
-	case ide_dma_begin:
+	case dma_start:
 	case ide_dma_end:
 	/* reset the chips state over and over.. */
 	pci_write_config_byte(dev, 0x51, 0x13);
@@ -592,12 +512,12 @@
 	udelay(10);
 }
 
-static int hpt370_ide_dma_begin (ide_drive_t *drive)
+static void hpt370_ide_dma_start(ide_drive_t *drive)
 {
 #ifdef HPT_RESET_STATE_ENGINE
 	hpt370_clear_engine(drive);
 #endif
-	return __ide_dma_begin(drive);
+	ide_dma_start(drive);
 }
 
 static int hpt370_ide_dma_end (ide_drive_t *drive)
@@ -1105,15 +1025,6 @@
 	}
 	if (ret)
 		return ret;
-	
-#if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
-	hpt_devs[n_hpt_devs++] = dev;
-
-	if (!hpt366_proc) {
-		hpt366_proc = 1;
-		ide_pci_create_host_proc("hpt366", hpt366_get_info);
-	}
-#endif /* DISPLAY_HPT366_TIMINGS && CONFIG_PROC_FS */
 
 	return dev->irq;
 }
@@ -1230,7 +1141,7 @@
 		hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq;
 		hwif->ide_dma_end = &hpt374_ide_dma_end;
 	} else if (hpt_minimum_revision(dev,3)) {
-		hwif->ide_dma_begin = &hpt370_ide_dma_begin;
+		hwif->dma_start = &hpt370_ide_dma_start;
 		hwif->ide_dma_end = &hpt370_ide_dma_end;
 		hwif->ide_dma_timeout = &hpt370_ide_dma_timeout;
 		hwif->ide_dma_lostirq = &hpt370_ide_dma_lostirq;
diff -Nru a/drivers/ide/pci/hpt366.h b/drivers/ide/pci/hpt366.h
--- a/drivers/ide/pci/hpt366.h	2004-12-24 13:37:02 -08:00
+++ b/drivers/ide/pci/hpt366.h	2004-12-24 13:37:02 -08:00
@@ -5,14 +5,12 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
-#define DISPLAY_HPT366_TIMINGS
-
 /* various tuning parameters */
 #define HPT_RESET_STATE_ENGINE
 #undef HPT_DELAY_INTERRUPT
 #undef HPT_SERIALIZE_IO
 
-const char *quirk_drives[] = {
+static const char *quirk_drives[] = {
 	"QUANTUM FIREBALLlct08 08",
 	"QUANTUM FIREBALLP KA6.4",
 	"QUANTUM FIREBALLP LM20.4",
@@ -20,7 +18,7 @@
         NULL
 };
 
-const char *bad_ata100_5[] = {
+static const char *bad_ata100_5[] = {
 	"IBM-DTLA-307075",
 	"IBM-DTLA-307060",
 	"IBM-DTLA-307045",
@@ -39,7 +37,7 @@
 	NULL
 };
 
-const char *bad_ata66_4[] = {
+static const char *bad_ata66_4[] = {
 	"IBM-DTLA-307075",
 	"IBM-DTLA-307060",
 	"IBM-DTLA-307045",
@@ -58,12 +56,12 @@
 	NULL
 };
 
-const char *bad_ata66_3[] = {
+static const char *bad_ata66_3[] = {
 	"WDC AC310200R",
 	NULL
 };
 
-const char *bad_ata33[] = {
+static const char *bad_ata33[] = {
 	"Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", "Maxtor 90845U3", "Maxtor 90650U2",
 	"Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2",
 	"Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4",
@@ -101,7 +99,7 @@
  *        PIO.
  * 31     FIFO enable.
  */
-struct chipset_bus_clock_list_entry forty_base_hpt366[] = {
+static struct chipset_bus_clock_list_entry forty_base_hpt366[] = {
 	{	XFER_UDMA_4,	0x900fd943	},
 	{	XFER_UDMA_3,	0x900ad943	},
 	{	XFER_UDMA_2,	0x900bd943	},
@@ -120,7 +118,7 @@
 	{	0,		0x0120d9d9	}
 };
 
-struct chipset_bus_clock_list_entry thirty_three_base_hpt366[] = {
+static struct chipset_bus_clock_list_entry thirty_three_base_hpt366[] = {
 	{	XFER_UDMA_4,	0x90c9a731	},
 	{	XFER_UDMA_3,	0x90cfa731	},
 	{	XFER_UDMA_2,	0x90caa731	},
@@ -139,7 +137,7 @@
 	{	0,		0x0120a7a7	}
 };
 
-struct chipset_bus_clock_list_entry twenty_five_base_hpt366[] = {
+static struct chipset_bus_clock_list_entry twenty_five_base_hpt366[] = {
 
 	{	XFER_UDMA_4,	0x90c98521	},
 	{	XFER_UDMA_3,	0x90cf8521	},
@@ -160,7 +158,7 @@
 };
 
 /* from highpoint documentation. these are old values */
-struct chipset_bus_clock_list_entry thirty_three_base_hpt370[] = {
+static struct chipset_bus_clock_list_entry thirty_three_base_hpt370[] = {
 /*	{	XFER_UDMA_5,	0x1A85F442,	0x16454e31	}, */
 	{	XFER_UDMA_5,	0x16454e31	},
 	{	XFER_UDMA_4,	0x16454e31	},
@@ -181,7 +179,7 @@
 	{	0,		0x06514e57	}
 };
 
-struct chipset_bus_clock_list_entry sixty_six_base_hpt370[] = {
+static struct chipset_bus_clock_list_entry sixty_six_base_hpt370[] = {
 	{       XFER_UDMA_5,    0x14846231      },
 	{       XFER_UDMA_4,    0x14886231      },
 	{       XFER_UDMA_3,    0x148c6231      },
@@ -202,7 +200,7 @@
 };
 
 /* these are the current (4 sep 2001) timings from highpoint */
-struct chipset_bus_clock_list_entry thirty_three_base_hpt370a[] = {
+static struct chipset_bus_clock_list_entry thirty_three_base_hpt370a[] = {
         {       XFER_UDMA_5,    0x12446231      },
         {       XFER_UDMA_4,    0x12446231      },
         {       XFER_UDMA_3,    0x126c6231      },
@@ -223,7 +221,7 @@
 };
 
 /* 2x 33MHz timings */
-struct chipset_bus_clock_list_entry sixty_six_base_hpt370a[] = {
+static struct chipset_bus_clock_list_entry sixty_six_base_hpt370a[] = {
 	{       XFER_UDMA_5,    0x1488e673       },
 	{       XFER_UDMA_4,    0x1488e673       },
 	{       XFER_UDMA_3,    0x1498e673       },
@@ -243,7 +241,7 @@
 	{       0,              0x0d02bf5f       }
 };
 
-struct chipset_bus_clock_list_entry fifty_base_hpt370a[] = {
+static struct chipset_bus_clock_list_entry fifty_base_hpt370a[] = {
 	{       XFER_UDMA_5,    0x12848242      },
 	{       XFER_UDMA_4,    0x12ac8242      },
 	{       XFER_UDMA_3,    0x128c8242      },
@@ -263,7 +261,7 @@
 	{       0,              0x0ac1f48a      }
 };
 
-struct chipset_bus_clock_list_entry thirty_three_base_hpt372[] = {
+static struct chipset_bus_clock_list_entry thirty_three_base_hpt372[] = {
 	{	XFER_UDMA_6,	0x1c81dc62	},
 	{	XFER_UDMA_5,	0x1c6ddc62	},
 	{	XFER_UDMA_4,	0x1c8ddc62	},
@@ -284,7 +282,7 @@
 	{	0,		0x0d029d5e	}
 };
 
-struct chipset_bus_clock_list_entry fifty_base_hpt372[] = {
+static struct chipset_bus_clock_list_entry fifty_base_hpt372[] = {
 	{	XFER_UDMA_5,	0x12848242	},
 	{	XFER_UDMA_4,	0x12ac8242	},
 	{	XFER_UDMA_3,	0x128c8242	},
@@ -304,7 +302,7 @@
 	{	0,		0x0a81f443	}
 };
 
-struct chipset_bus_clock_list_entry sixty_six_base_hpt372[] = {
+static struct chipset_bus_clock_list_entry sixty_six_base_hpt372[] = {
 	{	XFER_UDMA_6,	0x1c869c62	},
 	{	XFER_UDMA_5,	0x1cae9c62	},
 	{	XFER_UDMA_4,	0x1c8a9c62	},
@@ -325,7 +323,7 @@
 	{	0,		0x0d029d26	}
 };
 
-struct chipset_bus_clock_list_entry thirty_three_base_hpt374[] = {
+static struct chipset_bus_clock_list_entry thirty_three_base_hpt374[] = {
 	{	XFER_UDMA_6,	0x12808242	},
 	{	XFER_UDMA_5,	0x12848242	},
 	{	XFER_UDMA_4,	0x12ac8242	},
@@ -347,7 +345,7 @@
 };
 
 #if 0
-struct chipset_bus_clock_list_entry fifty_base_hpt374[] = {
+static struct chipset_bus_clock_list_entry fifty_base_hpt374[] = {
 	{	XFER_UDMA_6,	},
 	{	XFER_UDMA_5,	},
 	{	XFER_UDMA_4,	},
@@ -367,7 +365,7 @@
 };
 #endif
 #if 0
-struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = {
+static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = {
 	{	XFER_UDMA_6,	0x12406231	},	/* checkme */
 	{	XFER_UDMA_5,	0x12446231	},
 				0x14846231
diff -Nru a/drivers/ide/pci/it8172.c b/drivers/ide/pci/it8172.c
--- a/drivers/ide/pci/it8172.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/ide/pci/it8172.c	2004-12-24 13:37:18 -08:00
@@ -201,36 +201,16 @@
 	drive->init_speed = 0;
 
 	if (id && (id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = it8172_config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!it8172_config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!it8172_config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (it8172_config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		it8172_tune_drive(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
diff -Nru a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
--- a/drivers/ide/pci/ns87415.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/ide/pci/ns87415.c	2004-12-24 13:36:48 -08:00
@@ -4,6 +4,7 @@
  * Copyright (C) 1997-1998	Mark Lord <mlord@pobox.com>
  * Copyright (C) 1998		Eddie C. Dost <ecd@skynet.be>
  * Copyright (C) 1999-2000	Andre Hedrick <andre@linux-ide.org>
+ * Copyright (C) 2004		Grant Grundler <grundler at parisc-linux.org>
  *
  * Inspired by an earlier effort from David S. Miller <davem@redhat.com>
  */
@@ -25,6 +26,81 @@
 
 #include <asm/io.h>
 
+#ifdef CONFIG_SUPERIO
+/* SUPERIO 87560 is a PoS chip that NatSem denies exists.
+ * Unfortunately, it's built-in on all Astro-based PA-RISC workstations
+ * which use the integrated NS87514 cell for CD-ROM support.
+ * i.e we have to support for CD-ROM installs.
+ * See drivers/parisc/superio.c for more gory details.
+ */
+#include <asm/superio.h>
+
+static unsigned long superio_ide_status[2];
+static unsigned long superio_ide_select[2];
+static unsigned long superio_ide_dma_status[2];
+
+#define SUPERIO_IDE_MAX_RETRIES 25
+
+/* Because of a defect in Super I/O, all reads of the PCI DMA status 
+ * registers, IDE status register and the IDE select register need to be 
+ * retried
+ */
+static u8 superio_ide_inb (unsigned long port)
+{
+	if (port == superio_ide_status[0] ||
+	    port == superio_ide_status[1] ||
+	    port == superio_ide_select[0] ||
+	    port == superio_ide_select[1] ||
+	    port == superio_ide_dma_status[0] ||
+	    port == superio_ide_dma_status[1]) {
+		u8 tmp;
+		int retries = SUPERIO_IDE_MAX_RETRIES;
+
+		/* printk(" [ reading port 0x%x with retry ] ", port); */
+
+		do {
+			tmp = inb(port);
+			if (tmp == 0)
+				udelay(50);
+		} while (tmp == 0 && retries-- > 0);
+
+		return tmp;
+	}
+
+	return inb(port);
+}
+
+static void __devinit superio_ide_init_iops (struct hwif_s *hwif)
+{
+	u32 base, dmabase;
+	u8 tmp;
+	struct pci_dev *pdev = hwif->pci_dev;
+	u8 port = hwif->channel;
+
+	base = pci_resource_start(pdev, port * 2) & ~3;
+	dmabase = pci_resource_start(pdev, 4) & ~3;
+
+	superio_ide_status[port] = base + IDE_STATUS_OFFSET;
+	superio_ide_select[port] = base + IDE_SELECT_OFFSET;
+	superio_ide_dma_status[port] = dmabase + (!port ? 2 : 0xa);
+
+	/* Clear error/interrupt, enable dma */
+	tmp = superio_ide_inb(superio_ide_dma_status[port]);
+	outb(tmp | 0x66, superio_ide_dma_status[port]);
+
+	/* We need to override inb to workaround a SuperIO errata */
+	hwif->INB = superio_ide_inb;
+}
+
+static void __devinit init_iops_ns87415(ide_hwif_t *hwif)
+{
+	if (PCI_SLOT(hwif->pci_dev->devfn) == 0xE) {
+		/* Built-in - assume it's under superio. */
+		superio_ide_init_iops(hwif);
+	}
+}
+#endif
+
 static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 };
 
 /*
@@ -101,22 +177,11 @@
 	return (dma_stat & 7) != 4;
 }
 
-static int ns87415_ide_dma_read (ide_drive_t *drive)
+static int ns87415_ide_dma_setup(ide_drive_t *drive)
 {
 	/* select DMA xfer */
 	ns87415_prepare_drive(drive, 1);
-	if (!(__ide_dma_read(drive)))
-		return 0;
-	/* DMA failed: select PIO xfer */
-	ns87415_prepare_drive(drive, 0);
-	return 1;
-}
-
-static int ns87415_ide_dma_write (ide_drive_t *drive)
-{
-	/* select DMA xfer */
-	ns87415_prepare_drive(drive, 1);
-	if (!(__ide_dma_write(drive)))
+	if (!ide_dma_setup(drive))
 		return 0;
 	/* DMA failed: select PIO xfer */
 	ns87415_prepare_drive(drive, 0);
@@ -143,10 +208,6 @@
 	hwif->autodma = 0;
 	hwif->selectproc = &ns87415_selectproc;
 
-	/* Set a good latency timer and cache line size value. */
-	(void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
-	/* FIXME: use pci_set_master() to ensure good latency timer value */
-
 	/*
 	 * We cannot probe for IRQ: both ports share common IRQ on INTA.
 	 * Also, leave IRQ masked during drive probing, to prevent infinite
@@ -204,8 +265,7 @@
 		return;
 
 	hwif->OUTB(0x60, hwif->dma_status);
-	hwif->ide_dma_read = &ns87415_ide_dma_read;
-	hwif->ide_dma_write = &ns87415_ide_dma_write;
+	hwif->dma_setup = &ns87415_ide_dma_setup;
 	hwif->ide_dma_check = &ns87415_ide_dma_check;
 	hwif->ide_dma_end = &ns87415_ide_dma_end;
 
@@ -217,6 +277,9 @@
 
 static ide_pci_device_t ns87415_chipset __devinitdata = {
 	.name		= "NS87415",
+#ifdef CONFIG_SUPERIO
+	.init_iops	= init_iops_ns87415,
+#endif
 	.init_hwif	= init_hwif_ns87415,
 	.channels	= 2,
 	.autodma	= AUTODMA,
diff -Nru a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
--- a/drivers/ide/pci/pdc202xx_new.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/ide/pci/pdc202xx_new.c	2004-12-24 13:37:04 -08:00
@@ -41,61 +41,6 @@
 
 #define PDC202_DEBUG_CABLE	0
 
-#if defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 pdcnew_proc = 0;
-#define PDC202_MAX_DEVS		5
-static struct pci_dev *pdc202_devs[PDC202_MAX_DEVS];
-static int n_pdc202_devs;
-
-static char * pdcnew_info(char *buf, struct pci_dev *dev)
-{
-	char *p = buf;
-
-	p += sprintf(p, "\n                                ");
-	switch(dev->device) {
-		case PCI_DEVICE_ID_PROMISE_20277:
-			p += sprintf(p, "SBFastTrak 133 Lite"); break;
-		case PCI_DEVICE_ID_PROMISE_20276:
-			p += sprintf(p, "MBFastTrak 133 Lite"); break;
-		case PCI_DEVICE_ID_PROMISE_20275:
-			p += sprintf(p, "MBUltra133"); break;
-		case PCI_DEVICE_ID_PROMISE_20271:
-			p += sprintf(p, "FastTrak TX2000"); break;
-		case PCI_DEVICE_ID_PROMISE_20270:
-			p += sprintf(p, "FastTrak LP/TX2/TX4"); break;
-		case PCI_DEVICE_ID_PROMISE_20269:
-			p += sprintf(p, "Ultra133 TX2"); break;
-		case PCI_DEVICE_ID_PROMISE_20268:
-			p += sprintf(p, "Ultra100 TX2"); break;
-		default:
-			p += sprintf(p, "Ultra series"); break;
-			break;
-	}
-	p += sprintf(p, " Chipset.\n");
-	return (char *)p;
-}
-
-static int pdcnew_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	int i, len;
-
-	for (i = 0; i < n_pdc202_devs; i++) {
-		struct pci_dev *dev	= pdc202_devs[i];
-		p = pdcnew_info(buffer, dev);
-	}
-	/* p - buffer must be less than 4k! */
-	len = (p - buffer) - offset;
-	*addr = buffer + offset;
-	
-	return len > count ? count : len;
-}
-#endif  /* defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS) */
-
-
 static u8 pdcnew_ratemask (ide_drive_t *drive)
 {
 	u8 mode;
@@ -244,37 +189,16 @@
 	drive->init_speed = 0;
 
 	if (id && (id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			    (id->eide_dma_time < 150)) {
-				goto no_dma_set;
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		hwif->tuneproc(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
@@ -310,68 +234,12 @@
 		HWIF(drive)->channel ? "Secondary" : "Primary");
 }
 
-static void pdcnew_reset_host (ide_hwif_t *hwif)
-{
-//	unsigned long high_16	= hwif->dma_base - (8*(hwif->channel));
-	unsigned long high_16	= hwif->dma_master;
-	u8 udma_speed_flag	= hwif->INB(high_16|0x001f);
-
-	hwif->OUTB((udma_speed_flag | 0x10), (high_16|0x001f));
-	mdelay(100);
-	hwif->OUTB((udma_speed_flag & ~0x10), (high_16|0x001f));
-	mdelay(2000);	/* 2 seconds ?! */
-
-	printk(KERN_WARNING "PDC202XX: %s channel reset.\n",
-		hwif->channel ? "Secondary" : "Primary");
-}
-
-void pdcnew_reset (ide_drive_t *drive)
-{
-	ide_hwif_t *hwif	= HWIF(drive);
-	ide_hwif_t *mate	= hwif->mate;
-	
-	pdcnew_reset_host(hwif);
-	pdcnew_reset_host(mate);
-#if 0
-	/*
-	 * FIXME: Have to kick all the drives again :-/
-	 * What a pain in the ACE!
-	 */
-	if (hwif->present) {
-		u16 hunit = 0;
-		for (hunit = 0; hunit < MAX_DRIVES; ++hunit) {
-			ide_drive_t *hdrive = &hwif->drives[hunit];
-			if (hdrive->present) {
-				if (hwif->ide_dma_check)
-					hwif->ide_dma_check(hdrive);
-				else
-					hwif->tuneproc(hdrive, 5);
-			}
-		}
-	}
-	if (mate->present) {
-		u16 munit = 0;
-		for (munit = 0; munit < MAX_DRIVES; ++munit) {
-			ide_drive_t *mdrive = &mate->drives[munit];
-			if (mdrive->present) {
-				if (mate->ide_dma_check) 
-					mate->ide_dma_check(mdrive);
-				else
-					mate->tuneproc(mdrive, 5);
-			}
-		}
-	}
-#else
-	hwif->tuneproc(drive, 5);
-#endif
-}
-
 #ifdef CONFIG_PPC_PMAC
 static void __devinit apple_kiwi_init(struct pci_dev *pdev)
 {
 	struct device_node *np = pci_device_to_OF_node(pdev);
 	unsigned int class_rev = 0;
-	unsigned long mmio;
+	void __iomem *mmio;
 	u8 conf;
 
 	if (np == NULL || !device_is_compatible(np, "kiwi-root"))
@@ -385,7 +253,7 @@
 		pci_read_config_byte(pdev, 0x40, &conf);
 		pci_write_config_byte(pdev, 0x40, conf | 0x01);
 	}
-	mmio = (unsigned long)ioremap(pci_resource_start(pdev, 5),
+	mmio = ioremap(pci_resource_start(pdev, 5),
 				      pci_resource_len(pdev, 5));
 
 	/* Setup some PLL stuffs */
@@ -400,7 +268,7 @@
 		break;
 	}
 
-	iounmap((void *)mmio);
+	iounmap(mmio);
 }
 #endif /* CONFIG_PPC_PMAC */
 
@@ -416,15 +284,6 @@
 #ifdef CONFIG_PPC_PMAC
 	apple_kiwi_init(dev);
 #endif
-
-#if defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS)
-	pdc202_devs[n_pdc202_devs++] = dev;
-
-	if (!pdcnew_proc) {
-		pdcnew_proc = 1;
-		ide_pci_create_host_proc("pdcnew", pdcnew_get_info);
-	}
-#endif /* DISPLAY_PDC202XX_TIMINGS && CONFIG_PROC_FS */
 
 	return dev->irq;
 }
diff -Nru a/drivers/ide/pci/pdc202xx_new.h b/drivers/ide/pci/pdc202xx_new.h
--- a/drivers/ide/pci/pdc202xx_new.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/ide/pci/pdc202xx_new.h	2004-12-24 13:36:18 -08:00
@@ -43,8 +43,6 @@
 		set_2regs(0x13,(c));			\
 	} while(0)
 
-#define DISPLAY_PDC202XX_TIMINGS
-
 static void init_setup_pdcnew(struct pci_dev *, ide_pci_device_t *);
 static void init_setup_pdc20270(struct pci_dev *, ide_pci_device_t *);
 static void init_setup_pdc20276(struct pci_dev *dev, ide_pci_device_t *d);
diff -Nru a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
--- a/drivers/ide/pci/pdc202xx_old.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/ide/pci/pdc202xx_old.c	2004-12-24 13:37:29 -08:00
@@ -50,68 +50,14 @@
 
 #define PDC202_DEBUG_CABLE	0
 
-#if defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 pdc202xx_proc = 0;
-#define PDC202_MAX_DEVS		5
-static struct pci_dev *pdc202_devs[PDC202_MAX_DEVS];
-static int n_pdc202_devs;
-
-static char * pdc202xx_info (char *buf, struct pci_dev *dev)
-{
-	char *p = buf;
-
+#if 0
 	unsigned long bibma  = pci_resource_start(dev, 4);
-	u32 reg60h = 0, reg64h = 0, reg68h = 0, reg6ch = 0;
-	u16 reg50h = 0, pmask = (1<<10), smask = (1<<11);
 	u8 hi = 0, lo = 0;
 
-        /*
-         * at that point bibma+0x2 et bibma+0xa are byte registers
-         * to investigate:
-         */
-	u8 c0	= inb_p((u16)bibma + 0x02);
-	u8 c1	= inb_p((u16)bibma + 0x0a);
-
-	u8 sc11	= inb_p((u16)bibma + 0x11);
-	u8 sc1a	= inb_p((u16)bibma + 0x1a);
-	u8 sc1b	= inb_p((u16)bibma + 0x1b);
 	u8 sc1c	= inb_p((u16)bibma + 0x1c); 
-	u8 sc1d	= inb_p((u16)bibma + 0x1d);
 	u8 sc1e	= inb_p((u16)bibma + 0x1e);
 	u8 sc1f	= inb_p((u16)bibma + 0x1f);
 
-	pci_read_config_word(dev, 0x50, &reg50h);
-	pci_read_config_dword(dev, 0x60, &reg60h);
-	pci_read_config_dword(dev, 0x64, &reg64h);
-	pci_read_config_dword(dev, 0x68, &reg68h);
-	pci_read_config_dword(dev, 0x6c, &reg6ch);
-
-	p += sprintf(p, "\n                                ");
-	switch(dev->device) {
-		case PCI_DEVICE_ID_PROMISE_20267:
-			p += sprintf(p, "Ultra100"); break;
-		case PCI_DEVICE_ID_PROMISE_20265:
-			p += sprintf(p, "Ultra100 on M/B"); break;
-		case PCI_DEVICE_ID_PROMISE_20263:
-			p += sprintf(p, "FastTrak 66"); break;
-		case PCI_DEVICE_ID_PROMISE_20262:
-			p += sprintf(p, "Ultra66"); break;
-		case PCI_DEVICE_ID_PROMISE_20246:
-			p += sprintf(p, "Ultra33");
-			reg50h |= 0x0c00;
-			break;
-		default:
-			p += sprintf(p, "Ultra Series"); break;
-	}
-	p += sprintf(p, " Chipset.\n");
-
-	p += sprintf(p, "------------------------------- General Status "
-			"---------------------------------\n");
-	p += sprintf(p, "Burst Mode                           : %sabled\n",
-		(sc1f & 0x01) ? "en" : "dis");
 	p += sprintf(p, "Host Mode                            : %s\n",
 		(sc1f & 0x08) ? "Tri-Stated" : "Normal");
 	p += sprintf(p, "Bus Clocking                         : %s\n",
@@ -126,70 +72,7 @@
 	SPLIT_BYTE(sc1e, hi, lo);
 	p += sprintf(p, "Status Polling Period                : %d\n", hi);
 	p += sprintf(p, "Interrupt Check Status Polling Delay : %d\n", lo);
-	p += sprintf(p, "--------------- Primary Channel "
-			"---------------- Secondary Channel "
-			"-------------\n");
-	p += sprintf(p, "                %s                         %s\n",
-		(c0&0x80)?"disabled":"enabled ",
-		(c1&0x80)?"disabled":"enabled ");
-	p += sprintf(p, "66 Clocking     %s                         %s\n",
-		(sc11&0x02)?"enabled ":"disabled",
-		(sc11&0x08)?"enabled ":"disabled");
-	p += sprintf(p, "           Mode %s                      Mode %s\n",
-		(sc1a & 0x01) ? "MASTER" : "PCI   ",
-		(sc1b & 0x01) ? "MASTER" : "PCI   ");
-	p += sprintf(p, "                %s                     %s\n",
-		(sc1d & 0x08) ? "Error       " :
-		((sc1d & 0x05) == 0x05) ? "Not My INTR " :
-		(sc1d & 0x04) ? "Interrupting" :
-		(sc1d & 0x02) ? "FIFO Full   " :
-		(sc1d & 0x01) ? "FIFO Empty  " : "????????????",
-		(sc1d & 0x80) ? "Error       " :
-		((sc1d & 0x50) == 0x50) ? "Not My INTR " :
-		(sc1d & 0x40) ? "Interrupting" :
-		(sc1d & 0x20) ? "FIFO Full   " :
-		(sc1d & 0x10) ? "FIFO Empty  " : "????????????");
-	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, "DMA Mode:       %s           %s "
-			"         %s            %s\n",
-		pdc202xx_ultra_verbose(reg60h, (reg50h & pmask)),
-		pdc202xx_ultra_verbose(reg64h, (reg50h & pmask)),
-		pdc202xx_ultra_verbose(reg68h, (reg50h & smask)),
-		pdc202xx_ultra_verbose(reg6ch, (reg50h & smask)));
-	p += sprintf(p, "PIO Mode:       %s            %s "
-			"          %s            %s\n",
-		pdc202xx_pio_verbose(reg60h),
-		pdc202xx_pio_verbose(reg64h),
-		pdc202xx_pio_verbose(reg68h),
-		pdc202xx_pio_verbose(reg6ch));
-#if 0
-	p += sprintf(p, "--------------- Can ATAPI DMA ---------------\n");
 #endif
-	return (char *)p;
-}
-
-static int pdc202xx_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	int i, len;
-
-	for (i = 0; i < n_pdc202_devs; i++) {
-		struct pci_dev *dev	= pdc202_devs[i];
-		p = pdc202xx_info(buffer, dev);
-	}
-	/* p - buffer must be less than 4k! */
-	len = (p - buffer) - offset;
-	*addr = buffer + offset;
-	
-	return len > count ? count : len;
-}
-#endif  /* defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS) */
-
 
 static u8 pdc202xx_ratemask (ide_drive_t *drive)
 {
@@ -347,7 +230,7 @@
 {
 	u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10);
 	pci_read_config_word(hwif->pci_dev, 0x50, &CIS);
-	return ((u8)(CIS & mask));
+	return (CIS & mask) ? 1 : 0;
 }
 
 /*
@@ -451,37 +334,16 @@
 	drive->init_speed = 0;
 
 	if (id && (id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			    (id->eide_dma_time < 150)) {
-				goto no_dma_set;
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		hwif->tuneproc(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
@@ -494,7 +356,7 @@
 	return ((int) check_in_drive_lists(drive, pdc_quirk_drives));
 }
 
-static int pdc202xx_old_ide_dma_begin(ide_drive_t *drive)
+static void pdc202xx_old_ide_dma_start(ide_drive_t *drive)
 {
 	if (drive->current_speed > XFER_UDMA_2)
 		pdc_old_enable_66MHz_clock(drive->hwif);
@@ -515,7 +377,7 @@
 					word_count | 0x06000000;
 		hwif->OUTL(word_count, atapi_reg);
 	}
-	return __ide_dma_begin(drive);
+	ide_dma_start(drive);
 }
 
 static int pdc202xx_old_ide_dma_end(ide_drive_t *drive)
@@ -546,11 +408,13 @@
 	u8 sc1d			= hwif->INB((high_16 + 0x001d));
 
 	if (hwif->channel) {
+		/* bit7: Error, bit6: Interrupting, bit5: FIFO Full, bit4: FIFO Empty */
 		if ((sc1d & 0x50) == 0x50)
 			goto somebody_else;
 		else if ((sc1d & 0x40) == 0x40)
 			return (dma_stat & 4) == 4;
 	} else {
+		/* bit3: Error, bit2: Interrupting, bit1: FIFO Full, bit0: FIFO Empty */
 		if ((sc1d & 0x05) == 0x05)
 			goto somebody_else;
 		else if ((sc1d & 0x04) == 0x04)
@@ -593,7 +457,7 @@
 		hwif->channel ? "Secondary" : "Primary");
 }
 
-void pdc202xx_reset (ide_drive_t *drive)
+static void pdc202xx_reset (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	ide_hwif_t *mate	= hwif->mate;
@@ -668,15 +532,6 @@
 			name, dev->resource[PCI_ROM_RESOURCE].start);
 	}
 
-#if defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS)
-	pdc202_devs[n_pdc202_devs++] = dev;
-
-	if (!pdc202xx_proc) {
-		pdc202xx_proc = 1;
-		ide_pci_create_host_proc("pdc202xx", pdc202xx_get_info);
-	}
-#endif /* DISPLAY_PDC202XX_TIMINGS && CONFIG_PROC_FS */
-
 	/*
 	 * software reset -  this is required because the bios
 	 * will set UDMA timing on if the hdd supports it. The
@@ -709,7 +564,8 @@
 	struct pci_dev *dev = hwif->pci_dev;
 
 	/* PDC20265 has problems with large LBA48 requests */
-	if (dev->device == PCI_DEVICE_ID_PROMISE_20265)
+	if ((dev->device == PCI_DEVICE_ID_PROMISE_20267) ||
+	    (dev->device == PCI_DEVICE_ID_PROMISE_20265))
 		hwif->rqsize = 256;
 
 	hwif->autodma = 0;
@@ -736,7 +592,7 @@
 	if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) {
 		if (!(hwif->udma_four))
 			hwif->udma_four = (pdc202xx_old_cable_detect(hwif)) ? 0 : 1;
-		hwif->ide_dma_begin = &pdc202xx_old_ide_dma_begin;
+		hwif->dma_start = &pdc202xx_old_ide_dma_start;
 		hwif->ide_dma_end = &pdc202xx_old_ide_dma_end;
 	} 
 	hwif->ide_dma_test_irq = &pdc202xx_old_ide_dma_test_irq;
diff -Nru a/drivers/ide/pci/pdc202xx_old.h b/drivers/ide/pci/pdc202xx_old.h
--- a/drivers/ide/pci/pdc202xx_old.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/ide/pci/pdc202xx_old.h	2004-12-24 13:36:16 -08:00
@@ -23,41 +23,6 @@
 	NULL
 };
 
-static inline u8 *pdc202xx_pio_verbose (u32 drive_pci)
-{
-	if ((drive_pci & 0x000ff000) == 0x000ff000) return("NOTSET");
-	if ((drive_pci & 0x00000401) == 0x00000401) return("PIO 4");
-	if ((drive_pci & 0x00000602) == 0x00000602) return("PIO 3");
-	if ((drive_pci & 0x00000803) == 0x00000803) return("PIO 2");
-	if ((drive_pci & 0x00000C05) == 0x00000C05) return("PIO 1");
-	if ((drive_pci & 0x00001309) == 0x00001309) return("PIO 0");
-	return("PIO ?");
-}
-
-static inline u8 *pdc202xx_dma_verbose (u32 drive_pci)
-{
-	if ((drive_pci & 0x00036000) == 0x00036000) return("MWDMA 2");
-	if ((drive_pci & 0x00046000) == 0x00046000) return("MWDMA 1");
-	if ((drive_pci & 0x00056000) == 0x00056000) return("MWDMA 0");
-	if ((drive_pci & 0x00056000) == 0x00056000) return("SWDMA 2");
-	if ((drive_pci & 0x00068000) == 0x00068000) return("SWDMA 1");
-	if ((drive_pci & 0x000BC000) == 0x000BC000) return("SWDMA 0");
-	return("PIO---");
-}
-
-static inline u8 *pdc202xx_ultra_verbose (u32 drive_pci, u16 slow_cable)
-{
-	if ((drive_pci & 0x000ff000) == 0x000ff000)
-		return("NOTSET");
-	if ((drive_pci & 0x00012000) == 0x00012000)
-		return((slow_cable) ? "UDMA 2" : "UDMA 4");
-	if ((drive_pci & 0x00024000) == 0x00024000)
-		return((slow_cable) ? "UDMA 1" : "UDMA 3");
-	if ((drive_pci & 0x00036000) == 0x00036000)
-		return("UDMA 0");
-	return(pdc202xx_dma_verbose(drive_pci));
-}
-
 /* A Register */
 #define	SYNC_ERRDY_EN	0xC0
 
@@ -97,8 +62,6 @@
 #define	MC2		0x04	/* DMA"C" timing */
 #define	MC1		0x02	/* DMA"C" timing */
 #define	MC0		0x01	/* DMA"C" timing */
-
-#define DISPLAY_PDC202XX_TIMINGS
 
 static void init_setup_pdc202ata4(struct pci_dev *dev, ide_pci_device_t *d);
 static void init_setup_pdc20265(struct pci_dev *, ide_pci_device_t *);
diff -Nru a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
--- a/drivers/ide/pci/piix.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/ide/pci/piix.c	2004-12-24 13:36:17 -08:00
@@ -106,165 +106,6 @@
 #include "piix.h"
 
 static int no_piix_dma;
-#if defined(DISPLAY_PIIX_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 piix_proc = 0;
-#define PIIX_MAX_DEVS		5
-static struct pci_dev *piix_devs[PIIX_MAX_DEVS];
-static int n_piix_devs;
-
-/**
- *	piix_get_info		-	fill in /proc for PIIX ide
- *	@buffer: buffer to fill
- *	@addr: address of user start in buffer
- *	@offset: offset into 'file'
- *	@count: buffer count
- *
- *	Walks the PIIX devices and outputs summary data on the tuning and
- *	anything else that will help with debugging
- */
- 
-static int piix_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	int i;
-
-	for (i = 0; i < n_piix_devs; i++) {
-		struct pci_dev *dev	= piix_devs[i];
-		unsigned long bibma = pci_resource_start(dev, 4);
-	        u16 reg40 = 0, psitre = 0, reg42 = 0, ssitre = 0;
-		u8  c0 = 0, c1 = 0, reg54 = 0, reg55 = 0;
-		u8  reg44 = 0, reg48 = 0, reg4a = 0, reg4b = 0;
-
-		p += sprintf(p, "\nController: %d\n", i);
-		p += sprintf(p, "\n                                Intel ");
-		switch(dev->device) {
-			case PCI_DEVICE_ID_INTEL_82801EB_1:
-				p += sprintf(p, "PIIX4 SATA 150 ");
-				break;
-			case PCI_DEVICE_ID_INTEL_82801BA_8:
-			case PCI_DEVICE_ID_INTEL_82801BA_9:
-			case PCI_DEVICE_ID_INTEL_82801CA_10:
-			case PCI_DEVICE_ID_INTEL_82801CA_11:
-			case PCI_DEVICE_ID_INTEL_82801DB_10:
-			case PCI_DEVICE_ID_INTEL_82801DB_11:
-			case PCI_DEVICE_ID_INTEL_82801EB_11:
-			case PCI_DEVICE_ID_INTEL_82801E_11:
-			case PCI_DEVICE_ID_INTEL_ESB_2:
-			case PCI_DEVICE_ID_INTEL_ICH6_19:
-				p += sprintf(p, "PIIX4 Ultra 100 ");
-				break;
-			case PCI_DEVICE_ID_INTEL_82372FB_1:
-			case PCI_DEVICE_ID_INTEL_82801AA_1:
-				p += sprintf(p, "PIIX4 Ultra 66 ");
-				break;
-			case PCI_DEVICE_ID_INTEL_82451NX:
-			case PCI_DEVICE_ID_INTEL_82801AB_1:
-			case PCI_DEVICE_ID_INTEL_82443MX_1:
-			case PCI_DEVICE_ID_INTEL_82371AB:
-				p += sprintf(p, "PIIX4 Ultra 33 ");
-				break;
-			case PCI_DEVICE_ID_INTEL_82371SB_1:
-				p += sprintf(p, "PIIX3 ");
-				break;
-			case PCI_DEVICE_ID_INTEL_82371MX:
-				p += sprintf(p, "MPIIX ");
-				break;
-			case PCI_DEVICE_ID_INTEL_82371FB_1:
-			case PCI_DEVICE_ID_INTEL_82371FB_0:
-			default:
-				p += sprintf(p, "PIIX ");
-				break;
-		}
-		p += sprintf(p, "Chipset.\n");
-
-		if (dev->device == PCI_DEVICE_ID_INTEL_82371MX)
-			continue;
-
-		pci_read_config_word(dev, 0x40, &reg40);
-		pci_read_config_word(dev, 0x42, &reg42);
-		pci_read_config_byte(dev, 0x44, &reg44);
-		pci_read_config_byte(dev, 0x48, &reg48);
-		pci_read_config_byte(dev, 0x4a, &reg4a);
-		pci_read_config_byte(dev, 0x4b, &reg4b);
-		pci_read_config_byte(dev, 0x54, &reg54);
-		pci_read_config_byte(dev, 0x55, &reg55);
-
-		psitre = (reg40 & 0x4000) ? 1 : 0;
-		ssitre = (reg42 & 0x4000) ? 1 : 0;
-
-		/*
-		 * at that point bibma+0x2 et bibma+0xa are byte registers
-		 * to investigate:
-		 */
-		c0 = inb(bibma + 0x02);
-		c1 = inb(bibma + 0x0a);
-
-		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 enabled:   %s              %s "
-				"            %s               %s\n",
-				(reg48&0x01) ? "yes" : "no ",
-				(reg48&0x02) ? "yes" : "no ",
-				(reg48&0x04) ? "yes" : "no ",
-				(reg48&0x08) ? "yes" : "no " );
-		p += sprintf(p, "UDMA enabled:   %s                %s "
-				"              %s                 %s\n",
-				((reg54&0x11) &&
-				 (reg55&0x10) && (reg4a&0x01)) ? "5" :
-				((reg54&0x11) && (reg4a&0x02)) ? "4" :
-				((reg54&0x11) && (reg4a&0x01)) ? "3" :
-				(reg4a&0x02) ? "2" :
-				(reg4a&0x01) ? "1" :
-				(reg4a&0x00) ? "0" : "X",
-				((reg54&0x22) &&
-				 (reg55&0x20) && (reg4a&0x10)) ? "5" :
-				((reg54&0x22) && (reg4a&0x20)) ? "4" :
-				((reg54&0x22) && (reg4a&0x10)) ? "3" :
-				(reg4a&0x20) ? "2" :
-				(reg4a&0x10) ? "1" :
-				(reg4a&0x00) ? "0" : "X",
-				((reg54&0x44) &&
-				 (reg55&0x40) && (reg4b&0x03)) ? "5" :
-				((reg54&0x44) && (reg4b&0x02)) ? "4" :
-				((reg54&0x44) && (reg4b&0x01)) ? "3" :
-				(reg4b&0x02) ? "2" :
-				(reg4b&0x01) ? "1" :
-				(reg4b&0x00) ? "0" : "X",
-				((reg54&0x88) &&
-				 (reg55&0x80) && (reg4b&0x30)) ? "5" :
-				((reg54&0x88) && (reg4b&0x20)) ? "4" :
-				((reg54&0x88) && (reg4b&0x10)) ? "3" :
-				(reg4b&0x20) ? "2" :
-				(reg4b&0x10) ? "1" :
-				(reg4b&0x00) ? "0" : "X");
-
-		p += sprintf(p, "UDMA\n");
-		p += sprintf(p, "DMA\n");
-		p += sprintf(p, "PIO\n");
-
-		/*
-		 * FIXME.... Add configuration junk data....blah blah......
-		 */
-	}
-	return p-buffer;	 /* => must be less than 4k! */
-}
-#endif  /* defined(DISPLAY_PIIX_TIMINGS) && defined(CONFIG_PROC_FS) */
 
 /**
  *	piix_ratemask		-	compute rate mask for PIIX IDE
@@ -562,25 +403,11 @@
 
 	if ((id->capability & 1) && drive->autodma) {
 
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-
-		/**
-		 * Try to turn DMA on if:
-		 *  - UDMA or EIDE modes are supported or
-		 *  - drive is a known "good" drive
-		 *
-		 * Checks for best mode supported are down later by
-		 * piix_config_drive_for_dma() -> ide_dma_speed()
-		 */
-		if ((id->field_valid & (4 | 2)) ||
-		    (__ide_dma_good_drive(drive) && id->eide_dma_time < 150)) {
+		if (ide_use_dma(drive)) {
 			if (piix_config_drive_for_dma(drive))
 				return hwif->ide_dma_on(drive);
 		}
 
-		/* For some reason DMA wasn't turned on, so try PIO. */
 		goto fast_ata_pio;
 
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
@@ -627,14 +454,6 @@
 			break;
 	}
 
-#if defined(DISPLAY_PIIX_TIMINGS) && defined(CONFIG_PROC_FS)
-	piix_devs[n_piix_devs++] = dev;
-
-	if (!piix_proc) {
-		piix_proc = 1;
-		ide_pci_create_host_proc("piix", piix_get_info);
-	}
-#endif /* DISPLAY_PIIX_TIMINGS && CONFIG_PROC_FS */
 	return 0;
 }
 
diff -Nru a/drivers/ide/pci/piix.h b/drivers/ide/pci/piix.h
--- a/drivers/ide/pci/piix.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/ide/pci/piix.h	2004-12-24 13:36:31 -08:00
@@ -5,10 +5,6 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
-#define PIIX_DEBUG_DRIVE_INFO		0
-
-#define DISPLAY_PIIX_TIMINGS
-
 static void init_setup_piix(struct pci_dev *, ide_pci_device_t *);
 static unsigned int __devinit init_chipset_piix(struct pci_dev *, const char *);
 static void init_hwif_piix(ide_hwif_t *);
diff -Nru a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c
--- a/drivers/ide/pci/rz1000.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/ide/pci/rz1000.c	2004-12-24 13:36:47 -08:00
@@ -33,7 +33,7 @@
 
 #include <asm/io.h>
 
-static void __init init_hwif_rz1000 (ide_hwif_t *hwif)
+static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif)
 {
 	u16 reg;
 	struct pci_dev *dev = hwif->pci_dev;
diff -Nru a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
--- a/drivers/ide/pci/sc1200.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/ide/pci/sc1200.c	2004-12-24 13:37:00 -08:00
@@ -67,61 +67,12 @@
 	return pci_clock;
 }
 
-#define DISPLAY_SC1200_TIMINGS
-
-#if defined(DISPLAY_SC1200_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static int sc1200_get_info(char *, char **, off_t, int);
-extern int (*sc1200_display_info)(char *, char **, off_t, int); /* ide-proc.c */
-extern char *ide_media_verbose(ide_drive_t *);
-static u8 sc1200_proc = 0;
-
-static struct pci_dev *bmide_dev;
-
-static int sc1200_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	unsigned long bibma = pci_resource_start(bmide_dev, 4);
-	int len;
-	u8  c0 = 0, c1 = 0;
-
-	/*
-	 * at that point bibma+0x2 et bibma+0xa are byte registers
-	 * to investigate:
-	 */
-
-	c0 = inb_p(bibma + 0x02);
-	c1 = inb_p(bibma + 0x0a);
-
-	p += sprintf(p, "\n                               National SCx200 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");
-
-	len = (p - buffer) - offset;
-	*addr = buffer + offset;
-	
-	return len > count ? count : len;
-}
-#endif /* DISPLAY_SC1200_TIMINGS && CONFIG_PROC_FS */
-
 extern char *ide_xfer_verbose (byte xfer_rate);
 
 /*
  * Set a new transfer mode at the drive
  */
-int sc1200_set_xfer_mode (ide_drive_t *drive, byte mode)
+static int sc1200_set_xfer_mode (ide_drive_t *drive, byte mode)
 {
 	printk("%s: sc1200_set_xfer_mode(%s)\n", drive->name, ide_xfer_verbose(mode));
 	return ide_config_drive_speed(drive, mode);
@@ -312,7 +263,7 @@
  *
  *  returns 1 on error, 0 otherwise
  */
-int sc1200_ide_dma_end (ide_drive_t *drive)
+static int sc1200_ide_dma_end (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	unsigned long dma_base = hwif->dma_base;
@@ -505,21 +456,6 @@
 }
 
 /*
- * Initialize the sc1200 bridge for reliable IDE DMA operation.
- */
-static unsigned int __init init_chipset_sc1200 (struct pci_dev *dev, const char *name)
-{
-#if defined(DISPLAY_SC1200_TIMINGS) && defined(CONFIG_PROC_FS)
-	if (!bmide_dev) {
-		sc1200_proc = 1;
-		bmide_dev = dev;
-		ide_pci_create_host_proc("sc1200", sc1200_get_info);
-	}
-#endif /* DISPLAY_SC1200_TIMINGS && CONFIG_PROC_FS */
-	return 0;
-}
-
-/*
  * This gets invoked by the IDE driver once for each channel,
  * and performs channel-specific pre-initialization before drive probing.
  */
@@ -545,7 +481,6 @@
 
 static ide_pci_device_t sc1200_chipset __devinitdata = {
 	.name		= "SC1200",
-	.init_chipset	= init_chipset_sc1200,
 	.init_hwif	= init_hwif_sc1200,
 	.channels	= 2,
 	.autodma	= AUTODMA,
diff -Nru a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
--- a/drivers/ide/pci/serverworks.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/ide/pci/serverworks.c	2004-12-24 13:36:17 -08:00
@@ -44,164 +44,6 @@
 static u8 svwks_revision = 0;
 static struct pci_dev *isa_dev;
 
-#if defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 svwks_proc = 0;
-#define SVWKS_MAX_DEVS		2
-static struct pci_dev *svwks_devs[SVWKS_MAX_DEVS];
-static int n_svwks_devs;
-
-static int svwks_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	int i, len;
-
-	p += sprintf(p, "\n                             "
-			"ServerWorks OSB4/CSB5/CSB6\n");
-
-	for (i = 0; i < n_svwks_devs; i++) {
-		struct pci_dev *dev = svwks_devs[i];
-		unsigned long bibma = pci_resource_start(dev, 4);
-		u32 reg40, reg44;
-		u16 reg48, reg56;
-		u8  reg54, c0=0, c1=0;
-
-		pci_read_config_dword(dev, 0x40, &reg40);
-		pci_read_config_dword(dev, 0x44, &reg44);
-		pci_read_config_word(dev, 0x48, &reg48);
-		pci_read_config_byte(dev, 0x54, &reg54);
-		pci_read_config_word(dev, 0x56, &reg56);
-
-		/*
-		 * at that point bibma+0x2 et bibma+0xa are byte registers
-		 * to investigate:
-		 */
-		c0 = inb_p(bibma + 0x02);
-		c1 = inb_p(bibma + 0x0a);
-
-		p += sprintf(p, "\n                            ServerWorks ");
-		switch(dev->device) {
-			case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2:
-			case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE:
-				p += sprintf(p, "CSB6 ");
-				break;
-			case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
-				p += sprintf(p, "CSB5 ");
-				break;
-			case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE:
-				p += sprintf(p, "OSB4 ");
-				break;
-			default:
-				p += sprintf(p, "%04x ", dev->device);
-				break;
-		}
-		p += sprintf(p, "Chipset (rev %02x)\n", svwks_revision);
-
-		p += sprintf(p, "------------------------------- "
-				"General Status "
-				"---------------------------------\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 enabled:   %s              %s"
-				"             %s               %s\n",
-			(reg54 & 0x01) ? "yes" : "no ",
-			(reg54 & 0x02) ? "yes" : "no ",
-			(reg54 & 0x04) ? "yes" : "no ",
-			(reg54 & 0x08) ? "yes" : "no " );
-		p += sprintf(p, "UDMA enabled:   %s                %s"
-				"               %s                 %s\n",
-			((reg56&0x0005)==0x0005)?"5":
-				((reg56&0x0004)==0x0004)?"4":
-				((reg56&0x0003)==0x0003)?"3":
-				((reg56&0x0002)==0x0002)?"2":
-				((reg56&0x0001)==0x0001)?"1":
-				((reg56&0x000F))?"?":"0",
-			((reg56&0x0050)==0x0050)?"5":
-				((reg56&0x0040)==0x0040)?"4":
-				((reg56&0x0030)==0x0030)?"3":
-				((reg56&0x0020)==0x0020)?"2":
-				((reg56&0x0010)==0x0010)?"1":
-				((reg56&0x00F0))?"?":"0",
-			((reg56&0x0500)==0x0500)?"5":
-				((reg56&0x0400)==0x0400)?"4":
-				((reg56&0x0300)==0x0300)?"3":
-				((reg56&0x0200)==0x0200)?"2":
-				((reg56&0x0100)==0x0100)?"1":
-				((reg56&0x0F00))?"?":"0",
-			((reg56&0x5000)==0x5000)?"5":
-				((reg56&0x4000)==0x4000)?"4":
-				((reg56&0x3000)==0x3000)?"3":
-				((reg56&0x2000)==0x2000)?"2":
-				((reg56&0x1000)==0x1000)?"1":
-				((reg56&0xF000))?"?":"0");
-		p += sprintf(p, "DMA enabled:    %s                %s"
-				"               %s                 %s\n",
-			((reg44&0x00002000)==0x00002000)?"2":
-				((reg44&0x00002100)==0x00002100)?"1":
-				((reg44&0x00007700)==0x00007700)?"0":
-				((reg44&0x0000FF00)==0x0000FF00)?"X":"?",
-			((reg44&0x00000020)==0x00000020)?"2":
-				((reg44&0x00000021)==0x00000021)?"1":
-				((reg44&0x00000077)==0x00000077)?"0":
-				((reg44&0x000000FF)==0x000000FF)?"X":"?",
-			((reg44&0x20000000)==0x20000000)?"2":
-				((reg44&0x21000000)==0x21000000)?"1":
-				((reg44&0x77000000)==0x77000000)?"0":
-				((reg44&0xFF000000)==0xFF000000)?"X":"?",
-			((reg44&0x00200000)==0x00200000)?"2":
-				((reg44&0x00210000)==0x00210000)?"1":
-				((reg44&0x00770000)==0x00770000)?"0":
-				((reg44&0x00FF0000)==0x00FF0000)?"X":"?");
-
-		p += sprintf(p, "PIO  enabled:   %s                %s"
-				"               %s                 %s\n",
-			((reg40&0x00002000)==0x00002000)?"4":
-				((reg40&0x00002200)==0x00002200)?"3":
-				((reg40&0x00003400)==0x00003400)?"2":
-				((reg40&0x00004700)==0x00004700)?"1":
-				((reg40&0x00005D00)==0x00005D00)?"0":"?",
-			((reg40&0x00000020)==0x00000020)?"4":
-				((reg40&0x00000022)==0x00000022)?"3":
-				((reg40&0x00000034)==0x00000034)?"2":
-				((reg40&0x00000047)==0x00000047)?"1":
-				((reg40&0x0000005D)==0x0000005D)?"0":"?",
-			((reg40&0x20000000)==0x20000000)?"4":
-				((reg40&0x22000000)==0x22000000)?"3":
-				((reg40&0x34000000)==0x34000000)?"2":
-				((reg40&0x47000000)==0x47000000)?"1":
-				((reg40&0x5D000000)==0x5D000000)?"0":"?",
-			((reg40&0x00200000)==0x00200000)?"4":
-				((reg40&0x00220000)==0x00220000)?"3":
-				((reg40&0x00340000)==0x00340000)?"2":
-				((reg40&0x00470000)==0x00470000)?"1":
-				((reg40&0x005D0000)==0x005D0000)?"0":"?");
-
-	}
-	p += sprintf(p, "\n");
-
-	/* p - buffer must be less than 4k! */
-	len = (p - buffer) - offset;
-	*addr = buffer + offset;
-	
-	return len > count ? count : len;
-}
-#endif  /* defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS) */
-
 static int check_in_drive_lists (ide_drive_t *drive, const char **list)
 {
 	while (*list)
@@ -463,38 +305,16 @@
 	drive->init_speed = 0;
 
 	if ((id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			} else
-				/* UDMA disabled by mask, try other DMA modes */
-				goto try_dma_modes;
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto no_dma_set;
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		config_chipset_for_pio(drive);
 		//	hwif->tuneproc(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
@@ -616,16 +436,6 @@
 			btr |= (svwks_revision >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2;
 		pci_write_config_byte(dev, 0x5A, btr);
 	}
-
-
-#if defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS)
-	svwks_devs[n_svwks_devs++] = dev;
-
-	if (!svwks_proc) {
-		svwks_proc = 1;
-		ide_pci_create_host_proc("svwks", svwks_get_info);
-	}
-#endif /* DISPLAY_SVWKS_TIMINGS && CONFIG_PROC_FS */
 
 	return (dev->irq) ? dev->irq : 0;
 }
diff -Nru a/drivers/ide/pci/serverworks.h b/drivers/ide/pci/serverworks.h
--- a/drivers/ide/pci/serverworks.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/ide/pci/serverworks.h	2004-12-24 13:36:47 -08:00
@@ -13,15 +13,13 @@
 
 /* Seagate Barracuda ATA IV Family drives in UDMA mode 5
  * can overrun their FIFOs when used with the CSB5 */
-const char *svwks_bad_ata100[] = {
+static const char *svwks_bad_ata100[] = {
 	"ST320011A",
 	"ST340016A",
 	"ST360021A",
 	"ST380021A",
 	NULL
 };
-
-#define DISPLAY_SVWKS_TIMINGS	1
 
 static void init_setup_svwks(struct pci_dev *, ide_pci_device_t *);
 static void init_setup_csb6(struct pci_dev *, ide_pci_device_t *);
diff -Nru a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
--- a/drivers/ide/pci/sgiioc4.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/ide/pci/sgiioc4.c	2004-12-24 13:36:55 -08:00
@@ -192,16 +192,13 @@
 	return intr_reg & 3;
 }
 
-static int
-sgiioc4_ide_dma_begin(ide_drive_t * drive)
+static void sgiioc4_ide_dma_start(ide_drive_t * drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	unsigned int reg = hwif->INL(hwif->dma_base + IOC4_DMA_CTRL * 4);
 	unsigned int temp_reg = reg | IOC4_S_DMA_START;
 
 	hwif->OUTL(temp_reg, hwif->dma_base + IOC4_DMA_CTRL * 4);
-
-	return 0;
 }
 
 static u32
@@ -335,17 +332,6 @@
 }
 
 static int
-sgiioc4_ide_dma_verbose(ide_drive_t * drive)
-{
-	if (drive->using_dma == 1)
-		printk(", UDMA(16)");
-	else
-		printk(", PIO");
-
-	return 1;
-}
-
-static int
 sgiioc4_ide_dma_lostirq(ide_drive_t * drive)
 {
 	HWIF(drive)->resetproc(drive);
@@ -382,7 +368,7 @@
 }
 
 /* Creates a dma map for the scatter-gather list entries */
-static void __init
+static void __devinit
 ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
 {
 	int num_ports = sizeof (ioc4_dma_regs_t);
@@ -407,11 +393,7 @@
 	if (!hwif->dmatable_cpu)
 		goto dma_alloc_failure;
 
-	hwif->sg_table =
-	    kmalloc(sizeof (struct scatterlist) * IOC4_PRD_ENTRIES, GFP_KERNEL);
-
-	if (!hwif->sg_table)
-		goto dma_sgalloc_failure;
+	hwif->sg_max_nents = IOC4_PRD_ENTRIES;
 
 	hwif->dma_base2 = (unsigned long)
 		pci_alloc_consistent(hwif->pci_dev,
@@ -424,9 +406,6 @@
 	return;
 
 dma_base2alloc_failure:
-	kfree(hwif->sg_table);
-
-dma_sgalloc_failure:
 	pci_free_consistent(hwif->pci_dev,
 			    IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
 			    hwif->dmatable_cpu, hwif->dmatable_dma);
@@ -511,10 +490,7 @@
 	unsigned int count = 0, i = 1;
 	struct scatterlist *sg;
 
-	if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE)
-		hwif->sg_nents = i = ide_raw_build_sglist(drive, rq);
-	else
-		hwif->sg_nents = i = ide_build_sglist(drive, rq);
+	hwif->sg_nents = i = ide_build_sglist(drive, rq);
 
 	if (!i)
 		return 0;	/* sglist of length Zero */
@@ -574,40 +550,36 @@
 	return 0;		/* revert to PIO for this request */
 }
 
-static int
-sgiioc4_ide_dma_read(ide_drive_t * drive)
+static int sgiioc4_ide_dma_setup(ide_drive_t *drive)
 {
 	struct request *rq = HWGROUP(drive)->rq;
 	unsigned int count = 0;
+	int ddir;
 
-	if (!(count = sgiioc4_build_dma_table(drive, rq, PCI_DMA_FROMDEVICE))) {
-		/* try PIO instead of DMA */
-		return 1;
-	}
-	/* Writes FROM the IOC4 TO Main Memory */
-	sgiioc4_configure_for_dma(IOC4_DMA_WRITE, drive);
-
-	return 0;
-}
-
-static int
-sgiioc4_ide_dma_write(ide_drive_t * drive)
-{
-	struct request *rq = HWGROUP(drive)->rq;
-	unsigned int count = 0;
+	if (rq_data_dir(rq))
+		ddir = PCI_DMA_TODEVICE;
+	else
+		ddir = PCI_DMA_FROMDEVICE;
 
-	if (!(count = sgiioc4_build_dma_table(drive, rq, PCI_DMA_TODEVICE))) {
+	if (!(count = sgiioc4_build_dma_table(drive, rq, ddir))) {
 		/* try PIO instead of DMA */
+		ide_map_sg(drive, rq);
 		return 1;
 	}
 
-	sgiioc4_configure_for_dma(IOC4_DMA_READ, drive);
-	/* Writes TO the IOC4 FROM Main Memory */
+	if (rq_data_dir(rq))
+		/* Writes TO the IOC4 FROM Main Memory */
+		ddir = IOC4_DMA_READ;
+	else
+		/* Writes FROM the IOC4 TO Main Memory */
+		ddir = IOC4_DMA_WRITE;
+
+	sgiioc4_configure_for_dma(ddir, drive);
 
 	return 0;
 }
 
-static void __init
+static void __devinit
 ide_init_sgiioc4(ide_hwif_t * hwif)
 {
 	hwif->mmio = 2;
@@ -616,7 +588,6 @@
 	hwif->ultra_mask = 0x0;	/* Disable Ultra DMA */
 	hwif->mwdma_mask = 0x2;	/* Multimode-2 DMA  */
 	hwif->swdma_mask = 0x2;
-	hwif->identify = NULL;
 	hwif->tuneproc = NULL;	/* Sets timing for PIO mode */
 	hwif->speedproc = NULL;	/* Sets timing for DMA &/or PIO modes */
 	hwif->selectproc = NULL;/* Use the default routine to select drive */
@@ -629,9 +600,8 @@
 	hwif->quirkproc = NULL;
 	hwif->busproc = NULL;
 
-	hwif->ide_dma_read = &sgiioc4_ide_dma_read;
-	hwif->ide_dma_write = &sgiioc4_ide_dma_write;
-	hwif->ide_dma_begin = &sgiioc4_ide_dma_begin;
+	hwif->dma_setup = &sgiioc4_ide_dma_setup;
+	hwif->dma_start = &sgiioc4_ide_dma_start;
 	hwif->ide_dma_end = &sgiioc4_ide_dma_end;
 	hwif->ide_dma_check = &sgiioc4_ide_dma_check;
 	hwif->ide_dma_on = &sgiioc4_ide_dma_on;
@@ -639,13 +609,12 @@
 	hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq;
 	hwif->ide_dma_host_on = &sgiioc4_ide_dma_host_on;
 	hwif->ide_dma_host_off = &sgiioc4_ide_dma_host_off;
-	hwif->ide_dma_verbose = &sgiioc4_ide_dma_verbose;
 	hwif->ide_dma_lostirq = &sgiioc4_ide_dma_lostirq;
 	hwif->ide_dma_timeout = &__ide_dma_timeout;
 	hwif->INB = &sgiioc4_INB;
 }
 
-static int __init
+static int __devinit
 sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
 {
 	unsigned long base, ctl, dma_base, irqport;
@@ -708,22 +677,10 @@
 	return 0;
 }
 
-/* This ensures that we can build this for generic kernels without
- * having all the SN2 code sync'd and merged.
- */
-typedef enum pciio_endian_e {
-	PCIDMA_ENDIAN_BIG,
-	PCIDMA_ENDIAN_LITTLE
-} pciio_endian_t;
-pciio_endian_t snia_pciio_endian_set(struct pci_dev
-				     *pci_dev, pciio_endian_t device_end,
-				     pciio_endian_t desired_end);
-
-static unsigned int __init
+static unsigned int __devinit
 pci_init_sgiioc4(struct pci_dev *dev, ide_pci_device_t * d)
 {
 	unsigned int class_rev;
-	pciio_endian_t endian_status;
 
 	if (pci_enable_device(dev)) {
 		printk(KERN_ERR
@@ -743,17 +700,6 @@
 			"46 or higher\n", d->name, dev->slot_name);
 		return -ENODEV;
 	}
-
-	/* Enable Byte Swapping in the PIC... */
-	endian_status = snia_pciio_endian_set(dev, PCIDMA_ENDIAN_LITTLE,
-					      PCIDMA_ENDIAN_BIG);
-	if (endian_status != PCIDMA_ENDIAN_BIG) {
-		printk(KERN_ERR
-		       "Failed to set endianness for device %s at slot %s\n",
-		       d->name, dev->slot_name);
-		return -ENODEV;
-	}
-
 	return sgiioc4_ide_setup_pci_device(dev, d);
 }
 
@@ -784,13 +730,13 @@
 };
 MODULE_DEVICE_TABLE(pci, sgiioc4_pci_tbl);
 
-static struct pci_driver driver = {
+static struct pci_driver __devinitdata driver = {
 	.name = "SGI-IOC4_IDE",
 	.id_table = sgiioc4_pci_tbl,
 	.probe = sgiioc4_init_one,
 };
 
-static int
+static int __devinit
 sgiioc4_ide_init(void)
 {
 	return ide_pci_register_driver(&driver);
diff -Nru a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
--- a/drivers/ide/pci/siimage.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/ide/pci/siimage.c	2004-12-24 13:36:47 -08:00
@@ -420,37 +420,16 @@
 	struct hd_driveid *id	= drive->id;
 
 	if ((id->capability & 1) != 0 && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-
-		if ((id->field_valid & 4) && siimage_ratemask(drive)) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		config_chipset_for_pio(drive, 1);
 		return hwif->ide_dma_off_quietly(drive);
 	}
@@ -554,12 +533,6 @@
 	return 0;
 }
 
-static int siimage_mmio_ide_dma_verbose (ide_drive_t *drive)
-{
-	int temp = __ide_dma_verbose(drive);
-	return temp;
-}
-
 /**
  *	siimage_busproc		-	bus isolation ioctl
  *	@drive: drive to isolate/restore
@@ -898,12 +871,11 @@
 	 *	the MMIO layout isnt the same as the the standard port
 	 *	based I/O
 	 */
-	 
+
 	memset(&hw, 0, sizeof(hw_regs_t));
-	hw.priv				= addr;
 
-	base				= (unsigned long)addr;
-	if(ch)
+	base = (unsigned long)addr;
+	if (ch)
 		base += 0xC0;
 	else
 		base += 0x80;
@@ -928,16 +900,16 @@
 
 	hw.io_ports[IDE_IRQ_OFFSET]	= 0;
 
-        if (pdev_is_sata(dev)) {
-        	base = (unsigned long) addr;
-        	if(ch)
-        		base += 0x80;
-		hw.sata_scr[SATA_STATUS_OFFSET]	= base + 0x104;
-		hw.sata_scr[SATA_ERROR_OFFSET]	= base + 0x108;
-		hw.sata_scr[SATA_CONTROL_OFFSET]= base + 0x100;
-		hw.sata_misc[SATA_MISC_OFFSET]	= base + 0x140;
-		hw.sata_misc[SATA_PHY_OFFSET]	= base + 0x144;
-		hw.sata_misc[SATA_IEN_OFFSET]	= base + 0x148;
+	if (pdev_is_sata(dev)) {
+		base = (unsigned long)addr;
+		if (ch)
+			base += 0x80;
+		hwif->sata_scr[SATA_STATUS_OFFSET]	= base + 0x104;
+		hwif->sata_scr[SATA_ERROR_OFFSET]	= base + 0x108;
+		hwif->sata_scr[SATA_CONTROL_OFFSET]	= base + 0x100;
+		hwif->sata_misc[SATA_MISC_OFFSET]	= base + 0x140;
+		hwif->sata_misc[SATA_PHY_OFFSET]	= base + 0x144;
+		hwif->sata_misc[SATA_IEN_OFFSET]	= base + 0x148;
 	}
 
 	hw.irq				= hwif->pci_dev->irq;
@@ -945,11 +917,6 @@
 	memcpy(&hwif->hw, &hw, sizeof(hw));
 	memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
 
-	if (is_sata(hwif)) {
-		memcpy(hwif->sata_scr, hwif->hw.sata_scr, sizeof(hwif->hw.sata_scr));
-		memcpy(hwif->sata_misc, hwif->hw.sata_misc, sizeof(hwif->hw.sata_misc));
-	}
-
 	hwif->irq			= hw.irq;
 
        	base = (unsigned long) addr;
@@ -988,6 +955,22 @@
 }
 
 /**
+ *	siimage_fixup		-	post probe fixups
+ *	@hwif: interface to fix up
+ *
+ *	Called after drive probe we use this to decide whether the
+ *	Seagate fixup must be applied. This used to be in init_iops but
+ *	that can occur before we know what drives are present.
+ */
+
+static void __devinit siimage_fixup(ide_hwif_t *hwif)
+{
+	/* Try and raise the rqsize */
+	if (!is_sata(hwif) || !is_dev_seagate_sata(&hwif->drives[0]))
+		hwif->rqsize = 128;
+}
+
+/**
  *	init_iops_siimage	-	set up iops
  *	@hwif: interface to set up
  *
@@ -1007,9 +990,8 @@
 	
 	hwif->hwif_data = NULL;
 
-	hwif->rqsize = 128;
-	if (is_sata(hwif) && is_dev_seagate_sata(&hwif->drives[0]))
-		hwif->rqsize = 15;
+	/* Pessimal until we finish probing */
+	hwif->rqsize = 15;
 
 	if (pci_get_drvdata(dev) == NULL)
 		return;
@@ -1077,7 +1059,6 @@
 
 	if (hwif->mmio) {
 		hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq;
-		hwif->ide_dma_verbose = &siimage_mmio_ide_dma_verbose;
 	} else {
 		hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq;
 	}
@@ -1098,6 +1079,7 @@
 		.init_chipset	= init_chipset_siimage,	\
 		.init_iops	= init_iops_siimage,	\
 		.init_hwif	= init_hwif_siimage,	\
+		.fixup		= siimage_fixup,	\
 		.channels	= 2,			\
 		.autodma	= AUTODMA,		\
 		.bootable	= ON_BOARD,		\
diff -Nru a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
--- a/drivers/ide/pci/sis5513.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/ide/pci/sis5513.c	2004-12-24 13:36:49 -08:00
@@ -671,36 +671,16 @@
 	drive->init_speed = 0;
 
 	if (id && (id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!config_chipset_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!config_chipset_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (config_chipset_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		sis5513_tune_drive(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
diff -Nru a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
--- a/drivers/ide/pci/sl82c105.c	2004-12-24 13:36:35 -08:00
+++ b/drivers/ide/pci/sl82c105.c	2004-12-24 13:36:35 -08:00
@@ -236,15 +236,13 @@
  * The generic IDE core will have disabled the BMEN bit before this
  * function is called.
  */
-static int sl82c105_ide_dma_begin(ide_drive_t *drive)
+static void sl82c105_ide_dma_start(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	struct pci_dev *dev = hwif->pci_dev;
 
-//	DBG(("sl82c105_ide_dma_begin(drive:%s)\n", drive->name));
-
 	sl82c105_reset_host(dev);
-	return __ide_dma_begin(drive);
+	ide_dma_start(drive);
 }
 
 static int sl82c105_ide_dma_timeout(ide_drive_t *drive)
@@ -469,7 +467,7 @@
 	hwif->ide_dma_on = &sl82c105_ide_dma_on;
 	hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly;
 	hwif->ide_dma_lostirq = &sl82c105_ide_dma_lost_irq;
-	hwif->ide_dma_begin = &sl82c105_ide_dma_begin;
+	hwif->dma_start = &sl82c105_ide_dma_start;
 	hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout;
 
 	if (!noautodma)
diff -Nru a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
--- a/drivers/ide/pci/slc90e66.c	2004-12-24 13:37:17 -08:00
+++ b/drivers/ide/pci/slc90e66.c	2004-12-24 13:37:17 -08:00
@@ -21,103 +21,6 @@
 
 #include <asm/io.h>
 
-#define DISPLAY_SLC90E66_TIMINGS
-
-#if defined(DISPLAY_SLC90E66_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 slc90e66_proc = 0;
-static struct pci_dev *bmide_dev;
-
-static int slc90e66_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	int len;
-	unsigned long bibma = pci_resource_start(bmide_dev, 4);
-	u16 reg40 = 0, psitre = 0, reg42 = 0, ssitre = 0;
-	u8  c0 = 0, c1 = 0;
-	u8  reg44 = 0, reg47 = 0, reg48 = 0, reg4a = 0, reg4b = 0;
-
-	pci_read_config_word(bmide_dev, 0x40, &reg40);
-	pci_read_config_word(bmide_dev, 0x42, &reg42);
-	pci_read_config_byte(bmide_dev, 0x44, &reg44);
-	pci_read_config_byte(bmide_dev, 0x47, &reg47);
-	pci_read_config_byte(bmide_dev, 0x48, &reg48);
-	pci_read_config_byte(bmide_dev, 0x4a, &reg4a);
-	pci_read_config_byte(bmide_dev, 0x4b, &reg4b);
-
-	psitre = (reg40 & 0x4000) ? 1 : 0;
-	ssitre = (reg42 & 0x4000) ? 1 : 0;
-
-        /*
-         * at that point bibma+0x2 et bibma+0xa are byte registers
-         * to investigate:
-         */
-	c0 = inb_p(bibma + 0x02);
-	c1 = inb_p(bibma + 0x0a);
-
-	p += sprintf(p, "                                SLC90E66 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 enabled:   %s              %s "
-			"            %s               %s\n",
-			(reg48&0x01) ? "yes" : "no ",
-			(reg48&0x02) ? "yes" : "no ",
-			(reg48&0x04) ? "yes" : "no ",
-			(reg48&0x08) ? "yes" : "no " );
-	p += sprintf(p, "UDMA enabled:   %s                %s "
-			"              %s                 %s\n",
-			((reg4a&0x04)==0x04) ? "4" :
-			((reg4a&0x03)==0x03) ? "3" :
-			(reg4a&0x02) ? "2" :
-			(reg4a&0x01) ? "1" :
-			(reg4a&0x00) ? "0" : "X",
-			((reg4a&0x40)==0x40) ? "4" :
-			((reg4a&0x30)==0x30) ? "3" :
-			(reg4a&0x20) ? "2" :
-			(reg4a&0x10) ? "1" :
-			(reg4a&0x00) ? "0" : "X",
-			((reg4b&0x04)==0x04) ? "4" :
-			((reg4b&0x03)==0x03) ? "3" :
-			(reg4b&0x02) ? "2" :
-			(reg4b&0x01) ? "1" :
-			(reg4b&0x00) ? "0" : "X",
-			((reg4b&0x40)==0x40) ? "4" :
-			((reg4b&0x30)==0x30) ? "3" :
-			(reg4b&0x20) ? "2" :
-			(reg4b&0x10) ? "1" :
-			(reg4b&0x00) ? "0" : "X");
-
-	p += sprintf(p, "UDMA\n");
-	p += sprintf(p, "DMA\n");
-	p += sprintf(p, "PIO\n");
-
-/*
- *	FIXME.... Add configuration junk data....blah blah......
- */
-
-	/* p - buffer must be less than 4k! */
-	len = (p - buffer) - offset;
-	*addr = buffer + offset;
-	
-	return len > count ? count : len;
-}
-#endif  /* defined(DISPLAY_SLC90E66_TIMINGS) && defined(CONFIG_PROC_FS) */
-
 static u8 slc90e66_ratemask (ide_drive_t *drive)
 {
 	u8 mode	= 2;
@@ -236,6 +139,7 @@
 	if (speed >= XFER_UDMA_0) {
 		if (!(reg48 & u_flag))
 			pci_write_config_word(dev, 0x48, reg48|u_flag);
+		/* FIXME: (reg4a & a_speed) ? */
 		if ((reg4a & u_speed) != u_speed) {
 			pci_write_config_word(dev, 0x4a, reg4a & ~a_speed);
 			pci_read_config_word(dev, 0x4a, &reg4a);
@@ -274,37 +178,16 @@
 	drive->init_speed = 0;
 
 	if (id && (id->capability & 1) && drive->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			goto fast_ata_pio;
-
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & hwif->ultra_mask) {
-				/* Force if Capable UltraDMA */
-				int dma = slc90e66_config_drive_for_dma(drive);
-				if ((id->field_valid & 2) && !dma)
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-			    (id->dma_1word & hwif->swdma_mask)) {
-				/* Force if Capable regular DMA modes */
-				if (!slc90e66_config_drive_for_dma(drive))
-					goto no_dma_set;
-			}
-		} else if (__ide_dma_good_drive(drive) &&
-			   (id->eide_dma_time < 150)) {
-			/* Consult the list of known "good" drives */
-			if (!slc90e66_config_drive_for_dma(drive))
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
+
+		if (ide_use_dma(drive)) {
+			if (slc90e66_config_drive_for_dma(drive))
+				return hwif->ide_dma_on(drive);
 		}
-		return hwif->ide_dma_on(drive);
+
+		goto fast_ata_pio;
+
 	} else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-no_dma_set:
 		hwif->tuneproc(drive, 5);
 		return hwif->ide_dma_off_quietly(drive);
 	}
@@ -313,18 +196,6 @@
 }
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
-static unsigned int __init init_chipset_slc90e66 (struct pci_dev *dev, const char *name)
-{
-#if defined(DISPLAY_SLC90E66_TIMINGS) && defined(CONFIG_PROC_FS)
-	if (!slc90e66_proc) {
-		slc90e66_proc = 1;
-		bmide_dev = dev;
-		ide_pci_create_host_proc("slc90e66", slc90e66_get_info);
-	}
-#endif /* DISPLAY_SLC90E66_TIMINGS && CONFIG_PROC_FS */
-	return 0;
-}
-
 static void __init init_hwif_slc90e66 (ide_hwif_t *hwif)
 {
 	u8 reg47 = 0;
@@ -366,7 +237,6 @@
 
 static ide_pci_device_t slc90e66_chipset __devinitdata = {
 	.name		= "SLC90E66",
-	.init_chipset	= init_chipset_slc90e66,
 	.init_hwif	= init_hwif_slc90e66,
 	.channels	= 2,
 	.autodma	= AUTODMA,
diff -Nru a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
--- a/drivers/ide/pci/triflex.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/ide/pci/triflex.c	2004-12-24 13:36:47 -08:00
@@ -118,25 +118,16 @@
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct hd_driveid *id	= drive->id;
-	
-	if (id && (id->capability & 1) && drive->autodma) {
-		if (__ide_dma_bad_drive(drive))
-			goto tune_pio;
-		if (id->field_valid & 2) {
-			if ((id->dma_mword & hwif->mwdma_mask) ||
-				(id->dma_1word & hwif->swdma_mask)) {
-				if (!triflex_config_drive_for_dma(drive))
-					goto tune_pio;
-			}
-		} else 
-			goto tune_pio;
-	} else {
-tune_pio:
-		hwif->tuneproc(drive, 255);
-		return hwif->ide_dma_off_quietly(drive);
+
+	if ((id->capability & 1) && drive->autodma) {
+		if (ide_use_dma(drive)) {
+			if (triflex_config_drive_for_dma(drive))
+				return hwif->ide_dma_on(drive);
+		}
 	}
 
-	return hwif->ide_dma_on(drive);
+	hwif->tuneproc(drive, 255);
+	return hwif->ide_dma_off_quietly(drive);
 }
 
 static void __init init_hwif_triflex(ide_hwif_t *hwif)
diff -Nru a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c
--- a/drivers/ide/pci/trm290.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/ide/pci/trm290.c	2004-12-24 13:36:31 -08:00
@@ -179,64 +179,32 @@
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-static int trm290_ide_dma_write (ide_drive_t *drive /*, struct request *rq */)
+static void trm290_ide_dma_exec_cmd(ide_drive_t *drive, u8 command)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct request *rq	= HWGROUP(drive)->rq;
-//	ide_task_t *args	= rq->special;
-	task_ioreg_t command	= WIN_NOP;
-	unsigned int count, reading = 2, writing = 0;
 
-	reading = 0;
-	writing = 1;
-#ifdef TRM290_NO_DMA_WRITES
-	/* always use PIO for writes */
-	trm290_prepare_drive(drive, 0);	/* select PIO xfer */
-	return 1;
-#endif
-	if (!(count = ide_build_dmatable(drive, rq))) {
-		/* try PIO instead of DMA */
-		trm290_prepare_drive(drive, 0); /* select PIO xfer */
-		return 1;
-	}
-	/* select DMA xfer */
-	trm290_prepare_drive(drive, 1);
-	hwif->OUTL(hwif->dmatable_dma|reading|writing, hwif->dma_command);
-	drive->waiting_for_dma = 1;
-	/* start DMA */
-	hwif->OUTW((count * 2) - 1, hwif->dma_status);
-	if (drive->media != ide_disk)
-		return 0;
 	if (HWGROUP(drive)->handler != NULL)	/* paranoia check */
 		BUG();
 	ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
-	/*
-	 * FIX ME to use only ACB ide_task_t args Struct
-	 */
-#if 0
-	{
-		ide_task_t *args = rq->special;
-		command = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-#else
-	command = /* (lba48) ? WIN_READDMA_EXT : */ WIN_READDMA;
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-		command = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-#endif
 	/* issue cmd to drive */
 	hwif->OUTB(command, IDE_COMMAND_REG);
-	return hwif->ide_dma_begin(drive);
 }
 
-static int trm290_ide_dma_read (ide_drive_t *drive  /*, struct request *rq */)
+static int trm290_ide_dma_setup(ide_drive_t *drive)
 {
-	ide_hwif_t *hwif	= HWIF(drive);
-	struct request *rq	= HWGROUP(drive)->rq;
-//	ide_task_t *args	= rq->special;
-	task_ioreg_t command	= WIN_NOP;
-	unsigned int count, reading = 2, writing = 0;
+	ide_hwif_t *hwif = drive->hwif;
+	struct request *rq = hwif->hwgroup->rq;
+	unsigned int count, rw;
+
+	if (rq_data_dir(rq)) {
+#ifdef TRM290_NO_DMA_WRITES
+		/* always use PIO for writes */
+		trm290_prepare_drive(drive, 0);	/* select PIO xfer */
+		return 1;
+#endif
+		rw = 1;
+	} else
+		rw = 2;
 
 	if (!(count = ide_build_dmatable(drive, rq))) {
 		/* try PIO instead of DMA */
@@ -245,38 +213,15 @@
 	}
 	/* select DMA xfer */
 	trm290_prepare_drive(drive, 1);
-	hwif->OUTL(hwif->dmatable_dma|reading|writing, hwif->dma_command);
+	hwif->OUTL(hwif->dmatable_dma|rw, hwif->dma_command);
 	drive->waiting_for_dma = 1;
 	/* start DMA */
 	hwif->OUTW((count * 2) - 1, hwif->dma_status);
-	if (drive->media != ide_disk)
-		return 0;
-	if (HWGROUP(drive)->handler != NULL)	/* paranoia check */
-		BUG();
-	ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
-	/*
-	 * FIX ME to use only ACB ide_task_t args Struct
-	 */
-#if 0
-	{
-		ide_task_t *args = rq->special;
-		command = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-#else
-	command = /* (lba48) ? WIN_WRITEDMA_EXT : */ WIN_WRITEDMA;
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-		command = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-#endif
-	/* issue cmd to drive */
-	hwif->OUTB(command, IDE_COMMAND_REG);
-	return hwif->ide_dma_begin(drive);
+	return 0;
 }
 
-static int trm290_ide_dma_begin (ide_drive_t *drive)
+static void trm290_ide_dma_start(ide_drive_t *drive)
 {
-	return 0;
 }
 
 static int trm290_ide_dma_end (ide_drive_t *drive)
@@ -304,7 +249,7 @@
 /*
  * Invoked from ide-dma.c at boot time.
  */
-void __devinit init_hwif_trm290(ide_hwif_t *hwif)
+static void __devinit init_hwif_trm290(ide_hwif_t *hwif)
 {
 	unsigned int cfgbase = 0;
 	unsigned long flags;
@@ -347,9 +292,9 @@
 	ide_setup_dma(hwif, (hwif->config_data + 4) ^ (hwif->channel ? 0x0080 : 0x0000), 3);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-	hwif->ide_dma_write = &trm290_ide_dma_write;
-	hwif->ide_dma_read = &trm290_ide_dma_read;
-	hwif->ide_dma_begin = &trm290_ide_dma_begin;
+	hwif->dma_setup = &trm290_ide_dma_setup;
+	hwif->dma_exec_cmd = &trm290_ide_dma_exec_cmd;
+	hwif->dma_start = &trm290_ide_dma_start;
 	hwif->ide_dma_end = &trm290_ide_dma_end;
 	hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq;
 #endif /* CONFIG_BLK_DEV_IDEDMA */
diff -Nru a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
--- a/drivers/ide/ppc/pmac.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/ide/ppc/pmac.c	2004-12-24 13:36:18 -08:00
@@ -34,6 +34,7 @@
 #include <linux/pci.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
+#include <linux/scatterlist.h>
 
 #include <asm/prom.h>
 #include <asm/io.h>
@@ -51,8 +52,6 @@
 
 #include "ide-timing.h"
 
-extern void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq);
-
 #define IDE_PMAC_DEBUG
 
 #define DMA_WAIT_TIMEOUT	50
@@ -77,10 +76,6 @@
 	 */
 	volatile struct dbdma_regs __iomem *	dma_regs;
 	struct dbdma_cmd*		dma_table_cpu;
-	dma_addr_t			dma_table_dma;
-	struct scatterlist*		sg_table;
-	int				sg_nents;
-	int				sg_dma_direction;
 #endif
 	
 } pmac_ide_hwif_t;
@@ -361,7 +356,6 @@
 static void pmac_ide_tuneproc(ide_drive_t *drive, u8 pio);
 static void pmac_ide_selectproc(ide_drive_t *drive);
 static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
-static int pmac_ide_dma_begin (ide_drive_t *drive);
 
 #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
 
@@ -1245,6 +1239,8 @@
 		hwif->noprobe = 0;
 #endif /* CONFIG_PMAC_PBOOK */
 
+	hwif->sg_max_nents = MAX_DCMDS;
+
 #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
 	/* has a DBDMA controller channel */
 	if (pmif->dma_regs)
@@ -1364,10 +1360,10 @@
 	ide_hwif_t	*hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
 	int		rc = 0;
 
-	if (state != mdev->ofdev.dev.power_state && state >= 2) {
+	if (state != mdev->ofdev.dev.power.power_state && state >= 2) {
 		rc = pmac_ide_do_suspend(hwif);
 		if (rc == 0)
-			mdev->ofdev.dev.power_state = state;
+			mdev->ofdev.dev.power.power_state = state;
 	}
 
 	return rc;
@@ -1379,10 +1375,10 @@
 	ide_hwif_t	*hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
 	int		rc = 0;
 	
-	if (mdev->ofdev.dev.power_state != 0) {
+	if (mdev->ofdev.dev.power.power_state != 0) {
 		rc = pmac_ide_do_resume(hwif);
 		if (rc == 0)
-			mdev->ofdev.dev.power_state = 0;
+			mdev->ofdev.dev.power.power_state = 0;
 	}
 
 	return rc;
@@ -1472,10 +1468,10 @@
 	ide_hwif_t	*hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
 	int		rc = 0;
 	
-	if (state != pdev->dev.power_state && state >= 2) {
+	if (state != pdev->dev.power.power_state && state >= 2) {
 		rc = pmac_ide_do_suspend(hwif);
 		if (rc == 0)
-			pdev->dev.power_state = state;
+			pdev->dev.power.power_state = state;
 	}
 
 	return rc;
@@ -1487,10 +1483,10 @@
 	ide_hwif_t	*hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
 	int		rc = 0;
 	
-	if (pdev->dev.power_state != 0) {
+	if (pdev->dev.power.power_state != 0) {
 		rc = pmac_ide_do_resume(hwif);
 		if (rc == 0)
-			pdev->dev.power_state = 0;
+			pdev->dev.power.power_state = 0;
 	}
 
 	return rc;
@@ -1562,66 +1558,6 @@
 #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
 
 /*
- * This is very close to the generic ide-dma version of the function except
- * that we don't use the fields in the hwif but our own copies for sg_table
- * and friends. We build & map the sglist for a given request
- */
-static int __pmac
-pmac_ide_build_sglist(ide_drive_t *drive, struct request *rq)
-{
-	ide_hwif_t *hwif = HWIF(drive);
-	pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
-	struct scatterlist *sg = pmif->sg_table;
-	int nents;
-
-	nents = blk_rq_map_sg(drive->queue, rq, sg);
-		
-	if (rq_data_dir(rq) == READ)
-		pmif->sg_dma_direction = PCI_DMA_FROMDEVICE;
-	else
-		pmif->sg_dma_direction = PCI_DMA_TODEVICE;
-
-	return pci_map_sg(hwif->pci_dev, sg, nents, pmif->sg_dma_direction);
-}
-
-/*
- * Same as above but for a "raw" taskfile request
- */
-static int __pmac
-pmac_ide_raw_build_sglist(ide_drive_t *drive, struct request *rq)
-{
-	ide_hwif_t *hwif = HWIF(drive);
-	pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
-	struct scatterlist *sg = pmif->sg_table;
-	int nents = 0;
-	ide_task_t *args = rq->special;
-	unsigned char *virt_addr = rq->buffer;
-	int sector_count = rq->nr_sectors;
-
-	if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
-		pmif->sg_dma_direction = PCI_DMA_TODEVICE;
-	else
-		pmif->sg_dma_direction = PCI_DMA_FROMDEVICE;
-	
-	if (sector_count > 128) {
-		memset(&sg[nents], 0, sizeof(*sg));
-		sg[nents].page = virt_to_page(virt_addr);
-		sg[nents].offset = offset_in_page(virt_addr);
-		sg[nents].length = 128  * SECTOR_SIZE;
-		nents++;
-		virt_addr = virt_addr + (128 * SECTOR_SIZE);
-		sector_count -= 128;
-	}
-	memset(&sg[nents], 0, sizeof(*sg));
-	sg[nents].page = virt_to_page(virt_addr);
-	sg[nents].offset = offset_in_page(virt_addr);
-	sg[nents].length =  sector_count  * SECTOR_SIZE;
-	nents++;
-   
-	return pci_map_sg(hwif->pci_dev, sg, nents, pmif->sg_dma_direction);
-}
-
-/*
  * pmac_ide_build_dmatable builds the DBDMA command list
  * for a transfer and sets the DBDMA channel to point to it.
  */
@@ -1644,16 +1580,13 @@
 	while (readl(&dma->status) & RUN)
 		udelay(1);
 
-	/* Build sglist */
-	if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE)
-		pmif->sg_nents = i = pmac_ide_raw_build_sglist(drive, rq);
-	else
-		pmif->sg_nents = i = pmac_ide_build_sglist(drive, rq);
+	hwif->sg_nents = i = ide_build_sglist(drive, rq);
+
 	if (!i)
 		return 0;
 
 	/* Build DBDMA commands list */
-	sg = pmif->sg_table;
+	sg = hwif->sg_table;
 	while (i && sg_dma_len(sg)) {
 		u32 cur_addr;
 		u32 cur_len;
@@ -1698,16 +1631,16 @@
 		memset(table, 0, sizeof(struct dbdma_cmd));
 		st_le16(&table->command, DBDMA_STOP);
 		mb();
-		writel(pmif->dma_table_dma, &dma->cmdptr);
+		writel(hwif->dmatable_dma, &dma->cmdptr);
 		return 1;
 	}
 
 	printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name);
  use_pio_instead:
 	pci_unmap_sg(hwif->pci_dev,
-		     pmif->sg_table,
-		     pmif->sg_nents,
-		     pmif->sg_dma_direction);
+		     hwif->sg_table,
+		     hwif->sg_nents,
+		     hwif->sg_dma_direction);
 	return 0; /* revert to PIO for this request */
 }
 
@@ -1715,14 +1648,14 @@
 static void __pmac
 pmac_ide_destroy_dmatable (ide_drive_t *drive)
 {
+	ide_hwif_t *hwif = drive->hwif;
 	struct pci_dev *dev = HWIF(drive)->pci_dev;
-	pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
-	struct scatterlist *sg = pmif->sg_table;
-	int nents = pmif->sg_nents;
+	struct scatterlist *sg = hwif->sg_table;
+	int nents = hwif->sg_nents;
 
 	if (nents) {
-		pci_unmap_sg(dev, sg, nents, pmif->sg_dma_direction);
-		pmif->sg_nents = 0;
+		pci_unmap_sg(dev, sg, nents, hwif->sg_dma_direction);
+		hwif->sg_nents = 0;
 	}
 }
 
@@ -1885,7 +1818,7 @@
  * a read on KeyLargo ATA/66 and mark us as waiting for DMA completion
  */
 static int __pmac
-pmac_ide_dma_start(ide_drive_t *drive, int reading)
+pmac_ide_dma_setup(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
@@ -1897,12 +1830,14 @@
 		return 1;
 	ata4 = (pmif->kind == controller_kl_ata4);	
 
-	if (!pmac_ide_build_dmatable(drive, rq))
+	if (!pmac_ide_build_dmatable(drive, rq)) {
+		ide_map_sg(drive, rq);
 		return 1;
+	}
 
 	/* Apple adds 60ns to wrDataSetup on reads */
 	if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
-		writel(pmif->timings[unit] + (reading ? 0x00800000UL : 0),
+		writel(pmif->timings[unit] + (!rq_data_dir(rq) ? 0x00800000UL : 0),
 			PMAC_IDE_REG(IDE_TIMING_CONFIG));
 		(void)readl(PMAC_IDE_REG(IDE_TIMING_CONFIG));
 	}
@@ -1912,87 +1847,28 @@
 	return 0;
 }
 
-/*
- * Start a DMA READ command
- */
-static int __pmac
-pmac_ide_dma_read(ide_drive_t *drive)
-{
-	struct request *rq = HWGROUP(drive)->rq;
-	u8 lba48 = (drive->addressing == 1) ? 1 : 0;
-	task_ioreg_t command = WIN_NOP;
-
-	if (pmac_ide_dma_start(drive, 1))
-		return 1;
-
-	if (drive->media != ide_disk)
-		return 0;
-
-	command = (lba48) ? WIN_READDMA_EXT : WIN_READDMA;
-	
-	if (drive->vdma)
-		command = (lba48) ? WIN_READ_EXT: WIN_READ;
-		
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-		command = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-
-	/* issue cmd to drive */
-	ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL);
-
-	return pmac_ide_dma_begin(drive);
-}
-
-/*
- * Start a DMA WRITE command
- */
-static int __pmac
-pmac_ide_dma_write (ide_drive_t *drive)
+static void __pmac
+pmac_ide_dma_exec_cmd(ide_drive_t *drive, u8 command)
 {
-	struct request *rq = HWGROUP(drive)->rq;
-	u8 lba48 = (drive->addressing == 1) ? 1 : 0;
-	task_ioreg_t command = WIN_NOP;
-
-	if (pmac_ide_dma_start(drive, 0))
-		return 1;
-
-	if (drive->media != ide_disk)
-		return 0;
-
-	command = (lba48) ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
-	if (drive->vdma)
-		command = (lba48) ? WIN_WRITE_EXT: WIN_WRITE;
-		
-	if (rq->flags & REQ_DRIVE_TASKFILE) {
-		ide_task_t *args = rq->special;
-		command = args->tfRegister[IDE_COMMAND_OFFSET];
-	}
-
 	/* issue cmd to drive */
 	ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL);
-
-	return pmac_ide_dma_begin(drive);
 }
 
 /*
  * Kick the DMA controller into life after the DMA command has been issued
  * to the drive.
  */
-static int __pmac
-pmac_ide_dma_begin (ide_drive_t *drive)
+static void __pmac
+pmac_ide_dma_start(ide_drive_t *drive)
 {
 	pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
 	volatile struct dbdma_regs __iomem *dma;
 
-	if (pmif == NULL)
-		return 1;
 	dma = pmif->dma_regs;
 
 	writel((RUN << 16) | RUN, &dma->control);
 	/* Make sure it gets to the controller right now */
 	(void)readl(&dma->control);
-	return 0;
 }
 
 /*
@@ -2130,41 +2006,25 @@
 	pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent(
 		hwif->pci_dev,
 		(MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
-		&pmif->dma_table_dma);
+		&hwif->dmatable_dma);
 	if (pmif->dma_table_cpu == NULL) {
 		printk(KERN_ERR "%s: unable to allocate DMA command list\n",
 		       hwif->name);
 		return;
 	}
 
-	pmif->sg_table = kmalloc(sizeof(struct scatterlist) * MAX_DCMDS,
-				 GFP_KERNEL);
-	if (pmif->sg_table == NULL) {
-		pci_free_consistent(	hwif->pci_dev,
-					(MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
-				    	pmif->dma_table_cpu, pmif->dma_table_dma);
-		return;
-	}
 	hwif->ide_dma_off_quietly = &__ide_dma_off_quietly;
 	hwif->ide_dma_on = &__ide_dma_on;
 	hwif->ide_dma_check = &pmac_ide_dma_check;
-	hwif->ide_dma_read = &pmac_ide_dma_read;
-	hwif->ide_dma_write = &pmac_ide_dma_write;
-	hwif->ide_dma_begin = &pmac_ide_dma_begin;
+	hwif->dma_setup = &pmac_ide_dma_setup;
+	hwif->dma_exec_cmd = &pmac_ide_dma_exec_cmd;
+	hwif->dma_start = &pmac_ide_dma_start;
 	hwif->ide_dma_end = &pmac_ide_dma_end;
 	hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq;
 	hwif->ide_dma_host_off = &pmac_ide_dma_host_off;
 	hwif->ide_dma_host_on = &pmac_ide_dma_host_on;
-	hwif->ide_dma_verbose = &__ide_dma_verbose;
 	hwif->ide_dma_timeout = &__ide_dma_timeout;
 	hwif->ide_dma_lostirq = &pmac_ide_dma_lostirq;
-
-#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO
-	if (!noautodma)
-		hwif->autodma = 1;
-#endif
-	hwif->drives[0].autodma = hwif->autodma;
-	hwif->drives[1].autodma = hwif->autodma;
 
 	hwif->atapi_dma = 1;
 	switch(pmif->kind) {
diff -Nru a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
--- a/drivers/ide/setup-pci.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/ide/setup-pci.c	2004-12-24 13:36:48 -08:00
@@ -185,19 +185,16 @@
 second_chance_to_dma:
 #endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */
 
-	if ((hwif->mmio) && (hwif->dma_base))
+	if (hwif->mmio)
 		return hwif->dma_base;
 
 	if (hwif->mate && hwif->mate->dma_base) {
 		dma_base = hwif->mate->dma_base - (hwif->channel ? 0 : 8);
 	} else {
-		dma_base = (hwif->mmio) ?
-			((unsigned long) hwif->hwif_data) :
-			(pci_resource_start(dev, 4));
+		dma_base = pci_resource_start(dev, 4);
 		if (!dma_base) {
-			printk(KERN_ERR "%s: dma_base is invalid (0x%04lx)\n",
-				hwif->cds->name, dma_base);
-			dma_base = 0;
+			printk(KERN_ERR "%s: dma_base is invalid\n",
+					hwif->cds->name);
 		}
 	}
 
@@ -251,7 +248,6 @@
 				simplex_stat = hwif->INB(dma_base + 2);
 				if (simplex_stat & 0x80) {
 					/* simplex device? */
-#if 0					
 /*
  *	At this point we haven't probed the drives so we can't make the
  *	appropriate decision. Really we should defer this problem
@@ -259,18 +255,7 @@
  *	to be the DMA end. This has to be become dynamic to handle hot
  *	plug.
  */
-					/* Don't enable DMA on a simplex channel with no drives */
-					if (!hwif->drives[0].present && !hwif->drives[1].present)
-					{
-						printk(KERN_INFO "%s: simplex device with no drives: DMA disabled\n",
-								hwif->cds->name);
-						dma_base = 0;
-					}
-					/* If our other channel has DMA then we cannot */
-					else 
-#endif					
-					if(hwif->mate && hwif->mate->dma_base) 
-					{
+					if (hwif->mate && hwif->mate->dma_base) {
 						printk(KERN_INFO "%s: simplex device: "
 							"DMA disabled\n",
 							hwif->cds->name);
@@ -488,13 +473,8 @@
  			 * Set up BM-DMA capability
 			 * (PnP BIOS should have done this)
  			 */
-			if ((d->flags & IDEPCI_FLAG_FORCE_MASTER) == 0) {
-				/*
-				 * default DMA off if we had to
-				 * configure it here
-				 */
-				hwif->autodma = 0;
-			}
+			/* default DMA off if we had to configure it here */
+			hwif->autodma = 0;
 			pci_set_master(dev);
 			if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) {
 				printk(KERN_ERR "%s: %s error updating PCICMD\n",
@@ -514,6 +494,11 @@
 		}
 	}
 }
+
+#ifndef CONFIG_IDEDMA_PCI_AUTO
+#warning CONFIG_IDEDMA_PCI_AUTO=n support is obsolete, and will be removed soon.
+#endif
+
 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI*/
 
 /**
@@ -530,13 +515,9 @@
  
 static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, int noisy, int *config)
 {
-	int ret = 0;
 	u32 class_rev;
 	u16 pcicmd;
 
-	if (!noautodma)
-		ret = 1;
-
 	if (noisy)
 		ide_setup_pci_noise(dev, d);
 
@@ -550,8 +531,6 @@
 	if (!(pcicmd & PCI_COMMAND_IO)) {	/* is device disabled? */
 		if (ide_pci_configure(dev, d))
 			return -ENODEV;
-		/* default DMA off if we had to configure it here */
-		ret = 0;
 		*config = 1;
 		printk(KERN_INFO "%s: device enabled (Linux)\n", d->name);
 	}
@@ -560,14 +539,13 @@
 	class_rev &= 0xff;
 	if (noisy)
 		printk(KERN_INFO "%s: chipset revision %d\n", d->name, class_rev);
-	return ret;
+	return 0;
 }
 
 /**
  *	ide_pci_setup_ports	-	configure ports/devices on PCI IDE
  *	@dev: PCI device
  *	@d: IDE pci device info
- *	@autodma: Should we enable DMA
  *	@pciirq: IRQ line
  *	@index: ata index to update
  *
@@ -580,7 +558,7 @@
  *	where the chipset setup is not the default PCI IDE one.
  */
  
-void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int autodma, int pciirq, ata_index_t *index)
+void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, ata_index_t *index)
 {
 	int port;
 	int at_least_one_hwif_enabled = 0;
@@ -634,11 +612,7 @@
 
 		if (d->autodma == NODMA)
 			goto bypass_legacy_dma;
-		if (d->autodma == NOAUTODMA)
-			autodma = 0;
-		if (autodma)
-			hwif->autodma = 1;
-			
+
 		if(d->init_setup_dma)
 			d->init_setup_dma(dev, d, hwif);
 		else
@@ -671,12 +645,11 @@
  */
 static ata_index_t do_ide_setup_pci_device (struct pci_dev *dev, ide_pci_device_t *d, u8 noisy)
 {
-	int autodma = 0;
 	int pciirq = 0;
 	int tried_config = 0;
 	ata_index_t index = { .b = { .low = 0xff, .high = 0xff } };
 
-	if((autodma = ide_setup_pci_controller(dev, d, noisy, &tried_config)) < 0)
+	if (ide_setup_pci_controller(dev, d, noisy, &tried_config) < 0)
 		return index;
 
 	/*
@@ -724,7 +697,7 @@
 	if(pciirq < 0)		/* Error not an IRQ */
 		return index;
 
-	ide_pci_setup_ports(dev, d, autodma, pciirq, &index);
+	ide_pci_setup_ports(dev, d, pciirq, &index);
 
 	return index;
 }
@@ -734,9 +707,9 @@
 	ata_index_t index_list = do_ide_setup_pci_device(dev, d, 1);
 
 	if ((index_list.b.low & 0xf0) != 0xf0)
-		probe_hwif_init(&ide_hwifs[index_list.b.low]);
+		probe_hwif_init_with_fixup(&ide_hwifs[index_list.b.low], d->fixup);
 	if ((index_list.b.high & 0xf0) != 0xf0)
-		probe_hwif_init(&ide_hwifs[index_list.b.high]);
+		probe_hwif_init_with_fixup(&ide_hwifs[index_list.b.high], d->fixup);
 
 	create_proc_ide_interfaces();
 }
diff -Nru a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
--- a/drivers/ieee1394/eth1394.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/ieee1394/eth1394.c	2004-12-24 13:37:00 -08:00
@@ -190,8 +190,7 @@
 static int ether1394_tx(struct sk_buff *skb, struct net_device *dev);
 static void ether1394_iso(struct hpsb_iso *iso);
 
-static int ether1394_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
-static int ether1394_ethtool_ioctl(struct net_device *dev, void __user *useraddr);
+static struct ethtool_ops ethtool_ops;
 
 static int ether1394_write(struct hpsb_host *host, int srcid, int destid,
 			   quadlet_t *data, u64 addr, size_t len, u16 flags);
@@ -216,7 +215,7 @@
 /* This is called after an "ifup" */
 static int ether1394_open (struct net_device *dev)
 {
-	struct eth1394_priv *priv = dev->priv;
+	struct eth1394_priv *priv = netdev_priv(dev);
 	int ret = 0;
 
 	/* Something bad happened, don't even try */
@@ -261,7 +260,7 @@
 /* Return statistics to the caller */
 static struct net_device_stats *ether1394_stats (struct net_device *dev)
 {
-	return &(((struct eth1394_priv *)dev->priv)->stats);
+	return &(((struct eth1394_priv *)netdev_priv(dev))->stats);
 }
 
 /* What to do if we timeout. I think a host reset is probably in order, so
@@ -269,16 +268,16 @@
 static void ether1394_tx_timeout (struct net_device *dev)
 {
 	ETH1394_PRINT (KERN_ERR, dev->name, "Timeout, resetting host %s\n",
-		       ((struct eth1394_priv *)(dev->priv))->host->driver->name);
+		       ((struct eth1394_priv *)netdev_priv(dev))->host->driver->name);
 
-	highlevel_host_reset (((struct eth1394_priv *)(dev->priv))->host);
+	highlevel_host_reset (((struct eth1394_priv *)netdev_priv(dev))->host);
 
 	netif_wake_queue (dev);
 }
 
 static int ether1394_change_mtu(struct net_device *dev, int new_mtu)
 {
-	struct eth1394_priv *priv = dev->priv;
+	struct eth1394_priv *priv = netdev_priv(dev);
 
 	if ((new_mtu < 68) ||
 	    (new_mtu > min(ETH1394_DATA_LEN,
@@ -379,7 +378,7 @@
 	ud->device.driver_data = node_info;
 	new_node->ud = ud;
 
-	priv = (struct eth1394_priv *)hi->dev->priv;
+	priv = netdev_priv(hi->dev);
 	list_add_tail(&new_node->list, &priv->ip_node_list);
 
 	return 0;
@@ -400,7 +399,7 @@
 	if (!hi)
 		return -ENOENT;
 
-	priv = (struct eth1394_priv *)hi->dev->priv;
+	priv = netdev_priv(hi->dev);
 
 	old_node = eth1394_find_node(&priv->ip_node_list, ud);
 
@@ -435,7 +434,7 @@
 	if (!hi)
 		return -ENOENT;
 
-	priv = (struct eth1394_priv *)hi->dev->priv;
+	priv = netdev_priv(hi->dev);
 
 	node = eth1394_find_node(&priv->ip_node_list, ud);
 
@@ -459,7 +458,7 @@
 		ud->device.driver_data = node_info;
 		node->ud = ud;
 
-		priv = (struct eth1394_priv *)hi->dev->priv;
+		priv = netdev_priv(hi->dev);
 		list_add_tail(&node->list, &priv->ip_node_list);
 	}
 
@@ -496,7 +495,7 @@
 {
 	unsigned long flags;
 	int i;
-	struct eth1394_priv *priv = dev->priv;
+	struct eth1394_priv *priv = netdev_priv(dev);
 	struct hpsb_host *host = priv->host;
 	u64 guid = *((u64*)&(host->csr.rom->bus_info_data[3]));
 	u16 maxpayload = 1 << (host->csr.max_rec + 1);
@@ -547,7 +546,7 @@
 	dev->header_cache_update= ether1394_header_cache_update;
 	dev->hard_header_parse	= ether1394_header_parse;
 	dev->set_mac_address	= ether1394_mac_addr;
-	dev->do_ioctl		= ether1394_do_ioctl;
+	SET_ETHTOOL_OPS(dev, &ethtool_ops);
 
 	/* Some constants */
 	dev->watchdog_timeo	= ETHER1394_TIMEOUT;
@@ -601,8 +600,9 @@
         }
 
 	SET_MODULE_OWNER(dev);
+	SET_NETDEV_DEV(dev, &host->device);
 
-	priv = (struct eth1394_priv *)dev->priv;
+	priv = netdev_priv(dev);
 
 	INIT_LIST_HEAD(&priv->ip_node_list);
 
@@ -672,7 +672,7 @@
 
 	hi = hpsb_get_hostinfo(&eth1394_highlevel, host);
 	if (hi != NULL) {
-		struct eth1394_priv *priv = (struct eth1394_priv *)hi->dev->priv;
+		struct eth1394_priv *priv = netdev_priv(hi->dev);
 
 		hpsb_unregister_addrspace(&eth1394_highlevel, host,
 					  priv->local_fifo);
@@ -707,7 +707,7 @@
 		return;
 
 	dev = hi->dev;
-	priv = (struct eth1394_priv *)dev->priv;
+	priv = netdev_priv(dev);
 
 	/* Reset our private host data, but not our mtu */
 	netif_stop_queue (dev);
@@ -882,7 +882,7 @@
 					nodeid_t srcid, nodeid_t destid,
 					u16 ether_type)
 {
-	struct eth1394_priv *priv = dev->priv;
+	struct eth1394_priv *priv = netdev_priv(dev);
 	u64 dest_hw;
 	unsigned short ret = 0;
 
@@ -1112,7 +1112,7 @@
 {
 	struct sk_buff *skb;
 	unsigned long flags;
-	struct eth1394_priv *priv = (struct eth1394_priv *)dev->priv;
+	struct eth1394_priv *priv = netdev_priv(dev);
 	union eth1394_hdr *hdr = (union eth1394_hdr *)buf;
 	u16 ether_type = 0;  /* initialized to clear warning */
 	int hdr_len;
@@ -1350,7 +1350,7 @@
 				((be32_to_cpu(data[1]) & 0xff000000) >> 24));
 		source_id = be32_to_cpu(data[0]) >> 16;
 
-		priv = (struct eth1394_priv *)dev->priv;
+		priv = netdev_priv(dev);
 
 		if (info->channel != (iso->host->csr.broadcast_channel & 0x3f) ||
 		   specifier_id != ETHER1394_GASP_SPECIFIER_ID) {
@@ -1384,7 +1384,7 @@
 static inline void ether1394_arp_to_1394arp(struct sk_buff *skb,
 					    struct net_device *dev)
 {
-	struct eth1394_priv *priv = (struct eth1394_priv *)(dev->priv);
+	struct eth1394_priv *priv = netdev_priv(dev);
 
 	struct arphdr *arp = (struct arphdr *)skb->data;
 	unsigned char *arp_ptr = (unsigned char *)(arp + 1);
@@ -1582,7 +1582,7 @@
 {
 	struct sk_buff *skb = ptask->skb;
 	struct net_device *dev = skb->dev;
-	struct eth1394_priv *priv = dev->priv;
+	struct eth1394_priv *priv = netdev_priv(dev);
         unsigned long flags;
 
 	/* Statistics */
@@ -1635,7 +1635,7 @@
 {
 	int kmflags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
 	struct eth1394hdr *eth;
-	struct eth1394_priv *priv = dev->priv;
+	struct eth1394_priv *priv = netdev_priv(dev);
 	int proto;
 	unsigned long flags;
 	nodeid_t dest_node;
@@ -1768,53 +1768,17 @@
 	return 0;  /* returning non-zero causes serious problems */
 }
 
-static int ether1394_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	switch(cmd) {
-		case SIOCETHTOOL:
-			return ether1394_ethtool_ioctl(dev, ifr->ifr_data);
-
-		case SIOCGMIIPHY:		/* Get address of MII PHY in use. */
-		case SIOCGMIIREG:		/* Read MII PHY register. */
-		case SIOCSMIIREG:		/* Write MII PHY register. */
-		default:
-			return -EOPNOTSUPP;
-	}
-
-	return 0;
-}
-
-static int ether1394_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
-{
-	u32 ethcmd;
-
-	if (get_user(ethcmd, (u32 __user *)useraddr))
-		return -EFAULT;
-
-	switch (ethcmd) {
-		case ETHTOOL_GDRVINFO: {
-			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-			strcpy (info.driver, driver_name);
-			strcpy (info.version, "$Rev: 1224 $");
-			/* FIXME XXX provide sane businfo */
-			strcpy (info.bus_info, "ieee1394");
-			if (copy_to_user (useraddr, &info, sizeof (info)))
-				return -EFAULT;
-			break;
-		}
-		case ETHTOOL_GSET:
-		case ETHTOOL_SSET:
-		case ETHTOOL_NWAY_RST:
-		case ETHTOOL_GLINK:
-		case ETHTOOL_GMSGLVL:
-		case ETHTOOL_SMSGLVL:
-		default:
-			return -EOPNOTSUPP;
-	}
-
-	return 0;
+	strcpy (info->driver, driver_name);
+	strcpy (info->version, "$Rev: 1224 $");
+	/* FIXME XXX provide sane businfo */
+	strcpy (info->bus_info, "ieee1394");
 }
 
+static struct ethtool_ops ethtool_ops = {
+	.get_drvinfo = ether1394_get_drvinfo
+};
 
 static int __init ether1394_init_module (void)
 {
diff -Nru a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
--- a/drivers/ieee1394/nodemgr.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/ieee1394/nodemgr.c	2004-12-24 13:37:00 -08:00
@@ -70,8 +70,7 @@
 		if (!ret)
 			break;
 
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (schedule_timeout (HZ/3))
+		if (msleep_interruptible(334))
 			return -EINTR;
 	}
 
@@ -1489,14 +1488,16 @@
 			break;
 		}
 
-		if (hi->kill_me)
+		if (hi->kill_me) {
+			up(&nodemgr_serialize);
 			break;
+		}
 
 		/* Pause for 1/4 second in 1/16 second intervals,
 		 * to make sure things settle down. */
 		for (i = 0; i < 4 ; i++) {
 			set_current_state(TASK_INTERRUPTIBLE);
-			if (schedule_timeout(HZ/16)) {
+			if (msleep_interruptible(63)) {
 				up(&nodemgr_serialize);
 				goto caught_signal;
 			}
@@ -1514,8 +1515,10 @@
 				i = 0;
 
 			/* Check the kill_me again */
-			if (hi->kill_me)
+			if (hi->kill_me) {
+				up(&nodemgr_serialize);
 				goto caught_signal;
+			}
 		}
 
 		if (!nodemgr_check_irm_capability(host, reset_cycles)) {
diff -Nru a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
--- a/drivers/ieee1394/ohci1394.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/ieee1394/ohci1394.c	2004-12-24 13:37:18 -08:00
@@ -94,7 +94,6 @@
 #include <linux/pci.h>
 #include <linux/fs.h>
 #include <linux/poll.h>
-#include <linux/irq.h>
 #include <asm/byteorder.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
@@ -103,6 +102,7 @@
 
 #include <asm/pgtable.h>
 #include <asm/page.h>
+#include <asm/irq.h>
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/vmalloc.h>
@@ -2933,8 +2933,8 @@
 	d->ctrlClear = 0;
 	d->cmdPtr = 0;
 
-	d->buf_cpu = kmalloc(d->num_desc * sizeof(quadlet_t*), GFP_KERNEL);
-	d->buf_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL);
+	d->buf_cpu = kmalloc(d->num_desc * sizeof(quadlet_t*), GFP_ATOMIC);
+	d->buf_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC);
 
 	if (d->buf_cpu == NULL || d->buf_bus == NULL) {
 		PRINT(KERN_ERR, "Failed to allocate dma buffer");
@@ -2945,8 +2945,8 @@
 	memset(d->buf_bus, 0, d->num_desc * sizeof(dma_addr_t));
 
 	d->prg_cpu = kmalloc(d->num_desc * sizeof(struct dma_cmd*),
-			     GFP_KERNEL);
-	d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL);
+				GFP_ATOMIC);
+	d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC);
 
 	if (d->prg_cpu == NULL || d->prg_bus == NULL) {
 		PRINT(KERN_ERR, "Failed to allocate dma prg");
@@ -2956,7 +2956,7 @@
 	memset(d->prg_cpu, 0, d->num_desc * sizeof(struct dma_cmd*));
 	memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t));
 
-	d->spb = kmalloc(d->split_buf_size, GFP_KERNEL);
+	d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC);
 
 	if (d->spb == NULL) {
 		PRINT(KERN_ERR, "Failed to allocate split buffer");
diff -Nru a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
--- a/drivers/ieee1394/pcilynx.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/ieee1394/pcilynx.c	2004-12-24 13:36:47 -08:00
@@ -42,12 +42,12 @@
 #include <linux/pci.h>
 #include <linux/fs.h>
 #include <linux/poll.h>
-#include <linux/irq.h>
 #include <linux/kdev_t.h>
 #include <asm/byteorder.h>
 #include <asm/atomic.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
+#include <asm/irq.h>
 
 #include "csr1212.h"
 #include "ieee1394.h"
diff -Nru a/drivers/ieee1394/pcilynx.h b/drivers/ieee1394/pcilynx.h
--- a/drivers/ieee1394/pcilynx.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/ieee1394/pcilynx.h	2004-12-24 13:36:16 -08:00
@@ -49,10 +49,10 @@
                have_1394_buffers, have_iomappings, is_host } state;
 
         /* remapped memory spaces */
-        void *registers;
-        void *local_rom;
-        void *local_ram;
-        void *aux_port;
+        void __iomem *registers;
+        void __iomem *local_rom;
+        void __iomem *local_ram;
+        void __iomem *aux_port;
 	quadlet_t bus_info_block[5];
 
 #ifdef CONFIG_IEEE1394_PCILYNX_PORTS
diff -Nru a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
--- a/drivers/ieee1394/sbp2.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/ieee1394/sbp2.c	2004-12-24 13:36:18 -08:00
@@ -357,8 +357,7 @@
 	int i;
 
 	for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (schedule_timeout(HZ/10))	/* 100ms */
+		if (msleep_interruptible(100))	/* 100ms */
 			return(1);
 	}
 	return ((i > 0) ? 0:1);
@@ -1088,7 +1087,7 @@
 	scsi_id->query_logins_orb->query_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
 	SBP2_DEBUG("sbp2_query_logins: query_response_hi/lo initialized");
 
-	scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(QUERY_LOGINS_REQUEST);
+	scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST);
 	scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1);
 	if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) {
 		scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun);
@@ -1199,7 +1198,7 @@
 	scsi_id->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
 	SBP2_DEBUG("sbp2_login_device: login_response_hi/lo initialized");
 
-	scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(LOGIN_REQUEST);
+	scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST);
 	scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0);	/* One second reconnect time */
 	scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login);	/* Exclusive access to device */
 	scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1);	/* Notify us of login complete */
@@ -1325,7 +1324,7 @@
 	scsi_id->logout_orb->reserved3 = 0x0;
 	scsi_id->logout_orb->reserved4 = 0x0;
 
-	scsi_id->logout_orb->login_ID_misc = ORB_SET_FUNCTION(LOGOUT_REQUEST);
+	scsi_id->logout_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_LOGOUT_REQUEST);
 	scsi_id->logout_orb->login_ID_misc |= ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID);
 
 	/* Notify us when complete */
@@ -1390,7 +1389,7 @@
 	scsi_id->reconnect_orb->reserved3 = 0x0;
 	scsi_id->reconnect_orb->reserved4 = 0x0;
 
-	scsi_id->reconnect_orb->login_ID_misc = ORB_SET_FUNCTION(RECONNECT_REQUEST);
+	scsi_id->reconnect_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_RECONNECT_REQUEST);
 	scsi_id->reconnect_orb->login_ID_misc |=
 		ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID);
 
diff -Nru a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
--- a/drivers/ieee1394/sbp2.h	2004-12-24 13:36:19 -08:00
+++ b/drivers/ieee1394/sbp2.h	2004-12-24 13:36:19 -08:00
@@ -52,15 +52,15 @@
 	u8 cdb[12];
 };
 
-#define LOGIN_REQUEST			0x0
-#define QUERY_LOGINS_REQUEST		0x1
-#define RECONNECT_REQUEST		0x3
-#define SET_PASSWORD_REQUEST		0x4
-#define LOGOUT_REQUEST			0x7
-#define ABORT_TASK_REQUEST		0xb
-#define ABORT_TASK_SET			0xc
-#define LOGICAL_UNIT_RESET		0xe
-#define TARGET_RESET_REQUEST		0xf
+#define SBP2_LOGIN_REQUEST		0x0
+#define SBP2_QUERY_LOGINS_REQUEST	0x1
+#define SBP2_RECONNECT_REQUEST		0x3
+#define SBP2_SET_PASSWORD_REQUEST	0x4
+#define SBP2_LOGOUT_REQUEST		0x7
+#define SBP2_ABORT_TASK_REQUEST		0xb
+#define SBP2_ABORT_TASK_SET		0xc
+#define SBP2_LOGICAL_UNIT_RESET		0xe
+#define SBP2_TARGET_RESET_REQUEST	0xf
 
 #define ORB_SET_LUN(value)                      (value & 0xffff)
 #define ORB_SET_FUNCTION(value)                 ((value & 0xf) << 16)
diff -Nru a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
--- a/drivers/ieee1394/video1394.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/ieee1394/video1394.c	2004-12-24 13:36:19 -08:00
@@ -1157,7 +1157,7 @@
  *
  *  FIXME:
  *  - PAGE_READONLY should suffice!?
- *  - remap_page_range is kind of inefficient for page by page remapping.
+ *  - remap_pfn_range is kind of inefficient for page by page remapping.
  *    But e.g. pte_alloc() does not work in modules ... :-(
  */
 
diff -Nru a/drivers/input/evdev.c b/drivers/input/evdev.c
--- a/drivers/input/evdev.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/input/evdev.c	2004-12-24 13:37:03 -08:00
@@ -91,8 +91,6 @@
 
 static void evdev_free(struct evdev *evdev)
 {
-	devfs_remove("input/event%d", evdev->minor);
-	class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
 	evdev_table[evdev->minor] = NULL;
 	kfree(evdev);
 }
@@ -441,6 +439,8 @@
 {
 	struct evdev *evdev = handle->private;
 
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
+	devfs_remove("input/event%d", evdev->minor);
 	evdev->exist = 0;
 
 	if (evdev->open) {
diff -Nru a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
--- a/drivers/input/gameport/fm801-gp.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/input/gameport/fm801-gp.c	2004-12-24 13:36:59 -08:00
@@ -98,8 +98,8 @@
 	pci_enable_device(pci);
 	gp->gameport.io = pci_resource_start(pci, 0);
 	if ((gp->res_port = request_region(gp->gameport.io, 0x10, "FM801 GP")) == NULL) {
-		kfree(gp);
 		printk("unable to grab region 0x%x-0x%x\n", gp->gameport.io, gp->gameport.io + 0x0f);
+		kfree(gp);
 		return -1;
 	}
 
diff -Nru a/drivers/input/input.c b/drivers/input/input.c
--- a/drivers/input/input.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/input/input.c	2004-12-24 13:36:56 -08:00
@@ -19,7 +19,7 @@
 #include <linux/major.h>
 #include <linux/pm.h>
 #include <linux/proc_fs.h>
-#include <linux/kmod.h>
+#include <linux/kobject_uevent.h>
 #include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/device.h>
diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
--- a/drivers/input/joydev.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/input/joydev.c	2004-12-24 13:36:49 -08:00
@@ -143,9 +143,7 @@
 
 static void joydev_free(struct joydev *joydev)
 {
-	devfs_remove("input/js%d", joydev->minor);
 	joydev_table[joydev->minor] = NULL;
-	class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
 	kfree(joydev);
 }
 
@@ -466,6 +464,8 @@
 {
 	struct joydev *joydev = handle->private;
 
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
+	devfs_remove("input/js%d", joydev->minor);
 	joydev->exist = 0;
 
 	if (joydev->open)
diff -Nru a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c
--- a/drivers/input/joystick/amijoy.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/input/joystick/amijoy.c	2004-12-24 13:37:01 -08:00
@@ -46,8 +46,7 @@
 MODULE_LICENSE("GPL");
 
 static int amijoy[2] = { 0, 1 };
-static int amijoy_nargs;
-module_param_array_named(map, amijoy, uint, amijoy_nargs, 0);
+module_param_array_named(map, amijoy, uint, NULL, 0);
 MODULE_PARM_DESC(map, "Map of attached joysticks in form of <a>,<b> (default is 0,1)");
 
 __obsolete_setup("amijoy=");
diff -Nru a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
--- a/drivers/input/joystick/analog.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/input/joystick/analog.c	2004-12-24 13:37:19 -08:00
@@ -53,7 +53,7 @@
 static char *js[ANALOG_PORTS];
 static int js_nargs;
 static int analog_options[ANALOG_PORTS];
-module_param_array_named(map, js, charp, js_nargs, 0);
+module_param_array_named(map, js, charp, &js_nargs, 0);
 MODULE_PARM_DESC(map, "Describes analog joysticks type/capabilities");
 
 __obsolete_setup("js=");
diff -Nru a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
--- a/drivers/input/joystick/db9.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/input/joystick/db9.c	2004-12-24 13:36:31 -08:00
@@ -45,17 +45,17 @@
 
 static int db9[] __initdata = { -1, 0 };
 static int db9_nargs __initdata = 0;
-module_param_array_named(dev, db9, int, db9_nargs, 0);
+module_param_array_named(dev, db9, int, &db9_nargs, 0);
 MODULE_PARM_DESC(dev, "Describes first attached device (<parport#>,<type>)");
 
 static int db9_2[] __initdata = { -1, 0 };
 static int db9_nargs_2 __initdata = 0;
-module_param_array_named(dev2, db9_2, int, db9_nargs_2, 0);
+module_param_array_named(dev2, db9_2, int, &db9_nargs_2, 0);
 MODULE_PARM_DESC(dev2, "Describes second attached device (<parport#>,<type>)");
 
 static int db9_3[] __initdata = { -1, 0 };
 static int db9_nargs_3 __initdata = 0;
-module_param_array_named(dev3, db9_3, int, db9_nargs_3, 0);
+module_param_array_named(dev3, db9_3, int, &db9_nargs_3, 0);
 MODULE_PARM_DESC(dev3, "Describes third attached device (<parport#>,<type>)");
 
 __obsolete_setup("db9=");
diff -Nru a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
--- a/drivers/input/joystick/gamecon.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/input/joystick/gamecon.c	2004-12-24 13:37:32 -08:00
@@ -43,17 +43,17 @@
 
 static int gc[] __initdata = { -1, 0, 0, 0, 0, 0 };
 static int gc_nargs __initdata = 0;
-module_param_array_named(map, gc, int, gc_nargs, 0);
+module_param_array_named(map, gc, int, &gc_nargs, 0);
 MODULE_PARM_DESC(map, "Describers first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)");
 
 static int gc_2[] __initdata = { -1, 0, 0, 0, 0, 0 };
 static int gc_nargs_2 __initdata = 0;
-module_param_array_named(map2, gc_2, int, gc_nargs_2, 0);
+module_param_array_named(map2, gc_2, int, &gc_nargs_2, 0);
 MODULE_PARM_DESC(map2, "Describers second set of devices");
 
 static int gc_3[] __initdata = { -1, 0, 0, 0, 0, 0 };
 static int gc_nargs_3 __initdata = 0;
-module_param_array_named(map3, gc_3, int, gc_nargs_3, 0);
+module_param_array_named(map3, gc_3, int, &gc_nargs_3, 0);
 MODULE_PARM_DESC(map3, "Describers third set of devices");
 
 __obsolete_setup("gc=");
diff -Nru a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
--- a/drivers/input/joystick/turbografx.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/input/joystick/turbografx.c	2004-12-24 13:37:04 -08:00
@@ -44,17 +44,17 @@
 
 static int tgfx[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 };
 static int tgfx_nargs __initdata = 0;
-module_param_array_named(map, tgfx, int, tgfx_nargs, 0);
+module_param_array_named(map, tgfx, int, &tgfx_nargs, 0);
 MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<js1>,<js2>,..<js7>");
 
 static int tgfx_2[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 };
 static int tgfx_nargs_2 __initdata = 0;
-module_param_array_named(map2, tgfx_2, int, tgfx_nargs_2, 0);
+module_param_array_named(map2, tgfx_2, int, &tgfx_nargs_2, 0);
 MODULE_PARM_DESC(map2, "Describes second set of devices");
 
 static int tgfx_3[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 };
 static int tgfx_nargs_3 __initdata = 0;
-module_param_array_named(map3, tgfx_3, int, tgfx_nargs_3, 0);
+module_param_array_named(map3, tgfx_3, int, &tgfx_nargs_3, 0);
 MODULE_PARM_DESC(map3, "Describes third set of devices");
 
 __obsolete_setup("tgfx=");
diff -Nru a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
--- a/drivers/input/mouse/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/drivers/input/mouse/Kconfig	2004-12-24 13:37:18 -08:00
@@ -125,6 +125,6 @@
 	  puck) or a VSXXX-GA (rectangular) mouse. Theses mice are
 	  typically used on DECstations or VAXstations, but can also
 	  be used on any box capable of RS232 (with some adaptor
-	  described in the source file). This driver should, in theory,
-	  also work with the digitizer DEC produced, but it isn't tested
-	  with that (I don't have the hardware yet).
+	  described in the source file). This driver also works with the
+	  digitizer (VSXXX-AB) DEC produced.
+
diff -Nru a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
--- a/drivers/input/mouse/pc110pad.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/input/mouse/pc110pad.c	2004-12-24 13:36:47 -08:00
@@ -38,6 +38,7 @@
 #include <linux/input.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/pci.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -107,8 +108,22 @@
 	return 0;
 }
 
+/*
+ * We try to avoid enabling the hardware if it's not
+ * there, but we don't know how to test. But we do know
+ * that the PC110 is not a PCI system. So if we find any
+ * PCI devices in the machine, we don't have a PC110.
+ */
 static int __init pc110pad_init(void)
 {
+	struct pci_dev *dev;
+
+	dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
+	if (dev) {
+		pci_dev_put(dev);
+		return -ENOENT;
+	}
+
 	if (!request_region(pc110pad_io, 4, "pc110pad")) {
 		printk(KERN_ERR "pc110pad: I/O area %#x-%#x in use.\n",
 				pc110pad_io, pc110pad_io + 4);
diff -Nru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
--- a/drivers/input/mousedev.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/input/mousedev.c	2004-12-24 13:37:19 -08:00
@@ -329,8 +329,6 @@
 
 static void mousedev_free(struct mousedev *mousedev)
 {
-	devfs_remove("input/mouse%d", mousedev->minor);
-	class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
 	mousedev_table[mousedev->minor] = NULL;
 	kfree(mousedev);
 }
@@ -640,6 +638,8 @@
 {
 	struct mousedev *mousedev = handle->private;
 
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
+	devfs_remove("input/mouse%d", mousedev->minor);
 	mousedev->exist = 0;
 
 	if (mousedev->open) {
diff -Nru a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
--- a/drivers/input/serio/Kconfig	2004-12-24 13:36:55 -08:00
+++ b/drivers/input/serio/Kconfig	2004-12-24 13:36:55 -08:00
@@ -20,7 +20,7 @@
 	tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86
 	default y
 	select SERIO
-	depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST)
+	depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && !M68K
 	---help---
 	  i8042 is the chip over which the standard AT keyboard and PS/2
 	  mouse are connected to the computer. If you use these devices,
diff -Nru a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
--- a/drivers/input/serio/i8042-io.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/input/serio/i8042-io.h	2004-12-24 13:36:16 -08:00
@@ -35,6 +35,7 @@
 # define I8042_AUX_IRQ	12
 #endif
 
+
 /*
  * Register numbers.
  */
@@ -96,7 +97,7 @@
  * On ix86 platforms touching the i8042 data register region can do really
  * bad things. Because of this the region is always reserved on ix86 boxes.
  */
-#if !defined(__i386__) && !defined(__sh__) && !defined(__alpha__) && !defined(__x86_64__) && !defined(__mips__)
+#if !defined(__i386__) && !defined(__sh__) && !defined(__alpha__) && !defined(__x86_64__) && !defined(__mips__) && !defined (CONFIG_PPC64)
 	if (!request_region(I8042_DATA_REG, 16, "i8042"))
 		return -1;
 #endif
@@ -110,12 +111,18 @@
 		i8042_noloop = 1;
 #endif
 
+#if defined(CONFIG_PPC64)
+	if (check_legacy_ioport(I8042_DATA_REG))
+		return -1;
+	if (!request_region(I8042_DATA_REG, 16, "i8042"))
+		return -1;
+#endif
 	return 0;
 }
 
 static inline void i8042_platform_exit(void)
 {
-#if !defined(__i386__) && !defined(__sh__) && !defined(__alpha__) && !defined(__x86_64__)
+#if !defined(__i386__) && !defined(__sh__) && !defined(__alpha__) && !defined(__x86_64__) && !defined(CONFIG_PPC64)
 	release_region(I8042_DATA_REG, 16);
 #endif
 }
diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
--- a/drivers/input/serio/i8042.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/input/serio/i8042.c	2004-12-24 13:36:18 -08:00
@@ -813,6 +813,41 @@
 }
 
 
+static int blink_frequency = 500;
+module_param_named(panicblink, blink_frequency, int, 0600);
+
+/* Catch the case when the kbd interrupt is off */
+#define DELAY do { mdelay(1); if (++delay > 10) return delay; } while(0)
+
+/* Tell the user who may be running in X and not see the console that we have
+   panic'ed. This is to distingush panics from "real" lockups.  */
+static long i8042_panic_blink(long count)
+{
+	long delay = 0;
+	static long last_blink;
+	static char led;
+	/* Roughly 1/2s frequency. KDB uses about 1s. Make sure it is
+	   different. */
+	if (!blink_frequency)
+		return 0;
+	if (count - last_blink < blink_frequency)
+		return 0;
+	led ^= 0x01 | 0x04;
+	while (i8042_read_status() & I8042_STR_IBF)
+		DELAY;
+	i8042_write_data(0xed); /* set leds */
+	DELAY;
+	while (i8042_read_status() & I8042_STR_IBF)
+		DELAY;
+	DELAY;
+	i8042_write_data(led);
+	DELAY;
+	last_blink = count;
+	return delay;
+}
+
+#undef DELAY
+
 /*
  * Here we try to restore the original BIOS settings
  */
@@ -863,6 +898,8 @@
  */
 	mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD);
 
+	panic_blink = i8042_panic_blink;
+
 	return 0;
 }
 
@@ -1077,6 +1114,8 @@
 	driver_unregister(&i8042_driver);
 
 	i8042_platform_exit();
+
+	panic_blink = NULL;
 }
 
 module_init(i8042_init);
diff -Nru a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c
--- a/drivers/input/serio/q40kbd.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/input/serio/q40kbd.c	2004-12-24 13:36:31 -08:00
@@ -36,8 +36,8 @@
 #include <linux/serio.h>
 #include <linux/interrupt.h>
 #include <linux/err.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/q40_master.h>
diff -Nru a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
--- a/drivers/input/serio/rpckbd.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/input/serio/rpckbd.c	2004-12-24 13:36:17 -08:00
@@ -45,9 +45,6 @@
 MODULE_DESCRIPTION("Acorn RiscPC PS/2 keyboard controller driver");
 MODULE_LICENSE("GPL");
 
-static struct serio *rpckbd_port;
-static struct platform_device *rpckbd_device;
-
 static int rpckbd_write(struct serio *port, unsigned char val)
 {
 	while (!(iomd_readb(IOMD_KCTRL) & (1 << 7)))
@@ -109,45 +106,50 @@
  * Allocate and initialize serio structure for subsequent registration
  * with serio core.
  */
-
-static struct serio * __init rpckbd_allocate_port(void)
+static int __devinit rpckbd_probe(struct device *dev)
 {
 	struct serio *serio;
 
 	serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
-	if (serio) {
-		memset(serio, 0, sizeof(struct serio));
-		serio->type		= SERIO_8042;
-		serio->write		= rpckbd_write;
-		serio->open		= rpckbd_open;
-		serio->close		= rpckbd_close;
-		serio->dev.parent	= &rpckbd_device->dev;
-		strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name));
-		strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys));
-	}
+	if (!serio)
+		return -ENOMEM;
 
-	return serio;
+	memset(serio, 0, sizeof(struct serio));
+	serio->type		= SERIO_8042;
+	serio->write		= rpckbd_write;
+	serio->open		= rpckbd_open;
+	serio->close		= rpckbd_close;
+	serio->dev.parent	= dev;
+	strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name));
+	strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys));
+
+	dev_set_drvdata(dev, serio);
+	serio_register_port(serio);
+	return 0;
 }
 
-static int __init rpckbd_init(void)
+static int __devexit rpckbd_remove(struct device *dev)
 {
-	rpckbd_device = platform_device_register_simple("rpckbd", -1, NULL, 0);
-	if (IS_ERR(rpckbd_device))
-		return PTR_ERR(rpckbd_device);
+	struct serio *serio = dev_get_drvdata(dev);
+	serio_unregister_port(serio);
+	return 0;
+}
 
-	if (!(rpckbd_port = rpckbd_allocate_port())) {
-		platform_device_unregister(rpckbd_device);
-		return -ENOMEM;
-	}
+static struct device_driver rpckbd_driver = {
+	.name		= "kart",
+	.bus		= &platform_bus_type,
+	.probe		= rpckbd_probe,
+	.remove		= __devexit_p(rpckbd_remove),
+};
 
-	serio_register_port(rpckbd_port);
-	return 0;
+static int __init rpckbd_init(void)
+{
+	return driver_register(&rpckbd_driver);
 }
 
 static void __exit rpckbd_exit(void)
 {
-	serio_unregister_port(rpckbd_port);
-	platform_device_unregister(rpckbd_device);
+	driver_unregister(&rpckbd_driver);
 }
 
 module_init(rpckbd_init);
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/input/serio/serio.c	2004-12-24 13:36:17 -08:00
@@ -246,11 +246,6 @@
 	return sprintf(buf, "%s\n", serio->name);
 }
 
-static ssize_t serio_show_driver(struct device *dev, char *buf)
-{
-	return sprintf(buf, "%s\n", dev->driver ? dev->driver->name : "(none)");
-}
-
 static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count)
 {
 	struct serio *serio = to_serio_port(dev);
@@ -307,7 +302,7 @@
 
 static struct device_attribute serio_device_attrs[] = {
 	__ATTR(description, S_IRUGO, serio_show_description, NULL),
-	__ATTR(driver, S_IWUSR | S_IRUGO, serio_show_driver, serio_rebind_driver),
+	__ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver),
 	__ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode),
 	__ATTR_NULL
 };
diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/input/serio/serport.c	2004-12-24 13:37:19 -08:00
@@ -42,7 +42,7 @@
 static int serport_serio_write(struct serio *serio, unsigned char data)
 {
 	struct serport *serport = serio->port_data;
-	return -(serport->tty->driver->write(serport->tty, 0, &data, 1) != 1);
+	return -(serport->tty->driver->write(serport->tty, &data, 1) != 1);
 }
 
 static void serport_serio_close(struct serio *serio)
diff -Nru a/drivers/input/tsdev.c b/drivers/input/tsdev.c
--- a/drivers/input/tsdev.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/input/tsdev.c	2004-12-24 13:37:29 -08:00
@@ -1,7 +1,7 @@
 /*
  * $Id: tsdev.c,v 1.15 2002/04/10 16:50:19 jsimmons Exp $
  *
- *  Copyright (c) 2001 "Crazy" james Simmons 
+ *  Copyright (c) 2001 "Crazy" james Simmons
  *
  *  Compaq touchscreen protocol driver. The protocol emulated by this driver
  *  is obsolete; for new programs use the tslib library which can read directly
@@ -177,8 +177,6 @@
 
 static void tsdev_free(struct tsdev *tsdev)
 {
-	devfs_remove("input/ts%d", tsdev->minor);
-	class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
 	tsdev_table[tsdev->minor] = NULL;
 	kfree(tsdev);
 }
@@ -418,7 +416,7 @@
 			S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
 	devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2),
 			S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor);
-	class_simple_device_add(input_class, 
+	class_simple_device_add(input_class,
 				MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
 				dev->dev, "ts%d", minor);
 
@@ -429,6 +427,9 @@
 {
 	struct tsdev *tsdev = handle->private;
 
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
+	devfs_remove("input/ts%d", tsdev->minor);
+	devfs_remove("input/tsraw%d", tsdev->minor);
 	tsdev->exist = 0;
 
 	if (tsdev->open) {
@@ -436,7 +437,6 @@
 		wake_up_interruptible(&tsdev->wait);
 	} else
 		tsdev_free(tsdev);
-	devfs_remove("input/tsraw%d", tsdev->minor);
 }
 
 static struct input_device_id tsdev_ids[] = {
diff -Nru a/drivers/isdn/act2000/act2000_isa.c b/drivers/isdn/act2000/act2000_isa.c
--- a/drivers/isdn/act2000/act2000_isa.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/isdn/act2000/act2000_isa.c	2004-12-24 13:36:48 -08:00
@@ -18,13 +18,6 @@
 
 static act2000_card *irq2card_map[16];
 
-static void
-act2000_isa_delay(long t)
-{
-        set_current_state(TASK_INTERRUPTIBLE);
-        schedule_timeout(t);
-}
-
 /*
  * Reset Controller, then try to read the Card's signature.
  + Return:
@@ -419,7 +412,7 @@
 
         if (!act2000_isa_reset(card->port))
                 return -ENXIO;
-        act2000_isa_delay(HZ / 2);
+        msleep_interruptible(500);
         if(copy_from_user(&cblock, cb, sizeof(cblock)))
         	return -EFAULT;
         length = cblock.length;
@@ -452,6 +445,6 @@
                 p += l;
         }
         kfree(buf);
-        act2000_isa_delay(HZ / 2);
+        msleep_interruptible(500);
         return (act2000_isa_getid(card));
 }
diff -Nru a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
--- a/drivers/isdn/capi/capi.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/isdn/capi/capi.c	2004-12-24 13:37:29 -08:00
@@ -38,6 +38,7 @@
 #include <linux/kernelcapi.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/moduleparam.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/isdn/capiutil.h>
 #include <linux/isdn/capicmd.h>
@@ -67,10 +68,10 @@
 int capi_ttyminors = CAPINC_NR_PORTS;
 #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
 
-MODULE_PARM(capi_major, "i");
+module_param_named(major, capi_major, uint, 0);
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
-MODULE_PARM(capi_ttymajor, "i");
-MODULE_PARM(capi_ttyminors, "i");
+module_param_named(ttymajor, capi_ttymajor, uint, 0);
+module_param_named(ttyminors, capi_ttyminors, uint, 0);
 #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
 
 /* -------- defines ------------------------------------------------- */
@@ -1044,16 +1045,14 @@
 #endif
 }
 
-static int capinc_tty_write(struct tty_struct * tty, int from_user,
+static int capinc_tty_write(struct tty_struct * tty,
 			    const unsigned char *buf, int count)
 {
 	struct capiminor *mp = (struct capiminor *)tty->driver_data;
 	struct sk_buff *skb;
-	int retval;
 
 #ifdef _DEBUG_TTYFUNCS
-	printk(KERN_DEBUG "capinc_tty_write(from_user=%d,count=%d)\n",
-				from_user, count);
+	printk(KERN_DEBUG "capinc_tty_write(count=%d)\n", count);
 #endif
 
 	if (!mp || !mp->nccip) {
@@ -1077,18 +1076,7 @@
 	}
 
 	skb_reserve(skb, CAPI_DATA_B3_REQ_LEN);
-	if (from_user) {
-		retval = copy_from_user(skb_put(skb, count), buf, count);
-		if (retval) {
-			kfree_skb(skb);
-#ifdef _DEBUG_TTYFUNCS
-			printk(KERN_DEBUG "capinc_tty_write: copy_from_user=%d\n", retval);
-#endif
-			return -EFAULT;
-		}
-	} else {
-		memcpy(skb_put(skb, count), buf, count);
-	}
+	memcpy(skb_put(skb, count), buf, count);
 
 	skb_queue_tail(&mp->outqueue, skb);
 	mp->outbytes += skb->len;
diff -Nru a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
--- a/drivers/isdn/capi/capidrv.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/isdn/capi/capidrv.c	2004-12-24 13:36:48 -08:00
@@ -29,6 +29,7 @@
 #include <linux/kernelcapi.h>
 #include <linux/ctype.h>
 #include <linux/init.h>
+#include <linux/moduleparam.h>
 
 #include <linux/isdn/capiutil.h>
 #include <linux/isdn/capicmd.h>
@@ -40,7 +41,7 @@
 MODULE_DESCRIPTION("CAPI4Linux: Interface to ISDN4Linux");
 MODULE_AUTHOR("Carsten Paeth");
 MODULE_LICENSE("GPL");
-MODULE_PARM(debugmode, "i");
+module_param(debugmode, uint, 0);
 
 /* -------- type definitions ----------------------------------------- */
 
@@ -2057,6 +2058,10 @@
 		return -1;
 	}
 	card->myid = card->interface.channels;
+	memset(card->bchans, 0, sizeof(capidrv_bchan) * card->nbchan);
+	for (i = 0; i < card->nbchan; i++) {
+		card->bchans[i].contr = card;
+	}
 
 	spin_lock_irqsave(&global_lock, flags);
 	card->next = global.contr_list;
@@ -2064,11 +2069,6 @@
 	global.ncontr++;
 	spin_unlock_irqrestore(&global_lock, flags);
 
-	memset(card->bchans, 0, sizeof(capidrv_bchan) * card->nbchan);
-	for (i = 0; i < card->nbchan; i++) {
-		card->bchans[i].contr = card;
-	}
-
 	cmd.command = ISDN_STAT_RUN;
 	cmd.driver = card->myid;
 	card->interface.statcallb(&cmd);
@@ -2076,10 +2076,9 @@
 	card->cipmask = 0x1FFF03FF;	/* any */
 	card->cipmask2 = 0;
 
-	send_listen(card);
-
 	card->listentimer.data = (unsigned long)card;
 	card->listentimer.function = listentimerfunc;
+	send_listen(card);
 	mod_timer(&card->listentimer, jiffies + 60*HZ);
 
 	printk(KERN_INFO "%s: now up (%d B channels)\n",
diff -Nru a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
--- a/drivers/isdn/capi/kcapi.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/isdn/capi/kcapi.c	2004-12-24 13:37:18 -08:00
@@ -24,6 +24,8 @@
 #include <linux/capi.h>
 #include <linux/kernelcapi.h>
 #include <linux/init.h>
+#include <linux/moduleparam.h>
+#include <linux/delay.h>
 #include <asm/uaccess.h>
 #include <linux/isdn/capicmd.h>
 #include <linux/isdn/capiutil.h>
@@ -40,7 +42,7 @@
 MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer");
 MODULE_AUTHOR("Carsten Paeth");
 MODULE_LICENSE("GPL");
-MODULE_PARM(showcapimsgs, "i");
+module_param(showcapimsgs, uint, 0);
 
 /* ------------------------------------------------------------- */
 
@@ -148,7 +150,10 @@
 {
 	card = capi_ctr_get(card);
 
-	card->register_appl(card, applid, rparam);
+	if (card)
+		card->register_appl(card, applid, rparam);
+	else
+		printk(KERN_WARNING "%s: cannot get card resources\n", __FUNCTION__);
 }
 
 
@@ -171,10 +176,15 @@
 	if (showcapimsgs & 1) {
 	        printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr);
 	}
-
+	if (!card) {
+		printk(KERN_WARNING "%s: invalid contr %d\n", __FUNCTION__, contr);
+		return;
+	}
 	for (applid = 1; applid <= CAPI_MAXAPPL; applid++) {
 		ap = get_capi_appl_by_nr(applid);
-		if (ap && ap->callback && !ap->release_in_progress)
+		if (!ap || ap->release_in_progress) continue;
+		register_appl(card, applid, &ap->rparam);
+		if (ap->callback && !ap->release_in_progress)
 			ap->callback(KCI_CONTRUP, contr, &card->profile);
 	}
 }
@@ -317,19 +327,8 @@
 
 void capi_ctr_ready(struct capi_ctr * card)
 {
-	u16 appl;
-	struct capi20_appl *ap;
-
 	card->cardstate = CARD_RUNNING;
 
-	down(&controller_sem);
-	for (appl = 1; appl <= CAPI_MAXAPPL; appl++) {
-		ap = get_capi_appl_by_nr(appl);
-		if (!ap || ap->release_in_progress) continue;
-		register_appl(card, appl, &ap->rparam);
-	}
-	up(&controller_sem);
-
         printk(KERN_NOTICE "kcapi: card %d \"%s\" ready.\n",
 	       card->cnr, card->name);
 
@@ -831,8 +830,7 @@
 
 		while (card->cardstate != CARD_RUNNING) {
 
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(HZ/10);	/* 0.1 sec */
+			msleep_interruptible(100);	/* 0.1 sec */
 
 			if (signal_pending(current)) {
 				capi_ctr_put(card);
@@ -856,8 +854,7 @@
 
 		while (card->cardstate > CARD_DETECTED) {
 
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(HZ/10);	/* 0.1 sec */
+			msleep_interruptible(100);	/* 0.1 sec */
 
 			if (signal_pending(current))
 				return -EINTR;
diff -Nru a/drivers/isdn/divert/divert_init.c b/drivers/isdn/divert/divert_init.c
--- a/drivers/isdn/divert/divert_init.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/isdn/divert/divert_init.c	2004-12-24 13:37:02 -08:00
@@ -12,17 +12,14 @@
 #include <linux/module.h>
 #include <linux/version.h>
 #include <linux/init.h>
+#include <linux/kernel.h>
+
 #include "isdn_divert.h"
 
 MODULE_DESCRIPTION("ISDN4Linux: Call diversion support");
 MODULE_AUTHOR("Werner Cornelius");
 MODULE_LICENSE("GPL");
 
-/********************/
-/* needed externals */
-/********************/
-extern int printk(const char *fmt,...);
-
 /****************************************/
 /* structure containing interface to hl */
 /****************************************/
@@ -59,23 +56,23 @@
 /* Module deinit code */
 /**********************/
 static void __exit divert_exit(void)
-{ unsigned long flags;
+{
+  unsigned long flags;
   int i;
 
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&divert_lock, flags);
   divert_if.cmd = DIVERT_CMD_REL; /* release */
   if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR)
    { printk(KERN_WARNING "dss1_divert: error %d releasing module\n",i);
-     restore_flags(flags);
+     spin_unlock_irqrestore(&divert_lock, flags);
      return;
    } 
   if (divert_dev_deinit()) 
    { printk(KERN_WARNING "dss1_divert: device busy, remove cancelled\n");
-     restore_flags(flags);
+     spin_unlock_irqrestore(&divert_lock, flags);
      return;
    }
-  restore_flags(flags);
+  spin_unlock_irqrestore(&divert_lock, flags);
   deleterule(-1); /* delete all rules and free mem */
   deleteprocs();
   printk(KERN_INFO "dss1_divert module successfully removed \n");
diff -Nru a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
--- a/drivers/isdn/divert/divert_procfs.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/isdn/divert/divert_procfs.c	2004-12-24 13:37:19 -08:00
@@ -22,6 +22,7 @@
 #include <linux/isdnif.h>
 #include "isdn_divert.h"
 
+
 /*********************************/
 /* Variables for interface queue */
 /*********************************/
@@ -76,7 +77,7 @@
 /* deflection device read routine */
 /**********************************/
 static ssize_t
-isdn_divert_read(struct file *file, char *buf, size_t count, loff_t * off)
+isdn_divert_read(struct file *file, char __user *buf, size_t count, loff_t * off)
 {
 	struct divert_info *inf;
 	int len;
@@ -90,7 +91,7 @@
 		return (0);
 
 	inf->usage_cnt--;	/* new usage count */
-	(struct divert_info **) file->private_data = &inf->next;	/* next structure */
+	file->private_data = &inf->next;	/* next structure */
 	if ((len = strlen(inf->info_start)) <= count) {
 		if (copy_to_user(buf, inf->info_start, len))
 			return -EFAULT;
@@ -104,7 +105,7 @@
 /* deflection device write routine */
 /**********************************/
 static ssize_t
-isdn_divert_write(struct file *file, const char *buf, size_t count, loff_t * off)
+isdn_divert_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
 {
 	return (-ENODEV);
 }				/* isdn_divert_write */
@@ -137,9 +138,9 @@
 	spin_lock_irqsave( &divert_info_lock, flags );
  	if_used++;
 	if (divert_info_head)
-		(struct divert_info **) filep->private_data = &(divert_info_tail->next);
+		filep->private_data = &(divert_info_tail->next);
 	else
-		(struct divert_info **) filep->private_data = &divert_info_head;
+		filep->private_data = &divert_info_head;
 	spin_unlock_irqrestore( &divert_info_lock, flags );
 	/*  start_divert(); */
 	return nonseekable_open(ino, filep);
@@ -184,7 +185,7 @@
 	divert_rule *rulep;
 	char *cp;
 
-	if (copy_from_user(&dioctl, (char *) arg, sizeof(dioctl)))
+	if (copy_from_user(&dioctl, (void __user *) arg, sizeof(dioctl)))
 		return -EFAULT;
 
 	switch (cmd) {
@@ -215,10 +216,9 @@
 		case IIOCMODRULE:
 			if (!(rulep = getruleptr(dioctl.getsetrule.ruleidx)))
 				return (-EINVAL);
-			save_flags(flags);
-			cli();
+            spin_lock_irqsave(&divert_lock, flags);
 			*rulep = dioctl.getsetrule.rule;	/* copy data */
-			restore_flags(flags);
+			spin_unlock_irqrestore(&divert_lock, flags);
 			return (0);	/* no copy required */
 			break;
 
@@ -253,7 +253,7 @@
 		default:
 			return (-EINVAL);
 	}			/* switch cmd */
-	return copy_to_user((char *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0;
+	return copy_to_user((void __user *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0;
 }				/* isdn_divert_ioctl */
 
 
diff -Nru a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
--- a/drivers/isdn/divert/isdn_divert.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/isdn/divert/isdn_divert.c	2004-12-24 13:37:00 -08:00
@@ -11,6 +11,7 @@
 
 #include <linux/version.h>
 #include <linux/proc_fs.h>
+
 #include "isdn_divert.h"
 
 /**********************************/
@@ -47,54 +48,53 @@
 static struct deflect_struc *table_tail = NULL; 
 static unsigned char extern_wait_max = 4; /* maximum wait in s for external process */ 
 
+spinlock_t divert_lock = SPIN_LOCK_UNLOCKED;
+
 /***************************/
 /* timer callback function */
 /***************************/
 static void deflect_timer_expire(ulong arg)
-{ unsigned long flags;
+{
+  unsigned long flags;
   struct call_struc *cs = (struct call_struc *) arg;
 
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&divert_lock, flags);
   del_timer(&cs->timer); /* delete active timer */
-  restore_flags(flags);
+  spin_unlock_irqrestore(&divert_lock, flags);
 
   switch(cs->akt_state)
    { case DEFLECT_PROCEED:
        cs->ics.command = ISDN_CMD_HANGUP; /* cancel action */
        divert_if.ll_cmd(&cs->ics);                   	  
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&divert_lock, flags);
        cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
        cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
        add_timer(&cs->timer);
-       restore_flags(flags); 
+       spin_unlock_irqrestore(&divert_lock, flags);
        break;
 
      case DEFLECT_ALERT:
        cs->ics.command = ISDN_CMD_REDIR; /* protocol */
        strcpy(cs->ics.parm.setup.phone,cs->deflect_dest);
        strcpy(cs->ics.parm.setup.eazmsn,"Testtext delayed");
-       divert_if.ll_cmd(&cs->ics);                   	  
-       save_flags(flags);
-       cli();
+       divert_if.ll_cmd(&cs->ics);
+       spin_lock_irqsave(&divert_lock, flags);
        cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
        cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
        add_timer(&cs->timer);
-       restore_flags(flags); 
+       spin_unlock_irqrestore(&divert_lock, flags);
        break;
 
      case DEFLECT_AUTODEL:
      default:
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&divert_lock, flags);
        if (cs->prev) 
          cs->prev->next = cs->next; /* forward link */
         else
          divert_head = cs->next;
        if (cs->next)
          cs->next->prev = cs->prev; /* back link */           
-       restore_flags(flags); 
+       spin_unlock_irqrestore(&divert_lock, flags);
        kfree(cs);
        return;
 
@@ -166,10 +166,9 @@
   cs->ics.parm.dss1_io.datalen = p - tmp; /* total len */
   cs->ics.parm.dss1_io.data = tmp; /* start of buffer */
   
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&divert_lock, flags);
   cs->ics.parm.dss1_io.ll_id = next_id++; /* id for callback */
-  restore_flags(flags);
+  spin_unlock_irqrestore(&divert_lock, flags);
   *procid = cs->ics.parm.dss1_io.ll_id;  
 
   sprintf(cs->info,"%d 0x%lx %s%s 0 %s %02x %d%s%s\n",
@@ -187,11 +186,10 @@
 
   if (!retval)
    { cs->prev = NULL;
-     save_flags(flags);
-     cli();
+     spin_lock_irqsave(&divert_lock, flags);
      cs->next = divert_head;
      divert_head = cs; 
-     restore_flags(flags);
+     spin_unlock_irqrestore(&divert_lock, flags);
    }
   else
    kfree(cs);
@@ -224,13 +222,12 @@
    { case 0: /* hangup */
        del_timer(&cs->timer); 
        ic.command = ISDN_CMD_HANGUP;
-       i = divert_if.ll_cmd(&ic);                   	  
-       save_flags(flags);
-       cli();
+       i = divert_if.ll_cmd(&ic);
+       spin_lock_irqsave(&divert_lock, flags);
        cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
        cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
        add_timer(&cs->timer);
-       restore_flags(flags); 
+       spin_unlock_irqrestore(&divert_lock, flags);
      break;      
 
      case 1: /* alert */
@@ -239,12 +236,12 @@
        del_timer(&cs->timer); 
        ic.command = ISDN_CMD_ALERT;
        if ((i = divert_if.ll_cmd(&ic)))
-	{ save_flags(flags);
-          cli();
+	{
+          spin_lock_irqsave(&divert_lock, flags);
           cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
           cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
           add_timer(&cs->timer);
-          restore_flags(flags);
+          spin_unlock_irqrestore(&divert_lock, flags);
         }
        else
           cs->akt_state = DEFLECT_ALERT; 
@@ -256,12 +253,12 @@
        strcpy(cs->ics.parm.setup.eazmsn, "Testtext manual");
        ic.command = ISDN_CMD_REDIR;
        if ((i = divert_if.ll_cmd(&ic)))
-	{ save_flags(flags);
-          cli();
+	{
+          spin_lock_irqsave(&divert_lock, flags);
           cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
           cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
           add_timer(&cs->timer);
-          restore_flags(flags);
+          spin_unlock_irqrestore(&divert_lock, flags);
         }
        else
           cs->akt_state = DEFLECT_ALERT; 
@@ -284,8 +281,7 @@
 
   ds->rule = *newrule; /* set rule */
 
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&divert_lock, flags);
 
   if (idx >= 0)
    { ds1 = table_head;
@@ -313,7 +309,7 @@
         table_head = ds; /* first element */
    }
 
-  restore_flags(flags);
+  spin_unlock_irqrestore(&divert_lock, flags);
   return(0);
 } /* insertrule */
 
@@ -325,12 +321,11 @@
   unsigned long flags;
   
   if (idx < 0) 
-   { save_flags(flags);
-     cli();
+   { spin_lock_irqsave(&divert_lock, flags);
      ds = table_head;
      table_head = NULL;
      table_tail = NULL;
-     restore_flags(flags);
+     spin_unlock_irqrestore(&divert_lock, flags);
      while (ds)
       { ds1 = ds; 
         ds = ds->next;
@@ -339,8 +334,7 @@
      return(0); 
    }
 
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&divert_lock, flags);
   ds = table_head;
 
   while ((ds) && (idx > 0))
@@ -349,7 +343,8 @@
    }
 
   if (!ds) 
-   { restore_flags(flags);
+   {
+     spin_unlock_irqrestore(&divert_lock, flags);
      return(-EINVAL);
    }  
 
@@ -363,7 +358,7 @@
    else
      table_head = ds->next; /* start of chain */      
   
-  restore_flags(flags);
+  spin_unlock_irqrestore(&divert_lock, flags);
   kfree(ds);
   return(0);
 } /* deleterule */
@@ -474,10 +469,9 @@
             else  
               cs->timer.expires = 0;
            cs->akt_state = dv->rule.action;                
-           save_flags(flags);
-           cli();
+           spin_lock_irqsave(&divert_lock, flags);
            cs->divert_id = next_id++; /* new sequence number */
-           restore_flags(flags);
+           spin_unlock_irqrestore(&divert_lock, flags);
            cs->prev = NULL;
            if (cs->akt_state == DEFLECT_ALERT)
              { strcpy(cs->deflect_dest,dv->rule.to_nr);
@@ -525,12 +519,11 @@
 
   if (cs) 
    { cs->prev = NULL;
-     save_flags(flags);
-     cli();
+     spin_lock_irqsave(&divert_lock, flags);
      cs->next = divert_head;
      divert_head = cs; 
      if (cs->timer.expires) add_timer(&cs->timer);
-     restore_flags(flags);
+     spin_unlock_irqrestore(&divert_lock, flags);
 
      put_info_buffer(cs->info); 
      return(retval);
@@ -544,8 +537,7 @@
 { struct call_struc *cs, *cs1; 
   unsigned long flags;
 
-  save_flags(flags);
-  cli();
+  spin_lock_irqsave(&divert_lock, flags);
   cs = divert_head;
   divert_head = NULL;
   while (cs)
@@ -554,7 +546,7 @@
      cs = cs->next;
      kfree(cs1);
    } 
-  restore_flags(flags);
+  spin_unlock_irqrestore(&divert_lock, flags);
 } /* deleteprocs */
 
 /****************************************************/
@@ -769,8 +761,8 @@
    }  
 
   if (cs1->ics.driver == -1)
-   { save_flags(flags);
-     cli();
+   {
+     spin_lock_irqsave(&divert_lock, flags);
      del_timer(&cs1->timer);
      if (cs1->prev) 
        cs1->prev->next = cs1->next; /* forward link */
@@ -778,7 +770,7 @@
        divert_head = cs1->next;
      if (cs1->next)
        cs1->next->prev = cs1->prev; /* back link */           
-     restore_flags(flags); 
+     spin_unlock_irqrestore(&divert_lock, flags);
      kfree(cs1);
    } 
 
@@ -826,15 +818,14 @@
         cs = cs->next;
         if (cs1->ics.driver == -1)
           { 
-            save_flags(flags);
-            cli();
+            spin_lock_irqsave(&divert_lock, flags);
             if (cs1->prev) 
               cs1->prev->next = cs1->next; /* forward link */
             else
               divert_head = cs1->next;
             if (cs1->next)
               cs1->next->prev = cs1->prev; /* back link */           
-            restore_flags(flags); 
+            spin_unlock_irqrestore(&divert_lock, flags);
             kfree(cs1);
           } 
       }  
diff -Nru a/drivers/isdn/divert/isdn_divert.h b/drivers/isdn/divert/isdn_divert.h
--- a/drivers/isdn/divert/isdn_divert.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/isdn/divert/isdn_divert.h	2004-12-24 13:36:31 -08:00
@@ -114,6 +114,8 @@
 /**************/
 /* Prototypes */
 /**************/
+extern spinlock_t divert_lock;
+
 extern ulong if_used; /* number of interface users */
 extern int divert_dev_deinit(void);
 extern int divert_dev_init(void);
diff -Nru a/drivers/isdn/hardware/avm/Kconfig b/drivers/isdn/hardware/avm/Kconfig
--- a/drivers/isdn/hardware/avm/Kconfig	2004-12-24 13:36:31 -08:00
+++ b/drivers/isdn/hardware/avm/Kconfig	2004-12-24 13:36:31 -08:00
@@ -12,13 +12,13 @@
 
 config ISDN_DRV_AVMB1_B1ISA
 	tristate "AVM B1 ISA support"
-	depends on CAPI_AVM && ISDN_CAPI && ISA && BROKEN_ON_SMP
+	depends on CAPI_AVM && ISDN_CAPI && ISA
 	help
 	  Enable support for the ISA version of the AVM B1 card.
 
 config ISDN_DRV_AVMB1_B1PCI
 	tristate "AVM B1 PCI support"
-	depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
+	depends on CAPI_AVM && ISDN_CAPI && PCI
 	help
 	  Enable support for the PCI version of the AVM B1 card.
 
@@ -30,14 +30,14 @@
 
 config ISDN_DRV_AVMB1_T1ISA
 	tristate "AVM T1/T1-B ISA support"
-	depends on CAPI_AVM && ISDN_CAPI && ISA && BROKEN_ON_SMP
+	depends on CAPI_AVM && ISDN_CAPI && ISA
 	help
 	  Enable support for the AVM T1 T1B card.
 	  Note: This is a PRI card and handle 30 B-channels.
 
 config ISDN_DRV_AVMB1_B1PCMCIA
 	tristate "AVM B1/M1/M2 PCMCIA support"
-	depends on CAPI_AVM && ISDN_CAPI && BROKEN_ON_SMP
+	depends on CAPI_AVM && ISDN_CAPI
 	help
 	  Enable support for the PCMCIA version of the AVM B1 card.
 
@@ -50,14 +50,14 @@
 
 config ISDN_DRV_AVMB1_T1PCI
 	tristate "AVM T1/T1-B PCI support"
-	depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
+	depends on CAPI_AVM && ISDN_CAPI && PCI
 	help
 	  Enable support for the AVM T1 T1B card.
 	  Note: This is a PRI card and handle 30 B-channels.
 
 config ISDN_DRV_AVMB1_C4
 	tristate "AVM C4/C2 support"
-	depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
+	depends on CAPI_AVM && ISDN_CAPI && PCI
 	help
 	  Enable support for the AVM C4/C2 PCI cards.
 	  These cards handle 4/2 BRI ISDN lines (8/4 channels).
diff -Nru a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c
--- a/drivers/isdn/hardware/avm/c4.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/isdn/hardware/avm/c4.c	2004-12-24 13:36:56 -08:00
@@ -662,15 +662,16 @@
 
 static irqreturn_t c4_handle_interrupt(avmcard *card)
 {
+	unsigned long flags;
 	u32 status;
 
-	spin_lock(&card->lock);
+	spin_lock_irqsave(&card->lock, flags);
 	status = c4inmeml(card->mbase+DOORBELL);
 
 	if (status & DBELL_RESET_HOST) {
 		u_int i;
 		c4outmeml(card->mbase+PCI_OUT_INT_MASK, 0x0c);
-		spin_unlock(&card->lock);
+		spin_unlock_irqrestore(&card->lock, flags);
 		if (card->nlogcontr == 0)
 			return IRQ_HANDLED;
 		printk(KERN_ERR "%s: unexpected reset\n", card->name);
@@ -686,7 +687,7 @@
 
 	status &= (DBELL_UP_HOST | DBELL_DOWN_HOST);
 	if (!status) {
-		spin_unlock(&card->lock);
+		spin_unlock_irqrestore(&card->lock, flags);
 		return IRQ_HANDLED;
 	}
 	c4outmeml(card->mbase+DOORBELL, status);
@@ -709,7 +710,7 @@
 			c4_dispatch_tx(card);
 		}
 	}
-	spin_unlock(&card->lock);
+	spin_unlock_irqrestore(&card->lock, flags);
 	return IRQ_HANDLED;
 }
 
diff -Nru a/drivers/isdn/hardware/eicon/capifunc.c b/drivers/isdn/hardware/eicon/capifunc.c
--- a/drivers/isdn/hardware/eicon/capifunc.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/isdn/hardware/eicon/capifunc.c	2004-12-24 13:37:19 -08:00
@@ -240,13 +240,13 @@
 	DBG_PRV1(("sendf(a=%d,cmd=%x,format=%s)",
 		  appl->Id, command, (byte *) format))
 
-	    WRITE_WORD(&msg.header.appl_id, appl->Id);
-	WRITE_WORD(&msg.header.command, command);
+	PUT_WORD(&msg.header.appl_id, appl->Id);
+	PUT_WORD(&msg.header.command, command);
 	if ((byte) (command >> 8) == 0x82)
 		Number = appl->Number++;
-	WRITE_WORD(&msg.header.number, Number);
+	PUT_WORD(&msg.header.number, Number);
 
-	WRITE_DWORD(((byte *) & msg.header.controller), Id);
+	PUT_DWORD(&msg.header.controller, Id);
 	write = (byte *) & msg;
 	write += 12;
 
@@ -261,13 +261,13 @@
 			break;
 		case 'w':
 			tmp = va_arg(ap, dword);
-			WRITE_WORD(write, (tmp & 0xffff));
+			PUT_WORD(write, (tmp & 0xffff));
 			write += 2;
 			length += 2;
 			break;
 		case 'd':
 			tmp = va_arg(ap, dword);
-			WRITE_DWORD(write, tmp);
+			PUT_DWORD(write, tmp);
 			write += 4;
 			length += 4;
 			break;
@@ -282,11 +282,11 @@
 	}
 	va_end(ap);
 
-	WRITE_WORD(&msg.header.length, length);
+	PUT_WORD(&msg.header.length, length);
 	msg.header.controller = UnMapController(msg.header.controller);
 
 	if (command == _DATA_B3_I)
-		dlength = READ_WORD(
+		dlength = GET_WORD(
 			      ((byte *) & msg.info.data_b3_ind.Data_Length));
 
 	if (!(dmb = diva_os_alloc_message_buffer(length + dlength,
@@ -300,7 +300,7 @@
 
 	/* if DATA_B3_IND, copy data too */
 	if (command == _DATA_B3_I) {
-		dword data = READ_DWORD(&msg.info.data_b3_ind.Data);
+		dword data = GET_DWORD(&msg.info.data_b3_ind.Data);
 		memcpy(write + length, (void *) data, dlength);
 	}
 
@@ -318,7 +318,7 @@
 			if (myDriverDebugHandle.dbgMask & DL_BLK) {
 				xlog("\x00\x02", &msg, 0x81, length);
 				for (i = 0; i < dlength; i += 256) {
-				  DBG_BLK((((char *) READ_DWORD(&msg.info.data_b3_ind.Data)) + i,
+				  DBG_BLK((((char *) GET_DWORD(&msg.info.data_b3_ind.Data)) + i,
 				  	((dlength - i) < 256) ? (dlength - i) : 256))
 				  if (!(myDriverDebugHandle.dbgMask & DL_PRV0))
 					  break; /* not more if not explicitely requested */
@@ -700,7 +700,7 @@
 	}
 
 	/* profile information */
-	WRITE_WORD(&ctrl->profile.nbchannel, card->d.channels);
+	PUT_WORD(&ctrl->profile.nbchannel, card->d.channels);
 	ctrl->profile.goptions = a->profile.Global_Options;
 	ctrl->profile.support1 = a->profile.B1_Protocols;
 	ctrl->profile.support2 = a->profile.B2_Protocols;
@@ -882,11 +882,11 @@
 	word ret = 0;
 	diva_os_spin_lock_magic_t old_irql;
 	CAPI_MSG *msg = (CAPI_MSG *) DIVA_MESSAGE_BUFFER_DATA(dmb);
-	APPL *this = &application[READ_WORD(&msg->header.appl_id) - 1];
+	APPL *this = &application[GET_WORD(&msg->header.appl_id) - 1];
 	diva_card *card = ctrl->driverdata;
 	__u32 length = DIVA_MESSAGE_BUFFER_LEN(dmb);
-	word clength = READ_WORD(&msg->header.length);
-	word command = READ_WORD(&msg->header.command);
+	word clength = GET_WORD(&msg->header.length);
+	word command = GET_WORD(&msg->header.command);
 	u16 retval = CAPI_NOERROR;
 
 	if (diva_os_in_irq()) {
@@ -932,9 +932,9 @@
 		if (clength == 24)
 			clength = 22;	/* workaround for PPcom bug */
 		/* header is always 22      */
-		if (READ_WORD(&msg->info.data_b3_req.Data_Length) >
+		if (GET_WORD(&msg->info.data_b3_req.Data_Length) >
 		    this->MaxDataLength
-		    || READ_WORD(&msg->info.data_b3_req.Data_Length) >
+		    || GET_WORD(&msg->info.data_b3_req.Data_Length) >
 		    (length - clength)) {
 			DBG_ERR(("Write - invalid message size"))
 			retval = CAPI_ILLCMDORSUBCMDORMSGTOSMALL;
@@ -952,18 +952,18 @@
 
 		this->xbuffer_internal[i] = NULL;
 		memcpy(this->xbuffer_ptr[i], &((__u8 *) msg)[clength],
-		       READ_WORD(&msg->info.data_b3_req.Data_Length));
+		       GET_WORD(&msg->info.data_b3_req.Data_Length));
 
 #ifndef DIVA_NO_DEBUGLIB
 		if ((myDriverDebugHandle.dbgMask & DL_BLK)
 		    && (myDriverDebugHandle.dbgMask & DL_XLOG)) {
 			int j;
 			for (j = 0; j <
-			     READ_WORD(&msg->info.data_b3_req.Data_Length);
+			     GET_WORD(&msg->info.data_b3_req.Data_Length);
 			     j += 256) {
 				DBG_BLK((((char *) this->xbuffer_ptr[i]) + j,
-					((READ_WORD(&msg->info.data_b3_req.Data_Length) - j) <
-					  256) ? (READ_WORD(&msg->info.data_b3_req.Data_Length) - j) : 256))
+					((GET_WORD(&msg->info.data_b3_req.Data_Length) - j) <
+					  256) ? (GET_WORD(&msg->info.data_b3_req.Data_Length) - j) : 256))
 				if (!(myDriverDebugHandle.dbgMask & DL_PRV0))
 					break;	/* not more if not explicitely requested */
 			}
@@ -976,7 +976,7 @@
 	mapped_msg->header.controller = MapController(mapped_msg->header.controller);
 	mapped_msg->header.length = clength;
 	mapped_msg->header.command = command;
-	mapped_msg->header.number = READ_WORD(&msg->header.number);
+	mapped_msg->header.number = GET_WORD(&msg->header.number);
 
 	ret = api_put(this, mapped_msg);
 	switch (ret) {
diff -Nru a/drivers/isdn/hardware/eicon/di.c b/drivers/isdn/hardware/eicon/di.c
--- a/drivers/isdn/hardware/eicon/di.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/isdn/hardware/eicon/di.c	2004-12-24 13:36:47 -08:00
@@ -952,10 +952,10 @@
                                byte Id, byte Ch, byte Rc, byte cb, byte type) {
 #if defined(XDI_USE_XLOG)
   word LogInfo[4];
-  WRITE_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
-  WRITE_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
-  WRITE_WORD(&LogInfo[2], ((word)Rc | (word)(type << 8)));
-  WRITE_WORD(&LogInfo[3], cb);
+  PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
+  PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
+  PUT_WORD(&LogInfo[2], ((word)Rc | (word)(type << 8)));
+  PUT_WORD(&LogInfo[3], cb);
   xdi_xlog ((byte*)&LogInfo[0], 221, sizeof(LogInfo));
 #endif
 }
@@ -976,9 +976,9 @@
                               byte Ch, byte Req, byte type) {
 #if defined(XDI_USE_XLOG)
   word LogInfo[3];
-  WRITE_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
-  WRITE_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
-  WRITE_WORD(&LogInfo[2], ((word)Req | (word)(type << 8)));
+  PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
+  PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
+  PUT_WORD(&LogInfo[2], ((word)Req | (word)(type << 8)));
   xdi_xlog ((byte*)&LogInfo[0], 220, sizeof(LogInfo));
 #endif
 }
@@ -1020,10 +1020,10 @@
                           byte type) {
 #if defined(XDI_USE_XLOG)
   word LogInfo[4];
-  WRITE_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
-  WRITE_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
-  WRITE_WORD(&LogInfo[2], ((word)Ind | (word)(type << 8)));
-  WRITE_WORD(&LogInfo[3], ((word)rnr | (word)(rnr_valid << 8)));
+  PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8)));
+  PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8)));
+  PUT_WORD(&LogInfo[2], ((word)Ind | (word)(type << 8)));
+  PUT_WORD(&LogInfo[3], ((word)rnr | (word)(rnr_valid << 8)));
   xdi_xlog ((byte*)&LogInfo[0], 222, sizeof(LogInfo));
 #endif
 }
diff -Nru a/drivers/isdn/hardware/eicon/diva_pci.h b/drivers/isdn/hardware/eicon/diva_pci.h
--- a/drivers/isdn/hardware/eicon/diva_pci.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/isdn/hardware/eicon/diva_pci.h	2004-12-24 13:36:48 -08:00
@@ -3,11 +3,11 @@
 #ifndef __DIVA_PCI_INTERFACE_H__
 #define __DIVA_PCI_INTERFACE_H__
 
-void *divasa_remap_pci_bar(diva_os_xdi_adapter_t *a,
+void __iomem *divasa_remap_pci_bar(diva_os_xdi_adapter_t *a,
 			   int id,
 			   unsigned long bar,
 			   unsigned long area_length);
-void divasa_unmap_pci_bar(void *bar);
+void divasa_unmap_pci_bar(void __iomem *bar);
 unsigned long divasa_get_pci_irq(unsigned char bus,
 				 unsigned char func, void *pci_dev_handle);
 unsigned long divasa_get_pci_bar(unsigned char bus,
diff -Nru a/drivers/isdn/hardware/eicon/divasmain.c b/drivers/isdn/hardware/eicon/divasmain.c
--- a/drivers/isdn/hardware/eicon/divasmain.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/isdn/hardware/eicon/divasmain.c	2004-12-24 13:36:18 -08:00
@@ -435,16 +435,14 @@
 	return (0);
 }
 
-void *divasa_remap_pci_bar(diva_os_xdi_adapter_t *a, int id, unsigned long bar, unsigned long area_length)
+void __iomem *divasa_remap_pci_bar(diva_os_xdi_adapter_t *a, int id, unsigned long bar, unsigned long area_length)
 {
-	void *ret;
-
-	ret = (void *) ioremap(bar, area_length);
-	DBG_TRC(("remap(%08x)->%08x", bar, ret));
+	void __iomem *ret = ioremap(bar, area_length);
+	DBG_TRC(("remap(%08x)->%p", bar, ret));
 	return (ret);
 }
 
-void divasa_unmap_pci_bar(void *bar)
+void divasa_unmap_pci_bar(void __iomem *bar)
 {
 	if (bar) {
 		iounmap(bar);
@@ -454,32 +452,32 @@
 /*********************************************************
  ** I/O port access 
  *********************************************************/
-byte __inline__ inpp(void *addr)
+byte __inline__ inpp(void __iomem *addr)
 {
 	return (inb((unsigned long) addr));
 }
 
-word __inline__ inppw(void *addr)
+word __inline__ inppw(void __iomem *addr)
 {
 	return (inw((unsigned long) addr));
 }
 
-void __inline__ inppw_buffer(void *addr, void *P, int length)
+void __inline__ inppw_buffer(void __iomem *addr, void *P, int length)
 {
 	insw((unsigned long) addr, (word *) P, length >> 1);
 }
 
-void __inline__ outppw_buffer(void *addr, void *P, int length)
+void __inline__ outppw_buffer(void __iomem *addr, void *P, int length)
 {
 	outsw((unsigned long) addr, (word *) P, length >> 1);
 }
 
-void __inline__ outppw(void *addr, word w)
+void __inline__ outppw(void __iomem *addr, word w)
 {
 	outw(w, (unsigned long) addr);
 }
 
-void __inline__ outpp(void *addr, word p)
+void __inline__ outpp(void __iomem *addr, word p)
 {
 	outb(p, (unsigned long) addr);
 }
diff -Nru a/drivers/isdn/hardware/eicon/io.c b/drivers/isdn/hardware/eicon/io.c
--- a/drivers/isdn/hardware/eicon/io.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/isdn/hardware/eicon/io.c	2004-12-24 13:36:31 -08:00
@@ -95,13 +95,13 @@
  DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0]))
  for ( ; logCnt > 0 ; --logCnt )
  {
-  if ( !READ_WORD(&Xlog[logOut]) )
+  if ( !GET_WORD(&Xlog[logOut]) )
   {
    if ( --logCnt == 0 )
     break ;
    logOut = 0 ;
   }
-  if ( READ_WORD(&Xlog[logOut]) <= (logOut * sizeof(*Xlog)) )
+  if ( GET_WORD(&Xlog[logOut]) <= (logOut * sizeof(*Xlog)) )
   {
    if ( logCnt > 2 )
    {
@@ -110,9 +110,9 @@
    }
    break ;
   }
-  logLen = (dword)(READ_WORD(&Xlog[logOut]) - (logOut * sizeof(*Xlog))) ;
+  logLen = (dword)(GET_WORD(&Xlog[logOut]) - (logOut * sizeof(*Xlog))) ;
   DBG_FTL_MXLOG(( (char *)&Xlog[logOut + 1], (dword)(logLen - 2) ))
-  logOut = (READ_WORD(&Xlog[logOut]) + 1) / sizeof(*Xlog) ;
+  logOut = (GET_WORD(&Xlog[logOut]) + 1) / sizeof(*Xlog) ;
  }
  DBG_FTL(("%s: ***************** end of XLOG *****************",
           &IoAdapter->Name[0]))
@@ -154,10 +154,10 @@
  "VCED"
 } ;
 void
-dump_trap_frame (PISDN_ADAPTER IoAdapter, byte *exceptionFrame)
+dump_trap_frame (PISDN_ADAPTER IoAdapter, byte __iomem *exceptionFrame)
 {
- MP_XCPTC *xcept = (MP_XCPTC *)exceptionFrame ;
- dword    *regs;
+ MP_XCPTC __iomem *xcept = (MP_XCPTC __iomem *)exceptionFrame ;
+ dword    __iomem *regs;
  regs  = &xcept->regs[0] ;
  DBG_FTL(("%s: ***************** CPU TRAPPED *****************",
           &IoAdapter->Name[0]))
@@ -595,26 +595,22 @@
 byte mem_in (ADAPTER *a, void *addr)
 {
  byte val;
- volatile byte* Base;
-
- Base = (volatile byte *)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
- val = *(Base + (unsigned long)addr);
+ volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ val = READ_BYTE(Base + (unsigned long)addr);
  DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
  return (val);
 }
 word mem_inw (ADAPTER *a, void *addr)
 {
  word val;
- volatile byte* Base;
- 
- Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
  val = READ_WORD((Base + (unsigned long)addr));
  DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
  return (val);
 }
 void mem_in_dw (ADAPTER *a, void *addr, dword* data, int dwords)
 {
- volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ volatile byte __iomem * Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
  while (dwords--) {
   *data++ = READ_DWORD((Base + (unsigned long)addr));
   addr+=4;
@@ -623,8 +619,8 @@
 }
 void mem_in_buffer (ADAPTER *a, void *addr, void *buffer, word length)
 {
- volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
- memcpy (buffer, (void *)(Base + (unsigned long)addr), length);
+ volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ memcpy_fromio(buffer, (Base + (unsigned long)addr), length);
  DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
 }
 void mem_look_ahead (ADAPTER *a, PBUFFER *RBuffer, ENTITY *e)
@@ -637,19 +633,19 @@
 }
 void mem_out (ADAPTER *a, void *addr, byte data)
 {
- volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
- *(Base + (unsigned long)addr) = data ;
+ volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ WRITE_BYTE(Base + (unsigned long)addr, data);
  DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
 }
 void mem_outw (ADAPTER *a, void *addr, word data)
 {
- volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ volatile byte __iomem * Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
  WRITE_WORD((Base + (unsigned long)addr), data);
  DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
 }
 void mem_out_dw (ADAPTER *a, void *addr, const dword* data, int dwords)
 {
- volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ volatile byte __iomem * Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
  while (dwords--) {
 	WRITE_DWORD((Base + (unsigned long)addr), *data);
   	addr+=4;
@@ -659,15 +655,15 @@
 }
 void mem_out_buffer (ADAPTER *a, void *addr, void *buffer, word length)
 {
- volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
- memcpy ((void *)(Base + (unsigned long)addr), buffer, length) ;
+ volatile byte __iomem * Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ memcpy_toio((Base + (unsigned long)addr), buffer, length) ;
  DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
 }
 void mem_inc (ADAPTER *a, void *addr)
 {
- volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
- byte  x = *(Base + (unsigned long)addr);
- *(Base + (unsigned long)addr) = x + 1 ;
+ volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
+ byte  x = READ_BYTE(Base + (unsigned long)addr);
+ WRITE_BYTE(Base + (unsigned long)addr, x + 1);
  DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
 }
 /*------------------------------------------------------------------*/
@@ -676,7 +672,7 @@
 byte io_in(ADAPTER * a, void * adr)
 {
   byte val;
-  byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
+  byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
   outppw(Port + 4, (word)(unsigned long)adr);
   val = inpp(Port);
   DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
@@ -685,7 +681,7 @@
 word io_inw(ADAPTER * a, void * adr)
 {
   word val;
-  byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
+  byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
   outppw(Port + 4, (word)(unsigned long)adr);
   val = inppw(Port);
   DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
@@ -693,7 +689,7 @@
 }
 void io_in_buffer(ADAPTER * a, void * adr, void * buffer, word len)
 {
-  byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
+  byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
   byte* P = (byte*)buffer;
   if ((long)adr & 1) {
     outppw(Port+4, (word)(unsigned long)adr);
@@ -712,7 +708,7 @@
 }
 void io_look_ahead(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e)
 {
-  byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
+  byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
   outppw(Port+4, (word)(unsigned long)RBuffer);
   ((PISDN_ADAPTER)a->io)->RBuffer.length = inppw(Port);
   inppw_buffer (Port, ((PISDN_ADAPTER)a->io)->RBuffer.P, ((PISDN_ADAPTER)a->io)->RBuffer.length + 1);
@@ -721,21 +717,21 @@
 }
 void io_out(ADAPTER * a, void * adr, byte data)
 {
-  byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
+  byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
   outppw(Port+4, (word)(unsigned long)adr);
   outpp(Port, data);
   DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
 }
 void io_outw(ADAPTER * a, void * adr, word data)
 {
-  byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
+  byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
   outppw(Port+4, (word)(unsigned long)adr);
   outppw(Port, data);
   DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
 }
 void io_out_buffer(ADAPTER * a, void * adr, void * buffer, word len)
 {
-  byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
+  byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
   byte* P = (byte*)buffer;
   if ((long)adr & 1) {
     outppw(Port+4, (word)(unsigned long)adr);
@@ -755,7 +751,7 @@
 void io_inc(ADAPTER * a, void * adr)
 {
   byte x;
-  byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
+  byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
   outppw(Port+4, (word)(unsigned long)adr);
   x = inpp(Port);
   outppw(Port+4, (word)(unsigned long)adr);
@@ -865,7 +861,7 @@
 /* --------------------------------------------------------------------------
   routines for aligned reading and writing on RISC
   -------------------------------------------------------------------------- */
-void outp_words_from_buffer (word* adr, byte* P, dword len)
+void outp_words_from_buffer (word __iomem * adr, byte* P, dword len)
 {
   dword i = 0;
   word w;
@@ -875,7 +871,7 @@
     outppw (adr, w);
   }
 }
-void inp_words_to_buffer (word* adr, byte* P, dword len)
+void inp_words_to_buffer (word __iomem * adr, byte* P, dword len)
 {
   dword i = 0;
   word w;
diff -Nru a/drivers/isdn/hardware/eicon/io.h b/drivers/isdn/hardware/eicon/io.h
--- a/drivers/isdn/hardware/eicon/io.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/isdn/hardware/eicon/io.h	2004-12-24 13:37:31 -08:00
@@ -97,15 +97,15 @@
  dword               downloadAddrTable[4] ; /* add. for MultiMaster */
  dword               MemoryBase ;
  dword               MemorySize ;
- byte                *Address ;
- byte                *Config ;
- byte                *Control ;
- byte                *reset ;
- byte                *port ;
- byte                *ram ;
- byte                *cfg ;
- byte                *prom ;
- byte                *ctlReg ;
+ byte                __iomem *Address ;
+ byte                __iomem *Config ;
+ byte                __iomem *Control ;
+ byte                __iomem *reset ;
+ byte                __iomem *port ;
+ byte                __iomem *ram ;
+ byte                __iomem *cfg ;
+ byte                __iomem *prom ;
+ byte                __iomem *ctlReg ;
  struct pc_maint  *pcm ;
  diva_os_dependent_devica_name_t os_name;
  byte                Name[32] ;
@@ -254,8 +254,8 @@
 /* ---------------------------------------------------------------------
   Functions for port io
    --------------------------------------------------------------------- */
-void outp_words_from_buffer (word* adr, byte* P, dword len);
-void inp_words_to_buffer    (word* adr, byte* P, dword len);
+void outp_words_from_buffer (word __iomem * adr, byte* P, dword len);
+void inp_words_to_buffer    (word __iomem * adr, byte* P, dword len);
 /* ---------------------------------------------------------------------
   platform specific conversions
    --------------------------------------------------------------------- */
@@ -307,7 +307,7 @@
  word  cnt ;
  word  out ;
 } Xdesc ;
-extern void     dump_trap_frame  (PISDN_ADAPTER IoAdapter, byte *exception) ;
+extern void     dump_trap_frame  (PISDN_ADAPTER IoAdapter, byte __iomem *exception) ;
 extern void     dump_xlog_buffer (PISDN_ADAPTER IoAdapter, Xdesc *xlogDesc) ;
 /* --------------------------------------------------------------------- */
 #endif  /* } __DIVA_XDI_COMMON_IO_H_INC__ */
diff -Nru a/drivers/isdn/hardware/eicon/maintidi.c b/drivers/isdn/hardware/eicon/maintidi.c
--- a/drivers/isdn/hardware/eicon/maintidi.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/isdn/hardware/eicon/maintidi.c	2004-12-24 13:36:16 -08:00
@@ -1919,11 +1919,11 @@
 			break;
 
 		case 2:
-			value = (short)READ_WORD(ptr);
+			value = (short)GET_WORD(ptr);
 			break;
 
 		case 4:
-			value = (int)READ_DWORD(ptr);
+			value = (int)GET_DWORD(ptr);
 			break;
 
 		default:
@@ -1947,16 +1947,16 @@
 			break;
 
 		case 2:
-			value = (word)READ_WORD(ptr);
+			value = (word)GET_WORD(ptr);
 			break;
 
 		case 3:
-			value  = (dword)READ_DWORD(ptr);
+			value  = (dword)GET_DWORD(ptr);
 			value &= 0x00ffffff;
 			break;
 
 		case 4:
-			value = (dword)READ_DWORD(ptr);
+			value = (dword)GET_DWORD(ptr);
 			break;
 
 		default:
diff -Nru a/drivers/isdn/hardware/eicon/message.c b/drivers/isdn/hardware/eicon/message.c
--- a/drivers/isdn/hardware/eicon/message.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/isdn/hardware/eicon/message.c	2004-12-24 13:37:00 -08:00
@@ -419,7 +419,7 @@
   {
     dbug(1,dprintf("plci=%x",msg->header.plci));
     plci = &a->plci[msg->header.plci-1];
-    ncci = READ_WORD(&msg->header.ncci);
+    ncci = GET_WORD(&msg->header.ncci);
     if (plci->Id
      && (plci->appl
       || (plci->State == INC_CON_PENDING)
@@ -574,7 +574,7 @@
   }
 
 
-  c = ftable[i].function(READ_DWORD(&msg->header.controller),
+  c = ftable[i].function(GET_DWORD(&msg->header.controller),
                          msg->header.number,
                          a,
                          plci,
@@ -1264,7 +1264,7 @@
           ch = 0;
           if(ai_parms[0].length)
           {
-            ch = READ_WORD(ai_parms[0].info+1);
+            ch = GET_WORD(ai_parms[0].info+1);
             if(ch>4) ch=0; /* safety -> ignore ChannelID */
             if(ch==4) /* explizit CHI in message */
             {
@@ -1289,7 +1289,7 @@
 
             if(ch==3 && ai_parms[0].length>=7 && ai_parms[0].length<=36)
             {
-              dir = READ_WORD(ai_parms[0].info+3);
+              dir = GET_WORD(ai_parms[0].info+3);
               ch_mask = 0;
               m = 0x3f;
               for(i=0; i+5<=ai_parms[0].length; i++)
@@ -1348,15 +1348,15 @@
         add_s(plci,BC,&parms[6]);
         add_s(plci,LLC,&parms[7]);
         add_s(plci,HLC,&parms[8]);
-        CIP = READ_WORD(parms[0].info);
+        CIP = GET_WORD(parms[0].info);
         if (a->Info_Mask[appl->Id-1] & 0x200)
         {
           /* early B3 connect (CIP mask bit 9) no release after a disc */
           add_p(plci,LLI,"\x01\x01");
         }
-        if(READ_WORD(parms[0].info)<29) {
-          add_p(plci,BC,cip_bc[READ_WORD(parms[0].info)][a->u_law]);
-          add_p(plci,HLC,cip_hlc[READ_WORD(parms[0].info)]);
+        if(GET_WORD(parms[0].info)<29) {
+          add_p(plci,BC,cip_bc[GET_WORD(parms[0].info)][a->u_law]);
+          add_p(plci,HLC,cip_hlc[GET_WORD(parms[0].info)]);
         }
         add_p(plci,UID,"\x06\x43\x61\x70\x69\x32\x30");
         sig_req(plci,ASSIGN,DSIG_ID);
@@ -1442,11 +1442,11 @@
   {
     if(!api_parse(&ai->info[1],(word)ai->length,"ssss",ai_parms))
     {
-      dbug(1,dprintf("ai_parms[0].length=%d/0x%x",ai_parms[0].length,READ_WORD(ai_parms[0].info+1)));
+      dbug(1,dprintf("ai_parms[0].length=%d/0x%x",ai_parms[0].length,GET_WORD(ai_parms[0].info+1)));
       ch = 0;
       if(ai_parms[0].length)
       {
-        ch = READ_WORD(ai_parms[0].info+1);
+        ch = GET_WORD(ai_parms[0].info+1);
         dbug(1,dprintf("BCH-I=0x%x",ch));
       }
     }
@@ -1470,7 +1470,7 @@
   else if(plci->State==INC_CON_PENDING || plci->State==INC_CON_ALERT) {
     clear_c_ind_mask_bit (plci, (word)(appl->Id-1));
     dump_c_ind_mask (plci);
-    Reject = READ_WORD(parms[0].info);
+    Reject = GET_WORD(parms[0].info);
     dbug(1,dprintf("Reject=0x%x",Reject));
     if(Reject) 
     {
@@ -1672,15 +1672,15 @@
   Info = _WRONG_IDENTIFIER;
   if(a) {
     Info = 0;
-    a->Info_Mask[appl->Id-1] = READ_DWORD(parms[0].info);
-    a->CIP_Mask[appl->Id-1] = READ_DWORD(parms[1].info);
-    dbug(1,dprintf("CIP_MASK=0x%lx",READ_DWORD(parms[1].info)));
+    a->Info_Mask[appl->Id-1] = GET_DWORD(parms[0].info);
+    a->CIP_Mask[appl->Id-1] = GET_DWORD(parms[1].info);
+    dbug(1,dprintf("CIP_MASK=0x%lx",GET_DWORD(parms[1].info)));
     if (a->Info_Mask[appl->Id-1] & 0x200){ /* early B3 connect provides */
       a->Info_Mask[appl->Id-1] |=  0x10;   /* call progression infos    */
     }
 
     /* check if external controller listen and switch listen on or off*/
-    if(Id&EXT_CONTROLLER && READ_DWORD(parms[1].info)){
+    if(Id&EXT_CONTROLLER && GET_DWORD(parms[1].info)){
       if(a->profile.Global_Options & ON_BOARD_CODEC) {
         dummy_plci.State = IDLE;
         a->codec_listen[appl->Id-1] = &dummy_plci;
@@ -1886,7 +1886,7 @@
     Info = _WRONG_IDENTIFIER;
   }
 
-  selector = READ_WORD(msg[0].info);
+  selector = GET_WORD(msg[0].info);
 
   if(!Info)
   {
@@ -1902,8 +1902,8 @@
           Info = _WRONG_MESSAGE_FORMAT;
           break;
         }
-        SSreq = READ_WORD(&(msg[1].info[1]));
-        WRITE_WORD(&RCparms[1],SSreq);
+        SSreq = GET_WORD(&(msg[1].info[1]));
+        PUT_WORD(&RCparms[1],SSreq);
         SSparms = RCparms;
         switch(SSreq)
         {
@@ -1919,7 +1919,7 @@
             }
             else
             {
-              WRITE_DWORD(&SSstruct[6], MASK_TERMINAL_PORTABILITY);
+              PUT_DWORD(&SSstruct[6], MASK_TERMINAL_PORTABILITY);
               SSparms = (byte *)SSstruct;
               break;
             }
@@ -1946,7 +1946,7 @@
               Info = _WRONG_MESSAGE_FORMAT;
               break;
             }
-            a->Notification_Mask[appl->Id-1] = READ_DWORD(ss_parms[2].info);
+            a->Notification_Mask[appl->Id-1] = GET_DWORD(ss_parms[2].info);
             if(a->Notification_Mask[appl->Id-1] & SMASK_MWI) /* MWI active? */
             {
               if((i=get_plci(a)))
@@ -2096,7 +2096,7 @@
             }
             if(plci && plci->State && ((plci->SuppState==IDLE)||(plci->SuppState==CALL_HELD)))
             {
-              d = READ_DWORD(ss_parms[2].info);     
+              d = GET_DWORD(ss_parms[2].info);     
               if(d>=0x80)
               {
                 dbug(1,dprintf("format wrong"));
@@ -2171,7 +2171,7 @@
               Info = _WRONG_IDENTIFIER;
               break;
             }
-            relatedPLCIvalue = READ_DWORD(ss_parms[2].info);
+            relatedPLCIvalue = GET_DWORD(ss_parms[2].info);
             relatedPLCIvalue &= 0x0000FFFF;
             dbug(1,dprintf("PTY/ECT/addCONF,relPLCI=%lx",relatedPLCIvalue));
             /* controller starts with 0 up to (max_adapter - 1) */
@@ -2294,7 +2294,7 @@
               break;
             }
             /* reuse unused screening indicator */
-            ss_parms[3].info[3] = (byte)READ_WORD(&(ss_parms[2].info[0]));
+            ss_parms[3].info[3] = (byte)GET_WORD(&(ss_parms[2].info[0]));
             plci->command = 0;
             plci->internal_command = CD_REQ_PEND;
             appl->CDEnable = TRUE;
@@ -2334,10 +2334,10 @@
             rplci->internal_command = CF_START_PEND;
             rplci->appl = appl;
             rplci->number = Number;
-            appl->S_Handle = READ_DWORD(&(ss_parms[2].info[0]));
+            appl->S_Handle = GET_DWORD(&(ss_parms[2].info[0]));
             cai[0] = 2;
-            cai[1] = 0x70|(byte)READ_WORD(&(ss_parms[3].info[0])); /* Function */
-            cai[2] = (byte)READ_WORD(&(ss_parms[4].info[0])); /* Basic Service */
+            cai[1] = 0x70|(byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */
+            cai[2] = (byte)GET_WORD(&(ss_parms[4].info[0])); /* Basic Service */
             add_p(rplci,CAI,cai);
             add_p(rplci,OAD,ss_parms[5].info);
             add_p(rplci,CPN,ss_parms[6].info);
@@ -2393,7 +2393,7 @@
               switch(SSreq)
               {
                 case S_INTERROGATE_DIVERSION: /* use cai with S_SERVICE below */
-                  cai[1] = 0x60|(byte)READ_WORD(&(ss_parms[3].info[0])); /* Function */
+                  cai[1] = 0x60|(byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */
                   rplci->internal_command = INTERR_DIVERSION_REQ_PEND; /* move to rplci if assigned */
                   break;
                 case S_INTERROGATE_NUMBERS: /* use cai with S_SERVICE below */
@@ -2402,7 +2402,7 @@
                   break;
                 case S_CALL_FORWARDING_STOP:
                   rplci->internal_command = CF_STOP_PEND;
-                  cai[1] = 0x80|(byte)READ_WORD(&(ss_parms[3].info[0])); /* Function */
+                  cai[1] = 0x80|(byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */
                   break;
                 case S_CCBS_REQUEST:
                   cai[1] = CCBS_REQUEST;
@@ -2433,7 +2433,7 @@
               break;
             }
 
-            appl->S_Handle = READ_DWORD(&(ss_parms[2].info[0]));
+            appl->S_Handle = GET_DWORD(&(ss_parms[2].info[0]));
             switch(SSreq)
             {
             case S_INTERROGATE_NUMBERS:
@@ -2443,18 +2443,18 @@
             case S_CCBS_REQUEST:
             case S_CCBS_DEACTIVATE:
                 cai[0] = 3;
-                WRITE_WORD(&cai[2],READ_WORD(&(ss_parms[3].info[0])));
+                PUT_WORD(&cai[2],GET_WORD(&(ss_parms[3].info[0])));
                 add_p(rplci,CAI,cai);
                 break;
             case S_CCBS_INTERROGATE:
                 cai[0] = 3;
-                WRITE_WORD(&cai[2],READ_WORD(&(ss_parms[3].info[0])));
+                PUT_WORD(&cai[2],GET_WORD(&(ss_parms[3].info[0])));
                 add_p(rplci,CAI,cai);
                 add_p(rplci,OAD,ss_parms[4].info);
                 break;
             default:
             cai[0] = 2;
-            cai[2] = (byte)READ_WORD(&(ss_parms[4].info[0])); /* Basic Service */
+            cai[2] = (byte)GET_WORD(&(ss_parms[4].info[0])); /* Basic Service */
             add_p(rplci,CAI,cai);
             add_p(rplci,OAD,ss_parms[5].info);
                 break;
@@ -2503,11 +2503,11 @@
 
             cai[0] = 13;
             cai[1] = ACTIVATION_MWI; /* Function */
-            WRITE_WORD(&cai[2],READ_WORD(&(ss_parms[2].info[0]))); /* Basic Service */
-            WRITE_DWORD(&cai[4],READ_DWORD(&(ss_parms[3].info[0]))); /* Number of Messages */
-            WRITE_WORD(&cai[8],READ_WORD(&(ss_parms[4].info[0]))); /* Message Status */
-            WRITE_WORD(&cai[10],READ_WORD(&(ss_parms[5].info[0]))); /* Message Reference */
-            WRITE_WORD(&cai[12],READ_WORD(&(ss_parms[6].info[0]))); /* Invocation Mode */
+            PUT_WORD(&cai[2],GET_WORD(&(ss_parms[2].info[0]))); /* Basic Service */
+            PUT_DWORD(&cai[4],GET_DWORD(&(ss_parms[3].info[0]))); /* Number of Messages */
+            PUT_WORD(&cai[8],GET_WORD(&(ss_parms[4].info[0]))); /* Message Status */
+            PUT_WORD(&cai[10],GET_WORD(&(ss_parms[5].info[0]))); /* Message Reference */
+            PUT_WORD(&cai[12],GET_WORD(&(ss_parms[6].info[0]))); /* Invocation Mode */
             add_p(rplci,CAI,cai);
             add_p(rplci,CPN,ss_parms[7].info); /* Receiving User Number */
             add_p(rplci,OAD,ss_parms[8].info); /* Controlling User Number */
@@ -2555,8 +2555,8 @@
 
             cai[0] = 5;
             cai[1] = DEACTIVATION_MWI; /* Function */
-            WRITE_WORD(&cai[2],READ_WORD(&(ss_parms[2].info[0]))); /* Basic Service */
-            WRITE_WORD(&cai[4],READ_WORD(&(ss_parms[3].info[0]))); /* Invocation Mode */
+            PUT_WORD(&cai[2],GET_WORD(&(ss_parms[2].info[0]))); /* Basic Service */
+            PUT_WORD(&cai[4],GET_WORD(&(ss_parms[3].info[0]))); /* Invocation Mode */
             add_p(rplci,CAI,cai);
             add_p(rplci,CPN,ss_parms[4].info); /* Receiving User Number */
             add_p(rplci,OAD,ss_parms[5].info); /* Controlling User Number */
@@ -2684,8 +2684,8 @@
       {
         if (plci->NL.Id && !plci->nl_remove_id)
         {
-          fax_control_bits = READ_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low);
-          fax_feature_bits = READ_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->feature_bits_low);
+          fax_control_bits = GET_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low);
+          fax_feature_bits = GET_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->feature_bits_low);
           if (!(fax_control_bits & T30_CONTROL_BIT_MORE_DOCUMENTS)
            || (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS))
           {
@@ -2693,7 +2693,7 @@
             fax_info_change = FALSE;
             if (ncpi->length >= 4)
             {
-              w = READ_WORD(&ncpi->info[3]);
+              w = GET_WORD(&ncpi->info[3]);
               if ((w & 0x0001) != ((word)(((T30_INFO   *)(plci->fax_connect_info_buffer))->resolution & 0x0001)))
               {
                 ((T30_INFO   *)(plci->fax_connect_info_buffer))->resolution =
@@ -2711,7 +2711,7 @@
               }
               if (ncpi->length >= 6)
               {
-                w = READ_WORD(&ncpi->info[5]);
+                w = GET_WORD(&ncpi->info[5]);
                 if (((byte) w) != ((T30_INFO   *)(plci->fax_connect_info_buffer))->data_format)
                 {
                   ((T30_INFO   *)(plci->fax_connect_info_buffer))->data_format = (byte) w;
@@ -2719,12 +2719,12 @@
                 }
 
                 if ((a->man_profile.private_options & (1L << PRIVATE_FAX_SUB_SEP_PWD))
-                 && (READ_WORD(&ncpi->info[5]) & 0x8000)) /* Private SEP/SUB/PWD enable */
+                 && (GET_WORD(&ncpi->info[5]) & 0x8000)) /* Private SEP/SUB/PWD enable */
                 {
                   plci->requested_options_conn |= (1L << PRIVATE_FAX_SUB_SEP_PWD);
                 }
                 if ((a->man_profile.private_options & (1L << PRIVATE_FAX_NONSTANDARD))
-                 && (READ_WORD(&ncpi->info[5]) & 0x4000)) /* Private non-standard facilities enable */
+                 && (GET_WORD(&ncpi->info[5]) & 0x4000)) /* Private non-standard facilities enable */
                 {
                   plci->requested_options_conn |= (1L << PRIVATE_FAX_NONSTANDARD);
                 }
@@ -2775,7 +2775,7 @@
                       else
                       {
           if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2))
-            plci->nsf_control_bits = READ_WORD(&fax_parms[7].info[2]);
+            plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]);
    plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length);
           for (i = 0; i < fax_parms[7].length; i++)
      plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1+i];
@@ -2790,9 +2790,9 @@
                 fax_info_change = TRUE;
 
               }
-              if (fax_control_bits != READ_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low))
+              if (fax_control_bits != GET_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low))
               {
-                WRITE_WORD (&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low, fax_control_bits);
+                PUT_WORD (&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low, fax_control_bits);
                 fax_info_change = TRUE;
               }
             }
@@ -2865,7 +2865,7 @@
   ncci = (word)(Id>>16);
   if(plci && ncci) {
     if(a->ncci_state[ncci]==INC_CON_PENDING) {
-      if (READ_WORD (&parms[0].info[0]) != 0)
+      if (GET_WORD (&parms[0].info[0]) != 0)
       {
         a->ncci_state[ncci] = OUTG_REJ_PENDING;
         channel_request_xon (plci, a->ncci_ch[ncci]);
@@ -2907,7 +2907,7 @@
                 plci->fax_connect_info_buffer[len] = 0;
               len += 1 + plci->fax_connect_info_buffer[len];
               if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2))
-                plci->nsf_control_bits = READ_WORD(&fax_parms[7].info[2]);
+                plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]);
               plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length);
               for (i = 0; i < fax_parms[7].length; i++)
                 plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1+i];
@@ -3129,9 +3129,9 @@
       }
       else
         data->P = TransmitBufferSet(appl,*(dword *)parms[0].info);
-      data->Length = READ_WORD(parms[1].info);
-      data->Handle = READ_WORD(parms[2].info);
-      data->Flags = READ_WORD(parms[3].info);
+      data->Length = GET_WORD(parms[1].info);
+      data->Handle = GET_WORD(parms[2].info);
+      data->Flags = GET_WORD(parms[3].info);
       (ncci_ptr->data_pending)++;
 
         /* check for delivery confirmation */
@@ -3165,7 +3165,7 @@
           _DATA_B3_R|CONFIRM,
           Id,
           Number,
-          "ww",READ_WORD(parms[2].info),Info);
+          "ww",GET_WORD(parms[2].info),Info);
   }
   return FALSE;
 }
@@ -3180,7 +3180,7 @@
 
   ncci = (word)(Id>>16);
   if(plci && ncci) {
-    n = READ_WORD(parms[0].info);
+    n = GET_WORD(parms[0].info);
     dbug(1,dprintf("free(%d)",n));
     NCCIcode = ncci | (((word) a->Id) << 8);
     if(n<appl->MaxBuffer &&
@@ -3443,10 +3443,10 @@
   dbug(1,dprintf("manufacturer_req"));
   for(i=0;i<5;i++) m_parms[i].length = 0;
 
-  if(READ_DWORD(parms[0].info)!=_DI_MANU_ID) {
+  if(GET_DWORD(parms[0].info)!=_DI_MANU_ID) {
     Info = _WRONG_MESSAGE_FORMAT;
   }
-  command = READ_WORD(parms[1].info);
+  command = GET_WORD(parms[1].info);
   m = &parms[2];
   if (!Info)
   {
@@ -3456,7 +3456,7 @@
         Info = _WRONG_MESSAGE_FORMAT;
         break;
       }
-      codec = READ_WORD(m_parms[0].info);
+      codec = GET_WORD(m_parms[0].info);
       ch = m_parms[1].info[0];
       dir = m_parms[2].info[0];
       if((i=get_plci(a))) {
@@ -3724,12 +3724,12 @@
         Info = _WRONG_MESSAGE_FORMAT;
         break;
       }
-      if (READ_DWORD (m_parms[0].info) & ~a->man_profile.private_options)
+      if (GET_DWORD (m_parms[0].info) & ~a->man_profile.private_options)
       {
         Info = _FACILITY_NOT_SUPPORTED;
         break;
       }
-      a->requested_options_table[appl->Id-1] = READ_DWORD (m_parms[0].info);
+      a->requested_options_table[appl->Id-1] = GET_DWORD (m_parms[0].info);
       break;
 
 
@@ -3764,11 +3764,11 @@
 
   if ((msg[0].length == 0)
    || (msg[1].length == 0)
-   || (READ_DWORD(msg[0].info)!=_DI_MANU_ID))
+   || (GET_DWORD(msg[0].info)!=_DI_MANU_ID))
   {
     return FALSE;
   }
-  indication = READ_WORD(msg[1].info);
+  indication = GET_WORD(msg[1].info);
   switch (indication)
   {
 
@@ -3806,7 +3806,7 @@
         plci->fax_connect_info_buffer[len] = 0;
       len += 1 + plci->fax_connect_info_buffer[len];
       if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2))
-        plci->nsf_control_bits = READ_WORD(&fax_parms[7].info[2]);
+        plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]);
       plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length);
       for (i = 0; i < fax_parms[7].length; i++)
         plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1+i];
@@ -4290,7 +4290,7 @@
         {
           break;
         }
-        WRITE_DWORD(&SSstruct[6], MASK_TERMINAL_PORTABILITY);
+        PUT_DWORD(&SSstruct[6], MASK_TERMINAL_PORTABILITY);
         sendf(appl, _FACILITY_R|CONFIRM, Id, Number, "wws",0,3,SSstruct);
         plci_remove(plci);
         break;
@@ -4495,14 +4495,14 @@
             dbug(1,dprintf("MWI_REQ not supported"));
           }
           /* 0x3010: Request not allowed in this state */
-          WRITE_WORD(&SSparms[4],0x300E); /* SS not supported */
+          PUT_WORD(&SSparms[4],0x300E); /* SS not supported */
                     
         }
         if(plci->internal_command==MWI_ACTIVATE_REQ_PEND)
         {
-          WRITE_WORD(&SSparms[1],S_MWI_ACTIVATE);
+          PUT_WORD(&SSparms[1],S_MWI_ACTIVATE);
         }
-        else WRITE_WORD(&SSparms[1],S_MWI_DEACTIVATE);
+        else PUT_WORD(&SSparms[1],S_MWI_DEACTIVATE);
 
         if(plci->cr_enquiry)
         {
@@ -4875,7 +4875,7 @@
 
   a = plci->adapter;
   Id = ((word)plci->Id<<8)|a->Id;
-  WRITE_WORD(&SS_Ind[4],0x0000);
+  PUT_WORD(&SS_Ind[4],0x0000);
 
   if (plci->sig_remove_id)
   {
@@ -4987,21 +4987,21 @@
     if (esc_profile[0])
     {
       dbug (1, dprintf ("[%06x] CardProfile: %lx %lx %lx %lx %lx",
-        UnMapController (a->Id), READ_DWORD (&esc_profile[6]),
-        READ_DWORD (&esc_profile[10]), READ_DWORD (&esc_profile[14]),
-        READ_DWORD (&esc_profile[18]), READ_DWORD (&esc_profile[46])));
+        UnMapController (a->Id), GET_DWORD (&esc_profile[6]),
+        GET_DWORD (&esc_profile[10]), GET_DWORD (&esc_profile[14]),
+        GET_DWORD (&esc_profile[18]), GET_DWORD (&esc_profile[46])));
 
       a->profile.Global_Options &= 0x000000ffL;
       a->profile.B1_Protocols &= 0x000003ffL;
       a->profile.B2_Protocols &= 0x00001fdfL;
       a->profile.B3_Protocols &= 0x000000b7L;
 
-      a->profile.Global_Options &= READ_DWORD (&esc_profile[6]) |
+      a->profile.Global_Options &= GET_DWORD (&esc_profile[6]) |
         GL_BCHANNEL_OPERATION_SUPPORTED;
-      a->profile.B1_Protocols &= READ_DWORD (&esc_profile[10]);
-      a->profile.B2_Protocols &= READ_DWORD (&esc_profile[14]);
-      a->profile.B3_Protocols &= READ_DWORD (&esc_profile[18]);
-      a->manufacturer_features = READ_DWORD (&esc_profile[46]);
+      a->profile.B1_Protocols &= GET_DWORD (&esc_profile[10]);
+      a->profile.B2_Protocols &= GET_DWORD (&esc_profile[14]);
+      a->profile.B3_Protocols &= GET_DWORD (&esc_profile[18]);
+      a->manufacturer_features = GET_DWORD (&esc_profile[46]);
       a->man_profile.private_options = 0;
 
       if (a->manufacturer_features & MANUFACTURER_FEATURE_ECHO_CANCELLER)
@@ -5013,8 +5013,8 @@
 
       if (a->manufacturer_features & MANUFACTURER_FEATURE_RTP)
         a->man_profile.private_options |= 1L << PRIVATE_RTP;
-      a->man_profile.rtp_primary_payloads = READ_DWORD (&esc_profile[50]);
-      a->man_profile.rtp_additional_payloads = READ_DWORD (&esc_profile[54]);
+      a->man_profile.rtp_primary_payloads = GET_DWORD (&esc_profile[50]);
+      a->man_profile.rtp_additional_payloads = GET_DWORD (&esc_profile[54]);
 
 
       if (a->manufacturer_features & MANUFACTURER_FEATURE_T38)
@@ -5099,14 +5099,14 @@
     if(!plci->appl) break;
     if(pty_cai[0]==4)
     {
-      WRITE_DWORD(&CF_Ind[6],READ_DWORD(&pty_cai[1]) );
+      PUT_DWORD(&CF_Ind[6],GET_DWORD(&pty_cai[1]) );
     }
     else
     {
-      WRITE_DWORD(&CF_Ind[6],MASK_TERMINAL_PORTABILITY | MASK_HOLD_RETRIEVE);
+      PUT_DWORD(&CF_Ind[6],MASK_TERMINAL_PORTABILITY | MASK_HOLD_RETRIEVE);
     }
-    WRITE_WORD (&CF_Ind[1], 0);
-    WRITE_WORD (&CF_Ind[4], 0);
+    PUT_WORD (&CF_Ind[1], 0);
+    PUT_WORD (&CF_Ind[4], 0);
     sendf(plci->appl,_FACILITY_R|CONFIRM,Id&0x7,plci->number, "wws",0,3,CF_Ind);
     plci_remove(plci);
     break;
@@ -5126,7 +5126,7 @@
       if(tplci->tel) rId|=EXT_CONTROLLER;
       if(pty_cai[5]==ECT_EXECUTE)
       {
-        WRITE_WORD(&SS_Ind[1],S_ECT);
+        PUT_WORD(&SS_Ind[1],S_ECT);
 
         plci->vswitchstate=0;
         plci->relatedPTYPLCI->vswitchstate=0;
@@ -5134,15 +5134,15 @@
       }
       else
       {
-        WRITE_WORD(&SS_Ind[1],pty_cai[5]+3);
+        PUT_WORD(&SS_Ind[1],pty_cai[5]+3);
       }
       if(pty_cai[2]!=0xff)
       {
-        WRITE_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]);
+        PUT_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]);
       }
       else
       {
-        WRITE_WORD(&SS_Ind[4],0x300E);
+        PUT_WORD(&SS_Ind[4],0x300E);
       }
       plci->relatedPTYPLCI = NULL;
       plci->ptyState = 0;
@@ -5152,13 +5152,13 @@
     case CALL_DEFLECTION:
       if(pty_cai[2]!=0xff)
       {
-        WRITE_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]);
+        PUT_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]);
       }
       else
       {
-        WRITE_WORD(&SS_Ind[4],0x300E);
+        PUT_WORD(&SS_Ind[4],0x300E);
       }
-      WRITE_WORD(&SS_Ind[1],pty_cai[5]);
+      PUT_WORD(&SS_Ind[1],pty_cai[5]);
       for(i=0; i<max_appl; i++)
       {
         if(application[i].CDEnable)
@@ -5181,11 +5181,11 @@
       if(!plci->appl) break;
       if(pty_cai[2]!=0xff)
       {
-        WRITE_WORD(&Interr_Err_Ind[4],0x3600|(word)pty_cai[2]);
+        PUT_WORD(&Interr_Err_Ind[4],0x3600|(word)pty_cai[2]);
       }
       else
       {
-        WRITE_WORD(&Interr_Err_Ind[4],0x300E);
+        PUT_WORD(&Interr_Err_Ind[4],0x300E);
       }
       switch (pty_cai[5])
       {
@@ -5193,13 +5193,13 @@
           dbug(1,dprintf("Deact_Div"));
           Interr_Err_Ind[0]=0x9;
           Interr_Err_Ind[3]=0x6;
-          WRITE_WORD(&Interr_Err_Ind[1],S_CALL_FORWARDING_STOP);
+          PUT_WORD(&Interr_Err_Ind[1],S_CALL_FORWARDING_STOP);
           break;
         case ACTIVATION_DIVERSION:
           dbug(1,dprintf("Act_Div"));
           Interr_Err_Ind[0]=0x9;
           Interr_Err_Ind[3]=0x6;
-          WRITE_WORD(&Interr_Err_Ind[1],S_CALL_FORWARDING_START);
+          PUT_WORD(&Interr_Err_Ind[1],S_CALL_FORWARDING_START);
           break;
         case DIVERSION_INTERROGATE_CFU:
         case DIVERSION_INTERROGATE_CFB:
@@ -5207,34 +5207,34 @@
           dbug(1,dprintf("Interr_Div"));
           Interr_Err_Ind[0]=0xa;
           Interr_Err_Ind[3]=0x7;
-          WRITE_WORD(&Interr_Err_Ind[1],S_INTERROGATE_DIVERSION);
+          PUT_WORD(&Interr_Err_Ind[1],S_INTERROGATE_DIVERSION);
           break;
         case DIVERSION_INTERROGATE_NUM:
           dbug(1,dprintf("Interr_Num"));
           Interr_Err_Ind[0]=0xa;
           Interr_Err_Ind[3]=0x7;
-          WRITE_WORD(&Interr_Err_Ind[1],S_INTERROGATE_NUMBERS);
+          PUT_WORD(&Interr_Err_Ind[1],S_INTERROGATE_NUMBERS);
           break;
         case CCBS_REQUEST:
           dbug(1,dprintf("CCBS Request"));
           Interr_Err_Ind[0]=0xd;
           Interr_Err_Ind[3]=0xa;
-          WRITE_WORD(&Interr_Err_Ind[1],S_CCBS_REQUEST);
+          PUT_WORD(&Interr_Err_Ind[1],S_CCBS_REQUEST);
           break;
         case CCBS_DEACTIVATE:
           dbug(1,dprintf("CCBS Deactivate"));
           Interr_Err_Ind[0]=0x9;
           Interr_Err_Ind[3]=0x6;
-          WRITE_WORD(&Interr_Err_Ind[1],S_CCBS_DEACTIVATE);
+          PUT_WORD(&Interr_Err_Ind[1],S_CCBS_DEACTIVATE);
           break;
         case CCBS_INTERROGATE:
           dbug(1,dprintf("CCBS Interrogate"));
           Interr_Err_Ind[0]=0xb;
           Interr_Err_Ind[3]=0x8;
-          WRITE_WORD(&Interr_Err_Ind[1],S_CCBS_INTERROGATE);
+          PUT_WORD(&Interr_Err_Ind[1],S_CCBS_INTERROGATE);
           break;
       }
-      WRITE_DWORD(&Interr_Err_Ind[6],plci->appl->S_Handle);
+      PUT_DWORD(&Interr_Err_Ind[6],plci->appl->S_Handle);
       sendf(plci->appl,_FACILITY_I,Id&0x7,0,"ws",3, Interr_Err_Ind);
       plci_remove(plci);
       break;
@@ -5242,17 +5242,17 @@
     case DEACTIVATION_MWI:
       if(pty_cai[5]==ACTIVATION_MWI)
       {
-        WRITE_WORD(&SS_Ind[1],S_MWI_ACTIVATE);
+        PUT_WORD(&SS_Ind[1],S_MWI_ACTIVATE);
       }
-      else WRITE_WORD(&SS_Ind[1],S_MWI_DEACTIVATE);
+      else PUT_WORD(&SS_Ind[1],S_MWI_DEACTIVATE);
       
       if(pty_cai[2]!=0xff)
       {
-        WRITE_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]);
+        PUT_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]);
       }
       else
       {
-        WRITE_WORD(&SS_Ind[4],0x300E);
+        PUT_WORD(&SS_Ind[4],0x300E);
       }
 
       if(plci->cr_enquiry)
@@ -5275,29 +5275,29 @@
       switch(pty_cai[5])
       {
       case CONF_BEGIN:
-          WRITE_WORD(&CONF_Ind[1],S_CONF_BEGIN);
+          PUT_WORD(&CONF_Ind[1],S_CONF_BEGIN);
           plci->ptyState = 0;
           break;
       case CONF_DROP:
           CONF_Ind[0]=5;
           CONF_Ind[3]=2;
-          WRITE_WORD(&CONF_Ind[1],S_CONF_DROP);
+          PUT_WORD(&CONF_Ind[1],S_CONF_DROP);
           plci->ptyState = CONNECTED;
           break;
       case CONF_ISOLATE:
           CONF_Ind[0]=5;
           CONF_Ind[3]=2;
-          WRITE_WORD(&CONF_Ind[1],S_CONF_ISOLATE);
+          PUT_WORD(&CONF_Ind[1],S_CONF_ISOLATE);
           plci->ptyState = CONNECTED;
           break;
       case CONF_REATTACH:
           CONF_Ind[0]=5;
           CONF_Ind[3]=2;
-          WRITE_WORD(&CONF_Ind[1],S_CONF_REATTACH);
+          PUT_WORD(&CONF_Ind[1],S_CONF_REATTACH);
           plci->ptyState = CONNECTED;
           break;
       case CONF_ADD:
-          WRITE_WORD(&CONF_Ind[1],S_CONF_ADD);
+          PUT_WORD(&CONF_Ind[1],S_CONF_ADD);
           plci->relatedPTYPLCI = NULL;
           tplci=plci->relatedPTYPLCI;
           if(tplci) tplci->ptyState = CONNECTED;
@@ -5307,15 +5307,15 @@
           
       if(pty_cai[2]!=0xff)
       {
-        WRITE_WORD(&CONF_Ind[4],0x3600|(word)pty_cai[2]);
+        PUT_WORD(&CONF_Ind[4],0x3600|(word)pty_cai[2]);
       }
       else
       {
-        WRITE_WORD(&CONF_Ind[4],0x3303); /* Time-out: network did not respond
+        PUT_WORD(&CONF_Ind[4],0x3303); /* Time-out: network did not respond
                                             within the required time */
       }
 
-      WRITE_DWORD(&CONF_Ind[6],0x0);
+      PUT_DWORD(&CONF_Ind[6],0x0);
       sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, CONF_Ind);
       break;
     }
@@ -5324,7 +5324,7 @@
   /* Supplementary Service indicates success */
   case S_SERVICE:
     dbug(1,dprintf("Service_Ind"));
-    WRITE_WORD (&CF_Ind[4], 0);
+    PUT_WORD (&CF_Ind[4], 0);
     switch (pty_cai[5])
     {
     case THREE_PTY_END:
@@ -5336,7 +5336,7 @@
       if(tplci->tel) rId|=EXT_CONTROLLER;
       if(pty_cai[5]==ECT_EXECUTE)
       {
-        WRITE_WORD(&SS_Ind[1],S_ECT);
+        PUT_WORD(&SS_Ind[1],S_ECT);
 
         if(plci->vswitchstate!=3)
         {
@@ -5369,13 +5369,13 @@
           dbug(1,dprintf("3PTY OFF"));
           break;
         }
-        WRITE_WORD(&SS_Ind[1],pty_cai[5]+3);
+        PUT_WORD(&SS_Ind[1],pty_cai[5]+3);
         sendf(tplci->appl,_FACILITY_I,rId,0,"ws",3, SS_Ind);
       }
       break;
 
     case CALL_DEFLECTION:
-      WRITE_WORD(&SS_Ind[1],pty_cai[5]);
+      PUT_WORD(&SS_Ind[1],pty_cai[5]);
       for(i=0; i<max_appl; i++)
       {
         if(application[i].CDEnable)
@@ -5389,8 +5389,8 @@
     case DEACTIVATION_DIVERSION:
     case ACTIVATION_DIVERSION:
       if(!plci->appl) break;
-      WRITE_WORD(&CF_Ind[1],pty_cai[5]+2);
-      WRITE_DWORD(&CF_Ind[6],plci->appl->S_Handle);
+      PUT_WORD(&CF_Ind[1],pty_cai[5]+2);
+      PUT_DWORD(&CF_Ind[6],plci->appl->S_Handle);
       sendf(plci->appl,_FACILITY_I,Id&0x7,0,"ws",3, CF_Ind);
       plci_remove(plci);
       break;
@@ -5409,32 +5409,32 @@
         case DIVERSION_INTERROGATE_CFB:
         case DIVERSION_INTERROGATE_CFNR:
           dbug(1,dprintf("Interr_Div"));
-          WRITE_WORD(&pty_cai[1],S_INTERROGATE_DIVERSION);
+          PUT_WORD(&pty_cai[1],S_INTERROGATE_DIVERSION);
           pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */
           break;
         case DIVERSION_INTERROGATE_NUM:
           dbug(1,dprintf("Interr_Num"));
-          WRITE_WORD(&pty_cai[1],S_INTERROGATE_NUMBERS);
+          PUT_WORD(&pty_cai[1],S_INTERROGATE_NUMBERS);
           pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */
           break;
         case CCBS_REQUEST:
           dbug(1,dprintf("CCBS Request"));
-          WRITE_WORD(&pty_cai[1],S_CCBS_REQUEST);
+          PUT_WORD(&pty_cai[1],S_CCBS_REQUEST);
           pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */
           break;
         case CCBS_DEACTIVATE:
           dbug(1,dprintf("CCBS Deactivate"));
-          WRITE_WORD(&pty_cai[1],S_CCBS_DEACTIVATE);
+          PUT_WORD(&pty_cai[1],S_CCBS_DEACTIVATE);
           pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */
           break;
         case CCBS_INTERROGATE:
           dbug(1,dprintf("CCBS Interrogate"));
-          WRITE_WORD(&pty_cai[1],S_CCBS_INTERROGATE);
+          PUT_WORD(&pty_cai[1],S_CCBS_INTERROGATE);
           pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */
           break;
       }
-      WRITE_WORD(&pty_cai[4],0); /* Supplementary Service Reason */
-      WRITE_DWORD(&pty_cai[6],plci->appl->S_Handle);
+      PUT_WORD(&pty_cai[4],0); /* Supplementary Service Reason */
+      PUT_DWORD(&pty_cai[6],plci->appl->S_Handle);
       sendf(plci->appl,_FACILITY_I,Id&0x7,0,"wS",3, pty_cai);
       plci_remove(plci);
       break;
@@ -5443,9 +5443,9 @@
     case DEACTIVATION_MWI:
       if(pty_cai[5]==ACTIVATION_MWI)
       {
-        WRITE_WORD(&SS_Ind[1],S_MWI_ACTIVATE);
+        PUT_WORD(&SS_Ind[1],S_MWI_ACTIVATE);
       }
-      else WRITE_WORD(&SS_Ind[1],S_MWI_DEACTIVATE);
+      else PUT_WORD(&SS_Ind[1],S_MWI_DEACTIVATE);
       if(plci->cr_enquiry)
       {
         sendf(plci->appl,_FACILITY_I,Id&0xf,0,"ws",3, SS_Ind);
@@ -5459,7 +5459,7 @@
     case MWI_INDICATION:
       if(pty_cai[0]>=0x12)
       {
-        WRITE_WORD(&pty_cai[3],S_MWI_INDICATE);
+        PUT_WORD(&pty_cai[3],S_MWI_INDICATE);
         pty_cai[2]=pty_cai[0]-2; /* len Parameter */
         pty_cai[5]=pty_cai[0]-5; /* Supplementary Service-specific parameter len */
         if(plci->appl && (a->Notification_Mask[plci->appl->Id-1]&SMASK_MWI))
@@ -5516,45 +5516,45 @@
       switch(pty_cai[5])
       {
       case CONF_BEGIN:
-          WRITE_WORD(&CONF_Ind[1],S_CONF_BEGIN);
+          PUT_WORD(&CONF_Ind[1],S_CONF_BEGIN);
           if(pty_cai[0]==6)
           {
               d=pty_cai[6];
-              WRITE_DWORD(&CONF_Ind[6],d); /* PartyID */
+              PUT_DWORD(&CONF_Ind[6],d); /* PartyID */
           }
           else
           {
-              WRITE_DWORD(&CONF_Ind[6],0x0);
+              PUT_DWORD(&CONF_Ind[6],0x0);
           }
           break;
       case CONF_ISOLATE:
-          WRITE_WORD(&CONF_Ind[1],S_CONF_ISOLATE);
+          PUT_WORD(&CONF_Ind[1],S_CONF_ISOLATE);
           CONF_Ind[0]=5;
           CONF_Ind[3]=2;
           break;
       case CONF_REATTACH:
-          WRITE_WORD(&CONF_Ind[1],S_CONF_REATTACH);
+          PUT_WORD(&CONF_Ind[1],S_CONF_REATTACH);
           CONF_Ind[0]=5;
           CONF_Ind[3]=2;
           break;
       case CONF_DROP:
-          WRITE_WORD(&CONF_Ind[1],S_CONF_DROP);
+          PUT_WORD(&CONF_Ind[1],S_CONF_DROP);
           CONF_Ind[0]=5;
           CONF_Ind[3]=2;
           break;
       case CONF_ADD:
-          WRITE_WORD(&CONF_Ind[1],S_CONF_ADD);
+          PUT_WORD(&CONF_Ind[1],S_CONF_ADD);
           d=pty_cai[6];
-          WRITE_DWORD(&CONF_Ind[6],d); /* PartyID */
+          PUT_DWORD(&CONF_Ind[6],d); /* PartyID */
           tplci=plci->relatedPTYPLCI;
           if(tplci) tplci->ptyState = CONNECTED;
           break;
       case CONF_PARTYDISC:
           CONF_Ind[0]=7;
           CONF_Ind[3]=4;          
-          WRITE_WORD(&CONF_Ind[1],S_CONF_PARTYDISC);
+          PUT_WORD(&CONF_Ind[1],S_CONF_PARTYDISC);
           d=pty_cai[6];
-          WRITE_DWORD(&CONF_Ind[4],d); /* PartyID */
+          PUT_DWORD(&CONF_Ind[4],d); /* PartyID */
           break;
       }
       plci->ptyState = CONNECTED;
@@ -5568,13 +5568,13 @@
       switch(pty_cai[5])
       {
       case CCBS_INFO_RETAIN:
-        WRITE_WORD(&CONF_Ind[1],S_CCBS_INFO_RETAIN);
+        PUT_WORD(&CONF_Ind[1],S_CCBS_INFO_RETAIN);
         break;
       case CCBS_STOP_ALERTING:
-        WRITE_WORD(&CONF_Ind[1],S_CCBS_STOP_ALERTING);
+        PUT_WORD(&CONF_Ind[1],S_CCBS_STOP_ALERTING);
     break;
       case CCBS_ERASECALLLINKAGEID:
-        WRITE_WORD(&CONF_Ind[1],S_CCBS_ERASECALLLINKAGEID);
+        PUT_WORD(&CONF_Ind[1],S_CCBS_ERASECALLLINKAGEID);
         CONF_Ind[0]=7;
         CONF_Ind[3]=4;
         CONF_Ind[6]=0;
@@ -5582,7 +5582,7 @@
         break;
       }      
       w=pty_cai[6];
-      WRITE_WORD(&CONF_Ind[4],w); /* PartyID */
+      PUT_WORD(&CONF_Ind[4],w); /* PartyID */
 
       if(plci->appl && (a->Notification_Mask[plci->appl->Id-1]&SMASK_CCBS))
       {
@@ -5608,8 +5608,8 @@
     {
       i = 0x3603;
     }
-    WRITE_WORD(&SS_Ind[1],S_HOLD);
-    WRITE_WORD(&SS_Ind[4],i);
+    PUT_WORD(&SS_Ind[1],S_HOLD);
+    PUT_WORD(&SS_Ind[4],i);
     if(plci->SuppState == HOLD_REQUEST)
     {
       plci->SuppState = IDLE;
@@ -5637,8 +5637,8 @@
     {
       i = 0x3603;
     }
-    WRITE_WORD(&SS_Ind[1],S_RETRIEVE);
-    WRITE_WORD(&SS_Ind[4],i);
+    PUT_WORD(&SS_Ind[1],S_RETRIEVE);
+    PUT_WORD(&SS_Ind[4],i);
     if(plci->SuppState == RETRIEVE_REQUEST)
     {
       plci->SuppState = CALL_HELD;
@@ -5648,7 +5648,7 @@
     break;
 
   case CALL_RETRIEVE_ACK:
-    WRITE_WORD(&SS_Ind[1],S_RETRIEVE);
+    PUT_WORD(&SS_Ind[1],S_RETRIEVE);
     if(plci->SuppState == RETRIEVE_REQUEST)
     {
       plci->SuppState = IDLE;
@@ -5919,7 +5919,7 @@
               a->AdvSignalPLCI = &a->plci[i-1];
               tplci = a->AdvSignalPLCI;
               tplci->tel  = ADV_VOICE;
-              WRITE_WORD(&voice_cai[5],a->AdvSignalAppl->MaxDataLength);
+              PUT_WORD(&voice_cai[5],a->AdvSignalAppl->MaxDataLength);
               if (a->Info_Mask[a->AdvSignalAppl->Id-1] & 0x200){
                 /* early B3 connect (CIP mask bit 9) no release after a disc */
                 add_p(tplci,LLI,"\x01\x01");
@@ -5985,7 +5985,7 @@
 
   case RESUME:
     clear_c_ind_mask_bit (plci, (word)(plci->appl->Id-1));
-    WRITE_WORD(&resume_cau[4],GOOD);
+    PUT_WORD(&resume_cau[4],GOOD);
     sendf(plci->appl,_FACILITY_I,Id,0,"ws", (word)3, resume_cau);
     break;
 
@@ -6070,7 +6070,7 @@
       {
         if(plci->State==RESUMING)
         {
-          WRITE_WORD(&resume_cau[4],i);
+          PUT_WORD(&resume_cau[4],i);
           sendf(plci->appl,_FACILITY_I,Id,0,"ws", (word)3, resume_cau);
         }
         plci->State = INC_DIS_PENDING;
@@ -6624,10 +6624,10 @@
         if ((*data == DSP_CONNECTED_NORM_V18) || (*data == DSP_CONNECTED_NORM_VOWN))
           ncpi_state &= ~(NCPI_MDM_DCD_ON_RECEIVED | NCPI_MDM_CTS_ON_RECEIVED);
         data++;    /* connected norm */
-        conn_opt = READ_WORD(data);
+        conn_opt = GET_WORD(data);
         data += 2; /* connected options */
 
-        WRITE_WORD (&(plci->ncpi_buffer[1]), (word)(READ_DWORD(data) & 0x0000FFFF));
+        PUT_WORD (&(plci->ncpi_buffer[1]), (word)(GET_DWORD(data) & 0x0000FFFF));
 
         if (conn_opt & DSP_CONNECTED_OPTION_MASK_V42)
         {
@@ -6645,7 +6645,7 @@
         {
           ncpi_opt |= MDM_NCPI_COMPRESSED;
         }
-        WRITE_WORD (&(plci->ncpi_buffer[3]), ncpi_opt);
+        PUT_WORD (&(plci->ncpi_buffer[3]), ncpi_opt);
         plci->ncpi_buffer[0] = 4;
 
         plci->ncpi_state |= NCPI_VALID_CONNECT_B3_IND | NCPI_VALID_CONNECT_B3_ACT | NCPI_VALID_DISC_B3_IND;
@@ -6788,8 +6788,8 @@
       {
         dbug(1,dprintf("FaxStatus %04x", ((T30_INFO   *)plci->NL.RBuffer->P)->code));
         len = 9;
-        WRITE_WORD(&(plci->ncpi_buffer[1]),((T30_INFO   *)plci->NL.RBuffer->P)->rate_div_2400 * 2400);
-        fax_feature_bits = READ_WORD(&((T30_INFO   *)plci->NL.RBuffer->P)->feature_bits_low);
+        PUT_WORD(&(plci->ncpi_buffer[1]),((T30_INFO   *)plci->NL.RBuffer->P)->rate_div_2400 * 2400);
+        fax_feature_bits = GET_WORD(&((T30_INFO   *)plci->NL.RBuffer->P)->feature_bits_low);
         i = (((T30_INFO   *)plci->NL.RBuffer->P)->resolution & T30_RESOLUTION_R8_0770_OR_200) ? 0x0001 : 0x0000;
         if (plci->B3_prot == 5)
         {
@@ -6805,8 +6805,8 @@
             i |= 0x0002; /* Fax-polling indication */
         }
         dbug(1,dprintf("FAX Options %04x %04x",fax_feature_bits,i));
-        WRITE_WORD(&(plci->ncpi_buffer[3]),i);
-        WRITE_WORD(&(plci->ncpi_buffer[5]),((T30_INFO   *)plci->NL.RBuffer->P)->data_format);
+        PUT_WORD(&(plci->ncpi_buffer[3]),i);
+        PUT_WORD(&(plci->ncpi_buffer[5]),((T30_INFO   *)plci->NL.RBuffer->P)->data_format);
         plci->ncpi_buffer[7] = ((T30_INFO   *)plci->NL.RBuffer->P)->pages_low;
         plci->ncpi_buffer[8] = ((T30_INFO   *)plci->NL.RBuffer->P)->pages_high;
         plci->ncpi_buffer[len] = 0;
@@ -6833,8 +6833,8 @@
         }
 
         plci->ncpi_buffer[0] = len;
-        fax_feature_bits = READ_WORD(&((T30_INFO   *)plci->NL.RBuffer->P)->feature_bits_low);
-        WRITE_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->feature_bits_low, fax_feature_bits);
+        fax_feature_bits = GET_WORD(&((T30_INFO   *)plci->NL.RBuffer->P)->feature_bits_low);
+        PUT_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->feature_bits_low, fax_feature_bits);
 
         plci->ncpi_state |= NCPI_VALID_CONNECT_B3_IND;
  if (((plci->NL.Ind &0x0f) == N_CONNECT_ACK)
@@ -6902,7 +6902,7 @@
         {
         case EDATA_T30_DIS:
           if ((a->ncci_state[ncci] == OUTG_CON_PENDING)
-           && !(READ_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low) & T30_CONTROL_BIT_REQUEST_POLLING)
+           && !(GET_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low) & T30_CONTROL_BIT_REQUEST_POLLING)
            && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT)
            && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT))
           {
@@ -7063,11 +7063,11 @@
     {
       len = 9;
       i = ((T30_INFO   *)plci->fax_connect_info_buffer)->rate_div_2400 * 2400;
-      WRITE_WORD (&plci->ncpi_buffer[1], i);
-      WRITE_WORD (&plci->ncpi_buffer[3], 0);
+      PUT_WORD (&plci->ncpi_buffer[1], i);
+      PUT_WORD (&plci->ncpi_buffer[3], 0);
       i = ((T30_INFO   *)plci->fax_connect_info_buffer)->data_format;
-      WRITE_WORD (&plci->ncpi_buffer[5], i);
-      WRITE_WORD (&plci->ncpi_buffer[7], 0);
+      PUT_WORD (&plci->ncpi_buffer[5], i);
+      PUT_WORD (&plci->ncpi_buffer[7], 0);
       plci->ncpi_buffer[len] = 0;
       plci->ncpi_buffer[0] = len;
       if(plci->B3_prot == 4)
@@ -7493,7 +7493,7 @@
     plci->B1_resource = add_b1_facilities (plci, 9, (word)(b1_facilities | B1_FACILITY_VOICE));
     adjust_b1_facilities (plci, plci->B1_resource, (word)(b1_facilities | B1_FACILITY_VOICE));
     voice_cai[1] = plci->B1_resource;
-    WRITE_WORD (&voice_cai[5], plci->appl->MaxDataLength);
+    PUT_WORD (&voice_cai[5], plci->appl->MaxDataLength);
     add_p(plci, CAI, voice_cai);
     dbug(1,dprintf("Cai=1,0x%x (AdvVoice)",voice_cai[1]));
     return 0;
@@ -7534,7 +7534,7 @@
     {
       return _WRONG_MESSAGE_FORMAT;
     }
-    switch(READ_WORD(global_config[0].info))
+    switch(GET_WORD(global_config[0].info))
     {
     case 1:
       plci->call_dir = (plci->call_dir & ~CALL_DIR_ANSWER) | CALL_DIR_ORIGINATE;
@@ -7547,7 +7547,7 @@
   dbug(1,dprintf("call_dir=%04x", plci->call_dir));
 
 
-  if ((READ_WORD(bp_parms[0].info) == B1_RTP)
+  if ((GET_WORD(bp_parms[0].info) == B1_RTP)
    && (plci->adapter->man_profile.private_options & (1L << PRIVATE_RTP)))
   {
     plci->B1_resource = add_b1_facilities (plci, 31, (word)(b1_facilities & ~B1_FACILITY_VOICE));
@@ -7556,7 +7556,7 @@
     cai[2] = 0;
     cai[3] = 0;
     cai[4] = 0;
-    WRITE_WORD(&cai[5],plci->appl->MaxDataLength);
+    PUT_WORD(&cai[5],plci->appl->MaxDataLength);
     for (i = 0; i < bp_parms[3].length; i++)
       cai[7+i] = bp_parms[3].info[1+i];
     cai[0] = 6 + bp_parms[3].length;
@@ -7565,7 +7565,7 @@
   }
 
 
-  if ((READ_WORD(bp_parms[0].info) == B1_PIAFS)
+  if ((GET_WORD(bp_parms[0].info) == B1_PIAFS)
    && (plci->adapter->man_profile.private_options & (1L << PRIVATE_PIAFS)))
   {
     plci->B1_resource = add_b1_facilities (plci, 35/* PIAFS HARDWARE FACILITY */, (word)(b1_facilities & ~B1_FACILITY_VOICE));
@@ -7574,31 +7574,31 @@
     cai[2] = 0;
     cai[3] = 0;
     cai[4] = 0;
-    WRITE_WORD(&cai[5],plci->appl->MaxDataLength);
+    PUT_WORD(&cai[5],plci->appl->MaxDataLength);
     cai[0] = 6;
     add_p(plci, CAI, cai);
     return 0;
   }
 
 
-  if ((READ_WORD(bp_parms[0].info) >= 32)
-   || (!((1L << READ_WORD(bp_parms[0].info)) & plci->adapter->profile.B1_Protocols)
-    && ((READ_WORD(bp_parms[0].info) != 3)
+  if ((GET_WORD(bp_parms[0].info) >= 32)
+   || (!((1L << GET_WORD(bp_parms[0].info)) & plci->adapter->profile.B1_Protocols)
+    && ((GET_WORD(bp_parms[0].info) != 3)
      || !((1L << B1_HDLC) & plci->adapter->profile.B1_Protocols)
-     || ((bp_parms[3].length != 0) && (READ_WORD(&bp_parms[3].info[1]) != 0) && (READ_WORD(&bp_parms[3].info[1]) != 56000)))))
+     || ((bp_parms[3].length != 0) && (GET_WORD(&bp_parms[3].info[1]) != 0) && (GET_WORD(&bp_parms[3].info[1]) != 56000)))))
   {
     return _B1_NOT_SUPPORTED;
   }
-  plci->B1_resource = add_b1_facilities (plci, resource[READ_WORD(bp_parms[0].info)],
+  plci->B1_resource = add_b1_facilities (plci, resource[GET_WORD(bp_parms[0].info)],
     (word)(b1_facilities & ~B1_FACILITY_VOICE));
   adjust_b1_facilities (plci, plci->B1_resource, (word)(b1_facilities & ~B1_FACILITY_VOICE));
   cai[0] = 6;
   cai[1] = plci->B1_resource;
   for (i=2;i<sizeof(cai);i++) cai[i] = 0;
 
-  if ((READ_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE)
-   || (READ_WORD(bp_parms[0].info) == B1_MODEM_ASYNC)
-   || (READ_WORD(bp_parms[0].info) == B1_MODEM_SYNC_HDLC))
+  if ((GET_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE)
+   || (GET_WORD(bp_parms[0].info) == B1_MODEM_ASYNC)
+   || (GET_WORD(bp_parms[0].info) == B1_MODEM_SYNC_HDLC))
   { /* B1 - modem */
     for (i=0;i<7;i++) mdm_cfg[i].length = 0;
 
@@ -7611,15 +7611,15 @@
         
       cai[2] = 0; /* Bit rate for adaptation */
 
-      dbug(1,dprintf("MDM Max Bit Rate:<%d>", READ_WORD(mdm_cfg[0].info)));
+      dbug(1,dprintf("MDM Max Bit Rate:<%d>", GET_WORD(mdm_cfg[0].info)));
 
-      WRITE_WORD (&cai[13], 0);                          /* Min Tx speed */
-      WRITE_WORD (&cai[15], READ_WORD(mdm_cfg[0].info)); /* Max Tx speed */
-      WRITE_WORD (&cai[17], 0);                          /* Min Rx speed */
-      WRITE_WORD (&cai[19], READ_WORD(mdm_cfg[0].info)); /* Max Rx speed */
+      PUT_WORD (&cai[13], 0);                          /* Min Tx speed */
+      PUT_WORD (&cai[15], GET_WORD(mdm_cfg[0].info)); /* Max Tx speed */
+      PUT_WORD (&cai[17], 0);                          /* Min Rx speed */
+      PUT_WORD (&cai[19], GET_WORD(mdm_cfg[0].info)); /* Max Rx speed */
 
       cai[3] = 0; /* Async framing parameters */
-      switch (READ_WORD (mdm_cfg[2].info))
+      switch (GET_WORD (mdm_cfg[2].info))
       {       /* Parity     */
       case 1: /* odd parity */
         cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_ODD);
@@ -7636,7 +7636,7 @@
         break;
       }
 
-      switch (READ_WORD (mdm_cfg[3].info))
+      switch (GET_WORD (mdm_cfg[3].info))
       {       /* stop bits   */
       case 1: /* 2 stop bits */
         cai[3] |= DSP_CAI_ASYNC_TWO_STOP_BITS;
@@ -7648,7 +7648,7 @@
         break;
       }
 
-      switch (READ_WORD (mdm_cfg[1].info))
+      switch (GET_WORD (mdm_cfg[1].info))
       {     /* char length */
       case 5:
         cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_5;
@@ -7680,40 +7680,40 @@
         dbug(1, dprintf("MDM: Reverse direction"));
       }
 
-      if (READ_WORD (mdm_cfg[4].info) & MDM_CAPI_DISABLE_RETRAIN)
+      if (GET_WORD (mdm_cfg[4].info) & MDM_CAPI_DISABLE_RETRAIN)
       {
         cai[9] |= DSP_CAI_MODEM_DISABLE_RETRAIN;
         dbug(1, dprintf("MDM: Disable retrain"));
       }
 
-      if (READ_WORD (mdm_cfg[4].info) & MDM_CAPI_DISABLE_RING_TONE)
+      if (GET_WORD (mdm_cfg[4].info) & MDM_CAPI_DISABLE_RING_TONE)
       {
         cai[7] |= DSP_CAI_MODEM_DISABLE_CALLING_TONE | DSP_CAI_MODEM_DISABLE_ANSWER_TONE;
         dbug(1, dprintf("MDM: Disable ring tone"));
       }
 
-      if (READ_WORD (mdm_cfg[4].info) & MDM_CAPI_GUARD_1800)
+      if (GET_WORD (mdm_cfg[4].info) & MDM_CAPI_GUARD_1800)
       {
         cai[8] |= DSP_CAI_MODEM_GUARD_TONE_1800HZ;
         dbug(1, dprintf("MDM: 1800 guard tone"));
       }
-      else if (READ_WORD (mdm_cfg[4].info) & MDM_CAPI_GUARD_550 )
+      else if (GET_WORD (mdm_cfg[4].info) & MDM_CAPI_GUARD_550 )
       {
         cai[8] |= DSP_CAI_MODEM_GUARD_TONE_550HZ;
         dbug(1, dprintf("MDM: 550 guard tone"));
       }
 
-      if ((READ_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_V100)
+      if ((GET_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_V100)
       {
         cai[8] |= DSP_CAI_MODEM_NEGOTIATE_V100;
         dbug(1, dprintf("MDM: V100"));
       }
-      else if ((READ_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_MOD_CLASS)
+      else if ((GET_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_MOD_CLASS)
       {
         cai[8] |= DSP_CAI_MODEM_NEGOTIATE_IN_CLASS;
         dbug(1, dprintf("MDM: IN CLASS"));
       }
-      else if ((READ_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_DISABLED)
+      else if ((GET_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_DISABLED)
       {
         cai[8] |= DSP_CAI_MODEM_NEGOTIATE_DISABLED;
         dbug(1, dprintf("MDM: DISABLED"));
@@ -7721,11 +7721,11 @@
       cai[0] = 20;
 
       if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_V18))
-       && (READ_WORD(mdm_cfg[5].info) & 0x8000)) /* Private V.18 enable */
+       && (GET_WORD(mdm_cfg[5].info) & 0x8000)) /* Private V.18 enable */
       {
         plci->requested_options |= 1L << PRIVATE_V18;
       }
-      if (READ_WORD(mdm_cfg[5].info) & 0x4000) /* Private VOWN enable */
+      if (GET_WORD(mdm_cfg[5].info) & 0x4000) /* Private VOWN enable */
         plci->requested_options |= 1L << PRIVATE_VOWN;
 
       if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id-1])
@@ -7736,19 +7736,19 @@
           i = 27;
           if (mdm_cfg[6].length >= 4)
           {
-            d = READ_DWORD(&mdm_cfg[6].info[1]);
+            d = GET_DWORD(&mdm_cfg[6].info[1]);
             cai[7] |= (byte) d;          /* line taking options */
             cai[9] |= (byte)(d >> 8);    /* modulation options */
             cai[++i] = (byte)(d >> 16);  /* vown modulation options */
             cai[++i] = (byte)(d >> 24);
             if (mdm_cfg[6].length >= 8)
             {
-              d = READ_DWORD(&mdm_cfg[6].info[5]);
+              d = GET_DWORD(&mdm_cfg[6].info[5]);
               cai[10] |= (byte) d;        /* disabled modulations mask */
               cai[11] |= (byte)(d >> 8);
               if (mdm_cfg[6].length >= 12)
               {
-                d = READ_DWORD(&mdm_cfg[6].info[9]);
+                d = GET_DWORD(&mdm_cfg[6].info[9]);
                 cai[12] = (byte) d;          /* enabled modulations mask */
                 cai[++i] = (byte)(d >> 8);   /* vown enabled modulations */
                 cai[++i] = (byte)(d >> 16);
@@ -7756,31 +7756,31 @@
                 cai[++i] = 0;
                 if (mdm_cfg[6].length >= 14)
                 {
-                  w = READ_WORD(&mdm_cfg[6].info[13]);
+                  w = GET_WORD(&mdm_cfg[6].info[13]);
                   if (w != 0)
-                    WRITE_WORD(&cai[13], w);  /* min tx speed */
+                    PUT_WORD(&cai[13], w);  /* min tx speed */
                   if (mdm_cfg[6].length >= 16)
                   {
-                    w = READ_WORD(&mdm_cfg[6].info[15]);
+                    w = GET_WORD(&mdm_cfg[6].info[15]);
                     if (w != 0)
-                      WRITE_WORD(&cai[15], w);  /* max tx speed */
+                      PUT_WORD(&cai[15], w);  /* max tx speed */
                     if (mdm_cfg[6].length >= 18)
                     {
-                      w = READ_WORD(&mdm_cfg[6].info[17]);
+                      w = GET_WORD(&mdm_cfg[6].info[17]);
                       if (w != 0)
-                        WRITE_WORD(&cai[17], w);  /* min rx speed */
+                        PUT_WORD(&cai[17], w);  /* min rx speed */
                       if (mdm_cfg[6].length >= 20)
                       {
-                        w = READ_WORD(&mdm_cfg[6].info[19]);
+                        w = GET_WORD(&mdm_cfg[6].info[19]);
                         if (w != 0)
-                          WRITE_WORD(&cai[19], w);  /* max rx speed */
+                          PUT_WORD(&cai[19], w);  /* max rx speed */
                         if (mdm_cfg[6].length >= 22)
                         {
-                          w = READ_WORD(&mdm_cfg[6].info[21]);
+                          w = GET_WORD(&mdm_cfg[6].info[21]);
                           cai[23] = (byte)(-((short) w));  /* transmit level */
                           if (mdm_cfg[6].length >= 24)
                           {
-                            w = READ_WORD(&mdm_cfg[6].info[23]);
+                            w = GET_WORD(&mdm_cfg[6].info[23]);
                             cai[22] |= (byte) w;        /* info options mask */
                             cai[21] |= (byte)(w >> 8);  /* disabled symbol rates */
                           }
@@ -7813,21 +7813,21 @@
 
     }
   }
-  if(READ_WORD(bp_parms[0].info)==2 ||                         /* V.110 async */
-     READ_WORD(bp_parms[0].info)==3 )                          /* V.110 sync */
+  if(GET_WORD(bp_parms[0].info)==2 ||                         /* V.110 async */
+     GET_WORD(bp_parms[0].info)==3 )                          /* V.110 sync */
   {
     if(bp_parms[3].length){
-      dbug(1,dprintf("V.110,%d",READ_WORD(&bp_parms[3].info[1])));
-      switch(READ_WORD(&bp_parms[3].info[1])){                 /* Rate */
+      dbug(1,dprintf("V.110,%d",GET_WORD(&bp_parms[3].info[1])));
+      switch(GET_WORD(&bp_parms[3].info[1])){                 /* Rate */
         case 0:
         case 56000:
-          if(READ_WORD(bp_parms[0].info)==3){                  /* V.110 sync 56k */
+          if(GET_WORD(bp_parms[0].info)==3){                  /* V.110 sync 56k */
             dbug(1,dprintf("56k sync HSCX"));
             cai[1] = 8;
             cai[2] = 0;
             cai[3] = 0;
           }
-          else if(READ_WORD(bp_parms[0].info)==2){
+          else if(GET_WORD(bp_parms[0].info)==2){
             dbug(1,dprintf("56k async DSP"));
             cai[2] = 9;
           }
@@ -7863,7 +7863,7 @@
       {
         if (bp_parms[3].length >= 8)
         {
-          switch (READ_WORD (&bp_parms[3].info[3]))
+          switch (GET_WORD (&bp_parms[3].info[3]))
           {       /* char length */
           case 5:
             cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_5;
@@ -7875,7 +7875,7 @@
             cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_7;
             break;
           }
-          switch (READ_WORD (&bp_parms[3].info[5]))
+          switch (GET_WORD (&bp_parms[3].info[5]))
           {       /* Parity     */
           case 1: /* odd parity */
             cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_ODD);
@@ -7884,7 +7884,7 @@
             cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_EVEN);
             break;
           }
-          switch (READ_WORD (&bp_parms[3].info[7]))
+          switch (GET_WORD (&bp_parms[3].info[7]))
           {       /* stop bits   */
           case 1: /* 2 stop bits */
             cai[3] |= DSP_CAI_ASYNC_TWO_STOP_BITS;
@@ -7893,7 +7893,7 @@
         }
       }
     }
-    else if(cai[1]==8 || READ_WORD(bp_parms[0].info)==3 ){
+    else if(cai[1]==8 || GET_WORD(bp_parms[0].info)==3 ){
       dbug(1,dprintf("V.110 default 56k sync"));
       cai[1] = 8;
       cai[2] = 0;
@@ -7904,7 +7904,7 @@
       cai[2] = 5;
     }
   }
-  WRITE_WORD(&cai[5],plci->appl->MaxDataLength);
+  PUT_WORD(&cai[5],plci->appl->MaxDataLength);
   dbug(1,dprintf("CAI[%d]=%x,%x,%x,%x,%x,%x", cai[0], cai[1], cai[2], cai[3], cai[4], cai[5], cai[6]));
 /* HexDump ("CAI", sizeof(cai), &cai[0]); */
 
@@ -7987,7 +7987,7 @@
     llc[2] = 4;
     add_p(plci, LLC, llc);
     dlc[0] = 2;
-    WRITE_WORD(&dlc[1],plci->appl->MaxDataLength);
+    PUT_WORD(&dlc[1],plci->appl->MaxDataLength);
     add_p(plci, DLC, dlc);
     return 0;
   }
@@ -8002,7 +8002,7 @@
     llc[2] = 4;
     add_p(plci, LLC, llc);
     dlc[0] = 2;
-    WRITE_WORD(&dlc[1],plci->appl->MaxDataLength);
+    PUT_WORD(&dlc[1],plci->appl->MaxDataLength);
     add_p(plci, DLC, dlc);
     return 0;
   }
@@ -8026,25 +8026,25 @@
 
   if(plci->tel==ADV_VOICE) /* transparent B on advanced voice */
   {  
-    if(READ_WORD(bp_parms[1].info)!=1
-    || READ_WORD(bp_parms[2].info)!=0) return _B2_NOT_SUPPORTED;
+    if(GET_WORD(bp_parms[1].info)!=1
+    || GET_WORD(bp_parms[2].info)!=0) return _B2_NOT_SUPPORTED;
     plci->adv_nl = TRUE;
   }
   else if(plci->tel) return _B2_NOT_SUPPORTED;
 
 
-  if ((READ_WORD(bp_parms[1].info) == B2_RTP)
-   && (READ_WORD(bp_parms[2].info) == B3_RTP)
+  if ((GET_WORD(bp_parms[1].info) == B2_RTP)
+   && (GET_WORD(bp_parms[2].info) == B3_RTP)
    && (plci->adapter->man_profile.private_options & (1L << PRIVATE_RTP)))
   {
     add_p(plci,LLI,lli);
-    plci->B2_prot = (byte) READ_WORD(bp_parms[1].info);
-    plci->B3_prot = (byte) READ_WORD(bp_parms[2].info);
+    plci->B2_prot = (byte) GET_WORD(bp_parms[1].info);
+    plci->B3_prot = (byte) GET_WORD(bp_parms[2].info);
     llc[1] = (plci->call_dir & (CALL_DIR_ORIGINATE | CALL_DIR_FORCE_OUTG_NL)) ? 14 : 13;
     llc[2] = 4;
     add_p(plci, LLC, llc);
     dlc[0] = 2;
-    WRITE_WORD(&dlc[1],plci->appl->MaxDataLength);
+    PUT_WORD(&dlc[1],plci->appl->MaxDataLength);
     dlc[3] = 3; /* Addr A */
     dlc[4] = 1; /* Addr B */
     dlc[5] = 7; /* modulo mode */
@@ -8064,31 +8064,31 @@
 
 
 
-  if ((READ_WORD(bp_parms[1].info) >= 32)
-   || (!((1L << READ_WORD(bp_parms[1].info)) & plci->adapter->profile.B2_Protocols)
-    && ((READ_WORD(bp_parms[1].info) != B2_PIAFS)
+  if ((GET_WORD(bp_parms[1].info) >= 32)
+   || (!((1L << GET_WORD(bp_parms[1].info)) & plci->adapter->profile.B2_Protocols)
+    && ((GET_WORD(bp_parms[1].info) != B2_PIAFS)
      || !(plci->adapter->man_profile.private_options & (1L << PRIVATE_PIAFS)))))
 
   {
     return _B2_NOT_SUPPORTED;
   }
-  if ((READ_WORD(bp_parms[2].info) >= 32)
-   || !((1L << READ_WORD(bp_parms[2].info)) & plci->adapter->profile.B3_Protocols))
+  if ((GET_WORD(bp_parms[2].info) >= 32)
+   || !((1L << GET_WORD(bp_parms[2].info)) & plci->adapter->profile.B3_Protocols))
   {
     return _B3_NOT_SUPPORTED;
   }
-  if ((READ_WORD(bp_parms[1].info) != B2_SDLC)
-   && ((READ_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE)
-    || (READ_WORD(bp_parms[0].info) == B1_MODEM_ASYNC)
-    || (READ_WORD(bp_parms[0].info) == B1_MODEM_SYNC_HDLC)))
+  if ((GET_WORD(bp_parms[1].info) != B2_SDLC)
+   && ((GET_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE)
+    || (GET_WORD(bp_parms[0].info) == B1_MODEM_ASYNC)
+    || (GET_WORD(bp_parms[0].info) == B1_MODEM_SYNC_HDLC)))
   {
     return (add_modem_b23 (plci, bp_parms));
   }
 
   add_p(plci,LLI,lli);
 
-  plci->B2_prot = (byte) READ_WORD(bp_parms[1].info);
-  plci->B3_prot = (byte) READ_WORD(bp_parms[2].info);
+  plci->B2_prot = (byte) GET_WORD(bp_parms[1].info);
+  plci->B3_prot = (byte) GET_WORD(bp_parms[2].info);
   if(plci->B2_prot==12) SAPI = 0; /* default SAPI D-channel */
 
   if(bp_parms[6].length)
@@ -8097,7 +8097,7 @@
     {
       return _WRONG_MESSAGE_FORMAT;
     }
-    switch(READ_WORD(global_config[0].info))
+    switch(GET_WORD(global_config[0].info))
     {
     case 1:
       plci->call_dir = (plci->call_dir & ~CALL_DIR_ANSWER) | CALL_DIR_ORIGINATE;
@@ -8116,15 +8116,15 @@
 /* IMPLEMENT_PIAFS */
   {
     llc[1] = (plci->call_dir & (CALL_DIR_ORIGINATE | CALL_DIR_FORCE_OUTG_NL)) ?
-             llc2_out[READ_WORD(bp_parms[1].info)] : llc2_in[READ_WORD(bp_parms[1].info)];
+             llc2_out[GET_WORD(bp_parms[1].info)] : llc2_in[GET_WORD(bp_parms[1].info)];
   }
-  llc[2] = llc3[READ_WORD(bp_parms[2].info)];
+  llc[2] = llc3[GET_WORD(bp_parms[2].info)];
 
   add_p(plci, LLC, llc);
 
   dlc[0] = 2;
-  WRITE_WORD(&dlc[1], plci->appl->MaxDataLength +
-                      header[READ_WORD(bp_parms[2].info)]);
+  PUT_WORD(&dlc[1], plci->appl->MaxDataLength +
+                      header[GET_WORD(bp_parms[2].info)]);
 
   b1_config = &bp_parms[3];
   nlc[0] = 0;
@@ -8138,7 +8138,7 @@
     ((T30_INFO *)&nlc[1])->rate_div_2400 = 0xff;
     if(b1_config->length>=2)
     {
-      ((T30_INFO *)&nlc[1])->rate_div_2400 = (byte)(READ_WORD(&b1_config->info[1])/2400);
+      ((T30_INFO *)&nlc[1])->rate_div_2400 = (byte)(GET_WORD(&b1_config->info[1])/2400);
     }
   }
   b2_config = &bp_parms[4];
@@ -8153,7 +8153,7 @@
     if(b2_config->length && api_parse(&b2_config->info[1], (word)b2_config->length, "bwww", b2_config_parms)) {
       return _WRONG_MESSAGE_FORMAT;
     }
-    WRITE_WORD(&dlc[1],plci->appl->MaxDataLength);
+    PUT_WORD(&dlc[1],plci->appl->MaxDataLength);
     dlc[3] = 0; /* Addr A */
     dlc[4] = 0; /* Addr B */
     dlc[5] = 0; /* modulo mode */
@@ -8200,7 +8200,7 @@
       return _B_STACK_NOT_SUPPORTED;
 
     dlc[0] = 6;
-    WRITE_WORD (&dlc[1], READ_WORD (&dlc[1]) + 2);
+    PUT_WORD (&dlc[1], GET_WORD (&dlc[1]) + 2);
     dlc[3] = 0x08;
     dlc[4] = 0x01;
     dlc[5] = 127;
@@ -8320,7 +8320,7 @@
 
         }
         else {
-          WRITE_WORD(&dlc[7], (word)b2_config_parms[4].length);
+          PUT_WORD(&dlc[7], (word)b2_config_parms[4].length);
           for(i=0; i<b2_config_parms[4].length; i++)
             dlc[11+i] = b2_config_parms[4].info[1+i];
         }
@@ -8339,10 +8339,10 @@
       {
         return _WRONG_MESSAGE_FORMAT;
       }
-      i = READ_WORD((byte   *)(b3_config_parms[0].info));
+      i = GET_WORD((byte   *)(b3_config_parms[0].info));
       ((T30_INFO *)&nlc[1])->resolution = (byte)(((i & 0x0001) ||
-        ((plci->B3_prot == 4) && (((byte)(READ_WORD((byte   *)b3_config_parms[1].info))) != 5))) ? T30_RESOLUTION_R8_0770_OR_200 : 0);
-      ((T30_INFO *)&nlc[1])->data_format = (byte)(READ_WORD((byte   *)b3_config_parms[1].info));
+        ((plci->B3_prot == 4) && (((byte)(GET_WORD((byte   *)b3_config_parms[1].info))) != 5))) ? T30_RESOLUTION_R8_0770_OR_200 : 0);
+      ((T30_INFO *)&nlc[1])->data_format = (byte)(GET_WORD((byte   *)b3_config_parms[1].info));
       fax_control_bits = T30_CONTROL_BIT_ALL_FEATURES;
       if ((((T30_INFO *)&nlc[1])->rate_div_2400 != 0) && (((T30_INFO *)&nlc[1])->rate_div_2400 <= 6))
         fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_V34FAX;
@@ -8377,7 +8377,7 @@
           ((T30_INFO *)&nlc[1])->resolution = ((T30_INFO   *)plci->fax_connect_info_buffer)->resolution;
           ((T30_INFO *)&nlc[1])->data_format = ((T30_INFO   *)plci->fax_connect_info_buffer)->data_format;
           ((T30_INFO *)&nlc[1])->recording_properties = ((T30_INFO   *)plci->fax_connect_info_buffer)->recording_properties;
-          fax_control_bits |= READ_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low) &
+          fax_control_bits |= GET_WORD(&((T30_INFO   *)plci->fax_connect_info_buffer)->control_bits_low) &
             (T30_CONTROL_BIT_REQUEST_POLLING | T30_CONTROL_BIT_MORE_DOCUMENTS);
         }
       }
@@ -8435,12 +8435,12 @@
       if(plci->B3_prot == 5)
       {
         if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_FAX_SUB_SEP_PWD))
-         && (READ_WORD((byte   *)b3_config_parms[1].info) & 0x8000)) /* Private SUB/SEP/PWD enable */
+         && (GET_WORD((byte   *)b3_config_parms[1].info) & 0x8000)) /* Private SUB/SEP/PWD enable */
         {
           plci->requested_options |= 1L << PRIVATE_FAX_SUB_SEP_PWD;
         }
         if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_FAX_NONSTANDARD))
-         && (READ_WORD((byte   *)b3_config_parms[1].info) & 0x4000)) /* Private non-standard facilities enable */
+         && (GET_WORD((byte   *)b3_config_parms[1].info) & 0x4000)) /* Private non-standard facilities enable */
         {
           plci->requested_options |= 1L << PRIVATE_FAX_NONSTANDARD;
         }
@@ -8476,7 +8476,7 @@
      if ((pos < plci->fax_connect_info_length) && (plci->fax_connect_info_buffer[pos] != 0))
      {
               if ((plci->fax_connect_info_buffer[pos] >= 3) && (plci->fax_connect_info_buffer[pos+1] >= 2))
-                plci->nsf_control_bits = READ_WORD(&plci->fax_connect_info_buffer[pos+2]);
+                plci->nsf_control_bits = GET_WORD(&plci->fax_connect_info_buffer[pos+2]);
        for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--)
                 nlc[++len] = plci->fax_connect_info_buffer[pos++];
             }
@@ -8490,7 +8490,7 @@
        else
        {
                 if ((b3_config_parms[4].length >= 3) && (b3_config_parms[4].info[1] >= 2))
-                  plci->nsf_control_bits = READ_WORD(&b3_config_parms[4].info[2]);
+                  plci->nsf_control_bits = GET_WORD(&b3_config_parms[4].info[2]);
          nlc[++len] = (byte)(b3_config_parms[4].length);
          for (i = 0; i < b3_config_parms[4].length; i++)
     nlc[++len] = b3_config_parms[4].info[1+i];
@@ -8506,7 +8506,7 @@
         }
       }
 
-      WRITE_WORD(&(((T30_INFO *)&nlc[1])->control_bits_low), fax_control_bits);
+      PUT_WORD(&(((T30_INFO *)&nlc[1])->control_bits_low), fax_control_bits);
       len = ((byte)(((T30_INFO *) 0)->station_id + 20));
       for (i = 0; i < len; i++)
         plci->fax_connect_info_buffer[i] = nlc[1+i];
@@ -8522,10 +8522,10 @@
       if(b3_config->length!=16)
         return _B3_PARM_NOT_SUPPORTED;
       for(i=0; i<12; i++) nlc[1+i] = b3_config->info[1+i];
-      if(READ_WORD(&b3_config->info[13])!=8 && READ_WORD(&b3_config->info[13])!=128)
+      if(GET_WORD(&b3_config->info[13])!=8 && GET_WORD(&b3_config->info[13])!=128)
         return _B3_PARM_NOT_SUPPORTED;
       nlc[13] = b3_config->info[13];
-      if(READ_WORD(&b3_config->info[15])>=nlc[13])
+      if(GET_WORD(&b3_config->info[15])>=nlc[13])
         return _B3_PARM_NOT_SUPPORTED;
       nlc[14] = b3_config->info[15];
     }
@@ -8566,23 +8566,23 @@
   for(i=0;i<2;i++) mdm_config[i].length = 0;
   for(i=0;i<sizeof(dlc);i++) dlc[i] = 0;
 
-  if (((READ_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE)
-    && (READ_WORD(bp_parms[1].info) != B2_MODEM_EC_COMPRESSION))
-   || ((READ_WORD(bp_parms[0].info) != B1_MODEM_ALL_NEGOTIATE)
-    && (READ_WORD(bp_parms[1].info) != B2_TRANSPARENT)))
+  if (((GET_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE)
+    && (GET_WORD(bp_parms[1].info) != B2_MODEM_EC_COMPRESSION))
+   || ((GET_WORD(bp_parms[0].info) != B1_MODEM_ALL_NEGOTIATE)
+    && (GET_WORD(bp_parms[1].info) != B2_TRANSPARENT)))
   {
     return (_B_STACK_NOT_SUPPORTED);
   }
-  if ((READ_WORD(bp_parms[2].info) != B3_MODEM)
-   && (READ_WORD(bp_parms[2].info) != B3_TRANSPARENT))
+  if ((GET_WORD(bp_parms[2].info) != B3_MODEM)
+   && (GET_WORD(bp_parms[2].info) != B3_TRANSPARENT))
   {
     return (_B_STACK_NOT_SUPPORTED);
   }
 
-  plci->B2_prot = (byte) READ_WORD(bp_parms[1].info);
-  plci->B3_prot = (byte) READ_WORD(bp_parms[2].info);
+  plci->B2_prot = (byte) GET_WORD(bp_parms[1].info);
+  plci->B3_prot = (byte) GET_WORD(bp_parms[2].info);
 
-  if ((READ_WORD(bp_parms[1].info) == B2_MODEM_EC_COMPRESSION) && bp_parms[4].length)
+  if ((GET_WORD(bp_parms[1].info) == B2_MODEM_EC_COMPRESSION) && bp_parms[4].length)
   {
     if (api_parse (&bp_parms[4].info[1],
                   (word)bp_parms[4].length, "w",
@@ -8590,7 +8590,7 @@
     {
       return (_WRONG_MESSAGE_FORMAT);
     }
-    b2_config = READ_WORD(mdm_config[0].info);
+    b2_config = GET_WORD(mdm_config[0].info);
   }
 
   /* OK, L2 is modem */
@@ -8630,9 +8630,9 @@
   add_p(plci, LLI, lli);
   add_p(plci, LLC, llc);
   i =  1;
-  WRITE_WORD (&dlc[i], plci->appl->MaxDataLength);
+  PUT_WORD (&dlc[i], plci->appl->MaxDataLength);
   i += 2;
-  if (READ_WORD(bp_parms[1].info) == B2_MODEM_EC_COMPRESSION)
+  if (GET_WORD(bp_parms[1].info) == B2_MODEM_EC_COMPRESSION)
   {
     if (bp_parms[4].length)
   {
@@ -8702,7 +8702,7 @@
     plci->req_in +=2;
     plci->RBuffer[plci->req_in++] = 0;
   }
-  WRITE_WORD(&plci->RBuffer[plci->req_in_start], plci->req_in-plci->req_in_start-2);
+  PUT_WORD(&plci->RBuffer[plci->req_in_start], plci->req_in-plci->req_in_start-2);
   plci->RBuffer[plci->req_in++] = Id;   /* sig/nl flag */
   plci->RBuffer[plci->req_in++] = req;  /* request */
   plci->RBuffer[plci->req_in++] = 0;    /* channel */
@@ -8728,7 +8728,7 @@
     plci->req_in +=2;
     plci->RBuffer[plci->req_in++] = 0;
   }
-  WRITE_WORD(&plci->RBuffer[plci->req_in_start], plci->req_in-plci->req_in_start-2);
+  PUT_WORD(&plci->RBuffer[plci->req_in_start], plci->req_in-plci->req_in_start-2);
   plci->RBuffer[plci->req_in++] = 1;    /* sig/nl flag */
   plci->RBuffer[plci->req_in++] = req;  /* request */
   plci->RBuffer[plci->req_in++] = plci->adapter->ncci_ch[ncci];   /* channel */
@@ -8751,7 +8751,7 @@
 
   if(plci->nl_req || plci->sig_req) return;
 
-  l = READ_WORD(&plci->RBuffer[plci->req_out]);
+  l = GET_WORD(&plci->RBuffer[plci->req_out]);
   plci->req_out += 2;
   plci->XData[0].P = &plci->RBuffer[plci->req_out];
   plci->req_out += l;
@@ -9586,11 +9586,11 @@
     min_digit_duration = (plci->dtmf_rec_pulse_ms == 0) ? 40 : plci->dtmf_rec_pulse_ms;
     min_gap_duration = (plci->dtmf_rec_pause_ms == 0) ? 40 : plci->dtmf_rec_pause_ms;
     plci->internal_req_buffer[0] = DTMF_UDATA_REQUEST_ENABLE_RECEIVER;
-    WRITE_WORD (&plci->internal_req_buffer[1], min_digit_duration);
-    WRITE_WORD (&plci->internal_req_buffer[3], min_gap_duration);
+    PUT_WORD (&plci->internal_req_buffer[1], min_digit_duration);
+    PUT_WORD (&plci->internal_req_buffer[3], min_gap_duration);
     plci->NData[0].PLength = 5;
 
-    WRITE_WORD (&plci->internal_req_buffer[5], INTERNAL_IND_BUFFER_SIZE);
+    PUT_WORD (&plci->internal_req_buffer[5], INTERNAL_IND_BUFFER_SIZE);
     plci->NData[0].PLength += 2;
     capidtmf_recv_enable (&(plci->capidtmf_state), min_digit_duration, min_gap_duration);
 
@@ -9621,9 +9621,9 @@
 
   plci->internal_req_buffer[0] = DTMF_UDATA_REQUEST_SEND_DIGITS;
   w = (plci->dtmf_send_pulse_ms == 0) ? 40 : plci->dtmf_send_pulse_ms;
-  WRITE_WORD (&plci->internal_req_buffer[1], w);
+  PUT_WORD (&plci->internal_req_buffer[1], w);
   w = (plci->dtmf_send_pause_ms == 0) ? 40 : plci->dtmf_send_pause_ms;
-  WRITE_WORD (&plci->internal_req_buffer[3], w);
+  PUT_WORD (&plci->internal_req_buffer[3], w);
   for (i = 0; i < digit_count; i++)
   {
     w = 0;
@@ -9744,7 +9744,7 @@
 
   Info = GOOD;
   result[0] = 2;
-  WRITE_WORD (&result[1], DTMF_SUCCESS);
+  PUT_WORD (&result[1], DTMF_SUCCESS);
   internal_command = plci->internal_command;
   plci->internal_command = 0;
   mask = 0x01;
@@ -9915,7 +9915,7 @@
 
   Info = GOOD;
   result[0] = 2;
-  WRITE_WORD (&result[1], DTMF_SUCCESS);
+  PUT_WORD (&result[1], DTMF_SUCCESS);
   if (!(a->profile.Global_Options & GL_DTMF_SUPPORTED))
   {
     dbug (1, dprintf ("[%06lx] %s,%d: Facility not supported",
@@ -9929,21 +9929,21 @@
     Info = _WRONG_MESSAGE_FORMAT;
   }
 
-  else if ((READ_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_DETECT_CODES)
-    || (READ_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_SEND_CODES))
+  else if ((GET_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_DETECT_CODES)
+    || (GET_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_SEND_CODES))
   {
     if (!((a->requested_options_table[appl->Id-1])
         & (1L << PRIVATE_DTMF_TONE)))
     {
       dbug (1, dprintf ("[%06lx] %s,%d: DTMF unknown request %04x",
-        UnMapId (Id), (char   *)(FILE_), __LINE__, READ_WORD (dtmf_parms[0].info)));
-      WRITE_WORD (&result[1], DTMF_UNKNOWN_REQUEST);
+        UnMapId (Id), (char   *)(FILE_), __LINE__, GET_WORD (dtmf_parms[0].info)));
+      PUT_WORD (&result[1], DTMF_UNKNOWN_REQUEST);
     }
     else
     {
       for (i = 0; i < 32; i++)
         result[4 + i] = 0;
-      if (READ_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_DETECT_CODES)
+      if (GET_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_DETECT_CODES)
       {
         for (i = 0; i < DTMF_DIGIT_MAP_ENTRIES; i++)
         {
@@ -9982,7 +9982,7 @@
     else
     {
       plci->command = 0;
-      plci->dtmf_cmd = READ_WORD (dtmf_parms[0].info);
+      plci->dtmf_cmd = GET_WORD (dtmf_parms[0].info);
       mask = 0x01;
       switch (plci->dtmf_cmd)
       {
@@ -9997,8 +9997,8 @@
           & (1L << PRIVATE_DTMF_TONE)))
         {
           dbug (1, dprintf ("[%06lx] %s,%d: DTMF unknown request %04x",
-            UnMapId (Id), (char   *)(FILE_), __LINE__, READ_WORD (dtmf_parms[0].info)));
-          WRITE_WORD (&result[1], DTMF_UNKNOWN_REQUEST);
+            UnMapId (Id), (char   *)(FILE_), __LINE__, GET_WORD (dtmf_parms[0].info)));
+          PUT_WORD (&result[1], DTMF_UNKNOWN_REQUEST);
           break;
         }
 
@@ -10021,8 +10021,8 @@
           }
           else
           {
-            plci->dtmf_rec_pulse_ms = READ_WORD (dtmf_parms[1].info);
-            plci->dtmf_rec_pause_ms = READ_WORD (dtmf_parms[2].info);
+            plci->dtmf_rec_pulse_ms = GET_WORD (dtmf_parms[1].info);
+            plci->dtmf_rec_pause_ms = GET_WORD (dtmf_parms[2].info);
           }
         }
         start_internal_command (Id, plci, dtmf_command);
@@ -10037,8 +10037,8 @@
           & (1L << PRIVATE_DTMF_TONE)))
         {
           dbug (1, dprintf ("[%06lx] %s,%d: DTMF unknown request %04x",
-            UnMapId (Id), (char   *)(FILE_), __LINE__, READ_WORD (dtmf_parms[0].info)));
-          WRITE_WORD (&result[1], DTMF_UNKNOWN_REQUEST);
+            UnMapId (Id), (char   *)(FILE_), __LINE__, GET_WORD (dtmf_parms[0].info)));
+          PUT_WORD (&result[1], DTMF_UNKNOWN_REQUEST);
           break;
         }
 
@@ -10052,8 +10052,8 @@
         }
         if (mask & DTMF_LISTEN_ACTIVE_FLAG)
         {
-          plci->dtmf_send_pulse_ms = READ_WORD (dtmf_parms[1].info);
-          plci->dtmf_send_pause_ms = READ_WORD (dtmf_parms[2].info);
+          plci->dtmf_send_pulse_ms = GET_WORD (dtmf_parms[1].info);
+          plci->dtmf_send_pause_ms = GET_WORD (dtmf_parms[2].info);
         }
         i = 0;
         j = 0;
@@ -10072,7 +10072,7 @@
         {
           dbug (1, dprintf ("[%06lx] %s,%d: Incorrect DTMF digit %02x",
             UnMapId (Id), (char   *)(FILE_), __LINE__, dtmf_parms[3].info[i]));
-          WRITE_WORD (&result[1], DTMF_INCORRECT_DIGIT);
+          PUT_WORD (&result[1], DTMF_INCORRECT_DIGIT);
           break;
         }
         if (plci->dtmf_send_requests >=
@@ -10090,7 +10090,7 @@
       default:
         dbug (1, dprintf ("[%06lx] %s,%d: DTMF unknown request %04x",
           UnMapId (Id), (char   *)(FILE_), __LINE__, plci->dtmf_cmd));
-        WRITE_WORD (&result[1], DTMF_UNKNOWN_REQUEST);
+        PUT_WORD (&result[1], DTMF_UNKNOWN_REQUEST);
       }
     }
   }
@@ -10111,7 +10111,7 @@
 
   Info = GOOD;
   result[0] = 2;
-  WRITE_WORD (&result[1], DTMF_SUCCESS);
+  PUT_WORD (&result[1], DTMF_SUCCESS);
   if (plci->dtmf_send_requests != 0)
   {
     sendf (plci->appl, _FACILITY_R | CONFIRM, Id & 0xffffL, plci->dtmf_msg_number_queue[0],
@@ -11075,7 +11075,7 @@
         if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)
          && (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length))
         {
-          w = READ_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE);
+          w = GET_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE);
         }
         if (li_config_table[i].channel & LI_CHANNEL_TX_DATA)
           w |= MIXER_FEATURE_ENABLE_TX_DATA;
@@ -11181,7 +11181,7 @@
         if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)
          && (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length))
         {
-          w = READ_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE);
+          w = GET_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE);
         }
         if (li_config_table[i].channel & LI_CHANNEL_TX_DATA)
           w |= MIXER_FEATURE_ENABLE_TX_DATA;
@@ -11293,7 +11293,7 @@
         ((CAPI_MSG *) msg)->header.ncci = 0;
         ((CAPI_MSG *) msg)->info.facility_req.Selector = SELECTOR_LINE_INTERCONNECT;
         ((CAPI_MSG *) msg)->info.facility_req.structs[0] = 3;
-        WRITE_WORD (&(((CAPI_MSG *) msg)->info.facility_req.structs[1]), LI_REQ_SILENT_UPDATE);
+        PUT_WORD (&(((CAPI_MSG *) msg)->info.facility_req.structs[1]), LI_REQ_SILENT_UPDATE);
         ((CAPI_MSG *) msg)->info.facility_req.structs[3] = 0;
         w = api_put (notify_plci->appl, (CAPI_MSG *) msg);
         if (w != _QUEUE_FULL)
@@ -11910,7 +11910,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: LI request overrun",
       UnMapId (Id), (char   *)(FILE_), __LINE__));
-    WRITE_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE);
+    PUT_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE);
     return (NULL);
   }
   ctlr_b = 0;
@@ -11926,7 +11926,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: LI invalid second PLCI %08lx",
       UnMapId (Id), (char   *)(FILE_), __LINE__, plci_b_id));
-    WRITE_WORD (p_result, _WRONG_IDENTIFIER);
+    PUT_WORD (p_result, _WRONG_IDENTIFIER);
     return (NULL);
   }
   plci_b = &(adapter[ctlr_b - 1].plci[((plci_b_id >> 8) & 0xff) - 1]);
@@ -11936,7 +11936,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: LI peer in wrong state %08lx",
       UnMapId (Id), (char   *)(FILE_), __LINE__, plci_b_id));
-    WRITE_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE);
+    PUT_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE);
     return (NULL);
   }
   li_config_table[plci_b->adapter->li_base + (plci_b->li_bchannel_id - 1)].plci = plci_b;
@@ -11947,7 +11947,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: LI not on same ctrl %08lx",
       UnMapId (Id), (char   *)(FILE_), __LINE__, plci_b_id));
-    WRITE_WORD (p_result, _WRONG_IDENTIFIER);
+    PUT_WORD (p_result, _WRONG_IDENTIFIER);
     return (NULL);
   }
   if (!(get_b1_facilities (plci_b, add_b1_facilities (plci_b, plci_b->B1_resource,
@@ -11955,7 +11955,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: Interconnect peer cannot mix %d",
       UnMapId (Id), (char   *)(FILE_), __LINE__, plci_b->B1_resource));
-    WRITE_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE);
+    PUT_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE);
     return (NULL);
   }
   return (plci_b);
@@ -11973,7 +11973,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: LI request overrun",
       UnMapId (Id), (char   *)(FILE_), __LINE__));
-    WRITE_WORD (p_result, _WRONG_STATE);
+    PUT_WORD (p_result, _WRONG_STATE);
     return (NULL);
   }
   ctlr_b = 0;
@@ -11989,7 +11989,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: LI invalid second PLCI %08lx",
       UnMapId (Id), (char   *)(FILE_), __LINE__, plci_b_id));
-    WRITE_WORD (p_result, _WRONG_IDENTIFIER);
+    PUT_WORD (p_result, _WRONG_IDENTIFIER);
     return (NULL);
   }
   plci_b = &(adapter[ctlr_b - 1].plci[((plci_b_id >> 8) & 0xff) - 1]);
@@ -12000,7 +12000,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: LI peer in wrong state %08lx",
       UnMapId (Id), (char   *)(FILE_), __LINE__, plci_b_id));
-    WRITE_WORD (p_result, _WRONG_STATE);
+    PUT_WORD (p_result, _WRONG_STATE);
     return (NULL);
   }
   if (((byte)(plci_b_id & ~EXT_CONTROLLER)) !=
@@ -12010,7 +12010,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: LI not on same ctrl %08lx",
       UnMapId (Id), (char   *)(FILE_), __LINE__, plci_b_id));
-    WRITE_WORD (p_result, _WRONG_IDENTIFIER);
+    PUT_WORD (p_result, _WRONG_IDENTIFIER);
     return (NULL);
   }
   if (!(get_b1_facilities (plci_b, add_b1_facilities (plci_b, plci_b->B1_resource,
@@ -12018,7 +12018,7 @@
   {
     dbug (1, dprintf ("[%06lx] %s,%d: Interconnect peer cannot mix %d",
       UnMapId (Id), (char   *)(FILE_), __LINE__, plci_b->B1_resource));
-    WRITE_WORD (p_result, _WRONG_STATE);
+    PUT_WORD (p_result, _WRONG_STATE);
     return (NULL);
   }
   return (plci_b);
@@ -12062,16 +12062,16 @@
   else
   {
     result_buffer[0] = 3;
-    WRITE_WORD (&result_buffer[1], READ_WORD (li_parms[0].info));
+    PUT_WORD (&result_buffer[1], GET_WORD (li_parms[0].info));
     result_buffer[3] = 0;
-    switch (READ_WORD (li_parms[0].info))
+    switch (GET_WORD (li_parms[0].info))
     {
     case LI_GET_SUPPORTED_SERVICES:
       if (appl->appl_flags & APPL_FLAG_OLD_LI_SPEC)
       {
         result_buffer[0] = 17;
         result_buffer[3] = 14;
-        WRITE_WORD (&result_buffer[4], GOOD);
+        PUT_WORD (&result_buffer[4], GOOD);
         d = 0;
         if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_CH_CH)
           d |= LI_CONFERENCING_SUPPORTED;
@@ -12081,7 +12081,7 @@
           d |= LI_ANNOUNCEMENTS_SUPPORTED | LI_MIXING_SUPPORTED;
         if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT)
           d |= LI_CROSS_CONTROLLER_SUPPORTED;
-        WRITE_DWORD (&result_buffer[6], d);
+        PUT_DWORD (&result_buffer[6], d);
         if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT)
         {
           d = 0;
@@ -12099,14 +12099,14 @@
         {
           d = a->li_pri ? a->li_channels : MIXER_BCHANNELS_BRI;
         }
-        WRITE_DWORD (&result_buffer[10], d / 2);
-        WRITE_DWORD (&result_buffer[14], d);
+        PUT_DWORD (&result_buffer[10], d / 2);
+        PUT_DWORD (&result_buffer[14], d);
       }
       else
       {
         result_buffer[0] = 25;
         result_buffer[3] = 22;
-        WRITE_WORD (&result_buffer[4], GOOD);
+        PUT_WORD (&result_buffer[4], GOOD);
         d = LI2_ASYMMETRIC_SUPPORTED | LI2_B_LOOPING_SUPPORTED | LI2_X_LOOPING_SUPPORTED;
         if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_CH_PC)
           d |= LI2_MONITORING_SUPPORTED | LI2_REMOTE_MONITORING_SUPPORTED;
@@ -12116,10 +12116,10 @@
           d |= LI2_PC_LOOPING_SUPPORTED;
         if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT)
           d |= LI2_CROSS_CONTROLLER_SUPPORTED;
-        WRITE_DWORD (&result_buffer[6], d);
+        PUT_DWORD (&result_buffer[6], d);
         d = a->li_pri ? a->li_channels : MIXER_BCHANNELS_BRI;
-        WRITE_DWORD (&result_buffer[10], d / 2);
-        WRITE_DWORD (&result_buffer[14], d - 1);
+        PUT_DWORD (&result_buffer[10], d / 2);
+        PUT_DWORD (&result_buffer[14], d - 1);
         if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT)
         {
           d = 0;
@@ -12133,8 +12133,8 @@
             }
           }
         }
-        WRITE_DWORD (&result_buffer[18], d / 2);
-        WRITE_DWORD (&result_buffer[22], d - 1);
+        PUT_DWORD (&result_buffer[18], d / 2);
+        PUT_DWORD (&result_buffer[22], d - 1);
       }
       break;
 
@@ -12149,13 +12149,13 @@
           Info = _WRONG_MESSAGE_FORMAT;
           break;
         }
-        plci_b_id = READ_DWORD (li_req_parms[0].info) & 0xffff;
-        li_flags = READ_DWORD (li_req_parms[1].info);
+        plci_b_id = GET_DWORD (li_req_parms[0].info) & 0xffff;
+        li_flags = GET_DWORD (li_req_parms[1].info);
         Info = li_check_main_plci (Id, plci);
         result_buffer[0] = 9;
         result_buffer[3] = 6;
-        WRITE_DWORD (&result_buffer[4], plci_b_id);
-        WRITE_WORD (&result_buffer[8], GOOD);
+        PUT_DWORD (&result_buffer[4], plci_b_id);
+        PUT_WORD (&result_buffer[8], GOOD);
         if (Info != GOOD)
           break;
         result = plci->saved_msg.info;
@@ -12180,11 +12180,11 @@
           Info = _WRONG_MESSAGE_FORMAT;
           break;
         }
-        li_flags = READ_DWORD (li_req_parms[0].info) & ~(LI2_FLAG_INTERCONNECT_A_B | LI2_FLAG_INTERCONNECT_B_A);
+        li_flags = GET_DWORD (li_req_parms[0].info) & ~(LI2_FLAG_INTERCONNECT_A_B | LI2_FLAG_INTERCONNECT_B_A);
         Info = li_check_main_plci (Id, plci);
         result_buffer[0] = 7;
         result_buffer[3] = 4;
-        WRITE_WORD (&result_buffer[4], Info);
+        PUT_WORD (&result_buffer[4], Info);
         result_buffer[6] = 0;
         if (Info != GOOD)
           break;
@@ -12199,14 +12199,14 @@
         {
           result[result_pos] = 6;
           result_pos += 7;
-          WRITE_DWORD (&result[result_pos - 6], 0);
-          WRITE_WORD (&result[result_pos - 2], GOOD);
+          PUT_DWORD (&result[result_pos - 6], 0);
+          PUT_WORD (&result[result_pos - 2], GOOD);
           if (api_parse (&li_req_parms[1].info[1 + participant_parms_pos],
             (word)(li_parms[1].length - participant_parms_pos), "s", li_participant_struct))
           {
             dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format",
               UnMapId (Id), (char   *)(FILE_), __LINE__));
-            WRITE_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT);
+            PUT_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT);
             break;
           }
           if (api_parse (&li_participant_struct[0].info[1],
@@ -12214,17 +12214,17 @@
           {
             dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format",
               UnMapId (Id), (char   *)(FILE_), __LINE__));
-            WRITE_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT);
+            PUT_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT);
             break;
           }
-          plci_b_id = READ_DWORD (li_participant_parms[0].info) & 0xffff;
-          li_flags = READ_DWORD (li_participant_parms[1].info);
-          WRITE_DWORD (&result[result_pos - 6], plci_b_id);
+          plci_b_id = GET_DWORD (li_participant_parms[0].info) & 0xffff;
+          li_flags = GET_DWORD (li_participant_parms[1].info);
+          PUT_DWORD (&result[result_pos - 6], plci_b_id);
           if (sizeof(result) - result_pos < 7)
           {
             dbug (1, dprintf ("[%06lx] %s,%d: LI result overrun",
               UnMapId (Id), (char   *)(FILE_), __LINE__));
-            WRITE_WORD (&result[result_pos - 2], _WRONG_STATE);
+            PUT_WORD (&result[result_pos - 2], _WRONG_STATE);
             break;
           }
           plci_b = li2_check_plci_b (Id, plci, plci_b_id, plci_b_write_pos, &result[result_pos - 2]);
@@ -12259,7 +12259,7 @@
       sendf (appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number,
         "wwS", Info, SELECTOR_LINE_INTERCONNECT, result);
       plci->command = 0;
-      plci->li_cmd = READ_WORD (li_parms[0].info);
+      plci->li_cmd = GET_WORD (li_parms[0].info);
       start_internal_command (Id, plci, mixer_command);
       return (FALSE);
 
@@ -12274,12 +12274,12 @@
           Info = _WRONG_MESSAGE_FORMAT;
           break;
         }
-        plci_b_id = READ_DWORD (li_req_parms[0].info) & 0xffff;
+        plci_b_id = GET_DWORD (li_req_parms[0].info) & 0xffff;
         Info = li_check_main_plci (Id, plci);
         result_buffer[0] = 9;
         result_buffer[3] = 6;
-        WRITE_DWORD (&result_buffer[4], READ_DWORD (li_req_parms[0].info));
-        WRITE_WORD (&result_buffer[8], GOOD);
+        PUT_DWORD (&result_buffer[4], GET_DWORD (li_req_parms[0].info));
+        PUT_WORD (&result_buffer[8], GOOD);
         if (Info != GOOD)
           break;
         result = plci->saved_msg.info;
@@ -12307,7 +12307,7 @@
         Info = li_check_main_plci (Id, plci);
         result_buffer[0] = 7;
         result_buffer[3] = 4;
-        WRITE_WORD (&result_buffer[4], Info);
+        PUT_WORD (&result_buffer[4], Info);
         result_buffer[6] = 0;
         if (Info != GOOD)
           break;
@@ -12321,14 +12321,14 @@
         {
           result[result_pos] = 6;
           result_pos += 7;
-          WRITE_DWORD (&result[result_pos - 6], 0);
-          WRITE_WORD (&result[result_pos - 2], GOOD);
+          PUT_DWORD (&result[result_pos - 6], 0);
+          PUT_WORD (&result[result_pos - 2], GOOD);
           if (api_parse (&li_req_parms[0].info[1 + participant_parms_pos],
             (word)(li_parms[1].length - participant_parms_pos), "s", li_participant_struct))
           {
             dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format",
               UnMapId (Id), (char   *)(FILE_), __LINE__));
-            WRITE_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT);
+            PUT_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT);
             break;
           }
           if (api_parse (&li_participant_struct[0].info[1],
@@ -12336,16 +12336,16 @@
           {
             dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format",
               UnMapId (Id), (char   *)(FILE_), __LINE__));
-            WRITE_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT);
+            PUT_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT);
             break;
           }
-          plci_b_id = READ_DWORD (li_participant_parms[0].info) & 0xffff;
-          WRITE_DWORD (&result[result_pos - 6], plci_b_id);
+          plci_b_id = GET_DWORD (li_participant_parms[0].info) & 0xffff;
+          PUT_DWORD (&result[result_pos - 6], plci_b_id);
           if (sizeof(result) - result_pos < 7)
           {
             dbug (1, dprintf ("[%06lx] %s,%d: LI result overrun",
               UnMapId (Id), (char   *)(FILE_), __LINE__));
-            WRITE_WORD (&result[result_pos - 2], _WRONG_STATE);
+            PUT_WORD (&result[result_pos - 2], _WRONG_STATE);
             break;
           }
           plci_b = li2_check_plci_b (Id, plci, plci_b_id, plci_b_write_pos, &result[result_pos - 2]);
@@ -12378,7 +12378,7 @@
       sendf (appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number,
         "wwS", Info, SELECTOR_LINE_INTERCONNECT, result);
       plci->command = 0;
-      plci->li_cmd = READ_WORD (li_parms[0].info);
+      plci->li_cmd = GET_WORD (li_parms[0].info);
       start_internal_command (Id, plci, mixer_command);
       return (FALSE);
 
@@ -12412,13 +12412,13 @@
       plci->li_plci_b_write_pos = plci_b_write_pos;
       plci->li_channel_bits = li_config_table[a->li_base + (plci->li_bchannel_id - 1)].channel;
       plci->command = 0;
-      plci->li_cmd = READ_WORD (li_parms[0].info);
+      plci->li_cmd = GET_WORD (li_parms[0].info);
       start_internal_command (Id, plci, mixer_command);
       return (FALSE);
 
     default:
       dbug (1, dprintf ("[%06lx] %s,%d: LI unknown request %04x",
-        UnMapId (Id), (char   *)(FILE_), __LINE__, READ_WORD (li_parms[0].info)));
+        UnMapId (Id), (char   *)(FILE_), __LINE__, GET_WORD (li_parms[0].info)));
       Info = _FACILITY_NOT_SUPPORTED;
     }
   }
@@ -12450,16 +12450,16 @@
           if (d & LI_PLCI_B_DISC_FLAG)
           {
             result[0] = 5;
-            WRITE_WORD (&result[1], LI_IND_DISCONNECT);
+            PUT_WORD (&result[1], LI_IND_DISCONNECT);
             result[3] = 2;
-            WRITE_WORD (&result[4], _LI_USER_INITIATED);
+            PUT_WORD (&result[4], _LI_USER_INITIATED);
           }
           else
           {
             result[0] = 7;
-            WRITE_WORD (&result[1], LI_IND_CONNECT_ACTIVE);
+            PUT_WORD (&result[1], LI_IND_CONNECT_ACTIVE);
             result[3] = 4;
-            WRITE_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK);
+            PUT_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK);
           }
         }
         else
@@ -12467,17 +12467,17 @@
           if (d & LI_PLCI_B_DISC_FLAG)
           {
             result[0] = 9;
-            WRITE_WORD (&result[1], LI_IND_DISCONNECT);
+            PUT_WORD (&result[1], LI_IND_DISCONNECT);
             result[3] = 6;
-            WRITE_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK);
-            WRITE_WORD (&result[8], _LI_USER_INITIATED);
+            PUT_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK);
+            PUT_WORD (&result[8], _LI_USER_INITIATED);
           }
           else
           {
             result[0] = 7;
-            WRITE_WORD (&result[1], LI_IND_CONNECT_ACTIVE);
+            PUT_WORD (&result[1], LI_IND_CONNECT_ACTIVE);
             result[3] = 4;
-            WRITE_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK);
+            PUT_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK);
           }
         }
         sendf (plci->appl, _FACILITY_I, Id & 0xffffL, 0,
@@ -12627,10 +12627,10 @@
 
   parameter_buffer[0] = 5;
   parameter_buffer[1] = DSP_CTRL_SET_LEC_PARAMETERS;
-  WRITE_WORD (&parameter_buffer[2], plci->ec_idi_options);
+  PUT_WORD (&parameter_buffer[2], plci->ec_idi_options);
   plci->ec_idi_options &= ~LEC_RESET_COEFFICIENTS;
   w = (plci->ec_tail_length == 0) ? 128 : plci->ec_tail_length;
-  WRITE_WORD (&parameter_buffer[4], w);
+  PUT_WORD (&parameter_buffer[4], w);
   add_p (plci, FTY, parameter_buffer);
   sig_req (plci, TEL_CTRL, 0);
   send_req (plci);
@@ -12719,14 +12719,14 @@
   if (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC)
   {
     result[0] = 2;
-    WRITE_WORD (&result[1], EC_SUCCESS);
+    PUT_WORD (&result[1], EC_SUCCESS);
   }
   else
   {
     result[0] = 5;
-    WRITE_WORD (&result[1], plci->ec_cmd);
+    PUT_WORD (&result[1], plci->ec_cmd);
     result[3] = 2;
-    WRITE_WORD (&result[4], GOOD);
+    PUT_WORD (&result[4], GOOD);
   }
   internal_command = plci->internal_command;
   plci->internal_command = 0;
@@ -12864,13 +12864,13 @@
         else
         {
           plci->command = 0;
-          plci->ec_cmd = READ_WORD (ec_parms[0].info);
+          plci->ec_cmd = GET_WORD (ec_parms[0].info);
           plci->ec_idi_options &= ~(LEC_MANUAL_DISABLE | LEC_RESET_COEFFICIENTS);
           result[0] = 2;
-          WRITE_WORD (&result[1], EC_SUCCESS);
+          PUT_WORD (&result[1], EC_SUCCESS);
           if (msg[1].length >= 4)
           {
-            opt = READ_WORD (&ec_parms[0].info[2]);
+            opt = GET_WORD (&ec_parms[0].info[2]);
             plci->ec_idi_options &= ~(LEC_ENABLE_NONLINEAR_PROCESSING |
               LEC_ENABLE_2100HZ_DETECTOR | LEC_REQUIRE_2100HZ_REVERSALS);
             if (!(opt & EC_DISABLE_NON_LINEAR_PROCESSING))
@@ -12881,7 +12881,7 @@
               plci->ec_idi_options |= LEC_REQUIRE_2100HZ_REVERSALS;
             if (msg[1].length >= 6)
             {
-              plci->ec_tail_length = READ_WORD (&ec_parms[0].info[4]);
+              plci->ec_tail_length = GET_WORD (&ec_parms[0].info[4]);
             }
           }
           switch (plci->ec_cmd)
@@ -12916,7 +12916,7 @@
           default:
             dbug (1, dprintf ("[%06lx] %s,%d: EC unknown request %04x",
               UnMapId (Id), (char   *)(FILE_), __LINE__, plci->ec_cmd));
-            WRITE_WORD (&result[1], EC_UNSUPPORTED_OPERATION);
+            PUT_WORD (&result[1], EC_UNSUPPORTED_OPERATION);
           }
         }
       }
@@ -12931,15 +12931,15 @@
       }
       else
       {
-        if (READ_WORD (ec_parms[0].info) == EC_GET_SUPPORTED_SERVICES)
+        if (GET_WORD (ec_parms[0].info) == EC_GET_SUPPORTED_SERVICES)
         {
           result[0] = 11;
-          WRITE_WORD (&result[1], EC_GET_SUPPORTED_SERVICES);
+          PUT_WORD (&result[1], EC_GET_SUPPORTED_SERVICES);
           result[3] = 8;
-          WRITE_WORD (&result[4], GOOD);
-          WRITE_WORD (&result[6], 0x0007);
-          WRITE_WORD (&result[8], LEC_MAX_SUPPORTED_TAIL_LENGTH);
-          WRITE_WORD (&result[10], 0);
+          PUT_WORD (&result[4], GOOD);
+          PUT_WORD (&result[6], 0x0007);
+          PUT_WORD (&result[8], LEC_MAX_SUPPORTED_TAIL_LENGTH);
+          PUT_WORD (&result[10], 0);
         }
         else if (plci == NULL)
         {
@@ -12956,18 +12956,18 @@
         else
         {
           plci->command = 0;
-          plci->ec_cmd = READ_WORD (ec_parms[0].info);
+          plci->ec_cmd = GET_WORD (ec_parms[0].info);
           plci->ec_idi_options &= ~(LEC_MANUAL_DISABLE | LEC_RESET_COEFFICIENTS);
           result[0] = 5;
-          WRITE_WORD (&result[1], plci->ec_cmd);
+          PUT_WORD (&result[1], plci->ec_cmd);
           result[3] = 2;
-          WRITE_WORD (&result[4], GOOD);
+          PUT_WORD (&result[4], GOOD);
           plci->ec_idi_options &= ~(LEC_ENABLE_NONLINEAR_PROCESSING |
             LEC_ENABLE_2100HZ_DETECTOR | LEC_REQUIRE_2100HZ_REVERSALS);
           plci->ec_tail_length = 0;
           if (ec_parms[1].length >= 2)
           {
-            opt = READ_WORD (&ec_parms[1].info[1]);
+            opt = GET_WORD (&ec_parms[1].info[1]);
             if (opt & EC_ENABLE_NON_LINEAR_PROCESSING)
               plci->ec_idi_options |= LEC_ENABLE_NONLINEAR_PROCESSING;
             if (opt & EC_DETECT_DISABLE_TONE)
@@ -12976,7 +12976,7 @@
               plci->ec_idi_options |= LEC_REQUIRE_2100HZ_REVERSALS;
             if (ec_parms[1].length >= 4)
             {
-              plci->ec_tail_length = READ_WORD (&ec_parms[1].info[3]);
+              plci->ec_tail_length = GET_WORD (&ec_parms[1].info[3]);
             }
           }
           switch (plci->ec_cmd)
@@ -12996,7 +12996,7 @@
           default:
             dbug (1, dprintf ("[%06lx] %s,%d: EC unknown request %04x",
               UnMapId (Id), (char   *)(FILE_), __LINE__, plci->ec_cmd));
-            WRITE_WORD (&result[4], _FACILITY_SPECIFIC_FUNCTION_NOT_SUPP);
+            PUT_WORD (&result[4], _FACILITY_SPECIFIC_FUNCTION_NOT_SUPP);
           }
         }
       }
@@ -13021,36 +13021,36 @@
     if (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC)
     {
       result[0] = 2;
-      WRITE_WORD (&result[1], 0);
+      PUT_WORD (&result[1], 0);
       switch (msg[1])
       {
       case LEC_DISABLE_TYPE_CONTIGNUOUS_2100HZ:
-        WRITE_WORD (&result[1], EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ);
+        PUT_WORD (&result[1], EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ);
         break;
       case LEC_DISABLE_TYPE_REVERSED_2100HZ:
-        WRITE_WORD (&result[1], EC_BYPASS_DUE_TO_REVERSED_2100HZ);
+        PUT_WORD (&result[1], EC_BYPASS_DUE_TO_REVERSED_2100HZ);
         break;
       case LEC_DISABLE_RELEASED:
-        WRITE_WORD (&result[1], EC_BYPASS_RELEASED);
+        PUT_WORD (&result[1], EC_BYPASS_RELEASED);
         break;
       }
     }
     else
     {
       result[0] = 5;
-      WRITE_WORD (&result[1], EC_BYPASS_INDICATION);
+      PUT_WORD (&result[1], EC_BYPASS_INDICATION);
       result[3] = 2;
-      WRITE_WORD (&result[4], 0);
+      PUT_WORD (&result[4], 0);
       switch (msg[1])
       {
       case LEC_DISABLE_TYPE_CONTIGNUOUS_2100HZ:
-        WRITE_WORD (&result[4], EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ);
+        PUT_WORD (&result[4], EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ);
         break;
       case LEC_DISABLE_TYPE_REVERSED_2100HZ:
-        WRITE_WORD (&result[4], EC_BYPASS_DUE_TO_REVERSED_2100HZ);
+        PUT_WORD (&result[4], EC_BYPASS_DUE_TO_REVERSED_2100HZ);
         break;
       case LEC_DISABLE_RELEASED:
-        WRITE_WORD (&result[4], EC_BYPASS_RELEASED);
+        PUT_WORD (&result[4], EC_BYPASS_RELEASED);
         break;
       }
     }
@@ -13086,13 +13086,13 @@
   i = 0;
   while (i + sizeof(word) <= a->adv_voice_coef_length)
   {
-    WRITE_WORD (p, READ_WORD (a->adv_voice_coef_buffer + i));
+    PUT_WORD (p, GET_WORD (a->adv_voice_coef_buffer + i));
     p += 2;
     i += 2;
   }
   while (i < ADV_VOICE_OLD_COEF_COUNT * sizeof(word))
   {
-    WRITE_WORD (p, 0x8000);
+    PUT_WORD (p, 0x8000);
     p += 2;
     i += 2;
   }
@@ -13172,7 +13172,7 @@
     {
       w = 0;
       if (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length)
-        w = READ_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE);
+        w = GET_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE);
       if (li_config_table[i].channel & LI_CHANNEL_TX_DATA)
         w |= MIXER_FEATURE_ENABLE_TX_DATA;
       if (li_config_table[i].channel & LI_CHANNEL_RX_DATA)
diff -Nru a/drivers/isdn/hardware/eicon/os_4bri.c b/drivers/isdn/hardware/eicon/os_4bri.c
--- a/drivers/isdn/hardware/eicon/os_4bri.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/isdn/hardware/eicon/os_4bri.c	2004-12-24 13:36:48 -08:00
@@ -143,7 +143,7 @@
 int diva_4bri_init_card(diva_os_xdi_adapter_t * a)
 {
 	int bar, i;
-	byte *p;
+	byte __iomem *p;
 	PADAPTER_LIST_ENTRY quadro_list;
 	diva_os_xdi_adapter_t *diva_current;
 	diva_os_xdi_adapter_t *adapter_list[4];
@@ -424,7 +424,7 @@
 	   reset contains the base address for the PLX 9054 register set
 	 */
 	p = DIVA_OS_MEM_ATTACH_RESET(&a->xdi_adapter);
-	p[PLX9054_INTCSR] = 0x00;	/* disable PCI interrupts */
+	WRITE_BYTE(&p[PLX9054_INTCSR], 0x00);	/* disable PCI interrupts */
 	DIVA_OS_MEM_DETACH_RESET(&a->xdi_adapter, p);
 
 	/*
@@ -788,15 +788,15 @@
 							   a->xdi_mbox.
 							   data_length);
 					if (a->xdi_mbox.data) {
-						byte *p = DIVA_OS_MEM_ATTACH_ADDRESS(&a->xdi_adapter);
-						byte *src = p;
+						byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(&a->xdi_adapter);
+						byte __iomem *src = p;
 						byte *dst = a->xdi_mbox.data;
 						dword len = a->xdi_mbox.data_length;
 
 						src += cmd->command_data.read_sdram.offset;
 
 						while (len--) {
-							*dst++ = *src++;
+							*dst++ = READ_BYTE(src++);
 						}
 						DIVA_OS_MEM_DETACH_ADDRESS(&a->xdi_adapter, p);
 						a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY;
@@ -910,8 +910,8 @@
 			    dword address,
 			    const byte * data, dword length, dword limit)
 {
-	byte *p = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
-	byte *mem = p;
+	byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
+	byte __iomem *mem = p;
 
 	if (((address + length) >= limit) || !mem) {
 		DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, p);
@@ -922,7 +922,7 @@
 	mem += address;
 
 	while (length--) {
-		*mem++ = *data++;
+		WRITE_BYTE(mem++, *data++);
 	}
 
 	DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, p);
@@ -933,10 +933,10 @@
 diva_4bri_start_adapter(PISDN_ADAPTER IoAdapter,
 			dword start_address, dword features)
 {
-	volatile word *signature;
+	volatile word __iomem *signature;
 	int started = 0;
 	int i;
-	byte *p;
+	byte __iomem *p;
 
 	/*
 	   start adapter
@@ -947,7 +947,7 @@
 	/*
 	   wait for signature in shared memory (max. 3 seconds)
 	 */
-	signature = (volatile word *) (&p[0x1E]);
+	signature = (volatile word __iomem *) (&p[0x1E]);
 
 	for (i = 0; i < 300; ++i) {
 		diva_os_wait(10);
@@ -1011,7 +1011,7 @@
 #ifdef	SUPPORT_INTERRUPT_TEST_ON_4BRI
 	int i;
 	ADAPTER *a = &IoAdapter->a;
-	byte *p;
+	byte __iomem *p;
 
 	IoAdapter->IrqCount = 0;
 
@@ -1019,7 +1019,7 @@
 		return (-1);
 
 	p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
-	p[PLX9054_INTCSR] = PLX9054_INT_ENABLE;
+	WRITE_BYTE(&p[PLX9054_INTCSR], PLX9054_INT_ENABLE);
 	DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
 	/*
 	   interrupt test
@@ -1031,14 +1031,14 @@
 
 	return ((IoAdapter->IrqCount > 0) ? 0 : -1);
 #else
-	dword volatile *qBriIrq;
-	byte *p;
+	dword volatile __iomem *qBriIrq;
+	byte __iomem *p;
 	/*
 	   Reset on-board interrupt register
 	 */
 	IoAdapter->IrqCount = 0;
 	p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
-	qBriIrq = (dword volatile *) (&p[_4bri_is_rev_2_card
+	qBriIrq = (dword volatile __iomem *) (&p[_4bri_is_rev_2_card
 				       (IoAdapter->
 					cardType) ? (MQ2_BREG_IRQ_TEST)
 				       : (MQ_BREG_IRQ_TEST)]);
@@ -1047,7 +1047,7 @@
 	DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
 
 	p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
-	p[PLX9054_INTCSR] = PLX9054_INT_ENABLE;
+	WRITE_BYTE(&p[PLX9054_INTCSR], PLX9054_INT_ENABLE);
 	DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
 
 	diva_os_wait(100);
diff -Nru a/drivers/isdn/hardware/eicon/os_bri.c b/drivers/isdn/hardware/eicon/os_bri.c
--- a/drivers/isdn/hardware/eicon/os_bri.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/isdn/hardware/eicon/os_bri.c	2004-12-24 13:36:17 -08:00
@@ -78,7 +78,7 @@
 	word cmd = 0, cmd_org;
 	byte Bus, Slot;
 	void *hdev;
-	byte *p;
+	byte __iomem *p;
 
 	/*
 	   Set properties
@@ -331,10 +331,11 @@
 static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t * a)
 {
 	dword serNo = 0;
-	byte *confIO;
-	word serHi, serLo, *confMem;
+	byte __iomem *confIO;
+	word serHi, serLo;
+	word __iomem *confMem;
 
-	confIO = (byte *) DIVA_OS_MEM_ATTACH_CFG(&a->xdi_adapter);
+	confIO = DIVA_OS_MEM_ATTACH_CFG(&a->xdi_adapter);
 	serHi = (word) (inppw(&confIO[0x22]) & 0x0FFF);
 	serLo = (word) (inppw(&confIO[0x26]) & 0x0FFF);
 	serNo = ((dword) serHi << 16) | (dword) serLo;
@@ -343,7 +344,7 @@
 	if ((serNo == 0) || (serNo == 0xFFFFFFFF)) {
 		DBG_FTL(("W: BRI use BAR[0] to get card serial number"))
 
-		confMem = (word *) DIVA_OS_MEM_ATTACH_RAM(&a->xdi_adapter);
+		confMem = (word __iomem *)DIVA_OS_MEM_ATTACH_RAM(&a->xdi_adapter);
 		serHi = (word) (READ_WORD(&confMem[0x11]) & 0x0FFF);
 		serLo = (word) (READ_WORD(&confMem[0x13]) & 0x0FFF);
 		serNo = (((dword) serHi) << 16) | ((dword) serLo);
@@ -513,9 +514,9 @@
 
 static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter)
 {
-	byte *addrHi, *addrLo, *ioaddr;
+	byte __iomem *addrHi, *addrLo, *ioaddr;
 	dword i;
-	byte *Port;
+	byte __iomem *Port;
 
 	if (!IoAdapter->port) {
 		return (-1);
@@ -602,8 +603,8 @@
 diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter,
 			   dword address, const byte * data, dword length)
 {
-	byte *addrHi, *addrLo, *ioaddr;
-	byte *Port;
+	byte __iomem *addrHi, *addrLo, *ioaddr;
+	byte __iomem *Port;
 
 	if (!IoAdapter->port) {
 		return (-1);
@@ -630,9 +631,9 @@
 diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
 		       dword start_address, dword features)
 {
-	byte *Port;
+	byte __iomem *Port;
 	dword i, test;
-	byte *addrHi, *addrLo, *ioaddr;
+	byte __iomem *addrHi, *addrLo, *ioaddr;
 	int started = 0;
 	ADAPTER *a = &IoAdapter->a;
 
diff -Nru a/drivers/isdn/hardware/eicon/os_pri.c b/drivers/isdn/hardware/eicon/os_pri.c
--- a/drivers/isdn/hardware/eicon/os_pri.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/isdn/hardware/eicon/os_pri.c	2004-12-24 13:36:48 -08:00
@@ -332,7 +332,7 @@
 static int diva_pri_reset_adapter(PISDN_ADAPTER IoAdapter)
 {
 	dword i;
-	struct mp_load *boot;
+	struct mp_load __iomem *boot;
 
 	if (!IoAdapter->Address || !IoAdapter->reset) {
 		return (-1);
@@ -343,7 +343,7 @@
 		return (-1);
 	}
 
-	boot = (struct mp_load *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
+	boot = (struct mp_load __iomem *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
 	WRITE_DWORD(&boot->err, 0);
 	DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
 
@@ -351,7 +351,7 @@
 
 	diva_os_wait(10);
 
-	boot = (struct mp_load *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
+	boot = (struct mp_load __iomem *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
 	i = READ_DWORD(&boot->live);
 
 	diva_os_wait(10);
@@ -408,8 +408,8 @@
 			   dword address,
 			   const byte * data, dword length, dword limit)
 {
-	byte *p = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
-	byte *mem = p;
+	byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
+	byte __iomem *mem = p;
 
 	if (((address + length) >= limit) || !mem) {
 		DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, p);
@@ -419,8 +419,9 @@
 	}
 	mem += address;
 
+	/* memcpy_toio(), maybe? */
 	while (length--) {
-		*mem++ = *data++;
+		WRITE_BYTE(mem++, *data++);
 	}
 
 	DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, p);
@@ -433,8 +434,8 @@
 {
 	dword i;
 	int started = 0;
-	byte *p;
-	struct mp_load *boot = (struct mp_load *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
+	byte __iomem *p;
+	struct mp_load __iomem *boot = (struct mp_load __iomem *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
 	ADAPTER *a = &IoAdapter->a;
 
 	if (IoAdapter->Initialized) {
@@ -468,7 +469,7 @@
 	}
 
 	if (!started) {
-		byte *p = (byte *)boot;
+		byte __iomem *p = (byte __iomem *)boot;
 		dword TrapId;
 		dword debug;
 		TrapId = READ_DWORD(&p[0x80]);
@@ -492,7 +493,7 @@
 	 */
 	IoAdapter->IrqCount = 0;
 	p = DIVA_OS_MEM_ATTACH_CFG(IoAdapter);
-	WRITE_DWORD(((dword volatile *) p), (dword) ~ 0x03E00000);
+	WRITE_DWORD(p, (dword) ~ 0x03E00000);
 	DIVA_OS_MEM_DETACH_CFG(IoAdapter, p);
 	a->ReadyInt = 1;
 	a->ram_out(a, &PR_RAM->ReadyInt, 1);
@@ -729,15 +730,15 @@
 							   a->xdi_mbox.
 							   data_length);
 					if (a->xdi_mbox.data) {
-						byte *p = DIVA_OS_MEM_ATTACH_ADDRESS(&a->xdi_adapter);
-						byte *src = p;
+						byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(&a->xdi_adapter);
+						byte __iomem *src = p;
 						byte *dst = a->xdi_mbox.data;
 						dword len = a->xdi_mbox.data_length;
 
 						src += cmd->command_data.read_sdram.offset;
 
 						while (len--) {
-							*dst++ = *src++;
+							*dst++ = READ_BYTE(src++);
 						}
 						a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY;
 						DIVA_OS_MEM_DETACH_ADDRESS(&a->xdi_adapter, p);
@@ -764,18 +765,20 @@
 	byte data[64];
 	int i;
 	dword len = sizeof(data);
-	volatile byte *config;
-	volatile byte *flash;
+	volatile byte __iomem *config;
+	volatile byte __iomem *flash;
+	byte c;
 
 /*
  *  First set some GT6401x config registers before accessing the BOOT-ROM
  */
  	config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter);
-	if (!(config[0xc3c] & 0x08)) {
-		config[0xc3c] |= 0x08;	/* Base Address enable register */
+	c = READ_BYTE(&config[0xc3c]);
+	if (!(c & 0x08)) {
+		WRITE_BYTE(&config[0xc3c], c);	/* Base Address enable register */
 	}
-	config[LOW_BOOTCS_DREG] = 0x00;
-	config[HI_BOOTCS_DREG] = 0xFF;
+	WRITE_BYTE(&config[LOW_BOOTCS_DREG], 0x00);
+	WRITE_BYTE(&config[HI_BOOTCS_DREG], 0xFF);
  	DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config);
 /*
  *  Read only the last 64 bytes of manufacturing data
@@ -783,13 +786,13 @@
 	memset(data, '\0', len);
  	flash = DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter);
 	for (i = 0; i < len; i++) {
-		data[i] = flash[0x8000 - len + i];
+		data[i] = READ_BYTE(&flash[0x8000 - len + i]);
 	}
  	DIVA_OS_MEM_DETACH_PROM(&a->xdi_adapter, flash);
 
  	config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter);
-	config[LOW_BOOTCS_DREG] = 0xFC;	/* Disable FLASH EPROM access */
-	config[HI_BOOTCS_DREG] = 0xFF;
+	WRITE_BYTE(&config[LOW_BOOTCS_DREG], 0xFC);	/* Disable FLASH EPROM access */
+	WRITE_BYTE(&config[HI_BOOTCS_DREG], 0xFF);
  	DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config);
 
 	if (memcmp(&data[48], "DIVAserverPR", 12)) {
@@ -905,7 +908,7 @@
 **  Checks presence of DSP on board
 */
 static int
-dsp_check_presence(volatile byte * addr, volatile byte * data, int dsp)
+dsp_check_presence(volatile byte __iomem * addr, volatile byte __iomem * data, int dsp)
 {
 	word pattern;
 
@@ -950,8 +953,8 @@
 */
 static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t * a)
 {
-	byte *base;
-	byte *p;
+	byte __iomem *base;
+	byte __iomem *p;
 	dword ret = 0;
 	dword row_offset[7] = {
 		0x00000000,
@@ -962,7 +965,9 @@
 		0x00000000	/* 5 - ROW 0 */
 	};
 
-	byte *dsp_addr_port, *dsp_data_port, row_state;
+	byte __iomem *dsp_addr_port;
+	byte __iomem *dsp_data_port;
+	byte row_state;
 	int dsp_row = 0, dsp_index, dsp_num;
 
 	if (!a->xdi_adapter.Control || !a->xdi_adapter.reset) {
@@ -970,7 +975,7 @@
 	}
 
 	p = DIVA_OS_MEM_ATTACH_RESET(&a->xdi_adapter);
-	*(volatile byte *) p = _MP_RISC_RESET | _MP_DSP_RESET;
+	WRITE_BYTE(p, _MP_RISC_RESET | _MP_DSP_RESET);
 	DIVA_OS_MEM_DETACH_RESET(&a->xdi_adapter, p);
 	diva_os_wait(5);
 
@@ -997,7 +1002,7 @@
 	DIVA_OS_MEM_DETACH_CONTROL(&a->xdi_adapter, base);
 
 	p = DIVA_OS_MEM_ATTACH_RESET(&a->xdi_adapter);
-	*(volatile byte *) p = _MP_RISC_RESET | _MP_LED1 | _MP_LED2;
+	WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2);
 	DIVA_OS_MEM_DETACH_RESET(&a->xdi_adapter, p);
 	diva_os_wait(5);
 
diff -Nru a/drivers/isdn/hardware/eicon/platform.h b/drivers/isdn/hardware/eicon/platform.h
--- a/drivers/isdn/hardware/eicon/platform.h	2004-12-24 13:37:04 -08:00
+++ b/drivers/isdn/hardware/eicon/platform.h	2004-12-24 13:37:04 -08:00
@@ -235,12 +235,12 @@
 /*
 **  I/O port access abstraction
 */
-byte inpp (void*);
-word inppw (void*);
-void inppw_buffer (void*, void*, int);
-void outppw (void*, word);
-void outppw_buffer (void* , void*, int);
-void outpp (void*, word);
+byte inpp (void __iomem *);
+word inppw (void __iomem *);
+void inppw_buffer (void __iomem *, void*, int);
+void outppw (void __iomem *, word);
+void outppw_buffer (void __iomem * , void*, int);
+void outpp (void __iomem *, word);
 
 /*
 **  IRQ 
@@ -335,12 +335,34 @@
 
 /*
 ** endian macros
+**
+** If only...  In some cases we did use them for endianness conversion;
+** unfortunately, other uses were real iomem accesses.
 */
+#define READ_BYTE(addr)   readb(addr)
 #define READ_WORD(addr)   readw(addr)
 #define READ_DWORD(addr)  readl(addr)
 
+#define WRITE_BYTE(addr,v)  writeb(v,addr)
 #define WRITE_WORD(addr,v)  writew(v,addr)
 #define WRITE_DWORD(addr,v) writel(v,addr)
+
+static inline __u16 GET_WORD(void *addr)
+{
+	return le16_to_cpu(*(__le16 *)addr);
+}
+static inline __u32 GET_DWORD(void *addr)
+{
+	return le32_to_cpu(*(__le32 *)addr);
+}
+static inline void PUT_WORD(void *addr, __u16 v)
+{
+	*(__le16 *)addr = cpu_to_le16(v);
+}
+static inline void PUT_DWORD(void *addr, __u32 v)
+{
+	*(__le32 *)addr = cpu_to_le32(v);
+}
 
 /*
 ** 32/64 bit macors
diff -Nru a/drivers/isdn/hardware/eicon/s_4bri.c b/drivers/isdn/hardware/eicon/s_4bri.c
--- a/drivers/isdn/hardware/eicon/s_4bri.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/isdn/hardware/eicon/s_4bri.c	2004-12-24 13:36:16 -08:00
@@ -45,7 +45,7 @@
 		Recovery XLOG from QBRI Card
 	 -------------------------------------------------------------------------- */
 static void qBri_cpu_trapped (PISDN_ADAPTER IoAdapter) {
-	byte  *base ;
+	byte  __iomem *base ;
 	word *Xlog ;
 	dword   regs[4], TrapID, offset, size ;
 	Xdesc   xlogDesc ;
@@ -66,10 +66,10 @@
 		IoAdapter->trapped = 1 ;
 	}
 
-	regs[0] = READ_DWORD((&base + offset) + 0x70);
-	regs[1] = READ_DWORD((&base + offset) + 0x74);
-	regs[2] = READ_DWORD((&base + offset) + 0x78);
-	regs[3] = READ_DWORD((&base + offset) + 0x7c);
+	regs[0] = READ_DWORD((base + offset) + 0x70);
+	regs[1] = READ_DWORD((base + offset) + 0x74);
+	regs[2] = READ_DWORD((base + offset) + 0x78);
+	regs[3] = READ_DWORD((base + offset) + 0x7c);
 	regs[0] &= IoAdapter->MemorySize - 1 ;
 
 	if ( (regs[0] >= offset)
@@ -83,7 +83,7 @@
 		size = offset + (IoAdapter->MemorySize >> factor) - regs[0] ;
 		if ( size > MAX_XLOG_SIZE )
 			size = MAX_XLOG_SIZE ;
-		memcpy (Xlog, &base[regs[0]], size) ;
+		memcpy_fromio (Xlog, &base[regs[0]], size) ;
 		xlogDesc.buf = Xlog ;
 		xlogDesc.cnt = READ_WORD(&base[regs[1] & (IoAdapter->MemorySize - 1)]) ;
 		xlogDesc.out = READ_WORD(&base[regs[2] & (IoAdapter->MemorySize - 1)]) ;
@@ -98,11 +98,11 @@
 		Reset QBRI Hardware
 	 -------------------------------------------------------------------------- */
 static void reset_qBri_hardware (PISDN_ADAPTER IoAdapter) {
-	word volatile *qBriReset ;
-	byte  volatile *qBriCntrl ;
-	byte  volatile *p ;
+	word volatile __iomem *qBriReset ;
+	byte  volatile __iomem *qBriCntrl ;
+	byte  volatile __iomem *p ;
 
-	qBriReset = (word volatile *)DIVA_OS_MEM_ATTACH_PROM(IoAdapter);
+	qBriReset = (word volatile __iomem *)DIVA_OS_MEM_ATTACH_PROM(IoAdapter);
 	WRITE_WORD(qBriReset, READ_WORD(qBriReset) | PLX9054_SOFT_RESET) ;
 	diva_os_wait (1) ;
 	WRITE_WORD(qBriReset, READ_WORD(qBriReset) & ~PLX9054_SOFT_RESET) ;
@@ -126,10 +126,10 @@
 		Start Card CPU
 	 -------------------------------------------------------------------------- */
 void start_qBri_hardware (PISDN_ADAPTER IoAdapter) {
-	byte volatile *qBriReset ;
-	byte volatile *p ;
+	byte volatile __iomem *qBriReset ;
+	byte volatile __iomem *p ;
 
-	p = (byte volatile *)DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
+	p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
 	qBriReset = &p[(DIVA_4BRI_REVISION(IoAdapter)) ? (MQ2_BREG_RISC) : (MQ_BREG_RISC)];
 	WRITE_DWORD(qBriReset, MQ_RISC_COLD_RESET_MASK) ;
 	diva_os_wait (2) ;
@@ -144,10 +144,10 @@
 		Stop Card CPU
 	 -------------------------------------------------------------------------- */
 static void stop_qBri_hardware (PISDN_ADAPTER IoAdapter) {
-	byte volatile *p ;
-	dword volatile *qBriReset ;
-	dword volatile *qBriIrq ;
-	dword volatile *qBriIsacDspReset ;
+	byte volatile __iomem *p ;
+	dword volatile __iomem *qBriReset ;
+	dword volatile __iomem *qBriIrq ;
+	dword volatile __iomem *qBriIsacDspReset ;
 	int rev2 = DIVA_4BRI_REVISION(IoAdapter);
 	int reset_offset = rev2 ? (MQ2_BREG_RISC)      : (MQ_BREG_RISC);
 	int irq_offset   = rev2 ? (MQ2_BREG_IRQ_TEST)  : (MQ_BREG_IRQ_TEST);
@@ -155,9 +155,9 @@
 
 	if ( IoAdapter->ControllerNumber > 0 )
 		return ;
-	p = (byte volatile *)DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
-	qBriReset = (dword volatile *)&p[reset_offset];
-	qBriIsacDspReset = (dword volatile *)&p[hw_offset];
+	p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
+	qBriReset = (dword volatile __iomem *)&p[reset_offset];
+	qBriIsacDspReset = (dword volatile __iomem *)&p[hw_offset];
 /*
  *	clear interrupt line (reset Local Interrupt Test Register)
  */
@@ -165,12 +165,12 @@
  	WRITE_DWORD(qBriIsacDspReset, 0) ;
 	DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
 	
-	p = (byte volatile *)DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
-	p[PLX9054_INTCSR] = 0x00 ;	/* disable PCI interrupts */
+	p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
+	WRITE_BYTE(&p[PLX9054_INTCSR], 0x00);	/* disable PCI interrupts */
 	DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
 	
-	p = (byte volatile *)DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
-	qBriIrq   = (dword volatile *)&p[irq_offset];
+	p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
+	qBriIrq   = (dword volatile __iomem *)&p[irq_offset];
 	WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF) ;
 	DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
 
@@ -276,7 +276,7 @@
 	int            bit ;
 	byte           *File ;
 	dword          code, FileLength ;
-	word volatile *addr = (word volatile *)DIVA_OS_MEM_ATTACH_PROM(IoAdapter);
+	word volatile __iomem *addr = (word volatile __iomem *)DIVA_OS_MEM_ATTACH_PROM(IoAdapter);
 	word           val, baseval = FPGA_CS | FPGA_PROG ;
 
 
@@ -864,17 +864,17 @@
 		Card ISR
 	 -------------------------------------------------------------------------- */
 static int qBri_ISR (struct _ISDN_ADAPTER* IoAdapter) {
-	dword volatile     *qBriIrq ;
+	dword volatile     __iomem *qBriIrq ;
 
 	PADAPTER_LIST_ENTRY QuadroList = IoAdapter->QuadroList ;
 
 	word              	i ;
 	int             	serviced = 0 ;
-	byte *p;
+	byte __iomem *p;
 
 	p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
 
-	if ( !(p[PLX9054_INTCSR] & 0x80) ) {
+	if ( !(READ_BYTE(&p[PLX9054_INTCSR]) & 0x80) ) {
 		DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
 		return (0) ;
 	}
@@ -884,7 +884,7 @@
  *	clear interrupt line (reset Local Interrupt Test Register)
  */
 	p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
-	qBriIrq = (dword volatile *)(&p[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_IRQ_TEST)  : (MQ_BREG_IRQ_TEST)]);
+	qBriIrq = (dword volatile __iomem *)(&p[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_IRQ_TEST)  : (MQ_BREG_IRQ_TEST)]);
 	WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF) ;
 	DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
 
@@ -908,8 +908,8 @@
 		Does disable the interrupt on the card
 	 -------------------------------------------------------------------------- */
 static void disable_qBri_interrupt (PISDN_ADAPTER IoAdapter) {
-	dword volatile *qBriIrq ;
-	byte *p;
+	dword volatile __iomem *qBriIrq ;
+	byte __iomem *p;
 
 	if ( IoAdapter->ControllerNumber > 0 )
 		return ;
@@ -917,11 +917,11 @@
  *	clear interrupt line (reset Local Interrupt Test Register)
  */
 	p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
-	p[PLX9054_INTCSR] = 0x00 ;	/* disable PCI interrupts */
+	WRITE_BYTE(&p[PLX9054_INTCSR], 0x00);	/* disable PCI interrupts */
 	DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
 
 	p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
-	qBriIrq = (dword volatile *)(&p[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_IRQ_TEST)  : (MQ_BREG_IRQ_TEST)]);
+	qBriIrq = (dword volatile __iomem *)(&p[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_IRQ_TEST)  : (MQ_BREG_IRQ_TEST)]);
 	WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF) ;
 	DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
 }
diff -Nru a/drivers/isdn/hardware/eicon/s_bri.c b/drivers/isdn/hardware/eicon/s_bri.c
--- a/drivers/isdn/hardware/eicon/s_bri.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/isdn/hardware/eicon/s_bri.c	2004-12-24 13:37:19 -08:00
@@ -41,11 +41,11 @@
   Investigate card state, recovery trace buffer
   -------------------------------------------------------------------------- */
 static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) {
- byte  *addrHi, *addrLo, *ioaddr ;
+ byte  __iomem *addrHi, *addrLo, *ioaddr ;
  word *Xlog ;
  dword   regs[4], i, size ;
  Xdesc   xlogDesc ;
- byte *Port;
+ byte __iomem *Port;
 /*
  * first read pointers and trap frame
  */
@@ -61,15 +61,15 @@
 /*
  * check for trapped MIPS 3xxx CPU, dump only exception frame
  */
- if ( READ_DWORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 )
+ if ( GET_DWORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 )
  {
   dump_trap_frame (IoAdapter, &((byte *)Xlog)[0x90]) ;
   IoAdapter->trapped = 1 ;
  }
- regs[0] = READ_DWORD(&((byte *)Xlog)[0x70]);
- regs[1] = READ_DWORD(&((byte *)Xlog)[0x74]);
- regs[2] = READ_DWORD(&((byte *)Xlog)[0x78]);
- regs[3] = READ_DWORD(&((byte *)Xlog)[0x7c]);
+ regs[0] = GET_DWORD(&((byte *)Xlog)[0x70]);
+ regs[1] = GET_DWORD(&((byte *)Xlog)[0x74]);
+ regs[2] = GET_DWORD(&((byte *)Xlog)[0x78]);
+ regs[3] = GET_DWORD(&((byte *)Xlog)[0x7c]);
  outpp (addrHi, (regs[1] >> 16) & 0x7F) ;
  outppw (addrLo, regs[1] & 0xFFFF) ;
  xlogDesc.cnt = inppw(ioaddr) ;
@@ -102,7 +102,7 @@
    Reset hardware
   --------------------------------------------------------------------- */
 static void reset_bri_hardware (PISDN_ADAPTER IoAdapter) {
- byte *p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
+ byte __iomem *p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
  outpp (p, 0x00) ;
  DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
 }
@@ -110,7 +110,7 @@
    Halt system
   --------------------------------------------------------------------- */
 static void stop_bri_hardware (PISDN_ADAPTER IoAdapter) {
- byte *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
+ byte __iomem *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
  if (p) {
   outpp (p, 0x00) ; /* disable interrupts ! */
  }
@@ -471,7 +471,7 @@
 #endif /* } */
 /******************************************************************************/
 static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) {
- byte *p;
+ byte __iomem *p;
 
  p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
  if ( !(inpp (p) & 0x01) ) {
@@ -493,7 +493,7 @@
   Disable IRQ in the card hardware
   -------------------------------------------------------------------------- */
 static void disable_bri_interrupt (PISDN_ADAPTER IoAdapter) {
- byte *p;
+ byte __iomem *p;
  p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
  if ( p )
  {
diff -Nru a/drivers/isdn/hardware/eicon/s_pri.c b/drivers/isdn/hardware/eicon/s_pri.c
--- a/drivers/isdn/hardware/eicon/s_pri.c	2004-12-24 13:37:33 -08:00
+++ b/drivers/isdn/hardware/eicon/s_pri.c	2004-12-24 13:37:33 -08:00
@@ -47,7 +47,7 @@
   Recovery XLOG buffer from the card
   ------------------------------------------------------------------------- */
 static void pri_cpu_trapped (PISDN_ADAPTER IoAdapter) {
- byte  *base ;
+ byte  __iomem *base ;
  word *Xlog ;
  dword   regs[4], TrapID, size ;
  Xdesc   xlogDesc ;
@@ -75,7 +75,7 @@
   size = IoAdapter->MemorySize - regs[0] ;
   if ( size > MAX_XLOG_SIZE )
    size = MAX_XLOG_SIZE ;
-  memcpy (Xlog, &base[regs[0]], size) ;
+  memcpy_fromio(Xlog, &base[regs[0]], size) ;
   xlogDesc.buf = Xlog ;
   xlogDesc.cnt = READ_WORD(&base[regs[1] & (IoAdapter->MemorySize - 1)]) ;
   xlogDesc.out = READ_WORD(&base[regs[2] & (IoAdapter->MemorySize - 1)]) ;
@@ -89,10 +89,10 @@
   Hardware reset of PRI card
   ------------------------------------------------------------------------- */
 static void reset_pri_hardware (PISDN_ADAPTER IoAdapter) {
- byte *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
- *p = _MP_RISC_RESET | _MP_LED1 | _MP_LED2 ;
+ byte __iomem *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
+ WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2);
  diva_os_wait (50) ;
- *p = 0x00 ;
+ WRITE_BYTE(p, 0x00);
  diva_os_wait (50) ;
  DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
 }
@@ -101,10 +101,10 @@
   ------------------------------------------------------------------------- */
 static void stop_pri_hardware (PISDN_ADAPTER IoAdapter) {
  dword i;
- byte *p;
- dword volatile *cfgReg = (dword volatile *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter);
- cfgReg[3] = 0x00000000 ;
- cfgReg[1] = 0x00000000 ;
+ byte __iomem *p;
+ dword volatile __iomem *cfgReg = (void __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter);
+ WRITE_DWORD(&cfgReg[3], 0);
+ WRITE_DWORD(&cfgReg[1], 0);
  DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg);
  IoAdapter->a.ram_out (&IoAdapter->a, &RAM->SWReg, SWREG_HALT_CPU) ;
  i = 0 ;
@@ -114,12 +114,12 @@
   i++ ;
  }
  DBG_TRC(("%s: PRI stopped (%d)", IoAdapter->Name, i))
- cfgReg = (dword volatile *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter);
+ cfgReg = (void __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter);
  WRITE_DWORD(&cfgReg[0],((dword)(~0x03E00000)));
  DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg);
  diva_os_wait (1) ;
  p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
- *p = _MP_RISC_RESET | _MP_LED1 | _MP_LED2 ;
+ WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2);
  DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
 }
 #if !defined(DIVA_USER_MODE_CARD_CONFIG) /* { */
@@ -491,15 +491,15 @@
   PRI Adapter interrupt Service Routine
    -------------------------------------------------------------------------- */
 static int pri_ISR (struct _ISDN_ADAPTER* IoAdapter) {
- byte *cfg = DIVA_OS_MEM_ATTACH_CFG(IoAdapter);
- if ( !((READ_DWORD((dword *)cfg)) & 0x80000000) ) {
+ byte __iomem *cfg = DIVA_OS_MEM_ATTACH_CFG(IoAdapter);
+ if ( !(READ_DWORD(cfg) & 0x80000000) ) {
   DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfg);
   return (0) ;
  }
  /*
   clear interrupt line
   */
- WRITE_DWORD(((dword *)cfg), (dword)~0x03E00000) ;
+ WRITE_DWORD(cfg, (dword)~0x03E00000) ;
  DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfg);
  IoAdapter->IrqCount++ ;
  if ( IoAdapter->Initialized )
@@ -512,9 +512,9 @@
   Disable interrupt in the card hardware
   ------------------------------------------------------------------------- */
 static void disable_pri_interrupt (PISDN_ADAPTER IoAdapter) {
- dword volatile *cfgReg = (dword volatile *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter) ;
- cfgReg[3] = 0x00000000 ;
- cfgReg[1] = 0x00000000 ;
+ dword volatile __iomem *cfgReg = (dword volatile __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter) ;
+ WRITE_DWORD(&cfgReg[3], 0);
+ WRITE_DWORD(&cfgReg[1], 0);
  WRITE_DWORD(&cfgReg[0], (dword)(~0x03E00000)) ;
  DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg);
 }
diff -Nru a/drivers/isdn/hardware/eicon/xdi_adapter.h b/drivers/isdn/hardware/eicon/xdi_adapter.h
--- a/drivers/isdn/hardware/eicon/xdi_adapter.h	2004-12-24 13:36:57 -08:00
+++ b/drivers/isdn/hardware/eicon/xdi_adapter.h	2004-12-24 13:36:57 -08:00
@@ -12,7 +12,7 @@
 	void *hdev;
 
 	dword bar[8];		/* contains context of appropriate BAR Register */
-	void *addr[8];		/* same bar, but mapped into memory */
+	void __iomem *addr[8];		/* same bar, but mapped into memory */
 	dword length[8];	/* bar length */
 	int mem_type_id[MAX_MEM_TYPE];
 	unsigned int qoffset;
diff -Nru a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
--- a/drivers/isdn/hisax/amd7930_fn.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/isdn/hisax/amd7930_fn.c	2004-12-24 13:37:00 -08:00
@@ -316,14 +316,14 @@
 								QuickHex(t, cs->rcvbuf, cs->rcvidx);
 								debugl1(cs, cs->dlog);
 							}
-                                                        /* moves recieved data in sk-buffer */
+                                                        /* moves received data in sk-buffer */
 							memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
 							skb_queue_tail(&cs->rq, skb);
 						}
 					}
 
 				}
-                                /* throw damaged packets away, reset recieve-buffer, indicate RX */
+                                /* throw damaged packets away, reset receive-buffer, indicate RX */
 				ptr = cs->rcvbuf;
 				cs->rcvidx = 0;
 				schedule_event(cs, D_RCVBUFREADY);
diff -Nru a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
--- a/drivers/isdn/hisax/avm_pci.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/isdn/hisax/avm_pci.c	2004-12-24 13:36:47 -08:00
@@ -794,13 +794,13 @@
 #ifdef CONFIG_PCI
 	if ((dev_avm = pci_find_device(PCI_VENDOR_ID_AVM,
 		PCI_DEVICE_ID_AVM_A1,  dev_avm))) {
+		if (pci_enable_device(dev_avm))
+			return(0);
 		cs->irq = dev_avm->irq;
 		if (!cs->irq) {
 			printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n");
 			return(0);
 		}
-		if (pci_enable_device(dev_avm))
-			return(0);
 		cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1);
 		if (!cs->hw.avm.cfg_reg) {
 			printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n");
diff -Nru a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
--- a/drivers/isdn/hisax/config.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/isdn/hisax/config.c	2004-12-24 13:37:19 -08:00
@@ -843,9 +843,8 @@
 	}
 	while (cnt) {
 		cs->cardmsg(cs, CARD_INIT, NULL);
-		set_current_state(TASK_UNINTERRUPTIBLE);
 		/* Timeout 10ms */
-		schedule_timeout((10 * HZ) / 1000);
+		msleep(10);
 		printk(KERN_INFO "%s: IRQ %d count %d\n",
 		       CardType[cs->typ], cs->irq, kstat_irqs(cs->irq));
 		if (kstat_irqs(cs->irq) == irq_cnt) {
diff -Nru a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
--- a/drivers/isdn/hisax/elsa.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/isdn/hisax/elsa.c	2004-12-24 13:36:19 -08:00
@@ -691,8 +691,7 @@
 				byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
 				byteout(cs->hw.elsa.timer, 0);
 				spin_unlock_irqrestore(&cs->lock, flags);
-				set_current_state(TASK_UNINTERRUPTIBLE);
-				schedule_timeout((110*HZ)/1000);
+				msleep(110);
 				spin_lock_irqsave(&cs->lock, flags);
 				cs->hw.elsa.ctrl_reg &= ~ELSA_ENA_TIMER_INT;
 				byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
diff -Nru a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
--- a/drivers/isdn/hisax/hfc_pci.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/isdn/hisax/hfc_pci.c	2004-12-24 13:36:48 -08:00
@@ -1619,8 +1619,7 @@
 			inithfcpci(cs);
 			reset_hfcpci(cs);
 			spin_unlock_irqrestore(&cs->lock, flags);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout((80 * HZ) / 1000);	/* Timeout 80ms */
+			msleep(80);				/* Timeout 80ms */
 			/* now switch timer interrupt off */
 			spin_lock_irqsave(&cs->lock, flags);
 			cs->hw.hfcpci.int_m1 &= ~HFCPCI_INTS_TIMER;
diff -Nru a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
--- a/drivers/isdn/hisax/hfc_sx.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/isdn/hisax/hfc_sx.c	2004-12-24 13:36:18 -08:00
@@ -314,8 +314,7 @@
 	cs->hw.hfcsx.int_m2 = 0;	/* interrupt output off ! */
 	Write_hfc(cs, HFCSX_INT_M2, cs->hw.hfcsx.int_m2);
 	Write_hfc(cs, HFCSX_CIRM, HFCSX_RESET);	/* Reset On */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout((30 * HZ) / 1000);	/* Timeout 30ms */
+	msleep(30);				/* Timeout 30ms */
 	Write_hfc(cs, HFCSX_CIRM, 0);	/* Reset Off */
 	del_timer(&cs->hw.hfcsx.timer);
 	release_region(cs->hw.hfcsx.base, 2); /* release IO-Block */
@@ -1367,8 +1366,7 @@
 			spin_lock_irqsave(&cs->lock, flags);
 			inithfcsx(cs);
 			spin_unlock_irqrestore(&cs->lock, flags);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout((80 * HZ) / 1000);	/* Timeout 80ms */
+			msleep(80);				/* Timeout 80ms */
 			/* now switch timer interrupt off */
 			spin_lock_irqsave(&cs->lock, flags);
 			cs->hw.hfcsx.int_m1 &= ~HFCSX_INTS_TIMER;
diff -Nru a/drivers/isdn/hisax/hfcscard.c b/drivers/isdn/hisax/hfcscard.c
--- a/drivers/isdn/hisax/hfcscard.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/isdn/hisax/hfcscard.c	2004-12-24 13:37:29 -08:00
@@ -125,8 +125,7 @@
 			init2bds0(cs);
 			spin_unlock_irqrestore(&cs->lock, flags);
 			delay = (80*HZ)/1000 +1;
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout((80*HZ)/1000);
+			msleep(80);
 			spin_lock_irqsave(&cs->lock, flags);
 			cs->hw.hfcD.ctmt |= HFCD_TIM800;
 			cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt); 
diff -Nru a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
--- a/drivers/isdn/hisax/hisax.h	2004-12-24 13:37:01 -08:00
+++ b/drivers/isdn/hisax/hisax.h	2004-12-24 13:37:01 -08:00
@@ -580,7 +580,7 @@
 
 struct teles0_hw {
 	unsigned int cfg_reg;
-	unsigned long membase;
+	void __iomem *membase;
 	unsigned long phymem;
 };
 
@@ -751,8 +751,8 @@
 struct isurf_hw {
 	unsigned int reset;
 	unsigned long phymem;
-	unsigned long isac;
-	unsigned long isar;
+	void __iomem *isac;
+	void __iomem *isar;
 	struct isar_reg isar_r;
 };
 
diff -Nru a/drivers/isdn/hisax/hisax_fcpcipnp.c b/drivers/isdn/hisax/hisax_fcpcipnp.c
--- a/drivers/isdn/hisax/hisax_fcpcipnp.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/isdn/hisax/hisax_fcpcipnp.c	2004-12-24 13:37:04 -08:00
@@ -996,27 +996,17 @@
 
 static int __init hisax_fcpcipnp_init(void)
 {
-	int retval, pci_nr_found;
+	int retval;
 
 	printk(KERN_INFO "hisax_fcpcipnp: Fritz!Card PCI/PCIv2/PnP ISDN driver v0.0.1\n");
 
 	retval = pci_register_driver(&fcpci_driver);
-	if (retval < 0)
+	if (retval)
 		goto out;
-	pci_nr_found = retval;
-	retval = 0;
-
 #ifdef __ISAPNP__
 	retval = pnp_register_driver(&fcpnp_driver);
 	if (retval < 0)
 		goto out_unregister_pci;
-#endif
-
-#if !defined(CONFIG_HOTPLUG) || defined(MODULE)
-	if (pci_nr_found + retval == 0) {
-		retval = -ENODEV;
-		goto out_unregister_isapnp;
-	}
 #endif
 	return 0;
 
diff -Nru a/drivers/isdn/hisax/isurf.c b/drivers/isdn/hisax/isurf.c
--- a/drivers/isdn/hisax/isurf.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/isdn/hisax/isurf.c	2004-12-24 13:36:55 -08:00
@@ -126,7 +126,7 @@
 release_io_isurf(struct IsdnCardState *cs)
 {
 	release_region(cs->hw.isurf.reset, 1);
-	iounmap((unsigned char *)cs->hw.isurf.isar);
+	iounmap(cs->hw.isurf.isar);
 	release_mem_region(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE);
 }
 
@@ -272,8 +272,7 @@
 		release_region(cs->hw.isurf.reset, 1);
 		return (0);
 	}
-	cs->hw.isurf.isar =
-		(unsigned long) ioremap(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE);
+	cs->hw.isurf.isar = ioremap(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE);
 	cs->hw.isurf.isac = cs->hw.isurf.isar + ISURF_ISAC_OFFSET;
 	printk(KERN_INFO
 	       "ISurf: defined at 0x%x 0x%lx IRQ %d\n",
diff -Nru a/drivers/isdn/hisax/teles0.c b/drivers/isdn/hisax/teles0.c
--- a/drivers/isdn/hisax/teles0.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/isdn/hisax/teles0.c	2004-12-24 13:36:49 -08:00
@@ -30,65 +30,65 @@
 #define bytein(addr) inb(addr)
 
 static inline u_char
-readisac(unsigned long adr, u_char off)
+readisac(void __iomem *adr, u_char off)
 {
 	return readb(adr + ((off & 1) ? 0x2ff : 0x100) + off);
 }
 
 static inline void
-writeisac(unsigned long adr, u_char off, u_char data)
+writeisac(void __iomem *adr, u_char off, u_char data)
 {
 	writeb(data, adr + ((off & 1) ? 0x2ff : 0x100) + off); mb();
 }
 
 
 static inline u_char
-readhscx(unsigned long adr, int hscx, u_char off)
+readhscx(void __iomem *adr, int hscx, u_char off)
 {
 	return readb(adr + (hscx ? 0x1c0 : 0x180) +
 		     ((off & 1) ? 0x1ff : 0) + off);
 }
 
 static inline void
-writehscx(unsigned long adr, int hscx, u_char off, u_char data)
+writehscx(void __iomem *adr, int hscx, u_char off, u_char data)
 {
 	writeb(data, adr + (hscx ? 0x1c0 : 0x180) +
 	       ((off & 1) ? 0x1ff : 0) + off); mb();
 }
 
 static inline void
-read_fifo_isac(unsigned long adr, u_char * data, int size)
+read_fifo_isac(void __iomem *adr, u_char * data, int size)
 {
 	register int i;
-	register u_char *ad = (u_char *)adr + 0x100;
+	register u_char __iomem *ad = adr + 0x100;
 	for (i = 0; i < size; i++)
 		data[i] = readb(ad);
 }
 
 static inline void
-write_fifo_isac(unsigned long adr, u_char * data, int size)
+write_fifo_isac(void __iomem *adr, u_char * data, int size)
 {
 	register int i;
-	register u_char *ad = (u_char *)adr + 0x100;
+	register u_char __iomem *ad = adr + 0x100;
 	for (i = 0; i < size; i++) {
 		writeb(data[i], ad); mb();
 	}
 }
 
 static inline void
-read_fifo_hscx(unsigned long adr, int hscx, u_char * data, int size)
+read_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size)
 {
 	register int i;
-	register u_char *ad = (u_char *) (adr + (hscx ? 0x1c0 : 0x180));
+	register u_char __iomem *ad = adr + (hscx ? 0x1c0 : 0x180);
 	for (i = 0; i < size; i++)
 		data[i] = readb(ad);
 }
 
 static inline void
-write_fifo_hscx(unsigned long adr, int hscx, u_char * data, int size)
+write_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size)
 {
 	int i;
-	register u_char *ad = (u_char *) (adr + (hscx ? 0x1c0 : 0x180));
+	register u_char __iomem *ad = adr + (hscx ? 0x1c0 : 0x180);
 	for (i = 0; i < size; i++) {
 		writeb(data[i], ad); mb();
 	}
@@ -188,7 +188,7 @@
 {
 	if (cs->hw.teles0.cfg_reg)
 		release_region(cs->hw.teles0.cfg_reg, 8);
-	iounmap((unsigned char *)cs->hw.teles0.membase);
+	iounmap(cs->hw.teles0.membase);
 	release_mem_region(cs->hw.teles0.phymem, TELES_IOMEM_SIZE);
 }
 
@@ -336,10 +336,9 @@
 			release_region(cs->hw.teles0.cfg_reg, 8);
 		return (0);
 	}
-	cs->hw.teles0.membase =
-		(unsigned long) ioremap(cs->hw.teles0.phymem, TELES_IOMEM_SIZE);
+	cs->hw.teles0.membase = ioremap(cs->hw.teles0.phymem, TELES_IOMEM_SIZE);
 	printk(KERN_INFO
-	       "HiSax: %s config irq:%d mem:0x%lX cfg:0x%X\n",
+	       "HiSax: %s config irq:%d mem:%p cfg:0x%X\n",
 	       CardType[cs->typ], cs->irq,
 	       cs->hw.teles0.membase, cs->hw.teles0.cfg_reg);
 	if (reset_teles0(cs)) {
diff -Nru a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c
--- a/drivers/isdn/hisax/telespci.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/isdn/hisax/telespci.c	2004-12-24 13:37:01 -08:00
@@ -43,7 +43,7 @@
 				} while (portdata & ZORAN_PO_RQ_PEN)
 
 static inline u_char
-readisac(unsigned long adr, u_char off)
+readisac(void __iomem *adr, u_char off)
 {
 	register unsigned int portdata;
 
@@ -60,7 +60,7 @@
 }
 
 static inline void
-writeisac(unsigned long adr, u_char off, u_char data)
+writeisac(void __iomem *adr, u_char off, u_char data)
 {
 	register unsigned int portdata;
 
@@ -76,7 +76,7 @@
 }
 
 static inline u_char
-readhscx(unsigned long adr, int hscx, u_char off)
+readhscx(void __iomem *adr, int hscx, u_char off)
 {
 	register unsigned int portdata;
 
@@ -92,7 +92,7 @@
 }
 
 static inline void
-writehscx(unsigned long adr, int hscx, u_char off, u_char data)
+writehscx(void __iomem *adr, int hscx, u_char off, u_char data)
 {
 	register unsigned int portdata;
 
@@ -107,7 +107,7 @@
 }
 
 static inline void
-read_fifo_isac(unsigned long adr, u_char * data, int size)
+read_fifo_isac(void __iomem *adr, u_char * data, int size)
 {
 	register unsigned int portdata;
 	register int i;
@@ -125,7 +125,7 @@
 }
 
 static void
-write_fifo_isac(unsigned long adr, u_char * data, int size)
+write_fifo_isac(void __iomem *adr, u_char * data, int size)
 {
 	register unsigned int portdata;
 	register int i;
@@ -142,7 +142,7 @@
 }
 
 static inline void
-read_fifo_hscx(unsigned long adr, int hscx, u_char * data, int size)
+read_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size)
 {
 	register unsigned int portdata;
 	register int i;
@@ -160,7 +160,7 @@
 }
 
 static inline void
-write_fifo_hscx(unsigned long adr, int hscx, u_char * data, int size)
+write_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size)
 {
 	unsigned int portdata;
 	register int i;
@@ -260,7 +260,7 @@
 void
 release_io_telespci(struct IsdnCardState *cs)
 {
-	iounmap((void *)cs->hw.teles0.membase);
+	iounmap(cs->hw.teles0.membase);
 }
 
 static int
@@ -309,7 +309,7 @@
 			printk(KERN_WARNING "Teles: No IRQ for PCI card found\n");
 			return(0);
 		}
-		cs->hw.teles0.membase = (u_long) ioremap(pci_resource_start(dev_tel, 0),
+		cs->hw.teles0.membase = ioremap(pci_resource_start(dev_tel, 0),
 			PAGE_SIZE);
 		printk(KERN_INFO "Found: Zoran, base-address: 0x%lx, irq: 0x%x\n",
 			pci_resource_start(dev_tel, 0), dev_tel->irq);
@@ -333,7 +333,7 @@
 	/* writel(0x00800000, cs->hw.teles0.membase + 0x200); */
 
 	printk(KERN_INFO
-	       "HiSax: %s config irq:%d mem:%lx\n",
+	       "HiSax: %s config irq:%d mem:%p\n",
 	       CardType[cs->typ], cs->irq,
 	       cs->hw.teles0.membase);
 
diff -Nru a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
--- a/drivers/isdn/hysdn/boardergo.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/isdn/hysdn/boardergo.c	2004-12-24 13:36:55 -08:00
@@ -21,6 +21,7 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/vmalloc.h>
+#include <linux/delay.h>
 #include <asm/io.h>
 
 #include "hysdn_defs.h"
@@ -246,8 +247,7 @@
 		/* the interrupts are still masked */
 
 		sti();
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout((20 * HZ) / 1000);	/* Timeout 20ms */
+		msleep_interruptible(20);		/* Timeout 20ms */
 
 		if (((tDpramBootSpooler *) card->dpram)->Len != DPRAM_SPOOLER_DATA_SIZE) {
 			if (card->debug_flags & LOG_POF_CARD)
@@ -386,8 +386,7 @@
 			return (0);	/* success */
 		}		/* data has arrived */
 		sti();
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout((50 * HZ) / 1000);	/* Timeout 50ms */
+		msleep_interruptible(50);		/* Timeout 50ms */
 	}			/* wait until timeout */
 
 	if (card->debug_flags & LOG_POF_CARD)
diff -Nru a/drivers/isdn/hysdn/hycapi.c b/drivers/isdn/hysdn/hycapi.c
--- a/drivers/isdn/hysdn/hycapi.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/isdn/hysdn/hycapi.c	2004-12-24 13:36:18 -08:00
@@ -246,8 +246,6 @@
 	rp->level3cnt = MaxLogicalConnections;
 	memcpy(&hycapi_applications[appl-1].rp, 
 	       rp, sizeof(capi_register_params));
-	
-/*        MOD_INC_USE_COUNT; */
 }
 
 /*********************************************************************
@@ -311,7 +309,6 @@
 	{
 		hycapi_release_internal(ctrl, appl);
 	}
-/*        MOD_DEC_USE_COUNT;  */
 }
 
 
diff -Nru a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c
--- a/drivers/isdn/hysdn/hysdn_sched.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/isdn/hysdn/hysdn_sched.c	2004-12-24 13:36:18 -08:00
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 #include <asm/io.h>
 
 #include "hysdn_defs.h"
@@ -160,8 +161,7 @@
 		if (card->debug_flags & LOG_SCHED_ASYN)
 			hysdn_addlog(card, "async tx-cfg delayed");
 
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout((20 * HZ) / 1000);	/* Timeout 20ms */
+		msleep_interruptible(20);		/* Timeout 20ms */
 		if (!--cnt) {
 			restore_flags(flags);
 			return (-ERR_ASYNC_TIME);	/* timed out */
@@ -190,8 +190,7 @@
 		if (card->debug_flags & LOG_SCHED_ASYN)
 			hysdn_addlog(card, "async tx-cfg waiting for tx-ready");
 
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout((20 * HZ) / 1000);	/* Timeout 20ms */
+		msleep_interruptible(20);		/* Timeout 20ms */
 		if (!--cnt) {
 			restore_flags(flags);
 			return (-ERR_ASYNC_TIME);	/* timed out */
diff -Nru a/drivers/isdn/i4l/Kconfig b/drivers/isdn/i4l/Kconfig
--- a/drivers/isdn/i4l/Kconfig	2004-12-24 13:36:34 -08:00
+++ b/drivers/isdn/i4l/Kconfig	2004-12-24 13:36:34 -08:00
@@ -99,7 +99,7 @@
 
 config ISDN_DIVERSION
 	tristate "Support isdn diversion services"
-	depends on BROKEN && BROKEN_ON_SMP
+	depends on ISDN && ISDN_I4L
 	help
 	  This option allows you to use some supplementary diversion
 	  services in conjunction with the HiSax driver on an EURO/DSS1
diff -Nru a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c
--- a/drivers/isdn/i4l/isdn_bsdcomp.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/isdn/i4l/isdn_bsdcomp.c	2004-12-24 13:37:19 -08:00
@@ -68,9 +68,9 @@
 #include <linux/errno.h>
 #include <linux/string.h>	/* used in new tty drivers */
 #include <linux/signal.h>	/* used in new tty drivers */
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
 #include <asm/types.h>
 
@@ -364,7 +364,7 @@
 		db->lens = (unsigned short *) vmalloc ((maxmaxcode + 1) *
 			sizeof (db->lens[0]));
 		if (!db->lens) {
-			bsd_free (db); /* calls MOD_DEC_USE_COUNT; */
+			bsd_free (db);
 			return (NULL);
 		}
 	}
diff -Nru a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
--- a/drivers/isdn/i4l/isdn_tty.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/isdn/i4l/isdn_tty.c	2004-12-24 13:37:03 -08:00
@@ -13,6 +13,7 @@
 
 #include <linux/config.h>
 #include <linux/isdn.h>
+#include <linux/delay.h>
 #include "isdn_common.h"
 #include "isdn_tty.h"
 #ifdef CONFIG_ISDN_AUDIO
@@ -26,8 +27,8 @@
 
 /* Prototypes */
 
-static int isdn_tty_edit_at(const char *, int, modem_info *, int);
-static void isdn_tty_check_esc(const u_char *, u_char, int, int *, u_long *, int);
+static int isdn_tty_edit_at(const char *, int, modem_info *);
+static void isdn_tty_check_esc(const u_char *, u_char, int, int *, u_long *);
 static void isdn_tty_modem_reset_regs(modem_info *, int);
 static void isdn_tty_cmd_ATA(modem_info *);
 static void isdn_tty_flush_buffer(struct tty_struct *);
@@ -390,15 +391,12 @@
  * ^S or ^Q is sent.
  */
 static int
-isdn_tty_end_vrx(const char *buf, int c, int from_user)
+isdn_tty_end_vrx(const char *buf, int c)
 {
 	char ch;
 
 	while (c--) {
-		if (from_user)
-			get_user(ch, buf);
-		else
-			ch = *buf;
+		ch = *buf;
 		if ((ch != 0x11) && (ch != 0x13))
 			return 1;
 		buf++;
@@ -1126,7 +1124,7 @@
  *  - If dialing, abort dial.
  */
 static int
-isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int count)
+isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count)
 {
 	int c;
 	int total = 0;
@@ -1135,8 +1133,6 @@
 
 	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_write"))
 		return 0;
-	if (from_user)
-		down(&info->write_sem);
 	/* See isdn_tty_senddown() */
 	atomic_inc(&info->xmit_lock);
 	while (1) {
@@ -1157,12 +1153,8 @@
 #endif
 				isdn_tty_check_esc(buf, m->mdmreg[REG_ESC], c,
 						   &(m->pluscount),
-						   &(m->lastplus),
-						   from_user);
-			if (from_user)
-				copy_from_user(&(info->xmit_buf[info->xmit_count]), buf, c);
-			else
-				memcpy(&(info->xmit_buf[info->xmit_count]), buf, c);
+						   &(m->lastplus));
+			memcpy(&(info->xmit_buf[info->xmit_count]), buf, c);
 #ifdef CONFIG_ISDN_AUDIO
 			if (info->vonline) {
 				int cc = isdn_tty_handleDLEdown(info, m, c);
@@ -1181,7 +1173,7 @@
 					/* Do NOT handle Ctrl-Q or Ctrl-S
 					 * when in full-duplex audio mode.
 					 */
-					if (isdn_tty_end_vrx(buf, c, from_user)) {
+					if (isdn_tty_end_vrx(buf, c)) {
 						info->vonline &= ~1;
 #ifdef ISDN_DEBUG_MODEM_VOICE
 						printk(KERN_DEBUG
@@ -1224,7 +1216,7 @@
 				isdn_tty_modem_result(RESULT_NO_CARRIER, info);
 				isdn_tty_modem_hup(info, 1);
 			} else
-				c = isdn_tty_edit_at(buf, c, info, from_user);
+				c = isdn_tty_edit_at(buf, c, info);
 		}
 		buf += c;
 		count -= c;
@@ -1238,8 +1230,6 @@
 		}
 		isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, 1);
 	}
-	if (from_user)
-		up(&info->write_sem);
 	return total;
 }
 
@@ -1748,8 +1738,7 @@
 	tty->closing = 0;
 	module_put(info->owner);
 	if (info->blocked_open) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/2);
+		msleep_interruptible(500);
 		wake_up_interruptible(&info->open_wait);
 	}
 	info->flags &= ~(ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CLOSING);
@@ -2467,10 +2456,8 @@
  */
 static void
 isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount,
-		   u_long *lastplus, int from_user)
+		   u_long *lastplus)
 {
-	char cbuf[3];
-
 	if (plus > 127)
 		return;
 	if (count > 3) {
@@ -2478,10 +2465,6 @@
 		count = 3;
 		*pluscount = 0;
 	}
-	if (from_user) {
-		copy_from_user(cbuf, p, count);
-		p = cbuf;
-	}
 	while (count > 0) {
 		if (*(p++) == plus) {
 			if ((*pluscount)++) {
@@ -3761,10 +3744,9 @@
  *   p        inputbuffer
  *   count    length of buffer
  *   channel  index to line (minor-device)
- *   user     flag: buffer is in userspace
  */
 static int
-isdn_tty_edit_at(const char *p, int count, modem_info * info, int user)
+isdn_tty_edit_at(const char *p, int count, modem_info * info)
 {
 	atemu *m = &info->emu;
 	int total = 0;
@@ -3773,10 +3755,7 @@
 	int cnt;
 
 	for (cnt = count; cnt > 0; p++, cnt--) {
-		if (user)
-			get_user(c, p);
-		else
-			c = *p;
+		c = *p;
 		total++;
 		if (c == m->mdmreg[REG_CR] || c == m->mdmreg[REG_LF]) {
 			/* Separator (CR or LF) */
diff -Nru a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
--- a/drivers/isdn/i4l/isdn_x25iface.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/isdn/i4l/isdn_x25iface.c	2004-12-24 13:36:47 -08:00
@@ -21,6 +21,7 @@
 #include <linux/netdevice.h>
 #include <linux/concap.h>
 #include <linux/wanrouter.h>
+#include <net/x25device.h>
 #include "isdn_x25iface.h"
 
 /* for debugging messages not to cause an oops when device pointer is NULL*/
@@ -191,12 +192,9 @@
   	IX25DEBUG( "isdn_x25iface_receive %s \n", MY_DEVNAME(cprot->net_dev) );
 	if ( ( (ix25_pdata_t*) (cprot->proto_data) ) 
 	     -> state == WAN_CONNECTED ){
-		skb -> dev = cprot -> net_dev;
-		skb -> protocol = htons(ETH_P_X25);
-		skb -> pkt_type = PACKET_HOST;
 		if( skb_push(skb, 1)){
 			skb -> data[0]=0x00;
-			skb -> mac.raw = skb -> data;
+			skb->protocol = x25_type_trans(skb, cprot->net_dev);
 			netif_rx(skb);
 			return 0;
 		}
@@ -224,10 +222,7 @@
 	*state_p = WAN_CONNECTED;
 	if( skb ){
 		*( skb_put(skb, 1) ) = 0x01;
-		skb -> mac.raw = skb -> data;
-		skb -> dev  = cprot -> net_dev;
-		skb -> protocol = htons(ETH_P_X25);
-		skb -> pkt_type = PACKET_HOST;
+		skb->protocol = x25_type_trans(skb, cprot->net_dev);
 		netif_rx(skb);
 		return 0;
 	} else {
@@ -256,10 +251,7 @@
 	skb = dev_alloc_skb(1);
 	if( skb ){
 		*( skb_put(skb, 1) ) = 0x02;
-		skb -> mac.raw = skb -> data;
-		skb -> dev  = cprot -> net_dev;
-		skb -> protocol = htons(ETH_P_X25);
-		skb -> pkt_type = PACKET_HOST;
+		skb->protocol = x25_type_trans(skb, cprot->net_dev);
 		netif_rx(skb);
 		return 0;
 	} else {
diff -Nru a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
--- a/drivers/isdn/icn/icn.c	2004-12-24 13:37:33 -08:00
+++ b/drivers/isdn/icn/icn.c	2004-12-24 13:37:33 -08:00
@@ -762,8 +762,7 @@
 #ifdef BOOT_DEBUG
 			printk(KERN_DEBUG "Loader %d TO?\n", cardnumber);
 #endif
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(ICN_BOOT_TIMEOUT1);
+			msleep_interruptible(ICN_BOOT_TIMEOUT1);
 		} else {
 #ifdef BOOT_DEBUG
 			printk(KERN_DEBUG "Loader %d OK\n", cardnumber);
@@ -788,8 +787,7 @@
 int slsec = sec; \
   printk(KERN_DEBUG "SLEEP(%d)\n",slsec); \
   while (slsec) { \
-    current->state = TASK_INTERRUPTIBLE; \
-    schedule_timeout(HZ); \
+    msleep_interruptible(1000); \
     slsec--; \
   } \
 }
@@ -950,7 +948,7 @@
 				icn_maprelease_channel(card, 0);
 				return -EIO;
 			}
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			schedule_timeout(10);
 		}
 	}
@@ -974,8 +972,7 @@
 #ifdef BOOT_DEBUG
 			printk(KERN_DEBUG "Proto TO?\n");
 #endif
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(ICN_BOOT_TIMEOUT1);
+			msleep_interruptible(ICN_BOOT_TIMEOUT1);
 		} else {
 			if ((card->secondhalf) || (!card->doubleS0)) {
 #ifdef BOOT_DEBUG
@@ -1271,9 +1268,9 @@
 						if (!card->leased) {
 							card->leased = 1;
 							while (card->ptype == ISDN_PTYPE_UNKNOWN) {
-								schedule_timeout(ICN_BOOT_TIMEOUT1);
+								msleep_interruptible(ICN_BOOT_TIMEOUT1);
 							}
-							schedule_timeout(ICN_BOOT_TIMEOUT1);
+							msleep_interruptible(ICN_BOOT_TIMEOUT1);
 							sprintf(cbuf, "00;FV2ON\n01;EAZ%c\n02;EAZ%c\n",
 								(a & 1)?'1':'C', (a & 2)?'2':'C');
 							i = icn_writecmd(cbuf, strlen(cbuf), 0, card);
diff -Nru a/drivers/isdn/icn/icn.h b/drivers/isdn/icn/icn.h
--- a/drivers/isdn/icn/icn.h	2004-12-24 13:37:32 -08:00
+++ b/drivers/isdn/icn/icn.h	2004-12-24 13:37:32 -08:00
@@ -70,8 +70,7 @@
 #define ICN_FLAGS_RUNNING  4    /* Cards driver activated                  */
 #define ICN_FLAGS_RBTIMER  8    /* cyclic scheduling of B-Channel-poll     */
 
-#define ICN_BOOT_TIMEOUT1  (HZ) /* Delay for Boot-download (jiffies)       */
-#define ICN_CHANLOCK_DELAY (HZ/10)	/* Delay for Channel-mapping (jiffies)     */
+#define ICN_BOOT_TIMEOUT1  1000 /* Delay for Boot-download (msecs)         */
 
 #define ICN_TIMER_BCREAD (HZ/100)	/* B-Channel poll-cycle                    */
 #define ICN_TIMER_DCREAD (HZ/2) /* D-Channel poll-cycle                    */
diff -Nru a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
--- a/drivers/isdn/isdnloop/isdnloop.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/isdn/isdnloop/isdnloop.c	2004-12-24 13:36:16 -08:00
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/sched.h>
 #include "isdnloop.h"
 
 static char *revision = "$Revision: 1.11.6.7 $";
@@ -1161,8 +1162,10 @@
 						if (!card->leased) {
 							card->leased = 1;
 							while (card->ptype == ISDN_PTYPE_UNKNOWN) {
+								set_current_state(TASK_INTERRUPTIBLE);
 								schedule_timeout(10);
 							}
+							set_current_state(TASK_INTERRUPTIBLE);
 							schedule_timeout(10);
 							sprintf(cbuf, "00;FV2ON\n01;EAZ1\n02;EAZ2\n");
 							i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card);
diff -Nru a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
--- a/drivers/isdn/pcbit/drv.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/isdn/pcbit/drv.c	2004-12-24 13:37:03 -08:00
@@ -859,7 +859,7 @@
 		printk(KERN_DEBUG "Bank3 = %02x\n", 
 		       readb(dev->sh_mem + BANK3));
 #endif
-		*(dev->sh_mem + BANK4) = 0x40U;
+		writeb(0x40, dev->sh_mem + BANK4);
 
 		/* warn the upper layer */
 		ctl.driver = dev->id;
diff -Nru a/drivers/isdn/sc/card.h b/drivers/isdn/sc/card.h
--- a/drivers/isdn/sc/card.h	2004-12-24 13:37:29 -08:00
+++ b/drivers/isdn/sc/card.h	2004-12-24 13:37:29 -08:00
@@ -24,24 +24,25 @@
  * We need these if they're not already included
  */
 #include <linux/timer.h>
+#include <linux/time.h>
 #include <linux/isdnif.h>
 #include "message.h"
 
 /*
  * Amount of time to wait for a reset to complete
  */
-#define CHECKRESET_TIME		milliseconds(4000)
+#define CHECKRESET_TIME		msecs_to_jiffies(4000)
 
 /*
  * Amount of time between line status checks
  */
-#define CHECKSTAT_TIME		milliseconds(8000)
+#define CHECKSTAT_TIME		msecs_to_jiffies(8000)
 
 /*
  * The maximum amount of time to wait for a message response
  * to arrive. Use exclusively by send_and_receive
  */
-#define SAR_TIMEOUT		milliseconds(10000)
+#define SAR_TIMEOUT		msecs_to_jiffies(10000)
 
 /*
  * Macro to determine is a card id is valid
diff -Nru a/drivers/isdn/sc/hardware.h b/drivers/isdn/sc/hardware.h
--- a/drivers/isdn/sc/hardware.h	2004-12-24 13:37:29 -08:00
+++ b/drivers/isdn/sc/hardware.h	2004-12-24 13:37:29 -08:00
@@ -104,9 +104,6 @@
  * Some handy macros
  */
 
-/* Return the number of jiffies in a given number of msecs */
-#define milliseconds(x)	(((x)*HZ)/1000)
-
 /* Determine if a channel number is valid for the adapter */
 #define IS_VALID_CHANNEL(y,x)	((x>0) && (x <= sc_adapter[y]->channels))
 
diff -Nru a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
--- a/drivers/isdn/sc/init.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/isdn/sc/init.c	2004-12-24 13:37:02 -08:00
@@ -7,6 +7,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 #include "includes.h"
 #include "hardware.h"
 #include "card.h"
@@ -167,8 +168,7 @@
 		if(do_reset) {
 			pr_debug("Doing a SAFE probe reset\n");
 			outb(0xFF, io[b] + RESET_OFFSET);
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(milliseconds(10000));
+			msleep_interruptible(10000);
 		}
 		pr_debug("RAM Base for board %d is 0x%x, %s probe\n", b, ram[b],
 			ram[b] == 0 ? "will" : "won't");
@@ -500,8 +500,7 @@
 	 * Try to identify a PRI card
 	 */
 	outb(PRI_BASEPG_VAL, pgport);
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ);
+	msleep_interruptible(1000);
 	sig = readl(rambase + SIG_OFFSET);
 	pr_debug("Looking for a signature, got 0x%x\n", sig);
 	if(sig == SIGNATURE)
@@ -511,8 +510,7 @@
 	 * Try to identify a PRI card
 	 */
 	outb(BRI_BASEPG_VAL, pgport);
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ);
+	msleep_interruptible(1000);
 	sig = readl(rambase + SIG_OFFSET);
 	pr_debug("Looking for a signature, got 0x%x\n", sig);
 	if(sig == SIGNATURE)
diff -Nru a/drivers/isdn/tpam/tpam.h b/drivers/isdn/tpam/tpam.h
--- a/drivers/isdn/tpam/tpam.h	2004-12-24 13:36:19 -08:00
+++ b/drivers/isdn/tpam/tpam.h	2004-12-24 13:36:19 -08:00
@@ -14,6 +14,8 @@
 #ifndef _TPAM_PRIV_H_
 #define _TPAM_PRIV_H_
 
+//#define DEBUG /* uncomment if you want debugging output */
+#include <linux/kernel.h>
 #include <linux/isdnif.h>
 #include <linux/init.h>
 #include <linux/workqueue.h>
@@ -75,7 +77,7 @@
 typedef struct tpam_card {
 	struct tpam_card *next;		/* next card in list */
 	unsigned int irq;		/* IRQ used by this board */
-	unsigned long bar0;		/* ioremapped bar0 */
+	void __iomem *bar0;		/* ioremapped bar0 */
 	int id;				/* id of the board */
 	isdn_if interface;		/* isdn link-level pointer */
 	int channels_used;		/* number of channels actually used */
@@ -169,12 +171,12 @@
 extern u32 tpam_findchannel(tpam_card *, u32);
 
 /* Function prototypes from tpam_memory.c */
-extern void copy_to_pam_dword(tpam_card *, const void *, u32);
-extern void copy_to_pam(tpam_card *, void *, const void *, u32);
-extern u32 copy_from_pam_dword(tpam_card *, const void *);
-extern void copy_from_pam(tpam_card *, void *, const void *, u32);
-extern int copy_from_pam_to_user(tpam_card *, void __user *, const void *, u32);
-extern int copy_from_user_to_pam(tpam_card *, void *, const void __user *, u32);
+extern void copy_to_pam_dword(tpam_card *, u32, u32);
+extern void copy_to_pam(tpam_card *, u32, const void *, u32);
+extern u32 copy_from_pam_dword(tpam_card *, u32);
+extern void copy_from_pam(tpam_card *, void *, u32, u32);
+extern int copy_from_pam_to_user(tpam_card *, void __user *, u32, u32);
+extern int copy_from_user_to_pam(tpam_card *, u32, const void __user *, u32);
 extern int tpam_verify_area(u32, u32);
 
 /* Function prototypes from tpam_nco.c */
@@ -223,14 +225,5 @@
 extern void hdlc_encode_modem(u8 *, u32, u8 *, u32 *);
 extern void hdlc_no_accm_encode(u8 *, u32, u8 *, u32 *);
 extern u32 hdlc_no_accm_decode(u8 *, u32);
-
-/* Define this to enable debug tracing prints */
-#undef DEBUG
-
-#ifdef DEBUG
-#define dprintk printk
-#else
-#define dprintk while(0) printk
-#endif
 
 #endif /* _TPAM_H_ */
diff -Nru a/drivers/isdn/tpam/tpam_commands.c b/drivers/isdn/tpam/tpam_commands.c
--- a/drivers/isdn/tpam/tpam_commands.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/isdn/tpam/tpam_commands.c	2004-12-24 13:36:18 -08:00
@@ -21,8 +21,8 @@
 #include "tpam.h"
 
 /* Local functions prototypes */
-static int tpam_command_ioctl_dspload(tpam_card *, u32);
-static int tpam_command_ioctl_dspsave(tpam_card *, u32);
+static int tpam_command_ioctl_dspload(tpam_card *, unsigned long);
+static int tpam_command_ioctl_dspsave(tpam_card *, unsigned long);
 static int tpam_command_ioctl_dsprun(tpam_card *);
 static int tpam_command_ioctl_loopmode(tpam_card *, u8);
 static int tpam_command_dial(tpam_card *, u32, u8 *);
@@ -45,7 +45,7 @@
 	tpam_card *card;
 	unsigned long argp;
 
-	dprintk("TurboPAM(tpam_command) card=%d, command=%d\n", 
+	pr_debug("TurboPAM(tpam_command) card=%d, command=%d\n",
 		c->driver, c->command);	
 
 	/* search for the board */
@@ -75,7 +75,7 @@
 					return tpam_command_ioctl_loopmode(card,
 									   0);
 				default:
-					dprintk("TurboPAM(tpam_command): "
+					pr_debug("TurboPAM(tpam_command): "
 						"invalid tpam ioctl %ld\n", 
 						c->arg);	
 					return -EINVAL;
@@ -95,7 +95,7 @@
 		case ISDN_CMD_PROCEED:
 			return tpam_command_proceed(card, c->arg);
 		default:
-			dprintk("TurboPAM(tpam_command): "
+			pr_debug("TurboPAM(tpam_command): "
 				"unknown or unused isdn ioctl %d\n", 
 				c->command);	
 			return -EINVAL;
@@ -114,10 +114,10 @@
  *
  * Return: 0 if OK, <0 on errors.
  */
-static int tpam_command_ioctl_dspload(tpam_card *card, u32 arg) {
+static int tpam_command_ioctl_dspload(tpam_card *card, unsigned long arg) {
 	tpam_dsp_ioctl tdl;
 
-	dprintk("TurboPAM(tpam_command_ioctl_dspload): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_command_ioctl_dspload): card=%d\n", card->id);
 
 	/* get the IOCTL parameter from userspace */
 	if (copy_from_user(&tdl, (void __user *)arg, sizeof(tpam_dsp_ioctl)))
@@ -130,7 +130,7 @@
 		return -EPERM;
 
 	/* write the data in the board's memory */
-	return copy_from_user_to_pam(card, (void *)tdl.address, 
+	return copy_from_user_to_pam(card, tdl.address, 
 				     (void __user *)arg + sizeof(tpam_dsp_ioctl), 
 				     tdl.data_len);
 }
@@ -144,10 +144,10 @@
  *
  * Return: 0 if OK, <0 on errors.
  */
-static int tpam_command_ioctl_dspsave(tpam_card *card, u32 arg) {
+static int tpam_command_ioctl_dspsave(tpam_card *card, unsigned long arg) {
 	tpam_dsp_ioctl tdl;
 
-	dprintk("TurboPAM(tpam_command_ioctl_dspsave): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_command_ioctl_dspsave): card=%d\n", card->id);
 
 	/* get the IOCTL parameter from userspace */
 	if (copy_from_user(&tdl, (void __user *)arg, sizeof(tpam_dsp_ioctl)))
@@ -159,7 +159,7 @@
 
 	/* read the data from the board's memory */
 	return copy_from_pam_to_user(card, (void __user *)arg + sizeof(tpam_dsp_ioctl),
-				     (void *)tdl.address, tdl.data_len);
+				     tdl.address, tdl.data_len);
 }
 
 /*
@@ -178,7 +178,7 @@
 	isdn_ctrl ctrl;
 	struct sk_buff *skb;
 
-	dprintk("TurboPAM(tpam_command_ioctl_dsprun): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_command_ioctl_dsprun): card=%d\n", card->id);
 
 	/* board must _not_ be running */
 	if (card->running)
@@ -186,7 +186,7 @@
 
 	/* reset the board */
 	spin_lock_irq(&card->lock);
-	copy_to_pam_dword(card, (void *)TPAM_MAGICNUMBER_REGISTER, 0xdeadface);
+	copy_to_pam_dword(card, TPAM_MAGICNUMBER_REGISTER, 0xdeadface);
 	readl(card->bar0 + TPAM_DSPINT_REGISTER);
 	readl(card->bar0 + TPAM_HINTACK_REGISTER);
 	spin_unlock_irq(&card->lock);
@@ -196,7 +196,7 @@
 	while (time_before(jiffies, timeout)) {
 		spin_lock_irq(&card->lock);
 		signature = copy_from_pam_dword(card, 
-						(void *)TPAM_MAGICNUMBER_REGISTER);
+						TPAM_MAGICNUMBER_REGISTER);
 		spin_unlock_irq(&card->lock);
 		if (signature == TPAM_MAGICNUMBER)
 			break;
@@ -297,7 +297,7 @@
 	struct sk_buff *skb;
 	isdn_ctrl ctrl;
 
-	dprintk("TurboPAM(tpam_command_dial): card=%d, channel=%lu, phone=%s\n",
+	pr_debug("TurboPAM(tpam_command_dial): card=%d, channel=%lu, phone=%s\n",
 		card->id, (unsigned long)channel, phone);
 
 	/* board must be running */
@@ -341,7 +341,7 @@
  */
 static int tpam_command_setl2(tpam_card *card, u32 channel, u8 proto) {
 
-	dprintk("TurboPAM(tpam_command_setl2): card=%d, channel=%lu, proto=%d\n",
+	pr_debug("TurboPAM(tpam_command_setl2): card=%d, channel=%lu, proto=%d\n",
 		card->id, (unsigned long)channel, proto);
 
 	/* board must be running */
@@ -376,7 +376,7 @@
 	isdn_ctrl ctrl;
 	struct sk_buff *skb;
 
-	dprintk("TurboPAM(tpam_command_acceptd): card=%d, channel=%lu\n",
+	pr_debug("TurboPAM(tpam_command_acceptd): card=%d, channel=%lu\n",
 		card->id, (unsigned long)channel);
 
 	/* board must be running */
@@ -410,7 +410,7 @@
 static int tpam_command_acceptb(tpam_card *card, u32 channel) {
 	isdn_ctrl ctrl;
 
-	dprintk("TurboPAM(tpam_command_acceptb): card=%d, channel=%lu\n",
+	pr_debug("TurboPAM(tpam_command_acceptb): card=%d, channel=%lu\n",
 		card->id, (unsigned long)channel);
 
 	/* board must be running */
@@ -437,7 +437,7 @@
 static int tpam_command_hangup(tpam_card *card, u32 channel) {
 	struct sk_buff *skb;
 
-	dprintk("TurboPAM(tpam_command_hangup): card=%d, channel=%lu\n",
+	pr_debug("TurboPAM(tpam_command_hangup): card=%d, channel=%lu\n",
 		card->id, (unsigned long)channel);
 
 	/* board must be running */
@@ -464,7 +464,7 @@
 static int tpam_command_proceed(tpam_card *card, u32 channel) {
 	struct sk_buff *skb;
 
-	dprintk("TurboPAM(tpam_command_proceed): card=%d, channel=%lu\n",
+	pr_debug("TurboPAM(tpam_command_proceed): card=%d, channel=%lu\n",
 		card->id, (unsigned long)channel);
 
 	/* board must be running */
@@ -496,7 +496,7 @@
 	void *finaldata;
 	u32 finallen;
 
-	dprintk("TurboPAM(tpam_writebuf_skb): "
+	pr_debug("TurboPAM(tpam_writebuf_skb): "
 		"card=%d, channel=%ld, ack=%d, data size=%d\n", 
 		driverId, (unsigned long)channel, ack, skb->len);
 
@@ -531,14 +531,14 @@
 		if (!(tempdata = (void *)__get_free_page(GFP_ATOMIC))) {
 			printk(KERN_ERR "TurboPAM(tpam_writebuf_skb): "
 			       "get_free_page failed\n");
-			free_page((u32)finaldata);
+			free_page((unsigned long)finaldata);
 			return -ENOMEM;
 		}
 		hdlc_no_accm_encode(skb->data, skb->len, tempdata, &templen);
 		finallen = tpam_hdlc_encode(tempdata, finaldata, 
 				       &card->channels[channel].hdlcshift, 
 				       templen);
-		free_page((u32)tempdata);
+		free_page((unsigned long)tempdata);
 	}
 
 	/* free the old sk_buff */
@@ -548,13 +548,13 @@
 	skb = build_U3DataReq(card->channels[channel].ncoid, finaldata, 
 			      finallen, ack, orig_size);
 	if (!skb) {
-		free_page((u32)finaldata);
+		free_page((unsigned long)finaldata);
 		return -ENOMEM;
 	}
 	tpam_enqueue_data(&card->channels[channel], skb);
 
 	/* free the temporary memory */
-	free_page((u32)finaldata);
+	free_page((unsigned long)finaldata);
 	return orig_size;
 }
 
@@ -569,7 +569,7 @@
 	u8 status;
 	u32 channel;
 
-	dprintk("TurboPAM(tpam_recv_ACreateNCOCnf): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_recv_ACreateNCOCnf): card=%d\n", card->id);
 
 	/* parse the message contents */
 	if (parse_ACreateNCOCnf(skb, &status, &ncoid))
@@ -614,7 +614,7 @@
 	u8 status;
 	u32 channel;
 
-	dprintk("TurboPAM(tpam_recv_ADestroyNCOCnf): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_recv_ADestroyNCOCnf): card=%d\n", card->id);
 
 	/* parse the message contents */
 	if (parse_ADestroyNCOCnf(skb, &status, &ncoid))
@@ -647,7 +647,7 @@
 	u32 channel;
 	isdn_ctrl ctrl;
 
-	dprintk("TurboPAM(tpam_recv_CConnectCnf): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_recv_CConnectCnf): card=%d\n", card->id);
 
 	/* parse the message contents */
 	if (parse_CConnectCnf(skb, &ncoid))
@@ -685,7 +685,7 @@
 	isdn_ctrl ctrl;
 	int status;
 
-	dprintk("TurboPAM(tpam_recv_CConnectInd): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_recv_CConnectInd): card=%d\n", card->id);
 
 	/* parse the message contents */
 	if (parse_CConnectInd(skb, &ncoid, &hdlc, calling, called, &plan, &screen))
@@ -720,13 +720,13 @@
 		case 4:
 			/* call accepted, link layer will send us a ACCEPTD 
 			 * command later */
-			dprintk("TurboPAM(tpam_recv_CConnectInd): "
+			pr_debug("TurboPAM(tpam_recv_CConnectInd): "
 				"card=%d, channel=%d, icall waiting, status=%d\n", 
 				card->id, channel, status);
 			break;
 		default:
 			/* call denied, we build and send a CDisconnectReq */
-			dprintk("TurboPAM(tpam_recv_CConnectInd): "
+			pr_debug("TurboPAM(tpam_recv_CConnectInd): "
 				"card=%d, channel=%d, icall denied, status=%d\n", 
 				card->id, channel, status);
 			skb = build_CDisconnectReq(ncoid);
@@ -749,7 +749,7 @@
 	u32 cause;
 	isdn_ctrl ctrl;
 
-	dprintk("TurboPAM(tpam_recv_CDisconnectInd): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_recv_CDisconnectInd): card=%d\n", card->id);
 
 	/* parse the message contents */
 	if (parse_CDisconnectInd(skb, &ncoid, &cause))
@@ -794,7 +794,7 @@
 	u32 cause;
 	isdn_ctrl ctrl;
 
-	dprintk("TurboPAM(tpam_recv_CDisconnectCnf): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_recv_CDisconnectCnf): card=%d\n", card->id);
 
 	/* parse the message contents */
 	if (parse_CDisconnectCnf(skb, &ncoid, &cause))
@@ -835,7 +835,7 @@
 	u16 len;
 	struct sk_buff *result;
 
-	dprintk("TurboPAM(tpam_recv_U3DataInd): card=%d, datalen=%d\n", 
+	pr_debug("TurboPAM(tpam_recv_U3DataInd): card=%d, datalen=%d\n",
 		card->id, skb->len);
 
 	/* parse the message contents */
@@ -865,11 +865,11 @@
 		if (!(result = alloc_skb(templen, GFP_ATOMIC))) {
 			printk(KERN_ERR "TurboPAM(tpam_recv_U3DataInd): "
 			       "alloc_skb failed\n");
-			free_page((u32)tempdata);
+			free_page((unsigned long)tempdata);
 			return;
 		}
 		memcpy(skb_put(result, templen), tempdata, templen);
-		free_page((u32)tempdata);
+		free_page((unsigned long)tempdata);
 	}
 	else {
 		/* modem mode */
@@ -914,7 +914,7 @@
 	u32 channel;
 	u8 ready;
 
-	dprintk("TurboPAM(tpam_recv_U3ReadyToReceiveInd): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_recv_U3ReadyToReceiveInd): card=%d\n", card->id);
 
 	/* parse the message contents */
 	if (parse_U3ReadyToReceiveInd(skb, &ncoid, &ready))
@@ -943,7 +943,7 @@
 static void tpam_statcallb_run(unsigned long parm) {
 	tpam_statcallb_data *ds = (tpam_statcallb_data *)parm;
 
-	dprintk("TurboPAM(tpam_statcallb_run)\n");
+	pr_debug("TurboPAM(tpam_statcallb_run)\n");
 
 	(* ds->card->interface.statcallb)(&ds->ctrl);
 
@@ -961,7 +961,7 @@
 	struct timer_list *timer;
 	tpam_statcallb_data *ds;
 
-	dprintk("TurboPAM(tpam_statcallb): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_statcallb): card=%d\n", card->id);
 
 	if (!(timer = (struct timer_list *) kmalloc(sizeof(struct timer_list), 
 						    GFP_ATOMIC))) {
diff -Nru a/drivers/isdn/tpam/tpam_main.c b/drivers/isdn/tpam/tpam_main.c
--- a/drivers/isdn/tpam/tpam_main.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/isdn/tpam/tpam_main.c	2004-12-24 13:37:02 -08:00
@@ -88,10 +88,10 @@
 	tpam_card *card, *c;
 	int i, err;
 
-	if (pci_enable_device(dev)) {
+	if ((err = pci_enable_device(dev))) {
 		printk(KERN_ERR "TurboPAM: can't enable PCI device at %s\n",
 			pci_name(dev));
-		return -ENODEV;
+		return err;
 	}
 
 	/* allocate memory for the board structure */
@@ -118,7 +118,7 @@
 	}
 
 	/* remap board memory */
-	if (!(card->bar0 = (unsigned long) ioremap(pci_resource_start(dev, 0),
+	if (!(card->bar0 = ioremap(pci_resource_start(dev, 0),
 						   0x800000))) {
 		printk(KERN_ERR "TurboPAM: tpam_register_card: "
 		       "unable to remap bar0\n");
@@ -130,12 +130,12 @@
 	readl(card->bar0 + TPAM_RESETPAM_REGISTER);
 
 	/* initialisation magic :-( */
-	copy_to_pam_dword(card, (void *)0x01800008, 0x00000030);
-	copy_to_pam_dword(card, (void *)0x01800010, 0x00000030);
-	copy_to_pam_dword(card, (void *)0x01800014, 0x42240822);
-	copy_to_pam_dword(card, (void *)0x01800018, 0x07114000);
-	copy_to_pam_dword(card, (void *)0x0180001c, 0x00000400);
-	copy_to_pam_dword(card, (void *)0x01840070, 0x00000010);
+	copy_to_pam_dword(card, 0x01800008, 0x00000030);
+	copy_to_pam_dword(card, 0x01800010, 0x00000030);
+	copy_to_pam_dword(card, 0x01800014, 0x42240822);
+	copy_to_pam_dword(card, 0x01800018, 0x07114000);
+	copy_to_pam_dword(card, 0x0180001c, 0x00000400);
+	copy_to_pam_dword(card, 0x01840070, 0x00000010);
 
 	/* fill the ISDN link layer structure */
 	card->interface.owner = THIS_MODULE;
@@ -201,7 +201,7 @@
 	return 0;
 
 err_out_iounmap:
-	iounmap((void *)card->bar0);
+	iounmap(card->bar0);
 
 err_out_free_irq:
 	free_irq(card->irq, card);
@@ -231,7 +231,7 @@
 	free_irq(card->irq, card);
 
 	/* release mapped memory */
-	iounmap((void *)card->bar0);
+	iounmap(card->bar0);
 
 	pci_disable_device(pcidev);
 }
diff -Nru a/drivers/isdn/tpam/tpam_memory.c b/drivers/isdn/tpam/tpam_memory.c
--- a/drivers/isdn/tpam/tpam_memory.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/isdn/tpam/tpam_memory.c	2004-12-24 13:36:31 -08:00
@@ -23,14 +23,14 @@
  * 	addr: the address (in the board memory)
  * 	val: the value to put into the memory.
  */
-void copy_to_pam_dword(tpam_card *card, const void *addr, u32 val) {
+void copy_to_pam_dword(tpam_card *card, u32 addr, u32 val) {
 
 	/* set the page register */
-	writel(((unsigned long)addr) | TPAM_PAGE_SIZE, 
+	writel(addr | TPAM_PAGE_SIZE, 
 	       card->bar0 + TPAM_PAGE_REGISTER);
 
 	/* write the value */
-	writel(val, card->bar0 + (((unsigned long)addr) & TPAM_PAGE_SIZE));
+	writel(val, card->bar0 + (addr & TPAM_PAGE_SIZE));
 }
 
 /*
@@ -42,15 +42,15 @@
  * 	from: the source address (in the kernel memory)
  * 	n: number of bytes
  */
-void copy_to_pam(tpam_card *card, void *to, const void *from, u32 n) {
+void copy_to_pam(tpam_card *card, u32 to, const void *from, u32 n) {
 	u32 page, offset, count;
 
 	/* need to write in dword ! */
 	while (n & 3) n++;
 
 	while (n) {
-		page = ((u32)to) | TPAM_PAGE_SIZE;
-		offset = ((u32)to) & TPAM_PAGE_SIZE;
+		page = to | TPAM_PAGE_SIZE;
+		offset = to & TPAM_PAGE_SIZE;
 		count = n < TPAM_PAGE_SIZE - offset
 				? n
 				: TPAM_PAGE_SIZE - offset;
@@ -59,7 +59,7 @@
 		writel(page, card->bar0 + TPAM_PAGE_REGISTER);
 
 		/* copy the data */
-		memcpy_toio((void *)(card->bar0 + offset), from, count);
+		memcpy_toio(card->bar0 + offset, from, count);
 		
 		from += count;
 		to += count;
@@ -75,14 +75,14 @@
  *
  * Return: the value read into the memory.
  */
-u32 copy_from_pam_dword(tpam_card *card, const void *addr) {
+u32 copy_from_pam_dword(tpam_card *card, u32 addr) {
 
 	/* set the page register */
 	writel(((u32)addr) | TPAM_PAGE_SIZE, 
 	       card->bar0 + TPAM_PAGE_REGISTER);
 
 	/* read the data */
-	return readl(card->bar0 + (((u32)addr) & TPAM_PAGE_SIZE));
+	return readl(card->bar0 + (addr & TPAM_PAGE_SIZE));
 }
 
 /*
@@ -93,12 +93,12 @@
  * 	from: the source address (in the board memory)
  * 	n: number of bytes
  */
-void copy_from_pam(tpam_card *card, void *to, const void *from, u32 n) {
+void copy_from_pam(tpam_card *card, void *to, u32 from, u32 n) {
 	u32 page, offset, count;
 
 	while (n) {
-		page = ((u32)from) | TPAM_PAGE_SIZE;
-		offset = ((u32)from) & TPAM_PAGE_SIZE;
+		page = from | TPAM_PAGE_SIZE;
+		offset = from & TPAM_PAGE_SIZE;
 		count = n < TPAM_PAGE_SIZE - offset 
 				? n 
 				: TPAM_PAGE_SIZE - offset;
@@ -107,7 +107,7 @@
 		writel(page, card->bar0 + TPAM_PAGE_REGISTER);
 
 		/* read the data */
-		memcpy_fromio(to, (void *)(card->bar0 + offset), count);
+		memcpy_fromio(to, card->bar0 + offset, count);
 		
 		from += count;
 		to += count;
@@ -125,7 +125,7 @@
  *
  * Return: 0 if OK, <0 if error.
  */
-int copy_from_pam_to_user(tpam_card *card, void __user *to, const void *from, u32 n) {
+int copy_from_pam_to_user(tpam_card *card, void __user *to, u32 from, u32 n) {
 	void *page;
 	u32 count;
 
@@ -148,7 +148,7 @@
 		if (copy_to_user(to, page, count)) {
 			
 			/* this can fail... */
-			free_page((u32)page);
+			free_page((unsigned long)page);
 			return -EFAULT;
 		}
 		from += count;
@@ -157,7 +157,7 @@
 	}
 
 	/* release allocated memory */
-	free_page((u32)page);
+	free_page((unsigned long)page);
 	return 0;
 }
 
@@ -171,7 +171,7 @@
  *
  * Return: 0 if OK, <0 if error.
  */
-int copy_from_user_to_pam(tpam_card *card, void *to, const void __user *from, u32 n) {
+int copy_from_user_to_pam(tpam_card *card, u32 to, const void __user *from, u32 n) {
 	void *page;
 	u32 count;
 
@@ -188,7 +188,7 @@
 		/* copy data from the user memory into the kernel memory */
 		if (copy_from_user(page, from, count)) {
 			/* this can fail... */
-			free_page((u32)page);
+			free_page((unsigned long)page);
 			return -EFAULT;
 		}
 
@@ -203,7 +203,7 @@
 	}
 
 	/* release allocated memory */
-	free_page((u32)page);
+	free_page((unsigned long)page);
 	return 0;
 }
 
diff -Nru a/drivers/isdn/tpam/tpam_nco.c b/drivers/isdn/tpam/tpam_nco.c
--- a/drivers/isdn/tpam/tpam_nco.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/isdn/tpam/tpam_nco.c	2004-12-24 13:36:30 -08:00
@@ -84,7 +84,7 @@
 	struct sk_buff *skb;
 	u8 *tlv;
 
-	dprintk("TurboPAM(build_ACreateNCOReq): phone=%s\n", phone);
+	pr_debug("TurboPAM(build_ACreateNCOReq): phone=%s\n", phone);
 
 	/* build the NCO packet */
 	if (!(skb = build_NCOpacket(ID_ACreateNCOReq, 23 + strlen(phone), 0, 0, 0))) 
@@ -141,7 +141,7 @@
 	struct sk_buff *skb;
 	u8 *tlv;
 
-	dprintk("TurboPAM(build_ADestroyNCOReq): ncoid=%lu\n", 
+	pr_debug("TurboPAM(build_ADestroyNCOReq): ncoid=%lu\n",
 		(unsigned long)ncoid);
 
 	/* build the NCO packet */
@@ -170,7 +170,7 @@
 	struct sk_buff *skb;
 	u8 *tlv;
 
-	dprintk("TurboPAM(build_CConnectReq): ncoid=%lu, called=%s, hdlc=%d\n",
+	pr_debug("TurboPAM(build_CConnectReq): ncoid=%lu, called=%s, hdlc=%d\n",
 		(unsigned long)ncoid, called, hdlc);
 
 	/* build the NCO packet */
@@ -220,7 +220,7 @@
 	struct sk_buff *skb;
 	u8 *tlv;
 
-	dprintk("TurboPAM(build_CConnectRsp): ncoid=%lu\n",
+	pr_debug("TurboPAM(build_CConnectRsp): ncoid=%lu\n",
 		(unsigned long)ncoid);
 
 	/* build the NCO packet */
@@ -247,7 +247,7 @@
 	struct sk_buff *skb;
 	u8 *tlv;
 
-	dprintk("TurboPAM(build_CDisconnectReq): ncoid=%lu\n",
+	pr_debug("TurboPAM(build_CDisconnectReq): ncoid=%lu\n",
 		(unsigned long)ncoid);
 
 	/* build the NCO packet */
@@ -274,7 +274,7 @@
 	struct sk_buff *skb;
 	u8 *tlv;
 
-	dprintk("TurboPAM(build_CDisconnectRsp): ncoid=%lu\n",
+	pr_debug("TurboPAM(build_CDisconnectRsp): ncoid=%lu\n",
 		(unsigned long)ncoid);
 
 	/* build the NCO packet */
@@ -307,7 +307,7 @@
 	u8 *tlv;
 	void *p;
 
-	dprintk("TurboPAM(build_U3DataReq): "
+	pr_debug("TurboPAM(build_U3DataReq): "
 		"ncoid=%lu, len=%d, ack=%d, ack_size=%d\n", 
 		(unsigned long)ncoid, len, ack, ack_size);
 
@@ -397,7 +397,7 @@
 	}
 
 	if (*status) {
-		dprintk("TurboPAM(parse_ACreateNCOCnf): status=%d\n", *status);
+		pr_debug("TurboPAM(parse_ACreateNCOCnf): status=%d\n", *status);
 		return 0;
 	}
 
@@ -408,7 +408,7 @@
 		return -1;
 	}
 
-	dprintk("TurboPAM(parse_ACreateNCOCnf): ncoid=%lu, status=%d\n",
+	pr_debug("TurboPAM(parse_ACreateNCOCnf): ncoid=%lu, status=%d\n",
 		(unsigned long)*ncoid, *status);
 	return 0;
 }
@@ -432,7 +432,7 @@
 	}
 
 	if (*status) {
-		dprintk("TurboPAM(parse_ADestroyNCOCnf): status=%d\n", *status);
+		pr_debug("TurboPAM(parse_ADestroyNCOCnf): status=%d\n", *status);
 		return 0;
 	}
 
@@ -443,7 +443,7 @@
 		return -1;
 	}
 
-	dprintk("TurboPAM(parse_ADestroyNCOCnf): ncoid=%lu, status=%d\n", 
+	pr_debug("TurboPAM(parse_ADestroyNCOCnf): ncoid=%lu, status=%d\n",
 		(unsigned long)*ncoid, *status);
 	return 0;
 }
@@ -464,7 +464,7 @@
 		       "NCOID not found\n");
 		return -1;
 	}
-	dprintk("TurboPAM(parse_CConnectCnf): ncoid=%lu\n", 
+	pr_debug("TurboPAM(parse_CConnectCnf): ncoid=%lu\n",
 		(unsigned long)*ncoid);
 	return 0;
 }
@@ -522,7 +522,7 @@
 	}
 	memcpy(called, phone + 2, PHONE_MAXIMUMSIZE);
 
-	dprintk("TurboPAM(parse_CConnectInd): "
+	pr_debug("TurboPAM(parse_CConnectInd): "
 		"ncoid=%lu, hdlc=%d, plan=%d, scr=%d, calling=%s, called=%s\n",
 		(unsigned long)*ncoid, *hdlc, *plan, *screen, calling, called);
 	return 0;
@@ -553,7 +553,7 @@
 		return -1;
 	}
 
-	dprintk("TurboPAM(parse_CDisconnectCnf): ncoid=%lu, causetopuf=%lu\n", 
+	pr_debug("TurboPAM(parse_CDisconnectCnf): ncoid=%lu, causetopuf=%lu\n",
 		(unsigned long)*ncoid, (unsigned long)*causetopuf);
 	return 0;
 }
@@ -583,7 +583,7 @@
 		return -1;
 	}
 
-	dprintk("TurboPAM(parse_CDisconnectInd): ncoid=%lu, causetopuf=%lu\n", 
+	pr_debug("TurboPAM(parse_CDisconnectInd): ncoid=%lu, causetopuf=%lu\n",
 		(unsigned long)*ncoid, (unsigned long)*causetopuf);
 	return 0;
 }
@@ -613,7 +613,7 @@
 		return -1;
 	}
 
-	dprintk("TurboPAM(parse_U3ReadyToReceiveInd): ncoid=%lu, ready=%d\n", 
+	pr_debug("TurboPAM(parse_U3ReadyToReceiveInd): ncoid=%lu, ready=%d\n",
 		(unsigned long)*ncoid, *ready);
 	return 0;
 }
@@ -644,7 +644,7 @@
 		 sizeof(skb_header) + sizeof(pci_mpb) + p->actualBlockTLVSize);
 	*data = skb->data;
 
-	dprintk("TurboPAM(parse_U3DataInd): ncoid=%lu, datalen=%d\n", 
+	pr_debug("TurboPAM(parse_U3DataInd): ncoid=%lu, datalen=%d\n",
 		(unsigned long)*ncoid, *len);
 	return 0;
 }
diff -Nru a/drivers/isdn/tpam/tpam_queues.c b/drivers/isdn/tpam/tpam_queues.c
--- a/drivers/isdn/tpam/tpam_queues.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/isdn/tpam/tpam_queues.c	2004-12-24 13:36:17 -08:00
@@ -30,7 +30,7 @@
  */
 void tpam_enqueue(tpam_card *card, struct sk_buff *skb) {
 
-	dprintk("TurboPAM(tpam_enqueue): card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_enqueue): card=%d\n", card->id);
 
 	/* queue the sk_buff on the board's send queue */
 	skb_queue_tail(&card->sendq, skb);
@@ -49,7 +49,7 @@
  */
 void tpam_enqueue_data(tpam_channel *channel, struct sk_buff *skb) {
 	
-	dprintk("TurboPAM(tpam_enqueue_data): card=%d, channel=%d\n", 
+	pr_debug("TurboPAM(tpam_enqueue_data): card=%d, channel=%d\n",
 		channel->card->id, channel->num);
 
 	/* if existant, queue the sk_buff on the channel's send queue */
@@ -84,30 +84,30 @@
 	pci_mpb mpb;
 	skb_header *skbh;
 
-	dprintk("TurboPAM(tpam_irq): IRQ received, card=%d\n", card->id);
+	pr_debug("TurboPAM(tpam_irq): IRQ received, card=%d\n", card->id);
 
 	/* grab the board lock */
 	spin_lock(&card->lock);
 
 	/* get the message type */
-	ackupload = copy_from_pam_dword(card, (void *)TPAM_ACKUPLOAD_REGISTER);
+	ackupload = copy_from_pam_dword(card, TPAM_ACKUPLOAD_REGISTER);
 
 	/* acknowledge the interrupt */
-	copy_to_pam_dword(card, (void *)TPAM_INTERRUPTACK_REGISTER, 0);
+	copy_to_pam_dword(card, TPAM_INTERRUPTACK_REGISTER, 0);
 	readl(card->bar0 + TPAM_HINTACK_REGISTER);
 
 	if (!ackupload) {
 		/* it is a new message from the board */
 		
-		dprintk("TurboPAM(tpam_irq): message received, card=%d\n", 
+		pr_debug("TurboPAM(tpam_irq): message received, card=%d\n",
 			card->id);
 
 		/* get the upload pointer */
 		uploadptr = copy_from_pam_dword(card, 
-					    (void *)TPAM_UPLOADPTR_REGISTER);
+					    TPAM_UPLOADPTR_REGISTER);
 		
 		/* get the beginning of the message (pci_mpb part) */
-		copy_from_pam(card, &mpb, (void *)uploadptr, sizeof(pci_mpb));
+		copy_from_pam(card, &mpb, uploadptr, sizeof(pci_mpb));
 
 		/* allocate the sk_buff */
 		if (!(skb = alloc_skb(sizeof(skb_header) + sizeof(pci_mpb) + 
@@ -131,13 +131,13 @@
 
 		/* copy the TLV block into the sk_buff */
 		copy_from_pam(card, skb_put(skb, mpb.actualBlockTLVSize),
-			      (void *)uploadptr + sizeof(pci_mpb), 
+			      uploadptr + sizeof(pci_mpb), 
 			      mpb.actualBlockTLVSize);
 
 		/* if existent, copy the data block into the sk_buff */
 		if (mpb.actualDataSize)
 			copy_from_pam(card, skb_put(skb, mpb.actualDataSize),
-				(void *)uploadptr + sizeof(pci_mpb) + 4096, 
+				uploadptr + sizeof(pci_mpb) + 4096, 
 				mpb.actualDataSize);
 
 		/* wait for the board to become ready */
@@ -154,7 +154,7 @@
 		} while (hpic & 0x00000002);
 
 		/* acknowledge the message */
-        	copy_to_pam_dword(card, (void *)TPAM_ACKDOWNLOAD_REGISTER, 
+        	copy_to_pam_dword(card, TPAM_ACKDOWNLOAD_REGISTER, 
 				  0xffffffff);
         	readl(card->bar0 + TPAM_DSPINT_REGISTER);
 
@@ -176,7 +176,7 @@
 	else {
 		/* it is a ack from the board */
 
-		dprintk("TurboPAM(tpam_irq): message acknowledged, card=%d\n",
+		pr_debug("TurboPAM(tpam_irq): message acknowledged, card=%d\n",
 			card->id);
 
 		/* board is not busy anymore */
@@ -231,7 +231,7 @@
 				tpam_recv_U3DataInd(card, skb);
 				break;
 			default:
-				dprintk("TurboPAM(tpam_recv_tq): "
+				pr_debug("TurboPAM(tpam_recv_tq): "
 					"unknown messageID %d, card=%d\n", 
 					p->messageID, card->id);
 				break;
@@ -286,13 +286,13 @@
 	skb_header *skbh;
 	u32 waiting_too_long;
 
-	dprintk("TurboPAM(tpam_sendpacket), card=%d, channel=%d\n", 
+	pr_debug("TurboPAM(tpam_sendpacket), card=%d, channel=%d\n",
 		card->id, channel ? channel->num : -1);
 
 	if (channel) {
 		/* dequeue a packet from the channel's send queue */
 		if (!(skb = skb_dequeue(&channel->sendq))) {
-			dprintk("TurboPAM(tpam_sendpacket): "
+			pr_debug("TurboPAM(tpam_sendpacket): "
 				"card=%d, channel=%d, no packet\n", 
 				card->id, channel->num);
 			return 0;
@@ -301,7 +301,7 @@
 		/* if the channel is not ready to receive, requeue the packet
 		 * and return 0 to give a chance to another channel */
 		if (!channel->readytoreceive) {
-			dprintk("TurboPAM(tpam_sendpacket): "
+			pr_debug("TurboPAM(tpam_sendpacket): "
 				"card=%d, channel=%d, channel not ready\n",
 				card->id, channel->num);
 			skb_queue_head(&channel->sendq, skb);
@@ -314,7 +314,7 @@
 		/* if the board is busy, requeue the packet and return 1 since
 		 * there is no need to try another channel */
 		if (card->busy) {
-			dprintk("TurboPAM(tpam_sendpacket): "
+			pr_debug("TurboPAM(tpam_sendpacket): "
 				"card=%d, channel=%d, card busy\n",
 				card->id, channel->num);
 			skb_queue_head(&channel->sendq, skb);
@@ -325,7 +325,7 @@
 	else {
 		/* dequeue a packet from the board's send queue */
 		if (!(skb = skb_dequeue(&card->sendq))) {
-			dprintk("TurboPAM(tpam_sendpacket): "
+			pr_debug("TurboPAM(tpam_sendpacket): "
 				"card=%d, no packet\n", card->id);
 			return 0;
 		}
@@ -336,7 +336,7 @@
 		/* if the board is busy, requeue the packet and return 1 since
 		 * there is no need to try another channel */
 		if (card->busy) {
-			dprintk("TurboPAM(tpam_sendpacket): "
+			pr_debug("TurboPAM(tpam_sendpacket): "
 				"card=%d, card busy\n", card->id);
 			skb_queue_head(&card->sendq, skb);
 			spin_unlock_irq(&card->lock);
@@ -357,20 +357,19 @@
 	} while (hpic & 0x00000002);
 
 	skbh = (skb_header *)skb->data;
-	dprintk("TurboPAM(tpam_sendpacket): "
+	pr_debug("TurboPAM(tpam_sendpacket): "
 		"card=%d, card ready, sending %d/%d bytes\n", 
 		card->id, skbh->size, skbh->data_size);
 
 	/* get the board's download pointer */
-       	downloadptr = copy_from_pam_dword(card, 
-					  (void *)TPAM_DOWNLOADPTR_REGISTER);
+       	downloadptr = copy_from_pam_dword(card, TPAM_DOWNLOADPTR_REGISTER);
 
 	/* copy the packet to the board at the downloadptr location */
-       	copy_to_pam(card, (void *)downloadptr, skb->data + sizeof(skb_header), 
+       	copy_to_pam(card, downloadptr, skb->data + sizeof(skb_header), 
 		    skbh->size);
 	if (skbh->data_size)
 		/* if there is some data in the packet, copy it too */
-		copy_to_pam(card, (void *)downloadptr + sizeof(pci_mpb) + 4096,
+		copy_to_pam(card, downloadptr + sizeof(pci_mpb) + 4096,
 			    skb->data + sizeof(skb_header) + skbh->size, 
 			    skbh->data_size);
 
@@ -378,7 +377,7 @@
 	card->busy = 1;
 
 	/* interrupt the board */
-	copy_to_pam_dword(card, (void *)TPAM_ACKDOWNLOAD_REGISTER, 0);
+	copy_to_pam_dword(card, TPAM_ACKDOWNLOAD_REGISTER, 0);
 	readl(card->bar0 + TPAM_DSPINT_REGISTER);
 
 	/* release the lock */
diff -Nru a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
--- a/drivers/macintosh/ans-lcd.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/macintosh/ans-lcd.c	2004-12-24 13:37:30 -08:00
@@ -23,7 +23,7 @@
 
 static unsigned long anslcd_short_delay = 80;
 static unsigned long anslcd_long_delay = 3280;
-static volatile unsigned char* anslcd_ptr;
+static volatile unsigned char __iomem *anslcd_ptr;
 
 #undef DEBUG
 
@@ -151,12 +151,12 @@
 	if (strcmp(node->parent->name, "gc"))
 		return -ENODEV;
 
-	anslcd_ptr = (volatile unsigned char*)ioremap(ANSLCD_ADDR, 0x20);
+	anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
 	
 	retval = misc_register(&anslcd_dev);
 	if(retval < 0){
 		printk(KERN_INFO "LCD: misc_register failed\n");
-		iounmap((void *)anslcd_ptr);
+		iounmap(anslcd_ptr);
 		return retval;
 	}
 
@@ -179,7 +179,7 @@
 anslcd_exit(void)
 {
 	misc_deregister(&anslcd_dev);
-	iounmap((void *)anslcd_ptr);
+	iounmap(anslcd_ptr);
 }
 
 module_init(anslcd_init);
diff -Nru a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c
--- a/drivers/macintosh/macio-adb.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/macintosh/macio-adb.c	2004-12-24 13:37:31 -08:00
@@ -57,7 +57,7 @@
 /* Bits in autopoll register */
 #define APE	1		/* autopoll enable */
 
-static volatile struct adb_regs *adb;
+static volatile struct adb_regs __iomem *adb;
 static struct adb_request *current_req, *last_req;
 static spinlock_t macio_lock = SPIN_LOCK_UNLOCKED;
 
@@ -105,8 +105,7 @@
 	printk("\n"); }
 #endif
 	
-	adb = (volatile struct adb_regs *)
-		ioremap(adbs->addrs->address, sizeof(struct adb_regs));
+	adb = ioremap(adbs->addrs->address, sizeof(struct adb_regs));
 
 	out_8(&adb->ctrl.r, 0);
 	out_8(&adb->intr.r, 0);
@@ -202,7 +201,7 @@
 				       struct pt_regs *regs)
 {
 	int i, n, err;
-	struct adb_request *req;
+	struct adb_request *req = NULL;
 	unsigned char ibuf[16];
 	int ibuf_len = 0;
 	int complete = 0;
diff -Nru a/drivers/macintosh/macserial.c b/drivers/macintosh/macserial.c
--- a/drivers/macintosh/macserial.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/macintosh/macserial.c	2004-12-24 13:37:29 -08:00
@@ -32,6 +32,7 @@
 #include <linux/console.h>
 #endif
 #include <linux/slab.h>
+#include <linux/bitops.h>
 
 #include <asm/sections.h>
 #include <asm/io.h>
@@ -40,7 +41,6 @@
 #include <asm/prom.h>
 #include <asm/system.h>
 #include <asm/segment.h>
-#include <asm/bitops.h>
 #include <asm/machdep.h>
 #include <asm/pmac_feature.h>
 #include <linux/adb.h>
@@ -1461,7 +1461,7 @@
 	spin_unlock_irqrestore(&info->lock, flags);
 }
 
-static int rs_write(struct tty_struct * tty, int from_user,
+static int rs_write(struct tty_struct * tty,
 		    const unsigned char *buf, int count)
 {
 	int	c, ret = 0;
@@ -1474,51 +1474,22 @@
 	if (!tty || !info->xmit_buf || !tmp_buf)
 		return 0;
 
-	if (from_user) {
-		down(&tmp_buf_sem);
-		while (1) {
-			c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-						  SERIAL_XMIT_SIZE - info->xmit_head));
-			if (c <= 0)
-				break;
-
-			c -= copy_from_user(tmp_buf, buf, c);
-			if (!c) {
-				if (!ret)
-					ret = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&info->lock, flags);
-			c = min_t(int, c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					      SERIAL_XMIT_SIZE - info->xmit_head));
-			memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
-			info->xmit_head = ((info->xmit_head + c) &
-					   (SERIAL_XMIT_SIZE-1));
-			info->xmit_cnt += c;
-			spin_unlock_irqrestore(&info->lock, flags);
-			buf += c;
-			count -= c;
-			ret += c;
-		}
-		up(&tmp_buf_sem);
-	} else {
-		while (1) {
-			spin_lock_irqsave(&info->lock, flags);
-			c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-						  SERIAL_XMIT_SIZE - info->xmit_head));
-			if (c <= 0) {
-				spin_unlock_irqrestore(&info->lock, flags);
-				break;
-			}
-			memcpy(info->xmit_buf + info->xmit_head, buf, c);
-			info->xmit_head = ((info->xmit_head + c) &
-					   (SERIAL_XMIT_SIZE-1));
-			info->xmit_cnt += c;
+	while (1) {
+		spin_lock_irqsave(&info->lock, flags);
+		c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
+					  SERIAL_XMIT_SIZE - info->xmit_head));
+		if (c <= 0) {
 			spin_unlock_irqrestore(&info->lock, flags);
-			buf += c;
-			count -= c;
-			ret += c;
+			break;
 		}
+		memcpy(info->xmit_buf + info->xmit_head, buf, c);
+		info->xmit_head = ((info->xmit_head + c) &
+				   (SERIAL_XMIT_SIZE-1));
+		info->xmit_cnt += c;
+		spin_unlock_irqrestore(&info->lock, flags);
+		buf += c;
+		count -= c;
+		ret += c;
 	}
 	spin_lock_irqsave(&info->lock, flags);
 	if (info->xmit_cnt && !tty->stopped && !info->tx_stopped
diff -Nru a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
--- a/drivers/macintosh/mediabay.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/macintosh/mediabay.c	2004-12-24 13:36:31 -08:00
@@ -45,7 +45,7 @@
 #endif
 
 #define MB_FCR32(bay, r)	((bay)->base + ((r) >> 2))
-#define MB_FCR8(bay, r)		(((volatile u8*)((bay)->base)) + (r))
+#define MB_FCR8(bay, r)		(((volatile u8 __iomem *)((bay)->base)) + (r))
 
 #define MB_IN32(bay,r)		(in_le32(MB_FCR32(bay,r)))
 #define MB_OUT32(bay,r,v)	(out_le32(MB_FCR32(bay,r), (v)))
@@ -67,7 +67,7 @@
 };
 
 struct media_bay_info {
-	volatile u32*			base;
+	u32 __iomem			*base;
 	int				content_id;
 	int				state;
 	int				last_value;
@@ -80,7 +80,7 @@
 	int				sleeping;
 	struct semaphore		lock;
 #ifdef CONFIG_BLK_DEV_IDE
-	unsigned long			cd_base;
+	void __iomem			*cd_base;
 	int 				cd_index;
 	int				cd_irq;
 	int				cd_retry;
@@ -443,7 +443,7 @@
 	int	i;
 
 	for (i=0; i<media_bay_count; i++)
-		if (media_bays[i].mdev && base == media_bays[i].cd_base) {
+		if (media_bays[i].mdev && base == (unsigned long) media_bays[i].cd_base) {
 			if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
 				return 0;
 			media_bays[i].cd_index = -1;
@@ -468,7 +468,7 @@
 			
 			down(&bay->lock);
 
- 			bay->cd_base	= base;
+ 			bay->cd_base	= (void __iomem *) base;
 			bay->cd_irq	= irq;
 
 			if ((MB_CD != bay->content_id) || bay->state != mb_up) {
@@ -553,7 +553,7 @@
 	    	break;
 	    
 	case mb_ide_waiting:
-		if (bay->cd_base == 0) {
+		if (bay->cd_base == NULL) {
 			bay->timer = 0;
 			bay->state = mb_up;
 			MBDBG("mediabay%d: up before IDE init\n", i);
@@ -651,7 +651,7 @@
 static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_match *match)
 {
 	struct media_bay_info* bay;
-	volatile u32 *regbase;
+	u32 __iomem *regbase;
 	struct device_node *ofnode;
 	int i;
 
@@ -664,7 +664,8 @@
 	/* Media bay registers are located at the beginning of the
          * mac-io chip, we get the parent address for now (hrm...)
          */
-	regbase = (volatile u32 *)ioremap(ofnode->parent->addrs[0].address, 0x100);
+	regbase = (u32 __iomem *)
+		ioremap(ofnode->parent->addrs[0].address, 0x100);
 	if (regbase == NULL) {
 		macio_release_resources(mdev);
 		return -ENOMEM;
@@ -713,13 +714,13 @@
 {
 	struct media_bay_info	*bay = macio_get_drvdata(mdev);
 
-	if (state != mdev->ofdev.dev.power_state && state >= 2) {
+	if (state != mdev->ofdev.dev.power.power_state && state == PM_SUSPEND_MEM) {
 		down(&bay->lock);
 		bay->sleeping = 1;
 		set_mb_power(bay, 0);
 		up(&bay->lock);
 		msleep(MB_POLL_DELAY);
-		mdev->ofdev.dev.power_state = state;
+		mdev->ofdev.dev.power.power_state = state;
 	}
 	return 0;
 }
@@ -728,8 +729,8 @@
 {
 	struct media_bay_info	*bay = macio_get_drvdata(mdev);
 
-	if (mdev->ofdev.dev.power_state != 0) {
-		mdev->ofdev.dev.power_state = 0;
+	if (mdev->ofdev.dev.power.power_state != 0) {
+		mdev->ofdev.dev.power.power_state = 0;
 
 	       	/* We re-enable the bay using it's previous content
 	       	   only if it did not change. Note those bozo timings,
diff -Nru a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
--- a/drivers/macintosh/therm_adt746x.c	2004-12-24 13:37:17 -08:00
+++ b/drivers/macintosh/therm_adt746x.c	2004-12-24 13:37:17 -08:00
@@ -22,13 +22,16 @@
 #include <linux/spinlock.h>
 #include <linux/smp_lock.h>
 #include <linux/wait.h>
+#include <linux/suspend.h>
+#include <linux/kthread.h>
+#include <linux/moduleparam.h>
+
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/sections.h>
 #include <asm/of_device.h>
-#include <linux/kthread.h>
 
 #undef DEBUG
 
@@ -50,21 +53,26 @@
 static int fan_speed = -1;
 
 MODULE_AUTHOR("Colin Leroy <colin@colino.net>");
-MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and Powerbook G4 Alu");
+MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and "
+		   "Powerbook G4 Alu");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(limit_adjust,"i");
-MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50 cpu, 70 gpu) by N degrees.");
-MODULE_PARM(fan_speed,"i");
-MODULE_PARM_DESC(fan_speed,"Specify fan speed (0-255) when lim < temp < lim+8 (default 128)");
+module_param(limit_adjust, int, 0644);
+MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50 cpu, 70 gpu) "
+		 "by N degrees.");
+
+module_param(fan_speed, int, 0644);
+MODULE_PARM_DESC(fan_speed,"Specify starting fan speed (0-255) "
+		 "(default 64)");
 
 struct thermostat {
 	struct i2c_client	clt;
+	u8			temps[3];
 	u8			cached_temp[3];
 	u8			initial_limits[3];
 	u8			limits[3];
 	int			last_speed[2];
-	int			overriding[2];
+	int			last_var[2];
 };
 
 static enum {ADT7460, ADT7467} therm_type;
@@ -73,7 +81,9 @@
 static struct thermostat* thermostat;
 static struct task_struct *thread_therm = NULL;
 
-static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno);
+static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
+				 int busno);
+
 static void write_both_fan_speed(struct thermostat *th, int speed);
 static void write_fan_speed(struct thermostat *th, int speed, int fan);
 
@@ -139,10 +149,11 @@
 		kthread_stop(thread_therm);
 	}
 		
-	printk(KERN_INFO "adt746x: Putting max temperatures back from %d, %d, %d,"
-		" to %d, %d, %d\n",
+	printk(KERN_INFO "adt746x: Putting max temperatures back from "
+			 "%d, %d, %d to %d, %d, %d\n",
 		th->limits[0], th->limits[1], th->limits[2],
-		th->initial_limits[0], th->initial_limits[1], th->initial_limits[2]);
+		th->initial_limits[0], th->initial_limits[1],
+		th->initial_limits[2]);
 	
 	for (i = 0; i < 3; i++)
 		write_reg(th, LIMIT_REG[i], th->initial_limits[i]);
@@ -159,11 +170,11 @@
 }
 
 static struct i2c_driver thermostat_driver = {  
-	.name		="Apple Thermostat ADT746x",
-	.id		=0xDEAD7467,
-	.flags		=I2C_DF_NOTIFY,
-	.attach_adapter	=&attach_thermostat,
-	.detach_adapter	=&detach_thermostat,
+	.owner		= THIS_MODULE,
+	.name		= "therm_adt746x",
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= attach_thermostat,
+	.detach_adapter	= detach_thermostat,
 };
 
 static int read_fan_speed(struct thermostat *th, u8 addr)
@@ -201,11 +212,11 @@
 	
 	if (th->last_speed[fan] != speed) {
 		if (speed == -1)
-			printk(KERN_INFO "adt746x: Setting speed to: automatic for %s fan.\n",
-				fan?"GPU":"CPU");
+			printk(KERN_DEBUG "adt746x: Setting speed to automatic "
+				"for %s fan.\n", fan?"GPU":"CPU");
 		else
-			printk(KERN_INFO "adt746x: Setting speed to: %d for %s fan.\n",
-				speed, fan?"GPU":"CPU");
+			printk(KERN_DEBUG "adt746x: Setting speed to %d "
+				"for %s fan.\n", speed, fan?"GPU":"CPU");
 	} else
 		return;
 	
@@ -216,8 +227,11 @@
 	} else {
 		/* back to automatic */
 		if(therm_type == ADT7460) {
-			manual = read_reg(th, MANUAL_MODE[fan]) & (~MANUAL_MASK);
-			write_reg(th, MANUAL_MODE[fan], manual|REM_CONTROL[fan]);
+			manual = read_reg(th,
+				MANUAL_MODE[fan]) & (~MANUAL_MASK);
+
+			write_reg(th,
+				MANUAL_MODE[fan], manual|REM_CONTROL[fan]);
 		} else {
 			manual = read_reg(th, MANUAL_MODE[fan]);
 			write_reg(th, MANUAL_MODE[fan], manual&(~AUTO_MASK));
@@ -227,97 +241,117 @@
 	th->last_speed[fan] = speed;			
 }
 
-static int monitor_task(void *arg)
+static void read_sensors(struct thermostat *th)
 {
-	struct thermostat* th = arg;
-	u8 temps[3];
-	u8 lims[3];
-	int i;
+	int i = 0;
+
+	for (i = 0; i < 3; i++)
+		th->temps[i]  = read_reg(th, TEMP_REG[i]);
+}
+
 #ifdef DEBUG
-	int mfan_speed;
+static void display_stats(struct thermostat *th)
+{
+	if (th->temps[0] != th->cached_temp[0]
+	||  th->temps[1] != th->cached_temp[1]
+	||  th->temps[2] != th->cached_temp[2]) {
+		printk(KERN_INFO "adt746x: Temperature infos:"
+				 " thermostats: %d,%d,%d;"
+				 " limits: %d,%d,%d;"
+				 " fan speed: %d RPM\n",
+				 th->temps[0], th->temps[1], th->temps[2],
+				 th->limits[0],  th->limits[1],  th->limits[2],
+				 read_fan_speed(th, FAN_SPEED[0]));
+	}
+	th->cached_temp[0] = th->temps[0];
+	th->cached_temp[1] = th->temps[1];
+	th->cached_temp[2] = th->temps[2];
+}
 #endif
-	while(!kthread_should_stop())
-	{
-		msleep_interruptible(2000);
 
-		/* Check status */
-		/* local   : chip */
-		/* remote 1: CPU ?*/
-		/* remote 2: GPU ?*/
-#ifndef DEBUG
-		if (fan_speed != -1) {
-#endif
-			for (i = 0; i < 3; i++) {
-				temps[i]  = read_reg(th, TEMP_REG[i]);
-				lims[i]   = th->limits[i];
+static void update_fans_speed (struct thermostat *th)
+{
+	int lastvar = 0; /* last variation, for iBook */
+	int i = 0;
+
+	/* we don't care about local sensor, so we start at sensor 1 */
+	for (i = 1; i < 3; i++) {
+		int started = 0;
+		int fan_number = (therm_type == ADT7460 && i == 2);
+		int var = th->temps[i] - th->limits[i];
+
+		if (var > -1) {
+			int step = (255 - fan_speed) / 7;
+			int new_speed = 0;
+
+			/* hysteresis : change fan speed only if variation is
+			 * more than two degrees */
+			if (abs(var - th->last_var[fan_number]) < 2)
+				continue;
+
+			started = 1;
+			new_speed = fan_speed + ((var-1)*step);
+
+			if (new_speed < fan_speed)
+				new_speed = fan_speed;
+			if (new_speed > 255)
+				new_speed = 255;
+
+			printk(KERN_DEBUG "adt746x: setting fans speed to %d "
+					 "(limit exceeded by %d on %s) \n",
+					new_speed, var,
+					fan_number?"GPU/pwr":"CPU");
+			write_both_fan_speed(th, new_speed);
+			th->last_var[fan_number] = var;
+		} else if (var < -2) {
+			/* don't stop fan if GPU/power is cold and CPU is not
+			 * so cold (lastvar >= -1) */
+			if (i == 2 && lastvar < -1) {
+				if (th->last_speed[fan_number] != 0)
+					printk(KERN_DEBUG "adt746x: Stopping "
+						"fans.\n");
+				write_both_fan_speed(th, 0);
 			}
-#ifndef DEBUG
 		}
+
+		lastvar = var;
+
+		if (started)
+			return; /* we don't want to re-stop the fan
+				* if CPU is heating and GPU/power is not */
+	}
+}
+
+static int monitor_task(void *arg)
+{
+	struct thermostat* th = arg;
+
+	while(!kthread_should_stop()) {
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
+
+		msleep_interruptible(2000);
+
+#ifndef DEBUG
+		if (fan_speed != -1)
+			read_sensors(th);
+#else
+		read_sensors(th);
 #endif		
-		if (fan_speed != -1) {
-			int lastvar = 0;		/* for iBook */
-			for (i = 1; i < 3; i++) {	/* we don't care about local sensor */
-				int started = 0;
-				int fan_number = (therm_type == ADT7460 && i == 2);
-				int var = temps[i] - lims[i];
-				if (var > 8) {
-					if (th->overriding[fan_number] == 0)
-						printk(KERN_INFO "adt746x: Limit exceeded by %d, overriding specified fan speed for %s.\n",
-							var, fan_number?"GPU":"CPU");
-					th->overriding[fan_number] = 1;
-					write_fan_speed(th, 255, fan_number);
-					started = 1;
-				} else if ((!th->overriding[fan_number] || var < 6) && var > 0) {
-					if (th->overriding[fan_number] == 1)
-						printk(KERN_INFO "adt746x: Limit exceeded by %d, setting speed to specified for %s.\n",
-							var, fan_number?"GPU":"CPU");					
-					th->overriding[fan_number] = 0;
-					write_fan_speed(th, fan_speed, fan_number);
-					started = 1;
-				} else if (var < -1) {
-					/* don't stop iBook fan if GPU is cold and CPU is not
-					 * so cold (lastvar >= -1) */
-					if (therm_type == ADT7460 || lastvar < -1 || i == 1) {
-						if (th->last_speed[fan_number] != 0)
-							printk(KERN_INFO "adt746x: Stopping %s fan.\n",
-								fan_number?"GPU":"CPU");
-						write_fan_speed(th, 0, fan_number);
-					}
-				}
-				
-				lastvar = var;
-				
-				if (started && therm_type == ADT7467)
-					break; /* we don't want to re-stop the fan
-						* if CPU is heating and GPU is not */
-			}
-		}
+
+		if (fan_speed != -1)
+			update_fans_speed(th);
+
 #ifdef DEBUG
-		mfan_speed = read_fan_speed(th, FAN_SPEED[0]);
-		/* only one fan in the iBook G4 */
-				
-		if (temps[0] != th->cached_temp[0]
-		||  temps[1] != th->cached_temp[1]
-		||  temps[2] != th->cached_temp[2]) {
-			printk(KERN_INFO "adt746x: Temperature infos:"
-					 " thermostats: %d,%d,%d;"
-					 " limits: %d,%d,%d;"
-					 " fan speed: %d RPM\n",
-				temps[0], temps[1], temps[2],
-				lims[0],  lims[1],  lims[2],
-				mfan_speed);
-		}
-		th->cached_temp[0] = temps[0];
-		th->cached_temp[1] = temps[1];
-		th->cached_temp[2] = temps[2];
-#endif		
+		display_stats(th);
+#endif
+
 	}
 
 	return 0;
 }
 
-static void
-set_limit(struct thermostat *th, int i)
+static void set_limit(struct thermostat *th, int i)
 {
 		/* Set CPU limit higher to avoid powerdowns */ 
 		th->limits[i] = default_limits_chip[i] + limit_adjust;
@@ -326,9 +360,9 @@
 		/* set our limits to normal */
 		th->limits[i] = default_limits_local[i] + limit_adjust;
 }
-	
-static int
-attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
+
+static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
+				 int busno)
 {
 	struct thermostat* th;
 	int rc;
@@ -336,27 +370,31 @@
 
 	if (thermostat)
 		return 0;
-	th = (struct thermostat *)kmalloc(sizeof(struct thermostat), GFP_KERNEL);
+
+	th = (struct thermostat *)
+		kmalloc(sizeof(struct thermostat), GFP_KERNEL);
+
 	if (!th)
 		return -ENOMEM;
+
 	memset(th, 0, sizeof(*th));
 	th->clt.addr = addr;
 	th->clt.adapter = adapter;
 	th->clt.driver = &thermostat_driver;
-	th->clt.id = 0xDEAD7467;
 	strcpy(th->clt.name, "thermostat");
 
 	rc = read_reg(th, 0);
 	if (rc < 0) {
-		printk(KERN_ERR "adt746x: Thermostat failed to read config from bus %d !\n",
-			busno);
+		printk(KERN_ERR "adt746x: Thermostat failed to read config "
+				"from bus %d !\n",
+				busno);
 		kfree(th);
 		return -ENODEV;
 	}
+
 	/* force manual control to start the fan quieter */
-	
 	if (fan_speed == -1)
-		fan_speed=128;
+		fan_speed = 64;
 	
 	if(therm_type == ADT7460) {
 		printk(KERN_INFO "adt746x: ADT7460 initializing\n");
@@ -371,14 +409,16 @@
 	}
 	
 	printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d"
-		" to %d, %d, %d\n",
-		th->initial_limits[0], th->initial_limits[1], th->initial_limits[2], 
-		th->limits[0], th->limits[1], th->limits[2]);
+			 " to %d, %d, %d\n",
+			 th->initial_limits[0], th->initial_limits[1],
+			 th->initial_limits[2], th->limits[0], th->limits[1],
+			 th->limits[2]);
 
 	thermostat = th;
 
 	if (i2c_attach_client(&th->clt)) {
-		printk(KERN_INFO "adt746x: Thermostat failed to attach client !\n");
+		printk(KERN_INFO "adt746x: Thermostat failed to attach "
+				 "client !\n");
 		thermostat = NULL;
 		kfree(th);
 		return -ENODEV;
@@ -387,10 +427,14 @@
 	/* be sure to really write fan speed the first time */
 	th->last_speed[0] = -2;
 	th->last_speed[1] = -2;
-	
+	th->last_var[0] = -80;
+	th->last_var[1] = -80;
+
 	if (fan_speed != -1) {
+		/* manual mode, stop fans */
 		write_both_fan_speed(th, 0);
 	} else {
+		/* automatic mode */
 		write_both_fan_speed(th, -1);
 	}
 	
@@ -507,8 +551,9 @@
 	therm_bus = ((*prop) >> 8) & 0x0f;
 	therm_address = ((*prop) & 0xff) >> 1;
 
-	printk(KERN_INFO "adt746x: Thermostat bus: %d, address: 0x%02x, limit_adjust: %d, fan_speed: %d\n",
-		therm_bus, therm_address, limit_adjust, fan_speed);
+	printk(KERN_INFO "adt746x: Thermostat bus: %d, address: 0x%02x, "
+			 "limit_adjust: %d, fan_speed: %d\n",
+			 therm_bus, therm_address, limit_adjust, fan_speed);
 
 	of_dev = of_platform_device_create(np, "temperatures");
 	
@@ -545,8 +590,11 @@
 		device_remove_file(&of_dev->dev, &dev_attr_limit_adjust);
 		device_remove_file(&of_dev->dev, &dev_attr_specified_fan_speed);
 		device_remove_file(&of_dev->dev, &dev_attr_cpu_fan_speed);
+
 		if(therm_type == ADT7460)
-			device_remove_file(&of_dev->dev, &dev_attr_gpu_fan_speed);
+			device_remove_file(&of_dev->dev,
+					   &dev_attr_gpu_fan_speed);
+
 		of_device_unregister(of_dev);
 	}
 	i2c_del_driver(&thermostat_driver);
diff -Nru a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
--- a/drivers/macintosh/therm_pm72.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/macintosh/therm_pm72.c	2004-12-24 13:37:04 -08:00
@@ -46,6 +46,9 @@
  *          overtemp conditions so userland can take some policy
  *          decisions, like slewing down CPUs
  *	  - Deal with fan and i2c failures in a better way
+ *	  - Maybe do a generic PID based on params used for
+ *	    U3 and Drives ?
+ *        - Add RackMac3,1 support (XServe g5)
  *
  * History:
  *
@@ -73,6 +76,15 @@
  *        values in the configuration register
  *	- Switch back to use of target fan speed for PID, thus lowering
  *        pressure on i2c
+ *
+ *  Oct. 20, 2004 : 1.1
+ *	- Add device-tree lookup for fan IDs, should detect liquid cooling
+ *        pumps when present
+ *	- Enable driver for PowerMac7,3 machines
+ *	- Split the U3/Backside cooling on U3 & U3H versions as Darwin does
+ *	- Add new CPU cooling algorithm for machines with liquid cooling
+ *	- Workaround for some PowerMac7,3 with empty "fan" node in the devtree
+ *	- Fix a signed/unsigned compare issue in some PID loops
  */
 
 #include <linux/config.h>
@@ -101,7 +113,7 @@
 
 #include "therm_pm72.h"
 
-#define VERSION "0.9"
+#define VERSION "1.1"
 
 #undef DEBUG
 
@@ -121,16 +133,100 @@
 static struct i2c_adapter *		u3_1;
 static struct i2c_client *		fcu;
 static struct cpu_pid_state		cpu_state[2];
+static struct basckside_pid_params	backside_params;
 static struct backside_pid_state	backside_state;
 static struct drives_pid_state		drives_state;
 static int				state;
 static int				cpu_count;
+static int				cpu_pid_type;
 static pid_t				ctrl_task;
 static struct completion		ctrl_complete;
 static int				critical_state;
 static DECLARE_MUTEX(driver_lock);
 
 /*
+ * We have 2 types of CPU PID control. One is "split" old style control
+ * for intake & exhaust fans, the other is "combined" control for both
+ * CPUs that also deals with the pumps when present. To be "compatible"
+ * with OS X at this point, we only use "COMBINED" on the machines that
+ * are identified as having the pumps (though that identification is at
+ * least dodgy). Ultimately, we could probably switch completely to this
+ * algorithm provided we hack it to deal with the UP case
+ */
+#define CPU_PID_TYPE_SPLIT	0
+#define CPU_PID_TYPE_COMBINED	1
+
+/*
+ * This table describes all fans in the FCU. The "id" and "type" values
+ * are defaults valid for all earlier machines. Newer machines will
+ * eventually override the table content based on the device-tree
+ */
+struct fcu_fan_table
+{
+	char*	loc;	/* location code */
+	int	type;	/* 0 = rpm, 1 = pwm, 2 = pump */
+	int	id;	/* id or -1 */
+};
+
+#define FCU_FAN_RPM		0
+#define FCU_FAN_PWM		1
+
+#define FCU_FAN_ABSENT_ID	-1
+
+#define FCU_FAN_COUNT		ARRAY_SIZE(fcu_fans)
+
+struct fcu_fan_table	fcu_fans[] = {
+	[BACKSIDE_FAN_PWM_INDEX] = {
+		.loc	= "BACKSIDE",
+		.type	= FCU_FAN_PWM,
+		.id	= BACKSIDE_FAN_PWM_DEFAULT_ID,
+	},
+	[DRIVES_FAN_RPM_INDEX] = {
+		.loc	= "DRIVE BAY",
+		.type	= FCU_FAN_RPM,
+		.id	= DRIVES_FAN_RPM_DEFAULT_ID,
+	},
+	[SLOTS_FAN_PWM_INDEX] = {
+		.loc	= "SLOT",
+		.type	= FCU_FAN_PWM,
+		.id	= SLOTS_FAN_PWM_DEFAULT_ID,
+	},
+	[CPUA_INTAKE_FAN_RPM_INDEX] = {
+		.loc	= "CPU A INTAKE",
+		.type	= FCU_FAN_RPM,
+		.id	= CPUA_INTAKE_FAN_RPM_DEFAULT_ID,
+	},
+	[CPUA_EXHAUST_FAN_RPM_INDEX] = {
+		.loc	= "CPU A EXHAUST",
+		.type	= FCU_FAN_RPM,
+		.id	= CPUA_EXHAUST_FAN_RPM_DEFAULT_ID,
+	},
+	[CPUB_INTAKE_FAN_RPM_INDEX] = {
+		.loc	= "CPU B INTAKE",
+		.type	= FCU_FAN_RPM,
+		.id	= CPUB_INTAKE_FAN_RPM_DEFAULT_ID,
+	},
+	[CPUB_EXHAUST_FAN_RPM_INDEX] = {
+		.loc	= "CPU B EXHAUST",
+		.type	= FCU_FAN_RPM,
+		.id	= CPUB_EXHAUST_FAN_RPM_DEFAULT_ID,
+	},
+	/* pumps aren't present by default, have to be looked up in the
+	 * device-tree
+	 */
+	[CPUA_PUMP_RPM_INDEX] = {
+		.loc	= "CPU A PUMP",
+		.type	= FCU_FAN_RPM,		
+		.id	= FCU_FAN_ABSENT_ID,
+	},
+	[CPUB_PUMP_RPM_INDEX] = {
+		.loc	= "CPU B PUMP",
+		.type	= FCU_FAN_RPM,
+		.id	= FCU_FAN_ABSENT_ID,
+	},
+};
+
+/*
  * i2c_driver structure to attach to the host i2c controller
  */
 
@@ -139,8 +235,8 @@
 
 static struct i2c_driver therm_pm72_driver =
 {
+	.owner		= THIS_MODULE,
 	.name		= "therm_pm72",
-	.id		= 0xDEADBEEF,
 	.flags		= I2C_DF_NOTIFY,
 	.attach_adapter	= therm_pm72_attach,
 	.detach_adapter	= therm_pm72_detach,
@@ -170,7 +266,6 @@
 	clt->addr = (id >> 1) & 0x7f;
 	clt->adapter = adap;
 	clt->driver = &therm_pm72_driver;
-	clt->id = 0xDEADBEEF;
 	strncpy(clt->name, name, I2C_NAME_SIZE-1);
 
 	if (i2c_attach_client(clt)) {
@@ -331,10 +426,16 @@
 	return 0;
 }
 
-static int set_rpm_fan(int fan, int rpm)
+static int set_rpm_fan(int fan_index, int rpm)
 {
 	unsigned char buf[2];
-	int rc;
+	int rc, id;
+
+	if (fcu_fans[fan_index].type != FCU_FAN_RPM)
+		return -EINVAL;
+	id = fcu_fans[fan_index].id; 
+	if (id == FCU_FAN_ABSENT_ID)
+		return -EINVAL;
 
 	if (rpm < 300)
 		rpm = 300;
@@ -342,43 +443,55 @@
 		rpm = 8191;
 	buf[0] = rpm >> 5;
 	buf[1] = rpm << 3;
-	rc = fan_write_reg(0x10 + (fan * 2), buf, 2);
+	rc = fan_write_reg(0x10 + (id * 2), buf, 2);
 	if (rc < 0)
 		return -EIO;
 	return 0;
 }
 
-static int get_rpm_fan(int fan, int programmed)
+static int get_rpm_fan(int fan_index, int programmed)
 {
 	unsigned char failure;
 	unsigned char active;
 	unsigned char buf[2];
-	int rc, reg_base;
+	int rc, id, reg_base;
+
+	if (fcu_fans[fan_index].type != FCU_FAN_RPM)
+		return -EINVAL;
+	id = fcu_fans[fan_index].id; 
+	if (id == FCU_FAN_ABSENT_ID)
+		return -EINVAL;
 
 	rc = fan_read_reg(0xb, &failure, 1);
 	if (rc != 1)
 		return -EIO;
-	if ((failure & (1 << fan)) != 0)
+	if ((failure & (1 << id)) != 0)
 		return -EFAULT;
 	rc = fan_read_reg(0xd, &active, 1);
 	if (rc != 1)
 		return -EIO;
-	if ((active & (1 << fan)) == 0)
+	if ((active & (1 << id)) == 0)
 		return -ENXIO;
 
 	/* Programmed value or real current speed */
 	reg_base = programmed ? 0x10 : 0x11;
-	rc = fan_read_reg(reg_base + (fan * 2), buf, 2);
+	rc = fan_read_reg(reg_base + (id * 2), buf, 2);
 	if (rc != 2)
 		return -EIO;
 
 	return (buf[0] << 5) | buf[1] >> 3;
 }
 
-static int set_pwm_fan(int fan, int pwm)
+static int set_pwm_fan(int fan_index, int pwm)
 {
 	unsigned char buf[2];
-	int rc;
+	int rc, id;
+
+	if (fcu_fans[fan_index].type != FCU_FAN_PWM)
+		return -EINVAL;
+	id = fcu_fans[fan_index].id; 
+	if (id == FCU_FAN_ABSENT_ID)
+		return -EINVAL;
 
 	if (pwm < 10)
 		pwm = 10;
@@ -386,32 +499,38 @@
 		pwm = 100;
 	pwm = (pwm * 2559) / 1000;
 	buf[0] = pwm;
-	rc = fan_write_reg(0x30 + (fan * 2), buf, 1);
+	rc = fan_write_reg(0x30 + (id * 2), buf, 1);
 	if (rc < 0)
 		return rc;
 	return 0;
 }
 
-static int get_pwm_fan(int fan)
+static int get_pwm_fan(int fan_index)
 {
 	unsigned char failure;
 	unsigned char active;
 	unsigned char buf[2];
-	int rc;
+	int rc, id;
+
+	if (fcu_fans[fan_index].type != FCU_FAN_PWM)
+		return -EINVAL;
+	id = fcu_fans[fan_index].id; 
+	if (id == FCU_FAN_ABSENT_ID)
+		return -EINVAL;
 
 	rc = fan_read_reg(0x2b, &failure, 1);
 	if (rc != 1)
 		return -EIO;
-	if ((failure & (1 << fan)) != 0)
+	if ((failure & (1 << id)) != 0)
 		return -EFAULT;
 	rc = fan_read_reg(0x2d, &active, 1);
 	if (rc != 1)
 		return -EIO;
-	if ((active & (1 << fan)) == 0)
+	if ((active & (1 << id)) == 0)
 		return -ENXIO;
 
 	/* Programmed value or real current speed */
-	rc = fan_read_reg(0x30 + (fan * 2), buf, 1);
+	rc = fan_read_reg(0x30 + (id * 2), buf, 1);
 	if (rc != 1)
 		return -EIO;
 
@@ -513,80 +632,84 @@
 /*
  * CPUs fans control loop
  */
-static void do_monitor_cpu(struct cpu_pid_state *state)
+
+static int do_read_one_cpu_values(struct cpu_pid_state *state, s32 *temp, s32 *power)
 {
-	s32 temp, voltage, current_a, power, power_target;
-	s32 integral, derivative, proportional, adj_in_target, sval;
-	s64 integ_p, deriv_p, prop_p, sum; 
-	int i, intake, rc;
+	s32 ltemp, volts, amps;
+	int rc = 0;
 
-	DBG("cpu %d:\n", state->index);
+	/* Default (in case of error) */
+	*temp = state->cur_temp;
+	*power = state->cur_power;
 
 	/* Read current fan status */
 	if (state->index == 0)
-		rc = get_rpm_fan(CPUA_EXHAUST_FAN_RPM_ID, !RPM_PID_USE_ACTUAL_SPEED);
+		rc = get_rpm_fan(CPUA_EXHAUST_FAN_RPM_INDEX, !RPM_PID_USE_ACTUAL_SPEED);
 	else
-		rc = get_rpm_fan(CPUB_EXHAUST_FAN_RPM_ID, !RPM_PID_USE_ACTUAL_SPEED);
+		rc = get_rpm_fan(CPUB_EXHAUST_FAN_RPM_INDEX, !RPM_PID_USE_ACTUAL_SPEED);
 	if (rc < 0) {
-		printk(KERN_WARNING "Error %d reading CPU %d exhaust fan !\n",
-		       rc, state->index);
-		/* XXX What do we do now ? */
-	} else
+		/* XXX What do we do now ? Nothing for now, keep old value, but
+		 * return error upstream
+		 */
+		DBG("  cpu %d, fan reading error !\n", state->index);
+	} else {
 		state->rpm = rc;
-	DBG("  current rpm: %d\n", state->rpm);
+		DBG("  cpu %d, exhaust RPM: %d\n", state->index, state->rpm);
+	}
 
 	/* Get some sensor readings and scale it */
-	temp = read_smon_adc(state, 1);
-	if (temp == -1) {
+	ltemp = read_smon_adc(state, 1);
+	if (ltemp == -1) {
+		/* XXX What do we do now ? */
 		state->overtemp++;
-		return;
+		if (rc == 0)
+			rc = -EIO;
+		DBG("  cpu %d, temp reading error !\n", state->index);
+	} else {
+		/* Fixup temperature according to diode calibration
+		 */
+		DBG("  cpu %d, temp raw: %04x, m_diode: %04x, b_diode: %04x\n",
+		    state->index,
+		    ltemp, state->mpu.mdiode, state->mpu.bdiode);
+		*temp = ((s32)ltemp * (s32)state->mpu.mdiode + ((s32)state->mpu.bdiode << 12)) >> 2;
+		state->last_temp = *temp;
+		DBG("  temp: %d.%03d\n", FIX32TOPRINT((*temp)));
 	}
-	voltage = read_smon_adc(state, 3);
-	current_a = read_smon_adc(state, 4);
 
-	/* Fixup temperature according to diode calibration
+	/*
+	 * Read voltage & current and calculate power
 	 */
-	DBG("  temp raw: %04x, m_diode: %04x, b_diode: %04x\n",
-	    temp, state->mpu.mdiode, state->mpu.bdiode);
-	temp = ((s32)temp * (s32)state->mpu.mdiode + ((s32)state->mpu.bdiode << 12)) >> 2;
-	state->last_temp = temp;
-	DBG("  temp: %d.%03d\n", FIX32TOPRINT(temp));
+	volts = read_smon_adc(state, 3);
+	amps = read_smon_adc(state, 4);
 
-	/* Check tmax, increment overtemp if we are there. At tmax+8, we go
-	 * full blown immediately and try to trigger a shutdown
-	 */
-	if (temp >= ((state->mpu.tmax + 8) << 16)) {
-		printk(KERN_WARNING "Warning ! CPU %d temperature way above maximum"
-		       " (%d) !\n",
-		       state->index, temp >> 16);
-		state->overtemp = CPU_MAX_OVERTEMP;
-	} else if (temp > (state->mpu.tmax << 16))
-		state->overtemp++;
-	else
-		state->overtemp = 0;
-	if (state->overtemp >= CPU_MAX_OVERTEMP)
-		critical_state = 1;
-	if (state->overtemp > 0) {
-		state->rpm = state->mpu.rmaxn_exhaust_fan;
-		state->intake_rpm = intake = state->mpu.rmaxn_intake_fan;
-		goto do_set_fans;
-	}
-	
-	/* Scale other sensor values according to fixed scales
+	/* Scale voltage and current raw sensor values according to fixed scales
 	 * obtained in Darwin and calculate power from I and V
 	 */
-	state->voltage = voltage *= ADC_CPU_VOLTAGE_SCALE;
-	state->current_a = current_a *= ADC_CPU_CURRENT_SCALE;
-	power = (((u64)current_a) * ((u64)voltage)) >> 16;
+	volts *= ADC_CPU_VOLTAGE_SCALE;
+	amps *= ADC_CPU_CURRENT_SCALE;
+	*power = (((u64)volts) * ((u64)amps)) >> 16;
+	state->voltage = volts;
+	state->current_a = amps;
+	state->last_power = *power;
+
+	DBG("  cpu %d, current: %d.%03d, voltage: %d.%03d, power: %d.%03d W\n",
+	    state->index, FIX32TOPRINT(state->current_a),
+	    FIX32TOPRINT(state->voltage), FIX32TOPRINT(*power));
+
+	return 0;
+}
+
+static void do_cpu_pid(struct cpu_pid_state *state, s32 temp, s32 power)
+{
+	s32 power_target, integral, derivative, proportional, adj_in_target, sval;
+	s64 integ_p, deriv_p, prop_p, sum; 
+	int i;
 
 	/* Calculate power target value (could be done once for all)
 	 * and convert to a 16.16 fp number
 	 */
 	power_target = ((u32)(state->mpu.pmaxh - state->mpu.padjmax)) << 16;
-
-	DBG("  current: %d.%03d, voltage: %d.%03d\n",
-	    FIX32TOPRINT(current_a), FIX32TOPRINT(voltage));
-	DBG("  power: %d.%03d W, target: %d.%03d, error: %d.%03d\n", FIX32TOPRINT(power),
+	DBG("  power target: %d.%03d, error: %d.%03d\n",
 	    FIX32TOPRINT(power_target), FIX32TOPRINT(power_target - power));
 
 	/* Store temperature and power in history array */
@@ -626,7 +749,7 @@
 	 * input target is mpu.ttarget, input max is mpu.tmax
 	 */
 	integ_p = ((s64)state->mpu.pid_gr) * (s64)integral;
-	DBG("   integ_p: %d\n", (int)(deriv_p >> 36));
+	DBG("   integ_p: %d\n", (int)(integ_p >> 36));
 	sval = (state->mpu.tmax << 16) - ((integ_p >> 20) & 0xffffffff);
 	adj_in_target = (state->mpu.ttarget << 16);
 	if (adj_in_target > sval)
@@ -655,15 +778,136 @@
 	DBG("   sum: %d\n", (int)sum);
 	state->rpm += (s32)sum;
 
-	if (state->rpm < state->mpu.rminn_exhaust_fan)
+	if (state->rpm < (int)state->mpu.rminn_exhaust_fan)
 		state->rpm = state->mpu.rminn_exhaust_fan;
-	if (state->rpm > state->mpu.rmaxn_exhaust_fan)
+	if (state->rpm > (int)state->mpu.rmaxn_exhaust_fan)
 		state->rpm = state->mpu.rmaxn_exhaust_fan;
+}
+
+static void do_monitor_cpu_combined(void)
+{
+	struct cpu_pid_state *state0 = &cpu_state[0];
+	struct cpu_pid_state *state1 = &cpu_state[1];
+	s32 temp0, power0, temp1, power1;
+	s32 temp_combi, power_combi;
+	int rc, intake, pump;
+
+	rc = do_read_one_cpu_values(state0, &temp0, &power0);
+	if (rc < 0) {
+		/* XXX What do we do now ? */
+	}
+	state1->overtemp = 0;
+	rc = do_read_one_cpu_values(state1, &temp1, &power1);
+	if (rc < 0) {
+		/* XXX What do we do now ? */
+	}
+	if (state1->overtemp)
+		state0->overtemp++;
+
+	temp_combi = max(temp0, temp1);
+	power_combi = max(power0, power1);
+
+	/* Check tmax, increment overtemp if we are there. At tmax+8, we go
+	 * full blown immediately and try to trigger a shutdown
+	 */
+	if (temp_combi >= ((state0->mpu.tmax + 8) << 16)) {
+		printk(KERN_WARNING "Warning ! Temperature way above maximum (%d) !\n",
+		       temp_combi >> 16);
+		state0->overtemp = CPU_MAX_OVERTEMP;
+	} else if (temp_combi > (state0->mpu.tmax << 16))
+		state0->overtemp++;
+	else
+		state0->overtemp = 0;
+	if (state0->overtemp >= CPU_MAX_OVERTEMP)
+		critical_state = 1;
+	if (state0->overtemp > 0) {
+		state0->rpm = state0->mpu.rmaxn_exhaust_fan;
+		state0->intake_rpm = intake = state0->mpu.rmaxn_intake_fan;
+		pump = CPU_PUMP_OUTPUT_MAX;
+		goto do_set_fans;
+	}
+
+	/* Do the PID */
+	do_cpu_pid(state0, temp_combi, power_combi);
+
+	/* Calculate intake fan speed */
+	intake = (state0->rpm * CPU_INTAKE_SCALE) >> 16;
+	if (intake < (int)state0->mpu.rminn_intake_fan)
+		intake = state0->mpu.rminn_intake_fan;
+	if (intake > (int)state0->mpu.rmaxn_intake_fan)
+		intake = state0->mpu.rmaxn_intake_fan;
+	state0->intake_rpm = intake;
+
+	/* Calculate pump speed */
+	pump = (state0->rpm * CPU_PUMP_OUTPUT_MAX) /
+		state0->mpu.rmaxn_exhaust_fan;
+	if (pump > CPU_PUMP_OUTPUT_MAX)
+		pump = CPU_PUMP_OUTPUT_MAX;
+	if (pump < CPU_PUMP_OUTPUT_MIN)
+		pump = CPU_PUMP_OUTPUT_MIN;
+	
+ do_set_fans:
+	/* We copy values from state 0 to state 1 for /sysfs */
+	state1->rpm = state0->rpm;
+	state1->intake_rpm = state0->intake_rpm;
+
+	DBG("** CPU %d RPM: %d Ex, %d, Pump: %d, In, overtemp: %d\n",
+	    state1->index, (int)state1->rpm, intake, pump, state1->overtemp);
+
+	/* We should check for errors, shouldn't we ? But then, what
+	 * do we do once the error occurs ? For FCU notified fan
+	 * failures (-EFAULT) we probably want to notify userland
+	 * some way...
+	 */
+	set_rpm_fan(CPUA_INTAKE_FAN_RPM_INDEX, intake);
+	set_rpm_fan(CPUA_EXHAUST_FAN_RPM_INDEX, state0->rpm);
+	set_rpm_fan(CPUB_INTAKE_FAN_RPM_INDEX, intake);
+	set_rpm_fan(CPUB_EXHAUST_FAN_RPM_INDEX, state0->rpm);
+
+	if (fcu_fans[CPUA_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID)
+		set_rpm_fan(CPUA_PUMP_RPM_INDEX, pump);
+	if (fcu_fans[CPUB_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID)
+		set_rpm_fan(CPUB_PUMP_RPM_INDEX, pump);
+}
+
+static void do_monitor_cpu_split(struct cpu_pid_state *state)
+{
+	s32 temp, power;
+	int rc, intake;
+
+	/* Read current fan status */
+	rc = do_read_one_cpu_values(state, &temp, &power);
+	if (rc < 0) {
+		/* XXX What do we do now ? */
+	}
+
+	/* Check tmax, increment overtemp if we are there. At tmax+8, we go
+	 * full blown immediately and try to trigger a shutdown
+	 */
+	if (temp >= ((state->mpu.tmax + 8) << 16)) {
+		printk(KERN_WARNING "Warning ! CPU %d temperature way above maximum"
+		       " (%d) !\n",
+		       state->index, temp >> 16);
+		state->overtemp = CPU_MAX_OVERTEMP;
+	} else if (temp > (state->mpu.tmax << 16))
+		state->overtemp++;
+	else
+		state->overtemp = 0;
+	if (state->overtemp >= CPU_MAX_OVERTEMP)
+		critical_state = 1;
+	if (state->overtemp > 0) {
+		state->rpm = state->mpu.rmaxn_exhaust_fan;
+		state->intake_rpm = intake = state->mpu.rmaxn_intake_fan;
+		goto do_set_fans;
+	}
+
+	/* Do the PID */
+	do_cpu_pid(state, temp, power);
 
 	intake = (state->rpm * CPU_INTAKE_SCALE) >> 16;
-	if (intake < state->mpu.rminn_intake_fan)
+	if (intake < (int)state->mpu.rminn_intake_fan)
 		intake = state->mpu.rminn_intake_fan;
-	if (intake > state->mpu.rmaxn_intake_fan)
+	if (intake > (int)state->mpu.rmaxn_intake_fan)
 		intake = state->mpu.rmaxn_intake_fan;
 	state->intake_rpm = intake;
 
@@ -677,11 +921,11 @@
 	 * some way...
 	 */
 	if (state->index == 0) {
-		set_rpm_fan(CPUA_INTAKE_FAN_RPM_ID, intake);
-		set_rpm_fan(CPUA_EXHAUST_FAN_RPM_ID, state->rpm);
+		set_rpm_fan(CPUA_INTAKE_FAN_RPM_INDEX, intake);
+		set_rpm_fan(CPUA_EXHAUST_FAN_RPM_INDEX, state->rpm);
 	} else {
-		set_rpm_fan(CPUB_INTAKE_FAN_RPM_ID, intake);
-		set_rpm_fan(CPUB_EXHAUST_FAN_RPM_ID, state->rpm);
+		set_rpm_fan(CPUB_INTAKE_FAN_RPM_INDEX, intake);
+		set_rpm_fan(CPUB_EXHAUST_FAN_RPM_INDEX, state->rpm);
 	}
 }
 
@@ -696,6 +940,7 @@
 	state->overtemp = 0;
 	state->adc_config = 0x00;
 
+
 	if (index == 0)
 		state->monitor = attach_i2c_chip(SUPPLY_MONITOR_ID, "CPU0_monitor");
 	else if (index == 1)
@@ -778,7 +1023,7 @@
 	DBG("backside:\n");
 
 	/* Check fan status */
-	rc = get_pwm_fan(BACKSIDE_FAN_PWM_ID);
+	rc = get_pwm_fan(BACKSIDE_FAN_PWM_INDEX);
 	if (rc < 0) {
 		printk(KERN_WARNING "Error %d reading backside fan !\n", rc);
 		/* XXX What do we do now ? */
@@ -790,12 +1035,12 @@
 	temp = i2c_smbus_read_byte_data(state->monitor, MAX6690_EXT_TEMP) << 16;
 	state->last_temp = temp;
 	DBG("  temp: %d.%03d, target: %d.%03d\n", FIX32TOPRINT(temp),
-	    FIX32TOPRINT(BACKSIDE_PID_INPUT_TARGET));
+	    FIX32TOPRINT(backside_params.input_target));
 
 	/* Store temperature and error in history array */
 	state->cur_sample = (state->cur_sample + 1) % BACKSIDE_PID_HISTORY_SIZE;
 	state->sample_history[state->cur_sample] = temp;
-	state->error_history[state->cur_sample] = temp - BACKSIDE_PID_INPUT_TARGET;
+	state->error_history[state->cur_sample] = temp - backside_params.input_target;
 	
 	/* If first loop, fill the history table */
 	if (state->first) {
@@ -804,7 +1049,7 @@
 				BACKSIDE_PID_HISTORY_SIZE;
 			state->sample_history[state->cur_sample] = temp;
 			state->error_history[state->cur_sample] =
-				temp - BACKSIDE_PID_INPUT_TARGET;
+				temp - backside_params.input_target;
 		}
 		state->first = 0;
 	}
@@ -816,7 +1061,7 @@
 		integral += state->error_history[i];
 	integral *= BACKSIDE_PID_INTERVAL;
 	DBG("  integral: %08x\n", integral);
-	integ_p = ((s64)BACKSIDE_PID_G_r) * (s64)integral;
+	integ_p = ((s64)backside_params.G_r) * (s64)integral;
 	DBG("   integ_p: %d\n", (int)(integ_p >> 36));
 	sum += integ_p;
 
@@ -825,12 +1070,12 @@
 		state->error_history[(state->cur_sample + BACKSIDE_PID_HISTORY_SIZE - 1)
 				    % BACKSIDE_PID_HISTORY_SIZE];
 	derivative /= BACKSIDE_PID_INTERVAL;
-	deriv_p = ((s64)BACKSIDE_PID_G_d) * (s64)derivative;
+	deriv_p = ((s64)backside_params.G_d) * (s64)derivative;
 	DBG("   deriv_p: %d\n", (int)(deriv_p >> 36));
 	sum += deriv_p;
 
 	/* Calculate the proportional term */
-	prop_p = ((s64)BACKSIDE_PID_G_p) * (s64)(state->error_history[state->cur_sample]);
+	prop_p = ((s64)backside_params.G_p) * (s64)(state->error_history[state->cur_sample]);
 	DBG("   prop_p: %d\n", (int)(prop_p >> 36));
 	sum += prop_p;
 
@@ -839,13 +1084,13 @@
 
 	DBG("   sum: %d\n", (int)sum);
 	state->pwm += (s32)sum;
-	if (state->pwm < BACKSIDE_PID_OUTPUT_MIN)
-		state->pwm = BACKSIDE_PID_OUTPUT_MIN;
-	if (state->pwm > BACKSIDE_PID_OUTPUT_MAX)
-		state->pwm = BACKSIDE_PID_OUTPUT_MAX;
+	if (state->pwm < backside_params.output_min)
+		state->pwm = backside_params.output_min;
+	if (state->pwm > backside_params.output_max)
+		state->pwm = backside_params.output_max;
 
 	DBG("** BACKSIDE PWM: %d\n", (int)state->pwm);
-	set_pwm_fan(BACKSIDE_FAN_PWM_ID, state->pwm);
+	set_pwm_fan(BACKSIDE_FAN_PWM_INDEX, state->pwm);
 }
 
 /*
@@ -853,6 +1098,35 @@
  */
 static int init_backside_state(struct backside_pid_state *state)
 {
+	struct device_node *u3;
+	int u3h = 1; /* conservative by default */
+
+	/*
+	 * There are different PID params for machines with U3 and machines
+	 * with U3H, pick the right ones now
+	 */
+	u3 = of_find_node_by_path("/u3@0,f8000000");
+	if (u3 != NULL) {
+		u32 *vers = (u32 *)get_property(u3, "device-rev", NULL);
+		if (vers)
+			if (((*vers) & 0x3f) < 0x34)
+				u3h = 0;
+		of_node_put(u3);
+	}
+
+	backside_params.G_p = BACKSIDE_PID_G_p;
+	backside_params.G_r = BACKSIDE_PID_G_r;
+	backside_params.output_max = BACKSIDE_PID_OUTPUT_MAX;
+	if (u3h) {
+		backside_params.G_d = BACKSIDE_PID_U3H_G_d;
+		backside_params.input_target = BACKSIDE_PID_U3H_INPUT_TARGET;
+		backside_params.output_min = BACKSIDE_PID_U3H_OUTPUT_MIN;
+	} else {
+		backside_params.G_d = BACKSIDE_PID_U3_G_d;
+		backside_params.input_target = BACKSIDE_PID_U3_INPUT_TARGET;
+		backside_params.output_min = BACKSIDE_PID_U3_OUTPUT_MIN;
+	}
+
 	state->ticks = 1;
 	state->first = 1;
 	state->pwm = 50;
@@ -898,7 +1172,7 @@
 	DBG("drives:\n");
 
 	/* Check fan status */
-	rc = get_rpm_fan(DRIVES_FAN_RPM_ID, !RPM_PID_USE_ACTUAL_SPEED);
+	rc = get_rpm_fan(DRIVES_FAN_RPM_INDEX, !RPM_PID_USE_ACTUAL_SPEED);
 	if (rc < 0) {
 		printk(KERN_WARNING "Error %d reading drives fan !\n", rc);
 		/* XXX What do we do now ? */
@@ -965,7 +1239,7 @@
 		state->rpm = DRIVES_PID_OUTPUT_MAX;
 
 	DBG("** DRIVES RPM: %d\n", (int)state->rpm);
-	set_rpm_fan(DRIVES_FAN_RPM_ID, state->rpm);
+	set_rpm_fan(DRIVES_FAN_RPM_INDEX, state->rpm);
 }
 
 /*
@@ -1032,7 +1306,7 @@
 	}
 
 	/* Set the PCI fan once for now */
-	set_pwm_fan(SLOTS_FAN_PWM_ID, SLOTS_FAN_DEFAULT_PWM);
+	set_pwm_fan(SLOTS_FAN_PWM_INDEX, SLOTS_FAN_DEFAULT_PWM);
 
 	/* Initialize ADCs */
 	initialize_adc(&cpu_state[0]);
@@ -1047,9 +1321,13 @@
 		start = jiffies;
 
 		down(&driver_lock);
-		do_monitor_cpu(&cpu_state[0]);
-		if (cpu_state[1].monitor != NULL)
-			do_monitor_cpu(&cpu_state[1]);
+		if (cpu_pid_type == CPU_PID_TYPE_COMBINED)
+			do_monitor_cpu_combined();
+		else {
+			do_monitor_cpu_split(&cpu_state[0]);
+			if (cpu_state[1].monitor != NULL)
+				do_monitor_cpu_split(&cpu_state[1]);
+		}
 		do_monitor_backside(&backside_state);
 		do_monitor_drives(&drives_state);
 		up(&driver_lock);
@@ -1113,6 +1391,19 @@
 
 	DBG("counted %d CPUs in the device-tree\n", cpu_count);
 
+	/* Decide the type of PID algorithm to use based on the presence of
+	 * the pumps, though that may not be the best way, that is good enough
+	 * for now
+	 */
+	if (machine_is_compatible("PowerMac7,3")
+	    && (cpu_count > 1)
+	    && fcu_fans[CPUA_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID
+	    && fcu_fans[CPUB_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID) {
+		printk(KERN_INFO "Liquid cooling pumps detected, using new algorithm !\n");
+		cpu_pid_type = CPU_PID_TYPE_COMBINED;
+	} else
+		cpu_pid_type = CPU_PID_TYPE_SPLIT;
+
 	/* Create control loops for everything. If any fail, everything
 	 * fails
 	 */
@@ -1257,12 +1548,91 @@
 	return 0;
 }
 
+static void fcu_lookup_fans(struct device_node *fcu_node)
+{
+	struct device_node *np = NULL;
+	int i;
+
+	/* The table is filled by default with values that are suitable
+	 * for the old machines without device-tree informations. We scan
+	 * the device-tree and override those values with whatever is
+	 * there
+	 */
+
+	DBG("Looking up FCU controls in device-tree...\n");
+
+	while ((np = of_get_next_child(fcu_node, np)) != NULL) {
+		int type = -1;
+		char *loc;
+		u32 *reg;
+
+		DBG(" control: %s, type: %s\n", np->name, np->type);
+
+		/* Detect control type */
+		if (!strcmp(np->type, "fan-rpm-control") ||
+		    !strcmp(np->type, "fan-rpm"))
+			type = FCU_FAN_RPM;
+		if (!strcmp(np->type, "fan-pwm-control") ||
+		    !strcmp(np->type, "fan-pwm"))
+			type = FCU_FAN_PWM;
+		/* Only care about fans for now */
+		if (type == -1)
+			continue;
+
+		/* Lookup for a matching location */
+		loc = (char *)get_property(np, "location", NULL);
+		reg = (u32 *)get_property(np, "reg", NULL);
+		if (loc == NULL || reg == NULL)
+			continue;
+		DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg);
+
+		for (i = 0; i < FCU_FAN_COUNT; i++) {
+			int fan_id;
+
+			if (strcmp(loc, fcu_fans[i].loc))
+				continue;
+			DBG(" location match, index: %d\n", i);
+			fcu_fans[i].id = FCU_FAN_ABSENT_ID;
+			if (type != fcu_fans[i].type) {
+				printk(KERN_WARNING "therm_pm72: Fan type mismatch "
+				       "in device-tree for %s\n", np->full_name);
+				break;
+			}
+			if (type == FCU_FAN_RPM)
+				fan_id = ((*reg) - 0x10) / 2;
+			else
+				fan_id = ((*reg) - 0x30) / 2;
+			if (fan_id > 7) {
+				printk(KERN_WARNING "therm_pm72: Can't parse "
+				       "fan ID in device-tree for %s\n", np->full_name);
+				break;
+			}
+			DBG(" fan id -> %d, type -> %d\n", fan_id, type);
+			fcu_fans[i].id = fan_id;
+		}
+	}
+
+	/* Now dump the array */
+	printk(KERN_INFO "Detected fan controls:\n");
+	for (i = 0; i < FCU_FAN_COUNT; i++) {
+		if (fcu_fans[i].id == FCU_FAN_ABSENT_ID)
+			continue;
+		printk(KERN_INFO "  %d: %s fan, id %d, location: %s\n", i,
+		       fcu_fans[i].type == FCU_FAN_RPM ? "RPM" : "PWM",
+		       fcu_fans[i].id, fcu_fans[i].loc);
+	}
+}
+
 static int fcu_of_probe(struct of_device* dev, const struct of_match *match)
 {
 	int rc;
 
 	state = state_detached;
 
+	/* Lookup the fans in the device tree */
+	fcu_lookup_fans(dev->node);
+
+	/* Add the driver */
 	rc = i2c_add_driver(&therm_pm72_driver);
 	if (rc < 0)
 		return rc;
@@ -1301,15 +1671,20 @@
 {
 	struct device_node *np;
 
-	if (!machine_is_compatible("PowerMac7,2"))
+	if (!machine_is_compatible("PowerMac7,2") &&
+	    !machine_is_compatible("PowerMac7,3"))
 	    	return -ENODEV;
 
 	printk(KERN_INFO "PowerMac G5 Thermal control driver %s\n", VERSION);
 
 	np = of_find_node_by_type(NULL, "fcu");
 	if (np == NULL) {
-		printk(KERN_ERR "Can't find FCU in device-tree !\n");
-		return -ENODEV;
+		/* Some machines have strangely broken device-tree */
+		np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e");
+		if (np == NULL) {
+			    printk(KERN_ERR "Can't find FCU in device-tree !\n");
+			    return -ENODEV;
+		}
 	}
 	of_dev = of_platform_device_create(np, "temperature");
 	if (of_dev == NULL) {
diff -Nru a/drivers/macintosh/therm_pm72.h b/drivers/macintosh/therm_pm72.h
--- a/drivers/macintosh/therm_pm72.h	2004-12-24 13:36:49 -08:00
+++ b/drivers/macintosh/therm_pm72.h	2004-12-24 13:36:49 -08:00
@@ -119,18 +119,33 @@
 #define ADC_CPU_CURRENT_SCALE	0x1f40	/* _AD4 */
 
 /*
- * PID factors for the U3/Backside fan control loop
+ * PID factors for the U3/Backside fan control loop. We have 2 sets
+ * of values here, one set for U3 and one set for U3H
  */
-#define BACKSIDE_FAN_PWM_ID		1
-#define BACKSIDE_PID_G_d		0x02800000
+#define BACKSIDE_FAN_PWM_DEFAULT_ID	1
+#define BACKSIDE_FAN_PWM_INDEX		0
+#define BACKSIDE_PID_U3_G_d		0x02800000
+#define BACKSIDE_PID_U3H_G_d		0x01400000
 #define BACKSIDE_PID_G_p		0x00500000
 #define BACKSIDE_PID_G_r		0x00000000
-#define BACKSIDE_PID_INPUT_TARGET	0x00410000
+#define BACKSIDE_PID_U3_INPUT_TARGET	0x00410000
+#define BACKSIDE_PID_U3H_INPUT_TARGET	0x004b0000
 #define BACKSIDE_PID_INTERVAL		5
 #define BACKSIDE_PID_OUTPUT_MAX		100
-#define BACKSIDE_PID_OUTPUT_MIN		20
+#define BACKSIDE_PID_U3_OUTPUT_MIN	20
+#define BACKSIDE_PID_U3H_OUTPUT_MIN	30
 #define BACKSIDE_PID_HISTORY_SIZE	2
 
+struct basckside_pid_params
+{
+	s32			G_d;
+	s32			G_p;
+	s32			G_r;
+	s32			input_target;
+	s32			output_min;
+	s32			output_max;
+};
+
 struct backside_pid_state
 {
 	int			ticks;
@@ -146,7 +161,8 @@
 /*
  * PID factors for the Drive Bay fan control loop
  */
-#define DRIVES_FAN_RPM_ID      		2
+#define DRIVES_FAN_RPM_DEFAULT_ID	2
+#define DRIVES_FAN_RPM_INDEX		1
 #define DRIVES_PID_G_d			0x01e00000
 #define DRIVES_PID_G_p			0x00500000
 #define DRIVES_PID_G_r			0x00000000
@@ -168,7 +184,8 @@
 	int			first;
 };
 
-#define SLOTS_FAN_PWM_ID       		2
+#define SLOTS_FAN_PWM_DEFAULT_ID	2
+#define SLOTS_FAN_PWM_INDEX		2
 #define	SLOTS_FAN_DEFAULT_PWM		50 /* Do better here ! */
 
 /*
@@ -191,10 +208,15 @@
  * CPU B FAKE POWER	49	(I_V_inputs: 18, 19)
  */
 
-#define CPUA_INTAKE_FAN_RPM_ID		3
-#define CPUA_EXHAUST_FAN_RPM_ID		4
-#define CPUB_INTAKE_FAN_RPM_ID		5
-#define CPUB_EXHAUST_FAN_RPM_ID		6
+#define CPUA_INTAKE_FAN_RPM_DEFAULT_ID	3
+#define CPUA_EXHAUST_FAN_RPM_DEFAULT_ID	4
+#define CPUB_INTAKE_FAN_RPM_DEFAULT_ID	5
+#define CPUB_EXHAUST_FAN_RPM_DEFAULT_ID	6
+
+#define CPUA_INTAKE_FAN_RPM_INDEX	3
+#define CPUA_EXHAUST_FAN_RPM_INDEX	4
+#define CPUB_INTAKE_FAN_RPM_INDEX	5
+#define CPUB_EXHAUST_FAN_RPM_INDEX	6
 
 #define CPU_INTAKE_SCALE		0x0000f852
 #define CPU_TEMP_HISTORY_SIZE		2
@@ -202,6 +224,11 @@
 #define CPU_PID_INTERVAL		1
 #define CPU_MAX_OVERTEMP		30
 
+#define CPUA_PUMP_RPM_INDEX		7
+#define CPUB_PUMP_RPM_INDEX		8
+#define CPU_PUMP_OUTPUT_MAX		3700
+#define CPU_PUMP_OUTPUT_MIN		1000
+
 struct cpu_pid_state
 {
 	int			index;
@@ -219,6 +246,7 @@
 	s32			voltage;
 	s32			current_a;
 	s32			last_temp;
+	s32			last_power;
 	int			first;
 	u8			adc_config;
 };
diff -Nru a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
--- a/drivers/macintosh/therm_windtunnel.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/macintosh/therm_windtunnel.c	2004-12-24 13:37:03 -08:00
@@ -353,12 +353,12 @@
 }
 
 static struct i2c_driver g4fan_driver = {  
-	.name		= "Apple G4 Thermostat/Fan",
+	.owner		= THIS_MODULE,
+	.name		= "therm_windtunnel",
 	.id		= I2C_DRIVERID_G4FAN,
 	.flags		= I2C_DF_NOTIFY,
-	.attach_adapter = &do_attach,
-	.detach_client	= &do_detach,
-	.command	= NULL,
+	.attach_adapter = do_attach,
+	.detach_client	= do_detach,
 };
 
 static int
diff -Nru a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
--- a/drivers/macintosh/via-cuda.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/macintosh/via-cuda.c	2004-12-24 13:36:18 -08:00
@@ -32,7 +32,7 @@
 #include <asm/system.h>
 #include <linux/init.h>
 
-static volatile unsigned char *via;
+static volatile unsigned char __iomem *via;
 static spinlock_t cuda_lock = SPIN_LOCK_UNLOCKED;
 
 #ifdef CONFIG_MAC
@@ -160,7 +160,7 @@
 	if (vias->n_addrs < 1 || vias->n_intrs < 1)
 	    return 0;
     }
-    via = (volatile unsigned char *) ioremap(vias->addrs->address, 0x2000);
+    via = ioremap(vias->addrs->address, 0x2000);
 
     cuda_state = idle;
     sys_ctrler = SYS_CTRLER_CUDA;
diff -Nru a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
--- a/drivers/macintosh/via-pmu.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/macintosh/via-pmu.c	2004-12-24 13:37:19 -08:00
@@ -72,7 +72,7 @@
 /* How many iterations between battery polls */
 #define BATTERY_POLLING_COUNT	2
 
-static volatile unsigned char *via;
+static volatile unsigned char __iomem *via;
 
 /* VIA registers - spaced 0x200 bytes apart */
 #define RS		0x200		/* skip between registers */
@@ -141,7 +141,7 @@
 static int pmu_kind = PMU_UNKNOWN;
 static int pmu_fully_inited = 0;
 static int pmu_has_adb;
-static unsigned char *gpio_reg = NULL;
+static unsigned char __iomem *gpio_reg = NULL;
 static int gpio_irq = -1;
 static int gpio_irq_enabled = -1;
 static volatile int pmu_suspended = 0;
@@ -153,8 +153,8 @@
 static int option_lid_wakeup = 1;
 static int sleep_in_progress;
 static int can_sleep;
-static unsigned long async_req_locks;
 #endif /* CONFIG_PMAC_PBOOK */
+static unsigned long async_req_locks;
 static unsigned int pmu_irq_stats[11];
 
 static struct proc_dir_entry *proc_pmu_root;
@@ -352,7 +352,7 @@
 	} else
 		pmu_kind = PMU_UNKNOWN;
 
-	via = (volatile unsigned char *) ioremap(vias->addrs->address, 0x2000);
+	via = ioremap(vias->addrs->address, 0x2000);
 	
 	out_8(&via[IER], IER_CLR | 0x7f);	/* disable all intrs */
 	out_8(&via[IFR], 0x7f);			/* clear IFR */
@@ -1164,7 +1164,7 @@
 static inline void
 send_byte(int x)
 {
-	volatile unsigned char *v = via;
+	volatile unsigned char __iomem *v = via;
 
 	out_8(&v[ACR], in_8(&v[ACR]) | SR_OUT | SR_EXT);
 	out_8(&v[SR], x);
@@ -1175,7 +1175,7 @@
 static inline void
 recv_byte(void)
 {
-	volatile unsigned char *v = via;
+	volatile unsigned char __iomem *v = via;
 
 	out_8(&v[ACR], (in_8(&v[ACR]) & ~SR_OUT) | SR_EXT);
 	in_8(&v[SR]);		/* resets SR */
@@ -2630,8 +2630,8 @@
 	unsigned int hid0;
 	unsigned long p;
 	struct adb_request sleep_req;
-	char *mem_ctrl;
-	unsigned int *mem_ctrl_sleep;
+	void __iomem *mem_ctrl;
+	unsigned int __iomem *mem_ctrl_sleep;
 
 	/* first map in the memory controller registers */
 	mem_ctrl = ioremap(PB3400_MEM_CTRL, 0x100);
@@ -2639,7 +2639,7 @@
 		printk("powerbook_sleep_3400: ioremap failed\n");
 		return -ENOMEM;
 	}
-	mem_ctrl_sleep = (unsigned int *) (mem_ctrl + PB3400_MEM_CTRL_SLEEP);
+	mem_ctrl_sleep = mem_ctrl + PB3400_MEM_CTRL_SLEEP;
 
 	/* Allocate room for PCI save */
 	pbook_alloc_pci_save();
@@ -2977,7 +2977,7 @@
 
 #ifdef DEBUG_SLEEP
 static inline void  __pmac
-polled_handshake(volatile unsigned char *via)
+polled_handshake(volatile unsigned char __iomem *via)
 {
 	via[B] &= ~TREQ; eieio();
 	while ((via[B] & TACK) != 0)
@@ -2988,7 +2988,7 @@
 }
 
 static inline void  __pmac
-polled_send_byte(volatile unsigned char *via, int x)
+polled_send_byte(volatile unsigned char __iomem *via, int x)
 {
 	via[ACR] |= SR_OUT | SR_EXT; eieio();
 	via[SR] = x; eieio();
@@ -2996,7 +2996,7 @@
 }
 
 static inline int __pmac
-polled_recv_byte(volatile unsigned char *via)
+polled_recv_byte(volatile unsigned char __iomem *via)
 {
 	int x;
 
@@ -3012,7 +3012,7 @@
 {
 	unsigned long flags;
 	int i, l, c;
-	volatile unsigned char *v = via;
+	volatile unsigned char __iomem *v = via;
 
 	req->complete = 1;
 	c = req->data[0];
diff -Nru a/drivers/md/Kconfig b/drivers/md/Kconfig
--- a/drivers/md/Kconfig	2004-12-24 13:36:18 -08:00
+++ b/drivers/md/Kconfig	2004-12-24 13:36:18 -08:00
@@ -164,6 +164,15 @@
 
 	  If unsure, say N.
 
+config MD_FAULTY
+	tristate "Faulty test module for MD"
+	depends on BLK_DEV_MD
+	help
+	  The "faulty" module allows for a block device that occasionally returns
+	  read or write errors.  It is useful for testing.
+
+	  In unsure, say N.
+
 config BLK_DEV_DM
 	tristate "Device mapper support"
 	depends on MD
diff -Nru a/drivers/md/Makefile b/drivers/md/Makefile
--- a/drivers/md/Makefile	2004-12-24 13:36:56 -08:00
+++ b/drivers/md/Makefile	2004-12-24 13:36:56 -08:00
@@ -24,6 +24,7 @@
 obj-$(CONFIG_MD_RAID5)		+= raid5.o xor.o
 obj-$(CONFIG_MD_RAID6)		+= raid6.o xor.o
 obj-$(CONFIG_MD_MULTIPATH)	+= multipath.o
+obj-$(CONFIG_MD_FAULTY)		+= faulty.o
 obj-$(CONFIG_BLK_DEV_MD)	+= md.o
 obj-$(CONFIG_BLK_DEV_DM)	+= dm-mod.o
 obj-$(CONFIG_DM_CRYPT)		+= dm-crypt.o
diff -Nru a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
--- a/drivers/md/dm-crypt.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/md/dm-crypt.c	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2003 Christophe Saout <christophe@saout.de>
+ * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
  *
  * This file is released under the GPL.
  */
@@ -15,6 +16,7 @@
 #include <linux/workqueue.h>
 #include <asm/atomic.h>
 #include <asm/scatterlist.h>
+#include <asm/page.h>
 
 #include "dm.h"
 
@@ -40,12 +42,22 @@
 	struct bio *bio_out;
 	unsigned int offset_in;
 	unsigned int offset_out;
-	int idx_in;
-	int idx_out;
+	unsigned int idx_in;
+	unsigned int idx_out;
 	sector_t sector;
 	int write;
 };
 
+struct crypt_config;
+
+struct crypt_iv_operations {
+	int (*ctr)(struct crypt_config *cc, struct dm_target *ti,
+	           const char *opts);
+	void (*dtr)(struct crypt_config *cc);
+	const char *(*status)(struct crypt_config *cc);
+	int (*generator)(struct crypt_config *cc, u8 *iv, sector_t sector);
+};
+
 /*
  * Crypt: maps a linear range of a block device
  * and encrypts / decrypts at the same time.
@@ -64,11 +76,14 @@
 	/*
 	 * crypto related data
 	 */
-	struct crypto_tfm *tfm;
+	struct crypt_iv_operations *iv_gen_ops;
+	char *iv_mode;
+	void *iv_gen_private;
 	sector_t iv_offset;
-	int (*iv_generator)(struct crypt_config *cc, u8 *iv, sector_t sector);
-	int iv_size;
-	int key_size;
+	unsigned int iv_size;
+
+	struct crypto_tfm *tfm;
+	unsigned int key_size;
 	u8 key[0];
 };
 
@@ -93,18 +108,129 @@
 
 
 /*
- * Different IV generation algorithms
+ * Different IV generation algorithms:
+ *
+ * plain: the initial vector is the 32-bit low-endian version of the sector
+ *        number, padded with zeros if neccessary.
+ *
+ * ess_iv: "encrypted sector|salt initial vector", the sector number is
+ *         encrypted with the bulk cipher using a salt as key. The salt
+ *         should be derived from the bulk cipher's key via hashing.
+ *
+ * plumb: unimplemented, see:
+ * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454
  */
-static int crypt_iv_plain(struct crypt_config *cc, u8 *iv, sector_t sector)
+
+static int crypt_iv_plain_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
 {
+	memset(iv, 0, cc->iv_size);
 	*(u32 *)iv = cpu_to_le32(sector & 0xffffffff);
-	if (cc->iv_size > sizeof(u32) / sizeof(u8))
-		memset(iv + (sizeof(u32) / sizeof(u8)), 0,
-		       cc->iv_size - (sizeof(u32) / sizeof(u8)));
 
 	return 0;
 }
 
+static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
+	                      const char *opts)
+{
+	struct crypto_tfm *essiv_tfm;
+	struct crypto_tfm *hash_tfm;
+	struct scatterlist sg;
+	unsigned int saltsize;
+	u8 *salt;
+
+	if (opts == NULL) {
+		ti->error = PFX "Digest algorithm missing for ESSIV mode";
+		return -EINVAL;
+	}
+
+	/* Hash the cipher key with the given hash algorithm */
+	hash_tfm = crypto_alloc_tfm(opts, 0);
+	if (hash_tfm == NULL) {
+		ti->error = PFX "Error initializing ESSIV hash";
+		return -EINVAL;
+	}
+
+	if (crypto_tfm_alg_type(hash_tfm) != CRYPTO_ALG_TYPE_DIGEST) {
+		ti->error = PFX "Expected digest algorithm for ESSIV hash";
+		crypto_free_tfm(hash_tfm);
+		return -EINVAL;
+	}
+
+	saltsize = crypto_tfm_alg_digestsize(hash_tfm);
+	salt = kmalloc(saltsize, GFP_KERNEL);
+	if (salt == NULL) {
+		ti->error = PFX "Error kmallocing salt storage in ESSIV";
+		crypto_free_tfm(hash_tfm);
+		return -ENOMEM;
+	}
+
+	sg.page = virt_to_page(cc->key);
+	sg.offset = offset_in_page(cc->key);
+	sg.length = cc->key_size;
+	crypto_digest_digest(hash_tfm, &sg, 1, salt);
+	crypto_free_tfm(hash_tfm);
+
+	/* Setup the essiv_tfm with the given salt */
+	essiv_tfm = crypto_alloc_tfm(crypto_tfm_alg_name(cc->tfm),
+	                             CRYPTO_TFM_MODE_ECB);
+	if (essiv_tfm == NULL) {
+		ti->error = PFX "Error allocating crypto tfm for ESSIV";
+		kfree(salt);
+		return -EINVAL;
+	}
+	if (crypto_tfm_alg_blocksize(essiv_tfm)
+	    != crypto_tfm_alg_ivsize(cc->tfm)) {
+		ti->error = PFX "Block size of ESSIV cipher does "
+			        "not match IV size of block cipher";
+		crypto_free_tfm(essiv_tfm);
+		kfree(salt);
+		return -EINVAL;
+	}
+	if (crypto_cipher_setkey(essiv_tfm, salt, saltsize) < 0) {
+		ti->error = PFX "Failed to set key for ESSIV cipher";
+		crypto_free_tfm(essiv_tfm);
+		kfree(salt);
+		return -EINVAL;
+	}
+	kfree(salt);
+
+	cc->iv_gen_private = (void *)essiv_tfm;
+	return 0;
+}
+
+static void crypt_iv_essiv_dtr(struct crypt_config *cc)
+{
+	crypto_free_tfm((struct crypto_tfm *)cc->iv_gen_private);
+	cc->iv_gen_private = NULL;
+}
+
+static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
+{
+	struct scatterlist sg = { NULL, };
+
+	memset(iv, 0, cc->iv_size);
+	*(u64 *)iv = cpu_to_le64(sector);
+
+	sg.page = virt_to_page(iv);
+	sg.offset = offset_in_page(iv);
+	sg.length = cc->iv_size;
+	crypto_cipher_encrypt((struct crypto_tfm *)cc->iv_gen_private,
+	                      &sg, &sg, cc->iv_size);
+
+	return 0;
+}
+
+static struct crypt_iv_operations crypt_iv_plain_ops = {
+	.generator = crypt_iv_plain_gen
+};
+
+static struct crypt_iv_operations crypt_iv_essiv_ops = {
+	.ctr       = crypt_iv_essiv_ctr,
+	.dtr       = crypt_iv_essiv_dtr,
+	.generator = crypt_iv_essiv_gen
+};
+
+
 static inline int
 crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out,
                           struct scatterlist *in, unsigned int length,
@@ -113,8 +239,8 @@
 	u8 iv[cc->iv_size];
 	int r;
 
-	if (cc->iv_generator) {
-		r = cc->iv_generator(cc, iv, sector);
+	if (cc->iv_gen_ops) {
+		r = cc->iv_gen_ops->generator(cc, iv, sector);
 		if (r < 0)
 			return r;
 
@@ -200,13 +326,13 @@
  */
 static struct bio *
 crypt_alloc_buffer(struct crypt_config *cc, unsigned int size,
-                   struct bio *base_bio, int *bio_vec_idx)
+                   struct bio *base_bio, unsigned int *bio_vec_idx)
 {
 	struct bio *bio;
-	int nr_iovecs = dm_div_up(size, PAGE_SIZE);
+	unsigned int nr_iovecs = dm_div_up(size, PAGE_SIZE);
 	int gfp_mask = GFP_NOIO | __GFP_HIGHMEM;
-	int flags = current->flags;
-	int i;
+	unsigned long flags = current->flags;
+	unsigned int i;
 
 	/*
 	 * Tell VM to act less aggressively and fail earlier.
@@ -280,9 +406,8 @@
 static void crypt_free_buffer_pages(struct crypt_config *cc,
                                     struct bio *bio, unsigned int bytes)
 {
-	unsigned int start, end;
+	unsigned int i, start, end;
 	struct bio_vec *bv;
-	int i;
 
 	/*
 	 * This is ugly, but Jens Axboe thinks that using bi_idx in the
@@ -366,11 +491,11 @@
 /*
  * Decode key from its hex representation
  */
-static int crypt_decode_key(u8 *key, char *hex, int size)
+static int crypt_decode_key(u8 *key, char *hex, unsigned int size)
 {
 	char buffer[3];
 	char *endp;
-	int i;
+	unsigned int i;
 
 	buffer[2] = '\0';
 
@@ -393,9 +518,9 @@
 /*
  * Encode key into its hex representation
  */
-static void crypt_encode_key(char *hex, u8 *key, int size)
+static void crypt_encode_key(char *hex, u8 *key, unsigned int size)
 {
-	int i;
+	unsigned int i;
 
 	for(i = 0; i < size; i++) {
 		sprintf(hex, "%02x", *key);
@@ -414,9 +539,11 @@
 	struct crypto_tfm *tfm;
 	char *tmp;
 	char *cipher;
-	char *mode;
-	int crypto_flags;
-	int key_size;
+	char *chainmode;
+	char *ivmode;
+	char *ivopts;
+	unsigned int crypto_flags;
+	unsigned int key_size;
 
 	if (argc != 5) {
 		ti->error = PFX "Not enough arguments";
@@ -425,7 +552,9 @@
 
 	tmp = argv[0];
 	cipher = strsep(&tmp, "-");
-	mode = strsep(&tmp, "-");
+	chainmode = strsep(&tmp, "-");
+	ivopts = strsep(&tmp, "-");
+	ivmode = strsep(&ivopts, ":");
 
 	if (tmp)
 		DMWARN(PFX "Unexpected additional cipher options");
@@ -439,19 +568,33 @@
 		return -ENOMEM;
 	}
 
-	if (!mode || strcmp(mode, "plain") == 0)
-		cc->iv_generator = crypt_iv_plain;
-	else if (strcmp(mode, "ecb") == 0)
-		cc->iv_generator = NULL;
-	else {
-		ti->error = PFX "Invalid chaining mode";
+	cc->key_size = key_size;
+	if ((!key_size && strcmp(argv[1], "-") != 0) ||
+	    (key_size && crypt_decode_key(cc->key, argv[1], key_size) < 0)) {
+		ti->error = PFX "Error decoding key";
 		goto bad1;
 	}
 
-	if (cc->iv_generator)
+	/* Compatiblity mode for old dm-crypt cipher strings */
+	if (!chainmode || (strcmp(chainmode, "plain") == 0 && !ivmode)) {
+		chainmode = "cbc";
+		ivmode = "plain";
+	}
+
+	/* Choose crypto_flags according to chainmode */
+	if (strcmp(chainmode, "cbc") == 0)
 		crypto_flags = CRYPTO_TFM_MODE_CBC;
-	else
+	else if (strcmp(chainmode, "ecb") == 0)
 		crypto_flags = CRYPTO_TFM_MODE_ECB;
+	else {
+		ti->error = PFX "Unknown chaining mode";
+		goto bad1;
+	}
+
+	if (crypto_flags != CRYPTO_TFM_MODE_ECB && !ivmode) {
+		ti->error = PFX "This chaining mode requires an IV mechanism";
+		goto bad1;
+	}
 
 	tfm = crypto_alloc_tfm(cipher, crypto_flags);
 	if (!tfm) {
@@ -463,15 +606,39 @@
 		goto bad2;
 	}
 
+	cc->tfm = tfm;
+
+	/*
+	 * Choose ivmode. Valid modes: "plain", "essiv:<esshash>".
+	 * See comments at iv code
+	 */
+
+	if (ivmode == NULL)
+		cc->iv_gen_ops = NULL;
+	else if (strcmp(ivmode, "plain") == 0)
+		cc->iv_gen_ops = &crypt_iv_plain_ops;
+	else if (strcmp(ivmode, "essiv") == 0)
+		cc->iv_gen_ops = &crypt_iv_essiv_ops;
+	else {
+		ti->error = PFX "Invalid IV mode";
+		goto bad2;
+	}
+
+	if (cc->iv_gen_ops && cc->iv_gen_ops->ctr &&
+	    cc->iv_gen_ops->ctr(cc, ti, ivopts) < 0)
+		goto bad2;
+
 	if (tfm->crt_cipher.cit_decrypt_iv && tfm->crt_cipher.cit_encrypt_iv)
-		/* at least a 32 bit sector number should fit in our buffer */
+		/* at least a 64 bit sector number should fit in our buffer */
 		cc->iv_size = max(crypto_tfm_alg_ivsize(tfm),
-		                  (unsigned int)(sizeof(u32) / sizeof(u8)));
+		                  (unsigned int)(sizeof(u64) / sizeof(u8)));
 	else {
 		cc->iv_size = 0;
-		if (cc->iv_generator) {
+		if (cc->iv_gen_ops) {
 			DMWARN(PFX "Selected cipher does not support IVs");
-			cc->iv_generator = NULL;
+			if (cc->iv_gen_ops->dtr)
+				cc->iv_gen_ops->dtr(cc);
+			cc->iv_gen_ops = NULL;
 		}
 	}
 
@@ -479,52 +646,59 @@
 				     mempool_free_slab, _crypt_io_pool);
 	if (!cc->io_pool) {
 		ti->error = PFX "Cannot allocate crypt io mempool";
-		goto bad2;
+		goto bad3;
 	}
 
 	cc->page_pool = mempool_create(MIN_POOL_PAGES, mempool_alloc_page,
 				       mempool_free_page, NULL);
 	if (!cc->page_pool) {
 		ti->error = PFX "Cannot allocate page mempool";
-		goto bad3;
-	}
-
-	cc->tfm = tfm;
-	cc->key_size = key_size;
-	if ((key_size == 0 && strcmp(argv[1], "-") != 0)
-	    || crypt_decode_key(cc->key, argv[1], key_size) < 0) {
-		ti->error = PFX "Error decoding key";
 		goto bad4;
 	}
 
 	if (tfm->crt_cipher.cit_setkey(tfm, cc->key, key_size) < 0) {
 		ti->error = PFX "Error setting key";
-		goto bad4;
+		goto bad5;
 	}
 
 	if (sscanf(argv[2], SECTOR_FORMAT, &cc->iv_offset) != 1) {
 		ti->error = PFX "Invalid iv_offset sector";
-		goto bad4;
+		goto bad5;
 	}
 
 	if (sscanf(argv[4], SECTOR_FORMAT, &cc->start) != 1) {
 		ti->error = PFX "Invalid device sector";
-		goto bad4;
+		goto bad5;
 	}
 
 	if (dm_get_device(ti, argv[3], cc->start, ti->len,
 	                  dm_table_get_mode(ti->table), &cc->dev)) {
 		ti->error = PFX "Device lookup failed";
-		goto bad4;
+		goto bad5;
 	}
 
+	if (ivmode && cc->iv_gen_ops) {
+		if (ivopts)
+			*(ivopts - 1) = ':';
+		cc->iv_mode = kmalloc(strlen(ivmode) + 1, GFP_KERNEL);
+		if (!cc->iv_mode) {
+			ti->error = PFX "Error kmallocing iv_mode string";
+			goto bad5;
+		}
+		strcpy(cc->iv_mode, ivmode);
+	} else
+		cc->iv_mode = NULL;
+
 	ti->private = cc;
 	return 0;
 
-bad4:
+bad5:
 	mempool_destroy(cc->page_pool);
-bad3:
+bad4:
 	mempool_destroy(cc->io_pool);
+bad3:
+	if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
+		cc->iv_gen_ops->dtr(cc);
 bad2:
 	crypto_free_tfm(tfm);
 bad1:
@@ -539,6 +713,10 @@
 	mempool_destroy(cc->page_pool);
 	mempool_destroy(cc->io_pool);
 
+	if (cc->iv_mode)
+		kfree(cc->iv_mode);
+	if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
+		cc->iv_gen_ops->dtr(cc);
 	crypto_free_tfm(cc->tfm);
 	dm_put_device(ti, cc->dev);
 	kfree(cc);
@@ -577,7 +755,8 @@
 
 static inline struct bio *
 crypt_clone(struct crypt_config *cc, struct crypt_io *io, struct bio *bio,
-            sector_t sector, int *bvec_idx, struct convert_context *ctx)
+            sector_t sector, unsigned int *bvec_idx,
+            struct convert_context *ctx)
 {
 	struct bio *clone;
 
@@ -630,7 +809,7 @@
 	struct bio *clone;
 	unsigned int remaining = bio->bi_size;
 	sector_t sector = bio->bi_sector - ti->begin;
-	int bvec_idx = 0;
+	unsigned int bvec_idx = 0;
 
 	io->target = ti;
 	io->bio = bio;
@@ -692,8 +871,8 @@
 	struct crypt_config *cc = (struct crypt_config *) ti->private;
 	char buffer[32];
 	const char *cipher;
-	const char *mode = NULL;
-	int offset;
+	const char *chainmode = NULL;
+	unsigned int sz = 0;
 
 	switch (type) {
 	case STATUSTYPE_INFO:
@@ -705,34 +884,35 @@
 
 		switch(cc->tfm->crt_cipher.cit_mode) {
 		case CRYPTO_TFM_MODE_CBC:
-			mode = "plain";
+			chainmode = "cbc";
 			break;
 		case CRYPTO_TFM_MODE_ECB:
-			mode = "ecb";
+			chainmode = "ecb";
 			break;
 		default:
 			BUG();
 		}
 
-		snprintf(result, maxlen, "%s-%s ", cipher, mode);
-		offset = strlen(result);
+		if (cc->iv_mode)
+			DMEMIT("%s-%s-%s ", cipher, chainmode, cc->iv_mode);
+		else
+			DMEMIT("%s-%s ", cipher, chainmode);
 
 		if (cc->key_size > 0) {
-			if ((maxlen - offset) < ((cc->key_size << 1) + 1))
+			if ((maxlen - sz) < ((cc->key_size << 1) + 1))
 				return -ENOMEM;
 
-			crypt_encode_key(result + offset, cc->key, cc->key_size);
-			offset += cc->key_size << 1;
+			crypt_encode_key(result + sz, cc->key, cc->key_size);
+			sz += cc->key_size << 1;
 		} else {
-			if (offset >= maxlen)
+			if (sz >= maxlen)
 				return -ENOMEM;
-			result[offset++] = '-';
+			result[sz++] = '-';
 		}
 
 		format_dev_t(buffer, cc->dev->bdev->bd_dev);
-		snprintf(result + offset, maxlen - offset, " " SECTOR_FORMAT
-		         " %s " SECTOR_FORMAT, cc->iv_offset,
-		         buffer, cc->start);
+		DMEMIT(" " SECTOR_FORMAT " %s " SECTOR_FORMAT,
+		       cc->iv_offset, buffer, cc->start);
 		break;
 	}
 	return 0;
@@ -740,7 +920,7 @@
 
 static struct target_type crypt_target = {
 	.name   = "crypt",
-	.version= {1, 0, 0},
+	.version= {1, 1, 0},
 	.module = THIS_MODULE,
 	.ctr    = crypt_ctr,
 	.dtr    = crypt_dtr,
diff -Nru a/drivers/md/dm-io.c b/drivers/md/dm-io.c
--- a/drivers/md/dm-io.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/md/dm-io.c	2004-12-24 13:37:30 -08:00
@@ -267,7 +267,7 @@
 		/* create new pool */
 		_io_pool = mempool_create(new_ios, alloc_io, free_io, NULL);
 		if (!_io_pool)
-			r = -ENOMEM;
+			return -ENOMEM;
 
 		r = bio_set_init(&_bios, "dm-io", 512, 1);
 		if (r) {
diff -Nru a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
--- a/drivers/md/dm-ioctl.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/md/dm-ioctl.c	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the GPL.
  */
@@ -17,7 +18,7 @@
 
 #include <asm/uaccess.h>
 
-#define DM_DRIVER_EMAIL "dm@uk.sistina.com"
+#define DM_DRIVER_EMAIL "dm-devel@redhat.com"
 
 /*-----------------------------------------------------------------
  * The ioctl interface needs to be able to look up devices by
@@ -224,6 +225,7 @@
 	}
 	register_with_devfs(cell);
 	dm_get(md);
+	dm_set_mdptr(md, cell);
 	up_write(&_hash_lock);
 
 	return 0;
@@ -240,6 +242,7 @@
 	list_del(&hc->uuid_list);
 	list_del(&hc->name_list);
 	unregister_with_devfs(hc);
+	dm_set_mdptr(hc->md, NULL);
 	dm_put(hc->md);
 	if (hc->new_map)
 		dm_table_put(hc->new_map);
@@ -579,12 +582,16 @@
 }
 
 /*
- * Always use UUID for lookups if it's present, otherwise use name.
+ * Always use UUID for lookups if it's present, otherwise use name or dev.
  */
 static inline struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
 {
-	return *param->uuid ?
-	    __get_uuid_cell(param->uuid) : __get_name_cell(param->name);
+	if (*param->uuid)
+		return __get_uuid_cell(param->uuid);
+	else if (*param->name)
+		return __get_name_cell(param->name);
+	else
+		return dm_get_mdptr(huge_decode_dev(param->dev));
 }
 
 static inline struct mapped_device *find_device(struct dm_ioctl *param)
@@ -596,6 +603,7 @@
 	hc = __find_device_hash_cell(param);
 	if (hc) {
 		md = hc->md;
+		dm_get(md);
 
 		/*
 		 * Sneakily write in both the name and the uuid
@@ -611,8 +619,6 @@
 			param->flags |= DM_INACTIVE_PRESENT_FLAG;
 		else
 			param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
-
-		dm_get(md);
 	}
 	up_read(&_hash_lock);
 
@@ -1097,6 +1103,67 @@
 	return r;
 }
 
+/*
+ * Pass a message to the target that's at the supplied device offset.
+ */
+static int target_message(struct dm_ioctl *param, size_t param_size)
+{
+	int r, argc;
+	char **argv;
+	struct mapped_device *md;
+	struct dm_table *table;
+	struct dm_target *ti;
+	struct dm_target_msg *tmsg = (void *) param + param->data_start;
+
+	md = find_device(param);
+	if (!md)
+		return -ENXIO;
+
+	r = __dev_status(md, param);
+	if (r)
+		goto out;
+
+	if (tmsg < (struct dm_target_msg *) (param + 1) ||
+	    invalid_str(tmsg->message, (void *) param + param_size)) {
+		DMWARN("Invalid target message parameters.");
+		r = -EINVAL;
+		goto out;
+	}
+
+	r = dm_split_args(&argc, &argv, tmsg->message);
+	if (r) {
+		DMWARN("Failed to split target message parameters");
+		goto out;
+	}
+
+	table = dm_get_table(md);
+	if (!table)
+		goto out_argv;
+
+	if (tmsg->sector >= dm_table_get_size(table)) {
+		DMWARN("Target message sector outside device.");
+		r = -EINVAL;
+		goto out_table;
+	}
+
+	ti = dm_table_find_target(table, tmsg->sector);
+	if (ti->type->message)
+		r = ti->type->message(ti, argc, argv);
+	else {
+		DMWARN("Target type does not support messages");
+		r = -EINVAL;
+	}
+
+ out_table:
+	dm_table_put(table);
+ out_argv:
+	kfree(argv);
+ out:
+	param->data_size = 0;
+	dm_put(md);
+	return r;
+}
+
 /*-----------------------------------------------------------------
  * Implementation of open/close/ioctl on the special char
  * device.
@@ -1123,7 +1190,9 @@
 		{DM_TABLE_DEPS_CMD, table_deps},
 		{DM_TABLE_STATUS_CMD, table_status},
 
-		{DM_LIST_VERSIONS_CMD, list_versions}
+		{DM_LIST_VERSIONS_CMD, list_versions},
+
+		{DM_TARGET_MSG_CMD, target_message}
 	};
 
 	return (cmd >= ARRAY_SIZE(_ioctls)) ? NULL : _ioctls[cmd].fn;
@@ -1202,14 +1271,14 @@
 	    cmd == DM_LIST_VERSIONS_CMD)
 		return 0;
 
-	/* Unless creating, either name or uuid but not both */
-	if (cmd != DM_DEV_CREATE_CMD) {
-		if ((!*param->uuid && !*param->name) ||
-		    (*param->uuid && *param->name)) {
-			DMWARN("one of name or uuid must be supplied, cmd(%u)",
-			       cmd);
+	if ((cmd == DM_DEV_CREATE_CMD)) {
+		if (!*param->name) {
+			DMWARN("name not supplied when creating device");
 			return -EINVAL;
 		}
+	} else if ((*param->uuid && *param->name)) {
+		DMWARN("only supply one of name or uuid, cmd(%u)", cmd);
+		return -EINVAL;
 	}
 
 	/* Ensure strings are terminated */
diff -Nru a/drivers/md/dm-table.c b/drivers/md/dm-table.c
--- a/drivers/md/dm-table.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/md/dm-table.c	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001 Sistina Software (UK) Limited.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the GPL.
  */
@@ -575,7 +576,7 @@
 /*
  * Destructively splits up the argument list to pass to ctr.
  */
-static int split_args(int *argc, char ***argvp, char *input)
+int dm_split_args(int *argc, char ***argvp, char *input)
 {
 	char *start, *end = input, *out, **argv = NULL;
 	unsigned array_size = 0;
@@ -663,14 +664,14 @@
 
 	if (!len) {
 		tgt->error = "zero-length target";
-		DMERR(": %s\n", tgt->error);
+		DMERR("%s", tgt->error);
 		return -EINVAL;
 	}
 
 	tgt->type = dm_get_target_type(type);
 	if (!tgt->type) {
 		tgt->error = "unknown target type";
-		DMERR(": %s\n", tgt->error);
+		DMERR("%s", tgt->error);
 		return -EINVAL;
 	}
 
@@ -688,7 +689,7 @@
 		goto bad;
 	}
 
-	r = split_args(&argc, &argv, params);
+	r = dm_split_args(&argc, &argv, params);
 	if (r) {
 		tgt->error = "couldn't split parameters (insufficient memory)";
 		goto bad;
@@ -707,7 +708,7 @@
 	return 0;
 
  bad:
-	DMERR(": %s\n", tgt->error);
+	DMERR("%s", tgt->error);
 	dm_put_target_type(tgt->type);
 	return r;
 }
diff -Nru a/drivers/md/dm-target.c b/drivers/md/dm-target.c
--- a/drivers/md/dm-target.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/md/dm-target.c	2004-12-24 13:37:30 -08:00
@@ -120,10 +120,9 @@
 		return -ENOMEM;
 
 	down_write(&_lock);
-	if (__find_target_type(t->name)) {
-		kfree(ti);
+	if (__find_target_type(t->name))
 		rv = -EEXIST;
-	} else
+	else
 		list_add(&ti->list, &_targets);
 
 	up_write(&_lock);
diff -Nru a/drivers/md/dm.c b/drivers/md/dm.c
--- a/drivers/md/dm.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/md/dm.c	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the GPL.
  */
@@ -59,6 +60,8 @@
 	request_queue_t *queue;
 	struct gendisk *disk;
 
+	void *interface_ptr;
+
 	/*
 	 * A list of ios that arrived while we were suspended.
 	 */
@@ -138,23 +141,20 @@
 	DMINFO("cleaned up");
 }
 
-/*
- * We have a lot of init/exit functions, so it seems easier to
- * store them in an array.  The disposable macro 'xx'
- * expands a prefix into a pair of function names.
- */
-static struct {
-	int (*init) (void);
-	void (*exit) (void);
-
-} _inits[] = {
-#define xx(n) {n ## _init, n ## _exit},
-	xx(local)
-	xx(dm_target)
-	xx(dm_linear)
-	xx(dm_stripe)
-	xx(dm_interface)
-#undef xx
+int (*_inits[])(void) __initdata = {
+	local_init,
+	dm_target_init,
+	dm_linear_init,
+	dm_stripe_init,
+	dm_interface_init,
+};
+
+void (*_exits[])(void) = {
+	local_exit,
+	dm_target_exit,
+	dm_linear_exit,
+	dm_stripe_exit,
+	dm_interface_exit,
 };
 
 static int __init dm_init(void)
@@ -164,7 +164,7 @@
 	int r, i;
 
 	for (i = 0; i < count; i++) {
-		r = _inits[i].init();
+		r = _inits[i]();
 		if (r)
 			goto bad;
 	}
@@ -173,17 +173,17 @@
 
       bad:
 	while (i--)
-		_inits[i].exit();
+		_exits[i]();
 
 	return r;
 }
 
 static void __exit dm_exit(void)
 {
-	int i = ARRAY_SIZE(_inits);
+	int i = ARRAY_SIZE(_exits);
 
 	while (i--)
-		_inits[i].exit();
+		_exits[i]();
 }
 
 /*
@@ -643,7 +643,7 @@
 /*
  * See if the device with a specific minor # is free.
  */
-static int specific_minor(unsigned int minor)
+static int specific_minor(struct mapped_device *md, unsigned int minor)
 {
 	int r, m;
 
@@ -663,7 +663,7 @@
 		goto out;
 	}
 
-	r = idr_get_new_above(&_minor_idr, specific_minor, minor, &m);
+	r = idr_get_new_above(&_minor_idr, md, minor, &m);
 	if (r) {
 		goto out;
 	}
@@ -679,7 +679,7 @@
 	return r;
 }
 
-static int next_free_minor(unsigned int *minor)
+static int next_free_minor(struct mapped_device *md, unsigned int *minor)
 {
 	int r;
 	unsigned int m;
@@ -692,7 +692,7 @@
 		goto out;
 	}
 
-	r = idr_get_new(&_minor_idr, next_free_minor, &m);
+	r = idr_get_new(&_minor_idr, md, &m);
 	if (r) {
 		goto out;
 	}
@@ -726,7 +726,7 @@
 	}
 
 	/* get a minor number for the dev */
-	r = persistent ? specific_minor(minor) : next_free_minor(&minor);
+	r = persistent ? specific_minor(md, minor) : next_free_minor(md, &minor);
 	if (r < 0)
 		goto bad1;
 
@@ -805,7 +805,7 @@
 {
 	struct mapped_device *md = (struct mapped_device *) context;
 
-	atomic_inc(&md->event_nr);;
+	atomic_inc(&md->event_nr);
 	wake_up(&md->eventq);
 }
 
@@ -883,6 +883,32 @@
 	return create_aux(minor, 1, result);
 }
 
+void *dm_get_mdptr(dev_t dev)
+{
+	struct mapped_device *md;
+	void *mdptr = NULL;
+	unsigned minor = MINOR(dev);
+
+	if (MAJOR(dev) != _major || minor >= (1 << MINORBITS))
+		return NULL;
+
+	down(&_minor_lock);
+
+	md = idr_find(&_minor_idr, minor);
+
+	if (md && (dm_disk(md)->first_minor == minor))
+		mdptr = md->interface_ptr;
+
+	up(&_minor_lock);
+
+	return mdptr;
+}
+
+void dm_set_mdptr(struct mapped_device *md, void *ptr)
+{
+	md->interface_ptr = ptr;
+}
+
 void dm_get(struct mapped_device *md)
 {
 	atomic_inc(&md->holders);
@@ -1142,5 +1168,5 @@
 module_param(major, uint, 0);
 MODULE_PARM_DESC(major, "The major number of the device mapper");
 MODULE_DESCRIPTION(DM_NAME " driver");
-MODULE_AUTHOR("Joe Thornber <thornber@sistina.com>");
+MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/md/dm.h b/drivers/md/dm.h
--- a/drivers/md/dm.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/md/dm.h	2004-12-24 13:36:48 -08:00
@@ -2,6 +2,7 @@
  * Internal header file for device mapper
  *
  * Copyright (C) 2001, 2002 Sistina Software
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the LGPL.
  */
@@ -54,6 +55,8 @@
  *---------------------------------------------------------------*/
 int dm_create(struct mapped_device **md);
 int dm_create_with_minor(unsigned int minor, struct mapped_device **md);
+void dm_set_mdptr(struct mapped_device *md, void *ptr);
+void *dm_get_mdptr(dev_t dev);
 
 /*
  * Reference counting for md.
@@ -164,6 +167,8 @@
 {
 	return (n << 9);
 }
+
+int dm_split_args(int *argc, char ***argvp, char *input);
 
 /*
  * The device-mapper can be driven through one of two interfaces;
diff -Nru a/drivers/md/faulty.c b/drivers/md/faulty.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/md/faulty.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,343 @@
+/*
+ * faulty.c : Multiple Devices driver for Linux
+ *
+ * Copyright (C) 2004 Neil Brown
+ *
+ * fautly-device-simulator personality for md
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * (for example /usr/src/linux/COPYING); if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+/*
+ * The "faulty" personality causes some requests to fail.
+ *
+ * Possible failure modes are:
+ *   reads fail "randomly" but succeed on retry
+ *   writes fail "randomly" but succeed on retry
+ *   reads for some address fail and then persist until a write
+ *   reads for some address fail and then persist irrespective of write
+ *   writes for some address fail and persist
+ *   all writes fail
+ *
+ * Different modes can be active at a time, but only
+ * one can be set at array creation.  Others can be added later.
+ * A mode can be one-shot or recurrent with the recurrance being
+ * once in every N requests.
+ * The bottom 5 bits of the "layout" indicate the mode.  The
+ * remainder indicate a period, or 0 for one-shot.
+ *
+ * There is an implementation limit on the number of concurrently
+ * persisting-faulty blocks. When a new fault is requested that would
+ * exceed the limit, it is ignored.
+ * All current faults can be clear using a layout of "0".
+ *
+ * Requests are always sent to the device.  If they are to fail,
+ * we clone the bio and insert a new b_end_io into the chain.
+ */
+
+#define	WriteTransient	0
+#define	ReadTransient	1
+#define	WritePersistent	2
+#define	ReadPersistent	3
+#define	WriteAll	4 /* doesn't go to device */
+#define	ReadFixable	5
+#define	Modes	6
+
+#define	ClearErrors	31
+#define	ClearFaults	30
+
+#define AllPersist	100 /* internal use only */
+#define	NoPersist	101
+
+#define	ModeMask	0x1f
+#define	ModeShift	5
+
+#define MaxFault	50
+#include <linux/raid/md.h>
+
+
+static int faulty_fail(struct bio *bio, unsigned int bytes_done, int error)
+{
+	struct bio *b = bio->bi_private;
+
+	b->bi_size = bio->bi_size;
+	b->bi_sector = bio->bi_sector;
+
+	if (bio->bi_size == 0)
+		bio_put(bio);
+
+	clear_bit(BIO_UPTODATE, &b->bi_flags);
+	return (b->bi_end_io)(b, bytes_done, -EIO);
+}
+
+typedef struct faulty_conf {
+	int period[Modes];
+	atomic_t counters[Modes];
+	sector_t faults[MaxFault];
+	int	modes[MaxFault];
+	int nfaults;
+	mdk_rdev_t *rdev;
+} conf_t;
+
+static int check_mode(conf_t *conf, int mode)
+{
+	if (conf->period[mode] == 0 &&
+	    atomic_read(&conf->counters[mode]) <= 0)
+		return 0; /* no failure, no decrement */
+
+
+	if (atomic_dec_and_test(&conf->counters[mode])) {
+		if (conf->period[mode])
+			atomic_set(&conf->counters[mode], conf->period[mode]);
+		return 1;
+	}
+	return 0;
+}
+
+static int check_sector(conf_t *conf, sector_t start, sector_t end, int dir)
+{
+	/* If we find a ReadFixable sector, we fix it ... */
+	int i;
+	for (i=0; i<conf->nfaults; i++)
+		if (conf->faults[i] >= start &&
+		    conf->faults[i] < end) {
+			/* found it ... */
+			switch (conf->modes[i] * 2 + dir) {
+			case WritePersistent*2+WRITE: return 1;
+			case ReadPersistent*2+READ: return 1;
+			case ReadFixable*2+READ: return 1;
+			case ReadFixable*2+WRITE:
+				conf->modes[i] = NoPersist;
+				return 0;
+			case AllPersist*2+READ:
+			case AllPersist*2+WRITE: return 1;
+			default:
+				return 0;
+			}
+		}
+	return 0;
+}
+
+static void add_sector(conf_t *conf, sector_t start, int mode)
+{
+	int i;
+	int n = conf->nfaults;
+	for (i=0; i<conf->nfaults; i++)
+		if (conf->faults[i] == start) {
+			switch(mode) {
+			case NoPersist: conf->modes[i] = mode; return;
+			case WritePersistent:
+				if (conf->modes[i] == ReadPersistent ||
+				    conf->modes[i] == ReadFixable)
+					conf->modes[i] = AllPersist;
+				else
+					conf->modes[i] = WritePersistent;
+				return;
+			case ReadPersistent:
+				if (conf->modes[i] == WritePersistent)
+					conf->modes[i] = AllPersist;
+				else
+					conf->modes[i] = ReadPersistent;
+				return;
+			case ReadFixable:
+				if (conf->modes[i] == WritePersistent ||
+				    conf->modes[i] == ReadPersistent)
+					conf->modes[i] = AllPersist;
+				else
+					conf->modes[i] = ReadFixable;
+				return;
+			}
+		} else if (conf->modes[i] == NoPersist)
+			n = i;
+
+	if (n >= MaxFault)
+		return;
+	conf->faults[n] = start;
+	conf->modes[n] = mode;
+	if (conf->nfaults == n)
+		conf->nfaults = n+1;
+}
+
+static int make_request(request_queue_t *q, struct bio *bio)
+{
+	mddev_t *mddev = q->queuedata;
+	conf_t *conf = (conf_t*)mddev->private;
+	int failit = 0;
+
+	if (bio->bi_rw & 1) {
+		/* write request */
+		if (atomic_read(&conf->counters[WriteAll])) {
+			/* special case - don't decrement, don't generic_make_request,
+			 * just fail immediately
+			 */
+			bio_endio(bio, bio->bi_size, -EIO);
+			return 0;
+		}
+
+		if (check_sector(conf, bio->bi_sector, bio->bi_sector+(bio->bi_size>>9),
+				 WRITE))
+			failit = 1;
+		if (check_mode(conf, WritePersistent)) {
+			add_sector(conf, bio->bi_sector, WritePersistent);
+			failit = 1;
+		}
+		if (check_mode(conf, WriteTransient))
+			failit = 1;
+	} else {
+		/* read request */
+		if (check_sector(conf, bio->bi_sector, bio->bi_sector + (bio->bi_size>>9),
+				 READ))
+			failit = 1;
+		if (check_mode(conf, ReadTransient))
+			failit = 1;
+		if (check_mode(conf, ReadPersistent)) {
+			add_sector(conf, bio->bi_sector, ReadPersistent);
+			failit = 1;
+		}
+		if (check_mode(conf, ReadFixable)) {
+			add_sector(conf, bio->bi_sector, ReadFixable);
+			failit = 1;
+		}
+	}
+	if (failit) {
+		struct bio *b = bio_clone(bio, GFP_NOIO);
+		b->bi_bdev = conf->rdev->bdev;
+		b->bi_private = bio;
+		b->bi_end_io = faulty_fail;
+		generic_make_request(b);
+		return 0;
+	} else {
+		bio->bi_bdev = conf->rdev->bdev;
+		return 1;
+	}
+}
+
+static void status(struct seq_file *seq, mddev_t *mddev)
+{
+	conf_t *conf = (conf_t*)mddev->private;
+	int n;
+
+	if ((n=atomic_read(&conf->counters[WriteTransient])) != 0)
+		seq_printf(seq, " WriteTransient=%d(%d)",
+			   n, conf->period[WriteTransient]);
+
+	if ((n=atomic_read(&conf->counters[ReadTransient])) != 0)
+		seq_printf(seq, " ReadTransient=%d(%d)",
+			   n, conf->period[ReadTransient]);
+
+	if ((n=atomic_read(&conf->counters[WritePersistent])) != 0)
+		seq_printf(seq, " WritePersistent=%d(%d)",
+			   n, conf->period[WritePersistent]);
+
+	if ((n=atomic_read(&conf->counters[ReadPersistent])) != 0)
+		seq_printf(seq, " ReadPersistent=%d(%d)",
+			   n, conf->period[ReadPersistent]);
+
+
+	if ((n=atomic_read(&conf->counters[ReadFixable])) != 0)
+		seq_printf(seq, " ReadFixable=%d(%d)",
+			   n, conf->period[ReadFixable]);
+
+	if ((n=atomic_read(&conf->counters[WriteAll])) != 0)
+		seq_printf(seq, " WriteAll");
+
+	seq_printf(seq, " nfaults=%d", conf->nfaults);
+}
+
+
+static int reconfig(mddev_t *mddev, int layout, int chunk_size)
+{
+	int mode = layout & ModeMask;
+	int count = layout >> ModeShift;
+	conf_t *conf = mddev->private;
+
+	if (chunk_size != -1)
+		return -EINVAL;
+
+	/* new layout */
+	if (mode == ClearFaults)
+		conf->nfaults = 0;
+	else if (mode == ClearErrors) {
+		int i;
+		for (i=0 ; i < Modes ; i++) {
+			conf->period[i] = 0;
+			atomic_set(&conf->counters[i], 0);
+		}
+	} else if (mode < Modes) {
+		conf->period[mode] = count;
+		if (!count) count++;
+		atomic_set(&conf->counters[mode], count);
+	} else
+		return -EINVAL;
+	mddev->layout = -1; /* makes sure further changes come through */
+	return 0;
+}
+
+static int run(mddev_t *mddev)
+{
+	mdk_rdev_t *rdev;
+	struct list_head *tmp;
+	int i;
+
+	conf_t *conf = kmalloc(sizeof(*conf), GFP_KERNEL);
+
+	for (i=0; i<Modes; i++) {
+		atomic_set(&conf->counters[i], 0);
+		conf->period[i] = 0;
+	}
+	conf->nfaults = 0;
+
+	ITERATE_RDEV(mddev, rdev, tmp)
+		conf->rdev = rdev;
+
+	mddev->array_size = mddev->size;
+	mddev->private = conf;
+
+	reconfig(mddev, mddev->layout, -1);
+
+	return 0;
+}
+
+static int stop(mddev_t *mddev)
+{
+	conf_t *conf = (conf_t *)mddev->private;
+
+	kfree(conf);
+	mddev->private = NULL;
+	return 0;
+}
+
+static mdk_personality_t faulty_personality =
+{
+	.name		= "faulty",
+	.owner		= THIS_MODULE,
+	.make_request	= make_request,
+	.run		= run,
+	.stop		= stop,
+	.status		= status,
+	.reconfig	= reconfig,
+};
+
+static int __init raid_init(void)
+{
+	return register_md_personality(FAULTY, &faulty_personality);
+}
+
+static void raid_exit(void)
+{
+	unregister_md_personality(FAULTY);
+}
+
+module_init(raid_init);
+module_exit(raid_exit);
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("md-personality-10"); /* faulty */
diff -Nru a/drivers/md/linear.c b/drivers/md/linear.c
--- a/drivers/md/linear.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/md/linear.c	2004-12-24 13:36:48 -08:00
@@ -99,17 +99,14 @@
 	linear_conf_t *conf = mddev_to_conf(mddev);
 	int i, ret = 0;
 
-	for (i=0; i < mddev->raid_disks; i++) {
+	for (i=0; i < mddev->raid_disks && ret == 0; i++) {
 		struct block_device *bdev = conf->disks[i].rdev->bdev;
 		request_queue_t *r_queue = bdev_get_queue(bdev);
 
-		if (!r_queue->issue_flush_fn) {
+		if (!r_queue->issue_flush_fn)
 			ret = -EOPNOTSUPP;
-			break;
-		}
-		ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
-		if (ret)
-			break;
+		else
+			ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
 	}
 	return ret;
 }
@@ -119,8 +116,9 @@
 	linear_conf_t *conf;
 	struct linear_hash *table;
 	mdk_rdev_t *rdev;
-	int size, i, nb_zone, cnt;
-	unsigned int curr_offset;
+	int i, nb_zone, cnt;
+	sector_t start;
+	sector_t curr_offset;
 	struct list_head *tmp;
 
 	conf = kmalloc (sizeof (*conf) + mddev->raid_disks*sizeof(dev_info_t),
@@ -195,23 +193,24 @@
 	 * Here we generate the linear hash table
 	 */
 	table = conf->hash_table;
-	size = 0;
+	start = 0;
 	curr_offset = 0;
 	for (i = 0; i < cnt; i++) {
 		dev_info_t *disk = conf->disks + i;
 
+		if (start > curr_offset)
+			table[-1].dev1 = disk;
+
 		disk->offset = curr_offset;
 		curr_offset += disk->size;
 
-		if (size < 0) {
-			table[-1].dev1 = disk;
-		}
-		size += disk->size;
-
-		while (size>0) {
+		/* 'curr_offset' is the end of this disk
+		 * 'start' is the start of table
+		 */
+		while (start < curr_offset) {
 			table->dev0 = disk;
 			table->dev1 = NULL;
-			size -= conf->smallest->size;
+			start += conf->smallest->size;
 			table++;
 		}
 	}
@@ -233,6 +232,7 @@
 {
 	linear_conf_t *conf = mddev_to_conf(mddev);
   
+	blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
 	kfree(conf->hash_table);
 	kfree(conf);
 
@@ -268,10 +268,11 @@
 		char b[BDEVNAME_SIZE];
 
 		printk("linear_make_request: Block %llu out of bounds on "
-			"dev %s size %ld offset %ld\n",
+			"dev %s size %llu offset %llu\n",
 			(unsigned long long)block,
 			bdevname(tmp_dev->rdev->bdev, b),
-			tmp_dev->size, tmp_dev->offset);
+			(unsigned long long)tmp_dev->size,
+		        (unsigned long long)tmp_dev->offset);
 		bio_io_error(bio, bio->bi_size);
 		return 0;
 	}
diff -Nru a/drivers/md/md.c b/drivers/md/md.c
--- a/drivers/md/md.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/md/md.c	2004-12-24 13:36:31 -08:00
@@ -154,38 +154,6 @@
 		tmp = tmp->next;})					\
 		)
 
-int md_flush_mddev(mddev_t *mddev, sector_t *error_sector)
-{
-	struct list_head *tmp;
-	mdk_rdev_t *rdev;
-	int ret = 0;
-
-	/*
-	 * this list iteration is done without any locking in md?!
-	 */
-	ITERATE_RDEV(mddev, rdev, tmp) {
-		request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
-		int err;
-
-		if (!r_queue->issue_flush_fn)
-			err = -EOPNOTSUPP;
-		else
-			err = r_queue->issue_flush_fn(r_queue, rdev->bdev->bd_disk, error_sector);
-
-		if (!ret)
-			ret = err;
-	}
-
-	return ret;
-}
-
-static int md_flush_all(request_queue_t *q, struct gendisk *disk,
-			 sector_t *error_sector)
-{
-	mddev_t *mddev = q->queuedata;
-
-	return md_flush_mddev(mddev, error_sector);
-}
 
 static int md_fail_request (request_queue_t *q, struct bio *bio)
 {
@@ -472,30 +440,6 @@
 	return csum;
 }
 
-/* csum_partial is not consistent between different architectures.
- * Some (i386) do a 32bit csum.  Some (alpha) do 16 bit.
- * This makes it hard for user-space to know what to do.
- * So we use calc_sb_csum to set the checksum to allow working
- * with older kernels, but allow calc_sb_csum_common to
- * be used when checking if a checksum is correct, to
- * make life easier for user-space tools that might write
- * a superblock.
- */
-static unsigned int calc_sb_csum_common(mdp_super_t *super)
-{
-	unsigned int  disk_csum = super->sb_csum;
-	unsigned long long newcsum = 0;
-	unsigned int csum;
-	int i;
-	unsigned int *superc = (int*) super;
-	super->sb_csum = 0;
-
-	for (i=0; i<MD_SB_BYTES/4; i++)
-		newcsum+= superc[i];
-	csum = (newcsum& 0xffffffff) + (newcsum>>32);
-	super->sb_csum = disk_csum;
-	return csum;
-}
 
 /*
  * Handle superblock details.
@@ -579,8 +523,7 @@
 	if (sb->raid_disks <= 0)
 		goto abort;
 
-	if (calc_sb_csum(sb) != sb->sb_csum &&
-		calc_sb_csum_common(sb) != sb->sb_csum) {
+	if (csum_fold(calc_sb_csum(sb)) != csum_fold(sb->sb_csum)) {
 		printk(KERN_WARNING "md: invalid superblock checksum on %s\n",
 			b);
 		goto abort;
@@ -805,7 +748,7 @@
 {
 	unsigned int disk_csum, csum;
 	unsigned long long newcsum;
-	int size = 256 + sb->max_dev*2;
+	int size = 256 + le32_to_cpu(sb->max_dev)*2;
 	unsigned int *isuper = (unsigned int*)sb;
 	int i;
 
@@ -820,7 +763,7 @@
 
 	csum = (newcsum & 0xffffffff) + (newcsum >> 32);
 	sb->sb_csum = disk_csum;
-	return csum;
+	return cpu_to_le32(csum);
 }
 
 static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
@@ -842,7 +785,7 @@
 	case 0:
 		sb_offset = rdev->bdev->bd_inode->i_size >> 9;
 		sb_offset -= 8*2;
-		sb_offset &= ~(4*2);
+		sb_offset &= ~(4*2-1);
 		/* convert from sectors to K */
 		sb_offset /= 2;
 		break;
@@ -875,6 +818,11 @@
 			bdevname(rdev->bdev,b));
 		return -EINVAL;
 	}
+	if (le64_to_cpu(sb->data_size) < 10) {
+		printk("md: data_size too small on %s\n",
+		       bdevname(rdev->bdev,b));
+		return -EINVAL;
+	}
 	rdev->preferred_minor = 0xffff;
 	rdev->data_offset = le64_to_cpu(sb->data_offset);
 
@@ -919,7 +867,6 @@
 
 	if (mddev->raid_disks == 0) {
 		mddev->major_version = 1;
-		mddev->minor_version = 0;
 		mddev->patch_version = 0;
 		mddev->persistent = 1;
 		mddev->chunk_size = le32_to_cpu(sb->chunksize) << 9;
@@ -928,7 +875,7 @@
 		mddev->level = le32_to_cpu(sb->level);
 		mddev->layout = le32_to_cpu(sb->layout);
 		mddev->raid_disks = le32_to_cpu(sb->raid_disks);
-		mddev->size = (u32)le64_to_cpu(sb->size);
+		mddev->size = le64_to_cpu(sb->size)/2;
 		mddev->events = le64_to_cpu(sb->events);
 		
 		mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
@@ -996,7 +943,7 @@
 		if (rdev2->desc_nr > max_dev)
 			max_dev = rdev2->desc_nr;
 	
-	sb->max_dev = max_dev;
+	sb->max_dev = cpu_to_le32(max_dev);
 	for (i=0; i<max_dev;i++)
 		sb->dev_roles[max_dev] = cpu_to_le16(0xfffe);
 	
@@ -1491,17 +1438,6 @@
 	}
 
 
-	/*
-	 * Check if we can support this RAID array
-	 */
-	if (mddev->major_version != MD_MAJOR_VERSION ||
-			mddev->minor_version > MD_MINOR_VERSION) {
-		printk(KERN_ALERT 
-			"md: %s: unsupported raid array version %d.%d.%d\n",
-			mdname(mddev), mddev->major_version,
-			mddev->minor_version, mddev->patch_version);
-		goto abort;
-	}
 
 	if ((mddev->recovery_cp != MaxSector) &&
 	    ((mddev->level == 1) ||
@@ -1511,8 +1447,6 @@
 		       mdname(mddev));
 
 	return 0;
-abort:
-	return 1;
 }
 
 int mdp_major = 0;
@@ -1714,7 +1648,6 @@
 	 */
 	mddev->queue->queuedata = mddev;
 	mddev->queue->make_request_fn = mddev->pers->make_request;
-	mddev->queue->issue_flush_fn = md_flush_all;
 
 	mddev->changed = 1;
 	return 0;
@@ -1846,7 +1779,7 @@
 
 	err = do_md_run (mddev);
 	if (err) {
-		printk(KERN_WARNING "md :do_md_run() returned %d\n", err);
+		printk(KERN_WARNING "md: do_md_run() returned %d\n", err);
 		do_md_stop (mddev, 0);
 	}
 }
@@ -2036,7 +1969,7 @@
 
 	info.major_version = mddev->major_version;
 	info.minor_version = mddev->minor_version;
-	info.patch_version = 1;
+	info.patch_version = MD_PATCHLEVEL_VERSION;
 	info.ctime         = mddev->ctime;
 	info.level         = mddev->level;
 	info.size          = mddev->size;
@@ -2418,16 +2351,27 @@
 /*	    mddev->patch_version != info->patch_version || */
 	    mddev->ctime         != info->ctime         ||
 	    mddev->level         != info->level         ||
-	    mddev->layout        != info->layout        ||
+/*	    mddev->layout        != info->layout        || */
 	    !mddev->persistent	 != info->not_persistent||
 	    mddev->chunk_size    != info->chunk_size    )
 		return -EINVAL;
 	/* Check there is only one change */
 	if (mddev->size != info->size) cnt++;
 	if (mddev->raid_disks != info->raid_disks) cnt++;
+	if (mddev->layout != info->layout) cnt++;
 	if (cnt == 0) return 0;
 	if (cnt > 1) return -EINVAL;
 
+	if (mddev->layout != info->layout) {
+		/* Change layout
+		 * we don't need to do anything at the md level, the
+		 * personality will take care of it all.
+		 */
+		if (mddev->pers->reconfig == NULL)
+			return -EINVAL;
+		else
+			return mddev->pers->reconfig(mddev, info->layout, -1);
+	}
 	if (mddev->size != info->size) {
 		mdk_rdev_t * rdev;
 		struct list_head *tmp;
@@ -2436,7 +2380,7 @@
 		/* The "size" is the amount of each device that is used.
 		 * This can only make sense for arrays with redundancy.
 		 * linear and raid0 always use whatever space is available
-		 * We can only consider changing the size of no resync
+		 * We can only consider changing the size if no resync
 		 * or reconstruction is happening, and if the new size
 		 * is acceptable. It must fit before the sb_offset or,
 		 * if that is <data_offset, it must fit before the
@@ -3331,33 +3275,54 @@
 	 * 1 == like 2, but have yielded to allow conflicting resync to
 	 *		commense
 	 * other == active in resync - this many blocks
+	 *
+	 * Before starting a resync we must have set curr_resync to
+	 * 2, and then checked that every "conflicting" array has curr_resync
+	 * less than ours.  When we find one that is the same or higher
+	 * we wait on resync_wait.  To avoid deadlock, we reduce curr_resync
+	 * to 1 if we choose to yield (based arbitrarily on address of mddev structure).
+	 * This will mean we have to start checking from the beginning again.
+	 *
 	 */
+
 	do {
 		mddev->curr_resync = 2;
 
+	try_again:
+		if (signal_pending(current)) {
+			flush_signals(current);
+			goto skip;
+		}
 		ITERATE_MDDEV(mddev2,tmp) {
+			printk(".");
 			if (mddev2 == mddev)
 				continue;
 			if (mddev2->curr_resync && 
 			    match_mddev_units(mddev,mddev2)) {
-				printk(KERN_INFO "md: delaying resync of %s"
-					" until %s has finished resync (they"
-				       	" share one or more physical units)\n",
-				       mdname(mddev), mdname(mddev2));
-				if (mddev < mddev2) {/* arbitrarily yield */
+				DEFINE_WAIT(wq);
+				if (mddev < mddev2 && mddev->curr_resync == 2) {
+					/* arbitrarily yield */
 					mddev->curr_resync = 1;
 					wake_up(&resync_wait);
 				}
-				if (wait_event_interruptible(resync_wait,
-							     mddev2->curr_resync < mddev->curr_resync)) {
-					flush_signals(current);
+				if (mddev > mddev2 && mddev->curr_resync == 1)
+					/* no need to wait here, we can wait the next
+					 * time 'round when curr_resync == 2
+					 */
+					continue;
+				prepare_to_wait(&resync_wait, &wq, TASK_INTERRUPTIBLE);
+				if (!signal_pending(current)
+				    && mddev2->curr_resync >= mddev->curr_resync) {
+					printk(KERN_INFO "md: delaying resync of %s"
+					       " until %s has finished resync (they"
+					       " share one or more physical units)\n",
+					       mdname(mddev), mdname(mddev2));
 					mddev_put(mddev2);
-					goto skip;
+					schedule();
+					finish_wait(&resync_wait, &wq);
+					goto try_again;
 				}
-			}
-			if (mddev->curr_resync == 1) {
-				mddev_put(mddev2);
-				break;
+				finish_wait(&resync_wait, &wq);
 			}
 		}
 	} while (mddev->curr_resync < 2);
@@ -3395,7 +3360,7 @@
 	 * Tune reconstruction:
 	 */
 	window = 32*(PAGE_SIZE/512);
-	printk(KERN_INFO "md: using %dk window, over a total of %Lu blocks.\n",
+	printk(KERN_INFO "md: using %dk window, over a total of %llu blocks.\n",
 		window/2,(unsigned long long) max_sectors/2);
 
 	atomic_set(&mddev->recovery_active, 0);
@@ -3429,7 +3394,7 @@
 			break;
 
 	repeat:
-		if (jiffies >= mark[last_mark] + SYNC_MARK_STEP ) {
+		if (time_after_eq(jiffies, mark[last_mark] + SYNC_MARK_STEP )) {
 			/* step marks */
 			int next = (last_mark+1) % SYNC_MARKS;
 
@@ -3468,8 +3433,7 @@
 		if (currspeed > sysctl_speed_limit_min) {
 			if ((currspeed > sysctl_speed_limit_max) ||
 					!is_mddev_idle(mddev)) {
-				current->state = TASK_INTERRUPTIBLE;
-				schedule_timeout(HZ/4);
+				msleep_interruptible(250);
 				goto repeat;
 			}
 		}
@@ -3501,6 +3465,7 @@
 	md_enter_safemode(mddev);
  skip:
 	mddev->curr_resync = 0;
+	wake_up(&resync_wait);
 	set_bit(MD_RECOVERY_DONE, &mddev->recovery);
 	md_wakeup_thread(mddev->thread);
 }
@@ -3568,14 +3533,11 @@
 			mddev->recovery = 0;
 			/* flag recovery needed just to double check */
 			set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
-			wake_up(&resync_wait);
 			goto unlock;
 		}
-		if (mddev->recovery) {
+		if (mddev->recovery)
 			/* probably just the RECOVERY_NEEDED flag */
 			mddev->recovery = 0;
-			wake_up(&resync_wait);
-		}
 
 		/* no recovery is running.
 		 * remove any failed drives, then
diff -Nru a/drivers/md/multipath.c b/drivers/md/multipath.c
--- a/drivers/md/multipath.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/md/multipath.c	2004-12-24 13:36:48 -08:00
@@ -36,8 +36,6 @@
 
 
 static mdk_personality_t multipath_personality;
-static spinlock_t retry_list_lock = SPIN_LOCK_UNLOCKED;
-struct multipath_bh *multipath_retry_list = NULL, **multipath_retry_tail;
 
 
 static void *mp_pool_alloc(int gfp_flags, void *data)
@@ -63,16 +61,16 @@
 	 * now we use the first available disk.
 	 */
 
-	spin_lock_irq(&conf->device_lock);
+	rcu_read_lock();
 	for (i = 0; i < disks; i++) {
 		mdk_rdev_t *rdev = conf->multipaths[i].rdev;
 		if (rdev && rdev->in_sync) {
 			atomic_inc(&rdev->nr_pending);
-			spin_unlock_irq(&conf->device_lock);
+			rcu_read_unlock();
 			return i;
 		}
 	}
-	spin_unlock_irq(&conf->device_lock);
+	rcu_read_unlock();
 
 	printk(KERN_ERR "multipath_map(): no more operational IO paths?\n");
 	return (-1);
@@ -82,14 +80,11 @@
 {
 	unsigned long flags;
 	mddev_t *mddev = mp_bh->mddev;
+	multipath_conf_t *conf = mddev_to_conf(mddev);
 
-	spin_lock_irqsave(&retry_list_lock, flags);
-	if (multipath_retry_list == NULL)
-		multipath_retry_tail = &multipath_retry_list;
-	*multipath_retry_tail = mp_bh;
-	multipath_retry_tail = &mp_bh->next_mp;
-	mp_bh->next_mp = NULL;
-	spin_unlock_irqrestore(&retry_list_lock, flags);
+	spin_lock_irqsave(&conf->device_lock, flags);
+	list_add(&mp_bh->retry_list, &conf->retry_list);
+	spin_unlock_irqrestore(&conf->device_lock, flags);
 	md_wakeup_thread(mddev->thread);
 }
 
@@ -140,26 +135,26 @@
 {
 	multipath_conf_t *conf = mddev_to_conf(mddev);
 	int i;
-	unsigned long flags;
 
-	spin_lock_irqsave(&conf->device_lock, flags);
+	rcu_read_lock();
 	for (i=0; i<mddev->raid_disks; i++) {
 		mdk_rdev_t *rdev = conf->multipaths[i].rdev;
-		if (rdev && !rdev->faulty) {
+		if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
 			request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
 
 			atomic_inc(&rdev->nr_pending);
-			spin_unlock_irqrestore(&conf->device_lock, flags);
+			rcu_read_unlock();
 
 			if (r_queue->unplug_fn)
 				r_queue->unplug_fn(r_queue);
 
-			spin_lock_irqsave(&conf->device_lock, flags);
-			atomic_dec(&rdev->nr_pending);
+			rdev_dec_pending(rdev, mddev);
+			rcu_read_lock();
 		}
 	}
-	spin_unlock_irqrestore(&conf->device_lock, flags);
+	rcu_read_unlock();
 }
+
 static void multipath_unplug(request_queue_t *q)
 {
 	unplug_slaves(q->queuedata);
@@ -195,6 +190,7 @@
 	multipath = conf->multipaths + mp_bh->path;
 
 	mp_bh->bio = *bio;
+	mp_bh->bio.bi_sector += multipath->rdev->data_offset;
 	mp_bh->bio.bi_bdev = multipath->rdev->bdev;
 	mp_bh->bio.bi_rw |= (1 << BIO_RW_FAILFAST);
 	mp_bh->bio.bi_end_io = multipath_end_request;
@@ -224,22 +220,26 @@
 	multipath_conf_t *conf = mddev_to_conf(mddev);
 	int i, ret = 0;
 
-	for (i=0; i<mddev->raid_disks; i++) {
+	rcu_read_lock();
+	for (i=0; i<mddev->raid_disks && ret == 0; i++) {
 		mdk_rdev_t *rdev = conf->multipaths[i].rdev;
 		if (rdev && !rdev->faulty) {
 			struct block_device *bdev = rdev->bdev;
 			request_queue_t *r_queue = bdev_get_queue(bdev);
 
-			if (!r_queue->issue_flush_fn) {
+			if (!r_queue->issue_flush_fn)
 				ret = -EOPNOTSUPP;
-				break;
+			else {
+				atomic_inc(&rdev->nr_pending);
+				rcu_read_unlock();
+				ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk,
+							      error_sector);
+				rdev_dec_pending(rdev, mddev);
+				rcu_read_lock();
 			}
-
-			ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
-			if (ret)
-				break;
 		}
 	}
+	rcu_read_unlock();
 	return ret;
 }
 
@@ -310,10 +310,9 @@
 	struct multipath_info *p;
 
 	print_multipath_conf(conf);
-	spin_lock_irq(&conf->device_lock);
+
 	for (path=0; path<mddev->raid_disks; path++) 
 		if ((p=conf->multipaths+path)->rdev == NULL) {
-			p->rdev = rdev;
 			blk_queue_stack_limits(mddev->queue,
 					       rdev->bdev->bd_disk->queue);
 
@@ -330,9 +329,9 @@
 			conf->working_disks++;
 			rdev->raid_disk = path;
 			rdev->in_sync = 1;
+			p->rdev = rdev;
 			found = 1;
 		}
-	spin_unlock_irq(&conf->device_lock);
 
 	print_multipath_conf(conf);
 	return found;
@@ -341,26 +340,29 @@
 static int multipath_remove_disk(mddev_t *mddev, int number)
 {
 	multipath_conf_t *conf = mddev->private;
-	int err = 1;
+	int err = 0;
+	mdk_rdev_t *rdev;
 	struct multipath_info *p = conf->multipaths + number;
 
 	print_multipath_conf(conf);
-	spin_lock_irq(&conf->device_lock);
 
-	if (p->rdev) {
-		if (p->rdev->in_sync ||
-		    atomic_read(&p->rdev->nr_pending)) {
+	rdev = p->rdev;
+	if (rdev) {
+		if (rdev->in_sync ||
+		    atomic_read(&rdev->nr_pending)) {
 			printk(KERN_ERR "hot-remove-disk, slot %d is identified"				" but is still operational!\n", number);
 			err = -EBUSY;
 			goto abort;
 		}
 		p->rdev = NULL;
-		err = 0;
+		synchronize_kernel();
+		if (atomic_read(&rdev->nr_pending)) {
+			/* lost the race, try later */
+			err = -EBUSY;
+			p->rdev = rdev;
+		}
 	}
-	if (err)
-		MD_BUG();
 abort:
-	spin_unlock_irq(&conf->device_lock);
 
 	print_multipath_conf(conf);
 	return err;
@@ -382,18 +384,18 @@
 	struct bio *bio;
 	unsigned long flags;
 	multipath_conf_t *conf = mddev_to_conf(mddev);
+	struct list_head *head = &conf->retry_list;
 
 	md_check_recovery(mddev);
 	for (;;) {
 		char b[BDEVNAME_SIZE];
-		spin_lock_irqsave(&retry_list_lock, flags);
-		mp_bh = multipath_retry_list;
-		if (!mp_bh)
+		spin_lock_irqsave(&conf->device_lock, flags);
+		if (list_empty(head))
 			break;
-		multipath_retry_list = mp_bh->next_mp;
-		spin_unlock_irqrestore(&retry_list_lock, flags);
+		mp_bh = list_entry(head->prev, struct multipath_bh, retry_list);
+		list_del(head->prev);
+		spin_unlock_irqrestore(&conf->device_lock, flags);
 
-		mddev = mp_bh->mddev;
 		bio = &mp_bh->bio;
 		bio->bi_sector = mp_bh->master_bio->bi_sector;
 		
@@ -409,6 +411,7 @@
 				bdevname(bio->bi_bdev,b),
 				(unsigned long long)bio->bi_sector);
 			*bio = *(mp_bh->master_bio);
+			bio->bi_sector += conf->multipaths[mp_bh->path].rdev->data_offset;
 			bio->bi_bdev = conf->multipaths[mp_bh->path].rdev->bdev;
 			bio->bi_rw |= (1 << BIO_RW_FAILFAST);
 			bio->bi_end_io = multipath_end_request;
@@ -416,7 +419,7 @@
 			generic_make_request(bio);
 		}
 	}
-	spin_unlock_irqrestore(&retry_list_lock, flags);
+	spin_unlock_irqrestore(&conf->device_lock, flags);
 }
 
 static int multipath_run (mddev_t *mddev)
@@ -489,6 +492,7 @@
 	mddev->sb_dirty = 1;
 	conf->mddev = mddev;
 	conf->device_lock = SPIN_LOCK_UNLOCKED;
+	INIT_LIST_HEAD(&conf->retry_list);
 
 	if (!conf->working_disks) {
 		printk(KERN_ERR "multipath: no operational IO paths for %s\n",
@@ -543,6 +547,7 @@
 
 	md_unregister_thread(mddev->thread);
 	mddev->thread = NULL;
+	blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
 	mempool_destroy(conf->pool);
 	kfree(conf->multipaths);
 	kfree(conf);
diff -Nru a/drivers/md/raid0.c b/drivers/md/raid0.c
--- a/drivers/md/raid0.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/md/raid0.c	2004-12-24 13:36:56 -08:00
@@ -48,18 +48,14 @@
 	mdk_rdev_t **devlist = conf->strip_zone[0].dev;
 	int i, ret = 0;
 
-	for (i=0; i<mddev->raid_disks; i++) {
+	for (i=0; i<mddev->raid_disks && ret == 0; i++) {
 		struct block_device *bdev = devlist[i]->bdev;
 		request_queue_t *r_queue = bdev_get_queue(bdev);
 
-		if (!r_queue->issue_flush_fn) {
+		if (!r_queue->issue_flush_fn)
 			ret = -EOPNOTSUPP;
-			break;
-		}
-
-		ret =r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
-		if (ret)
-			break;
+		else
+			ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
 	}
 	return ret;
 }
@@ -389,6 +385,7 @@
 {
 	raid0_conf_t *conf = mddev_to_conf(mddev);
 
+	blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
 	kfree (conf->hash_table);
 	conf->hash_table = NULL;
 	kfree (conf->strip_zone);
diff -Nru a/drivers/md/raid1.c b/drivers/md/raid1.c
--- a/drivers/md/raid1.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/md/raid1.c	2004-12-24 13:36:55 -08:00
@@ -30,8 +30,6 @@
 #define	NR_RAID1_BIOS 256
 
 static mdk_personality_t raid1_personality;
-static spinlock_t retry_list_lock = SPIN_LOCK_UNLOCKED;
-static LIST_HEAD(retry_list_head);
 
 static void unplug_slaves(mddev_t *mddev);
 
@@ -188,10 +186,11 @@
 {
 	unsigned long flags;
 	mddev_t *mddev = r1_bio->mddev;
+	conf_t *conf = mddev_to_conf(mddev);
 
-	spin_lock_irqsave(&retry_list_lock, flags);
-	list_add(&r1_bio->retry_list, &retry_list_head);
-	spin_unlock_irqrestore(&retry_list_lock, flags);
+	spin_lock_irqsave(&conf->device_lock, flags);
+	list_add(&r1_bio->retry_list, &conf->retry_list);
+	spin_unlock_irqrestore(&conf->device_lock, flags);
 
 	md_wakeup_thread(mddev->thread);
 }
@@ -340,7 +339,7 @@
 	const int sectors = r1_bio->sectors;
 	sector_t new_distance, current_distance;
 
-	spin_lock_irq(&conf->device_lock);
+	rcu_read_lock();
 	/*
 	 * Check if it if we can balance. We can balance on the whole
 	 * device if no resync is going on, or below the resync window.
@@ -417,7 +416,7 @@
 		conf->last_used = new_disk;
 		atomic_inc(&conf->mirrors[new_disk].rdev->nr_pending);
 	}
-	spin_unlock_irq(&conf->device_lock);
+	rcu_read_unlock();
 
 	return new_disk;
 }
@@ -426,26 +425,26 @@
 {
 	conf_t *conf = mddev_to_conf(mddev);
 	int i;
-	unsigned long flags;
 
-	spin_lock_irqsave(&conf->device_lock, flags);
+	rcu_read_lock();
 	for (i=0; i<mddev->raid_disks; i++) {
 		mdk_rdev_t *rdev = conf->mirrors[i].rdev;
-		if (rdev && atomic_read(&rdev->nr_pending)) {
+		if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
 			request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
 
 			atomic_inc(&rdev->nr_pending);
-			spin_unlock_irqrestore(&conf->device_lock, flags);
+			rcu_read_unlock();
 
 			if (r_queue->unplug_fn)
 				r_queue->unplug_fn(r_queue);
 
-			spin_lock_irqsave(&conf->device_lock, flags);
-			atomic_dec(&rdev->nr_pending);
+			rdev_dec_pending(rdev, mddev);
+			rcu_read_lock();
 		}
 	}
-	spin_unlock_irqrestore(&conf->device_lock, flags);
+	rcu_read_unlock();
 }
+
 static void raid1_unplug(request_queue_t *q)
 {
 	unplug_slaves(q->queuedata);
@@ -456,24 +455,28 @@
 {
 	mddev_t *mddev = q->queuedata;
 	conf_t *conf = mddev_to_conf(mddev);
-	unsigned long flags;
 	int i, ret = 0;
 
-	spin_lock_irqsave(&conf->device_lock, flags);
-	for (i=0; i<mddev->raid_disks; i++) {
+	rcu_read_lock();
+	for (i=0; i<mddev->raid_disks && ret == 0; i++) {
 		mdk_rdev_t *rdev = conf->mirrors[i].rdev;
 		if (rdev && !rdev->faulty) {
 			struct block_device *bdev = rdev->bdev;
 			request_queue_t *r_queue = bdev_get_queue(bdev);
 
-			if (r_queue->issue_flush_fn) {
-				ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
-				if (ret)
-					break;
+			if (!r_queue->issue_flush_fn)
+				ret = -EOPNOTSUPP;
+			else {
+				atomic_inc(&rdev->nr_pending);
+				rcu_read_unlock();
+				ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk,
+							      error_sector);
+				rdev_dec_pending(rdev, mddev);
+				rcu_read_lock();
 			}
 		}
 	}
-	spin_unlock_irqrestore(&conf->device_lock, flags);
+	rcu_read_unlock();
 	return ret;
 }
 
@@ -580,7 +583,7 @@
 	 * bios[x] to bio
 	 */
 	disks = conf->raid_disks;
-	spin_lock_irq(&conf->device_lock);
+	rcu_read_lock();
 	for (i = 0;  i < disks; i++) {
 		if (conf->mirrors[i].rdev &&
 		    !conf->mirrors[i].rdev->faulty) {
@@ -589,7 +592,7 @@
 		} else
 			r1_bio->bios[i] = NULL;
 	}
-	spin_unlock_irq(&conf->device_lock);
+	rcu_read_unlock();
 
 	atomic_set(&r1_bio->remaining, 1);
 	md_write_start(mddev);
@@ -711,7 +714,6 @@
 	conf_t *conf = mddev->private;
 	mirror_info_t *tmp;
 
-	spin_lock_irq(&conf->device_lock);
 	/*
 	 * Find all failed disks within the RAID1 configuration 
 	 * and mark them readable
@@ -726,7 +728,6 @@
 			tmp->rdev->in_sync = 1;
 		}
 	}
-	spin_unlock_irq(&conf->device_lock);
 
 	print_conf(conf);
 	return 0;
@@ -740,10 +741,8 @@
 	int mirror;
 	mirror_info_t *p;
 
-	spin_lock_irq(&conf->device_lock);
 	for (mirror=0; mirror < mddev->raid_disks; mirror++)
 		if ( !(p=conf->mirrors+mirror)->rdev) {
-			p->rdev = rdev;
 
 			blk_queue_stack_limits(mddev->queue,
 					       rdev->bdev->bd_disk->queue);
@@ -758,9 +757,9 @@
 			p->head_position = 0;
 			rdev->raid_disk = mirror;
 			found = 1;
+			p->rdev = rdev;
 			break;
 		}
-	spin_unlock_irq(&conf->device_lock);
 
 	print_conf(conf);
 	return found;
@@ -769,24 +768,27 @@
 static int raid1_remove_disk(mddev_t *mddev, int number)
 {
 	conf_t *conf = mddev->private;
-	int err = 1;
+	int err = 0;
+	mdk_rdev_t *rdev;
 	mirror_info_t *p = conf->mirrors+ number;
 
 	print_conf(conf);
-	spin_lock_irq(&conf->device_lock);
-	if (p->rdev) {
-		if (p->rdev->in_sync ||
-		    atomic_read(&p->rdev->nr_pending)) {
+	rdev = p->rdev;
+	if (rdev) {
+		if (rdev->in_sync ||
+		    atomic_read(&rdev->nr_pending)) {
 			err = -EBUSY;
 			goto abort;
 		}
 		p->rdev = NULL;
-		err = 0;
+		synchronize_kernel();
+		if (atomic_read(&rdev->nr_pending)) {
+			/* lost the race, try later */
+			err = -EBUSY;
+			p->rdev = rdev;
+		}
 	}
-	if (err)
-		MD_BUG();
 abort:
-	spin_unlock_irq(&conf->device_lock);
 
 	print_conf(conf);
 	return err;
@@ -904,11 +906,11 @@
 
 static void raid1d(mddev_t *mddev)
 {
-	struct list_head *head = &retry_list_head;
 	r1bio_t *r1_bio;
 	struct bio *bio;
 	unsigned long flags;
 	conf_t *conf = mddev_to_conf(mddev);
+	struct list_head *head = &conf->retry_list;
 	int unplug=0;
 	mdk_rdev_t *rdev;
 
@@ -917,12 +919,12 @@
 	
 	for (;;) {
 		char b[BDEVNAME_SIZE];
-		spin_lock_irqsave(&retry_list_lock, flags);
+		spin_lock_irqsave(&conf->device_lock, flags);
 		if (list_empty(head))
 			break;
 		r1_bio = list_entry(head->prev, r1bio_t, retry_list);
 		list_del(head->prev);
-		spin_unlock_irqrestore(&retry_list_lock, flags);
+		spin_unlock_irqrestore(&conf->device_lock, flags);
 
 		mddev = r1_bio->mddev;
 		conf = mddev_to_conf(mddev);
@@ -941,6 +943,8 @@
 			} else {
 				r1_bio->bios[r1_bio->read_disk] = NULL;
 				r1_bio->read_disk = disk;
+				bio_put(bio);
+				bio = bio_clone(r1_bio->master_bio, GFP_NOIO);
 				r1_bio->bios[r1_bio->read_disk] = bio;
 				rdev = conf->mirrors[disk].rdev;
 				if (printk_ratelimit())
@@ -948,15 +952,17 @@
 					       " another mirror\n",
 					       bdevname(rdev->bdev,b),
 					       (unsigned long long)r1_bio->sector);
-				bio->bi_bdev = rdev->bdev;
 				bio->bi_sector = r1_bio->sector + rdev->data_offset;
+				bio->bi_bdev = rdev->bdev;
+				bio->bi_end_io = raid1_end_read_request;
 				bio->bi_rw = READ;
+				bio->bi_private = r1_bio;
 				unplug = 1;
 				generic_make_request(bio);
 			}
 		}
 	}
-	spin_unlock_irqrestore(&retry_list_lock, flags);
+	spin_unlock_irqrestore(&conf->device_lock, flags);
 	if (unplug)
 		unplug_slaves(mddev);
 }
@@ -1013,7 +1019,7 @@
 	 * put in a delay to throttle resync.
 	 */
 	if (!go_faster && waitqueue_active(&conf->wait_resume))
-		schedule_timeout(HZ);
+		msleep_interruptible(1000);
 	device_barrier(conf, sector_nr + RESYNC_SECTORS);
 
 	/*
@@ -1023,7 +1029,7 @@
 	 */
 	disk = conf->last_used;
 	/* make sure disk is operational */
-	spin_lock_irq(&conf->device_lock);
+
 	while (conf->mirrors[disk].rdev == NULL ||
 	       !conf->mirrors[disk].rdev->in_sync) {
 		if (disk <= 0)
@@ -1034,7 +1040,7 @@
 	}
 	conf->last_used = disk;
 	atomic_inc(&conf->mirrors[disk].rdev->nr_pending);
-	spin_unlock_irq(&conf->device_lock);
+
 
 	mirror = conf->mirrors + disk;
 
@@ -1087,7 +1093,7 @@
 		int rv = max_sector - sector_nr;
 		md_done_sync(mddev, rv, 1);
 		put_buf(r1_bio);
-		atomic_dec(&conf->mirrors[disk].rdev->nr_pending);
+		rdev_dec_pending(conf->mirrors[disk].rdev, mddev);
 		return rv;
 	}
 
@@ -1205,6 +1211,7 @@
 	conf->raid_disks = mddev->raid_disks;
 	conf->mddev = mddev;
 	conf->device_lock = SPIN_LOCK_UNLOCKED;
+	INIT_LIST_HEAD(&conf->retry_list);
 	if (conf->working_disks == 1)
 		mddev->recovery_cp = MaxSector;
 
@@ -1286,6 +1293,7 @@
 
 	md_unregister_thread(mddev->thread);
 	mddev->thread = NULL;
+	blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
 	if (conf->r1bio_pool)
 		mempool_destroy(conf->r1bio_pool);
 	if (conf->mirrors)
diff -Nru a/drivers/md/raid10.c b/drivers/md/raid10.c
--- a/drivers/md/raid10.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/md/raid10.c	2004-12-24 13:37:19 -08:00
@@ -36,7 +36,7 @@
  * device of the previous section.
  * Thus there are (near_copies*far_copies) of each chunk, and each is on a different
  * drive.
- * near_copies and far_copies must be at least one, and there product is at most
+ * near_copies and far_copies must be at least one, and their product is at most
  * raid_disks.
  */
 
@@ -498,7 +498,7 @@
 	sector_t new_distance, current_distance;
 
 	raid10_find_phys(conf, r10_bio);
-	spin_lock_irq(&conf->device_lock);
+	rcu_read_lock();
 	/*
 	 * Check if we can balance. We can balance on the whole
 	 * device if no resync is going on, or below the resync window.
@@ -570,7 +570,7 @@
 
 	if (disk >= 0 && conf->mirrors[disk].rdev)
 		atomic_inc(&conf->mirrors[disk].rdev->nr_pending);
-	spin_unlock_irq(&conf->device_lock);
+	rcu_read_unlock();
 
 	return disk;
 }
@@ -579,26 +579,26 @@
 {
 	conf_t *conf = mddev_to_conf(mddev);
 	int i;
-	unsigned long flags;
 
-	spin_lock_irqsave(&conf->device_lock, flags);
+	rcu_read_lock();
 	for (i=0; i<mddev->raid_disks; i++) {
 		mdk_rdev_t *rdev = conf->mirrors[i].rdev;
-		if (rdev && atomic_read(&rdev->nr_pending)) {
+		if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
 			request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
 
 			atomic_inc(&rdev->nr_pending);
-			spin_unlock_irqrestore(&conf->device_lock, flags);
+			rcu_read_unlock();
 
 			if (r_queue->unplug_fn)
 				r_queue->unplug_fn(r_queue);
 
-			spin_lock_irqsave(&conf->device_lock, flags);
-			atomic_dec(&rdev->nr_pending);
+			rdev_dec_pending(rdev, mddev);
+			rcu_read_lock();
 		}
 	}
-	spin_unlock_irqrestore(&conf->device_lock, flags);
+	rcu_read_unlock();
 }
+
 static void raid10_unplug(request_queue_t *q)
 {
 	unplug_slaves(q->queuedata);
@@ -609,24 +609,28 @@
 {
 	mddev_t *mddev = q->queuedata;
 	conf_t *conf = mddev_to_conf(mddev);
-	unsigned long flags;
 	int i, ret = 0;
 
-	spin_lock_irqsave(&conf->device_lock, flags);
-	for (i=0; i<mddev->raid_disks; i++) {
+	rcu_read_lock();
+	for (i=0; i<mddev->raid_disks && ret == 0; i++) {
 		mdk_rdev_t *rdev = conf->mirrors[i].rdev;
 		if (rdev && !rdev->faulty) {
 			struct block_device *bdev = rdev->bdev;
 			request_queue_t *r_queue = bdev_get_queue(bdev);
 
-			if (r_queue->issue_flush_fn) {
-				ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
-				if (ret)
-					break;
+			if (!r_queue->issue_flush_fn)
+				ret = -EOPNOTSUPP;
+			else {
+				atomic_inc(&rdev->nr_pending);
+				rcu_read_unlock();
+				ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk,
+							      error_sector);
+				rdev_dec_pending(rdev, mddev);
+				rcu_read_lock();
 			}
 		}
 	}
-	spin_unlock_irqrestore(&conf->device_lock, flags);
+	rcu_read_unlock();
 	return ret;
 }
 
@@ -757,7 +761,7 @@
 	 * bios[x] to bio
 	 */
 	raid10_find_phys(conf, r10_bio);
-	spin_lock_irq(&conf->device_lock);
+	rcu_read_lock();
 	for (i = 0;  i < conf->copies; i++) {
 		int d = r10_bio->devs[i].devnum;
 		if (conf->mirrors[d].rdev &&
@@ -767,7 +771,7 @@
 		} else
 			r10_bio->devs[i].bio = NULL;
 	}
-	spin_unlock_irq(&conf->device_lock);
+	rcu_read_unlock();
 
 	atomic_set(&r10_bio->remaining, 1);
 	md_write_start(mddev);
@@ -900,7 +904,6 @@
 	conf_t *conf = mddev->private;
 	mirror_info_t *tmp;
 
-	spin_lock_irq(&conf->device_lock);
 	/*
 	 * Find all non-in_sync disks within the RAID10 configuration
 	 * and mark them in_sync
@@ -915,7 +918,6 @@
 			tmp->rdev->in_sync = 1;
 		}
 	}
-	spin_unlock_irq(&conf->device_lock);
 
 	print_conf(conf);
 	return 0;
@@ -934,10 +936,9 @@
 		 * very different from resync
 		 */
 		return 0;
-	spin_lock_irq(&conf->device_lock);
+
 	for (mirror=0; mirror < mddev->raid_disks; mirror++)
 		if ( !(p=conf->mirrors+mirror)->rdev) {
-			p->rdev = rdev;
 
 			blk_queue_stack_limits(mddev->queue,
 					       rdev->bdev->bd_disk->queue);
@@ -952,9 +953,9 @@
 			p->head_position = 0;
 			rdev->raid_disk = mirror;
 			found = 1;
+			p->rdev = rdev;
 			break;
 		}
-	spin_unlock_irq(&conf->device_lock);
 
 	print_conf(conf);
 	return found;
@@ -963,24 +964,27 @@
 static int raid10_remove_disk(mddev_t *mddev, int number)
 {
 	conf_t *conf = mddev->private;
-	int err = 1;
+	int err = 0;
+	mdk_rdev_t *rdev;
 	mirror_info_t *p = conf->mirrors+ number;
 
 	print_conf(conf);
-	spin_lock_irq(&conf->device_lock);
-	if (p->rdev) {
-		if (p->rdev->in_sync ||
-		    atomic_read(&p->rdev->nr_pending)) {
+	rdev = p->rdev;
+	if (rdev) {
+		if (rdev->in_sync ||
+		    atomic_read(&rdev->nr_pending)) {
 			err = -EBUSY;
 			goto abort;
 		}
 		p->rdev = NULL;
-		err = 0;
+		synchronize_kernel();
+		if (atomic_read(&rdev->nr_pending)) {
+			/* lost the race, try later */
+			err = -EBUSY;
+			p->rdev = rdev;
+		}
 	}
-	if (err)
-		MD_BUG();
 abort:
-	spin_unlock_irq(&conf->device_lock);
 
 	print_conf(conf);
 	return err;
@@ -1145,6 +1149,8 @@
 		atomic_inc(&r10_bio->remaining);
 		md_sync_acct(conf->mirrors[d].rdev->bdev, tbio->bi_size >> 9);
 
+		tbio->bi_sector += conf->mirrors[d].rdev->data_offset;
+		tbio->bi_bdev = conf->mirrors[d].rdev->bdev;
 		generic_make_request(tbio);
 	}
 
@@ -1233,8 +1239,8 @@
 			int mirror;
 			bio = r10_bio->devs[r10_bio->read_slot].bio;
 			r10_bio->devs[r10_bio->read_slot].bio = NULL;
+			bio_put(bio);
 			mirror = read_balance(conf, r10_bio);
-			r10_bio->devs[r10_bio->read_slot].bio = bio;
 			if (mirror == -1) {
 				printk(KERN_ALERT "raid10: %s: unrecoverable I/O"
 				       " read error for block %llu\n",
@@ -1248,15 +1254,14 @@
 					       " another mirror\n",
 					       bdevname(rdev->bdev,b),
 					       (unsigned long long)r10_bio->sector);
-				bio->bi_bdev = rdev->bdev;
+				bio = bio_clone(r10_bio->master_bio, GFP_NOIO);
+				r10_bio->devs[r10_bio->read_slot].bio = bio;
 				bio->bi_sector = r10_bio->devs[r10_bio->read_slot].addr
 					+ rdev->data_offset;
-				bio->bi_next = NULL;
-				bio->bi_flags &= (1<<BIO_CLONED);
-				bio->bi_flags |= 1 << BIO_UPTODATE;
-				bio->bi_idx = 0;
-				bio->bi_size = r10_bio->sectors << 9;
+				bio->bi_bdev = rdev->bdev;
 				bio->bi_rw = READ;
+				bio->bi_private = r10_bio;
+				bio->bi_end_io = raid10_end_read_request;
 				unplug = 1;
 				generic_make_request(bio);
 			}
@@ -1358,7 +1363,7 @@
 	 * put in a delay to throttle resync.
 	 */
 	if (!go_faster && waitqueue_active(&conf->wait_resume))
-		schedule_timeout(HZ);
+		msleep_interruptible(1000);
 	device_barrier(conf, sector_nr + RESYNC_SECTORS);
 
 	/* Again, very different code for resync and recovery.
@@ -1468,7 +1473,7 @@
 		set_bit(R10BIO_IsSync, &r10_bio->state);
 		raid10_find_phys(conf, r10_bio);
 		r10_bio->sectors = (sector_nr | conf->chunk_mask) - sector_nr +1;
-		spin_lock_irq(&conf->device_lock);
+
 		for (i=0; i<conf->copies; i++) {
 			int d = r10_bio->devs[i].devnum;
 			bio = r10_bio->devs[i].bio;
@@ -1488,14 +1493,15 @@
 			bio->bi_bdev = conf->mirrors[d].rdev->bdev;
 			count++;
 		}
-		spin_unlock_irq(&conf->device_lock);
+
 		if (count < 2) {
 			for (i=0; i<conf->copies; i++) {
 				int d = r10_bio->devs[i].devnum;
 				if (r10_bio->devs[i].bio->bi_end_io)
-					atomic_dec(&conf->mirrors[d].rdev->nr_pending);
+					rdev_dec_pending(conf->mirrors[d].rdev, mddev);
 			}
 			put_buf(r10_bio);
+			biolist = NULL;
 			goto giveup;
 		}
 	}
@@ -1557,7 +1563,7 @@
 		}
 	}
 
-	return nr_sectors;
+	return sectors_skipped + nr_sectors;
  giveup:
 	/* There is nowhere to write, so all non-sync
 	 * drives must be failed, so try the next chunk...
@@ -1739,6 +1745,7 @@
 
 	md_unregister_thread(mddev->thread);
 	mddev->thread = NULL;
+	blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
 	if (conf->r10bio_pool)
 		mempool_destroy(conf->r10bio_pool);
 	if (conf->mirrors)
diff -Nru a/drivers/md/raid5.c b/drivers/md/raid5.c
--- a/drivers/md/raid5.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/md/raid5.c	2004-12-24 13:36:30 -08:00
@@ -21,7 +21,7 @@
 #include <linux/slab.h>
 #include <linux/raid/raid5.h>
 #include <linux/highmem.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/atomic.h>
 
 /*
@@ -1247,13 +1247,13 @@
 		else
 			bi->bi_end_io = raid5_end_read_request;
  
-		spin_lock_irq(&conf->device_lock);
+		rcu_read_lock();
 		rdev = conf->disks[i].rdev;
 		if (rdev && rdev->faulty)
 			rdev = NULL;
 		if (rdev)
 			atomic_inc(&rdev->nr_pending);
-		spin_unlock_irq(&conf->device_lock);
+		rcu_read_unlock();
  
 		if (rdev) {
 			if (test_bit(R5_Syncio, &sh->dev[i].flags))
@@ -1302,25 +1302,24 @@
 {
 	raid5_conf_t *conf = mddev_to_conf(mddev);
 	int i;
-	unsigned long flags;
 
-	spin_lock_irqsave(&conf->device_lock, flags);
+	rcu_read_lock();
 	for (i=0; i<mddev->raid_disks; i++) {
 		mdk_rdev_t *rdev = conf->disks[i].rdev;
-		if (rdev && atomic_read(&rdev->nr_pending)) {
+		if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
 			request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
 
 			atomic_inc(&rdev->nr_pending);
-			spin_unlock_irqrestore(&conf->device_lock, flags);
+			rcu_read_unlock();
 
-			if (r_queue && r_queue->unplug_fn)
+			if (r_queue->unplug_fn)
 				r_queue->unplug_fn(r_queue);
 
-			spin_lock_irqsave(&conf->device_lock, flags);
-			atomic_dec(&rdev->nr_pending);
+			rdev_dec_pending(rdev, mddev);
+			rcu_read_lock();
 		}
 	}
-	spin_unlock_irqrestore(&conf->device_lock, flags);
+	rcu_read_unlock();
 }
 
 static void raid5_unplug_device(request_queue_t *q)
@@ -1347,29 +1346,26 @@
 	raid5_conf_t *conf = mddev_to_conf(mddev);
 	int i, ret = 0;
 
-	for (i=0; i<mddev->raid_disks; i++) {
+	rcu_read_lock();
+	for (i=0; i<mddev->raid_disks && ret == 0; i++) {
 		mdk_rdev_t *rdev = conf->disks[i].rdev;
 		if (rdev && !rdev->faulty) {
 			struct block_device *bdev = rdev->bdev;
-			request_queue_t *r_queue;
-
-			if (!bdev)
-				continue;
-
-			r_queue = bdev_get_queue(bdev);
-			if (!r_queue)
-				continue;
+			request_queue_t *r_queue = bdev_get_queue(bdev);
 
-			if (!r_queue->issue_flush_fn) {
+			if (!r_queue->issue_flush_fn)
 				ret = -EOPNOTSUPP;
-				break;
+			else {
+				atomic_inc(&rdev->nr_pending);
+				rcu_read_unlock();
+				ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk,
+							      error_sector);
+				rdev_dec_pending(rdev, mddev);
+				rcu_read_lock();
 			}
-
-			ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
-			if (ret)
-				break;
 		}
 	}
+	rcu_read_unlock();
 	return ret;
 }
 
@@ -1410,7 +1406,7 @@
 		new_sector = raid5_compute_sector(logical_sector,
 						  raid_disks, data_disks, &dd_idx, &pd_idx, conf);
 
-		PRINTK("raid5: make_request, sector %Lu logical %Lu\n",
+		PRINTK("raid5: make_request, sector %llu logical %llu\n",
 			(unsigned long long)new_sector, 
 			(unsigned long long)logical_sector);
 
@@ -1711,6 +1707,7 @@
 	mddev->thread = NULL;
 	shrink_stripes(conf);
 	free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER);
+	blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
 	kfree(conf);
 	mddev->private = NULL;
 	return 0;
@@ -1799,7 +1796,6 @@
 	raid5_conf_t *conf = mddev->private;
 	struct disk_info *tmp;
 
-	spin_lock_irq(&conf->device_lock);
 	for (i = 0; i < conf->raid_disks; i++) {
 		tmp = conf->disks + i;
 		if (tmp->rdev
@@ -1811,7 +1807,6 @@
 			tmp->rdev->in_sync = 1;
 		}
 	}
-	spin_unlock_irq(&conf->device_lock);
 	print_raid5_conf(conf);
 	return 0;
 }
@@ -1819,25 +1814,28 @@
 static int raid5_remove_disk(mddev_t *mddev, int number)
 {
 	raid5_conf_t *conf = mddev->private;
-	int err = 1;
+	int err = 0;
+	mdk_rdev_t *rdev;
 	struct disk_info *p = conf->disks + number;
 
 	print_raid5_conf(conf);
-	spin_lock_irq(&conf->device_lock);
-
-	if (p->rdev) {
-		if (p->rdev->in_sync || 
-		    atomic_read(&p->rdev->nr_pending)) {
+	rdev = p->rdev;
+	if (rdev) {
+		if (rdev->in_sync ||
+		    atomic_read(&rdev->nr_pending)) {
 			err = -EBUSY;
 			goto abort;
 		}
 		p->rdev = NULL;
-		err = 0;
+		synchronize_kernel();
+		if (atomic_read(&rdev->nr_pending)) {
+			/* lost the race, try later */
+			err = -EBUSY;
+			p->rdev = rdev;
+		}
 	}
-	if (err)
-		MD_BUG();
 abort:
-	spin_unlock_irq(&conf->device_lock);
+
 	print_raid5_conf(conf);
 	return err;
 }
@@ -1849,19 +1847,17 @@
 	int disk;
 	struct disk_info *p;
 
-	spin_lock_irq(&conf->device_lock);
 	/*
 	 * find the disk ...
 	 */
 	for (disk=0; disk < mddev->raid_disks; disk++)
 		if ((p=conf->disks + disk)->rdev == NULL) {
-			p->rdev = rdev;
 			rdev->in_sync = 0;
 			rdev->raid_disk = disk;
 			found = 1;
+			p->rdev = rdev;
 			break;
 		}
-	spin_unlock_irq(&conf->device_lock);
 	print_raid5_conf(conf);
 	return found;
 }
diff -Nru a/drivers/md/raid6main.c b/drivers/md/raid6main.c
--- a/drivers/md/raid6main.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/md/raid6main.c	2004-12-24 13:36:17 -08:00
@@ -25,7 +25,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/highmem.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/atomic.h>
 #include "raid6.h"
 
@@ -734,7 +734,6 @@
 	case READ_MODIFY_WRITE:
 		BUG();		/* READ_MODIFY_WRITE N/A for RAID-6 */
 	case RECONSTRUCT_WRITE:
-	case UPDATE_PARITY:	/* Is this right? */
 		for (i= disks; i-- ;)
 			if ( i != pd_idx && i != qd_idx && sh->dev[i].towrite ) {
 				chosen = sh->dev[i].towrite;
@@ -770,7 +769,8 @@
 		i = d0_idx;
 		do {
 			ptrs[count++] = page_address(sh->dev[i].page);
-
+			if (count <= disks-2 && !test_bit(R5_UPTODATE, &sh->dev[i].flags))
+				printk("block %d/%d not uptodate on parity calc\n", i,count);
 			i = raid6_next_disk(i, disks);
 		} while ( i != d0_idx );
 //		break;
@@ -818,7 +818,7 @@
 			if (test_bit(R5_UPTODATE, &sh->dev[i].flags))
 				ptr[count++] = p;
 			else
-				PRINTK("compute_block() %d, stripe %llu, %d"
+				printk("compute_block() %d, stripe %llu, %d"
 				       " not present\n", dd_idx,
 				       (unsigned long long)sh->sector, i);
 
@@ -875,6 +875,9 @@
 		do {
 			ptrs[count++] = page_address(sh->dev[i].page);
 			i = raid6_next_disk(i, disks);
+			if (i != dd_idx1 && i != dd_idx2 &&
+			    !test_bit(R5_UPTODATE, &sh->dev[i].flags))
+				printk("compute_2 with missing block %d/%d\n", count, i);
 		} while ( i != d0_idx );
 
 		if ( failb == disks-2 ) {
@@ -1157,17 +1160,15 @@
 	 * parity, or to satisfy requests
 	 * or to load a block that is being partially written.
 	 */
-	if (to_read || non_overwrite || (syncing && (uptodate < disks))) {
+	if (to_read || non_overwrite || (to_write && failed) || (syncing && (uptodate < disks))) {
 		for (i=disks; i--;) {
 			dev = &sh->dev[i];
 			if (!test_bit(R5_LOCKED, &dev->flags) && !test_bit(R5_UPTODATE, &dev->flags) &&
 			    (dev->toread ||
 			     (dev->towrite && !test_bit(R5_OVERWRITE, &dev->flags)) ||
 			     syncing ||
-			     (failed >= 1 && (sh->dev[failed_num[0]].toread ||
-					 (sh->dev[failed_num[0]].towrite && !test_bit(R5_OVERWRITE, &sh->dev[failed_num[0]].flags)))) ||
-			     (failed >= 2 && (sh->dev[failed_num[1]].toread ||
-					 (sh->dev[failed_num[1]].towrite && !test_bit(R5_OVERWRITE, &sh->dev[failed_num[1]].flags))))
+			     (failed >= 1 && (sh->dev[failed_num[0]].toread || to_write)) ||
+			     (failed >= 2 && (sh->dev[failed_num[1]].toread || to_write))
 				    )
 				) {
 				/* we would like to get this block, possibly
@@ -1409,13 +1410,13 @@
 		else
 			bi->bi_end_io = raid6_end_read_request;
 
-		spin_lock_irq(&conf->device_lock);
+		rcu_read_lock();
 		rdev = conf->disks[i].rdev;
 		if (rdev && rdev->faulty)
 			rdev = NULL;
 		if (rdev)
 			atomic_inc(&rdev->nr_pending);
-		spin_unlock_irq(&conf->device_lock);
+		rcu_read_unlock();
 
 		if (rdev) {
 			if (test_bit(R5_Syncio, &sh->dev[i].flags))
@@ -1464,25 +1465,24 @@
 {
 	raid6_conf_t *conf = mddev_to_conf(mddev);
 	int i;
-	unsigned long flags;
 
-	spin_lock_irqsave(&conf->device_lock, flags);
+	rcu_read_lock();
 	for (i=0; i<mddev->raid_disks; i++) {
 		mdk_rdev_t *rdev = conf->disks[i].rdev;
-		if (rdev && atomic_read(&rdev->nr_pending)) {
+		if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
 			request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
 
 			atomic_inc(&rdev->nr_pending);
-			spin_unlock_irqrestore(&conf->device_lock, flags);
+			rcu_read_unlock();
 
-			if (r_queue && r_queue->unplug_fn)
+			if (r_queue->unplug_fn)
 				r_queue->unplug_fn(r_queue);
 
-			spin_lock_irqsave(&conf->device_lock, flags);
-			atomic_dec(&rdev->nr_pending);
+			rdev_dec_pending(rdev, mddev);
+			rcu_read_lock();
 		}
 	}
-	spin_unlock_irqrestore(&conf->device_lock, flags);
+	rcu_read_unlock();
 }
 
 static void raid6_unplug_device(request_queue_t *q)
@@ -1509,29 +1509,26 @@
 	raid6_conf_t *conf = mddev_to_conf(mddev);
 	int i, ret = 0;
 
-	for (i=0; i<mddev->raid_disks; i++) {
+	rcu_read_lock();
+	for (i=0; i<mddev->raid_disks && ret == 0; i++) {
 		mdk_rdev_t *rdev = conf->disks[i].rdev;
 		if (rdev && !rdev->faulty) {
 			struct block_device *bdev = rdev->bdev;
-			request_queue_t *r_queue;
+			request_queue_t *r_queue = bdev_get_queue(bdev);
 
-			if (!bdev)
-				continue;
-
-			r_queue = bdev_get_queue(bdev);
-			if (!r_queue)
-				continue;
-
-			if (!r_queue->issue_flush_fn) {
+			if (!r_queue->issue_flush_fn)
 				ret = -EOPNOTSUPP;
-				break;
+			else {
+				atomic_inc(&rdev->nr_pending);
+				rcu_read_unlock();
+				ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk,
+							      error_sector);
+				rdev_dec_pending(rdev, mddev);
+				rcu_read_lock();
 			}
-
-			ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector);
-			if (ret)
-				break;
 		}
 	}
+	rcu_read_unlock();
 	return ret;
 }
 
@@ -1573,7 +1570,7 @@
 		new_sector = raid6_compute_sector(logical_sector,
 						  raid_disks, data_disks, &dd_idx, &pd_idx, conf);
 
-		PRINTK("raid6: make_request, sector %Lu logical %Lu\n",
+		PRINTK("raid6: make_request, sector %llu logical %llu\n",
 		       (unsigned long long)new_sector,
 		       (unsigned long long)logical_sector);
 
@@ -1881,6 +1878,7 @@
 	mddev->thread = NULL;
 	shrink_stripes(conf);
 	free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER);
+	blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
 	kfree(conf);
 	mddev->private = NULL;
 	return 0;
@@ -1968,7 +1966,6 @@
 	raid6_conf_t *conf = mddev->private;
 	struct disk_info *tmp;
 
-	spin_lock_irq(&conf->device_lock);
 	for (i = 0; i < conf->raid_disks; i++) {
 		tmp = conf->disks + i;
 		if (tmp->rdev
@@ -1980,7 +1977,6 @@
 			tmp->rdev->in_sync = 1;
 		}
 	}
-	spin_unlock_irq(&conf->device_lock);
 	print_raid6_conf(conf);
 	return 0;
 }
@@ -1988,25 +1984,29 @@
 static int raid6_remove_disk(mddev_t *mddev, int number)
 {
 	raid6_conf_t *conf = mddev->private;
-	int err = 1;
+	int err = 0;
+	mdk_rdev_t *rdev;
 	struct disk_info *p = conf->disks + number;
 
 	print_raid6_conf(conf);
-	spin_lock_irq(&conf->device_lock);
-
-	if (p->rdev) {
-		if (p->rdev->in_sync ||
-		    atomic_read(&p->rdev->nr_pending)) {
+	rdev = p->rdev;
+	if (rdev) {
+		if (rdev->in_sync ||
+		    atomic_read(&rdev->nr_pending)) {
 			err = -EBUSY;
 			goto abort;
 		}
 		p->rdev = NULL;
-		err = 0;
+		synchronize_kernel();
+		if (atomic_read(&rdev->nr_pending)) {
+			/* lost the race, try later */
+			err = -EBUSY;
+			p->rdev = rdev;
+		}
 	}
-	if (err)
-		MD_BUG();
+
 abort:
-	spin_unlock_irq(&conf->device_lock);
+
 	print_raid6_conf(conf);
 	return err;
 }
@@ -2018,19 +2018,17 @@
 	int disk;
 	struct disk_info *p;
 
-	spin_lock_irq(&conf->device_lock);
 	/*
 	 * find the disk ...
 	 */
 	for (disk=0; disk < mddev->raid_disks; disk++)
 		if ((p=conf->disks + disk)->rdev == NULL) {
-			p->rdev = rdev;
 			rdev->in_sync = 0;
 			rdev->raid_disk = disk;
 			found = 1;
+			p->rdev = rdev;
 			break;
 		}
-	spin_unlock_irq(&conf->device_lock);
 	print_raid6_conf(conf);
 	return found;
 }
diff -Nru a/drivers/media/Kconfig b/drivers/media/Kconfig
--- a/drivers/media/Kconfig	2004-12-24 13:37:43 -08:00
+++ b/drivers/media/Kconfig	2004-12-24 13:37:43 -08:00
@@ -34,27 +34,18 @@
 
 config VIDEO_TUNER
 	tristate
-	default y if VIDEO_BT848=y || VIDEO_SAA7134=y || VIDEO_MXB=y || VIDEO_CX88=y
-	default m if VIDEO_BT848=m || VIDEO_SAA7134=m || VIDEO_MXB=m || VIDEO_CX88=m
-	depends on VIDEO_DEV
 
 config VIDEO_BUF
 	tristate
-	default y if VIDEO_BT848=y || VIDEO_SAA7134=y || VIDEO_SAA7146=y || VIDEO_CX88=y
-	default m if VIDEO_BT848=m || VIDEO_SAA7134=m || VIDEO_SAA7146=m || VIDEO_CX88=m
-	depends on VIDEO_DEV
+
+config VIDEO_BUF_DVB
+	tristate
 
 config VIDEO_BTCX
 	tristate
-	default y if VIDEO_BT848=y || VIDEO_CX88=y
-	default m if VIDEO_BT848=m || VIDEO_CX88=m
-	depends on VIDEO_DEV
 
 config VIDEO_IR
 	tristate
-	default y if VIDEO_BT848=y || VIDEO_SAA7134=y
-	default m if VIDEO_BT848=m || VIDEO_SAA7134=m
-	depends on VIDEO_DEV
 
 endmenu
 
diff -Nru a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
--- a/drivers/media/common/ir-common.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/media/common/ir-common.c	2004-12-24 13:37:02 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: ir-common.c,v 1.5 2004/11/07 13:17:15 kraxel Exp $
+ *
  * some common structs and functions to handle infrared remotes via
  * input layer ...
  *
@@ -29,11 +31,11 @@
 MODULE_LICENSE("GPL");
 
 static int repeat = 1;
-MODULE_PARM(repeat,"i");
+module_param(repeat, int, 0444);
 MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)");
 
 static int debug = 0;    /* debug level (0,1,2) */
-MODULE_PARM(debug,"i");
+module_param(debug, int, 0644);
 
 #define dprintk(level, fmt, arg...)	if (debug >= level) \
 	printk(KERN_DEBUG fmt , ## arg)
@@ -100,7 +102,7 @@
 	[ 0x2a ] = KEY_RESERVED,        // timed page/channel clck
 	[ 0x2b ] = KEY_RESERVED,        // increment (USA)
 	[ 0x2c ] = KEY_RESERVED,        // decrement (USA)
-	[ 0x2d ] = KEY_RESERVED,        // 
+	[ 0x2d ] = KEY_RESERVED,        //
 	[ 0x2f ] = KEY_RESERVED,        // PIP shift
 	[ 0x31 ] = KEY_RESERVED,        // erase
 	[ 0x34 ] = KEY_RESERVED,        // wind
@@ -141,7 +143,7 @@
 		   int ir_type, IR_KEYTAB_TYPE *ir_codes)
 {
 	int i;
-	
+
 	ir->ir_type = ir_type;
 	if (ir_codes)
 		memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes));
@@ -171,7 +173,7 @@
 		      u32 ir_key, u32 ir_raw)
 {
 	u32 keycode = IR_KEYCODE(ir->ir_codes, ir_key);
-	
+
 	if (ir->keypressed && ir->keycode != keycode) {
 		ir->keypressed = 0;
 		ir_input_key_event(dev,ir);
diff -Nru a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
--- a/drivers/media/common/saa7146_core.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/media/common/saa7146_core.c	2004-12-24 13:37:03 -08:00
@@ -25,11 +25,11 @@
 struct semaphore saa7146_devices_lock;
 
 static int initialized = 0;
-int saa7146_num = 0;
+static int saa7146_num = 0;
 
 unsigned int saa7146_debug = 0;
 
-MODULE_PARM(saa7146_debug,"i");
+module_param(saa7146_debug, int, 0644);
 MODULE_PARM_DESC(saa7146_debug, "debug level (default: 0)");
 
 #if 0
@@ -48,7 +48,7 @@
  * gpio and debi helper functions
  ****************************************************************************/
 
-/* write "data" to the gpio-pin "pin" */
+/* write "data" to the gpio-pin "pin" -- unused */
 void saa7146_set_gpio(struct saa7146_dev *dev, u8 pin, u8 data)
 {
 	u32 value = 0;
@@ -67,7 +67,7 @@
 }
 
 /* This DEBI code is based on the saa7146 Stradis driver by Nathan Laredo */
-int saa7146_wait_for_debi_done(struct saa7146_dev *dev)
+int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop)
 {
 	unsigned long start;
 
@@ -80,6 +80,8 @@
 			DEB_S(("timed out while waiting for registers getting programmed\n"));
 			return -ETIMEDOUT;
 		}
+		if (nobusyloop)
+			msleep(1);
 	}
 
 	/* wait for transfer to complete */
@@ -92,6 +94,8 @@
 			DEB_S(("timed out while waiting for transfer completion\n"));
 			return -ETIMEDOUT;
 		}
+		if (nobusyloop)
+			msleep(1);
 	}
 
 	return 0;
@@ -133,8 +137,6 @@
 /********************************************************************************/
 /* common page table functions */
 
-#define SAA7146_PGTABLE_SIZE 4096
-
 char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa7146_pgtable *pt)
 {
 	int pages = (length+PAGE_SIZE-1)/PAGE_SIZE;
@@ -182,11 +184,11 @@
         u32          *cpu;
         dma_addr_t   dma_addr;
 
-	cpu = pci_alloc_consistent(pci, SAA7146_PGTABLE_SIZE, &dma_addr);
+	cpu = pci_alloc_consistent(pci, PAGE_SIZE, &dma_addr);
 	if (NULL == cpu) {
 		return -ENOMEM;
 	}
-	pt->size = SAA7146_PGTABLE_SIZE;
+	pt->size = PAGE_SIZE;
 	pt->cpu  = cpu;
 	pt->dma  = dma_addr;
 
@@ -201,11 +203,7 @@
 	int   i,p;
 
 	BUG_ON( 0 == sglen);
-
-	if (list->offset > PAGE_SIZE) {
-		DEB_D(("offset > PAGE_SIZE. this should not happen."));
-		return -EINVAL;
-	}
+	BUG_ON(list->offset > PAGE_SIZE);
 	
 	/* if we have a user buffer, the first page may not be
 	   aligned to a page boundary. */
@@ -217,7 +215,7 @@
 		printk("i:%d, adr:0x%08x, len:%d, offset:%d\n", i,sg_dma_address(list), sg_dma_len(list), list->offset);
 */
 		for (p = 0; p * 4096 < list->length; p++, ptr++) {
-			*ptr = sg_dma_address(list) + p * 4096;
+			*ptr = cpu_to_le32(sg_dma_address(list) + p * 4096);
 			nr_pages++;
 		}
 	}
@@ -254,10 +252,9 @@
 
 /********************************************************************************/
 /* interrupt handler */
-
 static irqreturn_t interrupt_hw(int irq, void *dev_id, struct pt_regs *regs)
 {
-	struct saa7146_dev *dev = (struct saa7146_dev*)dev_id;
+	struct saa7146_dev *dev = dev_id;
 	u32 isr = 0;
 
 	/* read out the interrupt status register */
@@ -295,7 +292,7 @@
 	if (0 != (isr & (MASK_16|MASK_17))) {
 		u32 status = saa7146_read(dev, I2C_STATUS);
 		if( (0x3 == (status & 0x3)) || (0 == (status & 0x1)) ) {
-			IER_DISABLE(dev, MASK_16|MASK_17);
+			SAA7146_IER_DISABLE(dev, MASK_16|MASK_17);
 			/* only wake up if we expect something */
 			if( 0 != dev->i2c_op ) {
 				u32 psr = (saa7146_read(dev, PSR) >> 16) & 0x2;
@@ -314,7 +311,7 @@
 	if( 0 != isr ) {
 		ERR(("warning: interrupt enabled, but not handled properly.(0x%08x)\n",isr));
 		ERR(("disabling interrupt source(s)!\n"));
-		IER_DISABLE(dev,isr);
+		SAA7146_IER_DISABLE(dev,isr);
 	}
 	return IRQ_HANDLED;
 }
@@ -324,16 +321,15 @@
 
 static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent)
 {
-	unsigned long adr = 0, len = 0;
-	struct saa7146_dev* dev = kmalloc (sizeof(struct saa7146_dev),GFP_KERNEL);
-	
 	struct saa7146_pci_extension_data *pci_ext = (struct saa7146_pci_extension_data *)ent->driver_data;
 	struct saa7146_extension* ext = pci_ext->ext;
-	int err = 0;
+	struct saa7146_dev *dev;
+	int err = -ENOMEM;
 	
-	if (!(dev = kmalloc (sizeof(struct saa7146_dev),GFP_KERNEL))) {
+	dev = kmalloc(sizeof(struct saa7146_dev), GFP_KERNEL);
+	if (!dev) {
 		ERR(("out of memory.\n"));
-		return -ENOMEM;
+		goto out;
 	}
 
 	/* clear out mem for sure */
@@ -341,38 +337,37 @@
 
 	DEB_EE(("pci:%p\n",pci));
 
-	if (pci_enable_device(pci)) {
+	err = pci_enable_device(pci);
+	if (err < 0) {
 		ERR(("pci_enable_device() failed.\n"));
-		err = -EIO;
-		goto pci_error;
+		goto err_free;
 	}
 
 	/* enable bus-mastering */
 	pci_set_master(pci);
 
 	dev->pci = pci;
+
 	/* get chip-revision; this is needed to enable bug-fixes */
-	if( 0 > pci_read_config_dword(dev->pci, PCI_CLASS_REVISION, &dev->revision)) {
+	err = pci_read_config_dword(pci, PCI_CLASS_REVISION, &dev->revision);
+	if (err < 0) {
 		ERR(("pci_read_config_dword() failed.\n"));
-		err = -ENODEV;
-		goto pci_error;
+		goto err_disable;
 	}
 	dev->revision &= 0xf;
 
 	/* remap the memory from virtual to physical adress */
-	adr = pci_resource_start(pci,0);
-	len = pci_resource_len(pci,0);
 
-	if (!request_mem_region(pci_resource_start(pci,0), pci_resource_len(pci,0), "saa7146")) {
-		ERR(("request_mem_region() failed.\n"));
-		err = -ENODEV;
-		goto pci_error;
-	}
-
-	if (!(dev->mem = ioremap(adr,len))) {
+	err = pci_request_region(pci, 0, "saa7146");
+	if (err < 0)
+		goto err_disable;
+
+	dev->mem = ioremap(pci_resource_start(pci, 0),
+			   pci_resource_len(pci, 0));
+	if (!dev->mem) {
 		ERR(("ioremap() failed.\n"));
 		err = -ENODEV;
-		goto ioremap_error;
+		goto err_release;
 	}
 
 	/* we don't do a master reset here anymore, it screws up
@@ -392,42 +387,40 @@
 	saa7146_write(dev, MC2, 0xf8000000);
 
 	/* request an interrupt for the saa7146 */
-	if (request_irq(dev->pci->irq, interrupt_hw, SA_SHIRQ | SA_INTERRUPT,
-			dev->name, dev))
-	{
+	err = request_irq(pci->irq, interrupt_hw, SA_SHIRQ | SA_INTERRUPT,
+			  dev->name, dev);
+	if (err < 0) {
 		ERR(("request_irq() failed.\n"));
-		err = -ENODEV;
-		goto irq_error;
+		goto err_unmap;
 	}
 
-	/* get memory for various stuff */
-	dev->d_rps0.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_rps0.dma_handle);	
-	if( NULL == dev->d_rps0.cpu_addr ) {
 		err = -ENOMEM;
-		goto kmalloc_error_1;
-	}
+
+	/* get memory for various stuff */
+	dev->d_rps0.cpu_addr = pci_alloc_consistent(pci, SAA7146_RPS_MEM,
+						    &dev->d_rps0.dma_handle);
+	if (!dev->d_rps0.cpu_addr)
+		goto err_free_irq;
 	memset(dev->d_rps0.cpu_addr, 0x0, SAA7146_RPS_MEM);
 
-	dev->d_rps1.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_rps1.dma_handle);	
-	if( NULL == dev->d_rps1.cpu_addr ) {
-		err = -ENOMEM;
-		goto kmalloc_error_2;
-	}
+	dev->d_rps1.cpu_addr = pci_alloc_consistent(pci, SAA7146_RPS_MEM,
+						    &dev->d_rps1.dma_handle);
+	if (!dev->d_rps1.cpu_addr)
+		goto err_free_rps0;
 	memset(dev->d_rps1.cpu_addr, 0x0, SAA7146_RPS_MEM);
 
-	dev->d_i2c.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_RPS_MEM, &dev->d_i2c.dma_handle);	
-	if( NULL == dev->d_i2c.cpu_addr ) {
-		err = -ENOMEM;
-		goto kmalloc_error_3;
-	}
+	dev->d_i2c.cpu_addr = pci_alloc_consistent(pci, SAA7146_RPS_MEM,
+						   &dev->d_i2c.dma_handle);
+	if (!dev->d_i2c.cpu_addr)
+		goto err_free_rps1;
 	memset(dev->d_i2c.cpu_addr, 0x0, SAA7146_RPS_MEM);
 
 	/* the rest + print status message */
 
 	/* create a nice device name */
-	sprintf(&dev->name[0], "saa7146 (%d)",saa7146_num);
+	sprintf(dev->name, "saa7146 (%d)", saa7146_num);
 
-	INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision,dev->pci->irq,dev->pci->subsystem_vendor,dev->pci->subsystem_device));
+	INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device));
 	dev->ext = ext;
 
 	pci_set_drvdata(pci,dev);
@@ -444,18 +437,18 @@
 	/* set some sane pci arbitrition values */
 	saa7146_write(dev, PCI_BT_V1, 0x1c00101f); 
 
-	if( 0 != ext->probe) {
-		if( 0 != ext->probe(dev) ) {
-			DEB_D(("ext->probe() failed for %p. skipping device.\n",dev));
+	/* TODO: use the status code of the callback */
+
 			err = -ENODEV;
-			goto probe_error;
-		}
+
+	if (ext->probe && ext->probe(dev)) {
+		DEB_D(("ext->probe() failed for %p. skipping device.\n",dev));
+		goto err_free_i2c;
 	}
 
-	if( 0 != ext->attach(dev,pci_ext) ) {
+	if (ext->attach(dev, pci_ext)) {
 		DEB_D(("ext->attach() failed for %p. skipping device.\n",dev));
-			err = -ENODEV;
-			goto attach_error;
+		goto err_unprobe;
 	}
 
 	INIT_LIST_HEAD(&dev->item);
@@ -463,30 +456,46 @@
 	saa7146_num++;
 
 	err = 0;
-	goto out;
-attach_error:
-probe_error:
+out:
+	return err;
+
+err_unprobe:
 	pci_set_drvdata(pci,NULL);
-	pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr, dev->d_i2c.dma_handle);
-kmalloc_error_3:
-	pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps1.cpu_addr, dev->d_rps1.dma_handle);
-kmalloc_error_2:
-	pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps0.cpu_addr, dev->d_rps0.dma_handle);
-kmalloc_error_1:
-	free_irq(dev->pci->irq, (void *)dev);
-irq_error:
+err_free_i2c:
+	pci_free_consistent(pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr,
+			    dev->d_i2c.dma_handle);
+err_free_rps1:
+	pci_free_consistent(pci, SAA7146_RPS_MEM, dev->d_rps1.cpu_addr,
+			    dev->d_rps1.dma_handle);
+err_free_rps0:
+	pci_free_consistent(pci, SAA7146_RPS_MEM, dev->d_rps0.cpu_addr,
+			    dev->d_rps0.dma_handle);
+err_free_irq:
+	free_irq(pci->irq, (void *)dev);
+err_unmap:
 	iounmap(dev->mem);
-ioremap_error:
-        release_mem_region(adr,len);
-pci_error:
+err_release:
+	pci_release_region(pci, 0);
+err_disable:
+	pci_disable_device(pci);
+err_free:
 	kfree(dev);
-out:
-	return err;
+	goto out;
 }
 
 static void saa7146_remove_one(struct pci_dev *pdev)
 {
-	struct saa7146_dev* dev = (struct saa7146_dev*) pci_get_drvdata(pdev);
+	struct saa7146_dev* dev = pci_get_drvdata(pdev);
+	struct {
+		void *addr;
+		dma_addr_t dma;
+	} dev_map[] = {
+		{ dev->d_i2c.cpu_addr, dev->d_i2c.dma_handle },
+		{ dev->d_rps1.cpu_addr, dev->d_rps1.dma_handle },
+		{ dev->d_rps0.cpu_addr, dev->d_rps0.dma_handle },
+		{ NULL, 0 }
+	}, *p;
+
 	DEB_EE(("dev:%p\n",dev));
 
 	dev->ext->detach(dev);
@@ -497,17 +506,15 @@
 	/* disable all irqs, release irq-routine */
 	saa7146_write(dev, IER, 0);
 
-	free_irq(dev->pci->irq, (void *)dev);
+	free_irq(pdev->irq, dev);
 
-	/* free kernel memory */
-	pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr, dev->d_i2c.dma_handle);
-	pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps1.cpu_addr, dev->d_rps1.dma_handle);
-	pci_free_consistent(dev->pci, SAA7146_RPS_MEM, dev->d_rps0.cpu_addr, dev->d_rps0.dma_handle);
+	for (p = dev_map; p->addr; p++)
+		pci_free_consistent(pdev, SAA7146_RPS_MEM, p->addr, p->dma);
 
 	iounmap(dev->mem);
-	release_mem_region(pci_resource_start(dev->pci,0), pci_resource_len(dev->pci,0));
-
+	pci_release_region(pdev, 0);
 	list_del(&dev->item);
+	pci_disable_device(pdev);
 	kfree(dev);
 
 	saa7146_num--;
diff -Nru a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
--- a/drivers/media/common/saa7146_fops.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/media/common/saa7146_fops.c	2004-12-24 13:36:55 -08:00
@@ -1,4 +1,5 @@
 #include <media/saa7146_vv.h>
+#include <linux/version.h>
 
 #define BOARD_CAN_DO_VBI(dev)   (dev->revision != 0 && dev->vv_data->vbi_minor != -1) 
 
@@ -32,17 +33,6 @@
 	return 1;
 }
 
-int saa7146_res_check(struct saa7146_fh *fh, unsigned int bit)
-{
-	return (fh->resources & bit);
-}
-
-int saa7146_res_locked(struct saa7146_dev *dev, unsigned int bit)
-{
-	struct saa7146_vv *vv = dev->vv_data;
-	return (vv->resources & bit);
-}
-
 void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
 {
 	struct saa7146_dev *dev = fh->dev;
@@ -88,10 +78,7 @@
 #endif
 	DEB_EE(("dev:%p, dmaq:%p, buf:%p\n", dev, q, buf));
 
-	if( NULL == q ) {
-		ERR(("internal error: fatal NULL pointer for q.\n"));
-		return 0;
-	}
+	BUG_ON(!q);
 
 	if (NULL == q->curr) {
 		q->curr = buf;
@@ -112,14 +99,11 @@
 #ifdef DEBUG_SPINLOCKS
 	BUG_ON(!spin_is_locked(&dev->slock));
 #endif
-	if( NULL == q->curr ) {
-		ERR(("internal error: fatal NULL pointer for q->curr.\n"));
-		return;
-	}
-
 	DEB_EE(("dev:%p, dmaq:%p, state:%d\n", dev, q, state));
 	DEB_EE(("q->curr:%p\n",q->curr));
 
+	BUG_ON(!q->curr);
+
 	/* finish current buffer */
 	if (NULL == q->curr) {
 		DEB_D(("aiii. no current buffer\n"));
@@ -138,10 +122,7 @@
 {
 	struct saa7146_buf *buf,*next = NULL;
 
-	if( NULL == q ) {
-		ERR(("internal error: fatal NULL pointer for q.\n"));
-		return;
-	}
+	BUG_ON(!q);
 
 	DEB_INT(("dev:%p, dmaq:%p, vbi:%d\n", dev, q, vbi));
 
@@ -358,7 +339,7 @@
 		BUG();
 		return 0;
 	}
-	return videobuf_mmap_mapper(vma,q);
+	return videobuf_mmap_mapper(q,vma);
 }
 
 static unsigned int fops_poll(struct file *file, struct poll_table_struct *wait)
@@ -515,45 +496,58 @@
 	return 0;
 }
 
-int saa7146_register_device(struct video_device *vid, struct saa7146_dev* dev, char *name, int type)
+int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
+			    char *name, int type)
 {
 	struct saa7146_vv *vv = dev->vv_data;
+	struct video_device *vfd;
 
 	DEB_EE(("dev:%p, name:'%s', type:%d\n",dev,name,type));
  
- 	*vid = device_template;
-	strlcpy(vid->name, name, sizeof(vid->name));
-	vid->priv = dev;
+	// released by vfd->release
+ 	vfd = video_device_alloc();
+	if (vfd == NULL)
+		return -ENOMEM;
+
+	memcpy(vfd, &device_template, sizeof(struct video_device));
+	strlcpy(vfd->name, name, sizeof(vfd->name));
+	vfd->release = video_device_release;
+	vfd->priv = dev;
 
 	// fixme: -1 should be an insmod parameter *for the extension* (like "video_nr");
-	if (video_register_device(vid,type,-1) < 0) {
+	if (video_register_device(vfd, type, -1) < 0) {
 		ERR(("cannot register v4l2 device. skipping.\n"));
 		return -1;
 	}
 
 	if( VFL_TYPE_GRABBER == type ) {
-		vv->video_minor = vid->minor;
-		INFO(("%s: registered device video%d [v4l2]\n", dev->name,vid->minor & 0x1f));
+		vv->video_minor = vfd->minor;
+		INFO(("%s: registered device video%d [v4l2]\n",
+			dev->name, vfd->minor & 0x1f));
 	} else {
-		vv->vbi_minor = vid->minor;
-		INFO(("%s: registered device vbi%d [v4l2]\n", dev->name,vid->minor & 0x1f));
+		vv->vbi_minor = vfd->minor;
+		INFO(("%s: registered device vbi%d [v4l2]\n",
+			dev->name, vfd->minor & 0x1f));
 	}
 
+	*vid = vfd;
 	return 0;
 }
 
-int saa7146_unregister_device(struct video_device *vid, struct saa7146_dev* dev)
+int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev)
 {
 	struct saa7146_vv *vv = dev->vv_data;
 	
 	DEB_EE(("dev:%p\n",dev));
 
-	if( VFL_TYPE_GRABBER == vid->type ) {
+	if( VFL_TYPE_GRABBER == (*vid)->type ) {
 		vv->video_minor = -1;
 	} else {
 		vv->vbi_minor = -1;
 	}
-	video_unregister_device(vid);
+
+	video_unregister_device(*vid);
+	*vid = NULL;
 
 	return 0;
 }
diff -Nru a/drivers/media/common/saa7146_hlp.c b/drivers/media/common/saa7146_hlp.c
--- a/drivers/media/common/saa7146_hlp.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/media/common/saa7146_hlp.c	2004-12-24 13:37:00 -08:00
@@ -9,11 +9,6 @@
 	*clip_format |=  (( ((palette&0xf00)>>8) << 30) | ((palette&0x00f) << 24) | (((palette&0x0f0)>>4) << 16));
 }
 
-static void calculate_bcs_ctrl_register(struct saa7146_dev *dev, int brightness, int contrast, int colour, u32 *bcs_ctrl)
-{
-	*bcs_ctrl = ((brightness << 24) | (contrast << 16) | (colour <<  0));
-}
-
 static void calculate_hps_source_and_sync(struct saa7146_dev *dev, int source, int sync, u32* hps_ctrl)
 {
 	*hps_ctrl &= ~(MASK_30 | MASK_31 | MASK_28);
@@ -62,7 +57,7 @@
 };
 
 /* table of attenuation values for horizontal scaling */
-u8 h_attenuation[] = { 1, 2, 4, 8, 2, 4, 8, 16, 0};
+static u8 h_attenuation[] = { 1, 2, 4, 8, 2, 4, 8, 16, 0};
 
 /* calculate horizontal scale registers */
 static int calculate_h_scale_registers(struct saa7146_dev *dev,
@@ -208,7 +203,7 @@
 };
 
 /* table of attenuation values for vertical scaling */
-u16 v_attenuation[] = { 2, 4, 8, 16, 32, 64, 128, 256, 0};
+static u16 v_attenuation[] = { 2, 4, 8, 16, 32, 64, 128, 256, 0};
 
 /* calculate vertical scale registers */
 static int calculate_v_scale_registers(struct saa7146_dev *dev, enum v4l2_field field,
@@ -413,10 +408,10 @@
 
 	/* fill up cliptable */
 	for(i = 0; i < cnt_pixel; i++) {
-		clipping[2*i] |= (pixel_list[i] << 16);
+		clipping[2*i] |= cpu_to_le32(pixel_list[i] << 16);
 	}
 	for(i = 0; i < cnt_line; i++) {
-		clipping[(2*i)+1] |= (line_list[i] << 16);
+		clipping[(2*i)+1] |= cpu_to_le32(line_list[i] << 16);
 	}
 
 	/* fill up cliptable with the display infos */
@@ -430,7 +425,7 @@
 			if( pixel_list[i] < (x[j] + w[j])) {
 			
 				if ( pixel_list[i] >= x[j] ) {
-					clipping[2*i] |= (1 << j);			
+					clipping[2*i] |= cpu_to_le32(1 << j);
 				}
 			}
 		}
@@ -442,7 +437,7 @@
 			if( line_list[i] < (y[j] + h[j]) ) {
 
 				if( line_list[i] >= y[j] ) {
-					clipping[(2*i)+1] |= (1 << j);			
+					clipping[(2*i)+1] |= cpu_to_le32(1 << j);
 				}
 			}
 		}
@@ -560,9 +555,10 @@
 }
 
 /* calculate the new memory offsets for a desired position */
-static void saa7146_set_position(struct saa7146_dev *dev, int w_x, int w_y, int w_height, enum v4l2_field field)
+static void saa7146_set_position(struct saa7146_dev *dev, int w_x, int w_y, int w_height, enum v4l2_field field, u32 pixelformat)
 {	
 	struct saa7146_vv *vv = dev->vv_data;
+	struct saa7146_format *sfmt = format_by_fourcc(dev, pixelformat);
 
 	int b_depth = vv->ov_fmt->depth;
 	int b_bpl = vv->ov_fb.fmt.bytesperline;
@@ -601,7 +597,7 @@
 		vdma1.pitch *= -1;
 	}
 		
-	vdma1.base_page = 0;
+	vdma1.base_page = sfmt->swap;
 	vdma1.num_line_byte = (vv->standard->v_field<<16)+vv->standard->h_pixels;
 
 	saa7146_write_out_dma(dev, 1, &vdma1);
@@ -619,18 +615,6 @@
       	saa7146_write(dev, MC2, (MASK_05 | MASK_21));
 }
 
-void saa7146_set_picture_prop(struct saa7146_dev *dev, int brightness, int contrast, int colour)
-{
-	u32	bcs_ctrl = 0;
-	
-	calculate_bcs_ctrl_register(dev, brightness, contrast, colour, &bcs_ctrl);
-	saa7146_write(dev, BCS_CTRL, bcs_ctrl);
-	
-	/* update the bcs register */
-      	saa7146_write(dev, MC2, (MASK_06 | MASK_22));
-}
-
-
 /* select input-source */
 void saa7146_set_hps_source_and_sync(struct saa7146_dev *dev, int source, int sync)
 {
@@ -657,7 +641,7 @@
 	struct saa7146_vv *vv = dev->vv_data;
 
 	saa7146_set_window(dev, fh->ov.win.w.width, fh->ov.win.w.height, fh->ov.win.field);
-	saa7146_set_position(dev, fh->ov.win.w.left, fh->ov.win.w.top, fh->ov.win.w.height, fh->ov.win.field);
+	saa7146_set_position(dev, fh->ov.win.w.left, fh->ov.win.w.top, fh->ov.win.w.height, fh->ov.win.field, vv->ov_fmt->pixelformat);
 	saa7146_set_output_format(dev, vv->ov_fmt->trans);
 	saa7146_set_clipping_rect(fh);
 
@@ -727,7 +711,7 @@
 	vdma1.pitch		= (width*depth*2)/8;
 	}
 	vdma1.num_line_byte	= ((vv->standard->v_field<<16) + vv->standard->h_pixels);
-	vdma1.base_page		= buf->pt[0].dma | ME1;
+	vdma1.base_page		= buf->pt[0].dma | ME1 | sfmt->swap;
 	
 	if( 0 != vv->vflip ) {
 		vdma1.prot_addr	= buf->pt[0].offset;
diff -Nru a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c
--- a/drivers/media/common/saa7146_i2c.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/media/common/saa7146_i2c.c	2004-12-24 13:37:29 -08:00
@@ -1,7 +1,7 @@
 #include <linux/version.h>
 #include <media/saa7146_vv.h>
 
-u32 saa7146_i2c_func(struct i2c_adapter *adapter)
+static u32 saa7146_i2c_func(struct i2c_adapter *adapter)
 {
 //fm	DEB_I2C(("'%s'.\n", adapter->name));
 
@@ -190,7 +190,7 @@
 		saa7146_write(dev, I2C_TRANSFER, *dword);
 
 		dev->i2c_op = 1;
-		IER_ENABLE(dev, MASK_16|MASK_17);
+		SAA7146_IER_ENABLE(dev, MASK_16|MASK_17);
 		saa7146_write(dev, MC2, (MASK_00 | MASK_16));
 
 		wait_event_interruptible(dev->i2c_wq, dev->i2c_op == 0);
@@ -393,7 +393,7 @@
 	.functionality	= saa7146_i2c_func,
 };
 
-int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, unsigned int class, u32 bitrate)
+int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate)
 {
 	DEB_EE(("bitrate: 0x%08x\n",bitrate));
 	
@@ -404,13 +404,11 @@
 	saa7146_i2c_reset(dev);
 
 	if( NULL != i2c_adapter ) {
-		memset(i2c_adapter,0,sizeof(struct i2c_adapter));
-		strcpy(i2c_adapter->name, dev->name);	
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
 		i2c_adapter->data = dev;
 #else
+		BUG_ON(!i2c_adapter->class);
 		i2c_set_adapdata(i2c_adapter,dev);
-		i2c_adapter->class = class;
 #endif
 		i2c_adapter->algo	   = &saa7146_algo;
 		i2c_adapter->algo_data     = NULL;
diff -Nru a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c
--- a/drivers/media/common/saa7146_vbi.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/media/common/saa7146_vbi.c	2004-12-24 13:36:16 -08:00
@@ -91,7 +91,7 @@
 		saa7146_write(dev, MC2, MASK_04|MASK_20);
 	
 		/* enable rps1 irqs */
-		IER_ENABLE(dev,MASK_28);
+		SAA7146_IER_ENABLE(dev,MASK_28);
 
 		/* prepare to wait to be woken up by the irq-handler */
 		add_wait_queue(&vv->vbi_wq, &wait);
@@ -109,7 +109,7 @@
 		current->state = TASK_RUNNING;
 
 		/* disable rps1 irqs */
-		IER_DISABLE(dev,MASK_28);
+		SAA7146_IER_DISABLE(dev,MASK_28);
 
 		/* stop video-dma3 */
 		saa7146_write(dev, MC1, MASK_20);
@@ -130,7 +130,7 @@
 	return 0;
 }
 
-void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next)
+static void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next)
 {
 	struct saa7146_vv *vv = dev->vv_data;
 
@@ -190,7 +190,7 @@
 	WRITE_RPS1(CMD_STOP);					
 
 	/* enable rps1 irqs */
-	IER_ENABLE(dev, MASK_28);
+	SAA7146_IER_ENABLE(dev, MASK_28);
 
 	/* write the address of the rps-program */
 	saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
@@ -213,8 +213,9 @@
 	return 0;
 }
 
-static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,enum v4l2_field field)
+static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,enum v4l2_field field)
 {
+	struct file *file = q->priv_data;
 	struct saa7146_fh *fh = file->private_data;
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_buf *buf = (struct saa7146_buf *)vb;
@@ -264,7 +265,7 @@
 	return err;
 }
 
-static int buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
+static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
 {
 	int llength,lines;
 	
@@ -279,8 +280,9 @@
 	return 0;
 }
 
-static void buffer_queue(struct file *file, struct videobuf_buffer *vb)
+static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
+	struct file *file = q->priv_data;
 	struct saa7146_fh *fh = file->private_data;
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_vv *vv = dev->vv_data;
@@ -290,8 +292,9 @@
 	saa7146_buffer_queue(dev,&vv->vbi_q,buf);
 }
 
-static void buffer_release(struct file *file, struct videobuf_buffer *vb)
+static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
+	struct file *file = q->priv_data;
 	struct saa7146_fh *fh   = file->private_data;
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_buf *buf = (struct saa7146_buf *)vb;
@@ -322,7 +325,7 @@
 	saa7146_write(dev, MC1, MASK_29);
 
 	/* disable rps1 irqs */
-	IER_DISABLE(dev, MASK_28);
+	SAA7146_IER_DISABLE(dev, MASK_28);
 
 	/* shut down dma 3 transfers */
 	saa7146_write(dev, MC1, MASK_20);
@@ -331,7 +334,7 @@
 		saa7146_buffer_finish(dev,&vv->vbi_q,STATE_DONE);
 	}
 
-	videobuf_queue_cancel(file,&fh->vbi_q);
+	videobuf_queue_cancel(&fh->vbi_q);
 
 	vv->vbi_streaming = NULL;
 
@@ -404,7 +407,8 @@
 			    dev->pci, &dev->slock,
 			    V4L2_BUF_TYPE_VBI_CAPTURE,
 			    V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
-			    sizeof(struct saa7146_buf));
+			    sizeof(struct saa7146_buf),
+			    file);
 	init_MUTEX(&fh->vbi_q.lock);
 
 	init_timer(&fh->vbi_read_timeout);
@@ -480,7 +484,8 @@
 	}
 
 	mod_timer(&fh->vbi_read_timeout, jiffies+BUFFER_TIMEOUT);
-	ret = videobuf_read_stream(file, &fh->vbi_q, data, count, ppos, 1);
+	ret = videobuf_read_stream(&fh->vbi_q, data, count, ppos, 1,
+				   file->f_flags & O_NONBLOCK);
 /*
 	printk("BASE_ODD3:      0x%08x\n", saa7146_read(dev, BASE_ODD3));
 	printk("BASE_EVEN3:     0x%08x\n", saa7146_read(dev, BASE_EVEN3));
diff -Nru a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
--- a/drivers/media/common/saa7146_video.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/media/common/saa7146_video.c	2004-12-24 13:37:01 -08:00
@@ -2,7 +2,7 @@
 
 static int max_memory = 32;
 
-MODULE_PARM(max_memory,"i");
+module_param(max_memory, int, 0644);
 MODULE_PARM_DESC(max_memory, "maximum memory usage for capture buffers (default: 32Mb)");
 
 #define IS_CAPTURE_ACTIVE(fh) \
@@ -38,6 +38,13 @@
 		.depth		= 32,
 		.flags		= 0,
 	}, {
+		.name 		= "RGB-32 (R-G-B)",
+		.pixelformat	= V4L2_PIX_FMT_RGB32,
+		.trans 		= RGB32_COMPOSED,
+		.depth		= 32,
+		.flags		= 0,
+		.swap		= 0x2,
+	}, {
 		.name 		= "Greyscale-8",
 		.pixelformat	= V4L2_PIX_FMT_GREY,
 		.trans 		= Y8,
@@ -634,7 +641,7 @@
 		/* walk all pages, copy all page addresses to ptr1 */
 		for (i = 0; i < length; i++, list++) {
 			for (p = 0; p * 4096 < list->length; p++, ptr1++) {
-				*ptr1 = sg_dma_address(list) - list->offset;
+				*ptr1 = cpu_to_le32(sg_dma_address(list) - list->offset);
 			}
 		}
 /*
@@ -753,7 +760,7 @@
 	saa7146_write(dev, MC2, MASK_27 );
 
 	/* enable rps0 irqs */
-	IER_ENABLE(dev, MASK_27);
+	SAA7146_IER_ENABLE(dev, MASK_27);
 
 	vv->video_fh = fh;
 	vv->video_status = STATUS_CAPTURE;
@@ -798,7 +805,7 @@
 	saa7146_write(dev, MC1, MASK_28);
 
 	/* disable rps0 irqs */
-	IER_DISABLE(dev, MASK_27);
+	SAA7146_IER_DISABLE(dev, MASK_27);
 
 	/* shut down all used video dma transfers */
 	saa7146_write(dev, MC1, dmas);
@@ -1130,7 +1137,7 @@
 	case VIDIOC_REQBUFS: {
 		struct v4l2_requestbuffers *req = arg;
 		DEB_D(("VIDIOC_REQBUFS, type:%d\n",req->type));
-		return videobuf_reqbufs(file,q,req);
+		return videobuf_reqbufs(q,req);
 	}
 	case VIDIOC_QUERYBUF: {
 		struct v4l2_buffer *buf = arg;
@@ -1140,14 +1147,14 @@
 	case VIDIOC_QBUF: {
 		struct v4l2_buffer *buf = arg;
 		int ret = 0;
-		ret = videobuf_qbuf(file,q,buf);
+		ret = videobuf_qbuf(q,buf);
 		DEB_D(("VIDIOC_QBUF: ret:%d, index:%d\n",ret,buf->index));
 		return ret;
 	}
 	case VIDIOC_DQBUF: {
 		struct v4l2_buffer *buf = arg;
 		int ret = 0;
-		ret = videobuf_dqbuf(file,q,buf);
+		ret = videobuf_dqbuf(q,buf,file->f_flags & O_NONBLOCK);
 		DEB_D(("VIDIOC_DQBUF: ret:%d, index:%d\n",ret,buf->index));
 		return ret;
 	}
@@ -1159,7 +1166,7 @@
 		if( 0 != err) {
 				return err;
 			}
-		err = videobuf_streamon(file,q);
+		err = videobuf_streamon(q);
 		return err;
 	}
 	case VIDIOC_STREAMOFF: {
@@ -1180,7 +1187,7 @@
 			return -EBUSY;
 		}
 
-		err = videobuf_streamoff(file,q);
+		err = videobuf_streamoff(q);
 		if (0 != err) {
 			DEB_D(("warning: videobuf_streamoff() failed.\n"));
 		video_end(fh, file);
@@ -1203,7 +1210,7 @@
 
 		q = &fh->video_q;
 		down(&q->lock);
-		err = videobuf_mmap_setup(file,q,gbuffers,gbufsize,
+		err = videobuf_mmap_setup(q,gbuffers,gbufsize,
 					  V4L2_MEMORY_MMAP);
 		if (err < 0) {
 			up(&q->lock);
@@ -1240,8 +1247,10 @@
 	return 0;
 }
 
-static int buffer_prepare(struct file *file, struct videobuf_buffer *vb, enum v4l2_field field)
+static int buffer_prepare(struct videobuf_queue *q,
+			  struct videobuf_buffer *vb, enum v4l2_field field)
 {
+	struct file *file = q->priv_data;
 	struct saa7146_fh *fh = file->private_data;
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_vv *vv = dev->vv_data;
@@ -1322,8 +1331,9 @@
 	return err;
 }
 
-static int buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
+static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
 {
+	struct file *file = q->priv_data;
 	struct saa7146_fh *fh = file->private_data;
 
 	if (0 == *count || *count > MAX_SAA7146_CAPTURE_BUFFERS)
@@ -1341,8 +1351,9 @@
 	return 0;
 }
 
-static void buffer_queue(struct file *file, struct videobuf_buffer *vb)
+static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
+	struct file *file = q->priv_data;
 	struct saa7146_fh *fh = file->private_data;
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_vv *vv = dev->vv_data;
@@ -1353,8 +1364,9 @@
 }
 
 
-static void buffer_release(struct file *file, struct videobuf_buffer *vb)
+static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
+	struct file *file = q->priv_data;
 	struct saa7146_fh *fh = file->private_data;
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_buf *buf = (struct saa7146_buf *)vb;
@@ -1408,7 +1420,8 @@
 			    dev->pci, &dev->slock,
 			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
 			    V4L2_FIELD_INTERLACED,
-			    sizeof(struct saa7146_buf));
+			    sizeof(struct saa7146_buf),
+			    file);
 
 	init_MUTEX(&fh->video_q.lock);
 
@@ -1474,7 +1487,8 @@
 		goto out;
 	}
 
-	ret = videobuf_read_one(file,&fh->video_q , data, count, ppos);
+	ret = videobuf_read_one(&fh->video_q, data, count, ppos,
+				file->f_flags & O_NONBLOCK);
 	if (ret != 0) {
 	video_end(fh, file);
 	} else {
diff -Nru a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig
--- a/drivers/media/dvb/Kconfig	2004-12-24 13:36:33 -08:00
+++ b/drivers/media/dvb/Kconfig	2004-12-24 13:36:33 -08:00
@@ -12,26 +12,15 @@
 	  own a DVB adapter and want to use it or if you compile Linux for 
 	  a digital SetTopBox.
 
-	  API specs and user tools are available from
-	  <http://www.linuxtv.org/>. 
+	  API specs and user tools are available from <http://www.linuxtv.org/>.
 
 	  Please report problems regarding this driver to the LinuxDVB 
 	  mailing list.
 
-	  You might want add the following lines to your /etc/modules.conf:
-	  	
-	  	alias char-major-250 dvb
-	  	alias dvb dvb-ttpci
-	  	below dvb-ttpci alps_bsru6 alps_bsrv2 \
-	  			grundig_29504-401 grundig_29504-491 \
-	  			ves1820
-
 	  If unsure say N.
 
 source "drivers/media/dvb/dvb-core/Kconfig"
 
-source "drivers/media/dvb/frontends/Kconfig"
-
 comment "Supported SAA7146 based PCI Adapters"
 	depends on DVB_CORE && PCI
 source "drivers/media/dvb/ttpci/Kconfig"
@@ -40,6 +29,8 @@
 	depends on DVB_CORE && USB
 source "drivers/media/dvb/ttusb-budget/Kconfig"
 source "drivers/media/dvb/ttusb-dec/Kconfig"
+source "drivers/media/dvb/dibusb/Kconfig"
+source "drivers/media/dvb/cinergyT2/Kconfig"
 
 comment "Supported FlexCopII (B2C2) Adapters"
 	depends on DVB_CORE && PCI
@@ -49,5 +40,8 @@
 	depends on DVB_CORE && PCI
 source "drivers/media/dvb/bt8xx/Kconfig"
 
-endmenu
+comment "Supported DVB Frontends"
+	depends on DVB_CORE
+source "drivers/media/dvb/frontends/Kconfig"
 
+endmenu
diff -Nru a/drivers/media/dvb/Makefile b/drivers/media/dvb/Makefile
--- a/drivers/media/dvb/Makefile	2004-12-24 13:36:59 -08:00
+++ b/drivers/media/dvb/Makefile	2004-12-24 13:36:59 -08:00
@@ -2,5 +2,4 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
-obj-y        := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/
-
+obj-y        := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ dibusb/ cinergyT2/
diff -Nru a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig
--- a/drivers/media/dvb/b2c2/Kconfig	2004-12-24 13:36:59 -08:00
+++ b/drivers/media/dvb/b2c2/Kconfig	2004-12-24 13:36:59 -08:00
@@ -1,8 +1,24 @@
 config DVB_B2C2_SKYSTAR
-	tristate "Technisat Skystar2 PCI"
+	tristate "B2C2/Technisat Air/Sky/CableStar 2 PCI"
 	depends on DVB_CORE && PCI
+	select DVB_STV0299
+	select DVB_MT352
+	select DVB_MT312
 	help
 	  Support for the Skystar2 PCI DVB card by Technisat, which
 	  is equipped with the FlexCopII chipset by B2C2.
 
 	  Say Y if you own such a device and want to use it.
+
+config DVB_B2C2_USB
+	tristate "B2C2/Technisat Air/Sky/Cable2PC USB"
+	depends on DVB_CORE && USB && EXPERIMENTAL
+	select DVB_STV0299
+	select DVB_MT352
+	help
+	  Support for the Air/Sky/Cable2PC USB DVB device by B2C2. Currently
+	  this does nothing, but providing basic function for the used usb
+	  protocol.
+
+	  Say Y if you own such a device and want to use it.
+
diff -Nru a/drivers/media/dvb/b2c2/Makefile b/drivers/media/dvb/b2c2/Makefile
--- a/drivers/media/dvb/b2c2/Makefile	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/dvb/b2c2/Makefile	2004-12-24 13:36:18 -08:00
@@ -1,3 +1,6 @@
+obj-b2c2-usb = b2c2-usb-core.o b2c2-common.o
+
 obj-$(CONFIG_DVB_B2C2_SKYSTAR) += skystar2.o
+obj-$(CONFIG_DVB_B2C2_USB) + = b2c2-usb.o
 
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
+EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff -Nru a/drivers/media/dvb/b2c2/b2c2-common.c b/drivers/media/dvb/b2c2/b2c2-common.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/b2c2/b2c2-common.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,214 @@
+/*
+ * b2c2-common.c - common methods for the B2C2/Technisat SkyStar2 PCI DVB card and
+ *                 for the B2C2/Technisat Sky/Cable/AirStar USB devices
+ *                 based on the FlexCopII/FlexCopIII by B2C2, Inc.
+ *
+ * Copyright (C) 2003  Vadim Catana, skystar@moldova.cc
+ *
+ * FIX: DISEQC Tone Burst in flexcop_diseqc_ioctl()
+ * FIX: FULL soft DiSEqC for skystar2 (FlexCopII rev 130) VP310 equipped
+ *     Vincenzo Di Massa, hawk.it at tiscalinet.it
+ *
+ * Converted to Linux coding style
+ * Misc reorganization, polishing, restyling
+ *     Roberto Ragusa, r.ragusa at libero.it
+ *
+ * Added hardware filtering support,
+ *     Niklas Peinecke, peinecke at gdv.uni-hannover.de
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * 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 Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+#include "stv0299.h"
+#include "mt352.h"
+#include "mt312.h"
+
+static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
+{
+	u8 aclk = 0;
+	u8 bclk = 0;
+
+	if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
+	else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
+	else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
+	else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
+	else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
+	else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
+
+	stv0299_writereg (fe, 0x13, aclk);
+	stv0299_writereg (fe, 0x14, bclk);
+	stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg (fe, 0x20, (ratio >>  8) & 0xff);
+	stv0299_writereg (fe, 0x21, (ratio      ) & 0xf0);
+
+	return 0;
+}
+
+static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	u8 buf[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
+//	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
+
+	div = params->frequency / 125;
+
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x84;  // 0xC4
+	buf[3] = 0x08;
+
+	if (params->frequency < 1500000) buf[3] |= 0x10;
+
+//	if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+static u8 samsung_tbmu24112_inittab[] = {
+	     0x01, 0x15,
+	     0x02, 0x30,
+	     0x03, 0x00,
+	     0x04, 0x7D,
+	     0x05, 0x35,
+	     0x06, 0x02,
+	     0x07, 0x00,
+	     0x08, 0xC3,
+	     0x0C, 0x00,
+	     0x0D, 0x81,
+	     0x0E, 0x23,
+	     0x0F, 0x12,
+	     0x10, 0x7E,
+	     0x11, 0x84,
+	     0x12, 0xB9,
+	     0x13, 0x88,
+	     0x14, 0x89,
+	     0x15, 0xC9,
+	     0x16, 0x00,
+	     0x17, 0x5C,
+	     0x18, 0x00,
+	     0x19, 0x00,
+	     0x1A, 0x00,
+	     0x1C, 0x00,
+	     0x1D, 0x00,
+	     0x1E, 0x00,
+	     0x1F, 0x3A,
+	     0x20, 0x2E,
+	     0x21, 0x80,
+	     0x22, 0xFF,
+	     0x23, 0xC1,
+	     0x28, 0x00,
+	     0x29, 0x1E,
+	     0x2A, 0x14,
+	     0x2B, 0x0F,
+	     0x2C, 0x09,
+	     0x2D, 0x05,
+	     0x31, 0x1F,
+	     0x32, 0x19,
+	     0x33, 0xFE,
+	     0x34, 0x93,
+	     0xff, 0xff,
+};
+
+static struct stv0299_config samsung_tbmu24112_config = {
+	.demod_address = 0x68,
+	.inittab = samsung_tbmu24112_inittab,
+	.mclk = 88000000UL,
+	.invert = 0,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_LK,
+	.volt13_op0_op1 = STV0299_VOLT13_OP1,
+	.min_delay_ms = 100,
+	.set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
+   	.pll_set = samsung_tbmu24112_pll_set,
+};
+
+
+
+
+
+static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
+{
+	static u8 mt352_clock_config [] = { 0x89, 0x10, 0x2d };
+	static u8 mt352_reset [] = { 0x50, 0x80 };
+	static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+	static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 };
+	static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
+
+	mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
+	udelay(2000);
+	mt352_write(fe, mt352_reset, sizeof(mt352_reset));
+	mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
+
+	mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
+	mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
+
+	return 0;
+}
+
+int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
+{
+	u32 div;
+	unsigned char bs = 0;
+
+	#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
+	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
+
+	if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09;
+	if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
+	if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
+
+	pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
+	pllbuf[1] = div >> 8;
+   	pllbuf[2] = div & 0xff;
+   	pllbuf[3] = 0xcc;
+   	pllbuf[4] = bs;
+
+	return 0;
+}
+
+static struct mt352_config samsung_tdtc9251dh0_config = {
+
+	.demod_address = 0x0f,
+	.demod_init = samsung_tdtc9251dh0_demod_init,
+   	.pll_set = samsung_tdtc9251dh0_pll_set,
+};
+
+static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	u8 buf[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
+//	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
+
+	div = (params->frequency + (125/2)) / 125;
+
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = (div >> 0) & 0xff;
+	buf[2] = 0x84 | ((div >> 10) & 0x60);
+	buf[3] = 0x80;
+
+	if (params->frequency < 1550000)
+		buf[3] |= 0x02;
+
+	//if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+static struct mt312_config skystar23_samsung_tbdu18132_config = {
+
+	.demod_address = 0x0e,
+   	.pll_set = skystar23_samsung_tbdu18132_pll_set,
+};
diff -Nru a/drivers/media/dvb/b2c2/b2c2-usb-core.c b/drivers/media/dvb/b2c2/b2c2-usb-core.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/b2c2/b2c2-usb-core.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,538 @@
+/*
+ * Copyright (C) 2004 Patrick Boettcher <patrick.boettcher@desy.de>,
+ *                    Luca Bertagnolio <>,
+ *
+ * based on information provided by John Jurrius from BBTI, 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, version 2.
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/usb.h>
+#include <linux/moduleparam.h>
+#include <linux/pci.h>
+#include <linux/version.h>
+
+#include "dmxdev.h"
+#include "dvb_demux.h"
+#include "dvb_filter.h"
+#include "dvb_net.h"
+#include "dvb_frontend.h"
+
+/* debug */
+#define dprintk(level,args...) \
+	    do { if ((debug & level)) { printk(args); } } while (0)
+#define debug_dump(b,l) if (debug) {\
+	int i; deb_xfer("%s: %d > ",__FUNCTION__,l); \
+	for (i = 0; i < l; i++) deb_xfer("%02x ", b[i]); \
+	deb_xfer("\n");\
+}
+
+static int debug;
+module_param(debug, int, 0x644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2,ctrl=4 (or-able)).");
+
+#define deb_info(args...) dprintk(0x01,args)
+#define deb_ts(args...)   dprintk(0x02,args)
+#define deb_ctrl(args...) dprintk(0x04,args)
+
+/* Version information */
+#define DRIVER_VERSION "0.0"
+#define DRIVER_DESC "Driver for B2C2/Technisat Air/Cable/Sky-2-PC USB devices"
+#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
+
+/* transfer parameters */
+#define B2C2_USB_FRAMES_PER_ISO		4
+#define B2C2_USB_NUM_ISO_URB		4    /* TODO check out a good value */
+
+#define B2C2_USB_CTRL_PIPE_IN		usb_rcvctrlpipe(b2c2->udev,0)
+#define B2C2_USB_CTRL_PIPE_OUT		usb_sndctrlpipe(b2c2->udev,0)
+#define B2C2_USB_DATA_PIPE			usb_rcvisocpipe(b2c2->udev,0x81)
+
+struct usb_b2c2_usb {
+	struct usb_device *udev;
+	struct usb_interface *uintf;
+
+	u8 *iso_buffer;
+	int buffer_size;
+	dma_addr_t iso_dma_handle;
+	struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
+};
+
+
+/*
+ * USB
+ * 10 90 34 12 78 56 04 00
+ * usb_control_msg(udev, usb_sndctrlpipe(udev,0),
+ * 0x90,
+ * 0x10,
+ * 0x1234,
+ * 0x5678,
+ * buf,
+ * 4,
+ * 5*HZ);
+ *
+ * extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
+ * __u8 request,
+ * __u8 requesttype,
+ * __u16 value,
+ * __u16 index,
+ * void *data,
+ * __u16 size,
+ * int timeout);
+ *
+ */
+
+/* request types */
+typedef enum {
+	RTYPE_READ_DW         = (1 << 6),
+	RTYPE_WRITE_DW_1      = (3 << 6),
+	RTYPE_READ_V8_MEMORY  = (6 << 6),
+	RTYPE_WRITE_V8_MEMORY = (7 << 6),
+	RTYPE_WRITE_V8_FLASH  = (8 << 6),
+	RTYPE_GENERIC         = (9 << 6),
+} b2c2_usb_request_type_t;
+
+/* request */
+typedef enum {
+	B2C2_USB_WRITE_V8_MEM = 0x04,
+	B2C2_USB_READ_V8_MEM  = 0x05,
+	B2C2_USB_READ_REG     = 0x08,
+	B2C2_USB_WRITE_REG    = 0x0A,
+/*	B2C2_USB_WRITEREGLO   = 0x0A, */
+	B2C2_USB_WRITEREGHI   = 0x0B,
+	B2C2_USB_FLASH_BLOCK  = 0x10,
+	B2C2_USB_I2C_REQUEST  = 0x11,
+	B2C2_USB_UTILITY      = 0x12,
+} b2c2_usb_request_t;
+
+/* function definition for I2C_REQUEST */
+typedef enum {
+	USB_FUNC_I2C_WRITE       = 0x01,
+	USB_FUNC_I2C_MULTIWRITE  = 0x02,
+	USB_FUNC_I2C_READ        = 0x03,
+	USB_FUNC_I2C_REPEATWRITE = 0x04,
+	USB_FUNC_GET_DESCRIPTOR  = 0x05,
+	USB_FUNC_I2C_REPEATREAD  = 0x06,
+/* DKT 020208 - add this to support special case of DiSEqC */
+	USB_FUNC_I2C_CHECKWRITE  = 0x07,
+	USB_FUNC_I2C_CHECKRESULT = 0x08,
+} b2c2_usb_i2c_function_t;
+
+/*
+ * function definition for UTILITY request 0x12
+ * DKT 020304 - new utility function
+ */
+typedef enum {
+	UTILITY_SET_FILTER          = 0x01,
+	UTILITY_DATA_ENABLE         = 0x02,
+	UTILITY_FLEX_MULTIWRITE     = 0x03,
+	UTILITY_SET_BUFFER_SIZE     = 0x04,
+	UTILITY_FLEX_OPERATOR       = 0x05,
+	UTILITY_FLEX_RESET300_START = 0x06,
+	UTILITY_FLEX_RESET300_STOP  = 0x07,
+	UTILITY_FLEX_RESET300       = 0x08,
+	UTILITY_SET_ISO_SIZE        = 0x09,
+	UTILITY_DATA_RESET          = 0x0A,
+	UTILITY_GET_DATA_STATUS     = 0x10,
+	UTILITY_GET_V8_REG          = 0x11,
+/* DKT 020326 - add function for v1.14 */
+	UTILITY_SRAM_WRITE          = 0x12,
+	UTILITY_SRAM_READ           = 0x13,
+	UTILITY_SRAM_TESTFILL       = 0x14,
+	UTILITY_SRAM_TESTSET        = 0x15,
+	UTILITY_SRAM_TESTVERIFY     = 0x16,
+} b2c2_usb_utility_function_t;
+
+#define B2C2_WAIT_FOR_OPERATION_RW  1  // 1 s
+#define B2C2_WAIT_FOR_OPERATION_RDW 3  // 3 s
+#define B2C2_WAIT_FOR_OPERATION_WDW 1  // 1 s
+
+#define B2C2_WAIT_FOR_OPERATION_V8READ   3  // 3 s
+#define B2C2_WAIT_FOR_OPERATION_V8WRITE  3  // 3 s
+#define B2C2_WAIT_FOR_OPERATION_V8FLASH  3  // 3 s
+
+/* JLP 111700: we will include the 1 bit gap between the upper and lower 3 bits
+ * in the IBI address, to make the V8 code simpler.
+ * PCI ADDRESS FORMAT: 0x71C -> 0000 0111 0001 1100 (these are the six bits used)
+ *                  in general: 0000 0HHH 000L LL00
+ * IBI ADDRESS FORMAT:                    RHHH BLLL
+ *
+ * where R is the read(1)/write(0) bit, B is the busy bit
+ * and HHH and LLL are the two sets of three bits from the PCI address.
+ */
+#define B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(usPCI) (u8) (((usPCI >> 2) & 0x07) + ((usPCI >> 4) & 0x70))
+#define B2C2_FLEX_INTERNALADDR_TO_PCIOFFSET(ucAddr) (u16) (((ucAddr & 0x07) << 2) + ((ucAddr & 0x70) << 4))
+
+/*
+ * DKT 020228 - forget about this VENDOR_BUFFER_SIZE, read and write register
+ * deal with DWORD or 4 bytes, that should be should from now on
+ */
+static u32 b2c2_usb_read_dw(struct usb_b2c2_usb *b2c2, u16 wRegOffsPCI)
+{
+	u32 val;
+	u16 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI) | 0x0080;
+	int len = usb_control_msg(b2c2->udev,
+			B2C2_USB_CTRL_PIPE_IN,
+			B2C2_USB_READ_REG,
+			RTYPE_READ_DW,
+			wAddress,
+			0,
+			&val,
+			sizeof(u32),
+			B2C2_WAIT_FOR_OPERATION_RDW * HZ);
+
+	if (len != sizeof(u32)) {
+		err("error while reading dword from %d (%d).",wAddress,wRegOffsPCI);
+		return -EIO;
+	} else
+		return val;
+}
+
+/*
+ * DKT 020228 - from now on, we don't support anything older than firm 1.00
+ * I eliminated the write register as a 2 trip of writing hi word and lo word
+ * and force this to write only 4 bytes at a time.
+ * NOTE: this should work with all the firmware from 1.00 and newer
+ */
+static int b2c2_usb_write_dw(struct usb_b2c2_usb *b2c2, u16 wRegOffsPCI, u32 val)
+{
+	u16 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI);
+	int len = usb_control_msg(b2c2->udev,
+			B2C2_USB_CTRL_PIPE_OUT,
+			B2C2_USB_WRITE_REG,
+			RTYPE_WRITE_DW_1,
+			wAddress,
+			0,
+			&val,
+			sizeof(u32),
+			B2C2_WAIT_FOR_OPERATION_RDW * HZ);
+
+	if (len != sizeof(u32)) {
+		err("error while reading dword from %d (%d).",wAddress,wRegOffsPCI);
+		return -EIO;
+	} else
+		return 0;
+}
+
+/*
+ * DKT 010817 - add support for V8 memory read/write and flash update
+ */
+static int b2c2_usb_v8_memory_req(struct usb_b2c2_usb *b2c2,
+		b2c2_usb_request_t req, u8 page, u16 wAddress,
+		u16 buflen, u8 *pbBuffer)
+{
+	u8 dwRequestType;
+	u16 wIndex;
+	int nWaitTime,pipe,len;
+
+	wIndex = page << 8;
+
+	switch (req) {
+		case B2C2_USB_READ_V8_MEM:
+			nWaitTime = B2C2_WAIT_FOR_OPERATION_V8READ;
+			dwRequestType = (u8) RTYPE_READ_V8_MEMORY;
+			pipe = B2C2_USB_CTRL_PIPE_IN;
+		break;
+		case B2C2_USB_WRITE_V8_MEM:
+			wIndex |= pbBuffer[0];
+			nWaitTime = B2C2_WAIT_FOR_OPERATION_V8WRITE;
+			dwRequestType = (u8) RTYPE_WRITE_V8_MEMORY;
+			pipe = B2C2_USB_CTRL_PIPE_OUT;
+		break;
+		case B2C2_USB_FLASH_BLOCK:
+			nWaitTime = B2C2_WAIT_FOR_OPERATION_V8FLASH;
+			dwRequestType = (u8) RTYPE_WRITE_V8_FLASH;
+			pipe = B2C2_USB_CTRL_PIPE_OUT;
+		break;
+		default:
+			deb_info("unsupported request for v8_mem_req %x.\n",req);
+		return -EINVAL;
+	}
+	len = usb_control_msg(b2c2->udev,pipe,
+			req,
+			dwRequestType,
+			wAddress,
+			wIndex,
+			pbBuffer,
+			buflen,
+			nWaitTime * HZ);
+	return len == buflen ? 0 : -EIO;
+}
+
+static int b2c2_usb_i2c_req(struct usb_b2c2_usb *b2c2,
+		b2c2_usb_request_t req, b2c2_usb_i2c_function_t func,
+		u8 port, u8 chipaddr, u8 addr, u8 buflen, u8 *buf)
+{
+	u16 wValue, wIndex;
+	int nWaitTime,pipe,len;
+	u8 dwRequestType;
+
+	switch (func) {
+		case USB_FUNC_I2C_WRITE:
+		case USB_FUNC_I2C_MULTIWRITE:
+		case USB_FUNC_I2C_REPEATWRITE:
+		/* DKT 020208 - add this to support special case of DiSEqC */
+		case USB_FUNC_I2C_CHECKWRITE:
+			pipe = B2C2_USB_CTRL_PIPE_OUT;
+			nWaitTime = 2;
+			dwRequestType = (u8) RTYPE_GENERIC;
+		break;
+		case USB_FUNC_I2C_READ:
+		case USB_FUNC_I2C_REPEATREAD:
+			pipe = B2C2_USB_CTRL_PIPE_IN;
+			nWaitTime = 2;
+			dwRequestType = (u8) RTYPE_GENERIC;
+		break;
+		default:
+			deb_info("unsupported function for i2c_req %x\n",func);
+			return -EINVAL;
+	}
+	wValue = (func << 8 ) | port;
+	wIndex = (chipaddr << 8 ) | addr;
+
+	len = usb_control_msg(b2c2->udev,pipe,
+			req,
+			dwRequestType,
+			addr,
+			wIndex,
+			buf,
+			buflen,
+			nWaitTime * HZ);
+	return len == buflen ? 0 : -EIO;
+}
+
+int static b2c2_usb_utility_req(struct usb_b2c2_usb *b2c2, int set,
+		b2c2_usb_utility_function_t func, u8 extra, u16 wIndex,
+		u16 buflen, u8 *pvBuffer)
+{
+	u16 wValue;
+	int nWaitTime = 2,
+		pipe = set ? B2C2_USB_CTRL_PIPE_OUT : B2C2_USB_CTRL_PIPE_IN,
+		len;
+
+	wValue = (func << 8) | extra;
+
+	len = usb_control_msg(b2c2->udev,pipe,
+			B2C2_USB_UTILITY,
+			(u8) RTYPE_GENERIC,
+			wValue,
+			wIndex,
+			pvBuffer,
+			buflen,
+			nWaitTime * HZ);
+	return len == buflen ? 0 : -EIO;
+}
+
+
+
+static void b2c2_dumpfourreg(struct usb_b2c2_usb *b2c2, u16 offs)
+{
+	u32 r0,r1,r2,r3;
+	r0 = r1 = r2 = r3 = 0;
+	r0 = b2c2_usb_read_dw(b2c2,offs);
+	r1 = b2c2_usb_read_dw(b2c2,offs + 0x04);
+	r2 = b2c2_usb_read_dw(b2c2,offs + 0x08);
+	r3 = b2c2_usb_read_dw(b2c2,offs + 0x0c);
+	deb_ctrl("dump: offset: %03x, %08x, %08x, %08x, %08x\n",offs,r0,r1,r2,r3);
+}
+
+static void b2c2_urb_complete(struct urb *urb, struct pt_regs *ptregs)
+{
+	struct usb_b2c2_usb *b2c2 = urb->context;
+	deb_ts("urb completed, bufsize: %d\n",urb->transfer_buffer_length);
+
+//	urb_submit_urb(urb,GFP_ATOMIC); enable for real action
+}
+
+static void b2c2_exit_usb(struct usb_b2c2_usb *b2c2)
+{
+	int i;
+	for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
+		if (b2c2->iso_urb[i] != NULL) { /* not sure about unlink_urb and iso-urbs TODO */
+			deb_info("unlinking/killing urb no. %d\n",i);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,7)
+			usb_unlink_urb(b2c2->iso_urb[i]);
+#else
+			usb_kill_urb(b2c2->iso_urb[i]);
+#endif
+			usb_free_urb(b2c2->iso_urb[i]);
+		}
+
+	if (b2c2->iso_buffer != NULL)
+		pci_free_consistent(NULL,b2c2->buffer_size, b2c2->iso_buffer, b2c2->iso_dma_handle);
+
+}
+
+static int b2c2_init_usb(struct usb_b2c2_usb *b2c2)
+{
+	u16 frame_size = b2c2->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize;
+	int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size,i,j,ret;
+	int buffer_offset = 0;
+
+	deb_info("creating %d iso-urbs with %d frames each of %d bytes size = %d.\n",
+			B2C2_USB_NUM_ISO_URB, B2C2_USB_FRAMES_PER_ISO, frame_size,bufsize);
+
+	b2c2->iso_buffer = pci_alloc_consistent(NULL,bufsize,&b2c2->iso_dma_handle);
+	if (b2c2->iso_buffer == NULL)
+		return -ENOMEM;
+	memset(b2c2->iso_buffer, 0, bufsize);
+	b2c2->buffer_size = bufsize;
+
+	/* creating iso urbs */
+	for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
+		if (!(b2c2->iso_urb[i] = usb_alloc_urb(B2C2_USB_FRAMES_PER_ISO,GFP_ATOMIC))) {
+			ret = -ENOMEM;
+			goto urb_error;
+		}
+	/* initialising and submitting iso urbs */
+	for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) {
+		deb_info("initializing and submitting urb no. %d (buf_offset: %d).\n",i,buffer_offset);
+		int frame_offset = 0;
+		struct urb *urb = b2c2->iso_urb[i];
+
+		urb->dev = b2c2->udev;
+		urb->context = b2c2;
+		urb->complete = b2c2_urb_complete;
+		urb->pipe = B2C2_USB_DATA_PIPE;
+		urb->transfer_flags = URB_ISO_ASAP;
+		urb->interval = 1;
+		urb->number_of_packets = B2C2_USB_FRAMES_PER_ISO;
+		urb->transfer_buffer_length = frame_size * B2C2_USB_FRAMES_PER_ISO;
+		urb->transfer_buffer = b2c2->iso_buffer + buffer_offset;
+
+		buffer_offset += frame_size * B2C2_USB_FRAMES_PER_ISO;
+		for (j = 0; j < B2C2_USB_FRAMES_PER_ISO; j++) {
+			deb_info("urb no: %d, frame: %d, frame_offset: %d\n",i,j,frame_offset);
+			urb->iso_frame_desc[j].offset = frame_offset;
+			urb->iso_frame_desc[j].length = frame_size;
+			frame_offset += frame_size;
+		}
+
+		if ((ret = usb_submit_urb(b2c2->iso_urb[i],GFP_ATOMIC))) {
+			err("submitting urb %d failed with %d.",i,ret);
+			goto urb_error;
+		}
+		deb_info("submitted urb no. %d.\n",i);
+	}
+
+	ret = 0;
+	goto success;
+urb_error:
+	b2c2_exit_usb(b2c2);
+success:
+	return ret;
+}
+
+static int b2c2_usb_probe(struct usb_interface *intf,
+		const struct usb_device_id *id)
+{
+	struct usb_device *udev = interface_to_usbdev(intf);
+	struct usb_b2c2_usb *b2c2 = NULL;
+	int ret;
+
+	b2c2 = kmalloc(sizeof(struct usb_b2c2_usb),GFP_KERNEL);
+	if (b2c2 == NULL) {
+		err("no memory");
+		return -ENOMEM;
+	}
+	b2c2->udev = udev;
+	b2c2->uintf = intf;
+
+	/* use the alternate setting with the larges buffer */
+	usb_set_interface(udev,0,1);
+
+	if ((ret = b2c2_init_usb(b2c2)))
+		goto usb_init_error;
+
+	usb_set_intfdata(intf,b2c2);
+
+	switch (udev->speed) {
+		case USB_SPEED_LOW:
+			err("cannot handle USB speed because it is to sLOW.");
+			break;
+		case USB_SPEED_FULL:
+			info("running at FULL speed.");
+			break;
+		case USB_SPEED_HIGH:
+			info("running at HIGH speed.");
+			break;
+		case USB_SPEED_UNKNOWN: /* fall through */
+		default:
+			err("cannot handle USB speed because it is unkown.");
+		break;
+	}
+
+	b2c2_dumpfourreg(b2c2,0x200);
+	b2c2_dumpfourreg(b2c2,0x300);
+	b2c2_dumpfourreg(b2c2,0x400);
+	b2c2_dumpfourreg(b2c2,0x700);
+
+
+	if (ret == 0)
+		info("%s successfully initialized and connected.",DRIVER_DESC);
+	else
+		info("%s error while loading driver (%d)",DRIVER_DESC,ret);
+
+	ret = 0;
+	goto success;
+
+usb_init_error:
+	kfree(b2c2);
+success:
+	return ret;
+}
+
+static void b2c2_usb_disconnect(struct usb_interface *intf)
+{
+	struct usb_b2c2_usb *b2c2 = usb_get_intfdata(intf);
+	usb_set_intfdata(intf,NULL);
+	if (b2c2 != NULL) {
+		b2c2_exit_usb(b2c2);
+		kfree(b2c2);
+	}
+	info("%s successfully deinitialized and disconnected.",DRIVER_DESC);
+
+}
+
+static struct usb_device_id b2c2_usb_table [] = {
+	    { USB_DEVICE(0x0af7, 0x0101) }
+};
+
+/* usb specific object needed to register this driver with the usb subsystem */
+static struct usb_driver b2c2_usb_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "dvb_b2c2_usb",
+	.probe 		= b2c2_usb_probe,
+	.disconnect = b2c2_usb_disconnect,
+	.id_table 	= b2c2_usb_table,
+};
+
+/* module stuff */
+static int __init b2c2_usb_init(void)
+{
+	int result;
+	if ((result = usb_register(&b2c2_usb_driver))) {
+		err("usb_register failed. Error number %d",result);
+		return result;
+	}
+
+	return 0;
+}
+
+static void __exit b2c2_usb_exit(void)
+{
+	/* deregister this driver from the USB subsystem */
+	usb_deregister(&b2c2_usb_driver);
+}
+
+module_init (b2c2_usb_init);
+module_exit (b2c2_usb_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/media/dvb/b2c2/skystar2.c b/drivers/media/dvb/b2c2/skystar2.c
--- a/drivers/media/dvb/b2c2/skystar2.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/media/dvb/b2c2/skystar2.c	2004-12-24 13:37:43 -08:00
@@ -30,14 +30,16 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
+
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/version.h>
 
 #include <asm/io.h>
 
-#include "dvb_i2c.h"
 #include "dvb_frontend.h"
 
 #include <linux/dvb/frontend.h>
@@ -48,13 +50,21 @@
 #include "dvbdev.h"
 #include "demux.h"
 #include "dvb_net.h"
+#include "stv0299.h"
+#include "mt352.h"
+#include "mt312.h"
+
 
-#include "dvb_functions.h"
+static int debug;
+static int enable_hw_filters = 2;
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Set debugging level (0 = default, 1 = most messages, 2 = all messages).");
+module_param(enable_hw_filters, int, 0444);
+MODULE_PARM_DESC(enable_hw_filters, "enable hardware filters: supported values: 0 (none), 1, 2");
 
-static int debug = 0;
 #define dprintk(x...)	do { if (debug>=1) printk(x); } while (0)
 #define ddprintk(x...)	do { if (debug>=2) printk(x); } while (0)
-static int enable_hw_filters = 2;
 
 #define SIZE_OF_BUF_DMA1	0x3ac00
 #define SIZE_OF_BUF_DMA2	0x758
@@ -70,6 +80,9 @@
 	u8 *buffer;
 };
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
+#define __iomem
+#endif
 
 struct adapter {
 	struct pci_dev *pdev;
@@ -79,7 +92,7 @@
 	u32 pid_filter_max;
 	u32 mac_filter_max;
 	u32 irq;
-	unsigned long io_mem;
+	void __iomem *io_mem;
 	unsigned long io_port;
 	u8 mac_addr[8];
 	u32 dw_sram_type;
@@ -89,7 +102,7 @@
 	struct dmxdev dmxdev;
 	struct dmx_frontend hw_frontend;
 	struct dmx_frontend mem_frontend;
-	struct dvb_i2c_bus *i2c_bus;
+	struct i2c_adapter i2c_adap;
 	struct dvb_net dvbnet;
 
 	struct semaphore i2c_sem;
@@ -111,6 +124,9 @@
 	int pid_count;
 	int whole_bandwidth_count;
 	u32 mac_filter;
+
+	struct dvb_frontend* fe;
+	int (*fe_sleep)(struct dvb_frontend* fe);
 };
 
 #define write_reg_dw(adapter,reg,value) writel(value, adapter->io_mem + reg)
@@ -277,9 +293,9 @@
 	return buf - start;
 }
 
-static int master_xfer(struct dvb_i2c_bus *i2c, const struct i2c_msg *msgs, int num)
+static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg msgs[], int num)
 {
-	struct adapter *tmp = i2c->data;
+	struct adapter *tmp = i2c_get_adapdata(adapter);
 	int i, ret = 0;
 
 	if (down_interruptible(&tmp->i2c_sem))
@@ -290,13 +306,6 @@
 		for (i = 0; i < num; i++) {
 		ddprintk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
 			 msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
-	
-		/* allow only the mt312 and stv0299 frontends to access the bus */
-		if ((msgs[i].addr != 0x0e) && (msgs[i].addr != 0x68) && (msgs[i].addr != 0x61)) {
-		up(&tmp->i2c_sem);
-
-		return -EREMOTEIO;
-	}
 	}
 
 	// read command
@@ -307,10 +316,10 @@
 		up(&tmp->i2c_sem);
 
 		if (ret != msgs[1].len) {
-			printk("%s: read error !\n", __FUNCTION__);
+			dprintk("%s: read error !\n", __FUNCTION__);
 
 			for (i = 0; i < 2; i++) {
-				printk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
+				dprintk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
 				       msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
 		}
 
@@ -330,9 +339,9 @@
 		up(&tmp->i2c_sem);
 
 		if (ret != msgs[0].len - 1) {
-			printk("%s: write error %i !\n", __FUNCTION__, ret);
+			dprintk("%s: write error %i !\n", __FUNCTION__, ret);
 
-			printk("message %d: flags=0x%x, addr=0x%x, buf[0]=0x%x, len=%d \n", i,
+			dprintk("message %d: flags=0x%x, addr=0x%x, buf[0]=0x%x, len=%d \n", i,
 			       msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
 
 			return -EREMOTEIO;
@@ -778,7 +787,7 @@
 	return flex_i2c_read(adapter, 0x20000000, 0x50, addr, buf, len);
 }
 
-u8 calc_lrc(u8 *buf, int len)
+static u8 calc_lrc(u8 *buf, int len)
 {
 	int i;
 	u8 sum;
@@ -1763,11 +1772,11 @@
 
 	free_dma_queue(adapter);
 
-	if (adapter->io_mem != 0)
-		iounmap((void *) adapter->io_mem);
+	if (adapter->io_mem)
+		iounmap(adapter->io_mem);
 
 	if (adapter != 0)
-		kfree(adapter);
+	kfree(adapter);
 }
 
 static struct pci_driver skystar2_pci_driver;
@@ -1798,15 +1807,15 @@
 
 	adapter->io_port = pdev->resource[1].start;
 
-	adapter->io_mem = (unsigned long) ioremap(pdev->resource[0].start, 0x800);
+	adapter->io_mem = ioremap(pdev->resource[0].start, 0x800);
 
-	if (adapter->io_mem == 0) {
+	if (!adapter->io_mem) {
 		dprintk("%s: can not map io memory\n", __FUNCTION__);
 
 		return 2;
 	}
 
-	dprintk("%s: io memory maped at %lx\n", __FUNCTION__, adapter->io_mem);
+	dprintk("%s: io memory maped at %p\n", __FUNCTION__, adapter->io_mem);
 
 	return 1;
 }
@@ -2122,18 +2131,17 @@
 			udelay(12500);
 			set_tuner_tone(adapter, 0);
 		}
-		dvb_delay(20);
+		msleep(20);
 	}
 
 	return 0;
 }
 
-
-int soft_diseqc(struct adapter *adapter, unsigned int cmd, void *arg)
+static int flexcop_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
 {
-	switch (cmd) {
-	case FE_SET_TONE:
-		switch ((fe_sec_tone_mode_t) arg) {
+	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
+
+	switch(tone) {
 		case SEC_TONE_ON:
 			set_tuner_tone(adapter, 1);
 			break;
@@ -2143,91 +2151,312 @@
 			default:
 				return -EINVAL;
 			};
-		break;
 
-	case FE_DISEQC_SEND_MASTER_CMD:
+	return 0;
+}
+
+static int flexcop_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
 		{
-			struct dvb_diseqc_master_cmd *cmd = arg;
+	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
 
 			send_diseqc_msg(adapter, cmd->msg_len, cmd->msg, 0);
-			break;
+
+	return 0;
 		}
 
-	case FE_DISEQC_SEND_BURST:
-		send_diseqc_msg(adapter, 0, NULL, (unsigned long) arg);
-		break;
+static int flexcop_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
+{
+	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
 
-	default:
-		return -EOPNOTSUPP;
-	};
+	send_diseqc_msg(adapter, 0, NULL, minicmd);
 
 	return 0;
 }
 
-static int flexcop_diseqc_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static int flexcop_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
 		{
-	struct adapter *adapter = fe->before_after_data;
+	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
 
-	struct dvb_frontend_info info;
+	dprintk("%s: FE_SET_VOLTAGE\n", __FUNCTION__);
 
-	fe->ioctl(fe, FE_GET_INFO, &info);
-
-	// we must use different DiSEqC hw
+	switch (voltage) {
+	case SEC_VOLTAGE_13:
+		dprintk("%s: SEC_VOLTAGE_13, %x\n", __FUNCTION__, SEC_VOLTAGE_13);
+		set_tuner_polarity(adapter, 1);
+		return 0;
 
-	if (strcmp(info.name, "Zarlink MT312") == 0) {
-		//VP310 using mt312 driver for tuning only: diseqc not wired
-		//use FCII instead
-		if (!soft_diseqc(adapter, cmd, arg))
+	case SEC_VOLTAGE_18:
+		dprintk("%s: SEC_VOLTAGE_18, %x\n", __FUNCTION__, SEC_VOLTAGE_18);
+		set_tuner_polarity(adapter, 2);
 			return 0;
+
+	default:
+		return -EINVAL;
+	}
 	}
 
-	switch (cmd) {
-	case FE_SLEEP:
+static int flexcop_sleep(struct dvb_frontend* fe)
 		{
-			dprintk("%s: FE_SLEEP\n", __FUNCTION__);
+	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
 
+	dprintk("%s: FE_SLEEP\n", __FUNCTION__);
 			set_tuner_polarity(adapter, 0);
 
-			// return -EOPNOTSUPP, to make DVB core also send "FE_SLEEP" command to frontend.
-			return -EOPNOTSUPP;
+	if (adapter->fe_sleep) return adapter->fe_sleep(fe);
+	return 0;
 		}
 
-	case FE_SET_VOLTAGE:
+static u32 flexcop_i2c_func(struct i2c_adapter *adapter)
 		{
-			dprintk("%s: FE_SET_VOLTAGE\n", __FUNCTION__);
+	printk("flexcop_i2c_func\n");
+
+	return I2C_FUNC_I2C;
+}
+
+static struct i2c_algorithm    flexcop_algo = {
+	.name		= "flexcop i2c algorithm",
+	.id		= I2C_ALGO_BIT,
+	.master_xfer	= master_xfer,
+	.functionality	= flexcop_i2c_func,
+};
 
-			switch ((fe_sec_voltage_t) arg) {
-			case SEC_VOLTAGE_13:
 
-				dprintk("%s: SEC_VOLTAGE_13, %x\n", __FUNCTION__, SEC_VOLTAGE_13);
 
-				set_tuner_polarity(adapter, 1);
 
-				return 0;
+static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
+{
+	u8 aclk = 0;
+	u8 bclk = 0;
 
-			case SEC_VOLTAGE_18:
+	if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
+	else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
+	else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
+	else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
+	else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
+	else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
+
+	stv0299_writereg (fe, 0x13, aclk);
+	stv0299_writereg (fe, 0x14, bclk);
+	stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg (fe, 0x20, (ratio >>  8) & 0xff);
+	stv0299_writereg (fe, 0x21, (ratio      ) & 0xf0);
 
-				dprintk("%s: SEC_VOLTAGE_18, %x\n", __FUNCTION__, SEC_VOLTAGE_18);
+	return 0;
+}
 
-				set_tuner_polarity(adapter, 2);
+static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	u8 buf[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
+	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
 
-				return 0;
+	div = params->frequency / 125;
 
-			default:
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x84;  // 0xC4
+	buf[3] = 0x08;
 
-				return -EINVAL;
+	if (params->frequency < 1500000) buf[3] |= 0x10;
+
+	if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+static u8 samsung_tbmu24112_inittab[] = {
+	     0x01, 0x15,
+	     0x02, 0x30,
+	     0x03, 0x00,
+	     0x04, 0x7D,
+	     0x05, 0x35,
+	     0x06, 0x02,
+	     0x07, 0x00,
+	     0x08, 0xC3,
+	     0x0C, 0x00,
+	     0x0D, 0x81,
+	     0x0E, 0x23,
+	     0x0F, 0x12,
+	     0x10, 0x7E,
+	     0x11, 0x84,
+	     0x12, 0xB9,
+	     0x13, 0x88,
+	     0x14, 0x89,
+	     0x15, 0xC9,
+	     0x16, 0x00,
+	     0x17, 0x5C,
+	     0x18, 0x00,
+	     0x19, 0x00,
+	     0x1A, 0x00,
+	     0x1C, 0x00,
+	     0x1D, 0x00,
+	     0x1E, 0x00,
+	     0x1F, 0x3A,
+	     0x20, 0x2E,
+	     0x21, 0x80,
+	     0x22, 0xFF,
+	     0x23, 0xC1,
+	     0x28, 0x00,
+	     0x29, 0x1E,
+	     0x2A, 0x14,
+	     0x2B, 0x0F,
+	     0x2C, 0x09,
+	     0x2D, 0x05,
+	     0x31, 0x1F,
+	     0x32, 0x19,
+	     0x33, 0xFE,
+	     0x34, 0x93,
+	     0xff, 0xff,
 			};
-		}
 
+static struct stv0299_config samsung_tbmu24112_config = {
+	.demod_address = 0x68,
+	.inittab = samsung_tbmu24112_inittab,
+	.mclk = 88000000UL,
+	.invert = 0,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_LK,
+	.volt13_op0_op1 = STV0299_VOLT13_OP1,
+	.min_delay_ms = 100,
+	.set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
+   	.pll_set = samsung_tbmu24112_pll_set,
+};
 
-	default:
 
-		return -EOPNOTSUPP;
-	};
+
+
+
+static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
+{
+	static u8 mt352_clock_config [] = { 0x89, 0x10, 0x2d };
+	static u8 mt352_reset [] = { 0x50, 0x80 };
+	static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+	static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 };
+	static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
+
+	mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
+	udelay(2000);
+	mt352_write(fe, mt352_reset, sizeof(mt352_reset));
+	mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
+
+	mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
+	mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
+
+	return 0;
+}
+
+int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
+{
+	u32 div;
+	unsigned char bs = 0;
+
+	#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
+	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
+
+	if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09;
+	if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
+	if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
+
+	pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
+	pllbuf[1] = div >> 8;
+   	pllbuf[2] = div & 0xff;
+   	pllbuf[3] = 0xcc;
+   	pllbuf[4] = bs;
 
 	return 0;
 }
 
+static struct mt352_config samsung_tdtc9251dh0_config = {
+
+	.demod_address = 0x0f,
+	.demod_init = samsung_tdtc9251dh0_demod_init,
+   	.pll_set = samsung_tdtc9251dh0_pll_set,
+};
+
+static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	u8 buf[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
+	struct adapter* adapter = (struct adapter*) fe->dvb->priv;
+
+	div = (params->frequency + (125/2)) / 125;
+
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = (div >> 0) & 0xff;
+	buf[2] = 0x84 | ((div >> 10) & 0x60);
+	buf[3] = 0x80;
+
+	if (params->frequency < 1550000)
+		buf[3] |= 0x02;
+
+	if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+static struct mt312_config skystar23_samsung_tbdu18132_config = {
+
+	.demod_address = 0x0e,
+   	.pll_set = skystar23_samsung_tbdu18132_pll_set,
+};
+
+
+
+
+static void frontend_init(struct adapter *skystar2)
+{
+	switch(skystar2->pdev->device) {
+	case 0x2103: // Technisat Skystar2 OR Technisat Airstar2
+
+		// try the skystar2 v2.6 first (stv0299/Samsung tbmu24112(sl1935))
+		skystar2->fe = stv0299_attach(&samsung_tbmu24112_config, &skystar2->i2c_adap);
+		if (skystar2->fe != NULL) {
+			skystar2->fe->ops->set_voltage = flexcop_set_voltage;
+			skystar2->fe_sleep = skystar2->fe->ops->sleep;
+			skystar2->fe->ops->sleep = flexcop_sleep;
+			break;
+}
+
+		// try the airstar2 (mt352/Samsung tdtc9251dh0(??))
+		skystar2->fe = mt352_attach(&samsung_tdtc9251dh0_config, &skystar2->i2c_adap);
+		if (skystar2->fe != NULL) {
+			skystar2->fe->ops->info.frequency_min = 474000000;
+			skystar2->fe->ops->info.frequency_max = 858000000;
+			break;
+		}
+
+		// try the skystar2 v2.3 (vp310/Samsung tbdu18132(tsa5059))
+		skystar2->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &skystar2->i2c_adap);
+		if (skystar2->fe != NULL) {
+			skystar2->fe->ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
+			skystar2->fe->ops->diseqc_send_burst = flexcop_diseqc_send_burst;
+			skystar2->fe->ops->set_tone = flexcop_set_tone;
+			skystar2->fe->ops->set_voltage = flexcop_set_voltage;
+			skystar2->fe_sleep = skystar2->fe->ops->sleep;
+			skystar2->fe->ops->sleep = flexcop_sleep;
+			break;
+		}
+		break;
+	}
+
+	if (skystar2->fe == NULL) {
+		printk("skystar2: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
+		       skystar2->pdev->vendor,
+		       skystar2->pdev->device,
+		       skystar2->pdev->subsystem_vendor,
+		       skystar2->pdev->subsystem_device);
+	} else {
+		if (dvb_register_frontend(skystar2->dvb_adapter, skystar2->fe)) {
+			printk("skystar2: Frontend registration failed!\n");
+			if (skystar2->fe->ops->release)
+				skystar2->fe->ops->release(skystar2->fe);
+			skystar2->fe = NULL;
+		}
+	}
+}
+
+
 static int skystar2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	struct adapter *adapter;
@@ -2254,16 +2483,31 @@
 
 	adapter = (struct adapter *) pci_get_drvdata(pdev);
 
+	dvb_adapter->priv = adapter;
 	adapter->dvb_adapter = dvb_adapter;
 
+
 	init_MUTEX(&adapter->i2c_sem);
 
-	adapter->i2c_bus = dvb_register_i2c_bus(master_xfer, adapter, adapter->dvb_adapter, 0);
 
-	if (!adapter->i2c_bus)
-		return -ENOMEM;
+	memset(&adapter->i2c_adap, 0, sizeof(struct i2c_adapter));
+	strcpy(adapter->i2c_adap.name, "SkyStar2");
+
+	i2c_set_adapdata(&adapter->i2c_adap, adapter);
 
-	dvb_add_frontend_ioctls(adapter->dvb_adapter, flexcop_diseqc_ioctl, NULL, adapter);
+#ifdef I2C_ADAP_CLASS_TV_DIGITAL
+	adapter->i2c_adap.class 	    = I2C_ADAP_CLASS_TV_DIGITAL;
+#else
+	adapter->i2c_adap.class 	    = I2C_CLASS_TV_DIGITAL;
+#endif
+	adapter->i2c_adap.algo              = &flexcop_algo;
+	adapter->i2c_adap.algo_data         = NULL;
+	adapter->i2c_adap.id                = I2C_ALGO_BIT;
+
+	if (i2c_add_adapter(&adapter->i2c_adap) < 0) {
+		dvb_unregister_adapter (adapter->dvb_adapter);
+		return -ENOMEM;
+	}
 
 	dvbdemux = &adapter->demux;
 
@@ -2300,6 +2544,9 @@
 		return ret;
 
 	dvb_net_init(adapter->dvb_adapter, &adapter->dvbnet, &dvbdemux->dmx);
+
+	frontend_init(adapter);
+
 	return 0;
 }
 
@@ -2324,11 +2571,10 @@
 		dvb_dmxdev_release(&adapter->dmxdev);
 		dvb_dmx_release(&adapter->demux);
 
-		if (adapter->dvb_adapter != NULL) {
-			dvb_remove_frontend_ioctls(adapter->dvb_adapter, flexcop_diseqc_ioctl, NULL);
+		if (adapter->fe != NULL) dvb_unregister_frontend(adapter->fe);
 
-			if (adapter->i2c_bus != NULL)
-				dvb_unregister_i2c_bus(master_xfer, adapter->i2c_bus->adapter, adapter->i2c_bus->id);
+		if (adapter->dvb_adapter != NULL) {
+			i2c_del_adapter(&adapter->i2c_adap);
 
 			dvb_unregister_adapter(adapter->dvb_adapter);
 		}
@@ -2338,7 +2584,7 @@
 
 static struct pci_device_id skystar2_pci_tbl[] = {
 	{0x000013d0, 0x00002103, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000},
-	{0x000013d0, 0x00002200, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000},	//FCIII
+/*	{0x000013d0, 0x00002200, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000}, UNDEFINED HARDWARE - mail linuxtv.org list */	//FCIII
 	{0,},
 };
 
@@ -2363,11 +2609,6 @@
 
 module_init(skystar2_init);
 module_exit(skystar2_cleanup);
-
-MODULE_PARM(debug, "i");
-MODULE_PARM_DESC(debug, "enable verbose debug messages: supported values: 1 and 2");
-MODULE_PARM(enable_hw_filters, "i");
-MODULE_PARM_DESC(enable_hw_filters, "enable hardware filters: supported values: 0 (none), 1, 2");
 
 MODULE_DESCRIPTION("Technisat SkyStar2 DVB PCI Driver");
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
--- a/drivers/media/dvb/bt8xx/Kconfig	2004-12-24 13:36:48 -08:00
+++ b/drivers/media/dvb/bt8xx/Kconfig	2004-12-24 13:36:48 -08:00
@@ -1,13 +1,18 @@
 config DVB_BT8XX
-	tristate "Nebula/Pinnacle PCTV PCI cards"
+	tristate "Nebula/Pinnacle PCTV/Twinhan PCI cards"
 	depends on DVB_CORE && PCI && VIDEO_BT848
+	select DVB_MT352
+	select DVB_SP887X
 	help
 	  Support for PCI cards based on the Bt8xx PCI bridge. Examples are
-	  the Nebula cards, the Pinnacle PCTV cards, and Twinhan DST cards.
+	  the Nebula cards, the Pinnacle PCTV cards and Twinhan DST cards.
 
           Since these cards have no MPEG decoder onboard, they transmit
 	  only compressed MPEG data over the PCI bus, so you need
 	  an external software decoder to watch TV on your computer.
+
+	  If you have a Twinhan card, don't forget to select
+	  "Twinhan DST based DVB-S/-T frontend".
 
 	  Say Y if you own such a device and want to use it.
 
diff -Nru a/drivers/media/dvb/bt8xx/Makefile b/drivers/media/dvb/bt8xx/Makefile
--- a/drivers/media/dvb/bt8xx/Makefile	2004-12-24 13:36:16 -08:00
+++ b/drivers/media/dvb/bt8xx/Makefile	2004-12-24 13:36:16 -08:00
@@ -1,5 +1,5 @@
 
-obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o
+obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o
 
 EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/video -Idrivers/media/dvb/frontends
 
diff -Nru a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c
--- a/drivers/media/dvb/bt8xx/bt878.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/media/dvb/bt8xx/bt878.c	2004-12-24 13:36:55 -08:00
@@ -27,8 +27,8 @@
  * 
  */
 
-#include <linux/version.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <asm/io.h>
@@ -44,22 +44,21 @@
 #include "dmxdev.h"
 #include "dvbdev.h"
 #include "bt878.h"
-#include "dst-bt878.h"
+#include "dst_priv.h"
 
-#include "dvb_functions.h"
 
 /**************************************/
 /* Miscellaneous utility  definitions */
 /**************************************/
 
-unsigned int bt878_verbose = 1;
-unsigned int bt878_debug = 0;
-MODULE_PARM(bt878_verbose, "i");
+static unsigned int bt878_verbose = 1;
+static unsigned int bt878_debug;
+
+module_param_named(verbose, bt878_verbose, int, 0444);
 MODULE_PARM_DESC(bt878_verbose,
 		 "verbose startup messages, default is 1 (yes)");
-MODULE_PARM(bt878_debug, "i");
-MODULE_PARM_DESC(bt878_debug, "debug messages, default is 0 (no)");
-MODULE_LICENSE("GPL");
+module_param_named(debug, bt878_debug, int, 0644);
+MODULE_PARM_DESC(bt878_debug, "Turn on/off debugging (default:off).");
 
 int bt878_num;
 struct bt878 bt878[BT878_MAX];
@@ -339,10 +338,6 @@
 	return IRQ_HANDLED;
 }
 
-extern int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data);
-extern int bttv_read_gpio(unsigned int card, unsigned long *data);
-extern int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data);
-
 int
 bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *mp)
 {
@@ -386,20 +381,20 @@
 
 EXPORT_SYMBOL(bt878_device_control);
 
-struct bt878 *bt878_find_by_dvb_adap(struct dvb_adapter *adap)
+struct bt878 *bt878_find_by_i2c_adap(struct i2c_adapter *adapter)
 {
 	unsigned int card_nr;
 	
-	printk("bt878 find by dvb adap: checking \"%s\"\n",adap->name);
+	printk("bt878 find by dvb adap: checking \"%s\"\n",adapter->name);
 	for (card_nr = 0; card_nr < bt878_num; card_nr++) {
-		if (bt878[card_nr].adap_ptr == adap)
+		if (bt878[card_nr].adapter == adapter)
 			return &bt878[card_nr];
 	}
-	printk("bt878 find by dvb adap: NOT found \"%s\"\n",adap->name);
+	printk("bt878 find by dvb adap: NOT found \"%s\"\n",adapter->name);
 	return NULL;
 }
 
-EXPORT_SYMBOL(bt878_find_by_dvb_adap);
+EXPORT_SYMBOL(bt878_find_by_i2c_adap);
 
 /***********************/
 /* PCI device handling */
@@ -516,7 +511,7 @@
 		printk("bt878(%d): unloading\n", bt->nr);
 
 	/* turn off all capturing, DMA and IRQs */
-	btand(~13, BT878_AGPIO_DMA_CTL);
+	btand(~0x13, BT878_AGPIO_DMA_CTL);
 
 	/* first disable interrupts before unmapping the memory! */
 	btwrite(0, BT878_AINT_MASK);
@@ -564,22 +559,11 @@
 
 static int bt878_pci_driver_registered = 0;
 
-/* This will be used later by dvb-bt8xx to only use the audio
- * dma of certain cards */
-int bt878_find_audio_dma(void)
-{
-	// pci_register_driver(&bt878_pci_driver);
-	bt878_pci_driver_registered = 1;
-	return 0;
-}
-
-EXPORT_SYMBOL(bt878_find_audio_dma);
-
 /*******************************/
 /* Module management functions */
 /*******************************/
 
-int bt878_init_module(void)
+static int bt878_init_module(void)
 {
 	bt878_num = 0;
 	bt878_pci_driver_registered = 0;
@@ -591,13 +575,13 @@
 /*
         bt878_check_chipset();
 */
-	/* later we register inside of bt878_find_audio_dma
+	/* later we register inside of bt878_find_audio_dma()
 	 * because we may want to ignore certain cards */
 	bt878_pci_driver_registered = 1;
 	return pci_module_init(&bt878_pci_driver);
 }
 
-void bt878_cleanup_module(void)
+static void bt878_cleanup_module(void)
 {
 	if (bt878_pci_driver_registered) {
 		bt878_pci_driver_registered = 0;
@@ -606,10 +590,11 @@
 	return;
 }
 
-EXPORT_SYMBOL(bt878_init_module);
-EXPORT_SYMBOL(bt878_cleanup_module);
 module_init(bt878_init_module);
 module_exit(bt878_cleanup_module);
+
+//MODULE_AUTHOR("XXX");
+MODULE_LICENSE("GPL");
 
 /*
  * Local variables:
diff -Nru a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h
--- a/drivers/media/dvb/bt8xx/bt878.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/media/dvb/bt8xx/bt878.h	2004-12-24 13:37:43 -08:00
@@ -26,6 +26,7 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include "bt848.h"
+#include "bttv.h"
 
 #define BT878_VERSION_CODE 0x000000
 
@@ -94,14 +95,14 @@
 	struct semaphore  gpio_lock;
 	unsigned int nr;
 	unsigned int bttv_nr;
-	struct dvb_adapter *adap_ptr;
+	struct i2c_adapter *adapter;
 	struct pci_dev *dev;
 	unsigned int id;
 	unsigned int TS_Size;
 	unsigned char revision;
 	unsigned int irq;
 	unsigned long bt878_adr;
-	unsigned char *bt878_mem; /* function 1 */
+	volatile void __iomem *bt878_mem; /* function 1 */
 
 	volatile u32 finished_block;
 	volatile u32 last_block;
@@ -128,17 +129,17 @@
 void bt878_stop(struct bt878 *bt);	     
 
 #if defined(__powerpc__)	/* big-endian */
-extern __inline__ void io_st_le32(volatile unsigned *addr, unsigned val)
+extern __inline__ void io_st_le32(volatile unsigned __iomem *addr, unsigned val)
 {
 	__asm__ __volatile__("stwbrx %1,0,%2":"=m"(*addr):"r"(val),
 			     "r"(addr));
 	__asm__ __volatile__("eieio":::"memory");
 }
 
-#define bmtwrite(dat,adr)  io_st_le32((unsigned *)(adr),(dat))
-#define bmtread(adr)       ld_le32((unsigned *)(adr))
+#define bmtwrite(dat,adr)  io_st_le32((adr),(dat))
+#define bmtread(adr)       ld_le32((adr))
 #else
-#define bmtwrite(dat,adr)  writel((dat), (char *) (adr))
+#define bmtwrite(dat,adr)  writel((dat), (adr))
 #define bmtread(adr)       readl(adr)
 #endif
 
diff -Nru a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/bt8xx/dst.c	2004-12-24 13:37:18 -08:00
@@ -0,0 +1,1089 @@
+/*
+    Frontend-driver for TwinHan DST Frontend
+
+    Copyright (C) 2003 Jamie Honan
+
+    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.
+
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/delay.h>
+#include <asm/div64.h>
+
+#include "dvb_frontend.h"
+#include "dst_priv.h"
+#include "dst.h"
+
+struct dst_state {
+
+	struct i2c_adapter* i2c;
+
+	struct bt878* bt;
+
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct dst_config* config;
+
+	struct dvb_frontend frontend;
+
+	/* private demodulator data */
+	u8 tx_tuna[10];
+	u8 rx_tuna[10];
+	u8 rxbuffer[10];
+	u8 diseq_flags;
+	u8 dst_type;
+	u32 type_flags;
+	u32 frequency;		/* intermediate frequency in kHz for QPSK */
+	fe_spectral_inversion_t inversion;
+	u32 symbol_rate;	/* symbol rate in Symbols per second */
+	fe_code_rate_t fec;
+	fe_sec_voltage_t voltage;
+	fe_sec_tone_mode_t tone;
+	u32 decode_freq;
+	u8 decode_lock;
+	u16 decode_strength;
+	u16 decode_snr;
+	unsigned long cur_jiff;
+	u8 k22;
+	fe_bandwidth_t bandwidth;
+};
+
+static unsigned int dst_verbose = 0;
+module_param(dst_verbose, int, 0644);
+MODULE_PARM_DESC(dst_verbose, "verbose startup messages, default is 1 (yes)");
+static unsigned int dst_debug = 0;
+module_param(dst_debug, int, 0644);
+MODULE_PARM_DESC(dst_debug, "debug messages, default is 0 (no)");
+
+#define dprintk	if (dst_debug) printk
+
+#define DST_TYPE_IS_SAT		0
+#define DST_TYPE_IS_TERR	1
+#define DST_TYPE_IS_CABLE	2
+
+#define DST_TYPE_HAS_NEWTUNE	1
+#define DST_TYPE_HAS_TS204	2
+#define DST_TYPE_HAS_SYMDIV	4
+
+#define HAS_LOCK	1
+#define ATTEMPT_TUNE	2
+#define HAS_POWER	4
+
+static void dst_packsize(struct dst_state* state, int psize)
+{
+	union dst_gpio_packet bits;
+
+	bits.psize = psize;
+	bt878_device_control(state->bt, DST_IG_TS, &bits);
+}
+
+static int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh)
+{
+	union dst_gpio_packet enb;
+	union dst_gpio_packet bits;
+	int err;
+
+	enb.enb.mask = mask;
+	enb.enb.enable = enbb;
+	if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) {
+		dprintk("%s: dst_gpio_enb error (err == %i, mask == 0x%02x, enb == 0x%02x)\n", __FUNCTION__, err, mask, enbb);
+		return -EREMOTEIO;
+	}
+
+	/* because complete disabling means no output, no need to do output packet */
+	if (enbb == 0)
+		return 0;
+
+	bits.outp.mask = enbb;
+	bits.outp.highvals = outhigh;
+
+	if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) {
+		dprintk("%s: dst_gpio_outb error (err == %i, enbb == 0x%02x, outhigh == 0x%02x)\n", __FUNCTION__, err, enbb, outhigh);
+		return -EREMOTEIO;
+	}
+	return 0;
+}
+
+static int dst_gpio_inb(struct dst_state *state, u8 * result)
+{
+	union dst_gpio_packet rd_packet;
+	int err;
+
+	*result = 0;
+
+	if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) {
+		dprintk("%s: dst_gpio_inb error (err == %i)\n", __FUNCTION__, err);
+		return -EREMOTEIO;
+	}
+
+	*result = (u8) rd_packet.rd.value;
+	return 0;
+}
+
+#define DST_I2C_ENABLE	1
+#define DST_8820  	2
+
+static int dst_reset8820(struct dst_state *state)
+{
+	int retval;
+	/* pull 8820 gpio pin low, wait, high, wait, then low */
+	// dprintk ("%s: reset 8820\n", __FUNCTION__);
+	retval = dst_gpio_outb(state, DST_8820, DST_8820, 0);
+	if (retval < 0)
+		return retval;
+	msleep(10);
+	retval = dst_gpio_outb(state, DST_8820, DST_8820, DST_8820);
+	if (retval < 0)
+		return retval;
+	/* wait for more feedback on what works here *
+	   msleep(10);
+	   retval = dst_gpio_outb(dst, DST_8820, DST_8820, 0);
+	   if (retval < 0)
+	   return retval;
+	 */
+	return 0;
+}
+
+static int dst_i2c_enable(struct dst_state *state)
+{
+	int retval;
+	/* pull I2C enable gpio pin low, wait */
+	// dprintk ("%s: i2c enable\n", __FUNCTION__);
+	retval = dst_gpio_outb(state, ~0, DST_I2C_ENABLE, 0);
+	if (retval < 0)
+		return retval;
+	// dprintk ("%s: i2c enable delay\n", __FUNCTION__);
+	msleep(33);
+	return 0;
+}
+
+static int dst_i2c_disable(struct dst_state *state)
+{
+	int retval;
+	/* release I2C enable gpio pin, wait */
+	// dprintk ("%s: i2c disable\n", __FUNCTION__);
+	retval = dst_gpio_outb(state, ~0, 0, 0);
+	if (retval < 0)
+		return retval;
+	// dprintk ("%s: i2c disable delay\n", __FUNCTION__);
+	msleep(33);
+	return 0;
+}
+
+static int dst_wait_dst_ready(struct dst_state *state)
+{
+	u8 reply;
+	int retval;
+	int i;
+	for (i = 0; i < 200; i++) {
+		retval = dst_gpio_inb(state, &reply);
+		if (retval < 0)
+			return retval;
+		if ((reply & DST_I2C_ENABLE) == 0) {
+			dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i);
+			return 1;
+		}
+		msleep(10);
+	}
+	dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i);
+	return 0;
+}
+
+static int write_dst(struct dst_state *state, u8 * data, u8 len)
+{
+	struct i2c_msg msg = {
+		.addr = state->config->demod_address,.flags = 0,.buf = data,.len = len
+	};
+	int err;
+	int cnt;
+
+	if (dst_debug && dst_verbose) {
+		u8 i;
+		dprintk("%s writing", __FUNCTION__);
+		for (i = 0; i < len; i++) {
+			dprintk(" 0x%02x", data[i]);
+		}
+		dprintk("\n");
+	}
+	msleep(30);
+	for (cnt = 0; cnt < 4; cnt++) {
+		if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
+			dprintk("%s: write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]);
+			dst_i2c_disable(state);
+			msleep(500);
+			dst_i2c_enable(state);
+			msleep(500);
+			continue;
+		} else
+			break;
+	}
+	if (cnt >= 4)
+		return -EREMOTEIO;
+	return 0;
+}
+
+static int read_dst(struct dst_state *state, u8 * ret, u8 len)
+{
+	struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len };
+	int err;
+	int cnt;
+
+	for (cnt = 0; cnt < 4; cnt++) {
+		if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
+			dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]);
+			dst_i2c_disable(state);
+			dst_i2c_enable(state);
+			continue;
+		} else
+			break;
+	}
+	if (cnt >= 4)
+		return -EREMOTEIO;
+	dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]);
+	if (dst_debug && dst_verbose) {
+		for (err = 1; err < len; err++)
+			dprintk(" 0x%x", ret[err]);
+		if (err > 1)
+			dprintk("\n");
+	}
+	return 0;
+}
+
+static int dst_set_freq(struct dst_state *state, u32 freq)
+{
+	u8 *val;
+
+	state->frequency = freq;
+
+	// dprintk("%s: set frequency %u\n", __FUNCTION__, freq);
+	if (state->dst_type == DST_TYPE_IS_SAT) {
+		freq = freq / 1000;
+		if (freq < 950 || freq > 2150)
+			return -EINVAL;
+		val = &state->tx_tuna[0];
+		val[2] = (freq >> 8) & 0x7f;
+		val[3] = (u8) freq;
+		val[4] = 1;
+		val[8] &= ~4;
+		if (freq < 1531)
+			val[8] |= 4;
+	} else if (state->dst_type == DST_TYPE_IS_TERR) {
+		freq = freq / 1000;
+		if (freq < 137000 || freq > 858000)
+			return -EINVAL;
+		val = &state->tx_tuna[0];
+		val[2] = (freq >> 16) & 0xff;
+		val[3] = (freq >> 8) & 0xff;
+		val[4] = (u8) freq;
+		val[5] = 0;
+		switch (state->bandwidth) {
+		case BANDWIDTH_6_MHZ:
+			val[6] = 6;
+			break;
+
+		case BANDWIDTH_7_MHZ:
+		case BANDWIDTH_AUTO:
+			val[6] = 7;
+			break;
+
+		case BANDWIDTH_8_MHZ:
+			val[6] = 8;
+			break;
+		}
+
+		val[7] = 0;
+		val[8] = 0;
+	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
+		/* guess till will get one */
+		freq = freq / 1000;
+		val = &state->tx_tuna[0];
+		val[2] = (freq >> 16) & 0xff;
+		val[3] = (freq >> 8) & 0xff;
+		val[4] = (u8) freq;
+	} else
+		return -EINVAL;
+	return 0;
+}
+
+static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth)
+{
+	u8 *val;
+
+	state->bandwidth = bandwidth;
+
+	if (state->dst_type != DST_TYPE_IS_TERR)
+		return 0;
+
+	val = &state->tx_tuna[0];
+	switch (bandwidth) {
+	case BANDWIDTH_6_MHZ:
+		val[6] = 6;
+		break;
+
+	case BANDWIDTH_7_MHZ:
+		val[6] = 7;
+		break;
+
+	case BANDWIDTH_8_MHZ:
+		val[6] = 8;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion)
+{
+	u8 *val;
+
+	state->inversion = inversion;
+
+	val = &state->tx_tuna[0];
+
+	val[8] &= ~0x80;
+
+	switch (inversion) {
+	case INVERSION_OFF:
+		break;
+	case INVERSION_ON:
+		val[8] |= 0x80;
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec)
+{
+	state->fec = fec;
+	return 0;
+}
+
+static fe_code_rate_t dst_get_fec(struct dst_state* state)
+{
+	return state->fec;
+}
+
+static int dst_set_symbolrate(struct dst_state* state, u32 srate)
+{
+	u8 *val;
+	u32 symcalc;
+	u64 sval;
+
+	state->symbol_rate = srate;
+
+	if (state->dst_type == DST_TYPE_IS_TERR) {
+		return 0;
+	}
+	// dprintk("%s: set srate %u\n", __FUNCTION__, srate);
+	srate /= 1000;
+	val = &state->tx_tuna[0];
+
+	if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
+		sval = srate;
+		sval <<= 20;
+		do_div(sval, 88000);
+		symcalc = (u32) sval;
+		// dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc);
+		val[5] = (u8) (symcalc >> 12);
+		val[6] = (u8) (symcalc >> 4);
+		val[7] = (u8) (symcalc << 4);
+	} else {
+		val[5] = (u8) (srate >> 16) & 0x7f;
+		val[6] = (u8) (srate >> 8);
+		val[7] = (u8) srate;
+	}
+	val[8] &= ~0x20;
+	if (srate > 8000)
+		val[8] |= 0x20;
+	return 0;
+}
+
+static u8 dst_check_sum(u8 * buf, u32 len)
+{
+	u32 i;
+	u8 val = 0;
+	if (!len)
+		return 0;
+	for (i = 0; i < len; i++) {
+		val += buf[i];
+	}
+	return ((~val) + 1);
+}
+
+struct dst_types {
+	char *mstr;
+	int offs;
+	u8 dst_type;
+	u32 type_flags;
+};
+
+static struct dst_types dst_tlist[] = {
+	{"DST-020", 0, DST_TYPE_IS_SAT, DST_TYPE_HAS_SYMDIV},
+	{"DST-030", 0, DST_TYPE_IS_SAT, DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE},
+	{"DST-03T", 0, DST_TYPE_IS_SAT, DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_TS204},
+	{"DST-MOT", 0, DST_TYPE_IS_SAT, DST_TYPE_HAS_SYMDIV},
+	{"DST-CI",  1, DST_TYPE_IS_SAT, DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE},
+	{"DSTMCI",  1, DST_TYPE_IS_SAT, DST_TYPE_HAS_NEWTUNE},
+	{"DSTFCI",  1, DST_TYPE_IS_SAT, DST_TYPE_HAS_NEWTUNE},
+	{"DCTNEW",  1, DST_TYPE_IS_CABLE, DST_TYPE_HAS_NEWTUNE},
+	{"DCT-CI",  1, DST_TYPE_IS_CABLE, DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_TS204},
+	{"DTTDIG",  1, DST_TYPE_IS_TERR, 0}
+};
+
+/* DCTNEW and DCT-CI are guesses */
+
+static void dst_type_flags_print(u32 type_flags)
+{
+	printk("DST type flags :");
+	if (type_flags & DST_TYPE_HAS_NEWTUNE)
+		printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE);
+	if (type_flags & DST_TYPE_HAS_TS204)
+		printk(" 0x%x ts204", DST_TYPE_HAS_TS204);
+	if (type_flags & DST_TYPE_HAS_SYMDIV)
+		printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
+	printk("\n");
+}
+
+static int dst_type_print(u8 type)
+{
+	char *otype;
+	switch (type) {
+	case DST_TYPE_IS_SAT:
+		otype = "satellite";
+		break;
+	case DST_TYPE_IS_TERR:
+		otype = "terrestrial";
+		break;
+	case DST_TYPE_IS_CABLE:
+		otype = "cable";
+		break;
+	default:
+		printk("%s: invalid dst type %d\n", __FUNCTION__, type);
+		return -EINVAL;
+	}
+	printk("DST type : %s\n", otype);
+	return 0;
+}
+
+static int dst_check_ci(struct dst_state *state)
+{
+	u8 txbuf[8];
+	u8 rxbuf[8];
+	int retval;
+	int i;
+	struct dst_types *dsp;
+	u8 use_dst_type;
+	u32 use_type_flags;
+
+	memset(txbuf, 0, sizeof(txbuf));
+	txbuf[1] = 6;
+	txbuf[7] = dst_check_sum(txbuf, 7);
+
+	dst_i2c_enable(state);
+	dst_reset8820(state);
+	retval = write_dst(state, txbuf, 8);
+	if (retval < 0) {
+		dst_i2c_disable(state);
+		dprintk("%s: write not successful, maybe no card?\n", __FUNCTION__);
+		return retval;
+	}
+	msleep(3);
+	retval = read_dst(state, rxbuf, 1);
+	dst_i2c_disable(state);
+	if (retval < 0) {
+		dprintk("%s: read not successful, maybe no card?\n", __FUNCTION__);
+		return retval;
+	}
+	if (rxbuf[0] != 0xff) {
+		dprintk("%s: write reply not 0xff, not ci (%02x)\n", __FUNCTION__, rxbuf[0]);
+		return retval;
+	}
+	if (!dst_wait_dst_ready(state))
+		return 0;
+	// dst_i2c_enable(i2c); Dimitri
+	retval = read_dst(state, rxbuf, 8);
+	dst_i2c_disable(state);
+	if (retval < 0) {
+		dprintk("%s: read not successful\n", __FUNCTION__);
+		return retval;
+	}
+	if (rxbuf[7] != dst_check_sum(rxbuf, 7)) {
+		dprintk("%s: checksum failure\n", __FUNCTION__);
+		return retval;
+	}
+	rxbuf[7] = '\0';
+	for (i = 0, dsp = &dst_tlist[0]; i < sizeof(dst_tlist) / sizeof(dst_tlist[0]); i++, dsp++) {
+		if (!strncmp(&rxbuf[dsp->offs], dsp->mstr, strlen(dsp->mstr))) {
+			use_type_flags = dsp->type_flags;
+			use_dst_type = dsp->dst_type;
+			printk("%s: recognize %s\n", __FUNCTION__, dsp->mstr);
+			break;
+		}
+	}
+	if (i >= sizeof(dst_tlist) / sizeof(dst_tlist[0])) {
+		printk("%s: unable to recognize %s or %s\n", __FUNCTION__, &rxbuf[0], &rxbuf[1]);
+		printk("%s please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__);
+		use_dst_type = DST_TYPE_IS_SAT;
+		use_type_flags = DST_TYPE_HAS_SYMDIV;
+	}
+	dst_type_print(use_dst_type);
+
+	state->type_flags = use_type_flags;
+	state->dst_type = use_dst_type;
+	dst_type_flags_print(state->type_flags);
+
+	if (state->type_flags & DST_TYPE_HAS_TS204) {
+		dst_packsize(state, 204);
+	}
+	return 0;
+}
+
+static int dst_command(struct dst_state* state, u8 * data, u8 len)
+{
+	int retval;
+	u8 reply;
+
+	dst_i2c_enable(state);
+	dst_reset8820(state);
+	retval = write_dst(state, data, len);
+	if (retval < 0) {
+		dst_i2c_disable(state);
+		dprintk("%s: write not successful\n", __FUNCTION__);
+		return retval;
+	}
+	msleep(33);
+	retval = read_dst(state, &reply, 1);
+	dst_i2c_disable(state);
+	if (retval < 0) {
+		dprintk("%s: read verify  not successful\n", __FUNCTION__);
+		return retval;
+	}
+	if (reply != 0xff) {
+		dprintk("%s: write reply not 0xff 0x%02x \n", __FUNCTION__, reply);
+		return 0;
+	}
+	if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
+		return 0;
+	if (!dst_wait_dst_ready(state))
+		return 0;
+	// dst_i2c_enable(i2c); Per dimitri
+	retval = read_dst(state, state->rxbuffer, 8);
+	dst_i2c_disable(state);
+	if (retval < 0) {
+		dprintk("%s: read not successful\n", __FUNCTION__);
+		return 0;
+	}
+	if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
+		dprintk("%s: checksum failure\n", __FUNCTION__);
+		return 0;
+	}
+	return 0;
+}
+
+static int dst_get_signal(struct dst_state* state)
+{
+	int retval;
+	u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb };
+
+	if ((state->diseq_flags & ATTEMPT_TUNE) == 0) {
+		state->decode_lock = state->decode_strength = state->decode_snr = 0;
+		return 0;
+	}
+	if (0 == (state->diseq_flags & HAS_LOCK)) {
+		state->decode_lock = state->decode_strength = state->decode_snr = 0;
+		return 0;
+	}
+	if (time_after_eq(jiffies, state->cur_jiff + (HZ / 5))) {
+		retval = dst_command(state, get_signal, 8);
+		if (retval < 0)
+			return retval;
+		if (state->dst_type == DST_TYPE_IS_SAT) {
+			state->decode_lock = ((state->rxbuffer[6] & 0x10) == 0) ? 1 : 0;
+			state->decode_strength = state->rxbuffer[5] << 8;
+			state->decode_snr = state->rxbuffer[2] << 8 | state->rxbuffer[3];
+		} else if ((state->dst_type == DST_TYPE_IS_TERR) || (state->dst_type == DST_TYPE_IS_CABLE)) {
+			state->decode_lock = (state->rxbuffer[1]) ? 1 : 0;
+			state->decode_strength = state->rxbuffer[4] << 8;
+			state->decode_snr = state->rxbuffer[3] << 8;
+		}
+		state->cur_jiff = jiffies;
+	}
+	return 0;
+}
+
+static int dst_tone_power_cmd(struct dst_state* state)
+{
+	u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 };
+
+	if (state->dst_type == DST_TYPE_IS_TERR)
+		return 0;
+
+	if (state->voltage == SEC_VOLTAGE_OFF)
+		paket[4] = 0;
+	else
+		paket[4] = 1;
+	if (state->tone == SEC_TONE_ON)
+		paket[2] = state->k22;
+	else
+		paket[2] = 0;
+	paket[7] = dst_check_sum(&paket[0], 7);
+	dst_command(state, paket, 8);
+	return 0;
+}
+
+static int dst_get_tuna(struct dst_state* state)
+{
+	int retval;
+	if ((state->diseq_flags & ATTEMPT_TUNE) == 0)
+		return 0;
+	state->diseq_flags &= ~(HAS_LOCK);
+	if (!dst_wait_dst_ready(state))
+		return 0;
+	if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
+		/* how to get variable length reply ???? */
+		retval = read_dst(state, state->rx_tuna, 10);
+	} else {
+		retval = read_dst(state, &state->rx_tuna[2], 8);
+	}
+	if (retval < 0) {
+		dprintk("%s: read not successful\n", __FUNCTION__);
+		return 0;
+	}
+	if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
+		if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
+			dprintk("%s: checksum failure?\n", __FUNCTION__);
+			return 0;
+		}
+	} else {
+		if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) {
+			dprintk("%s: checksum failure?\n", __FUNCTION__);
+			return 0;
+		}
+	}
+	if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0)
+		return 0;
+	state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3];
+
+	state->decode_lock = 1;
+	/*
+	   dst->decode_n1 = (dst->rx_tuna[4] << 8) +
+	   (dst->rx_tuna[5]);
+
+	   dst->decode_n2 = (dst->rx_tuna[8] << 8) +
+	   (dst->rx_tuna[7]);
+	 */
+	state->diseq_flags |= HAS_LOCK;
+	/* dst->cur_jiff = jiffies; */
+	return 1;
+}
+
+static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
+
+static int dst_write_tuna(struct dvb_frontend* fe)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+	int retval;
+	u8 reply;
+
+	dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags);
+	state->decode_freq = 0;
+	state->decode_lock = state->decode_strength = state->decode_snr = 0;
+	if (state->dst_type == DST_TYPE_IS_SAT) {
+		if (!(state->diseq_flags & HAS_POWER))
+			dst_set_voltage(fe, SEC_VOLTAGE_13);
+	}
+	state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
+	dst_i2c_enable(state);
+	if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
+		dst_reset8820(state);
+		state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
+		retval = write_dst(state, &state->tx_tuna[0], 10);
+	} else {
+		state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7);
+		retval = write_dst(state, &state->tx_tuna[2], 8);
+	}
+	if (retval < 0) {
+		dst_i2c_disable(state);
+		dprintk("%s: write not successful\n", __FUNCTION__);
+		return retval;
+	}
+	msleep(3);
+	retval = read_dst(state, &reply, 1);
+	dst_i2c_disable(state);
+	if (retval < 0) {
+		dprintk("%s: read verify  not successful\n", __FUNCTION__);
+		return retval;
+	}
+	if (reply != 0xff) {
+		dprintk("%s: write reply not 0xff 0x%02x \n", __FUNCTION__, reply);
+		return 0;
+	}
+	state->diseq_flags |= ATTEMPT_TUNE;
+	return dst_get_tuna(state);
+}
+
+/*
+ * line22k0    0x00, 0x09, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00
+ * line22k1    0x00, 0x09, 0x01, 0xff, 0x01, 0x00, 0x00, 0x00
+ * line22k2    0x00, 0x09, 0x02, 0xff, 0x01, 0x00, 0x00, 0x00
+ * tone        0x00, 0x09, 0xff, 0x00, 0x01, 0x00, 0x00, 0x00
+ * data        0x00, 0x09, 0xff, 0x01, 0x01, 0x00, 0x00, 0x00
+ * power_off   0x00, 0x09, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00
+ * power_on    0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00
+ * Diseqc 1    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec
+ * Diseqc 2    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf4, 0xe8
+ * Diseqc 3    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf8, 0xe4
+ * Diseqc 4    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0
+ */
+
+static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+	u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec };
+
+	if (state->dst_type == DST_TYPE_IS_TERR)
+		return 0;
+
+	if (cmd->msg_len == 0 || cmd->msg_len > 4)
+		return -EINVAL;
+	memcpy(&paket[3], cmd->msg, cmd->msg_len);
+	paket[7] = dst_check_sum(&paket[0], 7);
+	dst_command(state, paket, 8);
+	return 0;
+}
+
+static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
+{
+	u8 *val;
+	int need_cmd;
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+
+	state->voltage = voltage;
+
+	if (state->dst_type == DST_TYPE_IS_TERR)
+		return 0;
+
+	need_cmd = 0;
+	val = &state->tx_tuna[0];
+	val[8] &= ~0x40;
+	switch (voltage) {
+	case SEC_VOLTAGE_13:
+		if ((state->diseq_flags & HAS_POWER) == 0)
+			need_cmd = 1;
+		state->diseq_flags |= HAS_POWER;
+		break;
+	case SEC_VOLTAGE_18:
+		if ((state->diseq_flags & HAS_POWER) == 0)
+			need_cmd = 1;
+		state->diseq_flags |= HAS_POWER;
+		val[8] |= 0x40;
+		break;
+	case SEC_VOLTAGE_OFF:
+		need_cmd = 1;
+		state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE);
+		break;
+	default:
+		return -EINVAL;
+	}
+	if (need_cmd) {
+		dst_tone_power_cmd(state);
+	}
+	return 0;
+}
+
+static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+{
+	u8 *val;
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+
+	state->tone = tone;
+
+	if (state->dst_type == DST_TYPE_IS_TERR)
+		return 0;
+
+	val = &state->tx_tuna[0];
+
+	val[8] &= ~0x1;
+
+	switch (tone) {
+	case SEC_TONE_OFF:
+		break;
+	case SEC_TONE_ON:
+		val[8] |= 1;
+		break;
+	default:
+		return -EINVAL;
+	}
+	dst_tone_power_cmd(state);
+	return 0;
+}
+
+static int dst_init(struct dvb_frontend* fe)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+	static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 };
+	static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 };
+	static u8 ini_tvfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
+	static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
+	static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
+	static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
+	state->inversion = INVERSION_ON;
+	state->voltage = SEC_VOLTAGE_13;
+	state->tone = SEC_TONE_OFF;
+	state->symbol_rate = 29473000;
+	state->fec = FEC_AUTO;
+	state->diseq_flags = 0;
+	state->k22 = 0x02;
+	state->bandwidth = BANDWIDTH_7_MHZ;
+	state->cur_jiff = jiffies;
+	if (state->dst_type == DST_TYPE_IS_SAT) {
+		state->frequency = 950000;
+		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_satci_tuna : ini_satfta_tuna), sizeof(ini_satfta_tuna));
+	} else if (state->dst_type == DST_TYPE_IS_TERR) {
+		state->frequency = 137000000;
+		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_tvci_tuna : ini_tvfta_tuna), sizeof(ini_tvfta_tuna));
+	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
+		state->frequency = 51000000;
+		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_cabci_tuna : ini_cabfta_tuna), sizeof(ini_cabfta_tuna));
+	}
+
+	return 0;
+}
+
+static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+
+	*status = 0;
+	if (state->diseq_flags & HAS_LOCK) {
+		dst_get_signal(state);
+		if (state->decode_lock)
+			*status |= FE_HAS_LOCK | FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_SYNC | FE_HAS_VITERBI;
+	}
+
+	return 0;
+}
+
+static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+
+	dst_get_signal(state);
+	*strength = state->decode_strength;
+
+	return 0;
+}
+
+static int dst_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+
+	dst_get_signal(state);
+	*snr = state->decode_snr;
+
+	return 0;
+}
+
+static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+
+	dst_set_freq(state, p->frequency);
+	dst_set_inversion(state, p->inversion);
+	if (state->dst_type == DST_TYPE_IS_SAT) {
+		dst_set_fec(state, p->u.qpsk.fec_inner);
+		dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
+	} else if (state->dst_type == DST_TYPE_IS_TERR) {
+		dst_set_bandwidth(state, p->u.ofdm.bandwidth);
+	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
+		dst_set_fec(state, p->u.qam.fec_inner);
+		dst_set_symbolrate(state, p->u.qam.symbol_rate);
+	}
+	dst_write_tuna(fe);
+
+	return 0;
+}
+
+static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+
+	p->frequency = state->decode_freq;
+	p->inversion = state->inversion;
+	if (state->dst_type == DST_TYPE_IS_SAT) {
+		p->u.qpsk.symbol_rate = state->symbol_rate;
+		p->u.qpsk.fec_inner = dst_get_fec(state);
+	} else if (state->dst_type == DST_TYPE_IS_TERR) {
+		p->u.ofdm.bandwidth = state->bandwidth;
+	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
+		p->u.qam.symbol_rate = state->symbol_rate;
+		p->u.qam.fec_inner = dst_get_fec(state);
+		p->u.qam.modulation = QAM_AUTO;
+	}
+
+	return 0;
+}
+
+static void dst_release(struct dvb_frontend* fe)
+{
+	struct dst_state* state = (struct dst_state*) fe->demodulator_priv;
+	kfree(state);
+}
+
+static struct dvb_frontend_ops dst_dvbt_ops;
+static struct dvb_frontend_ops dst_dvbs_ops;
+static struct dvb_frontend_ops dst_dvbc_ops;
+
+struct dvb_frontend* dst_attach(const struct dst_config* config,
+				struct i2c_adapter* i2c,
+				struct bt878 *bt)
+{
+	struct dst_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct dst_state*) kmalloc(sizeof(struct dst_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	state->bt = bt;
+
+	/* check if the demod is there */
+	if (dst_check_ci(state) < 0) goto error;
+
+	/* determine settings based on type */
+	switch (state->dst_type) {
+	case DST_TYPE_IS_TERR:
+		memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
+		break;
+	case DST_TYPE_IS_CABLE:
+		memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
+		break;
+	case DST_TYPE_IS_SAT:
+		memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
+		break;
+	default:
+		printk("dst: unknown frontend type. please report to the LinuxTV.org DVB mailinglist.\n");
+		goto error;
+	}
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops dst_dvbt_ops = {
+
+	.info = {
+		.name = "DST DVB-T",
+		.type = FE_OFDM,
+		.frequency_min = 137000000,
+		.frequency_max = 858000000,
+		.frequency_stepsize = 166667,
+		.caps = FE_CAN_FEC_AUTO | FE_CAN_QAM_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
+	},
+
+	.release = dst_release,
+
+	.init = dst_init,
+
+	.set_frontend = dst_set_frontend,
+	.get_frontend = dst_get_frontend,
+
+	.read_status = dst_read_status,
+	.read_signal_strength = dst_read_signal_strength,
+	.read_snr = dst_read_snr,
+};
+
+static struct dvb_frontend_ops dst_dvbs_ops = {
+
+	.info = {
+		.name = "DST DVB-S",
+		.type = FE_QPSK,
+		.frequency_min = 950000,
+		.frequency_max = 2150000,
+		.frequency_stepsize = 1000,	/* kHz for QPSK frontends */
+		.frequency_tolerance = 29500,
+		.symbol_rate_min = 1000000,
+		.symbol_rate_max = 45000000,
+	/*     . symbol_rate_tolerance	= 	???,*/
+		.caps = FE_CAN_FEC_AUTO | FE_CAN_QPSK
+	},
+
+	.release = dst_release,
+
+	.init = dst_init,
+
+	.set_frontend = dst_set_frontend,
+	.get_frontend = dst_get_frontend,
+
+	.read_status = dst_read_status,
+	.read_signal_strength = dst_read_signal_strength,
+	.read_snr = dst_read_snr,
+
+	.diseqc_send_master_cmd = dst_set_diseqc,
+	.set_voltage = dst_set_voltage,
+	.set_tone = dst_set_tone,
+};
+
+static struct dvb_frontend_ops dst_dvbc_ops = {
+
+	.info = {
+		.name = "DST DVB-C",
+		.type = FE_QAM,
+		.frequency_stepsize = 62500,
+		.frequency_min = 51000000,
+		.frequency_max = 858000000,
+		.symbol_rate_min = 1000000,
+		.symbol_rate_max = 45000000,
+	/*     . symbol_rate_tolerance	= 	???,*/
+		.caps = FE_CAN_FEC_AUTO | FE_CAN_QAM_AUTO
+	},
+
+	.release = dst_release,
+
+	.init = dst_init,
+
+	.set_frontend = dst_set_frontend,
+	.get_frontend = dst_get_frontend,
+
+	.read_status = dst_read_status,
+	.read_signal_strength = dst_read_signal_strength,
+	.read_snr = dst_read_snr,
+};
+
+MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver");
+MODULE_AUTHOR("Jamie Honan");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(dst_attach);
diff -Nru a/drivers/media/dvb/bt8xx/dst.h b/drivers/media/dvb/bt8xx/dst.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/bt8xx/dst.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,40 @@
+/*
+    Frontend-driver for TwinHan DST Frontend
+
+    Copyright (C) 2003 Jamie Honan
+
+    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.
+
+*/
+
+#ifndef DST_H
+#define DST_H
+
+#include <linux/dvb/frontend.h>
+#include <linux/device.h>
+#include "bt878.h"
+
+struct dst_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+};
+
+extern struct dvb_frontend* dst_attach(const struct dst_config* config,
+				       struct i2c_adapter* i2c,
+				       struct bt878 *bt);
+
+#endif // DST_H
diff -Nru a/drivers/media/dvb/bt8xx/dst_priv.h b/drivers/media/dvb/bt8xx/dst_priv.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/bt8xx/dst_priv.h	2004-12-24 13:37:18 -08:00
@@ -0,0 +1,37 @@
+/*
+ * dst-bt878.h: part of the DST driver for the TwinHan DST Frontend
+ *
+ * Copyright (C) 2003 Jamie Honan
+ */
+
+struct dst_gpio_enable {
+	u32	mask;
+	u32	enable;
+};
+
+struct dst_gpio_output {
+	u32	mask;
+	u32	highvals;
+};
+
+struct dst_gpio_read {
+	unsigned long value;
+};
+
+union dst_gpio_packet {
+	struct dst_gpio_enable enb;
+	struct dst_gpio_output outp;
+	struct dst_gpio_read rd;
+	int    psize;
+};
+
+#define DST_IG_ENABLE	0
+#define DST_IG_WRITE	1
+#define DST_IG_READ	2
+#define DST_IG_TS       3
+
+struct bt878;
+
+int bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *mp);
+
+struct bt878 *bt878_find_by_i2c_adap(struct i2c_adapter *adap);
diff -Nru a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c	2004-12-24 13:36:31 -08:00
@@ -19,9 +19,11 @@
  *
  */
 
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
+#include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
@@ -33,33 +35,32 @@
 
 #include "dvb-bt8xx.h"
 
-#include "dvb_functions.h"
-
 #include "bt878.h"
 
-/* ID THAT MUST GO INTO i2c ids */
-#ifndef  I2C_DRIVERID_DVB_BT878A
-# define I2C_DRIVERID_DVB_BT878A I2C_DRIVERID_EXP0+10
-#endif
-
+static int debug;
 
-#define dprintk if (debug) printk
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
 
-extern int bttv_get_cardinfo(unsigned int card, int *type, int *cardid);
-extern struct pci_dev* bttv_get_pcidev(unsigned int card);
-
-static LIST_HEAD(card_list);
-static int debug = 0;
+#define dprintk( args... ) \
+	do { \
+		if (debug) printk(KERN_DEBUG args); \
+	} while (0)
 
 static void dvb_bt8xx_task(unsigned long data)
 {
 	struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data;
 
-	//printk("%d ", finished_block);
+	//printk("%d ", card->bt->finished_block);
 
 	while (card->bt->last_block != card->bt->finished_block) {
-		(card->bt->TS_Size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter)(&card->demux, &card->bt->buf_cpu[card->bt->last_block * card->bt->block_bytes], card->bt->block_bytes);
-		card->bt->last_block = (card->bt->last_block + 1) % card->bt->block_count;
+		(card->bt->TS_Size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter)
+			(&card->demux,
+			 &card->bt->buf_cpu[card->bt->last_block *
+					    card->bt->block_bytes],
+			 card->bt->block_bytes);
+		card->bt->last_block = (card->bt->last_block + 1) %
+					card->bt->block_count;
 	}
 }
 
@@ -67,20 +68,21 @@
 {
 	struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
 	struct dvb_bt8xx_card *card = dvbdmx->priv;
+	int rc;
 
 	dprintk("dvb_bt8xx: start_feed\n");
 	
 	if (!dvbdmx->dmx.frontend)
 		return -EINVAL;
 
-	if (card->active)
-		return 0;
-		
-	card->active = 1;
-	
-//	bt878_start(card->bt, card->gpio_mode);
-
-	return 0;
+	down(&card->lock);
+	card->nfeeds++;
+	rc = card->nfeeds;
+	if (card->nfeeds == 1)
+		bt878_start(card->bt, card->gpio_mode,
+			    card->op_sync_orin, card->irq_err_ignore);
+	up(&card->lock);
+	return rc;
 }
 
 static int dvb_bt8xx_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
@@ -93,33 +95,15 @@
 	if (!dvbdmx->dmx.frontend)
 		return -EINVAL;
 		
-	if (!card->active)
-		return 0;
-
-//	bt878_stop(card->bt);
-
-	card->active = 0;
+	down(&card->lock);
+	card->nfeeds--;
+	if (card->nfeeds == 0)
+		bt878_stop(card->bt);
+	up(&card->lock);
 
 	return 0;
 }
 
-static int master_xfer (struct dvb_i2c_bus *i2c, const struct i2c_msg msgs[], int num)
-{
-	struct dvb_bt8xx_card *card = i2c->data;
-	int retval;
-
-	if (down_interruptible (&card->bt->gpio_lock))
-		return -ERESTARTSYS;
-
-	retval = i2c_transfer(card->i2c_adapter,
-			      (struct i2c_msg*) msgs,
-			      num);
-
-	up(&card->bt->gpio_lock);
-
-	return retval;
-}
-
 static int is_pci_slot_eq(struct pci_dev* adev, struct pci_dev* bdev)
 {
 	if ((adev->subsystem_vendor == bdev->subsystem_vendor) &&
@@ -142,168 +126,298 @@
 	return NULL;
 }
 
-static int __init dvb_bt8xx_card_match(unsigned int bttv_nr, char *card_name, u32 gpio_mode, u32 op_sync_orin, u32 irq_err_ignore)
-{
-	struct dvb_bt8xx_card *card;
-	struct pci_dev* bttv_pci_dev;
 
-	dprintk("dvb_bt8xx: identified card%d as %s\n", bttv_nr, card_name);
-			
-	if (!(card = kmalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL)))
-		return -ENOMEM;
+static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
+{
+	static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 };
+	static u8 mt352_reset [] = { 0x50, 0x80 };
+	static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+	static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0x20 };
+	static u8 mt352_gpp_ctl_cfg [] = { 0x75, 0x33 };
+	static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
+
+	mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
+	udelay(2000);
+	mt352_write(fe, mt352_reset, sizeof(mt352_reset));
+	mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
+
+	mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
+        mt352_write(fe, mt352_gpp_ctl_cfg, sizeof(mt352_gpp_ctl_cfg));
+	mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
 
-	memset(card, 0, sizeof(*card));
-	card->bttv_nr = bttv_nr;
-	strncpy(card->card_name, card_name, sizeof(card_name) - 1);
-	
-	if (!(bttv_pci_dev = bttv_get_pcidev(bttv_nr))) {
-		printk("dvb_bt8xx: no pci device for card %d\n", card->bttv_nr);
-		kfree(card);
-		return -EFAULT;
-	}
+	return 0;
+}
 
-	if (!(card->bt = dvb_bt8xx_878_match(card->bttv_nr, bttv_pci_dev))) {
-		printk("dvb_bt8xx: unable to determine DMA core of card %d\n", card->bttv_nr);
-	
-		kfree(card);
-		return -EFAULT;
-		
-	}
-	init_MUTEX(&card->bt->gpio_lock);
-	card->bt->bttv_nr = bttv_nr;
-	card->gpio_mode = gpio_mode;
-	card->op_sync_orin = op_sync_orin;
-	card->irq_err_ignore = irq_err_ignore;
-	list_add_tail(&card->list, &card_list);
+static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
+{
+	u32 div;
+	unsigned char bs = 0;
+	unsigned char cp = 0;
+
+	#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
+	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
+
+	if (params->frequency < 542000000) cp = 0xb4;
+	else if (params->frequency < 771000000) cp = 0xbc;
+	else cp = 0xf4;
+
+        if (params->frequency == 0) bs = 0x03;
+	else if (params->frequency < 443250000) bs = 0x02;
+	else bs = 0x08;
+
+	pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address
+	pllbuf[1] = div >> 8;
+   	pllbuf[2] = div & 0xff;
+   	pllbuf[3] = cp;
+   	pllbuf[4] = bs;
 
 	return 0;
 }
 
-static struct dvb_bt8xx_card *dvb_bt8xx_find_by_i2c_adap(struct i2c_adapter *adap)
+static struct mt352_config thomson_dtt7579_config = {
+
+	.demod_address = 0x0f,
+	.demod_init = thomson_dtt7579_demod_init,
+	.pll_set = thomson_dtt7579_pll_set,
+};
+
+
+
+static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
 {
-	struct dvb_bt8xx_card *card;
-	struct list_head *item;
-	
-	printk("find by i2c adap: checking \"%s\"\n",adap->name);
-	list_for_each(item, &card_list) {
-		card = list_entry(item, struct dvb_bt8xx_card, list);
-		if (card->i2c_adapter == adap)
-			return card;
-	}
-	return NULL;
+	struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
+	u8 cfg, cpump, band_select;
+	u8 data[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	div = (36000000 + params->frequency + 83333) / 166666;
+	cfg = 0x88;
+
+	if (params->frequency < 175000000) cpump = 2;
+	else if (params->frequency < 390000000) cpump = 1;
+	else if (params->frequency < 470000000) cpump = 2;
+	else if (params->frequency < 750000000) cpump = 2;
+	else cpump = 3;
+
+	if (params->frequency < 175000000) band_select = 0x0e;
+	else if (params->frequency < 470000000) band_select = 0x05;
+	else band_select = 0x03;
+
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = ((div >> 10) & 0x60) | cfg;
+	data[3] = cpump | band_select;
+
+	i2c_transfer(card->i2c_adapter, &msg, 1);
+	return (div * 166666 - 36000000);
 }
 
-static struct dvb_bt8xx_card *dvb_bt8xx_find_by_pci(struct i2c_adapter *adap)
+static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
 {
-	struct dvb_bt8xx_card *card;
-	struct list_head *item;
-	struct device  *dev;
-	struct pci_dev *pci;
-	
-	printk("find by pci: checking \"%s\"\n",adap->name);
-	dev = adap->dev.parent;
-	if (NULL == dev) {
-		/* shoudn't happen with 2.6.0-test7 + newer */
-		printk("attach: Huh? i2c adapter not in sysfs tree?\n");
-		return NULL;
-	}
-	pci = to_pci_dev(dev);
-	list_for_each(item, &card_list) {
-		card = list_entry(item, struct dvb_bt8xx_card, list);
-		if (is_pci_slot_eq(pci, card->bt->dev)) {
-			return card;
-		}
-	}
-	return NULL;
+	struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv;
+
+	return request_firmware(fw, name, &bt->bt->dev->dev);
 }
 
-static int dvb_bt8xx_attach(struct i2c_adapter *adap)
-{
-	struct dvb_bt8xx_card *card;
-	
-	printk("attach: checking \"%s\"\n",adap->name);
+struct sp887x_config microtune_mt7202dtf_config = {
+
+	.demod_address = 0x70,
+	.pll_set = microtune_mt7202dtf_pll_set,
+	.request_firmware = microtune_mt7202dtf_request_firmware,
+};
 
-	/* looking for bt878 cards ... */
-	if (adap->id != (I2C_ALGO_BIT | I2C_HW_B_BT848))
-		return 0;
-	card = dvb_bt8xx_find_by_pci(adap);
-	if (!card)
-		return 0;
-	card->i2c_adapter = adap;
-	printk("attach: \"%s\", to card %d\n",
-	       adap->name, card->bttv_nr);
-	try_module_get(adap->owner);
 
-	return 0;
-}
 
-static void dvb_bt8xx_i2c_adap_free(struct i2c_adapter *adap)
+static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
 {
-	module_put(adap->owner);
+	static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
+	static u8 mt352_reset [] = { 0x50, 0x80 };
+	static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+	static u8 mt352_agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
+	                               0x00, 0xFF, 0x00, 0x40, 0x40 };
+	static u8 mt352_av771_extra[] = { 0xB5, 0x7A };
+	static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
+
+
+	mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
+	udelay(2000);
+	mt352_write(fe, mt352_reset, sizeof(mt352_reset));
+	mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
+
+	mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg));
+	udelay(2000);
+	mt352_write(fe, mt352_av771_extra,sizeof(mt352_av771_extra));
+	mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
+
+	return 0;
 }
 
-static int dvb_bt8xx_detach(struct i2c_adapter *adap)
+static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
 {
-	struct dvb_bt8xx_card *card;
+	u32 div;
+	unsigned char bs = 0;
+	unsigned char cp = 0;
+
+	#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
+	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
+
+	if (params->frequency < 150000000) cp = 0xB4;
+	else if (params->frequency < 173000000) cp = 0xBC;
+	else if (params->frequency < 250000000) cp = 0xB4;
+	else if (params->frequency < 400000000) cp = 0xBC;
+	else if (params->frequency < 420000000) cp = 0xF4;
+	else if (params->frequency < 470000000) cp = 0xFC;
+	else if (params->frequency < 600000000) cp = 0xBC;
+	else if (params->frequency < 730000000) cp = 0xF4;
+	else cp = 0xFC;
+
+	if (params->frequency < 150000000) bs = 0x01;
+	else if (params->frequency < 173000000) bs = 0x01;
+	else if (params->frequency < 250000000) bs = 0x02;
+	else if (params->frequency < 400000000) bs = 0x02;
+	else if (params->frequency < 420000000) bs = 0x02;
+	else if (params->frequency < 470000000) bs = 0x02;
+	else if (params->frequency < 600000000) bs = 0x08;
+	else if (params->frequency < 730000000) bs = 0x08;
+	else bs = 0x08;
+
+	pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
+	pllbuf[1] = div >> 8;
+   	pllbuf[2] = div & 0xff;
+   	pllbuf[3] = cp;
+   	pllbuf[4] = bs;
 
-	card = dvb_bt8xx_find_by_i2c_adap(adap);
-	if (!card)
-		return 0;
-
-	/* This should not happen. We have locked the module! */
-	printk("detach: \"%s\", for card %d removed\n",
-	       adap->name, card->bttv_nr);
 	return 0;
 }
 
-static struct i2c_driver dvb_bt8xx_driver = {
-	.owner           = THIS_MODULE,
-	.name            = "dvb_bt8xx",
-        .id              = I2C_DRIVERID_DVB_BT878A,
-	.flags           = I2C_DF_NOTIFY,
-        .attach_adapter  = dvb_bt8xx_attach,
-        .detach_adapter  = dvb_bt8xx_detach,
+static struct mt352_config advbt771_samsung_tdtc9251dh0_config = {
+
+	.demod_address = 0x0f,
+	.demod_init = advbt771_samsung_tdtc9251dh0_demod_init,
+	.pll_set = advbt771_samsung_tdtc9251dh0_pll_set,
 };
 
-static void __init dvb_bt8xx_get_adaps(void)
-{
-	i2c_add_driver(&dvb_bt8xx_driver);
-}
 
-static void __exit dvb_bt8xx_exit_adaps(void)
+static struct dst_config dst_config = {
+
+	.demod_address = 0x55,
+};
+
+
+static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
 {
-	i2c_del_driver(&dvb_bt8xx_driver);
+	struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
+	u8 buf[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = buf, .len = sizeof(buf) };
+
+	div = (params->frequency + 36166667) / 166667;
+
+	buf[0] = (div >> 8) & 0x7F;
+	buf[1] = div & 0xFF;
+	buf[2] = 0x85;
+	if ((params->frequency >= 47000000) && (params->frequency < 153000000))
+		buf[3] = 0x01;
+	else if ((params->frequency >= 153000000) && (params->frequency < 430000000))
+		buf[3] = 0x02;
+	else if ((params->frequency >= 430000000) && (params->frequency < 824000000))
+		buf[3] = 0x0C;
+	else if ((params->frequency >= 824000000) && (params->frequency < 863000000))
+		buf[3] = 0x8C;
+	else
+		return -EINVAL;
+
+	i2c_transfer(card->i2c_adapter, &msg, 1);
+	return 0;
 }
 
-static int __init dvb_bt8xx_load_card( struct dvb_bt8xx_card *card)
+static struct nxt6000_config vp3021_alps_tded4_config = {
+
+	.demod_address = 0x0a,
+	.clock_inversion = 1,
+	.pll_set = vp3021_alps_tded4_pll_set,
+};
+
+
+static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
 {
-	int result;
+	switch(type) {
+#ifdef BTTV_DVICO_DVBT_LITE
+	case BTTV_DVICO_DVBT_LITE:
+		card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter);
+		if (card->fe != NULL) {
+			card->fe->ops->info.frequency_min = 174000000;
+			card->fe->ops->info.frequency_max = 862000000;
+			break;
+		}
+		break;
+#endif
 
-	if (!card->i2c_adapter) {
-		printk("dvb_bt8xx: unable to determine i2c adaptor of card %d, deleting\n", card->bttv_nr);
+#ifdef BTTV_TWINHAN_VP3021
+	case BTTV_TWINHAN_VP3021:
+#else
+	case BTTV_NEBULA_DIGITV:
+#endif
+		card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
+		if (card->fe != NULL) {
+			break;
+		}
+		break;
 
-		return -EFAULT;
-	
+	case BTTV_AVDVBT_761:
+		card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
+		if (card->fe != NULL) {
+			break;
+		}
+		break;
+
+	case BTTV_AVDVBT_771:
+		card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
+		if (card->fe != NULL) {
+			card->fe->ops->info.frequency_min = 174000000;
+			card->fe->ops->info.frequency_max = 862000000;
+			break;
+		}
+		break;
+
+	case BTTV_TWINHAN_DST:
+		card->fe = dst_attach(&dst_config, card->i2c_adapter, card->bt);
+		if (card->fe != NULL) {
+			break;
+		}
+		break;
 	}
 
-	if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE)) < 0) {
-	
+	if (card->fe == NULL) {
+		printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
+		       card->bt->dev->vendor,
+		       card->bt->dev->device,
+		       card->bt->dev->subsystem_vendor,
+		       card->bt->dev->subsystem_device);
+	} else {
+		if (dvb_register_frontend(card->dvb_adapter, card->fe)) {
+			printk("dvb-bt8xx: Frontend registration failed!\n");
+			if (card->fe->ops->release)
+				card->fe->ops->release(card->fe);
+			card->fe = NULL;
+		}
+	}
+}
+
+static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
+{
+	int result;
+
+	if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name,
+					   THIS_MODULE)) < 0) {
 		printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result);
-		
-		dvb_bt8xx_i2c_adap_free(card->i2c_adapter);
 		return result;
 		
 	}
-	card->bt->adap_ptr = card->dvb_adapter;
-
-	if (!(dvb_register_i2c_bus(master_xfer, card, card->dvb_adapter, 0))) {
-		printk("dvb_bt8xx: dvb_register_i2c_bus of card%d failed\n", card->bttv_nr);
+	card->dvb_adapter->priv = card;
 
-		dvb_unregister_adapter(card->dvb_adapter);
-		dvb_bt8xx_i2c_adap_free(card->i2c_adapter);
-
-		return -EFAULT;
-	}
+	card->bt->adapter = card->i2c_adapter;
 
 	memset(&card->demux, 0, sizeof(struct dvb_demux));
 
@@ -319,10 +433,7 @@
 	if ((result = dvb_dmx_init(&card->demux)) < 0) {
 		printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
 
-		dvb_unregister_i2c_bus(master_xfer, card->dvb_adapter, 0);
 		dvb_unregister_adapter(card->dvb_adapter);
-		dvb_bt8xx_i2c_adap_free(card->i2c_adapter);
-		
 		return result;
 	}
 
@@ -334,10 +445,7 @@
 		printk("dvb_bt8xx: dvb_dmxdev_init failed (errno = %d)\n", result);
 
 		dvb_dmx_release(&card->demux);
-		dvb_unregister_i2c_bus(master_xfer, card->dvb_adapter, 0);
 		dvb_unregister_adapter(card->dvb_adapter);
-		dvb_bt8xx_i2c_adap_free(card->i2c_adapter);
-		
 		return result;
 	}
 
@@ -348,10 +456,7 @@
 
 		dvb_dmxdev_release(&card->dmxdev);
 		dvb_dmx_release(&card->demux);
-		dvb_unregister_i2c_bus(master_xfer, card->dvb_adapter, 0);
 		dvb_unregister_adapter(card->dvb_adapter);
-		dvb_bt8xx_i2c_adap_free(card->i2c_adapter);
-		
 		return result;
 	}
 	
@@ -363,10 +468,7 @@
 		card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
 		dvb_dmxdev_release(&card->dmxdev);
 		dvb_dmx_release(&card->demux);
-		dvb_unregister_i2c_bus(master_xfer, card->dvb_adapter, 0);
 		dvb_unregister_adapter(card->dvb_adapter);
-		dvb_bt8xx_i2c_adap_free(card->i2c_adapter);
-		
 		return result;
 	}
 
@@ -377,10 +479,7 @@
 		card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
 		dvb_dmxdev_release(&card->dmxdev);
 		dvb_dmx_release(&card->demux);
-		dvb_unregister_i2c_bus(master_xfer, card->dvb_adapter, 0);
 		dvb_unregister_adapter(card->dvb_adapter);
-		dvb_bt8xx_i2c_adap_free(card->i2c_adapter);
-		
 		return result;
 	}
 
@@ -388,72 +487,65 @@
 
 	tasklet_init(&card->bt->tasklet, dvb_bt8xx_task, (unsigned long) card);
 	
-	bt878_start(card->bt, card->gpio_mode, card->op_sync_orin, card->irq_err_ignore);
+	frontend_init(card, type);
 
 	return 0;
 }
 
-static int __init dvb_bt8xx_load_all(void)
+static int dvb_bt8xx_probe(struct device *dev)
 {
+	struct bttv_sub_device *sub = to_bttv_sub_dev(dev);
 	struct dvb_bt8xx_card *card;
-	struct list_head *entry, *entry_safe;
-
-	list_for_each_safe(entry, entry_safe, &card_list) {
-		card = list_entry(entry, struct dvb_bt8xx_card, list);
-		if (dvb_bt8xx_load_card(card) < 0) {
-			list_del(&card->list);
-			kfree(card);
-			continue;
-		}
-	}
-	return 0;
-
-}
-
-#define BT878_NEBULA	0x68
-#define BT878_TWINHAN_DST 0x71
+	struct pci_dev* bttv_pci_dev;
+	int ret;
 
-static int __init dvb_bt8xx_init(void)
-{
-	unsigned int card_nr = 0;
-	int card_id;
-	int card_type;
+	if (!(card = kmalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL)))
+		return -ENOMEM;
 
-	dprintk("dvb_bt8xx: enumerating available bttv cards...\n");
-	
-	while (bttv_get_cardinfo(card_nr, &card_type, &card_id) == 0) {
-		switch(card_id) {
-			case 0x001C11BD:
-				dvb_bt8xx_card_match(card_nr, "Pinnacle PCTV DVB-S",
-					       0x0400C060, 0, 0);
+	memset(card, 0, sizeof(*card));
+	init_MUTEX(&card->lock);
+	card->bttv_nr = sub->core->nr;
+	strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
+	card->i2c_adapter = &sub->core->i2c_adap;
+
+	switch(sub->core->type)
+	{
+/*	case BTTV_PINNACLESAT: UNDEFINED HARDWARE */
+#ifdef BTTV_DVICO_DVBT_LITE
+	case BTTV_DVICO_DVBT_LITE:
+#endif
+		card->gpio_mode = 0x0400C060;
+		card->op_sync_orin = 0;
+		card->irq_err_ignore = 0;
 				/* 26, 15, 14, 6, 5 
-				 * A_G2X  DA_DPM DA_SBR DA_IOM_DA 
+		 * A_PWRDN  DA_DPM DA_SBR DA_IOM_DA
 				 * DA_APP(parallel) */
 				break;
-			case 0x01010071:
-nebula:
-				dvb_bt8xx_card_match(card_nr, "Nebula DigiTV DVB-T",
-					     (1 << 26) | (1 << 14) | (1 << 5),
-					     0, 0);
+
+#ifdef BTTV_TWINHAN_VP3021
+	case BTTV_TWINHAN_VP3021:
+#else
+	case BTTV_NEBULA_DIGITV:
+#endif
+	case BTTV_AVDVBT_761:
+		card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);
+		card->op_sync_orin = 0;
+		card->irq_err_ignore = 0;
 				/* A_PWRDN DA_SBR DA_APP (high speed serial) */
 				break;
-			case 0x07611461:
-				dvb_bt8xx_card_match(card_nr, "Avermedia DVB-T",
-					     (1 << 26) | (1 << 14) | (1 << 5),
-					     0, 0);
-				/* A_PWRDN DA_SBR DA_APP (high speed serial) */
+
+	case BTTV_AVDVBT_771: //case 0x07711461:
+		card->gpio_mode = 0x0400402B;
+		card->op_sync_orin = BT878_RISC_SYNC_MASK;
+		card->irq_err_ignore = 0;
+		/* A_PWRDN DA_SBR  DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/
 				break;
-			case 0x0:
-				if (card_type == BT878_NEBULA ||
-					card_type == BT878_TWINHAN_DST)
-					goto dst;
-				goto unknown_card;
-			case 0x2611BD:
-			case 0x11822:
-dst:
-				dvb_bt8xx_card_match(card_nr, "DST DVB-S", 0x2204f2c,
-						BT878_RISC_SYNC_MASK,
-						BT878_APABORT | BT878_ARIPERR | BT878_APPERR | BT878_AFBUS);
+
+	case BTTV_TWINHAN_DST:
+		card->gpio_mode = 0x2204f2c;
+		card->op_sync_orin = BT878_RISC_SYNC_MASK;
+		card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR |
+				       BT878_APPERR | BT878_AFBUS;
 				/* 25,21,14,11,10,9,8,3,2 then
 				 * 0x33 = 5,4,1,0
 				 * A_SEL=SML, DA_MLB, DA_SBR, 
@@ -466,42 +558,48 @@
 				 * ACAP_EN = 1,
 				 * RISC+FIFO ENABLE */
 				break;
+
 			default:
-unknown_card:
-				printk("%s: unknown card_id found %0X\n",
-					__FUNCTION__, card_id);
-				if (card_type == BT878_NEBULA) {
-					printk("%s: bttv type set to nebula\n",
-						__FUNCTION__);
-					goto nebula;
-				}
-				if (card_type == BT878_TWINHAN_DST) {
-					printk("%s: bttv type set to Twinhan DST\n",
-						__FUNCTION__);
-					goto dst;
-				}
-				printk("%s: unknown card_type found %0X, NOT LOADED\n",
-					__FUNCTION__, card_type);
-				printk("%s: unknown card_nr found %0X\n",
-					__FUNCTION__, card_nr);
+		printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n",
+				sub->core->type);
+		kfree(card);
+		return -ENODEV;
 		}
-		card_nr++;
+
+	dprintk("dvb_bt8xx: identified card%d as %s\n", card->bttv_nr, card->card_name);
+
+	if (!(bttv_pci_dev = bttv_get_pcidev(card->bttv_nr))) {
+		printk("dvb_bt8xx: no pci device for card %d\n", card->bttv_nr);
+		kfree(card);
+		return -EFAULT;
 	}
-	dvb_bt8xx_get_adaps();
-	dvb_bt8xx_load_all();
 
-	return 0;
+	if (!(card->bt = dvb_bt8xx_878_match(card->bttv_nr, bttv_pci_dev))) {
+		printk("dvb_bt8xx: unable to determine DMA core of card %d,\n",
+		       card->bttv_nr);
+		printk("dvb_bt8xx: if you have the ALSA bt87x audio driver "
+		       "installed, try removing it.\n");
+
+		kfree(card);
+		return -EFAULT;
 
 }
 
-static void __exit dvb_bt8xx_exit(void)
-{
-	struct dvb_bt8xx_card *card;
-	struct list_head *entry, *entry_safe;
+	init_MUTEX(&card->bt->gpio_lock);
+	card->bt->bttv_nr = sub->core->nr;
+
+	if ( (ret = dvb_bt8xx_load_card(card, sub->core->type)) ) {
+		kfree(card);
+		return ret;
+	}
 
-	dvb_bt8xx_exit_adaps();
-	list_for_each_safe(entry, entry_safe, &card_list) {
-		card = list_entry(entry, struct dvb_bt8xx_card, list);
+	dev_set_drvdata(dev, card);
+	return 0;
+}
+
+static int dvb_bt8xx_remove(struct device *dev)
+{
+	struct dvb_bt8xx_card *card = dev_get_drvdata(dev);
 		
 		dprintk("dvb_bt8xx: unloading card%d\n", card->bttv_nr);
 
@@ -512,14 +610,35 @@
 		card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
 		dvb_dmxdev_release(&card->dmxdev);
 		dvb_dmx_release(&card->demux);
-		dvb_unregister_i2c_bus(master_xfer, card->dvb_adapter, 0);
-		dvb_bt8xx_i2c_adap_free(card->i2c_adapter);
+	if (card->fe) dvb_unregister_frontend(card->fe);
 		dvb_unregister_adapter(card->dvb_adapter);
 		
-		list_del(&card->list);
 		kfree(card);
+
+	return 0;
 	}
 
+static struct bttv_sub_driver driver = {
+	.drv = {
+		.name		= "dvb-bt8xx",
+		.probe		= dvb_bt8xx_probe,
+		.remove		= dvb_bt8xx_remove,
+		/* FIXME:
+		 * .shutdown	= dvb_bt8xx_shutdown,
+		 * .suspend	= dvb_bt8xx_suspend,
+		 * .resume	= dvb_bt8xx_resume,
+		 */
+	},
+};
+
+static int __init dvb_bt8xx_init(void)
+{
+	return bttv_sub_register(&driver, "dvb");
+}
+
+static void __exit dvb_bt8xx_exit(void)
+{
+	bttv_sub_unregister(&driver);
 }
 
 module_init(dvb_bt8xx_init);
@@ -527,4 +646,4 @@
 MODULE_DESCRIPTION("Bt8xx based DVB adapter driver");
 MODULE_AUTHOR("Florian Schirmer <jolt@tuxbox.org>");
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
+
diff -Nru a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h	2004-12-24 13:37:29 -08:00
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h	2004-12-24 13:37:29 -08:00
@@ -25,11 +25,15 @@
 #include <linux/i2c.h>
 #include "dvbdev.h"
 #include "dvb_net.h"
+#include "bttv.h"
+#include "mt352.h"
+#include "sp887x.h"
+#include "dst.h"
+#include "nxt6000.h"
 
 struct dvb_bt8xx_card {
-
-	struct list_head list;
-	u8 active;
+	struct semaphore lock;
+	int nfeeds;
 	char card_name[32];
 	struct dvb_adapter *dvb_adapter;
 	struct bt878 *bt;
@@ -44,4 +48,5 @@
 	struct i2c_adapter *i2c_adapter;
 	struct dvb_net dvbnet;
 				
+	struct dvb_frontend* fe;
 };
diff -Nru a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/cinergyT2/Kconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,85 @@
+config DVB_CINERGYT2
+	tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver"
+	depends on DVB_CORE && USB
+	help
+	  Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers
+
+	  Say Y if you own such a device and want to use it.
+
+
+config DVB_CINERGYT2_TUNING
+	bool "sophisticated fine-tuning for CinergyT2 cards"
+	depends on DVB_CINERGYT2
+	help
+	  Here you can fine-tune some parameters of the CinergyT2 driver.
+
+	  Normally you don't need to touch this, but in exotic setups you
+	  may fine-tune your setup and adjust e.g. DMA buffer sizes for
+	  a particular application.
+
+
+config DVB_CINERGYT2_STREAM_URB_COUNT
+	int "Number of queued USB Request Blocks for Highspeed Stream Transfers"
+	depends on DVB_CINERGYT2_TUNING
+        default "32"
+	help
+	  USB Request Blocks for Highspeed Stream transfers are scheduled in
+	  a queue for the Host Controller.
+
+	  Usually the default value is a safe choice.
+
+	  You may increase this number if you are using this device in a 
+	  Server Environment with many high-traffic USB Highspeed devices 
+	  sharing the same USB bus.
+
+
+config DVB_CINERGYT2_STREAM_BUF_SIZE
+	int "Size of URB Stream Buffers for Highspeed Transfers"
+	depends on DVB_CINERGYT2_TUNING
+        default "512"
+	help
+	  Should be a multiple of native buffer size of 512 bytes.
+	  Default value is a safe choice.
+
+	  You may increase this number if you are using this device in a 
+	  Server Environment with many high-traffic USB Highspeed devices 
+	  sharing the same USB bus.
+
+
+config DVB_CINERGYT2_QUERY_INTERVAL
+	int "Status update interval [milliseconds]"
+	depends on DVB_CINERGYT2_TUNING
+        default "250"
+	help
+	  This is the interval for status readouts from the demodulator.
+	  You may try lower values if you need more responsive signal quality
+	  measurements.
+
+	  Please keep in mind that these updates cause traffic on the tuner
+	  control bus and thus may or may not affect receiption sensitivity.
+
+	  The default value should be a safe choice for common applications.
+
+
+config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
+	bool "Register the onboard IR Remote Control Receiver as Input Device"
+	depends on DVB_CINERGYT2_TUNING
+        default "yes"
+	help
+	  Enable this option if you want to use the onboard Infrared Remote 
+	  Control Receiver as Linux-Input device.
+
+	  Right now only the keycode table for the default Remote Control
+	  delivered with the device is supported, please see the driver
+	  source code to find out how to add support for other controls.
+
+
+config DVB_CINERGYT2_RC_QUERY_INTERVAL
+	int "Infrared Remote Controller update interval [milliseconds]"
+	depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
+        default "100"
+	help
+	  If you have a very fast-repeating remote control you can try lower
+	  values, for normal consumer receivers the default value should be
+	  a safe choice.
+
diff -Nru a/drivers/media/dvb/cinergyT2/Makefile b/drivers/media/dvb/cinergyT2/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/cinergyT2/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,3 @@
+obj-$(CONFIG_DVB_CINERGYT2) += cinergyT2.o
+
+EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
diff -Nru a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,973 @@
+/*
+ * TerraTec Cinergy T²/qanu USB2 DVB-T adapter.
+ *
+ * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
+ *		    Holger Waechtler <holger@qanu.de>
+ *
+ *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
+ *
+ * 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.
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/slab.h>
+#include <linux/usb.h>
+#include <linux/pci.h>
+#include <linux/input.h>
+#include <linux/dvb/frontend.h>
+
+#include "dmxdev.h"
+#include "dvb_demux.h"
+#include "dvb_net.h"
+
+
+
+
+
+
+
+
+
+#ifdef CONFIG_DVB_CINERGYT2_TUNING
+	#define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT)
+	#define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE)
+	#define QUERY_INTERVAL (CONFIG_DVB_CINERGYT2_QUERY_INTERVAL)
+	#ifdef CONFIG_DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
+		#define RC_QUERY_INTERVAL (CONFIG_DVB_CINERGYT2_RC_QUERY_INTERVAL)
+		#define ENABLE_RC (1)
+	#endif
+#else
+	#define STREAM_URB_COUNT (32)
+	#define STREAM_BUF_SIZE (512)	/* bytes */
+	#define ENABLE_RC (1)
+	#define RC_QUERY_INTERVAL (100)	/* milliseconds */
+	#define QUERY_INTERVAL (333)	/* milliseconds */
+#endif
+
+#define DRIVER_NAME "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"
+
+static int debug;
+module_param_named(debug, debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
+
+#define dprintk(level, args...) \
+do {									\
+	if ((debug & level)) {						\
+		printk("%s: %s(): ", __stringify(KBUILD_MODNAME),	\
+		       __FUNCTION__);					\
+		printk(args); }						\
+} while (0)
+
+enum cinergyt2_ep1_cmd {
+	CINERGYT2_EP1_PID_TABLE_RESET		= 0x01,
+	CINERGYT2_EP1_PID_SETUP			= 0x02,
+	CINERGYT2_EP1_CONTROL_STREAM_TRANSFER 	= 0x03,
+	CINERGYT2_EP1_SET_TUNER_PARAMETERS 	= 0x04,
+	CINERGYT2_EP1_GET_TUNER_STATUS		= 0x05,
+	CINERGYT2_EP1_START_SCAN		= 0x06,
+	CINERGYT2_EP1_CONTINUE_SCAN		= 0x07,
+	CINERGYT2_EP1_GET_RC_EVENTS		= 0x08,
+	CINERGYT2_EP1_SLEEP_MODE		= 0x09
+};
+
+struct dvbt_set_parameters_msg {
+	uint8_t cmd;
+	uint32_t freq;
+	uint8_t bandwidth;
+	uint16_t tps;
+	uint8_t flags;
+} __attribute__((packed));
+
+struct dvbt_get_status_msg {
+	uint32_t freq;
+	uint8_t bandwidth;
+	uint16_t tps;
+	uint8_t flags;
+	uint16_t gain;
+	uint8_t snr;
+	uint32_t viterbi_error_rate;
+	uint32_t rs_error_rate;
+	uint32_t uncorrected_block_count;
+	uint8_t lock_bits;
+	uint8_t prev_lock_bits;
+} __attribute__((packed));
+
+static struct dvb_frontend_info cinergyt2_fe_info = {
+	.name = DRIVER_NAME,
+	.type = FE_OFDM,
+	.frequency_min = 174000000,
+	.frequency_max = 862000000,
+	.frequency_stepsize = 166667,
+	.caps = FE_CAN_INVERSION_AUTO | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
+		FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
+		FE_CAN_FEC_AUTO |
+		FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+		FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
+		FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER | FE_CAN_MUTE_TS
+};
+
+struct cinergyt2 {
+	struct dvb_demux demux;
+	struct usb_device *udev;
+	struct semaphore sem;
+	struct dvb_adapter *adapter;
+	struct dvb_device *fedev;
+	struct dmxdev dmxdev;
+	struct dvb_net dvbnet;
+
+	int streaming;
+	int sleeping;
+
+	struct dvbt_set_parameters_msg param;
+	struct dvbt_get_status_msg status;
+	struct work_struct query_work;
+
+	wait_queue_head_t poll_wq;
+	int pending_fe_events;
+
+	void *streambuf;
+	dma_addr_t streambuf_dmahandle;
+	struct urb *stream_urb[STREAM_URB_COUNT];
+
+#ifdef ENABLE_RC
+	struct input_dev rc_input_dev;
+	struct work_struct rc_query_work;
+	int rc_input_event;
+#endif
+};
+
+enum {
+	CINERGYT2_RC_EVENT_TYPE_NONE = 0x00,
+	CINERGYT2_RC_EVENT_TYPE_NEC  = 0x01,
+	CINERGYT2_RC_EVENT_TYPE_RC5  = 0x02
+};
+
+struct cinergyt2_rc_event {
+	char type;
+	uint32_t value;
+} __attribute__((packed));
+
+static const uint32_t rc_keys [] = {
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfe01eb04,	KEY_POWER,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfd02eb04,	KEY_1,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfc03eb04,	KEY_2,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfb04eb04,	KEY_3,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfa05eb04,	KEY_4,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf906eb04,	KEY_5,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf807eb04,	KEY_6,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf708eb04,	KEY_7,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf609eb04,	KEY_8,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf50aeb04,	KEY_9,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf30ceb04,	KEY_0,
+	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf40beb04,	KEY_VIDEO,
+	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf20deb04,	KEY_REFRESH,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf10eeb04,	KEY_SELECT,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf00feb04,	KEY_EPG,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xef10eb04,	KEY_UP,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xeb14eb04,	KEY_DOWN,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xee11eb04,	KEY_LEFT,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xec13eb04,	KEY_RIGHT,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xed12eb04,	KEY_OK,	
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xea15eb04,	KEY_TEXT,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe916eb04,	KEY_INFO,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe817eb04,	KEY_RED,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe718eb04,	KEY_GREEN,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe619eb04,	KEY_YELLOW,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe51aeb04,	KEY_BLUE,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe31ceb04,	KEY_VOLUMEUP,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe11eeb04,	KEY_VOLUMEDOWN,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe21deb04,	KEY_MUTE,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe41beb04,	KEY_CHANNELUP,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe01feb04,	KEY_CHANNELDOWN,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xbf40eb04,	KEY_PAUSE,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xb34ceb04,	KEY_PLAY,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xa758eb04,	KEY_RECORD,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xab54eb04,	KEY_PREVIOUS,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xb748eb04,	KEY_STOP,
+	CINERGYT2_RC_EVENT_TYPE_NEC, 	0xa35ceb04,	KEY_NEXT
+};
+
+static int cinergyt2_command (struct cinergyt2 *cinergyt2,
+		    char *send_buf, int send_buf_len,
+			      char *recv_buf, int recv_buf_len)
+{
+	int actual_len;
+	char dummy;
+	int ret;
+
+	ret = usb_bulk_msg(cinergyt2->udev, usb_sndbulkpipe(cinergyt2->udev, 1),
+			   send_buf, send_buf_len, &actual_len, HZ);
+
+	if (ret)
+		dprintk(1, "usb_bulk_msg (send) failed, err %i\n", ret);
+
+	if (!recv_buf)
+		recv_buf = &dummy;
+
+	ret = usb_bulk_msg(cinergyt2->udev, usb_rcvbulkpipe(cinergyt2->udev, 1),
+			   recv_buf, recv_buf_len, &actual_len, HZ);
+
+	if (ret)
+		dprintk(1, "usb_bulk_msg (read) failed, err %i\n", ret);
+
+	return ret ? ret : actual_len;
+}
+
+static void cinergyt2_control_stream_transfer (struct cinergyt2 *cinergyt2, int enable)
+{
+	char buf [] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
+  	cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 0);
+}
+
+static void cinergyt2_sleep (struct cinergyt2 *cinergyt2, int sleep)
+{
+	char buf [] = { CINERGYT2_EP1_SLEEP_MODE, sleep ? 1 : 0 };
+  	cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 0);
+	cinergyt2->sleeping = sleep;
+}
+
+static void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs);
+
+static int cinergyt2_submit_stream_urb (struct cinergyt2 *cinergyt2, struct urb *urb)
+{
+	int err;
+
+	usb_fill_bulk_urb(urb,
+			  cinergyt2->udev,
+			  usb_rcvbulkpipe(cinergyt2->udev, 0x2),
+			  urb->transfer_buffer,
+			  STREAM_BUF_SIZE,
+			  cinergyt2_stream_irq,
+			  cinergyt2);
+
+	if ((err = usb_submit_urb(urb, GFP_ATOMIC)))
+		dprintk(1, "urb submission failed (err = %i)!\n", err);
+
+	return err;
+}
+
+static void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs)
+{
+	struct cinergyt2 *cinergyt2 = urb->context;
+
+	if (urb->actual_length > 0)
+		dvb_dmx_swfilter(&cinergyt2->demux,
+				 urb->transfer_buffer, urb->actual_length);
+
+	if (cinergyt2->streaming)
+		cinergyt2_submit_stream_urb(cinergyt2, urb);
+}
+
+static void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
+{
+	int i;
+
+	for (i=0; i<STREAM_URB_COUNT; i++)
+		if (cinergyt2->stream_urb[i])
+			usb_free_urb(cinergyt2->stream_urb[i]);
+
+	pci_free_consistent(NULL, STREAM_URB_COUNT*STREAM_BUF_SIZE,
+			    cinergyt2->streambuf, cinergyt2->streambuf_dmahandle);
+}
+
+static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
+{
+	int i;
+
+	cinergyt2->streambuf = pci_alloc_consistent(NULL, 
+					      STREAM_URB_COUNT*STREAM_BUF_SIZE,
+					      &cinergyt2->streambuf_dmahandle);
+	if (!cinergyt2->streambuf) {
+		dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
+		return -ENOMEM;
+	}
+
+	memset(cinergyt2->streambuf, 0, STREAM_URB_COUNT*STREAM_BUF_SIZE);
+
+	for (i=0; i<STREAM_URB_COUNT; i++) {
+		struct urb *urb;	
+
+		if (!(urb = usb_alloc_urb(0, GFP_ATOMIC))) {
+			dprintk(1, "failed to alloc consistent stream urbs, bailing out!\n");
+			cinergyt2_free_stream_urbs(cinergyt2);
+			return -ENOMEM;
+		}
+
+		urb->transfer_buffer = cinergyt2->streambuf + i * STREAM_BUF_SIZE;
+		urb->transfer_buffer_length = STREAM_BUF_SIZE;
+
+		cinergyt2->stream_urb[i] = urb;
+	}
+
+	return 0;
+}
+
+static void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
+{
+	int i;
+
+	cinergyt2_control_stream_transfer(cinergyt2, 0);
+
+	for (i=0; i<STREAM_URB_COUNT; i++)
+		if (cinergyt2->stream_urb[i])
+			usb_kill_urb(cinergyt2->stream_urb[i]);
+}
+
+static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
+{
+	int i, err;
+
+	for (i=0; i<STREAM_URB_COUNT; i++) {
+		if ((err = cinergyt2_submit_stream_urb(cinergyt2, cinergyt2->stream_urb[i]))) {
+			cinergyt2_stop_stream_xfer(cinergyt2);
+			dprintk(1, "failed urb submission (%i: err = %i)!\n", i, err);
+			return err;
+		}
+	}
+
+	cinergyt2_control_stream_transfer(cinergyt2, 1);
+	return 0;
+}
+
+static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
+{
+	struct dvb_demux *demux = dvbdmxfeed->demux;
+	struct cinergyt2 *cinergyt2 = demux->priv;
+
+	if (down_interruptible(&cinergyt2->sem))
+		return -ERESTARTSYS;
+	
+	if (cinergyt2->streaming == 0)
+	       	cinergyt2_start_stream_xfer(cinergyt2);
+
+	cinergyt2->streaming++;
+	up(&cinergyt2->sem);
+	return 0;
+}
+
+static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
+{
+	struct dvb_demux *demux = dvbdmxfeed->demux;
+	struct cinergyt2 *cinergyt2 = demux->priv;	
+
+	if (down_interruptible(&cinergyt2->sem))
+		return -ERESTARTSYS;
+
+	if (--cinergyt2->streaming == 0)
+		cinergyt2_stop_stream_xfer(cinergyt2);
+
+	up(&cinergyt2->sem);
+	return 0;
+}
+
+/**
+ *  convert linux-dvb frontend parameter set into TPS.
+ *  See ETSI ETS-300744, section 4.6.2, table 9 for details.
+ *
+ *  This function is probably reusable and may better get placed in a support
+ *  library.
+ *
+ *  We replace errornous fields by default TPS fields (the ones with value 0).
+ */
+static uint16_t compute_tps (struct dvb_frontend_parameters *p)
+{
+	struct dvb_ofdm_parameters *op = &p->u.ofdm;
+	uint16_t tps = 0;
+
+	switch (op->code_rate_HP) {
+		case FEC_2_3:
+			tps |= (1 << 7);
+			break;
+		case FEC_3_4:
+			tps |= (2 << 7);
+			break;
+		case FEC_5_6:
+			tps |= (3 << 7);
+			break;
+		case FEC_7_8:
+			tps |= (4 << 7);
+			break;
+		case FEC_1_2:
+		case FEC_AUTO:
+		default:
+			/* tps |= (0 << 7) */;
+	}
+
+	switch (op->code_rate_LP) {
+		case FEC_2_3:
+			tps |= (1 << 4);
+			break;
+		case FEC_3_4:
+			tps |= (2 << 4);
+			break;
+		case FEC_5_6:
+			tps |= (3 << 4);
+			break;
+		case FEC_7_8:
+			tps |= (4 << 4);
+			break;
+		case FEC_1_2:
+		case FEC_AUTO:
+		default:
+			/* tps |= (0 << 4) */;
+	}
+
+	switch (op->constellation) {
+		case QAM_16:
+			tps |= (1 << 13);
+			break;
+		case QAM_64:
+			tps |= (2 << 13);
+			break;
+		case QPSK:
+		default:
+			/* tps |= (0 << 13) */;
+	}
+
+	switch (op->transmission_mode) {
+		case TRANSMISSION_MODE_8K:
+			tps |= (1 << 0);
+			break;
+		case TRANSMISSION_MODE_2K:
+		default:
+			/* tps |= (0 << 0) */;
+	}
+
+	switch (op->guard_interval) {
+		case GUARD_INTERVAL_1_16:
+			tps |= (1 << 2);
+			break;
+		case GUARD_INTERVAL_1_8:
+			tps |= (2 << 2);
+			break;
+		case GUARD_INTERVAL_1_4:
+			tps |= (3 << 2);
+			break;
+		case GUARD_INTERVAL_1_32:
+		default:
+			/* tps |= (0 << 2) */;
+	}
+
+	switch (op->hierarchy_information) {
+		case HIERARCHY_1:
+			tps |= (1 << 10);
+			break;
+		case HIERARCHY_2:
+			tps |= (2 << 10);
+			break;
+		case HIERARCHY_4:
+			tps |= (3 << 10);
+			break;
+		case HIERARCHY_NONE:
+		default:
+			/* tps |= (0 << 10) */;
+	}
+
+	return tps;
+}
+
+static int cinergyt2_open (struct inode *inode, struct file *file)
+{
+	struct dvb_device *dvbdev = file->private_data;
+	struct cinergyt2 *cinergyt2 = dvbdev->priv;
+	int err;
+
+	if ((err = dvb_generic_open(inode, file)))
+		return err;
+
+	if (down_interruptible(&cinergyt2->sem))
+		return -ERESTARTSYS;
+
+	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
+		cinergyt2_sleep(cinergyt2, 0);
+		schedule_delayed_work(&cinergyt2->query_work, HZ/2);
+}
+
+	up(&cinergyt2->sem);
+	return 0;
+}
+
+static int cinergyt2_release (struct inode *inode, struct file *file)
+{
+	struct dvb_device *dvbdev = file->private_data;
+	struct cinergyt2 *cinergyt2 = dvbdev->priv;
+
+	if (down_interruptible(&cinergyt2->sem))
+		return -ERESTARTSYS;
+
+	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
+		cancel_delayed_work(&cinergyt2->query_work);
+		flush_scheduled_work();
+		cinergyt2_sleep(cinergyt2, 1);
+	}
+
+	up(&cinergyt2->sem);
+
+	return dvb_generic_release(inode, file);
+	}
+
+static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct *wait)
+	{
+	struct dvb_device *dvbdev = file->private_data;
+	struct cinergyt2 *cinergyt2 = dvbdev->priv;
+	poll_wait(file, &cinergyt2->poll_wq, wait);
+	return (POLLIN | POLLRDNORM | POLLPRI);
+	}
+
+
+static int cinergyt2_ioctl (struct inode *inode, struct file *file,
+		     unsigned cmd, unsigned long arg)
+	{
+	struct dvb_device *dvbdev = file->private_data;
+	struct cinergyt2 *cinergyt2 = dvbdev->priv;
+	struct dvbt_get_status_msg *stat = &cinergyt2->status;
+	fe_status_t status = 0;
+
+	switch (cmd) {
+	case FE_GET_INFO:
+		return copy_to_user((void*) arg, &cinergyt2_fe_info,
+				    sizeof(struct dvb_frontend_info));
+
+	case FE_READ_STATUS:
+		if (0xffff - le16_to_cpu(stat->gain) > 30)
+			status |= FE_HAS_SIGNAL;
+		if (stat->lock_bits & (1 << 6))
+			status |= FE_HAS_LOCK;
+		if (stat->lock_bits & (1 << 5))
+			status |= FE_HAS_SYNC;
+		if (stat->lock_bits & (1 << 4))
+			status |= FE_HAS_CARRIER;
+		if (stat->lock_bits & (1 << 1))
+			status |= FE_HAS_VITERBI;
+
+		return copy_to_user((void *) arg, &status, sizeof(status));
+
+	case FE_READ_BER:
+		return put_user(le32_to_cpu(stat->viterbi_error_rate),
+				(__u32 __user *) arg);
+
+	case FE_READ_SIGNAL_STRENGTH:
+		return put_user(0xffff - le16_to_cpu(stat->gain),
+				(__u16 __user *) arg);
+
+	case FE_READ_SNR:
+		return put_user((stat->snr << 8) | stat->snr,
+				(__u16 __user *) arg);
+
+	case FE_READ_UNCORRECTED_BLOCKS:
+		/* UNC are already converted to host byte order... */
+		return put_user(stat->uncorrected_block_count,
+				(__u32 __user *) arg);
+	
+	case FE_SET_FRONTEND:
+	{
+		struct dvbt_set_parameters_msg *param = &cinergyt2->param;
+		struct dvb_frontend_parameters p;
+		int err;
+
+		if ((file->f_flags & O_ACCMODE) == O_RDONLY)
+			return -EPERM;
+
+		if (copy_from_user(&p, (void *) arg, sizeof(p)))
+			return -EFAULT;
+
+		if (down_interruptible(&cinergyt2->sem))
+			return -ERESTARTSYS;
+
+		param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
+		param->tps = cpu_to_le16(compute_tps(&p));
+		param->freq = cpu_to_le32(p.frequency / 1000);
+		param->bandwidth = 8 - p.u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
+
+		stat->lock_bits = 0;
+		cinergyt2->pending_fe_events++;
+		wake_up_interruptible(&cinergyt2->poll_wq);
+
+		err = cinergyt2_command(cinergyt2,
+					(char *) param, sizeof(*param),
+					NULL, 0);
+
+		up(&cinergyt2->sem);
+
+		return (err < 0) ? err : 0;
+	}
+
+	case FE_GET_FRONTEND:
+		/**
+		 *  trivial to implement (see struct dvbt_get_status_msg).
+		 *  equivalent to FE_READ ioctls, but needs 
+		 *  TPS -> linux-dvb parameter set conversion. Feel free
+		 *  to implement this and send us a patch if you need this
+		 *  functionality.
+		 */
+		break;
+
+	case FE_GET_EVENT:
+	{
+		/**
+		 *  for now we only fill the status field. the parameters
+		 *  are trivial to fill as soon FE_GET_FRONTEND is done.
+		 */
+		struct dvb_frontend_event *e = (void *) arg;
+		if (cinergyt2->pending_fe_events == 0) {
+			if (file->f_flags & O_NONBLOCK)
+				return -EWOULDBLOCK;
+			wait_event_interruptible(cinergyt2->poll_wq,
+						 cinergyt2->pending_fe_events > 0);
+		}
+		cinergyt2->pending_fe_events = 0;
+		return cinergyt2_ioctl(inode, file, FE_READ_STATUS,
+					(unsigned long) &e->status);
+	}
+
+	default:
+		;
+	}
+
+	return -EINVAL;
+}
+
+static int cinergyt2_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	struct dvb_device *dvbdev = file->private_data;
+	struct cinergyt2 *cinergyt2 = dvbdev->priv;
+	int ret = 0;
+
+	lock_kernel();
+
+	if (vma->vm_flags & (VM_WRITE | VM_EXEC)) {
+		ret = -EPERM;
+		goto bailout;
+	}
+
+	if (vma->vm_end > vma->vm_start + STREAM_URB_COUNT * STREAM_BUF_SIZE) {
+		ret = -EINVAL;
+		goto bailout;
+	}
+
+        vma->vm_flags |= (VM_IO | VM_DONTCOPY);
+	vma->vm_file = file;
+
+	ret = remap_pfn_range(vma, vma->vm_start,
+			      virt_to_phys(cinergyt2->streambuf) >> PAGE_SHIFT,
+			      vma->vm_end - vma->vm_start,
+			      vma->vm_page_prot) ? -EAGAIN : 0;
+bailout:
+	unlock_kernel();
+	return ret;
+}
+
+static struct file_operations cinergyt2_fops = {
+	.owner          = THIS_MODULE,
+	.ioctl		= cinergyt2_ioctl,
+	.poll           = cinergyt2_poll,
+	.open           = cinergyt2_open,
+	.release        = cinergyt2_release,
+	.mmap		= cinergyt2_mmap
+};
+
+static struct dvb_device cinergyt2_fe_template = {
+	.users = ~0,
+	.writers = 1,
+	.readers = (~0)-1,
+	.fops = &cinergyt2_fops
+};
+
+#ifdef ENABLE_RC
+static void cinergyt2_query_rc (void *data)
+{
+	struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data;
+	char buf [1] = { CINERGYT2_EP1_GET_RC_EVENTS };
+	struct cinergyt2_rc_event rc_events[12];
+	int n, len;
+
+	if (down_interruptible(&cinergyt2->sem))
+		return;
+
+	len = cinergyt2_command(cinergyt2, buf, sizeof(buf), 
+			     (char *) rc_events, sizeof(rc_events));
+
+	for (n=0; len>0 && n<(len/sizeof(rc_events[0])); n++) {
+		int i;
+
+		if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC &&
+		    rc_events[n].value == ~0)
+		{
+			/**
+			 * keyrepeat bit. If we would handle this properly
+			 * we would need to emit down events as long the
+			 * keyrepeat goes, a up event if no further 
+			 * repeat bits occur. Would need a timer to implement
+			 * and no other driver does this, so we simply
+			 * emit the last key up/down sequence again.
+			 */
+		} else {
+			cinergyt2->rc_input_event = KEY_MAX;
+			for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i+=3) {
+				if (rc_keys[i+0] == rc_events[n].type &&
+				    rc_keys[i+1] == rc_events[n].value)
+				{
+					cinergyt2->rc_input_event = rc_keys[i+2];
+					break;
+				}
+			}
+		}
+
+		if (cinergyt2->rc_input_event != KEY_MAX) {
+			input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 1);
+			input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 0);
+			input_sync(&cinergyt2->rc_input_dev);
+	    	}
+	}
+
+	schedule_delayed_work(&cinergyt2->rc_query_work,
+			      msecs_to_jiffies(RC_QUERY_INTERVAL));
+
+	up(&cinergyt2->sem);
+}
+#endif
+
+static void cinergyt2_query (void *data)
+{
+	struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data;
+	char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	struct dvbt_get_status_msg *s = &cinergyt2->status;
+	uint8_t lock_bits;
+	uint32_t unc;
+
+	if (down_interruptible(&cinergyt2->sem))
+		return;
+
+	unc = s->uncorrected_block_count;
+	lock_bits = s->lock_bits;
+
+	cinergyt2_command(cinergyt2, cmd, sizeof(cmd), (char *) s, sizeof(*s));
+
+	unc += le32_to_cpu(s->uncorrected_block_count);
+	s->uncorrected_block_count = unc;
+
+	if (lock_bits != s->lock_bits) {
+		wake_up_interruptible(&cinergyt2->poll_wq);
+		cinergyt2->pending_fe_events++;
+	}
+
+	schedule_delayed_work(&cinergyt2->query_work,
+			      msecs_to_jiffies(QUERY_INTERVAL));
+
+	up(&cinergyt2->sem);
+}
+
+static int cinergyt2_probe (struct usb_interface *intf,
+		  const struct usb_device_id *id)
+{
+	struct cinergyt2 *cinergyt2;
+	int i, err;
+
+	if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) {
+		dprintk(1, "out of memory?!?\n");
+		return -ENOMEM;
+	}
+
+	memset (cinergyt2, 0, sizeof (struct cinergyt2));
+	usb_set_intfdata (intf, (void *) cinergyt2);
+
+	init_MUTEX(&cinergyt2->sem);
+	init_waitqueue_head (&cinergyt2->poll_wq);
+	INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2);
+
+	cinergyt2->udev = interface_to_usbdev(intf);
+	cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
+	
+	if (cinergyt2_alloc_stream_urbs (cinergyt2) < 0) {
+		dprintk(1, "unable to allocate stream urbs\n");
+		kfree(cinergyt2);
+		return -ENOMEM;
+	}
+
+	dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE);
+
+	cinergyt2->demux.priv = cinergyt2;
+	cinergyt2->demux.filternum = 256;
+	cinergyt2->demux.feednum = 256;
+	cinergyt2->demux.start_feed = cinergyt2_start_feed;
+	cinergyt2->demux.stop_feed = cinergyt2_stop_feed;
+	cinergyt2->demux.dmx.capabilities = DMX_TS_FILTERING |
+					 DMX_SECTION_FILTERING |
+					 DMX_MEMORY_BASED_FILTERING;
+
+	if ((err = dvb_dmx_init(&cinergyt2->demux)) < 0) {
+		dprintk(1, "dvb_dmx_init() failed (err = %d)\n", err);
+		goto bailout;
+	}
+
+	cinergyt2->dmxdev.filternum = cinergyt2->demux.filternum;
+	cinergyt2->dmxdev.demux = &cinergyt2->demux.dmx;
+	cinergyt2->dmxdev.capabilities = 0;
+
+	if ((err = dvb_dmxdev_init(&cinergyt2->dmxdev, cinergyt2->adapter)) < 0) {
+		dprintk(1, "dvb_dmxdev_init() failed (err = %d)\n", err);
+		goto bailout;
+	}
+
+	if (dvb_net_init(cinergyt2->adapter, &cinergyt2->dvbnet, &cinergyt2->demux.dmx))
+		dprintk(1, "dvb_net_init() failed!\n");
+
+	dvb_register_device(cinergyt2->adapter, &cinergyt2->fedev,
+			    &cinergyt2_fe_template, cinergyt2,
+			    DVB_DEVICE_FRONTEND);
+
+#ifdef ENABLE_RC
+	init_input_dev(&cinergyt2->rc_input_dev);			
+
+	cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY);
+	cinergyt2->rc_input_dev.keycodesize = sizeof(unsigned char);
+	cinergyt2->rc_input_dev.keycodemax = KEY_MAX;
+	cinergyt2->rc_input_dev.name = DRIVER_NAME " remote control";
+
+	for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i+=3)
+		set_bit(rc_keys[i+2], cinergyt2->rc_input_dev.keybit);
+
+	input_register_device(&cinergyt2->rc_input_dev);
+
+	cinergyt2->rc_input_event = KEY_MAX;
+	
+	INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2);
+	schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
+#endif
+	return 0;
+
+bailout:
+	dvb_dmxdev_release(&cinergyt2->dmxdev);
+	dvb_dmx_release(&cinergyt2->demux);
+	dvb_unregister_adapter (cinergyt2->adapter);
+	cinergyt2_free_stream_urbs (cinergyt2);
+	kfree(cinergyt2);
+	return -ENOMEM;
+}
+
+static void cinergyt2_disconnect (struct usb_interface *intf)
+{
+	struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
+
+	if (down_interruptible(&cinergyt2->sem))
+		return;
+
+#ifdef ENABLE_RC
+	cancel_delayed_work(&cinergyt2->rc_query_work);
+	flush_scheduled_work();
+	input_unregister_device(&cinergyt2->rc_input_dev);
+#endif
+
+	cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx);
+	dvb_net_release(&cinergyt2->dvbnet);
+	dvb_dmxdev_release(&cinergyt2->dmxdev);
+	dvb_dmx_release(&cinergyt2->demux);
+
+	dvb_unregister_device(cinergyt2->fedev);
+	dvb_unregister_adapter(cinergyt2->adapter);
+
+	cinergyt2_free_stream_urbs(cinergyt2);
+	up(&cinergyt2->sem);
+	kfree(cinergyt2);
+}
+
+static int cinergyt2_suspend (struct usb_interface *intf, u32 state)
+{
+	struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
+
+	if (down_interruptible(&cinergyt2->sem))
+		return -ERESTARTSYS;
+
+	if (state > 0) {	/* state 0 seems to mean DEVICE_PM_ON */
+		struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
+#ifdef ENABLE_RC
+		cancel_delayed_work(&cinergyt2->rc_query_work);
+#endif
+		cancel_delayed_work(&cinergyt2->query_work);
+		if (cinergyt2->streaming)
+		       	cinergyt2_stop_stream_xfer(cinergyt2);
+		flush_scheduled_work();
+		cinergyt2_sleep(cinergyt2, 1);
+	}
+
+	up(&cinergyt2->sem);
+	return 0;
+}
+
+static int cinergyt2_resume (struct usb_interface *intf)
+{
+	struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
+	struct dvbt_set_parameters_msg *param = &cinergyt2->param;
+
+	if (down_interruptible(&cinergyt2->sem))
+		return -ERESTARTSYS;
+
+	if (!cinergyt2->sleeping) {
+		cinergyt2_sleep(cinergyt2, 0);
+		cinergyt2_command(cinergyt2, (char *) param, sizeof(*param), NULL, 0);
+		if (cinergyt2->streaming)
+		       	cinergyt2_start_stream_xfer(cinergyt2);
+		schedule_delayed_work(&cinergyt2->query_work, HZ/2);
+	}
+
+#ifdef ENABLE_RC
+	schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
+#endif
+	up(&cinergyt2->sem);
+	return 0;
+}
+
+static const struct usb_device_id cinergyt2_table [] __devinitdata = {
+	{ USB_DEVICE(0x0ccd, 0x0038) },
+	{ 0 }
+};
+
+MODULE_DEVICE_TABLE(usb, cinergyt2_table);
+
+static struct usb_driver cinergyt2_driver = {
+	.owner 		= THIS_MODULE,
+	.name	= "cinergyT2",
+	.probe 		= cinergyt2_probe,
+	.disconnect 	= cinergyt2_disconnect,
+	.suspend	= cinergyt2_suspend,
+	.resume		= cinergyt2_resume,
+	.id_table 	= cinergyt2_table
+};
+
+static int __init cinergyt2_init (void)
+{
+	int err;
+
+	if ((err = usb_register(&cinergyt2_driver)) < 0)
+		dprintk(1, "usb_register() failed! (err %i)\n", err);
+
+	return err;
+}
+
+static void __exit cinergyt2_exit (void)
+{
+	usb_deregister(&cinergyt2_driver);
+}
+
+module_init (cinergyt2_init);
+module_exit (cinergyt2_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Holger Waechtler, Daniel Mack");
+
diff -Nru a/drivers/media/dvb/dibusb/Kconfig b/drivers/media/dvb/dibusb/Kconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/dibusb/Kconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,57 @@
+config DVB_DIBUSB
+	tristate "DiBcom USB DVB-T devices (see help for device list)"
+	depends on DVB_CORE && USB
+	select FW_LOADER
+	select DVB_DIB3000MB
+	select DVB_DIB3000MC
+	help
+	  Support for USB 1.1 and 2.0 DVB-T devices based on reference designs made by
+	  DiBcom (http://www.dibcom.fr).
+
+	  Devices supported by this driver:
+
+	    TwinhanDTV USB-Ter (VP7041)
+		TwinhanDTV Magic Box (VP7041e)
+	    KWorld V-Stream XPERT DTV - DVB-T USB
+	    Hama DVB-T USB-Box
+	    DiBcom reference device (non-public)
+	    Ultima Electronic/Artec T1 USB TVBOX
+	    Compro Videomate DVB-U2000 - DVB-T USB
+	    Grandtec DVB-T USB
+	    Avermedia AverTV DVBT USB
+	    Yakumo DVB-T mobile USB2.0
+
+	  The VP7041 seems to be identical to "CTS Portable" (Chinese
+	  Television System).
+
+	  These devices can be understood as budget ones, they "only" deliver
+	  (a part of) the MPEG2 transport stream.
+
+	  A firmware is needed to get the device working. See Documentation/dvb/README.dibusb
+	  details.
+
+	  Say Y if you own such a device and want to use it. You should build it as
+	  a module.
+
+config DVB_DIBUSB_MISDESIGNED_DEVICES
+	bool "Enable support for some misdesigned (see help) devices, which identify with wrong IDs"
+	depends on DVB_DIBUSB
+	help
+	  Somehow Artec/Ultima Electronic forgot to program the eeprom of some of their
+	  USB1.1/USB2.0 devices.
+	  So comes that they identify with the default Vendor and Product ID of the Cypress
+	  CY7C64613 (AN2235) or Cypress FX2.
+
+	  Affected device IDs:
+	    0x0574:0x2235 (Artec T1 USB1.1, cold)
+	    0x04b4:0x8613 (Artec T1 USB2.0, cold)
+	    0x0574:0x1002 (Artec T1 USB2.0, warm)
+
+	  Say Y if your device has one of the mentioned IDs.
+
+config DVB_DIBCOM_DEBUG
+	bool "Enable extended debug support for DiBcom USB device"
+	depends on DVB_DIBUSB
+	help
+	  Say Y if you want to enable debuging. See modinfo dvb-dibusb for
+	  debug levels.
diff -Nru a/drivers/media/dvb/dibusb/Makefile b/drivers/media/dvb/dibusb/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/dibusb/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,3 @@
+obj-$(CONFIG_DVB_DIBUSB) += dvb-dibusb.o
+
+EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff -Nru a/drivers/media/dvb/dibusb/dvb-dibusb.c b/drivers/media/dvb/dibusb/dvb-dibusb.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/dibusb/dvb-dibusb.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1032 @@
+/*
+ * Driver for mobile USB Budget DVB-T devices based on reference
+ * design made by DiBcom (http://www.dibcom.fr/)
+ *
+ * dvb-dibusb.c
+ *
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ *
+ * based on GPL code from DiBcom, which has
+ * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ *
+ * Remote control code added by David Matthews (dm@prolingua.co.uk)
+ *
+ *	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, version 2.
+ *
+ * Acknowledgements
+ *
+ *  Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
+ *  sources, on which this driver (and the dib3000mb/mc/p frontends) are based.
+ *
+ * see Documentation/dvb/README.dibusb for more information
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/usb.h>
+#include <linux/firmware.h>
+#include <linux/version.h>
+#include <linux/moduleparam.h>
+#include <linux/pci.h>
+#include <linux/input.h>
+
+#include "dmxdev.h"
+#include "dvb_demux.h"
+#include "dvb_filter.h"
+#include "dvb_net.h"
+#include "dvb_frontend.h"
+#include "dib3000.h"
+
+#include "dvb-dibusb.h"
+
+
+/* debug */
+#ifdef CONFIG_DVB_DIBCOM_DEBUG
+#define dprintk(level,args...) \
+	    do { if ((debug & level)) { printk(args); } } while (0)
+
+#define debug_dump(b,l) if (debug) {\
+	int i; deb_xfer("%s: %d > ",__FUNCTION__,l); \
+	for (i = 0; i < l; i++) deb_xfer("%02x ", b[i]); \
+	deb_xfer("\n");\
+}
+
+static int debug;
+module_param(debug, int, 0x644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=alotmore,8=ts,16=err,32=rc (|-able)).");
+#else
+#define dprintk(args...)
+#define debug_dump(b,l)
+#endif
+
+#define deb_info(args...) dprintk(0x01,args)
+#define deb_xfer(args...) dprintk(0x02,args)
+#define deb_alot(args...) dprintk(0x04,args)
+#define deb_ts(args...)   dprintk(0x08,args)
+#define deb_err(args...)   dprintk(0x10,args)
+#define deb_rc(args...)   dprintk(0x20,args)
+
+static int pid_parse;
+module_param(pid_parse, int, 0x644);
+MODULE_PARM_DESC(pid_parse, "enable pid parsing (filtering) when running at USB2.0");
+
+/* Version information */
+#define DRIVER_VERSION "0.1"
+#define DRIVER_DESC "Driver for DiBcom based USB Budget DVB-T device"
+#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
+
+static int dibusb_readwrite_usb(struct usb_dibusb *dib,
+		u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
+{
+	int actlen,ret = -ENOMEM;
+
+	if (wbuf == NULL || wlen == 0)
+		return -EINVAL;
+
+	if ((ret = down_interruptible(&dib->usb_sem)))
+		return ret;
+
+	if (dib->feedcount &&
+		wbuf[0] == DIBUSB_REQ_I2C_WRITE &&
+		dib->dibdev->parm->type == DIBUSB1_1)
+		deb_err("BUG: writing to i2c, while TS-streaming destroys the stream."
+				"(%x reg: %x %x)\n", wbuf[0],wbuf[2],wbuf[3]);
+			
+	debug_dump(wbuf,wlen);
+
+	ret = usb_bulk_msg(dib->udev,usb_sndbulkpipe(dib->udev,
+			dib->dibdev->parm->cmd_pipe), wbuf,wlen,&actlen,
+			DIBUSB_I2C_TIMEOUT);
+
+	if (ret)
+		err("bulk message failed: %d (%d/%d)",ret,wlen,actlen);
+	else
+		ret = actlen != wlen ? -1 : 0;
+
+	/* an answer is expected, and no error before */
+	if (!ret && rbuf && rlen) {
+		ret = usb_bulk_msg(dib->udev,usb_rcvbulkpipe(dib->udev,
+				dib->dibdev->parm->result_pipe),rbuf,rlen,&actlen,
+				DIBUSB_I2C_TIMEOUT);
+
+		if (ret)
+			err("recv bulk message failed: %d",ret);
+		else {
+			deb_alot("rlen: %d\n",rlen);
+			debug_dump(rbuf,actlen);
+		}
+	}
+
+	up(&dib->usb_sem);
+	return ret;
+}
+
+static int dibusb_i2c_msg(struct usb_dibusb *dib, u8 addr,
+		u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
+{
+	u8 sndbuf[wlen+4]; /* lead(1) devaddr,direction(1) addr(2) data(wlen) (len(2) (when reading)) */
+	/* write only ? */
+	int wo = (rbuf == NULL || rlen == 0),
+		len = 2 + wlen + (wo ? 0 : 2);
+
+	deb_alot("wo: %d, wlen: %d, len: %d\n",wo,wlen,len);
+
+	sndbuf[0] = wo ? DIBUSB_REQ_I2C_WRITE : DIBUSB_REQ_I2C_READ;
+	sndbuf[1] = (addr & 0xfe) | (wo ? 0 : 1);
+
+	memcpy(&sndbuf[2],wbuf,wlen);
+
+	if (!wo) {
+		sndbuf[wlen+2] = (rlen >> 8) & 0xff;
+		sndbuf[wlen+3] = rlen & 0xff;
+	}
+
+	return dibusb_readwrite_usb(dib,sndbuf,len,rbuf,rlen);
+}
+
+/*
+ * DVB stuff
+ */
+static void dibusb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
+{
+	struct usb_dibusb *dib = urb->context;
+
+	deb_ts("urb complete feedcount: %d, status: %d\n",dib->feedcount,urb->status);
+
+	if (dib->feedcount > 0 && urb->status == 0) {
+		deb_ts("URB return len: %d\n",urb->actual_length);
+		if (urb->actual_length % 188)
+			deb_ts("TS Packets: %d, %d\n", urb->actual_length/188,urb->actual_length % 188);
+
+		/* Francois recommends to drop not full-filled packets, even if they may 
+		 * contain valid TS packets
+		 */
+		if (urb->actual_length == dib->dibdev->parm->default_size && dib->dvb_is_ready)
+		dvb_dmx_swfilter_packets(&dib->demux, (u8*) urb->transfer_buffer,urb->actual_length/188);
+		else
+			deb_ts("URB dropped because of the " 
+					"actual_length or !dvb_is_ready (%d).\n",dib->dvb_is_ready);
+	} else 
+		deb_ts("URB dropped because of feedcount or status.\n");
+
+		usb_submit_urb(urb,GFP_KERNEL);
+}
+
+static int dibusb_ctrl_feed(struct usb_dibusb *dib, int pid, int onoff)
+{
+	if (dib->dibdev->parm->firmware_bug && dib->feedcount) {
+		deb_ts("stop feeding\n");
+		if (dib->xfer_ops.fifo_ctrl != NULL) {
+			if (dib->xfer_ops.fifo_ctrl(dib->fe,0)) {
+				err("error while inhibiting fifo.");
+				return -ENODEV;
+			}
+		} else {
+			err("fifo_ctrl is not set.");
+			return -ENODEV;
+		}
+	}
+
+	dib->feedcount += onoff ? 1 : -1;
+
+	if (dib->pid_parse) {
+	if (dib->xfer_ops.pid_ctrl != NULL) {
+		if (dib->xfer_ops.pid_ctrl(dib->fe,pid,onoff) < 0) {
+		err("no free pid in list.");
+		return -ENODEV;
+	}
+	} else {
+		err("no pid ctrl callback.");
+		return -ENODEV;
+	}
+	}
+	/*
+	 * start the feed, either if there is the firmware bug or
+	 * if this was the first pid to set.
+	 */
+	if (dib->dibdev->parm->firmware_bug || dib->feedcount == onoff) {
+
+		deb_ts("controlling pid parser\n");
+		if (dib->xfer_ops.pid_parse != NULL) {
+			if (dib->xfer_ops.pid_parse(dib->fe,dib->pid_parse) < 0) {
+				err("could not handle pid_parser");
+			}
+		}
+
+		deb_ts("start feeding\n");
+		if (dib->xfer_ops.fifo_ctrl != NULL) {
+			if (dib->xfer_ops.fifo_ctrl(dib->fe,1)) {
+				err("error while enabling fifo.");
+				return -ENODEV;
+			}
+		} else {
+			err("fifo_ctrl is not set.");
+			return -ENODEV;
+}
+	}
+	return 0;
+}
+
+static int dibusb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
+{
+	struct usb_dibusb *dib = dvbdmxfeed->demux->priv;
+	deb_ts("pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid,dvbdmxfeed->type);
+	dvbdmxfeed->priv = dib;
+	return dibusb_ctrl_feed(dib,dvbdmxfeed->pid,1);
+}
+
+static int dibusb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
+{
+	struct usb_dibusb *dib = (struct usb_dibusb *) dvbdmxfeed->priv;
+	if (dib == NULL) {
+		err("dib in dmxfeed->priv was NULL");
+		return -EINVAL;
+}
+	deb_ts("dvbdmxfeed pid: 0x%04x, feedtype: %d\n",
+			dvbdmxfeed->pid, dvbdmxfeed->type);
+	return dibusb_ctrl_feed(dib,dvbdmxfeed->pid,0);
+}
+
+/* Table to map raw key codes to key events.  This should not be hard-wired
+   into the kernel.  */
+static const struct { u8 c0, c1, c2; uint32_t key; } rc_keys [] =
+{
+	/* Key codes for the little Artec T1/Twinhan/HAMA/ remote. */
+	{ 0x00, 0xff, 0x16, KEY_POWER },
+	{ 0x00, 0xff, 0x10, KEY_MUTE },
+	{ 0x00, 0xff, 0x03, KEY_1 },
+	{ 0x00, 0xff, 0x01, KEY_2 },
+	{ 0x00, 0xff, 0x06, KEY_3 },
+	{ 0x00, 0xff, 0x09, KEY_4 },
+	{ 0x00, 0xff, 0x1d, KEY_5 },
+	{ 0x00, 0xff, 0x1f, KEY_6 },
+	{ 0x00, 0xff, 0x0d, KEY_7 },
+	{ 0x00, 0xff, 0x19, KEY_8 },
+	{ 0x00, 0xff, 0x1b, KEY_9 },
+	{ 0x00, 0xff, 0x15, KEY_0 },
+	{ 0x00, 0xff, 0x05, KEY_CHANNELUP },
+	{ 0x00, 0xff, 0x02, KEY_CHANNELDOWN },
+	{ 0x00, 0xff, 0x1e, KEY_VOLUMEUP },
+	{ 0x00, 0xff, 0x0a, KEY_VOLUMEDOWN },
+	{ 0x00, 0xff, 0x11, KEY_RECORD },
+	{ 0x00, 0xff, 0x17, KEY_FAVORITES }, /* Heart symbol - Channel list. */
+	{ 0x00, 0xff, 0x14, KEY_PLAY },
+	{ 0x00, 0xff, 0x1a, KEY_STOP },
+	{ 0x00, 0xff, 0x40, KEY_REWIND },
+	{ 0x00, 0xff, 0x12, KEY_FASTFORWARD },
+	{ 0x00, 0xff, 0x0e, KEY_PREVIOUS }, /* Recall - Previous channel. */
+	{ 0x00, 0xff, 0x4c, KEY_PAUSE },
+	{ 0x00, 0xff, 0x4d, KEY_SCREEN }, /* Full screen mode. */
+	{ 0x00, 0xff, 0x54, KEY_AUDIO }, /* MTS - Switch to secondary audio. */
+	/* additional keys TwinHan VisionPlus, the Artec seemingly not have */
+	{ 0x00, 0xff, 0x0c, KEY_CANCEL }, /* Cancel */
+	{ 0x00, 0xff, 0x1c, KEY_EPG }, /* EPG */
+	{ 0x00, 0xff, 0x00, KEY_TAB }, /* Tab */
+	{ 0x00, 0xff, 0x48, KEY_INFO }, /* Preview */
+	{ 0x00, 0xff, 0x04, KEY_LIST }, /* RecordList */
+	{ 0x00, 0xff, 0x0f, KEY_TEXT }, /* Teletext */
+	/* Key codes for the KWorld/ADSTech/JetWay remote. */
+	{ 0x86, 0x6b, 0x12, KEY_POWER },
+	{ 0x86, 0x6b, 0x0f, KEY_SELECT }, /* source */
+	{ 0x86, 0x6b, 0x0c, KEY_UNKNOWN }, /* scan */
+	{ 0x86, 0x6b, 0x0b, KEY_EPG },
+	{ 0x86, 0x6b, 0x10, KEY_MUTE },
+	{ 0x86, 0x6b, 0x01, KEY_1 },
+	{ 0x86, 0x6b, 0x02, KEY_2 },
+	{ 0x86, 0x6b, 0x03, KEY_3 },
+	{ 0x86, 0x6b, 0x04, KEY_4 },
+	{ 0x86, 0x6b, 0x05, KEY_5 },
+	{ 0x86, 0x6b, 0x06, KEY_6 },
+	{ 0x86, 0x6b, 0x07, KEY_7 },
+	{ 0x86, 0x6b, 0x08, KEY_8 },
+	{ 0x86, 0x6b, 0x09, KEY_9 },
+	{ 0x86, 0x6b, 0x0a, KEY_0 },
+	{ 0x86, 0x6b, 0x18, KEY_ZOOM },
+	{ 0x86, 0x6b, 0x1c, KEY_UNKNOWN }, /* preview */
+	{ 0x86, 0x6b, 0x13, KEY_UNKNOWN }, /* snap */
+	{ 0x86, 0x6b, 0x00, KEY_UNDO },
+	{ 0x86, 0x6b, 0x1d, KEY_RECORD },
+	{ 0x86, 0x6b, 0x0d, KEY_STOP },
+	{ 0x86, 0x6b, 0x0e, KEY_PAUSE },
+	{ 0x86, 0x6b, 0x16, KEY_PLAY },
+	{ 0x86, 0x6b, 0x11, KEY_BACK },
+	{ 0x86, 0x6b, 0x19, KEY_FORWARD },
+	{ 0x86, 0x6b, 0x14, KEY_UNKNOWN }, /* pip */
+	{ 0x86, 0x6b, 0x15, KEY_ESC },
+	{ 0x86, 0x6b, 0x1a, KEY_UP },
+	{ 0x86, 0x6b, 0x1e, KEY_DOWN },
+	{ 0x86, 0x6b, 0x1f, KEY_LEFT },
+	{ 0x86, 0x6b, 0x1b, KEY_RIGHT },
+};
+
+/*
+ * Read the remote control and feed the appropriate event.
+ * NEC protocol is used for remote controls
+ */
+static int dibusb_read_remote_control(struct usb_dibusb *dib)
+{
+	u8 b[1] = { DIBUSB_REQ_POLL_REMOTE }, rb[5];
+	int ret;
+	int i;
+	if ((ret = dibusb_readwrite_usb(dib,b,1,rb,5)))
+		return ret;
+
+	switch (rb[0]) {
+		case DIBUSB_RC_NEC_KEY_PRESSED:
+			/* rb[1-3] is the actual key, rb[4] is a checksum */
+			deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
+				rb[1], rb[2], rb[3], rb[4]);
+
+			if ((0xff - rb[3]) != rb[4]) {
+				deb_rc("remote control checksum failed.\n");
+				break;
+			}
+
+			/* See if we can match the raw key code. */
+			for (i = 0; i < sizeof(rc_keys)/sizeof(rc_keys[0]); i++) {
+				if (rc_keys[i].c0 == rb[1] &&
+					rc_keys[i].c1 == rb[2] &&
+				    rc_keys[i].c2 == rb[3]) {
+					dib->rc_input_event = rc_keys[i].key;
+					deb_rc("Translated key 0x%04x\n", dib->rc_input_event);
+					/* Signal down and up events for this key. */
+					input_report_key(&dib->rc_input_dev, dib->rc_input_event, 1);
+					input_report_key(&dib->rc_input_dev, dib->rc_input_event, 0);
+					input_sync(&dib->rc_input_dev);
+					break;
+				}
+			}
+			break;
+		case DIBUSB_RC_NEC_EMPTY: /* No (more) remote control keys. */
+			break;
+		case DIBUSB_RC_NEC_KEY_REPEATED:
+			/* rb[1]..rb[4] are always zero.*/
+			/* Repeats often seem to occur so for the moment just ignore this. */
+			deb_rc("Key repeat\n");
+			break;
+		default:
+			break;
+	}
+	
+	return 0;
+}
+
+#define RC_QUERY_INTERVAL (100)	/* milliseconds */
+
+/* Remote-control poll function - called every RC_QUERY_INTERVAL ms to see
+   whether the remote control has received anything. */
+static void dibusb_query_rc (void *data)
+{
+	struct usb_dibusb *dib = (struct usb_dibusb *) data;
+	/* TODO: need a lock here.  We can simply skip checking for the remote control
+	   if we're busy. */
+	dibusb_read_remote_control(dib);
+	schedule_delayed_work(&dib->rc_query_work,
+			      msecs_to_jiffies(RC_QUERY_INTERVAL));
+}
+
+/*
+ * Cypress controls
+ */
+
+#if 0
+/*
+ * #if 0'ing the following functions as they are not in use _now_,
+ * but probably will be sometime.
+ */
+
+/*
+ * do not use this, just a workaround for a bug,
+ * which will hopefully never occur :).
+ */
+static int dibusb_interrupt_read_loop(struct usb_dibusb *dib)
+{
+	u8 b[1] = { DIBUSB_REQ_INTR_READ };
+	return dibusb_write_usb(dib,b,1);
+}
+
+/*
+ * ioctl for power control
+ */
+static int dibusb_hw_sleep(struct usb_dibusb *dib)
+{
+	u8 b[1] = { DIBUSB_IOCTL_POWER_SLEEP };
+	return dibusb_ioctl_cmd(dib,DIBUSB_IOCTL_CMD_POWER_MODE, b,1);
+}
+
+#endif
+static int dibusb_write_usb(struct usb_dibusb *dib, u8 *buf, u16 len)
+{
+	return dibusb_readwrite_usb(dib,buf,len,NULL,0);
+}
+
+/*
+ * ioctl for the firmware
+ */
+static int dibusb_ioctl_cmd(struct usb_dibusb *dib, u8 cmd, u8 *param, int plen)
+{
+	u8 b[34];
+	int size = plen > 32 ? 32 : plen;
+	b[0] = DIBUSB_REQ_SET_IOCTL;
+	b[1] = cmd;
+	memcpy(&b[2],param,size);
+
+	return dibusb_write_usb(dib,b,2+size);
+}
+
+static int dibusb_hw_wakeup(struct usb_dibusb *dib)
+{
+	u8 b[1] = { DIBUSB_IOCTL_POWER_WAKEUP };
+	return dibusb_ioctl_cmd(dib,DIBUSB_IOCTL_CMD_POWER_MODE, b,1);
+}
+
+/*
+ * I2C
+ */
+static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
+{
+	struct usb_dibusb *dib = i2c_get_adapdata(adap);
+	int i;
+
+	if (down_interruptible(&dib->i2c_sem) < 0)
+		return -EAGAIN;
+
+	for (i = 0; i < num; i++) {
+		/* write/read request */
+		if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
+			if (dibusb_i2c_msg(dib, msg[i].addr, msg[i].buf,msg[i].len,
+						msg[i+1].buf,msg[i+1].len) < 0)
+				break;
+			i++;
+		} else
+			if (dibusb_i2c_msg(dib, msg[i].addr, msg[i].buf,msg[i].len,NULL,0) < 0)
+				break;
+	}
+
+	up(&dib->i2c_sem);
+	return i;
+}
+
+static u32 dibusb_i2c_func(struct i2c_adapter *adapter)
+{
+	return I2C_FUNC_I2C;
+}
+
+static int thomson_cable_eu_pll_set(struct dvb_frontend* fe, struct
+		dvb_frontend_parameters* params);
+
+static struct dib3000_config thomson_cable_eu_config = {
+	.demod_address = 0x10,
+	.pll_addr = 194,
+	.pll_set = thomson_cable_eu_pll_set,
+};
+
+static int thomson_cable_eu_pll_set(struct dvb_frontend* fe, struct
+		dvb_frontend_parameters* params)
+{
+	struct usb_dibusb* dib = (struct usb_dibusb*) fe->dvb->priv;
+	u8 buf[4];
+	struct i2c_msg msg = {
+		.addr = thomson_cable_eu_config.pll_addr,
+		.flags = 0,
+		.buf = buf,
+		.len = sizeof(buf)
+	};
+	u32 tfreq = (params->frequency + 36125000) / 62500;
+	int vu,p0,p1,p2;
+
+	if (params->frequency > 403250000)
+		vu = 1, p2 = 1, p1 = 0, p0 = 1;
+	else if (params->frequency > 115750000)
+		vu = 0, p2 = 1, p1 = 1, p0 = 0;
+	else if (params->frequency > 44250000)
+		vu = 0, p2 = 0, p1 = 1, p0 = 1;
+	else
+		return -EINVAL;
+
+	buf[0] = (tfreq >> 8) & 0x7f;
+	buf[1] = tfreq & 0xff;
+   	buf[2] = 0x8e;
+   	buf[3] = (vu << 7) | (p2 << 2) | (p1 << 1) | p0;
+
+	if (i2c_transfer (&dib->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+
+	msleep(1);
+	return 0;
+}
+
+static int panasonic_cofdm_env57h1xd5_pll_set(struct dvb_frontend *fe, struct
+		dvb_frontend_parameters *params);
+
+static struct dib3000_config panasonic_cofdm_env57h1xd5 = {
+	.demod_address = 0x18,
+	.pll_addr = 192,
+	.pll_set = panasonic_cofdm_env57h1xd5_pll_set,
+};
+
+static int panasonic_cofdm_env57h1xd5_pll_set(struct dvb_frontend *fe, struct
+		dvb_frontend_parameters *params)
+{
+	struct usb_dibusb* dib = (struct usb_dibusb*) fe->dvb->priv;
+	u8 buf[4];
+	u32 freq = params->frequency;
+	u32 tfreq = (freq + 36125000) / 1000000 * 6 + 1;
+	u8 TA, T210, R210, ctrl1, cp210, p4321;
+	struct i2c_msg msg = {
+		.addr = panasonic_cofdm_env57h1xd5.pll_addr,
+		.flags = 0,
+		.buf = buf,
+		.len = sizeof(buf)
+	};
+
+	if (freq > 858000000) {
+		err("frequency cannot be larger than 858 MHz.");
+		return -EINVAL;
+	}
+
+	// contol data 1 : 1 | T/A=1 | T2,T1,T0 = 0,0,0 | R2,R1,R0 = 0,1,0
+	TA = 1;
+	T210 = 0;
+	R210 = 0x2;
+	ctrl1 = (1 << 7) | (TA << 6) | (T210 << 3) | R210;
+
+// ********    CHARGE PUMP CONFIG vs RF FREQUENCIES     *****************
+	if (freq < 470000000)
+		cp210 = 2;  // VHF Low and High band ch E12 to E4 to E12
+	else if (freq < 526000000)
+		cp210 = 4;  // UHF band Ch E21 to E27
+	else // if (freq < 862000000)
+		cp210 = 5;  // UHF band ch E28 to E69
+
+//*********************    BW select  *******************************
+	if (freq < 153000000)
+		p4321  = 1; // BW selected for VHF low
+	else if (freq < 470000000)
+		p4321  = 2; // BW selected for VHF high E5 to E12
+	else // if (freq < 862000000)
+		p4321  = 4; // BW selection for UHF E21 to E69
+
+	buf[0] = (tfreq >> 8) & 0xff;
+	buf[1] = (tfreq >> 0) & 0xff;
+	buf[2] = 0xff & ctrl1;
+	buf[3] =  (cp210 << 5) | (p4321);
+
+	if (i2c_transfer (&dib->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+
+	msleep(1);
+	return 0;
+}
+
+static struct i2c_algorithm dibusb_algo = {
+	.name			= "DiBcom USB i2c algorithm",
+	.id				= I2C_ALGO_BIT,
+	.master_xfer	= dibusb_i2c_xfer,
+	.functionality	= dibusb_i2c_func,
+};
+
+static void frontend_init(struct usb_dibusb* dib)
+{
+	switch (dib->dibdev->parm->type) {
+		case DIBUSB1_1:
+		case DIBUSB1_1_AN2235:
+	dib->fe = dib3000mb_attach(&thomson_cable_eu_config, &dib->i2c_adap,&dib->xfer_ops);
+			break;
+		case DIBUSB2_0:
+			dib->fe = dib3000mc_attach(&panasonic_cofdm_env57h1xd5,&dib->i2c_adap, &dib->xfer_ops);
+			break;
+	}
+
+	if (dib->fe == NULL) {
+		printk("dvb-dibusb: A frontend driver was not found for device %04x/%04x\n",
+		       dib->udev->descriptor.idVendor,
+		       dib->udev->descriptor.idProduct);
+	} else {
+		if (dvb_register_frontend(dib->adapter, dib->fe)) {
+			printk("dvb-dibusb: Frontend registration failed!\n");
+			if (dib->fe->ops->release)
+				dib->fe->ops->release(dib->fe);
+			dib->fe = NULL;
+		}
+	}
+}
+
+static int dibusb_dvb_init(struct usb_dibusb *dib)
+{
+	int ret;
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,4)
+    if ((ret = dvb_register_adapter(&dib->adapter, DRIVER_DESC)) < 0) {
+#else
+    if ((ret = dvb_register_adapter(&dib->adapter, DRIVER_DESC ,
+			THIS_MODULE)) < 0) {
+#endif
+		deb_info("dvb_register_adapter failed: error %d", ret);
+		goto err;
+	}
+	dib->adapter->priv = dib;
+
+	strncpy(dib->i2c_adap.name,dib->dibdev->name,I2C_NAME_SIZE);
+#ifdef I2C_ADAP_CLASS_TV_DIGITAL
+	dib->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL,
+#else
+	dib->i2c_adap.class = I2C_CLASS_TV_DIGITAL,
+#endif
+	dib->i2c_adap.algo 		= &dibusb_algo;
+	dib->i2c_adap.algo_data = NULL;
+	dib->i2c_adap.id		= I2C_ALGO_BIT;
+
+	i2c_set_adapdata(&dib->i2c_adap, dib);
+
+	if ((i2c_add_adapter(&dib->i2c_adap) < 0)) {
+		err("could not add i2c adapter");
+		goto err_i2c;
+	}
+
+	dib->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING;
+
+	dib->demux.priv = (void *)dib;
+	/* get pidcount from demod */
+	dib->demux.feednum = dib->demux.filternum = 16;
+	dib->demux.start_feed = dibusb_start_feed;
+	dib->demux.stop_feed = dibusb_stop_feed;
+	dib->demux.write_to_decoder = NULL;
+	if ((ret = dvb_dmx_init(&dib->demux)) < 0) {
+		err("dvb_dmx_init failed: error %d",ret);
+		goto err_dmx;
+	}
+
+	dib->dmxdev.filternum = dib->demux.filternum;
+	dib->dmxdev.demux = &dib->demux.dmx;
+	dib->dmxdev.capabilities = 0;
+	if ((ret = dvb_dmxdev_init(&dib->dmxdev, dib->adapter)) < 0) {
+		err("dvb_dmxdev_init failed: error %d",ret);
+		goto err_dmx_dev;
+	}
+
+	dvb_net_init(dib->adapter, &dib->dvb_net, &dib->demux.dmx);
+
+	frontend_init(dib);
+
+	/* Start the remote-control polling. */
+	schedule_delayed_work(&dib->rc_query_work, msecs_to_jiffies(RC_QUERY_INTERVAL));
+
+	goto success;
+err_dmx_dev:
+	dvb_dmx_release(&dib->demux);
+err_dmx:
+	i2c_del_adapter(&dib->i2c_adap);
+err_i2c:
+	dvb_unregister_adapter(dib->adapter);
+err:
+	return ret;
+success:
+	dib->dvb_is_ready = 1;
+	return 0;
+}
+
+static int dibusb_dvb_exit(struct usb_dibusb *dib)
+{
+	cancel_delayed_work(&dib->rc_query_work);
+	flush_scheduled_work();
+	input_unregister_device(&dib->rc_input_dev);
+
+	dib->dvb_is_ready = 0;
+	deb_info("unregistering DVB part\n");
+	dvb_net_release(&dib->dvb_net);
+	dib->demux.dmx.close(&dib->demux.dmx);
+	dvb_dmxdev_release(&dib->dmxdev);
+	dvb_dmx_release(&dib->demux);
+	if (dib->fe != NULL) dvb_unregister_frontend(dib->fe);
+	i2c_del_adapter(&dib->i2c_adap);
+	dvb_unregister_adapter(dib->adapter);
+
+	return 0;
+}
+
+static int dibusb_exit(struct usb_dibusb *dib)
+{
+	int i;
+	if (dib->urb_list != NULL) {
+		for (i = 0; i < dib->dibdev->parm->num_urbs; i++) {
+			if (dib->urb_list[i] != NULL) {
+			deb_info("killing URB no. %d.\n",i);
+
+				/* stop the URBs */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,7)
+				usb_unlink_urb(dib->urb_list[i]);
+#else
+				usb_kill_urb(dib->urb_list[i]);
+#endif
+			
+			deb_info("freeing URB no. %d.\n",i);
+				/* free the URBs */
+				usb_free_urb(dib->urb_list[i]);
+			}
+		}
+		/* free the urb array */
+		kfree(dib->urb_list);
+		}
+
+	pci_free_consistent(NULL,
+		dib->dibdev->parm->urb_buf_size*dib->dibdev->parm->num_urbs,dib->buffer,
+		dib->dma_handle);
+	return 0;
+}
+
+static int dibusb_init(struct usb_dibusb *dib)
+{
+	int ret,i,bufsize;
+	sema_init(&dib->usb_sem, 1);
+	sema_init(&dib->i2c_sem, 1);
+
+	/*
+	 * when reloading the driver w/o replugging the device
+	 * a timeout occures, this helps
+	 */
+	usb_clear_halt(dib->udev,usb_sndbulkpipe(dib->udev,dib->dibdev->parm->cmd_pipe));
+	usb_clear_halt(dib->udev,usb_rcvbulkpipe(dib->udev,dib->dibdev->parm->result_pipe));
+	usb_clear_halt(dib->udev,usb_rcvbulkpipe(dib->udev,dib->dibdev->parm->data_pipe));
+
+	/* allocate the array for the data transfer URBs */
+	dib->urb_list = kmalloc(dib->dibdev->parm->num_urbs*sizeof(struct urb *),GFP_KERNEL);
+	if (dib->urb_list == NULL)
+		return -ENOMEM;
+	memset(dib->urb_list,0,dib->dibdev->parm->num_urbs*sizeof(struct urb *));
+
+	bufsize = dib->dibdev->parm->num_urbs*dib->dibdev->parm->urb_buf_size;
+	deb_info("allocate %d bytes as buffersize for all URBs\n",bufsize);
+	/* allocate the actual buffer for the URBs */
+	if ((dib->buffer = pci_alloc_consistent(NULL,bufsize,&dib->dma_handle)) == NULL) {
+		deb_info("not enough memory.\n");
+		dibusb_exit(dib);
+		return -ENOMEM;
+	}
+	deb_info("allocation complete\n");
+	memset(dib->buffer,0,bufsize);
+
+	/* allocate and submit the URBs */
+	for (i = 0; i < dib->dibdev->parm->num_urbs; i++) {
+		if (!(dib->urb_list[i] = usb_alloc_urb(0,GFP_KERNEL))) {
+		dibusb_exit(dib);
+		return -ENOMEM;
+	}
+		deb_info("submitting URB no. %d\n",i);
+
+		usb_fill_bulk_urb( dib->urb_list[i], dib->udev,
+				usb_rcvbulkpipe(dib->udev,dib->dibdev->parm->data_pipe),
+				&dib->buffer[i*dib->dibdev->parm->urb_buf_size],
+				dib->dibdev->parm->urb_buf_size,
+				dibusb_urb_complete, dib);
+
+		dib->urb_list[i]->transfer_flags = 0;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,7)
+		dib->urb_list[i]->timeout = 0;
+#endif
+
+		if ((ret = usb_submit_urb(dib->urb_list[i],GFP_KERNEL))) {
+			err("could not submit buffer urb no. %d\n",i);
+			dibusb_exit(dib);
+			return ret;
+		}
+	}
+
+	dib->dvb_is_ready = 0;
+
+	/* Initialise the remote-control structures.*/
+	init_input_dev(&dib->rc_input_dev);
+
+	dib->rc_input_dev.evbit[0] = BIT(EV_KEY);
+	dib->rc_input_dev.keycodesize = sizeof(unsigned char);
+	dib->rc_input_dev.keycodemax = KEY_MAX;
+	dib->rc_input_dev.name = DRIVER_DESC " remote control";
+
+	for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i++)
+		set_bit(rc_keys[i].key, dib->rc_input_dev.keybit);
+
+	input_register_device(&dib->rc_input_dev);
+
+	dib->rc_input_event = KEY_MAX;
+
+	INIT_WORK(&dib->rc_query_work, dibusb_query_rc, dib);
+
+	dibusb_hw_wakeup(dib);
+
+	if ((ret = dibusb_dvb_init(dib))) {
+		dibusb_exit(dib);
+		return ret;
+	}
+	return 0;
+}
+
+/*
+ * load a firmware packet to the device
+ */
+static int dibusb_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len)
+{
+	return usb_control_msg(udev, usb_sndctrlpipe(udev,0),
+			0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5*HZ);
+}
+
+static int dibusb_loadfirmware(struct usb_device *udev,
+		struct dibusb_device *dibdev)
+{
+	const struct firmware *fw = NULL;
+	const char **fws;
+	u16 addr;
+	u8 *b,*p;
+	int ret = 0,i;
+
+	fws = dibdev->parm->fw_filenames;
+
+	for (i = 0; i < sizeof(fws)/sizeof(const char*); i++) {
+		if ((ret = request_firmware(&fw, fws[i], &udev->dev)) == 0) {
+			info("using firmware file (%s).",fws[i]);
+			break;
+		}
+		deb_info("tried to find '%s' firmware - unsuccessful. (%d)\n",
+				fws[i],ret);
+	}
+
+	if (fw == NULL) {
+		err("did not find a valid firmware file. "
+			"Please see linux/Documentation/dvb/ for more details on firmware-problems.");
+		return -EINVAL;
+	}
+	p = kmalloc(fw->size,GFP_KERNEL);
+	if (p != NULL) {
+		u8 reset;
+		/*
+		 * you cannot use the fw->data as buffer for
+		 * usb_control_msg, a new buffer has to be
+		 * created
+		 */
+		memcpy(p,fw->data,fw->size);
+
+		/* stop the CPU */
+		reset = 1;
+		if ((ret = dibusb_writemem(udev,dibdev->parm->usb_cpu_csreg,&reset,1)) != 1)
+			err("could not stop the USB controller CPU.");
+		for(i = 0; p[i+3] == 0 && i < fw->size; ) {
+			b = (u8 *) &p[i];
+			addr = *((u16 *) &b[1]);
+
+			ret = dibusb_writemem(udev,addr,&b[4],b[0]);
+
+			if (ret != b[0]) {
+				err("error while transferring firmware "
+					"(transferred size: %d, block size: %d)",
+					ret,b[0]);
+				ret = -EINVAL;
+				break;
+			}
+			i += 5 + b[0];
+		}
+		/* length in ret */
+		if (ret > 0)
+			ret = 0;
+		/* restart the CPU */
+		reset = 0;
+		if (ret || dibusb_writemem(udev,dibdev->parm->usb_cpu_csreg,&reset,1) != 1) {
+			err("could not restart the USB controller CPU.");
+			ret = -EINVAL;
+		}
+
+		kfree(p);
+	} else {
+		ret = -ENOMEM;
+	}
+	release_firmware(fw);
+
+	return ret;
+}
+
+/*
+ * USB
+ */
+static int dibusb_probe(struct usb_interface *intf,
+		const struct usb_device_id *id)
+{
+	struct usb_device *udev = interface_to_usbdev(intf);
+	struct usb_dibusb *dib = NULL;
+	struct dibusb_device *dibdev = NULL;
+
+	int ret = -ENOMEM,i,cold=0;
+
+	for (i = 0; i < DIBUSB_SUPPORTED_DEVICES; i++)
+		if (dibusb_devices[i].cold_product_id == udev->descriptor.idProduct ||
+			dibusb_devices[i].warm_product_id == udev->descriptor.idProduct) {
+			dibdev = &dibusb_devices[i];
+
+			cold = dibdev->cold_product_id == udev->descriptor.idProduct;
+
+			if (cold)
+				info("found a '%s' in cold state, will try to load a firmware",dibdev->name);
+			else
+				info("found a '%s' in warm state.",dibdev->name);
+		}
+
+	if (dibdev == NULL) {
+		err("something went very wrong, "
+				"unknown product ID: %.4x",udev->descriptor.idProduct);
+		return -ENODEV;
+	}
+
+	if (cold)
+		ret = dibusb_loadfirmware(udev,dibdev);
+	else {
+		dib = kmalloc(sizeof(struct usb_dibusb),GFP_KERNEL);
+		if (dib == NULL) {
+			err("no memory");
+			return ret;
+		}
+		memset(dib,0,sizeof(struct usb_dibusb));
+
+		dib->pid_parse = 1;
+		switch (udev->speed) {
+			case USB_SPEED_LOW:
+				err("cannot handle USB speed because it is to sLOW.");
+				break;
+			case USB_SPEED_FULL:
+				info("running at FULL speed, will use pid parsing.");
+				break;
+			case USB_SPEED_HIGH:
+				if (!pid_parse) {
+					dib->pid_parse = 0;
+				info("running at HIGH speed, will deliver the complete TS.");
+				} else
+					info("running at HIGH speed, will use pid_parsing anyway.");
+				break;
+			case USB_SPEED_UNKNOWN: /* fall through */
+			default:
+				err("cannot handle USB speed because it is unkown.");
+				break;
+		}
+
+		dib->udev = udev;
+		dib->dibdev = dibdev;
+
+		usb_set_intfdata(intf, dib);
+
+		ret = dibusb_init(dib);
+	}
+
+	if (ret == 0)
+		info("%s successfully initialized and connected.",dibdev->name);
+	else
+		info("%s error while loading driver (%d)",dibdev->name,ret);
+	return ret;
+}
+
+static void dibusb_disconnect(struct usb_interface *intf)
+{
+	struct usb_dibusb *dib = usb_get_intfdata(intf);
+	const char *name = DRIVER_DESC;
+
+	usb_set_intfdata(intf,NULL);
+	if (dib != NULL) {
+		name = dib->dibdev->name;
+		dibusb_dvb_exit(dib);
+		dibusb_exit(dib);
+		kfree(dib);
+	}
+	info("%s successfully deinitialized and disconnected.",name);
+
+}
+
+/* usb specific object needed to register this driver with the usb subsystem */
+static struct usb_driver dibusb_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "dvb_dibusb",
+	.probe 		= dibusb_probe,
+	.disconnect = dibusb_disconnect,
+	.id_table 	= dibusb_table,
+};
+
+/* module stuff */
+static int __init usb_dibusb_init(void)
+{
+	int result;
+	if ((result = usb_register(&dibusb_driver))) {
+		err("usb_register failed. Error number %d",result);
+		return result;
+	}
+
+	return 0;
+}
+
+static void __exit usb_dibusb_exit(void)
+{
+	/* deregister this driver from the USB subsystem */
+	usb_deregister(&dibusb_driver);
+}
+
+module_init (usb_dibusb_init);
+module_exit (usb_dibusb_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/media/dvb/dibusb/dvb-dibusb.h b/drivers/media/dvb/dibusb/dvb-dibusb.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/dibusb/dvb-dibusb.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,351 @@
+/*
+ * dvb-dibusb.h
+ *
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ *
+ *	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, version 2.
+ *
+ * for more information see dvb-dibusb.c .
+ */
+
+#ifndef __DVB_DIBUSB_H__
+#define __DVB_DIBUSB_H__
+
+#include "dib3000.h"
+
+typedef enum {
+	DIBUSB1_1 = 0,
+	DIBUSB2_0,
+	DIBUSB1_1_AN2235,
+} dibusb_type;
+
+static const char * dibusb_fw_filenames1_1[] = {
+	"dvb-dibusb-5.0.0.11.fw"
+};
+
+static const char * dibusb_fw_filenames1_1_an2235[] = {
+	"dvb-dibusb-an2235-1.fw"
+};
+
+static const char * dibusb_fw_filenames2_0[] = {
+	"dvb-dibusb-6.0.0.5.fw"
+};
+
+struct dibusb_device_parameter {
+	dibusb_type type;
+	u8 demod_addr;
+	const char **fw_filenames;
+	const char *usb_controller;
+	u16 usb_cpu_csreg;
+
+	int num_urbs;
+	int urb_buf_size;
+	int default_size;
+	int firmware_bug;
+
+	int cmd_pipe;
+	int result_pipe;
+	int data_pipe;
+};
+
+static struct dibusb_device_parameter dibusb_dev_parm[3] = {
+	{	.type = DIBUSB1_1,
+		.demod_addr = 0x10,
+		.fw_filenames = dibusb_fw_filenames1_1,
+		.usb_controller = "Cypress AN2135",
+		.usb_cpu_csreg = 0x7f92,
+
+		.num_urbs = 3,
+		.urb_buf_size = 4096,
+		.default_size = 188*21,
+		.firmware_bug = 1,
+
+		.cmd_pipe = 0x01,
+		.result_pipe = 0x81,
+		.data_pipe = 0x82,
+	},
+	{	.type = DIBUSB2_0,
+		.demod_addr = 0x18,
+		.fw_filenames = dibusb_fw_filenames2_0,
+		.usb_controller = "Cypress FX2",
+		.usb_cpu_csreg = 0xe600,
+
+		.num_urbs = 3,
+		.urb_buf_size = 40960,
+		.default_size = 188*210,
+		.firmware_bug = 0,
+
+		.cmd_pipe = 0x01,
+		.result_pipe = 0x81,
+		.data_pipe = 0x86,
+	},
+	{	.type = DIBUSB1_1_AN2235,
+		.demod_addr = 0x10,
+		.fw_filenames = dibusb_fw_filenames1_1_an2235,
+		.usb_controller = "Cypress CY7C64613 (AN2235)",
+		.usb_cpu_csreg = 0x7f92,
+
+		.num_urbs = 3,
+		.urb_buf_size = 4096,
+		.default_size = 188*21,
+		.firmware_bug = 1,
+
+		.cmd_pipe = 0x01,
+		.result_pipe = 0x81,
+		.data_pipe = 0x82,
+	}
+};
+
+struct dibusb_device {
+	const char *name;
+	u16 cold_product_id;
+	u16 warm_product_id;
+	struct dibusb_device_parameter *parm;
+};
+
+/* Vendor IDs */
+#define USB_VID_ANCHOR						0x0547
+#define USB_VID_AVERMEDIA					0x14aa
+#define USB_VID_COMPRO						0x185b
+#define USB_VID_COMPRO_UNK					0x145f
+#define USB_VID_CYPRESS						0x04b4
+#define USB_VID_DIBCOM						0x10b8
+#define USB_VID_EMPIA						0xeb1a
+#define USB_VID_GRANDTEC					0x5032
+#define USB_VID_HYPER_PALTEK				0x1025
+#define USB_VID_IMC_NETWORKS				0x13d3
+#define USB_VID_TWINHAN						0x1822
+#define USB_VID_ULTIMA_ELECTRONIC			0x05d8
+
+/* Product IDs */
+#define USB_PID_AVERMEDIA_DVBT_USB_COLD		0x0001
+#define USB_PID_AVERMEDIA_DVBT_USB_WARM		0x0002
+#define USB_PID_COMPRO_DVBU2000_COLD		0xd000
+#define USB_PID_COMPRO_DVBU2000_WARM		0xd001
+#define USB_PID_COMPRO_DVBU2000_UNK_COLD	0x010c
+#define USB_PID_COMPRO_DVBU2000_UNK_WARM	0x010d
+#define USB_PID_DIBCOM_MOD3000_COLD			0x0bb8
+#define USB_PID_DIBCOM_MOD3000_WARM			0x0bb9
+#define USB_PID_DIBCOM_MOD3001_COLD			0x0bc6
+#define USB_PID_DIBCOM_MOD3001_WARM			0x0bc7
+#define USB_PID_GRANDTEC_DVBT_USB_COLD		0x0fa0
+#define USB_PID_GRANDTEC_DVBT_USB_WARM		0x0fa1
+#define USB_PID_KWORLD_VSTREAM_COLD			0x17de
+#define USB_PID_KWORLD_VSTREAM_WARM			0x17df
+#define USB_PID_TWINHAN_VP7041_COLD			0x3201
+#define USB_PID_TWINHAN_VP7041_WARM			0x3202
+#define USB_PID_ULTIMA_TVBOX_COLD			0x8105
+#define USB_PID_ULTIMA_TVBOX_WARM			0x8106
+#define USB_PID_ULTIMA_TVBOX_AN2235_COLD	0x8107
+#define USB_PID_ULTIMA_TVBOX_AN2235_WARM	0x8108
+#define USB_PID_ULTIMA_TVBOX_ANCHOR_COLD	0x2235
+#define USB_PID_ULTIMA_TVBOX_USB2_COLD		0x8109
+#define USB_PID_ULTIMA_TVBOX_USB2_FX_COLD	0x8613
+#define USB_PID_ULTIMA_TVBOX_USB2_FX_WARM	0x1002
+#define USB_PID_UNK_HYPER_PALTEK_COLD		0x005e
+#define USB_PID_UNK_HYPER_PALTEK_WARM		0x005f
+#define USB_PID_YAKUMO_DTT200U_COLD			0x0201
+#define USB_PID_YAKUMO_DTT200U_WARM			0x0301
+
+#define DIBUSB_SUPPORTED_DEVICES	15
+
+/* USB Driver stuff */
+static struct dibusb_device dibusb_devices[DIBUSB_SUPPORTED_DEVICES] = {
+	{	.name = "TwinhanDTV USB1.1 / Magic Box / HAMA USB1.1 DVB-T device",
+		.cold_product_id = USB_PID_TWINHAN_VP7041_COLD,
+		.warm_product_id = USB_PID_TWINHAN_VP7041_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "KWorld V-Stream XPERT DTV - DVB-T USB1.1",
+		.cold_product_id = USB_PID_KWORLD_VSTREAM_COLD,
+		.warm_product_id = USB_PID_KWORLD_VSTREAM_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "Grandtec USB1.1 DVB-T/DiBcom USB1.1 DVB-T reference design (MOD3000)",
+		.cold_product_id = USB_PID_DIBCOM_MOD3000_COLD,
+		.warm_product_id = USB_PID_DIBCOM_MOD3000_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "Artec T1 USB1.1 TVBOX with AN2135",
+		.cold_product_id = USB_PID_ULTIMA_TVBOX_COLD,
+		.warm_product_id = USB_PID_ULTIMA_TVBOX_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "Artec T1 USB1.1 TVBOX with AN2235",
+		.cold_product_id = USB_PID_ULTIMA_TVBOX_AN2235_COLD,
+		.warm_product_id = USB_PID_ULTIMA_TVBOX_AN2235_WARM,
+		.parm = &dibusb_dev_parm[2],
+	},
+	{	.name = "Artec T1 USB1.1 TVBOX with AN2235 (misdesigned)",
+		.cold_product_id = USB_PID_ULTIMA_TVBOX_ANCHOR_COLD,
+		.warm_product_id = 0, /* undefined, this design becomes USB_PID_DIBCOM_MOD3000_WARM in warm state */
+		.parm = &dibusb_dev_parm[2],
+	},
+	{	.name = "Artec T1 USB2.0 TVBOX (please report the warm ID)",
+		.cold_product_id = USB_PID_ULTIMA_TVBOX_USB2_COLD,
+		.warm_product_id = 0, /* don't know, it is most likely that the device will get another USB ID in warm state */
+		.parm = &dibusb_dev_parm[1],
+	},
+	{	.name = "Artec T1 USB2.0 TVBOX with FX2 IDs (misdesigned, please report the warm ID)",
+		.cold_product_id = USB_PID_ULTIMA_TVBOX_USB2_FX_COLD,
+		.warm_product_id = USB_PID_ULTIMA_TVBOX_USB2_FX_WARM, /* undefined, it could be that the device will get another USB ID in warm state */
+		.parm = &dibusb_dev_parm[1],
+	},
+	{	.name = "Compro Videomate DVB-U2000 - DVB-T USB1.1",
+		.cold_product_id = USB_PID_COMPRO_DVBU2000_COLD,
+		.warm_product_id = USB_PID_COMPRO_DVBU2000_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "Compro Videomate DVB-U2000 - DVB-T USB1.1 (really ?? please report the name!)",
+		.cold_product_id = USB_PID_COMPRO_DVBU2000_UNK_COLD,
+		.warm_product_id = USB_PID_COMPRO_DVBU2000_UNK_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "Unkown USB1.1 DVB-T device ???? please report the name to the author",
+		.cold_product_id = USB_PID_UNK_HYPER_PALTEK_COLD,
+		.warm_product_id = USB_PID_UNK_HYPER_PALTEK_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
+		.cold_product_id = USB_PID_DIBCOM_MOD3001_COLD,
+		.warm_product_id = USB_PID_DIBCOM_MOD3001_WARM,
+		.parm = &dibusb_dev_parm[1],
+	},
+	{	.name = "Grandtec DVB-T USB1.1",
+		.cold_product_id = USB_PID_GRANDTEC_DVBT_USB_COLD,
+		.warm_product_id = USB_PID_GRANDTEC_DVBT_USB_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "Avermedia AverTV DVBT USB1.1",
+		.cold_product_id = USB_PID_AVERMEDIA_DVBT_USB_COLD,
+		.warm_product_id = USB_PID_AVERMEDIA_DVBT_USB_WARM,
+		.parm = &dibusb_dev_parm[0],
+	},
+	{	.name = "Yakumo DVB-T mobile USB2.0",
+		.cold_product_id = USB_PID_YAKUMO_DTT200U_COLD,
+		.warm_product_id = USB_PID_YAKUMO_DTT200U_WARM,
+		.parm = &dibusb_dev_parm[1],
+	}
+};
+
+/* USB Driver stuff */
+/* table of devices that work with this driver */
+static struct usb_device_id dibusb_table [] = {
+	{ USB_DEVICE(USB_VID_AVERMEDIA,		USB_PID_AVERMEDIA_DVBT_USB_COLD)},
+	{ USB_DEVICE(USB_VID_AVERMEDIA,		USB_PID_AVERMEDIA_DVBT_USB_WARM)},
+	{ USB_DEVICE(USB_VID_COMPRO,		USB_PID_COMPRO_DVBU2000_COLD) },
+	{ USB_DEVICE(USB_VID_COMPRO,		USB_PID_COMPRO_DVBU2000_WARM) },
+	{ USB_DEVICE(USB_VID_DIBCOM,		USB_PID_DIBCOM_MOD3000_COLD) },
+	{ USB_DEVICE(USB_VID_DIBCOM,		USB_PID_DIBCOM_MOD3000_WARM) },
+	{ USB_DEVICE(USB_VID_DIBCOM,		USB_PID_DIBCOM_MOD3001_COLD) },
+	{ USB_DEVICE(USB_VID_DIBCOM,		USB_PID_DIBCOM_MOD3001_WARM) },
+	{ USB_DEVICE(USB_VID_EMPIA,			USB_PID_KWORLD_VSTREAM_COLD) },
+	{ USB_DEVICE(USB_VID_EMPIA,			USB_PID_KWORLD_VSTREAM_WARM) },
+	{ USB_DEVICE(USB_VID_GRANDTEC,		USB_PID_GRANDTEC_DVBT_USB_COLD) },
+	{ USB_DEVICE(USB_VID_GRANDTEC,		USB_PID_GRANDTEC_DVBT_USB_WARM) },
+	{ USB_DEVICE(USB_VID_GRANDTEC,		USB_PID_DIBCOM_MOD3000_COLD) },
+	{ USB_DEVICE(USB_VID_GRANDTEC,		USB_PID_DIBCOM_MOD3000_WARM) },
+	{ USB_DEVICE(USB_VID_HYPER_PALTEK,	USB_PID_UNK_HYPER_PALTEK_COLD) },
+	{ USB_DEVICE(USB_VID_HYPER_PALTEK,	USB_PID_UNK_HYPER_PALTEK_WARM) },
+	{ USB_DEVICE(USB_VID_IMC_NETWORKS,	USB_PID_TWINHAN_VP7041_COLD) },
+	{ USB_DEVICE(USB_VID_IMC_NETWORKS,	USB_PID_TWINHAN_VP7041_WARM) },
+	{ USB_DEVICE(USB_VID_TWINHAN, 		USB_PID_TWINHAN_VP7041_COLD) },
+	{ USB_DEVICE(USB_VID_TWINHAN, 		USB_PID_TWINHAN_VP7041_WARM) },
+	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_COLD) },
+	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_WARM) },
+	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_COLD) },
+	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_WARM) },
+	{ USB_DEVICE(USB_VID_AVERMEDIA,		USB_PID_YAKUMO_DTT200U_COLD) },
+	{ USB_DEVICE(USB_VID_AVERMEDIA,		USB_PID_YAKUMO_DTT200U_WARM) },
+	{ USB_DEVICE(USB_PID_COMPRO_DVBU2000_UNK_COLD, USB_VID_COMPRO_UNK) },
+	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,	USB_PID_ULTIMA_TVBOX_USB2_COLD) },
+
+/*
+ * activate the following define when you have one of the devices and want to
+ * build it from build-2.6 in dvb-kernel
+ */
+// #define CONFIG_DVB_DIBUSB_MISDESIGNED_DEVICES
+#ifdef CONFIG_DVB_DIBUSB_MISDESIGNED_DEVICES
+	{ USB_DEVICE(USB_VID_ANCHOR,		USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) },
+	{ USB_DEVICE(USB_VID_CYPRESS,		USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+	{ USB_DEVICE(USB_VID_ANCHOR,		USB_PID_ULTIMA_TVBOX_USB2_FX_WARM) },
+#endif
+	{ }                 /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE (usb, dibusb_table);
+
+#define DIBUSB_I2C_TIMEOUT 				HZ*5
+
+struct usb_dibusb {
+	/* usb */
+	struct usb_device * udev;
+
+	struct dibusb_device * dibdev;
+
+	int feedcount;
+	int pid_parse;
+	struct dib3000_xfer_ops xfer_ops;
+
+	struct urb **urb_list;
+	u8 *buffer;
+	dma_addr_t dma_handle;
+
+	/* I2C */
+	struct i2c_adapter i2c_adap;
+	struct i2c_client i2c_client;
+
+	/* locking */
+	struct semaphore usb_sem;
+	struct semaphore i2c_sem;
+
+	/* dvb */
+	int dvb_is_ready;
+	struct dvb_adapter *adapter;
+	struct dmxdev dmxdev;
+	struct dvb_demux demux;
+	struct dvb_net dvb_net;
+	struct dvb_frontend* fe;
+
+	/* remote control */
+	struct input_dev rc_input_dev;
+	struct work_struct rc_query_work;
+	int rc_input_event;
+};
+
+
+/* types of first byte of each buffer */
+
+#define DIBUSB_REQ_START_READ			0x00
+#define DIBUSB_REQ_START_DEMOD			0x01
+#define DIBUSB_REQ_I2C_READ  			0x02
+#define DIBUSB_REQ_I2C_WRITE 			0x03
+
+/* prefix for reading the current RC key */
+#define DIBUSB_REQ_POLL_REMOTE			0x04
+
+#define DIBUSB_RC_NEC_EMPTY				0x00
+#define DIBUSB_RC_NEC_KEY_PRESSED		0x01
+#define DIBUSB_RC_NEC_KEY_REPEATED		0x02
+
+/* 0x05 0xXX */
+#define DIBUSB_REQ_SET_STREAMING_MODE	0x05
+
+/* interrupt the internal read loop, when blocking */
+#define DIBUSB_REQ_INTR_READ		   	0x06
+
+/* IO control
+ * 0x07 <cmd 1 byte> <param 32 bytes>
+ */
+#define DIBUSB_REQ_SET_IOCTL			0x07
+
+/* IOCTL commands */
+
+/* change the power mode in firmware */
+#define DIBUSB_IOCTL_CMD_POWER_MODE		0x00
+#define DIBUSB_IOCTL_POWER_SLEEP			0x00
+#define DIBUSB_IOCTL_POWER_WAKEUP			0x01
+
+#endif
diff -Nru a/drivers/media/dvb/dvb-core/Makefile b/drivers/media/dvb/dvb-core/Makefile
--- a/drivers/media/dvb/dvb-core/Makefile	2004-12-24 13:37:30 -08:00
+++ b/drivers/media/dvb/dvb-core/Makefile	2004-12-24 13:37:30 -08:00
@@ -3,7 +3,7 @@
 #
 
 dvb-core-objs = dvbdev.o dmxdev.o dvb_demux.o dvb_filter.o \
-	        dvb_ca_en50221.o dvb_functions.o dvb_frontend.o \
-		dvb_i2c.o dvb_net.o dvb_ksyms.o dvb_ringbuffer.o
+	        dvb_ca_en50221.o dvb_frontend.o \
+		dvb_net.o dvb_ringbuffer.o
 
 obj-$(CONFIG_DVB_CORE) += dvb-core.o
diff -Nru a/drivers/media/dvb/dvb-core/Makefile.lib b/drivers/media/dvb/dvb-core/Makefile.lib
--- a/drivers/media/dvb/dvb-core/Makefile.lib	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1 +0,0 @@
-obj-$(CONFIG_DVB_CORE)		+= crc32.o
diff -Nru a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
--- a/drivers/media/dvb/dvb-core/dmxdev.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/media/dvb/dvb-core/dmxdev.c	2004-12-24 13:37:04 -08:00
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/sched.h>
 #include <linux/poll.h>
 #include <linux/ioctl.h>
@@ -33,25 +34,20 @@
 #include <asm/system.h>
 
 #include "dmxdev.h"
-#include "dvb_functions.h"
 
-MODULE_PARM(debug,"i");
-static int debug = 0;
+static int debug;
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
 
 #define dprintk	if (debug) printk
 
-inline struct dmxdev_filter *
+static inline struct dmxdev_filter *
 dvb_dmxdev_file_to_filter(struct file *file)
 {
 	return (struct dmxdev_filter *) file->private_data;
 }
 
-inline struct dmxdev_dvr *
-dvb_dmxdev_file_to_dvr(struct dmxdev *dmxdev, struct file *file)
-{
-	return (struct dmxdev_dvr *) file->private_data;
-}
-
 static inline void dvb_dmxdev_buffer_init(struct dmxdev_buffer *buffer) 
 {
 	buffer->data=NULL;
@@ -844,7 +840,7 @@
 }
 
 
-ssize_t 
+static ssize_t
 dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
 	struct dmxdev_filter *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
@@ -1120,6 +1116,7 @@
 
 	return 0;
 }
+EXPORT_SYMBOL(dvb_dmxdev_init);
 
 void 
 dvb_dmxdev_release(struct dmxdev *dmxdev)
@@ -1136,5 +1133,5 @@
 	}
 	dmxdev->demux->close(dmxdev->demux);
 }
-
+EXPORT_SYMBOL(dvb_dmxdev_release);
 
diff -Nru a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c	2004-12-24 13:36:47 -08:00
@@ -32,16 +32,19 @@
 #include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
-#include <asm/semaphore.h>
-#include <asm/atomic.h>
+#include <linux/rwsem.h>
 
 #include "dvb_ca_en50221.h"
-#include "dvb_functions.h"
 #include "dvb_ringbuffer.h"
 
-static int dvb_ca_en50221_debug = 0;
+static int dvb_ca_en50221_debug;
+
+module_param_named(cam_debug, dvb_ca_en50221_debug, int, 0644);
+MODULE_PARM_DESC(cam_debug, "enable verbose debug messages");
+
 #define dprintk if (dvb_ca_en50221_debug) printk
 
 #define INIT_TIMEOUT_SECS 5
@@ -108,7 +111,7 @@
         int link_buf_size;
 
         /* semaphore for syncing access to slot structure */
-        struct semaphore sem;
+        struct rw_semaphore sem;
 
         /* buffer for incoming packets */
         struct dvb_ringbuffer rx_buffer;
@@ -178,10 +181,12 @@
 {
         int i;
 
-        if (hlen < nlen) return NULL;
+	if (hlen < nlen)
+		return NULL;
 
         for(i=0; i<= hlen - nlen; i++) {
-                  if (!strncmp(haystack+i, needle, nlen)) return haystack+i;
+		if (!strncmp(haystack + i, needle, nlen))
+			return haystack + i;
         }
 
         return NULL;
@@ -199,7 +204,6 @@
 static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private* ca, int slot)
 {
         int slot_status;
-        int status;
         int cam_present_now;
         int cam_changed;
 
@@ -209,9 +213,7 @@
         }
 
         /* poll mode */
-        if ((status = down_interruptible(&ca->slot_info[slot].sem)) != 0) return status;
-        slot_status = ca->pub->poll_slot_status(ca->pub, slot);
-        up(&ca->slot_info[slot].sem);
+	slot_status = ca->pub->poll_slot_status(ca->pub, slot, ca->open);
 
         cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ? 1: 0;
         cam_changed = (slot_status & DVB_CA_EN50221_POLL_CAM_CHANGED) ? 1: 0;
@@ -250,7 +252,8 @@
  *
  * @return 0 on success, nonzero on error.
  */
-static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private* ca, int slot, u8 waitfor, int timeout_hz)
+static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
+					 u8 waitfor, int timeout_hz)
 {
         unsigned long timeout;
         unsigned long start;
@@ -263,7 +266,8 @@
         while(1) {
                 /* read the status and check for error */
                 int res = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
-                if (res < 0) return -EIO;
+		if (res < 0)
+			return -EIO;
 
                 /* if we got the flags, it was successful! */
                 if (res & waitfor) {
@@ -277,7 +281,7 @@
                 }
 
                 /* wait for a bit */
-                dvb_delay(1);
+                msleep(1);
         }
 
         dprintk("%s failed timeout:%lu\n", __FUNCTION__, jiffies - start);
@@ -306,33 +310,38 @@
         /* we'll be determining these during this function */
         ca->slot_info[slot].da_irq_supported = 0;
 
-        /* reset the link interface. Note CAM IRQs are disabled */
-        if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, CMDREG_RS)) != 0) return ret;
-        if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ/10)) != 0) return ret;
-
         /* set the host link buffer size temporarily. it will be overwritten with the
          * real negotiated size later. */
         ca->slot_info[slot].link_buf_size = 2;
 
         /* read the buffer size from the CAM */
-        if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0) return ret;
-        if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ/10)) != 0) return ret;
-        if ((ret = dvb_ca_en50221_read_data(ca, slot, buf, 2)) != 2) return -EIO;
-        if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0) return ret;
+	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0)
+		return ret;
+	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ / 10)) != 0)
+		return ret;
+	if ((ret = dvb_ca_en50221_read_data(ca, slot, buf, 2)) != 2)
+		return -EIO;
+	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0)
+		return ret;
 
         /* store it, and choose the minimum of our buffer and the CAM's buffer size */
         buf_size = (buf[0] << 8) | buf[1];
-        if (buf_size > HOST_LINK_BUF_SIZE) buf_size = HOST_LINK_BUF_SIZE;
+	if (buf_size > HOST_LINK_BUF_SIZE)
+		buf_size = HOST_LINK_BUF_SIZE;
         ca->slot_info[slot].link_buf_size = buf_size;
         buf[0] = buf_size >> 8;
         buf[1] = buf_size & 0xff;
         dprintk("Chosen link buffer size of %i\n", buf_size);
 
         /* write the buffer size to the CAM */
-        if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0) return ret;
-        if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ/10)) != 0) return ret;
-        if ((ret = dvb_ca_en50221_write_data(ca, slot, buf, 2)) != 2) return -EIO;
-        if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0) return ret;
+	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0)
+		return ret;
+	if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10)) != 0)
+		return ret;
+	if ((ret = dvb_ca_en50221_write_data(ca, slot, buf, 2)) != 2)
+		return -EIO;
+	if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0)
+		return ret;
 
         /* success */
         return 0;
@@ -359,8 +368,17 @@
         int _address = *address;
 
         /* grab the next tuple length and type */
-        if ((_tupleType = ca->pub->read_attribute_mem(ca->pub, slot, _address)) < 0) return _tupleType;
-        if ((_tupleLength = ca->pub->read_attribute_mem(ca->pub, slot, _address+2)) < 0) return _tupleLength;
+	if ((_tupleType = ca->pub->read_attribute_mem(ca->pub, slot, _address)) < 0)
+		return _tupleType;
+        if (_tupleType == 0xff) {
+                dprintk("END OF CHAIN TUPLE type:0x%x\n", _tupleType);
+                *address += 2;
+                *tupleType = _tupleType;
+                *tupleLength = 0;
+                return 0;
+        }
+	if ((_tupleLength = ca->pub->read_attribute_mem(ca->pub, slot, _address + 2)) < 0)
+		return _tupleLength;
         _address += 4;
 
         dprintk("TUPLE type:0x%x length:%i\n", _tupleType, _tupleLength);
@@ -368,7 +386,9 @@
         /* read in the whole tuple */
         for(i=0; i< _tupleLength; i++) {
                 tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot, _address + (i*2));
-                dprintk("  0x%02x: 0x%02x %c\n", i, tuple[i] & 0xff, ((tuple[i] > 31) && (tuple[i] < 127)) ? tuple[i] : '.');
+		dprintk("  0x%02x: 0x%02x %c\n",
+			i, tuple[i] & 0xff,
+			((tuple[i] > 31) && (tuple[i] < 127)) ? tuple[i] : '.');
         }
         _address += (_tupleLength*2);
 
@@ -406,40 +426,58 @@
 
 
         // CISTPL_DEVICE_0A
-        if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0) return status;
-        if (tupleType != 0x1D) return -EINVAL;
+	if ((status =
+	     dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
+		return status;
+	if (tupleType != 0x1D)
+		return -EINVAL;
 
 
 
         // CISTPL_DEVICE_0C
-        if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0) return status;
-        if (tupleType != 0x1C) return -EINVAL;
+	if ((status =
+	     dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
+		return status;
+	if (tupleType != 0x1C)
+		return -EINVAL;
 
 
 
         // CISTPL_VERS_1
-        if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0) return status;
-        if (tupleType != 0x15) return -EINVAL;
+	if ((status =
+	     dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
+		return status;
+	if (tupleType != 0x15)
+		return -EINVAL;
 
 
 
         // CISTPL_MANFID
-        if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0) return status;
-        if (tupleType != 0x20) return -EINVAL;
-        if (tupleLength != 4) return -EINVAL;
+	if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
+						&tupleLength, tuple)) < 0)
+		return status;
+	if (tupleType != 0x20)
+		return -EINVAL;
+	if (tupleLength != 4)
+		return -EINVAL;
         manfid = (tuple[1] << 8) | tuple[0];
         devid = (tuple[3] << 8) | tuple[2];
 
 
 
         // CISTPL_CONFIG
-        if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0) return status;
-        if (tupleType != 0x1A) return -EINVAL;
-        if (tupleLength < 3) return -EINVAL;
+	if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
+						&tupleLength, tuple)) < 0)
+		return status;
+	if (tupleType != 0x1A)
+		return -EINVAL;
+	if (tupleLength < 3)
+		return -EINVAL;
 
         /* extract the configbase */
         rasz = tuple[0] & 3;
-        if (tupleLength < (3 + rasz + 14)) return -EINVAL;
+	if (tupleLength < (3 + rasz + 14))
+		return -EINVAL;
         ca->slot_info[slot].config_base = 0;
         for(i=0; i< rasz+1; i++) {
                 ca->slot_info[slot].config_base |= (tuple[2+i] << (8*i));
@@ -447,32 +485,39 @@
 
         /* check it contains the correct DVB string */
         dvb_str = findstr(tuple, tupleLength, "DVB_CI_V", 8);
-        if (dvb_str == NULL) return -EINVAL;
-        if (tupleLength < ((dvb_str - (char*) tuple) + 12)) return -EINVAL;
+	if (dvb_str == NULL)
+		return -EINVAL;
+	if (tupleLength < ((dvb_str - (char *) tuple) + 12))
+		return -EINVAL;
 
         /* is it a version we support? */
         if (strncmp(dvb_str + 8, "1.00", 4)) {
-                printk("dvb_ca: Unsupported DVB CAM module version %c%c%c%c\n",
-                        dvb_str[8], dvb_str[9], dvb_str[10], dvb_str[11]);
+                printk("dvb_ca adapter %d: Unsupported DVB CAM module version %c%c%c%c\n",
+		       ca->dvbdev->adapter->num, dvb_str[8], dvb_str[9], dvb_str[10], dvb_str[11]);
                 return -EINVAL;
         }
 
         /* process the CFTABLE_ENTRY tuples, and any after those */
         while((!end_chain) && (address < 0x1000)) {
-                if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0) return status;
+		if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
+						        &tupleLength, tuple)) < 0)
+			return status;
                 switch(tupleType) {
                 case 0x1B: // CISTPL_CFTABLE_ENTRY
-                        if (tupleLength < (2+11+17)) break;
+			if (tupleLength < (2 + 11 + 17))
+				break;
 
                         /* if we've already parsed one, just use it */
-                        if (got_cftableentry) break;
+			if (got_cftableentry)
+				break;
 
                         /* get the config option */
                         ca->slot_info[slot].config_option = tuple[0] & 0x3f;
 
                         /* OK, check it contains the correct strings */
                         if ((findstr(tuple, tupleLength, "DVB_HOST", 8) == NULL) ||
-                            (findstr(tuple, tupleLength, "DVB_CI_MODULE", 13) == NULL)) break;
+			    (findstr(tuple, tupleLength, "DVB_CI_MODULE", 13) == NULL))
+				break;
 
                         got_cftableentry = 1;
                         break;
@@ -485,17 +530,17 @@
                         break;
 
                 default: /* Unknown tuple type - just skip this tuple and move to the next one */
-                        dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n", tupleType, tupleLength);
+			dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n", tupleType,
+				tupleLength);
                         break;
                 }
         }
 
-        if ((address > 0x1000) || (!got_cftableentry)) return -EINVAL;
+	if ((address > 0x1000) || (!got_cftableentry))
+		return -EINVAL;
 
         dprintk("Valid DVB CAM detected MANID:%x DEVID:%x CONFIGBASE:0x%x CONFIGOPTION:0x%x\n",
-                manfid, devid,
-                ca->slot_info[slot].config_base,
-                ca->slot_info[slot].config_option);
+		manfid, devid, ca->slot_info[slot].config_base, ca->slot_info[slot].config_option);
 
         // success!
         return 0;
@@ -515,7 +560,9 @@
         dprintk ("%s\n", __FUNCTION__);
 
         /* set the config option */
-        ca->pub->write_attribute_mem(ca->pub, slot, ca->slot_info[slot].config_base, ca->slot_info[slot].config_option);
+	ca->pub->write_attribute_mem(ca->pub, slot,
+				     ca->slot_info[slot].config_base,
+				     ca->slot_info[slot].config_option);
 
         /* check it */
         configoption = ca->pub->read_attribute_mem(ca->pub, slot, ca->slot_info[slot].config_base);
@@ -550,25 +597,28 @@
 
         dprintk ("%s\n", __FUNCTION__);
 
-        /* acquire the slot */
-        if ((status = down_interruptible(&ca->slot_info[slot].sem)) != 0) return status;
-
         /* check if we have space for a link buf in the rx_buffer */
         if (ebuf == NULL) {
-                if (dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer) <
-                    (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
+		int buf_free;
+
+		down_read(&ca->slot_info[slot].sem);
+		if (ca->slot_info[slot].rx_buffer.data == NULL) {
+			up_read(&ca->slot_info[slot].sem);
+			status = -EIO;
+			goto exit;
+		}
+		buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer);
+		up_read(&ca->slot_info[slot].sem);
+
+                if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
                         status = -EAGAIN;
                         goto exit;
                 }
         }
 
-        /* reset the interface if there's been a tx error */
-        if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) goto exit;
-        if (status & STATUSREG_TXERR) {
-                ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
-                status = -EIO;
-                goto exit;
-        }
+        /* check if there is data available */
+	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+		goto exit;
         if (!(status & STATUSREG_DA)) {
                 /* no data */
                 status = 0;
@@ -576,28 +626,33 @@
         }
 
         /* read the amount of data */
-        if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH)) < 0) goto exit;
+	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH)) < 0)
+		goto exit;
         bytes_read = status << 8;
-        if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW)) < 0) goto exit;
+	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW)) < 0)
+		goto exit;
         bytes_read |= status;
 
         /* check it will fit */
         if (ebuf == NULL) {
                 if (bytes_read > ca->slot_info[slot].link_buf_size) {
-                        printk("dvb_ca: CAM tried to send a buffer larger than the link buffer size!\n");
+			printk("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
+			       ca->dvbdev->adapter->num, bytes_read, ca->slot_info[slot].link_buf_size);
                         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
                         status = -EIO;
                         goto exit;
                 }
                 if (bytes_read < 2) {
-                        printk("dvb_ca: CAM sent a buffer that was less than 2 bytes!\n");
+			printk("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n",
+			       ca->dvbdev->adapter->num);
                         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
                         status = -EIO;
                         goto exit;
                 }
         } else {
                 if (bytes_read > ecount) {
-                        printk("dvb_ca: CAM tried to send a buffer larger than the ecount size!\n");
+			printk("dvb_ca adapter %d: CAM tried to send a buffer larger than the ecount size!\n",
+			       ca->dvbdev->adapter->num);
                         status = -EIO;
                         goto exit;
                 }
@@ -606,26 +661,39 @@
         /* fill the buffer */
         for(i=0; i < bytes_read; i++) {
                 /* read byte and check */
-                if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_DATA)) < 0) goto exit;
+		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_DATA)) < 0)
+			goto exit;
 
                 /* OK, store it in the buffer */
                 buf[i] = status;
         }
 
-        /* check for read error (RE should now go to 0) */
-        if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) goto exit;
+        /* check for read error (RE should now be 0) */
+	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+		goto exit;
         if (status & STATUSREG_RE) {
+		ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
                 status = -EIO;
                 goto exit;
         }
 
         /* OK, add it to the receive buffer, or copy into external buffer if supplied */
         if (ebuf == NULL) {
+		down_read(&ca->slot_info[slot].sem);
+		if (ca->slot_info[slot].rx_buffer.data == NULL) {
+			up_read(&ca->slot_info[slot].sem);
+			status = -EIO;
+			goto exit;
+		}
                 dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read);
+		up_read(&ca->slot_info[slot].sem);
         } else {
                 memcpy(ebuf, buf, bytes_read);
         }
 
+	dprintk("Received CA packet for slot %i connection id 0x%x last_frag:%i size:0x%x\n", slot,
+		buf[0], (buf[1] & 0x80) == 0, bytes_read);
+
         /* wake up readers when a last_fragment is received */
         if ((buf[1] & 0x80) == 0x00) {
                 wake_up_interruptible(&ca->wait_queue);
@@ -634,7 +702,6 @@
         status = bytes_read;
 
 exit:
-        up(&ca->slot_info[slot].sem);
         return status;
 }
 
@@ -660,30 +727,25 @@
 
 
         // sanity check
-        if (bytes_write > ca->slot_info[slot].link_buf_size) return -EINVAL;
-
-        /* acquire the slot */
-        if ((status = down_interruptible(&ca->slot_info[slot].sem)) != 0) return status;
-
-        /* reset the interface if there's been a tx error */
-        if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) goto exitnowrite;
-        if (status & STATUSREG_TXERR) {
-                ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
-                status = -EIO;
-                goto exitnowrite;
-        }
+	if (bytes_write > ca->slot_info[slot].link_buf_size)
+		return -EINVAL;
 
-        /* check if interface is actually waiting for us to read from it */
-        if (status & STATUSREG_DA) {
+        /* check if interface is actually waiting for us to read from it, or if a read is in progress */
+	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+		goto exitnowrite;
+        if (status & (STATUSREG_DA|STATUSREG_RE)) {
                 status = -EAGAIN;
                 goto exitnowrite;
         }
 
         /* OK, set HC bit */
-        if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_HC)) != 0) goto exit;
+	if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
+						 IRQEN | CMDREG_HC)) != 0)
+		goto exit;
 
         /* check if interface is still free */
-        if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) goto exit;
+	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+		goto exit;
         if (!(status & STATUSREG_FR)) {
                 /* it wasn't free => try again later */
                 status = -EAGAIN;
@@ -691,29 +753,38 @@
         }
 
         /* send the amount of data */
-        if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH, bytes_write >> 8)) != 0) goto exit;
-        if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW, bytes_write & 0xff)) != 0) goto exit;
+	if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH, bytes_write >> 8)) != 0)
+		goto exit;
+	if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW,
+						 bytes_write & 0xff)) != 0)
+		goto exit;
 
         /* send the buffer */
         for(i=0; i < bytes_write; i++) {
-                if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA, buf[i])) != 0) goto exit;
+		if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA, buf[i])) != 0)
+			goto exit;
         }
 
         /* check for write error (WE should now be 0) */
-        if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) goto exit;
+	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
+		goto exit;
         if (status & STATUSREG_WE) {
+		ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
                 status = -EIO;
                 goto exit;
         }
         status = bytes_write;
 
+	dprintk("Wrote CA packet for slot %i, connection id 0x%x last_frag:%i size:0x%x\n", slot,
+		buf[0], (buf[1] & 0x80) == 0, bytes_write);
+
 exit:
         ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
 
 exitnowrite:
-        up(&ca->slot_info[slot].sem);
         return status;
 }
+EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
 
 
 
@@ -729,16 +800,15 @@
  */
 static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private* ca, int slot)
 {
-        int status;
-
         dprintk ("%s\n", __FUNCTION__);
 
-        if ((status = down_interruptible(&ca->slot_info[slot].sem)) != 0) return status;
+        down_write(&ca->slot_info[slot].sem);
         ca->pub->slot_shutdown(ca->pub, slot);
         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
-        if (ca->slot_info[slot].rx_buffer.data) vfree(ca->slot_info[slot].rx_buffer.data);
+	if (ca->slot_info[slot].rx_buffer.data)
+		vfree(ca->slot_info[slot].rx_buffer.data);
         ca->slot_info[slot].rx_buffer.data = NULL;
-        up(&ca->slot_info[slot].sem);
+        up_write(&ca->slot_info[slot].sem);
 
         /* need to wake up all processes to check if they're now
            trying to write to a defunct CAM */
@@ -749,6 +819,7 @@
         /* success */
         return 0;
 }
+EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
 
 
 /**
@@ -777,6 +848,7 @@
         atomic_inc(&ca->slot_info[slot].camchange_count);
         dvb_ca_en50221_thread_wakeup(ca);
 }
+EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
 
 
 /**
@@ -821,10 +893,8 @@
                 break;
 
         case DVB_CA_SLOTSTATE_RUNNING:
-                flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS);
-                if (flags & STATUSREG_DA) {
-                        dvb_ca_en50221_thread_wakeup(ca);
-                }
+		if (ca->open)
+			dvb_ca_en50221_read_data(ca, slot, NULL, 0);
                 break;
         }
 }
@@ -860,7 +930,8 @@
                 ca->wakeup = 0;
                 return 1;
         }
-        if (ca->exit) return 1;
+	if (ca->exit)
+		return 1;
    
         return 0;
 }
@@ -910,7 +981,8 @@
                         break;
                 }
 
-                if (delay < curdelay) curdelay = delay;
+		if (delay < curdelay)
+			curdelay = delay;
         }
 
         ca->delay = curdelay;
@@ -927,6 +999,7 @@
         char name[15];
         int slot;
         int flags;
+	int status;
         int pktcount;
         void* rxbuf;
 
@@ -934,7 +1007,11 @@
 
         /* setup kernel thread */
         snprintf(name, sizeof(name), "kdvb-ca-%i:%i", ca->dvbdev->adapter->num, ca->dvbdev->id);
-        dvb_kernel_thread_setup(name);
+
+        lock_kernel ();
+        daemonize (name);
+        sigfillset (&current->blocked);
+        unlock_kernel ();
 
         /* choose the correct initial delay */
         dvb_ca_en50221_thread_update_delay(ca);
@@ -943,7 +1020,9 @@
         while(!ca->exit) {
                 /* sleep for a bit */
                 if (!ca->wakeup) {
-                        flags = wait_event_interruptible_timeout(ca->thread_queue, dvb_ca_en50221_thread_should_wakeup(ca), ca->delay);
+			flags = wait_event_interruptible_timeout(ca->thread_queue,
+								 dvb_ca_en50221_thread_should_wakeup(ca),
+								 ca->delay);
                         if ((flags == -ERESTARTSYS) || ca->exit) {
                                 /* got signal or quitting */
                                 break;
@@ -957,7 +1036,8 @@
                         // check the cam status + deal with CAMCHANGEs
                         while(dvb_ca_en50221_check_camstatus(ca, slot)) {
                                 /* clear down an old CI slot if necessary */
-                                if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) dvb_ca_en50221_slot_shutdown(ca, slot);
+				if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE)
+					dvb_ca_en50221_slot_shutdown(ca, slot);
 
                                 /* if a CAM is NOW present, initialise it */
                                 if (ca->slot_info[slot].camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) {
@@ -984,7 +1064,8 @@
 
                         case DVB_CA_SLOTSTATE_WAITREADY:
                                 if (time_after(jiffies, ca->slot_info[slot].timeout)) {
-                                        printk("dvb_ca: PC card did not respond :(\n");
+					printk("dvb_ca adaptor %d: PC card did not respond :(\n",
+					       ca->dvbdev->adapter->num);
                                         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
 				        dvb_ca_en50221_thread_update_delay(ca);
                                         break;
@@ -993,14 +1074,25 @@
                                 break;
 
                         case DVB_CA_SLOTSTATE_VALIDATE:
-                                if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) {
-                                        printk("dvb_ca: Invalid PC card inserted :(\n");
+				if (dvb_ca_en50221_parse_attributes(ca, slot)
+				    != 0) {
+					printk("dvb_ca adapter %d: Invalid PC card inserted :(\n",
+					       ca->dvbdev->adapter->num);
                                         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
-				        dvb_ca_en50221_thread_update_delay(ca);
+                                        dvb_ca_en50221_thread_update_delay(ca);
                                         break;
                                 }
                                 if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
-                                        printk("dvb_ca: Unable to initialise CAM :(\n");
+					printk("dvb_ca adapter %d: Unable to initialise CAM :(\n",
+					       ca->dvbdev->adapter->num);
+                                        ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
+				        dvb_ca_en50221_thread_update_delay(ca);
+                                        break;
+                                }
+				if (ca->pub->write_cam_control(ca->pub, slot,
+							       CTRLIF_COMMAND, CMDREG_RS) != 0) {
+					printk("dvb_ca adapter %d: Unable to reset CAM IF\n",
+					       ca->dvbdev->adapter->num);
                                         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
 				        dvb_ca_en50221_thread_update_delay(ca);
                                         break;
@@ -1015,7 +1107,8 @@
 
                         case DVB_CA_SLOTSTATE_WAITFR:
                                 if (time_after(jiffies, ca->slot_info[slot].timeout)) {
-                                        printk("dvb_ca: DVB CAM did not respond :(\n");
+					printk("dvb_ca adapter %d: DVB CAM did not respond :(\n",
+					       ca->dvbdev->adapter->num);
                                         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
 				        dvb_ca_en50221_thread_update_delay(ca);
                                         break;
@@ -1030,7 +1123,7 @@
 
                         case DVB_CA_SLOTSTATE_LINKINIT:
                                 if (dvb_ca_en50221_link_init(ca, slot) != 0) {
-                                        printk("dvb_ca: DVB CAM link initialisation failed :(\n");
+                                        printk("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n", ca->dvbdev->adapter->num);
                                         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
 			                dvb_ca_en50221_thread_update_delay(ca);
                                         break;
@@ -1038,25 +1131,34 @@
 
                                 rxbuf = vmalloc(RX_BUFFER_SIZE);
                                 if (rxbuf == NULL) {
-                                        printk("dvb_ca: Unable to allocate CAM rx buffer :(\n");
+                                        printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num);
                                         ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
 				        dvb_ca_en50221_thread_update_delay(ca);
                                         break;
                                 }
+				down_write(&ca->slot_info[slot].sem);
                                 dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
+				up_write(&ca->slot_info[slot].sem);
 
                                 ca->pub->slot_ts_enable(ca->pub, slot);
                                 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING;
                                 dvb_ca_en50221_thread_update_delay(ca);
-                                printk("dvb_ca: DVB CAM detected and initialised successfully\n");
+                                printk("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n", ca->dvbdev->adapter->num);
                                 break;
 
                         case DVB_CA_SLOTSTATE_RUNNING:
-                                if (!ca->open) break;
+				if (!ca->open)
+					continue;
 
+				// no need to poll if the CAM supports IRQs
+				if (ca->slot_info[slot].da_irq_supported)
+					break;
+
+				// poll mode
                                 pktcount = 0;
-                                while(dvb_ca_en50221_read_data(ca, slot, NULL, 0) > 0) {
-                                        if (!ca->open) break;
+				while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) {
+					if (!ca->open)
+						break;
 
                                         /* if a CAMCHANGE occurred at some point, do not do any more processing of this slot */
                                         if (dvb_ca_en50221_check_camstatus(ca, slot)) {
@@ -1100,7 +1202,8 @@
  *
  * @return 0 on success, <0 on error.
  */
-static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *parg)
+static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
+				      unsigned int cmd, void *parg)
 {
         struct dvb_device* dvbdev=(struct dvb_device*) file->private_data;
         struct dvb_ca_private* ca = (struct dvb_ca_private*) dvbdev->priv;
@@ -1115,15 +1218,16 @@
                         if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) {
                                 dvb_ca_en50221_slot_shutdown(ca, slot);
                                 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
-                                        dvb_ca_en50221_camchange_irq(ca->pub, slot, DVB_CA_EN50221_CAMCHANGE_INSERTED);
+					dvb_ca_en50221_camchange_irq(ca->pub,
+								     slot,
+								     DVB_CA_EN50221_CAMCHANGE_INSERTED);
                         }
                 }
                 ca->next_read_slot = 0;
                 dvb_ca_en50221_thread_wakeup(ca);
                 break;
 
-        case CA_GET_CAP:
-        {
+	case CA_GET_CAP: {
                 struct ca_caps *caps = (struct ca_caps*) parg;
 
                 caps->slot_num=ca->slot_count;
@@ -1133,9 +1237,7 @@
                 break;
         }
 
-
-        case CA_GET_SLOT_INFO:
-        {
+	case CA_GET_SLOT_INFO: {
                 struct ca_slot_info *info=(struct ca_slot_info *)parg;
 
                 if ((info->num > ca->slot_count) || (info->num < 0))
@@ -1143,8 +1245,8 @@
 
                 info->type = CA_CI_LINK;
                 info->flags = 0;
-                if ((ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_NONE) &&
-                    (ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_INVALID)) {
+		if ((ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_NONE)
+			&& (ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_INVALID)) {
                         info->flags = CA_CI_MODULE_PRESENT;
                 }
                 if (ca->slot_info[info->num].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
@@ -1172,7 +1274,8 @@
  *
  * @return 0 on success, <0 on error.
  */
-static int dvb_ca_en50221_io_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static int dvb_ca_en50221_io_ioctl(struct inode *inode, struct file *file,
+				   unsigned int cmd, unsigned long arg)
 {
         return dvb_usercopy(inode, file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
 }
@@ -1188,7 +1291,8 @@
  *
  * @return Number of bytes read, or <0 on error.
  */
-static ssize_t dvb_ca_en50221_io_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
+static ssize_t dvb_ca_en50221_io_write(struct file *file,
+				       const char __user * buf, size_t count, loff_t * ppos)
 {
         struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
         struct dvb_ca_private *ca=(struct dvb_ca_private*) dvbdev->priv;
@@ -1196,44 +1300,57 @@
         int status;
         char fragbuf[HOST_LINK_BUF_SIZE];
         int fragpos = 0;
-        size_t fraglen;
+        int fraglen;
         unsigned long timeout;
         int written;
 
         dprintk ("%s\n", __FUNCTION__);
 
         /* Incoming packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */
-        if (count < 2) return -EINVAL;
+	if (count < 2)
+		return -EINVAL;
 
         /* extract slot & connection id */
-        if (copy_from_user(&slot, buf, 1)) return -EFAULT;
-        if (copy_from_user(&connection_id, buf+1, 1)) return -EFAULT;
+	if (copy_from_user(&slot, buf, 1))
+		return -EFAULT;
+	if (copy_from_user(&connection_id, buf + 1, 1))
+		return -EFAULT;
         buf+=2;
         count-=2;
 
         /* check if the slot is actually running */
-        if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) return -EINVAL;
+	if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
+		return -EINVAL;
 
         /* fragment the packets & store in the buffer */
         while(fragpos < count) {
                 fraglen = ca->slot_info[slot].link_buf_size - 2;
-                if ((count - fragpos) < fraglen) fraglen = count - fragpos;
+		if ((count - fragpos) < fraglen)
+			fraglen = count - fragpos;
 
                 fragbuf[0] = connection_id;
                 fragbuf[1] = ((fragpos + fraglen) < count) ? 0x80 : 0x00;
-                if ((status = copy_from_user(fragbuf+2, buf+fragpos, fraglen)) != 0) goto exit;
+		if ((status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen)) != 0)
+			goto exit;
 
 		timeout = jiffies + HZ/2;
 	        written = 0;
                 while(!time_after(jiffies, timeout)) {
+			/* check the CAM hasn't been removed/reset in the meantime */
+			if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) {
+				status = -EIO;
+				goto exit;
+			}
+
                         status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen+2);
 		        if (status == (fraglen+2)) {
 			       written = 1;
 			       break;
 			}
-                        if (status != -EAGAIN) goto exit;
+			if (status != -EAGAIN)
+				goto exit;
 
-                        dvb_delay(1);
+                        msleep(1);
                 }
 	        if (!written) {
 		        status = -EIO;
@@ -1257,21 +1374,28 @@
         int slot;
         int slot_count = 0;
         int idx;
-        size_t fraglen;
+        int fraglen;
         int connection_id = -1;
         int found = 0;
         u8 hdr[2];
 
         slot = ca->next_read_slot;
         while((slot_count < ca->slot_count) && (!found)) {
-                if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) goto nextslot;
+		if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
+			goto nextslot;
 
-                if ((*result = down_interruptible(&ca->slot_info[slot].sem)) != 0) return 1;
+                down_read(&ca->slot_info[slot].sem);
+
+		if (ca->slot_info[slot].rx_buffer.data == NULL) {
+			up_read(&ca->slot_info[slot].sem);
+			return 0;
+		}
 
                 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, -1, &fraglen);
                 while(idx != -1) {
                         dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 0, hdr, 2, 0);
-                        if (connection_id == -1) connection_id = hdr[0];
+			if (connection_id == -1)
+				connection_id = hdr[0];
                         if ((hdr[0] == connection_id) && ((hdr[1] & 0x80) == 0)) {
                                 *_slot = slot;
                                 found = 1;
@@ -1281,7 +1405,8 @@
                         idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
                 }
 
-                if (!found) up(&ca->slot_info[slot].sem);
+		if (!found)
+			up_read(&ca->slot_info[slot].sem);
 
 nextslot:
                 slot = (slot + 1) % ca->slot_count;
@@ -1303,7 +1428,8 @@
  *
  * @return Number of bytes read, or <0 on error.
  */
-static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
+				      size_t count, loff_t * ppos)
 {
         struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
         struct dvb_ca_private *ca=(struct dvb_ca_private*) dvbdev->priv;
@@ -1321,19 +1447,24 @@
         dprintk ("%s\n", __FUNCTION__);
 
         /* Outgoing packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */
-        if (count < 2) return -EINVAL;
+	if (count < 2)
+		return -EINVAL;
 
         /* wait for some data */
         if ((status = dvb_ca_en50221_io_read_condition(ca, &result, &slot)) == 0) {
 
                 /* if we're in nonblocking mode, exit immediately */
-                if (file->f_flags & O_NONBLOCK) return -EWOULDBLOCK;
+		if (file->f_flags & O_NONBLOCK)
+			return -EWOULDBLOCK;
 
                 /* wait for some data */
-                status = wait_event_interruptible(ca->wait_queue, dvb_ca_en50221_io_read_condition(ca, &result, &slot));
+		status = wait_event_interruptible(ca->wait_queue,
+						  dvb_ca_en50221_io_read_condition
+						  (ca, &result, &slot));
         }
         if ((status < 0) || (result < 0)) {
-                if (result) return result;
+		if (result)
+			return result;
                 return status;
         }
 
@@ -1341,13 +1472,14 @@
         pktlen = 2;
         do {
                 if (idx == -1) {
-                        printk("dvb_ca: BUG: read packet ended before last_fragment encountered\n");
+                        printk("dvb_ca adapter %d: BUG: read packet ended before last_fragment encountered\n", ca->dvbdev->adapter->num);
                         status = -EIO;
                         goto exit;
                 }
 
                 dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 0, hdr, 2, 0);
-                if (connection_id == -1) connection_id = hdr[0];
+		if (connection_id == -1)
+			connection_id = hdr[0];
                 if (hdr[0] == connection_id) {
                         if (pktlen < count) {
                                 if ((pktlen + fraglen - 2) > count) {
@@ -1356,29 +1488,33 @@
                                         fraglen -= 2;
                                 }
 
-			        if ((status = dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 2, buf + pktlen, fraglen, 1)) < 0) {
+				if ((status = dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 2,
+								      buf + pktlen, fraglen, 1)) < 0) {
                                         goto exit;
                                 }
                                 pktlen += fraglen;
                         }
 
-                        if ((hdr[1] & 0x80) == 0) last_fragment = 1;
+			if ((hdr[1] & 0x80) == 0)
+				last_fragment = 1;
                         dispose = 1;
                 }
 
                 idx2 = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
-                if (dispose) dvb_ringbuffer_pkt_dispose(&ca->slot_info[slot].rx_buffer, idx);
+		if (dispose)
+			dvb_ringbuffer_pkt_dispose(&ca->slot_info[slot].rx_buffer, idx);
                 idx = idx2;
                 dispose = 0;
         } while (!last_fragment);
 
         hdr[0] = slot;
         hdr[1] = connection_id;
-        if ((status = copy_to_user(buf, hdr, 2)) != 0) goto exit;
+	if ((status = copy_to_user(buf, hdr, 2)) != 0)
+		goto exit;
         status = pktlen;
 
 exit:
-        up(&ca->slot_info[slot].sem);
+        up_read(&ca->slot_info[slot].sem);
         return status;
 }
 
@@ -1400,13 +1536,21 @@
 
         dprintk ("%s\n", __FUNCTION__);
 
+	if (!try_module_get(ca->pub->owner))
+		return -EIO;
+
         err=dvb_generic_open(inode, file);
         if (err<0)
                 return err;
 
         for(i=0; i< ca->slot_count; i++) {
+
                 if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
+		        down_write(&ca->slot_info[i].sem);
+			if (ca->slot_info[i].rx_buffer.data != NULL) {
                         dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer);
+			}
+		        up_write(&ca->slot_info[i].sem);
                 }
         }
 
@@ -1430,7 +1574,7 @@
 {
         struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
         struct dvb_ca_private *ca=(struct dvb_ca_private*) dvbdev->priv;
-        int err;
+	int err = 0;
 
         dprintk ("%s\n", __FUNCTION__);
 
@@ -1439,8 +1583,9 @@
         dvb_ca_en50221_thread_update_delay(ca);
 
         err=dvb_generic_release(inode, file);
-        if (err<0)
-                return err;
+
+	module_put(ca->pub->owner);
+
         return 0;
 }
 
@@ -1464,43 +1609,45 @@
         dprintk ("%s\n", __FUNCTION__);
 
         if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
-                up(&ca->slot_info[slot].sem);
+                up_read(&ca->slot_info[slot].sem);
                 mask |= POLLIN;
         }
 
         /* if there is something, return now */
-        if (mask) return mask;
+	if (mask)
+		return mask;
 
         /* wait for something to happen */
         poll_wait(file, &ca->wait_queue, wait);
 
         if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
-                up(&ca->slot_info[slot].sem);
+                up_read(&ca->slot_info[slot].sem);
                 mask |= POLLIN;
         }
 
         return mask;
 }
+EXPORT_SYMBOL(dvb_ca_en50221_init);
 
 
 static struct file_operations dvb_ca_fops = {
-        .owner = THIS_MODULE,
-        .read = dvb_ca_en50221_io_read,
-        .write = dvb_ca_en50221_io_write,
-        .ioctl = dvb_ca_en50221_io_ioctl,
-        .open = dvb_ca_en50221_io_open,
-        .release = dvb_ca_en50221_io_release,
-        .poll = dvb_ca_en50221_io_poll,
+	.owner	= THIS_MODULE,
+	.read	= dvb_ca_en50221_io_read,
+	.write	= dvb_ca_en50221_io_write,
+	.ioctl	= dvb_ca_en50221_io_ioctl,
+	.open	= dvb_ca_en50221_io_open,
+	.release= dvb_ca_en50221_io_release,
+	.poll	= dvb_ca_en50221_io_poll,
 };
 
 static struct dvb_device dvbdev_ca = {
-        .users = 1,
-        .readers = 1,
-        .writers = 1,
-        .fops = &dvb_ca_fops,
+        .priv	= NULL,
+	.users	= 1,
+	.readers= 1,
+	.writers= 1,
+	.fops	= &dvb_ca_fops,
 };
 
-
 /* ******************************************************************************** */
 /* Initialisation/shutdown functions */
 
@@ -1515,7 +1662,8 @@
  *
  * @return 0 on success, nonzero on failure
  */
-int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, struct dvb_ca_en50221* pubca, int flags, int slot_count)
+int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
+			struct dvb_ca_en50221 *pubca, int flags, int slot_count)
 {
         int ret;
         struct dvb_ca_private* ca = NULL;
@@ -1523,10 +1671,13 @@
 
         dprintk ("%s\n", __FUNCTION__);
 
-        if (slot_count < 1) return -EINVAL;
+	if (slot_count < 1)
+		return -EINVAL;
 
         /* initialise the system data */
-        if ((ca = (struct dvb_ca_private*) kmalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) {
+	if ((ca =
+	     (struct dvb_ca_private *) kmalloc(sizeof(struct dvb_ca_private),
+					       GFP_KERNEL)) == NULL) {
                 ret = -ENOMEM;
                 goto error;
         }
@@ -1550,7 +1701,8 @@
 
         /* register the DVB device */
         ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA);
-        if (ret) goto error;
+	if (ret)
+		goto error;
 
         /* now initialise each slot */
         for(i=0; i< slot_count; i++) {
@@ -1558,7 +1710,7 @@
                 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE;
                 atomic_set(&ca->slot_info[i].camchange_count, 0);
                 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
-                init_MUTEX(&ca->slot_info[i].sem);
+                init_rwsem(&ca->slot_info[i].sem);
         }
 
         if (signal_pending(current)) {
@@ -1578,13 +1730,16 @@
 
 error:
         if (ca != NULL) {
-                if (ca->dvbdev != NULL) dvb_unregister_device(ca->dvbdev);
-                if (ca->slot_info != NULL) kfree(ca->slot_info);
+		if (ca->dvbdev != NULL)
+			dvb_unregister_device(ca->dvbdev);
+		if (ca->slot_info != NULL)
+			kfree(ca->slot_info);
                 kfree(ca);
         }
         pubca->private = NULL;
         return ret;
 }
+EXPORT_SYMBOL(dvb_ca_en50221_release);
 
 
 
@@ -1604,7 +1759,8 @@
         /* shutdown the thread if there was one */
         if (ca->thread_pid) {
                 if (kill_proc(ca->thread_pid, 0, 1) == -ESRCH) {
-                        printk("dvb_ca_release: thread PID %d already died\n", ca->thread_pid);
+			printk("dvb_ca_release adapter %d: thread PID %d already died\n",
+			       ca->dvbdev->adapter->num, ca->thread_pid);
                 } else {
                         ca->exit = 1;
                         mb();
@@ -1622,6 +1778,3 @@
         pubca->private = NULL;
 }
 
-MODULE_PARM(dvb_ca_en50221_debug,"i");
-
-MODULE_PARM_DESC(dvb_ca_en50221_debug, "enable verbose debug messages");
diff -Nru a/drivers/media/dvb/dvb-core/dvb_ca_en50221.h b/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.h	2004-12-24 13:37:19 -08:00
@@ -42,6 +42,12 @@
 /* Structure describing a CA interface */
 struct dvb_ca_en50221 {
 
+	/* the module owning this structure */
+	struct module* owner;
+
+	/* NOTE: the read_*, write_* and poll_slot_status functions must use locks as
+	 * they may be called from several threads at once */
+
 	/* functions for accessing attribute memory on the CAM */
 	int (*read_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address);
 	int (*write_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address, u8 value);
@@ -59,7 +65,7 @@
 	* Poll slot status.
 	* Only necessary if DVB_CA_FLAG_EN50221_IRQ_CAMCHANGE is not set
 	*/
-	int (*poll_slot_status)(struct dvb_ca_en50221* ca, int slot);
+	int (*poll_slot_status)(struct dvb_ca_en50221* ca, int slot, int open);
 
 	/* private data, used by caller */
 	void* data;
diff -Nru a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
--- a/drivers/media/dvb/dvb-core/dvb_demux.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c	2004-12-24 13:36:19 -08:00
@@ -31,7 +31,6 @@
 #include <asm/uaccess.h>
 
 #include "dvb_demux.h"
-#include "dvb_functions.h"
 
 #define NOBUFS  
 /* 
@@ -425,7 +424,7 @@
 			feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK);
 	}
 }
-
+EXPORT_SYMBOL(dvb_dmx_swfilter_packet);
 
 void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t count)
 {
@@ -440,6 +439,7 @@
 
 	spin_unlock(&demux->lock);
 }
+EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
 
 
 void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
@@ -479,6 +479,7 @@
 bailout:
 	spin_unlock(&demux->lock);
 }
+EXPORT_SYMBOL(dvb_dmx_swfilter);
 
 void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
 {
@@ -523,6 +524,7 @@
 bailout:
 	spin_unlock(&demux->lock);
 }
+EXPORT_SYMBOL(dvb_dmx_swfilter_204);
 
 
 static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux)
@@ -570,24 +572,30 @@
 
 static void dvb_demux_feed_add(struct dvb_demux_feed *feed)
 {
+	spin_lock_irq(&feed->demux->lock);
 	if (dvb_demux_feed_find(feed)) {
 		printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n",
 				__FUNCTION__, feed->type, feed->state, feed->pid);
-		return;
+		goto out;
 	}
 
 	list_add(&feed->list_head, &feed->demux->feed_list);
+out:
+	spin_unlock_irq(&feed->demux->lock);
 }
 
 static void dvb_demux_feed_del(struct dvb_demux_feed *feed)
 {
+	spin_lock_irq(&feed->demux->lock);
 	if (!(dvb_demux_feed_find(feed))) {
 		printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n",
 				__FUNCTION__, feed->type, feed->state, feed->pid);
-		return;
+		goto out;
 }
 
 	list_del(&feed->list_head);
+out:
+	spin_unlock_irq(&feed->demux->lock);
 }
 
 static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, 
@@ -789,7 +797,7 @@
 
 		feed->pid = 0xffff;
 	
-	if (feed->ts_type & TS_DECODER)
+	if (feed->ts_type & TS_DECODER && feed->pes_type < DMX_TS_PES_OTHER)
 		demux->pesfilter[feed->pes_type] = NULL;
 
 	up(&demux->mutex);
@@ -1158,6 +1166,7 @@
 	up(&dvbdemux->mutex);
 	return 0;
 }
+EXPORT_SYMBOL(dvbdmx_connect_frontend);
 
 
 int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
@@ -1171,6 +1180,7 @@
 	up(&dvbdemux->mutex);
 	return 0;
 }
+EXPORT_SYMBOL(dvbdmx_disconnect_frontend);
 
 
 static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids)
@@ -1251,6 +1261,7 @@
 
 	return 0;
 }
+EXPORT_SYMBOL(dvb_dmx_init);
 
 
 int dvb_dmx_release(struct dvb_demux *dvbdemux)
@@ -1264,3 +1275,5 @@
 		vfree(dvbdemux->feed);
 	return 0;
 }
+EXPORT_SYMBOL(dvb_dmx_release);
+
diff -Nru a/drivers/media/dvb/dvb-core/dvb_filter.c b/drivers/media/dvb/dvb-core/dvb_filter.c
--- a/drivers/media/dvb/dvb-core/dvb_filter.c	2004-12-24 13:37:34 -08:00
+++ b/drivers/media/dvb/dvb-core/dvb_filter.c	2004-12-24 13:37:34 -08:00
@@ -3,19 +3,20 @@
 #include <linux/string.h>
 #include "dvb_filter.h"
 
-unsigned int bitrates[3][16] =
+#if 0
+static unsigned int bitrates[3][16] =
 {{0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0},
  {0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,0},
  {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0}};
+#endif
 
-u32 freq[4] = {441, 480, 320, 0};
+static u32 freq[4] = {480, 441, 320, 0};
 
-unsigned int ac3_bitrates[32] =
+static unsigned int ac3_bitrates[32] =
     {32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,576,640,
      0,0,0,0,0,0,0,0,0,0,0,0,0};
 
-u32 ac3_freq[4] = {480, 441, 320, 0};
-u32 ac3_frames[3][32] =
+static u32 ac3_frames[3][32] =
     {{64,80,96,112,128,160,192,224,256,320,384,448,512,640,768,896,1024,
       1152,1280,0,0,0,0,0,0,0,0,0,0,0,0,0},
      {69,87,104,121,139,174,208,243,278,348,417,487,557,696,835,975,1114,
@@ -389,6 +390,7 @@
 
 	return 0;
 }
+EXPORT_SYMBOL(dvb_filter_get_ac3info);
 
 
 #if 0
@@ -563,6 +565,7 @@
 	p2ts->cb=cb;
 	p2ts->priv=priv;
 }
+EXPORT_SYMBOL(dvb_filter_pes2ts_init);
 
 int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes,
 		      int len, int payload_start)
@@ -597,4 +600,5 @@
 	memcpy(buf+5+rest, pes, len);
 	return p2ts->cb(p2ts->priv, buf);
 }
+EXPORT_SYMBOL(dvb_filter_pes2ts);
 
diff -Nru a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,6 @@
 /*
- * dvb-core.c: DVB core driver
+ * dvb_frontend.c: DVB frontend tuning interface/thread
+ *
  *
  * Copyright (C) 1999-2001 Ralph  Metzler
  *                         Marcus Metzler
@@ -31,13 +32,33 @@
 #include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/list.h>
+#include <linux/suspend.h>
 #include <asm/processor.h>
 #include <asm/semaphore.h>
 
 #include "dvb_frontend.h"
 #include "dvbdev.h"
-#include "dvb_functions.h"
+
+static int dvb_frontend_debug;
+static int dvb_shutdown_timeout = 5;
+static int dvb_force_auto_inversion;
+static int dvb_override_tune_delay;
+static int dvb_powerdown_on_sleep = 1;
+
+module_param_named(frontend_debug, dvb_frontend_debug, int, 0644);
+MODULE_PARM_DESC(dvb_frontend_debug, "Turn on/off frontend core debugging (default:off).");
+module_param(dvb_shutdown_timeout, int, 0444);
+MODULE_PARM_DESC(dvb_shutdown_timeout, "wait <shutdown_timeout> seconds after close() before suspending hardware");
+module_param(dvb_force_auto_inversion, int, 0444);
+MODULE_PARM_DESC(dvb_force_auto_inversion, "0: normal (default), 1: INVERSION_AUTO forced always");
+module_param(dvb_override_tune_delay, int, 0444);
+MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt");
+module_param(dvb_powerdown_on_sleep, int, 0444);
+MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB volatage off on sleep (default)");
+
+#define dprintk if (dvb_frontend_debug) printk
 
 #define FESTATE_IDLE 1
 #define FESTATE_RETUNE 2
@@ -66,189 +87,9 @@
  * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
  */
 
-
-static int dvb_frontend_debug = 0;
-static int dvb_shutdown_timeout = 5;
-static int dvb_override_frequency_bending = 0;
-static int dvb_force_auto_inversion = 0;
-static int dvb_override_tune_delay = 0;
-
-static int do_frequency_bending = 0;
-
-#define dprintk if (dvb_frontend_debug) printk
-
-#define MAX_EVENT 8
-
-struct dvb_fe_events {
-	struct dvb_frontend_event events[MAX_EVENT];
-	int                       eventw;
-	int                       eventr;
-	int                       overflow;
-	wait_queue_head_t         wait_queue;
-	struct semaphore          sem;
-};
-
-
-struct dvb_frontend_data {
-	struct dvb_frontend_info *info;
-	struct dvb_frontend frontend;
-	struct dvb_device *dvbdev;
-	struct dvb_frontend_parameters parameters;
-	struct dvb_fe_events events;
-	struct semaphore sem;
-	struct list_head list_head;
-	wait_queue_head_t wait_queue;
-	pid_t thread_pid;
-	unsigned long release_jiffies;
-	int state;
-	int bending;
-	int lnb_drift;
-	int inversion;
-	int auto_step;
-	int auto_sub_step;
-	int started_auto_step;
-	int min_delay;
-	int max_drift;
-	int step_size;
-	int exit;
-	int wakeup;
-        fe_status_t status;
-};
-
-
-struct dvb_frontend_ioctl_data {
-	struct list_head list_head;
-	struct dvb_adapter *adapter;
-	int (*before_ioctl) (struct dvb_frontend *frontend,
-			     unsigned int cmd, void *arg);
-	int (*after_ioctl)  (struct dvb_frontend *frontend,
-			     unsigned int cmd, void *arg);
-	void *before_after_data;
-};
-
-
-struct dvb_frontend_notifier_data {
-	struct list_head list_head;
-	struct dvb_adapter *adapter;
-	void (*callback) (fe_status_t s, void *data);
-	void *data;
-};
-
-
-static LIST_HEAD(frontend_list);
-static LIST_HEAD(frontend_ioctl_list);
-static LIST_HEAD(frontend_notifier_list);
-
 static DECLARE_MUTEX(frontend_mutex);
 
-
-static int dvb_frontend_internal_ioctl (struct dvb_frontend *frontend, 
-				 unsigned int cmd, void *arg)
-{
-	int err = -EOPNOTSUPP;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	if (frontend->before_ioctl)
-		err = frontend->before_ioctl (frontend, cmd, arg);
-
-	if (err == -EOPNOTSUPP) {
-		err = frontend->ioctl (frontend, cmd, arg);
-
-		if ((err == -EOPNOTSUPP) && frontend->after_ioctl)
-			err = frontend->after_ioctl (frontend, cmd, arg);
-	}
-
-	return err;
-}
-
-
-/**
- *  if 2 tuners are located side by side you can get interferences when
- *  they try to tune to the same frequency, so both lose sync.
- *  We will slightly mistune in this case. The AFC of the demodulator
- *  should make it still possible to receive the requested transponder 
- *  on both tuners...
- */
-static void dvb_bend_frequency (struct dvb_frontend_data *this_fe, int recursive)
-{
-	struct list_head *entry;
-	int stepsize = this_fe->info->frequency_stepsize;
-	int this_fe_adap_num = this_fe->frontend.i2c->adapter->num;
-	int frequency;
-
-	if (!stepsize || recursive > 10) {
-		printk ("%s: too deep recursion, check frequency_stepsize "
-			"in your frontend code!\n", __FUNCTION__);
-		return;
-	}
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	if (!recursive) {
-		if (down_interruptible (&frontend_mutex))
-			return;
-
-		this_fe->bending = 0;
-	}
-
-	list_for_each (entry, &frontend_list) {
-		struct dvb_frontend_data *fe;
-		int f;
-
-		fe = list_entry (entry, struct dvb_frontend_data, list_head);
-
-		if (fe->frontend.i2c->adapter->num != this_fe_adap_num)
-			continue;
-
-		f = fe->parameters.frequency;
-		f += fe->lnb_drift;
-		f += fe->bending;
-
-		frequency = this_fe->parameters.frequency;
-		frequency += this_fe->lnb_drift;
-		frequency += this_fe->bending;
-
-		if (this_fe != fe && (fe->state != FESTATE_IDLE) &&
-                    frequency > f - stepsize && frequency < f + stepsize)
-		{
-			if (recursive % 2)
-				this_fe->bending += stepsize;
-			else
-				this_fe->bending = -this_fe->bending;
-
-			dvb_bend_frequency (this_fe, recursive + 1);
-			goto done;
-		}
-	}
-done:
-	if (!recursive)
-		up (&frontend_mutex);
-}
-
-
-static void dvb_call_frontend_notifiers (struct dvb_frontend_data *fe,
-				  fe_status_t s)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	if (((s ^ fe->status) & FE_HAS_LOCK) && (s & FE_HAS_LOCK))
-		dvb_delay (fe->info->notifier_delay);
-
-	fe->status = s;
-
-	if (!(s & FE_HAS_LOCK) && (fe->info->caps & FE_CAN_MUTE_TS))
-		return;
-
-	/**
-	 *   now tell the Demux about the TS status changes...
-	 */
-	if (fe->frontend.notifier_callback)
-		fe->frontend.notifier_callback(fe->status, fe->frontend.notifier_data);
-}
-
-
-static void dvb_frontend_add_event (struct dvb_frontend_data *fe, fe_status_t status)
+static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
 {
 	struct dvb_fe_events *events = &fe->events;
 	struct dvb_frontend_event *e;
@@ -272,21 +113,19 @@
 		sizeof (struct dvb_frontend_parameters));
 
 	if (status & FE_HAS_LOCK)
-		dvb_frontend_internal_ioctl (&fe->frontend,
-					     FE_GET_FRONTEND,
-					     &e->parameters);
+		if (fe->ops->get_frontend)
+			fe->ops->get_frontend(fe, &e->parameters);
+
 	events->eventw = wp;
 
 	up (&events->sem);
 
 	e->status = status;
-	dvb_call_frontend_notifiers (fe, status);
 
 	wake_up_interruptible (&events->wait_queue);
 }
 
-
-static int dvb_frontend_get_event (struct dvb_frontend_data *fe,
+static int dvb_frontend_get_event(struct dvb_frontend *fe,
 			    struct dvb_frontend_event *event, int flags)
 {
         struct dvb_fe_events *events = &fe->events;
@@ -329,15 +168,14 @@
         return 0;
 }
 
-static void dvb_frontend_init (struct dvb_frontend_data *fe)
+static void dvb_frontend_init(struct dvb_frontend *fe)
 {
-	struct dvb_frontend *frontend = &fe->frontend;
-
-	dprintk ("DVB: initialising frontend %i:%i (%s)...\n",
-		 frontend->i2c->adapter->num, frontend->i2c->id,
-		 fe->info->name);
+	dprintk ("DVB: initialising frontend %i (%s)...\n",
+		 fe->dvb->num,
+		 fe->ops->info.name);
 
-	dvb_frontend_internal_ioctl (frontend, FE_INIT, NULL);
+	if (fe->ops->init)
+		fe->ops->init(fe);
 }
 
 static void update_delay (int *quality, int *delay, int min_delay, int locked)
@@ -364,32 +202,33 @@
  * @param check_wrapped Checks if an iteration has completed. DO NOT SET ON THE FIRST ATTEMPT
  * @returns Number of complete iterations that have been performed.
  */
-static int dvb_frontend_autotune(struct dvb_frontend_data *fe, int check_wrapped)
+static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped)
 {
 	int autoinversion;
 	int ready = 0;
 	int original_inversion = fe->parameters.inversion;
 	u32 original_frequency = fe->parameters.frequency;
 
-	// are we using autoinversion?
-	autoinversion = ((!(fe->info->caps & FE_CAN_INVERSION_AUTO)) && (fe->parameters.inversion == INVERSION_AUTO));
+	/* are we using autoinversion? */
+	autoinversion = ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&
+			 (fe->parameters.inversion == INVERSION_AUTO));
 
-	// setup parameters correctly
+	/* setup parameters correctly */
 	while(!ready) {
-		// calculate the lnb_drift
+		/* calculate the lnb_drift */
 		fe->lnb_drift = fe->auto_step * fe->step_size;
 
-		// wrap the auto_step if we've exceeded the maximum drift
+		/* wrap the auto_step if we've exceeded the maximum drift */
 		if (fe->lnb_drift > fe->max_drift) {
 			fe->auto_step = 0;
 			fe->auto_sub_step = 0;
 			fe->lnb_drift = 0;
 		}
 
-		// perform inversion and +/- zigzag
+		/* perform inversion and +/- zigzag */
 		switch(fe->auto_sub_step) {
 		case 0:
-			// try with the current inversion and current drift setting
+			/* try with the current inversion and current drift setting */
 			ready = 1;
 			break;
 
@@ -418,42 +257,40 @@
 		    
 		default:
 			fe->auto_step++;
-			fe->auto_sub_step = -1; // it'll be incremented to 0 in a moment
+			fe->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */
 			break;
 		}
 	    
 		if (!ready) fe->auto_sub_step++;
 	}
 
-	// if this attempt would hit where we started, indicate a complete iteration has occurred
-	if ((fe->auto_step == fe->started_auto_step) && (fe->auto_sub_step == 0) && check_wrapped) {
+	/* if this attempt would hit where we started, indicate a complete
+	 * iteration has occurred */
+	if ((fe->auto_step == fe->started_auto_step) &&
+	    (fe->auto_sub_step == 0) && check_wrapped) {
 		return 1;
 		}
 
-	// perform frequency bending if necessary
-	if ((dvb_override_frequency_bending != 1) && do_frequency_bending)
-		dvb_bend_frequency(fe, 0);
-
-	// instrumentation
-	dprintk("%s: drift:%i bending:%i inversion:%i auto_step:%i auto_sub_step:%i started_auto_step:%i\n", 
-		__FUNCTION__, fe->lnb_drift, fe->bending, fe->inversion, fe->auto_step, fe->auto_sub_step,
-		fe->started_auto_step);
+	dprintk("%s: drift:%i inversion:%i auto_step:%i "
+		"auto_sub_step:%i started_auto_step:%i\n",
+		__FUNCTION__, fe->lnb_drift, fe->inversion,
+		fe->auto_step, fe->auto_sub_step, fe->started_auto_step);
     
-	// set the frontend itself
-	fe->parameters.frequency += fe->lnb_drift + fe->bending;
-	if (autoinversion) fe->parameters.inversion = fe->inversion;
-	dvb_frontend_internal_ioctl (&fe->frontend, FE_SET_FRONTEND, &fe->parameters);
+	/* set the frontend itself */
+	fe->parameters.frequency += fe->lnb_drift;
+	if (autoinversion)
+		fe->parameters.inversion = fe->inversion;
+	if (fe->ops->set_frontend)
+		fe->ops->set_frontend(fe, &fe->parameters);
+
 	fe->parameters.frequency = original_frequency;
 	fe->parameters.inversion = original_inversion;
 
-	// normal return
 	fe->auto_sub_step++;
 	return 0;
 }
 
-
-
-static int dvb_frontend_is_exiting (struct dvb_frontend_data *fe)
+static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
 {
 	if (fe->exit)
 		return 1;
@@ -465,7 +302,7 @@
 	return 0;
 }
 
-static int dvb_frontend_should_wakeup (struct dvb_frontend_data *fe)
+static int dvb_frontend_should_wakeup(struct dvb_frontend *fe)
 {
 	if (fe->wakeup) {
 		fe->wakeup = 0;
@@ -474,14 +311,18 @@
 	return dvb_frontend_is_exiting(fe);
 }
 
-static void dvb_frontend_wakeup (struct dvb_frontend_data *fe) {
+static void dvb_frontend_wakeup(struct dvb_frontend *fe)
+{
 	fe->wakeup = 1;
 	wake_up_interruptible(&fe->wait_queue);
 }
 
+/*
+ * FIXME: use linux/kthread.h
+ */
 static int dvb_frontend_thread (void *data)
 {
-	struct dvb_frontend_data *fe = (struct dvb_frontend_data *) data;
+	struct dvb_frontend *fe = (struct dvb_frontend *) data;
 	unsigned long timeout;
 	char name [15];
 	int quality = 0, delay = 3*HZ;
@@ -490,86 +331,101 @@
 
 	dprintk ("%s\n", __FUNCTION__);
 
-	snprintf (name, sizeof(name), "kdvb-fe-%i:%i",
-		  fe->frontend.i2c->adapter->num, fe->frontend.i2c->id);
+	snprintf (name, sizeof(name), "kdvb-fe-%i", fe->dvb->num);
 
-	dvb_kernel_thread_setup (name);
+        lock_kernel ();
+        daemonize (name);
+        sigfillset (&current->blocked);
+        unlock_kernel ();
 
-	dvb_call_frontend_notifiers (fe, 0);
+	fe->status = 0;
 	dvb_frontend_init (fe);
 	fe->wakeup = 0;
 
 	while (1) {
 		up (&fe->sem);      /* is locked when we enter the thread... */
 
-		timeout = wait_event_interruptible_timeout(fe->wait_queue,0 != dvb_frontend_should_wakeup (fe), delay);
-		if (-ERESTARTSYS == timeout || 0 != dvb_frontend_is_exiting (fe)) {
+		timeout = wait_event_interruptible_timeout(fe->wait_queue,
+							   dvb_frontend_should_wakeup(fe),
+							   delay);
+		if (0 != dvb_frontend_is_exiting (fe)) {
 			/* got signal or quitting */
 			break;
 		}
 
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
+
 		if (down_interruptible (&fe->sem))
 			break;
 
-		// if we've got no parameters, just keep idling
+		/* if we've got no parameters, just keep idling */
 		if (fe->state & FESTATE_IDLE) {
 			delay = 3*HZ;
 			quality = 0;
 			continue;
 		}
 
-		// get the frontend status
-		dvb_frontend_internal_ioctl (&fe->frontend, FE_READ_STATUS, &s);
-		if (s != fe->status)
+retune:
+		/* get the frontend status */
+		if (fe->state & FESTATE_RETUNE) {
+			s = 0;
+		} else {
+			if (fe->ops->read_status)
+				fe->ops->read_status(fe, &s);
+			if (s != fe->status) {
 			dvb_frontend_add_event (fe, s);
-
-		// if we're not tuned, and we have a lock, move to the TUNED state
+				fe->status = s;
+			}
+		}
+		/* if we're not tuned, and we have a lock, move to the TUNED state */
 		if ((fe->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) {
 			update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
 			fe->state = FESTATE_TUNED;
 
-			// if we're tuned, then we have determined the correct inversion
-			if ((!(fe->info->caps & FE_CAN_INVERSION_AUTO)) && (fe->parameters.inversion == INVERSION_AUTO)) {
+			/* if we're tuned, then we have determined the correct inversion */
+			if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&
+			    (fe->parameters.inversion == INVERSION_AUTO)) {
 				fe->parameters.inversion = fe->inversion;
 			}
 			continue;
 		}
 
-		// if we are tuned already, check we're still locked
+		/* if we are tuned already, check we're still locked */
 		if (fe->state & FESTATE_TUNED) {
 			update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
 
-			// we're tuned, and the lock is still good...
-		if (s & FE_HAS_LOCK) {
+			/* we're tuned, and the lock is still good... */
+			if (s & FE_HAS_LOCK)
 				continue;
-		} else {
-				// if we _WERE_ tuned, but now don't have a lock, need to zigzag
+			else {
+				/* if we _WERE_ tuned, but now don't have a lock,
+				 * need to zigzag */
 				fe->state = FESTATE_ZIGZAG_FAST;
 				fe->started_auto_step = fe->auto_step;
 				check_wrapped = 0;
-				// fallthrough
 			}
 		}
 
-		// don't actually do anything if we're in the LOSTLOCK state, the frontend is set to
-		// FE_CAN_RECOVER, and the max_drift is 0
+		/* don't actually do anything if we're in the LOSTLOCK state,
+		 * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */
 		if ((fe->state & FESTATE_LOSTLOCK) && 
-		    (fe->info->caps & FE_CAN_RECOVER) && (fe->max_drift == 0)) {
+		    (fe->ops->info.caps & FE_CAN_RECOVER) && (fe->max_drift == 0)) {
 			update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
 						continue;
 				}
 	    
-		// don't do anything if we're in the DISEQC state, since this might be someone
-		// with a motorized dish controlled by DISEQC. If its actually a re-tune, there will
-		// be a SET_FRONTEND soon enough.
+		/* don't do anything if we're in the DISEQC state, since this
+		 * might be someone with a motorized dish controlled by DISEQC.
+		 * If its actually a re-tune, there will be a SET_FRONTEND soon enough.	*/
 		if (fe->state & FESTATE_DISEQC) {
 			update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
 			continue;
 				}
 
-		// if we're in the RETUNE state, set everything up for a brand new scan,
-		// keeping the current inversion setting, as the next tune is _very_ likely
-		// to require the same
+		/* if we're in the RETUNE state, set everything up for a brand
+		 * new scan, keeping the current inversion setting, as the next
+		 * tune is _very_ likely to require the same */
 		if (fe->state & FESTATE_RETUNE) {
 			fe->lnb_drift = 0;
 			fe->auto_step = 0;
@@ -578,43 +434,47 @@
 			check_wrapped = 0;
 		}
 
-		// fast zigzag.
+		/* fast zigzag. */
 		if ((fe->state & FESTATE_SEARCHING_FAST) || (fe->state & FESTATE_RETUNE)) {
 			delay = fe->min_delay;
 
-			// peform a tune
+			/* peform a tune */
 			if (dvb_frontend_autotune(fe, check_wrapped)) {
-				// OK, if we've run out of trials at the fast speed. Drop back to
-				// slow for the _next_ attempt
+				/* OK, if we've run out of trials at the fast speed.
+				 * Drop back to slow for the _next_ attempt */
 				fe->state = FESTATE_SEARCHING_SLOW;
 				fe->started_auto_step = fe->auto_step;
 				continue;
 			}
 			check_wrapped = 1;
 
-			// if we've just retuned, enter the ZIGZAG_FAST state. This ensures
-			// we cannot return from an FE_SET_FRONTEND ioctl before the first frontend
-			// tune occurs
+			/* if we've just retuned, enter the ZIGZAG_FAST state.
+			 * This ensures we cannot return from an
+			 * FE_SET_FRONTEND ioctl before the first frontend tune
+			 * occurs */
 			if (fe->state & FESTATE_RETUNE) {
 				fe->state = FESTATE_TUNING_FAST;
-				wake_up_interruptible(&fe->wait_queue);
+				goto retune;
 			}
 		}
 
-		// slow zigzag
+		/* slow zigzag */
 		if (fe->state & FESTATE_SEARCHING_SLOW) {
 			update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
 		    
-			// Note: don't bother checking for wrapping; we stay in this state 
-			// until we get a lock
+			/* Note: don't bother checking for wrapping; we stay in this
+			 * state until we get a lock */
 			dvb_frontend_autotune(fe, 0);
 		}
-	};
-
-	if (dvb_shutdown_timeout)
-		dvb_frontend_internal_ioctl (&fe->frontend, FE_SLEEP, NULL); 
+	}
 
-	up (&fe->sem);
+	if (dvb_shutdown_timeout) {
+		if (dvb_powerdown_on_sleep)
+			if (fe->ops->set_voltage)
+				fe->ops->set_voltage(fe, SEC_VOLTAGE_OFF);
+		if (fe->ops->sleep)
+			fe->ops->sleep(fe);
+	}
 
 	fe->thread_pid = 0;
 	mb();
@@ -623,8 +483,7 @@
 	return 0;
 }
 
-
-static void dvb_frontend_stop (struct dvb_frontend_data *fe)
+static void dvb_frontend_stop(struct dvb_frontend *fe)
 {
 	unsigned long ret;
 
@@ -662,8 +521,7 @@
 				fe->thread_pid);
 }
 
-
-static int dvb_frontend_start (struct dvb_frontend_data *fe)
+static int dvb_frontend_start(struct dvb_frontend *fe)
 {
 	int ret;
 
@@ -702,30 +560,120 @@
 			unsigned int cmd, void *parg)
 {
 	struct dvb_device *dvbdev = file->private_data;
-	struct dvb_frontend_data *fe = dvbdev->priv;
-	struct dvb_frontend_tune_settings fetunesettings;
-	int err = 0;
+	struct dvb_frontend *fe = dvbdev->priv;
+	int err = -EOPNOTSUPP;
 
 	dprintk ("%s\n", __FUNCTION__);
 
-	if (!fe || !fe->frontend.ioctl || fe->exit)
+	if (!fe || fe->exit)
 		return -ENODEV;
 
+	if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
+	    (_IOC_DIR(cmd) != _IOC_READ || cmd == FE_GET_EVENT ||
+	     cmd == FE_DISEQC_RECV_SLAVE_REPLY))
+		return -EPERM;
+
 	if (down_interruptible (&fe->sem))
 		return -ERESTARTSYS;
 
 	switch (cmd) {
+	case FE_GET_INFO: {
+		struct dvb_frontend_info* info = (struct dvb_frontend_info*) parg;
+		memcpy(info, &fe->ops->info, sizeof(struct dvb_frontend_info));
+
+		/* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't
+		 * do it, it is done for it. */
+		info->caps |= FE_CAN_INVERSION_AUTO;
+		err = 0;
+		break;
+	}
+
+	case FE_READ_STATUS:
+		if (fe->ops->read_status)
+			err = fe->ops->read_status(fe, (fe_status_t*) parg);
+		break;
+
+	case FE_READ_BER:
+		if (fe->ops->read_ber)
+			err = fe->ops->read_ber(fe, (__u32*) parg);
+		break;
+
+	case FE_READ_SIGNAL_STRENGTH:
+		if (fe->ops->read_signal_strength)
+			err = fe->ops->read_signal_strength(fe, (__u16*) parg);
+		break;
+
+	case FE_READ_SNR:
+		if (fe->ops->read_snr)
+			err = fe->ops->read_snr(fe, (__u16*) parg);
+		break;
+
+	case FE_READ_UNCORRECTED_BLOCKS:
+		if (fe->ops->read_ucblocks)
+			err = fe->ops->read_ucblocks(fe, (__u32*) parg);
+		break;
+
+
+	case FE_DISEQC_RESET_OVERLOAD:
+		if (fe->ops->diseqc_reset_overload) {
+			err = fe->ops->diseqc_reset_overload(fe);
+			fe->state = FESTATE_DISEQC;
+			fe->status = 0;
+		}
+		break;
+
 	case FE_DISEQC_SEND_MASTER_CMD:
+		if (fe->ops->diseqc_send_master_cmd) {
+			err = fe->ops->diseqc_send_master_cmd(fe, (struct dvb_diseqc_master_cmd*) parg);
+			fe->state = FESTATE_DISEQC;
+			fe->status = 0;
+		}
+		break;
+
 	case FE_DISEQC_SEND_BURST:
+		if (fe->ops->diseqc_send_burst) {
+			err = fe->ops->diseqc_send_burst(fe, (fe_sec_mini_cmd_t) parg);
+			fe->state = FESTATE_DISEQC;
+			fe->status = 0;
+		}
+		break;
+
 	case FE_SET_TONE:
-		if (fe->status)
-			dvb_call_frontend_notifiers (fe, 0);
-		dvb_frontend_internal_ioctl (&fe->frontend, cmd, parg);
+		if (fe->ops->set_tone) {
+			err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg);
+			fe->state = FESTATE_DISEQC;
+			fe->status = 0;
+		}
+		break;
+
+	case FE_SET_VOLTAGE:
+		if (fe->ops->set_voltage) {
+			err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg);
 		fe->state = FESTATE_DISEQC;
+			fe->status = 0;
+		}
 		break;
 
-	case FE_SET_FRONTEND:
-		fe->state = FESTATE_RETUNE;
+	case FE_DISHNETWORK_SEND_LEGACY_CMD:
+		if (fe->ops->dishnetwork_send_legacy_command) {
+			err = fe->ops->dishnetwork_send_legacy_command(fe, (unsigned int) parg);
+			fe->state = FESTATE_DISEQC;
+			fe->status = 0;
+		}
+		break;
+
+	case FE_DISEQC_RECV_SLAVE_REPLY:
+		if (fe->ops->diseqc_recv_slave_reply)
+			err = fe->ops->diseqc_recv_slave_reply(fe, (struct dvb_diseqc_slave_reply*) parg);
+		break;
+
+	case FE_ENABLE_HIGH_LNB_VOLTAGE:
+		if (fe->ops->enable_high_lnb_voltage);
+			err = fe->ops->enable_high_lnb_voltage(fe, (int) parg);
+		break;
+
+	case FE_SET_FRONTEND: {
+		struct dvb_frontend_tune_settings fetunesettings;
 	    
 		memcpy (&fe->parameters, parg,
 			sizeof (struct dvb_frontend_parameters));
@@ -734,75 +682,73 @@
 		memcpy(&fetunesettings.parameters, parg,
 		       sizeof (struct dvb_frontend_parameters));
 		    
-		// force auto frequency inversion if requested
+		/* force auto frequency inversion if requested */
 		if (dvb_force_auto_inversion) {
 			fe->parameters.inversion = INVERSION_AUTO;
 			fetunesettings.parameters.inversion = INVERSION_AUTO;
 		}
+		if (fe->ops->info.type == FE_OFDM) {
+			/* without hierachical coding code_rate_LP is irrelevant,
+			 * so we tolerate the otherwise invalid FEC_NONE setting */
+			if (fe->parameters.u.ofdm.hierarchy_information == HIERARCHY_NONE &&
+			    fe->parameters.u.ofdm.code_rate_LP == FEC_NONE)
+				fe->parameters.u.ofdm.code_rate_LP = FEC_AUTO;
+		}
 
-		// get frontend-specific tuning settings
-		if (dvb_frontend_internal_ioctl(&fe->frontend, FE_GET_TUNE_SETTINGS, &fetunesettings) == 0) {
+		/* get frontend-specific tuning settings */
+		if (fe->ops->get_tune_settings && (fe->ops->get_tune_settings(fe, &fetunesettings) == 0)) {
 			fe->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000;
 			fe->max_drift = fetunesettings.max_drift;
 			fe->step_size = fetunesettings.step_size;
 		} else {
-			// default values
-			switch(fe->info->type) {
+			/* default values */
+			switch(fe->ops->info.type) {
 			case FE_QPSK:
-				fe->min_delay = HZ/20; // default mindelay of 50ms
+				fe->min_delay = HZ/20;
 				fe->step_size = fe->parameters.u.qpsk.symbol_rate / 16000;
 				fe->max_drift = fe->parameters.u.qpsk.symbol_rate / 2000;
 		break;
 			    
 			case FE_QAM:
-				fe->min_delay = HZ/20; // default mindelay of 50ms
-				fe->step_size = 0;
-				fe->max_drift = 0; // don't want any zigzagging under DVB-C frontends
+				fe->min_delay = HZ/20;
+				fe->step_size = 0; /* no zigzag */
+				fe->max_drift = 0;
 				break;
 			    
 			case FE_OFDM:
-				fe->min_delay = HZ/20; // default mindelay of 50ms
-				fe->step_size = fe->info->frequency_stepsize * 2;
-				fe->max_drift = (fe->info->frequency_stepsize * 2) + 1;
+				fe->min_delay = HZ/20;
+				fe->step_size = fe->ops->info.frequency_stepsize * 2;
+				fe->max_drift = (fe->ops->info.frequency_stepsize * 2) + 1;
+				break;
+			case FE_ATSC:
+				printk("dvb-core: FE_ATSC not handled yet.\n");
 				break;
 			}
 		}
-		if (dvb_override_tune_delay > 0) {
+		if (dvb_override_tune_delay > 0)
 		       fe->min_delay = (dvb_override_tune_delay * HZ) / 1000;
-		}
 
+		fe->state = FESTATE_RETUNE;
+		dvb_frontend_wakeup(fe);
 		dvb_frontend_add_event (fe, 0);	    
+		fe->status = 0;
+		err = 0;
 		break;
+	}
 
 	case FE_GET_EVENT:
 		err = dvb_frontend_get_event (fe, parg, file->f_flags);
 		break;
+
 	case FE_GET_FRONTEND:
-		memcpy (parg, &fe->parameters,
-			sizeof (struct dvb_frontend_parameters));
-		/*  fall-through... */
-	default:
-		err = dvb_frontend_internal_ioctl (&fe->frontend, cmd, parg);
+		if (fe->ops->get_frontend) {
+			memcpy (parg, &fe->parameters, sizeof (struct dvb_frontend_parameters));
+			err = fe->ops->get_frontend(fe, (struct dvb_frontend_parameters*) parg);
+		}
+		break;
 	};
 
 	up (&fe->sem);
-	if (err < 0)
-		return err;
-
-	// Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't do it, it is done for it.
-	if ((cmd == FE_GET_INFO) && (err == 0)) {
-		struct dvb_frontend_info* tmp = (struct dvb_frontend_info*) parg;
-		tmp->caps |= FE_CAN_INVERSION_AUTO;
-	}
-
-	// if the frontend has just been set, wait until the first tune has finished.
-	// This ensures the app doesn't start reading data too quickly, perhaps from the
-	// previous lock, which is REALLY CONFUSING TO DEBUG!
-	if ((cmd == FE_SET_FRONTEND) && (err == 0)) {
-		dvb_frontend_wakeup(fe);
-		err = wait_event_interruptible(fe->wait_queue, fe->state & ~FESTATE_RETUNE);
-	}
-
 	return err;
 }
 
@@ -810,7 +756,7 @@
 static unsigned int dvb_frontend_poll (struct file *file, struct poll_table_struct *wait)
 {
 	struct dvb_device *dvbdev = file->private_data;
-	struct dvb_frontend_data *fe = dvbdev->priv;
+	struct dvb_frontend *fe = dvbdev->priv;
 
 	dprintk ("%s\n", __FUNCTION__);
 
@@ -826,7 +772,7 @@
 static int dvb_frontend_open (struct inode *inode, struct file *file)
 {
 	struct dvb_device *dvbdev = file->private_data;
-	struct dvb_frontend_data *fe = dvbdev->priv;
+	struct dvb_frontend *fe = dvbdev->priv;
 	int ret;
 
 	dprintk ("%s\n", __FUNCTION__);
@@ -850,7 +796,7 @@
 static int dvb_frontend_release (struct inode *inode, struct file *file)
 {
 	struct dvb_device *dvbdev = file->private_data;
-	struct dvb_frontend_data *fe = dvbdev->priv;
+	struct dvb_frontend *fe = dvbdev->priv;
 
 	dprintk ("%s\n", __FUNCTION__);
 
@@ -861,193 +807,6 @@
 }
 
 
-
-int
-dvb_add_frontend_ioctls (struct dvb_adapter *adapter,
-                         int (*before_ioctl) (struct dvb_frontend *frontend,
-                                              unsigned int cmd, void *arg),
-                         int (*after_ioctl)  (struct dvb_frontend *frontend,
-                                              unsigned int cmd, void *arg),
-			 void *before_after_data)
-{
-	struct dvb_frontend_ioctl_data *ioctl;
-        struct list_head *entry;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	if (down_interruptible (&frontend_mutex))
-		return -ERESTARTSYS;
-
-	ioctl = kmalloc (sizeof(struct dvb_frontend_ioctl_data), GFP_KERNEL);
-
-	if (!ioctl) {
-		up (&frontend_mutex);
-		return -ENOMEM;
-	}
-
-	ioctl->adapter = adapter;
-	ioctl->before_ioctl = before_ioctl;
-	ioctl->after_ioctl = after_ioctl;
-	ioctl->before_after_data = before_after_data;
-
-	list_add_tail (&ioctl->list_head, &frontend_ioctl_list);
-
-	list_for_each (entry, &frontend_list) {
-		struct dvb_frontend_data *fe;
-
-		fe = list_entry (entry, struct dvb_frontend_data, list_head);
-
-		if (fe->frontend.i2c->adapter == adapter &&
-		    fe->frontend.before_ioctl == NULL &&
-		    fe->frontend.after_ioctl == NULL)
-		{
-			fe->frontend.before_ioctl = before_ioctl;
-			fe->frontend.after_ioctl = after_ioctl;
-			fe->frontend.before_after_data = before_after_data;
-		}
-	}
-
-	up (&frontend_mutex);
-
-	return 0;
-}
-
-
-void
-dvb_remove_frontend_ioctls (struct dvb_adapter *adapter,
-			    int (*before_ioctl) (struct dvb_frontend *frontend,
-                                                 unsigned int cmd, void *arg),
-                            int (*after_ioctl)  (struct dvb_frontend *frontend,
-                                                 unsigned int cmd, void *arg))
-{
-	struct list_head *entry, *n;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	down (&frontend_mutex);
-
-	list_for_each (entry, &frontend_list) {
-		struct dvb_frontend_data *fe;
-
-		fe = list_entry (entry, struct dvb_frontend_data, list_head);
-
-		if (fe->frontend.i2c->adapter == adapter &&
-		    fe->frontend.before_ioctl == before_ioctl &&
-		    fe->frontend.after_ioctl == after_ioctl)
-		{
-			fe->frontend.before_ioctl = NULL;
-			fe->frontend.after_ioctl = NULL;
-
-		}
-	}
-
-	list_for_each_safe (entry, n, &frontend_ioctl_list) {
-		struct dvb_frontend_ioctl_data *ioctl;
-
-		ioctl = list_entry (entry, struct dvb_frontend_ioctl_data, list_head);
-
-		if (ioctl->adapter == adapter &&
-		    ioctl->before_ioctl == before_ioctl &&
-		    ioctl->after_ioctl == after_ioctl)
-		{
-			list_del (&ioctl->list_head);
-			kfree (ioctl);
-			
-			break;
-		}
-	}
-
-	up (&frontend_mutex);
-}
-
-
-int
-dvb_add_frontend_notifier (struct dvb_adapter *adapter,
-			   void (*callback) (fe_status_t s, void *data),
-			   void *data)
-{
-	struct dvb_frontend_notifier_data *notifier;
-	struct list_head *entry;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	if (down_interruptible (&frontend_mutex))
-		return -ERESTARTSYS;
-
-	notifier = kmalloc (sizeof(struct dvb_frontend_notifier_data), GFP_KERNEL);
-
-	if (!notifier) {
-		up (&frontend_mutex);
-		return -ENOMEM;
-	}
-
-	notifier->adapter = adapter;
-	notifier->callback = callback;
-	notifier->data = data;
-
-	list_add_tail (&notifier->list_head, &frontend_notifier_list);
-
-	list_for_each (entry, &frontend_list) {
-		struct dvb_frontend_data *fe;
-
-		fe = list_entry (entry, struct dvb_frontend_data, list_head);
-
-		if (fe->frontend.i2c->adapter == adapter &&
-		    fe->frontend.notifier_callback == NULL)
-		{
-			fe->frontend.notifier_callback = callback;
-			fe->frontend.notifier_data = data;
-		}
-	}
-
-	up (&frontend_mutex);
-
-	return 0;
-}
-
-
-void
-dvb_remove_frontend_notifier (struct dvb_adapter *adapter,
-			      void (*callback) (fe_status_t s, void *data))
-{
-	struct list_head *entry, *n;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	down (&frontend_mutex);
-
-	list_for_each (entry, &frontend_list) {
-		struct dvb_frontend_data *fe;
-
-		fe = list_entry (entry, struct dvb_frontend_data, list_head);
-
-		if (fe->frontend.i2c->adapter == adapter &&
-		    fe->frontend.notifier_callback == callback)
-		{
-			fe->frontend.notifier_callback = NULL;
-
-		}
-	}
-
-	list_for_each_safe (entry, n, &frontend_notifier_list) {
-		struct dvb_frontend_notifier_data *notifier;
-
-		notifier = list_entry (entry, struct dvb_frontend_notifier_data, list_head);
-
-		if (notifier->adapter == adapter &&
-		    notifier->callback == callback)
-		{
-			list_del (&notifier->list_head);
-			kfree (notifier);
-			
-			break;
-		}
-	}
-
-	up (&frontend_mutex);
-}
-
-
 static struct file_operations dvb_frontend_fops = {
 	.owner		= THIS_MODULE,
 	.ioctl		= dvb_generic_ioctl,
@@ -1056,17 +815,9 @@
 	.release	= dvb_frontend_release
 };
 
-
-
-int
-dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
-				     unsigned int cmd, void *arg),
-		       struct dvb_i2c_bus *i2c,
-		       void *data,
-		       struct dvb_frontend_info *info)
+int dvb_register_frontend(struct dvb_adapter* dvb,
+			  struct dvb_frontend* fe)
 {
-	struct list_head *entry;
-	struct dvb_frontend_data *fe;
 	static const struct dvb_device dvbdev_template = {
 		.users = ~0,
 		.writers = 1,
@@ -1080,110 +831,39 @@
 	if (down_interruptible (&frontend_mutex))
 		return -ERESTARTSYS;
 
-	if (!(fe = kmalloc (sizeof (struct dvb_frontend_data), GFP_KERNEL))) {
-		up (&frontend_mutex);
-		return -ENOMEM;
-	}
-
-	memset (fe, 0, sizeof (struct dvb_frontend_data));
-
 	init_MUTEX (&fe->sem);
 	init_waitqueue_head (&fe->wait_queue);
 	init_waitqueue_head (&fe->events.wait_queue);
 	init_MUTEX (&fe->events.sem);
 	fe->events.eventw = fe->events.eventr = 0;
 	fe->events.overflow = 0;
-
-	fe->frontend.ioctl = ioctl;
-	fe->frontend.i2c = i2c;
-	fe->frontend.data = data;
-	fe->info = info;
+	fe->dvb = dvb;
 	fe->inversion = INVERSION_OFF;
 
-	list_for_each (entry, &frontend_ioctl_list) {
-		struct dvb_frontend_ioctl_data *ioctl;
-
-		ioctl = list_entry (entry,
-				    struct dvb_frontend_ioctl_data,
-				    list_head);
-
-		if (ioctl->adapter == i2c->adapter) {
-			fe->frontend.before_ioctl = ioctl->before_ioctl;
-			fe->frontend.after_ioctl = ioctl->after_ioctl;
-			fe->frontend.before_after_data = ioctl->before_after_data;
-			break;
-		}
-	}
-
-	list_for_each (entry, &frontend_notifier_list) {
-		struct dvb_frontend_notifier_data *notifier;
+	printk ("DVB: registering frontend %i (%s)...\n",
+		fe->dvb->num,
+		fe->ops->info.name);
 
-		notifier = list_entry (entry,
-				       struct dvb_frontend_notifier_data,
-				       list_head);
-
-		if (notifier->adapter == i2c->adapter) {
-			fe->frontend.notifier_callback = notifier->callback;
-			fe->frontend.notifier_data = notifier->data;
-			break;
-		}
-	}
-
-	list_add_tail (&fe->list_head, &frontend_list);
-
-	printk ("DVB: registering frontend %i:%i (%s)...\n",
-		fe->frontend.i2c->adapter->num, fe->frontend.i2c->id,
-		fe->info->name);
-
-	dvb_register_device (i2c->adapter, &fe->dvbdev, &dvbdev_template,
+	dvb_register_device (fe->dvb, &fe->dvbdev, &dvbdev_template,
 			     fe, DVB_DEVICE_FRONTEND);
 
-	if ((info->caps & FE_NEEDS_BENDING) || (dvb_override_frequency_bending == 2))
-		do_frequency_bending = 1;
-    
 	up (&frontend_mutex);
-
 	return 0;
 }
+EXPORT_SYMBOL(dvb_register_frontend);
 
-
-int dvb_unregister_frontend (int (*ioctl) (struct dvb_frontend *frontend,
-					   unsigned int cmd, void *arg),
-			     struct dvb_i2c_bus *i2c)
+int dvb_unregister_frontend(struct dvb_frontend* fe)
 {
-        struct list_head *entry, *n;
-
 	dprintk ("%s\n", __FUNCTION__);
 
 	down (&frontend_mutex);
-
-	list_for_each_safe (entry, n, &frontend_list) {
-		struct dvb_frontend_data *fe;
-
-		fe = list_entry (entry, struct dvb_frontend_data, list_head);
-
-		if (fe->frontend.ioctl == ioctl && fe->frontend.i2c == i2c) {
 			dvb_unregister_device (fe->dvbdev);
-			list_del (entry);
-			up (&frontend_mutex);
 			dvb_frontend_stop (fe);
-			kfree (fe);
-			return 0;
-		}
-	}
-
+	if (fe->ops->release)
+		fe->ops->release(fe);
+	else
+		printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops->info.name);
 	up (&frontend_mutex);
-	return -EINVAL;
+	return 0;
 }
-
-MODULE_PARM(dvb_frontend_debug,"i");
-MODULE_PARM(dvb_shutdown_timeout,"i");
-MODULE_PARM(dvb_override_frequency_bending,"i");
-MODULE_PARM(dvb_force_auto_inversion,"i");
-MODULE_PARM(dvb_override_tune_delay,"i");
-
-MODULE_PARM_DESC(dvb_frontend_debug, "enable verbose debug messages");
-MODULE_PARM_DESC(dvb_shutdown_timeout, "wait <shutdown_timeout> seconds after close() before suspending hardware");
-MODULE_PARM_DESC(dvb_override_frequency_bending, "0: normal (default), 1: never use frequency bending, 2: always use frequency bending");
-MODULE_PARM_DESC(dvb_force_auto_inversion, "0: normal (default), 1: INVERSION_AUTO forced always");
-MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt");
+EXPORT_SYMBOL(dvb_unregister_frontend);
diff -Nru a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h	2004-12-24 13:37:29 -08:00
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h	2004-12-24 13:37:29 -08:00
@@ -1,9 +1,12 @@
 /* 
  * dvb_frontend.h
  *
- * Copyright (C) 2001 Ralph Metzler for convergence integrated media GmbH
- *                    overhauled by Holger Waechtler for Convergence GmbH
+ * Copyright (C) 2001 convergence integrated media GmbH
+ * Copyright (C) 2004 convergence GmbH
  *
+ * Written by Ralph Metzler
+ * Overhauled by Holger Waechtler
+ * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -31,31 +34,34 @@
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/errno.h>
+#include <linux/delay.h>
 
 #include <linux/dvb/frontend.h>
 
-#include "dvb_i2c.h"
 #include "dvbdev.h"
 
+/* FIXME: Move to i2c-id.h */
+#define I2C_DRIVERID_DVBFE_SP8870	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_CX22700	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_AT76C651	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_CX24110	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_CX22702	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_DIB3000MB	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_DST		I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_DUMMY	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_L64781	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_MT312	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_MT352	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_NXT6000	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_SP887X	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_STV0299	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_TDA1004X	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_TDA8083	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_VES1820	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_VES1X93	I2C_DRIVERID_EXP2
+#define I2C_DRIVERID_DVBFE_TDA80XX	I2C_DRIVERID_EXP2
 
 
-
-/**
- *   when before_ioctl is registered and returns value 0, ioctl and after_ioctl
- *   are not executed.
- */
-
-struct dvb_frontend {
-	int (*before_ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
-	int (*ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
-	int (*after_ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
-	void (*notifier_callback) (fe_status_t s, void *data);
-	struct dvb_i2c_bus *i2c;
-	void *before_after_data;   /*  can be used by hardware module... */
-	void *notifier_data;       /*  can be used by hardware module... */
-	void *data;                /*  can be used by hardware module... */
-};
-
 struct dvb_frontend_tune_settings {
         int min_delay_ms;
         int step_size;
@@ -63,65 +69,79 @@
         struct dvb_frontend_parameters parameters;
 };
 
+struct dvb_frontend;
 
-/**
- *   private frontend command ioctl's.
- *   keep them in sync with the public ones defined in linux/dvb/frontend.h
- * 
- *   FE_SLEEP. Ioctl used to put frontend into a low power mode.
- *   FE_INIT. Ioctl used to initialise the frontend.
- *   FE_GET_TUNE_SETTINGS. Get the frontend-specific tuning loop settings for the supplied set of parameters.
- */
-#define FE_SLEEP              _IO('v', 80)
-#define FE_INIT               _IO('v', 81)
-#define FE_GET_TUNE_SETTINGS  _IOWR('v', 83, struct dvb_frontend_tune_settings)
-
-
-extern int
-dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
-				     unsigned int cmd, void *arg),
-		       struct dvb_i2c_bus *i2c,
-		       void *data,
-		       struct dvb_frontend_info *info);
-
-extern int
-dvb_unregister_frontend (int (*ioctl) (struct dvb_frontend *frontend,
-				       unsigned int cmd, void *arg),
-			 struct dvb_i2c_bus *i2c);
-
-
-/**
- *  Add special ioctl code performed before and after the main ioctl
- *  to all frontend devices on the specified DVB adapter.
- *  This is necessairy because the 22kHz/13V-18V/DiSEqC stuff depends
- *  heavily on the hardware around the frontend, the same tuner can create 
- *  these signals on about a million different ways...
- *
- *  Return value: number of frontends where the ioctl's were applied.
- */
-extern int
-dvb_add_frontend_ioctls (struct dvb_adapter *adapter,
-			 int (*before_ioctl) (struct dvb_frontend *frontend,
-					      unsigned int cmd, void *arg),
-			 int (*after_ioctl)  (struct dvb_frontend *frontend,
-					      unsigned int cmd, void *arg),
-			 void *before_after_data);
-
-
-extern void
-dvb_remove_frontend_ioctls (struct dvb_adapter *adapter,
-			    int (*before_ioctl) (struct dvb_frontend *frontend,
-					         unsigned int cmd, void *arg),
-			    int (*after_ioctl)  (struct dvb_frontend *frontend,
-					         unsigned int cmd, void *arg));
-
-extern int
-dvb_add_frontend_notifier (struct dvb_adapter *adapter,
-			   void (*callback) (fe_status_t s, void *data),
-			   void *data);
-extern void
-dvb_remove_frontend_notifier (struct dvb_adapter *adapter,
-			      void (*callback) (fe_status_t s, void *data));
+struct dvb_frontend_ops {
 
-#endif
+	struct dvb_frontend_info info;
+
+	void (*release)(struct dvb_frontend* fe);
 
+	int (*init)(struct dvb_frontend* fe);
+	int (*sleep)(struct dvb_frontend* fe);
+
+	int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+	int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+	int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
+
+	int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);
+	int (*read_ber)(struct dvb_frontend* fe, u32* ber);
+	int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
+	int (*read_snr)(struct dvb_frontend* fe, u16* snr);
+	int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
+
+	int (*diseqc_reset_overload)(struct dvb_frontend* fe);
+	int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
+	int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
+	int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
+	int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
+	int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
+	int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, int arg);
+	int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned int cmd);
+};
+
+#define MAX_EVENT 8
+
+struct dvb_fe_events {
+	struct dvb_frontend_event events[MAX_EVENT];
+	int			  eventw;
+	int			  eventr;
+	int			  overflow;
+	wait_queue_head_t	  wait_queue;
+	struct semaphore	  sem;
+};
+
+struct dvb_frontend {
+	struct dvb_frontend_ops* ops;
+	struct dvb_adapter *dvb;
+	void* demodulator_priv;
+
+	struct dvb_device *dvbdev;
+	struct dvb_frontend_parameters parameters;
+	struct dvb_fe_events events;
+	struct semaphore sem;
+	struct list_head list_head;
+	wait_queue_head_t wait_queue;
+	pid_t thread_pid;
+	unsigned long release_jiffies;
+	int state;
+	int bending;
+	int lnb_drift;
+	int inversion;
+	int auto_step;
+	int auto_sub_step;
+	int started_auto_step;
+	int min_delay;
+	int max_drift;
+	int step_size;
+	int exit;
+	int wakeup;
+	fe_status_t status;
+};
+
+extern int dvb_register_frontend(struct dvb_adapter* dvb,
+				 struct dvb_frontend* fe);
+
+extern int dvb_unregister_frontend(struct dvb_frontend* fe);
+
+#endif
diff -Nru a/drivers/media/dvb/dvb-core/dvb_functions.c b/drivers/media/dvb/dvb-core/dvb_functions.c
--- a/drivers/media/dvb/dvb-core/dvb_functions.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,89 +0,0 @@
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include <linux/ioctl.h>
-#include <linux/slab.h>
-#include <linux/smp_lock.h>
-#include <asm/uaccess.h>
-
-void dvb_kernel_thread_setup (const char *thread_name)
-{
-        lock_kernel ();
-
-        daemonize (thread_name);
-
-        sigfillset (&current->blocked);
-
-        unlock_kernel ();
-}
-
-/* if the miracle happens and "generic_usercopy()" is included into
-   the kernel, then this can vanish. please don't make the mistake and
-   define this as video_usercopy(). this will introduce a dependecy
-   to the v4l "videodev.o" module, which is unnecessary for some
-   cards (ie. the budget dvb-cards don't need the v4l module...) */
-int dvb_usercopy(struct inode *inode, struct file *file,
-	             unsigned int cmd, unsigned long arg,
-		     int (*func)(struct inode *inode, struct file *file,
-		     unsigned int cmd, void *arg))
-{
-        char    sbuf[128];
-        void    *mbuf = NULL;
-        void    *parg = NULL;
-        int     err  = -EINVAL;
-
-        /*  Copy arguments into temp kernel buffer  */
-        switch (_IOC_DIR(cmd)) {
-        case _IOC_NONE:
-		/*
-		 * For this command, the pointer is actually an integer
-		 * argument.
-		 */
-                parg = (void *) arg;
-                break;
-        case _IOC_READ: /* some v4l ioctls are marked wrong ... */
-        case _IOC_WRITE:
-        case (_IOC_WRITE | _IOC_READ):
-                if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
-                        parg = sbuf;
-                } else {
-                        /* too big to allocate from stack */
-                        mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
-                        if (NULL == mbuf)
-                                return -ENOMEM;
-                        parg = mbuf;
-                }
-
-                err = -EFAULT;
-                if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
-                        goto out;
-                break;
-        }
-
-        /* call driver */
-        if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
-                err = -EINVAL;
-
-        if (err < 0)
-                goto out;
-
-        /*  Copy results into user buffer  */
-        switch (_IOC_DIR(cmd))
-        {
-        case _IOC_READ:
-        case (_IOC_WRITE | _IOC_READ):
-                if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
-                        err = -EFAULT;
-                break;
-        }
-
-out:
-        if (mbuf)
-                kfree(mbuf);
-
-        return err;
-}
-
-EXPORT_SYMBOL(dvb_usercopy);
-EXPORT_SYMBOL(dvb_kernel_thread_setup);
diff -Nru a/drivers/media/dvb/dvb-core/dvb_functions.h b/drivers/media/dvb/dvb-core/dvb_functions.h
--- a/drivers/media/dvb/dvb-core/dvb_functions.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,50 +0,0 @@
-/* 
- * dvb_functions.h: isolate some Linux specific stuff from the dvb-core
- *                  that can't be expressed as a one-liner
- *                  in order to make porting to other environments easier
- *
- * Copyright (C) 2003 Convergence GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Lesser Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- */
-
-#ifndef __DVB_FUNCTIONS_H__
-#define __DVB_FUNCTIONS_H__
-
-/**
- *  a sleeping delay function, waits i ms
- *
- */
-static inline
-void dvb_delay(int i)
-{
-	current->state=TASK_INTERRUPTIBLE;
-	schedule_timeout((HZ*i)/1000);
-}
-
-/* we don't mess with video_usercopy() any more,
-we simply define out own dvb_usercopy(), which will hopefull become
-generic_usercopy()  someday... */
-
-extern int dvb_usercopy(struct inode *inode, struct file *file,
-	                    unsigned int cmd, unsigned long arg,
-			    int (*func)(struct inode *inode, struct file *file,
-			    unsigned int cmd, void *arg));
-
-extern void dvb_kernel_thread_setup (const char *thread_name);
-
-#endif
-
diff -Nru a/drivers/media/dvb/dvb-core/dvb_i2c.c b/drivers/media/dvb/dvb-core/dvb_i2c.c
--- a/drivers/media/dvb/dvb-core/dvb_i2c.c	2004-12-24 13:37:04 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,290 +0,0 @@
-/*
- * dvb_i2c.h: simplified i2c interface for DVB adapters to get rid of i2c-core.c
- *
- * Copyright (C) 2002 Holger Waechtler for convergence integrated media GmbH
- *
- * 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.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- */
-
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <asm/semaphore.h>
-
-#include "dvb_i2c.h"
-#include "dvb_functions.h"
-
-
-struct dvb_i2c_device {
-	struct list_head list_head;
-	struct module *owner;
-	int (*attach) (struct dvb_i2c_bus *i2c, void **data);
-	void (*detach) (struct dvb_i2c_bus *i2c, void *data);
-	void *data;
-};
-
-LIST_HEAD(dvb_i2c_buslist);
-LIST_HEAD(dvb_i2c_devicelist);
-
-DECLARE_MUTEX(dvb_i2c_mutex);
-
-static int register_i2c_client (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
-{
-	struct dvb_i2c_device *client;
-
-	if (!(client = kmalloc (sizeof (struct dvb_i2c_device), GFP_KERNEL)))
-		return -ENOMEM;
-
-	client->detach = dev->detach;
-	client->owner = dev->owner;
-	client->data = dev->data;
-
-	INIT_LIST_HEAD(&client->list_head);
-
-	list_add_tail (&client->list_head, &i2c->client_list);
-
-	return 0;
-}
-
-
-static void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
-{
-	if (dev->owner) {
-		if (!try_module_get(dev->owner))
-			return;
-	}
-
-	if (dev->attach (i2c, &dev->data) == 0) {
-		register_i2c_client (i2c, dev);
-	} else {
-		if (dev->owner)
-			module_put (dev->owner);
-	}
-}
-
-
-static void detach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
-{
-	dev->detach (i2c, dev->data);
-
-	if (dev->owner)
-		module_put (dev->owner);
-}
-
-
-static void unregister_i2c_client_from_bus (struct dvb_i2c_device *dev,
-				     struct dvb_i2c_bus *i2c)
-{
-	struct list_head *entry, *n;
-
-	list_for_each_safe (entry, n, &i2c->client_list) {
-                struct dvb_i2c_device *client;
-
-		client = list_entry (entry, struct dvb_i2c_device, list_head);
-
-		if (client->detach == dev->detach) {
-			list_del (entry);
-			detach_device (i2c, dev);
-		}
-	}
-}
-
-
-static void unregister_i2c_client_from_all_busses (struct dvb_i2c_device *dev)
-{
-	struct list_head *entry, *n;
-
-	list_for_each_safe (entry, n, &dvb_i2c_buslist) {
-                struct dvb_i2c_bus *i2c;
-
-		i2c = list_entry (entry, struct dvb_i2c_bus, list_head);
-
-		unregister_i2c_client_from_bus (dev, i2c);
-	}
-}
-
-
-static void unregister_all_clients_from_bus (struct dvb_i2c_bus *i2c)
-{
-	struct list_head *entry, *n;
-
-	list_for_each_safe (entry, n, &(i2c->client_list)) {
-		struct dvb_i2c_device *dev;
-
-		dev = list_entry (entry, struct dvb_i2c_device, list_head);
-
-		unregister_i2c_client_from_bus (dev, i2c);
-	}
-}
-
-
-static void probe_device_on_all_busses (struct dvb_i2c_device *dev)
-{
-	struct list_head *entry;
-
-	list_for_each (entry, &dvb_i2c_buslist) {
-                struct dvb_i2c_bus *i2c;
-
-		i2c = list_entry (entry, struct dvb_i2c_bus, list_head);
-
-		try_attach_device (i2c, dev);
-	}
-}
-
-
-static void probe_devices_on_bus (struct dvb_i2c_bus *i2c)
-{
-	struct list_head *entry;
-
-	list_for_each (entry, &dvb_i2c_devicelist) {
-		struct dvb_i2c_device *dev;
-
-		dev = list_entry (entry, struct dvb_i2c_device, list_head);
-
-		try_attach_device (i2c, dev);
-	}
-}
-
-
-static struct dvb_i2c_bus* dvb_find_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
-		                                   const struct i2c_msg msgs[],
-						   int num),
-				      struct dvb_adapter *adapter,
-				      int id)
-{
-	struct list_head *entry;
-
-	list_for_each (entry, &dvb_i2c_buslist) {
-		struct dvb_i2c_bus *i2c;
-
-		i2c = list_entry (entry, struct dvb_i2c_bus, list_head);
-
-		if (i2c->xfer == xfer && i2c->adapter == adapter && i2c->id == id)
-			return i2c;
-	}
-
-	return NULL;
-}
-
-
-struct dvb_i2c_bus*
-dvb_register_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
-				   const struct i2c_msg *msgs, int num),
-		      void *data, struct dvb_adapter *adapter, int id)
-{
-	struct dvb_i2c_bus *i2c;
-
-	if (down_interruptible (&dvb_i2c_mutex))
-		return NULL;
-
-	if (!(i2c = kmalloc (sizeof (struct dvb_i2c_bus), GFP_KERNEL))) {
-		up (&dvb_i2c_mutex);
-		return NULL;
-	}
-
-	INIT_LIST_HEAD(&i2c->list_head);
-	INIT_LIST_HEAD(&i2c->client_list);
-
-	i2c->xfer = xfer;
-	i2c->data = data;
-	i2c->adapter = adapter;
-	i2c->id = id;
-
-	probe_devices_on_bus (i2c);
-
-	list_add_tail (&i2c->list_head, &dvb_i2c_buslist);
-
-	up (&dvb_i2c_mutex);
-
-	return i2c;
-}
-
-
-void dvb_unregister_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
-					  const struct i2c_msg msgs[], int num),
-			     struct dvb_adapter *adapter, int id)
-{
-	struct dvb_i2c_bus *i2c;
-
-	down (&dvb_i2c_mutex);
-
-	if ((i2c = dvb_find_i2c_bus (xfer, adapter, id))) {
-		unregister_all_clients_from_bus (i2c);
-		list_del (&i2c->list_head);
-		kfree (i2c);
-	}
-
-	up (&dvb_i2c_mutex);
-}
-
-
-int dvb_register_i2c_device (struct module *owner,
-			     int (*attach) (struct dvb_i2c_bus *i2c, void **data),
-			     void (*detach) (struct dvb_i2c_bus *i2c, void *data))
-{
-	struct dvb_i2c_device *entry;
-
-	if (down_interruptible (&dvb_i2c_mutex))
-		return -ERESTARTSYS;
-
-	if (!(entry = kmalloc (sizeof (struct dvb_i2c_device), GFP_KERNEL))) {
-		up(&dvb_i2c_mutex);
-		return -ENOMEM;
-	}
-
-	entry->owner = owner;
-	entry->attach = attach;
-	entry->detach = detach;
-
-	INIT_LIST_HEAD(&entry->list_head);
-
-	probe_device_on_all_busses (entry);
-
-	list_add_tail (&entry->list_head, &dvb_i2c_devicelist);
-
-	up (&dvb_i2c_mutex);
-
-	return 0;
-}
-
-
-int dvb_unregister_i2c_device (int (*attach) (struct dvb_i2c_bus *i2c, void **data))
-{
-	struct list_head *entry, *n;
-
-	down (&dvb_i2c_mutex);
-
-	list_for_each_safe (entry, n, &dvb_i2c_devicelist) {
-		struct dvb_i2c_device *dev;
-
-		dev = list_entry (entry, struct dvb_i2c_device, list_head);
-
-		if (dev->attach == attach) {
-			list_del (entry);
-			unregister_i2c_client_from_all_busses (dev);
-			kfree (entry);
-			up (&dvb_i2c_mutex);
-			return 0;
-                }
-        }
-
-	up (&dvb_i2c_mutex);
-
-        return -EINVAL;
-}
-
-
diff -Nru a/drivers/media/dvb/dvb-core/dvb_i2c.h b/drivers/media/dvb/dvb-core/dvb_i2c.h
--- a/drivers/media/dvb/dvb-core/dvb_i2c.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,63 +0,0 @@
-/*
- * dvb_i2c.h: i2c interface to get rid of i2c-core.c
- *
- * Copyright (C) 2002 Holger Waechtler for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _DVB_I2C_H_
-#define _DVB_I2C_H_
-
-#include <linux/list.h>
-#include <linux/i2c.h>
-
-#include "dvbdev.h"
-
-
-struct dvb_i2c_bus {
-	struct list_head list_head;
-	int (*xfer) (struct dvb_i2c_bus *i2c, 
-		     const struct i2c_msg msgs[],
-		     int num);
-	void *data;
-	struct dvb_adapter *adapter;
-	int id;
-	struct list_head client_list;
-};
-
-
-extern struct dvb_i2c_bus*
-dvb_register_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
-				   const struct i2c_msg *msgs, int num),
-		      void *data,
-		      struct dvb_adapter *adapter,
-		      int id);
-
-extern
-void dvb_unregister_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
-					  const struct i2c_msg msgs[], int num),
-			     struct dvb_adapter *adapter,
-			     int id);
-
-
-extern int dvb_register_i2c_device (struct module *owner,
-				    int (*attach) (struct dvb_i2c_bus *i2c, void **data),
-				    void (*detach) (struct dvb_i2c_bus *i2c, void *data));
-
-extern int dvb_unregister_i2c_device (int (*attach) (struct dvb_i2c_bus *i2c, void **data));
-
-#endif
-
diff -Nru a/drivers/media/dvb/dvb-core/dvb_ksyms.c b/drivers/media/dvb/dvb-core/dvb_ksyms.c
--- a/drivers/media/dvb/dvb-core/dvb_ksyms.c	2004-12-24 13:37:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,57 +0,0 @@
-#include <linux/errno.h>
-#include <linux/module.h>
-#include <linux/ioctl.h>
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <asm/uaccess.h>
-
-#include "dmxdev.h"
-#include "dvb_demux.h"
-#include "dvb_frontend.h"
-#include "dvb_net.h"
-#include "dvb_filter.h"
-#include "dvb_ca_en50221.h"
-
-EXPORT_SYMBOL(dvb_dmxdev_init);
-EXPORT_SYMBOL(dvb_dmxdev_release);
-EXPORT_SYMBOL(dvb_dmx_init);
-EXPORT_SYMBOL(dvb_dmx_release);
-EXPORT_SYMBOL(dvb_dmx_swfilter_packet);
-EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
-EXPORT_SYMBOL(dvb_dmx_swfilter);
-EXPORT_SYMBOL(dvb_dmx_swfilter_204);
-EXPORT_SYMBOL(dvbdmx_connect_frontend);
-EXPORT_SYMBOL(dvbdmx_disconnect_frontend);
-
-EXPORT_SYMBOL(dvb_register_frontend);
-EXPORT_SYMBOL(dvb_unregister_frontend);
-EXPORT_SYMBOL(dvb_add_frontend_ioctls);
-EXPORT_SYMBOL(dvb_remove_frontend_ioctls);
-EXPORT_SYMBOL(dvb_add_frontend_notifier);
-EXPORT_SYMBOL(dvb_remove_frontend_notifier);
-
-EXPORT_SYMBOL(dvb_register_i2c_bus);
-EXPORT_SYMBOL(dvb_unregister_i2c_bus);
-EXPORT_SYMBOL(dvb_register_i2c_device);
-EXPORT_SYMBOL(dvb_unregister_i2c_device);
-
-EXPORT_SYMBOL(dvb_net_init);
-EXPORT_SYMBOL(dvb_net_release);
-
-EXPORT_SYMBOL(dvb_register_adapter);
-EXPORT_SYMBOL(dvb_unregister_adapter);
-EXPORT_SYMBOL(dvb_register_device);
-EXPORT_SYMBOL(dvb_unregister_device);
-EXPORT_SYMBOL(dvb_generic_ioctl);
-EXPORT_SYMBOL(dvb_generic_open);
-EXPORT_SYMBOL(dvb_generic_release);
-
-EXPORT_SYMBOL(dvb_filter_pes2ts_init);
-EXPORT_SYMBOL(dvb_filter_pes2ts);
-EXPORT_SYMBOL(dvb_filter_get_ac3info);
-
-EXPORT_SYMBOL(dvb_ca_en50221_init);
-EXPORT_SYMBOL(dvb_ca_en50221_release);
-EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
-EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
-EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
diff -Nru a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
--- a/drivers/media/dvb/dvb-core/dvb_net.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/media/dvb/dvb-core/dvb_net.c	2004-12-24 13:36:30 -08:00
@@ -6,13 +6,13 @@
  * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
  *
  * ULE Decapsulation code:
- * Copyright (C) 2003 gcs - Global Communication & Services GmbH.
- *                and Institute for Computer Sciences
- *                    Salzburg University.
+ * Copyright (C) 2003, 2004 gcs - Global Communication & Services GmbH.
+ *                      and Department of Scientific Computing
+ *                          Paris Lodron University of Salzburg.
  *                    Hilmar Linder <hlinder@cosy.sbg.ac.at>
  *                and Wolfram Stering <wstering@cosy.sbg.ac.at>
  *
- * ULE Decaps according to draft-fair-ipdvb-ule-01.txt.
+ * ULE Decaps according to draft-ietf-ipdvb-ule-03.txt.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -30,6 +30,31 @@
  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
  */
 
+/*
+ * ULE ChangeLog:
+ * Feb 2004: hl/ws v1: Implementing draft-fair-ipdvb-ule-01.txt
+ *
+ * Dec 2004: hl/ws v2: Implementing draft-ietf-ipdvb-ule-03.txt:
+ *                       ULE Extension header handling.
+ *                     Bugreports by Moritz Vieth and Hanno Tersteegen,
+ *                       Fraunhofer Institute for Open Communication Systems
+ *                       Competence Center for Advanced Satellite Communications.
+ *                     Bugfixes and robustness improvements.
+ *                     Filtering on dest MAC addresses, if present (D-Bit = 0)
+ *                     ULE_DEBUG compile-time option.
+ */
+
+/*
+ * FIXME / TODO (dvb_net.c):
+ *
+ * Unloading does not work for 2.6.9 kernels: a refcount doesn't go to zero.
+ *
+ * TS_FEED callback is called once for every single TS cell although it is
+ * registered (in dvb_net_feed_start()) for 100 TS cells (used for dvb_net_ule()).
+ *
+ */
+
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -37,10 +62,16 @@
 #include <linux/uio.h>
 #include <asm/uaccess.h>
 #include <linux/crc32.h>
+#include <linux/version.h>
 
 #include "dvb_demux.h"
 #include "dvb_net.h"
-#include "dvb_functions.h"
+
+static int dvb_net_debug;
+module_param(dvb_net_debug, int, 0444);
+MODULE_PARM_DESC(dvb_net_debug, "enable debug messages");
+
+#define dprintk(x...) do { if (dvb_net_debug) printk(x); } while (0)
 
 
 static inline __u32 iov_crc32( __u32 c, struct kvec *iov, unsigned int cnt )
@@ -52,14 +83,11 @@
 }
 
 
-#if 1
-#define dprintk(x...) printk(x)
-#else
-#define dprintk(x...)
-#endif
+#define DVB_NET_MULTICAST_MAX 10
 
+#undef ULE_DEBUG
 
-#define DVB_NET_MULTICAST_MAX 10
+#ifdef ULE_DEBUG
 
 #define isprint(c)	((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))
 
@@ -90,6 +118,7 @@
 	}
 }
 
+#endif
 
 struct dvb_net_priv {
 	int in_use;
@@ -111,18 +140,19 @@
 #define RX_MODE_PROMISC 3
 	struct work_struct set_multicast_list_wq;
 	struct work_struct restart_net_feed_wq;
-	unsigned char feedtype;
-	int need_pusi;
-	unsigned char tscc;			/* TS continuity counter after sync. */
-	struct sk_buff *ule_skb;
-	unsigned short ule_sndu_len;
-	unsigned short ule_sndu_type;
-	unsigned char ule_sndu_type_1;
-	unsigned char ule_dbit;			/* whether the DestMAC address present
-						 * bit is set or not. */
-	unsigned char ule_ethhdr_complete;	/* whether we have completed the Ethernet
-						 * header for the current ULE SNDU. */
-	int ule_sndu_remain;
+	unsigned char feedtype;			/* Either FEED_TYPE_ or FEED_TYPE_ULE */
+	int need_pusi;				/* Set to 1, if synchronization on PUSI required. */
+	unsigned char tscc;			/* TS continuity counter after sync on PUSI. */
+	struct sk_buff *ule_skb;		/* ULE SNDU decodes into this buffer. */
+	unsigned char *ule_next_hdr;		/* Pointer into skb to next ULE extension header. */
+	unsigned short ule_sndu_len;		/* ULE SNDU length in bytes, w/o D-Bit. */
+	unsigned short ule_sndu_type;		/* ULE SNDU type field, complete. */
+	unsigned char ule_sndu_type_1;		/* ULE SNDU type field, if split across 2 TS cells. */
+	unsigned char ule_dbit;			/* Whether the DestMAC address present
+						 * or not (bit is set). */
+	unsigned char ule_bridged;		/* Whether the ULE_BRIDGED extension header was found. */
+	int ule_sndu_remain;			/* Nr. of bytes still required for current ULE SNDU. */
+	unsigned long ts_count;			/* Current ts cell counter. */
 };
 
 
@@ -142,7 +172,11 @@
 	
 	skb->mac.raw=skb->data;
 	skb_pull(skb,dev->hard_header_len);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,8)
+	eth = skb->mac.ethernet;
+#else
 	eth = eth_hdr(skb);
+#endif
 	
 	if (*eth->h_dest & 1) {
 		if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
@@ -174,78 +208,194 @@
 #define TS_SZ	188
 #define TS_SYNC	0x47
 #define TS_TEI	0x80
+#define TS_SC	0xC0
 #define TS_PUSI	0x40
 #define TS_AF_A	0x20
 #define TS_AF_D	0x10
 
+/* ULE Extension Header handlers. */
+
 #define ULE_TEST	0
 #define ULE_BRIDGED	1
-#define ULE_LLC		2
 
+int ule_test_sndu( struct dvb_net_priv *p )
+{
+	return -1;
+}
+
+int ule_bridged_sndu( struct dvb_net_priv *p )
+{
+	/* BRIDGE SNDU handling sucks in draft-ietf-ipdvb-ule-03.txt.
+	 * This has to be the last extension header, otherwise it won't work.
+	 * Blame the authors!
+	 */
+	p->ule_bridged = 1;
+	return 0;
+}
+
+
+/** Handle ULE extension headers.
+ *  Function is called after a successful CRC32 verification of an ULE SNDU to complete its decoding.
+ *  Returns: >= 0: nr. of bytes consumed by next extension header
+ *  	     -1:   Mandatory extension header that is not recognized or TEST SNDU; discard.
+ */
+static int handle_one_ule_extension( struct dvb_net_priv *p )
+{
+	/* Table of mandatory extension header handlers.  The header type is the index. */
+	static int (*ule_mandatory_ext_handlers[255])( struct dvb_net_priv *p ) =
+		{ [0] = ule_test_sndu, [1] = ule_bridged_sndu, [2] = NULL,  };
+
+	/* Table of optional extension header handlers.  The header type is the index. */
+	static int (*ule_optional_ext_handlers[255])( struct dvb_net_priv *p ) = { NULL, };
+
+	int ext_len = 0;
+	unsigned char hlen = (p->ule_sndu_type & 0x0700) >> 8;
+	unsigned char htype = p->ule_sndu_type & 0x00FF;
+
+	/* Discriminate mandatory and optional extension headers. */
+	if (hlen == 0) {
+		/* Mandatory extension header */
+		if (ule_mandatory_ext_handlers[htype]) {
+			ext_len = ule_mandatory_ext_handlers[htype]( p );
+			p->ule_next_hdr += ext_len;
+			if (! p->ule_bridged) {
+				p->ule_sndu_type = ntohs( *(unsigned short *)p->ule_next_hdr );
+				p->ule_next_hdr += 2;
+			} else {
+				p->ule_sndu_type = ntohs( *(unsigned short *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN)) );
+				/* This assures the extension handling loop will terminate. */
+			}
+		} else
+			ext_len = -1;	/* SNDU has to be discarded. */
+	} else {
+		/* Optional extension header.  Calculate the length. */
+		ext_len = hlen << 2;
+		/* Process the optional extension header according to its type. */
+		if (ule_optional_ext_handlers[htype])
+			(void)ule_optional_ext_handlers[htype]( p );
+		p->ule_next_hdr += ext_len;
+		p->ule_sndu_type = ntohs( *(unsigned short *)p->ule_next_hdr );
+		p->ule_next_hdr += 2;
+	}
+
+	return ext_len;
+}
+
+static int handle_ule_extensions( struct dvb_net_priv *p )
+{
+	int total_ext_len = 0, l;
+
+	p->ule_next_hdr = p->ule_skb->data;
+	do {
+		l = handle_one_ule_extension( p );
+		if (l == -1) return -1;	/* Stop extension header processing and discard SNDU. */
+		total_ext_len += l;
+
+	} while (p->ule_sndu_type < 1536);
+
+	return total_ext_len;
+}
+
+
+/** Prepare for a new ULE SNDU: reset the decoder state. */
 static inline void reset_ule( struct dvb_net_priv *p )
 {
 	p->ule_skb = NULL;
+	p->ule_next_hdr = NULL;
 	p->ule_sndu_len = 0;
 	p->ule_sndu_type = 0;
 	p->ule_sndu_type_1 = 0;
 	p->ule_sndu_remain = 0;
 	p->ule_dbit = 0xFF;
-	p->ule_ethhdr_complete = 0;
+	p->ule_bridged = 0;
 }
 
-static const char eth_dest_addr[] = { 0x0b, 0x0a, 0x09, 0x08, 0x04, 0x03 };
-
+/**
+ * Decode ULE SNDUs according to draft-ietf-ipdvb-ule-03.txt from a sequence of
+ * TS cells of a single PID.
+ */
 static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
 {
 	struct dvb_net_priv *priv = (struct dvb_net_priv *)dev->priv;
-	unsigned long skipped = 0L, skblen = 0L;
+	unsigned long skipped = 0L;
 	u8 *ts, *ts_end, *from_where = NULL, ts_remain = 0, how_much = 0, new_ts = 1;
 	struct ethhdr *ethh = NULL;
-	unsigned int emergency_count = 0;
+
+#ifdef ULE_DEBUG
+	/* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */
+	static unsigned char ule_hist[100*TS_SZ];
+	static unsigned char *ule_where = ule_hist, ule_dump = 0;
+#endif
 
 	if (dev == NULL) {
 		printk( KERN_ERR "NO netdev struct!\n" );
 		return;
 	}
 
-	for (ts = (char *)buf, ts_end = (char *)buf + buf_len; ts < ts_end; ) {
+	/* For all TS cells in current buffer.
+	 * Appearently, we are called for every single TS cell.
+	 */
+	for (ts = (char *)buf, ts_end = (char *)buf + buf_len; ts < ts_end; /* no default incr. */ ) {
 
-		if (emergency_count++ > 200) {
-			/* Huh?? */
-			hexdump(ts, TS_SZ);
-			printk(KERN_WARNING "*** LOOP ALERT! ts %p ts_remain %u "
-				"how_much %u, ule_skb %p, ule_len %u, ule_remain %u\n",
-				ts, ts_remain, how_much, priv->ule_skb,
-				priv->ule_sndu_len, priv->ule_sndu_remain);
-			break;
+		if (new_ts) {
+			/* We are about to process a new TS cell. */
+
+#ifdef ULE_DEBUG
+			if (ule_where >= &ule_hist[100*TS_SZ]) ule_where = ule_hist;
+			memcpy( ule_where, ts, TS_SZ );
+			if (ule_dump) {
+				hexdump( ule_where, TS_SZ );
+				ule_dump = 0;
 		}
+			ule_where += TS_SZ;
+#endif
 
-		if (new_ts) {
-			if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI)) {
-				printk(KERN_WARNING "Invalid TS cell: SYNC %#x, TEI %u.\n",
-				       ts[0], ts[1] & TS_TEI >> 7);
+			/* Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control . */
+			if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI) || ((ts[3] & TS_SC) != 0)) {
+				printk(KERN_WARNING "%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n",
+				       priv->ts_count, ts[0], ts[1] & TS_TEI >> 7, ts[3] & 0xC0 >> 6);
+
+				/* Drop partly decoded SNDU, reset state, resync on PUSI. */
+				if (priv->ule_skb) {
+					dev_kfree_skb( priv->ule_skb );
+					/* Prepare for next SNDU. */
+					((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
+					((struct dvb_net_priv *) dev->priv)->stats.rx_frame_errors++;
+				}
+				reset_ule(priv);
+				priv->need_pusi = 1;
+
+				/* Continue with next TS cell. */
+				ts += TS_SZ;
+				priv->ts_count++;
 				continue;
 			}
+
 			ts_remain = 184;
 			from_where = ts + 4;
 		}
 		/* Synchronize on PUSI, if required. */
 		if (priv->need_pusi) {
 			if (ts[1] & TS_PUSI) {
-				/* Find beginning of first ULE SNDU in current TS cell.
-				 * priv->need_pusi = 0; */
+				/* Find beginning of first ULE SNDU in current TS cell. */
+				/* Synchronize continuity counter. */
 				priv->tscc = ts[3] & 0x0F;
 				/* There is a pointer field here. */
 				if (ts[4] > ts_remain) {
-					printk(KERN_ERR "Invalid ULE packet "
-					       "(pointer field %d)\n", ts[4]);
+					printk(KERN_ERR "%lu: Invalid ULE packet "
+					       "(pointer field %d)\n", priv->ts_count, ts[4]);
+					ts += TS_SZ;
+					priv->ts_count++;
 					continue;
 				}
+				/* Skip to destination of pointer field. */
 				from_where = &ts[5] + ts[4];
 				ts_remain -= 1 + ts[4];
 				skipped = 0;
 			} else {
 				skipped++;
+				ts += TS_SZ;
+				priv->ts_count++;
 				continue;
 			}
 		}
@@ -256,32 +406,45 @@
 				priv->tscc = (priv->tscc + 1) & 0x0F;
 			else {
 				/* TS discontinuity handling: */
+				printk(KERN_WARNING "%lu: TS discontinuity: got %#x, "
+				       "exptected %#x.\n", priv->ts_count, ts[3] & 0x0F, priv->tscc);
+				/* Drop partly decoded SNDU, reset state, resync on PUSI. */
 				if (priv->ule_skb) {
 					dev_kfree_skb( priv->ule_skb );
 					/* Prepare for next SNDU. */
-					reset_ule(priv);
+					// reset_ule(priv);  moved to below.
 					((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
 					((struct dvb_net_priv *) dev->priv)->stats.rx_frame_errors++;
 				}
+				reset_ule(priv);
 				/* skip to next PUSI. */
-				printk(KERN_WARNING "TS discontinuity: got %#x, "
-				       "exptected %#x.\n", ts[3] & 0x0F, priv->tscc);
 				priv->need_pusi = 1;
+				ts += TS_SZ;
+				priv->ts_count++;
 				continue;
 			}
 			/* If we still have an incomplete payload, but PUSI is
-			 * set, some TS cells are missing.
+			 * set; some TS cells are missing.
 			 * This is only possible here, if we missed exactly 16 TS
-			 * cells (continuity counter). */
+			 * cells (continuity counter wrap). */
 			if (ts[1] & TS_PUSI) {
 				if (! priv->need_pusi) {
-					/* printk(KERN_WARNING "Skipping pointer field %u.\n", *from_where); */
 					if (*from_where > 181) {
-						printk(KERN_WARNING "*** Invalid pointer "
-						       "field: %u.  Current TS cell "
-						       "follows:\n", *from_where);
-						hexdump( ts, TS_SZ );
-						printk(KERN_WARNING "-------------------\n");
+						/* Pointer field is invalid.  Drop this TS cell and any started ULE SNDU. */
+						printk(KERN_WARNING "%lu: Invalid pointer "
+						       "field: %u.\n", priv->ts_count, *from_where);
+
+						/* Drop partly decoded SNDU, reset state, resync on PUSI. */
+						if (priv->ule_skb) {
+							dev_kfree_skb( priv->ule_skb );
+							((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
+							((struct dvb_net_priv *) dev->priv)->stats.rx_frame_errors++;
+						}
+						reset_ule(priv);
+						priv->need_pusi = 1;
+						ts += TS_SZ;
+						priv->ts_count++;
+						continue;
 					}
 					/* Skip pointer field (we're processing a
 					 * packed payload). */
@@ -291,21 +454,26 @@
 					priv->need_pusi = 0;
 
 				if (priv->ule_sndu_remain > 183) {
+					/* Current SNDU lacks more data than there could be available in the
+					 * current TS cell. */
 					((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
 					((struct dvb_net_priv *) dev->priv)->stats.rx_length_errors++;
-					printk(KERN_WARNING "Expected %d more SNDU bytes, but "
-					       "got PUSI.  Flushing incomplete payload.\n",
-					       priv->ule_sndu_remain);
+					printk(KERN_WARNING "%lu: Expected %d more SNDU bytes, but "
+					       "got PUSI (pf %d, ts_remain %d).  Flushing incomplete payload.\n",
+					       priv->ts_count, priv->ule_sndu_remain, ts[4], ts_remain);
 					dev_kfree_skb(priv->ule_skb);
 					/* Prepare for next SNDU. */
 					reset_ule(priv);
+					/* Resync: go to where pointer field points to: start of next ULE SNDU. */
+					from_where += ts[4];
+					ts_remain -= ts[4];
 				}
 			}
 		}
 
 		/* Check if new payload needs to be started. */
 		if (priv->ule_skb == NULL) {
-			/* Start a new payload w/ skb.
+			/* Start a new payload with skb.
 			 * Find ULE header.  It is only guaranteed that the
 			 * length field (2 bytes) is contained in the current
 			 * TS.
@@ -319,6 +487,7 @@
 			}
 
 			if (! priv->ule_sndu_len) {
+				/* Got at least two bytes, thus extrace the SNDU length. */
 				priv->ule_sndu_len = from_where[0] << 8 | from_where[1];
 				if (priv->ule_sndu_len & 0x8000) {
 					/* D-Bit is set: no dest mac present. */
@@ -327,17 +496,14 @@
 				} else
 					priv->ule_dbit = 0;
 
-				/* printk(KERN_WARNING "ULE D-Bit: %d, SNDU len %u.\n",
-				          priv->ule_dbit, priv->ule_sndu_len); */
-
 				if (priv->ule_sndu_len > 32763) {
-					printk(KERN_WARNING "Invalid ULE SNDU length %u. "
-					       "Resyncing.\n", priv->ule_sndu_len);
-					hexdump(ts, TS_SZ);
+					printk(KERN_WARNING "%lu: Invalid ULE SNDU length %u. "
+					       "Resyncing.\n", priv->ts_count, priv->ule_sndu_len);
 					priv->ule_sndu_len = 0;
 					priv->need_pusi = 1;
 					new_ts = 1;
 					ts += TS_SZ;
+					priv->ts_count++;
 					continue;
 				}
 				ts_remain -= 2;	/* consume the 2 bytes SNDU length. */
@@ -355,11 +521,12 @@
 				case 1:
 					priv->ule_sndu_type = from_where[0] << 8;
 					priv->ule_sndu_type_1 = 1; /* first byte of ule_type is set. */
-					/* ts_remain -= 1; from_where += 1;
-					 *   here not necessary, because we continue. */
+					ts_remain -= 1; from_where += 1;
+					/* Continue w/ next TS. */
 				case 0:
 					new_ts = 1;
 					ts += TS_SZ;
+					priv->ts_count++;
 					continue;
 
 				default: /* complete ULE header is present in current TS. */
@@ -377,24 +544,9 @@
 					break;
 			}
 
-			if (priv->ule_sndu_type == ULE_TEST) {
-				/* Test SNDU, discarded by the receiver. */
-				printk(KERN_WARNING "Discarding ULE Test SNDU (%d bytes). "
-				       "Resyncing.\n", priv->ule_sndu_len);
-				priv->ule_sndu_len = 0;
-				priv->need_pusi = 1;
-				continue;
-			}
-
-			skblen = priv->ule_sndu_len;	/* Including CRC32 */
-			if (priv->ule_sndu_type != ULE_BRIDGED) {
-				skblen += ETH_HLEN;
-#if 1
-				if (! priv->ule_dbit)
-					skblen -= ETH_ALEN;
-#endif
-			}
-			priv->ule_skb = dev_alloc_skb(skblen);
+			/* Allocate the skb (decoder target buffer) with the correct size, as follows:
+			 * prepare for the largest case: bridged SNDU with MAC address (dbit = 0). */
+			priv->ule_skb = dev_alloc_skb( priv->ule_sndu_len + ETH_HLEN + ETH_ALEN );
 			if (priv->ule_skb == NULL) {
 				printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
 				       dev->name);
@@ -402,130 +554,129 @@
 				return;
 			}
 
-#if 0
-			if (priv->ule_sndu_type != ULE_BRIDGED) {
-				// skb_reserve(priv->ule_skb, 2);    /* longword align L3 header */
-				// Create Ethernet header.
-				ethh = (struct ethhdr *)skb_put( priv->ule_skb, ETH_HLEN );
-				memset( ethh->h_source, 0x00, ETH_ALEN );
-				if (priv->ule_dbit) {
-					// Dest MAC address not present --> generate our own.
-					memcpy( ethh->h_dest, eth_dest_addr, ETH_ALEN );
-				} else {
-					// Dest MAC address could be split across two TS cells.
-					// FIXME: implement.
-
-					printk( KERN_WARNING "%s: got destination MAC "
-						"address.\n", dev->name );
-					memcpy( ethh->h_dest, eth_dest_addr, ETH_ALEN );
-				}
-				ethh->h_proto = htons(priv->ule_sndu_type == ULE_LLC ?
-						      priv->ule_sndu_len : priv->ule_sndu_type);
-			}
-#endif
-			/* this includes the CRC32 _and_ dest mac, if !dbit! */
+			/* This includes the CRC32 _and_ dest mac, if !dbit. */
 			priv->ule_sndu_remain = priv->ule_sndu_len;
 			priv->ule_skb->dev = dev;
+			/* Leave space for Ethernet or bridged SNDU header (eth hdr plus one MAC addr). */
+			skb_reserve( priv->ule_skb, ETH_HLEN + ETH_ALEN );
 		}
 
 		/* Copy data into our current skb. */
 		how_much = min(priv->ule_sndu_remain, (int)ts_remain);
-		if ((priv->ule_ethhdr_complete < ETH_ALEN) &&
-		    (priv->ule_sndu_type != ULE_BRIDGED)) {
-			ethh = (struct ethhdr *)priv->ule_skb->data;
-			if (! priv->ule_dbit) {
-				if (how_much >= (ETH_ALEN - priv->ule_ethhdr_complete)) {
-					/* copy dest mac address. */
-					memcpy(skb_put(priv->ule_skb,
-						       (ETH_ALEN - priv->ule_ethhdr_complete)),
-					       from_where,
-					       (ETH_ALEN - priv->ule_ethhdr_complete));
-					memset(ethh->h_source, 0x00, ETH_ALEN);
-					ethh->h_proto = htons(priv->ule_sndu_type == ULE_LLC ?
-							      priv->ule_sndu_len :
-							      priv->ule_sndu_type);
-					skb_put(priv->ule_skb, ETH_ALEN + 2);
-
-					how_much -= (ETH_ALEN - priv->ule_ethhdr_complete);
-					priv->ule_sndu_remain -= (ETH_ALEN -
-								  priv->ule_ethhdr_complete);
-					ts_remain -= (ETH_ALEN - priv->ule_ethhdr_complete);
-					from_where += (ETH_ALEN - priv->ule_ethhdr_complete);
-					priv->ule_ethhdr_complete = ETH_ALEN;
-				}
-			} else {
-				/* Generate whole Ethernet header. */
-				memcpy(ethh->h_dest, eth_dest_addr, ETH_ALEN);
-				memset(ethh->h_source, 0x00, ETH_ALEN);
-				ethh->h_proto = htons(priv->ule_sndu_type == ULE_LLC ?
-						      priv->ule_sndu_len : priv->ule_sndu_type);
-				skb_put(priv->ule_skb, ETH_HLEN);
-				priv->ule_ethhdr_complete = ETH_ALEN;
-			}
-		}
-		/* printk(KERN_WARNING "Copying %u bytes, ule_sndu_remain = %u, "
-		          "ule_sndu_len = %u.\n", how_much, priv->ule_sndu_remain,
-			  priv->ule_sndu_len); */
 		memcpy(skb_put(priv->ule_skb, how_much), from_where, how_much);
 		priv->ule_sndu_remain -= how_much;
 		ts_remain -= how_much;
 		from_where += how_much;
 
-		if ((priv->ule_ethhdr_complete < ETH_ALEN) &&
-		    (priv->ule_sndu_type != ULE_BRIDGED)) {
-			priv->ule_ethhdr_complete += how_much;
-		}
-
 		/* Check for complete payload. */
 		if (priv->ule_sndu_remain <= 0) {
 			/* Check CRC32, we've got it in our skb already. */
 			unsigned short ulen = htons(priv->ule_sndu_len);
 			unsigned short utype = htons(priv->ule_sndu_type);
-			struct kvec iov[4] = {
+			struct kvec iov[3] = {
 				{ &ulen, sizeof ulen },
 				{ &utype, sizeof utype },
-				{ NULL, 0 },
-				{ priv->ule_skb->data + ETH_HLEN,
-					priv->ule_skb->len - ETH_HLEN - 4 }
+				{ priv->ule_skb->data, priv->ule_skb->len - 4 }
 			};
 			unsigned long ule_crc = ~0L, expected_crc;
 			if (priv->ule_dbit) {
 				/* Set D-bit for CRC32 verification,
 				 * if it was set originally. */
 				ulen |= 0x0080;
-			} else {
-				iov[2].iov_base = priv->ule_skb->data;
-				iov[2].iov_len = ETH_ALEN;
 			}
-			ule_crc = iov_crc32(ule_crc, iov, 4);
+
+			ule_crc = iov_crc32(ule_crc, iov, 3);
 			expected_crc = *((u8 *)priv->ule_skb->tail - 4) << 24 |
 				*((u8 *)priv->ule_skb->tail - 3) << 16 |
 				*((u8 *)priv->ule_skb->tail - 2) << 8 |
 				*((u8 *)priv->ule_skb->tail - 1);
 			if (ule_crc != expected_crc) {
-				printk(KERN_WARNING "CRC32 check %s: %#lx / %#lx.\n",
-				       ule_crc != expected_crc ? "FAILED" : "OK",
-				       ule_crc, expected_crc);
-				hexdump(priv->ule_skb->data + ETH_HLEN,
-					priv->ule_skb->len - ETH_HLEN);
+				printk(KERN_WARNING "%lu: CRC32 check FAILED: %#lx / %#lx, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
+				       priv->ts_count, ule_crc, expected_crc, priv->ule_sndu_len, priv->ule_sndu_type, ts_remain, ts_remain > 2 ? *(unsigned short *)from_where : 0);
+
+#ifdef ULE_DEBUG
+				hexdump( iov[0].iov_base, iov[0].iov_len );
+				hexdump( iov[1].iov_base, iov[1].iov_len );
+				hexdump( iov[2].iov_base, iov[2].iov_len );
+
+				if (ule_where == ule_hist) {
+					hexdump( &ule_hist[98*TS_SZ], TS_SZ );
+					hexdump( &ule_hist[99*TS_SZ], TS_SZ );
+				} else if (ule_where == &ule_hist[TS_SZ]) {
+					hexdump( &ule_hist[99*TS_SZ], TS_SZ );
+					hexdump( ule_hist, TS_SZ );
+				} else {
+					hexdump( ule_where - TS_SZ - TS_SZ, TS_SZ );
+					hexdump( ule_where - TS_SZ, TS_SZ );
+				}
+				ule_dump = 1;
+#endif
 
 				((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
 				((struct dvb_net_priv *) dev->priv)->stats.rx_crc_errors++;
 				dev_kfree_skb(priv->ule_skb);
 			} else {
+				/* CRC32 verified OK. */
+				/* Handle ULE Extension Headers. */
+				if (priv->ule_sndu_type < 1536) {
+					/* There is an extension header.  Handle it accordingly. */
+					int l = handle_ule_extensions( priv );
+					if (l < 0) {
+						/* Mandatory extension header unknown or TEST SNDU.  Drop it. */
+						// printk( KERN_WARNING "Dropping SNDU, extension headers.\n" );
+						dev_kfree_skb( priv->ule_skb );
+						goto sndu_done;
+					}
+					skb_pull( priv->ule_skb, l );
+				}
+
 				/* CRC32 was OK. Remove it from skb. */
 				priv->ule_skb->tail -= 4;
 				priv->ule_skb->len -= 4;
+
+				/* Filter on receiver's destination MAC address, if present. */
+				if (!priv->ule_dbit) {
+					/* The destination MAC address is the next data in the skb. */
+					if (memcmp( priv->ule_skb->data, dev->dev_addr, ETH_ALEN )) {
+						/* MAC addresses don't match.  Drop SNDU. */
+						// printk( KERN_WARNING "Dropping SNDU, MAC address.\n" );
+						dev_kfree_skb( priv->ule_skb );
+						goto sndu_done;
+					}
+					if (! priv->ule_bridged) {
+						skb_push( priv->ule_skb, ETH_ALEN + 2 );
+						ethh = (struct ethhdr *)priv->ule_skb->data;
+						memcpy( ethh->h_dest, ethh->h_source, ETH_ALEN );
+						memset( ethh->h_source, 0, ETH_ALEN );
+						ethh->h_proto = htons( priv->ule_sndu_type );
+					} else {
+						/* Skip the Receiver destination MAC address. */
+						skb_pull( priv->ule_skb, ETH_ALEN );
+					}
+				} else {
+					if (! priv->ule_bridged) {
+						skb_push( priv->ule_skb, ETH_HLEN );
+						ethh = (struct ethhdr *)priv->ule_skb->data;
+						memcpy( ethh->h_dest, dev->dev_addr, ETH_ALEN );
+						memset( ethh->h_source, 0, ETH_ALEN );
+						ethh->h_proto = htons( priv->ule_sndu_type );
+					} else {
+						/* skb is in correct state; nothing to do. */
+					}
+				}
+				priv->ule_bridged = 0;
+
 				/* Stuff into kernel's protocol stack. */
 				priv->ule_skb->protocol = dvb_net_eth_type_trans(priv->ule_skb, dev);
 				/* If D-bit is set (i.e. destination MAC address not present),
-				 * receive the packet anyhw. */
-				/* if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST) */
-					priv->ule_skb->pkt_type = PACKET_HOST;
+				 * receive the packet anyhow. */
+				/* if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST)
+					priv->ule_skb->pkt_type = PACKET_HOST; */
 				((struct dvb_net_priv *) dev->priv)->stats.rx_packets++;
 				((struct dvb_net_priv *) dev->priv)->stats.rx_bytes += priv->ule_skb->len;
 				netif_rx(priv->ule_skb);
 			}
+			sndu_done:
 			/* Prepare for next SNDU. */
 			reset_ule(priv);
 		}
@@ -545,6 +696,7 @@
 		} else {
 			new_ts = 1;
 			ts += TS_SZ;
+			priv->ts_count++;
 			if (priv->ule_skb == NULL) {
 				priv->need_pusi = 1;
 				priv->ule_sndu_type_1 = 0;
@@ -662,6 +814,7 @@
 
 static int dvb_net_tx(struct sk_buff *skb, struct net_device *dev)
 {
+	dev_kfree_skb(skb);
 	return 0;
 }
 
@@ -723,7 +876,7 @@
         unsigned char *mac = (unsigned char *) dev->dev_addr;
 		
 	dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
-	if (priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
+	if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
 		printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
 
 	priv->secfeed=NULL;
@@ -919,14 +1072,6 @@
 }
 
 
-static int dvb_net_set_config(struct net_device *dev, struct ifmap *map)
-{
-	if (netif_running(dev))
-		return -EBUSY;
-	return 0;
-}
-
-
 static void wq_restart_net_feed (void *data)
 {
 	struct net_device *dev = data;
@@ -985,7 +1130,6 @@
 	dev->hard_start_xmit	= dvb_net_tx;
 	dev->get_stats		= dvb_net_get_stats;
 	dev->set_multicast_list = dvb_net_set_multicast_list;
-	dev->set_config         = dvb_net_set_config;
 	dev->set_mac_address    = dvb_net_set_mac;
 	dev->mtu		= 4096;
 	dev->mc_count           = 0;
@@ -1057,13 +1201,14 @@
 }
 
 
-static int dvb_net_remove_if(struct dvb_net *dvbnet, int num)
+static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num)
 {
 	struct net_device *net = dvbnet->device[num];
-	struct dvb_net_priv *priv = net->priv;
+	struct dvb_net_priv *priv;
 
 	if (!dvbnet->state[num])
 		return -EINVAL;
+	priv = net->priv;
 	if (priv->in_use)
 		return -EBUSY;
 
@@ -1124,10 +1269,18 @@
 		break;
 	}
 	case NET_REMOVE_IF:
+	{
+		int ret;
+
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		module_put(dvbdev->adapter->module);
-		return dvb_net_remove_if(dvbnet, (int) (long) parg);
+		if ((unsigned int) parg >= DVB_NET_DEVICES_MAX)
+			return -EINVAL;
+		ret = dvb_net_remove_if(dvbnet, (unsigned int) parg);
+		if (!ret)
+			module_put(dvbdev->adapter->module);
+		return ret;
+	}
 
 	/* binary compatiblity cruft */
 	case __NET_ADD_IF_OLD:
@@ -1203,6 +1356,7 @@
 		dvb_net_remove_if(dvbnet, i);
 	}
 }
+EXPORT_SYMBOL(dvb_net_release);
 
 
 int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet,
@@ -1220,4 +1374,4 @@
 
 	return 0;
 }
-
+EXPORT_SYMBOL(dvb_net_init);
diff -Nru a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
--- a/drivers/media/dvb/dvb-core/dvbdev.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/dvb/dvb-core/dvbdev.c	2004-12-24 13:36:31 -08:00
@@ -25,22 +25,26 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/device.h>
 
 #include "dvbdev.h"
-#include "dvb_functions.h"
 
-static int dvbdev_debug = 0;
+static int dvbdev_debug;
+
+module_param(dvbdev_debug, int, 0644);
+MODULE_PARM_DESC(dvbdev_debug, "Turn on/off device debugging (default:off).");
+
 #define dprintk if (dvbdev_debug) printk
 
 static LIST_HEAD(dvb_adapter_list);
 static DECLARE_MUTEX(dvbdev_register_lock);
 
-
-static char *dnames[] = { 
+static const char * const dnames[] = {
         "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
 	"net", "osd"
 };
@@ -49,6 +53,9 @@
 #define DVB_MAX_IDS              4
 #define nums2minor(num,type,id)  ((num << 6) | (id << 4) | type)
 
+struct class_simple *dvb_class;
+EXPORT_SYMBOL(dvb_class);
+
 static struct dvb_device* dvbdev_find_device (int minor)
 {
 	struct list_head *entry;
@@ -125,6 +132,7 @@
 	dvbdev->users--;
 	return 0;
 }
+EXPORT_SYMBOL(dvb_generic_open);
 
 
 int dvb_generic_release(struct inode *inode, struct file *file)
@@ -143,6 +151,7 @@
 	dvbdev->users++;
 	return 0;
 }
+EXPORT_SYMBOL(dvb_generic_release);
 
 
 int dvb_generic_ioctl(struct inode *inode, struct file *file,
@@ -158,6 +167,7 @@
 
 	return dvb_usercopy (inode, file, cmd, arg, dvbdev->kernel_ioctl);
 }
+EXPORT_SYMBOL(dvb_generic_ioctl);
 
 
 static int dvbdev_get_free_id (struct dvb_adapter *adap, int type)
@@ -219,12 +229,16 @@
 			S_IFCHR | S_IRUSR | S_IWUSR,
 			"dvb/adapter%d/%s%d", adap->num, dnames[type], id);
 
+	class_simple_device_add(dvb_class, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
+				NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
+
 	dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
 		adap->num, dnames[type], id, nums2minor(adap->num, type, id),
 		nums2minor(adap->num, type, id));
 
 	return 0;
 }
+EXPORT_SYMBOL(dvb_register_device);
 
 
 void dvb_unregister_device(struct dvb_device *dvbdev)
@@ -235,9 +249,13 @@
 		devfs_remove("dvb/adapter%d/%s%d", dvbdev->adapter->num,
 				dnames[dvbdev->type], dvbdev->id);
 
+	class_simple_device_remove(MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num,
+					dvbdev->type, dvbdev->id)));
+
 		list_del(&dvbdev->list_head);
 		kfree(dvbdev);
 	}
+EXPORT_SYMBOL(dvb_unregister_device);
 
 
 static int dvbdev_get_free_adapter_num (void)
@@ -296,28 +314,101 @@
 
 	return num;
 }
+EXPORT_SYMBOL(dvb_register_adapter);
 
 
 int dvb_unregister_adapter(struct dvb_adapter *adap)
 {
+	devfs_remove("dvb/adapter%d", adap->num);
+
 	if (down_interruptible (&dvbdev_register_lock))
 		return -ERESTARTSYS;
-        devfs_remove("dvb/adapter%d", adap->num);
 	list_del (&adap->list_head);
 	up (&dvbdev_register_lock);
 	kfree (adap);
 	return 0;
 }
+EXPORT_SYMBOL(dvb_unregister_adapter);
 
+/* if the miracle happens and "generic_usercopy()" is included into
+   the kernel, then this can vanish. please don't make the mistake and
+   define this as video_usercopy(). this will introduce a dependecy
+   to the v4l "videodev.o" module, which is unnecessary for some
+   cards (ie. the budget dvb-cards don't need the v4l module...) */
+int dvb_usercopy(struct inode *inode, struct file *file,
+	             unsigned int cmd, unsigned long arg,
+		     int (*func)(struct inode *inode, struct file *file,
+		     unsigned int cmd, void *arg))
+{
+        char    sbuf[128];
+        void    *mbuf = NULL;
+        void    *parg = NULL;
+        int     err  = -EINVAL;
+
+        /*  Copy arguments into temp kernel buffer  */
+        switch (_IOC_DIR(cmd)) {
+        case _IOC_NONE:
+		/*
+		 * For this command, the pointer is actually an integer
+		 * argument.
+		 */
+		parg = (void *) arg;
+		break;
+        case _IOC_READ: /* some v4l ioctls are marked wrong ... */
+        case _IOC_WRITE:
+        case (_IOC_WRITE | _IOC_READ):
+                if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
+                        parg = sbuf;
+                } else {
+                        /* too big to allocate from stack */
+                        mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
+                        if (NULL == mbuf)
+                                return -ENOMEM;
+                        parg = mbuf;
+                }
+
+                err = -EFAULT;
+                if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
+                        goto out;
+                break;
+        }
+
+        /* call driver */
+        if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
+                err = -EINVAL;
+
+        if (err < 0)
+                goto out;
+
+        /*  Copy results into user buffer  */
+        switch (_IOC_DIR(cmd))
+        {
+        case _IOC_READ:
+        case (_IOC_WRITE | _IOC_READ):
+                if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
+                        err = -EFAULT;
+                break;
+        }
+
+out:
+        if (mbuf)
+                kfree(mbuf);
+
+        return err;
+}
 
 static int __init init_dvbdev(void)
 {
 	int retval;
+
+	if ((retval = register_chrdev(DVB_MAJOR,"DVB", &dvb_device_fops)))
+		printk("dvb-core: unable to get major %d\n", DVB_MAJOR);
+
 	devfs_mk_dir("dvb");
 
-	retval = register_chrdev(DVB_MAJOR,"DVB", &dvb_device_fops);
-	if (retval)
-		printk("video_dev: unable to get major %d\n", DVB_MAJOR);
+	dvb_class = class_simple_create(THIS_MODULE, "dvb");
+	if (IS_ERR(dvb_class))
+		return PTR_ERR(dvb_class);
 
 	return retval;
 }
@@ -327,6 +418,7 @@
 {
 	unregister_chrdev(DVB_MAJOR, "DVB");
         devfs_remove("dvb");
+	class_simple_destroy(dvb_class);
 }
 
 module_init(init_dvbdev);
@@ -335,7 +427,4 @@
 MODULE_DESCRIPTION("DVB Core Driver");
 MODULE_AUTHOR("Marcus Metzler, Ralph Metzler, Holger Waechtler");
 MODULE_LICENSE("GPL");
-
-MODULE_PARM(dvbdev_debug,"i");
-MODULE_PARM_DESC(dvbdev_debug, "enable verbose debug messages");
 
diff -Nru a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
--- a/drivers/media/dvb/dvb-core/dvbdev.h	2004-12-24 13:36:33 -08:00
+++ b/drivers/media/dvb/dvb-core/dvbdev.h	2004-12-24 13:36:33 -08:00
@@ -28,6 +28,7 @@
 #include <linux/fs.h>
 #include <linux/list.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/smp_lock.h>
 
 #define DVB_MAJOR 212
 
@@ -48,6 +49,7 @@
 	struct list_head device_list;
 	const char *name;
 	u8 proposed_mac [6];
+	void* priv;
 
 	struct module *module;
 };
@@ -92,5 +94,15 @@
 extern int dvb_generic_release (struct inode *inode, struct file *file);
 extern int dvb_generic_ioctl (struct inode *inode, struct file *file,
 			      unsigned int cmd, unsigned long arg);
+
+/* we don't mess with video_usercopy() any more,
+we simply define out own dvb_usercopy(), which will hopefully become
+generic_usercopy()  someday... */
+
+extern int dvb_usercopy(struct inode *inode, struct file *file,
+	                    unsigned int cmd, unsigned long arg,
+			    int (*func)(struct inode *inode, struct file *file,
+			    unsigned int cmd, void *arg));
+
 #endif /* #ifndef _DVBDEV_H_ */
 
diff -Nru a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
--- a/drivers/media/dvb/frontends/Kconfig	2004-12-24 13:36:19 -08:00
+++ b/drivers/media/dvb/frontends/Kconfig	2004-12-24 13:36:19 -08:00
@@ -1,187 +1,148 @@
-comment "Supported Frontend Modules"
-	depends on DVB
-
-config DVB_TWINHAN_DST
-	tristate "TWINHAN DST based DVB-S frontend (QPSK)"
-	depends on DVB_CORE && DVB_BT8XX
-	help
-	  Used in such cards as the VP-1020/1030, Twinhan DST,
-	  VVmer TV@SAT. Say Y when you want to support frontends 
-	  using this asic.
+menu "Customise DVB Frontends"
+	depends on DVB_CORE
 
-	  This module requires the dvb-bt8xx driver and dvb bt878
-	  module.
+comment "DVB-S (satellite) frontends"
+	depends on DVB_CORE
 
 config DVB_STV0299
-	tristate "STV0299 based DVB-S frontend (QPSK)"
+	tristate "ST STV0299 based"
 	depends on DVB_CORE
 	help
-	  The stv0299 by ST is used in many DVB-S tuner modules, 
-	  say Y when you want to support frontends based on this 
-	  DVB-S demodulator.
-
-	  Some examples are the Alps BSRU6, the Philips SU1278 and
-	  the LG TDQB-S00x.
-
-	  If you don't know what tuner module is soldered on your 
-	  DVB adapter simply enable all supported frontends, the 
-	  right one will get autodetected.
+	  A DVB-S tuner module. Say Y when you want to support this frontend.
 
-config DVB_SP887X
- 	tristate "Frontends with sp887x demodulators, e.g. Microtune DTF7072"
+config DVB_CX24110
+	tristate "Conexant CX24110 based"
  	depends on DVB_CORE
  	help
- 	  A DVB-T demodulator driver. Say Y when you want to support the sp887x.
+	  A DVB-S tuner module. Say Y when you want to support this frontend.
  
- 	  If you don't know what tuner module is soldered on your
- 	  DVB adapter simply enable all supported frontends, the
- 	  right one will get autodetected.
+config DVB_TDA8083
+	tristate "Philips TDA8083 based"
+	depends on DVB_CORE
+	help
+	  A DVB-S tuner module. Say Y when you want to support this frontend.
 
+config DVB_TDA80XX
+	tristate "Philips TDA8044 or TDA8083 based"
+	depends on DVB_CORE
+	help
+	  A DVB-S tuner module. Say Y when you want to support this frontend.
 
-config DVB_SP887X_FIRMWARE_FILE
-        string "Full pathname of sp887x firmware file"
-        depends on DVB_SP887X
-        default "/usr/lib/hotplug/firmware/sc_main.mc"
-        help
-          This driver needs a copy of the Avermedia firmware. The version tested
-	  is part of the Avermedia DVB-T 1.3.26.3 Application. This can be downloaded
-	  from the Avermedia web site.
-	  If the software is installed in Windows the file will be in the
-	  /Program Files/AVerTV DVB-T/ directory and is called sc_main.mc.
-	  Alternatively it can "extracted" from the install cab files but this will have
-	  to be done in windows as I don't know of a linux version of extract.exe.
-	  Copy this file to /usr/lib/hotplug/firmware/sc_main.mc.
-	  With this version of the file the first 10 bytes are discarded and the next
-	  0x4000 loaded. This may change in future versions.
+config DVB_MT312
+	tristate "Zarlink MT312 based"
+	depends on DVB_CORE
+	help
+	  A DVB-S tuner module. Say Y when you want to support this frontend.
 
-config DVB_ALPS_TDLB7
-	tristate "Alps TDLB7 (OFDM)"
+config DVB_VES1X93
+	tristate "VLSI VES1893 or VES1993 based"
 	depends on DVB_CORE
 	help
-	  A DVB-T tuner module. Say Y when you want to support this frontend.
+	  A DVB-S tuner module. Say Y when you want to support this frontend.
 
-	  This tuner module needs some microcode located in a file called
-	  "Sc_main.mc" in the windows driver. Please pass the module parameter
-	  mcfile="/PATH/FILENAME" when loading alps_tdlb7.o.
+comment "DVB-T (terrestrial) frontends"
+	depends on DVB_CORE
 
-	  If you don't know what tuner module is soldered on your
-	  DVB adapter simply enable all supported frontends, the
-	  right one will get autodetected.
+config DVB_SP8870
+ 	tristate "Spase sp8870 based"
+	depends on DVB_CORE
+	help
+ 	  A DVB-T tuner module. Say Y when you want to support this frontend.
 
+	  This driver needs external firmware. Please use the command
+	  "<kerneldir>/Documentation/dvb/get_dvb_firmware sp8870" to
+	  download/extract it, and then copy it to /usr/lib/hotplug/firmware.
 
-config DVB_ALPS_TDMB7
-	tristate "Alps TDMB7 (OFDM)"
+config DVB_SP887X
+ 	tristate "Spase sp887x based"
 	depends on DVB_CORE
 	help
 	  A DVB-T tuner module. Say Y when you want to support this frontend.
 
-	  If you don't know what tuner module is soldered on your
-	  DVB adapter simply enable all supported frontends, the
-	  right one will get autodetected.
+	  This driver needs external firmware. Please use the command
+	  "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to
+	  download/extract it, and then copy it to /usr/lib/hotplug/firmware.
 
-config DVB_ATMEL_AT76C651
-	tristate "Atmel AT76C651 (QAM)"
+config DVB_CX22700
+	tristate "Conexant CX22700 based"
 	depends on DVB_CORE
 	help
-	  The AT76C651 Demodulator is used in some DVB-C SetTopBoxes. Say Y
-	  when you see this demodulator chip near your tuner module.
+	  A DVB-T tuner module. Say Y when you want to support this frontend.
 
-	  If you don't know what tuner module is soldered on your
-	  DVB adapter simply enable all supported frontends, the
-	  right one will get autodetected.
+config DVB_CX22702
+ 	tristate "Conexant cx22702 demodulator (OFDM)"
+ 	depends on DVB_CORE
+ 	help
+ 	  A DVB-T tuner module. Say Y when you want to support this frontend.
 
-config DVB_CX24110
-	tristate "Frontends with Connexant CX24110 demodulator (QPSK)"
+config DVB_L64781
+	tristate "LSI L64781"
 	depends on DVB_CORE
 	help
-	  The CX24110 Demodulator is used in some DVB-S frontends. 
-	  Say Y if you want support for this chip in your kernel.
-
-	  If you don't know what tuner module is soldered on your 
-	  DVB adapter simply enable all supported frontends, the 
-	  right one will get autodetected.
+	  A DVB-T tuner module. Say Y when you want to support this frontend.
 
-config DVB_GRUNDIG_29504_491
-	tristate "Grundig 29504-491 (QPSK)"
+config DVB_TDA1004X
+	tristate "Philips TDA10045H/TDA10046H based"
 	depends on DVB_CORE
 	help
-	  A DVB-S tuner module. Say Y when you want to support this frontend.
+	  A DVB-T tuner module. Say Y when you want to support this frontend.
 
-	  If you don't know what tuner module is soldered on your 
-	  DVB adapter simply enable all supported frontends, the 
-	  right one will get autodetected.
+	  This driver needs external firmware. Please use the commands
+	  "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",
+  	  "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to
+	  download/extract them, and then copy them to /usr/lib/hotplug/firmware.
 
-config DVB_GRUNDIG_29504_401
-	tristate "Grundig 29504-401 (OFDM)"
+config DVB_NXT6000
+	tristate "NxtWave Communications NXT6000 based"
 	depends on DVB_CORE
 	help
 	  A DVB-T tuner module. Say Y when you want to support this frontend.
 
-	  If you don't know what tuner module is soldered on your 
-	  DVB adapter simply enable all supported frontends, the 
-	  right one will get autodetected.
-
-config DVB_MT312
-	tristate "Zarlink MT312 Satellite Channel Decoder (QPSK)"
+config DVB_MT352
+	tristate "Zarlink MT352 based"
 	depends on DVB_CORE
 	help
-	  A DVB-S tuner module. Say Y when you want to support this frontend.
-
-	  If you don't know what tuner module is soldered on your 
-	  DVB adapter simply enable all supported frontends, the 
-	  right one will get autodetected.
+	  A DVB-T tuner module. Say Y when you want to support this frontend.
 
-config DVB_VES1820
-	tristate "Frontends with external VES1820 demodulator (QAM)"
+config DVB_DIB3000MB
+	tristate "DiBcom 3000-MB"
 	depends on DVB_CORE
 	help
-	  The VES1820 Demodulator is used on many DVB-C PCI cards and in some
-	  DVB-C SetTopBoxes. Say Y when you see this demodulator chip near your
-	  tuner module.
-
-	  If you don't know what tuner module is soldered on your 
-	  DVB adapter simply enable all supported frontends, the 
-	  right one will get autodetected.
+	  A DVB-T tuner module. Designed for mobile usage. Say Y when you want
+	  to support this frontend.
 
-config DVB_VES1X93
-	tristate "Frontends with VES1893 or VES1993 demodulator (QPSK)"
+config DVB_DIB3000MC
+	tristate "DiBcom 3000-MC/P"
 	depends on DVB_CORE
 	help
-	  A DVB-S tuner module. Say Y when you want to support this frontend.
+	  A DVB-T tuner module. Designed for mobile usage. Say Y when you want
+	  to support this frontend.
 
-	  If you don't know what tuner module is soldered on your 
-	  DVB adapter simply enable all supported frontends, the 
-	  right one will get autodetected.
+comment "DVB-C (cable) frontends"
+	depends on DVB_CORE
 
-config DVB_TDA1004X
-	tristate "Frontends with external TDA10045H or TDA10046H demodulators (OFDM)"
+config DVB_ATMEL_AT76C651
+	tristate "Atmel AT76C651 based"
 	depends on DVB_CORE
-	help
-	  A DVB-T tuner module. Say Y when you want to support this frontend.
+        help
+ 	  A DVB-C tuner module. Say Y when you want to support this frontend.
 
-	  If you don't know what tuner module is soldered on your
-	  DVB adapter simply enable all supported frontends, the
-	  right one will get autodetected.
+config DVB_VES1820
+	tristate "VLSI VES1820 based"
+	depends on DVB_CORE
+	help
+ 	  A DVB-C tuner module. Say Y when you want to support this frontend.
 
-config DVB_TDA1004X_FIRMWARE_FILE
-        string "Full pathname of tda1004x.bin firmware file"
-        depends on DVB_TDA1004X
-        default "/usr/lib/hotplug/firmware/tda1004x.bin"
-        help
-          The TDA1004X requires additional firmware in order to function.
-          The firmware file can obtained as follows:
-            wget http://www.technotrend.de/new/215/TTweb_215a_budget_20_05_2003.zip
-            unzip -j TTweb_215a_budget_20_05_2003.zip Software/Oem/PCI/App/ttlcdacc.dll
-            mv ttlcdacc.dll /usr/lib/hotplug/firmware/tda1004x.bin
-	  Note: even if you're using a USB device, you MUST get the file from the
-	  TechnoTrend PCI drivers.
+config DVB_TDA10021
+	tristate "Philips TDA10021 based"
+	depends on DVB_CORE
+	help
+ 	  A DVB-C tuner module. Say Y when you want to support this frontend.
 
-config DVB_NXT6000
-	tristate "Frontends with NxtWave Communications NXT6000 demodulator (OFDM)"
+config DVB_STV0297
+	tristate "ST STV0297 based"
 	depends on DVB_CORE
 	help
-	  A DVB-T tuner module. Say Y when you want to support this frontend.
+	  A DVB-C tuner module. Say Y when you want to support this frontend.
 
-	  If you don't know what tuner module is soldered on your
-	  DVB adapter simply enable all supported frontends, the
-	  right one will get autodetected.
+endmenu
diff -Nru a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
--- a/drivers/media/dvb/frontends/Makefile	2004-12-24 13:36:17 -08:00
+++ b/drivers/media/dvb/frontends/Makefile	2004-12-24 13:36:17 -08:00
@@ -4,17 +4,23 @@
 
 EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
 
-obj-$(CONFIG_DVB_TWINHAN_DST) += dst.o
 obj-$(CONFIG_DVB_STV0299) += stv0299.o
-obj-$(CONFIG_DVB_ALPS_TDLB7) += alps_tdlb7.o
-obj-$(CONFIG_DVB_ALPS_TDMB7) += alps_tdmb7.o
+obj-$(CONFIG_DVB_SP8870) += sp8870.o
+obj-$(CONFIG_DVB_CX22700) += cx22700.o
 obj-$(CONFIG_DVB_ATMEL_AT76C651) += at76c651.o
 obj-$(CONFIG_DVB_CX24110) += cx24110.o
-obj-$(CONFIG_DVB_GRUNDIG_29504_491) += grundig_29504-491.o
-obj-$(CONFIG_DVB_GRUNDIG_29504_401) += grundig_29504-401.o
+obj-$(CONFIG_DVB_TDA8083) += tda8083.o
+obj-$(CONFIG_DVB_L64781) += l64781.o
+obj-$(CONFIG_DVB_DIB3000MB) += dib3000mb.o dib3000-common.o
+obj-$(CONFIG_DVB_DIB3000MC) += dib3000mc.o dib3000-common.o
 obj-$(CONFIG_DVB_MT312) += mt312.o
 obj-$(CONFIG_DVB_VES1820) += ves1820.o
 obj-$(CONFIG_DVB_VES1X93) += ves1x93.o
 obj-$(CONFIG_DVB_TDA1004X) += tda1004x.o
 obj-$(CONFIG_DVB_SP887X) += sp887x.o
 obj-$(CONFIG_DVB_NXT6000) += nxt6000.o
+obj-$(CONFIG_DVB_MT352) += mt352.o
+obj-$(CONFIG_DVB_CX22702) += cx22702.o
+obj-$(CONFIG_DVB_TDA80XX) += tda80xx.o
+obj-$(CONFIG_DVB_TDA10021) += tda10021.o
+obj-$(CONFIG_DVB_STV0297) += stv0297.o
diff -Nru a/drivers/media/dvb/frontends/alps_tdlb7.c b/drivers/media/dvb/frontends/alps_tdlb7.c
--- a/drivers/media/dvb/frontends/alps_tdlb7.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,724 +0,0 @@
-/*
-    Driver for Alps TDLB7 Frontend
-
-    Copyright (C) 1999 Juergen Peitz
-
-    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.
-
-*/
-
-
-/* 
-    This driver needs a copy of the firmware file 'Sc_main.mc' from the Haupauge
-    windows driver in the '/usr/lib/DVB/driver/frontends' directory.
-    You can also pass the complete file name with the module parameter 'firmware_file'.
-    
-*/  
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/vmalloc.h>
-#include <linux/fs.h>
-#include <linux/unistd.h>
-#include <linux/delay.h>
-#include <linux/syscalls.h>
-
-#include "dvb_frontend.h"
-#include "dvb_functions.h"
-
-#ifndef CONFIG_ALPS_TDLB7_FIRMWARE_LOCATION
-#define CONFIG_ALPS_TDLB7_FIRMWARE_LOCATION "/usr/lib/DVB/driver/frontends/Sc_main.mc"
-#endif
-
-static char * firmware_file = CONFIG_ALPS_TDLB7_FIRMWARE_LOCATION;
-static int debug = 0;
-
-#define dprintk	if (debug) printk
-
-/* firmware size for sp8870 */
-#define SP8870_FIRMWARE_SIZE 16382
-
-/* starting point for firmware in file 'Sc_main.mc' */
-#define SP8870_FIRMWARE_OFFSET 0x0A
-
-static struct dvb_frontend_info tdlb7_info = {
-	.name			= "Alps TDLB7",
-	.type			= FE_OFDM,
-	.frequency_min		= 470000000,
-	.frequency_max		= 860000000,
-	.frequency_stepsize	= 166666,
-	.caps			= FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
-				  FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 |
-				  FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-				  FE_CAN_QPSK | FE_CAN_QAM_16 |
-				  FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
-				  FE_CAN_HIERARCHY_AUTO |  FE_CAN_RECOVER
-};
-
-
-static int sp8870_writereg (struct dvb_i2c_bus *i2c, u16 reg, u16 data)
-{
-        u8 buf [] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff };
-	struct i2c_msg msg = { .addr = 0x71, .flags = 0, .buf = buf, .len = 4 };
-	int err;
-
-        if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
-		dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
-		return -EREMOTEIO;
-	}
-
-        return 0;
-}
-
-
-static u16 sp8870_readreg (struct dvb_i2c_bus *i2c, u16 reg)
-{
-	int ret;
-	u8 b0 [] = { reg >> 8 , reg & 0xff };
-	u8 b1 [] = { 0, 0 };
-	struct i2c_msg msg [] = { { .addr = 0x71, .flags = 0, .buf = b0, .len = 2 },
-			   { .addr = 0x71, .flags = I2C_M_RD, .buf = b1, .len = 2 } };
-
-	ret = i2c->xfer (i2c, msg, 2);
-
-	if (ret != 2) {
-		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
-		return -1;
-	}
-
-	return (b1[0] << 8 | b1[1]);
-}
-
-
-static int sp5659_write (struct dvb_i2c_bus *i2c, u8 data [4])
-{
-        int ret;
-        struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = 4 };
-
-        ret = i2c->xfer (i2c, &msg, 1);
-
-        if (ret != 1)
-                printk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
-
-        return (ret != 1) ? -1 : 0;
-}
-
-
-static void sp5659_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
-{
-        u32 div = (freq + 36200000) / 166666;
-        u8 buf [4];
-	int pwr;
-
-	if (freq <= 782000000)
-		pwr = 1;
-	else 
-		pwr = 2;
-
-	buf[0] = (div >> 8) & 0x7f;
-	buf[1] = div & 0xff;
-	buf[2] = 0x85;
-	buf[3] = pwr << 6;
-
-	/* open i2c gate for PLL message transmission... */
-	sp8870_writereg(i2c, 0x206, 0x001);
-	sp5659_write (i2c, buf);
-	sp8870_writereg(i2c, 0x206, 0x000);
-}
-
-
-static int sp8870_read_firmware_file (const char *fn, char **fp)
-{
-        int fd;
-	loff_t filesize;
-	char *dp;
-
-	fd = sys_open(fn, 0, 0);
-	if (fd == -1) {
-                printk("%s: unable to open '%s'.\n", __FUNCTION__, fn);
-		return -EIO;
-	}
-
-	filesize = sys_lseek(fd, 0L, 2);
-	if (filesize <= 0 || filesize < SP8870_FIRMWARE_OFFSET + SP8870_FIRMWARE_SIZE) {
-	        printk("%s: firmware filesize to small '%s'\n", __FUNCTION__, fn);
-		sys_close(fd);
-		return -EIO;
-	}
-
-	*fp= dp = vmalloc(SP8870_FIRMWARE_SIZE);
-	if (dp == NULL)	{
-		printk("%s: out of memory loading '%s'.\n", __FUNCTION__, fn);
-		sys_close(fd);
-		return -EIO;
-	}
-
-	sys_lseek(fd, SP8870_FIRMWARE_OFFSET, 0);
-	if (sys_read(fd, dp, SP8870_FIRMWARE_SIZE) != SP8870_FIRMWARE_SIZE) {
-		printk("%s: failed to read '%s'.\n",__FUNCTION__, fn);
-		vfree(dp);
-		sys_close(fd);
-		return -EIO;
-	}
-
-	sys_close(fd);
-	*fp = dp;
-
-	return 0;
-}
-
-
-static int sp8870_firmware_upload (struct dvb_i2c_bus *i2c)
-{
-	struct i2c_msg msg;
-	char *fw_buf = NULL;
-	int fw_pos;
-	u8 tx_buf[255];
-	int tx_len;
-	int err = 0;
-	mm_segment_t fs = get_fs();
-
-	dprintk ("%s: ...\n", __FUNCTION__);
-
-	// system controller stop 
-	sp8870_writereg(i2c,0x0F00,0x0000);
-
-	// instruction RAM register hiword
-	sp8870_writereg(i2c, 0x8F08, ((SP8870_FIRMWARE_SIZE / 2) & 0xFFFF));
-
-	// instruction RAM MWR
-	sp8870_writereg(i2c, 0x8F0A, ((SP8870_FIRMWARE_SIZE / 2) >> 16));
-
-	// reading firmware file to buffer
-	set_fs(get_ds());
-        err = sp8870_read_firmware_file(firmware_file, (char**) &fw_buf);
-	set_fs(fs);
-	if (err != 0) {
-		printk("%s: reading firmware file failed!\n", __FUNCTION__);
-		return err;
-	}
-
-	// do firmware upload
-	fw_pos = 0;
-	while (fw_pos < SP8870_FIRMWARE_SIZE){
-		tx_len = (fw_pos <= SP8870_FIRMWARE_SIZE - 252) ? 252 : SP8870_FIRMWARE_SIZE - fw_pos;
-		// write register 0xCF0A
-		tx_buf[0] = 0xCF;
-		tx_buf[1] = 0x0A;
-		memcpy(&tx_buf[2], fw_buf + fw_pos, tx_len);
-		msg.addr=0x71;
-		msg.flags=0;
-		msg.buf = tx_buf;
-		msg.len = tx_len + 2;
-        	if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
-			printk("%s: firmware upload failed!\n", __FUNCTION__);
-			printk ("%s: i2c error (err == %i)\n", __FUNCTION__, err);
-        		vfree(fw_buf);
-			return err;
-		}
-		fw_pos += tx_len;
-	}
-
-	vfree(fw_buf);
-
-	dprintk ("%s: done!\n", __FUNCTION__);
-	return 0;
-};
-
-
-static void sp8870_microcontroller_stop (struct dvb_i2c_bus *i2c)
-{
-	sp8870_writereg(i2c, 0x0F08, 0x000);
-	sp8870_writereg(i2c, 0x0F09, 0x000);
-
-	// microcontroller STOP
-	sp8870_writereg(i2c, 0x0F00, 0x000);
-}
-
-
-static void sp8870_microcontroller_start (struct dvb_i2c_bus *i2c)
-{
-	sp8870_writereg(i2c, 0x0F08, 0x000);
-	sp8870_writereg(i2c, 0x0F09, 0x000);
-
-	// microcontroller START
-	sp8870_writereg(i2c, 0x0F00, 0x001);
-	// not documented but if we don't read 0x0D01 out here
-	// we don't get a correct data valid signal
-	sp8870_readreg(i2c, 0x0D01);
-}
-
-
-static int sp8870_init (struct dvb_i2c_bus *i2c)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	/* enable TS output and interface pins */
-	sp8870_writereg(i2c, 0xc18, 0x00d);
-
-	// system controller stop 
-	sp8870_microcontroller_stop(i2c);
-
-	// ADC mode
-	sp8870_writereg(i2c,0x0301,0x0003);
-
-	// Reed Solomon parity bytes passed to output
-	sp8870_writereg(i2c,0x0C13,0x0001);
-
-	// MPEG clock is suppressed if no valid data
-	sp8870_writereg(i2c,0x0C14,0x0001);
-
-	/* bit 0x010: enable data valid signal */
-	sp8870_writereg(i2c, 0x0D00, 0x010);
-	sp8870_writereg(i2c, 0x0D01, 0x000);
-
-	return 0;
-}
-
-
-static int sp8870_read_status (struct dvb_i2c_bus *i2c,  fe_status_t * fe_status)
-{
-	int status;
-	int signal;
-
-	*fe_status = 0;
-
-	status = sp8870_readreg (i2c, 0x0200);
-	if (status < 0)
-		return -EIO;
-
-	signal = sp8870_readreg (i2c, 0x0303);
-	if (signal < 0)
-		return -EIO;
-
-	if (signal > 0x0F)
-		*fe_status |= FE_HAS_SIGNAL;
-	if (status & 0x08)
-		*fe_status |= FE_HAS_SYNC;
-	if (status & 0x04)
-		*fe_status |= FE_HAS_LOCK | FE_HAS_CARRIER | FE_HAS_VITERBI;
-
-	return 0;
-}
-
-
-static int sp8870_read_ber (struct dvb_i2c_bus *i2c, u32 * ber)
-{
-	int ret;
-	u32 tmp;
-
-	*ber = 0;
-
-	ret = sp8870_readreg(i2c, 0xC08);
-	if (ret < 0)
-		return -EIO;
-
-	tmp = ret & 0x3F;
-
-	ret = sp8870_readreg(i2c, 0xC07);
-	if (ret < 0)
-		return -EIO;
-
-	 tmp = ret << 6;
-
-	if (tmp >= 0x3FFF0)
-		tmp = ~0;
-
-	*ber = tmp;
-
-	return 0;
-	}
-
-
-static int sp8870_read_signal_strength (struct dvb_i2c_bus *i2c,  u16 * signal)
-	{
-	int ret;
-	u16 tmp;
-
-	*signal = 0;
-
-	ret = sp8870_readreg (i2c, 0x306);
-	if (ret < 0)
-		return -EIO;
-
-	tmp = ret << 8;
-
-	ret = sp8870_readreg (i2c, 0x303);
-	if (ret < 0)
-		return -EIO;
-
-	tmp |= ret;
-
-	if (tmp)
-		*signal = 0xFFFF - tmp;
-
-	return 0;
-	}
-
-
-static int sp8870_read_snr(struct dvb_i2c_bus *i2c, u32* snr)
-	{
-                *snr=0;  
-		return -EOPNOTSUPP;
-	}
-
-
-static int sp8870_read_uncorrected_blocks (struct dvb_i2c_bus *i2c, u32* ublocks)
-	{
-		int ret;
-
-		*ublocks=0;  
-
-		ret = sp8870_readreg(i2c, 0xC0C);
-		if (ret < 0)
-			return -EIO;
-
-		if (ret == 0xFFFF)
-			ret = ~0;
-
-		*ublocks = ret;
-
-		return 0;
-	}
-
-
-static int sp8870_read_data_valid_signal(struct dvb_i2c_bus *i2c)
-{
-	return (sp8870_readreg(i2c, 0x0D02) > 0);
-}
-
-
-static
-int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
-{
-	int known_parameters = 1;
-
-	*reg0xc05 = 0x000;
-
-	switch (p->u.ofdm.constellation) {
-	case QPSK:
-		break;
-	case QAM_16:
-		*reg0xc05 |= (1 << 10);
-		break;
-	case QAM_64:
-		*reg0xc05 |= (2 << 10);
-		break;
-	case QAM_AUTO:
-		known_parameters = 0;
-		break;
-	default:
-		return -EINVAL;
-	};
-
-	switch (p->u.ofdm.hierarchy_information) {
-	case HIERARCHY_NONE:
-		break;
-	case HIERARCHY_1:
-		*reg0xc05 |= (1 << 7);
-		break;
-	case HIERARCHY_2:
-		*reg0xc05 |= (2 << 7);
-		break;
-	case HIERARCHY_4:
-		*reg0xc05 |= (3 << 7);
-		break;
-	case HIERARCHY_AUTO:
-		known_parameters = 0;
-		break;
-	default:
-		return -EINVAL;
-	};
-
-	switch (p->u.ofdm.code_rate_HP) {
-	case FEC_1_2:
-		break;
-	case FEC_2_3:
-		*reg0xc05 |= (1 << 3);
-		break;
-	case FEC_3_4:
-		*reg0xc05 |= (2 << 3);
-		break;
-	case FEC_5_6:
-		*reg0xc05 |= (3 << 3);
-		break;
-	case FEC_7_8:
-		*reg0xc05 |= (4 << 3);
-		break;
-	case FEC_AUTO:
-		known_parameters = 0;
-		break;
-	default:
-		return -EINVAL;
-	};
-
-	if (known_parameters)
-		*reg0xc05 |= (2 << 1);	/* use specified parameters */
-	else
-		*reg0xc05 |= (1 << 1);	/* enable autoprobing */
-
-	return 0;
-}
-
-
-static int sp8870_set_frontend_parameters (struct dvb_i2c_bus *i2c,
-				      struct dvb_frontend_parameters *p)
-        {
-	int  err;
-	u16 reg0xc05;
-
-	if ((err = configure_reg0xc05(p, &reg0xc05)))
-		return err;
-
-		// system controller stop 
-	sp8870_microcontroller_stop(i2c);
-
-	// set tuner parameters
-		sp5659_set_tv_freq (i2c, p->frequency);
-
-		// sample rate correction bit [23..17]
-		sp8870_writereg(i2c,0x0319,0x000A);
-		
-		// sample rate correction bit [16..0]
-		sp8870_writereg(i2c,0x031A,0x0AAB);
-
-		// integer carrier offset 
-		sp8870_writereg(i2c,0x0309,0x0400);
-
-		// fractional carrier offset
-		sp8870_writereg(i2c,0x030A,0x0000);
-
-		// filter for 6/7/8 Mhz channel
-		if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
-			sp8870_writereg(i2c,0x0311,0x0002);
-		else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
-			sp8870_writereg(i2c,0x0311,0x0001);
-		else
-			sp8870_writereg(i2c,0x0311,0x0000);
-
-		// scan order: 2k first = 0x0000, 8k first = 0x0001 
-		if (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_2K)
-			sp8870_writereg(i2c,0x0338,0x0000);
-		else
-			sp8870_writereg(i2c,0x0338,0x0001);
-
-	sp8870_writereg(i2c, 0xc05, reg0xc05);
-
-	// read status reg in order to clear pending irqs
-	sp8870_readreg(i2c, 0x200);
-
-		// system controller start
-	sp8870_microcontroller_start(i2c);
-
-	return 0;
-        }
-
-
-// number of trials to recover from lockup
-#define MAXTRIALS 5
-// maximum checks for data valid signal
-#define MAXCHECKS 100
-
-// only for debugging: counter for detected lockups
-static int lockups = 0;
-// only for debugging: counter for channel switches
-static int switches = 0;
-
-static int sp8870_set_frontend (struct dvb_i2c_bus *i2c, struct dvb_frontend_parameters *p)
-	{
-	/*
-	    The firmware of the sp8870 sometimes locks up after setting frontend parameters.
-	    We try to detect this by checking the data valid signal.
-	    If it is not set after MAXCHECKS we try to recover the lockup by setting
-	    the frontend parameters again.
-	*/
-
-	int err = 0;
-	int valid = 0;
-	int trials = 0;
-	int check_count = 0;
-
-	dprintk("%s: frequency = %i\n", __FUNCTION__, p->frequency);
-
-	for (trials = 1; trials <= MAXTRIALS; trials++) {
-
-		if ((err = sp8870_set_frontend_parameters(i2c, p)))
-			return err;
-
-		for (check_count = 0; check_count < MAXCHECKS; check_count++) {
-//			valid = ((sp8870_readreg(i2c, 0x0200) & 4) == 0);
-			valid = sp8870_read_data_valid_signal(i2c);
-			if (valid) {
-				dprintk("%s: delay = %i usec\n",
-					__FUNCTION__, check_count * 10);
-				break;
-			}
-			udelay(10);
-		}
-		if (valid)
-		break;
-	}
-
-	if (!valid) {
-		printk("%s: firmware crash!!!!!!\n", __FUNCTION__);
-		return -EIO;
-	}
-
-	if (debug) {
-		if (valid) {
-			if (trials > 1) {
-				printk("%s: firmware lockup!!!\n", __FUNCTION__);
-				printk("%s: recovered after %i trial(s))\n",  __FUNCTION__, trials - 1);
-				lockups++;
-			}
-		}
-		switches++;
-		printk("%s: switches = %i lockups = %i\n", __FUNCTION__, switches, lockups);
-	}
-
-	return 0;
-}
-
-
-static int sp8870_sleep(struct dvb_i2c_bus *i2c)
-{
-	// tristate TS output and disable interface pins
-	return sp8870_writereg(i2c, 0xC18, 0x000);
-}
-
-
-static int sp8870_wake_up(struct dvb_i2c_bus *i2c)
-{
-	// enable TS output and interface pins
-	return sp8870_writereg(i2c, 0xC18, 0x00D);
-}
-
-
-static int tdlb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-	struct dvb_i2c_bus *i2c = fe->i2c;
-
-        switch (cmd) {
-        case FE_GET_INFO:
-		memcpy (arg, &tdlb7_info, sizeof(struct dvb_frontend_info));
-		break;
-
-        case FE_READ_STATUS:
-		return sp8870_read_status(i2c, (fe_status_t *) arg);
-
-        case FE_READ_BER:
-		return sp8870_read_ber(i2c, (u32 *) arg);
-
-        case FE_READ_SIGNAL_STRENGTH:
-		return sp8870_read_signal_strength(i2c, (u16 *) arg);
-
-        case FE_READ_SNR:				// not supported by hardware?
-		return sp8870_read_snr(i2c, (u32 *) arg);
-
-	case FE_READ_UNCORRECTED_BLOCKS:
-		return sp8870_read_uncorrected_blocks(i2c, (u32 *) arg);
-
-        case FE_SET_FRONTEND:
-		return sp8870_set_frontend(i2c, (struct dvb_frontend_parameters*) arg);
-
-	case FE_GET_FRONTEND:			 // FIXME: read known values back from Hardware...
-		return -EOPNOTSUPP;
-
-        case FE_SLEEP:
-		return sp8870_sleep(i2c);
-
-        case FE_INIT:
-		sp8870_wake_up(i2c);
-		if (fe->data == NULL) {		// first time initialisation...
-			fe->data = (void*) ~0;
-			sp8870_init (i2c);
-		}
-		break;
-
-	case FE_GET_TUNE_SETTINGS:
-	{
-	        struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
-	        fesettings->min_delay_ms = 150;
-	        fesettings->step_size = 166667;
-	        fesettings->max_drift = 166667*2;
-	        return 0;
-	}	    
-	    
-	default:
-		return -EOPNOTSUPP;
-        };
-
-        return 0;
-}
-
-
-static int tdlb7_attach (struct dvb_i2c_bus *i2c, void **data)
-{
-        u8 b0 [] = { 0x02 , 0x00 };
-        u8 b1 [] = { 0, 0 };
-        struct i2c_msg msg [] = { { .addr = 0x71, .flags = 0, .buf = b0, .len = 2 },
-                                  { .addr = 0x71, .flags = I2C_M_RD, .buf = b1, .len = 2 } };
-
-	dprintk ("%s\n", __FUNCTION__);
-
-        if (i2c->xfer (i2c, msg, 2) != 2)
-                return -ENODEV;
-
-	sp8870_firmware_upload(i2c);
-
-	return dvb_register_frontend (tdlb7_ioctl, i2c, NULL, &tdlb7_info);
-}
-
-
-static void tdlb7_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	dvb_unregister_frontend (tdlb7_ioctl, i2c);
-}
-
-
-static int __init init_tdlb7 (void)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	return dvb_register_i2c_device (THIS_MODULE, tdlb7_attach, tdlb7_detach);
-}
-
-
-static void __exit exit_tdlb7 (void)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	dvb_unregister_i2c_device (tdlb7_attach);
-}
-
-
-module_init(init_tdlb7);
-module_exit(exit_tdlb7);
-
-
-MODULE_PARM(debug,"i");
-MODULE_PARM_DESC(debug, "enable verbose debug messages");
-
-MODULE_PARM(firmware_file,"s");
-MODULE_PARM_DESC(firmware_file, "where to find the firmware file");
-
-MODULE_DESCRIPTION("TDLB7 DVB-T Frontend");
-MODULE_AUTHOR("Juergen Peitz");
-MODULE_LICENSE("GPL");
-
-
diff -Nru a/drivers/media/dvb/frontends/alps_tdmb7.c b/drivers/media/dvb/frontends/alps_tdmb7.c
--- a/drivers/media/dvb/frontends/alps_tdmb7.c	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,458 +0,0 @@
-/* 
-    Alps TDMB7 DVB OFDM frontend driver
-
-    Copyright (C) 2001-2002 Convergence Integrated Media GmbH
-	Holger Waechtler <holger@convergence.de>
-
-    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.
-
-*/    
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "dvb_functions.h"
-
-
-static int debug = 0;
-#define dprintk	if (debug) printk
-
-
-static struct dvb_frontend_info tdmb7_info = {
-	.name 			= "Alps TDMB7",
-	.type 			= FE_OFDM,
-	.frequency_min 		= 470000000,
-	.frequency_max 		= 860000000,
-	.frequency_stepsize 	= 166667,
-#if 0
-    	.frequency_tolerance 	= ???,
-	.symbol_rate_min 	= ???,
-	.symbol_rate_max 	= ???,
-	.symbol_rate_tolerance	= 500,  /* ppm */
-	.notifier_delay 	= 0,
-#endif
-	.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-	      FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-	      FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | 
-              FE_CAN_RECOVER
-};
-
-
-static u8 init_tab [] = {
-	0x04, 0x10,
-	0x05, 0x09,
-	0x06, 0x00,
-	0x08, 0x04,
-	0x09, 0x00,
-	0x0a, 0x01,
-	0x15, 0x40,
-	0x16, 0x10,
-	0x17, 0x87,
-	0x18, 0x17,
-	0x1a, 0x10,
-	0x25, 0x04,
-	0x2e, 0x00,
-	0x39, 0x00,
-	0x3a, 0x04,
-	0x45, 0x08,
-	0x46, 0x02,
-	0x47, 0x05,
-};
-
-
-static int cx22700_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
-{
-	int ret;
-	u8 buf [] = { reg, data };
-	struct i2c_msg msg = { .addr = 0x43, .flags = 0, .buf = buf, .len = 2 };
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	ret = i2c->xfer (i2c, &msg, 1);
-
-	if (ret != 1) 
-		printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
-			__FUNCTION__, reg, data, ret);
-
-	return (ret != 1) ? -1 : 0;
-}
-
-
-static u8 cx22700_readreg (struct dvb_i2c_bus *i2c, u8 reg)
-{
-	int ret;
-	u8 b0 [] = { reg };
-	u8 b1 [] = { 0 };
-	struct i2c_msg msg [] = { { .addr = 0x43, .flags = 0, .buf = b0, .len = 1 },
-			   { .addr = 0x43, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-        
-	dprintk ("%s\n", __FUNCTION__);
-
-	ret = i2c->xfer (i2c, msg, 2);
-        
-	if (ret != 2) 
-		printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
-
-	return b1[0];
-}
-
-
-static int pll_write (struct dvb_i2c_bus *i2c, u8 data [4])
-{
-	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = 4 };
-	int ret;
-
-	cx22700_writereg (i2c, 0x0a, 0x00);  /* open i2c bus switch */
-	ret = i2c->xfer (i2c, &msg, 1);
-	cx22700_writereg (i2c, 0x0a, 0x01);  /* close i2c bus switch */
-
-	if (ret != 1)
-		printk("%s: i/o error (addr == 0x%02x, ret == %i)\n", __FUNCTION__, msg.addr, ret);
-
-	return (ret != 1) ? -1 : 0;
-}
-
-
-/**
- *   set up the downconverter frequency divisor for a 
- *   reference clock comparision frequency of 125 kHz.
- */
-static int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
-{
-	u32 div = (freq + 36166667) / 166667;
-#if 1 //ALPS_SETTINGS
-	u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, ((div >> 10) & 0x60) | 0x85,
-		       freq < 592000000 ? 0x40 : 0x80 };
-#else
-	u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, ((div >> 10) & 0x60) | 0x85,
-		       freq < 470000000 ? 0x42 : freq < 862000000 ? 0x41 : 0x81 };
-#endif
-
-	dprintk ("%s: freq == %i, div == %i\n", __FUNCTION__, (int) freq, (int) div);
-
-	return pll_write (i2c, buf);
-}
-
-
-static int cx22700_init (struct dvb_i2c_bus *i2c)
-{
-	int i;
-
-	dprintk("cx22700_init: init chip\n");
-
-	cx22700_writereg (i2c, 0x00, 0x02);   /*  soft reset */
-	cx22700_writereg (i2c, 0x00, 0x00);
-
-	dvb_delay(10);
-	
-	for (i=0; i<sizeof(init_tab); i+=2)
-		cx22700_writereg (i2c, init_tab[i], init_tab[i+1]);
-
-	cx22700_writereg (i2c, 0x00, 0x01);
-	
-	return 0;
-}
-
-
-static int cx22700_set_inversion (struct dvb_i2c_bus *i2c, int inversion)
-{
-	u8 val;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	switch (inversion) {
-	case INVERSION_AUTO:
-		return -EOPNOTSUPP;
-	case INVERSION_ON:
-		val = cx22700_readreg (i2c, 0x09);
-		return cx22700_writereg (i2c, 0x09, val | 0x01);
-	case INVERSION_OFF:
-		val = cx22700_readreg (i2c, 0x09);
-		return cx22700_writereg (i2c, 0x09, val & 0xfe);
-	default:
-		return -EINVAL;
-	}
-}
-
-
-static int cx22700_set_tps (struct dvb_i2c_bus *i2c, struct dvb_ofdm_parameters *p)
-{
-	static const u8 qam_tab [4] = { 0, 1, 0, 2 };
-	static const u8 fec_tab [6] = { 0, 1, 2, 0, 3, 4 };
-	u8 val;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	if (p->code_rate_HP < FEC_1_2 || p->code_rate_HP > FEC_7_8)
-		return -EINVAL;
-
-	if (p->code_rate_LP < FEC_1_2 || p->code_rate_LP > FEC_7_8)
-
-	if (p->code_rate_HP == FEC_4_5 || p->code_rate_LP == FEC_4_5)
-		return -EINVAL;
-
-	if (p->guard_interval < GUARD_INTERVAL_1_32 ||
-	    p->guard_interval > GUARD_INTERVAL_1_4)
-		return -EINVAL;
-
-	if (p->transmission_mode != TRANSMISSION_MODE_2K &&
-	    p->transmission_mode != TRANSMISSION_MODE_8K)
-		return -EINVAL;
-
-	if (p->constellation != QPSK &&
-	    p->constellation != QAM_16 &&
-	    p->constellation != QAM_64)
-		return -EINVAL;
-
-	if (p->hierarchy_information < HIERARCHY_NONE ||
-	    p->hierarchy_information > HIERARCHY_4)
-		return -EINVAL;
-
-	if (p->bandwidth < BANDWIDTH_8_MHZ && p->bandwidth > BANDWIDTH_6_MHZ)
-		return -EINVAL;
-
-	if (p->bandwidth == BANDWIDTH_7_MHZ)
-		cx22700_writereg (i2c, 0x09, cx22700_readreg (i2c, 0x09 | 0x10));
-	else
-		cx22700_writereg (i2c, 0x09, cx22700_readreg (i2c, 0x09 & ~0x10));
-
-	val = qam_tab[p->constellation - QPSK];
-	val |= p->hierarchy_information - HIERARCHY_NONE;
-
-	cx22700_writereg (i2c, 0x04, val);
-
-	val = fec_tab[p->code_rate_HP - FEC_1_2] << 3;
-	val |= fec_tab[p->code_rate_LP - FEC_1_2];
-
-	cx22700_writereg (i2c, 0x05, val);
-
-	val = (p->guard_interval - GUARD_INTERVAL_1_32) << 2;
-	val |= p->transmission_mode - TRANSMISSION_MODE_2K;
-
-	cx22700_writereg (i2c, 0x06, val);
-
-	cx22700_writereg (i2c, 0x08, 0x04 | 0x02);  /* use user tps parameters */
-	cx22700_writereg (i2c, 0x08, 0x04);         /* restart aquisition */
-
-	return 0;
-}
-
-
-static int cx22700_get_tps (struct dvb_i2c_bus *i2c, struct dvb_ofdm_parameters *p)
-{
-	static const fe_modulation_t qam_tab [3] = { QPSK, QAM_16, QAM_64 };
-	static const fe_code_rate_t fec_tab [5] = { FEC_1_2, FEC_2_3, FEC_3_4,
-						    FEC_5_6, FEC_7_8 };
-	u8 val;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	if (!(cx22700_readreg(i2c, 0x07) & 0x20))  /*  tps valid? */
-		return -EAGAIN;
-
-	val = cx22700_readreg (i2c, 0x01);
-
-	if ((val & 0x7) > 4)
-		p->hierarchy_information = HIERARCHY_AUTO;
-	else
-		p->hierarchy_information = HIERARCHY_NONE + (val & 0x7);
-
-	if (((val >> 3) & 0x3) > 2)
-		p->constellation = QAM_AUTO;
-	else
-		p->constellation = qam_tab[(val >> 3) & 0x3];
-
-
-	val = cx22700_readreg (i2c, 0x02);
-
-	if (((val >> 3) & 0x07) > 4)
-		p->code_rate_HP = FEC_AUTO;
-	else
-		p->code_rate_HP = fec_tab[(val >> 3) & 0x07];
-
-	if ((val & 0x07) > 4)
-		p->code_rate_LP = FEC_AUTO;
-	else
-		p->code_rate_LP = fec_tab[val & 0x07];
-
-
-	val = cx22700_readreg (i2c, 0x03);
-
-	p->guard_interval = GUARD_INTERVAL_1_32 + ((val >> 6) & 0x3);
-	p->transmission_mode = TRANSMISSION_MODE_2K + ((val >> 5) & 0x1);
-
-	return 0;
-}
-
-
-static int tdmb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-	struct dvb_i2c_bus *i2c = fe->i2c;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	switch (cmd) {
-	case FE_GET_INFO:
-		memcpy (arg, &tdmb7_info, sizeof(struct dvb_frontend_info));
-		break;
-
-	case FE_READ_STATUS:
-	{
-		fe_status_t *status = (fe_status_t *) arg;
-		u16 rs_ber = (cx22700_readreg (i2c, 0x0d) << 9)
-			   | (cx22700_readreg (i2c, 0x0e) << 1);
-		u8 sync = cx22700_readreg (i2c, 0x07);
-
-		*status = 0;
-
-		if (rs_ber < 0xff00)
-			*status |= FE_HAS_SIGNAL;
-
-		if (sync & 0x20)
-			*status |= FE_HAS_CARRIER;
-
-		if (sync & 0x10)
-			*status |= FE_HAS_VITERBI;
-
-		if (sync & 0x10)
-			*status |= FE_HAS_SYNC;
-
-		if (*status == 0x0f)
-			*status |= FE_HAS_LOCK;
-
-		break;
-	}
-
-        case FE_READ_BER:
-		*((u32*) arg) = cx22700_readreg (i2c, 0x0c) & 0x7f;
-		cx22700_writereg (i2c, 0x0c, 0x00);
-		break;
-
-	case FE_READ_SIGNAL_STRENGTH:
-	{
-		u16 rs_ber = (cx22700_readreg (i2c, 0x0d) << 9)
-			   | (cx22700_readreg (i2c, 0x0e) << 1);
-		*((u16*) arg) = ~rs_ber;
-		break;
-	}
-        case FE_READ_SNR:
-	{
-		u16 rs_ber = (cx22700_readreg (i2c, 0x0d) << 9)
-			   | (cx22700_readreg (i2c, 0x0e) << 1);
-		*((u16*) arg) = ~rs_ber;
-		break;
-	}
-	case FE_READ_UNCORRECTED_BLOCKS: 
-		*((u32*) arg) = cx22700_readreg (i2c, 0x0f);
-		cx22700_writereg (i2c, 0x0f, 0x00);
-		break;
-
-        case FE_SET_FRONTEND:
-        {
-		struct dvb_frontend_parameters *p = arg;
-
-		cx22700_writereg (i2c, 0x00, 0x02); /* XXX CHECKME: soft reset*/
-		cx22700_writereg (i2c, 0x00, 0x00);
-
-		pll_set_tv_freq (i2c, p->frequency);
-		cx22700_set_inversion (i2c, p->inversion);
-                cx22700_set_tps (i2c, &p->u.ofdm);
-		cx22700_writereg (i2c, 0x37, 0x01);  /* PAL loop filter off */
-		cx22700_writereg (i2c, 0x00, 0x01);  /* restart acquire */
-                break;
-        }
-
-        case FE_GET_FRONTEND:
-        {
-		struct dvb_frontend_parameters *p = arg;
-		u8 reg09 = cx22700_readreg (i2c, 0x09);
-		
-		p->inversion = reg09 & 0x1 ? INVERSION_ON : INVERSION_OFF;
-		return cx22700_get_tps (i2c, &p->u.ofdm);
-        }
-
-        case FE_INIT:
-		return cx22700_init (i2c);
-
-	case FE_GET_TUNE_SETTINGS:
-	{
-	        struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
-	        fesettings->min_delay_ms = 150;
-	        fesettings->step_size = 166667;
-	        fesettings->max_drift = 166667*2;
-	        return 0;
-	}	    
-
-	default:
-		return -EOPNOTSUPP;
-	};
-
-	return 0;
-}
-
-
-
-static int tdmb7_attach (struct dvb_i2c_bus *i2c, void **data)
-{
-        u8 b0 [] = { 0x7 };
-        u8 b1 [] = { 0 };
-        struct i2c_msg msg [] = { { .addr = 0x43, .flags = 0, .buf = b0, .len = 1 },
-                                  { .addr = 0x43, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
-	dprintk ("%s\n", __FUNCTION__);
-
-        if (i2c->xfer (i2c, msg, 2) != 2)
-                return -ENODEV;
-
-	return dvb_register_frontend (tdmb7_ioctl, i2c, NULL, &tdmb7_info);
-}
-
-
-static void tdmb7_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	dvb_unregister_frontend (tdmb7_ioctl, i2c);
-}
-
-
-static int __init init_tdmb7 (void)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	return dvb_register_i2c_device (THIS_MODULE, tdmb7_attach, tdmb7_detach);
-}
-
-
-static void __exit exit_tdmb7 (void)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	dvb_unregister_i2c_device (tdmb7_attach);
-}
-
-module_init (init_tdmb7);
-module_exit (exit_tdmb7);
-
-MODULE_PARM(debug,"i");
-MODULE_PARM_DESC(debug, "enable verbose debug messages");
-MODULE_DESCRIPTION("TDMB7 DVB Frontend driver");
-MODULE_AUTHOR("Holger Waechtler");
-MODULE_LICENSE("GPL");
-
diff -Nru a/drivers/media/dvb/frontends/at76c651.c b/drivers/media/dvb/frontends/at76c651.c
--- a/drivers/media/dvb/frontends/at76c651.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/dvb/frontends/at76c651.c	2004-12-24 13:37:18 -08:00
@@ -1,10 +1,10 @@
 /*
  * at76c651.c
  * 
- * Atmel DVB-C Frontend Driver (at76c651/dat7021)
+ * Atmel DVB-C Frontend Driver (at76c651/tua6010xs)
  *
  * Copyright (C) 2001 fnbrd <fnbrd@gmx.de>
- *             & 2002 Andreas Oberritter <obi@linuxtv.org>
+ *             & 2002-2004 Andreas Oberritter <obi@linuxtv.org>
  *             & 2003 Wolfram Joost <dbox2@frokaschwei.de>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -21,59 +21,46 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
+ * AT76C651
+ * http://www.nalanda.nitc.ac.in/industry/datasheets/atmel/acrobat/doc1293.pdf
+ * http://www.atmel.com/atmel/acrobat/doc1320.pdf
  */
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/slab.h>
+#include <linux/bitops.h>
+#include "dvb_frontend.h"
+#include "at76c651.h"
 
-#if defined(__powerpc__)
-#include <asm/bitops.h>
-#endif
 
-#include "dvb_frontend.h"
-#include "dvb_i2c.h"
-#include "dvb_functions.h"
+struct at76c651_state {
 
-static int debug = 0;
-static u8 at76c651_qam;
-static u8 at76c651_revision;
-
-#define dprintk	if (debug) printk
-
-/*
- * DAT7021
- * -------
- * Input Frequency Range (RF): 48.25 MHz to 863.25 MHz
- * Band Width: 8 MHz
- * Level Input (Range for Digital Signals): -61 dBm to -41 dBm
- * Output Frequency (IF): 36 MHz
- *
- * (see http://www.atmel.com/atmel/acrobat/doc1320.pdf)
- */
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	const struct at76c651_config* config;
+
+	struct dvb_frontend frontend;
 
-static struct dvb_frontend_info at76c651_info = {
+	/* revision of the chip */
+	u8 revision;
 
-	.name = "Atmel AT76C651(B) with DAT7021",
-	.type = FE_QAM,
-	.frequency_min = 48250000,
-	.frequency_max = 863250000,
-	.frequency_stepsize = 62500,
-	/*.frequency_tolerance = */	/* FIXME: 12% of SR */
-	.symbol_rate_min = 0,		/* FIXME */
-	.symbol_rate_max = 9360000,	/* FIXME */
-	.symbol_rate_tolerance = 4000,
-	.notifier_delay = 0,
-	.caps = FE_CAN_INVERSION_AUTO |
-	    FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-	    FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
-	    FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
-	    FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 | FE_CAN_QAM_128 |
-	    FE_CAN_MUTE_TS | FE_CAN_QAM_256 | FE_CAN_RECOVER
+	/* last QAM value set */
+	u8 qam;
 };
 
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "at76c651: " args); \
+	} while (0)
+
+
 #if ! defined(__powerpc__)
 static __inline__ int __ilog2(unsigned long x)
 {
@@ -89,229 +76,150 @@
 }
 #endif
 
-static int at76c651_writereg(struct dvb_i2c_bus *i2c, u8 reg, u8 data)
+static int at76c651_writereg(struct at76c651_state* state, u8 reg, u8 data)
 {
-
 	int ret;
 	u8 buf[] = { reg, data };
-	struct i2c_msg msg = { .addr = 0x1a >> 1, .flags = 0, .buf = buf, .len = 2 };
+	struct i2c_msg msg =
+		{ .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
 
-	ret = i2c->xfer(i2c, &msg, 1);
+	ret = i2c_transfer(state->i2c, &msg, 1);
 
 	if (ret != 1)
 		dprintk("%s: writereg error "
 			"(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
 			__FUNCTION__, reg, data, ret);
 
-	dvb_delay(10);
+	msleep(10);
 
 	return (ret != 1) ? -EREMOTEIO : 0;
-
 }
 
-static u8 at76c651_readreg(struct dvb_i2c_bus *i2c, u8 reg)
+static u8 at76c651_readreg(struct at76c651_state* state, u8 reg)
 {
-
 	int ret;
-	u8 b0[] = { reg };
-	u8 b1[] = { 0 };
-	struct i2c_msg msg[] = { {.addr =  0x1a >> 1, .flags =  0, .buf =  b0, .len = 1},
-			  {.addr =  0x1a >> 1, .flags =  I2C_M_RD, .buf =  b1, .len = 1} };
+	u8 val;
+	struct i2c_msg msg[] = {
+		{ .addr = state->config->demod_address, .flags = 0, .buf = &reg, .len = 1 },
+		{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = &val, .len = 1 }
+	};
 
-	ret = i2c->xfer(i2c, msg, 2);
+	ret = i2c_transfer(state->i2c, msg, 2);
 
 	if (ret != 2)
 		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
 
-	return b1[0];
-
+	return val;
 }
 
-static int at76c651_reset(struct dvb_i2c_bus *i2c)
+static int at76c651_reset(struct at76c651_state* state)
 {
-
-	return at76c651_writereg(i2c, 0x07, 0x01);
-
+	return at76c651_writereg(state, 0x07, 0x01);
 }
 
-static int at76c651_disable_interrupts(struct dvb_i2c_bus *i2c)
+static void at76c651_disable_interrupts(struct at76c651_state* state)
 {
-
-	return at76c651_writereg(i2c, 0x0b, 0x00);
-
+	at76c651_writereg(state, 0x0b, 0x00);
 }
 
-static int at76c651_set_auto_config(struct dvb_i2c_bus *i2c)
+static int at76c651_set_auto_config(struct at76c651_state *state)
 {
-
 	/*
 	 * Autoconfig
 	 */
 
-	at76c651_writereg(i2c, 0x06, 0x01);
+	at76c651_writereg(state, 0x06, 0x01);
 
 	/*
 	 * Performance optimizations, should be done after autoconfig
 	 */
 
-	at76c651_writereg(i2c, 0x10, 0x06);
-	at76c651_writereg(i2c, 0x11, ((at76c651_qam == 5) || (at76c651_qam == 7)) ? 0x12 : 0x10);
-	at76c651_writereg(i2c, 0x15, 0x28);
-	at76c651_writereg(i2c, 0x20, 0x09);
-	at76c651_writereg(i2c, 0x24, ((at76c651_qam == 5) || (at76c651_qam == 7)) ? 0xC0 : 0x90);
-	at76c651_writereg(i2c, 0x30, 0x90);
-	if (at76c651_qam == 5)
-		at76c651_writereg(i2c, 0x35, 0x2A);
+	at76c651_writereg(state, 0x10, 0x06);
+	at76c651_writereg(state, 0x11, ((state->qam == 5) || (state->qam == 7)) ? 0x12 : 0x10);
+	at76c651_writereg(state, 0x15, 0x28);
+	at76c651_writereg(state, 0x20, 0x09);
+	at76c651_writereg(state, 0x24, ((state->qam == 5) || (state->qam == 7)) ? 0xC0 : 0x90);
+	at76c651_writereg(state, 0x30, 0x90);
+	if (state->qam == 5)
+		at76c651_writereg(state, 0x35, 0x2A);
 
 	/*
 	 * Initialize A/D-converter
 	 */
 
-	if (at76c651_revision == 0x11) {
-		at76c651_writereg(i2c, 0x2E, 0x38);
-		at76c651_writereg(i2c, 0x2F, 0x13);
+	if (state->revision == 0x11) {
+		at76c651_writereg(state, 0x2E, 0x38);
+		at76c651_writereg(state, 0x2F, 0x13);
 }
 
-	at76c651_disable_interrupts(i2c);
+	at76c651_disable_interrupts(state);
 
 	/*
 	 * Restart operation
 	 */
 
-	at76c651_reset(i2c);
-
-	return 0;
-
-}
-
-static int at76c651_set_bbfreq(struct dvb_i2c_bus *i2c)
-{
-
-	at76c651_writereg(i2c, 0x04, 0x3f);
-	at76c651_writereg(i2c, 0x05, 0xee);
+	at76c651_reset(state);
 
 	return 0;
-
 }
 
-static int at76c651_switch_tuner_i2c(struct dvb_i2c_bus *i2c, u8 enable)
+static void at76c651_set_bbfreq(struct at76c651_state* state)
 {
-
-	if (enable)
-		return at76c651_writereg(i2c, 0x0c, 0xc2 | 0x01);
-	else
-		return at76c651_writereg(i2c, 0x0c, 0xc2);
-
+	at76c651_writereg(state, 0x04, 0x3f);
+	at76c651_writereg(state, 0x05, 0xee);
 }
 
-static int dat7021_write(struct dvb_i2c_bus *i2c, u32 tw)
+static int at76c651_set_symbol_rate(struct at76c651_state* state, u32 symbol_rate)
 {
-
-	int ret;
-	struct i2c_msg msg =
-	    { .addr = 0xc2 >> 1, .flags = 0, .buf = (u8 *) & tw, .len = sizeof (tw) };
-
-#ifdef __LITTLE_ENDIAN
-	tw = __cpu_to_be32(tw);
-#endif
-
-	at76c651_switch_tuner_i2c(i2c, 1);
-
-	ret = i2c->xfer(i2c, &msg, 1);
-
-	at76c651_switch_tuner_i2c(i2c, 0);
-
-	if (ret != 4)
-		return -EFAULT;
-
-	at76c651_reset(i2c);
-
-	return 0;
-
-}
-
-static int dat7021_set_tv_freq(struct dvb_i2c_bus *i2c, u32 freq)
-{
-
-	u32 dw;
-
-	freq /= 1000;
-
-	if ((freq < 48250) || (freq > 863250))
-		return -EINVAL;
-
-	/*
-	 * formula: dw=0x17e28e06+(freq-346000UL)/8000UL*0x800000
-	 *      or: dw=0x4E28E06+(freq-42000) / 125 * 0x20000
-	 */
-
-	dw = (freq - 42000) * 4096;
-	dw = dw / 125;
-	dw = dw * 32;
-
-	if (freq > 394000)
-		dw += 0x4E28E85;
-	else
-		dw += 0x4E28E06;
-
-	return dat7021_write(i2c, dw);
-
-}
-
-static int at76c651_set_symbolrate(struct dvb_i2c_bus *i2c, u32 symbolrate)
-{
-
 	u8 exponent;
 	u32 mantissa;
 
-	if (symbolrate > 9360000)
+	if (symbol_rate > 9360000)
 		return -EINVAL;
 
 	/*
 	 * FREF = 57800 kHz
-	 * exponent = 10 + floor ( log2 ( symbolrate / FREF ) )
-	 * mantissa = ( symbolrate / FREF) * ( 1 << ( 30 - exponent ) )
+	 * exponent = 10 + floor (log2(symbol_rate / FREF))
+	 * mantissa = (symbol_rate / FREF) * (1 << (30 - exponent))
 	 */
 
-	exponent = __ilog2((symbolrate << 4) / 903125);
-	mantissa = ((symbolrate / 3125) * (1 << (24 - exponent))) / 289;
+	exponent = __ilog2((symbol_rate << 4) / 903125);
+	mantissa = ((symbol_rate / 3125) * (1 << (24 - exponent))) / 289;
 
-	at76c651_writereg(i2c, 0x00, mantissa >> 13);
-	at76c651_writereg(i2c, 0x01, mantissa >> 5);
-	at76c651_writereg(i2c, 0x02, (mantissa << 3) | exponent);
+	at76c651_writereg(state, 0x00, mantissa >> 13);
+	at76c651_writereg(state, 0x01, mantissa >> 5);
+	at76c651_writereg(state, 0x02, (mantissa << 3) | exponent);
 
 	return 0;
-
 }
 
-static int at76c651_set_qam(struct dvb_i2c_bus *i2c, fe_modulation_t qam)
+static int at76c651_set_qam(struct at76c651_state *state, fe_modulation_t qam)
 {
-
 	switch (qam) {
 	case QPSK:
-		at76c651_qam = 0x02;
+		state->qam = 0x02;
 		break;
 	case QAM_16:
-		at76c651_qam = 0x04;
+		state->qam = 0x04;
 		break;
 	case QAM_32:
-		at76c651_qam = 0x05;
+		state->qam = 0x05;
 		break;
 	case QAM_64:
-		at76c651_qam = 0x06;
+		state->qam = 0x06;
 		break;
 	case QAM_128:
-		at76c651_qam = 0x07;
+		state->qam = 0x07;
 		break;
 	case QAM_256:
-		at76c651_qam = 0x08;
+		state->qam = 0x08;
 		break;
 #if 0
 	case QAM_512:
-		at76c651_qam = 0x09;
+		state->qam = 0x09;
 		break;
 	case QAM_1024:
-		at76c651_qam = 0x0A;
+		state->qam = 0x0A;
 		break;
 #endif
 	default:
@@ -319,15 +227,12 @@
 
 	}
 
-	return at76c651_writereg(i2c, 0x03, at76c651_qam);
-
+	return at76c651_writereg(state, 0x03, state->qam);
 }
 
-static int at76c651_set_inversion(struct dvb_i2c_bus *i2c,
-		       fe_spectral_inversion_t inversion)
+static int at76c651_set_inversion(struct at76c651_state* state, fe_spectral_inversion_t inversion)
 {
-
-	u8 feciqinv = at76c651_readreg(i2c, 0x60);
+	u8 feciqinv = at76c651_readreg(state, 0x60);
 
 	switch (inversion) {
 	case INVERSION_OFF:
@@ -347,56 +252,63 @@
 		return -EINVAL;
 	}
 
-	return at76c651_writereg(i2c, 0x60, feciqinv);
-
+	return at76c651_writereg(state, 0x60, feciqinv);
 }
 
-static int at76c651_set_parameters(struct dvb_i2c_bus *i2c,
-			struct dvb_frontend_parameters *p)
-{
 
-	dat7021_set_tv_freq(i2c, p->frequency);
-	at76c651_set_symbolrate(i2c, p->u.qam.symbol_rate);
-	at76c651_set_inversion(i2c, p->inversion);
-	at76c651_set_auto_config(i2c);
-        at76c651_reset(i2c);
 
-	return 0;
 
-}
 
-static int at76c651_set_defaults(struct dvb_i2c_bus *i2c)
+
+
+
+
+static int at76c651_set_parameters(struct dvb_frontend* fe,
+			struct dvb_frontend_parameters *p)
 {
+	int ret;
+	struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv;
 
-	at76c651_set_symbolrate(i2c, 6900000);
-	at76c651_set_qam(i2c, QAM_64);
-	at76c651_set_bbfreq(i2c);
-	at76c651_set_auto_config(i2c);
+	at76c651_writereg(state, 0x0c, 0xc3);
+	state->config->pll_set(fe, p);
+	at76c651_writereg(state, 0x0c, 0xc2);
 
-	return 0;
+	if ((ret = at76c651_set_symbol_rate(state, p->u.qam.symbol_rate)))
+		return ret;
 
+	if ((ret = at76c651_set_inversion(state, p->inversion)))
+		return ret;
+
+	return at76c651_set_auto_config(state);
 }
 
-static int at76c651_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static int at76c651_set_defaults(struct dvb_frontend* fe)
 {
+	struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv;
 
-	switch (cmd) {
+	at76c651_set_symbol_rate(state, 6900000);
+	at76c651_set_qam(state, QAM_64);
+	at76c651_set_bbfreq(state);
+	at76c651_set_auto_config(state);
 
-	case FE_GET_INFO:
-		memcpy(arg, &at76c651_info, sizeof (struct dvb_frontend_info));
-		break;
+	if (state->config->pll_init) {
+		at76c651_writereg(state, 0x0c, 0xc3);
+		state->config->pll_init(fe);
+		at76c651_writereg(state, 0x0c, 0xc2);
+}
 
-	case FE_READ_STATUS:
-		{
+	return 0;
+}
 
-			fe_status_t *status = (fe_status_t *) arg;
+static int at76c651_read_status(struct dvb_frontend* fe, fe_status_t* status)
+		{
+	struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv;
 			u8 sync;
 
 			/*
 			 * Bits: FEC, CAR, EQU, TIM, AGC2, AGC1, ADC, PLL (PLL=0) 
 			 */
-			sync = at76c651_readreg(fe->i2c, 0x80);
-
+	sync = at76c651_readreg(state, 0x80);
 			*status = 0;
 
 			if (sync & (0x04 | 0x10))	/* AGC1 || TIM */
@@ -414,122 +326,138 @@
 			if ((sync & 0xF0) == 0xF0)	/* TIM && EQU && CAR && FEC */
 				*status |= FE_HAS_LOCK;
 
-			break;
-
+	return 0;
 		}
 
-	case FE_READ_BER:
+static int at76c651_read_ber(struct dvb_frontend* fe, u32* ber)
 		{
-			u32 *ber = (u32 *) arg;
+	struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv;
 
-			*ber = (at76c651_readreg(fe->i2c, 0x81) & 0x0F) << 16;
-			*ber |= at76c651_readreg(fe->i2c, 0x82) << 8;
-			*ber |= at76c651_readreg(fe->i2c, 0x83);
+	*ber = (at76c651_readreg(state, 0x81) & 0x0F) << 16;
+	*ber |= at76c651_readreg(state, 0x82) << 8;
+	*ber |= at76c651_readreg(state, 0x83);
 			*ber *= 10;
 
-			break;
+	return 0;
 		}
 
-	case FE_READ_SIGNAL_STRENGTH:
+static int at76c651_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 		{
-			u8 gain = ~at76c651_readreg(fe->i2c, 0x91);
-
-			*(u16 *) arg = (gain << 8) | gain;
-			break;
-		}
-
-	case FE_READ_SNR:
-		*(u16 *) arg =
-		    0xFFFF -
-		    ((at76c651_readreg(fe->i2c, 0x8F) << 8) |
-		     at76c651_readreg(fe->i2c, 0x90));
-		break;
-
-	case FE_READ_UNCORRECTED_BLOCKS:
-		*(u32 *) arg = at76c651_readreg(fe->i2c, 0x82);
-		break;
+	struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv;
 
-	case FE_SET_FRONTEND:
-		return at76c651_set_parameters(fe->i2c, arg);
-
-	case FE_GET_FRONTEND:
-		break;
-
-	case FE_SLEEP:
-		break;
-
-	case FE_INIT:
-		return at76c651_set_defaults(fe->i2c);
-
-	case FE_GET_TUNE_SETTINGS:
-	{
-	        struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
-	        fesettings->min_delay_ms = 50;
-	        fesettings->step_size = 0;
-	        fesettings->max_drift = 0;
-	        return 0;
-	}	    
-
-	default:
-		return -ENOIOCTLCMD;
-	}
+	u8 gain = ~at76c651_readreg(state, 0x91);
+	*strength = (gain << 8) | gain;
 
 	return 0;
-
 }
 
-static int at76c651_attach(struct dvb_i2c_bus *i2c, void **data)
-{
-	if ( (at76c651_readreg(i2c, 0x0E) != 0x65) ||
-	     ( ( (at76c651_revision = at76c651_readreg(i2c, 0x0F)) & 0xFE) != 0x10) )
+static int at76c651_read_snr(struct dvb_frontend* fe, u16* snr)
 {
-		dprintk("no AT76C651(B) found\n");
-		return -ENODEV;
-	}
+	struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv;
 
-	if (at76c651_revision == 0x10)
-	{
-		dprintk("AT76C651A found\n");
-		strcpy(at76c651_info.name,"Atmel AT76C651A with DAT7021");
-		}
-	else
-	{
-		strcpy(at76c651_info.name,"Atmel AT76C651B with DAT7021");
-		dprintk("AT76C651B found\n");
-	}
-
-	at76c651_set_defaults(i2c);
+	*snr = 0xFFFF -
+	    ((at76c651_readreg(state, 0x8F) << 8) |
+	     at76c651_readreg(state, 0x90));
 
-	return dvb_register_frontend(at76c651_ioctl, i2c, NULL, &at76c651_info);
 
+	return 0;
 }
 
-static void at76c651_detach(struct dvb_i2c_bus *i2c, void *data)
-{
+static int at76c651_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+	{
+	struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv;
 
-	dvb_unregister_frontend(at76c651_ioctl, i2c);
+	*ucblocks = at76c651_readreg(state, 0x82);
 
+	return 0;
 }
 
-static int __init at76c651_init(void)
+static int at76c651_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *fesettings)
 {
+        fesettings->min_delay_ms = 50;
+        fesettings->step_size = 0;
+        fesettings->max_drift = 0;
+	return 0;
+	}
 
-	return dvb_register_i2c_device(THIS_MODULE, at76c651_attach,
-				       at76c651_detach);
+static void at76c651_release(struct dvb_frontend* fe)
+{
+	struct at76c651_state* state = (struct at76c651_state*) fe->demodulator_priv;
+		kfree(state);
+	}
 
-}
+static struct dvb_frontend_ops at76c651_ops;
 
-static void __exit at76c651_exit(void)
+struct dvb_frontend* at76c651_attach(const struct at76c651_config* config,
+				     struct i2c_adapter* i2c)
 {
+	struct at76c651_state* state = NULL;
 
-	dvb_unregister_i2c_device(at76c651_attach);
-
-}
+	/* allocate memory for the internal state */
+	state = (struct at76c651_state*) kmalloc(sizeof(struct at76c651_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->qam = 0;
+
+	/* check if the demod is there */
+	if (at76c651_readreg(state, 0x0e) != 0x65) goto error;
+
+	/* finalise state setup */
+	state->i2c = i2c;
+	state->revision = at76c651_readreg(state, 0x0f) & 0xfe;
+	memcpy(&state->ops, &at76c651_ops, sizeof(struct dvb_frontend_ops));
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops at76c651_ops = {
+
+	.info = {
+		.name = "Atmel AT76C651B DVB-C",
+		.type = FE_QAM,
+		.frequency_min = 48250000,
+		.frequency_max = 863250000,
+		.frequency_stepsize = 62500,
+		/*.frequency_tolerance = */	/* FIXME: 12% of SR */
+		.symbol_rate_min = 0,		/* FIXME */
+		.symbol_rate_max = 9360000,	/* FIXME */
+		.symbol_rate_tolerance = 4000,
+		.caps = FE_CAN_INVERSION_AUTO |
+		    FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+		    FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
+		    FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
+		    FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 | FE_CAN_QAM_128 |
+		    FE_CAN_MUTE_TS | FE_CAN_QAM_256 | FE_CAN_RECOVER
+	},
+
+	.release = at76c651_release,
+
+	.init = at76c651_set_defaults,
+
+	.set_frontend = at76c651_set_parameters,
+	.get_tune_settings = at76c651_get_tune_settings,
+
+	.read_status = at76c651_read_status,
+	.read_ber = at76c651_read_ber,
+	.read_signal_strength = at76c651_read_signal_strength,
+	.read_snr = at76c651_read_snr,
+	.read_ucblocks = at76c651_read_ucblocks,
+};
 
-module_init(at76c651_init);
-module_exit(at76c651_exit);
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
 
-MODULE_DESCRIPTION("at76c651/dat7021 dvb-c frontend driver");
+MODULE_DESCRIPTION("Atmel AT76C651 DVB-C Demodulator Driver");
 MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
+
+EXPORT_SYMBOL(at76c651_attach);
diff -Nru a/drivers/media/dvb/frontends/at76c651.h b/drivers/media/dvb/frontends/at76c651.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/at76c651.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,47 @@
+/*
+ * at76c651.c
+ *
+ * Atmel DVB-C Frontend Driver (at76c651)
+ *
+ * Copyright (C) 2001 fnbrd <fnbrd@gmx.de>
+ *             & 2002-2004 Andreas Oberritter <obi@linuxtv.org>
+ *             & 2003 Wolfram Joost <dbox2@frokaschwei.de>
+ *
+ * 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.
+ *
+ * AT76C651
+ * http://www.nalanda.nitc.ac.in/industry/datasheets/atmel/acrobat/doc1293.pdf
+ * http://www.atmel.com/atmel/acrobat/doc1320.pdf
+ */
+
+#ifndef AT76C651_H
+#define AT76C651_H
+
+#include <linux/dvb/frontend.h>
+
+struct at76c651_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* at76c651_attach(const struct at76c651_config* config,
+					    struct i2c_adapter* i2c);
+
+#endif // AT76C651_H
diff -Nru a/drivers/media/dvb/frontends/cx22700.c b/drivers/media/dvb/frontends/cx22700.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/cx22700.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,445 @@
+#/*
+    Conexant cx22700 DVB OFDM demodulator driver
+
+    Copyright (C) 2001-2002 Convergence Integrated Media GmbH
+	Holger Waechtler <holger@convergence.de>
+
+    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.
+
+*/
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include "dvb_frontend.h"
+#include "cx22700.h"
+
+
+struct cx22700_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	const struct cx22700_config* config;
+
+	struct dvb_frontend frontend;
+};
+
+
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "cx22700: " args); \
+	} while (0)
+
+static u8 init_tab [] = {
+	0x04, 0x10,
+	0x05, 0x09,
+	0x06, 0x00,
+	0x08, 0x04,
+	0x09, 0x00,
+	0x0a, 0x01,
+	0x15, 0x40,
+	0x16, 0x10,
+	0x17, 0x87,
+	0x18, 0x17,
+	0x1a, 0x10,
+	0x25, 0x04,
+	0x2e, 0x00,
+	0x39, 0x00,
+	0x3a, 0x04,
+	0x45, 0x08,
+	0x46, 0x02,
+	0x47, 0x05,
+};
+
+
+static int cx22700_writereg (struct cx22700_state* state, u8 reg, u8 data)
+{
+	int ret;
+	u8 buf [] = { reg, data };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
+
+	dprintk ("%s\n", __FUNCTION__);
+
+	ret = i2c_transfer (state->i2c, &msg, 1);
+
+	if (ret != 1)
+		printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
+			__FUNCTION__, reg, data, ret);
+
+	return (ret != 1) ? -1 : 0;
+}
+
+static int cx22700_readreg (struct cx22700_state* state, u8 reg)
+{
+	int ret;
+	u8 b0 [] = { reg };
+	u8 b1 [] = { 0 };
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
+			   { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
+
+	dprintk ("%s\n", __FUNCTION__);
+
+	ret = i2c_transfer (state->i2c, msg, 2);
+
+	if (ret != 2) return -EIO;
+
+	return b1[0];
+}
+
+static int cx22700_set_inversion (struct cx22700_state* state, int inversion)
+{
+	u8 val;
+
+	dprintk ("%s\n", __FUNCTION__);
+
+	switch (inversion) {
+	case INVERSION_AUTO:
+		return -EOPNOTSUPP;
+	case INVERSION_ON:
+		val = cx22700_readreg (state, 0x09);
+		return cx22700_writereg (state, 0x09, val | 0x01);
+	case INVERSION_OFF:
+		val = cx22700_readreg (state, 0x09);
+		return cx22700_writereg (state, 0x09, val & 0xfe);
+	default:
+		return -EINVAL;
+	}
+}
+
+static int cx22700_set_tps (struct cx22700_state *state, struct dvb_ofdm_parameters *p)
+{
+	static const u8 qam_tab [4] = { 0, 1, 0, 2 };
+	static const u8 fec_tab [6] = { 0, 1, 2, 0, 3, 4 };
+	u8 val;
+
+	dprintk ("%s\n", __FUNCTION__);
+
+	if (p->code_rate_HP < FEC_1_2 || p->code_rate_HP > FEC_7_8)
+		return -EINVAL;
+
+	if (p->code_rate_LP < FEC_1_2 || p->code_rate_LP > FEC_7_8)
+
+	if (p->code_rate_HP == FEC_4_5 || p->code_rate_LP == FEC_4_5)
+		return -EINVAL;
+
+	if (p->guard_interval < GUARD_INTERVAL_1_32 ||
+	    p->guard_interval > GUARD_INTERVAL_1_4)
+		return -EINVAL;
+
+	if (p->transmission_mode != TRANSMISSION_MODE_2K &&
+	    p->transmission_mode != TRANSMISSION_MODE_8K)
+		return -EINVAL;
+
+	if (p->constellation != QPSK &&
+	    p->constellation != QAM_16 &&
+	    p->constellation != QAM_64)
+		return -EINVAL;
+
+	if (p->hierarchy_information < HIERARCHY_NONE ||
+	    p->hierarchy_information > HIERARCHY_4)
+		return -EINVAL;
+
+	if (p->bandwidth < BANDWIDTH_8_MHZ && p->bandwidth > BANDWIDTH_6_MHZ)
+		return -EINVAL;
+
+	if (p->bandwidth == BANDWIDTH_7_MHZ)
+		cx22700_writereg (state, 0x09, cx22700_readreg (state, 0x09 | 0x10));
+	else
+		cx22700_writereg (state, 0x09, cx22700_readreg (state, 0x09 & ~0x10));
+
+	val = qam_tab[p->constellation - QPSK];
+	val |= p->hierarchy_information - HIERARCHY_NONE;
+
+	cx22700_writereg (state, 0x04, val);
+
+	val = fec_tab[p->code_rate_HP - FEC_1_2] << 3;
+	val |= fec_tab[p->code_rate_LP - FEC_1_2];
+
+	cx22700_writereg (state, 0x05, val);
+
+	val = (p->guard_interval - GUARD_INTERVAL_1_32) << 2;
+	val |= p->transmission_mode - TRANSMISSION_MODE_2K;
+
+	cx22700_writereg (state, 0x06, val);
+
+	cx22700_writereg (state, 0x08, 0x04 | 0x02);  /* use user tps parameters */
+	cx22700_writereg (state, 0x08, 0x04);         /* restart aquisition */
+
+	return 0;
+}
+
+static int cx22700_get_tps (struct cx22700_state* state, struct dvb_ofdm_parameters *p)
+{
+	static const fe_modulation_t qam_tab [3] = { QPSK, QAM_16, QAM_64 };
+	static const fe_code_rate_t fec_tab [5] = { FEC_1_2, FEC_2_3, FEC_3_4,
+						    FEC_5_6, FEC_7_8 };
+	u8 val;
+
+	dprintk ("%s\n", __FUNCTION__);
+
+	if (!(cx22700_readreg(state, 0x07) & 0x20))  /*  tps valid? */
+		return -EAGAIN;
+
+	val = cx22700_readreg (state, 0x01);
+
+	if ((val & 0x7) > 4)
+		p->hierarchy_information = HIERARCHY_AUTO;
+	else
+		p->hierarchy_information = HIERARCHY_NONE + (val & 0x7);
+
+	if (((val >> 3) & 0x3) > 2)
+		p->constellation = QAM_AUTO;
+	else
+		p->constellation = qam_tab[(val >> 3) & 0x3];
+
+	val = cx22700_readreg (state, 0x02);
+
+	if (((val >> 3) & 0x07) > 4)
+		p->code_rate_HP = FEC_AUTO;
+	else
+		p->code_rate_HP = fec_tab[(val >> 3) & 0x07];
+
+	if ((val & 0x07) > 4)
+		p->code_rate_LP = FEC_AUTO;
+	else
+		p->code_rate_LP = fec_tab[val & 0x07];
+
+	val = cx22700_readreg (state, 0x03);
+
+	p->guard_interval = GUARD_INTERVAL_1_32 + ((val >> 6) & 0x3);
+	p->transmission_mode = TRANSMISSION_MODE_2K + ((val >> 5) & 0x1);
+
+	return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+static int cx22700_init (struct dvb_frontend* fe)
+
+{	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+	int i;
+
+	dprintk("cx22700_init: init chip\n");
+
+	cx22700_writereg (state, 0x00, 0x02);   /*  soft reset */
+	cx22700_writereg (state, 0x00, 0x00);
+
+	msleep(10);
+
+	for (i=0; i<sizeof(init_tab); i+=2)
+		cx22700_writereg (state, init_tab[i], init_tab[i+1]);
+
+	cx22700_writereg (state, 0x00, 0x01);
+
+	if (state->config->pll_init) {
+		cx22700_writereg (state, 0x0a, 0x00);  /* open i2c bus switch */
+		state->config->pll_init(fe);
+		cx22700_writereg (state, 0x0a, 0x01);  /* close i2c bus switch */
+	}
+
+	return 0;
+}
+
+static int cx22700_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+
+	u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
+		   | (cx22700_readreg (state, 0x0e) << 1);
+	u8 sync = cx22700_readreg (state, 0x07);
+
+	*status = 0;
+
+	if (rs_ber < 0xff00)
+		*status |= FE_HAS_SIGNAL;
+
+	if (sync & 0x20)
+		*status |= FE_HAS_CARRIER;
+
+	if (sync & 0x10)
+		*status |= FE_HAS_VITERBI;
+
+	if (sync & 0x10)
+		*status |= FE_HAS_SYNC;
+
+	if (*status == 0x0f)
+		*status |= FE_HAS_LOCK;
+
+	return 0;
+}
+
+static int cx22700_read_ber(struct dvb_frontend* fe, u32* ber)
+{
+	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+
+	*ber = cx22700_readreg (state, 0x0c) & 0x7f;
+	cx22700_writereg (state, 0x0c, 0x00);
+
+	return 0;
+}
+
+static int cx22700_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
+{
+	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+
+	u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
+		   | (cx22700_readreg (state, 0x0e) << 1);
+	*signal_strength = ~rs_ber;
+
+	return 0;
+}
+
+static int cx22700_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+
+	u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
+		   | (cx22700_readreg (state, 0x0e) << 1);
+	*snr = ~rs_ber;
+
+	return 0;
+}
+
+static int cx22700_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+
+	*ucblocks = cx22700_readreg (state, 0x0f);
+	cx22700_writereg (state, 0x0f, 0x00);
+
+	return 0;
+}
+
+static int cx22700_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+
+	cx22700_writereg (state, 0x00, 0x02); /* XXX CHECKME: soft reset*/
+	cx22700_writereg (state, 0x00, 0x00);
+
+	cx22700_writereg (state, 0x0a, 0x00);  /* open i2c bus switch */
+	state->config->pll_set(fe, p);
+	cx22700_writereg (state, 0x0a, 0x01);  /* close i2c bus switch */
+	cx22700_set_inversion (state, p->inversion);
+	cx22700_set_tps (state, &p->u.ofdm);
+	cx22700_writereg (state, 0x37, 0x01);  /* PAL loop filter off */
+	cx22700_writereg (state, 0x00, 0x01);  /* restart acquire */
+
+	return 0;
+}
+
+static int cx22700_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+	u8 reg09 = cx22700_readreg (state, 0x09);
+
+	p->inversion = reg09 & 0x1 ? INVERSION_ON : INVERSION_OFF;
+	return cx22700_get_tps (state, &p->u.ofdm);
+}
+
+static int cx22700_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
+{
+        fesettings->min_delay_ms = 150;
+        fesettings->step_size = 166667;
+        fesettings->max_drift = 166667*2;
+        return 0;
+}
+
+static void cx22700_release(struct dvb_frontend* fe)
+{
+	struct cx22700_state* state = (struct cx22700_state*) fe->demodulator_priv;
+	kfree(state);
+}
+
+static struct dvb_frontend_ops cx22700_ops;
+
+struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
+				    struct i2c_adapter* i2c)
+{
+	struct cx22700_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct cx22700_state*) kmalloc(sizeof(struct cx22700_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &cx22700_ops, sizeof(struct dvb_frontend_ops));
+
+	/* check if the demod is there */
+	if (cx22700_readreg(state, 0x07) < 0) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops cx22700_ops = {
+
+	.info = {
+		.name 			= "Conexant CX22700 DVB-T",
+		.type 			= FE_OFDM,
+		.frequency_min 		= 470000000,
+		.frequency_max 		= 860000000,
+		.frequency_stepsize 	= 166667,
+		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+		      FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+		      FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
+	              FE_CAN_RECOVER
+	},
+
+	.release = cx22700_release,
+
+	.init = cx22700_init,
+
+	.set_frontend = cx22700_set_frontend,
+	.get_frontend = cx22700_get_frontend,
+	.get_tune_settings = cx22700_get_tune_settings,
+
+	.read_status = cx22700_read_status,
+	.read_ber = cx22700_read_ber,
+	.read_signal_strength = cx22700_read_signal_strength,
+	.read_snr = cx22700_read_snr,
+	.read_ucblocks = cx22700_read_ucblocks,
+};
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
+
+MODULE_DESCRIPTION("Conexant CX22700 DVB-T Demodulator driver");
+MODULE_AUTHOR("Holger Waechtler");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(cx22700_attach);
diff -Nru a/drivers/media/dvb/frontends/cx22700.h b/drivers/media/dvb/frontends/cx22700.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/cx22700.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,41 @@
+/*
+    Conexant CX22700 DVB OFDM demodulator driver
+
+    Copyright (C) 2001-2002 Convergence Integrated Media GmbH
+	Holger Waechtler <holger@convergence.de>
+
+    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.
+
+*/
+
+#ifndef CX22700_H
+#define CX22700_H
+
+#include <linux/dvb/frontend.h>
+
+struct cx22700_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
+					   struct i2c_adapter* i2c);
+
+#endif // CX22700_H
diff -Nru a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/cx22702.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,532 @@
+/*
+    Conexant 22702 DVB OFDM demodulator driver
+
+    based on:
+        Alps TDMB7 DVB OFDM demodulator driver
+
+    Copyright (C) 2001-2002 Convergence Integrated Media GmbH
+	  Holger Waechtler <holger@convergence.de>
+
+    Copyright (C) 2004 Steven Toth <steve@toth.demon.co.uk>
+
+    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.
+
+*/
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include "dvb_frontend.h"
+#include "cx22702.h"
+
+
+struct cx22702_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct cx22702_config* config;
+
+	struct dvb_frontend frontend;
+
+	/* previous uncorrected block counter */
+	u8 prevUCBlocks;
+};
+
+static int debug = 0;
+#define dprintk	if (debug) printk
+
+/* Register values to initialise the demod */
+static u8 init_tab [] = {
+	0x00, 0x00, /* Stop aquisition */
+	0x0B, 0x06,
+	0x09, 0x01,
+	0x0D, 0x41,
+	0x16, 0x32,
+	0x20, 0x0A,
+	0x21, 0x17,
+	0x24, 0x3e,
+	0x26, 0xff,
+	0x27, 0x10,
+	0x28, 0x00,
+	0x29, 0x00,
+	0x2a, 0x10,
+	0x2b, 0x00,
+	0x2c, 0x10,
+	0x2d, 0x00,
+	0x48, 0xd4,
+	0x49, 0x56,
+	0x6b, 0x1e,
+	0xc8, 0x02,
+	0xf8, 0x02,
+	0xf9, 0x00,
+	0xfa, 0x00,
+	0xfb, 0x00,
+	0xfc, 0x00,
+	0xfd, 0x00,
+};
+
+static int cx22702_writereg (struct cx22702_state* state, u8 reg, u8 data)
+{
+	int ret;
+	u8 buf [] = { reg, data };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
+
+	ret = i2c_transfer(state->i2c, &msg, 1);
+
+	if (ret != 1)
+		printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
+			__FUNCTION__, reg, data, ret);
+
+	return (ret != 1) ? -1 : 0;
+}
+
+static u8 cx22702_readreg (struct cx22702_state* state, u8 reg)
+{
+	int ret;
+	u8 b0 [] = { reg };
+	u8 b1 [] = { 0 };
+
+	struct i2c_msg msg [] = {
+		{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
+		{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
+
+	ret = i2c_transfer(state->i2c, msg, 2);
+
+	if (ret != 2)
+		printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+
+	return b1[0];
+}
+
+static int cx22702_set_inversion (struct cx22702_state *state, int inversion)
+{
+	u8 val;
+
+	switch (inversion) {
+
+		case INVERSION_AUTO:
+			return -EOPNOTSUPP;
+
+		case INVERSION_ON:
+			val = cx22702_readreg (state, 0x0C);
+			return cx22702_writereg (state, 0x0C, val | 0x01);
+
+		case INVERSION_OFF:
+			val = cx22702_readreg (state, 0x0C);
+			return cx22702_writereg (state, 0x0C, val & 0xfe);
+
+		default:
+			return -EINVAL;
+
+	}
+
+}
+
+/* Retrieve the demod settings */
+static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_parameters *p)
+{
+	u8 val;
+
+	/* Make sure the TPS regs are valid */
+	if (!(cx22702_readreg(state, 0x0A) & 0x20))
+		return -EAGAIN;
+
+	val = cx22702_readreg (state, 0x01);
+	switch( (val&0x18)>>3) {
+		case 0: p->constellation =   QPSK; break;
+		case 1: p->constellation = QAM_16; break;
+		case 2: p->constellation = QAM_64; break;
+	}
+	switch( val&0x07 ) {
+		case 0: p->hierarchy_information = HIERARCHY_NONE; break;
+		case 1: p->hierarchy_information =    HIERARCHY_1; break;
+		case 2: p->hierarchy_information =    HIERARCHY_2; break;
+		case 3: p->hierarchy_information =    HIERARCHY_4; break;
+	}
+
+
+	val = cx22702_readreg (state, 0x02);
+	switch( (val&0x38)>>3 ) {
+		case 0: p->code_rate_HP = FEC_1_2; break;
+		case 1: p->code_rate_HP = FEC_2_3; break;
+		case 2: p->code_rate_HP = FEC_3_4; break;
+		case 3: p->code_rate_HP = FEC_5_6; break;
+		case 4: p->code_rate_HP = FEC_7_8; break;
+	}
+	switch( val&0x07 ) {
+		case 0: p->code_rate_LP = FEC_1_2; break;
+		case 1: p->code_rate_LP = FEC_2_3; break;
+		case 2: p->code_rate_LP = FEC_3_4; break;
+		case 3: p->code_rate_LP = FEC_5_6; break;
+		case 4: p->code_rate_LP = FEC_7_8; break;
+	}
+
+
+	val = cx22702_readreg (state, 0x03);
+	switch( (val&0x0c)>>2 ) {
+		case 0: p->guard_interval = GUARD_INTERVAL_1_32; break;
+		case 1: p->guard_interval = GUARD_INTERVAL_1_16; break;
+		case 2: p->guard_interval =  GUARD_INTERVAL_1_8; break;
+		case 3: p->guard_interval =  GUARD_INTERVAL_1_4; break;
+}
+	switch( val&0x03 ) {
+		case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break;
+		case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break;
+	}
+
+	return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Talk to the demod, set the FEC, GUARD, QAM settings etc */
+static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	u8 val;
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+
+	/* set PLL */
+        cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);
+	state->config->pll_set(fe, p);
+        cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);
+
+	/* set inversion */
+	cx22702_set_inversion (state, p->inversion);
+
+	/* set bandwidth */
+	switch(p->u.ofdm.bandwidth) {
+	case BANDWIDTH_6_MHZ:
+		cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20 );
+		break;
+	case BANDWIDTH_7_MHZ:
+		cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10 );
+		break;
+	case BANDWIDTH_8_MHZ:
+		cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf );
+		break;
+	default:
+		dprintk ("%s: invalid bandwidth\n",__FUNCTION__);
+		return -EINVAL;
+	}
+
+
+	p->u.ofdm.code_rate_LP = FEC_AUTO; //temp hack as manual not working
+
+	/* use auto configuration? */
+	if((p->u.ofdm.hierarchy_information==HIERARCHY_AUTO) ||
+	   (p->u.ofdm.constellation==QAM_AUTO) ||
+	   (p->u.ofdm.code_rate_HP==FEC_AUTO) ||
+	   (p->u.ofdm.code_rate_LP==FEC_AUTO) ||
+	   (p->u.ofdm.guard_interval==GUARD_INTERVAL_AUTO) ||
+	   (p->u.ofdm.transmission_mode==TRANSMISSION_MODE_AUTO) ) {
+
+		/* TPS Source - use hardware driven values */
+		cx22702_writereg(state, 0x06, 0x10);
+		cx22702_writereg(state, 0x07, 0x9);
+		cx22702_writereg(state, 0x08, 0xC1);
+		cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc );
+		cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 );
+		cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */
+		printk("%s: Autodetecting\n",__FUNCTION__);
+		return 0;
+	}
+
+   	/* manually programmed values */
+	val=0;
+	switch(p->u.ofdm.constellation) {
+		case   QPSK: val = (val&0xe7); break;
+		case QAM_16: val = (val&0xe7)|0x08; break;
+		case QAM_64: val = (val&0xe7)|0x10; break;
+		default:
+			dprintk ("%s: invalid constellation\n",__FUNCTION__);
+			return -EINVAL;
+	}
+	switch(p->u.ofdm.hierarchy_information) {
+		case HIERARCHY_NONE: val = (val&0xf8); break;
+		case    HIERARCHY_1: val = (val&0xf8)|1; break;
+		case    HIERARCHY_2: val = (val&0xf8)|2; break;
+		case    HIERARCHY_4: val = (val&0xf8)|3; break;
+		default:
+			dprintk ("%s: invalid hierarchy\n",__FUNCTION__);
+			return -EINVAL;
+	}
+	cx22702_writereg (state, 0x06, val);
+
+	val=0;
+	switch(p->u.ofdm.code_rate_HP) {
+		case FEC_NONE:
+		case FEC_1_2: val = (val&0xc7); break;
+		case FEC_2_3: val = (val&0xc7)|0x08; break;
+		case FEC_3_4: val = (val&0xc7)|0x10; break;
+		case FEC_5_6: val = (val&0xc7)|0x18; break;
+		case FEC_7_8: val = (val&0xc7)|0x20; break;
+		default:
+			dprintk ("%s: invalid code_rate_HP\n",__FUNCTION__);
+			return -EINVAL;
+	}
+	switch(p->u.ofdm.code_rate_LP) {
+		case FEC_NONE:
+		case FEC_1_2: val = (val&0xf8); break;
+		case FEC_2_3: val = (val&0xf8)|1; break;
+		case FEC_3_4: val = (val&0xf8)|2; break;
+		case FEC_5_6: val = (val&0xf8)|3; break;
+		case FEC_7_8: val = (val&0xf8)|4; break;
+		default:
+			dprintk ("%s: invalid code_rate_LP\n",__FUNCTION__);
+			return -EINVAL;
+	}
+	cx22702_writereg (state, 0x07, val);
+
+	val=0;
+	switch(p->u.ofdm.guard_interval) {
+		case GUARD_INTERVAL_1_32: val = (val&0xf3); break;
+		case GUARD_INTERVAL_1_16: val = (val&0xf3)|0x04; break;
+		case  GUARD_INTERVAL_1_8: val = (val&0xf3)|0x08; break;
+		case  GUARD_INTERVAL_1_4: val = (val&0xf3)|0x0c; break;
+		default:
+			dprintk ("%s: invalid guard_interval\n",__FUNCTION__);
+			return -EINVAL;
+	}
+	switch(p->u.ofdm.transmission_mode) {
+		case TRANSMISSION_MODE_2K: val = (val&0xfc); break;
+		case TRANSMISSION_MODE_8K: val = (val&0xfc)|1; break;
+		default:
+			dprintk ("%s: invalid transmission_mode\n",__FUNCTION__);
+			return -EINVAL;
+	}
+	cx22702_writereg(state, 0x08, val);
+	cx22702_writereg(state, 0x0B, (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02 );
+	cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 );
+
+	/* Begin channel aquisition */
+	cx22702_writereg(state, 0x00, 0x01);
+
+	return 0;
+}
+
+
+/* Reset the demod hardware and reset all of the configuration registers
+   to a default state. */
+static int cx22702_init (struct dvb_frontend* fe)
+{
+	int i;
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+
+	cx22702_writereg (state, 0x00, 0x02);
+
+	msleep(10);
+
+	for (i=0; i<sizeof(init_tab); i+=2)
+		cx22702_writereg (state, init_tab[i], init_tab[i+1]);
+
+
+	/* init PLL */
+	if (state->config->pll_init) {
+	        cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);
+		state->config->pll_init(fe);
+		cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);
+	}
+
+	return 0;
+}
+
+static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+	u8 reg0A;
+	u8 reg23;
+
+			*status = 0;
+
+	reg0A = cx22702_readreg (state, 0x0A);
+	reg23 = cx22702_readreg (state, 0x23);
+
+			dprintk ("%s: status demod=0x%02x agc=0x%02x\n"
+				,__FUNCTION__,reg0A,reg23);
+
+			if(reg0A & 0x10) {
+				*status |= FE_HAS_LOCK;
+				*status |= FE_HAS_VITERBI;
+				*status |= FE_HAS_SYNC;
+			}
+
+			if(reg0A & 0x20)
+				*status |= FE_HAS_CARRIER;
+
+			if(reg23 < 0xf0)
+				*status |= FE_HAS_SIGNAL;
+
+	return 0;
+			}
+
+static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber)
+		{
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+
+	if(cx22702_readreg (state, 0xE4) & 0x02) {
+				/* Realtime statistics */
+		*ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
+			| (cx22702_readreg (state, 0xDF)&0x7F);
+			} else {
+		/* Averagtine statistics */
+		*ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
+			| cx22702_readreg (state, 0xDF);
+		}
+
+	return 0;
+		}
+
+static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
+		{
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+
+	*signal_strength = cx22702_readreg (state, 0x23);
+
+	return 0;
+}
+
+static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+
+	u16 rs_ber=0;
+	if(cx22702_readreg (state, 0xE4) & 0x02) {
+		/* Realtime statistics */
+		rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
+			| (cx22702_readreg (state, 0xDF)& 0x7F);
+	} else {
+		/* Averagine statistics */
+		rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 8
+			| cx22702_readreg (state, 0xDF);
+	}
+	*snr = ~rs_ber;
+
+	return 0;
+}
+
+static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+
+	u8 _ucblocks;
+
+	/* RS Uncorrectable Packet Count then reset */
+	_ucblocks = cx22702_readreg (state, 0xE3);
+	if (state->prevUCBlocks < _ucblocks) *ucblocks = (_ucblocks - state->prevUCBlocks);
+	else *ucblocks = state->prevUCBlocks - _ucblocks;
+	state->prevUCBlocks = _ucblocks;
+
+	return 0;
+}
+
+static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+
+	u8 reg0C = cx22702_readreg (state, 0x0C);
+
+	p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF;
+	return cx22702_get_tps (state, &p->u.ofdm);
+}
+
+static void cx22702_release(struct dvb_frontend* fe)
+{
+	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
+		kfree(state);
+	}
+
+static struct dvb_frontend_ops cx22702_ops;
+
+struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
+				    struct i2c_adapter* i2c)
+{
+	struct cx22702_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct cx22702_state*) kmalloc(sizeof(struct cx22702_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &cx22702_ops, sizeof(struct dvb_frontend_ops));
+	state->prevUCBlocks = 0;
+
+	/* check if the demod is there */
+	if (cx22702_readreg(state, 0x1f) != 0x3) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops cx22702_ops = {
+
+	.info = {
+		.name			= "Conexant CX22702 DVB-T",
+		.type			= FE_OFDM,
+		.frequency_min		= 177000000,
+		.frequency_max		= 858000000,
+		.frequency_stepsize	= 166666,
+		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+		FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+		FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+		FE_CAN_HIERARCHY_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
+		FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_RECOVER
+	},
+
+	.release = cx22702_release,
+
+	.init = cx22702_init,
+
+	.set_frontend = cx22702_set_tps,
+	.get_frontend = cx22702_get_frontend,
+
+	.read_status = cx22702_read_status,
+	.read_ber = cx22702_read_ber,
+	.read_signal_strength = cx22702_read_signal_strength,
+	.read_snr = cx22702_read_snr,
+	.read_ucblocks = cx22702_read_ucblocks,
+};
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Enable verbose debug messages");
+
+MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver");
+MODULE_AUTHOR("Steven Toth");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(cx22702_attach);
diff -Nru a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/cx22702.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,46 @@
+/*
+    Conexant 22702 DVB OFDM demodulator driver
+
+    based on:
+        Alps TDMB7 DVB OFDM demodulator driver
+
+    Copyright (C) 2001-2002 Convergence Integrated Media GmbH
+	  Holger Waechtler <holger@convergence.de>
+
+    Copyright (C) 2004 Steven Toth <steve@toth.demon.co.uk>
+
+    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.
+
+*/
+
+#ifndef CX22702_H
+#define CX22702_H
+
+#include <linux/dvb/frontend.h>
+
+struct cx22702_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
+					   struct i2c_adapter* i2c);
+
+#endif // CX22702_H
diff -Nru a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c
--- a/drivers/media/dvb/frontends/cx24110.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/media/dvb/frontends/cx24110.c	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,5 @@
 /*
     cx24110 - Single Chip Satellite Channel Receiver driver module
-               used on the the Pinnacle PCTV Sat cards
 
     Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> based on
     work
@@ -23,46 +22,36 @@
 
 */
 
-/* currently drives the Conexant cx24110 and cx24106 QPSK decoder chips,
-   connected via i2c to a Conexant Fusion 878 (this uses the standard
-   linux bttv driver). The tuner chip is supposed to be the Conexant
-   cx24108 digital satellite tuner, driven through the tuner interface
-   of the cx24110. SEC is also supplied by the cx24110.
-
-   Oct-2002: Migrate to API V3 (formerly known as NEWSTRUCT)
-*/
-
 #include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 
 #include "dvb_frontend.h"
-#include "dvb_functions.h"
+#include "cx24110.h"
+
+
+struct cx24110_state {
 
-static int debug = 0;
-#define dprintk	if (debug) printk
+	struct i2c_adapter* i2c;
 
+	struct dvb_frontend_ops ops;
 
-static struct dvb_frontend_info cx24110_info = {
-	.name = "Conexant CX24110 with CX24108 tuner, aka HM1221/HM1811",
-	.type = FE_QPSK,
-	.frequency_min = 950000,
-	.frequency_max = 2150000,
-	.frequency_stepsize = 1011,  /* kHz for QPSK frontends, can be reduced
-					to 253kHz on the cx24108 tuner */
-	.frequency_tolerance = 29500,
-	.symbol_rate_min = 1000000,
-	.symbol_rate_max = 45000000,
-/*      .symbol_rate_tolerance = ???,*/
-	.notifier_delay = 50,                /* 1/20 s */
-	.caps = FE_CAN_INVERSION_AUTO |
-		FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-		FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-		FE_CAN_QPSK | FE_CAN_RECOVER
+	const struct cx24110_config* config;
+
+	struct dvb_frontend frontend;
+
+	u32 lastber;
+	u32 lastbler;
+	u32 lastesn0;
 };
-/* fixme: are these values correct? especially ..._tolerance and caps */
 
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "cx24110: " args); \
+	} while (0)
 
 static struct {u8 reg; u8 data;} cx24110_regdata[]=
                       /* Comments beginning with @ denote this value should
@@ -127,16 +116,15 @@
 	};
 
 
-static int cx24110_writereg (struct dvb_i2c_bus *i2c, int reg, int data)
+static int cx24110_writereg (struct cx24110_state* state, int reg, int data)
 {
         u8 buf [] = { reg, data };
-	struct i2c_msg msg = { .addr = 0x55, .flags = 0, .buf = buf, .len = 2 };
-/* fixme (medium): HW allows any i2c address. 0x55 is the default, but the
-   cx24110 might show up at any address */
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
 	int err;
 
-        if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
-		dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
+        if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
+		dprintk ("%s: writereg error (err == %i, reg == 0x%02x,"
+			 " data == 0x%02x)\n", __FUNCTION__, err, reg, data);
 		return -EREMOTEIO;
 	}
 
@@ -144,161 +132,46 @@
 }
 
 
-static u8 cx24110_readreg (struct dvb_i2c_bus *i2c, u8 reg)
+static int cx24110_readreg (struct cx24110_state* state, u8 reg)
 {
 	int ret;
 	u8 b0 [] = { reg };
 	u8 b1 [] = { 0 };
-	struct i2c_msg msg [] = { { .addr = 0x55, .flags = 0, .buf = b0, .len = 1 },
-			   { .addr = 0x55, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-/* fixme (medium): address might be different from 0x55 */
-	ret = i2c->xfer (i2c, msg, 2);
-
-	if (ret != 2)
-		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
+			   { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
 
-	return b1[0];
-}
+	ret = i2c_transfer(state->i2c, msg, 2);
 
+	if (ret != 2) return ret;
 
-static int cx24108_write (struct dvb_i2c_bus *i2c, u32 data)
-{
-/* tuner data is 21 bits long, must be left-aligned in data */
-/* tuner cx24108 is written through a dedicated 3wire interface on the demod chip */
-/* FIXME (low): add error handling, avoid infinite loops if HW fails... */
-
-dprintk("cx24110 debug: cx24108_write(%8.8x)\n",data);
-
-        cx24110_writereg(i2c,0x6d,0x30); /* auto mode at 62kHz */
-        cx24110_writereg(i2c,0x70,0x15); /* auto mode 21 bits */
-        /* if the auto tuner writer is still busy, clear it out */
-        while (cx24110_readreg(i2c,0x6d)&0x80)
-		cx24110_writereg(i2c,0x72,0);
-        /* write the topmost 8 bits */
-        cx24110_writereg(i2c,0x72,(data>>24)&0xff);
-        /* wait for the send to be completed */
-        while ((cx24110_readreg(i2c,0x6d)&0xc0)==0x80)
-		;
-        /* send another 8 bytes */
-        cx24110_writereg(i2c,0x72,(data>>16)&0xff);
-        while ((cx24110_readreg(i2c,0x6d)&0xc0)==0x80)
-		;
-        /* and the topmost 5 bits of this byte */
-        cx24110_writereg(i2c,0x72,(data>>8)&0xff);
-        while ((cx24110_readreg(i2c,0x6d)&0xc0)==0x80)
-		;
-        /* now strobe the enable line once */
-        cx24110_writereg(i2c,0x6d,0x32);
-        cx24110_writereg(i2c,0x6d,0x30);
-
-        return 0;
-}
-
-
-static int cx24108_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
-{
-/* fixme (low): error handling */
-        int i, a, n, pump;
-        u32 band, pll;
-
-
-        static const u32 osci[]={ 950000,1019000,1075000,1178000,
-			         1296000,1432000,1576000,1718000,
-				 1856000,2036000,2150000};
-        static const u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,
-				      0x00101000,0x00102000,0x00104000,
-				      0x00108000,0x00110000,0x00120000,
-				      0x00140000};
-
-#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
-        dprintk("cx24110 debug: cx24108_set_tv_freq, freq=%d\n",freq);
-
-        if (freq<950000)
-		freq=950000; /* kHz */
-        if (freq>2150000)
-		freq=2150000; /* satellite IF is 950..2150MHz */
-        /* decide which VCO to use for the input frequency */
-        for (i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++)
-		;
-        dprintk("cx24110 debug: select vco #%d (f=%d)\n",i,freq);
-        band=bandsel[i];
-        /* the gain values must be set by SetSymbolrate */
-        /* compute the pll divider needed, from Conexant data sheet,
-           resolved for (n*32+a), remember f(vco) is f(receive) *2 or *4,
-           depending on the divider bit. It is set to /4 on the 2 lowest
-           bands  */
-        n=((i<=2?2:1)*freq*10L)/(XTAL/100);
-        a=n%32; n/=32;
-	if (a==0)
-		n--;
-        pump=(freq<(osci[i-1]+osci[i])/2);
-        pll=0xf8000000|
-            ((pump?1:2)<<(14+11))|
-            ((n&0x1ff)<<(5+11))|
-            ((a&0x1f)<<11);
-        /* everything is shifted left 11 bits to left-align the bits in the
-           32bit word. Output to the tuner goes MSB-aligned, after all */
-        dprintk("cx24110 debug: pump=%d, n=%d, a=%d\n",pump,n,a);
-        cx24108_write(i2c,band);
-        /* set vga and vca to their widest-band settings, as a precaution.
-           SetSymbolrate might not be called to set this up */
-        cx24108_write(i2c,0x500c0000);
-        cx24108_write(i2c,0x83f1f800);
-        cx24108_write(i2c,pll);
-        cx24110_writereg(i2c,0x56,0x7f);
-
-	dvb_delay(10); /* wait a moment for the tuner pll to lock */
-
-	/* tuner pll lock can be monitored on GPIO pin 4 of cx24110 */
-        while (!(cx24110_readreg(i2c,0x66)&0x20)&&i<1000)
-		i++;
-        dprintk("cx24110 debug: GPIO IN=%2.2x(loop=%d)\n",
-                cx24110_readreg(i2c,0x66),i);
-        return 0;
-
-}
-
-
-static int cx24110_init (struct dvb_i2c_bus *i2c)
-{
-/* fixme (low): error handling */
-        int i;
-
-	dprintk("%s: init chip\n", __FUNCTION__);
-
-        for(i=0;i<sizeof(cx24110_regdata)/sizeof(cx24110_regdata[0]);i++) {
-		cx24110_writereg(i2c,cx24110_regdata[i].reg,cx24110_regdata[i].data);
-        };
-
-	return 0;
+	return b1[0];
 }
 
-
-static int cx24110_set_inversion (struct dvb_i2c_bus *i2c, fe_spectral_inversion_t inversion)
+static int cx24110_set_inversion (struct cx24110_state* state, fe_spectral_inversion_t inversion)
 {
 /* fixme (low): error handling */
 
 	switch (inversion) {
 	case INVERSION_OFF:
-                cx24110_writereg(i2c,0x37,cx24110_readreg(i2c,0x37)|0x1);
+                cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1);
                 /* AcqSpectrInvDis on. No idea why someone should want this */
-                cx24110_writereg(i2c,0x5,cx24110_readreg(i2c,0x5)&0xf7);
+                cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)&0xf7);
                 /* Initial value 0 at start of acq */
-                cx24110_writereg(i2c,0x22,cx24110_readreg(i2c,0x22)&0xef);
+                cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)&0xef);
                 /* current value 0 */
                 /* The cx24110 manual tells us this reg is read-only.
                    But what the heck... set it ayways */
                 break;
 	case INVERSION_ON:
-                cx24110_writereg(i2c,0x37,cx24110_readreg(i2c,0x37)|0x1);
+                cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1);
                 /* AcqSpectrInvDis on. No idea why someone should want this */
-                cx24110_writereg(i2c,0x5,cx24110_readreg(i2c,0x5)|0x08);
+                cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)|0x08);
                 /* Initial value 1 at start of acq */
-                cx24110_writereg(i2c,0x22,cx24110_readreg(i2c,0x22)|0x10);
+                cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)|0x10);
                 /* current value 1 */
                 break;
 	case INVERSION_AUTO:
-                cx24110_writereg(i2c,0x37,cx24110_readreg(i2c,0x37)&0xfe);
+                cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xfe);
                 /* AcqSpectrInvDis off. Leave initial & current states as is */
                 break;
 	default:
@@ -309,7 +182,7 @@
 }
 
 
-static int cx24110_set_fec (struct dvb_i2c_bus *i2c, fe_code_rate_t fec)
+static int cx24110_set_fec (struct cx24110_state* state, fe_code_rate_t fec)
 {
 /* fixme (low): error handling */
 
@@ -325,27 +198,27 @@
                 fec=FEC_AUTO;
 
         if (fec==FEC_AUTO) { /* (re-)establish AutoAcq behaviour */
-		cx24110_writereg(i2c,0x37,cx24110_readreg(i2c,0x37)&0xdf);
+		cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xdf);
 		/* clear AcqVitDis bit */
-		cx24110_writereg(i2c,0x18,0xae);
+		cx24110_writereg(state,0x18,0xae);
 		/* allow all DVB standard code rates */
-		cx24110_writereg(i2c,0x05,(cx24110_readreg(i2c,0x05)&0xf0)|0x3);
+		cx24110_writereg(state,0x05,(cx24110_readreg(state,0x05)&0xf0)|0x3);
 		/* set nominal Viterbi rate 3/4 */
-		cx24110_writereg(i2c,0x22,(cx24110_readreg(i2c,0x22)&0xf0)|0x3);
+		cx24110_writereg(state,0x22,(cx24110_readreg(state,0x22)&0xf0)|0x3);
 		/* set current Viterbi rate 3/4 */
-		cx24110_writereg(i2c,0x1a,0x05); cx24110_writereg(i2c,0x1b,0x06);
+		cx24110_writereg(state,0x1a,0x05); cx24110_writereg(state,0x1b,0x06);
 		/* set the puncture registers for code rate 3/4 */
 		return 0;
         } else {
-		cx24110_writereg(i2c,0x37,cx24110_readreg(i2c,0x37)|0x20);
+		cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x20);
 		/* set AcqVitDis bit */
 		if(rate[fec]>0) {
-			cx24110_writereg(i2c,0x05,(cx24110_readreg(i2c,0x05)&0xf0)|rate[fec]);
+			cx24110_writereg(state,0x05,(cx24110_readreg(state,0x05)&0xf0)|rate[fec]);
 			/* set nominal Viterbi rate */
-			cx24110_writereg(i2c,0x22,(cx24110_readreg(i2c,0x22)&0xf0)|rate[fec]);
+			cx24110_writereg(state,0x22,(cx24110_readreg(state,0x22)&0xf0)|rate[fec]);
 			/* set current Viterbi rate */
-			cx24110_writereg(i2c,0x1a,g1[fec]);
-			cx24110_writereg(i2c,0x1b,g2[fec]);
+			cx24110_writereg(state,0x1a,g1[fec]);
+			cx24110_writereg(state,0x1b,g2[fec]);
 			/* not sure if this is the right way: I always used AutoAcq mode */
            } else
 		   return -EOPNOTSUPP;
@@ -355,11 +228,11 @@
 }
 
 
-static fe_code_rate_t cx24110_get_fec (struct dvb_i2c_bus *i2c)
+static fe_code_rate_t cx24110_get_fec (struct cx24110_state* state)
 {
 	int i;
 
-	i=cx24110_readreg(i2c,0x22)&0x0f;
+	i=cx24110_readreg(state,0x22)&0x0f;
 	if(!(i&0x08)) {
 		return FEC_1_2 + i - 1;
 	} else {
@@ -372,16 +245,13 @@
 }
 
 
-static int cx24110_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
+static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate)
 {
 /* fixme (low): add error handling */
         u32 ratio;
         u32 tmp, fclk, BDRI;
 
         static const u32 bands[]={5000000UL,15000000UL,90999000UL/2};
-        static const u32 vca[]={0x80f03800,0x81f0f800,0x83f1f800};
-        static const u32 vga[]={0x5f8fc000,0x580f0000,0x500c0000};
-        static const u8  filtune[]={0xa2,0xcc,0x66};
         int i;
 
 dprintk("cx24110 debug: entering %s(%d)\n",__FUNCTION__,srate);
@@ -395,22 +265,22 @@
         /* first, check which sample rate is appropriate: 45, 60 80 or 90 MHz,
            and set the PLL accordingly (R07[1:0] Fclk, R06[7:4] PLLmult,
            R06[3:0] PLLphaseDetGain */
-        tmp=cx24110_readreg(i2c,0x07)&0xfc;
+        tmp=cx24110_readreg(state,0x07)&0xfc;
         if(srate<90999000UL/4) { /* sample rate 45MHz*/
-		cx24110_writereg(i2c,0x07,tmp);
-		cx24110_writereg(i2c,0x06,0x78);
+		cx24110_writereg(state,0x07,tmp);
+		cx24110_writereg(state,0x06,0x78);
 		fclk=90999000UL/2;
         } else if(srate<60666000UL/2) { /* sample rate 60MHz */
-		cx24110_writereg(i2c,0x07,tmp|0x1);
-		cx24110_writereg(i2c,0x06,0xa5);
+		cx24110_writereg(state,0x07,tmp|0x1);
+		cx24110_writereg(state,0x06,0xa5);
 		fclk=60666000UL;
         } else if(srate<80888000UL/2) { /* sample rate 80MHz */
-		cx24110_writereg(i2c,0x07,tmp|0x2);
-		cx24110_writereg(i2c,0x06,0x87);
+		cx24110_writereg(state,0x07,tmp|0x2);
+		cx24110_writereg(state,0x06,0x87);
 		fclk=80888000UL;
         } else { /* sample rate 90MHz */
-		cx24110_writereg(i2c,0x07,tmp|0x3);
-		cx24110_writereg(i2c,0x06,0x78);
+		cx24110_writereg(state,0x07,tmp|0x3);
+		cx24110_writereg(state,0x06,0x78);
 		fclk=90999000UL;
         };
         dprintk("cx24110 debug: fclk %d Hz\n",fclk);
@@ -439,62 +309,123 @@
         dprintk("fclk = %d\n", fclk);
         dprintk("ratio= %08x\n", ratio);
 
-        cx24110_writereg(i2c, 0x1, (ratio>>16)&0xff);
-        cx24110_writereg(i2c, 0x2, (ratio>>8)&0xff);
-        cx24110_writereg(i2c, 0x3, (ratio)&0xff);
-
-        /* please see the cx24108 data sheet, this controls tuner gain
-           and bandwidth settings depending on the symbol rate */
-        cx24108_write(i2c,vga[i]);
-        cx24108_write(i2c,vca[i]); /* gain is set on tuner chip */
-        cx24110_writereg(i2c,0x56,filtune[i]); /* bw is contolled by filtune voltage */
+        cx24110_writereg(state, 0x1, (ratio>>16)&0xff);
+        cx24110_writereg(state, 0x2, (ratio>>8)&0xff);
+        cx24110_writereg(state, 0x3, (ratio)&0xff);
+
+        return 0;
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+int cx24110_pll_write (struct dvb_frontend* fe, u32 data)
+{
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
+
+/* tuner data is 21 bits long, must be left-aligned in data */
+/* tuner cx24108 is written through a dedicated 3wire interface on the demod chip */
+/* FIXME (low): add error handling, avoid infinite loops if HW fails... */
+
+	dprintk("cx24110 debug: cx24108_write(%8.8x)\n",data);
+
+        cx24110_writereg(state,0x6d,0x30); /* auto mode at 62kHz */
+        cx24110_writereg(state,0x70,0x15); /* auto mode 21 bits */
+
+        /* if the auto tuner writer is still busy, clear it out */
+        while (cx24110_readreg(state,0x6d)&0x80)
+		cx24110_writereg(state,0x72,0);
+
+        /* write the topmost 8 bits */
+        cx24110_writereg(state,0x72,(data>>24)&0xff);
+
+        /* wait for the send to be completed */
+        while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
+		;
+
+        /* send another 8 bytes */
+        cx24110_writereg(state,0x72,(data>>16)&0xff);
+        while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
+		;
+
+        /* and the topmost 5 bits of this byte */
+        cx24110_writereg(state,0x72,(data>>8)&0xff);
+        while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
+		;
+
+        /* now strobe the enable line once */
+        cx24110_writereg(state,0x6d,0x32);
+        cx24110_writereg(state,0x6d,0x30);
 
         return 0;
+}
+
 
+
+static int cx24110_initfe(struct dvb_frontend* fe)
+{
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
+/* fixme (low): error handling */
+        int i;
+
+	dprintk("%s: init chip\n", __FUNCTION__);
+
+        for(i=0;i<sizeof(cx24110_regdata)/sizeof(cx24110_regdata[0]);i++) {
+		cx24110_writereg(state, cx24110_regdata[i].reg, cx24110_regdata[i].data);
+        };
+
+	if (state->config->pll_init) state->config->pll_init(fe);
+
+	return 0;
 }
 
 
-static int cx24110_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage)
+static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
 {
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
+
 	switch (voltage) {
 	case SEC_VOLTAGE_13:
-		return cx24110_writereg(i2c,0x76,(cx24110_readreg(i2c,0x76)&0x3b)|0xc0);
+		return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&0x3b)|0xc0);
 	case SEC_VOLTAGE_18:
-		return cx24110_writereg(i2c,0x76,(cx24110_readreg(i2c,0x76)&0x3b)|0x40);
+		return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&0x3b)|0x40);
 	default:
 		return -EINVAL;
 	};
 }
 
-static void sendDiSEqCMessage(struct dvb_i2c_bus *i2c, struct dvb_diseqc_master_cmd *pCmd)
+static int cx24110_send_diseqc_msg(struct dvb_frontend* fe,
+				    struct dvb_diseqc_master_cmd *cmd)
 {
 	int i, rv;
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
 
-	for (i = 0; i < pCmd->msg_len; i++)
-		cx24110_writereg(i2c, 0x79 + i, pCmd->msg[i]);
+	for (i = 0; i < cmd->msg_len; i++)
+		cx24110_writereg(state, 0x79 + i, cmd->msg[i]);
 
-	rv = cx24110_readreg(i2c, 0x76);
+	rv = cx24110_readreg(state, 0x76);
 
-	cx24110_writereg(i2c, 0x76, ((rv & 0x90) | 0x40) | ((pCmd->msg_len-3) & 3));
-	for (i=500; i-- > 0 && !(cx24110_readreg(i2c,0x76)&0x40);)
+	cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3));
+	for (i=500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);)
 		; /* wait for LNB ready */
-}
 
+	return 0;
+}
 
-static int cx24110_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static int cx24110_read_status(struct dvb_frontend* fe, fe_status_t* status)
 {
-	struct dvb_i2c_bus *i2c = fe->i2c;
-	static int lastber=0, lastbyer=0,lastbler=0, lastesn0=0, sum_bler=0;
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
 
-        switch (cmd) {
-        case FE_GET_INFO:
-		memcpy (arg, &cx24110_info, sizeof(struct dvb_frontend_info));
-		break;
-
-        case FE_READ_STATUS:
-	{
-		fe_status_t *status = arg;
-		int sync = cx24110_readreg (i2c, 0x55);
+	int sync = cx24110_readreg (state, 0x55);
 
 		*status = 0;
 
@@ -504,7 +435,7 @@
 		if (sync & 0x08)
 			*status |= FE_HAS_CARRIER;
 
-		sync = cx24110_readreg (i2c, 0x08);
+	sync = cx24110_readreg (state, 0x08);
 
 		if (sync & 0x40)
 			*status |= FE_HAS_VITERBI;
@@ -515,87 +446,97 @@
 		if ((sync & 0x60) == 0x60)
 			*status |= FE_HAS_LOCK;
 
-		if(cx24110_readreg(i2c,0x10)&0x40) {
-			/* the RS error counter has finished one counting window */
-			cx24110_writereg(i2c,0x10,0x60); /* select the byer reg */
-			lastbyer=cx24110_readreg(i2c,0x12)|
-				(cx24110_readreg(i2c,0x13)<<8)|
-				(cx24110_readreg(i2c,0x14)<<16);
-			cx24110_writereg(i2c,0x10,0x70); /* select the bler reg */
-			lastbler=cx24110_readreg(i2c,0x12)|
-				(cx24110_readreg(i2c,0x13)<<8)|
-				(cx24110_readreg(i2c,0x14)<<16);
-			cx24110_writereg(i2c,0x10,0x20); /* start new count window */
-			sum_bler += lastbler;
-		}
-		if(cx24110_readreg(i2c,0x24)&0x10) {
-			/* the Viterbi error counter has finished one counting window */
-			cx24110_writereg(i2c,0x24,0x04); /* select the ber reg */
-			lastber=cx24110_readreg(i2c,0x25)|
-				(cx24110_readreg(i2c,0x26)<<8);
-			cx24110_writereg(i2c,0x24,0x04); /* start new count window */
-			cx24110_writereg(i2c,0x24,0x14);
-		}
-		if(cx24110_readreg(i2c,0x6a)&0x80) {
-			/* the Es/N0 error counter has finished one counting window */
-			lastesn0=cx24110_readreg(i2c,0x69)|
-				(cx24110_readreg(i2c,0x68)<<8);
-			cx24110_writereg(i2c,0x6a,0x84); /* start new count window */
-		}
-		break;
+	return 0;
 	}
 
-        case FE_READ_BER:
+static int cx24110_read_ber(struct dvb_frontend* fe, u32* ber)
 	{
-		u32 *ber = (u32 *) arg;
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
 
-		*ber = lastber;
 /* fixme (maybe): value range is 16 bit. Scale? */
-		break;
+	if(cx24110_readreg(state,0x24)&0x10) {
+		/* the Viterbi error counter has finished one counting window */
+		cx24110_writereg(state,0x24,0x04); /* select the ber reg */
+		state->lastber=cx24110_readreg(state,0x25)|
+			(cx24110_readreg(state,0x26)<<8);
+		cx24110_writereg(state,0x24,0x04); /* start new count window */
+		cx24110_writereg(state,0x24,0x14);
 	}
+	*ber = state->lastber;
 
-        case FE_READ_SIGNAL_STRENGTH:
+	return 0;
+	}
+
+static int cx24110_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
 	{
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
+
 /* no provision in hardware. Read the frontend AGC accumulator. No idea how to scale this, but I know it is 2s complement */
-		u8 signal = cx24110_readreg (i2c, 0x27)+128;
-		*((u16*) arg) = (signal << 8) | signal;
-		break;
+	u8 signal = cx24110_readreg (state, 0x27)+128;
+	*signal_strength = (signal << 8) | signal;
+
+	return 0;
 	}
 
-        case FE_READ_SNR:
+static int cx24110_read_snr(struct dvb_frontend* fe, u16* snr)
 	{
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
+
 /* no provision in hardware. Can be computed from the Es/N0 estimator, but I don't know how. */
-		*(u16*) arg = lastesn0;
-		break;
+	if(cx24110_readreg(state,0x6a)&0x80) {
+		/* the Es/N0 error counter has finished one counting window */
+		state->lastesn0=cx24110_readreg(state,0x69)|
+			(cx24110_readreg(state,0x68)<<8);
+		cx24110_writereg(state,0x6a,0x84); /* start new count window */
+	}
+	*snr = state->lastesn0;
+
+	return 0;
 	}
 
-	case FE_READ_UNCORRECTED_BLOCKS:
+static int cx24110_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
 	{
-		*(u16*) arg = sum_bler&0xffff;
-		sum_bler=0;
-		break;
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
+	u32 lastbyer;
+
+	if(cx24110_readreg(state,0x10)&0x40) {
+		/* the RS error counter has finished one counting window */
+		cx24110_writereg(state,0x10,0x60); /* select the byer reg */
+		lastbyer=cx24110_readreg(state,0x12)|
+			(cx24110_readreg(state,0x13)<<8)|
+			(cx24110_readreg(state,0x14)<<16);
+		cx24110_writereg(state,0x10,0x70); /* select the bler reg */
+		state->lastbler=cx24110_readreg(state,0x12)|
+			(cx24110_readreg(state,0x13)<<8)|
+			(cx24110_readreg(state,0x14)<<16);
+		cx24110_writereg(state,0x10,0x20); /* start new count window */
 	}
+	*ucblocks = state->lastbler;
 
-        case FE_SET_FRONTEND:
+	return 0;
+}
+
+static int cx24110_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
         {
-		struct dvb_frontend_parameters *p = arg;
+	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
 
-		cx24108_set_tv_freq (i2c, p->frequency);
-		cx24110_set_inversion (i2c, p->inversion);
-		cx24110_set_fec (i2c, p->u.qpsk.fec_inner);
-		cx24110_set_symbolrate (i2c, p->u.qpsk.symbol_rate);
-		cx24110_writereg(i2c,0x04,0x05); /* start aquisition */
-                break;
+	state->config->pll_set(fe, p);
+	cx24110_set_inversion (state, p->inversion);
+	cx24110_set_fec (state, p->u.qpsk.fec_inner);
+	cx24110_set_symbolrate (state, p->u.qpsk.symbol_rate);
+	cx24110_writereg(state,0x04,0x05); /* start aquisition */
+
+	return 0;
         }
 
-	case FE_GET_FRONTEND:
+static int cx24110_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
 	{
-		struct dvb_frontend_parameters *p = arg;
+   	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
 		s32 afc; unsigned sclk;
 
 /* cannot read back tuner settings (freq). Need to have some private storage */
 
-		sclk = cx24110_readreg (i2c, 0x07) & 0x03;
+	sclk = cx24110_readreg (state, 0x07) & 0x03;
 /* ok, real AFC (FEDR) freq. is afc/2^24*fsamp, fsamp=45/60/80/90MHz.
  * Need 64 bit arithmetic. Is thiss possible in the kernel? */
 		if (sclk==0) sclk=90999000L/2L;
@@ -603,76 +544,104 @@
 		else if (sclk==2) sclk=80888000L;
 		else sclk=90999000L;
 		sclk>>=8;
-		afc = sclk*(cx24110_readreg (i2c, 0x44)&0x1f)+
-		      ((sclk*cx24110_readreg (i2c, 0x45))>>8)+
-		      ((sclk*cx24110_readreg (i2c, 0x46))>>16);
+	afc = sclk*(cx24110_readreg (state, 0x44)&0x1f)+
+	      ((sclk*cx24110_readreg (state, 0x45))>>8)+
+	      ((sclk*cx24110_readreg (state, 0x46))>>16);
 
 		p->frequency += afc;
-		p->inversion = (cx24110_readreg (i2c, 0x22) & 0x10) ?
+	p->inversion = (cx24110_readreg (state, 0x22) & 0x10) ?
 					INVERSION_ON : INVERSION_OFF;
-		p->u.qpsk.fec_inner = cx24110_get_fec (i2c);
-		break;
-	}
-
-        case FE_SLEEP:
-/* cannot do this from the FE end. How to communicate this to the place where it can be done? */
-		break;
-        case FE_INIT:
-		return cx24110_init (i2c);
-
-	case FE_SET_TONE:
-		return cx24110_writereg(i2c,0x76,(cx24110_readreg(i2c,0x76)&~0x10)|((((fe_sec_tone_mode_t) arg)==SEC_TONE_ON)?0x10:0));
-	case FE_SET_VOLTAGE:
-		return cx24110_set_voltage (i2c, (fe_sec_voltage_t) arg);
-
-	case FE_DISEQC_SEND_MASTER_CMD:
-		sendDiSEqCMessage(i2c, (struct dvb_diseqc_master_cmd*) arg);
-		return 0;
-
-	default:
-		return -EOPNOTSUPP;
-        };
+	p->u.qpsk.fec_inner = cx24110_get_fec (state);
 
         return 0;
 }
 
-
-static int cx24110_attach (struct dvb_i2c_bus *i2c, void **data)
+static int cx24110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
 {
-	u8 sig;
-
-	sig=cx24110_readreg (i2c, 0x00);
-	if ( sig != 0x5a && sig != 0x69 )
-		return -ENODEV;
+   	struct cx24110_state *state = (struct cx24110_state*) fe->demodulator_priv;
 
-	return dvb_register_frontend (cx24110_ioctl, i2c, NULL, &cx24110_info);
+	return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&~0x10)|(((tone==SEC_TONE_ON))?0x10:0));
 }
 
-
-static void cx24110_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	dvb_unregister_frontend (cx24110_ioctl, i2c);
-}
-
-
-static int __init init_cx24110 (void)
+static void cx24110_release(struct dvb_frontend* fe)
 {
-	return dvb_register_i2c_device (THIS_MODULE, cx24110_attach, cx24110_detach);
+	struct cx24110_state* state = (struct cx24110_state*) fe->demodulator_priv;
+		kfree(state);
 }
 
+static struct dvb_frontend_ops cx24110_ops;
 
-static void __exit exit_cx24110 (void)
+struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
+				    struct i2c_adapter* i2c)
 {
-	dvb_unregister_i2c_device (cx24110_attach);
-}
-
+	struct cx24110_state* state = NULL;
+	int ret;
 
-module_init(init_cx24110);
-module_exit(exit_cx24110);
+	/* allocate memory for the internal state */
+	state = (struct cx24110_state*) kmalloc(sizeof(struct cx24110_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &cx24110_ops, sizeof(struct dvb_frontend_ops));
+	state->lastber = 0;
+	state->lastbler = 0;
+   	state->lastesn0 = 0;
+
+	/* check if the demod is there */
+	ret = cx24110_readreg(state, 0x00);
+	if ((ret != 0x5a) && (ret != 0x69)) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops cx24110_ops = {
+
+	.info = {
+		.name = "Conexant CX24110 DVB-S",
+		.type = FE_QPSK,
+		.frequency_min = 950000,
+		.frequency_max = 2150000,
+		.frequency_stepsize = 1011,  /* kHz for QPSK frontends */
+		.frequency_tolerance = 29500,
+		.symbol_rate_min = 1000000,
+		.symbol_rate_max = 45000000,
+		.caps = FE_CAN_INVERSION_AUTO |
+			FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+			FE_CAN_QPSK | FE_CAN_RECOVER
+	},
+
+	.release = cx24110_release,
+
+	.init = cx24110_initfe,
+	.set_frontend = cx24110_set_frontend,
+	.get_frontend = cx24110_get_frontend,
+	.read_status = cx24110_read_status,
+	.read_ber = cx24110_read_ber,
+	.read_signal_strength = cx24110_read_signal_strength,
+	.read_snr = cx24110_read_snr,
+	.read_ucblocks = cx24110_read_ucblocks,
+
+	.diseqc_send_master_cmd = cx24110_send_diseqc_msg,
+	.set_tone = cx24110_set_tone,
+	.set_voltage = cx24110_set_voltage,
+};
 
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
 
-MODULE_DESCRIPTION("DVB Frontend driver module for the Conexant cx24108/cx24110 chipset");
+MODULE_DESCRIPTION("Conexant CX24110 DVB-S Demodulator driver");
 MODULE_AUTHOR("Peter Hettkamp");
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug,"i");
 
+EXPORT_SYMBOL(cx24110_attach);
+EXPORT_SYMBOL(cx24110_pll_write);
diff -Nru a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/cx24110.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,45 @@
+/*
+    cx24110 - Single Chip Satellite Channel Receiver driver module
+
+    Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> based on
+    work
+    Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
+
+    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.
+
+*/
+
+#ifndef CX24110_H
+#define CX24110_H
+
+#include <linux/dvb/frontend.h>
+
+struct cx24110_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
+					   struct i2c_adapter* i2c);
+
+extern int cx24110_pll_write(struct dvb_frontend* fe, u32 data);
+
+#endif // CX24110_H
diff -Nru a/drivers/media/dvb/frontends/dib3000-common.c b/drivers/media/dvb/frontends/dib3000-common.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/dib3000-common.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,145 @@
+#include "dib3000-common.h"
+
+#ifdef CONFIG_DVB_DIBCOM_DEBUG
+static int debug;
+module_param(debug, int, 0x644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c,4=srch (|-able)).");
+#endif
+#define deb_info(args...) dprintk(0x01,args)
+#define deb_i2c(args...) dprintk(0x02,args)
+#define deb_srch(args...) dprintk(0x04,args)
+
+
+int dib3000_read_reg(struct dib3000_state *state, u16 reg)
+{
+	u8 wb[] = { ((reg >> 8) | 0x80) & 0xff, reg & 0xff };
+	u8 rb[2];
+	struct i2c_msg msg[] = {
+		{ .addr = state->config.demod_address, .flags = 0,        .buf = wb, .len = 2 },
+		{ .addr = state->config.demod_address, .flags = I2C_M_RD, .buf = rb, .len = 2 },
+	};
+
+	if (i2c_transfer(state->i2c, msg, 2) != 2)
+		deb_i2c("i2c read error\n");
+
+	deb_i2c("reading i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,
+			(rb[0] << 8) | rb[1],(rb[0] << 8) | rb[1]);
+
+	return (rb[0] << 8) | rb[1];
+}
+
+int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val)
+{
+	u8 b[] = {
+		(reg >> 8) & 0xff, reg & 0xff,
+		(val >> 8) & 0xff, val & 0xff,
+	};
+	struct i2c_msg msg[] = {
+		{ .addr = state->config.demod_address, .flags = 0, .buf = b, .len = 4 }
+	};
+	deb_i2c("writing i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,val,val);
+
+	return i2c_transfer(state->i2c,msg, 1) != 1 ? -EREMOTEIO : 0;
+}
+
+int dib3000_init_pid_list(struct dib3000_state *state, int num)
+{
+	int i;
+	if (state != NULL) {
+		state->pid_list = kmalloc(sizeof(struct dib3000_pid) * num,GFP_KERNEL);
+		if (state->pid_list == NULL)
+			return -ENOMEM;
+
+		deb_info("initializing %d pids for the pid_list.\n",num);
+		state->pid_list_lock = SPIN_LOCK_UNLOCKED;
+		memset(state->pid_list,0,num*(sizeof(struct dib3000_pid)));
+		for (i=0; i < num; i++) {
+			state->pid_list[i].pid = 0;
+			state->pid_list[i].active = 0;
+		}
+		state->feedcount = 0;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+void dib3000_dealloc_pid_list(struct dib3000_state *state)
+{
+	if (state != NULL && state->pid_list != NULL)
+		kfree(state->pid_list);
+}
+
+/* fetch a pid from pid_list */
+int dib3000_get_pid_index(struct dib3000_pid pid_list[], int num_pids, int pid,
+		spinlock_t *pid_list_lock,int onoff)
+{
+	int i,ret = -1;
+	unsigned long flags;
+
+	spin_lock_irqsave(pid_list_lock,flags);
+	for (i=0; i < num_pids; i++)
+		if (onoff) {
+			if (!pid_list[i].active) {
+				pid_list[i].pid = pid;
+				pid_list[i].active = 1;
+				ret = i;
+				break;
+			}
+		} else {
+			if (pid_list[i].active && pid_list[i].pid == pid) {
+				pid_list[i].pid = 0;
+				pid_list[i].active = 0;
+				ret = i;
+				break;
+			}
+		}
+
+	deb_info("setting pid: %5d %04x at index %d '%s'\n",pid,pid,ret,onoff ? "on" : "off");
+
+	spin_unlock_irqrestore(pid_list_lock,flags);
+	return ret;
+}
+
+int dib3000_search_status(u16 irq,u16 lock)
+{
+	if (irq & 0x02) {
+		if (lock & 0x01) {
+			deb_srch("auto search succeeded\n");
+			return 1; // auto search succeeded
+		} else {
+			deb_srch("auto search not successful\n");
+			return 0; // auto search failed
+		}
+	} else if (irq & 0x01)  {
+		deb_srch("auto search failed\n");
+		return 0; // auto search failed
+	}
+	return -1; // try again
+}
+
+/* for auto search */
+u16 dib3000_seq[2][2][2] =     /* fft,gua,   inv   */
+	{ /* fft */
+		{ /* gua */
+			{ 0, 1 },                   /*  0   0   { 0,1 } */
+			{ 3, 9 },                   /*  0   1   { 0,1 } */
+		},
+		{
+			{ 2, 5 },                   /*  1   0   { 0,1 } */
+			{ 6, 11 },                  /*  1   1   { 0,1 } */
+		}
+	};
+
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de");
+MODULE_DESCRIPTION("Common functions for the dib3000mb/dib3000mc dvb frontend drivers");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(dib3000_seq);
+
+EXPORT_SYMBOL(dib3000_read_reg);
+EXPORT_SYMBOL(dib3000_write_reg);
+EXPORT_SYMBOL(dib3000_init_pid_list);
+EXPORT_SYMBOL(dib3000_dealloc_pid_list);
+EXPORT_SYMBOL(dib3000_get_pid_index);
+EXPORT_SYMBOL(dib3000_search_status);
diff -Nru a/drivers/media/dvb/frontends/dib3000-common.h b/drivers/media/dvb/frontends/dib3000-common.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/dib3000-common.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,153 @@
+/*
+ * .h-files for the common use of the frontend drivers made by DiBcom
+ * DiBcom 3000-MB/MC/P
+ *
+ * DiBcom (http://www.dibcom.fr/)
+ *
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ *
+ * based on GPL code from DibCom, which has
+ *
+ * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ *
+ *	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, version 2.
+ *
+ * Acknowledgements
+ *
+ *  Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
+ *  sources, on which this driver (and the dvb-dibusb) are based.
+ *
+ * see Documentation/dvb/README.dibusb for more information
+ *
+ */
+
+#ifndef DIB3000_COMMON_H
+#define DIB3000_COMMON_H
+
+#include "dvb_frontend.h"
+#include "dib3000.h"
+
+/* info and err, taken from usb.h, if there is anything available like by default,
+ * please change !
+ */
+#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg)
+#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg)
+
+/* a PID for the pid_filter list, when in use */
+struct dib3000_pid
+{
+	u16 pid;
+	int active;
+};
+
+/* frontend state */
+struct dib3000_state {
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+/* configuration settings */
+	struct dib3000_config config;
+
+	spinlock_t pid_list_lock;
+	struct dib3000_pid *pid_list;
+
+	int feedcount;
+
+	struct dvb_frontend frontend;
+	int timing_offset;
+	int timing_offset_comp_done;
+};
+
+/* commonly used methods by the dib3000mb/mc/p frontend */
+extern int dib3000_read_reg(struct dib3000_state *state, u16 reg);
+extern int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val);
+
+extern int dib3000_init_pid_list(struct dib3000_state *state, int num);
+extern void dib3000_dealloc_pid_list(struct dib3000_state *state);
+extern int dib3000_get_pid_index(struct dib3000_pid pid_list[], int num_pids,
+	int pid, spinlock_t *pid_list_lock,int onoff);
+
+extern int dib3000_search_status(u16 irq,u16 lock);
+
+/* handy shortcuts */
+#define rd(reg) dib3000_read_reg(state,reg)
+
+#define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \
+	{ err("while sending 0x%04x to 0x%04x.",val,reg); return -EREMOTEIO; }
+
+#define wr_foreach(a,v) { int i; \
+	if (sizeof(a) != sizeof(v)) \
+		err("sizeof: %d %d is different",sizeof(a),sizeof(v));\
+	for (i=0; i < sizeof(a)/sizeof(u16); i++) \
+		wr(a[i],v[i]); \
+	}
+
+#define set_or(reg,val) wr(reg,rd(reg) | val)
+
+#define set_and(reg,val) wr(reg,rd(reg) & val)
+
+
+/* debug */
+
+#ifdef CONFIG_DVB_DIBCOM_DEBUG
+#define dprintk(level,args...) \
+    do { if ((debug & level)) { printk(args); } } while (0)
+#else
+#define dprintk(args...) do { } while (0)
+#endif
+
+/* mask for enabling a specific pid for the pid_filter */
+#define DIB3000_ACTIVATE_PID_FILTERING	(0x2000)
+
+/* common values for tuning */
+#define DIB3000_ALPHA_0					(     0)
+#define DIB3000_ALPHA_1					(     1)
+#define DIB3000_ALPHA_2					(     2)
+#define DIB3000_ALPHA_4					(     4)
+
+#define DIB3000_CONSTELLATION_QPSK		(     0)
+#define DIB3000_CONSTELLATION_16QAM		(     1)
+#define DIB3000_CONSTELLATION_64QAM		(     2)
+
+#define DIB3000_GUARD_TIME_1_32			(     0)
+#define DIB3000_GUARD_TIME_1_16			(     1)
+#define DIB3000_GUARD_TIME_1_8			(     2)
+#define DIB3000_GUARD_TIME_1_4			(     3)
+
+#define DIB3000_TRANSMISSION_MODE_2K	(     0)
+#define DIB3000_TRANSMISSION_MODE_8K	(     1)
+
+#define DIB3000_SELECT_LP				(     0)
+#define DIB3000_SELECT_HP				(     1)
+
+#define DIB3000_FEC_1_2					(     1)
+#define DIB3000_FEC_2_3					(     2)
+#define DIB3000_FEC_3_4					(     3)
+#define DIB3000_FEC_5_6					(     5)
+#define DIB3000_FEC_7_8					(     7)
+
+#define DIB3000_HRCH_OFF				(     0)
+#define DIB3000_HRCH_ON					(     1)
+
+#define DIB3000_DDS_INVERSION_OFF		(     0)
+#define DIB3000_DDS_INVERSION_ON		(     1)
+
+#define DIB3000_TUNER_WRITE_ENABLE(a)	(0xffff & (a << 7))
+#define DIB3000_TUNER_WRITE_DISABLE(a)	(0xffff & ((a << 7) | (1 << 7)))
+
+/* for auto search */
+extern u16 dib3000_seq[2][2][2];
+
+#define DIB3000_REG_MANUFACTOR_ID		(  1025)
+#define DIB3000_I2C_ID_DIBCOM			(0x01b3)
+
+#define DIB3000_REG_DEVICE_ID			(  1026)
+#define DIB3000MB_DEVICE_ID				(0x3000)
+#define DIB3000MC_DEVICE_ID				(0x3001)
+#define DIB3000P_DEVICE_ID				(0x3002)
+
+#endif // DIB3000_COMMON_H
diff -Nru a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/dib3000.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,55 @@
+/*
+ * public header file of the frontend drivers for mobile DVB-T demodulators
+ * DiBcom 3000-MB and DiBcom 3000-MC/P (http://www.dibcom.fr/)
+ *
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ *
+ * based on GPL code from DibCom, which has
+ *
+ * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ *
+ *	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, version 2.
+ *
+ * Acknowledgements
+ *
+ *  Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
+ *  sources, on which this driver (and the dvb-dibusb) are based.
+ *
+ * see Documentation/dvb/README.dibusb for more information
+ *
+ */
+
+#ifndef DIB3000_H
+#define DIB3000_H
+
+#include <linux/dvb/frontend.h>
+
+struct dib3000_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* The i2c address of the PLL */
+	u8 pll_addr;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend *fe);
+	int (*pll_set)(struct dvb_frontend *fe, struct dvb_frontend_parameters* params);
+};
+
+struct dib3000_xfer_ops
+{
+	/* pid and transfer handling is done in the demodulator */
+	int (*pid_parse)(struct dvb_frontend *fe, int onoff);
+	int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
+	int (*pid_ctrl)(struct dvb_frontend *fe, int pid, int onoff);
+};
+
+extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
+					     struct i2c_adapter* i2c, struct dib3000_xfer_ops *xfer_ops);
+
+extern struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
+					     struct i2c_adapter* i2c, struct dib3000_xfer_ops *xfer_ops);
+#endif // DIB3000_H
diff -Nru a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/dib3000mb.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,833 @@
+/*
+ * Frontend driver for mobile DVB-T demodulator DiBcom 3000-MB
+ * DiBcom (http://www.dibcom.fr/)
+ *
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ *
+ * based on GPL code from DibCom, which has
+ *
+ * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ *
+ *	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, version 2.
+ *
+ * Acknowledgements
+ *
+ *  Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
+ *  sources, on which this driver (and the dvb-dibusb) are based.
+ *
+ * see Documentation/dvb/README.dibusb for more information
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+
+#include "dvb_frontend.h"
+#include "dib3000-common.h"
+#include "dib3000mb_priv.h"
+#include "dib3000.h"
+
+/* Version information */
+#define DRIVER_VERSION "0.1"
+#define DRIVER_DESC "DiBcom 3000-MB DVB-T demodulator driver"
+#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
+
+#ifdef CONFIG_DVB_DIBCOM_DEBUG
+static int debug;
+module_param(debug, int, 0x644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able)).");
+#endif
+#define deb_info(args...) dprintk(0x01,args)
+#define deb_xfer(args...) dprintk(0x02,args)
+#define deb_setf(args...) dprintk(0x04,args)
+#define deb_getf(args...) dprintk(0x08,args)
+
+static int dib3000mb_get_frontend(struct dvb_frontend* fe,
+				  struct dvb_frontend_parameters *fep);
+
+static int dib3000mb_set_frontend(struct dvb_frontend* fe,
+		struct dvb_frontend_parameters *fep, int tuner)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+	struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
+	fe_code_rate_t fe_cr = FEC_NONE;
+	int search_state,seq;
+
+	if (tuner) {
+		wr(DIB3000MB_REG_TUNER,
+				DIB3000_TUNER_WRITE_ENABLE(state->config.pll_addr));
+		state->config.pll_set(fe, fep);
+		wr(DIB3000MB_REG_TUNER,
+				DIB3000_TUNER_WRITE_DISABLE(state->config.pll_addr));
+
+		deb_setf("bandwidth: ");
+		switch (ofdm->bandwidth) {
+			case BANDWIDTH_8_MHZ:
+				deb_setf("8 MHz\n");
+				wr_foreach(dib3000mb_reg_timing_freq,dib3000mb_timing_freq[2]);
+				wr_foreach(dib3000mb_reg_bandwidth,dib3000mb_bandwidth_8mhz);
+				break;
+			case BANDWIDTH_7_MHZ:
+				deb_setf("7 MHz\n");
+				wr_foreach(dib3000mb_reg_timing_freq,dib3000mb_timing_freq[1]);
+				wr_foreach(dib3000mb_reg_bandwidth,dib3000mb_bandwidth_7mhz);
+				break;
+			case BANDWIDTH_6_MHZ:
+				deb_setf("6 MHz\n");
+				wr_foreach(dib3000mb_reg_timing_freq,dib3000mb_timing_freq[0]);
+				wr_foreach(dib3000mb_reg_bandwidth,dib3000mb_bandwidth_6mhz);
+				break;
+			case BANDWIDTH_AUTO:
+				return -EOPNOTSUPP;
+			default:
+				err("unkown bandwidth value.");
+				return -EINVAL;
+		}
+	}
+	wr(DIB3000MB_REG_LOCK1_MASK,DIB3000MB_LOCK1_SEARCH_4);
+
+	deb_setf("transmission mode: ");
+	switch (ofdm->transmission_mode) {
+		case TRANSMISSION_MODE_2K:
+			deb_setf("2k\n");
+			wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K);
+			break;
+		case TRANSMISSION_MODE_8K:
+			deb_setf("8k\n");
+			wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_8K);
+			break;
+		case TRANSMISSION_MODE_AUTO:
+			deb_setf("auto\n");
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	deb_setf("guard: ");
+	switch (ofdm->guard_interval) {
+		case GUARD_INTERVAL_1_32:
+			deb_setf("1_32\n");
+			wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32);
+			break;
+		case GUARD_INTERVAL_1_16:
+			deb_setf("1_16\n");
+			wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_16);
+			break;
+		case GUARD_INTERVAL_1_8:
+			deb_setf("1_8\n");
+			wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_8);
+			break;
+		case GUARD_INTERVAL_1_4:
+			deb_setf("1_4\n");
+			wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_4);
+			break;
+		case GUARD_INTERVAL_AUTO:
+			deb_setf("auto\n");
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	deb_setf("inversion: ");
+	switch (fep->inversion) {
+		case INVERSION_OFF:
+			deb_setf("off\n");
+			wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF);
+			break;
+		case INVERSION_AUTO:
+			deb_setf("auto ");
+			break;
+		case INVERSION_ON:
+			deb_setf("on\n");
+			wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_ON);
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	deb_setf("constellation: ");
+	switch (ofdm->constellation) {
+		case QPSK:
+			deb_setf("qpsk\n");
+			wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK);
+			break;
+		case QAM_16:
+			deb_setf("qam16\n");
+			wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_16QAM);
+			break;
+		case QAM_64:
+			deb_setf("qam64\n");
+			wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_64QAM);
+			break;
+		case QAM_AUTO:
+			break;
+		default:
+			return -EINVAL;
+	}
+	deb_setf("hierachy: ");	
+	switch (ofdm->hierarchy_information) {
+		case HIERARCHY_NONE:
+			deb_setf("none ");
+			/* fall through */
+		case HIERARCHY_1:
+			deb_setf("alpha=1\n");	
+			wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_1);
+			break;
+		case HIERARCHY_2:
+			deb_setf("alpha=2\n");	
+			wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_2);
+			break;
+		case HIERARCHY_4:
+			deb_setf("alpha=4\n");	
+			wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_4);
+			break;
+		case HIERARCHY_AUTO:
+			deb_setf("alpha=auto\n");	
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	deb_setf("hierarchy: ");
+	if (ofdm->hierarchy_information == HIERARCHY_NONE) {
+		deb_setf("none\n");
+		wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF);
+		wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP);
+		fe_cr = ofdm->code_rate_HP;
+	} else if (ofdm->hierarchy_information != HIERARCHY_AUTO) {
+		deb_setf("on\n");
+		wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON);
+		wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP);
+		fe_cr = ofdm->code_rate_LP;
+	}
+	deb_setf("fec: ");
+	switch (fe_cr) {
+		case FEC_1_2:
+			deb_setf("1_2\n");
+			wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_1_2);
+			break;
+		case FEC_2_3:
+			deb_setf("2_3\n");
+			wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_2_3);
+			break;
+		case FEC_3_4:
+			deb_setf("3_4\n");
+			wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_3_4);
+			break;
+		case FEC_5_6:
+			deb_setf("5_6\n");
+			wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_5_6);
+			break;
+		case FEC_7_8:
+			deb_setf("7_8\n");
+			wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_7_8);
+			break;
+		case FEC_NONE:
+			deb_setf("none ");
+			break;
+		case FEC_AUTO:
+			deb_setf("auto\n");
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	seq = dib3000_seq
+		[ofdm->transmission_mode == TRANSMISSION_MODE_AUTO]
+		[ofdm->guard_interval == GUARD_INTERVAL_AUTO]
+		[fep->inversion == INVERSION_AUTO];
+
+	deb_setf("seq? %d\n",seq);
+
+	wr(DIB3000MB_REG_SEQ,seq);
+
+	wr(DIB3000MB_REG_ISI,seq ? DIB3000MB_ISI_INHIBIT : DIB3000MB_ISI_ACTIVATE);
+
+	if (ofdm->transmission_mode == TRANSMISSION_MODE_2K) {
+		if (ofdm->guard_interval == GUARD_INTERVAL_1_8) {
+			wr(DIB3000MB_REG_SYNC_IMPROVEMENT,DIB3000MB_SYNC_IMPROVE_2K_1_8);
+		} else {
+			wr(DIB3000MB_REG_SYNC_IMPROVEMENT,DIB3000MB_SYNC_IMPROVE_DEFAULT);
+		}
+
+		wr(DIB3000MB_REG_UNK_121,DIB3000MB_UNK_121_2K);
+	} else {
+		wr(DIB3000MB_REG_UNK_121,DIB3000MB_UNK_121_DEFAULT);
+	}
+
+	wr(DIB3000MB_REG_MOBILE_ALGO,DIB3000MB_MOBILE_ALGO_OFF);
+	wr(DIB3000MB_REG_MOBILE_MODE_QAM,DIB3000MB_MOBILE_MODE_QAM_OFF);
+	wr(DIB3000MB_REG_MOBILE_MODE,DIB3000MB_MOBILE_MODE_OFF);
+
+	wr_foreach(dib3000mb_reg_agc_bandwidth,dib3000mb_agc_bandwidth_high);
+
+	wr(DIB3000MB_REG_ISI,DIB3000MB_ISI_ACTIVATE);
+
+	wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_AGC+DIB3000MB_RESTART_CTRL);
+	wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_OFF);
+
+	/* wait for AGC lock */
+	msleep(70);
+
+	wr_foreach(dib3000mb_reg_agc_bandwidth,dib3000mb_agc_bandwidth_low);
+
+	/* something has to be auto searched */
+	if (ofdm->constellation == QAM_AUTO ||
+		ofdm->hierarchy_information == HIERARCHY_AUTO ||
+		fe_cr == FEC_AUTO ||
+		fep->inversion == INVERSION_AUTO) {
+		int as_count=0;
+
+		deb_setf("autosearch enabled.\n");	
+
+		wr(DIB3000MB_REG_ISI,DIB3000MB_ISI_INHIBIT);
+
+		wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_AUTO_SEARCH);
+		wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_OFF);
+
+		while ((search_state =
+				dib3000_search_status(
+					rd(DIB3000MB_REG_AS_IRQ_PENDING),
+					rd(DIB3000MB_REG_LOCK2_VALUE))) < 0 && as_count++ < 100)
+			msleep(1);
+
+		deb_info("search_state after autosearch %d after %d checks\n",search_state,as_count);
+
+		if (search_state == 1) {
+			struct dvb_frontend_parameters feps;
+			if (dib3000mb_get_frontend(fe, &feps) == 0) {
+				deb_setf("reading tuning data from frontend succeeded.\n");
+				return dib3000mb_set_frontend(fe, &feps, 0);
+			}
+		}
+
+	} else {
+		wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_CTRL);
+		wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_OFF);
+	}
+
+	return 0;
+}
+
+static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	wr(DIB3000MB_REG_POWER_CONTROL,DIB3000MB_POWER_UP);
+
+	wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_AGC);
+
+	wr(DIB3000MB_REG_RESET_DEVICE,DIB3000MB_RESET_DEVICE);
+	wr(DIB3000MB_REG_RESET_DEVICE,DIB3000MB_RESET_DEVICE_RST);
+
+	wr(DIB3000MB_REG_CLOCK,DIB3000MB_CLOCK_DEFAULT);
+
+	wr(DIB3000MB_REG_ELECT_OUT_MODE,DIB3000MB_ELECT_OUT_MODE_ON);
+
+	wr(DIB3000MB_REG_DDS_FREQ_MSB,DIB3000MB_DDS_FREQ_MSB);
+	wr(DIB3000MB_REG_DDS_FREQ_LSB,DIB3000MB_DDS_FREQ_LSB);
+
+	wr_foreach(dib3000mb_reg_timing_freq,dib3000mb_timing_freq[2]);
+
+	wr_foreach(dib3000mb_reg_impulse_noise,
+			dib3000mb_impulse_noise_values[DIB3000MB_IMPNOISE_OFF]);
+
+	wr_foreach(dib3000mb_reg_agc_gain,dib3000mb_default_agc_gain);
+
+	wr(DIB3000MB_REG_PHASE_NOISE,DIB3000MB_PHASE_NOISE_DEFAULT);
+
+	wr_foreach(dib3000mb_reg_phase_noise, dib3000mb_default_noise_phase);
+
+	wr_foreach(dib3000mb_reg_lock_duration,dib3000mb_default_lock_duration);
+
+	wr_foreach(dib3000mb_reg_agc_bandwidth,dib3000mb_agc_bandwidth_low);
+
+	wr(DIB3000MB_REG_LOCK0_MASK,DIB3000MB_LOCK0_DEFAULT);
+	wr(DIB3000MB_REG_LOCK1_MASK,DIB3000MB_LOCK1_SEARCH_4);
+	wr(DIB3000MB_REG_LOCK2_MASK,DIB3000MB_LOCK2_DEFAULT);
+	wr(DIB3000MB_REG_SEQ, dib3000_seq[1][1][1]);
+
+	wr_foreach(dib3000mb_reg_bandwidth,dib3000mb_bandwidth_8mhz);
+
+	wr(DIB3000MB_REG_UNK_68,DIB3000MB_UNK_68);
+	wr(DIB3000MB_REG_UNK_69,DIB3000MB_UNK_69);
+	wr(DIB3000MB_REG_UNK_71,DIB3000MB_UNK_71);
+	wr(DIB3000MB_REG_UNK_77,DIB3000MB_UNK_77);
+	wr(DIB3000MB_REG_UNK_78,DIB3000MB_UNK_78);
+	wr(DIB3000MB_REG_ISI,DIB3000MB_ISI_INHIBIT);
+	wr(DIB3000MB_REG_UNK_92,DIB3000MB_UNK_92);
+	wr(DIB3000MB_REG_UNK_96,DIB3000MB_UNK_96);
+	wr(DIB3000MB_REG_UNK_97,DIB3000MB_UNK_97);
+	wr(DIB3000MB_REG_UNK_106,DIB3000MB_UNK_106);
+	wr(DIB3000MB_REG_UNK_107,DIB3000MB_UNK_107);
+	wr(DIB3000MB_REG_UNK_108,DIB3000MB_UNK_108);
+	wr(DIB3000MB_REG_UNK_122,DIB3000MB_UNK_122);
+	wr(DIB3000MB_REG_MOBILE_MODE_QAM,DIB3000MB_MOBILE_MODE_QAM_OFF);
+	wr(DIB3000MB_REG_BERLEN,DIB3000MB_BERLEN_DEFAULT);
+
+	wr_foreach(dib3000mb_reg_filter_coeffs,dib3000mb_filter_coeffs);
+
+	wr(DIB3000MB_REG_MOBILE_ALGO,DIB3000MB_MOBILE_ALGO_ON);
+	wr(DIB3000MB_REG_MULTI_DEMOD_MSB,DIB3000MB_MULTI_DEMOD_MSB);
+	wr(DIB3000MB_REG_MULTI_DEMOD_LSB,DIB3000MB_MULTI_DEMOD_LSB);
+
+	wr(DIB3000MB_REG_OUTPUT_MODE,DIB3000MB_OUTPUT_MODE_SLAVE);
+
+	wr(DIB3000MB_REG_FIFO_142,DIB3000MB_FIFO_142);
+	wr(DIB3000MB_REG_MPEG2_OUT_MODE,DIB3000MB_MPEG2_OUT_MODE_188);
+	wr(DIB3000MB_REG_PID_PARSE, DIB3000MB_PID_PARSE_ACTIVATE);
+	wr(DIB3000MB_REG_FIFO,DIB3000MB_FIFO_INHIBIT);
+	wr(DIB3000MB_REG_FIFO_146,DIB3000MB_FIFO_146);
+	wr(DIB3000MB_REG_FIFO_147,DIB3000MB_FIFO_147);
+
+	wr(DIB3000MB_REG_DATA_IN_DIVERSITY,DIB3000MB_DATA_DIVERSITY_IN_OFF);
+
+	if (state->config.pll_init) {
+		wr(DIB3000MB_REG_TUNER,
+			DIB3000_TUNER_WRITE_ENABLE(state->config.pll_addr));
+		state->config.pll_init(fe);
+		wr(DIB3000MB_REG_TUNER,
+			DIB3000_TUNER_WRITE_DISABLE(state->config.pll_addr));
+	}
+
+	return 0;
+}
+
+static int dib3000mb_get_frontend(struct dvb_frontend* fe,
+				  struct dvb_frontend_parameters *fep)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+	struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
+	fe_code_rate_t *cr;
+	u16 tps_val;
+	int inv_test1,inv_test2;
+	u32 dds_val, threshold = 0x800000;
+
+	if (!rd(DIB3000MB_REG_TPS_LOCK))
+		return 0;
+
+	dds_val = ((rd(DIB3000MB_REG_DDS_VALUE_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_VALUE_LSB);
+	if (dds_val < threshold)
+		inv_test1 = 0;
+	else if (dds_val == threshold)
+		inv_test1 = 1;
+	else
+		inv_test1 = 2;
+
+	dds_val = ((rd(DIB3000MB_REG_DDS_FREQ_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_FREQ_LSB);
+	if (dds_val < threshold)
+		inv_test2 = 0;
+	else if (dds_val == threshold)
+		inv_test2 = 1;
+	else
+		inv_test2 = 2;
+
+	fep->inversion =
+		((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) ||
+		((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ?
+		INVERSION_ON : INVERSION_OFF;
+
+	deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, fep->inversion);
+
+	switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) {
+		case DIB3000_CONSTELLATION_QPSK:
+			deb_getf("QPSK ");
+			ofdm->constellation = QPSK;
+			break;
+		case DIB3000_CONSTELLATION_16QAM:
+			deb_getf("QAM16 ");
+			ofdm->constellation = QAM_16;
+			break;
+		case DIB3000_CONSTELLATION_64QAM:
+			deb_getf("QAM64 ");
+			ofdm->constellation = QAM_64;
+			break;
+		default:
+			err("Unexpected constellation returned by TPS (%d)", tps_val);
+			break;
+ 	}
+	deb_getf("TPS: %d\n", tps_val);
+
+	if (rd(DIB3000MB_REG_TPS_HRCH)) {
+		deb_getf("HRCH ON\n");
+		cr = &ofdm->code_rate_LP;
+		ofdm->code_rate_HP = FEC_NONE;
+		switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) {
+			case DIB3000_ALPHA_0:
+				deb_getf("HIERARCHY_NONE ");
+				ofdm->hierarchy_information = HIERARCHY_NONE;
+				break;
+			case DIB3000_ALPHA_1:
+				deb_getf("HIERARCHY_1 ");
+				ofdm->hierarchy_information = HIERARCHY_1;
+				break;
+			case DIB3000_ALPHA_2:
+				deb_getf("HIERARCHY_2 ");
+				ofdm->hierarchy_information = HIERARCHY_2;
+				break;
+			case DIB3000_ALPHA_4:
+				deb_getf("HIERARCHY_4 ");
+				ofdm->hierarchy_information = HIERARCHY_4;
+				break;
+			default:
+				err("Unexpected ALPHA value returned by TPS (%d)", tps_val);
+				break;
+		}
+		deb_getf("TPS: %d\n", tps_val);
+
+		tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_LP);
+	} else {
+		deb_getf("HRCH OFF\n");
+		cr = &ofdm->code_rate_HP;
+		ofdm->code_rate_LP = FEC_NONE;
+		ofdm->hierarchy_information = HIERARCHY_NONE;
+
+		tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_HP);
+	}
+
+	switch (tps_val) {
+		case DIB3000_FEC_1_2:
+			deb_getf("FEC_1_2 ");
+			*cr = FEC_1_2;
+			break;
+		case DIB3000_FEC_2_3:
+			deb_getf("FEC_2_3 ");
+			*cr = FEC_2_3;
+			break;
+		case DIB3000_FEC_3_4:
+			deb_getf("FEC_3_4 ");
+			*cr = FEC_3_4;
+			break;
+		case DIB3000_FEC_5_6:
+			deb_getf("FEC_5_6 ");
+			*cr = FEC_4_5;
+			break;
+		case DIB3000_FEC_7_8:
+			deb_getf("FEC_7_8 ");
+			*cr = FEC_7_8;
+			break;
+		default:
+			err("Unexpected FEC returned by TPS (%d)", tps_val);
+			break;
+	}
+	deb_getf("TPS: %d\n",tps_val);
+
+	switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) {
+		case DIB3000_GUARD_TIME_1_32:
+			deb_getf("GUARD_INTERVAL_1_32 ");
+			ofdm->guard_interval = GUARD_INTERVAL_1_32;
+			break;
+		case DIB3000_GUARD_TIME_1_16:
+			deb_getf("GUARD_INTERVAL_1_16 ");
+			ofdm->guard_interval = GUARD_INTERVAL_1_16;
+			break;
+		case DIB3000_GUARD_TIME_1_8:
+			deb_getf("GUARD_INTERVAL_1_8 ");
+			ofdm->guard_interval = GUARD_INTERVAL_1_8;
+			break;
+		case DIB3000_GUARD_TIME_1_4:
+			deb_getf("GUARD_INTERVAL_1_4 ");
+			ofdm->guard_interval = GUARD_INTERVAL_1_4;
+			break;
+		default:
+			err("Unexpected Guard Time returned by TPS (%d)", tps_val);
+			break;
+	}
+	deb_getf("TPS: %d\n", tps_val);
+
+	switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) {
+		case DIB3000_TRANSMISSION_MODE_2K:
+			deb_getf("TRANSMISSION_MODE_2K ");
+			ofdm->transmission_mode = TRANSMISSION_MODE_2K;
+			break;
+		case DIB3000_TRANSMISSION_MODE_8K:
+			deb_getf("TRANSMISSION_MODE_8K ");
+			ofdm->transmission_mode = TRANSMISSION_MODE_8K;
+			break;
+		default:
+			err("unexpected transmission mode return by TPS (%d)", tps_val);
+			break;
+	}
+	deb_getf("TPS: %d\n", tps_val);
+
+	return 0;
+}
+
+static int dib3000mb_read_status(struct dvb_frontend* fe, fe_status_t *stat)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	*stat = 0;
+
+	if (rd(DIB3000MB_REG_AGC_LOCK))
+		*stat |= FE_HAS_SIGNAL;
+	if (rd(DIB3000MB_REG_CARRIER_LOCK))
+		*stat |= FE_HAS_CARRIER;
+	if (rd(DIB3000MB_REG_VIT_LCK))
+		*stat |= FE_HAS_VITERBI;
+	if (rd(DIB3000MB_REG_TS_SYNC_LOCK))
+		*stat |= (FE_HAS_SYNC | FE_HAS_LOCK);
+
+	deb_info("actual status is %2x\n",*stat);
+
+	deb_getf("tps %x %x %x %x %x\n",
+			rd(DIB3000MB_REG_TPS_1),
+			rd(DIB3000MB_REG_TPS_2),
+			rd(DIB3000MB_REG_TPS_3),
+			rd(DIB3000MB_REG_TPS_4),
+			rd(DIB3000MB_REG_TPS_5));
+	
+	deb_info("autoval: tps: %d, qam: %d, hrch: %d, alpha: %d, hp: %d, lp: %d, guard: %d, fft: %d cell: %d\n",
+			rd(DIB3000MB_REG_TPS_LOCK),
+			rd(DIB3000MB_REG_TPS_QAM),
+			rd(DIB3000MB_REG_TPS_HRCH),
+			rd(DIB3000MB_REG_TPS_VIT_ALPHA),
+			rd(DIB3000MB_REG_TPS_CODE_RATE_HP),
+			rd(DIB3000MB_REG_TPS_CODE_RATE_LP),
+			rd(DIB3000MB_REG_TPS_GUARD_TIME),
+			rd(DIB3000MB_REG_TPS_FFT),
+			rd(DIB3000MB_REG_TPS_CELL_ID));
+
+	//*stat = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+	return 0;
+}
+
+static int dib3000mb_read_ber(struct dvb_frontend* fe, u32 *ber)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	*ber = ((rd(DIB3000MB_REG_BER_MSB) << 16) | rd(DIB3000MB_REG_BER_LSB) );
+	return 0;
+}
+/*
+ * Amaury:
+ * signal strength is measured with dBm (power compared to mW)
+ * the standard range is -90dBm(low power) to -10 dBm (strong power),
+ * but the calibration is done for -100 dBm to 0dBm
+ */
+
+#define DIB3000MB_AGC_REF_dBm		-14
+#define DIB3000MB_GAIN_SLOPE_dBm	100
+#define DIB3000MB_GAIN_DELTA_dBm	-2
+static int dib3000mb_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+/* TODO log10 
+	u16 sigpow = rd(DIB3000MB_REG_SIGNAL_POWER), 
+		n_agc_power = rd(DIB3000MB_REG_AGC_POWER),
+		rf_power = rd(DIB3000MB_REG_RF_POWER);
+	double rf_power_dBm, ad_power_dBm, minar_power_dBm;
+	
+	if (n_agc_power == 0 )
+		n_agc_power = 1 ;
+
+	ad_power_dBm    = 10 * log10 ( (float)n_agc_power / (float)(1<<16) );
+	minor_power_dBm = ad_power_dBm - DIB3000MB_AGC_REF_dBm;
+	rf_power_dBm = (-DIB3000MB_GAIN_SLOPE_dBm * (float)rf_power / (float)(1<<16) + 
+			DIB3000MB_GAIN_DELTA_dBm) + minor_power_dBm;
+	// relative rf_power 
+	*strength = (u16) ((rf_power_dBm + 100) / 100 * 0xffff);
+*/
+	*strength = rd(DIB3000MB_REG_SIGNAL_POWER) * 0xffff / 0x170;
+	return 0;
+}
+
+/*
+ * Amaury: 
+ * snr is the signal quality measured in dB.
+ * snr = 10*log10(signal power / noise power)
+ * the best quality is near 35dB (cable transmission & good modulator)
+ * the minimum without errors depend of transmission parameters
+ * some indicative values are given in en300744 Annex A
+ * ex : 16QAM 2/3 (Gaussian)  = 11.1 dB
+ *
+ * If SNR is above 20dB, BER should be always 0.
+ * choose 0dB as the minimum
+ */
+static int dib3000mb_read_snr(struct dvb_frontend* fe, u16 *snr)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+	short sigpow = rd(DIB3000MB_REG_SIGNAL_POWER);
+	int icipow = ((rd(DIB3000MB_REG_NOISE_POWER_MSB) & 0xff) << 16) |
+		rd(DIB3000MB_REG_NOISE_POWER_LSB);
+/*
+	float snr_dBm=0;
+
+	if (sigpow > 0 && icipow > 0)
+		snr_dBm = 10.0 * log10( (float) (sigpow<<8) / (float)icipow )  ;
+	else if (sigpow > 0)
+		snr_dBm = 35;
+	
+	*snr = (u16) ((snr_dBm / 35) * 0xffff);
+*/
+	*snr = (sigpow << 8) / ((icipow > 0) ? icipow : 1);
+	return 0;
+}
+
+static int dib3000mb_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	*unc = rd(DIB3000MB_REG_UNC);
+	return 0;
+}
+
+static int dib3000mb_sleep(struct dvb_frontend* fe)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	wr(DIB3000MB_REG_POWER_CONTROL,DIB3000MB_POWER_DOWN);
+	return 0;
+}
+
+static int dib3000mb_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
+{
+	tune->min_delay_ms = 800;
+	tune->step_size = 166667;
+	tune->max_drift = 166667*2;
+					
+	return 0;
+}
+
+static int dib3000mb_fe_init_nonmobile(struct dvb_frontend* fe)
+{
+	return dib3000mb_fe_init(fe, 0);
+}
+
+static int dib3000mb_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep)
+{
+	return dib3000mb_set_frontend(fe, fep, 1);
+}
+
+static void dib3000mb_release(struct dvb_frontend* fe)
+{
+	struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv;
+	kfree(state);
+}
+
+/* pid filter and transfer stuff */
+static int dib3000mb_pid_control(struct dvb_frontend *fe,int pid,int onoff)
+{
+	struct dib3000_state *state = fe->demodulator_priv;
+	int index = dib3000_get_pid_index(state->pid_list, DIB3000MB_NUM_PIDS, pid, &state->pid_list_lock,onoff);
+	pid = (onoff ? pid | DIB3000_ACTIVATE_PID_FILTERING : 0);
+
+	if (index >= 0) {
+		wr(index+DIB3000MB_REG_FIRST_PID,pid);
+	} else {
+		err("no more pids for filtering.");
+		return -ENOMEM;
+	}
+	return 0;
+}
+
+static int dib3000mb_fifo_control(struct dvb_frontend *fe, int onoff)
+{
+	struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv;
+
+	deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling");
+	if (onoff) {
+		wr(DIB3000MB_REG_FIFO, DIB3000MB_FIFO_ACTIVATE);
+	} else {
+		wr(DIB3000MB_REG_FIFO, DIB3000MB_FIFO_INHIBIT);
+	}
+	return 0;
+	}
+
+static int dib3000mb_pid_parse(struct dvb_frontend *fe, int onoff)
+{
+	//struct dib3000_state *state = fe->demodulator_priv;
+	/* switch it off and on */
+	return 0;
+	}
+
+static struct dvb_frontend_ops dib3000mb_ops;
+
+struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
+				      struct i2c_adapter* i2c, struct dib3000_xfer_ops *xfer_ops)
+{
+	struct dib3000_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct dib3000_state*) kmalloc(sizeof(struct dib3000_state), GFP_KERNEL);
+	if (state == NULL)
+		goto error;
+
+	/* setup the state */
+	state->i2c = i2c;
+	memcpy(&state->config,config,sizeof(struct dib3000_config));
+	memcpy(&state->ops, &dib3000mb_ops, sizeof(struct dvb_frontend_ops));
+
+	/* check for the correct demod */
+	if (rd(DIB3000_REG_MANUFACTOR_ID) != DIB3000_I2C_ID_DIBCOM)
+		goto error;
+
+	if (rd(DIB3000_REG_DEVICE_ID) != DIB3000MB_DEVICE_ID)
+		goto error;
+
+	if (dib3000_init_pid_list(state,DIB3000MB_NUM_PIDS))
+		goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+
+	/* set the xfer operations */
+	xfer_ops->pid_parse = dib3000mb_pid_parse;
+	xfer_ops->fifo_ctrl = dib3000mb_fifo_control;
+	xfer_ops->pid_ctrl = dib3000mb_pid_control;
+
+	return &state->frontend;
+
+error:
+	if (state)
+	kfree(state);
+	return NULL;
+	}
+
+static struct dvb_frontend_ops dib3000mb_ops = {
+
+	.info = {
+		.name			= "DiBcom 3000-MB DVB-T",
+		.type 			= FE_OFDM,
+		.frequency_min 		= 44250000,
+		.frequency_max 		= 867250000,
+		.frequency_stepsize	= 62500,
+		.caps = FE_CAN_INVERSION_AUTO |
+				FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+				FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+				FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+				FE_CAN_TRANSMISSION_MODE_AUTO |
+				FE_CAN_GUARD_INTERVAL_AUTO |
+				FE_CAN_HIERARCHY_AUTO,
+	},
+
+	.release = dib3000mb_release,
+
+	.init = dib3000mb_fe_init_nonmobile,
+	.sleep = dib3000mb_sleep,
+
+	.set_frontend = dib3000mb_set_frontend_and_tuner,
+	.get_frontend = dib3000mb_get_frontend,
+	.get_tune_settings = dib3000mb_fe_get_tune_settings,
+
+	.read_status = dib3000mb_read_status,
+	.read_ber = dib3000mb_read_ber,
+	.read_signal_strength = dib3000mb_read_signal_strength,
+	.read_snr = dib3000mb_read_snr,
+	.read_ucblocks = dib3000mb_read_unc_blocks,
+};
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(dib3000mb_attach);
diff -Nru a/drivers/media/dvb/frontends/dib3000mb_priv.h b/drivers/media/dvb/frontends/dib3000mb_priv.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/dib3000mb_priv.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,467 @@
+/*
+ * dib3000mb_priv.h
+ *
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ *
+ *	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, version 2.
+ *
+ * for more information see dib3000mb.c .
+ */
+
+#ifndef __DIB3000MB_PRIV_H_INCLUDED__
+#define __DIB3000MB_PRIV_H_INCLUDED__
+
+/* register addresses and some of their default values */
+
+/* restart subsystems */
+#define DIB3000MB_REG_RESTART			(     0)
+
+#define DIB3000MB_RESTART_OFF			(     0)
+#define DIB3000MB_RESTART_AUTO_SEARCH		(1 << 1)
+#define DIB3000MB_RESTART_CTRL				(1 << 2)
+#define DIB3000MB_RESTART_AGC				(1 << 3)
+
+/* FFT size */
+#define DIB3000MB_REG_FFT				(     1)
+
+/* Guard time */
+#define DIB3000MB_REG_GUARD_TIME		(     2)
+
+/* QAM */
+#define DIB3000MB_REG_QAM				(     3)
+
+/* Alpha coefficient high priority Viterbi algorithm */
+#define DIB3000MB_REG_VIT_ALPHA			(     4)
+
+/* spectrum inversion */
+#define DIB3000MB_REG_DDS_INV			(     5)
+
+/* DDS frequency value (IF position) ad ? values don't match reg_3000mb.txt */
+#define DIB3000MB_REG_DDS_FREQ_MSB		(     6)
+#define DIB3000MB_REG_DDS_FREQ_LSB		(     7)
+#define DIB3000MB_DDS_FREQ_MSB				(   178)
+#define DIB3000MB_DDS_FREQ_LSB				(  8990)
+
+/* timing frequency (carrier spacing) */
+static u16 dib3000mb_reg_timing_freq[] = { 8,9 };
+static u16 dib3000mb_timing_freq[][2] = {
+	{ 126 , 48873 }, /* 6 MHz */
+	{ 147 , 57019 }, /* 7 MHz */
+	{ 168 , 65164 }, /* 8 MHz */
+};
+
+/* impulse noise parameter */
+/* 36 ??? */
+
+static u16 dib3000mb_reg_impulse_noise[] = { 10,11,12,15,36 };
+
+enum dib3000mb_impulse_noise_type {
+	DIB3000MB_IMPNOISE_OFF,
+	DIB3000MB_IMPNOISE_MOBILE,
+	DIB3000MB_IMPNOISE_FIXED,
+	DIB3000MB_IMPNOISE_DEFAULT
+};
+
+static u16 dib3000mb_impulse_noise_values[][5] = {
+	{ 0x0000, 0x0004, 0x0014, 0x01ff, 0x0399 }, /* off */
+	{ 0x0001, 0x0004, 0x0014, 0x01ff, 0x037b }, /* mobile */
+	{ 0x0001, 0x0004, 0x0020, 0x01bd, 0x0399 }, /* fixed */
+	{ 0x0000, 0x0002, 0x000a, 0x01ff, 0x0399 }, /* default */
+};
+
+/*
+ * Dual Automatic-Gain-Control
+ * - gains RF in tuner (AGC1)
+ * - gains IF after filtering (AGC2)
+ */
+
+/* also from 16 to 18 */
+static u16 dib3000mb_reg_agc_gain[] = {
+	19,20,21,22,23,24,25,26,27,28,29,30,31,32
+};
+
+static u16 dib3000mb_default_agc_gain[] =
+	{ 0x0001, 52429,   623, 128, 166, 195, 61,   /* RF ??? */
+	  0x0001, 53766, 38011,   0,  90,  33, 23 }; /* IF ??? */
+
+/* phase noise */
+/* 36 is set when setting the impulse noise */
+static u16 dib3000mb_reg_phase_noise[] = { 33,34,35,37,38 };
+
+static u16 dib3000mb_default_noise_phase[] = { 2, 544, 0, 5, 4 };
+
+/* lock duration */
+static u16 dib3000mb_reg_lock_duration[] = { 39,40 };
+static u16 dib3000mb_default_lock_duration[] = { 135, 135 };
+
+/* AGC loop bandwidth */
+static u16 dib3000mb_reg_agc_bandwidth[] = { 43,44,45,46,47,48,49,50 };
+
+static u16 dib3000mb_agc_bandwidth_low[]  =
+	{ 2088, 10, 2088, 10, 3448, 5, 3448, 5 };
+static u16 dib3000mb_agc_bandwidth_high[] =
+	{ 2349,  5, 2349,  5, 2586, 2, 2586, 2 };
+
+/*
+ * lock0 definition (coff_lock)
+ */
+#define DIB3000MB_REG_LOCK0_MASK		(    51)
+#define DIB3000MB_LOCK0_DEFAULT				(     4)
+
+/*
+ * lock1 definition (cpil_lock)
+ * for auto search
+ * which values hide behind the lock masks
+ */
+#define DIB3000MB_REG_LOCK1_MASK		(    52)
+#define DIB3000MB_LOCK1_SEARCH_4			(0x0004)
+#define DIB3000MB_LOCK1_SEARCH_2048			(0x0800)
+#define DIB3000MB_LOCK1_DEFAULT				(0x0001)
+
+/*
+ * lock2 definition (fec_lock) */
+#define DIB3000MB_REG_LOCK2_MASK		(    53)
+#define DIB3000MB_LOCK2_DEFAULT				(0x0080)
+
+/*
+ * SEQ ? what was that again ... :)
+ * changes when, inversion, guard time and fft is
+ * either automatically detected or not
+ */
+#define DIB3000MB_REG_SEQ				(    54)
+
+/* bandwidth */
+static u16 dib3000mb_reg_bandwidth[] = { 55,56,57,58,59,60,61,62,63,64,65,66,67 };
+static u16 dib3000mb_bandwidth_6mhz[] =
+	{ 0, 33, 53312, 112, 46635, 563, 36565, 0, 1000, 0, 1010, 1, 45264 };
+
+static u16 dib3000mb_bandwidth_7mhz[] =
+	{ 0, 28, 64421,  96, 39973, 483,  3255, 0, 1000, 0, 1010, 1, 45264 };
+
+static u16 dib3000mb_bandwidth_8mhz[] =
+	{ 0, 25, 23600,  84, 34976, 422, 43808, 0, 1000, 0, 1010, 1, 45264 };
+
+#define DIB3000MB_REG_UNK_68				(    68)
+#define DIB3000MB_UNK_68						(     0)
+
+#define DIB3000MB_REG_UNK_69				(    69)
+#define DIB3000MB_UNK_69						(     0)
+
+#define DIB3000MB_REG_UNK_71				(    71)
+#define DIB3000MB_UNK_71						(     0)
+
+#define DIB3000MB_REG_UNK_77				(    77)
+#define DIB3000MB_UNK_77						(     6)
+
+#define DIB3000MB_REG_UNK_78				(    78)
+#define DIB3000MB_UNK_78						(0x0080)
+
+/* isi */
+#define DIB3000MB_REG_ISI				(    79)
+#define DIB3000MB_ISI_ACTIVATE				(     0)
+#define DIB3000MB_ISI_INHIBIT				(     1)
+
+/* sync impovement */
+#define DIB3000MB_REG_SYNC_IMPROVEMENT	(    84)
+#define DIB3000MB_SYNC_IMPROVE_2K_1_8		(     3)
+#define DIB3000MB_SYNC_IMPROVE_DEFAULT		(     0)
+
+/* phase noise compensation inhibition */
+#define DIB3000MB_REG_PHASE_NOISE		(    87)
+#define DIB3000MB_PHASE_NOISE_DEFAULT	(     0)
+
+#define DIB3000MB_REG_UNK_92				(    92)
+#define DIB3000MB_UNK_92						(0x0080)
+
+#define DIB3000MB_REG_UNK_96				(    96)
+#define DIB3000MB_UNK_96						(0x0010)
+
+#define DIB3000MB_REG_UNK_97				(    97)
+#define DIB3000MB_UNK_97						(0x0009)
+
+/* mobile mode ??? */
+#define DIB3000MB_REG_MOBILE_MODE		(   101)
+#define DIB3000MB_MOBILE_MODE_ON			(     1)
+#define DIB3000MB_MOBILE_MODE_OFF			(     0)
+
+#define DIB3000MB_REG_UNK_106			(   106)
+#define DIB3000MB_UNK_106					(0x0080)
+
+#define DIB3000MB_REG_UNK_107			(   107)
+#define DIB3000MB_UNK_107					(0x0080)
+
+#define DIB3000MB_REG_UNK_108			(   108)
+#define DIB3000MB_UNK_108					(0x0080)
+
+/* fft */
+#define DIB3000MB_REG_UNK_121			(   121)
+#define DIB3000MB_UNK_121_2K				(     7)
+#define DIB3000MB_UNK_121_DEFAULT			(     5)
+
+#define DIB3000MB_REG_UNK_122			(   122)
+#define DIB3000MB_UNK_122					(  2867)
+
+/* QAM for mobile mode */
+#define DIB3000MB_REG_MOBILE_MODE_QAM	(   126)
+#define DIB3000MB_MOBILE_MODE_QAM_64		(     3)
+#define DIB3000MB_MOBILE_MODE_QAM_QPSK_16	(     1)
+#define DIB3000MB_MOBILE_MODE_QAM_OFF		(     0)
+
+/*
+ * data diversity when having more than one chip on-board
+ * see also DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY
+ */
+#define DIB3000MB_REG_DATA_IN_DIVERSITY		(   127)
+#define DIB3000MB_DATA_DIVERSITY_IN_OFF			(     0)
+#define DIB3000MB_DATA_DIVERSITY_IN_ON			(     2)
+
+/* vit hrch */
+#define DIB3000MB_REG_VIT_HRCH			(   128)
+
+/* vit code rate */
+#define DIB3000MB_REG_VIT_CODE_RATE		(   129)
+
+/* vit select hp */
+#define DIB3000MB_REG_VIT_HP			(   130)
+
+/* time frame for Bit-Error-Rate calculation */
+#define DIB3000MB_REG_BERLEN			(   135)
+#define DIB3000MB_BERLEN_LONG				(     0)
+#define DIB3000MB_BERLEN_DEFAULT			(     1)
+#define DIB3000MB_BERLEN_MEDIUM				(     2)
+#define DIB3000MB_BERLEN_SHORT				(     3)
+
+/* 142 - 152 FIFO parameters
+ * which is what ?
+ */
+
+#define DIB3000MB_REG_FIFO_142			(   142)
+#define DIB3000MB_FIFO_142					(     0)
+
+/* MPEG2 TS output mode */
+#define DIB3000MB_REG_MPEG2_OUT_MODE	(   143)
+#define DIB3000MB_MPEG2_OUT_MODE_204		(     0)
+#define DIB3000MB_MPEG2_OUT_MODE_188		(     1)
+
+#define DIB3000MB_REG_PID_PARSE			(   144)
+#define DIB3000MB_PID_PARSE_INHIBIT		(     0)
+#define DIB3000MB_PID_PARSE_ACTIVATE	(     1)
+
+#define DIB3000MB_REG_FIFO				(   145)
+#define DIB3000MB_FIFO_INHIBIT				(     1)
+#define DIB3000MB_FIFO_ACTIVATE				(     0)
+
+#define DIB3000MB_REG_FIFO_146			(   146)
+#define DIB3000MB_FIFO_146					(     3)
+
+#define DIB3000MB_REG_FIFO_147			(   147)
+#define DIB3000MB_FIFO_147					(0x0100)
+
+/*
+ * pidfilter
+ * it is not a hardware pidfilter but a filter which drops all pids
+ * except the ones set. Necessary because of the limited USB1.1 bandwidth.
+ * regs 153-168
+ */
+
+#define DIB3000MB_REG_FIRST_PID			(   153)
+#define DIB3000MB_NUM_PIDS				(    16)
+
+/*
+ * output mode
+ * USB devices have to use 'slave'-mode
+ * see also DIB3000MB_REG_ELECT_OUT_MODE
+ */
+#define DIB3000MB_REG_OUTPUT_MODE		(   169)
+#define DIB3000MB_OUTPUT_MODE_GATED_CLK		(     0)
+#define DIB3000MB_OUTPUT_MODE_CONT_CLK		(     1)
+#define DIB3000MB_OUTPUT_MODE_SERIAL		(     2)
+#define DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY	(     5)
+#define DIB3000MB_OUTPUT_MODE_SLAVE			(     6)
+
+/* irq event mask */
+#define DIB3000MB_REG_IRQ_EVENT_MASK		(   170)
+#define DIB3000MB_IRQ_EVENT_MASK				(     0)
+
+/* filter coefficients */
+static u16 dib3000mb_reg_filter_coeffs[] = {
+	171, 172, 173, 174, 175, 176, 177, 178,
+	179, 180, 181, 182, 183, 184, 185, 186,
+	188, 189, 190, 191, 192, 194
+};
+
+static u16 dib3000mb_filter_coeffs[] = {
+	 226,  160,   29,
+ 	 979,  998,   19,
+	  22, 1019, 1006,
+	1022,   12,    6,
+	1017, 1017,    3,
+	   6,       1019,
+	1021,    2,    3,
+	   1,          0,
+};
+
+/*
+ * mobile algorithm (when you are moving with your device)
+ * but not faster than 90 km/h
+ */
+#define DIB3000MB_REG_MOBILE_ALGO		(   195)
+#define DIB3000MB_MOBILE_ALGO_ON			(     0)
+#define DIB3000MB_MOBILE_ALGO_OFF			(     1)
+
+/* multiple demodulators algorithm */
+#define DIB3000MB_REG_MULTI_DEMOD_MSB	(   206)
+#define DIB3000MB_REG_MULTI_DEMOD_LSB	(   207)
+
+/* terminator, no more demods */
+#define DIB3000MB_MULTI_DEMOD_MSB			( 32767)
+#define DIB3000MB_MULTI_DEMOD_LSB			(  4095)
+
+/* bring the device into a known  */
+#define DIB3000MB_REG_RESET_DEVICE		(  1024)
+#define DIB3000MB_RESET_DEVICE				(0x812c)
+#define DIB3000MB_RESET_DEVICE_RST			(     0)
+
+/* hardware clock configuration */
+#define DIB3000MB_REG_CLOCK				(  1027)
+#define DIB3000MB_CLOCK_DEFAULT				(0x9000)
+#define DIB3000MB_CLOCK_DIVERSITY			(0x92b0)
+
+/* power down config */
+#define DIB3000MB_REG_POWER_CONTROL		(  1028)
+#define DIB3000MB_POWER_DOWN				(     1)
+#define DIB3000MB_POWER_UP					(     0)
+
+/* electrical output mode */
+#define DIB3000MB_REG_ELECT_OUT_MODE	(  1029)
+#define DIB3000MB_ELECT_OUT_MODE_OFF		(     0)
+#define DIB3000MB_ELECT_OUT_MODE_ON			(     1)
+
+/* set the tuner i2c address */
+#define DIB3000MB_REG_TUNER				(  1089)
+
+/* monitoring registers (read only) */
+
+/* agc loop locked (size: 1) */
+#define DIB3000MB_REG_AGC_LOCK			(   324)
+
+/* agc power (size: 16) */
+#define DIB3000MB_REG_AGC_POWER			(   325)
+
+/* agc1 value (16) */
+#define DIB3000MB_REG_AGC1_VALUE		(   326)
+
+/* agc2 value (16) */
+#define DIB3000MB_REG_AGC2_VALUE		(   327)
+
+/* total RF power (16), can be used for signal strength */
+#define DIB3000MB_REG_RF_POWER			(   328)
+
+/* dds_frequency with offset (24) */
+#define DIB3000MB_REG_DDS_VALUE_MSB		(   339)
+#define DIB3000MB_REG_DDS_VALUE_LSB		(   340)
+
+/* timing offset signed (24) */
+#define DIB3000MB_REG_TIMING_OFFSET_MSB	(   341)
+#define DIB3000MB_REG_TIMING_OFFSET_LSB	(   342)
+
+/* fft start position (13) */
+#define DIB3000MB_REG_FFT_WINDOW_POS	(   353)
+
+/* carriers locked (1) */
+#define DIB3000MB_REG_CARRIER_LOCK		(   355)
+
+/* noise power (24) */
+#define DIB3000MB_REG_NOISE_POWER_MSB	(   372)
+#define DIB3000MB_REG_NOISE_POWER_LSB	(   373)
+
+#define DIB3000MB_REG_MOBILE_NOISE_MSB	(   374)
+#define DIB3000MB_REG_MOBILE_NOISE_LSB	(   375)
+
+/*
+ * signal power (16), this and the above can be
+ * used to calculate the signal/noise - ratio
+ */
+#define DIB3000MB_REG_SIGNAL_POWER		(   380)
+
+/* mer (24) */
+#define DIB3000MB_REG_MER_MSB			(   381)
+#define DIB3000MB_REG_MER_LSB			(   382)
+
+/*
+ * Transmission Parameter Signalling (TPS)
+ * the following registers can be used to get TPS-information.
+ * The values are according to the DVB-T standard.
+ */
+
+/* TPS locked (1) */
+#define DIB3000MB_REG_TPS_LOCK			(   394)
+
+/* QAM from TPS (2) (values according to DIB3000MB_REG_QAM) */
+#define DIB3000MB_REG_TPS_QAM			(   398)
+
+/* hierarchy from TPS (1) */
+#define DIB3000MB_REG_TPS_HRCH			(   399)
+
+/* alpha from TPS (3) (values according to DIB3000MB_REG_VIT_ALPHA) */
+#define DIB3000MB_REG_TPS_VIT_ALPHA		(   400)
+
+/* code rate high priority from TPS (3) (values according to DIB3000MB_FEC_*) */
+#define DIB3000MB_REG_TPS_CODE_RATE_HP	(   401)
+
+/* code rate low priority from TPS (3) if DIB3000MB_REG_TPS_VIT_ALPHA */
+#define DIB3000MB_REG_TPS_CODE_RATE_LP	(   402)
+
+/* guard time from TPS (2) (values according to DIB3000MB_REG_GUARD_TIME */
+#define DIB3000MB_REG_TPS_GUARD_TIME	(   403)
+
+/* fft size from TPS (2) (values according to DIB3000MB_REG_FFT) */
+#define DIB3000MB_REG_TPS_FFT			(   404)
+
+/* cell id from TPS (16) */
+#define DIB3000MB_REG_TPS_CELL_ID		(   406)
+
+/* TPS (68) */
+#define DIB3000MB_REG_TPS_1				(   408)
+#define DIB3000MB_REG_TPS_2				(   409)
+#define DIB3000MB_REG_TPS_3				(   410)
+#define DIB3000MB_REG_TPS_4				(   411)
+#define DIB3000MB_REG_TPS_5				(   412)
+
+/* bit error rate (before RS correction) (21) */
+#define DIB3000MB_REG_BER_MSB			(   414)
+#define DIB3000MB_REG_BER_LSB			(   415)
+
+/* packet error rate (uncorrected TS packets) (16) */
+#define DIB3000MB_REG_PACKET_ERROR_RATE	(   417)
+
+/* uncorrected packet count (16) */
+#define DIB3000MB_REG_UNC				(   420)
+
+/* viterbi locked (1) */
+#define DIB3000MB_REG_VIT_LCK			(   421)
+
+/* viterbi inidcator (16) */
+#define DIB3000MB_REG_VIT_INDICATOR		(   422)
+
+/* transport stream sync lock (1) */
+#define DIB3000MB_REG_TS_SYNC_LOCK		(   423)
+
+/* transport stream RS lock (1) */
+#define DIB3000MB_REG_TS_RS_LOCK		(   424)
+
+/* lock mask 0 value (1) */
+#define DIB3000MB_REG_LOCK0_VALUE		(   425)
+
+/* lock mask 1 value (1) */
+#define DIB3000MB_REG_LOCK1_VALUE		(   426)
+
+/* lock mask 2 value (1) */
+#define DIB3000MB_REG_LOCK2_VALUE		(   427)
+
+/* interrupt pending for auto search */
+#define DIB3000MB_REG_AS_IRQ_PENDING	(   434)
+
+#endif
diff -Nru a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/dib3000mc.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,860 @@
+/*
+ * Frontend driver for mobile DVB-T demodulator DiBcom 3000-MC/P
+ * DiBcom (http://www.dibcom.fr/)
+ *
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ *
+ * based on GPL code from DibCom, which has
+ *
+ * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ *
+ *	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, version 2.
+ *
+ * Acknowledgements
+ *
+ *  Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
+ *  sources, on which this driver (and the dvb-dibusb) are based.
+ *
+ * see Documentation/dvb/README.dibusb for more information
+ *
+ */
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+
+#include "dvb_frontend.h"
+#include "dib3000-common.h"
+#include "dib3000mc_priv.h"
+#include "dib3000.h"
+
+/* Version information */
+#define DRIVER_VERSION "0.1"
+#define DRIVER_DESC "DiBcom 3000-MC DVB-T demodulator driver"
+#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
+
+#ifdef CONFIG_DVB_DIBCOM_DEBUG
+static int debug;
+module_param(debug, int, 0x644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able)).");
+#endif
+#define deb_info(args...) dprintk(0x01,args)
+#define deb_xfer(args...) dprintk(0x02,args)
+#define deb_setf(args...) dprintk(0x04,args)
+#define deb_getf(args...) dprintk(0x08,args)
+
+
+static int dib3000mc_set_impulse_noise(struct dib3000_state * state, int mode,
+	fe_transmit_mode_t transmission_mode, fe_bandwidth_t bandwidth)
+{
+	switch (transmission_mode) {
+		case TRANSMISSION_MODE_2K:
+			wr_foreach(dib3000mc_reg_fft,dib3000mc_fft_modes[0]);
+			break;
+		case TRANSMISSION_MODE_8K:
+			wr_foreach(dib3000mc_reg_fft,dib3000mc_fft_modes[1]);
+			break;
+		default:
+			break;
+	}
+
+	switch (bandwidth) {
+/*		case BANDWIDTH_5_MHZ:
+			wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[0]);
+			break; */
+		case BANDWIDTH_6_MHZ:
+			wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[1]);
+			break;
+		case BANDWIDTH_7_MHZ:
+			wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[2]);
+			break;
+		case BANDWIDTH_8_MHZ:
+			wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[3]);
+			break;
+		default:
+			break;
+	}
+
+	switch (mode) {
+		case 0: /* no impulse */ /* fall through */
+			wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[0]);
+			break;
+		case 1: /* new algo */
+			wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[1]);
+			set_or(DIB3000MC_REG_IMP_NOISE_55,DIB3000MC_IMP_NEW_ALGO(0)); /* gives 1<<10 */
+			break;
+		default: /* old algo */
+			wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[3]);
+			break;
+	}
+	return 0;
+}
+
+static int dib3000mc_set_timing(struct dib3000_state *state, int upd_offset,
+		fe_transmit_mode_t fft, fe_bandwidth_t bw)
+{
+	u16 timf_msb,timf_lsb;
+	s32 tim_offset,tim_sgn;
+	u64 comp1,comp2,comp=0;
+
+	switch (bw) {
+		case BANDWIDTH_8_MHZ: comp = DIB3000MC_CLOCK_REF*8; break;
+		case BANDWIDTH_7_MHZ: comp = DIB3000MC_CLOCK_REF*7; break;
+		case BANDWIDTH_6_MHZ: comp = DIB3000MC_CLOCK_REF*6; break;
+		default: err("unknown bandwidth (%d)",bw); break;
+	}
+	timf_msb = (comp >> 16) & 0xff;
+	timf_lsb = (comp & 0xffff);
+
+	// Update the timing offset ;
+	if (upd_offset > 0) {
+		if (!state->timing_offset_comp_done) {
+			msleep(200);
+			state->timing_offset_comp_done = 1;
+		}
+		tim_offset = rd(DIB3000MC_REG_TIMING_OFFS_MSB);
+		if ((tim_offset & 0x2000) == 0x2000)
+			tim_offset |= 0xC000;
+		if (fft == TRANSMISSION_MODE_2K)
+			tim_offset <<= 2;
+		state->timing_offset += tim_offset;
+	}
+
+	tim_offset = state->timing_offset;
+	if (tim_offset < 0) {
+		tim_sgn = 1;
+		tim_offset = -tim_offset;
+	} else
+		tim_sgn = 0;
+
+	comp1 =  (u32)tim_offset * (u32)timf_lsb ;
+	comp2 =  (u32)tim_offset * (u32)timf_msb ;
+	comp  = ((comp1 >> 16) + comp2) >> 7;
+
+	if (tim_sgn == 0)
+		comp = (u32)(timf_msb << 16) + (u32) timf_lsb + comp;
+	else
+		comp = (u32)(timf_msb << 16) + (u32) timf_lsb - comp ;
+
+	timf_msb = (comp >> 16) & 0xff;
+	timf_lsb = comp & 0xffff;
+
+	wr(DIB3000MC_REG_TIMING_FREQ_MSB,timf_msb);
+	wr(DIB3000MC_REG_TIMING_FREQ_LSB,timf_lsb);
+	return 0;
+}
+
+static int dib3000mc_init_auto_scan(struct dib3000_state *state, fe_bandwidth_t bw, int boost)
+{
+	if (boost) {
+		wr(DIB3000MC_REG_SCAN_BOOST,DIB3000MC_SCAN_BOOST_ON);
+	} else {
+		wr(DIB3000MC_REG_SCAN_BOOST,DIB3000MC_SCAN_BOOST_OFF);
+	}
+	switch (bw) {
+		case BANDWIDTH_8_MHZ:
+			wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_8mhz);
+			break;
+		case BANDWIDTH_7_MHZ:
+			wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_7mhz);
+			break;
+		case BANDWIDTH_6_MHZ:
+			wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_6mhz);
+			break;
+/*		case BANDWIDTH_5_MHZ:
+			wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_5mhz);
+			break;*/
+		case BANDWIDTH_AUTO:
+			return -EOPNOTSUPP;
+		default:
+			err("unknown bandwidth value (%d).",bw);
+			return -EINVAL;
+	}
+	if (boost) {
+		u32 timeout = (rd(DIB3000MC_REG_BW_TIMOUT_MSB) << 16) +
+			rd(DIB3000MC_REG_BW_TIMOUT_LSB);
+		timeout *= 85; timeout >>= 7;
+		wr(DIB3000MC_REG_BW_TIMOUT_MSB,(timeout >> 16) & 0xffff);
+		wr(DIB3000MC_REG_BW_TIMOUT_LSB,timeout & 0xffff);
+	}
+	return 0;
+}
+
+static int dib3000mc_get_frontend(struct dvb_frontend* fe,
+				  struct dvb_frontend_parameters *fep);
+
+static int dib3000mc_set_frontend(struct dvb_frontend* fe,
+				  struct dvb_frontend_parameters *fep, int tuner)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+	struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
+	fe_code_rate_t fe_cr = FEC_NONE;
+	int search_state, seq;
+	u16 val;
+	u8 fft=0, guard=0, qam=0, alpha=0, sel_hp=0, cr=0, hrch=0;
+
+	if (tuner) {
+		wr(DIB3000MC_REG_TUNER,
+				DIB3000_TUNER_WRITE_ENABLE(state->config.pll_addr));
+		state->config.pll_set(fe, fep);
+		wr(DIB3000MC_REG_TUNER,
+				DIB3000_TUNER_WRITE_DISABLE(state->config.pll_addr));
+	}
+
+	dib3000mc_set_timing(state,0,ofdm->transmission_mode,ofdm->bandwidth);
+	dib3000mc_init_auto_scan(state, ofdm->bandwidth, 0);
+
+	wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_AGC);
+	wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_OFF);
+
+/* Default cfg isi offset adp */
+	wr_foreach(dib3000mc_reg_offset,dib3000mc_offset[0]);
+
+	wr(DIB3000MC_REG_ISI,DIB3000MC_ISI_DEFAULT | DIB3000MC_ISI_INHIBIT);
+	wr_foreach(dib3000mc_reg_adp_cfg,dib3000mc_adp_cfg[1]);
+	wr(DIB3000MC_REG_UNK_133,DIB3000MC_UNK_133);
+
+	wr_foreach(dib3000mc_reg_bandwidth_general,dib3000mc_bandwidth_general);
+	if (ofdm->bandwidth == BANDWIDTH_8_MHZ) {
+		wr_foreach(dib3000mc_reg_bw,dib3000mc_bw[3]);
+	} else {
+		wr_foreach(dib3000mc_reg_bw,dib3000mc_bw[0]);
+	}
+
+	switch (ofdm->transmission_mode) {
+		case TRANSMISSION_MODE_2K: fft = DIB3000_TRANSMISSION_MODE_2K; break;
+		case TRANSMISSION_MODE_8K: fft = DIB3000_TRANSMISSION_MODE_8K; break;
+		case TRANSMISSION_MODE_AUTO: break;
+		default: return -EINVAL;
+	}
+	switch (ofdm->guard_interval) {
+		case GUARD_INTERVAL_1_32: guard = DIB3000_GUARD_TIME_1_32; break;
+		case GUARD_INTERVAL_1_16: guard = DIB3000_GUARD_TIME_1_16; break;
+		case GUARD_INTERVAL_1_8: guard = DIB3000_GUARD_TIME_1_8; break;
+		case GUARD_INTERVAL_1_4: guard = DIB3000_GUARD_TIME_1_4; break;
+		case GUARD_INTERVAL_AUTO: break;
+		default: return -EINVAL;
+	}
+	switch (ofdm->constellation) {
+		case QPSK: qam = DIB3000_CONSTELLATION_QPSK; break;
+		case QAM_16: qam = DIB3000_CONSTELLATION_16QAM; break;
+		case QAM_64: qam = DIB3000_CONSTELLATION_64QAM; break;
+		case QAM_AUTO: break;
+		default: return -EINVAL;
+	}
+	switch (ofdm->hierarchy_information) {
+		case HIERARCHY_NONE: /* fall through */
+		case HIERARCHY_1: alpha = DIB3000_ALPHA_1; break;
+		case HIERARCHY_2: alpha = DIB3000_ALPHA_2; break;
+		case HIERARCHY_4: alpha = DIB3000_ALPHA_4; break;
+		case HIERARCHY_AUTO: break;
+		default: return -EINVAL;
+	}
+	if (ofdm->hierarchy_information == HIERARCHY_NONE) {
+		hrch = DIB3000_HRCH_OFF;
+		sel_hp = DIB3000_SELECT_HP;
+		fe_cr = ofdm->code_rate_HP;
+	} else if (ofdm->hierarchy_information != HIERARCHY_AUTO) {
+		hrch = DIB3000_HRCH_ON;
+		sel_hp = DIB3000_SELECT_LP;
+		fe_cr = ofdm->code_rate_LP;
+	}
+	switch (fe_cr) {
+		case FEC_1_2: cr = DIB3000_FEC_1_2; break;
+		case FEC_2_3: cr = DIB3000_FEC_2_3; break;
+		case FEC_3_4: cr = DIB3000_FEC_3_4; break;
+		case FEC_5_6: cr = DIB3000_FEC_5_6; break;
+		case FEC_7_8: cr = DIB3000_FEC_7_8; break;
+		case FEC_NONE: break;
+		case FEC_AUTO: break;
+		default: return -EINVAL;
+	}
+
+	wr(DIB3000MC_REG_DEMOD_PARM,DIB3000MC_DEMOD_PARM(alpha,qam,guard,fft));
+	wr(DIB3000MC_REG_HRCH_PARM,DIB3000MC_HRCH_PARM(sel_hp,cr,hrch));
+
+	switch (fep->inversion) {
+		case INVERSION_OFF:
+			wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_OFF);
+			break;
+		case INVERSION_AUTO:
+			break;
+		case INVERSION_ON:
+			wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_ON);
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	seq = dib3000_seq
+		[ofdm->transmission_mode == TRANSMISSION_MODE_AUTO]
+		[ofdm->guard_interval == GUARD_INTERVAL_AUTO]
+		[fep->inversion == INVERSION_AUTO];
+
+	deb_setf("seq? %d\n", seq);
+	wr(DIB3000MC_REG_SEQ_TPS,DIB3000MC_SEQ_TPS(seq,1));
+
+	dib3000mc_set_impulse_noise(state,0,ofdm->constellation,ofdm->bandwidth);
+
+	val = rd(DIB3000MC_REG_DEMOD_PARM);
+	wr(DIB3000MC_REG_DEMOD_PARM,val|DIB3000MC_DEMOD_RST_DEMOD_ON);
+	wr(DIB3000MC_REG_DEMOD_PARM,val);
+
+	msleep(70);
+
+	wr_foreach(dib3000mc_reg_agc_bandwidth, dib3000mc_agc_bandwidth);
+
+	/* something has to be auto searched */
+	if (ofdm->constellation == QAM_AUTO ||
+		ofdm->hierarchy_information == HIERARCHY_AUTO ||
+		ofdm->guard_interval == GUARD_INTERVAL_AUTO ||
+		ofdm->transmission_mode == TRANSMISSION_MODE_AUTO ||
+		fe_cr == FEC_AUTO ||
+		fep->inversion == INVERSION_AUTO
+		) {
+		int as_count=0;
+
+		deb_setf("autosearch enabled.\n");
+
+		val = rd(DIB3000MC_REG_DEMOD_PARM);
+		wr(DIB3000MC_REG_DEMOD_PARM,val | DIB3000MC_DEMOD_RST_AUTO_SRCH_ON);
+		wr(DIB3000MC_REG_DEMOD_PARM,val);
+
+		while ((search_state = dib3000_search_status(
+					rd(DIB3000MC_REG_AS_IRQ),1)) < 0 && as_count++ < 100)
+			msleep(10);
+
+		deb_info("search_state after autosearch %d after %d checks\n",search_state,as_count);
+
+		if (search_state == 1) {
+			struct dvb_frontend_parameters feps;
+			feps.u.ofdm.bandwidth = ofdm->bandwidth; /* bw is not auto searched */;
+			if (dib3000mc_get_frontend(fe, &feps) == 0) {
+				deb_setf("reading tuning data from frontend succeeded.\n");
+				return dib3000mc_set_frontend(fe, &feps, 0);
+			}
+		}
+	} else {
+		wr(DIB3000MC_REG_ISI,DIB3000MC_ISI_DEFAULT|DIB3000MC_ISI_ACTIVATE);
+		wr_foreach(dib3000mc_reg_adp_cfg,dib3000mc_adp_cfg[qam]);
+		/* set_offset_cfg */
+		wr_foreach(dib3000mc_reg_offset,
+				dib3000mc_offset[(ofdm->transmission_mode == TRANSMISSION_MODE_8K)+1]);
+
+//		dib3000mc_set_timing(1,ofdm->transmission_mode,ofdm->bandwidth);
+
+//		wr(DIB3000MC_REG_LOCK_MASK,DIB3000MC_ACTIVATE_LOCK_MASK); /* activates some locks if needed */
+
+/*		set_or(DIB3000MC_REG_DEMOD_PARM,DIB3000MC_DEMOD_RST_AUTO_SRCH_ON);
+		set_or(DIB3000MC_REG_DEMOD_PARM,DIB3000MC_DEMOD_RST_AUTO_SRCH_OFF);
+		wr(DIB3000MC_REG_RESTART_VIT,DIB3000MC_RESTART_VIT_ON);
+		wr(DIB3000MC_REG_RESTART_VIT,DIB3000MC_RESTART_VIT_OFF);*/
+	}
+
+	return 0;
+}
+
+
+static int dib3000mc_fe_init(struct dvb_frontend* fe, int mobile_mode)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	state->timing_offset = 0;
+	state->timing_offset_comp_done = 0;
+
+	wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_DIV_OUT_ON);
+	wr(DIB3000MC_REG_OUTMODE,DIB3000MC_OM_PAR_CONT_CLK);
+	wr(DIB3000MC_REG_RST_I2C_ADDR,
+		DIB3000MC_DEMOD_ADDR(state->config.demod_address) |
+		DIB3000MC_DEMOD_ADDR_ON);
+
+	wr(DIB3000MC_REG_RST_I2C_ADDR,
+		DIB3000MC_DEMOD_ADDR(state->config.demod_address));
+
+	wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_CONFIG);
+	wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_OFF);
+
+	wr(DIB3000MC_REG_CLK_CFG_1,DIB3000MC_CLK_CFG_1_POWER_UP);
+	wr(DIB3000MC_REG_CLK_CFG_2,DIB3000MC_CLK_CFG_2_PUP_MOBILE);
+	wr(DIB3000MC_REG_CLK_CFG_3,DIB3000MC_CLK_CFG_3_POWER_UP);
+	wr(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_INIT);
+
+	wr(DIB3000MC_REG_RST_UNC,DIB3000MC_RST_UNC_OFF);
+	wr(DIB3000MC_REG_UNK_19,DIB3000MC_UNK_19);
+
+	wr(33,5);
+	wr(36,81);
+	wr(DIB3000MC_REG_UNK_88,DIB3000MC_UNK_88);
+
+	wr(DIB3000MC_REG_UNK_99,DIB3000MC_UNK_99);
+	wr(DIB3000MC_REG_UNK_111,DIB3000MC_UNK_111_PH_N_MODE_0); /* phase noise algo off */
+
+	/* mobile mode - portable reception */
+	wr_foreach(dib3000mc_reg_mobile_mode,dib3000mc_mobile_mode[1]);
+
+/* TUNER_PANASONIC_ENV57H12D5: */
+	wr_foreach(dib3000mc_reg_agc_bandwidth,dib3000mc_agc_bandwidth);
+	wr_foreach(dib3000mc_reg_agc_bandwidth_general,dib3000mc_agc_bandwidth_general);
+	wr_foreach(dib3000mc_reg_agc,dib3000mc_agc_tuner[1]);
+
+	wr(DIB3000MC_REG_UNK_110,DIB3000MC_UNK_110);
+	wr(26,0x6680);
+	wr(DIB3000MC_REG_UNK_1,DIB3000MC_UNK_1);
+	wr(DIB3000MC_REG_UNK_2,DIB3000MC_UNK_2);
+	wr(DIB3000MC_REG_UNK_3,DIB3000MC_UNK_3);
+	wr(DIB3000MC_REG_SEQ_TPS,DIB3000MC_SEQ_TPS_DEFAULT);
+
+	wr_foreach(dib3000mc_reg_bandwidth_general,dib3000mc_bandwidth_general);
+	wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_8mhz);
+
+	wr(DIB3000MC_REG_UNK_4,DIB3000MC_UNK_4);
+
+	wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_OFF);
+	wr(DIB3000MC_REG_SET_DDS_FREQ_LSB,DIB3000MC_DDS_FREQ_LSB);
+
+	dib3000mc_set_timing(state,0,TRANSMISSION_MODE_2K,BANDWIDTH_8_MHZ);
+//	wr_foreach(dib3000mc_reg_timing_freq,dib3000mc_timing_freq[3]);
+
+	wr(DIB3000MC_REG_UNK_120,DIB3000MC_UNK_120);
+	wr(DIB3000MC_REG_UNK_134,DIB3000MC_UNK_134);
+	wr(DIB3000MC_REG_FEC_CFG,DIB3000MC_FEC_CFG);
+
+	dib3000mc_set_impulse_noise(state,0,TRANSMISSION_MODE_8K,BANDWIDTH_8_MHZ);
+
+/* output mode control, just the MPEG2_SLAVE */
+	set_or(DIB3000MC_REG_OUTMODE,DIB3000MC_OM_SLAVE);
+	wr(DIB3000MC_REG_SMO_MODE,DIB3000MC_SMO_MODE_SLAVE);
+	wr(DIB3000MC_REG_FIFO_THRESHOLD,DIB3000MC_FIFO_THRESHOLD_SLAVE);
+	wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_SLAVE);
+
+/* MPEG2_PARALLEL_CONTINUOUS_CLOCK
+	wr(DIB3000MC_REG_OUTMODE,
+		DIB3000MC_SET_OUTMODE(DIB3000MC_OM_PAR_CONT_CLK,
+			rd(DIB3000MC_REG_OUTMODE)));
+
+	wr(DIB3000MC_REG_SMO_MODE,
+			DIB3000MC_SMO_MODE_DEFAULT |
+			DIB3000MC_SMO_MODE_188);
+
+	wr(DIB3000MC_REG_FIFO_THRESHOLD,DIB3000MC_FIFO_THRESHOLD_DEFAULT);
+	wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_DIV_OUT_ON);
+*/
+/* diversity */
+	wr(DIB3000MC_REG_DIVERSITY1,DIB3000MC_DIVERSITY1_DEFAULT);
+	wr(DIB3000MC_REG_DIVERSITY2,DIB3000MC_DIVERSITY2_DEFAULT);
+
+	wr(DIB3000MC_REG_DIVERSITY3,DIB3000MC_DIVERSITY3_IN_OFF);
+
+	set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_DIV_IN_OFF);
+
+
+/*	if (state->config->pll_init) {
+		wr(DIB3000MC_REG_TUNER,
+			DIB3000_TUNER_WRITE_ENABLE(state->config->pll_addr));
+		state->config->pll_init(fe);
+		wr(DIB3000MC_REG_TUNER,
+			DIB3000_TUNER_WRITE_DISABLE(state->config->pll_addr));
+	}*/
+	return 0;
+}
+
+static int dib3000mc_get_frontend(struct dvb_frontend* fe,
+				  struct dvb_frontend_parameters *fep)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+	struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
+	fe_code_rate_t *cr;
+	u16 tps_val,cr_val;
+	int inv_test1,inv_test2;
+	u32 dds_val, threshold = 0x1000000;
+
+	if (!(rd(DIB3000MC_REG_LOCK_507) & DIB3000MC_LOCK_507))
+		return 0;
+
+	dds_val = ((rd(DIB3000MC_REG_DDS_FREQ_MSB) & 0xff) << 16) + rd(DIB3000MC_REG_DDS_FREQ_LSB);
+	if (dds_val < threshold)
+		inv_test1 = 0;
+	else if (dds_val == threshold)
+		inv_test1 = 1;
+	else
+		inv_test1 = 2;
+
+	dds_val = ((rd(DIB3000MC_REG_SET_DDS_FREQ_MSB) & 0xff) << 16) + rd(DIB3000MC_REG_SET_DDS_FREQ_LSB);
+	if (dds_val < threshold)
+		inv_test2 = 0;
+	else if (dds_val == threshold)
+		inv_test2 = 1;
+	else
+		inv_test2 = 2;
+
+	fep->inversion =
+		((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) ||
+		((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ?
+		INVERSION_ON : INVERSION_OFF;
+
+	deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, fep->inversion);
+
+	tps_val = rd(DIB3000MC_REG_TUNING_PARM);
+
+	switch (DIB3000MC_TP_QAM(tps_val)) {
+		case DIB3000_CONSTELLATION_QPSK:
+			deb_getf("QPSK ");
+			ofdm->constellation = QPSK;
+			break;
+		case DIB3000_CONSTELLATION_16QAM:
+			deb_getf("QAM16 ");
+			ofdm->constellation = QAM_16;
+			break;
+		case DIB3000_CONSTELLATION_64QAM:
+			deb_getf("QAM64 ");
+			ofdm->constellation = QAM_64;
+			break;
+		default:
+			err("Unexpected constellation returned by TPS (%d)", tps_val);
+			break;
+ 	}
+
+	if (DIB3000MC_TP_HRCH(tps_val)) {
+		deb_getf("HRCH ON ");
+		cr = &ofdm->code_rate_LP;
+		ofdm->code_rate_HP = FEC_NONE;
+		switch (DIB3000MC_TP_ALPHA(tps_val)) {
+			case DIB3000_ALPHA_0:
+				deb_getf("HIERARCHY_NONE ");
+				ofdm->hierarchy_information = HIERARCHY_NONE;
+				break;
+			case DIB3000_ALPHA_1:
+				deb_getf("HIERARCHY_1 ");
+				ofdm->hierarchy_information = HIERARCHY_1;
+				break;
+			case DIB3000_ALPHA_2:
+				deb_getf("HIERARCHY_2 ");
+				ofdm->hierarchy_information = HIERARCHY_2;
+				break;
+			case DIB3000_ALPHA_4:
+				deb_getf("HIERARCHY_4 ");
+				ofdm->hierarchy_information = HIERARCHY_4;
+				break;
+			default:
+				err("Unexpected ALPHA value returned by TPS (%d)", tps_val);
+				break;
+		}
+		cr_val = DIB3000MC_TP_FEC_CR_LP(tps_val);
+	} else {
+		deb_getf("HRCH OFF ");
+		cr = &ofdm->code_rate_HP;
+		ofdm->code_rate_LP = FEC_NONE;
+		ofdm->hierarchy_information = HIERARCHY_NONE;
+		cr_val = DIB3000MC_TP_FEC_CR_HP(tps_val);
+	}
+
+	switch (cr_val) {
+		case DIB3000_FEC_1_2:
+			deb_getf("FEC_1_2 ");
+			*cr = FEC_1_2;
+			break;
+		case DIB3000_FEC_2_3:
+			deb_getf("FEC_2_3 ");
+			*cr = FEC_2_3;
+			break;
+		case DIB3000_FEC_3_4:
+			deb_getf("FEC_3_4 ");
+			*cr = FEC_3_4;
+			break;
+		case DIB3000_FEC_5_6:
+			deb_getf("FEC_5_6 ");
+			*cr = FEC_4_5;
+			break;
+		case DIB3000_FEC_7_8:
+			deb_getf("FEC_7_8 ");
+			*cr = FEC_7_8;
+			break;
+		default:
+			err("Unexpected FEC returned by TPS (%d)", tps_val);
+			break;
+	}
+
+	switch (DIB3000MC_TP_GUARD(tps_val)) {
+		case DIB3000_GUARD_TIME_1_32:
+			deb_getf("GUARD_INTERVAL_1_32 ");
+			ofdm->guard_interval = GUARD_INTERVAL_1_32;
+			break;
+		case DIB3000_GUARD_TIME_1_16:
+			deb_getf("GUARD_INTERVAL_1_16 ");
+			ofdm->guard_interval = GUARD_INTERVAL_1_16;
+			break;
+		case DIB3000_GUARD_TIME_1_8:
+			deb_getf("GUARD_INTERVAL_1_8 ");
+			ofdm->guard_interval = GUARD_INTERVAL_1_8;
+			break;
+		case DIB3000_GUARD_TIME_1_4:
+			deb_getf("GUARD_INTERVAL_1_4 ");
+			ofdm->guard_interval = GUARD_INTERVAL_1_4;
+			break;
+		default:
+			err("Unexpected Guard Time returned by TPS (%d)", tps_val);
+			break;
+	}
+
+	switch (DIB3000MC_TP_FFT(tps_val)) {
+		case DIB3000_TRANSMISSION_MODE_2K:
+			deb_getf("TRANSMISSION_MODE_2K ");
+			ofdm->transmission_mode = TRANSMISSION_MODE_2K;
+			break;
+		case DIB3000_TRANSMISSION_MODE_8K:
+			deb_getf("TRANSMISSION_MODE_8K ");
+			ofdm->transmission_mode = TRANSMISSION_MODE_8K;
+			break;
+		default:
+			err("unexpected transmission mode return by TPS (%d)", tps_val);
+			break;
+	}
+	return 0;
+}
+
+static int dib3000mc_read_status(struct dvb_frontend* fe, fe_status_t *stat)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+	u16 lock = rd(DIB3000MC_REG_LOCKING);
+
+	*stat = 0;
+	if (DIB3000MC_AGC_LOCK(lock))
+		*stat |= FE_HAS_SIGNAL;
+	if (DIB3000MC_CARRIER_LOCK(lock))
+		*stat |= FE_HAS_CARRIER;
+	if (DIB3000MC_TPS_LOCK(lock)) /* VIT_LOCK ? */
+		*stat |= FE_HAS_VITERBI;
+	if (DIB3000MC_MPEG_SYNC_LOCK(lock))
+		*stat |= (FE_HAS_SYNC | FE_HAS_LOCK);
+
+	deb_info("actual status is %2x\n",*stat);
+
+	return 0;
+}
+
+static int dib3000mc_read_ber(struct dvb_frontend* fe, u32 *ber)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+	*ber = ((rd(DIB3000MC_REG_BER_MSB) << 16) | rd(DIB3000MC_REG_BER_LSB));
+	return 0;
+}
+
+static int dib3000mc_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	*unc = rd(DIB3000MC_REG_PACKET_ERROR_COUNT);
+	return 0;
+}
+
+/* see dib3000mb.c for calculation comments */
+static int dib3000mc_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+	u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB);
+	*strength = (((val >> 6) & 0xff) << 8) + (val & 0x3f);
+
+	deb_info("signal: mantisse = %d, exponent = %d\n",(*strength >> 8) & 0xff, *strength & 0xff);
+	return 0;
+}
+
+/* see dib3000mb.c for calculation comments */
+static int dib3000mc_read_snr(struct dvb_frontend* fe, u16 *snr)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_MSB),
+		val2 = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB);
+	u16 sig,noise;
+
+	sig =   (((val >> 6) & 0xff) << 8) + (val & 0x3f);
+	noise = (((val >> 4) & 0xff) << 8) + ((val & 0xf) << 2) + ((val2 >> 14) & 0x3);
+	if (noise == 0)
+		*snr = 0xffff;
+	else
+		*snr = (u16) sig/noise;
+
+	deb_info("signal: mantisse = %d, exponent = %d\n",(sig >> 8) & 0xff, sig & 0xff);
+	deb_info("noise:  mantisse = %d, exponent = %d\n",(noise >> 8) & 0xff, noise & 0xff);
+	deb_info("snr: %d\n",*snr);
+	return 0;
+}
+
+static int dib3000mc_sleep(struct dvb_frontend* fe)
+{
+	struct dib3000_state* state = (struct dib3000_state*) fe->demodulator_priv;
+
+	set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_PWR_DOWN);
+	wr(DIB3000MC_REG_CLK_CFG_1,DIB3000MC_CLK_CFG_1_POWER_DOWN);
+	wr(DIB3000MC_REG_CLK_CFG_2,DIB3000MC_CLK_CFG_2_POWER_DOWN);
+	wr(DIB3000MC_REG_CLK_CFG_3,DIB3000MC_CLK_CFG_3_POWER_DOWN);
+	return 0;
+}
+
+static int dib3000mc_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
+{
+	tune->min_delay_ms = 800;
+	tune->step_size = 166667;
+	tune->max_drift = 166667 * 2;
+
+	return 0;
+}
+
+static int dib3000mc_fe_init_nonmobile(struct dvb_frontend* fe)
+{
+	return dib3000mc_fe_init(fe, 0);
+}
+
+static int dib3000mc_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep)
+{
+	return dib3000mc_set_frontend(fe, fep, 1);
+}
+
+static void dib3000mc_release(struct dvb_frontend* fe)
+{
+	struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv;
+	dib3000_dealloc_pid_list(state);
+	kfree(state);
+}
+
+/* pid filter and transfer stuff */
+static int dib3000mc_pid_control(struct dvb_frontend *fe,int pid,int onoff)
+{
+	struct dib3000_state *state = fe->demodulator_priv;
+	int index = dib3000_get_pid_index(state->pid_list, DIB3000MC_NUM_PIDS, pid, &state->pid_list_lock,onoff);
+	pid = (onoff ? pid | DIB3000_ACTIVATE_PID_FILTERING : 0);
+
+	if (index >= 0) {
+		wr(index+DIB3000MC_REG_FIRST_PID,pid);
+	} else {
+		err("no more pids for filtering.");
+		return -ENOMEM;
+	}
+	return 0;
+}
+
+static int dib3000mc_fifo_control(struct dvb_frontend *fe, int onoff)
+{
+	struct dib3000_state *state = (struct dib3000_state*) fe->demodulator_priv;
+	u16 tmp = rd(DIB3000MC_REG_SMO_MODE);
+	deb_xfer("%s fifo",onoff ? "enabling" : "disabling");
+	if (onoff) {
+		wr(DIB3000MC_REG_SMO_MODE,tmp & DIB3000MC_SMO_MODE_FIFO_UNFLUSH);
+	} else {
+		wr(DIB3000MC_REG_SMO_MODE,tmp | DIB3000MC_SMO_MODE_FIFO_FLUSH);
+	}
+	return 0;
+}
+
+static int dib3000mc_pid_parse(struct dvb_frontend *fe, int onoff)
+{
+	struct dib3000_state *state = fe->demodulator_priv;
+	u16 tmp = rd(DIB3000MC_REG_SMO_MODE);
+	deb_xfer("%s pid parsing",onoff ? "enabling" : "disabling");
+	if (onoff) {
+		wr(DIB3000MC_REG_SMO_MODE,tmp | DIB3000MC_SMO_MODE_PID_PARSE);
+	} else {
+		wr(DIB3000MC_REG_SMO_MODE,tmp & DIB3000MC_SMO_MODE_NO_PID_PARSE);
+	}
+	return 0;
+}
+
+static struct dvb_frontend_ops dib3000mc_ops;
+
+struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
+				      struct i2c_adapter* i2c, struct dib3000_xfer_ops *xfer_ops)
+{
+	struct dib3000_state* state = NULL;
+	u16 devid;
+
+	/* allocate memory for the internal state */
+	state = (struct dib3000_state*) kmalloc(sizeof(struct dib3000_state), GFP_KERNEL);
+	if (state == NULL)
+		goto error;
+
+	/* setup the state */
+	state->i2c = i2c;
+	memcpy(&state->config,config,sizeof(struct dib3000_config));
+	memcpy(&state->ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops));
+
+	/* check for the correct demod */
+	if (rd(DIB3000_REG_MANUFACTOR_ID) != DIB3000_I2C_ID_DIBCOM)
+		goto error;
+
+	devid = rd(DIB3000_REG_DEVICE_ID);
+	if (devid != DIB3000MC_DEVICE_ID && devid != DIB3000P_DEVICE_ID)
+		goto error;
+
+
+	switch (devid) {
+		case DIB3000MC_DEVICE_ID:
+			info("Found a DiBcom 3000-MC.");
+			break;
+		case DIB3000P_DEVICE_ID:
+			info("Found a DiBcom 3000-P.");
+			break;
+	}
+
+	if (dib3000_init_pid_list(state,DIB3000MC_NUM_PIDS))
+		goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+
+	/* set the xfer operations */
+	xfer_ops->pid_parse = dib3000mc_pid_parse;
+	xfer_ops->fifo_ctrl = dib3000mc_fifo_control;
+	xfer_ops->pid_ctrl = dib3000mc_pid_control;
+
+	return &state->frontend;
+
+error:
+	if (state)
+		kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops dib3000mc_ops = {
+
+	.info = {
+		.name			= "DiBcom 3000-MC/P DVB-T",
+		.type 			= FE_OFDM,
+		.frequency_min 		= 44250000,
+		.frequency_max 		= 867250000,
+		.frequency_stepsize	= 62500,
+		.caps = FE_CAN_INVERSION_AUTO |
+				FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+				FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+				FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+				FE_CAN_TRANSMISSION_MODE_AUTO |
+				FE_CAN_GUARD_INTERVAL_AUTO |
+				FE_CAN_HIERARCHY_AUTO,
+	},
+
+	.release = dib3000mc_release,
+
+	.init = dib3000mc_fe_init_nonmobile,
+	.sleep = dib3000mc_sleep,
+
+	.set_frontend = dib3000mc_set_frontend_and_tuner,
+	.get_frontend = dib3000mc_get_frontend,
+	.get_tune_settings = dib3000mc_fe_get_tune_settings,
+
+	.read_status = dib3000mc_read_status,
+	.read_ber = dib3000mc_read_ber,
+	.read_signal_strength = dib3000mc_read_signal_strength,
+	.read_snr = dib3000mc_read_snr,
+	.read_ucblocks = dib3000mc_read_unc_blocks,
+};
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(dib3000mc_attach);
diff -Nru a/drivers/media/dvb/frontends/dib3000mc_priv.h b/drivers/media/dvb/frontends/dib3000mc_priv.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/dib3000mc_priv.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,439 @@
+/*
+ * dib3000mc_priv.h
+ *
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ *
+ *	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, version 2.
+ *
+ * for more information see dib3000mc.c .
+ */
+
+#ifndef __DIB3000MC_PRIV_H__
+#define __DIB3000MC_PRIV_H__
+
+/* info and err, taken from usb.h, if there is anything available like by default,
+ * please change !
+ */
+#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg)
+#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg)
+
+// defines the phase noise algorithm to be used (O:Inhib, 1:CPE on)
+#define DEF_PHASE_NOISE_MODE                0
+
+// define Mobille algorithms
+#define DEF_MOBILE_MODE      Auto_Reception
+
+// defines the tuner type
+#define DEF_TUNER_TYPE   TUNER_PANASONIC_ENV57H13D5
+
+// defines the impule noise algorithm to be used
+#define DEF_IMPULSE_NOISE_MODE      0
+
+// defines the MPEG2 data output format
+#define DEF_MPEG2_OUTPUT_188       0
+
+// defines the MPEG2 data output format
+#define DEF_OUTPUT_MODE       MPEG2_PARALLEL_CONTINUOUS_CLOCK
+
+/*
+ * Demodulator parameters
+ * reg: 0  1 1  1 11 11 111
+ *         | |  |  |  |  |
+ *         | |  |  |  |  +-- alpha (000=0, 001=1, 010=2, 100=4)
+ *         | |  |  |  +----- constellation (00=QPSK, 01=16QAM, 10=64QAM)
+ *         | |  |  +-------- guard (00=1/32, 01=1/16, 10=1/8, 11=1/4)
+ *         | |  +----------- transmission mode (0=2k, 1=8k)
+ *         | |
+ *         | +-------------- restart autosearch for parameters
+ *         +---------------- restart the demodulator
+ * reg: 181      1 111 1
+ *               |  |  |
+ *               |  |  +- FEC applies for HP or LP (0=LP, 1=HP)
+ *               |  +---- FEC rate (001=1/2, 010=2/3, 011=3/4, 101=5/6, 111=7/8)
+ *               +------- hierarchy on (0=no, 1=yes)
+ */
+
+/* demodulator tuning parameter and restart options */
+#define DIB3000MC_REG_DEMOD_PARM		(     0)
+#define DIB3000MC_DEMOD_PARM(a,c,g,t)	( \
+		 (0x7 & a) | \
+		((0x3 & c) << 3) | \
+		((0x3 & g) << 5) | \
+		((0x1 & t) << 7) )
+#define DIB3000MC_DEMOD_RST_AUTO_SRCH_ON	(1 << 8)
+#define DIB3000MC_DEMOD_RST_AUTO_SRCH_OFF	(0 << 8)
+#define DIB3000MC_DEMOD_RST_DEMOD_ON		(1 << 9)
+#define DIB3000MC_DEMOD_RST_DEMOD_OFF		(0 << 9)
+
+/* register for hierarchy parameters */
+#define DIB3000MC_REG_HRCH_PARM			(   181)
+#define DIB3000MC_HRCH_PARM(s,f,h)		( \
+		 (0x1 & s) | \
+		((0x7 & f) << 1) | \
+		((0x1 & h) << 4) )
+
+/* timeout ??? */
+#define DIB3000MC_REG_UNK_1				(     1)
+#define DIB3000MC_UNK_1					(  0x04)
+
+/* timeout ??? */
+#define DIB3000MC_REG_UNK_2				(     2)
+#define DIB3000MC_UNK_2					(  0x04)
+
+/* timeout ??? */
+#define DIB3000MC_REG_UNK_3				(     3)
+#define DIB3000MC_UNK_3					(0x1000)
+
+#define DIB3000MC_REG_UNK_4				(     4)
+#define DIB3000MC_UNK_4					(0x0814)
+
+/* timeout ??? */
+#define DIB3000MC_REG_SEQ_TPS			(     5)
+#define DIB3000MC_SEQ_TPS_DEFAULT		(     1)
+#define DIB3000MC_SEQ_TPS(s,t)			( \
+		((s & 0x0f) << 4) | \
+		((t & 0x01) << 8) )
+#define DIB3000MC_IS_TPS(v)				((v << 8) & 0x1)
+#define DIB3000MC_IS_AS(v)				((v >> 4) & 0xf)
+
+/* parameters for the bandwidth */
+#define DIB3000MC_REG_BW_TIMOUT_MSB		(     6)
+#define DIB3000MC_REG_BW_TIMOUT_LSB		(     7)
+
+static u16 dib3000mc_reg_bandwidth[] = { 6,7,8,9,10,11,16,17 };
+
+/*static u16 dib3000mc_bandwidth_5mhz[] =
+	{ 0x28, 0x9380, 0x87, 0x4100, 0x2a4, 0x4500, 0x1, 0xb0d0 };*/
+
+static u16 dib3000mc_bandwidth_6mhz[] =
+	{ 0x21, 0xd040, 0x70, 0xb62b, 0x233, 0x8ed5, 0x1, 0xb0d0 };
+
+static u16 dib3000mc_bandwidth_7mhz[] =
+	{ 0x1c, 0xfba5, 0x60, 0x9c25, 0x1e3, 0x0cb7, 0x1, 0xb0d0 };
+
+static u16 dib3000mc_bandwidth_8mhz[] =
+	{ 0x19, 0x5c30, 0x54, 0x88a0, 0x1a6, 0xab20, 0x1, 0xb0b0 };
+
+static u16 dib3000mc_reg_bandwidth_general[] = { 12,13,14,15 };
+static u16 dib3000mc_bandwidth_general[] = { 0x0000, 0x03e8, 0x0000, 0x03f2 };
+
+/* lock mask */
+#define DIB3000MC_REG_LOCK_MASK			(    15)
+#define DIB3000MC_ACTIVATE_LOCK_MASK	(0x0800)
+
+/* reset the uncorrected packet count (??? do it 5 times) */
+#define DIB3000MC_REG_RST_UNC			(    18)
+#define DIB3000MC_RST_UNC_ON			(     1)
+#define DIB3000MC_RST_UNC_OFF			(     0)
+
+#define DIB3000MC_REG_UNK_19			(    19)
+#define DIB3000MC_UNK_19				(     0)
+
+/* DDS frequency value (IF position) and inversion bit */
+#define DIB3000MC_REG_INVERSION			(    21)
+#define DIB3000MC_REG_SET_DDS_FREQ_MSB	(    21)
+#define DIB3000MC_DDS_FREQ_MSB_INV_OFF	(0x0164)
+#define DIB3000MC_DDS_FREQ_MSB_INV_ON	(0x0364)
+
+#define DIB3000MC_REG_SET_DDS_FREQ_LSB	(    22)
+#define DIB3000MC_DDS_FREQ_LSB			(0x463d)
+
+/* timing frequencies setting */
+#define DIB3000MC_REG_TIMING_FREQ_MSB	(    23)
+#define DIB3000MC_REG_TIMING_FREQ_LSB	(    24)
+#define DIB3000MC_CLOCK_REF				(0x151fd1)
+
+//static u16 dib3000mc_reg_timing_freq[] = { 23,24 };
+
+//static u16 dib3000mc_timing_freq[][2] = {
+//	{ 0x69, 0x9f18 }, /* 5 MHz */
+//	{ 0x7e ,0xbee9 }, /* 6 MHz */
+//	{ 0x93 ,0xdebb }, /* 7 MHz */
+//	{ 0xa8 ,0xfe8c }, /* 8 MHz */
+//};
+
+/* timeout ??? */
+static u16 dib3000mc_reg_offset[] = { 26,33 };
+
+static u16 dib3000mc_offset[][2] = {
+	{ 26240, 5 }, /* default */
+	{ 30336, 6 }, /* 8K */
+	{ 38528, 8 }, /* 2K */
+};
+
+#define DIB3000MC_REG_ISI				(    29)
+#define DIB3000MC_ISI_DEFAULT			(0x1073)
+#define DIB3000MC_ISI_ACTIVATE			(0x0000)
+#define DIB3000MC_ISI_INHIBIT			(0x0200)
+
+/* impulse noise control */
+static u16 dib3000mc_reg_imp_noise_ctl[] = { 34,35 };
+
+static u16 dib3000mc_imp_noise_ctl[][2] = {
+	{ 0x1294, 0xfff8 }, /* mode 0 */
+	{ 0x1294, 0xfff8 }, /* mode 1 */
+	{ 0x1294, 0xfff8 }, /* mode 2 */
+	{ 0x1294, 0xfff8 }, /* mode 3 */
+	{ 0x1294, 0xfff8 }, /* mode 4 */
+};
+
+/* AGC registers */
+static u16 dib3000mc_reg_agc[] = {
+	36,37,38,39,42,43,44,45,46,47,48,49
+};
+
+static u16 dib3000mc_agc_tuner[][12] = {
+	{	0x0051, 0x301d, 0x0000, 0x1cc7, 0xcf5c, 0x6666,
+		0xbae1, 0xa148, 0x3b5e, 0x3c1c, 0x001a, 0x2019
+	}, /* TUNER_PANASONIC_ENV77H04D5, */
+
+	{	0x0051, 0x301d, 0x0000, 0x1cc7, 0xdc29, 0x570a,
+		0xbae1, 0x8ccd, 0x3b6d, 0x551d, 0x000a, 0x951e
+	}, /* TUNER_PANASONIC_ENV57H13D5, TUNER_PANASONIC_ENV57H12D5 */
+
+	{	0x0051, 0x301d, 0x0000, 0x1cc7, 0xffff, 0xffff,
+		0xffff, 0x0000, 0xfdfd, 0x4040, 0x00fd, 0x4040
+	}, /* TUNER_SAMSUNG_DTOS333IH102, TUNER_RFAGCIN_UNKNOWN */
+
+	{	0x0196, 0x301d, 0x0000, 0x1cc7, 0xbd71, 0x5c29,
+		0xb5c3, 0x6148, 0x6569, 0x5127, 0x0033, 0x3537
+	}, /* TUNER_PROVIDER_X */
+	/* TODO TUNER_PANASONIC_ENV57H10D8, TUNER_PANASONIC_ENV57H11D8 */
+};
+
+/* AGC loop bandwidth */
+static u16 dib3000mc_reg_agc_bandwidth[] = { 40,41 };
+static u16 dib3000mc_agc_bandwidth[]  = { 0x119,0x330 };
+
+static u16 dib3000mc_reg_agc_bandwidth_general[] = { 50,51,52,53,54 };
+static u16 dib3000mc_agc_bandwidth_general[] =
+	{ 0x8000, 0x91ca, 0x01ba, 0x0087, 0x0087 };
+
+#define DIB3000MC_REG_IMP_NOISE_55 		(    55)
+#define DIB3000MC_IMP_NEW_ALGO(w)		(w | (1<<10))
+
+/* Impulse noise params */
+static u16 dib3000mc_reg_impulse_noise[] = { 55,56,57 };
+static u16 dib3000mc_impluse_noise[][3] = {
+	{ 0x489, 0x89, 0x72 }, /* 5 MHz */
+	{ 0x4a5, 0xa5, 0x89 }, /* 6 MHz */
+	{ 0x4c0, 0xc0, 0xa0 }, /* 7 MHz */
+	{ 0x4db, 0xdb, 0xb7 }, /* 8 Mhz */
+};
+
+static u16 dib3000mc_reg_fft[] = {
+	58,59,60,61,62,63,64,65,66,67,68,69,
+	70,71,72,73,74,75,76,77,78,79,80,81,
+	82,83,84,85,86
+};
+
+static u16 dib3000mc_fft_modes[][29] = {
+	{	0x38, 0x6d9, 0x3f28, 0x7a7, 0x3a74, 0x196, 0x32a, 0x48c,
+		0x3ffe, 0x7f3, 0x2d94, 0x76, 0x53d,
+		0x3ff8, 0x7e3, 0x3320, 0x76, 0x5b3,
+	  	0x3feb, 0x7d2, 0x365e, 0x76, 0x48c,
+	  	0x3ffe, 0x5b3, 0x3feb, 0x76,   0x0, 0xd
+	}, /* fft mode 0 */
+	{	0x3b, 0x6d9, 0x3f28, 0x7a7, 0x3a74, 0x196, 0x32a, 0x48c,
+		0x3ffe, 0x7f3, 0x2d94, 0x76, 0x53d,
+		0x3ff8, 0x7e3, 0x3320, 0x76, 0x5b3,
+	  	0x3feb, 0x7d2, 0x365e, 0x76, 0x48c,
+	  	0x3ffe, 0x5b3, 0x3feb, 0x0,  0x8200, 0xd
+	}, /* fft mode 1 */
+};
+
+#define DIB3000MC_REG_UNK_88			(    88)
+#define DIB3000MC_UNK_88				(0x0410)
+
+static u16 dib3000mc_reg_bw[] = { 93,94,95,96,97,98 };
+static u16 dib3000mc_bw[][6] = {
+	{ 0,0,0,0,0,0 }, /* 5 MHz */
+	{ 0,0,0,0,0,0 }, /* 6 MHz */
+	{ 0,0,0,0,0,0 }, /* 7 MHz */
+	{ 0x20, 0x21, 0x20, 0x23, 0x20, 0x27 }, /* 8 MHz */
+};
+
+
+/* phase noise control */
+#define DIB3000MC_REG_UNK_99			(    99)
+#define DIB3000MC_UNK_99				(0x0220)
+
+#define DIB3000MC_REG_SCAN_BOOST		(   100)
+#define DIB3000MC_SCAN_BOOST_ON			((11 << 6) + 6)
+#define DIB3000MC_SCAN_BOOST_OFF		((16 << 6) + 9)
+
+/* timeout ??? */
+#define DIB3000MC_REG_UNK_110			(   110)
+#define DIB3000MC_UNK_110				(  3277)
+
+#define DIB3000MC_REG_UNK_111			(   111)
+#define DIB3000MC_UNK_111_PH_N_MODE_0	(     0)
+#define DIB3000MC_UNK_111_PH_N_MODE_1	(1 << 1)
+
+/* superious rm config */
+#define DIB3000MC_REG_UNK_120			(   120)
+#define DIB3000MC_UNK_120				(  8207)
+
+#define DIB3000MC_REG_UNK_133			(   133)
+#define DIB3000MC_UNK_133				( 15564)
+
+#define DIB3000MC_REG_UNK_134			(   134)
+#define DIB3000MC_UNK_134				(     0)
+
+/* adapter config for constellation */
+static u16 dib3000mc_reg_adp_cfg[] = { 129, 130, 131, 132 };
+
+static u16 dib3000mc_adp_cfg[][4] = {
+	{ 0x99a, 0x7fae, 0x333, 0x7ff0 }, /* QPSK  */
+	{ 0x23d, 0x7fdf, 0x0a4, 0x7ff0 }, /* 16-QAM */
+	{ 0x148, 0x7ff0, 0x0a4, 0x7ff8 }, /* 64-QAM */
+};
+
+static u16 dib3000mc_reg_mobile_mode[] = { 139, 140, 141, 175, 1032 };
+
+static u16 dib3000mc_mobile_mode[][5] = {
+	{ 0x01, 0x0, 0x0, 0x00, 0x12c }, /* fixed */
+	{ 0x01, 0x0, 0x0, 0x00, 0x12c }, /* portable */
+	{ 0x00, 0x0, 0x0, 0x02, 0x000 }, /* mobile */
+	{ 0x00, 0x0, 0x0, 0x02, 0x000 }, /* auto */
+};
+
+#define DIB3000MC_REG_DIVERSITY1		(   177)
+#define DIB3000MC_DIVERSITY1_DEFAULT	(     1)
+
+#define DIB3000MC_REG_DIVERSITY2		(   178)
+#define DIB3000MC_DIVERSITY2_DEFAULT	(     1)
+
+#define DIB3000MC_REG_DIVERSITY3		(   180)
+#define DIB3000MC_DIVERSITY3_IN_OFF		(0xfff0)
+#define DIB3000MC_DIVERSITY3_IN_ON		(0xfff6)
+
+#define DIB3000MC_REG_FEC_CFG			(   195)
+#define DIB3000MC_FEC_CFG				(  0x10)
+
+#define DIB3000MC_REG_SMO_MODE			(   206)
+#define DIB3000MC_SMO_MODE_DEFAULT		(1 << 2)
+#define DIB3000MC_SMO_MODE_FIFO_FLUSH	(1 << 3)
+#define DIB3000MC_SMO_MODE_FIFO_UNFLUSH	~DIB3000MC_SMO_MODE_FIFO_FLUSH
+#define DIB3000MC_SMO_MODE_PID_PARSE	(1 << 4)
+#define DIB3000MC_SMO_MODE_NO_PID_PARSE	~DIB3000MC_SMO_MODE_PID_PARSE
+#define DIB3000MC_SMO_MODE_188			(1 << 5)
+#define DIB3000MC_SMO_MODE_SLAVE		(DIB3000MC_SMO_MODE_DEFAULT | \
+			DIB3000MC_SMO_MODE_188 | DIB3000MC_SMO_MODE_PID_PARSE | (1<<1))
+
+#define DIB3000MC_REG_FIFO_THRESHOLD	(   207)
+#define DIB3000MC_FIFO_THRESHOLD_DEFAULT	(  1792)
+#define DIB3000MC_FIFO_THRESHOLD_SLAVE	(   512)
+/*
+ * pidfilter
+ * it is not a hardware pidfilter but a filter which drops all pids
+ * except the ones set. When connected to USB1.1 bandwidth this is important.
+ * DiB3000-MC/P can filter up to 32 PIDs
+ */
+#define DIB3000MC_REG_FIRST_PID			(   212)
+#define DIB3000MC_NUM_PIDS				(    32)
+
+#define DIB3000MC_REG_OUTMODE			(   244)
+#define DIB3000MC_OM_PARALLEL_GATED_CLK	(     0)
+#define DIB3000MC_OM_PAR_CONT_CLK		(1 << 11)
+#define DIB3000MC_OM_SERIAL				(2 << 11)
+#define DIB3000MC_OM_DIVOUT_ON			(4 << 11)
+#define DIB3000MC_OM_SLAVE				(DIB3000MC_OM_DIVOUT_ON | DIB3000MC_OM_PAR_CONT_CLK)
+
+#define DIB3000MC_REG_RF_POWER			(   392)
+
+#define DIB3000MC_REG_FFT_POSITION		(   407)
+
+#define DIB3000MC_REG_DDS_FREQ_MSB		(   414)
+#define DIB3000MC_REG_DDS_FREQ_LSB		(   415)
+
+#define DIB3000MC_REG_TIMING_OFFS_MSB	(   416)
+#define DIB3000MC_REG_TIMING_OFFS_LSB	(   417)
+
+#define DIB3000MC_REG_TUNING_PARM		(   458)
+#define DIB3000MC_TP_QAM(v)				((v >> 13) & 0x03)
+#define DIB3000MC_TP_HRCH(v)			((v >> 12) & 0x01)
+#define DIB3000MC_TP_ALPHA(v)			((v >> 9) & 0x07)
+#define DIB3000MC_TP_FFT(v)				((v >> 8) & 0x01)
+#define DIB3000MC_TP_FEC_CR_HP(v)		((v >> 5) & 0x07)
+#define DIB3000MC_TP_FEC_CR_LP(v)		((v >> 2) & 0x07)
+#define DIB3000MC_TP_GUARD(v)			(v & 0x03)
+
+#define DIB3000MC_REG_SIGNAL_NOISE_MSB	(   483)
+#define DIB3000MC_REG_SIGNAL_NOISE_LSB	(   484)
+
+#define DIB3000MC_REG_MER				(   485)
+
+#define DIB3000MC_REG_BER_MSB			(   500)
+#define DIB3000MC_REG_BER_LSB			(   501)
+
+#define DIB3000MC_REG_PACKET_ERRORS		(   503)
+
+#define DIB3000MC_REG_PACKET_ERROR_COUNT	(   506)
+
+#define DIB3000MC_REG_LOCK_507			(   507)
+#define DIB3000MC_LOCK_507				(0x0002) // ? name correct ?
+
+#define DIB3000MC_REG_LOCKING			(   509)
+#define DIB3000MC_AGC_LOCK(v)			(v & 0x8000)
+#define DIB3000MC_CARRIER_LOCK(v)		(v & 0x2000)
+#define DIB3000MC_MPEG_SYNC_LOCK(v)		(v & 0x0080)
+#define DIB3000MC_MPEG_DATA_LOCK(v)		(v & 0x0040)
+#define DIB3000MC_TPS_LOCK(v)			(v & 0x0004)
+
+#define DIB3000MC_REG_AS_IRQ			(   511)
+#define DIB3000MC_AS_IRQ_SUCCESS		(1 << 1)
+#define DIB3000MC_AS_IRQ_FAIL			(     1)
+
+#define DIB3000MC_REG_TUNER				(   769)
+
+#define DIB3000MC_REG_RST_I2C_ADDR		(  1024)
+#define DIB3000MC_DEMOD_ADDR_ON			(     1)
+#define DIB3000MC_DEMOD_ADDR(a)			((a << 3) & 0x03F0)
+
+#define DIB3000MC_REG_RESTART			(  1027)
+#define DIB3000MC_RESTART_OFF			(0x0000)
+#define DIB3000MC_RESTART_AGC			(0x0800)
+#define DIB3000MC_RESTART_CONFIG		(0x8000)
+
+#define DIB3000MC_REG_RESTART_VIT		(  1028)
+#define DIB3000MC_RESTART_VIT_OFF		(     0)
+#define DIB3000MC_RESTART_VIT_ON		(     1)
+
+#define DIB3000MC_REG_CLK_CFG_1			(  1031)
+#define DIB3000MC_CLK_CFG_1_POWER_UP	(     0)
+#define DIB3000MC_CLK_CFG_1_POWER_DOWN	(0xffff)
+
+#define DIB3000MC_REG_CLK_CFG_2			(  1032)
+#define DIB3000MC_CLK_CFG_2_PUP_FIXED	(0x012c)
+#define DIB3000MC_CLK_CFG_2_PUP_PORT	(0x0104)
+#define DIB3000MC_CLK_CFG_2_PUP_MOBILE  (0x0000)
+#define DIB3000MC_CLK_CFG_2_POWER_DOWN	(0xffff)
+
+#define DIB3000MC_REG_CLK_CFG_3			(  1033)
+#define DIB3000MC_CLK_CFG_3_POWER_UP	(     0)
+#define DIB3000MC_CLK_CFG_3_POWER_DOWN	(0xfff5)
+
+#define DIB3000MC_REG_CLK_CFG_7			(  1037)
+#define DIB3000MC_CLK_CFG_7_INIT		( 12592)
+#define DIB3000MC_CLK_CFG_7_POWER_UP	(~0x0003)
+#define DIB3000MC_CLK_CFG_7_PWR_DOWN	(0x0003)
+#define DIB3000MC_CLK_CFG_7_DIV_IN_OFF	(1 << 8)
+
+/* was commented out ??? */
+#define DIB3000MC_REG_CLK_CFG_8			(  1038)
+#define DIB3000MC_CLK_CFG_8_POWER_UP	(0x160c)
+
+#define DIB3000MC_REG_CLK_CFG_9			(  1039)
+#define DIB3000MC_CLK_CFG_9_POWER_UP	(     0)
+
+/* also clock ??? */
+#define DIB3000MC_REG_ELEC_OUT			(  1040)
+#define DIB3000MC_ELEC_OUT_HIGH_Z		(     0)
+#define DIB3000MC_ELEC_OUT_DIV_OUT_ON	(     1)
+#define DIB3000MC_ELEC_OUT_SLAVE		(     3)
+
+#endif
diff -Nru a/drivers/media/dvb/frontends/dst-bt878.h b/drivers/media/dvb/frontends/dst-bt878.h
--- a/drivers/media/dvb/frontends/dst-bt878.h	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,38 +0,0 @@
-/*
- * dst-bt878.h: part of the DST driver for the TwinHan DST Frontend
- *
- * Copyright (C) 2003 Jamie Honan
- */
-
-struct dst_gpio_enable {
-	u32	mask;
-	u32	enable;
-};
-
-struct dst_gpio_output {
-	u32	mask;
-	u32	highvals;
-};
-
-struct dst_gpio_read {
-	unsigned long value;
-};
-
-union dst_gpio_packet {
-	struct dst_gpio_enable enb;
-	struct dst_gpio_output outp;
-	struct dst_gpio_read rd;
-	int    psize;
-};
-
-#define DST_IG_ENABLE	0
-#define DST_IG_WRITE	1
-#define DST_IG_READ	2
-#define DST_IG_TS       3
-
-struct bt878 ;
-
-int
-bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *mp);
-
-struct bt878 *bt878_find_by_dvb_adap(struct dvb_adapter *adap);
diff -Nru a/drivers/media/dvb/frontends/dst.c b/drivers/media/dvb/frontends/dst.c
--- a/drivers/media/dvb/frontends/dst.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1187 +0,0 @@
-/* 
-    Frontend-driver for TwinHan DST Frontend
-
-    Copyright (C) 2003 Jamie Honan
-
-
-
-    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.
-
-*/    
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/delay.h>
-#include <asm/div64.h>
-
-#include "dvb_frontend.h"
-#include "dvb_functions.h"
-#include "dst-bt878.h"
-
-unsigned int dst_debug = 0;
-unsigned int dst_verbose = 0;
-
-MODULE_PARM(dst_verbose, "i");
-MODULE_PARM_DESC(dst_verbose,
-		 "verbose startup messages, default is 1 (yes)");
-MODULE_PARM(dst_debug, "i");
-MODULE_PARM_DESC(dst_debug, "debug messages, default is 0 (no)");
-
-#define DST_MAX_CARDS	6
-unsigned int dst_cur_no = 0;
-
-unsigned int dst_type[DST_MAX_CARDS] = { [0 ... (DST_MAX_CARDS-1)] = (-1U)};
-unsigned int dst_type_flags[DST_MAX_CARDS] = { [0 ... (DST_MAX_CARDS-1)] = (-1U)};
-MODULE_PARM(dst_type, "1-" __stringify(DST_MAX_CARDS) "i");
-MODULE_PARM_DESC(dst_type,
-		"Type of DST card, 0 Satellite, 1 terrestial TV, 2 Cable, default driver determined");
-MODULE_PARM(dst_type_flags, "1-" __stringify(DST_MAX_CARDS) "i");
-MODULE_PARM_DESC(dst_type_flags,
-		"Type flags of DST card, bitfield 1=10 byte tuner, 2=TS is 204, 4=symdiv");
-
-#define dprintk	if (dst_debug) printk
-
-#define DST_TYPE_IS_SAT		0
-#define DST_TYPE_IS_TERR	1
-#define DST_TYPE_IS_CABLE	2
-
-#define DST_TYPE_HAS_NEWTUNE	1
-#define DST_TYPE_HAS_TS204	2
-#define DST_TYPE_HAS_SYMDIV	4
-
-#define HAS_LOCK	1
-#define ATTEMPT_TUNE	2
-#define HAS_POWER	4
-
-struct dst_data {
-	u8	tx_tuna[10];
-	u8	rx_tuna[10];
-	u8	rxbuffer[10];
-	u8	diseq_flags;
-	u8	dst_type;
-	u32	type_flags;
-	u32 frequency;     /* intermediate frequency in kHz for QPSK */
-        fe_spectral_inversion_t inversion;
-        u32   symbol_rate;  /* symbol rate in Symbols per second */
-	fe_code_rate_t  fec;
-	fe_sec_voltage_t voltage;
-	fe_sec_tone_mode_t tone;
-	u32 decode_freq;
-	u8  decode_lock;
-	u16 decode_strength;
-	u16 decode_snr;
-	unsigned long cur_jiff;
-	u8  k22;
-	fe_bandwidth_t bandwidth;
-	struct bt878 *bt;
-	struct dvb_i2c_bus *i2c;
-} ;
-
-static struct dvb_frontend_info dst_info_sat = {
-	.name 			= "DST SAT",
-	.type 			= FE_QPSK,
-	.frequency_min 		= 950000,
-	.frequency_max 		= 2150000,
-	.frequency_stepsize 	= 1000,           /* kHz for QPSK frontends */
-	.frequency_tolerance 	= 29500,
-	.symbol_rate_min	= 1000000,
-	.symbol_rate_max	= 45000000,
-/*     . symbol_rate_tolerance	= 	???,*/
-	.notifier_delay		= 50,                /* 1/20 s */
-	.caps = FE_CAN_FEC_AUTO |
-		FE_CAN_QPSK
-};
-
-static struct dvb_frontend_info dst_info_cable = {
-	.name 			= "DST CABLE",
-	.type 			= FE_QAM,
-        .frequency_stepsize 	= 62500,
-	.frequency_min 		= 51000000,
-	.frequency_max 		= 858000000,
-	.symbol_rate_min	= 1000000,
-	.symbol_rate_max	= 45000000,
-/*     . symbol_rate_tolerance	= 	???,*/
-	.notifier_delay		= 50,                /* 1/20 s */
-	.caps = FE_CAN_FEC_AUTO |
-		FE_CAN_QAM_AUTO
-};
-
-static struct dvb_frontend_info dst_info_tv = {
-	.name 			= "DST TERR",
-	.type 			= FE_OFDM,
-	.frequency_min 		= 137000000,
-	.frequency_max 		= 858000000,
-	.frequency_stepsize 	= 166667,
-	.caps = FE_CAN_FEC_AUTO |
-	    FE_CAN_QAM_AUTO |
-	    FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
-};
-
-static void dst_packsize(struct dst_data *dst, int psize)
-{
-	union dst_gpio_packet bits;
-
-	bits.psize = psize;
-	bt878_device_control(dst->bt, DST_IG_TS, &bits);
-}
-
-static int dst_gpio_outb(struct dst_data *dst, u32 mask, u32 enbb, u32 outhigh)
-{
-	union dst_gpio_packet enb;
-	union dst_gpio_packet bits;
-	int err;
-
-	enb.enb.mask = mask;
-	enb.enb.enable = enbb;
-        if ((err = bt878_device_control(dst->bt, DST_IG_ENABLE, &enb)) < 0) {
-		dprintk ("%s: dst_gpio_enb error (err == %i, mask == 0x%02x, enb == 0x%02x)\n", __FUNCTION__, err, mask, enbb);
-		return -EREMOTEIO;
-	}
-
-	/* because complete disabling means no output, no need to do
-	 * output packet */
-	if (enbb == 0)
-		return 0;
-
-	bits.outp.mask = enbb;
-	bits.outp.highvals = outhigh;
-
-        if ((err = bt878_device_control(dst->bt, DST_IG_WRITE, &bits)) < 0) {
-		dprintk ("%s: dst_gpio_outb error (err == %i, enbb == 0x%02x, outhigh == 0x%02x)\n", __FUNCTION__, err, enbb, outhigh);
-		return -EREMOTEIO;
-	}
-        return 0;
-}
-
-static int dst_gpio_inb(struct dst_data *dst, u8 *result)
-{
-	union dst_gpio_packet rd_packet;
-	int err;
-
-	*result = 0;
-
-        if ((err = bt878_device_control(dst->bt, DST_IG_READ, &rd_packet)) < 0) {
-		dprintk ("%s: dst_gpio_inb error (err == %i)\n", __FUNCTION__, err);
-		return -EREMOTEIO;
-	}
-	*result = (u8)rd_packet.rd.value;
-        return 0;
-}
-
-#define DST_I2C_ENABLE	1
-#define DST_8820  	2
-
-static int
-dst_reset8820(struct dst_data *dst)
-{
-int retval;
-	/* pull 8820 gpio pin low, wait, high, wait, then low */
-	// dprintk ("%s: reset 8820\n", __FUNCTION__);
-	retval = dst_gpio_outb(dst, DST_8820, DST_8820, 0);
-	if (retval < 0)
-		return retval;
-	dvb_delay(10);
-	retval = dst_gpio_outb(dst, DST_8820, DST_8820, DST_8820);
-	if (retval < 0)
-		return retval;
-	/* wait for more feedback on what works here *
-	dvb_delay(10);
-	retval = dst_gpio_outb(dst, DST_8820, DST_8820, 0);
-	if (retval < 0)
-		return retval;
-	*/
-	return 0;
-}
-
-static int
-dst_i2c_enable(struct dst_data *dst)
-{
-int retval;
-	/* pull I2C enable gpio pin low, wait */
-	// dprintk ("%s: i2c enable\n", __FUNCTION__);
-	retval = dst_gpio_outb(dst, ~0, DST_I2C_ENABLE, 0);
-	if (retval < 0)
-		return retval;
-	// dprintk ("%s: i2c enable delay\n", __FUNCTION__);
-	dvb_delay(33);
-	return 0;
-}
-
-static int
-dst_i2c_disable(struct dst_data *dst)
-{
-int retval;
-	/* release I2C enable gpio pin, wait */
-	// dprintk ("%s: i2c disable\n", __FUNCTION__);
-	retval = dst_gpio_outb(dst, ~0, 0, 0);
-	if (retval < 0)
-		return retval;
-	// dprintk ("%s: i2c disable delay\n", __FUNCTION__);
-	dvb_delay(33);
-	return 0;
-}
-
-static int
-dst_wait_dst_ready(struct dst_data *dst)
-{
-u8 reply;
-int retval;
-int i;
-	for (i = 0; i < 200; i++) {
-		retval = dst_gpio_inb(dst, &reply);
-		if (retval < 0)
-			return retval;
-		if ((reply & DST_I2C_ENABLE) == 0) {
-			dprintk ("%s: dst wait ready after %d\n", __FUNCTION__, i);
-			return 1;
-		}
-		dvb_delay(5);
-	}
-	dprintk ("%s: dst wait NOT ready after %d\n", __FUNCTION__, i);
-	return 0;
-}
-
-#define DST_I2C_ADDR 0x55
-
-static int write_dst (struct dst_data *dst, u8 *data, u8 len)
-{
-	struct i2c_msg msg = {
-		.addr = DST_I2C_ADDR, .flags = 0, .buf = data, .len = len };
-	int err;
-	int cnt;
-
-	if (dst_debug && dst_verbose) {
-		u8 i;
-		dprintk("%s writing",__FUNCTION__);
-		for (i = 0 ; i < len ; i++) {
-			dprintk(" 0x%02x", data[i]);
-		}
-		dprintk("\n");
-	}
-	dvb_delay(30);
-	for (cnt = 0; cnt < 4; cnt++) {
-		if ((err = dst->i2c->xfer (dst->i2c, &msg, 1)) < 0) {
-			dprintk ("%s: write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]);
-			dst_i2c_disable(dst);
-			dvb_delay(500);
-			dst_i2c_enable(dst);
-			dvb_delay(500);
-			continue;
-		} else
-			break;
-	}
-	if (cnt >= 4)
-		return -EREMOTEIO;
-        return 0;
-}
-
-static int read_dst (struct dst_data *dst, u8 *ret, u8 len)
-{
-	struct i2c_msg msg = 
-		{ .addr = DST_I2C_ADDR, .flags = I2C_M_RD, .buf = ret, .len = len };
-	int err;
-	int cnt;
-
-	for (cnt = 0; cnt < 4; cnt++) {
-		if ((err = dst->i2c->xfer (dst->i2c, &msg, 1)) < 0) {
-			dprintk ("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]);
-			dst_i2c_disable(dst);
-			dst_i2c_enable(dst);
-			continue;
-		} else
-			break;
-	}
-	if (cnt >= 4)
-		return -EREMOTEIO;
-	dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]);
-	if (dst_debug && dst_verbose) {
-		for (err = 1; err < len; err++)
-			dprintk(" 0x%x", ret[err]);
-		if (err > 1)
-			dprintk("\n");
-	}
-	return 0;
-}
-
-static int dst_set_freq(struct dst_data *dst, u32 freq)
-{
-	u8 *val;
-
-	dst->frequency = freq;
-
-	// dprintk("%s: set frequency %u\n", __FUNCTION__, freq);
-	if (dst->dst_type == DST_TYPE_IS_SAT) {
-		freq = freq / 1000;
-		if (freq < 950 || freq > 2150)
-			return -EINVAL;
-		val = &dst->tx_tuna[0];
-		val[2] = (freq >> 8) & 0x7f;
-		val[3] = (u8)freq;
-		val[4] = 1;
-		val[8] &= ~4;
-		if (freq < 1531)
-			val[8] |= 4;
-	} else if (dst->dst_type == DST_TYPE_IS_TERR) {
-		freq = freq / 1000;
-		if (freq < 137000 || freq > 858000)
-			return -EINVAL;
-		val = &dst->tx_tuna[0];
-		val[2] = (freq >> 16) & 0xff;
-		val[3] = (freq >> 8) & 0xff;
-		val[4] = (u8)freq;
-		val[5] = 0;
-		switch (dst->bandwidth) {
-		case BANDWIDTH_6_MHZ:
-			val[6] = 6;
-			break;
-
-		case BANDWIDTH_7_MHZ:
-		case BANDWIDTH_AUTO:
-			val[6] = 7;
-			break;
-
-		case BANDWIDTH_8_MHZ:
-			val[6] = 8;
-			break;
-		}
-
-		val[7] = 0;
-		val[8] = 0;
-	} else if (dst->dst_type == DST_TYPE_IS_CABLE) {
-		/* guess till will get one */
-		freq = freq / 1000;
-		val = &dst->tx_tuna[0];
-		val[2] = (freq >> 16) & 0xff;
-		val[3] = (freq >> 8) & 0xff;
-		val[4] = (u8)freq;
-	} else
-		return -EINVAL;
-	return 0;
-}
-
-static int dst_set_bandwidth(struct dst_data *dst, fe_bandwidth_t bandwidth)
-{
-	u8 *val;
-
-	dst->bandwidth = bandwidth;
-
-	if (dst->dst_type != DST_TYPE_IS_TERR)
-		return 0;
-
-	val = &dst->tx_tuna[0];
-        switch (bandwidth) {
-	case BANDWIDTH_6_MHZ:
-		val[6] = 6;
-		break;
-
-	case BANDWIDTH_7_MHZ:
-		val[6] = 7;
-		break;
-
-	case BANDWIDTH_8_MHZ:
-		val[6] = 8;
-		break;
-
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int dst_set_inversion (struct dst_data *dst, fe_spectral_inversion_t inversion)
-{
-	u8 *val;
-
-	dst->inversion = inversion;
-
-	val = &dst->tx_tuna[0];
-
-	val[8] &= ~0x80;
-
-	switch (inversion) {
-	case INVERSION_OFF:
-		break;
-	case INVERSION_ON:
-		val[8] |= 0x80;
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-
-static int dst_set_fec (struct dst_data *dst, fe_code_rate_t fec)
-{
-	dst->fec = fec;
-	return 0;
-}
-
-static fe_code_rate_t dst_get_fec (struct dst_data *dst)
-{
-	return dst->fec;
-}
-
-static int dst_set_symbolrate (struct dst_data *dst, u32 srate)
-{
-	u8 *val;
-	u32 symcalc;
-	u64 sval;
-
-	dst->symbol_rate = srate;
-
-	if (dst->dst_type == DST_TYPE_IS_TERR) {
-		return 0;
-	}
-
-	// dprintk("%s: set srate %u\n", __FUNCTION__, srate);
-	srate /= 1000;
-	val = &dst->tx_tuna[0];
-
-	if (dst->type_flags & DST_TYPE_HAS_SYMDIV) {
-		sval = srate;
-		sval <<= 20;
-		do_div(sval, 88000);
-	        symcalc = (u32)sval;
-		// dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc);
-		val[5] = (u8)(symcalc >> 12);
-		val[6] = (u8)(symcalc >> 4);
-		val[7] = (u8)(symcalc << 4);
-	} else {
-		val[5] = (u8)(srate >> 16) & 0x7f;
-		val[6] = (u8)(srate >> 8);
-		val[7] = (u8)srate;
-	}
-	val[8] &= ~0x20;
-	if (srate > 8000)
-		val[8] |= 0x20;
-	return 0;
-}
-
-
-static u8 dst_check_sum(u8 *buf, u32 len)
-{
-	u32 i;
-	u8  val = 0;
-	if (!len)
-		return 0;
-	for (i = 0; i < len; i++) {
-		val += buf[i];
-	}
-	return ((~val) + 1);
-}
-
-typedef struct dst_types {
-	char	*mstr;
-	int	offs;
-	u8	dst_type;
-	u32	type_flags;
-} DST_TYPES;
-
-struct dst_types dst_tlist[] = {
-	{ "DST-020", 0,  DST_TYPE_IS_SAT,    DST_TYPE_HAS_SYMDIV },
-	{ "DST-030", 0,  DST_TYPE_IS_SAT,    DST_TYPE_HAS_TS204|DST_TYPE_HAS_NEWTUNE },
-	{ "DST-03T", 0,  DST_TYPE_IS_SAT,    DST_TYPE_HAS_SYMDIV|DST_TYPE_HAS_TS204},
-	{ "DST-MOT", 0,  DST_TYPE_IS_SAT,    DST_TYPE_HAS_SYMDIV },
-	{ "DST-CI",  1,  DST_TYPE_IS_SAT,    DST_TYPE_HAS_TS204|DST_TYPE_HAS_NEWTUNE },
-	{ "DSTMCI",  1,  DST_TYPE_IS_SAT,    DST_TYPE_HAS_NEWTUNE },
-	{ "DSTFCI",  1,  DST_TYPE_IS_SAT,    DST_TYPE_HAS_NEWTUNE },
-	{ "DCTNEW",  1,  DST_TYPE_IS_CABLE,  DST_TYPE_HAS_NEWTUNE },
-	{ "DCT_CI",  1,  DST_TYPE_IS_CABLE,  DST_TYPE_HAS_NEWTUNE|DST_TYPE_HAS_TS204 },
-	{ "DTTDIG" , 1,  DST_TYPE_IS_TERR,   0} };
-/* DCTNEW and DCT-CI are guesses */
-
-static void dst_type_flags_print(u32 type_flags)
-{
-	printk("DST type flags :");
-	if (type_flags & DST_TYPE_HAS_NEWTUNE)
-		printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE);
-	if (type_flags & DST_TYPE_HAS_TS204)
-		printk(" 0x%x ts204", DST_TYPE_HAS_TS204);
-	if (type_flags & DST_TYPE_HAS_SYMDIV)
-		printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
-	printk("\n");
-}
-
-static int dst_type_print(u8 type)
-{
-	char *otype;
-	switch (type) {
-		case DST_TYPE_IS_SAT:
-			otype = "satellite";
-			break;
-		case DST_TYPE_IS_TERR:
-			otype = "terrestial TV";
-			break;
-		case DST_TYPE_IS_CABLE:
-			otype = "terrestial TV";
-			break;
-		default:
-			printk("%s: invalid dst type %d\n",
-				__FUNCTION__, type);
-			return -EINVAL;
-	}
-	printk("DST type : %s\n", otype);
-	return 0;
-}
-
-static int dst_check_ci (struct dst_data *dst)
-{
-	u8 txbuf[8];
-	u8 rxbuf[8];
-	int retval;
-	int i;
-	struct dst_types *dsp;
-	u8 use_dst_type;
-	u32 use_type_flags;
-
-	memset(txbuf, 0, sizeof(txbuf));
-	txbuf[1] = 6;
-	txbuf[7] = dst_check_sum (txbuf, 7);
- 
-	dst_i2c_enable(dst);
-	dst_reset8820(dst);
-	retval = write_dst (dst, txbuf, 8);
-	if (retval < 0) {
-		dst_i2c_disable(dst);
-		dprintk("%s: write not successful, maybe no card?\n", __FUNCTION__);
-		return retval;
-	}
-	dvb_delay(3);
-	retval = read_dst (dst, rxbuf, 1);
-	dst_i2c_disable(dst);
-	if (retval < 0) {
-		dprintk("%s: read not successful, maybe no card?\n", __FUNCTION__);
-		return retval;
-	}
-	if (rxbuf[0] != 0xff) {
-		dprintk("%s: write reply not 0xff, not ci (%02x)\n", __FUNCTION__, rxbuf[0]);
-		return retval;
-	}
-	if (!dst_wait_dst_ready(dst))
-		return 0;
-	// dst_i2c_enable(i2c); Dimitri
-	retval = read_dst (dst, rxbuf, 8);
-	dst_i2c_disable(dst);
-	if (retval < 0) {
-		dprintk("%s: read not successful\n", __FUNCTION__);
-		return retval;
-	}
-	if (rxbuf[7] != dst_check_sum (rxbuf, 7)) {
-		dprintk("%s: checksum failure\n", __FUNCTION__);
-		return retval;
-	}
-	rxbuf[7] = '\0';
-	for (i = 0, dsp = &dst_tlist[0]; i < sizeof(dst_tlist) / sizeof(dst_tlist[0]); i++, dsp++) {
-		if (!strncmp(&rxbuf[dsp->offs],
-				dsp->mstr,
-				strlen(dsp->mstr))) {
-			use_type_flags = dsp->type_flags;
-			use_dst_type = dsp->dst_type;
-			printk("%s: recognize %s\n", __FUNCTION__, dsp->mstr);
-			break;
-		}
-	}
-	if (i >= sizeof(dst_tlist) / sizeof(dst_tlist[0])) {
-		printk("%s: unable to recognize %s or %s\n", __FUNCTION__, &rxbuf[0], &rxbuf[1]);
-		printk("%s please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__);
-		use_dst_type = DST_TYPE_IS_SAT;
-		use_type_flags = DST_TYPE_HAS_SYMDIV;
-	}
-	switch (dst_type[dst_cur_no]) {
-		case (-1U):
-			/* not used */
-			break;
-		case DST_TYPE_IS_SAT:
-		case DST_TYPE_IS_TERR:
-		case DST_TYPE_IS_CABLE:
-			use_dst_type = (u8)(dst_type[dst_cur_no]);
-			break;
-		default:
-			printk("%s: invalid user override dst type %d, not used\n",
-				__FUNCTION__, dst_type[dst_cur_no]);
-			break;
-	}
-	dst_type_print(use_dst_type);
-	if (dst_type_flags[dst_cur_no] != (-1U)) {
-		printk("%s: user override dst type flags 0x%x\n",
-				__FUNCTION__, dst_type_flags[dst_cur_no]);
-		use_type_flags = dst_type_flags[dst_cur_no];
-	}
-	dst->type_flags = use_type_flags;
-	dst->dst_type= use_dst_type;
-	dst_type_flags_print(dst->type_flags);
-
-	if (dst->type_flags & DST_TYPE_HAS_TS204) {
-		dst_packsize(dst, 204);
-	}
-	return 0;
-}
-
-static int dst_command (struct dst_data *dst, u8 *data, u8 len)
-{
-	int retval;
-	u8 reply;
-
-	dst_i2c_enable(dst);
-	dst_reset8820(dst);
-	retval = write_dst (dst, data, len);
-	if (retval < 0) {
-		dst_i2c_disable(dst);
-		dprintk("%s: write not successful\n", __FUNCTION__);
-		return retval;
-	}
-	dvb_delay(33);
-	retval = read_dst (dst, &reply, 1);
-	dst_i2c_disable(dst);
-	if (retval < 0) {
-		dprintk("%s: read verify  not successful\n", __FUNCTION__);
-		return retval;
-	}
-	if (reply != 0xff) {
-		dprintk("%s: write reply not 0xff 0x%02x \n", __FUNCTION__, reply);
-		return 0;
-	}
-	if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
-		return 0;
-	if (!dst_wait_dst_ready(dst))
-		return 0;
-	// dst_i2c_enable(i2c); Per dimitri
-	retval = read_dst (dst, dst->rxbuffer, 8);
-	dst_i2c_disable(dst);
-	if (retval < 0) {
-		dprintk("%s: read not successful\n", __FUNCTION__);
-		return 0;
-	}
-	if (dst->rxbuffer[7] != dst_check_sum (dst->rxbuffer, 7)) {
-		dprintk("%s: checksum failure\n", __FUNCTION__);
-		return 0;
-	}
-	return 0;
-}
-
-static int dst_get_signal(struct dst_data *dst)
-{
-	int retval;
-	u8 get_signal[] = {0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb};
-
-	if ((dst->diseq_flags & ATTEMPT_TUNE) == 0) {
-		dst->decode_lock = dst->decode_strength = dst->decode_snr = 0;
-		return 0;
-	}
-	if (0 == (dst->diseq_flags & HAS_LOCK)) {
-		dst->decode_lock = dst->decode_strength = dst->decode_snr = 0;
-		return 0;
-	}
-	if (time_after_eq(jiffies, dst->cur_jiff + (HZ/5))) {
-		retval =  dst_command(dst, get_signal, 8);
-		if (retval < 0)
-			return retval;
-		if (dst->dst_type == DST_TYPE_IS_SAT) {
-			dst->decode_lock = ((dst->rxbuffer[6] & 0x10) == 0) ?
-					1 : 0;
-			dst->decode_strength = dst->rxbuffer[5] << 8;
-			dst->decode_snr = dst->rxbuffer[2] << 8 |
-				dst->rxbuffer[3];
-		} else if ((dst->dst_type == DST_TYPE_IS_TERR) ||
-				(dst->dst_type == DST_TYPE_IS_CABLE)) {
-			dst->decode_lock = (dst->rxbuffer[1]) ?
-					1 : 0;
-			dst->decode_strength = dst->rxbuffer[4] << 8;
-			dst->decode_snr = dst->rxbuffer[3] << 8;
-		}
-		dst->cur_jiff = jiffies;
-	}
-	return 0;
-}
-
-/*
- * line22k0    0x00, 0x09, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00
- * line22k1    0x00, 0x09, 0x01, 0xff, 0x01, 0x00, 0x00, 0x00
- * line22k2    0x00, 0x09, 0x02, 0xff, 0x01, 0x00, 0x00, 0x00
- * tone        0x00, 0x09, 0xff, 0x00, 0x01, 0x00, 0x00, 0x00
- * data        0x00, 0x09, 0xff, 0x01, 0x01, 0x00, 0x00, 0x00
- * power_off   0x00, 0x09, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00
- * power_on    0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00
- * Diseqc 1    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec
- * Diseqc 2    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf4, 0xe8 
- * Diseqc 3    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf8, 0xe4 
- * Diseqc 4    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 
- */
-
-static int dst_set_diseqc (struct dst_data *dst, u8 *cmd, u8 len)
-{
-	u8 paket[8] =  {0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec };
-
-	if (dst->dst_type == DST_TYPE_IS_TERR)
-		return 0;
-
-	if (len == 0 || len > 4)
-		return -EINVAL;
-	memcpy(&paket[3], cmd, len);
-	paket[7] = dst_check_sum (&paket[0], 7);
-	dst_command(dst, paket, 8);
-	return 0;
-}
-
-static int dst_tone_power_cmd (struct dst_data *dst)
-{
-	u8 paket[8] =  {0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00};
-
-	if (dst->dst_type == DST_TYPE_IS_TERR)
-		return 0;
-
-	if (dst->voltage == SEC_VOLTAGE_OFF) 
-		paket[4] = 0;
-	else
-		paket[4] = 1;
-	if (dst->tone == SEC_TONE_ON)
-		paket[2] = dst->k22;
-	else
-		paket[2] = 0;
-	paket[7] = dst_check_sum (&paket[0], 7);
-	dst_command(dst, paket, 8);
-	return 0;
-}
-
-static int dst_set_voltage (struct dst_data *dst, fe_sec_voltage_t voltage)
-{
-	u8 *val;
-	int need_cmd;
-
-	dst->voltage = voltage;
-
-	if (dst->dst_type == DST_TYPE_IS_TERR)
-		return 0;
-
-	need_cmd = 0;
-	val = &dst->tx_tuna[0];
-	val[8] &= ~0x40;
-	switch (voltage) {
-	case SEC_VOLTAGE_13:
-		if ((dst->diseq_flags & HAS_POWER) == 0)
-			need_cmd = 1;
-		dst->diseq_flags |= HAS_POWER;
-		break;
-	case SEC_VOLTAGE_18:
-		if ((dst->diseq_flags & HAS_POWER) == 0)
-			need_cmd = 1;
-		dst->diseq_flags |= HAS_POWER;
-		val[8] |= 0x40;
-		break;
-	case SEC_VOLTAGE_OFF:
-		need_cmd = 1;
-		dst->diseq_flags &= ~(HAS_POWER|HAS_LOCK|ATTEMPT_TUNE);
-		break;
-	default:
-		return -EINVAL;
-	}
-	if (need_cmd) {
-		dst_tone_power_cmd(dst);
-	}
-	return 0;
-}
-
-
-static int dst_set_tone (struct dst_data *dst, fe_sec_tone_mode_t tone)
-{
-	u8 *val;
-
-	dst->tone = tone;
-
-	if (dst->dst_type == DST_TYPE_IS_TERR)
-		return 0;
-
-	val = &dst->tx_tuna[0];
-
-	val[8] &= ~0x1;
-
-	switch (tone) {
-	case SEC_TONE_OFF:
-		break;
-	case SEC_TONE_ON:
-		val[8] |= 1;
-		break;
-	default:
-		return -EINVAL;
-	}
-	dst_tone_power_cmd(dst);
-	return 0;
-}
-
-static int dst_get_tuna (struct dst_data *dst)
-{
-int retval;
-	if ((dst->diseq_flags & ATTEMPT_TUNE) == 0)
-		return 0;
-	dst->diseq_flags &= ~(HAS_LOCK);
-	if (!dst_wait_dst_ready(dst))
-		return 0;
-	if (dst->type_flags & DST_TYPE_HAS_NEWTUNE) {
-		/* how to get variable length reply ???? */
-		retval = read_dst (dst, dst->rx_tuna, 10);
-	} else {
-		retval = read_dst (dst, &dst->rx_tuna[2], 8);
-	}
-	if (retval < 0) {
-		dprintk("%s: read not successful\n", __FUNCTION__);
-		return 0;
-	}
-	if (dst->type_flags & DST_TYPE_HAS_NEWTUNE) {
-		if (dst->rx_tuna[9] != dst_check_sum (&dst->rx_tuna[0], 9)) {
-			dprintk("%s: checksum failure?\n", __FUNCTION__);
-			return 0;
-		}
-	} else {
-		if (dst->rx_tuna[9] != dst_check_sum (&dst->rx_tuna[2], 7)) {
-			dprintk("%s: checksum failure?\n", __FUNCTION__);
-			return 0;
-		}
-	}
-	if (dst->rx_tuna[2] == 0 && dst->rx_tuna[3] == 0)
-		return 0;
-	dst->decode_freq = ((dst->rx_tuna[2] & 0x7f) << 8) +  dst->rx_tuna[3];
-
-	dst->decode_lock = 1;
-	/*
-	dst->decode_n1 = (dst->rx_tuna[4] << 8) +  
-			(dst->rx_tuna[5]);
-
-	dst->decode_n2 = (dst->rx_tuna[8] << 8) +  
-			(dst->rx_tuna[7]);
-	*/
-	dst->diseq_flags |= HAS_LOCK;
-	/* dst->cur_jiff = jiffies; */
-	return 1;
-}
-
-static int dst_write_tuna (struct dst_data *dst)
-{
-	int retval;
-	u8 reply;
-
-	dprintk("%s: type_flags 0x%x \n", __FUNCTION__, dst->type_flags);
-	dst->decode_freq = 0;
-	dst->decode_lock = dst->decode_strength = dst->decode_snr = 0;
-	if (dst->dst_type == DST_TYPE_IS_SAT) {
-		if (!(dst->diseq_flags & HAS_POWER))
-			dst_set_voltage (dst, SEC_VOLTAGE_13);
-	}
-	dst->diseq_flags &= ~(HAS_LOCK|ATTEMPT_TUNE);
-	dst_i2c_enable(dst);
-	if (dst->type_flags & DST_TYPE_HAS_NEWTUNE) {
-		dst_reset8820(dst);
-		dst->tx_tuna[9] = dst_check_sum (&dst->tx_tuna[0], 9);
-		retval = write_dst (dst, &dst->tx_tuna[0], 10);
-	} else {
-		dst->tx_tuna[9] = dst_check_sum (&dst->tx_tuna[2], 7);
-		retval = write_dst (dst, &dst->tx_tuna[2], 8);
-	}
-	if (retval < 0) {
-		dst_i2c_disable(dst);
-		dprintk("%s: write not successful\n", __FUNCTION__);
-		return retval;
-	}
-	dvb_delay(3);
-	retval = read_dst (dst, &reply, 1);
-	dst_i2c_disable(dst);
-	if (retval < 0) {
-		dprintk("%s: read verify  not successful\n", __FUNCTION__);
-		return retval;
-	}
-	if (reply != 0xff) {
-		dprintk("%s: write reply not 0xff 0x%02x \n", __FUNCTION__, reply);
-		return 0;
-	}
-	dst->diseq_flags |= ATTEMPT_TUNE;
-	return dst_get_tuna(dst);
-}
-
-static void dst_init (struct dst_data *dst)
-{
-static u8 ini_satci_tuna[] = {  9, 0, 3, 0xb6, 1, 0,    0x73, 0x21, 0, 0 };
-static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 };
-static u8 ini_tvfta_tuna[] = { 0, 0,  3, 0xb6, 1, 7,    0x0,   0x0, 0, 0 };
-static u8 ini_tvci_tuna[] = { 9, 0,  3, 0xb6, 1, 7,    0x0,   0x0, 0, 0 };
-static u8 ini_cabfta_tuna[] = { 0, 0,  3, 0xb6, 1, 7,    0x0,   0x0, 0, 0 };
-static u8 ini_cabci_tuna[] = { 9, 0,  3, 0xb6, 1, 7,    0x0,   0x0, 0, 0 };
-	dst->inversion = INVERSION_ON;
-	dst->voltage = SEC_VOLTAGE_13;
-	dst->tone = SEC_TONE_OFF;
-	dst->symbol_rate = 29473000;
-	dst->fec = FEC_AUTO;
-	dst->diseq_flags = 0;
-	dst->k22 = 0x02;
-	dst->bandwidth = BANDWIDTH_7_MHZ;
-	dst->cur_jiff = jiffies;
-	if (dst->dst_type == DST_TYPE_IS_SAT) {
-		dst->frequency = 950000;
-		memcpy(dst->tx_tuna, ((dst->type_flags &  DST_TYPE_HAS_NEWTUNE )? 
-					ini_satci_tuna : ini_satfta_tuna),
-				sizeof(ini_satfta_tuna));
-	} else if (dst->dst_type == DST_TYPE_IS_TERR) {
-		dst->frequency = 137000000;
-		memcpy(dst->tx_tuna, ((dst->type_flags &  DST_TYPE_HAS_NEWTUNE )? 
-					ini_tvci_tuna : ini_tvfta_tuna),
-				sizeof(ini_tvfta_tuna));
-	} else if (dst->dst_type == DST_TYPE_IS_CABLE) {
-		dst->frequency = 51000000;
-		memcpy(dst->tx_tuna, ((dst->type_flags &  DST_TYPE_HAS_NEWTUNE )? 
-					ini_cabci_tuna : ini_cabfta_tuna),
-				sizeof(ini_cabfta_tuna));
-	}
-}
-
-struct lkup {
-	unsigned int cmd;
-	char *desc;
-} looker[] = {
-	{FE_GET_INFO,                "FE_GET_INFO:"},
-	{FE_READ_STATUS,             "FE_READ_STATUS:" },
-	{FE_READ_BER,                "FE_READ_BER:" },
-	{FE_READ_SIGNAL_STRENGTH,    "FE_READ_SIGNAL_STRENGTH:" },
-	{FE_READ_SNR,                "FE_READ_SNR:" },
-	{FE_READ_UNCORRECTED_BLOCKS, "FE_READ_UNCORRECTED_BLOCKS:" },
-	{FE_SET_FRONTEND,            "FE_SET_FRONTEND:" },
-	{FE_GET_FRONTEND,            "FE_GET_FRONTEND:" },
-	{FE_SLEEP,                   "FE_SLEEP:" },
-	{FE_INIT,                    "FE_INIT:" },
-	{FE_SET_TONE,                "FE_SET_TONE:" },
-	{FE_SET_VOLTAGE,             "FE_SET_VOLTAGE:" },
-	};
-
-static int dst_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-	struct dst_data *dst = fe->data;
-	int retval;
-	/*
-	char  *cc;
-                
-	cc = "FE_UNSUPP:";
-	for(retval = 0; retval < sizeof(looker) / sizeof(looker[0]); retval++) {
-		if (looker[retval].cmd == cmd) {
-			cc = looker[retval].desc;
-			break;
-		}
-	}
-	dprintk("%s cmd %s (0x%x)\n",__FUNCTION__, cc, cmd);
-	*/
-	// printk("%s: dst %8.8x bt %8.8x i2c %8.8x\n", __FUNCTION__, dst, dst->bt, dst->i2c);
-	/* should be set by attach, but just in case */
-	dst->i2c = fe->i2c;
-        switch (cmd) {
-        case FE_GET_INFO: 
-	{
-	     struct dvb_frontend_info *info;
-		info = &dst_info_sat;
-		if (dst->dst_type == DST_TYPE_IS_TERR)
-			info = &dst_info_tv;
-		else if (dst->dst_type == DST_TYPE_IS_CABLE)
-			info = &dst_info_cable;
-		memcpy (arg, info, sizeof(struct dvb_frontend_info));
-		break;
-	}
-        case FE_READ_STATUS:
-	{
-		fe_status_t *status = arg;
-
-		*status = 0;
-		if (dst->diseq_flags & HAS_LOCK) {
-			dst_get_signal(dst);
-			if (dst->decode_lock)
-				*status |= FE_HAS_LOCK 
-					| FE_HAS_SIGNAL 
-					| FE_HAS_CARRIER
-					| FE_HAS_SYNC
-					| FE_HAS_VITERBI;
-		}
-		break;
-	}
-
-        case FE_READ_BER:
-	{
-		/* guess */
-		// *(u32*) arg = dst->decode_n1;
-		*(u32*) arg = 0;
-		return -EOPNOTSUPP; 
-	}
-
-        case FE_READ_SIGNAL_STRENGTH:
-	{
-		dst_get_signal(dst);
-		*((u16*) arg) = dst->decode_strength;
-		break;
-	}
-
-        case FE_READ_SNR:
-	{
-		dst_get_signal(dst);
-		*((u16*) arg) = dst->decode_snr;
-		break;
-	}
-
-	case FE_READ_UNCORRECTED_BLOCKS: 
-	{
-		*((u32*) arg) = 0;    /* the stv0299 can't measure BER and */
-		return -EOPNOTSUPP;   /* errors at the same time.... */
-	}
-
-        case FE_SET_FRONTEND:
-        {
-		struct dvb_frontend_parameters *p = arg;
-
-		dst_set_freq (dst, p->frequency);
-		dst_set_inversion (dst, p->inversion);
-		if (dst->dst_type == DST_TYPE_IS_SAT) {
-			dst_set_fec (dst, p->u.qpsk.fec_inner);
-			dst_set_symbolrate (dst, p->u.qpsk.symbol_rate);
-		} else if (dst->dst_type == DST_TYPE_IS_TERR) {
-			dst_set_bandwidth(dst, p->u.ofdm.bandwidth);
-		} else if (dst->dst_type == DST_TYPE_IS_CABLE) {
-			dst_set_fec (dst, p->u.qam.fec_inner);
-			dst_set_symbolrate (dst, p->u.qam.symbol_rate);
-		}
-		dst_write_tuna (dst);
-
-                break;
-        }
-
-	case FE_GET_FRONTEND:
-	{
-		struct dvb_frontend_parameters *p = arg;
-
-
-		p->frequency = dst->decode_freq;
-		p->inversion = dst->inversion;
-		if (dst->dst_type == DST_TYPE_IS_SAT) {
-			p->u.qpsk.symbol_rate = dst->symbol_rate;
-			p->u.qpsk.fec_inner = dst_get_fec (dst);
-		} else if (dst->dst_type == DST_TYPE_IS_TERR) {
-			p->u.ofdm.bandwidth = dst->bandwidth;
-		} else if (dst->dst_type == DST_TYPE_IS_CABLE) {
-			p->u.qam.symbol_rate = dst->symbol_rate;
-			p->u.qam.fec_inner = dst_get_fec (dst);
-			p->u.qam.modulation = QAM_AUTO;
-		}
-		break;
-	}
-
-        case FE_SLEEP:
-		return 0;
-
-        case FE_INIT:
-		dst_init(dst);
-		break;
-
-	case FE_DISEQC_SEND_MASTER_CMD:
-	{
-		struct dvb_diseqc_master_cmd *cmd = (struct dvb_diseqc_master_cmd *)arg;
-		retval = dst_set_diseqc (dst, cmd->msg, cmd->msg_len);
-		if (retval < 0)
-			return retval;
-		break;
-	}
-	case FE_SET_TONE:
-		retval = dst_set_tone (dst, (fe_sec_tone_mode_t) arg);
-		if (retval < 0)
-			return retval;
-		break;
-	case FE_SET_VOLTAGE:
-		retval = dst_set_voltage (dst, (fe_sec_voltage_t) arg);
-		if (retval < 0)
-			return retval;
-		break;
-	default:
-		return -EOPNOTSUPP;
-        };
-        
-        return 0;
-} 
-
-
-static int dst_attach (struct dvb_i2c_bus *i2c, void **data)
-{
-	struct dst_data *dst;
-	struct bt878 *bt;
-	struct dvb_frontend_info *info;
-
-	dprintk("%s: check ci\n", __FUNCTION__);
-	if (dst_cur_no >= DST_MAX_CARDS) {
-		dprintk("%s: can't have more than %d cards\n", __FUNCTION__, DST_MAX_CARDS);
-		return -ENODEV;
-	}
-	bt = bt878_find_by_dvb_adap(i2c->adapter);
-	if (!bt)
-		return -ENODEV;
-	dst = kmalloc(sizeof(struct dst_data), GFP_KERNEL);
-	if (dst == NULL) {
-		printk(KERN_INFO "%s: Out of memory.\n", __FUNCTION__);
-		return -ENOMEM;
-	}
-	memset(dst, 0, sizeof(*dst));
-	*data = dst;
-	dst->bt = bt;
-	dst->i2c = i2c;
-	if (dst_check_ci(dst) < 0) {
-		kfree(dst);
-		return -ENODEV;
-	}
-
-	dst_init (dst);
-	dprintk("%s: register dst %p bt %p i2c %p\n", __FUNCTION__, 
-			dst, dst->bt, dst->i2c);
-
-	info = &dst_info_sat;
-	if (dst->dst_type == DST_TYPE_IS_TERR)
-		info = &dst_info_tv;
-	else if (dst->dst_type == DST_TYPE_IS_CABLE)
-		info = &dst_info_cable;
-
-	dvb_register_frontend (dst_ioctl, i2c, dst, info);
-	dst_cur_no++;
-	return 0;
-}
-
-static void dst_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	dvb_unregister_frontend (dst_ioctl, i2c);
-	dprintk("%s: unregister dst %p\n", __FUNCTION__, data);
-	if (data)
-		kfree(data);
-}
-
-static int __init init_dst (void)
-{
-	return dvb_register_i2c_device (THIS_MODULE, dst_attach, dst_detach);
-}
-
-static void __exit exit_dst (void)
-{
-	dvb_unregister_i2c_device (dst_attach);
-}
-
-
-module_init(init_dst);
-module_exit(exit_dst);
-
-MODULE_DESCRIPTION("DST DVB-S Frontend");
-MODULE_AUTHOR("Jamie Honan");
-MODULE_LICENSE("GPL");
-
diff -Nru a/drivers/media/dvb/frontends/dvb_dummy_fe.c b/drivers/media/dvb/frontends/dvb_dummy_fe.c
--- a/drivers/media/dvb/frontends/dvb_dummy_fe.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/dvb/frontends/dvb_dummy_fe.c	2004-12-24 13:36:31 -08:00
@@ -20,186 +20,262 @@
  */    
 
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 
 #include "dvb_frontend.h"
+#include "dvb_dummy_fe.h"
 
-static int sct = 0;
 
 
-/* depending on module parameter sct deliver different infos
- */
+struct dvb_dummy_fe_state {
 
-static struct dvb_frontend_info dvb_s_dummyfe_info = {
-	.name 			= "DVB-S dummy frontend",
-	.type 			= FE_QPSK,
-	.frequency_min 		= 950000,
-	.frequency_max 		= 2150000,
-	.frequency_stepsize 	= 250,           /* kHz for QPSK frontends */
-	.frequency_tolerance 	= 29500,
-	.symbol_rate_min 	= 1000000,
-	.symbol_rate_max 	= 45000000,
-/*      .symbol_rate_tolerance 	= ???,*/
-	.notifier_delay		 = 50,                /* 1/20 s */
-	.caps = FE_CAN_INVERSION_AUTO | 
-	FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-	FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-	FE_CAN_QPSK
-};
-
-static struct dvb_frontend_info dvb_c_dummyfe_info = {
-	.name = "DVB-C dummy frontend",
-	.type = FE_QAM,
-	.frequency_stepsize = 62500,
-	.frequency_min = 51000000,
-	.frequency_max = 858000000,
-	.symbol_rate_min = (57840000/2)/64,     /* SACLK/64 == (XIN/2)/64 */
-	.symbol_rate_max = (57840000/2)/4,      /* SACLK/4 */
-#if 0
-	.frequency_tolerance	= ???,
-	.symbol_rate_tolerance	= ???,  /* ppm */  /* == 8% (spec p. 5) */
-	.notifier_delay		= ?,
-#endif
-	.caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
-		FE_CAN_QAM_128 | FE_CAN_QAM_256 | 
-		FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
-};
+	struct dvb_frontend_ops ops;
 
-static struct dvb_frontend_info dvb_t_dummyfe_info = {
-	.name = "DVB-T dummy frontend",
-	.type = FE_OFDM,
-	.frequency_min = 0,
-	.frequency_max = 863250000,
-	.frequency_stepsize = 62500,
-	/*.frequency_tolerance = */	/* FIXME: 12% of SR */
-	.symbol_rate_min = 0,		/* FIXME */
-	.symbol_rate_max = 9360000,	/* FIXME */
-	.symbol_rate_tolerance = 4000,
-	.notifier_delay = 0,
-	.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-			FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
-			FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
-			FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
-			FE_CAN_TRANSMISSION_MODE_AUTO |
-			FE_CAN_GUARD_INTERVAL_AUTO |
-			FE_CAN_HIERARCHY_AUTO,
+	struct dvb_frontend frontend;
 };
 
-struct dvb_frontend_info *frontend_info(void)
-{
-	switch(sct)
-	{
-	case 2:
-		return &dvb_t_dummyfe_info;
-	case 1:
-		return &dvb_c_dummyfe_info;
-	case 0:
-	default:
-	        return &dvb_s_dummyfe_info;
-	}
-}
-
-
-static int dvbdummyfe_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-        switch (cmd) {
-        case FE_GET_INFO:
-		memcpy (arg, frontend_info(), 
-			sizeof(struct dvb_frontend_info));
-		break;
-
-        case FE_READ_STATUS:
+static int dvb_dummy_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
 	{
-		fe_status_t *status = arg;
 		*status = FE_HAS_SIGNAL
 			| FE_HAS_CARRIER
 			| FE_HAS_VITERBI
 			| FE_HAS_SYNC
 			| FE_HAS_LOCK;
-		break;
+
+	return 0;
 	}
 
-        case FE_READ_BER:
+static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
 	{
-		u32 *ber = (u32 *) arg;
 		*ber = 0;
-		break;
+	return 0;
 	}
 
-        case FE_READ_SIGNAL_STRENGTH:
+static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 	{
-		u8 signal = 0xff;
-		*((u16*) arg) = (signal << 8) | signal;
-		break;
+	*strength = 0;
+	return 0;
 	}
 
-        case FE_READ_SNR:
+static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
 	{
-		u8 snr = 0xf0;
-		*(u16*) arg = (snr << 8) | snr;
-		break;
+	*snr = 0;
+	return 0;
 	}
 
-	case FE_READ_UNCORRECTED_BLOCKS: 
-		*(u32*) arg = 0;
-		break;
-
-        case FE_SET_FRONTEND:
-                break;
-
-	case FE_GET_FRONTEND:
-		break;
-
-        case FE_SLEEP:
+static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	*ucblocks = 0;
 		return 0;
+}
 
-        case FE_INIT:
+static int dvb_dummy_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
 		return 0;
+}
 
-	case FE_SET_TONE:
-		return -EOPNOTSUPP;
+static int dvb_dummy_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	return 0;
+}
 
-	case FE_SET_VOLTAGE:
+static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
+{
 		return 0;
+}
 
-	default:
-		return -EOPNOTSUPP;
+static int dvb_dummy_fe_init(struct dvb_frontend* fe)
+{
+	return 0;
         }
+
+static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+{
         return 0;
 } 
 
+static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
+{
+	return 0;
+}
 
-static int dvbdummyfe_attach (struct dvb_i2c_bus *i2c, void **data)
+static void dvb_dummy_fe_release(struct dvb_frontend* fe)
 {
-	return dvb_register_frontend (dvbdummyfe_ioctl, i2c, NULL, frontend_info());
+	struct dvb_dummy_fe_state* state = (struct dvb_dummy_fe_state*) fe->demodulator_priv;
+	kfree(state);
 }
 
+static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
 
-static void dvbdummyfe_detach (struct dvb_i2c_bus *i2c, void *data)
+struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
 {
-	dvb_unregister_frontend (dvbdummyfe_ioctl, i2c);
+	struct dvb_dummy_fe_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct dvb_dummy_fe_state*) kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	memcpy(&state->ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
 }
 
+static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
 
-static int __init init_dvbdummyfe (void)
+struct dvb_frontend* dvb_dummy_fe_qpsk_attach()
 {
-	return dvb_register_i2c_device (THIS_MODULE,
-					dvbdummyfe_attach, 
-					dvbdummyfe_detach);
+	struct dvb_dummy_fe_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct dvb_dummy_fe_state*) kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	memcpy(&state->ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
 }
 
+static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
 
-static void __exit exit_dvbdummyfe (void)
+struct dvb_frontend* dvb_dummy_fe_qam_attach()
 {
-	dvb_unregister_i2c_device (dvbdummyfe_attach);
+	struct dvb_dummy_fe_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct dvb_dummy_fe_state*) kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	memcpy(&state->ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
 }
 
+static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
+
+	.info = {
+		.name			= "Dummy DVB-T",
+		.type 			= FE_OFDM,
+		.frequency_min 		= 0,
+		.frequency_max 		= 863250000,
+		.frequency_stepsize	= 62500,
+		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+				FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
+				FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
+				FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+				FE_CAN_TRANSMISSION_MODE_AUTO |
+				FE_CAN_GUARD_INTERVAL_AUTO |
+				FE_CAN_HIERARCHY_AUTO,
+	},
+
+	.release = dvb_dummy_fe_release,
+
+	.init = dvb_dummy_fe_init,
+	.sleep = dvb_dummy_fe_sleep,
+
+	.set_frontend = dvb_dummy_fe_set_frontend,
+	.get_frontend = dvb_dummy_fe_get_frontend,
+
+	.read_status = dvb_dummy_fe_read_status,
+	.read_ber = dvb_dummy_fe_read_ber,
+	.read_signal_strength = dvb_dummy_fe_read_signal_strength,
+	.read_snr = dvb_dummy_fe_read_snr,
+	.read_ucblocks = dvb_dummy_fe_read_ucblocks,
+};
 
-module_init(init_dvbdummyfe);
-module_exit(exit_dvbdummyfe);
+static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
+
+	.info = {
+		.name			= "Dummy DVB-C",
+		.type 			= FE_QAM,
+		.frequency_stepsize	= 62500,
+		.frequency_min 		= 51000000,
+		.frequency_max 		= 858000000,
+		.symbol_rate_min 	= (57840000/2)/64,     /* SACLK/64 == (XIN/2)/64 */
+		.symbol_rate_max 	= (57840000/2)/4,      /* SACLK/4 */
+		.caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
+			FE_CAN_QAM_128 | FE_CAN_QAM_256 |
+			FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
+	},
+
+	.release = dvb_dummy_fe_release,
+
+	.init = dvb_dummy_fe_init,
+	.sleep = dvb_dummy_fe_sleep,
+
+	.set_frontend = dvb_dummy_fe_set_frontend,
+	.get_frontend = dvb_dummy_fe_get_frontend,
+
+	.read_status = dvb_dummy_fe_read_status,
+	.read_ber = dvb_dummy_fe_read_ber,
+	.read_signal_strength = dvb_dummy_fe_read_signal_strength,
+	.read_snr = dvb_dummy_fe_read_snr,
+	.read_ucblocks = dvb_dummy_fe_read_ucblocks,
+};
 
+static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
+
+	.info = {
+		.name 			= "Dummy DVB-S",
+		.type 			= FE_QPSK,
+		.frequency_min 		= 950000,
+		.frequency_max 		= 2150000,
+		.frequency_stepsize 	= 250,           /* kHz for QPSK frontends */
+		.frequency_tolerance 	= 29500,
+		.symbol_rate_min 	= 1000000,
+		.symbol_rate_max 	= 45000000,
+		.caps = FE_CAN_INVERSION_AUTO |
+			FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+			FE_CAN_QPSK
+	},
+
+	.release = dvb_dummy_fe_release,
+
+	.init = dvb_dummy_fe_init,
+	.sleep = dvb_dummy_fe_sleep,
+
+	.set_frontend = dvb_dummy_fe_set_frontend,
+	.get_frontend = dvb_dummy_fe_get_frontend,
+
+	.read_status = dvb_dummy_fe_read_status,
+	.read_ber = dvb_dummy_fe_read_ber,
+	.read_signal_strength = dvb_dummy_fe_read_signal_strength,
+	.read_snr = dvb_dummy_fe_read_snr,
+	.read_ucblocks = dvb_dummy_fe_read_ucblocks,
+
+	.set_voltage = dvb_dummy_fe_set_voltage,
+     	.set_tone = dvb_dummy_fe_set_tone,
+};
 
 MODULE_DESCRIPTION("DVB DUMMY Frontend");
 MODULE_AUTHOR("Emard");
 MODULE_LICENSE("GPL");
-MODULE_PARM(sct, "i");
+
+EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
+EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
+EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);
diff -Nru a/drivers/media/dvb/frontends/dvb_dummy_fe.h b/drivers/media/dvb/frontends/dvb_dummy_fe.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/dvb_dummy_fe.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,32 @@
+/*
+ *  Driver for Dummy Frontend
+ *
+ *  Written by Emard <emard@softhome.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 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.=
+ */
+
+#ifndef DVB_DUMMY_FE_H
+#define DVB_DUMMY_FE_H
+
+#include <linux/dvb/frontend.h>
+#include "dvb_frontend.h"
+
+extern struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void);
+extern struct dvb_frontend* dvb_dummy_fe_qpsk_attach(void);
+extern struct dvb_frontend* dvb_dummy_fe_qam_attach(void);
+
+#endif // DVB_DUMMY_FE_H
diff -Nru a/drivers/media/dvb/frontends/grundig_29504-401.c b/drivers/media/dvb/frontends/grundig_29504-401.c
--- a/drivers/media/dvb/frontends/grundig_29504-401.c	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,664 +0,0 @@
-/* 
-    driver for Grundig 29504-401 DVB-T Frontends based on
-    LSI L64781 COFDM demodulator as used in Technotrend DVB-T cards
-
-    Copyright (C) 2001 Holger Waechtler <holger@convergence.de>
-                       for Convergence Integrated Media GmbH
-                       Marko Kohtala <marko.kohtala@nokia.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 program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/    
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "dvb_functions.h"
-
-static int debug = 0;
-
-#define dprintk	if (debug) printk
-
-struct grundig_state {
-	int first:1;
-};
-
-struct dvb_frontend_info grundig_29504_401_info = {
-	.name = "Grundig 29504-401",
-	.type = FE_OFDM,
-/*	.frequency_min = ???,*/
-/*	.frequency_max = ???,*/
-	.frequency_stepsize = 166666,
-/*      .frequency_tolerance = ???,*/
-/*      .symbol_rate_tolerance = ???,*/
-	.notifier_delay = 0,
-	.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-	      FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
-	      FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
-              FE_CAN_MUTE_TS
-};
-
-
-static int l64781_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
-{
-	int ret;
-	u8 buf [] = { reg, data };
-	struct i2c_msg msg = { .addr = 0x55, .flags = 0, .buf = buf, .len = 2 };
-
-	if ((ret = i2c->xfer (i2c, &msg, 1)) != 1)
-		dprintk ("%s: write_reg error (reg == %02x) = %02x!\n",
-			 __FUNCTION__, reg, ret);
-
-	return (ret != 1) ? -1 : 0;
-}
-
-
-static u8 l64781_readreg (struct dvb_i2c_bus *i2c, u8 reg)
-{
-	int ret;
-	u8 b0 [] = { reg };
-	u8 b1 [] = { 0 };
-	struct i2c_msg msg [] = { { .addr = 0x55, .flags = 0, .buf = b0, .len = 1 },
-			   { .addr = 0x55, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
-	ret = i2c->xfer (i2c, msg, 2);
-
-	if (ret != 2)
-		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
-
-	return b1[0];
-}
-
-
-static int tsa5060_write (struct dvb_i2c_bus *i2c, u8 data [4])
-{
-	int ret;
-	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = 4 };
-
-	if ((ret = i2c->xfer (i2c, &msg, 1)) != 1)
-		dprintk ("%s: write_reg error == %02x!\n", __FUNCTION__, ret);
-
-	return (ret != 1) ? -1 : 0;
-}
-
-
-/**
- *   set up the downconverter frequency divisor for a
- *   reference clock comparision frequency of 166666 Hz.
- *   frequency offset is 36125000 Hz.
- */
-static int tsa5060_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
-{
-#if 1
-	u32 div;
-	u8 buf [4];
-	u8 cfg, cpump, band_select;
-
-	div = (36125000 + freq) / 166666;
-	cfg = 0x88;
-
-	cpump = freq < 175000000 ? 2 : freq < 390000000 ? 1 :
-		freq < 470000000 ? 2 : freq < 750000000 ? 1 : 3;
-
-	band_select = freq < 175000000 ? 0x0e : freq < 470000000 ? 0x05 : 0x03;
-
-	buf [0] = (div >> 8) & 0x7f;
-	buf [1] = div & 0xff;
-	buf [2] = ((div >> 10) & 0x60) | cfg;
-	buf [3] = (cpump << 6) | band_select;
-#else
-	/* old code which seems to work better for at least one person */
-        u32 div;
-        u8 buf [4];
-        u8 cfg;
-
-        div = (36000000 + freq) / 166666;
-        cfg = 0x88;
-
-        buf [0] = (div >> 8) & 0x7f;
-        buf [1] = div & 0xff;
-        buf [2] = ((div >> 10) & 0x60) | cfg;
-        buf [3] = 0xc0;
-#endif
-
-	return tsa5060_write (i2c, buf);
-}
-
-
-static void apply_tps (struct dvb_i2c_bus *i2c)
-{
-	l64781_writereg (i2c, 0x2a, 0x00);
-	l64781_writereg (i2c, 0x2a, 0x01);
-
-	/* This here is a little bit questionable because it enables
-	   the automatic update of TPS registers. I think we'd need to
-	   handle the IRQ from FE to update some other registers as
-	   well, or at least implement some magic to tuning to correct
-	   to the TPS received from transmission. */
-	l64781_writereg (i2c, 0x2a, 0x02);
-}
-
-
-static void reset_afc (struct dvb_i2c_bus *i2c)
-{
-	/* Set AFC stall for the AFC_INIT_FRQ setting, TIM_STALL for
-	   timing offset */
-	l64781_writereg (i2c, 0x07, 0x9e); /* stall AFC */
-	l64781_writereg (i2c, 0x08, 0);    /* AFC INIT FREQ */
-	l64781_writereg (i2c, 0x09, 0);
-	l64781_writereg (i2c, 0x0a, 0);
-	l64781_writereg (i2c, 0x07, 0x8e);
-	l64781_writereg (i2c, 0x0e, 0);    /* AGC gain to zero in beginning */
-	l64781_writereg (i2c, 0x11, 0x80); /* stall TIM */
-	l64781_writereg (i2c, 0x10, 0);    /* TIM_OFFSET_LSB */
-	l64781_writereg (i2c, 0x12, 0);
-	l64781_writereg (i2c, 0x13, 0);
-	l64781_writereg (i2c, 0x11, 0x00);
-}
-
-
-static int apply_frontend_param (struct dvb_i2c_bus *i2c,
-			  struct dvb_frontend_parameters *param)
-{
-	/* The coderates for FEC_NONE, FEC_4_5 and FEC_FEC_6_7 are arbitrary */
-	static const u8 fec_tab[] = { 7, 0, 1, 2, 9, 3, 10, 4 };
-	/* QPSK, QAM_16, QAM_64 */
-	static const u8 qam_tab [] = { 2, 4, 0, 6 };
-	static const u8 bw_tab [] = { 8, 7, 6 };  /* 8Mhz, 7MHz, 6MHz */
-	static const u8 guard_tab [] = { 1, 2, 4, 8 };
-	/* The Grundig 29504-401.04 Tuner comes with 18.432MHz crystal. */
-	static const u32 ppm = 8000;
-	struct dvb_ofdm_parameters *p = &param->u.ofdm;
-	u32 ddfs_offset_fixed;
-/*	u32 ddfs_offset_variable = 0x6000-((1000000UL+ppm)/ */
-/*			bw_tab[p->bandWidth]<<10)/15625; */
-	u32 init_freq;
-	u32 spi_bias;
-	u8 val0x04;
-	u8 val0x05;
-	u8 val0x06;
-	int bw = p->bandwidth - BANDWIDTH_8_MHZ;
-
-	if (param->inversion != INVERSION_ON &&
-	    param->inversion != INVERSION_OFF)
-		return -EINVAL;
-
-	if (bw < 0 || bw > 2)
-		return -EINVAL;
-	
-	if (p->code_rate_HP != FEC_1_2 && p->code_rate_HP != FEC_2_3 &&
-	    p->code_rate_HP != FEC_3_4 && p->code_rate_HP != FEC_5_6 &&
-	    p->code_rate_HP != FEC_7_8)
-		return -EINVAL;
-
-	if (p->hierarchy_information != HIERARCHY_NONE &&
-	    (p->code_rate_LP != FEC_1_2 && p->code_rate_LP != FEC_2_3 &&
-	     p->code_rate_LP != FEC_3_4 && p->code_rate_LP != FEC_5_6 &&
-	     p->code_rate_LP != FEC_7_8))
-		return -EINVAL;
-
-	if (p->constellation != QPSK && p->constellation != QAM_16 &&
-	    p->constellation != QAM_64)
-		return -EINVAL;
-
-	if (p->transmission_mode != TRANSMISSION_MODE_2K &&
-	    p->transmission_mode != TRANSMISSION_MODE_8K)
-		return -EINVAL;
-
-	if (p->guard_interval < GUARD_INTERVAL_1_32 ||
-	    p->guard_interval > GUARD_INTERVAL_1_4)
-		return -EINVAL;
-
-	if (p->hierarchy_information < HIERARCHY_NONE ||
-	    p->hierarchy_information > HIERARCHY_4)
-		return -EINVAL;
-
-	ddfs_offset_fixed = 0x4000-(ppm<<16)/bw_tab[p->bandwidth]/1000000;
-
-	/* This works up to 20000 ppm, it overflows if too large ppm! */
-	init_freq = (((8UL<<25) + (8UL<<19) / 25*ppm / (15625/25)) /
-			bw_tab[p->bandwidth] & 0xFFFFFF);
-
-	/* SPI bias calculation is slightly modified to fit in 32bit */
-	/* will work for high ppm only... */
-	spi_bias = 378 * (1 << 10);
-	spi_bias *= 16;
-	spi_bias *= bw_tab[p->bandwidth];
-	spi_bias *= qam_tab[p->constellation];
-	spi_bias /= p->code_rate_HP + 1;
-	spi_bias /= (guard_tab[p->guard_interval] + 32);
-	spi_bias *= 1000ULL;
-	spi_bias /= 1000ULL + ppm/1000;
-	spi_bias *= p->code_rate_HP;
-
-	val0x04 = (p->transmission_mode << 2) | p->guard_interval;
-	val0x05 = fec_tab[p->code_rate_HP];
-
-	if (p->hierarchy_information != HIERARCHY_NONE)
-		val0x05 |= (p->code_rate_LP - FEC_1_2) << 3;
-
-	val0x06 = (p->hierarchy_information << 2) | p->constellation;
-
-	l64781_writereg (i2c, 0x04, val0x04);
-	l64781_writereg (i2c, 0x05, val0x05);
-	l64781_writereg (i2c, 0x06, val0x06);
-
-	reset_afc (i2c);
-
-	/* Technical manual section 2.6.1, TIM_IIR_GAIN optimal values */
-	l64781_writereg (i2c, 0x15,
-			 p->transmission_mode == TRANSMISSION_MODE_2K ? 1 : 3);
-	l64781_writereg (i2c, 0x16, init_freq & 0xff);
-	l64781_writereg (i2c, 0x17, (init_freq >> 8) & 0xff);
-	l64781_writereg (i2c, 0x18, (init_freq >> 16) & 0xff);
-
-	l64781_writereg (i2c, 0x1b, spi_bias & 0xff);
-	l64781_writereg (i2c, 0x1c, (spi_bias >> 8) & 0xff);
-	l64781_writereg (i2c, 0x1d, ((spi_bias >> 16) & 0x7f) |
-		(param->inversion == INVERSION_ON ? 0x80 : 0x00));
-
-	l64781_writereg (i2c, 0x22, ddfs_offset_fixed & 0xff);
-	l64781_writereg (i2c, 0x23, (ddfs_offset_fixed >> 8) & 0x3f);
-
-	l64781_readreg (i2c, 0x00);  /*  clear interrupt registers... */
-	l64781_readreg (i2c, 0x01);  /*  dto. */
-
-	apply_tps (i2c);
-
-	return 0;
-}
-
-
-static int reset_and_configure (struct dvb_i2c_bus *i2c)
-{
-	u8 buf [] = { 0x06 };
-	struct i2c_msg msg = { .addr = 0x00, .flags = 0, .buf = buf, .len = 1 };
-
-	return (i2c->xfer (i2c, &msg, 1) == 1) ? 0 : -ENODEV;
-}
-
-
-static int get_frontend(struct dvb_i2c_bus* i2c, struct dvb_frontend_parameters* param)
-{
-	int tmp;
-
-
-	tmp = l64781_readreg(i2c, 0x04);
-	switch(tmp & 3) {
-	case 0: 
-		param->u.ofdm.guard_interval = GUARD_INTERVAL_1_32; 
-		break;
-	case 1:
-		param->u.ofdm.guard_interval = GUARD_INTERVAL_1_16;
-		break;
-	case 2:
-		param->u.ofdm.guard_interval = GUARD_INTERVAL_1_8; 
-		break;
-	case 3:
-		param->u.ofdm.guard_interval = GUARD_INTERVAL_1_4; 
-		break;
-	}
-	switch((tmp >> 2) & 3) {
-	case 0: 
-		param->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
-		break;
-	case 1:
-		param->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
-		break;
-	default:
-		printk("Unexpected value for transmission_mode\n");
-	}
-	
-	
-	
-	tmp = l64781_readreg(i2c, 0x05);
-	switch(tmp & 7) {
-	case 0: 
-		param->u.ofdm.code_rate_HP = FEC_1_2;
-		break;
-	case 1:
-		param->u.ofdm.code_rate_HP = FEC_2_3;
-		break;
-	case 2:
-		param->u.ofdm.code_rate_HP = FEC_3_4;
-		break;
-	case 3:
-		param->u.ofdm.code_rate_HP = FEC_5_6;
-		break;
-	case 4:
-		param->u.ofdm.code_rate_HP = FEC_7_8;
-		break;
-	default:
-		printk("Unexpected value for code_rate_HP\n");
-	}
-	switch((tmp >> 3) & 7) {
-	case 0: 
-		param->u.ofdm.code_rate_LP = FEC_1_2;
-		break;
-	case 1:
-		param->u.ofdm.code_rate_LP = FEC_2_3;
-		break;
-	case 2:
-		param->u.ofdm.code_rate_LP = FEC_3_4;
-		break;
-	case 3:
-		param->u.ofdm.code_rate_LP = FEC_5_6;
-		break;
-	case 4:
-		param->u.ofdm.code_rate_LP = FEC_7_8;
-		break;
-	default:
-		printk("Unexpected value for code_rate_LP\n");
-	}
-	
-	
-	tmp = l64781_readreg(i2c, 0x06);
-	switch(tmp & 3) {
-	case 0: 
-		param->u.ofdm.constellation = QPSK;
-		break;
-	case 1:
-		param->u.ofdm.constellation = QAM_16;
-		break;
-	case 2:
-		param->u.ofdm.constellation = QAM_64;
-		break;
-	default:
-		printk("Unexpected value for constellation\n");
-	}
-	switch((tmp >> 2) & 7) {
-	case 0: 
-		param->u.ofdm.hierarchy_information = HIERARCHY_NONE;
-		break;
-	case 1:
-		param->u.ofdm.hierarchy_information = HIERARCHY_1;
-		break;
-	case 2:
-		param->u.ofdm.hierarchy_information = HIERARCHY_2;
-		break;
-	case 3:
-		param->u.ofdm.hierarchy_information = HIERARCHY_4;
-		break;
-	default:
-		printk("Unexpected value for hierarchy\n");
-	}
-
-
-	tmp = l64781_readreg (i2c, 0x1d);
-	param->inversion = (tmp & 0x80) ? INVERSION_ON : INVERSION_OFF;
-
-	tmp = (int) (l64781_readreg (i2c, 0x08) | 
-		     (l64781_readreg (i2c, 0x09) << 8) |
-		     (l64781_readreg (i2c, 0x0a) << 16));
-	param->frequency += tmp;
-
-	return 0;
-}
-
-
-static int init (struct dvb_i2c_bus *i2c)
-{
-        reset_and_configure (i2c);
-
-	/* Power up */
-	l64781_writereg (i2c, 0x3e, 0xa5);
-
-	/* Reset hard */
-	l64781_writereg (i2c, 0x2a, 0x04);
-	l64781_writereg (i2c, 0x2a, 0x00);
-
-	/* Set tuner specific things */
-	/* AFC_POL, set also in reset_afc */
-	l64781_writereg (i2c, 0x07, 0x8e);
-
-	/* Use internal ADC */
-	l64781_writereg (i2c, 0x0b, 0x81);
-
-	/* AGC loop gain, and polarity is positive */
-	l64781_writereg (i2c, 0x0c, 0x84);
-
-	/* Internal ADC outputs two's complement */
-	l64781_writereg (i2c, 0x0d, 0x8c);
-
-	/* With ppm=8000, it seems the DTR_SENSITIVITY will result in
-           value of 2 with all possible bandwidths and guard
-           intervals, which is the initial value anyway. */
-        /*l64781_writereg (i2c, 0x19, 0x92);*/
-
-	/* Everything is two's complement, soft bit and CSI_OUT too */
-	l64781_writereg (i2c, 0x1e, 0x09);
-
-	return 0;
-}
-
-
-static 
-int grundig_29504_401_ioctl (struct dvb_frontend *fe,
-			     unsigned int cmd, void *arg)
-{
-	struct dvb_i2c_bus *i2c = fe->i2c;
-	int res;
-	struct grundig_state* state = (struct grundig_state*) fe->data;
-
-        switch (cmd) {
-        case FE_GET_INFO:
-		memcpy (arg, &grundig_29504_401_info,
-			sizeof(struct dvb_frontend_info));
-                break;
-
-	case FE_READ_STATUS:
-	{
-		fe_status_t *status = (fe_status_t *) arg;
-		int sync = l64781_readreg (i2c, 0x32);
-		int gain = l64781_readreg (i2c, 0x0e);
-
-		l64781_readreg (i2c, 0x00);  /*  clear interrupt registers... */
-		l64781_readreg (i2c, 0x01);  /*  dto. */
-
-		*status = 0;
-
-		if (gain > 5)
-			*status |= FE_HAS_SIGNAL;
-
-		if (sync & 0x02) /* VCXO locked, this criteria should be ok */
-			*status |= FE_HAS_CARRIER;
-
-		if (sync & 0x20)
-			*status |= FE_HAS_VITERBI;
-
-		if (sync & 0x40)
-			*status |= FE_HAS_SYNC;
-
-		if (sync == 0x7f)
-			*status |= FE_HAS_LOCK;
-
-		break;
-	}
-
-        case FE_READ_BER:
-	{
-		/*   XXX FIXME: set up counting period (reg 0x26...0x28)
-		 */
-		u32 *ber = (u32 *) arg;
-		*ber = l64781_readreg (i2c, 0x39)
-		    | (l64781_readreg (i2c, 0x3a) << 8);
-		break;
-	}
-
-        case FE_READ_SIGNAL_STRENGTH:
-	{
-		u8 gain = l64781_readreg (i2c, 0x0e);
-		*(u16 *) arg = (gain << 8) | gain;
-		break;
-	}
-
-        case FE_READ_SNR:
-	{
-		u16 *snr = (u16 *) arg;
-		u8 avg_quality = 0xff - l64781_readreg (i2c, 0x33);
-		*snr = (avg_quality << 8) | avg_quality; /* not exact, but...*/ 
-		break;
-	}
-
-	case FE_READ_UNCORRECTED_BLOCKS: 
-	{
-		u32 *ub = (u32 *) arg;
-		*ub = l64781_readreg (i2c, 0x37)
-		   | (l64781_readreg (i2c, 0x38) << 8);
-		break;
-	}
-
-        case FE_SET_FRONTEND:
-	{
-		struct dvb_frontend_parameters *p = arg;
-
-		tsa5060_set_tv_freq (i2c, p->frequency);
-		return apply_frontend_param (i2c, p);
-	}
-
-        case FE_GET_FRONTEND:
-	{
-		struct dvb_frontend_parameters *p = arg;
-		return get_frontend(i2c, p);
-	}
-
-	case FE_SLEEP:
-		/* Power down */
-		return l64781_writereg (i2c, 0x3e, 0x5a);
-
-	case FE_INIT:
-		res = init (i2c);
-		if ((res == 0) && (state->first)) {
-			state->first = 0;
-			dvb_delay(200);
-		}
-		return res;
-
-	case FE_GET_TUNE_SETTINGS:
-	{
-	        struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
-	        fesettings->min_delay_ms = 200;
-	        fesettings->step_size = 166667;
-	        fesettings->max_drift = 166667*2;
-	        return 0;
-	}
-
-        default:
-		dprintk ("%s: unknown command !!!\n", __FUNCTION__);
-		return -EINVAL;
-        };
-        
-        return 0;
-} 
-
-
-static int l64781_attach (struct dvb_i2c_bus *i2c, void **data)
-{
-	u8 reg0x3e;
-	u8 b0 [] = { 0x1a };
-	u8 b1 [] = { 0x00 };
-	struct i2c_msg msg [] = { { .addr = 0x55, .flags = 0, .buf = b0, .len = 1 },
-			   { .addr = 0x55, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-	struct grundig_state* state;
-
-	/**
-	 *  the L64781 won't show up before we send the reset_and_configure()
-	 *  broadcast. If nothing responds there is no L64781 on the bus...
-	 */
-	if (reset_and_configure(i2c) < 0) {
-		dprintk("no response on reset_and_configure() broadcast, bailing out...\n");
-		return -ENODEV;
-	}
-
-	/* The chip always responds to reads */
-	if (i2c->xfer(i2c, msg, 2) != 2) {  
-	        dprintk("no response to read on I2C bus\n");
-		return -ENODEV;
-	}
-
-	/* Save current register contents for bailout */
-	reg0x3e = l64781_readreg(i2c, 0x3e);
-
-	/* Reading the POWER_DOWN register always returns 0 */
-	if (reg0x3e != 0) {
-	        dprintk("Device doesn't look like L64781\n");
-		return -ENODEV;
-	}
-
-	/* Turn the chip off */
-	l64781_writereg (i2c, 0x3e, 0x5a);
-
-	/* Responds to all reads with 0 */
-	if (l64781_readreg(i2c, 0x1a) != 0) {
- 	        dprintk("Read 1 returned unexpcted value\n");
-	        goto bailout;
-	}	  
-
-	/* Turn the chip on */
-	l64781_writereg (i2c, 0x3e, 0xa5);
-	
-	/* Responds with register default value */
-	if (l64781_readreg(i2c, 0x1a) != 0xa1) { 
- 	        dprintk("Read 2 returned unexpcted value\n");
-	        goto bailout;
-	}
-
-	state = kmalloc(sizeof(struct grundig_state), GFP_KERNEL);
-	if (state == NULL) goto bailout;
-	*data = state;
-	state->first = 1;
-
-	return dvb_register_frontend (grundig_29504_401_ioctl, i2c, state,
-			       &grundig_29504_401_info);
-
- bailout:
-	l64781_writereg (i2c, 0x3e, reg0x3e);  /* restore reg 0x3e */
-	return -ENODEV;
-}
-
-
-
-static void l64781_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	kfree(data);
-	dvb_unregister_frontend (grundig_29504_401_ioctl, i2c);
-}
-
-
-static int __init init_grundig_29504_401 (void)
-{
-	return dvb_register_i2c_device (THIS_MODULE,
-					l64781_attach, l64781_detach);
-}
-
-
-static void __exit exit_grundig_29504_401 (void)
-{
-	dvb_unregister_i2c_device (l64781_attach);
-}
-
-module_init(init_grundig_29504_401);
-module_exit(exit_grundig_29504_401);
-
-MODULE_PARM(debug,"i");
-MODULE_PARM_DESC(debug, "enable verbose debug messages");
-MODULE_DESCRIPTION("Grundig 29504-401 DVB-T Frontend");
-MODULE_AUTHOR("Holger Waechtler, Marko Kohtala");
-MODULE_LICENSE("GPL");
-
diff -Nru a/drivers/media/dvb/frontends/grundig_29504-491.c b/drivers/media/dvb/frontends/grundig_29504-491.c
--- a/drivers/media/dvb/frontends/grundig_29504-491.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,465 +0,0 @@
-/* 
-    Driver for Grundig 29504-491, a Philips TDA8083 based QPSK Frontend
-
-    Copyright (C) 2001 Convergence Integrated Media GmbH
-
-    written by Ralph Metzler <ralph@convergence.de>
-
-    adoption to the new DVB frontend API and diagnostic ioctl's
-    by Holger Waechtler <holger@convergence.de>
-
-    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.
-
-*/    
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "dvb_functions.h"
-
-static int debug = 0;
-#define dprintk	if (debug) printk
-
-
-static struct dvb_frontend_info grundig_29504_491_info = {
-	.name			= "Grundig 29504-491, (TDA8083 based)",
-	.type			= FE_QPSK,
-	.frequency_min		= 950000,     /* FIXME: guessed! */
-	.frequency_max		= 1400000,    /* FIXME: guessed! */
-	.frequency_stepsize	= 125,   /* kHz for QPSK frontends */
-/*      .frequency_tolerance	= ???,*/
-	.symbol_rate_min	= 1000000,   /* FIXME: guessed! */
-	.symbol_rate_max	= 45000000,  /* FIXME: guessed! */
-/*      .symbol_rate_tolerance	= ???,*/
-	.notifier_delay		= 0,
-	.caps = FE_CAN_INVERSION_AUTO |
-		FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-		FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
-		FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
-		FE_CAN_QPSK | FE_CAN_MUTE_TS
-};
-
-
-
-static u8 tda8083_init_tab [] = {
-	0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea,
-	0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10,
-	0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8,
-	0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00,
-	0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00
-};
-
-
-
-static int tda8083_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
-{
-	int ret;
-	u8 buf [] = { reg, data };
-	struct i2c_msg msg = { .addr = 0x68, .flags = 0, .buf = buf, .len = 2 };
-
-        ret = i2c->xfer (i2c, &msg, 1);
-
-        if (ret != 1)
-                dprintk ("%s: writereg error (reg %02x, ret == %i)\n",
-			__FUNCTION__, reg, ret);
-
-        return (ret != 1) ? -1 : 0;
-}
-
-
-static int tda8083_readregs (struct dvb_i2c_bus *i2c, u8 reg1, u8 *b, u8 len)
-{
-	int ret;
-	struct i2c_msg msg [] = { { .addr = 0x68, .flags = 0, .buf = &reg1, .len = 1 },
-			   { .addr = 0x68, .flags = I2C_M_RD, .buf = b, .len = len } };
-
-	ret = i2c->xfer (i2c, msg, 2);
-
-	if (ret != 2)
-		dprintk ("%s: readreg error (reg %02x, ret == %i)\n",
-			__FUNCTION__, reg1, ret);
-
-        return ret == 2 ? 0 : -1;
-}
-
-
-static inline u8 tda8083_readreg (struct dvb_i2c_bus *i2c, u8 reg)
-{
-	u8 val;
-
-	tda8083_readregs (i2c, reg, &val, 1);
-
-	return val;
-}
-
-
-static int tsa5522_write (struct dvb_i2c_bus *i2c, u8 data [4])
-{
-	int ret;
-	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = 4 };
-
-	ret = i2c->xfer (i2c, &msg, 1);
-
-	if (ret != 1)
-		dprintk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
-
-	return (ret != 1) ? -1 : 0;
-}
-
-
-/**
- *   set up the downconverter frequency divisor for a
- *   reference clock comparision frequency of 125 kHz.
- */
-static int tsa5522_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
-{
-	u32 div = freq / 125;
-	u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x8e, 0x00 };
-
-	return tsa5522_write (i2c, buf);
-}
-
-
-static int tda8083_init (struct dvb_i2c_bus *i2c)
-{
-	int i;
-	
-	dprintk("%s: init TDA8083\n", __FILE__);
-
-	for (i=0; i<44; i++)
-		tda8083_writereg (i2c, i, tda8083_init_tab[i]);
-
-	return 0;
-}
-
-
-static int tda8083_set_inversion (struct dvb_i2c_bus *i2c, fe_spectral_inversion_t inversion)
-{
-	/*  XXX FIXME: implement other modes than FEC_AUTO */
-	if (inversion == INVERSION_AUTO)
-		return 0;
-	
-	return -EINVAL;
-}
-
-
-static int tda8083_set_fec (struct dvb_i2c_bus *i2c, fe_code_rate_t fec)
-{
-	if (fec == FEC_AUTO)
-		return tda8083_writereg (i2c, 0x07, 0xff);
-
-	if (fec >= FEC_1_2 && fec <= FEC_8_9)
-		return tda8083_writereg (i2c, 0x07, 1 << (FEC_8_9 - fec));
-
-	return -EINVAL;
-}
-
-
-static fe_code_rate_t tda8083_get_fec (struct dvb_i2c_bus *i2c)
-{
-	u8 index;
-	static fe_code_rate_t fec_tab [] = { FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
-				       FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8 };
-
-	index = tda8083_readreg(i2c, 0x0e) & 0x07;
-
-	return fec_tab [index];
-}
-
-
-static int tda8083_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
-{
-        u32 ratio;
-	u32 tmp;
-	u8 filter;
-
-	if (srate > 32000000)
-                srate = 32000000;
-        if (srate < 500000)
-                srate = 500000;
-
-	filter = 0;
-	if (srate < 24000000)
-		filter = 2;
-	if (srate < 16000000)
-		filter = 3;
-
-	tmp = 31250 << 16;
-	ratio = tmp / srate;
-        
-	tmp = (tmp % srate) << 8;
-	ratio = (ratio << 8) + tmp / srate;
-        
-	tmp = (tmp % srate) << 8;
-	ratio = (ratio << 8) + tmp / srate;
-	
-	dprintk("tda8083: ratio == %08x\n", (unsigned int) ratio);
-
-	tda8083_writereg (i2c, 0x05, filter);
-	tda8083_writereg (i2c, 0x02, (ratio >> 16) & 0xff);
-	tda8083_writereg (i2c, 0x03, (ratio >>  8) & 0xff);
-	tda8083_writereg (i2c, 0x04, (ratio      ) & 0xff);
-	
-	tda8083_writereg (i2c, 0x00, 0x3c);
-	tda8083_writereg (i2c, 0x00, 0x04);
-
-	return 1;
-}
-
-
-static void tda8083_wait_diseqc_fifo (struct dvb_i2c_bus *i2c, int timeout)
-{
-	unsigned long start = jiffies;
-
-	while (jiffies - start < timeout &&
-               !(tda8083_readreg(i2c, 0x02) & 0x80))
-	{
-		dvb_delay(50);
-	};
-}
-
-
-static int tda8083_send_diseqc_msg (struct dvb_i2c_bus *i2c,
-			     struct dvb_diseqc_master_cmd *m)
-{
-	int i;
-
-	tda8083_writereg (i2c, 0x29, (m->msg_len - 3) | (1 << 2)); /* enable */
-
-	for (i=0; i<m->msg_len; i++)
-		tda8083_writereg (i2c, 0x23 + i, m->msg[i]);
-
-	tda8083_writereg (i2c, 0x29, (m->msg_len - 3) | (3 << 2)); /* send!! */
-
-	tda8083_wait_diseqc_fifo (i2c, 100);
-
-	return 0;
-}
-
-
-static int tda8083_send_diseqc_burst (struct dvb_i2c_bus *i2c, fe_sec_mini_cmd_t burst)
-{
-	switch (burst) {
-	case SEC_MINI_A:
-		tda8083_writereg (i2c, 0x29, (5 << 2));  /* send burst A */
-		break;
-	case SEC_MINI_B:
-		tda8083_writereg (i2c, 0x29, (7 << 2));  /* send B */
-		break;
-	default:
-		return -EINVAL;
-	};
-	
-	tda8083_wait_diseqc_fifo (i2c, 100); 
-
-	return 0;
-}
-
-
-static int tda8083_set_tone (struct dvb_i2c_bus *i2c, fe_sec_tone_mode_t tone)
-{
-	tda8083_writereg (i2c, 0x26, 0xf1);
-
-	switch (tone) {
-	case SEC_TONE_OFF:
-		return tda8083_writereg (i2c, 0x29, 0x00);
-	case SEC_TONE_ON:
-		return tda8083_writereg (i2c, 0x29, 0x80);
-	default:
-		return -EINVAL;
-	};
-}
-
-
-static int tda8083_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage)
-{
-	switch (voltage) {
-	case SEC_VOLTAGE_13:
-		return tda8083_writereg (i2c, 0x20, 0x00);
-	case SEC_VOLTAGE_18:
-		return tda8083_writereg (i2c, 0x20, 0x11);
-	default:
-		return -EINVAL;
-	};
-}
-
-
-static int grundig_29504_491_ioctl (struct dvb_frontend *fe, unsigned int cmd,
-			     void *arg)
-{
-	struct dvb_i2c_bus *i2c = fe->i2c;
-
-        switch (cmd) {
-	case FE_GET_INFO:
-		memcpy (arg, &grundig_29504_491_info, 
-			sizeof(struct dvb_frontend_info));
-                break;
-
-        case FE_READ_STATUS:
-	{
-		fe_status_t *status=(fe_status_t *) arg;
-		u8 signal = ~tda8083_readreg (i2c, 0x01);
-		u8 sync = tda8083_readreg (i2c, 0x02);
-
-		*status = 0;
-
-		if (signal > 10)
-			*status |= FE_HAS_SIGNAL;
-
-		if (sync & 0x01)
-			*status |= FE_HAS_CARRIER;
-
-		if (sync & 0x02)
-			*status |= FE_HAS_VITERBI;
-
-		if (sync & 0x10)
-			*status |= FE_HAS_SYNC;
-
-		if ((sync & 0x1f) == 0x1f)
-			*status |= FE_HAS_LOCK;
-
-		break;
-	}
-
-        case FE_READ_BER:
-                *((u32*) arg) = 0; /*   XXX FIXME: implement me!!! */
-                return -EOPNOTSUPP;
-
-        case FE_READ_SIGNAL_STRENGTH:
-	{
-		u8 signal = ~tda8083_readreg (i2c, 0x01);
-                *((u16*) arg) = (signal << 8) | signal;
-                break;
-	}
-        case FE_READ_SNR:
-	{
-		u8 snr = tda8083_readreg (i2c, 0x08);
-                *((u16*) arg) = (snr << 8) | snr;
-                break;
-	}
-        case FE_READ_UNCORRECTED_BLOCKS:
-                *((u32*) arg) = 0; /*   XXX FIXME: implement me!!! */
-                return -EOPNOTSUPP;
-
-
-        case FE_SET_FRONTEND:
-        {
-		struct dvb_frontend_parameters *p = arg;
-
-		tsa5522_set_tv_freq (i2c, p->frequency);
-		tda8083_set_inversion (i2c, p->inversion);
-		tda8083_set_fec (i2c, p->u.qpsk.fec_inner);
-		tda8083_set_symbolrate (i2c, p->u.qpsk.symbol_rate);
-
-		tda8083_writereg (i2c, 0x00, 0x3c);
-		tda8083_writereg (i2c, 0x00, 0x04);
-
-		break;
-        }
-
-	case FE_GET_FRONTEND:
-        {
-		struct dvb_frontend_parameters *p = arg;
-
-		/*  FIXME: get symbolrate & frequency offset...*/
-		/*p->frequency = ???;*/
-		p->inversion = (tda8083_readreg (i2c, 0x0e) & 0x80) ?
-				INVERSION_ON : INVERSION_OFF;
-		p->u.qpsk.fec_inner = tda8083_get_fec (i2c);
-		/*p->u.qpsk.symbol_rate = tda8083_get_symbolrate (i2c);*/
-		break;
-        }
-
-	case FE_SLEEP:
-		tda8083_writereg (i2c, 0x00, 0x02);
-		break;
-
-	case FE_INIT:
-		tda8083_init (i2c);
-		tda8083_writereg (i2c, 0x00, 0x3c);
-		tda8083_writereg (i2c, 0x00, 0x04);
-		break;
-
-	case FE_DISEQC_SEND_MASTER_CMD:
-		return tda8083_send_diseqc_msg (i2c, arg);
-
-	case FE_DISEQC_SEND_BURST:
-		tda8083_send_diseqc_burst (i2c, (fe_sec_mini_cmd_t) arg);
-		tda8083_writereg (i2c, 0x00, 0x3c);
-		tda8083_writereg (i2c, 0x00, 0x04);
-
-		break;
-
-	case FE_SET_TONE:
-		tda8083_set_tone (i2c, (fe_sec_tone_mode_t) arg);
-		tda8083_writereg (i2c, 0x00, 0x3c);
-		tda8083_writereg (i2c, 0x00, 0x04);
-		break;
-
-	case FE_SET_VOLTAGE:
-		tda8083_set_voltage (i2c, (fe_sec_voltage_t) arg);
-		tda8083_writereg (i2c, 0x00, 0x3c);
-		tda8083_writereg (i2c, 0x00, 0x04);
-		break;
-
-	default:
-		return -EOPNOTSUPP;
-	};
-
-	return 0;
-} 
-
-
-static int tda8083_attach (struct dvb_i2c_bus *i2c, void **data)
-{
-	if ((tda8083_readreg (i2c, 0x00)) != 0x05)
-		return -ENODEV;
-
-	return dvb_register_frontend (grundig_29504_491_ioctl, i2c, NULL,
-			       &grundig_29504_491_info);
-}
-
-
-static void tda8083_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	dvb_unregister_frontend (grundig_29504_491_ioctl, i2c);
-}
-
-
-static int __init init_tda8083 (void)
-{
-	return dvb_register_i2c_device (THIS_MODULE,
-					tda8083_attach, tda8083_detach);
-}
-
-
-static void __exit exit_tda8083 (void)
-{
-	dvb_unregister_i2c_device (tda8083_attach);
-}
-
-module_init(init_tda8083);
-module_exit(exit_tda8083);
-
-MODULE_PARM(debug,"i");
-MODULE_DESCRIPTION("Grundig 29504-491 DVB frontend driver");
-MODULE_AUTHOR("Ralph Metzler, Holger Waechtler");
-MODULE_LICENSE("GPL");
-
diff -Nru a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/l64781.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,607 @@
+/*
+    driver for LSI L64781 COFDM demodulator
+
+    Copyright (C) 2001 Holger Waechtler <holger@convergence.de>
+                       for Convergence Integrated Media GmbH
+                       Marko Kohtala <marko.kohtala@nokia.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 program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include "dvb_frontend.h"
+#include "l64781.h"
+
+
+struct l64781_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	const struct l64781_config* config;
+
+	struct dvb_frontend frontend;
+
+	/* private demodulator data */
+   	int first:1;
+};
+
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "l64781: " args); \
+	} while (0)
+
+static int debug;
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
+
+
+static int l64781_writereg (struct l64781_state* state, u8 reg, u8 data)
+{
+	int ret;
+	u8 buf [] = { reg, data };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
+
+	if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1)
+		dprintk ("%s: write_reg error (reg == %02x) = %02x!\n",
+			 __FUNCTION__, reg, ret);
+
+	return (ret != 1) ? -1 : 0;
+}
+
+static int l64781_readreg (struct l64781_state* state, u8 reg)
+{
+	int ret;
+	u8 b0 [] = { reg };
+	u8 b1 [] = { 0 };
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
+			   { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
+
+	ret = i2c_transfer(state->i2c, msg, 2);
+
+	if (ret != 2) return ret;
+
+	return b1[0];
+}
+
+static void apply_tps (struct l64781_state* state)
+{
+	l64781_writereg (state, 0x2a, 0x00);
+	l64781_writereg (state, 0x2a, 0x01);
+
+	/* This here is a little bit questionable because it enables
+	   the automatic update of TPS registers. I think we'd need to
+	   handle the IRQ from FE to update some other registers as
+	   well, or at least implement some magic to tuning to correct
+	   to the TPS received from transmission. */
+	l64781_writereg (state, 0x2a, 0x02);
+}
+
+
+static void reset_afc (struct l64781_state* state)
+{
+	/* Set AFC stall for the AFC_INIT_FRQ setting, TIM_STALL for
+	   timing offset */
+	l64781_writereg (state, 0x07, 0x9e); /* stall AFC */
+	l64781_writereg (state, 0x08, 0);    /* AFC INIT FREQ */
+	l64781_writereg (state, 0x09, 0);
+	l64781_writereg (state, 0x0a, 0);
+	l64781_writereg (state, 0x07, 0x8e);
+	l64781_writereg (state, 0x0e, 0);    /* AGC gain to zero in beginning */
+	l64781_writereg (state, 0x11, 0x80); /* stall TIM */
+	l64781_writereg (state, 0x10, 0);    /* TIM_OFFSET_LSB */
+	l64781_writereg (state, 0x12, 0);
+	l64781_writereg (state, 0x13, 0);
+	l64781_writereg (state, 0x11, 0x00);
+}
+
+static int reset_and_configure (struct l64781_state* state)
+{
+	u8 buf [] = { 0x06 };
+	struct i2c_msg msg = { .addr = 0x00, .flags = 0, .buf = buf, .len = 1 };
+	// NOTE: this is correct in writing to address 0x00
+
+	return (i2c_transfer(state->i2c, &msg, 1) == 1) ? 0 : -ENODEV;
+}
+
+static int apply_frontend_param (struct dvb_frontend* fe, struct dvb_frontend_parameters *param)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+	/* The coderates for FEC_NONE, FEC_4_5 and FEC_FEC_6_7 are arbitrary */
+	static const u8 fec_tab[] = { 7, 0, 1, 2, 9, 3, 10, 4 };
+	/* QPSK, QAM_16, QAM_64 */
+	static const u8 qam_tab [] = { 2, 4, 0, 6 };
+	static const u8 bw_tab [] = { 8, 7, 6 };  /* 8Mhz, 7MHz, 6MHz */
+	static const u8 guard_tab [] = { 1, 2, 4, 8 };
+	/* The Grundig 29504-401.04 Tuner comes with 18.432MHz crystal. */
+	static const u32 ppm = 8000;
+	struct dvb_ofdm_parameters *p = &param->u.ofdm;
+	u32 ddfs_offset_fixed;
+/*	u32 ddfs_offset_variable = 0x6000-((1000000UL+ppm)/ */
+/*			bw_tab[p->bandWidth]<<10)/15625; */
+	u32 init_freq;
+	u32 spi_bias;
+	u8 val0x04;
+	u8 val0x05;
+	u8 val0x06;
+	int bw = p->bandwidth - BANDWIDTH_8_MHZ;
+
+	state->config->pll_set(fe, param);
+
+	if (param->inversion != INVERSION_ON &&
+	    param->inversion != INVERSION_OFF)
+		return -EINVAL;
+
+	if (bw < 0 || bw > 2)
+		return -EINVAL;
+
+	if (p->code_rate_HP != FEC_1_2 && p->code_rate_HP != FEC_2_3 &&
+	    p->code_rate_HP != FEC_3_4 && p->code_rate_HP != FEC_5_6 &&
+	    p->code_rate_HP != FEC_7_8)
+		return -EINVAL;
+
+	if (p->hierarchy_information != HIERARCHY_NONE &&
+	    (p->code_rate_LP != FEC_1_2 && p->code_rate_LP != FEC_2_3 &&
+	     p->code_rate_LP != FEC_3_4 && p->code_rate_LP != FEC_5_6 &&
+	     p->code_rate_LP != FEC_7_8))
+		return -EINVAL;
+
+	if (p->constellation != QPSK && p->constellation != QAM_16 &&
+	    p->constellation != QAM_64)
+		return -EINVAL;
+
+	if (p->transmission_mode != TRANSMISSION_MODE_2K &&
+	    p->transmission_mode != TRANSMISSION_MODE_8K)
+		return -EINVAL;
+
+	if (p->guard_interval < GUARD_INTERVAL_1_32 ||
+	    p->guard_interval > GUARD_INTERVAL_1_4)
+		return -EINVAL;
+
+	if (p->hierarchy_information < HIERARCHY_NONE ||
+	    p->hierarchy_information > HIERARCHY_4)
+		return -EINVAL;
+
+	ddfs_offset_fixed = 0x4000-(ppm<<16)/bw_tab[p->bandwidth]/1000000;
+
+	/* This works up to 20000 ppm, it overflows if too large ppm! */
+	init_freq = (((8UL<<25) + (8UL<<19) / 25*ppm / (15625/25)) /
+			bw_tab[p->bandwidth] & 0xFFFFFF);
+
+	/* SPI bias calculation is slightly modified to fit in 32bit */
+	/* will work for high ppm only... */
+	spi_bias = 378 * (1 << 10);
+	spi_bias *= 16;
+	spi_bias *= bw_tab[p->bandwidth];
+	spi_bias *= qam_tab[p->constellation];
+	spi_bias /= p->code_rate_HP + 1;
+	spi_bias /= (guard_tab[p->guard_interval] + 32);
+	spi_bias *= 1000ULL;
+	spi_bias /= 1000ULL + ppm/1000;
+	spi_bias *= p->code_rate_HP;
+
+	val0x04 = (p->transmission_mode << 2) | p->guard_interval;
+	val0x05 = fec_tab[p->code_rate_HP];
+
+	if (p->hierarchy_information != HIERARCHY_NONE)
+		val0x05 |= (p->code_rate_LP - FEC_1_2) << 3;
+
+	val0x06 = (p->hierarchy_information << 2) | p->constellation;
+
+	l64781_writereg (state, 0x04, val0x04);
+	l64781_writereg (state, 0x05, val0x05);
+	l64781_writereg (state, 0x06, val0x06);
+
+	reset_afc (state);
+
+	/* Technical manual section 2.6.1, TIM_IIR_GAIN optimal values */
+	l64781_writereg (state, 0x15,
+			 p->transmission_mode == TRANSMISSION_MODE_2K ? 1 : 3);
+	l64781_writereg (state, 0x16, init_freq & 0xff);
+	l64781_writereg (state, 0x17, (init_freq >> 8) & 0xff);
+	l64781_writereg (state, 0x18, (init_freq >> 16) & 0xff);
+
+	l64781_writereg (state, 0x1b, spi_bias & 0xff);
+	l64781_writereg (state, 0x1c, (spi_bias >> 8) & 0xff);
+	l64781_writereg (state, 0x1d, ((spi_bias >> 16) & 0x7f) |
+		(param->inversion == INVERSION_ON ? 0x80 : 0x00));
+
+	l64781_writereg (state, 0x22, ddfs_offset_fixed & 0xff);
+	l64781_writereg (state, 0x23, (ddfs_offset_fixed >> 8) & 0x3f);
+
+	l64781_readreg (state, 0x00);  /*  clear interrupt registers... */
+	l64781_readreg (state, 0x01);  /*  dto. */
+
+	apply_tps (state);
+
+	return 0;
+}
+
+static int get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* param)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+	int tmp;
+
+
+	tmp = l64781_readreg(state, 0x04);
+	switch(tmp & 3) {
+	case 0:
+		param->u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
+		break;
+	case 1:
+		param->u.ofdm.guard_interval = GUARD_INTERVAL_1_16;
+		break;
+	case 2:
+		param->u.ofdm.guard_interval = GUARD_INTERVAL_1_8;
+		break;
+	case 3:
+		param->u.ofdm.guard_interval = GUARD_INTERVAL_1_4;
+		break;
+	}
+	switch((tmp >> 2) & 3) {
+	case 0:
+		param->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
+		break;
+	case 1:
+		param->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
+		break;
+	default:
+		printk("Unexpected value for transmission_mode\n");
+	}
+
+
+
+	tmp = l64781_readreg(state, 0x05);
+	switch(tmp & 7) {
+	case 0:
+		param->u.ofdm.code_rate_HP = FEC_1_2;
+		break;
+	case 1:
+		param->u.ofdm.code_rate_HP = FEC_2_3;
+		break;
+	case 2:
+		param->u.ofdm.code_rate_HP = FEC_3_4;
+		break;
+	case 3:
+		param->u.ofdm.code_rate_HP = FEC_5_6;
+		break;
+	case 4:
+		param->u.ofdm.code_rate_HP = FEC_7_8;
+		break;
+	default:
+		printk("Unexpected value for code_rate_HP\n");
+	}
+	switch((tmp >> 3) & 7) {
+	case 0:
+		param->u.ofdm.code_rate_LP = FEC_1_2;
+		break;
+	case 1:
+		param->u.ofdm.code_rate_LP = FEC_2_3;
+		break;
+	case 2:
+		param->u.ofdm.code_rate_LP = FEC_3_4;
+		break;
+	case 3:
+		param->u.ofdm.code_rate_LP = FEC_5_6;
+		break;
+	case 4:
+		param->u.ofdm.code_rate_LP = FEC_7_8;
+		break;
+	default:
+		printk("Unexpected value for code_rate_LP\n");
+	}
+
+
+	tmp = l64781_readreg(state, 0x06);
+	switch(tmp & 3) {
+	case 0:
+		param->u.ofdm.constellation = QPSK;
+		break;
+	case 1:
+		param->u.ofdm.constellation = QAM_16;
+		break;
+	case 2:
+		param->u.ofdm.constellation = QAM_64;
+		break;
+	default:
+		printk("Unexpected value for constellation\n");
+	}
+	switch((tmp >> 2) & 7) {
+	case 0:
+		param->u.ofdm.hierarchy_information = HIERARCHY_NONE;
+		break;
+	case 1:
+		param->u.ofdm.hierarchy_information = HIERARCHY_1;
+		break;
+	case 2:
+		param->u.ofdm.hierarchy_information = HIERARCHY_2;
+		break;
+	case 3:
+		param->u.ofdm.hierarchy_information = HIERARCHY_4;
+		break;
+	default:
+		printk("Unexpected value for hierarchy\n");
+	}
+
+
+	tmp = l64781_readreg (state, 0x1d);
+	param->inversion = (tmp & 0x80) ? INVERSION_ON : INVERSION_OFF;
+
+	tmp = (int) (l64781_readreg (state, 0x08) |
+		     (l64781_readreg (state, 0x09) << 8) |
+		     (l64781_readreg (state, 0x0a) << 16));
+	param->frequency += tmp;
+
+	return 0;
+}
+
+static int l64781_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+	int sync = l64781_readreg (state, 0x32);
+	int gain = l64781_readreg (state, 0x0e);
+
+	l64781_readreg (state, 0x00);  /*  clear interrupt registers... */
+	l64781_readreg (state, 0x01);  /*  dto. */
+
+	*status = 0;
+
+	if (gain > 5)
+		*status |= FE_HAS_SIGNAL;
+
+	if (sync & 0x02) /* VCXO locked, this criteria should be ok */
+		*status |= FE_HAS_CARRIER;
+
+	if (sync & 0x20)
+		*status |= FE_HAS_VITERBI;
+
+	if (sync & 0x40)
+		*status |= FE_HAS_SYNC;
+
+	if (sync == 0x7f)
+		*status |= FE_HAS_LOCK;
+
+	return 0;
+}
+
+static int l64781_read_ber(struct dvb_frontend* fe, u32* ber)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+
+	/*   XXX FIXME: set up counting period (reg 0x26...0x28)
+	 */
+	*ber = l64781_readreg (state, 0x39)
+	    | (l64781_readreg (state, 0x3a) << 8);
+
+	return 0;
+}
+
+static int l64781_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+
+	u8 gain = l64781_readreg (state, 0x0e);
+	*signal_strength = (gain << 8) | gain;
+
+	return 0;
+}
+
+static int l64781_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+
+	u8 avg_quality = 0xff - l64781_readreg (state, 0x33);
+	*snr = (avg_quality << 8) | avg_quality; /* not exact, but...*/
+
+	return 0;
+}
+
+static int l64781_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+
+	*ucblocks = l64781_readreg (state, 0x37)
+	   | (l64781_readreg (state, 0x38) << 8);
+
+	return 0;
+}
+
+static int l64781_sleep(struct dvb_frontend* fe)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+
+	/* Power down */
+	return l64781_writereg (state, 0x3e, 0x5a);
+}
+
+static int l64781_init(struct dvb_frontend* fe)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+
+        reset_and_configure (state);
+
+	/* Power up */
+	l64781_writereg (state, 0x3e, 0xa5);
+
+	/* Reset hard */
+	l64781_writereg (state, 0x2a, 0x04);
+	l64781_writereg (state, 0x2a, 0x00);
+
+	/* Set tuner specific things */
+	/* AFC_POL, set also in reset_afc */
+	l64781_writereg (state, 0x07, 0x8e);
+
+	/* Use internal ADC */
+	l64781_writereg (state, 0x0b, 0x81);
+
+	/* AGC loop gain, and polarity is positive */
+	l64781_writereg (state, 0x0c, 0x84);
+
+	/* Internal ADC outputs two's complement */
+	l64781_writereg (state, 0x0d, 0x8c);
+
+	/* With ppm=8000, it seems the DTR_SENSITIVITY will result in
+           value of 2 with all possible bandwidths and guard
+           intervals, which is the initial value anyway. */
+        /*l64781_writereg (state, 0x19, 0x92);*/
+
+	/* Everything is two's complement, soft bit and CSI_OUT too */
+	l64781_writereg (state, 0x1e, 0x09);
+
+	if (state->config->pll_init) state->config->pll_init(fe);
+
+	/* delay a bit after first init attempt */
+	if (state->first) {
+		state->first = 0;
+		msleep(200);
+	}
+
+	return 0;
+}
+
+static int l64781_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
+{
+        fesettings->min_delay_ms = 200;
+        fesettings->step_size = 166667;
+        fesettings->max_drift = 166667*2;
+        return 0;
+}
+
+static void l64781_release(struct dvb_frontend* fe)
+{
+	struct l64781_state* state = (struct l64781_state*) fe->demodulator_priv;
+	kfree(state);
+}
+
+static struct dvb_frontend_ops l64781_ops;
+
+struct dvb_frontend* l64781_attach(const struct l64781_config* config,
+				   struct i2c_adapter* i2c)
+{
+	struct l64781_state* state = NULL;
+	int reg0x3e = -1;
+	u8 b0 [] = { 0x1a };
+	u8 b1 [] = { 0x00 };
+	struct i2c_msg msg [] = { { .addr = config->demod_address, .flags = 0, .buf = b0, .len = 1 },
+			   { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
+
+	/* allocate memory for the internal state */
+	state = (struct l64781_state*) kmalloc(sizeof(struct l64781_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &l64781_ops, sizeof(struct dvb_frontend_ops));
+	state->first = 1;
+
+	/**
+	 *  the L64781 won't show up before we send the reset_and_configure()
+	 *  broadcast. If nothing responds there is no L64781 on the bus...
+	 */
+	if (reset_and_configure(state) < 0) {
+		dprintk("No response to reset and configure broadcast...\n");
+		goto error;
+	}
+
+	/* The chip always responds to reads */
+	if (i2c_transfer(state->i2c, msg, 2) != 2) {
+	        dprintk("No response to read on I2C bus\n");
+		goto error;
+	}
+
+	/* Save current register contents for bailout */
+	reg0x3e = l64781_readreg(state, 0x3e);
+
+	/* Reading the POWER_DOWN register always returns 0 */
+	if (reg0x3e != 0) {
+	        dprintk("Device doesn't look like L64781\n");
+		goto error;
+	}
+
+	/* Turn the chip off */
+	l64781_writereg (state, 0x3e, 0x5a);
+
+	/* Responds to all reads with 0 */
+	if (l64781_readreg(state, 0x1a) != 0) {
+ 	        dprintk("Read 1 returned unexpcted value\n");
+		goto error;
+	}
+
+	/* Turn the chip on */
+	l64781_writereg (state, 0x3e, 0xa5);
+
+	/* Responds with register default value */
+	if (l64781_readreg(state, 0x1a) != 0xa1) {
+ 	        dprintk("Read 2 returned unexpcted value\n");
+		goto error;
+	}
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (reg0x3e >= 0) l64781_writereg (state, 0x3e, reg0x3e);  /* restore reg 0x3e */
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops l64781_ops = {
+
+	.info = {
+		.name = "LSI L64781 DVB-T",
+		.type = FE_OFDM,
+	/*	.frequency_min = ???,*/
+	/*	.frequency_max = ???,*/
+		.frequency_stepsize = 166666,
+	/*      .frequency_tolerance = ???,*/
+	/*      .symbol_rate_tolerance = ???,*/
+		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+		      FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
+		      FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
+        	      FE_CAN_MUTE_TS
+	},
+
+     	.release = l64781_release,
+
+	.init = l64781_init,
+	.sleep = l64781_sleep,
+
+	.set_frontend = apply_frontend_param,
+	.get_frontend = get_frontend,
+	.get_tune_settings = l64781_get_tune_settings,
+
+	.read_status = l64781_read_status,
+	.read_ber = l64781_read_ber,
+	.read_signal_strength = l64781_read_signal_strength,
+	.read_snr = l64781_read_snr,
+	.read_ucblocks = l64781_read_ucblocks,
+};
+
+MODULE_DESCRIPTION("LSI L64781 DVB-T Demodulator driver");
+MODULE_AUTHOR("Holger Waechtler, Marko Kohtala");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(l64781_attach);
diff -Nru a/drivers/media/dvb/frontends/l64781.h b/drivers/media/dvb/frontends/l64781.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/l64781.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,43 @@
+/*
+    driver for LSI L64781 COFDM demodulator
+
+    Copyright (C) 2001 Holger Waechtler <holger@convergence.de>
+                       for Convergence Integrated Media GmbH
+                       Marko Kohtala <marko.kohtala@nokia.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 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.
+
+*/
+
+#ifndef L64781_H
+#define L64781_H
+
+#include <linux/dvb/frontend.h>
+
+struct l64781_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+
+extern struct dvb_frontend* l64781_attach(const struct l64781_config* config,
+					  struct i2c_adapter* i2c);
+
+#endif // L64781_H
diff -Nru a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
--- a/drivers/media/dvb/frontends/mt312.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/dvb/frontends/mt312.c	2004-12-24 13:36:18 -08:00
@@ -1,5 +1,5 @@
 /* 
-    Driver for Zarlink MT312 Satellite Channel Decoder
+    Driver for Zarlink VP310/MT312 Satellite Channel Decoder
 
     Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org>
 
@@ -28,236 +28,235 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 
 #include "dvb_frontend.h"
+#include "mt312_priv.h"
 #include "mt312.h"
 
-#define I2C_ADDR_MT312		0x0e
-#define I2C_ADDR_SL1935		0x61
-#define I2C_ADDR_TSA5059	0x61
 
-#define MT312_DEBUG		0
+struct mt312_state {
 
-#define MT312_SYS_CLK		90000000UL	/* 90 MHz */
-#define MT312_LPOWER_SYS_CLK	60000000UL	/* 60 MHz */
-#define MT312_PLL_CLK		10000000UL	/* 10 MHz */
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
 
-/* number of active frontends */
-static int mt312_count = 0;
+	/* configuration settings */
+	const struct mt312_config* config;
 
-#if MT312_DEBUG == 0
-#define dprintk(x...)
-#else
-static int debug = 0;
-#define dprintk if(debug == 1) printk
-#endif
-
-static struct dvb_frontend_info mt312_info = {
-	.name = "Zarlink MT312",
-	.type = FE_QPSK,
-	.frequency_min = 950000,
-	.frequency_max = 2150000,
-	.frequency_stepsize = (MT312_PLL_CLK / 1000) / 128,
-	/*.frequency_tolerance = 29500,         FIXME: binary compatibility waste? */
-	.symbol_rate_min = MT312_SYS_CLK / 128,
-	.symbol_rate_max = MT312_SYS_CLK / 2,
-	/*.symbol_rate_tolerance = 500,         FIXME: binary compatibility waste? 2% */
-	.notifier_delay = 0,
-	.caps =
-	    FE_CAN_INVERSION_AUTO | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
-	    FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
-	    FE_CAN_FEC_AUTO | FE_CAN_QPSK | FE_CAN_MUTE_TS | 
-            FE_CAN_RECOVER
+	struct dvb_frontend frontend;
+
+	u8 id;
+	u8 frequency;
 };
 
-static int mt312_read(struct dvb_i2c_bus *i2c,
-		      const enum mt312_reg_addr reg, void *buf,
-		      const size_t count)
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "mt312: " args); \
+	} while (0)
+
+#define MT312_SYS_CLK		90000000UL	/* 90 MHz */
+#define MT312_LPOWER_SYS_CLK	60000000UL	/* 60 MHz */
+#define MT312_PLL_CLK		10000000UL	/* 10 MHz */
+
+static int mt312_read(struct mt312_state* state, const enum mt312_reg_addr reg,
+		      void *buf, const size_t count)
 {
 	int ret;
 	struct i2c_msg msg[2];
 	u8 regbuf[1] = { reg };
 
-	msg[0].addr = I2C_ADDR_MT312;
+	msg[0].addr = state->config->demod_address;
 	msg[0].flags = 0;
 	msg[0].buf = regbuf;
 	msg[0].len = 1;
-	msg[1].addr = I2C_ADDR_MT312;
+	msg[1].addr = state->config->demod_address;
 	msg[1].flags = I2C_M_RD;
 	msg[1].buf = buf;
 	msg[1].len = count;
 
-	ret = i2c->xfer(i2c, msg, 2);
+	ret = i2c_transfer(state->i2c, msg, 2);
 
-	if ((ret != 2) && (mt312_count != 0)) {
+	if (ret != 2) {
 		printk(KERN_ERR "%s: ret == %d\n", __FUNCTION__, ret);
 		return -EREMOTEIO;
 	}
-#if MT312_DEBUG
+
 	if(debug) {
 		int i;
-		printk(KERN_INFO "R(%d):", reg & 0x7f);
+		dprintk("R(%d):", reg & 0x7f);
 		for (i = 0; i < count; i++)
 			printk(" %02x", ((const u8 *) buf)[i]);
 		printk("\n");
 	}
-#endif
 
 	return 0;
 }
 
-static int mt312_write(struct dvb_i2c_bus *i2c,
-		       const enum mt312_reg_addr reg, const void *src,
-		       const size_t count)
+static int mt312_write(struct mt312_state* state, const enum mt312_reg_addr reg,
+		       const void *src, const size_t count)
 {
 	int ret;
 	u8 buf[count + 1];
 	struct i2c_msg msg;
 
-#if MT312_DEBUG
 	if(debug) {
 		int i;
-		printk(KERN_INFO "W(%d):", reg & 0x7f);
+		dprintk("W(%d):", reg & 0x7f);
 		for (i = 0; i < count; i++)
 			printk(" %02x", ((const u8 *) src)[i]);
 		printk("\n");
 	}
-#endif
 
 	buf[0] = reg;
 	memcpy(&buf[1], src, count);
 
-	msg.addr = I2C_ADDR_MT312;
+	msg.addr = state->config->demod_address;
 	msg.flags = 0;
 	msg.buf = buf;
 	msg.len = count + 1;
 
-	ret = i2c->xfer(i2c, &msg, 1);
+	ret = i2c_transfer(state->i2c, &msg, 1);
 
 	if (ret != 1) {
-		printk(KERN_ERR "%s: ret == %d\n", __FUNCTION__, ret);
+		dprintk("%s: ret == %d\n", __FUNCTION__, ret);
 		return -EREMOTEIO;
 	}
 
 	return 0;
 }
 
-static inline int mt312_readreg(struct dvb_i2c_bus *i2c,
+static inline int mt312_readreg(struct mt312_state* state,
 				const enum mt312_reg_addr reg, u8 * val)
 {
-	return mt312_read(i2c, reg, val, 1);
+	return mt312_read(state, reg, val, 1);
 }
 
-static inline int mt312_writereg(struct dvb_i2c_bus *i2c,
+static inline int mt312_writereg(struct mt312_state* state,
 				 const enum mt312_reg_addr reg, const u8 val)
 {
-	return mt312_write(i2c, reg, &val, 1);
+	return mt312_write(state, reg, &val, 1);
 }
 
-static int mt312_pll_write(struct dvb_i2c_bus *i2c, const u8 addr,
-			   u8 * buf, const u8 len)
+static inline u32 mt312_div(u32 a, u32 b)
+{
+	return (a + (b / 2)) / b;
+}
+
+static int mt312_reset(struct mt312_state* state, const u8 full)
+{
+	return mt312_writereg(state, RESET, full ? 0x80 : 0x40);
+}
+
+static int mt312_get_inversion(struct mt312_state* state,
+			       fe_spectral_inversion_t *i)
 {
 	int ret;
-	struct i2c_msg msg;
+	u8 vit_mode;
 
-	msg.addr = addr;
-	msg.flags = 0;
-	msg.buf = buf;
-	msg.len = len;
+	if ((ret = mt312_readreg(state, VIT_MODE, &vit_mode)) < 0)
+		return ret;
+
+	if (vit_mode & 0x80)	/* auto inversion was used */
+		*i = (vit_mode & 0x40) ? INVERSION_ON : INVERSION_OFF;
+
+	return 0;
+}
+
+static int mt312_get_symbol_rate(struct mt312_state* state, u32 *sr)
+{
+	int ret;
+	u8 sym_rate_h;
+	u8 dec_ratio;
+	u16 sym_rat_op;
+	u16 monitor;
+	u8 buf[2];
 
-	if ((ret = mt312_writereg(i2c, GPP_CTRL, 0x40)) < 0)
+	if ((ret = mt312_readreg(state, SYM_RATE_H, &sym_rate_h)) < 0)
 		return ret;
 
-	if ((ret = i2c->xfer(i2c, &msg, 1)) != 1)
-		printk(KERN_ERR "%s: i/o error (ret == %d)\n", __FUNCTION__, ret);
+	if (sym_rate_h & 0x80) {	/* symbol rate search was used */
+		if ((ret = mt312_writereg(state, MON_CTRL, 0x03)) < 0)
+			return ret;
 
-	if ((ret = mt312_writereg(i2c, GPP_CTRL, 0x00)) < 0)
+		if ((ret = mt312_read(state, MONITOR_H, buf, sizeof(buf))) < 0)
 		return ret;
 
-	return 0;
+		monitor = (buf[0] << 8) | buf[1];
+
+		dprintk(KERN_DEBUG "sr(auto) = %u\n",
+		       mt312_div(monitor * 15625, 4));
+	} else {
+		if ((ret = mt312_writereg(state, MON_CTRL, 0x05)) < 0)
+			return ret;
+
+		if ((ret = mt312_read(state, MONITOR_H, buf, sizeof(buf))) < 0)
+			return ret;
+
+		dec_ratio = ((buf[0] >> 5) & 0x07) * 32;
+
+		if ((ret = mt312_read(state, SYM_RAT_OP_H, buf, sizeof(buf))) < 0)
+			return ret;
+
+		sym_rat_op = (buf[0] << 8) | buf[1];
+
+		dprintk(KERN_DEBUG "sym_rat_op=%d dec_ratio=%d\n",
+		       sym_rat_op, dec_ratio);
+		dprintk(KERN_DEBUG "*sr(manual) = %lu\n",
+		       (((MT312_PLL_CLK * 8192) / (sym_rat_op + 8192)) *
+			2) - dec_ratio);
 }
 
-static inline u32 mt312_div(u32 a, u32 b)
-{
-	return (a + (b / 2)) / b;
+	return 0;
 }
 
-static int sl1935_set_tv_freq(struct dvb_i2c_bus *i2c, u32 freq, u32 sr)
+static int mt312_get_code_rate(struct mt312_state* state, fe_code_rate_t *cr)
 {
-	/* 155 uA, Baseband Path B */
-	u8 buf[4] = { 0x00, 0x00, 0x80, 0x00 };
+	const fe_code_rate_t fec_tab[8] =
+	    { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_6_7, FEC_7_8,
+		FEC_AUTO, FEC_AUTO };
+
+	int ret;
+	u8 fec_status;
+
+	if ((ret = mt312_readreg(state, FEC_STATUS, &fec_status)) < 0)
+		return ret;
 
-	u8 exp;
-	u32 ref;
-	u32 div;
-
-	if (sr < 10000000) {	/* 1-10 MSym/s: ratio 2 ^ 3 */
-		exp = 3;
-		buf[2] |= 0x40;	/* 690 uA */
-	} else if (sr < 15000000) {	/* 10-15 MSym/s: ratio 2 ^ 4 */
-		exp = 4;
-		buf[2] |= 0x20;	/* 330 uA */
-	} else {		/* 15-45 MSym/s: ratio 2 ^ 7 */
-		exp = 7;
-		buf[3] |= 0x08;	/* Baseband Path A */
+	*cr = fec_tab[(fec_status >> 4) & 0x07];
+
+	return 0;
 	}
 
-	div = mt312_div(MT312_PLL_CLK, 1 << exp);
-	ref = mt312_div(freq * 1000, div);
-	mt312_info.frequency_stepsize = mt312_div(div, 1000);
 
-	buf[0] = (ref >> 8) & 0x7f;
-	buf[1] = (ref >> 0) & 0xff;
-	buf[2] |= (exp - 1);
 
-	if (freq < 1550000)
-		buf[3] |= 0x10;
 
-	dprintk(KERN_INFO "synth dword = %02x%02x%02x%02x\n", buf[0],
-	       buf[1], buf[2], buf[3]);
 
-	return mt312_pll_write(i2c, I2C_ADDR_SL1935, buf, sizeof(buf));
-}
 
-static int tsa5059_set_tv_freq(struct dvb_i2c_bus *i2c, u32 freq, u32 sr)
-{
-	u8 buf[4];
 
-	u32 ref = mt312_div(freq, 125);
 
-	buf[0] = (ref >> 8) & 0x7f;
-	buf[1] = (ref >> 0) & 0xff;
-	buf[2] = 0x84 | ((ref >> 10) & 0x60);
-	buf[3] = 0x80;
 	
-	if (freq < 1550000)
-		buf[3] |= 0x02;
 
-	dprintk(KERN_INFO "synth dword = %02x%02x%02x%02x\n", buf[0],
-	       buf[1], buf[2], buf[3]);
 
-	return mt312_pll_write(i2c, I2C_ADDR_TSA5059, buf, sizeof(buf));
-}
 
-static int mt312_reset(struct dvb_i2c_bus *i2c, const u8 full)
-{
-	return mt312_writereg(i2c, RESET, full ? 0x80 : 0x40);
-}
 
-static int mt312_init(struct dvb_i2c_bus *i2c, const long id, u8 pll)
+
+
+static int mt312_initfe(struct dvb_frontend* fe)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 	u8 buf[2];
 
 	/* wake up */
-	if ((ret = mt312_writereg(i2c, CONFIG, (pll == 60 ? 0x88 : 0x8c))) < 0)
+	if ((ret = mt312_writereg(state, CONFIG, (state->frequency == 60 ? 0x88 : 0x8c))) < 0)
 		return ret;
 
 	/* wait at least 150 usec */
 	udelay(150);
 
 	/* full reset */
-	if ((ret = mt312_reset(i2c, 1)) < 0)
+	if ((ret = mt312_reset(state, 1)) < 0)
 		return ret;
 
 // Per datasheet, write correct values. 09/28/03 ACCJr.
@@ -265,56 +264,63 @@
 	{
 		u8 buf_def[8]={0x14, 0x12, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00};
 
-		if ((ret = mt312_write(i2c, VIT_SETUP, buf_def, sizeof(buf_def))) < 0)
+		if ((ret = mt312_write(state, VIT_SETUP, buf_def, sizeof(buf_def))) < 0)
 			return ret;
 	}
 
 	/* SYS_CLK */
-	buf[0] = mt312_div((pll == 60 ? MT312_LPOWER_SYS_CLK : MT312_SYS_CLK) * 2, 1000000);
+	buf[0] = mt312_div((state->frequency == 60 ? MT312_LPOWER_SYS_CLK : MT312_SYS_CLK) * 2, 1000000);
 
 	/* DISEQC_RATIO */
 	buf[1] = mt312_div(MT312_PLL_CLK, 15000 * 4);
 
-	if ((ret = mt312_write(i2c, SYS_CLK, buf, sizeof(buf))) < 0)
+	if ((ret = mt312_write(state, SYS_CLK, buf, sizeof(buf))) < 0)
 		return ret;
 
-	if ((ret = mt312_writereg(i2c, SNR_THS_HIGH, 0x32)) < 0)
+	if ((ret = mt312_writereg(state, SNR_THS_HIGH, 0x32)) < 0)
 		return ret;
 
-	if ((ret = mt312_writereg(i2c, OP_CTRL, 0x53)) < 0)
+	if ((ret = mt312_writereg(state, OP_CTRL, 0x53)) < 0)
 		return ret;
 
 	/* TS_SW_LIM */
 	buf[0] = 0x8c;
 	buf[1] = 0x98;
 
-	if ((ret = mt312_write(i2c, TS_SW_LIM_L, buf, sizeof(buf))) < 0)
+	if ((ret = mt312_write(state, TS_SW_LIM_L, buf, sizeof(buf))) < 0)
 		return ret;
 
-	if ((ret = mt312_writereg(i2c, CS_SW_LIM, 0x69)) < 0)
+	if ((ret = mt312_writereg(state, CS_SW_LIM, 0x69)) < 0)
 		return ret;
 
+	if (state->config->pll_init) {
+		mt312_writereg(state, GPP_CTRL, 0x40);
+		state->config->pll_init(fe);
+		mt312_writereg(state, GPP_CTRL, 0x00);
+	}
+
 	return 0;
 }
 
-static int mt312_send_master_cmd(struct dvb_i2c_bus *i2c,
-				 const struct dvb_diseqc_master_cmd *c)
+static int mt312_send_master_cmd(struct dvb_frontend* fe,
+				 struct dvb_diseqc_master_cmd *c)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 	u8 diseqc_mode;
 
 	if ((c->msg_len == 0) || (c->msg_len > sizeof(c->msg)))
 		return -EINVAL;
 
-	if ((ret = mt312_readreg(i2c, DISEQC_MODE, &diseqc_mode)) < 0)
+	if ((ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode)) < 0)
 		return ret;
 
 	if ((ret =
-	     mt312_write(i2c, (0x80 | DISEQC_INSTR), c->msg, c->msg_len)) < 0)
+	     mt312_write(state, (0x80 | DISEQC_INSTR), c->msg, c->msg_len)) < 0)
 		return ret;
 
 	if ((ret =
-	     mt312_writereg(i2c, DISEQC_MODE,
+	     mt312_writereg(state, DISEQC_MODE,
 			    (diseqc_mode & 0x40) | ((c->msg_len - 1) << 3)
 			    | 0x04)) < 0)
 		return ret;
@@ -322,21 +328,15 @@
 	/* set DISEQC_MODE[2:0] to zero if a return message is expected */
 	if (c->msg[0] & 0x02)
 		if ((ret =
-		     mt312_writereg(i2c, DISEQC_MODE, (diseqc_mode & 0x40))) < 0)
+		     mt312_writereg(state, DISEQC_MODE, (diseqc_mode & 0x40))) < 0)
 			return ret;
 
 	return 0;
 }
 
-static int mt312_recv_slave_reply(struct dvb_i2c_bus *i2c,
-				  struct dvb_diseqc_slave_reply *r)
-{
-	/* TODO */
-	return -EOPNOTSUPP;
-}
-
-static int mt312_send_burst(struct dvb_i2c_bus *i2c, const fe_sec_mini_cmd_t c)
+static int mt312_send_burst(struct dvb_frontend* fe, const fe_sec_mini_cmd_t c)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	const u8 mini_tab[2] = { 0x02, 0x03 };
 
 	int ret;
@@ -345,19 +345,20 @@
 	if (c > SEC_MINI_B)
 		return -EINVAL;
 
-	if ((ret = mt312_readreg(i2c, DISEQC_MODE, &diseqc_mode)) < 0)
+	if ((ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode)) < 0)
 		return ret;
 
 	if ((ret =
-	     mt312_writereg(i2c, DISEQC_MODE,
+	     mt312_writereg(state, DISEQC_MODE,
 			    (diseqc_mode & 0x40) | mini_tab[c])) < 0)
 		return ret;
 
 	return 0;
 }
 
-static int mt312_set_tone(struct dvb_i2c_bus *i2c, const fe_sec_tone_mode_t t)
+static int mt312_set_tone(struct dvb_frontend* fe, const fe_sec_tone_mode_t t)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	const u8 tone_tab[2] = { 0x01, 0x00 };
 
 	int ret;
@@ -366,35 +367,37 @@
 	if (t > SEC_TONE_OFF)
 		return -EINVAL;
 
-	if ((ret = mt312_readreg(i2c, DISEQC_MODE, &diseqc_mode)) < 0)
+	if ((ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode)) < 0)
 		return ret;
 
 	if ((ret =
-	     mt312_writereg(i2c, DISEQC_MODE,
+	     mt312_writereg(state, DISEQC_MODE,
 			    (diseqc_mode & 0x40) | tone_tab[t])) < 0)
 		return ret;
 
 	return 0;
 }
 
-static int mt312_set_voltage(struct dvb_i2c_bus *i2c, const fe_sec_voltage_t v)
+static int mt312_set_voltage(struct dvb_frontend* fe, const fe_sec_voltage_t v)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	const u8 volt_tab[3] = { 0x00, 0x40, 0x00 };
 
 	if (v > SEC_VOLTAGE_OFF)
 		return -EINVAL;
 
-	return mt312_writereg(i2c, DISEQC_MODE, volt_tab[v]);
+	return mt312_writereg(state, DISEQC_MODE, volt_tab[v]);
 }
 
-static int mt312_read_status(struct dvb_i2c_bus *i2c, fe_status_t *s, const long id)
+static int mt312_read_status(struct dvb_frontend* fe, fe_status_t *s)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
-	u8 status[3], vit_mode;
+	u8 status[3];
 
 	*s = 0;
 
-	if ((ret = mt312_read(i2c, QPSK_STAT_H, status, sizeof(status))) < 0)
+	if ((ret = mt312_read(state, QPSK_STAT_H, status, sizeof(status))) < 0)
 		return ret;
 
 	dprintk(KERN_DEBUG "QPSK_STAT_H: 0x%02x, QPSK_STAT_L: 0x%02x, FEC_STATUS: 0x%02x\n", status[0], status[1], status[2]);
@@ -409,26 +412,17 @@
 		*s |= FE_HAS_SYNC;	/* byte align lock */
 	if (status[0] & 0x01)
 		*s |= FE_HAS_LOCK;	/* qpsk lock */
-	// VP310 doesn't have AUTO, so we "implement it here" ACCJr
-	if ((id == ID_VP310) && !(status[0] & 0x01)) {
-		if ((ret = mt312_readreg(i2c, VIT_MODE, &vit_mode)) < 0)
-			return ret;
-		vit_mode ^= 0x40;
-		if ((ret = mt312_writereg(i2c, VIT_MODE, vit_mode)) < 0)
-                	return ret;
-		if ((ret = mt312_writereg(i2c, GO, 0x01)) < 0)
-                	return ret;
-	}
 
 	return 0;
 }
 
-static int mt312_read_bercnt(struct dvb_i2c_bus *i2c, u32 * ber)
+static int mt312_read_ber(struct dvb_frontend* fe, u32 *ber)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 	u8 buf[3];
 
-	if ((ret = mt312_read(i2c, RS_BERCNT_H, buf, 3)) < 0)
+	if ((ret = mt312_read(state, RS_BERCNT_H, buf, 3)) < 0)
 		return ret;
 
 	*ber = ((buf[0] << 16) | (buf[1] << 8) | buf[2]) * 64;
@@ -436,14 +430,15 @@
 	return 0;
 }
 
-static int mt312_read_agc(struct dvb_i2c_bus *i2c, u16 * signal_strength)
+static int mt312_read_signal_strength(struct dvb_frontend* fe, u16 *signal_strength)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 	u8 buf[3];
 	u16 agc;
 	s16 err_db;
 
-	if ((ret = mt312_read(i2c, AGC_H, buf, sizeof(buf))) < 0)
+	if ((ret = mt312_read(state, AGC_H, buf, sizeof(buf))) < 0)
 		return ret;
 
 	agc = (buf[0] << 6) | (buf[1] >> 2);
@@ -456,12 +451,13 @@
 	return 0;
 }
 
-static int mt312_read_snr(struct dvb_i2c_bus *i2c, u16 * snr)
+static int mt312_read_snr(struct dvb_frontend* fe, u16 *snr)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 	u8 buf[2];
 
-	if ((ret = mt312_read(i2c, M_SNR_H, &buf, sizeof(buf))) < 0)
+	if ((ret = mt312_read(state, M_SNR_H, &buf, sizeof(buf))) < 0)
 		return ret;
 
 	*snr = 0xFFFF - ((((buf[0] & 0x7f) << 8) | buf[1]) << 1);
@@ -469,12 +465,13 @@
 	return 0;
 }
 
-static int mt312_read_ubc(struct dvb_i2c_bus *i2c, u32 * ubc)
+static int mt312_read_ucblocks(struct dvb_frontend* fe, u32 *ubc)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 	u8 buf[2];
 
-	if ((ret = mt312_read(i2c, RS_UBC_H, &buf, sizeof(buf))) < 0)
+	if ((ret = mt312_read(state, RS_UBC_H, &buf, sizeof(buf))) < 0)
 		return ret;
 
 	*ubc = (buf[0] << 8) | buf[1];
@@ -482,10 +479,10 @@
 	return 0;
 }
 
-static int mt312_set_frontend(struct dvb_i2c_bus *i2c,
-			      const struct dvb_frontend_parameters *p,
-			      const long id)
+static int mt312_set_frontend(struct dvb_frontend* fe,
+			      struct dvb_frontend_parameters *p)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 	u8 buf[5], config_val;
 	u16 sr;
@@ -494,20 +491,18 @@
 	    { 0x00, 0x01, 0x02, 0x04, 0x3f, 0x08, 0x10, 0x20, 0x3f, 0x3f };
 	const u8 inv_tab[3] = { 0x00, 0x40, 0x80 };
 
-	int (*set_tv_freq)(struct dvb_i2c_bus *i2c, u32 freq, u32 sr);
-
 	dprintk("%s: Freq %d\n", __FUNCTION__, p->frequency);
 
-	if ((p->frequency < mt312_info.frequency_min)
-	    || (p->frequency > mt312_info.frequency_max))
+	if ((p->frequency < fe->ops->info.frequency_min)
+	    || (p->frequency > fe->ops->info.frequency_max))
 		return -EINVAL;
 
 	if ((p->inversion < INVERSION_OFF)
-	    || (p->inversion > INVERSION_AUTO))
+	    || (p->inversion > INVERSION_ON))
 		return -EINVAL;
 
-	if ((p->u.qpsk.symbol_rate < mt312_info.symbol_rate_min)
-	    || (p->u.qpsk.symbol_rate > mt312_info.symbol_rate_max))
+	if ((p->u.qpsk.symbol_rate < fe->ops->info.symbol_rate_min)
+	    || (p->u.qpsk.symbol_rate > fe->ops->info.symbol_rate_max))
 		return -EINVAL;
 
 	if ((p->u.qpsk.fec_inner < FEC_NONE)
@@ -518,35 +513,40 @@
 	    || (p->u.qpsk.fec_inner == FEC_8_9))
 		return -EINVAL;
 
-	switch (id) {
+	switch (state->id) {
 	case ID_VP310:
 	// For now we will do this only for the VP310.
 	// It should be better for the mt312 as well, but tunning will be slower. ACCJr 09/29/03
-		if ((ret = mt312_readreg(i2c, CONFIG, &config_val) < 0))
+		if ((ret = mt312_readreg(state, CONFIG, &config_val) < 0))
 			return ret;
 		if (p->u.qpsk.symbol_rate >= 30000000) //Note that 30MS/s should use 90MHz
 		{
-			if ((config_val & 0x0c) == 0x08) //We are running 60MHz
-				if ((ret = mt312_init(i2c, id, (u8) 90)) < 0)
+			if ((config_val & 0x0c) == 0x08) { //We are running 60MHz
+				state->frequency = 90;
+				if ((ret = mt312_initfe(fe)) < 0)
 					return ret;
 		}
+		}
 		else
 		{
-			if ((config_val & 0x0c) == 0x0C) //We are running 90MHz
-				if ((ret = mt312_init(i2c, id, (u8) 60)) < 0)
+			if ((config_val & 0x0c) == 0x0C) { //We are running 90MHz
+				state->frequency = 60;
+				if ((ret = mt312_initfe(fe)) < 0)
 					return ret;
 		}
-		set_tv_freq = tsa5059_set_tv_freq;
+		}
 		break;
+
 	case ID_MT312:
-		set_tv_freq = sl1935_set_tv_freq;
 		break;
+
 	default:
 		return -EINVAL;
 	}
 
-	if ((ret = set_tv_freq(i2c, p->frequency, p->u.qpsk.symbol_rate)) < 0)
-		return ret;
+	mt312_writereg(state, GPP_CTRL, 0x40);
+	state->config->pll_set(fe, p);
+	mt312_writereg(state, GPP_CTRL, 0x00);
 
 	/* sr = (u16)(sr * 256.0 / 1000000.0) */
 	sr = mt312_div(p->u.qpsk.symbol_rate * 4, 15625);
@@ -567,259 +567,182 @@
 	/* GO */
 	buf[4] = 0x01;
 
-	if ((ret = mt312_write(i2c, SYM_RATE_H, buf, sizeof(buf))) < 0)
-		return ret;
-
-        mt312_reset(i2c, 0);
-
-	return 0;
-}
-
-static int mt312_get_inversion(struct dvb_i2c_bus *i2c,
-			       fe_spectral_inversion_t * i)
-{
-	int ret;
-	u8 vit_mode;
-
-	if ((ret = mt312_readreg(i2c, VIT_MODE, &vit_mode)) < 0)
+	if ((ret = mt312_write(state, SYM_RATE_H, buf, sizeof(buf))) < 0)
 		return ret;
 
-	if (vit_mode & 0x80)	/* auto inversion was used */
-		*i = (vit_mode & 0x40) ? INVERSION_ON : INVERSION_OFF;
-
-	return 0;
-}
-
-static int mt312_get_symbol_rate(struct dvb_i2c_bus *i2c, u32 * sr)
-{
-	int ret;
-	u8 sym_rate_h;
-	u8 dec_ratio;
-	u16 sym_rat_op;
-	u16 monitor;
-	u8 buf[2];
-
-	if ((ret = mt312_readreg(i2c, SYM_RATE_H, &sym_rate_h)) < 0)
-		return ret;
-
-	if (sym_rate_h & 0x80) {	/* symbol rate search was used */
-		if ((ret = mt312_writereg(i2c, MON_CTRL, 0x03)) < 0)
-			return ret;
-
-		if ((ret = mt312_read(i2c, MONITOR_H, buf, sizeof(buf))) < 0)
-			return ret;
-
-		monitor = (buf[0] << 8) | buf[1];
-
-		dprintk(KERN_DEBUG "sr(auto) = %u\n",
-		       mt312_div(monitor * 15625, 4));
-	} else {
-		if ((ret = mt312_writereg(i2c, MON_CTRL, 0x05)) < 0)
-			return ret;
-
-		if ((ret = mt312_read(i2c, MONITOR_H, buf, sizeof(buf))) < 0)
-			return ret;
-
-		dec_ratio = ((buf[0] >> 5) & 0x07) * 32;
-
-		if ((ret = mt312_read(i2c, SYM_RAT_OP_H, buf, sizeof(buf))) < 0)
-			return ret;
-
-		sym_rat_op = (buf[0] << 8) | buf[1];
-
-		dprintk(KERN_DEBUG "sym_rat_op=%d dec_ratio=%d\n",
-		       sym_rat_op, dec_ratio);
-		dprintk(KERN_DEBUG "*sr(manual) = %lu\n",
-		       (((MT312_PLL_CLK * 8192) / (sym_rat_op + 8192)) *
-			2) - dec_ratio);
-	}
+        mt312_reset(state, 0);
 
 	return 0;
 }
 
-static int mt312_get_code_rate(struct dvb_i2c_bus *i2c, fe_code_rate_t * cr)
-{
-	const fe_code_rate_t fec_tab[8] =
-	    { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_6_7, FEC_7_8,
-		FEC_AUTO, FEC_AUTO };
-
-	int ret;
-	u8 fec_status;
-
-	if ((ret = mt312_readreg(i2c, FEC_STATUS, &fec_status)) < 0)
-		return ret;
-
-	*cr = fec_tab[(fec_status >> 4) & 0x07];
-
-	return 0;
-}
-
-static int mt312_get_frontend(struct dvb_i2c_bus *i2c,
+static int mt312_get_frontend(struct dvb_frontend* fe,
 			      struct dvb_frontend_parameters *p)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 
-	if ((ret = mt312_get_inversion(i2c, &p->inversion)) < 0)
+	if ((ret = mt312_get_inversion(state, &p->inversion)) < 0)
 		return ret;
 
-	if ((ret = mt312_get_symbol_rate(i2c, &p->u.qpsk.symbol_rate)) < 0)
+	if ((ret = mt312_get_symbol_rate(state, &p->u.qpsk.symbol_rate)) < 0)
 		return ret;
 
-	if ((ret = mt312_get_code_rate(i2c, &p->u.qpsk.fec_inner)) < 0)
+	if ((ret = mt312_get_code_rate(state, &p->u.qpsk.fec_inner)) < 0)
 		return ret;
 
 	return 0;
 }
 
-static int mt312_sleep(struct dvb_i2c_bus *i2c)
+static int mt312_sleep(struct dvb_frontend* fe)
 {
+	struct mt312_state *state = (struct mt312_state*) fe->demodulator_priv;
 	int ret;
 	u8 config;
 
 	/* reset all registers to defaults */
-	if ((ret = mt312_reset(i2c, 1)) < 0)
+	if ((ret = mt312_reset(state, 1)) < 0)
 		return ret;
 
-	if ((ret = mt312_readreg(i2c, CONFIG, &config)) < 0)
+	if ((ret = mt312_readreg(state, CONFIG, &config)) < 0)
 		return ret;
 
 	/* enter standby */
-	if ((ret = mt312_writereg(i2c, CONFIG, config & 0x7f)) < 0)
+	if ((ret = mt312_writereg(state, CONFIG, config & 0x7f)) < 0)
 		return ret;
 
 	return 0;
 }
 
-static int mt312_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-	struct dvb_i2c_bus *i2c = fe->i2c;
-
-	switch (cmd) {
-	case FE_GET_INFO:
-		memcpy(arg, &mt312_info, sizeof(struct dvb_frontend_info));
-		break;
-
-	case FE_DISEQC_RESET_OVERLOAD:
-		return -EOPNOTSUPP;
-
-	case FE_DISEQC_SEND_MASTER_CMD:
-		return mt312_send_master_cmd(i2c, arg);
-
-	case FE_DISEQC_RECV_SLAVE_REPLY:
-		if ((long) fe->data == ID_MT312)
-			return mt312_recv_slave_reply(i2c, arg);
-		else
-			return -EOPNOTSUPP;
-
-	case FE_DISEQC_SEND_BURST:
-		return mt312_send_burst(i2c, (fe_sec_mini_cmd_t) arg);
-
-	case FE_SET_TONE:
-		return mt312_set_tone(i2c, (fe_sec_tone_mode_t) arg);
-
-	case FE_SET_VOLTAGE:
-		return mt312_set_voltage(i2c, (fe_sec_voltage_t) arg);
-
-	case FE_ENABLE_HIGH_LNB_VOLTAGE:
-		return -EOPNOTSUPP;
-
-	case FE_READ_STATUS:
-		return mt312_read_status(i2c, arg, (long) fe->data);
-
-	case FE_READ_BER:
-		return mt312_read_bercnt(i2c, arg);
-
-	case FE_READ_SIGNAL_STRENGTH:
-		return mt312_read_agc(i2c, arg);
-
-	case FE_READ_SNR:
-		return mt312_read_snr(i2c, arg);
-
-	case FE_READ_UNCORRECTED_BLOCKS:
-		return mt312_read_ubc(i2c, arg);
-
-	case FE_SET_FRONTEND:
-		return mt312_set_frontend(i2c, arg, (long) fe->data);
-
-	case FE_GET_FRONTEND:
-		return mt312_get_frontend(i2c, arg);
-
-	case FE_GET_EVENT:
-		return -EOPNOTSUPP;
-
-	case FE_SLEEP:
-		return mt312_sleep(i2c);
-
-	case FE_INIT:
-	//For the VP310 we should run at 60MHz when ever possible.
-	//It should be better to run the mt312 ar lower speed when ever possible, but tunning will be slower. ACCJr 09/29/03
-		if ((long)fe->data == ID_MT312)
-			return mt312_init(i2c, (long) fe->data, (u8) 90);
-		else
-			return mt312_init(i2c, (long) fe->data, (u8) 60);
-
-	case FE_GET_TUNE_SETTINGS:
+static int mt312_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
 	{
-	        struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
 	        fesettings->min_delay_ms = 50;
 	        fesettings->step_size = 0;
 	        fesettings->max_drift = 0;
 	        return 0;
 	}	    
 
-	default:
-		return -ENOIOCTLCMD;
-	}
-
-	return 0;
-}
-
-static int mt312_attach(struct dvb_i2c_bus *i2c, void **data)
+static void mt312_release(struct dvb_frontend* fe)
 {
-	int ret;
-	u8 id;
-
-	if ((ret = mt312_readreg(i2c, ID, &id)) < 0)
-		return ret;
-
-	if ((id != ID_VP310) && (id != ID_MT312))
-		return -ENODEV;
-
-	if ((ret = dvb_register_frontend(mt312_ioctl, i2c,
-				(void *)(long)id, &mt312_info)) < 0)
-		return ret;
-
-	mt312_count++;
-
-	return 0;
+	struct mt312_state* state = (struct mt312_state*) fe->demodulator_priv;
+	kfree(state);
 }
 
-static void mt312_detach(struct dvb_i2c_bus *i2c, void *data)
+static struct dvb_frontend_ops vp310_mt312_ops;
+
+struct dvb_frontend* vp310_attach(const struct mt312_config* config,
+				  struct i2c_adapter* i2c)
 {
-	dvb_unregister_frontend(mt312_ioctl, i2c);
+	struct mt312_state* state = NULL;
 
-	if (mt312_count)
-		mt312_count--;
-}
+	/* allocate memory for the internal state */
+	state = (struct mt312_state*) kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
+	if (state == NULL)
+		goto error;
 
-static int __init mt312_module_init(void)
-{
-	return dvb_register_i2c_device(THIS_MODULE, mt312_attach, mt312_detach);
-}
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
+	strcpy(state->ops.info.name, "Zarlink VP310 DVB-S");
 
-static void __exit mt312_module_exit(void)
-{
-	dvb_unregister_i2c_device(mt312_attach);
-}
+	/* check if the demod is there */
+	if (mt312_readreg(state, ID, &state->id) < 0)
+		goto error;
+	if (state->id != ID_VP310) {
+		goto error;
+	}
 
-module_init(mt312_module_init);
-module_exit(mt312_module_exit);
+	/* create dvb_frontend */
+		state->frequency = 90;
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state)
+		kfree(state);
+	return NULL;
+}
+
+struct dvb_frontend* mt312_attach(const struct mt312_config* config,
+				  struct i2c_adapter* i2c)
+{
+	struct mt312_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct mt312_state*) kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
+	if (state == NULL)
+		goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
+	strcpy(state->ops.info.name, "Zarlink MT312 DVB-S");
+
+	/* check if the demod is there */
+	if (mt312_readreg(state, ID, &state->id) < 0)
+		goto error;
+	if (state->id != ID_MT312) {
+		goto error;
+}
+
+	/* create dvb_frontend */
+	state->frequency = 60;
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state)
+		kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops vp310_mt312_ops = {
+
+	.info = {
+		.name = "Zarlink ???? DVB-S",
+		.type = FE_QPSK,
+		.frequency_min = 950000,
+		.frequency_max = 2150000,
+		.frequency_stepsize = (MT312_PLL_CLK / 1000) / 128,
+		.symbol_rate_min = MT312_SYS_CLK / 128,
+		.symbol_rate_max = MT312_SYS_CLK / 2,
+		.caps =
+		    FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
+		    FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
+		    FE_CAN_FEC_AUTO | FE_CAN_QPSK | FE_CAN_MUTE_TS |
+	            FE_CAN_RECOVER
+	},
+
+     	.release = mt312_release,
+
+	.init = mt312_initfe,
+	.sleep = mt312_sleep,
+
+	.set_frontend = mt312_set_frontend,
+	.get_frontend = mt312_get_frontend,
+	.get_tune_settings = mt312_get_tune_settings,
+
+	.read_status = mt312_read_status,
+	.read_ber = mt312_read_ber,
+	.read_signal_strength = mt312_read_signal_strength,
+	.read_snr = mt312_read_snr,
+	.read_ucblocks = mt312_read_ucblocks,
+
+	.diseqc_send_master_cmd = mt312_send_master_cmd,
+	.diseqc_send_burst = mt312_send_burst,
+	.set_tone = mt312_set_tone,
+	.set_voltage = mt312_set_voltage,
+};
 
-#if MT312_DEBUG != 0
-MODULE_PARM(debug,"i");
-MODULE_PARM_DESC(debug, "enable verbose debug messages");
-#endif
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
 
-MODULE_DESCRIPTION("MT312 Satellite Channel Decoder Driver");
+MODULE_DESCRIPTION("Zarlink VP310/MT312 DVB-S Demodulator driver");
 MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
 MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(mt312_attach);
+EXPORT_SYMBOL(vp310_attach);
diff -Nru a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
--- a/drivers/media/dvb/frontends/mt312.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/media/dvb/frontends/mt312.h	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,5 @@
 /* 
-    Driver for Zarlink MT312 QPSK Frontend
+    Driver for Zarlink MT312 Satellite Channel Decoder
 
     Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org>
 
@@ -18,145 +18,30 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+    References:
+    http://products.zarlink.com/product_profiles/MT312.htm
+    http://products.zarlink.com/product_profiles/SL1935.htm
 */
 
-#ifndef _DVB_FRONTENDS_MT312
-#define _DVB_FRONTENDS_MT312
+#ifndef MT312_H
+#define MT312_H
 
-enum mt312_reg_addr {
-	QPSK_INT_H = 0,
-	QPSK_INT_M = 1,
-	QPSK_INT_L = 2,
-	FEC_INT = 3,
-	QPSK_STAT_H = 4,
-	QPSK_STAT_L = 5,
-	FEC_STATUS = 6,
-	LNB_FREQ_H = 7,
-	LNB_FREQ_L = 8,
-	M_SNR_H = 9,
-	M_SNR_L = 10,
-	VIT_ERRCNT_H = 11,
-	VIT_ERRCNT_M = 12,
-	VIT_ERRCNT_L = 13,
-	RS_BERCNT_H = 14,
-	RS_BERCNT_M = 15,
-	RS_BERCNT_L = 16,
-	RS_UBC_H = 17,
-	RS_UBC_L = 18,
-	SIG_LEVEL = 19,
-	GPP_CTRL = 20,
-	RESET = 21,
-	DISEQC_MODE = 22,
-	SYM_RATE_H = 23,
-	SYM_RATE_L = 24,
-	VIT_MODE = 25,
-	QPSK_CTRL = 26,
-	GO = 27,
-	IE_QPSK_H = 28,
-	IE_QPSK_M = 29,
-	IE_QPSK_L = 30,
-	IE_FEC = 31,
-	QPSK_STAT_EN = 32,
-	FEC_STAT_EN = 33,
-	SYS_CLK = 34,
-	DISEQC_RATIO = 35,
-	DISEQC_INSTR = 36,
-	FR_LIM = 37,
-	FR_OFF = 38,
-	AGC_CTRL = 39,
-	AGC_INIT = 40,
-	AGC_REF = 41,
-	AGC_MAX = 42,
-	AGC_MIN = 43,
-	AGC_LK_TH = 44,
-	TS_AGC_LK_TH = 45,
-	AGC_PWR_SET = 46,
-	QPSK_MISC = 47,
-	SNR_THS_LOW = 48,
-	SNR_THS_HIGH = 49,
-	TS_SW_RATE = 50,
-	TS_SW_LIM_L = 51,
-	TS_SW_LIM_H = 52,
-	CS_SW_RATE_1 = 53,
-	CS_SW_RATE_2 = 54,
-	CS_SW_RATE_3 = 55,
-	CS_SW_RATE_4 = 56,
-	CS_SW_LIM = 57,
-	TS_LPK = 58,
-	TS_LPK_M = 59,
-	TS_LPK_L = 60,
-	CS_KPROP_H = 61,
-	CS_KPROP_L = 62,
-	CS_KINT_H = 63,
-	CS_KINT_L = 64,
-	QPSK_SCALE = 65,
-	TLD_OUTCLK_TH = 66,
-	TLD_INCLK_TH = 67,
-	FLD_TH = 68,
-	PLD_OUTLK3 = 69,
-	PLD_OUTLK2 = 70,
-	PLD_OUTLK1 = 71,
-	PLD_OUTLK0 = 72,
-	PLD_INLK3 = 73,
-	PLD_INLK2 = 74,
-	PLD_INLK1 = 75,
-	PLD_INLK0 = 76,
-	PLD_ACC_TIME = 77,
-	SWEEP_PAR = 78,
-	STARTUP_TIME = 79,
-	LOSSLOCK_TH = 80,
-	FEC_LOCK_TM = 81,
-	LOSSLOCK_TM = 82,
-	VIT_ERRPER_H = 83,
-	VIT_ERRPER_M = 84,
-	VIT_ERRPER_L = 85,
-	VIT_SETUP = 86,
-	VIT_REF0 = 87,
-	VIT_REF1 = 88,
-	VIT_REF2 = 89,
-	VIT_REF3 = 90,
-	VIT_REF4 = 91,
-	VIT_REF5 = 92,
-	VIT_REF6 = 93,
-	VIT_MAXERR = 94,
-	BA_SETUPT = 95,
-	OP_CTRL = 96,
-	FEC_SETUP = 97,
-	PROG_SYNC = 98,
-	AFC_SEAR_TH = 99,
-	CSACC_DIF_TH = 100,
-	QPSK_LK_CT = 101,
-	QPSK_ST_CT = 102,
-	MON_CTRL = 103,
-	QPSK_RESET = 104,
-	QPSK_TST_CT = 105,
-	QPSK_TST_ST = 106,
-	TEST_R = 107,
-	AGC_H = 108,
-	AGC_M = 109,
-	AGC_L = 110,
-	FREQ_ERR1_H = 111,
-	FREQ_ERR1_M = 112,
-	FREQ_ERR1_L = 113,
-	FREQ_ERR2_H = 114,
-	FREQ_ERR2_L = 115,
-	SYM_RAT_OP_H = 116,
-	SYM_RAT_OP_L = 117,
-	DESEQC2_INT = 118,
-	DISEQC2_STAT = 119,
-	DISEQC2_FIFO = 120,
-	DISEQC2_CTRL1 = 121,
-	DISEQC2_CTRL2 = 122,
-	MONITOR_H = 123,
-	MONITOR_L = 124,
-	TEST_MODE = 125,
-	ID = 126,
-	CONFIG = 127
-};
+#include <linux/dvb/frontend.h>
 
-enum mt312_model_id {
-	ID_VP310 = 1,
-	ID_MT312 = 3
+struct mt312_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
 };
 
-#endif				/* DVB_FRONTENDS_MT312 */
+extern struct dvb_frontend* mt312_attach(const struct mt312_config* config,
+					 struct i2c_adapter* i2c);
+
+extern struct dvb_frontend* vp310_attach(const struct mt312_config* config,
+					 struct i2c_adapter* i2c);
+
+#endif // MT312_H
diff -Nru a/drivers/media/dvb/frontends/mt312_priv.h b/drivers/media/dvb/frontends/mt312_priv.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/mt312_priv.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,162 @@
+/*
+    Driver for Zarlink MT312 QPSK Frontend
+
+    Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.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 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.
+
+*/
+
+#ifndef _DVB_FRONTENDS_MT312_PRIV
+#define _DVB_FRONTENDS_MT312_PRIV
+
+enum mt312_reg_addr {
+	QPSK_INT_H = 0,
+	QPSK_INT_M = 1,
+	QPSK_INT_L = 2,
+	FEC_INT = 3,
+	QPSK_STAT_H = 4,
+	QPSK_STAT_L = 5,
+	FEC_STATUS = 6,
+	LNB_FREQ_H = 7,
+	LNB_FREQ_L = 8,
+	M_SNR_H = 9,
+	M_SNR_L = 10,
+	VIT_ERRCNT_H = 11,
+	VIT_ERRCNT_M = 12,
+	VIT_ERRCNT_L = 13,
+	RS_BERCNT_H = 14,
+	RS_BERCNT_M = 15,
+	RS_BERCNT_L = 16,
+	RS_UBC_H = 17,
+	RS_UBC_L = 18,
+	SIG_LEVEL = 19,
+	GPP_CTRL = 20,
+	RESET = 21,
+	DISEQC_MODE = 22,
+	SYM_RATE_H = 23,
+	SYM_RATE_L = 24,
+	VIT_MODE = 25,
+	QPSK_CTRL = 26,
+	GO = 27,
+	IE_QPSK_H = 28,
+	IE_QPSK_M = 29,
+	IE_QPSK_L = 30,
+	IE_FEC = 31,
+	QPSK_STAT_EN = 32,
+	FEC_STAT_EN = 33,
+	SYS_CLK = 34,
+	DISEQC_RATIO = 35,
+	DISEQC_INSTR = 36,
+	FR_LIM = 37,
+	FR_OFF = 38,
+	AGC_CTRL = 39,
+	AGC_INIT = 40,
+	AGC_REF = 41,
+	AGC_MAX = 42,
+	AGC_MIN = 43,
+	AGC_LK_TH = 44,
+	TS_AGC_LK_TH = 45,
+	AGC_PWR_SET = 46,
+	QPSK_MISC = 47,
+	SNR_THS_LOW = 48,
+	SNR_THS_HIGH = 49,
+	TS_SW_RATE = 50,
+	TS_SW_LIM_L = 51,
+	TS_SW_LIM_H = 52,
+	CS_SW_RATE_1 = 53,
+	CS_SW_RATE_2 = 54,
+	CS_SW_RATE_3 = 55,
+	CS_SW_RATE_4 = 56,
+	CS_SW_LIM = 57,
+	TS_LPK = 58,
+	TS_LPK_M = 59,
+	TS_LPK_L = 60,
+	CS_KPROP_H = 61,
+	CS_KPROP_L = 62,
+	CS_KINT_H = 63,
+	CS_KINT_L = 64,
+	QPSK_SCALE = 65,
+	TLD_OUTCLK_TH = 66,
+	TLD_INCLK_TH = 67,
+	FLD_TH = 68,
+	PLD_OUTLK3 = 69,
+	PLD_OUTLK2 = 70,
+	PLD_OUTLK1 = 71,
+	PLD_OUTLK0 = 72,
+	PLD_INLK3 = 73,
+	PLD_INLK2 = 74,
+	PLD_INLK1 = 75,
+	PLD_INLK0 = 76,
+	PLD_ACC_TIME = 77,
+	SWEEP_PAR = 78,
+	STARTUP_TIME = 79,
+	LOSSLOCK_TH = 80,
+	FEC_LOCK_TM = 81,
+	LOSSLOCK_TM = 82,
+	VIT_ERRPER_H = 83,
+	VIT_ERRPER_M = 84,
+	VIT_ERRPER_L = 85,
+	VIT_SETUP = 86,
+	VIT_REF0 = 87,
+	VIT_REF1 = 88,
+	VIT_REF2 = 89,
+	VIT_REF3 = 90,
+	VIT_REF4 = 91,
+	VIT_REF5 = 92,
+	VIT_REF6 = 93,
+	VIT_MAXERR = 94,
+	BA_SETUPT = 95,
+	OP_CTRL = 96,
+	FEC_SETUP = 97,
+	PROG_SYNC = 98,
+	AFC_SEAR_TH = 99,
+	CSACC_DIF_TH = 100,
+	QPSK_LK_CT = 101,
+	QPSK_ST_CT = 102,
+	MON_CTRL = 103,
+	QPSK_RESET = 104,
+	QPSK_TST_CT = 105,
+	QPSK_TST_ST = 106,
+	TEST_R = 107,
+	AGC_H = 108,
+	AGC_M = 109,
+	AGC_L = 110,
+	FREQ_ERR1_H = 111,
+	FREQ_ERR1_M = 112,
+	FREQ_ERR1_L = 113,
+	FREQ_ERR2_H = 114,
+	FREQ_ERR2_L = 115,
+	SYM_RAT_OP_H = 116,
+	SYM_RAT_OP_L = 117,
+	DESEQC2_INT = 118,
+	DISEQC2_STAT = 119,
+	DISEQC2_FIFO = 120,
+	DISEQC2_CTRL1 = 121,
+	DISEQC2_CTRL2 = 122,
+	MONITOR_H = 123,
+	MONITOR_L = 124,
+	TEST_MODE = 125,
+	ID = 126,
+	CONFIG = 127
+};
+
+enum mt312_model_id {
+	ID_VP310 = 1,
+	ID_MT312 = 3
+};
+
+#endif				/* DVB_FRONTENDS_MT312_PRIV */
diff -Nru a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/mt352.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,558 @@
+/*
+ *  Driver for Zarlink DVB-T MT352 demodulator
+ *
+ *  Written by Holger Waechtler <holger@qanu.de>
+ *	 and Daniel Mack <daniel@qanu.de>
+ *
+ *  AVerMedia AVerTV DVB-T 771 support by
+ *       Wolfram Joost <dbox2@frokaschwei.de>
+ *
+ *  Support for Samsung TDTC9251DH01C(M) tuner
+ *  Copyright (C) 2004 Antonio Mancuso <antonio.mancuso@digitaltelevision.it>
+ *                     Amauri  Celani  <acelani@essegi.net>
+ *
+ *  DVICO FusionHDTV DVB-T1 and DVICO FusionHDTV DVB-T Lite support by
+ *       Christopher Pascoe <c.pascoe@itee.uq.edu.au>
+ *
+ *  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.=
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+
+#include "dvb_frontend.h"
+#include "mt352_priv.h"
+#include "mt352.h"
+
+struct mt352_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct mt352_config* config;
+
+	struct dvb_frontend frontend;
+};
+
+static int debug;
+#define dprintk(args...) \
+do {									\
+		if (debug) printk(KERN_DEBUG "mt352: " args); \
+} while (0)
+
+int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0,
+			       .buf = ibuf, .len = ilen };
+	int err = i2c_transfer(state->i2c, &msg, 1);
+	if (err != 1) {
+		dprintk("mt352_write() failed (err = %d)!\n", err);
+		return err;
+}
+
+	return 0;
+}
+
+static u8 mt352_read_register(struct mt352_state* state, u8 reg)
+{
+	int ret;
+	u8 b0 [] = { reg };
+	u8 b1 [] = { 0 };
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address,
+				    .flags = 0,
+				    .buf = b0, .len = 1 },
+				  { .addr = state->config->demod_address,
+				    .flags = I2C_M_RD,
+				    .buf = b1, .len = 1 } };
+
+	ret = i2c_transfer(state->i2c, msg, 2);
+
+	if (ret != 2)
+		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+
+	return b1[0];
+}
+
+
+
+
+
+
+
+
+
+
+
+
+static int mt352_sleep(struct dvb_frontend* fe)
+{
+	static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 };
+
+	mt352_write(fe, mt352_softdown, sizeof(mt352_softdown));
+
+	return 0;
+}
+
+static int mt352_set_parameters(struct dvb_frontend* fe,
+				struct dvb_frontend_parameters *param)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+	unsigned char buf[14];
+	unsigned int tps = 0;
+	struct dvb_ofdm_parameters *op = &param->u.ofdm;
+	int i;
+
+	switch (op->code_rate_HP) {
+		case FEC_2_3:
+			tps |= (1 << 7);
+			break;
+		case FEC_3_4:
+			tps |= (2 << 7);
+			break;
+		case FEC_5_6:
+			tps |= (3 << 7);
+			break;
+		case FEC_7_8:
+			tps |= (4 << 7);
+			break;
+		case FEC_1_2:
+		case FEC_AUTO:
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	switch (op->code_rate_LP) {
+		case FEC_2_3:
+			tps |= (1 << 4);
+			break;
+		case FEC_3_4:
+			tps |= (2 << 4);
+			break;
+		case FEC_5_6:
+			tps |= (3 << 4);
+			break;
+		case FEC_7_8:
+			tps |= (4 << 4);
+			break;
+		case FEC_1_2:
+		case FEC_AUTO:
+			break;
+		case FEC_NONE:
+			if (op->hierarchy_information == HIERARCHY_AUTO ||
+			    op->hierarchy_information == HIERARCHY_NONE)
+				break;
+		default:
+			return -EINVAL;
+	}
+
+	switch (op->constellation) {
+		case QPSK:
+			break;
+		case QAM_AUTO:
+		case QAM_16:
+			tps |= (1 << 13);
+			break;
+		case QAM_64:
+			tps |= (2 << 13);
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	switch (op->transmission_mode) {
+		case TRANSMISSION_MODE_2K:
+		case TRANSMISSION_MODE_AUTO:
+			break;
+		case TRANSMISSION_MODE_8K:
+			tps |= (1 << 0);
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	switch (op->guard_interval) {
+		case GUARD_INTERVAL_1_32:
+		case GUARD_INTERVAL_AUTO:
+			break;
+		case GUARD_INTERVAL_1_16:
+			tps |= (1 << 2);
+			break;
+		case GUARD_INTERVAL_1_8:
+			tps |= (2 << 2);
+			break;
+		case GUARD_INTERVAL_1_4:
+			tps |= (3 << 2);
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	switch (op->hierarchy_information) {
+		case HIERARCHY_AUTO:
+		case HIERARCHY_NONE:
+			break;
+		case HIERARCHY_1:
+			tps |= (1 << 10);
+			break;
+		case HIERARCHY_2:
+			tps |= (2 << 10);
+			break;
+		case HIERARCHY_4:
+			tps |= (3 << 10);
+			break;
+		default:
+			return -EINVAL;
+	}
+
+
+	buf[0] = TPS_GIVEN_1; /* TPS_GIVEN_1 and following registers */
+
+	buf[1] = msb(tps);      /* TPS_GIVEN_(1|0) */
+	buf[2] = lsb(tps);
+
+	buf[3] = 0x50;
+
+	/**
+	 *  these settings assume 20.48MHz f_ADC, for other tuners you might
+	 *  need other values. See p. 33 in the MT352 Design Manual.
+	 */
+	if (op->bandwidth == BANDWIDTH_8_MHZ) {
+		buf[4] = 0x72;  /* TRL_NOMINAL_RATE_(1|0) */
+		buf[5] = 0x49;
+	} else if (op->bandwidth == BANDWIDTH_7_MHZ) {
+		buf[4] = 0x64;
+		buf[5] = 0x00;
+	} else {		/* 6MHz */
+		buf[4] = 0x55;
+		buf[5] = 0xb7;
+	}
+
+	buf[6] = 0x31;  /* INPUT_FREQ_(1|0), 20.48MHz clock, 36.166667MHz IF */
+	buf[7] = 0x05;  /* see MT352 Design Manual page 32 for details */
+
+	state->config->pll_set(fe, param, buf+8);
+
+	buf[13] = 0x01; /* TUNER_GO!! */
+
+	/* Only send the tuning request if the tuner doesn't have the requested
+	 * parameters already set.  Enhances tuning time and prevents stream
+	 * breakup when retuning the same transponder. */
+	for (i = 1; i < 13; i++)
+		if (buf[i] != mt352_read_register(state, i + 0x50)) {
+			mt352_write(fe, buf, sizeof(buf));
+			break;
+		}
+
+	return 0;
+}
+
+static int mt352_get_parameters(struct dvb_frontend* fe,
+				struct dvb_frontend_parameters *param)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+	u16 tps;
+	u16 div;
+	u8 trl;
+	struct dvb_ofdm_parameters *op = &param->u.ofdm;
+	static const u8 tps_fec_to_api[8] =
+	{
+		FEC_1_2,
+		FEC_2_3,
+		FEC_3_4,
+		FEC_5_6,
+		FEC_7_8,
+		FEC_AUTO,
+		FEC_AUTO,
+		FEC_AUTO
+	};
+
+	if ( (mt352_read_register(state,0x00) & 0xC0) != 0xC0 )
+	{
+		return -EINVAL;
+	}
+
+	/* Use TPS_RECEIVED-registers, not the TPS_CURRENT-registers because
+	 * the mt352 sometimes works with the wrong parameters
+	 */
+	tps = (mt352_read_register(state, TPS_RECEIVED_1) << 8) | mt352_read_register(state, TPS_RECEIVED_0);
+	div = (mt352_read_register(state, CHAN_START_1) << 8) | mt352_read_register(state, CHAN_START_0);
+	trl = mt352_read_register(state, TRL_NOMINAL_RATE_1);
+
+	op->code_rate_HP = tps_fec_to_api[(tps >> 7) & 7];
+	op->code_rate_LP = tps_fec_to_api[(tps >> 4) & 7];
+
+	switch ( (tps >> 13) & 3)
+	{
+		case 0:
+			op->constellation = QPSK;
+			break;
+		case 1:
+			op->constellation = QAM_16;
+			break;
+		case 2:
+			op->constellation = QAM_64;
+			break;
+		default:
+			op->constellation = QAM_AUTO;
+			break;
+	}
+
+	op->transmission_mode = (tps & 0x01) ? TRANSMISSION_MODE_8K : TRANSMISSION_MODE_2K;
+
+	switch ( (tps >> 2) & 3)
+	{
+		case 0:
+			op->guard_interval = GUARD_INTERVAL_1_32;
+			break;
+		case 1:
+			op->guard_interval = GUARD_INTERVAL_1_16;
+			break;
+		case 2:
+			op->guard_interval = GUARD_INTERVAL_1_8;
+			break;
+		case 3:
+			op->guard_interval = GUARD_INTERVAL_1_4;
+			break;
+		default:
+			op->guard_interval = GUARD_INTERVAL_AUTO;
+			break;
+	}
+
+	switch ( (tps >> 10) & 7)
+	{
+		case 0:
+			op->hierarchy_information = HIERARCHY_NONE;
+			break;
+		case 1:
+			op->hierarchy_information = HIERARCHY_1;
+			break;
+		case 2:
+			op->hierarchy_information = HIERARCHY_2;
+			break;
+		case 3:
+			op->hierarchy_information = HIERARCHY_4;
+			break;
+		default:
+			op->hierarchy_information = HIERARCHY_AUTO;
+			break;
+	}
+
+	param->frequency = ( 500 * (div - IF_FREQUENCYx6) ) / 3 * 1000;
+
+	if (trl == 0x72)
+	{
+		op->bandwidth = BANDWIDTH_8_MHZ;
+	}
+	else if (trl == 0x64)
+	{
+		op->bandwidth = BANDWIDTH_7_MHZ;
+	}
+	else
+	{
+		op->bandwidth = BANDWIDTH_6_MHZ;
+	}
+
+
+	if (mt352_read_register(state, STATUS_2) & 0x02)
+		param->inversion = INVERSION_OFF;
+	else
+		param->inversion = INVERSION_ON;
+
+	return 0;
+}
+
+static int mt352_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+	u8 r;
+
+		*status = 0;
+	r = mt352_read_register (state, STATUS_0);
+		if (r & (1 << 4))
+			*status = FE_HAS_CARRIER;
+		if (r & (1 << 1))
+			*status |= FE_HAS_VITERBI;
+		if (r & (1 << 5))
+			*status |= FE_HAS_LOCK;
+
+	r = mt352_read_register (state, STATUS_1);
+		if (r & (1 << 1))
+			*status |= FE_HAS_SYNC;
+
+	r = mt352_read_register (state, STATUS_3);
+		if (r & (1 << 6))
+			*status |= FE_HAS_SIGNAL;
+
+	if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
+		      (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
+		*status &= ~FE_HAS_LOCK;
+
+	return 0;
+}
+
+static int mt352_read_ber(struct dvb_frontend* fe, u32* ber)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+
+	*ber = (mt352_read_register (state, RS_ERR_CNT_2) << 16) |
+	       (mt352_read_register (state, RS_ERR_CNT_1) << 8) |
+	       (mt352_read_register (state, RS_ERR_CNT_0));
+
+			return 0;
+	}
+
+static int mt352_read_signal_strength(struct dvb_frontend* fe, u16* strength)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+
+	u16 signal = (mt352_read_register (state, AGC_GAIN_3) << 8) |
+		     (mt352_read_register (state, AGC_GAIN_2));
+
+	*strength = ~signal;
+	return 0;
+}
+
+static int mt352_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+
+	u8 _snr = mt352_read_register (state, SNR);
+	*snr = (_snr << 8) | _snr;
+
+	return 0;
+}
+
+static int mt352_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+
+	*ucblocks = (mt352_read_register (state,  RS_UBC_1) << 8) |
+		    (mt352_read_register (state,  RS_UBC_0));
+
+	return 0;
+	}
+
+static int mt352_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fe_tune_settings)
+{
+	fe_tune_settings->min_delay_ms = 800;
+	fe_tune_settings->step_size = 0;
+	fe_tune_settings->max_drift = 0;
+
+	return 0;
+	}
+
+static int mt352_init(struct dvb_frontend* fe)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+
+	static u8 mt352_reset_attach [] = { RESET, 0xC0 };
+
+	if ((mt352_read_register(state, CLOCK_CTL) & 0x10) == 0 ||
+	    (mt352_read_register(state, CONFIG) & 0x20) == 0) {
+
+	/* Do a "hard" reset */
+		mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
+		return state->config->demod_init(fe);
+	}
+
+	return 0;
+	}
+
+static void mt352_release(struct dvb_frontend* fe)
+{
+	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
+		kfree(state);
+	}
+
+static struct dvb_frontend_ops mt352_ops;
+
+struct dvb_frontend* mt352_attach(const struct mt352_config* config,
+				  struct i2c_adapter* i2c)
+{
+	struct mt352_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct mt352_state*) kmalloc(sizeof(struct mt352_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &mt352_ops, sizeof(struct dvb_frontend_ops));
+
+	/* check if the demod is there */
+	if (mt352_read_register(state, CHIP_ID) != ID_MT352) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops mt352_ops = {
+
+	.info = {
+		.name			= "Zarlink MT352 DVB-T",
+		.type			= FE_OFDM,
+		.frequency_min		= 174000000,
+		.frequency_max		= 862000000,
+		.frequency_stepsize	= 166667,
+		.frequency_tolerance	= 0,
+		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
+			FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
+			FE_CAN_FEC_AUTO |
+			FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+			FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
+			FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER |
+			FE_CAN_MUTE_TS
+	},
+
+	.release = mt352_release,
+
+	.init = mt352_init,
+	.sleep = mt352_sleep,
+
+	.set_frontend = mt352_set_parameters,
+	.get_frontend = mt352_get_parameters,
+	.get_tune_settings = mt352_get_tune_settings,
+
+	.read_status = mt352_read_status,
+	.read_ber = mt352_read_ber,
+	.read_signal_strength = mt352_read_signal_strength,
+	.read_snr = mt352_read_snr,
+	.read_ucblocks = mt352_read_ucblocks,
+};
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
+
+MODULE_DESCRIPTION("Zarlink MT352 DVB-T Demodulator driver");
+MODULE_AUTHOR("Holger Waechtler, Daniel Mack, Antonio Mancuso");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(mt352_attach);
+EXPORT_SYMBOL(mt352_write);
diff -Nru a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/mt352.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,58 @@
+/*
+ *  Driver for Zarlink DVB-T MT352 demodulator
+ *
+ *  Written by Holger Waechtler <holger@qanu.de>
+ *	 and Daniel Mack <daniel@qanu.de>
+ *
+ *  AVerMedia AVerTV DVB-T 771 support by
+ *       Wolfram Joost <dbox2@frokaschwei.de>
+ *
+ *  Support for Samsung TDTC9251DH01C(M) tuner
+ *  Copyright (C) 2004 Antonio Mancuso <antonio.mancuso@digitaltelevision.it>
+ *                     Amauri  Celani  <acelani@essegi.net>
+ *
+ *  DVICO FusionHDTV DVB-T1 and DVICO FusionHDTV DVB-T Lite support by
+ *       Christopher Pascoe <c.pascoe@itee.uq.edu.au>
+ *
+ *  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.=
+ */
+
+#ifndef MT352_H
+#define MT352_H
+
+#include <linux/dvb/frontend.h>
+
+struct mt352_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* Initialise the demodulator and PLL. Cannot be NULL */
+	int (*demod_init)(struct dvb_frontend* fe);
+
+	/* PLL setup - fill out the supplied 5 byte buffer with your PLL settings.
+	 * byte0: Set to pll i2c address (nonlinux; left shifted by 1)
+	 * byte1-4: PLL configuration.
+	 */
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf);
+};
+
+extern struct dvb_frontend* mt352_attach(const struct mt352_config* config,
+					 struct i2c_adapter* i2c);
+
+extern int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen);
+
+#endif // MT352_H
diff -Nru a/drivers/media/dvb/frontends/mt352_priv.h b/drivers/media/dvb/frontends/mt352_priv.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/mt352_priv.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,127 @@
+/*
+ *  Driver for Zarlink DVB-T MT352 demodulator
+ *
+ *  Written by Holger Waechtler <holger@qanu.de>
+ *	 and Daniel Mack <daniel@qanu.de>
+ *
+ *  AVerMedia AVerTV DVB-T 771 support by
+ *       Wolfram Joost <dbox2@frokaschwei.de>
+ *
+ *  Support for Samsung TDTC9251DH01C(M) tuner
+ *  Copyright (C) 2004 Antonio Mancuso <antonio.mancuso@digitaltelevision.it>
+ *                     Amauri  Celani  <acelani@essegi.net>
+ *
+ *  DVICO FusionHDTV DVB-T1 and DVICO FusionHDTV DVB-T Lite support by
+ *       Christopher Pascoe <c.pascoe@itee.uq.edu.au>
+ *
+ *  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.=
+ */
+
+#ifndef _MT352_PRIV_
+#define _MT352_PRIV_
+
+#define ID_MT352        0x13
+
+#define msb(x) (((x) >> 8) & 0xff)
+#define lsb(x) ((x) & 0xff)
+
+enum mt352_reg_addr {
+	STATUS_0           = 0x00,
+	STATUS_1           = 0x01,
+	STATUS_2           = 0x02,
+	STATUS_3           = 0x03,
+	STATUS_4           = 0x04,
+	INTERRUPT_0        = 0x05,
+	INTERRUPT_1        = 0x06,
+	INTERRUPT_2        = 0x07,
+	INTERRUPT_3        = 0x08,
+	SNR                = 0x09,
+	VIT_ERR_CNT_2      = 0x0A,
+	VIT_ERR_CNT_1      = 0x0B,
+	VIT_ERR_CNT_0      = 0x0C,
+	RS_ERR_CNT_2       = 0x0D,
+	RS_ERR_CNT_1       = 0x0E,
+	RS_ERR_CNT_0       = 0x0F,
+	RS_UBC_1           = 0x10,
+	RS_UBC_0           = 0x11,
+	AGC_GAIN_3         = 0x12,
+	AGC_GAIN_2         = 0x13,
+	AGC_GAIN_1         = 0x14,
+	AGC_GAIN_0         = 0x15,
+	FREQ_OFFSET_2      = 0x17,
+	FREQ_OFFSET_1      = 0x18,
+	FREQ_OFFSET_0      = 0x19,
+	TIMING_OFFSET_1    = 0x1A,
+	TIMING_OFFSET_0    = 0x1B,
+	CHAN_FREQ_1        = 0x1C,
+	CHAN_FREQ_0        = 0x1D,
+	TPS_RECEIVED_1     = 0x1E,
+	TPS_RECEIVED_0     = 0x1F,
+	TPS_CURRENT_1      = 0x20,
+	TPS_CURRENT_0      = 0x21,
+	TPS_CELL_ID_1      = 0x22,
+	TPS_CELL_ID_0      = 0x23,
+	TPS_MISC_DATA_2    = 0x24,
+	TPS_MISC_DATA_1    = 0x25,
+	TPS_MISC_DATA_0    = 0x26,
+	RESET              = 0x50,
+	TPS_GIVEN_1        = 0x51,
+	TPS_GIVEN_0        = 0x52,
+	ACQ_CTL            = 0x53,
+	TRL_NOMINAL_RATE_1 = 0x54,
+	TRL_NOMINAL_RATE_0 = 0x55,
+	INPUT_FREQ_1       = 0x56,
+	INPUT_FREQ_0       = 0x57,
+	TUNER_ADDR         = 0x58,
+	CHAN_START_1       = 0x59,
+	CHAN_START_0       = 0x5A,
+	CONT_1             = 0x5B,
+	CONT_0             = 0x5C,
+	TUNER_GO           = 0x5D,
+	STATUS_EN_0        = 0x5F,
+	STATUS_EN_1        = 0x60,
+	INTERRUPT_EN_0     = 0x61,
+	INTERRUPT_EN_1     = 0x62,
+	INTERRUPT_EN_2     = 0x63,
+	INTERRUPT_EN_3     = 0x64,
+	AGC_TARGET         = 0x67,
+	AGC_CTL            = 0x68,
+	CAPT_RANGE         = 0x75,
+	SNR_SELECT_1       = 0x79,
+	SNR_SELECT_0       = 0x7A,
+	RS_ERR_PER_1       = 0x7C,
+	RS_ERR_PER_0       = 0x7D,
+	CHIP_ID            = 0x7F,
+	CHAN_STOP_1        = 0x80,
+	CHAN_STOP_0        = 0x81,
+	CHAN_STEP_1        = 0x82,
+	CHAN_STEP_0        = 0x83,
+	FEC_LOCK_TIME      = 0x85,
+	OFDM_LOCK_TIME     = 0x86,
+	ACQ_DELAY          = 0x87,
+	SCAN_CTL           = 0x88,
+	CLOCK_CTL          = 0x89,
+	CONFIG             = 0x8A,
+	MCLK_RATIO         = 0x8B,
+	GPP_CTL            = 0x8C,
+	ADC_CTL_1          = 0x8E,
+	ADC_CTL_0          = 0x8F
+};
+
+/* here we assume 1/6MHz == 166.66kHz stepsize */
+#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
+
+#endif                          /* _MT352_PRIV_ */
diff -Nru a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c
--- a/drivers/media/dvb/frontends/nxt6000.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/media/dvb/frontends/nxt6000.c	2004-12-24 13:37:03 -08:00
@@ -1,13 +1,6 @@
 /* 
-
 	NxtWave Communications - NXT6000 demodulator driver
 	
-	This driver currently supports:
-	
-	Alps TDME7 (Tuner: MITEL SP5659)
-	Alps TDED4 (Tuner: TI ALP510, external Nxt6000)
-	Comtech DVBT-6k07 (PLL IC: SP5730)
-
     Copyright (C) 2002-2003 Florian Schirmer <jolt@tuxbox.org>
     Copyright (C) 2003 Paul Andreassen <paul@andreassen.com.au>
 
@@ -34,241 +27,69 @@
 #include <linux/slab.h>
 
 #include "dvb_frontend.h"
+#include "nxt6000_priv.h"
 #include "nxt6000.h"
 
-static int debug = 0;
 
-MODULE_DESCRIPTION("NxtWave NXT6000 DVB demodulator driver");
-MODULE_AUTHOR("Florian Schirmer");
-MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
 
-static struct dvb_frontend_info nxt6000_info = {
+struct nxt6000_state {
 
-	.name = "NxtWave NXT6000",
-	.type = FE_OFDM,
-	.frequency_min = 0,
-	.frequency_max = 863250000,
-	.frequency_stepsize = 62500,
-	/*.frequency_tolerance = */	/* FIXME: 12% of SR */
-	.symbol_rate_min = 0,		/* FIXME */
-	.symbol_rate_max = 9360000,	/* FIXME */
-	.symbol_rate_tolerance = 4000,
-	.notifier_delay = 0,
-	.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 
-                FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | 
-                FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | 
-                FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | 
-                FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | 
-                FE_CAN_HIERARCHY_AUTO,
-};
+	struct i2c_adapter *i2c;
 
-struct nxt6000_config {
-	u8 demod_addr;
-	u8 tuner_addr;
-	u8 tuner_type;
-	u8 clock_inversion;
-};
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct nxt6000_config* config;
 
-#define TUNER_TYPE_ALP510	0
-#define TUNER_TYPE_SP5659	1
-#define TUNER_TYPE_SP5730	2
+	struct dvb_frontend frontend;
 
-#define FE2NXT(fe) ((struct nxt6000_config *)((fe)->data))
-#define FREQ2DIV(freq) ((freq + 36166667) / 166667)
+};
 
+static int debug = 0;
 #define dprintk if (debug) printk
 
-static int nxt6000_write(struct dvb_i2c_bus *i2c, u8 addr, u8 reg, u8 data)
+static int nxt6000_writereg(struct nxt6000_state* state, u8 reg, u8 data)
 {
-
 	u8 buf[] = {reg, data};
-	struct i2c_msg msg = {.addr = addr >> 1, .flags = 0, .buf = buf, .len = 2};
+	struct i2c_msg msg = {.addr = state->config->demod_address,.flags = 0,.buf = buf,.len = 2 };
 	int ret;
 	
-	if ((ret = i2c->xfer(i2c, &msg, 1)) != 1)
-		dprintk("nxt6000: nxt6000_write error (.addr = 0x%02X, reg: 0x%02X, data: 0x%02X, ret: %d)\n", addr, reg, data, ret);
+	if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1)
+		dprintk("nxt6000: nxt6000_write error (reg: 0x%02X, data: 0x%02X, ret: %d)\n", reg, data, ret);
 
 	return (ret != 1) ? -EFAULT : 0;
-	
 }
 
-static u8 nxt6000_writereg(struct dvb_frontend *fe, u8 reg, u8 data)
+static u8 nxt6000_readreg(struct nxt6000_state* state, u8 reg)
 {
-
-	struct nxt6000_config *nxt = FE2NXT(fe);
-
-	return nxt6000_write(fe->i2c, nxt->demod_addr, reg, data);
-
-}
-
-static u8 nxt6000_read(struct dvb_i2c_bus *i2c, u8 addr, u8 reg)
-{
-
 	int ret;
 	u8 b0[] = {reg};
 	u8 b1[] = {0};
 	struct i2c_msg msgs[] = {
-		{.addr = addr >> 1,.flags = 0,.buf = b0,.len = 1},
-		{.addr = addr >> 1,.flags = I2C_M_RD,.buf = b1,.len = 1}
+		{.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = 1},
+		{.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1}
 	};
 
-	ret = i2c->xfer(i2c, msgs, 2);
+	ret = i2c_transfer(state->i2c, msgs, 2);
 	
 	if (ret != 2)
-		dprintk("nxt6000: nxt6000_read error (.addr = 0x%02X, reg: 0x%02X, ret: %d)\n", addr, reg, ret);
+		dprintk("nxt6000: nxt6000_read error (reg: 0x%02X, ret: %d)\n", reg, ret);
 	
 	return b1[0];
-
-}
-
-static u8 nxt6000_readreg(struct dvb_frontend *fe, u8 reg)
-{
-
-	struct nxt6000_config *nxt = FE2NXT(fe);
-
-	return nxt6000_read(fe->i2c, nxt->demod_addr, reg);
-}
-
-static int pll_test(struct dvb_i2c_bus *i2c, u8 demod_addr, u8 tuner_addr)
-{
-	u8 buf [1];
-	struct i2c_msg msg = {.addr = tuner_addr >> 1,.flags = I2C_M_RD,.buf = buf,.len = 1 };
-	int ret;
-
-	nxt6000_write(i2c, demod_addr, ENABLE_TUNER_IIC, 0x01);	/* open i2c bus switch */
-	ret = i2c->xfer(i2c, &msg, 1);
-	nxt6000_write(i2c, demod_addr, ENABLE_TUNER_IIC, 0x00);	/* close i2c bus switch */
-
-	return (ret != 1) ? -EFAULT : 0;
-}
-
-static int pll_write(struct dvb_i2c_bus *i2c, u8 demod_addr, u8 tuner_addr, u8 *buf, u8 len)
-{
-
-	struct i2c_msg msg = {.addr = tuner_addr >> 1, .flags = 0, .buf = buf, .len = len};
-	int ret;
-				
-	nxt6000_write(i2c, demod_addr, ENABLE_TUNER_IIC, 0x01);		/* open i2c bus switch */
-	ret = i2c->xfer(i2c, &msg, 1);
-	nxt6000_write(i2c, demod_addr, ENABLE_TUNER_IIC, 0x00);		/* close i2c bus switch */
-										
-	if (ret != 1)
-		dprintk("nxt6000: pll_write error %d\n", ret);
-																
-	return (ret != 1) ? -EFAULT : 0;
-
-}
-
-static int sp5659_set_tv_freq(struct dvb_frontend *fe, u32 freq)
-{
-
-	u8 buf[4];
-	struct nxt6000_config *nxt = FE2NXT(fe);
-
-	buf[0] = (FREQ2DIV(freq) >> 8) & 0x7F;
-	buf[1] = FREQ2DIV(freq) & 0xFF;
-	buf[2] = (((FREQ2DIV(freq) >> 15) & 0x03) << 5) | 0x85;
-
-	if ((freq >= 174000000) && (freq < 230000000))
-		buf[3] = 0x82;
-	else if ((freq >= 470000000) && (freq < 782000000))
-		buf[3] = 0x85;
-	else if ((freq >= 782000000) && (freq < 863000000))
-		buf[3] = 0xC5;
-	else
-		return -EINVAL;
-
-	return pll_write(fe->i2c, nxt->demod_addr, nxt->tuner_addr, buf, 4);
-	
-}
-
-static int alp510_set_tv_freq(struct dvb_frontend *fe, u32 freq)
-{
-
-	u8 buf[4];
-	struct nxt6000_config *nxt = FE2NXT(fe);
-
-	buf[0] = (FREQ2DIV(freq) >> 8) & 0x7F;
-	buf[1] = FREQ2DIV(freq) & 0xFF;
-	buf[2] = 0x85;
-
-#if 0
-	if ((freq >= 47000000) && (freq < 153000000))
-		buf[3] = 0x01;
-	else if ((freq >= 153000000) && (freq < 430000000))
-		buf[3] = 0x02;
-	else if ((freq >= 430000000) && (freq < 824000000))
-		buf[3] = 0x08;
-	else if ((freq >= 824000000) && (freq < 863000000))
-		buf[3] = 0x88;
-	else
-		return -EINVAL;
-#else
-	if ((freq >= 47000000) && (freq < 153000000))
-		buf[3] = 0x01;
-	else if ((freq >= 153000000) && (freq < 430000000))
-		buf[3] = 0x02;
-	else if ((freq >= 430000000) && (freq < 824000000))
-		buf[3] = 0x0C;
-	else if ((freq >= 824000000) && (freq < 863000000))
-		buf[3] = 0x8C;
-	else
-		return -EINVAL;
-#endif
-
-	return pll_write(fe->i2c, nxt->demod_addr, nxt->tuner_addr, buf, 4);
-	
 }
 
-static int sp5730_set_tv_freq(struct dvb_frontend *fe, u32 freq)
+static void nxt6000_reset(struct nxt6000_state* state)
 {
-
-	u8 buf[4];
-	struct nxt6000_config *nxt = FE2NXT(fe);
-
-	buf[0] = (FREQ2DIV(freq) >> 8) & 0x7F;
-	buf[1] = FREQ2DIV(freq) & 0xFF;
-	buf[2] = 0x93;
-
-	if ((freq >= 51000000) && (freq < 132100000))
-		buf[3] = 0x05;
-	else if ((freq >= 132100000) && (freq < 143000000))
-		buf[3] = 0x45;
-	else if ((freq >= 146000000) && (freq < 349100000))
-		buf[3] = 0x06;
-	else if ((freq >= 349100000) && (freq < 397100000))
-		buf[3] = 0x46;
-	else if ((freq >= 397100000) && (freq < 426000000))
-		buf[3] = 0x86;
-	else if ((freq >= 430000000) && (freq < 659100000))
-		buf[3] = 0x03;
-	else if ((freq >= 659100000) && (freq < 759100000))
-		buf[3] = 0x43;
-	else if ((freq >= 759100000) && (freq < 858000000))
-		buf[3] = 0x83;
-	else
-		return -EINVAL;
-
-	return pll_write(fe->i2c, nxt->demod_addr, nxt->tuner_addr, buf, 4);
-	
-}
-
-static void nxt6000_reset(struct dvb_frontend *fe)
-{
-
 	u8 val;
 
-	val = nxt6000_readreg(fe, OFDM_COR_CTL);
-	
-	nxt6000_writereg(fe, OFDM_COR_CTL, val & ~COREACT);
-	nxt6000_writereg(fe, OFDM_COR_CTL, val | COREACT);
+	val = nxt6000_readreg(state, OFDM_COR_CTL);
 	
+	nxt6000_writereg(state, OFDM_COR_CTL, val & ~COREACT);
+	nxt6000_writereg(state, OFDM_COR_CTL, val | COREACT);
 }
 
-static int nxt6000_set_bandwidth(struct dvb_frontend *fe, fe_bandwidth_t bandwidth)
+static int nxt6000_set_bandwidth(struct nxt6000_state* state, fe_bandwidth_t bandwidth)
 {
-
 	u16 nominal_rate;
 	int result;
 
@@ -293,132 +114,115 @@
 			break;
 
 		default:
-			
 			return -EINVAL;
-			
 	}
 
-	if ((result = nxt6000_writereg(fe, OFDM_TRL_NOMINALRATE_1, nominal_rate & 0xFF)) < 0)
+	if ((result = nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_1, nominal_rate & 0xFF)) < 0)
 		return result;
 		
-	return nxt6000_writereg(fe, OFDM_TRL_NOMINALRATE_2, (nominal_rate >> 8) & 0xFF);
-		
+	return nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_2, (nominal_rate >> 8) & 0xFF);
 }
 
-static int nxt6000_set_guard_interval(struct dvb_frontend *fe, fe_guard_interval_t guard_interval)
+static int nxt6000_set_guard_interval(struct nxt6000_state* state, fe_guard_interval_t guard_interval)
 {
-
 	switch(guard_interval) {
 	
 		case GUARD_INTERVAL_1_32:
-
-			return nxt6000_writereg(fe, OFDM_COR_MODEGUARD, 0x00 | (nxt6000_readreg(fe, OFDM_COR_MODEGUARD) & ~0x03));
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x00 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
 
 		case GUARD_INTERVAL_1_16:
-
-			return nxt6000_writereg(fe, OFDM_COR_MODEGUARD, 0x01 | (nxt6000_readreg(fe, OFDM_COR_MODEGUARD) & ~0x03));
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x01 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
 
 		case GUARD_INTERVAL_AUTO:
 		case GUARD_INTERVAL_1_8:
-
-			return nxt6000_writereg(fe, OFDM_COR_MODEGUARD, 0x02 | (nxt6000_readreg(fe, OFDM_COR_MODEGUARD) & ~0x03));
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x02 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
 
 		case GUARD_INTERVAL_1_4:
-
-			return nxt6000_writereg(fe, OFDM_COR_MODEGUARD, 0x03 | (nxt6000_readreg(fe, OFDM_COR_MODEGUARD) & ~0x03));
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x03 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
 			
 		default:
-		
 			return -EINVAL;
-
 	}
-
 }
 
-static int nxt6000_set_inversion(struct dvb_frontend *fe, fe_spectral_inversion_t inversion)
+static int nxt6000_set_inversion(struct nxt6000_state* state, fe_spectral_inversion_t inversion)
 {
-
 	switch(inversion) {
 	
 		case INVERSION_OFF:
-		
-			return nxt6000_writereg(fe, OFDM_ITB_CTL, 0x00);
+		return nxt6000_writereg(state, OFDM_ITB_CTL, 0x00);
 			
 		case INVERSION_ON:
-		
-			return nxt6000_writereg(fe, OFDM_ITB_CTL, ITBINV);
+		return nxt6000_writereg(state, OFDM_ITB_CTL, ITBINV);
 
 		default:
-		
 			return -EINVAL;	
 	
 	}
-
 }
 
-static int nxt6000_set_transmission_mode(struct dvb_frontend *fe, fe_transmit_mode_t transmission_mode)
+static int nxt6000_set_transmission_mode(struct nxt6000_state* state, fe_transmit_mode_t transmission_mode)
 {
-
 	int result;
 
 	switch(transmission_mode) {
 
 		case TRANSMISSION_MODE_2K:	
-
-			if ((result = nxt6000_writereg(fe, EN_DMD_RACQ, 0x00 | (nxt6000_readreg(fe, EN_DMD_RACQ) & ~0x03))) < 0)
+		if ((result = nxt6000_writereg(state, EN_DMD_RACQ, 0x00 | (nxt6000_readreg(state, EN_DMD_RACQ) & ~0x03))) < 0)
 				return result;
 				
-			return nxt6000_writereg(fe, OFDM_COR_MODEGUARD, (0x00 << 2) | (nxt6000_readreg(fe, OFDM_COR_MODEGUARD) & ~0x04));
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, (0x00 << 2) | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x04));
 
 		case TRANSMISSION_MODE_8K:	
 		case TRANSMISSION_MODE_AUTO:	
-
-			if ((result = nxt6000_writereg(fe, EN_DMD_RACQ, 0x02 | (nxt6000_readreg(fe, EN_DMD_RACQ) & ~0x03))) < 0)
+		if ((result = nxt6000_writereg(state, EN_DMD_RACQ, 0x02 | (nxt6000_readreg(state, EN_DMD_RACQ) & ~0x03))) < 0)
 				return result;
 
-			return nxt6000_writereg(fe, OFDM_COR_MODEGUARD, (0x01 << 2) | (nxt6000_readreg(fe, OFDM_COR_MODEGUARD) & ~0x04));
+		return nxt6000_writereg(state, OFDM_COR_MODEGUARD, (0x01 << 2) | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x04));
 
 		default:
-			
 			return -EINVAL;
 	
 	}
-
 }
 
-static void nxt6000_setup(struct dvb_frontend *fe)
+static void nxt6000_setup(struct dvb_frontend* fe)
 {
-
-	struct nxt6000_config *nxt = FE2NXT(fe);
-
-	nxt6000_writereg(fe, RS_COR_SYNC_PARAM, SYNC_PARAM);
-	nxt6000_writereg(fe, BER_CTRL, /*(1 << 2) |*/ (0x01 << 1) | 0x01);
-	nxt6000_writereg(fe, VIT_COR_CTL, VIT_COR_RESYNC);
-	nxt6000_writereg(fe, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(fe, OFDM_COR_CTL) & 0x0F));
-	nxt6000_writereg(fe, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02);
-	nxt6000_writereg(fe, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW);
-	nxt6000_writereg(fe, OFDM_ITB_FREQ_1, 0x06);
-	nxt6000_writereg(fe, OFDM_ITB_FREQ_2, 0x31);
-	nxt6000_writereg(fe, OFDM_CAS_CTL, (0x01 << 7) | (0x02 << 3) | 0x04);
-	nxt6000_writereg(fe, CAS_FREQ, 0xBB);	/* CHECKME */
-	nxt6000_writereg(fe, OFDM_SYR_CTL, 1 << 2);
-	nxt6000_writereg(fe, OFDM_PPM_CTL_1, PPM256);
-	nxt6000_writereg(fe, OFDM_TRL_NOMINALRATE_1, 0x49);
-	nxt6000_writereg(fe, OFDM_TRL_NOMINALRATE_2, 0x72);
-	nxt6000_writereg(fe, ANALOG_CONTROL_0, 1 << 5);
-	nxt6000_writereg(fe, EN_DMD_RACQ, (1 << 7) | (3 << 4) | 2);
-	nxt6000_writereg(fe, DIAG_CONFIG, TB_SET);
+	struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
 	
-	if (nxt->clock_inversion)
-		nxt6000_writereg(fe, SUB_DIAG_MODE_SEL, CLKINVERSION);
+	nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM);
+	nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01);
+	nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC);
+	nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F));
+	nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02);
+	nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW);
+	nxt6000_writereg(state, OFDM_ITB_FREQ_1, 0x06);
+	nxt6000_writereg(state, OFDM_ITB_FREQ_2, 0x31);
+	nxt6000_writereg(state, OFDM_CAS_CTL, (0x01 << 7) | (0x02 << 3) | 0x04);
+	nxt6000_writereg(state, CAS_FREQ, 0xBB);	/* CHECKME */
+	nxt6000_writereg(state, OFDM_SYR_CTL, 1 << 2);
+	nxt6000_writereg(state, OFDM_PPM_CTL_1, PPM256);
+	nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_1, 0x49);
+	nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_2, 0x72);
+	nxt6000_writereg(state, ANALOG_CONTROL_0, 1 << 5);
+	nxt6000_writereg(state, EN_DMD_RACQ, (1 << 7) | (3 << 4) | 2);
+	nxt6000_writereg(state, DIAG_CONFIG, TB_SET);
+
+	if (state->config->clock_inversion)
+		nxt6000_writereg(state, SUB_DIAG_MODE_SEL, CLKINVERSION);
 	else
-		nxt6000_writereg(fe, SUB_DIAG_MODE_SEL, 0);
-		
-	nxt6000_writereg(fe, TS_FORMAT, 0);
+		nxt6000_writereg(state, SUB_DIAG_MODE_SEL, 0);
 
+	nxt6000_writereg(state, TS_FORMAT, 0);
+		
+	if (state->config->pll_init) {
+		nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01);	/* open i2c bus switch */
+		state->config->pll_init(fe);
+		nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x00);	/* close i2c bus switch */
+	}
 }
 
-static void nxt6000_dump_status(struct dvb_frontend *fe)
+static void nxt6000_dump_status(struct nxt6000_state *state)
 {
 	u8 val;
 
@@ -436,12 +240,12 @@
 */
 	printk("NXT6000 status:");
 
-	val = nxt6000_readreg(fe, RS_COR_STAT);
+	val = nxt6000_readreg(state, RS_COR_STAT);
 	
 	printk(" DATA DESCR LOCK: %d,", val & 0x01);
 	printk(" DATA SYNC LOCK: %d,", (val >> 1) & 0x01);
 
-	val = nxt6000_readreg(fe, VIT_SYNC_STATUS);
+	val = nxt6000_readreg(state, VIT_SYNC_STATUS);
 
 	printk(" VITERBI LOCK: %d,", (val >> 7) & 0x01);
 
@@ -479,7 +283,7 @@
 			
 	}
 
-	val = nxt6000_readreg(fe, OFDM_COR_STAT);
+	val = nxt6000_readreg(state, OFDM_COR_STAT);
 	
 	printk(" CHCTrack: %d,", (val >> 7) & 0x01);
 	printk(" TPSLock: %d,", (val >> 6) & 0x01);
@@ -532,7 +336,7 @@
 			
 	}
 
-	val = nxt6000_readreg(fe, OFDM_SYR_STAT);
+	val = nxt6000_readreg(state, OFDM_SYR_STAT);
 
 	printk(" SYRLock: %d,", (val >> 4) & 0x01);
 	printk(" SYRMode: %s,", (val >> 2) & 0x01 ? "8K" : "2K");
@@ -558,14 +362,11 @@
 			break;
 	
 		case 0x03: 
-		
 			printk(" SYRGuard: 1/4,");
-			
 			break;
-			
 	}
 
-	val = nxt6000_readreg(fe, OFDM_TPS_RCVD_3);
+	val = nxt6000_readreg(state, OFDM_TPS_RCVD_3);
 	
 	switch((val >> 4) & 0x07) {
 	
@@ -635,7 +436,7 @@
 			
 	}
 
-	val = nxt6000_readreg(fe, OFDM_TPS_RCVD_4);
+	val = nxt6000_readreg(state, OFDM_TPS_RCVD_4);
 	
 	printk(" TPSMode: %s,", val & 0x01 ? "8K" : "2K");
 	
@@ -668,253 +469,156 @@
 	}
 	
 	/* Strange magic required to gain access to RF_AGC_STATUS */
-	nxt6000_readreg(fe, RF_AGC_VAL_1);
-	val = nxt6000_readreg(fe, RF_AGC_STATUS);
-	val = nxt6000_readreg(fe, RF_AGC_STATUS);
+	nxt6000_readreg(state, RF_AGC_VAL_1);
+	val = nxt6000_readreg(state, RF_AGC_STATUS);
+	val = nxt6000_readreg(state, RF_AGC_STATUS);
 
 	printk(" RF AGC LOCK: %d,", (val >> 4) & 0x01);
-
 	printk("\n");
-	
 }
 
-static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
 
-	switch (cmd) {
 
-		case FE_GET_INFO:
 
-			memcpy(arg, &nxt6000_info, sizeof (struct dvb_frontend_info));
 
-			return 0;
 
-		case FE_READ_STATUS:
-		{
-			fe_status_t *status = (fe_status_t *)arg;
 
+
+
+
+
+static int nxt6000_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
 			u8 core_status;
+	struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
 
 			*status = 0;
 			
-			core_status = nxt6000_readreg(fe, OFDM_COR_STAT);
+	core_status = nxt6000_readreg(state, OFDM_COR_STAT);
 
 			if (core_status & AGCLOCKED)
 				*status |= FE_HAS_SIGNAL;
 
-			if (nxt6000_readreg(fe, OFDM_SYR_STAT) & GI14_SYR_LOCK)
+	if (nxt6000_readreg(state, OFDM_SYR_STAT) & GI14_SYR_LOCK)
 				*status |= FE_HAS_CARRIER;
 
-			if (nxt6000_readreg(fe, VIT_SYNC_STATUS) & VITINSYNC)
+	if (nxt6000_readreg(state, VIT_SYNC_STATUS) & VITINSYNC)
 				*status |= FE_HAS_VITERBI;
 
-			if (nxt6000_readreg(fe, RS_COR_STAT) & RSCORESTATUS)
+	if (nxt6000_readreg(state, RS_COR_STAT) & RSCORESTATUS)
 				*status |= FE_HAS_SYNC;
 				
 			if ((core_status & TPSLOCKED) && (*status == (FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)))
 				*status |= FE_HAS_LOCK;
 				
 			if (debug)
-				nxt6000_dump_status(fe);
+		nxt6000_dump_status(state);
 
 			return 0;
-			
 		}
 	
-		case FE_READ_BER:
+static int nxt6000_init(struct dvb_frontend* fe)
 		{
-			u32 *ber = (u32 *)arg;
+	struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
 
-			*ber=0;
-
-			return 0;
-			
-		}
+	nxt6000_reset(state);
+	nxt6000_setup(fe);
 	
-		case FE_READ_SIGNAL_STRENGTH:
-		{
-			s16 *signal = (s16 *) arg;
-/*
-			*signal=(((signed char)readreg(client, 0x16))+128)<<8;
-*/
-			*signal = 0;
 			return 0;
-			
-		}
-	
-		case FE_READ_SNR:
-		{
-			s16 *snr = (s16 *) arg;
-/*
-			*snr=readreg(client, 0x24)<<8;
-			*snr|=readreg(client, 0x25);
-*/
-			*snr = 0;
-			break;
 		}
 	
-		case FE_READ_UNCORRECTED_BLOCKS: 
-		{
-			u32 *ublocks = (u32 *)arg;
-
-			*ublocks = 0;
 
-			break;
-		}
-	
-		case FE_INIT:
-			nxt6000_reset(fe);
-			nxt6000_setup(fe);
-		break;
-
-		case FE_SET_FRONTEND:
+static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *param)
 		{
-			struct nxt6000_config *nxt = FE2NXT(fe);
-			struct dvb_frontend_parameters *param = (struct dvb_frontend_parameters *)arg;
+	struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
 			int result;
 
-			switch(nxt->tuner_type) {
-			
-				case TUNER_TYPE_ALP510:
+	nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01);	/* open i2c bus switch */
+	state->config->pll_set(fe, param);
+	nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x00);	/* close i2c bus switch */
 
-					if ((result = alp510_set_tv_freq(fe, param->frequency)) < 0)
+	if ((result = nxt6000_set_bandwidth(state, param->u.ofdm.bandwidth)) < 0)
 						return result;
-						
-					break;
-
-				case TUNER_TYPE_SP5659:
-
-					if ((result = sp5659_set_tv_freq(fe, param->frequency)) < 0)
-						return result;
-						
-					break;
-					
-				case TUNER_TYPE_SP5730:
-
-					if ((result = sp5730_set_tv_freq(fe, param->frequency)) < 0)
-						return result;
-
-					break;
-
-				default:
-				
-					return -EFAULT;
-					
-			}
-
-			if ((result = nxt6000_set_bandwidth(fe, param->u.ofdm.bandwidth)) < 0)
+	if ((result = nxt6000_set_guard_interval(state, param->u.ofdm.guard_interval)) < 0)
 				return result;
-			if ((result = nxt6000_set_guard_interval(fe, param->u.ofdm.guard_interval)) < 0)
+	if ((result = nxt6000_set_transmission_mode(state, param->u.ofdm.transmission_mode)) < 0)
 				return result;
-			if ((result = nxt6000_set_transmission_mode(fe, param->u.ofdm.transmission_mode)) < 0)
+	if ((result = nxt6000_set_inversion(state, param->inversion)) < 0)
 				return result;
-			if ((result = nxt6000_set_inversion(fe, param->inversion)) < 0)
-				return result;
-			
-			break;
-		}
-
-		default:
-
-			return -EOPNOTSUPP;
-
-	}
 
 	return 0;
-	
 } 
 
-static u8 demod_addr_tbl[] = {0x14, 0x18, 0x24, 0x28};
 
-static int nxt6000_attach(struct dvb_i2c_bus *i2c, void **data)
+static void nxt6000_release(struct dvb_frontend* fe)
 {
-	u8 addr_nr;
-	u8 fe_count = 0;
-	struct nxt6000_config *pnxt;
-
-	dprintk("nxt6000: attach\n");
-	
-	pnxt = kmalloc(sizeof(demod_addr_tbl)*sizeof(struct nxt6000_config), GFP_KERNEL);
-	if (NULL == pnxt) {
-		dprintk("nxt6000: no memory for private data.\n");
-		return -ENOMEM;
+	struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
+	kfree(state);
 	}
-	*data = pnxt;
-
-	for (addr_nr = 0; addr_nr < sizeof(demod_addr_tbl); addr_nr++) {
-		struct nxt6000_config *nxt = &pnxt[addr_nr];
 	
-		if (nxt6000_read(i2c, demod_addr_tbl[addr_nr], OFDM_MSC_REV) != NXT6000ASICDEVICE)
-			continue;
-
-		if (pll_test(i2c, demod_addr_tbl[addr_nr], 0xC0) == 0) {
-			nxt->tuner_addr = 0xC0;
-			nxt->tuner_type = TUNER_TYPE_ALP510;
-			nxt->clock_inversion = 1;
+static struct dvb_frontend_ops nxt6000_ops;
 	
-			dprintk("nxt6000: detected TI ALP510 tuner at 0x%02X\n", nxt->tuner_addr);
-		
-		} else if (pll_test(i2c, demod_addr_tbl[addr_nr], 0xC2) == 0) {
-			nxt->tuner_addr = 0xC2;
-			nxt->tuner_type = TUNER_TYPE_SP5659;
-			nxt->clock_inversion = 0;
+struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
+				    struct i2c_adapter* i2c)
+{
+	struct nxt6000_state* state = NULL;
 
-			dprintk("nxt6000: detected MITEL SP5659 tuner at 0x%02X\n", nxt->tuner_addr);
-		
-		} else if (pll_test(i2c, demod_addr_tbl[addr_nr], 0xC0) == 0) {
-			nxt->tuner_addr = 0xC0;
-			nxt->tuner_type = TUNER_TYPE_SP5730;
-			nxt->clock_inversion = 0;
+	/* allocate memory for the internal state */
+	state = (struct nxt6000_state*) kmalloc(sizeof(struct nxt6000_state), GFP_KERNEL);
+	if (state == NULL) goto error;
 
-			dprintk("nxt6000: detected SP5730 tuner at 0x%02X\n", nxt->tuner_addr);
-		
-		} else {
-			printk("nxt6000: unable to detect tuner\n");
-			continue;	
-		}
-		
-		nxt->demod_addr = demod_addr_tbl[addr_nr];
-	  
-		dprintk("nxt6000: attached at %d:%d\n", i2c->adapter->num, i2c->id);
-	
-		dvb_register_frontend(nxt6000_ioctl, i2c, (void *)nxt, &nxt6000_info);
-		
-		fe_count++;
-	}
-	
-	if (fe_count == 0) {
-		kfree(pnxt);
-		return -ENODEV;
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &nxt6000_ops, sizeof(struct dvb_frontend_ops));
+
+	/* check if the demod is there */
+	if (nxt6000_readreg(state, OFDM_MSC_REV) != NXT6000ASICDEVICE) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
 	}
-	
-	return 0;
-}
 
-static void nxt6000_detach(struct dvb_i2c_bus *i2c, void *data)
-{
-	struct nxt6000_config *pnxt = (struct nxt6000_config *)data;
-	dprintk("nxt6000: detach\n");
-	dvb_unregister_frontend(nxt6000_ioctl, i2c);
-	kfree(pnxt);
-}
+static struct dvb_frontend_ops nxt6000_ops = {
 
-static __init int nxt6000_init(void)
-{
+	.info = {
+		.name = "NxtWave NXT6000 DVB-T",
+		.type = FE_OFDM,
+		.frequency_min = 0,
+		.frequency_max = 863250000,
+		.frequency_stepsize = 62500,
+		/*.frequency_tolerance = *//* FIXME: 12% of SR */
+		.symbol_rate_min = 0,	/* FIXME */
+		.symbol_rate_max = 9360000,	/* FIXME */
+		.symbol_rate_tolerance = 4000,
+		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+	                FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
+	                FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
+	                FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+	                FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
+	                FE_CAN_HIERARCHY_AUTO,
+	},
+
+	.release = nxt6000_release,
 
-	dprintk("nxt6000: init\n");
+	.init = nxt6000_init,
 	
-	return dvb_register_i2c_device(THIS_MODULE, nxt6000_attach, nxt6000_detach);
+	.set_frontend = nxt6000_set_frontend,
 	
-}
-
-static __exit void nxt6000_exit(void)
-{
-
-	dprintk("nxt6000: cleanup\n");
+	.read_status = nxt6000_read_status,
+};
 
-	dvb_unregister_i2c_device(nxt6000_attach);
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
 
-}
+MODULE_DESCRIPTION("NxtWave NXT6000 DVB-T demodulator driver");
+MODULE_AUTHOR("Florian Schirmer");
+MODULE_LICENSE("GPL");
 
-module_init(nxt6000_init);
-module_exit(nxt6000_exit);
+EXPORT_SYMBOL(nxt6000_attach);
diff -Nru a/drivers/media/dvb/frontends/nxt6000.h b/drivers/media/dvb/frontends/nxt6000.h
--- a/drivers/media/dvb/frontends/nxt6000.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/media/dvb/frontends/nxt6000.h	2004-12-24 13:36:16 -08:00
@@ -1,266 +1,43 @@
 /*
- * Public Include File for DRV6000 users
- * (ie. NxtWave Communications - NXT6000 demodulator driver)
- *
- * Copyright (C) 2001 NxtWave Communications, Inc.
- *
- */
-
-/*  Nxt6000 Register Addresses and Bit Masks */
-
-/* Maximum Register Number */
-#define MAXNXT6000REG          (0x9A)
-
-/* 0x1B A_VIT_BER_0  aka 0x3A */
-#define A_VIT_BER_0            (0x1B)
-
-/* 0x1D A_VIT_BER_TIMER_0 aka 0x38 */
-#define A_VIT_BER_TIMER_0      (0x1D)
-
-/* 0x21 RS_COR_STAT */
-#define RS_COR_STAT            (0x21)
-#define RSCORESTATUS           (0x03)
-
-/* 0x22 RS_COR_INTEN */
-#define RS_COR_INTEN           (0x22)
-
-/* 0x23 RS_COR_INSTAT */
-#define RS_COR_INSTAT          (0x23)
-#define INSTAT_ERROR           (0x04)
-#define LOCK_LOSS_BITS         (0x03)
-
-/* 0x24 RS_COR_SYNC_PARAM */
-#define RS_COR_SYNC_PARAM      (0x24)
-#define SYNC_PARAM             (0x03)
-
-/* 0x25 BER_CTRL */
-#define BER_CTRL               (0x25)
-#define BER_ENABLE             (0x02)
-#define BER_RESET              (0x01)
-
-/* 0x26 BER_PAY */
-#define BER_PAY                (0x26)
-
-/* 0x27 BER_PKT_L */
-#define BER_PKT_L              (0x27)
-#define BER_PKTOVERFLOW        (0x80)
-
-/* 0x30 VIT_COR_CTL */
-#define VIT_COR_CTL            (0x30)
-#define BER_CONTROL            (0x02)
-#define VIT_COR_MASK           (0x82)
-#define VIT_COR_RESYNC         (0x80)
-
-
-/* 0x32 VIT_SYNC_STATUS */
-#define VIT_SYNC_STATUS        (0x32)
-#define VITINSYNC              (0x80)
-
-/* 0x33 VIT_COR_INTEN */
-#define VIT_COR_INTEN          (0x33)
-#define GLOBAL_ENABLE          (0x80)
-
-/* 0x34 VIT_COR_INTSTAT */
-#define VIT_COR_INTSTAT        (0x34)
-#define BER_DONE               (0x08)
-#define BER_OVERFLOW           (0x10)
-
-/* 0x38 OFDM_BERTimer */     /* Use the alias registers */
-#define A_VIT_BER_TIMER_0      (0x1D)
-
-/* 0x3A VIT_BER_TIMER_0 */   /* Use the alias registers */
-#define A_VIT_BER_0            (0x1B)
-
-/* 0x40 OFDM_COR_CTL */
-#define OFDM_COR_CTL           (0x40)
-#define COREACT                (0x20)
-#define HOLDSM                 (0x10)
-#define WAIT_AGC               (0x02)
-#define WAIT_SYR               (0x03)
-
-/* 0x41 OFDM_COR_STAT */
-#define OFDM_COR_STAT          (0x41)
-#define COR_STATUS             (0x0F)
-#define MONITOR_TPS            (0x06)
-#define TPSLOCKED              (0x40)
-#define AGCLOCKED              (0x10)
-
-/* 0x42 OFDM_COR_INTEN */
-#define OFDM_COR_INTEN         (0x42)
-#define TPSRCVBAD              (0x04)
-#define TPSRCVCHANGED         (0x02)
-#define TPSRCVUPDATE           (0x01)
-
-/* 0x43 OFDM_COR_INSTAT */
-#define OFDM_COR_INSTAT        (0x43)
-
-/* 0x44 OFDM_COR_MODEGUARD */
-#define OFDM_COR_MODEGUARD     (0x44)
-#define FORCEMODE              (0x08)
-#define FORCEMODE8K			   (0x04)
-
-/* 0x45 OFDM_AGC_CTL */
-#define OFDM_AGC_CTL           (0x45)
-#define INITIAL_AGC_BW		   (0x08)
-#define AGCNEG                 (0x02)
-#define AGCLAST				   (0x10)
-
-/* 0x48 OFDM_AGC_TARGET */
-#define OFDM_AGC_TARGET		   (0x48)
-#define OFDM_AGC_TARGET_DEFAULT (0x28)
-#define OFDM_AGC_TARGET_IMPULSE (0x38)
-
-/* 0x49 OFDM_AGC_GAIN_1 */
-#define OFDM_AGC_GAIN_1        (0x49)
-
-/* 0x4B OFDM_ITB_CTL */
-#define OFDM_ITB_CTL           (0x4B)
-#define ITBINV                 (0x01)
-
-/* 0x4C OFDM_ITB_FREQ_1 */
-#define OFDM_ITB_FREQ_1        (0x4C)
-
-/* 0x4D OFDM_ITB_FREQ_2 */
-#define OFDM_ITB_FREQ_2        (0x4D)
-
-/* 0x4E  OFDM_CAS_CTL */       
-#define OFDM_CAS_CTL           (0x4E)
-#define ACSDIS                 (0x40)
-#define CCSEN                  (0x80)
-
-/* 0x4F CAS_FREQ */
-#define CAS_FREQ               (0x4F)
-
-/* 0x51 OFDM_SYR_CTL */
-#define OFDM_SYR_CTL           (0x51)
-#define SIXTH_ENABLE           (0x80)
-#define SYR_TRACKING_DISABLE   (0x01)
-
-/* 0x52 OFDM_SYR_STAT */
-#define OFDM_SYR_STAT		   (0x52)
-#define GI14_2K_SYR_LOCK	   (0x13)
-#define GI14_8K_SYR_LOCK	   (0x17)
-#define GI14_SYR_LOCK		   (0x10)
-
-/* 0x55 OFDM_SYR_OFFSET_1 */
-#define OFDM_SYR_OFFSET_1      (0x55)
-
-/* 0x56 OFDM_SYR_OFFSET_2 */
-#define OFDM_SYR_OFFSET_2      (0x56)
-
-/* 0x58 OFDM_SCR_CTL */
-#define OFDM_SCR_CTL           (0x58)
-#define SYR_ADJ_DECAY_MASK     (0x70)
-#define SYR_ADJ_DECAY          (0x30)
- 
-/* 0x59 OFDM_PPM_CTL_1 */
-#define OFDM_PPM_CTL_1         (0x59)
-#define PPMMAX_MASK            (0x30)
-#define PPM256				   (0x30)
-
-/* 0x5B OFDM_TRL_NOMINALRATE_1 */
-#define OFDM_TRL_NOMINALRATE_1 (0x5B)
-
-/* 0x5C OFDM_TRL_NOMINALRATE_2 */
-#define OFDM_TRL_NOMINALRATE_2 (0x5C)
-
-/* 0x5D OFDM_TRL_TIME_1 */
-#define OFDM_TRL_TIME_1        (0x5D)
-
-/* 0x60 OFDM_CRL_FREQ_1 */
-#define OFDM_CRL_FREQ_1        (0x60)
-
-/* 0x63 OFDM_CHC_CTL_1 */
-#define OFDM_CHC_CTL_1         (0x63)
-#define MANMEAN1               (0xF0);
-#define CHCFIR                 (0x01)
-
-/* 0x64 OFDM_CHC_SNR */
-#define OFDM_CHC_SNR           (0x64)
-
-/* 0x65 OFDM_BDI_CTL */
-#define OFDM_BDI_CTL           (0x65)
-#define LP_SELECT              (0x02)
-
-/* 0x67 OFDM_TPS_RCVD_1 */
-#define OFDM_TPS_RCVD_1        (0x67)
-#define TPSFRAME               (0x03)
-
-/* 0x68 OFDM_TPS_RCVD_2 */
-#define OFDM_TPS_RCVD_2        (0x68)
-
-/* 0x69 OFDM_TPS_RCVD_3 */
-#define OFDM_TPS_RCVD_3        (0x69)
-
-/* 0x6A OFDM_TPS_RCVD_4 */
-#define OFDM_TPS_RCVD_4        (0x6A)
-
-/* 0x6B OFDM_TPS_RESERVED_1 */
-#define OFDM_TPS_RESERVED_1    (0x6B)
-
-/* 0x6C OFDM_TPS_RESERVED_2 */
-#define OFDM_TPS_RESERVED_2    (0x6C)
-
-/* 0x73 OFDM_MSC_REV */
-#define OFDM_MSC_REV           (0x73)
-
-/* 0x76 OFDM_SNR_CARRIER_2 */
-#define OFDM_SNR_CARRIER_2     (0x76)
-#define MEAN_MASK              (0x80)
-#define MEANBIT                (0x80)
-
-/* 0x80 ANALOG_CONTROL_0 */
-#define ANALOG_CONTROL_0       (0x80)
-#define POWER_DOWN_ADC         (0x40)
-
-/* 0x81 ENABLE_TUNER_IIC */
-#define ENABLE_TUNER_IIC       (0x81)
-#define ENABLE_TUNER_BIT       (0x01)
-
-/* 0x82 EN_DMD_RACQ */
-#define EN_DMD_RACQ            (0x82)
-#define EN_DMD_RACQ_REG_VAL    (0x81) 
-#define EN_DMD_RACQ_REG_VAL_14 (0x01)
-
-/* 0x84 SNR_COMMAND */
-#define SNR_COMMAND            (0x84)
-#define SNRStat                (0x80)
-
-/* 0x85 SNRCARRIERNUMBER_LSB */
-#define SNRCARRIERNUMBER_LSB   (0x85)
-
-/* 0x87 SNRMINTHRESHOLD_LSB */
-#define SNRMINTHRESHOLD_LSB    (0x87)
-
-/* 0x89 SNR_PER_CARRIER_LSB */
-#define SNR_PER_CARRIER_LSB    (0x89)
-
-/* 0x8B SNRBELOWTHRESHOLD_LSB */
-#define SNRBELOWTHRESHOLD_LSB  (0x8B)
-
-/* 0x91 RF_AGC_VAL_1 */
-#define RF_AGC_VAL_1           (0x91)
-
-/* 0x92 RF_AGC_STATUS */
-#define RF_AGC_STATUS          (0x92)
-
-/* 0x98 DIAG_CONFIG */
-#define DIAG_CONFIG            (0x98)
-#define DIAG_MASK              (0x70)
-#define TB_SET                 (0x10)
-#define TRAN_SELECT            (0x07)
-#define SERIAL_SELECT          (0x01)
-
-/* 0x99 SUB_DIAG_MODE_SEL */
-#define SUB_DIAG_MODE_SEL      (0x99)
-#define CLKINVERSION           (0x01)
-
-/* 0x9A TS_FORMAT */
-#define TS_FORMAT              (0x9A)
-#define ERROR_SENSE            (0x08)
-#define VALID_SENSE            (0x04)
-#define SYNC_SENSE             (0x02)
-#define GATED_CLOCK            (0x01)
+	NxtWave Communications - NXT6000 demodulator driver
 
-#define NXT6000ASICDEVICE      (0x0b)
+    Copyright (C) 2002-2003 Florian Schirmer <jolt@tuxbox.org>
+    Copyright (C) 2003 Paul Andreassen <paul@andreassen.com.au>
 
+    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.
+*/
+
+#ifndef NXT6000_H
+#define NXT6000_H
+
+#include <linux/dvb/frontend.h>
+
+struct nxt6000_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* should clock inversion be used? */
+	u8 clock_inversion:1;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
+					   struct i2c_adapter* i2c);
+
+#endif // NXT6000_H
diff -Nru a/drivers/media/dvb/frontends/nxt6000_priv.h b/drivers/media/dvb/frontends/nxt6000_priv.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/nxt6000_priv.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,265 @@
+/*
+ * Public Include File for DRV6000 users
+ * (ie. NxtWave Communications - NXT6000 demodulator driver)
+ *
+ * Copyright (C) 2001 NxtWave Communications, Inc.
+ *
+ */
+
+/*  Nxt6000 Register Addresses and Bit Masks */
+
+/* Maximum Register Number */
+#define MAXNXT6000REG          (0x9A)
+
+/* 0x1B A_VIT_BER_0  aka 0x3A */
+#define A_VIT_BER_0            (0x1B)
+
+/* 0x1D A_VIT_BER_TIMER_0 aka 0x38 */
+#define A_VIT_BER_TIMER_0      (0x1D)
+
+/* 0x21 RS_COR_STAT */
+#define RS_COR_STAT            (0x21)
+#define RSCORESTATUS           (0x03)
+
+/* 0x22 RS_COR_INTEN */
+#define RS_COR_INTEN           (0x22)
+
+/* 0x23 RS_COR_INSTAT */
+#define RS_COR_INSTAT          (0x23)
+#define INSTAT_ERROR           (0x04)
+#define LOCK_LOSS_BITS         (0x03)
+
+/* 0x24 RS_COR_SYNC_PARAM */
+#define RS_COR_SYNC_PARAM      (0x24)
+#define SYNC_PARAM             (0x03)
+
+/* 0x25 BER_CTRL */
+#define BER_CTRL               (0x25)
+#define BER_ENABLE             (0x02)
+#define BER_RESET              (0x01)
+
+/* 0x26 BER_PAY */
+#define BER_PAY                (0x26)
+
+/* 0x27 BER_PKT_L */
+#define BER_PKT_L              (0x27)
+#define BER_PKTOVERFLOW        (0x80)
+
+/* 0x30 VIT_COR_CTL */
+#define VIT_COR_CTL            (0x30)
+#define BER_CONTROL            (0x02)
+#define VIT_COR_MASK           (0x82)
+#define VIT_COR_RESYNC         (0x80)
+
+
+/* 0x32 VIT_SYNC_STATUS */
+#define VIT_SYNC_STATUS        (0x32)
+#define VITINSYNC              (0x80)
+
+/* 0x33 VIT_COR_INTEN */
+#define VIT_COR_INTEN          (0x33)
+#define GLOBAL_ENABLE          (0x80)
+
+/* 0x34 VIT_COR_INTSTAT */
+#define VIT_COR_INTSTAT        (0x34)
+#define BER_DONE               (0x08)
+#define BER_OVERFLOW           (0x10)
+
+			     /* 0x38 OFDM_BERTimer *//* Use the alias registers */
+#define A_VIT_BER_TIMER_0      (0x1D)
+
+			     /* 0x3A VIT_BER_TIMER_0 *//* Use the alias registers */
+#define A_VIT_BER_0            (0x1B)
+
+/* 0x40 OFDM_COR_CTL */
+#define OFDM_COR_CTL           (0x40)
+#define COREACT                (0x20)
+#define HOLDSM                 (0x10)
+#define WAIT_AGC               (0x02)
+#define WAIT_SYR               (0x03)
+
+/* 0x41 OFDM_COR_STAT */
+#define OFDM_COR_STAT          (0x41)
+#define COR_STATUS             (0x0F)
+#define MONITOR_TPS            (0x06)
+#define TPSLOCKED              (0x40)
+#define AGCLOCKED              (0x10)
+
+/* 0x42 OFDM_COR_INTEN */
+#define OFDM_COR_INTEN         (0x42)
+#define TPSRCVBAD              (0x04)
+#define TPSRCVCHANGED         (0x02)
+#define TPSRCVUPDATE           (0x01)
+
+/* 0x43 OFDM_COR_INSTAT */
+#define OFDM_COR_INSTAT        (0x43)
+
+/* 0x44 OFDM_COR_MODEGUARD */
+#define OFDM_COR_MODEGUARD     (0x44)
+#define FORCEMODE              (0x08)
+#define FORCEMODE8K			   (0x04)
+
+/* 0x45 OFDM_AGC_CTL */
+#define OFDM_AGC_CTL           (0x45)
+#define INITIAL_AGC_BW		   (0x08)
+#define AGCNEG                 (0x02)
+#define AGCLAST				   (0x10)
+
+/* 0x48 OFDM_AGC_TARGET */
+#define OFDM_AGC_TARGET		   (0x48)
+#define OFDM_AGC_TARGET_DEFAULT (0x28)
+#define OFDM_AGC_TARGET_IMPULSE (0x38)
+
+/* 0x49 OFDM_AGC_GAIN_1 */
+#define OFDM_AGC_GAIN_1        (0x49)
+
+/* 0x4B OFDM_ITB_CTL */
+#define OFDM_ITB_CTL           (0x4B)
+#define ITBINV                 (0x01)
+
+/* 0x4C OFDM_ITB_FREQ_1 */
+#define OFDM_ITB_FREQ_1        (0x4C)
+
+/* 0x4D OFDM_ITB_FREQ_2 */
+#define OFDM_ITB_FREQ_2        (0x4D)
+
+/* 0x4E  OFDM_CAS_CTL */
+#define OFDM_CAS_CTL           (0x4E)
+#define ACSDIS                 (0x40)
+#define CCSEN                  (0x80)
+
+/* 0x4F CAS_FREQ */
+#define CAS_FREQ               (0x4F)
+
+/* 0x51 OFDM_SYR_CTL */
+#define OFDM_SYR_CTL           (0x51)
+#define SIXTH_ENABLE           (0x80)
+#define SYR_TRACKING_DISABLE   (0x01)
+
+/* 0x52 OFDM_SYR_STAT */
+#define OFDM_SYR_STAT		   (0x52)
+#define GI14_2K_SYR_LOCK	   (0x13)
+#define GI14_8K_SYR_LOCK	   (0x17)
+#define GI14_SYR_LOCK		   (0x10)
+
+/* 0x55 OFDM_SYR_OFFSET_1 */
+#define OFDM_SYR_OFFSET_1      (0x55)
+
+/* 0x56 OFDM_SYR_OFFSET_2 */
+#define OFDM_SYR_OFFSET_2      (0x56)
+
+/* 0x58 OFDM_SCR_CTL */
+#define OFDM_SCR_CTL           (0x58)
+#define SYR_ADJ_DECAY_MASK     (0x70)
+#define SYR_ADJ_DECAY          (0x30)
+
+/* 0x59 OFDM_PPM_CTL_1 */
+#define OFDM_PPM_CTL_1         (0x59)
+#define PPMMAX_MASK            (0x30)
+#define PPM256				   (0x30)
+
+/* 0x5B OFDM_TRL_NOMINALRATE_1 */
+#define OFDM_TRL_NOMINALRATE_1 (0x5B)
+
+/* 0x5C OFDM_TRL_NOMINALRATE_2 */
+#define OFDM_TRL_NOMINALRATE_2 (0x5C)
+
+/* 0x5D OFDM_TRL_TIME_1 */
+#define OFDM_TRL_TIME_1        (0x5D)
+
+/* 0x60 OFDM_CRL_FREQ_1 */
+#define OFDM_CRL_FREQ_1        (0x60)
+
+/* 0x63 OFDM_CHC_CTL_1 */
+#define OFDM_CHC_CTL_1         (0x63)
+#define MANMEAN1               (0xF0);
+#define CHCFIR                 (0x01)
+
+/* 0x64 OFDM_CHC_SNR */
+#define OFDM_CHC_SNR           (0x64)
+
+/* 0x65 OFDM_BDI_CTL */
+#define OFDM_BDI_CTL           (0x65)
+#define LP_SELECT              (0x02)
+
+/* 0x67 OFDM_TPS_RCVD_1 */
+#define OFDM_TPS_RCVD_1        (0x67)
+#define TPSFRAME               (0x03)
+
+/* 0x68 OFDM_TPS_RCVD_2 */
+#define OFDM_TPS_RCVD_2        (0x68)
+
+/* 0x69 OFDM_TPS_RCVD_3 */
+#define OFDM_TPS_RCVD_3        (0x69)
+
+/* 0x6A OFDM_TPS_RCVD_4 */
+#define OFDM_TPS_RCVD_4        (0x6A)
+
+/* 0x6B OFDM_TPS_RESERVED_1 */
+#define OFDM_TPS_RESERVED_1    (0x6B)
+
+/* 0x6C OFDM_TPS_RESERVED_2 */
+#define OFDM_TPS_RESERVED_2    (0x6C)
+
+/* 0x73 OFDM_MSC_REV */
+#define OFDM_MSC_REV           (0x73)
+
+/* 0x76 OFDM_SNR_CARRIER_2 */
+#define OFDM_SNR_CARRIER_2     (0x76)
+#define MEAN_MASK              (0x80)
+#define MEANBIT                (0x80)
+
+/* 0x80 ANALOG_CONTROL_0 */
+#define ANALOG_CONTROL_0       (0x80)
+#define POWER_DOWN_ADC         (0x40)
+
+/* 0x81 ENABLE_TUNER_IIC */
+#define ENABLE_TUNER_IIC       (0x81)
+#define ENABLE_TUNER_BIT       (0x01)
+
+/* 0x82 EN_DMD_RACQ */
+#define EN_DMD_RACQ            (0x82)
+#define EN_DMD_RACQ_REG_VAL    (0x81)
+#define EN_DMD_RACQ_REG_VAL_14 (0x01)
+
+/* 0x84 SNR_COMMAND */
+#define SNR_COMMAND            (0x84)
+#define SNRStat                (0x80)
+
+/* 0x85 SNRCARRIERNUMBER_LSB */
+#define SNRCARRIERNUMBER_LSB   (0x85)
+
+/* 0x87 SNRMINTHRESHOLD_LSB */
+#define SNRMINTHRESHOLD_LSB    (0x87)
+
+/* 0x89 SNR_PER_CARRIER_LSB */
+#define SNR_PER_CARRIER_LSB    (0x89)
+
+/* 0x8B SNRBELOWTHRESHOLD_LSB */
+#define SNRBELOWTHRESHOLD_LSB  (0x8B)
+
+/* 0x91 RF_AGC_VAL_1 */
+#define RF_AGC_VAL_1           (0x91)
+
+/* 0x92 RF_AGC_STATUS */
+#define RF_AGC_STATUS          (0x92)
+
+/* 0x98 DIAG_CONFIG */
+#define DIAG_CONFIG            (0x98)
+#define DIAG_MASK              (0x70)
+#define TB_SET                 (0x10)
+#define TRAN_SELECT            (0x07)
+#define SERIAL_SELECT          (0x01)
+
+/* 0x99 SUB_DIAG_MODE_SEL */
+#define SUB_DIAG_MODE_SEL      (0x99)
+#define CLKINVERSION           (0x01)
+
+/* 0x9A TS_FORMAT */
+#define TS_FORMAT              (0x9A)
+#define ERROR_SENSE            (0x08)
+#define VALID_SENSE            (0x04)
+#define SYNC_SENSE             (0x02)
+#define GATED_CLOCK            (0x01)
+
+#define NXT6000ASICDEVICE      (0x0b)
diff -Nru a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/sp8870.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,613 @@
+/*
+    Driver for Spase SP8870 demodulator
+
+    Copyright (C) 1999 Juergen Peitz
+
+    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.
+
+*/
+/*
+ * This driver needs external firmware. Please use the command
+ * "<kerneldir>/Documentation/dvb/get_dvb_firmware alps_tdlb7" to
+ * download/extract it, and then copy it to /usr/lib/hotplug/firmware.
+ */
+#define SP8870_DEFAULT_FIRMWARE "dvb-fe-sp8870.fw"
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
+#include <linux/firmware.h>
+#include <linux/delay.h>
+
+#include "dvb_frontend.h"
+#include "sp8870.h"
+
+
+struct sp8870_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	const struct sp8870_config* config;
+
+	struct dvb_frontend frontend;
+
+	/* demodulator private data */
+	u8 initialised:1;
+};
+
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "sp8870: " args); \
+	} while (0)
+
+/* firmware size for sp8870 */
+#define SP8870_FIRMWARE_SIZE 16382
+
+/* starting point for firmware in file 'Sc_main.mc' */
+#define SP8870_FIRMWARE_OFFSET 0x0A
+
+static int sp8870_writereg (struct sp8870_state* state, u16 reg, u16 data)
+{
+        u8 buf [] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 4 };
+	int err;
+
+        if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
+		dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
+		return -EREMOTEIO;
+	}
+
+        return 0;
+}
+
+static int sp8870_readreg (struct sp8870_state* state, u16 reg)
+{
+	int ret;
+	u8 b0 [] = { reg >> 8 , reg & 0xff };
+	u8 b1 [] = { 0, 0 };
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
+			   { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 } };
+
+	ret = i2c_transfer (state->i2c, msg, 2);
+
+	if (ret != 2) {
+		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+		return -1;
+	}
+
+	return (b1[0] << 8 | b1[1]);
+}
+
+static int sp8870_firmware_upload (struct sp8870_state* state, const struct firmware *fw)
+{
+	struct i2c_msg msg;
+	char *fw_buf = fw->data;
+	int fw_pos;
+	u8 tx_buf[255];
+	int tx_len;
+	int err = 0;
+
+	dprintk ("%s: ...\n", __FUNCTION__);
+
+	if (fw->size < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET)
+		return -EINVAL;
+
+	// system controller stop
+	sp8870_writereg(state, 0x0F00, 0x0000);
+
+	// instruction RAM register hiword
+	sp8870_writereg(state, 0x8F08, ((SP8870_FIRMWARE_SIZE / 2) & 0xFFFF));
+
+	// instruction RAM MWR
+	sp8870_writereg(state, 0x8F0A, ((SP8870_FIRMWARE_SIZE / 2) >> 16));
+
+	// do firmware upload
+	fw_pos = SP8870_FIRMWARE_OFFSET;
+	while (fw_pos < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET){
+		tx_len = (fw_pos <= SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET - 252) ? 252 : SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET - fw_pos;
+		// write register 0xCF0A
+		tx_buf[0] = 0xCF;
+		tx_buf[1] = 0x0A;
+		memcpy(&tx_buf[2], fw_buf + fw_pos, tx_len);
+		msg.addr = state->config->demod_address;
+		msg.flags = 0;
+		msg.buf = tx_buf;
+		msg.len = tx_len + 2;
+        	if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
+			printk("%s: firmware upload failed!\n", __FUNCTION__);
+			printk ("%s: i2c error (err == %i)\n", __FUNCTION__, err);
+			return err;
+		}
+		fw_pos += tx_len;
+	}
+
+	dprintk ("%s: done!\n", __FUNCTION__);
+	return 0;
+};
+
+static void sp8870_microcontroller_stop (struct sp8870_state* state)
+{
+	sp8870_writereg(state, 0x0F08, 0x000);
+	sp8870_writereg(state, 0x0F09, 0x000);
+
+	// microcontroller STOP
+	sp8870_writereg(state, 0x0F00, 0x000);
+}
+
+static void sp8870_microcontroller_start (struct sp8870_state* state)
+{
+	sp8870_writereg(state, 0x0F08, 0x000);
+	sp8870_writereg(state, 0x0F09, 0x000);
+
+	// microcontroller START
+	sp8870_writereg(state, 0x0F00, 0x001);
+	// not documented but if we don't read 0x0D01 out here
+	// we don't get a correct data valid signal
+	sp8870_readreg(state, 0x0D01);
+}
+
+static int sp8870_read_data_valid_signal(struct sp8870_state* state)
+{
+	return (sp8870_readreg(state, 0x0D02) > 0);
+}
+
+static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
+{
+	int known_parameters = 1;
+
+	*reg0xc05 = 0x000;
+
+	switch (p->u.ofdm.constellation) {
+	case QPSK:
+		break;
+	case QAM_16:
+		*reg0xc05 |= (1 << 10);
+		break;
+	case QAM_64:
+		*reg0xc05 |= (2 << 10);
+		break;
+	case QAM_AUTO:
+		known_parameters = 0;
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	switch (p->u.ofdm.hierarchy_information) {
+	case HIERARCHY_NONE:
+		break;
+	case HIERARCHY_1:
+		*reg0xc05 |= (1 << 7);
+		break;
+	case HIERARCHY_2:
+		*reg0xc05 |= (2 << 7);
+		break;
+	case HIERARCHY_4:
+		*reg0xc05 |= (3 << 7);
+		break;
+	case HIERARCHY_AUTO:
+		known_parameters = 0;
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	switch (p->u.ofdm.code_rate_HP) {
+	case FEC_1_2:
+		break;
+	case FEC_2_3:
+		*reg0xc05 |= (1 << 3);
+		break;
+	case FEC_3_4:
+		*reg0xc05 |= (2 << 3);
+		break;
+	case FEC_5_6:
+		*reg0xc05 |= (3 << 3);
+		break;
+	case FEC_7_8:
+		*reg0xc05 |= (4 << 3);
+		break;
+	case FEC_AUTO:
+		known_parameters = 0;
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	if (known_parameters)
+		*reg0xc05 |= (2 << 1);	/* use specified parameters */
+	else
+		*reg0xc05 |= (1 << 1);	/* enable autoprobing */
+
+	return 0;
+}
+
+static int sp8870_wake_up(struct sp8870_state* state)
+{
+	// enable TS output and interface pins
+	return sp8870_writereg(state, 0xC18, 0x00D);
+}
+
+static int sp8870_set_frontend_parameters (struct dvb_frontend* fe,
+					   struct dvb_frontend_parameters *p)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+	int  err;
+	u16 reg0xc05;
+
+	if ((err = configure_reg0xc05(p, &reg0xc05)))
+		return err;
+
+	// system controller stop
+	sp8870_microcontroller_stop(state);
+
+	// set tuner parameters
+	sp8870_writereg(state, 0x206, 0x001);
+	state->config->pll_set(fe, p);
+	sp8870_writereg(state, 0x206, 0x000);
+
+	// sample rate correction bit [23..17]
+	sp8870_writereg(state, 0x0319, 0x000A);
+
+	// sample rate correction bit [16..0]
+	sp8870_writereg(state, 0x031A, 0x0AAB);
+
+	// integer carrier offset
+	sp8870_writereg(state, 0x0309, 0x0400);
+
+	// fractional carrier offset
+	sp8870_writereg(state, 0x030A, 0x0000);
+
+	// filter for 6/7/8 Mhz channel
+	if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
+		sp8870_writereg(state, 0x0311, 0x0002);
+	else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
+		sp8870_writereg(state, 0x0311, 0x0001);
+	else
+		sp8870_writereg(state, 0x0311, 0x0000);
+
+	// scan order: 2k first = 0x0000, 8k first = 0x0001
+	if (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_2K)
+		sp8870_writereg(state, 0x0338, 0x0000);
+	else
+		sp8870_writereg(state, 0x0338, 0x0001);
+
+	sp8870_writereg(state, 0xc05, reg0xc05);
+
+	// read status reg in order to clear pending irqs
+	sp8870_readreg(state, 0x200);
+
+	// system controller start
+	sp8870_microcontroller_start(state);
+
+	return 0;
+}
+
+static int sp8870_init (struct dvb_frontend* fe)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+        const struct firmware *fw = NULL;
+
+	sp8870_wake_up(state);
+	if (state->initialised) return 0;
+	state->initialised = 1;
+
+	dprintk ("%s\n", __FUNCTION__);
+
+
+	/* request the firmware, this will block until someone uploads it */
+	printk("sp8870: waiting for firmware upload...\n");
+	if (state->config->request_firmware(fe, &fw, SP8870_DEFAULT_FIRMWARE)) {
+		printk("sp8870: no firmware upload (timeout or file not found?)\n");
+		release_firmware(fw);
+		return -EIO;
+	}
+
+	if (sp8870_firmware_upload(state, fw)) {
+		printk("sp8870: writing firmware to device failed\n");
+		release_firmware(fw);
+		return -EIO;
+	}
+
+	/* enable TS output and interface pins */
+	sp8870_writereg(state, 0xc18, 0x00d);
+
+	// system controller stop
+	sp8870_microcontroller_stop(state);
+
+	// ADC mode
+	sp8870_writereg(state, 0x0301, 0x0003);
+
+	// Reed Solomon parity bytes passed to output
+	sp8870_writereg(state, 0x0C13, 0x0001);
+
+	// MPEG clock is suppressed if no valid data
+	sp8870_writereg(state, 0x0C14, 0x0001);
+
+	/* bit 0x010: enable data valid signal */
+	sp8870_writereg(state, 0x0D00, 0x010);
+	sp8870_writereg(state, 0x0D01, 0x000);
+
+	/* setup PLL */
+	if (state->config->pll_init) {
+		sp8870_writereg(state, 0x206, 0x001);
+		state->config->pll_init(fe);
+		sp8870_writereg(state, 0x206, 0x000);
+	}
+
+	return 0;
+}
+
+static int sp8870_read_status (struct dvb_frontend* fe, fe_status_t * fe_status)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+	int status;
+	int signal;
+
+	*fe_status = 0;
+
+	status = sp8870_readreg (state, 0x0200);
+	if (status < 0)
+		return -EIO;
+
+	signal = sp8870_readreg (state, 0x0303);
+	if (signal < 0)
+		return -EIO;
+
+	if (signal > 0x0F)
+		*fe_status |= FE_HAS_SIGNAL;
+	if (status & 0x08)
+		*fe_status |= FE_HAS_SYNC;
+	if (status & 0x04)
+		*fe_status |= FE_HAS_LOCK | FE_HAS_CARRIER | FE_HAS_VITERBI;
+
+	return 0;
+}
+
+static int sp8870_read_ber (struct dvb_frontend* fe, u32 * ber)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+	int ret;
+	u32 tmp;
+
+	*ber = 0;
+
+	ret = sp8870_readreg(state, 0xC08);
+	if (ret < 0)
+		return -EIO;
+
+	tmp = ret & 0x3F;
+
+	ret = sp8870_readreg(state, 0xC07);
+	if (ret < 0)
+		return -EIO;
+
+	 tmp = ret << 6;
+
+	if (tmp >= 0x3FFF0)
+		tmp = ~0;
+
+	*ber = tmp;
+
+	return 0;
+}
+
+static int sp8870_read_signal_strength(struct dvb_frontend* fe,  u16 * signal)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+	int ret;
+	u16 tmp;
+
+	*signal = 0;
+
+	ret = sp8870_readreg (state, 0x306);
+	if (ret < 0)
+		return -EIO;
+
+	tmp = ret << 8;
+
+	ret = sp8870_readreg (state, 0x303);
+	if (ret < 0)
+		return -EIO;
+
+	tmp |= ret;
+
+	if (tmp)
+		*signal = 0xFFFF - tmp;
+
+	return 0;
+}
+
+static int sp8870_read_uncorrected_blocks (struct dvb_frontend* fe, u32* ublocks)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+	int ret;
+
+	*ublocks = 0;
+
+	ret = sp8870_readreg(state, 0xC0C);
+	if (ret < 0)
+		return -EIO;
+
+	if (ret == 0xFFFF)
+		ret = ~0;
+
+	*ublocks = ret;
+
+	return 0;
+}
+
+// number of trials to recover from lockup
+#define MAXTRIALS 5
+// maximum checks for data valid signal
+#define MAXCHECKS 100
+
+// only for debugging: counter for detected lockups
+static int lockups = 0;
+// only for debugging: counter for channel switches
+static int switches = 0;
+
+static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+
+	/*
+	    The firmware of the sp8870 sometimes locks up after setting frontend parameters.
+	    We try to detect this by checking the data valid signal.
+	    If it is not set after MAXCHECKS we try to recover the lockup by setting
+	    the frontend parameters again.
+	*/
+
+	int err = 0;
+	int valid = 0;
+	int trials = 0;
+	int check_count = 0;
+
+	dprintk("%s: frequency = %i\n", __FUNCTION__, p->frequency);
+
+	for (trials = 1; trials <= MAXTRIALS; trials++) {
+
+		if ((err = sp8870_set_frontend_parameters(fe, p)))
+			return err;
+
+		for (check_count = 0; check_count < MAXCHECKS; check_count++) {
+//			valid = ((sp8870_readreg(i2c, 0x0200) & 4) == 0);
+			valid = sp8870_read_data_valid_signal(state);
+			if (valid) {
+				dprintk("%s: delay = %i usec\n",
+					__FUNCTION__, check_count * 10);
+				break;
+			}
+			udelay(10);
+		}
+		if (valid)
+			break;
+	}
+
+	if (!valid) {
+		printk("%s: firmware crash!!!!!!\n", __FUNCTION__);
+		return -EIO;
+	}
+
+	if (debug) {
+		if (valid) {
+			if (trials > 1) {
+				printk("%s: firmware lockup!!!\n", __FUNCTION__);
+				printk("%s: recovered after %i trial(s))\n",  __FUNCTION__, trials - 1);
+				lockups++;
+			}
+		}
+		switches++;
+		printk("%s: switches = %i lockups = %i\n", __FUNCTION__, switches, lockups);
+	}
+
+	return 0;
+}
+
+static int sp8870_sleep(struct dvb_frontend* fe)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+
+	// tristate TS output and disable interface pins
+	return sp8870_writereg(state, 0xC18, 0x000);
+}
+
+static int sp8870_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
+{
+        fesettings->min_delay_ms = 350;
+        fesettings->step_size = 0;
+        fesettings->max_drift = 0;
+        return 0;
+}
+
+static void sp8870_release(struct dvb_frontend* fe)
+{
+	struct sp8870_state* state = (struct sp8870_state*) fe->demodulator_priv;
+	kfree(state);
+}
+
+static struct dvb_frontend_ops sp8870_ops;
+
+struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
+				   struct i2c_adapter* i2c)
+{
+	struct sp8870_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct sp8870_state*) kmalloc(sizeof(struct sp8870_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &sp8870_ops, sizeof(struct dvb_frontend_ops));
+	state->initialised = 0;
+
+	/* check if the demod is there */
+	if (sp8870_readreg(state, 0x0200) < 0) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops sp8870_ops = {
+
+	.info = {
+		.name			= "Spase SP8870 DVB-T",
+		.type			= FE_OFDM,
+		.frequency_min		= 470000000,
+		.frequency_max		= 860000000,
+		.frequency_stepsize	= 166666,
+		.caps			= FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
+					  FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 |
+					  FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+					  FE_CAN_QPSK | FE_CAN_QAM_16 |
+					  FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+					  FE_CAN_HIERARCHY_AUTO |  FE_CAN_RECOVER
+	},
+
+	.release = sp8870_release,
+
+	.init = sp8870_init,
+	.sleep = sp8870_sleep,
+
+	.set_frontend = sp8870_set_frontend,
+	.get_tune_settings = sp8870_get_tune_settings,
+
+	.read_status = sp8870_read_status,
+	.read_ber = sp8870_read_ber,
+	.read_signal_strength = sp8870_read_signal_strength,
+	.read_ucblocks = sp8870_read_uncorrected_blocks,
+};
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
+
+MODULE_DESCRIPTION("Spase SP8870 DVB-T Demodulator driver");
+MODULE_AUTHOR("Juergen Peitz");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(sp8870_attach);
diff -Nru a/drivers/media/dvb/frontends/sp8870.h b/drivers/media/dvb/frontends/sp8870.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/sp8870.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,45 @@
+/*
+    Driver for Spase SP8870 demodulator
+
+    Copyright (C) 1999 Juergen Peitz
+
+    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.
+
+*/
+
+#ifndef SP8870_H
+#define SP8870_H
+
+#include <linux/dvb/frontend.h>
+#include <linux/firmware.h>
+
+struct sp8870_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+
+	/* request firmware for device */
+	int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
+};
+
+extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
+					  struct i2c_adapter* i2c);
+
+#endif // SP8870_H
diff -Nru a/drivers/media/dvb/frontends/sp887x.c b/drivers/media/dvb/frontends/sp887x.c
--- a/drivers/media/dvb/frontends/sp887x.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/dvb/frontends/sp887x.c	2004-12-24 13:37:18 -08:00
@@ -1,107 +1,69 @@
 /*
-   Driver for the Microtune 7202D Frontend
+   Driver for the Spase sp887x demodulator
 */
 
 /*
-   This driver needs a copy of the Avermedia firmware. The version tested
-   is part of the Avermedia DVB-T 1.3.26.3 Application. If the software is
-   installed in Windows the file will be in the /Program Files/AVerTV DVB-T/
-   directory and is called sc_main.mc. Alternatively it can "extracted" from
-   the install cab files. Copy this file to '/usr/lib/hotplug/firmware/sc_main.mc'.
-   With this version of the file the first 10 bytes are discarded and the
-   next 0x4000 loaded. This may change in future versions.
+ * This driver needs external firmware. Please use the command
+ * "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to
+ * download/extract it, and then copy it to /usr/lib/hotplug/firmware.
  */
+#define SP887X_DEFAULT_FIRMWARE "dvb-fe-sp887x.fw"
 
-#include <linux/kernel.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
 #include <linux/init.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/unistd.h>
-#include <linux/fcntl.h>
-#include <linux/errno.h>
-#include <linux/i2c.h>
-#include <linux/syscalls.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
+#include <linux/firmware.h>
 
 #include "dvb_frontend.h"
-#include "dvb_functions.h"
+#include "sp887x.h"
 
-#ifndef DVB_SP887X_FIRMWARE_FILE
-#define DVB_SP887X_FIRMWARE_FILE "/usr/lib/hotplug/firmware/sc_main.mc"
-#endif
-
-static char *sp887x_firmware = DVB_SP887X_FIRMWARE_FILE;
-
-#if 0
-#define dprintk(x...) printk(x)
-#else
-#define dprintk(x...)
-#endif
-
-#if 0
-#define LOG(dir,addr,buf,len) 					\
-	do {							\
-		int i;						\
-		printk("%s (%02x):", dir, addr & 0xff);		\
-		for (i=0; i<len; i++)				\
-			printk(" 0x%02x,", buf[i] & 0xff);	\
-		printk("\n");					\
-	} while (0)
-#else
-#define LOG(dir,addr,buf,len)
-#endif
-
-
-static
-struct dvb_frontend_info sp887x_info = {
-	.name = "Microtune MT7202DTF",
-	.type = FE_OFDM,
-	.frequency_min =  50500000,
-	.frequency_max = 858000000,
-	.frequency_stepsize = 166666,
-	.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-		FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-		FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
-                FE_CAN_RECOVER
+
+struct sp887x_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	const struct sp887x_config* config;
+
+	struct dvb_frontend frontend;
+
+	/* demodulator private data */
+	u8 initialised:1;
 };
 
-static
-int i2c_writebytes (struct dvb_frontend *fe, u8 addr, u8 *buf, u8 len)
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "sp887x: " args); \
+	} while (0)
+
+static int i2c_writebytes (struct sp887x_state* state, u8 *buf, u8 len)
 {
-	struct dvb_i2c_bus *i2c = fe->i2c;
-	struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = len };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = len };
 	int err;
 
-	LOG("i2c_writebytes", msg.addr, msg.buf, msg.len);
-
-	if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
+	if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
 		printk ("%s: i2c write error (addr %02x, err == %i)\n",
-			__FUNCTION__, addr, err);
+			__FUNCTION__, state->config->demod_address, err);
 		return -EREMOTEIO;
 	}
 
 	return 0;
 }
 
-
-
-static
-int sp887x_writereg (struct dvb_frontend *fe, u16 reg, u16 data)
+static int sp887x_writereg (struct sp887x_state* state, u16 reg, u16 data)
 {
-	struct dvb_i2c_bus *i2c = fe->i2c;
 	u8 b0 [] = { reg >> 8 , reg & 0xff, data >> 8, data & 0xff };
-	struct i2c_msg msg = { .addr = 0x70, .flags = 0, .buf = b0, .len = 4 };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 4 };
 	int ret;
 
-	LOG("sp887x_writereg", msg.addr, msg.buf, msg.len);
-
-	if ((ret = i2c->xfer(i2c, &msg, 1)) != 1) {
+	if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) {
 		/**
 		 *  in case of soft reset we ignore ACK errors...
 		 */
-		if (!(reg == 0xf1a && data == 0x000 && 
+		if (!(reg == 0xf1a && data == 0x000 &&
 			(ret == -EREMOTEIO || ret == -EFAULT)))
 		{
 			printk("%s: writereg error "
@@ -114,153 +76,103 @@
 	return 0;
 }
 
-
-static
-u16 sp887x_readreg (struct dvb_frontend *fe, u16 reg)
+static int sp887x_readreg (struct sp887x_state* state, u16 reg)
 {
-	struct dvb_i2c_bus *i2c = fe->i2c;
 	u8 b0 [] = { reg >> 8 , reg & 0xff };
 	u8 b1 [2];
 	int ret;
-	struct i2c_msg msg[] = {{ .addr = 0x70, .flags = 0, .buf = b0, .len = 2 },
-		         { .addr = 0x70, .flags = I2C_M_RD, .buf = b1, .len = 2 }};
-
-	LOG("sp887x_readreg (w)", msg[0].addr, msg[0].buf, msg[0].len);
-	LOG("sp887x_readreg (r)", msg[1].addr, msg[1].buf, msg[1].len);
+	struct i2c_msg msg[] = {{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
+		         { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }};
 
-	if ((ret = i2c->xfer(i2c, msg, 2)) != 2)
+	if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) {
 		printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+		return -1;
+	}
 
 	return (((b1[0] << 8) | b1[1]) & 0xfff);
 }
 
-
-static
-void sp887x_microcontroller_stop (struct dvb_frontend *fe)
+static void sp887x_microcontroller_stop (struct sp887x_state* state)
 {
 	dprintk("%s\n", __FUNCTION__);
-	sp887x_writereg(fe, 0xf08, 0x000);
-	sp887x_writereg(fe, 0xf09, 0x000);		
+	sp887x_writereg(state, 0xf08, 0x000);
+	sp887x_writereg(state, 0xf09, 0x000);
 
 	/* microcontroller STOP */
-	sp887x_writereg(fe, 0xf00, 0x000);
+	sp887x_writereg(state, 0xf00, 0x000);
 }
 
-
-static
-void sp887x_microcontroller_start (struct dvb_frontend *fe)
+static void sp887x_microcontroller_start (struct sp887x_state* state)
 {
 	dprintk("%s\n", __FUNCTION__);
-	sp887x_writereg(fe, 0xf08, 0x000);
-	sp887x_writereg(fe, 0xf09, 0x000);		
+	sp887x_writereg(state, 0xf08, 0x000);
+	sp887x_writereg(state, 0xf09, 0x000);
 
 	/* microcontroller START */
-	sp887x_writereg(fe, 0xf00, 0x001);
+	sp887x_writereg(state, 0xf00, 0x001);
 }
 
-
-static
-void sp887x_setup_agc (struct dvb_frontend *fe)
+static void sp887x_setup_agc (struct sp887x_state* state)
 {
 	/* setup AGC parameters */
 	dprintk("%s\n", __FUNCTION__);
-	sp887x_writereg(fe, 0x33c, 0x054);
-	sp887x_writereg(fe, 0x33b, 0x04c);
-	sp887x_writereg(fe, 0x328, 0x000);
-	sp887x_writereg(fe, 0x327, 0x005);
-	sp887x_writereg(fe, 0x326, 0x001);
-	sp887x_writereg(fe, 0x325, 0x001);
-	sp887x_writereg(fe, 0x324, 0x001);
-	sp887x_writereg(fe, 0x318, 0x050);
-	sp887x_writereg(fe, 0x317, 0x3fe);
-	sp887x_writereg(fe, 0x316, 0x001);
-	sp887x_writereg(fe, 0x313, 0x005);
-	sp887x_writereg(fe, 0x312, 0x002);
-	sp887x_writereg(fe, 0x306, 0x000);
-	sp887x_writereg(fe, 0x303, 0x000);
+	sp887x_writereg(state, 0x33c, 0x054);
+	sp887x_writereg(state, 0x33b, 0x04c);
+	sp887x_writereg(state, 0x328, 0x000);
+	sp887x_writereg(state, 0x327, 0x005);
+	sp887x_writereg(state, 0x326, 0x001);
+	sp887x_writereg(state, 0x325, 0x001);
+	sp887x_writereg(state, 0x324, 0x001);
+	sp887x_writereg(state, 0x318, 0x050);
+	sp887x_writereg(state, 0x317, 0x3fe);
+	sp887x_writereg(state, 0x316, 0x001);
+	sp887x_writereg(state, 0x313, 0x005);
+	sp887x_writereg(state, 0x312, 0x002);
+	sp887x_writereg(state, 0x306, 0x000);
+	sp887x_writereg(state, 0x303, 0x000);
 }
 
-
 #define BLOCKSIZE 30
-
+#define FW_SIZE 0x4000
 /**
  *  load firmware and setup MPEG interface...
  */
-static
-int sp887x_initial_setup (struct dvb_frontend *fe)
+static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware *fw)
 {
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
 	u8 buf [BLOCKSIZE+2];
-	unsigned char *firmware = NULL;
 	int i;
-	int fd;
-	int filesize;
-	int fw_size;
-	mm_segment_t fs;
+	int fw_size = fw->size;
+	unsigned char *mem = fw->data;
 
 	dprintk("%s\n", __FUNCTION__);
 
-	/* soft reset */
-	sp887x_writereg(fe, 0xf1a, 0x000);
+	/* ignore the first 10 bytes, then we expect 0x4000 bytes of firmware */
+	if (fw_size < FW_SIZE+10)
+		return -ENODEV;
 
-	sp887x_microcontroller_stop (fe);
+	mem = fw->data + 10;
 
-	fs = get_fs();
+	/* soft reset */
+	sp887x_writereg(state, 0xf1a, 0x000);
 
-	// Load the firmware
-	set_fs(get_ds());
-	fd = sys_open(sp887x_firmware, 0, 0);
-	if (fd < 0) {
-		printk(KERN_WARNING "%s: Unable to open firmware %s\n", __FUNCTION__,
-		       sp887x_firmware);
-		return -EIO;
-	}
-	filesize = sys_lseek(fd, 0L, 2);
-	if (filesize <= 0) {
-		printk(KERN_WARNING "%s: Firmware %s is empty\n", __FUNCTION__,
-		       sp887x_firmware);
-		sys_close(fd);
-		return -EIO;
-	}
-
-	fw_size = 0x4000;
-
-	// allocate buffer for it
-	firmware = vmalloc(fw_size);
-	if (firmware == NULL) {
-		printk(KERN_WARNING "%s: Out of memory loading firmware\n",
-		       __FUNCTION__);
-		sys_close(fd);
-		return -EIO;
-	}
-
-	// read it!
-	// read the first 16384 bytes from the file
-	// ignore the first 10 bytes
-	sys_lseek(fd, 10, 0);
-	if (sys_read(fd, firmware, fw_size) != fw_size) {
-		printk(KERN_WARNING "%s: Failed to read firmware\n", __FUNCTION__);
-		vfree(firmware);
-		sys_close(fd);
-		return -EIO;
-	}
-	sys_close(fd);
-	set_fs(fs);
+	sp887x_microcontroller_stop (state);
 
 	printk ("%s: firmware upload... ", __FUNCTION__);
 
 	/* setup write pointer to -1 (end of memory) */
 	/* bit 0x8000 in address is set to enable 13bit mode */
-	sp887x_writereg(fe, 0x8f08, 0x1fff);
+	sp887x_writereg(state, 0x8f08, 0x1fff);
 
 	/* dummy write (wrap around to start of memory) */
-	sp887x_writereg(fe, 0x8f0a, 0x0000);
+	sp887x_writereg(state, 0x8f0a, 0x0000);
 
-	for (i=0; i<fw_size; i+=BLOCKSIZE) {
+	for (i = 0; i < FW_SIZE; i += BLOCKSIZE) {
 		int c = BLOCKSIZE;
 		int err;
 
-		if (i+c > fw_size)
-			c = fw_size - i;
+		if (i+c > FW_SIZE)
+			c = FW_SIZE - i;
 
 		/* bit 0x8000 in address is set to enable 13bit mode */
 		/* bit 0x4000 enables multibyte read/write transfers */
@@ -268,83 +180,51 @@
 		buf[0] = 0xcf;
 		buf[1] = 0x0a;
 
-		memcpy(&buf[2], firmware + i, c);
+		memcpy(&buf[2], mem + i, c);
 
-		if ((err = i2c_writebytes (fe, 0x70, buf, c+2)) < 0) {
+		if ((err = i2c_writebytes (state, buf, c+2)) < 0) {
 			printk ("failed.\n");
 			printk ("%s: i2c error (err == %i)\n", __FUNCTION__, err);
-			vfree(firmware);
 			return err;
 		}
 	}
 
-	vfree(firmware);
-
 	/* don't write RS bytes between packets */
-	sp887x_writereg(fe, 0xc13, 0x001);
+	sp887x_writereg(state, 0xc13, 0x001);
 
 	/* suppress clock if (!data_valid) */
-	sp887x_writereg(fe, 0xc14, 0x000);
+	sp887x_writereg(state, 0xc14, 0x000);
 
 	/* setup MPEG interface... */
-	sp887x_writereg(fe, 0xc1a, 0x872);
-	sp887x_writereg(fe, 0xc1b, 0x001);
-	sp887x_writereg(fe, 0xc1c, 0x000); /* parallel mode (serial mode == 1) */
-	sp887x_writereg(fe, 0xc1a, 0x871);
+	sp887x_writereg(state, 0xc1a, 0x872);
+	sp887x_writereg(state, 0xc1b, 0x001);
+	sp887x_writereg(state, 0xc1c, 0x000); /* parallel mode (serial mode == 1) */
+	sp887x_writereg(state, 0xc1a, 0x871);
 
 	/* ADC mode, 2 for MT8872, 3 for SP8870/SP8871 */
-	sp887x_writereg(fe, 0x301, 0x002);
+	sp887x_writereg(state, 0x301, 0x002);
 
-	sp887x_setup_agc(fe);
+	sp887x_setup_agc(state);
 
 	/* bit 0x010: enable data valid signal */
-	sp887x_writereg(fe, 0xd00, 0x010);
-	sp887x_writereg(fe, 0x0d1, 0x000);
+	sp887x_writereg(state, 0xd00, 0x010);
+	sp887x_writereg(state, 0x0d1, 0x000);
+
+	/* setup the PLL */
+	if (state->config->pll_init) {
+		sp887x_writereg(state, 0x206, 0x001);
+		state->config->pll_init(fe);
+		sp887x_writereg(state, 0x206, 0x000);
+	}
 
 	printk ("done.\n");
 	return 0;
 };
 
-
-/**
- *  returns the actual tuned center frequency which can be used
- *  to initialise the AFC registers
- */
-static
-int tsa5060_setup_pll (struct dvb_frontend *fe, int freq)
-{
-	u8 cfg, cpump, band_select;
-	u8 buf [4];
-	u32 div;
-
-	div = (36000000 + freq + 83333) / 166666;
-	cfg = 0x88;
-
-	cpump = freq < 175000000 ? 2 : freq < 390000000 ? 1 :
-		freq < 470000000 ? 2 : freq < 750000000 ? 2 : 3;
-
-	band_select = freq < 175000000 ? 0x0e : freq < 470000000 ? 0x05 : 0x03;
-
-	buf [0] = (div >> 8) & 0x7f;
-	buf [1] = div & 0xff;
-	buf [2] = ((div >> 10) & 0x60) | cfg;
-	buf [3] = cpump | band_select;
-
-	/* open i2c gate for PLL message transmission... */
-	sp887x_writereg(fe, 0x206, 0x001);
-	i2c_writebytes(fe, 0x60, buf, 4);
-	sp887x_writereg(fe, 0x206, 0x000);
-
-	return (div * 166666 - 36000000);
-}
-
-
-
-static
-int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
+static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
 {
 	int known_parameters = 1;
-	
+
 	*reg0xc05 = 0x000;
 
 	switch (p->u.ofdm.constellation) {
@@ -412,13 +292,11 @@
 	return 0;
 }
 
-
 /**
  *  estimates division of two 24bit numbers,
  *  derived from the ves1820/stv0299 driver code
  */
-static
-void divide (int n, int d, int *quotient_i, int *quotient_f)
+static void divide (int n, int d, int *quotient_i, int *quotient_f)
 {
 	unsigned int q, r;
 
@@ -436,9 +314,7 @@
 	}
 }
 
-
-static
-void sp887x_correct_offsets (struct dvb_frontend *fe,
+static void sp887x_correct_offsets (struct sp887x_state* state,
 			     struct dvb_frontend_parameters *p,
 			     int actual_freq)
 {
@@ -461,19 +337,31 @@
 		frequency_shift = -frequency_shift;
 
 	/* sample rate correction */
-	sp887x_writereg(fe, 0x319, srate_correction[bw_index] >> 12);
-	sp887x_writereg(fe, 0x31a, srate_correction[bw_index] & 0xfff);
+	sp887x_writereg(state, 0x319, srate_correction[bw_index] >> 12);
+	sp887x_writereg(state, 0x31a, srate_correction[bw_index] & 0xfff);
 
 	/* carrier offset correction */
-	sp887x_writereg(fe, 0x309, frequency_shift >> 12);
-	sp887x_writereg(fe, 0x30a, frequency_shift & 0xfff);
+	sp887x_writereg(state, 0x309, frequency_shift >> 12);
+	sp887x_writereg(state, 0x30a, frequency_shift & 0xfff);
 }
 
 
-static
-int sp887x_setup_frontend_parameters (struct dvb_frontend *fe,
+
+
+
+
+
+
+
+
+
+
+
+
+static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
 				      struct dvb_frontend_parameters *p)
 {
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
 	int actual_freq, err;
 	u16 val, reg0xc05;
 
@@ -481,18 +369,21 @@
 	    p->u.ofdm.bandwidth != BANDWIDTH_7_MHZ &&
 	    p->u.ofdm.bandwidth != BANDWIDTH_6_MHZ)
 		return -EINVAL;
-	
+
 	if ((err = configure_reg0xc05(p, &reg0xc05)))
 		return err;
 
-	sp887x_microcontroller_stop(fe);
+	sp887x_microcontroller_stop(state);
 
-	actual_freq = tsa5060_setup_pll(fe, p->frequency);
+	/* setup the PLL */
+	sp887x_writereg(state, 0x206, 0x001);
+	actual_freq = state->config->pll_set(fe, p);
+	sp887x_writereg(state, 0x206, 0x000);
 
-	/* read status reg in order to clear pending irqs */
-	sp887x_readreg(fe, 0x200);
+	/* read status reg in order to clear <pending irqs */
+	sp887x_readreg(state, 0x200);
 
-	sp887x_correct_offsets(fe, p, actual_freq);
+	sp887x_correct_offsets(state, p, actual_freq);
 
 	/* filter for 6/7/8 Mhz channel */
 	if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
@@ -502,15 +393,15 @@
 	else
 		val = 0;
 
-	sp887x_writereg(fe, 0x311, val);
+	sp887x_writereg(state, 0x311, val);
 
 	/* scan order: 2k first = 0, 8k first = 1 */
 	if (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_2K)
-		sp887x_writereg(fe, 0x338, 0x000);
+		sp887x_writereg(state, 0x338, 0x000);
 	else
-		sp887x_writereg(fe, 0x338, 0x001);
+		sp887x_writereg(state, 0x338, 0x001);
 
-	sp887x_writereg(fe, 0xc05, reg0xc05);
+	sp887x_writereg(state, 0xc05, reg0xc05);
 
 	if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
 		val = 2 << 3;
@@ -522,28 +413,19 @@
 	/* enable OFDM and SAW bits as lock indicators in sync register 0xf17,
 	 * optimize algorithm for given bandwidth...
 	 */
-	sp887x_writereg(fe, 0xf14, 0x160 | val);
-	sp887x_writereg(fe, 0xf15, 0x000);
+	sp887x_writereg(state, 0xf14, 0x160 | val);
+	sp887x_writereg(state, 0xf15, 0x000);
 
-	sp887x_microcontroller_start(fe);
+	sp887x_microcontroller_start(state);
 	return 0;
 }
 
-
-static
-int sp887x_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-        switch (cmd) {
-        case FE_GET_INFO:
-		memcpy (arg, &sp887x_info, sizeof(struct dvb_frontend_info));
-		break;
-
-        case FE_READ_STATUS:
+static int sp887x_read_status(struct dvb_frontend* fe, fe_status_t* status)
 	{
-		u16 snr12 = sp887x_readreg(fe, 0xf16);
-		u16 sync0x200 = sp887x_readreg(fe, 0x200);
-		u16 sync0xf17 = sp887x_readreg(fe, 0xf17);
-		fe_status_t *status = arg;
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
+	u16 snr12 = sp887x_readreg(state, 0xf16);
+	u16 sync0x200 = sp887x_readreg(state, 0x200);
+	u16 sync0xf17 = sp887x_readreg(state, 0xf17);
 
 		*status = 0;
 
@@ -569,128 +451,172 @@
 			       steps);
 		}
 
-		break;
-
+	return 0;
 	}
 
-        case FE_READ_BER:
+static int sp887x_read_ber(struct dvb_frontend* fe, u32* ber)
 	{
-		u32* ber = arg;
-		*ber = (sp887x_readreg(fe, 0xc08) & 0x3f) |
-		       (sp887x_readreg(fe, 0xc07) << 6);
-		sp887x_writereg(fe, 0xc08, 0x000);
-		sp887x_writereg(fe, 0xc07, 0x000);
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
+
+	*ber = (sp887x_readreg(state, 0xc08) & 0x3f) |
+	       (sp887x_readreg(state, 0xc07) << 6);
+	sp887x_writereg(state, 0xc08, 0x000);
+	sp887x_writereg(state, 0xc07, 0x000);
 		if (*ber >= 0x3fff0)
 			*ber = ~0;
-		break;
 
+	return 0;
 	}
 
-        case FE_READ_SIGNAL_STRENGTH:		// FIXME: correct registers ?
+static int sp887x_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 	{
-		u16 snr12 = sp887x_readreg(fe, 0xf16);
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
+
+	u16 snr12 = sp887x_readreg(state, 0xf16);
 		u32 signal = 3 * (snr12 << 4);
-		*((u16*) arg) = (signal < 0xffff) ? signal : 0xffff;
-		break;
-	}
+	*strength = (signal < 0xffff) ? signal : 0xffff;
 
-        case FE_READ_SNR:
-	{
-		u16 snr12 = sp887x_readreg(fe, 0xf16);
-		*(u16*) arg = (snr12 << 4) | (snr12 >> 8);
-		break;
+	return 0;
 	}
 
-	case FE_READ_UNCORRECTED_BLOCKS:
+static int sp887x_read_snr(struct dvb_frontend* fe, u16* snr)
 	{
-		u32 *ublocks = (u32 *) arg;
-		*ublocks = sp887x_readreg(fe, 0xc0c);
-		if (*ublocks == 0xfff)
-			*ublocks = ~0;
-		break;
-	}
-
-        case FE_SET_FRONTEND:
-		return sp887x_setup_frontend_parameters(fe, arg);
-
-	case FE_GET_FRONTEND:  // FIXME: read known values back from Hardware...
-		break;
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
 
-        case FE_SLEEP:
-		/* tristate TS output and disable interface pins */
-		sp887x_writereg(fe, 0xc18, 0x000);
-		break;
-
-        case FE_INIT:
-		if (fe->data == NULL) {	  /* first time initialisation... */
-			fe->data = (void*) ~0;
-			sp887x_initial_setup (fe);
-		}
-		/* enable TS output and interface pins */
-		sp887x_writereg(fe, 0xc18, 0x00d);
-		break;
+	u16 snr12 = sp887x_readreg(state, 0xf16);
+	*snr = (snr12 << 4) | (snr12 >> 8);
 
-	case FE_GET_TUNE_SETTINGS:
-	{
-	        struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
-	        fesettings->min_delay_ms = 50;
-	        fesettings->step_size = 0;
-	        fesettings->max_drift = 0;
 	        return 0;
-	}	    
+	}
 
-	default:
-		return -EOPNOTSUPP;
-        };
+static int sp887x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
+
+	*ucblocks = sp887x_readreg(state, 0xc0c);
+	if (*ucblocks == 0xfff)
+		*ucblocks = ~0;
 
         return 0;
 }
 
+static int sp887x_sleep(struct dvb_frontend* fe)
+{
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
 
+	/* tristate TS output and disable interface pins */
+	sp887x_writereg(state, 0xc18, 0x000);
 
-static
-int sp887x_attach (struct dvb_i2c_bus *i2c, void **data)
+	return 0;
+	}
+
+static int sp887x_init(struct dvb_frontend* fe)
 {
-	struct i2c_msg msg = {.addr = 0x70, .flags = 0, .buf = NULL, .len = 0 };
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
+        const struct firmware *fw = NULL;
+	int ret;
 
-	dprintk ("%s\n", __FUNCTION__);
+	if (!state->initialised) {
+	/* request the firmware, this will block until someone uploads it */
+	printk("sp887x: waiting for firmware upload...\n");
+		ret = state->config->request_firmware(fe, &fw, SP887X_DEFAULT_FIRMWARE);
+	if (ret) {
+		printk("sp887x: no firmware upload (timeout or file not found?)\n");
+			return ret;
+	}
 
-	if (i2c->xfer (i2c, &msg, 1) != 1)
-                return -ENODEV;
+		ret = sp887x_initial_setup(fe, fw);
+	if (ret) {
+		printk("sp887x: writing firmware to device failed\n");
+			release_firmware(fw);
+			return ret;
+	}
+		state->initialised = 1;
+	}
 
-	return dvb_register_frontend (sp887x_ioctl, i2c, NULL, &sp887x_info);
-}
+	/* enable TS output and interface pins */
+	sp887x_writereg(state, 0xc18, 0x00d);
 
+	return 0;
+}
 
-static
-void sp887x_detach (struct dvb_i2c_bus *i2c, void *data)
+static int sp887x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
 {
-	dprintk ("%s\n", __FUNCTION__);
-	dvb_unregister_frontend (sp887x_ioctl, i2c);
+        fesettings->min_delay_ms = 350;
+        fesettings->step_size = 166666*2;
+        fesettings->max_drift = (166666*2)+1;
+        return 0;
 }
 
-
-static
-int __init init_sp887x (void)
+static void sp887x_release(struct dvb_frontend* fe)
 {
-	dprintk ("%s\n", __FUNCTION__);
-	return dvb_register_i2c_device (NULL, sp887x_attach, sp887x_detach);
+	struct sp887x_state* state = (struct sp887x_state*) fe->demodulator_priv;
+	kfree(state);
 }
 
+static struct dvb_frontend_ops sp887x_ops;
 
-static
-void __exit exit_sp887x (void)
+struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
+				   struct i2c_adapter* i2c)
 {
-	dprintk ("%s\n", __FUNCTION__);
-	dvb_unregister_i2c_device (sp887x_attach);
+	struct sp887x_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct sp887x_state*) kmalloc(sizeof(struct sp887x_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &sp887x_ops, sizeof(struct dvb_frontend_ops));
+	state->initialised = 0;
+
+	/* check if the demod is there */
+	if (sp887x_readreg(state, 0x0200) < 0) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
 }
 
+static struct dvb_frontend_ops sp887x_ops = {
 
-module_init(init_sp887x);
-module_exit(exit_sp887x);
+	.info = {
+		.name = "Spase SP887x DVB-T",
+		.type = FE_OFDM,
+		.frequency_min =  50500000,
+		.frequency_max = 858000000,
+		.frequency_stepsize = 166666,
+		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+			FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
+	                FE_CAN_RECOVER
+	},
 
+	.release = sp887x_release,
 
-MODULE_DESCRIPTION("sp887x DVB-T demodulator driver");
-MODULE_LICENSE("GPL");
+	.init = sp887x_init,
+	.sleep = sp887x_sleep,
 
+	.set_frontend = sp887x_setup_frontend_parameters,
+	.get_tune_settings = sp887x_get_tune_settings,
+
+	.read_status = sp887x_read_status,
+	.read_ber = sp887x_read_ber,
+	.read_signal_strength = sp887x_read_signal_strength,
+	.read_snr = sp887x_read_snr,
+	.read_ucblocks = sp887x_read_ucblocks,
+};
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
+
+MODULE_DESCRIPTION("Spase sp887x DVB-T demodulator driver");
+MODULE_LICENSE("GPL");
 
+EXPORT_SYMBOL(sp887x_attach);
diff -Nru a/drivers/media/dvb/frontends/sp887x.h b/drivers/media/dvb/frontends/sp887x.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/sp887x.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,29 @@
+/*
+   Driver for the Spase sp887x demodulator
+*/
+
+#ifndef SP887X_H
+#define SP887X_H
+
+#include <linux/dvb/frontend.h>
+#include <linux/firmware.h>
+
+struct sp887x_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+
+	/* this should return the actual frequency tuned to */
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+
+	/* request firmware for device */
+	int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
+};
+
+extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
+					  struct i2c_adapter* i2c);
+
+#endif // SP887X_H
diff -Nru a/drivers/media/dvb/frontends/sp887x_firm.h b/drivers/media/dvb/frontends/sp887x_firm.h
--- a/drivers/media/dvb/frontends/sp887x_firm.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1375 +0,0 @@
-#ifndef __SP887x_FIRM_H__
-#define __SP887x_FIRM_H__
-
-
-static const
-u8 sp887x_firm [16384] __devinitdata = {
-	0x00, 0xb9, 0x00, 0xb9, 0x0f, 0xf9, 0x1f, 0x5d, 0x0f, 0xf9, 0x1b, 0x67,
-	0x0f, 0xf9, 0x19, 0x2f, 0x0f, 0xf9, 0x00, 0x36, 0x0f, 0xf9, 0x00, 0x3c,
-	0x0f, 0xf5, 0x00, 0x3e, 0x0f, 0xf9, 0x03, 0x0c, 0x0f, 0xf9, 0x0c, 0x59,
-	0x0f, 0xf9, 0x15, 0xde, 0x0f, 0xf9, 0x19, 0x07, 0x0f, 0xf9, 0x08, 0x98,
-	0x0f, 0xf9, 0x08, 0x03, 0x0f, 0xf9, 0x00, 0x26, 0x0f, 0xf9, 0x03, 0x11,
-	0x0f, 0xf9, 0x1b, 0x47, 0x0f, 0xf9, 0x00, 0x76, 0x0f, 0xf9, 0x0a, 0xdd,
-	0x0f, 0xf9, 0x0d, 0x09, 0x0f, 0xc4, 0x01, 0x62, 0x0b, 0x21, 0x0f, 0x38,
-	0x00, 0x15, 0x0f, 0xf8, 0x00, 0x32, 0x09, 0xa1, 0x0f, 0xf9, 0x04, 0x2e,
-	0x0f, 0xf9, 0x04, 0x5e, 0x0f, 0xd9, 0x00, 0x2e, 0x09, 0xfb, 0x0f, 0x39,
-	0x0f, 0xf0, 0x02, 0x02, 0x0f, 0xc4, 0x01, 0x7a, 0x0f, 0xf9, 0x00, 0x42,
-	0x0f, 0xf0, 0x02, 0x05, 0x0f, 0xc4, 0x01, 0x7b, 0x0f, 0xf9, 0x00, 0x42,
-	0x0b, 0x21, 0x0f, 0xc4, 0x01, 0x7c, 0x0f, 0xd4, 0x02, 0xa0, 0x1f, 0xf8,
-	0x00, 0x53, 0x11, 0xa1, 0x0f, 0xd4, 0x00, 0xa0, 0x1f, 0xf8, 0x00, 0x53,
-	0x11, 0xe1, 0x08, 0x15, 0x1f, 0x39, 0x0f, 0x38, 0x0c, 0x32, 0x0b, 0x13,
-	0x00, 0x08, 0x10, 0x48, 0x0f, 0x38, 0x0c, 0x32, 0x00, 0x21, 0x07, 0x04,
-	0x0b, 0x94, 0x1b, 0x94, 0x1f, 0x39, 0x06, 0x45, 0x0b, 0xd5, 0x1f, 0xf9,
-	0x00, 0x65, 0x0b, 0xd5, 0x1f, 0xf9, 0x00, 0x65, 0x0f, 0x39, 0x07, 0x84,
-	0x0b, 0x27, 0x09, 0xa1, 0x06, 0xc5, 0x0b, 0x67, 0x09, 0x94, 0x1f, 0xf9,
-	0x00, 0x6f, 0x0f, 0x38, 0x09, 0x97, 0x06, 0x44, 0x07, 0x05, 0x0b, 0xa1,
-	0x0b, 0xd8, 0x0b, 0xa1, 0x0f, 0x38, 0x0b, 0xd2, 0x0f, 0xcb, 0x01, 0x39,
-	0x0f, 0xf5, 0x02, 0x47, 0x0f, 0xf4, 0x02, 0x5d, 0x06, 0x0b, 0x05, 0x85,
-	0x0b, 0xea, 0x0b, 0xe1, 0x02, 0xde, 0x09, 0xeb, 0x0f, 0xee, 0x01, 0xc0,
-	0x0f, 0xee, 0x0a, 0x01, 0x0f, 0xcf, 0x0c, 0x80, 0x0e, 0x2a, 0x0e, 0x6b,
-	0x0f, 0xec, 0x06, 0xbe, 0x09, 0x2d, 0x0d, 0xee, 0x0f, 0xc4, 0x00, 0x95,
-	0x12, 0x35, 0x0f, 0xe1, 0x0d, 0xbd, 0x0e, 0x18, 0x09, 0xec, 0x0f, 0xe1,
-	0x00, 0xcd, 0x0e, 0x51, 0x09, 0xed, 0x0d, 0xee, 0x0b, 0xe1, 0x02, 0xdf,
-	0x09, 0xe7, 0x0f, 0xe1, 0x05, 0x6d, 0x0e, 0x18, 0x09, 0xec, 0x0f, 0xe1,
-	0x02, 0x26, 0x0e, 0x51, 0x09, 0xed, 0x0d, 0xee, 0x12, 0x35, 0x0f, 0xe1,
-	0x0d, 0x03, 0x0f, 0xce, 0x03, 0xd2, 0x0e, 0x18, 0x09, 0xec, 0x0d, 0xa1,
-	0x0e, 0x51, 0x09, 0xed, 0x0d, 0xee, 0x0f, 0xcb, 0x0a, 0xe3, 0x0f, 0xe1,
-	0x08, 0x10, 0x0f, 0xce, 0x05, 0x88, 0x0e, 0x18, 0x09, 0xec, 0x0d, 0xa1,
-	0x0e, 0x51, 0x09, 0xed, 0x0d, 0xee, 0x0f, 0xca, 0x09, 0x00, 0x0f, 0xe1,
-	0x00, 0x38, 0x0f, 0xce, 0x07, 0xa7, 0x0e, 0x18, 0x09, 0xec, 0x0d, 0xa1,
-	0x0e, 0x51, 0x09, 0xed, 0x0d, 0xee, 0x0f, 0xe2, 0x00, 0x3f, 0x0f, 0xe1,
-	0x0a, 0xb1, 0x0f, 0xce, 0x0b, 0x89, 0x0e, 0x18, 0x09, 0xec, 0x0d, 0xa1,
-	0x0e, 0x51, 0x09, 0xed, 0x0d, 0xee, 0x0f, 0xc9, 0x0a, 0x75, 0x0f, 0xe1,
-	0x03, 0xf3, 0x0f, 0xce, 0x07, 0x15, 0x0e, 0x18, 0x09, 0xec, 0x0d, 0xa1,
-	0x0e, 0x53, 0x09, 0xed, 0x0d, 0xee, 0x0f, 0xcf, 0x07, 0xc0, 0x0d, 0xce,
-	0x1f, 0xce, 0x01, 0xc0, 0x00, 0x21, 0x0d, 0xae, 0x0c, 0x6e, 0x09, 0x96,
-	0x0f, 0xce, 0x05, 0x00, 0x0f, 0xcd, 0x05, 0x40, 0x0f, 0xcc, 0x03, 0x00,
-	0x09, 0xab, 0x00, 0x2a, 0x0d, 0xee, 0x1d, 0xae, 0x1e, 0x18, 0x19, 0xea,
-	0x1e, 0x58, 0x19, 0xeb, 0x1d, 0x6e, 0x1e, 0x18, 0x19, 0xec, 0x1e, 0x51,
-	0x19, 0xed, 0x1d, 0x2e, 0x0c, 0xee, 0x0f, 0xe1, 0x1f, 0xe7, 0x0c, 0xae,
-	0x05, 0x84, 0x0e, 0x02, 0x0e, 0x42, 0x0e, 0xa4, 0x09, 0x99, 0x09, 0xe1,
-	0x02, 0xdc, 0x12, 0xdd, 0x0f, 0x38, 0x09, 0xc2, 0x0f, 0xfb, 0x00, 0x7d,
-	0x03, 0x37, 0x0f, 0xc4, 0x00, 0x9e, 0x05, 0xb7, 0x0f, 0xf5, 0x01, 0x39,
-	0x0f, 0xfb, 0x00, 0x7d, 0x03, 0x37, 0x0f, 0xc4, 0x00, 0xa1, 0x05, 0xb7,
-	0x0f, 0xf5, 0x01, 0x39, 0x05, 0x84, 0x0b, 0xaa, 0x0b, 0xab, 0x0f, 0xef,
-	0x01, 0xc0, 0x0b, 0x88, 0x0c, 0x27, 0x09, 0xa6, 0x18, 0xb4, 0x05, 0x84,
-	0x09, 0xa1, 0x0f, 0xd9, 0x0a, 0x69, 0x09, 0xee, 0x0f, 0xd7, 0x1f, 0xd0,
-	0x18, 0xb5, 0x02, 0x97, 0x0c, 0x21, 0x1f, 0xf8, 0x01, 0x36, 0x02, 0xde,
-	0x0f, 0xc4, 0x06, 0x28, 0x02, 0x34, 0x19, 0x44, 0x1f, 0xf9, 0x01, 0x45,
-	0x0f, 0xee, 0x05, 0x00, 0x00, 0x21, 0x0e, 0x18, 0x09, 0xea, 0x0e, 0x58,
-	0x09, 0xeb, 0x0f, 0xee, 0x05, 0x40, 0x0e, 0x18, 0x0f, 0xf8, 0x01, 0x4a,
-	0x09, 0xc9, 0x0e, 0x09, 0x0f, 0xee, 0x05, 0x00, 0x0e, 0x2a, 0x0e, 0x6b,
-	0x0f, 0xcf, 0x0c, 0x80, 0x0f, 0xec, 0x0e, 0x2d, 0x00, 0x2d, 0x0d, 0xee,
-	0x0f, 0xe1, 0x01, 0xa4, 0x01, 0x4e, 0x0e, 0x20, 0x09, 0xec, 0x0d, 0xa1,
-	0x0e, 0x59, 0x09, 0xed, 0x0d, 0xee, 0x0f, 0xe1, 0x0a, 0x35, 0x0f, 0xce,
-	0x00, 0x27, 0x0e, 0x20, 0x09, 0xec, 0x0d, 0xa1, 0x0e, 0x59, 0x09, 0xed,
-	0x0d, 0xee, 0x0f, 0xe1, 0x04, 0x34, 0x0f, 0xce, 0x00, 0xe3, 0x0e, 0x20,
-	0x09, 0xec, 0x0d, 0xa1, 0x0e, 0x59, 0x09, 0xed, 0x0d, 0xee, 0x0f, 0xe1,
-	0x0f, 0xb1, 0x0f, 0xce, 0x03, 0xd7, 0x0e, 0x20, 0x09, 0xec, 0x0d, 0xa1,
-	0x0e, 0x59, 0x09, 0xed, 0x0d, 0xee, 0x0f, 0xe1, 0x02, 0x15, 0x0f, 0xce,
-	0x0b, 0x17, 0x0e, 0x20, 0x09, 0xec, 0x0d, 0xa1, 0x0e, 0x59, 0x09, 0xed,
-	0x0d, 0xee, 0x0f, 0xcf, 0x0a, 0xbf, 0x0f, 0xce, 0x09, 0x00, 0x0d, 0xee,
-	0x0c, 0x61, 0x0d, 0xae, 0x0e, 0x02, 0x0e, 0x42, 0x0e, 0x99, 0x09, 0xe1,
-	0x12, 0xdf, 0x12, 0x34, 0x19, 0x44, 0x02, 0xdc, 0x0f, 0x38, 0x09, 0xc2,
-	0x09, 0x44, 0x0f, 0xc2, 0x0f, 0xff, 0x0f, 0xc2, 0x0f, 0xff, 0x0f, 0xc2,
-	0x03, 0xff, 0x0f, 0xc4, 0x00, 0x95, 0x0f, 0xc2, 0x0f, 0xff, 0x0f, 0xc2,
-	0x0f, 0xff, 0x0f, 0xc2, 0x0b, 0xff, 0x0f, 0xc4, 0x00, 0x98, 0x00, 0x02,
-	0x0f, 0xc2, 0x08, 0x00, 0x0f, 0xc2, 0x04, 0x00, 0x0f, 0xc4, 0x00, 0x9b,
-	0x00, 0x02, 0x0f, 0xc2, 0x08, 0x00, 0x0f, 0xc2, 0x0c, 0x00, 0x0f, 0xc4,
-	0x00, 0x9e, 0x0f, 0xc2, 0x08, 0xc1, 0x0f, 0xc2, 0x0c, 0x0a, 0x00, 0x42,
-	0x0f, 0xc4, 0x00, 0xa1, 0x0f, 0xc2, 0x08, 0xc1, 0x0f, 0xc2, 0x0c, 0x0a,
-	0x00, 0x82, 0x0f, 0xc4, 0x00, 0xa4, 0x00, 0x02, 0x0f, 0xc2, 0x0a, 0x00,
-	0x00, 0xc2, 0x0f, 0xc4, 0x00, 0xa7, 0x00, 0x02, 0x0f, 0xc2, 0x0c, 0x80,
-	0x0f, 0xf4, 0x04, 0xe0, 0x01, 0x82, 0x0f, 0xc4, 0x01, 0x5d, 0x0b, 0x3b,
-	0x0f, 0x39, 0x04, 0x04, 0x0b, 0x21, 0x0f, 0xc4, 0x01, 0x5c, 0x0f, 0xc5,
-	0x07, 0x3d, 0x0b, 0x01, 0x0b, 0x14, 0x1f, 0x39, 0x00, 0x14, 0x09, 0xc0,
-	0x0f, 0xc8, 0x04, 0x18, 0x00, 0xd4, 0x1f, 0xc8, 0x1b, 0xb6, 0x00, 0x54,
-	0x1f, 0xc8, 0x1c, 0xa7, 0x01, 0x14, 0x1f, 0xc8, 0x1c, 0x9f, 0x00, 0x94,
-	0x1f, 0xc4, 0x01, 0x5e, 0x1b, 0x08, 0x02, 0x94, 0x1f, 0xc8, 0x04, 0x24,
-	0x02, 0xd4, 0x1f, 0xc8, 0x04, 0x26, 0x03, 0x14, 0x1f, 0xc8, 0x04, 0x28,
-	0x03, 0x54, 0x1f, 0xc8, 0x04, 0x2a, 0x03, 0x94, 0x1f, 0xc8, 0x04, 0x2c,
-	0x03, 0xd4, 0x1f, 0xc8, 0x04, 0x2e, 0x05, 0x14, 0x1f, 0xc8, 0x04, 0x30,
-	0x0f, 0xd4, 0x00, 0x28, 0x1f, 0xc8, 0x08, 0xeb, 0x0f, 0xd4, 0x00, 0x29,
-	0x1f, 0xc8, 0x09, 0x49, 0x0f, 0xd4, 0x00, 0x2a, 0x1f, 0xc8, 0x09, 0xe6,
-	0x0f, 0xd4, 0x00, 0x2b, 0x1f, 0xc8, 0x0b, 0x54, 0x0f, 0xd4, 0x00, 0x32,
-	0x1f, 0xc8, 0x0b, 0x87, 0x0f, 0xd4, 0x00, 0x3c, 0x1f, 0xc8, 0x0b, 0xcf,
-	0x0f, 0xd4, 0x00, 0x46, 0x1f, 0xc8, 0x11, 0x95, 0x0f, 0xd4, 0x00, 0x47,
-	0x1f, 0xc8, 0x11, 0xb9, 0x0f, 0xd4, 0x00, 0x3f, 0x1f, 0xc8, 0x09, 0x85,
-	0x0f, 0xd4, 0x00, 0x40, 0x1f, 0xc8, 0x09, 0x89, 0x0f, 0xd4, 0x00, 0x41,
-	0x1f, 0xc8, 0x09, 0xcb, 0x02, 0x14, 0x1f, 0xc8, 0x04, 0x18, 0x0f, 0xd4,
-	0x00, 0x50, 0x1f, 0xc8, 0x0e, 0xd9, 0x0f, 0xc4, 0x01, 0x5d, 0x0f, 0x38,
-	0x0c, 0x00, 0x0f, 0xc8, 0x01, 0x00, 0x0f, 0xf7, 0x05, 0x82, 0x0f, 0xc4,
-	0x01, 0x8b, 0x00, 0x00, 0x0f, 0xc4, 0x01, 0x8a, 0x00, 0x00, 0x0f, 0xf1,
-	0x03, 0x39, 0x0f, 0xc5, 0x01, 0x89, 0x0f, 0xc4, 0x01, 0x8e, 0x0b, 0x21,
-	0x0a, 0x48, 0x0c, 0x13, 0x1f, 0xf8, 0x02, 0x5f, 0x0c, 0x01, 0x0f, 0xc4,
-	0x01, 0x90, 0x00, 0x21, 0x0b, 0x15, 0x1f, 0xc5, 0x01, 0x8b, 0x1c, 0x01,
-	0x1f, 0xc5, 0x01, 0x8a, 0x1b, 0x3a, 0x1b, 0x01, 0x0f, 0xf1, 0x03, 0x39,
-	0x0f, 0xc4, 0x01, 0x8e, 0x0b, 0x21, 0x0a, 0x48, 0x0c, 0x12, 0x1f, 0xf9,
-	0x02, 0x4b, 0x0f, 0xc4, 0x01, 0x8c, 0x0f, 0xf6, 0x05, 0x9d, 0x0c, 0x00,
-	0x0f, 0xf1, 0x03, 0x39, 0x0f, 0xc4, 0x01, 0x8d, 0x1f, 0x38, 0x0a, 0x40,
-	0x0f, 0xc5, 0x01, 0x88, 0x0b, 0x01, 0x0f, 0xc4, 0x01, 0x89, 0x0f, 0xc5,
-	0x07, 0x3b, 0x0b, 0x01, 0x0f, 0xc4, 0x01, 0x8b, 0x0f, 0xc5, 0x07, 0x3c,
-	0x0b, 0x01, 0x0f, 0xc4, 0x01, 0x8c, 0x0f, 0xc5, 0x01, 0x87, 0x0b, 0x01,
-	0x0f, 0xc4, 0x01, 0x8a, 0x0f, 0xc5, 0x01, 0x86, 0x0b, 0x01, 0x0f, 0xc4,
-	0x01, 0x6a, 0x0f, 0xc5, 0x01, 0x85, 0x0b, 0x01, 0x0f, 0xc4, 0x01, 0x6b,
-	0x0f, 0xc5, 0x01, 0x84, 0x0f, 0x38, 0x0b, 0x01, 0x0f, 0xc4, 0x01, 0x90,
-	0x0c, 0x40, 0x0c, 0x21, 0x0f, 0xd9, 0x00, 0x67, 0x09, 0xc8, 0x00, 0xb6,
-	0x00, 0x09, 0x0f, 0xf7, 0x04, 0x66, 0x0f, 0xc4, 0x06, 0x96, 0x0f, 0xc5,
-	0x06, 0x2b, 0x0f, 0xf7, 0x02, 0x74, 0x07, 0x04, 0x00, 0x02, 0x0f, 0xc2,
-	0x0c, 0x00, 0x0f, 0xf6, 0x02, 0x70, 0x01, 0x02, 0x05, 0x37, 0x0f, 0xf7,
-	0x04, 0x6f, 0x0f, 0xf7, 0x02, 0x09, 0x0f, 0xf7, 0x01, 0x33, 0x0f, 0xc4,
-	0x01, 0x8f, 0x07, 0x36, 0x0c, 0x00, 0x0f, 0xe1, 0x08, 0x0f, 0x1f, 0xe1,
-	0x02, 0x0f, 0x0c, 0x11, 0x0f, 0xc4, 0x01, 0x8e, 0x0f, 0x38, 0x09, 0xc0,
-	0x0f, 0xf0, 0x0f, 0x10, 0x0c, 0x32, 0x0f, 0xc4, 0x07, 0xc0, 0x0f, 0x38,
-	0x0c, 0x00, 0x0f, 0xf1, 0x0f, 0x11, 0x00, 0x08, 0x0a, 0x61, 0x00, 0x15,
-	0x11, 0x13, 0x10, 0x49, 0x10, 0x48, 0x0f, 0xf1, 0x0f, 0x13, 0x0f, 0xc4,
-	0x07, 0xbc, 0x0b, 0x22, 0x00, 0x00, 0x0a, 0x65, 0x09, 0xb2, 0x00, 0x21,
-	0x09, 0x95, 0x1c, 0x62, 0x10, 0xa5, 0x19, 0x89, 0x10, 0x48, 0x0c, 0x15,
-	0x1f, 0xf0, 0x02, 0x04, 0x0c, 0x72, 0x0f, 0xf0, 0x02, 0x03, 0x00, 0x32,
-	0x0f, 0x38, 0x00, 0x72, 0x0f, 0xfa, 0x02, 0xb8, 0x00, 0xc8, 0x0f, 0xf9,
-	0x02, 0xbf, 0x0f, 0xc4, 0x07, 0xba, 0x0f, 0xc0, 0x00, 0x40, 0x0f, 0xc4,
-	0x07, 0xbb, 0x00, 0x40, 0x0f, 0xc4, 0x07, 0xb8, 0x0f, 0xc0, 0x04, 0x00,
-	0x0f, 0xc4, 0x07, 0xb9, 0x0f, 0xc0, 0x08, 0x00, 0x0f, 0xc4, 0x07, 0xbd,
-	0x0f, 0xc0, 0x0f, 0xff, 0x0f, 0xc4, 0x07, 0xdd, 0x00, 0x00, 0x0f, 0xc4,
-	0x07, 0xc2, 0x0f, 0x38, 0x00, 0x40, 0x0f, 0xf8, 0x03, 0x03, 0x0b, 0x22,
-	0x0f, 0xf8, 0x03, 0x03, 0x0c, 0x22, 0x0f, 0xc4, 0x07, 0xbd, 0x0b, 0x24,
-	0x09, 0xa2, 0x0f, 0xc4, 0x07, 0xbc, 0x0b, 0x25, 0x0f, 0x38, 0x09, 0x80,
-	0x0f, 0xfa, 0x02, 0xb8, 0x00, 0x48, 0x0f, 0xf9, 0x02, 0xbf, 0x0f, 0xf0,
-	0x0f, 0x10, 0x0c, 0x32, 0x0a, 0xe1, 0x0f, 0xc5, 0x07, 0xc3, 0x0f, 0xf1,
-	0x0f, 0x10, 0x0a, 0x7f, 0x0f, 0xf0, 0x0f, 0x12, 0x0b, 0xf2, 0x0a, 0xd5,
-	0x1f, 0xf9, 0x03, 0x1a, 0x03, 0xb9, 0x0a, 0x44, 0x0f, 0xf1, 0x0f, 0x12,
-	0x0a, 0x7e, 0x0f, 0xfd, 0x03, 0x28, 0x00, 0x3f, 0x0b, 0x83, 0x07, 0x39,
-	0x0a, 0x45, 0x0f, 0xf1, 0x0f, 0x12, 0x0a, 0x7e, 0x0f, 0xfd, 0x03, 0x33,
-	0x00, 0x3f, 0x0f, 0xf1, 0x0f, 0x12, 0x0a, 0x43, 0x03, 0xb9, 0x0f, 0xc4,
-	0x07, 0x6e, 0x00, 0x00, 0x04, 0x04, 0x00, 0x40, 0x0f, 0xc4, 0x07, 0xdd,
-	0x00, 0x00, 0x0f, 0xc4, 0x07, 0xc2, 0x00, 0x40, 0x0f, 0xf0, 0x0f, 0x17,
-	0x03, 0xb8, 0x00, 0x32, 0x04, 0x04, 0x00, 0xc0, 0x0f, 0xc4, 0x07, 0xdd,
-	0x00, 0x40, 0x0f, 0xc4, 0x07, 0xc2, 0x03, 0xb8, 0x00, 0x40, 0x0f, 0xc4,
-	0x07, 0x6e, 0x00, 0x00, 0x04, 0x04, 0x01, 0x00, 0x0f, 0xc4, 0x07, 0xdd,
-	0x00, 0x00, 0x0f, 0xc4, 0x07, 0xc2, 0x03, 0xb8, 0x00, 0x40, 0x04, 0x04,
-	0x02, 0x00, 0x0f, 0xc4, 0x07, 0x6e, 0x00, 0x00, 0x0f, 0xc4, 0x07, 0xdd,
-	0x03, 0xb8, 0x00, 0x00, 0x0f, 0xc4, 0x01, 0x30, 0x0b, 0x83, 0x0b, 0x83,
-	0x0f, 0xc4, 0x01, 0x32, 0x0b, 0x83, 0x07, 0x38, 0x0b, 0x83, 0x0f, 0xc4,
-	0x06, 0x94, 0x0b, 0x83, 0x0b, 0x83, 0x0f, 0xc4, 0x01, 0x6c, 0x07, 0x38,
-	0x0b, 0x83, 0x0f, 0xc4, 0x01, 0x38, 0x0b, 0x83, 0x0b, 0x83, 0x0f, 0xc4,
-	0x01, 0x3a, 0x0b, 0x83, 0x0b, 0x83, 0x0f, 0xc4, 0x01, 0x3c, 0x0b, 0x83,
-	0x0b, 0x83, 0x0f, 0xc4, 0x01, 0x76, 0x0b, 0x83, 0x0f, 0xc4, 0x01, 0x77,
-	0x07, 0x38, 0x0b, 0x83, 0x0f, 0xc4, 0x01, 0x78, 0x0b, 0x83, 0x0f, 0xc4,
-	0x01, 0x79, 0x07, 0x38, 0x0b, 0x83, 0x0f, 0xc4, 0x05, 0xe6, 0x0b, 0x83,
-	0x0b, 0x83, 0x0f, 0xc4, 0x01, 0x40, 0x0b, 0x83, 0x07, 0x38, 0x0b, 0x83,
-	0x0f, 0xf1, 0x0f, 0x11, 0x0a, 0x48, 0x0c, 0x21, 0x02, 0x13, 0x1f, 0xf9,
-	0x02, 0xbf, 0x0f, 0xf1, 0x0f, 0x10, 0x00, 0x09, 0x02, 0x54, 0x13, 0x89,
-	0x02, 0xd4, 0x1f, 0xc9, 0x03, 0x35, 0x03, 0x54, 0x1f, 0xc9, 0x03, 0x44,
-	0x03, 0xd4, 0x1f, 0xc9, 0x03, 0x59, 0x0f, 0xd4, 0x00, 0x59, 0x1f, 0xc9,
-	0x03, 0x4d, 0x0f, 0xd4, 0x00, 0x41, 0x1f, 0xc9, 0x03, 0x21, 0x0f, 0xd4,
-	0x00, 0x49, 0x1f, 0xc9, 0x03, 0x2a, 0x0f, 0xd4, 0x00, 0x71, 0x1f, 0xc9,
-	0x03, 0x62, 0x0f, 0xd4, 0x00, 0x73, 0x1f, 0xc9, 0x03, 0x6b, 0x0f, 0xd4,
-	0x00, 0x80, 0x1f, 0xc9, 0x03, 0x73, 0x0f, 0xd4, 0x00, 0x81, 0x1f, 0xc9,
-	0x03, 0x86, 0x0f, 0xd4, 0x00, 0x82, 0x1f, 0xc9, 0x03, 0x8d, 0x0c, 0x61,
-	0x00, 0x15, 0x1f, 0xf1, 0x0f, 0x12, 0x1f, 0xc5, 0x07, 0xc3, 0x1c, 0x79,
-	0x0f, 0xf9, 0x02, 0xde, 0x0f, 0xfb, 0x03, 0x96, 0x0f, 0xc4, 0x07, 0xdd,
-	0x0b, 0x21, 0x00, 0x15, 0x1f, 0xf9, 0x03, 0xd4, 0x0f, 0x39, 0x0f, 0xc8,
-	0x00, 0x3c, 0x03, 0x3b, 0x1f, 0x39, 0x0f, 0xf1, 0x0a, 0x07, 0x00, 0x21,
-	0x0f, 0xc4, 0x01, 0x91, 0x0b, 0x08, 0x0f, 0xc4, 0x01, 0x92, 0x0b, 0x15,
-	0x1b, 0x08, 0x0c, 0x14, 0x1f, 0x39, 0x0c, 0x21, 0x0a, 0x55, 0x1f, 0xc4,
-	0x01, 0x93, 0x1c, 0x00, 0x1f, 0xc8, 0x03, 0xf6, 0x15, 0x3b, 0x0f, 0x39,
-	0x0f, 0xc4, 0x01, 0x93, 0x0b, 0x0f, 0x0d, 0xc8, 0x00, 0xb6, 0x00, 0x09,
-	0x05, 0x37, 0x0d, 0xe1, 0x02, 0x19, 0x09, 0xc8, 0x00, 0xb6, 0x00, 0x09,
-	0x0f, 0xf7, 0x02, 0x70, 0x0f, 0xc4, 0x00, 0xad, 0x00, 0x37, 0x01, 0xbb,
-	0x0f, 0xc8, 0x00, 0x60, 0x00, 0xb6, 0x00, 0x09, 0x0f, 0xc4, 0x00, 0xad,
-	0x0f, 0xf7, 0x02, 0x81, 0x0f, 0xf0, 0x0a, 0x07, 0x0f, 0xc4, 0x01, 0x93,
-	0x0b, 0x32, 0x0f, 0xc4, 0x00, 0xaa, 0x00, 0x35, 0x02, 0x3a, 0x00, 0x08,
-	0x02, 0xba, 0x00, 0x48, 0x0f, 0xfb, 0x03, 0xd4, 0x0f, 0xf6, 0x00, 0x3a,
-	0x02, 0x08, 0x1f, 0xf9, 0x04, 0x1c, 0x0f, 0x39, 0x0f, 0xf5, 0x05, 0xc7,
-	0x0f, 0xf5, 0x06, 0x07, 0x0f, 0xf5, 0x06, 0x14, 0x0f, 0xf5, 0x06, 0x79,
-	0x0f, 0xf5, 0x06, 0x98, 0x0f, 0xf5, 0x06, 0xbc, 0x0f, 0xc4, 0x06, 0x8f,
-	0x0b, 0x88, 0x00, 0xb6, 0x0b, 0x89, 0x03, 0x37, 0x02, 0x36, 0x04, 0xc4,
-	0x06, 0xbb, 0x1f, 0xf7, 0x00, 0x8f, 0x0f, 0xfb, 0x00, 0x7a, 0x0f, 0xc4,
-	0x00, 0xb0, 0x00, 0x37, 0x04, 0x44, 0x0f, 0xc5, 0x01, 0x94, 0x0b, 0x01,
-	0x0f, 0xf7, 0x06, 0xdc, 0x0f, 0xc4, 0x00, 0xb0, 0x02, 0x37, 0x04, 0x44,
-	0x0b, 0x21, 0x0f, 0xc4, 0x01, 0x94, 0x0b, 0x11, 0x01, 0x36, 0x09, 0xc8,
-	0x03, 0xb7, 0x0f, 0xc4, 0x06, 0x8f, 0x0c, 0x02, 0x03, 0x36, 0x0c, 0x42,
-	0x00, 0xb7, 0x05, 0x37, 0x04, 0x37, 0x06, 0xbb, 0x1f, 0xf7, 0x00, 0x8f,
-	0x00, 0x34, 0x04, 0xc4, 0x01, 0x38, 0x00, 0x48, 0x07, 0x37, 0x0f, 0xc4,
-	0x02, 0x0e, 0x0f, 0xc0, 0x08, 0xe1, 0x1f, 0xc0, 0x02, 0x39, 0x0f, 0xc4,
-	0x07, 0x38, 0x1f, 0xc4, 0x07, 0x37, 0x0f, 0xc5, 0x01, 0x95, 0x0b, 0x01,
-	0x0f, 0xc4, 0x07, 0x2e, 0x1f, 0xc4, 0x07, 0x2b, 0x02, 0x37, 0x0f, 0xc4,
-	0x05, 0xf2, 0x0b, 0x21, 0x01, 0x9e, 0x0f, 0xc5, 0x01, 0x96, 0x0f, 0xc4,
-	0x05, 0xea, 0x0b, 0x01, 0x1f, 0xc4, 0x05, 0xf0, 0x1b, 0x01, 0x0b, 0x61,
-	0x0f, 0xc4, 0x06, 0x2b, 0x00, 0x14, 0x1f, 0xc4, 0x07, 0x31, 0x00, 0x54,
-	0x1f, 0xc4, 0x07, 0x34, 0x06, 0xb7, 0x0f, 0xc4, 0x00, 0xb3, 0x00, 0x37,
-	0x0f, 0xc4, 0x07, 0x39, 0x0b, 0x2a, 0x1f, 0xc4, 0x06, 0x07, 0x1b, 0x21,
-	0x10, 0xd3, 0x11, 0x2a, 0x0f, 0xec, 0x00, 0x2b, 0x0f, 0xee, 0x0d, 0x40,
-	0x0e, 0x21, 0x0f, 0xd9, 0x02, 0xd3, 0x0f, 0xc4, 0x02, 0x0a, 0x0f, 0xc2,
-	0x02, 0xd3, 0x09, 0xc2, 0x0f, 0xc2, 0x02, 0xc7, 0x0f, 0xc2, 0x02, 0xd3,
-	0x0f, 0xfb, 0x08, 0x15, 0x0f, 0xc8, 0x04, 0x60, 0x0f, 0xc9, 0x04, 0xae,
-	0x0f, 0xfb, 0x02, 0x8c, 0x0f, 0xf9, 0x07, 0xed, 0x00, 0x21, 0x0f, 0xc4,
-	0x04, 0x2b, 0x0b, 0x14, 0x1f, 0xc0, 0x04, 0xb6, 0x0b, 0x3b, 0x0f, 0x39,
-	0x0f, 0xc0, 0x04, 0xe6, 0x0f, 0xc4, 0x04, 0x40, 0x0f, 0xc8, 0x04, 0x50,
-	0x0f, 0xf7, 0x00, 0x71, 0x0f, 0xc5, 0x04, 0x2d, 0x0f, 0xfb, 0x08, 0x4d,
-	0x0f, 0xfb, 0x08, 0x4d, 0x0f, 0xc4, 0x02, 0x10, 0x0b, 0x21, 0x00, 0x15,
-	0x1f, 0xfa, 0x08, 0x4d, 0x00, 0x01, 0x0f, 0xc4, 0x02, 0x0e, 0x0b, 0x8f,
-	0x00, 0x61, 0x0f, 0xc5, 0x04, 0x2c, 0x0b, 0x01, 0x0b, 0x19, 0x09, 0xc0,
-	0x0f, 0xc5, 0x02, 0x10, 0x00, 0x41, 0x09, 0xe1, 0x0d, 0xd3, 0x1f, 0xf9,
-	0x08, 0x82, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x0f, 0xfa, 0x08, 0x3d,
-	0x00, 0x00, 0x0f, 0xc4, 0x04, 0x2b, 0x0f, 0xc0, 0x06, 0x8f, 0x0f, 0x39,
-	0x0f, 0xc0, 0x04, 0xf3, 0x0f, 0xc4, 0x01, 0x82, 0x0f, 0xc5, 0x04, 0x33,
-	0x0b, 0x01, 0x0f, 0xcf, 0x04, 0x34, 0x0f, 0xfb, 0x08, 0x5f, 0x0f, 0xf9,
-	0x08, 0x82, 0x0f, 0xc5, 0x01, 0x82, 0x0b, 0x4f, 0x0f, 0xc5, 0x04, 0x33,
-	0x0b, 0x61, 0x0d, 0xd4, 0x1f, 0x38, 0x0d, 0xc1, 0x0f, 0xc0, 0x05, 0x04,
-	0x0f, 0xcf, 0x04, 0x50, 0x0f, 0xfb, 0x08, 0x5f, 0x0f, 0xf9, 0x08, 0x82,
-	0x0f, 0xc0, 0x05, 0x10, 0x0f, 0xc4, 0x04, 0x50, 0x0f, 0xcf, 0x04, 0x34,
-	0x04, 0x0e, 0x0f, 0xcd, 0x04, 0x56, 0x0f, 0xcc, 0x00, 0xc4, 0x05, 0xb9,
-	0x0f, 0xc0, 0x05, 0x1c, 0x0f, 0xc4, 0x04, 0x53, 0x0f, 0xcf, 0x04, 0x37,
-	0x04, 0x0e, 0x0f, 0xcd, 0x04, 0x59, 0x0f, 0xcc, 0x00, 0xc4, 0x05, 0xb9,
-	0x0f, 0xc0, 0x05, 0x27, 0x0f, 0xc4, 0x04, 0x50, 0x0a, 0x8f, 0x0f, 0xce,
-	0x01, 0x39, 0x0f, 0xcd, 0x04, 0x46, 0x05, 0xb8, 0x06, 0x0c, 0x0f, 0xc0,
-	0x05, 0x32, 0x0f, 0xc4, 0x04, 0x53, 0x0a, 0x8f, 0x0f, 0xce, 0x01, 0x39,
-	0x0f, 0xcd, 0x04, 0x46, 0x05, 0xb8, 0x06, 0x0c, 0x0f, 0xc0, 0x05, 0x3d,
-	0x0f, 0xc4, 0x04, 0x56, 0x0a, 0x8f, 0x0f, 0xce, 0x01, 0x39, 0x0f, 0xcd,
-	0x04, 0x49, 0x05, 0xb8, 0x06, 0x0c, 0x0f, 0xc0, 0x05, 0x56, 0x0f, 0xc5,
-	0x04, 0x4f, 0x0b, 0x61, 0x00, 0x15, 0x1f, 0xc0, 0x05, 0x81, 0x0f, 0xc5,
-	0x04, 0x2c, 0x0b, 0x62, 0x00, 0xe4, 0x09, 0xa1, 0x00, 0x15, 0x1f, 0xc0,
-	0x05, 0x6b, 0x0f, 0xc4, 0x04, 0x59, 0x0a, 0x8f, 0x0f, 0xce, 0x01, 0x39,
-	0x0f, 0xcd, 0x04, 0x49, 0x05, 0xb8, 0x06, 0x0c, 0x0f, 0xc5, 0x04, 0x4f,
-	0x0b, 0x61, 0x00, 0x59, 0x09, 0xc1, 0x0f, 0xc5, 0x01, 0x95, 0x0b, 0x52,
-	0x0f, 0xc0, 0x04, 0xf3, 0x1f, 0xc0, 0x05, 0xdf, 0x0f, 0xc4, 0x04, 0x50,
-	0x0f, 0xc5, 0x04, 0x34, 0x03, 0x3e, 0x0f, 0xf7, 0x00, 0x2d, 0x0f, 0xf9,
-	0x08, 0x82, 0x0f, 0xc0, 0x05, 0x76, 0x0f, 0xc4, 0x04, 0x56, 0x0f, 0xcf,
-	0x04, 0x40, 0x06, 0x0e, 0x0d, 0xcd, 0x0f, 0xcc, 0x00, 0xc4, 0x05, 0xb9,
-	0x0f, 0xc0, 0x05, 0x56, 0x0f, 0xc4, 0x04, 0x59, 0x0f, 0xcf, 0x04, 0x43,
-	0x06, 0x0e, 0x0d, 0xcd, 0x0f, 0xcc, 0x00, 0xc4, 0x05, 0xb9, 0x0f, 0xc0,
-	0x05, 0x8e, 0x0f, 0xc4, 0x04, 0x56, 0x0f, 0xcf, 0x04, 0x3a, 0x0f, 0xce,
-	0x01, 0x39, 0x0f, 0xcd, 0x04, 0x5c, 0x0f, 0xcc, 0x00, 0xc4, 0x05, 0xb9,
-	0x0f, 0xc0, 0x05, 0x9a, 0x0f, 0xc4, 0x04, 0x59, 0x0f, 0xcf, 0x04, 0x3d,
-	0x0f, 0xce, 0x01, 0x39, 0x0f, 0xcd, 0x04, 0x5c, 0x05, 0xb8, 0x06, 0x0c,
-	0x0f, 0xc0, 0x05, 0xa7, 0x0f, 0xc4, 0x04, 0x59, 0x0f, 0xcf, 0x04, 0x3a,
-	0x0f, 0xce, 0x01, 0x39, 0x0f, 0xcd, 0x04, 0x5f, 0x0f, 0xcc, 0x00, 0xc4,
-	0x05, 0xb9, 0x0f, 0xc0, 0x05, 0xb3, 0x0f, 0xc4, 0x04, 0x56, 0x0f, 0xcf,
-	0x04, 0x3d, 0x0f, 0xce, 0x01, 0x39, 0x0f, 0xcd, 0x04, 0x5f, 0x05, 0xb8,
-	0x04, 0x0c, 0x0f, 0xc0, 0x05, 0xbe, 0x0f, 0xc4, 0x04, 0x5c, 0x0a, 0x8f,
-	0x0f, 0xce, 0x01, 0x39, 0x0f, 0xcd, 0x04, 0x4c, 0x05, 0xb8, 0x06, 0x0c,
-	0x0f, 0xc0, 0x05, 0xc9, 0x0f, 0xc4, 0x04, 0x5f, 0x0a, 0x8f, 0x0f, 0xce,
-	0x01, 0x39, 0x0f, 0xcd, 0x04, 0x4c, 0x05, 0xb8, 0x06, 0x0c, 0x0f, 0xc0,
-	0x05, 0xd4, 0x0f, 0xc4, 0x04, 0x5c, 0x0f, 0xcf, 0x04, 0x40, 0x06, 0x0e,
-	0x0d, 0xcd, 0x0f, 0xcc, 0x00, 0xc4, 0x05, 0xb9, 0x0f, 0xc0, 0x05, 0x56,
-	0x0f, 0xc4, 0x04, 0x5f, 0x0f, 0xcf, 0x04, 0x43, 0x06, 0x0e, 0x0d, 0xcd,
-	0x0f, 0xcc, 0x00, 0xc4, 0x05, 0xb9, 0x0f, 0xc0, 0x05, 0xec, 0x0f, 0xc4,
-	0x04, 0x40, 0x0f, 0xcf, 0x04, 0x40, 0x0f, 0xce, 0x01, 0x39, 0x0f, 0xcd,
-	0x04, 0x62, 0x0f, 0xcc, 0x00, 0xc4, 0x05, 0xb9, 0x0f, 0xc0, 0x05, 0xf8,
-	0x0f, 0xc4, 0x04, 0x43, 0x0f, 0xcf, 0x04, 0x43, 0x0f, 0xce, 0x01, 0x39,
-	0x0f, 0xcd, 0x04, 0x62, 0x05, 0xb8, 0x06, 0x0c, 0x0f, 0xc0, 0x06, 0x1a,
-	0x0f, 0xc5, 0x04, 0x2c, 0x0b, 0x62, 0x00, 0xe4, 0x09, 0xa1, 0x00, 0x15,
-	0x0f, 0xcf, 0x04, 0x6c, 0x0f, 0xce, 0x04, 0x62, 0x0f, 0xcd, 0x04, 0x6f,
-	0x0f, 0xcc, 0x04, 0x4c, 0x1f, 0xcf, 0x04, 0x72, 0x1f, 0xcd, 0x04, 0x75,
-	0x1f, 0xcc, 0x04, 0x49, 0x0d, 0xc4, 0x0f, 0xf6, 0x02, 0x74, 0x0d, 0x85,
-	0x00, 0x36, 0x0d, 0xc4, 0x0d, 0x44, 0x0f, 0xf6, 0x02, 0x74, 0x0d, 0x05,
-	0x00, 0x34, 0x0d, 0x44, 0x0f, 0xc0, 0x06, 0x2a, 0x0f, 0xc4, 0x04, 0x46,
-	0x02, 0x37, 0x0f, 0xf7, 0x02, 0x99, 0x0f, 0xc4, 0x04, 0x65, 0x00, 0x37,
-	0x0f, 0xc4, 0x04, 0x78, 0x02, 0xb7, 0x0f, 0xc4, 0x04, 0x78, 0x00, 0x35,
-	0x0f, 0xc0, 0x06, 0x3a, 0x0f, 0xc4, 0x04, 0x49, 0x0f, 0xc5, 0x00, 0xaa,
-	0x08, 0x3b, 0x0f, 0xc4, 0x04, 0x49, 0x00, 0x37, 0x0f, 0xc4, 0x04, 0x65,
-	0x06, 0xb7, 0x0f, 0xc4, 0x04, 0x68, 0x00, 0x35, 0x0f, 0xc0, 0x06, 0x57,
-	0x0f, 0xc4, 0x04, 0x68, 0x0f, 0xf7, 0x00, 0xbd, 0x0f, 0xc4, 0x00, 0xb3,
-	0x05, 0xb7, 0x0f, 0xfb, 0x00, 0x58, 0x00, 0x08, 0x10, 0x48, 0x0f, 0xc4,
-	0x04, 0x6b, 0x0c, 0x00, 0x0f, 0xc4, 0x04, 0x87, 0x0b, 0x21, 0x0c, 0x19,
-	0x09, 0xc0, 0x0f, 0xc5, 0x04, 0x2d, 0x0f, 0xfb, 0x08, 0x1b, 0x0f, 0xfb,
-	0x08, 0x1b, 0x0f, 0xf9, 0x08, 0x1b, 0x0f, 0xc0, 0x06, 0x7a, 0x0f, 0xc4,
-	0x04, 0x6b, 0x0b, 0x21, 0x00, 0x14, 0x0f, 0xcf, 0x04, 0x7b, 0x1f, 0xcf,
-	0x04, 0x7e, 0x0f, 0xce, 0x06, 0x28, 0x1f, 0xce, 0x04, 0x49, 0x0f, 0xc4,
-	0x04, 0x46, 0x02, 0x37, 0x0f, 0xc4, 0x02, 0xc4, 0x00, 0x37, 0x0d, 0xc4,
-	0x0f, 0xc5, 0x04, 0x46, 0x0f, 0xf7, 0x02, 0x74, 0x00, 0x36, 0x0d, 0xc4,
-	0x0f, 0xcf, 0x04, 0x81, 0x0d, 0xc4, 0x0f, 0xf6, 0x02, 0x74, 0x0d, 0x85,
-	0x00, 0x34, 0x0d, 0xc4, 0x0f, 0xc0, 0x04, 0xb6, 0x0f, 0xc4, 0x04, 0x6b,
-	0x0b, 0x21, 0x00, 0x14, 0x1f, 0x39, 0x0f, 0xc4, 0x04, 0x84, 0x0f, 0xf7,
-	0x00, 0xbd, 0x0f, 0xc4, 0x04, 0x46, 0x05, 0xb7, 0x0f, 0xfb, 0x00, 0x58,
-	0x1f, 0x39, 0x0f, 0xc4, 0x04, 0x84, 0x0f, 0xf5, 0x00, 0xb2, 0x0f, 0xc0,
-	0x04, 0xe6, 0x0f, 0xc4, 0x04, 0x6c, 0x0f, 0xc5, 0x04, 0x88, 0x07, 0x3e,
-	0x0f, 0xf7, 0x00, 0x2d, 0x0f, 0xfb, 0x08, 0x15, 0x0f, 0xc8, 0x06, 0x9f,
-	0x05, 0x3b, 0x0f, 0xf9, 0x08, 0x82, 0x0f, 0xc4, 0x02, 0x0e, 0x0b, 0x08,
-	0x00, 0xb6, 0x00, 0x09, 0x0f, 0xf7, 0x02, 0x99, 0x0f, 0xc4, 0x00, 0xb6,
-	0x00, 0x37, 0x01, 0xbb, 0x0f, 0xc4, 0x04, 0x97, 0x0f, 0xc5, 0x04, 0x9a,
-	0x0f, 0xf7, 0x02, 0x74, 0x0f, 0xc4, 0x00, 0xc2, 0x00, 0x37, 0x01, 0xbb,
-	0x0f, 0xc4, 0x00, 0xc2, 0x0f, 0xc5, 0x04, 0x94, 0x08, 0x3b, 0x0f, 0xc4,
-	0x00, 0xb6, 0x06, 0xb7, 0x0f, 0xc4, 0x00, 0xb6, 0x06, 0xb7, 0x0f, 0xc4,
-	0x00, 0xc5, 0x00, 0x37, 0x01, 0xbb, 0x0f, 0xc4, 0x04, 0xa3, 0x0b, 0x08,
-	0x00, 0xb6, 0x00, 0x09, 0x0f, 0xc4, 0x00, 0xb9, 0x00, 0x37, 0x0f, 0xc4,
-	0x00, 0xb6, 0x06, 0xb7, 0x0f, 0xc4, 0x00, 0xce, 0x00, 0x37, 0x01, 0xbb,
-	0x0f, 0xc4, 0x02, 0x0e, 0x0b, 0x21, 0x0f, 0xc4, 0x04, 0xa3, 0x0b, 0x11,
-	0x09, 0xc8, 0x00, 0xb6, 0x00, 0x09, 0x0f, 0xc4, 0x00, 0xbc, 0x00, 0x37,
-	0x0f, 0xc4, 0x04, 0x97, 0x06, 0xb7, 0x0f, 0xc4, 0x00, 0xbf, 0x00, 0x37,
-	0x01, 0xbb, 0x0f, 0xc4, 0x00, 0xbf, 0x0f, 0xc5, 0x04, 0x9a, 0x0f, 0xf7,
-	0x02, 0x7d, 0x0f, 0xc4, 0x00, 0xb9, 0x0f, 0xf7, 0x02, 0x81, 0x0f, 0xc4,
-	0x00, 0xc8, 0x00, 0x37, 0x01, 0xbb, 0x0f, 0xc4, 0x04, 0xa0, 0x0f, 0xc5,
-	0x04, 0x9a, 0x0f, 0xf7, 0x02, 0x7d, 0x0f, 0xc4, 0x00, 0xbc, 0x06, 0xb7,
-	0x0f, 0xc4, 0x00, 0xcb, 0x00, 0x37, 0x01, 0xbb, 0x0f, 0xc4, 0x04, 0x8e,
-	0x0f, 0xc5, 0x04, 0x91, 0x0f, 0xf7, 0x02, 0x7d, 0x0f, 0xc4, 0x00, 0xd1,
-	0x00, 0x37, 0x01, 0xbb, 0x0f, 0xc4, 0x04, 0x88, 0x0f, 0xc5, 0x04, 0x8b,
-	0x0f, 0xf7, 0x02, 0x7d, 0x0f, 0xc4, 0x00, 0xd4, 0x00, 0x37, 0x01, 0xbb,
-	0x0f, 0xcf, 0x0f, 0xff, 0x0f, 0xce, 0x02, 0xbb, 0x0f, 0xc4, 0x00, 0xce,
-	0x0f, 0xc9, 0x0f, 0x5c, 0x0f, 0xca, 0x07, 0xf8, 0x0f, 0xcc, 0x0f, 0xf8,
-	0x06, 0x3a, 0x01, 0xcd, 0x0f, 0xc4, 0x00, 0xce, 0x0f, 0xc9, 0x09, 0x9a,
-	0x0f, 0xca, 0x07, 0xfe, 0x07, 0xcc, 0x0f, 0xcd, 0x0f, 0xe7, 0x06, 0x3b,
-	0x0f, 0xc4, 0x00, 0xcb, 0x0f, 0xc9, 0x0a, 0x66, 0x00, 0x0a, 0x0f, 0xcc,
-	0x00, 0x3f, 0x0f, 0xcd, 0x0f, 0xdf, 0x06, 0x3b, 0x0f, 0xc4, 0x00, 0xc8,
-	0x0f, 0xc9, 0x0b, 0x33, 0x0f, 0xca, 0x07, 0xff, 0x0f, 0xcc, 0x00, 0x7f,
-	0x0f, 0xcd, 0x0f, 0xbf, 0x06, 0x3b, 0x0f, 0xc4, 0x00, 0xbf, 0x01, 0xba,
-	0x0d, 0xc0, 0x0f, 0xc4, 0x00, 0xbf, 0x0b, 0x0f, 0x0f, 0xce, 0x02, 0xbf,
-	0x0f, 0xc4, 0x00, 0xc5, 0x0f, 0xc9, 0x08, 0xcd, 0x00, 0x0a, 0x0f, 0xcc,
-	0x0f, 0x7e, 0x0f, 0xcd, 0x00, 0xf9, 0x06, 0x3b, 0x0f, 0xc4, 0x00, 0xc5,
-	0x0f, 0xc9, 0x0b, 0x00, 0x00, 0xca, 0x0f, 0xcc, 0x07, 0xff, 0x0f, 0xcd,
-	0x0b, 0xff, 0x06, 0x3b, 0x0f, 0xc4, 0x00, 0xd1, 0x0f, 0xc9, 0x08, 0x00,
-	0x00, 0x0a, 0x1f, 0xc9, 0x0c, 0x00, 0x1f, 0xca, 0x07, 0xff, 0x0f, 0xcc,
-	0x01, 0xef, 0x0f, 0xcd, 0x0e, 0xff, 0x06, 0x3b, 0x0f, 0xc4, 0x00, 0xd4,
-	0x0f, 0xc9, 0x0c, 0x00, 0x00, 0x4a, 0x1f, 0xc9, 0x0e, 0x00, 0x0f, 0xcc,
-	0x03, 0xef, 0x0f, 0xcd, 0x0d, 0xff, 0x06, 0x3b, 0x0f, 0xc4, 0x00, 0xd1,
-	0x0f, 0xc9, 0x08, 0x00, 0x00, 0x0a, 0x1f, 0xca, 0x07, 0xff, 0x0f, 0xcc,
-	0x0f, 0xfb, 0x0f, 0xcd, 0x0f, 0xfd, 0x06, 0x3b, 0x0f, 0xc4, 0x01, 0x99,
-	0x0f, 0xc5, 0x01, 0x97, 0x0b, 0x61, 0x0d, 0xd5, 0x1f, 0xf8, 0x07, 0x93,
-	0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x00, 0xd2, 0x0f, 0xf8, 0x07, 0x99,
-	0x10, 0xc0, 0x00, 0x00, 0x00, 0xd2, 0x1f, 0xf9, 0x07, 0x99, 0x0f, 0xfb,
-	0x07, 0xab, 0x0f, 0xc4, 0x01, 0x98, 0x0f, 0xfa, 0x07, 0xa2, 0x0b, 0x0e,
-	0x0f, 0xc5, 0x01, 0x81, 0x0f, 0x38, 0x00, 0x41, 0x0f, 0xf1, 0x0f, 0x15,
-	0x0f, 0xe2, 0x0f, 0xf8, 0x0a, 0x64, 0x09, 0xa2, 0x0d, 0xa5, 0x0f, 0x38,
-	0x09, 0xb2, 0x0f, 0xc4, 0x01, 0x97, 0x0d, 0xc0, 0x00, 0x0e, 0x07, 0x36,
-	0x04, 0x0d, 0x01, 0x0a, 0x12, 0x8a, 0x02, 0x09, 0x12, 0x09, 0x00, 0x4c,
-	0x00, 0x0b, 0x0d, 0xe2, 0x00, 0x21, 0x0f, 0xe4, 0x00, 0x81, 0x09, 0x95,
-	0x10, 0x4e, 0x10, 0x8d, 0x10, 0x0c, 0x0f, 0xe4, 0x00, 0x50, 0x09, 0x95,
-	0x10, 0x8e, 0x10, 0x8d, 0x10, 0x0c, 0x08, 0x24, 0x09, 0x95, 0x10, 0xce,
-	0x1c, 0x8d, 0x10, 0x4b, 0x0f, 0xe4, 0x08, 0x04, 0x09, 0x95, 0x11, 0x0e,
-	0x11, 0x0d, 0x10, 0x0c, 0x0f, 0xe4, 0x03, 0x0a, 0x09, 0x95, 0x14, 0x24,
-	0x19, 0x94, 0x11, 0x4e, 0x0f, 0xe4, 0x04, 0x00, 0x09, 0x95, 0x11, 0x8e,
-	0x1c, 0x4d, 0x10, 0x4c, 0x0f, 0xc4, 0x07, 0x3a, 0x0b, 0x21, 0x00, 0x15,
-	0x0f, 0xc4, 0x01, 0x98, 0x0d, 0x80, 0x1f, 0xc4, 0x01, 0x91, 0x1d, 0x40,
-	0x1f, 0xc4, 0x01, 0x83, 0x1d, 0x00, 0x1f, 0xf0, 0x0a, 0x11, 0x0f, 0x38,
-	0x1c, 0xf2, 0x01, 0xe2, 0x0f, 0xc4, 0x07, 0xf5, 0x0b, 0x24, 0x09, 0xa1,
-	0x00, 0x0f, 0x00, 0x54, 0x10, 0x4f, 0x00, 0x94, 0x14, 0x0f, 0x01, 0x14,
-	0x11, 0x0f, 0x01, 0x54, 0x10, 0x8f, 0x01, 0x94, 0x1f, 0xcf, 0x04, 0x00,
-	0x0d, 0xe1, 0x00, 0x14, 0x1f, 0x39, 0x0f, 0xf9, 0x07, 0xab, 0x0f, 0xf7,
-	0x00, 0xbd, 0x07, 0x04, 0x00, 0x02, 0x0c, 0x42, 0x0f, 0xfa, 0x00, 0x58,
-	0x0c, 0x82, 0x0d, 0xe2, 0x0d, 0x64, 0x1d, 0x24, 0x09, 0x8f, 0x0d, 0x84,
-	0x0d, 0x48, 0x1d, 0x08, 0x0c, 0x02, 0x07, 0x34, 0x0a, 0x8e, 0x0f, 0xc4,
-	0x04, 0x6c, 0x0f, 0xc8, 0x04, 0x88, 0x0f, 0xf5, 0x00, 0x71, 0x0b, 0xc9,
-	0x0b, 0xca, 0x00, 0x21, 0x0c, 0x54, 0x1f, 0x39, 0x0c, 0x9f, 0x09, 0xe2,
-	0x0c, 0x44, 0x0b, 0x8b, 0x0b, 0x25, 0x09, 0x82, 0x09, 0x8c, 0x0c, 0x14,
-	0x10, 0x22, 0x0b, 0x25, 0x09, 0x82, 0x09, 0x8d, 0x0f, 0xc4, 0x01, 0x80,
-	0x0b, 0x21, 0x00, 0x14, 0x0f, 0xe1, 0x0f, 0xff, 0x0c, 0xd9, 0x0c, 0xce,
-	0x19, 0xce, 0x0d, 0x14, 0x1f, 0xf0, 0x0a, 0x12, 0x1d, 0xb2, 0x1f, 0xf0,
-	0x0a, 0x13, 0x0f, 0x38, 0x1d, 0x72, 0x0b, 0x0f, 0x0f, 0xc4, 0x02, 0x0c,
-	0x0b, 0x21, 0x00, 0xd9, 0x09, 0xc0, 0x09, 0xe1, 0x0f, 0xd2, 0x02, 0xd3,
-	0x1f, 0xc0, 0x02, 0xc7, 0x0b, 0x04, 0x0d, 0xc2, 0x00, 0x02, 0x0f, 0x38,
-	0x00, 0x02, 0x0f, 0xc4, 0x02, 0x0c, 0x0b, 0x03, 0x0f, 0xc4, 0x02, 0x11,
-	0x0b, 0x03, 0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x09, 0xe1, 0x03, 0x13,
-	0x1f, 0x39, 0x00, 0x02, 0x0b, 0x21, 0x00, 0x59, 0x0f, 0xf8, 0x08, 0x3d,
-	0x09, 0xc0, 0x0f, 0xf1, 0x0a, 0x1f, 0x0f, 0xc4, 0x04, 0x2c, 0x07, 0x36,
-	0x0b, 0x08, 0x1a, 0x66, 0x19, 0xa6, 0x19, 0xa6, 0x19, 0xa6, 0x19, 0xaa,
-	0x1f, 0xec, 0x02, 0x39, 0x1f, 0xee, 0x0d, 0x40, 0x1e, 0x21, 0x1c, 0x19,
-	0x0f, 0xf6, 0x0b, 0x3f, 0x19, 0xc8, 0x0c, 0x4d, 0x0c, 0x8e, 0x0f, 0xfa,
-	0x08, 0x7a, 0x0c, 0x09, 0x0a, 0x8f, 0x0d, 0x49, 0x00, 0xb6, 0x00, 0x08,
-	0x0d, 0xa1, 0x05, 0xd1, 0x01, 0x36, 0x09, 0xc8, 0x00, 0x34, 0x0d, 0xc4,
-	0x0f, 0xc4, 0x02, 0x0a, 0x0a, 0x8f, 0x0b, 0x85, 0x0b, 0x0e, 0x0f, 0xc4,
-	0x04, 0x2b, 0x0f, 0xfb, 0x08, 0x94, 0x0d, 0xc4, 0x0a, 0xc0, 0x0a, 0xe1,
-	0x0d, 0x92, 0x1f, 0xc0, 0x02, 0xd3, 0x0b, 0x04, 0x0f, 0xc5, 0x04, 0x2b,
-	0x0f, 0xfe, 0x00, 0x2b, 0x0f, 0xf5, 0x00, 0x2d, 0x0f, 0xf7, 0x00, 0xbd,
-	0x05, 0xb6, 0x0d, 0xc4, 0x0d, 0xb7, 0x05, 0x37, 0x0f, 0xf6, 0x00, 0xbd,
-	0x0d, 0x44, 0x0d, 0x37, 0x00, 0x34, 0x0d, 0x44, 0x00, 0x0a, 0x00, 0x0b,
-	0x01, 0x3e, 0x0f, 0xfd, 0x08, 0xb4, 0x00, 0x3f, 0x0b, 0x88, 0x00, 0x09,
-	0x0c, 0x21, 0x02, 0xdf, 0x1f, 0xc9, 0x0f, 0xff, 0x0c, 0xa0, 0x09, 0xca,
-	0x0c, 0x61, 0x0c, 0xd9, 0x09, 0xcb, 0x0c, 0xaa, 0x0c, 0xeb, 0x0f, 0xee,
-	0x02, 0x40, 0x0c, 0xe1, 0x02, 0xdf, 0x0f, 0xc8, 0x0a, 0x7e, 0x1f, 0xc8,
-	0x0a, 0xbe, 0x0c, 0x2e, 0x0f, 0x38, 0x0e, 0x01, 0x0f, 0xc4, 0x00, 0x5c,
-	0x0f, 0xc5, 0x01, 0xb8, 0x0f, 0xfb, 0x08, 0xa4, 0x0f, 0xc4, 0x00, 0x60,
-	0x0f, 0xc5, 0x01, 0xb9, 0x0f, 0xfb, 0x08, 0xa4, 0x0f, 0xc4, 0x00, 0x64,
-	0x0f, 0xc5, 0x01, 0xba, 0x0f, 0xfb, 0x08, 0xa4, 0x0f, 0xc4, 0x00, 0x68,
-	0x0f, 0xc5, 0x01, 0xbb, 0x0f, 0xfb, 0x08, 0xa4, 0x0f, 0xc5, 0x05, 0x60,
-	0x0f, 0xc4, 0x01, 0xb8, 0x0b, 0x03, 0x0f, 0xc4, 0x01, 0xb9, 0x0b, 0x03,
-	0x0f, 0xc5, 0x05, 0x62, 0x0f, 0xc4, 0x01, 0xba, 0x0b, 0x03, 0x0f, 0xc4,
-	0x01, 0xbb, 0x0f, 0x38, 0x0b, 0x03, 0x07, 0xb7, 0x1f, 0xf9, 0x08, 0xf8,
-	0x0f, 0xc4, 0x01, 0x34, 0x00, 0x02, 0x00, 0x02, 0x0f, 0xc4, 0x01, 0x61,
-	0x0f, 0xc0, 0x00, 0x2d, 0x0f, 0xf9, 0x09, 0x02, 0x0f, 0xc4, 0x01, 0x34,
-	0x00, 0x02, 0x00, 0x02, 0x0f, 0xc4, 0x01, 0x61, 0x0f, 0xc0, 0x00, 0xd9,
-	0x0f, 0xf9, 0x09, 0x02, 0x0f, 0xc4, 0x01, 0x34, 0x0f, 0xf0, 0x05, 0x01,
-	0x0b, 0xb2, 0x0f, 0xf0, 0x05, 0x00, 0x0b, 0xb2, 0x0f, 0xc4, 0x01, 0x60,
-	0x0f, 0xf0, 0x05, 0x02, 0x00, 0x00, 0x00, 0x32, 0x0f, 0xf0, 0x0a, 0x03,
-	0x00, 0x32, 0x0f, 0xc4, 0x01, 0x61, 0x0f, 0xf0, 0x0a, 0x02, 0x0b, 0x32,
-	0x0f, 0xc4, 0x01, 0xb0, 0x0f, 0xc0, 0x00, 0x64, 0x00, 0x08, 0x0f, 0xfa,
-	0x19, 0x6d, 0x00, 0x09, 0x0f, 0xf7, 0x02, 0xb6, 0x0f, 0xfb, 0x12, 0xcf,
-	0x0f, 0xc4, 0x06, 0x8d, 0x0b, 0x21, 0x0f, 0xd3, 0x00, 0x30, 0x0f, 0xc4,
-	0x06, 0x94, 0x09, 0xe1, 0x0b, 0xa0, 0x0f, 0xf0, 0x03, 0x2a, 0x09, 0xf2,
-	0x00, 0x21, 0x1f, 0xe1, 0x1f, 0xff, 0x0b, 0x99, 0x0f, 0xf0, 0x03, 0x29,
-	0x09, 0xf2, 0x0f, 0xc4, 0x01, 0x9e, 0x00, 0x02, 0x0f, 0xc4, 0x01, 0xac,
-	0x00, 0x00, 0x0f, 0xc4, 0x01, 0xaf, 0x00, 0x00, 0x0f, 0xc4, 0x05, 0x86,
-	0x00, 0x00, 0x04, 0x05, 0x0f, 0xc1, 0x00, 0x29, 0x02, 0xba, 0x00, 0x08,
-	0x0f, 0x39, 0x0f, 0xc4, 0x06, 0x94, 0x0f, 0xf0, 0x03, 0x2a, 0x0b, 0xb2,
-	0x0f, 0xf0, 0x03, 0x29, 0x0b, 0xb2, 0x0f, 0xc4, 0x06, 0x8d, 0x0f, 0xf0,
-	0x03, 0x2b, 0x0f, 0xc0, 0x00, 0x30, 0x0f, 0xf2, 0x00, 0x30, 0x0f, 0xf7,
-	0x0b, 0xc3, 0x0f, 0xc8, 0x0a, 0xa1, 0x07, 0x36, 0x00, 0x49, 0x1f, 0xc8,
-	0x06, 0xa9, 0x00, 0xb6, 0x10, 0x09, 0x0f, 0xc8, 0x1f, 0xe7, 0x01, 0x37,
-	0x0f, 0xc4, 0x05, 0x5c, 0x00, 0x37, 0x09, 0x36, 0x04, 0x08, 0x0f, 0xc4,
-	0x06, 0x01, 0x04, 0x00, 0x04, 0x04, 0x0f, 0xc0, 0x00, 0x2a, 0x0f, 0xc4,
-	0x01, 0xa0, 0x00, 0x00, 0x08, 0xc4, 0x00, 0x80, 0x0f, 0xc8, 0x00, 0x3f,
-	0x0f, 0xf7, 0x05, 0x23, 0x0f, 0x39, 0x08, 0xc4, 0x0b, 0x21, 0x00, 0x54,
-	0x1f, 0xf9, 0x09, 0x82, 0x0f, 0x38, 0x09, 0xc0, 0x0f, 0xf7, 0x05, 0x37,
-	0x0f, 0x39, 0x04, 0x3b, 0x0f, 0xfb, 0x09, 0x7b, 0x0f, 0x39, 0x04, 0x3b,
-	0x07, 0x37, 0x1f, 0xf9, 0x09, 0x90, 0x0f, 0xf6, 0x05, 0x5c, 0x00, 0x48,
-	0x0f, 0xfb, 0x0d, 0xb2, 0x0f, 0xc4, 0x01, 0xa2, 0x00, 0x21, 0x0b, 0x15,
-	0x1f, 0xf9, 0x09, 0xae, 0x0f, 0xc4, 0x01, 0x5f, 0x0b, 0x21, 0x00, 0x59,
-	0x09, 0xc0, 0x06, 0x53, 0x1f, 0xf9, 0x09, 0xa4, 0x0f, 0xf7, 0x05, 0x37,
-	0x01, 0x38, 0x00, 0xc8, 0x09, 0xe2, 0x00, 0x64, 0x09, 0xa2, 0x00, 0x63,
-	0x02, 0x3a, 0x09, 0x88, 0x0f, 0xf7, 0x0c, 0x13, 0x0f, 0xf5, 0x0c, 0x97,
-	0x08, 0xc4, 0x0b, 0x21, 0x00, 0x54, 0x09, 0xe2, 0x00, 0x64, 0x09, 0xa2,
-	0x00, 0x63, 0x02, 0x3a, 0x09, 0x88, 0x0f, 0xf7, 0x0c, 0x13, 0x0f, 0xf7,
-	0x0c, 0x97, 0x0f, 0xfb, 0x09, 0x7b, 0x04, 0x04, 0x0f, 0xc5, 0x01, 0x5f,
-	0x0b, 0x21, 0x0f, 0xd5, 0x00, 0x40, 0x1f, 0xf8, 0x09, 0xc7, 0x10, 0x01,
-	0x0f, 0x39, 0x0f, 0xf0, 0x05, 0x0c, 0x0f, 0x38, 0x00, 0xb2, 0x04, 0x3b,
-	0x0f, 0xf7, 0x0c, 0x13, 0x0f, 0xf7, 0x0c, 0x97, 0x07, 0x37, 0x1f, 0xf9,
-	0x09, 0xd6, 0x0f, 0xf6, 0x05, 0x5c, 0x00, 0x48, 0x09, 0x3b, 0x04, 0x04,
-	0x0f, 0xc0, 0x00, 0x41, 0x08, 0xc4, 0x0b, 0x21, 0x00, 0x54, 0x09, 0xe2,
-	0x00, 0x64, 0x09, 0xa2, 0x00, 0x63, 0x02, 0x3a, 0x09, 0x88, 0x0f, 0xfb,
-	0x09, 0x7b, 0x0f, 0x39, 0x04, 0x3b, 0x07, 0xba, 0x00, 0xc8, 0x0f, 0xc4,
-	0x01, 0xa0, 0x0b, 0x21, 0x00, 0x15, 0x1f, 0xf9, 0x09, 0xf3, 0x0f, 0xfb,
-	0x0d, 0xf5, 0x0f, 0xf9, 0x0a, 0x38, 0x0f, 0xfb, 0x0d, 0xb2, 0x0f, 0xfb,
-	0x0e, 0x05, 0x0f, 0xc4, 0x01, 0xb6, 0x0b, 0x21, 0x00, 0x15, 0x1f, 0xf9,
-	0x0a, 0xc3, 0x0f, 0xc4, 0x01, 0x9f, 0x0b, 0x22, 0x0f, 0xe4, 0x00, 0xc0,
-	0x09, 0xa1, 0x0f, 0xd4, 0x00, 0xc0, 0x1f, 0xf9, 0x0a, 0x15, 0x0f, 0xd4,
-	0x00, 0x40, 0x1f, 0xf9, 0x0a, 0x15, 0x00, 0x14, 0x1f, 0x39, 0x0f, 0xc4,
-	0x01, 0xa1, 0x0b, 0x21, 0x00, 0x55, 0x1f, 0x38, 0x09, 0xc0, 0x0f, 0xf9,
-	0x0a, 0x38, 0x0f, 0xc4, 0x01, 0x42, 0x0b, 0x08, 0x0f, 0xc4, 0x01, 0xa7,
-	0x0b, 0x21, 0x0f, 0xd4, 0x08, 0x00, 0x1f, 0xf9, 0x0a, 0x2c, 0x0c, 0x14,
-	0x1f, 0xf9, 0x0a, 0x99, 0x0f, 0xc4, 0x01, 0xa8, 0x0b, 0x21, 0x0f, 0xd4,
-	0x08, 0x00, 0x1f, 0xf9, 0x0a, 0x2c, 0x0c, 0x14, 0x1f, 0xf9, 0x0a, 0x99,
-	0x0c, 0x00, 0x0f, 0xc4, 0x01, 0xa6, 0x0b, 0x21, 0x00, 0x54, 0x1f, 0xf8,
-	0x0a, 0x38, 0x09, 0xc0, 0x0f, 0xc4, 0x01, 0xa1, 0x0f, 0x38, 0x01, 0x00,
-	0x0f, 0xc4, 0x01, 0xa3, 0x00, 0x00, 0x0f, 0xc4, 0x01, 0xa2, 0x00, 0x00,
-	0x0f, 0xc4, 0x01, 0xa1, 0x01, 0x00, 0x0f, 0xc4, 0x01, 0xa6, 0x00, 0xc0,
-	0x0f, 0xc4, 0x01, 0xa7, 0x0f, 0xc0, 0x08, 0x00, 0x0f, 0xc4, 0x01, 0xa8,
-	0x0f, 0xc0, 0x08, 0x00, 0x07, 0xb7, 0x01, 0x48, 0x13, 0xc8, 0x0f, 0xc4,
-	0x01, 0xa0, 0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x09, 0xcb, 0x09, 0xe1,
-	0x0c, 0x16, 0x1f, 0xf9, 0x0a, 0xda, 0x00, 0x54, 0x10, 0x08, 0x00, 0x94,
-	0x16, 0x48, 0x00, 0xd4, 0x1f, 0xc8, 0x1f, 0xe7, 0x01, 0x14, 0x1f, 0xc8,
-	0x00, 0x32, 0x01, 0x54, 0x1f, 0xc8, 0x1f, 0xce, 0x01, 0x94, 0x1f, 0xc8,
-	0x00, 0x4b, 0x01, 0xd4, 0x1f, 0xc8, 0x1f, 0xb5, 0x02, 0x14, 0x1f, 0xc8,
-	0x00, 0x64, 0x02, 0x54, 0x1f, 0xc8, 0x1f, 0x9c, 0x02, 0x94, 0x1f, 0xc8,
-	0x00, 0x7d, 0x02, 0xd4, 0x1f, 0xc8, 0x1f, 0x83, 0x03, 0x14, 0x1f, 0xc8,
-	0x00, 0x96, 0x03, 0x54, 0x1f, 0xc8, 0x1f, 0x6a, 0x03, 0x94, 0x1f, 0xc8,
-	0x00, 0xaf, 0x03, 0xd4, 0x1f, 0xc8, 0x1f, 0x51, 0x0f, 0xfb, 0x19, 0x85,
-	0x07, 0xb7, 0x0f, 0xc9, 0x00, 0x2d, 0x1f, 0xc9, 0x00, 0xd9, 0x0c, 0x61,
-	0x0c, 0x1b, 0x09, 0xc8, 0x0c, 0x21, 0x0f, 0xd7, 0x1f, 0xff, 0x10, 0x08,
-	0x0f, 0xf0, 0x0a, 0x02, 0x0c, 0x32, 0x0f, 0xc4, 0x01, 0x61, 0x0f, 0x38,
-	0x0c, 0x00, 0x0f, 0xc4, 0x01, 0x42, 0x0f, 0xf6, 0x0d, 0x7c, 0x00, 0x48,
-	0x04, 0xc4, 0x0f, 0xc5, 0x05, 0x6e, 0x04, 0xb7, 0x0f, 0xc4, 0x01, 0xaa,
-	0x00, 0x00, 0x0f, 0xc4, 0x06, 0x96, 0x0f, 0xc5, 0x05, 0x71, 0x04, 0xb7,
-	0x0f, 0xc4, 0x01, 0xab, 0x00, 0x00, 0x04, 0x04, 0x0f, 0xc0, 0x00, 0x2b,
-	0x08, 0xc4, 0x02, 0x80, 0x0f, 0xc8, 0x00, 0x40, 0x0f, 0xf7, 0x05, 0x23,
-	0x07, 0xb7, 0x0f, 0xc8, 0x00, 0x2d, 0x1f, 0xc8, 0x00, 0xd9, 0x0f, 0xf0,
-	0x0a, 0x02, 0x0c, 0x32, 0x00, 0x08, 0x0f, 0xfa, 0x19, 0x6d, 0x00, 0x09,
-	0x0f, 0x39, 0x0f, 0xc4, 0x01, 0x62, 0x0b, 0x22, 0x00, 0x63, 0x09, 0x80,
-	0x02, 0x36, 0x04, 0xc4, 0x0f, 0xf7, 0x00, 0x8f, 0x05, 0x84, 0x0f, 0xf6,
-	0x0d, 0x7c, 0x00, 0x08, 0x08, 0xc4, 0x01, 0x80, 0x0f, 0xc8, 0x00, 0x3f,
-	0x0f, 0xf7, 0x05, 0x23, 0x0f, 0xc4, 0x01, 0xa0, 0x0f, 0x38, 0x00, 0x00,
-	0x01, 0x3a, 0x00, 0x88, 0x0f, 0x39, 0x00, 0x44, 0x0c, 0x00, 0x04, 0x3b,
-	0x0f, 0xf7, 0x0c, 0x13, 0x0f, 0xf7, 0x0c, 0x97, 0x0f, 0xc8, 0x00, 0x2b,
-	0x03, 0x3b, 0x1f, 0xf9, 0x0b, 0x02, 0x0f, 0xf0, 0x0a, 0x07, 0x01, 0x32,
-	0x0f, 0xc4, 0x06, 0xe9, 0x0f, 0xc5, 0x07, 0x51, 0x04, 0xb7, 0x0f, 0xc4,
-	0x06, 0xec, 0x0f, 0xc5, 0x07, 0x54, 0x04, 0xb7, 0x0f, 0xc4, 0x06, 0xe3,
-	0x0f, 0xc5, 0x07, 0x3f, 0x04, 0xb7, 0x0f, 0xc4, 0x06, 0xe6, 0x0f, 0xc5,
-	0x07, 0x42, 0x04, 0xb7, 0x0f, 0xf9, 0x0b, 0x16, 0x0f, 0xc4, 0x06, 0xf5,
-	0x0f, 0xc5, 0x07, 0x51, 0x04, 0xb7, 0x0f, 0xc4, 0x06, 0xf8, 0x0f, 0xc5,
-	0x07, 0x54, 0x04, 0xb7, 0x0f, 0xc4, 0x06, 0xef, 0x0f, 0xc5, 0x07, 0x3f,
-	0x04, 0xb7, 0x0f, 0xc4, 0x06, 0xf2, 0x0f, 0xc5, 0x07, 0x42, 0x04, 0xb7,
-	0x07, 0x37, 0x1f, 0xf9, 0x0b, 0x2d, 0x0f, 0xf7, 0x09, 0x2f, 0x0f, 0xf7,
-	0x09, 0x62, 0x0f, 0xf7, 0x09, 0xc3, 0x0f, 0xc8, 0x00, 0x2b, 0x03, 0x3b,
-	0x1f, 0xfb, 0x0b, 0xfa, 0x00, 0x44, 0x0f, 0xfa, 0x0c, 0x0e, 0x0b, 0x08,
-	0x0f, 0xf6, 0x05, 0x5c, 0x00, 0x48, 0x0f, 0xf9, 0x0b, 0x4b, 0x0f, 0xf7,
-	0x09, 0x2f, 0x0f, 0xf7, 0x09, 0xc3, 0x0f, 0xfb, 0x0b, 0xff, 0x0f, 0xf7,
-	0x09, 0x2f, 0x0f, 0xf7, 0x09, 0x62, 0x0f, 0xc8, 0x00, 0x2b, 0x03, 0x3b,
-	0x1f, 0xf7, 0x0a, 0x0a, 0x0f, 0xfb, 0x0b, 0xff, 0x0f, 0xc8, 0x00, 0x2b,
-	0x03, 0x3b, 0x1f, 0xf7, 0x0a, 0x72, 0x0f, 0xfb, 0x17, 0x68, 0x0f, 0xfb,
-	0x0b, 0xff, 0x00, 0x44, 0x0f, 0xfa, 0x0c, 0x0e, 0x0b, 0x08, 0x0f, 0xc4,
-	0x01, 0x9e, 0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x09, 0xe1, 0x00, 0x14,
-	0x10, 0x40, 0x0f, 0x39, 0x0f, 0xc8, 0x00, 0x50, 0x08, 0xbb, 0x07, 0xba,
-	0x01, 0x08, 0x0f, 0xc8, 0x00, 0x50, 0x03, 0x3b, 0x1f, 0xf9, 0x0b, 0x7e,
-	0x0f, 0xc4, 0x01, 0x9e, 0x07, 0x36, 0x0b, 0x08, 0x1c, 0x27, 0x19, 0xa7,
-	0x19, 0x88, 0x0c, 0x21, 0x0f, 0xd2, 0x00, 0x6f, 0x1f, 0xc4, 0x01, 0xb7,
-	0x1f, 0xf8, 0x0b, 0x75, 0x10, 0x40, 0x0f, 0xc4, 0x05, 0xe8, 0x0b, 0x21,
-	0x00, 0x14, 0x14, 0x04, 0x1f, 0xc0, 0x00, 0x2b, 0x1f, 0x39, 0x07, 0xba,
-	0x01, 0x48, 0x0f, 0xf0, 0x0a, 0x07, 0x00, 0x32, 0x0f, 0xc4, 0x01, 0x9e,
-	0x0f, 0x38, 0x00, 0x02, 0x0f, 0xc4, 0x01, 0x9e, 0x0f, 0xc5, 0x07, 0x5e,
-	0x0b, 0xa1, 0x0b, 0xd2, 0x11, 0x3a, 0x11, 0x08, 0x0f, 0x39, 0x0f, 0xc8,
-	0x00, 0x3c, 0x08, 0xbb, 0x0f, 0xc4, 0x01, 0x7f, 0x0b, 0x21, 0x00, 0x00,
-	0x00, 0x15, 0x0f, 0xc4, 0x01, 0xbc, 0x0b, 0x21, 0x00, 0x19, 0x10, 0x59,
-	0x09, 0xc0, 0x09, 0xe1, 0x00, 0x93, 0x14, 0x04, 0x1f, 0xc0, 0x00, 0x32,
-	0x0f, 0xc8, 0x00, 0x3c, 0x03, 0x3b, 0x1f, 0x39, 0x0f, 0xc4, 0x01, 0xb0,
-	0x0f, 0xc0, 0x00, 0x96, 0x0f, 0xc4, 0x01, 0x80, 0x0b, 0x21, 0x00, 0x15,
-	0x1f, 0xc4, 0x01, 0x83, 0x1f, 0xfa, 0x04, 0x60, 0x10, 0x40, 0x0f, 0x39,
-	0x0f, 0xc4, 0x01, 0x78, 0x0b, 0x21, 0x0f, 0xd3, 0x00, 0xfa, 0x1f, 0xf9,
-	0x0b, 0xcd, 0x0f, 0xc5, 0x01, 0xbe, 0x0f, 0xc4, 0x01, 0xbd, 0x0b, 0x21,
-	0x00, 0x59, 0x09, 0xc0, 0x09, 0xe1, 0x0f, 0xd3, 0x00, 0x28, 0x1f, 0x39,
-	0x0f, 0xd2, 0x00, 0x3c, 0x1f, 0xc0, 0x00, 0x28, 0x10, 0x01, 0x0f, 0xc4,
-	0x05, 0x86, 0x0b, 0x21, 0x00, 0x93, 0x1b, 0x61, 0x10, 0x59, 0x19, 0xc1,
-	0x0b, 0x61, 0x02, 0x93, 0x1f, 0x39, 0x01, 0x38, 0x01, 0x08, 0x0f, 0xc8,
-	0x00, 0x3c, 0x08, 0xbb, 0x0f, 0xfb, 0x0b, 0xac, 0x07, 0x37, 0x00, 0x48,
-	0x11, 0x08, 0x0c, 0x21, 0x0f, 0xc4, 0x01, 0x2e, 0x0b, 0x20, 0x09, 0xc2,
-	0x09, 0xc8, 0x00, 0x21, 0x0b, 0x19, 0x09, 0xc2, 0x07, 0xba, 0x00, 0x88,
-	0x0f, 0xc8, 0x00, 0x3c, 0x0f, 0xf7, 0x00, 0x3a, 0x1f, 0xf9, 0x0b, 0xed,
-	0x0f, 0xd5, 0x00, 0x32, 0x1f, 0xf9, 0x0b, 0xf2, 0x0f, 0x39, 0x02, 0x3a,
-	0x00, 0x48, 0x0f, 0xfb, 0x11, 0x41, 0x0f, 0x39, 0x01, 0x3a, 0x01, 0x08,
-	0x02, 0x3a, 0x00, 0x08, 0x02, 0xba, 0x00, 0x08, 0x0f, 0x39, 0x0f, 0x39,
-	0x0f, 0xf7, 0x0a, 0x0a, 0x0f, 0xf7, 0x0a, 0x72, 0x0f, 0x39, 0x09, 0x3b,
-	0x0f, 0xfb, 0x0c, 0xf8, 0x0f, 0xfb, 0x13, 0xae, 0x0f, 0xfb, 0x0c, 0x26,
-	0x0f, 0xfb, 0x02, 0x35, 0x04, 0x3b, 0x0f, 0xf7, 0x0c, 0x13, 0x0f, 0xf7,
-	0x0c, 0x97, 0x0f, 0x39, 0x00, 0x04, 0x0c, 0x00, 0x09, 0x3b, 0x0f, 0xf6,
-	0x00, 0x3a, 0x00, 0x48, 0x1f, 0x39, 0x02, 0x14, 0x1f, 0x39, 0x0f, 0xc4,
-	0x05, 0x86, 0x0b, 0x21, 0x00, 0x59, 0x09, 0xc8, 0x09, 0xe1, 0x02, 0x96,
-	0x1f, 0xf9, 0x0c, 0x22, 0x0f, 0x38, 0x0c, 0x00, 0x04, 0x04, 0x00, 0x05,
-	0x0b, 0x40, 0x0f, 0x39, 0x0f, 0xc4, 0x00, 0x56, 0x02, 0x37, 0x0f, 0xc5,
-	0x00, 0x56, 0x04, 0xb7, 0x0f, 0xc4, 0x00, 0x74, 0x04, 0xb7, 0x0f, 0xc4,
-	0x00, 0xe9, 0x00, 0x37, 0x03, 0x37, 0x0f, 0xc4, 0x05, 0xd7, 0x07, 0x05,
-	0x0b, 0x83, 0x0b, 0x83, 0x0f, 0xc3, 0x07, 0xff, 0x0f, 0xf7, 0x01, 0x39,
-	0x0f, 0xc4, 0x00, 0xec, 0x0f, 0xc5, 0x00, 0xef, 0x04, 0xb7, 0x0f, 0xc4,
-	0x00, 0xec, 0x00, 0x37, 0x0f, 0xc4, 0x00, 0xe9, 0x0f, 0xf7, 0x02, 0x93,
-	0x0f, 0xc4, 0x00, 0xef, 0x02, 0xb7, 0x0f, 0xc4, 0x00, 0xf2, 0x00, 0x37,
-	0x0f, 0xc4, 0x06, 0xb1, 0x0f, 0xf7, 0x02, 0x81, 0x01, 0x36, 0x03, 0x08,
-	0x03, 0xb7, 0x0f, 0xc4, 0x01, 0x64, 0x0f, 0x38, 0x0c, 0x00, 0x0f, 0xc4,
-	0x01, 0xa2, 0x0b, 0x21, 0x00, 0x15, 0x1f, 0xfb, 0x0d, 0xa1, 0x0f, 0xf1,
-	0x05, 0x0d, 0x0a, 0x48, 0x0f, 0xf1, 0x05, 0x0e, 0x0f, 0xc4, 0x01, 0x9a,
-	0x0c, 0x00, 0x0f, 0xc4, 0x01, 0x9b, 0x0a, 0x49, 0x0f, 0xf6, 0x03, 0xcd,
-	0x0c, 0x40, 0x0f, 0xc4, 0x01, 0x72, 0x0c, 0x00, 0x0f, 0xc4, 0x07, 0x06,
-	0x0b, 0x21, 0x00, 0x14, 0x1f, 0xc4, 0x01, 0x64, 0x1c, 0x21, 0x1b, 0x19,
-	0x19, 0xc8, 0x0f, 0xf6, 0x00, 0x47, 0x00, 0x4b, 0x10, 0x08, 0x0f, 0xc4,
-	0x01, 0x83, 0x0b, 0x21, 0x00, 0x15, 0x10, 0x08, 0x0f, 0xc4, 0x01, 0x9c,
-	0x0c, 0x21, 0x0b, 0x19, 0x09, 0xc0, 0x09, 0xc9, 0x0f, 0xc4, 0x01, 0x9d,
-	0x0b, 0x21, 0x0c, 0x51, 0x09, 0xca, 0x0f, 0xc4, 0x01, 0xbf, 0x0b, 0x21,
-	0x0c, 0x91, 0x09, 0xc8, 0x0c, 0x80, 0x0f, 0xf0, 0x05, 0x02, 0x07, 0x36,
-	0x0c, 0xb2, 0x1f, 0xc4, 0x00, 0xd7, 0x1a, 0x85, 0x1b, 0x8b, 0x1b, 0x83,
-	0x1b, 0x83, 0x1c, 0x83, 0x1c, 0xca, 0x0f, 0xf6, 0x00, 0x42, 0x01, 0xcb,
-	0x1f, 0xf0, 0x05, 0x08, 0x1c, 0xb2, 0x0f, 0xc4, 0x01, 0xa9, 0x0c, 0x00,
-	0x0f, 0xfb, 0x0e, 0x59, 0x0f, 0xfb, 0x13, 0x6f, 0x0f, 0xfb, 0x0e, 0xd8,
-	0x0f, 0xc4, 0x01, 0xa9, 0x0b, 0x09, 0x00, 0xb6, 0x00, 0x08, 0x0f, 0xc8,
-	0x1f, 0xe8, 0x01, 0x37, 0x0f, 0xc4, 0x00, 0xda, 0x00, 0x37, 0x03, 0x37,
-	0x0f, 0xc4, 0x06, 0xb1, 0x05, 0xb7, 0x0f, 0xf7, 0x01, 0x39, 0x0f, 0xc4,
-	0x00, 0xdd, 0x00, 0x37, 0x0f, 0xc4, 0x01, 0xa9, 0x0b, 0x08, 0x00, 0x09,
-	0x0c, 0x21, 0x02, 0xdf, 0x1f, 0xc9, 0x0f, 0xff, 0x0f, 0xc4, 0x01, 0x44,
-	0x0b, 0x21, 0x0c, 0x20, 0x09, 0xc2, 0x09, 0xc8, 0x0b, 0x21, 0x0c, 0x59,
-	0x09, 0xc0, 0x09, 0xc9, 0x0f, 0xc5, 0x02, 0x1f, 0x0f, 0xc4, 0x02, 0x21,
-	0x02, 0xbe, 0x0f, 0xf7, 0x00, 0x2d, 0x0c, 0x03, 0x0c, 0x43, 0x0f, 0xf1,
-	0x0a, 0x18, 0x08, 0x84, 0x0b, 0x21, 0x0f, 0xd9, 0x00, 0x5c, 0x09, 0xc4,
-	0x0a, 0x40, 0x0f, 0xf1, 0x0a, 0x19, 0x0f, 0xd9, 0x00, 0x60, 0x09, 0xc4,
-	0x0a, 0x40, 0x0f, 0xf1, 0x0a, 0x1a, 0x0f, 0xd9, 0x00, 0x64, 0x09, 0xc4,
-	0x0a, 0x40, 0x0f, 0xf1, 0x0a, 0x1b, 0x0f, 0xd9, 0x00, 0x68, 0x09, 0xc4,
-	0x0a, 0x40, 0x0f, 0x39, 0x0f, 0xc4, 0x01, 0x34, 0x0b, 0x88, 0x0b, 0x89,
-	0x0f, 0xf0, 0x05, 0x01, 0x0c, 0x32, 0x0f, 0xf0, 0x05, 0x00, 0x0c, 0x72,
-	0x0f, 0xf0, 0x05, 0x07, 0x0c, 0x32, 0x0f, 0xf0, 0x05, 0x06, 0x0f, 0x38,
-	0x0c, 0x72, 0x0f, 0xfb, 0x0d, 0xb2, 0x0f, 0xc4, 0x01, 0x9f, 0x0b, 0x22,
-	0x0f, 0xf1, 0x0a, 0x04, 0x0a, 0x62, 0x00, 0x48, 0x00, 0x09, 0x00, 0x21,
-	0x0f, 0xc4, 0x01, 0xad, 0x0b, 0x21, 0x00, 0xd9, 0x09, 0xca, 0x09, 0xe1,
-	0x03, 0x12, 0x19, 0xca, 0x0c, 0x80, 0x04, 0x24, 0x00, 0x21, 0x09, 0x94,
-	0x1f, 0xf9, 0x0d, 0x46, 0x00, 0x49, 0x08, 0x24, 0x09, 0x94, 0x1f, 0xf8,
-	0x0d, 0x46, 0x10, 0x08, 0x03, 0xe4, 0x0c, 0xa1, 0x09, 0x95, 0x09, 0x80,
-	0x10, 0x08, 0x0f, 0xe4, 0x00, 0x80, 0x09, 0x94, 0x1f, 0xf9, 0x0d, 0x46,
-	0x00, 0x49, 0x0f, 0xe4, 0x00, 0x40, 0x09, 0x94, 0x10, 0x08, 0x0f, 0xc4,
-	0x01, 0x42, 0x00, 0x21, 0x0b, 0x95, 0x10, 0x08, 0x0b, 0x95, 0x10, 0x08,
-	0x08, 0x84, 0x0b, 0x0a, 0x0c, 0xa1, 0x0f, 0xc4, 0x01, 0xa4, 0x0b, 0x15,
-	0x10, 0x08, 0x1c, 0x80, 0x00, 0x21, 0x0c, 0x54, 0x1f, 0xf9, 0x0d, 0x57,
-	0x0c, 0x14, 0x1f, 0xf9, 0x0d, 0x57, 0x0f, 0xc4, 0x01, 0xaf, 0x0b, 0x0b,
-	0x0f, 0xc5, 0x01, 0xae, 0x0c, 0xe1, 0x0b, 0x56, 0x00, 0x00, 0x0f, 0x38,
-	0x1c, 0xc1, 0x0f, 0xc4, 0x01, 0xaf, 0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0,
-	0x09, 0xe1, 0x0f, 0xc4, 0x01, 0xb0, 0x0b, 0x17, 0x1f, 0x39, 0x0f, 0xc4,
-	0x01, 0xa5, 0x0c, 0x67, 0x09, 0xa2, 0x0c, 0x25, 0x09, 0x80, 0x0c, 0x21,
-	0x00, 0x15, 0x01, 0x48, 0x01, 0x38, 0x11, 0x88, 0x0f, 0x39, 0x0f, 0xc5,
-	0x01, 0xa4, 0x08, 0x84, 0x00, 0x61, 0x00, 0xe2, 0x0b, 0x19, 0x09, 0xe4,
-	0x09, 0x80, 0x09, 0x81, 0x0f, 0xf1, 0x0a, 0x04, 0x0f, 0xc5, 0x01, 0xb1,
-	0x0f, 0xc4, 0x01, 0x9f, 0x0a, 0x48, 0x0c, 0x01, 0x0c, 0x22, 0x0f, 0xe4,
-	0x00, 0xf0, 0x09, 0x80, 0x0f, 0xe4, 0x00, 0xc0, 0x09, 0xa1, 0x0f, 0xd5,
-	0x00, 0xc0, 0x0f, 0x39, 0x00, 0x61, 0x00, 0xe2, 0x0f, 0xc4, 0x01, 0xa4,
-	0x0b, 0x19, 0x09, 0xe4, 0x09, 0x80, 0x08, 0x84, 0x09, 0x80, 0x09, 0xa1,
-	0x00, 0x14, 0x1f, 0xc4, 0x01, 0x82, 0x1b, 0x21, 0x10, 0x59, 0x19, 0xc0,
-	0x0f, 0xc4, 0x01, 0x9f, 0x0f, 0xc0, 0x00, 0xf0, 0x0f, 0xe1, 0x00, 0xc0,
-	0x0f, 0xd5, 0x00, 0xc0, 0x0f, 0x39, 0x00, 0x61, 0x00, 0xe2, 0x08, 0x84,
-	0x0b, 0x19, 0x09, 0xe4, 0x0f, 0xf0, 0x0a, 0x05, 0x07, 0xb6, 0x09, 0xb2,
-	0x0f, 0xcb, 0x00, 0xac, 0x1f, 0xcb, 0x02, 0xb0, 0x0f, 0xf0, 0x0a, 0x06,
-	0x0c, 0xf2, 0x0f, 0x39, 0x0f, 0xc4, 0x01, 0xa2, 0x0b, 0x21, 0x00, 0x15,
-	0x1f, 0xf9, 0x0d, 0xf2, 0x0f, 0xfb, 0x0d, 0x6d, 0x1f, 0x39, 0x07, 0xb7,
-	0x0f, 0xcb, 0x00, 0xac, 0x1f, 0xcb, 0x02, 0xb0, 0x0f, 0xf1, 0x0a, 0x06,
-	0x0a, 0x4a, 0x0c, 0xa1, 0x0c, 0xd8, 0x09, 0xca, 0x00, 0x21, 0x00, 0x11,
-	0x09, 0xcb, 0x0f, 0xc4, 0x01, 0x42, 0x0c, 0x82, 0x0c, 0xc2, 0x00, 0x21,
-	0x0c, 0x95, 0x1f, 0xf9, 0x0d, 0xe1, 0x0c, 0xd5, 0x1f, 0xf9, 0x0d, 0xe1,
-	0x0f, 0xf1, 0x0a, 0x05, 0x08, 0x84, 0x00, 0xe2, 0x0a, 0x64, 0x09, 0x80,
-	0x08, 0x84, 0x0b, 0x21, 0x0f, 0xc4, 0x01, 0xa4, 0x0b, 0x14, 0x1f, 0xf9,
-	0x0d, 0xe5, 0x0f, 0xc4, 0x01, 0xa3, 0x0f, 0x38, 0x00, 0x00, 0x0f, 0xc4,
-	0x01, 0xa3, 0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x09, 0xe1, 0x00, 0xd5,
-	0x1f, 0x39, 0x0f, 0xc4, 0x01, 0xa2, 0x0f, 0xc0, 0x0a, 0xaa, 0x0f, 0x39,
-	0x0f, 0xf9, 0x0d, 0x88, 0x0f, 0x39, 0x0f, 0xc4, 0x01, 0xb6, 0x00, 0x00,
-	0x0f, 0xc4, 0x01, 0xb3, 0x00, 0x00, 0x0f, 0xc4, 0x01, 0xb5, 0x00, 0x00,
-	0x0f, 0xc4, 0x01, 0xb2, 0x08, 0x00, 0x0f, 0xc4, 0x01, 0xb4, 0x0f, 0x38,
-	0x08, 0x00, 0x0f, 0xc4, 0x01, 0xb2, 0x0b, 0x21, 0x00, 0xd9, 0x09, 0xc8,
-	0x09, 0xe1, 0x03, 0x12, 0x19, 0xc8, 0x0c, 0x00, 0x0f, 0xc4, 0x01, 0xb4,
-	0x0b, 0x21, 0x00, 0xd3, 0x09, 0xc8, 0x19, 0xe1, 0x13, 0x19, 0x19, 0xc8,
-	0x0c, 0x00, 0x0f, 0xc4, 0x01, 0xb1, 0x0b, 0x22, 0x0f, 0xe4, 0x00, 0x30,
-	0x09, 0xa1, 0x0f, 0xd5, 0x00, 0x30, 0x1f, 0x39, 0x03, 0xe4, 0x09, 0xa1,
-	0x0f, 0xc4, 0x01, 0xb2, 0x0b, 0x14, 0x09, 0x80, 0x0f, 0xc4, 0x01, 0xb3,
-	0x0b, 0x21, 0x00, 0x19, 0x10, 0x59, 0x09, 0xc0, 0x09, 0xc8, 0x09, 0xa1,
-	0x0f, 0xc4, 0x01, 0xb4, 0x0b, 0x14, 0x09, 0x80, 0x0f, 0xc4, 0x01, 0xb5,
-	0x0b, 0x21, 0x00, 0x19, 0x10, 0x59, 0x09, 0xc0, 0x09, 0xc9, 0x0c, 0x61,
-	0x03, 0x17, 0x1f, 0x39, 0x0c, 0x17, 0x1f, 0xf9, 0x0d, 0xf5, 0x0f, 0xc4,
-	0x01, 0xb6, 0x00, 0x40, 0x0f, 0x39, 0x00, 0xe2, 0x0c, 0x24, 0x09, 0xa1,
-	0x09, 0xa7, 0x09, 0x99, 0x09, 0xc9, 0x0f, 0xc4, 0x01, 0xa4, 0x0b, 0x19,
-	0x09, 0xe4, 0x09, 0x80, 0x08, 0x84, 0x09, 0x80, 0x0f, 0xc4, 0x01, 0xad,
-	0x0b, 0x21, 0x0c, 0x59, 0x09, 0xc0, 0x09, 0xe1, 0x03, 0x12, 0x0f, 0x38,
-	0x19, 0xc0, 0x0f, 0xf1, 0x05, 0x0f, 0x00, 0x04, 0x0f, 0x00, 0x05, 0x84,
-	0x0f, 0xc2, 0x08, 0x00, 0x0a, 0x42, 0x0f, 0xf1, 0x05, 0x10, 0x0f, 0xf6,
-	0x02, 0x99, 0x00, 0x02, 0x05, 0x21, 0x0a, 0x51, 0x01, 0x36, 0x09, 0xc8,
-	0x0f, 0xc4, 0x00, 0xe6, 0x00, 0x37, 0x05, 0x84, 0x0b, 0xaa, 0x0b, 0xab,
-	0x0f, 0xee, 0x01, 0xc0, 0x0b, 0xa7, 0x09, 0xa6, 0x09, 0x89, 0x0c, 0x21,
-	0x0f, 0xd7, 0x1f, 0xff, 0x0f, 0xd0, 0x1f, 0xfd, 0x1f, 0xd9, 0x1f, 0xfd,
-	0x10, 0x09, 0x09, 0xe1, 0x0f, 0xd7, 0x1f, 0xf4, 0x1f, 0xe1, 0x1f, 0xf5,
-	0x0f, 0xd9, 0x0a, 0x80, 0x09, 0xee, 0x0e, 0x48, 0x0c, 0x2a, 0x00, 0x2b,
-	0x0f, 0xee, 0x01, 0xc0, 0x03, 0x61, 0x0c, 0x57, 0x1c, 0x61, 0x0f, 0xd9,
-	0x0a, 0x00, 0x09, 0xee, 0x0f, 0xc4, 0x01, 0x46, 0x0b, 0xa1, 0x0e, 0x18,
-	0x09, 0xca, 0x0b, 0xa1, 0x0e, 0x53, 0x09, 0xcb, 0x10, 0x21, 0x1c, 0x98,
-	0x19, 0xca, 0x1c, 0xd1, 0x19, 0xcb, 0x0f, 0xc4, 0x01, 0x48, 0x0c, 0xa1,
-	0x0b, 0x98, 0x0c, 0xe1, 0x0b, 0x93, 0x1f, 0xf9, 0x0e, 0xd6, 0x0f, 0xc4,
-	0x01, 0x46, 0x0e, 0x02, 0x0e, 0x42, 0x0f, 0xf6, 0x00, 0x47, 0x01, 0x8b,
-	0x1f, 0xf9, 0x0e, 0xd5, 0x0f, 0xf0, 0x05, 0x04, 0x0c, 0x32, 0x0f, 0xf0,
-	0x05, 0x05, 0x07, 0x36, 0x0c, 0x72, 0x1f, 0xf9, 0x0e, 0xc2, 0x0f, 0xf6,
-	0x00, 0x42, 0x01, 0xcb, 0x1f, 0xf0, 0x05, 0x0a, 0x1c, 0x32, 0x1f, 0xf0,
-	0x05, 0x0b, 0x0f, 0xf8, 0x0e, 0xd5, 0x1c, 0x72, 0x0f, 0xf6, 0x00, 0x42,
-	0x01, 0xcb, 0x0f, 0xc4, 0x00, 0x50, 0x0a, 0x85, 0x1f, 0xf0, 0x05, 0x0a,
-	0x1b, 0xb2, 0x1f, 0xf0, 0x05, 0x0b, 0x1b, 0xb2, 0x0f, 0xc4, 0x00, 0x52,
-	0x01, 0x3e, 0x0f, 0xf7, 0x00, 0x2d, 0x0c, 0x03, 0x0c, 0x43, 0x00, 0x3f,
-	0x00, 0x04, 0x0b, 0x39, 0x0f, 0x39, 0x0f, 0xc8, 0x00, 0x80, 0x0f, 0xf7,
-	0x05, 0x5c, 0x0f, 0xf1, 0x03, 0x2d, 0x0f, 0xc4, 0x01, 0xc2, 0x0a, 0x40,
-	0x0f, 0xf0, 0x04, 0x00, 0x00, 0x72, 0x0f, 0xf0, 0x05, 0x11, 0x00, 0x72,
-	0x0f, 0xf1, 0x0a, 0x1f, 0x03, 0xe2, 0x00, 0x61, 0x0f, 0xc4, 0x01, 0xc0,
-	0x0a, 0x64, 0x09, 0x80, 0x0f, 0xc4, 0x05, 0x46, 0x09, 0x99, 0x09, 0xc0,
-	0x0f, 0xc4, 0x05, 0x47, 0x00, 0x00, 0x02, 0xba, 0x00, 0x08, 0x0f, 0xf7,
-	0x0a, 0xc2, 0x0f, 0xf7, 0x0b, 0xb6, 0x0f, 0xfb, 0x0f, 0x73, 0x09, 0x36,
-	0x00, 0x48, 0x0f, 0xf6, 0x05, 0x5c, 0x00, 0x48, 0x0f, 0xf1, 0x03, 0x2d,
-	0x0f, 0xc4, 0x01, 0xc3, 0x0a, 0x40, 0x0f, 0xc4, 0x06, 0x94, 0x0f, 0xc5,
-	0x01, 0x4a, 0x0b, 0xa1, 0x0b, 0xe0, 0x0f, 0xf0, 0x03, 0x2a, 0x09, 0xf2,
-	0x0b, 0xa1, 0x0b, 0xd9, 0x0f, 0xf0, 0x03, 0x29, 0x09, 0xf2, 0x0f, 0xf6,
-	0x05, 0x5c, 0x00, 0x48, 0x0f, 0xc4, 0x06, 0x94, 0x0f, 0xf0, 0x03, 0x2a,
-	0x0b, 0xb2, 0x0f, 0xf0, 0x03, 0x29, 0x0b, 0xb2, 0x0f, 0xf0, 0x05, 0x11,
-	0x00, 0x32, 0x0f, 0xf0, 0x04, 0x00, 0x00, 0x32, 0x0f, 0xf6, 0x05, 0x5c,
-	0x00, 0x48, 0x0f, 0xf0, 0x0a, 0x07, 0x04, 0x32, 0x0f, 0xc4, 0x04, 0xc8,
-	0x0b, 0x21, 0x00, 0x92, 0x1f, 0xf9, 0x0f, 0x3b, 0x04, 0x04, 0x0f, 0xc0,
-	0x00, 0x32, 0x09, 0x04, 0x0f, 0xf8, 0x0f, 0x42, 0x00, 0x80, 0x04, 0x04,
-	0x0f, 0xc0, 0x00, 0x47, 0x0f, 0xfb, 0x16, 0x6c, 0x09, 0x04, 0x00, 0x00,
-	0x08, 0xc4, 0x02, 0xc0, 0x0f, 0xc8, 0x00, 0x41, 0x0f, 0xf7, 0x05, 0x23,
-	0x0f, 0xc4, 0x01, 0xaf, 0x00, 0x00, 0x0f, 0xc4, 0x05, 0x86, 0x00, 0x00,
-	0x02, 0x36, 0x04, 0xc4, 0x0f, 0xc4, 0x05, 0x6e, 0x00, 0x37, 0x0f, 0xc4,
-	0x06, 0x96, 0x02, 0x37, 0x0f, 0xc4, 0x05, 0x71, 0x00, 0x37, 0x0f, 0xf7,
-	0x0b, 0xdb, 0x0f, 0xf7, 0x05, 0xb9, 0x0f, 0xc4, 0x01, 0x71, 0x0b, 0x21,
-	0x00, 0x15, 0x0f, 0xc4, 0x01, 0xc3, 0x0b, 0x21, 0x0f, 0xc4, 0x01, 0xc2,
-	0x0b, 0x11, 0x09, 0xe1, 0x00, 0xd9, 0x10, 0xd9, 0x0f, 0xc4, 0x01, 0xc4,
-	0x09, 0xc0, 0x0f, 0xfa, 0x0e, 0x43, 0x09, 0xc8, 0x07, 0xba, 0x01, 0x88,
-	0x0f, 0x39, 0x0f, 0xfb, 0x10, 0x36, 0x0f, 0xc4, 0x01, 0x07, 0x0f, 0xc5,
-	0x01, 0x04, 0x0b, 0x83, 0x0b, 0x83, 0x0f, 0xfa, 0x10, 0xa4, 0x0b, 0x83,
-	0x0f, 0xfb, 0x10, 0x36, 0x0f, 0xc4, 0x05, 0x49, 0x0b, 0x08, 0x0f, 0xe1,
-	0x07, 0x55, 0x0c, 0x17, 0x1f, 0xf9, 0x0f, 0x8f, 0x00, 0x21, 0x0c, 0x18,
-	0x09, 0xc8, 0x00, 0x11, 0x0f, 0xf8, 0x0f, 0x94, 0x09, 0xc9, 0x00, 0x09,
-	0x0f, 0xe1, 0x08, 0x00, 0x0c, 0x11, 0x09, 0xc8, 0x00, 0xb7, 0x0f, 0xc4,
-	0x01, 0x0a, 0x02, 0xb7, 0x07, 0x04, 0x0f, 0xc2, 0x0a, 0xab, 0x0f, 0xc2,
-	0x0a, 0xaa, 0x0f, 0xc2, 0x07, 0xfe, 0x0f, 0xf7, 0x02, 0x70, 0x04, 0x44,
-	0x00, 0x08, 0x03, 0x61, 0x0b, 0x14, 0x01, 0x36, 0x10, 0x88, 0x0f, 0xc4,
-	0x00, 0xf5, 0x00, 0x37, 0x01, 0x08, 0x00, 0xb6, 0x00, 0x09, 0x0f, 0xc4,
-	0x00, 0xf5, 0x0f, 0xf7, 0x02, 0x93, 0x03, 0xb7, 0x0f, 0xc4, 0x01, 0x4a,
-	0x0c, 0x02, 0x00, 0xb6, 0x0c, 0x42, 0x05, 0x37, 0x04, 0x37, 0x03, 0x37,
-	0x00, 0x08, 0x00, 0xb6, 0x00, 0x09, 0x05, 0x37, 0x04, 0x37, 0x0f, 0xc4,
-	0x00, 0xf8, 0x00, 0x37, 0x03, 0xb7, 0x0f, 0xc4, 0x01, 0x63, 0x03, 0x36,
-	0x0c, 0x00, 0x00, 0xb7, 0x05, 0x37, 0x04, 0x37, 0x0f, 0xc4, 0x06, 0xae,
-	0x00, 0x37, 0x0f, 0xc4, 0x05, 0x74, 0x00, 0x37, 0x0f, 0xc4, 0x00, 0xf8,
-	0x02, 0x37, 0x04, 0x44, 0x02, 0xc8, 0x02, 0xe1, 0x0b, 0x14, 0x01, 0x36,
-	0x13, 0x48, 0x03, 0xb7, 0x0f, 0xc4, 0x01, 0x34, 0x0c, 0x02, 0x0f, 0xfa,
-	0x0c, 0xf8, 0x0c, 0x42, 0x0f, 0x39, 0x0f, 0xf0, 0x05, 0x16, 0x0c, 0x32,
-	0x0f, 0xc4, 0x01, 0x4c, 0x0c, 0x00, 0x0f, 0xf0, 0x05, 0x18, 0x0f, 0x38,
-	0x0c, 0x32, 0x0f, 0xf0, 0x05, 0x32, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x33,
-	0x0f, 0x38, 0x00, 0x32, 0x0f, 0xf1, 0x05, 0x12, 0x0f, 0xc4, 0x01, 0x4c,
-	0x0c, 0x21, 0x0b, 0x15, 0x1f, 0xfb, 0x0f, 0xe1, 0x1f, 0xf1, 0x05, 0x12,
-	0x0a, 0x49, 0x0f, 0xf1, 0x05, 0x13, 0x0f, 0xc4, 0x01, 0x4c, 0x00, 0x61,
-	0x0b, 0x19, 0x09, 0xc0, 0x0f, 0x38, 0x0a, 0x48, 0x0f, 0xfb, 0x0f, 0xf2,
-	0x0c, 0x2a, 0x0c, 0x6b, 0x0f, 0xee, 0x02, 0x40, 0x03, 0xe2, 0x0c, 0x24,
-	0x0f, 0xee, 0x0a, 0x7e, 0x09, 0x8a, 0x0f, 0xe2, 0x0f, 0xfc, 0x0c, 0x64,
-	0x09, 0x89, 0x0e, 0x24, 0x09, 0x88, 0x00, 0x2a, 0x00, 0x2c, 0x0c, 0x0b,
-	0x00, 0x21, 0x0c, 0x16, 0x19, 0xcb, 0x0c, 0xeb, 0x0c, 0xed, 0x0f, 0xee,
-	0x0c, 0x80, 0x0f, 0xc4, 0x01, 0x0d, 0x0c, 0x02, 0x0c, 0x42, 0x0c, 0x56,
-	0x19, 0xc9, 0x0c, 0x6b, 0x0c, 0x6d, 0x0f, 0xee, 0x0c, 0xc0, 0x0c, 0x82,
-	0x0c, 0xa7, 0x09, 0xa1, 0x05, 0x84, 0x0f, 0xee, 0x0a, 0xd3, 0x0e, 0x02,
-	0x0e, 0x42, 0x0e, 0x99, 0x0f, 0x38, 0x09, 0xc2, 0x04, 0x44, 0x0b, 0x21,
-	0x03, 0x54, 0x1f, 0xf9, 0x10, 0x54, 0x0f, 0xc4, 0x05, 0x49, 0x0b, 0x08,
-	0x0f, 0xfa, 0x0f, 0xe1, 0x00, 0x09, 0x0f, 0xfb, 0x10, 0x06, 0x0f, 0xc4,
-	0x01, 0x07, 0x00, 0x37, 0x0f, 0xc4, 0x00, 0xfe, 0x00, 0x37, 0x0f, 0xc4,
-	0x00, 0xfb, 0x01, 0xb7, 0x0f, 0xc4, 0x01, 0x01, 0x01, 0xb7, 0x0f, 0xc4,
-	0x01, 0x0a, 0x01, 0xb7, 0x0f, 0xf9, 0x0f, 0xeb, 0x0f, 0xc4, 0x05, 0x49,
-	0x0b, 0x21, 0x00, 0x51, 0x09, 0xc8, 0x00, 0x09, 0x00, 0x04, 0x0c, 0x00,
-	0x0f, 0xfb, 0x0f, 0xe1, 0x0f, 0xfb, 0x10, 0x06, 0x0f, 0xf7, 0x04, 0x66,
-	0x03, 0x37, 0x0f, 0xc4, 0x00, 0xfb, 0x00, 0x37, 0x0f, 0xfb, 0x10, 0x99,
-	0x0f, 0xfb, 0x10, 0x06, 0x05, 0x37, 0x0f, 0xc4, 0x00, 0xfe, 0x00, 0x37,
-	0x06, 0x37, 0x03, 0x37, 0x0f, 0xfb, 0x10, 0x99, 0x0f, 0xfb, 0x10, 0x06,
-	0x0f, 0xf7, 0x04, 0x66, 0x05, 0x37, 0x0f, 0xc4, 0x01, 0x01, 0x00, 0x37,
-	0x06, 0x37, 0x0f, 0xc4, 0x01, 0x07, 0x00, 0x37, 0x0f, 0xf7, 0x04, 0x72,
-	0x0f, 0xf7, 0x04, 0x6f, 0x04, 0x37, 0x0f, 0xc4, 0x01, 0x07, 0x0f, 0xf7,
-	0x02, 0x81, 0x07, 0x04, 0x0f, 0xc2, 0x05, 0x3b, 0x0f, 0xc2, 0x08, 0x8c,
-	0x0f, 0xf6, 0x02, 0x70, 0x00, 0x02, 0x0f, 0xc4, 0x01, 0x0a, 0x00, 0x37,
-	0x0f, 0xc4, 0x00, 0xfe, 0x0f, 0xc5, 0x01, 0x07, 0x04, 0xb7, 0x0f, 0xf9,
-	0x0f, 0xeb, 0x00, 0x04, 0x00, 0x61, 0x0f, 0xe2, 0x07, 0xff, 0x0b, 0x19,
-	0x09, 0xe4, 0x09, 0x88, 0x0c, 0x00, 0x0f, 0x38, 0x00, 0x09, 0x0f, 0x39,
-	0x01, 0x84, 0x0f, 0xc0, 0x07, 0xf8, 0x0f, 0xc4, 0x01, 0x04, 0x02, 0x37,
-	0x00, 0x21, 0x0f, 0xc4, 0x07, 0x26, 0x0b, 0x11, 0x01, 0x36, 0x09, 0xc8,
-	0x0f, 0xc4, 0x01, 0x10, 0x00, 0x37, 0x00, 0x36, 0x00, 0x44, 0x0f, 0xc4,
-	0x05, 0x48, 0x0b, 0x08, 0x01, 0xc4, 0x0c, 0x00, 0x01, 0x44, 0x0c, 0x00,
-	0x00, 0x04, 0x00, 0x40, 0x0c, 0x21, 0x01, 0x19, 0x09, 0xe2, 0x0f, 0xe4,
-	0x07, 0xff, 0x09, 0x88, 0x00, 0x09, 0x01, 0x04, 0x0f, 0xfa, 0x0f, 0xe1,
-	0x0c, 0x00, 0x0f, 0xc4, 0x04, 0xc8, 0x00, 0x00, 0x0f, 0xc4, 0x04, 0xc9,
-	0x00, 0x00, 0x0f, 0xc4, 0x04, 0xca, 0x00, 0x00, 0x0f, 0xfb, 0x10, 0x06,
-	0x03, 0x37, 0x0f, 0xc4, 0x01, 0x10, 0x05, 0xb7, 0x0f, 0xfb, 0x00, 0x58,
-	0x1f, 0xf9, 0x10, 0xe7, 0x00, 0x04, 0x0b, 0x21, 0x00, 0x14, 0x1f, 0xf9,
-	0x10, 0xe3, 0x0f, 0xfb, 0x11, 0x1b, 0x01, 0xb6, 0x00, 0x44, 0x0f, 0xf9,
-	0x10, 0xfc, 0x05, 0xb6, 0x00, 0x44, 0x0f, 0xfb, 0x00, 0x58, 0x1f, 0xf9,
-	0x10, 0xf4, 0x00, 0x04, 0x0b, 0x21, 0x00, 0x15, 0x1f, 0xfb, 0x11, 0x1b,
-	0x0f, 0xf9, 0x10, 0xf9, 0x01, 0x04, 0x01, 0x45, 0x0b, 0x01, 0x00, 0x04,
-	0x00, 0x40, 0x0f, 0xf6, 0x00, 0xaf, 0x00, 0x44, 0x01, 0x84, 0x0b, 0x21,
-	0x00, 0x54, 0x1f, 0xf8, 0x11, 0x0d, 0x09, 0xc0, 0x01, 0x04, 0x00, 0x61,
-	0x0f, 0xe2, 0x07, 0xff, 0x0b, 0x19, 0x09, 0xe4, 0x09, 0x88, 0x0c, 0x00,
-	0x0f, 0xf8, 0x10, 0xd2, 0x00, 0x09, 0x0f, 0xfb, 0x0f, 0xeb, 0x0f, 0xc4,
-	0x04, 0xca, 0x0b, 0x21, 0x0f, 0xd9, 0x04, 0xb8, 0x09, 0xc4, 0x0f, 0xc5,
-	0x05, 0x49, 0x0f, 0xfa, 0x12, 0x20, 0x0b, 0x01, 0x0f, 0x39, 0x01, 0x44,
-	0x01, 0xc5, 0x0b, 0x0f, 0x0d, 0xc1, 0x00, 0x04, 0x00, 0x00, 0x0f, 0xc4,
-	0x04, 0xc8, 0x0b, 0x21, 0x04, 0x12, 0x1f, 0x39, 0x0f, 0xd9, 0x04, 0xb8,
-	0x09, 0xc5, 0x0d, 0xc1, 0x00, 0x59, 0x09, 0xc0, 0x00, 0x14, 0x1f, 0x38,
-	0x09, 0xce, 0x0f, 0xc4, 0x04, 0xb8, 0x0d, 0xe1, 0x0b, 0x13, 0x19, 0xe1,
-	0x1f, 0xd9, 0x08, 0x00, 0x09, 0xe1, 0x0f, 0xd2, 0x02, 0x00, 0x1f, 0x39,
-	0x0f, 0xc4, 0x04, 0xc9, 0x0d, 0x80, 0x0f, 0xc4, 0x04, 0xca, 0x0f, 0x38,
-	0x0d, 0x80, 0x0f, 0xc4, 0x04, 0xc9, 0x0b, 0x08, 0x0c, 0x21, 0x0f, 0xc5,
-	0x04, 0xca, 0x0b, 0x49, 0x0c, 0x54, 0x1f, 0x39, 0x0c, 0x40, 0x0c, 0x53,
-	0x0f, 0xe1, 0x04, 0xb8, 0x0c, 0x19, 0x09, 0xc4, 0x0b, 0x0a, 0x0c, 0x59,
-	0x09, 0xc4, 0x0b, 0x0b, 0x0c, 0xa1, 0x1c, 0xe1, 0x0c, 0xd1, 0x1c, 0x91,
-	0x09, 0xcc, 0x09, 0xe1, 0x0f, 0xd2, 0x08, 0x00, 0x19, 0xcc, 0x00, 0x0d,
-	0x0c, 0x21, 0x0c, 0x53, 0x10, 0x21, 0x1d, 0x11, 0x19, 0xcc, 0x1f, 0xcd,
-	0x0f, 0xff, 0x0f, 0xc4, 0x04, 0xcb, 0x0d, 0x00, 0x0d, 0x08, 0x00, 0xb6,
-	0x0d, 0x49, 0x07, 0x04, 0x0f, 0xc2, 0x0a, 0xab, 0x0f, 0xc2, 0x0a, 0xaa,
-	0x0f, 0xc2, 0x07, 0xfe, 0x0f, 0xf7, 0x02, 0x70, 0x07, 0xb7, 0x11, 0x36,
-	0x10, 0x88, 0x03, 0xb7, 0x0f, 0xc4, 0x01, 0x4e, 0x0c, 0x02, 0x0c, 0x42,
-	0x0f, 0xc4, 0x06, 0x94, 0x0b, 0x8a, 0x0b, 0x8b, 0x0f, 0xc4, 0x01, 0x50,
-	0x0c, 0x82, 0x0c, 0xc2, 0x0c, 0xa1, 0x0c, 0x20, 0x09, 0xc8, 0x0c, 0xe1,
-	0x0c, 0x59, 0x0f, 0xf6, 0x09, 0x24, 0x09, 0xc9, 0x04, 0x04, 0x0f, 0xc0,
-	0x00, 0x46, 0x0f, 0xc4, 0x06, 0x01, 0x0f, 0xf6, 0x05, 0xb9, 0x00, 0x40,
-	0x0f, 0x39, 0x0f, 0xc4, 0x01, 0x50, 0x0b, 0x88, 0x0f, 0xf6, 0x09, 0x24,
-	0x0b, 0x89, 0x0f, 0xf6, 0x05, 0x5c, 0x00, 0x48, 0x09, 0x04, 0x00, 0xa1,
-	0x0b, 0x16, 0x04, 0x04, 0x0f, 0xc0, 0x00, 0x32, 0x1f, 0xc0, 0x00, 0x47,
-	0x1f, 0xfb, 0x16, 0x6c, 0x07, 0x37, 0x02, 0xc8, 0x12, 0xc8, 0x08, 0xc4,
-	0x0c, 0x00, 0x0f, 0xc8, 0x00, 0x41, 0x0f, 0xf7, 0x05, 0x23, 0x0f, 0xfa,
-	0x0e, 0x43, 0x00, 0x88, 0x0f, 0xc4, 0x06, 0x01, 0x0f, 0xf4, 0x05, 0xb9,
-	0x04, 0x00, 0x00, 0x21, 0x0f, 0xc4, 0x06, 0xfe, 0x0b, 0x15, 0x1f, 0xf9,
-	0x11, 0xdb, 0x0f, 0xc4, 0x01, 0xb7, 0x0b, 0x15, 0x1f, 0xf9, 0x11, 0xdb,
-	0x0f, 0xc4, 0x01, 0xc5, 0x0f, 0xc0, 0x00, 0x47, 0x0f, 0xc4, 0x05, 0xe8,
-	0x0b, 0x21, 0x00, 0x15, 0x1f, 0xf9, 0x11, 0xe2, 0x0f, 0xc4, 0x01, 0xc6,
-	0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x0f, 0xd2, 0x00, 0x46, 0x11, 0x38,
-	0x11, 0x88, 0x0f, 0xc8, 0x00, 0x47, 0x08, 0xbb, 0x0f, 0x39, 0x04, 0x04,
-	0x0f, 0xc0, 0x00, 0x32, 0x0f, 0xc8, 0x00, 0x3c, 0x08, 0xbb, 0x0f, 0x39,
-	0x04, 0x3b, 0x0f, 0xf7, 0x0c, 0x13, 0x0f, 0xf7, 0x0c, 0x97, 0x0f, 0xc4,
-	0x01, 0x70, 0x0b, 0x21, 0x0f, 0xc4, 0x06, 0xff, 0x0b, 0x12, 0x1f, 0xf9,
-	0x12, 0x07, 0x0f, 0xc4, 0x01, 0xc5, 0x0b, 0x21, 0x0f, 0xd5, 0x00, 0x47,
-	0x1f, 0xf9, 0x12, 0x07, 0x0f, 0xfb, 0x16, 0x8b, 0x09, 0x3b, 0x0f, 0xfb,
-	0x0c, 0xf8, 0x0f, 0xfb, 0x13, 0xae, 0x04, 0x04, 0x0f, 0xc5, 0x01, 0xc5,
-	0x0b, 0x01, 0x0f, 0xc0, 0x00, 0x47, 0x0f, 0xf7, 0x05, 0x9d, 0x0f, 0xf9,
-	0x11, 0xe2, 0x07, 0xb7, 0x1f, 0xf6, 0x05, 0x5c, 0x10, 0x48, 0x09, 0x3b,
-	0x0f, 0xe1, 0x00, 0x47, 0x04, 0x04, 0x0b, 0x15, 0x19, 0x45, 0x1f, 0xc4,
-	0x00, 0x80, 0x1f, 0xf7, 0x00, 0xa4, 0x0f, 0xc4, 0x01, 0xc5, 0x0b, 0x15,
-	0x19, 0x45, 0x1f, 0xc4, 0x00, 0x80, 0x1f, 0xf7, 0x00, 0xa4, 0x0f, 0xfb,
-	0x12, 0x46, 0x0f, 0x39, 0x09, 0x04, 0x00, 0x00, 0x0f, 0xc4, 0x04, 0xc9,
-	0x0f, 0xc5, 0x04, 0xce, 0x0b, 0x01, 0x0f, 0xc5, 0x04, 0xcf, 0x0b, 0x01,
-	0x0f, 0xc5, 0x04, 0xcc, 0x00, 0x01, 0x0f, 0xc5, 0x04, 0xcd, 0x00, 0x01,
-	0x0f, 0xc5, 0x04, 0xd0, 0x00, 0x41, 0x0f, 0xc5, 0x04, 0xd5, 0x00, 0x01,
-	0x0f, 0xc5, 0x04, 0xd1, 0x0b, 0x01, 0x02, 0x36, 0x09, 0x44, 0x0f, 0xc8,
-	0x1f, 0xfc, 0x01, 0x37, 0x0f, 0xc4, 0x04, 0xd2, 0x00, 0x37, 0x0f, 0xfb,
-	0x16, 0x2f, 0x0f, 0xfb, 0x16, 0x6c, 0x0f, 0x39, 0x0f, 0xc4, 0x00, 0x80,
-	0x02, 0x37, 0x0f, 0xc4, 0x04, 0xc9, 0x0b, 0x21, 0x0b, 0x27, 0x09, 0x99,
-	0x09, 0xe1, 0x0f, 0xd9, 0x04, 0xd6, 0x00, 0x36, 0x09, 0xc4, 0x0f, 0xc4,
-	0x04, 0xd2, 0x0f, 0xf7, 0x00, 0xbd, 0x0f, 0xc4, 0x00, 0x80, 0x05, 0xb7,
-	0x0f, 0xfb, 0x00, 0x58, 0x0f, 0xc4, 0x04, 0xd0, 0x0b, 0x0c, 0x1f, 0xf8,
-	0x12, 0x65, 0x00, 0x21, 0x0f, 0xf8, 0x12, 0x75, 0x0d, 0x15, 0x0f, 0xc4,
-	0x04, 0xd2, 0x0f, 0xf7, 0x00, 0xb2, 0x0f, 0xc4, 0x04, 0xd1, 0x0f, 0xc5,
-	0x04, 0xc9, 0x0b, 0x40, 0x0f, 0xc4, 0x04, 0xd5, 0x0b, 0x14, 0x1f, 0xf8,
-	0x12, 0x7a, 0x10, 0x40, 0x0d, 0x14, 0x0f, 0xc5, 0x04, 0xcc, 0x1f, 0xc5,
-	0x04, 0xcd, 0x00, 0x41, 0x0f, 0xc4, 0x04, 0xcc, 0x0b, 0x88, 0x0b, 0x89,
-	0x0b, 0x8a, 0x0b, 0x8b, 0x00, 0x21, 0x0c, 0x15, 0x1f, 0xf9, 0x12, 0x8c,
-	0x0c, 0xa1, 0x00, 0x51, 0x09, 0xca, 0x09, 0xe1, 0x0f, 0xd7, 0x1f, 0xff,
-	0x10, 0x0a, 0x10, 0x48, 0x00, 0x21, 0x0c, 0x55, 0x1f, 0xf9, 0x12, 0x9a,
-	0x0c, 0xe1, 0x00, 0x59, 0x09, 0xe1, 0x0f, 0xc4, 0x04, 0xc8, 0x0b, 0x12,
-	0x00, 0x11, 0x10, 0x51, 0x09, 0xcb, 0x10, 0x49, 0x00, 0x21, 0x0d, 0x15,
-	0x1f, 0xf9, 0x12, 0xa4, 0x0c, 0x0d, 0x0d, 0x55, 0x10, 0x4c, 0x0f, 0xf8,
-	0x12, 0xa8, 0x1c, 0x4d, 0x0c, 0x4d, 0x0d, 0x55, 0x10, 0x0c, 0x1c, 0x0d,
-	0x0f, 0xc4, 0x04, 0xcc, 0x0c, 0x02, 0x0c, 0x42, 0x0f, 0xc4, 0x04, 0xd0,
-	0x0d, 0x00, 0x0d, 0x54, 0x1f, 0xf9, 0x12, 0xbf, 0x0f, 0xc4, 0x04, 0xca,
-	0x0f, 0xc5, 0x04, 0xd1, 0x0b, 0x40, 0x04, 0x04, 0x0f, 0xc0, 0x00, 0x32,
-	0x09, 0x04, 0x0f, 0xfa, 0x11, 0x41, 0x00, 0x80, 0x0f, 0x39, 0x0d, 0x15,
-	0x0c, 0x8d, 0x0f, 0xc4, 0x04, 0xce, 0x1c, 0xcd, 0x1f, 0xc4, 0x04, 0xcf,
-	0x0d, 0x40, 0x0f, 0xc4, 0x04, 0xca, 0x0f, 0xfa, 0x11, 0x41, 0x0d, 0x40,
-	0x09, 0x04, 0x0f, 0x38, 0x00, 0x00, 0x07, 0x37, 0x0f, 0xf0, 0x0b, 0x08,
-	0x0f, 0xf2, 0x00, 0x3f, 0x0f, 0xf0, 0x0b, 0x09, 0x0f, 0xf2, 0x0d, 0x59,
-	0x1f, 0xf2, 0x07, 0x4d, 0x0f, 0xf0, 0x0b, 0x10, 0x0f, 0xf2, 0x00, 0x87,
-	0x1f, 0xf2, 0x01, 0x47, 0x0f, 0xf0, 0x0b, 0x11, 0x0f, 0xf2, 0x03, 0x12,
-	0x0f, 0xf0, 0x0b, 0x12, 0x0f, 0xf2, 0x06, 0x61, 0x0f, 0xf0, 0x0b, 0x13,
-	0x0f, 0xf2, 0x0b, 0xbf, 0x0f, 0xc4, 0x06, 0xc9, 0x0f, 0xc2, 0x0c, 0xcd,
-	0x0f, 0xc2, 0x07, 0xfe, 0x1f, 0xc4, 0x06, 0xc9, 0x1f, 0xc2, 0x0a, 0xe1,
-	0x1f, 0xc2, 0x07, 0xfd, 0x0f, 0x39, 0x0f, 0xc4, 0x01, 0xd9, 0x08, 0x02,
-	0x00, 0x02, 0x0f, 0xc2, 0x0b, 0xb5, 0x0f, 0xc2, 0x07, 0xf0, 0x00, 0x02,
-	0x0f, 0xc2, 0x0b, 0xb4, 0x0f, 0xc2, 0x07, 0xf0, 0x00, 0x02, 0x0f, 0xc2,
-	0x0a, 0x5b, 0x0f, 0xc2, 0x07, 0xff, 0x00, 0x02, 0x0f, 0xc2, 0x0d, 0xdf,
-	0x0f, 0xc2, 0x07, 0xfa, 0x00, 0x02, 0x0f, 0xc2, 0x0a, 0x22, 0x00, 0x02,
-	0x00, 0x02, 0x0f, 0xc2, 0x0a, 0x2f, 0x0f, 0xc2, 0x07, 0xf2, 0x00, 0x02,
-	0x0f, 0xc2, 0x0b, 0x40, 0x0f, 0xc2, 0x07, 0xfa, 0x00, 0x02, 0x0f, 0xc2,
-	0x0c, 0x52, 0x00, 0x02, 0x00, 0x02, 0x0f, 0xc2, 0x08, 0x00, 0x00, 0x42,
-	0x00, 0x02, 0x0f, 0xc2, 0x0c, 0xb5, 0x0f, 0xc2, 0x07, 0xfb, 0x00, 0x02,
-	0x0f, 0xc2, 0x0f, 0x98, 0x0f, 0xc2, 0x07, 0xfa, 0x00, 0x02, 0x0f, 0xc2,
-	0x0b, 0x23, 0x0f, 0xc2, 0x07, 0xfa, 0x00, 0x02, 0x0f, 0xc2, 0x08, 0x40,
-	0x0f, 0xc2, 0x07, 0xfa, 0x00, 0x02, 0x0f, 0xc2, 0x0d, 0x4e, 0x0f, 0xc2,
-	0x07, 0xf9, 0x00, 0x02, 0x0f, 0xc2, 0x0d, 0xc5, 0x00, 0x02, 0x00, 0x02,
-	0x0f, 0xc2, 0x09, 0x06, 0x00, 0x42, 0x07, 0xc4, 0x0a, 0x8f, 0x0f, 0xc2,
-	0x04, 0xf3, 0x0f, 0xc2, 0x0b, 0x50, 0x00, 0x02, 0x0d, 0xc4, 0x08, 0x3a,
-	0x0d, 0xc5, 0x0f, 0xc4, 0x06, 0xcb, 0x00, 0x37, 0x06, 0xb6, 0x0d, 0xc4,
-	0x0f, 0xc4, 0x06, 0xce, 0x00, 0x37, 0x06, 0xb6, 0x0d, 0xc4, 0x0f, 0xc4,
-	0x06, 0xd1, 0x00, 0x37, 0x06, 0xb6, 0x0d, 0xc4, 0x0f, 0xc4, 0x06, 0xd4,
-	0x00, 0x37, 0x06, 0xb6, 0x0d, 0xc4, 0x0f, 0xc4, 0x06, 0xd7, 0x00, 0x37,
-	0x0f, 0xc4, 0x06, 0xda, 0x00, 0x02, 0x0f, 0xc2, 0x0c, 0x00, 0x0f, 0x38,
-	0x00, 0xc2, 0x0f, 0xf1, 0x0a, 0x36, 0x0f, 0xc5, 0x01, 0x52, 0x0f, 0xc4,
-	0x01, 0xd9, 0x07, 0x36, 0x0b, 0x0a, 0x0a, 0x43, 0x0f, 0xf1, 0x0a, 0x37,
-	0x1c, 0xa7, 0x19, 0xa7, 0x19, 0x8a, 0x0f, 0xc4, 0x01, 0xc9, 0x0c, 0x80,
-	0x0f, 0xc4, 0x01, 0xc8, 0x0b, 0x0c, 0x0d, 0x21, 0x00, 0x59, 0x09, 0xcb,
-	0x0a, 0x43, 0x0c, 0x97, 0x1c, 0xcc, 0x0f, 0xc5, 0x01, 0xc7, 0x00, 0x21,
-	0x0b, 0x55, 0x00, 0x01, 0x10, 0x0c, 0x0f, 0xc5, 0x01, 0x6e, 0x0b, 0x55,
-	0x00, 0x01, 0x1f, 0xc5, 0x01, 0xcb, 0x10, 0x41, 0x1f, 0xc5, 0x01, 0xcc,
-	0x10, 0x01, 0x1f, 0xc5, 0x01, 0xc7, 0x10, 0x41, 0x1c, 0xa1, 0x10, 0x59,
-	0x19, 0xcc, 0x0d, 0x00, 0x0d, 0x21, 0x0c, 0x92, 0x0f, 0xc4, 0x01, 0xca,
-	0x0b, 0x22, 0x00, 0xe4, 0x09, 0xa2, 0x03, 0x25, 0x10, 0x25, 0x0f, 0xf0,
-	0x0a, 0x2f, 0x09, 0xb2, 0x0f, 0x38, 0x09, 0x80, 0x0f, 0xc4, 0x01, 0xc8,
-	0x0b, 0x21, 0x0f, 0xc4, 0x01, 0xc9, 0x0b, 0x16, 0x1f, 0xf9, 0x14, 0x13,
-	0x0f, 0xc4, 0x01, 0xcb, 0x00, 0x00, 0x00, 0x15, 0x0f, 0xc5, 0x01, 0x52,
-	0x1f, 0xf9, 0x13, 0xc2, 0x0f, 0xc4, 0x05, 0x0b, 0x0f, 0x38, 0x0b, 0xc0,
-	0x0b, 0xc8, 0x0c, 0x2a, 0x00, 0x2b, 0x0c, 0x2c, 0x00, 0x2d, 0x0f, 0xee,
-	0x0c, 0x80, 0x0f, 0xe1, 0x0a, 0x00, 0x0b, 0xc9, 0x0c, 0x59, 0x09, 0xe1,
-	0x0c, 0x59, 0x09, 0xee, 0x0f, 0xce, 0x05, 0x06, 0x0d, 0x84, 0x0b, 0xaa,
-	0x0b, 0xab, 0x0b, 0xac, 0x0b, 0xad, 0x0f, 0xef, 0x08, 0x40, 0x1f, 0xf9,
-	0x13, 0xe9, 0x0d, 0x84, 0x0f, 0xee, 0x05, 0x00, 0x0e, 0x02, 0x0e, 0x42,
-	0x0f, 0xee, 0x05, 0x40, 0x0e, 0x02, 0x0e, 0x42, 0x0f, 0xc4, 0x05, 0x0a,
-	0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x0f, 0xf1, 0x05, 0x0f, 0x0f, 0xee,
-	0x03, 0x80, 0x0f, 0xe1, 0x09, 0xf8, 0x00, 0x2d, 0x0f, 0xcf, 0x05, 0x10,
-	0x0a, 0x6c, 0x0d, 0xf1, 0x0f, 0xee, 0x02, 0x80, 0x0f, 0xce, 0x05, 0x0c,
-	0x0d, 0x84, 0x0b, 0xaa, 0x0b, 0xab, 0x0b, 0xac, 0x0b, 0xad, 0x0a, 0x59,
-	0x09, 0xee, 0x0f, 0xcd, 0x05, 0x00, 0x0f, 0xcc, 0x05, 0x40, 0x0f, 0xef,
-	0x08, 0x40, 0x1f, 0x39, 0x0d, 0x84, 0x0d, 0x6e, 0x0e, 0x02, 0x0e, 0x42,
-	0x0d, 0x2e, 0x0e, 0x02, 0x0e, 0x42, 0x0f, 0xc4, 0x05, 0x10, 0x0b, 0x21,
-	0x00, 0x59, 0x0f, 0x38, 0x09, 0xc0, 0x0f, 0xc4, 0x01, 0xcb, 0x0b, 0x21,
-	0x00, 0x15, 0x1f, 0x39, 0x00, 0x40, 0x0f, 0xc4, 0x01, 0xcc, 0x0b, 0x21,
-	0x00, 0x59, 0x09, 0xc8, 0x09, 0xe1, 0x01, 0x17, 0x1c, 0x00, 0x00, 0x54,
-	0x1f, 0xc8, 0x14, 0x26, 0x15, 0x3b, 0x0f, 0x39, 0x0f, 0xc4, 0x01, 0xcc,
-	0x0b, 0x21, 0x00, 0x14, 0x1f, 0x39, 0x0f, 0xc4, 0x05, 0x06, 0x0f, 0xc5,
-	0x05, 0x11, 0x0b, 0x03, 0x00, 0x02, 0x0b, 0x03, 0x00, 0x02, 0x0b, 0x03,
-	0x00, 0x02, 0x0b, 0x03, 0x00, 0x02, 0x0f, 0xc4, 0x05, 0x0a, 0x0f, 0xc5,
-	0x05, 0x15, 0x0b, 0x03, 0x00, 0x02, 0x0f, 0xc4, 0x05, 0x0b, 0x0f, 0xc5,
-	0x05, 0x16, 0x0b, 0x03, 0x00, 0x02, 0x0f, 0xc4, 0x05, 0x0c, 0x0f, 0xc5,
-	0x05, 0x17, 0x0b, 0x03, 0x00, 0x02, 0x0b, 0x03, 0x00, 0x02, 0x0b, 0x03,
-	0x00, 0x02, 0x0b, 0x03, 0x00, 0x02, 0x0f, 0xc4, 0x05, 0x10, 0x0f, 0xc5,
-	0x05, 0x1b, 0x0b, 0x03, 0x00, 0x02, 0x0f, 0xc4, 0x01, 0xc7, 0x00, 0x40,
-	0x0f, 0xc4, 0x05, 0x11, 0x0b, 0xaa, 0x0b, 0xab, 0x0b, 0xac, 0x0b, 0xad,
-	0x0f, 0xee, 0x03, 0x00, 0x0f, 0xee, 0x0a, 0xef, 0x0f, 0xee, 0x09, 0x00,
-	0x07, 0xc4, 0x0f, 0xe2, 0x00, 0x3f, 0x0e, 0x02, 0x0e, 0x42, 0x0e, 0xa4,
-	0x09, 0x82, 0x0f, 0xf6, 0x00, 0xbd, 0x07, 0xc4, 0x0f, 0xc4, 0x05, 0x16,
-	0x0b, 0x2a, 0x0b, 0x2c, 0x0f, 0xee, 0x0d, 0x40, 0x0e, 0x2a, 0x0e, 0x6b,
-	0x0f, 0xc4, 0x05, 0x15, 0x0b, 0x2c, 0x00, 0x2d, 0x0f, 0xee, 0x0c, 0x80,
-	0x0f, 0xee, 0x0a, 0xef, 0x0f, 0xee, 0x09, 0x00, 0x07, 0x04, 0x0f, 0xe2,
-	0x00, 0x3f, 0x0e, 0x02, 0x0e, 0x42, 0x0e, 0xa4, 0x0f, 0xf6, 0x02, 0x09,
-	0x09, 0x82, 0x0f, 0xc4, 0x00, 0x7d, 0x00, 0x37, 0x0f, 0xc4, 0x01, 0xcc,
-	0x0b, 0x21, 0x00, 0x15, 0x1f, 0xc4, 0x01, 0x6f, 0x01, 0xba, 0x10, 0x40,
-	0x0f, 0xc4, 0x00, 0x7d, 0x02, 0x37, 0x07, 0x37, 0x0f, 0xc4, 0x01, 0xda,
-	0x1f, 0xc4, 0x01, 0xdd, 0x06, 0xb7, 0x0f, 0xc4, 0x01, 0x1c, 0x00, 0x37,
-	0x0f, 0xf1, 0x0a, 0x07, 0x0f, 0xc4, 0x01, 0xe0, 0x06, 0xb7, 0x04, 0x21,
-	0x0a, 0x54, 0x0f, 0xf1, 0x0a, 0x10, 0x1f, 0xf9, 0x14, 0xc6, 0x00, 0x2a,
-	0x09, 0xeb, 0x0f, 0xee, 0x01, 0xc0, 0x0f, 0xee, 0x0a, 0xcb, 0x0f, 0xf7,
-	0x04, 0x66, 0x05, 0x84, 0x0e, 0x02, 0x0e, 0x42, 0x0e, 0x82, 0x0f, 0xc4,
-	0x01, 0xe3, 0x06, 0xb7, 0x0f, 0xc4, 0x00, 0x9e, 0x0f, 0xf7, 0x02, 0x81,
-	0x0f, 0xfb, 0x01, 0x1c, 0x0f, 0xf7, 0x04, 0x72, 0x0f, 0xf7, 0x02, 0x70,
-	0x0f, 0xf9, 0x14, 0xd0, 0x07, 0xb7, 0x1f, 0xf9, 0x14, 0xd0, 0x0a, 0x61,
-	0x00, 0x14, 0x1f, 0xf9, 0x14, 0xd0, 0x0f, 0xc4, 0x01, 0xe6, 0x06, 0xb7,
-	0x0f, 0xc4, 0x01, 0x13, 0x00, 0x37, 0x0f, 0xc4, 0x01, 0x1c, 0x02, 0x37,
-	0x0f, 0xfb, 0x01, 0x0c, 0x0f, 0xf7, 0x00, 0x8f, 0x0f, 0xc4, 0x01, 0x22,
-	0x00, 0x37, 0x0f, 0xc4, 0x01, 0x22, 0x0f, 0xc5, 0x00, 0xa7, 0x08, 0x3b,
-	0x03, 0xb7, 0x00, 0x21, 0x0c, 0x55, 0x1f, 0xc8, 0x0f, 0xff, 0x0f, 0xc4,
-	0x01, 0x79, 0x01, 0xba, 0x0c, 0x00, 0x0f, 0xc4, 0x01, 0x13, 0x02, 0x37,
-	0x0f, 0xfb, 0x01, 0x0c, 0x0f, 0xf7, 0x00, 0x8f, 0x0f, 0xc4, 0x06, 0xdd,
-	0x00, 0x37, 0x0f, 0xc4, 0x00, 0xa7, 0x06, 0xb7, 0x03, 0xb7, 0x00, 0x21,
-	0x0c, 0x55, 0x1f, 0xc8, 0x0f, 0xff, 0x0f, 0xf0, 0x0f, 0x16, 0x0c, 0x32,
-	0x0f, 0xc4, 0x01, 0x78, 0x0c, 0x00, 0x0f, 0xc4, 0x01, 0x7f, 0x0c, 0x00,
-	0x0f, 0xfa, 0x03, 0x00, 0x08, 0x08, 0x0f, 0xc4, 0x05, 0x17, 0x0b, 0xaa,
-	0x0b, 0xab, 0x0b, 0xac, 0x0b, 0xad, 0x0f, 0xee, 0x03, 0x00, 0x0f, 0xee,
-	0x0a, 0xef, 0x0f, 0xf1, 0x05, 0x04, 0x0a, 0x4f, 0x0f, 0xf1, 0x05, 0x05,
-	0x0f, 0xee, 0x09, 0x00, 0x0f, 0xe2, 0x00, 0x3f, 0x02, 0x21, 0x07, 0xc4,
-	0x0e, 0x02, 0x0e, 0x42, 0x0e, 0xa4, 0x09, 0x99, 0x09, 0xc2, 0x0f, 0xc4,
-	0x01, 0x54, 0x0d, 0xc2, 0x01, 0xba, 0x0a, 0x42, 0x0f, 0xf6, 0x00, 0xbd,
-	0x07, 0xc4, 0x0f, 0xc4, 0x05, 0x1b, 0x00, 0x2a, 0x0b, 0x2b, 0x0f, 0xee,
-	0x01, 0xc0, 0x0f, 0xee, 0x0a, 0xcb, 0x07, 0x04, 0x00, 0x02, 0x0e, 0x42,
-	0x0f, 0xf6, 0x02, 0x09, 0x0e, 0x82, 0x0f, 0xc4, 0x01, 0x54, 0x0b, 0x8f,
-	0x00, 0x21, 0x0d, 0xd5, 0x10, 0x2a, 0x1d, 0xeb, 0x1f, 0xee, 0x01, 0xc0,
-	0x1f, 0xe1, 0x0b, 0x02, 0x1b, 0x99, 0x19, 0xee, 0x17, 0x04, 0x1e, 0x02,
-	0x1e, 0x42, 0x1e, 0xa2, 0x1f, 0xe4, 0x07, 0xff, 0x1f, 0xf6, 0x02, 0x70,
-	0x19, 0x82, 0x0f, 0xc4, 0x01, 0xe9, 0x06, 0xb7, 0x07, 0x37, 0x11, 0x36,
-	0x10, 0x88, 0x0f, 0xc4, 0x01, 0x1f, 0x00, 0x37, 0x01, 0xbb, 0x0f, 0xc4,
-	0x06, 0xc7, 0x0b, 0x21, 0x00, 0x15, 0x1f, 0xf9, 0x15, 0x68, 0x0f, 0xc4,
-	0x01, 0x1f, 0x02, 0x37, 0x0f, 0xfb, 0x01, 0x14, 0x0f, 0xc4, 0x06, 0xe0,
-	0x0f, 0xf9, 0x15, 0x72, 0x0f, 0xc4, 0x06, 0xe0, 0x0f, 0xc5, 0x00, 0xa1,
-	0x0f, 0xf7, 0x02, 0x7d, 0x0f, 0xfb, 0x01, 0x1c, 0x0f, 0xc4, 0x01, 0x1f,
-	0x00, 0x37, 0x0f, 0xc4, 0x01, 0x1f, 0x02, 0x37, 0x0f, 0xc4, 0x01, 0xec,
-	0x06, 0xb7, 0x0f, 0xc4, 0x01, 0x16, 0x00, 0x37, 0x0f, 0xc4, 0x01, 0x6c,
-	0x0b, 0x22, 0x0f, 0xe4, 0x00, 0x38, 0x09, 0xa1, 0x0f, 0xc4, 0x01, 0xf5,
-	0x02, 0x14, 0x1f, 0xc4, 0x01, 0xf8, 0x04, 0x14, 0x1f, 0xc4, 0x01, 0xfb,
-	0x06, 0x14, 0x1f, 0xc4, 0x01, 0xfe, 0x08, 0x14, 0x1f, 0xc4, 0x02, 0x01,
-	0x0f, 0xe4, 0x0c, 0x00, 0x09, 0xa1, 0x0f, 0xc5, 0x06, 0x2b, 0x0f, 0xd4,
-	0x04, 0x00, 0x1f, 0xc5, 0x02, 0x04, 0x00, 0x14, 0x1f, 0xc5, 0x02, 0x07,
-	0x08, 0x3b, 0x0f, 0xc4, 0x01, 0x7e, 0x0b, 0x21, 0x00, 0x15, 0x11, 0x36,
-	0x10, 0x88, 0x0f, 0xc4, 0x01, 0x25, 0x00, 0x37, 0x0f, 0xc4, 0x01, 0x16,
-	0x06, 0xb7, 0x0f, 0xc4, 0x01, 0x16, 0x06, 0xb7, 0x07, 0x37, 0x0f, 0xc4,
-	0x01, 0xef, 0x1f, 0xc4, 0x01, 0xf2, 0x06, 0xb7, 0x0f, 0xc4, 0x01, 0x19,
-	0x00, 0x37, 0x01, 0xbb, 0x0f, 0xc4, 0x01, 0xcd, 0x0f, 0xc0, 0x06, 0xc8,
-	0x0f, 0xc4, 0x01, 0xce, 0x0f, 0xc0, 0x05, 0x1c, 0x04, 0xbb, 0x04, 0xbb,
-	0x04, 0xbb, 0x04, 0xbb, 0x04, 0xbb, 0x04, 0xbb, 0x01, 0xbb, 0x04, 0xbb,
-	0x0f, 0xc4, 0x05, 0x1c, 0x0f, 0xc8, 0x0a, 0x24, 0x00, 0x61, 0x01, 0xfe,
-	0x0f, 0xfd, 0x15, 0xd2, 0x00, 0x3f, 0x0c, 0x30, 0x0b, 0xb2, 0x0c, 0x19,
-	0x09, 0xc8, 0x0f, 0xc4, 0x01, 0xcc, 0x0b, 0x21, 0x00, 0x14, 0x1f, 0x39,
-	0x00, 0x54, 0x1f, 0x38, 0x09, 0xc0, 0x01, 0xbb, 0x0f, 0xf8, 0x14, 0x26,
-	0x0f, 0xc4, 0x01, 0xcd, 0x0b, 0x05, 0x0b, 0xc8, 0x0b, 0xc9, 0x0b, 0xca,
-	0x0a, 0xc0, 0x05, 0x84, 0x0c, 0x02, 0x0c, 0x42, 0x0c, 0x82, 0x0f, 0xc4,
-	0x01, 0x19, 0x06, 0xb7, 0x0f, 0xc4, 0x01, 0x80, 0x0b, 0x21, 0x00, 0x15,
-	0x1f, 0xf9, 0x16, 0x0c, 0x05, 0x84, 0x0b, 0xaa, 0x0b, 0xab, 0x0f, 0xee,
-	0x01, 0xc0, 0x0f, 0xee, 0x0a, 0x7a, 0x0b, 0xa7, 0x09, 0xa6, 0x09, 0xa1,
-	0x01, 0x51, 0x09, 0xc8, 0x01, 0x16, 0x1f, 0xf9, 0x16, 0x24, 0x0c, 0x21,
-	0x0f, 0xd7, 0x1f, 0xfa, 0x1f, 0xe1, 0x1f, 0xfa, 0x0f, 0xd9, 0x0a, 0x80,
-	0x09, 0xee, 0x0f, 0xf8, 0x16, 0x24, 0x00, 0x08, 0x05, 0x84, 0x0b, 0xaa,
-	0x0b, 0xab, 0x0f, 0xee, 0x01, 0xc0, 0x0f, 0xee, 0x0a, 0x7b, 0x0b, 0xa7,
-	0x09, 0xa6, 0x09, 0xa1, 0x01, 0x91, 0x09, 0xc8, 0x01, 0x56, 0x1f, 0xf9,
-	0x16, 0x24, 0x0c, 0x21, 0x0f, 0xd7, 0x1f, 0xf9, 0x1f, 0xe1, 0x1f, 0xf9,
-	0x0f, 0xd9, 0x0a, 0x80, 0x09, 0xee, 0x00, 0x08, 0x0f, 0xf6, 0x00, 0x26,
-	0x0c, 0x27, 0x09, 0xa2, 0x0e, 0x65, 0x0f, 0xc4, 0x01, 0xce, 0x0b, 0x05,
-	0x09, 0x83, 0x0f, 0x38, 0x0a, 0xc0, 0x0f, 0xc4, 0x01, 0xcf, 0x00, 0x00,
-	0x02, 0x04, 0x0f, 0xc2, 0x00, 0x28, 0x0f, 0xc2, 0x00, 0x29, 0x0f, 0xc2,
-	0x00, 0x2b, 0x0f, 0xc2, 0x00, 0x2d, 0x0f, 0xc2, 0x00, 0x2f, 0x0f, 0xc2,
-	0x00, 0x33, 0x0f, 0xc2, 0x00, 0x37, 0x0f, 0xc2, 0x00, 0x3b, 0x0f, 0xc4,
-	0x00, 0x28, 0x0f, 0xc2, 0x00, 0x88, 0x0f, 0xc2, 0x00, 0x3d, 0x0f, 0xc2,
-	0x00, 0xb6, 0x0f, 0xc2, 0x00, 0x56, 0x0f, 0xc2, 0x00, 0xac, 0x0f, 0xc2,
-	0x00, 0x6b, 0x0f, 0xc2, 0x00, 0xa0, 0x07, 0x82, 0x0f, 0xc2, 0x00, 0x59,
-	0x0f, 0xc2, 0x00, 0x94, 0x0f, 0xc2, 0x00, 0xcf, 0x0f, 0xc2, 0x00, 0x32,
-	0x0f, 0xc2, 0x00, 0x63, 0x0f, 0xc2, 0x00, 0x95, 0x0f, 0xc2, 0x00, 0xc6,
-	0x0f, 0xc2, 0x00, 0x4a, 0x0f, 0xc2, 0x00, 0x6f, 0x0f, 0xc2, 0x00, 0x94,
-	0x0f, 0xc2, 0x00, 0xb9, 0x0f, 0x38, 0x00, 0x02, 0x0f, 0xc4, 0x01, 0x70,
-	0x00, 0x00, 0x0f, 0xc4, 0x00, 0x6c, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
-	0x0f, 0x38, 0x00, 0x02, 0x00, 0x21, 0x0c, 0x16, 0x19, 0xc8, 0x0d, 0x09,
-	0x0c, 0x84, 0x0c, 0xfe, 0x0f, 0xfd, 0x16, 0x86, 0x0b, 0xa1, 0x0c, 0x17,
-	0x09, 0xce, 0x10, 0x21, 0x1d, 0x91, 0x19, 0xce, 0x0c, 0x61, 0x0d, 0x96,
-	0x1d, 0x89, 0x0c, 0x6a, 0x0c, 0x6c, 0x0f, 0x38, 0x0d, 0x6e, 0x0f, 0xc4,
-	0x05, 0xeb, 0x0b, 0x08, 0x0f, 0xc4, 0x05, 0xea, 0x0b, 0x09, 0x00, 0x0a,
-	0x0c, 0x61, 0x00, 0x14, 0x1f, 0xf9, 0x16, 0xaa, 0x00, 0x55, 0x1f, 0xf9,
-	0x16, 0xa1, 0x00, 0x4a, 0x0c, 0x21, 0x00, 0x94, 0x10, 0x8a, 0x00, 0xd4,
-	0x0f, 0xf8, 0x16, 0xaa, 0x10, 0xca, 0x00, 0x55, 0x1f, 0xf9, 0x16, 0xaa,
-	0x01, 0x0a, 0x0c, 0x21, 0x00, 0x94, 0x11, 0x4a, 0x00, 0xd4, 0x11, 0x8a,
-	0x0f, 0xc4, 0x01, 0xcf, 0x0c, 0x80, 0x0f, 0xf0, 0x0a, 0x0d, 0x00, 0x32,
-	0x0f, 0xf6, 0x05, 0x5c, 0x01, 0x08, 0x0f, 0xc4, 0x00, 0x6c, 0x0b, 0xaa,
-	0x0b, 0xab, 0x0b, 0xac, 0x0b, 0xad, 0x0f, 0xee, 0x03, 0x00, 0x0f, 0xc5,
-	0x01, 0xcf, 0x0b, 0x61, 0x02, 0x19, 0x09, 0xc5, 0x0b, 0xca, 0x0b, 0xe1,
-	0x0c, 0x91, 0x09, 0xcb, 0x0f, 0xcc, 0x07, 0xff, 0x0f, 0xcd, 0x0c, 0xc0,
-	0x00, 0x2b, 0x00, 0x2d, 0x0f, 0xf1, 0x03, 0x39, 0x0f, 0xce, 0x00, 0xc2,
-	0x0f, 0xcf, 0x07, 0x68, 0x07, 0x37, 0x1f, 0xce, 0x00, 0x41, 0x1f, 0xcf,
-	0x01, 0xe9, 0x0a, 0x61, 0x0f, 0xf1, 0x03, 0x39, 0x0d, 0x93, 0x1f, 0xf9,
-	0x16, 0xd5, 0x0f, 0xf1, 0x0a, 0x22, 0x0a, 0x48, 0x0f, 0xf1, 0x0a, 0x23,
-	0x0f, 0xfb, 0x16, 0x76, 0x0a, 0x48, 0x0f, 0xf1, 0x0a, 0x22, 0x0f, 0xfb,
-	0x16, 0x76, 0x0a, 0x48, 0x0f, 0xf1, 0x03, 0x39, 0x0f, 0xc4, 0x01, 0x70,
-	0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x09, 0xe1, 0x0f, 0xc4, 0x06, 0xff,
-	0x0b, 0x12, 0x1f, 0xf9, 0x17, 0x04, 0x0a, 0x61, 0x0d, 0xd3, 0x1f, 0xf9,
-	0x16, 0xde, 0x0f, 0xc4, 0x00, 0x6c, 0x0f, 0xee, 0x05, 0x00, 0x0e, 0x02,
-	0x0e, 0x42, 0x0f, 0xee, 0x05, 0x40, 0x0e, 0x02, 0x0f, 0x38, 0x0e, 0x42,
-	0x0f, 0xee, 0x0a, 0xef, 0x0f, 0xe2, 0x00, 0x3f, 0x0f, 0xe1, 0x1f, 0xf6,
-	0x0f, 0xc4, 0x00, 0x80, 0x0f, 0xee, 0x09, 0x00, 0x0e, 0x02, 0x0e, 0x42,
-	0x0e, 0xa4, 0x09, 0x99, 0x09, 0xe2, 0x0f, 0xe4, 0x07, 0xff, 0x0f, 0x38,
-	0x09, 0x82, 0x0f, 0xfb, 0x17, 0x68, 0x0f, 0xfb, 0x0c, 0x26, 0x0f, 0xfb,
-	0x0c, 0xf8, 0x0f, 0xf7, 0x0d, 0xa3, 0x0f, 0xfb, 0x18, 0x62, 0x0f, 0xfb,
-	0x1f, 0x0b, 0x0f, 0xfb, 0x13, 0xae, 0x0f, 0xf7, 0x05, 0x92, 0x0f, 0xf6,
-	0x05, 0x8d, 0x02, 0x48, 0x1f, 0xf9, 0x17, 0x33, 0x0f, 0xc4, 0x01, 0x69,
-	0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x0f, 0xfb, 0x1a, 0xa8, 0x0f, 0xf6,
-	0x05, 0x8d, 0x02, 0x88, 0x1f, 0xf9, 0x17, 0x45, 0x00, 0x61, 0x0f, 0xc4,
-	0x01, 0x67, 0x0b, 0x19, 0x09, 0xc0, 0x0f, 0xc4, 0x01, 0x66, 0x0b, 0x19,
-	0x09, 0xc0, 0x02, 0xba, 0x00, 0x48, 0x0f, 0xf9, 0x17, 0x47, 0x02, 0xba,
-	0x00, 0x08, 0x0f, 0xf6, 0x05, 0x8d, 0x02, 0xc8, 0x1f, 0xf9, 0x17, 0x54,
-	0x0f, 0xc4, 0x01, 0x68, 0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x0f, 0xc4,
-	0x07, 0xbf, 0x00, 0x40, 0x0f, 0xc8, 0x0e, 0x00, 0x0f, 0xf7, 0x05, 0x94,
-	0x0f, 0xfb, 0x03, 0x96, 0x0f, 0xc4, 0x01, 0x6c, 0x0f, 0xf1, 0x0c, 0x06,
-	0x0a, 0x40, 0x0f, 0xfb, 0x1a, 0xcf, 0x0f, 0xfb, 0x03, 0xdd, 0x0f, 0xfb,
-	0x18, 0xd3, 0x0f, 0xfb, 0x19, 0x16, 0x0f, 0x39, 0x0f, 0xc4, 0x06, 0x92,
-	0x0b, 0x22, 0x0f, 0xe4, 0x0d, 0xff, 0x09, 0x80, 0x07, 0x64, 0x09, 0xa2,
-	0x0f, 0xe5, 0x1f, 0xe2, 0x09, 0xa2, 0x04, 0x84, 0x0b, 0x24, 0x09, 0x80,
-	0x04, 0x84, 0x0b, 0x21, 0x01, 0x1e, 0x1f, 0xf9, 0x17, 0x87, 0x0f, 0xc4,
-	0x06, 0xa7, 0x02, 0x37, 0x0f, 0xc4, 0x06, 0xae, 0x00, 0x37, 0x0f, 0xc4,
-	0x07, 0x5a, 0x06, 0xb7, 0x0f, 0xc4, 0x00, 0x77, 0x00, 0x37, 0x04, 0x84,
-	0x0b, 0x21, 0x00, 0xde, 0x1f, 0xf9, 0x17, 0x9b, 0x0f, 0xc4, 0x06, 0xaa,
-	0x02, 0x37, 0x0f, 0xc4, 0x07, 0x0b, 0x02, 0xb7, 0x0f, 0xc4, 0x00, 0x7a,
-	0x00, 0x37, 0x0f, 0xc4, 0x07, 0x57, 0x06, 0xb7, 0x0f, 0xc4, 0x00, 0x74,
-	0x00, 0x37, 0x04, 0x84, 0x0b, 0x21, 0x00, 0x9e, 0x1f, 0xf9, 0x17, 0xb5,
-	0x00, 0x21, 0x01, 0x9f, 0x09, 0xe1, 0x01, 0xdf, 0x09, 0xe2, 0x0b, 0x25,
-	0x09, 0x80, 0x0f, 0xc4, 0x06, 0xa4, 0x02, 0x37, 0x0f, 0xc4, 0x00, 0x77,
-	0x02, 0xb7, 0x0f, 0xc4, 0x07, 0x67, 0x02, 0xb7, 0x0f, 0xc4, 0x06, 0x96,
-	0x00, 0x37, 0x0f, 0xf7, 0x0d, 0x69, 0x04, 0x84, 0x0b, 0x21, 0x00, 0x1e,
-	0x1f, 0xf9, 0x17, 0xef, 0x00, 0x21, 0x01, 0x9f, 0x09, 0xe2, 0x0b, 0x25,
-	0x09, 0x80, 0x0f, 0xc4, 0x01, 0x5c, 0x0b, 0x21, 0x03, 0x95, 0x1f, 0xf9,
-	0x17, 0xd3, 0x04, 0xc4, 0x0f, 0xc5, 0x06, 0x9f, 0x0f, 0xf7, 0x02, 0x74,
-	0x03, 0x37, 0x03, 0xb7, 0x00, 0xb7, 0x05, 0x37, 0x04, 0x37, 0x00, 0x36,
-	0x04, 0xc4, 0x0f, 0xf9, 0x17, 0xef, 0x0f, 0xc4, 0x01, 0x44, 0x0b, 0x88,
-	0x00, 0xb6, 0x0b, 0x89, 0x0f, 0xc8, 0x1f, 0xf4, 0x01, 0x37, 0x0f, 0xc4,
-	0x00, 0x86, 0x00, 0x37, 0x0f, 0xc4, 0x07, 0x08, 0x06, 0xb7, 0x0f, 0xc4,
-	0x00, 0x89, 0x00, 0x37, 0x0f, 0xc4, 0x06, 0x9f, 0x02, 0xb7, 0x0f, 0xc4,
-	0x00, 0x74, 0x02, 0xb7, 0x0f, 0xc4, 0x07, 0x64, 0x02, 0xb7, 0x00, 0x36,
-	0x04, 0xc4, 0x04, 0x84, 0x0b, 0x21, 0x00, 0x5e, 0x1f, 0xf9, 0x18, 0x0c,
-	0x00, 0x21, 0x01, 0x9f, 0x09, 0xe2, 0x0b, 0x25, 0x09, 0x80, 0x00, 0x21,
-	0x0f, 0xc4, 0x06, 0xa2, 0x0b, 0x88, 0x06, 0xba, 0x0b, 0x89, 0x10, 0x21,
-	0x1c, 0x18, 0x19, 0xc8, 0x1c, 0x51, 0x19, 0xc9, 0x0f, 0xc4, 0x06, 0x8f,
-	0x0b, 0x21, 0x0c, 0x20, 0x09, 0xc2, 0x0b, 0x21, 0x0c, 0x59, 0x09, 0xc2,
-	0x04, 0x84, 0x0b, 0x21, 0x01, 0x9e, 0x1f, 0xf9, 0x18, 0x33, 0x0f, 0xc4,
-	0x06, 0x8f, 0x0b, 0x88, 0x00, 0xb6, 0x0b, 0x89, 0x06, 0xbb, 0x1f, 0xf7,
-	0x00, 0x8f, 0x02, 0xb6, 0x04, 0xc4, 0x0f, 0xc4, 0x00, 0x92, 0x00, 0x37,
-	0x0f, 0xc4, 0x06, 0x9c, 0x06, 0xb7, 0x03, 0xb7, 0x06, 0xbb, 0x0f, 0xe1,
-	0x04, 0x00, 0x1f, 0xe1, 0x0c, 0x00, 0x0c, 0x59, 0x09, 0xc9, 0x0f, 0xc4,
-	0x01, 0x30, 0x0c, 0x02, 0x0c, 0x42, 0x0f, 0xf0, 0x03, 0x0a, 0x0c, 0x32,
-	0x0f, 0xf0, 0x03, 0x09, 0x0c, 0x72, 0x04, 0x84, 0x0b, 0x21, 0x01, 0xde,
-	0x1f, 0xf9, 0x18, 0x4e, 0x0f, 0xc4, 0x06, 0x96, 0x02, 0x37, 0x01, 0x36,
-	0x06, 0x08, 0x03, 0xb7, 0x0f, 0xc4, 0x01, 0x32, 0x0c, 0x02, 0x0c, 0x42,
-	0x0c, 0x61, 0x02, 0xdf, 0x11, 0x3a, 0x12, 0x08, 0x1f, 0xf9, 0x18, 0x50,
-	0x0f, 0xf0, 0x03, 0x1a, 0x0c, 0x32, 0x0f, 0xf0, 0x03, 0x19, 0x0c, 0x72,
-	0x04, 0x84, 0x00, 0x00, 0x0f, 0x39, 0x0f, 0xf1, 0x03, 0x3a, 0x0f, 0xc4,
-	0x07, 0xe2, 0x0a, 0x48, 0x0c, 0x00, 0x0f, 0xc4, 0x07, 0xe3, 0x0c, 0x00,
-	0x0f, 0xf1, 0x03, 0x03, 0x0f, 0xc4, 0x07, 0xe4, 0x0f, 0xc2, 0x08, 0x00,
-	0x0f, 0x38, 0x0a, 0x42, 0x0f, 0xc4, 0x07, 0xe1, 0x00, 0x21, 0x0b, 0x14,
-	0x1f, 0xf9, 0x18, 0xd2, 0x0f, 0xc4, 0x07, 0xea, 0x0b, 0x15, 0x0f, 0xc8,
-	0x03, 0x03, 0x1f, 0xc8, 0x03, 0x06, 0x0c, 0x31, 0x0f, 0xc4, 0x07, 0xe5,
-	0x0a, 0x40, 0x0f, 0xf1, 0x03, 0x3a, 0x0f, 0xc4, 0x07, 0xe2, 0x0a, 0x48,
-	0x0c, 0x00, 0x0f, 0xc4, 0x07, 0xe3, 0x0c, 0x00, 0x0f, 0xc4, 0x07, 0xe1,
-	0x0b, 0x09, 0x0c, 0x61, 0x0c, 0x13, 0x1c, 0x21, 0x1c, 0x51, 0x09, 0xe1,
-	0x0f, 0xc4, 0x07, 0xf1, 0x0b, 0x13, 0x1f, 0xf9, 0x18, 0xd2, 0x0c, 0x61,
-	0x0c, 0x12, 0x0f, 0xcb, 0x18, 0xa4, 0x1f, 0xcb, 0x18, 0xb2, 0x09, 0xca,
-	0x00, 0x21, 0x0c, 0x91, 0x19, 0xd1, 0x09, 0xe1, 0x0f, 0xc4, 0x07, 0xf2,
-	0x0b, 0x16, 0x0f, 0xc4, 0x07, 0xe6, 0x1f, 0xc4, 0x07, 0xe8, 0x0b, 0x88,
-	0x0b, 0x89, 0x0f, 0xc4, 0x07, 0xf0, 0x0b, 0x21, 0x0f, 0xc4, 0x07, 0xe4,
-	0x0c, 0xf8, 0x00, 0x15, 0x1f, 0xf9, 0x18, 0xb4, 0x0b, 0xa1, 0x0c, 0x18,
-	0x09, 0xc8, 0x0b, 0xa1, 0x0c, 0x51, 0x09, 0xc9, 0x00, 0x21, 0x0c, 0x56,
-	0x10, 0x08, 0x0f, 0xf8, 0x18, 0xc1, 0x10, 0x09, 0x1f, 0xf9, 0x18, 0xa6,
-	0x0b, 0xa1, 0x0c, 0x20, 0x09, 0xc8, 0x0b, 0xa1, 0x0c, 0x59, 0x09, 0xc9,
-	0x0c, 0x61, 0x0f, 0xd6, 0x00, 0xff, 0x1f, 0xc8, 0x0f, 0xff, 0x1f, 0xc9,
-	0x00, 0xff, 0x0f, 0xc4, 0x07, 0xe4, 0x0c, 0x02, 0x0c, 0x42, 0x00, 0x21,
-	0x0f, 0xc4, 0x07, 0xea, 0x0b, 0x14, 0x1f, 0xf0, 0x03, 0x03, 0x1c, 0x72,
-	0x0f, 0xc4, 0x07, 0xeb, 0x0b, 0x14, 0x1f, 0xf0, 0x03, 0x06, 0x1c, 0x72,
-	0x0f, 0x39, 0x0f, 0xc5, 0x01, 0x65, 0x0f, 0xc4, 0x01, 0x81, 0x0b, 0x21,
-	0x00, 0x14, 0x1f, 0x38, 0x10, 0x01, 0x0f, 0xc4, 0x07, 0x6c, 0x0b, 0x21,
-	0x00, 0x14, 0x09, 0xcb, 0x1f, 0x38, 0x10, 0x01, 0x0f, 0xc4, 0x07, 0x6a,
-	0x0b, 0x08, 0x0f, 0xc4, 0x07, 0x6b, 0x0b, 0x09, 0x0c, 0x21, 0x0c, 0x59,
-	0x09, 0xc9, 0x0f, 0xc4, 0x01, 0x65, 0x0f, 0xc5, 0x01, 0x66, 0x0b, 0x21,
-	0x00, 0x59, 0x09, 0xc0, 0x0c, 0x14, 0x1f, 0x38, 0x10, 0x01, 0x0c, 0x55,
-	0x1f, 0x39, 0x0c, 0x00, 0x0b, 0x61, 0x0c, 0xd6, 0x1f, 0x39, 0x01, 0x38,
-	0x01, 0xc8, 0x0b, 0x21, 0x0f, 0xd9, 0x00, 0x48, 0x09, 0xc5, 0x00, 0x59,
-	0x09, 0xc0, 0x09, 0xe1, 0x02, 0x12, 0x0f, 0x38, 0x10, 0x00, 0x0f, 0xc4,
-	0x01, 0xd2, 0x0b, 0x21, 0x02, 0x13, 0x1f, 0xf9, 0x19, 0x0e, 0x0f, 0x39,
-	0x00, 0x59, 0x09, 0xc0, 0x0f, 0xc4, 0x01, 0xd0, 0x0f, 0xfb, 0x18, 0xfd,
-	0x0f, 0x38, 0x0c, 0x01, 0x0f, 0xf1, 0x03, 0x39, 0x0f, 0xc4, 0x01, 0x6a,
-	0x00, 0x00, 0x0f, 0xc4, 0x01, 0x6b, 0x0a, 0x40, 0x0f, 0xc4, 0x01, 0xd2,
-	0x0b, 0x21, 0x00, 0x17, 0x1f, 0x38, 0x10, 0x00, 0x00, 0x51, 0x09, 0xc0,
-	0x0f, 0xc4, 0x01, 0xd1, 0x0f, 0xfb, 0x18, 0xfd, 0x0b, 0x48, 0x0f, 0xc4,
-	0x01, 0x6a, 0x0c, 0x38, 0x0c, 0x00, 0x05, 0x38, 0x0f, 0x08, 0x0d, 0x30,
-	0x0d, 0x21, 0x00, 0x59, 0x09, 0xcc, 0x0d, 0x61, 0x0c, 0xa0, 0x09, 0xea,
-	0x00, 0x21, 0x0c, 0xd9, 0x09, 0xeb, 0x0f, 0xee, 0x01, 0xc0, 0x1f, 0xee,
-	0x0a, 0x7e, 0x0c, 0x21, 0x0e, 0x20, 0x09, 0xce, 0x0c, 0x61, 0x0e, 0x59,
-	0x09, 0xf2, 0x0d, 0x83, 0x09, 0xc3, 0x0d, 0x21, 0x00, 0x59, 0x0d, 0x30,
-	0x0d, 0xb2, 0x0f, 0x38, 0x09, 0xcc, 0x0f, 0xc4, 0x07, 0x0e, 0x00, 0x02,
-	0x00, 0x02, 0x0f, 0xc2, 0x01, 0x90, 0x00, 0x02, 0x0f, 0xc2, 0x00, 0x83,
-	0x00, 0x42, 0x0f, 0xc2, 0x04, 0x07, 0x0f, 0x38, 0x00, 0x42, 0x0f, 0xc4,
-	0x07, 0x0e, 0x0b, 0x8a, 0x0f, 0xfa, 0x19, 0x31, 0x0b, 0x8b, 0x0b, 0x8a,
-	0x0f, 0xfa, 0x19, 0x31, 0x0b, 0x8b, 0x0b, 0x8a, 0x0f, 0xfa, 0x19, 0x31,
-	0x0b, 0x8b, 0x0b, 0x8a, 0x0f, 0xf8, 0x19, 0x31, 0x0b, 0x8b, 0x0f, 0xc5,
-	0x04, 0xa8, 0x07, 0x37, 0x0f, 0xcc, 0x05, 0x38, 0x0f, 0xcd, 0x02, 0xb0,
-	0x0f, 0xfb, 0x19, 0x5b, 0x0f, 0xcc, 0x0a, 0x38, 0x0f, 0xfa, 0x19, 0x5b,
-	0x00, 0x0d, 0x0f, 0xf0, 0x05, 0x2e, 0x00, 0xf2, 0x0f, 0xf1, 0x0a, 0x2e,
-	0x0a, 0x62, 0x0f, 0xe5, 0x01, 0xc0, 0x0f, 0x38, 0x09, 0xb2, 0x00, 0x04,
-	0x0c, 0x00, 0x0c, 0x21, 0x02, 0xdf, 0x1f, 0xf9, 0x19, 0x94, 0x0c, 0x27,
-	0x0c, 0x21, 0x09, 0x99, 0x09, 0xc8, 0x0f, 0xfa, 0x19, 0x6d, 0x00, 0x09,
-	0x0f, 0xf9, 0x19, 0xa1, 0x00, 0x21, 0x0c, 0x11, 0x09, 0xe7, 0x09, 0xe1,
-	0x09, 0x99, 0x09, 0xc8, 0x00, 0x21, 0x0c, 0x11, 0x09, 0xc8, 0x0f, 0xc9,
-	0x1f, 0xff, 0x0f, 0xfb, 0x19, 0x6d, 0x00, 0x04, 0x0f, 0x38, 0x0b, 0x08,
-	0x0f, 0xf1, 0x0a, 0x33, 0x0f, 0xc4, 0x05, 0xe8, 0x0a, 0x48, 0x0c, 0x02,
-	0x0f, 0xee, 0x0a, 0x7f, 0x0c, 0x2a, 0x00, 0x2b, 0x0f, 0xee, 0x02, 0x40,
-	0x0f, 0xee, 0x0a, 0x01, 0x08, 0x36, 0x02, 0x08, 0x0f, 0xc4, 0x05, 0xe9,
-	0x0b, 0x21, 0x00, 0x14, 0x1f, 0xc4, 0x01, 0x41, 0x1b, 0x22, 0x1f, 0xe4,
-	0x0f, 0xef, 0x19, 0x80, 0x00, 0x1e, 0x0f, 0xc5, 0x01, 0x7d, 0x1f, 0x38,
-	0x1c, 0x41, 0x00, 0x2b, 0x0c, 0x6a, 0x0f, 0xee, 0x01, 0xc0, 0x0f, 0xee,
-	0x0a, 0x78, 0x0b, 0x6a, 0x0f, 0xee, 0x02, 0x40, 0x0f, 0xee, 0x0a, 0x08,
-	0x0f, 0xc4, 0x01, 0x40, 0x04, 0x22, 0x0e, 0x02, 0x0e, 0x65, 0x0f, 0x38,
-	0x09, 0x82, 0x0f, 0xc4, 0x05, 0xf3, 0x0f, 0xc2, 0x0f, 0x80, 0x0f, 0xc2,
-	0x0f, 0xff, 0x0f, 0xc2, 0x07, 0xff, 0x00, 0x02, 0x0f, 0xc2, 0x0f, 0xc0,
-	0x01, 0x82, 0x0f, 0xc4, 0x00, 0x3c, 0x00, 0x42, 0x00, 0x82, 0x01, 0x82,
-	0x03, 0x02, 0x07, 0x02, 0x0f, 0xc2, 0x00, 0x30, 0x0f, 0xc2, 0x00, 0x70,
-	0x0f, 0xc2, 0x00, 0xf0, 0x0f, 0xc2, 0x01, 0xd0, 0x0f, 0xc2, 0x03, 0x50,
-	0x0f, 0xc2, 0x07, 0x50, 0x0f, 0xc2, 0x0e, 0x50, 0x0f, 0x39, 0x0f, 0xc4,
-	0x01, 0xd4, 0x0f, 0x00, 0x0f, 0xc4, 0x05, 0xf9, 0x02, 0x37, 0x0f, 0xc4,
-	0x06, 0x34, 0x02, 0xb7, 0x0f, 0xc4, 0x05, 0xf6, 0x0f, 0xf7, 0x02, 0x85,
-	0x0f, 0xf7, 0x01, 0x33, 0x0f, 0xc4, 0x01, 0xd3, 0x0c, 0x21, 0x00, 0x51,
-	0x09, 0xc0, 0x09, 0xcf, 0x09, 0xe1, 0x0f, 0xd9, 0x00, 0x3c, 0x09, 0xc4,
-	0x0b, 0x0d, 0x0f, 0xc4, 0x05, 0xf9, 0x0f, 0xc5, 0x01, 0x2b, 0x04, 0xb7,
-	0x0f, 0xc4, 0x00, 0x70, 0x0d, 0x42, 0x0d, 0x82, 0x01, 0xba, 0x0d, 0xc2,
-	0x0f, 0xc4, 0x00, 0x70, 0x0b, 0x8d, 0x0b, 0x8e, 0x0b, 0x8f, 0x0d, 0xe1,
-	0x00, 0x2a, 0x00, 0x59, 0x09, 0xeb, 0x0f, 0xee, 0x01, 0xc0, 0x0f, 0xee,
-	0x0a, 0xcb, 0x05, 0x84, 0x0e, 0x02, 0x0e, 0x42, 0x0e, 0x82, 0x0f, 0xc4,
-	0x01, 0x28, 0x00, 0x37, 0x0f, 0xc4, 0x05, 0xf9, 0x06, 0xb7, 0x0f, 0xf7,
-	0x01, 0x33, 0x0c, 0x21, 0x0d, 0xe7, 0x09, 0x91, 0x09, 0xce, 0x0d, 0xa1,
-	0x0f, 0xd2, 0x00, 0x80, 0x1f, 0xce, 0x00, 0x7f, 0x0d, 0xa1, 0x09, 0x99,
-	0x00, 0x2a, 0x09, 0xeb, 0x0f, 0xee, 0x01, 0xc0, 0x0f, 0xee, 0x0a, 0xcb,
-	0x05, 0x84, 0x0e, 0x02, 0x0e, 0x42, 0x0e, 0x82, 0x0f, 0xc4, 0x01, 0x28,
-	0x0f, 0xf7, 0x02, 0x81, 0x0f, 0xc4, 0x05, 0xf9, 0x0f, 0xf7, 0x02, 0x93,
-	0x0f, 0xf7, 0x02, 0x05, 0x02, 0xdf, 0x1f, 0xf9, 0x1a, 0x69, 0x0f, 0xc4,
-	0x01, 0x2b, 0x0f, 0xf7, 0x02, 0x90, 0x0f, 0xf7, 0x02, 0x05, 0x1f, 0xf9,
-	0x1a, 0x69, 0x06, 0x44, 0x0f, 0xc5, 0x01, 0x2b, 0x04, 0xb7, 0x0f, 0xc4,
-	0x05, 0xfc, 0x0d, 0x80, 0x0f, 0xc4, 0x05, 0xfd, 0x0d, 0xc0, 0x0d, 0xe1,
-	0x00, 0x53, 0x1f, 0xf9, 0x1a, 0x74, 0x09, 0xcf, 0x0d, 0x61, 0x0d, 0xdf,
-	0x1f, 0xf9, 0x1a, 0x16, 0x0f, 0xf9, 0x1a, 0x69, 0x0f, 0xc4, 0x01, 0xd4,
-	0x0b, 0x39, 0x0f, 0xc4, 0x05, 0xff, 0x0b, 0x0f, 0x0d, 0xe1, 0x00, 0x2b,
-	0x0f, 0xea, 0x0c, 0xe5, 0x00, 0xd4, 0x1f, 0xea, 0x05, 0xac, 0x01, 0x14,
-	0x1f, 0xea, 0x03, 0x44, 0x01, 0x94, 0x1f, 0xea, 0x01, 0x56, 0x02, 0x14,
-	0x1f, 0xea, 0x00, 0x83, 0x0f, 0xc4, 0x05, 0xf0, 0x0b, 0x0e, 0x0d, 0xa1,
-	0x00, 0x2c, 0x03, 0x2d, 0x00, 0x54, 0x11, 0xad, 0x00, 0x94, 0x11, 0x2d,
-	0x0f, 0xee, 0x0c, 0x80, 0x00, 0xa1, 0x0f, 0xc4, 0x01, 0x73, 0x0e, 0x19,
-	0x09, 0xc0, 0x0f, 0xc4, 0x01, 0x75, 0x00, 0x40, 0x0d, 0xa1, 0x00, 0x94,
-	0x10, 0x00, 0x00, 0x54, 0x0d, 0xe1, 0x10, 0x96, 0x10, 0x00, 0x00, 0xd6,
-	0x0f, 0x38, 0x10, 0x00, 0x0f, 0xc8, 0x1a, 0xab, 0x05, 0x39, 0x0f, 0xf7,
-	0x0d, 0xf7, 0x0f, 0xfb, 0x19, 0xa4, 0x0f, 0xc4, 0x07, 0xba, 0x0f, 0xfb,
-	0x02, 0xfd, 0x01, 0xbb, 0x0f, 0xf7, 0x0e, 0x2a, 0x01, 0xbb, 0x0f, 0xf7,
-	0x0e, 0x7e, 0x01, 0xbb, 0x0f, 0xfb, 0x19, 0xf7, 0x01, 0xbb, 0x0f, 0xf7,
-	0x0e, 0xff, 0x01, 0xbb, 0x0f, 0xfb, 0x1a, 0x77, 0x0f, 0xf6, 0x00, 0x42,
-	0x02, 0x8b, 0x1f, 0xf7, 0x0f, 0x52, 0x0f, 0xc4, 0x06, 0x00, 0x0f, 0xf0,
-	0x0a, 0x01, 0x0f, 0x38, 0x0b, 0x32, 0x0f, 0xff, 0x0f, 0x6b, 0x0f, 0xf1,
-	0x0c, 0x0a, 0x0f, 0xc4, 0x01, 0x6d, 0x0a, 0x49, 0x0c, 0x61, 0x00, 0x1e,
-	0x1f, 0xf8, 0x1b, 0x0b, 0x0c, 0x40, 0x0f, 0xf1, 0x0c, 0x07, 0x0f, 0xc4,
-	0x01, 0x36, 0x0f, 0xc5, 0x07, 0x60, 0x00, 0x2b, 0x0a, 0x6a, 0x0f, 0xf1,
-	0x0c, 0x08, 0x0f, 0xee, 0x01, 0xc0, 0x0f, 0xee, 0x0a, 0x06, 0x0e, 0x22,
-	0x0a, 0x65, 0x09, 0x82, 0x0e, 0x42, 0x0f, 0xc4, 0x01, 0x56, 0x0b, 0x21,
-	0x09, 0xa0, 0x09, 0xc2, 0x0b, 0x21, 0x0e, 0x59, 0x09, 0xc2, 0x0f, 0xc4,
-	0x01, 0xd5, 0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x09, 0xe1, 0x0b, 0x53,
-	0x1f, 0xf9, 0x1b, 0x0b, 0x0f, 0xc5, 0x01, 0x76, 0x0b, 0x01, 0x00, 0x00,
-	0x0f, 0xc5, 0x01, 0x38, 0x0f, 0xc4, 0x01, 0x56, 0x0b, 0x03, 0x00, 0x02,
-	0x0b, 0x03, 0x00, 0x02, 0x0f, 0xfa, 0x03, 0x00, 0x02, 0x08, 0x0c, 0x61,
-	0x00, 0x5e, 0x1f, 0x39, 0x0f, 0xf1, 0x0c, 0x0c, 0x0f, 0xc4, 0x01, 0x5a,
-	0x0b, 0x21, 0x0a, 0x60, 0x09, 0xc2, 0x0b, 0x21, 0x00, 0x19, 0x09, 0xc0,
-	0x0f, 0xf1, 0x0c, 0x09, 0x0f, 0xc4, 0x01, 0x58, 0x0b, 0x21, 0x0f, 0xc5,
-	0x07, 0x61, 0x0a, 0x48, 0x0c, 0x20, 0x09, 0xc2, 0x0b, 0x21, 0x00, 0x19,
-	0x09, 0xc2, 0x0f, 0xc4, 0x01, 0x74, 0x0c, 0x00, 0x0f, 0xc4, 0x01, 0xd6,
-	0x0b, 0x21, 0x00, 0x59, 0x09, 0xc0, 0x09, 0xe1, 0x0b, 0x53, 0x1f, 0x39,
-	0x0f, 0xc5, 0x01, 0x77, 0x0b, 0x01, 0x00, 0x00, 0x0f, 0xc5, 0x01, 0x3a,
-	0x0f, 0xc4, 0x01, 0x58, 0x0b, 0x03, 0x00, 0x02, 0x0b, 0x03, 0x00, 0x02,
-	0x0f, 0xc5, 0x01, 0x3c, 0x0f, 0xc4, 0x01, 0x5a, 0x0b, 0x03, 0x00, 0x02,
-	0x0b, 0x03, 0x00, 0x02, 0x0f, 0xf8, 0x03, 0x00, 0x04, 0x08, 0x0f, 0xf1,
-	0x0f, 0x17, 0x0f, 0xe2, 0x0f, 0xf0, 0x0c, 0x21, 0x0a, 0x64, 0x09, 0x99,
-	0x09, 0xf2, 0x00, 0x09, 0x0c, 0x22, 0x03, 0xe4, 0x09, 0xa1, 0x00, 0x94,
-	0x11, 0x09, 0x00, 0x54, 0x10, 0x49, 0x01, 0x54, 0x10, 0x89, 0x0c, 0x61,
-	0x00, 0x14, 0x1f, 0x39, 0x01, 0x14, 0x0f, 0xc4, 0x01, 0xd7, 0x0b, 0x21,
-	0x10, 0x40, 0x10, 0x15, 0x1f, 0x39, 0x0f, 0xf8, 0x03, 0x00, 0x0c, 0x48,
-	0x0f, 0x39, 0x00, 0x04, 0x0f, 0x00, 0x04, 0x04, 0x0b, 0x27, 0x09, 0xa7,
-	0x09, 0xa7, 0x09, 0xa7, 0x09, 0xa2, 0x0c, 0x25, 0x0f, 0xc5, 0x07, 0x6e,
-	0x09, 0x81, 0x07, 0xba, 0x04, 0x48, 0x0f, 0xc4, 0x07, 0x6d, 0x0b, 0x21,
-	0x00, 0x15, 0x00, 0x48, 0x12, 0x08, 0x04, 0x04, 0x0c, 0x00, 0x00, 0x04,
-	0x0b, 0x39, 0x00, 0x04, 0x0f, 0x00, 0x0f, 0xc4, 0x07, 0x80, 0x0f, 0xc8,
-	0x08, 0x00, 0x0f, 0xf7, 0x00, 0x71, 0x0f, 0xf1, 0x0f, 0x14, 0x0f, 0xc4,
-	0x07, 0xf4, 0x0a, 0x42, 0x0f, 0xf1, 0x0f, 0x15, 0x0a, 0x42, 0x0f, 0xf1,
-	0x03, 0x0a, 0x0f, 0xc4, 0x07, 0xf6, 0x0a, 0x42, 0x0f, 0xf1, 0x03, 0x09,
-	0x0a, 0x42, 0x0f, 0xf1, 0x03, 0x1a, 0x0f, 0xc4, 0x07, 0xf8, 0x0a, 0x42,
-	0x0f, 0xf1, 0x03, 0x19, 0x0a, 0x42, 0x0f, 0xf1, 0x03, 0x38, 0x0f, 0xc4,
-	0x07, 0xfa, 0x0a, 0x40, 0x0f, 0xf1, 0x03, 0x11, 0x0f, 0xc4, 0x07, 0xfb,
-	0x0a, 0x40, 0x0f, 0xf1, 0x0c, 0x05, 0x0f, 0xc4, 0x07, 0xfc, 0x0a, 0x40,
-	0x0f, 0xc4, 0x07, 0xfe, 0x0f, 0xc2, 0x07, 0x06, 0x0f, 0xc2, 0x00, 0x80,
-	0x00, 0x04, 0x0b, 0x39, 0x0f, 0xc4, 0x07, 0xf3, 0x0f, 0x00, 0x0f, 0xc4,
-	0x06, 0xc0, 0x0f, 0xc8, 0x07, 0x80, 0x0f, 0xf7, 0x00, 0x71, 0x0f, 0xf0,
-	0x0f, 0x17, 0x00, 0x32, 0x0f, 0xf0, 0x02, 0x04, 0x00, 0x32, 0x0f, 0xfa,
-	0x01, 0x92, 0x0e, 0xff, 0x0f, 0xc8, 0x08, 0x89, 0x0f, 0xc9, 0x08, 0x88,
-	0x0f, 0xca, 0x07, 0xfc, 0x0f, 0xcb, 0x07, 0xfe, 0x0f, 0xc4, 0x06, 0xe3,
-	0x0c, 0x02, 0x0c, 0x42, 0x0c, 0xc2, 0x0c, 0x02, 0x0c, 0x42, 0x0c, 0xc2,
-	0x0f, 0xc2, 0x07, 0x0a, 0x0f, 0xc2, 0x0a, 0x3d, 0x0f, 0xc2, 0x07, 0xf6,
-	0x0f, 0xc2, 0x03, 0x9c, 0x0f, 0xc2, 0x0c, 0x95, 0x0f, 0xc2, 0x07, 0xed,
-	0x0c, 0x02, 0x0c, 0x42, 0x0c, 0x82, 0x0c, 0x02, 0x0c, 0x42, 0x0c, 0x82,
-	0x0f, 0xc2, 0x07, 0x0a, 0x0f, 0xc2, 0x0a, 0x3d, 0x0f, 0xc2, 0x07, 0xf3,
-	0x0f, 0xc2, 0x03, 0x9c, 0x0f, 0xc2, 0x0c, 0x95, 0x0f, 0xc2, 0x07, 0xea,
-	0x0f, 0xc9, 0x08, 0x00, 0x0f, 0xca, 0x07, 0xfe, 0x0f, 0xc4, 0x07, 0x45,
-	0x00, 0x02, 0x0f, 0xc2, 0x0c, 0x00, 0x0c, 0x82, 0x00, 0x02, 0x0c, 0x42,
-	0x0c, 0x82, 0x0f, 0xc2, 0x0a, 0xab, 0x0f, 0xc2, 0x0a, 0xaa, 0x0f, 0xc2,
-	0x07, 0xfd, 0x0f, 0xc2, 0x07, 0x0a, 0x0f, 0xc2, 0x0a, 0x3d, 0x0f, 0xc2,
-	0x07, 0xf8, 0x0f, 0xc4, 0x07, 0x57, 0x00, 0x02, 0x0c, 0x42, 0x0f, 0xc2,
-	0x07, 0xfa, 0x00, 0x02, 0x0c, 0x42, 0x0f, 0xc2, 0x07, 0xf0, 0x0f, 0xc4,
-	0x07, 0x08, 0x0f, 0xc2, 0x09, 0x51, 0x0f, 0xc2, 0x09, 0xd4, 0x0f, 0xc2,
-	0x07, 0xf5, 0x0f, 0xc4, 0x07, 0x0b, 0x00, 0x02, 0x0f, 0xc2, 0x08, 0x00,
-	0x0f, 0xc2, 0x07, 0xfd, 0x0f, 0xc4, 0x07, 0x5d, 0x0f, 0xc0, 0x0d, 0xbf,
-	0x0f, 0xc4, 0x07, 0xe1, 0x0f, 0xc0, 0x00, 0x50, 0x0f, 0xc4, 0x07, 0xe6,
-	0x0f, 0xc2, 0x00, 0x40, 0x00, 0x02, 0x0f, 0xc2, 0x08, 0x00, 0x00, 0x02,
-	0x0f, 0xc4, 0x07, 0xf0, 0x00, 0x02, 0x02, 0x02, 0x04, 0x02, 0x0f, 0xc4,
-	0x07, 0x5e, 0x0f, 0xc2, 0x00, 0x64, 0x00, 0x02, 0x0f, 0xc4, 0x07, 0x26,
-	0x02, 0x40, 0x0f, 0xf1, 0x03, 0x04, 0x0f, 0xc4, 0x07, 0x62, 0x02, 0x82,
-	0x00, 0x02, 0x0f, 0xc4, 0x07, 0x6a, 0x0f, 0xc2, 0x0d, 0xac, 0x0f, 0xc2,
-	0x00, 0x64, 0x0f, 0xc2, 0x00, 0x55, 0x0f, 0xc4, 0x07, 0x6d, 0x00, 0x00,
-	0x0f, 0xc4, 0x07, 0xef, 0x02, 0x00, 0x0a, 0x72, 0x0f, 0xc4, 0x07, 0x70,
-	0x0f, 0xc0, 0x0f, 0xff, 0x0f, 0xc4, 0x07, 0x72, 0x03, 0xc2, 0x0f, 0xc2,
-	0x02, 0x80, 0x0f, 0xc2, 0x01, 0xe0, 0x02, 0x82, 0x0f, 0xc4, 0x06, 0xff,
-	0x0f, 0xc2, 0x08, 0x00, 0x0f, 0xfb, 0x19, 0x4d, 0x0f, 0xf1, 0x0d, 0x00,
-	0x0a, 0x61, 0x02, 0xde, 0x0f, 0xc4, 0x07, 0x22, 0x00, 0x40, 0x0f, 0xc4,
-	0x07, 0x2b, 0x0f, 0xc2, 0x02, 0x6e, 0x0f, 0xc2, 0x08, 0x31, 0x0f, 0xc2,
-	0x07, 0xf9, 0x0f, 0xc2, 0x0b, 0xa5, 0x0f, 0xc2, 0x0c, 0x49, 0x0f, 0xc2,
-	0x07, 0xf7, 0x0f, 0xc2, 0x00, 0x38, 0x0f, 0xc2, 0x0e, 0xc3, 0x00, 0xc2,
-	0x0f, 0xc2, 0x05, 0x0d, 0x0f, 0xc2, 0x0f, 0x5e, 0x00, 0x42, 0x02, 0x82,
-	0x01, 0x82, 0x02, 0x02, 0x00, 0x42, 0x1f, 0xc4, 0x07, 0x5d, 0x1f, 0xe2,
-	0x0e, 0xff, 0x1b, 0x24, 0x19, 0x80, 0x0f, 0xc4, 0x07, 0x60, 0x02, 0x00,
-	0x12, 0x00, 0x0f, 0xc4, 0x07, 0x61, 0x01, 0x00, 0x0f, 0xf8, 0x1c, 0xa7,
-	0x11, 0x00, 0x0f, 0xc4, 0x06, 0xfc, 0x00, 0x40, 0x0f, 0xc4, 0x07, 0xf3,
-	0x0f, 0xf8, 0x1c, 0xa7, 0x00, 0x00, 0x0f, 0xc4, 0x07, 0xf3, 0x00, 0x21,
-	0x0b, 0x14, 0x1f, 0x00, 0x0f, 0xc4, 0x07, 0xfd, 0x0b, 0x08, 0x00, 0x61,
-	0x0c, 0x19, 0x09, 0xc0, 0x09, 0xe1, 0x00, 0x14, 0x10, 0x80, 0x0f, 0xfb,
-	0x1e, 0xe0, 0x0f, 0xc4, 0x07, 0xf6, 0x0f, 0xf0, 0x03, 0x0a, 0x0b, 0xb2,
-	0x0f, 0xf0, 0x03, 0x09, 0x0b, 0xb2, 0x0f, 0xc4, 0x07, 0xf8, 0x0b, 0x88,
-	0x0b, 0x89, 0x0f, 0xf0, 0x03, 0x1a, 0x0c, 0x32, 0x0f, 0xf0, 0x03, 0x19,
-	0x0c, 0x72, 0x0f, 0xc4, 0x07, 0xfa, 0x0f, 0xf0, 0x03, 0x38, 0x0b, 0x32,
-	0x0f, 0xc4, 0x07, 0xfb, 0x0f, 0xf0, 0x03, 0x11, 0x0b, 0x32, 0x0f, 0xc4,
-	0x07, 0xfc, 0x0f, 0xf0, 0x0c, 0x05, 0x0f, 0xf8, 0x1c, 0xdd, 0x0b, 0x32,
-	0x0f, 0xc4, 0x07, 0xf3, 0x0f, 0x00, 0x00, 0x04, 0x0f, 0xc8, 0x06, 0xc0,
-	0x0f, 0xf7, 0x00, 0x71, 0x0f, 0xc4, 0x07, 0x3d, 0x0f, 0xc5, 0x07, 0x3e,
-	0x0b, 0x21, 0x0f, 0xd5, 0x00, 0x3c, 0x1f, 0xf8, 0x1c, 0xff, 0x10, 0x01,
-	0x0f, 0xf1, 0x0f, 0x15, 0x01, 0xe2, 0x00, 0x21, 0x0f, 0xc4, 0x07, 0xf5,
-	0x0a, 0x48, 0x0c, 0x24, 0x09, 0x95, 0x1c, 0x00, 0x0b, 0x61, 0x00, 0x59,
-	0x09, 0xc1, 0x00, 0xd2, 0x10, 0x01, 0x1b, 0x22, 0x1f, 0xe4, 0x0f, 0xf8,
-	0x19, 0x80, 0x02, 0x3a, 0x00, 0x48, 0x02, 0xba, 0x00, 0x48, 0x0f, 0xc4,
-	0x07, 0xc2, 0x00, 0x61, 0x0b, 0x15, 0x1f, 0xc4, 0x07, 0x62, 0x1b, 0x88,
-	0x1f, 0xf6, 0x00, 0x4c, 0x1b, 0x89, 0x0f, 0xfb, 0x01, 0x92, 0x0f, 0xfb,
-	0x19, 0xd5, 0x0f, 0xc4, 0x05, 0x80, 0x00, 0x02, 0x0f, 0xc2, 0x0e, 0x00,
-	0x0f, 0xc2, 0x07, 0xff, 0x0f, 0xc4, 0x06, 0x31, 0x0f, 0xc5, 0x05, 0x83,
-	0x04, 0xb7, 0x0f, 0xfb, 0x12, 0xf9, 0x0f, 0xc4, 0x01, 0x5e, 0x0f, 0xc0,
-	0x1c, 0xda, 0x0f, 0xc4, 0x06, 0x92, 0x0f, 0xc5, 0x07, 0x5d, 0x0b, 0x40,
-	0x0f, 0xc4, 0x07, 0xf4, 0x0b, 0x21, 0x01, 0x88, 0x00, 0xdf, 0x11, 0xc8,
-	0x01, 0x1e, 0x12, 0x08, 0x0f, 0xc4, 0x01, 0x7c, 0x0c, 0x00, 0x0f, 0xfb,
-	0x1f, 0x0b, 0x0f, 0xf1, 0x03, 0x11, 0x00, 0xe2, 0x0f, 0xc4, 0x06, 0x8e,
-	0x0a, 0x64, 0x09, 0x80, 0x0f, 0xf1, 0x0c, 0x05, 0x0f, 0xc4, 0x05, 0xf2,
-	0x0a, 0x48, 0x0c, 0x00, 0x0f, 0xf1, 0x03, 0x38, 0x0a, 0x62, 0x00, 0x64,
-	0x09, 0xa1, 0x00, 0x54, 0x03, 0x48, 0x12, 0xc8, 0x04, 0x44, 0x0c, 0x00,
-	0x0f, 0xf1, 0x03, 0x1a, 0x0a, 0x48, 0x0f, 0xf1, 0x03, 0x19, 0x0a, 0x49,
-	0x0f, 0xc4, 0x01, 0x32, 0x0c, 0x02, 0x00, 0xb6, 0x0c, 0x42, 0x0f, 0xc8,
-	0x1f, 0xe8, 0x01, 0x37, 0x0f, 0xc4, 0x06, 0x96, 0x00, 0x37, 0x0f, 0xc4,
-	0x06, 0x2b, 0x02, 0xb7, 0x0f, 0xf7, 0x04, 0x66, 0x0f, 0xc4, 0x01, 0x7c,
-	0x0b, 0x08, 0x00, 0xb6, 0x00, 0x09, 0x03, 0x37, 0x0f, 0xf7, 0x04, 0x72,
-	0x0f, 0xf7, 0x01, 0x39, 0x0f, 0xc8, 0x1f, 0xfd, 0x01, 0x37, 0x0f, 0xc4,
-	0x00, 0x8f, 0x00, 0x37, 0x0f, 0xf7, 0x0d, 0x69, 0x0f, 0xf1, 0x03, 0x0a,
-	0x0a, 0x48, 0x0f, 0xf1, 0x03, 0x09, 0x0a, 0x49, 0x0f, 0xc4, 0x01, 0x30,
-	0x0c, 0x02, 0x0c, 0x42, 0x0c, 0x61, 0x00, 0x17, 0x1f, 0xf9, 0x1d, 0x8b,
-	0x0f, 0xc4, 0x01, 0x62, 0x00, 0x00, 0x0c, 0x61, 0x0f, 0xd1, 0x04, 0x00,
-	0x0f, 0xf8, 0x1d, 0x97, 0x09, 0xc9, 0x0f, 0xc4, 0x01, 0x62, 0x00, 0x40,
-	0x0c, 0x61, 0x0f, 0xd1, 0x0c, 0x00, 0x09, 0xc9, 0x00, 0x21, 0x0c, 0x18,
-	0x09, 0xc8, 0x0c, 0x51, 0x09, 0xc9, 0x00, 0xb7, 0x0f, 0xc4, 0x06, 0x99,
-	0x06, 0xb7, 0x03, 0x37, 0x03, 0xb7, 0x0f, 0xc4, 0x06, 0x8f, 0x0c, 0x02,
-	0x00, 0xb6, 0x0c, 0x42, 0x05, 0x37, 0x04, 0x37, 0x06, 0xbb, 0x1f, 0xf7,
-	0x00, 0x8f, 0x00, 0x36, 0x04, 0xc4, 0x0f, 0xfa, 0x07, 0xa2, 0x00, 0x0e,
-	0x07, 0x37, 0x0f, 0xf0, 0x03, 0x0b, 0x00, 0x32, 0x0f, 0xf0, 0x03, 0x1b,
-	0x00, 0x32, 0x0f, 0xf1, 0x03, 0x1d, 0x0a, 0x7f, 0x0f, 0xf0, 0x03, 0x1c,
-	0x0f, 0xf2, 0x00, 0x3f, 0x0f, 0xf0, 0x03, 0x1e, 0x00, 0x32, 0x0f, 0xf0,
-	0x03, 0x1f, 0x00, 0x32, 0x0f, 0xf0, 0x03, 0x2a, 0x0f, 0xf2, 0x07, 0xff,
-	0x0f, 0xf0, 0x03, 0x29, 0x00, 0xb2, 0x0f, 0xf0, 0x03, 0x2b, 0x0f, 0xf2,
-	0x00, 0x28, 0x0f, 0xf0, 0x03, 0x2f, 0x00, 0x72, 0x0f, 0xf0, 0x04, 0x00,
-	0x00, 0x32, 0x0f, 0xf0, 0x05, 0x11, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x15,
-	0x00, 0x32, 0x0f, 0xf0, 0x05, 0x17, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x0c,
-	0x00, 0xb2, 0x0f, 0xf0, 0x05, 0x02, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x08,
-	0x00, 0x32, 0x0f, 0xf0, 0x05, 0x01, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x00,
-	0x00, 0x32, 0x0f, 0xf0, 0x05, 0x07, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x06,
-	0x00, 0x32, 0x0f, 0xf0, 0x05, 0x04, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x05,
-	0x00, 0x32, 0x0f, 0xf0, 0x05, 0x0a, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x0b,
-	0x00, 0x32, 0x0f, 0xf0, 0x05, 0x03, 0x00, 0x32, 0x0f, 0xf0, 0x05, 0x09,
-	0x00, 0x32, 0x0f, 0xf0, 0x0a, 0x00, 0x05, 0xb2, 0x0f, 0xc8, 0x01, 0x13,
-	0x0f, 0xc4, 0x06, 0x00, 0x0f, 0xf0, 0x0a, 0x01, 0x0c, 0x32, 0x0c, 0x00,
-	0x0f, 0xf0, 0x0a, 0x20, 0x00, 0x32, 0x0f, 0xf0, 0x0a, 0x10, 0x00, 0x72,
-	0x0f, 0xf0, 0x0a, 0x11, 0x00, 0x32, 0x0f, 0xf0, 0x0a, 0x0a, 0x00, 0x32,
-	0x0f, 0xf0, 0x0a, 0x07, 0x04, 0x32, 0x0f, 0xf0, 0x0a, 0x2e, 0x0f, 0xf2,
-	0x01, 0xc8, 0x0f, 0xf0, 0x0a, 0x30, 0x0f, 0xf6, 0x0d, 0xdb, 0x06, 0x32,
-	0x0f, 0xf0, 0x0c, 0x11, 0x02, 0xb2, 0x0f, 0xf0, 0x0c, 0x12, 0x00, 0x32,
-	0x0f, 0xf0, 0x0c, 0x03, 0x00, 0x72, 0x0f, 0xf0, 0x0c, 0x1a, 0x0f, 0xf2,
-	0x08, 0x72, 0x0f, 0xf1, 0x0c, 0x1b, 0x0a, 0x62, 0x01, 0x25, 0x09, 0xb2,
-	0x0f, 0xc4, 0x01, 0x80, 0x00, 0x40, 0x0f, 0xc8, 0x0c, 0x1d, 0x0c, 0x30,
-	0x0f, 0xf2, 0x00, 0xa0, 0x0c, 0x31, 0x0a, 0x61, 0x0f, 0xd5, 0x02, 0xa0,
-	0x10, 0x00, 0x0c, 0x30, 0x0f, 0xf2, 0x00, 0x60, 0x0c, 0x31, 0x0a, 0x61,
-	0x0f, 0xd5, 0x01, 0x60, 0x10, 0x00, 0x0f, 0xf0, 0x0c, 0x1a, 0x0f, 0xf2,
-	0x08, 0x71, 0x0f, 0xf1, 0x0d, 0x00, 0x0a, 0x49, 0x0c, 0x61, 0x02, 0xde,
-	0x0c, 0x62, 0x0f, 0xe4, 0x08, 0x18, 0x1f, 0xe4, 0x08, 0x1e, 0x09, 0xa2,
-	0x04, 0x25, 0x09, 0xb2, 0x0f, 0xf1, 0x0d, 0x01, 0x00, 0x22, 0x1f, 0xe2,
-	0x0a, 0xaa, 0x0a, 0x64, 0x09, 0xb2, 0x0f, 0xc4, 0x06, 0x93, 0x0f, 0xc0,
-	0x00, 0x2b, 0x0f, 0xc8, 0x0f, 0xff, 0x09, 0x37, 0x0f, 0xc4, 0x06, 0x01,
-	0x00, 0x40, 0x04, 0x84, 0x00, 0x00, 0x04, 0x04, 0x00, 0x80, 0x0f, 0xc4,
-	0x06, 0xba, 0x0f, 0xc0, 0x06, 0xbb, 0x04, 0x04, 0x00, 0x40, 0x0f, 0xc8,
-	0x00, 0x28, 0x0f, 0xf7, 0x05, 0x23, 0x0f, 0xf6, 0x05, 0x23, 0x02, 0x88,
-	0x00, 0x69, 0x0e, 0xff, 0x00, 0x28, 0x0e, 0xff, 0x02, 0x3a, 0x00, 0x08,
-	0x02, 0xba, 0x00, 0x08, 0x0f, 0xc4, 0x01, 0xc1, 0x0f, 0xc0, 0x00, 0x47,
-	0x0f, 0xc4, 0x07, 0xf3, 0x0b, 0x08, 0x0c, 0x38, 0x00, 0x00, 0x01, 0x04,
-	0x0f, 0xc2, 0x0c, 0x18, 0x0f, 0xc2, 0x03, 0x01, 0x0f, 0xc2, 0x0d, 0x01,
-	0x0f, 0xc2, 0x0d, 0x00, 0x0f, 0xc2, 0x03, 0x03, 0x0f, 0xc2, 0x03, 0x06,
-	0x0f, 0xc2, 0x03, 0x05, 0x0f, 0xc2, 0x03, 0x28, 0x0f, 0xc2, 0x03, 0x18,
-	0x0f, 0xc2, 0x03, 0x3c, 0x0f, 0xc2, 0x03, 0x3b, 0x0f, 0xc2, 0x03, 0x16,
-	0x0f, 0xc2, 0x03, 0x17, 0x0f, 0xc2, 0x03, 0x26, 0x0f, 0xc2, 0x03, 0x27,
-	0x0f, 0xc2, 0x03, 0x24, 0x0f, 0xc2, 0x03, 0x25, 0x0f, 0xc2, 0x03, 0x12,
-	0x0f, 0xc2, 0x0f, 0x00, 0x0f, 0xc8, 0x0f, 0x12, 0x0c, 0x02, 0x0c, 0x02,
-	0x0c, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x0c, 0x02,
-	0x0f, 0xc2, 0x0f, 0x10, 0x0f, 0xc2, 0x0f, 0x13, 0x0f, 0xc2, 0x02, 0x01,
-	0x0f, 0xc2, 0x02, 0x04, 0x0f, 0xc2, 0x02, 0x03, 0x0f, 0xc2, 0x02, 0x06,
-	0x00, 0xc5, 0x0a, 0x83, 0x0a, 0xa1, 0x0b, 0xf1, 0x0a, 0xd5, 0x0a, 0x42,
-	0x1b, 0xf1, 0x1f, 0xf8, 0x1e, 0xd1, 0x1a, 0xd5, 0x0f, 0x39, 0x00, 0xc5,
-	0x0b, 0xc4, 0x0a, 0xa1, 0x0a, 0xd5, 0x1b, 0xf0, 0x1f, 0xf8, 0x1e, 0xda,
-	0x1b, 0xb2, 0x0f, 0x39, 0x0f, 0xc4, 0x06, 0xfd, 0x00, 0x61, 0x0b, 0x14,
-	0x00, 0x00, 0x1f, 0xc4, 0x06, 0xfc, 0x1f, 0x38, 0x10, 0x00, 0x0f, 0xc4,
-	0x06, 0xfb, 0x0b, 0x15, 0x0f, 0xc4, 0x06, 0xfc, 0x1b, 0x15, 0x1f, 0x39,
-	0x00, 0x40, 0x0f, 0xe2, 0x0a, 0xaa, 0x00, 0x04, 0x0f, 0xc5, 0x07, 0xfd,
-	0x0b, 0x63, 0x09, 0x82, 0x0f, 0xc5, 0x07, 0xfe, 0x0b, 0xe3, 0x09, 0x82,
-	0x0b, 0xe3, 0x0f, 0xfa, 0x1e, 0x8f, 0x09, 0x82, 0x0f, 0xf0, 0x0f, 0x19,
-	0x00, 0x32, 0x0f, 0xf0, 0x0f, 0x18, 0x00, 0x32, 0x0f, 0xf0, 0x0f, 0x1a,
-	0x00, 0x72, 0x0f, 0xf9, 0x1f, 0x09, 0x0f, 0xf1, 0x0f, 0x14, 0x0f, 0xc4,
-	0x01, 0x3e, 0x0a, 0x48, 0x0c, 0x02, 0x0f, 0xf1, 0x0f, 0x15, 0x0a, 0x42,
-	0x0c, 0x21, 0x00, 0x1f, 0x0f, 0xc4, 0x07, 0xf0, 0x00, 0x00, 0x10, 0x40,
-	0x00, 0x09, 0x00, 0x4a, 0x00, 0x5f, 0x10, 0x49, 0x10, 0x0a, 0x00, 0x9e,
-	0x10, 0x49, 0x10, 0x4a, 0x0f, 0xc4, 0x07, 0xea, 0x0c, 0x40, 0x0f, 0xc4,
-	0x07, 0xeb, 0x0c, 0x80, 0x0f, 0xe2, 0x02, 0xa0, 0x0f, 0xc4, 0x01, 0x7b,
-	0x0c, 0x24, 0x09, 0x80, 0x0f, 0xc4, 0x01, 0x7a, 0x0c, 0x26, 0x09, 0xa4,
-	0x0f, 0x38, 0x09, 0x80, 0x0f, 0xf9, 0x19, 0xf7, 0x0f, 0xf9, 0x1f, 0x42,
-	0x0f, 0xf9, 0x1f, 0x46, 0x0f, 0xf9, 0x1f, 0x4a, 0x0f, 0xf9, 0x1f, 0x4e,
-	0x0f, 0xf9, 0x1f, 0x52, 0x0f, 0xf9, 0x1f, 0x5a, 0x0f, 0xc4, 0x00, 0x83,
-	0x00, 0x37, 0x0f, 0xb9, 0x0f, 0xc4, 0x00, 0xe0, 0x00, 0x37, 0x0f, 0xb9,
-	0x0f, 0xc4, 0x00, 0xe3, 0x00, 0x37, 0x0f, 0xb9, 0x0f, 0xc4, 0x00, 0x8c,
-	0x00, 0x37, 0x0f, 0xb9, 0x0f, 0xbb, 0x0f, 0xc4, 0x01, 0x71, 0x0b, 0x14,
-	0x1f, 0x39, 0x0c, 0x51, 0x0f, 0x38, 0x09, 0xc9, 0x0f, 0xfb, 0x08, 0xc2,
-	0x0f, 0xb9, 0x0f, 0xbf, 0x00, 0xf3, 0x0f, 0xfc, 0x1f, 0x34, 0x0f, 0xfc,
-	0x0e, 0xe2, 0x0f, 0xfc, 0x09, 0x7e, 0x0f, 0xfc, 0x09, 0x84, 0x0f, 0xfc,
-	0x09, 0x87, 0x0f, 0xfc, 0x0c, 0x9f, 0x0f, 0xfc, 0x0b, 0x5b, 0x0f, 0xfc,
-	0x0a, 0x72, 0x0f, 0xff, 0x00, 0x00, 0x0f, 0xff, 0x0f, 0x77, 0x0f, 0xff,
-	0x00, 0x26, 0x0f, 0xff, 0x00, 0x27, 0x0f, 0xff, 0x00, 0x28, 0x0f, 0xff,
-	0x00, 0x29, 0x0f, 0xff, 0x00, 0x2a, 0x0f, 0xff, 0x02, 0x00, 0x0f, 0xff,
-	0x02, 0x05, 0x0f, 0xff, 0x0c, 0xad, 0x0f, 0xff, 0x0a, 0xb6, 0x0f, 0xc4,
-	0x06, 0xfd, 0x00, 0x00, 0x00, 0x04, 0x0f, 0xe2, 0x0a, 0xaa, 0x0f, 0xc5,
-	0x07, 0xfd, 0x0b, 0xa3, 0x09, 0xa1, 0x0b, 0xd4, 0x1f, 0xc5, 0x07, 0xfe,
-	0x1b, 0xa3, 0x19, 0xa1, 0x1b, 0xd4, 0x1b, 0xa3, 0x19, 0xa1, 0x1b, 0xd4,
-	0x1f, 0xc4, 0x06, 0xfc, 0x1b, 0x21, 0x10, 0x54, 0x1f, 0xf9, 0x1f, 0xab,
-	0x0f, 0xfb, 0x1b, 0x7f, 0x0f, 0xfb, 0x18, 0x51, 0x0f, 0xfb, 0x02, 0xe3,
-	0x0f, 0xfb, 0x1b, 0xb6, 0x0f, 0xf0, 0x0f, 0x00, 0x0f, 0xf8, 0x1f, 0xb7,
-	0x01, 0x72, 0x0f, 0xc4, 0x06, 0xfd, 0x0f, 0xfa, 0x1e, 0xd7, 0x00, 0x40,
-	0x0f, 0xc4, 0x07, 0xf3, 0x0f, 0xfa, 0x1c, 0xa7, 0x00, 0x00, 0x0f, 0xf9,
-	0x1f, 0xb7, 0x0f, 0xfb, 0x01, 0xcf, 0x0f, 0xf9, 0x1f, 0xc2, 0x03, 0x3a,
-	0x00, 0xc8, 0x10, 0x55, 0x10, 0x95, 0x12, 0x15, 0x1f, 0xfb, 0x02, 0x35,
-	0x0f, 0xfb, 0x01, 0xcb, 0x0f, 0xfb, 0x17, 0x17, 0x0f, 0xfb, 0x01, 0xcf,
-	0x0f, 0xf8, 0x1f, 0xbb, 0x00, 0xc8, 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, 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, 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, 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, 0x00, 0x00,
-	0x00, 0x08, 0x07, 0x06 
-};
-
-#endif
diff -Nru a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/stv0297.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,783 @@
+/*
+    Driver for STV0297 demodulator
+
+    Copyright (C) 2004 Andrew de Quincey <adq_dvb@lidskialf.net>
+    Copyright (C) 2003-2004 Dennis Noermann <dennis.noermann@noernet.de>
+
+    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.
+*/
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+
+#include "dvb_frontend.h"
+#include "stv0297.h"
+
+struct stv0297_state {
+
+        struct i2c_adapter* i2c;
+
+        struct dvb_frontend_ops ops;
+
+        const struct stv0297_config* config;
+
+        struct dvb_frontend frontend;
+
+        int freq_off;
+
+	unsigned long base_freq;
+
+	u8 pwm;
+};
+
+#if 1
+#define dprintk(x...) printk(x)
+#else
+#define dprintk(x...)
+#endif
+
+#define STV0297_CLOCK_KHZ   28900
+
+static u8 init_tab [] = {
+  0x00, 0x09,
+  0x01, 0x69,
+  0x03, 0x00,
+  0x04, 0x00,
+  0x07, 0x00,
+  0x08, 0x00,
+  0x20, 0x00,
+  0x21, 0x40,
+  0x22, 0x00,
+  0x23, 0x00,
+  0x24, 0x40,
+  0x25, 0x88,
+  0x30, 0xff,
+  0x31, 0x00,
+  0x32, 0xff,
+  0x33, 0x00,
+  0x34, 0x50,
+  0x35, 0x7f,
+  0x36, 0x00,
+  0x37, 0x20,
+  0x38, 0x00,
+  0x40, 0x1c,
+  0x41, 0xff,
+  0x42, 0x29,
+	0x43, 0x00,
+  0x44, 0xff,
+  0x45, 0x00,
+  0x46, 0x00,
+  0x49, 0x04,
+  0x4a, 0xff,
+  0x4b, 0x7f,
+  0x52, 0x30,
+  0x55, 0xae,
+  0x56, 0x47,
+  0x57, 0xe1,
+  0x58, 0x3a,
+  0x5a, 0x1e,
+  0x5b, 0x34,
+  0x60, 0x00,
+  0x63, 0x00,
+  0x64, 0x00,
+  0x65, 0x00,
+  0x66, 0x00,
+  0x67, 0x00,
+  0x68, 0x00,
+  0x69, 0x00,
+  0x6a, 0x02,
+  0x6b, 0x00,
+  0x70, 0xff,
+  0x71, 0x00,
+  0x72, 0x00,
+  0x73, 0x00,
+  0x74, 0x0c,
+  0x80, 0x00,
+  0x81, 0x00,
+  0x82, 0x00,
+  0x83, 0x00,
+  0x84, 0x04,
+  0x85, 0x80,
+  0x86, 0x24,
+  0x87, 0x78,
+  0x88, 0x00,
+  0x89, 0x00,
+  0x90, 0x01,
+  0x91, 0x01,
+  0xa0, 0x00,
+  0xa1, 0x00,
+  0xa2, 0x00,
+  0xb0, 0x91,
+  0xb1, 0x0b,
+  0xc0, 0x53,
+  0xc1, 0x70,
+  0xc2, 0x12,
+  0xd0, 0x00,
+  0xd1, 0x00,
+  0xd2, 0x00,
+  0xd3, 0x00,
+  0xd4, 0x00,
+  0xd5, 0x00,
+  0xde, 0x00,
+  0xdf, 0x00,
+  0x61, 0x49,
+  0x62, 0x0b,
+  0x53, 0x08,
+  0x59, 0x08,
+};
+
+
+static int stv0297_writereg (struct stv0297_state* state, u8 reg, u8 data)
+{
+        int ret;
+        u8 buf [] = { reg, data };
+        struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
+
+        ret = i2c_transfer (state->i2c, &msg, 1);
+
+        if (ret != 1)
+                dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, "
+                  "ret == %i)\n", __FUNCTION__, reg, data, ret);
+
+        return (ret != 1) ? -1 : 0;
+}
+
+static int stv0297_readreg (struct stv0297_state* state, u8 reg)
+{
+        int ret;
+        u8 b0[] = { reg };
+        u8 b1[] = { 0 };
+        struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
+                                  { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
+
+        // this device needs a STOP between the register and data
+        if ((ret = i2c_transfer (state->i2c, &msg[0], 1)) != 1) {
+		dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg, ret);
+                return -1;
+        }
+        if ((ret = i2c_transfer (state->i2c, &msg[1], 1)) != 1) {
+		dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg, ret);
+                return -1;
+        }
+
+        return b1[0];
+}
+
+static int stv0297_writereg_mask (struct stv0297_state* state, u8 reg, u8 mask, u8 data)
+{
+        int val;
+
+        val = stv0297_readreg(state, reg);
+        val &= ~mask;
+        val |= (data & mask);
+        stv0297_writereg(state, reg, val);
+
+        return 0;
+}
+
+static int stv0297_readregs (struct stv0297_state* state, u8 reg1, u8 *b, u8 len)
+{
+        int ret;
+        struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = &reg1, .len = 1 },
+                                  { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } };
+
+        // this device needs a STOP between the register and data
+        if ((ret = i2c_transfer (state->i2c, &msg[0], 1)) != 1) {
+		dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg1, ret);
+                return -1;
+        }
+        if ((ret = i2c_transfer (state->i2c, &msg[1], 1)) != 1) {
+		dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg1, ret);
+                return -1;
+        }
+
+        return 0;
+}
+
+static void stv0297_set_symbolrate(struct stv0297_state *state, u32 srate)
+{
+	long tmp;
+
+	tmp = 131072L * srate;	/* 131072 = 2^17  */
+	tmp = tmp / (STV0297_CLOCK_KHZ / 4);	/* 1/4 = 2^-2 */
+	tmp = tmp * 8192L;	/* 8192 = 2^13 */
+
+        stv0297_writereg (state, 0x55,(unsigned char)(tmp & 0xFF));
+        stv0297_writereg (state, 0x56,(unsigned char)(tmp>> 8));
+        stv0297_writereg (state, 0x57,(unsigned char)(tmp>>16));
+        stv0297_writereg (state, 0x58,(unsigned char)(tmp>>24));
+}
+
+static void stv0297_set_sweeprate(struct stv0297_state *state, short fshift, long symrate)
+{
+	long tmp;
+
+	tmp = (long) fshift *262144L;	/* 262144 = 2*18 */
+	tmp /= symrate;
+	tmp *= 1024;		/* 1024 = 2*10   */
+
+        // adjust
+        if (tmp >= 0) {
+                tmp += 500000;
+        } else {
+                tmp -= 500000;
+        }
+	tmp /= 1000000;
+
+        stv0297_writereg(state, 0x60, tmp & 0xFF);
+        stv0297_writereg_mask(state, 0x69, 0xF0, (tmp >> 4) & 0xf0);
+}
+
+static void stv0297_set_carrieroffset(struct stv0297_state* state, long offset)
+{
+	long tmp;
+
+	/* symrate is hardcoded to 10000 */
+	tmp = offset * 26844L;	/* (2**28)/10000 */
+	if (tmp < 0)
+		tmp += 0x10000000;
+	tmp &= 0x0FFFFFFF;
+
+	stv0297_writereg(state, 0x66, (unsigned char) (tmp & 0xFF));
+	stv0297_writereg(state, 0x67, (unsigned char) (tmp >> 8));
+	stv0297_writereg(state, 0x68, (unsigned char) (tmp >> 16));
+	stv0297_writereg_mask(state, 0x69, 0x0F, (tmp >> 24) & 0x0f);
+}
+
+static long stv0297_get_carrieroffset(struct stv0297_state* state)
+{
+        s32 raw;
+	long tmp;
+
+        stv0297_writereg(state,0x6B, 0x00);
+
+        raw =   stv0297_readreg(state,0x66);
+        raw |= (stv0297_readreg(state,0x67) << 8);
+        raw |= (stv0297_readreg(state,0x68) << 16);
+        raw |= (stv0297_readreg(state,0x69) & 0x0F) << 24;
+
+        tmp = raw;
+	tmp /= 26844L;
+
+	return tmp;
+}
+
+static void stv0297_set_initialdemodfreq(struct stv0297_state* state, long freq)
+{
+/*
+        s64 tmp;
+
+        if (freq > 10000) freq -= STV0297_CLOCK_KHZ;
+
+        tmp = freq << 16;
+        do_div(tmp, STV0297_CLOCK_KHZ);
+        if (tmp > 0xffff) tmp = 0xffff; // check this calculation
+
+        stv0297_writereg_mask(state, 0x25, 0x80, 0x80);
+        stv0297_writereg(state, 0x21, tmp >> 8);
+        stv0297_writereg(state, 0x20, tmp);
+*/
+}
+
+static int stv0297_set_qam(struct stv0297_state* state, fe_modulation_t modulation)
+{
+        int val = 0;
+
+        switch(modulation) {
+        case QAM_16:
+                val = 0;
+                break;
+
+        case QAM_32:
+                val = 1;
+                break;
+
+        case QAM_64:
+                val = 4;
+                break;
+
+        case QAM_128:
+                val = 2;
+                break;
+
+        case QAM_256:
+                val = 3;
+                break;
+
+        default:
+                return -EINVAL;
+        }
+
+        stv0297_writereg_mask(state, 0x00, 0x70, val << 4);
+
+        return 0;
+}
+
+static int stv0297_set_inversion(struct stv0297_state* state, fe_spectral_inversion_t inversion)
+{
+        int val = 0;
+
+        switch(inversion) {
+        case INVERSION_OFF:
+                val = 0;
+                break;
+
+        case INVERSION_ON:
+                val = 1;
+                break;
+
+        default:
+                return -EINVAL;
+        }
+
+        stv0297_writereg_mask(state, 0x83, 0x08, val << 3);
+
+        return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+int stv0297_enable_plli2c(struct dvb_frontend* fe)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+
+        stv0297_writereg(state, 0x87, 0x78);
+        stv0297_writereg(state, 0x86, 0xc8);
+
+        return 0;
+}
+
+static int stv0297_init (struct dvb_frontend* fe)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+        int i;
+
+	/* soft reset */
+        stv0297_writereg_mask(state, 0x80, 1, 1);
+        stv0297_writereg_mask(state, 0x80, 1, 0);
+
+	/* reset deinterleaver */
+        stv0297_writereg_mask(state, 0x81, 1, 1);
+        stv0297_writereg_mask(state, 0x81, 1, 0);
+
+	/* load init table */
+        for (i=0; i<sizeof(init_tab); i+=2) {
+                stv0297_writereg (state, init_tab[i], init_tab[i+1]);
+        }
+
+	/* set a dummy symbol rate */
+        stv0297_set_symbolrate(state, 6900);
+
+	/* invert AGC1 polarity */
+        stv0297_writereg_mask(state, 0x88, 0x10, 0x10);
+
+	/* setup bit error counting */
+        stv0297_writereg_mask(state, 0xA0, 0x80, 0x00);
+        stv0297_writereg_mask(state, 0xA0, 0x10, 0x00);
+        stv0297_writereg_mask(state, 0xA0, 0x08, 0x00);
+        stv0297_writereg_mask(state, 0xA0, 0x07, 0x04);
+
+	/* min + max PWM */
+        stv0297_writereg(state, 0x4a, 0x00);
+        stv0297_writereg(state, 0x4b, state->pwm);
+        msleep(200);
+
+	if (state->config->pll_init)
+		state->config->pll_init(fe);
+
+        return 0;
+}
+
+static int stv0297_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+
+        u8 sync = stv0297_readreg (state, 0xDF);
+
+        *status = 0;
+        if (sync & 0x80)
+		*status |=
+			FE_HAS_SYNC | FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_LOCK;
+        return 0;
+}
+
+static int stv0297_read_ber(struct dvb_frontend* fe, u32* ber)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+        u8 BER[3];
+
+        stv0297_writereg (state, 0xA0, 0x80);	// Start Counting bit errors for 4096 Bytes
+        mdelay(25);				// Hopefully got 4096 Bytes
+        stv0297_readregs (state, 0xA0, BER, 3);
+        mdelay(25);
+        *ber = (BER[2] << 8 | BER[1]) / ( 8 * 4096);
+
+        return 0;
+}
+
+
+static int stv0297_read_signal_strength(struct dvb_frontend* fe, u16* strength)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+        u8 STRENGTH[2];
+
+        stv0297_readregs (state, 0x41, STRENGTH, 2);
+        *strength = (STRENGTH[1] & 0x03) << 8 | STRENGTH[0];
+
+        return 0;
+}
+
+static int stv0297_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+        u8 SNR[2];
+
+        stv0297_readregs (state, 0x07, SNR, 2);
+        *snr = SNR[1] << 8 | SNR[0];
+
+        return 0;
+}
+
+static int stv0297_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+
+        *ucblocks = (stv0297_readreg (state, 0xD5) << 8)
+                   | stv0297_readreg (state, 0xD4);
+
+        return 0;
+}
+
+static int stv0297_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+        int u_threshold;
+        int initial_u;
+        int blind_u;
+        int delay;
+        int sweeprate;
+        int carrieroffset;
+        unsigned long starttime;
+        unsigned long timeout;
+
+        switch(p->u.qam.modulation) {
+        case QAM_16:
+        case QAM_32:
+        case QAM_64:
+          delay = 100;
+          sweeprate = 1500;
+          break;
+
+        case QAM_128:
+          delay = 150;
+          sweeprate = 1000;
+          break;
+
+        case QAM_256:
+          delay = 200;
+          sweeprate = 500;
+          break;
+
+        default:
+          return -EINVAL;
+        }
+
+        // determine inversion dependant parameters
+        carrieroffset = -330;
+        switch(p->inversion) {
+        case INVERSION_OFF:
+          break;
+
+        case INVERSION_ON:
+          sweeprate = -sweeprate;
+          carrieroffset = -carrieroffset;
+          break;
+
+        default:
+          return -EINVAL;
+        }
+
+        state->config->pll_set(fe, p);
+
+	/* clear software interrupts */
+	stv0297_writereg(state, 0x82, 0x0);
+
+	/* set initial demodulation frequency */
+        stv0297_set_initialdemodfreq(state, state->freq_off + 7250);
+
+	/* setup AGC */
+        stv0297_writereg_mask(state, 0x43, 0x10, 0x00);
+        stv0297_writereg(state, 0x41, 0x00);
+        stv0297_writereg_mask(state, 0x42, 0x03, 0x01);
+        stv0297_writereg_mask(state, 0x36, 0x60, 0x00);
+        stv0297_writereg_mask(state, 0x36, 0x18, 0x00);
+        stv0297_writereg_mask(state, 0x71, 0x80, 0x80);
+        stv0297_writereg(state, 0x72, 0x00);
+        stv0297_writereg(state, 0x73, 0x00);
+        stv0297_writereg_mask(state, 0x74, 0x0F, 0x00);
+        stv0297_writereg_mask(state, 0x43, 0x08, 0x00);
+        stv0297_writereg_mask(state, 0x71, 0x80, 0x00);
+
+	/* setup STL */
+        stv0297_writereg_mask(state, 0x5a, 0x20, 0x20);
+        stv0297_writereg_mask(state, 0x5b, 0x02, 0x02);
+        stv0297_writereg_mask(state, 0x5b, 0x02, 0x00);
+        stv0297_writereg_mask(state, 0x5b, 0x01, 0x00);
+        stv0297_writereg_mask(state, 0x5a, 0x40, 0x40);
+
+	/* disable frequency sweep */
+        stv0297_writereg_mask(state, 0x6a, 0x01, 0x00);
+
+	/* reset deinterleaver */
+        stv0297_writereg_mask(state, 0x81, 0x01, 0x01);
+        stv0297_writereg_mask(state, 0x81, 0x01, 0x00);
+
+	/* ??? */
+        stv0297_writereg_mask(state, 0x83, 0x20, 0x20);
+        stv0297_writereg_mask(state, 0x83, 0x20, 0x00);
+
+	/* reset equaliser */
+        u_threshold = stv0297_readreg(state, 0x00) & 0xf;
+        initial_u = stv0297_readreg(state, 0x01) >> 4;
+        blind_u = stv0297_readreg(state, 0x01) & 0xf;
+        stv0297_writereg_mask(state, 0x84, 0x01, 0x01);
+        stv0297_writereg_mask(state, 0x84, 0x01, 0x00);
+        stv0297_writereg_mask(state, 0x00, 0x0f, u_threshold);
+        stv0297_writereg_mask(state, 0x01, 0xf0, initial_u << 4);
+        stv0297_writereg_mask(state, 0x01, 0x0f, blind_u);
+
+	/* data comes from internal A/D */
+        stv0297_writereg_mask(state, 0x87, 0x80, 0x00);
+
+	/* clear phase registers */
+        stv0297_writereg(state, 0x63, 0x00);
+        stv0297_writereg(state, 0x64, 0x00);
+        stv0297_writereg(state, 0x65, 0x00);
+        stv0297_writereg(state, 0x66, 0x00);
+        stv0297_writereg(state, 0x67, 0x00);
+        stv0297_writereg(state, 0x68, 0x00);
+        stv0297_writereg_mask(state, 0x69, 0x0f, 0x00);
+
+	/* set parameters */
+        stv0297_set_qam(state, p->u.qam.modulation);
+        stv0297_set_symbolrate(state, p->u.qam.symbol_rate/1000);
+	stv0297_set_sweeprate(state, sweeprate, p->u.qam.symbol_rate / 1000);
+        stv0297_set_carrieroffset(state, carrieroffset);
+        stv0297_set_inversion(state, p->inversion);
+
+	/* kick off lock */
+        stv0297_writereg_mask(state, 0x88, 0x08, 0x08);
+        stv0297_writereg_mask(state, 0x5a, 0x20, 0x00);
+        stv0297_writereg_mask(state, 0x6a, 0x01, 0x01);
+        stv0297_writereg_mask(state, 0x43, 0x40, 0x40);
+        stv0297_writereg_mask(state, 0x5b, 0x30, 0x00);
+        stv0297_writereg_mask(state, 0x03, 0x0c, 0x0c);
+        stv0297_writereg_mask(state, 0x03, 0x03, 0x03);
+        stv0297_writereg_mask(state, 0x43, 0x10, 0x10);
+
+	/* wait for WGAGC lock */
+        starttime = jiffies;
+        timeout = jiffies + (200*HZ)/1000;
+        while(time_before(jiffies, timeout)) {
+                msleep(10);
+		if (stv0297_readreg(state, 0x43) & 0x08)
+			break;
+        }
+        if (time_after(jiffies, timeout)) {
+                goto timeout;
+        }
+        msleep(20);
+
+	/* wait for equaliser partial convergence */
+        timeout = jiffies + (50*HZ)/1000;
+        while(time_before(jiffies, timeout)) {
+                msleep(10);
+
+                if (stv0297_readreg(state, 0x82) & 0x04) {
+			break;
+                }
+        }
+	if (time_after(jiffies, timeout)) {
+                goto timeout;
+        }
+
+	/* wait for equaliser full convergence */
+        timeout = jiffies + (delay*HZ)/1000;
+        while(time_before(jiffies, timeout)) {
+                msleep(10);
+
+                if (stv0297_readreg(state, 0x82) & 0x08) {
+                        break;
+                }
+        }
+        if (time_after(jiffies, timeout)) {
+                goto timeout;
+        }
+
+	/* disable sweep */
+        stv0297_writereg_mask(state, 0x6a, 1, 0);
+        stv0297_writereg_mask(state, 0x88, 8, 0);
+
+	/* wait for main lock */
+        timeout = jiffies + (20*HZ)/1000;
+        while(time_before(jiffies, timeout)) {
+                msleep(10);
+
+                if (stv0297_readreg(state, 0xDF) & 0x80) {
+                        break;
+                }
+        }
+        if (time_after(jiffies, timeout)) {
+                goto timeout;
+        }
+        msleep(100);
+
+	/* is it still locked after that delay? */
+        if (!(stv0297_readreg(state, 0xDF) & 0x80)) {
+                goto timeout;
+        }
+
+	/* success!! */
+        stv0297_writereg_mask(state, 0x5a, 0x40, 0x00);
+        state->freq_off = stv0297_get_carrieroffset(state);
+        state->base_freq = p->frequency;
+        return 0;
+
+timeout:
+        stv0297_writereg_mask(state, 0x6a, 0x01, 0x00);
+        return 0;
+}
+
+static int stv0297_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+        int reg_00, reg_83;
+
+        reg_00 = stv0297_readreg(state, 0x00);
+        reg_83 = stv0297_readreg(state, 0x83);
+
+        p->frequency = state->base_freq + state->freq_off;
+        p->inversion = (reg_83 & 0x08) ? INVERSION_ON : INVERSION_OFF;
+	p->u.qam.symbol_rate = 0;
+        p->u.qam.fec_inner = 0;
+
+        switch((reg_00 >> 4) & 0x7) {
+	case 0:
+		p->u.qam.modulation = QAM_16;
+		break;
+	case 1:
+		p->u.qam.modulation = QAM_32;
+		break;
+	case 2:
+		p->u.qam.modulation = QAM_128;
+		break;
+	case 3:
+		p->u.qam.modulation = QAM_256;
+		break;
+	case 4:
+		p->u.qam.modulation = QAM_64;
+		break;
+        }
+
+        return 0;
+}
+
+static void stv0297_release(struct dvb_frontend* fe)
+{
+        struct stv0297_state* state = (struct stv0297_state*) fe->demodulator_priv;
+        kfree(state);
+}
+
+static struct dvb_frontend_ops stv0297_ops;
+
+struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
+				    struct i2c_adapter *i2c, int pwm)
+{
+        struct stv0297_state* state = NULL;
+
+        /* allocate memory for the internal state */
+        state = (struct stv0297_state*) kmalloc(sizeof(struct stv0297_state), GFP_KERNEL);
+	if (state == NULL)
+		goto error;
+
+        /* setup the state */
+        state->config = config;
+        state->i2c = i2c;
+        memcpy(&state->ops, &stv0297_ops, sizeof(struct dvb_frontend_ops));
+        state->freq_off = 0;
+        state->base_freq = 0;
+        state->pwm = pwm;
+
+        /* check if the demod is there */
+	if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20)
+		goto error;
+
+        /* create dvb_frontend */
+        state->frontend.ops = &state->ops;
+        state->frontend.demodulator_priv = state;
+        return &state->frontend;
+
+error:
+	if (state)
+		kfree(state);
+        return NULL;
+}
+
+static struct dvb_frontend_ops stv0297_ops = {
+
+        .info = {
+                .name			= "ST STV0297 DVB-C",
+                .type			= FE_QAM,
+                .frequency_min		= 64000000,
+                .frequency_max		= 1300000000,
+                .frequency_stepsize	= 62500,
+                .symbol_rate_min	= 870000,
+                .symbol_rate_max	= 11700000,
+                .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
+		 FE_CAN_QAM_128 | FE_CAN_QAM_256 | FE_CAN_FEC_AUTO},
+
+        .release = stv0297_release,
+
+        .init = stv0297_init,
+
+        .set_frontend = stv0297_set_frontend,
+        .get_frontend = stv0297_get_frontend,
+
+        .read_status = stv0297_read_status,
+        .read_ber = stv0297_read_ber,
+        .read_signal_strength = stv0297_read_signal_strength,
+        .read_snr = stv0297_read_snr,
+        .read_ucblocks = stv0297_read_ucblocks,
+};
+
+MODULE_DESCRIPTION("ST STV0297 DVB-C Demodulator driver");
+MODULE_AUTHOR("Dennis Noermann and Andrew de Quincey");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(stv0297_attach);
+EXPORT_SYMBOL(stv0297_enable_plli2c);
diff -Nru a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/stv0297.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,41 @@
+/*
+    Driver for STV0297 demodulator
+
+    Copyright (C) 2003-2004 Dennis Noermann <dennis.noermann@noernet.de>
+
+    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.
+*/
+
+#ifndef STV0297_H
+#define STV0297_H
+
+#include <linux/dvb/frontend.h>
+#include "dvb_frontend.h"
+
+struct stv0297_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
+					   struct i2c_adapter* i2c, int pwm);
+extern int stv0297_enable_plli2c(struct dvb_frontend* fe);
+
+#endif // STV0297_H
diff -Nru a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c
--- a/drivers/media/dvb/frontends/stv0299.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/media/dvb/frontends/stv0299.c	2004-12-24 13:37:32 -08:00
@@ -1,8 +1,5 @@
 /*
-    Universal driver for STV0299/TDA5059/SL1935 based
-    DVB QPSK frontends
-
-    Alps BSRU6, LG TDQB-S00x
+    Driver for ST STV0299 demodulator
 
     Copyright (C) 2001-2002 Convergence Integrated Media GmbH
 	<ralph@convergence.de>,
@@ -48,250 +45,73 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <asm/div64.h>
 
 #include "dvb_frontend.h"
-#include "dvb_functions.h"
-
-#if 0
-#define dprintk(x...) printk(x)
-#else
-#define dprintk(x...)
-#endif
+#include "stv0299.h"
 
-static int stv0299_status = 0;
-static int disable_typhoon = 0;
+struct stv0299_state {
 
-#define STATUS_BER 0
-#define STATUS_UCBLOCKS 1
+	struct i2c_adapter* i2c;
 
+	struct dvb_frontend_ops ops;
 
-/* frontend types */
-#define UNKNOWN_FRONTEND  -1
-#define PHILIPS_SU1278_TSA	0 // SU1278 with TSA5059 synth and datasheet recommended settings
-#define ALPS_BSRU6         1
-#define LG_TDQF_S001F      2
-#define PHILIPS_SU1278_TUA      3 // SU1278 with TUA6100 synth
-#define SAMSUNG_TBMU24112IMB    4
-#define PHILIPS_SU1278_TSA_TT	5 // SU1278 with TSA5059 synth and TechnoTrend settings
-#define PHILIPS_SU1278_TSA_TY	6 // SU1278 with TUA5059 synth and Typhoon wiring
-
-/* Master Clock = 88 MHz */
-#define M_CLK (88000000UL) 
-
-/* Master Clock for TT cards = 64 MHz */
-#define M_CLK_SU1278_TSA_TT (64000000UL)
-
-static struct dvb_frontend_info uni0299_info = {
-	.name			= "STV0299/TSA5059/SL1935 based",
-	.type			= FE_QPSK,
-	.frequency_min		= 950000,
-	.frequency_max		= 2150000,
-	.frequency_stepsize	= 125,   /* kHz for QPSK frontends */
-	.frequency_tolerance	= M_CLK/2000,
-	.symbol_rate_min	= 1000000,
-	.symbol_rate_max	= 45000000,
-	.symbol_rate_tolerance	= 500,  /* ppm */
-	.notifier_delay		= 0,
-	.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-	      FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
-	      FE_CAN_QPSK |
-	      FE_CAN_FEC_AUTO
-};
+	const struct stv0299_config* config;
 
+	struct dvb_frontend frontend;
 
-struct stv0299_state {
-	u8 tuner_type;
 	u8 initialised:1;
 	u32 tuner_frequency;
 	u32 symbol_rate;
 	fe_code_rate_t fec_inner;
+	int errmode;
 };
 
+#define STATUS_BER 0
+#define STATUS_UCBLOCKS 1
 
-static u8 init_tab [] = {
-	0x04, 0x7d,   /* F22FR = 0x7d                                 */
-		      /* F22 = f_VCO / 128 / 0x7d = 22 kHz            */
-
-        /* I2C bus repeater */
-	0x05, 0x35,   /* I2CT = 0, SCLT = 1, SDAT = 1                 */
-
- 	/* general purpose DAC registers */
-	0x06, 0x40,   /* DAC not used, set to high impendance mode    */
-	0x07, 0x00,   /* DAC LSB                                      */
-
-	/* DiSEqC registers */
-	0x08, 0x40,   /* DiSEqC off, LNB power on OP2/LOCK pin on     */
-	0x09, 0x00,   /* FIFO                                         */
-
-        /* Input/Output configuration register */
-	0x0c, 0x51,   /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
-	              /* OP0 ctl = Normal, OP0 val = 1 (18 V)         */
-                      /* Nyquist filter = 00, QPSK reverse = 0        */
-                   
-        /* AGC1 control register */
-	0x0d, 0x82,   /* DC offset compensation = ON, beta_agc1 = 2   */
-
-        /* Timing loop register */
-	0x0e, 0x23,   /* alpha_tmg = 2, beta_tmg = 3                  */
-
-	0x10, 0x3f,   // AGC2  0x3d
-
-	0x11, 0x84,
-	0x12, 0xb5,   // Lock detect: -64  Carrier freq detect:on
-
-	0x15, 0xc9,   // lock detector threshold
-
-	0x16, 0x00,
-	0x17, 0x00,
-	0x18, 0x00,
-	0x19, 0x00,
-	0x1a, 0x00,
-
-	0x1f, 0x50,
-
-	0x20, 0x00,
-	0x21, 0x00,
-	0x22, 0x00,
-	0x23, 0x00,
-
-	0x28, 0x00,  // out imp: normal  out type: parallel FEC mode:0
-
-	0x29, 0x1e,  // 1/2 threshold
-	0x2a, 0x14,  // 2/3 threshold
-	0x2b, 0x0f,  // 3/4 threshold
-	0x2c, 0x09,  // 5/6 threshold
-	0x2d, 0x05,  // 7/8 threshold
-	0x2e, 0x01,
-
-	0x31, 0x1f,  // test all FECs
-
-	0x32, 0x19,  // viterbi and synchro search
-	0x33, 0xfc,  // rs control
-	0x34, 0x93,  // error control
-};
-
-
-static u8 init_tab_samsung [] = {
-	0x01, 0x15,
-	0x02, 0x00,
-	0x03, 0x00,
-	0x04, 0x7D,
-	0x05, 0x35,
-	0x06, 0x02,
-	0x07, 0x00,
-	0x08, 0xC3,
-	0x0C, 0x00,
-	0x0D, 0x81,
-	0x0E, 0x23,
-	0x0F, 0x12,
-	0x10, 0x7E,
-	0x11, 0x84,
-	0x12, 0xB9,
-	0x13, 0x88,
-	0x14, 0x89,
-	0x15, 0xC9,
-	0x16, 0x00,
-	0x17, 0x5C,
-	0x18, 0x00,
-	0x19, 0x00,
-	0x1A, 0x00,
-	0x1C, 0x00,
-	0x1D, 0x00,
-	0x1E, 0x00,
-	0x1F, 0x3A,
-	0x20, 0x2E,
-	0x21, 0x80,
-	0x22, 0xFF,
-	0x23, 0xC1,
-	0x28, 0x00,
-	0x29, 0x1E,
-	0x2A, 0x14,
-	0x2B, 0x0F,
-	0x2C, 0x09,
-	0x2D, 0x05,
-	0x31, 0x1F,
-	0x32, 0x19,
-	0x33, 0xFE,
-	0x34, 0x93
-};
-
-
-static u8 init_tab_su1278_tsa_tt [] = {
-        0x01, 0x0f,
-        0x02, 0x30,
-        0x03, 0x00,
-        0x04, 0x5b,
-        0x05, 0x85,
-        0x06, 0x02,
-        0x07, 0x00,
-        0x08, 0x02,
-        0x09, 0x00,
-        0x0C, 0x01,
-        0x0D, 0x81,
-        0x0E, 0x44,
-        0x0f, 0x14,
-        0x10, 0x3c,
-        0x11, 0x84,
-        0x12, 0xda,
-        0x13, 0x97,
-        0x14, 0x95,
-        0x15, 0xc9,
-        0x16, 0x19,
-        0x17, 0x8c,
-        0x18, 0x59,
-        0x19, 0xf8,
-        0x1a, 0xfe,
-        0x1c, 0x7f,
-        0x1d, 0x00,
-        0x1e, 0x00,
-        0x1f, 0x50,
-        0x20, 0x00,
-        0x21, 0x00,
-        0x22, 0x00,
-        0x23, 0x00,
-        0x28, 0x00,
-        0x29, 0x28,
-        0x2a, 0x14,
-        0x2b, 0x0f,
-        0x2c, 0x09,
-        0x2d, 0x09,
-        0x31, 0x1f,
-        0x32, 0x19,
-        0x33, 0xfc,
-        0x34, 0x13
-};
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "stv0299: " args); \
+	} while (0)
 
-static int stv0299_set_FEC (struct dvb_i2c_bus *i2c, fe_code_rate_t fec);
-static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate, int tuner_type);
 
-static int stv0299_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
+static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
 {
 	int ret;
 	u8 buf [] = { reg, data };
-	struct i2c_msg msg = { .addr = 0x68, .flags = 0, .buf = buf, .len = 2 };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
 
-	ret = i2c->xfer (i2c, &msg, 1);
+	ret = i2c_transfer (state->i2c, &msg, 1);
 
 	if (ret != 1) 
 		dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, "
 			"ret == %i)\n", __FUNCTION__, reg, data, ret);
 
-	return (ret != 1) ? -1 : 0;
+	return (ret != 1) ? -EREMOTEIO : 0;
 }
 
+int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data)
+{
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 
-static u8 stv0299_readreg (struct dvb_i2c_bus *i2c, u8 reg)
+	return stv0299_writeregI(state, reg, data);
+}
+
+
+static u8 stv0299_readreg (struct stv0299_state* state, u8 reg)
 {
 	int ret;
 	u8 b0 [] = { reg };
 	u8 b1 [] = { 0 };
-	struct i2c_msg msg [] = { { .addr = 0x68, .flags = 0, .buf = b0, .len = 1 },
-			   { .addr = 0x68, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
+			   { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
 
-	ret = i2c->xfer (i2c, msg, 2);
+	ret = i2c_transfer (state->i2c, msg, 2);
         
 	if (ret != 2) 
 		dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n",
@@ -301,13 +121,13 @@
 }
 
 
-static int stv0299_readregs (struct dvb_i2c_bus *i2c, u8 reg1, u8 *b, u8 len)
+static int stv0299_readregs (struct stv0299_state* state, u8 reg1, u8 *b, u8 len)
 {
         int ret;
-        struct i2c_msg msg [] = { { .addr = 0x68, .flags = 0, .buf = &reg1, .len = 1 },
-                           { .addr = 0x68, .flags = I2C_M_RD, .buf = b, .len = len } };
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = &reg1, .len = 1 },
+			   { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } };
 
-        ret = i2c->xfer (i2c, msg, 2);
+	ret = i2c_transfer (state->i2c, msg, 2);
 
         if (ret != 2)
                 dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
@@ -316,372 +136,44 @@
 }
 
 
-static int pll_write (struct dvb_i2c_bus *i2c, u8 addr, u8 *data, int len)
-{
-	int ret;
-	struct i2c_msg msg = { .addr = addr, .buf = data, .len = len };
-
-
-	stv0299_writereg(i2c, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */
-
-	ret =  i2c->xfer (i2c, &msg, 1);
-
-	stv0299_writereg(i2c, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */
-
-	if (ret != 1)
-		dprintk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
-
-	return (ret != 1) ? -1 : 0;
-}
-
-
-static int sl1935_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype)
-{
-	u8 buf[4];
-	u32 div;
-
-	div = freq / 125;
-
-	dprintk("%s : freq = %i, div = %i\n", __FUNCTION__, freq, div);
-
-	buf[0] = (div >> 8) & 0x7f;
-	buf[1] = div & 0xff;
-	buf[2] = 0x84;	// 0xC4
-	buf[3] = 0x08;
-
-	if (freq < 1500000) buf[3] |= 0x10;
-
-	return pll_write (i2c, 0x61, buf, sizeof(buf));
-}
-
-/**
- *   set up the downconverter frequency divisor for a 
- *   reference clock comparision frequency of 125 kHz.
- */
-static int tsa5059_set_tv_freq	(struct dvb_i2c_bus *i2c, u32 freq, int ftype, int srate)
-{
-	u8 addr;
-	u32 div;
-	u8 buf[4];
-	int divisor, regcode;
-
-	dprintk ("%s: freq %i, ftype %i\n", __FUNCTION__, freq, ftype);
-
-	if ((freq < 950000) || (freq > 2150000)) return -EINVAL;
-
-	if (ftype == PHILIPS_SU1278_TSA_TT) {
-        divisor = 500;
-        regcode = 2;
-	} else {
-		divisor = 125;
-		regcode = 4;
-	}
-
-	// setup frequency divisor
-	div = (freq + (divisor - 1)) / divisor; // round correctly
-	buf[0] = (div >> 8) & 0x7f;
-	buf[1] = div & 0xff;
-	buf[2] = 0x80 | ((div & 0x18000) >> 10) | regcode;
-	buf[3] = 0;
-
-	// tuner-specific settings
-	switch(ftype) {
-	case PHILIPS_SU1278_TSA:
-	case PHILIPS_SU1278_TSA_TT:
-	case PHILIPS_SU1278_TSA_TY:
-		if (ftype == PHILIPS_SU1278_TSA_TY)
-			addr = 0x61;
-		else
-		addr = 0x60;
-
-		buf[3] |= 0x20;
-
-		if (srate < 4000000) buf[3] |= 1;
-	   
-		if (freq < 1250000) buf[3] |= 0;
-		else if (freq < 1550000) buf[3] |= 0x40;
-		else if (freq < 2050000) buf[3] |= 0x80;
-		else if (freq < 2150000) buf[3] |= 0xC0;
-		break;
-
-	case ALPS_BSRU6:
-		addr = 0x61;
-		buf[3] = 0xC4;
-		if (freq > 1530000) buf[3] = 0xc0;
-	 	break;
-
-	default:
-		return -EINVAL;
-	}
-
-	return pll_write (i2c, addr, buf, sizeof(buf));
-}
-
-
-#define MIN2(a,b) ((a) < (b) ? (a) : (b))
-#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
-
-static int tua6100_set_tv_freq	(struct dvb_i2c_bus *i2c, u32 freq,
-			 int ftype, int srate)
-{
-	u8 reg0 [2] = { 0x00, 0x00 };
-	u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 };
-	u8 reg2 [3] = { 0x02, 0x00, 0x00 };
-	int _fband;
-	int first_ZF;
-	int R, A, N, P, M;
-	int err;
-
-	first_ZF = (freq) / 1000;
-
-	if (abs(MIN2(abs(first_ZF-1190),abs(first_ZF-1790))) <
-	    abs(MIN3(abs(first_ZF-1202),abs(first_ZF-1542),abs(first_ZF-1890))))
-		_fband = 2;
-	else
-		_fband = 3;
-
-	if (_fband == 2) {
-		if (((first_ZF >= 950) && (first_ZF < 1350)) ||
-		    ((first_ZF >= 1430) && (first_ZF < 1950)))
-			reg0[1] = 0x07;
-		else if (((first_ZF >= 1350) && (first_ZF < 1430)) ||
-			    ((first_ZF >= 1950) && (first_ZF < 2150)))
-			reg0[1] = 0x0B;
-	}
-
-	if(_fband == 3) {
-		if (((first_ZF >= 950) && (first_ZF < 1350)) ||
-		     ((first_ZF >= 1455) && (first_ZF < 1950)))
-			reg0[1] = 0x07;
-		else if (((first_ZF >= 1350) && (first_ZF < 1420)) ||
-			 ((first_ZF >= 1950) && (first_ZF < 2150)))
-			reg0[1] = 0x0B;
-		else if ((first_ZF >= 1420) && (first_ZF < 1455))
-			reg0[1] = 0x0F;
-}
-
-	if (first_ZF > 1525)
-		reg1[1] |= 0x80;
-	else
-		reg1[1] &= 0x7F;
-
-	if (_fband == 2) {
-	        if (first_ZF > 1430) { /* 1430MHZ */
-	                reg1[1] &= 0xCF; /* N2 */
-			reg2[1] &= 0xCF; /* R2 */
-			reg2[1] |= 0x10;
-	        } else {
-        		reg1[1] &= 0xCF; /* N2 */
-			reg1[1] |= 0x20;
-			reg2[1] &= 0xCF; /* R2 */
-			reg2[1] |= 0x10;
-		}
-}
-
-	if (_fband == 3) {
-        	if ((first_ZF >= 1455) &&
-		    (first_ZF < 1630)) {
-			reg1[1] &= 0xCF; /* N2 */
-			reg1[1] |= 0x20;
-			reg2[1] &= 0xCF; /* R2 */
-	        } else {
-			if (first_ZF < 1455) {
-	                        reg1[1] &= 0xCF; /* N2 */
-				reg1[1] |= 0x20;
-                	        reg2[1] &= 0xCF; /* R2 */
-                        	reg2[1] |= 0x10;
-	                } else {
-	                        if (first_ZF >= 1630) {
-        	                        reg1[1] &= 0xCF; /* N2 */
-                        	        reg2[1] &= 0xCF; /* R2 */
-                                	reg2[1] |= 0x10;
-	                        }
-        	        }
-	        }
-	}
-
-        /* set ports, enable P0 for symbol rates > 4Ms/s */
-	if (srate >= 4000000)
-		reg1[1] |= 0x0c;
-	else
-		reg1[1] |= 0x04;
-
-	reg2[1] |= 0x0c;
-
-	R = 64;
-	A = 64;
-	P = 64;  //32
-
-	M = (freq * R) / 4;		/* in Mhz */
-	N = (M - A * 1000) / (P * 1000);
-
-	reg1[1] |= (N >> 9) & 0x03;
-	reg1[2]  = (N >> 1) & 0xff;
-	reg1[3]  = (N << 7) & 0x80;
-
-	reg2[1] |= (R >> 8) & 0x03;
-	reg2[2]  = R & 0xFF;	/* R */
-
-	reg1[3] |= A & 0x7f;	/* A */
-
-	if (P == 64)
-		reg1[1] |= 0x40; /* Prescaler 64/65 */
-
-	reg0[1] |= 0x03;
-
-	if ((err = pll_write(i2c, 0x60, reg0, sizeof(reg0))))
-		return err;
-
-	if ((err = pll_write(i2c, 0x60, reg1, sizeof(reg1))))
-		return err;
-
-	if ((err = pll_write(i2c, 0x60, reg2, sizeof(reg2))))
-		return err;
-
-	return 0;
-}
-
-
-static int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, int srate)
-{
-	switch(ftype) {
-	case SAMSUNG_TBMU24112IMB:
-		return sl1935_set_tv_freq(i2c, freq, ftype);
-
-	case LG_TDQF_S001F:
-		return sl1935_set_tv_freq(i2c, freq, ftype);
-
-	case PHILIPS_SU1278_TUA:
-		return tua6100_set_tv_freq(i2c, freq, ftype, srate);
-
-	default:
-		return tsa5059_set_tv_freq(i2c, freq, ftype, srate);
-}
-}
-
-#if 0
-static int tsa5059_read_status	(struct dvb_i2c_bus *i2c)
-{
-	int ret;
-	u8 rpt1 [] = { 0x05, 0xb5 };
-	u8 stat [] = { 0 };
-
-	struct i2c_msg msg [] = {{ .addr = 0x68, .flags = 0, .buf = rpt1, .len = 2 },
-			  { .addr = 0x60, .flags = I2C_M_RD, .buf = stat, .len = 1 }};
-
-	dprintk ("%s\n", __FUNCTION__);
-
-	ret = i2c->xfer (i2c, msg, 2);
-
-	if (ret != 2)
-		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
-
-	return stat[0];
-}
-#endif
-
-
-static int stv0299_init (struct dvb_i2c_bus *i2c, int ftype)
-{
-	int i;
-
-	dprintk("stv0299: init chip\n");
-
-	switch(ftype) {
-	case SAMSUNG_TBMU24112IMB:
-		dprintk("%s: init stv0299 chip for Samsung TBMU24112IMB\n", __FUNCTION__);
-
-		for (i=0; i<sizeof(init_tab_samsung); i+=2)
-		{
-			dprintk("%s: reg == 0x%02x, val == 0x%02x\n", __FUNCTION__, init_tab_samsung[i], init_tab_samsung[i+1]);
-
-			stv0299_writereg (i2c, init_tab_samsung[i], init_tab_samsung[i+1]);
-		}
-		break;
-
-	case PHILIPS_SU1278_TSA_TT:
-	        for (i=0; i<sizeof(init_tab_su1278_tsa_tt); i+=2) {
-			stv0299_writereg (i2c, init_tab_su1278_tsa_tt[i], init_tab_su1278_tsa_tt[i+1]);
-		}
-	        break;
-
-	default:
-	stv0299_writereg (i2c, 0x01, 0x15);
-		stv0299_writereg (i2c, 0x02, ftype == PHILIPS_SU1278_TUA ? 0x00 : 0x30);
-	stv0299_writereg (i2c, 0x03, 0x00);
-
-	for (i=0; i<sizeof(init_tab); i+=2)
-		stv0299_writereg (i2c, init_tab[i], init_tab[i+1]);
-
-        /* AGC1 reference register setup */
-		if (ftype == PHILIPS_SU1278_TSA || ftype == PHILIPS_SU1278_TSA_TY)
-		  stv0299_writereg (i2c, 0x0f, 0x92);  /* Iagc = Inverse, m1 = 18 */
-		else if (ftype == PHILIPS_SU1278_TUA)
-		  stv0299_writereg (i2c, 0x0f, 0x94);  /* Iagc = Inverse, m1 = 20 */
-	else
-	  stv0299_writereg (i2c, 0x0f, 0x52);  /* Iagc = Normal,  m1 = 18 */
-		break;
-	}
-	
-	switch(stv0299_status) {
-	case STATUS_BER:
-		stv0299_writereg(i2c, 0x34, 0x93);
-		break;
-	
-	case STATUS_UCBLOCKS:
-		stv0299_writereg(i2c, 0x34, 0xB3);
-		break;
-	}
-
-	return 0;
-}
-
-
-static int stv0299_set_FEC (struct dvb_i2c_bus *i2c, fe_code_rate_t fec)
+static int stv0299_set_FEC (struct stv0299_state* state, fe_code_rate_t fec)
 {
 	dprintk ("%s\n", __FUNCTION__);
 
 	switch (fec) {
 	case FEC_AUTO:
 	{
-		dprintk ("%s : FEC_AUTO\n", __FUNCTION__);
-		return stv0299_writereg (i2c, 0x31, 0x1f);
+		return stv0299_writeregI (state, 0x31, 0x1f);
 	}
 	case FEC_1_2:
 	{
-		dprintk ("%s : FEC_1_2\n", __FUNCTION__);
-		return stv0299_writereg (i2c, 0x31, 0x01);
+		return stv0299_writeregI (state, 0x31, 0x01);
 	}
 	case FEC_2_3:
 	{
-		dprintk ("%s : FEC_2_3\n", __FUNCTION__);
-		return stv0299_writereg (i2c, 0x31, 0x02);
+		return stv0299_writeregI (state, 0x31, 0x02);
 	}
 	case FEC_3_4:
 	{
-		dprintk ("%s : FEC_3_4\n", __FUNCTION__);
-		return stv0299_writereg (i2c, 0x31, 0x04);
+		return stv0299_writeregI (state, 0x31, 0x04);
 	}
 	case FEC_5_6:
 	{
-		dprintk ("%s : FEC_5_6\n", __FUNCTION__);
-		return stv0299_writereg (i2c, 0x31, 0x08);
+		return stv0299_writeregI (state, 0x31, 0x08);
 	}
 	case FEC_7_8:
 	{
-		dprintk ("%s : FEC_7_8\n", __FUNCTION__);
-		return stv0299_writereg (i2c, 0x31, 0x10);
+		return stv0299_writeregI (state, 0x31, 0x10);
 	}
 	default:
 	{
-		dprintk ("%s : FEC invalid\n", __FUNCTION__);
 		return -EINVAL;
 	}
 }
 }
 
 
-static fe_code_rate_t stv0299_get_fec (struct dvb_i2c_bus *i2c)
+static fe_code_rate_t stv0299_get_fec (struct stv0299_state* state)
 {
 	static fe_code_rate_t fec_tab [] = { FEC_2_3, FEC_3_4, FEC_5_6,
 					     FEC_7_8, FEC_1_2 };
@@ -689,7 +181,7 @@
 
 	dprintk ("%s\n", __FUNCTION__);
 
-	index = stv0299_readreg (i2c, 0x1b);
+	index = stv0299_readreg (state, 0x1b);
 	index &= 0x7;
 
 	if (index > 4)
@@ -699,136 +191,191 @@
 }
 
 
-static int stv0299_wait_diseqc_fifo (struct dvb_i2c_bus *i2c, int timeout)
+static int stv0299_wait_diseqc_fifo (struct stv0299_state* state, int timeout)
 {
 	unsigned long start = jiffies;
 
 	dprintk ("%s\n", __FUNCTION__);
 
-	while (stv0299_readreg(i2c, 0x0a) & 1) {
+	while (stv0299_readreg(state, 0x0a) & 1) {
 		if (jiffies - start > timeout) {
 			dprintk ("%s: timeout!!\n", __FUNCTION__);
 			return -ETIMEDOUT;
 		}
-		dvb_delay(10);
+		msleep(10);
 	};
 
 	return 0;
 }
 
 
-static int stv0299_wait_diseqc_idle (struct dvb_i2c_bus *i2c, int timeout)
+static int stv0299_wait_diseqc_idle (struct stv0299_state* state, int timeout)
 {
 	unsigned long start = jiffies;
 
 	dprintk ("%s\n", __FUNCTION__);
 
-	while ((stv0299_readreg(i2c, 0x0a) & 3) != 2 ) {
+	while ((stv0299_readreg(state, 0x0a) & 3) != 2 ) {
 		if (jiffies - start > timeout) {
 			dprintk ("%s: timeout!!\n", __FUNCTION__);
 			return -ETIMEDOUT;
 		}
-		dvb_delay(10);
+		msleep(10);
 	};
 
 	return 0;
 }
 
+static int stv0299_set_symbolrate (struct dvb_frontend* fe, u32 srate)
+{
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
+	u64 big = srate;
+	u32 ratio;
+
+	// check rate is within limits
+	if ((srate < 1000000) || (srate > 45000000)) return -EINVAL;
+
+	// calculate value to program
+	big = big << 20;
+	big += (state->config->mclk-1); // round correctly
+	do_div(big, state->config->mclk);
+	ratio = big << 4;
+
+	return state->config->set_symbol_rate(fe, srate, ratio);
+}
+
+
+static int stv0299_get_symbolrate (struct stv0299_state* state)
+{
+	u32 Mclk = state->config->mclk / 4096L;
+	u32 srate;
+	s32 offset;
+	u8 sfr[3];
+	s8 rtf;
+
+	dprintk ("%s\n", __FUNCTION__);
+
+	stv0299_readregs (state, 0x1f, sfr, 3);
+	stv0299_readregs (state, 0x1a, &rtf, 1);
+
+	srate = (sfr[0] << 8) | sfr[1];
+	srate *= Mclk;
+	srate /= 16;
+	srate += (sfr[2] >> 4) * Mclk / 256;
+	offset = (s32) rtf * (srate / 4096L);
+	offset /= 128;
+
+	dprintk ("%s : srate = %i\n", __FUNCTION__, srate);
+	dprintk ("%s : ofset = %i\n", __FUNCTION__, offset);
+
+	srate += offset;
+
+	srate += 1000;
+	srate /= 2000;
+	srate *= 2000;
+
+	return srate;
+}
+
+
+
 
-static int stv0299_send_diseqc_msg (struct dvb_i2c_bus *i2c,
+
+
+
+
+
+
+
+
+
+
+static int stv0299_send_diseqc_msg (struct dvb_frontend* fe,
 			     struct dvb_diseqc_master_cmd *m)
 {
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 	u8 val;
 	int i;
 
 	dprintk ("%s\n", __FUNCTION__);
 
-	if (stv0299_wait_diseqc_idle (i2c, 100) < 0)
+	if (stv0299_wait_diseqc_idle (state, 100) < 0)
 		return -ETIMEDOUT;
 
-	val = stv0299_readreg (i2c, 0x08);
+	val = stv0299_readreg (state, 0x08);
 
-	if (stv0299_writereg (i2c, 0x08, (val & ~0x7) | 0x6))  /* DiSEqC mode */
+	if (stv0299_writeregI (state, 0x08, (val & ~0x7) | 0x6))  /* DiSEqC mode */
 		return -EREMOTEIO;
 
 	for (i=0; i<m->msg_len; i++) {
-		if (stv0299_wait_diseqc_fifo (i2c, 100) < 0)
+		if (stv0299_wait_diseqc_fifo (state, 100) < 0)
 			return -ETIMEDOUT;
 
-		if (stv0299_writereg (i2c, 0x09, m->msg[i]))
+		if (stv0299_writeregI (state, 0x09, m->msg[i]))
 			return -EREMOTEIO;
 	}
 
-	if (stv0299_wait_diseqc_idle (i2c, 100) < 0)
+	if (stv0299_wait_diseqc_idle (state, 100) < 0)
 		return -ETIMEDOUT;
 
 	return 0;
 }
 
 
-static int stv0299_send_diseqc_burst (struct dvb_i2c_bus *i2c, fe_sec_mini_cmd_t burst)
+static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
 {
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 	u8 val;
 
 	dprintk ("%s\n", __FUNCTION__);
 
-	if (stv0299_wait_diseqc_idle (i2c, 100) < 0)
+	if (stv0299_wait_diseqc_idle (state, 100) < 0)
 		return -ETIMEDOUT;
 
-	val = stv0299_readreg (i2c, 0x08);
+	val = stv0299_readreg (state, 0x08);
 
-	if (stv0299_writereg (i2c, 0x08, (val & ~0x7) | 0x2))   /* burst mode */
+	if (stv0299_writeregI (state, 0x08, (val & ~0x7) | 0x2))	/* burst mode */
 		return -EREMOTEIO;
 
-	if (stv0299_writereg (i2c, 0x09, burst == SEC_MINI_A ? 0x00 : 0xff))
+	if (stv0299_writeregI (state, 0x09, burst == SEC_MINI_A ? 0x00 : 0xff))
 		return -EREMOTEIO;
 
-	if (stv0299_wait_diseqc_idle (i2c, 100) < 0)
+	if (stv0299_wait_diseqc_idle (state, 100) < 0)
 		return -ETIMEDOUT;
 
-	if (stv0299_writereg (i2c, 0x08, val))
+	if (stv0299_writeregI (state, 0x08, val))
 		return -EREMOTEIO;
 
 	return 0;
 }
 
 
-static int stv0299_set_tone (struct dvb_i2c_bus *i2c, fe_sec_tone_mode_t tone)
+static int stv0299_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
 {
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 	u8 val;
 
-	dprintk("%s: %s\n", __FUNCTION__,
-		tone == SEC_TONE_ON ? "SEC_TONE_ON" : 
-		tone == SEC_TONE_OFF ? "SEC_TONE_OFF" : "??");
-
-	if (stv0299_wait_diseqc_idle (i2c, 100) < 0)
+	if (stv0299_wait_diseqc_idle (state, 100) < 0)
 		return -ETIMEDOUT;
 
-	val = stv0299_readreg (i2c, 0x08);
+	val = stv0299_readreg (state, 0x08);
 
 	switch (tone) {
 	case SEC_TONE_ON:
-	{
-	    	dprintk("%s: TONE_ON\n", __FUNCTION__);
-		return stv0299_writereg (i2c, 0x08, val | 0x3);
-	}	
+		return stv0299_writeregI (state, 0x08, val | 0x3);
+
 	case SEC_TONE_OFF:
-	{
-	    	dprintk("%s: TONE_OFF\n", __FUNCTION__);
-		return stv0299_writereg (i2c, 0x08, (val & ~0x3) | 0x02);
-	}
+		return stv0299_writeregI (state, 0x08, (val & ~0x3) | 0x02);
+
 	default:
-	{
-	    	dprintk("%s: TONE INVALID\n", __FUNCTION__);
 		return -EINVAL;
 	}
-	};
 }
 
 
-static int stv0299_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage,
-				int tuner_type)
+static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
 {
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 	u8 reg0x08;
 	u8 reg0x0c;
 
@@ -836,8 +383,8 @@
 		voltage == SEC_VOLTAGE_13 ? "SEC_VOLTAGE_13" : 
 		voltage == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" : "??");
 
-	reg0x08 = stv0299_readreg (i2c, 0x08);
-	reg0x0c = stv0299_readreg (i2c, 0x0c);
+	reg0x08 = stv0299_readreg (state, 0x08);
+	reg0x0c = stv0299_readreg (state, 0x0c);
 
 	/**
 	 *  H/V switching over OP0, OP1 and OP2 are LNB power enable bits
@@ -845,181 +392,91 @@
 	reg0x0c &= 0x0f;
 
 	if (voltage == SEC_VOLTAGE_OFF) {
-		stv0299_writereg (i2c, 0x0c, 0x00); /*	LNB power off! */
-		return stv0299_writereg (i2c, 0x08, 0x00); /*	LNB power off! */
+		stv0299_writeregI (state, 0x0c, 0x00); /*	LNB power off! */
+		return stv0299_writeregI (state, 0x08, 0x00); /*	LNB power off! */
 	}
 	
-		stv0299_writereg (i2c, 0x08, reg0x08 | 0x40);
+	stv0299_writeregI (state, 0x08, (reg0x08 & 0x3f) | (state->config->lock_output << 6));
 
 	switch (voltage) {
 	case SEC_VOLTAGE_13:
-		if (tuner_type == PHILIPS_SU1278_TSA_TY)
-			return stv0299_writereg (i2c, 0x0c, reg0x0c | 0x10);
-		else
-			return stv0299_writereg (i2c, 0x0c, reg0x0c | 0x40);
+		if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0) reg0x0c |= 0x10;
+		else reg0x0c |= 0x40;
 
-	case SEC_VOLTAGE_18:
-		return stv0299_writereg (i2c, 0x0c, reg0x0c | 0x50);
+		return stv0299_writeregI(state, 0x0c, reg0x0c);
 
+	case SEC_VOLTAGE_18:
+		return stv0299_writeregI(state, 0x0c, reg0x0c | 0x50);
 	default:
 		return -EINVAL;
 	};
 }
 
 
-static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate, int tuner_type)
+static int stv0299_send_legacy_dish_cmd(struct dvb_frontend* fe, u32 cmd)
 {
-	u64 big = srate;
-	u32 ratio;
-	u8 aclk = 0;
-	u8 bclk = 0;
-	u8 m1;
-        int Mclk = M_CLK;
+	u8 last = 1;
+	int i;
 
-        // check rate is within limits
-	if ((srate < 1000000) || (srate > 45000000)) return -EINVAL;
+	/* reset voltage at the end
+	if((0x50 & stv0299_readreg (i2c, 0x0c)) == 0x50)
+		cmd |= 0x80;
+	else
+		cmd &= 0x7F;
+	*/
+
+	cmd = cmd << 1;
+	dprintk("%s switch command: 0x%04x\n",__FUNCTION__, cmd);
+
+	stv0299_set_voltage(fe,SEC_VOLTAGE_18);
+	msleep(32);
 
-        // calculate value to program
-	if (tuner_type == PHILIPS_SU1278_TSA_TT) Mclk = M_CLK_SU1278_TSA_TT;
-        big = big << 20;
-	big += (Mclk-1); // round correctly
-        do_div(big, Mclk);
-        ratio = big << 4;
-
-        // program registers
-	switch(tuner_type) {
-	case PHILIPS_SU1278_TSA_TT:
-	        stv0299_writereg (i2c, 0x0e, 0x44);
-	        if (srate >= 10000000) {
-		        stv0299_writereg (i2c, 0x13, 0x97);
-		        stv0299_writereg (i2c, 0x14, 0x95);
-		        stv0299_writereg (i2c, 0x15, 0xc9);
-		        stv0299_writereg (i2c, 0x17, 0x8c);
-		        stv0299_writereg (i2c, 0x1a, 0xfe);
-		        stv0299_writereg (i2c, 0x1c, 0x7f);
-		        stv0299_writereg (i2c, 0x2d, 0x09);
-		} else {
-		        stv0299_writereg (i2c, 0x13, 0x99);
-		        stv0299_writereg (i2c, 0x14, 0x8d);
-		        stv0299_writereg (i2c, 0x15, 0xce);
-		        stv0299_writereg (i2c, 0x17, 0x43);
-		        stv0299_writereg (i2c, 0x1a, 0x1d);
-		        stv0299_writereg (i2c, 0x1c, 0x12);
-		        stv0299_writereg (i2c, 0x2d, 0x05);
+	for (i=0; i<9; i++) {
+		if((cmd & 0x01) != last) {
+			stv0299_set_voltage(fe,
+					    last ? SEC_VOLTAGE_13 :
+					    	   SEC_VOLTAGE_18);
+			last = (last) ? 0 : 1;
 		}
-	        stv0299_writereg (i2c, 0x0e, 0x23);
-	        stv0299_writereg (i2c, 0x0f, 0x94);
-	        stv0299_writereg (i2c, 0x10, 0x39);
-	        stv0299_writereg (i2c, 0x15, 0xc9);
-
-	        stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
-	        stv0299_writereg (i2c, 0x20, (ratio >>  8) & 0xff);
-	        stv0299_writereg (i2c, 0x21, (ratio      ) & 0xf0);
-	        break;
-
-	case PHILIPS_SU1278_TSA_TY:
-	case PHILIPS_SU1278_TSA:
-		aclk = 0xb5;
-		if (srate < 2000000) bclk = 0x86;
-		else if (srate < 5000000) bclk = 0x89;
-		else if (srate < 15000000) bclk = 0x8f;
-		else if (srate < 45000000) bclk = 0x95;
-
-		m1 = 0x14;
-		if (srate < 4000000) m1 = 0x10;
-
-	    	stv0299_writereg (i2c, 0x13, aclk);
-  	        stv0299_writereg (i2c, 0x14, bclk);
-	        stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
-	        stv0299_writereg (i2c, 0x20, (ratio >>  8) & 0xff);
-	        stv0299_writereg (i2c, 0x21, (ratio      ) & 0xf0);
-	        stv0299_writereg (i2c, 0x0f, (stv0299_readreg(i2c, 0x0f) & 0xc0) | m1);
-		break;
 
-	case ALPS_BSRU6:
-	default:
-		if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
-		else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
-		else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
-		else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
-		else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
-		else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
-  
-	stv0299_writereg (i2c, 0x13, aclk);
-	stv0299_writereg (i2c, 0x14, bclk);
-	stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
-	stv0299_writereg (i2c, 0x20, (ratio >>  8) & 0xff);
-	stv0299_writereg (i2c, 0x21, (ratio      ) & 0xf0);
-		break;
-	}
+		cmd = cmd >> 1;
 
+		if (i != 8)
+			msleep(8);
+	}
 
 	return 0;
 }
 
 
-static int stv0299_get_symbolrate (struct dvb_i2c_bus *i2c, int tuner_type)
+static int stv0299_init (struct dvb_frontend* fe)
 {
-	u32 Mclk = M_CLK / 4096L;
-	u32 srate;
-	s32 offset;
-	u8 sfr[3];
-	s8 rtf;
-
-	dprintk ("%s\n", __FUNCTION__);
-
-    	if (tuner_type == PHILIPS_SU1278_TSA_TT) Mclk = M_CLK_SU1278_TSA_TT / 4096L;
-
-	stv0299_readregs (i2c, 0x1f, sfr, 3);
-	stv0299_readregs (i2c, 0x1a, &rtf, 1);
-
-	srate = (sfr[0] << 8) | sfr[1];
-	srate *= Mclk;
-	srate /= 16;
-	srate += (sfr[2] >> 4) * Mclk / 256;
-
-	offset = (s32) rtf * (srate / 4096L);
-	offset /= 128;
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
+	int i;
 
-	dprintk ("%s : srate = %i\n", __FUNCTION__, srate);
-	dprintk ("%s : ofset = %i\n", __FUNCTION__, offset);
+	dprintk("stv0299: init chip\n");
 
-	srate += offset;
+	for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2)
+		stv0299_writeregI(state, state->config->inittab[i], state->config->inittab[i+1]);
 
-	srate += 1000;
-	srate /= 2000;
-	srate *= 2000;
+	if (state->config->pll_init) {
+		stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */
+		state->config->pll_init(fe);
+		stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */
+	}
 
-	return srate;
+	return 0;
 }
 
-static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-	struct dvb_i2c_bus *i2c = fe->i2c;
-	struct stv0299_state *state = (struct stv0299_state *) fe->data;
-
-	dprintk ("%s\n", __FUNCTION__);
 
-	switch (cmd) {
-	case FE_GET_INFO:
+static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status)
 	{
-	        struct dvb_frontend_info* tmp = (struct dvb_frontend_info*) arg;
-		memcpy (arg, &uni0299_info, sizeof(struct dvb_frontend_info));
-
-		if (state->tuner_type == PHILIPS_SU1278_TSA_TT) {
-		        tmp->frequency_tolerance = M_CLK_SU1278_TSA_TT / 2000;
-		}
-		break;
-	}
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 
-	case FE_READ_STATUS:
-	{
-		fe_status_t *status = (fe_status_t *) arg;
-		u8 signal = 0xff - stv0299_readreg (i2c, 0x18);
-		u8 sync = stv0299_readreg (i2c, 0x1b);
+	u8 signal = 0xff - stv0299_readreg (state, 0x18);
+	u8 sync = stv0299_readreg (state, 0x1b);
 
 		dprintk ("%s : FE_READ_STATUS : VSTATUS: 0x%02x\n", __FUNCTION__, sync);
-
 		*status = 0;
 
 		if (signal > 10)
@@ -1037,53 +494,61 @@
 		if ((sync & 0x98) == 0x98)
 			*status |= FE_HAS_LOCK;
 
-		break;
+	return 0;
 	}
 
-        case FE_READ_BER:
-		if (stv0299_status == STATUS_BER) {
-		*((u32*) arg) = (stv0299_readreg (i2c, 0x1d) << 8)
-			       | stv0299_readreg (i2c, 0x1e);
-		} else {
-			*((u32*) arg) = 0;
+static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber)
+{
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
+
+	if (state->errmode != STATUS_BER) return 0;
+	*ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
+
+	return 0;
 		}
-		break;
 
-	case FE_READ_SIGNAL_STRENGTH:
+static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 	{
-		s32 signal =  0xffff - ((stv0299_readreg (i2c, 0x18) << 8)
-			               | stv0299_readreg (i2c, 0x19));
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
+
+	s32 signal =  0xffff - ((stv0299_readreg (state, 0x18) << 8)
+			       | stv0299_readreg (state, 0x19));
 
 		dprintk ("%s : FE_READ_SIGNAL_STRENGTH : AGC2I: 0x%02x%02x, signal=0x%04x\n", __FUNCTION__,
-			 stv0299_readreg (i2c, 0x18),
-			 stv0299_readreg (i2c, 0x19), (int) signal);
+		 stv0299_readreg (state, 0x18),
+		 stv0299_readreg (state, 0x19), (int) signal);
 
 		signal = signal * 5 / 4;
-		*((u16*) arg) = (signal > 0xffff) ? 0xffff :
-				(signal < 0) ? 0 : signal;
-		break;
-	}
-        case FE_READ_SNR:
-	{
-		s32 snr = 0xffff - ((stv0299_readreg (i2c, 0x24) << 8)
-			           | stv0299_readreg (i2c, 0x25));
-		snr = 3 * (snr - 0xa100);
-		*((u16*) arg) = (snr > 0xffff) ? 0xffff :
-				(snr < 0) ? 0 : snr;
-		break;
-	}
-	case FE_READ_UNCORRECTED_BLOCKS: 
-		if (stv0299_status == STATUS_UCBLOCKS) {
-			*((u32*) arg) = (stv0299_readreg (i2c, 0x1d) << 8)
-			               | stv0299_readreg (i2c, 0x1e);
-		} else {
-			*((u32*) arg) = 0;
+	*strength = (signal > 0xffff) ? 0xffff : (signal < 0) ? 0 : signal;
+
+	return 0;
 		}
-		break;
 
-        case FE_SET_FRONTEND:
+static int stv0299_read_snr(struct dvb_frontend* fe, u16* snr)
         {
-		struct dvb_frontend_parameters *p = arg;
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
+
+	s32 xsnr = 0xffff - ((stv0299_readreg (state, 0x24) << 8)
+			   | stv0299_readreg (state, 0x25));
+	xsnr = 3 * (xsnr - 0xa100);
+	*snr = (xsnr > 0xffff) ? 0xffff : (xsnr < 0) ? 0 : xsnr;
+
+	return 0;
+}
+
+static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
+
+	if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0;
+	else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
+
+	return 0;
+}
+
+static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
+{
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 		int invval = 0;
 
 		dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__);
@@ -1095,12 +560,10 @@
 			printk("stv0299 does not support auto-inversion\n");
 			return -EINVAL;
 		}
-		if (state->tuner_type == ALPS_BSRU6) invval = (~invval) & 1;
-		stv0299_writereg(i2c, 0x0c, (stv0299_readreg(i2c, 0x0c) & 0xfe) | invval);
+	if (state->config->invert) invval = (~invval) & 1;
+	stv0299_writeregI(state, 0x0c, (stv0299_readreg(state, 0x0c) & 0xfe) | invval);
 
-		switch(state->tuner_type) {
-		case PHILIPS_SU1278_TSA_TT: 
-		{
+	if (state->config->enhanced_tuning) {
 			/* check if we should do a finetune */
 			int frequency_delta = p->frequency - state->tuner_frequency;
 			int minmax = p->u.qpsk.symbol_rate / 2000;
@@ -1109,125 +572,88 @@
 			if ((frequency_delta > -minmax) && (frequency_delta < minmax) && (frequency_delta != 0) &&
 			    (state->fec_inner == p->u.qpsk.fec_inner) && 
 			    (state->symbol_rate == p->u.qpsk.symbol_rate)) {
-				int Drot_freq = (frequency_delta << 16) / (M_CLK_SU1278_TSA_TT / 1000);
+			int Drot_freq = (frequency_delta << 16) / (state->config->mclk / 1000);
 
 				// zap the derotator registers first
-				stv0299_writereg (i2c, 0x22, 0x00); 
-				stv0299_writereg (i2c, 0x23, 0x00);
+			stv0299_writeregI(state, 0x22, 0x00);
+			stv0299_writeregI(state, 0x23, 0x00);
 
 				// now set them as we want
-				stv0299_writereg (i2c, 0x22, Drot_freq >> 8);
-				stv0299_writereg (i2c, 0x23, Drot_freq);
+			stv0299_writeregI(state, 0x22, Drot_freq >> 8);
+			stv0299_writeregI(state, 0x23, Drot_freq);
 			} else {
 				/* A "normal" tune is requested */
-				pll_set_tv_freq (i2c, p->frequency, state->tuner_type, p->u.qpsk.symbol_rate);
-				stv0299_writereg (i2c, 0x32, 0x80);
-				stv0299_writereg (i2c, 0x22, 0x00);
-				stv0299_writereg (i2c, 0x23, 0x00);
-				stv0299_writereg (i2c, 0x32, 0x19);
-				stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate, state->tuner_type);
-                stv0299_set_FEC (i2c, p->u.qpsk.fec_inner);
-			}
-			break;
+			stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */
+			state->config->pll_set(fe, p);
+			stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */
+
+			stv0299_writeregI(state, 0x32, 0x80);
+			stv0299_writeregI(state, 0x22, 0x00);
+			stv0299_writeregI(state, 0x23, 0x00);
+			stv0299_writeregI(state, 0x32, 0x19);
+			stv0299_set_symbolrate (fe, p->u.qpsk.symbol_rate);
+			stv0299_set_FEC (state, p->u.qpsk.fec_inner);
 		}
-		    
-		default:
-			pll_set_tv_freq (i2c, p->frequency, state->tuner_type, p->u.qpsk.symbol_rate);
-			stv0299_set_FEC (i2c, p->u.qpsk.fec_inner);
-			stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate, state->tuner_type);
-		stv0299_writereg (i2c, 0x22, 0x00);
-		stv0299_writereg (i2c, 0x23, 0x00);
-		stv0299_readreg (i2c, 0x23);
-		stv0299_writereg (i2c, 0x12, 0xb9);
-			break;
+	} else {
+		stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */
+		state->config->pll_set(fe, p);
+		stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */
+
+		stv0299_set_FEC (state, p->u.qpsk.fec_inner);
+		stv0299_set_symbolrate (fe, p->u.qpsk.symbol_rate);
+		stv0299_writeregI(state, 0x22, 0x00);
+		stv0299_writeregI(state, 0x23, 0x00);
+		stv0299_readreg (state, 0x23);
+		stv0299_writeregI(state, 0x12, 0xb9);
 		}
 
 		state->tuner_frequency = p->frequency;
 		state->fec_inner = p->u.qpsk.fec_inner;
 		state->symbol_rate = p->u.qpsk.symbol_rate;
-                break;
+
+	return 0;
         }
 
-        case FE_GET_FRONTEND:
+static int stv0299_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
         {
-		struct dvb_frontend_parameters *p = arg;
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 		s32 derot_freq;
-	        int Mclk = M_CLK;
 		int invval;
 
-		if (state->tuner_type == PHILIPS_SU1278_TSA_TT) Mclk = M_CLK_SU1278_TSA_TT;
+	derot_freq = (s32)(s16) ((stv0299_readreg (state, 0x22) << 8)
+				| stv0299_readreg (state, 0x23));
 
-		derot_freq = (s32)(s16) ((stv0299_readreg (i2c, 0x22) << 8)
-					| stv0299_readreg (i2c, 0x23));
-
-		derot_freq *= (Mclk >> 16);
+	derot_freq *= (state->config->mclk >> 16);
 		derot_freq += 500;
 		derot_freq /= 1000;
 
 		p->frequency += derot_freq;
 
-		invval = stv0299_readreg (i2c, 0x0c) & 1;
-		if (state->tuner_type == ALPS_BSRU6) invval = (~invval) & 1;
+	invval = stv0299_readreg (state, 0x0c) & 1;
+	if (state->config->invert) invval = (~invval) & 1;
 		p->inversion = invval ? INVERSION_ON : INVERSION_OFF;
 
-		p->u.qpsk.fec_inner = stv0299_get_fec (i2c);
-		p->u.qpsk.symbol_rate = stv0299_get_symbolrate (i2c, state->tuner_type);
-                break;
-        }
-
-        case FE_SLEEP:
-		stv0299_writereg (i2c, 0x0c, 0x00);  /*  LNB power off! */
-		stv0299_writereg (i2c, 0x08, 0x00); /*  LNB power off! */
-		stv0299_writereg (i2c, 0x02, 0x80);
-		state->initialised = 0;
-		break;
-
-        case FE_INIT:
-		switch(state->tuner_type) {
-		case PHILIPS_SU1278_TSA_TT:
-			state->tuner_frequency = 0;
-			if (!state->initialised) {
-				state->initialised = 1;
-				return stv0299_init (i2c, state->tuner_type);
-			}
-			break;
+	p->u.qpsk.fec_inner = stv0299_get_fec (state);
+	p->u.qpsk.symbol_rate = stv0299_get_symbolrate (state);
 
-		default:
-			return stv0299_init (i2c, state->tuner_type);
+	return 0;
 		}
-		break;
 
-	case FE_DISEQC_SEND_MASTER_CMD:
-		return stv0299_send_diseqc_msg (i2c, arg);
-
-	case FE_DISEQC_SEND_BURST:
-		return stv0299_send_diseqc_burst (i2c, (fe_sec_mini_cmd_t) arg);
+static int stv0299_sleep(struct dvb_frontend* fe)
+{
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 
-	case FE_SET_TONE:
-		return stv0299_set_tone (i2c, (fe_sec_tone_mode_t) arg);
+	stv0299_writeregI(state, 0x02, 0x80);
+	state->initialised = 0;
 
-	case FE_SET_VOLTAGE:
-		return stv0299_set_voltage (i2c, (fe_sec_voltage_t) arg,
-					    state->tuner_type);
+	return 0;
+}
 
-	case FE_GET_TUNE_SETTINGS:
+static int stv0299_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
 	{
-		struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
-	    
-		switch(state->tuner_type) {
-		case PHILIPS_SU1278_TSA_TT:
-			fesettings->min_delay_ms = 50;
-			if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
-				fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 32000;
-				fesettings->max_drift = 5000;
-			} else {
-				fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 16000;
-				fesettings->max_drift = fesettings->parameters.u.qpsk.symbol_rate / 2000;
-			}
-			break;
+        struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
 
-		default:
-			fesettings->min_delay_ms = 100;
+	fesettings->min_delay_ms = state->config->min_delay_ms;
 			if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
 				fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 32000;
 				fesettings->max_drift = 5000;
@@ -1235,166 +661,103 @@
 				fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 16000;
 				fesettings->max_drift = fesettings->parameters.u.qpsk.symbol_rate / 2000;
 			}
-			break;		    
-		}
-
-		return 0;
-	}
-
-	default:
-		return -EOPNOTSUPP;
-	};
-
 	return 0;
 }
 
-static long probe_tuner (struct dvb_i2c_bus *i2c)
-{
-	struct dvb_adapter * adapter = (struct dvb_adapter *) i2c->adapter;
-
-        /* read the status register of TSA5059 */
-	u8 rpt[] = { 0x05, 0xb5 };
-        u8 stat [] = { 0 };
-	u8 tda6100_buf [] = { 0, 0 };
-	int ret;
-	struct i2c_msg msg1 [] = {{ .addr = 0x68, .buf = rpt,  .len = 2 },
-			   { .addr = 0x60, .flags = I2C_M_RD, .buf = stat, .len = 1 }};
-	struct i2c_msg msg2 [] = {{ .addr = 0x68, .buf = rpt,  .len = 2 },
-			   { .addr = 0x61, .flags = I2C_M_RD, .buf = stat, .len = 1 }};
-	struct i2c_msg msg3 [] = {{ .addr = 0x68, .buf = rpt,  .len = 2 },
-			   { .addr = 0x60, .buf = tda6100_buf, .len = 2 }};
-
-	stv0299_writereg (i2c, 0x01, 0x15);
-	stv0299_writereg (i2c, 0x02, 0x30);
-	stv0299_writereg (i2c, 0x03, 0x00);
-
-
-	printk ("%s: try to attach to %s\n", __FUNCTION__, adapter->name);
-
-	if ( strcmp(adapter->name, "SkyStar2") == 0 )
-	{
-	    printk ("%s: setup for tuner Samsung TBMU24112IMB\n", __FILE__);
-
-    	    return SAMSUNG_TBMU24112IMB;
-	}
-
-	if ((ret = i2c->xfer(i2c, msg1, 2)) == 2) {
-	        if ( strcmp(adapter->name, "TT-Budget/WinTV-NOVA-CI PCI") == 0 ) {
-		        // technotrend cards require non-datasheet settings
-			printk ("%s: setup for tuner SU1278 (TSA5059 synth) on"
-				" TechnoTrend hardware\n", __FILE__);
-		        return PHILIPS_SU1278_TSA_TT;
-		}  else {
-		        // fall back to datasheet-recommended settings
-			printk ("%s: setup for tuner SU1278 (TSA5059 synth)\n",
-				__FILE__);
-		        return PHILIPS_SU1278_TSA;
-		}
-		}
-
-	if ((ret = i2c->xfer(i2c, msg2, 2)) == 2) {
-		if ( strcmp(adapter->name, "KNC1 DVB-S") == 0 &&
-		     !disable_typhoon )
+static void stv0299_release(struct dvb_frontend* fe)
 		{
-			// Typhoon cards have unusual wiring.
-			printk ("%s: setup for tuner SU1278 (TSA5059 synth) on"
-				" Typhoon hardware\n", __FILE__);
-			return PHILIPS_SU1278_TSA_TY;
-		}
-		//else if ((stat[0] & 0x3f) == 0) {
-		else if (0) {
-			printk ("%s: setup for tuner TDQF-S001F\n", __FILE__);
-			return LG_TDQF_S001F;
-	} else {
-			printk ("%s: setup for tuner BSRU6, TDQB-S00x\n",
-			__FILE__);
-			return ALPS_BSRU6;
-	}
-	}
-
-	/**
-	 *  setup i2c timing for SU1278...
-	 */
-	stv0299_writereg (i2c, 0x02, 0x00);
-
-	if ((ret = i2c->xfer(i2c, msg3, 2)) == 2) {
-		printk ("%s: setup for tuner Philips SU1278 (TUA6100 synth)\n",
-			__FILE__);
-		return PHILIPS_SU1278_TUA;
-	}
-
-	printk ("%s: unknown PLL synthesizer (ret == %i), "
-		"please report to <linuxdvb@linuxtv.org>!!\n",
-		__FILE__, ret);
-
-	return UNKNOWN_FRONTEND;
+	struct stv0299_state* state = (struct stv0299_state*) fe->demodulator_priv;
+	kfree(state);
 }
 
+static struct dvb_frontend_ops stv0299_ops;
 
-static int uni0299_attach (struct dvb_i2c_bus *i2c, void **data)
+struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
+				    struct i2c_adapter* i2c)
 {
-	struct stv0299_state* state;
-	int tuner_type;
-	u8 id;
+	struct stv0299_state* state = NULL;
+	int id;
  
-	stv0299_writereg (i2c, 0x02, 0x34); /* standby off */
-	dvb_delay(200);
-	id = stv0299_readreg (i2c, 0x00);
-
-	dprintk ("%s: id == 0x%02x\n", __FUNCTION__, id);
+	/* allocate memory for the internal state */
+	state = (struct stv0299_state*) kmalloc(sizeof(struct stv0299_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &stv0299_ops, sizeof(struct dvb_frontend_ops));
+	state->initialised = 0;
+	state->tuner_frequency = 0;
+	state->symbol_rate = 0;
+	state->fec_inner = 0;
+	state->errmode = STATUS_BER;
+
+	/* check if the demod is there */
+	stv0299_writeregI(state, 0x02, 0x34); /* standby off */
+	msleep(200);
+	id = stv0299_readreg(state, 0x00);
 
 	/* register 0x00 contains 0xa1 for STV0299 and STV0299B */
 	/* register 0x00 might contain 0x80 when returning from standby */
-	if (id != 0xa1 && id != 0x80)
-		return -ENODEV;
-
-	if ((tuner_type = probe_tuner(i2c)) < 0)
-		return -ENODEV;
-
-	if ((state = kmalloc(sizeof(struct stv0299_state), GFP_KERNEL)) == NULL) {
-		return -ENOMEM;
-	}
+	if (id != 0xa1 && id != 0x80) goto error;
 
-	*data = state;
-	state->tuner_type = tuner_type;
-	state->tuner_frequency = 0;
-	state->initialised = 0;
-	return dvb_register_frontend (uni0299_ioctl, i2c, (void *) state,
-			       &uni0299_info);
-}
-
-
-static void uni0299_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	dprintk ("%s\n", __FUNCTION__);
-	kfree(data);
-	dvb_unregister_frontend (uni0299_ioctl, i2c);
-}
-
-
-static int __init init_uni0299 (void)
-{
-	dprintk ("%s\n", __FUNCTION__);
-	return dvb_register_i2c_device (NULL, uni0299_attach, uni0299_detach);
-}
-
-
-static void __exit exit_uni0299 (void)
-{
-	dprintk ("%s\n", __FUNCTION__);
-
-	dvb_unregister_i2c_device (uni0299_attach);
-}
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+        state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops stv0299_ops = {
+
+	.info = {
+		.name			= "ST STV0299 DVB-S",
+		.type			= FE_QPSK,
+		.frequency_min		= 950000,
+		.frequency_max		= 2150000,
+		.frequency_stepsize	= 125,	 /* kHz for QPSK frontends */
+		.frequency_tolerance	= 0,
+		.symbol_rate_min	= 1000000,
+		.symbol_rate_max	= 45000000,
+		.symbol_rate_tolerance	= 500,	/* ppm */
+		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+		      FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
+		      FE_CAN_QPSK |
+		      FE_CAN_FEC_AUTO
+	},
+
+	.release = stv0299_release,
+
+	.init = stv0299_init,
+	.sleep = stv0299_sleep,
+
+	.set_frontend = stv0299_set_frontend,
+	.get_frontend = stv0299_get_frontend,
+	.get_tune_settings = stv0299_get_tune_settings,
+
+	.read_status = stv0299_read_status,
+	.read_ber = stv0299_read_ber,
+	.read_signal_strength = stv0299_read_signal_strength,
+	.read_snr = stv0299_read_snr,
+	.read_ucblocks = stv0299_read_ucblocks,
+
+	.diseqc_send_master_cmd = stv0299_send_diseqc_msg,
+	.diseqc_send_burst = stv0299_send_diseqc_burst,
+	.set_tone = stv0299_set_tone,
+	.set_voltage = stv0299_set_voltage,
+	.dishnetwork_send_legacy_command = stv0299_send_legacy_dish_cmd,
+};
 
-module_init (init_uni0299);
-module_exit (exit_uni0299);
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
 
-MODULE_DESCRIPTION("Universal STV0299/TSA5059/SL1935 DVB Frontend driver");
-MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann, Felix Domke, Andreas Oberritter, Andrew de Quincey");
+MODULE_DESCRIPTION("ST STV0299 DVB Demodulator driver");
+MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann, Felix Domke, "
+              "Andreas Oberritter, Andrew de Quincey, Kenneth Aafløy");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(stv0299_status, "i");
-MODULE_PARM_DESC(stv0299_status, "Which status value to support (0: BER, 1: UCBLOCKS)");
-
-MODULE_PARM(disable_typhoon, "i");
-MODULE_PARM_DESC(disable_typhoon, "Disable support for Philips SU1278 on Typhoon hardware.");
+EXPORT_SYMBOL(stv0299_writereg);
+EXPORT_SYMBOL(stv0299_attach);
diff -Nru a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/stv0299.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,104 @@
+/*
+    Driver for ST STV0299 demodulator
+
+    Copyright (C) 2001-2002 Convergence Integrated Media GmbH
+	<ralph@convergence.de>,
+	<holger@convergence.de>,
+	<js@convergence.de>
+
+
+    Philips SU1278/SH
+
+    Copyright (C) 2002 by Peter Schildmann <peter.schildmann@web.de>
+
+
+    LG TDQF-S001F
+
+    Copyright (C) 2002 Felix Domke <tmbinc@elitedvb.net>
+		     & Andreas Oberritter <obi@linuxtv.org>
+
+
+    Support for Samsung TBMU24112IMB used on Technisat SkyStar2 rev. 2.6B
+
+    Copyright (C) 2003 Vadim Catana <skystar@moldova.cc>:
+
+    Support for Philips SU1278 on Technotrend hardware
+
+    Copyright (C) 2004 Andrew de Quincey <adq_dvb@lidskialf.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 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.
+
+*/
+
+#ifndef STV0299_H
+#define STV0299_H
+
+#include <linux/dvb/frontend.h>
+#include "dvb_frontend.h"
+
+#define STV0229_LOCKOUTPUT_0  0
+#define STV0229_LOCKOUTPUT_1  1
+#define STV0229_LOCKOUTPUT_CF 2
+#define STV0229_LOCKOUTPUT_LK 3
+
+#define STV0299_VOLT13_OP0 0
+#define STV0299_VOLT13_OP1 1
+
+struct stv0299_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* inittab - array of pairs of values.
+	 * First of each pair is the register, second is the value.
+	 * List should be terminated with an 0xff, 0xff pair.
+	 */
+	u8* inittab;
+
+	/* master clock to use */
+	u32 mclk;
+
+	/* does the inversion require inversion? */
+	u8 invert:1;
+
+	/* Should the enhanced tuning code be used? */
+	u8 enhanced_tuning:1;
+
+	/* Skip reinitialisation? */
+	u8 skip_reinit:1;
+
+	/* LOCK OUTPUT setting */
+	u8 lock_output:2;
+
+	/* Is 13v controlled by OP0 or OP1? */
+	u8 volt13_op0_op1:1;
+
+	/* minimum delay before retuning */
+	int min_delay_ms;
+
+	/* Set the symbol rate */
+	int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio);
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data);
+
+extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
+					   struct i2c_adapter* i2c);
+
+#endif // STV0299_H
diff -Nru a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/tda10021.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,483 @@
+/*
+    TDA10021  - Single Chip Cable Channel Receiver driver module
+               used on the the Siemens DVB-C cards
+
+    Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
+    Copyright (C) 2004 Markus Schulz <msc@antzsystem.de>
+                   Suppport for TDA10021
+
+    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.
+*/
+
+#include <linux/config.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+
+#include "dvb_frontend.h"
+#include "tda10021.h"
+
+
+struct tda10021_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct tda10021_config* config;
+
+	struct dvb_frontend frontend;
+
+	u8 pwm;
+	u8 reg0;
+};
+
+
+#if 0
+#define dprintk(x...) printk(x)
+#else
+#define dprintk(x...)
+#endif
+
+static int verbose;
+
+#define XIN 57840000UL
+#define DISABLE_INVERSION(reg0)		do { reg0 |= 0x20; } while (0)
+#define ENABLE_INVERSION(reg0)		do { reg0 &= ~0x20; } while (0)
+#define HAS_INVERSION(reg0)		(!(reg0 & 0x20))
+
+#define FIN (XIN >> 4)
+
+int tda10021_inittab_size = 0x40;
+static u8 tda10021_inittab[0x40]=
+{
+	0x73, 0x6a, 0x23, 0x0a, 0x02, 0x37, 0x77, 0x1a,
+	0x37, 0x6a, 0x17, 0x8a, 0x1e, 0x86, 0x43, 0x40,
+	0xb8, 0x3f, 0xa1, 0x00, 0xcd, 0x01, 0x00, 0xff,
+	0x11, 0x00, 0x7c, 0x31, 0x30, 0x20, 0x00, 0x00,
+	0x02, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00,
+	0x07, 0x00, 0x33, 0x11, 0x0d, 0x95, 0x08, 0x58,
+	0x00, 0x00, 0x80, 0x00, 0x80, 0xff, 0x00, 0x00,
+	0x04, 0x2d, 0x2f, 0xff, 0x00, 0x00, 0x00, 0x00,
+};
+
+static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
+{
+        u8 buf[] = { reg, data };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
+        int ret;
+
+	ret = i2c_transfer (state->i2c, &msg, 1);
+	if (ret != 1)
+		printk("DVB: TDA10021(%d): %s, writereg error "
+			"(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
+			state->frontend.dvb->num, __FUNCTION__, reg, data, ret);
+
+	msleep(10);
+	return (ret != 1) ? -EREMOTEIO : 0;
+}
+
+
+static u8 tda10021_readreg (struct tda10021_state* state, u8 reg)
+{
+	u8 b0 [] = { reg };
+	u8 b1 [] = { 0 };
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
+	                          { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
+	int ret;
+
+	ret = i2c_transfer (state->i2c, msg, 2);
+	if (ret != 2)
+		printk("DVB: TDA10021(%d): %s: readreg error (ret == %i)\n",
+				state->frontend.dvb->num, __FUNCTION__, ret);
+	return b1[0];
+}
+
+//get access to tuner
+static int lock_tuner(struct tda10021_state* state)
+{
+	u8 buf[2] = { 0x0f, tda10021_inittab[0x0f] | 0x80 };
+	struct i2c_msg msg = {.addr=state->config->demod_address, .flags=0, .buf=buf, .len=2};
+
+	if(i2c_transfer(state->i2c, &msg, 1) != 1)
+	{
+		printk("tda10021: lock tuner fails\n");
+		return -EREMOTEIO;
+	}
+	return 0;
+}
+
+//release access from tuner
+static int unlock_tuner(struct tda10021_state* state)
+{
+	u8 buf[2] = { 0x0f, tda10021_inittab[0x0f] & 0x7f };
+	struct i2c_msg msg_post={.addr=state->config->demod_address, .flags=0, .buf=buf, .len=2};
+
+	if(i2c_transfer(state->i2c, &msg_post, 1) != 1)
+	{
+		printk("tda10021: unlock tuner fails\n");
+		return -EREMOTEIO;
+	}
+	return 0;
+}
+
+static int tda10021_setup_reg0 (struct tda10021_state* state, u8 reg0,
+				fe_spectral_inversion_t inversion)
+{
+	reg0 |= state->reg0 & 0x63;
+
+	if (INVERSION_ON == inversion)
+		ENABLE_INVERSION(reg0);
+	else if (INVERSION_OFF == inversion)
+		DISABLE_INVERSION(reg0);
+
+	tda10021_writereg (state, 0x00, reg0 & 0xfe);
+	tda10021_writereg (state, 0x00, reg0 | 0x01);
+
+	state->reg0 = reg0;
+	return 0;
+}
+
+static int tda10021_set_symbolrate (struct tda10021_state* state, u32 symbolrate)
+{
+	s32 BDR;
+	s32 BDRI;
+	s16 SFIL=0;
+	u16 NDEC = 0;
+	u32 tmp, ratio;
+
+	if (symbolrate > XIN/2)
+		symbolrate = XIN/2;
+	if (symbolrate < 500000)
+		symbolrate = 500000;
+
+	if (symbolrate < XIN/16) NDEC = 1;
+	if (symbolrate < XIN/32) NDEC = 2;
+	if (symbolrate < XIN/64) NDEC = 3;
+
+	if (symbolrate < (u32)(XIN/12.3)) SFIL = 1;
+	if (symbolrate < (u32)(XIN/16))	 SFIL = 0;
+	if (symbolrate < (u32)(XIN/24.6)) SFIL = 1;
+	if (symbolrate < (u32)(XIN/32))	 SFIL = 0;
+	if (symbolrate < (u32)(XIN/49.2)) SFIL = 1;
+	if (symbolrate < (u32)(XIN/64))	 SFIL = 0;
+	if (symbolrate < (u32)(XIN/98.4)) SFIL = 1;
+
+	symbolrate <<= NDEC;
+	ratio = (symbolrate << 4) / FIN;
+	tmp =  ((symbolrate << 4) % FIN) << 8;
+	ratio = (ratio << 8) + tmp / FIN;
+	tmp = (tmp % FIN) << 8;
+	ratio = (ratio << 8) + (tmp + FIN/2) / FIN;
+
+	BDR = ratio;
+	BDRI = (((XIN << 5) / symbolrate) + 1) / 2;
+
+	if (BDRI > 0xFF)
+		BDRI = 0xFF;
+
+	SFIL = (SFIL << 4) | tda10021_inittab[0x0E];
+
+	NDEC = (NDEC << 6) | tda10021_inittab[0x03];
+
+	tda10021_writereg (state, 0x03, NDEC);
+	tda10021_writereg (state, 0x0a, BDR&0xff);
+	tda10021_writereg (state, 0x0b, (BDR>> 8)&0xff);
+	tda10021_writereg (state, 0x0c, (BDR>>16)&0x3f);
+
+	tda10021_writereg (state, 0x0d, BDRI);
+	tda10021_writereg (state, 0x0e, SFIL);
+
+	return 0;
+}
+
+
+
+
+
+
+
+
+
+
+static int tda10021_init (struct dvb_frontend *fe)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+	int i;
+
+	dprintk("DVB: TDA10021(%d): init chip\n", fe->adapter->num);
+
+	//tda10021_writereg (fe, 0, 0);
+
+	for (i=0; i<tda10021_inittab_size; i++)
+		tda10021_writereg (state, i, tda10021_inittab[i]);
+
+	tda10021_writereg (state, 0x34, state->pwm);
+
+	//Comment by markus
+	//0x2A[3-0] == PDIV -> P multiplaying factor (P=PDIV+1)(default 0)
+	//0x2A[4] == BYPPLL -> Power down mode (default 1)
+	//0x2A[5] == LCK -> PLL Lock Flag
+	//0x2A[6] == POLAXIN -> Polarity of the input reference clock (default 0)
+
+	//Activate PLL
+	tda10021_writereg(state, 0x2a, tda10021_inittab[0x2a] & 0xef);
+
+	if (state->config->pll_init) {
+		lock_tuner(state);
+		state->config->pll_init(fe);
+		unlock_tuner(state);
+	}
+
+	return 0;
+}
+
+static int tda10021_set_parameters (struct dvb_frontend *fe,
+			    struct dvb_frontend_parameters *p)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+
+	//table for QAM4-QAM256 ready  QAM4  QAM16 QAM32 QAM64 QAM128 QAM256
+	//CONF
+	static const u8 reg0x00 [] = { 0x14, 0x00, 0x04, 0x08, 0x0c,  0x10 };
+	//AGCREF value
+	static const u8 reg0x01 [] = { 0x78, 0x8c, 0x8c, 0x6a, 0x78,  0x5c };
+	//LTHR value
+	static const u8 reg0x05 [] = { 0x78, 0x87, 0x64, 0x46, 0x36,  0x26 };
+	//MSETH
+	static const u8 reg0x08 [] = { 0x8c, 0xa2, 0x74, 0x43, 0x34,  0x23 };
+	//AREF
+	static const u8 reg0x09 [] = { 0x96, 0x91, 0x96, 0x6a, 0x7e,  0x6b };
+
+	int qam = p->u.qam.modulation;
+
+	if (qam < 0 || qam > 5)
+		return -EINVAL;
+
+	//printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate);
+
+	lock_tuner(state);
+	state->config->pll_set(fe, p);
+	unlock_tuner(state);
+
+	tda10021_set_symbolrate (state, p->u.qam.symbol_rate);
+	tda10021_writereg (state, 0x34, state->pwm);
+
+	tda10021_writereg (state, 0x01, reg0x01[qam]);
+	tda10021_writereg (state, 0x05, reg0x05[qam]);
+	tda10021_writereg (state, 0x08, reg0x08[qam]);
+	tda10021_writereg (state, 0x09, reg0x09[qam]);
+
+	tda10021_setup_reg0 (state, reg0x00[qam], p->inversion);
+
+	return 0;
+}
+
+static int tda10021_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+	int sync;
+
+	*status = 0;
+	//0x11[0] == EQALGO -> Equalizer algorithms state
+	//0x11[1] == CARLOCK -> Carrier locked
+	//0x11[2] == FSYNC -> Frame synchronisation
+	//0x11[3] == FEL -> Front End locked
+	//0x11[6] == NODVB -> DVB Mode Information
+	sync = tda10021_readreg (state, 0x11);
+
+	if (sync & 2)
+		*status |= FE_HAS_SIGNAL|FE_HAS_CARRIER;
+
+	if (sync & 4)
+		*status |= FE_HAS_SYNC|FE_HAS_VITERBI;
+
+	if (sync & 8)
+		*status |= FE_HAS_LOCK;
+
+	return 0;
+}
+
+static int tda10021_read_ber(struct dvb_frontend* fe, u32* ber)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+
+	u32 _ber = tda10021_readreg(state, 0x14) |
+     		  (tda10021_readreg(state, 0x15) << 8) |
+		 ((tda10021_readreg(state, 0x16) & 0x0f) << 16);
+	*ber = 10 * _ber;
+
+	return 0;
+}
+
+static int tda10021_read_signal_strength(struct dvb_frontend* fe, u16* strength)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+
+	u8 gain = tda10021_readreg(state, 0x17);
+	*strength = (gain << 8) | gain;
+
+	return 0;
+}
+
+static int tda10021_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+
+	u8 quality = ~tda10021_readreg(state, 0x18);
+	*snr = (quality << 8) | quality;
+
+	return 0;
+}
+
+static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+
+	*ucblocks = tda10021_readreg (state, 0x13) & 0x7f;
+	if (*ucblocks == 0x7f)
+		*ucblocks = 0xffffffff;
+
+	/* reset uncorrected block counter */
+	tda10021_writereg (state, 0x10, tda10021_inittab[0x10] & 0xdf);
+	tda10021_writereg (state, 0x10, tda10021_inittab[0x10]);
+
+	return 0;
+}
+
+static int tda10021_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+	int sync;
+	s8 afc = 0;
+
+	sync = tda10021_readreg(state, 0x11);
+	afc = tda10021_readreg(state, 0x19);
+	if (verbose) {
+		/* AFC only valid when carrier has been recovered */
+		printk(sync & 2 ? "DVB: TDA10021(%d): AFC (%d) %dHz\n" :
+				  "DVB: TDA10021(%d): [AFC (%d) %dHz]\n",
+			state->frontend.dvb->num, afc,
+		       -((s32)p->u.qam.symbol_rate * afc) >> 10);
+	}
+
+	p->inversion = HAS_INVERSION(state->reg0) ? INVERSION_ON : INVERSION_OFF;
+	p->u.qam.modulation = ((state->reg0 >> 2) & 7) + QAM_16;
+
+	p->u.qam.fec_inner = FEC_NONE;
+	p->frequency = ((p->frequency + 31250) / 62500) * 62500;
+
+	if (sync & 2)
+		p->frequency -= ((s32)p->u.qam.symbol_rate * afc) >> 10;
+
+	return 0;
+}
+
+static int tda10021_sleep(struct dvb_frontend* fe)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+
+	tda10021_writereg (state, 0x1b, 0x02);  /* pdown ADC */
+	tda10021_writereg (state, 0x00, 0x80);  /* standby */
+
+	return 0;
+}
+
+static void tda10021_release(struct dvb_frontend* fe)
+{
+	struct tda10021_state* state = (struct tda10021_state*) fe->demodulator_priv;
+	kfree(state);
+}
+
+static struct dvb_frontend_ops tda10021_ops;
+
+struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
+				     struct i2c_adapter* i2c,
+				     u8 pwm)
+{
+	struct tda10021_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct tda10021_state*) kmalloc(sizeof(struct tda10021_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &tda10021_ops, sizeof(struct dvb_frontend_ops));
+	state->pwm = pwm;
+	state->reg0 = tda10021_inittab[0];
+
+	/* check if the demod is there */
+	if ((tda10021_readreg(state, 0x1a) & 0xf0) != 0x70) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops tda10021_ops = {
+
+	.info = {
+		.name = "Philips TDA10021 DVB-C",
+		.type = FE_QAM,
+		.frequency_stepsize = 62500,
+		.frequency_min = 51000000,
+		.frequency_max = 858000000,
+		.symbol_rate_min = (XIN/2)/64,     /* SACLK/64 == (XIN/2)/64 */
+		.symbol_rate_max = (XIN/2)/4,      /* SACLK/4 */
+	#if 0
+		.frequency_tolerance = ???,
+		.symbol_rate_tolerance = ???,  /* ppm */  /* == 8% (spec p. 5) */
+	#endif
+		.caps = 0x400 | //FE_CAN_QAM_4
+			FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
+			FE_CAN_QAM_128 | FE_CAN_QAM_256 |
+			FE_CAN_FEC_AUTO
+	},
+
+	.release = tda10021_release,
+
+	.init = tda10021_init,
+	.sleep = tda10021_sleep,
+
+	.set_frontend = tda10021_set_parameters,
+	.get_frontend = tda10021_get_frontend,
+
+	.read_status = tda10021_read_status,
+	.read_ber = tda10021_read_ber,
+	.read_signal_strength = tda10021_read_signal_strength,
+	.read_snr = tda10021_read_snr,
+	.read_ucblocks = tda10021_read_ucblocks,
+};
+
+module_param(verbose, int, 0644);
+MODULE_PARM_DESC(verbose, "print AFC offset after tuning for debugging the PWM setting");
+
+MODULE_DESCRIPTION("Philips TDA10021 DVB-C demodulator driver");
+MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Markus Schulz");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(tda10021_attach);
diff -Nru a/drivers/media/dvb/frontends/tda10021.h b/drivers/media/dvb/frontends/tda10021.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/tda10021.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,43 @@
+/*
+    TDA10021  - Single Chip Cable Channel Receiver driver module
+               used on the the Siemens DVB-C cards
+
+    Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
+    Copyright (C) 2004 Markus Schulz <msc@antzsystem.de>
+                   Suppport for TDA10021
+
+    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.
+*/
+
+#ifndef TDA10021_H
+#define TDA10021_H
+
+#include <linux/dvb/frontend.h>
+
+struct tda10021_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
+					    struct i2c_adapter* i2c,
+					    u8 pwm);
+
+#endif // TDA10021_H
diff -Nru a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
--- a/drivers/media/dvb/frontends/tda1004x.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/media/dvb/frontends/tda1004x.c	2004-12-24 13:36:16 -08:00
@@ -1,5 +1,5 @@
   /*
-     Driver for Philips tda1004xh OFDM Frontend
+     Driver for Philips tda1004xh OFDM Demodulator
 
      (c) 2003, 2004 Andrew de Quincey & Robert Schlabbach
 
@@ -19,177 +19,128 @@
      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
    */
-
 /*
-    This driver needs a copy of the DLL "ttlcdacc.dll" from the Haupauge or Technotrend
-    windows driver saved as '/usr/lib/hotplug/firmware/tda1004x.bin'.
-    You can also pass the complete file name with the module parameter 'tda1004x_firmware'.
-
-    Currently the DLL from v2.15a of the technotrend driver is supported. Other versions can
-    be added reasonably painlessly.
-
-    Windows driver URL: http://www.technotrend.de/
+ * This driver needs external firmware. Please use the commands
+ * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",
+ * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to
+ * download/extract them, and then copy them to /usr/lib/hotplug/firmware.
  */
+#define TDA10045_DEFAULT_FIRMWARE "dvb-fe-tda10045.fw"
+#define TDA10046_DEFAULT_FIRMWARE "dvb-fe-tda10046.fw"
 
-
-#include <linux/kernel.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
 #include <linux/init.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/fcntl.h>
-#include <linux/errno.h>
-#include <linux/syscalls.h>
-
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
 #include "dvb_frontend.h"
-#include "dvb_functions.h"
+#include "tda1004x.h"
 
-#ifndef DVB_TDA1004X_FIRMWARE_FILE
-#define DVB_TDA1004X_FIRMWARE_FILE "/usr/lib/hotplug/firmware/tda1004x.bin"
-#endif
-
-static int tda1004x_debug = 0;
-static char *tda1004x_firmware = DVB_TDA1004X_FIRMWARE_FILE;
-
-#define MC44BC374_ADDRESS        0x65
-
-#define TDA1004X_CHIPID          0x00
-#define TDA1004X_AUTO            0x01
-#define TDA1004X_IN_CONF1        0x02
-#define TDA1004X_IN_CONF2        0x03
-#define TDA1004X_OUT_CONF1       0x04
-#define TDA1004X_OUT_CONF2       0x05
-#define TDA1004X_STATUS_CD       0x06
-#define TDA1004X_CONFC4          0x07
-#define TDA1004X_DSSPARE2        0x0C
-#define TDA10045H_CODE_IN        0x0D
-#define TDA10045H_FWPAGE         0x0E
-#define TDA1004X_SCAN_CPT        0x10
-#define TDA1004X_DSP_CMD         0x11
-#define TDA1004X_DSP_ARG         0x12
-#define TDA1004X_DSP_DATA1       0x13
-#define TDA1004X_DSP_DATA2       0x14
-#define TDA1004X_CONFADC1        0x15
-#define TDA1004X_CONFC1          0x16
-#define TDA10045H_S_AGC          0x1a
-#define TDA10046H_AGC_TUN_LEVEL  0x1a
-#define TDA1004X_SNR             0x1c
-#define TDA1004X_CONF_TS1        0x1e
-#define TDA1004X_CONF_TS2        0x1f
-#define TDA1004X_CBER_RESET      0x20
-#define TDA1004X_CBER_MSB        0x21
-#define TDA1004X_CBER_LSB        0x22
-#define TDA1004X_CVBER_LUT       0x23
-#define TDA1004X_VBER_MSB        0x24
-#define TDA1004X_VBER_MID        0x25
-#define TDA1004X_VBER_LSB        0x26
-#define TDA1004X_UNCOR           0x27
-
-#define TDA10045H_CONFPLL_P      0x2D
-#define TDA10045H_CONFPLL_M_MSB  0x2E
-#define TDA10045H_CONFPLL_M_LSB  0x2F
-#define TDA10045H_CONFPLL_N      0x30
-
-#define TDA10046H_CONFPLL1       0x2D
-#define TDA10046H_CONFPLL2       0x2F
-#define TDA10046H_CONFPLL3       0x30
-#define TDA10046H_TIME_WREF1     0x31
-#define TDA10046H_TIME_WREF2     0x32
-#define TDA10046H_TIME_WREF3     0x33
-#define TDA10046H_TIME_WREF4     0x34
-#define TDA10046H_TIME_WREF5     0x35
-
-#define TDA10045H_UNSURW_MSB     0x31
-#define TDA10045H_UNSURW_LSB     0x32
-#define TDA10045H_WREF_MSB       0x33
-#define TDA10045H_WREF_MID       0x34
-#define TDA10045H_WREF_LSB       0x35
-#define TDA10045H_MUXOUT         0x36
-#define TDA1004X_CONFADC2        0x37
+#define TDA1004X_DEMOD_TDA10045 0
+#define TDA1004X_DEMOD_TDA10046 1
 
-#define TDA10045H_IOFFSET        0x38
 
-#define TDA10046H_CONF_TRISTATE1 0x3B
-#define TDA10046H_CONF_TRISTATE2 0x3C
-#define TDA10046H_CONF_POLARITY  0x3D
-#define TDA10046H_FREQ_OFFSET    0x3E
-#define TDA10046H_GPIO_OUT_SEL   0x41
-#define TDA10046H_GPIO_SELECT    0x42
-#define TDA10046H_AGC_CONF       0x43
-#define TDA10046H_AGC_GAINS      0x46
-#define TDA10046H_AGC_TUN_MIN    0x47
-#define TDA10046H_AGC_TUN_MAX    0x48
-#define TDA10046H_AGC_IF_MIN     0x49
-#define TDA10046H_AGC_IF_MAX     0x4A
-
-#define TDA10046H_FREQ_PHY2_MSB  0x4D
-#define TDA10046H_FREQ_PHY2_LSB  0x4E
-
-#define TDA10046H_CVBER_CTRL     0x4F
-#define TDA10046H_AGC_IF_LEVEL   0x52
-#define TDA10046H_CODE_CPT       0x57
-#define TDA10046H_CODE_IN        0x58
-
-
-#define FE_TYPE_TDA10045H     0
-#define FE_TYPE_TDA10046H     1
-
-#define TUNER_TYPE_TD1344     0
-#define TUNER_TYPE_TD1316     1
-
-#define dprintk if (tda1004x_debug) printk
-
-static struct dvb_frontend_info tda10045h_info = {
-	.name = "Philips TDA10045H",
-	.type = FE_OFDM,
-	.frequency_min = 51000000,
-	.frequency_max = 858000000,
-	.frequency_stepsize = 166667,
-	.caps =
-	    FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-	    FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-	    FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
-	    FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
-};
+struct tda1004x_state
+{
+	struct i2c_adapter* i2c;
 
-static struct dvb_frontend_info tda10046h_info = {
-        .name = "Philips TDA10046H",
-        .type = FE_OFDM,
-        .frequency_min = 51000000,
-        .frequency_max = 858000000,
-        .frequency_stepsize = 166667,
-        .caps =
-            FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-            FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-            FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
-            FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
-};
+	struct dvb_frontend_ops ops;
+
+	const struct tda1004x_config* config;
 
+	struct dvb_frontend frontend;
 
-struct tda1004x_state {
-	u8 tda1004x_address;
-	u8 tuner_address;
+	/* private demod data */
 	u8 initialised:1;
-        u8 tuner_type:2;
-        u8 fe_type:2;
+
+	u8 demod_type;
 };
 
 
-struct fwinfo {
-	int file_size;
-	int fw_offset;
-	int fw_size;
-};
-static struct fwinfo tda10045h_fwinfo[] = { {.file_size = 286720,.fw_offset = 0x34cc5,.fw_size = 30555} };
-static int tda10045h_fwinfo_count = sizeof(tda10045h_fwinfo) / sizeof(struct fwinfo);
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "tda1004x: " args); \
+	} while (0)
+
+#define TDA1004X_CHIPID		 0x00
+#define TDA1004X_AUTO		 0x01
+#define TDA1004X_IN_CONF1	 0x02
+#define TDA1004X_IN_CONF2	 0x03
+#define TDA1004X_OUT_CONF1	 0x04
+#define TDA1004X_OUT_CONF2	 0x05
+#define TDA1004X_STATUS_CD	 0x06
+#define TDA1004X_CONFC4		 0x07
+#define TDA1004X_DSSPARE2	 0x0C
+#define TDA10045H_CODE_IN	 0x0D
+#define TDA10045H_FWPAGE	 0x0E
+#define TDA1004X_SCAN_CPT	 0x10
+#define TDA1004X_DSP_CMD	 0x11
+#define TDA1004X_DSP_ARG	 0x12
+#define TDA1004X_DSP_DATA1	 0x13
+#define TDA1004X_DSP_DATA2	 0x14
+#define TDA1004X_CONFADC1	 0x15
+#define TDA1004X_CONFC1		 0x16
+#define TDA10045H_S_AGC		 0x1a
+#define TDA10046H_AGC_TUN_LEVEL	 0x1a
+#define TDA1004X_SNR		 0x1c
+#define TDA1004X_CONF_TS1	 0x1e
+#define TDA1004X_CONF_TS2	 0x1f
+#define TDA1004X_CBER_RESET	 0x20
+#define TDA1004X_CBER_MSB	 0x21
+#define TDA1004X_CBER_LSB	 0x22
+#define TDA1004X_CVBER_LUT	 0x23
+#define TDA1004X_VBER_MSB	 0x24
+#define TDA1004X_VBER_MID	 0x25
+#define TDA1004X_VBER_LSB	 0x26
+#define TDA1004X_UNCOR		 0x27
+
+#define TDA10045H_CONFPLL_P	 0x2D
+#define TDA10045H_CONFPLL_M_MSB	 0x2E
+#define TDA10045H_CONFPLL_M_LSB	 0x2F
+#define TDA10045H_CONFPLL_N	 0x30
+
+#define TDA10046H_CONFPLL1	 0x2D
+#define TDA10046H_CONFPLL2	 0x2F
+#define TDA10046H_CONFPLL3	 0x30
+#define TDA10046H_TIME_WREF1	 0x31
+#define TDA10046H_TIME_WREF2	 0x32
+#define TDA10046H_TIME_WREF3	 0x33
+#define TDA10046H_TIME_WREF4	 0x34
+#define TDA10046H_TIME_WREF5	 0x35
+
+#define TDA10045H_UNSURW_MSB	 0x31
+#define TDA10045H_UNSURW_LSB	 0x32
+#define TDA10045H_WREF_MSB	 0x33
+#define TDA10045H_WREF_MID	 0x34
+#define TDA10045H_WREF_LSB	 0x35
+#define TDA10045H_MUXOUT	 0x36
+#define TDA1004X_CONFADC2	 0x37
+
+#define TDA10045H_IOFFSET	 0x38
 
-static struct fwinfo tda10046h_fwinfo[] = { {.file_size = 286720,.fw_offset = 0x3c4f9,.fw_size = 24479} };
-static int tda10046h_fwinfo_count = sizeof(tda10046h_fwinfo) / sizeof(struct fwinfo);
+#define TDA10046H_CONF_TRISTATE1 0x3B
+#define TDA10046H_CONF_TRISTATE2 0x3C
+#define TDA10046H_CONF_POLARITY	 0x3D
+#define TDA10046H_FREQ_OFFSET	 0x3E
+#define TDA10046H_GPIO_OUT_SEL	 0x41
+#define TDA10046H_GPIO_SELECT	 0x42
+#define TDA10046H_AGC_CONF	 0x43
+#define TDA10046H_AGC_GAINS	 0x46
+#define TDA10046H_AGC_TUN_MIN	 0x47
+#define TDA10046H_AGC_TUN_MAX	 0x48
+#define TDA10046H_AGC_IF_MIN	 0x49
+#define TDA10046H_AGC_IF_MAX	 0x4A
+
+#define TDA10046H_FREQ_PHY2_MSB	 0x4D
+#define TDA10046H_FREQ_PHY2_LSB	 0x4E
+
+#define TDA10046H_CVBER_CTRL	 0x4F
+#define TDA10046H_AGC_IF_LEVEL	 0x52
+#define TDA10046H_CODE_CPT	 0x57
+#define TDA10046H_CODE_IN	 0x58
 
 
-static int tda1004x_write_byte(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state, int reg, int data)
+static int tda1004x_write_byteI(struct tda1004x_state *state, int reg, int data)
 {
 	int ret;
 	u8 buf[] = { reg, data };
@@ -197,35 +148,35 @@
 
 	dprintk("%s: reg=0x%x, data=0x%x\n", __FUNCTION__, reg, data);
 
-        msg.addr = tda_state->tda1004x_address;
-	ret = i2c->xfer(i2c, &msg, 1);
+	msg.addr = state->config->demod_address;
+	ret = i2c_transfer(state->i2c, &msg, 1);
 
 	if (ret != 1)
 		dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n",
-		       __FUNCTION__, reg, data, ret);
+			__FUNCTION__, reg, data, ret);
 
 	dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __FUNCTION__,
 		reg, data, ret);
 	return (ret != 1) ? -1 : 0;
 }
 
-static int tda1004x_read_byte(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state, int reg)
+static int tda1004x_read_byte(struct tda1004x_state *state, int reg)
 {
 	int ret;
 	u8 b0[] = { reg };
 	u8 b1[] = { 0 };
 	struct i2c_msg msg[] = {{ .addr=0, .flags=0, .buf=b0, .len=1},
-	                        { .addr=0, .flags=I2C_M_RD, .buf=b1, .len = 1}};
+				{ .addr=0, .flags=I2C_M_RD, .buf=b1, .len = 1}};
 
 	dprintk("%s: reg=0x%x\n", __FUNCTION__, reg);
 
-        msg[0].addr = tda_state->tda1004x_address;
-        msg[1].addr = tda_state->tda1004x_address;
-	ret = i2c->xfer(i2c, msg, 2);
+	msg[0].addr = state->config->demod_address;
+	msg[1].addr = state->config->demod_address;
+	ret = i2c_transfer(state->i2c, msg, 2);
 
 	if (ret != 2) {
 		dprintk("%s: error reg=0x%x, ret=%i\n", __FUNCTION__, reg,
-		       ret);
+			ret);
 		return -1;
 	}
 
@@ -234,14 +185,14 @@
 	return b1[0];
 }
 
-static int tda1004x_write_mask(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state, int reg, int mask, int data)
+static int tda1004x_write_mask(struct tda1004x_state *state, int reg, int mask, int data)
 {
-        int val;
+	int val;
 	dprintk("%s: reg=0x%x, mask=0x%x, data=0x%x\n", __FUNCTION__, reg,
 		mask, data);
 
 	// read a byte and check
-	val = tda1004x_read_byte(i2c, tda_state, reg);
+	val = tda1004x_read_byte(state, reg);
 	if (val < 0)
 		return val;
 
@@ -250,10 +201,10 @@
 	val |= data & 0xff;
 
 	// write it out again
-	return tda1004x_write_byte(i2c, tda_state, reg, val);
+	return tda1004x_write_byteI(state, reg, val);
 }
 
-static int tda1004x_write_buf(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state, int reg, unsigned char *buf, int len)
+static int tda1004x_write_buf(struct tda1004x_state *state, int reg, unsigned char *buf, int len)
 {
 	int i;
 	int result;
@@ -262,7 +213,7 @@
 
 	result = 0;
 	for (i = 0; i < len; i++) {
-		result = tda1004x_write_byte(i2c, tda_state, reg + i, buf[i]);
+		result = tda1004x_write_byteI(state, reg + i, buf[i]);
 		if (result != 0)
 			break;
 	}
@@ -270,358 +221,219 @@
 	return result;
 }
 
-static int tda1004x_enable_tuner_i2c(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state)
+static int tda1004x_enable_tuner_i2c(struct tda1004x_state *state)
 {
-        int result;
+	int result;
 	dprintk("%s\n", __FUNCTION__);
 
-	result = tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 2, 2);
-	dvb_delay(1);
+	result = tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 2);
+	msleep(1);
 	return result;
 }
 
-static int tda1004x_disable_tuner_i2c(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state)
+static int tda1004x_disable_tuner_i2c(struct tda1004x_state *state)
 {
-
 	dprintk("%s\n", __FUNCTION__);
 
-	return tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 2, 0);
+	return tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 0);
 }
 
-
-static int tda10045h_set_bandwidth(struct dvb_i2c_bus *i2c,
-	                           struct tda1004x_state *tda_state,
-		                   fe_bandwidth_t bandwidth)
+static int tda10045h_set_bandwidth(struct tda1004x_state *state,
+				   fe_bandwidth_t bandwidth)
 {
-        static u8 bandwidth_6mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x60, 0x1e, 0xa7, 0x45, 0x4f };
-        static u8 bandwidth_7mhz[] = { 0x02, 0x00, 0x37, 0x00, 0x4a, 0x2f, 0x6d, 0x76, 0xdb };
-        static u8 bandwidth_8mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x48, 0x17, 0x89, 0xc7, 0x14 };
+	static u8 bandwidth_6mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x60, 0x1e, 0xa7, 0x45, 0x4f };
+	static u8 bandwidth_7mhz[] = { 0x02, 0x00, 0x37, 0x00, 0x4a, 0x2f, 0x6d, 0x76, 0xdb };
+	static u8 bandwidth_8mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x48, 0x17, 0x89, 0xc7, 0x14 };
 
-        switch (bandwidth) {
+	switch (bandwidth) {
 	case BANDWIDTH_6_MHZ:
-		tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0x14);
-                tda1004x_write_buf(i2c, tda_state, TDA10045H_CONFPLL_P, bandwidth_6mhz, sizeof(bandwidth_6mhz));
+		tda1004x_write_buf(state, TDA10045H_CONFPLL_P, bandwidth_6mhz, sizeof(bandwidth_6mhz));
 		break;
 
 	case BANDWIDTH_7_MHZ:
-		tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0x80);
-                tda1004x_write_buf(i2c, tda_state, TDA10045H_CONFPLL_P, bandwidth_7mhz, sizeof(bandwidth_7mhz));
+		tda1004x_write_buf(state, TDA10045H_CONFPLL_P, bandwidth_7mhz, sizeof(bandwidth_7mhz));
 		break;
 
 	case BANDWIDTH_8_MHZ:
-		tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0x14);
-                tda1004x_write_buf(i2c, tda_state, TDA10045H_CONFPLL_P, bandwidth_8mhz, sizeof(bandwidth_8mhz));
+		tda1004x_write_buf(state, TDA10045H_CONFPLL_P, bandwidth_8mhz, sizeof(bandwidth_8mhz));
 		break;
 
 	default:
 		return -EINVAL;
 	}
 
-        tda1004x_write_byte(i2c, tda_state, TDA10045H_IOFFSET, 0);
+	tda1004x_write_byteI(state, TDA10045H_IOFFSET, 0);
 
-        // done
-        return 0;
+	return 0;
 }
 
-
-static int tda10046h_set_bandwidth(struct dvb_i2c_bus *i2c,
-                                   struct tda1004x_state *tda_state,
-                                   fe_bandwidth_t bandwidth)
+static int tda10046h_set_bandwidth(struct tda1004x_state *state,
+				   fe_bandwidth_t bandwidth)
 {
-        static u8 bandwidth_6mhz[] = { 0x80, 0x15, 0xfe, 0xab, 0x8e };
-        static u8 bandwidth_7mhz[] = { 0x6e, 0x02, 0x53, 0xc8, 0x25 };
-        static u8 bandwidth_8mhz[] = { 0x60, 0x12, 0xa8, 0xe4, 0xbd };
+	static u8 bandwidth_6mhz[] = { 0x80, 0x15, 0xfe, 0xab, 0x8e };
+	static u8 bandwidth_7mhz[] = { 0x6e, 0x02, 0x53, 0xc8, 0x25 };
+	static u8 bandwidth_8mhz[] = { 0x60, 0x12, 0xa8, 0xe4, 0xbd };
 
-        switch (bandwidth) {
-        case BANDWIDTH_6_MHZ:
-                tda1004x_write_buf(i2c, tda_state, TDA10046H_TIME_WREF1, bandwidth_6mhz, sizeof(bandwidth_6mhz));
-                tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0);
-                break;
+	switch (bandwidth) {
+	case BANDWIDTH_6_MHZ:
+		tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz, sizeof(bandwidth_6mhz));
+		break;
 
-        case BANDWIDTH_7_MHZ:
-                tda1004x_write_buf(i2c, tda_state, TDA10046H_TIME_WREF1, bandwidth_7mhz, sizeof(bandwidth_7mhz));
-                tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0);
-                break;
+	case BANDWIDTH_7_MHZ:
+		tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz, sizeof(bandwidth_7mhz));
+		break;
 
-        case BANDWIDTH_8_MHZ:
-                tda1004x_write_buf(i2c, tda_state, TDA10046H_TIME_WREF1, bandwidth_8mhz, sizeof(bandwidth_8mhz));
-                tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0xFF);
-                break;
+	case BANDWIDTH_8_MHZ:
+		tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz, sizeof(bandwidth_8mhz));
+		break;
 
-        default:
-                return -EINVAL;
-        }
+	default:
+		return -EINVAL;
+	}
 
-        // done
-        return 0;
+	return 0;
 }
 
-
-static int tda1004x_fwupload(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state)
+static int tda1004x_do_upload(struct tda1004x_state *state,
+			      unsigned char *mem, unsigned int len,
+			      u8 dspCodeCounterReg, u8 dspCodeInReg)
 {
-	u8 fw_buf[65];
-	struct i2c_msg fw_msg = {.addr = 0,.flags = 0,.buf = fw_buf,.len = 0 };
-	unsigned char *firmware = NULL;
-	int filesize;
-	int fd;
-	int fwinfo_idx;
-	int fw_size = 0;
-        int fw_pos, fw_offset;
+	u8 buf[65];
+	struct i2c_msg fw_msg = {.addr = 0,.flags = 0,.buf = buf,.len = 0 };
 	int tx_size;
-	mm_segment_t fs = get_fs();
-        int dspCodeCounterReg=0, dspCodeInReg=0, dspVersion=0;
-        int fwInfoCount=0;
-        struct fwinfo* fwInfo = NULL;
-        unsigned long timeout;
-
-        // DSP parameters
-        switch(tda_state->fe_type) {
-        case FE_TYPE_TDA10045H:
-                dspCodeCounterReg = TDA10045H_FWPAGE;
-                dspCodeInReg = TDA10045H_CODE_IN;
-                dspVersion = 0x2c;
-                fwInfoCount = tda10045h_fwinfo_count;
-                fwInfo = tda10045h_fwinfo;
-                break;
-
-        case FE_TYPE_TDA10046H:
-                dspCodeCounterReg = TDA10046H_CODE_CPT;
-                dspCodeInReg = TDA10046H_CODE_IN;
-                dspVersion = 0x20;
-                fwInfoCount = tda10046h_fwinfo_count;
-                fwInfo = tda10046h_fwinfo;
-                break;
-        }
-
-	// Load the firmware
-	set_fs(get_ds());
-	fd = sys_open(tda1004x_firmware, 0, 0);
-	if (fd < 0) {
-		printk("%s: Unable to open firmware %s\n", __FUNCTION__,
-		       tda1004x_firmware);
-		return -EIO;
-	}
-	filesize = sys_lseek(fd, 0L, 2);
-	if (filesize <= 0) {
-		printk("%s: Firmware %s is empty\n", __FUNCTION__,
-		       tda1004x_firmware);
-		sys_close(fd);
-		return -EIO;
-	}
+	int pos = 0;
 
-        // find extraction parameters for firmware
-        for (fwinfo_idx = 0; fwinfo_idx < fwInfoCount; fwinfo_idx++) {
-                if (fwInfo[fwinfo_idx].file_size == filesize)
-			break;
-	}
-        if (fwinfo_idx >= fwInfoCount) {
-		printk("%s: Unsupported firmware %s\n", __FUNCTION__, tda1004x_firmware);
-		sys_close(fd);
-		return -EIO;
-	}
-        fw_size = fwInfo[fwinfo_idx].fw_size;
-        fw_offset = fwInfo[fwinfo_idx].fw_offset;
-
-	// allocate buffer for it
-	firmware = vmalloc(fw_size);
-	if (firmware == NULL) {
-		printk("%s: Out of memory loading firmware\n",
-		       __FUNCTION__);
-		sys_close(fd);
-		return -EIO;
-	}
-
-	// read it!
-	sys_lseek(fd, fw_offset, 0);
-	if (sys_read(fd, firmware, fw_size) != fw_size) {
-		printk("%s: Failed to read firmware\n", __FUNCTION__);
-		vfree(firmware);
-		sys_close(fd);
-		return -EIO;
-	}
-	sys_close(fd);
-	set_fs(fs);
+	/* clear code counter */
+	tda1004x_write_byteI(state, dspCodeCounterReg, 0);
+	fw_msg.addr = state->config->demod_address;
 
-        // set some valid bandwith parameters before uploading
-        switch(tda_state->fe_type) {
-        case FE_TYPE_TDA10045H:
-                // reset chip
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 0x10, 0);
-                tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 8, 8);
-                tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 8, 0);
-                dvb_delay(10);
-
-                // set parameters
-                tda10045h_set_bandwidth(i2c, tda_state, BANDWIDTH_8_MHZ);
-                break;
-
-        case FE_TYPE_TDA10046H:
-                // reset chip
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 1, 0);
-                tda1004x_write_mask(i2c, tda_state, TDA10046H_CONF_TRISTATE1, 1, 0);
-                dvb_delay(10);
-
-                // set parameters
-                tda1004x_write_byte(i2c, tda_state, TDA10046H_CONFPLL2, 10);
-                tda1004x_write_byte(i2c, tda_state, TDA10046H_CONFPLL3, 0);
-                tda1004x_write_byte(i2c, tda_state, TDA10046H_FREQ_OFFSET, 99);
-                tda1004x_write_byte(i2c, tda_state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
-                tda1004x_write_byte(i2c, tda_state, TDA10046H_FREQ_PHY2_LSB, 0x2c);
-                tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST
-                break;
-        }
-
-	// do the firmware upload
-        tda1004x_write_byte(i2c, tda_state, dspCodeCounterReg, 0); // clear code counter
-        fw_msg.addr = tda_state->tda1004x_address;
-	fw_pos = 0;
-	while (fw_pos != fw_size) {
+	buf[0] = dspCodeInReg;
+	while (pos != len) {
 
 		// work out how much to send this time
-		tx_size = fw_size - fw_pos;
-                if (tx_size > 0x10) {
-                        tx_size = 0x10;
+		tx_size = len - pos;
+		if (tx_size > 0x10) {
+			tx_size = 0x10;
 		}
 
 		// send the chunk
-                fw_buf[0] = dspCodeInReg;
-		memcpy(fw_buf + 1, firmware + fw_pos, tx_size);
+		memcpy(buf + 1, mem + pos, tx_size);
 		fw_msg.len = tx_size + 1;
-		if (i2c->xfer(i2c, &fw_msg, 1) != 1) {
-                        printk("tda1004x: Error during firmware upload\n");
-			vfree(firmware);
+		if (i2c_transfer(state->i2c, &fw_msg, 1) != 1) {
+			printk("tda1004x: Error during firmware upload\n");
 			return -EIO;
 		}
-		fw_pos += tx_size;
+		pos += tx_size;
 
-		dprintk("%s: fw_pos=0x%x\n", __FUNCTION__, fw_pos);
+		dprintk("%s: fw_pos=0x%x\n", __FUNCTION__, pos);
 	}
-	vfree(firmware);
+	return 0;
+}
+
+static int tda1004x_check_upload_ok(struct tda1004x_state *state, u8 dspVersion)
+{
+	u8 data1, data2;
+
+	// check upload was OK
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 0x10, 0); // we want to read from the DSP
+	tda1004x_write_byteI(state, TDA1004X_DSP_CMD, 0x67);
 
-        // wait for DSP to initialise
-        switch(tda_state->fe_type) {
-        case FE_TYPE_TDA10045H:
-                // DSPREADY doesn't seem to work on the TDA10045H
-                dvb_delay(100);
-                break;
-
-        case FE_TYPE_TDA10046H:
-                timeout = jiffies + HZ;
-                while(!(tda1004x_read_byte(i2c, tda_state, TDA1004X_STATUS_CD) & 0x20)) {
-                        if (time_after(jiffies, timeout)) {
-                                printk("tda1004x: DSP failed to initialised.\n");
-                                return -EIO;
-                        }
-
-                        dvb_delay(1);
-                }
-                break;
-        }
-
-        // check upload was OK
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 0x10, 0); // we want to read from the DSP
-	tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_CMD, 0x67);
-	if ((tda1004x_read_byte(i2c, tda_state, TDA1004X_DSP_DATA1) != 0x67) ||
-            (tda1004x_read_byte(i2c, tda_state, TDA1004X_DSP_DATA2) != dspVersion)) {
-		printk("%s: firmware upload failed!\n", __FUNCTION__);
+	data1 = tda1004x_read_byte(state, TDA1004X_DSP_DATA1);
+	data2 = tda1004x_read_byte(state, TDA1004X_DSP_DATA2);
+	if (data1 != 0x67 || data2 != dspVersion) {
 		return -EIO;
 	}
 
-        // success
-        return 0;
+	return 0;
 }
 
 
-static int tda10045h_init(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state)
+static int tda10045_fwupload(struct dvb_frontend* fe)
 {
-        struct i2c_msg tuner_msg = {.addr = 0,.flags = 0,.buf = NULL,.len = 0 };
-        static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
+	struct tda1004x_state* state = fe->demodulator_priv;
+	int ret;
+	const struct firmware *fw;
 
-        dprintk("%s\n", __FUNCTION__);
 
-	tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFADC1, 0x10, 0); // wake up the ADC
+	/* don't re-upload unless necessary */
+	if (tda1004x_check_upload_ok(state, 0x2c) == 0) return 0;
 
-        // Disable the MC44BC374C
-        tda1004x_enable_tuner_i2c(i2c, tda_state);
-        tuner_msg.addr = MC44BC374_ADDRESS;
-        tuner_msg.buf = disable_mc44BC374c;
-        tuner_msg.len = sizeof(disable_mc44BC374c);
-        if (i2c->xfer(i2c, &tuner_msg, 1) != 1) {
-                i2c->xfer(i2c, &tuner_msg, 1);
-        }
-        tda1004x_disable_tuner_i2c(i2c, tda_state);
+	/* request the firmware, this will block until someone uploads it */
+	printk("tda1004x: waiting for firmware upload...\n");
+	ret = state->config->request_firmware(fe, &fw, TDA10045_DEFAULT_FIRMWARE);
+	if (ret) {
+		printk("tda1004x: no firmware upload (timeout or file not found?)\n");
+	   	return ret;
+	}
 
-	// tda setup
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 8, 0); // select HP stream
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x40, 0); // no frequency inversion
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x80, 0x80); // enable pulse killer
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 0x10, 0x10); // enable auto offset
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF2, 0xC0, 0x0); // no frequency offset
-        tda1004x_write_byte(i2c, tda_state, TDA1004X_CONF_TS1, 0); // setup MPEG2 TS interface
-        tda1004x_write_byte(i2c, tda_state, TDA1004X_CONF_TS2, 0); // setup MPEG2 TS interface
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_VBER_MSB, 0xe0, 0xa0); // 10^6 VBER measurement bits
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x10, 0); // VAGC polarity
-        tda1004x_write_byte(i2c, tda_state, TDA1004X_CONFADC1, 0x2e);
-
-	// done
-	return 0;
-}
+	/* reset chip */
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 0x10, 0);
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8);
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 0);
+	msleep(10);
 
+	/* set parameters */
+	tda10045h_set_bandwidth(state, BANDWIDTH_8_MHZ);
 
+	ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10045H_FWPAGE, TDA10045H_CODE_IN);
+	if (ret)
+		return ret;
 
-static int tda10046h_init(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state)
-{
-        struct i2c_msg tuner_msg = {.addr = 0,.flags = 0,.buf = NULL,.len = 0 };
-        static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
+	/* wait for DSP to initialise */
+	/* DSPREADY doesn't seem to work on the TDA10045H */
+	msleep(100);
 
-        dprintk("%s\n", __FUNCTION__);
+	return tda1004x_check_upload_ok(state, 0x2c);
+}
 
-	tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 1, 0); // wake up the chip
+static int tda10046_fwupload(struct dvb_frontend* fe)
+{
+	struct tda1004x_state* state = fe->demodulator_priv;
+	unsigned long timeout;
+	int ret;
+	const struct firmware *fw;
 
-        // Disable the MC44BC374C
-        tda1004x_enable_tuner_i2c(i2c, tda_state);
-        tuner_msg.addr = MC44BC374_ADDRESS;
-        tuner_msg.buf = disable_mc44BC374c;
-        tuner_msg.len = sizeof(disable_mc44BC374c);
-        if (i2c->xfer(i2c, &tuner_msg, 1) != 1) {
-                i2c->xfer(i2c, &tuner_msg, 1);
-        }
-        tda1004x_disable_tuner_i2c(i2c, tda_state);
-
-        // tda setup
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x40, 0x40); // TT TDA10046H needs inversion ON
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 8, 0); // select HP stream
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x80, 0); // disable pulse killer
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_CONFPLL2, 10); // PLL M = 10
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_FREQ_OFFSET, 99); // FREQOFFS = 99
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_FREQ_PHY2_MSB, 0xd4); // } PHY2 = -11221
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_FREQ_PHY2_LSB, 0x2c); // }
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_AGC_CONF, 0); // AGC setup
-        tda1004x_write_mask(i2c, tda_state, TDA10046H_CONF_POLARITY, 0x60, 0x60); // set AGC polarities
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_AGC_TUN_MIN, 0);    // }
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_AGC_IF_MIN, 0);     // }
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_AGC_IF_MAX, 0xff);  // }
-        tda1004x_write_mask(i2c, tda_state, TDA10046H_CVBER_CTRL, 0x30, 0x10); // 10^6 VBER measurement bits
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_AGC_GAINS, 1); // IF gain 2, TUN gain 1
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 0x80, 0); // crystal is 50ppm
-        tda1004x_write_byte(i2c, tda_state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config
-        tda1004x_write_mask(i2c, tda_state, TDA1004X_CONF_TS2, 0x31, 0); // MPEG2 interface config
-        tda1004x_write_mask(i2c, tda_state, TDA10046H_CONF_TRISTATE1, 0x9e, 0); // disable AGC_TUN
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_CONF_TRISTATE2, 0xe1); // tristate setup
-        tda1004x_write_byte(i2c, tda_state, TDA10046H_GPIO_OUT_SEL, 0xcc); // GPIO output config
-        tda1004x_write_mask(i2c, tda_state, TDA10046H_GPIO_SELECT, 8, 8); // GPIO select
-        tda10046h_set_bandwidth(i2c, tda_state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz
+	/* reset + wake up chip */
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 0);
+	tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0);
+	msleep(100);
+
+	/* don't re-upload unless necessary */
+	if (tda1004x_check_upload_ok(state, 0x20) == 0) return 0;
+
+	/* request the firmware, this will block until someone uploads it */
+	printk("tda1004x: waiting for firmware upload...\n");
+	ret = state->config->request_firmware(fe, &fw, TDA10046_DEFAULT_FIRMWARE);
+	if (ret) {
+		printk("tda1004x: no firmware upload (timeout or file not found?)\n");
+   	   	return ret;
+	}
+
+	/* set parameters */
+	tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10);
+	tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0);
+	tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99);
+	tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
+	tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c);
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST
+
+	ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10046H_CODE_CPT, TDA10046H_CODE_IN);
+	if (ret)
+		return ret;
+
+	/* wait for DSP to initialise */
+	timeout = jiffies + HZ;
+	while(!(tda1004x_read_byte(state, TDA1004X_STATUS_CD) & 0x20)) {
+		if (time_after(jiffies, timeout)) {
+			printk("tda1004x: DSP failed to initialised.\n");
+			return -EIO;
+		}
+		msleep(1);
+	}
 
-        // done
-        return 0;
+	return tda1004x_check_upload_ok(state, 0x20);
 }
 
-
-
 static int tda1004x_encode_fec(int fec)
 {
 	// convert known FEC values
@@ -662,217 +474,194 @@
 	return -1;
 }
 
-static int tda1004x_set_frequency(struct dvb_i2c_bus *i2c,
-			   struct tda1004x_state *tda_state,
-			   struct dvb_frontend_parameters *fe_params)
-{
-	u8 tuner_buf[4];
-	struct i2c_msg tuner_msg = {.addr=0, .flags=0, .buf=tuner_buf, .len=sizeof(tuner_buf) };
-        int tuner_frequency = 0;
-        u8 band, cp, filter;
-	int counter, counter2;
 
-	dprintk("%s\n", __FUNCTION__);
 
-	// setup the frequency buffer
-        switch (tda_state->tuner_type) {
-        case TUNER_TYPE_TD1344:
-
-		// setup tuner buffer
-                // ((Fif+((1000000/6)/2)) + Finput)/(1000000/6)
-		tuner_frequency =
-                        (((fe_params->frequency / 1000) * 6) + 217502) / 1000;
-		tuner_buf[0] = tuner_frequency >> 8;
-		tuner_buf[1] = tuner_frequency & 0xff;
-		tuner_buf[2] = 0x88;
-		if (fe_params->frequency < 550000000) {
-			tuner_buf[3] = 0xab;
-		} else {
-			tuner_buf[3] = 0xeb;
-		}
 
-		// tune it
-		tda1004x_enable_tuner_i2c(i2c, tda_state);
-		tuner_msg.addr = tda_state->tuner_address;
-		tuner_msg.len = 4;
-		i2c->xfer(i2c, &tuner_msg, 1);
-
-		// wait for it to finish
-		tuner_msg.len = 1;
-		tuner_msg.flags = I2C_M_RD;
-		counter = 0;
-		counter2 = 0;
-		while (counter++ < 100) {
-			if (i2c->xfer(i2c, &tuner_msg, 1) == 1) {
-				if (tuner_buf[0] & 0x40) {
-					counter2++;
-				} else {
-					counter2 = 0;
-				}
-			}
-
-			if (counter2 > 10) {
-				break;
-			}
-		}
-		tda1004x_disable_tuner_i2c(i2c, tda_state);
-		break;
 
-        case TUNER_TYPE_TD1316:
-		// determine charge pump
-		tuner_frequency = fe_params->frequency + 36130000;
-		if (tuner_frequency < 87000000) {
-			return -EINVAL;
-		} else if (tuner_frequency < 130000000) {
-                        cp = 3;
-		} else if (tuner_frequency < 160000000) {
-			cp = 5;
-		} else if (tuner_frequency < 200000000) {
-			cp = 6;
-		} else if (tuner_frequency < 290000000) {
-			cp = 3;
-		} else if (tuner_frequency < 420000000) {
-			cp = 5;
-		} else if (tuner_frequency < 480000000) {
-			cp = 6;
-		} else if (tuner_frequency < 620000000) {
-			cp = 3;
-		} else if (tuner_frequency < 830000000) {
-			cp = 5;
-		} else if (tuner_frequency < 895000000) {
-			cp = 7;
-		} else {
-			return -EINVAL;
+
+
+
+
+
+
+
+
+
+
+
+
+
+int tda1004x_write_byte(struct dvb_frontend* fe, int reg, int data)
+{
+	struct tda1004x_state* state = fe->demodulator_priv;
+
+	return tda1004x_write_byteI(state, reg, data);
 		}
 
-		// determine band
-		if (fe_params->frequency < 49000000) {
-                        return -EINVAL;
-		} else if (fe_params->frequency < 159000000) {
-                        band = 1;
-		} else if (fe_params->frequency < 444000000) {
-			band = 2;
-		} else if (fe_params->frequency < 861000000) {
-			band = 4;
-		} else {
-			return -EINVAL;
+static int tda10045_init(struct dvb_frontend* fe)
+{
+	struct tda1004x_state* state = fe->demodulator_priv;
+
+	dprintk("%s\n", __FUNCTION__);
+
+	if (state->initialised) return 0;
+
+	if (tda10045_fwupload(fe)) {
+		printk("tda1004x: firmware upload failed\n");
+		return -EIO;
 		}
 
-		// work out filter
-		switch (fe_params->u.ofdm.bandwidth) {
-		case BANDWIDTH_6_MHZ:
-                        filter = 0;
-                        break;
+	tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0); // wake up the ADC
 
-                case BANDWIDTH_7_MHZ:
-			filter = 0;
-			break;
+	// Init the PLL
+	if (state->config->pll_init) {
+		tda1004x_enable_tuner_i2c(state);
+		state->config->pll_init(fe);
+		tda1004x_disable_tuner_i2c(state);
+	}
 
-		case BANDWIDTH_8_MHZ:
-			filter = 1;
-			break;
+	// tda setup
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
+	tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream
+	tda1004x_write_mask(state, TDA1004X_CONFC1, 0x40, 0); // set polarity of VAGC signal
+	tda1004x_write_mask(state, TDA1004X_CONFC1, 0x80, 0x80); // enable pulse killer
+	tda1004x_write_mask(state, TDA1004X_AUTO, 0x10, 0x10); // enable auto offset
+	tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0xC0, 0x0); // no frequency offset
+	tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 0); // setup MPEG2 TS interface
+	tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0); // setup MPEG2 TS interface
+	tda1004x_write_mask(state, TDA1004X_VBER_MSB, 0xe0, 0xa0); // 10^6 VBER measurement bits
+	tda1004x_write_mask(state, TDA1004X_CONFC1, 0x10, 0); // VAGC polarity
+	tda1004x_write_byteI(state, TDA1004X_CONFADC1, 0x2e);
 
-		default:
-			return -EINVAL;
+	tda1004x_write_mask(state, 0x1f, 0x01, state->config->invert_oclk);
+
+	state->initialised = 1;
+	return 0;
 		}
 
-                // calculate divisor
-                // ((36130000+((1000000/6)/2)) + Finput)/(1000000/6)
-		tuner_frequency =
-                        (((fe_params->frequency / 1000) * 6) + 217280) / 1000;
-
-                // setup tuner buffer
-		tuner_buf[0] = tuner_frequency >> 8;
-		tuner_buf[1] = tuner_frequency & 0xff;
-		tuner_buf[2] = 0xca;
-		tuner_buf[3] = (cp << 5) | (filter << 3) | band;
-
-		// tune it
-                if (tda_state->fe_type == FE_TYPE_TDA10046H) {
-                        // setup auto offset
-                        tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 0x10, 0x10);
-                        tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x80, 0);
-                        tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF2, 0xC0, 0);
-
-                        // disable agc_conf[2]
-                        tda1004x_write_mask(i2c, tda_state, TDA10046H_AGC_CONF, 4, 0);
-                }
-		tda1004x_enable_tuner_i2c(i2c, tda_state);
-		tuner_msg.addr = tda_state->tuner_address;
-		tuner_msg.len = 4;
-                if (i2c->xfer(i2c, &tuner_msg, 1) != 1) {
+static int tda10046_init(struct dvb_frontend* fe)
+{
+	struct tda1004x_state* state = fe->demodulator_priv;
+	dprintk("%s\n", __FUNCTION__);
+
+	if (state->initialised) return 0;
+
+	if (tda10046_fwupload(fe)) {
+		printk("tda1004x: firmware upload failed\n");
 			return -EIO;
 		}
-		dvb_delay(1);
-		tda1004x_disable_tuner_i2c(i2c, tda_state);
-                if (tda_state->fe_type == FE_TYPE_TDA10046H)
-                        tda1004x_write_mask(i2c, tda_state, TDA10046H_AGC_CONF, 4, 4);
-		break;
 
-	default:
-		return -EINVAL;
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 0); // wake up the chip
+
+	// Init the PLL
+	if (state->config->pll_init) {
+		tda1004x_enable_tuner_i2c(state);
+		state->config->pll_init(fe);
+		tda1004x_disable_tuner_i2c(state);
 	}
 
-	dprintk("%s: success\n", __FUNCTION__);
+	// tda setup
+	tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
+	tda1004x_write_mask(state, TDA1004X_CONFC1, 0x40, 0x40);
+	tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream
+	tda1004x_write_mask(state, TDA1004X_CONFC1, 0x80, 0); // disable pulse killer
+	tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); // PLL M = 10
+	tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0
+	tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99); // FREQOFFS = 99
+	tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4); // } PHY2 = -11221
+	tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c); // }
+	tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0); // AGC setup
+	tda1004x_write_mask(state, TDA10046H_CONF_POLARITY, 0x60, 0x60); // set AGC polarities
+	tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0);	  // }
+	tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values
+	tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0);	  // }
+	tda1004x_write_byteI(state, TDA10046H_AGC_IF_MAX, 0xff);  // }
+	tda1004x_write_mask(state, TDA10046H_CVBER_CTRL, 0x30, 0x10); // 10^6 VBER measurement bits
+	tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 1); // IF gain 2, TUN gain 1
+	tda1004x_write_mask(state, TDA1004X_AUTO, 0x80, 0); // crystal is 50ppm
+	tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config
+	tda1004x_write_mask(state, TDA1004X_CONF_TS2, 0x31, 0); // MPEG2 interface config
+	tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 0x9e, 0); // disable AGC_TUN
+	tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE2, 0xe1); // tristate setup
+	tda1004x_write_byteI(state, TDA10046H_GPIO_OUT_SEL, 0xcc); // GPIO output config
+	tda1004x_write_mask(state, TDA10046H_GPIO_SELECT, 8, 8); // GPIO select
+	tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz
+
+	tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7);
 
-	// done
+	state->initialised = 1;
 	return 0;
 }
 
-static int tda1004x_set_fe(struct dvb_i2c_bus *i2c,
-	 	           struct tda1004x_state *tda_state,
-		           struct dvb_frontend_parameters *fe_params)
+static int tda1004x_set_fe(struct dvb_frontend* fe,
+			   struct dvb_frontend_parameters *fe_params)
 {
+	struct tda1004x_state* state = fe->demodulator_priv;
 	int tmp;
-        int inversion;
+	int inversion;
 
 	dprintk("%s\n", __FUNCTION__);
 
-	// set frequency
-        if ((tmp = tda1004x_set_frequency(i2c, tda_state, fe_params)) < 0)
-		return tmp;
+	if (state->demod_type == TDA1004X_DEMOD_TDA10046) {
+		// setup auto offset
+		tda1004x_write_mask(state, TDA1004X_AUTO, 0x10, 0x10);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x80, 0);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0xC0, 0);
 
-        // hardcoded to use auto as much as possible
-        fe_params->u.ofdm.code_rate_HP = FEC_AUTO;
-        fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_AUTO;
-        fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO;
+		// disable agc_conf[2]
+		tda1004x_write_mask(state, TDA10046H_AGC_CONF, 4, 0);
+	}
+
+	// set frequency
+	tda1004x_enable_tuner_i2c(state);
+	state->config->pll_set(fe, fe_params);
+	tda1004x_disable_tuner_i2c(state);
+
+	if (state->demod_type == TDA1004X_DEMOD_TDA10046)
+		tda1004x_write_mask(state, TDA10046H_AGC_CONF, 4, 4);
+
+	// Hardcoded to use auto as much as possible on the TDA10045 as it
+	// is very unreliable if AUTO mode is _not_ used.
+	if (state->demod_type == TDA1004X_DEMOD_TDA10045) {
+	fe_params->u.ofdm.code_rate_HP = FEC_AUTO;
+	fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_AUTO;
+	fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO;
+	}
 
 	// Set standard params.. or put them to auto
 	if ((fe_params->u.ofdm.code_rate_HP == FEC_AUTO) ||
 	    (fe_params->u.ofdm.code_rate_LP == FEC_AUTO) ||
 	    (fe_params->u.ofdm.constellation == QAM_AUTO) ||
 	    (fe_params->u.ofdm.hierarchy_information == HIERARCHY_AUTO)) {
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 1, 1);	// enable auto
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x03, 0);	// turn off constellation bits
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x60, 0);	// turn off hierarchy bits
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF2, 0x3f, 0);	// turn off FEC bits
+		tda1004x_write_mask(state, TDA1004X_AUTO, 1, 1);	// enable auto
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x03, 0);	// turn off constellation bits
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 0);	// turn off hierarchy bits
+		tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0x3f, 0);	// turn off FEC bits
 	} else {
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 1, 0);	// disable auto
+		tda1004x_write_mask(state, TDA1004X_AUTO, 1, 0);	// disable auto
 
 		// set HP FEC
 		tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_HP);
 		if (tmp < 0) return tmp;
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF2, 7, tmp);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF2, 7, tmp);
 
 		// set LP FEC
-		if (fe_params->u.ofdm.code_rate_LP != FEC_NONE) {
-			tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_LP);
-			if (tmp < 0) return tmp;
-			tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF2, 0x38, tmp << 3);
-		}
+		tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_LP);
+		if (tmp < 0) return tmp;
+		tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0x38, tmp << 3);
 
 		// set constellation
 		switch (fe_params->u.ofdm.constellation) {
 		case QPSK:
-			tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 3, 0);
+			tda1004x_write_mask(state, TDA1004X_IN_CONF1, 3, 0);
 			break;
 
 		case QAM_16:
-			tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 3, 1);
+			tda1004x_write_mask(state, TDA1004X_IN_CONF1, 3, 1);
 			break;
 
 		case QAM_64:
-			tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 3, 2);
+			tda1004x_write_mask(state, TDA1004X_IN_CONF1, 3, 2);
 			break;
 
 		default:
@@ -882,19 +671,19 @@
 		// set hierarchy
 		switch (fe_params->u.ofdm.hierarchy_information) {
 		case HIERARCHY_NONE:
-			tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x60, 0 << 5);
+			tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 0 << 5);
 			break;
 
 		case HIERARCHY_1:
-			tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x60, 1 << 5);
+			tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 1 << 5);
 			break;
 
 		case HIERARCHY_2:
-			tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x60, 2 << 5);
+			tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 2 << 5);
 			break;
 
 		case HIERARCHY_4:
-			tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x60, 3 << 5);
+			tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 3 << 5);
 			break;
 
 		default:
@@ -902,31 +691,27 @@
 		}
 	}
 
-        // set bandwidth
-        switch(tda_state->fe_type) {
-        case FE_TYPE_TDA10045H:
-                tda10045h_set_bandwidth(i2c, tda_state, fe_params->u.ofdm.bandwidth);
-                break;
-
-        case FE_TYPE_TDA10046H:
-                tda10046h_set_bandwidth(i2c, tda_state, fe_params->u.ofdm.bandwidth);
-                break;
-        }
-
-        // need to invert the inversion for TT TDA10046H
-        inversion = fe_params->inversion;
-        if (tda_state->fe_type == FE_TYPE_TDA10046H) {
-                inversion = inversion ? INVERSION_OFF : INVERSION_ON;
-        }
+	// set bandwidth
+	switch(state->demod_type) {
+	case TDA1004X_DEMOD_TDA10045:
+		tda10045h_set_bandwidth(state, fe_params->u.ofdm.bandwidth);
+		break;
+
+	case TDA1004X_DEMOD_TDA10046:
+		tda10046h_set_bandwidth(state, fe_params->u.ofdm.bandwidth);
+		break;
+	}
 
 	// set inversion
-        switch (inversion) {
+	inversion = fe_params->inversion;
+	if (state->config->invert) inversion = inversion ? INVERSION_OFF : INVERSION_ON;
+	switch (inversion) {
 	case INVERSION_OFF:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x20, 0);
+		tda1004x_write_mask(state, TDA1004X_CONFC1, 0x20, 0);
 		break;
 
 	case INVERSION_ON:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x20, 0x20);
+		tda1004x_write_mask(state, TDA1004X_CONFC1, 0x20, 0x20);
 		break;
 
 	default:
@@ -936,28 +721,28 @@
 	// set guard interval
 	switch (fe_params->u.ofdm.guard_interval) {
 	case GUARD_INTERVAL_1_32:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 2, 0);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x0c, 0 << 2);
+		tda1004x_write_mask(state, TDA1004X_AUTO, 2, 0);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 0 << 2);
 		break;
 
 	case GUARD_INTERVAL_1_16:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 2, 0);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x0c, 1 << 2);
+		tda1004x_write_mask(state, TDA1004X_AUTO, 2, 0);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 1 << 2);
 		break;
 
 	case GUARD_INTERVAL_1_8:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 2, 0);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x0c, 2 << 2);
+		tda1004x_write_mask(state, TDA1004X_AUTO, 2, 0);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 2 << 2);
 		break;
 
 	case GUARD_INTERVAL_1_4:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 2, 0);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x0c, 3 << 2);
+		tda1004x_write_mask(state, TDA1004X_AUTO, 2, 0);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 3 << 2);
 		break;
 
 	case GUARD_INTERVAL_AUTO:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 2, 2);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x0c, 0 << 2);
+		tda1004x_write_mask(state, TDA1004X_AUTO, 2, 2);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 0 << 2);
 		break;
 
 	default:
@@ -967,98 +752,92 @@
 	// set transmission mode
 	switch (fe_params->u.ofdm.transmission_mode) {
 	case TRANSMISSION_MODE_2K:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 4, 0);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x10, 0 << 4);
+		tda1004x_write_mask(state, TDA1004X_AUTO, 4, 0);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x10, 0 << 4);
 		break;
 
 	case TRANSMISSION_MODE_8K:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 4, 0);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x10, 1 << 4);
+		tda1004x_write_mask(state, TDA1004X_AUTO, 4, 0);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x10, 1 << 4);
 		break;
 
 	case TRANSMISSION_MODE_AUTO:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 4, 4);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF1, 0x10, 0);
+		tda1004x_write_mask(state, TDA1004X_AUTO, 4, 4);
+		tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x10, 0);
 		break;
 
 	default:
 		return -EINVAL;
 	}
 
-        // start the lock
-        switch(tda_state->fe_type) {
-        case FE_TYPE_TDA10045H:
-	tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 8, 8);
-	tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 8, 0);
-	dvb_delay(10);
-                break;
-
-        case FE_TYPE_TDA10046H:
-                tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 0x40, 0x40);
-                dvb_delay(10);
-                break;
-        }
+	// start the lock
+	switch(state->demod_type) {
+	case TDA1004X_DEMOD_TDA10045:
+		tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8);
+		tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 0);
+		msleep(10);
+		break;
+
+	case TDA1004X_DEMOD_TDA10046:
+		tda1004x_write_mask(state, TDA1004X_AUTO, 0x40, 0x40);
+		msleep(10);
+		break;
+	}
 
-	// done
 	return 0;
 }
 
-
-static int tda1004x_get_fe(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda_state, struct dvb_frontend_parameters *fe_params)
+static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_parameters *fe_params)
 {
-
+	struct tda1004x_state* state = fe->demodulator_priv;
 	dprintk("%s\n", __FUNCTION__);
 
 	// inversion status
 	fe_params->inversion = INVERSION_OFF;
-	if (tda1004x_read_byte(i2c, tda_state, TDA1004X_CONFC1) & 0x20) {
+	if (tda1004x_read_byte(state, TDA1004X_CONFC1) & 0x20) {
 		fe_params->inversion = INVERSION_ON;
 	}
-
-        // need to invert the inversion for TT TDA10046H
-        if (tda_state->fe_type == FE_TYPE_TDA10046H) {
-                fe_params->inversion = fe_params->inversion ? INVERSION_OFF : INVERSION_ON;
-        }
+	if (state->config->invert) fe_params->inversion = fe_params->inversion ? INVERSION_OFF : INVERSION_ON;
 
 	// bandwidth
-        switch(tda_state->fe_type) {
-        case FE_TYPE_TDA10045H:
-                switch (tda1004x_read_byte(i2c, tda_state, TDA10045H_WREF_LSB)) {
-	case 0x14:
-		fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
-		break;
-	case 0xdb:
-		fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
-		break;
-	case 0x4f:
-		fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
-		break;
-	}
-                break;
-
-        case FE_TYPE_TDA10046H:
-                switch (tda1004x_read_byte(i2c, tda_state, TDA10046H_TIME_WREF1)) {
-                case 0x60:
-                        fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
-                        break;
-                case 0x6e:
-                        fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
-                        break;
-                case 0x80:
-                        fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
-                        break;
-                }
-                break;
-        }
+	switch(state->demod_type) {
+	case TDA1004X_DEMOD_TDA10045:
+		switch (tda1004x_read_byte(state, TDA10045H_WREF_LSB)) {
+		case 0x14:
+			fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
+			break;
+		case 0xdb:
+			fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
+			break;
+		case 0x4f:
+			fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
+			break;
+		}
+		break;
+
+	case TDA1004X_DEMOD_TDA10046:
+		switch (tda1004x_read_byte(state, TDA10046H_TIME_WREF1)) {
+		case 0x60:
+			fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
+			break;
+		case 0x6e:
+			fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
+			break;
+		case 0x80:
+			fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
+			break;
+		}
+		break;
+	}
 
 	// FEC
 	fe_params->u.ofdm.code_rate_HP =
-	    tda1004x_decode_fec(tda1004x_read_byte(i2c, tda_state, TDA1004X_OUT_CONF2) & 7);
+	    tda1004x_decode_fec(tda1004x_read_byte(state, TDA1004X_OUT_CONF2) & 7);
 	fe_params->u.ofdm.code_rate_LP =
-	    tda1004x_decode_fec((tda1004x_read_byte(i2c, tda_state, TDA1004X_OUT_CONF2) >> 3) & 7);
+	    tda1004x_decode_fec((tda1004x_read_byte(state, TDA1004X_OUT_CONF2) >> 3) & 7);
 
 	// constellation
-	switch (tda1004x_read_byte(i2c, tda_state, TDA1004X_OUT_CONF1) & 3) {
+	switch (tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 3) {
 	case 0:
 		fe_params->u.ofdm.constellation = QPSK;
 		break;
@@ -1072,12 +851,12 @@
 
 	// transmission mode
 	fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
-	if (tda1004x_read_byte(i2c, tda_state, TDA1004X_OUT_CONF1) & 0x10) {
+	if (tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x10) {
 		fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
 	}
 
 	// guard interval
-	switch ((tda1004x_read_byte(i2c, tda_state, TDA1004X_OUT_CONF1) & 0x0c) >> 2) {
+	switch ((tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x0c) >> 2) {
 	case 0:
 		fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
 		break;
@@ -1093,7 +872,7 @@
 	}
 
 	// hierarchy
-	switch ((tda1004x_read_byte(i2c, tda_state, TDA1004X_OUT_CONF1) & 0x60) >> 5) {
+	switch ((tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x60) >> 5) {
 	case 0:
 		fe_params->u.ofdm.hierarchy_information = HIERARCHY_NONE;
 		break;
@@ -1108,125 +887,124 @@
 		break;
 	}
 
-	// done
 	return 0;
 }
 
-
-static int tda1004x_read_status(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda_state, fe_status_t * fe_status)
+static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status)
 {
+	struct tda1004x_state* state = fe->demodulator_priv;
 	int status;
-        int cber;
-        int vber;
+	int cber;
+	int vber;
 
 	dprintk("%s\n", __FUNCTION__);
 
 	// read status
-	status = tda1004x_read_byte(i2c, tda_state, TDA1004X_STATUS_CD);
+	status = tda1004x_read_byte(state, TDA1004X_STATUS_CD);
 	if (status == -1) {
 		return -EIO;
 	}
 
-        // decode
+	// decode
 	*fe_status = 0;
-        if (status & 4) *fe_status |= FE_HAS_SIGNAL;
-        if (status & 2) *fe_status |= FE_HAS_CARRIER;
-        if (status & 8) *fe_status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
-
-        // if we don't already have VITERBI (i.e. not LOCKED), see if the viterbi
-        // is getting anything valid
-        if (!(*fe_status & FE_HAS_VITERBI)) {
-                // read the CBER
-                cber = tda1004x_read_byte(i2c, tda_state, TDA1004X_CBER_LSB);
-                if (cber == -1) return -EIO;
-                status = tda1004x_read_byte(i2c, tda_state, TDA1004X_CBER_MSB);
-                if (status == -1) return -EIO;
-                cber |= (status << 8);
-                tda1004x_read_byte(i2c, tda_state, TDA1004X_CBER_RESET);
-
-                if (cber != 65535) {
-                        *fe_status |= FE_HAS_VITERBI;
-                }
-        }
-
-        // if we DO have some valid VITERBI output, but don't already have SYNC
-        // bytes (i.e. not LOCKED), see if the RS decoder is getting anything valid.
-        if ((*fe_status & FE_HAS_VITERBI) && (!(*fe_status & FE_HAS_SYNC))) {
-                // read the VBER
-                vber = tda1004x_read_byte(i2c, tda_state, TDA1004X_VBER_LSB);
-                if (vber == -1) return -EIO;
-                status = tda1004x_read_byte(i2c, tda_state, TDA1004X_VBER_MID);
-                if (status == -1) return -EIO;
-                vber |= (status << 8);
-                status = tda1004x_read_byte(i2c, tda_state, TDA1004X_VBER_MSB);
-                if (status == -1) return -EIO;
-                vber |= ((status << 16) & 0x0f);
-                tda1004x_read_byte(i2c, tda_state, TDA1004X_CVBER_LUT);
-
-                // if RS has passed some valid TS packets, then we must be
-                // getting some SYNC bytes
-                if (vber < 16632) {
-                        *fe_status |= FE_HAS_SYNC;
-                }
-        }
+	if (status & 4) *fe_status |= FE_HAS_SIGNAL;
+	if (status & 2) *fe_status |= FE_HAS_CARRIER;
+	if (status & 8) *fe_status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+
+	// if we don't already have VITERBI (i.e. not LOCKED), see if the viterbi
+	// is getting anything valid
+	if (!(*fe_status & FE_HAS_VITERBI)) {
+		// read the CBER
+		cber = tda1004x_read_byte(state, TDA1004X_CBER_LSB);
+		if (cber == -1) return -EIO;
+		status = tda1004x_read_byte(state, TDA1004X_CBER_MSB);
+		if (status == -1) return -EIO;
+		cber |= (status << 8);
+		tda1004x_read_byte(state, TDA1004X_CBER_RESET);
+
+		if (cber != 65535) {
+			*fe_status |= FE_HAS_VITERBI;
+		}
+	}
+
+	// if we DO have some valid VITERBI output, but don't already have SYNC
+	// bytes (i.e. not LOCKED), see if the RS decoder is getting anything valid.
+	if ((*fe_status & FE_HAS_VITERBI) && (!(*fe_status & FE_HAS_SYNC))) {
+		// read the VBER
+		vber = tda1004x_read_byte(state, TDA1004X_VBER_LSB);
+		if (vber == -1) return -EIO;
+		status = tda1004x_read_byte(state, TDA1004X_VBER_MID);
+		if (status == -1) return -EIO;
+		vber |= (status << 8);
+		status = tda1004x_read_byte(state, TDA1004X_VBER_MSB);
+		if (status == -1) return -EIO;
+		vber |= ((status << 16) & 0x0f);
+		tda1004x_read_byte(state, TDA1004X_CVBER_LUT);
+
+		// if RS has passed some valid TS packets, then we must be
+		// getting some SYNC bytes
+		if (vber < 16632) {
+			*fe_status |= FE_HAS_SYNC;
+		}
+	}
 
 	// success
 	dprintk("%s: fe_status=0x%x\n", __FUNCTION__, *fe_status);
 	return 0;
 }
 
-static int tda1004x_read_signal_strength(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda_state, u16 * signal)
+static int tda1004x_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
 {
+	struct tda1004x_state* state = fe->demodulator_priv;
 	int tmp;
-        int reg = 0;
+	int reg = 0;
 
 	dprintk("%s\n", __FUNCTION__);
 
-        // determine the register to use
-        switch(tda_state->fe_type) {
-        case FE_TYPE_TDA10045H:
-                reg = TDA10045H_S_AGC;
-                break;
-
-        case FE_TYPE_TDA10046H:
-                reg = TDA10046H_AGC_IF_LEVEL;
-                break;
-        }
+	// determine the register to use
+	switch(state->demod_type) {
+	case TDA1004X_DEMOD_TDA10045:
+		reg = TDA10045H_S_AGC;
+		break;
+
+	case TDA1004X_DEMOD_TDA10046:
+		reg = TDA10046H_AGC_IF_LEVEL;
+		break;
+	}
 
 	// read it
-        tmp = tda1004x_read_byte(i2c, tda_state, reg);
+	tmp = tda1004x_read_byte(state, reg);
 	if (tmp < 0)
 		return -EIO;
 
-	// done
 	*signal = (tmp << 8) | tmp;
 	dprintk("%s: signal=0x%x\n", __FUNCTION__, *signal);
 	return 0;
 }
 
-
-static int tda1004x_read_snr(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda_state, u16 * snr)
+static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr)
 {
+	struct tda1004x_state* state = fe->demodulator_priv;
 	int tmp;
 
 	dprintk("%s\n", __FUNCTION__);
 
 	// read it
-	tmp = tda1004x_read_byte(i2c, tda_state, TDA1004X_SNR);
+	tmp = tda1004x_read_byte(state, TDA1004X_SNR);
 	if (tmp < 0)
 		return -EIO;
-        if (tmp) {
-                tmp = 255 - tmp;
-        }
+	if (tmp) {
+		tmp = 255 - tmp;
+	}
 
-        // done
 	*snr = ((tmp << 8) | tmp);
 	dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr);
 	return 0;
 }
 
-static int tda1004x_read_ucblocks(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda_state, u32* ucblocks)
+static int tda1004x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
 {
+	struct tda1004x_state* state = fe->demodulator_priv;
 	int tmp;
 	int tmp2;
 	int counter;
@@ -1235,16 +1013,16 @@
 
 	// read the UCBLOCKS and reset
 	counter = 0;
-	tmp = tda1004x_read_byte(i2c, tda_state, TDA1004X_UNCOR);
+	tmp = tda1004x_read_byte(state, TDA1004X_UNCOR);
 	if (tmp < 0)
 		return -EIO;
-        tmp &= 0x7f;
+	tmp &= 0x7f;
 	while (counter++ < 5) {
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_UNCOR, 0x80, 0);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_UNCOR, 0x80, 0);
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_UNCOR, 0x80, 0);
+		tda1004x_write_mask(state, TDA1004X_UNCOR, 0x80, 0);
+		tda1004x_write_mask(state, TDA1004X_UNCOR, 0x80, 0);
+		tda1004x_write_mask(state, TDA1004X_UNCOR, 0x80, 0);
 
-		tmp2 = tda1004x_read_byte(i2c, tda_state, TDA1004X_UNCOR);
+		tmp2 = tda1004x_read_byte(state, TDA1004X_UNCOR);
 		if (tmp2 < 0)
 			return -EIO;
 		tmp2 &= 0x7f;
@@ -1252,7 +1030,6 @@
 			break;
 	}
 
-	// done
 	if (tmp != 0x7f) {
 		*ucblocks = tmp;
 	} else {
@@ -1262,278 +1039,189 @@
 	return 0;
 }
 
-static int tda1004x_read_ber(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda_state, u32* ber)
+static int tda1004x_read_ber(struct dvb_frontend* fe, u32* ber)
 {
-        int tmp;
+	struct tda1004x_state* state = fe->demodulator_priv;
+	int tmp;
 
 	dprintk("%s\n", __FUNCTION__);
 
 	// read it in
-        tmp = tda1004x_read_byte(i2c, tda_state, TDA1004X_CBER_LSB);
-        if (tmp < 0) return -EIO;
-        *ber = tmp << 1;
-        tmp = tda1004x_read_byte(i2c, tda_state, TDA1004X_CBER_MSB);
-        if (tmp < 0) return -EIO;
-        *ber |= (tmp << 9);
-        tda1004x_read_byte(i2c, tda_state, TDA1004X_CBER_RESET);
+	tmp = tda1004x_read_byte(state, TDA1004X_CBER_LSB);
+	if (tmp < 0) return -EIO;
+	*ber = tmp << 1;
+	tmp = tda1004x_read_byte(state, TDA1004X_CBER_MSB);
+	if (tmp < 0) return -EIO;
+	*ber |= (tmp << 9);
+	tda1004x_read_byte(state, TDA1004X_CBER_RESET);
 
-	// done
 	dprintk("%s: ber=0x%x\n", __FUNCTION__, *ber);
 	return 0;
 }
 
-static int tda1004x_sleep(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda_state)
-{
-	switch(tda_state->fe_type) {
-	case FE_TYPE_TDA10045H:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFADC1, 0x10, 0x10);
-		break;
-
-	case FE_TYPE_TDA10046H:
-		tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 1, 1);
-		break;
-	}
-
-	return 0;
-}
-
-
-static int tda1004x_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static int tda1004x_sleep(struct dvb_frontend* fe)
 {
-	int status = 0;
-	struct dvb_i2c_bus *i2c = fe->i2c;
-	struct tda1004x_state *tda_state = (struct tda1004x_state *) fe->data;
-
-	dprintk("%s: cmd=0x%x\n", __FUNCTION__, cmd);
-
-	switch (cmd) {
-	case FE_GET_INFO:
-                switch(tda_state->fe_type) {
-                case FE_TYPE_TDA10045H:
-        		memcpy(arg, &tda10045h_info, sizeof(struct dvb_frontend_info));
-                        break;
+	struct tda1004x_state* state = fe->demodulator_priv;
 
-                case FE_TYPE_TDA10046H:
-                        memcpy(arg, &tda10046h_info, sizeof(struct dvb_frontend_info));
-                        break;
-                }
-		break;
-
-	case FE_READ_STATUS:
-		return tda1004x_read_status(i2c, tda_state, (fe_status_t *) arg);
-
-	case FE_READ_BER:
-		return tda1004x_read_ber(i2c, tda_state, (u32 *) arg);
-
-	case FE_READ_SIGNAL_STRENGTH:
-		return tda1004x_read_signal_strength(i2c, tda_state, (u16 *) arg);
-
-	case FE_READ_SNR:
-		return tda1004x_read_snr(i2c, tda_state, (u16 *) arg);
-
-	case FE_READ_UNCORRECTED_BLOCKS:
-		return tda1004x_read_ucblocks(i2c, tda_state, (u32 *) arg);
-
-	case FE_SET_FRONTEND:
-		return tda1004x_set_fe(i2c, tda_state, (struct dvb_frontend_parameters*) arg);
-
-	case FE_GET_FRONTEND:
-		return tda1004x_get_fe(i2c, tda_state, (struct dvb_frontend_parameters*) arg);
-
-	case FE_SLEEP:
-		tda_state->initialised = 0;
-		return tda1004x_sleep(i2c, tda_state);
+	switch(state->demod_type) {
+	case TDA1004X_DEMOD_TDA10045:
+		tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0x10);
+			break;
 
-	case FE_INIT:
+	case TDA1004X_DEMOD_TDA10046:
+		tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1);
+			break;
+		}
+	state->initialised = 0;
 
-		// don't bother reinitialising
-		if (tda_state->initialised)
 			return 0;
+		}
 
-		// OK, perform initialisation
-                switch(tda_state->fe_type) {
-                case FE_TYPE_TDA10045H:
-                        status = tda10045h_init(i2c, tda_state);
-                        break;
-
-                case FE_TYPE_TDA10046H:
-                        status = tda10046h_init(i2c, tda_state);
-                        break;
-                }
-		if (status == 0)
-			tda_state->initialised = 1;
-		return status;
-
-	case FE_GET_TUNE_SETTINGS:
+static int tda1004x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
 	{
-		struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
 		fesettings->min_delay_ms = 800;
 		fesettings->step_size = 166667;
 		fesettings->max_drift = 166667*2;
 		return 0;
 	}
-	    
-	default:
-		return -EOPNOTSUPP;
-	}
 
-	return 0;
-}
+static void tda1004x_release(struct dvb_frontend* fe)
+{
+	struct tda1004x_state* state = (struct tda1004x_state*) fe->demodulator_priv;
+	kfree(state);
+	}
 
+static struct dvb_frontend_ops tda10045_ops;
 
-static int tda1004x_attach(struct dvb_i2c_bus *i2c, void **data)
+struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
+				     struct i2c_adapter* i2c)
 {
-        int tda1004x_address = -1;
-	int tuner_address = -1;
-        int fe_type = -1;
-        int tuner_type = -1;
-	struct tda1004x_state tda_state;
-	struct tda1004x_state* ptda_state;
-	struct i2c_msg tuner_msg = {.addr=0, .flags=0, .buf=NULL, .len=0 };
-        static u8 td1344_init[] = { 0x0b, 0xf5, 0x88, 0xab };
-        static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab };
-        static u8 td1316_init_tda10046h[] = { 0x0b, 0xf5, 0x80, 0xab };
-        int status;
+	struct tda1004x_state* state = NULL;
 
-	dprintk("%s\n", __FUNCTION__);
-
-        // probe for tda10045h
-        if (tda1004x_address == -1) {
-                tda_state.tda1004x_address = 0x08;
-	if (tda1004x_read_byte(i2c, &tda_state, TDA1004X_CHIPID) == 0x25) {
-                        tda1004x_address = 0x08;
-                        fe_type = FE_TYPE_TDA10045H;
-                printk("tda1004x: Detected Philips TDA10045H.\n");
-        }
-        }
-
-        // probe for tda10046h
-        if (tda1004x_address == -1) {
-                tda_state.tda1004x_address = 0x08;
-                if (tda1004x_read_byte(i2c, &tda_state, TDA1004X_CHIPID) == 0x46) {
-                        tda1004x_address = 0x08;
-                        fe_type = FE_TYPE_TDA10046H;
-                        printk("tda1004x: Detected Philips TDA10046H.\n");
-                }
-        }
-
-        // did we find a frontend?
-        if (tda1004x_address == -1) {
-		return -ENODEV;
-        }
-
-        // enable access to the tuner
-	tda1004x_enable_tuner_i2c(i2c, &tda_state);
-
-        // check for a TD1344 first
-        if (tuner_address == -1) {
-                tuner_msg.addr = 0x61;
-	tuner_msg.buf = td1344_init;
-	tuner_msg.len = sizeof(td1344_init);
-	if (i2c->xfer(i2c, &tuner_msg, 1) == 1) {
-                dvb_delay(1);
-                        tuner_address = 0x61;
-                        tuner_type = TUNER_TYPE_TD1344;
-                        printk("tda1004x: Detected Philips TD1344 tuner.\n");
-                }
-        }
-
-        // OK, try a TD1316 on address 0x63
-        if (tuner_address == -1) {
-                tuner_msg.addr = 0x63;
-                tuner_msg.buf = td1316_init;
-                tuner_msg.len = sizeof(td1316_init);
-                if (i2c->xfer(i2c, &tuner_msg, 1) == 1) {
-                        dvb_delay(1);
-                        tuner_address = 0x63;
-                        tuner_type = TUNER_TYPE_TD1316;
-                        printk("tda1004x: Detected Philips TD1316 tuner.\n");
-                }
-        }
-
-        // OK, TD1316 again, on address 0x60 (TDA10046H)
-        if (tuner_address == -1) {
-                tuner_msg.addr = 0x60;
-                tuner_msg.buf = td1316_init_tda10046h;
-                tuner_msg.len = sizeof(td1316_init_tda10046h);
-                if (i2c->xfer(i2c, &tuner_msg, 1) == 1) {
-                        dvb_delay(1);
-                        tuner_address = 0x60;
-                        tuner_type = TUNER_TYPE_TD1316;
-                        printk("tda1004x: Detected Philips TD1316 tuner.\n");
-		}
-	}
-	tda1004x_disable_tuner_i2c(i2c, &tda_state);
+	/* allocate memory for the internal state */
+	state = (struct tda1004x_state*) kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
+	if (state == NULL) goto error;
 
-	// did we find a tuner?
-	if (tuner_address == -1) {
-		printk("tda1004x: Detected, but with unknown tuner.\n");
-		return -ENODEV;
-	}
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &tda10045_ops, sizeof(struct dvb_frontend_ops));
+	state->initialised = 0;
+	state->demod_type = TDA1004X_DEMOD_TDA10045;
 
-        // create state
-        tda_state.tda1004x_address = tda1004x_address;
-        tda_state.fe_type = fe_type;
-	tda_state.tuner_address = tuner_address;
-        tda_state.tuner_type = tuner_type;
-	tda_state.initialised = 0;
+	/* check if the demod is there */
+	if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x25) goto error;
 
-        // upload firmware
-        if ((status = tda1004x_fwupload(i2c, &tda_state)) != 0) return status;
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
 
-	// create the real state we'll be passing about
-	if ((ptda_state = (struct tda1004x_state*) kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL)) == NULL) {
-		return -ENOMEM;
+error:
+	if (state) kfree(state);
+	return NULL;
 	}
-	memcpy(ptda_state, &tda_state, sizeof(struct tda1004x_state));
-	*data = ptda_state;
 
-	// register
-        switch(tda_state.fe_type) {
-        case FE_TYPE_TDA10045H:
-		return dvb_register_frontend(tda1004x_ioctl, i2c, ptda_state, &tda10045h_info);
+static struct dvb_frontend_ops tda10046_ops;
+
+struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
+				     struct i2c_adapter* i2c)
+{
+	struct tda1004x_state* state = NULL;
 
-        case FE_TYPE_TDA10046H:
-		return dvb_register_frontend(tda1004x_ioctl, i2c, ptda_state, &tda10046h_info);
-        }
+	/* allocate memory for the internal state */
+	state = (struct tda1004x_state*) kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
+	if (state == NULL) goto error;
 
-        // should not get here
-        return -EINVAL;
-}
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
+	state->initialised = 0;
+	state->demod_type = TDA1004X_DEMOD_TDA10046;
 
+	/* check if the demod is there */
+	if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) goto error;
 
-static
-void tda1004x_detach(struct dvb_i2c_bus *i2c, void *data)
-{
-	dprintk("%s\n", __FUNCTION__);
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
 
-	kfree(data);
-	dvb_unregister_frontend(tda1004x_ioctl, i2c);
-}
+error:
+	if (state) kfree(state);
+	return NULL;
+		}
 
+static struct dvb_frontend_ops tda10045_ops = {
 
-static
-int __init init_tda1004x(void)
-{
-	return dvb_register_i2c_device(THIS_MODULE, tda1004x_attach, tda1004x_detach);
-}
+	.info = {
+		.name = "Philips TDA10045H DVB-T",
+		.type = FE_OFDM,
+		.frequency_min = 51000000,
+		.frequency_max = 858000000,
+		.frequency_stepsize = 166667,
+		.caps =
+		    FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+		    FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+		    FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+		    FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
+	},
+
+	.release = tda1004x_release,
+
+	.init = tda10045_init,
+	.sleep = tda1004x_sleep,
+
+	.set_frontend = tda1004x_set_fe,
+	.get_frontend = tda1004x_get_fe,
+	.get_tune_settings = tda1004x_get_tune_settings,
+
+	.read_status = tda1004x_read_status,
+	.read_ber = tda1004x_read_ber,
+	.read_signal_strength = tda1004x_read_signal_strength,
+	.read_snr = tda1004x_read_snr,
+	.read_ucblocks = tda1004x_read_ucblocks,
+};
 
+static struct dvb_frontend_ops tda10046_ops = {
 
-static
-void __exit exit_tda1004x(void)
-{
-	dvb_unregister_i2c_device(tda1004x_attach);
-}
+	.info = {
+		.name = "Philips TDA10046H DVB-T",
+		.type = FE_OFDM,
+		.frequency_min = 51000000,
+		.frequency_max = 858000000,
+		.frequency_stepsize = 166667,
+		.caps =
+		    FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+		    FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+		    FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+		    FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
+	},
+
+	.release = tda1004x_release,
+
+	.init = tda10046_init,
+	.sleep = tda1004x_sleep,
+
+	.set_frontend = tda1004x_set_fe,
+	.get_frontend = tda1004x_get_fe,
+	.get_tune_settings = tda1004x_get_tune_settings,
+
+	.read_status = tda1004x_read_status,
+	.read_ber = tda1004x_read_ber,
+	.read_signal_strength = tda1004x_read_signal_strength,
+	.read_snr = tda1004x_read_snr,
+	.read_ucblocks = tda1004x_read_ucblocks,
+};
 
-module_init(init_tda1004x);
-module_exit(exit_tda1004x);
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
 
-MODULE_DESCRIPTION("Philips TDA10045H & TDA10046H DVB-T Frontend");
+MODULE_DESCRIPTION("Philips TDA10045H & TDA10046H DVB-T Demodulator");
 MODULE_AUTHOR("Andrew de Quincey & Robert Schlabbach");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(tda1004x_debug, "i");
-MODULE_PARM_DESC(tda1004x_debug, "enable verbose debug messages");
-
-MODULE_PARM(tda1004x_firmware, "s");
-MODULE_PARM_DESC(tda1004x_firmware, "Where to find the firmware file");
+EXPORT_SYMBOL(tda10045_attach);
+EXPORT_SYMBOL(tda10046_attach);
+EXPORT_SYMBOL(tda1004x_write_byte);
diff -Nru a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/tda1004x.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,56 @@
+  /*
+     Driver for Philips tda1004xh OFDM Frontend
+
+     (c) 2004 Andrew de Quincey
+
+     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.
+
+   */
+
+#ifndef TDA1004X_H
+#define TDA1004X_H
+
+#include <linux/dvb/frontend.h>
+#include <linux/firmware.h>
+
+struct tda1004x_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* does the "inversion" need inverted? */
+	u8 invert:1;
+
+	/* Does the OCLK signal need inverted? */
+	u8 invert_oclk:1;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+
+	/* request firmware for device */
+	int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
+};
+
+extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
+					    struct i2c_adapter* i2c);
+
+extern struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
+					    struct i2c_adapter* i2c);
+
+extern int tda1004x_write_byte(struct dvb_frontend* fe, int reg, int data);
+
+#endif // TDA1004X_H
diff -Nru a/drivers/media/dvb/frontends/tda8083.c b/drivers/media/dvb/frontends/tda8083.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/tda8083.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,490 @@
+/*
+    Driver for Philips TDA8083 based QPSK Demodulator
+
+    Copyright (C) 2001 Convergence Integrated Media GmbH
+
+    written by Ralph Metzler <ralph@convergence.de>
+
+    adoption to the new DVB frontend API and diagnostic ioctl's
+    by Holger Waechtler <holger@convergence.de>
+
+    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.
+
+*/
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include "dvb_frontend.h"
+#include "tda8083.h"
+
+
+struct tda8083_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct tda8083_config* config;
+
+	struct dvb_frontend frontend;
+};
+
+static int debug;
+#define dprintk(args...) \
+	do { \
+		if (debug) printk(KERN_DEBUG "tda8083: " args); \
+	} while (0)
+
+
+static u8 tda8083_init_tab [] = {
+	0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea,
+	0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10,
+	0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8,
+	0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00,
+	0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00
+};
+
+
+static int tda8083_writereg (struct tda8083_state* state, u8 reg, u8 data)
+{
+	int ret;
+	u8 buf [] = { reg, data };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
+
+        ret = i2c_transfer(state->i2c, &msg, 1);
+
+        if (ret != 1)
+                dprintk ("%s: writereg error (reg %02x, ret == %i)\n",
+			__FUNCTION__, reg, ret);
+
+        return (ret != 1) ? -1 : 0;
+}
+
+
+static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len)
+{
+	int ret;
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = &reg1, .len = 1 },
+			   { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } };
+
+	ret = i2c_transfer(state->i2c, msg, 2);
+
+	if (ret != 2)
+		dprintk ("%s: readreg error (reg %02x, ret == %i)\n",
+			__FUNCTION__, reg1, ret);
+
+        return ret == 2 ? 0 : -1;
+}
+
+
+static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg)
+{
+	u8 val;
+
+	tda8083_readregs (state, reg, &val, 1);
+
+	return val;
+}
+
+
+
+static int tda8083_set_inversion (struct tda8083_state* state, fe_spectral_inversion_t inversion)
+{
+	/*  XXX FIXME: implement other modes than FEC_AUTO */
+	if (inversion == INVERSION_AUTO)
+		return 0;
+
+	return -EINVAL;
+}
+
+
+static int tda8083_set_fec (struct tda8083_state* state, fe_code_rate_t fec)
+{
+	if (fec == FEC_AUTO)
+		return tda8083_writereg (state, 0x07, 0xff);
+
+	if (fec >= FEC_1_2 && fec <= FEC_8_9)
+		return tda8083_writereg (state, 0x07, 1 << (FEC_8_9 - fec));
+
+	return -EINVAL;
+}
+
+
+static fe_code_rate_t tda8083_get_fec (struct tda8083_state* state)
+{
+	u8 index;
+	static fe_code_rate_t fec_tab [] = { FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
+				       FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8 };
+
+	index = tda8083_readreg(state, 0x0e) & 0x07;
+
+	return fec_tab [index];
+}
+
+
+static int tda8083_set_symbolrate (struct tda8083_state* state, u32 srate)
+{
+        u32 ratio;
+	u32 tmp;
+	u8 filter;
+
+	if (srate > 32000000)
+                srate = 32000000;
+        if (srate < 500000)
+                srate = 500000;
+
+	filter = 0;
+	if (srate < 24000000)
+		filter = 2;
+	if (srate < 16000000)
+		filter = 3;
+
+	tmp = 31250 << 16;
+	ratio = tmp / srate;
+
+	tmp = (tmp % srate) << 8;
+	ratio = (ratio << 8) + tmp / srate;
+
+	tmp = (tmp % srate) << 8;
+	ratio = (ratio << 8) + tmp / srate;
+
+	dprintk("tda8083: ratio == %08x\n", (unsigned int) ratio);
+
+	tda8083_writereg (state, 0x05, filter);
+	tda8083_writereg (state, 0x02, (ratio >> 16) & 0xff);
+	tda8083_writereg (state, 0x03, (ratio >>  8) & 0xff);
+	tda8083_writereg (state, 0x04, (ratio      ) & 0xff);
+
+	tda8083_writereg (state, 0x00, 0x3c);
+	tda8083_writereg (state, 0x00, 0x04);
+
+	return 1;
+}
+
+
+static void tda8083_wait_diseqc_fifo (struct tda8083_state* state, int timeout)
+{
+	unsigned long start = jiffies;
+
+	while (jiffies - start < timeout &&
+               !(tda8083_readreg(state, 0x02) & 0x80))
+	{
+		msleep(50);
+	};
+}
+
+static int tda8083_set_tone (struct tda8083_state* state, fe_sec_tone_mode_t tone)
+{
+	tda8083_writereg (state, 0x26, 0xf1);
+
+	switch (tone) {
+	case SEC_TONE_OFF:
+		return tda8083_writereg (state, 0x29, 0x00);
+	case SEC_TONE_ON:
+		return tda8083_writereg (state, 0x29, 0x80);
+	default:
+		return -EINVAL;
+	};
+}
+
+
+static int tda8083_set_voltage (struct tda8083_state* state, fe_sec_voltage_t voltage)
+{
+	switch (voltage) {
+	case SEC_VOLTAGE_13:
+		return tda8083_writereg (state, 0x20, 0x00);
+	case SEC_VOLTAGE_18:
+		return tda8083_writereg (state, 0x20, 0x11);
+	default:
+		return -EINVAL;
+	};
+}
+
+static int tda8083_send_diseqc_burst (struct tda8083_state* state, fe_sec_mini_cmd_t burst)
+{
+	switch (burst) {
+	case SEC_MINI_A:
+		tda8083_writereg (state, 0x29, (5 << 2));  /* send burst A */
+		break;
+	case SEC_MINI_B:
+		tda8083_writereg (state, 0x29, (7 << 2));  /* send B */
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	tda8083_wait_diseqc_fifo (state, 100);
+
+	return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+static int tda8083_send_diseqc_msg (struct dvb_frontend* fe,
+				    struct dvb_diseqc_master_cmd *m)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+	int i;
+
+	tda8083_writereg (state, 0x29, (m->msg_len - 3) | (1 << 2)); /* enable */
+
+	for (i=0; i<m->msg_len; i++)
+		tda8083_writereg (state, 0x23 + i, m->msg[i]);
+
+	tda8083_writereg (state, 0x29, (m->msg_len - 3) | (3 << 2)); /* send!! */
+
+	tda8083_wait_diseqc_fifo (state, 100);
+
+	return 0;
+}
+
+static int tda8083_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	u8 signal = ~tda8083_readreg (state, 0x01);
+	u8 sync = tda8083_readreg (state, 0x02);
+
+	*status = 0;
+
+	if (signal > 10)
+		*status |= FE_HAS_SIGNAL;
+
+	if (sync & 0x01)
+		*status |= FE_HAS_CARRIER;
+
+	if (sync & 0x02)
+		*status |= FE_HAS_VITERBI;
+
+	if (sync & 0x10)
+		*status |= FE_HAS_SYNC;
+
+	if ((sync & 0x1f) == 0x1f)
+		*status |= FE_HAS_LOCK;
+
+	return 0;
+}
+
+static int tda8083_read_signal_strength(struct dvb_frontend* fe, u16* strength)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	u8 signal = ~tda8083_readreg (state, 0x01);
+	*strength = (signal << 8) | signal;
+
+	return 0;
+}
+
+static int tda8083_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	u8 _snr = tda8083_readreg (state, 0x08);
+	*snr = (_snr << 8) | _snr;
+
+	return 0;
+}
+
+static int tda8083_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	state->config->pll_set(fe, p);
+	tda8083_set_inversion (state, p->inversion);
+	tda8083_set_fec (state, p->u.qpsk.fec_inner);
+	tda8083_set_symbolrate (state, p->u.qpsk.symbol_rate);
+
+	tda8083_writereg (state, 0x00, 0x3c);
+	tda8083_writereg (state, 0x00, 0x04);
+
+	return 0;
+}
+
+static int tda8083_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	/*  FIXME: get symbolrate & frequency offset...*/
+	/*p->frequency = ???;*/
+	p->inversion = (tda8083_readreg (state, 0x0e) & 0x80) ?
+			INVERSION_ON : INVERSION_OFF;
+	p->u.qpsk.fec_inner = tda8083_get_fec (state);
+	/*p->u.qpsk.symbol_rate = tda8083_get_symbolrate (state);*/
+
+	return 0;
+}
+
+static int tda8083_sleep(struct dvb_frontend* fe)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	tda8083_writereg (state, 0x00, 0x02);
+	return 0;
+}
+
+static int tda8083_init(struct dvb_frontend* fe)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+	int i;
+
+	for (i=0; i<44; i++)
+		tda8083_writereg (state, i, tda8083_init_tab[i]);
+
+	if (state->config->pll_init) state->config->pll_init(fe);
+
+	tda8083_writereg (state, 0x00, 0x3c);
+	tda8083_writereg (state, 0x00, 0x04);
+
+	return 0;
+}
+
+static int tda8083_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	tda8083_send_diseqc_burst (state, burst);
+	tda8083_writereg (state, 0x00, 0x3c);
+	tda8083_writereg (state, 0x00, 0x04);
+
+	return 0;
+}
+
+static int tda8083_diseqc_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	tda8083_set_tone (state, tone);
+	tda8083_writereg (state, 0x00, 0x3c);
+	tda8083_writereg (state, 0x00, 0x04);
+
+	return 0;
+}
+
+static int tda8083_diseqc_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+
+	tda8083_set_voltage (state, voltage);
+	tda8083_writereg (state, 0x00, 0x3c);
+	tda8083_writereg (state, 0x00, 0x04);
+
+	return 0;
+}
+
+static void tda8083_release(struct dvb_frontend* fe)
+{
+	struct tda8083_state* state = (struct tda8083_state*) fe->demodulator_priv;
+	kfree(state);
+}
+
+static struct dvb_frontend_ops tda8083_ops;
+
+struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
+				    struct i2c_adapter* i2c)
+{
+	struct tda8083_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct tda8083_state*) kmalloc(sizeof(struct tda8083_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &tda8083_ops, sizeof(struct dvb_frontend_ops));
+
+	/* check if the demod is there */
+	if ((tda8083_readreg(state, 0x00)) != 0x05) goto error;
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops tda8083_ops = {
+
+	.info = {
+		.name			= "Philips TDA8083 DVB-S",
+		.type			= FE_QPSK,
+		.frequency_min		= 950000,     /* FIXME: guessed! */
+		.frequency_max		= 1400000,    /* FIXME: guessed! */
+		.frequency_stepsize	= 125,   /* kHz for QPSK frontends */
+	/*      .frequency_tolerance	= ???,*/
+		.symbol_rate_min	= 1000000,   /* FIXME: guessed! */
+		.symbol_rate_max	= 45000000,  /* FIXME: guessed! */
+	/*      .symbol_rate_tolerance	= ???,*/
+		.caps = FE_CAN_INVERSION_AUTO |
+			FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
+			FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
+			FE_CAN_QPSK | FE_CAN_MUTE_TS
+	},
+
+	.release = tda8083_release,
+
+	.init = tda8083_init,
+	.sleep = tda8083_sleep,
+
+	.set_frontend = tda8083_set_frontend,
+	.get_frontend = tda8083_get_frontend,
+
+	.read_status = tda8083_read_status,
+	.read_signal_strength = tda8083_read_signal_strength,
+	.read_snr = tda8083_read_snr,
+
+	.diseqc_send_master_cmd = tda8083_send_diseqc_msg,
+     	.diseqc_send_burst = tda8083_diseqc_send_burst,
+     	.set_tone = tda8083_diseqc_set_tone,
+     	.set_voltage = tda8083_diseqc_set_voltage,
+};
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
+
+MODULE_DESCRIPTION("Philips TDA8083 DVB-S Demodulator");
+MODULE_AUTHOR("Ralph Metzler, Holger Waechtler");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(tda8083_attach);
diff -Nru a/drivers/media/dvb/frontends/tda8083.h b/drivers/media/dvb/frontends/tda8083.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/tda8083.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,45 @@
+/*
+    Driver for Grundig 29504-491, a Philips TDA8083 based QPSK Frontend
+
+    Copyright (C) 2001 Convergence Integrated Media GmbH
+
+    written by Ralph Metzler <ralph@convergence.de>
+
+    adoption to the new DVB frontend API and diagnostic ioctl's
+    by Holger Waechtler <holger@convergence.de>
+
+    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.
+
+*/
+
+#ifndef TDA8083_H
+#define TDA8083_H
+
+#include <linux/dvb/frontend.h>
+
+struct tda8083_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
+					   struct i2c_adapter* i2c);
+
+#endif // TDA8083_H
diff -Nru a/drivers/media/dvb/frontends/tda80xx.c b/drivers/media/dvb/frontends/tda80xx.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/tda80xx.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,749 @@
+/*
+ * tda80xx.c
+ *
+ * Philips TDA8044 / TDA8083 QPSK demodulator driver
+ *
+ * Copyright (C) 2001 Felix Domke <tmbinc@elitedvb.net>
+ * Copyright (C) 2002-2004 Andreas Oberritter <obi@linuxtv.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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/config.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/threads.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <asm/div64.h>
+
+#include "dvb_frontend.h"
+#include "tda80xx.h"
+
+enum {
+	ID_TDA8044 = 0x04,
+	ID_TDA8083 = 0x05,
+};
+
+
+struct tda80xx_state {
+
+	struct i2c_adapter* i2c;
+
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct tda80xx_config* config;
+
+	struct dvb_frontend frontend;
+
+	u32 clk;
+	int afc_loop;
+	struct work_struct worklet;
+	fe_code_rate_t code_rate;
+	fe_spectral_inversion_t spectral_inversion;
+	fe_status_t status;
+	u8 id;
+};
+
+static int debug = 1;
+#define dprintk	if (debug) printk
+
+static u8 tda8044_inittab_pre[] = {
+	0x02, 0x00, 0x6f, 0xb5, 0x86, 0x22, 0x00, 0xea,
+	0x30, 0x42, 0x98, 0x68, 0x70, 0x42, 0x99, 0x58,
+	0x95, 0x10, 0xf5, 0xe7, 0x93, 0x0b, 0x15, 0x68,
+	0x9a, 0x90, 0x61, 0x80, 0x00, 0xe0, 0x40, 0x00,
+	0x0f, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00
+};
+
+static u8 tda8044_inittab_post[] = {
+	0x04, 0x00, 0x6f, 0xb5, 0x86, 0x22, 0x00, 0xea,
+	0x30, 0x42, 0x98, 0x68, 0x70, 0x42, 0x99, 0x50,
+	0x95, 0x10, 0xf5, 0xe7, 0x93, 0x0b, 0x15, 0x68,
+	0x9a, 0x90, 0x61, 0x80, 0x00, 0xe0, 0x40, 0x6c,
+	0x0f, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00
+};
+
+static u8 tda8083_inittab[] = {
+	0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea,
+	0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10,
+	0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8,
+	0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00,
+	0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00
+};
+
+static __inline__ u32 tda80xx_div(u32 a, u32 b)
+{
+	return (a + (b / 2)) / b;
+}
+
+static __inline__ u32 tda80xx_gcd(u32 a, u32 b)
+{
+	u32 r;
+
+	while ((r = a % b)) {
+		a = b;
+		b = r;
+	}
+
+	return b;
+}
+
+static int tda80xx_read(struct tda80xx_state* state, u8 reg, u8 *buf, u8 len)
+{
+	int ret;
+	struct i2c_msg msg[] = { { .addr = state->config->demod_address, .flags = 0, .buf = &reg, .len = 1 },
+			  { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = buf, .len = len } };
+
+	ret = i2c_transfer(state->i2c, msg, 2);
+
+	if (ret != 2)
+		dprintk("%s: readreg error (reg %02x, ret == %i)\n",
+				__FUNCTION__, reg, ret);
+
+	mdelay(10);
+
+	return (ret == 2) ? 0 : -EREMOTEIO;
+}
+
+static int tda80xx_write(struct tda80xx_state* state, u8 reg, const u8 *buf, u8 len)
+{
+	int ret;
+	u8 wbuf[len + 1];
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = wbuf, .len = len + 1 };
+
+	wbuf[0] = reg;
+	memcpy(&wbuf[1], buf, len);
+
+	ret = i2c_transfer(state->i2c, &msg, 1);
+
+	if (ret != 1)
+		dprintk("%s: i2c xfer error (ret == %i)\n", __FUNCTION__, ret);
+
+	mdelay(10);
+
+	return (ret == 1) ? 0 : -EREMOTEIO;
+}
+
+static __inline__ u8 tda80xx_readreg(struct tda80xx_state* state, u8 reg)
+{
+	u8 val;
+
+	tda80xx_read(state, reg, &val, 1);
+
+	return val;
+}
+
+static __inline__ int tda80xx_writereg(struct tda80xx_state* state, u8 reg, u8 data)
+{
+	return tda80xx_write(state, reg, &data, 1);
+}
+
+static int tda80xx_set_parameters(struct tda80xx_state* state,
+				  fe_spectral_inversion_t inversion,
+				  u32 symbol_rate,
+				  fe_code_rate_t fec_inner)
+{
+	u8 buf[15];
+	u64 ratio;
+	u32 clk;
+	u32 k;
+	u32 sr = symbol_rate;
+	u32 gcd;
+	u8 scd;
+
+	if (symbol_rate > (state->clk * 3) / 16)
+		scd = 0;
+	else if (symbol_rate > (state->clk * 3) / 32)
+		scd = 1;
+	else if (symbol_rate > (state->clk * 3) / 64)
+		scd = 2;
+	else
+		scd = 3;
+
+	clk = scd ? (state->clk / (scd * 2)) : state->clk;
+
+	/*
+	 * Viterbi decoder:
+	 * Differential decoding off
+	 * Spectral inversion unknown
+	 * QPSK modulation
+	 */
+	if (inversion == INVERSION_ON)
+		buf[0] = 0x60;
+	else if (inversion == INVERSION_OFF)
+		buf[0] = 0x20;
+	else
+		buf[0] = 0x00;
+
+	/*
+	 * CLK ratio:
+	 * system clock frequency is up to 64 or 96 MHz
+	 *
+	 * formula:
+	 * r = k * clk / symbol_rate
+	 *
+	 * k:	2^21 for caa 0..3,
+	 * 	2^20 for caa 4..5,
+	 * 	2^19 for caa 6..7
+	 */
+	if (symbol_rate <= (clk * 3) / 32)
+		k = (1 << 19);
+	else if (symbol_rate <= (clk * 3) / 16)
+		k = (1 << 20);
+	else
+		k = (1 << 21);
+
+	gcd = tda80xx_gcd(clk, sr);
+	clk /= gcd;
+	sr /= gcd;
+
+	gcd = tda80xx_gcd(k, sr);
+	k /= gcd;
+	sr /= gcd;
+
+	ratio = (u64)k * (u64)clk;
+	do_div(ratio, sr);
+
+	buf[1] = ratio >> 16;
+	buf[2] = ratio >> 8;
+	buf[3] = ratio;
+
+	/* nyquist filter roll-off factor 35% */
+	buf[4] = 0x20;
+
+	clk = scd ? (state->clk / (scd * 2)) : state->clk;
+
+	/* Anti Alias Filter */
+	if (symbol_rate < (clk * 3) / 64)
+		printk("tda80xx: unsupported symbol rate: %u\n", symbol_rate);
+	else if (symbol_rate <= clk / 16)
+		buf[4] |= 0x07;
+	else if (symbol_rate <= (clk * 3) / 32)
+		buf[4] |= 0x06;
+	else if (symbol_rate <= clk / 8)
+		buf[4] |= 0x05;
+	else if (symbol_rate <= (clk * 3) / 16)
+		buf[4] |= 0x04;
+	else if (symbol_rate <= clk / 4)
+		buf[4] |= 0x03;
+	else if (symbol_rate <= (clk * 3) / 8)
+		buf[4] |= 0x02;
+	else if (symbol_rate <= clk / 2)
+		buf[4] |= 0x01;
+	else
+		buf[4] |= 0x00;
+
+	/* Sigma Delta converter */
+	buf[5] = 0x00;
+
+	/* FEC: Possible puncturing rates */
+	if (fec_inner == FEC_NONE)
+		buf[6] = 0x00;
+	else if ((fec_inner >= FEC_1_2) && (fec_inner <= FEC_8_9))
+		buf[6] = (1 << (8 - fec_inner));
+	else if (fec_inner == FEC_AUTO)
+		buf[6] = 0xff;
+	else
+		return -EINVAL;
+
+	/* carrier lock detector threshold value */
+	buf[7] = 0x30;
+	/* AFC1: proportional part settings */
+	buf[8] = 0x42;
+	/* AFC1: integral part settings */
+	buf[9] = 0x98;
+	/* PD: Leaky integrator SCPC mode */
+	buf[10] = 0x28;
+	/* AFC2, AFC1 controls */
+	buf[11] = 0x30;
+	/* PD: proportional part settings */
+	buf[12] = 0x42;
+	/* PD: integral part settings */
+	buf[13] = 0x99;
+	/* AGC */
+	buf[14] = 0x50 | scd;
+
+	printk("symbol_rate=%u clk=%u\n", symbol_rate, clk);
+
+	return tda80xx_write(state, 0x01, buf, sizeof(buf));
+}
+
+static int tda80xx_set_clk(struct tda80xx_state* state)
+{
+	u8 buf[2];
+
+	/* CLK proportional part */
+	buf[0] = (0x06 << 5) | 0x08;	/* CMP[2:0], CSP[4:0] */
+	/* CLK integral part */
+	buf[1] = (0x04 << 5) | 0x1a;	/* CMI[2:0], CSI[4:0] */
+
+	return tda80xx_write(state, 0x17, buf, sizeof(buf));
+}
+
+#if 0
+static int tda80xx_set_scpc_freq_offset(struct tda80xx_state* state)
+{
+	/* a constant value is nonsense here imho */
+	return tda80xx_writereg(state, 0x22, 0xf9);
+}
+#endif
+
+static int tda80xx_close_loop(struct tda80xx_state* state)
+{
+	u8 buf[2];
+
+	/* PD: Loop closed, LD: lock detect enable, SCPC: Sweep mode - AFC1 loop closed */
+	buf[0] = 0x68;
+	/* AFC1: Loop closed, CAR Feedback: 8192 */
+	buf[1] = 0x70;
+
+	return tda80xx_write(state, 0x0b, buf, sizeof(buf));
+}
+
+static irqreturn_t tda80xx_irq(int irq, void *priv, struct pt_regs *pt)
+{
+	schedule_work(priv);
+
+	return IRQ_HANDLED;
+}
+
+static void tda80xx_read_status_int(struct tda80xx_state* state)
+{
+	u8 val;
+
+	static const fe_spectral_inversion_t inv_tab[] = {
+		INVERSION_OFF, INVERSION_ON
+	};
+
+	static const fe_code_rate_t fec_tab[] = {
+		FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
+		FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8,
+	};
+
+	val = tda80xx_readreg(state, 0x02);
+
+	state->status = 0;
+
+	if (val & 0x01) /* demodulator lock */
+		state->status |= FE_HAS_SIGNAL;
+	if (val & 0x02) /* clock recovery lock */
+		state->status |= FE_HAS_CARRIER;
+	if (val & 0x04) /* viterbi lock */
+		state->status |= FE_HAS_VITERBI;
+	if (val & 0x08) /* deinterleaver lock (packet sync) */
+		state->status |= FE_HAS_SYNC;
+	if (val & 0x10) /* derandomizer lock (frame sync) */
+		state->status |= FE_HAS_LOCK;
+	if (val & 0x20) /* frontend can not lock */
+		state->status |= FE_TIMEDOUT;
+
+	if ((state->status & (FE_HAS_CARRIER)) && (state->afc_loop)) {
+		printk("tda80xx: closing loop\n");
+		tda80xx_close_loop(state);
+		state->afc_loop = 0;
+	}
+
+	if (state->status & (FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK)) {
+		val = tda80xx_readreg(state, 0x0e);
+		state->code_rate = fec_tab[val & 0x07];
+		if (state->status & (FE_HAS_SYNC | FE_HAS_LOCK))
+			state->spectral_inversion = inv_tab[(val >> 7) & 0x01];
+		else
+			state->spectral_inversion = INVERSION_AUTO;
+	}
+	else {
+		state->code_rate = FEC_AUTO;
+	}
+}
+
+static void tda80xx_worklet(void *priv)
+{
+	struct tda80xx_state *state = priv;
+
+	tda80xx_writereg(state, 0x00, 0x04);
+	enable_irq(state->config->irq);
+
+	tda80xx_read_status_int(state);
+}
+
+static void tda80xx_wait_diseqc_fifo(struct tda80xx_state* state)
+{
+	size_t i;
+
+	for (i = 0; i < 100; i++) {
+		if (tda80xx_readreg(state, 0x02) & 0x80)
+			break;
+		msleep(10);
+	}
+}
+
+static int tda8044_init(struct dvb_frontend* fe)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+	int ret;
+
+	/*
+	 * this function is a mess...
+	 */
+
+	if ((ret = tda80xx_write(state, 0x00, tda8044_inittab_pre, sizeof(tda8044_inittab_pre))))
+		return ret;
+
+	tda80xx_writereg(state, 0x0f, 0x50);
+#if 1
+	tda80xx_writereg(state, 0x20, 0x8F);		/* FIXME */
+	tda80xx_writereg(state, 0x20, state->config->volt18setting);	/* FIXME */
+	//tda80xx_writereg(state, 0x00, 0x04);
+	tda80xx_writereg(state, 0x00, 0x0C);
+#endif
+	//tda80xx_writereg(state, 0x00, 0x08); /* Reset AFC1 loop filter */
+
+	tda80xx_write(state, 0x00, tda8044_inittab_post, sizeof(tda8044_inittab_post));
+
+	if (state->config->pll_init) {
+	   	tda80xx_writereg(state, 0x1c, 0x80);
+		state->config->pll_init(fe);
+		tda80xx_writereg(state, 0x1c, 0x00);
+	}
+
+	return 0;
+}
+
+static int tda8083_init(struct dvb_frontend* fe)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	tda80xx_write(state, 0x00, tda8083_inittab, sizeof(tda8083_inittab));
+
+	if (state->config->pll_init) {
+	   	tda80xx_writereg(state, 0x1c, 0x80);
+		state->config->pll_init(fe);
+		tda80xx_writereg(state, 0x1c, 0x00);
+	}
+
+	return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+static int tda80xx_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	switch (voltage) {
+	case SEC_VOLTAGE_13:
+		return tda80xx_writereg(state, 0x20, state->config->volt13setting);
+	case SEC_VOLTAGE_18:
+		return tda80xx_writereg(state, 0x20, state->config->volt18setting);
+	case SEC_VOLTAGE_OFF:
+		return tda80xx_writereg(state, 0x20, 0);
+	default:
+		return -EINVAL;
+	}
+}
+
+static int tda80xx_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	switch (tone) {
+	case SEC_TONE_OFF:
+		return tda80xx_writereg(state, 0x29, 0x00);
+	case SEC_TONE_ON:
+		return tda80xx_writereg(state, 0x29, 0x80);
+	default:
+		return -EINVAL;
+	}
+}
+
+static int tda80xx_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd)
+{
+   	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	if (cmd->msg_len > 6)
+		return -EINVAL;
+
+	tda80xx_writereg(state, 0x29, 0x08 | (cmd->msg_len - 3));
+	tda80xx_write(state, 0x23, cmd->msg, cmd->msg_len);
+	tda80xx_writereg(state, 0x29, 0x0c | (cmd->msg_len - 3));
+	tda80xx_wait_diseqc_fifo(state);
+
+	return 0;
+}
+
+static int tda80xx_send_diseqc_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t cmd)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	switch (cmd) {
+	case SEC_MINI_A:
+		tda80xx_writereg(state, 0x29, 0x14);
+		break;
+	case SEC_MINI_B:
+		tda80xx_writereg(state, 0x29, 0x1c);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	tda80xx_wait_diseqc_fifo(state);
+
+	return 0;
+}
+
+static int tda80xx_sleep(struct dvb_frontend* fe)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	tda80xx_writereg(state, 0x00, 0x02);	/* enter standby */
+
+	return 0;
+}
+
+static int tda80xx_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+   	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	tda80xx_writereg(state, 0x1c, 0x80);
+	state->config->pll_set(fe, p);
+	tda80xx_writereg(state, 0x1c, 0x00);
+
+	tda80xx_set_parameters(state, p->inversion, p->u.qpsk.symbol_rate, p->u.qpsk.fec_inner);
+	tda80xx_set_clk(state);
+	//tda80xx_set_scpc_freq_offset(state);
+	state->afc_loop = 1;
+
+	return 0;
+}
+
+static int tda80xx_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	if (!state->config->irq)
+		tda80xx_read_status_int(state);
+
+	p->inversion = state->spectral_inversion;
+	p->u.qpsk.fec_inner = state->code_rate;
+
+	return 0;
+}
+
+static int tda80xx_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	if (!state->config->irq)
+		tda80xx_read_status_int(state);
+	*status = state->status;
+
+	return 0;
+}
+
+static int tda80xx_read_ber(struct dvb_frontend* fe, u32* ber)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+	int ret;
+	u8 buf[3];
+
+	if ((ret = tda80xx_read(state, 0x0b, buf, sizeof(buf))))
+		return ret;
+
+	*ber = ((buf[0] & 0x1f) << 16) | (buf[1] << 8) | buf[2];
+
+	return 0;
+}
+
+static int tda80xx_read_signal_strength(struct dvb_frontend* fe, u16* strength)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	u8 gain = ~tda80xx_readreg(state, 0x01);
+	*strength = (gain << 8) | gain;
+
+	return 0;
+}
+
+static int tda80xx_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	u8 quality = tda80xx_readreg(state, 0x08);
+	*snr = (quality << 8) | quality;
+
+	return 0;
+}
+
+static int tda80xx_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	*ucblocks = tda80xx_readreg(state, 0x0f);
+	if (*ucblocks == 0xff)
+		*ucblocks = 0xffffffff;
+
+	return 0;
+}
+
+static int tda80xx_init(struct dvb_frontend* fe)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	switch(state->id) {
+	case ID_TDA8044:
+		return tda8044_init(fe);
+
+	case ID_TDA8083:
+		return tda8083_init(fe);
+	}
+	return 0;
+}
+
+static void tda80xx_release(struct dvb_frontend* fe)
+{
+	struct tda80xx_state* state = (struct tda80xx_state*) fe->demodulator_priv;
+
+	if (state->config->irq)
+		free_irq(state->config->irq, &state->worklet);
+
+	kfree(state);
+}
+
+static struct dvb_frontend_ops tda80xx_ops;
+
+struct dvb_frontend* tda80xx_attach(const struct tda80xx_config* config,
+				    struct i2c_adapter* i2c)
+{
+	struct tda80xx_state* state = NULL;
+	int ret;
+
+	/* allocate memory for the internal state */
+	state = (struct tda80xx_state*) kmalloc(sizeof(struct tda80xx_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &tda80xx_ops, sizeof(struct dvb_frontend_ops));
+	state->spectral_inversion = INVERSION_AUTO;
+	state->code_rate = FEC_AUTO;
+	state->status = 0;
+	state->afc_loop = 0;
+
+	/* check if the demod is there */
+	if (tda80xx_writereg(state, 0x89, 0x00) < 0) goto error;
+	state->id = tda80xx_readreg(state, 0x00);
+
+	switch (state->id) {
+	case ID_TDA8044:
+		state->clk = 96000000;
+		printk("tda80xx: Detected tda8044\n");
+		break;
+
+	case ID_TDA8083:
+		state->clk = 64000000;
+		printk("tda80xx: Detected tda8083\n");
+		break;
+
+	default:
+		goto error;
+	}
+
+	/* setup IRQ */
+	if (state->config->irq) {
+		INIT_WORK(&state->worklet, tda80xx_worklet, state);
+		if ((ret = request_irq(state->config->irq, tda80xx_irq, SA_ONESHOT, "tda80xx", &state->worklet)) < 0) {
+			printk(KERN_ERR "tda80xx: request_irq failed (%d)\n", ret);
+			goto error;
+		}
+	}
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops tda80xx_ops = {
+
+	.info = {
+		.name = "Philips TDA80xx DVB-S",
+		.type = FE_QPSK,
+		.frequency_min = 500000,
+		.frequency_max = 2700000,
+		.frequency_stepsize = 125,
+		.symbol_rate_min = 4500000,
+		.symbol_rate_max = 45000000,
+		.caps =	FE_CAN_INVERSION_AUTO |
+			FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
+			FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
+			FE_CAN_QPSK |
+			FE_CAN_MUTE_TS
+	},
+
+	.release = tda80xx_release,
+
+	.init = tda80xx_init,
+	.sleep = tda80xx_sleep,
+
+	.set_frontend = tda80xx_set_frontend,
+	.get_frontend = tda80xx_get_frontend,
+
+	.read_status = tda80xx_read_status,
+	.read_ber = tda80xx_read_ber,
+	.read_signal_strength = tda80xx_read_signal_strength,
+	.read_snr = tda80xx_read_snr,
+	.read_ucblocks = tda80xx_read_ucblocks,
+
+	.diseqc_send_master_cmd = tda80xx_send_diseqc_msg,
+     	.diseqc_send_burst = tda80xx_send_diseqc_burst,
+     	.set_tone = tda80xx_set_tone,
+     	.set_voltage = tda80xx_set_voltage,
+};
+
+module_param(debug, int, 0644);
+
+MODULE_DESCRIPTION("Philips TDA8044 / TDA8083 DVB-S Demodulator driver");
+MODULE_AUTHOR("Felix Domke, Andreas Oberritter");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(tda80xx_attach);
diff -Nru a/drivers/media/dvb/frontends/tda80xx.h b/drivers/media/dvb/frontends/tda80xx.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/tda80xx.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,51 @@
+/*
+ * tda80xx.c
+ *
+ * Philips TDA8044 / TDA8083 QPSK demodulator driver
+ *
+ * Copyright (C) 2001 Felix Domke <tmbinc@elitedvb.net>
+ * Copyright (C) 2002-2004 Andreas Oberritter <obi@linuxtv.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 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.
+ */
+
+#ifndef TDA80XX_H
+#define TDA80XX_H
+
+#include <linux/dvb/frontend.h>
+
+struct tda80xx_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* IRQ to use (0=>no IRQ used) */
+	u32 irq;
+
+	/* Register setting to use for 13v */
+	u8 volt13setting;
+
+	/* Register setting to use for 18v */
+	u8 volt18setting;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* tda80xx_attach(const struct tda80xx_config* config,
+					   struct i2c_adapter* i2c);
+
+#endif // TDA80XX_H
diff -Nru a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
--- a/drivers/media/dvb/frontends/ves1820.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/media/dvb/frontends/ves1820.c	2004-12-24 13:36:55 -08:00
@@ -1,6 +1,5 @@
 /* 
     VES1820  - Single Chip Cable Channel Receiver driver module
-               used on the the Siemens DVB-C cards
 
     Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
 
@@ -27,98 +26,34 @@
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/slab.h>
+#include <asm/div64.h>
 
 #include "dvb_frontend.h"
-#include "dvb_functions.h"
+#include "ves1820.h"
 
 
-#if 0
-#define dprintk(x...) printk(x)
-#else
-#define dprintk(x...)
-#endif
 
-#define MAX_UNITS 4
-static int pwm[MAX_UNITS] = { -1, -1, -1, -1 };
-static int verbose;
+struct ves1820_state {
+
+	struct i2c_adapter *i2c;
+
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct ves1820_config* config;
 
-/**
- *  since we need only a few bits to store internal state we don't allocate
- *  extra memory but use frontend->data as bitfield
- */
-
-#define SET_PWM(data,pwm) do { 		\
-	long d = (long)data;		\
-	d &= ~0xff; 			\
-	d |= pwm; 			\
-	data = (void *)d;		\
-} while (0)
-
-#define SET_REG0(data,reg0) do {	\
-	long d = (long)data;		\
-	d &= ~(0xff << 8); 		\
-	d |= reg0 << 8; 		\
-	data = (void *)d;		\
-} while (0)
-
-#define SET_TUNER(data,type) do {	\
-	long d = (long)data;		\
-	d &= ~(0xff << 16); 		\
-	d |= type << 16;		\
-	data = (void *)d;		\
-} while (0)
-
-#define SET_DEMOD_ADDR(data,type) do {	\
-	long d = (long)data;		\
-	d &= ~(0xff << 24); 		\
-	d |= type << 24;		\
-	data = (void *)d;		\
-} while (0)
-
-#define GET_PWM(data) ((u8) ((long) data & 0xff))
-#define GET_REG0(data) ((u8) (((long) data >> 8) & 0xff))
-#define GET_TUNER(data) ((u8) (((long) data >> 16) & 0xff))
-#define GET_DEMOD_ADDR(data) ((u8) (((long) data >> 24) & 0xff))
-
-#if defined(CONFIG_DBOX2)
-#define XIN 69600000UL
-#define DISABLE_INVERSION(reg0)		do { reg0 &= ~0x20; } while (0)
-#define ENABLE_INVERSION(reg0)		do { reg0 |= 0x20; } while (0)
-#define HAS_INVERSION(reg0)		(reg0 & 0x20)
-#else	/* PCI cards */
-#define XIN 57840000UL
-#define DISABLE_INVERSION(reg0)		do { reg0 |= 0x20; } while (0)
-#define ENABLE_INVERSION(reg0)		do { reg0 &= ~0x20; } while (0)
-#define HAS_INVERSION(reg0)		(!(reg0 & 0x20))
-#endif
-
-#define FIN (XIN >> 4)
-
-
-
-static struct dvb_frontend_info ves1820_info = {
-	.name = "VES1820 based DVB-C frontend",
-	.type = FE_QAM,
-	.frequency_stepsize = 62500,
-	.frequency_min = 51000000,
-	.frequency_max = 858000000,
-	.symbol_rate_min = (XIN/2)/64,     /* SACLK/64 == (XIN/2)/64 */
-	.symbol_rate_max = (XIN/2)/4,      /* SACLK/4 */
-#if 0
-	.frequency_tolerance = ???,
-	.symbol_rate_tolerance = ???,  /* ppm */  /* == 8% (spec p. 5) */
-	.notifier_delay = ?,
-#endif
-	.caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
-		FE_CAN_QAM_128 | FE_CAN_QAM_256 | 
-		FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO,
+	struct dvb_frontend frontend;
+
+	/* private demodulator data */
+	u8 reg0;
+	u8 pwm;
 };
 
 
+static int verbose;
 
-static u8 ves1820_inittab [] =
-{
-	0x69, 0x6A, 0x9B, 0x12, 0x12, 0x46, 0x26, 0x1A,
+static u8 ves1820_inittab[] = {
+	0x69, 0x6A, 0x93, 0x12, 0x12, 0x46, 0x26, 0x1A,
 	0x43, 0x6A, 0xAA, 0xAA, 0x1E, 0x85, 0x43, 0x20,
 	0xE0, 0x00, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
@@ -127,189 +62,123 @@
 	0x00, 0x00, 0x00, 0x00, 0x40
 };
 
-
-static int ves1820_writereg (struct dvb_frontend *fe, u8 reg, u8 data)
+static int ves1820_writereg(struct ves1820_state *state, u8 reg, u8 data)
 {
-	u8 addr = GET_DEMOD_ADDR(fe->data);
         u8 buf[] = { 0x00, reg, data };
-	struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 3 };
-	struct dvb_i2c_bus *i2c = fe->i2c;
+	struct i2c_msg msg = {.addr = state->config->demod_address,.flags = 0,.buf = buf,.len = 3 };
         int ret;
 
-	ret = i2c->xfer (i2c, &msg, 1);
+	ret = i2c_transfer(state->i2c, &msg, 1);
 
 	if (ret != 1)
-		printk("DVB: VES1820(%d): %s, writereg error "
-			"(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
-			fe->i2c->adapter->num, __FUNCTION__, reg, data, ret);
+		printk("ves1820: %s(): writereg error (reg == 0x%02x,"
+			"val == 0x%02x, ret == %i)\n", __FUNCTION__, reg, data, ret);
 
-	dvb_delay(10);
+	msleep(10);
 	return (ret != 1) ? -EREMOTEIO : 0;
 }
 
-
-static u8 ves1820_readreg (struct dvb_frontend *fe, u8 reg)
+static u8 ves1820_readreg(struct ves1820_state *state, u8 reg)
 {
 	u8 b0 [] = { 0x00, reg };
 	u8 b1 [] = { 0 };
-	u8 addr = GET_DEMOD_ADDR(fe->data);
-	struct i2c_msg msg [] = { { .addr = addr, .flags = 0, .buf = b0, .len = 2 },
-	                   { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-	struct dvb_i2c_bus *i2c = fe->i2c;
+	struct i2c_msg msg[] = {
+		{.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = 2},
+		{.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1}
+	};
 	int ret;
 
-	ret = i2c->xfer (i2c, msg, 2);
+	ret = i2c_transfer(state->i2c, msg, 2);
 
 	if (ret != 2)
-		printk("DVB: VES1820(%d): %s: readreg error (ret == %i)\n",
-				fe->i2c->adapter->num, __FUNCTION__, ret);
+		printk("ves1820: %s(): readreg error (reg == 0x%02x,"
+		"ret == %i)\n", __FUNCTION__, reg, ret);
 
 	return b1[0];
 }
 
 
-static int tuner_write (struct dvb_i2c_bus *i2c, u8 addr, u8 data [4])
+static int ves1820_setup_reg0(struct ves1820_state *state, u8 reg0, fe_spectral_inversion_t inversion)
 {
-        int ret;
-        struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = data, .len = 4 };
-
-        ret = i2c->xfer (i2c, &msg, 1);
-
-        if (ret != 1)
-                printk("DVB: VES1820(%d): %s: i/o error (ret == %i)\n",
-				i2c->adapter->num, __FUNCTION__, ret);
-
-        return (ret != 1) ? -EREMOTEIO : 0;
-}
-
-
-/**
- *   set up the downconverter frequency divisor for a
- *   reference clock comparision frequency of 62.5 kHz.
- */
-static int tuner_set_tv_freq (struct dvb_frontend *fe, u32 freq)
-{
-        u32 div, ifreq;
-	static u8 addr [] = { 0x61, 0x62 };
-	static u8 byte3 [] = { 0x8e, 0x85 };
-	int tuner_type = GET_TUNER(fe->data);
-        u8 buf [4];
-
-	if (tuner_type == 0xff)     /*  PLL not reachable over i2c ...  */
-		return 0;
-
-	if (strstr (fe->i2c->adapter->name, "Technotrend") ||
-	    strstr (fe->i2c->adapter->name, "TT-Budget"))
-		ifreq = 35937500;
-	else
-		ifreq = 36125000;
-
-	div = (freq + ifreq + 31250) / 62500;
-
-	buf[0] = (div >> 8) & 0x7f;
-	buf[1] = div & 0xff;
-	buf[2] = byte3[tuner_type];
-
-	if (tuner_type == 1) {
-		buf[2] |= (div >> 10) & 0x60;
-		buf[3] = (freq < 174000000 ? 0x88 :
-			  freq < 470000000 ? 0x84 : 0x81);
-	} else {
-		buf[3] = (freq < 174000000 ? 0xa1 :
-			  freq < 454000000 ? 0x92 : 0x34);
-	}
-
-        return tuner_write (fe->i2c, addr[tuner_type], buf);
-}
-
-
-static int ves1820_setup_reg0 (struct dvb_frontend *fe, u8 reg0,
-			fe_spectral_inversion_t inversion)
-{
-	reg0 |= GET_REG0(fe->data) & 0x62;
+	reg0 |= state->reg0 & 0x62;
 	
-	if (INVERSION_ON == inversion)
-		ENABLE_INVERSION(reg0);
-	else if (INVERSION_OFF == inversion)
-		DISABLE_INVERSION(reg0);
+	if (INVERSION_ON == inversion) {
+		if (!state->config->invert) reg0 |= 0x20;
+		else reg0 &= ~0x20;
 	
-	ves1820_writereg (fe, 0x00, reg0 & 0xfe);
-        ves1820_writereg (fe, 0x00, reg0 | 0x01);
+	} else if (INVERSION_OFF == inversion) {
 
-	/**
-	 *  check lock and toggle inversion bit if required...
-	 */
-	if (INVERSION_AUTO == inversion && !(ves1820_readreg (fe, 0x11) & 0x08)) {
-		mdelay(50);
-		if (!(ves1820_readreg (fe, 0x11) & 0x08)) {
-			reg0 ^= 0x20;
-			ves1820_writereg (fe, 0x00, reg0 & 0xfe);
-        		ves1820_writereg (fe, 0x00, reg0 | 0x01);
-		}
+     		if (!state->config->invert) reg0 &= ~0x20;
+		else reg0 |= 0x20;
 	}
 
-	SET_REG0(fe->data, reg0);
-
-	return 0;
-}
+			ves1820_writereg(state, 0x00, reg0 & 0xfe);
+			ves1820_writereg(state, 0x00, reg0 | 0x01);
 
-
-static int ves1820_init (struct dvb_frontend *fe)
-{
-	int i;
-        
-        dprintk("DVB: VES1820(%d): init chip\n", fe->i2c->adapter->num);
-
-        ves1820_writereg (fe, 0, 0);
-
-#if defined(CONFIG_DBOX2)
-	ves1820_inittab[2] &= ~0x08;
-#endif
-
-	for (i=0; i<53; i++)
-                ves1820_writereg (fe, i, ves1820_inittab[i]);
-
-	ves1820_writereg (fe, 0x34, GET_PWM(fe->data)); 
+	state->reg0 = reg0;
 
 	return 0;
 }
 
-
-static int ves1820_set_symbolrate (struct dvb_frontend *fe, u32 symbolrate)
+static int ves1820_set_symbolrate(struct ves1820_state *state, u32 symbolrate)
 {
         s32 BDR; 
         s32 BDRI;
         s16 SFIL=0;
         u16 NDEC = 0;
-        u32 tmp, ratio;
+	u32 ratio;
+	u32 fin;
+	u32 tmp;
+	u64 fptmp;
+	u64 fpxin;
 
-        if (symbolrate > XIN/2) 
-                symbolrate = XIN/2;
+	if (symbolrate > state->config->xin / 2)
+		symbolrate = state->config->xin / 2;
 
 	if (symbolrate < 500000)
                 symbolrate = 500000;
 
-        if (symbolrate < XIN/16) NDEC = 1;
-        if (symbolrate < XIN/32) NDEC = 2;
-        if (symbolrate < XIN/64) NDEC = 3;
-
-        if (symbolrate < (u32)(XIN/12.3)) SFIL = 1;
-        if (symbolrate < (u32)(XIN/16))	 SFIL = 0;
-        if (symbolrate < (u32)(XIN/24.6)) SFIL = 1;
-        if (symbolrate < (u32)(XIN/32))	 SFIL = 0;
-        if (symbolrate < (u32)(XIN/49.2)) SFIL = 1;
-        if (symbolrate < (u32)(XIN/64))	 SFIL = 0;
-        if (symbolrate < (u32)(XIN/98.4)) SFIL = 1;
+	if (symbolrate < state->config->xin / 16)
+		NDEC = 1;
+	if (symbolrate < state->config->xin / 32)
+		NDEC = 2;
+	if (symbolrate < state->config->xin / 64)
+		NDEC = 3;
+
+	/* yeuch! */
+	fpxin = state->config->xin * 10;
+	fptmp = fpxin; do_div(fptmp, 123);
+	if (symbolrate < fptmp);
+		SFIL = 1;
+	fptmp = fpxin; do_div(fptmp, 160);
+	if (symbolrate < fptmp);
+		SFIL = 0;
+	fptmp = fpxin; do_div(fptmp, 246);
+	if (symbolrate < fptmp);
+		SFIL = 1;
+	fptmp = fpxin; do_div(fptmp, 320);
+	if (symbolrate < fptmp);
+		SFIL = 0;
+	fptmp = fpxin; do_div(fptmp, 492);
+	if (symbolrate < fptmp);
+		SFIL = 1;
+	fptmp = fpxin; do_div(fptmp, 640);
+	if (symbolrate < fptmp);
+		SFIL = 0;
+	fptmp = fpxin; do_div(fptmp, 984);
+	if (symbolrate < fptmp);
+		SFIL = 1;
         
+	fin = state->config->xin >> 4;
         symbolrate <<= NDEC;
-        ratio = (symbolrate << 4) / FIN;
-        tmp =  ((symbolrate << 4) % FIN) << 8;
-        ratio = (ratio << 8) + tmp / FIN;
-        tmp = (tmp % FIN) << 8;
-        ratio = (ratio << 8) + (tmp + FIN/2) / FIN;
+	ratio = (symbolrate << 4) / fin;
+	tmp = ((symbolrate << 4) % fin) << 8;
+	ratio = (ratio << 8) + tmp / fin;
+	tmp = (tmp % fin) << 8;
+	ratio = (ratio << 8) + (tmp + fin / 2) / fin;
         
         BDR = ratio;
-        BDRI = (((XIN << 5) / symbolrate) + 1) / 2;
+	BDRI = (((state->config->xin << 5) / symbolrate) + 1) / 2;
         
         if (BDRI > 0xFF) 
                 BDRI = 0xFF;
@@ -318,21 +187,53 @@
         
         NDEC = (NDEC << 6) | ves1820_inittab[0x03];
 
-        ves1820_writereg (fe, 0x03, NDEC);
-        ves1820_writereg (fe, 0x0a, BDR&0xff);
-        ves1820_writereg (fe, 0x0b, (BDR>> 8)&0xff);
-        ves1820_writereg (fe, 0x0c, (BDR>>16)&0x3f);
+	ves1820_writereg(state, 0x03, NDEC);
+	ves1820_writereg(state, 0x0a, BDR & 0xff);
+	ves1820_writereg(state, 0x0b, (BDR >> 8) & 0xff);
+	ves1820_writereg(state, 0x0c, (BDR >> 16) & 0x3f);
 
-        ves1820_writereg (fe, 0x0d, BDRI);
-        ves1820_writereg (fe, 0x0e, SFIL);
+	ves1820_writereg(state, 0x0d, BDRI);
+	ves1820_writereg(state, 0x0e, SFIL);
 
         return 0;
 }
 
 
-static int ves1820_set_parameters (struct dvb_frontend *fe,
-			    struct dvb_frontend_parameters *p)
+
+
+
+
+
+
+
+
+
+
+
+static int ves1820_init(struct dvb_frontend* fe)
 {
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
+	int i;
+	int val;
+
+	ves1820_writereg(state, 0, 0);
+
+	for (i = 0; i < 53; i++) {
+		val = ves1820_inittab[i];
+		if ((i == 2) && (state->config->selagc)) val |= 0x08;
+		ves1820_writereg(state, i, val);
+	}
+
+	ves1820_writereg(state, 0x34, state->pwm);
+
+	if (state->config->pll_init) state->config->pll_init(fe);
+
+	return 0;
+}
+
+static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
 	static const u8 reg0x00 [] = { 0x00, 0x04, 0x08, 0x0c, 0x10 };
 	static const u8 reg0x01 [] = {  140,  140,  106,  100,   92 };
 	static const u8 reg0x05 [] = {  135,  100,   70,   54,   38 };
@@ -343,41 +244,28 @@
 	if (real_qam < 0 || real_qam > 4)
 		return -EINVAL;
 
-	tuner_set_tv_freq (fe, p->frequency);
-	ves1820_set_symbolrate (fe, p->u.qam.symbol_rate);
-	ves1820_writereg (fe, 0x34, GET_PWM(fe->data));
-
-        ves1820_writereg (fe, 0x01, reg0x01[real_qam]);
-        ves1820_writereg (fe, 0x05, reg0x05[real_qam]);
-        ves1820_writereg (fe, 0x08, reg0x08[real_qam]);
-        ves1820_writereg (fe, 0x09, reg0x09[real_qam]);
-
-	ves1820_setup_reg0 (fe, reg0x00[real_qam], p->inversion);
-
-	/* yes, this speeds things up: userspace reports lock in about 8 ms
-	   instead of 500 to 1200 ms after calling FE_SET_FRONTEND. */
-	mdelay(50);
+	state->config->pll_set(fe, p);
+	ves1820_set_symbolrate(state, p->u.qam.symbol_rate);
+	ves1820_writereg(state, 0x34, state->pwm);
+
+	ves1820_writereg(state, 0x01, reg0x01[real_qam]);
+	ves1820_writereg(state, 0x05, reg0x05[real_qam]);
+	ves1820_writereg(state, 0x08, reg0x08[real_qam]);
+	ves1820_writereg(state, 0x09, reg0x09[real_qam]);
+
+	ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion);
 
 	return 0;
 }
 
-
-
-static int ves1820_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static int ves1820_read_status(struct dvb_frontend* fe, fe_status_t* status)
 {
-        switch (cmd) {
-	case FE_GET_INFO:
-		memcpy (arg, &ves1820_info, sizeof(struct dvb_frontend_info));
-		break;
-
-        case FE_READ_STATUS:
-	{
-		fe_status_t *status = (fe_status_t *) arg;
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
 		int sync;
 
 		*status = 0;
 
-                sync = ves1820_readreg (fe, 0x11);
+			sync = ves1820_readreg(state, 0x11);
 
 		if (sync & 1)
 			*status |= FE_HAS_SIGNAL;
@@ -394,201 +282,189 @@
 		if (sync & 8)
 			*status |= FE_HAS_LOCK;
 
-		break;
+	return 0;
 	}
 
-	case FE_READ_BER:
+static int ves1820_read_ber(struct dvb_frontend* fe, u32* ber)
 	{
-		u32 ber = ves1820_readreg(fe, 0x14) |
-			 (ves1820_readreg(fe, 0x15) << 8) |
-			 ((ves1820_readreg(fe, 0x16) & 0x0f) << 16);
-		*((u32*) arg) = 10 * ber;
-		break;
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
+
+	u32 _ber = ves1820_readreg(state, 0x14) |
+					(ves1820_readreg(state, 0x15) << 8) |
+					((ves1820_readreg(state, 0x16) & 0x0f) << 16);
+	*ber = 10 * _ber;
+
+	return 0;
 	}
-	case FE_READ_SIGNAL_STRENGTH:
+
+static int ves1820_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 	{
-		u8 gain = ves1820_readreg(fe, 0x17);
-		*((u16*) arg) = (gain << 8) | gain;
-		break;
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
+
+			u8 gain = ves1820_readreg(state, 0x17);
+	*strength = (gain << 8) | gain;
+
+	return 0;
 	}
 
-	case FE_READ_SNR:
+static int ves1820_read_snr(struct dvb_frontend* fe, u16* snr)
 	{
-		u8 quality = ~ves1820_readreg(fe, 0x18);
-		*((u16*) arg) = (quality << 8) | quality;
-		break;
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
+
+			u8 quality = ~ves1820_readreg(state, 0x18);
+	*snr = (quality << 8) | quality;
+
+	return 0;
 	}
 
-	case FE_READ_UNCORRECTED_BLOCKS:
-		*((u32*) arg) = ves1820_readreg (fe, 0x13) & 0x7f;
-		if (*((u32*) arg) == 0x7f)
-			*((u32*) arg) = 0xffffffff;
+static int ves1820_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
+{
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
+
+	*ucblocks = ves1820_readreg(state, 0x13) & 0x7f;
+	if (*ucblocks == 0x7f)
+		*ucblocks = 0xffffffff;
+
 		/* reset uncorrected block counter */
-		ves1820_writereg (fe, 0x10, ves1820_inittab[0x10] & 0xdf);
-	        ves1820_writereg (fe, 0x10, ves1820_inittab[0x10]);
-		break;
+		ves1820_writereg(state, 0x10, ves1820_inittab[0x10] & 0xdf);
+		ves1820_writereg(state, 0x10, ves1820_inittab[0x10]);
 
-        case FE_SET_FRONTEND:
-		return ves1820_set_parameters (fe, arg);
+	return 0;
+}
 
-	case FE_GET_FRONTEND:
+static int ves1820_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
 	{
-		struct dvb_frontend_parameters *p = (struct dvb_frontend_parameters *)arg;
-		u8 reg0 = GET_REG0(fe->data);
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
 		int sync;
 		s8 afc = 0;
                 
-                sync = ves1820_readreg (fe, 0x11);
-			afc = ves1820_readreg(fe, 0x19);
+			sync = ves1820_readreg(state, 0x11);
+			afc = ves1820_readreg(state, 0x19);
 		if (verbose) {
 			/* AFC only valid when carrier has been recovered */
-			printk(sync & 2 ? "DVB: VES1820(%d): AFC (%d) %dHz\n" :
-					  "DVB: VES1820(%d): [AFC (%d) %dHz]\n",
-					fe->i2c->adapter->num, afc,
-			       -((s32)p->u.qam.symbol_rate * afc) >> 10);
+				printk(sync & 2 ? "ves1820: AFC (%d) %dHz\n" :
+					"ves1820: [AFC (%d) %dHz]\n", afc, -((s32) p->u.qam.symbol_rate * afc) >> 10);
 		}
 
-		p->inversion = HAS_INVERSION(reg0) ? INVERSION_ON : INVERSION_OFF;
-		p->u.qam.modulation = ((reg0 >> 2) & 7) + QAM_16;
+	if (!state->config->invert) {
+		p->inversion = (state->reg0 & 0x20) ? INVERSION_ON : INVERSION_OFF;
+	} else {
+		p->inversion = (!(state->reg0 & 0x20)) ? INVERSION_ON : INVERSION_OFF;
+	}
+
+			p->u.qam.modulation = ((state->reg0 >> 2) & 7) + QAM_16;
 
 		p->u.qam.fec_inner = FEC_NONE;
 
 		p->frequency = ((p->frequency + 31250) / 62500) * 62500;
 		if (sync & 2)
 			p->frequency -= ((s32)p->u.qam.symbol_rate * afc) >> 10;
-		break;
-	}
-	case FE_SLEEP:
-		ves1820_writereg (fe, 0x1b, 0x02);  /* pdown ADC */
-		ves1820_writereg (fe, 0x00, 0x80);  /* standby */
-		break;
-
-        case FE_INIT:
-                return ves1820_init (fe);
-
-        default:
-                return -EINVAL;
-        }
 
         return 0;
 } 
 
-
-static long probe_tuner (struct dvb_i2c_bus *i2c)
+static int ves1820_sleep(struct dvb_frontend* fe)
 {
-	static const struct i2c_msg msg1 = 
-		{ .addr = 0x61, .flags = 0, .buf = NULL, .len = 0 };
-	static const struct i2c_msg msg2 =
-		{ .addr = 0x62, .flags = 0, .buf = NULL, .len = 0 };
-	int type;
-
-	if (i2c->xfer(i2c, &msg1, 1) == 1) {
-		type = 0;
-		printk ("DVB: VES1820(%d): setup for tuner spXXXX\n", i2c->adapter->num);
-	} else if (i2c->xfer(i2c, &msg2, 1) == 1) {
-		type = 1;
-		printk ("DVB: VES1820(%d): setup for tuner sp5659c\n", i2c->adapter->num);
-	} else {
-		type = -1;
-	}
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
 
-	return type;
-}
+	ves1820_writereg(state, 0x1b, 0x02);	/* pdown ADC */
+	ves1820_writereg(state, 0x00, 0x80);	/* standby */
 
+	return 0;
+}
 
-static u8 read_pwm (struct dvb_i2c_bus *i2c)
+static int ves1820_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
 {
-	u8 b = 0xff;
-	u8 pwm;
-	struct i2c_msg msg [] = { { .addr = 0x50, .flags = 0, .buf = &b, .len = 1 },
-			 { .addr = 0x50, .flags = I2C_M_RD, .buf = &pwm, .len = 1 } };
-
-	if ((i2c->xfer(i2c, msg, 2) != 2) || (pwm == 0xff))
-		pwm = 0x48;
 
-	printk("DVB: VES1820(%d): pwm=0x%02x\n", i2c->adapter->num, pwm);
-
-	return pwm;
+	fesettings->min_delay_ms = 200;
+	fesettings->step_size = 0;
+	fesettings->max_drift = 0;
+	return 0;
 }
 
-
-static long probe_demod_addr (struct dvb_i2c_bus *i2c)
+static void ves1820_release(struct dvb_frontend* fe)
 {
-	u8 b [] = { 0x00, 0x1a };
-	u8 id;
-	struct i2c_msg msg [] = { { .addr = 0x08, .flags = 0, .buf = b, .len = 2 },
-	                   { .addr = 0x08, .flags = I2C_M_RD, .buf = &id, .len = 1 } };
-
-	if (i2c->xfer(i2c, msg, 2) == 2 && (id & 0xf0) == 0x70)
-		return msg[0].addr;
-
-	msg[0].addr = msg[1].addr = 0x09;
-
-	if (i2c->xfer(i2c, msg, 2) == 2 && (id & 0xf0) == 0x70)
-		return msg[0].addr;
-
-	return -1;
+	struct ves1820_state* state = (struct ves1820_state*) fe->demodulator_priv;
+	kfree(state);
 }
 
+static struct dvb_frontend_ops ves1820_ops;
 
-static int ves1820_attach (struct dvb_i2c_bus *i2c, void **data)
+struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
+				    struct i2c_adapter* i2c,
+				    u8 pwm)
 {
-	void *priv = NULL;
-	long demod_addr;
-	long tuner_type;
+	struct ves1820_state* state = NULL;
 
-	if ((demod_addr = probe_demod_addr(i2c)) < 0)
-		return -ENODEV;
+	/* allocate memory for the internal state */
+	state = (struct ves1820_state*) kmalloc(sizeof(struct ves1820_state), GFP_KERNEL);
+	if (state == NULL)
+		goto error;
 
-	tuner_type = probe_tuner(i2c);
+	/* setup the state */
+	memcpy(&state->ops, &ves1820_ops, sizeof(struct dvb_frontend_ops));
+	state->reg0 = ves1820_inittab[0];
+	state->config = config;
+	state->i2c = i2c;
+	state->pwm = pwm;
 
-	if ((i2c->adapter->num < MAX_UNITS) && pwm[i2c->adapter->num] != -1) {
-		printk("DVB: VES1820(%d): pwm=0x%02x (user specified)\n",
-				i2c->adapter->num, pwm[i2c->adapter->num]);
-		SET_PWM(priv, pwm[i2c->adapter->num]);
-	}
-	else
-		SET_PWM(priv, read_pwm(i2c));
-	SET_REG0(priv, ves1820_inittab[0]);
-	SET_TUNER(priv, tuner_type);
-	SET_DEMOD_ADDR(priv, demod_addr);
-
-	return dvb_register_frontend (ves1820_ioctl, i2c, priv, &ves1820_info);
-}
-
-
-static void ves1820_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	dvb_unregister_frontend (ves1820_ioctl, i2c);
-}
+	/* check if the demod is there */
+	if ((ves1820_readreg(state, 0x1a) & 0xf0) != 0x70)
+		goto error;
 
+	if (verbose)
+		printk("ves1820: pwm=0x%02x\n", state->pwm);
 
-static int __init init_ves1820 (void)
-{
-	int i;
-	for (i = 0; i < MAX_UNITS; i++)
-		if (pwm[i] < -1 || pwm[i] > 255)
-			return -EINVAL;
-	return dvb_register_i2c_device (THIS_MODULE,
-					ves1820_attach, ves1820_detach);
-}
+	state->ops.info.symbol_rate_min = (state->config->xin / 2) / 64;      /* SACLK/64 == (XIN/2)/64 */
+	state->ops.info.symbol_rate_max = (state->config->xin / 2) / 4;       /* SACLK/4 */
 
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
 
-static void __exit exit_ves1820 (void)
-{
-	dvb_unregister_i2c_device (ves1820_attach);
-}
+error:
+	if (state) kfree(state);
+	return NULL;
+	}
 
+static struct dvb_frontend_ops ves1820_ops = {
 
-module_init(init_ves1820);
-module_exit(exit_ves1820);
+	.info = {
+		.name = "VLSI VES1820 DVB-C",
+		.type = FE_QAM,
+		.frequency_stepsize = 62500,
+		.frequency_min = 51000000,
+		.frequency_max = 858000000,
+		.caps = FE_CAN_QAM_16 |
+			FE_CAN_QAM_32 |
+			FE_CAN_QAM_64 |
+			FE_CAN_QAM_128 |
+			FE_CAN_QAM_256 |
+			FE_CAN_FEC_AUTO
+	},
+
+	.release = ves1820_release,
+
+	.init = ves1820_init,
+	.sleep = ves1820_sleep,
+
+	.set_frontend = ves1820_set_parameters,
+	.get_frontend = ves1820_get_frontend,
+	.get_tune_settings = ves1820_get_tune_settings,
+
+	.read_status = ves1820_read_status,
+	.read_ber = ves1820_read_ber,
+	.read_signal_strength = ves1820_read_signal_strength,
+	.read_snr = ves1820_read_snr,
+	.read_ucblocks = ves1820_read_ucblocks,
+};
 
-MODULE_PARM(pwm, "1-" __MODULE_STRING(MAX_UNITS) "i");
-MODULE_PARM_DESC(pwm, "override PWM value stored in EEPROM (tuner calibration)");
-MODULE_PARM(verbose, "i");
+module_param(verbose, int, 0644);
 MODULE_PARM_DESC(verbose, "print AFC offset after tuning for debugging the PWM setting");
 
-MODULE_DESCRIPTION("VES1820 DVB-C frontend driver");
+MODULE_DESCRIPTION("VLSI VES1820 DVB-C Demodulator driver");
 MODULE_AUTHOR("Ralph Metzler, Holger Waechtler");
 MODULE_LICENSE("GPL");
 
+EXPORT_SYMBOL(ves1820_attach);
diff -Nru a/drivers/media/dvb/frontends/ves1820.h b/drivers/media/dvb/frontends/ves1820.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/ves1820.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,52 @@
+/*
+    VES1820  - Single Chip Cable Channel Receiver driver module
+
+    Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
+
+    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.
+*/
+
+#ifndef VES1820_H
+#define VES1820_H
+
+#include <linux/dvb/frontend.h>
+
+#define VES1820_SELAGC_PWM 0
+#define VES1820_SELAGC_SIGNAMPERR 1
+
+struct ves1820_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* value of XIN to use */
+	u32 xin;
+
+	/* does inversion need inverted? */
+	u8 invert:1;
+
+	/* SELAGC control */
+	u8 selagc:1;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
+					   struct i2c_adapter* i2c,
+					   u8 pwm);
+
+#endif // VES1820_H
diff -Nru a/drivers/media/dvb/frontends/ves1x93.c b/drivers/media/dvb/frontends/ves1x93.c
--- a/drivers/media/dvb/frontends/ves1x93.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/dvb/frontends/ves1x93.c	2004-12-24 13:36:18 -08:00
@@ -1,5 +1,5 @@
 /* 
-    Driver for VES1893 and VES1993 QPSK Frontends
+    Driver for VES1893 and VES1993 QPSK Demodulators
 
     Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
     Copyright (C) 2001 Ronny Strutz <3des@elitedvb.de>
@@ -28,44 +28,36 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 
 #include "dvb_frontend.h"
-#include "dvb_functions.h"
+#include "ves1x93.h"
 
-static int debug = 0;
-#define dprintk	if (debug) printk
 
-static int board_type = 0;
-#define BOARD_SIEMENS_PCI	0
-#define BOARD_NOKIA_DBOX2	1
-#define BOARD_SAGEM_DBOX2	2
+struct ves1x93_state {
+
+	struct i2c_adapter* i2c;
 
-static int demod_type = 0;
-#define DEMOD_VES1893		0
-#define DEMOD_VES1993		1
+	struct dvb_frontend_ops ops;
 
-static struct dvb_frontend_info ves1x93_info = {
-	.name			= "VES1x93",
-	.type			= FE_QPSK,
-	.frequency_min		= 950000,
-	.frequency_max		= 2150000,
-	.frequency_stepsize	= 250,           /* kHz for QPSK frontends */
-	.frequency_tolerance	= 29500,
-	.symbol_rate_min	= 1000000,
-	.symbol_rate_max	= 45000000,
-/*      .symbol_rate_tolerance	=	???,*/
-	.notifier_delay		= 50,                /* 1/20 s */
-	.caps = FE_CAN_INVERSION_AUTO |
-		FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-		FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-		FE_CAN_QPSK
+	/* configuration settings */
+	const struct ves1x93_config* config;
+
+	struct dvb_frontend frontend;
+
+	/* previous uncorrected block counter */
+	fe_spectral_inversion_t inversion;
+	u8 *init_1x93_tab;
+	u8 *init_1x93_wtab;
+	u8 tab_size;
+	u8 demod_type;
 };
 
+static int debug = 0;
+#define dprintk	if (debug) printk
 
-/**
- * nokia dbox2 (ves1893) and sagem dbox2 (ves1993)
- * need bit AGCR[PWMS] set to 1
- */
+#define DEMOD_VES1893		0
+#define DEMOD_VES1993		1
 
 static u8 init_1893_tab [] = {
 	0x01, 0xa4, 0x35, 0x80, 0x2a, 0x0b, 0x55, 0xc4,
@@ -89,10 +81,6 @@
 	0x00, 0x00, 0x0e, 0x80, 0x00
 };
 
-
-static u8 * init_1x93_tab;
-
-
 static u8 init_1893_wtab[] =
 {
         1,1,1,1,1,1,1,1, 1,1,0,0,1,1,0,0,
@@ -110,19 +98,13 @@
 	1,1,1,0,1,1,1,1, 1,1,1,1,1
 };
 
-struct ves1x93_state {
-	fe_spectral_inversion_t inversion;
-};
-
-
-
-static int ves1x93_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
+static int ves1x93_writereg (struct ves1x93_state* state, u8 reg, u8 data)
 {
         u8 buf [] = { 0x00, reg, data };
-	struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 3 };
+	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 3 };
 	int err;
 
-        if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
+	if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
 		dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
 		return -EREMOTEIO;
 	}
@@ -131,142 +113,31 @@
 }
 
 
-static u8 ves1x93_readreg (struct dvb_i2c_bus *i2c, u8 reg)
+static u8 ves1x93_readreg (struct ves1x93_state* state, u8 reg)
 {
 	int ret;
 	u8 b0 [] = { 0x00, reg };
 	u8 b1 [] = { 0 };
-	struct i2c_msg msg [] = { { .addr = 0x08, .flags = 0, .buf = b0, .len = 2 },
-			   { .addr = 0x08, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
+	struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
+			   { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
 
-	ret = i2c->xfer (i2c, msg, 2);
+	ret = i2c_transfer (state->i2c, msg, 2);
 
-	if (ret != 2)
-		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+	if (ret != 2) return ret;
 
 	return b1[0];
 }
 
-
-static int tuner_write (struct dvb_i2c_bus *i2c, u8 *data, u8 len)
-{
-        int ret;
-        struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = len };
-
-	ves1x93_writereg(i2c, 0x00, 0x11);
-        ret = i2c->xfer (i2c, &msg, 1);
-	ves1x93_writereg(i2c, 0x00, 0x01);
-
-        if (ret != 1)
-                printk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
-
-        return (ret != 1) ? -1 : 0;
-}
-
-
-
-/**
- *   set up the downconverter frequency divisor for a
- *   reference clock comparision frequency of 125 kHz.
- */
-static int sp5659_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, u8 pwr)
-{
-        u32 div = (freq + 479500) / 125;
-	u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x95, (pwr << 5) | 0x30 };
-
-	return tuner_write (i2c, buf, sizeof(buf));
-}
-
-
-static int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
+static int ves1x93_clr_bit (struct ves1x93_state* state)
 {
-	int ret;
-	u8 buf [2];
-
-	freq /= 1000;
-
-	buf[0] = (freq >> 8) & 0x7F;
-	buf[1] = freq & 0xFF;
-
-	ret = tuner_write(i2c, buf, sizeof(buf));
-
-	return ret;
-}
-
-
-static int tuner_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, u8 pwr)
-{
-	if ((demod_type == DEMOD_VES1893) && (board_type == BOARD_SIEMENS_PCI))
-		return sp5659_set_tv_freq (i2c, freq, pwr);
-	else if (demod_type == DEMOD_VES1993)
-		return tsa5059_set_tv_freq (i2c, freq);
-
-	return -EINVAL;
-}
-
-
-static int ves1x93_init (struct dvb_i2c_bus *i2c)
-{
-	int i;
-	int size;
-	u8 *init_1x93_wtab;
- 
-	dprintk("%s: init chip\n", __FUNCTION__);
-
-	switch (demod_type) {
-	case DEMOD_VES1893:
-		init_1x93_tab = init_1893_tab;
-		init_1x93_wtab = init_1893_wtab;
-		size = sizeof(init_1893_tab);
-		if (board_type == BOARD_NOKIA_DBOX2)
-			init_1x93_tab[0x05] |= 0x20; /* invert PWM */
-		break;
-
-	case DEMOD_VES1993:
-		init_1x93_tab = init_1993_tab;
-		init_1x93_wtab = init_1993_wtab;
-		size = sizeof(init_1993_tab);
-		if (board_type == BOARD_SAGEM_DBOX2)
-			init_1x93_tab[0x05] |= 0x20; /* invert PWM */
-		break;
-
-	default:
-		return -EINVAL;
-	}
-
-	for (i = 0; i < size; i++)
-		if (init_1x93_wtab[i])
-			ves1x93_writereg (i2c, i, init_1x93_tab[i]);
-
-	if (demod_type == DEMOD_VES1993) {
-		if (board_type == BOARD_NOKIA_DBOX2)
-			tuner_write(i2c, "\x06\x5c\x83\x60", 4);
-		else if (board_type == BOARD_SAGEM_DBOX2)
-			tuner_write(i2c, "\x25\x70\x92\x40", 4);
-	}
-
-	return 0;
-}
-
-
-static int ves1x93_clr_bit (struct dvb_i2c_bus *i2c)
-{
-        ves1x93_writereg (i2c, 0, init_1x93_tab[0] & 0xfe);
-        ves1x93_writereg (i2c, 0, init_1x93_tab[0]);
-	dvb_delay(5);
-	return 0;
-}
-
-static int ves1x93_init_aquire (struct dvb_i2c_bus *i2c)
-{
-        ves1x93_writereg (i2c, 3, 0x00);
-	ves1x93_writereg (i2c, 3, init_1x93_tab[3]);
-	dvb_delay(5);
+	msleep(10);
+	ves1x93_writereg (state, 0, state->init_1x93_tab[0] & 0xfe);
+	ves1x93_writereg (state, 0, state->init_1x93_tab[0]);
+	msleep(50);
 	return 0;
 }
 
-
-static int ves1x93_set_inversion (struct dvb_i2c_bus *i2c, fe_spectral_inversion_t inversion)
+static int ves1x93_set_inversion (struct ves1x93_state* state, fe_spectral_inversion_t inversion)
 {
 	u8 val;
 
@@ -289,66 +160,47 @@
 		return -EINVAL;
 	}
 
-	return ves1x93_writereg (i2c, 0x0c, (init_1x93_tab[0x0c] & 0x3f) | val);
+	return ves1x93_writereg (state, 0x0c, (state->init_1x93_tab[0x0c] & 0x3f) | val);
 }
 
 
-static int ves1x93_set_fec (struct dvb_i2c_bus *i2c, fe_code_rate_t fec)
+static int ves1x93_set_fec (struct ves1x93_state* state, fe_code_rate_t fec)
 {
 	if (fec == FEC_AUTO)
-		return ves1x93_writereg (i2c, 0x0d, 0x08);
+		return ves1x93_writereg (state, 0x0d, 0x08);
 	else if (fec < FEC_1_2 || fec > FEC_8_9)
 		return -EINVAL;
 	else
-		return ves1x93_writereg (i2c, 0x0d, fec - FEC_1_2);
+		return ves1x93_writereg (state, 0x0d, fec - FEC_1_2);
 }
 
 
-static fe_code_rate_t ves1x93_get_fec (struct dvb_i2c_bus *i2c)
+static fe_code_rate_t ves1x93_get_fec (struct ves1x93_state* state)
 {
-	return FEC_1_2 + ((ves1x93_readreg (i2c, 0x0d) >> 4) & 0x7);
+	return FEC_1_2 + ((ves1x93_readreg (state, 0x0d) >> 4) & 0x7);
 }
 
 
-static int ves1x93_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
+static int ves1x93_set_symbolrate (struct ves1x93_state* state, u32 srate)
 {
 	u32 BDR;
         u32 ratio;
 	u8  ADCONF, FCONF, FNR;
 	u32 BDRI;
 	u32 tmp;
-	u32 XIN, FIN;
+	u32 FIN;
 
 	dprintk("%s: srate == %d\n", __FUNCTION__, (unsigned int) srate);
 
-	switch (board_type) {
-	case BOARD_SIEMENS_PCI:
-		XIN = 90100000UL;
-		break;
-	case BOARD_NOKIA_DBOX2:
-		if (demod_type == DEMOD_VES1893)
-			XIN = 91000000UL;
-		else if (demod_type == DEMOD_VES1993)
-			XIN = 96000000UL;
-		else
-			return -EINVAL;
-		break;
-	case BOARD_SAGEM_DBOX2:
-		XIN = 92160000UL;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	if (srate > XIN/2)
-		srate = XIN/2;
+	if (srate > state->config->xin/2)
+		srate = state->config->xin/2;
 
 	if (srate < 500000)
 		srate = 500000;
 
 #define MUL (1UL<<26)
 
-	FIN = (XIN + 6000) >> 4;
+	FIN = (state->config->xin + 6000) >> 4;
 
 	tmp = srate << 6;
 	ratio = tmp / FIN;
@@ -393,75 +245,102 @@
 	if (BDRI > 0xff)
 		BDRI = 0xff;
 
-	ves1x93_writereg (i2c, 0x06, 0xff & BDR);
-	ves1x93_writereg (i2c, 0x07, 0xff & (BDR >> 8));
-	ves1x93_writereg (i2c, 0x08, 0x0f & (BDR >> 16));
-
-	ves1x93_writereg (i2c, 0x09, BDRI);
-	ves1x93_writereg (i2c, 0x20, ADCONF);
-	ves1x93_writereg (i2c, 0x21, FCONF);
+	ves1x93_writereg (state, 0x06, 0xff & BDR);
+	ves1x93_writereg (state, 0x07, 0xff & (BDR >> 8));
+	ves1x93_writereg (state, 0x08, 0x0f & (BDR >> 16));
+
+	ves1x93_writereg (state, 0x09, BDRI);
+	ves1x93_writereg (state, 0x20, ADCONF);
+	ves1x93_writereg (state, 0x21, FCONF);
 
 	if (srate < 6000000) 
-		ves1x93_writereg (i2c, 0x05, init_1x93_tab[0x05] | 0x80);
+		ves1x93_writereg (state, 0x05, state->init_1x93_tab[0x05] | 0x80);
 	else
-		ves1x93_writereg (i2c, 0x05, init_1x93_tab[0x05] & 0x7f);
+		ves1x93_writereg (state, 0x05, state->init_1x93_tab[0x05] & 0x7f);
 
 	/* ves1993 hates this, will lose lock */
-	if (demod_type != DEMOD_VES1993)
-		ves1x93_clr_bit (i2c);
+	if (state->demod_type != DEMOD_VES1993)
+		ves1x93_clr_bit (state);
 
 	return 0;
 }
 
 
-static int ves1x93_afc (struct dvb_i2c_bus *i2c, u32 freq, u32 srate)
+
+
+
+
+
+
+
+
+
+
+
+
+
+static int ves1x93_init (struct dvb_frontend* fe)
 {
-	int afc;
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
+	int i;
+	int val;
 
-	afc = ((int)((ves1x93_readreg (i2c, 0x0a) << 1) & 0xff))/2;
-	afc = (afc * (int)(srate/1000/8))/16;
-    
-	if (afc) {
-	
-		freq -= afc;
+	dprintk("%s: init chip\n", __FUNCTION__);
 
-		tuner_set_tv_freq (i2c, freq, 0);
+	for (i = 0; i < state->tab_size; i++) {
+		if (state->init_1x93_wtab[i]) {
+			val = state->init_1x93_tab[i];
+
+			if (state->config->invert_pwm && (i == 0x05)) val |= 0x20; /* invert PWM */
+			ves1x93_writereg (state, i, val);
+		}
+	}
 
-		ves1x93_init_aquire (i2c);
+	if (state->config->pll_init) {
+		ves1x93_writereg(state, 0x00, 0x11);
+		state->config->pll_init(fe);
+		ves1x93_writereg(state, 0x00, 0x01);
 	}
-       
+
 	return 0;
 }
 
-static int ves1x93_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage)
+static int ves1x93_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
 {
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
+
 	switch (voltage) {
 	case SEC_VOLTAGE_13:
-		return ves1x93_writereg (i2c, 0x1f, 0x20);
+		return ves1x93_writereg (state, 0x1f, 0x20);
 	case SEC_VOLTAGE_18:
-		return ves1x93_writereg (i2c, 0x1f, 0x30);
+		return ves1x93_writereg (state, 0x1f, 0x30);
 	case SEC_VOLTAGE_OFF:
-		return ves1x93_writereg (i2c, 0x1f, 0x00);
+		return ves1x93_writereg (state, 0x1f, 0x00);
 	default:
 		return -EINVAL;
 	}
 }
 
-
-static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static int ves1x93_read_status(struct dvb_frontend* fe, fe_status_t* status)
 {
-	struct dvb_i2c_bus *i2c = fe->i2c;
-	struct ves1x93_state *state = (struct ves1x93_state*) fe->data;
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
 
-        switch (cmd) {
-        case FE_GET_INFO:
-		memcpy (arg, &ves1x93_info, sizeof(struct dvb_frontend_info));
-		break;
+	u8 sync = ves1x93_readreg (state, 0x0e);
 
-        case FE_READ_STATUS:
-	{
-		fe_status_t *status = arg;
-		u8 sync = ves1x93_readreg (i2c, 0x0e);
+		/*
+		 * The ves1893 sometimes returns sync values that make no sense,
+		 * because, e.g., the SIGNAL bit is 0, while some of the higher
+		 * bits are 1 (and how can there be a CARRIER w/o a SIGNAL?).
+		 * Tests showed that the the VITERBI and SYNC bits are returned
+		 * reliably, while the SIGNAL and CARRIER bits ar sometimes wrong.
+		 * If such a case occurs, we read the value again, until we get a
+		 * valid value.
+		 */
+		int maxtry = 10; /* just for safety - let's not get stuck here */
+		while ((sync & 0x03) != 0x03 && (sync & 0x0c) && maxtry--) {
+			msleep(10);
+		sync = ves1x93_readreg (state, 0x0e);
+		}
 
 		*status = 0;
 
@@ -480,65 +359,78 @@
 		if ((sync & 0x1f) == 0x1f)
 			*status |= FE_HAS_LOCK;
 
-		break;
+	return 0;
 	}
 
-        case FE_READ_BER:
+
+static int ves1x93_read_ber(struct dvb_frontend* fe, u32* ber)
 	{
-		u32 *ber = (u32 *) arg;
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
 
-		*ber = ves1x93_readreg (i2c, 0x15);
-                *ber |= (ves1x93_readreg (i2c, 0x16) << 8);
-                *ber |= ((ves1x93_readreg (i2c, 0x17) & 0x0F) << 16);
+	*ber = ves1x93_readreg (state, 0x15);
+	*ber |= (ves1x93_readreg (state, 0x16) << 8);
+	*ber |= ((ves1x93_readreg (state, 0x17) & 0x0F) << 16);
 		*ber *= 10;
-		break;
+
+	return 0;
 	}
 
-        case FE_READ_SIGNAL_STRENGTH:
+static int ves1x93_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 	{
-		u8 signal = ~ves1x93_readreg (i2c, 0x0b);
-		*((u16*) arg) = (signal << 8) | signal;
-		break;
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
+
+	u8 signal = ~ves1x93_readreg (state, 0x0b);
+	*strength = (signal << 8) | signal;
+
+	return 0;
 	}
 
-        case FE_READ_SNR:
+static int ves1x93_read_snr(struct dvb_frontend* fe, u16* snr)
 	{
-		u8 snr = ~ves1x93_readreg (i2c, 0x1c);
-		*(u16*) arg = (snr << 8) | snr;
-		break;
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
+
+	u8 _snr = ~ves1x93_readreg (state, 0x1c);
+	*snr = (_snr << 8) | _snr;
+
+	return 0;
 	}
 
-	case FE_READ_UNCORRECTED_BLOCKS: 
+static int ves1x93_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
 	{
-		*(u32*) arg = ves1x93_readreg (i2c, 0x18) & 0x7f;
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
 
-		if (*(u32*) arg == 0x7f)
-			*(u32*) arg = 0xffffffff;   /* counter overflow... */
+	*ucblocks = ves1x93_readreg (state, 0x18) & 0x7f;
 		
-		ves1x93_writereg (i2c, 0x18, 0x00);  /* reset the counter */
-		ves1x93_writereg (i2c, 0x18, 0x80);  /* dto. */
-		break;
+	if (*ucblocks == 0x7f)
+		*ucblocks = 0xffffffff;   /* counter overflow... */
+
+	ves1x93_writereg (state, 0x18, 0x00);  /* reset the counter */
+	ves1x93_writereg (state, 0x18, 0x80);  /* dto. */
+
+	return 0;
 	}
 
-        case FE_SET_FRONTEND:
+static int ves1x93_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
         {
-		struct dvb_frontend_parameters *p = arg;
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
 
-		tuner_set_tv_freq (i2c, p->frequency, 0);
-		ves1x93_set_inversion (i2c, p->inversion);
-		ves1x93_set_fec (i2c, p->u.qpsk.fec_inner);
-		ves1x93_set_symbolrate (i2c, p->u.qpsk.symbol_rate);
-		ves1x93_afc (i2c, p->frequency, p->u.qpsk.symbol_rate);	    
+	ves1x93_writereg(state, 0x00, 0x11);
+	state->config->pll_set(fe, p);
+	ves1x93_writereg(state, 0x00, 0x01);
+	ves1x93_set_inversion (state, p->inversion);
+	ves1x93_set_fec (state, p->u.qpsk.fec_inner);
+	ves1x93_set_symbolrate (state, p->u.qpsk.symbol_rate);
 		state->inversion = p->inversion;
-                break;
+
+	return 0;
         }
 
-	case FE_GET_FRONTEND:
+static int ves1x93_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
 	{
-		struct dvb_frontend_parameters *p = arg;
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
 		int afc;
 
-		afc = ((int)((char)(ves1x93_readreg (i2c, 0x0a) << 1)))/2;
+	afc = ((int)((char)(ves1x93_readreg (state, 0x0a) << 1)))/2;
 		afc = (afc * (int)(p->u.qpsk.symbol_rate/1000/8))/16;
 
 		p->frequency -= afc;
@@ -548,113 +440,125 @@
 		 * if auto inversion was used
 		 */
 		if (state->inversion == INVERSION_AUTO)
-			p->inversion = (ves1x93_readreg (i2c, 0x0f) & 2) ? 
+		p->inversion = (ves1x93_readreg (state, 0x0f) & 2) ?
 					INVERSION_OFF : INVERSION_ON;
-		p->u.qpsk.fec_inner = ves1x93_get_fec (i2c);
+	p->u.qpsk.fec_inner = ves1x93_get_fec (state);
 	/*  XXX FIXME: timing offset !! */
-		break;
-	}
 
-        case FE_SLEEP:
-		if (board_type == BOARD_SIEMENS_PCI)
-			ves1x93_writereg (i2c, 0x1f, 0x00);    /*  LNB power off  */
-		return ves1x93_writereg (i2c, 0x00, 0x08);
-
-        case FE_INIT:
-		return ves1x93_init (i2c);
-
-	case FE_SET_TONE:
-		return -EOPNOTSUPP;  /* the ves1893 can generate the 22k */
-		                     /* let's implement this when we have */
-		                     /* a box that uses the 22K_0 pin... */
+	return 0;
+}
 
-	case FE_SET_VOLTAGE:
-		return ves1x93_set_voltage (i2c, (fe_sec_voltage_t) arg);
+static int ves1x93_sleep(struct dvb_frontend* fe)
+{
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
 
-	default:
-		return -EOPNOTSUPP;
-        };
+	return ves1x93_writereg (state, 0x00, 0x08);
+}
         
-        return 0;
+static void ves1x93_release(struct dvb_frontend* fe)
+{
+	struct ves1x93_state* state = (struct ves1x93_state*) fe->demodulator_priv;
+	kfree(state);
 } 
 
+static struct dvb_frontend_ops ves1x93_ops;
 
-static int ves1x93_attach (struct dvb_i2c_bus *i2c, void **data)
+struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
+				    struct i2c_adapter* i2c)
 {
-	u8 identity = ves1x93_readreg(i2c, 0x1e);
-	struct ves1x93_state* state;
+	struct ves1x93_state* state = NULL;
+	u8 identity;
+
+	/* allocate memory for the internal state */
+	state = (struct ves1x93_state*) kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &ves1x93_ops, sizeof(struct dvb_frontend_ops));
+	state->inversion = INVERSION_OFF;
 
+	/* check if the demod is there + identify it */
+	identity = ves1x93_readreg(state, 0x1e);
 	switch (identity) {
 	case 0xdc: /* VES1893A rev1 */
 		printk("ves1x93: Detected ves1893a rev1\n");
-		demod_type = DEMOD_VES1893;
-		ves1x93_info.name[4] = '8';
+		state->demod_type = DEMOD_VES1893;
+		state->init_1x93_tab = init_1893_tab;
+		state->init_1x93_wtab = init_1893_wtab;
+		state->tab_size = sizeof(init_1893_tab);
 		break;
+
 	case 0xdd: /* VES1893A rev2 */
 		printk("ves1x93: Detected ves1893a rev2\n");
-		demod_type = DEMOD_VES1893;
-		ves1x93_info.name[4] = '8';
+		state->demod_type = DEMOD_VES1893;
+		state->init_1x93_tab = init_1893_tab;
+		state->init_1x93_wtab = init_1893_wtab;
+		state->tab_size = sizeof(init_1893_tab);
 		break;
+
 	case 0xde: /* VES1993 */
 		printk("ves1x93: Detected ves1993\n");
-		demod_type = DEMOD_VES1993;
-		ves1x93_info.name[4] = '9';
+		state->demod_type = DEMOD_VES1993;
+		state->init_1x93_tab = init_1993_tab;
+		state->init_1x93_wtab = init_1993_wtab;
+		state->tab_size = sizeof(init_1993_tab);
 		break;
-	default:
-		dprintk("VES1x93 not found (identity %02x)\n", identity);
-		return -ENODEV;
-	}
-
-	if ((state = kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL)) == NULL) {
-		return -ENOMEM;
-	}
-	state->inversion = INVERSION_OFF;
-	*data = state;
-
-	return dvb_register_frontend (ves1x93_ioctl, i2c, (void*) state, &ves1x93_info);
-}
-
 
-static void ves1x93_detach (struct dvb_i2c_bus *i2c, void *data)
-{
-	kfree(data);
-	dvb_unregister_frontend (ves1x93_ioctl, i2c);
-}
-
-
-static int __init init_ves1x93 (void)
-{
-	switch (board_type) {
-	case BOARD_NOKIA_DBOX2:
-		dprintk("%s: NOKIA_DBOX2\n", __FILE__);
-		break;
-	case BOARD_SAGEM_DBOX2:
-		dprintk("%s: SAGEM_DBOX2\n", __FILE__);
-		break;
-	case BOARD_SIEMENS_PCI:
-		dprintk("%s: SIEMENS_PCI\n", __FILE__);
-		break;
 	default:
-		return -EIO;
+		goto error;
 	}
 
-	return dvb_register_i2c_device (THIS_MODULE, ves1x93_attach, ves1x93_detach);
-}
-
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+	}
+
+static struct dvb_frontend_ops ves1x93_ops = {
+
+	.info = {
+		.name			= "VLSI VES1x93 DVB-S",
+		.type			= FE_QPSK,
+		.frequency_min		= 950000,
+		.frequency_max		= 2150000,
+		.frequency_stepsize	= 125,		 /* kHz for QPSK frontends */
+		.frequency_tolerance	= 29500,
+		.symbol_rate_min	= 1000000,
+		.symbol_rate_max	= 45000000,
+	/*	.symbol_rate_tolerance	=	???,*/
+		.caps = FE_CAN_INVERSION_AUTO |
+			FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+			FE_CAN_QPSK
+	},
+
+	.release = ves1x93_release,
+
+	.init = ves1x93_init,
+	.sleep = ves1x93_sleep,
+
+	.set_frontend = ves1x93_set_frontend,
+	.get_frontend = ves1x93_get_frontend,
+
+	.read_status = ves1x93_read_status,
+	.read_ber = ves1x93_read_ber,
+	.read_signal_strength = ves1x93_read_signal_strength,
+	.read_snr = ves1x93_read_snr,
+	.read_ucblocks = ves1x93_read_ucblocks,
 
-static void __exit exit_ves1x93 (void)
-{
-	dvb_unregister_i2c_device (ves1x93_attach);
-}
-
-
-module_init(init_ves1x93);
-module_exit(exit_ves1x93);
+	.set_voltage = ves1x93_set_voltage,
+};
 
+module_param(debug, int, 0644);
 
-MODULE_DESCRIPTION("VES1x93 DVB-S Frontend");
+MODULE_DESCRIPTION("VLSI VES1x93 DVB-S Demodulator driver");
 MODULE_AUTHOR("Ralph Metzler");
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug,"i");
-MODULE_PARM(board_type,"i");
 
+EXPORT_SYMBOL(ves1x93_attach);
diff -Nru a/drivers/media/dvb/frontends/ves1x93.h b/drivers/media/dvb/frontends/ves1x93.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/frontends/ves1x93.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,50 @@
+/*
+    Driver for VES1893 and VES1993 QPSK Demodulators
+
+    Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
+    Copyright (C) 2001 Ronny Strutz <3des@elitedvb.de>
+    Copyright (C) 2002 Dennis Noermann <dennis.noermann@noernet.de>
+    Copyright (C) 2002-2003 Andreas Oberritter <obi@linuxtv.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 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.
+
+*/
+
+#ifndef VES1X93_H
+#define VES1X93_H
+
+#include <linux/dvb/frontend.h>
+
+struct ves1x93_config
+{
+	/* the demodulator's i2c address */
+	u8 demod_address;
+
+	/* value of XIN to use */
+	u32 xin;
+
+	/* should PWM be inverted? */
+	u8 invert_pwm:1;
+
+	/* PLL maintenance */
+	int (*pll_init)(struct dvb_frontend* fe);
+	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+};
+
+extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
+					   struct i2c_adapter* i2c);
+
+#endif // VES1X93_H
diff -Nru a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
--- a/drivers/media/dvb/ttpci/Kconfig	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/dvb/ttpci/Kconfig	2004-12-24 13:36:18 -08:00
@@ -4,6 +4,12 @@
 	select FW_LOADER
 	select VIDEO_DEV
 	select VIDEO_SAA7146_VV
+	select DVB_VES1820
+	select DVB_VES1X93
+	select DVB_STV0299
+	select DVB_TDA8083
+	select DVB_SP8870
+	select DVB_STV0297
 	help
 	  Support for SAA7146 and AV7110 based DVB cards as produced 
 	  by Fujitsu-Siemens, Technotrend, Hauppauge and others.
@@ -11,11 +17,16 @@
 	  This driver only supports the fullfeatured cards with
 	  onboard MPEG2 decoder.
 
+          This driver needs an external firmware. Please use the script
+          "<kerneldir>/Documentation/dvb/get_dvb_firmware av7110" to
+          download/extract it, and then copy it to /usr/lib/hotplug/firmware.
+
 	  Say Y if you own such a card and want to use it.
 
 config DVB_AV7110_FIRMWARE
 	bool "Compile AV7110 firmware into the driver"
 	depends on DVB_AV7110 && !STANDALONE
+	default y if DVB_AV7110=y
 	help
 	  The AV7110 firmware is normally loaded by the firmware hotplug manager.
 	  If you want to compile the firmware into the driver you need to say
@@ -33,6 +44,7 @@
 config DVB_AV7110_OSD
 	bool "AV7110 OSD support"
 	depends on DVB_AV7110
+	default y if DVB_AV7110=y || DVB_AV7110=m
 	help
 	  The AV7110 firmware provides some code to generate an OnScreenDisplay
 	  on the video output. This is kind of nonstandard and not guaranteed to
@@ -47,6 +59,12 @@
 	tristate "Budget cards"
 	depends on DVB_CORE && PCI
 	select VIDEO_SAA7146
+	select DVB_STV0299
+	select DVB_VES1X93
+	select DVB_VES1820
+	select DVB_L64781
+	select DVB_TDA8083
+	select DVB_TDA10021
 	help
 	  Support for simple SAA7146 based DVB cards
 	  (so called Budget- or Nova-PCI cards) without onboard
@@ -61,6 +79,8 @@
 	tristate "Budget cards with onboard CI connector"
 	depends on DVB_CORE && PCI
 	select VIDEO_SAA7146
+	select DVB_STV0299
+	select DVB_TDA1004X
 	help
 	  Support for simple SAA7146 based DVB cards
 	  (so called Budget- or Nova-PCI cards) without onboard
@@ -79,6 +99,7 @@
 	depends on DVB_CORE && PCI
 	select VIDEO_DEV
 	select VIDEO_SAA7146_VV
+	select DVB_STV0299
 	help
 	  Support for simple SAA7146 based DVB cards
 	  (so called Budget- or Nova-PCI cards) without onboard
@@ -91,8 +112,11 @@
 
 config DVB_BUDGET_PATCH
 	tristate "AV7110 cards with Budget Patch"
-	depends on DVB_BUDGET
+	depends on DVB_CORE && DVB_BUDGET
 	select DVB_AV7110
+	select DVB_STV0299
+	select DVB_VES1X93
+	select DVB_TDA8083
 	help
 	  Support for Budget Patch (full TS) modification on 
 	  SAA7146+AV7110 based cards (DVB-S cards). This
diff -Nru a/drivers/media/dvb/ttpci/Makefile b/drivers/media/dvb/ttpci/Makefile
--- a/drivers/media/dvb/ttpci/Makefile	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/dvb/ttpci/Makefile	2004-12-24 13:36:18 -08:00
@@ -11,7 +11,7 @@
 obj-$(CONFIG_DVB_BUDGET_PATCH) += budget-core.o budget-patch.o ttpci-eeprom.o
 obj-$(CONFIG_DVB_AV7110) += dvb-ttpci.o ttpci-eeprom.o
 
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
+EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
 
 hostprogs-y	:= fdump
 
diff -Nru a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
--- a/drivers/media/dvb/ttpci/av7110.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/media/dvb/ttpci/av7110.c	2004-12-24 13:37:01 -08:00
@@ -41,6 +41,7 @@
 #include <linux/smp_lock.h>
 
 #include <linux/kernel.h>
+#include <linux/moduleparam.h>
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
@@ -50,18 +51,14 @@
 #include <linux/vmalloc.h>
 #include <linux/firmware.h>
 #include <linux/crc32.h>
+#include <linux/i2c.h>
 
 #include <asm/system.h>
 #include <asm/semaphore.h>
 
 #include <linux/dvb/frontend.h>
 
-#include "dvb_i2c.h"
 #include "dvb_frontend.h"
-#include "dvb_functions.h"
-
-
-	#define DEBUG_VARIABLE av7110_debug
 
 #include "ttpci-eeprom.h"
 #include "av7110.h"
@@ -70,33 +67,112 @@
 #include "av7110_ca.h"
 #include "av7110_ipack.h"
 
-
-static void restart_feeds(struct av7110 *av7110);
-
-int av7110_debug = 0;
+int av7110_debug;
 
 static int vidmode=CVBS_RGB_OUT;
 static int pids_off;
 static int adac=DVB_ADAC_TI;
-static int hw_sections = 0;
-static int rgb_on = 0;
+static int hw_sections;
+static int rgb_on;
+static int volume = 255;
+
+module_param_named(debug, av7110_debug, int, 0644);
+MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)");
+module_param(vidmode, int, 0444);
+MODULE_PARM_DESC(vidmode,"analog video out: 0 off, 1 CVBS+RGB (default), 2 CVBS+YC, 3 YC");
+module_param(pids_off, int, 0444);
+MODULE_PARM_DESC(pids_off,"clear video/audio/PCR PID filters when demux is closed");
+module_param(adac, int, 0444);
+MODULE_PARM_DESC(adac,"audio DAC type: 0 TI, 1 CRYSTAL, 2 MSP (use if autodetection fails)");
+module_param(hw_sections, int, 0444);
+MODULE_PARM_DESC(hw_sections, "0 use software section filter, 1 use hardware");
+module_param(rgb_on, int, 0444);
+MODULE_PARM_DESC(rgb_on, "For Siemens DVB-C cards only: Enable RGB control"
+		" signal on SCART pin 16 to switch SCART video mode from CVBS to RGB");
+module_param(volume, int, 0444);
+MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)");
+
+static void restart_feeds(struct av7110 *av7110);
+
+static int av7110_num = 0;
+
+#define FE_FUNC_OVERRIDE(fe_func, av7110_copy, av7110_func) \
+{\
+	if (fe_func != NULL) { \
+		av7110_copy = fe_func; \
+	   	fe_func = av7110_func; \
+	} \
+}
+
+
+static void init_av7110_av(struct av7110 *av7110)
+{
+	struct saa7146_dev *dev=av7110->dev;
+
+	/* set internal volume control to maximum */
+	av7110->adac_type = DVB_ADAC_TI;
+	av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
+
+	av7710_set_video_mode(av7110, vidmode);
+
+	/* handle different card types */
+	/* remaining inits according to card and frontend type */
+	av7110->analog_tuner_flags = 0;
+	av7110->current_input = 0;
+	if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) {
+		printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n",
+			av7110->dvb_adapter->num);
+		av7110->adac_type = DVB_ADAC_CRYSTAL;
+		i2c_writereg(av7110, 0x20, 0x01, 0xd2);
+		i2c_writereg(av7110, 0x20, 0x02, 0x49);
+		i2c_writereg(av7110, 0x20, 0x03, 0x00);
+		i2c_writereg(av7110, 0x20, 0x04, 0x00);
+
+	/**
+	 * some special handling for the Siemens DVB-C cards...
+	 */
+	} else if (0 == av7110_init_analog_module(av7110)) {
+		/* done. */
+	}
+	else if (dev->pci->subsystem_vendor == 0x110a) {
+		printk("dvb-ttpci: DVB-C w/o analog module @ card %d detected\n",
+			av7110->dvb_adapter->num);
+		av7110->adac_type = DVB_ADAC_NONE;
+	}
+	else {
+		av7110->adac_type = adac;
+		printk("dvb-ttpci: adac type set to %d @ card %d\n",
+			av7110->dvb_adapter->num, av7110->adac_type);
+	}
 
-int av7110_num = 0;
+	if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) {
+		// switch DVB SCART on
+		av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
+		av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
+		if (rgb_on &&
+		    (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) {
+			saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
+		//saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8
+	}
+	}
 
+	av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
+	av7110_setup_irc_config(av7110, 0);
+}
 
 static void recover_arm(struct av7110 *av7110)
 {
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n",av7110);
 
 	av7110_bootarm(av7110);
-        dvb_delay(100); 
+	msleep(100);
         restart_feeds(av7110);
 	av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, av7110->ir_config);
 }
 
 static void arm_error(struct av7110 *av7110)
 {
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n",av7110);
 
         av7110->arm_errors++;
         av7110->arm_ready=0;
@@ -106,17 +182,22 @@
 static int arm_thread(void *data)
 {
 	struct av7110 *av7110 = data;
-	unsigned long timeout;
         u16 newloops = 0;
+	int timeout;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n",av7110);
 	
-	dvb_kernel_thread_setup ("arm_mon");
+        lock_kernel ();
+        daemonize ("arm_mon");
+        sigfillset (&current->blocked);
+        unlock_kernel ();
+
 	av7110->arm_thread = current;
 
-	while (1) {
-		timeout = wait_event_interruptible_timeout(av7110->arm_wait,0 != av7110->arm_rmmod, 5*HZ);
-		if (-ERESTARTSYS == timeout || 0 != av7110->arm_rmmod) {
+	for (;;) {
+		timeout = wait_event_interruptible_timeout(av7110->arm_wait,
+							   av7110->arm_rmmod, 5 * HZ);
+		if (-ERESTARTSYS == timeout || av7110->arm_rmmod) {
 			/* got signal or told to quit*/
 			break;
 		}
@@ -131,10 +212,13 @@
                 up(&av7110->dcomlock);
 
                 if (newloops==av7110->arm_loops) {
-                        printk(KERN_ERR "av7110%d: ARM crashed!\n",
+			printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
 				av7110->dvb_adapter->num);
 
 			arm_error(av7110);
+			av7710_set_video_mode(av7110, vidmode);
+
+			init_av7110_av(av7110);
 
                         if (down_interruptible(&av7110->dcomlock))
                                 break;
@@ -160,7 +244,7 @@
 {
 	static struct av7110 *last;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n",av7110);
 
 	if (!av7110)
 		av7110 = last;
@@ -177,27 +261,27 @@
 
 void av7110_register_irc_handler(void (*func)(u32)) 
 {
-	DEB_EE(("registering %p\n", func));
+	dprintk(4, "registering %p\n", func);
         irc_handler = func;
 }
 
 void av7110_unregister_irc_handler(void (*func)(u32)) 
 {
-	DEB_EE(("unregistering %p\n", func));
+	dprintk(4, "unregistering %p\n", func);
         irc_handler = NULL;
 }
 
-void run_handlers(unsigned long ircom) 
+static void run_handlers(unsigned long ircom)
 {
         if (irc_handler != NULL)
                 (*irc_handler)((u32) ircom);
 }
 
-DECLARE_TASKLET(irtask,run_handlers,0);
+static DECLARE_TASKLET(irtask, run_handlers, 0);
 
-void IR_handle(struct av7110 *av7110, u32 ircom)
+static void IR_handle(struct av7110 *av7110, u32 ircom)
 {
-	DEB_S(("av7110: ircommand = %08x\n", ircom));
+	dprintk(4, "ircommand = %08x\n", ircom);
         irtask.data = (unsigned long) ircom;
         tasklet_schedule(&irtask);
 }
@@ -206,14 +290,12 @@
  * IRQ handling
  ****************************************************************************/
 
-static inline int DvbDmxFilterCallback(u8 * buffer1, size_t buffer1_len,
+static int DvbDmxFilterCallback(u8 *buffer1, size_t buffer1_len,
                      u8 * buffer2, size_t buffer2_len,
                      struct dvb_demux_filter *dvbdmxfilter,
                      enum dmx_success success,
                      struct av7110 *av7110)
 {
-	DEB_INT(("av7110: %p\n",av7110));
-
         if (!dvbdmxfilter->feed->demux->dmx.frontend)
                 return 0;
         if (dvbdmxfilter->feed->demux->dmx.frontend->source==DMX_MEMORY_FE)
@@ -273,12 +355,11 @@
         int type=av7110->debitype;
         int handle=(type>>8)&0x1f;
 	
-//	DEB_EE(("av7110: %p\n",av7110));
+//	dprintk(4, "%p\n",av7110);
 
         print_time("debi");
-        saa7146_write(av7110->dev, IER, 
-                      saa7146_read(av7110->dev, IER) & ~MASK_19 );
-        saa7146_write(av7110->dev, ISR, MASK_19 );
+	SAA7146_IER_DISABLE(av7110->dev, MASK_19);
+	SAA7146_ISR_CLEAR(av7110->dev, MASK_19);
 
         if (type==-1) {
 		printk("DEBI irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
@@ -405,10 +486,8 @@
         u32 rxbuf, txbuf;
         int len;
         
-        //printk("GPIO0 irq\n");        
-
         if (av7110->debitype !=-1)
-		printk("GPIO0 irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
+		printk("dvb-ttpci: GPIO0 irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
 		       jiffies, saa7146_read(av7110->dev, PSR),
 		       saa7146_read(av7110->dev, SSR));
        
@@ -416,9 +495,8 @@
 
 	ARM_ClearIrq(av7110);
 
-        saa7146_write(av7110->dev, IER, 
-                      saa7146_read(av7110->dev, IER) & ~MASK_19 );
-        saa7146_write(av7110->dev, ISR, MASK_19 );
+	SAA7146_IER_DISABLE(av7110->dev, MASK_19);
+	SAA7146_ISR_CLEAR(av7110->dev, MASK_19);
 
         av7110->debitype = irdebi(av7110, DEBINOSWAP, IRQ_STATE, 0, 2);
         av7110->debilen  = irdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
@@ -426,10 +504,10 @@
         txbuf=irdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
 	len = (av7110->debilen + 3) & ~3;
 
-//        DEB_D(("GPIO0 irq %d %d\n", av7110->debitype, av7110->debilen));
+//	dprintk(8, "GPIO0 irq %d %d\n", av7110->debitype, av7110->debilen);
         print_time("gpio");
 
-//       DEB_D(("GPIO0 irq %02x\n", av7110->debitype&0xff));        
+//	dprintk(8, "GPIO0 irq %02x\n", av7110->debitype&0xff);
         switch (av7110->debitype&0xff) {
 
         case DATA_TS_PLAY:
@@ -448,10 +526,10 @@
                 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
 
 		av7110->video_size.h = h_ar & 0xfff;
-		DEB_D(("GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n",
+		dprintk(8, "GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n",
 				av7110->video_size.w,
 				av7110->video_size.h,
-				av7110->video_size.aspect_ratio));
+				av7110->video_size.aspect_ratio);
 
 		event.type = VIDEO_EVENT_SIZE_CHANGED;
 		event.u.size.w = av7110->video_size.w;
@@ -504,7 +582,7 @@
                 wake_up(&cibuf->queue);
                 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
                 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
-		saa7146_wait_for_debi_done(av7110->dev);
+		saa7146_wait_for_debi_done(av7110->dev, 0);
                 saa7146_write(av7110->dev, IER, 
                               saa7146_read(av7110->dev, IER) | MASK_19 );
 		if (len < 5)
@@ -539,10 +617,10 @@
                         iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
                         break;
                 } 
-                DEB_D(("GPIO0 PES_PLAY len=%04x\n", len));        
+		dprintk(8, "GPIO0 PES_PLAY len=%04x\n", len);
                 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
                 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
-		saa7146_wait_for_debi_done(av7110->dev);
+		saa7146_wait_for_debi_done(av7110->dev, 0);
                 saa7146_write(av7110->dev, IER, 
                               saa7146_read(av7110->dev, IER) | MASK_19 );
 
@@ -569,7 +647,7 @@
                 memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len);
                 av7110->bmpp+=len;
                 av7110->bmplen-=len;
-		saa7146_wait_for_debi_done(av7110->dev);
+		saa7146_wait_for_debi_done(av7110->dev, 0);
                 saa7146_write(av7110->dev, IER, 
                               saa7146_read(av7110->dev, IER) | MASK_19 );
 		if (len < 5)
@@ -591,7 +669,7 @@
 
         case DATA_TS_RECORD:
         case DATA_PES_RECORD:
-		saa7146_wait_for_debi_done(av7110->dev);
+		saa7146_wait_for_debi_done(av7110->dev, 0);
                 saa7146_write(av7110->dev, IER, 
                               saa7146_read(av7110->dev, IER) | MASK_19);
                 irdebi(av7110, DEBISWAB, DPRAM_BASE+rxbuf, 0, len);
@@ -599,7 +677,7 @@
                 return;
 
         case DATA_DEBUG_MESSAGE:
-		saa7146_wait_for_debi_done(av7110->dev);
+		saa7146_wait_for_debi_done(av7110->dev, 0);
                 if (!len || len>0xff) {
                         iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
                         break;
@@ -617,7 +695,7 @@
                 break;
 
         default:
-                printk("gpioirq unknown type=%d len=%d\n", 
+		printk("dvb-ttpci: gpioirq unknown type=%d len=%d\n",
                        av7110->debitype, av7110->debilen);
                 break;
         }      
@@ -634,10 +712,12 @@
 	struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (cmd == OSD_SEND_CMD)
 		return av7110_osd_cmd(av7110, (osd_cmd_t *) parg);
+	if (cmd == OSD_GET_CAPABILITY)
+		return av7110_osd_capability(av7110, (osd_cap_t *) parg);
 
 	return -EINVAL;
         }
@@ -663,7 +743,7 @@
 static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
 			  u16 subpid, u16 pcrpid)
         {
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (vpid == 0x1fff || apid == 0x1fff ||
 	    ttpid == 0x1fff || subpid == 0x1fff || pcrpid == 0x1fff) {
@@ -681,7 +761,7 @@
 void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
 		u16 subpid, u16 pcrpid)
 {
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
         
 	if (down_interruptible(&av7110->pid_mutex))
 		return;
@@ -720,7 +800,7 @@
 //	u16 mode=0x0320;
 	u16 mode=0xb96a;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (dvbdmxfilter->type == DMX_TYPE_SEC) {
 		if (hw_sections) {
@@ -743,9 +823,13 @@
 	buf[3] = mode;
 
 	ret = av7110_fw_request(av7110, buf, 20, &handle, 1);
-	if (ret < 0) {
-		printk("StartHWFilter error\n");
-		return ret;
+	if (ret != 0 || handle >= 32) {
+		printk("dvb-ttpci: %s error  buf %04x %04x %04x %04x  "
+				"ret %x  handle %04x\n",
+				__FUNCTION__, buf[0], buf[1], buf[2], buf[3],
+				ret, handle);
+		dvbdmxfilter->hw_handle = 0xffff;
+		return -1;
         }
 
 	av7110->handle2filter[handle] = dvbdmxfilter;
@@ -762,13 +846,12 @@
 	int ret;
 	u16 handle;
         
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	handle = dvbdmxfilter->hw_handle;
-	if (handle > 32) {
-		DEB_S(("dvb: StopHWFilter tried to stop invalid filter %d.\n",
-		       handle));
-		DEB_S(("dvb: filter type = %d\n", dvbdmxfilter->type));
+	if (handle >= 32) {
+		printk("%s tried to stop invalid filter %04x, filter type = %x\n",
+				__FUNCTION__, handle, dvbdmxfilter->type);
 		return 0;
                 }
 
@@ -778,11 +861,11 @@
 	buf[1] = 1;
 	buf[2] = handle;
 	ret = av7110_fw_request(av7110, buf, 3, answ, 2);
-	if (ret)
-		printk("StopHWFilter error\n");
-
-	if (answ[1] != handle) {
-		DEB_S(("dvb: filter %d shutdown error :%d\n", handle, answ[1]));
+	if (ret != 0 || answ[1] != handle) {
+		printk("dvb-ttpci: %s error  cmd %04x %04x %04x  ret %x  "
+				"resp %04x %04x  pid %d\n",
+				__FUNCTION__, buf[0], buf[1], buf[2], ret,
+				answ[0], answ[1], dvbdmxfilter->feed->pid);
 		ret = -1;
         }
         return ret;
@@ -796,7 +879,7 @@
 	u16 *pid = dvbdmx->pids, npids[5];
 	int i;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 
 	npids[0] = npids[1] = npids[2] = npids[3] = npids[4] = 0xffff;
 	i = dvbdmxfeed->pes_type;
@@ -829,7 +912,7 @@
 	u16 *pid = dvbdmx->pids, npids[5];
 	int i;
                 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
                 
 	if (dvbdmxfeed->pes_type <= 1) {
 		av7110_av_stop(av7110, dvbdmxfeed->pes_type ?  RP_VIDEO : RP_AUDIO);
@@ -860,9 +943,9 @@
 static int av7110_start_feed(struct dvb_demux_feed *feed)
 {
 	struct dvb_demux *demux = feed->demux;
-	struct av7110 *av7110 = (struct av7110 *) demux->priv;
+	struct av7110 *av7110 = demux->priv;
                 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
                 
 	if (!demux->dmx.frontend)
 		return -EINVAL;
@@ -918,9 +1001,9 @@
 static int av7110_stop_feed(struct dvb_demux_feed *feed)
 {
 	struct dvb_demux *demux = feed->demux;
-	struct av7110 *av7110 = (struct av7110 *) demux->priv;
+	struct av7110 *av7110 = demux->priv;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (feed->type == DMX_TYPE_TS) {
 		if (feed->ts_type & TS_DECODER) {
@@ -962,7 +1045,7 @@
 	int mode;
 	int i;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 
 	mode = av7110->playing;
 	av7110->playing = 0;
@@ -995,7 +1078,7 @@
 		BUG();
 	av7110 = (struct av7110 *) dvbdemux->priv;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (num != 0)
 		return -EINVAL;
@@ -1005,14 +1088,14 @@
 		printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__);
 		return -EIO;
 }
-	DEB_EE(("av7110: fwstc = %04hx %04hx %04hx %04hx\n",
-		fwstc[0], fwstc[1], fwstc[2], fwstc[3]));
+	dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n",
+		fwstc[0], fwstc[1], fwstc[2], fwstc[3]);
 
 	*stc =	(((uint64_t) ((fwstc[3] & 0x8000) >> 15)) << 32) |
 		(((uint64_t)  fwstc[1]) << 16) | ((uint64_t) fwstc[0]);
 	*base = 1;
         
-	DEB_EE(("av7110: stc = %lu\n", (unsigned long)*stc));
+	dprintk(4, "stc = %lu\n", (unsigned long)*stc);
 
 	return 0;
 }
@@ -1022,71 +1105,44 @@
  * SEC device file operations
  ******************************************************************************/
 
-static int av7110_diseqc_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-	struct av7110 *av7110 = fe->before_after_data;
 
-	DEB_EE(("av7110: %p\n", av7110));
+static int av7110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+{
+	struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
 
-	switch (cmd) {
-	case FE_SET_TONE:
-		switch ((fe_sec_tone_mode_t) arg) {
+	switch (tone) {
 		case SEC_TONE_ON:
 			Set22K(av7110, 1);
 			break;
 		case SEC_TONE_OFF:
 			Set22K(av7110, 0);
 			break;
+
 		default:
 			return -EINVAL;
-};
-		break;
-
-	case FE_DISEQC_SEND_MASTER_CMD:
-	{
-		struct dvb_diseqc_master_cmd *cmd = arg;
-		av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1);
-		break;
 	}
 
-	case FE_DISEQC_SEND_BURST:
-		av7110_diseqc_send(av7110, 0, NULL, (unsigned long) arg);
-		break;
-
-	default:
-		return -EOPNOTSUPP;
-};
-
 	return 0;
 }
 
-
-static void av7110_before_after_tune (fe_status_t s, void *data)
+static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe,
+					 struct dvb_diseqc_master_cmd* cmd)
 {
-	struct av7110 *av7110 = data;
+	struct av7110* av7110 = fe->dvb->priv;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1);
 
-        av7110->fe_synced = (s & FE_HAS_LOCK) ? 1 : 0;
-
-        if (av7110->playing)
-                return;
+	return 0;
+}
 
-        if (down_interruptible(&av7110->pid_mutex))
-                return;
+static int av7110_diseqc_send_burst(struct dvb_frontend* fe,
+				    fe_sec_mini_cmd_t minicmd)
+{
+	struct av7110* av7110 = fe->dvb->priv;
 
-	if (av7110->fe_synced) {
-                SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO], 
-                        av7110->pids[DMX_PES_AUDIO], 
-                        av7110->pids[DMX_PES_TELETEXT], 0, 
-                        av7110->pids[DMX_PES_PCR]);
-		av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
-	} else {
-		SetPIDs(av7110, 0, 0, 0, 0, 0);
-		av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, FlushTSQueue, 0);
-	}
+	av7110_diseqc_send(av7110, 0, NULL, minicmd);
 
-        up(&av7110->pid_mutex);
+	return 0;
 }
 
 
@@ -1095,22 +1151,13 @@
         int ret, i;
         struct dvb_demux *dvbdemux=&av7110->demux;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 
         if (av7110->registered)
                 return -1;
 
         av7110->registered=1;
 
-	dvb_add_frontend_notifier (av7110->dvb_adapter,
-				   av7110_before_after_tune, av7110);
-
-	/**
-	 *   init DiSEqC stuff
-	 */
-	dvb_add_frontend_ioctls (av7110->dvb_adapter,
-				 av7110_diseqc_ioctl, NULL, av7110);
-
         dvbdemux->priv = (void *) av7110;
 
 	for (i=0; i<32; i++)
@@ -1170,7 +1217,7 @@
 {
         struct dvb_demux *dvbdemux=&av7110->demux;
 
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 
         if (!av7110->registered)
                 return;
@@ -1184,12 +1231,8 @@
         dvb_dmxdev_release(&av7110->dmxdev);
         dvb_dmx_release(&av7110->demux);
 
-	dvb_remove_frontend_notifier (av7110->dvb_adapter,
-				      av7110_before_after_tune);
-
-	dvb_remove_frontend_ioctls (av7110->dvb_adapter,
-				    av7110_diseqc_ioctl, NULL);
-
+	if (av7110->fe != NULL)
+		dvb_unregister_frontend(av7110->fe);
 	dvb_unregister_device(av7110->osd_dev);
 	av7110_av_unregister(av7110);
 	av7110_ca_unregister(av7110);
@@ -1203,19 +1246,18 @@
 int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val)
 {
 	u8 msg[2] = { reg, val };
-	struct dvb_i2c_bus *i2c = av7110->i2c_bus;
 	struct i2c_msg msgs;
 	
 	msgs.flags = 0;
 	msgs.addr = id / 2;
 	msgs.len = 2;
 	msgs.buf = msg;
-	return i2c->xfer(i2c, &msgs, 1);
+	return i2c_transfer(&av7110->i2c_adap, &msgs, 1);
 }
 
+#if 0
 u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg)
 {
-	struct dvb_i2c_bus *i2c = av7110->i2c_bus;
 	u8 mm1[] = {0x00};
 	u8 mm2[] = {0x00};
 	struct i2c_msg msgs[2];
@@ -1226,16 +1268,11 @@
 	mm1[0] = reg;
 	msgs[0].len = 1; msgs[1].len = 1;
 	msgs[0].buf = mm1; msgs[1].buf = mm2;
-	i2c->xfer(i2c, msgs, 2);
+	i2c_transfer(&av7110->i2c_adap, msgs, 2);
 
 	return mm2[0];
 }
-
-static int master_xfer(struct dvb_i2c_bus *i2c, const struct i2c_msg msgs[], int num)
-{
-	struct saa7146_dev *dev = i2c->data;
-	return saa7146_i2c_transfer(dev, msgs, num, 6);
-}
+#endif
 
 /****************************************************************************
  * INITIALIZATION
@@ -1310,44 +1347,616 @@
 	/* request the av7110 firmware, this will block until someone uploads it */
 	ret = request_firmware(&fw, "dvb-ttpci-01.fw", &av7110->dev->pci->dev);
 	if (ret) {
-		printk("dvb-ttpci: cannot request firmware!\n");
+		if (ret == -ENOENT) {
+			printk(KERN_ERR "dvb-ttpci: could not load firmware,"
+			       " file not found: dvb-ttpci-01.fw\n");
+			printk(KERN_ERR "dvb-ttpci: usually this should be in"
+			       " /usr/lib/hotplug/firmware\n");
+			printk(KERN_ERR "dvb-ttpci: and can be downloaded here"
+			       " http://www.linuxtv.org/download/dvb/firmware/\n");
+		} else
+			printk(KERN_ERR "dvb-ttpci: cannot request firmware"
+			       " (error %i)\n", ret);
 		return -EINVAL;
 	}
+
 	if (fw->size <= 200000) {
 		printk("dvb-ttpci: this firmware is way too small.\n");
+		release_firmware(fw);
 		return -EINVAL;
 	}
+
 	/* check if the firmware is available */
 	av7110->bin_fw = (unsigned char*) vmalloc(fw->size);
 	if (NULL == av7110->bin_fw) {
-		DEB_D(("out of memory\n"));
+		dprintk(1, "out of memory\n");
+		release_firmware(fw);
 		return -ENOMEM;
 	}
+
 	memcpy(av7110->bin_fw, fw->data, fw->size);
 	av7110->size_fw = fw->size;
 	if ((ret = check_firmware(av7110)))
 		vfree(av7110->bin_fw);
+
+	release_firmware(fw);
 	return ret;
 }
 #endif
 
+
+static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
+	u8 pwr = 0;
+	u8 buf[4];
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
+	u32 div = (params->frequency + 479500) / 125;
+
+	if (params->frequency > 2000000) pwr = 3;
+	else if (params->frequency > 1800000) pwr = 2;
+	else if (params->frequency > 1600000) pwr = 1;
+	else if (params->frequency > 1200000) pwr = 0;
+	else if (params->frequency >= 1100000) pwr = 1;
+	else pwr = 2;
+
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = ((div & 0x18000) >> 10) | 0x95;
+	buf[3] = (pwr << 6) | 0x30;
+
+        // NOTE: since we're using a prescaler of 2, we set the
+	// divisor frequency to 62.5kHz and divide by 125 above
+
+	if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static struct ves1x93_config alps_bsrv2_config = {
+	.demod_address = 0x08,
+	.xin = 90100000UL,
+	.invert_pwm = 0,
+	.pll_set = alps_bsrv2_pll_set,
+};
+
+
+static u8 alps_bsru6_inittab[] = {
+	0x01, 0x15,
+	0x02, 0x30,
+	0x03, 0x00,
+	0x04, 0x7d,   /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
+	0x05, 0x35,   /* I2CT = 0, SCLT = 1, SDAT = 1 */
+	0x06, 0x40,   /* DAC not used, set to high impendance mode */
+	0x07, 0x00,   /* DAC LSB */
+	0x08, 0x40,   /* DiSEqC off, LNB power on OP2/LOCK pin on */
+	0x09, 0x00,   /* FIFO */
+	0x0c, 0x51,   /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
+	0x0d, 0x82,   /* DC offset compensation = ON, beta_agc1 = 2 */
+	0x0e, 0x23,   /* alpha_tmg = 2, beta_tmg = 3 */
+	0x10, 0x3f,   // AGC2  0x3d
+	0x11, 0x84,
+	0x12, 0xb5,   // Lock detect: -64  Carrier freq detect:on
+	0x15, 0xc9,   // lock detector threshold
+	0x16, 0x00,
+	0x17, 0x00,
+	0x18, 0x00,
+	0x19, 0x00,
+	0x1a, 0x00,
+	0x1f, 0x50,
+	0x20, 0x00,
+	0x21, 0x00,
+	0x22, 0x00,
+	0x23, 0x00,
+	0x28, 0x00,  // out imp: normal  out type: parallel FEC mode:0
+	0x29, 0x1e,  // 1/2 threshold
+	0x2a, 0x14,  // 2/3 threshold
+	0x2b, 0x0f,  // 3/4 threshold
+	0x2c, 0x09,  // 5/6 threshold
+	0x2d, 0x05,  // 7/8 threshold
+	0x2e, 0x01,
+	0x31, 0x1f,  // test all FECs
+	0x32, 0x19,  // viterbi and synchro search
+	0x33, 0xfc,  // rs control
+	0x34, 0x93,  // error control
+	0x0f, 0x52,
+	0xff, 0xff
+};
+
+static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
+{
+	u8 aclk = 0;
+	u8 bclk = 0;
+
+	if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
+	else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
+	else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
+	else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
+	else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
+	else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
+
+	stv0299_writereg (fe, 0x13, aclk);
+	stv0299_writereg (fe, 0x14, bclk);
+	stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg (fe, 0x20, (ratio >>  8) & 0xff);
+	stv0299_writereg (fe, 0x21, (ratio      ) & 0xf0);
+
+	return 0;
+}
+
+static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
+	int ret;
+	u8 data[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	if ((params->frequency < 950000) || (params->frequency > 2150000))
+		return -EINVAL;
+
+	div = (params->frequency + (125 - 1)) / 125; // round correctly
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
+	data[3] = 0xC4;
+
+	if (params->frequency > 1530000) data[3] = 0xc0;
+
+	ret = i2c_transfer (&av7110->i2c_adap, &msg, 1);
+	if (ret != 1)
+		return -EIO;
+	return 0;
+}
+
+static struct stv0299_config alps_bsru6_config = {
+
+	.demod_address = 0x68,
+	.inittab = alps_bsru6_inittab,
+	.mclk = 88000000UL,
+	.invert = 1,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_1,
+	.volt13_op0_op1 = STV0299_VOLT13_OP1,
+	.min_delay_ms = 100,
+	.set_symbol_rate = alps_bsru6_set_symbol_rate,
+	.pll_set = alps_bsru6_pll_set,
+};
+
+
+
+static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+	u32 div;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	div = (params->frequency + 35937500 + 31250) / 62500;
+
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x85 | ((div >> 10) & 0x60);
+	data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81);
+
+	if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static struct ves1820_config alps_tdbe2_config = {
+	.demod_address = 0x09,
+	.xin = 57840000UL,
+	.invert = 1,
+	.selagc = VES1820_SELAGC_SIGNAMPERR,
+	.pll_set = alps_tdbe2_pll_set,
+};
+
+
+
+
+static int grundig_29504_451_pll_set(struct dvb_frontend* fe,
+				     struct dvb_frontend_parameters* params)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+	u32 div;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	div = params->frequency / 125;
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x8e;
+	data[3] = 0x00;
+
+	if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static struct tda8083_config grundig_29504_451_config = {
+	.demod_address = 0x68,
+	.pll_set = grundig_29504_451_pll_set,
+};
+
+
+
+static int philips_cd1516_pll_set(struct dvb_frontend* fe,
+				  struct dvb_frontend_parameters* params)
+{
+        struct av7110* av7110 = fe->dvb->priv;
+	u32 div;
+	u32 f = params->frequency;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	div = (f + 36125000 + 31250) / 62500;
+
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x8e;
+	data[3] = (f < 174000000 ? 0xa1 : f < 470000000 ? 0x92 : 0x34);
+
+	if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static struct ves1820_config philips_cd1516_config = {
+	.demod_address = 0x09,
+	.xin = 57840000UL,
+	.invert = 1,
+	.selagc = VES1820_SELAGC_SIGNAMPERR,
+	.pll_set = philips_cd1516_pll_set,
+};
+
+
+
+static int alps_tdlb7_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+	u32 div, pwr;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	div = (params->frequency + 36200000) / 166666;
+
+	if (params->frequency <= 782000000)
+		pwr = 1;
+	else
+		pwr = 2;
+
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x85;
+	data[3] = pwr << 6;
+
+	if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static int alps_tdlb7_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
+{
+	struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
+
+	return request_firmware(fw, name, &av7110->dev->pci->dev);
+}
+
+static struct sp8870_config alps_tdlb7_config = {
+
+	.demod_address = 0x71,
+	.pll_set = alps_tdlb7_pll_set,
+	.request_firmware = alps_tdlb7_request_firmware,
+};
+
+
+
+static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+	u32 div;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x63, .flags = 0, .buf = data, .len = sizeof(data) };
+	struct i2c_msg readmsg = { .addr = 0x63, .flags = I2C_M_RD, .buf = data, .len = 1 };
+	int i;
+
+	div = (params->frequency + 36150000 + 31250) / 62500;
+
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0xce;
+
+	if (params->frequency < 45000000)
+		return -EINVAL;
+	else if (params->frequency < 137000000)
+		data[3] = 0x01;
+	else if (params->frequency < 403000000)
+		data[3] = 0x02;
+	else if (params->frequency < 860000000)
+		data[3] = 0x04;
+	else
+		return -EINVAL;
+
+	stv0297_enable_plli2c(fe);
+	if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) {
+		printk("nexusca: pll transfer failed!\n");
+		return -EIO;
+	}
+
+	// wait for PLL lock
+	for(i=0; i< 20; i++) {
+
+		stv0297_enable_plli2c(fe);
+		if (i2c_transfer (&av7110->i2c_adap, &readmsg, 1) == 1)
+			if (data[0] & 0x40) break;
+		msleep(10);
+	}
+
+	return 0;
+}
+
+static struct stv0297_config nexusca_stv0297_config = {
+
+	.demod_address = 0x1C,
+	.pll_set = nexusca_stv0297_pll_set,
+};
+
+
+static void av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
+{
+	int synced = (status & FE_HAS_LOCK) ? 1 : 0;
+
+	av7110->fe_status = status;
+
+	if (av7110->fe_synced == synced)
+		return;
+
+	av7110->fe_synced = synced;
+
+	if (av7110->playing)
+		return;
+
+	if (down_interruptible(&av7110->pid_mutex))
+		return;
+
+	if (av7110->fe_synced) {
+		SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO],
+			av7110->pids[DMX_PES_AUDIO],
+			av7110->pids[DMX_PES_TELETEXT], 0,
+			av7110->pids[DMX_PES_PCR]);
+	                av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
+	} else {
+			SetPIDs(av7110, 0, 0, 0, 0, 0);
+		av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0);
+		av7110_wait_msgstate(av7110, GPMQBusy);
+	}
+
+	up(&av7110->pid_mutex);
+}
+
+static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+	av7110_fe_lock_fix(av7110, 0);
+	return av7110->fe_set_frontend(fe, params);
+}
+
+static int av7110_fe_init(struct dvb_frontend* fe)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+
+	av7110_fe_lock_fix(av7110, 0);
+	return av7110->fe_init(fe);
+}
+
+static int av7110_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+	int ret;
+
+	/* call the real implementation */
+	ret = av7110->fe_read_status(fe, status);
+	if (ret)
+		return ret;
+
+	if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK)) {
+		av7110_fe_lock_fix(av7110, *status);
+	}
+
+	return 0;
+}
+
+static int av7110_fe_diseqc_reset_overload(struct dvb_frontend* fe)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+
+	av7110_fe_lock_fix(av7110, 0);
+	return av7110->fe_diseqc_reset_overload(fe);
+}
+
+static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
+					    struct dvb_diseqc_master_cmd* cmd)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+
+	av7110_fe_lock_fix(av7110, 0);
+	return av7110->fe_diseqc_send_master_cmd(fe, cmd);
+}
+
+static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+
+	av7110_fe_lock_fix(av7110, 0);
+	return av7110->fe_diseqc_send_burst(fe, minicmd);
+}
+
+static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+
+	av7110_fe_lock_fix(av7110, 0);
+	return av7110->fe_set_tone(fe, tone);
+}
+
+static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+
+	av7110_fe_lock_fix(av7110, 0);
+	return av7110->fe_set_voltage(fe, voltage);
+}
+
+static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned int cmd)
+{
+	struct av7110* av7110 = fe->dvb->priv;
+
+	av7110_fe_lock_fix(av7110, 0);
+	return av7110->fe_dishnetwork_send_legacy_command(fe, cmd);
+}
+
+static u8 read_pwm(struct av7110* av7110)
+{
+	u8 b = 0xff;
+	u8 pwm;
+	struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
+				 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
+
+        if ((i2c_transfer(&av7110->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
+		pwm = 0x48;
+
+	return pwm;
+}
+
+static void frontend_init(struct av7110 *av7110)
+{
+	if (av7110->dev->pci->subsystem_vendor == 0x110a) {
+		switch(av7110->dev->pci->subsystem_device) {
+		case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??))
+			av7110->fe = ves1820_attach(&philips_cd1516_config,
+						    &av7110->i2c_adap, read_pwm(av7110));
+			break;
+		}
+
+	} else if (av7110->dev->pci->subsystem_vendor == 0x13c2) {
+		switch(av7110->dev->pci->subsystem_device) {
+		case 0x0000: // Hauppauge/TT WinTV DVB-S rev1.X
+		case 0x0003: // Hauppauge/TT WinTV Nexus-S Rev 2.X
+		case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE
+
+			// try the ALPS BSRV2 first of all
+			av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap);
+			if (av7110->fe) {
+				av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
+				av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
+				av7110->fe->ops->set_tone = av7110_set_tone;
+				break;
+			}
+
+			// try the ALPS BSRU6 now
+			av7110->fe = stv0299_attach(&alps_bsru6_config, &av7110->i2c_adap);
+			if (av7110->fe) {
+				av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
+				av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
+				av7110->fe->ops->set_tone = av7110_set_tone;
+				break;
+			}
+
+			// Try the grundig 29504-451
+                        av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap);
+			if (av7110->fe) {
+				av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
+				av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
+				av7110->fe->ops->set_tone = av7110_set_tone;
+				break;
+			}
+
+			/* Try DVB-C cards */
+			switch(av7110->dev->pci->subsystem_device) {
+			case 0x0000:
+				/* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */
+				av7110->fe = ves1820_attach(&philips_cd1516_config, &av7110->i2c_adap,
+							read_pwm(av7110));
+				break;
+			case 0x0003:
+				/* Haupauge DVB-C 2.1 VES1820/ALPS TDBE2 */
+				av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap,
+							read_pwm(av7110));
+				break;
+			}
+			break;
+
+		case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
+
+			// ALPS TDLB7
+                        av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap);
+			break;
+
+		case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
+
+                        av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
+			break;
+
+		case 0x000A: // Hauppauge/TT Nexus-CA rev1.X
+
+			av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap, 0x7b);
+			if (av7110->fe) {
+				/* set TDA9819 into DVB mode */
+				saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD)
+				saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9198 pin30(VIF)
+
+				/* tuner on this needs a slower i2c bus speed */
+				av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
+				break;
+			}
+		}
+	}
+
+	if (av7110->fe == NULL) {
+		printk("dvb-ttpci: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
+		       av7110->dev->pci->vendor,
+		       av7110->dev->pci->device,
+		       av7110->dev->pci->subsystem_vendor,
+		       av7110->dev->pci->subsystem_device);
+	} else {
+		FE_FUNC_OVERRIDE(av7110->fe->ops->init, av7110->fe_init, av7110_fe_init);
+		FE_FUNC_OVERRIDE(av7110->fe->ops->read_status, av7110->fe_read_status, av7110_fe_read_status);
+		FE_FUNC_OVERRIDE(av7110->fe->ops->diseqc_reset_overload, av7110->fe_diseqc_reset_overload, av7110_fe_diseqc_reset_overload);
+		FE_FUNC_OVERRIDE(av7110->fe->ops->diseqc_send_master_cmd, av7110->fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd);
+		FE_FUNC_OVERRIDE(av7110->fe->ops->diseqc_send_burst, av7110->fe_diseqc_send_burst, av7110_fe_diseqc_send_burst);
+		FE_FUNC_OVERRIDE(av7110->fe->ops->set_tone, av7110->fe_set_tone, av7110_fe_set_tone);
+		FE_FUNC_OVERRIDE(av7110->fe->ops->set_voltage, av7110->fe_set_voltage, av7110_fe_set_voltage;)
+		FE_FUNC_OVERRIDE(av7110->fe->ops->dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command);
+		FE_FUNC_OVERRIDE(av7110->fe->ops->set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend);
+
+		if (dvb_register_frontend(av7110->dvb_adapter, av7110->fe)) {
+			printk("av7110: Frontend registration failed!\n");
+			if (av7110->fe->ops->release)
+				av7110->fe->ops->release(av7110->fe);
+			av7110->fe = NULL;
+		}
+	}
+}
+
 static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data *pci_ext)
 {
 	struct av7110 *av7110 = NULL;
 	int ret = 0;
 
-	DEB_EE(("dev: %p\n", dev));
+	dprintk(4, "dev: %p\n", dev);
 
 	/* prepare the av7110 device struct */
 	if (!(av7110 = kmalloc (sizeof (struct av7110), GFP_KERNEL))) {
-		printk ("%s: out of memory!\n", __FUNCTION__);
+		dprintk(1, "out of memory\n");
 		return -ENOMEM;
 	}
-	DEB_EE(("av7110: %p\n", av7110));
+
 	memset(av7110, 0, sizeof(struct av7110));
 	
 	av7110->card_name = (char*)pci_ext->ext_priv;
-	av7110->dev=(struct saa7146_dev *)dev;
+	av7110->dev = dev;
 	dev->ext_priv = av7110;
 
 	if ((ret = get_firmware(av7110))) {
@@ -1361,18 +1970,22 @@
 	   get recognized before the main driver is fully loaded */
 	saa7146_write(dev, GPIO_CTRL, 0x500000);
 
-	saa7146_i2c_adapter_prepare(dev, NULL, 0, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */
+#ifdef I2C_ADAP_CLASS_TV_DIGITAL
+	av7110->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
+#else
+	av7110->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
+#endif
+	strlcpy(av7110->i2c_adap.name, pci_ext->ext_priv, sizeof(av7110->i2c_adap.name));
 
-	av7110->i2c_bus = dvb_register_i2c_bus (master_xfer, dev,
-						av7110->dvb_adapter, 0);
+	saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */
 
-	if (!av7110->i2c_bus) {
+	if (i2c_add_adapter(&av7110->i2c_adap) < 0) {
 		dvb_unregister_adapter (av7110->dvb_adapter);
 		kfree(av7110);
 		return -ENOMEM;
 	}
 
-	ttpci_eeprom_parse_mac(av7110->i2c_bus);
+	ttpci_eeprom_parse_mac(&av7110->i2c_adap, av7110->dvb_adapter->proposed_mac);
 
 	saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
 	saa7146_write(dev, BCS_CTRL, 0x80400040);
@@ -1394,11 +2007,11 @@
         /* locks for data transfers from/to AV7110 */
         spin_lock_init (&av7110->debilock);
         sema_init(&av7110->dcomlock, 1);
-        av7110->debilock=SPIN_LOCK_UNLOCKED;
         av7110->debitype=-1;
 
         /* default OSD window */
         av7110->osdwin=1;
+	sema_init(&av7110->osd_sema, 1);
 
         /* ARM "watchdog" */
 	init_waitqueue_head(&av7110->arm_wait);
@@ -1434,63 +2047,21 @@
 	}
 
 	if (FW_VERSION(av7110->arm_app)<0x2501)
-		printk ("av7110: Warning, firmware version 0x%04x is too old. "
+		printk ("dvb-ttpci: Warning, firmware version 0x%04x is too old. "
 			"System might be unstable!\n", FW_VERSION(av7110->arm_app));
 
 	if (kernel_thread(arm_thread, (void *) av7110, 0) < 0) {
-		printk(KERN_ERR "av7110(%d): faile to start arm_mon kernel thread\n",
+		printk("dvb-ttpci: failed to start arm_mon kernel thread @ card %d\n",
 		       av7110->dvb_adapter->num);
 		goto err2;
 	}
 
-	/* set internal volume control to maximum */
-	av7110->adac_type = DVB_ADAC_TI;
-	av7110_set_volume(av7110, 0xff, 0xff);
-
-	av7710_set_video_mode(av7110, vidmode);
-
-	/* handle different card types */
-	/* remaining inits according to card and frontend type */
-	av7110->has_analog_tuner = 0;
-	av7110->current_input = 0;
-	if (i2c_writereg(av7110, 0x20, 0x00, 0x00)==1) {
-		printk ("av7110(%d): Crystal audio DAC detected\n",
-			av7110->dvb_adapter->num);
-		av7110->adac_type = DVB_ADAC_CRYSTAL;
-		i2c_writereg(av7110, 0x20, 0x01, 0xd2);
-		i2c_writereg(av7110, 0x20, 0x02, 0x49);
-		i2c_writereg(av7110, 0x20, 0x03, 0x00);
-		i2c_writereg(av7110, 0x20, 0x04, 0x00);
-	
-	/**
-	 * some special handling for the Siemens DVB-C cards...
-	 */
-	} else if (0 == av7110_init_analog_module(av7110)) {
-		/* done. */
-	}
-	else if (dev->pci->subsystem_vendor == 0x110a) {
-		printk("av7110(%d): DVB-C w/o analog module detected\n",
-			av7110->dvb_adapter->num);
-		av7110->adac_type = DVB_ADAC_NONE;
-	}
-	else {
-		av7110->adac_type = adac;
-		printk("av7110(%d): adac type set to %d\n",
-			av7110->dvb_adapter->num, av7110->adac_type);
-		}
-
-	if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) {
-		// switch DVB SCART on
-		av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
-		av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
-		if (rgb_on)
-			saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
-		//saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8
-	}
+	/* set initial volume in mixer struct */
+	av7110->mixer.volume_left  = volume;
+	av7110->mixer.volume_right = volume;
 	
-	av7110_set_volume(av7110, 0xff, 0xff);
+	init_av7110_av(av7110);
 
-	av7110_setup_irc_config (av7110, 0);
 	av7110_register(av7110);
 	
 	/* special case DVB-C: these cards have an analog tuner
@@ -1501,7 +2072,10 @@
 	if (ret)
 		goto err3;
 
-	printk(KERN_INFO "av7110: found av7110-%d.\n",av7110_num);
+	av7110->dvb_adapter->priv = av7110;
+	frontend_init(av7110);
+
+	printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num);
 	av7110->device_initialized = 1;
 	av7110_num++;
         return 0;
@@ -1510,13 +2084,12 @@
 	av7110->arm_rmmod = 1;
 	wake_up_interruptible(&av7110->arm_wait);
 	while (av7110->arm_thread)
-		dvb_delay(1);
+		msleep(1);
 err2:
 	av7110_ca_exit(av7110);
 	av7110_av_exit(av7110);
 err:
-	dvb_unregister_i2c_bus (master_xfer,av7110->i2c_bus->adapter,
-				av7110->i2c_bus->id);
+	i2c_del_adapter(&av7110->i2c_adap);
 
 	dvb_unregister_adapter (av7110->dvb_adapter);
 
@@ -1534,7 +2107,7 @@
 static int av7110_detach (struct saa7146_dev* saa)
 {
 	struct av7110 *av7110 = (struct av7110*)saa->ext_priv;
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 	
 	if( 0 == av7110->device_initialized ) {
 		return 0;
@@ -1546,15 +2119,12 @@
 	wake_up_interruptible(&av7110->arm_wait);
 
 	while (av7110->arm_thread)
-		dvb_delay(1);
+		msleep(1);
 
 	dvb_unregister(av7110);
 	
-	IER_DISABLE(saa, (MASK_19 | MASK_03));
-//	saa7146_write (av7110->dev, IER, 
-//		     saa7146_read(av7110->dev, IER) & ~(MASK_19 | MASK_03));
-	
-	saa7146_write(av7110->dev, ISR,(MASK_19 | MASK_03));
+	SAA7146_IER_DISABLE(saa, MASK_19 | MASK_03);
+	SAA7146_ISR_CLEAR(saa, MASK_19 | MASK_03);
 
 	av7110_ca_exit(av7110);
 	av7110_av_exit(av7110);
@@ -1563,7 +2133,8 @@
 	pci_free_consistent(saa->pci, 8192, av7110->debi_virt,
 			    av7110->debi_bus);
 
-	dvb_unregister_i2c_bus (master_xfer,av7110->i2c_bus->adapter, av7110->i2c_bus->id);
+	i2c_del_adapter(&av7110->i2c_adap);
+
 	dvb_unregister_adapter (av7110->dvb_adapter);
 
 	av7110_num--;
@@ -1580,9 +2151,7 @@
 
 static void av7110_irq(struct saa7146_dev* dev, u32 *isr) 
 {
-	struct av7110 *av7110 = (struct av7110*)dev->ext_priv;
-
-//	DEB_INT(("dev: %p, av7110: %p\n",dev,av7110));
+	struct av7110 *av7110 = dev->ext_priv;
 
 	if (*isr & MASK_19)
 		tasklet_schedule (&av7110->debi_tasklet);
@@ -1599,33 +2168,29 @@
 	.ext_priv = x_name, \
 	.ext = &av7110_extension }
 
-MAKE_AV7110_INFO(fs_1_5, "Siemens cable card PCI rev1.5");
-MAKE_AV7110_INFO(fs_1_3, "Siemens/Technotrend/Hauppauge PCI rev1.3");
-MAKE_AV7110_INFO(tt_1_6, "Technotrend/Hauppauge PCI rev1.3 or 1.6");
-MAKE_AV7110_INFO(tt_2_1, "Technotrend/Hauppauge PCI rev2.1");
-MAKE_AV7110_INFO(tt_t,	 "Technotrend/Hauppauge PCI DVB-T");
-MAKE_AV7110_INFO(unkwn0, "Technotrend/Hauppauge PCI rev?(unknown0)?");
-MAKE_AV7110_INFO(unkwn1, "Technotrend/Hauppauge PCI rev?(unknown1)?");
-MAKE_AV7110_INFO(unkwn2, "Technotrend/Hauppauge PCI rev?(unknown2)?");
-MAKE_AV7110_INFO(nexus,  "Technotrend/Hauppauge Nexus PCI DVB-S");
-MAKE_AV7110_INFO(dvboc11,"Octal/Technotrend DVB-C for iTV");
+MAKE_AV7110_INFO(tts_1_X,    "Technotrend/Hauppauge WinTV DVB-S rev1.X");
+MAKE_AV7110_INFO(ttt_1_X,    "Technotrend/Hauppauge WinTV DVB-T rev1.X");
+MAKE_AV7110_INFO(ttc_1_X,    "Technotrend/Hauppauge WinTV Nexus-CA rev1.X");
+MAKE_AV7110_INFO(ttc_2_X,    "Technotrend/Hauppauge WinTV DVB-C rev2.X");
+MAKE_AV7110_INFO(tts_2_X,    "Technotrend/Hauppauge WinTV Nexus-S rev2.X");
+MAKE_AV7110_INFO(tts_1_3se,  "Technotrend/Hauppauge WinTV Nexus-S rev1.3");
+MAKE_AV7110_INFO(fsc,        "Fujitsu Siemens DVB-C");
 
 static struct pci_device_id pci_tbl[] = {
-	MAKE_EXTENSION_PCI(fs_1_5, 0x110a, 0xffff),
-	MAKE_EXTENSION_PCI(fs_1_5, 0x110a, 0x0000),
-	MAKE_EXTENSION_PCI(fs_1_3, 0x13c2, 0x0000),
-	MAKE_EXTENSION_PCI(unkwn0, 0x13c2, 0x1002),
-	MAKE_EXTENSION_PCI(tt_1_6, 0x13c2, 0x0001),
-	MAKE_EXTENSION_PCI(tt_2_1, 0x13c2, 0x0002),
-	MAKE_EXTENSION_PCI(tt_2_1, 0x13c2, 0x0003),
-	MAKE_EXTENSION_PCI(tt_2_1, 0x13c2, 0x0004),
-	MAKE_EXTENSION_PCI(tt_1_6, 0x13c2, 0x0006),
-	MAKE_EXTENSION_PCI(tt_t,   0x13c2, 0x0008),
-	MAKE_EXTENSION_PCI(tt_2_1, 0x13c2, 0x1102),
-	MAKE_EXTENSION_PCI(unkwn1, 0xffc2, 0x0000),
-	MAKE_EXTENSION_PCI(unkwn2, 0x00a1, 0x00a1),
-	MAKE_EXTENSION_PCI(nexus,  0x00a1, 0xa1a0),
-	MAKE_EXTENSION_PCI(dvboc11,0x13c2, 0x000a),
+	MAKE_EXTENSION_PCI(tts_1_X,   0x13c2, 0x0000),
+	MAKE_EXTENSION_PCI(ttt_1_X,   0x13c2, 0x0001),
+	MAKE_EXTENSION_PCI(ttc_2_X,   0x13c2, 0x0002),
+	MAKE_EXTENSION_PCI(tts_2_X,   0x13c2, 0x0003),
+	MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
+	MAKE_EXTENSION_PCI(fsc,       0x110a, 0x0000),
+	MAKE_EXTENSION_PCI(ttc_1_X,   0x13c2, 0x000a),
+
+/*	MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte
+/*	MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1
+/*	MAKE_EXTENSION_PCI(???, 0x13c2, 0x0006), UNDEFINED CARD */ // TT/Hauppauge WinTV Nexus-S v????
+/*	MAKE_EXTENSION_PCI(???, 0x13c2, 0x0008), UNDEFINED CARD */ // TT/Hauppauge WinTV DVB-T v????
+/*	MAKE_EXTENSION_PCI(???, 0x13c2, 0x0009), UNDEFINED CARD */ // TT/Hauppauge WinTV Nexus-CA v????
+
 	{
 		.vendor    = 0,
 	}
@@ -1684,15 +2249,3 @@
 MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(av7110_debug,"i");
-MODULE_PARM(vidmode,"i");
-MODULE_PARM_DESC(vidmode,"analog video out: 0 off, 1 CVBS+RGB (default), 2 CVBS+YC, 3 YC");
-MODULE_PARM(pids_off,"i");
-MODULE_PARM_DESC(pids_off,"clear video/audio/PCR PID filters when demux is closed");
-MODULE_PARM(adac,"i");
-MODULE_PARM_DESC(adac,"audio DAC type: 0 TI, 1 CRYSTAL, 2 MSP (use if autodetection fails)");
-MODULE_PARM(hw_sections, "i");
-MODULE_PARM_DESC(hw_sections, "0 use software section filter, 1 use hardware");
-MODULE_PARM(rgb_on, "i");
-MODULE_PARM_DESC(rgb_on, "For Siemens DVB-C cards only: Enable RGB control"
-		" signal on SCART pin 16 to switch SCART video mode from CVBS to RGB");
diff -Nru a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
--- a/drivers/media/dvb/ttpci/av7110.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/media/dvb/ttpci/av7110.h	2004-12-24 13:36:17 -08:00
@@ -4,13 +4,12 @@
 #include <linux/interrupt.h>
 #include <linux/socket.h>
 #include <linux/netdevice.h>
+#include <linux/i2c.h>
 
 #ifdef CONFIG_DEVFS_FS
 #include <linux/devfs_fs_kernel.h>
 #endif
 
-#include <media/saa7146_vv.h>
-
 #include <linux/dvb/video.h>
 #include <linux/dvb/audio.h>
 #include <linux/dvb/dmx.h>
@@ -25,7 +24,25 @@
 #include "dvb_filter.h"
 #include "dvb_net.h"
 #include "dvb_ringbuffer.h"
+#include "dvb_frontend.h"
+#include "ves1820.h"
+#include "ves1x93.h"
+#include "stv0299.h"
+#include "tda8083.h"
+#include "sp8870.h"
+#include "stv0297.h"
+
+#include <media/saa7146_vv.h>
+
 
+#define ANALOG_TUNER_VES1820 1
+#define ANALOG_TUNER_STV0297 2
+#define ANALOG_TUNER_VBI     0x100
+
+extern int av7110_debug;
+
+#define dprintk(level,args...) \
+	    do { if ((av7110_debug & level)) { printk("dvb-ttpci: %s(): ", __FUNCTION__); printk(args); } } while (0)
 
 #define MAXFILT 32
 
@@ -60,16 +77,17 @@
         struct dvb_device       dvb_dev;
         struct dvb_net               dvb_net;
 
-	struct video_device	v4l_dev;
-	struct video_device	vbi_dev;
+	struct video_device	*v4l_dev;
+	struct video_device	*vbi_dev;
 
         struct saa7146_dev	*dev;
 
-	struct dvb_i2c_bus	*i2c_bus;	
+	struct i2c_adapter	i2c_adap;
+
 	char			*card_name;
 
 	/* support for analog module of dvb-c */
-	int			has_analog_tuner;
+	int			analog_tuner_flags;
 	int			current_input;
 	u32			current_freq;
 				
@@ -109,8 +127,8 @@
 
         spinlock_t              debilock;
         struct semaphore        dcomlock;
-        int                     debitype;
-        int                     debilen;
+	volatile int		debitype;
+	volatile int		debilen;
 
 
         /* Recording and playback flags */
@@ -127,7 +145,7 @@
 
         int                     osdwin;      /* currently active window */
         u16                     osdbpp[8];
-
+	struct semaphore	osd_sema;
 
         /* CA */
 
@@ -187,6 +205,7 @@
         struct dvb_ringbuffer    ci_rbuffer;
         struct dvb_ringbuffer    ci_wbuffer;
 
+	struct audio_mixer	mixer;
 
         struct dvb_adapter       *dvb_adapter;
         struct dvb_device        *video_dev;
@@ -210,6 +229,18 @@
 
 	unsigned char *bin_root;
 	unsigned long size_root;
+
+	struct dvb_frontend* fe;
+	fe_status_t fe_status;
+	int (*fe_init)(struct dvb_frontend* fe);
+	int (*fe_read_status)(struct dvb_frontend* fe, fe_status_t* status);
+	int (*fe_diseqc_reset_overload)(struct dvb_frontend* fe);
+	int (*fe_diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
+	int (*fe_diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
+	int (*fe_set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
+	int (*fe_set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
+	int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned int cmd);
+	int (*fe_set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
 };
 
 
diff -Nru a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
--- a/drivers/media/dvb/ttpci/av7110_av.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/dvb/ttpci/av7110_av.c	2004-12-24 13:36:31 -08:00
@@ -37,14 +37,10 @@
 #include <linux/smp_lock.h>
 #include <linux/fs.h>
 
-#define DEBUG_VARIABLE av7110_debug
-extern int av7110_debug;
-
 #include "av7110.h"
 #include "av7110_hw.h"
 #include "av7110_av.h"
 #include "av7110_ipack.h"
-#include "dvb_functions.h"
 
 /* MPEG-2 (ISO 13818 / H.222.0) stream types */
 #define PROG_STREAM_MAP  0xBC
@@ -102,8 +98,6 @@
 {
 	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) p2t->priv;
 
-//	DEB_EE(("struct dvb_filter_pes2ts:%p\n", p2t));
-
 	if (!(dvbdmxfeed->ts_type & TS_PACKET))
 		return 0;
 	if (buf[3] == 0xe0)	 // video PES do not have a length in TS
@@ -119,8 +113,6 @@
 {
 	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) priv;
 
-//	DEB_EE(("dvb_demux_feed:%p\n", dvbdmxfeed));
-
 	dvbdmxfeed->cb.ts(data, 188, NULL, 0,
 			  &dvbdmxfeed->feed.ts, DMX_OK);
 	return 0;
@@ -131,7 +123,7 @@
 {
 	struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
 
-	DEB_EE(("av7110: %p, dvb_demux_feed:%p\n", av7110, dvbdmxfeed));
+	dprintk(2, "av7110:%p, , dvb_demux_feed:%p\n", av7110, dvbdmxfeed);
 
 	if (av7110->playing || (av7110->rec_mode & av))
 		return -EBUSY;
@@ -173,7 +165,7 @@
 
 int av7110_av_start_play(struct av7110 *av7110, int av)
 {
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (av7110->rec_mode)
 		return -EBUSY;
@@ -206,7 +198,7 @@
 
 void av7110_av_stop(struct av7110 *av7110, int av)
 {
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (!(av7110->playing & av) && !(av7110->rec_mode & av))
 		return;
@@ -247,8 +239,6 @@
 	u32 sync;
 	u16 blen;
 
-	DEB_EE(("dvb_ring_buffer_t: %p\n", buf));
-
 	if (!dlen) {
 		wake_up(&buf->queue);
 		return -1;
@@ -279,8 +269,8 @@
 
 	dvb_ringbuffer_read(buf, dest, (size_t) blen, 0);
 
-	DEB_S(("pread=0x%08lx, pwrite=0x%08lx\n",
-	       (unsigned long) buf->pread, (unsigned long) buf->pwrite));
+	dprintk(2, "pread=0x%08lx, pwrite=0x%08lx\n",
+	       (unsigned long) buf->pread, (unsigned long) buf->pwrite);
 	wake_up(&buf->queue);
 	return blen;
 }
@@ -290,7 +280,10 @@
 {
 	int err, vol, val, balance = 0;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
+
+	av7110->mixer.volume_left = volleft;
+	av7110->mixer.volume_right = volright;
 
 	switch (av7110->adac_type) {
 	case DVB_ADAC_TI:
@@ -326,7 +319,7 @@
 
 void av7110_set_vidmode(struct av7110 *av7110, int mode)
 {
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	av7110_fw_cmd(av7110, COMTYPE_ENCODER, LoadVidCode, 1, mode);
 
@@ -354,7 +347,7 @@
 	int sw;
 	u8 *p;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (av7110->sinfo)
 		return;
@@ -367,7 +360,7 @@
 		vsize = ((p[1] &0x0F) << 8) | (p[2]);
 		sw = (p[3] & 0x0F);
 		av7110_set_vidmode(av7110, sw2mode[sw]);
-		DEB_S(("dvb: playback %dx%d fr=%d\n", hsize, vsize, sw));
+		dprintk(2, "playback %dx%d fr=%d\n", hsize, vsize, sw);
 		av7110->sinfo = 1;
 		break;
 	}
@@ -404,7 +397,7 @@
 static void play_video_cb(u8 *buf, int count, void *priv)
 {
 	struct av7110 *av7110 = (struct av7110 *) priv;
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if ((buf[3] & 0xe0) == 0xe0) {
 		get_video_format(av7110, buf, count);
@@ -416,7 +409,7 @@
 static void play_audio_cb(u8 *buf, int count, void *priv)
 {
 	struct av7110 *av7110 = (struct av7110 *) priv;
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	aux_ring_buffer_write(&av7110->aout, buf, count);
 }
@@ -428,7 +421,7 @@
 			unsigned long count, int nonblock, int type)
 {
 	unsigned long todo = count, n;
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (!av7110->kbuf[type])
 		return -ENOBUFS;
@@ -461,7 +454,7 @@
 			unsigned long count, int nonblock, int type)
 {
 	unsigned long todo = count, n;
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (!av7110->kbuf[type])
 		return -ENOBUFS;
@@ -491,7 +484,7 @@
 			 unsigned long count, int nonblock, int type)
 {
 	unsigned long todo = count, n;
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (!av7110->kbuf[type])
 		return -ENOBUFS;
@@ -681,7 +674,7 @@
 }
 
 
-int write_ts_header2(u16 pid, u8 *counter, int pes_start, u8 *buf, u8 length)
+static int write_ts_header2(u16 pid, u8 *counter, int pes_start, u8 *buf, u8 length)
 {
 	int i;
 	int c = 0;
@@ -770,7 +763,7 @@
 	struct av7110 *av7110 = (struct av7110 *) demux->priv;
 	struct ipack *ipack = &av7110->ipack[feed->pes_type];
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	switch (feed->pes_type) {
 	case 0:
@@ -811,8 +804,6 @@
 	struct dvb_video_events *events = &av7110->video_events;
 	int wp;
 
-	DEB_D(("\n"));
-
 	spin_lock_bh(&events->lock);
 
 	wp = (events->eventw + 1) % MAX_VIDEO_EVENT;
@@ -835,8 +826,6 @@
 {
 	struct dvb_video_events *events = &av7110->video_events;
 
-	DEB_D(("\n"));
-
 	if (events->overflow) {
 		events->overflow = 0;
 		return -EOVERFLOW;
@@ -875,7 +864,7 @@
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 	unsigned int mask = 0;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if ((file->f_flags & O_ACCMODE) != O_RDONLY)
 		poll_wait(file, &av7110->avout.queue, wait);
@@ -902,7 +891,7 @@
 	struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if ((file->f_flags & O_ACCMODE) == O_RDONLY)
 		return -EPERM;
@@ -919,7 +908,7 @@
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 	unsigned int mask = 0;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	poll_wait(file, &av7110->aout.queue, wait);
 
@@ -938,7 +927,7 @@
 	struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (av7110->audiostate.stream_source != AUDIO_SOURCE_MEMORY) {
 		printk(KERN_ERR "not audio source memory\n");
@@ -947,7 +936,7 @@
 	return dvb_aplay(av7110, buf, count, file->f_flags & O_NONBLOCK, 0);
 }
 
-u8 iframe_header[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00 };
+static u8 iframe_header[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00 };
 
 #define MIN_IFRAME 400000
 
@@ -955,7 +944,7 @@
 {
 	int i, n;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (!(av7110->playing & RP_VIDEO)) {
 		if (av7110_av_start_play(av7110, RP_VIDEO) < 0)
@@ -985,7 +974,7 @@
 	unsigned long arg = (unsigned long) parg;
 	int ret = 0;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
 		if ( cmd != VIDEO_GET_STATUS && cmd != VIDEO_GET_EVENT &&
@@ -1181,7 +1170,7 @@
 	unsigned long arg = (unsigned long) parg;
 	int ret = 0;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (((file->f_flags & O_ACCMODE) == O_RDONLY) &&
 	    (cmd != AUDIO_GET_STATUS))
@@ -1297,7 +1286,7 @@
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 	int err;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if ((err = dvb_generic_open(inode, file)) < 0)
 		return err;
@@ -1321,7 +1310,7 @@
 	struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
 		av7110_av_stop(av7110, RP_VIDEO);
@@ -1336,7 +1325,7 @@
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 	int err=dvb_generic_open(inode, file);
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	if (err < 0)
 		return err;
@@ -1350,7 +1339,7 @@
 	struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(2, "av7110:%p, \n", av7110);
 
 	av7110_av_stop(av7110, RP_AUDIO);
 	return dvb_generic_release(inode, file);
diff -Nru a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
--- a/drivers/media/dvb/ttpci/av7110_ca.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/media/dvb/ttpci/av7110_ca.c	2004-12-24 13:37:01 -08:00
@@ -38,18 +38,13 @@
 #include <linux/byteorder/swabb.h>
 #include <linux/smp_lock.h>
 
-#define DEBUG_VARIABLE av7110_debug
-extern int av7110_debug;
-
-#include "dvb_i2c.h"
 #include "av7110.h"
 #include "av7110_hw.h"
-#include "dvb_functions.h"
 
 
 void CI_handle(struct av7110 *av7110, u8 *data, u16 len)
 {
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(8, "av7110:%p\n",av7110);
 
 	if (len < 3)
 		return;
@@ -94,20 +89,20 @@
  * CI link layer file ops
  ******************************************************************************/
 
-int ci_ll_init(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf, int size)
+static int ci_ll_init(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf, int size)
 {
 	dvb_ringbuffer_init(cirbuf, vmalloc(size), size);
 	dvb_ringbuffer_init(ciwbuf, vmalloc(size), size);
 	return 0;
 }
 
-void ci_ll_flush(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf)
+static void ci_ll_flush(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf)
 {
 	dvb_ringbuffer_flush_spinlock_wakeup(cirbuf);
 	dvb_ringbuffer_flush_spinlock_wakeup(ciwbuf);
 }
 
-void ci_ll_release(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf)
+static void ci_ll_release(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf)
 {
 	vfree(cirbuf->data);
 	cirbuf->data = NULL;
@@ -115,7 +110,7 @@
 	ciwbuf->data = NULL;
 }
 
-int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file,
+static int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file,
 		int slots, ca_slot_info_t *slot)
 {
 	int i;
@@ -212,7 +207,7 @@
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 	int err = dvb_generic_open(inode, file);
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(8, "av7110:%p\n",av7110);
 
 	if (err < 0)
 		return err;
@@ -228,13 +223,16 @@
 	struct dvb_ringbuffer *wbuf = &av7110->ci_wbuffer;
 	unsigned int mask = 0;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(8, "av7110:%p\n",av7110);
 
 	poll_wait(file, &rbuf->queue, wait);
+	poll_wait(file, &wbuf->queue, wait);
+
 	if (!dvb_ringbuffer_empty(rbuf))
-		mask |= POLLIN;
-	if (dvb_ringbuffer_avail(wbuf) > 1024)
-		mask |= POLLOUT;
+		mask |= (POLLIN | POLLRDNORM);
+
+	if (dvb_ringbuffer_free(wbuf) > 1024)
+		mask |= (POLLOUT | POLLWRNORM);
 
 	return mask;
 }
@@ -246,7 +244,7 @@
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 	unsigned long arg = (unsigned long) parg;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(8, "av7110:%p\n",av7110);
 
 	switch (cmd) {
 	case CA_RESET:
@@ -323,7 +321,7 @@
 	struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(8, "av7110:%p\n",av7110);
 	return ci_ll_write(&av7110->ci_wbuffer, file, buf, count, ppos);
 }
 
@@ -333,7 +331,7 @@
 	struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
 	struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(8, "av7110:%p\n",av7110);
 	return ci_ll_read(&av7110->ci_rbuffer, file, buf, count, ppos);
 }
 
diff -Nru a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
--- a/drivers/media/dvb/ttpci/av7110_hw.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/media/dvb/ttpci/av7110_hw.c	2004-12-24 13:37:01 -08:00
@@ -38,12 +38,8 @@
 #include <linux/smp_lock.h>
 #include <linux/fs.h>
 
-#define DEBUG_VARIABLE av7110_debug
-extern int av7110_debug;
-
 #include "av7110.h"
 #include "av7110_hw.h"
-#include "dvb_functions.h"
 
 /****************************************************************************
  * DEBI functions
@@ -57,10 +53,14 @@
 {
 	struct saa7146_dev *dev = av7110->dev;
 
-	if (count <= 0 || count > 32764)
+	if (count <= 0 || count > 32764) {
+		printk("%s: invalid count %d\n", __FUNCTION__, count);
 		return -1;
-	if (saa7146_wait_for_debi_done(av7110->dev) < 0)
+	}
+	if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
+		printk("%s: wait_for_debi_done failed\n", __FUNCTION__);
 		return -1;
+	}
 	saa7146_write(dev, DEBI_CONFIG, config);
 	if (count <= 4)		/* immediate transfer */
 		saa7146_write(dev, DEBI_AD, val);
@@ -76,10 +76,14 @@
 	struct saa7146_dev *dev = av7110->dev;
 	u32 result = 0;
 
-	if (count > 32764 || count <= 0)
+	if (count > 32764 || count <= 0) {
+		printk("%s: invalid count %d\n", __FUNCTION__, count);
 		return 0;
-	if (saa7146_wait_for_debi_done(av7110->dev) < 0)
+	}
+	if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
+		printk("%s: wait_for_debi_done #1 failed\n", __FUNCTION__);
 		return 0;
+	}
 	saa7146_write(dev, DEBI_AD, av7110->debi_bus);
 	saa7146_write(dev, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff));
 
@@ -87,7 +91,11 @@
 	saa7146_write(dev, MC2, (2 << 16) | 2);
 	if (count > 4)
 		return count;
-	saa7146_wait_for_debi_done(av7110->dev);
+	if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
+		printk("%s: wait_for_debi_done #2 failed\n", __FUNCTION__);
+		return 0;
+	}
+
 	result = saa7146_read(dev, DEBI_AD);
 	result &= (0xffffffffUL >> ((4 - count) * 8));
 	return result;
@@ -102,19 +110,19 @@
 	saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO);
 
 	/* Disable DEBI and GPIO irq */
-	IER_DISABLE(av7110->dev, (MASK_19 | MASK_03));
-	saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03));
+	SAA7146_IER_DISABLE(av7110->dev, MASK_19 | MASK_03);
+	SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
 
 	saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTHI);
-	dvb_delay(30);	/* the firmware needs some time to initialize */
+	msleep(30);	/* the firmware needs some time to initialize */
 
 	ARM_ResetMailBox(av7110);
 
-	saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03));
-	IER_ENABLE(av7110->dev, MASK_03);
+	SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
+	SAA7146_IER_ENABLE(av7110->dev, MASK_03);
 
 	av7110->arm_ready = 1;
-	printk("av7110: ARM RESET\n");
+	dprintk(1, "reset ARM\n");
 }
 
 
@@ -122,7 +130,7 @@
 {
 	int k;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	for (k = 0; k < 100; k++) {
 		if (irdebi(av7110, DEBINOSWAP, adr, 0, 2) == state)
@@ -138,7 +146,7 @@
 	int blocks, rest;
 	u32 base, bootblock = BOOT_BLOCK;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	blocks = len / BOOT_MAX_SIZE;
 	rest = len % BOOT_MAX_SIZE;
@@ -147,7 +155,7 @@
 	for (i = 0; i < blocks; i++) {
 		if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0)
 			return -1;
-		DEB_D(("Writing DRAM block %d\n", i));
+		dprintk(4, "writing DRAM block %d\n", i);
 		mwdebi(av7110, DEBISWAB, bootblock,
 		       ((char*)data) + i * BOOT_MAX_SIZE, BOOT_MAX_SIZE);
 		bootblock ^= 0x1400;
@@ -210,13 +218,13 @@
 	u32 ret;
 	int i;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO);
 
 	/* Disable DEBI and GPIO irq */
-	IER_DISABLE(av7110->dev, MASK_03 | MASK_19);
-	saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03));
+	SAA7146_IER_DISABLE(av7110->dev, MASK_03 | MASK_19);
+	SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
 
 	/* enable DEBI */
 	saa7146_write(av7110->dev, MC1, 0x08800880);
@@ -226,17 +234,17 @@
 	/* test DEBI */
 	iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
 	if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) {
-		printk(KERN_ERR "dvb: debi test in av7110_bootarm() failed: "
-		       "%08x != %08x (check your BIOS hotplug settings)\n",
+		printk(KERN_ERR "dvb-ttpci: debi test in av7110_bootarm() failed: "
+		       "%08x != %08x (check your BIOS 'Plug&Play OS' settings)\n",
 		       ret, 0x10325476);
 		return -1;
 	}
 	for (i = 0; i < 8192; i += 4)
 		iwdebi(av7110, DEBISWAP, DPRAM_BASE + i, 0x00, 4);
-	DEB_D(("av7110_bootarm: debi test OK\n"));
+	dprintk(2, "debi test OK\n");
 
 	/* boot */
-	DEB_D(("av7110_bootarm: load boot code\n"));
+	dprintk(1, "load boot code\n");
 	saa7146_setgpio(dev, ARM_IRQ_LINE, SAA7146_GPIO_IRQLO);
 	//saa7146_setgpio(dev, DEBI_DONE_LINE, SAA7146_GPIO_INPUT);
 	//saa7146_setgpio(dev, 3, SAA7146_GPIO_INPUT);
@@ -244,36 +252,36 @@
 	mwdebi(av7110, DEBISWAB, DPRAM_BASE, bootcode, sizeof(bootcode));
 	iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
 
-	if (saa7146_wait_for_debi_done(av7110->dev)) {
-		printk(KERN_ERR "dvb: av7110_bootarm(): "
+	if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
+		printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
 		       "saa7146_wait_for_debi_done() timed out\n");
 		return -1;
 	}
 	saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
 	mdelay(1);
 
-	DEB_D(("av7110_bootarm: load dram code\n"));
+	dprintk(1, "load dram code\n");
 	if (load_dram(av7110, (u32 *)av7110->bin_root, av7110->size_root) < 0)
 		return -1;
 
 	saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO);
 	mdelay(1);
 
-	DEB_D(("av7110_bootarm: load dpram code\n"));
+	dprintk(1, "load dpram code\n");
 	mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram);
 
-	if (saa7146_wait_for_debi_done(av7110->dev)) {
-		printk(KERN_ERR "dvb: av7110_bootarm(): "
+	if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
+		printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
 		       "saa7146_wait_for_debi_done() timed out after loading DRAM\n");
 		return -1;
 	}
 	saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
-	dvb_delay(30);	/* the firmware needs some time to initialize */
+	msleep(30);	/* the firmware needs some time to initialize */
 
 	//ARM_ClearIrq(av7110);
 	ARM_ResetMailBox(av7110);
-	saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03));
-	IER_ENABLE(av7110->dev, MASK_03);
+	SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
+	SAA7146_IER_ENABLE(av7110->dev, MASK_03);
 
 	av7110->arm_errors = 0;
 	av7110->arm_ready = 1;
@@ -285,49 +293,113 @@
  * DEBI command polling
  ****************************************************************************/
 
+int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
+{
+	unsigned long start;
+	u32 stat;
+
+	if (FW_VERSION(av7110->arm_app) <= 0x261c) {
+		/* not supported by old firmware */
+		msleep(50);
+		return 0;
+	}
+
+	/* new firmware */
+	start = jiffies;
+	for (;;) {
+		if (down_interruptible(&av7110->dcomlock))
+			return -ERESTARTSYS;
+		stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
+		up(&av7110->dcomlock);
+		if ((stat & flags) == 0) {
+			break;
+		}
+		if (time_after(jiffies, start + ARM_WAIT_FREE)) {
+			printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n",
+				__FUNCTION__, stat & flags);
+			return -1;
+		}
+		msleep(1);
+	}
+	return 0;
+}
+
 int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
 {
 	int i;
 	unsigned long start;
-#ifdef COM_DEBUG
+	char *type = NULL;
+	u16 flags[2] = {0, 0};
 	u32 stat;
-#endif
 
-//	DEB_EE(("av7110: %p\n", av7110));
+//	dprintk(4, "%p\n", av7110);
 
 	if (!av7110->arm_ready) {
-		DEB_D(("arm not ready.\n"));
+		dprintk(1, "arm not ready.\n");
 		return -1;
 	}
 
 	start = jiffies;
 	while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) {
-		dvb_delay(1);
+		msleep(1);
 		if (time_after(jiffies, start + ARM_WAIT_FREE)) {
-			printk(KERN_ERR "%s: timeout waiting for COMMAND idle\n", __FUNCTION__);
+			printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __FUNCTION__);
 			return -1;
 		}
 	}
 
+	wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2);
+
 #ifndef _NOHANDSHAKE
 	start = jiffies;
 	while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 )) {
-		dvb_delay(1);
+		msleep(1);
 		if (time_after(jiffies, start + ARM_WAIT_SHAKE)) {
-			printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
+			printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
 			return -1;
 		}
 	}
 #endif
 
+	switch ((buf[0] >> 8) & 0xff) {
+	case COMTYPE_PIDFILTER:
+	case COMTYPE_ENCODER:
+	case COMTYPE_REC_PLAY:
+	case COMTYPE_MPEGDECODER:
+		type = "MSG";
+		flags[0] = GPMQOver;
+		flags[1] = GPMQFull;
+		break;
+	case COMTYPE_OSD:
+		type = "OSD";
+		flags[0] = OSDQOver;
+		flags[1] = OSDQFull;
+		break;
+	default:
+		break;
+	}
+
+	if (type != NULL) {
+		/* non-immediate COMMAND type */
 	start = jiffies;
-	while (rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2) & OSDQFull) {
-		dvb_delay(1);
-		if (time_after(jiffies, start + ARM_WAIT_OSD)) {
-			printk(KERN_ERR "%s: timeout waiting for !OSDQFull\n", __FUNCTION__);
+		for (;;) {
+			stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
+			if (stat & flags[0]) {
+				printk(KERN_ERR "%s: %s QUEUE overflow\n",
+					__FUNCTION__, type);
+				return -1;
+			}
+			if ((stat & flags[1]) == 0)
+				break;
+			if (time_after(jiffies, start + ARM_WAIT_FREE)) {
+				printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n",
+					__FUNCTION__, type);
 			return -1;
 		}
+			msleep(1);
+		}
 	}
+
 	for (i = 2; i < length; i++)
 		wdebi(av7110, DEBINOSWAP, COMMAND + 2 * i, (u32) buf[i], 2);
 
@@ -338,12 +410,14 @@
 
 	wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2);
 
+	wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2);
+
 #ifdef COM_DEBUG
 	start = jiffies;
 	while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) {
-		dvb_delay(1);
+		msleep(1);
 		if (time_after(jiffies, start + ARM_WAIT_FREE)) {
-			printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n",
+			printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND to complete\n",
 			       __FUNCTION__);
 			return -1;
 		}
@@ -351,11 +425,11 @@
 
 	stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
 	if (stat & GPMQOver) {
-		printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__);
+		printk(KERN_ERR "dvb-ttpci: %s(): GPMQOver\n", __FUNCTION__);
 		return -1;
 	}
 	else if (stat & OSDQOver) {
-		printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__);
+		printk(KERN_ERR "dvb-ttpci: %s(): OSDQOver\n", __FUNCTION__);
 		return -1;
 	}
 #endif
@@ -367,10 +441,10 @@
 {
 	int ret;
 
-//	DEB_EE(("av7110: %p\n", av7110));
+//	dprintk(4, "%p\n", av7110);
 
 	if (!av7110->arm_ready) {
-		DEB_D(("arm not ready.\n"));
+		dprintk(1, "arm not ready.\n");
 		return -1;
 	}
 	if (down_interruptible(&av7110->dcomlock))
@@ -379,7 +453,7 @@
 	ret = __av7110_send_fw_cmd(av7110, buf, length);
 	up(&av7110->dcomlock);
 	if (ret)
-		printk("av7110_send_fw_cmd error\n");
+		printk("dvb-ttpci: %s(): av7110_send_fw_cmd error\n", __FUNCTION__);
 	return ret;
 }
 
@@ -389,7 +463,7 @@
 	u16 buf[num + 2];
 	int i, ret;
 
-//	DEB_EE(("av7110: %p\n",av7110));
+//	dprintk(4, "%p\n", av7110);
 
 	buf[0] = ((type << 8) | com);
 	buf[1] = num;
@@ -403,7 +477,7 @@
 
 	ret = av7110_send_fw_cmd(av7110, buf, num + 2);
 	if (ret)
-		printk("av7110_fw_cmd error\n");
+		printk("dvb-ttpci: av7110_fw_cmd error\n");
 	return ret;
 }
 
@@ -413,7 +487,7 @@
 	u16 cmd[18] = { ((COMTYPE_COMMON_IF << 8) + subcom),
 		16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	for(i = 0; i < len && i < 32; i++)
 	{
@@ -425,7 +499,7 @@
 
 	ret = av7110_send_fw_cmd(av7110, cmd, 18);
 	if (ret)
-		printk("av7110_send_ci_cmd error\n");
+		printk("dvb-ttpci: av7110_send_ci_cmd error\n");
 	return ret;
 }
 
@@ -439,10 +513,10 @@
 	u32 stat;
 #endif
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (!av7110->arm_ready) {
-		DEB_D(("arm not ready.\n"));
+		dprintk(1, "arm not ready.\n");
 		return -1;
 	}
 
@@ -451,17 +525,17 @@
 
 	if ((err = __av7110_send_fw_cmd(av7110, request_buf, request_buf_len)) < 0) {
 		up(&av7110->dcomlock);
-		printk("av7110_fw_request error\n");
+		printk("dvb-ttpci: av7110_fw_request error\n");
 		return err;
 	}
 
 	start = jiffies;
 	while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2)) {
 #ifdef _NOHANDSHAKE
-		dvb_delay(1);
+		msleep(1);
 #endif
 		if (time_after(jiffies, start + ARM_WAIT_FREE)) {
-			printk("%s: timeout waiting for COMMAND to complete\n", __FUNCTION__);
+			printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__);
 			up(&av7110->dcomlock);
 			return -1;
 		}
@@ -470,7 +544,7 @@
 #ifndef _NOHANDSHAKE
 	start = jiffies;
 	while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 )) {
-		dvb_delay(1);
+		msleep(1);
 		if (time_after(jiffies, start + ARM_WAIT_SHAKE)) {
 			printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
 			up(&av7110->dcomlock);
@@ -505,7 +579,7 @@
 	int ret;
 	ret = av7110_fw_request(av7110, &tag, 0, buf, length);
 	if (ret)
-		printk("av7110_fw_query error\n");
+		printk("dvb-ttpci: av7110_fw_query error\n");
 	return ret;
 }
 
@@ -520,10 +594,10 @@
 	u16 buf[20];
 	u16 tag = ((COMTYPE_REQUEST << 8) + ReqVersion);
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (av7110_fw_query(av7110, tag, buf, 16)) {
-		printk("DVB: AV7110-%d: ERROR: Failed to boot firmware\n",
+		printk("dvb-ttpci: failed to boot firmware @ card %d\n",
 		       av7110->dvb_adapter->num);
 		return -EIO;
 	}
@@ -534,17 +608,17 @@
 	av7110->arm_app = (buf[6] << 16) + buf[7];
 	av7110->avtype = (buf[8] << 16) + buf[9];
 
-	printk("DVB: AV711%d(%d) - firm %08x, rtsl %08x, vid %08x, app %08x\n",
-	       av7110->avtype, av7110->dvb_adapter->num, av7110->arm_fw,
+	printk("dvb-ttpci: info @ card %d: firm %08x, rtsl %08x, vid %08x, app %08x\n",
+	       av7110->dvb_adapter->num, av7110->arm_fw,
 	       av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app);
 
 	/* print firmware capabilities */
 	if (FW_CI_LL_SUPPORT(av7110->arm_app))
-		printk("DVB: AV711%d(%d) - firmware supports CI link layer interface\n",
-		       av7110->avtype, av7110->dvb_adapter->num);
+		printk("dvb-ttpci: firmware @ card %d supports CI link layer interface\n",
+		       av7110->dvb_adapter->num);
 	else
-		printk("DVB: AV711%d(%d) - no firmware support for CI link layer interface\n",
-		       av7110->avtype, av7110->dvb_adapter->num);
+		printk("dvb-ttpci: no firmware support for CI link layer interface @ card %d\n",
+		       av7110->dvb_adapter->num);
 
 	return 0;
 }
@@ -556,7 +630,7 @@
 	u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) + SendDiSEqC),
 			16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (len > 10)
 		len = 10;
@@ -573,7 +647,7 @@
 		buf[i + 4] = msg[i];
 
 	if (av7110_send_fw_cmd(av7110, buf, 18))
-		printk("av7110_diseqc_send error\n");
+		printk("dvb-ttpci: av7110_diseqc_send error\n");
 
 	return 0;
 }
@@ -630,9 +704,9 @@
 		return -ERESTARTSYS;
 	start = jiffies;
 	while (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2)) {
-		dvb_delay(1);
+		msleep(1);
 		if (time_after(jiffies, start + ARM_WAIT_OSD)) {
-			printk(KERN_ERR "%s: timeout waiting for BUFF1_BASE == 0\n",
+			printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n",
 			       __FUNCTION__);
 			up(&av7110->dcomlock);
 			return -1;
@@ -654,9 +728,9 @@
 
 	start = jiffies;
 	while (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2)) {
-		dvb_delay(1);
+		msleep(1);
 		if (time_after(jiffies, start + ARM_WAIT_OSD)) {
-			printk(KERN_ERR "%s: timeout waiting for BUFF1_BASE == 0\n",
+			printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n",
 			       __FUNCTION__);
 			up(&av7110->dcomlock);
 			return -1;
@@ -665,9 +739,9 @@
 #ifndef _NOHANDSHAKE
 	start = jiffies;
 	while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2)) {
-		dvb_delay(1);
+		msleep(1);
 		if (time_after(jiffies, start + ARM_WAIT_SHAKE)) {
-			printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n",
+			printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n",
 			       __FUNCTION__);
 			up(&av7110->dcomlock);
 			return -1;
@@ -682,7 +756,7 @@
 	ret = __av7110_send_fw_cmd(av7110, cbuf, 5);
 	up(&av7110->dcomlock);
 	if (ret)
-		printk("WriteText error\n");
+		printk("dvb-ttpci: WriteText error\n");
 	return ret;
 }
 
@@ -721,7 +795,7 @@
 }
 
 static inline int CreateOSDWindow(struct av7110 *av7110, u8 windownr,
-				  enum av7110_window_display_type disptype,
+				  osd_raw_window_t disptype,
 				  u16 width, u16 height)
 {
 	return av7110_fw_cmd(av7110, COMTYPE_OSD, WCreate, 4,
@@ -732,8 +806,8 @@
 static enum av7110_osd_palette_type bpp2pal[8] = {
 	Pal1Bit, Pal2Bit, 0, Pal4Bit, 0, 0, 0, Pal8Bit
 };
-static enum av7110_window_display_type bpp2bit[8] = {
-	BITMAP1, BITMAP2, 0, BITMAP4, 0, 0, 0, BITMAP8
+static osd_raw_window_t bpp2bit[8] = {
+	OSD_BITMAP1, OSD_BITMAP2, 0, OSD_BITMAP4, 0, 0, 0, OSD_BITMAP8
 };
 
 static inline int LoadBitmap(struct av7110 *av7110, u16 format,
@@ -743,32 +817,26 @@
 	int i;
 	int d, delta;
 	u8 c;
-	DECLARE_WAITQUEUE(wait, current);
+	int ret;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
-	if (av7110->bmp_state == BMP_LOADING) {
-		add_wait_queue(&av7110->bmpq, &wait);
-		while (1) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			if (av7110->bmp_state != BMP_LOADING
-			    || signal_pending(current))
-				break;
-			schedule();
-		}
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&av7110->bmpq, &wait);
-	}
-	if (av7110->bmp_state == BMP_LOADING)
+	ret = wait_event_interruptible_timeout(av7110->bmpq, av7110->bmp_state != BMP_LOADING, HZ);
+	if (ret == -ERESTARTSYS || ret == 0) {
+		printk("dvb-ttpci: warning: timeout waiting in %s()\n", __FUNCTION__);
+		av7110->bmp_state = BMP_NONE;
 		return -1;
+	}
+	BUG_ON (av7110->bmp_state == BMP_LOADING);
+
 	av7110->bmp_state = BMP_LOADING;
-	if	(format == BITMAP8) {
+	if	(format == OSD_BITMAP8) {
 		bpp=8; delta = 1;
-	} else if (format == BITMAP4) {
+	} else if (format == OSD_BITMAP4) {
 		bpp=4; delta = 2;
-	} else if (format == BITMAP2) {
+	} else if (format == OSD_BITMAP2) {
 		bpp=2; delta = 4;
-	} else if (format == BITMAP1) {
+	} else if (format == OSD_BITMAP1) {
 		bpp=1; delta = 8;
 	} else {
 		av7110->bmp_state = BMP_NONE;
@@ -786,7 +854,7 @@
 			return -1;
 		}
 	}
-	if (format != BITMAP8) {
+	if (format != OSD_BITMAP8) {
 		for (i = 0; i < dx * dy / delta; i++) {
 			c = ((u8 *)av7110->bmpbuf)[1024 + i * delta + delta - 1];
 			for (d = delta - 2; d >= 0; d--) {
@@ -802,32 +870,27 @@
 
 static int BlitBitmap(struct av7110 *av7110, u16 win, u16 x, u16 y, u16 trans)
 {
-	DECLARE_WAITQUEUE(wait, current);
+	int ret;
+
+	dprintk(4, "%p\n", av7110);
 
-	DEB_EE(("av7110: %p\n", av7110));
+	BUG_ON (av7110->bmp_state == BMP_NONE);
 
-       if (av7110->bmp_state == BMP_NONE)
+	ret = wait_event_interruptible_timeout(av7110->bmpq, av7110->bmp_state != BMP_LOADING, HZ);
+	if (ret == -ERESTARTSYS || ret == 0) {
+		printk("dvb-ttpci: warning: timeout waiting in %s()\n", __FUNCTION__);
+		av7110->bmp_state = BMP_NONE;
 		return -1;
-	if (av7110->bmp_state == BMP_LOADING) {
-		add_wait_queue(&av7110->bmpq, &wait);
-		while (1) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			if (av7110->bmp_state != BMP_LOADING
-			    || signal_pending(current))
-				break;
-			schedule();
 		}
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&av7110->bmpq, &wait);
-	}
-	if (av7110->bmp_state == BMP_LOADED)
+
+	BUG_ON (av7110->bmp_state != BMP_LOADED);
+
 		return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, win, x, y, trans);
-	return -1;
 }
 
 static inline int ReleaseBitmap(struct av7110 *av7110)
 {
-	DEB_EE(("av7110: %p\n",av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if (av7110->bmp_state != BMP_LOADED)
 		return -1;
@@ -865,18 +928,22 @@
 		  color, ((blend >> 4) & 0x0f));
 }
 
-static int OSDSetPalette(struct av7110 *av7110, u32 *colors, u8 first, u8 last)
+static int OSDSetPalette(struct av7110 *av7110, u32 __user * colors, u8 first, u8 last)
 {
        int i;
        int length = last - first + 1;
 
        if (length * 4 > DATA_BUFF3_SIZE)
-	       return -1;
+	       return -EINVAL;
 
        for (i = 0; i < length; i++) {
-	       u32 blend = (colors[i] & 0xF0000000) >> 4;
-	       u32 yuv = blend ? RGB2YUV(colors[i] & 0xFF, (colors[i] >> 8) & 0xFF,
-					 (colors[i] >> 16) & 0xFF) | blend : 0;
+	       u32 color, blend, yuv;
+
+	       if (get_user(color, colors + i))
+		       return -EFAULT;
+	       blend = (color & 0xF0000000) >> 4;
+	       yuv = blend ? RGB2YUV(color & 0xFF, (color >> 8) & 0xFF,
+				     (color >> 16) & 0xFF) | blend : 0;
 	       yuv = ((yuv & 0xFFFF0000) >> 16) | ((yuv & 0x0000FFFF) << 16);
 	       wdebi(av7110, DEBINOSWAP, DATA_BUFF3_BASE + i * 4, yuv, 4);
        }
@@ -922,10 +989,19 @@
 
 int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
 {
+	int ret;
+
+	ret = down_interruptible(&av7110->osd_sema);
+	if (ret)
+		return -ERESTARTSYS;
+
+	/* stupid, but OSD functions don't provide a return code anyway */
+	ret = 0;
+
 	switch (dc->cmd) {
 	case OSD_Close:
 		DestroyOSDWindow(av7110, av7110->osdwin);
-		return 0;
+		goto out;
 	case OSD_Open:
 		av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7;
 		CreateOSDWindow(av7110, av7110->osdwin,
@@ -935,90 +1011,84 @@
 			MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
 			SetColorBlend(av7110, av7110->osdwin);
 		}
-		return 0;
+		goto out;
 	case OSD_Show:
 		MoveWindowRel(av7110, av7110->osdwin, 0, 0);
-		return 0;
+		goto out;
 	case OSD_Hide:
 		HideWindow(av7110, av7110->osdwin);
-		return 0;
+		goto out;
 	case OSD_Clear:
 		DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0);
-		return 0;
+		goto out;
 	case OSD_Fill:
 		DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color);
-		return 0;
+		goto out;
 	case OSD_SetColor:
 		OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1);
-		return 0;
+		goto out;
 	case OSD_SetPalette:
 	{
-		int len = dc->x0-dc->color+1;
-		void *buf;
-		if (len <= 0)
-			return 0;
-
-		buf = kmalloc(len * 4, GFP_KERNEL);
-		if (!buf)
-			return -ENOMEM;
-
-		if (copy_from_user(buf, dc->data, len * 4)) {
-			kfree(buf);
-			return -EFAULT;
+		if (FW_VERSION(av7110->arm_app) >= 0x2618) {
+			ret = OSDSetPalette(av7110, dc->data, dc->color, dc->x0);
+			goto out;
+		} else {
+			int i, len = dc->x0-dc->color+1;
+			u8 __user *colors = (u8 *)dc->data;
+			u8 r, g, b, blend;
+
+			for (i = 0; i<len; i++) {
+				if (get_user(r, colors + i * 4) ||
+				    get_user(g, colors + i * 4 + 1) ||
+				    get_user(b, colors + i * 4 + 2) ||
+				    get_user(blend, colors + i * 4 + 3)) {
+					ret = -EFAULT;
+					goto out;
 		}
-
-		if (FW_VERSION(av7110->arm_app) >= 0x2618)
-			OSDSetPalette(av7110, buf, dc->color, dc->x0);
-		else {
-			int i;
-			u8 *colors = buf;
-
-			for (i = 0; i<len; i++)
-				OSDSetColor(av7110, dc->color + i,
-					colors[i * 4], colors[i * 4 + 1],
-					colors[i * 4 + 2], colors[i * 4 + 3]);
+				OSDSetColor(av7110, dc->color + i, r, g, b, blend);
 		}
-		kfree(buf);
-		return 0;
+		}
+		ret = 0;
+		goto out;
 	}
 	case OSD_SetTrans:
-		return 0;
+		goto out;
 	case OSD_SetPixel:
 		DrawLine(av7110, av7110->osdwin,
 			 dc->x0, dc->y0, 0, 0, dc->color);
-		return 0;
+		goto out;
 	case OSD_GetPixel:
-		return 0;
-
+		goto out;
 	case OSD_SetRow:
 		dc->y1 = dc->y0;
 		/* fall through */
 	case OSD_SetBlock:
 		OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data);
-		return 0;
-
+		goto out;
 	case OSD_FillRow:
 		DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
 			  dc->x1-dc->x0+1, dc->y1, dc->color);
-		return 0;
+		goto out;
 	case OSD_FillBlock:
 		DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
 			  dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color);
-		return 0;
+		goto out;
 	case OSD_Line:
 		DrawLine(av7110, av7110->osdwin,
 			 dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color);
-		return 0;
+		goto out;
 	case OSD_Query:
-		return 0;
+		goto out;
 	case OSD_Test:
-		return 0;
+		goto out;
 	case OSD_Text:
 	{
 		char textbuf[240];
 
-		if (strncpy_from_user(textbuf, dc->data, 240) < 0)
-			return -EFAULT;
+		if (strncpy_from_user(textbuf, dc->data, 240) < 0) {
+			ret = -EFAULT;
+			goto out;
+		}
 		textbuf[239] = 0;
 		if (dc->x1 > 3)
 			dc->x1 = 3;
@@ -1026,16 +1096,55 @@
 			(u16) (dc->color & 0xffff), (u16) (dc->color >> 16));
 		FlushText(av7110);
 		WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf);
-		return 0;
+		goto out;
 	}
 	case OSD_SetWindow:
-		if (dc->x0 < 1 || dc->x0 > 7)
-			return -EINVAL;
+		if (dc->x0 < 1 || dc->x0 > 7) {
+			ret = -EINVAL;
+			goto out;
+		}
 		av7110->osdwin = dc->x0;
-		return 0;
+		goto out;
 	case OSD_MoveWindow:
 		MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
 		SetColorBlend(av7110, av7110->osdwin);
+		goto out;
+	case OSD_OpenRaw:
+		if (dc->color < OSD_BITMAP1 || dc->color > OSD_CURSOR) {
+			ret = -EINVAL;
+			goto out;
+		}
+		if (dc->color >= OSD_BITMAP1 && dc->color <= OSD_BITMAP8HR) {
+			av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1;
+		}
+		else {
+			av7110->osdbpp[av7110->osdwin] = 0;
+		}
+		CreateOSDWindow(av7110, av7110->osdwin, (osd_raw_window_t)dc->color,
+				dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1);
+		if (!dc->data) {
+			MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
+			SetColorBlend(av7110, av7110->osdwin);
+		}
+		goto out;
+	default:
+		ret = -EINVAL;
+		goto out;
+	}
+
+out:
+	up(&av7110->osd_sema);
+	return ret;
+}
+
+int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap)
+{
+        switch (cap->cmd) {
+        case OSD_CAP_MEMSIZE:
+                if (FW_4M_SDRAM(av7110->arm_app))
+                        cap->val = 1000000;
+                else
+                        cap->val = 92000;
 		return 0;
 	default:
 		return -EINVAL;
diff -Nru a/drivers/media/dvb/ttpci/av7110_hw.h b/drivers/media/dvb/ttpci/av7110_hw.h
--- a/drivers/media/dvb/ttpci/av7110_hw.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/media/dvb/ttpci/av7110_hw.h	2004-12-24 13:36:47 -08:00
@@ -39,29 +39,6 @@
 	Pal8Bit =  256	   /* 256 colors for 16 bit palette */
 };
 
-enum av7110_window_display_type {
-	BITMAP1,	   /* 1 bit bitmap */
-	BITMAP2,	   /* 2 bit bitmap */
-	BITMAP4,	   /* 4 bit bitmap */
-	BITMAP8,	   /* 8 bit bitmap */
-	BITMAP1HR,	   /* 1 Bit bitmap half resolution */
-	BITMAP2HR,	   /* 2 bit bitmap half resolution */
-	BITMAP4HR,	   /* 4 bit bitmap half resolution */
-	BITMAP8HR,	   /* 8 bit bitmap half resolution */
-	YCRCB422,	   /* 4:2:2 YCRCB Graphic Display */
-	YCRCB444,	   /* 4:4:4 YCRCB Graphic Display */
-	YCRCB444HR,	   /* 4:4:4 YCRCB graphic half resolution */
-	VIDEOTSIZE,	   /* True Size Normal MPEG Video Display */
-	VIDEOHSIZE,	   /* MPEG Video Display Half Resolution */
-	VIDEOQSIZE,	   /* MPEG Video Display Quarter Resolution */
-	VIDEODSIZE,	   /* MPEG Video Display Double Resolution */
-	VIDEOTHSIZE,	   /* True Size MPEG Video Display Half Resolution */
-	VIDEOTQSIZE,	   /* True Size MPEG Video Display Quarter Resolution*/
-	VIDEOTDSIZE,	   /* True Size MPEG Video Display Double Resolution */
-	VIDEONSIZE,	   /* Full Size MPEG Video Display */
-	CURSOR		   /* Cursor */
-};
-
 /* switch defines */
 #define SB_GPIO 3
 #define SB_OFF	SAA7146_GPIO_OUTLO  /* SlowBlank off (TV-Mode) */
@@ -88,6 +65,9 @@
 #define HPQOver		0x0008
 #define OSDQFull	0x0010		/* OSD Queue Full */
 #define OSDQOver	0x0020
+#define GPMQBusy	0x0040		/* Queue not empty, FW >= 261d */
+#define HPQBusy		0x0080
+#define OSDQBusy	0x0100
 
 /* hw section filter flags */
 #define	SECTION_EIT		0x01
@@ -388,8 +368,10 @@
 extern int av7110_bootarm(struct av7110 *av7110);
 extern int av7110_firmversion(struct av7110 *av7110);
 #define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000)
+#define FW_4M_SDRAM(arm_app)      ((arm_app) & 0x40000000)
 #define FW_VERSION(arm_app)	  ((arm_app) & 0x0000FFFF)
 
+extern int av7110_wait_msgstate(struct av7110 *av7110, u16 flags);
 extern int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...);
 extern int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length);
 extern int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length);
@@ -495,7 +477,7 @@
 
 static int inline audcom(struct av7110 *av7110, u32 com)
 {
-	return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_AUDIO_COMMAND, 4,
+	return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_AUDIO_COMMAND, 2,
 			     (com>>16), (com&0xffff));
 }
 
@@ -510,6 +492,7 @@
 
 #ifdef CONFIG_DVB_AV7110_OSD
 extern int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc);
+extern int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap);
 #endif /* CONFIG_DVB_AV7110_OSD */
 
 
diff -Nru a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
--- a/drivers/media/dvb/ttpci/av7110_ir.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/media/dvb/ttpci/av7110_ir.c	2004-12-24 13:36:30 -08:00
@@ -1,23 +1,16 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/input.h>
 #include <linux/proc_fs.h>
 #include <asm/bitops.h>
 
 #include "av7110.h"
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-#include "input_fake.h"
-#endif
-
-
 #define UP_TIMEOUT (HZ/4)
 
-static int av7110_ir_debug = 0;
-
-#define dprintk(x...)  do { if (av7110_ir_debug) printk (x); } while (0)
-
+/* enable ir debugging by or'ing av7110_debug with 16 */
 
 static struct input_dev input_dev;
 
@@ -80,7 +73,7 @@
 
 	keycode = key_map[data];
 	
-	dprintk ("#########%08x######### addr %i data 0x%02x (keycode %i)\n",
+	dprintk(16, "#########%08x######### addr %i data 0x%02x (keycode %i)\n",
 		 ircom, addr, data, keycode);
 
 	/* check device address (if selected) */
@@ -205,6 +198,7 @@
 
 void __exit av7110_ir_exit (void)
 {
+	del_timer_sync(&keyup_timer);
 	remove_proc_entry ("av7110_ir", NULL);
 	av7110_unregister_irc_handler (av7110_emit_key);
 	input_unregister_device(&input_dev);
@@ -212,7 +206,4 @@
 
 //MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>");
 //MODULE_LICENSE("GPL");
-
-MODULE_PARM(av7110_ir_debug,"i");
-MODULE_PARM_DESC(av7110_ir_debug, "enable AV7110 IR receiver debug messages");
 
diff -Nru a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
--- a/drivers/media/dvb/ttpci/av7110_v4l.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c	2004-12-24 13:36:56 -08:00
@@ -35,25 +35,18 @@
 #include <linux/byteorder/swabb.h>
 #include <linux/smp_lock.h>
 
-#define DEBUG_VARIABLE av7110_debug
-extern int av7110_debug;
-
-#include "dvb_i2c.h"
 #include "av7110.h"
 #include "av7110_hw.h"
 #include "av7110_av.h"
-#include "dvb_functions.h"
-
 
 int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val)
 {
 	u8 msg[5] = { dev, reg >> 8, reg & 0xff, val >> 8 , val & 0xff };
-	struct dvb_i2c_bus *i2c = av7110->i2c_bus;
 	struct i2c_msg msgs = { .flags = 0, .addr = 0x40, .len = 5, .buf = msg };
 
-	if (i2c->xfer(i2c, &msgs, 1) != 1) {
-		printk("av7110(%d): %s(%u = %u) failed\n",
-		       av7110->dvb_adapter->num, __FUNCTION__, reg, val);
+	if (i2c_transfer(&av7110->i2c_adap, &msgs, 1) != 1) {
+		dprintk(1, "dvb-ttpci: failed @ card %d, %u = %u\n",
+		       av7110->dvb_adapter->num, reg, val);
 		return -EIO;
 	}
 	return 0;
@@ -63,15 +56,14 @@
 {
 	u8 msg1[3] = { dev, reg >> 8, reg & 0xff };
 	u8 msg2[2];
-	struct dvb_i2c_bus *i2c = av7110->i2c_bus;
 	struct i2c_msg msgs[2] = {
 		{ .flags = 0,	     .addr = 0x40, .len = 3, .buf = msg1 },
 		{ .flags = I2C_M_RD, .addr = 0x40, .len = 2, .buf = msg2 }
 	};
 
-	if (i2c->xfer(i2c, msgs, 2) != 2) {
-		printk("av7110(%d): %s(%u) failed\n",
-		       av7110->dvb_adapter->num, __FUNCTION__, reg);
+	if (i2c_transfer(&av7110->i2c_adap, &msgs[0], 2) != 2) {
+		dprintk(1, "dvb-ttpci: failed @ card %d, %u\n",
+		       av7110->dvb_adapter->num, reg);
 		return -EIO;
 	}
 	*val = (msg2[0] << 8) | msg2[1];
@@ -100,43 +92,47 @@
 	}
 };
 
-/* for Siemens DVB-C analog module: (taken from ves1820.c) */
-static int ves1820_writereg(struct saa7146_dev *dev, u8 reg, u8 data)
+static int ves1820_writereg(struct saa7146_dev *dev, u8 addr, u8 reg, u8 data)
 {
-	u8 addr = 0x09;
 	u8 buf[] = { 0x00, reg, data };
 	struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 3 };
 
-	DEB_EE(("av7710: dev: %p\n", dev));
+	dprintk(4, "dev: %p\n", dev);
+
+	if (1 != saa7146_i2c_transfer(dev, &msg, 1, 1))
+		return -1;
+	return 0;
+}
+
+static int stv0297_writereg(struct saa7146_dev *dev, u8 addr, u8 reg, u8 data)
+{
+        u8 buf [] = { reg, data };
+        struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 2 };
 
 	if (1 != saa7146_i2c_transfer(dev, &msg, 1, 1))
 		return -1;
 	return 0;
 }
 
+
 static int tuner_write(struct saa7146_dev *dev, u8 addr, u8 data [4])
 {
 	struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = data, .len = 4 };
 
-	DEB_EE(("av7710: dev: %p\n", dev));
+	dprintk(4, "dev: %p\n", dev);
 
 	if (1 != saa7146_i2c_transfer(dev, &msg, 1, 1))
 		return -1;
 	return 0;
 }
 
-
-/**
- *   set up the downconverter frequency divisor for a
- *   reference clock comparision frequency of 62.5 kHz.
- */
-static int tuner_set_tv_freq(struct saa7146_dev *dev, u32 freq)
+static int ves1820_set_tv_freq(struct saa7146_dev *dev, u32 freq)
 {
 	u32 div;
 	u8 config;
 	u8 buf[4];
 
-	DEB_EE(("av7710: freq: 0x%08x\n", freq));
+	dprintk(4, "freq: 0x%08x\n", freq);
 
 	/* magic number: 614. tuning with the frequency given by v4l2
 	   is always off by 614*62.5 = 38375 kHz...*/
@@ -159,6 +155,34 @@
 	return tuner_write(dev, 0x61, buf);
 }
 
+static int stv0297_set_tv_freq(struct saa7146_dev *dev, u32 freq)
+{
+	u32 div;
+	u8 data[4];
+
+	div = (freq + 38900000 + 31250) / 62500;
+
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0xce;
+
+	if (freq < 45000000)
+		return -EINVAL;
+	else if (freq < 137000000)
+		data[3] = 0x01;
+	else if (freq < 403000000)
+		data[3] = 0x02;
+	else if (freq < 860000000)
+		data[3] = 0x04;
+	else
+		return -EINVAL;
+
+	stv0297_writereg(dev, 0x1C, 0x87, 0x78);
+	stv0297_writereg(dev, 0x1C, 0x86, 0xc8);
+	return tuner_write(dev, 0x63, data);
+}
+
+
 
 static struct saa7146_standard analog_standard[];
 static struct saa7146_standard dvb_standard[];
@@ -170,60 +194,71 @@
 	.capability = V4L2_AUDCAP_STEREO
 };
 
-int av7110_dvb_c_switch(struct saa7146_fh *fh)
+static int av7110_dvb_c_switch(struct saa7146_fh *fh)
 {
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_vv *vv = dev->vv_data;
 	struct av7110 *av7110 = (struct av7110*)dev->ext_priv;
 	u16 adswitch;
-	u8 band = 0;
 	int source, sync, err;
 
-	DEB_EE(("av7110: %p\n", av7110));
+	dprintk(4, "%p\n", av7110);
 
 	if ((vv->video_status & STATUS_OVERLAY) != 0) {
 		vv->ov_suspend = vv->video_fh;
 		err = saa7146_stop_preview(vv->video_fh); /* side effect: video_status is now 0, video_fh is NULL */
 		if (err != 0) {
-			DEB_D(("warning: suspending video failed\n"));
+			dprintk(2, "suspending video failed\n");
 			vv->ov_suspend = NULL;
 		}
 	}
 
 	if (0 != av7110->current_input) {
 		adswitch = 1;
-		band = 0x60; /* analog band */
 		source = SAA7146_HPS_SOURCE_PORT_B;
 		sync = SAA7146_HPS_SYNC_PORT_B;
 		memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2);
-		printk("av7110: switching to analog TV\n");
+		dprintk(1, "switching to analog TV\n");
 		msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source
 		msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source
 		msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source
 		msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
 		msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
 		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
+
+		if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
+			if (ves1820_writereg(dev, 0x09, 0x0f, 0x60))
+				dprintk(1, "setting band in demodulator failed.\n");
+		} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
+			saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD)
+			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF)
+		}
 	} else {
 		adswitch = 0;
-		band = 0x20; /* digital band */
 		source = SAA7146_HPS_SOURCE_PORT_A;
 		sync = SAA7146_HPS_SYNC_PORT_A;
 		memcpy(standard, dvb_standard, sizeof(struct saa7146_standard) * 2);
-		printk("av7110: switching DVB mode\n");
+		dprintk(1, "switching DVB mode\n");
 		msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source
 		msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0220); // headphone source
 		msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0220); // SCART 1 source
 		msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
 		msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone
 		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x7f00); // SCART 1 volume
+
+		if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
+			if (ves1820_writereg(dev, 0x09, 0x0f, 0x20))
+				dprintk(1, "setting band in demodulator failed.\n");
+		} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
+			saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD)
+			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // TDA9198 pin30(VIF)
+		}
 	}
 
 	/* hmm, this does not do anything!? */
 	if (av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, adswitch))
-		printk("ADSwitch error\n");
+		dprintk(1, "ADSwitch error\n");
 
-	if (ves1820_writereg(dev, 0x0f, band))
-		printk("setting band in demodulator failed.\n");
 	saa7146_set_hps_source_and_sync(dev, source, sync);
 
 	if (vv->ov_suspend != NULL) {
@@ -234,11 +269,11 @@
 	return 0;
 }
 
-int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
+static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
 {
 	struct saa7146_dev *dev = fh->dev;
 	struct av7110 *av7110 = (struct av7110*) dev->ext_priv;
-	DEB_EE(("saa7146_dev: %p\n", dev));
+	dprintk(4, "saa7146_dev: %p\n", dev);
 
 	switch (cmd) {
 	case VIDIOC_G_TUNER:
@@ -247,9 +282,9 @@
 		u16 stereo_det;
 		s8 stereo;
 
-		DEB_EE(("VIDIOC_G_TUNER: %d\n", t->index));
+		dprintk(2, "VIDIOC_G_TUNER: %d\n", t->index);
 
-		if (!av7110->has_analog_tuner || t->index != 0)
+		if (!av7110->analog_tuner_flags || t->index != 0)
 			return -EINVAL;
 
 		memset(t, 0, sizeof(*t));
@@ -266,10 +301,10 @@
 
 		// FIXME: standard / stereo detection is still broken
 		msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det);
-printk("VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det);
+		dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det);
 
 		msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det);
-		printk("VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det);
+		dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det);
 		stereo = (s8)(stereo_det >> 8);
 		if (stereo > 0x10) {
 			/* stereo */
@@ -290,29 +325,29 @@
 	{
 		struct v4l2_tuner *t = arg;
 		u16 fm_matrix, src;
-		DEB_EE(("VIDIOC_S_TUNER: %d\n", t->index));
+		dprintk(2, "VIDIOC_S_TUNER: %d\n", t->index);
 
-		if (!av7110->has_analog_tuner || av7110->current_input != 1)
+		if (!av7110->analog_tuner_flags || av7110->current_input != 1)
 			return -EINVAL;
 
 		switch (t->audmode) {
 		case V4L2_TUNER_MODE_STEREO:
-			DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n"));
+			dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n");
 			fm_matrix = 0x3001; // stereo
 			src = 0x0020;
 			break;
 		case V4L2_TUNER_MODE_LANG1:
-			DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n"));
+			dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n");
 			fm_matrix = 0x3000; // mono
 			src = 0x0000;
 			break;
 		case V4L2_TUNER_MODE_LANG2:
-			DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG2\n"));
+			dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG2\n");
 			fm_matrix = 0x3000; // mono
 			src = 0x0010;
 			break;
 		default: /* case V4L2_TUNER_MODE_MONO: {*/
-			DEB_D(("VIDIOC_S_TUNER: TDA9840_SET_MONO\n"));
+			dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n");
 			fm_matrix = 0x3000; // mono
 			src = 0x0030;
 			break;
@@ -327,9 +362,9 @@
 	{
 		struct v4l2_frequency *f = arg;
 
-		DEB_EE(("VIDIOC_G_FREQ: freq:0x%08x.\n", f->frequency));
+		dprintk(2, "VIDIOC_G_FREQ: freq:0x%08x.\n", f->frequency);
 
-		if (!av7110->has_analog_tuner || av7110->current_input != 1)
+		if (!av7110->analog_tuner_flags || av7110->current_input != 1)
 			return -EINVAL;
 
 		memset(f, 0, sizeof(*f));
@@ -341,9 +376,9 @@
 	{
 		struct v4l2_frequency *f = arg;
 
-		DEB_EE(("VIDIOC_S_FREQUENCY: freq:0x%08x.\n", f->frequency));
+		dprintk(2, "VIDIOC_S_FREQUENCY: freq:0x%08x.\n", f->frequency);
 
-		if (!av7110->has_analog_tuner || av7110->current_input != 1)
+		if (!av7110->analog_tuner_flags || av7110->current_input != 1)
 			return -EINVAL;
 
 		if (V4L2_TUNER_ANALOG_TV != f->type)
@@ -353,7 +388,11 @@
 		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0xffe0);
 
 		/* tune in desired frequency */
-		tuner_set_tv_freq(dev, f->frequency);
+		if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
+			ves1820_set_tv_freq(dev, f->frequency);
+		} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
+			stv0297_set_tv_freq(dev, f->frequency);
+		}
 		av7110->current_freq = f->frequency;
 
 		msp_writereg(av7110, MSP_WR_DSP, 0x0015, 0x003f); // start stereo detection
@@ -366,9 +405,9 @@
 	{
 		struct v4l2_input *i = arg;
 
-		DEB_EE(("VIDIOC_ENUMINPUT: %d\n", i->index));
+		dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index);
 
-		if (av7110->has_analog_tuner ) {
+		if (av7110->analog_tuner_flags) {
 			if (i->index < 0 || i->index >= 2)
 				return -EINVAL;
 		} else {
@@ -384,16 +423,16 @@
 	{
 		int *input = (int *)arg;
 		*input = av7110->current_input;
-		DEB_EE(("VIDIOC_G_INPUT: %d\n", *input));
+		dprintk(2, "VIDIOC_G_INPUT: %d\n", *input);
 		return 0;
 	}
 	case VIDIOC_S_INPUT:
 	{
 		int input = *(int *)arg;
 
-		DEB_EE(("VIDIOC_S_INPUT: %d\n", input));
+		dprintk(2, "VIDIOC_S_INPUT: %d\n", input);
 
-		if (!av7110->has_analog_tuner )
+		if (!av7110->analog_tuner_flags)
 			return 0;
 
 		if (input < 0 || input >= 2)
@@ -407,7 +446,7 @@
 	{
 		struct v4l2_audio *a = arg;
 
-		DEB_EE(("VIDIOC_G_AUDIO: %d\n", a->index));
+		dprintk(2, "VIDIOC_G_AUDIO: %d\n", a->index);
 		if (a->index != 0)
 			return -EINVAL;
 		memcpy(a, &msp3400_v4l2_audio, sizeof(struct v4l2_audio));
@@ -416,7 +455,7 @@
 	case VIDIOC_S_AUDIO:
 	{
 		struct v4l2_audio *a = arg;
-		DEB_EE(("VIDIOC_S_AUDIO: %d\n", a->index));
+		dprintk(2, "VIDIOC_S_AUDIO: %d\n", a->index);
 		break;
 	}
 	default:
@@ -431,7 +470,7 @@
  * INITIALIZATION
  ****************************************************************************/
 
-struct saa7146_extension_ioctls ioctls[] = {
+static struct saa7146_extension_ioctls ioctls[] = {
 	{ VIDIOC_ENUMINPUT,	SAA7146_EXCLUSIVE },
 	{ VIDIOC_G_INPUT,	SAA7146_EXCLUSIVE },
 	{ VIDIOC_S_INPUT,	SAA7146_EXCLUSIVE },
@@ -514,13 +553,13 @@
 	    || i2c_writereg(av7110, 0x80, 0x0, 0) != 1)
 		return -ENODEV;
 
-	printk("av7110(%d): DVB-C analog module detected, initializing MSP3400\n",
+	printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3400\n",
 		av7110->dvb_adapter->num);
 	av7110->adac_type = DVB_ADAC_MSP;
-	dvb_delay(100); // the probing above resets the msp...
+	msleep(100); // the probing above resets the msp...
 	msp_readreg(av7110, MSP_RD_DSP, 0x001e, &version1);
 	msp_readreg(av7110, MSP_RD_DSP, 0x001f, &version2);
-	printk("av7110(%d): MSP3400 version 0x%04x 0x%04x\n",
+	dprintk(1, "dvb-ttpci: @ card %d MSP3400 version 0x%04x 0x%04x\n",
 		av7110->dvb_adapter->num, version1, version2);
 	msp_writereg(av7110, MSP_WR_DSP, 0x0013, 0x0c00);
 	msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone
@@ -535,12 +574,31 @@
 		INFO(("saa7113 not accessible.\n"));
 	} else {
 		u8 *i = saa7113_init_regs;
-		av7110->has_analog_tuner = 1;
+
+		if ((av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) {
+			/* Fujitsu/Siemens DVB-Cable */
+			av7110->analog_tuner_flags |= ANALOG_TUNER_VES1820;
+		} else if ((av7110->dev->pci->subsystem_vendor == 0x13c2) && (av7110->dev->pci->subsystem_device == 0x0002)) {
+			/* Hauppauge/TT DVB-C premium */
+			av7110->analog_tuner_flags |= ANALOG_TUNER_VES1820;
+		} else if ((av7110->dev->pci->subsystem_vendor == 0x13c2) && (av7110->dev->pci->subsystem_device == 0x000A)) {
+			/* Hauppauge/TT DVB-C premium */
+			av7110->analog_tuner_flags |= ANALOG_TUNER_STV0297;
+		}
+
+		/* setup for DVB by default */
+		if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
+			if (ves1820_writereg(av7110->dev, 0x09, 0x0f, 0x20))
+				dprintk(1, "setting band in demodulator failed.\n");
+		} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
+			saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD)
+			saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9198 pin30(VIF)
+		}
+
 		/* init the saa7113 */
 		while (*i != 0xff) {
 			if (i2c_writereg(av7110, 0x48, i[0], i[1]) != 1) {
-				printk("av7110(%d): saa7113 initialization failed",
-						av7110->dvb_adapter->num);
+				dprintk(1, "saa7113 initialization failed @ card %d", av7110->dvb_adapter->num);
 				break;
 			}
 			i += 2;
@@ -587,7 +645,7 @@
 	/* special case DVB-C: these cards have an analog tuner
 	   plus need some special handling, so we have separate
 	   saa7146_ext_vv data for these... */
-	if (av7110->has_analog_tuner)
+	if (av7110->analog_tuner_flags)
 		ret = saa7146_vv_init(dev, &av7110_vv_data_c);
 	else
 		ret = saa7146_vv_init(dev, &av7110_vv_data_st);
@@ -602,12 +660,12 @@
 		saa7146_vv_release(dev);
 		return -ENODEV;
 	}
-	if (av7110->has_analog_tuner) {
+	if (av7110->analog_tuner_flags) {
 		if (saa7146_register_device(&av7110->vbi_dev, dev, "av7110", VFL_TYPE_VBI)) {
 			ERR(("cannot register vbi v4l2 device. skipping.\n"));
-		} else
-			/* we use this to remember that this dvb-c card can do vbi */
-			av7110->has_analog_tuner = 2;
+		} else {
+			av7110->analog_tuner_flags |= ANALOG_TUNER_VBI;
+		}
 	}
 	return 0;
 }
@@ -615,7 +673,7 @@
 int av7110_exit_v4l(struct av7110 *av7110)
 {
 	saa7146_unregister_device(&av7110->v4l_dev, av7110->dev);
-	if (2 == av7110->has_analog_tuner)
+	if (av7110->analog_tuner_flags & ANALOG_TUNER_VBI)
 		saa7146_unregister_device(&av7110->vbi_dev, av7110->dev);
 	return 0;
 }
@@ -692,7 +750,7 @@
 	.flags		= 0,
 
 	.stds		= &standard[0],
-	.num_stds	= sizeof(standard) / sizeof(struct saa7146_standard),
+	.num_stds	= ARRAY_SIZE(standard),
 	.std_callback	= &std_callback,
 
 	.ioctls		= &ioctls[0],
@@ -706,7 +764,7 @@
 	.flags		= SAA7146_USE_PORT_B_FOR_VBI,
 
 	.stds		= &standard[0],
-	.num_stds	= sizeof(standard) / sizeof(struct saa7146_standard),
+	.num_stds	= ARRAY_SIZE(standard),
 	.std_callback	= &std_callback,
 
 	.ioctls		= &ioctls[0],
diff -Nru a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
--- a/drivers/media/dvb/ttpci/budget-av.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/dvb/ttpci/budget-av.c	2004-12-24 13:37:18 -08:00
@@ -4,6 +4,9 @@
  *
  * Compiled from various sources by Michael Hunold <michael@mihu.de> 
  *
+ * CI interface support (c) 2004 Olivier Gournet <ogournet@anevia.com> &
+ *                               Andrew de Quincey <adq_dvb@lidskialf.net>
+ *
  * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
  *
  * Copyright (C) 1999-2002 Ralph  Metzler 
@@ -30,24 +33,41 @@
  * the project's page is at http://www.linuxtv.org/dvb/
  */
 
+#include "budget.h"
+#include "stv0299.h"
+#include "tda10021.h"
+#include "tda1004x.h"
 #include <media/saa7146_vv.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <linux/spinlock.h>
 
-#include "budget.h"
-#include "dvb_functions.h"
+#include "dvb_ca_en50221.h"
+
+#define DEBICICAM		0x02420000
 
 struct budget_av {
 	struct budget budget;
-	struct video_device vd;
+	struct video_device *vd;
 	int cur_input;
 	int has_saa7113;
+	struct tasklet_struct ciintf_irq_tasklet;
+	int slot_status;
+	struct dvb_ca_en50221 ca;
 };
 
+int enable_ci = 0;
+
+
 /****************************************************************************
  * INITIALIZATION
  ****************************************************************************/
 
 
-static u8 i2c_readreg (struct dvb_i2c_bus *i2c, u8 id, u8 reg)
+static u8 i2c_readreg (struct i2c_adapter *i2c, u8 id, u8 reg)
 {
 	u8 mm1[] = {0x00};
 	u8 mm2[] = {0x00};
@@ -57,15 +77,17 @@
 	msgs[1].flags = I2C_M_RD;
 	msgs[0].addr = msgs[1].addr=id/2;
 	mm1[0] = reg;
-	msgs[0].len = 1; msgs[1].len = 1;
-	msgs[0].buf = mm1; msgs[1].buf = mm2;
+	msgs[0].len = 1;
+	msgs[1].len = 1;
+	msgs[0].buf = mm1;
+	msgs[1].buf = mm2;
 
-	i2c->xfer(i2c, msgs, 2);
+	i2c_transfer(i2c, msgs, 2);
 
 	return mm2[0];
 }
 
-static int i2c_readregs(struct dvb_i2c_bus *i2c, u8 id, u8 reg, u8 *buf, u8 len)
+static int i2c_readregs(struct i2c_adapter *i2c, u8 id, u8 reg, u8 *buf, u8 len)
 {
         u8 mm1[] = { reg };
         struct i2c_msg msgs[2] = {
@@ -73,13 +95,14 @@
 		{ .addr = id/2, .flags = I2C_M_RD, .buf = buf, .len = len }
 	};
 
-        if (i2c->xfer(i2c, msgs, 2) != 2)
+        if (i2c_transfer(i2c, msgs, 2) != 2)
 		return -EIO;
+
 	return 0;
 }
 
 
-static int i2c_writereg (struct dvb_i2c_bus *i2c, u8 id, u8 reg, u8 val)
+static int i2c_writereg (struct i2c_adapter *i2c, u8 id, u8 reg, u8 val)
 {
         u8 msg[2]={ reg, val }; 
         struct i2c_msg msgs;
@@ -88,7 +111,212 @@
         msgs.addr=id/2;
         msgs.len=2;
         msgs.buf=msg;
-        return i2c->xfer (i2c, &msgs, 1);
+        return i2c_transfer(i2c, &msgs, 1);
+}
+
+static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
+{
+	struct budget_av *budget_av = (struct budget_av *) ca->data;
+	int result;
+
+	if (slot != 0)
+		return -EINVAL;
+
+	saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
+	result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 0);
+
+	if (result == -ETIMEDOUT)
+		budget_av->slot_status = 0;
+	return result;
+}
+
+static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
+{
+	struct budget_av *budget_av = (struct budget_av *) ca->data;
+	int result;
+
+	if (slot != 0)
+		return -EINVAL;
+
+	saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
+	result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 0);
+
+	if (result == -ETIMEDOUT)
+		budget_av->slot_status = 0;
+	return result;
+}
+
+static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
+{
+	struct budget_av *budget_av = (struct budget_av *) ca->data;
+	int result;
+
+	if (slot != 0)
+		return -EINVAL;
+
+	saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
+	result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
+
+	if (result == -ETIMEDOUT)
+		budget_av->slot_status = 0;
+	return result;
+}
+
+static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
+{
+	struct budget_av *budget_av = (struct budget_av *) ca->data;
+	int result;
+
+	if (slot != 0)
+		return -EINVAL;
+
+	saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
+	result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
+
+	if (result == -ETIMEDOUT)
+		budget_av->slot_status = 0;
+	return result;
+}
+
+static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
+{
+	struct budget_av *budget_av = (struct budget_av *) ca->data;
+	struct saa7146_dev *saa = budget_av->budget.dev;
+
+	if (slot != 0)
+		return -EINVAL;
+
+	dprintk(1, "ciintf_slot_reset\n");
+
+	/* reset the card */
+	saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
+	msleep(100);
+	saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
+	msleep(2000);		/* horrendous I know, but its the only way to be absolutely sure without an IRQ line! */
+
+	ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
+	return 0;
+}
+
+static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
+{
+	struct budget_av *budget_av = (struct budget_av *) ca->data;
+	struct saa7146_dev *saa = budget_av->budget.dev;
+
+	if (slot != 0)
+		return -EINVAL;
+
+	dprintk(1, "ciintf_slot_shutdown\n");
+
+	ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
+	budget_av->slot_status = 0;
+	return 0;
+}
+
+static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
+{
+	struct budget_av *budget_av = (struct budget_av *) ca->data;
+	struct saa7146_dev *saa = budget_av->budget.dev;
+
+	if (slot != 0)
+		return -EINVAL;
+
+	dprintk(1, "ciintf_slot_ts_enable: %d\n", budget_av->slot_status);
+
+	ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
+	return 0;
+}
+
+static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
+{
+	struct budget_av *budget_av = (struct budget_av *) ca->data;
+	struct saa7146_dev *saa = budget_av->budget.dev;
+	int cam = 0;
+
+	if (slot != 0)
+		return -EINVAL;
+
+	if (!budget_av->slot_status) {
+		saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
+		udelay(1);
+		cam = saa7146_read(saa, PSR) & MASK_06;
+		saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
+
+		if (cam)
+			budget_av->slot_status = 1;
+	} else if (!open) {
+		saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
+		if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) == -ETIMEDOUT)
+			budget_av->slot_status = 0;
+	}
+
+	if (budget_av->slot_status == 1)
+		return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
+
+	return 0;
+}
+
+static int ciintf_init(struct budget_av *budget_av)
+{
+	struct saa7146_dev *saa = budget_av->budget.dev;
+	int result;
+
+	memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221));
+
+	/* setup GPIOs */
+	saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI);
+	saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO);
+	saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
+
+	/* Reset the card */
+	saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
+	msleep(50);
+	saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
+	msleep(100);
+
+	/* Enable DEBI pins */
+	saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
+
+	/* register CI interface */
+	budget_av->ca.owner = THIS_MODULE;
+	budget_av->ca.read_attribute_mem = ciintf_read_attribute_mem;
+	budget_av->ca.write_attribute_mem = ciintf_write_attribute_mem;
+	budget_av->ca.read_cam_control = ciintf_read_cam_control;
+	budget_av->ca.write_cam_control = ciintf_write_cam_control;
+	budget_av->ca.slot_reset = ciintf_slot_reset;
+	budget_av->ca.slot_shutdown = ciintf_slot_shutdown;
+	budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
+	budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
+	budget_av->ca.data = budget_av;
+	if ((result = dvb_ca_en50221_init(budget_av->budget.dvb_adapter,
+					  &budget_av->ca, 0, 1)) != 0) {
+		printk("budget_av: CI interface detected, but initialisation failed.\n");
+		goto error;
+	}
+	// success!
+	printk("ciintf_init: CI interface initialised\n");
+	budget_av->budget.ci_present = 1;
+	return 0;
+
+error:
+	saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16));
+	return result;
+}
+
+static void ciintf_deinit(struct budget_av *budget_av)
+{
+	struct saa7146_dev *saa = budget_av->budget.dev;
+
+	saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
+	saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
+	saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
+	saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
+
+	/* release the CA device */
+	dvb_ca_en50221_release(&budget_av->ca);
+
+	/* disable DEBI pins */
+	saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16));
 }
 
 
@@ -127,20 +355,19 @@
 	struct budget *budget = &budget_av->budget;
 	const u8 *data = saa7113_tab;
 
-        if (i2c_writereg (budget->i2c_bus, 0x4a, 0x01, 0x08) != 1) {
-                DEB_D(("saa7113: not found on KNC card\n"));
+        if (i2c_writereg (&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) {
+                dprintk(1, "saa7113 not found on KNC card\n");
                 return -ENODEV;
         }
 
-        INFO(("saa7113: detected and initializing\n"));
+        dprintk(1, "saa7113 detected and initializing\n");
 
 	while (*data != 0xff) {
-                i2c_writereg(budget->i2c_bus, 0x4a, *data, *(data+1));
+                i2c_writereg(&budget->i2c_adap, 0x4a, *data, *(data+1));
                 data += 2;
         }
 
-	DEB_D(("saa7113: status=%02x\n",
-	      i2c_readreg(budget->i2c_bus, 0x4a, 0x1f)));
+	dprintk(1, "saa7113  status=%02x\n", i2c_readreg(&budget->i2c_adap, 0x4a, 0x1f));
 
 	return 0;
 }
@@ -154,11 +381,11 @@
 		return -ENODEV;
 
 	if (input == 1) {
-		i2c_writereg(budget->i2c_bus, 0x4a, 0x02, 0xc7);
-		i2c_writereg(budget->i2c_bus, 0x4a, 0x09, 0x80);
+		i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc7);
+		i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x80);
 	} else if (input == 0) {
-		i2c_writereg(budget->i2c_bus, 0x4a, 0x02, 0xc0);
-		i2c_writereg(budget->i2c_bus, 0x4a, 0x09, 0x00);
+		i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc0);
+		i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x00);
 	} else
 		return -EINVAL;
 
@@ -167,21 +394,405 @@
 }
 
 
+static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
+{
+	u8 aclk = 0;
+	u8 bclk = 0;
+	u8 m1;
+
+	aclk = 0xb5;
+	if (srate < 2000000)
+		bclk = 0x86;
+	else if (srate < 5000000)
+		bclk = 0x89;
+	else if (srate < 15000000)
+		bclk = 0x8f;
+	else if (srate < 45000000)
+		bclk = 0x95;
+
+	m1 = 0x14;
+	if (srate < 4000000)
+		m1 = 0x10;
+
+	stv0299_writereg(fe, 0x13, aclk);
+	stv0299_writereg(fe, 0x14, bclk);
+	stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
+	stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
+	stv0299_writereg(fe, 0x0f, 0x80 | m1);
+
+	return 0;
+}
+
+static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe,
+					struct dvb_frontend_parameters *params)
+{
+	struct budget_av *budget_av = (struct budget_av *) fe->dvb->priv;
+	u32 div;
+	u8 buf[4];
+	struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
+
+	if ((params->frequency < 950000) || (params->frequency > 2150000))
+		return -EINVAL;
+
+	div = (params->frequency + (125 - 1)) / 125;	// round correctly
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
+	buf[3] = 0x20;
+
+	if (params->u.qpsk.symbol_rate < 4000000)
+		buf[3] |= 1;
+
+	if (params->frequency < 1250000)
+		buf[3] |= 0;
+	else if (params->frequency < 1550000)
+		buf[3] |= 0x40;
+	else if (params->frequency < 2050000)
+		buf[3] |= 0x80;
+	else if (params->frequency < 2150000)
+		buf[3] |= 0xC0;
+
+	if (i2c_transfer(&budget_av->budget.i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static u8 typhoon_cinergy1200s_inittab[] = {
+	0x01, 0x15,
+	0x02, 0x30,
+	0x03, 0x00,
+	0x04, 0x7d,		/* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
+	0x05, 0x35,		/* I2CT = 0, SCLT = 1, SDAT = 1 */
+	0x06, 0x40,		/* DAC not used, set to high impendance mode */
+	0x07, 0x00,		/* DAC LSB */
+	0x08, 0x40,		/* DiSEqC off */
+	0x09, 0x00,		/* FIFO */
+	0x0c, 0x51,		/* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
+	0x0d, 0x82,		/* DC offset compensation = ON, beta_agc1 = 2 */
+	0x0e, 0x23,		/* alpha_tmg = 2, beta_tmg = 3 */
+	0x10, 0x3f,		// AGC2  0x3d
+	0x11, 0x84,
+	0x12, 0xb5,		// Lock detect: -64  Carrier freq detect:on
+	0x15, 0xc9,		// lock detector threshold
+	0x16, 0x00,
+	0x17, 0x00,
+	0x18, 0x00,
+	0x19, 0x00,
+	0x1a, 0x00,
+	0x1f, 0x50,
+	0x20, 0x00,
+	0x21, 0x00,
+	0x22, 0x00,
+	0x23, 0x00,
+	0x28, 0x00,		// out imp: normal  out type: parallel FEC mode:0
+	0x29, 0x1e,		// 1/2 threshold
+	0x2a, 0x14,		// 2/3 threshold
+	0x2b, 0x0f,		// 3/4 threshold
+	0x2c, 0x09,		// 5/6 threshold
+	0x2d, 0x05,		// 7/8 threshold
+	0x2e, 0x01,
+	0x31, 0x1f,		// test all FECs
+	0x32, 0x19,		// viterbi and synchro search
+	0x33, 0xfc,		// rs control
+	0x34, 0x93,		// error control
+	0x0f, 0x92,
+	0xff, 0xff
+};
+
+static struct stv0299_config typhoon_config = {
+	.demod_address = 0x68,
+	.inittab = typhoon_cinergy1200s_inittab,
+	.mclk = 88000000UL,
+	.invert = 0,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_1,
+	.volt13_op0_op1 = STV0299_VOLT13_OP0,
+	.min_delay_ms = 100,
+	.set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
+	.pll_set = philips_su1278_ty_ci_pll_set,
+};
+
+
+static struct stv0299_config cinergy_1200s_config = {
+	.demod_address = 0x68,
+	.inittab = typhoon_cinergy1200s_inittab,
+	.mclk = 88000000UL,
+	.invert = 0,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_0,
+	.volt13_op0_op1 = STV0299_VOLT13_OP0,
+	.min_delay_ms = 100,
+	.set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
+	.pll_set = philips_su1278_ty_ci_pll_set,
+};
+
+
+static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+	struct budget *budget = (struct budget *) fe->dvb->priv;
+	u8 buf[4];
+	struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
+
+#define TUNER_MUL 62500
+
+	u32 div = (params->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL;
+
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x8e;
+	buf[3] = (params->frequency < 174500000 ? 0xa1 :
+		  params->frequency < 454000000 ? 0x92 : 0x34);
+
+	if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static struct tda10021_config philips_cu1216_config = {
+	.demod_address = 0x0c,
+	.pll_set = philips_cu1216_pll_set,
+};
+
+
+
+
+static int philips_tu1216_pll_init(struct dvb_frontend *fe)
+{
+	struct budget *budget = (struct budget *) fe->dvb->priv;
+	static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
+	struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
+
+	// setup PLL configuration
+	if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
+		return -EIO;
+	msleep(1);
+
+	return 0;
+}
+
+static int philips_tu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+	struct budget *budget = (struct budget *) fe->dvb->priv;
+	u8 tuner_buf[4];
+	struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,.len =
+			sizeof(tuner_buf) };
+	int tuner_frequency = 0;
+	u8 band, cp, filter;
+
+	// determine charge pump
+	tuner_frequency = params->frequency + 36166000;
+	if (tuner_frequency < 87000000)
+		return -EINVAL;
+	else if (tuner_frequency < 130000000)
+		cp = 3;
+	else if (tuner_frequency < 160000000)
+		cp = 5;
+	else if (tuner_frequency < 200000000)
+		cp = 6;
+	else if (tuner_frequency < 290000000)
+		cp = 3;
+	else if (tuner_frequency < 420000000)
+		cp = 5;
+	else if (tuner_frequency < 480000000)
+		cp = 6;
+	else if (tuner_frequency < 620000000)
+		cp = 3;
+	else if (tuner_frequency < 830000000)
+		cp = 5;
+	else if (tuner_frequency < 895000000)
+		cp = 7;
+	else
+		return -EINVAL;
+
+	// determine band
+	if (params->frequency < 49000000)
+		return -EINVAL;
+	else if (params->frequency < 161000000)
+		band = 1;
+	else if (params->frequency < 444000000)
+		band = 2;
+	else if (params->frequency < 861000000)
+		band = 4;
+	else
+		return -EINVAL;
+
+	// setup PLL filter
+	switch (params->u.ofdm.bandwidth) {
+	case BANDWIDTH_6_MHZ:
+		filter = 0;
+		break;
+
+	case BANDWIDTH_7_MHZ:
+		filter = 0;
+		break;
+
+	case BANDWIDTH_8_MHZ:
+		filter = 1;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	// calculate divisor
+	// ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
+	tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
+
+	// setup tuner buffer
+	tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
+	tuner_buf[1] = tuner_frequency & 0xff;
+	tuner_buf[2] = 0xca;
+	tuner_buf[3] = (cp << 5) | (filter << 3) | band;
+
+	if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
+		return -EIO;
+
+	msleep(1);
+	return 0;
+}
+
+static int philips_tu1216_request_firmware(struct dvb_frontend *fe,
+					   const struct firmware **fw, char *name)
+{
+	struct budget *budget = (struct budget *) fe->dvb->priv;
+
+	return request_firmware(fw, name, &budget->dev->pci->dev);
+}
+
+struct tda1004x_config philips_tu1216_config = {
+
+	.demod_address = 0x8,
+	.invert = 1,
+	.invert_oclk = 1,
+	.pll_init = philips_tu1216_pll_init,
+	.pll_set = philips_tu1216_pll_set,
+	.request_firmware = philips_tu1216_request_firmware,
+};
+
+
+
+
+static u8 read_pwm(struct budget_av *budget_av)
+{
+	u8 b = 0xff;
+	u8 pwm;
+	struct i2c_msg msg[] = { {.addr = 0x50,.flags = 0,.buf = &b,.len = 1},
+	{.addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1}
+	};
+
+	if ((i2c_transfer(&budget_av->budget.i2c_adap, msg, 2) != 2)
+	    || (pwm == 0xff))
+		pwm = 0x48;
+
+	return pwm;
+}
+
+
+static void frontend_init(struct budget_av *budget_av)
+{
+	switch (budget_av->budget.dev->pci->subsystem_device) {
+	case 0x4f56:		// Typhoon/KNC1 DVB-S budget (stv0299/Philips SU1278(tsa5059))
+		budget_av->budget.dvb_frontend =
+			stv0299_attach(&typhoon_config, &budget_av->budget.i2c_adap);
+		if (budget_av->budget.dvb_frontend != NULL) {
+			break;
+		}
+		break;
+
+	case 0x0020:		// KNC1 DVB-C budget (tda10021/Philips CU1216(tua6034))
+		budget_av->budget.dvb_frontend =
+			tda10021_attach(&philips_cu1216_config,
+					&budget_av->budget.i2c_adap, read_pwm(budget_av));
+		if (budget_av->budget.dvb_frontend != NULL) {
+			break;
+		}
+		break;
+
+	case 0x0030:		// KNC1 DVB-T budget (tda10046/Philips TU1216(tda6651tt))
+		budget_av->budget.dvb_frontend =
+			tda10046_attach(&philips_tu1216_config, &budget_av->budget.i2c_adap);
+		if (budget_av->budget.dvb_frontend != NULL) {
+			break;
+		}
+		break;
+
+	case 0x1154:		// TerraTec Cinergy 1200 DVB-S (stv0299/Philips SU1278(tsa5059))
+		budget_av->budget.dvb_frontend =
+			stv0299_attach(&cinergy_1200s_config, &budget_av->budget.i2c_adap);
+		if (budget_av->budget.dvb_frontend != NULL) {
+			break;
+		}
+		break;
+
+	case 0x1156:		// Terratec Cinergy 1200 DVB-C (tda10021/Philips CU1216(tua6034))
+		budget_av->budget.dvb_frontend =
+			tda10021_attach(&philips_cu1216_config,
+					&budget_av->budget.i2c_adap, read_pwm(budget_av));
+		if (budget_av->budget.dvb_frontend) {
+			break;
+		}
+		break;
+
+	case 0x1157:		// Terratec Cinergy 1200 DVB-T (tda10046/Philips TU1216(tda6651tt))
+		budget_av->budget.dvb_frontend =
+			tda10046_attach(&philips_tu1216_config, &budget_av->budget.i2c_adap);
+		if (budget_av->budget.dvb_frontend) {
+			break;
+		}
+		break;
+	}
+
+	if (budget_av->budget.dvb_frontend == NULL) {
+		printk("budget_av: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
+		       budget_av->budget.dev->pci->vendor,
+		       budget_av->budget.dev->pci->device,
+		       budget_av->budget.dev->pci->subsystem_vendor,
+		       budget_av->budget.dev->pci->subsystem_device);
+	} else {
+		if (dvb_register_frontend
+		    (budget_av->budget.dvb_adapter, budget_av->budget.dvb_frontend)) {
+			printk("budget-av: Frontend registration failed!\n");
+			if (budget_av->budget.dvb_frontend->ops->release)
+				budget_av->budget.dvb_frontend->ops->release(budget_av->budget.dvb_frontend);
+			budget_av->budget.dvb_frontend = NULL;
+		}
+	}
+}
+
+
+static void budget_av_irq(struct saa7146_dev *dev, u32 * isr)
+{
+	struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
+
+	dprintk(8, "dev: %p, budget_av: %p\n", dev, budget_av);
+
+	if (*isr & MASK_10)
+		ttpci_budget_irq10_handler(dev, isr);
+}
+
 static int budget_av_detach (struct saa7146_dev *dev)
 {
 	struct budget_av *budget_av = (struct budget_av*) dev->ext_priv;
 	int err;
 
-	DEB_EE(("dev: %p\n",dev));
+	dprintk(2, "dev: %p\n", dev);
 
 	if ( 1 == budget_av->has_saa7113 ) {
 	saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
 
-	dvb_delay(200);
+		msleep(200);
 
 	saa7146_unregister_device (&budget_av->vd, dev);
 	}
 
+	if (budget_av->budget.ci_present)
+		ciintf_deinit(budget_av);
+
+	if (budget_av->budget.dvb_frontend != NULL)
+		dvb_unregister_frontend(budget_av->budget.dvb_frontend);
 	err = ttpci_budget_deinit (&budget_av->budget);
 
 	kfree (budget_av);
@@ -191,41 +802,35 @@
 
 static struct saa7146_ext_vv vv_data;
 
-static int budget_av_attach (struct saa7146_dev* dev,
-		      struct saa7146_pci_extension_data *info)
+static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
 {
 	struct budget_av *budget_av;
-	struct budget_info *bi = info->ext_priv;
 	u8 *mac;
 	int err;
 
-	DEB_EE(("dev: %p\n",dev));
-
-	if (bi->type != BUDGET_KNC1) {
-		return -ENODEV;
-	}
+	dprintk(2, "dev: %p\n", dev);
 
 	if (!(budget_av = kmalloc(sizeof(struct budget_av), GFP_KERNEL)))
 		return -ENOMEM;
 
 	memset(budget_av, 0, sizeof(struct budget_av));
 
-	if ((err = ttpci_budget_init(&budget_av->budget, dev, info))) {
+	budget_av->budget.ci_present = 0;
+
+	dev->ext_priv = budget_av;
+
+	if ((err = ttpci_budget_init(&budget_av->budget, dev, info, THIS_MODULE))) {
 		kfree(budget_av);
 		return err;
 	}
 
-	dev->ext_priv = budget_av;
-
 	/* knc1 initialization */
 	saa7146_write(dev, DD1_STREAM_B, 0x04000000);
 	saa7146_write(dev, DD1_INIT, 0x07000600);
 	saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26);
 
-	//test_knc_ci(av7110);
-
 	saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTHI);
-	dvb_delay(500);
+	msleep(500);
 
 	if ( 0 == saa7113_init(budget_av) ) {
 		budget_av->has_saa7113 = 1;
@@ -236,9 +841,7 @@
 		return err;
 	}
 
-	if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1",
-					   VFL_TYPE_GRABBER)))
-	{
+		if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) {
 		/* fixme: proper cleanup here */
 		ERR(("cannot register capture v4l2 device.\n"));
 		return err;
@@ -259,19 +862,24 @@
 	saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
 
 	mac = budget_av->budget.dvb_adapter->proposed_mac;
-	if (i2c_readregs(budget_av->budget.i2c_bus, 0xa0, 0x30, mac, 6)) {
+	if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
 		printk("KNC1-%d: Could not read MAC from KNC1 card\n",
 				budget_av->budget.dvb_adapter->num);
 		memset(mac, 0, 6);
-	}
-	else
+	} else {
 		printk("KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
 				budget_av->budget.dvb_adapter->num,
 				mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-	return 0;
 }
 
+	budget_av->budget.dvb_adapter->priv = budget_av;
+	frontend_init(budget_av);
+
+	if (enable_ci)
+		ciintf_init(budget_av);
 
+	return 0;
+}
 
 #define KNC1_INPUTS 2
 static struct v4l2_input knc1_inputs[KNC1_INPUTS] = {
@@ -292,57 +900,47 @@
 {
 	struct saa7146_dev *dev = fh->dev;
 	struct budget_av *budget_av = (struct budget_av*) dev->ext_priv;
-/*
-	struct saa7146_vv *vv = dev->vv_data; 
-*/	
+
 	switch(cmd) {
-	case VIDIOC_ENUMINPUT:
-	{
+	case VIDIOC_ENUMINPUT:{
 		struct v4l2_input *i = arg;
 		
-		DEB_EE(("VIDIOC_ENUMINPUT %d.\n",i->index));
+		dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index);
 		if( i->index < 0 || i->index >= KNC1_INPUTS) {
 			return -EINVAL;
 		}
 		memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input));
 		return 0;
 	}
-	case VIDIOC_G_INPUT:
-	{
+	case VIDIOC_G_INPUT:{
 		int *input = (int *)arg;
 
 		*input = budget_av->cur_input;
 
-		DEB_EE(("VIDIOC_G_INPUT %d.\n",*input));
+		dprintk(1, "VIDIOC_G_INPUT %d.\n", *input);
 		return 0;		
 	}	
-	case VIDIOC_S_INPUT:
-	{
+	case VIDIOC_S_INPUT:{
 		int input = *(int *)arg;
-		DEB_EE(("VIDIOC_S_INPUT %d.\n", input));
+		dprintk(1, "VIDIOC_S_INPUT %d.\n", input);
 		return saa7113_setinput (budget_av, input);
 	}
 	default:
-/*
-		DEB2(printk("does not handle this ioctl.\n"));
-*/
 		return -ENOIOCTLCMD;
 	}
 	return 0;
 }
 
 static struct saa7146_standard standard[] = {
-	{
-		.name	= "PAL", 	.id	= V4L2_STD_PAL,
+	{.name = "PAL",.id = V4L2_STD_PAL,
 		.v_offset	= 0x17,	.v_field 	= 288,
 		.h_offset	= 0x14,	.h_pixels 	= 680,  	      
-		.v_max_out	= 576,	.h_max_out	= 768
-	}, {
-		.name	= "NTSC", 	.id	= V4L2_STD_NTSC,
+	 .v_max_out = 576,.h_max_out = 768 },
+
+	{.name = "NTSC",.id = V4L2_STD_NTSC,
 		.v_offset	= 0x16,	.v_field 	= 240,
 		.h_offset	= 0x06,	.h_pixels 	= 708,
-		.v_max_out	= 480,	.h_max_out	= 640,
-	}
+	 .v_max_out = 480,.h_max_out = 640, },
 };
 
 static struct saa7146_ext_vv vv_data = {
@@ -355,15 +953,22 @@
 	.ioctl		= av_ioctl,
 };
 
-
-
 static struct saa7146_extension budget_extension;
 
-
-MAKE_BUDGET_INFO(knc1, "KNC1 DVB-S", BUDGET_KNC1);
+MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
+MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
+MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
+MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
+MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
+MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
 
 static struct pci_device_id pci_tbl [] = {
-	MAKE_EXTENSION_PCI(knc1, 0x1131, 0x4f56),
+	MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
+	MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
+	MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
+	MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
+	MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
+	MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
 	{
 		.vendor    = 0,
 	}
@@ -380,24 +985,16 @@
 	.detach		= budget_av_detach,
 
 	.irq_mask	= MASK_10,
-	.irq_func	= ttpci_budget_irq10_handler,
+	.irq_func = budget_av_irq,
 };	
 
-
 static int __init budget_av_init(void) 
 {
-	DEB_EE((".\n"));
-
-	if (saa7146_register_extension(&budget_extension))
-		return -ENODEV;
-	
-	return 0;
+	return saa7146_register_extension(&budget_extension);
 }
 
-
 static void __exit budget_av_exit(void)
 {
-	DEB_EE((".\n"));
 	saa7146_unregister_extension(&budget_extension); 
 }
 
@@ -407,5 +1004,6 @@
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
 MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
-		   "budget PCI DVB w/ analog input (e.g. the KNC cards)");
-
+		   "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");
+module_param_named(enable_ci, enable_ci, int, 0644);
+MODULE_PARM_DESC(enable_ci, "Turn on/off CI module (default:off).");
diff -Nru a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
--- a/drivers/media/dvb/ttpci/budget-ci.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/dvb/ttpci/budget-ci.c	2004-12-24 13:36:18 -08:00
@@ -38,12 +38,9 @@
 #include <linux/input.h>
 #include <linux/spinlock.h>
 
-#include "dvb_functions.h"
 #include "dvb_ca_en50221.h"
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-#include "input_fake.h"
-#endif
+#include "stv0299.h"
+#include "tda1004x.h"
 
 #define DEBIADDR_IR		0x1234
 #define DEBIADDR_CICONTROL	0x0000
@@ -69,70 +66,11 @@
 	struct input_dev input_dev;
 	struct tasklet_struct msp430_irq_tasklet;
 	struct tasklet_struct ciintf_irq_tasklet;
-	spinlock_t debilock;
 	int slot_status;
 	struct dvb_ca_en50221 ca;
 	char ir_dev_name[50];
 };
 
-static u32 budget_debiread (struct budget_ci* budget_ci, u32 config, int addr, int count)
-{
-	struct saa7146_dev *saa = budget_ci->budget.dev;
-	u32 result = 0;
-
-	if (count > 4 || count <= 0)
-		return 0;
-
-	spin_lock(&budget_ci->debilock);
-
-	if (saa7146_wait_for_debi_done(saa) < 0) {
-		spin_unlock(&budget_ci->debilock);
-		return 0;
-	}
-
-	saa7146_write (saa, DEBI_COMMAND,
-		       (count << 17) | 0x10000 | (addr & 0xffff));
-	saa7146_write(saa, DEBI_CONFIG, config);
-	saa7146_write(saa, DEBI_PAGE, 0);
-	saa7146_write(saa, MC2, (2 << 16) | 2);
-
-	saa7146_wait_for_debi_done(saa);
-
-	result = saa7146_read(saa, 0x88);
-	result &= (0xffffffffUL >> ((4 - count) * 8));
-
-	spin_unlock(&budget_ci->debilock);
-	return result;
-}
-
-static u8 budget_debiwrite (struct budget_ci* budget_ci, u32 config, int addr, int count, u32 value)
-{
-	struct saa7146_dev *saa = budget_ci->budget.dev;
-
-	if (count > 4 || count <= 0)
-		return 0;
-
-	spin_lock(&budget_ci->debilock);
-
-	if (saa7146_wait_for_debi_done(saa) < 0) {
-		spin_unlock(&budget_ci->debilock);
-		return 0;
-	}
-
-	saa7146_write (saa, DEBI_COMMAND,
-		       (count << 17) | 0x00000 | (addr & 0xffff));
-	saa7146_write(saa, DEBI_CONFIG, config);
-	saa7146_write(saa, DEBI_PAGE, 0);
-	saa7146_write(saa, DEBI_AD, value);
-	saa7146_write(saa, MC2, (2 << 16) | 2);
-
-	saa7146_wait_for_debi_done(saa);
-
-	spin_unlock(&budget_ci->debilock);
-	return 0;
-}
-
-
 /* from reading the following remotes:
    Zenith Universal 7 / TV Mode 807 / VCR Mode 837
    Hauppauge (from NOVA-CI-s box product)
@@ -209,7 +147,8 @@
 {
 	struct budget_ci *budget_ci = (struct budget_ci*) data;
 	struct input_dev *dev = &budget_ci->input_dev;
-	unsigned int code = budget_debiread(budget_ci, DEBINOSWAP, DEBIADDR_IR, 2) >> 8;
+	unsigned int code =
+		ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
 
 	if (code & 0x40) {
 	        code &= 0x3f;
@@ -224,8 +163,7 @@
 		}
 
 		if (!key_map[code]) {
-        	        printk ("DVB (%s): no key for %02x!\n",
-				__FUNCTION__, code);
+			printk("DVB (%s): no key for %02x!\n", __FUNCTION__, code);
 		        return;
        		}
 
@@ -284,79 +222,98 @@
 	input_unregister_device(dev);
 }
 
-static int ciintf_read_attribute_mem(struct dvb_ca_en50221* ca, int slot, int address) {
+static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
+{
 	struct budget_ci* budget_ci = (struct budget_ci*) ca->data;
 
-	if (slot != 0) return -EINVAL;
+	if (slot != 0)
+		return -EINVAL;
 
-	return budget_debiread(budget_ci, DEBICICAM, DEBIADDR_ATTR | (address & 0xfff), 1);
+	return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM,
+				     DEBIADDR_ATTR | (address & 0xfff), 1, 1, 0);
 }
 
-static int ciintf_write_attribute_mem(struct dvb_ca_en50221* ca, int slot, int address, u8 value) {
+static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
+{
 	struct budget_ci* budget_ci = (struct budget_ci*) ca->data;
 
-	if (slot != 0) return -EINVAL;
+	if (slot != 0)
+		return -EINVAL;
 
-	return budget_debiwrite(budget_ci, DEBICICAM, DEBIADDR_ATTR | (address & 0xfff), 1, value);
+	return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM,
+				      DEBIADDR_ATTR | (address & 0xfff), 1, value, 1, 0);
 }
 
-static int ciintf_read_cam_control(struct dvb_ca_en50221* ca, int slot, u8 address) {
+static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
+{
 	struct budget_ci* budget_ci = (struct budget_ci*) ca->data;
 
-	if (slot != 0) return -EINVAL;
+	if (slot != 0)
+		return -EINVAL;
 
-	return budget_debiread(budget_ci, DEBICICAM, DEBIADDR_IO | (address & 3), 1);
+	return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM,
+				     DEBIADDR_IO | (address & 3), 1, 1, 0);
 }
 
-static int ciintf_write_cam_control(struct dvb_ca_en50221* ca, int slot, u8 address, u8 value) {
+static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
+{
 	struct budget_ci* budget_ci = (struct budget_ci*) ca->data;
 
-	if (slot != 0) return -EINVAL;
+	if (slot != 0)
+		return -EINVAL;
 
-	return budget_debiwrite(budget_ci, DEBICICAM, DEBIADDR_IO | (address & 3), 1, value);
+	return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM,
+				      DEBIADDR_IO | (address & 3), 1, value, 1, 0);
 }
 
-static int ciintf_slot_reset(struct dvb_ca_en50221* ca, int slot) {
+static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
+{
 	struct budget_ci* budget_ci = (struct budget_ci*) ca->data;
 	struct saa7146_dev *saa = budget_ci->budget.dev;
 
-	if (slot != 0) return -EINVAL;
+	if (slot != 0)
+		return -EINVAL;
 
 	// trigger on RISING edge during reset so we know when READY is re-asserted
 	saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
 	budget_ci->slot_status = SLOTSTATUS_RESET;
-	budget_debiwrite(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1, 0);
-	dvb_delay(1);
-	budget_debiwrite(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1, CICONTROL_RESET);
+	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
+	msleep(1);
+	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
+			       CICONTROL_RESET, 1, 0);
 
 	saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI);
    	ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
 	return 0;
 }
 
-static int ciintf_slot_shutdown(struct dvb_ca_en50221* ca, int slot) {
+static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
+{
    	struct budget_ci* budget_ci = (struct budget_ci*) ca->data;
 	struct saa7146_dev *saa = budget_ci->budget.dev;
 
-	if (slot != 0) return -EINVAL;
+	if (slot != 0)
+		return -EINVAL;
 
 	saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI);
 	ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
 	return 0;
 }
 
-static int ciintf_slot_ts_enable(struct dvb_ca_en50221* ca, int slot) {
+static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
+{
 	struct budget_ci* budget_ci = (struct budget_ci*) ca->data;
 	struct saa7146_dev *saa = budget_ci->budget.dev;
 	int tmp;
 
-	if (slot != 0) return -EINVAL;
-
+	if (slot != 0)
+		return -EINVAL;
 
 	saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
 
-	tmp = budget_debiread(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1);
-	budget_debiwrite(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1, tmp | CICONTROL_ENABLETS);
+	tmp = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
+	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
+			       tmp | CICONTROL_ENABLETS, 1, 0);
 
    	ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
 	return 0;
@@ -370,20 +327,21 @@
 	unsigned int flags;
 
 	// ensure we don't get spurious IRQs during initialisation
-	if (!budget_ci->budget.ci_present) return;
+	if (!budget_ci->budget.ci_present)
+		return;
 
-	flags = budget_debiread(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1);
+	// read the CAM status
+	flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
+	if (flags & CICONTROL_CAMDETECT) {
 
-	// always set the GPIO mode back to "normal", in case the card is
-	// yanked at an inopportune moment
+		// GPIO should be set to trigger on falling edge if a CAM is present
 	saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO);
 
-	if (flags & CICONTROL_CAMDETECT) {
-
 		if (budget_ci->slot_status & SLOTSTATUS_NONE) {
 			// CAM insertion IRQ
 			budget_ci->slot_status = SLOTSTATUS_PRESENT;
-			dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, DVB_CA_EN50221_CAMCHANGE_INSERTED);
+			dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0,
+						     DVB_CA_EN50221_CAMCHANGE_INSERTED);
 
 		} else if (budget_ci->slot_status & SLOTSTATUS_RESET) {
 			// CAM ready (reset completed)
@@ -395,9 +353,18 @@
 			dvb_ca_en50221_frda_irq(&budget_ci->ca, 0);
 		}
 	} else {
+
+		// trigger on rising edge if a CAM is not present - when a CAM is inserted, we
+		// only want to get the IRQ when it sets READY. If we trigger on the falling edge,
+		// the CAM might not actually be ready yet.
+		saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
+
+	   	// generate a CAM removal IRQ if we haven't already
 		if (budget_ci->slot_status & SLOTSTATUS_OCCUPIED) {
+			// CAM removal IRQ
 			budget_ci->slot_status = SLOTSTATUS_NONE;
-			dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, DVB_CA_EN50221_CAMCHANGE_REMOVED);
+			dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0,
+						     DVB_CA_EN50221_CAMCHANGE_REMOVED);
 		}
 	}
 }
@@ -414,18 +381,18 @@
 	saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
 
 	// test if it is there
-	if ((budget_debiread(budget_ci, DEBICICTL, DEBIADDR_CIVERSION, 1) & 0xa0) != 0xa0) {
+	if ((ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0) & 0xa0) != 0xa0) {
 		result = -ENODEV;
 		goto error;
 	}
-
 	// determine whether a CAM is present or not
-	flags = budget_debiread(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1);
+	flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
 	budget_ci->slot_status = SLOTSTATUS_NONE;
-	if (flags & CICONTROL_CAMDETECT) budget_ci->slot_status = SLOTSTATUS_PRESENT;
-
+	if (flags & CICONTROL_CAMDETECT)
+		budget_ci->slot_status = SLOTSTATUS_PRESENT;
 
 	// register CI interface
+	budget_ci->ca.owner = THIS_MODULE;
 	budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem;
 	budget_ci->ca.write_attribute_mem = ciintf_write_attribute_mem;
 	budget_ci->ca.read_cam_control = ciintf_read_cam_control;
@@ -438,17 +405,21 @@
 					  &budget_ci->ca,
 					  DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE |
 					  DVB_CA_EN50221_FLAG_IRQ_FR |
-					  DVB_CA_EN50221_FLAG_IRQ_DA,
-				  1)) != 0) {
+					  DVB_CA_EN50221_FLAG_IRQ_DA, 1)) != 0) {
 		printk("budget_ci: CI interface detected, but initialisation failed.\n");
 		goto error;
 	}
 
 	// Setup CI slot IRQ
 	tasklet_init (&budget_ci->ciintf_irq_tasklet, ciintf_interrupt, (unsigned long) budget_ci);
+	if (budget_ci->slot_status != SLOTSTATUS_NONE) {
 	saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO);
+	} else {
+		saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
+	}
 	saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_03);
-	budget_debiwrite(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1, CICONTROL_RESET);
+	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
+			       CICONTROL_RESET, 1, 0);
 
 	// success!
 	printk("budget_ci: CI interface initialised\n");
@@ -456,7 +427,8 @@
 
 	// forge a fake CI IRQ so the CAM state is setup correctly
 	flags = DVB_CA_EN50221_CAMCHANGE_REMOVED;
-	if (budget_ci->slot_status != SLOTSTATUS_NONE) flags = DVB_CA_EN50221_CAMCHANGE_INSERTED;
+	if (budget_ci->slot_status != SLOTSTATUS_NONE)
+		flags = DVB_CA_EN50221_CAMCHANGE_INSERTED;
 	dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, flags);
 
 	return 0;
@@ -474,9 +446,10 @@
 	saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_03);
 	saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
 	tasklet_kill(&budget_ci->ciintf_irq_tasklet);
-	budget_debiwrite(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1, 0);
-	dvb_delay(1);
-	budget_debiwrite(budget_ci, DEBICICTL, DEBIADDR_CICONTROL, 1, CICONTROL_RESET);
+	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
+	msleep(1);
+	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
+			       CICONTROL_RESET, 1, 0);
 
 	// disable TS data stream to CI interface
 	saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
@@ -492,7 +465,7 @@
 {
         struct budget_ci *budget_ci = (struct budget_ci*) dev->ext_priv;
 
-        DEB_EE(("dev: %p, budget_ci: %p\n", dev, budget_ci));
+	dprintk(8, "dev: %p, budget_ci: %p\n", dev, budget_ci);
 
         if (*isr & MASK_06)
                 tasklet_schedule (&budget_ci->msp430_irq_tasklet);
@@ -505,9 +478,426 @@
 }
 
 
+static u8 alps_bsru6_inittab[] = {
+	0x01, 0x15,
+	0x02, 0x00,
+	0x03, 0x00,
+	0x04, 0x7d,		/* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
+	0x05, 0x35,		/* I2CT = 0, SCLT = 1, SDAT = 1 */
+	0x06, 0x40,		/* DAC not used, set to high impendance mode */
+	0x07, 0x00,		/* DAC LSB */
+	0x08, 0x40,		/* DiSEqC off, LNB power on OP2/LOCK pin on */
+	0x09, 0x00,		/* FIFO */
+	0x0c, 0x51,		/* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
+	0x0d, 0x82,		/* DC offset compensation = ON, beta_agc1 = 2 */
+	0x0e, 0x23,		/* alpha_tmg = 2, beta_tmg = 3 */
+	0x10, 0x3f,		// AGC2  0x3d
+	0x11, 0x84,
+	0x12, 0xb5,		// Lock detect: -64  Carrier freq detect:on
+	0x15, 0xc9,		// lock detector threshold
+	0x16, 0x00,
+	0x17, 0x00,
+	0x18, 0x00,
+	0x19, 0x00,
+	0x1a, 0x00,
+	0x1f, 0x50,
+	0x20, 0x00,
+	0x21, 0x00,
+	0x22, 0x00,
+	0x23, 0x00,
+	0x28, 0x00,		// out imp: normal  out type: parallel FEC mode:0
+	0x29, 0x1e,		// 1/2 threshold
+	0x2a, 0x14,		// 2/3 threshold
+	0x2b, 0x0f,		// 3/4 threshold
+	0x2c, 0x09,		// 5/6 threshold
+	0x2d, 0x05,		// 7/8 threshold
+	0x2e, 0x01,
+	0x31, 0x1f,		// test all FECs
+	0x32, 0x19,		// viterbi and synchro search
+	0x33, 0xfc,		// rs control
+	0x34, 0x93,		// error control
+	0x0f, 0x52,
+	0xff, 0xff
+};
+
+static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
+{
+	u8 aclk = 0;
+	u8 bclk = 0;
+
+	if (srate < 1500000) {
+		aclk = 0xb7;
+		bclk = 0x47;
+	} else if (srate < 3000000) {
+		aclk = 0xb7;
+		bclk = 0x4b;
+	} else if (srate < 7000000) {
+		aclk = 0xb7;
+		bclk = 0x4f;
+	} else if (srate < 14000000) {
+		aclk = 0xb7;
+		bclk = 0x53;
+	} else if (srate < 30000000) {
+		aclk = 0xb6;
+		bclk = 0x53;
+	} else if (srate < 45000000) {
+		aclk = 0xb4;
+		bclk = 0x51;
+	}
+
+	stv0299_writereg(fe, 0x13, aclk);
+	stv0299_writereg(fe, 0x14, bclk);
+	stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
+	stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
+
+	return 0;
+}
 
-static int budget_ci_attach (struct saa7146_dev* dev,
-		      struct saa7146_pci_extension_data *info)
+static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+	struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
+	u8 buf[4];
+	u32 div;
+	struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
+
+	if ((params->frequency < 950000) || (params->frequency > 2150000))
+		return -EINVAL;
+
+	div = (params->frequency + (125 - 1)) / 125;	// round correctly
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
+	buf[3] = 0xC4;
+
+	if (params->frequency > 1530000)
+		buf[3] = 0xc0;
+
+	if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static struct stv0299_config alps_bsru6_config = {
+
+	.demod_address = 0x68,
+	.inittab = alps_bsru6_inittab,
+	.mclk = 88000000UL,
+	.invert = 1,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_1,
+	.volt13_op0_op1 = STV0299_VOLT13_OP1,
+	.min_delay_ms = 100,
+	.set_symbol_rate = alps_bsru6_set_symbol_rate,
+	.pll_set = alps_bsru6_pll_set,
+};
+
+
+
+
+static u8 philips_su1278_tt_inittab[] = {
+	0x01, 0x0f,
+	0x02, 0x30,
+	0x03, 0x00,
+	0x04, 0x5b,
+	0x05, 0x85,
+	0x06, 0x02,
+	0x07, 0x00,
+	0x08, 0x02,
+	0x09, 0x00,
+	0x0C, 0x01,
+	0x0D, 0x81,
+	0x0E, 0x44,
+	0x0f, 0x14,
+	0x10, 0x3c,
+	0x11, 0x84,
+	0x12, 0xda,
+	0x13, 0x97,
+	0x14, 0x95,
+	0x15, 0xc9,
+	0x16, 0x19,
+	0x17, 0x8c,
+	0x18, 0x59,
+	0x19, 0xf8,
+	0x1a, 0xfe,
+	0x1c, 0x7f,
+	0x1d, 0x00,
+	0x1e, 0x00,
+	0x1f, 0x50,
+	0x20, 0x00,
+	0x21, 0x00,
+	0x22, 0x00,
+	0x23, 0x00,
+	0x28, 0x00,
+	0x29, 0x28,
+	0x2a, 0x14,
+	0x2b, 0x0f,
+	0x2c, 0x09,
+	0x2d, 0x09,
+	0x31, 0x1f,
+	0x32, 0x19,
+	0x33, 0xfc,
+	0x34, 0x93,
+	0xff, 0xff
+};
+
+static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
+{
+	stv0299_writereg(fe, 0x0e, 0x44);
+	if (srate >= 10000000) {
+		stv0299_writereg(fe, 0x13, 0x97);
+		stv0299_writereg(fe, 0x14, 0x95);
+		stv0299_writereg(fe, 0x15, 0xc9);
+		stv0299_writereg(fe, 0x17, 0x8c);
+		stv0299_writereg(fe, 0x1a, 0xfe);
+		stv0299_writereg(fe, 0x1c, 0x7f);
+		stv0299_writereg(fe, 0x2d, 0x09);
+	} else {
+		stv0299_writereg(fe, 0x13, 0x99);
+		stv0299_writereg(fe, 0x14, 0x8d);
+		stv0299_writereg(fe, 0x15, 0xce);
+		stv0299_writereg(fe, 0x17, 0x43);
+		stv0299_writereg(fe, 0x1a, 0x1d);
+		stv0299_writereg(fe, 0x1c, 0x12);
+		stv0299_writereg(fe, 0x2d, 0x05);
+	}
+	stv0299_writereg(fe, 0x0e, 0x23);
+	stv0299_writereg(fe, 0x0f, 0x94);
+	stv0299_writereg(fe, 0x10, 0x39);
+	stv0299_writereg(fe, 0x15, 0xc9);
+
+	stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
+	stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
+
+	return 0;
+}
+
+static int philips_su1278_tt_pll_set(struct dvb_frontend *fe,
+				     struct dvb_frontend_parameters *params)
+{
+	struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
+	u32 div;
+	u8 buf[4];
+	struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
+
+	if ((params->frequency < 950000) || (params->frequency > 2150000))
+		return -EINVAL;
+
+	div = (params->frequency + (500 - 1)) / 500;	// round correctly
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x80 | ((div & 0x18000) >> 10) | 2;
+	buf[3] = 0x20;
+
+	if (params->u.qpsk.symbol_rate < 4000000)
+		buf[3] |= 1;
+
+	if (params->frequency < 1250000)
+		buf[3] |= 0;
+	else if (params->frequency < 1550000)
+		buf[3] |= 0x40;
+	else if (params->frequency < 2050000)
+		buf[3] |= 0x80;
+	else if (params->frequency < 2150000)
+		buf[3] |= 0xC0;
+
+	if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1)
+		return -EIO;
+	return 0;
+}
+
+static struct stv0299_config philips_su1278_tt_config = {
+
+	.demod_address = 0x68,
+	.inittab = philips_su1278_tt_inittab,
+	.mclk = 64000000UL,
+	.invert = 0,
+	.enhanced_tuning = 1,
+	.skip_reinit = 1,
+	.lock_output = STV0229_LOCKOUTPUT_1,
+	.volt13_op0_op1 = STV0299_VOLT13_OP1,
+	.min_delay_ms = 50,
+	.set_symbol_rate = philips_su1278_tt_set_symbol_rate,
+	.pll_set = philips_su1278_tt_pll_set,
+};
+
+
+
+static int philips_tdm1316l_pll_init(struct dvb_frontend *fe)
+{
+	struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
+	static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab };
+	static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
+	struct i2c_msg tuner_msg = {.addr = 0x63,.flags = 0,.buf = td1316_init,.len =
+			sizeof(td1316_init) };
+
+	// setup PLL configuration
+	if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
+		return -EIO;
+	msleep(1);
+
+	// disable the mc44BC374c (do not check for errors)
+	tuner_msg.addr = 0x65;
+	tuner_msg.buf = disable_mc44BC374c;
+	tuner_msg.len = sizeof(disable_mc44BC374c);
+	if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) {
+		i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1);
+	}
+
+	return 0;
+}
+
+static int philips_tdm1316l_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+	struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
+	u8 tuner_buf[4];
+	struct i2c_msg tuner_msg = {.addr = 0x63,.flags = 0,.buf = tuner_buf,.len = sizeof(tuner_buf) };
+	int tuner_frequency = 0;
+	u8 band, cp, filter;
+
+	// determine charge pump
+	tuner_frequency = params->frequency + 36130000;
+	if (tuner_frequency < 87000000)
+		return -EINVAL;
+	else if (tuner_frequency < 130000000)
+		cp = 3;
+	else if (tuner_frequency < 160000000)
+		cp = 5;
+	else if (tuner_frequency < 200000000)
+		cp = 6;
+	else if (tuner_frequency < 290000000)
+		cp = 3;
+	else if (tuner_frequency < 420000000)
+		cp = 5;
+	else if (tuner_frequency < 480000000)
+		cp = 6;
+	else if (tuner_frequency < 620000000)
+		cp = 3;
+	else if (tuner_frequency < 830000000)
+		cp = 5;
+	else if (tuner_frequency < 895000000)
+		cp = 7;
+	else
+		return -EINVAL;
+
+	// determine band
+	if (params->frequency < 49000000)
+		return -EINVAL;
+	else if (params->frequency < 159000000)
+		band = 1;
+	else if (params->frequency < 444000000)
+		band = 2;
+	else if (params->frequency < 861000000)
+		band = 4;
+	else
+		return -EINVAL;
+
+	// setup PLL filter and TDA9889
+	switch (params->u.ofdm.bandwidth) {
+	case BANDWIDTH_6_MHZ:
+		tda1004x_write_byte(fe, 0x0C, 0x14);
+		filter = 0;
+		break;
+
+	case BANDWIDTH_7_MHZ:
+		tda1004x_write_byte(fe, 0x0C, 0x80);
+		filter = 0;
+		break;
+
+	case BANDWIDTH_8_MHZ:
+		tda1004x_write_byte(fe, 0x0C, 0x14);
+		filter = 1;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	// calculate divisor
+	// ((36130000+((1000000/6)/2)) + Finput)/(1000000/6)
+	tuner_frequency = (((params->frequency / 1000) * 6) + 217280) / 1000;
+
+	// setup tuner buffer
+	tuner_buf[0] = tuner_frequency >> 8;
+	tuner_buf[1] = tuner_frequency & 0xff;
+	tuner_buf[2] = 0xca;
+	tuner_buf[3] = (cp << 5) | (filter << 3) | band;
+
+	if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
+		return -EIO;
+
+	msleep(1);
+	return 0;
+}
+
+static int philips_tdm1316l_request_firmware(struct dvb_frontend *fe,
+					     const struct firmware **fw, char *name)
+{
+	struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
+
+	return request_firmware(fw, name, &budget_ci->budget.dev->pci->dev);
+}
+
+static struct tda1004x_config philips_tdm1316l_config = {
+
+	.demod_address = 0x8,
+	.invert = 0,
+	.invert_oclk = 0,
+	.pll_init = philips_tdm1316l_pll_init,
+	.pll_set = philips_tdm1316l_pll_set,
+	.request_firmware = philips_tdm1316l_request_firmware,
+};
+
+
+
+static void frontend_init(struct budget_ci *budget_ci)
+{
+	switch (budget_ci->budget.dev->pci->subsystem_device) {
+	case 0x100c:		// Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059))
+		budget_ci->budget.dvb_frontend =
+			stv0299_attach(&alps_bsru6_config, &budget_ci->budget.i2c_adap);
+		if (budget_ci->budget.dvb_frontend) {
+			break;
+		}
+		break;
+
+	case 0x100f:		// Hauppauge/TT Nova-CI budget (stv0299b/Philips su1278(tsa5059))
+		budget_ci->budget.dvb_frontend =
+			stv0299_attach(&philips_su1278_tt_config, &budget_ci->budget.i2c_adap);
+		if (budget_ci->budget.dvb_frontend) {
+			break;
+		}
+		break;
+
+	case 0x1011:		// Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
+		budget_ci->budget.dvb_frontend =
+			tda10045_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
+		if (budget_ci->budget.dvb_frontend) {
+			break;
+		}
+		break;
+	}
+
+	if (budget_ci->budget.dvb_frontend == NULL) {
+		printk("budget-ci: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
+		       budget_ci->budget.dev->pci->vendor,
+		       budget_ci->budget.dev->pci->device,
+		       budget_ci->budget.dev->pci->subsystem_vendor,
+		       budget_ci->budget.dev->pci->subsystem_device);
+	} else {
+		if (dvb_register_frontend
+		    (budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) {
+			printk("budget-ci: Frontend registration failed!\n");
+			if (budget_ci->budget.dvb_frontend->ops->release)
+				budget_ci->budget.dvb_frontend->ops->release(budget_ci->budget.dvb_frontend);
+			budget_ci->budget.dvb_frontend = NULL;
+		}
+	}
+}
+
+static int budget_ci_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
 {
 	struct budget_ci *budget_ci;
 	int err;
@@ -515,25 +905,26 @@
 	if (!(budget_ci = kmalloc (sizeof(struct budget_ci), GFP_KERNEL)))
 		return -ENOMEM;
 
-	DEB_EE(("budget_ci: %p\n", budget_ci));
+	dprintk(2, "budget_ci: %p\n", budget_ci);
 
-	spin_lock_init(&budget_ci->debilock);
 	budget_ci->budget.ci_present = 0;
 
-	if ((err = ttpci_budget_init (&budget_ci->budget, dev, info))) {
+	dev->ext_priv = budget_ci;
+
+	if ((err = ttpci_budget_init(&budget_ci->budget, dev, info, THIS_MODULE))) {
 		kfree (budget_ci);
 		return err;
 	}
 
-	dev->ext_priv = budget_ci;
-
 	tasklet_init (&budget_ci->msp430_irq_tasklet, msp430_ir_interrupt,
 		      (unsigned long) budget_ci);
 
 	msp430_ir_init (budget_ci);
 
-	// UNCOMMENT TO TEST CI INTERFACE
-//	ciintf_init(budget_ci);
+	ciintf_init(budget_ci);
+
+	budget_ci->budget.dvb_adapter->priv = budget_ci;
+	frontend_init(budget_ci);
 
 	return 0;
 }
@@ -546,8 +937,10 @@
 	struct saa7146_dev *saa = budget_ci->budget.dev;
 	int err;
 
-	if (budget_ci->budget.ci_present) ciintf_deinit(budget_ci);
-
+	if (budget_ci->budget.ci_present)
+		ciintf_deinit(budget_ci);
+	if (budget_ci->budget.dvb_frontend)
+		dvb_unregister_frontend(budget_ci->budget.dvb_frontend);
 	err = ttpci_budget_deinit (&budget_ci->budget);
 
 	tasklet_kill (&budget_ci->msp430_irq_tasklet);
@@ -599,10 +992,8 @@
 	return saa7146_register_extension(&budget_extension);
 }
 
-
 static void __exit budget_ci_exit(void)
 {
-	DEB_EE((".\n"));
 	saa7146_unregister_extension(&budget_extension); 
 }
 
diff -Nru a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c
--- a/drivers/media/dvb/ttpci/budget-core.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/media/dvb/ttpci/budget-core.c	2004-12-24 13:36:34 -08:00
@@ -34,10 +34,15 @@
  * the project's page is at http://www.linuxtv.org/dvb/
  */
 
+#include <linux/moduleparam.h>
+
 #include "budget.h"
 #include "ttpci-eeprom.h"
 
-int budget_debug = 0;
+int budget_debug;
+
+module_param_named(debug, budget_debug, int, 0644);
+MODULE_PARM_DESC(budget_debug, "Turn on/off budget debugging (default:off).");
 
 /****************************************************************************
  * TT budget / WinTV Nova
@@ -45,13 +50,13 @@
 
 static int stop_ts_capture(struct budget *budget)
 {
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
         if (--budget->feeding)
                 return budget->feeding;
 
         saa7146_write(budget->dev, MC1, MASK_20); // DMA3 off
-	IER_DISABLE(budget->dev, MASK_10);
+	SAA7146_IER_DISABLE(budget->dev, MASK_10);
         return 0;
 }
 
@@ -60,7 +65,7 @@
 {
         struct saa7146_dev *dev=budget->dev;
 
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
         if (budget->feeding) 
                 return ++budget->feeding;
@@ -69,8 +74,7 @@
 
         memset(budget->grabbing, 0x00, TS_HEIGHT*TS_WIDTH);
 
-        saa7146_write(dev, PCI_BT_V1, 0x001c0000 |
-            (saa7146_read(dev, PCI_BT_V1) & ~0x001f0000));
+	saa7146_write(dev, PCI_BT_V1, 0x001c0000 | (saa7146_read(dev, PCI_BT_V1) & ~0x001f0000));
 
         budget->tsf=0xff;
         budget->ttbp=0;
@@ -120,7 +124,7 @@
       	saa7146_write(dev, MC2, (MASK_04 | MASK_20));
      	saa7146_write(dev, MC1, (MASK_04 | MASK_20)); // DMA3 on
 
-	IER_ENABLE(budget->dev, MASK_10); // VPE
+	SAA7146_IER_ENABLE(budget->dev, MASK_10);	// VPE
 
         return ++budget->feeding;
 }
@@ -145,14 +149,87 @@
 		return;
 
         if (newdma > olddma) { /* no wraparound, dump olddma..newdma */
-                        dvb_dmx_swfilter_packets(&budget->demux, 
-        	                mem+olddma, (newdma-olddma) / 188);
+		dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, (newdma - olddma) / 188);
         } else { /* wraparound, dump olddma..buflen and 0..newdma */
-	                dvb_dmx_swfilter_packets(&budget->demux,
-        	                mem+olddma, (TS_BUFLEN-olddma) / 188);
-                        dvb_dmx_swfilter_packets(&budget->demux,
-                                mem, newdma / 188);
+		dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, (TS_BUFLEN - olddma) / 188);
+		dvb_dmx_swfilter_packets(&budget->demux, mem, newdma / 188);
+	}
         }
+
+
+int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count,
+			  int uselocks, int nobusyloop)
+{
+	struct saa7146_dev *saa = budget->dev;
+	int result = 0;
+	unsigned long flags = 0;
+
+	if (count > 4 || count <= 0)
+		return 0;
+
+	if (uselocks)
+		spin_lock_irqsave(&budget->debilock, flags);
+
+	if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) {
+		if (uselocks)
+			spin_unlock_irqrestore(&budget->debilock, flags);
+		return result;
+	}
+
+	saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff));
+	saa7146_write(saa, DEBI_CONFIG, config);
+	saa7146_write(saa, DEBI_PAGE, 0);
+	saa7146_write(saa, MC2, (2 << 16) | 2);
+
+	if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) {
+		if (uselocks)
+			spin_unlock_irqrestore(&budget->debilock, flags);
+		return result;
+	}
+
+	result = saa7146_read(saa, DEBI_AD);
+	result &= (0xffffffffUL >> ((4 - count) * 8));
+
+	if (uselocks)
+		spin_unlock_irqrestore(&budget->debilock, flags);
+
+	return result;
+}
+
+int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr,
+			   int count, u32 value, int uselocks, int nobusyloop)
+{
+	struct saa7146_dev *saa = budget->dev;
+	unsigned long flags = 0;
+	int result;
+
+	if (count > 4 || count <= 0)
+		return 0;
+
+	if (uselocks)
+		spin_lock_irqsave(&budget->debilock, flags);
+
+	if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) {
+		if (uselocks)
+			spin_unlock_irqrestore(&budget->debilock, flags);
+		return result;
+	}
+
+	saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x00000 | (addr & 0xffff));
+	saa7146_write(saa, DEBI_CONFIG, config);
+	saa7146_write(saa, DEBI_PAGE, 0);
+	saa7146_write(saa, DEBI_AD, value);
+	saa7146_write(saa, MC2, (2 << 16) | 2);
+
+	if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) {
+		if (uselocks)
+			spin_unlock_irqrestore(&budget->debilock, flags);
+		return result;
+	}
+
+	if (uselocks)
+		spin_unlock_irqrestore(&budget->debilock, flags);
+	return 0;
 }
 
 
@@ -166,7 +243,7 @@
         struct budget *budget = (struct budget*) demux->priv;
 	int status;
 
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
         if (!demux->dmx.frontend)
                 return -EINVAL;
@@ -183,7 +260,7 @@
         struct budget *budget = (struct budget *) demux->priv;
 	int status;
 
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
    	spin_lock(&budget->feedlock);
 	status = stop_ts_capture (budget);
@@ -197,7 +274,7 @@
         struct dvb_demux *dvbdemux=&budget->demux;
         int ret;
 
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
         dvbdemux->priv = (void *) budget;
 
@@ -226,13 +303,11 @@
                 return ret;
         
         budget->mem_frontend.source = DMX_MEMORY_FE;
-        ret=dvbdemux->dmx.add_frontend (&dvbdemux->dmx, 
-                                        &budget->mem_frontend);
+	ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->mem_frontend);
         if (ret<0)
                 return ret;
         
-        ret=dvbdemux->dmx.connect_frontend (&dvbdemux->dmx, 
-                                            &budget->hw_frontend);
+	ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &budget->hw_frontend);
         if (ret < 0)
                 return ret;
 
@@ -246,7 +321,7 @@
 {
         struct dvb_demux *dvbdemux=&budget->demux;
 
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
 	dvb_net_release(&budget->dvb_net);
 
@@ -258,17 +333,9 @@
         dvb_dmx_release(&budget->demux);
 }
 
-
-static int master_xfer (struct dvb_i2c_bus *i2c, const struct i2c_msg msgs[], int num)
-{
-	struct saa7146_dev *dev = i2c->data;
-	return saa7146_i2c_transfer(dev, msgs, num, 6);
-}
-
-
-int ttpci_budget_init (struct budget *budget,
-		       struct saa7146_dev* dev,
-		       struct saa7146_pci_extension_data *info)
+int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
+		      struct saa7146_pci_extension_data *info,
+		      struct module *owner)
 {
 	int length = TS_WIDTH*TS_HEIGHT;
 	int ret = 0;
@@ -276,12 +343,12 @@
 
 	memset(budget, 0, sizeof(struct budget));
 
-	DEB_EE(("dev: %p, budget: %p\n", dev, budget));
+	dprintk(2, "dev: %p, budget: %p\n", dev, budget);
 
 	budget->card = bi;
 	budget->dev = (struct saa7146_dev *) dev;
 
-	dvb_register_adapter(&budget->dvb_adapter, budget->card->name, THIS_MODULE);
+	dvb_register_adapter(&budget->dvb_adapter, budget->card->name, owner);
 
 	/* set dd1 stream a & b */
       	saa7146_write(dev, DD1_STREAM_B, 0x00000000);
@@ -295,25 +362,33 @@
 	else
 		budget->video_port = BUDGET_VIDEO_PORTA;
 	spin_lock_init(&budget->feedlock);
+	spin_lock_init(&budget->debilock);
 
 	/* the Siemens DVB needs this if you want to have the i2c chips
            get recognized before the main driver is loaded */
 	if (bi->type != BUDGET_FS_ACTIVY)
 		saa7146_write(dev, GPIO_CTRL, 0x500000); /* GPIO 3 = 1 */
 	
-	saa7146_i2c_adapter_prepare(dev, NULL, 0, SAA7146_I2C_BUS_BIT_RATE_120);
+#ifdef I2C_ADAP_CLASS_TV_DIGITAL
+	budget->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
+#else
+	budget->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
+#endif
 
-	budget->i2c_bus = dvb_register_i2c_bus (master_xfer, dev,
-						budget->dvb_adapter, 0);
+	strlcpy(budget->i2c_adap.name, budget->card->name, sizeof(budget->i2c_adap.name));
 
-	if (!budget->i2c_bus) {
+	saa7146_i2c_adapter_prepare(dev, &budget->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120);
+	strcpy(budget->i2c_adap.name, budget->card->name);
+
+	if (i2c_add_adapter(&budget->i2c_adap) < 0) {
 		dvb_unregister_adapter (budget->dvb_adapter);
 		return -ENOMEM;
 	}
 
-	ttpci_eeprom_parse_mac(budget->i2c_bus);
+	ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter->proposed_mac);
 
-	if( NULL == (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci,length,&budget->pt))) {
+	if (NULL ==
+	    (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, length, &budget->pt))) {
 		ret = -ENOMEM;
 		goto err;
 	}
@@ -334,12 +409,11 @@
 		return 0;
 	}
 err:
+	i2c_del_adapter(&budget->i2c_adap);
+
 	if (budget->grabbing)
 		vfree(budget->grabbing);
 
-	dvb_unregister_i2c_bus (master_xfer,budget->i2c_bus->adapter,
-				budget->i2c_bus->id);
-
 	dvb_unregister_adapter (budget->dvb_adapter);
 
 	return ret;
@@ -350,12 +424,11 @@
 {
 	struct saa7146_dev *dev = budget->dev;
 
-	DEB_EE(("budget: %p\n", budget));
+	dprintk(2, "budget: %p\n", budget);
 
 	budget_unregister (budget);
 
-	dvb_unregister_i2c_bus (master_xfer, budget->i2c_bus->adapter,
-				budget->i2c_bus->id);
+	i2c_del_adapter(&budget->i2c_adap);
 
 	dvb_unregister_adapter (budget->dvb_adapter);
 
@@ -372,7 +445,7 @@
 {
 	struct budget *budget = (struct budget*)dev->ext_priv;
 
-	DEB_EE(("dev: %p, budget: %p\n",dev,budget));
+	dprintk(8, "dev: %p, budget: %p\n",dev,budget);
 
 	if (*isr & MASK_10)
 		tasklet_schedule (&budget->vpe_tasklet);
@@ -394,15 +467,13 @@
    	spin_unlock(&budget->feedlock);
 }
 
-
-
+EXPORT_SYMBOL_GPL(ttpci_budget_debiread);
+EXPORT_SYMBOL_GPL(ttpci_budget_debiwrite);
 EXPORT_SYMBOL_GPL(ttpci_budget_init);
 EXPORT_SYMBOL_GPL(ttpci_budget_deinit);
 EXPORT_SYMBOL_GPL(ttpci_budget_irq10_handler);
 EXPORT_SYMBOL_GPL(ttpci_budget_set_video_port);
 EXPORT_SYMBOL_GPL(budget_debug);
 
-MODULE_PARM(budget_debug,"i");
 MODULE_LICENSE("GPL");
-
 
diff -Nru a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
--- a/drivers/media/dvb/ttpci/budget-patch.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/dvb/ttpci/budget-patch.c	2004-12-24 13:36:18 -08:00
@@ -30,9 +30,12 @@
  * the project's page is at http://www.linuxtv.org/dvb/
  */
 
-#include "budget.h"
 #include "av7110.h"
 #include "av7110_hw.h"
+#include "budget.h"
+#include "stv0299.h"
+#include "ves1x93.h"
+#include "tda8083.h"
 
 #define budget_patch budget
 
@@ -51,7 +54,7 @@
 {
         struct saa7146_dev *dev=budget->dev;
 
-        DEB_EE(("budget: %p\n", budget));
+        dprintk(2, "budget: %p\n", budget);
 
         if (count <= 0 || count > 4)
                 return -1;
@@ -71,7 +74,7 @@
 {
         int i;
 
-        DEB_EE(("budget: %p\n", budget));
+        dprintk(2, "budget: %p\n", budget);
 
         for (i = 2; i < length; i++)
                 budget_wdebi(budget, DEBINOSWAP, COMMAND + 2*i, (u32) buf[i], 2);
@@ -90,7 +93,7 @@
 {
         u16 buf[2] = {( COMTYPE_AUDIODAC << 8) | (state ? ON22K : OFF22K), 0};
         
-        DEB_EE(("budget: %p\n", budget));
+        dprintk(2, "budget: %p\n", budget);
         budget_av7110_send_fw_cmd(budget, buf, 2);
 }
 
@@ -101,7 +104,7 @@
         u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) | SendDiSEqC),
                 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
-        DEB_EE(("budget: %p\n", budget));
+        dprintk(2, "budget: %p\n", budget);
 
         if (len>10)
                 len=10;
@@ -121,16 +124,11 @@
         return 0;
 }
 
-
-int budget_patch_diseqc_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static int budget_patch_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
 {
-        struct budget_patch *budget = fe->before_after_data;
+	struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
 
-        DEB_EE(("budget: %p\n", budget));
-
-        switch (cmd) {
-        case FE_SET_TONE:
-                switch ((fe_sec_tone_mode_t) arg) {
+	switch (tone) {
                 case SEC_TONE_ON:
                         av7110_set22k (budget, 1);
                         break;
@@ -140,27 +138,232 @@
                 default:
                         return -EINVAL;
                 }
-                break;
 
-        case FE_DISEQC_SEND_MASTER_CMD:
+	return 0;
+}
+
+static int budget_patch_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
         {
-                struct dvb_diseqc_master_cmd *cmd = arg;
+	struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
 
                 av7110_send_diseqc_msg (budget, cmd->msg_len, cmd->msg, 0);
-                break;
+
+	return 0;
         }
 
-        case FE_DISEQC_SEND_BURST:
-                av7110_send_diseqc_msg (budget, 0, NULL, (int) (long) arg);
-                break;
+static int budget_patch_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
+{
+	struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
+
+	av7110_send_diseqc_msg (budget, 0, NULL, minicmd);
 
-        default:
-                return -EOPNOTSUPP;
+	return 0;
         }
 
+static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
+	u8 pwr = 0;
+	u8 buf[4];
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
+	u32 div = (params->frequency + 479500) / 125;
+
+	if (params->frequency > 2000000) pwr = 3;
+	else if (params->frequency > 1800000) pwr = 2;
+	else if (params->frequency > 1600000) pwr = 1;
+	else if (params->frequency > 1200000) pwr = 0;
+	else if (params->frequency >= 1100000) pwr = 1;
+	else pwr = 2;
+
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = ((div & 0x18000) >> 10) | 0x95;
+	buf[3] = (pwr << 6) | 0x30;
+
+        // NOTE: since we're using a prescaler of 2, we set the
+	// divisor frequency to 62.5kHz and divide by 125 above
+
+	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+static struct ves1x93_config alps_bsrv2_config = {
+	.demod_address = 0x08,
+	.xin = 90100000UL,
+	.invert_pwm = 0,
+	.pll_set = alps_bsrv2_pll_set,
+};
+
+static u8 alps_bsru6_inittab[] = {
+	0x01, 0x15,
+	0x02, 0x00,
+	0x03, 0x00,
+        0x04, 0x7d,   /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
+	0x05, 0x35,   /* I2CT = 0, SCLT = 1, SDAT = 1 */
+	0x06, 0x40,   /* DAC not used, set to high impendance mode */
+	0x07, 0x00,   /* DAC LSB */
+	0x08, 0x40,   /* DiSEqC off, LNB power on OP2/LOCK pin on */
+	0x09, 0x00,   /* FIFO */
+	0x0c, 0x51,   /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
+	0x0d, 0x82,   /* DC offset compensation = ON, beta_agc1 = 2 */
+	0x0e, 0x23,   /* alpha_tmg = 2, beta_tmg = 3 */
+	0x10, 0x3f,   // AGC2  0x3d
+	0x11, 0x84,
+	0x12, 0xb5,   // Lock detect: -64  Carrier freq detect:on
+	0x15, 0xc9,   // lock detector threshold
+	0x16, 0x00,
+	0x17, 0x00,
+	0x18, 0x00,
+	0x19, 0x00,
+	0x1a, 0x00,
+	0x1f, 0x50,
+	0x20, 0x00,
+	0x21, 0x00,
+	0x22, 0x00,
+	0x23, 0x00,
+	0x28, 0x00,  // out imp: normal  out type: parallel FEC mode:0
+	0x29, 0x1e,  // 1/2 threshold
+	0x2a, 0x14,  // 2/3 threshold
+	0x2b, 0x0f,  // 3/4 threshold
+	0x2c, 0x09,  // 5/6 threshold
+	0x2d, 0x05,  // 7/8 threshold
+	0x2e, 0x01,
+	0x31, 0x1f,  // test all FECs
+	0x32, 0x19,  // viterbi and synchro search
+	0x33, 0xfc,  // rs control
+	0x34, 0x93,  // error control
+	0x0f, 0x52,
+	0xff, 0xff
+};
+
+static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
+{
+	u8 aclk = 0;
+	u8 bclk = 0;
+
+	if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
+	else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
+	else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
+	else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
+	else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
+	else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
+
+	stv0299_writereg (fe, 0x13, aclk);
+	stv0299_writereg (fe, 0x14, bclk);
+	stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg (fe, 0x20, (ratio >>  8) & 0xff);
+	stv0299_writereg (fe, 0x21, (ratio      ) & 0xf0);
+
         return 0;
 }
 
+static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
+	u8 data[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	if ((params->frequency < 950000) || (params->frequency > 2150000)) return -EINVAL;
+
+	div = (params->frequency + (125 - 1)) / 125; // round correctly
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
+	data[3] = 0xC4;
+
+	if (params->frequency > 1530000) data[3] = 0xc0;
+
+	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+static struct stv0299_config alps_bsru6_config = {
+
+	.demod_address = 0x68,
+	.inittab = alps_bsru6_inittab,
+	.mclk = 88000000UL,
+	.invert = 1,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_1,
+	.volt13_op0_op1 = STV0299_VOLT13_OP1,
+	.min_delay_ms = 100,
+	.set_symbol_rate = alps_bsru6_set_symbol_rate,
+	.pll_set = alps_bsru6_pll_set,
+};
+
+static int grundig_29504_451_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
+	u32 div;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	div = params->frequency / 125;
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x8e;
+	data[3] = 0x00;
+
+	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+struct tda8083_config grundig_29504_451_config = {
+	.demod_address = 0x68,
+	.pll_set = grundig_29504_451_pll_set,
+};
+
+static void frontend_init(struct budget_patch* budget)
+{
+	switch(budget->dev->pci->subsystem_device) {
+	case 0x0000: // Hauppauge/TT WinTV DVB-S rev1.X
+
+		// try the ALPS BSRV2 first of all
+		budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap);
+		if (budget->dvb_frontend) {
+			budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd;
+			budget->dvb_frontend->ops->diseqc_send_burst = budget_patch_diseqc_send_burst;
+			budget->dvb_frontend->ops->set_tone = budget_patch_set_tone;
+			break;
+		}
+
+		// try the ALPS BSRU6 now
+		budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap);
+		if (budget->dvb_frontend) {
+			budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd;
+			budget->dvb_frontend->ops->diseqc_send_burst = budget_patch_diseqc_send_burst;
+			budget->dvb_frontend->ops->set_tone = budget_patch_set_tone;
+			break;
+		}
+
+		// Try the grundig 29504-451
+		budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap);
+		if (budget->dvb_frontend) {
+			budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd;
+			budget->dvb_frontend->ops->diseqc_send_burst = budget_patch_diseqc_send_burst;
+			budget->dvb_frontend->ops->set_tone = budget_patch_set_tone;
+			break;
+		}
+		break;
+	}
+
+	if (budget->dvb_frontend == NULL) {
+		printk("dvb-ttpci: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
+		       budget->dev->pci->vendor,
+		       budget->dev->pci->device,
+		       budget->dev->pci->subsystem_vendor,
+		       budget->dev->pci->subsystem_device);
+	} else {
+		if (dvb_register_frontend(budget->dvb_adapter, budget->dvb_frontend)) {
+			printk("budget-av: Frontend registration failed!\n");
+			if (budget->dvb_frontend->ops->release)
+				budget->dvb_frontend->ops->release(budget->dvb_frontend);
+			budget->dvb_frontend = NULL;
+		}
+	}
+}
 
 static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
 {
@@ -171,9 +374,9 @@
         if (!(budget = kmalloc (sizeof(struct budget_patch), GFP_KERNEL)))
                 return -ENOMEM;
 
-        DEB_EE(("budget: %p\n",budget));
+        dprintk(2, "budget: %p\n", budget);
 
-        if ((err = ttpci_budget_init (budget, dev, info))) {
+        if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) {
                 kfree (budget);
                 return err;
         }
@@ -221,11 +424,11 @@
         // Enable RPS1                                                  (rFC p33)
         saa7146_write(dev, MC1, (MASK_13 | MASK_29));
 
-        dvb_add_frontend_ioctls (budget->dvb_adapter,
-                budget_patch_diseqc_ioctl, NULL, budget);
-
         dev->ext_priv = budget;
 
+	budget->dvb_adapter->priv = budget;
+	frontend_init(budget);
+
         return 0;
 }
 
@@ -235,8 +438,7 @@
         struct budget_patch *budget = (struct budget_patch*) dev->ext_priv;
         int err;
 
-        dvb_remove_frontend_ioctls (budget->dvb_adapter,
-                budget_patch_diseqc_ioctl, NULL);
+	if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend);
 
         err = ttpci_budget_deinit (budget);
 
@@ -251,10 +453,8 @@
 	return saa7146_register_extension(&budget_extension);
 }
 
-
 static void __exit budget_patch_exit(void)
 {
-        DEB_EE((".\n"));
         saa7146_unregister_extension(&budget_extension); 
 }
 
diff -Nru a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
--- a/drivers/media/dvb/ttpci/budget.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/media/dvb/ttpci/budget.c	2004-12-24 13:36:56 -08:00
@@ -35,12 +35,16 @@
  */
 
 #include "budget.h"
-#include "dvb_functions.h"
+#include "stv0299.h"
+#include "ves1x93.h"
+#include "ves1820.h"
+#include "l64781.h"
+#include "tda8083.h"
 
 static void Set22K (struct budget *budget, int state)
 {
 	struct saa7146_dev *dev=budget->dev;
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 	saa7146_setgpio(dev, 3, (state ? SAA7146_GPIO_OUTHI : SAA7146_GPIO_OUTLO));
 }
 
@@ -52,7 +56,7 @@
 static void DiseqcSendBit (struct budget *budget, int data)
 {
 	struct saa7146_dev *dev=budget->dev;
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
 	saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
 	udelay(data ? 500 : 1000);
@@ -65,7 +69,7 @@
 {
 	int i, par=1, d;
 
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
 	for (i=7; i>=0; i--) {
 		d = (data>>i)&1;
@@ -82,7 +86,7 @@
 	struct saa7146_dev *dev=budget->dev;
 	int i;
 
-	DEB_EE(("budget: %p\n",budget));
+	dprintk(2, "budget: %p\n", budget);
 
 	saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
 	mdelay(16);
@@ -100,95 +104,374 @@
 			udelay(12500);
 			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
 		}
-		dvb_delay(20);
+		msleep(20);
 	}
 
 	return 0;
 }
 
+/*
+ *   Routines for the Fujitsu Siemens Activy budget card
+ *   22 kHz tone and DiSEqC are handled by the frontend.
+ *   Voltage must be set here.
+ */
+static int SetVoltage_Activy (struct budget *budget, fe_sec_voltage_t voltage)
+{
+	struct saa7146_dev *dev=budget->dev;
 
-int budget_diseqc_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
+       dprintk(2, "budget: %p\n", budget);
+
+	switch (voltage) {
+		case SEC_VOLTAGE_13:
+			saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTLO);
+			break;
+		case SEC_VOLTAGE_18:
+			saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
+			break;
+		default:
+			return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int siemens_budget_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
 {
-       struct budget *budget = fe->before_after_data;
+	struct budget* budget = (struct budget*) fe->dvb->priv;
+
+	return SetVoltage_Activy (budget, voltage);
+}
 
-       DEB_EE(("budget: %p\n",budget));
+static int budget_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+{
+	struct budget* budget = (struct budget*) fe->dvb->priv;
 
-       switch (cmd) {
-       case FE_SET_TONE:
-               switch ((fe_sec_tone_mode_t) arg) {
+	switch (tone) {
                case SEC_TONE_ON:
                        Set22K (budget, 1);
                        break;
                case SEC_TONE_OFF:
                        Set22K (budget, 0);
                        break;
+
                default:
                        return -EINVAL;
-               };
-               break;
+	}
 
-       case FE_DISEQC_SEND_MASTER_CMD:
+	return 0;
+}
+
+static int budget_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
        {
-               struct dvb_diseqc_master_cmd *cmd = arg;
+	struct budget* budget = (struct budget*) fe->dvb->priv;
 
                SendDiSEqCMsg (budget, cmd->msg_len, cmd->msg, 0);
-               break;
+
+	return 0;
        }
 
-       case FE_DISEQC_SEND_BURST:
-               SendDiSEqCMsg (budget, 0, NULL, (unsigned long)arg);
-               break;
-
-       default:
-               return -EOPNOTSUPP;
-       };
+static int budget_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
+{
+	struct budget* budget = (struct budget*) fe->dvb->priv;
+
+	SendDiSEqCMsg (budget, 0, NULL, minicmd);
 
        return 0;
 }
 
+static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct budget* budget = (struct budget*) fe->dvb->priv;
+	u8 pwr = 0;
+	u8 buf[4];
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
+	u32 div = (params->frequency + 479500) / 125;
+
+	if (params->frequency > 2000000) pwr = 3;
+	else if (params->frequency > 1800000) pwr = 2;
+	else if (params->frequency > 1600000) pwr = 1;
+	else if (params->frequency > 1200000) pwr = 0;
+	else if (params->frequency >= 1100000) pwr = 1;
+	else pwr = 2;
+
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = ((div & 0x18000) >> 10) | 0x95;
+	buf[3] = (pwr << 6) | 0x30;
+
+        // NOTE: since we're using a prescaler of 2, we set the
+	// divisor frequency to 62.5kHz and divide by 125 above
 
-/*
- *   Routines for the Fujitsu Siemens Activy budget card
- *   22 kHz tone and DiSEqC are handled by the frontend.
- *   Voltage must be set here.
- */
-static int SetVoltage_Activy (struct budget *budget, fe_sec_voltage_t voltage)
+	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+static struct ves1x93_config alps_bsrv2_config =
 {
-	struct saa7146_dev *dev=budget->dev;
+	.demod_address = 0x08,
+	.xin = 90100000UL,
+	.invert_pwm = 0,
+	.pll_set = alps_bsrv2_pll_set,
+};
 
-	DEB_EE(("budget: %p\n",budget));
+static u8 alps_bsru6_inittab[] = {
+	0x01, 0x15,
+	0x02, 0x00,
+	0x03, 0x00,
+        0x04, 0x7d,   /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
+	0x05, 0x35,   /* I2CT = 0, SCLT = 1, SDAT = 1 */
+	0x06, 0x40,   /* DAC not used, set to high impendance mode */
+	0x07, 0x00,   /* DAC LSB */
+	0x08, 0x40,   /* DiSEqC off, LNB power on OP2/LOCK pin on */
+	0x09, 0x00,   /* FIFO */
+	0x0c, 0x51,   /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
+	0x0d, 0x82,   /* DC offset compensation = ON, beta_agc1 = 2 */
+	0x0e, 0x23,   /* alpha_tmg = 2, beta_tmg = 3 */
+	0x10, 0x3f,   // AGC2  0x3d
+	0x11, 0x84,
+	0x12, 0xb5,   // Lock detect: -64  Carrier freq detect:on
+	0x15, 0xc9,   // lock detector threshold
+	0x16, 0x00,
+	0x17, 0x00,
+	0x18, 0x00,
+	0x19, 0x00,
+	0x1a, 0x00,
+	0x1f, 0x50,
+	0x20, 0x00,
+	0x21, 0x00,
+	0x22, 0x00,
+	0x23, 0x00,
+	0x28, 0x00,  // out imp: normal  out type: parallel FEC mode:0
+	0x29, 0x1e,  // 1/2 threshold
+	0x2a, 0x14,  // 2/3 threshold
+	0x2b, 0x0f,  // 3/4 threshold
+	0x2c, 0x09,  // 5/6 threshold
+	0x2d, 0x05,  // 7/8 threshold
+	0x2e, 0x01,
+	0x31, 0x1f,  // test all FECs
+	0x32, 0x19,  // viterbi and synchro search
+	0x33, 0xfc,  // rs control
+	0x34, 0x93,  // error control
+	0x0f, 0x52,
+	0xff, 0xff
+};
 
-	switch (voltage) {
-		case SEC_VOLTAGE_13:
-			saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTLO);
-			break;
-		case SEC_VOLTAGE_18:
-			saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
-			break;
-		default:
-			return -EINVAL;
+static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
+{
+	u8 aclk = 0;
+	u8 bclk = 0;
+
+	if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
+	else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
+	else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
+	else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
+	else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
+	else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
+
+	stv0299_writereg (fe, 0x13, aclk);
+	stv0299_writereg (fe, 0x14, bclk);
+	stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg (fe, 0x20, (ratio >>  8) & 0xff);
+	stv0299_writereg (fe, 0x21, (ratio      ) & 0xf0);
+
+	return 0;
 	}
 
+static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct budget* budget = (struct budget*) fe->dvb->priv;
+	u8 data[4];
+	u32 div;
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	if ((params->frequency < 950000) || (params->frequency > 2150000)) return -EINVAL;
+
+	div = (params->frequency + (125 - 1)) / 125; // round correctly
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
+	data[3] = 0xC4;
+
+	if (params->frequency > 1530000) data[3] = 0xc0;
+
+	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
 	return 0;
 }
 
+static struct stv0299_config alps_bsru6_config = {
+
+	.demod_address = 0x68,
+	.inittab = alps_bsru6_inittab,
+	.mclk = 88000000UL,
+	.invert = 1,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_1,
+	.volt13_op0_op1 = STV0299_VOLT13_OP1,
+	.min_delay_ms = 100,
+	.set_symbol_rate = alps_bsru6_set_symbol_rate,
+	.pll_set = alps_bsru6_pll_set,
+};
 
-static int budget_ioctl_activy (struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
 {
-	struct budget *budget = fe->before_after_data;
+	struct budget* budget = (struct budget*) fe->dvb->priv;
+	u32 div;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
 
-	DEB_EE(("budget: %p\n",budget));
+	div = (params->frequency + 35937500 + 31250) / 62500;
 
-	switch (cmd) {
-		case FE_SET_VOLTAGE:
-			return SetVoltage_Activy (budget, (fe_sec_voltage_t) arg);
-		default:
-			return -EOPNOTSUPP;
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x85 | ((div >> 10) & 0x60);
+	data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81);
+
+	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+static struct ves1820_config alps_tdbe2_config = {
+	.demod_address = 0x09,
+	.xin = 57840000UL,
+	.invert = 1,
+	.selagc = VES1820_SELAGC_SIGNAMPERR,
+	.pll_set = alps_tdbe2_pll_set,
+};
+
+static int grundig_29504_401_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct budget* budget = (struct budget*) fe->dvb->priv;
+	u32 div;
+	u8 cfg, cpump, band_select;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	div = (36125000 + params->frequency) / 166666;
+
+	cfg = 0x88;
+
+	if (params->frequency < 175000000) cpump = 2;
+	else if (params->frequency < 390000000) cpump = 1;
+	else if (params->frequency < 470000000) cpump = 2;
+	else if (params->frequency < 750000000) cpump = 1;
+	else cpump = 3;
+
+	if (params->frequency < 175000000) band_select = 0x0e;
+	else if (params->frequency < 470000000) band_select = 0x05;
+	else band_select = 0x03;
+
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = ((div >> 10) & 0x60) | cfg;
+	data[3] = (cpump << 6) | band_select;
+
+	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
 	}
 
+static struct l64781_config grundig_29504_401_config = {
+	.demod_address = 0x55,
+	.pll_set = grundig_29504_401_pll_set,
+};
+
+static int grundig_29504_451_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct budget* budget = (struct budget*) fe->dvb->priv;
+	u32 div;
+	u8 data[4];
+	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+	div = params->frequency / 125;
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = 0x8e;
+	data[3] = 0x00;
+
+	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
 	return 0;
 }
 
+static struct tda8083_config grundig_29504_451_config = {
+	.demod_address = 0x68,
+	.pll_set = grundig_29504_451_pll_set,
+};
+
+static u8 read_pwm(struct budget* budget)
+{
+	u8 b = 0xff;
+	u8 pwm;
+	struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
+				 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
+
+        if ((i2c_transfer(&budget->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
+		pwm = 0x48;
+
+	return pwm;
+}
+
+static void frontend_init(struct budget *budget)
+{
+	switch(budget->dev->pci->subsystem_device) {
+	case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659))
+
+		// try the ALPS BSRV2 first of all
+		budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap);
+		if (budget->dvb_frontend) {
+			budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
+		        budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst;
+			budget->dvb_frontend->ops->set_tone = budget_set_tone;
+			break;
+		}
+
+		// try the ALPS BSRU6 now
+		budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap);
+		if (budget->dvb_frontend) {
+			budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
+			budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst;
+			budget->dvb_frontend->ops->set_tone = budget_set_tone;
+			break;
+		}
+		break;
+
+   	case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
+
+		budget->dvb_frontend = ves1820_attach(&alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget));
+		if (budget->dvb_frontend) break;
+		break;
+
+   	case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060))
+
+		budget->dvb_frontend = l64781_attach(&grundig_29504_401_config, &budget->i2c_adap);
+		if (budget->dvb_frontend) break;
+		break;
+
+	case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI (tda8083/Grundig 29504-451(tsa5522))
+
+		// grundig 29504-451
+                budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap);
+		if (budget->dvb_frontend) {
+			budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage;
+			break;
+		}
+		break;
+	}
+
+	if (budget->dvb_frontend == NULL) {
+		printk("budget: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
+		       budget->dev->pci->vendor,
+		       budget->dev->pci->device,
+		       budget->dev->pci->subsystem_vendor,
+		       budget->dev->pci->subsystem_device);
+	} else {
+		if (dvb_register_frontend(budget->dvb_adapter, budget->dvb_frontend)) {
+			printk("budget: Frontend registration failed!\n");
+			if (budget->dvb_frontend->ops->release)
+				budget->dvb_frontend->ops->release(budget->dvb_frontend);
+			budget->dvb_frontend = NULL;
+		}
+	}
+}
 
 static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
 {
@@ -200,22 +483,18 @@
 		return -ENOMEM;
 	}
 
-	DEB_EE(("dev:%p, info:%p, budget:%p\n",dev,info,budget));
+	dprintk(2, "dev:%p, info:%p, budget:%p\n", dev, info, budget);
 
-	if ((err = ttpci_budget_init (budget, dev, info))) {
+	dev->ext_priv = budget;
+
+	if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) {
 		printk("==> failed\n");
 		kfree (budget);
 		return err;
 	}
 
-	if (budget->card->type == BUDGET_FS_ACTIVY)
-		dvb_add_frontend_ioctls (budget->dvb_adapter,
-				 budget_ioctl_activy, NULL, budget);
-	else
-	dvb_add_frontend_ioctls (budget->dvb_adapter,
-				 budget_diseqc_ioctl, NULL, budget);
-
-	dev->ext_priv = budget;
+	budget->dvb_adapter->priv = budget;
+	frontend_init(budget);
 
 	return 0;
 }
@@ -226,12 +505,7 @@
 	struct budget *budget = (struct budget*) dev->ext_priv;
 	int err;
 
-	if (budget->card->type == BUDGET_FS_ACTIVY)
-		dvb_remove_frontend_ioctls (budget->dvb_adapter,
-				    budget_ioctl_activy, NULL);
-	else
-	dvb_remove_frontend_ioctls (budget->dvb_adapter,
-				    budget_diseqc_ioctl, NULL);
+	if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend);
 
 	err = ttpci_budget_deinit (budget);
 
@@ -248,18 +522,14 @@
 MAKE_BUDGET_INFO(ttbs,	"TT-Budget/WinTV-NOVA-S  PCI",	BUDGET_TT);
 MAKE_BUDGET_INFO(ttbc,	"TT-Budget/WinTV-NOVA-C  PCI",	BUDGET_TT);
 MAKE_BUDGET_INFO(ttbt,	"TT-Budget/WinTV-NOVA-T  PCI",	BUDGET_TT);
-MAKE_BUDGET_INFO(satel,	"SATELCO Multimedia PCI",	BUDGET_TT_HW_DISEQC);
+/* MAKE_BUDGET_INFO(satel,	"SATELCO Multimedia PCI",	BUDGET_TT_HW_DISEQC); UNDEFINED HARDWARE - mail linuxtv.org list */
 MAKE_BUDGET_INFO(fsacs, "Fujitsu Siemens Activy Budget-S PCI", BUDGET_FS_ACTIVY);
-/* Uncomment for Budget Patch */
-/*MAKE_BUDGET_INFO(fs_1_3,"Siemens/Technotrend/Hauppauge PCI rev1.3+Budget_Patch", BUDGET_PATCH);*/
 
 static struct pci_device_id pci_tbl[] = {
-	/* Uncomment for Budget Patch */
-	/*MAKE_EXTENSION_PCI(fs_1_3,0x13c2, 0x0000),*/
 	MAKE_EXTENSION_PCI(ttbs,  0x13c2, 0x1003),
 	MAKE_EXTENSION_PCI(ttbc,  0x13c2, 0x1004),
 	MAKE_EXTENSION_PCI(ttbt,  0x13c2, 0x1005),
-	MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
+/*	MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013), UNDEFINED HARDWARE */
 	MAKE_EXTENSION_PCI(fsacs, 0x1131, 0x4f61),
 	{
 		.vendor    = 0,
@@ -290,7 +560,6 @@
 
 static void __exit budget_exit(void)
 {
-	DEB_EE((".\n"));
 	saa7146_unregister_extension(&budget_extension); 
 }
 
diff -Nru a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
--- a/drivers/media/dvb/ttpci/budget.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/media/dvb/ttpci/budget.h	2004-12-24 13:37:00 -08:00
@@ -1,9 +1,6 @@
 #ifndef __BUDGET_DVB__
 #define __BUDGET_DVB__
 
-#include <media/saa7146.h>
-
-#include "dvb_i2c.h"
 #include "dvb_frontend.h"
 #include "dvbdev.h"
 #include "demux.h"
@@ -12,8 +9,18 @@
 #include "dvb_filter.h"
 #include "dvb_net.h"
 
+#include <linux/module.h>
+#include <media/saa7146.h>
+
 extern int budget_debug;
 
+#ifdef dprintk
+#undef dprintk
+#endif
+
+#define dprintk(level,args...) \
+            do { if ((budget_debug & level)) { printk("%s: %s(): ",__stringify(KBUILD_MODNAME), __FUNCTION__); printk(args); } } while (0)
+
 struct budget_info {
 	char *name;
 	int type;
@@ -28,7 +35,7 @@
 
         struct saa7146_dev	*dev;
 
-	struct dvb_i2c_bus	*i2c_bus;	
+	struct i2c_adapter	i2c_adap;
 	struct budget_info	*card;
 
 	unsigned char		*grabbing;
@@ -55,7 +62,10 @@
 
 	spinlock_t feedlock;
 
+	spinlock_t debilock;
+
         struct dvb_adapter       *dvb_adapter;
+	struct dvb_frontend *dvb_frontend;
 	void			 *priv;
 };
 
@@ -76,19 +86,27 @@
 
 #define BUDGET_TT		   0
 #define BUDGET_TT_HW_DISEQC	   1
-#define BUDGET_KNC1		   2
 #define BUDGET_PATCH		   3
 #define BUDGET_FS_ACTIVY	   4
+#define BUDGET_CIN1200S		   5
+#define BUDGET_CIN1200C		   6
+#define BUDGET_CIN1200T		   7
+#define BUDGET_KNC1S		   8
+#define BUDGET_KNC1C		   9
+#define BUDGET_KNC1T		   10
 
 #define BUDGET_VIDEO_PORTA         0
 #define BUDGET_VIDEO_PORTB         1
 
-extern int ttpci_budget_init (struct budget *budget,
-			      struct saa7146_dev* dev,
-			      struct saa7146_pci_extension_data *info);
+extern int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
+			     struct saa7146_pci_extension_data *info,
+			     struct module *owner);
 extern int ttpci_budget_deinit (struct budget *budget);
 extern void ttpci_budget_irq10_handler (struct saa7146_dev* dev, u32 *isr);
 extern void ttpci_budget_set_video_port(struct saa7146_dev* dev, int video_port);
+extern int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count,
+				 int uselocks, int nobusyloop);
+extern int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr, int count, u32 value,
+				  int uselocks, int nobusyloop);
 
 #endif
-
diff -Nru a/drivers/media/dvb/ttpci/ttpci-eeprom.c b/drivers/media/dvb/ttpci/ttpci-eeprom.c
--- a/drivers/media/dvb/ttpci/ttpci-eeprom.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/media/dvb/ttpci/ttpci-eeprom.c	2004-12-24 13:37:01 -08:00
@@ -35,9 +35,8 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/i2c.h>
 
-#include "dvb_i2c.h"
-#include "dvb_functions.h"
 
 #if 1
 #define dprintk(x...) do { printk(x); } while (0)
@@ -85,7 +84,7 @@
         return 0;
 }
 
-static int ttpci_eeprom_read_encodedMAC(struct dvb_i2c_bus *i2c, u8 * encodedMAC)
+static int ttpci_eeprom_read_encodedMAC(struct i2c_adapter *adapter, u8 * encodedMAC)
 {
 	int ret;
 	u8 b0[] = { 0xcc };
@@ -97,7 +96,7 @@
 
 	/* dprintk("%s\n", __FUNCTION__); */
 
-	ret = i2c->xfer(i2c, msg, 2);
+	ret = i2c_transfer(adapter, msg, 2);
 
 	if (ret != 2)		/* Assume EEPROM isn't there */
 		return (-ENODEV);
@@ -106,36 +105,34 @@
 }
 
 
-int ttpci_eeprom_parse_mac(struct dvb_i2c_bus *i2c)
+int ttpci_eeprom_parse_mac(struct i2c_adapter *adapter, u8 *proposed_mac)
 {
 	int ret, i;
 	u8 encodedMAC[20];
 	u8 decodedMAC[6];
 
-	ret = ttpci_eeprom_read_encodedMAC(i2c, encodedMAC);
+	ret = ttpci_eeprom_read_encodedMAC(adapter, encodedMAC);
 
 	if (ret != 0) {		/* Will only be -ENODEV */
 		dprintk("Couldn't read from EEPROM: not there?\n");
-		memset(i2c->adapter->proposed_mac, 0, 6);
+		memset(proposed_mac, 0, 6);
 		return ret;
 	}
 
 	ret = getmac_tt(decodedMAC, encodedMAC);
 	if( ret != 0 ) {
-		dprintk("%s adapter %i failed MAC signature check\n",
-			i2c->adapter->name, i2c->adapter->num);
+		dprintk("adapter failed MAC signature check\n");
 		dprintk("encoded MAC from EEPROM was " );
 		for(i=0; i<19; i++) {
 			dprintk( "%.2x:", encodedMAC[i]);
 		}
 		dprintk("%.2x\n", encodedMAC[19]);
-		memset(i2c->adapter->proposed_mac, 0, 6);
+		memset(proposed_mac, 0, 6);
 		return ret;
 	}
 
-	memcpy(i2c->adapter->proposed_mac, decodedMAC, 6);
-	dprintk("%s adapter %i has MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
-		i2c->adapter->name, i2c->adapter->num,
+	memcpy(proposed_mac, decodedMAC, 6);
+	dprintk("adapter has MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
 		decodedMAC[0], decodedMAC[1], decodedMAC[2],
 		decodedMAC[3], decodedMAC[4], decodedMAC[5]);
 	return 0;
diff -Nru a/drivers/media/dvb/ttpci/ttpci-eeprom.h b/drivers/media/dvb/ttpci/ttpci-eeprom.h
--- a/drivers/media/dvb/ttpci/ttpci-eeprom.h	2004-12-24 13:36:19 -08:00
+++ b/drivers/media/dvb/ttpci/ttpci-eeprom.h	2004-12-24 13:36:19 -08:00
@@ -25,8 +25,9 @@
 #ifndef __TTPCI_EEPROM_H__
 #define __TTPCI_EEPROM_H__
 
-#include "dvb_i2c.h"
+#include <linux/types.h>
+#include <linux/i2c.h>
 
-extern int ttpci_eeprom_parse_mac(struct dvb_i2c_bus *i2c);
+extern int ttpci_eeprom_parse_mac(struct i2c_adapter *adapter, u8 *propsed_mac);
 
 #endif
diff -Nru a/drivers/media/dvb/ttusb-budget/Kconfig b/drivers/media/dvb/ttusb-budget/Kconfig
--- a/drivers/media/dvb/ttusb-budget/Kconfig	2004-12-24 13:36:16 -08:00
+++ b/drivers/media/dvb/ttusb-budget/Kconfig	2004-12-24 13:36:16 -08:00
@@ -1,6 +1,10 @@
 config DVB_TTUSB_BUDGET
 	tristate "Technotrend/Hauppauge Nova-USB devices"
 	depends on DVB_CORE && USB
+	select DVB_CX22700
+	select DVB_TDA1004X
+	select DVB_TDA8083
+	select DVB_STV0299
 	help
 	  Support for external USB adapters designed by Technotrend and
 	  produced by Hauppauge, shipped under the brand name 'Nova-USB'.
diff -Nru a/drivers/media/dvb/ttusb-budget/Makefile b/drivers/media/dvb/ttusb-budget/Makefile
--- a/drivers/media/dvb/ttusb-budget/Makefile	2004-12-24 13:37:31 -08:00
+++ b/drivers/media/dvb/ttusb-budget/Makefile	2004-12-24 13:37:31 -08:00
@@ -1,3 +1,3 @@
 obj-$(CONFIG_DVB_TTUSB_BUDGET) += dvb-ttusb-budget.o
 
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
+EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends
diff -Nru a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c	2004-12-24 13:37:30 -08:00
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/wait.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/usb.h>
 #include <linux/delay.h>
 #include <linux/time.h>
@@ -23,13 +24,15 @@
 #include "dmxdev.h"
 #include "dvb_demux.h"
 #include "dvb_net.h"
+#include "cx22700.h"
+#include "tda1004x.h"
+#include "stv0299.h"
+#include "tda8083.h"
 
 #include <linux/dvb/frontend.h>
 #include <linux/dvb/dmx.h>
 #include <linux/pci.h>
 
-#include "dvb_functions.h"
-
 /*
   TTUSB_HWSECTIONS:
     the DSP supports filtering in hardware, however, since the "muxstream"
@@ -49,7 +52,10 @@
     this unless the device doesn't load at all. > 2 for bandwidth statistics.
 */
 
-static int debug = 0;
+static int debug;
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
 
 #define dprintk(x...) do { if (debug) printk(KERN_DEBUG x); } while (0)
 
@@ -80,6 +86,8 @@
 	struct dvb_adapter *adapter;
 	struct usb_device *dev;
 
+	struct i2c_adapter i2c_adap;
+
 	int disconnecting;
 	int iso_streaming;
 
@@ -128,6 +136,8 @@
 #if 0
 	devfs_handle_t stc_devfs_handle;
 #endif
+
+	struct dvb_frontend* fe;
 };
 
 /* ugly workaround ... don't know why it's neccessary to read */
@@ -242,10 +252,9 @@
 	return rcv_len;
 }
 
-static int ttusb_i2c_xfer(struct dvb_i2c_bus *i2c, const struct i2c_msg msg[],
-		   int num)
+static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg msg[], int num)
 {
-	struct ttusb *ttusb = i2c->data;
+	struct ttusb *ttusb = i2c_get_adapdata(adapter);
 	int i = 0;
 	int inc;
 
@@ -458,9 +467,10 @@
 }
 
 #ifdef TTUSB_DISEQC
-static int ttusb_send_diseqc(struct ttusb *ttusb,
+static int ttusb_send_diseqc(struct dvb_frontend* fe,
 		      const struct dvb_diseqc_master_cmd *cmd)
 {
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
 	u8 b[12] = { 0xaa, ++ttusb->c, 0x18 };
 
 	int err;
@@ -498,41 +508,24 @@
 	return err;
 }
 
-static int ttusb_set_voltage(struct ttusb *ttusb, fe_sec_voltage_t voltage)
+static int ttusb_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
 {
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
+
 	ttusb->voltage = voltage;
 	return ttusb_update_lnb(ttusb);
 }
 
 #ifdef TTUSB_TONE
-static int ttusb_set_tone(struct ttusb *ttusb, fe_sec_tone_mode_t tone)
+static int ttusb_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
 {
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
+
 	ttusb->tone = tone;
 	return ttusb_update_lnb(ttusb);
 }
 #endif
 
-static int ttusb_lnb_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-	struct ttusb *ttusb = fe->i2c->data;
-
-	switch (cmd) {
-	case FE_SET_VOLTAGE:
-		return ttusb_set_voltage(ttusb, (fe_sec_voltage_t) arg);
-#ifdef TTUSB_TONE
-	case FE_SET_TONE:
-		return ttusb_set_tone(ttusb, (fe_sec_tone_mode_t) arg);
-#endif
-#ifdef TTUSB_DISEQC
-	case FE_DISEQC_SEND_MASTER_CMD:
-		return ttusb_send_diseqc(ttusb,
-					 (struct dvb_diseqc_master_cmd *)
-					 arg);
-#endif
-	default:
-		return -EOPNOTSUPP;
-	};
-}
 
 #if 0
 static void ttusb_set_led_freq(struct ttusb *ttusb, u8 freq)
@@ -557,7 +550,7 @@
 				  const u8 * data, int len);
 #endif
 
-int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid;
+static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid;
 
 static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
 			   int len)
@@ -787,7 +780,7 @@
 			ttusb_process_frame(ttusb, data, len);
 		}
 	}
-	usb_submit_urb(urb, GFP_KERNEL);
+	usb_submit_urb(urb, GFP_ATOMIC);
 }
 
 static void ttusb_free_iso_urbs(struct ttusb *ttusb)
@@ -822,7 +815,7 @@
 
 		if (!
 		    (urb =
-		     usb_alloc_urb(FRAMES_PER_ISO_BUF, GFP_KERNEL))) {
+		     usb_alloc_urb(FRAMES_PER_ISO_BUF, GFP_ATOMIC))) {
 			ttusb_free_iso_urbs(ttusb);
 			return -ENOMEM;
 		}
@@ -880,7 +873,7 @@
 	}
 
 	for (i = 0; i < ISO_BUF_COUNT; i++) {
-		if ((err = usb_submit_urb(ttusb->iso_urb[i], GFP_KERNEL))) {
+		if ((err = usb_submit_urb(ttusb->iso_urb[i], GFP_ATOMIC))) {
 			ttusb_stop_iso_xfer(ttusb);
 			printk
 			    ("%s: failed urb submission (%i: err = %i)!\n",
@@ -1068,6 +1061,347 @@
 };
 #endif
 
+static u32 functionality(struct i2c_adapter *adapter)
+{
+	return I2C_FUNC_I2C;
+}
+
+
+
+static int alps_tdmb7_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
+	u8 data[4];
+	struct i2c_msg msg = {.addr=0x61, .flags=0, .buf=data, .len=sizeof(data) };
+	u32 div;
+
+	div = (params->frequency + 36166667) / 166667;
+
+	data[0] = (div >> 8) & 0x7f;
+	data[1] = div & 0xff;
+	data[2] = ((div >> 10) & 0x60) | 0x85;
+	data[3] = params->frequency < 592000000 ? 0x40 : 0x80;
+
+	if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) return -EIO;
+	return 0;
+}
+
+struct cx22700_config alps_tdmb7_config = {
+	.demod_address = 0x43,
+	.pll_set = alps_tdmb7_pll_set,
+};
+
+
+
+
+
+static int philips_tdm1316l_pll_init(struct dvb_frontend* fe)
+{
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
+	static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab };
+	static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
+	struct i2c_msg tuner_msg = { .addr=0x60, .flags=0, .buf=td1316_init, .len=sizeof(td1316_init) };
+
+	// setup PLL configuration
+	if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) return -EIO;
+	msleep(1);
+
+	// disable the mc44BC374c (do not check for errors)
+	tuner_msg.addr = 0x65;
+	tuner_msg.buf = disable_mc44BC374c;
+	tuner_msg.len = sizeof(disable_mc44BC374c);
+	if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
+		i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1);
+	}
+
+	return 0;
+}
+
+static int philips_tdm1316l_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
+	u8 tuner_buf[4];
+	struct i2c_msg tuner_msg = {.addr=0x60, .flags=0, .buf=tuner_buf, .len=sizeof(tuner_buf) };
+	int tuner_frequency = 0;
+	u8 band, cp, filter;
+
+	// determine charge pump
+	tuner_frequency = params->frequency + 36130000;
+	if (tuner_frequency < 87000000) return -EINVAL;
+	else if (tuner_frequency < 130000000) cp = 3;
+	else if (tuner_frequency < 160000000) cp = 5;
+	else if (tuner_frequency < 200000000) cp = 6;
+	else if (tuner_frequency < 290000000) cp = 3;
+	else if (tuner_frequency < 420000000) cp = 5;
+	else if (tuner_frequency < 480000000) cp = 6;
+	else if (tuner_frequency < 620000000) cp = 3;
+	else if (tuner_frequency < 830000000) cp = 5;
+	else if (tuner_frequency < 895000000) cp = 7;
+	else return -EINVAL;
+
+	// determine band
+	if (params->frequency < 49000000) return -EINVAL;
+	else if (params->frequency < 159000000) band = 1;
+	else if (params->frequency < 444000000) band = 2;
+	else if (params->frequency < 861000000) band = 4;
+	else return -EINVAL;
+
+	// setup PLL filter
+	switch (params->u.ofdm.bandwidth) {
+	case BANDWIDTH_6_MHZ:
+		tda1004x_write_byte(fe, 0x0C, 0);
+		filter = 0;
+		break;
+
+	case BANDWIDTH_7_MHZ:
+		tda1004x_write_byte(fe, 0x0C, 0);
+		filter = 0;
+		break;
+
+	case BANDWIDTH_8_MHZ:
+		tda1004x_write_byte(fe, 0x0C, 0xFF);
+		filter = 1;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	// calculate divisor
+	// ((36130000+((1000000/6)/2)) + Finput)/(1000000/6)
+	tuner_frequency = (((params->frequency / 1000) * 6) + 217280) / 1000;
+
+	// setup tuner buffer
+	tuner_buf[0] = tuner_frequency >> 8;
+	tuner_buf[1] = tuner_frequency & 0xff;
+	tuner_buf[2] = 0xca;
+	tuner_buf[3] = (cp << 5) | (filter << 3) | band;
+
+	if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1)
+		return -EIO;
+
+	msleep(1);
+	return 0;
+}
+
+static int philips_tdm1316l_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
+{
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
+
+	return request_firmware(fw, name, &ttusb->dev->dev);
+}
+
+static struct tda1004x_config philips_tdm1316l_config = {
+
+	.demod_address = 0x8,
+	.invert = 1,
+	.invert_oclk = 0,
+	.pll_init = philips_tdm1316l_pll_init,
+	.pll_set = philips_tdm1316l_pll_set,
+	.request_firmware = philips_tdm1316l_request_firmware,
+};
+
+
+static u8 alps_bsru6_inittab[] = {
+	0x01, 0x15,
+	0x02, 0x00,
+	0x03, 0x00,
+	0x04, 0x7d,		/* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
+	0x05, 0x35,		/* I2CT = 0, SCLT = 1, SDAT = 1 */
+	0x06, 0x40,		/* DAC not used, set to high impendance mode */
+	0x07, 0x00,		/* DAC LSB */
+	0x08, 0x40,		/* DiSEqC off, LNB power on OP2/LOCK pin on */
+	0x09, 0x00,		/* FIFO */
+	0x0c, 0x51,		/* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
+	0x0d, 0x82,		/* DC offset compensation = ON, beta_agc1 = 2 */
+	0x0e, 0x23,		/* alpha_tmg = 2, beta_tmg = 3 */
+	0x10, 0x3f,		// AGC2  0x3d
+	0x11, 0x84,
+	0x12, 0xb5,		// Lock detect: -64  Carrier freq detect:on
+	0x15, 0xc9,		// lock detector threshold
+	0x16, 0x00,
+	0x17, 0x00,
+	0x18, 0x00,
+	0x19, 0x00,
+	0x1a, 0x00,
+	0x1f, 0x50,
+	0x20, 0x00,
+	0x21, 0x00,
+	0x22, 0x00,
+	0x23, 0x00,
+	0x28, 0x00,		// out imp: normal  out type: parallel FEC mode:0
+	0x29, 0x1e,		// 1/2 threshold
+	0x2a, 0x14,		// 2/3 threshold
+	0x2b, 0x0f,		// 3/4 threshold
+	0x2c, 0x09,		// 5/6 threshold
+	0x2d, 0x05,		// 7/8 threshold
+	0x2e, 0x01,
+	0x31, 0x1f,		// test all FECs
+	0x32, 0x19,		// viterbi and synchro search
+	0x33, 0xfc,		// rs control
+	0x34, 0x93,		// error control
+	0x0f, 0x52,
+	0xff, 0xff
+};
+
+static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
+{
+	u8 aclk = 0;
+	u8 bclk = 0;
+
+	if (srate < 1500000) {
+		aclk = 0xb7;
+		bclk = 0x47;
+	} else if (srate < 3000000) {
+		aclk = 0xb7;
+		bclk = 0x4b;
+	} else if (srate < 7000000) {
+		aclk = 0xb7;
+		bclk = 0x4f;
+	} else if (srate < 14000000) {
+		aclk = 0xb7;
+		bclk = 0x53;
+	} else if (srate < 30000000) {
+		aclk = 0xb6;
+		bclk = 0x53;
+	} else if (srate < 45000000) {
+		aclk = 0xb4;
+		bclk = 0x51;
+	}
+
+	stv0299_writereg(fe, 0x13, aclk);
+	stv0299_writereg(fe, 0x14, bclk);
+	stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
+	stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
+	stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
+
+	return 0;
+}
+
+static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
+	u8 buf[4];
+	u32 div;
+	struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
+
+	if ((params->frequency < 950000) || (params->frequency > 2150000))
+		return -EINVAL;
+
+	div = (params->frequency + (125 - 1)) / 125;	// round correctly
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
+	buf[3] = 0xC4;
+
+	if (params->frequency > 1530000)
+		buf[3] = 0xc0;
+
+	if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+
+	return 0;
+}
+
+static struct stv0299_config alps_bsru6_config = {
+
+	.demod_address = 0x68,
+	.inittab = alps_bsru6_inittab,
+	.mclk = 88000000UL,
+	.invert = 1,
+	.enhanced_tuning = 0,
+	.skip_reinit = 0,
+	.lock_output = STV0229_LOCKOUTPUT_1,
+	.volt13_op0_op1 = STV0299_VOLT13_OP1,
+	.min_delay_ms = 100,
+	.set_symbol_rate = alps_bsru6_set_symbol_rate,
+	.pll_set = alps_bsru6_pll_set,
+};
+
+static int ttusb_novas_grundig_29504_491_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
+	u8 buf[4];
+	u32 div;
+	struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
+
+        div = params->frequency / 125;
+
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x8e;
+	buf[3] = 0x00;
+
+	if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1)
+		return -EIO;
+
+	return 0;
+}
+
+static struct tda8083_config ttusb_novas_grundig_29504_491_config = {
+
+	.demod_address = 0x68,
+	.pll_set = ttusb_novas_grundig_29504_491_pll_set,
+};
+
+
+
+static void frontend_init(struct ttusb* ttusb)
+{
+	switch(ttusb->dev->descriptor.idProduct) {
+	case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6(tsa5059)
+		// try the ALPS BSRU6 first
+		ttusb->fe = stv0299_attach(&alps_bsru6_config, &ttusb->i2c_adap);
+		if (ttusb->fe != NULL) {
+			ttusb->fe->ops->set_voltage = ttusb_set_voltage;
+			break;
+		}
+
+		// Grundig 29504-491
+		ttusb->fe = tda8083_attach(&ttusb_novas_grundig_29504_491_config, &ttusb->i2c_adap);
+		if (ttusb->fe != NULL) {
+			ttusb->fe->ops->set_voltage = ttusb_set_voltage;
+			break;
+		}
+
+		break;
+
+	case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??))
+		// try the ALPS TDMB7 first
+		ttusb->fe = cx22700_attach(&alps_tdmb7_config, &ttusb->i2c_adap);
+		if (ttusb->fe != NULL)
+			break;
+
+		// Philips td1316
+		ttusb->fe = tda10046_attach(&philips_tdm1316l_config, &ttusb->i2c_adap);
+		if (ttusb->fe != NULL)
+			break;
+		break;
+	}
+
+	if (ttusb->fe == NULL) {
+		printk("dvb-ttusb-budget: A frontend driver was not found for device %04x/%04x\n",
+		       ttusb->dev->descriptor.idVendor,
+		       ttusb->dev->descriptor.idProduct);
+	} else {
+		if (dvb_register_frontend(ttusb->adapter, ttusb->fe)) {
+			printk("dvb-ttusb-budget: Frontend registration failed!\n");
+			if (ttusb->fe->ops->release)
+				ttusb->fe->ops->release(ttusb->fe);
+			ttusb->fe = NULL;
+		}
+	}
+}
+
+
+
+static struct i2c_algorithm ttusb_dec_algo = {
+	.name		= "ttusb dec i2c algorithm",
+	.id		= I2C_ALGO_BIT,
+	.master_xfer	= master_xfer,
+	.functionality	= functionality,
+};
+
 static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
 	struct usb_device *udev;
@@ -1078,17 +1412,6 @@
 
 	udev = interface_to_usbdev(intf);
 
-	/* Device has already been reset; its configuration was chosen.
-	 * If this fault happens, use a hotplug script to choose the
-	 * right configuration (write bConfigurationValue in sysfs).
-	 */
-	if (udev->actconfig->desc.bConfigurationValue != 1) {
-		dev_err(&intf->dev, "device config is #%d, need #1\n",
-			udev->actconfig->desc.bConfigurationValue);
-		return -ENODEV;
-	}
-
-
         if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV;
 
 	if (!(ttusb = kmalloc(sizeof(struct ttusb), GFP_KERNEL)))
@@ -1116,10 +1439,28 @@
 	up(&ttusb->sem);
 
 	dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE);
+	ttusb->adapter->priv = ttusb;
 
-	dvb_register_i2c_bus(ttusb_i2c_xfer, ttusb, ttusb->adapter, 0);
-	dvb_add_frontend_ioctls(ttusb->adapter, ttusb_lnb_ioctl, NULL,
-				ttusb);
+	/* i2c */
+	memset(&ttusb->i2c_adap, 0, sizeof(struct i2c_adapter));
+	strcpy(ttusb->i2c_adap.name, "TTUSB DEC");
+
+	i2c_set_adapdata(&ttusb->i2c_adap, ttusb);
+
+#ifdef I2C_ADAP_CLASS_TV_DIGITAL
+	ttusb->i2c_adap.class 	    	  = I2C_ADAP_CLASS_TV_DIGITAL;
+#else
+	ttusb->i2c_adap.class 	    	  = I2C_CLASS_TV_DIGITAL;
+#endif
+	ttusb->i2c_adap.algo              = &ttusb_dec_algo;
+	ttusb->i2c_adap.algo_data         = NULL;
+	ttusb->i2c_adap.id                = I2C_ALGO_BIT;
+
+	result = i2c_add_adapter(&ttusb->i2c_adap);
+	if (result) {
+		dvb_unregister_adapter (ttusb->adapter);
+		return result;
+	}
 
 	memset(&ttusb->dvb_demux, 0, sizeof(ttusb->dvb_demux));
 
@@ -1137,9 +1478,10 @@
 	ttusb->dvb_demux.write_to_decoder = NULL;
 
 	if ((result = dvb_dmx_init(&ttusb->dvb_demux)) < 0) {
-		printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n",
-		       result);
-		goto err;
+		printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n", result);
+		i2c_del_adapter(&ttusb->i2c_adap);
+		dvb_unregister_adapter (ttusb->adapter);
+		return -ENODEV;
 	}
 //FIXME dmxdev (nur WAS?)
 	ttusb->dmxdev.filternum = ttusb->dvb_demux.filternum;
@@ -1150,15 +1492,20 @@
 		printk("ttusb_dvb: dvb_dmxdev_init failed (errno = %d)\n",
 		       result);
 		dvb_dmx_release(&ttusb->dvb_demux);
-		goto err;
+		i2c_del_adapter(&ttusb->i2c_adap);
+		dvb_unregister_adapter (ttusb->adapter);
+		return -ENODEV;
 	}
 
-	if (dvb_net_init
-	    (ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) {
+	if (dvb_net_init(ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) {
 		printk("ttusb_dvb: dvb_net_init failed!\n");
+		dvb_dmxdev_release(&ttusb->dmxdev);
+		dvb_dmx_release(&ttusb->dvb_demux);
+		i2c_del_adapter(&ttusb->i2c_adap);
+		dvb_unregister_adapter (ttusb->adapter);
+		return -ENODEV;
 	}
 
-      err:
 #if 0
 	ttusb->stc_devfs_handle =
 	    devfs_register(ttusb->adapter->devfs_handle, TTUSB_BUDGET_NAME,
@@ -1166,9 +1513,10 @@
 			   S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
 			   | S_IROTH | S_IWOTH, &stc_fops, ttusb);
 #endif
-
 	usb_set_intfdata(intf, (void *) ttusb);
 
+	frontend_init(ttusb);
+
 	return 0;
 }
 
@@ -1186,8 +1534,8 @@
 	dvb_net_release(&ttusb->dvbnet);
 	dvb_dmxdev_release(&ttusb->dmxdev);
 	dvb_dmx_release(&ttusb->dvb_demux);
-
-	dvb_unregister_i2c_bus(ttusb_i2c_xfer, ttusb->adapter, 0);
+	if (ttusb->fe != NULL) dvb_unregister_frontend(ttusb->fe);
+	i2c_del_adapter(&ttusb->i2c_adap);
 	dvb_unregister_adapter(ttusb->adapter);
 
 	ttusb_free_iso_urbs(ttusb);
@@ -1199,7 +1547,7 @@
 
 static struct usb_device_id ttusb_table[] = {
 	{USB_DEVICE(0xb48, 0x1003)},
-	{USB_DEVICE(0xb48, 0x1004)},	/* to be confirmed ????  */
+/*	{USB_DEVICE(0xb48, 0x1004)},UNDEFINED HARDWARE - mail linuxtv.org list*/	/* to be confirmed ????  */
 	{USB_DEVICE(0xb48, 0x1005)},
 	{}
 };
@@ -1233,9 +1581,6 @@
 
 module_init(ttusb_init);
 module_exit(ttusb_exit);
-
-MODULE_PARM(debug, "i");
-MODULE_PARM_DESC(debug, "Debug or not");
 
 MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>");
 MODULE_DESCRIPTION("TTUSB DVB Driver");
diff -Nru a/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h b/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h	2004-12-24 13:36:18 -08:00
@@ -1,7 +1,7 @@
 
 #include <asm/types.h>
 
-u8 dsp_bootcode [] = {
+static u8 dsp_bootcode [] = {
 	0x08, 0xaa, 0x00, 0x18, 0x00, 0x03, 0x08, 0x00, 
 	0x00, 0x10, 0x00, 0x00, 0x01, 0x80, 0x18, 0x5f, 
 	0x00, 0x00, 0x01, 0x80, 0x77, 0x18, 0x2a, 0xeb, 
diff -Nru a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig
--- a/drivers/media/dvb/ttusb-dec/Kconfig	2004-12-24 13:36:19 -08:00
+++ b/drivers/media/dvb/ttusb-dec/Kconfig	2004-12-24 13:36:19 -08:00
@@ -12,8 +12,10 @@
 	  only compressed MPEG data over the USB bus, so you need
 	  an external software decoder to watch TV on your computer.	  
 
-	  The DEC devices require firmware in order to boot into a mode in
-	  which they are slaves to the PC.  See
-	  <file:Documentation/dvb/ttusb-dec.txt> for details.
+          This driver needs external firmware. Please use the commands
+          "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2000t",
+          "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2540t",
+          "<kerneldir>/Documentation/dvb/get_dvb_firmware dec3000s",
+          download/extract them, and then copy them to /usr/lib/hotplug/firmware.
 
 	  Say Y if you own such a device and want to use it.
diff -Nru a/drivers/media/dvb/ttusb-dec/Makefile b/drivers/media/dvb/ttusb-dec/Makefile
--- a/drivers/media/dvb/ttusb-dec/Makefile	2004-12-24 13:36:55 -08:00
+++ b/drivers/media/dvb/ttusb-dec/Makefile	2004-12-24 13:36:55 -08:00
@@ -1,3 +1,3 @@
-obj-$(CONFIG_DVB_TTUSB_DEC) += ttusb_dec.o
+obj-$(CONFIG_DVB_TTUSB_DEC) += ttusb_dec.o ttusbdecfe.o
 
 EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
diff -Nru a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c	2004-12-24 13:37:19 -08:00
@@ -22,28 +22,31 @@
 #include <asm/semaphore.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/usb.h>
+#include <linux/version.h>
 #include <linux/interrupt.h>
 #include <linux/firmware.h>
-#if defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE)
 #include <linux/crc32.h>
-#else
-#warning "CRC checking of firmware not available"
-#endif
 #include <linux/init.h>
 
 #include "dmxdev.h"
 #include "dvb_demux.h"
-#include "dvb_i2c.h"
 #include "dvb_filter.h"
 #include "dvb_frontend.h"
 #include "dvb_net.h"
+#include "ttusbdecfe.h"
 
-static int debug = 0;
-static int output_pva = 0;
+static int debug;
+static int output_pva;
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
+module_param(output_pva, int, 0444);
+MODULE_PARM_DESC(output_pva, "Output PVA from dvr device (default:off)");
 
 #define dprintk	if (debug) printk
 
@@ -63,9 +66,6 @@
 
 #define	MAX_PVA_LENGTH		6144
 
-#define LOF_HI			10600000
-#define LOF_LO			9750000
-
 enum ttusb_dec_model {
 	TTUSB_DEC2000T,
 	TTUSB_DEC2540T,
@@ -95,14 +95,10 @@
 	struct dmxdev			dmxdev;
 	struct dvb_demux		demux;
 	struct dmx_frontend		frontend;
-	struct dvb_i2c_bus		i2c_bus;
 	struct dvb_net			dvb_net;
-	struct dvb_frontend_info	*frontend_info;
-	int (*frontend_ioctl) (struct dvb_frontend *, unsigned int, void *);
+	struct dvb_frontend*		fe;
 
 	u16			pid[DMX_PES_OTHER];
-	int			hi_band;
-	int			voltage;
 
 	/* USB bits */
 	struct usb_device	*udev;
@@ -161,32 +157,6 @@
 	struct list_head	filter_info_list;
 };
 
-static struct dvb_frontend_info dec2000t_frontend_info = {
-	.name			= "TechnoTrend/Hauppauge DEC2000-t Frontend",
-	.type			= FE_OFDM,
-	.frequency_min		= 51000000,
-	.frequency_max		= 858000000,
-	.frequency_stepsize	= 62500,
-	.caps =	FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-		FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-		FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
-		FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
-		FE_CAN_HIERARCHY_AUTO,
-};
-
-static struct dvb_frontend_info dec3000s_frontend_info = {
-	.name			= "TechnoTrend/Hauppauge DEC3000-s Frontend",
-	.type			= FE_QPSK,
-	.frequency_min		= 950000,
-	.frequency_max		= 2150000,
-	.frequency_stepsize	= 125,
-	.caps =	FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
-		FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-		FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
-		FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
-		FE_CAN_HIERARCHY_AUTO,
-};
-
 static void ttusb_dec_set_model(struct ttusb_dec *dec,
 				enum ttusb_dec_model model);
 
@@ -1100,7 +1070,7 @@
 				 	       &dec->iso_dma_handle);
 
 	memset(dec->iso_buffer, 0,
-	       sizeof(ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT)));
+	       ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT));
 
 	for (i = 0; i < ISO_BUF_COUNT; i++) {
 		struct urb *urb;
@@ -1165,10 +1135,9 @@
 	u16 firmware_csum = 0;
 	u16 firmware_csum_ns;
 	u32 firmware_size_nl;
-#if defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE)
 	u32 crc32_csum, crc32_check, tmp;
-#endif
 	const struct firmware *fw_entry = NULL;
+
 	dprintk("%s\n", __FUNCTION__);
 
 	if (request_firmware(&fw_entry, dec->firmware_name, &dec->udev->dev)) {
@@ -1189,7 +1158,6 @@
 	/* a 32 bit checksum over the first 56 bytes of the DSP Code is stored
 	   at offset 56 of file, so use it to check if the firmware file is
 	   valid. */
-#if defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE)
 	crc32_csum = crc32(~0L, firmware, 56) ^ ~0L;
 	memcpy(&tmp, &firmware[56], 4);
 	crc32_check = htonl(tmp);
@@ -1199,7 +1167,6 @@
 			__FUNCTION__, crc32_csum, crc32_check);
 		return -1;
 	}
-#endif
 	memcpy(idstring, &firmware[36], 20);
 	idstring[20] = '\0';
 	printk(KERN_INFO "ttusb_dec: found DSP code \"%s\".\n", idstring);
@@ -1288,6 +1255,7 @@
 				ttusb_dec_set_model(dec, TTUSB_DEC3000S);
 				break;
 			case 0x00070009:
+			case 0x00070013:
 				ttusb_dec_set_model(dec, TTUSB_DEC2000T);
 				break;
 			case 0x00070011:
@@ -1398,6 +1366,7 @@
 	dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend);
 	dvb_dmxdev_release(&dec->dmxdev);
 	dvb_dmx_release(&dec->demux);
+	if (dec->fe) dvb_unregister_frontend(dec->fe);
 	dvb_unregister_adapter(dec->adapter);
 }
 
@@ -1429,257 +1398,6 @@
 	}
 }
 
-static int ttusb_dec_2000t_frontend_ioctl(struct dvb_frontend *fe, unsigned int cmd,
-				  void *arg)
-{
-	struct ttusb_dec *dec = fe->data;
-
-	dprintk("%s\n", __FUNCTION__);
-
-	switch (cmd) {
-
-	case FE_GET_INFO:
-		dprintk("%s: FE_GET_INFO\n", __FUNCTION__);
-		memcpy(arg, dec->frontend_info,
-		       sizeof (struct dvb_frontend_info));
-		break;
-
-	case FE_READ_STATUS: {
-			fe_status_t *status = (fe_status_t *)arg;
-			dprintk("%s: FE_READ_STATUS\n", __FUNCTION__);
-			*status = FE_HAS_SIGNAL | FE_HAS_VITERBI |
-				  FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK;
-			break;
-		}
-
-	case FE_READ_BER: {
-			u32 *ber = (u32 *)arg;
-			dprintk("%s: FE_READ_BER\n", __FUNCTION__);
-			*ber = 0;
-			return -ENOSYS;
-			break;
-		}
-
-	case FE_READ_SIGNAL_STRENGTH: {
-			dprintk("%s: FE_READ_SIGNAL_STRENGTH\n", __FUNCTION__);
-			*(s32 *)arg = 0xFF;
-			return -ENOSYS;
-			break;
-		}
-
-	case FE_READ_SNR:
-		dprintk("%s: FE_READ_SNR\n", __FUNCTION__);
-		*(s32 *)arg = 0;
-		return -ENOSYS;
-		break;
-
-	case FE_READ_UNCORRECTED_BLOCKS:
-		dprintk("%s: FE_READ_UNCORRECTED_BLOCKS\n", __FUNCTION__);
-		*(u32 *)arg = 0;
-		return -ENOSYS;
-		break;
-
-	case FE_SET_FRONTEND: {
-			struct dvb_frontend_parameters *p =
-				(struct dvb_frontend_parameters *)arg;
-		u8 b[] = { 0x00, 0x00, 0x00, 0x03,
-			   0x00, 0x00, 0x00, 0x00,
-			   0x00, 0x00, 0x00, 0x01,
-			   0x00, 0x00, 0x00, 0xff,
-			   0x00, 0x00, 0x00, 0xff };
-			u32 freq;
-
-			dprintk("%s: FE_SET_FRONTEND\n", __FUNCTION__);
-
-			dprintk("            frequency->%d\n", p->frequency);
-			dprintk("            symbol_rate->%d\n",
-				p->u.qam.symbol_rate);
-			dprintk("            inversion->%d\n", p->inversion);
-
-			freq = htonl(p->frequency / 1000);
-			memcpy(&b[4], &freq, sizeof (u32));
-			ttusb_dec_send_command(dec, 0x71, sizeof(b), b, NULL, NULL);
-
-			break;
-		}
-
-	case FE_GET_FRONTEND:
-		dprintk("%s: FE_GET_FRONTEND\n", __FUNCTION__);
-		break;
-
-	case FE_SLEEP:
-		dprintk("%s: FE_SLEEP\n", __FUNCTION__);
-		return -ENOSYS;
-		break;
-
-	case FE_INIT:
-		dprintk("%s: FE_INIT\n", __FUNCTION__);
-		break;
-
-	default:
-		dprintk("%s: unknown IOCTL (0x%X)\n", __FUNCTION__, cmd);
-		return -EINVAL;
-
-	}
-
-	return 0;
-}
-
-static int ttusb_dec_3000s_frontend_ioctl(struct dvb_frontend *fe,
-					  unsigned int cmd, void *arg)
-{
-	struct ttusb_dec *dec = fe->data;
-
-	dprintk("%s\n", __FUNCTION__);
-
-	switch (cmd) {
-
-	case FE_GET_INFO:
-		dprintk("%s: FE_GET_INFO\n", __FUNCTION__);
-		memcpy(arg, dec->frontend_info,
-		       sizeof (struct dvb_frontend_info));
-		break;
-
-	case FE_READ_STATUS: {
-			fe_status_t *status = (fe_status_t *)arg;
-			dprintk("%s: FE_READ_STATUS\n", __FUNCTION__);
-			*status = FE_HAS_SIGNAL | FE_HAS_VITERBI |
-				  FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK;
-			break;
-		}
-
-	case FE_READ_BER: {
-			u32 *ber = (u32 *)arg;
-			dprintk("%s: FE_READ_BER\n", __FUNCTION__);
-			*ber = 0;
-			return -ENOSYS;
-			break;
-		}
-
-	case FE_READ_SIGNAL_STRENGTH: {
-			dprintk("%s: FE_READ_SIGNAL_STRENGTH\n", __FUNCTION__);
-			*(s32 *)arg = 0xFF;
-			return -ENOSYS;
-			break;
-		}
-
-	case FE_READ_SNR:
-		dprintk("%s: FE_READ_SNR\n", __FUNCTION__);
-		*(s32 *)arg = 0;
-		return -ENOSYS;
-		break;
-
-	case FE_READ_UNCORRECTED_BLOCKS:
-		dprintk("%s: FE_READ_UNCORRECTED_BLOCKS\n", __FUNCTION__);
-		*(u32 *)arg = 0;
-		return -ENOSYS;
-		break;
-
-	case FE_SET_FRONTEND: {
-			struct dvb_frontend_parameters *p =
-				(struct dvb_frontend_parameters *)arg;
-		u8 b[] = { 0x00, 0x00, 0x00, 0x01,
-			   0x00, 0x00, 0x00, 0x00,
-			   0x00, 0x00, 0x00, 0x01,
-			   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, 0x00, 0x00, 0x00 };
-			u32 freq;
-			u32 sym_rate;
-			u32 band;
-		u32 lnb_voltage;
-
-			dprintk("%s: FE_SET_FRONTEND\n", __FUNCTION__);
-
-			dprintk("            frequency->%d\n", p->frequency);
-			dprintk("            symbol_rate->%d\n",
-				p->u.qam.symbol_rate);
-			dprintk("            inversion->%d\n", p->inversion);
-
-		freq = htonl(p->frequency * 1000 +
-		       (dec->hi_band ? LOF_HI : LOF_LO));
-			memcpy(&b[4], &freq, sizeof(u32));
-			sym_rate = htonl(p->u.qam.symbol_rate);
-			memcpy(&b[12], &sym_rate, sizeof(u32));
-			band = htonl(dec->hi_band ? LOF_HI : LOF_LO);
-			memcpy(&b[24], &band, sizeof(u32));
-		lnb_voltage = htonl(dec->voltage);
-		memcpy(&b[28], &lnb_voltage, sizeof(u32));
-
-			ttusb_dec_send_command(dec, 0x71, sizeof(b), b, NULL, NULL);
-
-			break;
-		}
-
-	case FE_GET_FRONTEND:
-		dprintk("%s: FE_GET_FRONTEND\n", __FUNCTION__);
-		break;
-
-	case FE_SLEEP:
-		dprintk("%s: FE_SLEEP\n", __FUNCTION__);
-		return -ENOSYS;
-		break;
-
-	case FE_INIT:
-		dprintk("%s: FE_INIT\n", __FUNCTION__);
-		break;
-
-	case FE_DISEQC_SEND_MASTER_CMD:
-		dprintk("%s: FE_DISEQC_SEND_MASTER_CMD\n", __FUNCTION__);
-		break;
-
-	case FE_DISEQC_SEND_BURST:
-		dprintk("%s: FE_DISEQC_SEND_BURST\n", __FUNCTION__);
-		break;
-
-	case FE_SET_TONE: {
-			fe_sec_tone_mode_t tone = (fe_sec_tone_mode_t)arg;
-			dprintk("%s: FE_SET_TONE\n", __FUNCTION__);
-			dec->hi_band = (SEC_TONE_ON == tone);
-			break;
-		}
-
-	case FE_SET_VOLTAGE:
-		dprintk("%s: FE_SET_VOLTAGE\n", __FUNCTION__);
-		switch ((fe_sec_voltage_t) arg) {
-		case SEC_VOLTAGE_13:
-			dec->voltage = 13;
-			break;
-		case SEC_VOLTAGE_18:
-			dec->voltage = 18;
-			break;
-		default:
-			return -EINVAL;
-			break;
-		}
-		break;
-
-	default:
-		dprintk("%s: unknown IOCTL (0x%X)\n", __FUNCTION__, cmd);
-		return -EINVAL;
-
-	}
-
-	return 0;
-}
-
-static void ttusb_dec_init_frontend(struct ttusb_dec *dec)
-{
-	dec->i2c_bus.adapter = dec->adapter;
-
-	dvb_register_frontend(dec->frontend_ioctl, &dec->i2c_bus, (void *)dec,
-			      dec->frontend_info);
-}
-
-static void ttusb_dec_exit_frontend(struct ttusb_dec *dec)
-{
-	dvb_unregister_frontend(dec->frontend_ioctl, &dec->i2c_bus);
-}
-
 static void ttusb_dec_init_filters(struct ttusb_dec *dec)
 {
 	INIT_LIST_HEAD(&dec->filter_info_list);
@@ -1698,6 +1416,18 @@
 	}
 }
 
+int fe_send_command(struct dvb_frontend* fe, const u8 command,
+		    int param_length, const u8 params[],
+		    int *result_length, u8 cmd_result[])
+{
+	struct ttusb_dec* dec = (struct ttusb_dec*) fe->dvb->priv;
+	return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result);
+}
+
+struct ttusbdecfe_config fe_config = {
+	.send_command = fe_send_command
+};
+
 static int ttusb_dec_probe(struct usb_interface *intf,
 			   const struct usb_device_id *id)
 {
@@ -1739,7 +1469,32 @@
 		return 0;
 	}
 	ttusb_dec_init_dvb(dec);
-	ttusb_dec_init_frontend(dec);
+
+	dec->adapter->priv = dec;
+	switch (id->idProduct) {
+	case 0x1006:
+		dec->fe = ttusbdecfe_dvbs_attach(&fe_config);
+		break;
+
+	case 0x1008:
+	case 0x1009:
+		dec->fe = ttusbdecfe_dvbt_attach(&fe_config);
+		break;
+	}
+
+	if (dec->fe == NULL) {
+		printk("dvb-ttusb-dec: A frontend driver was not found for device %04x/%04x\n",
+		       dec->udev->descriptor.idVendor,
+		       dec->udev->descriptor.idProduct);
+	} else {
+		if (dvb_register_frontend(dec->adapter, dec->fe)) {
+			printk("budget-ci: Frontend registration failed!\n");
+			if (dec->fe->ops->release)
+				dec->fe->ops->release(dec->fe);
+			dec->fe = NULL;
+		}
+	}
+
 	ttusb_dec_init_v_pes(dec);
 	ttusb_dec_init_filters(dec);
 	ttusb_dec_init_tasklet(dec);
@@ -1763,7 +1518,6 @@
 	ttusb_dec_exit_tasklet(dec);
 		ttusb_dec_exit_filters(dec);
 	ttusb_dec_exit_usb(dec);
-		ttusb_dec_exit_frontend(dec);
 	ttusb_dec_exit_dvb(dec);
 	}
 
@@ -1779,22 +1533,16 @@
 	case TTUSB_DEC2000T:
 		dec->model_name = "DEC2000-t";
 		dec->firmware_name = "dvb-ttusb-dec-2000t.fw";
-		dec->frontend_info = &dec2000t_frontend_info;
-		dec->frontend_ioctl = ttusb_dec_2000t_frontend_ioctl;
 		break;
 
 	case TTUSB_DEC2540T:
 		dec->model_name = "DEC2540-t";
 		dec->firmware_name = "dvb-ttusb-dec-2540t.fw";
-		dec->frontend_info = &dec2000t_frontend_info;
-		dec->frontend_ioctl = ttusb_dec_2000t_frontend_ioctl;
 		break;
 
 	case TTUSB_DEC3000S:
 		dec->model_name = "DEC3000-s";
 		dec->firmware_name = "dvb-ttusb-dec-3000s.fw";
-		dec->frontend_info = &dec3000s_frontend_info;
-		dec->frontend_ioctl = ttusb_dec_3000s_frontend_ioctl;
 		break;
 	}
 }
@@ -1840,7 +1588,3 @@
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(usb, ttusb_dec_table);
 
-MODULE_PARM(debug, "i");
-MODULE_PARM_DESC(debug, "Debug level");
-MODULE_PARM(output_pva, "i");
-MODULE_PARM_DESC(output_pva, "Output PVA from dvr device");
diff -Nru a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,255 @@
+/*
+ * TTUSB DEC Frontend Driver
+ *
+ * Copyright (C) 2003-2004 Alex Woods <linux-dvb@giblets.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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "dvb_frontend.h"
+#include "ttusbdecfe.h"
+
+
+#define LOF_HI			10600000
+#define LOF_LO			9750000
+
+struct ttusbdecfe_state {
+
+	struct dvb_frontend_ops ops;
+
+	/* configuration settings */
+	const struct ttusbdecfe_config* config;
+
+	struct dvb_frontend frontend;
+
+	u8 hi_band;
+	u8 voltage;
+};
+
+
+static int ttusbdecfe_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	*status = FE_HAS_SIGNAL | FE_HAS_VITERBI |
+		  FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK;
+
+	return 0;
+}
+
+static int ttusbdecfe_dvbt_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
+	u8 b[] = { 0x00, 0x00, 0x00, 0x03,
+		   0x00, 0x00, 0x00, 0x00,
+		   0x00, 0x00, 0x00, 0x01,
+		   0x00, 0x00, 0x00, 0xff,
+		   0x00, 0x00, 0x00, 0xff };
+
+	u32 freq = htonl(p->frequency / 1000);
+	memcpy(&b[4], &freq, sizeof (u32));
+	state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL);
+
+	return 0;
+}
+
+static int ttusbdecfe_dvbs_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+{
+	struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
+
+	u8 b[] = { 0x00, 0x00, 0x00, 0x01,
+		   0x00, 0x00, 0x00, 0x00,
+		   0x00, 0x00, 0x00, 0x01,
+		   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, 0x00, 0x00, 0x00 };
+	u32 freq;
+	u32 sym_rate;
+	u32 band;
+	u32 lnb_voltage;
+
+	freq = htonl(p->frequency +
+	       (state->hi_band ? LOF_HI : LOF_LO));
+	memcpy(&b[4], &freq, sizeof(u32));
+	sym_rate = htonl(p->u.qam.symbol_rate);
+	memcpy(&b[12], &sym_rate, sizeof(u32));
+	band = htonl(state->hi_band ? LOF_HI : LOF_LO);
+	memcpy(&b[24], &band, sizeof(u32));
+	lnb_voltage = htonl(state->voltage);
+	memcpy(&b[28], &lnb_voltage, sizeof(u32));
+
+	state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL);
+
+	return 0;
+}
+
+static int ttusbdecfe_dvbs_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd)
+{
+	struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
+	u8 b[] = { 0x00, 0xff, 0x00, 0x00,
+		   0x00, 0x00, 0x00, 0x00,
+		   0x00, 0x00 };
+
+	memcpy(&b[4], cmd->msg, cmd->msg_len);
+
+	state->config->send_command(fe, 0x72,
+				    sizeof(b) - (6 - cmd->msg_len), b,
+				    NULL, NULL);
+
+	return 0;
+}
+
+
+static int ttusbdecfe_dvbs_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+{
+	struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
+
+	state->hi_band = (SEC_TONE_ON == tone);
+
+	return 0;
+}
+
+
+static int ttusbdecfe_dvbs_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
+{
+	struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
+
+	switch (voltage) {
+	case SEC_VOLTAGE_13:
+		state->voltage = 13;
+		break;
+	case SEC_VOLTAGE_18:
+		state->voltage = 18;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void ttusbdecfe_release(struct dvb_frontend* fe)
+{
+	struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
+	kfree(state);
+}
+
+static struct dvb_frontend_ops ttusbdecfe_dvbt_ops;
+
+struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* config)
+{
+	struct ttusbdecfe_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	memcpy(&state->ops, &ttusbdecfe_dvbt_ops, sizeof(struct dvb_frontend_ops));
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops ttusbdecfe_dvbs_ops;
+
+struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* config)
+{
+	struct ttusbdecfe_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
+	if (state == NULL) goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->voltage = 0;
+	state->hi_band = 0;
+	memcpy(&state->ops, &ttusbdecfe_dvbs_ops, sizeof(struct dvb_frontend_ops));
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	if (state) kfree(state);
+	return NULL;
+}
+
+static struct dvb_frontend_ops ttusbdecfe_dvbt_ops = {
+
+	.info = {
+		.name			= "TechnoTrend/Hauppauge DEC2000-t Frontend",
+		.type			= FE_OFDM,
+		.frequency_min		= 51000000,
+		.frequency_max		= 858000000,
+		.frequency_stepsize	= 62500,
+		.caps =	FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+			FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+			FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
+			FE_CAN_HIERARCHY_AUTO,
+	},
+
+	.release = ttusbdecfe_release,
+
+	.set_frontend = ttusbdecfe_dvbt_set_frontend,
+
+	.read_status = ttusbdecfe_read_status,
+};
+
+static struct dvb_frontend_ops ttusbdecfe_dvbs_ops = {
+
+	.info = {
+		.name			= "TechnoTrend/Hauppauge DEC3000-s Frontend",
+		.type			= FE_QPSK,
+		.frequency_min		= 950000,
+		.frequency_max		= 2150000,
+		.frequency_stepsize	= 125,
+		.caps =	FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+			FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+			FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
+			FE_CAN_HIERARCHY_AUTO,
+	},
+
+	.release = ttusbdecfe_release,
+
+	.set_frontend = ttusbdecfe_dvbs_set_frontend,
+
+	.read_status = ttusbdecfe_read_status,
+
+	.diseqc_send_master_cmd = ttusbdecfe_dvbs_diseqc_send_master_cmd,
+	.set_voltage = ttusbdecfe_dvbs_set_voltage,
+	.set_tone = ttusbdecfe_dvbs_set_tone,
+};
+
+MODULE_DESCRIPTION("TTUSB DEC DVB-T/S Demodulator driver");
+MODULE_AUTHOR("Alex Woods/Andrew de Quincey");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(ttusbdecfe_dvbt_attach);
+EXPORT_SYMBOL(ttusbdecfe_dvbs_attach);
diff -Nru a/drivers/media/dvb/ttusb-dec/ttusbdecfe.h b/drivers/media/dvb/ttusb-dec/ttusbdecfe.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/dvb/ttusb-dec/ttusbdecfe.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,38 @@
+/*
+ * TTUSB DEC Driver
+ *
+ * Copyright (C) 2003-2004 Alex Woods <linux-dvb@giblets.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 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.
+ *
+ */
+
+#ifndef TTUSBDECFE_H
+#define TTUSBDECFE_H
+
+#include <linux/dvb/frontend.h>
+
+struct ttusbdecfe_config
+{
+	int (*send_command)(struct dvb_frontend* fe, const u8 command,
+			    int param_length, const u8 params[],
+			    int *result_length, u8 cmd_result[]);
+};
+
+extern struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* config);
+
+extern struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* config);
+
+#endif // TTUSBDECFE_H
diff -Nru a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
--- a/drivers/media/video/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/drivers/media/video/Kconfig	2004-12-24 13:37:19 -08:00
@@ -9,8 +9,13 @@
 
 config VIDEO_BT848
 	tristate "BT848 Video For Linux"
-	depends on VIDEO_DEV && PCI && I2C && SOUND
+	depends on VIDEO_DEV && PCI && I2C
 	select I2C_ALGOBIT
+	select FW_LOADER
+	select VIDEO_BTCX
+	select VIDEO_BUF
+	select VIDEO_IR
+	select VIDEO_TUNER
 	---help---
 	  Support for BT848 based frame grabber/overlay boards. This includes
 	  the Miro, Hauppauge and STB boards. Please read the material in
@@ -214,8 +219,8 @@
 	  module will be called zr36120.
 
 config VIDEO_MEYE
-	tristate "Sony Vaio Picturebook Motion Eye Video For Linux (EXPERIMENTAL)"
-	depends on VIDEO_DEV && SONYPI && !HIGHMEM64G
+	tristate "Sony Vaio Picturebook Motion Eye Video For Linux"
+	depends on VIDEO_DEV && PCI && SONYPI
 	---help---
 	  This is the video4linux driver for the Motion Eye camera found
 	  in the Vaio Picturebook laptops. Please read the material in
@@ -230,6 +235,9 @@
 config VIDEO_SAA7134
 	tristate "Philips SAA7134 support"
 	depends on VIDEO_DEV && PCI && I2C
+	select VIDEO_BUF
+	select VIDEO_IR
+	select VIDEO_TUNER
 	---help---
 	  This is a video4linux driver for Philips SAA7130/7134 based
 	  TV cards.
@@ -237,10 +245,18 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called saa7134.
 
+config VIDEO_SAA7134_DVB
+	tristate "DVB Support for saa7134 based TV cards"
+	depends on VIDEO_SAA7134 && DVB_CORE && BROKEN
+	---help---
+	  This adds support for DVB cards based on the
+	  Philips saa7134 chip.
+
 config VIDEO_MXB
 	tristate "Siemens-Nixdorf 'Multimedia eXtension Board'"
 	depends on VIDEO_DEV && PCI
 	select VIDEO_SAA7146_VV
+	select VIDEO_TUNER
 	---help---
 	  This is a video4linux driver for the 'Multimedia eXtension Board'
 	  TV card by Siemens-Nixdorf.
@@ -287,7 +303,11 @@
 
 config VIDEO_CX88
 	tristate "Conexant 2388x (bt878 successor) support"
-	depends on VIDEO_DEV && PCI && I2C_ALGOBIT && EXPERIMENTAL
+	depends on VIDEO_DEV && PCI && EXPERIMENTAL
+	select I2C_ALGOBIT
+	select VIDEO_BTCX
+	select VIDEO_BUF
+	select VIDEO_TUNER
 	---help---
 	  This is a video4linux driver for Conexant 2388x based
 	  TV cards.
@@ -295,6 +315,14 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called cx8800
 
+config VIDEO_CX88_DVB
+	tristate "DVB Support for cx2388x based TV cards"
+	depends on VIDEO_CX88 && DVB_CORE && BROKEN
+	select VIDEO_BUF_DVB
+	---help---
+	  This adds support for DVB cards based on the
+	  Connexant 2388x chip.
+
 config VIDEO_OVCAMCHIP
 	tristate "OmniVision Camera Chip support"
 	depends on VIDEO_DEV && I2C
@@ -306,5 +334,18 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called ovcamchip
 
-endmenu
+config VIDEO_M32R_AR
+	tristate "AR devices"
+	depends on M32R
+	---help---
+	  This is a video4linux driver for the Renesas AR (Artificial Retina)
+	  camera module.
 
+config VIDEO_M32R_AR_M64278
+	tristate "Use Colour AR module M64278(VGA)"
+	depends on VIDEO_M32R_AR
+	---help---
+	  Say Y here to use the Renesas M64278E-800 camera module,
+	  which supports VGA(640x480 pixcels) size of images.
+
+endmenu
diff -Nru a/drivers/media/video/Makefile b/drivers/media/video/Makefile
--- a/drivers/media/video/Makefile	2004-12-24 13:36:47 -08:00
+++ b/drivers/media/video/Makefile	2004-12-24 13:36:47 -08:00
@@ -46,4 +46,9 @@
 
 obj-$(CONFIG_VIDEO_TUNER) += tuner.o tda9887.o
 obj-$(CONFIG_VIDEO_BUF)   += video-buf.o
+obj-$(CONFIG_VIDEO_BUF_DVB) += video-buf-dvb.o
 obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
+
+obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
+
+EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
diff -Nru a/drivers/media/video/arv.c b/drivers/media/video/arv.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/video/arv.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,916 @@
+/*
+ * Colour AR M64278(VGA) driver for Video4Linux
+ *
+ * Copyright (C) 2003	Takeo Takahashi <takahashi.takeo@renesas.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.
+ *
+ * Some code is taken from AR driver sample program for M3T-M32700UT.
+ *
+ * AR driver sample (M32R SDK):
+ *     Copyright (c) 2003 RENESAS TECHNOROGY CORPORATION
+ *     AND RENESAS SOLUTIONS CORPORATION
+ *     All Rights Reserved.
+ *
+ * 2003-09-01:	Support w3cam by Takeo Takahashi
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/devfs_fs_kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/videodev.h>
+
+#include <asm/semaphore.h>
+#include <asm/uaccess.h>
+#include <asm/m32r.h>
+#include <asm/io.h>
+#include <asm/dma.h>
+#include <asm/byteorder.h>
+
+#if 0
+#define DEBUG(n, args...) printk(args)
+#define CHECK_LOST	1
+#else
+#define DEBUG(n, args...)
+#define CHECK_LOST	0
+#endif
+
+/*
+ * USE_INT is always 0, interrupt mode is not available
+ * on linux due to lack of speed
+ */
+#define USE_INT		0	/* Don't modify */
+
+#define VERSION	"0.03"
+
+#define ar_inl(addr) 		inl((unsigned long)(addr))
+#define ar_outl(val, addr)	outl((unsigned long)(val),(unsigned long)(addr))
+
+extern struct cpuinfo_m32r	boot_cpu_data;
+
+/*
+ * CCD pixel size
+ *	Note that M32700UT does not support CIF mode, but QVGA is
+ *	supported by M32700UT hardware using VGA mode of AR LSI.
+ *
+ * 	Supported: VGA  (Normal mode, Interlace mode)
+ *		   QVGA (Always Interlace mode of VGA)
+ *
+ */
+#define AR_WIDTH_VGA		640
+#define AR_HEIGHT_VGA		480
+#define AR_WIDTH_QVGA		320
+#define AR_HEIGHT_QVGA		240
+#define MIN_AR_WIDTH		AR_WIDTH_QVGA
+#define MIN_AR_HEIGHT		AR_HEIGHT_QVGA
+#define MAX_AR_WIDTH		AR_WIDTH_VGA
+#define MAX_AR_HEIGHT		AR_HEIGHT_VGA
+
+/* bits & bytes per pixel */
+#define AR_BITS_PER_PIXEL	16
+#define AR_BYTES_PER_PIXEL	(AR_BITS_PER_PIXEL/8)
+
+/* line buffer size */
+#define AR_LINE_BYTES_VGA	(AR_WIDTH_VGA * AR_BYTES_PER_PIXEL)
+#define AR_LINE_BYTES_QVGA	(AR_WIDTH_QVGA * AR_BYTES_PER_PIXEL)
+#define MAX_AR_LINE_BYTES	AR_LINE_BYTES_VGA
+
+/* frame size & type */
+#define AR_FRAME_BYTES_VGA \
+	(AR_WIDTH_VGA * AR_HEIGHT_VGA * AR_BYTES_PER_PIXEL)
+#define AR_FRAME_BYTES_QVGA \
+	(AR_WIDTH_QVGA * AR_HEIGHT_QVGA * AR_BYTES_PER_PIXEL)
+#define MAX_AR_FRAME_BYTES \
+	(MAX_AR_WIDTH * MAX_AR_HEIGHT * AR_BYTES_PER_PIXEL)
+
+#define AR_MAX_FRAME		15
+
+/* capture size */
+#define AR_SIZE_VGA		0
+#define AR_SIZE_QVGA		1
+
+/* capture mode */
+#define AR_MODE_INTERLACE	0
+#define AR_MODE_NORMAL		1
+
+struct ar_device {
+	struct video_device *vdev;
+	unsigned int start_capture;	/* duaring capture in INT. mode. */
+#if USE_INT
+	unsigned char *line_buff;	/* DMA line buffer */
+#endif
+	unsigned char *frame[MAX_AR_HEIGHT];	/* frame data */
+	short size;			/* capture size */
+	short mode;			/* capture mode */
+	int width, height;
+	int frame_bytes, line_bytes;
+	wait_queue_head_t wait;
+	struct semaphore lock;
+};
+
+static int video_nr = -1;	/* video device number (first free) */
+static unsigned char	yuv[MAX_AR_FRAME_BYTES];
+
+/* module parameters */
+/* default frequency */
+#define DEFAULT_FREQ	50	/* 50 or 75 (MHz) is available as BCLK */
+static int freq = DEFAULT_FREQ;	/* BCLK: available 50 or 70 (MHz) */
+static int vga = 0;		/* default mode(0:QVGA mode, other:VGA mode) */
+static int vga_interlace = 0;	/* 0 is normal mode for, else interlace mode */
+MODULE_PARM(freq, "i");
+MODULE_PARM(vga, "i");
+MODULE_PARM(vga_interlace, "i");
+
+static int ar_initialize(struct video_device *dev);
+
+static inline void wait_for_vsync(void)
+{
+	while (ar_inl(ARVCR0) & ARVCR0_VDS)	/* wait for VSYNC */
+		cpu_relax();
+	while (!(ar_inl(ARVCR0) & ARVCR0_VDS))	/* wait for VSYNC */
+		cpu_relax();
+}
+
+static inline void wait_acknowledge(void)
+{
+	int i;
+
+	for (i = 0; i < 1000; i++)
+		cpu_relax();
+	while (ar_inl(PLDI2CSTS) & PLDI2CSTS_NOACK)
+		cpu_relax();
+}
+
+/*******************************************************************
+ * I2C functions
+ *******************************************************************/
+void iic(int n, unsigned long addr, unsigned long data1, unsigned long data2,
+	 unsigned long data3)
+{
+	int i;
+
+  	/* Slave Address */
+  	ar_outl(addr, PLDI2CDATA);
+	wait_for_vsync();
+
+  	/* Start */
+  	ar_outl(1, PLDI2CCND);
+	wait_acknowledge();
+
+	/* Transfer data 1 */
+  	ar_outl(data1, PLDI2CDATA);
+	wait_for_vsync();
+  	ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
+	wait_acknowledge();
+
+	/* Transfer data 2 */
+  	ar_outl(data2, PLDI2CDATA);
+	wait_for_vsync();
+  	ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
+	wait_acknowledge();
+
+	if (n == 3) {
+		/* Transfer data 3 */
+	  	ar_outl(data3, PLDI2CDATA);
+		wait_for_vsync();
+	  	ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
+		wait_acknowledge();
+  	}
+
+  	/* Stop */
+	for (i = 0; i < 100; i++)
+		cpu_relax();
+  	ar_outl(2, PLDI2CCND);
+  	ar_outl(2, PLDI2CCND);
+
+	while (ar_inl(PLDI2CSTS) & PLDI2CSTS_BB)
+		cpu_relax();
+}
+
+
+void init_iic(void)
+{
+	DEBUG(1, "init_iic:\n");
+
+  	/*
+	 * ICU Setting (iic)
+	 */
+  	/* I2C Setting */
+  	ar_outl(0x0, PLDI2CCR);      	/* I2CCR Disable                   */
+  	ar_outl(0x0300, PLDI2CMOD); 	/* I2CMOD ACK/8b-data/7b-addr/auto */
+  	ar_outl(0x1, PLDI2CACK);	/* I2CACK ACK                      */
+
+    	/* I2C CLK */
+   	/* 50MH-100k */
+	if (freq == 75) {
+  		ar_outl(369, PLDI2CFREQ);	/* BCLK = 75MHz */
+	} else if (freq == 50) {
+		ar_outl(244, PLDI2CFREQ);	/* BCLK = 50MHz */
+	} else {
+		ar_outl(244, PLDI2CFREQ);	/* default: BCLK = 50MHz */
+	}
+  	ar_outl(0x1, PLDI2CCR); 	/* I2CCR Enable */
+}
+
+/**************************************************************************
+ *
+ * Video4Linux Interface functions
+ *
+ **************************************************************************/
+
+static inline void disable_dma(void)
+{
+	ar_outl(0x8000, M32R_DMAEN_PORTL);	/* disable DMA0 */
+}
+
+static inline void enable_dma(void)
+{
+	ar_outl(0x8080, M32R_DMAEN_PORTL);	/* enable DMA0 */
+}
+
+static inline void clear_dma_status(void)
+{
+	ar_outl(0x8000, M32R_DMAEDET_PORTL);	/* clear status */
+}
+
+static inline void wait_for_vertical_sync(int exp_line)
+{
+#if CHECK_LOST
+	int tmout = 10000;	/* FIXME */
+	int l;
+
+	/*
+	 * check HCOUNT because we cannot check vertical sync.
+ 	 */
+	for (; tmout >= 0; tmout--) {
+		l = ar_inl(ARVHCOUNT);
+		if (l == exp_line)
+			break;
+	}
+	if (tmout < 0)
+		printk("arv: lost %d -> %d\n", exp_line, l);
+#else
+	while (ar_inl(ARVHCOUNT) != exp_line)
+		cpu_relax();
+#endif
+}
+
+static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+	struct video_device *v = video_devdata(file);
+	struct ar_device *ar = v->priv;
+	long ret = ar->frame_bytes;		/* return read bytes */
+	unsigned long arvcr1 = 0;
+	unsigned long flags;
+	unsigned char *p;
+	int h, w;
+	unsigned char *py, *pu, *pv;
+#if ! USE_INT
+	int l;
+#endif
+
+	DEBUG(1, "ar_read()\n");
+
+	if (ar->size == AR_SIZE_QVGA)
+		arvcr1 |= ARVCR1_QVGA;
+	if (ar->mode == AR_MODE_NORMAL)
+		arvcr1 |= ARVCR1_NORMAL;
+
+	down(&ar->lock);
+
+#if USE_INT
+	local_irq_save(flags);
+	disable_dma();
+	ar_outl(0xa1871300, M32R_DMA0CR0_PORTL);
+	ar_outl(0x01000000, M32R_DMA0CR1_PORTL);
+
+	/* set AR FIFO address as source(BSEL5) */
+	ar_outl(ARDATA32, M32R_DMA0CSA_PORTL);
+	ar_outl(ARDATA32, M32R_DMA0RSA_PORTL);
+	ar_outl(ar->line_buff, M32R_DMA0CDA_PORTL);	/* destination addr. */
+	ar_outl(ar->line_buff, M32R_DMA0RDA_PORTL); 	/* reload address */
+	ar_outl(ar->line_bytes, M32R_DMA0CBCUT_PORTL); 	/* byte count (bytes) */
+	ar_outl(ar->line_bytes, M32R_DMA0RBCUT_PORTL); 	/* reload count (bytes) */
+
+	/*
+	 * Okey , kicks AR LSI to invoke an interrupt
+	 */
+	ar->start_capture = 0;
+	ar_outl(arvcr1 | ARVCR1_HIEN, ARVCR1);
+	local_irq_restore(flags);
+	/* .... AR interrupts .... */
+	interruptible_sleep_on(&ar->wait);
+	if (signal_pending(current)) {
+		printk("arv: interrupted while get frame data.\n");
+		ret = -EINTR;
+		goto out_up;
+	}
+#else	/* ! USE_INT */
+	/* polling */
+	ar_outl(arvcr1, ARVCR1);
+	disable_dma();
+	ar_outl(0x8000, M32R_DMAEDET_PORTL);
+	ar_outl(0xa0861300, M32R_DMA0CR0_PORTL);
+	ar_outl(0x01000000, M32R_DMA0CR1_PORTL);
+	ar_outl(ARDATA32, M32R_DMA0CSA_PORTL);
+	ar_outl(ARDATA32, M32R_DMA0RSA_PORTL);
+	ar_outl(ar->line_bytes, M32R_DMA0CBCUT_PORTL);
+	ar_outl(ar->line_bytes, M32R_DMA0RBCUT_PORTL);
+
+	local_irq_save(flags);
+	while (ar_inl(ARVHCOUNT) != 0)		/* wait for 0 */
+		cpu_relax();
+	if (ar->mode == AR_MODE_INTERLACE && ar->size == AR_SIZE_VGA) {
+		for (h = 0; h < ar->height; h++) {
+			wait_for_vertical_sync(h);
+			if (h < (AR_HEIGHT_VGA/2))
+				l = h << 1;
+			else
+				l = (((h - (AR_HEIGHT_VGA/2)) << 1) + 1);
+			ar_outl(virt_to_phys(ar->frame[l]), M32R_DMA0CDA_PORTL);
+			enable_dma();
+			while (!(ar_inl(M32R_DMAEDET_PORTL) & 0x8000))
+				cpu_relax();
+			disable_dma();
+			clear_dma_status();
+			ar_outl(0xa0861300, M32R_DMA0CR0_PORTL);
+		}
+	} else {
+		for (h = 0; h < ar->height; h++) {
+			wait_for_vertical_sync(h);
+			ar_outl(virt_to_phys(ar->frame[h]), M32R_DMA0CDA_PORTL);
+			enable_dma();
+			while (!(ar_inl(M32R_DMAEDET_PORTL) & 0x8000))
+				cpu_relax();
+			disable_dma();
+			clear_dma_status();
+			ar_outl(0xa0861300, M32R_DMA0CR0_PORTL);
+		}
+	}
+	local_irq_restore(flags);
+#endif	/* ! USE_INT */
+
+	/*
+	 * convert YUV422 to YUV422P
+	 * 	+--------------------+
+	 *	|  Y0,Y1,...	     |
+	 *	|  ..............Yn  |
+	 *	+--------------------+
+	 *	|  U0,U1,........Un  |
+	 *	+--------------------+
+	 *	|  V0,V1,........Vn  |
+	 *	+--------------------+
+	 */
+	py = yuv;
+	pu = py + (ar->frame_bytes / 2);
+	pv = pu + (ar->frame_bytes / 4);
+	for (h = 0; h < ar->height; h++) {
+		p = ar->frame[h];
+		for (w = 0; w < ar->line_bytes; w += 4) {
+			*py++ = *p++;
+			*pu++ = *p++;
+			*py++ = *p++;
+			*pv++ = *p++;
+		}
+	}
+	if (copy_to_user(buf, yuv, ar->frame_bytes)) {
+		printk("arv: failed while copy_to_user yuv.\n");
+		ret = -EFAULT;
+		goto out_up;
+	}
+	DEBUG(1, "ret = %d\n", ret);
+out_up:
+	up(&ar->lock);
+	return ret;
+}
+
+static int ar_do_ioctl(struct inode *inode, struct file *file,
+		       unsigned int cmd, void *arg)
+{
+	struct video_device *dev = video_devdata(file);
+	struct ar_device *ar = dev->priv;
+
+	DEBUG(1, "ar_ioctl()\n");
+	switch(cmd) {
+	case VIDIOCGCAP:
+	{
+		struct video_capability *b = arg;
+		DEBUG(1, "VIDIOCGCAP:\n");
+		strcpy(b->name, ar->vdev->name);
+		b->type = VID_TYPE_CAPTURE;
+		b->channels = 0;
+		b->audios = 0;
+		b->maxwidth = MAX_AR_WIDTH;
+		b->maxheight = MAX_AR_HEIGHT;
+		b->minwidth = MIN_AR_WIDTH;
+		b->minheight = MIN_AR_HEIGHT;
+		return 0;
+	}
+	case VIDIOCGCHAN:
+		DEBUG(1, "VIDIOCGCHAN:\n");
+		return 0;
+	case VIDIOCSCHAN:
+		DEBUG(1, "VIDIOCSCHAN:\n");
+		return 0;
+	case VIDIOCGTUNER:
+		DEBUG(1, "VIDIOCGTUNER:\n");
+		return 0;
+	case VIDIOCSTUNER:
+		DEBUG(1, "VIDIOCSTUNER:\n");
+		return 0;
+	case VIDIOCGPICT:
+		DEBUG(1, "VIDIOCGPICT:\n");
+		return 0;
+	case VIDIOCSPICT:
+		DEBUG(1, "VIDIOCSPICT:\n");
+		return 0;
+	case VIDIOCCAPTURE:
+		DEBUG(1, "VIDIOCCAPTURE:\n");
+		return -EINVAL;
+	case VIDIOCGWIN:
+	{
+		struct video_window *w = arg;
+		DEBUG(1, "VIDIOCGWIN:\n");
+		memset(w, 0, sizeof(w));
+		w->width = ar->width;
+		w->height = ar->height;
+		return 0;
+	}
+	case VIDIOCSWIN:
+	{
+		struct video_window *w = arg;
+		DEBUG(1, "VIDIOCSWIN:\n");
+		if ((w->width != AR_WIDTH_VGA || w->height != AR_HEIGHT_VGA) &&
+		    (w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA))
+				return -EINVAL;
+
+		down(&ar->lock);
+		ar->width = w->width;
+		ar->height = w->height;
+		if (ar->width == AR_WIDTH_VGA) {
+			ar->size = AR_SIZE_VGA;
+			ar->frame_bytes = AR_FRAME_BYTES_VGA;
+			ar->line_bytes = AR_LINE_BYTES_VGA;
+			if (vga_interlace)
+				ar->mode = AR_MODE_INTERLACE;
+			else
+				ar->mode = AR_MODE_NORMAL;
+		} else {
+			ar->size = AR_SIZE_QVGA;
+			ar->frame_bytes = AR_FRAME_BYTES_QVGA;
+			ar->line_bytes = AR_LINE_BYTES_QVGA;
+			ar->mode = AR_MODE_INTERLACE;
+		}
+		up(&ar->lock);
+		return 0;
+	}
+	case VIDIOCGFBUF:
+		DEBUG(1, "VIDIOCGFBUF:\n");
+		return -EINVAL;
+	case VIDIOCSFBUF:
+		DEBUG(1, "VIDIOCSFBUF:\n");
+		return -EINVAL;
+	case VIDIOCKEY:
+		DEBUG(1, "VIDIOCKEY:\n");
+		return 0;
+	case VIDIOCGFREQ:
+		DEBUG(1, "VIDIOCGFREQ:\n");
+		return -EINVAL;
+	case VIDIOCSFREQ:
+		DEBUG(1, "VIDIOCSFREQ:\n");
+		return -EINVAL;
+	case VIDIOCGAUDIO:
+		DEBUG(1, "VIDIOCGAUDIO:\n");
+		return -EINVAL;
+	case VIDIOCSAUDIO:
+		DEBUG(1, "VIDIOCSAUDIO:\n");
+		return -EINVAL;
+	case VIDIOCSYNC:
+		DEBUG(1, "VIDIOCSYNC:\n");
+		return -EINVAL;
+	case VIDIOCMCAPTURE:
+		DEBUG(1, "VIDIOCMCAPTURE:\n");
+		return -EINVAL;
+	case VIDIOCGMBUF:
+		DEBUG(1, "VIDIOCGMBUF:\n");
+		return -EINVAL;
+	case VIDIOCGUNIT:
+		DEBUG(1, "VIDIOCGUNIT:\n");
+		return -EINVAL;
+	case VIDIOCGCAPTURE:
+		DEBUG(1, "VIDIOCGCAPTURE:\n");
+		return -EINVAL;
+	case VIDIOCSCAPTURE:
+		DEBUG(1, "VIDIOCSCAPTURE:\n");
+		return -EINVAL;
+	case VIDIOCSPLAYMODE:
+		DEBUG(1, "VIDIOCSPLAYMODE:\n");
+		return -EINVAL;
+	case VIDIOCSWRITEMODE:
+		DEBUG(1, "VIDIOCSWRITEMODE:\n");
+		return -EINVAL;
+	case VIDIOCGPLAYINFO:
+		DEBUG(1, "VIDIOCGPLAYINFO:\n");
+		return -EINVAL;
+	case VIDIOCSMICROCODE:
+		DEBUG(1, "VIDIOCSMICROCODE:\n");
+		return -EINVAL;
+	case VIDIOCGVBIFMT:
+		DEBUG(1, "VIDIOCGVBIFMT:\n");
+		return -EINVAL;
+	case VIDIOCSVBIFMT:
+		DEBUG(1, "VIDIOCSVBIFMT:\n");
+		return -EINVAL;
+	default:
+		DEBUG(1, "Unknown ioctl(0x%08x)\n", cmd);
+		return -ENOIOCTLCMD;
+	}
+	return 0;
+}
+
+static int ar_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+		    unsigned long arg)
+{
+	return video_usercopy(inode, file, cmd, arg, ar_do_ioctl);
+}
+
+#if USE_INT
+/*
+ * Interrupt handler
+ */
+static void ar_interrupt(int irq, void *dev, struct pt_regs *regs)
+{
+	struct ar_device *ar = dev;
+	unsigned int line_count;
+	unsigned int line_number;
+	unsigned int arvcr1;
+
+	line_count = ar_inl(ARVHCOUNT);			/* line number */
+	if (ar->mode == AR_MODE_INTERLACE && ar->size == AR_SIZE_VGA) {
+		/* operations for interlace mode */
+		if ( line_count < (AR_HEIGHT_VGA/2) ) 	/* even line */
+			line_number = (line_count << 1);
+		else 		  			/* odd line */
+ 			line_number =
+			(((line_count - (AR_HEIGHT_VGA/2)) << 1) + 1);
+	} else {
+		line_number = line_count;
+	}
+
+	if (line_number == 0) {
+		/*
+		 * It is an interrupt for line 0.
+		 * we have to start capture.
+		 */
+		disable_dma();
+#if 0
+		ar_outl(ar->line_buff, M32R_DMA0CDA_PORTL);	/* needless? */
+#endif
+		memcpy(ar->frame[0], ar->line_buff, ar->line_bytes);
+#if 0
+		ar_outl(0xa1861300, M32R_DMA0CR0_PORTL);
+#endif
+		enable_dma();
+		ar->start_capture = 1;			/* during capture */
+		return;
+	}
+
+	if (ar->start_capture == 1 && line_number <= (ar->height - 1)) {
+		disable_dma();
+		memcpy(ar->frame[line_number], ar->line_buff, ar->line_bytes);
+
+		/*
+		 * if captured all line of a frame, disable AR interrupt
+		 * and wake a process up.
+		 */
+		if (line_number == (ar->height - 1)) { 	/* end  of line */
+
+			ar->start_capture = 0;
+
+			/* disable AR interrupt request */
+			arvcr1 = ar_inl(ARVCR1);
+			arvcr1 &= ~ARVCR1_HIEN;		/* clear int. flag */
+			ar_outl(arvcr1, ARVCR1);	/* disable */
+			wake_up_interruptible(&ar->wait);
+		} else {
+#if 0
+			ar_outl(ar->line_buff, M32R_DMA0CDA_PORTL);
+			ar_outl(0xa1861300, M32R_DMA0CR0_PORTL);
+#endif
+			enable_dma();
+		}
+	}
+}
+#endif
+
+/*
+ * ar_initialize()
+ * 	ar_initialize() is called by video_register_device() and
+ *	initializes AR LSI and peripherals.
+ *
+ *	-1 is returned in all failures.
+ *	0 is returned in success.
+ *
+ */
+static int ar_initialize(struct video_device *dev)
+{
+	struct ar_device *ar = (struct ar_device *)dev->priv;
+	unsigned long cr = 0;
+	int i,found=0;
+
+	DEBUG(1, "ar_initialize:\n");
+
+	/*
+	 * initialize AR LSI
+	 */
+	ar_outl(0, ARVCR0);		/* assert reset of AR LSI */
+	for (i = 0; i < 0x18; i++)	/* wait for over 10 cycles @ 27MHz */
+		cpu_relax();
+	ar_outl(ARVCR0_RST, ARVCR0);	/* negate reset of AR LSI (enable) */
+	for (i = 0; i < 0x40d; i++)	/* wait for over 420 cycles @ 27MHz */
+		cpu_relax();
+
+	/* AR uses INT3 of CPU as interrupt pin. */
+	ar_outl(ARINTSEL_INT3, ARINTSEL);
+
+	if (ar->size == AR_SIZE_QVGA)
+		cr |= ARVCR1_QVGA;
+	if (ar->mode == AR_MODE_NORMAL)
+		cr |= ARVCR1_NORMAL;
+	ar_outl(cr, ARVCR1);
+
+  	/*
+	 * Initialize IIC so that CPU can communicate with AR LSI,
+	 * and send boot commands to AR LSI.
+	 */
+	init_iic();
+
+	for (i = 0; i < 0x100000; i++) {	/* > 0xa1d10,  56ms */
+		if ((ar_inl(ARVCR0) & ARVCR0_VDS)) {	/* VSYNC */
+			found = 1;
+			break;
+		}
+	}
+
+	if (found == 0)
+		return -ENODEV;
+
+	printk("arv: Initializing ");
+
+	iic(2,0x78,0x11,0x01,0x00);	/* start */
+	iic(3,0x78,0x12,0x00,0x06);
+	iic(3,0x78,0x12,0x12,0x30);
+	iic(3,0x78,0x12,0x15,0x58);
+	iic(3,0x78,0x12,0x17,0x30);
+	printk(".");
+	iic(3,0x78,0x12,0x1a,0x97);
+	iic(3,0x78,0x12,0x1b,0xff);
+	iic(3,0x78,0x12,0x1c,0xff);
+	iic(3,0x78,0x12,0x26,0x10);
+	iic(3,0x78,0x12,0x27,0x00);
+	printk(".");
+	iic(2,0x78,0x34,0x02,0x00);
+	iic(2,0x78,0x7a,0x10,0x00);
+	iic(2,0x78,0x80,0x39,0x00);
+	iic(2,0x78,0x81,0xe6,0x00);
+	iic(2,0x78,0x8d,0x00,0x00);
+	printk(".");
+	iic(2,0x78,0x8e,0x0c,0x00);
+	iic(2,0x78,0x8f,0x00,0x00);
+#if 0
+	iic(2,0x78,0x90,0x00,0x00);	/* AWB on=1 off=0 */
+#endif
+	iic(2,0x78,0x93,0x01,0x00);
+	iic(2,0x78,0x94,0xcd,0x00);
+	iic(2,0x78,0x95,0x00,0x00);
+	printk(".");
+	iic(2,0x78,0x96,0xa0,0x00);
+	iic(2,0x78,0x97,0x00,0x00);
+	iic(2,0x78,0x98,0x60,0x00);
+	iic(2,0x78,0x99,0x01,0x00);
+	iic(2,0x78,0x9a,0x19,0x00);
+	printk(".");
+	iic(2,0x78,0x9b,0x02,0x00);
+	iic(2,0x78,0x9c,0xe8,0x00);
+	iic(2,0x78,0x9d,0x02,0x00);
+	iic(2,0x78,0x9e,0x2e,0x00);
+	iic(2,0x78,0xb8,0x78,0x00);
+	iic(2,0x78,0xba,0x05,0x00);
+#if 0
+	iic(2,0x78,0x83,0x8c,0x00);	/* brightness */
+#endif
+	printk(".");
+
+	/* color correction */
+	iic(3,0x78,0x49,0x00,0x95);	/* a		*/
+	iic(3,0x78,0x49,0x01,0x96);	/* b		*/
+	iic(3,0x78,0x49,0x03,0x85);	/* c		*/
+	iic(3,0x78,0x49,0x04,0x97);	/* d		*/
+	iic(3,0x78,0x49,0x02,0x7e);	/* e(Lo)	*/
+	iic(3,0x78,0x49,0x05,0xa4);	/* f(Lo)	*/
+	iic(3,0x78,0x49,0x06,0x04);	/* e(Hi)	*/
+	iic(3,0x78,0x49,0x07,0x04);	/* e(Hi)	*/
+	iic(2,0x78,0x48,0x01,0x00);	/* on=1 off=0	*/
+
+	printk(".");
+	iic(2,0x78,0x11,0x00,0x00);	/* end */
+	printk(" done\n");
+	return 0;
+}
+
+
+void ar_release(struct video_device *vfd)
+{
+	struct ar_device *ar = vfd->priv;
+	down(&ar->lock);
+	video_device_release(vfd);
+}
+
+/****************************************************************************
+ *
+ * Video4Linux Module functions
+ *
+ ****************************************************************************/
+static struct file_operations ar_fops = {
+	.owner		= THIS_MODULE,
+	.open		= video_exclusive_open,
+	.release	= video_exclusive_release,
+	.read		= ar_read,
+	.ioctl		= ar_ioctl,
+	.llseek		= no_llseek,
+};
+
+static struct video_device ar_template = {
+	.owner		= THIS_MODULE,
+	.name		= "Colour AR VGA",
+	.type		= VID_TYPE_CAPTURE,
+	.hardware	= VID_HARDWARE_ARV,
+	.fops		= &ar_fops,
+	.release	= ar_release,
+	.minor		= -1,
+};
+
+#define ALIGN4(x)	((((int)(x)) & 0x3) == 0)
+static struct ar_device ardev;
+
+static int __init ar_init(void)
+{
+	struct ar_device *ar;
+	int ret;
+	int i;
+
+	DEBUG(1, "ar_init:\n");
+	ret = -EIO;
+	printk(KERN_INFO "arv: Colour AR VGA driver %s\n", VERSION);
+
+	ar = &ardev;
+	memset(ar, 0, sizeof(struct ar_device));
+
+#if USE_INT
+	/* allocate a DMA buffer for 1 line.  */
+	ar->line_buff = kmalloc(MAX_AR_LINE_BYTES, GFP_KERNEL | GFP_DMA);
+	if (ar->line_buff == NULL || ! ALIGN4(ar->line_buff)) {
+		printk("arv: buffer allocation failed for DMA.\n");
+		ret = -ENOMEM;
+		goto out_end;
+	}
+#endif
+	/* allocate buffers for a frame */
+	for (i = 0; i < MAX_AR_HEIGHT; i++) {
+		ar->frame[i] = kmalloc(MAX_AR_LINE_BYTES, GFP_KERNEL);
+		if (ar->frame[i] == NULL || ! ALIGN4(ar->frame[i])) {
+			printk("arv: buffer allocation failed for frame.\n");
+			ret = -ENOMEM;
+			goto out_line_buff;
+		}
+	}
+
+	ar->vdev = video_device_alloc();
+	if (!ar->vdev) {
+		printk(KERN_ERR "arv: video_device_alloc() failed\n");
+		return -ENOMEM;
+	}
+	memcpy(ar->vdev, &ar_template, sizeof(ar_template));
+	ar->vdev->priv = ar;
+
+	if (vga) {
+		ar->width 	= AR_WIDTH_VGA;
+		ar->height 	= AR_HEIGHT_VGA;
+		ar->size 	= AR_SIZE_VGA;
+		ar->frame_bytes = AR_FRAME_BYTES_VGA;
+		ar->line_bytes	= AR_LINE_BYTES_VGA;
+		if (vga_interlace)
+			ar->mode = AR_MODE_INTERLACE;
+		else
+			ar->mode = AR_MODE_NORMAL;
+	} else {
+		ar->width 	= AR_WIDTH_QVGA;
+		ar->height 	= AR_HEIGHT_QVGA;
+		ar->size 	= AR_SIZE_QVGA;
+		ar->frame_bytes = AR_FRAME_BYTES_QVGA;
+		ar->line_bytes	= AR_LINE_BYTES_QVGA;
+		ar->mode	= AR_MODE_INTERLACE;
+	}
+	init_MUTEX(&ar->lock);
+	init_waitqueue_head(&ar->wait);
+
+#if USE_INT
+	if (request_irq(M32R_IRQ_INT3, ar_interrupt, 0, "arv", ar)) {
+		printk("arv: request_irq(%d) failed.\n", M32R_IRQ_INT3);
+		ret = -EIO;
+		goto out_irq;
+	}
+#endif
+
+	if (ar_initialize(ar->vdev) != 0) {
+		printk("arv: M64278 not found.\n");
+		ret = -ENODEV;
+		goto out_dev;
+	}
+
+	/*
+	 * ok, we can initialize h/w according to parameters,
+	 * so register video device as a frame grabber type.
+	 * device is named "video[0-64]".
+	 * video_register_device() initializes h/w using ar_initialize().
+ 	 */
+	if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) {
+		/* return -1, -ENFILE(full) or others */
+		printk("arv: register video (Colour AR) failed.\n");
+		ret = -ENODEV;
+		goto out_dev;
+	}
+
+	printk("video%d: Found M64278 VGA (IRQ %d, Freq %dMHz).\n",
+		ar->vdev->minor, M32R_IRQ_INT3, freq);
+
+	return 0;
+
+out_dev:
+#if USE_INT
+	free_irq(M32R_IRQ_INT3, ar);
+
+out_irq:
+#endif
+	for (i = 0; i < MAX_AR_HEIGHT; i++) {
+		if (ar->frame[i])
+			kfree(ar->frame[i]);
+	}
+
+out_line_buff:
+#if USE_INT
+	kfree(ar->line_buff);
+
+out_end:
+#endif
+	return ret;
+}
+
+
+static int __init ar_init_module(void)
+{
+	freq = (boot_cpu_data.bus_clock / 1000000);
+	printk("arv: Bus clock %d\n", freq);
+	if (freq != 50 && freq != 75)
+		freq = DEFAULT_FREQ;
+	return ar_init();
+}
+
+static void __exit ar_cleanup_module(void)
+{
+	struct ar_device *ar;
+	int i;
+
+	ar = &ardev;
+	video_unregister_device(ar->vdev);
+#if USE_INT
+	free_irq(M32R_IRQ_INT3, ar);
+#endif
+	for (i = 0; i < MAX_AR_HEIGHT; i++) {
+		if (ar->frame[i])
+			kfree(ar->frame[i]);
+	}
+#if USE_INT
+	kfree(ar->line_buff);
+#endif
+}
+
+module_init(ar_init_module);
+module_exit(ar_cleanup_module);
+
+MODULE_AUTHOR("Takeo Takahashi <takahashi.takeo@renesas.com>");
+MODULE_DESCRIPTION("Colour AR M64278(VGA) for Video4Linux");
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/media/video/bt848.h b/drivers/media/video/bt848.h
--- a/drivers/media/video/bt848.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/video/bt848.h	2004-12-24 13:36:31 -08:00
@@ -1,4 +1,4 @@
-/* 
+/*
     bt848.h - Bt848 register offsets
 
     Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
@@ -22,10 +22,10 @@
 #define _BT848_H_
 
 #ifndef PCI_VENDOR_ID_BROOKTREE
-#define PCI_VENDOR_ID_BROOKTREE 0x109e 
+#define PCI_VENDOR_ID_BROOKTREE 0x109e
 #endif
 #ifndef PCI_DEVICE_ID_BT848
-#define PCI_DEVICE_ID_BT848     0x350	
+#define PCI_DEVICE_ID_BT848     0x350
 #endif
 #ifndef PCI_DEVICE_ID_BT849
 #define PCI_DEVICE_ID_BT849     0x351
@@ -50,7 +50,7 @@
 #define BT848_DSTATUS_LOF      (1<<1)
 #define BT848_DSTATUS_COF      (1<<0)
 
-#define BT848_IFORM            0x004  
+#define BT848_IFORM            0x004
 #define BT848_IFORM_HACTIVE    (1<<7)
 #define BT848_IFORM_MUXSEL     (3<<5)
 #define BT848_IFORM_MUX0       (2<<5)
@@ -71,7 +71,7 @@
 #define BT848_IFORM_AUTO       0
 #define BT848_IFORM_NORM       7
 
-#define BT848_TDEC             0x008  
+#define BT848_TDEC             0x008
 #define BT848_TDEC_DEC_FIELD   (1<<7)
 #define BT848_TDEC_FLDALIGN    (1<<6)
 #define BT848_TDEC_DEC_RAT     (0x1f)
diff -Nru a/drivers/media/video/btcx-risc.c b/drivers/media/video/btcx-risc.c
--- a/drivers/media/video/btcx-risc.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/media/video/btcx-risc.c	2004-12-24 13:36:16 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: btcx-risc.c,v 1.4 2004/11/07 13:17:14 kraxel Exp $
+
     btcx-risc.c
 
     bt848/bt878/cx2388x risc code generator.
@@ -36,7 +38,7 @@
 MODULE_LICENSE("GPL");
 
 static unsigned int debug = 0;
-MODULE_PARM(debug,"i");
+module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug,"debug messages, default is 0 (no)");
 
 /* ---------------------------------------------------------- */
@@ -187,7 +189,7 @@
 {
 	unsigned int clip,skip;
 	int end,maxline;
-	
+
 	skip=0;
 	maxline = 9999;
 	for (clip = 0; clip < nclips; clip++) {
@@ -197,7 +199,7 @@
 			continue;
 		if (clips[clip].c.left > (signed)width)
 			break;
-		
+
 		/* vertical range */
 		if (line > clips[clip].c.top+clips[clip].c.height-1)
 			continue;
diff -Nru a/drivers/media/video/btcx-risc.h b/drivers/media/video/btcx-risc.h
--- a/drivers/media/video/btcx-risc.h	2004-12-24 13:37:44 -08:00
+++ b/drivers/media/video/btcx-risc.h	2004-12-24 13:37:44 -08:00
@@ -1,4 +1,6 @@
-
+/*
+ * $Id: btcx-risc.h,v 1.2 2004/09/15 16:15:24 kraxel Exp $
+ */
 struct btcx_riscmem {
 	unsigned int   size;
 	u32            *cpu;
diff -Nru a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
--- a/drivers/media/video/bttv-cards.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/media/video/bttv-cards.c	2004-12-24 13:36:49 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: bttv-cards.c,v 1.32 2004/11/07 13:17:14 kraxel Exp $
+
     bttv-cards.c
 
     this file has configuration informations - card-specific stuff
@@ -104,53 +106,31 @@
 static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET };
 
 /* insmod options */
-MODULE_PARM(triton1,"i");
+module_param(triton1,    int, 0444);
+module_param(vsfx,       int, 0444);
+module_param(no_overlay, int, 0444);
+module_param(latency,    int, 0444);
+module_param(gpiomask,   int, 0444);
+module_param(audioall,   int, 0444);
+module_param(autoload,   int, 0444);
+
+module_param_array(card,     int, NULL, 0444);
+module_param_array(pll,      int, NULL, 0444);
+module_param_array(tuner,    int, NULL, 0444);
+module_param_array(svhs,     int, NULL, 0444);
+module_param_array(remote,   int, NULL, 0444);
+module_param_array(audiomux, int, NULL, 0444);
+
 MODULE_PARM_DESC(triton1,"set ETBF pci config bit "
 		 "[enable bug compatibility for triton1 + others]");
-MODULE_PARM(vsfx,"i");
 MODULE_PARM_DESC(vsfx,"set VSFX pci config bit "
 		 "[yet another chipset flaw workaround]");
-MODULE_PARM(no_overlay,"i");
-MODULE_PARM(latency,"i");
 MODULE_PARM_DESC(latency,"pci latency timer");
-MODULE_PARM(card,"1-" __stringify(BTTV_MAX) "i");
 MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list");
-MODULE_PARM(pll,"1-" __stringify(BTTV_MAX) "i");
 MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
-MODULE_PARM(tuner,"1-" __stringify(BTTV_MAX) "i");
 MODULE_PARM_DESC(tuner,"specify installed tuner type");
-MODULE_PARM(autoload,"i");
 MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)");
 
-MODULE_PARM(svhs,"1-" __stringify(BTTV_MAX) "i");
-MODULE_PARM(remote,"1-" __stringify(BTTV_MAX) "i");
-
-MODULE_PARM(gpiomask,"i");
-MODULE_PARM(audioall,"i");
-MODULE_PARM(audiomux,"1-6i");
-
-/* kernel args */
-#ifndef MODULE
-static int __init p_card(char *str)  { return bttv_parse(str,BTTV_MAX,card);  }
-static int __init p_pll(char *str)   { return bttv_parse(str,BTTV_MAX,pll);   }
-static int __init p_tuner(char *str) { return bttv_parse(str,BTTV_MAX,tuner); }
-__setup("bttv.card=",  p_card);
-__setup("bttv.pll=",   p_pll);
-__setup("bttv.tuner=", p_tuner);
-
-int __init bttv_parse(char *str, int max, int *vals)
-{
-	int i,number,res = 2;
-	
-	for (i = 0; res == 2 && i < max; i++) {
-		res = get_option(&str,&number);
-		if (res)
-			vals[i] = number;
-	}
-	return 1;
-}
-#endif
-
 /* ----------------------------------------------------------------------- */
 /* list of card IDs for bt878+ cards                                       */
 
@@ -182,7 +162,6 @@
  	{ 0xd01810fc, BTTV_GVBCTV5PCI,    "I-O Data Co. GV-BCTV5/PCI" },
 
 	{ 0x001211bd, BTTV_PINNACLE,      "Pinnacle PCTV" },
-	{ 0x001c11bd, BTTV_PINNACLESAT,   "Pinnacle PCTV Sat" },
 	// some cards ship with byteswapped IDs ...
 	{ 0x1200bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
 	{ 0xff00bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
@@ -190,8 +169,9 @@
 	{ 0x3000121a, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
 	{ 0x263710b4, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
 	{ 0x3060121a, BTTV_STB2,	  "3Dfx VoodooTV 100/ STB OEM" },
-	
+
 	{ 0x3000144f, BTTV_MAGICTVIEW063, "(Askey Magic/others) TView99 CPH06x" },
+	{ 0xa005144f, BTTV_MAGICTVIEW063, "CPH06X TView99-Card" },
 	{ 0x3002144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH05x" },
 	{ 0x3005144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH061/06L (T1/LC)" },
 	{ 0x5000144f, BTTV_MAGICTVIEW061, "Askey CPH050" },
@@ -208,7 +188,7 @@
 	{ 0x1118153b, BTTV_TERRATVALUE,   "Terratec TValue (Temic PAL B/G)" },
 	{ 0x1119153b, BTTV_TERRATVALUE,   "Terratec TValue (Philips PAL I)" },
 	{ 0x111a153b, BTTV_TERRATVALUE,   "Terratec TValue (Temic PAL I)" },
- 
+
 	{ 0x1123153b, BTTV_TERRATVRADIO,  "Terratec TV Radio+" },
 	{ 0x1127153b, BTTV_TERRATV,       "Terratec TV+ (V1.05)"    },
 	// clashes with FlyVideo
@@ -244,7 +224,7 @@
 	{ 0xa1550000, BTTV_IVC200,        "IVC-200"  },
 	{ 0xa1550001, BTTV_IVC200,        "IVC-200"  },
 	{ 0xa1550002, BTTV_IVC200,        "IVC-200"  },
-	{ 0xa1550003, BTTV_IVC200,        "IVC-200"  },	
+	{ 0xa1550003, BTTV_IVC200,        "IVC-200"  },
 	{ 0xa1550100, BTTV_IVC200,        "IVC-200G" },
 	{ 0xa1550101, BTTV_IVC200,        "IVC-200G" },
 	{ 0xa1550102, BTTV_IVC200,        "IVC-200G" },
@@ -265,10 +245,10 @@
 	{ 0xa182ff0d, BTTV_IVC120,        "IVC-120G" },
 	{ 0xa182ff0e, BTTV_IVC120,        "IVC-120G" },
 	{ 0xa182ff0f, BTTV_IVC120,        "IVC-120G" },
-	
+
 	{ 0x41424344, BTTV_GRANDTEC,      "GrandTec Multi Capture" },
 	{ 0x01020304, BTTV_XGUARD,        "Grandtec Grand X-Guard" },
-	
+
 	{ 0x18501851, BTTV_CHRONOS_VS2,   "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" },
 	{ 0xa0501851, BTTV_CHRONOS_VS2,   "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" },
 	{ 0x18511851, BTTV_FLYVIDEO98EZ,  "FlyVideo 98EZ (LR51)/ CyberMail AV" },
@@ -300,15 +280,17 @@
 
 	// likely broken, vendor id doesn't match the other magic views ...
 	//{ 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" },
-	
+
 	// DVB cards (using pci function .1 for mpeg data xfer)
 	{ 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
 	{ 0x07611461, BTTV_AVDVBT_761,    "AverMedia AverTV DVB-T" },
+	{ 0x001c11bd, BTTV_PINNACLESAT,   "Pinnacle PCTV Sat" },
 	{ 0x002611bd, BTTV_TWINHAN_DST,   "Pinnacle PCTV SAT CI" },
 	{ 0x00011822, BTTV_TWINHAN_DST,   "Twinhan VisionPlus DVB-T" },
 	{ 0xfc00270f, BTTV_TWINHAN_DST,   "ChainTech digitop DST-1000 DVB-S" },
 	{ 0x07711461, BTTV_AVDVBT_771,    "AVermedia DVB-T 771" },
-	
+	{ 0xdb1018ac, BTTV_DVICO_DVBT_LITE,    "DVICO FusionHDTV DVB-T Lite" },
+
 	{ 0, -1, NULL }
 };
 
@@ -699,7 +681,7 @@
 		10000 : ext. Video audio input
 		20000 : TV Mono
 		a0000 : TV Mono/2
-	       1a0000 : TV Stereo	
+	       1a0000 : TV Stereo
 		30000 : Radio
 		40000 : Mute
        */
@@ -1114,7 +1096,7 @@
 	.pll            = PLL_28,
 	.tuner_type     = 5,
 },{
-	/* This is the ultimate cheapo capture card 
+	/* This is the ultimate cheapo capture card
 	 * just a BT848A on a small PCB!
 	 * Steve Hosgood <steve@equiinet.com> */
 	.name           = "GrandTec 'Grand Video Capture' (Bt848)",
@@ -1185,7 +1167,7 @@
 	.tuner_type     = -1,
 },{
 	/* Miguel Angel Alvarez <maacruz@navegalia.com>
-	   new Easy TV BT878 version (model CPH061) 
+	   new Easy TV BT878 version (model CPH061)
 	   special thanks to Informatica Mieres for providing the card */
 	.name           = "Askey CPH061/ BESTBUY Easy TV (bt878)",
 	.video_inputs	= 3,
@@ -1389,7 +1371,7 @@
 },{
         .name           = "Powercolor MTV878/ MTV878R/ MTV878F",
         .video_inputs   = 3,
-        .audio_inputs   = 2, 
+        .audio_inputs   = 2,
 	.tuner		= 0,
         .svhs           = 2,
         .gpiomask       = 0x1C800F,  // Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset
@@ -1567,7 +1549,7 @@
         .no_tda9875     = 1,
         .no_tda7432     = 1,
 },{
-	
+
 	/* ---- card 0x58 ---------------------------------- */
 	.name           = "Osprey 200/250",   /* 0x1(A|B)-00C4-C1 */
 	.video_inputs   = 2,
@@ -1660,13 +1642,14 @@
 	.tuner_type     = -1,
 	.no_msp34xx     = 1,
 	.no_tda9875     = 1,
-	.no_tda7432     = 1,   
+	.no_tda7432     = 1,
 	.gpiomask       = 0x01,
 	.audiomux       = { 0, 0, 0, 0, 1 },
 	.muxsel         = { 3, 0, 1, 2},
-	.needs_tvaudio  = 0, 
+	.needs_tvaudio  = 0,
 	.pll            = PLL_28,
 	.no_gpioirq     = 1,
+	.has_dvb        = 1,
 },{
         .name           = "Formac ProTV II (bt878)",
         .video_inputs   = 4,
@@ -1676,7 +1659,7 @@
         .gpiomask       = 2,
 	// TV, Comp1, Composite over SVID con, SVID
         .muxsel         = { 2, 3, 1, 1},
-        .audiomux       = { 2, 2, 0, 0, 0 }, 
+        .audiomux       = { 2, 2, 0, 0, 0 },
         .pll            = PLL_28,
 	.has_radio      = 1,
         .tuner_type     = TUNER_PHILIPS_PAL,
@@ -1761,7 +1744,7 @@
 	/* Notes:
 	   - card lacks subsystem ID
 	   - stereo variant w/ daughter board with tda9874a @0xb0
-	   - Audio Routing: 
+	   - Audio Routing:
 		always from tda9874 independent of GPIO (?)
 		external line in: unknown
 	   - Other chips: em78p156elp @ 0x96 (probably IR remote control)
@@ -1845,7 +1828,7 @@
 	.audio_inputs   = 0,
 	.tuner          = -1, /* card has no tuner */
 	.svhs           = 3,
-	.gpiomask       = 0x00, 
+	.gpiomask       = 0x00,
 	.muxsel         = { 2, 3, 1, 0},
 	.audiomux       = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
 	.needs_tvaudio  = 1,
@@ -1918,7 +1901,7 @@
 	.no_tda9875     = 1,
 	.no_tda7432     = 1,
 	.gpiomask       = 0x00,
-	.muxsel         = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 
+	.muxsel         = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
 			    0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 },
 	.muxsel_hook    = ivc120_muxsel,
 	.pll            = PLL_28,
@@ -2081,18 +2064,16 @@
         .pll            = PLL_28,
         .has_dvb        = 1,
         .no_gpioirq     = 1,
-#if 0 /* untested */
         .has_remote     = 1,
-#endif
 },{
 	/* ---- card 0x7c ---------------------------------- */
 	/* Matt Jesson <dvb@jesson.eclipse.co.uk> */
 	/* Based on the Nebula card data - added remote and new card number - BTTV_AVDVBT_761, see also ir-kbd-gpio.c */
 	.name           = "AverMedia AverTV DVB-T 761",
-	.video_inputs   = 1,
+	.video_inputs   = 2,
 	.tuner          = -1,
-	.svhs           = -1,
-	.muxsel         = { 2, 3, 1, 0},
+	.svhs           = 1,
+	.muxsel         = { 3, 1, 2, 0}, /* Comp0, S-Video, ?, ? */
 	.no_msp34xx     = 1,
 	.no_tda9875     = 1,
 	.no_tda7432     = 1,
@@ -2147,6 +2128,34 @@
 	.tuner_type     = TUNER_PHILIPS_PAL,
 	.has_remote     = 1,   /* miniremote works, see ir-kbd-gpio.c */
 	.has_radio      = 1,   /* not every card has radio */
+},{
+
+	/* ---- card 0x80 ---------------------------------- */
+	/* Chris Pascoe <c.pascoe@itee.uq.edu.au> */
+	.name           = "DVICO FusionHDTV DVB-T Lite",
+	.tuner          = -1,
+	.no_msp34xx     = 1,
+	.no_tda9875     = 1,
+	.no_tda7432     = 1,
+	.pll            = PLL_28,
+	.no_video       = 1,
+	.has_dvb        = 1,
+	.tuner_type     = -1,
+},{
+	/* Steven <photon38@pchome.com.tw> */
+	.name           = "V-Gear MyVCD",
+	.video_inputs   = 3,
+	.audio_inputs   = 1,
+	.tuner          = 0,
+	.svhs           = 2,
+	.gpiomask       = 0x3f,
+	.muxsel         = {2, 3, 1, 0},
+	.audiomux       = {0x31, 0x31, 0x31, 0x31, 0x31, 0x31},
+	.no_msp34xx     = 1,
+	.pll            = PLL_28,
+	.tuner_type     = TUNER_PHILIPS_NTSC_M,
+	.has_radio      = 0,
+	// .has_remote     = 1,
 }};
 
 const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
@@ -2175,7 +2184,7 @@
 		for (type = -1, i = 0; cards[i].id != 0; i++)
 			if (cards[i].id  == btv->cardid)
 				type = i;
-		
+
 		if (type != -1) {
 			/* found it */
 			printk(KERN_INFO "bttv%d: detected: %s [card=%d], "
@@ -2192,12 +2201,12 @@
 			printk(KERN_DEBUG "please mail id, board name and "
 			       "the correct card= insmod option to kraxel@bytesex.org\n");
 		}
-	} 
+	}
 
 	/* let the user override the autodetected type */
 	if (card[btv->c.nr] < bttv_num_tvcards)
 		btv->c.type=card[btv->c.nr];
-	
+
 	/* print which card config we are using */
 	printk(KERN_INFO "bttv%d: using: %s [card=%d,%s]\n",btv->c.nr,
 	       bttv_tvcards[btv->c.type].name, btv->c.type,
@@ -2237,7 +2246,7 @@
 void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256])
 {
 	int type = -1;
-	
+
 	if (0 == strncmp(eeprom_data,"GET MM20xPCTV",13))
 		type = BTTV_MODTEC_205;
 	else if (0 == strncmp(eeprom_data+20,"Picolo",7))
@@ -2253,7 +2262,7 @@
 }
 
 static void flyvideo_gpio(struct bttv *btv)
-{ 
+{
 	int gpio,has_remote,has_radio,is_capture_only,is_lr90,has_tda9820_tda9821;
 	int tuner=-1,ttype;
 
@@ -2267,10 +2276,10 @@
 	//       CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1.
 	//       GPIO14-12: n.c.
 	// LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878)
-	
+
 	// lowest 3 bytes are remote control codes (no handshake needed)
         // xxxFFF: No remote control chip soldered
-        // xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered 
+        // xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered
 	// Note: Some bits are Audio_Mask !
 
 	ttype=(gpio&0x0f0000)>>16;
@@ -2298,18 +2307,18 @@
 	is_lr90             = !(gpio & 0x002000); // else LR26/LR50 (LR38/LR51 f. capture only)
         //		        gpio & 0x001000 // output bit for audio routing
 
-	if(is_capture_only) 
-		tuner=4; // No tuner present 
+	if(is_capture_only)
+		tuner=4; // No tuner present
 
-	printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", 
-	       btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio); 
+	printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n",
+	       btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio);
 	printk(KERN_INFO "bttv%d: FlyVideo  LR90=%s tda9821/tda9820=%s capture_only=%s\n",
-		btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ", 
+		btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ",
 		is_capture_only?"yes":"no ");
 
 	if(tuner!= -1) // only set if known tuner autodetected, else let insmod option through
 		btv->tuner_type = tuner;
-	btv->has_radio = has_radio;  
+	btv->has_radio = has_radio;
 
 	// LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80
         // LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00
@@ -2408,13 +2417,13 @@
 {
 	gpio_inout(0xffffff,0xFFFF37);
 	gpio_write(0x200020);
-	
+
 	/* flash strobe inverter ?! */
 	gpio_write(0x200024);
-	
+
 	/* switch sync drive off */
 	gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
-	
+
 	/* set BT848 muxel to 2 */
 	btaor((2)<<5, ~(2<<5), BT848_IFORM);
 }
@@ -2503,7 +2512,7 @@
 	 */
 	if (btv->id != 878)
 		return;
-	
+
 	if (bttv_debug)
 		printk("bttv%d: BT878A ARESET\n",btv->c.nr);
 	btwrite((1<<7), 0x058);
@@ -2538,6 +2547,7 @@
 /* initialization part two -- after registering i2c bus */
 void __devinit bttv_init_card2(struct bttv *btv)
 {
+	int tda9887;
         btv->tuner_type = -1;
 
 	if (BTTV_UNKNOWN == btv->c.type) {
@@ -2549,7 +2559,7 @@
 	case BTTV_MIRO:
 	case BTTV_MIROPRO:
 	case BTTV_PINNACLE:
-	case BTTV_PINNACLEPRO: 
+	case BTTV_PINNACLEPRO:
 		/* miro/pinnacle */
 		miro_pinnacle_gpio(btv);
 		break;
@@ -2673,7 +2683,7 @@
 
 	/* tuner configuration (from card list / autodetect / insmod option) */
  	if (UNSET != bttv_tvcards[btv->c.type].tuner_type)
-		if(UNSET == btv->tuner_type) 
+		if(UNSET == btv->tuner_type)
                 	btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type;
 	if (UNSET != tuner[btv->c.nr])
 		btv->tuner_type = tuner[btv->c.nr];
@@ -2705,57 +2715,52 @@
 			boot_bt832(btv);
 	}
 
+	if (!autoload)
+		return;
+
 	/* try to detect audio/fader chips */
 	if (!bttv_tvcards[btv->c.type].no_msp34xx &&
-	    bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0) {
-		if (autoload)
-			request_module("msp3400");
-	}
+	    bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0)
+		request_module("msp3400");
 
 	if (bttv_tvcards[btv->c.type].msp34xx_alt &&
-	    bttv_I2CRead(btv, I2C_MSP3400_ALT, "MSP34xx (alternate address)") >=0) {
-		if (autoload)
-			request_module("msp3400");
-	}
+	    bttv_I2CRead(btv, I2C_MSP3400_ALT, "MSP34xx (alternate address)") >=0)
+		request_module("msp3400");
 
 	if (!bttv_tvcards[btv->c.type].no_tda9875 &&
-	    bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0) {
-		if (autoload)
-			request_module("tda9875");
-	}
+	    bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0)
+		request_module("tda9875");
 
-	if (!bttv_tvcards[btv->c.type].no_tda7432 && 
-	    bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0) {
-		if (autoload)
-			request_module("tda7432");
-	}
+	if (!bttv_tvcards[btv->c.type].no_tda7432 &&
+	    bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0)
+		request_module("tda7432");
 
-	if (bttv_tvcards[btv->c.type].needs_tvaudio) {
-		if (autoload)
-			request_module("tvaudio");
-	}
+	if (bttv_tvcards[btv->c.type].needs_tvaudio)
+		request_module("tvaudio");
 
 	/* tuner modules */
-	if (btv->pinnacle_id != UNSET) {
-		if (autoload)
-			request_module("tda9887");
-	}
-	if (btv->tuner_type != UNSET) {
-		if (autoload)
-			request_module("tuner");
-	}
+	tda9887 = 0;
+	if (btv->pinnacle_id != UNSET)
+		tda9887 = 1;
+	if (0 == tda9887 && 0 == bttv_tvcards[btv->c.type].has_dvb &&
+	    bttv_I2CRead(btv, I2C_TDA9887, "TDA9887") >=0)
+		tda9887 = 1;
+	if (tda9887)
+		request_module("tda9887");
+	if (btv->tuner_type != UNSET)
+		request_module("tuner");
 }
 
 
 /* ----------------------------------------------------------------------- */
 /* some hauppauge specific stuff                                           */
 
-static struct HAUPPAUGE_TUNER 
+static struct HAUPPAUGE_TUNER
 {
         int  id;
         char *name;
-} 
-hauppauge_tuner[] __devinitdata = 
+}
+hauppauge_tuner[] __devinitdata =
 {
         { TUNER_ABSENT,        "" },
         { TUNER_ABSENT,        "External" },
@@ -2805,7 +2810,7 @@
 	{ TUNER_ABSENT,        "Philips TD1536D_FH_44"},
 	{ TUNER_LG_NTSC_FM,    "LG TPI8NSR01F"},
 	{ TUNER_LG_PAL_FM,     "LG TPI8PSB01D"},
-	{ TUNER_LG_PAL,        "LG TPI8PSB11D"},	
+	{ TUNER_LG_PAL,        "LG TPI8PSB11D"},
 	{ TUNER_LG_PAL_I_FM,   "LG TAPC-I001D"},
 	{ TUNER_LG_PAL_I,      "LG TAPC-I701D"}
 };
@@ -2845,16 +2850,17 @@
 	model = eeprom_data[12] << 8 | eeprom_data[11];
 	tuner = eeprom_data[9];
 	radio = eeprom_data[blk2-1] & 0x01;
-	
+
         if (tuner < ARRAY_SIZE(hauppauge_tuner))
                 btv->tuner_type = hauppauge_tuner[tuner].id;
 	if (radio)
 		btv->has_radio = 1;
-	
+
 	if (bttv_verbose)
 		printk(KERN_INFO "bttv%d: Hauppauge eeprom: model=%d, "
 		       "tuner=%s (%d), radio=%s\n",
-		       btv->c.nr, model, hauppauge_tuner[tuner].name,
+		       btv->c.nr, model, (tuner < ARRAY_SIZE(hauppauge_tuner)
+					  ? hauppauge_tuner[tuner].name : "?"),
 		       btv->tuner_type, radio ? "yes" : "no");
 }
 
@@ -2886,7 +2892,7 @@
 		btv->has_matchbox = 0;
 	}
 	return 0;
-}	
+}
 
 
 /* ----------------------------------------------------------------------- */
@@ -2913,7 +2919,7 @@
 	gpio_inout(0xffffff,BTTV_ALT_DATA|BTTV_ALT_DCLK|BTTV_ALT_NCONFIG);
 	gpio_write(0);
 	udelay(PVR_GPIO_DELAY);
-	
+
 	gpio_write(BTTV_ALT_NCONFIG);
 	udelay(PVR_GPIO_DELAY);
 
@@ -2923,7 +2929,7 @@
 			gpio_bits(BTTV_ALT_DCLK,0);
 			if (bits & 0x01)
 				gpio_bits(BTTV_ALT_DATA,BTTV_ALT_DATA);
-			else 
+			else
 				gpio_bits(BTTV_ALT_DATA,0);
 			gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK);
 			bits >>= 1;
@@ -2931,7 +2937,7 @@
 	}
 	gpio_bits(BTTV_ALT_DCLK,0);
 	udelay(PVR_GPIO_DELAY);
-	
+
 	/* begin Altera init loop (Not necessary,but doesn't hurt) */
 	for (i = 0 ; i < 30 ; i++) {
 		gpio_bits(BTTV_ALT_DCLK,0);
@@ -2941,40 +2947,6 @@
 	return 0;
 }
 
-#if !defined(CONFIG_FW_LOADER) && !defined(CONFIG_FW_LOADER_MODULE)
-/* old 2.4.x way -- via soundcore's mod_firmware_load */
-   
-static char *firm_altera = "/usr/lib/video4linux/hcwamc.rbf";
-MODULE_PARM(firm_altera,"s");
-MODULE_PARM_DESC(firm_altera,"WinTV/PVR firmware "
-		 "(driver CD => unzip pvr45xxx.exe => hcwamc.rbf)");
-
-extern int mod_firmware_load(const char *fn, char **fp);
-
-int __devinit pvr_boot(struct bttv *btv)
-{
-	u32 microlen;
-	u8 *micro;
-	int result;
-
-	microlen = mod_firmware_load(firm_altera, (char**) &micro);
-	if (!microlen) {
-		printk(KERN_WARNING "bttv%d: altera firmware not found [%s]\n",
-		       btv->c.nr, firm_altera);
-		return -1;
-	}
-	
-	printk(KERN_INFO "bttv%d: uploading altera firmware [%s] ...\n",
-	       btv->c.nr, firm_altera);
-	result = pvr_altera_load(btv, micro, microlen);
-	printk(KERN_INFO "bttv%d: ... upload %s\n",
-	       btv->c.nr, (result < 0) ? "failed" : "ok");
-	vfree(micro);
-	return result;
-}
-#else
-/* new 2.5.x way -- via hotplug firmware loader */
-
 int __devinit pvr_boot(struct bttv *btv)
 {
         const struct firmware *fw_entry;
@@ -2991,8 +2963,7 @@
 	       btv->c.nr, (rc < 0) ? "failed" : "ok");
         release_firmware(fw_entry);
 	return rc;
-}	
-#endif
+}
 
 /* ----------------------------------------------------------------------- */
 /* some osprey specific stuff                                              */
@@ -3002,7 +2973,7 @@
        int i = 0;
        unsigned char *ee = eeprom_data;
        unsigned long serial = 0;
-    
+
        if (btv->c.type == 0) {
                /* this might be an antique... check for MMAC label in eeprom */
                if ((ee[0]=='M') && (ee[1]=='M') && (ee[2]=='A') && (ee[3]=='C')) {
@@ -3018,7 +2989,7 @@
        } else {
 	       unsigned short type;
                int offset = 4*16;
-        
+
                for(; offset < 8*16; offset += 16) {
                        unsigned short checksum = 0;
                        /* verify the checksum */
@@ -3029,13 +3000,13 @@
                                break;
                        }
                }
-        
+
                if (offset >= 8*16)
 		       return;
 
 	       /* found a valid descriptor */
 	       type = (ee[offset+4]<<8) | (ee[offset+5]);
-	       
+
 	       switch(type) {
 
 	       /* 848 based */
@@ -3045,7 +3016,7 @@
 	       case 0x0005:
 		       btv->c.type = BTTV_OSPREY101_848;
 		       break;
-		       
+
                /* 878 based */
 	       case 0x0012:
 	       case 0x0013:
@@ -3093,10 +3064,10 @@
 		       | (ee[offset+8] <<  8)
 		       | (ee[offset+9]);
        }
-       
+
        printk(KERN_INFO "bttv%d: osprey eeprom: card=%d name=%s serial=%ld\n",
 	      btv->c.nr, btv->c.type, bttv_tvcards[btv->c.type].name,serial);
-}	
+}
 
 /* ----------------------------------------------------------------------- */
 /* AVermedia specific stuff, from  bktr_card.c                             */
@@ -3138,7 +3109,7 @@
 	if (tuner_make == 1)
 		if(tuner_format <=9)
 			tuner = tuner_1_table[tuner_format];
-	
+
 	printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=",
 		btv->c.nr,eeprom_data[0x41],eeprom_data[0x42]);
 	if(tuner) {
@@ -3228,8 +3199,8 @@
 
 /* ----------------------------------------------------------------------- */
 /*  Imagenation L-Model PXC200 Framegrabber */
-/*  This is basically the same procedure as 
- *  used by Alessandro Rubini in his pxc200 
+/*  This is basically the same procedure as
+ *  used by Alessandro Rubini in his pxc200
  *  driver, but using BTTV functions */
 
 static void __devinit init_PXC200(struct bttv *btv)
@@ -3240,13 +3211,13 @@
 	unsigned int i;
 	int tmp;
 	u32 val;
-	
+
 	/* Initialise GPIO-connevted stuff */
 	gpio_inout(0xffffff, (1<<13));
 	gpio_write(0);
 	udelay(3);
 	gpio_write(1<<13);
-	/* GPIO inputs are pulled up, so no need to drive 
+	/* GPIO inputs are pulled up, so no need to drive
 	 * reset pin any longer */
 	gpio_bits(0xffffff, 0);
 	if (bttv_gpio)
@@ -3261,16 +3232,16 @@
 	*/
 
 	btwrite(BT848_ADC_RESERVED|BT848_ADC_AGC_EN, BT848_ADC);
-	
+
 	/*	Initialise MAX517 DAC */
 	printk(KERN_INFO "Setting DAC reference voltage level ...\n");
 	bttv_I2CWrite(btv,0x5E,0,0x80,1);
-	
+
 	/*	Initialise 12C508 PIC */
-	/*	The I2CWrite and I2CRead commmands are actually to the 
+	/*	The I2CWrite and I2CRead commmands are actually to the
 	 *	same chips - but the R/W bit is included in the address
 	 *	argument so the numbers are different */
-	
+
 
 	printk(KERN_INFO "Initialising 12C508 PIC chip ...\n");
 
@@ -3278,7 +3249,7 @@
 	val = btread(BT848_GPIO_DMA_CTL);
 	val |= BT848_GPIO_DMA_CTL_GPCLKMODE;
 	btwrite(val, BT848_GPIO_DMA_CTL);
-	
+
 	/* Then, push to 0 the reset pin long enough to reset the *
 	 * device same as above for the reset line, but not the same
 	 * value sent to the GPIO-connected stuff
@@ -3390,7 +3361,7 @@
 	unsigned long timeout;
 	int value = 0;
 	int i;
-	
+
 	/* better safe than sorry */
 	gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we);
 
@@ -3402,10 +3373,10 @@
 
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,"tea5757 read");
-	
+
 	bus_low(btv,btv->mbox_we);
 	bus_low(btv,btv->mbox_clk);
-	
+
 	udelay(10);
 	timeout= jiffies + HZ;
 
@@ -3437,7 +3408,7 @@
 {
 	int i;
 	int reg = value;
-	
+
 	gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we | btv->mbox_data);
 
 	if (btv->mbox_ior) {
@@ -3492,7 +3463,7 @@
 		v->flags |= VIDEO_AUDIO_VOLUME;
 		return;
 	}
-	
+
 	/* 32 levels logarithmic */
 	vol = 32 - ((v->volume>>11));
 	/* units */
@@ -3519,7 +3490,7 @@
 	data |=  WINVIEW_PT2254_STROBE;
 	data &= ~WINVIEW_PT2254_DATA;
 	gpio_write(data);
-	udelay(10);                     
+	udelay(10);
 	data &= ~WINVIEW_PT2254_STROBE;
 	gpio_write(data);
 }
@@ -3644,7 +3615,7 @@
 avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v, int set)
 {
 	int val = 0;
-	
+
 	if (set) {
 		if (v->mode & VIDEO_SOUND_LANG2)   /* SAP */
 			val = 0x01;
@@ -3779,7 +3750,7 @@
 
 /*
  * Dariusz Kowalewski <darekk@automex.pl>
- * sound control for FlyVideo 2000S (with tda9874 decoder) 
+ * sound control for FlyVideo 2000S (with tda9874 decoder)
  * based on pvbt878p9b_audio() - this is not tested, please fix!!!
  */
 static void
@@ -3962,13 +3933,13 @@
  * ivc120_muxsel [Added by Alan Garfield <alan@fromorbit.com>]
  *
  * The IVC120G security card has 4 i2c controlled TDA8540 matrix
- * swichers to provide 16 channels to MUX0. The TDA8540's have 
- * 4 indepedant outputs and as such the IVC120G also has the 
- * optional "Monitor Out" bus. This allows the card to be looking 
+ * swichers to provide 16 channels to MUX0. The TDA8540's have
+ * 4 indepedant outputs and as such the IVC120G also has the
+ * optional "Monitor Out" bus. This allows the card to be looking
  * at one input while the monitor is looking at another.
  *
  * Since I've couldn't be bothered figuring out how to add an
- * independant muxsel for the monitor bus, I've just set it to 
+ * independant muxsel for the monitor bus, I've just set it to
  * whatever the card is looking at.
  *
  *  OUT0 of the TDA8540's is connected to MUX0         (0x03)
@@ -3993,12 +3964,12 @@
 static void ivc120_muxsel(struct bttv *btv, unsigned int input)
 {
 	// Simple maths
-	int key = input % 4;    
+	int key = input % 4;
 	int matrix = input / 4;
-	
+
 	dprintk("bttv%d: ivc120_muxsel: Input - %02d | TDA - %02d | In - %02d\n",
 		btv->c.nr, input, matrix, key);
-	
+
 	// Handles the input selection on the TDA8540's
 	bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x00,
 		      ((matrix == 3) ? (key | key << 2) : 0x00), 1);
@@ -4008,22 +3979,102 @@
 		      ((matrix == 1) ? (key | key << 2) : 0x00), 1);
 	bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x00,
 		      ((matrix == 2) ? (key | key << 2) : 0x00), 1);
-	
+
 	// Handles the output enables on the TDA8540's
 	bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x02,
 		      ((matrix == 3) ? 0x03 : 0x00), 1);  // 13 - 16
 	bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x02,
 		      ((matrix == 0) ? 0x03 : 0x00), 1);  // 1-4
 	bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x02,
-		      ((matrix == 1) ? 0x03 : 0x00), 1);  // 5-8 
+		      ((matrix == 1) ? 0x03 : 0x00), 1);  // 5-8
 	bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x02,
 		      ((matrix == 2) ? 0x03 : 0x00), 1);  // 9-12
-	
+
 	// Selects MUX0 for input on the 878
 	btaor((0)<<5, ~(3<<5), BT848_IFORM);
 }
 
 
+/* PXC200 muxsel helper
+ * luke@syseng.anu.edu.au
+ * another transplant
+ * from Alessandro Rubini (rubini@linux.it)
+ *
+ * There are 4 kinds of cards:
+ * PXC200L which is bt848
+ * PXC200F which is bt848 with PIC controlling mux
+ * PXC200AL which is bt878
+ * PXC200AF which is bt878 with PIC controlling mux
+ */
+#define PX_CFG_PXC200F 0x01
+#define PX_FLAG_PXC200A  0x00001000 /* a pxc200A is bt-878 based */
+#define PX_I2C_PIC       0x0f
+#define PX_PXC200A_CARDID 0x200a1295
+#define PX_I2C_CMD_CFG   0x00
+
+static void PXC200_muxsel(struct bttv *btv, unsigned int input)
+{
+        int rc;
+	long mux;
+	int bitmask;
+        unsigned char buf[2];
+
+	/* Read PIC config to determine if this is a PXC200F */
+	/* PX_I2C_CMD_CFG*/
+	buf[0]=0;
+	buf[1]=0;
+	rc=bttv_I2CWrite(btv,(PX_I2C_PIC<<1),buf[0],buf[1],1);
+	if (rc) {
+	  printk(KERN_DEBUG "bttv%d: PXC200_muxsel: pic cfg write failed:%d\n", btv->c.nr,rc);
+	  /* not PXC ? do nothing */
+	  return;
+	}
+
+	rc=bttv_I2CRead(btv,(PX_I2C_PIC<<1),NULL);
+	if (!(rc & PX_CFG_PXC200F)) {
+	  printk(KERN_DEBUG "bttv%d: PXC200_muxsel: not PXC200F rc:%d \n", btv->c.nr,rc);
+	  return;
+	}
+
+
+	/* The multiplexer in the 200F is handled by the GPIO port */
+	/* get correct mapping between inputs  */
+	/*  mux = bttv_tvcards[btv->type].muxsel[input] & 3; */
+	/* ** not needed!?   */
+	mux = input;
+
+	/* make sure output pins are enabled */
+	/* bitmask=0x30f; */
+	bitmask=0x302;
+	/* check whether we have a PXC200A */
+ 	if (btv->cardid == PX_PXC200A_CARDID)  {
+	   bitmask ^= 0x180; /* use 7 and 9, not 8 and 9 */
+	   bitmask |= 7<<4; /* the DAC */
+	}
+	btwrite(bitmask, BT848_GPIO_OUT_EN);
+
+	bitmask = btread(BT848_GPIO_DATA);
+ 	if (btv->cardid == PX_PXC200A_CARDID)
+	  bitmask = (bitmask & ~0x280) | ((mux & 2) << 8) | ((mux & 1) << 7);
+	else /* older device */
+	  bitmask = (bitmask & ~0x300) | ((mux & 3) << 8);
+	btwrite(bitmask,BT848_GPIO_DATA);
+
+	/*
+	 * Was "to be safe, set the bt848 to input 0"
+	 * Actually, since it's ok at load time, better not messing
+	 * with these bits (on PXC200AF you need to set mux 2 here)
+	 *
+	 * needed because bttv-driver sets mux before calling this function
+	 */
+ 	if (btv->cardid == PX_PXC200A_CARDID)
+	  btaor(2<<5, ~BT848_IFORM_MUXSEL, BT848_IFORM);
+	else /* older device */
+	  btand(~BT848_IFORM_MUXSEL,BT848_IFORM);
+
+	printk(KERN_DEBUG "bttv%d: setting input channel to:%d\n", btv->c.nr,(int)mux);
+}
+
 /* ----------------------------------------------------------------------- */
 /* motherboard chipset specific stuff                                      */
 
@@ -4109,86 +4160,6 @@
 	return 0;
 }
 
-
-/* PXC200 muxsel helper
- * luke@syseng.anu.edu.au
- * another transplant
- * from Alessandro Rubini (rubini@linux.it)
- *
- * There are 4 kinds of cards:
- * PXC200L which is bt848
- * PXC200F which is bt848 with PIC controlling mux
- * PXC200AL which is bt878
- * PXC200AF which is bt878 with PIC controlling mux
- */
-#define PX_CFG_PXC200F 0x01
-#define PX_FLAG_PXC200A  0x00001000 /* a pxc200A is bt-878 based */
-#define PX_I2C_PIC       0x0f
-#define PX_PXC200A_CARDID 0x200a1295
-#define PX_I2C_CMD_CFG   0x00
-
-static void PXC200_muxsel(struct bttv *btv, unsigned int input)
-{
-        int rc;
-	long mux;
-	int bitmask;
-        unsigned char buf[2];
-
-	/* Read PIC config to determine if this is a PXC200F */
-	/* PX_I2C_CMD_CFG*/
-	buf[0]=0;
-	buf[1]=0;
-	rc=bttv_I2CWrite(btv,(PX_I2C_PIC<<1),buf[0],buf[1],1);
-	if (rc) {
-	  printk(KERN_DEBUG "bttv%d: PXC200_muxsel: pic cfg write failed:%d\n", btv->c.nr,rc);
-	  /* not PXC ? do nothing */
-	  return;
-	}
-
-	rc=bttv_I2CRead(btv,(PX_I2C_PIC<<1),0);
-	if (!(rc & PX_CFG_PXC200F)) {
-	  printk(KERN_DEBUG "bttv%d: PXC200_muxsel: not PXC200F rc:%d \n", btv->c.nr,rc);
-	  return;
-	}
-
-
-	/* The multiplexer in the 200F is handled by the GPIO port */
-	/* get correct mapping between inputs  */
-	/*  mux = bttv_tvcards[btv->type].muxsel[input] & 3; */
-	/* ** not needed!?   */
-	mux = input;
-
-	/* make sure output pins are enabled */
-	/* bitmask=0x30f; */
-	bitmask=0x302;
-	/* check whether we have a PXC200A */
- 	if (btv->cardid == PX_PXC200A_CARDID)  {
-	   bitmask ^= 0x180; /* use 7 and 9, not 8 and 9 */
-	   bitmask |= 7<<4; /* the DAC */
-	}
-	btwrite(bitmask, BT848_GPIO_OUT_EN);
-
-	bitmask = btread(BT848_GPIO_DATA);
- 	if (btv->cardid == PX_PXC200A_CARDID)
-	  bitmask = (bitmask & ~0x280) | ((mux & 2) << 8) | ((mux & 1) << 7);
-	else /* older device */
-	  bitmask = (bitmask & ~0x300) | ((mux & 3) << 8);
-	btwrite(bitmask,BT848_GPIO_DATA);
-
-	/*
-	 * Was "to be safe, set the bt848 to input 0"
-	 * Actually, since it's ok at load time, better not messing
-	 * with these bits (on PXC200AF you need to set mux 2 here)
-	 *
-	 * needed because bttv-driver sets mux before calling this function
-	 */
- 	if (btv->cardid == PX_PXC200A_CARDID)
-	  btaor(2<<5, ~BT848_IFORM_MUXSEL, BT848_IFORM);
-	else /* older device */
-	  btand(~BT848_IFORM_MUXSEL,BT848_IFORM);
-
-	printk(KERN_DEBUG "bttv%d: setting input channel to:%d\n", btv->c.nr,(int)mux);
-}
 
 /*
  * Local variables:
diff -Nru a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
--- a/drivers/media/video/bttv-driver.c	2004-12-24 13:37:17 -08:00
+++ b/drivers/media/video/bttv-driver.c	2004-12-24 13:37:17 -08:00
@@ -1,23 +1,25 @@
 /*
+    $Id: bttv-driver.c,v 1.27 2004/11/07 14:44:59 kraxel Exp $
+
     bttv - Bt848 frame grabber driver
-    
+
     Copyright (C) 1996,97,98 Ralph  Metzler <rjkm@thp.uni-koeln.de>
                            & Marcus Metzler <mocm@thp.uni-koeln.de>
     (c) 1999-2002 Gerd Knorr <kraxel@bytesex.org>
-    
+
     some v4l2 code lines are taken from Justin's bttv2 driver which is
     (c) 2000 Justin Schoeman <justin@suntiger.ee.up.ac.za>
-    
+
     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.
@@ -75,63 +77,56 @@
 static unsigned int irq_iswitch = 0;
 
 /* API features (turn on/off stuff for testing) */
-static unsigned int v4l2       = 1;
+static unsigned int v4l2        = 1;
 
 
 /* insmod args */
-MODULE_PARM(radio,"1-" __stringify(BTTV_MAX) "i");
+module_param(bttv_verbose,      int, 0644);
+module_param(bttv_gpio,         int, 0644);
+module_param(bttv_debug,        int, 0644);
+module_param(irq_debug,         int, 0644);
+module_param(debug_latency,     int, 0644);
+
+module_param(fdsr,              int, 0444);
+module_param(video_nr,          int, 0444);
+module_param(radio_nr,          int, 0444);
+module_param(vbi_nr,            int, 0444);
+module_param(gbuffers,          int, 0444);
+module_param(gbufsize,          int, 0444);
+
+module_param(v4l2,              int, 0644);
+module_param(bigendian,         int, 0644);
+module_param(irq_iswitch,       int, 0644);
+module_param(combfilter,        int, 0444);
+module_param(lumafilter,        int, 0444);
+module_param(automute,          int, 0444);
+module_param(chroma_agc,        int, 0444);
+module_param(adc_crush,         int, 0444);
+module_param(whitecrush_upper,  int, 0444);
+module_param(whitecrush_lower,  int, 0444);
+module_param(vcr_hack,          int, 0444);
+module_param_array(radio, int, NULL, 0444);
+
 MODULE_PARM_DESC(radio,"The TV card supports radio, default is 0 (no)");
-MODULE_PARM(bigendian,"i");
 MODULE_PARM_DESC(bigendian,"byte order of the framebuffer, default is native endian");
-MODULE_PARM(bttv_verbose,"i");
 MODULE_PARM_DESC(bttv_verbose,"verbose startup messages, default is 1 (yes)");
-MODULE_PARM(bttv_gpio,"i");
 MODULE_PARM_DESC(bttv_gpio,"log gpio changes, default is 0 (no)");
-MODULE_PARM(bttv_debug,"i");
 MODULE_PARM_DESC(bttv_debug,"debug messages, default is 0 (no)");
-MODULE_PARM(irq_debug,"i");
 MODULE_PARM_DESC(irq_debug,"irq handler debug messages, default is 0 (no)");
-MODULE_PARM(gbuffers,"i");
 MODULE_PARM_DESC(gbuffers,"number of capture buffers. range 2-32, default 8");
-MODULE_PARM(gbufsize,"i");
 MODULE_PARM_DESC(gbufsize,"size of the capture buffers, default is 0x208000");
-
-MODULE_PARM(video_nr,"i");
-MODULE_PARM(radio_nr,"i");
-MODULE_PARM(vbi_nr,"i");
-MODULE_PARM(debug_latency,"i");
-
-MODULE_PARM(fdsr,"i");
-
-MODULE_PARM(combfilter,"i");
-MODULE_PARM(lumafilter,"i");
-MODULE_PARM(automute,"i");
 MODULE_PARM_DESC(automute,"mute audio on bad/missing video signal, default is 1 (yes)");
-MODULE_PARM(chroma_agc,"i");
 MODULE_PARM_DESC(chroma_agc,"enables the AGC of chroma signal, default is 0 (no)");
-MODULE_PARM(adc_crush,"i");
 MODULE_PARM_DESC(adc_crush,"enables the luminance ADC crush, default is 1 (yes)");
-MODULE_PARM(whitecrush_upper,"i");
 MODULE_PARM_DESC(whitecrush_upper,"sets the white crush upper value, default is 207");
-MODULE_PARM(whitecrush_lower,"i");
 MODULE_PARM_DESC(whitecrush_lower,"sets the white crush lower value, default is 127");
-MODULE_PARM(vcr_hack,"i");
 MODULE_PARM_DESC(vcr_hack,"enables the VCR hack (improves synch on poor VCR tapes), default is 0 (no)");
-MODULE_PARM(irq_iswitch,"i");
 MODULE_PARM_DESC(irq_iswitch,"switch inputs in irq handler");
 
-MODULE_PARM(v4l2,"i");
-
 MODULE_DESCRIPTION("bttv - v4l/v4l2 driver module for bt848/878 based cards");
 MODULE_AUTHOR("Ralph Metzler & Marcus Metzler & Gerd Knorr");
 MODULE_LICENSE("GPL");
 
-/* kernel args */
-#ifndef MODULE
-static int __init p_radio(char *str) { return bttv_parse(str,BTTV_MAX,radio); }
-__setup("bttv.radio=", p_radio);
-#endif
-
 /* ----------------------------------------------------------------------- */
 /* sysfs                                                                   */
 
@@ -192,7 +187,7 @@
 		.sheight        = 576,
 		.totalwidth     = 1135,
 		.adelay         = 0x7f,
-		.bdelay         = 0x72, 
+		.bdelay         = 0x72,
 		.iform          = (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
 		.scaledtwidth   = 1135,
 		.hdelayx1       = 186,
@@ -680,20 +675,20 @@
 /* ----------------------------------------------------------------------- */
 /* If Bt848a or Bt849, use PLL for PAL/SECAM and crystal for NTSC          */
 
-/* Frequency = (F_input / PLL_X) * PLL_I.PLL_F/PLL_C 
-   PLL_X = Reference pre-divider (0=1, 1=2) 
+/* Frequency = (F_input / PLL_X) * PLL_I.PLL_F/PLL_C
+   PLL_X = Reference pre-divider (0=1, 1=2)
    PLL_C = Post divider (0=6, 1=4)
-   PLL_I = Integer input 
-   PLL_F = Fractional input 
-   
-   F_input = 28.636363 MHz: 
+   PLL_I = Integer input
+   PLL_F = Fractional input
+
+   F_input = 28.636363 MHz:
    PAL (CLKx2 = 35.46895 MHz): PLL_X = 1, PLL_I = 0x0E, PLL_F = 0xDCF9, PLL_C = 0
 */
 
 static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout)
 {
         unsigned char fl, fh, fi;
-        
+
         /* prevent overflows */
         fin/=4;
         fout/=4;
@@ -743,9 +738,8 @@
         for (i=0; i<10; i++) {
 		/*  Let other people run while the PLL stabilizes */
 		vprintk(".");
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/50);
-		
+		msleep(10);
+
                 if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) {
 			btwrite(0,BT848_DSTATUS);
                 } else {
@@ -808,7 +802,7 @@
 static void bt848_hue(struct bttv *btv, int hue)
 {
 	int value;
-	
+
 	btv->hue = hue;
 
 	/* -128 to 127 */
@@ -819,9 +813,9 @@
 static void bt848_contrast(struct bttv *btv, int cont)
 {
 	int value,hibit;
-	
+
 	btv->contrast = cont;
-	
+
 	/* 0-511 */
 	value = (cont  >> 7);
 	hibit = (value >> 6) & 4;
@@ -833,7 +827,7 @@
 static void bt848_sat(struct bttv *btv, int color)
 {
 	int val_u,val_v,hibits;
-	
+
 	btv->saturation = color;
 
 	/* 0-511 for the color */
@@ -975,11 +969,11 @@
 set_input(struct bttv *btv, unsigned int input)
 {
 	unsigned long flags;
-	
+
 	btv->input = input;
 	if (irq_iswitch) {
 		spin_lock_irqsave(&btv->s_lock,flags);
-		if (btv->curr.irqflags) {
+		if (btv->curr.frame_irq) {
 			/* active capture -> delayed input switch */
 			btv->new_input = input;
 		} else {
@@ -992,6 +986,7 @@
 	audio_mux(btv,(input == bttv_tvcards[btv->c.type].tuner ?
 		       AUDIO_TUNER : AUDIO_EXTERN));
 	set_tvnorm(btv,btv->tvnorm);
+	i2c_vidiocschan(btv);
 }
 
 static void init_irqreg(struct bttv *btv)
@@ -1019,7 +1014,7 @@
 static void init_bt848(struct bttv *btv)
 {
 	int val;
-	
+
 	if (bttv_tvcards[btv->c.type].no_video) {
 		/* very basic init only */
 		init_irqreg(btv);
@@ -1036,7 +1031,7 @@
                 BT848_GPIO_DMA_CTL_PLTP1_16|
                 BT848_GPIO_DMA_CTL_PLTP23_16|
                 BT848_GPIO_DMA_CTL_GPINTC|
-                BT848_GPIO_DMA_CTL_GPINTI, 
+                BT848_GPIO_DMA_CTL_GPINTI,
                 BT848_GPIO_DMA_CTL);
 
 	val = btv->opt_chroma_agc ? BT848_SCLOOP_CAGC : 0;
@@ -1076,7 +1071,7 @@
 		printk(KERN_INFO "bttv%d: reset, reinitialize\n",btv->c.nr);
 	spin_lock_irqsave(&btv->s_lock,flags);
 	btv->errors=0;
-	bttv_set_dma(btv,0,0);
+	bttv_set_dma(btv,0);
 	spin_unlock_irqrestore(&btv->s_lock,flags);
 
 	init_bt848(btv);
@@ -1088,7 +1083,7 @@
 {
 	struct video_audio va;
 	int i;
-	
+
 	for (i = 0; i < BTTV_CTLS; i++)
 		if (bttv_ctls[i].id == c->id)
 			break;
@@ -1334,8 +1329,8 @@
 	spin_lock_irqsave(&btv->s_lock,flags);
 	old = btv->screen;
 	btv->screen = new;
-	btv->curr.irqflags |= 1;
-	bttv_set_dma(btv, 0x03, btv->curr.irqflags);
+	btv->loop_irq |= 1;
+	bttv_set_dma(btv, 0x03);
 	spin_unlock_irqrestore(&btv->s_lock,flags);
 	if (NULL == new)
 		free_btres(btv,fh,RESOURCE_OVERLAY);
@@ -1358,7 +1353,7 @@
 {
 	int redo_dma_risc = 0;
 	int rc;
-	
+
 	/* check settings */
 	if (NULL == fmt)
 		return -EINVAL;
@@ -1378,7 +1373,7 @@
 		if (0 != buf->vb.baddr  &&  buf->vb.bsize < buf->vb.size)
 			return -EINVAL;
 	}
-	
+
 	/* alloc + fill struct bttv_buffer (if changed) */
 	if (buf->vb.width != width || buf->vb.height != height ||
 	    buf->vb.field != field ||
@@ -1411,10 +1406,10 @@
 }
 
 static int
-buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
+buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
 {
-	struct bttv_fh *fh = file->private_data;
-	
+	struct bttv_fh *fh = q->priv_data;
+
 	*size = fh->fmt->depth*fh->width*fh->height >> 3;
 	if (0 == *count)
 		*count = gbuffers;
@@ -1424,32 +1419,35 @@
 }
 
 static int
-buffer_prepare(struct file *file, struct videobuf_buffer *vb,
+buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
 	       enum v4l2_field field)
 {
-	struct bttv_buffer *buf = (struct bttv_buffer*)vb;
-	struct bttv_fh *fh = file->private_data;
+	struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
+	struct bttv_fh *fh = q->priv_data;
 
 	return bttv_prepare_buffer(fh->btv, buf, fh->fmt,
 				   fh->width, fh->height, field);
 }
 
 static void
-buffer_queue(struct file *file, struct videobuf_buffer *vb)
+buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct bttv_buffer *buf = (struct bttv_buffer*)vb;
-	struct bttv_fh *fh = file->private_data;
+	struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
+	struct bttv_fh *fh = q->priv_data;
+	struct bttv    *btv = fh->btv;
 
 	buf->vb.state = STATE_QUEUED;
-	list_add_tail(&buf->vb.queue,&fh->btv->capture);
-	fh->btv->curr.irqflags |= 1;
-	bttv_set_dma(fh->btv, 0x03, fh->btv->curr.irqflags);
+	list_add_tail(&buf->vb.queue,&btv->capture);
+	if (!btv->curr.frame_irq) {
+		btv->loop_irq |= 1;
+		bttv_set_dma(btv, 0x03);
+	}
 }
 
-static void buffer_release(struct file *file, struct videobuf_buffer *vb)
+static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct bttv_buffer *buf = (struct bttv_buffer*)vb;
-	struct bttv_fh *fh = file->private_data;
+	struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
+	struct bttv_fh *fh = q->priv_data;
 
 	bttv_dma_free(fh->btv,buf);
 }
@@ -1497,7 +1495,7 @@
 	case VIDIOCGTUNER:
 	{
 		struct video_tuner *v = arg;
-		
+
 		if (UNSET == bttv_tvcards[btv->c.type].tuner)
 			return -EINVAL;
 		if (v->tuner) /* Only tuner 0 */
@@ -1526,7 +1524,7 @@
 		up(&btv->lock);
 		return 0;
 	}
-	
+
         case VIDIOCGCHAN:
         {
                 struct video_channel *v = arg;
@@ -1608,7 +1606,7 @@
 		/* card specific hooks */
 		if (btv->audio_hook)
 			btv->audio_hook(btv,v,1);
-		
+
 		up(&btv->lock);
 		return 0;
 	}
@@ -1618,7 +1616,7 @@
 	{
 		struct v4l2_standard *e = arg;
 		unsigned int index = e->index;
-		
+
 		if (index >= BTTV_TVNORMS)
 			return -EINVAL;
 		v4l2_video_std_construct(e, bttv_tvnorms[e->index].v4l2_id,
@@ -1652,7 +1650,7 @@
 	case VIDIOC_QUERYSTD:
 	{
 		v4l2_std_id *id = arg;
-		
+
 		if (btread(BT848_DSTATUS) & BT848_DSTATUS_NUML)
 			*id = V4L2_STD_625_50;
 		else
@@ -1664,7 +1662,7 @@
 	{
 		struct v4l2_input *i = arg;
 		unsigned int n;
-		
+
 		n = i->index;
 		if (n >= bttv_tvcards[btv->c.type].video_inputs)
 			return -EINVAL;
@@ -1701,16 +1699,15 @@
 	case VIDIOC_S_INPUT:
 	{
 		unsigned int *i = arg;
-		
+
 		if (*i > bttv_tvcards[btv->c.type].video_inputs)
 			return -EINVAL;
 		down(&btv->lock);
 		set_input(btv,*i);
-		i2c_vidiocschan(btv);
 		up(&btv->lock);
 		return 0;
 	}
-	
+
 	case VIDIOC_G_TUNER:
 	{
 		struct v4l2_tuner *t = arg;
@@ -1806,7 +1803,7 @@
 
 	default:
 		return -ENOIOCTLCMD;
-	
+
 	}
 	return 0;
 }
@@ -1901,25 +1898,25 @@
 	default:
 		BUG();
 	}
-	
+
 	down(&fh->cap.lock);
 	if (fh->ov.clips)
 		kfree(fh->ov.clips);
 	fh->ov.clips    = clips;
 	fh->ov.nclips   = n;
-	
+
 	fh->ov.w        = win->w;
 	fh->ov.field    = win->field;
 	fh->ov.setup_ok = 1;
 	btv->init.ov.w.width   = win->w.width;
 	btv->init.ov.w.height  = win->w.height;
 	btv->init.ov.field     = win->field;
-	
+
 	/* update overlay if needed */
 	retval = 0;
 	if (check_btres(fh, RESOURCE_OVERLAY)) {
 		struct bttv_buffer *new;
-		
+
 		new = videobuf_alloc(sizeof(*new));
 		bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
 		retval = bttv_switch_overlay(btv,fh,new);
@@ -1933,7 +1930,7 @@
 static struct videobuf_queue* bttv_queue(struct bttv_fh *fh)
 {
 	struct videobuf_queue* q = NULL;
-	
+
 	switch (fh->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		q = &fh->cap;
@@ -1950,7 +1947,7 @@
 static int bttv_resource(struct bttv_fh *fh)
 {
 	int res = 0;
-	
+
 	switch (fh->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		res = RESOURCE_VIDEO;
@@ -2059,7 +2056,7 @@
 			(f->fmt.pix.width * fmt->depth) >> 3;
 		f->fmt.pix.sizeimage =
 			f->fmt.pix.height * f->fmt.pix.bytesperline;
-		
+
 		return 0;
 	}
 	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
@@ -2077,7 +2074,7 @@
 		      struct v4l2_format *f)
 {
 	int retval;
-	
+
 	switch (f->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 	{
@@ -2090,7 +2087,7 @@
 		if (0 != retval)
 			return retval;
 		fmt = format_by_fourcc(f->fmt.pix.pixelformat);
-		
+
 		/* update our state informations */
 		down(&fh->cap.lock);
 		fh->fmt              = fmt;
@@ -2102,7 +2099,7 @@
 		btv->init.width      = f->fmt.pix.width;
 		btv->init.height     = f->fmt.pix.height;
 		up(&fh->cap.lock);
-		
+
 		return 0;
 	}
 	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
@@ -2149,7 +2146,6 @@
 	if (btv->errors)
 		bttv_reinit_bt848(btv);
 
-#ifdef VIDIOC_G_PRIORITY
 	switch (cmd) {
         case VIDIOCSFREQ:
         case VIDIOCSTUNER:
@@ -2163,7 +2159,7 @@
 		if (0 != retval)
 			return retval;
 	};
-#endif
+
 	switch (cmd) {
 
 	/* ***  v4l1  *** ************************************************ */
@@ -2212,7 +2208,7 @@
 	{
 		struct video_picture *pic = arg;
 		const struct bttv_format *fmt;
-		
+
 		fmt = format_by_palette(pic->palette);
 		if (NULL == fmt)
 			return -EINVAL;
@@ -2359,7 +2355,7 @@
 
 		if (!check_alloc_btres(btv,fh,RESOURCE_OVERLAY))
 			return -EBUSY;
-		
+
 		down(&fh->cap.lock);
 		if (*on) {
 			fh->ov.tvnorm = btv->tvnorm;
@@ -2381,7 +2377,7 @@
 		unsigned int i;
 
 		down(&fh->cap.lock);
-		retval = videobuf_mmap_setup(file,&fh->cap,gbuffers,gbufsize,
+		retval = videobuf_mmap_setup(&fh->cap,gbuffers,gbufsize,
 					     V4L2_MEMORY_MMAP);
 		if (retval < 0)
 			goto fh_unlock_and_return;
@@ -2412,7 +2408,7 @@
 		if (buf->vb.state == STATE_QUEUED ||
 		    buf->vb.state == STATE_ACTIVE)
 			goto fh_unlock_and_return;
-		
+
 		field = (vm->height > bttv_tvnorms[btv->tvnorm].sheight/2)
 			? V4L2_FIELD_INTERLACED
 			: V4L2_FIELD_BOTTOM;
@@ -2422,7 +2418,7 @@
 		if (0 != retval)
 			goto fh_unlock_and_return;
 		spin_lock_irqsave(&btv->s_lock,flags);
-		buffer_queue(file,&buf->vb);
+		buffer_queue(&fh->cap,&buf->vb);
 		spin_unlock_irqrestore(&btv->s_lock,flags);
 		up(&fh->cap.lock);
 		return 0;
@@ -2536,7 +2532,7 @@
 			V4L2_CAP_VIDEO_OVERLAY |
 			V4L2_CAP_VBI_CAPTURE |
 			V4L2_CAP_TUNER |
-			V4L2_CAP_READWRITE | 
+			V4L2_CAP_READWRITE |
 			V4L2_CAP_STREAMING;
 		return 0;
 	}
@@ -2621,7 +2617,7 @@
 	{
 		struct v4l2_framebuffer *fb = arg;
 		const struct bttv_format *fmt;
-		
+
 		if(!capable(CAP_SYS_ADMIN) &&
 		   !capable(CAP_SYS_RAWIO))
 			return -EPERM;
@@ -2650,7 +2646,7 @@
 			btv->fbuf.fmt.bytesperline = fb->fmt.bytesperline;
 		else
 			btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fmt->depth/8;
-		
+
 		retval = 0;
 		fh->ovfmt = fmt;
 		btv->init.ovfmt = fmt;
@@ -2668,7 +2664,7 @@
 
 			if (check_btres(fh, RESOURCE_OVERLAY)) {
 				struct bttv_buffer *new;
-		
+
 				new = videobuf_alloc(sizeof(*new));
 				bttv_overlay_risc(btv,&fh->ov,fh->ovfmt,new);
 				retval = bttv_switch_overlay(btv,fh,new);
@@ -2679,16 +2675,17 @@
 	}
 
 	case VIDIOC_REQBUFS:
-		return videobuf_reqbufs(file,bttv_queue(fh),arg);
+		return videobuf_reqbufs(bttv_queue(fh),arg);
 
 	case VIDIOC_QUERYBUF:
 		return videobuf_querybuf(bttv_queue(fh),arg);
 
 	case VIDIOC_QBUF:
-		return videobuf_qbuf(file,bttv_queue(fh),arg);
+		return videobuf_qbuf(bttv_queue(fh),arg);
 
 	case VIDIOC_DQBUF:
-		return videobuf_dqbuf(file,bttv_queue(fh),arg);
+		return videobuf_dqbuf(bttv_queue(fh),arg,
+				      file->f_flags & O_NONBLOCK);
 
 	case VIDIOC_STREAMON:
 	{
@@ -2696,13 +2693,13 @@
 
 		if (!check_alloc_btres(btv,fh,res))
 			return -EBUSY;
-		return videobuf_streamon(file,bttv_queue(fh));
+		return videobuf_streamon(bttv_queue(fh));
 	}
 	case VIDIOC_STREAMOFF:
 	{
 		int res = bttv_resource(fh);
 
-		retval = videobuf_streamoff(file,bttv_queue(fh));
+		retval = videobuf_streamoff(bttv_queue(fh));
 		if (retval < 0)
 			return retval;
 		free_btres(btv,fh,res);
@@ -2771,7 +2768,6 @@
 		return 0;
 	}
 
-#ifdef VIDIOC_G_PRIORITY
 	case VIDIOC_G_PRIORITY:
 	{
 		enum v4l2_priority *p = arg;
@@ -2785,9 +2781,7 @@
 
 		return v4l2_prio_change(&btv->prio, &fh->prio, *prio);
 	}
-#endif
 
-	
 	case VIDIOC_ENUMSTD:
 	case VIDIOC_G_STD:
 	case VIDIOC_S_STD:
@@ -2839,12 +2833,14 @@
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		if (locked_btres(fh->btv,RESOURCE_VIDEO))
 			return -EBUSY;
-		retval = videobuf_read_one(file, &fh->cap, data, count, ppos);
+		retval = videobuf_read_one(&fh->cap, data, count, ppos,
+					   file->f_flags & O_NONBLOCK);
 		break;
 	case V4L2_BUF_TYPE_VBI_CAPTURE:
 		if (!check_alloc_btres(fh->btv,fh,RESOURCE_VBI))
 			return -EBUSY;
-		retval = videobuf_read_stream(file, &fh->vbi, data, count, ppos, 1);
+		retval = videobuf_read_stream(&fh->vbi, data, count, ppos, 1,
+					      file->f_flags & O_NONBLOCK);
 		break;
 	default:
 		BUG();
@@ -2860,7 +2856,7 @@
 
 	if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) {
 		if (!check_alloc_btres(fh->btv,fh,RESOURCE_VBI))
-			return -EBUSY;
+			return POLLERR;
 		return videobuf_poll_stream(file, &fh->vbi, wait);
 	}
 
@@ -2885,17 +2881,17 @@
 			}
 			fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
 			field = videobuf_next_field(&fh->cap);
-			if (0 != fh->cap.ops->buf_prepare(file,fh->cap.read_buf,field)) {
+			if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
 				up(&fh->cap.lock);
 				return POLLERR;
 			}
-			fh->cap.ops->buf_queue(file,fh->cap.read_buf);
+			fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
 			fh->cap.read_off = 0;
 		}
 		up(&fh->cap.lock);
 		buf = (struct bttv_buffer*)fh->cap.read_buf;
 	}
-	
+
 	poll_wait(file, &buf->vb.done, wait);
 	if (buf->vb.state == STATE_DONE ||
 	    buf->vb.state == STATE_ERROR)
@@ -2941,20 +2937,20 @@
 	*fh = btv->init;
 	fh->type = type;
 	fh->ov.setup_ok = 0;
-#ifdef VIDIOC_G_PRIORITY
 	v4l2_prio_open(&btv->prio,&fh->prio);
-#endif
 
 	videobuf_queue_init(&fh->cap, &bttv_video_qops,
 			    btv->c.pci, &btv->s_lock,
 			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
 			    V4L2_FIELD_INTERLACED,
-			    sizeof(struct bttv_buffer));
+			    sizeof(struct bttv_buffer),
+			    fh);
 	videobuf_queue_init(&fh->vbi, &bttv_vbi_qops,
 			    btv->c.pci, &btv->s_lock,
 			    V4L2_BUF_TYPE_VBI_CAPTURE,
 			    V4L2_FIELD_SEQ_TB,
-			    sizeof(struct bttv_buffer));
+			    sizeof(struct bttv_buffer),
+			    fh);
 	i2c_vidiocschan(btv);
 
 	btv->users++;
@@ -2972,29 +2968,27 @@
 	/* turn off overlay */
 	if (check_btres(fh, RESOURCE_OVERLAY))
 		bttv_switch_overlay(btv,fh,NULL);
-	
+
 	/* stop video capture */
 	if (check_btres(fh, RESOURCE_VIDEO)) {
-		videobuf_streamoff(file,&fh->cap);
+		videobuf_streamoff(&fh->cap);
 		free_btres(btv,fh,RESOURCE_VIDEO);
 	}
 	if (fh->cap.read_buf) {
-		buffer_release(file,fh->cap.read_buf);
+		buffer_release(&fh->cap,fh->cap.read_buf);
 		kfree(fh->cap.read_buf);
 	}
 
 	/* stop vbi capture */
 	if (check_btres(fh, RESOURCE_VBI)) {
 		if (fh->vbi.streaming)
-			videobuf_streamoff(file,&fh->vbi);
+			videobuf_streamoff(&fh->vbi);
 		if (fh->vbi.reading)
-			videobuf_read_stop(file,&fh->vbi);
+			videobuf_read_stop(&fh->vbi);
 		free_btres(btv,fh,RESOURCE_VBI);
 	}
 
-#ifdef VIDIOC_G_PRIORITY
 	v4l2_prio_close(&btv->prio,&fh->prio);
-#endif
 	file->private_data = NULL;
 	kfree(fh);
 
@@ -3011,7 +3005,7 @@
 	dprintk("bttv%d: mmap type=%s 0x%lx+%ld\n",
 		fh->btv->c.nr, v4l2_type_names[fh->type],
 		vma->vm_start, vma->vm_end - vma->vm_start);
-	return videobuf_mmap_mapper(vma,bttv_queue(fh));
+	return videobuf_mmap_mapper(bttv_queue(fh),vma);
 }
 
 static struct file_operations bttv_fops =
@@ -3127,7 +3121,7 @@
         case VIDIOCSTUNER:
 		/* nothing to do */
 		return 0;
-	
+
 	case BTTV_VERSION:
         case VIDIOCGFREQ:
         case VIDIOCSFREQ:
@@ -3193,7 +3187,7 @@
 static void bttv_print_irqbits(u32 print, u32 mark)
 {
 	unsigned int i;
-	
+
 	printk("bits:");
 	for (i = 0; i < ARRAY_SIZE(irq_name); i++) {
 		if (print & (1 << i))
@@ -3249,7 +3243,7 @@
 
 	/* capture request ? */
 	if (!list_empty(&btv->capture)) {
-		set->irqflags = 1;
+		set->frame_irq = 1;
 		item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue);
 		if (V4L2_FIELD_HAS_TOP(item->vb.field))
 			set->top    = item;
@@ -3270,7 +3264,7 @@
 					set->bottom = item;
 				}
 				if (NULL != set->top  &&  NULL != set->bottom)
-					set->topirq = 2;
+					set->top_irq = 2;
 			}
 		}
 	}
@@ -3296,7 +3290,7 @@
 
 	dprintk("bttv%d: next set: top=%p bottom=%p [screen=%p,irq=%d,%d]\n",
 		btv->c.nr,set->top, set->bottom,
-		btv->screen,set->irqflags,set->topirq);
+		btv->screen,set->frame_irq,set->top_irq);
 	return 0;
 }
 
@@ -3360,7 +3354,7 @@
 	struct bttv_buffer *ovbi;
 	struct bttv_buffer *item;
 	unsigned long flags;
-	
+
 	if (bttv_verbose) {
 		printk(KERN_INFO "bttv%d: timeout: drop=%d irq=%d/%d, risc=%08x, ",
 		       btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total,
@@ -3370,16 +3364,17 @@
 	}
 
 	spin_lock_irqsave(&btv->s_lock,flags);
-	
+
 	/* deactivate stuff */
 	memset(&new,0,sizeof(new));
 	old  = btv->curr;
 	ovbi = btv->cvbi;
 	btv->curr = new;
 	btv->cvbi = NULL;
+	btv->loop_irq = 0;
 	bttv_buffer_activate_video(btv, &new);
 	bttv_buffer_activate_vbi(btv,   NULL);
-	bttv_set_dma(btv, 0, 0);
+	bttv_set_dma(btv, 0);
 
 	/* wake up */
 	bttv_irq_wakeup_video(btv, &old, &new, STATE_ERROR);
@@ -3398,7 +3393,7 @@
 		item->vb.state = STATE_ERROR;
 		wake_up(&item->vb.done);
 	}
-	
+
 	btv->errors++;
 	spin_unlock_irqrestore(&btv->s_lock,flags);
 }
@@ -3412,7 +3407,7 @@
 		return;
 
 	spin_lock(&btv->s_lock);
-	btv->curr.topirq = 0;
+	btv->curr.top_irq = 0;
 	btv->curr.top = NULL;
 	bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
 
@@ -3452,12 +3447,13 @@
 		spin_unlock(&btv->s_lock);
 		return;
 	}
-	
+
 	/* switch over */
 	old = btv->curr;
 	btv->curr = new;
+	btv->loop_irq &= ~1;
 	bttv_buffer_activate_video(btv, &new);
-	bttv_set_dma(btv, 0, new.irqflags);
+	bttv_set_dma(btv, 0);
 
 	/* switch input */
 	if (UNSET != btv->new_input) {
@@ -3495,8 +3491,9 @@
 
 	/* switch */
 	btv->cvbi = new;
+	btv->loop_irq &= ~4;
 	bttv_buffer_activate_vbi(btv, new);
-	bttv_set_dma(btv, 0, btv->curr.irqflags);
+	bttv_set_dma(btv, 0);
 
 	bttv_irq_wakeup_vbi(btv, old, STATE_DONE);
 	spin_unlock(&btv->s_lock);
@@ -3542,7 +3539,7 @@
 			printk("\n");
 		}
 
-		if (astat&BT848_INT_VSYNC) 
+		if (astat&BT848_INT_VSYNC)
                         btv->field_count++;
 
 		if (astat & BT848_INT_GPINT) {
@@ -3587,7 +3584,7 @@
 		count++;
 		if (count > 4) {
 			btwrite(0, BT848_INT_MASK);
-			printk(KERN_ERR 
+			printk(KERN_ERR
 			       "bttv%d: IRQ lockup, cleared int mask [", btv->c.nr);
 			bttv_print_irqbits(stat,astat);
 			printk("]\n");
@@ -3695,9 +3692,9 @@
 {
 #if defined(__powerpc__)
         unsigned int cmd;
-	
+
         pci_read_config_dword(dev, PCI_COMMAND, &cmd);
-        cmd = (cmd | PCI_COMMAND_MEMORY ); 
+        cmd = (cmd | PCI_COMMAND_MEMORY );
         pci_write_config_dword(dev, PCI_COMMAND, cmd);
 #endif
 }
@@ -3727,21 +3724,19 @@
         INIT_LIST_HEAD(&btv->c.subs);
         INIT_LIST_HEAD(&btv->capture);
         INIT_LIST_HEAD(&btv->vcapture);
-#ifdef VIDIOC_G_PRIORITY
 	v4l2_prio_init(&btv->prio);
-#endif
 
 	init_timer(&btv->timeout);
 	btv->timeout.function = bttv_irq_timeout;
 	btv->timeout.data     = (unsigned long)btv;
-	
+
         btv->i2c_rc = -1;
         btv->tuner_type  = UNSET;
         btv->pinnacle_id = UNSET;
 	btv->new_input   = UNSET;
 	btv->gpioirq     = 1;
 	btv->has_radio=radio[btv->c.nr];
-	
+
 	/* pci stuff (init, get irq/mmio, ... */
 	btv->c.pci = dev;
         btv->id  = dev->device;
@@ -3778,7 +3773,7 @@
         printk("irq: %d, latency: %d, mmio: 0x%lx\n",
 	       btv->c.pci->irq, lat, pci_resource_start(dev,0));
 	schedule();
-	
+
 	btv->bt848_mmio=ioremap(pci_resource_start(dev,0), 0x1000);
 	if (NULL == ioremap(pci_resource_start(dev,0), 0x1000)) {
 		printk("bttv%d: ioremap() failed\n", btv->c.nr);
@@ -3813,7 +3808,7 @@
 	btv->opt_vcr_hack   = vcr_hack;
 	btv->opt_whitecrush_upper  = whitecrush_upper;
 	btv->opt_whitecrush_lower  = whitecrush_lower;
-	
+
 	/* fill struct bttv with some useful defaults */
 	btv->init.btv         = btv;
 	btv->init.ov.w.width  = 320;
@@ -3870,7 +3865,7 @@
 
  fail2:
         free_irq(btv->c.pci->irq,btv);
-	
+
  fail1:
 	if (btv->bt848_mmio)
 		iounmap(btv->bt848_mmio);
@@ -3899,7 +3894,7 @@
 	btv->shutdown=1;
 	wake_up(&btv->gpioq);
 	bttv_sub_del_devices(&btv->c);
-	
+
         /* unregister i2c_bus + input */
 	fini_bttv_i2c(btv);
 
@@ -3925,17 +3920,19 @@
 	struct bttv_buffer_set idle;
 	unsigned long flags;
 
-	printk("bttv%d: suspend %d\n", btv->c.nr, state);
+	dprintk("bttv%d: suspend %d\n", btv->c.nr, state);
 
 	/* stop dma + irqs */
 	spin_lock_irqsave(&btv->s_lock,flags);
 	memset(&idle, 0, sizeof(idle));
 	btv->state.video = btv->curr;
 	btv->state.vbi   = btv->cvbi;
+	btv->state.loop_irq = btv->loop_irq;
 	btv->curr = idle;
+	btv->loop_irq = 0;
 	bttv_buffer_activate_video(btv, &idle);
 	bttv_buffer_activate_vbi(btv, NULL);
-	bttv_set_dma(btv, 0, 0);
+	bttv_set_dma(btv, 0);
 	btwrite(0, BT848_INT_MASK);
 	spin_unlock_irqrestore(&btv->s_lock,flags);
 
@@ -3944,7 +3941,7 @@
 	btv->state.gpio_data   = gpio_read();
 
 	/* save pci state */
-	pci_save_state(pci_dev, btv->state.pci_cfg);
+	pci_save_state(pci_dev);
 	if (0 != pci_set_power_state(pci_dev, state)) {
 		pci_disable_device(pci_dev);
 		btv->state.disabled = 1;
@@ -3957,7 +3954,7 @@
         struct bttv *btv = pci_get_drvdata(pci_dev);
 	unsigned long flags;
 
-	printk("bttv%d: resume\n", btv->c.nr);
+	dprintk("bttv%d: resume\n", btv->c.nr);
 
 	/* restore pci state */
 	if (btv->state.disabled) {
@@ -3965,7 +3962,7 @@
 		btv->state.disabled = 0;
 	}
 	pci_set_power_state(pci_dev, 0);
-	pci_restore_state(pci_dev, btv->state.pci_cfg);
+	pci_restore_state(pci_dev);
 
 	/* restore bt878 state */
 	bttv_reinit_bt848(btv);
@@ -3976,9 +3973,10 @@
 	spin_lock_irqsave(&btv->s_lock,flags);
 	btv->curr = btv->state.video;
 	btv->cvbi = btv->state.vbi;
+	btv->loop_irq = btv->state.loop_irq;
 	bttv_buffer_activate_video(btv, &btv->curr);
 	bttv_buffer_activate_vbi(btv, btv->cvbi);
-	bttv_set_dma(btv, 0, btv->curr.irqflags);
+	bttv_set_dma(btv, 0);
 	spin_unlock_irqrestore(&btv->s_lock,flags);
 	return 0;
 }
@@ -4002,14 +4000,12 @@
         .id_table = bttv_pci_tbl,
         .probe    = bttv_probe,
         .remove   = __devexit_p(bttv_remove),
-
-	.suspend    = bttv_suspend,
-	.resume     = bttv_resume,
+	.suspend  = bttv_suspend,
+	.resume   = bttv_resume,
 };
 
 static int bttv_init_module(void)
 {
-	int rc;
 	bttv_num = 0;
 
 	printk(KERN_INFO "bttv: driver version %d.%d.%d loaded\n",
@@ -4032,13 +4028,7 @@
 	bttv_check_chipset();
 
 	bus_register(&bttv_sub_bus_type);
-	rc = pci_module_init(&bttv_pci_driver);
-	if (-ENODEV == rc) {
-		/* plenty of people trying to use bttv for the cx2388x ... */
-		if (NULL != pci_find_device(0x14f1, 0x8800, NULL))
-			printk("bttv doesn't support your Conexant 2388x card.\n");
-	}
-	return rc;
+	return pci_module_init(&bttv_pci_driver);
 }
 
 static void bttv_cleanup_module(void)
diff -Nru a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bttv-gpio.c
--- a/drivers/media/video/bttv-gpio.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/media/video/bttv-gpio.c	2004-12-24 13:37:04 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: bttv-gpio.c,v 1.6 2004/11/03 09:04:50 kraxel Exp $
+
     bttv-gpio.c  --  gpio sub drivers
 
     sysfs-based sub driver interface for bttv
@@ -22,7 +24,7 @@
     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>
@@ -61,6 +63,7 @@
 int bttv_sub_add_device(struct bttv_core *core, char *name)
 {
 	struct bttv_sub_device *sub;
+	int err;
 
 	sub = kmalloc(sizeof(*sub),GFP_KERNEL);
 	if (NULL == sub)
@@ -74,9 +77,13 @@
 	snprintf(sub->dev.bus_id,sizeof(sub->dev.bus_id),"%s%d",
 		 name, core->nr);
 
+	err = device_register(&sub->dev);
+	if (0 != err) {
+		kfree(sub);
+		return err;
+	}
 	printk("bttv%d: add subdevice \"%s\"\n", core->nr, sub->dev.bus_id);
 	list_add_tail(&sub->list,&core->subs);
-	device_register(&sub->dev);
 	return 0;
 }
 
@@ -127,8 +134,7 @@
 {
 	sub->drv.bus = &bttv_sub_bus_type;
 	snprintf(sub->wanted,sizeof(sub->wanted),"%s",wanted);
-	driver_register(&sub->drv);
-	return 0;
+	return driver_register(&sub->drv);
 }
 EXPORT_SYMBOL(bttv_sub_register);
 
diff -Nru a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
--- a/drivers/media/video/bttv-i2c.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/media/video/bttv-i2c.c	2004-12-24 13:36:17 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: bttv-i2c.c,v 1.13 2004/11/07 13:17:15 kraxel Exp $
+
     bttv-i2c.c  --  all the i2c code is here
 
     bttv - Bt848 frame grabber driver
@@ -20,7 +22,7 @@
     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>
@@ -35,17 +37,16 @@
 static struct i2c_adapter bttv_i2c_adap_hw_template;
 static struct i2c_client bttv_i2c_client_template;
 
-#ifndef I2C_PEC
-static void bttv_inc_use(struct i2c_adapter *adap);
-static void bttv_dec_use(struct i2c_adapter *adap);
-#endif
 static int attach_inform(struct i2c_client *client);
 static int detach_inform(struct i2c_client *client);
 
 static int i2c_debug = 0;
 static int i2c_hw = 0;
-MODULE_PARM(i2c_debug,"i");
-MODULE_PARM(i2c_hw,"i");
+static int i2c_scan = 0;
+module_param(i2c_debug, int, 0644);
+module_param(i2c_hw,    int, 0444);
+module_param(i2c_scan,  int, 0444);
+MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
 
 /* ----------------------------------------------------------------------- */
 /* I2C functions - bitbanging adapter (software i2c)                       */
@@ -78,7 +79,7 @@
 {
 	struct bttv *btv = (struct bttv*)data;
 	int state;
-	
+
 	state = btread(BT848_I2C) & 0x02 ? 1 : 0;
 	return state;
 }
@@ -103,12 +104,7 @@
 };
 
 static struct i2c_adapter bttv_i2c_adap_sw_template = {
-#ifdef I2C_PEC
 	.owner             = THIS_MODULE,
-#else
-	.inc_use           = bttv_inc_use,
-	.dec_use           = bttv_dec_use,
-#endif
 #ifdef I2C_CLASS_TV_ANALOG
 	.class             = I2C_CLASS_TV_ANALOG,
 #endif
@@ -121,7 +117,7 @@
 /* ----------------------------------------------------------------------- */
 /* I2C functions - hardware i2c                                            */
 
-static int algo_control(struct i2c_adapter *adapter, 
+static int algo_control(struct i2c_adapter *adapter,
 			unsigned int cmd, unsigned long arg)
 {
 	return 0;
@@ -137,12 +133,10 @@
 {
 	DECLARE_WAITQUEUE(wait, current);
 	int rc = 0;
-	
+
 	add_wait_queue(&btv->i2c_queue, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
 	if (0 == btv->i2c_done)
-		schedule_timeout(HZ/50+1);
-	set_current_state(TASK_RUNNING);
+		msleep_interruptible(20);
 	remove_wait_queue(&btv->i2c_queue, &wait);
 
 	if (0 == btv->i2c_done)
@@ -287,12 +281,7 @@
 };
 
 static struct i2c_adapter bttv_i2c_adap_hw_template = {
-#ifdef I2C_PEC
 	.owner         = THIS_MODULE,
-#else
-	.inc_use       = bttv_inc_use,
-	.dec_use       = bttv_dec_use,
-#endif
 #ifdef I2C_CLASS_TV_ANALOG
 	.class         = I2C_CLASS_TV_ANALOG,
 #endif
@@ -306,18 +295,6 @@
 /* ----------------------------------------------------------------------- */
 /* I2C functions - common stuff                                            */
 
-#ifndef I2C_PEC
-static void bttv_inc_use(struct i2c_adapter *adap)
-{
-	MOD_INC_USE_COUNT;
-}
-
-static void bttv_dec_use(struct i2c_adapter *adap)
-{
-	MOD_DEC_USE_COUNT;
-}
-#endif
-
 static int attach_inform(struct i2c_client *client)
 {
         struct bttv *btv = i2c_get_adapdata(client->adapter);
@@ -364,7 +341,7 @@
 
 
 /* read I2C */
-int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for) 
+int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for)
 {
         unsigned char buffer = 0;
 
@@ -409,7 +386,7 @@
 void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr)
 {
 	int i;
-        
+
 	if (bttv_I2CWrite(btv, addr, 0, -1, 0)<0) {
 		printk(KERN_WARNING "bttv: readee error\n");
 		return;
@@ -423,6 +400,30 @@
 	}
 }
 
+static char *i2c_devs[128] = {
+	[ 0x30 >> 1 ] = "IR (hauppauge)",
+	[ 0x80 >> 1 ] = "msp34xx",
+	[ 0x86 >> 1 ] = "tda9887",
+	[ 0xa0 >> 1 ] = "eeprom",
+	[ 0xc0 >> 1 ] = "tuner (analog)",
+	[ 0xc2 >> 1 ] = "tuner (analog)",
+};
+
+static void do_i2c_scan(char *name, struct i2c_client *c)
+{
+	unsigned char buf;
+	int i,rc;
+
+	for (i = 0; i < 128; i++) {
+		c->addr = i;
+		rc = i2c_master_recv(c,&buf,0);
+		if (rc < 0)
+			continue;
+		printk("%s: i2c scan: found device @ 0x%x  [%s]\n",
+		       name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
+	}
+}
+
 /* init + register i2c algo-bit adapter */
 int __devinit init_bttv_i2c(struct bttv *btv)
 {
@@ -453,6 +454,13 @@
         i2c_set_adapdata(&btv->c.i2c_adap, btv);
         btv->i2c_client.adapter = &btv->c.i2c_adap;
 
+#ifdef I2C_CLASS_TV_ANALOG
+	if (bttv_tvcards[btv->c.type].no_video)
+		btv->c.i2c_adap.class &= ~I2C_CLASS_TV_ANALOG;
+	if (bttv_tvcards[btv->c.type].has_dvb)
+		btv->c.i2c_adap.class |= I2C_CLASS_TV_DIGITAL;
+#endif
+
 	if (btv->use_i2c_hw) {
 		btv->i2c_rc = i2c_add_adapter(&btv->c.i2c_adap);
 	} else {
@@ -460,6 +468,8 @@
 		bttv_bit_setsda(btv,1);
 		btv->i2c_rc = i2c_bit_add_bus(&btv->c.i2c_adap);
 	}
+	if (0 == btv->i2c_rc && i2c_scan)
+		do_i2c_scan(btv->c.name,&btv->i2c_client);
 	return btv->i2c_rc;
 }
 
diff -Nru a/drivers/media/video/bttv-if.c b/drivers/media/video/bttv-if.c
--- a/drivers/media/video/bttv-if.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/video/bttv-if.c	2004-12-24 13:36:18 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: bttv-if.c,v 1.3 2004/10/13 10:39:00 kraxel Exp $
+
     bttv-if.c  --  old gpio interface to other kernel modules
                    don't use in new code, will go away in 2.7
 		   have a look at bttv-gpio.c instead.
@@ -22,7 +24,7 @@
     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>
@@ -80,7 +82,7 @@
 	if (card >= bttv_num) {
 		return -EINVAL;
 	}
-	
+
 	btv = &bttvs[card];
 	gpio_inout(mask,data);
 	if (bttv_gpio)
@@ -91,7 +93,7 @@
 int bttv_read_gpio(unsigned int card, unsigned long *data)
 {
 	struct bttv *btv;
-	
+
 	if (card >= bttv_num) {
 		return -EINVAL;
 	}
@@ -102,7 +104,7 @@
 		return -ENODEV;
 	}
 
-/* prior setting BT848_GPIO_REG_INP is (probably) not needed 
+/* prior setting BT848_GPIO_REG_INP is (probably) not needed
    because we set direct input on init */
 	*data = gpio_read();
 	return 0;
@@ -111,14 +113,14 @@
 int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data)
 {
 	struct bttv *btv;
-	
+
 	if (card >= bttv_num) {
 		return -EINVAL;
 	}
 
 	btv = &bttvs[card];
 
-/* prior setting BT848_GPIO_REG_INP is (probably) not needed 
+/* prior setting BT848_GPIO_REG_INP is (probably) not needed
    because direct input is set on init */
 	gpio_bits(mask,data);
 	if (bttv_gpio)
diff -Nru a/drivers/media/video/bttv-risc.c b/drivers/media/video/bttv-risc.c
--- a/drivers/media/video/bttv-risc.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/media/video/bttv-risc.c	2004-12-24 13:36:49 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: bttv-risc.c,v 1.9 2004/10/13 10:39:00 kraxel Exp $
+
     bttv-risc.c  --  interfaces to other kernel modules
 
     bttv risc code handling
@@ -55,8 +57,6 @@
 	instructions += 2;
 	if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0)
 		return rc;
-	dprintk("bttv%d: risc packed: bpl %d lines %d instr %d size %d ptr %p\n",
-		btv->c.nr, bpl, lines, instructions, risc->size, risc->cpu);
 
 	/* sync instruction */
 	rp = risc->cpu;
@@ -101,13 +101,11 @@
 			offset += todo;
 		}
 		offset += padding;
-		dprintk("bttv%d: risc packed:   line %d ptr %p\n",
-			btv->c.nr, line, rp);
 	}
-	dprintk("bttv%d: risc packed: %d sglist elems\n", btv->c.nr, (int)(sg-sglist));
 
 	/* save pointer to jmp instruction address */
 	risc->jmp = rp;
+	BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
 	return 0;
 }
 
@@ -155,15 +153,15 @@
 			break;
 		case 1:
 			if (topfield)
-				chroma = (line & 1) == 0;
+				chroma = ((line & 1) == 0);
 			else
-				chroma = (line & 1) == 1;
+				chroma = ((line & 1) == 1);
 			break;
 		case 2:
 			if (topfield)
-				chroma = (line & 3) == 0;
+				chroma = ((line & 3) == 0);
 			else
-				chroma = (line & 3) == 2;
+				chroma = ((line & 3) == 2);
 			break;
 		default:
 			chroma = 0;
@@ -225,6 +223,7 @@
 
 	/* save pointer to jmp instruction address */
 	risc->jmp = rp;
+	BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
 	return 0;
 }
 
@@ -241,7 +240,7 @@
 	/* skip list for window clipping */
 	if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL)))
 		return -ENOMEM;
-	
+
 	/* estimate risc mem: worst case is (clip+1) * lines instructions
 	   + sync + jump (all 2 dwords) */
 	instructions  = (ov->nclips + 1) *
@@ -294,7 +293,7 @@
 				ra = addr + (fmt->depth>>3)*start;
 			else
 				ra = 0;
-				
+
 			if (0 == start)
 				ri |= BT848_RISC_SOL;
 			if (ov->w.width == end)
@@ -309,6 +308,7 @@
 
 	/* save pointer to jmp instruction address */
 	risc->jmp = rp;
+	BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
 	kfree(skips);
 	return 0;
 }
@@ -391,7 +391,7 @@
 /* risc group / risc main loop / dma management               */
 
 void
-bttv_set_dma(struct bttv *btv, int override, int irqflags)
+bttv_set_dma(struct bttv *btv, int override)
 {
 	unsigned long cmd;
 	int capctl;
@@ -407,26 +407,26 @@
 	capctl |= override;
 
 	d2printk(KERN_DEBUG
-		 "bttv%d: capctl=%x irq=%d top=%08Lx/%08Lx even=%08Lx/%08Lx\n",
-		 btv->c.nr,capctl,irqflags,
+		 "bttv%d: capctl=%x lirq=%d top=%08Lx/%08Lx even=%08Lx/%08Lx\n",
+		 btv->c.nr,capctl,btv->loop_irq,
 		 btv->cvbi         ? (unsigned long long)btv->cvbi->top.dma            : 0,
 		 btv->curr.top     ? (unsigned long long)btv->curr.top->top.dma        : 0,
 		 btv->cvbi         ? (unsigned long long)btv->cvbi->bottom.dma         : 0,
 		 btv->curr.bottom  ? (unsigned long long)btv->curr.bottom->bottom.dma  : 0);
-	
+
 	cmd = BT848_RISC_JUMP;
-	if (irqflags) {
+	if (btv->loop_irq) {
 		cmd |= BT848_RISC_IRQ;
-		cmd |= (irqflags  & 0x0f) << 16;
-		cmd |= (~irqflags & 0x0f) << 20;
+		cmd |= (btv->loop_irq  & 0x0f) << 16;
+		cmd |= (~btv->loop_irq & 0x0f) << 20;
 	}
-	if (irqflags || btv->cvbi) {
+	if (btv->curr.frame_irq || btv->loop_irq || btv->cvbi) {
 		mod_timer(&btv->timeout, jiffies+BTTV_TIMEOUT);
 	} else {
 		del_timer(&btv->timeout);
 	}
         btv->main.cpu[RISC_SLOT_LOOP] = cpu_to_le32(cmd);
-	
+
 	btaor(capctl, ~0x0f, BT848_CAP_CTL);
 	if (capctl) {
 		if (btv->dma_on)
@@ -447,7 +447,7 @@
 bttv_risc_init_main(struct bttv *btv)
 {
 	int rc;
-	
+
 	if ((rc = btcx_riscmem_alloc(btv->c.pci,&btv->main,PAGE_SIZE)) < 0)
 		return rc;
 	dprintk(KERN_DEBUG "bttv%d: risc main @ %08Lx\n",
@@ -559,8 +559,10 @@
 		}
 		bttv_apply_geo(btv, &set->top->geo, 1);
 		bttv_apply_geo(btv, &set->bottom->geo,0);
-		bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top, set->topirq);
-		bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom, 0);
+		bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top,
+			       set->top_irq);
+		bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom,
+			       set->frame_irq);
 		btaor((set->top->btformat & 0xf0) | (set->bottom->btformat & 0x0f),
 		      ~0xff, BT848_COLOR_FMT);
 		btaor((set->top->btswap & 0x0a) | (set->bottom->btswap & 0x05),
@@ -571,7 +573,8 @@
 			list_del(&set->top->vb.queue);
 		bttv_apply_geo(btv, &set->top->geo,1);
 		bttv_apply_geo(btv, &set->top->geo,0);
-		bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top, 0);
+		bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top,
+			       set->frame_irq);
 		bttv_risc_hook(btv, RISC_SLOT_E_FIELD, NULL,           0);
 		btaor(set->top->btformat & 0xff, ~0xff, BT848_COLOR_FMT);
 		btaor(set->top->btswap & 0x0f,   ~0x0f, BT848_COLOR_CTL);
@@ -581,8 +584,9 @@
 			list_del(&set->bottom->vb.queue);
 		bttv_apply_geo(btv, &set->bottom->geo,1);
 		bttv_apply_geo(btv, &set->bottom->geo,0);
-		bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL,                 0);
-		bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom, 0);
+		bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
+		bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom,
+			       set->frame_irq);
 		btaor(set->bottom->btformat & 0xff, ~0xff, BT848_COLOR_FMT);
 		btaor(set->bottom->btswap & 0x0f,   ~0x0f, BT848_COLOR_CTL);
 	} else {
@@ -612,7 +616,7 @@
 
 		bttv_calc_geo(btv,&buf->geo,buf->vb.width,buf->vb.height,
 			      V4L2_FIELD_HAS_BOTH(buf->vb.field),buf->tvnorm);
-		
+
 		switch (buf->vb.field) {
 		case V4L2_FIELD_TOP:
 			bttv_risc_packed(btv,&buf->top,buf->vb.dma.sglist,
diff -Nru a/drivers/media/video/bttv-vbi.c b/drivers/media/video/bttv-vbi.c
--- a/drivers/media/video/bttv-vbi.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/media/video/bttv-vbi.c	2004-12-24 13:37:01 -08:00
@@ -1,19 +1,21 @@
 /*
+    $Id: bttv-vbi.c,v 1.7 2004/11/07 13:17:15 kraxel Exp $
+
     bttv - Bt848 frame grabber driver
     vbi interface
-    
+
     (c) 2002 Gerd Knorr <kraxel@bytesex.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 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.
@@ -35,9 +37,9 @@
 static unsigned int vbibufs = 4;
 static unsigned int vbi_debug = 0;
 
-MODULE_PARM(vbibufs,"i");
+module_param(vbibufs,   int, 0444);
+module_param(vbi_debug, int, 0644);
 MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32, default 4");
-MODULE_PARM(vbi_debug,"i");
 MODULE_PARM_DESC(vbi_debug,"vbi code debug messages, default is 0 (no)");
 
 #ifdef dprintk
@@ -61,10 +63,10 @@
 	return 0;
 }
 
-static int vbi_buffer_setup(struct file *file,
+static int vbi_buffer_setup(struct videobuf_queue *q,
 			    unsigned int *count, unsigned int *size)
 {
-	struct bttv_fh *fh = file->private_data;
+	struct bttv_fh *fh = q->priv_data;
 	struct bttv *btv = fh->btv;
 
 	if (0 == *count)
@@ -74,14 +76,15 @@
 	return 0;
 }
 
-static int vbi_buffer_prepare(struct file *file, struct videobuf_buffer *vb,
+static int vbi_buffer_prepare(struct videobuf_queue *q,
+			      struct videobuf_buffer *vb,
 			      enum v4l2_field field)
 {
-	struct bttv_fh *fh = file->private_data;
+	struct bttv_fh *fh = q->priv_data;
 	struct bttv *btv = fh->btv;
-	struct bttv_buffer *buf = (struct bttv_buffer*)vb;
+	struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
 	int rc;
-	
+
 	buf->vb.size = fh->lines * 2 * 2048;
 	if (0 != buf->vb.baddr  &&  buf->vb.bsize < buf->vb.size)
 		return -EINVAL;
@@ -105,27 +108,27 @@
 }
 
 static void
-vbi_buffer_queue(struct file *file, struct videobuf_buffer *vb)
+vbi_buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct bttv_fh *fh = file->private_data;
+	struct bttv_fh *fh = q->priv_data;
 	struct bttv *btv = fh->btv;
-	struct bttv_buffer *buf = (struct bttv_buffer*)vb;
-	
+	struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
+
 	dprintk("queue %p\n",vb);
 	buf->vb.state = STATE_QUEUED;
 	list_add_tail(&buf->vb.queue,&btv->vcapture);
 	if (NULL == btv->cvbi) {
-		fh->btv->curr.irqflags |= 4;
-		bttv_set_dma(btv,0x0c,fh->btv->curr.irqflags);
+		fh->btv->loop_irq |= 4;
+		bttv_set_dma(btv,0x0c);
 	}
 }
 
-static void vbi_buffer_release(struct file *file, struct videobuf_buffer *vb)
+static void vbi_buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct bttv_fh *fh = file->private_data;
+	struct bttv_fh *fh = q->priv_data;
 	struct bttv *btv = fh->btv;
-	struct bttv_buffer *buf = (struct bttv_buffer*)vb;
-	
+	struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
+
 	dprintk("free %p\n",vb);
 	bttv_dma_free(fh->btv,buf);
 }
diff -Nru a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h
--- a/drivers/media/video/bttv.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/video/bttv.h	2004-12-24 13:36:18 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: bttv.h,v 1.10 2004/10/13 10:39:00 kraxel Exp $
+ *
  *  bttv - Bt848 frame grabber driver
  *
  *  card ID's and external interfaces of the bttv driver
@@ -24,9 +26,9 @@
 #define BTTV_HAUPPAUGE     0x02
 #define BTTV_STB           0x03
 #define BTTV_INTEL         0x04
-#define BTTV_DIAMOND       0x05 
-#define BTTV_AVERMEDIA     0x06 
-#define BTTV_MATRIX_VISION 0x07 
+#define BTTV_DIAMOND       0x05
+#define BTTV_AVERMEDIA     0x06
+#define BTTV_MATRIX_VISION 0x07
 #define BTTV_FLYVIDEO      0x08
 #define BTTV_TURBOTV       0x09
 #define BTTV_HAUPPAUGE878  0x0a
@@ -130,6 +132,7 @@
 #define BTTV_MATRIX_VISIONSQ  0x7d
 #define BTTV_MATRIX_VISIONSLC 0x7e
 #define BTTV_APAC_VIEWCOMP  0x7f
+#define BTTV_DVICO_DVBT_LITE  0x80
 
 /* i2c address list */
 #define I2C_TSA5522        0xc2
@@ -227,9 +230,6 @@
 extern void tea5757_set_freq(struct bttv *btv, unsigned short freq);
 extern void bttv_tda9880_setnorm(struct bttv *btv, int norm);
 
-/* kernel cmd line parse helper */
-extern int bttv_parse(char *str, int max, int *vals);
-
 /* extra tweaks for some chipsets */
 extern void bttv_check_chipset(void);
 extern int bttv_handle_chipset(struct bttv *btv);
@@ -242,7 +242,7 @@
 
 /* returns card type + card ID (for bt878-based ones)
    for possible values see lines below beginning with #define BTTV_UNKNOWN
-   returns negative value if error occurred 
+   returns negative value if error occurred
 */
 extern int bttv_get_cardinfo(unsigned int card, int *type,
 			     unsigned int *cardid);
@@ -265,18 +265,18 @@
 
 /* sets GPDATA register to new value:
   (data & mask) | (current_GPDATA_value & ~mask)
-  returns negative value if error occurred 
+  returns negative value if error occurred
 */
 extern int bttv_write_gpio(unsigned int card,
 			   unsigned long mask, unsigned long data);
 
-/* returns pointer to task queue which can be used as parameter to 
+/* returns pointer to task queue which can be used as parameter to
    interruptible_sleep_on
    in interrupt handler if BT848_INT_GPINT bit is set - this queue is activated
-   (wake_up_interruptible) and following call to the function bttv_read_gpio 
+   (wake_up_interruptible) and following call to the function bttv_read_gpio
    should return new value of GPDATA,
    returns NULL value if error occurred or queue is not available
-   WARNING: because there is no buffer for GPIO data, one MUST 
+   WARNING: because there is no buffer for GPIO data, one MUST
    process data ASAP
 */
 extern wait_queue_head_t* bttv_get_gpio_queue(unsigned int card);
diff -Nru a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h
--- a/drivers/media/video/bttvp.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/media/video/bttvp.h	2004-12-24 13:36:47 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: bttvp.h,v 1.12 2004/10/25 11:26:36 kraxel Exp $
+
     bttv - Bt848 frame grabber driver
 
     bttv's *private* header file  --  nobody other than bttv itself
@@ -127,8 +129,8 @@
 struct bttv_buffer_set {
 	struct bttv_buffer     *top;       /* top field buffer    */
 	struct bttv_buffer     *bottom;    /* bottom field buffer */
-	unsigned int           irqflags;
-	unsigned int           topirq;
+	unsigned int           top_irq;
+	unsigned int           frame_irq;
 };
 
 struct bttv_overlay {
@@ -143,7 +145,7 @@
 struct bttv_fh {
 	struct bttv              *btv;
 	int resources;
-#ifdef VIDIOC_G_PRIORITY 
+#ifdef VIDIOC_G_PRIORITY
 	enum v4l2_priority       prio;
 #endif
 	enum v4l2_buf_type       type;
@@ -189,7 +191,7 @@
 void bttv_apply_geo(struct bttv *btv, struct bttv_geometry *geo, int top);
 
 /* control dma register + risc main loop */
-void bttv_set_dma(struct bttv *btv, int override, int irqflags);
+void bttv_set_dma(struct bttv *btv, int override);
 int bttv_risc_init_main(struct bttv *btv);
 int bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
 		   int irqflags);
@@ -277,10 +279,10 @@
 };
 
 struct bttv_suspend_state {
-	u32  pci_cfg[64 / sizeof(u32)];
 	u32  gpio_enable;
 	u32  gpio_data;
 	int  disabled;
+	int  loop_irq;
 	struct bttv_buffer_set video;
 	struct bttv_buffer     *vbi;
 };
@@ -291,7 +293,7 @@
 	/* pci device config */
 	unsigned short id;
 	unsigned char revision;
-	unsigned char *bt848_mmio;   /* pointer to mmio */
+	unsigned char __iomem *bt848_mmio;   /* pointer to mmio */
 
 	/* card configuration info */
 	unsigned int cardid;   /* pci subsystem id (bt878 based ones) */
@@ -332,10 +334,10 @@
         struct semaphore lock;
 	int resources;
         struct semaphore reslock;
-#ifdef VIDIOC_G_PRIORITY 
+#ifdef VIDIOC_G_PRIORITY
 	struct v4l2_prio_state prio;
 #endif
-	
+
 	/* video state */
 	unsigned int input;
 	unsigned int audio;
@@ -381,6 +383,7 @@
 	struct list_head        vcapture;   /* vbi capture queue   */
 	struct bttv_buffer_set  curr;       /* active buffers      */
 	struct bttv_buffer      *cvbi;      /* active vbi buffer   */
+	int                     loop_irq;
 	int                     new_input;
 
 	unsigned long cap_ctl;
@@ -404,7 +407,7 @@
 
 #endif
 
-#define btwrite(dat,adr)    writel((dat), (char *) (btv->bt848_mmio+(adr)))
+#define btwrite(dat,adr)    writel((dat), btv->bt848_mmio+(adr))
 #define btread(adr)         readl(btv->bt848_mmio+(adr))
 
 #define btand(dat,adr)      btwrite((dat) & btread(adr), adr)
diff -Nru a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
--- a/drivers/media/video/bw-qcam.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/video/bw-qcam.c	2004-12-24 13:36:31 -08:00
@@ -91,11 +91,6 @@
 	return parport_read_status(q->pport);
 }
 
-static inline int read_lpcontrol(struct qcam_device *q)
-{
-	return parport_read_control(q->pport);
-}
-
 static inline int read_lpdata(struct qcam_device *q)
 {
 	return parport_read_data(q->pport);
@@ -249,8 +244,7 @@
 			   
 			if(runs++>maxpoll)
 			{
-				current->state=TASK_INTERRUPTIBLE;
-				schedule_timeout(HZ/200);
+				msleep_interruptible(5);
 			}
 			if(runs>(maxpoll+1000)) /* 5 seconds */
 				return -1;
@@ -269,8 +263,7 @@
 			   
 			if(runs++>maxpoll)
 			{
-				current->state=TASK_INTERRUPTIBLE;
-				schedule_timeout(HZ/200);
+				msleep_interruptible(5);
 			}
 			if(runs++>(maxpoll+1000)) /* 5 seconds */
 				return -1;
@@ -302,8 +295,7 @@
 		   
 		if(runs++>maxpoll)
 		{
-			current->state=TASK_INTERRUPTIBLE;
-			schedule_timeout(HZ/200);
+			msleep_interruptible(5);
 		}
 		if(runs++>(maxpoll+1000)) /* 5 seconds */
 			return 0;
@@ -669,8 +661,7 @@
 		   time will be 240 / 200 = 1.2 seconds. The compile-time
 		   default is to yield every 4 lines. */
 		if (i >= yield) {
-			current->state=TASK_INTERRUPTIBLE;
-			schedule_timeout(HZ/200);
+			msleep_interruptible(5);
 			yield = i + yieldlines;
 		}
 	}
diff -Nru a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
--- a/drivers/media/video/c-qcam.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/media/video/c-qcam.c	2004-12-24 13:36:48 -08:00
@@ -103,8 +103,7 @@
 	{
 		if (qcam_ready1(qcam) == value)
 			return 0;
-		current->state=TASK_INTERRUPTIBLE;
-		schedule_timeout(HZ/10);
+		msleep_interruptible(100);
 	}
 
 	/* Probably somebody pulled the plug out.  Not much we can do. */
@@ -129,8 +128,7 @@
 	{
 		if (qcam_ready2(qcam) == value)
 			return 0;
-		current->state=TASK_INTERRUPTIBLE;
-		schedule_timeout(HZ/10);
+		msleep_interruptible(100);
 	}
 
 	/* Probably somebody pulled the plug out.  Not much we can do. */
diff -Nru a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
--- a/drivers/media/video/cpia.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/media/video/cpia.c	2004-12-24 13:37:02 -08:00
@@ -37,6 +37,7 @@
 #include <linux/proc_fs.h>
 #include <linux/ctype.h>
 #include <linux/pagemap.h>
+#include <linux/delay.h>
 #include <asm/io.h>
 #include <asm/semaphore.h>
 
@@ -215,20 +216,6 @@
  * Memory management
  *
  **********************************************************************/
-
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *rvmalloc(unsigned long size)
 {
 	void *mem;
@@ -2886,9 +2873,7 @@
 				cond_resched();
 
 				/* sleep for 10 ms, hopefully ;) */
-				current->state = TASK_INTERRUPTIBLE;
-
-				schedule_timeout(10*HZ/1000);
+				msleep_interruptible(10);
 				if (signal_pending(current))
 					return -EINTR;
 
@@ -2951,8 +2936,7 @@
 		        		   CPIA_GRAB_SINGLE, 0, 0, 0);
 				/* FIXME: Trial & error - need up to 70ms for
 				   the grab mode change to complete ? */
-				current->state = TASK_INTERRUPTIBLE;
-				schedule_timeout(70*HZ / 1000);
+				msleep_interruptible(70);
 				if (signal_pending(current))
 					return -EINTR;
 			}
@@ -3003,8 +2987,7 @@
 {
 	if (do_command(cam, CPIA_COMMAND_GotoHiPower, 0, 0, 0, 0))
 		return -EIO;
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(40*HZ/1000);	/* windows driver does it too */
+	msleep_interruptible(40);	/* windows driver does it too */
 	if(signal_pending(current))
 		return -EINTR;
 	if (do_command(cam, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0))
@@ -3074,10 +3057,8 @@
 	
 	/* Wait 6 frames for the sensor to get all settings and
 	   AEC/ACB to settle */
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout((6*(cam->params.sensorFps.baserate ? 33 : 40) *
-	                    (1 << cam->params.sensorFps.divisor) + 10) *
-			 HZ / 1000);
+	msleep_interruptible(6*(cam->params.sensorFps.baserate ? 33 : 40) *
+			       (1 << cam->params.sensorFps.divisor) + 10);
 
 	if(signal_pending(current))
 		return -EINTR;
@@ -3800,8 +3781,8 @@
 
 	pos = (unsigned long)(cam->frame_buf);
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
-		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up(&cam->busy_lock);
 			return -EAGAIN;
 		}
@@ -4066,22 +4047,13 @@
 	proc_cpia_create();
 #endif
 
-#ifdef CONFIG_KMOD
-#ifdef CONFIG_VIDEO_CPIA_PP_MODULE
-	request_module("cpia_pp");
-#endif
-
-#ifdef CONFIG_VIDEO_CPIA_USB_MODULE
-	request_module("cpia_usb");
-#endif
-#endif	/* CONFIG_KMOD */
-
 #ifdef CONFIG_VIDEO_CPIA_PP
 	cpia_pp_init();
 #endif
 #ifdef CONFIG_VIDEO_CPIA_USB
 	cpia_usb_init();
 #endif
+
 	return 0;
 }
 
diff -Nru a/drivers/media/video/cx88/Makefile b/drivers/media/video/cx88/Makefile
--- a/drivers/media/video/cx88/Makefile	2004-12-24 13:36:30 -08:00
+++ b/drivers/media/video/cx88/Makefile	2004-12-24 13:36:30 -08:00
@@ -1,6 +1,10 @@
-cx88xx-objs	:= cx88-cards.o cx88-core.o
-cx8800-objs	:= cx88-video.o cx88-tvaudio.o cx88-i2c.o cx88-vbi.o
+cx88xx-objs	:= cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o
+cx8800-objs	:= cx88-video.o cx88-vbi.o
+cx8802-objs	:= cx88-mpeg.o
 
-obj-$(CONFIG_VIDEO_CX88) += cx88xx.o cx8800.o
+obj-$(CONFIG_VIDEO_CX88) += cx88xx.o cx8800.o cx8802.o cx88-blackbird.o
+obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o
 
-EXTRA_CFLAGS = -I$(src)/..
+EXTRA_CFLAGS += -I$(src)/..
+EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
+EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends
diff -Nru a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/video/cx88/cx88-blackbird.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,904 @@
+/*
+ * $Id: cx88-blackbird.c,v 1.17 2004/11/07 13:17:15 kraxel Exp $
+ *
+ *  Support for a cx23416 mpeg encoder via cx2388x host port.
+ *  "blackbird" reference design.
+ *
+ *    (c) 2004 Jelle Foks <jelle@foks.8m.com>
+ *    (c) 2004 Gerd Knorr <kraxel@bytesex.org>
+ *
+ *  Includes parts from the ivtv driver( http://ivtv.sourceforge.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 program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/firmware.h>
+
+#include "cx88.h"
+
+MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards");
+MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>");
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+static unsigned int mpegbufs = 8;
+module_param(mpegbufs,int,0644);
+MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32");
+
+static unsigned int debug = 0;
+module_param(debug,int,0644);
+MODULE_PARM_DESC(debug,"enable debug messages [blackbird]");
+
+#define dprintk(level,fmt, arg...)	if (debug >= level) \
+	printk(KERN_DEBUG "%s/2-bb: " fmt, dev->core->name , ## arg)
+
+static LIST_HEAD(cx8802_devlist);
+
+/* ------------------------------------------------------------------ */
+
+#define BLACKBIRD_FIRM_ENC_FILENAME "blackbird-fw-enc.bin"
+#define BLACKBIRD_FIRM_IMAGE_SIZE 256*1024
+
+/* defines below are from ivtv-driver.h */
+
+#define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF
+
+/*Firmware API commands*/
+#define IVTV_API_ENC_PING_FW 0x00000080
+#define IVTV_API_ENC_GETVER 0x000000C4
+#define IVTV_API_ENC_HALT_FW 0x000000C3
+#define IVTV_API_STD_TIMEOUT 0x00010000 /*units??*/
+//#define IVTV_API_ASSIGN_PGM_INDEX_INFO 0x000000c7
+#define IVTV_API_ASSIGN_STREAM_TYPE 0x000000b9
+#define IVTV_API_ASSIGN_OUTPUT_PORT 0x000000bb
+#define IVTV_API_ASSIGN_FRAMERATE 0x0000008f
+#define IVTV_API_ASSIGN_FRAME_SIZE 0x00000091
+#define IVTV_API_ASSIGN_ASPECT_RATIO 0x00000099
+#define IVTV_API_ASSIGN_BITRATES 0x00000095
+#define IVTV_API_ASSIGN_GOP_PROPERTIES 0x00000097
+#define IVTV_API_ASSIGN_3_2_PULLDOWN 0x000000b1
+#define IVTV_API_ASSIGN_GOP_CLOSURE 0x000000c5
+#define IVTV_API_ASSIGN_AUDIO_PROPERTIES 0x000000bd
+#define IVTV_API_ASSIGN_DNR_FILTER_MODE 0x0000009b
+#define IVTV_API_ASSIGN_DNR_FILTER_PROPS 0x0000009d
+#define IVTV_API_ASSIGN_CORING_LEVELS 0x0000009f
+#define IVTV_API_ASSIGN_SPATIAL_FILTER_TYPE 0x000000a1
+#define IVTV_API_ASSIGN_FRAME_DROP_RATE 0x000000d0
+#define IVTV_API_ASSIGN_PLACEHOLDER 0x000000d8
+#define IVTV_API_MUTE_VIDEO 0x000000d9
+#define IVTV_API_MUTE_AUDIO 0x000000da
+#define IVTV_API_INITIALIZE_INPUT 0x000000cd
+#define IVTV_API_REFRESH_INPUT 0x000000d3
+#define IVTV_API_ASSIGN_NUM_VSYNC_LINES 0x000000d6
+#define IVTV_API_BEGIN_CAPTURE 0x00000081
+//#define IVTV_API_PAUSE_ENCODER 0x000000d2
+//#define IVTV_API_EVENT_NOTIFICATION 0x000000d5
+#define IVTV_API_END_CAPTURE 0x00000082
+
+/* Registers */
+#define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8 /*| IVTV_REG_OFFSET*/)
+#define IVTV_REG_ENC_SDRAM_PRECHARGE (0x07FC /*| IVTV_REG_OFFSET*/)
+#define IVTV_REG_SPU (0x9050 /*| IVTV_REG_OFFSET*/)
+#define IVTV_REG_HW_BLOCKS (0x9054 /*| IVTV_REG_OFFSET*/)
+#define IVTV_REG_VPU (0x9058 /*| IVTV_REG_OFFSET*/)
+#define IVTV_REG_APU (0xA064 /*| IVTV_REG_OFFSET*/)
+
+/* ------------------------------------------------------------------ */
+
+static void host_setup(struct cx88_core *core)
+{
+	/* toggle reset of the host */
+	cx_write(MO_GPHST_SOFT_RST, 1);
+	udelay(100);
+	cx_write(MO_GPHST_SOFT_RST, 0);
+	udelay(100);
+
+	/* host port setup */
+	cx_write(MO_GPHST_WSC, 0x44444444U);
+	cx_write(MO_GPHST_XFR, 0);
+	cx_write(MO_GPHST_WDTH, 15);
+	cx_write(MO_GPHST_HDSHK, 0);
+	cx_write(MO_GPHST_MUX16, 0x44448888U);
+	cx_write(MO_GPHST_MODE, 0);
+}
+
+/* ------------------------------------------------------------------ */
+
+#define P1_MDATA0 0x390000
+#define P1_MDATA1 0x390001
+#define P1_MDATA2 0x390002
+#define P1_MDATA3 0x390003
+#define P1_MADDR2 0x390004
+#define P1_MADDR1 0x390005
+#define P1_MADDR0 0x390006
+#define P1_RDATA0 0x390008
+#define P1_RDATA1 0x390009
+#define P1_RDATA2 0x39000A
+#define P1_RDATA3 0x39000B
+#define P1_RADDR0 0x39000C
+#define P1_RADDR1 0x39000D
+#define P1_RRDWR  0x39000E
+
+static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state)
+{
+	unsigned long timeout = jiffies + msecs_to_jiffies(1);
+	u32 gpio0,need;
+
+	need = state ? 2 : 0;
+	for (;;) {
+		gpio0 = cx_read(MO_GP0_IO) & 2;
+		if (need == gpio0)
+			return 0;
+		if (time_after(jiffies,timeout))
+			return -1;
+		udelay(1);
+	}
+}
+
+static int memory_write(struct cx88_core *core, u32 address, u32 value)
+{
+	/* Warning: address is dword address (4 bytes) */
+	cx_writeb(P1_MDATA0, (unsigned int)value);
+	cx_writeb(P1_MDATA1, (unsigned int)(value >> 8));
+	cx_writeb(P1_MDATA2, (unsigned int)(value >> 16));
+	cx_writeb(P1_MDATA3, (unsigned int)(value >> 24));
+	cx_writeb(P1_MADDR2, (unsigned int)(address >> 16) | 0x40);
+	cx_writeb(P1_MADDR1, (unsigned int)(address >> 8));
+	cx_writeb(P1_MADDR0, (unsigned int)address);
+	cx_read(P1_MDATA0);
+	cx_read(P1_MADDR0);
+
+	return wait_ready_gpio0_bit1(core,1);
+}
+
+static int memory_read(struct cx88_core *core, u32 address, u32 *value)
+{
+        int retval;
+	u32 val;
+
+	/* Warning: address is dword address (4 bytes) */
+	cx_writeb(P1_MADDR2, (unsigned int)(address >> 16) & ~0xC0);
+	cx_writeb(P1_MADDR1, (unsigned int)(address >> 8));
+	cx_writeb(P1_MADDR0, (unsigned int)address);
+	cx_read(P1_MADDR0);
+
+	retval = wait_ready_gpio0_bit1(core,1);
+
+	cx_writeb(P1_MDATA3, 0);
+	val     = (unsigned char)cx_read(P1_MDATA3) << 24;
+	cx_writeb(P1_MDATA2, 0);
+	val    |= (unsigned char)cx_read(P1_MDATA2) << 16;
+	cx_writeb(P1_MDATA1, 0);
+	val    |= (unsigned char)cx_read(P1_MDATA1) << 8;
+	cx_writeb(P1_MDATA0, 0);
+	val    |= (unsigned char)cx_read(P1_MDATA0);
+
+	*value  = val;
+	return retval;
+}
+
+static int register_write(struct cx88_core *core, u32 address, u32 value)
+{
+	cx_writeb(P1_RDATA0, (unsigned int)value);
+	cx_writeb(P1_RDATA1, (unsigned int)(value >> 8));
+	cx_writeb(P1_RDATA2, (unsigned int)(value >> 16));
+	cx_writeb(P1_RDATA3, (unsigned int)(value >> 24));
+	cx_writeb(P1_RADDR0, (unsigned int)address);
+	cx_writeb(P1_RADDR1, (unsigned int)(address >> 8));
+	cx_writeb(P1_RRDWR, 1);
+	cx_read(P1_RDATA0);
+	cx_read(P1_RADDR0);
+
+	return wait_ready_gpio0_bit1(core,1);
+#if 0
+	udelay(1000); /* without this, things don't go right (subsequent memory_write()'s don't get through */
+	/* ? would this be safe here? set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); */
+#endif
+}
+
+
+static int register_read(struct cx88_core *core, u32 address, u32 *value)
+{
+	int retval;
+	u32 val;
+
+	cx_writeb(P1_RADDR0, (unsigned int)address);
+	cx_writeb(P1_RADDR1, (unsigned int)(address >> 8));
+	cx_writeb(P1_RRDWR, 0);
+	cx_read(P1_RADDR0);
+
+	retval  = wait_ready_gpio0_bit1(core,1);
+	val     = (unsigned char)cx_read(P1_RDATA0);
+	val    |= (unsigned char)cx_read(P1_RDATA1) << 8;
+	val    |= (unsigned char)cx_read(P1_RDATA2) << 16;
+	val    |= (unsigned char)cx_read(P1_RDATA3) << 24;
+
+	*value  = val;
+	return retval;
+}
+
+/* ------------------------------------------------------------------ */
+
+/* We don't need to call the API often, so using just one mailbox will probably suffice */
+static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
+			     u32 inputcnt, u32 outputcnt, ...)
+{
+	unsigned long timeout;
+	u32 value, flag, retval;
+	int i;
+	va_list args;
+	va_start(args, outputcnt);
+
+	dprintk(1,"%s: 0x%X\n", __FUNCTION__, command);
+
+	/* this may not be 100% safe if we can't read any memory location
+	   without side effects */
+	memory_read(dev->core, dev->mailbox - 4, &value);
+	if (value != 0x12345678) {
+		dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n");
+		return -1;
+	}
+
+	memory_read(dev->core, dev->mailbox, &flag);
+	if (flag) {
+		dprintk(0, "ERROR: Mailbox appears to be in use (%x)\n", flag);
+		return -1;
+	}
+
+	flag |= 1; /* tell 'em we're working on it */
+	memory_write(dev->core, dev->mailbox, flag);
+
+	/* write command + args + fill remaining with zeros */
+	memory_write(dev->core, dev->mailbox + 1, command); /* command code */
+	memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */
+	for (i = 0; i < inputcnt ; i++) {
+		value = va_arg(args, int);
+		memory_write(dev->core, dev->mailbox + 4 + i, value);
+		dprintk(1, "API Input %d = %d\n", i, value);
+	}
+	for (; i < 16 ; i++)
+		memory_write(dev->core, dev->mailbox + 4 + i, 0);
+
+	flag |= 3; /* tell 'em we're done writing */
+	memory_write(dev->core, dev->mailbox, flag);
+
+	/* wait for firmware to handle the API command */
+	timeout = jiffies + msecs_to_jiffies(10);
+	for (;;) {
+		memory_read(dev->core, dev->mailbox, &flag);
+		if (0 == (flag & 4))
+			break;
+		if (time_after(jiffies,timeout)) {
+			dprintk(0, "ERROR: API Mailbox timeout\n");
+			return -1;
+		}
+		udelay(10);
+	}
+
+	/* read output values */
+	for (i = 0; i < outputcnt ; i++) {
+		int *vptr = va_arg(args, int *);
+		memory_read(dev->core, dev->mailbox + 4 + i, vptr);
+		dprintk(1, "API Output %d = %d\n", i, *vptr);
+	}
+	va_end(args);
+
+	memory_read(dev->core, dev->mailbox + 2, &retval);
+	dprintk(1, "API result = %d\n",retval);
+
+	flag = 0;
+	memory_write(dev->core, dev->mailbox, flag);
+	return retval;
+}
+
+
+static int blackbird_find_mailbox(struct cx8802_dev *dev)
+{
+	u32 signature[4]={0x12345678, 0x34567812, 0x56781234, 0x78123456};
+	int signaturecnt=0;
+	u32 value;
+	int i;
+
+	for (i = 0; i < BLACKBIRD_FIRM_IMAGE_SIZE; i++) {
+		memory_read(dev->core, i, &value);
+		if (value == signature[signaturecnt])
+			signaturecnt++;
+		else
+			signaturecnt = 0;
+		if (4 == signaturecnt) {
+			dprintk(1, "Mailbox signature found\n");
+			return i;
+		}
+	}
+	dprintk(0, "Mailbox signature values not found!\n");
+	return -1;
+}
+
+static int blackbird_load_firmware(struct cx8802_dev *dev)
+{
+	static const unsigned char magic[8] = {
+		0xa7, 0x0d, 0x00, 0x00, 0x66, 0xbb, 0x55, 0xaa
+	};
+	const struct firmware *firmware;
+	int i, retval = 0;
+	u32 value = 0;
+	u32 checksum = 0;
+	u32 *dataptr;
+
+	retval  = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED);
+        retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST);
+        retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640);
+        retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A);
+	msleep(1);
+        retval |= register_write(dev->core, IVTV_REG_APU, 0);
+
+	if (retval < 0)
+		dprintk(0, "Error with register_write\n");
+
+	retval = request_firmware(&firmware, BLACKBIRD_FIRM_ENC_FILENAME,
+				  &dev->pci->dev);
+	if (retval != 0) {
+		dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n",
+			BLACKBIRD_FIRM_ENC_FILENAME);
+		dprintk(0, "Please fix your hotplug setup, the board will "
+			"not work without firmware loaded!\n");
+		return -1;
+	}
+
+	if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) {
+		dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n",
+			firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE);
+		return -1;
+	}
+
+	if (0 != memcmp(firmware->data, magic, 8)) {
+		dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n");
+		return -1;
+	}
+
+	/* transfer to the chip */
+	dprintk(1,"Loading firmware ...\n");
+	dataptr = (u32*)firmware->data;
+	for (i = 0; i < (firmware->size >> 2); i++) {
+		value = *dataptr;
+		checksum += ~value;
+		memory_write(dev->core, i, value);
+		dataptr++;
+	}
+
+	/* read back to verify with the checksum */
+	for (i--; i >= 0; i--) {
+		memory_read(dev->core, i, &value);
+		checksum -= ~value;
+	}
+	if (checksum) {
+		dprintk(0, "ERROR: Firmware load failed (checksum mismatch).\n");
+		return -1;
+	}
+	release_firmware(firmware);
+	dprintk(0, "Firmware upload successful.\n");
+
+        retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST);
+        retval |= register_read(dev->core, IVTV_REG_SPU, &value);
+        retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE);
+	msleep(1);
+
+	retval |= register_read(dev->core, IVTV_REG_VPU, &value);
+        retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8);
+
+	if (retval < 0)
+		dprintk(0, "Error with register_write\n");
+	return 0;
+}
+
+static void blackbird_codec_settings(struct cx8802_dev *dev)
+{
+	int bitrate_mode = 1;
+	int bitrate = 7500000;
+	int bitrate_peak = 7500000;
+
+	/* assign stream type */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_STREAM_TYPE, 1, 0, 0); /* program stream */
+        //blackbird_api_cmd(dev, IVTV_API_ASSIGN_STREAM_TYPE, 1, 0, 2); /* MPEG1 stream */
+        //blackbird_api_cmd(dev, IVTV_API_ASSIGN_STREAM_TYPE, 1, 0, 3); /* PES A/V */
+        //blackbird_api_cmd(dev, IVTV_API_ASSIGN_STREAM_TYPE, 1, 0, 10); /* DVD stream */
+
+        /* assign output port */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_OUTPUT_PORT, 1, 0, 1); /* 1 = Host */
+
+        /* assign framerate */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAMERATE, 1, 0, 0);
+
+        /* assign frame size */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_SIZE, 2, 0, 480, 720);
+
+        /* assign aspect ratio */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_ASPECT_RATIO, 1, 0, 2);
+
+        /* assign bitrates */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_BITRATES, 5, 0,
+			 bitrate_mode,         /* mode */
+			 bitrate,              /* bps */
+			 bitrate_peak / 400,   /* peak/400 */
+			 0, 0x70);             /* encoding buffer, ckennedy */
+
+        /* assign gop properties */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_GOP_PROPERTIES, 2, 0, 15, 3);
+        //blackbird_api_cmd(dev, IVTV_API_ASSIGN_GOP_PROPERTIES, 2, 0, 2, 1);
+
+        /* assign 3 2 pulldown */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_3_2_PULLDOWN, 1, 0, 0);
+
+        /* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */
+	blackbird_api_cmd(dev, IVTV_API_ASSIGN_AUDIO_PROPERTIES, 1, 0, (2<<2) | (8<<4));
+
+	/* assign gop closure */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_GOP_CLOSURE, 1, 0, 0);
+
+        /* assign audio properties */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_AUDIO_PROPERTIES, 1, 0, 0 | (2 << 2) | (14 << 4));
+
+        /* assign dnr filter mode */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_DNR_FILTER_MODE, 2, 0, 0, 0);
+
+        /* assign dnr filter props*/
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_DNR_FILTER_PROPS, 2, 0, 0, 0);
+
+        /* assign coring levels (luma_h, luma_l, chroma_h, chroma_l) */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_CORING_LEVELS, 4, 0, 0, 255, 0, 255);
+
+	/* assign spatial filter type: luma_t: 1 = horiz_only, chroma_t: 1 = horiz_only */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_SPATIAL_FILTER_TYPE, 2, 0, 1, 1);
+
+        /* assign frame drop rate */
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_DROP_RATE, 1, 0, 0);
+}
+
+static int blackbird_initialize_codec(struct cx8802_dev *dev)
+{
+	struct cx88_core *core = dev->core;
+	int version;
+	int retval;
+
+	dprintk(1,"Initialize codec\n");
+	retval = blackbird_api_cmd(dev, IVTV_API_ENC_PING_FW, 0, 0); /* ping */
+	if (retval < 0) {
+		/* ping was not successful, reset and upload firmware */
+		cx_write(MO_SRST_IO, 0); /* SYS_RSTO=0 */
+		msleep(1);
+		cx_write(MO_SRST_IO, 1); /* SYS_RSTO=1 */
+		msleep(1);
+		retval = blackbird_load_firmware(dev);
+		if (retval < 0)
+			return retval;
+
+		dev->mailbox = blackbird_find_mailbox(dev);
+		if (dev->mailbox < 0)
+			return -1;
+
+		retval = blackbird_api_cmd(dev, IVTV_API_ENC_PING_FW, 0, 0); /* ping */
+		if (retval < 0) {
+			dprintk(0, "ERROR: Firmware ping failed!\n");
+			return -1;
+		}
+
+		retval = blackbird_api_cmd(dev, IVTV_API_ENC_GETVER, 0, 1, &version);
+		if (retval < 0) {
+			dprintk(0, "ERROR: Firmware get encoder version failed!\n");
+			return -1;
+		}
+		dprintk(0, "Firmware version is 0x%08x\n", version);
+	}
+	msleep(1);
+
+	cx_write(MO_PINMUX_IO, 0x88); /* 656-8bit IO and enable MPEG parallel IO */
+	cx_clear(MO_INPUT_FORMAT, 0x100); /* chroma subcarrier lock to normal? */
+	cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */
+	cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */
+
+#if 0 /* FIXME */
+	set_scale(dev, 720, 480, V4L2_FIELD_INTERLACED);
+#endif
+	blackbird_codec_settings(dev);
+	msleep(1);
+
+	//blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xef, 0xef);
+	blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xf0, 0xf0);
+	//blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0x180, 0x180);
+        blackbird_api_cmd(dev, IVTV_API_ASSIGN_PLACEHOLDER, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+	blackbird_api_cmd(dev, IVTV_API_INITIALIZE_INPUT, 0, 0); /* initialize the video input */
+
+	msleep(1);
+
+        blackbird_api_cmd(dev, IVTV_API_MUTE_VIDEO, 1, 0, 0);
+	msleep(1);
+        blackbird_api_cmd(dev, IVTV_API_MUTE_AUDIO, 1, 0, 0);
+	msleep(1);
+
+	blackbird_api_cmd(dev, IVTV_API_BEGIN_CAPTURE, 2, 0, 0, 0x13); /* start capturing to the host interface */
+	//blackbird_api_cmd(dev, IVTV_API_BEGIN_CAPTURE, 2, 0, 0, 0); /* start capturing to the host interface */
+	msleep(1);
+
+	blackbird_api_cmd(dev, IVTV_API_REFRESH_INPUT, 0,0);
+	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+
+static int bb_buf_setup(struct videobuf_queue *q,
+			unsigned int *count, unsigned int *size)
+{
+	struct cx8802_fh *fh = q->priv_data;
+
+	fh->dev->ts_packet_size  = 512;
+	fh->dev->ts_packet_count = 100;
+
+	*size = fh->dev->ts_packet_size * fh->dev->ts_packet_count;
+	if (0 == *count)
+		*count = mpegbufs;
+	if (*count < 2)
+		*count = 2;
+	if (*count > 32)
+		*count = 32;
+	return 0;
+}
+
+static int
+bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
+	       enum v4l2_field field)
+{
+	struct cx8802_fh *fh = q->priv_data;
+	return cx8802_buf_prepare(fh->dev, (struct cx88_buffer*)vb);
+}
+
+static void
+bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
+{
+	struct cx8802_fh *fh = q->priv_data;
+	cx8802_buf_queue(fh->dev, (struct cx88_buffer*)vb);
+}
+
+static void
+bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
+{
+	struct cx8802_fh *fh = q->priv_data;
+	cx88_free_buffer(fh->dev->pci, (struct cx88_buffer*)vb);
+}
+
+static struct videobuf_queue_ops blackbird_qops = {
+	.buf_setup    = bb_buf_setup,
+	.buf_prepare  = bb_buf_prepare,
+	.buf_queue    = bb_buf_queue,
+	.buf_release  = bb_buf_release,
+};
+
+/* ------------------------------------------------------------------ */
+
+static int mpeg_do_ioctl(struct inode *inode, struct file *file,
+			 unsigned int cmd, void *arg)
+{
+	struct cx8802_fh  *fh  = file->private_data;
+	struct cx8802_dev *dev = fh->dev;
+
+	if (debug > 1)
+		cx88_print_ioctl(dev->core->name,cmd);
+
+	switch (cmd) {
+
+	/* --- capture ioctls ---------------------------------------- */
+	case VIDIOC_ENUM_FMT:
+	{
+		struct v4l2_fmtdesc *f = arg;
+		int index;
+
+		index = f->index;
+		if (index != 0)
+			return -EINVAL;
+
+		memset(f,0,sizeof(*f));
+		f->index = index;
+		strlcpy(f->description, "MPEG TS", sizeof(f->description));
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		f->pixelformat = V4L2_PIX_FMT_MPEG;
+		return 0;
+	}
+	case VIDIOC_G_FMT:
+	case VIDIOC_S_FMT:
+	case VIDIOC_TRY_FMT:
+	{
+		/* FIXME -- quick'n'dirty for exactly one size ... */
+		struct v4l2_format *f = arg;
+
+		memset(f,0,sizeof(*f));
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		f->fmt.pix.width        = 720;
+		f->fmt.pix.height       = 576;
+		f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+		f->fmt.pix.sizeimage    = 1024 * 512 /* FIXME: BUFFER_SIZE */;
+	}
+
+	/* --- streaming capture ------------------------------------- */
+	case VIDIOC_REQBUFS:
+		return videobuf_reqbufs(&fh->mpegq, arg);
+
+	case VIDIOC_QUERYBUF:
+		return videobuf_querybuf(&fh->mpegq, arg);
+
+	case VIDIOC_QBUF:
+		return videobuf_qbuf(&fh->mpegq, arg);
+
+	case VIDIOC_DQBUF:
+		return videobuf_dqbuf(&fh->mpegq, arg,
+				      file->f_flags & O_NONBLOCK);
+
+	case VIDIOC_STREAMON:
+		return videobuf_streamon(&fh->mpegq);
+
+	case VIDIOC_STREAMOFF:
+		return videobuf_streamoff(&fh->mpegq);
+
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int mpeg_ioctl(struct inode *inode, struct file *file,
+		       unsigned int cmd, unsigned long arg)
+{
+	return video_usercopy(inode, file, cmd, arg, mpeg_do_ioctl);
+}
+
+static int mpeg_open(struct inode *inode, struct file *file)
+{
+	int minor = iminor(inode);
+	struct cx8802_dev *h,*dev = NULL;
+	struct cx8802_fh *fh;
+	struct list_head *list;
+
+	list_for_each(list,&cx8802_devlist) {
+		h = list_entry(list, struct cx8802_dev, devlist);
+		if (h->mpeg_dev->minor == minor)
+			dev = h;
+	}
+	if (NULL == dev)
+		return -ENODEV;
+
+	if (blackbird_initialize_codec(dev) < 0)
+		return -EINVAL;
+	dprintk(1,"open minor=%d\n",minor);
+
+	/* allocate + initialize per filehandle data */
+	fh = kmalloc(sizeof(*fh),GFP_KERNEL);
+	if (NULL == fh)
+		return -ENOMEM;
+	memset(fh,0,sizeof(*fh));
+	file->private_data = fh;
+	fh->dev      = dev;
+
+	videobuf_queue_init(&fh->mpegq, &blackbird_qops,
+			    dev->pci, &dev->slock,
+			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
+			    V4L2_FIELD_TOP,
+			    sizeof(struct cx88_buffer),
+			    fh);
+	return 0;
+}
+
+static int mpeg_release(struct inode *inode, struct file *file)
+{
+	struct cx8802_fh  *fh  = file->private_data;
+
+	blackbird_api_cmd(fh->dev, IVTV_API_END_CAPTURE, 3, 0, 1, 0, 0x13);
+
+	/* stop mpeg capture */
+	if (fh->mpegq.streaming)
+		videobuf_streamoff(&fh->mpegq);
+	if (fh->mpegq.reading)
+		videobuf_read_stop(&fh->mpegq);
+
+	file->private_data = NULL;
+	kfree(fh);
+	return 0;
+}
+
+static ssize_t
+mpeg_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
+{
+	struct cx8802_fh *fh = file->private_data;
+
+	return videobuf_read_stream(&fh->mpegq, data, count, ppos, 0,
+				    file->f_flags & O_NONBLOCK);
+}
+
+static unsigned int
+mpeg_poll(struct file *file, struct poll_table_struct *wait)
+{
+	struct cx8802_fh *fh = file->private_data;
+
+	return videobuf_poll_stream(file, &fh->mpegq, wait);
+}
+
+static int
+mpeg_mmap(struct file *file, struct vm_area_struct * vma)
+{
+	struct cx8802_fh *fh = file->private_data;
+
+	return videobuf_mmap_mapper(&fh->mpegq, vma);
+}
+
+static struct file_operations mpeg_fops =
+{
+	.owner	       = THIS_MODULE,
+	.open	       = mpeg_open,
+	.release       = mpeg_release,
+	.read	       = mpeg_read,
+	.poll          = mpeg_poll,
+	.mmap	       = mpeg_mmap,
+	.ioctl	       = mpeg_ioctl,
+	.llseek        = no_llseek,
+};
+
+static struct video_device cx8802_mpeg_template =
+{
+	.name          = "cx8802",
+	.type          = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES|VID_TYPE_MPEG_ENCODER,
+	.hardware      = 0,
+	.fops          = &mpeg_fops,
+	.minor         = -1,
+};
+
+/* ------------------------------------------------------------------ */
+
+static void blackbird_unregister_video(struct cx8802_dev *dev)
+{
+	if (dev->mpeg_dev) {
+		if (-1 != dev->mpeg_dev->minor)
+			video_unregister_device(dev->mpeg_dev);
+		else
+			video_device_release(dev->mpeg_dev);
+		dev->mpeg_dev = NULL;
+	}
+}
+
+static int blackbird_register_video(struct cx8802_dev *dev)
+{
+	int err;
+
+	dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci,
+				       &cx8802_mpeg_template,"mpeg");
+	err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1);
+	if (err < 0) {
+		printk(KERN_INFO "%s/2: can't register mpeg device\n",
+		       dev->core->name);
+		return err;
+	}
+	printk(KERN_INFO "%s/2: registered device video%d [mpeg]\n",
+	       dev->core->name,dev->mpeg_dev->minor & 0x1f);
+	return 0;
+}
+
+/* ----------------------------------------------------------- */
+
+static int __devinit blackbird_probe(struct pci_dev *pci_dev,
+				     const struct pci_device_id *pci_id)
+{
+	struct cx8802_dev *dev;
+	struct cx88_core  *core;
+	int err;
+
+	/* general setup */
+	core = cx88_core_get(pci_dev);
+	if (NULL == core)
+		return -EINVAL;
+
+	err = -ENODEV;
+	if (!cx88_boards[core->board].blackbird)
+		goto fail_core;
+
+	err = -ENOMEM;
+	dev = kmalloc(sizeof(*dev),GFP_KERNEL);
+	if (NULL == dev)
+		goto fail_core;
+	memset(dev,0,sizeof(*dev));
+	dev->pci = pci_dev;
+	dev->core = core;
+
+	err = cx8802_init_common(dev);
+	if (0 != err)
+		goto fail_free;
+
+	/* blackbird stuff */
+	printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n",
+	       core->name);
+	host_setup(dev->core);
+
+	list_add_tail(&dev->devlist,&cx8802_devlist);
+	blackbird_register_video(dev);
+	return 0;
+
+ fail_free:
+	kfree(dev);
+ fail_core:
+	cx88_core_put(core,pci_dev);
+	return err;
+}
+
+static void __devexit blackbird_remove(struct pci_dev *pci_dev)
+{
+        struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
+
+	/* blackbird */
+	blackbird_unregister_video(dev);
+	list_del(&dev->devlist);
+
+	/* common */
+	cx8802_fini_common(dev);
+}
+
+static struct pci_device_id cx8802_pci_tbl[] = {
+	{
+		.vendor       = 0x14f1,
+		.device       = 0x8802,
+                .subvendor    = PCI_ANY_ID,
+                .subdevice    = PCI_ANY_ID,
+	},{
+		/* --- end of list --- */
+	}
+};
+MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl);
+
+static struct pci_driver blackbird_pci_driver = {
+        .name     = "cx88-blackbird",
+        .id_table = cx8802_pci_tbl,
+        .probe    = blackbird_probe,
+        .remove   = __devexit_p(blackbird_remove),
+	.suspend  = cx8802_suspend_common,
+	.resume   = cx8802_resume_common,
+};
+
+static int blackbird_init(void)
+{
+	printk(KERN_INFO "cx2388x blackbird driver version %d.%d.%d loaded\n",
+	       (CX88_VERSION_CODE >> 16) & 0xff,
+	       (CX88_VERSION_CODE >>  8) & 0xff,
+	       CX88_VERSION_CODE & 0xff);
+#ifdef SNAPSHOT
+	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
+	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
+#endif
+	return pci_module_init(&blackbird_pci_driver);
+}
+
+static void blackbird_fini(void)
+{
+	pci_unregister_driver(&blackbird_pci_driver);
+}
+
+module_init(blackbird_init);
+module_exit(blackbird_fini);
+
+/* ----------------------------------------------------------- */
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -Nru a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
--- a/drivers/media/video/cx88/cx88-cards.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/video/cx88/cx88-cards.c	2004-12-24 13:37:18 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: cx88-cards.c,v 1.47 2004/11/03 09:04:50 kraxel Exp $
+ *
  * device driver for Conexant 2388x based TV cards
  * card-specific stuff.
  *
@@ -22,8 +24,16 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/delay.h>
+
+#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
+# define WITH_DVB 1
+#endif
 
 #include "cx88.h"
+#ifdef WITH_DVB
+#include "cx22702.h"
+#endif
 
 /* ------------------------------------------------------------------ */
 /* board config info                                                  */
@@ -85,6 +95,7 @@
 		.input          = {{
 			.type   = CX88_VMUX_TELEVISION,
 			.vmux   = 0,
+			.gpio0  = 0xff00,  // internal decoder
 		},{
 			.type   = CX88_VMUX_COMPOSITE1,
 			.vmux   = 1,
@@ -92,30 +103,33 @@
 			.type   = CX88_VMUX_SVIDEO,
 			.vmux   = 2,
 		}},
+		.radio = {
+			 .type  = CX88_RADIO,
+			 .gpio0 = 0xff10,
+		 },
 	},
 	[CX88_BOARD_ATI_WONDER_PRO] = {
 		.name           = "ATI TV Wonder Pro",
 		.tuner_type     = 44,
+		.tda9887_conf   = TDA9887_PRESENT | TDA9887_INTERCARRIER,
 		.input          = {{
 			.type   = CX88_VMUX_TELEVISION,
 			.vmux   = 0,
-                        .gpio0  = 0x000003ff,
-                        .gpio1  = 0x000000ff,
-                        .gpio2  = 0x000000ff,
-                        .gpio3  = 0x00000000,
+                        .gpio0  = 0x03ff,
 		},{
 			.type   = CX88_VMUX_COMPOSITE1,
 			.vmux   = 1,
+                        .gpio0  = 0x03fe,
 		},{
 			.type   = CX88_VMUX_SVIDEO,
 			.vmux   = 2,
-
+                        .gpio0  = 0x03fe,
 		}},
 	},
         [CX88_BOARD_WINFAST2000XP] = {
                 .name           = "Leadtek Winfast 2000XP Expert",
                 .tuner_type     = 44,
-		.needs_tda9887  = 1,
+		.tda9887_conf   = TDA9887_PRESENT,
                 .input          = {{
                         .type   = CX88_VMUX_TELEVISION,
                         .vmux   = 0,
@@ -148,48 +162,58 @@
         },
 	[CX88_BOARD_AVERTV_303] = {
 		.name           = "AverTV Studio 303 (M126)",
-		.tuner_type     = TUNER_PHILIPS_PAL_DK,
+		.tuner_type     = 38,
+		.tda9887_conf   = TDA9887_PRESENT,
 		.input          = {{
 			.type   = CX88_VMUX_TELEVISION,
 			.vmux   = 0,
+			.gpio1  = 0x309f,
+		},{
+			.type   = CX88_VMUX_COMPOSITE1,
+			.vmux   = 1,
+			.gpio1  = 0x305f,
+		},{
+			.type   = CX88_VMUX_SVIDEO,
+			.vmux   = 2,
+			.gpio1  = 0x305f,
 		}},
+		.radio = {
+			.type   = CX88_RADIO,
+		},
 	},
 	[CX88_BOARD_MSI_TVANYWHERE_MASTER] = {
-		//added gpio values thanks to Torsten Seeboth
-		//values for PAL from DScaler
+		// added gpio values thanks to Michal
+		// values for PAL from DScaler
 		.name           = "MSI TV-@nywhere Master",
 		.tuner_type     = 33,
-		.needs_tda9887	= 1,
+		.tda9887_conf	= TDA9887_PRESENT,
 		.input          = {{
 			.type   = CX88_VMUX_TELEVISION,
 			.vmux   = 0,
 			.gpio0  = 0x000040bf,
 			.gpio1  = 0x000080c0,
 			.gpio2  = 0x0000ff40,
-                   	.gpio3  = 0x00000000,
 		},{
                         .type   = CX88_VMUX_COMPOSITE1,
                         .vmux   = 1,
 			.gpio0  = 0x000040bf,
 			.gpio1  = 0x000080c0,
 			.gpio2  = 0x0000ff40,
-			.gpio3  = 0x00000000,
 		},{
                         .type   = CX88_VMUX_SVIDEO,
                         .vmux   = 2,
 			.gpio0  = 0x000040bf,
 			.gpio1  = 0x000080c0,
 			.gpio2  = 0x0000ff40,
-			.gpio3  = 0x00000000,
                 }},
                 .radio = {
-                        .type   = CX88_RADIO,
+			 .type   = CX88_RADIO,
                 },
 	},
 	[CX88_BOARD_WINFAST_DV2000] = {
                 .name           = "Leadtek Winfast DV2000",
                 .tuner_type     = 38,
-		.needs_tda9887  = 1,
+		.tda9887_conf   = TDA9887_PRESENT,
                 .input          = {{
                         .type   = CX88_VMUX_TELEVISION,
                         .vmux   = 0,
@@ -214,11 +238,11 @@
                 .radio = {
                         .type   = CX88_RADIO,
                 },
+		.blackbird = 1,
         },
 	[CX88_BOARD_IODATA_GVVCP3PCI] = {
  		.name		= "IODATA GV-VCP3/PCI",
 		.tuner_type     = TUNER_ABSENT,
-		.needs_tda9887  = 0,
  		.input          = {{
  			.type   = CX88_VMUX_COMPOSITE1,
  			.vmux   = 0,
@@ -233,7 +257,7 @@
 	[CX88_BOARD_PROLINK_PLAYTVPVR] = {
                 .name           = "Prolink PlayTV PVR",
                 .tuner_type     = 43,
-		.needs_tda9887	= 1,
+		.tda9887_conf	= TDA9887_PRESENT,
 		.input          = {{
 			.type   = CX88_VMUX_TELEVISION,
 			.vmux   = 0,
@@ -255,57 +279,179 @@
 	[CX88_BOARD_ASUS_PVR_416] = {
 		.name		= "ASUS PVR-416",
 		.tuner_type     = 43,
-                .needs_tda9887  = 1,
+                .tda9887_conf   = TDA9887_PRESENT,
 		.input          = {{
 			.type   = CX88_VMUX_TELEVISION,
 			.vmux   = 0,
 			.gpio0  = 0x0000fde6,
-			.gpio1  = 0x00000000, // possibly for mpeg data
-			.gpio2  = 0x000000e9,
-                   	.gpio3  = 0x00000000,
  		},{
 			.type   = CX88_VMUX_SVIDEO,
 			.vmux   = 2,
 			.gpio0  = 0x0000fde6, // 0x0000fda6 L,R RCA audio in?
-			.gpio1  = 0x00000000, // possibly for mpeg data
-			.gpio2  = 0x000000e9,
-                   	.gpio3  = 0x00000000,
 		}},
                 .radio = {
                         .type   = CX88_RADIO,
 			.gpio0  = 0x0000fde2,
-			.gpio1  = 0x00000000,
-			.gpio2  = 0x000000e9,
-                   	.gpio3  = 0x00000000,
                 },
+		.blackbird = 1,
 	},
 	[CX88_BOARD_MSI_TVANYWHERE] = {
 		.name           = "MSI TV-@nywhere",
 		.tuner_type     = 33,
-		.needs_tda9887  = 1,
+		.tda9887_conf   = TDA9887_PRESENT,
 		.input          = {{
 			.type   = CX88_VMUX_TELEVISION,
 			.vmux   = 0,
 			.gpio0  = 0x00000fbf,
-			.gpio1  = 0x000000c0,
 			.gpio2  = 0x0000fc08,
-			.gpio3  = 0x00000000,
 		},{
   			.type   = CX88_VMUX_COMPOSITE1,
   			.vmux   = 1,
 			.gpio0  = 0x00000fbf,
-			.gpio1  = 0x000000c0,
 			.gpio2  = 0x0000fc68,
-			.gpio3  = 0x00000000,
 		},{
   			.type   = CX88_VMUX_SVIDEO,
   			.vmux   = 2,
 			.gpio0  = 0x00000fbf,
-			.gpio1  = 0x000000c0,
 			.gpio2  = 0x0000fc68,
-			.gpio3  = 0x00000000,
   		}},
 	},
+        [CX88_BOARD_KWORLD_DVB_T] = {
+                .name           = "KWorld/VStream XPert DVB-T",
+		.tuner_type     = TUNER_ABSENT,
+                .input          = {{
+                        .type   = CX88_VMUX_DVB,
+                        .vmux   = 0,
+                },{
+                        .type   = CX88_VMUX_COMPOSITE1,
+                        .vmux   = 1,
+                },{
+                        .type   = CX88_VMUX_SVIDEO,
+                        .vmux   = 2,
+                }},
+		.dvb            = 1,
+	},
+	[CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = {
+		.name           = "DVICO FusionHDTV DVB-T1",
+		.tuner_type     = TUNER_ABSENT, /* No analog tuner */
+		.input          = {{
+			.type   = CX88_VMUX_COMPOSITE1,
+			.vmux   = 1,
+			.gpio0  = 0x000027df,
+		 },{
+			.type   = CX88_VMUX_SVIDEO,
+			.vmux   = 2,
+			.gpio0  = 0x000027df,
+		}},
+		.dvb            = 1,
+	},
+	[CX88_BOARD_KWORLD_LTV883] = {
+		.name           = "KWorld LTV883RF",
+                .tuner_type     = 48,
+                .input          = {{
+                        .type   = CX88_VMUX_TELEVISION,
+                        .vmux   = 0,
+                        .gpio0  = 0x07f8,
+		},{
+			.type   = CX88_VMUX_DEBUG,
+			.vmux   = 0,
+			.gpio0  = 0x07f9,  // mono from tuner chip
+                },{
+                        .type   = CX88_VMUX_COMPOSITE1,
+                        .vmux   = 1,
+                        .gpio0  = 0x000007fa,
+                },{
+                        .type   = CX88_VMUX_SVIDEO,
+                        .vmux   = 2,
+                        .gpio0  = 0x000007fa,
+                }},
+                .radio = {
+                        .type   = CX88_RADIO,
+                        .gpio0  = 0x000007f8,
+                },
+	},
+	[CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD] = {
+		.name		= "DViCO - FusionHDTV 3 Gold",
+		.tuner_type     = TUNER_MICROTUNE_4042FI5,
+		/*
+		   GPIO[0] resets DT3302 DTV receiver
+		    0 - reset asserted
+		    1 - normal operation
+		   GPIO[1] mutes analog audio output connector
+		    0 - enable selected source
+		    1 - mute
+		   GPIO[2] selects source for analog audio output connector
+		    0 - analog audio input connector on tab
+		    1 - analog DAC output from CX23881 chip
+		   GPIO[3] selects RF input connector on tuner module
+		    0 - RF connector labeled CABLE
+		    1 - RF connector labeled ANT
+		*/
+		.input          = {{
+			.type   = CX88_VMUX_TELEVISION,
+			.vmux   = 0,
+			.gpio0	= 0x0f0d,
+		},{
+			.type   = CX88_VMUX_CABLE,
+			.vmux   = 0,
+			.gpio0	= 0x0f05,
+		},{
+			.type   = CX88_VMUX_COMPOSITE1,
+			.vmux   = 1,
+			.gpio0	= 0x0f00,
+		},{
+			.type   = CX88_VMUX_SVIDEO,
+			.vmux   = 2,
+			.gpio0	= 0x0f00,
+		}},
+#if 0
+		.ts             = {
+			 .type   = CX88_TS,
+			 .gpio0  = 0x00000f01,   /* Hooked to tuner reset bit */
+		 }
+#endif
+	},
+        [CX88_BOARD_HAUPPAUGE_DVB_T1] = {
+                .name           = "Hauppauge Nova-T DVB-T",
+		.tuner_type     = TUNER_ABSENT,
+                .input          = {{
+                        .type   = CX88_VMUX_DVB,
+                        .vmux   = 0,
+                }},
+		.dvb            = 1,
+	},
+        [CX88_BOARD_CONEXANT_DVB_T1] = {
+		.name           = "Conexant DVB-T reference design",
+		.tuner_type     = TUNER_ABSENT,
+                .input          = {{
+                        .type   = CX88_VMUX_DVB,
+                        .vmux   = 0,
+                }},
+		.dvb            = 1,
+	},
+	[CX88_BOARD_PROVIDEO_PV259] = {
+		.name		= "Provideo PV259",
+		.tuner_type     = TUNER_PHILIPS_FQ1216ME,
+		.input          = {{
+			.type   = CX88_VMUX_TELEVISION,
+			.vmux   = 0,
+		}},
+		.blackbird = 1,
+	},
+	[CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = {
+		.name           = "DVICO FusionHDTV DVB-T Plus",
+		.tuner_type     = TUNER_ABSENT, /* No analog tuner */
+		.input          = {{
+			.type   = CX88_VMUX_COMPOSITE1,
+			.vmux   = 1,
+			.gpio0  = 0x000027df,
+		 },{
+			.type   = CX88_VMUX_SVIDEO,
+			.vmux   = 2,
+			.gpio0  = 0x000027df,
+		}},
+		.dvb            = 1,
+	},
 };
 const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
 
@@ -369,14 +515,42 @@
  		.subvendor = 0x1043,
  		.subdevice = 0x4823,  /* with mpeg encoder */
  		.card      = CX88_BOARD_ASUS_PVR_416,
- 	}
+	},{
+		.subvendor = 0x17de,
+		.subdevice = 0x08a6,
+		.card      = CX88_BOARD_KWORLD_DVB_T,
+	},{
+		.subvendor = 0x18ac,
+		.subdevice = 0xd810,
+		.card      = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD,
+	},{
+		.subvendor = 0x18AC,
+		.subdevice = 0xDB00,
+		.card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1,
+ 	},{
+		.subvendor = 0x0070,
+		.subdevice = 0x9002,
+		.card      = CX88_BOARD_HAUPPAUGE_DVB_T1,
+ 	},{
+		.subvendor = 0x14f1,
+		.subdevice = 0x0187,
+		.card      = CX88_BOARD_CONEXANT_DVB_T1,
+ 	},{
+		.subvendor = 0x1540,
+		.subdevice = 0x2580,
+		.card      = CX88_BOARD_PROVIDEO_PV259,
+	},{
+		.subvendor = 0x18AC,
+		.subdevice = 0xDB10,
+		.card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
+	}
 };
 const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
 
 /* ----------------------------------------------------------------------- */
 /* some leadtek specific stuff                                             */
 
-static void __devinit leadtek_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
+static void __devinit leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
 {
 	/* This is just for the Winfast 2000 XP board ATM; I don't have data on
 	 * any others.
@@ -387,16 +561,17 @@
 	if (eeprom_data[4] != 0x7d ||
 	    eeprom_data[5] != 0x10 ||
 	    eeprom_data[7] != 0x66) {
-		printk(KERN_WARNING "%s Leadtek eeprom invalid.\n", dev->name);
+		printk(KERN_WARNING "%s: Leadtek eeprom invalid.\n",
+		       core->name);
 		return;
 	}
 
-	dev->has_radio  = 1;
-	dev->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38;
+	core->has_radio  = 1;
+	core->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38;
 
 	printk(KERN_INFO "%s: Leadtek Winfast 2000 XP config: "
 	       "tuner=%d, eeprom[0]=0x%02x\n",
-	       dev->name, dev->tuner_type, eeprom_data[0]);
+	       core->name, core->tuner_type, eeprom_data[0]);
 }
 
 
@@ -455,18 +630,18 @@
 	{ TUNER_ABSENT,        "Philips TD1536D_FH_44"},
 	{ TUNER_LG_NTSC_FM,    "LG TPI8NSR01F"},
 	{ TUNER_LG_PAL_FM,     "LG TPI8PSB01D"},
-	{ TUNER_LG_PAL,        "LG TPI8PSB11D"},	
+	{ TUNER_LG_PAL,        "LG TPI8PSB11D"},
 	{ TUNER_LG_PAL_I_FM,   "LG TAPC-I001D"},
 	{ TUNER_LG_PAL_I,      "LG TAPC-I701D"}
 };
 
-static void __devinit hauppauge_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
+static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
 {
 	unsigned int blk2,tuner,radio,model;
 
 	if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0) {
 		printk(KERN_WARNING "%s: Hauppauge eeprom: invalid\n",
-		       dev->name);
+		       core->name);
 		return;
 	}
 
@@ -477,17 +652,63 @@
 	model = eeprom_data[12] << 8 | eeprom_data[11];
 	tuner = eeprom_data[9];
 	radio = eeprom_data[blk2-1] & 0x01;
-	
+
         if (tuner < ARRAY_SIZE(hauppauge_tuner))
-                dev->tuner_type = hauppauge_tuner[tuner].id;
+                core->tuner_type = hauppauge_tuner[tuner].id;
 	if (radio)
-		dev->has_radio = 1;
-	
+		core->has_radio = 1;
+
 	printk(KERN_INFO "%s: hauppauge eeprom: model=%d, "
 	       "tuner=%s (%d), radio=%s\n",
-	       dev->name, model, hauppauge_tuner[tuner].name,
-	       dev->tuner_type, radio ? "yes" : "no");
+	       core->name, model, (tuner < ARRAY_SIZE(hauppauge_tuner)
+				   ? hauppauge_tuner[tuner].name : "?"),
+	       core->tuner_type, radio ? "yes" : "no");
+}
+
+#ifdef WITH_DVB
+static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
+{
+	int model;
+	int tuner;
+	char *tname;
+
+	/* Make sure we support the board model */
+	model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c];
+	switch(model) {
+	case 90002:
+	case 90500:
+	case 90501:
+		/* known */
+		break;
+	default:
+		printk("%s: warning: unknown hauppauge model #%d\n",
+		       core->name, model);
+		break;
+	}
+
+	/* Make sure we support the tuner */
+	tuner = ee[0x2d];
+	switch(tuner) {
+	case 0x4B:
+		tname = "Thomson DTT 7595";
+		core->pll_type = PLLTYPE_DTT7595;
+		break;
+	case 0x4C:
+		tname = "Thomson DTT 7592";
+		core->pll_type = PLLTYPE_DTT7592;
+		break;
+	default:
+		printk("%s: error: unknown hauppauge tuner 0x%02x\n",
+		       core->name, tuner);
+		return -ENODEV;
+	}
+	printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%s (%d)\n",
+	       core->name, model, tname, tuner);
+
+	core->pll_addr = 0x61;
+	core->demod_addr = 0x43;
 }
+#endif
 
 /* ----------------------------------------------------------------------- */
 /* some GDI (was: Modular Technology) specific stuff                       */
@@ -527,17 +748,17 @@
 		     .name = "PHILIPS_FI1216_MK3" },
 };
 
-static void __devinit gdi_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
+static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
 {
 	char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
 		? gdi_tuner[eeprom_data[0x0d]].name : NULL;
 
-	printk(KERN_INFO "%s: GDI: tuner=%s\n", dev->name,
+	printk(KERN_INFO "%s: GDI: tuner=%s\n", core->name,
 	       name ? name : "unknown");
 	if (NULL == name)
 		return;
-	dev->tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
-	dev->has_radio  = gdi_tuner[eeprom_data[0x0d]].fm;
+	core->tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
+	core->has_radio  = gdi_tuner[eeprom_data[0x0d]].fm;
 }
 
 /* ----------------------------------------------------------------------- */
@@ -572,56 +793,74 @@
 	return 0;
 }
 
-void cx88_card_list(struct cx8800_dev *dev)
+void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
 {
 	int i;
 
-	if (0 == dev->pci->subsystem_vendor &&
-	    0 == dev->pci->subsystem_device) {
+	if (0 == pci->subsystem_vendor &&
+	    0 == pci->subsystem_device) {
 		printk("%s: Your board has no valid PCI Subsystem ID and thus can't\n"
 		       "%s: be autodetected.  Please pass card=<n> insmod option to\n"
 		       "%s: workaround that.  Redirect complaints to the vendor of\n"
 		       "%s: the TV card.  Best regards,\n"
 		       "%s:         -- tux\n",
-		       dev->name,dev->name,dev->name,dev->name,dev->name);
+		       core->name,core->name,core->name,core->name,core->name);
 	} else {
 		printk("%s: Your board isn't known (yet) to the driver.  You can\n"
 		       "%s: try to pick one of the existing card configs via\n"
 		       "%s: card=<n> insmod option.  Updating to the latest\n"
 		       "%s: version might help as well.\n",
-		       dev->name,dev->name,dev->name,dev->name);
+		       core->name,core->name,core->name,core->name);
 	}
 	printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
-	       dev->name);
+	       core->name);
 	for (i = 0; i < cx88_bcount; i++)
 		printk("%s:    card=%d -> %s\n",
-		       dev->name, i, cx88_boards[i].name);
+		       core->name, i, cx88_boards[i].name);
 }
 
-void cx88_card_setup(struct cx8800_dev *dev)
+void cx88_card_setup(struct cx88_core *core)
 {
 	static u8 eeprom[128];
-		
-	switch (dev->board) {
+
+	switch (core->board) {
 	case CX88_BOARD_HAUPPAUGE:
-		if (0 == dev->i2c_rc)
-			i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
-		hauppauge_eeprom(dev,eeprom+8);
+		if (0 == core->i2c_rc)
+			i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
+		hauppauge_eeprom(core,eeprom+8);
 		break;
 	case CX88_BOARD_GDI:
-		if (0 == dev->i2c_rc)
-			i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
-		gdi_eeprom(dev,eeprom);
+		if (0 == core->i2c_rc)
+			i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
+		gdi_eeprom(core,eeprom);
 		break;
 	case CX88_BOARD_WINFAST2000XP:
-		if (0 == dev->i2c_rc)
-			i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
-		leadtek_eeprom(dev,eeprom);
+		if (0 == core->i2c_rc)
+			i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
+		leadtek_eeprom(core,eeprom);
+		break;
+	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
+		/* Tuner reset is hooked to  the tuner out of reset */
+		cx_set(MO_GP0_IO, 0x00000101);
+		cx_clear(MO_GP0_IO, 0x00000001);
+		msleep(1);
+		cx_set(MO_GP0_IO, 0x00000101);
 		break;
-        case CX88_BOARD_ASUS_PVR_416:
-		dev->has_radio = 1;
-                break;
+#ifdef WITH_DVB
+	case CX88_BOARD_HAUPPAUGE_DVB_T1:
+		if (0 == core->i2c_rc)
+			i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
+		hauppauge_eeprom_dvb(core,eeprom);
+		break;
+	case CX88_BOARD_CONEXANT_DVB_T1:
+		core->pll_type   = PLLTYPE_DTT7579;
+		core->pll_addr   = 0x60;
+		core->demod_addr = 0x43;
+		break;
+#endif
 	}
+	if (cx88_boards[core->board].radio.type == CX88_RADIO)
+		core->has_radio = 1;
 }
 
 /* ------------------------------------------------------------------ */
diff -Nru a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
--- a/drivers/media/video/cx88/cx88-core.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/video/cx88/cx88-core.c	2004-12-24 13:36:31 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: cx88-core.c,v 1.15 2004/10/25 11:26:36 kraxel Exp $
+ *
  * device driver for Conexant 2388x based TV cards
  * driver core
  *
@@ -28,6 +30,7 @@
 #include <linux/sound.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/delay.h>
 #include <linux/videodev.h>
 
 #include "cx88.h"
@@ -38,42 +41,33 @@
 
 /* ------------------------------------------------------------------ */
 
-#if 0
-static unsigned int gpio_tracking = 0;
-MODULE_PARM(gpio_tracking,"i");
-MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]");
-
-static unsigned int ts_nr = -1;
-MODULE_PARM(ts_nr,"i");
-MODULE_PARM_DESC(ts_nr,"ts device number");
-
-static unsigned int vbi_nr = -1;
-MODULE_PARM(vbi_nr,"i");
-MODULE_PARM_DESC(vbi_nr,"vbi device number");
-
-static unsigned int radio_nr = -1;
-MODULE_PARM(radio_nr,"i");
-MODULE_PARM_DESC(radio_nr,"radio device number");
-
-static unsigned int oss = 0;
-MODULE_PARM(oss,"i");
-MODULE_PARM_DESC(oss,"register oss devices (default: no)");
-
-static unsigned int dsp_nr = -1;
-MODULE_PARM(dsp_nr,"i");
-MODULE_PARM_DESC(dsp_nr,"oss dsp device number");
-
-static unsigned int mixer_nr = -1;
-MODULE_PARM(mixer_nr,"i");
-MODULE_PARM_DESC(mixer_nr,"oss mixer device number");
-#endif
-
 static unsigned int core_debug = 0;
-MODULE_PARM(core_debug,"i");
+module_param(core_debug,int,0644);
 MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
 
-#define dprintk(fmt, arg...)	if (core_debug) \
-	printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
+static unsigned int latency = UNSET;
+module_param(latency,int,0444);
+MODULE_PARM_DESC(latency,"pci latency timer");
+
+static unsigned int tuner[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
+static unsigned int card[]  = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
+
+module_param_array(tuner, int, NULL, 0444);
+module_param_array(card,  int, NULL, 0444);
+
+MODULE_PARM_DESC(tuner,"tuner type");
+MODULE_PARM_DESC(card,"card type");
+
+static unsigned int nicam = 0;
+module_param(nicam,int,0644);
+MODULE_PARM_DESC(nicam,"tv audio is nicam");
+
+#define dprintk(level,fmt, arg...)	if (core_debug >= level)	\
+	printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
+
+static unsigned int cx88_devcount;
+static LIST_HEAD(cx88_devlist);
+static DECLARE_MUTEX(devlist);
 
 /* ------------------------------------------------------------------ */
 /* debug help functions                                               */
@@ -129,6 +123,7 @@
 }
 
 /* ------------------------------------------------------------------ */
+#define NO_SYNC_LINE (-1U)
 
 static u32* cx88_risc_field(u32 *rp, struct scatterlist *sglist,
 			    unsigned int offset, u32 sync_line,
@@ -139,8 +134,9 @@
 	unsigned int line,todo;
 
 	/* sync instruction */
-	*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
-	
+	if (sync_line != NO_SYNC_LINE)
+		*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
+
 	/* scan lines */
 	sg = sglist;
 	for (line = 0; line < lines; line++) {
@@ -212,6 +208,32 @@
 
 	/* save pointer to jmp instruction address */
 	risc->jmp = rp;
+	BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
+	return 0;
+}
+
+int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
+			 struct scatterlist *sglist, unsigned int bpl,
+			 unsigned int lines)
+{
+	u32 instructions;
+	u32 *rp;
+	int rc;
+
+	/* estimate risc mem: worst case is one write per page border +
+	   one write per scan line + syncs + jump (all 2 dwords) */
+	instructions  = (bpl * lines) / PAGE_SIZE + lines;
+	instructions += 3 + 4;
+	if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0)
+		return rc;
+
+	/* write risc instructions */
+	rp = risc->cpu;
+	rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines);
+
+	/* save pointer to jmp instruction address */
+	risc->jmp = rp;
+	BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
 	return 0;
 }
 
@@ -259,14 +281,16 @@
  *
  * FIFO space allocations:
  *    channel  21    (y video)  - 10.0k
+ *    channel  22    (u video)  -  2.0k
+ *    channel  23    (v video)  -  2.0k
  *    channel  24    (vbi)      -  4.0k
  *    channels 25+26 (audio)    -  0.5k
- *    everything else           -  2.0k
- *    TOTAL                     = 29.0k
+ *    channel  28    (mpeg)     -  4.0k
+ *    TOTAL                     = 25.5k
  *
  * Every channel has 160 bytes control data (64 bytes instruction
  * queue and 6 CDT entries), which is close to 2k total.
- * 
+ *
  * Address layout:
  *    0x0000 - 0x03ff    CMDs / reserved
  *    0x0400 - 0x0bff    instruction queues + CDs
@@ -346,9 +370,21 @@
 		.cnt1_reg   = MO_DMA26_CNT1,
 		.cnt2_reg   = MO_DMA26_CNT2,
 	},
+	[SRAM_CH28] = {
+		.name       = "mpeg",
+		.cmds_start = 0x180200,
+		.ctrl_start = 0x1807C0,
+		.cdt        = 0x1807C0 + 64,
+		.fifo_start = 0x185600,
+		.fifo_size  = 0x001000,
+		.ptr1_reg   = MO_DMA28_PTR1,
+		.ptr2_reg   = MO_DMA28_PTR2,
+		.cnt1_reg   = MO_DMA28_CNT1,
+		.cnt2_reg   = MO_DMA28_CNT2,
+	},
 };
 
-int cx88_sram_channel_setup(struct cx8800_dev *dev,
+int cx88_sram_channel_setup(struct cx88_core *core,
 			    struct sram_channel *ch,
 			    unsigned int bpl, u32 risc)
 {
@@ -378,10 +414,10 @@
 	/* fill registers */
 	cx_write(ch->ptr1_reg, ch->fifo_start);
 	cx_write(ch->ptr2_reg, cdt);
-	cx_write(ch->cnt1_reg, bpl >> 3);
+	cx_write(ch->cnt1_reg, (bpl >> 3) -1);
 	cx_write(ch->cnt2_reg, (lines*16) >> 3);
 
-	dprintk("sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines);
+	dprintk(2,"sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines);
 	return 0;
 }
 
@@ -426,25 +462,25 @@
 	return incr[risc >> 28] ? incr[risc >> 28] : 1;
 }
 
-void cx88_risc_disasm(struct cx8800_dev *dev,
+void cx88_risc_disasm(struct cx88_core *core,
 		      struct btcx_riscmem *risc)
 {
 	unsigned int i,j,n;
-	
+
 	printk("%s: risc disasm: %p [dma=0x%08lx]\n",
-	       dev->name, risc->cpu, (unsigned long)risc->dma);
+	       core->name, risc->cpu, (unsigned long)risc->dma);
 	for (i = 0; i < (risc->size >> 2); i += n) {
-		printk("%s:   %04d: ", dev->name, i);
+		printk("%s:   %04d: ", core->name, i);
 		n = cx88_risc_decode(risc->cpu[i]);
 		for (j = 1; j < n; j++)
 			printk("%s:   %04d: 0x%08x [ arg #%d ]\n",
-			       dev->name, i+j, risc->cpu[i+j], j);
+			       core->name, i+j, risc->cpu[i+j], j);
 		if (risc->cpu[i] == RISC_JUMP)
 			break;
 	}
 }
 
-void cx88_sram_channel_dump(struct cx8800_dev *dev,
+void cx88_sram_channel_dump(struct cx88_core *core,
 			    struct sram_channel *ch)
 {
 	static char *name[] = {
@@ -463,54 +499,63 @@
 	u32 risc;
 	unsigned int i,j,n;
 
-	printk("%s: %s - dma channel status dump\n",dev->name,ch->name);
+	printk("%s: %s - dma channel status dump\n",
+	       core->name,ch->name);
 	for (i = 0; i < ARRAY_SIZE(name); i++)
 		printk("%s:   cmds: %-12s: 0x%08x\n",
-		       dev->name,name[i],
+		       core->name,name[i],
 		       cx_read(ch->cmds_start + 4*i));
 	for (i = 0; i < 4; i++) {
 		risc = cx_read(ch->cmds_start + 4 * (i+11));
-		printk("%s:   risc%d: ", dev->name, i);
+		printk("%s:   risc%d: ", core->name, i);
 		cx88_risc_decode(risc);
 	}
 	for (i = 0; i < 16; i += n) {
 		risc = cx_read(ch->ctrl_start + 4 * i);
-		printk("%s:   iq %x: ", dev->name, i);
+		printk("%s:   iq %x: ", core->name, i);
 		n = cx88_risc_decode(risc);
 		for (j = 1; j < n; j++) {
 			risc = cx_read(ch->ctrl_start + 4 * (i+j));
 			printk("%s:   iq %x: 0x%08x [ arg #%d ]\n",
-			       dev->name, i+j, risc, j);
+			       core->name, i+j, risc, j);
 		}
 	}
 
 	printk("%s: fifo: 0x%08x -> 0x%x\n",
-	       dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size);
+	       core->name, ch->fifo_start, ch->fifo_start+ch->fifo_size);
 	printk("%s: ctrl: 0x%08x -> 0x%x\n",
-	       dev->name, ch->ctrl_start, ch->ctrl_start+6*16);
+	       core->name, ch->ctrl_start, ch->ctrl_start+6*16);
 	printk("%s:   ptr1_reg: 0x%08x\n",
-	       dev->name,cx_read(ch->ptr1_reg));
+	       core->name,cx_read(ch->ptr1_reg));
 	printk("%s:   ptr2_reg: 0x%08x\n",
-	       dev->name,cx_read(ch->ptr2_reg));
+	       core->name,cx_read(ch->ptr2_reg));
 	printk("%s:   cnt1_reg: 0x%08x\n",
-	       dev->name,cx_read(ch->cnt1_reg));
+	       core->name,cx_read(ch->cnt1_reg));
 	printk("%s:   cnt2_reg: 0x%08x\n",
-	       dev->name,cx_read(ch->cnt2_reg));
+	       core->name,cx_read(ch->cnt2_reg));
 }
 
 char *cx88_pci_irqs[32] = {
-	"vid", "aud", "ts", "vip", "hst", "5", "6", "tm1", 
+	"vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
 	"src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
 	"brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
 	"i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1"
 };
 char *cx88_vid_irqs[32] = {
-	"y_risci1", "u_risci1", "v_risci1", "vbi_risc1", 
+	"y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
 	"y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
 	"y_oflow",  "u_oflow",  "v_oflow",  "vbi_oflow",
 	"y_sync",   "u_sync",   "v_sync",   "vbi_sync",
 	"opc_err",  "par_err",  "rip_err",  "pci_abort",
 };
+char *cx88_mpeg_irqs[32] = {
+	"ts_risci1", NULL, NULL, NULL,
+	"ts_risci2", NULL, NULL, NULL,
+	"ts_oflow",  NULL, NULL, NULL,
+	"ts_sync",   NULL, NULL, NULL,
+	"opc_err", "par_err", "rip_err", "pci_abort",
+	"ts_err?",
+};
 
 void cx88_print_irqbits(char *name, char *tag, char **strings,
 			u32 bits, u32 mask)
@@ -521,7 +566,10 @@
 	for (i = 0; i < 32; i++) {
 		if (!(bits & (1 << i)))
 			continue;
-		printk(" %s",strings[i]);
+		if (strings[i])
+			printk(" %s", strings[i]);
+		else
+			printk(" %d", i);
 		if (!(mask & (1 << i)))
 			continue;
 		printk("*");
@@ -531,14 +579,429 @@
 
 /* ------------------------------------------------------------------ */
 
-int cx88_pci_quirks(char *name, struct pci_dev *pci, unsigned int *latency)
+void cx88_irq(struct cx88_core *core, u32 status, u32 mask)
 {
-	u8 ctrl = 0;
-	u8 value;
+	cx88_print_irqbits(core->name, "irq pci",
+			   cx88_pci_irqs, status, mask);
+}
+
+void cx88_wakeup(struct cx88_core *core,
+		 struct cx88_dmaqueue *q, u32 count)
+{
+	struct cx88_buffer *buf;
+	int bc;
+
+	for (bc = 0;; bc++) {
+		if (list_empty(&q->active))
+			break;
+		buf = list_entry(q->active.next,
+				 struct cx88_buffer, vb.queue);
+#if 0
+		if (buf->count > count)
+			break;
+#else
+		/* count comes from the hw and is is 16bit wide --
+		 * this trick handles wrap-arounds correctly for
+		 * up to 32767 buffers in flight... */
+		if ((s16) (count - buf->count) < 0)
+			break;
+#endif
+		do_gettimeofday(&buf->vb.ts);
+		dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i,
+			count, buf->count);
+		buf->vb.state = STATE_DONE;
+		list_del(&buf->vb.queue);
+		wake_up(&buf->vb.done);
+	}
+	if (list_empty(&q->active)) {
+		del_timer(&q->timeout);
+	} else {
+		mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+	}
+	if (bc != 1)
+		printk("%s: %d buffers handled (should be 1)\n",__FUNCTION__,bc);
+}
+
+void cx88_shutdown(struct cx88_core *core)
+{
+	/* disable RISC controller + IRQs */
+	cx_write(MO_DEV_CNTRL2, 0);
 
-	if (0 == pci_pci_problems)
+	/* stop dma transfers */
+	cx_write(MO_VID_DMACNTRL, 0x0);
+	cx_write(MO_AUD_DMACNTRL, 0x0);
+	cx_write(MO_TS_DMACNTRL, 0x0);
+	cx_write(MO_VIP_DMACNTRL, 0x0);
+	cx_write(MO_GPHST_DMACNTRL, 0x0);
+
+	/* stop interrupts */
+	cx_write(MO_PCI_INTMSK, 0x0);
+	cx_write(MO_VID_INTMSK, 0x0);
+	cx_write(MO_AUD_INTMSK, 0x0);
+	cx_write(MO_TS_INTMSK, 0x0);
+	cx_write(MO_VIP_INTMSK, 0x0);
+	cx_write(MO_GPHST_INTMSK, 0x0);
+
+	/* stop capturing */
+	cx_write(VID_CAPTURE_CONTROL, 0);
+}
+
+int cx88_reset(struct cx88_core *core)
+{
+	dprintk(1,"%s\n",__FUNCTION__);
+	cx88_shutdown(core);
+
+	/* clear irq status */
+	cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int
+	cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int
+	cx_write(MO_INT1_STAT,   0xFFFFFFFF); // Clear RISC int
+
+	/* wait a bit */
+	msleep(100);
+
+	/* init sram */
+	cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], 720*4, 0);
+	cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH22], 128, 0);
+	cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH23], 128, 0);
+	cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH24], 128, 0);
+	cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
+	cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
+	cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 188*4, 0);
+
+	/* misc init ... */
+	cx_write(MO_INPUT_FORMAT, ((1 << 13) |   // agc enable
+				   (1 << 12) |   // agc gain
+				   (1 << 11) |   // adaptibe agc
+				   (0 << 10) |   // chroma agc
+				   (0 <<  9) |   // ckillen
+				   (7)));
+
+	/* setup image format */
+	cx_andor(MO_COLOR_CTRL, 0x4000, 0x4000);
+
+	/* setup FIFO Threshholds */
+	cx_write(MO_PDMA_STHRSH,   0x0807);
+	cx_write(MO_PDMA_DTHRSH,   0x0807);
+
+	/* fixes flashing of image */
+	cx_write(MO_AGC_SYNC_TIP1, 0x0380000F);
+	cx_write(MO_AGC_BACK_VBI,  0x00E00555);
+
+	cx_write(MO_VID_INTSTAT,   0xFFFFFFFF); // Clear PIV int
+	cx_write(MO_PCI_INTSTAT,   0xFFFFFFFF); // Clear PCI int
+	cx_write(MO_INT1_STAT,     0xFFFFFFFF); // Clear RISC int
+
+	/* Reset on-board parts */
+	cx_write(MO_SRST_IO, 0);
+	msleep(10);
+	cx_write(MO_SRST_IO, 1);
+
+	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+
+static unsigned int inline norm_swidth(struct cx88_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 922 : 754;
+}
+
+static unsigned int inline norm_hdelay(struct cx88_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 186 : 135;
+}
+
+static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 0x24 : 0x18;
+}
+
+static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm)
+{
+	static const unsigned int ntsc = 28636360;
+	static const unsigned int pal  = 35468950;
+
+	return (norm->id & V4L2_STD_625_50) ? pal : ntsc;
+}
+
+static unsigned int inline norm_notchfilter(struct cx88_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50)
+		? HLNotchFilter135PAL
+		: HLNotchFilter135NTSC;
+}
+
+static unsigned int inline norm_htotal(struct cx88_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 1135 : 910;
+}
+
+static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 511 : 288;
+}
+
+int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int height,
+		   enum v4l2_field field)
+{
+	unsigned int swidth  = norm_swidth(core->tvnorm);
+	unsigned int sheight = norm_maxh(core->tvnorm);
+	u32 value;
+
+	dprintk(1,"set_scale: %dx%d [%s%s,%s]\n", width, height,
+		V4L2_FIELD_HAS_TOP(field)    ? "T" : "",
+		V4L2_FIELD_HAS_BOTTOM(field) ? "B" : "",
+		core->tvnorm->name);
+	if (!V4L2_FIELD_HAS_BOTH(field))
+		height *= 2;
+
+	// recalc H delay and scale registers
+	value = (width * norm_hdelay(core->tvnorm)) / swidth;
+	value &= 0x3fe;
+	cx_write(MO_HDELAY_EVEN,  value);
+	cx_write(MO_HDELAY_ODD,   value);
+	dprintk(1,"set_scale: hdelay  0x%04x\n", value);
+
+	value = (swidth * 4096 / width) - 4096;
+	cx_write(MO_HSCALE_EVEN,  value);
+	cx_write(MO_HSCALE_ODD,   value);
+	dprintk(1,"set_scale: hscale  0x%04x\n", value);
+
+	cx_write(MO_HACTIVE_EVEN, width);
+	cx_write(MO_HACTIVE_ODD,  width);
+	dprintk(1,"set_scale: hactive 0x%04x\n", width);
+
+	// recalc V scale Register (delay is constant)
+	cx_write(MO_VDELAY_EVEN, norm_vdelay(core->tvnorm));
+	cx_write(MO_VDELAY_ODD,  norm_vdelay(core->tvnorm));
+	dprintk(1,"set_scale: vdelay  0x%04x\n", norm_vdelay(core->tvnorm));
+
+	value = (0x10000 - (sheight * 512 / height - 512)) & 0x1fff;
+	cx_write(MO_VSCALE_EVEN,  value);
+	cx_write(MO_VSCALE_ODD,   value);
+	dprintk(1,"set_scale: vscale  0x%04x\n", value);
+
+	cx_write(MO_VACTIVE_EVEN, sheight);
+	cx_write(MO_VACTIVE_ODD,  sheight);
+	dprintk(1,"set_scale: vactive 0x%04x\n", sheight);
+
+	// setup filters
+	value = 0;
+	value |= (1 << 19);        // CFILT (default)
+	if (core->tvnorm->id & V4L2_STD_SECAM) {
+		value |= (1 << 15);
+		value |= (1 << 16);
+	}
+	if (INPUT(core->input)->type == CX88_VMUX_SVIDEO)
+		value |= (1 << 13) | (1 << 5);
+	if (V4L2_FIELD_INTERLACED == field)
+		value |= (1 << 3); // VINT (interlaced vertical scaling)
+	if (width < 385)
+		value |= (1 << 0); // 3-tap interpolation
+	if (width < 193)
+		value |= (1 << 1); // 5-tap interpolation
+
+	cx_write(MO_FILTER_EVEN,  value);
+	cx_write(MO_FILTER_ODD,   value);
+	dprintk(1,"set_scale: filter  0x%04x\n", value);
+
+	return 0;
+}
+
+static const u32 xtal = 28636363;
+
+static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
+{
+	static u32 pre[] = { 0, 0, 0, 3, 2, 1 };
+	u64 pll;
+	u32 reg;
+	int i;
+
+	if (prescale < 2)
+		prescale = 2;
+	if (prescale > 5)
+		prescale = 5;
+
+	pll = ofreq * 8 * prescale * (u64)(1 << 20);
+	do_div(pll,xtal);
+	reg = (pll & 0x3ffffff) | (pre[prescale] << 26);
+	if (((reg >> 20) & 0x3f) < 14) {
+		printk("%s/0: pll out of range\n",core->name);
+		return -1;
+	}
+
+	dprintk(1,"set_pll:    MO_PLL_REG       0x%08x [old=0x%08x,freq=%d]\n",
+		reg, cx_read(MO_PLL_REG), ofreq);
+	cx_write(MO_PLL_REG, reg);
+	for (i = 0; i < 100; i++) {
+		reg = cx_read(MO_DEVICE_STATUS);
+		if (reg & (1<<2)) {
+			dprintk(1,"pll locked [pre=%d,ofreq=%d]\n",
+				prescale,ofreq);
+			return 0;
+		}
+		dprintk(1,"pll not locked yet, waiting ...\n");
+		msleep(10);
+	}
+	dprintk(1,"pll NOT locked [pre=%d,ofreq=%d]\n",prescale,ofreq);
+	return -1;
+}
+
+static int set_tvaudio(struct cx88_core *core)
+{
+	struct cx88_tvnorm *norm = core->tvnorm;
+
+	if (CX88_VMUX_TELEVISION != INPUT(core->input)->type)
 		return 0;
 
+	if (V4L2_STD_PAL_BG & norm->id) {
+		core->tvaudio = nicam ? WW_NICAM_BGDKL : WW_A2_BG;
+
+	} else if (V4L2_STD_PAL_DK & norm->id) {
+		core->tvaudio = nicam ? WW_NICAM_BGDKL : WW_A2_DK;
+
+	} else if (V4L2_STD_PAL_I & norm->id) {
+		core->tvaudio = WW_NICAM_I;
+
+	} else if (V4L2_STD_SECAM_L & norm->id) {
+		core->tvaudio = WW_SYSTEM_L_AM;
+
+	} else if (V4L2_STD_SECAM_DK & norm->id) {
+		core->tvaudio = WW_A2_DK;
+
+	} else if ((V4L2_STD_NTSC_M & norm->id) ||
+		   (V4L2_STD_PAL_M  & norm->id)) {
+		core->tvaudio = WW_BTSC;
+
+	} else if (V4L2_STD_NTSC_M_JP & norm->id) {
+		core->tvaudio = WW_EIAJ;
+
+	} else {
+		printk("%s/0: tvaudio support needs work for this tv norm [%s], sorry\n",
+		       core->name, norm->name);
+		core->tvaudio = 0;
+		return 0;
+	}
+
+	cx_andor(MO_AFECFG_IO, 0x1f, 0x0);
+	cx88_set_tvaudio(core);
+	// cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO);
+
+	cx_write(MO_AUDD_LNGTH, 128/8);  /* fifo size */
+	cx_write(MO_AUDR_LNGTH, 128/8);  /* fifo size */
+	cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */
+	return 0;
+}
+
+int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
+{
+	u32 fsc8;
+	u32 adc_clock;
+	u32 vdec_clock;
+	u32 step_db,step_dr;
+	u64 tmp64;
+	u32 bdelay,agcdelay,htotal;
+
+	core->tvnorm = norm;
+	fsc8       = norm_fsc8(norm);
+	adc_clock  = xtal;
+	vdec_clock = fsc8;
+	step_db    = fsc8;
+	step_dr    = fsc8;
+
+	if (norm->id & V4L2_STD_SECAM) {
+		step_db = 4250000 * 8;
+		step_dr = 4406250 * 8;
+	}
+
+	dprintk(1,"set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d db/dr=%d/%d\n",
+		norm->name, fsc8, adc_clock, vdec_clock, step_db, step_dr);
+	set_pll(core,2,vdec_clock);
+
+	dprintk(1,"set_tvnorm: MO_INPUT_FORMAT  0x%08x [old=0x%08x]\n",
+		norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
+	cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat);
+
+#if 1
+	// FIXME: as-is from DScaler
+	dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
+		norm->cxoformat, cx_read(MO_OUTPUT_FORMAT));
+	cx_write(MO_OUTPUT_FORMAT, norm->cxoformat);
+#endif
+
+	// MO_SCONV_REG = adc clock / video dec clock * 2^17
+	tmp64  = adc_clock * (u64)(1 << 17);
+	do_div(tmp64, vdec_clock);
+	dprintk(1,"set_tvnorm: MO_SCONV_REG     0x%08x [old=0x%08x]\n",
+		(u32)tmp64, cx_read(MO_SCONV_REG));
+	cx_write(MO_SCONV_REG, (u32)tmp64);
+
+	// MO_SUB_STEP = 8 * fsc / video dec clock * 2^22
+	tmp64  = step_db * (u64)(1 << 22);
+	do_div(tmp64, vdec_clock);
+	dprintk(1,"set_tvnorm: MO_SUB_STEP      0x%08x [old=0x%08x]\n",
+		(u32)tmp64, cx_read(MO_SUB_STEP));
+	cx_write(MO_SUB_STEP, (u32)tmp64);
+
+	// MO_SUB_STEP_DR = 8 * 4406250 / video dec clock * 2^22
+	tmp64  = step_dr * (u64)(1 << 22);
+	do_div(tmp64, vdec_clock);
+	dprintk(1,"set_tvnorm: MO_SUB_STEP_DR   0x%08x [old=0x%08x]\n",
+		(u32)tmp64, cx_read(MO_SUB_STEP_DR));
+	cx_write(MO_SUB_STEP_DR, (u32)tmp64);
+
+	// bdelay + agcdelay
+	bdelay   = vdec_clock * 65 / 20000000 + 21;
+	agcdelay = vdec_clock * 68 / 20000000 + 15;
+	dprintk(1,"set_tvnorm: MO_AGC_BURST     0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n",
+		(bdelay << 8) | agcdelay, cx_read(MO_AGC_BURST), bdelay, agcdelay);
+	cx_write(MO_AGC_BURST, (bdelay << 8) | agcdelay);
+
+	// htotal
+	tmp64 = norm_htotal(norm) * (u64)vdec_clock;
+	do_div(tmp64, fsc8);
+	htotal = (u32)tmp64 | (norm_notchfilter(norm) << 11);
+	dprintk(1,"set_tvnorm: MO_HTOTAL        0x%08x [old=0x%08x,htotal=%d]\n",
+		htotal, cx_read(MO_HTOTAL), (u32)tmp64);
+	cx_write(MO_HTOTAL, htotal);
+
+	// vbi stuff
+	cx_write(MO_VBI_PACKET, ((1 << 11) | /* (norm_vdelay(norm)   << 11) | */
+				 norm_vbipack(norm)));
+
+	// audio
+	set_tvaudio(core);
+
+	// tell i2c chips
+#ifdef V4L2_I2C_CLIENTS
+	cx88_call_i2c_clients(core,VIDIOC_S_STD,&norm->id);
+#else
+	{
+		struct video_channel c;
+		memset(&c,0,sizeof(c));
+		c.channel = core->input;
+		c.norm = VIDEO_MODE_PAL;
+		if ((norm->id & (V4L2_STD_NTSC_M|V4L2_STD_NTSC_M_JP)))
+			c.norm = VIDEO_MODE_NTSC;
+		if (norm->id & V4L2_STD_SECAM)
+			c.norm = VIDEO_MODE_SECAM;
+		cx88_call_i2c_clients(core,VIDIOCSCHAN,&c);
+	}
+#endif
+
+	// done
+	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+
+static int cx88_pci_quirks(char *name, struct pci_dev *pci)
+{
+	unsigned int lat = UNSET;
+	u8 ctrl = 0;
+	u8 value;
+
+	/* check pci quirks */
 	if (pci_pci_problems & PCIPCI_TRITON) {
 		printk(KERN_INFO "%s: quirk: PCIPCI_TRITON -- set TBFX\n",
 		       name);
@@ -563,25 +1026,174 @@
 	if (pci_pci_problems & PCIPCI_ALIMAGIK) {
 		printk(KERN_INFO "%s: quirk: PCIPCI_ALIMAGIK -- latency fixup\n",
 		       name);
-		*latency = 0x0A;
+		lat = 0x0A;
 	}
 #endif
+
+	/* check insmod options */
+	if (UNSET != latency)
+		lat = latency;
+
+	/* apply stuff */
 	if (ctrl) {
 		pci_read_config_byte(pci, CX88X_DEVCTRL, &value);
 		value |= ctrl;
 		pci_write_config_byte(pci, CX88X_DEVCTRL, value);
 	}
+	if (UNSET != lat) {
+		printk(KERN_INFO "%s: setting pci latency timer to %d\n",
+		       name, latency);
+		pci_write_config_byte(pci, PCI_LATENCY_TIMER, latency);
+	}
 	return 0;
 }
 
 /* ------------------------------------------------------------------ */
 
+struct video_device *cx88_vdev_init(struct cx88_core *core,
+				    struct pci_dev *pci,
+				    struct video_device *template,
+				    char *type)
+{
+	struct video_device *vfd;
+
+	vfd = video_device_alloc();
+	if (NULL == vfd)
+		return NULL;
+	*vfd = *template;
+	vfd->minor   = -1;
+	vfd->dev     = &pci->dev;
+	vfd->release = video_device_release;
+	snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
+		 core->name, type, cx88_boards[core->board].name);
+	return vfd;
+}
+
+static int get_ressources(struct cx88_core *core, struct pci_dev *pci)
+{
+	if (request_mem_region(pci_resource_start(pci,0),
+			       pci_resource_len(pci,0),
+			       core->name))
+		return 0;
+	printk(KERN_ERR "%s: can't get MMIO memory @ 0x%lx\n",
+	       core->name,pci_resource_start(pci,0));
+	return -EBUSY;
+}
+
+struct cx88_core* cx88_core_get(struct pci_dev *pci)
+{
+	struct cx88_core *core;
+	struct list_head *item;
+	int i;
+
+	down(&devlist);
+	list_for_each(item,&cx88_devlist) {
+		core = list_entry(item, struct cx88_core, devlist);
+		if (pci->bus->number != core->pci_bus)
+			continue;
+		if (PCI_SLOT(pci->devfn) != core->pci_slot)
+			continue;
+
+		if (0 != get_ressources(core,pci))
+			goto fail_unlock;
+		atomic_inc(&core->refcount);
+		up(&devlist);
+		return core;
+	}
+	core = kmalloc(sizeof(*core),GFP_KERNEL);
+	if (NULL == core)
+		goto fail_unlock;
+
+	memset(core,0,sizeof(*core));
+	core->pci_bus  = pci->bus->number;
+	core->pci_slot = PCI_SLOT(pci->devfn);
+	atomic_inc(&core->refcount);
+
+	core->nr = cx88_devcount++;
+	sprintf(core->name,"cx88[%d]",core->nr);
+	if (0 != get_ressources(core,pci)) {
+		cx88_devcount--;
+		goto fail_free;
+	}
+	list_add_tail(&core->devlist,&cx88_devlist);
+
+	/* PCI stuff */
+	cx88_pci_quirks(core->name, pci);
+	core->lmmio = ioremap(pci_resource_start(pci,0),
+			      pci_resource_len(pci,0));
+	core->bmmio = (u8 __iomem *)core->lmmio;
+
+	/* board config */
+	core->board = UNSET;
+	if (card[core->nr] < cx88_bcount)
+		core->board = card[core->nr];
+	for (i = 0; UNSET == core->board  &&  i < cx88_idcount; i++)
+		if (pci->subsystem_vendor == cx88_subids[i].subvendor &&
+		    pci->subsystem_device == cx88_subids[i].subdevice)
+			core->board = cx88_subids[i].card;
+	if (UNSET == core->board) {
+		core->board = CX88_BOARD_UNKNOWN;
+		cx88_card_list(core,pci);
+	}
+        printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
+	       core->name,pci->subsystem_vendor,
+	       pci->subsystem_device,cx88_boards[core->board].name,
+	       core->board, card[core->nr] == core->board ?
+	       "insmod option" : "autodetected");
+
+	core->tuner_type = tuner[core->nr];
+	if (UNSET == core->tuner_type)
+		core->tuner_type = cx88_boards[core->board].tuner_type;
+	core->tda9887_conf = cx88_boards[core->board].tda9887_conf;
+
+	/* init hardware */
+	cx88_reset(core);
+	cx88_i2c_init(core,pci);
+	cx88_card_setup(core);
+
+	up(&devlist);
+	return core;
+
+fail_free:
+	kfree(core);
+fail_unlock:
+	up(&devlist);
+	return NULL;
+}
+
+void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
+{
+	release_mem_region(pci_resource_start(pci,0),
+			   pci_resource_len(pci,0));
+
+	if (!atomic_dec_and_test(&core->refcount))
+		return;
+
+	down(&devlist);
+	if (0 == core->i2c_rc)
+		i2c_bit_del_bus(&core->i2c_adap);
+	list_del(&core->devlist);
+	iounmap(core->lmmio);
+	cx88_devcount--;
+	up(&devlist);
+	kfree(core);
+}
+
+/* ------------------------------------------------------------------ */
+
 EXPORT_SYMBOL(cx88_print_ioctl);
 EXPORT_SYMBOL(cx88_pci_irqs);
 EXPORT_SYMBOL(cx88_vid_irqs);
+EXPORT_SYMBOL(cx88_mpeg_irqs);
 EXPORT_SYMBOL(cx88_print_irqbits);
 
+EXPORT_SYMBOL(cx88_irq);
+EXPORT_SYMBOL(cx88_wakeup);
+EXPORT_SYMBOL(cx88_reset);
+EXPORT_SYMBOL(cx88_shutdown);
+
 EXPORT_SYMBOL(cx88_risc_buffer);
+EXPORT_SYMBOL(cx88_risc_databuffer);
 EXPORT_SYMBOL(cx88_risc_stopper);
 EXPORT_SYMBOL(cx88_free_buffer);
 
@@ -591,7 +1203,12 @@
 EXPORT_SYMBOL(cx88_sram_channel_setup);
 EXPORT_SYMBOL(cx88_sram_channel_dump);
 
-EXPORT_SYMBOL(cx88_pci_quirks);
+EXPORT_SYMBOL(cx88_set_tvnorm);
+EXPORT_SYMBOL(cx88_set_scale);
+
+EXPORT_SYMBOL(cx88_vdev_init);
+EXPORT_SYMBOL(cx88_core_get);
+EXPORT_SYMBOL(cx88_core_put);
 
 /*
  * Local variables:
diff -Nru a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/video/cx88/cx88-dvb.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,338 @@
+/*
+ * $Id: cx88-dvb.c,v 1.19 2004/11/07 14:44:59 kraxel Exp $
+ *
+ * device driver for Conexant 2388x based TV cards
+ * MPEG Transport Stream (DVB) routines
+ *
+ * (c) 2004 Chris Pascoe <c.pascoe@itee.uq.edu.au>
+ * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *
+ *  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.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/kthread.h>
+#include <linux/file.h>
+#include <linux/suspend.h>
+
+#include "cx88.h"
+#include "cx22702.h"
+#include "mt352.h"
+#include "mt352_priv.h" /* FIXME */
+
+MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
+MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+static unsigned int debug = 0;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
+
+#define dprintk(level,fmt, arg...)	if (debug >= level) \
+	printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->core->name , ## arg)
+
+/* ------------------------------------------------------------------ */
+
+static int dvb_buf_setup(struct videobuf_queue *q,
+			 unsigned int *count, unsigned int *size)
+{
+	struct cx8802_dev *dev = q->priv_data;
+
+	dev->ts_packet_size  = 188 * 4;
+	dev->ts_packet_count = 32;
+
+	*size  = dev->ts_packet_size * dev->ts_packet_count;
+	*count = 32;
+	return 0;
+}
+
+static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
+			   enum v4l2_field field)
+{
+	struct cx8802_dev *dev = q->priv_data;
+	return cx8802_buf_prepare(dev, (struct cx88_buffer*)vb);
+}
+
+static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
+{
+	struct cx8802_dev *dev = q->priv_data;
+	cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
+}
+
+static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
+{
+	struct cx8802_dev *dev = q->priv_data;
+	cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb);
+}
+
+struct videobuf_queue_ops dvb_qops = {
+	.buf_setup    = dvb_buf_setup,
+	.buf_prepare  = dvb_buf_prepare,
+	.buf_queue    = dvb_buf_queue,
+	.buf_release  = dvb_buf_release,
+};
+
+/* ------------------------------------------------------------------ */
+
+static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
+{
+	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x39 };
+	static u8 reset []         = { RESET,      0x80 };
+	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
+	static u8 agc_cfg []       = { AGC_TARGET, 0x24, 0x20 };
+	static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
+	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
+
+	mt352_write(fe, clock_config,   sizeof(clock_config));
+	udelay(200);
+	mt352_write(fe, reset,          sizeof(reset));
+	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
+
+	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
+	mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
+	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
+	return 0;
+}
+
+#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
+
+static int lg_z201_pll_set(struct dvb_frontend* fe,
+			   struct dvb_frontend_parameters* params, u8* pllbuf)
+{
+	u32 div;
+	unsigned char cp = 0;
+	unsigned char bs = 0;
+
+	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
+
+	if (params->frequency < 542000000) cp = 0xbc;
+	else if (params->frequency < 830000000) cp = 0xf4;
+	else cp = 0xfc;
+
+	if (params->frequency == 0) bs = 0x03;
+	else if (params->frequency < 157500000) bs = 0x01;
+	else if (params->frequency < 443250000) bs = 0x02;
+	else bs = 0x04;
+
+	pllbuf[0] = 0xC2; /* Note: non-linux standard PLL I2C address */
+	pllbuf[1] = div >> 8;
+	pllbuf[2] = div & 0xff;
+	pllbuf[3] = cp;
+	pllbuf[4] = bs;
+
+	return 0;
+}
+
+static int thomson_dtt7579_pll_set(struct dvb_frontend* fe,
+				   struct dvb_frontend_parameters* params,
+				   u8* pllbuf)
+{
+	u32 div;
+	unsigned char cp = 0;
+	unsigned char bs = 0;
+
+	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
+
+	if (params->frequency < 542000000) cp = 0xb4;
+	else if (params->frequency < 771000000) cp = 0xbc;
+	else cp = 0xf4;
+
+        if (params->frequency == 0) bs = 0x03;
+	else if (params->frequency < 443250000) bs = 0x02;
+	else bs = 0x08;
+
+	pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address
+	pllbuf[1] = div >> 8;
+   	pllbuf[2] = div & 0xff;
+   	pllbuf[3] = cp;
+   	pllbuf[4] = bs;
+
+	return 0;
+}
+
+struct mt352_config dvico_fusionhdtv_dvbt1 = {
+	.demod_address = 0x0F,
+	.demod_init    = dvico_fusionhdtv_demod_init,
+	.pll_set       = lg_z201_pll_set,
+};
+
+struct mt352_config dvico_fusionhdtv_dvbt_plus = {
+	.demod_address = 0x0F,
+	.demod_init    = dvico_fusionhdtv_demod_init,
+	.pll_set       = thomson_dtt7579_pll_set,
+};
+
+static int dvb_register(struct cx8802_dev *dev)
+{
+	/* init struct videobuf_dvb */
+	dev->dvb.name = dev->core->name;
+
+	/* init frontend */
+	switch (dev->core->board) {
+	case CX88_BOARD_HAUPPAUGE_DVB_T1:
+	case CX88_BOARD_CONEXANT_DVB_T1:
+		dev->dvb.frontend = cx22702_create(&dev->core->i2c_adap,
+						   dev->core->pll_addr,
+						   dev->core->pll_type,
+						   dev->core->demod_addr);
+		break;
+	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
+		dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt1,
+						 &dev->core->i2c_adap);
+		if (dev->dvb.frontend) {
+			dev->dvb.frontend->ops->info.frequency_min = 174000000;
+			dev->dvb.frontend->ops->info.frequency_max = 862000000;
+		}
+		break;
+	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
+		dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt_plus,
+						 &dev->core->i2c_adap);
+		if (dev->dvb.frontend) {
+			dev->dvb.frontend->ops->info.frequency_min = 174000000;
+			dev->dvb.frontend->ops->info.frequency_max = 862000000;
+		}
+		break;
+	default:
+		printk("%s: FIXME: frontend handling not here yet ...\n",
+		       dev->core->name);
+		break;
+	}
+	if (NULL == dev->dvb.frontend)
+		return -1;
+
+	/* Copy the board name into the DVB structure */
+	strlcpy(dev->dvb.frontend->ops->info.name,
+		cx88_boards[dev->core->board].name,
+		sizeof(dev->dvb.frontend->ops->info.name));
+
+	/* register everything */
+	return videobuf_dvb_register(&dev->dvb);
+}
+
+/* ----------------------------------------------------------- */
+
+static int __devinit dvb_probe(struct pci_dev *pci_dev,
+			       const struct pci_device_id *pci_id)
+{
+	struct cx8802_dev *dev;
+	struct cx88_core  *core;
+	int err;
+
+	/* general setup */
+	core = cx88_core_get(pci_dev);
+	if (NULL == core)
+		return -EINVAL;
+
+	err = -ENODEV;
+	if (!cx88_boards[core->board].dvb)
+		goto fail_core;
+
+	err = -ENOMEM;
+	dev = kmalloc(sizeof(*dev),GFP_KERNEL);
+	if (NULL == dev)
+		goto fail_core;
+	memset(dev,0,sizeof(*dev));
+	dev->pci = pci_dev;
+	dev->core = core;
+
+	err = cx8802_init_common(dev);
+	if (0 != err)
+		goto fail_free;
+
+	/* dvb stuff */
+	printk("%s/2: cx2388x based dvb card\n", core->name);
+	videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
+			    dev->pci, &dev->slock,
+			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
+			    V4L2_FIELD_TOP,
+			    sizeof(struct cx88_buffer),
+			    dev);
+	err = dvb_register(dev);
+	if (0 != err)
+		goto fail_free;
+	return 0;
+
+ fail_free:
+	kfree(dev);
+ fail_core:
+	cx88_core_put(core,pci_dev);
+	return err;
+}
+
+static void __devexit dvb_remove(struct pci_dev *pci_dev)
+{
+        struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
+
+	/* dvb */
+	videobuf_dvb_unregister(&dev->dvb);
+
+	/* common */
+	cx8802_fini_common(dev);
+	cx88_core_put(dev->core,dev->pci);
+	kfree(dev);
+}
+
+static struct pci_device_id cx8802_pci_tbl[] = {
+	{
+		.vendor       = 0x14f1,
+		.device       = 0x8802,
+                .subvendor    = PCI_ANY_ID,
+                .subdevice    = PCI_ANY_ID,
+	},{
+		/* --- end of list --- */
+	}
+};
+MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl);
+
+static struct pci_driver dvb_pci_driver = {
+        .name     = "cx88-dvb",
+        .id_table = cx8802_pci_tbl,
+        .probe    = dvb_probe,
+        .remove   = __devexit_p(dvb_remove),
+	.suspend  = cx8802_suspend_common,
+	.resume   = cx8802_resume_common,
+};
+
+static int dvb_init(void)
+{
+	printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n",
+	       (CX88_VERSION_CODE >> 16) & 0xff,
+	       (CX88_VERSION_CODE >>  8) & 0xff,
+	       CX88_VERSION_CODE & 0xff);
+#ifdef SNAPSHOT
+	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
+	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
+#endif
+	return pci_module_init(&dvb_pci_driver);
+}
+
+static void dvb_fini(void)
+{
+	pci_unregister_driver(&dvb_pci_driver);
+}
+
+module_init(dvb_init);
+module_exit(dvb_fini);
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * compile-command: "make DVB=1"
+ * End:
+ */
diff -Nru a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
--- a/drivers/media/video/cx88/cx88-i2c.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/media/video/cx88/cx88-i2c.c	2004-12-24 13:36:47 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: cx88-i2c.c,v 1.18 2004/10/13 10:39:00 kraxel Exp $
+
     cx88-i2c.c  --  all the i2c code is here
 
     Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@thp.uni-koeln.de)
@@ -19,7 +21,7 @@
     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>
@@ -29,44 +31,55 @@
 
 #include "cx88.h"
 
+static unsigned int i2c_debug = 0;
+module_param(i2c_debug, int, 0644);
+MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]");
+
+static unsigned int i2c_scan = 0;
+module_param(i2c_scan, int, 0444);
+MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
+
+#define dprintk(level,fmt, arg...)	if (i2c_debug >= level) \
+	printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
+
 /* ----------------------------------------------------------------------- */
 
 void cx8800_bit_setscl(void *data, int state)
 {
-	struct cx8800_dev *dev = data;
+	struct cx88_core *core = data;
 
 	if (state)
-		dev->i2c_state |= 0x02;
+		core->i2c_state |= 0x02;
 	else
-		dev->i2c_state &= ~0x02;
-	cx_write(MO_I2C, dev->i2c_state);
+		core->i2c_state &= ~0x02;
+	cx_write(MO_I2C, core->i2c_state);
 	cx_read(MO_I2C);
 }
 
 void cx8800_bit_setsda(void *data, int state)
 {
-	struct cx8800_dev *dev = data;
+	struct cx88_core *core = data;
 
 	if (state)
-		dev->i2c_state |= 0x01;
+		core->i2c_state |= 0x01;
 	else
-		dev->i2c_state &= ~0x01;
-	cx_write(MO_I2C, dev->i2c_state);
+		core->i2c_state &= ~0x01;
+	cx_write(MO_I2C, core->i2c_state);
 	cx_read(MO_I2C);
 }
 
 static int cx8800_bit_getscl(void *data)
 {
-	struct cx8800_dev *dev = data;
+	struct cx88_core *core = data;
 	u32 state;
-	
+
 	state = cx_read(MO_I2C);
 	return state & 0x02 ? 1 : 0;
 }
 
 static int cx8800_bit_getsda(void *data)
 {
-	struct cx8800_dev *dev = data;
+	struct cx88_core *core = data;
 	u32 state;
 
 	state = cx_read(MO_I2C);
@@ -75,36 +88,35 @@
 
 /* ----------------------------------------------------------------------- */
 
-#ifndef I2C_PEC
-static void cx8800_inc_use(struct i2c_adapter *adap)
+static int attach_inform(struct i2c_client *client)
 {
-	MOD_INC_USE_COUNT;
-}
+	struct cx88_core *core = i2c_get_adapdata(client->adapter);
 
-static void cx8800_dec_use(struct i2c_adapter *adap)
-{
-	MOD_DEC_USE_COUNT;
+	dprintk(1, "i2c attach [addr=0x%x,client=%s]\n",
+		client->addr, i2c_clientname(client));
+	if (!client->driver->command)
+		return 0;
+
+	if (core->tuner_type != UNSET)
+		client->driver->command(client, TUNER_SET_TYPE, &core->tuner_type);
+	if (core->tda9887_conf)
+		client->driver->command(client, TDA9887_SET_CONFIG, &core->tda9887_conf);
+	return 0;
 }
-#endif
 
-static int attach_inform(struct i2c_client *client)
+static int detach_inform(struct i2c_client *client)
 {
-        struct cx8800_dev *dev = i2c_get_adapdata(client->adapter);
-
-	if (dev->tuner_type != UNSET)
-		cx8800_call_i2c_clients(dev,TUNER_SET_TYPE,&dev->tuner_type);
+	struct cx88_core *core = i2c_get_adapdata(client->adapter);
 
-        if (1 /* fixme: debug */)
-		printk("%s: i2c attach [client=%s]\n",
-		       dev->name, i2c_clientname(client));
-        return 0;
+	dprintk(1, "i2c detach [client=%s]\n", i2c_clientname(client));
+	return 0;
 }
 
-void cx8800_call_i2c_clients(struct cx8800_dev *dev, unsigned int cmd, void *arg)
+void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg)
 {
-	if (0 != dev->i2c_rc)
+	if (0 != core->i2c_rc)
 		return;
-	i2c_clients_command(&dev->i2c_adap, cmd, arg);
+	i2c_clients_command(&core->i2c_adap, cmd, arg);
 }
 
 static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
@@ -120,18 +132,11 @@
 /* ----------------------------------------------------------------------- */
 
 static struct i2c_adapter cx8800_i2c_adap_template = {
-#ifdef I2C_PEC
-	.owner             = THIS_MODULE,
-#else
-	.inc_use           = cx8800_inc_use,
-	.dec_use           = cx8800_dec_use,
-#endif
-#ifdef I2C_CLASS_TV_ANALOG
-	.class             = I2C_CLASS_TV_ANALOG,
-#endif
 	I2C_DEVNAME("cx2388x"),
+	.owner             = THIS_MODULE,
 	.id                = I2C_HW_B_BT848,
 	.client_register   = attach_inform,
+	.client_unregister = detach_inform,
 };
 
 static struct i2c_client cx8800_i2c_client_template = {
@@ -139,31 +144,67 @@
         .id   = -1,
 };
 
+static char *i2c_devs[128] = {
+	[ 0x86 >> 1 ] = "tda9887/cx22702",
+	[ 0xa0 >> 1 ] = "eeprom",
+	[ 0xc0 >> 1 ] = "tuner (analog)",
+	[ 0xc2 >> 1 ] = "tuner (analog/dvb)",
+};
+
+static void do_i2c_scan(char *name, struct i2c_client *c)
+{
+	unsigned char buf;
+	int i,rc;
+
+	for (i = 0; i < 128; i++) {
+		c->addr = i;
+		rc = i2c_master_recv(c,&buf,0);
+		if (rc < 0)
+			continue;
+		printk("%s: i2c scan: found device @ 0x%x  [%s]\n",
+		       name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
+	}
+}
+
 /* init + register i2c algo-bit adapter */
-int __devinit cx8800_i2c_init(struct cx8800_dev *dev)
+int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
 {
-	memcpy(&dev->i2c_adap, &cx8800_i2c_adap_template,
-	       sizeof(dev->i2c_adap));
-	memcpy(&dev->i2c_algo, &cx8800_i2c_algo_template,
-	       sizeof(dev->i2c_algo));
-	memcpy(&dev->i2c_client, &cx8800_i2c_client_template,
-	       sizeof(dev->i2c_client));
-
-	dev->i2c_adap.dev.parent = &dev->pci->dev;
-	strlcpy(dev->i2c_adap.name,dev->name,sizeof(dev->i2c_adap.name));
-        dev->i2c_algo.data = dev;
-        i2c_set_adapdata(&dev->i2c_adap,dev);
-        dev->i2c_adap.algo_data = &dev->i2c_algo;
-        dev->i2c_client.adapter = &dev->i2c_adap;
-
-	cx8800_bit_setscl(dev,1);
-	cx8800_bit_setsda(dev,1);
-
-	dev->i2c_rc = i2c_bit_add_bus(&dev->i2c_adap);
-	printk("%s: i2c register %s\n", dev->name,
-	       (0 == dev->i2c_rc) ? "ok" : "FAILED");
-	return dev->i2c_rc;
+	memcpy(&core->i2c_adap, &cx8800_i2c_adap_template,
+	       sizeof(core->i2c_adap));
+	memcpy(&core->i2c_algo, &cx8800_i2c_algo_template,
+	       sizeof(core->i2c_algo));
+	memcpy(&core->i2c_client, &cx8800_i2c_client_template,
+	       sizeof(core->i2c_client));
+
+	if (core->tuner_type != TUNER_ABSENT)
+		core->i2c_adap.class |= I2C_CLASS_TV_ANALOG;
+	if (cx88_boards[core->board].dvb)
+		core->i2c_adap.class |= I2C_CLASS_TV_DIGITAL;
+
+	core->i2c_adap.dev.parent = &pci->dev;
+	strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name));
+        core->i2c_algo.data = core;
+        i2c_set_adapdata(&core->i2c_adap,core);
+        core->i2c_adap.algo_data = &core->i2c_algo;
+        core->i2c_client.adapter = &core->i2c_adap;
+
+	cx8800_bit_setscl(core,1);
+	cx8800_bit_setsda(core,1);
+
+	core->i2c_rc = i2c_bit_add_bus(&core->i2c_adap);
+	if (0 == core->i2c_rc) {
+		dprintk(1, "i2c register ok\n");
+		if (i2c_scan)
+			do_i2c_scan(core->name,&core->i2c_client);
+	} else
+		printk("%s: i2c register FAILED\n", core->name);
+	return core->i2c_rc;
 }
+
+/* ----------------------------------------------------------------------- */
+
+EXPORT_SYMBOL(cx88_call_i2c_clients);
+EXPORT_SYMBOL(cx88_i2c_init);
 
 /*
  * Local variables:
diff -Nru a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/video/cx88/cx88-mpeg.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,468 @@
+/*
+ * $Id: cx88-mpeg.c,v 1.14 2004/10/25 11:26:36 kraxel Exp $
+ *
+ *  Support for the mpeg transport stream transfers
+ *  PCI function #2 of the cx2388x.
+ *
+ *    (c) 2004 Jelle Foks <jelle@foks.8m.com>
+ *    (c) 2004 Chris Pascoe <c.pascoe@itee.uq.edu.au>
+ *    (c) 2004 Gerd Knorr <kraxel@bytesex.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 program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+#include <asm/delay.h>
+
+#include "cx88.h"
+
+/* ------------------------------------------------------------------ */
+
+MODULE_DESCRIPTION("mpeg driver for cx2388x based TV cards");
+MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>");
+MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+static unsigned int debug = 0;
+module_param(debug,int,0644);
+MODULE_PARM_DESC(debug,"enable debug messages [mpeg]");
+
+#define dprintk(level,fmt, arg...)	if (debug >= level) \
+	printk(KERN_DEBUG "%s/2: " fmt, dev->core->name , ## arg)
+
+/* ------------------------------------------------------------------ */
+
+static int cx8802_start_dma(struct cx8802_dev    *dev,
+			    struct cx88_dmaqueue *q,
+			    struct cx88_buffer   *buf)
+{
+	struct cx88_core *core = dev->core;
+
+	dprintk(1, "cx8802_start_mpegport_dma %d\n", buf->vb.width);
+
+	/* setup fifo + format */
+	cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28],
+				dev->ts_packet_size, buf->risc.dma);
+
+	/* write TS length to chip */
+	cx_write(MO_TS_LNGTH, buf->vb.width);
+
+#if 1
+	/* FIXME: this needs a review.
+	 * also: move to cx88-blackbird + cx88-dvb source files? */
+
+	if (cx88_boards[core->board].dvb) {
+		/* Setup TS portion of chip */
+		cx_write(TS_GEN_CNTRL, 0x0c);
+	}
+
+	if (cx88_boards[core->board].blackbird) {
+		cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */
+
+		// cx_write(TS_F2_CMD_STAT_MM, 0x2900106); /* F2_CMD_STAT_MM defaults + master + memory space */
+		cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */
+		udelay(100);
+
+		cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */
+		//cx_write(TS_HW_SOP_CNTRL, 0x2F0BC0); /* mpeg start byte ts: 0x2F0BC0 ? */
+		cx_write(TS_VALERR_CNTRL, 0x2000);
+
+		cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */
+		udelay(100);
+	}
+#endif
+
+	/* reset counter */
+	cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET);
+	q->count = 1;
+
+	/* enable irqs */
+	cx_set(MO_PCI_INTMSK, 0x00fc04);
+	cx_write(MO_TS_INTMSK,  0x1f0011);
+
+	/* start dma */
+	cx_write(MO_DEV_CNTRL2, (1<<5)); /* FIXME: s/write/set/ ??? */
+	cx_write(MO_TS_DMACNTRL, 0x11);
+	return 0;
+}
+
+static int cx8802_stop_dma(struct cx8802_dev *dev)
+{
+	struct cx88_core *core = dev->core;
+
+	/* stop dma */
+	cx_clear(MO_TS_DMACNTRL, 0x11);
+
+	/* disable irqs */
+	cx_clear(MO_PCI_INTMSK, 0x000004);
+	cx_clear(MO_TS_INTMSK, 0x1f0011);
+
+	/* Reset the controller */
+	cx_write(TS_GEN_CNTRL, 0xcd);
+	return 0;
+}
+
+static int cx8802_restart_queue(struct cx8802_dev    *dev,
+				struct cx88_dmaqueue *q)
+{
+	struct cx88_buffer *buf;
+	struct list_head *item;
+
+	if (list_empty(&q->active))
+		return 0;
+
+	buf = list_entry(q->active.next, struct cx88_buffer, vb.queue);
+	dprintk(2,"restart_queue [%p/%d]: restart dma\n",
+		buf, buf->vb.i);
+	cx8802_start_dma(dev, q, buf);
+	list_for_each(item,&q->active) {
+		buf = list_entry(item, struct cx88_buffer, vb.queue);
+		buf->count = q->count++;
+	}
+	mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+
+int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf)
+{
+	int size = dev->ts_packet_size * dev->ts_packet_count;
+	int rc;
+
+	dprintk(1, "%s: %p\n", __FUNCTION__, buf);
+	if (0 != buf->vb.baddr  &&  buf->vb.bsize < size)
+		return -EINVAL;
+
+	if (STATE_NEEDS_INIT == buf->vb.state) {
+		buf->vb.width  = dev->ts_packet_size;
+		buf->vb.height = dev->ts_packet_count;
+		buf->vb.size   = size;
+		buf->vb.field  = V4L2_FIELD_TOP;
+
+		if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
+			goto fail;
+		cx88_risc_databuffer(dev->pci, &buf->risc,
+				     buf->vb.dma.sglist,
+				     buf->vb.width, buf->vb.height);
+	}
+	buf->vb.state = STATE_PREPARED;
+	return 0;
+
+ fail:
+	cx88_free_buffer(dev->pci,buf);
+	return rc;
+}
+
+void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
+{
+	struct cx88_buffer    *prev;
+	struct cx88_dmaqueue  *q    = &dev->mpegq;
+
+	/* add jump to stopper */
+	buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
+	buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
+
+	if (list_empty(&q->active)) {
+		list_add_tail(&buf->vb.queue,&q->active);
+		cx8802_start_dma(dev, q, buf);
+		buf->vb.state = STATE_ACTIVE;
+		buf->count    = q->count++;
+		mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+		dprintk(2,"[%p/%d] %s - first active\n",
+			buf, buf->vb.i, __FUNCTION__);
+
+	} else {
+		prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue);
+		list_add_tail(&buf->vb.queue,&q->active);
+		buf->vb.state = STATE_ACTIVE;
+		buf->count    = q->count++;
+		prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
+		dprintk(2,"[%p/%d] %s - append to active\n",
+			buf, buf->vb.i, __FUNCTION__);
+	}
+}
+
+/* ----------------------------------------------------------- */
+
+static void do_cancel_buffers(struct cx8802_dev *dev, char *reason, int restart)
+{
+	struct cx88_dmaqueue *q = &dev->mpegq;
+	struct cx88_buffer *buf;
+	unsigned long flags;
+
+	spin_lock_irqsave(&dev->slock,flags);
+	while (!list_empty(&q->active)) {
+		buf = list_entry(q->active.next, struct cx88_buffer, vb.queue);
+		list_del(&buf->vb.queue);
+		buf->vb.state = STATE_ERROR;
+		wake_up(&buf->vb.done);
+		dprintk(1,"[%p/%d] %s - dma=0x%08lx\n",
+			buf, buf->vb.i, reason, (unsigned long)buf->risc.dma);
+	}
+	if (restart)
+		cx8802_restart_queue(dev,q);
+	spin_unlock_irqrestore(&dev->slock,flags);
+}
+
+void cx8802_cancel_buffers(struct cx8802_dev *dev)
+{
+	struct cx88_dmaqueue *q = &dev->mpegq;
+
+	del_timer_sync(&q->timeout);
+	cx8802_stop_dma(dev);
+	do_cancel_buffers(dev,"cancel",0);
+}
+
+static void cx8802_timeout(unsigned long data)
+{
+	struct cx8802_dev *dev = (struct cx8802_dev*)data;
+
+	dprintk(1, "%s\n",__FUNCTION__);
+
+	if (debug)
+		cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]);
+	cx8802_stop_dma(dev);
+	do_cancel_buffers(dev,"timeout",1);
+}
+
+static void cx8802_mpeg_irq(struct cx8802_dev *dev)
+{
+	struct cx88_core *core = dev->core;
+	u32 status, mask, count;
+
+	status = cx_read(MO_TS_INTSTAT);
+	mask   = cx_read(MO_TS_INTMSK);
+	if (0 == (status & mask))
+		return;
+
+	cx_write(MO_TS_INTSTAT, status);
+	if (debug || (status & mask & ~0xff))
+		cx88_print_irqbits(core->name, "irq mpeg ",
+				   cx88_mpeg_irqs, status, mask);
+
+	/* risc op code error */
+	if (status & (1 << 16)) {
+		printk(KERN_WARNING "%s: mpeg risc op code error\n",core->name);
+		cx_clear(MO_TS_DMACNTRL, 0x11);
+		cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]);
+	}
+
+	/* risc1 y */
+	if (status & 0x01) {
+		spin_lock(&dev->slock);
+		count = cx_read(MO_TS_GPCNT);
+		cx88_wakeup(dev->core, &dev->mpegq, count);
+		spin_unlock(&dev->slock);
+	}
+
+	/* risc2 y */
+	if (status & 0x10) {
+		spin_lock(&dev->slock);
+		cx8802_restart_queue(dev,&dev->mpegq);
+		spin_unlock(&dev->slock);
+	}
+
+        /* other general errors */
+        if (status & 0x1f0100) {
+                spin_lock(&dev->slock);
+		cx8802_stop_dma(dev);
+                cx8802_restart_queue(dev,&dev->mpegq);
+                spin_unlock(&dev->slock);
+        }
+}
+
+static irqreturn_t cx8802_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct cx8802_dev *dev = dev_id;
+	struct cx88_core *core = dev->core;
+	u32 status, mask;
+	int loop, handled = 0;
+
+	for (loop = 0; loop < 10; loop++) {
+		status = cx_read(MO_PCI_INTSTAT) & (~0x1f | 0x04);
+		mask   = cx_read(MO_PCI_INTMSK);
+		if (0 == (status & mask))
+			goto out;
+		handled = 1;
+		cx_write(MO_PCI_INTSTAT, status);
+
+		if (status & mask & ~0x1f)
+			cx88_irq(core,status,mask);
+		if (status & 0x04)
+			cx8802_mpeg_irq(dev);
+	};
+	if (10 == loop) {
+		printk(KERN_WARNING "%s/0: irq loop -- clearing mask\n",
+		       core->name);
+		cx_write(MO_PCI_INTMSK,0);
+	}
+
+ out:
+	return IRQ_RETVAL(handled);
+}
+
+/* ----------------------------------------------------------- */
+/* exported stuff                                              */
+
+int cx8802_init_common(struct cx8802_dev *dev)
+{
+	int err;
+
+	/* pci init */
+	if (pci_enable_device(dev->pci))
+		return -EIO;
+	pci_set_master(dev->pci);
+	if (!pci_dma_supported(dev->pci,0xffffffff)) {
+		printk("%s/2: Oops: no 32bit PCI DMA ???\n",dev->core->name);
+		return -EIO;
+	}
+
+	pci_read_config_byte(dev->pci, PCI_CLASS_REVISION, &dev->pci_rev);
+        pci_read_config_byte(dev->pci, PCI_LATENCY_TIMER,  &dev->pci_lat);
+        printk(KERN_INFO "%s/2: found at %s, rev: %d, irq: %d, "
+	       "latency: %d, mmio: 0x%lx\n", dev->core->name,
+	       pci_name(dev->pci), dev->pci_rev, dev->pci->irq,
+	       dev->pci_lat,pci_resource_start(dev->pci,0));
+
+	/* initialize driver struct */
+        init_MUTEX(&dev->lock);
+	dev->slock = SPIN_LOCK_UNLOCKED;
+
+	/* init dma queue */
+	INIT_LIST_HEAD(&dev->mpegq.active);
+	INIT_LIST_HEAD(&dev->mpegq.queued);
+	dev->mpegq.timeout.function = cx8802_timeout;
+	dev->mpegq.timeout.data     = (unsigned long)dev;
+	init_timer(&dev->mpegq.timeout);
+	cx88_risc_stopper(dev->pci,&dev->mpegq.stopper,
+			  MO_TS_DMACNTRL,0x11,0x00);
+
+#if 0 /* FIXME */
+	/* initialize hardware */
+	cx8802_reset(dev);
+#endif
+
+	/* get irq */
+	err = request_irq(dev->pci->irq, cx8802_irq,
+			  SA_SHIRQ | SA_INTERRUPT, dev->core->name, dev);
+	if (err < 0) {
+		printk(KERN_ERR "%s: can't get IRQ %d\n",
+		       dev->core->name, dev->pci->irq);
+		return err;
+	}
+
+#if 0 /* FIXME */
+	/* register i2c bus + load i2c helpers */
+	cx88_card_setup(dev);
+#endif
+
+	/* everything worked */
+	pci_set_drvdata(dev->pci,dev);
+	return 0;
+}
+
+void cx8802_fini_common(struct cx8802_dev *dev)
+{
+	cx8802_stop_dma(dev);
+	pci_disable_device(dev->pci);
+
+	/* unregister stuff */
+	free_irq(dev->pci->irq, dev);
+	pci_set_drvdata(dev->pci, NULL);
+
+	/* free memory */
+	btcx_riscmem_free(dev->pci,&dev->mpegq.stopper);
+}
+
+/* ----------------------------------------------------------- */
+
+int cx8802_suspend_common(struct pci_dev *pci_dev, u32 state)
+{
+        struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
+	struct cx88_core *core = dev->core;
+
+	/* stop mpeg dma */
+	spin_lock(&dev->slock);
+	if (!list_empty(&dev->mpegq.active)) {
+		printk("%s: suspend mpeg\n", core->name);
+		cx8802_stop_dma(dev);
+		del_timer(&dev->mpegq.timeout);
+	}
+	spin_unlock(&dev->slock);
+
+#if 1
+	/* FIXME -- shutdown device */
+	cx88_shutdown(dev->core);
+#endif
+
+	pci_save_state(pci_dev);
+	if (0 != pci_set_power_state(pci_dev, state)) {
+		pci_disable_device(pci_dev);
+		dev->state.disabled = 1;
+	}
+	return 0;
+}
+
+int cx8802_resume_common(struct pci_dev *pci_dev)
+{
+        struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
+	struct cx88_core *core = dev->core;
+
+	if (dev->state.disabled) {
+		pci_enable_device(pci_dev);
+		dev->state.disabled = 0;
+	}
+	pci_set_power_state(pci_dev, 0);
+	pci_restore_state(pci_dev);
+
+#if 1
+	/* FIXME: re-initialize hardware */
+	cx88_reset(dev->core);
+#endif
+
+	/* restart video+vbi capture */
+	spin_lock(&dev->slock);
+	if (!list_empty(&dev->mpegq.active)) {
+		printk("%s: resume mpeg\n", core->name);
+		cx8802_restart_queue(dev,&dev->mpegq);
+	}
+	spin_unlock(&dev->slock);
+
+	return 0;
+}
+
+/* ----------------------------------------------------------- */
+
+EXPORT_SYMBOL(cx8802_buf_prepare);
+EXPORT_SYMBOL(cx8802_buf_queue);
+EXPORT_SYMBOL(cx8802_cancel_buffers);
+
+EXPORT_SYMBOL(cx8802_init_common);
+EXPORT_SYMBOL(cx8802_fini_common);
+
+EXPORT_SYMBOL(cx8802_suspend_common);
+EXPORT_SYMBOL(cx8802_resume_common);
+
+/* ----------------------------------------------------------- */
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -Nru a/drivers/media/video/cx88/cx88-reg.h b/drivers/media/video/cx88/cx88-reg.h
--- a/drivers/media/video/cx88/cx88-reg.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/media/video/cx88/cx88-reg.h	2004-12-24 13:36:48 -08:00
@@ -1,4 +1,6 @@
-/* 
+/*
+    $Id: cx88-reg.h,v 1.6 2004/10/13 10:39:00 kraxel Exp $
+
     cx88x-hw.h - CX2388x register offsets
 
     Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
@@ -502,12 +504,6 @@
 
 #define MO_GPHSTD_DMA       0x350000 // {64}RWp Host downstream
 #define MO_GPHSTU_DMA       0x350008 // {64}RWp Host upstream
-#define MO_GPHSTD_GPCNT     0x35C020 // Host down general purpose counter
-#define MO_GPHSTU_GPCNT     0x35C024 // Host up general purpose counter
-#define MO_GPHSTD_GPCNTRL   0x38C030 // Host down general purpose control
-#define MO_GPHSTU_GPCNTRL   0x38C034 // Host up general purpose control
-#define MO_GPHST_DMACNTRL   0x38C040 // Host DMA control
-#define MO_GPHST_XFR_STAT   0x38C044 // Host transfer status
 #define MO_GPHSTU_CNTRL     0x380048 // Host upstream control #1
 #define MO_GPHSTD_CNTRL     0x38004C // Host downstream control #2
 #define MO_GPHSTD_LNGTH     0x380050 // Host downstream line length
@@ -518,6 +514,14 @@
 #define MO_GPHST_MUX16      0x380064 // Host muxed 16-bit transfer parameters
 #define MO_GPHST_MODE       0x380068 // Host mode select
 
+#define MO_GPHSTD_GPCNT     0x35C020 // Host down general purpose counter
+#define MO_GPHSTU_GPCNT     0x35C024 // Host up general purpose counter
+#define MO_GPHSTD_GPCNTRL   0x38C030 // Host down general purpose control
+#define MO_GPHSTU_GPCNTRL   0x38C034 // Host up general purpose control
+#define MO_GPHST_DMACNTRL   0x38C040 // Host DMA control
+#define MO_GPHST_XFR_STAT   0x38C044 // Host transfer status
+#define MO_GPHST_SOFT_RST   0x38C06C // Host software reset
+
 
 /* ---------------------------------------------------------------------- */
 /* RISC instructions                                                      */
@@ -555,11 +559,11 @@
 /* ---------------------------------------------------------------------- */
 /* various constants                                                      */
 
-#define SEL_BTSC     0x01 
-#define SEL_EIAJ     0x02 
-#define SEL_A2       0x04 
+#define SEL_BTSC     0x01
+#define SEL_EIAJ     0x02
+#define SEL_A2       0x04
 #define SEL_SAP      0x08
-#define SEL_NICAM    0x10 
+#define SEL_NICAM    0x10
 #define SEL_FMRADIO  0x20
 
 // AUD_CTL
@@ -614,7 +618,7 @@
 #define EN_DMTRX_BYPASS         (1 << 11)
 #endif
 
-// Video 
+// Video
 #define VID_CAPTURE_CONTROL		0x310180
 
 #define CX23880_CAP_CTL_CAPTURE_VBI_ODD  (1<<3)
@@ -626,10 +630,10 @@
 #define VideoInputMux1		 0x1
 #define VideoInputMux2		 0x2
 #define VideoInputMux3		 0x3
-#define VideoInputTuner		 0x0 
-#define VideoInputComposite	 0x1 
+#define VideoInputTuner		 0x0
+#define VideoInputComposite	 0x1
 #define VideoInputSVideo	 0x2
-#define VideoInputOther		 0x3 
+#define VideoInputOther		 0x3
 
 #define Xtal0		 0x1
 #define Xtal1		 0x2
@@ -640,12 +644,12 @@
 #define VideoFormatNTSCJapan	 0x2
 #define VideoFormatNTSC443	 0x3
 #define VideoFormatPAL		 0x4
-#define VideoFormatPALB		 0x4 
-#define VideoFormatPALD		 0x4 
-#define VideoFormatPALG		 0x4 
-#define VideoFormatPALH		 0x4 
-#define VideoFormatPALI		 0x4 
-#define VideoFormatPALBDGHI	 0x4 
+#define VideoFormatPALB		 0x4
+#define VideoFormatPALD		 0x4
+#define VideoFormatPALG		 0x4
+#define VideoFormatPALH		 0x4
+#define VideoFormatPALI		 0x4
+#define VideoFormatPALBDGHI	 0x4
 #define VideoFormatPALM		 0x5
 #define VideoFormatPALN		 0x6
 #define VideoFormatPALNC	 0x7
@@ -657,12 +661,12 @@
 #define VideoFormatNTSCJapan27MHz	 0x12
 #define VideoFormatNTSC44327MHz		 0x13
 #define VideoFormatPAL27MHz		 0x14
-#define VideoFormatPALB27MHz		 0x14 
-#define VideoFormatPALD27MHz		 0x14 
-#define VideoFormatPALG27MHz		 0x14 
-#define VideoFormatPALH27MHz		 0x14 
-#define VideoFormatPALI27MHz		 0x14 
-#define VideoFormatPALBDGHI27MHz	 0x14 
+#define VideoFormatPALB27MHz		 0x14
+#define VideoFormatPALD27MHz		 0x14
+#define VideoFormatPALG27MHz		 0x14
+#define VideoFormatPALH27MHz		 0x14
+#define VideoFormatPALI27MHz		 0x14
+#define VideoFormatPALBDGHI27MHz	 0x14
 #define VideoFormatPALM27MHz		 0x15
 #define VideoFormatPALN27MHz		 0x16
 #define VideoFormatPALNC27MHz		 0x17
@@ -741,8 +745,8 @@
 #define CHANNEL_VIP_UP		 0xA
 #define CHANNEL_HOST_DN		 0xB
 #define CHANNEL_HOST_UP		 0xC
-#define CHANNEL_FIRST		 0x1 
-#define CHANNEL_LAST		 0xC 
+#define CHANNEL_FIRST		 0x1
+#define CHANNEL_LAST		 0xC
 
 #define GP_COUNT_CONTROL_NONE		 0x0
 #define GP_COUNT_CONTROL_INC		 0x1
@@ -769,15 +773,15 @@
 #define DEFAULT_SAT_U_NTSC			0x7F
 #define DEFAULT_SAT_V_NTSC			0x5A
 
-typedef enum                                                                          
-{                                                                                     
-	SOURCE_TUNER = 0,                                                             
-	SOURCE_COMPOSITE,                                                             
-	SOURCE_SVIDEO,                                                                
-	SOURCE_OTHER1,                                                                
-	SOURCE_OTHER2,                                                                
-	SOURCE_COMPVIASVIDEO,                                                         
-	SOURCE_CCIR656                                                                    
+typedef enum
+{
+	SOURCE_TUNER = 0,
+	SOURCE_COMPOSITE,
+	SOURCE_SVIDEO,
+	SOURCE_OTHER1,
+	SOURCE_OTHER2,
+	SOURCE_COMPVIASVIDEO,
+	SOURCE_CCIR656
 } VIDEOSOURCETYPE;
 
 #endif /* _CX88_REG_H_ */
diff -Nru a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
--- a/drivers/media/video/cx88/cx88-tvaudio.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/media/video/cx88/cx88-tvaudio.c	2004-12-24 13:36:48 -08:00
@@ -1,4 +1,6 @@
 /*
+    $Id: cx88-tvaudio.c,v 1.24 2004/10/25 11:51:00 kraxel Exp $
+
     cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
 
      (c) 2001 Michael Eskin, Tom Zakrajsek [Windows version]
@@ -16,9 +18,9 @@
 
     Some comes from the dscaler sources, one of the dscaler driver guy works
     for Conexant ...
-    
+
     -----------------------------------------------------------------------
-    
+
     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
@@ -49,15 +51,17 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
+#include <linux/delay.h>
+#include <linux/kthread.h>
 
 #include "cx88.h"
 
 static unsigned int audio_debug = 1;
-MODULE_PARM(audio_debug,"i");
+module_param(audio_debug,int,0644);
 MODULE_PARM_DESC(audio_debug,"enable debug messages [audio]");
 
 #define dprintk(fmt, arg...)	if (audio_debug) \
-	printk(KERN_DEBUG "%s: " fmt, dev->name , ## arg)
+	printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
 
 /* ----------------------------------------------------------- */
 
@@ -93,7 +97,7 @@
 	u32 val;
 };
 
-static void set_audio_registers(struct cx8800_dev *dev,
+static void set_audio_registers(struct cx88_core *core,
 				const struct rlist *l)
 {
 	int i;
@@ -115,7 +119,7 @@
 	}
 }
 
-static void set_audio_start(struct cx8800_dev *dev,
+static void set_audio_start(struct cx88_core *core,
 			    u32 mode, u32 ctl)
 {
 	// mute
@@ -133,7 +137,7 @@
 	cx_write(AUD_CTL,           ctl);
 }
 
-static void set_audio_finish(struct cx8800_dev *dev)
+static void set_audio_finish(struct cx88_core *core)
 {
 	u32 volume;
 
@@ -150,7 +154,7 @@
 
 /* ----------------------------------------------------------- */
 
-static void set_audio_standard_BTSC(struct cx8800_dev *dev, unsigned int sap)
+static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap)
 {
 	static const struct rlist btsc[] = {
 		/* from dscaler */
@@ -247,19 +251,19 @@
 	// dscaler: don't know why to set EN_FMRADIO_EN_RDS
 	if (sap) {
 		dprintk("%s SAP (status: unknown)\n",__FUNCTION__);
-		set_audio_start(dev, 0x0001,
+		set_audio_start(core, 0x0001,
 				EN_FMRADIO_EN_RDS | EN_BTSC_FORCE_SAP);
-		set_audio_registers(dev, btsc_sap);
+		set_audio_registers(core, btsc_sap);
 	} else {
 		dprintk("%s (status: known-good)\n",__FUNCTION__);
-		set_audio_start(dev, 0x0001,
+		set_audio_start(core, 0x0001,
 				EN_FMRADIO_EN_RDS | EN_BTSC_AUTO_STEREO);
-		set_audio_registers(dev, btsc);
+		set_audio_registers(core, btsc);
 	}
-	set_audio_finish(dev);
+	set_audio_finish(core);
 }
 
-static void set_audio_standard_NICAM(struct cx8800_dev *dev)
+static void set_audio_standard_NICAM(struct cx88_core *core)
 {
 	static const struct rlist nicam_common[] = {
 		/* from dscaler */
@@ -316,24 +320,25 @@
                 { /* end of list */ },
 	};
 
-        set_audio_start(dev, 0x0010,
+        set_audio_start(core, 0x0010,
 			EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO);
-        set_audio_registers(dev, nicam_common);
-	switch (dev->tvaudio) {
+        set_audio_registers(core, nicam_common);
+	switch (core->tvaudio) {
 	case WW_NICAM_I:
 		dprintk("%s PAL-I NICAM (status: unknown)\n",__FUNCTION__);
-		set_audio_registers(dev, nicam_pal_i);
+		set_audio_registers(core, nicam_pal_i);
+		break;
 	case WW_NICAM_BGDKL:
-		dprintk("%s PAL NICAM (status: unknown)\n",__FUNCTION__);
-		set_audio_registers(dev, nicam_default);
+		dprintk("%s PAL-BGDK NICAM (status: unknown)\n",__FUNCTION__);
+		set_audio_registers(core, nicam_default);
 		break;
 	};
-        set_audio_finish(dev);
+        set_audio_finish(core);
 }
 
-static void set_audio_standard_NICAM_L(struct cx8800_dev *dev)
+static void set_audio_standard_NICAM_L(struct cx88_core *core)
 {
-	/* This is officially wierd.. register dumps indicate windows
+	/* This is officially weird.. register dumps indicate windows
 	 * uses audio mode 4.. A2. Let's operate and find out. */
 
 	static const struct rlist nicam_l[] = {
@@ -449,13 +454,13 @@
 	};
 
 	dprintk("%s (status: unknown)\n",__FUNCTION__);
-        set_audio_start(dev, 0x0004,
+        set_audio_start(core, 0x0004,
 			0 /* FIXME */);
-	set_audio_registers(dev, nicam_l);
-        set_audio_finish(dev);
+	set_audio_registers(core, nicam_l);
+        set_audio_finish(core);
 }
 
-static void set_audio_standard_A2(struct cx8800_dev *dev)
+static void set_audio_standard_A2(struct cx88_core *core)
 {
 	/* from dscaler cvs */
 	static const struct rlist a2_common[] = {
@@ -545,26 +550,33 @@
 		{ /* end of list */ },
 	};
 
-	set_audio_start(dev, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_AUTO_STEREO);
-	set_audio_registers(dev, a2_common);
-	switch (dev->tvaudio) {
+	set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_AUTO_STEREO);
+	set_audio_registers(core, a2_common);
+	switch (core->tvaudio) {
+	case WW_NICAM_I:
+		/* gives at least mono according to the dscaler guys */
+		/* so use use that while nicam is broken ...         */
+		dprintk("%s PAL-I mono (status: unknown)\n",__FUNCTION__);
+		set_audio_registers(core, a2_table1);
+		cx_write(AUD_CTL, EN_A2_FORCE_MONO1);
+		break;
 	case WW_A2_BG:
 		dprintk("%s PAL-BG A2 (status: known-good)\n",__FUNCTION__);
-		set_audio_registers(dev, a2_table1);
+		set_audio_registers(core, a2_table1);
 		break;
 	case WW_A2_DK:
 		dprintk("%s PAL-DK A2 (status: known-good)\n",__FUNCTION__);
-		set_audio_registers(dev, a2_table2);
+		set_audio_registers(core, a2_table2);
 		break;
 	case WW_A2_M:
 		dprintk("%s NTSC-M A2 (status: unknown)\n",__FUNCTION__);
-		set_audio_registers(dev, a2_table3);
+		set_audio_registers(core, a2_table3);
 		break;
 	};
-	set_audio_finish(dev);
+	set_audio_finish(core);
 }
 
-static void set_audio_standard_EIAJ(struct cx8800_dev *dev)
+static void set_audio_standard_EIAJ(struct cx88_core *core)
 {
 	static const struct rlist eiaj[] = {
 		/* TODO: eiaj register settings are not there yet ... */
@@ -573,12 +585,12 @@
 	};
 	dprintk("%s (status: unknown)\n",__FUNCTION__);
 
-	set_audio_start(dev, 0x0002, EN_EIAJ_AUTO_STEREO);
-	set_audio_registers(dev, eiaj);
-	set_audio_finish(dev);
+	set_audio_start(core, 0x0002, EN_EIAJ_AUTO_STEREO);
+	set_audio_registers(core, eiaj);
+	set_audio_finish(core);
 }
 
-static void set_audio_standard_FM(struct cx8800_dev *dev)
+static void set_audio_standard_FM(struct cx88_core *core)
 {
 #if 0 /* FIXME */
 	switch (dev->audio_properties.FM_deemphasis)
@@ -596,7 +608,7 @@
 			cx_write(AUD_DEEMPH1_B0, 0x1C29);
 			cx_write(AUD_DEEMPH1_A1, 0x3FC66);
 			cx_write(AUD_DEEMPH1_B1, 0x399A);
-			
+
 			break;
 
 		case WW_FM_DEEMPH_75:
@@ -618,50 +630,51 @@
 #endif
 
 	dprintk("%s (status: unknown)\n",__FUNCTION__);
-	set_audio_start(dev, 0x0020, EN_FMRADIO_AUTO_STEREO);
+	set_audio_start(core, 0x0020, EN_FMRADIO_AUTO_STEREO);
 
 	// AB: 10/2/01: this register is not being reset appropriately on occasion.
 	cx_write(AUD_POLYPH80SCALEFAC,3);
 
-	set_audio_finish(dev);
+	set_audio_finish(core);
 }
 
 /* ----------------------------------------------------------- */
 
-void cx88_set_tvaudio(struct cx8800_dev *dev)
+void cx88_set_tvaudio(struct cx88_core *core)
 {
-	switch (dev->tvaudio) {
+	switch (core->tvaudio) {
 	case WW_BTSC:
-		set_audio_standard_BTSC(dev,0);
+		set_audio_standard_BTSC(core,0);
 		break;
-	case WW_NICAM_I:
+	// case WW_NICAM_I:
 	case WW_NICAM_BGDKL:
-		set_audio_standard_NICAM(dev);
+		set_audio_standard_NICAM(core);
 		break;
+	case WW_NICAM_I:
 	case WW_A2_BG:
 	case WW_A2_DK:
 	case WW_A2_M:
-		set_audio_standard_A2(dev);
+		set_audio_standard_A2(core);
 		break;
 	case WW_EIAJ:
-		set_audio_standard_EIAJ(dev);
+		set_audio_standard_EIAJ(core);
 		break;
 	case WW_FM:
-		set_audio_standard_FM(dev);
+		set_audio_standard_FM(core);
 		break;
 	case WW_SYSTEM_L_AM:
-		set_audio_standard_NICAM_L(dev);
+		set_audio_standard_NICAM_L(core);
 		break;
 	case WW_NONE:
 	default:
-		printk("%s: unknown tv audio mode [%d]\n",
-		       dev->name, dev->tvaudio);
+		printk("%s/0: unknown tv audio mode [%d]\n",
+		       core->name, core->tvaudio);
 		break;
 	}
 	return;
 }
 
-void cx88_get_stereo(struct cx8800_dev *dev, struct v4l2_tuner *t)
+void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
 {
 	static char *m[] = {"stereo", "dual mono", "mono", "sap"};
 	static char *p[] = {"no pilot", "pilot c1", "pilot c2", "?"};
@@ -670,16 +683,28 @@
 	reg   = cx_read(AUD_STATUS);
 	mode  = reg & 0x03;
 	pilot = (reg >> 2) & 0x03;
-	dprintk("AUD_STATUS: 0x%x [%s/%s] ctl=%s\n",
-		reg, m[mode], p[pilot],
-		aud_ctl_names[cx_read(AUD_CTL) & 63]);
+
+	if (core->astat != reg)
+		dprintk("AUD_STATUS: 0x%x [%s/%s] ctl=%s\n",
+			reg, m[mode], p[pilot],
+			aud_ctl_names[cx_read(AUD_CTL) & 63]);
+	core->astat = reg;
 
 	t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP |
 		V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
 	t->rxsubchans = V4L2_TUNER_SUB_MONO;
 	t->audmode    = V4L2_TUNER_MODE_MONO;
 
-	switch (dev->tvaudio) {
+	switch (core->tvaudio) {
+	case WW_BTSC:
+		t->capability = V4L2_TUNER_CAP_STEREO |
+			V4L2_TUNER_CAP_SAP;
+		t->rxsubchans = V4L2_TUNER_SUB_STEREO;
+ 		if (1 == pilot) {
+			/* SAP */
+			t->rxsubchans |= V4L2_TUNER_SUB_SAP;
+		}
+		break;
 	case WW_A2_BG:
 	case WW_A2_DK:
 	case WW_A2_M:
@@ -707,17 +732,33 @@
 	return;
 }
 
-void cx88_set_stereo(struct cx8800_dev *dev, u32 mode)
+void cx88_set_stereo(struct cx88_core *core, u32 mode)
 {
 	u32 ctl  = UNSET;
 	u32 mask = UNSET;
 
-	switch (dev->tvaudio) {
+	switch (core->tvaudio) {
+	case WW_BTSC:
+		switch (mode) {
+		case V4L2_TUNER_MODE_MONO:
+			ctl  = EN_BTSC_FORCE_MONO;
+			mask = 0x3f;
+			break;
+		case V4L2_TUNER_MODE_SAP:
+			ctl  = EN_BTSC_FORCE_SAP;
+			mask = 0x3f;
+			break;
+		case V4L2_TUNER_MODE_STEREO:
+			ctl  = EN_BTSC_AUTO_STEREO;
+			mask = 0x3f;
+			break;
+		}
+		break;
 	case WW_A2_BG:
 	case WW_A2_DK:
 	case WW_A2_M:
 		switch (mode) {
-		case V4L2_TUNER_MODE_MONO:   
+		case V4L2_TUNER_MODE_MONO:
 		case V4L2_TUNER_MODE_LANG1:
 			ctl  = EN_A2_FORCE_MONO1;
 			mask = 0x3f;
@@ -734,7 +775,7 @@
 		break;
 	case WW_NICAM_BGDKL:
 		switch (mode) {
-		case V4L2_TUNER_MODE_MONO:   
+		case V4L2_TUNER_MODE_MONO:
 			ctl  = EN_NICAM_FORCE_MONO1;
 			mask = 0x3f;
 			break;
@@ -747,10 +788,10 @@
 			mask = 0x93f;
 			break;
 		}
-		break;	
+		break;
 	case WW_FM:
 		switch (mode) {
-		case V4L2_TUNER_MODE_MONO:   
+		case V4L2_TUNER_MODE_MONO:
 			ctl  = EN_FMRADIO_FORCE_MONO;
 			mask = 0x3f;
 			break;
@@ -759,7 +800,7 @@
 			mask = 0x3f;
 			break;
 		}
-		break;	
+		break;
 	}
 
 	if (UNSET != ctl) {
@@ -774,31 +815,32 @@
 	return;
 }
 
-/* just monitor the audio status for now ... */
 int cx88_audio_thread(void *data)
 {
-	struct cx8800_dev *dev = data;
+	struct cx88_core *core = data;
 	struct v4l2_tuner t;
 
-	daemonize("msp3400");
-	allow_signal(SIGTERM);
 	dprintk("cx88: tvaudio thread started\n");
-
 	for (;;) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ*3);
-		if (signal_pending(current))
-			break;
-		if (dev->shutdown)
+		if (kthread_should_stop())
 			break;
 
+		/* just monitor the audio status for now ... */
 		memset(&t,0,sizeof(t));
-		cx88_get_stereo(dev,&t);
+		cx88_get_stereo(core,&t);
+		msleep_interruptible(1000);
 	}
 
 	dprintk("cx88: tvaudio thread exiting\n");
-        complete_and_exit(&dev->texit, 0);
+	return 0;
 }
+
+/* ----------------------------------------------------------- */
+
+EXPORT_SYMBOL(cx88_set_tvaudio);
+EXPORT_SYMBOL(cx88_set_stereo);
+EXPORT_SYMBOL(cx88_get_stereo);
+EXPORT_SYMBOL(cx88_audio_thread);
 
 /*
  * Local variables:
diff -Nru a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
--- a/drivers/media/video/cx88/cx88-vbi.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/media/video/cx88/cx88-vbi.c	2004-12-24 13:36:48 -08:00
@@ -1,3 +1,6 @@
+/*
+ * $Id: cx88-vbi.c,v 1.14 2004/11/07 13:17:15 kraxel Exp $
+ */
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -6,15 +9,15 @@
 #include "cx88.h"
 
 static unsigned int vbibufs = 4;
-MODULE_PARM(vbibufs,"i");
+module_param(vbibufs,int,0644);
 MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32");
 
 static unsigned int vbi_debug = 0;
-MODULE_PARM(vbi_debug,"i");
-MODULE_PARM_DESC(vbi_debug,"enable debug messages [video]");
+module_param(vbi_debug,int,0644);
+MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]");
 
 #define dprintk(level,fmt, arg...)	if (vbi_debug >= level) \
-	printk(KERN_DEBUG "%s: " fmt, dev->name , ## arg)
+	printk(KERN_DEBUG "%s: " fmt, dev->core->name , ## arg)
 
 /* ------------------------------------------------------------------ */
 
@@ -28,13 +31,13 @@
 	f->fmt.vbi.count[0] = VBI_LINE_COUNT;
 	f->fmt.vbi.count[1] = VBI_LINE_COUNT;
 
-	if (dev->tvnorm->id & V4L2_STD_525_60) {
+	if (dev->core->tvnorm->id & V4L2_STD_525_60) {
 		/* ntsc */
 		f->fmt.vbi.sampling_rate = 28636363;
 		f->fmt.vbi.start[0] = 10 -1;
 		f->fmt.vbi.start[1] = 273 -1;
 
-	} else if (V4L2_STD_625_50) {
+	} else if (dev->core->tvnorm->id & V4L2_STD_625_50) {
 		/* pal */
 		f->fmt.vbi.sampling_rate = 35468950;
 		f->fmt.vbi.start[0] = 7 -1;
@@ -46,8 +49,10 @@
 			 struct cx88_dmaqueue *q,
 			 struct cx88_buffer   *buf)
 {
+	struct cx88_core *core = dev->core;
+
 	/* setup fifo + format */
-	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH24],
+	cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24],
 				buf->vb.width, buf->risc.dma);
 
 	cx_write(MO_VBOS_CONTROL, ( (1 << 18) |  // comb filter delay fixup
@@ -55,7 +60,7 @@
 				    (1 << 11) ));
 
 	/* reset counter */
-	cx_write(MO_VBI_GPCNTRL,0x3);
+	cx_write(MO_VBI_GPCNTRL, GP_COUNT_CONTROL_RESET);
 	q->count = 1;
 
 	/* enable irqs */
@@ -72,6 +77,22 @@
 	return 0;
 }
 
+int cx8800_stop_vbi_dma(struct cx8800_dev *dev)
+{
+	struct cx88_core *core = dev->core;
+
+	/* stop dma */
+	cx_clear(MO_VID_DMACNTRL, 0x88);
+
+	/* disable capture */
+	cx_clear(VID_CAPTURE_CONTROL,0x18);
+
+	/* disable irqs */
+	cx_clear(MO_PCI_INTMSK, 0x000001);
+	cx_clear(MO_VID_INTMSK, 0x0f0088);
+	return 0;
+}
+
 int cx8800_restart_vbi_queue(struct cx8800_dev    *dev,
 			     struct cx88_dmaqueue *q)
 {
@@ -96,11 +117,12 @@
 void cx8800_vbi_timeout(unsigned long data)
 {
 	struct cx8800_dev *dev = (struct cx8800_dev*)data;
+	struct cx88_core *core = dev->core;
 	struct cx88_dmaqueue *q = &dev->vbiq;
 	struct cx88_buffer *buf;
 	unsigned long flags;
 
-	cx88_sram_channel_dump(dev, &cx88_sram_channels[SRAM_CH24]);
+	cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH24]);
 
 	cx_clear(MO_VID_DMACNTRL, 0x88);
 	cx_clear(VID_CAPTURE_CONTROL, 0x18);
@@ -111,7 +133,7 @@
 		list_del(&buf->vb.queue);
 		buf->vb.state = STATE_ERROR;
 		wake_up(&buf->vb.done);
-		printk("%s: [%p/%d] timeout - dma=0x%08lx\n", dev->name,
+		printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", dev->core->name,
 		       buf, buf->vb.i, (unsigned long)buf->risc.dma);
 	}
 	cx8800_restart_vbi_queue(dev,q);
@@ -121,7 +143,7 @@
 /* ------------------------------------------------------------------ */
 
 static int
-vbi_setup(struct file *file, unsigned int *count, unsigned int *size)
+vbi_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
 {
 	*size = VBI_LINE_COUNT * VBI_LINE_LENGTH * 2;
 	if (0 == *count)
@@ -134,12 +156,12 @@
 }
 
 static int
-vbi_prepare(struct file *file, struct videobuf_buffer *vb,
+vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
 	    enum v4l2_field field)
 {
-	struct cx8800_fh   *fh  = file->private_data;
+	struct cx8800_fh   *fh  = q->priv_data;
 	struct cx8800_dev  *dev = fh->dev;
-	struct cx88_buffer *buf = (struct cx88_buffer*)vb;
+	struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
 	unsigned int size;
 	int rc;
 
@@ -170,16 +192,16 @@
 }
 
 static void
-vbi_queue(struct file *file, struct videobuf_buffer *vb)
+vbi_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
 {
-	struct cx88_buffer    *buf  = (struct cx88_buffer*)vb;
+	struct cx88_buffer    *buf = container_of(vb,struct cx88_buffer,vb);
 	struct cx88_buffer    *prev;
-	struct cx8800_fh      *fh   = file->private_data;
+	struct cx8800_fh      *fh   = vq->priv_data;
 	struct cx8800_dev     *dev  = fh->dev;
 	struct cx88_dmaqueue  *q    = &dev->vbiq;
 
 	/* add jump to stopper */
-	buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | 0x10000);
+	buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
 	buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
 
 	if (list_empty(&q->active)) {
@@ -202,10 +224,10 @@
 	}
 }
 
-static void vbi_release(struct file *file, struct videobuf_buffer *vb)
+static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct cx88_buffer *buf = (struct cx88_buffer*)vb;
-	struct cx8800_fh   *fh  = file->private_data;
+	struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
+	struct cx8800_fh   *fh  = q->priv_data;
 
 	cx88_free_buffer(fh->dev->pci,buf);
 }
diff -Nru a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
--- a/drivers/media/video/cx88/cx88-video.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/media/video/cx88/cx88-video.c	2004-12-24 13:36:56 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: cx88-video.c,v 1.46 2004/11/07 14:44:59 kraxel Exp $
+ *
  * device driver for Conexant 2388x based TV cards
  * video4linux video interface
  *
@@ -26,12 +28,12 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/kthread.h>
 #include <asm/div64.h>
 
 #include "cx88.h"
 
-#define V4L2_I2C_CLIENTS 1
-
 MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
 MODULE_LICENSE("GPL");
@@ -39,108 +41,40 @@
 /* ------------------------------------------------------------------ */
 
 static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(video_nr,"1-" __stringify(CX88_MAXBOARDS) "i");
-MODULE_PARM_DESC(video_nr,"video device numbers");
+static unsigned int vbi_nr[]   = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
+static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
 
-static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(vbi_nr,"1-" __stringify(CX88_MAXBOARDS) "i");
-MODULE_PARM_DESC(vbi_nr,"vbi device numbers");
+module_param_array(video_nr, int, NULL, 0444);
+module_param_array(vbi_nr,   int, NULL, 0444);
+module_param_array(radio_nr, int, NULL, 0444);
 
-static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(radio_nr,"1-" __stringify(CX88_MAXBOARDS) "i");
+MODULE_PARM_DESC(video_nr,"video device numbers");
+MODULE_PARM_DESC(vbi_nr,"vbi device numbers");
 MODULE_PARM_DESC(radio_nr,"radio device numbers");
 
-static unsigned int latency = UNSET;
-MODULE_PARM(latency,"i");
-MODULE_PARM_DESC(latency,"pci latency timer");
-
 static unsigned int video_debug = 0;
-MODULE_PARM(video_debug,"i");
+module_param(video_debug,int,0644);
 MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
 
 static unsigned int irq_debug = 0;
-MODULE_PARM(irq_debug,"i");
+module_param(irq_debug,int,0644);
 MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]");
 
 static unsigned int vid_limit = 16;
-MODULE_PARM(vid_limit,"i");
+module_param(vid_limit,int,0644);
 MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
 
-static unsigned int tuner[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(tuner,"1-" __stringify(CX88_MAXBOARDS) "i");
-MODULE_PARM_DESC(tuner,"tuner type");
-
-static unsigned int card[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(card,"1-" __stringify(CX88_MAXBOARDS) "i");
-MODULE_PARM_DESC(card,"card type");
-
-static unsigned int nicam = 0;
-MODULE_PARM(nicam,"i");
-MODULE_PARM_DESC(nicam,"tv audio is nicam");
-
 #define dprintk(level,fmt, arg...)	if (video_debug >= level) \
-	printk(KERN_DEBUG "%s: " fmt, dev->name , ## arg)
+	printk(KERN_DEBUG "%s/0: " fmt, dev->core->name , ## arg)
 
 /* ------------------------------------------------------------------ */
 
-static struct list_head  cx8800_devlist;
-static unsigned int      cx8800_devcount;
+static LIST_HEAD(cx8800_devlist);
 
 /* ------------------------------------------------------------------- */
 /* static data                                                         */
 
-static unsigned int inline norm_swidth(struct cx8800_tvnorm *norm)
-{
-	return (norm->id & V4L2_STD_625_50) ? 922 : 754;
-}
-
-static unsigned int inline norm_hdelay(struct cx8800_tvnorm *norm)
-{
-	return (norm->id & V4L2_STD_625_50) ? 186 : 135;
-}
-
-static unsigned int inline norm_vdelay(struct cx8800_tvnorm *norm)
-{
-	return (norm->id & V4L2_STD_625_50) ? 0x24 : 0x18;
-}
-
-static unsigned int inline norm_maxw(struct cx8800_tvnorm *norm)
-{
-	return (norm->id & V4L2_STD_625_50) ? 768 : 640;
-//	return (norm->id & V4L2_STD_625_50) ? 720 : 640;
-}
-
-static unsigned int inline norm_maxh(struct cx8800_tvnorm *norm)
-{
-	return (norm->id & V4L2_STD_625_50) ? 576 : 480;
-}
-
-static unsigned int inline norm_fsc8(struct cx8800_tvnorm *norm)
-{
-	static const unsigned int ntsc = 28636360;
-	static const unsigned int pal  = 35468950;
-	
-	return (norm->id & V4L2_STD_625_50) ? pal : ntsc;
-}
-
-static unsigned int inline norm_notchfilter(struct cx8800_tvnorm *norm)
-{
-	return (norm->id & V4L2_STD_625_50)
-		? HLNotchFilter135PAL
-		: HLNotchFilter135NTSC;
-}
-
-static unsigned int inline norm_htotal(struct cx8800_tvnorm *norm)
-{
-	return (norm->id & V4L2_STD_625_50) ? 1135 : 910;
-}
-
-static unsigned int inline norm_vbipack(struct cx8800_tvnorm *norm)
-{
-	return (norm->id & V4L2_STD_625_50) ? 511 : 288;
-}
-
-static struct cx8800_tvnorm tvnorms[] = {
+static struct cx88_tvnorm tvnorms[] = {
 	{
 		.name      = "NTSC-M",
 		.id        = V4L2_STD_NTSC_M,
@@ -273,7 +207,7 @@
 static struct cx8800_fmt* format_by_fourcc(unsigned int fourcc)
 {
 	unsigned int i;
-	
+
 	for (i = 0; i < ARRAY_SIZE(formats); i++)
 		if (formats[i].fourcc == fourcc)
 			return formats+i;
@@ -443,264 +377,33 @@
 
 /* ------------------------------------------------------------------ */
 
-static const u32 xtal = 28636363;
-
-static int set_pll(struct cx8800_dev *dev, int prescale, u32 ofreq)
-{
-	static u32 pre[] = { 0, 0, 0, 3, 2, 1 };
-	u64 pll;
-	u32 reg;
-	int i;
-
-	if (prescale < 2)
-		prescale = 2;
-	if (prescale > 5)
-		prescale = 5;
-
-	pll = ofreq * 8 * prescale * (u64)(1 << 20);
-	do_div(pll,xtal);
-	reg = (pll & 0x3ffffff) | (pre[prescale] << 26);
-	if (((reg >> 20) & 0x3f) < 14) {
-		printk("%s: pll out of range\n",dev->name);
-		return -1;
-	}
-		
-	dprintk(1,"set_pll:    MO_PLL_REG       0x%08x [old=0x%08x,freq=%d]\n",
-		reg, cx_read(MO_PLL_REG), ofreq);
-	cx_write(MO_PLL_REG, reg);
-	for (i = 0; i < 10; i++) {
-		reg = cx_read(MO_DEVICE_STATUS);
-		if (reg & (1<<2)) {
-			dprintk(1,"pll locked [pre=%d,ofreq=%d]\n",
-				prescale,ofreq);
-			return 0;
-		}
-		dprintk(1,"pll not locked yet, waiting ...\n");
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/10);
-	}
-	dprintk(1,"pll NOT locked [pre=%d,ofreq=%d]\n",prescale,ofreq);
-	return -1;
-}
-
-static int set_tvaudio(struct cx8800_dev *dev)
-{
-	if (CX88_VMUX_TELEVISION != INPUT(dev->input)->type)
-		return 0;
-
-	if (V4L2_STD_PAL_BG & dev->tvnorm->id) {
-		dev->tvaudio = nicam ? WW_NICAM_BGDKL : WW_A2_BG;
-
-	} else if (V4L2_STD_PAL_DK & dev->tvnorm->id) {
-		dev->tvaudio = nicam ? WW_NICAM_BGDKL : WW_A2_DK;
-
-	} else if (V4L2_STD_PAL_I & dev->tvnorm->id) {
-		dev->tvaudio = WW_NICAM_I;
-
-	} else if (V4L2_STD_SECAM_L & dev->tvnorm->id) {
-		dev->tvaudio = WW_SYSTEM_L_AM;
-
-	} else if (V4L2_STD_SECAM_DK & dev->tvnorm->id) {
-		dev->tvaudio = WW_A2_DK;
-
-	} else if ((V4L2_STD_NTSC_M & dev->tvnorm->id) ||
-		   (V4L2_STD_PAL_M  & dev->tvnorm->id)) {
-		dev->tvaudio = WW_BTSC;
-
-	} else if (V4L2_STD_NTSC_M_JP & dev->tvnorm->id) {
-		dev->tvaudio = WW_EIAJ;
-
-	} else {
-		printk("%s: tvaudio support needs work for this tv norm [%s], sorry\n",
-		       dev->name, dev->tvnorm->name);
-		dev->tvaudio = 0;
-		return 0;
-	}
-
-	cx_andor(MO_AFECFG_IO, 0x1f, 0x0);
-	cx88_set_tvaudio(dev);
-	// cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO);
-
-	cx_write(MO_AUDD_LNGTH, 128/8);  /* fifo size */
-	cx_write(MO_AUDR_LNGTH, 128/8);  /* fifo size */
-	cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */
-	return 0;
-}
-
-static int set_tvnorm(struct cx8800_dev *dev, struct cx8800_tvnorm *norm)
-{
-	u32 fsc8;
-	u32 adc_clock;
-	u32 vdec_clock;
-	u64 tmp64;
-	u32 bdelay,agcdelay,htotal;
-	
-	dev->tvnorm = norm;
-	fsc8       = norm_fsc8(norm);
-	adc_clock  = xtal;
-	vdec_clock = fsc8;
-
-	dprintk(1,"set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d\n",
-		norm->name, fsc8, adc_clock, vdec_clock);
-	set_pll(dev,2,vdec_clock);
-	
-	dprintk(1,"set_tvnorm: MO_INPUT_FORMAT  0x%08x [old=0x%08x]\n",
-		norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
-	cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat);
-
-#if 1
-	// FIXME: as-is from DScaler
-	dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
-		norm->cxoformat, cx_read(MO_OUTPUT_FORMAT));
-	cx_write(MO_OUTPUT_FORMAT, norm->cxoformat);
-#endif
-
-	// MO_SCONV_REG = adc clock / video dec clock * 2^17
-	tmp64  = adc_clock * (u64)(1 << 17);
-	do_div(tmp64, vdec_clock);
-	dprintk(1,"set_tvnorm: MO_SCONV_REG     0x%08x [old=0x%08x]\n",
-		(u32)tmp64, cx_read(MO_SCONV_REG));
-	cx_write(MO_SCONV_REG, (u32)tmp64);
-
-	// MO_SUB_STEP = 8 * fsc / video dec clock * 2^22
-	tmp64  = fsc8 * (u64)(1 << 22);
-	do_div(tmp64, vdec_clock);
-	dprintk(1,"set_tvnorm: MO_SUB_STEP      0x%08x [old=0x%08x]\n",
-		(u32)tmp64, cx_read(MO_SUB_STEP));
-	cx_write(MO_SUB_STEP, (u32)tmp64);
-
-	// MO_SUB_STEP_DR = 8 * 4406250 / video dec clock * 2^22
-	tmp64  = 4406250 * 8 * (u64)(1 << 22);
-	do_div(tmp64, vdec_clock);
-	dprintk(1,"set_tvnorm: MO_SUB_STEP_DR   0x%08x [old=0x%08x]\n",
-		(u32)tmp64, cx_read(MO_SUB_STEP_DR));
-	cx_write(MO_SUB_STEP_DR, (u32)tmp64);
-
-	// bdelay + agcdelay
-	bdelay   = vdec_clock * 65 / 20000000 + 21;
-	agcdelay = vdec_clock * 68 / 20000000 + 15;
-	dprintk(1,"set_tvnorm: MO_AGC_BURST     0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n",
-		(bdelay << 8) | agcdelay, cx_read(MO_AGC_BURST), bdelay, agcdelay);
-	cx_write(MO_AGC_BURST, (bdelay << 8) | agcdelay);
-
-	// htotal
-	tmp64 = norm_htotal(norm) * (u64)vdec_clock;
-	do_div(tmp64, fsc8);
-	htotal = (u32)tmp64 | (norm_notchfilter(norm) << 11);
-	dprintk(1,"set_tvnorm: MO_HTOTAL        0x%08x [old=0x%08x,htotal=%d]\n",
-		htotal, cx_read(MO_HTOTAL), (u32)tmp64);
-	cx_write(MO_HTOTAL, htotal);
-
-	// vbi stuff
-	cx_write(MO_VBI_PACKET, ((1 << 11) | /* (norm_vdelay(norm)   << 11) | */
-				 norm_vbipack(norm)));
-	
-	// audio
-	set_tvaudio(dev);
-
-	// tell i2c chips
-#ifdef V4L2_I2C_CLIENTS
-	cx8800_call_i2c_clients(dev,VIDIOC_S_STD,&norm->id);
-#else
-	{
-		struct video_channel c;
-		memset(&c,0,sizeof(c));
-		c.channel = dev->input;
-		c.norm = VIDEO_MODE_PAL;
-		if ((norm->id & (V4L2_STD_NTSC_M|V4L2_STD_NTSC_M_JP)))
-			c.norm = VIDEO_MODE_NTSC;
-		if (norm->id & V4L2_STD_SECAM)
-			c.norm = VIDEO_MODE_SECAM;
-		cx8800_call_i2c_clients(dev,VIDIOCSCHAN,&c);
-	}
-#endif
-
-	// done
-	return 0;
-}
-
-static int set_scale(struct cx8800_dev *dev, unsigned int width, unsigned int height,
-		     enum v4l2_field field)
-{
-	unsigned int swidth  = norm_swidth(dev->tvnorm);
-	unsigned int sheight = norm_maxh(dev->tvnorm);
-	u32 value;
-
-	dprintk(1,"set_scale: %dx%d [%s%s,%s]\n", width, height,
-		V4L2_FIELD_HAS_TOP(field)    ? "T" : "",
-		V4L2_FIELD_HAS_BOTTOM(field) ? "B" : "",
-		dev->tvnorm->name);
-	if (!V4L2_FIELD_HAS_BOTH(field))
-		height *= 2;
-
-	// recalc H delay and scale registers
-	value = (width * norm_hdelay(dev->tvnorm)) / swidth;
-	value &= 0x3fe;
-	cx_write(MO_HDELAY_EVEN,  value);
-	cx_write(MO_HDELAY_ODD,   value);
-	dprintk(1,"set_scale: hdelay  0x%04x\n", value);
-	
-	value = (swidth * 4096 / width) - 4096;
-	cx_write(MO_HSCALE_EVEN,  value);
-	cx_write(MO_HSCALE_ODD,   value);
-	dprintk(1,"set_scale: hscale  0x%04x\n", value);
-
-	cx_write(MO_HACTIVE_EVEN, width);
-	cx_write(MO_HACTIVE_ODD,  width);
-	dprintk(1,"set_scale: hactive 0x%04x\n", width);
-	
-	// recalc V scale Register (delay is constant)
-	cx_write(MO_VDELAY_EVEN, norm_vdelay(dev->tvnorm));
-	cx_write(MO_VDELAY_ODD,  norm_vdelay(dev->tvnorm));
-	dprintk(1,"set_scale: vdelay  0x%04x\n", norm_vdelay(dev->tvnorm));
-	
-	value = (0x10000 - (sheight * 512 / height - 512)) & 0x1fff;
-	cx_write(MO_VSCALE_EVEN,  value);
-	cx_write(MO_VSCALE_ODD,   value);
-	dprintk(1,"set_scale: vscale  0x%04x\n", value);
-
-	cx_write(MO_VACTIVE_EVEN, sheight);
-	cx_write(MO_VACTIVE_ODD,  sheight);
-	dprintk(1,"set_scale: vactive 0x%04x\n", sheight);
-
-	// setup filters
-	value = 0;
-	value |= (1 << 19);        // CFILT (default)
-	if (V4L2_FIELD_INTERLACED == field)
-		value |= (1 << 3); // VINT (interlaced vertical scaling)
-	if (width < 385)
-		value |= (1 << 0); // 3-tap interpolation
-	if (width < 193)
-		value |= (1 << 1); // 5-tap interpolation
-
-	cx_write(MO_FILTER_EVEN,  value);
-	cx_write(MO_FILTER_ODD,   value);
-	dprintk(1,"set_scale: filter  0x%04x\n", value);
-	
-	return 0;
-}
-
 static int video_mux(struct cx8800_dev *dev, unsigned int input)
 {
+	struct cx88_core *core = dev->core;
+
 	dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
 		input, INPUT(input)->vmux,
 		INPUT(input)->gpio0,INPUT(input)->gpio1,
 		INPUT(input)->gpio2,INPUT(input)->gpio3);
-	dev->input = input;
+	dev->core->input = input;
 	cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input)->vmux << 14);
+	cx_write(MO_GP3_IO, INPUT(input)->gpio3);
 	cx_write(MO_GP0_IO, INPUT(input)->gpio0);
 	cx_write(MO_GP1_IO, INPUT(input)->gpio1);
 	cx_write(MO_GP2_IO, INPUT(input)->gpio2);
-	cx_write(MO_GP3_IO, INPUT(input)->gpio3);
 
 	switch (INPUT(input)->type) {
 	case CX88_VMUX_SVIDEO:
 		cx_set(MO_AFECFG_IO,    0x00000001);
 		cx_set(MO_INPUT_FORMAT, 0x00010010);
+		cx_set(MO_FILTER_EVEN,  0x00002020);
+		cx_set(MO_FILTER_ODD,   0x00002020);
 		break;
 	default:
 		cx_clear(MO_AFECFG_IO,    0x00000001);
 		cx_clear(MO_INPUT_FORMAT, 0x00010010);
+		cx_clear(MO_FILTER_EVEN,  0x00002020);
+		cx_clear(MO_FILTER_ODD,   0x00002020);
 		break;
 	}
 	return 0;
@@ -712,23 +415,25 @@
 			   struct cx88_dmaqueue *q,
 			   struct cx88_buffer   *buf)
 {
+	struct cx88_core *core = dev->core;
+
 	/* setup fifo + format */
-	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH21],
+	cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH21],
 				buf->bpl, buf->risc.dma);
-	set_scale(dev, buf->vb.width, buf->vb.height, buf->vb.field);
+	cx88_set_scale(dev->core, buf->vb.width, buf->vb.height, buf->vb.field);
 	cx_write(MO_COLOR_CTRL, buf->fmt->cxformat | ColorFormatGamma);
 
 	/* reset counter */
-	cx_write(MO_VIDY_GPCNTRL,0x3);
+	cx_write(MO_VIDY_GPCNTRL,GP_COUNT_CONTROL_RESET);
 	q->count = 1;
 
 	/* enable irqs */
 	cx_set(MO_PCI_INTMSK, 0x00fc01);
 	cx_set(MO_VID_INTMSK, 0x0f0011);
-	
+
 	/* enable capture */
 	cx_set(VID_CAPTURE_CONTROL,0x06);
-	
+
 	/* start dma */
 	cx_set(MO_DEV_CNTRL2, (1<<5));
 	cx_set(MO_VID_DMACNTRL, 0x11);
@@ -736,12 +441,28 @@
 	return 0;
 }
 
+static int stop_video_dma(struct cx8800_dev    *dev)
+{
+	struct cx88_core *core = dev->core;
+
+	/* stop dma */
+	cx_clear(MO_VID_DMACNTRL, 0x11);
+
+	/* disable capture */
+	cx_clear(VID_CAPTURE_CONTROL,0x06);
+
+	/* disable irqs */
+	cx_clear(MO_PCI_INTMSK, 0x000001);
+	cx_clear(MO_VID_INTMSK, 0x0f0011);
+	return 0;
+}
+
 static int restart_video_queue(struct cx8800_dev    *dev,
 			       struct cx88_dmaqueue *q)
 {
 	struct cx88_buffer *buf, *prev;
 	struct list_head *item;
-	
+
 	if (!list_empty(&q->active)) {
 	        buf = list_entry(q->active.next, struct cx88_buffer, vb.queue);
 		dprintk(2,"restart_queue [%p/%d]: restart dma\n",
@@ -790,10 +511,10 @@
 /* ------------------------------------------------------------------ */
 
 static int
-buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
+buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
 {
-	struct cx8800_fh *fh = file->private_data;
-	
+	struct cx8800_fh *fh = q->priv_data;
+
 	*size = fh->fmt->depth*fh->width*fh->height >> 3;
 	if (0 == *count)
 		*count = 32;
@@ -803,17 +524,17 @@
 }
 
 static int
-buffer_prepare(struct file *file, struct videobuf_buffer *vb,
+buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
 	       enum v4l2_field field)
 {
-	struct cx8800_fh   *fh  = file->private_data;
+	struct cx8800_fh   *fh  = q->priv_data;
 	struct cx8800_dev  *dev = fh->dev;
-	struct cx88_buffer *buf = (struct cx88_buffer*)vb;
+	struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
 	int rc, init_buffer = 0;
 
 	BUG_ON(NULL == fh->fmt);
-	if (fh->width  < 48 || fh->width  > norm_maxw(dev->tvnorm) ||
-	    fh->height < 32 || fh->height > norm_maxh(dev->tvnorm))
+	if (fh->width  < 48 || fh->width  > norm_maxw(dev->core->tvnorm) ||
+	    fh->height < 32 || fh->height > norm_maxh(dev->core->tvnorm))
 		return -EINVAL;
 	buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3;
 	if (0 != buf->vb.baddr  &&  buf->vb.bsize < buf->vb.size)
@@ -887,16 +608,16 @@
 }
 
 static void
-buffer_queue(struct file *file, struct videobuf_buffer *vb)
+buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
 {
-	struct cx88_buffer    *buf  = (struct cx88_buffer*)vb;
+	struct cx88_buffer    *buf = container_of(vb,struct cx88_buffer,vb);
 	struct cx88_buffer    *prev;
-	struct cx8800_fh      *fh   = file->private_data;
+	struct cx8800_fh      *fh   = vq->priv_data;
 	struct cx8800_dev     *dev  = fh->dev;
 	struct cx88_dmaqueue  *q    = &dev->vidq;
 
 	/* add jump to stopper */
-	buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | 0x10000);
+	buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
 	buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
 
 	if (!list_empty(&q->queued)) {
@@ -935,10 +656,10 @@
 	}
 }
 
-static void buffer_release(struct file *file, struct videobuf_buffer *vb)
+static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct cx88_buffer *buf = (struct cx88_buffer*)vb;
-	struct cx8800_fh   *fh  = file->private_data;
+	struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
+	struct cx8800_fh   *fh  = q->priv_data;
 
 	cx88_free_buffer(fh->dev->pci,buf);
 }
@@ -998,7 +719,7 @@
 				ra = addr + (fh->fmt->depth>>3)*start;
 			else
 				ra = 0;
-				
+
 			if (0 == start)
 				ri |= RISC_SOL;
 			if (fh->win.w.width == end)
@@ -1021,11 +742,11 @@
 	u32 instructions,fields;
 	u32 *rp;
 	int rc;
-	
+
 	/* skip list for window clipping */
 	if (NULL == (skips = kmalloc(sizeof(*skips) * fh->nclips,GFP_KERNEL)))
 		return -ENOMEM;
-	
+
 	fields = 0;
 	if (V4L2_FIELD_HAS_TOP(fh->win.field))
 		fields++;
@@ -1077,8 +798,8 @@
 		return -EINVAL;
 
 	field = win->field;
-	maxw  = norm_maxw(dev->tvnorm);
-	maxh  = norm_maxh(dev->tvnorm);
+	maxw  = norm_maxw(core->tvnorm);
+	maxh  = norm_maxh(core->tvnorm);
 
 	if (V4L2_FIELD_ANY == field) {
                 field = (win->w.height > maxh/2)
@@ -1151,7 +872,7 @@
 	default:
 		BUG();
 	}
-	
+
 	down(&fh->vidq.lock);
 	if (fh->clips)
 		kfree(fh->clips);
@@ -1161,13 +882,13 @@
 #if 0
 	fh->ov.setup_ok = 1;
 #endif
-	
+
 	/* update overlay if needed */
 	retval = 0;
 #if 0
 	if (check_btres(fh, RESOURCE_OVERLAY)) {
 		struct bttv_buffer *new;
-		
+
 		new = videobuf_alloc(sizeof(*new));
 		bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
 		retval = bttv_switch_overlay(btv,fh,new);
@@ -1214,7 +935,7 @@
 	struct list_head *list;
 	enum v4l2_buf_type type = 0;
 	int radio = 0;
-	
+
 	list_for_each(list,&cx8800_devlist) {
 		h = list_entry(list, struct cx8800_dev, devlist);
 		if (h->video_dev->minor == minor) {
@@ -1254,25 +975,27 @@
 			    dev->pci, &dev->slock,
 			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
 			    V4L2_FIELD_INTERLACED,
-			    sizeof(struct cx88_buffer));
+			    sizeof(struct cx88_buffer),
+			    fh);
 	videobuf_queue_init(&fh->vbiq, &cx8800_vbi_qops,
 			    dev->pci, &dev->slock,
 			    V4L2_BUF_TYPE_VBI_CAPTURE,
 			    V4L2_FIELD_SEQ_TB,
-			    sizeof(struct cx88_buffer));
-	init_MUTEX(&fh->vidq.lock);
-	init_MUTEX(&fh->vbiq.lock);
+			    sizeof(struct cx88_buffer),
+			    fh);
 
 	if (fh->radio) {
+		struct cx88_core *core = dev->core;
+		int board = core->board;
 		dprintk(1,"video_open: setting radio device\n");
-		cx_write(MO_GP0_IO, cx88_boards[dev->board].radio.gpio0);
-		cx_write(MO_GP1_IO, cx88_boards[dev->board].radio.gpio1);
-		cx_write(MO_GP2_IO, cx88_boards[dev->board].radio.gpio2);
-		cx_write(MO_GP3_IO, cx88_boards[dev->board].radio.gpio3);
-		dev->tvaudio = WW_FM;
-		cx88_set_tvaudio(dev);
-		cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO);
-		cx8800_call_i2c_clients(dev,AUDC_SET_RADIO,NULL);
+		cx_write(MO_GP0_IO, cx88_boards[board].radio.gpio0);
+		cx_write(MO_GP1_IO, cx88_boards[board].radio.gpio1);
+		cx_write(MO_GP2_IO, cx88_boards[board].radio.gpio2);
+		cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3);
+		dev->core->tvaudio = WW_FM;
+		cx88_set_tvaudio(core);
+		cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO);
+		cx88_call_i2c_clients(dev->core,AUDC_SET_RADIO,NULL);
 	}
 
         return 0;
@@ -1287,11 +1010,13 @@
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		if (res_locked(fh->dev,RESOURCE_VIDEO))
 			return -EBUSY;
-		return videobuf_read_one(file, &fh->vidq, data, count, ppos);
+		return videobuf_read_one(&fh->vidq, data, count, ppos,
+					 file->f_flags & O_NONBLOCK);
 	case V4L2_BUF_TYPE_VBI_CAPTURE:
 		if (!res_get(fh->dev,fh,RESOURCE_VBI))
 			return -EBUSY;
-		return videobuf_read_stream(file, &fh->vbiq, data, count, ppos, 1);
+		return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1,
+					    file->f_flags & O_NONBLOCK);
 	default:
 		BUG();
 		return 0;
@@ -1302,12 +1027,30 @@
 video_poll(struct file *file, struct poll_table_struct *wait)
 {
 	struct cx8800_fh *fh = file->private_data;
+	struct cx88_buffer *buf;
 
-	if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type)
+	if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) {
+		if (!res_get(fh->dev,fh,RESOURCE_VBI))
+			return POLLERR;
 		return videobuf_poll_stream(file, &fh->vbiq, wait);
+	}
 
-	/* FIXME */
-	return POLLERR;
+	if (res_check(fh,RESOURCE_VIDEO)) {
+		/* streaming capture */
+		if (list_empty(&fh->vidq.stream))
+			return POLLERR;
+		buf = list_entry(fh->vidq.stream.next,struct cx88_buffer,vb.stream);
+	} else {
+		/* read() capture */
+		buf = (struct cx88_buffer*)fh->vidq.read_buf;
+		if (NULL == buf)
+			return POLLERR;
+	}
+	poll_wait(file, &buf->vb.done, wait);
+	if (buf->vb.state == STATE_DONE ||
+	    buf->vb.state == STATE_ERROR)
+		return POLLIN|POLLRDNORM;
+	return 0;
 }
 
 static int video_release(struct inode *inode, struct file *file)
@@ -1323,20 +1066,20 @@
 
 	/* stop video capture */
 	if (res_check(fh, RESOURCE_VIDEO)) {
-		videobuf_queue_cancel(file,&fh->vidq);
+		videobuf_queue_cancel(&fh->vidq);
 		res_free(dev,fh,RESOURCE_VIDEO);
 	}
 	if (fh->vidq.read_buf) {
-		buffer_release(file,fh->vidq.read_buf);
+		buffer_release(&fh->vidq,fh->vidq.read_buf);
 		kfree(fh->vidq.read_buf);
 	}
 
 	/* stop vbi capture */
 	if (res_check(fh, RESOURCE_VBI)) {
 		if (fh->vbiq.streaming)
-			videobuf_streamoff(file,&fh->vbiq);
+			videobuf_streamoff(&fh->vbiq);
 		if (fh->vbiq.reading)
-			videobuf_read_stop(file,&fh->vbiq);
+			videobuf_read_stop(&fh->vbiq);
 		res_free(dev,fh,RESOURCE_VBI);
 	}
 
@@ -1350,17 +1093,18 @@
 {
 	struct cx8800_fh *fh = file->private_data;
 
-	return videobuf_mmap_mapper(vma, get_queue(fh));
+	return videobuf_mmap_mapper(get_queue(fh), vma);
 }
 
 /* ------------------------------------------------------------------ */
 
 static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl)
 {
+	struct cx88_core *core = dev->core;
 	struct cx88_ctrl *c = NULL;
 	u32 value;
 	int i;
-	
+
 	for (i = 0; i < CX8800_CTLS; i++)
 		if (cx8800_ctls[i].v.id == ctl->id)
 			c = &cx8800_ctls[i];
@@ -1384,6 +1128,7 @@
 
 static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl)
 {
+	struct cx88_core *core = dev->core;
 	struct cx88_ctrl *c = NULL;
         u32 v_sat_value;
 	u32 value;
@@ -1484,8 +1229,8 @@
 			return -EINVAL;
 
 		field = f->fmt.pix.field;
-		maxw  = norm_maxw(dev->tvnorm);
-		maxh  = norm_maxh(dev->tvnorm);
+		maxw  = norm_maxw(dev->core->tvnorm);
+		maxh  = norm_maxh(dev->core->tvnorm);
 
 		if (V4L2_FIELD_ANY == field) {
 			field = (f->fmt.pix.height > maxh/2)
@@ -1533,7 +1278,7 @@
 			struct v4l2_format *f)
 {
 	int err;
-	
+
 	switch (f->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		err = cx8800_try_fmt(dev,fh,f);
@@ -1561,23 +1306,24 @@
 static int video_do_ioctl(struct inode *inode, struct file *file,
 			  unsigned int cmd, void *arg)
 {
-	struct cx8800_fh  *fh  = file->private_data;
-	struct cx8800_dev *dev = fh->dev;
+	struct cx8800_fh  *fh   = file->private_data;
+	struct cx8800_dev *dev  = fh->dev;
+	struct cx88_core  *core = dev->core;
 #if 0
 	unsigned long flags;
 #endif
 	int err;
 
 	if (video_debug > 1)
-		cx88_print_ioctl(dev->name,cmd);
+		cx88_print_ioctl(core->name,cmd);
 	switch (cmd) {
 	case VIDIOC_QUERYCAP:
 	{
 		struct v4l2_capability *cap = arg;
-		
+
 		memset(cap,0,sizeof(*cap));
                 strcpy(cap->driver, "cx8800");
-		strlcpy(cap->card, cx88_boards[dev->board].name,
+		strlcpy(cap->card, cx88_boards[core->board].name,
 			sizeof(cap->card));
 		sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
 		cap->version = CX88_VERSION_CODE;
@@ -1590,7 +1336,7 @@
 			V4L2_CAP_VIDEO_OVERLAY |
 #endif
 			0;
-		if (UNSET != dev->tuner_type)
+		if (UNSET != core->tuner_type)
 			cap->capabilities |= V4L2_CAP_TUNER;
 
 		return 0;
@@ -1616,7 +1362,7 @@
 	{
 		v4l2_std_id *id = arg;
 
-		*id = dev->tvnorm->id;
+		*id = core->tvnorm->id;
 		return 0;
 	}
 	case VIDIOC_S_STD:
@@ -1631,7 +1377,7 @@
 			return -EINVAL;
 
 		down(&dev->lock);
-		set_tvnorm(dev,&tvnorms[i]);
+		cx88_set_tvnorm(dev->core,&tvnorms[i]);
 		up(&dev->lock);
 		return 0;
 	}
@@ -1644,8 +1390,10 @@
 			[ CX88_VMUX_COMPOSITE2 ] = "Composite2",
 			[ CX88_VMUX_COMPOSITE3 ] = "Composite3",
 			[ CX88_VMUX_COMPOSITE4 ] = "Composite4",
-			[ CX88_VMUX_TELEVISION ] = "Television",
 			[ CX88_VMUX_SVIDEO     ] = "S-Video",
+			[ CX88_VMUX_TELEVISION ] = "Television",
+			[ CX88_VMUX_CABLE      ] = "Cable TV",
+			[ CX88_VMUX_DVB        ] = "DVB",
 			[ CX88_VMUX_DEBUG      ] = "for debug only",
 		};
 		struct v4l2_input *i = arg;
@@ -1660,7 +1408,8 @@
 		i->index = n;
 		i->type  = V4L2_INPUT_TYPE_CAMERA;
 		strcpy(i->name,iname[INPUT(n)->type]);
-		if (CX88_VMUX_TELEVISION == INPUT(n)->type)
+		if ((CX88_VMUX_TELEVISION == INPUT(n)->type) ||
+		    (CX88_VMUX_CABLE      == INPUT(n)->type))
 			i->type = V4L2_INPUT_TYPE_TUNER;
 		for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
 			i->std |= tvnorms[n].id;
@@ -1670,13 +1419,13 @@
 	{
 		unsigned int *i = arg;
 
-		*i = dev->input;
+		*i = dev->core->input;
 		return 0;
 	}
 	case VIDIOC_S_INPUT:
 	{
 		unsigned int *i = arg;
-		
+
 		if (*i >= 4)
 			return -EINVAL;
 		down(&dev->lock);
@@ -1685,6 +1434,38 @@
 		return 0;
 	}
 
+
+#if 0
+	/* needs review */
+	case VIDIOC_G_AUDIO:
+	{
+		struct v4l2_audio *a = arg;
+		unsigned int n = a->index;
+
+		memset(a,0,sizeof(*a));
+		a->index = n;
+		switch (n) {
+		case 0:
+			if ((CX88_VMUX_TELEVISION == INPUT(n)->type)
+			    || (CX88_VMUX_CABLE == INPUT(n)->type)) {
+				strcpy(a->name,"Television");
+				// FIXME figure out if stereo received and set V4L2_AUDCAP_STEREO.
+				return 0;
+			}
+			break;
+		case 1:
+			if (CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD == core->board) {
+				strcpy(a->name,"Line In");
+				a->capability = V4L2_AUDCAP_STEREO;
+				return 0;
+			}
+			break;
+		}
+		// Audio input not available.
+		return -EINVAL;
+	}
+#endif
+
 	/* --- capture ioctls ---------------------------------------- */
 	case VIDIOC_ENUM_FMT:
 	{
@@ -1748,14 +1529,14 @@
 		return get_control(dev,arg);
 	case VIDIOC_S_CTRL:
 		return set_control(dev,arg);
-		
+
 	/* --- tuner ioctls ------------------------------------------ */
 	case VIDIOC_G_TUNER:
 	{
 		struct v4l2_tuner *t = arg;
 		u32 reg;
-		
-		if (UNSET == dev->tuner_type)
+
+		if (UNSET == core->tuner_type)
 			return -EINVAL;
 		if (0 != t->index)
 			return -EINVAL;
@@ -1766,7 +1547,7 @@
 		t->capability = V4L2_TUNER_CAP_NORM;
 		t->rangehigh  = 0xffffffffUL;
 
-		cx88_get_stereo(dev ,t);
+		cx88_get_stereo(core ,t);
 		reg = cx_read(MO_DEVICE_STATUS);
                 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;
 		return 0;
@@ -1775,18 +1556,18 @@
 	{
 		struct v4l2_tuner *t = arg;
 
-		if (UNSET == dev->tuner_type)
+		if (UNSET == core->tuner_type)
 			return -EINVAL;
 		if (0 != t->index)
 			return -EINVAL;
-		cx88_set_stereo(dev,t->audmode);
+		cx88_set_stereo(core, t->audmode);
 		return 0;
 	}
 	case VIDIOC_G_FREQUENCY:
 	{
 		struct v4l2_frequency *f = arg;
 
-		if (UNSET == dev->tuner_type)
+		if (UNSET == core->tuner_type)
 			return -EINVAL;
 		if (f->tuner != 0)
 			return -EINVAL;
@@ -1799,7 +1580,7 @@
 	{
 		struct v4l2_frequency *f = arg;
 
-		if (UNSET == dev->tuner_type)
+		if (UNSET == core->tuner_type)
 			return -EINVAL;
 		if (f->tuner != 0)
 			return -EINVAL;
@@ -1810,9 +1591,9 @@
 		down(&dev->lock);
 		dev->freq = f->frequency;
 #ifdef V4L2_I2C_CLIENTS
-		cx8800_call_i2c_clients(dev,VIDIOC_S_FREQUENCY,f);
+		cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f);
 #else
-		cx8800_call_i2c_clients(dev,VIDIOCSFREQ,&dev->freq);
+		cx88_call_i2c_clients(dev->core,VIDIOCSFREQ,&dev->freq);
 #endif
 		up(&dev->lock);
 		return 0;
@@ -1831,7 +1612,7 @@
 		req.type   = q->type;
 		req.count  = 8;
 		req.memory = V4L2_MEMORY_MMAP;
-		err = videobuf_reqbufs(file,q,&req);
+		err = videobuf_reqbufs(q,&req);
 		if (err < 0)
 			return err;
 		memset(mbuf,0,sizeof(*mbuf));
@@ -1844,16 +1625,17 @@
 		return 0;
 	}
 	case VIDIOC_REQBUFS:
-		return videobuf_reqbufs(file, get_queue(fh), arg);
+		return videobuf_reqbufs(get_queue(fh), arg);
 
 	case VIDIOC_QUERYBUF:
 		return videobuf_querybuf(get_queue(fh), arg);
 
 	case VIDIOC_QBUF:
-		return videobuf_qbuf(file, get_queue(fh), arg);
+		return videobuf_qbuf(get_queue(fh), arg);
 
 	case VIDIOC_DQBUF:
-		return videobuf_dqbuf(file, get_queue(fh), arg);
+		return videobuf_dqbuf(get_queue(fh), arg,
+				      file->f_flags & O_NONBLOCK);
 
 	case VIDIOC_STREAMON:
 	{
@@ -1861,13 +1643,13 @@
 
                 if (!res_get(dev,fh,res))
 			return -EBUSY;
-		return videobuf_streamon(file, get_queue(fh));
+		return videobuf_streamon(get_queue(fh));
 	}
 	case VIDIOC_STREAMOFF:
 	{
 		int res = get_ressource(fh);
 
-		err = videobuf_streamoff(file, get_queue(fh));
+		err = videobuf_streamoff(get_queue(fh));
 		if (err < 0)
 			return err;
 		res_free(dev,fh,res);
@@ -1892,20 +1674,21 @@
 static int radio_do_ioctl(struct inode *inode, struct file *file,
 			unsigned int cmd, void *arg)
 {
-	struct cx8800_fh *fh = file->private_data;
-	struct cx8800_dev *dev = fh->dev;
-	
+	struct cx8800_fh *fh    = file->private_data;
+	struct cx8800_dev *dev  = fh->dev;
+	struct cx88_core  *core = dev->core;
+
 	if (video_debug > 1)
-		cx88_print_ioctl(dev->name,cmd);
+		cx88_print_ioctl(core->name,cmd);
 
 	switch (cmd) {
 	case VIDIOC_QUERYCAP:
 	{
 		struct v4l2_capability *cap = arg;
-		
+
 		memset(cap,0,sizeof(*cap));
                 strcpy(cap->driver, "cx8800");
-		strlcpy(cap->card, cx88_boards[dev->board].name,
+		strlcpy(cap->card, cx88_boards[core->board].name,
 			sizeof(cap->card));
 		sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci));
 		cap->version = CX88_VERSION_CODE;
@@ -1923,14 +1706,14 @@
 		strcpy(t->name, "Radio");
                 t->rangelow  = (int)(65*16);
                 t->rangehigh = (int)(108*16);
-		
+
 #ifdef V4L2_I2C_CLIENTS
-		cx8800_call_i2c_clients(dev,VIDIOC_G_TUNER,t);
+		cx88_call_i2c_clients(dev->core,VIDIOC_G_TUNER,t);
 #else
 		{
 			struct video_tuner vt;
 			memset(&vt,0,sizeof(vt));
-			cx8800_call_i2c_clients(dev,VIDIOCGTUNER,&vt);
+			cx88_call_i2c_clients(dev,VIDIOCGTUNER,&vt);
 			t->signal = vt.signal;
 		}
 #endif
@@ -1939,7 +1722,7 @@
 	case VIDIOC_ENUMINPUT:
 	{
 		struct v4l2_input *i = arg;
-		
+
 		if (i->index != 0)
 			return -EINVAL;
 		strcpy(i->name,"Radio");
@@ -1996,7 +1779,7 @@
 	case VIDIOC_G_FREQUENCY:
 	case VIDIOC_S_FREQUENCY:
 		return video_do_ioctl(inode,file,cmd,arg);
-		
+
 	default:
 		return v4l_compat_translate_ioctl(inode,file,cmd,arg,
 						  radio_do_ioctl);
@@ -2015,13 +1798,13 @@
 static void cx8800_vid_timeout(unsigned long data)
 {
 	struct cx8800_dev *dev = (struct cx8800_dev*)data;
+	struct cx88_core *core = dev->core;
 	struct cx88_dmaqueue *q = &dev->vidq;
 	struct cx88_buffer *buf;
 	unsigned long flags;
 
-	cx88_sram_channel_dump(dev, &cx88_sram_channels[SRAM_CH21]);
-	//cx88_risc_disasm(dev,&dev->vidq.stopper);
-	
+	cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH21]);
+
 	cx_clear(MO_VID_DMACNTRL, 0x11);
 	cx_clear(VID_CAPTURE_CONTROL, 0x06);
 
@@ -2031,41 +1814,16 @@
 		list_del(&buf->vb.queue);
 		buf->vb.state = STATE_ERROR;
 		wake_up(&buf->vb.done);
-		printk("%s: [%p/%d] timeout - dma=0x%08lx\n", dev->name,
+		printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", core->name,
 		       buf, buf->vb.i, (unsigned long)buf->risc.dma);
 	}
 	restart_video_queue(dev,q);
 	spin_unlock_irqrestore(&dev->slock,flags);
 }
 
-static void cx8800_wakeup(struct cx8800_dev *dev,
-			  struct cx88_dmaqueue *q, u32 count)
-{
-	struct cx88_buffer *buf;
-
-	for (;;) {
-		if (list_empty(&q->active))
-			break;
-		buf = list_entry(q->active.next,
-				 struct cx88_buffer, vb.queue);
-		if (buf->count > count)
-			break;
-		do_gettimeofday(&buf->vb.ts);
-		dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i,
-			count, buf->count);
-		buf->vb.state = STATE_DONE;
-		list_del(&buf->vb.queue);
-		wake_up(&buf->vb.done);
-	}
-	if (list_empty(&q->active)) {
-		del_timer(&q->timeout);
-	} else {
-		mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
-	}
-}
-
 static void cx8800_vid_irq(struct cx8800_dev *dev)
 {
+	struct cx88_core *core = dev->core;
 	u32 status, mask, count;
 
 	status = cx_read(MO_VID_INTSTAT);
@@ -2074,22 +1832,22 @@
 		return;
 	cx_write(MO_VID_INTSTAT, status);
 	if (irq_debug  ||  (status & mask & ~0xff))
-		cx88_print_irqbits(dev->name, "irq vid",
+		cx88_print_irqbits(core->name, "irq vid",
 				   cx88_vid_irqs, status, mask);
 
 	/* risc op code error */
 	if (status & (1 << 16)) {
-		printk(KERN_WARNING "%s: video risc op code error\n",dev->name);
+		printk(KERN_WARNING "%s/0: video risc op code error\n",core->name);
 		cx_clear(MO_VID_DMACNTRL, 0x11);
 		cx_clear(VID_CAPTURE_CONTROL, 0x06);
-		cx88_sram_channel_dump(dev, &cx88_sram_channels[SRAM_CH21]);
+		cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH21]);
 	}
-	
+
 	/* risc1 y */
 	if (status & 0x01) {
 		spin_lock(&dev->slock);
 		count = cx_read(MO_VIDY_GPCNT);
-		cx8800_wakeup(dev, &dev->vidq, count);
+		cx88_wakeup(dev->core, &dev->vidq, count);
 		spin_unlock(&dev->slock);
 	}
 
@@ -2097,7 +1855,7 @@
 	if (status & 0x08) {
 		spin_lock(&dev->slock);
 		count = cx_read(MO_VBI_GPCNT);
-		cx8800_wakeup(dev, &dev->vbiq, count);
+		cx88_wakeup(dev->core, &dev->vbiq, count);
 		spin_unlock(&dev->slock);
 	}
 
@@ -2121,29 +1879,29 @@
 static irqreturn_t cx8800_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct cx8800_dev *dev = dev_id;
+	struct cx88_core *core = dev->core;
 	u32 status, mask;
 	int loop, handled = 0;
 
 	for (loop = 0; loop < 10; loop++) {
-		status = cx_read(MO_PCI_INTSTAT);
+		status = cx_read(MO_PCI_INTSTAT) & (~0x1f | 0x01);
 		mask   = cx_read(MO_PCI_INTMSK);
 		if (0 == (status & mask))
 			goto out;
-		handled = 1;
 		cx_write(MO_PCI_INTSTAT, status);
-		if (irq_debug  ||  (status & mask & ~0x1f))
-			cx88_print_irqbits(dev->name, "irq pci",
-					   cx88_pci_irqs, status, mask);
+		handled = 1;
 
-		if (status & 1)
+		if (status & mask & ~0x1f)
+			cx88_irq(core,status,mask);
+		if (status & 0x01)
 			cx8800_vid_irq(dev);
 	};
 	if (10 == loop) {
-		printk(KERN_WARNING "%s: irq loop -- clearing mask\n",
-		       dev->name);
+		printk(KERN_WARNING "%s/0: irq loop -- clearing mask\n",
+		       core->name);
 		cx_write(MO_PCI_INTMSK,0);
 	}
-	
+
  out:
 	return IRQ_RETVAL(handled);
 }
@@ -2201,97 +1959,6 @@
 
 /* ----------------------------------------------------------- */
 
-static void cx8800_shutdown(struct cx8800_dev *dev)
-{
-	/* disable RISC controller + IRQs */
-	cx_write(MO_DEV_CNTRL2, 0);
-
-	/* stop dma transfers */
-	cx_write(MO_VID_DMACNTRL, 0x0);
-	cx_write(MO_AUD_DMACNTRL, 0x0);
-	cx_write(MO_TS_DMACNTRL, 0x0);
-	cx_write(MO_VIP_DMACNTRL, 0x0);
-	cx_write(MO_GPHST_DMACNTRL, 0x0);
-
-	/* stop interupts */
-	cx_write(MO_PCI_INTMSK, 0x0);
-	cx_write(MO_VID_INTMSK, 0x0);
-	cx_write(MO_AUD_INTMSK, 0x0);
-	cx_write(MO_TS_INTMSK, 0x0);
-	cx_write(MO_VIP_INTMSK, 0x0);
-	cx_write(MO_GPHST_INTMSK, 0x0);
-
-	/* stop capturing */
-	cx_write(VID_CAPTURE_CONTROL, 0);
-}
-
-static int cx8800_reset(struct cx8800_dev *dev)
-{
-	dprintk(1,"cx8800_reset\n");
-
-	cx8800_shutdown(dev);
-	
-	/* clear irq status */
-	cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int
-	cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int
-	cx_write(MO_INT1_STAT,   0xFFFFFFFF); // Clear RISC int
-
-	/* wait a bit */
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ/10);
-	
-	/* init sram */
-	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH21], 720*4, 0);
-	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH22], 128, 0);
-	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH23], 128, 0);
-	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH24], 128, 0);
-	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH25], 128, 0);
-	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH26], 128, 0);
-	
-	/* misc init ... */
-	cx_write(MO_INPUT_FORMAT, ((1 << 13) |   // agc enable
-				   (1 << 12) |   // agc gain
-				   (1 << 11) |   // adaptibe agc
-				   (0 << 10) |   // chroma agc
-				   (0 <<  9) |   // ckillen
-				   (7)));
-
-	/* setup image format */
-	cx_andor(MO_COLOR_CTRL, 0x4000, 0x4000);
-
-	/* setup FIFO Threshholds */
-	cx_write(MO_PDMA_STHRSH,   0x0807);
-	cx_write(MO_PDMA_DTHRSH,   0x0807);
-
-	/* fixes flashing of image */
-	cx_write(MO_AGC_SYNC_TIP1, 0x0380000F);
-	cx_write(MO_AGC_BACK_VBI,  0x00E00555);
-	
-	cx_write(MO_VID_INTSTAT,   0xFFFFFFFF); // Clear PIV int
-	cx_write(MO_PCI_INTSTAT,   0xFFFFFFFF); // Clear PCI int
-	cx_write(MO_INT1_STAT,     0xFFFFFFFF); // Clear RISC int
-
-	return 0;
-}
-
-static struct video_device *vdev_init(struct cx8800_dev *dev,
-				      struct video_device *template,
-				      char *type)
-{
-	struct video_device *vfd;
-
-	vfd = video_device_alloc();
-	if (NULL == vfd)
-		return NULL;
-	*vfd = *template;
-	vfd->minor   = -1;
-	vfd->dev     = &dev->pci->dev;
-	vfd->release = video_device_release;
-	snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
-		 dev->name, type, cx88_boards[dev->board].name);
-	return vfd;
-}
-
 static void cx8800_unregister_video(struct cx8800_dev *dev)
 {
 	if (dev->radio_dev) {
@@ -2321,7 +1988,7 @@
 				    const struct pci_device_id *pci_id)
 {
 	struct cx8800_dev *dev;
-	unsigned int i;
+	struct cx88_core *core;
 	int err;
 
 	dev = kmalloc(sizeof(*dev),GFP_KERNEL);
@@ -2333,70 +2000,34 @@
 	dev->pci = pci_dev;
 	if (pci_enable_device(pci_dev)) {
 		err = -EIO;
-		goto fail1;
+		goto fail_free;
 	}
-	sprintf(dev->name,"cx%x[%d]",pci_dev->device,cx8800_devcount);
-
-	/* pci quirks */
-	cx88_pci_quirks(dev->name, dev->pci, &latency);
-	if (UNSET != latency) {
-		printk(KERN_INFO "%s: setting pci latency timer to %d\n",
-		       dev->name,latency);
-		pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, latency);
+	core = cx88_core_get(dev->pci);
+	if (NULL == core) {
+		err = -EINVAL;
+		goto fail_free;
 	}
+	dev->core = core;
 
 	/* print pci info */
 	pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
         pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER,  &dev->pci_lat);
-        printk(KERN_INFO "%s: found at %s, rev: %d, irq: %d, "
-	       "latency: %d, mmio: 0x%lx\n", dev->name,
+        printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, "
+	       "latency: %d, mmio: 0x%lx\n", core->name,
 	       pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
 	       dev->pci_lat,pci_resource_start(pci_dev,0));
 
 	pci_set_master(pci_dev);
 	if (!pci_dma_supported(pci_dev,0xffffffff)) {
-		printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name);
+		printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name);
 		err = -EIO;
-		goto fail1;
+		goto fail_core;
 	}
 
-	/* board config */
-	dev->board = card[cx8800_devcount];
-	for (i = 0; UNSET == dev->board  &&  i < cx88_idcount; i++) 
-		if (pci_dev->subsystem_vendor == cx88_subids[i].subvendor &&
-		    pci_dev->subsystem_device == cx88_subids[i].subdevice)
-			dev->board = cx88_subids[i].card;
-	if (UNSET == dev->board) {
-		dev->board = CX88_BOARD_UNKNOWN;
-		cx88_card_list(dev);
-	}
-        printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
-	       dev->name,pci_dev->subsystem_vendor,
-	       pci_dev->subsystem_device,cx88_boards[dev->board].name,
-	       dev->board, card[cx8800_devcount] == dev->board ?
-	       "insmod option" : "autodetected");
-
-	dev->tuner_type = tuner[cx8800_devcount];
-	if (UNSET == dev->tuner_type)
-		dev->tuner_type = cx88_boards[dev->board].tuner_type;
-
-	/* get mmio */
-	if (!request_mem_region(pci_resource_start(pci_dev,0),
-				pci_resource_len(pci_dev,0),
-				dev->name)) {
-		err = -EBUSY;
-		printk(KERN_ERR "%s: can't get MMIO memory @ 0x%lx\n",
-		       dev->name,pci_resource_start(pci_dev,0));
-		goto fail1;
-	}
-	dev->lmmio = ioremap(pci_resource_start(pci_dev,0),
-			     pci_resource_len(pci_dev,0));
-	dev->bmmio = (u8*)dev->lmmio;
-
 	/* initialize driver struct */
         init_MUTEX(&dev->lock);
 	dev->slock = SPIN_LOCK_UNLOCKED;
-	dev->tvnorm = tvnorms;
+	core->tvnorm = tvnorms;
 
 	/* init video dma queues */
 	INIT_LIST_HEAD(&dev->vidq.active);
@@ -2416,92 +2047,85 @@
 	cx88_risc_stopper(dev->pci,&dev->vbiq.stopper,
 			  MO_VID_DMACNTRL,0x88,0x00);
 
-	/* initialize hardware */
-	cx8800_reset(dev);
-
 	/* get irq */
 	err = request_irq(pci_dev->irq, cx8800_irq,
-			  SA_SHIRQ | SA_INTERRUPT, dev->name, dev);
+			  SA_SHIRQ | SA_INTERRUPT, core->name, dev);
 	if (err < 0) {
 		printk(KERN_ERR "%s: can't get IRQ %d\n",
-		       dev->name,pci_dev->irq);
-		goto fail2;
+		       core->name,pci_dev->irq);
+		goto fail_core;
 	}
 
-	/* register i2c bus + load i2c helpers */
-	cx8800_i2c_init(dev);
-	cx88_card_setup(dev);
-
 	/* load and configure helper modules */
-	if (TUNER_ABSENT != dev->tuner_type)
+	if (TUNER_ABSENT != core->tuner_type)
 		request_module("tuner");
-	if (cx88_boards[dev->board].needs_tda9887)
+	if (core->tda9887_conf)
 		request_module("tda9887");
-	if (dev->tuner_type != UNSET)
-		cx8800_call_i2c_clients(dev,TUNER_SET_TYPE,&dev->tuner_type);
+	if (core->tuner_type != UNSET)
+		cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE,&core->tuner_type);
+	if (core->tda9887_conf)
+		cx88_call_i2c_clients(dev->core,TDA9887_SET_CONFIG,&core->tda9887_conf);
 
 	/* register v4l devices */
-	dev->video_dev = vdev_init(dev,&cx8800_video_template,"video");
+	dev->video_dev = cx88_vdev_init(core,dev->pci,
+					&cx8800_video_template,"video");
 	err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
-				    video_nr[cx8800_devcount]);
+				    video_nr[core->nr]);
 	if (err < 0) {
 		printk(KERN_INFO "%s: can't register video device\n",
-		       dev->name);
-		goto fail3;
+		       core->name);
+		goto fail_unreg;
 	}
-	printk(KERN_INFO "%s: registered device video%d [v4l2]\n",
-	       dev->name,dev->video_dev->minor & 0x1f);
+	printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n",
+	       core->name,dev->video_dev->minor & 0x1f);
 
-	dev->vbi_dev = vdev_init(dev,&cx8800_vbi_template,"vbi");
+	dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi");
 	err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
-				    vbi_nr[cx8800_devcount]);
+				    vbi_nr[core->nr]);
 	if (err < 0) {
-		printk(KERN_INFO "%s: can't register vbi device\n",
-		       dev->name);
-		goto fail3;
-	}
-	printk(KERN_INFO "%s: registered device vbi%d\n",
-	       dev->name,dev->vbi_dev->minor & 0x1f);
-
-	if (dev->has_radio) {
-		dev->radio_dev = vdev_init(dev,&cx8800_radio_template,"radio");
+		printk(KERN_INFO "%s/0: can't register vbi device\n",
+		       core->name);
+		goto fail_unreg;
+	}
+	printk(KERN_INFO "%s/0: registered device vbi%d\n",
+	       core->name,dev->vbi_dev->minor & 0x1f);
+
+	if (core->has_radio) {
+		dev->radio_dev = cx88_vdev_init(core,dev->pci,
+						&cx8800_radio_template,"radio");
 		err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
-					    radio_nr[cx8800_devcount]);
+					    radio_nr[core->nr]);
 		if (err < 0) {
-			printk(KERN_INFO "%s: can't register radio device\n",
-			       dev->name);
-			goto fail3;
+			printk(KERN_INFO "%s/0: can't register radio device\n",
+			       core->name);
+			goto fail_unreg;
 		}
-		printk(KERN_INFO "%s: registered device radio%d\n",
-		       dev->name,dev->radio_dev->minor & 0x1f);
+		printk(KERN_INFO "%s/0: registered device radio%d\n",
+		       core->name,dev->radio_dev->minor & 0x1f);
 	}
 
 	/* everything worked */
 	list_add_tail(&dev->devlist,&cx8800_devlist);
 	pci_set_drvdata(pci_dev,dev);
-	cx8800_devcount++;
 
 	/* initial device configuration */
 	down(&dev->lock);
 	init_controls(dev);
-	set_tvnorm(dev,tvnorms);
+	cx88_set_tvnorm(dev->core,tvnorms);
 	video_mux(dev,0);
 	up(&dev->lock);
 
 	/* start tvaudio thread */
-	init_completion(&dev->texit);
-	dev->tpid = kernel_thread(cx88_audio_thread, dev, 0);
+	if (core->tuner_type != TUNER_ABSENT)
+		core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio");
 	return 0;
 
- fail3:
+fail_unreg:
 	cx8800_unregister_video(dev);
-	if (0 == dev->i2c_rc)
-		i2c_bit_del_bus(&dev->i2c_adap);
 	free_irq(pci_dev->irq, dev);
- fail2:
-	release_mem_region(pci_resource_start(pci_dev,0),
-			   pci_resource_len(pci_dev,0));
- fail1:
+fail_core:
+	cx88_core_put(core,dev->pci);
+fail_free:
 	kfree(dev);
 	return err;
 }
@@ -2511,41 +2135,52 @@
         struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
 
 	/* stop thread */
-	dev->shutdown = 1;
-	if (dev->tpid >= 0)
-		wait_for_completion(&dev->texit);
+	if (dev->core->kthread) {
+		kthread_stop(dev->core->kthread);
+		dev->core->kthread = NULL;
+	}
 
-	cx8800_shutdown(dev);
+	cx88_shutdown(dev->core); /* FIXME */
 	pci_disable_device(pci_dev);
 
-	/* unregister stuff */	
-	if (0 == dev->i2c_rc)
-		i2c_bit_del_bus(&dev->i2c_adap);
+	/* unregister stuff */
 
 	free_irq(pci_dev->irq, dev);
-	release_mem_region(pci_resource_start(pci_dev,0),
-			   pci_resource_len(pci_dev,0));
-
 	cx8800_unregister_video(dev);
 	pci_set_drvdata(pci_dev, NULL);
 
 	/* free memory */
 	btcx_riscmem_free(dev->pci,&dev->vidq.stopper);
 	list_del(&dev->devlist);
-	cx8800_devcount--;
+	cx88_core_put(dev->core,dev->pci);
 	kfree(dev);
 }
 
 static int cx8800_suspend(struct pci_dev *pci_dev, u32 state)
 {
         struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
+	struct cx88_core *core = dev->core;
 
-	printk("%s: suspend %d\n", dev->name, state);
+	/* stop video+vbi capture */
+	spin_lock(&dev->slock);
+	if (!list_empty(&dev->vidq.active)) {
+		printk("%s: suspend video\n", core->name);
+		stop_video_dma(dev);
+		del_timer(&dev->vidq.timeout);
+	}
+	if (!list_empty(&dev->vbiq.active)) {
+		printk("%s: suspend vbi\n", core->name);
+		cx8800_stop_vbi_dma(dev);
+		del_timer(&dev->vbiq.timeout);
+	}
+	spin_unlock(&dev->slock);
+
+#if 1
+	/* FIXME -- shutdown device */
+	cx88_shutdown(dev->core);
+#endif
 
-	cx8800_shutdown(dev);
-	del_timer(&dev->vidq.timeout);
-	
-	pci_save_state(pci_dev, dev->state.pci_cfg);
+	pci_save_state(pci_dev);
 	if (0 != pci_set_power_state(pci_dev, state)) {
 		pci_disable_device(pci_dev);
 		dev->state.disabled = 1;
@@ -2556,22 +2191,30 @@
 static int cx8800_resume(struct pci_dev *pci_dev)
 {
         struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
-
-	printk("%s: resume\n", dev->name);
+	struct cx88_core *core = dev->core;
 
 	if (dev->state.disabled) {
 		pci_enable_device(pci_dev);
 		dev->state.disabled = 0;
 	}
 	pci_set_power_state(pci_dev, 0);
-	pci_restore_state(pci_dev, dev->state.pci_cfg);
+	pci_restore_state(pci_dev);
 
-	/* re-initialize hardware */
-	cx8800_reset(dev);
+#if 1
+	/* FIXME: re-initialize hardware */
+	cx88_reset(dev->core);
+#endif
 
-	/* restart video capture */
+	/* restart video+vbi capture */
 	spin_lock(&dev->slock);
-	restart_video_queue(dev,&dev->vidq);
+	if (!list_empty(&dev->vidq.active)) {
+		printk("%s: resume video\n", core->name);
+		restart_video_queue(dev,&dev->vidq);
+	}
+	if (!list_empty(&dev->vbiq.active)) {
+		printk("%s: resume vbi\n", core->name);
+		cx8800_restart_vbi_queue(dev,&dev->vbiq);
+	}
 	spin_unlock(&dev->slock);
 
 	return 0;
@@ -2595,7 +2238,7 @@
         .name     = "cx8800",
         .id_table = cx8800_pci_tbl,
         .probe    = cx8800_initdev,
-        .remove   = cx8800_finidev,
+        .remove   = __devexit_p(cx8800_finidev),
 
 	.suspend  = cx8800_suspend,
 	.resume   = cx8800_resume,
@@ -2603,7 +2246,6 @@
 
 static int cx8800_init(void)
 {
-	INIT_LIST_HEAD(&cx8800_devlist);
 	printk(KERN_INFO "cx2388x v4l2 driver version %d.%d.%d loaded\n",
 	       (CX88_VERSION_CODE >> 16) & 0xff,
 	       (CX88_VERSION_CODE >>  8) & 0xff,
diff -Nru a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
--- a/drivers/media/video/cx88/cx88.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/media/video/cx88/cx88.h	2004-12-24 13:37:31 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: cx88.h,v 1.40 2004/11/03 09:04:51 kraxel Exp $
+ *
  * v4l2 device driver for cx2388x based TV cards
  *
  * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
@@ -24,9 +26,10 @@
 #include <linux/videodev.h>
 #include <linux/kdev_t.h>
 
-#include <media/video-buf.h>
 #include <media/tuner.h>
 #include <media/audiochip.h>
+#include <media/video-buf.h>
+#include <media/video-buf-dvb.h>
 
 #include "btcx-risc.h"
 #include "cx88-reg.h"
@@ -47,6 +50,8 @@
 /* ----------------------------------------------------------- */
 /* defines and enums                                           */
 
+#define V4L2_I2C_CLIENTS 1
+
 #define FORMAT_FLAGS_PACKED       0x01
 #define FORMAT_FLAGS_PLANAR       0x02
 
@@ -59,15 +64,29 @@
 #define SHADOW_MAX                   2
 
 /* ----------------------------------------------------------- */
-/* static data                                                 */
+/* tv norms                                                    */
 
-struct cx8800_tvnorm {
+struct cx88_tvnorm {
 	char                   *name;
 	v4l2_std_id            id;
 	u32                    cxiformat;
 	u32                    cxoformat;
 };
 
+static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 768 : 640;
+//	return (norm->id & V4L2_STD_625_50) ? 720 : 640;
+}
+
+static unsigned int inline norm_maxh(struct cx88_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 576 : 480;
+}
+
+/* ----------------------------------------------------------- */
+/* static data                                                 */
+
 struct cx8800_fmt {
 	char  *name;
 	u32   fourcc;          /* v4l2 format id */
@@ -94,6 +113,7 @@
 #define SRAM_CH24 3   /* vbi   */
 #define SRAM_CH25 4   /* audio */
 #define SRAM_CH26 5
+#define SRAM_CH28 6   /* mpeg */
 /* more */
 
 struct sram_channel {
@@ -113,31 +133,41 @@
 /* ----------------------------------------------------------- */
 /* card configuration                                          */
 
-#define CX88_BOARD_NOAUTO        UNSET
-#define CX88_BOARD_UNKNOWN               0
-#define CX88_BOARD_HAUPPAUGE             1
-#define CX88_BOARD_GDI                   2
-#define CX88_BOARD_PIXELVIEW             3
-#define CX88_BOARD_ATI_WONDER_PRO        4
-#define CX88_BOARD_WINFAST2000XP         5
-#define CX88_BOARD_AVERTV_303            6
-#define CX88_BOARD_MSI_TVANYWHERE_MASTER 7
-#define CX88_BOARD_WINFAST_DV2000        8
-#define CX88_BOARD_LEADTEK_PVR2000       9
-#define CX88_BOARD_IODATA_GVVCP3PCI      10
-#define CX88_BOARD_PROLINK_PLAYTVPVR     11
-#define CX88_BOARD_ASUS_PVR_416          12
-#define CX88_BOARD_MSI_TVANYWHERE        13
+#define CX88_BOARD_NOAUTO               UNSET
+#define CX88_BOARD_UNKNOWN                  0
+#define CX88_BOARD_HAUPPAUGE                1
+#define CX88_BOARD_GDI                      2
+#define CX88_BOARD_PIXELVIEW                3
+#define CX88_BOARD_ATI_WONDER_PRO           4
+#define CX88_BOARD_WINFAST2000XP            5
+#define CX88_BOARD_AVERTV_303               6
+#define CX88_BOARD_MSI_TVANYWHERE_MASTER    7
+#define CX88_BOARD_WINFAST_DV2000           8
+#define CX88_BOARD_LEADTEK_PVR2000          9
+#define CX88_BOARD_IODATA_GVVCP3PCI        10
+#define CX88_BOARD_PROLINK_PLAYTVPVR       11
+#define CX88_BOARD_ASUS_PVR_416            12
+#define CX88_BOARD_MSI_TVANYWHERE          13
+#define CX88_BOARD_KWORLD_DVB_T            14
+#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1 15
+#define CX88_BOARD_KWORLD_LTV883           16
+#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD 17
+#define CX88_BOARD_HAUPPAUGE_DVB_T1        18
+#define CX88_BOARD_CONEXANT_DVB_T1         19
+#define CX88_BOARD_PROVIDEO_PV259          20
+#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS 21
 
 enum cx88_itype {
 	CX88_VMUX_COMPOSITE1 = 1,
-	CX88_VMUX_COMPOSITE2 = 2,
-	CX88_VMUX_COMPOSITE3 = 3,
-	CX88_VMUX_COMPOSITE4 = 4,
-	CX88_VMUX_TELEVISION = 5,
-	CX88_VMUX_SVIDEO     = 6,
-	CX88_VMUX_DEBUG      = 7,
-	CX88_RADIO           = 8,
+	CX88_VMUX_COMPOSITE2,
+	CX88_VMUX_COMPOSITE3,
+	CX88_VMUX_COMPOSITE4,
+	CX88_VMUX_SVIDEO,
+	CX88_VMUX_TELEVISION,
+	CX88_VMUX_CABLE,
+	CX88_VMUX_DVB,
+	CX88_VMUX_DEBUG,
+	CX88_RADIO,
 };
 
 struct cx88_input {
@@ -149,9 +179,11 @@
 struct cx88_board {
 	char                    *name;
 	unsigned int            tuner_type;
-	int                     needs_tda9887:1;
+	int                     tda9887_conf;
 	struct cx88_input       input[8];
 	struct cx88_input       radio;
+	int                     blackbird:1;
+	int                     dvb:1;
 };
 
 struct cx88_subid {
@@ -160,7 +192,7 @@
 	u32     card;
 };
 
-#define INPUT(nr) (&cx88_boards[dev->board].input[nr])
+#define INPUT(nr) (&cx88_boards[core->board].input[nr])
 
 /* ----------------------------------------------------------- */
 /* device / file handle status                                 */
@@ -169,10 +201,8 @@
 #define RESOURCE_VIDEO         2
 #define RESOURCE_VBI           4
 
-//#define BUFFER_TIMEOUT     (HZ/2)  /* 0.5 seconds */
-#define BUFFER_TIMEOUT     (HZ*2)
-
-struct cx8800_dev;
+#define BUFFER_TIMEOUT     (HZ/2)  /* 0.5 seconds */
+//#define BUFFER_TIMEOUT     (HZ*2)
 
 /* buffer for one video frame */
 struct cx88_buffer {
@@ -194,7 +224,52 @@
 	u32                    count;
 };
 
-/* video filehandle status */
+struct cx88_core {
+	struct list_head           devlist;
+	atomic_t                   refcount;
+
+	/* board name */
+	int                        nr;
+	char                       name[32];
+
+	/* pci stuff */
+	int                        pci_bus;
+	int                        pci_slot;
+        u32                        __iomem *lmmio;
+        u8                         __iomem *bmmio;
+	u32                        shadow[SHADOW_MAX];
+
+	/* i2c i/o */
+	struct i2c_adapter         i2c_adap;
+	struct i2c_algo_bit_data   i2c_algo;
+	struct i2c_client          i2c_client;
+	u32                        i2c_state, i2c_rc;
+
+	/* config info -- analog */
+	unsigned int               board;
+	unsigned int               tuner_type;
+	unsigned int               tda9887_conf;
+	unsigned int               has_radio;
+
+	/* config info -- dvb */
+	unsigned int               pll_type;
+	unsigned int               pll_addr;
+	unsigned int               demod_addr;
+
+	/* state info */
+	struct task_struct         *kthread;
+	struct cx88_tvnorm         *tvnorm;
+	u32                        tvaudio;
+	u32                        input;
+	u32                        astat;
+};
+
+struct cx8800_dev;
+struct cx8802_dev;
+
+/* ----------------------------------------------------------- */
+/* function 0: video stuff                                     */
+
 struct cx8800_fh {
 	struct cx8800_dev          *dev;
 	enum v4l2_buf_type         type;
@@ -216,12 +291,11 @@
 };
 
 struct cx8800_suspend_state {
-	u32                        pci_cfg[64 / sizeof(u32)];
 	int                        disabled;
 };
 
-/* global device status */
 struct cx8800_dev {
+	struct cx88_core           *core;
 	struct list_head           devlist;
         struct semaphore           lock;
        	spinlock_t                 slock;
@@ -233,99 +307,150 @@
 	struct video_device        *radio_dev;
 
 	/* pci i/o */
-	char                       name[32];
 	struct pci_dev             *pci;
 	unsigned char              pci_rev,pci_lat;
-        u32                        *lmmio;
-        u8                         *bmmio;
-
-	/* config info */
-	unsigned int               board;
-	unsigned int               tuner_type;
-	unsigned int               has_radio;
-
-	/* i2c i/o */
-	struct i2c_adapter         i2c_adap;
-	struct i2c_algo_bit_data   i2c_algo;
-	struct i2c_client          i2c_client;
-	u32                        i2c_state, i2c_rc;
 
+#if 0
 	/* video overlay */
 	struct v4l2_framebuffer    fbuf;
 	struct cx88_buffer         *screen;
+#endif
 
 	/* capture queues */
 	struct cx88_dmaqueue       vidq;
 	struct cx88_dmaqueue       vbiq;
 
 	/* various v4l controls */
-	struct cx8800_tvnorm       *tvnorm;
-	u32                        tvaudio;
-	u32                        input;
 	u32                        freq;
 
 	/* other global state info */
-	u32                         shadow[SHADOW_MAX];
-	int                         shutdown;
-	pid_t                       tpid;
-	struct completion           texit;
 	struct cx8800_suspend_state state;
 };
 
 /* ----------------------------------------------------------- */
+/* function 1: audio/alsa stuff                                */
+
+struct cx8801_dev {
+	struct cx88_core           *core;
+
+	/* pci i/o */
+	struct pci_dev             *pci;
+	unsigned char              pci_rev,pci_lat;
+};
+
+/* ----------------------------------------------------------- */
+/* function 2: mpeg stuff                                      */
+
+struct cx8802_fh {
+	struct cx8802_dev          *dev;
+	struct videobuf_queue      mpegq;
+};
+
+struct cx8802_suspend_state {
+	int                        disabled;
+};
+
+struct cx8802_dev {
+	struct cx88_core           *core;
+        struct semaphore           lock;
+       	spinlock_t                 slock;
+
+	/* pci i/o */
+	struct pci_dev             *pci;
+	unsigned char              pci_rev,pci_lat;
+
+	/* dma queues */
+	struct cx88_dmaqueue       mpegq;
+	u32                        ts_packet_size;
+	u32                        ts_packet_count;
+
+	/* other global state info */
+	struct cx8802_suspend_state state;
+
+	/* for blackbird only */
+	struct list_head           devlist;
+	struct video_device        *mpeg_dev;
+	u32                        mailbox;
+
+	/* for dvb only */
+	struct videobuf_dvb        dvb;
+	void*                      fe_handle;
+	int                        (*fe_release)(void *handle);
+};
+
+/* ----------------------------------------------------------- */
 
-#define cx_read(reg)             readl(dev->lmmio + ((reg)>>2))
-#define cx_write(reg,value)      writel((value), dev->lmmio + ((reg)>>2));
-#define cx_writeb(reg,value)     writeb((value), dev->bmmio + (reg));
+#define cx_read(reg)             readl(core->lmmio + ((reg)>>2))
+#define cx_write(reg,value)      writel((value), core->lmmio + ((reg)>>2))
+#define cx_writeb(reg,value)     writeb((value), core->bmmio + (reg))
 
 #define cx_andor(reg,mask,value) \
-  writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\
-  ((value) & (mask)), dev->lmmio+((reg)>>2))
+  writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\
+  ((value) & (mask)), core->lmmio+((reg)>>2))
 #define cx_set(reg,bit)          cx_andor((reg),(bit),(bit))
 #define cx_clear(reg,bit)        cx_andor((reg),(bit),0)
 
 #define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); }
 
 /* shadow registers */
-#define cx_sread(sreg)		    (dev->shadow[sreg])
+#define cx_sread(sreg)		    (core->shadow[sreg])
 #define cx_swrite(sreg,reg,value) \
-  (dev->shadow[sreg] = value, \
-   writel(dev->shadow[sreg], dev->lmmio + ((reg)>>2)))
+  (core->shadow[sreg] = value, \
+   writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
 #define cx_sandor(sreg,reg,mask,value) \
-  (dev->shadow[sreg] = (dev->shadow[sreg] & ~(mask)) | ((value) & (mask)), \
-   writel(dev->shadow[sreg], dev->lmmio + ((reg)>>2)))
+  (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \
+   writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
 
 /* ----------------------------------------------------------- */
 /* cx88-core.c                                                 */
 
 extern char *cx88_pci_irqs[32];
 extern char *cx88_vid_irqs[32];
+extern char *cx88_mpeg_irqs[32];
 extern void cx88_print_irqbits(char *name, char *tag, char **strings,
 			       u32 bits, u32 mask);
 extern void cx88_print_ioctl(char *name, unsigned int cmd);
 
+extern void cx88_irq(struct cx88_core *core, u32 status, u32 mask);
+extern void cx88_wakeup(struct cx88_core *core,
+			struct cx88_dmaqueue *q, u32 count);
+extern void cx88_shutdown(struct cx88_core *core);
+extern int cx88_reset(struct cx88_core *core);
+
 extern int
 cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
 		 struct scatterlist *sglist,
 		 unsigned int top_offset, unsigned int bottom_offset,
 		 unsigned int bpl, unsigned int padding, unsigned int lines);
 extern int
+cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
+		     struct scatterlist *sglist, unsigned int bpl,
+		     unsigned int lines);
+extern int
 cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
 		  u32 reg, u32 mask, u32 value);
 extern void
 cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf);
 
-extern void cx88_risc_disasm(struct cx8800_dev *dev,
+extern void cx88_risc_disasm(struct cx88_core *core,
 			     struct btcx_riscmem *risc);
-
-extern int cx88_sram_channel_setup(struct cx8800_dev *dev,
+extern int cx88_sram_channel_setup(struct cx88_core *core,
 				   struct sram_channel *ch,
 				   unsigned int bpl, u32 risc);
-extern void cx88_sram_channel_dump(struct cx8800_dev *dev,
+extern void cx88_sram_channel_dump(struct cx88_core *core,
 				   struct sram_channel *ch);
 
-extern int cx88_pci_quirks(char *name, struct pci_dev *pci,
-			   unsigned int *latency);
+extern int cx88_set_scale(struct cx88_core *core, unsigned int width,
+			  unsigned int height, enum v4l2_field field);
+extern int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm);
+
+extern struct video_device *cx88_vdev_init(struct cx88_core *core,
+					   struct pci_dev *pci,
+					   struct video_device *template,
+					   char *type);
+extern struct cx88_core* cx88_core_get(struct pci_dev *pci);
+extern void cx88_core_put(struct cx88_core *core,
+			  struct pci_dev *pci);
 
 /* ----------------------------------------------------------- */
 /* cx88-vbi.c                                                  */
@@ -334,6 +459,7 @@
 int cx8800_start_vbi_dma(struct cx8800_dev    *dev,
 			 struct cx88_dmaqueue *q,
 			 struct cx88_buffer   *buf);
+int cx8800_stop_vbi_dma(struct cx8800_dev *dev);
 int cx8800_restart_vbi_queue(struct cx8800_dev    *dev,
 			     struct cx88_dmaqueue *q);
 void cx8800_vbi_timeout(unsigned long data);
@@ -343,9 +469,9 @@
 /* ----------------------------------------------------------- */
 /* cx88-i2c.c                                                  */
 
-extern int cx8800_i2c_init(struct cx8800_dev *dev);
-extern void cx8800_call_i2c_clients(struct cx8800_dev *dev,
-				    unsigned int cmd, void *arg);
+extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci);
+extern void cx88_call_i2c_clients(struct cx88_core *core,
+				  unsigned int cmd, void *arg);
 
 
 /* ----------------------------------------------------------- */
@@ -357,8 +483,8 @@
 extern struct cx88_subid cx88_subids[];
 extern const unsigned int cx88_idcount;
 
-extern void cx88_card_list(struct cx8800_dev *dev);
-extern void cx88_card_setup(struct cx8800_dev *dev);
+extern void cx88_card_list(struct cx88_core *core, struct pci_dev *pci);
+extern void cx88_card_setup(struct cx88_core *core);
 
 /* ----------------------------------------------------------- */
 /* cx88-tvaudio.c                                              */
@@ -376,10 +502,23 @@
 #define WW_I2SPT	11
 #define WW_FM		12
 
-void cx88_set_tvaudio(struct cx8800_dev *dev);
-void cx88_get_stereo(struct cx8800_dev *dev, struct v4l2_tuner *t);
-void cx88_set_stereo(struct cx8800_dev *dev, u32 mode);
+void cx88_set_tvaudio(struct cx88_core *core);
+void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t);
+void cx88_set_stereo(struct cx88_core *core, u32 mode);
 int cx88_audio_thread(void *data);
+
+/* ----------------------------------------------------------- */
+/* cx88-mpeg.c                                                 */
+
+int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf);
+void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
+void cx8802_cancel_buffers(struct cx8802_dev *dev);
+
+int cx8802_init_common(struct cx8802_dev *dev);
+void cx8802_fini_common(struct cx8802_dev *dev);
+
+int cx8802_suspend_common(struct pci_dev *pci_dev, u32 state);
+int cx8802_resume_common(struct pci_dev *pci_dev);
 
 /*
  * Local variables:
diff -Nru a/drivers/media/video/dpc7146.c b/drivers/media/video/dpc7146.c
--- a/drivers/media/video/dpc7146.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/media/video/dpc7146.c	2004-12-24 13:36:48 -08:00
@@ -79,8 +79,8 @@
 
 struct dpc
 {
-	struct video_device	video_dev;
-	struct video_device	vbi_dev;
+	struct video_device	*video_dev;
+	struct video_device	*vbi_dev;
 
 	struct i2c_adapter	i2c_adapter;	
 	struct i2c_client	*saa7111a;
@@ -106,7 +106,11 @@
 	   video port pins should be enabled here ?! */
 	saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
 
-	saa7146_i2c_adapter_prepare(dev, &dpc->i2c_adapter, I2C_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480);
+	dpc->i2c_adapter = (struct i2c_adapter) {
+		.class = I2C_CLASS_TV_ANALOG,
+		.name = "dpc7146",
+	};
+	saa7146_i2c_adapter_prepare(dev, &dpc->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
 	if(i2c_add_adapter(&dpc->i2c_adapter) < 0) {
 		DEB_S(("cannot register i2c-device. skipping.\n"));
 		kfree(dpc);
diff -Nru a/drivers/media/video/hexium_gemini.c b/drivers/media/video/hexium_gemini.c
--- a/drivers/media/video/hexium_gemini.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/media/video/hexium_gemini.c	2004-12-24 13:36:31 -08:00
@@ -78,7 +78,8 @@
 struct hexium
 {
 	int type;
-	struct video_device	video_dev;
+
+	struct video_device	*video_dev;
 	struct i2c_adapter	i2c_adapter;
 		
 	int 		cur_input;	/* current input */
@@ -250,7 +251,11 @@
 	/* enable i2c-port pins */
 	saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
 
-	saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, I2C_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480);
+	hexium->i2c_adapter = (struct i2c_adapter) {
+		.class = I2C_CLASS_TV_ANALOG,
+		.name = "hexium gemini",
+	};
+	saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
 	if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
 		DEB_S(("cannot register i2c-device. skipping.\n"));
 		kfree(hexium);
diff -Nru a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c
--- a/drivers/media/video/hexium_orion.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/media/video/hexium_orion.c	2004-12-24 13:37:43 -08:00
@@ -68,8 +68,9 @@
 struct hexium
 {
 	int type;
-	struct video_device	video_dev;
+	struct video_device	*video_dev;
 	struct i2c_adapter	i2c_adapter;	
+
 	int cur_input;	/* current input */
 };
 
@@ -237,7 +238,11 @@
 	saa7146_write(dev, DD1_STREAM_B, 0x00000000);
 	saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
 
-	saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, I2C_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480);
+	hexium->i2c_adapter = (struct i2c_adapter) {
+		.class = I2C_CLASS_TV_ANALOG,
+		.name = "hexium orion",
+	};
+	saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
 	if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
 		DEB_S(("cannot register i2c-device. skipping.\n"));
 		kfree(hexium);
diff -Nru a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c
--- a/drivers/media/video/ir-kbd-gpio.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/video/ir-kbd-gpio.c	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,6 @@
-
 /*
+ * $Id: ir-kbd-gpio.c,v 1.10 2004/09/15 16:15:24 kraxel Exp $
+ *
  * Copyright (c) 2003 Gerd Knorr
  * Copyright (c) 2003 Pavel Machek
  *
@@ -45,7 +46,7 @@
 	[ 60 ] = KEY_KP9,
 
 	[ 48 ] = KEY_EJECTCD,     // Unmarked on my controller
-	[  0 ] = KEY_POWER, 
+	[  0 ] = KEY_POWER,
 	[ 18 ] = BTN_LEFT,        // DISPLAY/L
 	[ 50 ] = BTN_RIGHT,       // LOOP/R
 	[ 10 ] = KEY_MUTE,
@@ -74,6 +75,45 @@
 	[  1 ] = KEY_BLUE,        // unmarked
 };
 
+/* Matt Jesson <dvb@jesson.eclipse.co.uk */
+static IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE] = {
+	[ 0x28 ] = KEY_KP0,         //'0' / 'enter'
+	[ 0x22 ] = KEY_KP1,         //'1'
+	[ 0x12 ] = KEY_KP2,         //'2' / 'up arrow'
+	[ 0x32 ] = KEY_KP3,         //'3'
+	[ 0x24 ] = KEY_KP4,         //'4' / 'left arrow'
+	[ 0x14 ] = KEY_KP5,         //'5'
+	[ 0x34 ] = KEY_KP6,         //'6' / 'right arrow'
+	[ 0x26 ] = KEY_KP7,         //'7'
+	[ 0x16 ] = KEY_KP8,         //'8' / 'down arrow'
+	[ 0x36 ] = KEY_KP9,         //'9'
+
+	[ 0x20 ] = KEY_LIST,        // 'source'
+	[ 0x10 ] = KEY_TEXT,        // 'teletext'
+	[ 0x00 ] = KEY_POWER,       // 'power'
+	[ 0x04 ] = KEY_AUDIO,       // 'audio'
+	[ 0x06 ] = KEY_ZOOM,        // 'full screen'
+	[ 0x18 ] = KEY_VIDEO,       // 'display'
+	[ 0x38 ] = KEY_SEARCH,      // 'loop'
+	[ 0x08 ] = KEY_INFO,        // 'preview'
+	[ 0x2a ] = KEY_REWIND,      // 'backward <<'
+	[ 0x1a ] = KEY_FASTFORWARD, // 'forward >>'
+	[ 0x3a ] = KEY_RECORD,      // 'capture'
+	[ 0x0a ] = KEY_MUTE,        // 'mute'
+	[ 0x2c ] = KEY_RECORD,      // 'record'
+	[ 0x1c ] = KEY_PAUSE,       // 'pause'
+	[ 0x3c ] = KEY_STOP,        // 'stop'
+	[ 0x0c ] = KEY_PLAY,        // 'play'
+	[ 0x2e ] = KEY_RED,         // 'red'
+	[ 0x01 ] = KEY_BLUE,        // 'blue' / 'cancel'
+	[ 0x0e ] = KEY_YELLOW,      // 'yellow' / 'ok'
+	[ 0x21 ] = KEY_GREEN,       // 'green'
+	[ 0x11 ] = KEY_CHANNELDOWN, // 'channel -'
+	[ 0x31 ] = KEY_CHANNELUP,   // 'channel +'
+	[ 0x1e ] = KEY_VOLUMEDOWN,  // 'volume -'
+	[ 0x3e ] = KEY_VOLUMEUP,    // 'volume +'
+};
+
 static IR_KEYTAB_TYPE winfast_codes[IR_KEYTAB_SIZE] = {
 	[  5 ] = KEY_KP1,
 	[  6 ] = KEY_KP2,
@@ -130,7 +170,7 @@
 	[  6 ] = KEY_KP7,
 	[ 10 ] = KEY_KP8,
 	[ 18 ] = KEY_KP9,
-	
+
 	[  3 ] = KEY_TUNER,       // TV/FM
 	[  7 ] = KEY_SEARCH,      // scan
 	[ 28 ] = KEY_ZOOM,        // full screen
@@ -140,7 +180,7 @@
 	[ 20 ] = KEY_CHANNELDOWN,
 	[ 22 ] = KEY_CHANNELUP,
 	[ 24 ] = KEY_MUTE,
-	
+
 	[  0 ] = KEY_LIST,        // source
 	[ 19 ] = KEY_INFO,        // loop
 	[ 16 ] = KEY_LAST,        // +100
@@ -151,6 +191,47 @@
 	[ 15 ] = KEY_STOP,         // freeze
 };
 
+/* Attila Kondoros <attila.kondoros@chello.hu> */
+static IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE] = {
+
+	[  1 ] = KEY_KP1,
+	[  2 ] = KEY_KP2,
+	[  3 ] = KEY_KP3,
+	[  4 ] = KEY_KP4,
+	[  5 ] = KEY_KP5,
+	[  6 ] = KEY_KP6,
+	[  7 ] = KEY_KP7,
+	[  8 ] = KEY_KP8,
+	[  9 ] = KEY_KP9,
+	[  0 ] = KEY_KP0,
+	[ 23 ] = KEY_LAST,        // +100
+	[ 10 ] = KEY_LIST,        // recall
+
+
+	[ 28 ] = KEY_TUNER,       // TV/FM
+	[ 21 ] = KEY_SEARCH,      // scan
+	[ 18 ] = KEY_POWER,       // power
+	[ 31 ] = KEY_VOLUMEDOWN,  // vol up
+	[ 27 ] = KEY_VOLUMEUP,    // vol down
+	[ 30 ] = KEY_CHANNELDOWN, // chn up
+	[ 26 ] = KEY_CHANNELUP,   // chn down
+
+	[ 17 ] = KEY_VIDEO,       // video
+	[ 15 ] = KEY_ZOOM,        // full screen
+	[ 19 ] = KEY_MUTE,        // mute/unmute
+	[ 16 ] = KEY_TEXT,        // min
+
+	[ 13 ] = KEY_STOP,        // freeze
+	[ 14 ] = KEY_RECORD,      // record
+	[ 29 ] = KEY_PLAYPAUSE,   // stop
+	[ 25 ] = KEY_PLAY,        // play
+
+	[ 22 ] = KEY_GOTO,        // osd
+	[ 20 ] = KEY_REFRESH,     // default
+	[ 12 ] = KEY_KPPLUS,      // fine tune >>>>
+	[ 24 ] = KEY_KPMINUS      // fine tune <<<<
+};
+
 /* ---------------------------------------------------------------------- */
 
 struct IR {
@@ -202,7 +283,7 @@
 			return;
 		ir->last_gpio = gpio;
 	}
-	
+
 	/* extract data */
 	data = ir_extract_bits(gpio, ir->mask_keycode);
 	dprintk(DEVNAME ": irq gpio=0x%x code=%d | %s%s%s\n",
@@ -284,6 +365,14 @@
 		ir->polling      = 50; // ms
 		break;
 
+	case BTTV_AVDVBT_761:
+	/* case BTTV_AVDVBT_771: */
+		ir_codes         = ir_codes_avermedia_dvbt;
+		ir->mask_keycode = 0x0f00c0;
+		ir->mask_keydown = 0x000020;
+		ir->polling      = 50; // ms
+		break;
+
 	case BTTV_PXELVWPLTVPAK:
 		ir_codes         = ir_codes_pixelview;
 		ir->mask_keycode = 0x003e00;
@@ -308,6 +397,12 @@
 		ir->mask_keycode = 0x0008e000;
 		ir->mask_keydown = 0x00200000;
 		break;
+	case BTTV_APAC_VIEWCOMP:
+		ir_codes         = ir_codes_apac_viewcomp;
+		ir->mask_keycode = 0x001f00;
+		ir->mask_keyup   = 0x008000;
+		ir->polling      = 50; // ms
+		break;
 	}
 	if (NULL == ir_codes) {
 		kfree(ir);
@@ -317,7 +412,7 @@
 	/* init hardware-specific stuff */
 	bttv_gpio_inout(sub->core, ir->mask_keycode | ir->mask_keydown, 0);
 	ir->sub = sub;
-	
+
 	/* init input device */
 	snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)",
 		 sub->core->type);
diff -Nru a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
--- a/drivers/media/video/ir-kbd-i2c.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/media/video/ir-kbd-i2c.c	2004-12-24 13:36:16 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: ir-kbd-i2c.c,v 1.8 2004/09/15 16:15:24 kraxel Exp $
+ *
  * keyboard input driver for i2c IR remote controls
  *
  * Copyright (c) 2000-2003 Gerd Knorr <kraxel@bytesex.org>
@@ -156,7 +158,7 @@
 static inline int reverse(int data, int bits)
 {
 	int i,c;
-	
+
 	for (c=0,i=0; i<bits; i++) {
 		c |= (((data & (1<<i)) ? 1:0)) << (bits-1-i);
 	}
@@ -193,7 +195,7 @@
 static int get_key_pixelview(struct IR *ir, u32 *ir_key, u32 *ir_raw)
 {
         unsigned char b;
-	
+
 	/* poll IR chip */
 	if (1 != i2c_master_recv(&ir->c,&b,1)) {
 		dprintk(1,"read error\n");
@@ -207,7 +209,7 @@
 static int get_key_pv951(struct IR *ir, u32 *ir_key, u32 *ir_raw)
 {
         unsigned char b;
-	
+
 	/* poll IR chip */
 	if (1 != i2c_master_recv(&ir->c,&b,1)) {
 		dprintk(1,"read error\n");
@@ -218,7 +220,7 @@
 	if (b==0xaa)
 		return 0;
 	dprintk(2,"key %02x\n", b);
-	
+
 	*ir_key = b;
 	*ir_raw = b;
 	return 1;
@@ -227,26 +229,26 @@
 static int get_key_knc1(struct IR *ir, u32 *ir_key, u32 *ir_raw)
 {
 	unsigned char b;
-	
+
 	/* poll IR chip */
 	if (1 != i2c_master_recv(&ir->c,&b,1)) {
 		dprintk(1,"read error\n");
 		return -EIO;
 	}
-	
+
 	/* it seems that 0xFE indicates that a button is still hold
 	   down, while 0xFF indicates that no button is hold
 	   down. 0xFE sequences are sometimes interrupted by 0xFF */
-	
+
 	dprintk(2,"key %02x\n", b);
-	
+
 	if (b == 0xFF)
 		return 0;
-	
+
 	if (b == 0xFE)
 		/* keep old data */
 		return 1;
-	
+
 	*ir_key = b;
 	*ir_raw = b;
 	return 1;
@@ -323,7 +325,7 @@
         .detach_client  = ir_detach,
 };
 
-static struct i2c_client client_template = 
+static struct i2c_client client_template =
 {
         I2C_DEVNAME("unset"),
         .driver = &driver
@@ -336,7 +338,7 @@
 	char *name;
 	int ir_type;
         struct IR *ir;
-		
+
         if (NULL == (ir = kmalloc(sizeof(struct IR),GFP_KERNEL)))
                 return -ENOMEM;
 	memset(ir,0,sizeof(*ir));
@@ -400,14 +402,14 @@
 	input_register_device(&ir->input);
 	printk(DEVNAME ": %s detected at %s [%s]\n",
 	       ir->input.name,ir->input.phys,adap->name);
-	       
+
 	/* start polling via eventd */
 	INIT_WORK(&ir->work, ir_work, ir);
 	init_timer(&ir->timer);
 	ir->timer.function = ir_timer;
 	ir->timer.data     = (unsigned long)ir;
 	schedule_work(&ir->work);
-	
+
 	return 0;
 }
 
@@ -430,16 +432,16 @@
 
 static int ir_probe(struct i2c_adapter *adap)
 {
-	
+
 	/* The external IR receiver is at i2c address 0x34 (0x35 for
 	   reads).  Future Hauppauge cards will have an internal
 	   receiver at 0x30 (0x31 for reads).  In theory, both can be
 	   fitted, and Hauppauge suggest an external overrides an
-	   internal. 
-	   
-	   That's why we probe 0x1a (~0x34) first. CB 
+	   internal.
+
+	   That's why we probe 0x1a (~0x34) first. CB
 	*/
-	
+
 	static const int probe_bttv[] = { 0x1a, 0x18, 0x4b, 0x64, 0x30, -1};
 	static const int probe_saa7134[] = { 0x7a, -1};
 	const int *probe = NULL;
@@ -478,13 +480,12 @@
 MODULE_DESCRIPTION("input driver for i2c IR remote controls");
 MODULE_LICENSE("GPL");
 
-static int ir_init(void)
+static int __init ir_init(void)
 {
-	i2c_add_driver(&driver);
-	return 0;
+	return i2c_add_driver(&driver);
 }
 
-static void ir_fini(void)
+static void __exit ir_fini(void)
 {
 	i2c_del_driver(&driver);
 }
diff -Nru a/drivers/media/video/meye.c b/drivers/media/video/meye.c
--- a/drivers/media/video/meye.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/media/video/meye.c	2004-12-24 13:36:59 -08:00
@@ -1,7 +1,7 @@
-/* 
+/*
  * Motion Eye video4linux driver for Sony Vaio PictureBook
  *
- * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
+ * Copyright (C) 2001-2004 Stelian Pop <stelian@popies.net>
  *
  * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
  *
@@ -11,17 +11,17 @@
  *
  * Some parts borrowed from various video4linux drivers, especially
  * bttv-driver.c and zoran.c, see original files for credits.
- * 
+ *
  * 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.
@@ -39,104 +39,50 @@
 #include <linux/vmalloc.h>
 
 #include "meye.h"
-#include "linux/meye.h"
+#include <linux/meye.h>
+
+MODULE_AUTHOR("Stelian Pop <stelian@popies.net>");
+MODULE_DESCRIPTION("v4l/v4l2 driver for the MotionEye camera");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(MEYE_DRIVER_VERSION);
+
+/* force usage of V4L1 API */
+static int forcev4l1; /* = 0 */
+module_param(forcev4l1, int, 0644);
+MODULE_PARM_DESC(forcev4l1, "force use of V4L1 instead of V4L2");
 
-/* driver structure - only one possible */
-static struct meye meye;
 /* number of grab buffers */
 static unsigned int gbuffers = 2;
+module_param(gbuffers, int, 0444);
+MODULE_PARM_DESC(gbuffers, "number of capture buffers, default is 2 (32 max)");
+
 /* size of a grab buffer */
 static unsigned int gbufsize = MEYE_MAX_BUFSIZE;
+module_param(gbufsize, int, 0444);
+MODULE_PARM_DESC(gbufsize, "size of the capture buffers, default is 614400"
+		 " (will be rounded up to a page multiple)");
+
 /* /dev/videoX registration number */
 static int video_nr = -1;
+module_param(video_nr, int, 0444);
+MODULE_PARM_DESC(video_nr, "video device to register (0=/dev/video0, etc)");
 
-/****************************************************************************/
-/* Queue routines                                                           */
-/****************************************************************************/
-
-/* Inits the queue */
-static inline void meye_initq(struct meye_queue *queue) {
-	queue->head = queue->tail = 0;
-	queue->len = 0;
-	queue->s_lock = SPIN_LOCK_UNLOCKED;
-	init_waitqueue_head(&queue->proc_list);
-}
-
-/* Pulls an element from the queue */
-static inline int meye_pullq(struct meye_queue *queue) {
-	int result;
-	unsigned long flags;
-
-	spin_lock_irqsave(&queue->s_lock, flags);
-	if (!queue->len) {
-		spin_unlock_irqrestore(&queue->s_lock, flags);
-		return -1;
-	}
-	result = queue->buf[queue->head];
-	queue->head++;
-	queue->head &= (MEYE_QUEUE_SIZE - 1);
-	queue->len--;
-	spin_unlock_irqrestore(&queue->s_lock, flags);
-	return result;
-}
-
-/* Pushes an element into the queue */
-static inline void meye_pushq(struct meye_queue *queue, int element) {
-	unsigned long flags;
-
-	spin_lock_irqsave(&queue->s_lock, flags);
-	if (queue->len == MEYE_QUEUE_SIZE) {
-		/* remove the first element */
-		queue->head++;
-		queue->head &= (MEYE_QUEUE_SIZE - 1);
-		queue->len--;
-	}
-	queue->buf[queue->tail] = element;
-	queue->tail++;
-	queue->tail &= (MEYE_QUEUE_SIZE - 1);
-	queue->len++;
-
-	spin_unlock_irqrestore(&queue->s_lock, flags);
-}
-
-/* Tests if the queue is empty */
-static inline int meye_emptyq(struct meye_queue *queue, int *elem) {
-	int result;
-	unsigned long flags;
-
-	spin_lock_irqsave(&queue->s_lock, flags);
-	result = (queue->len == 0);
-	if (!result && elem)
-		*elem = queue->buf[queue->head];
-	spin_unlock_irqrestore(&queue->s_lock, flags);
-	return result;
-}
+/* driver structure - only one possible */
+static struct meye meye;
 
 /****************************************************************************/
 /* Memory allocation routines (stolen from bttv-driver.c)                   */
 /****************************************************************************/
-
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa(unsigned long adr) {
-        unsigned long kva, ret;
-
-        kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-        return ret;
-}
-
-static void *rvmalloc(unsigned long size) {
+static void *rvmalloc(unsigned long size)
+{
 	void *mem;
 	unsigned long adr;
 
 	size = PAGE_ALIGN(size);
 	mem = vmalloc_32(size);
 	if (mem) {
-		memset(mem, 0, size); /* Clear the ram out, no junk to the user */
-	        adr = (unsigned long)mem;
+		memset(mem, 0, size);
+		adr = (unsigned long) mem;
 		while (size > 0) {
 			SetPageReserved(vmalloc_to_page((void *)adr));
 			adr += PAGE_SIZE;
@@ -146,11 +92,12 @@
 	return mem;
 }
 
-static void rvfree(void * mem, unsigned long size) {
-        unsigned long adr;
+static void rvfree(void * mem, unsigned long size)
+{
+	unsigned long adr;
 
 	if (mem) {
-	        adr = (unsigned long) mem;
+		adr = (unsigned long) mem;
 		while ((long) size > 0) {
 			ClearPageReserved(vmalloc_to_page((void *)adr));
 			adr += PAGE_SIZE;
@@ -163,18 +110,20 @@
 /*
  * return a page table pointing to N pages of locked memory
  *
- * NOTE: The meye device expects dma_addr_t size to be 32 bits
- * (the toc must be exactly 1024 entries each of them being 4 bytes
- * in size, the whole result being 4096 bytes). We're using here
- * dma_addr_t for correctness but the compilation of this driver is
- * disabled for HIGHMEM64G=y, where sizeof(dma_addr_t) != 4
+ * NOTE: The meye device expects DMA addresses on 32 bits, we build
+ * a table of 1024 entries = 4 bytes * 1024 = 4096 bytes.
  */
-static int ptable_alloc(void) {
-	dma_addr_t *pt;
+static int ptable_alloc(void)
+{
+	u32 *pt;
 	int i;
 
 	memset(meye.mchip_ptable, 0, sizeof(meye.mchip_ptable));
 
+	/* give only 32 bit DMA addresses */
+	if (dma_set_mask(&meye.mchip_dev->dev, 0xffffffff))
+		return -1;
+
 	meye.mchip_ptable_toc = dma_alloc_coherent(&meye.mchip_dev->dev,
 						   PAGE_SIZE,
 						   &meye.mchip_dmahandle,
@@ -186,17 +135,19 @@
 
 	pt = meye.mchip_ptable_toc;
 	for (i = 0; i < MCHIP_NB_PAGES; i++) {
-		meye.mchip_ptable[i] = dma_alloc_coherent(&meye.mchip_dev->dev, 
+		dma_addr_t dma;
+		meye.mchip_ptable[i] = dma_alloc_coherent(&meye.mchip_dev->dev,
 							  PAGE_SIZE,
-							  pt,
+							  &dma,
 							  GFP_KERNEL);
 		if (!meye.mchip_ptable[i]) {
 			int j;
 			pt = meye.mchip_ptable_toc;
 			for (j = 0; j < i; ++j) {
+				dma = (dma_addr_t) *pt;
 				dma_free_coherent(&meye.mchip_dev->dev,
 						  PAGE_SIZE,
-						  meye.mchip_ptable[j], *pt);
+						  meye.mchip_ptable[j], dma);
 				pt++;
 			}
 			dma_free_coherent(&meye.mchip_dev->dev,
@@ -207,27 +158,30 @@
 			meye.mchip_dmahandle = 0;
 			return -1;
 		}
+		*pt = (u32) dma;
 		pt++;
 	}
 	return 0;
 }
 
-static void ptable_free(void) {
-	dma_addr_t *pt;
+static void ptable_free(void)
+{
+	u32 *pt;
 	int i;
 
 	pt = meye.mchip_ptable_toc;
 	for (i = 0; i < MCHIP_NB_PAGES; i++) {
+		dma_addr_t dma = (dma_addr_t) *pt;
 		if (meye.mchip_ptable[i])
-			dma_free_coherent(&meye.mchip_dev->dev, 
-					  PAGE_SIZE, 
-					  meye.mchip_ptable[i], *pt);
+			dma_free_coherent(&meye.mchip_dev->dev,
+					  PAGE_SIZE,
+					  meye.mchip_ptable[i], dma);
 		pt++;
 	}
 
 	if (meye.mchip_ptable_toc)
-		dma_free_coherent(&meye.mchip_dev->dev, 
-				  PAGE_SIZE, 
+		dma_free_coherent(&meye.mchip_dev->dev,
+				  PAGE_SIZE,
 				  meye.mchip_ptable_toc,
 				  meye.mchip_dmahandle);
 
@@ -237,9 +191,10 @@
 }
 
 /* copy data from ptable into buf */
-static void ptable_copy(u8 *buf, int start, int size, int pt_pages) {
+static void ptable_copy(u8 *buf, int start, int size, int pt_pages)
+{
 	int i;
-	
+
 	for (i = 0; i < (size / PAGE_SIZE) * PAGE_SIZE; i += PAGE_SIZE) {
 		memcpy(buf + i, meye.mchip_ptable[start++], PAGE_SIZE);
 		if (start >= pt_pages)
@@ -248,224 +203,193 @@
 	memcpy(buf + i, meye.mchip_ptable[start], size % PAGE_SIZE);
 }
 
-
 /****************************************************************************/
 /* JPEG tables at different qualities to load into the VRJ chip             */
 /****************************************************************************/
 
 /* return a set of quantisation tables based on a quality from 1 to 10 */
-static u16 *jpeg_quantisation_tables(int *size, int quality) {
-	static u16 tables0[] = {
-		0xdbff, 0x4300, 0xff00, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 
-		0xdbff, 0x4300, 0xff01, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 
-	};
-	static u16 tables1[] = {
-		0xdbff, 0x4300, 0x5000, 0x3c37, 0x3c46, 0x5032, 0x4146, 0x5a46, 
-		0x5055, 0x785f, 0x82c8, 0x6e78, 0x786e, 0xaff5, 0x91b9, 0xffc8, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 
-		0xdbff, 0x4300, 0x5501, 0x5a5a, 0x6978, 0xeb78, 0x8282, 0xffeb, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
-		0xffff, 0xffff, 0xffff, 
-	};
-	static u16 tables2[] = {
-		0xdbff, 0x4300, 0x2800, 0x1e1c, 0x1e23, 0x2819, 0x2123, 0x2d23, 
-		0x282b, 0x3c30, 0x4164, 0x373c, 0x3c37, 0x587b, 0x495d, 0x9164, 
-		0x9980, 0x8f96, 0x8c80, 0xa08a, 0xe6b4, 0xa0c3, 0xdaaa, 0x8aad, 
-		0xc88c, 0xcbff, 0xeeda, 0xfff5, 0xffff, 0xc19b, 0xffff, 0xfaff, 
-		0xe6ff, 0xfffd, 0xfff8, 
-		0xdbff, 0x4300, 0x2b01, 0x2d2d, 0x353c, 0x763c, 0x4141, 0xf876, 
-		0x8ca5, 0xf8a5, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 
-		0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 
-		0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 
-		0xf8f8, 0xf8f8, 0xfff8, 
-	};
-	static u16 tables3[] = {
-		0xdbff, 0x4300, 0x1b00, 0x1412, 0x1417, 0x1b11, 0x1617, 0x1e17, 
-		0x1b1c, 0x2820, 0x2b42, 0x2528, 0x2825, 0x3a51, 0x303d, 0x6042, 
-		0x6555, 0x5f64, 0x5d55, 0x6a5b, 0x9978, 0x6a81, 0x9071, 0x5b73, 
-		0x855d, 0x86b5, 0x9e90, 0xaba3, 0xabad, 0x8067, 0xc9bc, 0xa6ba, 
-		0x99c7, 0xaba8, 0xffa4, 
-		0xdbff, 0x4300, 0x1c01, 0x1e1e, 0x2328, 0x4e28, 0x2b2b, 0xa44e, 
-		0x5d6e, 0xa46e, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 
-		0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 
-		0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 
-		0xa4a4, 0xa4a4, 0xffa4, 
-	};
-	static u16 tables4[] = {
-		0xdbff, 0x4300, 0x1400, 0x0f0e, 0x0f12, 0x140d, 0x1012, 0x1712, 
-		0x1415, 0x1e18, 0x2132, 0x1c1e, 0x1e1c, 0x2c3d, 0x242e, 0x4932, 
-		0x4c40, 0x474b, 0x4640, 0x5045, 0x735a, 0x5062, 0x6d55, 0x4556, 
-		0x6446, 0x6588, 0x776d, 0x817b, 0x8182, 0x604e, 0x978d, 0x7d8c, 
-		0x7396, 0x817e, 0xff7c, 
-		0xdbff, 0x4300, 0x1501, 0x1717, 0x1a1e, 0x3b1e, 0x2121, 0x7c3b, 
-		0x4653, 0x7c53, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 
-		0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 
-		0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 
-		0x7c7c, 0x7c7c, 0xff7c, 
-	};
-	static u16 tables5[] = {
-		0xdbff, 0x4300, 0x1000, 0x0c0b, 0x0c0e, 0x100a, 0x0d0e, 0x120e, 
-		0x1011, 0x1813, 0x1a28, 0x1618, 0x1816, 0x2331, 0x1d25, 0x3a28, 
-		0x3d33, 0x393c, 0x3833, 0x4037, 0x5c48, 0x404e, 0x5744, 0x3745, 
-		0x5038, 0x516d, 0x5f57, 0x6762, 0x6768, 0x4d3e, 0x7971, 0x6470, 
-		0x5c78, 0x6765, 0xff63, 
-		0xdbff, 0x4300, 0x1101, 0x1212, 0x1518, 0x2f18, 0x1a1a, 0x632f, 
-		0x3842, 0x6342, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 
-		0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 
-		0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 
-		0x6363, 0x6363, 0xff63, 
-	};
-	static u16 tables6[] = {
-		0xdbff, 0x4300, 0x0d00, 0x0a09, 0x0a0b, 0x0d08, 0x0a0b, 0x0e0b, 
-		0x0d0e, 0x130f, 0x1520, 0x1213, 0x1312, 0x1c27, 0x171e, 0x2e20, 
-		0x3129, 0x2e30, 0x2d29, 0x332c, 0x4a3a, 0x333e, 0x4636, 0x2c37, 
-		0x402d, 0x4157, 0x4c46, 0x524e, 0x5253, 0x3e32, 0x615a, 0x505a, 
-		0x4a60, 0x5251, 0xff4f, 
-		0xdbff, 0x4300, 0x0e01, 0x0e0e, 0x1113, 0x2613, 0x1515, 0x4f26, 
-		0x2d35, 0x4f35, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 
-		0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 
-		0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 
-		0x4f4f, 0x4f4f, 0xff4f, 
-	};
-	static u16 tables7[] = {
-		0xdbff, 0x4300, 0x0a00, 0x0707, 0x0708, 0x0a06, 0x0808, 0x0b08, 
-		0x0a0a, 0x0e0b, 0x1018, 0x0d0e, 0x0e0d, 0x151d, 0x1116, 0x2318, 
-		0x251f, 0x2224, 0x221f, 0x2621, 0x372b, 0x262f, 0x3429, 0x2129, 
-		0x3022, 0x3141, 0x3934, 0x3e3b, 0x3e3e, 0x2e25, 0x4944, 0x3c43, 
-		0x3748, 0x3e3d, 0xff3b, 
-		0xdbff, 0x4300, 0x0a01, 0x0b0b, 0x0d0e, 0x1c0e, 0x1010, 0x3b1c, 
-		0x2228, 0x3b28, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 
-		0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 
-		0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 
-		0x3b3b, 0x3b3b, 0xff3b, 
-	};
-	static u16 tables8[] = {
-		0xdbff, 0x4300, 0x0600, 0x0504, 0x0506, 0x0604, 0x0506, 0x0706, 
-		0x0607, 0x0a08, 0x0a10, 0x090a, 0x0a09, 0x0e14, 0x0c0f, 0x1710, 
-		0x1814, 0x1718, 0x1614, 0x1a16, 0x251d, 0x1a1f, 0x231b, 0x161c, 
-		0x2016, 0x202c, 0x2623, 0x2927, 0x292a, 0x1f19, 0x302d, 0x282d, 
-		0x2530, 0x2928, 0xff28, 
-		0xdbff, 0x4300, 0x0701, 0x0707, 0x080a, 0x130a, 0x0a0a, 0x2813, 
-		0x161a, 0x281a, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 
-		0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 
-		0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 
-		0x2828, 0x2828, 0xff28, 
-	};
-	static u16 tables9[] = {
-		0xdbff, 0x4300, 0x0300, 0x0202, 0x0203, 0x0302, 0x0303, 0x0403, 
-		0x0303, 0x0504, 0x0508, 0x0405, 0x0504, 0x070a, 0x0607, 0x0c08, 
-		0x0c0a, 0x0b0c, 0x0b0a, 0x0d0b, 0x120e, 0x0d10, 0x110e, 0x0b0e, 
-		0x100b, 0x1016, 0x1311, 0x1514, 0x1515, 0x0f0c, 0x1817, 0x1416, 
-		0x1218, 0x1514, 0xff14, 
-		0xdbff, 0x4300, 0x0301, 0x0404, 0x0405, 0x0905, 0x0505, 0x1409, 
-		0x0b0d, 0x140d, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 
-		0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 
-		0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 
-		0x1414, 0x1414, 0xff14, 
-	};
-	static u16 tables10[] = {
-		0xdbff, 0x4300, 0x0100, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0101, 0x0101, 0xff01, 
-		0xdbff, 0x4300, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0101, 0x0101, 0xff01, 
-	};
-
-	switch (quality) {
-	case 0:
-		*size = sizeof(tables0);
-		return tables0;
-	case 1:
-		*size = sizeof(tables1);
-		return tables1;
-	case 2:
-		*size = sizeof(tables2);
-		return tables2;
-	case 3:
-		*size = sizeof(tables3);
-		return tables3;
-	case 4:
-		*size = sizeof(tables4);
-		return tables4;
-	case 5:
-		*size = sizeof(tables5);
-		return tables5;
-	case 6:
-		*size = sizeof(tables6);
-		return tables6;
-	case 7:
-		*size = sizeof(tables7);
-		return tables7;
-	case 8:
-		*size = sizeof(tables8);
-		return tables8;
-	case 9:
-		*size = sizeof(tables9);
-		return tables9;
-	case 10:
-		*size = sizeof(tables10);
-		return tables10;
-	default:
-		printk(KERN_WARNING "meye: invalid quality level %d - using 8\n", quality);
-		*size = sizeof(tables8);
-		return tables8;
+static u16 *jpeg_quantisation_tables(int *length, int quality)
+{
+	static u16 jpeg_tables[][70] = { {
+		0xdbff, 0x4300, 0xff00, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff,
+		0xdbff, 0x4300, 0xff01, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff,
+	},
+	{
+		0xdbff, 0x4300, 0x5000, 0x3c37, 0x3c46, 0x5032, 0x4146, 0x5a46,
+		0x5055, 0x785f, 0x82c8, 0x6e78, 0x786e, 0xaff5, 0x91b9, 0xffc8,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff,
+		0xdbff, 0x4300, 0x5501, 0x5a5a, 0x6978, 0xeb78, 0x8282, 0xffeb,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+		0xffff, 0xffff, 0xffff,
+	},
+	{
+		0xdbff, 0x4300, 0x2800, 0x1e1c, 0x1e23, 0x2819, 0x2123, 0x2d23,
+		0x282b, 0x3c30, 0x4164, 0x373c, 0x3c37, 0x587b, 0x495d, 0x9164,
+		0x9980, 0x8f96, 0x8c80, 0xa08a, 0xe6b4, 0xa0c3, 0xdaaa, 0x8aad,
+		0xc88c, 0xcbff, 0xeeda, 0xfff5, 0xffff, 0xc19b, 0xffff, 0xfaff,
+		0xe6ff, 0xfffd, 0xfff8,
+		0xdbff, 0x4300, 0x2b01, 0x2d2d, 0x353c, 0x763c, 0x4141, 0xf876,
+		0x8ca5, 0xf8a5, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8,
+		0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8,
+		0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8, 0xf8f8,
+		0xf8f8, 0xf8f8, 0xfff8,
+	},
+	{
+		0xdbff, 0x4300, 0x1b00, 0x1412, 0x1417, 0x1b11, 0x1617, 0x1e17,
+		0x1b1c, 0x2820, 0x2b42, 0x2528, 0x2825, 0x3a51, 0x303d, 0x6042,
+		0x6555, 0x5f64, 0x5d55, 0x6a5b, 0x9978, 0x6a81, 0x9071, 0x5b73,
+		0x855d, 0x86b5, 0x9e90, 0xaba3, 0xabad, 0x8067, 0xc9bc, 0xa6ba,
+		0x99c7, 0xaba8, 0xffa4,
+		0xdbff, 0x4300, 0x1c01, 0x1e1e, 0x2328, 0x4e28, 0x2b2b, 0xa44e,
+		0x5d6e, 0xa46e, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4,
+		0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4,
+		0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4, 0xa4a4,
+		0xa4a4, 0xa4a4, 0xffa4,
+	},
+	{
+		0xdbff, 0x4300, 0x1400, 0x0f0e, 0x0f12, 0x140d, 0x1012, 0x1712,
+		0x1415, 0x1e18, 0x2132, 0x1c1e, 0x1e1c, 0x2c3d, 0x242e, 0x4932,
+		0x4c40, 0x474b, 0x4640, 0x5045, 0x735a, 0x5062, 0x6d55, 0x4556,
+		0x6446, 0x6588, 0x776d, 0x817b, 0x8182, 0x604e, 0x978d, 0x7d8c,
+		0x7396, 0x817e, 0xff7c,
+		0xdbff, 0x4300, 0x1501, 0x1717, 0x1a1e, 0x3b1e, 0x2121, 0x7c3b,
+		0x4653, 0x7c53, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c,
+		0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c,
+		0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c, 0x7c7c,
+		0x7c7c, 0x7c7c, 0xff7c,
+	},
+	{
+		0xdbff, 0x4300, 0x1000, 0x0c0b, 0x0c0e, 0x100a, 0x0d0e, 0x120e,
+		0x1011, 0x1813, 0x1a28, 0x1618, 0x1816, 0x2331, 0x1d25, 0x3a28,
+		0x3d33, 0x393c, 0x3833, 0x4037, 0x5c48, 0x404e, 0x5744, 0x3745,
+		0x5038, 0x516d, 0x5f57, 0x6762, 0x6768, 0x4d3e, 0x7971, 0x6470,
+		0x5c78, 0x6765, 0xff63,
+		0xdbff, 0x4300, 0x1101, 0x1212, 0x1518, 0x2f18, 0x1a1a, 0x632f,
+		0x3842, 0x6342, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363,
+		0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363,
+		0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363, 0x6363,
+		0x6363, 0x6363, 0xff63,
+	},
+	{
+		0xdbff, 0x4300, 0x0d00, 0x0a09, 0x0a0b, 0x0d08, 0x0a0b, 0x0e0b,
+		0x0d0e, 0x130f, 0x1520, 0x1213, 0x1312, 0x1c27, 0x171e, 0x2e20,
+		0x3129, 0x2e30, 0x2d29, 0x332c, 0x4a3a, 0x333e, 0x4636, 0x2c37,
+		0x402d, 0x4157, 0x4c46, 0x524e, 0x5253, 0x3e32, 0x615a, 0x505a,
+		0x4a60, 0x5251, 0xff4f,
+		0xdbff, 0x4300, 0x0e01, 0x0e0e, 0x1113, 0x2613, 0x1515, 0x4f26,
+		0x2d35, 0x4f35, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f,
+		0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f,
+		0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f, 0x4f4f,
+		0x4f4f, 0x4f4f, 0xff4f,
+	},
+	{
+		0xdbff, 0x4300, 0x0a00, 0x0707, 0x0708, 0x0a06, 0x0808, 0x0b08,
+		0x0a0a, 0x0e0b, 0x1018, 0x0d0e, 0x0e0d, 0x151d, 0x1116, 0x2318,
+		0x251f, 0x2224, 0x221f, 0x2621, 0x372b, 0x262f, 0x3429, 0x2129,
+		0x3022, 0x3141, 0x3934, 0x3e3b, 0x3e3e, 0x2e25, 0x4944, 0x3c43,
+		0x3748, 0x3e3d, 0xff3b,
+		0xdbff, 0x4300, 0x0a01, 0x0b0b, 0x0d0e, 0x1c0e, 0x1010, 0x3b1c,
+		0x2228, 0x3b28, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b,
+		0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b,
+		0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b, 0x3b3b,
+		0x3b3b, 0x3b3b, 0xff3b,
+	},
+	{
+		0xdbff, 0x4300, 0x0600, 0x0504, 0x0506, 0x0604, 0x0506, 0x0706,
+		0x0607, 0x0a08, 0x0a10, 0x090a, 0x0a09, 0x0e14, 0x0c0f, 0x1710,
+		0x1814, 0x1718, 0x1614, 0x1a16, 0x251d, 0x1a1f, 0x231b, 0x161c,
+		0x2016, 0x202c, 0x2623, 0x2927, 0x292a, 0x1f19, 0x302d, 0x282d,
+		0x2530, 0x2928, 0xff28,
+		0xdbff, 0x4300, 0x0701, 0x0707, 0x080a, 0x130a, 0x0a0a, 0x2813,
+		0x161a, 0x281a, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828,
+		0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828,
+		0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828, 0x2828,
+		0x2828, 0x2828, 0xff28,
+	},
+	{
+		0xdbff, 0x4300, 0x0300, 0x0202, 0x0203, 0x0302, 0x0303, 0x0403,
+		0x0303, 0x0504, 0x0508, 0x0405, 0x0504, 0x070a, 0x0607, 0x0c08,
+		0x0c0a, 0x0b0c, 0x0b0a, 0x0d0b, 0x120e, 0x0d10, 0x110e, 0x0b0e,
+		0x100b, 0x1016, 0x1311, 0x1514, 0x1515, 0x0f0c, 0x1817, 0x1416,
+		0x1218, 0x1514, 0xff14,
+		0xdbff, 0x4300, 0x0301, 0x0404, 0x0405, 0x0905, 0x0505, 0x1409,
+		0x0b0d, 0x140d, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414,
+		0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414,
+		0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414, 0x1414,
+		0x1414, 0x1414, 0xff14,
+	},
+	{
+		0xdbff, 0x4300, 0x0100, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0101, 0x0101, 0xff01,
+		0xdbff, 0x4300, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0101, 0x0101, 0xff01,
+	} };
+
+	if (quality < 0 || quality > 10) {
+		printk(KERN_WARNING
+		       "meye: invalid quality level %d - using 8\n", quality);
+		quality = 8;
 	}
-	return NULL;
+
+	*length = ARRAY_SIZE(jpeg_tables[quality]);
+	return jpeg_tables[quality];
 }
 
 /* return a generic set of huffman tables */
-static u16 *jpeg_huffman_tables(int *size) {
+static u16 *jpeg_huffman_tables(int *length)
+{
 	static u16 tables[] = {
-		0xC4FF, 0xB500, 0x0010, 0x0102, 0x0303, 0x0402, 0x0503, 0x0405, 
-		0x0004, 0x0100, 0x017D, 0x0302, 0x0400, 0x0511, 0x2112, 0x4131, 
-		0x1306, 0x6151, 0x2207, 0x1471, 0x8132, 0xA191, 0x2308, 0xB142, 
-		0x15C1, 0xD152, 0x24F0, 0x6233, 0x8272, 0x0A09, 0x1716, 0x1918, 
-		0x251A, 0x2726, 0x2928, 0x342A, 0x3635, 0x3837, 0x3A39, 0x4443, 
-		0x4645, 0x4847, 0x4A49, 0x5453, 0x5655, 0x5857, 0x5A59, 0x6463, 
-		0x6665, 0x6867, 0x6A69, 0x7473, 0x7675, 0x7877, 0x7A79, 0x8483, 
-		0x8685, 0x8887, 0x8A89, 0x9392, 0x9594, 0x9796, 0x9998, 0xA29A, 
-		0xA4A3, 0xA6A5, 0xA8A7, 0xAAA9, 0xB3B2, 0xB5B4, 0xB7B6, 0xB9B8, 
-		0xC2BA, 0xC4C3, 0xC6C5, 0xC8C7, 0xCAC9, 0xD3D2, 0xD5D4, 0xD7D6, 
-		0xD9D8, 0xE1DA, 0xE3E2, 0xE5E4, 0xE7E6, 0xE9E8, 0xF1EA, 0xF3F2, 
-		0xF5F4, 0xF7F6, 0xF9F8, 0xFFFA, 
-		0xC4FF, 0xB500, 0x0011, 0x0102, 0x0402, 0x0304, 0x0704, 0x0405, 
-		0x0004, 0x0201, 0x0077, 0x0201, 0x1103, 0x0504, 0x3121, 0x1206, 
-		0x5141, 0x6107, 0x1371, 0x3222, 0x0881, 0x4214, 0xA191, 0xC1B1, 
-		0x2309, 0x5233, 0x15F0, 0x7262, 0x0AD1, 0x2416, 0xE134, 0xF125, 
-		0x1817, 0x1A19, 0x2726, 0x2928, 0x352A, 0x3736, 0x3938, 0x433A, 
-		0x4544, 0x4746, 0x4948, 0x534A, 0x5554, 0x5756, 0x5958, 0x635A, 
-		0x6564, 0x6766, 0x6968, 0x736A, 0x7574, 0x7776, 0x7978, 0x827A, 
-		0x8483, 0x8685, 0x8887, 0x8A89, 0x9392, 0x9594, 0x9796, 0x9998, 
-		0xA29A, 0xA4A3, 0xA6A5, 0xA8A7, 0xAAA9, 0xB3B2, 0xB5B4, 0xB7B6, 
-		0xB9B8, 0xC2BA, 0xC4C3, 0xC6C5, 0xC8C7, 0xCAC9, 0xD3D2, 0xD5D4, 
-		0xD7D6, 0xD9D8, 0xE2DA, 0xE4E3, 0xE6E5, 0xE8E7, 0xEAE9, 0xF3F2, 
-		0xF5F4, 0xF7F6, 0xF9F8, 0xFFFA, 
-		0xC4FF, 0x1F00, 0x0000, 0x0501, 0x0101, 0x0101, 0x0101, 0x0000, 
-		0x0000, 0x0000, 0x0000, 0x0201, 0x0403, 0x0605, 0x0807, 0x0A09, 
-		0xFF0B, 
-		0xC4FF, 0x1F00, 0x0001, 0x0103, 0x0101, 0x0101, 0x0101, 0x0101, 
-		0x0000, 0x0000, 0x0000, 0x0201, 0x0403, 0x0605, 0x0807, 0x0A09, 
+		0xC4FF, 0xB500, 0x0010, 0x0102, 0x0303, 0x0402, 0x0503, 0x0405,
+		0x0004, 0x0100, 0x017D, 0x0302, 0x0400, 0x0511, 0x2112, 0x4131,
+		0x1306, 0x6151, 0x2207, 0x1471, 0x8132, 0xA191, 0x2308, 0xB142,
+		0x15C1, 0xD152, 0x24F0, 0x6233, 0x8272, 0x0A09, 0x1716, 0x1918,
+		0x251A, 0x2726, 0x2928, 0x342A, 0x3635, 0x3837, 0x3A39, 0x4443,
+		0x4645, 0x4847, 0x4A49, 0x5453, 0x5655, 0x5857, 0x5A59, 0x6463,
+		0x6665, 0x6867, 0x6A69, 0x7473, 0x7675, 0x7877, 0x7A79, 0x8483,
+		0x8685, 0x8887, 0x8A89, 0x9392, 0x9594, 0x9796, 0x9998, 0xA29A,
+		0xA4A3, 0xA6A5, 0xA8A7, 0xAAA9, 0xB3B2, 0xB5B4, 0xB7B6, 0xB9B8,
+		0xC2BA, 0xC4C3, 0xC6C5, 0xC8C7, 0xCAC9, 0xD3D2, 0xD5D4, 0xD7D6,
+		0xD9D8, 0xE1DA, 0xE3E2, 0xE5E4, 0xE7E6, 0xE9E8, 0xF1EA, 0xF3F2,
+		0xF5F4, 0xF7F6, 0xF9F8, 0xFFFA,
+		0xC4FF, 0xB500, 0x0011, 0x0102, 0x0402, 0x0304, 0x0704, 0x0405,
+		0x0004, 0x0201, 0x0077, 0x0201, 0x1103, 0x0504, 0x3121, 0x1206,
+		0x5141, 0x6107, 0x1371, 0x3222, 0x0881, 0x4214, 0xA191, 0xC1B1,
+		0x2309, 0x5233, 0x15F0, 0x7262, 0x0AD1, 0x2416, 0xE134, 0xF125,
+		0x1817, 0x1A19, 0x2726, 0x2928, 0x352A, 0x3736, 0x3938, 0x433A,
+		0x4544, 0x4746, 0x4948, 0x534A, 0x5554, 0x5756, 0x5958, 0x635A,
+		0x6564, 0x6766, 0x6968, 0x736A, 0x7574, 0x7776, 0x7978, 0x827A,
+		0x8483, 0x8685, 0x8887, 0x8A89, 0x9392, 0x9594, 0x9796, 0x9998,
+		0xA29A, 0xA4A3, 0xA6A5, 0xA8A7, 0xAAA9, 0xB3B2, 0xB5B4, 0xB7B6,
+		0xB9B8, 0xC2BA, 0xC4C3, 0xC6C5, 0xC8C7, 0xCAC9, 0xD3D2, 0xD5D4,
+		0xD7D6, 0xD9D8, 0xE2DA, 0xE4E3, 0xE6E5, 0xE8E7, 0xEAE9, 0xF3F2,
+		0xF5F4, 0xF7F6, 0xF9F8, 0xFFFA,
+		0xC4FF, 0x1F00, 0x0000, 0x0501, 0x0101, 0x0101, 0x0101, 0x0000,
+		0x0000, 0x0000, 0x0000, 0x0201, 0x0403, 0x0605, 0x0807, 0x0A09,
+		0xFF0B,
+		0xC4FF, 0x1F00, 0x0001, 0x0103, 0x0101, 0x0101, 0x0101, 0x0101,
+		0x0000, 0x0000, 0x0000, 0x0201, 0x0403, 0x0605, 0x0807, 0x0A09,
 		0xFF0B
 	};
 
-	*size = sizeof(tables);
+	*length = ARRAY_SIZE(tables);
 	return tables;
 }
 
@@ -474,23 +398,27 @@
 /****************************************************************************/
 
 /* returns the horizontal capture size */
-static inline int mchip_hsize(void) {
+static inline int mchip_hsize(void)
+{
 	return meye.params.subsample ? 320 : 640;
 }
 
 /* returns the vertical capture size */
-static inline int mchip_vsize(void) {
+static inline int mchip_vsize(void)
+{
 	return meye.params.subsample ? 240 : 480;
 }
 
 /* waits for a register to be available */
-static void mchip_sync(int reg) {
+static void mchip_sync(int reg)
+{
 	u32 status;
 	int i;
 
 	if (reg == MCHIP_MM_FIFO_DATA) {
 		for (i = 0; i < MCHIP_REG_TIMEOUT; i++) {
-			status = readl(meye.mchip_mmregs + MCHIP_MM_FIFO_STATUS);
+			status = readl(meye.mchip_mmregs +
+				       MCHIP_MM_FIFO_STATUS);
 			if (!(status & MCHIP_MM_FIFO_WAIT)) {
 				printk(KERN_WARNING "meye: fifo not ready\n");
 				return;
@@ -499,44 +427,48 @@
 				return;
 			udelay(1);
 		}
-	}
-	else if (reg > 0x80) {
+	} else if (reg > 0x80) {
 		u32 mask = (reg < 0x100) ? MCHIP_HIC_STATUS_MCC_RDY
-			                 : MCHIP_HIC_STATUS_VRJ_RDY;
+					 : MCHIP_HIC_STATUS_VRJ_RDY;
 		for (i = 0; i < MCHIP_REG_TIMEOUT; i++) {
 			status = readl(meye.mchip_mmregs + MCHIP_HIC_STATUS);
 			if (status & mask)
 				return;
 			udelay(1);
 		}
-	}
-	else
+	} else
 		return;
-	printk(KERN_WARNING "meye: mchip_sync() timeout on reg 0x%x status=0x%x\n", reg, status);
+	printk(KERN_WARNING
+	       "meye: mchip_sync() timeout on reg 0x%x status=0x%x\n",
+	       reg, status);
 }
 
 /* sets a value into the register */
-static inline void mchip_set(int reg, u32 v) {
+static inline void mchip_set(int reg, u32 v)
+{
 	mchip_sync(reg);
 	writel(v, meye.mchip_mmregs + reg);
 }
 
 /* get the register value */
-static inline u32 mchip_read(int reg) {
+static inline u32 mchip_read(int reg)
+{
 	mchip_sync(reg);
 	return readl(meye.mchip_mmregs + reg);
 }
 
 /* wait for a register to become a particular value */
-static inline int mchip_delay(u32 reg, u32 v) {
+static inline int mchip_delay(u32 reg, u32 v)
+{
 	int n = 10;
-	while (--n && mchip_read(reg) != v) 
+	while (--n && mchip_read(reg) != v)
 		udelay(1);
 	return n;
 }
 
 /* setup subsampling */
-static void mchip_subsample(void) {
+static void mchip_subsample(void)
+{
 	mchip_set(MCHIP_MCC_R_SAMPLING, meye.params.subsample);
 	mchip_set(MCHIP_MCC_R_XRANGE, mchip_hsize());
 	mchip_set(MCHIP_MCC_R_YRANGE, mchip_vsize());
@@ -546,29 +478,31 @@
 }
 
 /* set the framerate into the mchip */
-static void mchip_set_framerate(void) {
+static void mchip_set_framerate(void)
+{
 	mchip_set(MCHIP_HIC_S_RATE, meye.params.framerate);
 }
 
 /* load some huffman and quantisation tables into the VRJ chip ready
    for JPEG compression */
-static void mchip_load_tables(void) {
+static void mchip_load_tables(void)
+{
 	int i;
-	int size;
+	int length;
 	u16 *tables;
 
-	tables = jpeg_huffman_tables(&size);
-	for (i = 0; i < size / 2; i++)
+	tables = jpeg_huffman_tables(&length);
+	for (i = 0; i < length; i++)
 		writel(tables[i], meye.mchip_mmregs + MCHIP_VRJ_TABLE_DATA);
 
-	tables = jpeg_quantisation_tables(&size, meye.params.quality);
-	for (i = 0; i < size / 2; i++)
+	tables = jpeg_quantisation_tables(&length, meye.params.quality);
+	for (i = 0; i < length; i++)
 		writel(tables[i], meye.mchip_mmregs + MCHIP_VRJ_TABLE_DATA);
 }
 
 /* setup the VRJ parameters in the chip */
-static void mchip_vrj_setup(u8 mode) {
-
+static void mchip_vrj_setup(u8 mode)
+{
 	mchip_set(MCHIP_VRJ_BUS_MODE, 5);
 	mchip_set(MCHIP_VRJ_SIGNAL_ACTIVE_LEVEL, 0x1f);
 	mchip_set(MCHIP_VRJ_PDAT_USE, 1);
@@ -585,23 +519,25 @@
 	mchip_set(MCHIP_VRJ_SOF2, 0x1502);
 	mchip_set(MCHIP_VRJ_SOF3, 0x1503);
 	mchip_set(MCHIP_VRJ_SOF4, 0x1596);
-	mchip_set(MCHIP_VRJ_SOS,  0x0ed0);
+	mchip_set(MCHIP_VRJ_SOS, 0x0ed0);
 
 	mchip_load_tables();
 }
 
 /* sets the DMA parameters into the chip */
-static void mchip_dma_setup(u32 dma_addr) {
+static void mchip_dma_setup(dma_addr_t dma_addr)
+{
 	int i;
 
-	mchip_set(MCHIP_MM_PT_ADDR, dma_addr);
+	mchip_set(MCHIP_MM_PT_ADDR, (u32)dma_addr);
 	for (i = 0; i < 4; i++)
 		mchip_set(MCHIP_MM_FIR(i), 0);
 	meye.mchip_fnum = 0;
 }
 
 /* setup for DMA transfers - also zeros the framebuffer */
-static int mchip_dma_alloc(void) {
+static int mchip_dma_alloc(void)
+{
 	if (!meye.mchip_dmahandle)
 		if (ptable_alloc())
 			return -1;
@@ -609,7 +545,8 @@
 }
 
 /* frees the DMA buffer */
-static void mchip_dma_free(void) {
+static void mchip_dma_free(void)
+{
 	if (meye.mchip_dmahandle) {
 		mchip_dma_setup(0);
 		ptable_free();
@@ -618,7 +555,8 @@
 
 /* stop any existing HIC action and wait for any dma to complete then
    reset the dma engine */
-static void mchip_hic_stop(void) {
+static void mchip_hic_stop(void)
+{
 	int i, j;
 
 	meye.mchip_mode = MCHIP_HIC_MODE_NOOP;
@@ -628,12 +566,13 @@
 		mchip_set(MCHIP_HIC_CMD, MCHIP_HIC_CMD_STOP);
 		mchip_delay(MCHIP_HIC_CMD, 0);
 		for (j = 0; j < 100; ++j) {
-			if (mchip_delay(MCHIP_HIC_STATUS, MCHIP_HIC_STATUS_IDLE))
+			if (mchip_delay(MCHIP_HIC_STATUS,
+					MCHIP_HIC_STATUS_IDLE))
 				return;
 			msleep(1);
 		}
 		printk(KERN_ERR "meye: need to reset HIC!\n");
-	
+
 		mchip_set(MCHIP_HIC_CTL, MCHIP_HIC_CTL_SOFT_RESET);
 		msleep(250);
 	}
@@ -645,15 +584,17 @@
 /****************************************************************************/
 
 /* get the next ready frame from the dma engine */
-static u32 mchip_get_frame(void) {
+static u32 mchip_get_frame(void)
+{
 	u32 v;
-	
+
 	v = mchip_read(MCHIP_MM_FIR(meye.mchip_fnum));
 	return v;
 }
 
 /* frees the current frame from the dma engine */
-static void mchip_free_frame(void) {
+static void mchip_free_frame(void)
+{
 	mchip_set(MCHIP_MM_FIR(meye.mchip_fnum), 0);
 	meye.mchip_fnum++;
 	meye.mchip_fnum %= 4;
@@ -661,17 +602,18 @@
 
 /* read one frame from the framebuffer assuming it was captured using
    a uncompressed transfer */
-static void mchip_cont_read_frame(u32 v, u8 *buf, int size) {
+static void mchip_cont_read_frame(u32 v, u8 *buf, int size)
+{
 	int pt_id;
 
 	pt_id = (v >> 17) & 0x3FF;
 
 	ptable_copy(buf, pt_id, size, MCHIP_NB_PAGES);
-
 }
 
 /* read a compressed frame from the framebuffer */
-static int mchip_comp_read_frame(u32 v, u8 *buf, int size) {
+static int mchip_comp_read_frame(u32 v, u8 *buf, int size)
+{
 	int pt_start, pt_end, trailer;
 	int fsize;
 	int i;
@@ -687,18 +629,17 @@
 		fsize = (pt_end - pt_start) * PAGE_SIZE + trailer * 4;
 
 	if (fsize > size) {
-		printk(KERN_WARNING "meye: oversized compressed frame %d\n", 
+		printk(KERN_WARNING "meye: oversized compressed frame %d\n",
 		       fsize);
 		return -1;
 	}
 
 	ptable_copy(buf, pt_start, fsize, MCHIP_NB_PAGES_MJPEG);
 
-
 #ifdef MEYE_JPEG_CORRECTION
 
 	/* Some mchip generated jpeg frames are incorrect. In most
-	 * (all ?) of those cases, the final EOI (0xff 0xd9) marker 
+	 * (all ?) of those cases, the final EOI (0xff 0xd9) marker
 	 * is not present at the end of the frame.
 	 *
 	 * Since adding the final marker is not enough to restore
@@ -716,9 +657,10 @@
 }
 
 /* take a picture into SDRAM */
-static void mchip_take_picture(void) {
+static void mchip_take_picture(void)
+{
 	int i;
-	
+
 	mchip_hic_stop();
 	mchip_subsample();
 	mchip_dma_setup(meye.mchip_dmahandle);
@@ -736,7 +678,8 @@
 }
 
 /* dma a previously taken picture into a buffer */
-static void mchip_get_picture(u8 *buf, int bufsize) {
+static void mchip_get_picture(u8 *buf, int bufsize)
+{
 	u32 v;
 	int i;
 
@@ -749,7 +692,7 @@
 			break;
 		msleep(1);
 	}
-	for (i = 0; i < 4 ; ++i) {
+	for (i = 0; i < 4; ++i) {
 		v = mchip_get_frame();
 		if (v & MCHIP_MM_FIR_RDY) {
 			mchip_cont_read_frame(v, buf, bufsize);
@@ -760,7 +703,8 @@
 }
 
 /* start continuous dma capture */
-static void mchip_continuous_start(void) {
+static void mchip_continuous_start(void)
+{
 	mchip_hic_stop();
 	mchip_subsample();
 	mchip_set_framerate();
@@ -775,7 +719,8 @@
 }
 
 /* compress one frame into a buffer */
-static int mchip_compress_frame(u8 *buf, int bufsize) {
+static int mchip_compress_frame(u8 *buf, int bufsize)
+{
 	u32 v;
 	int len = -1, i;
 
@@ -784,7 +729,7 @@
 
 	mchip_set(MCHIP_HIC_MODE, MCHIP_HIC_MODE_STILL_COMP);
 	mchip_set(MCHIP_HIC_CMD, MCHIP_HIC_CMD_START);
-	
+
 	mchip_delay(MCHIP_HIC_CMD, 0);
 	for (i = 0; i < 100; ++i) {
 		if (mchip_delay(MCHIP_HIC_STATUS, MCHIP_HIC_STATUS_IDLE))
@@ -792,7 +737,7 @@
 		msleep(1);
 	}
 
-	for (i = 0; i < 4 ; ++i) {
+	for (i = 0; i < 4; ++i) {
 		v = mchip_get_frame();
 		if (v & MCHIP_MM_FIR_RDY) {
 			len = mchip_comp_read_frame(v, buf, bufsize);
@@ -805,13 +750,14 @@
 
 #if 0
 /* uncompress one image into a buffer */
-static int mchip_uncompress_frame(u8 *img, int imgsize, u8 *buf, int bufsize) {
+static int mchip_uncompress_frame(u8 *img, int imgsize, u8 *buf, int bufsize)
+{
 	mchip_vrj_setup(0x3f);
 	udelay(50);
 
 	mchip_set(MCHIP_HIC_MODE, MCHIP_HIC_MODE_STILL_DECOMP);
 	mchip_set(MCHIP_HIC_CMD, MCHIP_HIC_CMD_START);
-	
+
 	mchip_delay(MCHIP_HIC_CMD, 0);
 
 	return mchip_comp_read_frame(buf, bufsize);
@@ -819,7 +765,8 @@
 #endif
 
 /* start continuous compressed capture */
-static void mchip_cont_compression_start(void) {
+static void mchip_cont_compression_start(void)
+{
 	mchip_hic_stop();
 	mchip_vrj_setup(0x3f);
 	mchip_subsample();
@@ -838,88 +785,100 @@
 /* Interrupt handling                                                       */
 /****************************************************************************/
 
-static irqreturn_t meye_irq(int irq, void *dev_id, struct pt_regs *regs) {
+static irqreturn_t meye_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
 	u32 v;
 	int reqnr;
-	v = mchip_read(MCHIP_MM_INTA);
-
-	while (1) {
-		v = mchip_get_frame();
-		if (!(v & MCHIP_MM_FIR_RDY))
-			return IRQ_NONE;
-		switch (meye.mchip_mode) {
-
-		case MCHIP_HIC_MODE_CONT_OUT:
-			if (!meye_emptyq(&meye.grabq, NULL)) {
-				int nr = meye_pullq(&meye.grabq);
-				mchip_cont_read_frame(
-					v, 
-					meye.grab_fbuffer + gbufsize * nr,
-					mchip_hsize() * mchip_vsize() * 2);
-				meye.grab_buffer[nr].state = MEYE_BUF_DONE;
-				wake_up_interruptible(&meye.grabq.proc_list);
-			}
-			break;
-
-		case MCHIP_HIC_MODE_CONT_COMP:
-			if (!meye_emptyq(&meye.grabq, &reqnr)) {
-				int size;
-				size = mchip_comp_read_frame(
-					v,
-					meye.grab_fbuffer + gbufsize * reqnr,
-					gbufsize);
-				if (size == -1)
-					break;
-				reqnr = meye_pullq(&meye.grabq);
-				meye.grab_buffer[reqnr].size = size;
-				meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
-				wake_up_interruptible(&meye.grabq.proc_list);
-			}
-			break;
+	static int sequence = 0;
 
-		default:
-			/* do not free frame, since it can be a snap */
-			return IRQ_NONE;
-		} /* switch */
+	v = mchip_read(MCHIP_MM_INTA);
 
-		mchip_free_frame();
+	if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_OUT &&
+	    meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP)
+		return IRQ_NONE;
+
+again:
+	v = mchip_get_frame();
+	if (!(v & MCHIP_MM_FIR_RDY))
+		return IRQ_HANDLED;
+
+	if (meye.mchip_mode == MCHIP_HIC_MODE_CONT_OUT) {
+		if (kfifo_get(meye.grabq, (unsigned char *)&reqnr,
+			      sizeof(int)) != sizeof(int)) {
+			mchip_free_frame();
+			return IRQ_HANDLED;
+		}
+		mchip_cont_read_frame(v, meye.grab_fbuffer + gbufsize * reqnr,
+				      mchip_hsize() * mchip_vsize() * 2);
+		meye.grab_buffer[reqnr].size = mchip_hsize() * mchip_vsize() * 2;
+		meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
+		do_gettimeofday(&meye.grab_buffer[reqnr].timestamp);
+		meye.grab_buffer[reqnr].sequence = sequence++;
+		kfifo_put(meye.doneq, (unsigned char *)&reqnr, sizeof(int));
+		wake_up_interruptible(&meye.proc_list);
+	} else {
+		int size;
+		size = mchip_comp_read_frame(v, meye.grab_temp, gbufsize);
+		if (size == -1) {
+			mchip_free_frame();
+			goto again;
+		}
+		if (kfifo_get(meye.grabq, (unsigned char *)&reqnr,
+			      sizeof(int)) != sizeof(int)) {
+			mchip_free_frame();
+			goto again;
+		}
+		memcpy(meye.grab_fbuffer + gbufsize * reqnr, meye.grab_temp,
+		       size);
+		meye.grab_buffer[reqnr].size = size;
+		meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
+		do_gettimeofday(&meye.grab_buffer[reqnr].timestamp);
+		meye.grab_buffer[reqnr].sequence = sequence++;
+		kfifo_put(meye.doneq, (unsigned char *)&reqnr, sizeof(int));
+		wake_up_interruptible(&meye.proc_list);
 	}
-	return IRQ_HANDLED;
+	mchip_free_frame();
+	goto again;
 }
 
 /****************************************************************************/
 /* video4linux integration                                                  */
 /****************************************************************************/
 
-static int meye_open(struct inode *inode, struct file *file) {
+static int meye_open(struct inode *inode, struct file *file)
+{
 	int i, err;
 
-	err = video_exclusive_open(inode,file);
+	err = video_exclusive_open(inode, file);
 	if (err < 0)
 		return err;
-			
+
+	mchip_hic_stop();
+
 	if (mchip_dma_alloc()) {
 		printk(KERN_ERR "meye: mchip framebuffer allocation failed\n");
-		video_exclusive_release(inode,file);
+		video_exclusive_release(inode, file);
 		return -ENOBUFS;
 	}
-	mchip_hic_stop();
-	meye_initq(&meye.grabq);
+
 	for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
 		meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
+	kfifo_reset(meye.grabq);
+	kfifo_reset(meye.doneq);
 	return 0;
 }
 
-static int meye_release(struct inode *inode, struct file *file) {
+static int meye_release(struct inode *inode, struct file *file)
+{
 	mchip_hic_stop();
 	mchip_dma_free();
-	video_exclusive_release(inode,file);
+	video_exclusive_release(inode, file);
 	return 0;
 }
 
 static int meye_do_ioctl(struct inode *inode, struct file *file,
-			 unsigned int cmd, void *arg) {
-
+			 unsigned int cmd, void *arg)
+{
 	switch (cmd) {
 
 	case VIDIOCGCAP: {
@@ -961,18 +920,18 @@
 
 	case VIDIOCSPICT: {
 		struct video_picture *p = arg;
-		if (p->depth != 2)
+		if (p->depth != 16)
 			return -EINVAL;
 		if (p->palette != VIDEO_PALETTE_YUV422)
 			return -EINVAL;
 		down(&meye.lock);
-		sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS, 
+		sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS,
 				      p->brightness >> 10);
-		sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE, 
+		sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE,
 				      p->hue >> 10);
-		sonypi_camera_command(SONYPI_COMMAND_SETCAMERACOLOR, 
+		sonypi_camera_command(SONYPI_COMMAND_SETCAMERACOLOR,
 				      p->colour >> 10);
-		sonypi_camera_command(SONYPI_COMMAND_SETCAMERACONTRAST, 
+		sonypi_camera_command(SONYPI_COMMAND_SETCAMERACONTRAST,
 				      p->contrast >> 10);
 		meye.picture = *p;
 		up(&meye.lock);
@@ -981,22 +940,34 @@
 
 	case VIDIOCSYNC: {
 		int *i = arg;
+		int unused;
 
 		if (*i < 0 || *i >= gbuffers)
 			return -EINVAL;
 
+		down(&meye.lock);
+
 		switch (meye.grab_buffer[*i].state) {
 
 		case MEYE_BUF_UNUSED:
+			up(&meye.lock);
 			return -EINVAL;
 		case MEYE_BUF_USING:
-			if (wait_event_interruptible(meye.grabq.proc_list,
-						     (meye.grab_buffer[*i].state != MEYE_BUF_USING)))
+			if (file->f_flags & O_NONBLOCK) {
+				up(&meye.lock);
+				return -EAGAIN;
+			}
+			if (wait_event_interruptible(meye.proc_list,
+						     (meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
+				up(&meye.lock);
 				return -EINTR;
+			}
 			/* fall through */
 		case MEYE_BUF_DONE:
 			meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
+			kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int));
 		}
+		up(&meye.lock);
 		break;
 	}
 
@@ -1021,14 +992,12 @@
 				meye.params.subsample = 0;
 				restart = 1;
 			}
-		}
-		else if (vm->width == 320 && vm->height == 240) {
+		} else if (vm->width == 320 && vm->height == 240) {
 			if (!meye.params.subsample) {
 				meye.params.subsample = 1;
 				restart = 1;
 			}
-		}
-		else {
+		} else {
 			up(&meye.lock);
 			return -EINVAL;
 		}
@@ -1036,7 +1005,7 @@
 		if (restart || meye.mchip_mode != MCHIP_HIC_MODE_CONT_OUT)
 			mchip_continuous_start();
 		meye.grab_buffer[vm->frame].state = MEYE_BUF_USING;
-		meye_pushq(&meye.grabq, vm->frame);
+		kfifo_put(meye.grabq, (unsigned char *)&vm->frame, sizeof(int));
 		up(&meye.lock);
 		break;
 	}
@@ -1087,7 +1056,7 @@
 	case MEYEIOC_QBUF_CAPT: {
 		int *nb = arg;
 
-		if (!meye.grab_fbuffer) 
+		if (!meye.grab_fbuffer)
 			return -EINVAL;
 		if (*nb >= gbuffers)
 			return -EINVAL;
@@ -1102,36 +1071,47 @@
 		if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP)
 			mchip_cont_compression_start();
 		meye.grab_buffer[*nb].state = MEYE_BUF_USING;
-		meye_pushq(&meye.grabq, *nb);
+		kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int));
 		up(&meye.lock);
 		break;
 	}
 
 	case MEYEIOC_SYNC: {
 		int *i = arg;
+		int unused;
 
 		if (*i < 0 || *i >= gbuffers)
 			return -EINVAL;
 
+		down(&meye.lock);
 		switch (meye.grab_buffer[*i].state) {
 
 		case MEYE_BUF_UNUSED:
+			up(&meye.lock);
 			return -EINVAL;
 		case MEYE_BUF_USING:
-			if (wait_event_interruptible(meye.grabq.proc_list,
-						     (meye.grab_buffer[*i].state != MEYE_BUF_USING)))
+			if (file->f_flags & O_NONBLOCK) {
+				up(&meye.lock);
+				return -EAGAIN;
+			}
+			if (wait_event_interruptible(meye.proc_list,
+						     (meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
+				up(&meye.lock);
 				return -EINTR;
+			}
 			/* fall through */
 		case MEYE_BUF_DONE:
 			meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
+			kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int));
 		}
 		*i = meye.grab_buffer[*i].size;
+		up(&meye.lock);
 		break;
 	}
 
 	case MEYEIOC_STILLCAPT: {
 
-		if (!meye.grab_fbuffer) 
+		if (!meye.grab_fbuffer)
 			return -EINVAL;
 		if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED)
 			return -EBUSY;
@@ -1149,7 +1129,7 @@
 	case MEYEIOC_STILLJCAPT: {
 		int *len = arg;
 
-		if (!meye.grab_fbuffer) 
+		if (!meye.grab_fbuffer)
 			return -EINVAL;
 		if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED)
 			return -EBUSY;
@@ -1165,10 +1145,518 @@
 		break;
 	}
 
+	case VIDIOC_QUERYCAP: {
+		struct v4l2_capability *cap = arg;
+
+		if (forcev4l1)
+			return -EINVAL;
+
+		memset(cap, 0, sizeof(*cap));
+		strcpy(cap->driver, "meye");
+		strcpy(cap->card, "meye");
+		sprintf(cap->bus_info, "PCI:%s", meye.mchip_dev->slot_name);
+		cap->version = (MEYE_DRIVER_MAJORVERSION << 8) +
+			       MEYE_DRIVER_MINORVERSION;
+		cap->capabilities = V4L2_CAP_VIDEO_CAPTURE |
+				    V4L2_CAP_STREAMING;
+		break;
+	}
+
+	case VIDIOC_ENUMINPUT: {
+		struct v4l2_input *i = arg;
+
+		if (i->index != 0)
+			return -EINVAL;
+		memset(i, 0, sizeof(*i));
+		i->index = 0;
+		strcpy(i->name, "Camera");
+		i->type = V4L2_INPUT_TYPE_CAMERA;
+		break;
+	}
+
+	case VIDIOC_G_INPUT: {
+		int *i = arg;
+
+		*i = 0;
+		break;
+	}
+
+	case VIDIOC_S_INPUT: {
+		int *i = arg;
+
+		if (*i != 0)
+			return -EINVAL;
+		break;
+	}
+
+	case VIDIOC_QUERYCTRL: {
+		struct v4l2_queryctrl *c = arg;
+
+		switch (c->id) {
+
+		case V4L2_CID_BRIGHTNESS:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "Brightness");
+			c->minimum = 0;
+			c->maximum = 63;
+			c->step = 1;
+			c->default_value = 32;
+			c->flags = 0;
+			break;
+		case V4L2_CID_HUE:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "Hue");
+			c->minimum = 0;
+			c->maximum = 63;
+			c->step = 1;
+			c->default_value = 32;
+			c->flags = 0;
+			break;
+		case V4L2_CID_CONTRAST:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "Contrast");
+			c->minimum = 0;
+			c->maximum = 63;
+			c->step = 1;
+			c->default_value = 32;
+			c->flags = 0;
+			break;
+		case V4L2_CID_SATURATION:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "Saturation");
+			c->minimum = 0;
+			c->maximum = 63;
+			c->step = 1;
+			c->default_value = 32;
+			c->flags = 0;
+			break;
+		case V4L2_CID_AGC:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "Agc");
+			c->minimum = 0;
+			c->maximum = 63;
+			c->step = 1;
+			c->default_value = 48;
+			c->flags = 0;
+			break;
+		case V4L2_CID_SHARPNESS:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "Sharpness");
+			c->minimum = 0;
+			c->maximum = 63;
+			c->step = 1;
+			c->default_value = 32;
+			c->flags = 0;
+			break;
+		case V4L2_CID_PICTURE:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "Picture");
+			c->minimum = 0;
+			c->maximum = 63;
+			c->step = 1;
+			c->default_value = 0;
+			c->flags = 0;
+			break;
+		case V4L2_CID_JPEGQUAL:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "JPEG quality");
+			c->minimum = 0;
+			c->maximum = 10;
+			c->step = 1;
+			c->default_value = 8;
+			c->flags = 0;
+			break;
+		case V4L2_CID_FRAMERATE:
+			c->type = V4L2_CTRL_TYPE_INTEGER;
+			strcpy(c->name, "Framerate");
+			c->minimum = 0;
+			c->maximum = 31;
+			c->step = 1;
+			c->default_value = 0;
+			c->flags = 0;
+			break;
+		default:
+			return -EINVAL;
+		}
+		break;
+	}
+
+	case VIDIOC_S_CTRL: {
+		struct v4l2_control *c = arg;
+
+		down(&meye.lock);
+		switch (c->id) {
+		case V4L2_CID_BRIGHTNESS:
+			sonypi_camera_command(
+				SONYPI_COMMAND_SETCAMERABRIGHTNESS, c->value);
+			meye.picture.brightness = c->value << 10;
+			break;
+		case V4L2_CID_HUE:
+			sonypi_camera_command(
+				SONYPI_COMMAND_SETCAMERAHUE, c->value);
+			meye.picture.hue = c->value << 10;
+			break;
+		case V4L2_CID_CONTRAST:
+			sonypi_camera_command(
+				SONYPI_COMMAND_SETCAMERACONTRAST, c->value);
+			meye.picture.contrast = c->value << 10;
+			break;
+		case V4L2_CID_SATURATION:
+			sonypi_camera_command(
+				SONYPI_COMMAND_SETCAMERACOLOR, c->value);
+			meye.picture.colour = c->value << 10;
+			break;
+		case V4L2_CID_AGC:
+			sonypi_camera_command(
+				SONYPI_COMMAND_SETCAMERAAGC, c->value);
+			meye.params.agc = c->value;
+			break;
+		case V4L2_CID_SHARPNESS:
+			sonypi_camera_command(
+				SONYPI_COMMAND_SETCAMERASHARPNESS, c->value);
+			meye.params.sharpness = c->value;
+			break;
+		case V4L2_CID_PICTURE:
+			sonypi_camera_command(
+				SONYPI_COMMAND_SETCAMERAPICTURE, c->value);
+			meye.params.picture = c->value;
+			break;
+		case V4L2_CID_JPEGQUAL:
+			meye.params.quality = c->value;
+			break;
+		case V4L2_CID_FRAMERATE:
+			meye.params.framerate = c->value;
+			break;
+		default:
+			up(&meye.lock);
+			return -EINVAL;
+		}
+		up(&meye.lock);
+		break;
+	}
+
+	case VIDIOC_G_CTRL: {
+		struct v4l2_control *c = arg;
+
+		down(&meye.lock);
+		switch (c->id) {
+		case V4L2_CID_BRIGHTNESS:
+			c->value = meye.picture.brightness >> 10;
+			break;
+		case V4L2_CID_HUE:
+			c->value = meye.picture.hue >> 10;
+			break;
+		case V4L2_CID_CONTRAST:
+			c->value = meye.picture.contrast >> 10;
+			break;
+		case V4L2_CID_SATURATION:
+			c->value = meye.picture.colour >> 10;
+			break;
+		case V4L2_CID_AGC:
+			c->value = meye.params.agc;
+			break;
+		case V4L2_CID_SHARPNESS:
+			c->value = meye.params.sharpness;
+			break;
+		case V4L2_CID_PICTURE:
+			c->value = meye.params.picture;
+			break;
+		case V4L2_CID_JPEGQUAL:
+			c->value = meye.params.quality;
+			break;
+		case V4L2_CID_FRAMERATE:
+			c->value = meye.params.framerate;
+			break;
+		default:
+			up(&meye.lock);
+			return -EINVAL;
+		}
+		up(&meye.lock);
+		break;
+	}
+
+	case VIDIOC_ENUM_FMT: {
+		struct v4l2_fmtdesc *f = arg;
+
+		if (f->index > 1)
+			return -EINVAL;
+		if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+		if (f->index == 0) {
+			/* standard YUV 422 capture */
+			memset(f, 0, sizeof(*f));
+			f->index = 0;
+			f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+			f->flags = 0;
+			strcpy(f->description, "YUV422");
+			f->pixelformat = V4L2_PIX_FMT_YUYV;
+		} else {
+			/* compressed MJPEG capture */
+			memset(f, 0, sizeof(*f));
+			f->index = 1;
+			f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+			f->flags = V4L2_FMT_FLAG_COMPRESSED;
+			strcpy(f->description, "MJPEG");
+			f->pixelformat = V4L2_PIX_FMT_MJPEG;
+		}
+		break;
+	}
+
+	case VIDIOC_TRY_FMT: {
+		struct v4l2_format *f = arg;
+
+		if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+		if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
+		    f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
+			return -EINVAL;
+		if (f->fmt.pix.field != V4L2_FIELD_ANY &&
+		    f->fmt.pix.field != V4L2_FIELD_NONE)
+			return -EINVAL;
+		f->fmt.pix.field = V4L2_FIELD_NONE;
+		if (f->fmt.pix.width <= 320) {
+			f->fmt.pix.width = 320;
+			f->fmt.pix.height = 240;
+		} else {
+			f->fmt.pix.width = 640;
+			f->fmt.pix.height = 480;
+		}
+		f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
+		f->fmt.pix.sizeimage = f->fmt.pix.height *
+				       f->fmt.pix.bytesperline;
+		f->fmt.pix.colorspace = 0;
+		f->fmt.pix.priv = 0;
+		break;
+	}
+
+	case VIDIOC_G_FMT: {
+		struct v4l2_format *f = arg;
+
+		if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+		memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format));
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		switch (meye.mchip_mode) {
+		case MCHIP_HIC_MODE_CONT_OUT:
+		default:
+			f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
+			break;
+		case MCHIP_HIC_MODE_CONT_COMP:
+			f->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
+			break;
+		}
+		f->fmt.pix.field = V4L2_FIELD_NONE;
+		f->fmt.pix.width = mchip_hsize();
+		f->fmt.pix.height = mchip_vsize();
+		f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
+		f->fmt.pix.sizeimage = f->fmt.pix.height *
+				       f->fmt.pix.bytesperline;
+		f->fmt.pix.colorspace = 0;
+		f->fmt.pix.priv = 0;
+		break;
+	}
+
+	case VIDIOC_S_FMT: {
+		struct v4l2_format *f = arg;
+
+		if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+		if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
+		    f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
+			return -EINVAL;
+		if (f->fmt.pix.field != V4L2_FIELD_ANY &&
+		    f->fmt.pix.field != V4L2_FIELD_NONE)
+			return -EINVAL;
+		f->fmt.pix.field = V4L2_FIELD_NONE;
+		down(&meye.lock);
+		if (f->fmt.pix.width <= 320) {
+			f->fmt.pix.width = 320;
+			f->fmt.pix.height = 240;
+			meye.params.subsample = 1;
+		} else {
+			f->fmt.pix.width = 640;
+			f->fmt.pix.height = 480;
+			meye.params.subsample = 0;
+		}
+		switch (f->fmt.pix.pixelformat) {
+		case V4L2_PIX_FMT_YUYV:
+			meye.mchip_mode = MCHIP_HIC_MODE_CONT_OUT;
+			break;
+		case V4L2_PIX_FMT_MJPEG:
+			meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP;
+			break;
+		}
+		up(&meye.lock);
+		f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
+		f->fmt.pix.sizeimage = f->fmt.pix.height *
+				       f->fmt.pix.bytesperline;
+		f->fmt.pix.colorspace = 0;
+		f->fmt.pix.priv = 0;
+
+		break;
+	}
+
+	case VIDIOC_REQBUFS: {
+		struct v4l2_requestbuffers *req = arg;
+		int i;
+
+		if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+		if (req->memory != V4L2_MEMORY_MMAP)
+			return -EINVAL;
+		if (meye.grab_fbuffer && req->count == gbuffers) {
+			/* already allocated, no modifications */
+			break;
+		}
+		down(&meye.lock);
+		if (meye.grab_fbuffer) {
+			for (i = 0; i < gbuffers; i++)
+				if (meye.vma_use_count[i]) {
+					up(&meye.lock);
+					return -EINVAL;
+				}
+			rvfree(meye.grab_fbuffer, gbuffers * gbufsize);
+			meye.grab_fbuffer = NULL;
+		}
+		gbuffers = max(2, min((int)req->count, MEYE_MAX_BUFNBRS));
+		req->count = gbuffers;
+		meye.grab_fbuffer = rvmalloc(gbuffers * gbufsize);
+		if (!meye.grab_fbuffer) {
+			printk(KERN_ERR "meye: v4l framebuffer allocation"
+					" failed\n");
+			up(&meye.lock);
+			return -ENOMEM;
+		}
+		for (i = 0; i < gbuffers; i++)
+			meye.vma_use_count[i] = 0;
+		up(&meye.lock);
+		break;
+	}
+
+	case VIDIOC_QUERYBUF: {
+		struct v4l2_buffer *buf = arg;
+		int index = buf->index;
+
+		if (index < 0 || index >= gbuffers)
+			return -EINVAL;
+		memset(buf, 0, sizeof(*buf));
+		buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		buf->index = index;
+		buf->bytesused = meye.grab_buffer[index].size;
+		buf->flags = V4L2_BUF_FLAG_MAPPED;
+		if (meye.grab_buffer[index].state == MEYE_BUF_USING)
+			buf->flags |= V4L2_BUF_FLAG_QUEUED;
+		if (meye.grab_buffer[index].state == MEYE_BUF_DONE)
+			buf->flags |= V4L2_BUF_FLAG_DONE;
+		buf->field = V4L2_FIELD_NONE;
+		buf->timestamp = meye.grab_buffer[index].timestamp;
+		buf->sequence = meye.grab_buffer[index].sequence;
+		buf->memory = V4L2_MEMORY_MMAP;
+		buf->m.offset = index * gbufsize;
+		buf->length = gbufsize;
+		break;
+	}
+
+	case VIDIOC_QBUF: {
+		struct v4l2_buffer *buf = arg;
+
+		if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+		if (buf->memory != V4L2_MEMORY_MMAP)
+			return -EINVAL;
+		if (buf->index < 0 || buf->index >= gbuffers)
+			return -EINVAL;
+		if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED)
+			return -EINVAL;
+		down(&meye.lock);
+		buf->flags |= V4L2_BUF_FLAG_QUEUED;
+		buf->flags &= ~V4L2_BUF_FLAG_DONE;
+		meye.grab_buffer[buf->index].state = MEYE_BUF_USING;
+		kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int));
+		up(&meye.lock);
+		break;
+	}
+
+	case VIDIOC_DQBUF: {
+		struct v4l2_buffer *buf = arg;
+		int reqnr;
+
+		if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+		if (buf->memory != V4L2_MEMORY_MMAP)
+			return -EINVAL;
+
+		down(&meye.lock);
+		if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) {
+			up(&meye.lock);
+			return -EAGAIN;
+		}
+		if (wait_event_interruptible(meye.proc_list,
+					     kfifo_len(meye.doneq) != 0) < 0) {
+			up(&meye.lock);
+			return -EINTR;
+		}
+		if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr,
+			       sizeof(int))) {
+			up(&meye.lock);
+			return -EBUSY;
+		}
+		if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) {
+			up(&meye.lock);
+			return -EINVAL;
+		}
+		buf->index = reqnr;
+		buf->bytesused = meye.grab_buffer[reqnr].size;
+		buf->flags = V4L2_BUF_FLAG_MAPPED;
+		buf->field = V4L2_FIELD_NONE;
+		buf->timestamp = meye.grab_buffer[reqnr].timestamp;
+		buf->sequence = meye.grab_buffer[reqnr].sequence;
+		buf->memory = V4L2_MEMORY_MMAP;
+		buf->m.offset = reqnr * gbufsize;
+		buf->length = gbufsize;
+		meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED;
+		up(&meye.lock);
+		break;
+	}
+
+	case VIDIOC_STREAMON: {
+		down(&meye.lock);
+		switch (meye.mchip_mode) {
+		case MCHIP_HIC_MODE_CONT_OUT:
+			mchip_continuous_start();
+			break;
+		case MCHIP_HIC_MODE_CONT_COMP:
+			mchip_cont_compression_start();
+			break;
+		default:
+			up(&meye.lock);
+			return -EINVAL;
+		}
+		up(&meye.lock);
+		break;
+	}
+
+	case VIDIOC_STREAMOFF: {
+		int i;
+
+		down(&meye.lock);
+		mchip_hic_stop();
+		kfifo_reset(meye.grabq);
+		kfifo_reset(meye.doneq);
+		for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
+			meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
+		up(&meye.lock);
+		break;
+	}
+
+	/*
+	 * XXX what about private snapshot ioctls ?
+	 * Do they need to be converted to V4L2 ?
+	*/
+
 	default:
 		return -ENOIOCTLCMD;
-		
-	} /* switch */
+	}
 
 	return 0;
 }
@@ -1179,9 +1667,40 @@
 	return video_usercopy(inode, file, cmd, arg, meye_do_ioctl);
 }
 
-static int meye_mmap(struct file *file, struct vm_area_struct *vma) {
+static unsigned int meye_poll(struct file *file, poll_table *wait)
+{
+	unsigned int res = 0;
+
+	down(&meye.lock);
+	poll_wait(file, &meye.proc_list, wait);
+	if (kfifo_len(meye.doneq))
+		res = POLLIN | POLLRDNORM;
+	up(&meye.lock);
+	return res;
+}
+
+static void meye_vm_open(struct vm_area_struct *vma)
+{
+	int idx = (int)vma->vm_private_data;
+	meye.vma_use_count[idx]++;
+}
+
+static void meye_vm_close(struct vm_area_struct *vma)
+{
+	int idx = (int)vma->vm_private_data;
+	meye.vma_use_count[idx]--;
+}
+
+static struct vm_operations_struct meye_vm_ops = {
+	.open		= meye_vm_open,
+	.close		= meye_vm_close,
+};
+
+static int meye_mmap(struct file *file, struct vm_area_struct *vma)
+{
 	unsigned long start = vma->vm_start;
-	unsigned long size  = vma->vm_end - vma->vm_start;
+	unsigned long size = vma->vm_end - vma->vm_start;
+	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
 	unsigned long page, pos;
 
 	down(&meye.lock);
@@ -1190,6 +1709,8 @@
 		return -EINVAL;
 	}
 	if (!meye.grab_fbuffer) {
+		int i;
+
 		/* lazy allocation */
 		meye.grab_fbuffer = rvmalloc(gbuffers*gbufsize);
 		if (!meye.grab_fbuffer) {
@@ -1197,19 +1718,31 @@
 			up(&meye.lock);
 			return -ENOMEM;
 		}
+		for (i = 0; i < gbuffers; i++)
+			meye.vma_use_count[i] = 0;
 	}
-	pos = (unsigned long)meye.grab_fbuffer;
+	pos = (unsigned long)meye.grab_fbuffer + offset;
 
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
-		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up(&meye.lock);
 			return -EAGAIN;
 		}
 		start += PAGE_SIZE;
 		pos += PAGE_SIZE;
-		size -= PAGE_SIZE;
+		if (size > PAGE_SIZE)
+			size -= PAGE_SIZE;
+		else
+			size = 0;
 	}
+
+	vma->vm_ops = &meye_vm_ops;
+	vma->vm_flags &= ~VM_IO;	/* not I/O memory */
+	vma->vm_flags |= VM_RESERVED;	/* avoid to swap out this VMA */
+	vma->vm_private_data = (void *) (offset / gbufsize);
+	meye_vm_open(vma);
+
 	up(&meye.lock);
 	return 0;
 }
@@ -1220,6 +1753,7 @@
 	.release	= meye_release,
 	.mmap		= meye_mmap,
 	.ioctl		= meye_ioctl,
+	.poll		= meye_poll,
 	.llseek		= no_llseek,
 };
 
@@ -1236,7 +1770,7 @@
 #ifdef CONFIG_PM
 static int meye_suspend(struct pci_dev *pdev, u32 state)
 {
-	pci_save_state(pdev, meye.pm_state);
+	pci_save_state(pdev);
 	meye.pm_mchip_mode = meye.mchip_mode;
 	mchip_hic_stop();
 	mchip_set(MCHIP_MM_INTA, 0x0);
@@ -1245,7 +1779,7 @@
 
 static int meye_resume(struct pci_dev *pdev)
 {
-	pci_restore_state(pdev, meye.pm_state);
+	pci_restore_state(pdev);
 	pci_write_config_word(meye.mchip_dev, MCHIP_PCI_SOFTRESET_SET, 1);
 
 	mchip_delay(MCHIP_HIC_CMD, 0);
@@ -1269,70 +1803,93 @@
 }
 #endif
 
-static int __devinit meye_probe(struct pci_dev *pcidev, 
-		                const struct pci_device_id *ent) {
-	int ret;
+static int __devinit meye_probe(struct pci_dev *pcidev,
+				const struct pci_device_id *ent)
+{
+	int ret = -EBUSY;
 	unsigned long mchip_adr;
 	u8 revision;
 
 	if (meye.mchip_dev != NULL) {
 		printk(KERN_ERR "meye: only one device allowed!\n");
-		ret = -EBUSY;
-		goto out1;
+		goto outnotdev;
 	}
 
 	meye.mchip_dev = pcidev;
 	meye.video_dev = video_device_alloc();
 	if (!meye.video_dev) {
 		printk(KERN_ERR "meye: video_device_alloc() failed!\n");
-		ret = -EBUSY;
-		goto out1;
+		goto outnotdev;
 	}
+
+	ret = -ENOMEM;
+	meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
+	if (!meye.grab_temp) {
+		printk(KERN_ERR "meye: grab buffer allocation failed\n");
+		goto outvmalloc;
+	}
+
+	meye.grabq_lock = SPIN_LOCK_UNLOCKED;
+	meye.grabq = kfifo_alloc(sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL,
+				 &meye.grabq_lock);
+	if (IS_ERR(meye.grabq)) {
+		printk(KERN_ERR "meye: fifo allocation failed\n");
+		goto outkfifoalloc1;
+	}
+	meye.doneq_lock = SPIN_LOCK_UNLOCKED;
+	meye.doneq = kfifo_alloc(sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL,
+				 &meye.doneq_lock);
+	if (IS_ERR(meye.doneq)) {
+		printk(KERN_ERR "meye: fifo allocation failed\n");
+		goto outkfifoalloc2;
+	}
+
 	memcpy(meye.video_dev, &meye_template, sizeof(meye_template));
 	meye.video_dev->dev = &meye.mchip_dev->dev;
 
-	sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1);
+	if ((ret = sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1))) {
+		printk(KERN_ERR "meye: unable to power on the camera\n");
+		printk(KERN_ERR "meye: did you enable the camera in "
+				"sonypi using the module options ?\n");
+		goto outsonypienable;
+	}
 
+	ret = -EIO;
 	if ((ret = pci_enable_device(meye.mchip_dev))) {
 		printk(KERN_ERR "meye: pci_enable_device failed\n");
-		goto out2;
+		goto outenabledev;
 	}
 
-	meye.mchip_irq = pcidev->irq;
 	mchip_adr = pci_resource_start(meye.mchip_dev,0);
 	if (!mchip_adr) {
 		printk(KERN_ERR "meye: mchip has no device base address\n");
-		ret = -EIO;
-		goto out3;
+		goto outregions;
 	}
 	if (!request_mem_region(pci_resource_start(meye.mchip_dev, 0),
-			        pci_resource_len(meye.mchip_dev, 0),
+				pci_resource_len(meye.mchip_dev, 0),
 				"meye")) {
-		ret = -EIO;
 		printk(KERN_ERR "meye: request_mem_region failed\n");
-		goto out3;
+		goto outregions;
+	}
+	meye.mchip_mmregs = ioremap(mchip_adr, MCHIP_MM_REGS);
+	if (!meye.mchip_mmregs) {
+		printk(KERN_ERR "meye: ioremap failed\n");
+		goto outremap;
 	}
 
-	pci_read_config_byte(meye.mchip_dev, PCI_REVISION_ID, &revision);
-
-	pci_set_master(meye.mchip_dev);
+	meye.mchip_irq = pcidev->irq;
+	if (request_irq(meye.mchip_irq, meye_irq,
+			SA_INTERRUPT | SA_SHIRQ, "meye", meye_irq)) {
+		printk(KERN_ERR "meye: request_irq failed\n");
+		goto outreqirq;
+	}
 
+	pci_read_config_byte(meye.mchip_dev, PCI_REVISION_ID, &revision);
 	pci_write_config_byte(meye.mchip_dev, PCI_CACHE_LINE_SIZE, 8);
 	pci_write_config_byte(meye.mchip_dev, PCI_LATENCY_TIMER, 64);
 
-	if ((ret = request_irq(meye.mchip_irq, meye_irq, 
-			       SA_INTERRUPT | SA_SHIRQ, "meye", meye_irq))) {
-		printk(KERN_ERR "meye: request_irq failed (ret=%d)\n", ret);
-		goto out4;
-	}
+	pci_set_master(meye.mchip_dev);
 
-	meye.mchip_mmregs = ioremap(mchip_adr, MCHIP_MM_REGS);
-	if (!meye.mchip_mmregs) {
-		printk(KERN_ERR "meye: ioremap failed\n");
-		ret = -EIO;
-		goto out5;
-	}
-	
 	/* Ask the camera to perform a soft reset. */
 	pci_write_config_word(meye.mchip_dev, MCHIP_PCI_SOFTRESET_SET, 1);
 
@@ -1348,23 +1905,15 @@
 	msleep(1);
 	mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK);
 
-	if (video_register_device(meye.video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
-
+	if (video_register_device(meye.video_dev, VFL_TYPE_GRABBER,
+				  video_nr) < 0) {
 		printk(KERN_ERR "meye: video_register_device failed\n");
-		ret = -EIO;
-		goto out6;
+		goto outvideoreg;
 	}
-	
-	printk(KERN_INFO "meye: Motion Eye Camera Driver v%d.%d.\n",
-	       MEYE_DRIVER_MAJORVERSION,
-	       MEYE_DRIVER_MINORVERSION);
-	printk(KERN_INFO "meye: mchip KL5A72002 rev. %d, base %lx, irq %d\n", 
-		revision, mchip_adr, meye.mchip_irq);
 
-	/* init all fields */
 	init_MUTEX(&meye.lock);
-
-	meye.picture.depth = 2;
+	init_waitqueue_head(&meye.proc_list);
+	meye.picture.depth = 16;
 	meye.picture.palette = VIDEO_PALETTE_YUV422;
 	meye.picture.brightness = 32 << 10;
 	meye.picture.hue = 32 << 10;
@@ -1372,11 +1921,12 @@
 	meye.picture.contrast = 32 << 10;
 	meye.picture.whiteness = 0;
 	meye.params.subsample = 0;
-	meye.params.quality = 7;
+	meye.params.quality = 8;
 	meye.params.sharpness = 32;
 	meye.params.agc = 48;
 	meye.params.picture = 0;
 	meye.params.framerate = 0;
+
 	sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS, 32);
 	sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE, 32);
 	sonypi_camera_command(SONYPI_COMMAND_SETCAMERACOLOR, 32);
@@ -1385,27 +1935,38 @@
 	sonypi_camera_command(SONYPI_COMMAND_SETCAMERAPICTURE, 0);
 	sonypi_camera_command(SONYPI_COMMAND_SETCAMERAAGC, 48);
 
+	printk(KERN_INFO "meye: Motion Eye Camera Driver v%s.\n",
+	       MEYE_DRIVER_VERSION);
+	printk(KERN_INFO "meye: mchip KL5A72002 rev. %d, base %lx, irq %d\n",
+	       revision, mchip_adr, meye.mchip_irq);
+
 	return 0;
-out6:
-	iounmap(meye.mchip_mmregs);
-out5:
+
+outvideoreg:
 	free_irq(meye.mchip_irq, meye_irq);
-out4:
+outreqirq:
+	iounmap(meye.mchip_mmregs);
+outremap:
 	release_mem_region(pci_resource_start(meye.mchip_dev, 0),
 			   pci_resource_len(meye.mchip_dev, 0));
-out3:
+outregions:
 	pci_disable_device(meye.mchip_dev);
-out2:
-	video_device_release(meye.video_dev);
-	meye.video_dev = NULL;
-
+outenabledev:
 	sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 0);
-out1:
+outsonypienable:
+	kfifo_free(meye.doneq);
+outkfifoalloc2:
+	kfifo_free(meye.grabq);
+outkfifoalloc1:
+	vfree(meye.grab_temp);
+outvmalloc:
+	video_device_release(meye.video_dev);
+outnotdev:
 	return ret;
 }
 
-static void __devexit meye_remove(struct pci_dev *pcidev) {
-
+static void __devexit meye_remove(struct pci_dev *pcidev)
+{
 	video_unregister_device(meye.video_dev);
 
 	mchip_hic_stop();
@@ -1424,16 +1985,23 @@
 
 	pci_disable_device(meye.mchip_dev);
 
-	if (meye.grab_fbuffer)
-		rvfree(meye.grab_fbuffer, gbuffers*gbufsize);
-
 	sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 0);
 
+	kfifo_free(meye.doneq);
+	kfifo_free(meye.grabq);
+
+	vfree(meye.grab_temp);
+
+	if (meye.grab_fbuffer) {
+		rvfree(meye.grab_fbuffer, gbuffers*gbufsize);
+		meye.grab_fbuffer = NULL;
+	}
+
 	printk(KERN_INFO "meye: removed\n");
 }
 
 static struct pci_device_id meye_pci_tbl[] = {
-	{ PCI_VENDOR_ID_KAWASAKI, PCI_DEVICE_ID_MCHIP_KL5A72002, 
+	{ PCI_VENDOR_ID_KAWASAKI, PCI_DEVICE_ID_MCHIP_KL5A72002,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
 	{ }
 };
@@ -1451,54 +2019,23 @@
 #endif
 };
 
-static int __init meye_init_module(void) {
-	if (gbuffers < 2)
-		gbuffers = 2;
-	if (gbuffers > MEYE_MAX_BUFNBRS)
-		gbuffers = MEYE_MAX_BUFNBRS;
+static int __init meye_init(void)
+{
+	gbuffers = max(2, min((int)gbuffers, MEYE_MAX_BUFNBRS));
 	if (gbufsize < 0 || gbufsize > MEYE_MAX_BUFSIZE)
 		gbufsize = MEYE_MAX_BUFSIZE;
-	printk(KERN_INFO "meye: using %d buffers with %dk (%dk total) for capture\n",
-	       gbuffers, gbufsize/1024, gbuffers*gbufsize/1024);
-	return pci_module_init(&meye_driver);
+	gbufsize = PAGE_ALIGN(gbufsize);
+	printk(KERN_INFO "meye: using %d buffers with %dk (%dk total)"
+			 "for capture\n",
+			 gbuffers,
+			 gbufsize / 1024, gbuffers * gbufsize / 1024);
+	return pci_register_driver(&meye_driver);
 }
 
-static void __exit meye_cleanup_module(void) {
+static void __exit meye_exit(void)
+{
 	pci_unregister_driver(&meye_driver);
 }
 
-#ifndef MODULE
-static int __init meye_setup(char *str) {
-	int ints[4];
-
-	str = get_options(str, ARRAY_SIZE(ints), ints);
-	if (ints[0] <= 0) 
-		goto out;
-	gbuffers = ints[1];
-	if (ints[0] == 1)
-		goto out;
-	gbufsize = ints[2];
-	if (ints[0] == 2)
-		goto out;
-	video_nr = ints[3];
-out:
-	return 1;
-}
-
-__setup("meye=", meye_setup);
-#endif
-
-MODULE_AUTHOR("Stelian Pop <stelian@popies.net>");
-MODULE_DESCRIPTION("video4linux driver for the MotionEye camera");
-MODULE_LICENSE("GPL");
-
-MODULE_PARM(gbuffers,"i");
-MODULE_PARM_DESC(gbuffers,"number of capture buffers, default is 2 (32 max)");
-MODULE_PARM(gbufsize,"i");
-MODULE_PARM_DESC(gbufsize,"size of the capture buffers, default is 614400");
-MODULE_PARM(video_nr,"i");
-MODULE_PARM_DESC(video_nr,"video device to register (0=/dev/video0, etc)");
-
-/* Module entry points */
-module_init(meye_init_module);
-module_exit(meye_cleanup_module);
+module_init(meye_init);
+module_exit(meye_exit);
diff -Nru a/drivers/media/video/meye.h b/drivers/media/video/meye.h
--- a/drivers/media/video/meye.h	2004-12-24 13:36:55 -08:00
+++ b/drivers/media/video/meye.h	2004-12-24 13:36:55 -08:00
@@ -1,27 +1,27 @@
-/* 
+/*
  * Motion Eye video4linux driver for Sony Vaio PictureBook
  *
- * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
+ * Copyright (C) 2001-2004 Stelian Pop <stelian@popies.net>
  *
  * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
  *
  * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
  *
  * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
- * 
+ *
  * Some parts borrowed from various video4linux drivers, especially
  * bttv-driver.c and zoran.c, see original files for credits.
- * 
+ *
  * 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.
@@ -30,12 +30,16 @@
 #ifndef _MEYE_PRIV_H_
 #define _MEYE_PRIV_H_
 
-#define MEYE_DRIVER_MAJORVERSION	1
-#define MEYE_DRIVER_MINORVERSION	10
+#define MEYE_DRIVER_MAJORVERSION	 1
+#define MEYE_DRIVER_MINORVERSION	13
+
+#define MEYE_DRIVER_VERSION __stringify(MEYE_DRIVER_MAJORVERSION) "." \
+			    __stringify(MEYE_DRIVER_MINORVERSION)
 
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/kfifo.h>
 
 /****************************************************************************/
 /* Motion JPEG chip registers                                               */
@@ -43,7 +47,7 @@
 
 /* Motion JPEG chip PCI configuration registers */
 #define MCHIP_PCI_POWER_CSR		0x54
-#define MCHIP_PCI_MCORE_STATUS		0x60	/* see HIC_STATUS   */
+#define MCHIP_PCI_MCORE_STATUS		0x60		/* see HIC_STATUS   */
 #define MCHIP_PCI_HOSTUSEREQ_SET	0x64
 #define MCHIP_PCI_HOSTUSEREQ_CLR	0x68
 #define MCHIP_PCI_LOWPOWER_SET		0x6c
@@ -73,7 +77,7 @@
 #define MCHIP_MM_INTA_PCI_ERR		0x00000040	/* PCI error */
 #define MCHIP_MM_INTA_PCI_ERR_MASK	0x00004000
 
-#define MCHIP_MM_PT_ADDR		0x08		/* page table address */
+#define MCHIP_MM_PT_ADDR		0x08		/* page table address*/
 							/* n*4kB */
 #define MCHIP_NB_PAGES			1024		/* pages for display */
 #define MCHIP_NB_PAGES_MJPEG		256		/* pages for mjpeg */
@@ -275,47 +279,38 @@
 struct meye_grab_buffer {
 	int state;			/* state of buffer */
 	unsigned long size;		/* size of jpg frame */
+	struct timeval timestamp;	/* timestamp */
+	unsigned long sequence;		/* sequence number */
 };
 
-/* queues containing the buffer indices */
+/* size of kfifos containings buffer indices */
 #define MEYE_QUEUE_SIZE	MEYE_MAX_BUFNBRS
-struct meye_queue {
-	unsigned int head;		/* queue head */
-	unsigned int tail;		/* queue tail */
-	unsigned int len;		/* queue length */
-	spinlock_t s_lock;		/* spinlock protecting the queue */
-	wait_queue_head_t proc_list;	/* wait queue */
-	int buf[MEYE_QUEUE_SIZE];	/* queue contents */
-};
 
 /* Motion Eye device structure */
 struct meye {
-
-	/* mchip related */
 	struct pci_dev *mchip_dev;	/* pci device */
 	u8 mchip_irq;			/* irq */
 	u8 mchip_mode;			/* actual mchip mode: HIC_MODE... */
 	u8 mchip_fnum;			/* current mchip frame number */
-
-	unsigned char *mchip_mmregs;	/* mchip: memory mapped registers */
+	unsigned char __iomem *mchip_mmregs;/* mchip: memory mapped registers */
 	u8 *mchip_ptable[MCHIP_NB_PAGES];/* mchip: ptable */
-	dma_addr_t *mchip_ptable_toc;	/* mchip: ptable toc */
+	void *mchip_ptable_toc;		/* mchip: ptable toc */
 	dma_addr_t mchip_dmahandle;	/* mchip: dma handle to ptable toc */
-
 	unsigned char *grab_fbuffer;	/* capture framebuffer */
+	unsigned char *grab_temp;	/* temporary buffer */
 					/* list of buffers */
 	struct meye_grab_buffer grab_buffer[MEYE_MAX_BUFNBRS];
-
-	/* other */
+	int vma_use_count[MEYE_MAX_BUFNBRS]; /* mmap count */
 	struct semaphore lock;		/* semaphore for open/mmap... */
-
-	struct meye_queue grabq;	/* queue for buffers to be grabbed */
-
+	struct kfifo *grabq;		/* queue for buffers to be grabbed */
+	spinlock_t grabq_lock;		/* lock protecting the queue */
+	struct kfifo *doneq;		/* queue for grabbed buffers */
+	spinlock_t doneq_lock;		/* lock protecting the queue */
+	wait_queue_head_t proc_list;	/* wait queue */
 	struct video_device *video_dev;	/* video device parameters */
 	struct video_picture picture;	/* video picture parameters */
 	struct meye_params params;	/* additional parameters */
 #ifdef CONFIG_PM
-	u32 pm_state[16];		/* PCI configuration space */
 	u8 pm_mchip_mode;		/* old mchip mode */
 #endif
 };
diff -Nru a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
--- a/drivers/media/video/msp3400.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/media/video/msp3400.c	2004-12-24 13:37:00 -08:00
@@ -47,6 +47,8 @@
 #include <linux/videodev.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
+#include <linux/kthread.h>
+#include <linux/suspend.h>
 #include <asm/semaphore.h>
 #include <asm/pgtable.h>
 
@@ -54,54 +56,53 @@
 #include <media/id.h>
 #include "msp3400.h"
 
+#define OPMODE_AUTO    -1
+#define OPMODE_MANUAL   0
+#define OPMODE_SIMPLE   1   /* use short programming (>= msp3410 only) */
+#define OPMODE_SIMPLER  2   /* use shorter programming (>= msp34xxG)   */
+
 /* insmod parameters */
+static int opmode   = OPMODE_AUTO;
 static int debug    = 0;    /* debug output */
 static int once     = 0;    /* no continous stereo monitoring */
 static int amsound  = 0;    /* hard-wire AM sound at 6.5 Hz (france),
-			      the autoscan seems work well only with FM... */
-static int simple   = -1;   /* use short programming (>= msp3410 only) */
+			       the autoscan seems work well only with FM... */
+static int standard = 1;    /* Override auto detect of audio standard, if needed. */
 static int dolby    = 0;
 
-#define DFP_COUNT 0x41
-static const int bl_dfp[] = {
-	0x00, 0x01, 0x02, 0x03,  0x06, 0x08, 0x09, 0x0a,
-	0x0b, 0x0d, 0x0e, 0x10
-};
+static int stereo_threshold = 0x190; /* a2 threshold for stereo/bilingual
+					(msp34xxg only) 0x00a0-0x03c0 */
 
 struct msp3400c {
 	int rev1,rev2;
-	
-	int simple;
+
+	int opmode;
 	int mode;
 	int norm;
-	int stereo;
 	int nicam_on;
 	int acb;
 	int main, second;	/* sound carrier */
 	int input;
+	int source;             /* see msp34xxg_set_source */
+
+	/* v4l2 */
+	int audmode;
+	int rxsubchans;
 
 	int muted;
 	int volume, balance;
 	int bass, treble;
 
-	/* shadow register set */
-	int dfp_regs[DFP_COUNT];
-
 	/* thread */
-	pid_t                tpid;
-	struct completion    texit;
+	struct task_struct   *kthread;
 	wait_queue_head_t    wq;
-
-	int                  active:1;
 	int                  restart:1;
-	int                  rmmod:1;
-
-	int                  watch_stereo;
-	struct timer_list    wake_stereo;
+	int                  watch_stereo:1;
 };
 
 #define HAVE_NICAM(msp)   (((msp->rev2>>8) & 0xff) != 00)
 #define HAVE_SIMPLE(msp)  ((msp->rev1      & 0xff) >= 'D'-'@')
+#define HAVE_SIMPLER(msp) ((msp->rev1      & 0xff) >= 'G'-'@')
 #define HAVE_RADIO(msp)   ((msp->rev1      & 0xff) >= 'G'-'@')
 
 #define VIDEO_MODE_RADIO 16      /* norm magic for radio mode */
@@ -111,11 +112,21 @@
 #define dprintk      if (debug >= 1) printk
 #define d2printk     if (debug >= 2) printk
 
-MODULE_PARM(once,"i");
-MODULE_PARM(debug,"i");
-MODULE_PARM(simple,"i");
-MODULE_PARM(amsound,"i");
-MODULE_PARM(dolby,"i");
+/* read-only */
+module_param(opmode,           int, 0444);
+
+/* read-write */
+module_param(once,             int, 0644);
+module_param(debug,            int, 0644);
+module_param(stereo_threshold, int, 0644);
+module_param(standard,         int, 0644);
+module_param(amsound,          int, 0644);
+module_param(dolby,            int, 0644);
+
+MODULE_PARM_DESC(once, "No continuous stereo monitoring");
+MODULE_PARM_DESC(debug, "Enable debug messages");
+MODULE_PARM_DESC(standard, "Specify audio standard: 32 = NTSC, 64 = radio, Default: Autodetect");
+MODULE_PARM_DESC(amsound, "Hardwire AM sound at 6.5Hz (France), FM can autoscan");
 
 MODULE_DESCRIPTION("device driver for msp34xx TV sound processor");
 MODULE_AUTHOR("Gerd Knorr");
@@ -141,10 +152,6 @@
 /* ----------------------------------------------------------------------- */
 /* functions for talking to the MSP3400C Sound processor                   */
 
-#ifndef I2C_M_IGNORE_NAK
-# define I2C_M_IGNORE_NAK 0x1000
-#endif
-
 static int msp3400c_reset(struct i2c_client *client)
 {
 	/* reset and read revision code */
@@ -160,14 +167,14 @@
 		{ client->addr, 0,        3, write },
 		{ client->addr, I2C_M_RD, 2, read  },
 	};
-	
+
 	if ( (1 != i2c_transfer(client->adapter,&reset[0],1)) ||
 	     (1 != i2c_transfer(client->adapter,&reset[1],1)) ||
 	     (2 != i2c_transfer(client->adapter,test,2)) ) {
 		printk(KERN_ERR "msp3400: chip reset failed\n");
 		return -1;
         }
-	return 0; 
+	return 0;
 }
 
 static int
@@ -191,15 +198,14 @@
 		err++;
 		printk(KERN_WARNING "msp34xx: I/O error #%d (read 0x%02x/0x%02x)\n",
 		       err, dev, addr);
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/10);
+		msleep(10);
 	}
 	if (3 == err) {
 		printk(KERN_WARNING "msp34xx: giving up, reseting chip. Sound will go off, sorry folks :-|\n");
 		msp3400c_reset(client);
 		return -1;
 	}
-        return read[0] << 8 | read[1];
+	return read[0] << 8 | read[1];
 }
 
 static int
@@ -220,8 +226,7 @@
 		err++;
 		printk(KERN_WARNING "msp34xx: I/O error #%d (write 0x%02x/0x%02x)\n",
 		       err, dev, addr);
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/10);
+		msleep(10);
 	}
 	if (3 == err) {
 		printk(KERN_WARNING "msp34xx: giving up, reseting chip. Sound will go off, sorry folks :-|\n");
@@ -305,15 +310,15 @@
 
 static struct CARRIER_DETECT carrier_detect_main[] = {
 	/* main carrier */
-	{ MSP_CARRIER(4.5),        "4.5   NTSC"                   }, 
-	{ MSP_CARRIER(5.5),        "5.5   PAL B/G"                }, 
+	{ MSP_CARRIER(4.5),        "4.5   NTSC"                   },
+	{ MSP_CARRIER(5.5),        "5.5   PAL B/G"                },
 	{ MSP_CARRIER(6.0),        "6.0   PAL I"                  },
 	{ MSP_CARRIER(6.5),        "6.5   PAL D/K + SAT + SECAM"  }
 };
 
 static struct CARRIER_DETECT carrier_detect_55[] = {
 	/* PAL B/G */
-	{ MSP_CARRIER(5.7421875),  "5.742 PAL B/G FM-stereo"     }, 
+	{ MSP_CARRIER(5.7421875),  "5.742 PAL B/G FM-stereo"     },
 	{ MSP_CARRIER(5.85),       "5.85  PAL B/G NICAM"         }
 };
 
@@ -331,16 +336,6 @@
 
 /* ----------------------------------------------------------------------- */
 
-#define SCART_MASK    0
-#define SCART_IN1     1
-#define SCART_IN2     2
-#define SCART_IN1_DA  3
-#define SCART_IN2_DA  4
-#define SCART_IN3     5
-#define SCART_IN4     6
-#define SCART_MONO    7
-#define SCART_MUTE    8
-
 static int scarts[3][9] = {
   /* MASK    IN1     IN2     IN1_DA  IN2_DA  IN3     IN4     MONO    MUTE   */
   {  0x0320, 0x0000, 0x0200, -1,     -1,     0x0300, 0x0020, 0x0100, 0x0320 },
@@ -394,8 +389,8 @@
 		muted ? "on" : "off", volume, balance, val>>8, bal);
 	msp3400c_write(client,I2C_MSP3400C_DFP, 0x0000, val); /* loudspeaker */
 	msp3400c_write(client,I2C_MSP3400C_DFP, 0x0006, val); /* headphones  */
-	/* scart - on/off only */
-	msp3400c_write(client,I2C_MSP3400C_DFP, 0x0007, val ? 0x4000 : 0);
+	msp3400c_write(client,I2C_MSP3400C_DFP, 0x0007,
+		       muted ? 0x01 : (val | 0x01));
 	msp3400c_write(client,I2C_MSP3400C_DFP, 0x0001, bal << 8);
 }
 
@@ -419,31 +414,32 @@
 {
 	struct msp3400c *msp = i2c_get_clientdata(client);
 	int i;
-	
+
 	dprintk(KERN_DEBUG "msp3400: setmode: %d\n",type);
-	msp->mode   = type;
-	msp->stereo = VIDEO_SOUND_MONO;
+	msp->mode       = type;
+	msp->audmode    = V4L2_TUNER_MODE_MONO;
+	msp->rxsubchans = V4L2_TUNER_SUB_MONO;
 
 	msp3400c_write(client,I2C_MSP3400C_DEM, 0x00bb,          /* ad_cv */
 		       msp_init_data[type].ad_cv);
-    
+
 	for (i = 5; i >= 0; i--)                                   /* fir 1 */
 		msp3400c_write(client,I2C_MSP3400C_DEM, 0x0001,
 			       msp_init_data[type].fir1[i]);
-    
+
 	msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0004); /* fir 2 */
 	msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0040);
 	msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0000);
 	for (i = 5; i >= 0; i--)
 		msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005,
 			       msp_init_data[type].fir2[i]);
-    
+
 	msp3400c_write(client,I2C_MSP3400C_DEM, 0x0083,     /* MODE_REG */
 		       msp_init_data[type].mode_reg);
-    
+
 	msp3400c_setcarrier(client, msp_init_data[type].cdo1,
 			    msp_init_data[type].cdo2);
-    
+
 	msp3400c_write(client,I2C_MSP3400C_DEM, 0x0056, 0); /*LOAD_REG_1/2*/
 
 	if (dolby) {
@@ -472,51 +468,67 @@
 	}
 }
 
+static int best_audio_mode(int rxsubchans)
+{
+	if (rxsubchans & V4L2_TUNER_SUB_STEREO)
+		return V4L2_TUNER_MODE_STEREO;
+	if (rxsubchans & V4L2_TUNER_SUB_LANG1)
+		return V4L2_TUNER_MODE_LANG1;
+	if (rxsubchans & V4L2_TUNER_SUB_LANG2)
+		return V4L2_TUNER_MODE_LANG2;
+	return V4L2_TUNER_MODE_MONO;
+}
+
 /* turn on/off nicam + stereo */
-static void msp3400c_setstereo(struct i2c_client *client, int mode)
+static void msp3400c_set_audmode(struct i2c_client *client, int audmode)
 {
 	static char *strmode[16] = {
 #if __GNUC__ >= 3
-		[ 0 ... 15 ]           = "invalid",
+		[ 0 ... 15 ]               = "invalid",
 #endif
-		[ VIDEO_SOUND_MONO ]   = "mono",
-		[ VIDEO_SOUND_STEREO ] = "stereo",
-		[ VIDEO_SOUND_LANG1  ] = "lang1",
-		[ VIDEO_SOUND_LANG2  ] = "lang2",
+		[ V4L2_TUNER_MODE_MONO   ] = "mono",
+		[ V4L2_TUNER_MODE_STEREO ] = "stereo",
+		[ V4L2_TUNER_MODE_LANG1  ] = "lang1",
+		[ V4L2_TUNER_MODE_LANG2  ] = "lang2",
 	};
 	struct msp3400c *msp = i2c_get_clientdata(client);
 	int nicam=0; /* channel source: FM/AM or nicam */
 	int src=0;
 
+	BUG_ON(msp->opmode == OPMODE_SIMPLER);
+	msp->audmode = audmode;
+
 	/* switch demodulator */
 	switch (msp->mode) {
 	case MSP_MODE_FM_TERRA:
-		dprintk(KERN_DEBUG "msp3400: FM setstereo: %s\n",strmode[mode]);
+		dprintk(KERN_DEBUG "msp3400: FM setstereo: %s\n",
+			strmode[audmode]);
 		msp3400c_setcarrier(client,msp->second,msp->main);
-		switch (mode) {
-		case VIDEO_SOUND_STEREO:
+		switch (audmode) {
+		case V4L2_TUNER_MODE_STEREO:
 			msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3001);
 			break;
-		case VIDEO_SOUND_MONO:
-		case VIDEO_SOUND_LANG1:
-		case VIDEO_SOUND_LANG2:
+		case V4L2_TUNER_MODE_MONO:
+		case V4L2_TUNER_MODE_LANG1:
+		case V4L2_TUNER_MODE_LANG2:
 			msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3000);
 			break;
 		}
 		break;
 	case MSP_MODE_FM_SAT:
-		dprintk(KERN_DEBUG "msp3400: SAT setstereo: %s\n",strmode[mode]);
-		switch (mode) {
-		case VIDEO_SOUND_MONO:
+		dprintk(KERN_DEBUG "msp3400: SAT setstereo: %s\n",
+			strmode[audmode]);
+		switch (audmode) {
+		case V4L2_TUNER_MODE_MONO:
 			msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
 			break;
-		case VIDEO_SOUND_STEREO:
+		case V4L2_TUNER_MODE_STEREO:
 			msp3400c_setcarrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02));
 			break;
-		case VIDEO_SOUND_LANG1:
+		case V4L2_TUNER_MODE_LANG1:
 			msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02));
 			break;
-		case VIDEO_SOUND_LANG2:
+		case V4L2_TUNER_MODE_LANG2:
 			msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02));
 			break;
 		}
@@ -524,21 +536,25 @@
 	case MSP_MODE_FM_NICAM1:
 	case MSP_MODE_FM_NICAM2:
 	case MSP_MODE_AM_NICAM:
-		dprintk(KERN_DEBUG "msp3400: NICAM setstereo: %s\n",strmode[mode]);
+		dprintk(KERN_DEBUG "msp3400: NICAM setstereo: %s\n",
+			strmode[audmode]);
 		msp3400c_setcarrier(client,msp->second,msp->main);
 		if (msp->nicam_on)
 			nicam=0x0100;
 		break;
 	case MSP_MODE_BTSC:
-		dprintk(KERN_DEBUG "msp3400: BTSC setstereo: %s\n",strmode[mode]);
+		dprintk(KERN_DEBUG "msp3400: BTSC setstereo: %s\n",
+			strmode[audmode]);
 		nicam=0x0300;
 		break;
 	case MSP_MODE_EXTERN:
-		dprintk(KERN_DEBUG "msp3400: extern setstereo: %s\n",strmode[mode]);
+		dprintk(KERN_DEBUG "msp3400: extern setstereo: %s\n",
+			strmode[audmode]);
 		nicam = 0x0200;
 		break;
 	case MSP_MODE_FM_RADIO:
-		dprintk(KERN_DEBUG "msp3400: FM-Radio setstereo: %s\n",strmode[mode]);
+		dprintk(KERN_DEBUG "msp3400: FM-Radio setstereo: %s\n",
+			strmode[audmode]);
 		break;
 	default:
 		dprintk(KERN_DEBUG "msp3400: mono setstereo\n");
@@ -546,15 +562,15 @@
 	}
 
 	/* switch audio */
-	switch (mode) {
-	case VIDEO_SOUND_STEREO:
+	switch (audmode) {
+	case V4L2_TUNER_MODE_STEREO:
 		src = 0x0020 | nicam;
-#if 0 
+#if 0
 		/* spatial effect */
 		msp3400c_write(client,I2C_MSP3400C_DFP, 0x0005,0x4000);
 #endif
 		break;
-	case VIDEO_SOUND_MONO:
+	case V4L2_TUNER_MODE_MONO:
 		if (msp->mode == MSP_MODE_AM_NICAM) {
 			dprintk("msp3400: switching to AM mono\n");
 			/* AM mono decoding is handled by tuner, not MSP chip */
@@ -563,10 +579,10 @@
 			src = 0x0200;
 			break;
 		}
-	case VIDEO_SOUND_LANG1:
+	case V4L2_TUNER_MODE_LANG1:
 		src = 0x0000 | nicam;
 		break;
-	case VIDEO_SOUND_LANG2:
+	case V4L2_TUNER_MODE_LANG2:
 		src = 0x0010 | nicam;
 		break;
 	}
@@ -610,19 +626,6 @@
 	}
 }
 
-static void
-msp3400c_restore_dfp(struct i2c_client *client)
-{
-	struct msp3400c *msp = i2c_get_clientdata(client);
-	int i;
-
-	for (i = 0; i < DFP_COUNT; i++) {
-		if (-1 == msp->dfp_regs[i])
-			continue;
-		msp3400c_write(client,I2C_MSP3400C_DFP, i, msp->dfp_regs[i]);
-	}
-}
-
 /* ----------------------------------------------------------------------- */
 
 struct REGISTER_DUMP {
@@ -643,8 +646,8 @@
 {
 	struct msp3400c *msp = i2c_get_clientdata(client);
 	int val;
-	int newstereo = msp->stereo;
-	int newnicam  = msp->nicam_on;
+	int rxsubchans = msp->rxsubchans;
+	int newnicam   = msp->nicam_on;
 	int update = 0;
 
 	switch (msp->mode) {
@@ -655,11 +658,11 @@
 		dprintk(KERN_DEBUG
 			"msp34xx: stereo detect register: %d\n",val);
 		if (val > 4096) {
-			newstereo = VIDEO_SOUND_STEREO | VIDEO_SOUND_MONO;
+			rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO;
 		} else if (val < -4096) {
-			newstereo = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
+			rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
 		} else {
-			newstereo = VIDEO_SOUND_MONO;
+			rxsubchans = V4L2_TUNER_SUB_MONO;
 		}
 		newnicam = 0;
 		break;
@@ -676,27 +679,27 @@
 			switch ((val & 0x1e) >> 1)  {
 			case 0:
 			case 8:
-				newstereo = VIDEO_SOUND_STEREO;
+				rxsubchans = V4L2_TUNER_SUB_STEREO;
 				break;
 			case 1:
 			case 9:
-				newstereo = VIDEO_SOUND_MONO
-					| VIDEO_SOUND_LANG1;
+				rxsubchans = V4L2_TUNER_SUB_MONO
+					| V4L2_TUNER_SUB_LANG1;
 				break;
 			case 2:
 			case 10:
-				newstereo = VIDEO_SOUND_MONO
-					| VIDEO_SOUND_LANG1
-					| VIDEO_SOUND_LANG2;
+				rxsubchans = V4L2_TUNER_SUB_MONO
+					| V4L2_TUNER_SUB_LANG1
+					| V4L2_TUNER_SUB_LANG2;
 				break;
 			default:
-				newstereo = VIDEO_SOUND_MONO;
+				rxsubchans = V4L2_TUNER_SUB_MONO;
 				break;
 			}
 			newnicam=1;
 		} else {
 			newnicam = 0;
-			newstereo = VIDEO_SOUND_MONO;
+			rxsubchans = V4L2_TUNER_SUB_MONO;
 		}
 		break;
 	case MSP_MODE_BTSC:
@@ -709,16 +712,16 @@
 			(val & 0x0040) ? "stereo" : "mono",
 			(val & 0x0080) ? ", nicam 2nd mono" : "",
 			(val & 0x0100) ? ", bilingual/SAP"  : "");
-		newstereo = VIDEO_SOUND_MONO;
-		if (val & 0x0040) newstereo |= VIDEO_SOUND_STEREO;
-		if (val & 0x0100) newstereo |= VIDEO_SOUND_LANG1;
+		rxsubchans = V4L2_TUNER_SUB_MONO;
+		if (val & 0x0040) rxsubchans |= V4L2_TUNER_SUB_STEREO;
+		if (val & 0x0100) rxsubchans |= V4L2_TUNER_SUB_LANG1;
 		break;
 	}
-	if (newstereo != msp->stereo) {
+	if (rxsubchans != msp->rxsubchans) {
 		update = 1;
-		dprintk(KERN_DEBUG "msp34xx: watch: stereo %d => %d\n",
-			msp->stereo,newstereo);
-		msp->stereo   = newstereo;
+		dprintk(KERN_DEBUG "msp34xx: watch: rxsubchans %d => %d\n",
+			msp->rxsubchans,rxsubchans);
+		msp->rxsubchans = rxsubchans;
 	}
 	if (newnicam != msp->nicam_on) {
 		update = 1;
@@ -739,22 +742,24 @@
 	DECLARE_WAITQUEUE(wait, current);
 
 	add_wait_queue(&msp->wq, &wait);
-	if (!msp->rmmod) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (timeout < 0)
+	if (!kthread_should_stop()) {
+		if (timeout < 0) {
+			set_current_state(TASK_INTERRUPTIBLE);
 			schedule();
-		else
-			schedule_timeout(timeout);
+		} else {
+#if 0
+			/* hmm, that one doesn't return on wakeup ... */
+			msleep_interruptible(timeout);
+#else
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(msecs_to_jiffies(timeout));
+#endif
+		}
 	}
+	if (current->flags & PF_FREEZE)
+		refrigerator(PF_FREEZE);
 	remove_wait_queue(&msp->wq, &wait);
-	return msp->rmmod || signal_pending(current);
-}
-
-static void msp3400c_stereo_wake(unsigned long data)
-{
-	struct msp3400c *msp = (struct msp3400c*)data;   /* XXX alpha ??? */
-
-	wake_up_interruptible(&msp->wq);
+	return msp->restart;
 }
 
 /* stereo/multilang monitoring */
@@ -762,53 +767,31 @@
 {
 	struct msp3400c *msp = i2c_get_clientdata(client);
 
-	if (autodetect_stereo(client)) {
-		if (msp->stereo & VIDEO_SOUND_STEREO)
-			msp3400c_setstereo(client,VIDEO_SOUND_STEREO);
-		else if (msp->stereo & VIDEO_SOUND_LANG1)
-			msp3400c_setstereo(client,VIDEO_SOUND_LANG1);
-		else if (msp->stereo & VIDEO_SOUND_LANG2)
-			msp3400c_setstereo(client,VIDEO_SOUND_LANG2);
-		else
-			msp3400c_setstereo(client,VIDEO_SOUND_MONO);
-	}
+	if (autodetect_stereo(client))
+		msp3400c_set_audmode(client,best_audio_mode(msp->rxsubchans));
 	if (once)
 		msp->watch_stereo = 0;
-	if (msp->watch_stereo)
-		mod_timer(&msp->wake_stereo, jiffies+5*HZ);
 }
 
 static int msp3400c_thread(void *data)
 {
 	struct i2c_client *client = data;
 	struct msp3400c *msp = i2c_get_clientdata(client);
-	
 	struct CARRIER_DETECT *cd;
 	int count, max1,max2,val1,val2, val,this;
-	
-	daemonize("msp3400");
-	allow_signal(SIGTERM);
-	printk("msp3400: daemon started\n");
 
+	printk("msp3400: kthread started\n");
 	for (;;) {
 		d2printk("msp3400: thread: sleep\n");
-		if (msp34xx_sleep(msp,-1))
-			goto done;
-
+		msp34xx_sleep(msp,-1);
 		d2printk("msp3400: thread: wakeup\n");
-		msp->active = 1;
 
-		if (msp->watch_stereo) {
-			watch_stereo(client);
-			msp->active = 0;
-			continue;
-		}
-
-		/* some time for the tuner to sync */
-		if (msp34xx_sleep(msp,HZ/5))
-			goto done;
-		
 	restart:
+		dprintk("msp3410: thread: restart scan\n");
+		msp->restart = 0;
+		if (kthread_should_stop())
+			break;
+
 		if (VIDEO_MODE_RADIO == msp->norm ||
 		    MSP_MODE_EXTERN  == msp->mode) {
 			/* no carrier scan, just unmute */
@@ -817,14 +800,18 @@
 					   msp->volume, msp->balance);
 			continue;
 		}
-		msp->restart = 0;
+
+		/* mute */
 		msp3400c_setvolume(client, msp->muted, 0, 0);
 		msp3400c_setmode(client, MSP_MODE_AM_DETECT /* +1 */ );
 		val1 = val2 = 0;
 		max1 = max2 = -1;
-		del_timer(&msp->wake_stereo);
 		msp->watch_stereo = 0;
 
+		/* some time for the tuner to sync */
+		if (msp34xx_sleep(msp,200))
+			goto restart;
+
 		/* carrier detect pass #1 -- main carrier */
 		cd = carrier_detect_main; count = CARRIER_COUNT(carrier_detect_main);
 
@@ -837,12 +824,8 @@
 
 		for (this = 0; this < count; this++) {
 			msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo);
-
-			if (msp34xx_sleep(msp,HZ/10))
-				goto done;
-			if (msp->restart)
-				msp->restart = 0;
-
+			if (msp34xx_sleep(msp,100))
+				goto restart;
 			val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b);
 			if (val > 32767)
 				val -= 65536;
@@ -850,14 +833,16 @@
 				val1 = val, max1 = this;
 			dprintk("msp3400: carrier1 val: %5d / %s\n", val,cd[this].name);
 		}
-	
+
 		/* carrier detect pass #2 -- second (stereo) carrier */
 		switch (max1) {
 		case 1: /* 5.5 */
-			cd = carrier_detect_55; count = CARRIER_COUNT(carrier_detect_55);
+			cd = carrier_detect_55;
+			count = CARRIER_COUNT(carrier_detect_55);
 			break;
 		case 3: /* 6.5 */
-			cd = carrier_detect_65; count = CARRIER_COUNT(carrier_detect_65);
+			cd = carrier_detect_65;
+			count = CARRIER_COUNT(carrier_detect_65);
 			break;
 		case 0: /* 4.5 */
 		case 2: /* 6.0 */
@@ -865,19 +850,15 @@
 			cd = NULL; count = 0;
 			break;
 		}
-		
+
 		if (amsound && (msp->norm == VIDEO_MODE_SECAM)) {
 			/* autodetect doesn't work well with AM ... */
 			cd = NULL; count = 0; max2 = 0;
 		}
 		for (this = 0; this < count; this++) {
 			msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo);
-
-			if (msp34xx_sleep(msp,HZ/10))
-				goto done;
-			if (msp->restart)
+			if (msp34xx_sleep(msp,100))
 				goto restart;
-
 			val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b);
 			if (val > 32767)
 				val -= 65536;
@@ -895,7 +876,7 @@
 				msp->second = carrier_detect_55[max2].cdo;
 				msp3400c_setmode(client, MSP_MODE_FM_TERRA);
 				msp->nicam_on = 0;
-				msp3400c_setstereo(client, VIDEO_SOUND_MONO);
+				msp3400c_set_audmode(client, V4L2_TUNER_MODE_MONO);
 				msp->watch_stereo = 1;
 			} else if (max2 == 1 && HAVE_NICAM(msp)) {
 				/* B/G NICAM */
@@ -922,7 +903,7 @@
 				msp->second = carrier_detect_65[max2].cdo;
 				msp3400c_setmode(client, MSP_MODE_FM_TERRA);
 				msp->nicam_on = 0;
-				msp3400c_setstereo(client, VIDEO_SOUND_MONO);
+				msp3400c_set_audmode(client, V4L2_TUNER_MODE_MONO);
 				msp->watch_stereo = 1;
 			} else if (max2 == 0 &&
 				   msp->norm == VIDEO_MODE_SECAM) {
@@ -930,7 +911,7 @@
 				msp->second = carrier_detect_65[max2].cdo;
 				msp3400c_setmode(client, MSP_MODE_AM_NICAM);
 				msp->nicam_on = 0;
-				msp3400c_setstereo(client, VIDEO_SOUND_MONO);
+				msp3400c_set_audmode(client, V4L2_TUNER_MODE_MONO);
 				msp3400c_setcarrier(client, msp->second, msp->main);
 				/* volume prescale for SCART (AM mono input) */
 				msp3400c_write(client,I2C_MSP3400C_DFP, 0x000d, 0x1900);
@@ -953,29 +934,26 @@
 			msp3400c_setmode(client, MSP_MODE_FM_TERRA);
 			msp->nicam_on = 0;
 			msp3400c_setcarrier(client, msp->second, msp->main);
-			msp->stereo = VIDEO_SOUND_MONO;
-			msp3400c_setstereo(client, VIDEO_SOUND_MONO);
+			msp->rxsubchans = V4L2_TUNER_SUB_MONO;
+			msp3400c_set_audmode(client, V4L2_TUNER_MODE_MONO);
 			break;
 		}
 
-		/* unmute + restore dfp registers */
+		/* unmute */
 		msp3400c_setvolume(client, msp->muted,
 				   msp->volume, msp->balance);
-		msp3400c_restore_dfp(client);
-
-		if (msp->watch_stereo)
-			mod_timer(&msp->wake_stereo, jiffies+5*HZ);
-
 		if (debug)
 			msp3400c_print_mode(msp);
-		
-		msp->active = 0;
-	}
 
-done:
-	msp->active = 0;
+		/* monitor tv audio mode */
+		while (msp->watch_stereo) {
+			if (msp34xx_sleep(msp,5000))
+				goto restart;
+			watch_stereo(client);
+		}
+	}
 	dprintk(KERN_DEBUG "msp3400: thread: exit\n");
-        complete_and_exit(&msp->texit, 0);
+	return 0;
 }
 
 /* ----------------------------------------------------------------------- */
@@ -1008,36 +986,68 @@
 	{ 0x0060, MSP_CARRIER(7.2), MSP_CARRIER(7.2), "7.2  SAT ADR" },
 	{     -1, 0, 0, NULL }, /* EOF */
 };
- 
+
+static inline const char *msp34xx_standard_mode_name(int mode)
+{
+	int i;
+	for (i = 0; modelist[i].name != NULL; i++)
+		if (modelist[i].retval == mode)
+			return modelist[i].name;
+	return "unknown";
+}
+
+static int msp34xx_modus(int norm)
+{
+	switch (norm) {
+	case VIDEO_MODE_PAL:
+		return 0x1003;
+	case VIDEO_MODE_NTSC:  /* BTSC */
+		return 0x2003;
+	case VIDEO_MODE_SECAM:
+		return 0x0003;
+	case VIDEO_MODE_RADIO:
+		return 0x0003;
+	case VIDEO_MODE_AUTO:
+		return 0x2003;
+	default:
+		return 0x0003;
+	}
+}
+
+static int msp34xx_standard(int norm)
+{
+	switch (norm) {
+	case VIDEO_MODE_PAL:
+		return 1;
+	case VIDEO_MODE_NTSC:  /* BTSC */
+		return 0x0020;
+	case VIDEO_MODE_SECAM:
+		return 1;
+	case VIDEO_MODE_RADIO:
+		return 0x0040;
+	default:
+		return 1;
+	}
+}
+
 static int msp3410d_thread(void *data)
 {
 	struct i2c_client *client = data;
 	struct msp3400c *msp = i2c_get_clientdata(client);
 	int mode,val,i,std;
-    
-	daemonize("msp3410 [auto]");
-	allow_signal(SIGTERM);
-	printk("msp3410: daemon started\n");
 
+	printk("msp3410: daemon started\n");
 	for (;;) {
 		d2printk(KERN_DEBUG "msp3410: thread: sleep\n");
-		if (msp34xx_sleep(msp,-1))
-			goto done;
-
+		msp34xx_sleep(msp,-1);
 		d2printk(KERN_DEBUG "msp3410: thread: wakeup\n");
-		msp->active = 1;
-
-		if (msp->watch_stereo) {
-			watch_stereo(client);
-			msp->active = 0;
-			continue;
-		}
-	
-		/* some time for the tuner to sync */
-		if (msp34xx_sleep(msp,HZ/5))
-			goto done;
 
 	restart:
+		dprintk("msp3410: thread: restart scan\n");
+		msp->restart = 0;
+		if (kthread_should_stop())
+			break;
+
 		if (msp->mode == MSP_MODE_EXTERN) {
 			/* no carrier scan needed, just unmute */
 			dprintk(KERN_DEBUG "msp3410: thread: no carrier scan\n");
@@ -1045,47 +1055,24 @@
 					   msp->volume, msp->balance);
 			continue;
 		}
-		msp->restart = 0;
-		del_timer(&msp->wake_stereo);
-		msp->watch_stereo = 0;
 
 		/* put into sane state (and mute) */
 		msp3400c_reset(client);
 
+		/* some time for the tuner to sync */
+		if (msp34xx_sleep(msp,200))
+			goto restart;
+
 		/* start autodetect */
-		switch (msp->norm) {
-		case VIDEO_MODE_PAL:
-			mode = 0x1003;
-			std  = 1;
-			break;
-		case VIDEO_MODE_NTSC:  /* BTSC */
-			mode = 0x2003;
-			std  = 0x0020;
-			break;
-		case VIDEO_MODE_SECAM: 
-			mode = 0x0003;
-			std  = 1;
-			break;
-		case VIDEO_MODE_RADIO:
-			mode = 0x0003;
-			std  = 0x0040;
-			break;
-		default:
-			mode = 0x0003;
-			std  = 1;
-			break;
-		}
+		mode = msp34xx_modus(msp->norm);
+		std  = msp34xx_standard(msp->norm);
 		msp3400c_write(client, I2C_MSP3400C_DEM, 0x30, mode);
 		msp3400c_write(client, I2C_MSP3400C_DEM, 0x20, std);
+		msp->watch_stereo = 0;
 
-		if (debug) {
-			int i;
-			for (i = 0; modelist[i].name != NULL; i++)
-				if (modelist[i].retval == std)
-					break;
+		if (debug)
 			printk(KERN_DEBUG "msp3410: setting mode: %s (0x%04x)\n",
-			       modelist[i].name ? modelist[i].name : "unknown",std);
-		}
+			       msp34xx_standard_mode_name(std) ,std);
 
 		if (std != 1) {
 			/* programmed some specific mode */
@@ -1093,9 +1080,7 @@
 		} else {
 			/* triggered autodetect */
 			for (;;) {
-				if (msp34xx_sleep(msp,HZ/10))
-					goto done;
-				if (msp->restart)
+				if (msp34xx_sleep(msp,100))
 					goto restart;
 
 				/* check results */
@@ -1137,29 +1122,30 @@
 			else
 				msp->mode = MSP_MODE_FM_NICAM2;
 			/* just turn on stereo */
-			msp->stereo = VIDEO_SOUND_STEREO;
+			msp->rxsubchans = V4L2_TUNER_SUB_STEREO;
 			msp->nicam_on = 1;
 			msp->watch_stereo = 1;
-			msp3400c_setstereo(client,VIDEO_SOUND_STEREO);
+			msp3400c_set_audmode(client,V4L2_TUNER_MODE_STEREO);
 			break;
-		case 0x0009:			
+		case 0x0009:
 			msp->mode = MSP_MODE_AM_NICAM;
-			msp->stereo = VIDEO_SOUND_MONO;
+			msp->rxsubchans = V4L2_TUNER_SUB_MONO;
 			msp->nicam_on = 1;
-			msp3400c_setstereo(client,VIDEO_SOUND_MONO);
+			msp3400c_set_audmode(client,V4L2_TUNER_MODE_MONO);
 			msp->watch_stereo = 1;
 			break;
 		case 0x0020: /* BTSC */
 			/* just turn on stereo */
-			msp->mode   = MSP_MODE_BTSC;
-			msp->stereo = VIDEO_SOUND_STEREO;
+			msp->mode = MSP_MODE_BTSC;
+			msp->rxsubchans = V4L2_TUNER_SUB_STEREO;
 			msp->nicam_on = 0;
 			msp->watch_stereo = 1;
-			msp3400c_setstereo(client,VIDEO_SOUND_STEREO);
+			msp3400c_set_audmode(client,V4L2_TUNER_MODE_STEREO);
 			break;
 		case 0x0040: /* FM radio */
 			msp->mode   = MSP_MODE_FM_RADIO;
-			msp->stereo = VIDEO_SOUND_STEREO;
+			msp->rxsubchans = V4L2_TUNER_SUB_STEREO;
+			msp->audmode = V4L2_TUNER_MODE_STEREO;
 			msp->nicam_on = 0;
 			msp->watch_stereo = 0;
 			/* not needed in theory if HAVE_RADIO(), but
@@ -1185,50 +1171,278 @@
 		case 0x0004:
 		case 0x0005:
 			msp->mode   = MSP_MODE_FM_TERRA;
-			msp->stereo = VIDEO_SOUND_MONO;
+			msp->rxsubchans = V4L2_TUNER_SUB_MONO;
+			msp->audmode = V4L2_TUNER_MODE_MONO;
 			msp->nicam_on = 0;
 			msp->watch_stereo = 1;
 			break;
 		}
-		
-		/* unmute + restore dfp registers */
+
+		/* unmute, restore misc registers */
 		msp3400c_setbass(client, msp->bass);
 		msp3400c_settreble(client, msp->treble);
 		msp3400c_setvolume(client, msp->muted,
 				    msp->volume, msp->balance);
-		msp3400c_restore_dfp(client);
-
-		if (msp->watch_stereo)
-			mod_timer(&msp->wake_stereo, jiffies+HZ);
+		msp3400c_write(client, I2C_MSP3400C_DFP, 0x0013, msp->acb);
 
-		msp->active = 0;
+		/* monitor tv audio mode */
+		while (msp->watch_stereo) {
+			if (msp34xx_sleep(msp,5000))
+				goto restart;
+			watch_stereo(client);
+		}
 	}
-
-done:
-	msp->active = 0;
 	dprintk(KERN_DEBUG "msp3410: thread: exit\n");
-        complete_and_exit(&msp->texit, 0);
 	return 0;
 }
 
 /* ----------------------------------------------------------------------- */
+/* msp34xxG + (simpler no-thread)                                          */
+/* this one uses both automatic standard detection and automatic sound     */
+/* select which are available in the newer G versions                      */
+/* struct msp: only norm, acb and source are really used in this mode      */
+
+static void msp34xxg_set_source(struct i2c_client *client, int source);
+
+/* (re-)initialize the msp34xxg, according to the current norm in msp->norm
+ * return 0 if it worked, -1 if it failed
+ */
+static int msp34xxg_init(struct i2c_client *client)
+{
+	struct msp3400c *msp = i2c_get_clientdata(client);
+	int modus;
+
+	if (msp3400c_reset(client))
+		return -1;
+
+	/* make sure that input/output is muted (paranoid mode) */
+	if (msp3400c_write(client,
+			   I2C_MSP3400C_DFP,
+			   0x13, /* ACB */
+			   0x0f20 /* mute DSP input, mute SCART 1 */))
+		return -1;
+
+	/* step-by-step initialisation, as described in the manual */
+	modus = msp34xx_modus(msp->norm);
+	modus &= ~0x03; /* STATUS_CHANGE=0 */
+	modus |= 0x01;  /* AUTOMATIC_SOUND_DETECTION=1 */
+	if (msp3400c_write(client,
+			   I2C_MSP3400C_DEM,
+			   0x30/*MODUS*/,
+			   modus))
+		return -1;
+
+	/* write the dfps that may have an influence on
+	   standard/audio autodetection right now */
+	msp34xxg_set_source(client, msp->source);
+
+	if (msp3400c_write(client, I2C_MSP3400C_DFP,
+			   0x0e, /* AM/FM Prescale */
+			   0x3000 /* default: [15:8] 75khz deviation */))
+		return -1;
+
+	if (msp3400c_write(client, I2C_MSP3400C_DFP,
+			   0x10, /* NICAM Prescale */
+			   0x5a00 /* default: 9db gain (as recommended) */))
+		return -1;
+
+	if (msp3400c_write(client,
+			   I2C_MSP3400C_DEM,
+			   0x20, /* STANDARD SELECT  */
+			   standard /* default: 0x01 for automatic standard select*/))
+		return -1;
+	return 0;
+}
+
+static int msp34xxg_thread(void *data)
+{
+	struct i2c_client *client = data;
+	struct msp3400c *msp = i2c_get_clientdata(client);
+	int val, std, i;
+
+	printk("msp34xxg: daemon started\n");
+	for (;;) {
+		d2printk(KERN_DEBUG "msp34xxg: thread: sleep\n");
+		msp34xx_sleep(msp,-1);
+		d2printk(KERN_DEBUG "msp34xxg: thread: wakeup\n");
+
+	restart:
+		dprintk("msp34xxg: thread: restart scan\n");
+		msp->restart = 0;
+		if (kthread_should_stop())
+			break;
+
+		/* setup the chip*/
+		msp34xxg_init(client);
+		std = standard;
+		if (std != 0x01)
+			goto unmute;
+
+		/* watch autodetect */
+		dprintk("msp34xxg: triggered autodetect, waiting for result\n");
+		for (i = 0; i < 10; i++) {
+			if (msp34xx_sleep(msp,100))
+				goto restart;
+
+			/* check results */
+			val = msp3400c_read(client, I2C_MSP3400C_DEM, 0x7e);
+			if (val < 0x07ff) {
+				std = val;
+				break;
+			}
+			dprintk("msp34xxg: detection still in progress\n");
+		}
+		if (0x01 == std) {
+			dprintk("msp34xxg: detection still in progress after 10 tries. giving up.\n");
+			continue;
+		}
+
+	unmute:
+		dprintk("msp34xxg: current mode: %s (0x%04x)\n",
+			msp34xx_standard_mode_name(std), std);
+
+		/* unmute: dispatch sound to scart output, set scart volume */
+		dprintk("msp34xxg: unmute\n");
+
+		msp3400c_setbass(client, msp->bass);
+		msp3400c_settreble(client, msp->treble);
+		msp3400c_setvolume(client, msp->muted, msp->volume, msp->balance);
+
+		/* restore ACB */
+		if (msp3400c_write(client,
+				   I2C_MSP3400C_DFP,
+				   0x13, /* ACB */
+				   msp->acb))
+			return -1;
+	}
+	dprintk(KERN_DEBUG "msp34xxg: thread: exit\n");
+	return 0;
+}
+
+/* set the same 'source' for the loudspeaker, scart and quasi-peak detector
+ * the value for source is the same as bit 15:8 of DFP registers 0x08,
+ * 0x0a and 0x0c: 0=mono, 1=stereo or A|B, 2=SCART, 3=stereo or A, 4=stereo or B
+ *
+ * this function replaces msp3400c_setstereo
+ */
+static void msp34xxg_set_source(struct i2c_client *client, int source)
+{
+	struct msp3400c *msp = i2c_get_clientdata(client);
+
+	/* fix matrix mode to stereo and let the msp choose what
+	 * to output according to 'source', as recommended
+	 */
+	int value = (source&0x07)<<8|(source==0 ? 0x00:0x20);
+	dprintk("msp34xxg: set source to %d (0x%x)\n", source, value);
+	msp3400c_write(client,
+		       I2C_MSP3400C_DFP,
+		       0x08, /* Loudspeaker Output */
+		       value);
+	msp3400c_write(client,
+		       I2C_MSP3400C_DFP,
+		       0x0a, /* SCART1 DA Output */
+		       value);
+	msp3400c_write(client,
+		       I2C_MSP3400C_DFP,
+		       0x0c, /* Quasi-peak detector */
+		       value);
+	/*
+	 * set identification threshold. Personally, I
+	 * I set it to a higher value that the default
+	 * of 0x190 to ignore noisy stereo signals.
+	 * this needs tuning. (recommended range 0x00a0-0x03c0)
+	 * 0x7f0 = forced mono mode
+	 */
+	msp3400c_write(client,
+		       I2C_MSP3400C_DEM,
+		       0x22, /* a2 threshold for stereo/bilingual */
+		       source==0 ? 0x7f0:stereo_threshold);
+	msp->source=source;
+}
+
+static void msp34xxg_detect_stereo(struct i2c_client *client)
+{
+	struct msp3400c *msp = i2c_get_clientdata(client);
+
+	int status = msp3400c_read(client,
+				   I2C_MSP3400C_DEM,
+				   0x0200 /* STATUS */);
+	int is_bilingual = status&0x100;
+	int is_stereo = status&0x40;
+
+	msp->rxsubchans = 0;
+	if (is_stereo)
+		msp->rxsubchans |= V4L2_TUNER_SUB_STEREO;
+	else
+		msp->rxsubchans |= V4L2_TUNER_SUB_MONO;
+	if (is_bilingual) {
+		msp->rxsubchans |= V4L2_TUNER_SUB_LANG1|V4L2_TUNER_SUB_LANG2;
+		/* I'm supposed to check whether it's SAP or not
+		 * and set only LANG2/SAP in this case. Yet, the MSP
+		 * does a lot of work to hide this and handle everything
+		 * the same way. I don't want to work around it so unless
+		 * this is a problem, I'll handle SAP just like lang1/lang2.
+		 */
+	}
+	dprintk("msp34xxg: status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
+		status, is_stereo, is_bilingual, msp->rxsubchans);
+}
+
+static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
+{
+	struct msp3400c *msp = i2c_get_clientdata(client);
+	int source = 0;
+
+	switch (audmode) {
+	case V4L2_TUNER_MODE_MONO:
+		source=0; /* mono only */
+		break;
+	case V4L2_TUNER_MODE_STEREO:
+		source=1; /* stereo or A|B, see comment in msp34xxg_get_v4l2_stereo() */
+		/* problem: that could also mean 2 (scart input) */
+		break;
+	case V4L2_TUNER_MODE_LANG1:
+		source=3; /* stereo or A */
+		break;
+	case V4L2_TUNER_MODE_LANG2:
+		source=4; /* stereo or B */
+		break;
+	default: /* doing nothing: a safe, sane default */
+		audmode = 0;
+		return;
+	}
+	msp->audmode = audmode;
+	msp34xxg_set_source(client, source);
+}
+
+
+/* ----------------------------------------------------------------------- */
 
 static int msp_attach(struct i2c_adapter *adap, int addr, int kind);
 static int msp_detach(struct i2c_client *client);
 static int msp_probe(struct i2c_adapter *adap);
 static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg);
 
+static int msp_suspend(struct device * dev, u32 state, u32 level);
+static int msp_resume(struct device * dev, u32 level);
+
+static void msp_wake_thread(struct i2c_client *client);
+
 static struct i2c_driver driver = {
 	.owner          = THIS_MODULE,
-        .name           = "i2c msp3400 driver",
+	.name           = "i2c msp3400 driver",
         .id             = I2C_DRIVERID_MSP3400,
         .flags          = I2C_DF_NOTIFY,
         .attach_adapter = msp_probe,
         .detach_client  = msp_detach,
         .command        = msp_command,
+	.driver = {
+		.suspend = msp_suspend,
+		.resume  = msp_resume,
+	},
 };
 
-static struct i2c_client client_template = 
+static struct i2c_client client_template =
 {
 	I2C_DEVNAME("(unset)"),
 	.flags     = I2C_CLIENT_ALLOW_USE,
@@ -1239,7 +1453,7 @@
 {
 	struct msp3400c *msp;
         struct i2c_client *c;
-	int i;
+	int (*thread_func)(void *data) = NULL;
 
         client_template.adapter = adap;
         client_template.addr = addr;
@@ -1248,7 +1462,7 @@
                 dprintk("msp3400: no chip found\n");
                 return -1;
         }
-	
+
         if (NULL == (c = kmalloc(sizeof(struct i2c_client),GFP_KERNEL)))
                 return -ENOMEM;
         memcpy(c,&client_template,sizeof(struct i2c_client));
@@ -1256,16 +1470,14 @@
 		kfree(c);
 		return -ENOMEM;
 	}
-	
+
 	memset(msp,0,sizeof(struct msp3400c));
-	msp->volume = 65535;
+	msp->volume  = 58880;  /* 0db gain */
 	msp->balance = 32768;
-	msp->bass   = 32768;
-	msp->treble = 32768;
-	msp->input  = -1;
-	msp->muted  = 1;
-	for (i = 0; i < DFP_COUNT; i++)
-		msp->dfp_regs[i] = -1;
+	msp->bass    = 32768;
+	msp->treble  = 32768;
+	msp->input   = -1;
+	msp->muted   = 1;
 
 	i2c_set_clientdata(c, msp);
 	init_waitqueue_head(&msp->wq);
@@ -1276,7 +1488,7 @@
 		dprintk("msp3400: no chip found\n");
 		return -1;
 	}
-    
+
 	msp->rev1 = msp3400c_read(c, I2C_MSP3400C_DFP, 0x1e);
 	if (-1 != msp->rev1)
 		msp->rev2 = msp3400c_read(c, I2C_MSP3400C_DFP, 0x1f);
@@ -1297,36 +1509,54 @@
 		 (msp->rev2>>8)&0xff, (msp->rev1&0xff)+'@',
 		 ((msp->rev1>>8)&0xff)+'@', msp->rev2&0x1f);
 
-	if (simple == -1) {
-		/* default mode */
-		msp->simple = HAVE_SIMPLE(msp);
-	} else {
-		/* use insmod option */
-		msp->simple = simple;
+	msp->opmode = opmode;
+	if (OPMODE_AUTO == msp->opmode) {
+#if 0 /* seems to work for ivtv only, disable by default for now ... */
+		if (HAVE_SIMPLER(msp))
+			msp->opmode = OPMODE_SIMPLER;
+		else
+#endif
+		if (HAVE_SIMPLE(msp))
+			msp->opmode = OPMODE_SIMPLE;
+		else
+			msp->opmode = OPMODE_MANUAL;
 	}
 
-	/* timer for stereo checking */
-	init_timer(&msp->wake_stereo);
-	msp->wake_stereo.function = msp3400c_stereo_wake;
-	msp->wake_stereo.data     = (unsigned long)msp;
-
 	/* hello world :-) */
 	printk(KERN_INFO "msp34xx: init: chip=%s",i2c_clientname(c));
 	if (HAVE_NICAM(msp))
 		printk(" +nicam");
 	if (HAVE_SIMPLE(msp))
 		printk(" +simple");
+	if (HAVE_SIMPLER(msp))
+		printk(" +simpler");
 	if (HAVE_RADIO(msp))
 		printk(" +radio");
+
+	/* version-specific initialization */
+	switch (msp->opmode) {
+	case OPMODE_MANUAL:
+		printk(" mode=manual");
+		thread_func = msp3400c_thread;
+		break;
+	case OPMODE_SIMPLE:
+		printk(" mode=simple");
+		thread_func = msp3410d_thread;
+		break;
+	case OPMODE_SIMPLER:
+		printk(" mode=simpler");
+		thread_func = msp34xxg_thread;
+		break;
+	}
 	printk("\n");
 
-	/* startup control thread */
-	init_completion(&msp->texit);
-	msp->tpid = kernel_thread(msp->simple ? msp3410d_thread : msp3400c_thread,
-				  (void *)c, 0);
-	if (msp->tpid < 0)
-		printk(KERN_WARNING "msp34xx: kernel_thread() failed\n");
-	wake_up_interruptible(&msp->wq);
+	/* startup control thread if needed */
+	if (thread_func) {
+		msp->kthread = kthread_run(thread_func, c, "msp34xx");
+		if (NULL == msp->kthread)
+			printk(KERN_WARNING "msp34xx: kernel_thread() failed\n");
+		msp_wake_thread(c);
+	}
 
 	/* done */
         i2c_attach_client(c);
@@ -1336,13 +1566,11 @@
 static int msp_detach(struct i2c_client *client)
 {
 	struct msp3400c *msp  = i2c_get_clientdata(client);
-	
+
 	/* shutdown control thread */
-	del_timer_sync(&msp->wake_stereo);
-	if (msp->tpid >= 0) {
-		msp->rmmod = 1;
-		wake_up_interruptible(&msp->wq);
-		wait_for_completion(&msp->texit);
+	if (msp->kthread >= 0) {
+		msp->restart = 1;
+		kthread_stop(msp->kthread);
 	}
     	msp3400c_reset(client);
 
@@ -1354,18 +1582,8 @@
 
 static int msp_probe(struct i2c_adapter *adap)
 {
-#ifdef I2C_CLASS_TV_ANALOG
 	if (adap->class & I2C_CLASS_TV_ANALOG)
 		return i2c_probe(adap, &addr_data, msp_attach);
-#else
-	switch (adap->id) {
-	case I2C_ALGO_BIT | I2C_HW_SMBUS_VOODOO3:
-	case I2C_ALGO_BIT | I2C_HW_B_BT848:
-	//case I2C_ALGO_SAA7134:
-		return i2c_probe(adap, &addr_data, msp_attach);
-		break;
-	}
-#endif
 	return 0;
 }
 
@@ -1373,14 +1591,73 @@
 {
 	struct msp3400c *msp  = i2c_get_clientdata(client);
 
+	if (NULL == msp->kthread)
+		return;
 	msp3400c_setvolume(client,msp->muted,0,0);
-	msp->watch_stereo=0;
-	del_timer(&msp->wake_stereo);
-	if (msp->active)
-		msp->restart = 1;
+	msp->watch_stereo = 0;
+	msp->restart = 1;
 	wake_up_interruptible(&msp->wq);
 }
 
+/* ----------------------------------------------------------------------- */
+
+static int mode_v4l2_to_v4l1(int rxsubchans)
+{
+	int mode = 0;
+
+	if (rxsubchans & V4L2_TUNER_SUB_STEREO)
+		mode |= VIDEO_SOUND_STEREO;
+	if (rxsubchans & V4L2_TUNER_SUB_LANG2)
+		mode |= VIDEO_SOUND_LANG2;
+	if (rxsubchans & V4L2_TUNER_SUB_LANG1)
+		mode |= VIDEO_SOUND_LANG1;
+	if (0 == mode)
+		mode |= VIDEO_SOUND_MONO;
+	return mode;
+}
+
+static int mode_v4l1_to_v4l2(int mode)
+{
+	if (mode & VIDEO_SOUND_STEREO)
+		return V4L2_TUNER_MODE_STEREO;
+	if (mode & VIDEO_SOUND_LANG2)
+		return V4L2_TUNER_MODE_LANG2;
+	if (mode & VIDEO_SOUND_LANG1)
+		return V4L2_TUNER_MODE_LANG1;
+	return V4L2_TUNER_MODE_MONO;
+}
+
+static void msp_any_detect_stereo(struct i2c_client *client)
+{
+	struct msp3400c *msp  = i2c_get_clientdata(client);
+
+	switch (msp->opmode) {
+	case OPMODE_MANUAL:
+	case OPMODE_SIMPLE:
+		autodetect_stereo(client);
+		break;
+	case OPMODE_SIMPLER:
+		msp34xxg_detect_stereo(client);
+		break;
+	}
+}
+
+static void msp_any_set_audmode(struct i2c_client *client, int audmode)
+{
+	struct msp3400c *msp  = i2c_get_clientdata(client);
+
+	switch (msp->opmode) {
+	case OPMODE_MANUAL:
+	case OPMODE_SIMPLE:
+		msp->watch_stereo = 0;
+		msp3400c_set_audmode(client, audmode);
+		break;
+	case OPMODE_SIMPLER:
+		msp34xxg_set_audmode(client, audmode);
+		break;
+	}
+}
+
 static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
 {
 	struct msp3400c *msp  = i2c_get_clientdata(client);
@@ -1412,7 +1689,6 @@
 			break;
 		case AUDIO_TUNER:
 			msp->mode   = -1;
-			msp_wake_thread(client);
 			break;
 		default:
 			if (*sarg & AUDIO_MUTE)
@@ -1420,63 +1696,38 @@
 			break;
 		}
 		if (scart) {
-			msp->stereo = VIDEO_SOUND_STEREO;
+			msp->rxsubchans = V4L2_TUNER_SUB_STEREO;
+			msp->audmode = V4L2_TUNER_MODE_STEREO;
 			msp3400c_set_scart(client,scart,0);
 			msp3400c_write(client,I2C_MSP3400C_DFP,0x000d,0x1900);
-			msp3400c_setstereo(client,msp->stereo);
+			if (msp->opmode != OPMODE_SIMPLER)
+				msp3400c_set_audmode(client, msp->audmode);
 		}
-		if (msp->active)
-			msp->restart = 1;
+		msp_wake_thread(client);
 		break;
 
 	case AUDC_SET_RADIO:
 		dprintk(KERN_DEBUG "msp34xx: AUDC_SET_RADIO\n");
 		msp->norm = VIDEO_MODE_RADIO;
-		msp->watch_stereo=0;
-		del_timer(&msp->wake_stereo);
 		dprintk(KERN_DEBUG "msp34xx: switching to radio mode\n");
-		if (msp->simple) {
-			/* the thread will do for us */
-			msp_wake_thread(client);
-		} else {
+		msp->watch_stereo = 0;
+		switch (msp->opmode) {
+		case OPMODE_MANUAL:
 			/* set msp3400 to FM radio mode */
 			msp3400c_setmode(client,MSP_MODE_FM_RADIO);
 			msp3400c_setcarrier(client, MSP_CARRIER(10.7),
 					    MSP_CARRIER(10.7));
 			msp3400c_setvolume(client, msp->muted,
 					   msp->volume, msp->balance);
+			break;
+		case OPMODE_SIMPLE:
+		case OPMODE_SIMPLER:
+			/* the thread will do for us */
+			msp_wake_thread(client);
+			break;
 		}
-		if (msp->active)
-			msp->restart = 1;
 		break;
 
-#if 1
-	/* work-in-progress:  hook to control the DFP registers */
-	case MSP_SET_DFPREG:
-	{
-		struct msp_dfpreg *r = arg;
-		unsigned int i;
-
-		if (r->reg < 0 || r->reg >= DFP_COUNT)
-			return -EINVAL;
-		for (i = 0; i < ARRAY_SIZE(bl_dfp); i++)
-			if (r->reg == bl_dfp[i])
-				return -EINVAL;
-		msp->dfp_regs[r->reg] = r->value;
-		msp3400c_write(client,I2C_MSP3400C_DFP,r->reg,r->value);
-		return 0;
-	}
-	case MSP_GET_DFPREG:
-	{
-		struct msp_dfpreg *r = arg;
-
-		if (r->reg < 0 || r->reg >= DFP_COUNT)
-			return -EINVAL;
-		r->value = msp3400c_read(client,I2C_MSP3400C_DFP,r->reg);
-		return 0;
-	}
-#endif
-
 	/* --- v4l ioctls --- */
 	/* take care: bttv does userspace copying, we'll get a
 	   kernel pointer here... */
@@ -1497,10 +1748,8 @@
 		va->bass = msp->bass;
 		va->treble = msp->treble;
 
-		if (msp->norm != VIDEO_MODE_RADIO) {
-			autodetect_stereo(client);
-			va->mode = msp->stereo;
-		}
+		msp_any_detect_stereo(client);
+		va->mode = mode_v4l2_to_v4l1(msp->rxsubchans);
 		break;
 	}
 	case VIDIOCSAUDIO:
@@ -1519,23 +1768,22 @@
 		msp3400c_setbass(client,msp->bass);
 		msp3400c_settreble(client,msp->treble);
 
-		if (va->mode != 0 && msp->norm != VIDEO_MODE_RADIO) {
-			msp->watch_stereo=0;
-			del_timer(&msp->wake_stereo);
-			msp->stereo = va->mode & 0x0f;
-			msp3400c_setstereo(client,va->mode & 0x0f);
-		}
+		if (va->mode != 0 && msp->norm != VIDEO_MODE_RADIO)
+			msp_any_set_audmode(client,mode_v4l1_to_v4l2(va->mode));
 		break;
 	}
 	case VIDIOCSCHAN:
 	{
 		struct video_channel *vc = arg;
-		
+
 		dprintk(KERN_DEBUG "msp34xx: VIDIOCSCHAN (norm=%d)\n",vc->norm);
 		msp->norm = vc->norm;
+		msp_wake_thread(client);
 		break;
 	}
+
 	case VIDIOCSFREQ:
+	case VIDIOC_S_FREQUENCY:
 	{
 		/* new channel -- kick audio carrier scan */
 		dprintk(KERN_DEBUG "msp34xx: VIDIOCSFREQ\n");
@@ -1543,10 +1791,61 @@
 		break;
 	}
 
+	/* --- v4l2 ioctls --- */
+	case VIDIOC_G_TUNER:
+	{
+		struct v4l2_tuner *vt = arg;
+
+		msp_any_detect_stereo(client);
+		vt->audmode    = msp->audmode;
+		vt->rxsubchans = msp->rxsubchans;
+		vt->capability = V4L2_TUNER_CAP_STEREO |
+			V4L2_TUNER_CAP_LANG1|
+			V4L2_TUNER_CAP_LANG2;
+		break;
+	}
+	case VIDIOC_S_TUNER:
+	{
+		struct v4l2_tuner *vt=(struct v4l2_tuner *)arg;
+
+		/* only set audmode */
+		if (vt->audmode != -1 && vt->audmode != 0)
+			msp_any_set_audmode(client, vt->audmode);
+		break;
+	}
+
+	/* msp34xx specific */
+	case MSP_SET_MATRIX:
+	{
+		struct msp_matrix *mspm = arg;
+
+		dprintk(KERN_DEBUG "msp34xx: MSP_SET_MATRIX\n");
+		msp3400c_set_scart(client, mspm->input, mspm->output);
+		break;
+	}
+
 	default:
 		/* nothing */
 		break;
 	}
+	return 0;
+}
+
+static int msp_suspend(struct device * dev, u32 state, u32 level)
+{
+	struct i2c_client *c = container_of(dev, struct i2c_client, dev);
+
+	dprintk("msp34xx: suspend\n");
+	msp3400c_reset(c);
+	return 0;
+}
+
+static int msp_resume(struct device * dev, u32 level)
+{
+	struct i2c_client *c = container_of(dev, struct i2c_client, dev);
+
+	dprintk("msp34xx: resume\n");
+	msp_wake_thread(c);
 	return 0;
 }
 
diff -Nru a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h
--- a/drivers/media/video/msp3400.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/media/video/msp3400.h	2004-12-24 13:37:19 -08:00
@@ -8,7 +8,29 @@
     int value;
 };
 
+struct msp_matrix {
+  int input;
+  int output;
+};
+
 #define MSP_SET_DFPREG     _IOW('m',15,struct msp_dfpreg)
 #define MSP_GET_DFPREG     _IOW('m',16,struct msp_dfpreg)
+
+/* ioctl for MSP_SET_MATRIX will have to be registered */
+#define MSP_SET_MATRIX     _IOW('m',17,struct msp_matrix)
+
+#define SCART_MASK    0
+#define SCART_IN1     1
+#define SCART_IN2     2
+#define SCART_IN1_DA  3
+#define SCART_IN2_DA  4
+#define SCART_IN3     5
+#define SCART_IN4     6
+#define SCART_MONO    7
+#define SCART_MUTE    8
+
+#define SCART_DSP_IN  0
+#define SCART1_OUT    1
+#define SCART2_OUT    2
 
 #endif /* MSP3400_H */
diff -Nru a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
--- a/drivers/media/video/mxb.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/media/video/mxb.c	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,5 @@
 /*
-    mxb.c - v4l2 driver for the Multimedia eXtension Board
+    mxb - v4l2 driver for the Multimedia eXtension Board
     
     Copyright (C) 1998-2003 Michael Hunold <michael@mihu.de>
 
@@ -43,12 +43,12 @@
    in verden (lower saxony, germany) 4148 is a
    channel called "phoenix" */
 static int freq = 4148;
-MODULE_PARM(freq,"i");
+module_param(freq, int, 0644);
 MODULE_PARM_DESC(freq, "initial frequency the tuner will be tuned to while setup");
 
 static int debug = 0;
-MODULE_PARM(debug,"i");
-MODULE_PARM_DESC(debug, "debug verbosity");
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
 
 #define MXB_INPUTS 4
 enum { TUNER, AUX1, AUX3, AUX3_YC };
@@ -128,8 +128,8 @@
 
 struct mxb
 {
-	struct video_device	video_dev;
-	struct video_device	vbi_dev;
+	struct video_device	*video_dev;
+	struct video_device	*vbi_dev;
 
 	struct i2c_adapter	i2c_adapter;	
 
@@ -183,7 +183,12 @@
 	}
 	memset(mxb, 0x0, sizeof(struct mxb));	
 
-	saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, I2C_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480);
+	mxb->i2c_adapter = (struct i2c_adapter) {
+		.class = I2C_CLASS_TV_ANALOG,
+		.name = "mxb",
+	};
+
+	saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
 	if(i2c_add_adapter(&mxb->i2c_adapter) < 0) {
 		DEB_S(("cannot register i2c-device. skipping.\n"));
 		kfree(mxb);
diff -Nru a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c
--- a/drivers/media/video/ovcamchip/ovcamchip_core.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/media/video/ovcamchip/ovcamchip_core.c	2004-12-24 13:37:19 -08:00
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 #include "ovcamchip_priv.h"
 
 #define DRIVER_VERSION "v2.27 for Linux 2.6"
@@ -128,8 +129,7 @@
 	ov_write(c, 0x12, 0x80);
 
 	/* Wait for it to initialize */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(1 + 150 * HZ / 1000);
+	msleep(150);
 
 	for (i = 0, success = 0; i < I2C_DETECT_RETRIES && !success; i++) {
 		if (ov_read(c, GENERIC_REG_ID_HIGH, &high) >= 0) {
@@ -145,8 +145,7 @@
 		ov_write(c, 0x12, 0x80);
 
 		/* Wait for it to initialize */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1 + 150 * HZ / 1000);
+		msleep(150);
 
 		/* Dummy read to sync I2C */
 		ov_read(c, 0x00, &low);
diff -Nru a/drivers/media/video/planb.c b/drivers/media/video/planb.c
--- a/drivers/media/video/planb.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/video/planb.c	2004-12-24 13:37:18 -08:00
@@ -178,8 +178,7 @@
 	saa_write_reg (SAA7196_STDC, saa_regs[pb->win.norm][SAA7196_STDC]);
 
 	/* Let's wait 30msec for this one */
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(30 * HZ / 1000);
+	msleep_interruptible(30);
 
 	return (unsigned char)in_8 (&planb_regs->saa_status);
 }
@@ -1996,8 +1995,10 @@
 			return err;
 	}
 	for (i = 0; i < pb->rawbuf_size; i++) {
-		if (remap_page_range(vma, start, virt_to_phys((void *)pb->rawbuf[i]),
-						PAGE_SIZE, PAGE_SHARED))
+		unsigned long pfn;
+
+		pfn = virt_to_phys((void *)pb->rawbuf[i]) >> PAGE_SHIFT;
+		if (remap_pfn_range(vma, start, pfn, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 		start += PAGE_SIZE;
 		if (size <= PAGE_SIZE)
diff -Nru a/drivers/media/video/pms.c b/drivers/media/video/pms.c
--- a/drivers/media/video/pms.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/video/pms.c	2004-12-24 13:37:18 -08:00
@@ -68,6 +68,7 @@
 static int io_port		=	0x250;
 static int data_port		=	0x251;
 static int mem_base		=	0xC8000;
+static void __iomem *mem;
 static int video_nr             =       -1;
 
 	
@@ -629,7 +630,6 @@
 {
 	int y;
 	int dw = 2*dev->width;
-	u32 src = mem_base;
 
 	char tmp[dw+32]; /* using a temp buffer is faster than direct  */
 	int cnt = 0;
@@ -644,14 +644,14 @@
   
 	for (y = 0; y < dev->height; y++ ) 
 	{
-		isa_writeb(0, src);  /* synchronisiert neue Zeile */
+		writeb(0, mem);  /* synchronisiert neue Zeile */
 		
 		/*
 		 *	This is in truth a fifo, be very careful as if you
 		 *	forgot this odd things will occur 8)
 		 */
 		 
-		isa_memcpy_fromio(tmp, src, dw+32); /* discard 16 word   */
+		memcpy_fromio(tmp, mem, dw+32); /* discard 16 word   */
 		cnt -= dev->height;
 		while (cnt <= 0) 
 		{ 
@@ -865,7 +865,7 @@
 	return video_usercopy(inode, file, cmd, arg, pms_do_ioctl);
 }
 
-static int pms_read(struct file *file, char __user *buf,
+static ssize_t pms_read(struct file *file, char __user *buf,
 		    size_t count, loff_t *ppos)
 {
 	struct video_device *v = video_devdata(file);
@@ -918,16 +918,22 @@
 		0x34,0x0A,0xF4,0xCE,
 		0xE4
 	};
+
+	mem = ioremap(mem_base, 0x800);
+	if (!mem)
+		return -ENOMEM;
 	
 	if (!request_region(0x9A01, 1, "Mediavision PMS config"))
 	{
 		printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n");
+		iounmap(mem);
 		return -EBUSY;
 	}
 	if (!request_region(io_port, 3, "Mediavision PMS"))
 	{
 		printk(KERN_WARNING "mediavision: I/O port %d in use.\n", io_port);
 		release_region(0x9A01, 1);
+		iounmap(mem);
 		return -EBUSY;
 	}
 	outb(0xB8, 0x9A01);		/* Unlock */
@@ -950,6 +956,7 @@
 	if(idec == 0) {
 		release_region(io_port, 3);
 		release_region(0x9A01, 1);
+		iounmap(mem);
 		return -ENODEV;
 	}
 
@@ -1045,6 +1052,7 @@
 {
 	shutdown_mediavision();
 	video_unregister_device((struct video_device *)&pms_device);
+	iounmap(mem);
 }
 
 module_init(init_pms_cards);
diff -Nru a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
--- a/drivers/media/video/saa5249.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/media/video/saa5249.c	2004-12-24 13:37:04 -08:00
@@ -273,8 +273,7 @@
 	sigfillset(&current->blocked);
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(delay);
+	msleep_interruptible(jiffies_to_msecs(delay));
 
 	spin_lock_irq(&current->sighand->siglock);
 	current->blocked = oldblocked;
diff -Nru a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
--- a/drivers/media/video/saa7111.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/media/video/saa7111.c	2004-12-24 13:37:43 -08:00
@@ -60,7 +60,7 @@
 #include <linux/video_decoder.h>
 
 static int debug = 0;
-MODULE_PARM(debug, "i");
+module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Debug level (0-1)");
 
 #define dprintk(num, format, args...) \
@@ -342,7 +342,7 @@
 
 		case VIDEO_MODE_SECAM:
 			saa7111_write(client, 0x08,
-				      (decoder->reg[0x0e] & 0x3f) | 0x00);
+				      (decoder->reg[0x08] & 0x3f) | 0x00);
 			saa7111_write(client, 0x0e,
 				      (decoder->reg[0x0e] & 0x8f) | 0x50);
 			break;
diff -Nru a/drivers/media/video/saa7134/Makefile b/drivers/media/video/saa7134/Makefile
--- a/drivers/media/video/saa7134/Makefile	2004-12-24 13:37:34 -08:00
+++ b/drivers/media/video/saa7134/Makefile	2004-12-24 13:37:34 -08:00
@@ -3,6 +3,8 @@
 		saa7134-oss.o saa7134-ts.o saa7134-tvaudio.o	\
 		saa7134-vbi.o saa7134-video.o saa7134-input.o
 
-obj-$(CONFIG_VIDEO_SAA7134) += saa7134.o saa6752hs.o
+obj-$(CONFIG_VIDEO_SAA7134) += saa7134.o saa7134-empress.o saa6752hs.o
+obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o
 
-EXTRA_CFLAGS = -I$(src)/..
+EXTRA_CFLAGS += -I$(src)/..
+EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
diff -Nru a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
--- a/drivers/media/video/saa7134/saa6752hs.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/media/video/saa7134/saa6752hs.c	2004-12-24 13:37:29 -08:00
@@ -36,7 +36,7 @@
     	SAA6752HS_COMMAND_RECONFIGURE = 4,
     	SAA6752HS_COMMAND_SLEEP = 5,
 	SAA6752HS_COMMAND_RECONFIGURE_FORCE = 6,
-    
+
 	SAA6752HS_COMMAND_MAX
 };
 
@@ -46,24 +46,24 @@
 static u8 PAT[] = {
 	0xc2, // i2c register
 	0x00, // table number for encoder
-  
+
 	0x47, // sync
 	0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0)
 	0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0)
-     
+
 	0x00, // PSI pointer to start of table
-    
+
 	0x00, // tid(0)
 	0xb0, 0x0d, // section_syntax_indicator(1), section_length(13)
-    
+
 	0x00, 0x01, // transport_stream_id(1)
-    
+
 	0xc1, // version_number(0), current_next_indicator(1)
-    
+
 	0x00, 0x00, // section_number(0), last_section_number(0)
 
 	0x00, 0x01, // program_number(1)
-	
+
 	0xe0, 0x10, // PMT PID(0x10)
 
 	0x76, 0xf1, 0x44, 0xd1 // CRC32
@@ -72,29 +72,29 @@
 static u8 PMT[] = {
 	0xc2, // i2c register
 	0x01, // table number for encoder
-  
+
 	0x47, // sync
 	0x40, 0x10, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0x10)
 	0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0)
-     
+
 	0x00, // PSI pointer to start of table
-    
+
 	0x02, // tid(2)
 	0xb0, 0x17, // section_syntax_indicator(1), section_length(23)
 
 	0x00, 0x01, // program_number(1)
-    
+
 	0xc1, // version_number(0), current_next_indicator(1)
-    
+
 	0x00, 0x00, // section_number(0), last_section_number(0)
-    
+
 	0xe1, 0x04, // PCR_PID (0x104)
-   
+
 	0xf0, 0x00, // program_info_length(0)
-    
+
 	0x02, 0xe1, 0x00, 0xf0, 0x00, // video stream type(2), pid(0x100)
 	0x04, 0xe1, 0x03, 0xf0, 0x00, // audio stream type(4), pid(0x103)
-    
+
 	0xa1, 0xca, 0x0f, 0x82 // CRC32
 };
 
@@ -106,7 +106,7 @@
 	.total_bitrate = 6000,
 };
 
-  
+
 /* ---------------------------------------------------------------------- */
 
 
@@ -122,11 +122,11 @@
   	case SAA6752HS_COMMAND_RESET:
   		buf[0] = 0x00;
 		break;
-	  
+
 	case SAA6752HS_COMMAND_STOP:
 		  	buf[0] = 0x03;
 		break;
-	  
+
 	case SAA6752HS_COMMAND_START:
   		buf[0] = 0x02;
 		break;
@@ -134,11 +134,11 @@
 	case SAA6752HS_COMMAND_PAUSE:
   		buf[0] = 0x04;
 		break;
-	  
+
 	case SAA6752HS_COMMAND_RECONFIGURE:
 		buf[0] = 0x05;
 		break;
-	  
+
   	case SAA6752HS_COMMAND_SLEEP:
   		buf[0] = 0x06;
 		break;
@@ -146,11 +146,11 @@
   	case SAA6752HS_COMMAND_RECONFIGURE_FORCE:
 		buf[0] = 0x07;
 		break;
-	
+
 	default:
-		return -EINVAL;  
+		return -EINVAL;
 	}
-	
+
   	// set it and wait for it to be so
 	i2c_master_send(client, buf, 1);
 	timeout = jiffies + HZ * 3;
@@ -166,16 +166,14 @@
 			status = -ETIMEDOUT;
 			break;
 		}
-	
+
 		// wait a bit
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	}
 
 	// delay a bit to let encoder settle
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ/20);
-	
+	msleep(50);
+
 	// done
   	return status;
 }
@@ -185,12 +183,12 @@
 				 struct mpeg_params* params)
 {
   	u8 buf[3];
-  
+
 	// set the bitrate mode
 	buf[0] = 0x71;
 	buf[1] = params->bitrate_mode;
 	i2c_master_send(client, buf, 2);
-	  
+
 	// set the video bitrate
 	if (params->bitrate_mode == MPEG_BITRATE_MODE_VBR) {
 		// set the target bitrate
@@ -211,24 +209,24 @@
 	  	buf[2] = params->video_target_bitrate & 0xff;
 		i2c_master_send(client, buf, 3);
 	}
-	  
+
 	// set the audio bitrate
  	buf[0] = 0x94;
   	buf[1] = params->audio_bitrate;
 	i2c_master_send(client, buf, 2);
-	
+
 	// set the total bitrate
 	buf[0] = 0xb1;
   	buf[1] = params->total_bitrate >> 8;
   	buf[2] = params->total_bitrate & 0xff;
 	i2c_master_send(client, buf, 3);
-  
+
 	return 0;
 }
 
 
 static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params)
-{  
+{
 	unsigned char buf[3];
 	void *data;
 
@@ -246,41 +244,41 @@
         		return -EINVAL;
 		if (params->bitrate_mode         == MPEG_BITRATE_MODE_MAX &&
 		    params->video_target_bitrate <= params->video_max_bitrate)
-			return -EINVAL; 
+			return -EINVAL;
 	}
-  
+
     	// Set GOP structure {3, 13}
 	buf[0] = 0x72;
 	buf[1] = 0x03;
 	buf[2] = 0x0D;
 	i2c_master_send(client,buf,3);
-  
+
     	// Set minimum Q-scale {4}
 	buf[0] = 0x82;
 	buf[1] = 0x04;
 	i2c_master_send(client,buf,2);
-  
+
     	// Set maximum Q-scale {12}
 	buf[0] = 0x83;
 	buf[1] = 0x0C;
 	i2c_master_send(client,buf,2);
-  
+
     	// Set Output Protocol
 	buf[0] = 0xD0;
 	buf[1] = 0x01;
 	i2c_master_send(client,buf,2);
-  
+
     	// Set video output stream format {TS}
 	buf[0] = 0xB0;
 	buf[1] = 0x05;
 	i2c_master_send(client,buf,2);
-  
+
     	// Set Audio PID {0x103}
 	buf[0] = 0xC1;
 	buf[1] = 0x01;
 	buf[2] = 0x03;
 	i2c_master_send(client,buf,3);
-  
+
         // setup bitrate settings
 	data = i2c_get_clientdata(client);
 	if (params) {
@@ -290,18 +288,18 @@
 		// parameters were not supplied. use the previous set
    		saa6752hs_set_bitrate(client, (struct mpeg_params*) data);
 	}
-	  
+
 	// Send SI tables
   	i2c_master_send(client,PAT,sizeof(PAT));
   	i2c_master_send(client,PMT,sizeof(PMT));
-	  
+
 	// mute then unmute audio. This removes buzzing artefacts
 	buf[0] = 0xa4;
 	buf[1] = 1;
 	i2c_master_send(client, buf, 2);
   	buf[1] = 0;
 	i2c_master_send(client, buf, 2);
-	  
+
 	// start it going
 	saa6752hs_chip_command(client, SAA6752HS_COMMAND_START);
 
@@ -322,14 +320,14 @@
                 return -ENOMEM;
         memcpy(client,&client_template,sizeof(struct i2c_client));
 	strlcpy(client->name, "saa6752hs", sizeof(client->name));
-   
+
 	if (NULL == (params = kmalloc(sizeof(struct mpeg_params), GFP_KERNEL)))
 		return -ENOMEM;
 	memcpy(params,&mpeg_params_template,sizeof(struct mpeg_params));
 	i2c_set_clientdata(client, params);
 
         i2c_attach_client(client);
-  
+
 	return 0;
 }
 
@@ -364,7 +362,7 @@
 		/* nothing */
 		break;
 	}
-	
+
 	return 0;
 }
 
diff -Nru a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
--- a/drivers/media/video/saa7134/saa7134-cards.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/video/saa7134/saa7134-cards.c	2004-12-24 13:37:18 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-cards.c,v 1.35 2004/11/07 14:44:59 kraxel Exp $
+ *
  * device driver for philips saa7134 based TV cards
  * card-specific stuff.
  *
@@ -197,7 +199,7 @@
 			.name = name_radio,
 			.amux = LINE2,
 		},
-		.has_ts    = 1,
+		.mpeg      = SAA7134_MPEG_EMPRESS,
 		.video_out = CCIR656,
 	},
 	[SAA7134_BOARD_MONSTERTV] = {
@@ -321,7 +323,7 @@
 			.amux = LINE2,
 			.gpio = 0x20000,
 		},
-		.has_ts		= 1,
+		.mpeg           = SAA7134_MPEG_EMPRESS,
 		.video_out	= CCIR656,
 	},
 	[SAA7134_BOARD_CINERGY400] = {
@@ -404,6 +406,7 @@
                 .name           = "Terratec Cinergy 600 TV",
                 .audio_clock    = 0x00200000,
                 .tuner_type     = TUNER_PHILIPS_PAL,
+		.tda9887_conf   = TDA9887_PRESENT,
                 .inputs         = {{
                         .name = name_tv,
                         .vmux = 1,
@@ -625,7 +628,7 @@
 			.vmux = 8,
 			.amux = LINE1,
 		}},
-		.has_ts    = 1,
+		.mpeg      = SAA7134_MPEG_EMPRESS,
 		.video_out = CCIR656,
 	},
 	[SAA7134_BOARD_VIDEOMATE_TV] = {
@@ -647,6 +650,29 @@
                         .tv   = 1,
                 }},
         },
+    [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS] = {
+		.name           = "Compro VideoMate TV Gold+",
+		.audio_clock    = 0x00187de7,
+		.tuner_type     = TUNER_PHILIPS_NTSC_M,
+		.gpiomask       = 0x800c0000,
+                .inputs         = {{
+                        .name = name_svideo,
+                        .vmux = 8,
+                        .amux = LINE1,
+                        .gpio = 0x06c00012,
+                },{
+                        .name = name_comp1,
+                        .vmux = 3,
+                        .amux = LINE1,
+                        .gpio = 0x0ac20012,
+                },{
+                        .name = name_tv,
+                        .vmux = 1,
+                        .amux = LINE2,
+                        .gpio = 0x08c20012,
+                        .tv   = 1,
+                }},
+        },
 	[SAA7134_BOARD_CRONOS_PLUS] = {
 		/* gpio pins:
 		   0  .. 3   BASE_ID
@@ -726,7 +752,7 @@
 			.amux = LINE2,
 			.tv   = 1,
 		}},
-		.has_ts    = 1,
+		.mpeg      = SAA7134_MPEG_EMPRESS,
 		.video_out = CCIR656,
         },
         [SAA7134_BOARD_ASUSTEK_TVFM7133] = {
@@ -759,7 +785,7 @@
                 .name           = "Pinnacle PCTV Stereo (saa7134)",
                 .audio_clock    = 0x00187de7,
                 .tuner_type     = TUNER_MT2032,
-                .tda9887_conf   = TDA9887_PRESENT,
+                .tda9887_conf   = TDA9887_PRESENT | TDA9887_INTERCARRIER,
                 .inputs         = {{
                         .name = name_tv,
                         .vmux = 3,
@@ -812,7 +838,7 @@
 			.name = name_svideo,
 			.vmux = 8,
 			.amux = LINE1,
-		},{			
+		},{
 			.name = name_comp1,
 			.vmux = 1,
 			.amux = LINE1,
@@ -1049,8 +1075,19 @@
        			.name = name_tv,
 			.vmux = 1,
 			.amux = LINE2,
-			.gpio = 0x0000,
 			.tv   = 1,
+                },{
+                        .name = name_comp1,
+                        .vmux = 4,
+                        .amux = LINE1,
+                },{
+                        .name = name_svideo,
+                        .vmux = 8,
+                        .amux = LINE1,
+                },{
+                        .name = name_comp2, // CVideo over SVideo Connector
+                        .vmux = 0,
+                        .amux = LINE1,
 		}},
 		.mute = {
 			 .name = name_mute,
@@ -1091,6 +1128,156 @@
 			.gpio = 0x40000,
 		},
         },
+        [SAA7134_BOARD_SABRENT_SBTTVFM] = {
+		/* Michael Rodriguez-Torrent */
+                .name           = "Sabrent SBT-TVFM (saa7130)",
+                .audio_clock    = 0x00187de7,
+                .tuner_type     = TUNER_PHILIPS_NTSC_M,
+  		.tda9887_conf   = TDA9887_PRESENT,
+                .inputs         = {{
+                        .name = name_tv,
+                        .vmux = 3,
+                        .amux = LINE2,
+                        .tv   = 1,
+                },{
+                        .name = name_comp1,
+                        .vmux = 1,
+                        .amux = LINE2,
+                },{
+                        .name = name_svideo,
+                        .vmux = 8,
+                        .amux = LINE2,
+                }},
+                .radio = {
+                        .name   = name_radio,
+                        .amux   = LINE2,
+                },
+        },
+	[SAA7134_BOARD_ZOLID_XPERT_TV7134] = {
+		/* Helge Jensen <helge.jensen@slog.dk> */
+                .name           = ":Zolid Xpert TV7134",
+		.audio_clock    = 0x00187de7,
+		.tuner_type     = TUNER_PHILIPS_NTSC,
+                .inputs         = {{
+			.name = name_svideo,
+                        .vmux = 8,
+                        .amux = LINE1,
+                },{
+                        .name = name_comp1,
+                        .vmux = 3,
+                        .amux = LINE1,
+                },{
+                        .name = name_tv,
+                        .vmux = 1,
+                        .amux = LINE2,
+                        .tv   = 1,
+                }},
+	},
+	[SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE] = {
+		/* "Matteo Az" <matte.az@nospam.libero.it> ;-) */
+		.name           = "Empire PCI TV-Radio LE",
+		.audio_clock    = 0x00187de7,
+		.tuner_type     = TUNER_PHILIPS_PAL,
+		.gpiomask       = 0x4000,
+		.inputs         = {{
+			.name = name_tv_mono,
+			.vmux = 1,
+			.amux = LINE2,
+			.gpio = 0x8000,
+			.tv   = 1,
+		},{
+			.name = name_comp1,
+			.vmux = 3,
+			.amux = LINE1,
+			.gpio = 0x8000,
+		},{
+			.name = name_svideo,
+			.vmux = 6,
+			.amux = LINE1,
+			.gpio = 0x8000,
+		}},
+                .radio = {
+			 .name = name_radio,
+			 .amux = LINE1,
+			 .gpio = 0x8000,
+		 },
+		.mute = {
+			 .name = name_mute,
+			 .amux = TV,
+			 .gpio =0x8000,
+		 }
+	},
+        [SAA7134_BOARD_AVERMEDIA_307] = {
+		/* Nickolay V. Shmyrev <nshmyrev@yandex.ru> */
+		.name           = "Avermedia AVerTV Studio 307",
+		.audio_clock    = 0x00187de7,
+		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
+		.tda9887_conf   = TDA9887_PRESENT,
+		.inputs         = {{
+			.name = name_tv,
+			.vmux = 1,
+			.amux = TV,
+			.tv   = 1,
+		},{
+			.name = name_comp1,
+			.vmux = 0,
+			.amux = LINE2,
+		},{
+			.name = name_comp2,
+			.vmux = 3,
+			.amux = LINE2,
+		},{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE2,
+		}},
+		.radio = {
+			.name = name_radio,
+			.amux = TV,
+		},
+        },
+	[SAA7134_BOARD_AVERMEDIA_CARDBUS] = {
+		/* Jon Westgate <oryn@oryn.fsck.tv> */
+		.name           = "AVerMedia Cardbus TV/Radio",
+		.audio_clock    = 0x00200000,
+		.tuner_type     = TUNER_PHILIPS_PAL,
+		.inputs         = {{
+			.name = name_tv,
+			.vmux = 1,
+			.amux = LINE2,
+			.tv   = 1,
+		},{
+			.name = name_comp1,
+			.vmux = 3,
+			.amux = LINE2,
+		},{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE2,
+		}},
+		.radio = {
+                	.name = name_radio,
+			.amux = LINE1,
+		},
+	},
+	[SAA7134_BOARD_CINERGY400_CARDBUS] = {
+		.name           = "Terratec Cinergy 400 mobile",
+		.audio_clock    = 0x187de7,
+		.tuner_type     = UNSET /* not supported yet :/ */,
+		.inputs         = {{
+       			.name = name_tv,
+			.vmux = 5,
+			.tv   = 1,
+                },{
+                        .name = name_comp1,
+                        .vmux = 3,
+                        .amux = LINE1,
+                },{
+                        .name = name_svideo,
+                        .vmux = 4,
+                        .amux = LINE1,
+		}},
+	},
 };
 const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
 
@@ -1136,6 +1323,12 @@
                 .driver_data  = SAA7134_BOARD_CINERGY600,
         },{
 		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
+		.subvendor    = 0x153b,
+		.subdevice    = 0x1162,
+		.driver_data  = SAA7134_BOARD_CINERGY400_CARDBUS,
+        },{
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
 		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
 		.subvendor    = 0x5168,
 		.subdevice    = 0x0138,
@@ -1238,6 +1431,12 @@
 		.driver_data  = SAA7134_BOARD_VIDEOMATE_TV,
         },{
 		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
+                .subvendor    = 0x185b,
+                .subdevice    = 0xc100,
+		.driver_data  = SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS,
+        },{
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
 		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
                 .subvendor    = PCI_VENDOR_ID_MATROX,
                 .subdevice    = 0x48d0,
@@ -1261,6 +1460,13 @@
                 .subdevice    = 0x10ff,
 		.driver_data  = SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER,
         },{
+		/* AVerMedia CardBus */
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+                .subvendor    = 0x1461, /* Avermedia Technologies Inc */
+                .subdevice    = 0xd6ee,
+		.driver_data  = SAA7134_BOARD_AVERMEDIA_CARDBUS,
+	},{
 		/* TransGear 3000TV */
 		.vendor       = PCI_VENDOR_ID_PHILIPS,
 		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
@@ -1276,6 +1482,12 @@
         },{
                 .vendor       = PCI_VENDOR_ID_PHILIPS,
                 .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+                .subvendor    = 0x11bd,
+                .subdevice    = 0x002d, /* 300i DVB-T + PAL */
+                .driver_data  = SAA7134_BOARD_PINNACLE_PCTV_STEREO,
+        },{
+                .vendor       = PCI_VENDOR_ID_PHILIPS,
+                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
                 .subvendor    = 0x1019,
                 .subdevice    = 0x4cb4,
                 .driver_data  = SAA7134_BOARD_ECS_TVP3XP,
@@ -1304,7 +1516,14 @@
                 .subvendor    = 0x185b,
                 .subdevice    = 0xc100,
 		.driver_data  = SAA7134_BOARD_VIDEOMATE_TV_PVR,
-		
+
+ 	},{
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+               .subvendor    = 0x1461, /* Avermedia Technologies Inc */
+               .subdevice    = 0x9715,
+		.driver_data  = SAA7134_BOARD_AVERMEDIA_307,
+
  	},{
 		/* --- boards without eeprom + subsystem ID --- */
                 .vendor       = PCI_VENDOR_ID_PHILIPS,
@@ -1319,7 +1538,7 @@
 		.subdevice    = 0,
 		.driver_data  = SAA7134_BOARD_NOAUTO,
 	},{
-		
+
 		/* --- default catch --- */
 		.vendor       = PCI_VENDOR_ID_PHILIPS,
 		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
@@ -1401,7 +1620,7 @@
 
 /* ----------------------------------------------------------- */
 
-int saa7134_board_init(struct saa7134_dev *dev)
+int saa7134_board_init1(struct saa7134_dev *dev)
 {
 	// Always print gpio, often manufacturers encode tuner type and other info.
 	saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0);
@@ -1420,6 +1639,8 @@
 	case SAA7134_BOARD_CINERGY600:
 	case SAA7134_BOARD_ECS_TVP3XP:
 	case SAA7134_BOARD_ECS_TVP3XP_4CB5:
+	case SAA7134_BOARD_MD2819:
+	case SAA7134_BOARD_AVERMEDIA_307:
 		dev->has_remote = 1;
 		break;
 	case SAA7134_BOARD_AVACSSMARTTV:
@@ -1430,6 +1651,36 @@
 		       "%s: (with the same ID) out there.  If sound doesn't work for\n"
 		       "%s: you try the audio_clock_override=0x200000 insmod option.\n",
 		       dev->name,dev->name,dev->name);
+		break;
+	case SAA7134_BOARD_CINERGY400_CARDBUS:
+		/* power-up tuner chip */
+		saa_andorl(SAA7134_GPIO_GPMODE0 >> 2,   0x00040000, 0x00040000);
+		saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000);
+		break;
+	}
+	return 0;
+}
+
+/* stuff which needs working i2c */
+int saa7134_board_init2(struct saa7134_dev *dev)
+{
+	unsigned char buf;
+	int board;
+
+	switch (dev->board) {
+	case SAA7134_BOARD_BMK_MPEX_NOTUNER:
+	case SAA7134_BOARD_BMK_MPEX_TUNER:
+		dev->i2c_client.addr = 0x60;
+		board = (i2c_master_recv(&dev->i2c_client,&buf,0) < 0)
+			? SAA7134_BOARD_BMK_MPEX_NOTUNER
+			: SAA7134_BOARD_BMK_MPEX_TUNER;
+		if (board == dev->board)
+			break;
+		printk("%s: board type fixup: %s\n", dev->name,
+		       saa7134_boards[dev->board].name);
+		dev->tuner_type = saa7134_boards[dev->board].tuner_type;
+		if (TUNER_ABSENT != dev->tuner_type)
+			saa7134_i2c_call_clients(dev,TUNER_SET_TYPE,&dev->tuner_type);
 		break;
 	}
 	return 0;
diff -Nru a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
--- a/drivers/media/video/saa7134/saa7134-core.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/media/video/saa7134/saa7134-core.c	2004-12-24 13:36:34 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-core.c,v 1.15 2004/11/07 14:44:59 kraxel Exp $
+ *
  * device driver for philips saa7134 based TV cards
  * driver core
  *
@@ -27,6 +29,7 @@
 #include <linux/kmod.h>
 #include <linux/sound.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #include "saa7134-reg.h"
 #include "saa7134.h"
@@ -35,64 +38,56 @@
 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
 MODULE_LICENSE("GPL");
 
-#define SAA7134_MAXBOARDS 8
-
 /* ------------------------------------------------------------------ */
 
 static unsigned int irq_debug = 0;
-MODULE_PARM(irq_debug,"i");
+module_param(irq_debug, int, 0644);
 MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]");
 
 static unsigned int core_debug = 0;
-MODULE_PARM(core_debug,"i");
+module_param(core_debug, int, 0644);
 MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
 
 static unsigned int gpio_tracking = 0;
-MODULE_PARM(gpio_tracking,"i");
+module_param(gpio_tracking, int, 0644);
 MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]");
 
-static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(video_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM_DESC(video_nr,"video device number");
-
-static unsigned int ts_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(ts_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM_DESC(ts_nr,"ts device number");
-
-static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(vbi_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM_DESC(vbi_nr,"vbi device number");
-
-static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(radio_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM_DESC(radio_nr,"radio device number");
-
 static unsigned int oss = 0;
-MODULE_PARM(oss,"i");
+module_param(oss, int, 0444);
 MODULE_PARM_DESC(oss,"register oss devices (default: no)");
 
-static unsigned int dsp_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(dsp_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM_DESC(dsp_nr,"oss dsp device number");
-
-static unsigned int mixer_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(mixer_nr,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM_DESC(mixer_nr,"oss mixer device number");
-
-static unsigned int tuner[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(tuner,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM_DESC(tuner,"tuner type");
-
-static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-MODULE_PARM(card,"1-" __stringify(SAA7134_MAXBOARDS) "i");
-MODULE_PARM_DESC(card,"card type");
-
 static unsigned int latency = UNSET;
-MODULE_PARM(latency,"i");
+module_param(latency, int, 0444);
 MODULE_PARM_DESC(latency,"pci latency timer");
 
-struct list_head  saa7134_devlist;
-unsigned int      saa7134_devcount;
+static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+static unsigned int vbi_nr[]   = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+static unsigned int dsp_nr[]   = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+static unsigned int mixer_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+static unsigned int tuner[]    = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+static unsigned int card[]     = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+
+module_param_array(video_nr, int, NULL, 0444);
+module_param_array(vbi_nr,   int, NULL, 0444);
+module_param_array(radio_nr, int, NULL, 0444);
+module_param_array(dsp_nr,   int, NULL, 0444);
+module_param_array(mixer_nr, int, NULL, 0444);
+module_param_array(tuner,    int, NULL, 0444);
+module_param_array(card,     int, NULL, 0444);
+
+MODULE_PARM_DESC(video_nr, "video device number");
+MODULE_PARM_DESC(vbi_nr,   "vbi device number");
+MODULE_PARM_DESC(radio_nr, "radio device number");
+MODULE_PARM_DESC(dsp_nr,   "oss dsp device number");
+MODULE_PARM_DESC(mixer_nr, "oss mixer device number");
+MODULE_PARM_DESC(tuner,    "tuner type");
+MODULE_PARM_DESC(card,     "card type");
+
+static DECLARE_MUTEX(devlist_lock);
+LIST_HEAD(saa7134_devlist);
+static LIST_HEAD(mops_list);
+unsigned int saa7134_devcount;
 
 #define dprintk(fmt, arg...)	if (core_debug) \
 	printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
@@ -243,7 +238,7 @@
 int saa7134_buffer_count(unsigned int size, unsigned int count)
 {
 	unsigned int maxcount;
-	
+
 	maxcount = 1024 / saa7134_buffer_pages(size);
 	if (count > maxcount)
 		count = maxcount;
@@ -270,7 +265,7 @@
 {
         u32          *cpu;
         dma_addr_t   dma_addr;
-	
+
 	cpu = pci_alloc_consistent(pci, SAA7134_PGTABLE_SIZE, &dma_addr);
 	if (NULL == cpu)
 		return -ENOMEM;
@@ -327,7 +322,7 @@
 #ifdef DEBUG_SPINLOCKS
 	BUG_ON(!spin_is_locked(&dev->slock));
 #endif
-	
+
 	dprintk("buffer_queue %p\n",buf);
 	if (NULL == q->curr) {
 		if (!q->need_two) {
@@ -357,7 +352,7 @@
 	BUG_ON(!spin_is_locked(&dev->slock));
 #endif
 	dprintk("buffer_finish %p\n",q->curr);
-	
+
 	/* finish current buffer */
 	q->curr->vb.state = state;
 	do_gettimeofday(&q->curr->vb.ts);
@@ -480,7 +475,7 @@
 			SAA7134_IRQ1_INTE_RA2_1 |
 			SAA7134_IRQ1_INTE_RA2_0;
 	}
-	
+
 	/* set task conditions + field handling */
 	if (V4L2_FIELD_HAS_BOTH(cap) || V4L2_FIELD_HAS_BOTH(ov) || cap == ov) {
 		/* default config -- use full frames */
@@ -504,7 +499,7 @@
 		saa_writeb(SAA7134_FIELD_HANDLING(TASK_B),  0x01);
 		split = 1;
 	}
-	
+
 	/* irqs */
 	saa_writeb(SAA7134_REGION_ENABLE, task);
 	saa_writel(SAA7134_IRQ1,          irq);
@@ -538,7 +533,7 @@
 			    unsigned long report, unsigned long status)
 {
 	unsigned int i;
-	
+
 	printk(KERN_DEBUG "%s/irq[%d,%ld]: r=0x%lx s=0x%02lx",
 	       dev->name,loop,jiffies,report,status);
 	for (i = 0; i < IRQBITS; i++) {
@@ -593,7 +588,7 @@
 			saa7134_irq_vbi_done(dev,status);
 
 		if ((report & SAA7134_IRQ_REPORT_DONE_RA2) &&
-		    card_has_ts(dev))
+		    card_has_mpeg(dev))
 			saa7134_irq_ts_done(dev,status);
 
 		if ((report & SAA7134_IRQ_REPORT_DONE_RA3))
@@ -640,7 +635,7 @@
 	saa7134_track_gpio(dev,"pre-init");
 	saa7134_video_init1(dev);
 	saa7134_vbi_init1(dev);
-	if (card_has_ts(dev))
+	if (card_has_mpeg(dev))
 		saa7134_ts_init1(dev);
 	saa7134_input_init1(dev);
 
@@ -651,11 +646,11 @@
 		saa7134_oss_init1(dev);
 		break;
 	}
-	
+
 	/* RAM FIFO config */
 	saa_writel(SAA7134_FIFO_SIZE, 0x08070503);
 	saa_writel(SAA7134_THRESHOULD,0x02020202);
-	
+
 	/* enable audio + video processing */
 	saa_writel(SAA7134_MAIN_CTRL,
 		   SAA7134_MAIN_CTRL_VPLLE |
@@ -672,7 +667,7 @@
 
 	/* set vertical line numbering start (vbi needs this) */
 	saa_writeb(SAA7134_SOURCE_TIMING2, 0x20);
-	
+
 	return 0;
 }
 
@@ -716,7 +711,7 @@
 		saa7134_oss_fini(dev);
 		break;
 	}
-	if (card_has_ts(dev))
+	if (card_has_mpeg(dev))
 		saa7134_ts_fini(dev);
 	saa7134_input_fini(dev);
 	saa7134_vbi_fini(dev);
@@ -757,7 +752,7 @@
 				      char *type)
 {
 	struct video_device *vfd;
-	
+
 	vfd = video_device_alloc();
 	if (NULL == vfd)
 		return NULL;
@@ -779,13 +774,6 @@
 			video_device_release(dev->video_dev);
 		dev->video_dev = NULL;
 	}
-	if (dev->ts_dev) {
-		if (-1 != dev->ts_dev->minor)
-			video_unregister_device(dev->ts_dev);
-		else
-			video_device_release(dev->ts_dev);
-		dev->ts_dev = NULL;
-	}
 	if (dev->vbi_dev) {
 		if (-1 != dev->vbi_dev->minor)
 			video_unregister_device(dev->vbi_dev);
@@ -802,10 +790,38 @@
 	}
 }
 
+static void mpeg_ops_attach(struct saa7134_mpeg_ops *ops,
+			    struct saa7134_dev *dev)
+{
+	int err;
+
+	if (NULL != dev->mops)
+		return;
+	if (saa7134_boards[dev->board].mpeg != ops->type)
+		return;
+	err = ops->init(dev);
+	if (0 != err)
+		return;
+	dev->mops = ops;
+}
+
+static void mpeg_ops_detach(struct saa7134_mpeg_ops *ops,
+			    struct saa7134_dev *dev)
+{
+	if (NULL == dev->mops)
+		return;
+	if (dev->mops != ops)
+		return;
+	dev->mops->fini(dev);
+	dev->mops = NULL;
+}
+
 static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
 				     const struct pci_device_id *pci_id)
 {
 	struct saa7134_dev *dev;
+	struct list_head *item;
+	struct saa7134_mpeg_ops *mops;
 	int err;
 
 	dev = kmalloc(sizeof(*dev),GFP_KERNEL);
@@ -819,7 +835,9 @@
 		err = -EIO;
 		goto fail1;
 	}
-	sprintf(dev->name,"saa%x[%d]",pci_dev->device,saa7134_devcount);
+
+	dev->nr = saa7134_devcount;
+	sprintf(dev->name,"saa%x[%d]",pci_dev->device,dev->nr);
 
 	/* pci quirks */
 	if (pci_pci_problems) {
@@ -861,21 +879,21 @@
 
 	/* board config */
 	dev->board = pci_id->driver_data;
-	if (card[saa7134_devcount] >= 0 &&
-	    card[saa7134_devcount] < saa7134_bcount)
-		dev->board = card[saa7134_devcount];
+	if (card[dev->nr] >= 0 &&
+	    card[dev->nr] < saa7134_bcount)
+		dev->board = card[dev->nr];
 	if (SAA7134_BOARD_NOAUTO == dev->board) {
 		must_configure_manually();
 		dev->board = SAA7134_BOARD_UNKNOWN;
 	}
 	dev->tuner_type   = saa7134_boards[dev->board].tuner_type;
 	dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf;
-	if (UNSET != tuner[saa7134_devcount])
-		dev->tuner_type = tuner[saa7134_devcount];
+	if (UNSET != tuner[dev->nr])
+		dev->tuner_type = tuner[dev->nr];
         printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
 	       dev->name,pci_dev->subsystem_vendor,
 	       pci_dev->subsystem_device,saa7134_boards[dev->board].name,
-	       dev->board, card[saa7134_devcount] == dev->board ?
+	       dev->board, card[dev->nr] == dev->board ?
 	       "insmod option" : "autodetected");
 
 	/* get mmio */
@@ -888,7 +906,7 @@
 		goto fail1;
 	}
 	dev->lmmio = ioremap(pci_resource_start(pci_dev,0), 0x1000);
-	dev->bmmio = (__u8*)dev->lmmio;
+	dev->bmmio = (__u8 __iomem *)dev->lmmio;
 	if (NULL == dev->lmmio) {
 		err = -EIO;
 		printk(KERN_ERR "%s: can't ioremap() MMIO memory\n",
@@ -897,7 +915,7 @@
 	}
 
 	/* initialize hardware #1 */
-	saa7134_board_init(dev);
+	saa7134_board_init1(dev);
 	saa7134_hwinit1(dev);
 
 	/* get irq */
@@ -910,11 +928,11 @@
 	}
 
 	/* wait a bit, register i2c bus */
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ/10);
+	msleep(100);
 	saa7134_i2c_register(dev);
 
 	/* initialize hardware #2 */
+	saa7134_board_init2(dev);
 	saa7134_hwinit2(dev);
 
 	/* load i2c helpers */
@@ -922,17 +940,19 @@
 		request_module("tuner");
 	if (dev->tda9887_conf)
 		request_module("tda9887");
-  	if (card_has_ts(dev))
+  	if (card_is_empress(dev)) {
+		request_module("saa7134-empress");
 		request_module("saa6752hs");
+	}
+  	if (card_is_dvb(dev))
+		request_module("saa7134-dvb");
 
-#ifdef VIDIOC_G_PRIORITY
 	v4l2_prio_init(&dev->prio);
-#endif
 
 	/* register v4l devices */
 	dev->video_dev = vdev_init(dev,&saa7134_video_template,"video");
 	err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
-				    video_nr[saa7134_devcount]);
+				    video_nr[dev->nr]);
 	if (err < 0) {
 		printk(KERN_INFO "%s: can't register video device\n",
 		       dev->name);
@@ -941,22 +961,9 @@
 	printk(KERN_INFO "%s: registered device video%d [v4l2]\n",
 	       dev->name,dev->video_dev->minor & 0x1f);
 
-	if (card_has_ts(dev)) {
-		dev->ts_dev = vdev_init(dev,&saa7134_ts_template,"ts");
-		err = video_register_device(dev->ts_dev,VFL_TYPE_GRABBER,
-					    ts_nr[saa7134_devcount]);
-		if (err < 0) {
-			printk(KERN_INFO "%s: can't register video device\n",
-			       dev->name);
-			goto fail4;
-		}
-		printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
-		       dev->name,dev->ts_dev->minor & 0x1f);
-	}
-	
 	dev->vbi_dev = vdev_init(dev,&saa7134_vbi_template,"vbi");
 	err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
-				    vbi_nr[saa7134_devcount]);
+				    vbi_nr[dev->nr]);
 	if (err < 0)
 		goto fail4;
 	printk(KERN_INFO "%s: registered device vbi%d\n",
@@ -965,7 +972,7 @@
 	if (card_has_radio(dev)) {
 		dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio");
 		err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
-					    radio_nr[saa7134_devcount]);
+					    radio_nr[dev->nr]);
 		if (err < 0)
 			goto fail4;
 		printk(KERN_INFO "%s: registered device radio%d\n",
@@ -980,16 +987,16 @@
 		if (oss) {
 			err = dev->oss.minor_dsp =
 				register_sound_dsp(&saa7134_dsp_fops,
-						   dsp_nr[saa7134_devcount]);
+						   dsp_nr[dev->nr]);
 			if (err < 0) {
 				goto fail4;
 			}
 			printk(KERN_INFO "%s: registered device dsp%d\n",
 			       dev->name,dev->oss.minor_dsp >> 4);
-			
+
 			err = dev->oss.minor_mixer =
 				register_sound_mixer(&saa7134_mixer_fops,
-						     mixer_nr[saa7134_devcount]);
+						     mixer_nr[dev->nr]);
 			if (err < 0)
 				goto fail5;
 			printk(KERN_INFO "%s: registered device mixer%d\n",
@@ -999,9 +1006,16 @@
 	}
 
 	/* everything worked */
-	list_add_tail(&dev->devlist,&saa7134_devlist);
 	pci_set_drvdata(pci_dev,dev);
 	saa7134_devcount++;
+
+	down(&devlist_lock);
+	list_for_each(item,&mops_list) {
+		mops = list_entry(item, struct saa7134_mpeg_ops, next);
+		mpeg_ops_attach(mops, dev);
+	}
+	list_add_tail(&dev->devlist,&saa7134_devlist);
+	up(&devlist_lock);
 	return 0;
 
  fail5:
@@ -1031,6 +1045,8 @@
 static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
 {
         struct saa7134_dev *dev = pci_get_drvdata(pci_dev);
+	struct list_head *item;
+	struct saa7134_mpeg_ops *mops;
 
 	/* debugging ... */
 	if (irq_debug) {
@@ -1051,6 +1067,15 @@
 	saa7134_hwfini(dev);
 
 	/* unregister */
+	down(&devlist_lock);
+	list_del(&dev->devlist);
+	list_for_each(item,&mops_list) {
+		mops = list_entry(item, struct saa7134_mpeg_ops, next);
+		mpeg_ops_detach(mops, dev);
+	}
+	up(&devlist_lock);
+	saa7134_devcount--;
+
 	saa7134_i2c_unregister(dev);
 	switch (dev->pci->device) {
 	case PCI_DEVICE_ID_PHILIPS_SAA7134:
@@ -1076,16 +1101,50 @@
 	pci_set_drvdata(pci_dev, NULL);
 
 	/* free memory */
-	list_del(&dev->devlist);
-	saa7134_devcount--;
 	kfree(dev);
 }
 
+/* ----------------------------------------------------------- */
+
+int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
+{
+	struct list_head *item;
+	struct saa7134_dev *dev;
+
+	down(&devlist_lock);
+	list_for_each(item,&saa7134_devlist) {
+		dev = list_entry(item, struct saa7134_dev, devlist);
+		mpeg_ops_attach(ops, dev);
+	}
+	list_add_tail(&ops->next,&mops_list);
+	up(&devlist_lock);
+	return 0;
+}
+
+void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops)
+{
+	struct list_head *item;
+	struct saa7134_dev *dev;
+
+	down(&devlist_lock);
+	list_del(&ops->next);
+	list_for_each(item,&saa7134_devlist) {
+		dev = list_entry(item, struct saa7134_dev, devlist);
+		mpeg_ops_detach(ops, dev);
+	}
+	up(&devlist_lock);
+}
+
+EXPORT_SYMBOL(saa7134_ts_register);
+EXPORT_SYMBOL(saa7134_ts_unregister);
+
+/* ----------------------------------------------------------- */
+
 static struct pci_driver saa7134_pci_driver = {
         .name     = "saa7134",
         .id_table = saa7134_pci_tbl,
         .probe    = saa7134_initdev,
-        .remove   = saa7134_finidev,
+        .remove   = __devexit_p(saa7134_finidev),
 };
 
 static int saa7134_init(void)
@@ -1109,6 +1168,13 @@
 
 module_init(saa7134_init);
 module_exit(saa7134_fini);
+
+/* ----------------------------------------------------------- */
+
+EXPORT_SYMBOL(saa7134_print_ioctl);
+EXPORT_SYMBOL(saa7134_i2c_call_clients);
+EXPORT_SYMBOL(saa7134_devlist);
+EXPORT_SYMBOL(saa7134_boards);
 
 /* ----------------------------------------------------------- */
 /*
diff -Nru a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/video/saa7134/saa7134-dvb.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,91 @@
+/*
+ * $Id: saa7134-dvb.c,v 1.4 2004/11/07 14:44:59 kraxel Exp $
+ *
+ * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *
+ *  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.
+ */
+
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/kthread.h>
+#include <linux/suspend.h>
+
+#include "saa7134-reg.h"
+#include "saa7134.h"
+
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+/* ------------------------------------------------------------------ */
+
+static int dvb_init(struct saa7134_dev *dev)
+{
+	printk("%s: %s\n",dev->name,__FUNCTION__);
+
+	/* init struct videobuf_dvb */
+	dev->dvb.name = dev->name;
+	videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
+			    dev->pci, &dev->slock,
+			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
+			    V4L2_FIELD_TOP,
+			    sizeof(struct saa7134_buf),
+			    dev);
+
+	/* TODO: init frontend */
+	if (NULL == dev->dvb.frontend)
+		return -1;
+
+	/* register everything else */
+	return videobuf_dvb_register(&dev->dvb);
+}
+
+static int dvb_fini(struct saa7134_dev *dev)
+{
+	printk("%s: %s\n",dev->name,__FUNCTION__);
+	videobuf_dvb_unregister(&dev->dvb);
+	return 0;
+}
+
+static struct saa7134_mpeg_ops dvb_ops = {
+	.type          = SAA7134_MPEG_DVB,
+	.init          = dvb_init,
+	.fini          = dvb_fini,
+};
+
+static int __init dvb_register(void)
+{
+	return saa7134_ts_register(&dvb_ops);
+}
+
+static void __exit dvb_unregister(void)
+{
+	saa7134_ts_unregister(&dvb_ops);
+}
+
+module_init(dvb_register);
+module_exit(dvb_unregister);
+
+/* ------------------------------------------------------------------ */
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * compile-command: "make DVB=1"
+ * End:
+ */
diff -Nru a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/video/saa7134/saa7134-empress.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,394 @@
+/*
+ * $Id: saa7134-empress.c,v 1.3 2004/11/07 13:17:15 kraxel Exp $
+ *
+ * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *
+ *  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.
+ */
+
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+
+#include "saa7134-reg.h"
+#include "saa7134.h"
+
+#include <media/saa6752hs.h>
+
+/* ------------------------------------------------------------------ */
+
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+static unsigned int empress_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+module_param_array(empress_nr, int, NULL, 0444);
+MODULE_PARM_DESC(empress_nr,"ts device number");
+
+static unsigned int debug = 0;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug,"enable debug messages");
+
+#define dprintk(fmt, arg...)	if (debug)			\
+	printk(KERN_DEBUG "%s/empress: " fmt, dev->name , ## arg)
+
+/* ------------------------------------------------------------------ */
+
+static void ts_reset_encoder(struct saa7134_dev* dev)
+{
+	saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
+	msleep(10);
+   	saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
+	msleep(100);
+}
+
+static int ts_init_encoder(struct saa7134_dev* dev, void* arg)
+{
+	ts_reset_encoder(dev);
+	saa7134_i2c_call_clients(dev, MPEG_SETPARAMS, arg);
+ 	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+
+static int ts_open(struct inode *inode, struct file *file)
+{
+	int minor = iminor(inode);
+	struct saa7134_dev *h,*dev = NULL;
+	struct list_head *list;
+	int err;
+
+	list_for_each(list,&saa7134_devlist) {
+		h = list_entry(list, struct saa7134_dev, devlist);
+		if (h->empress_dev && h->empress_dev->minor == minor)
+			dev = h;
+	}
+	if (NULL == dev)
+		return -ENODEV;
+
+	dprintk("open minor=%d\n",minor);
+	down(&dev->empress_tsq.lock);
+	err = -EBUSY;
+	if (dev->empress_users)
+		goto done;
+
+	dev->empress_users++;
+	file->private_data = dev;
+	ts_init_encoder(dev, NULL);
+	err = 0;
+
+ done:
+	up(&dev->empress_tsq.lock);
+	return err;
+}
+
+static int ts_release(struct inode *inode, struct file *file)
+{
+	struct saa7134_dev *dev = file->private_data;
+
+	if (dev->empress_tsq.streaming)
+		videobuf_streamoff(&dev->empress_tsq);
+	down(&dev->empress_tsq.lock);
+	if (dev->empress_tsq.reading)
+		videobuf_read_stop(&dev->empress_tsq);
+	dev->empress_users--;
+
+	/* stop the encoder */
+	ts_reset_encoder(dev);
+
+	up(&dev->empress_tsq.lock);
+	return 0;
+}
+
+static ssize_t
+ts_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
+{
+	struct saa7134_dev *dev = file->private_data;
+
+	return videobuf_read_stream(&dev->empress_tsq,
+				    data, count, ppos, 0,
+				    file->f_flags & O_NONBLOCK);
+}
+
+static unsigned int
+ts_poll(struct file *file, struct poll_table_struct *wait)
+{
+	struct saa7134_dev *dev = file->private_data;
+
+	return videobuf_poll_stream(file, &dev->empress_tsq, wait);
+}
+
+
+static int
+ts_mmap(struct file *file, struct vm_area_struct * vma)
+{
+	struct saa7134_dev *dev = file->private_data;
+
+	return videobuf_mmap_mapper(&dev->empress_tsq, vma);
+}
+
+/*
+ * This function is _not_ called directly, but from
+ * video_generic_ioctl (and maybe others).  userspace
+ * copying is done already, arg is a kernel pointer.
+ */
+static int ts_do_ioctl(struct inode *inode, struct file *file,
+		       unsigned int cmd, void *arg)
+{
+	struct saa7134_dev *dev = file->private_data;
+
+	if (debug > 1)
+		saa7134_print_ioctl(dev->name,cmd);
+	switch (cmd) {
+	case VIDIOC_QUERYCAP:
+	{
+		struct v4l2_capability *cap = arg;
+
+		memset(cap,0,sizeof(*cap));
+                strcpy(cap->driver, "saa7134");
+		strlcpy(cap->card, saa7134_boards[dev->board].name,
+			sizeof(cap->card));
+		sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
+		cap->version = SAA7134_VERSION_CODE;
+		cap->capabilities =
+			V4L2_CAP_VIDEO_CAPTURE |
+			V4L2_CAP_READWRITE |
+			V4L2_CAP_STREAMING;
+		return 0;
+	}
+
+	/* --- input switching --------------------------------------- */
+	case VIDIOC_ENUMINPUT:
+	{
+		struct v4l2_input *i = arg;
+
+		if (i->index != 0)
+			return -EINVAL;
+		i->type = V4L2_INPUT_TYPE_CAMERA;
+		strcpy(i->name,"CCIR656");
+		return 0;
+	}
+	case VIDIOC_G_INPUT:
+	{
+		int *i = arg;
+		*i = 0;
+		return 0;
+	}
+	case VIDIOC_S_INPUT:
+	{
+		int *i = arg;
+
+		if (*i != 0)
+			return -EINVAL;
+		return 0;
+	}
+	/* --- capture ioctls ---------------------------------------- */
+
+	case VIDIOC_ENUM_FMT:
+	{
+		struct v4l2_fmtdesc *f = arg;
+		int index;
+
+		index = f->index;
+		if (index != 0)
+			return -EINVAL;
+
+		memset(f,0,sizeof(*f));
+		f->index = index;
+		strlcpy(f->description, "MPEG TS", sizeof(f->description));
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		f->pixelformat = V4L2_PIX_FMT_MPEG;
+		return 0;
+	}
+
+	case VIDIOC_G_FMT:
+	{
+		struct v4l2_format *f = arg;
+
+		memset(f,0,sizeof(*f));
+		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+		/* FIXME: translate subsampling type EMPRESS into
+		 *        width/height: */
+		f->fmt.pix.width        = 720; /* D1 */
+		f->fmt.pix.height       = 576;
+		f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+		f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
+		return 0;
+	}
+
+	case VIDIOC_S_FMT:
+	{
+		struct v4l2_format *f = arg;
+
+		if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		    return -EINVAL;
+
+		/*
+		  FIXME: translate and round width/height into EMPRESS
+		  subsample type:
+
+		          type  |   PAL   |  NTSC
+			---------------------------
+			  SIF   | 352x288 | 352x240
+			 1/2 D1 | 352x576 | 352x480
+			 2/3 D1 | 480x576 | 480x480
+			  D1    | 720x576 | 720x480
+		*/
+
+		f->fmt.pix.width        = 720; /* D1 */
+		f->fmt.pix.height       = 576;
+		f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+		f->fmt.pix.sizeimage    = TS_PACKET_SIZE* dev->ts.nr_packets;
+		return 0;
+	}
+
+	case VIDIOC_REQBUFS:
+		return videobuf_reqbufs(&dev->empress_tsq,arg);
+
+	case VIDIOC_QUERYBUF:
+		return videobuf_querybuf(&dev->empress_tsq,arg);
+
+	case VIDIOC_QBUF:
+		return videobuf_qbuf(&dev->empress_tsq,arg);
+
+	case VIDIOC_DQBUF:
+		return videobuf_dqbuf(&dev->empress_tsq,arg,
+				      file->f_flags & O_NONBLOCK);
+
+	case VIDIOC_STREAMON:
+		return videobuf_streamon(&dev->empress_tsq);
+
+	case VIDIOC_STREAMOFF:
+		return videobuf_streamoff(&dev->empress_tsq);
+
+	case VIDIOC_QUERYCTRL:
+	case VIDIOC_G_CTRL:
+	case VIDIOC_S_CTRL:
+		return saa7134_common_ioctl(dev, cmd, arg);
+
+	case MPEG_SETPARAMS:
+		return ts_init_encoder(dev, arg);
+
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return 0;
+}
+
+static int ts_ioctl(struct inode *inode, struct file *file,
+		     unsigned int cmd, unsigned long arg)
+{
+	return video_usercopy(inode, file, cmd, arg, ts_do_ioctl);
+}
+
+static struct file_operations ts_fops =
+{
+	.owner	  = THIS_MODULE,
+	.open	  = ts_open,
+	.release  = ts_release,
+	.read	  = ts_read,
+	.poll	  = ts_poll,
+	.mmap	  = ts_mmap,
+	.ioctl	  = ts_ioctl,
+	.llseek   = no_llseek,
+};
+
+/* ----------------------------------------------------------- */
+
+static struct video_device saa7134_empress_template =
+{
+	.name          = "saa7134-empress",
+	.type          = 0 /* FIXME */,
+	.type2         = 0 /* FIXME */,
+	.hardware      = 0,
+	.fops          = &ts_fops,
+	.minor	       = -1,
+};
+
+static int empress_init(struct saa7134_dev *dev)
+{
+	int err;
+
+	dprintk("%s: %s\n",dev->name,__FUNCTION__);
+	dev->empress_dev = video_device_alloc();
+	if (NULL == dev->empress_dev)
+		return -ENOMEM;
+	*(dev->empress_dev) = saa7134_empress_template;
+	dev->empress_dev->dev     = &dev->pci->dev;
+	dev->empress_dev->release = video_device_release;
+	snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),
+		 "%s empress (%s)", dev->name,
+		 saa7134_boards[dev->board].name);
+
+	err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
+				    empress_nr[dev->nr]);
+	if (err < 0) {
+		printk(KERN_INFO "%s: can't register video device\n",
+		       dev->name);
+		video_device_release(dev->empress_dev);
+		dev->empress_dev = NULL;
+		return err;
+	}
+	printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
+	       dev->name,dev->empress_dev->minor & 0x1f);
+
+	videobuf_queue_init(&dev->empress_tsq, &saa7134_ts_qops,
+			    dev->pci, &dev->slock,
+			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
+			    V4L2_FIELD_ALTERNATE,
+			    sizeof(struct saa7134_buf),
+			    dev);
+	return 0;
+}
+
+static int empress_fini(struct saa7134_dev *dev)
+{
+	dprintk("%s: %s\n",dev->name,__FUNCTION__);
+
+	if (NULL == dev->empress_dev)
+		return 0;
+	video_unregister_device(dev->empress_dev);
+	dev->empress_dev = NULL;
+	return 0;
+}
+
+static struct saa7134_mpeg_ops empress_ops = {
+	.type          = SAA7134_MPEG_EMPRESS,
+	.init          = empress_init,
+	.fini          = empress_fini,
+};
+
+static int __init empress_register(void)
+{
+	return saa7134_ts_register(&empress_ops);
+}
+
+static void __exit empress_unregister(void)
+{
+	saa7134_ts_unregister(&empress_ops);
+}
+
+module_init(empress_register);
+module_exit(empress_unregister);
+
+/* ----------------------------------------------------------- */
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -Nru a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c
--- a/drivers/media/video/saa7134/saa7134-i2c.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/media/video/saa7134/saa7134-i2c.c	2004-12-24 13:36:19 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-i2c.c,v 1.7 2004/11/07 13:17:15 kraxel Exp $
+ *
  * device driver for philips saa7134 based TV cards
  * i2c interface support
  *
@@ -32,11 +34,11 @@
 /* ----------------------------------------------------------- */
 
 static unsigned int i2c_debug = 0;
-MODULE_PARM(i2c_debug,"i");
+module_param(i2c_debug, int, 0644);
 MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]");
 
 static unsigned int i2c_scan = 0;
-MODULE_PARM(i2c_scan,"i");
+module_param(i2c_scan, int, 0444);
 MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
 
 #define d1printk if (1 == i2c_debug) printk
@@ -86,7 +88,7 @@
 static inline enum i2c_status i2c_get_status(struct saa7134_dev *dev)
 {
 	enum i2c_status status;
-	
+
 	status = saa_readb(SAA7134_I2C_ATTR_STATUS) & 0x0f;
 	d2printk(KERN_DEBUG "%s: i2c stat <= %s\n",dev->name,
 		 str_i2c_status[status]);
@@ -182,7 +184,7 @@
 
 	if (!i2c_is_idle(status))
 		return FALSE;
-	
+
 	i2c_set_attr(dev,NOP);
 	return TRUE;
 }
@@ -208,7 +210,7 @@
 	saa_writel(SAA7134_I2C_ATTR_STATUS >> 2, dword);
 #endif
 	d2printk(KERN_DEBUG "%s: i2c data => 0x%x\n",dev->name,data);
-	
+
 	if (!i2c_is_busy_wait(dev))
 		return -EIO;
 	status = i2c_get_status(dev);
@@ -221,7 +223,7 @@
 {
 	enum i2c_status status;
 	unsigned char data;
-	
+
 	i2c_set_attr(dev,CONTINUE);
 	if (!i2c_is_busy_wait(dev))
 		return -EIO;
@@ -300,7 +302,7 @@
 
 /* ----------------------------------------------------------- */
 
-static int algo_control(struct i2c_adapter *adapter, 
+static int algo_control(struct i2c_adapter *adapter,
 			unsigned int cmd, unsigned long arg)
 {
 	return 0;
@@ -393,21 +395,26 @@
 	return 0;
 }
 
-static int
-saa7134_i2c_scan(struct saa7134_dev *dev)
+static char *i2c_devs[128] = {
+	[ 0x20      ] = "mpeg encoder (saa6752hs)",
+	[ 0xa0 >> 1 ] = "eeprom",
+	[ 0xc0 >> 1 ] = "tuner (analog)",
+	[ 0x86 >> 1 ] = "tda9887",
+};
+
+static void do_i2c_scan(char *name, struct i2c_client *c)
 {
 	unsigned char buf;
 	int i,rc;
 
-	for (i = 0; i < 256; i+= 2) {
-		dev->i2c_client.addr = i >> 1;
-		rc = i2c_master_recv(&dev->i2c_client,&buf,0);
+	for (i = 0; i < 128; i++) {
+		c->addr = i;
+		rc = i2c_master_recv(c,&buf,0);
 		if (rc < 0)
 			continue;
-		printk("%s: i2c scan: found device @ %x%s\n",
-		       dev->name, i, (i == 0xa0) ? " [eeprom]" : "");
+		printk("%s: i2c scan: found device @ 0x%x  [%s]\n",
+		       name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
 	}
-	return 0;
 }
 
 void saa7134_i2c_call_clients(struct saa7134_dev *dev,
@@ -424,13 +431,13 @@
 	strcpy(dev->i2c_adap.name,dev->name);
 	dev->i2c_adap.algo_data = dev;
 	i2c_add_adapter(&dev->i2c_adap);
-	
+
 	dev->i2c_client = saa7134_client_template;
 	dev->i2c_client.adapter = &dev->i2c_adap;
-	
+
 	saa7134_i2c_eeprom(dev,dev->eedata,sizeof(dev->eedata));
 	if (i2c_scan)
-		saa7134_i2c_scan(dev);
+		do_i2c_scan(dev->name,&dev->i2c_client);
 	return 0;
 }
 
diff -Nru a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
--- a/drivers/media/video/saa7134/saa7134-input.c	2004-12-24 13:37:44 -08:00
+++ b/drivers/media/video/saa7134/saa7134-input.c	2004-12-24 13:37:44 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-input.c,v 1.12 2004/11/07 13:17:15 kraxel Exp $
+ *
  * handle saa7134 IR remotes via linux kernel input layer.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -28,11 +30,11 @@
 #include "saa7134.h"
 
 static unsigned int disable_ir = 0;
-MODULE_PARM(disable_ir,"i");
+module_param(disable_ir, int, 0444);
 MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
 
 static unsigned int ir_debug = 0;
-MODULE_PARM(ir_debug,"i");
+module_param(ir_debug, int, 0644);
 MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
 
 #define dprintk(fmt, arg...)	if (ir_debug) \
@@ -61,7 +63,7 @@
 	[   20 ] = KEY_VOLUMEUP,
 	[   23 ] = KEY_VOLUMEDOWN,
 	[   18 ] = KEY_CHANNELUP,    // Channel +
-	[   19 ] = KEY_CHANNELDOWN,  // Channel - 
+	[   19 ] = KEY_CHANNELDOWN,  // Channel -
 	[    6 ] = KEY_AGAIN,        // Recal
 	[   16 ] = KEY_KPENTER,      // Enter
 
@@ -209,6 +211,53 @@
         [ 15 ] = KEY_F22,		// min
 	[ 26 ] = KEY_F23,		// freeze
 };
+
+/* Alex Hermann <gaaf@gmx.net> */
+static IR_KEYTAB_TYPE md2819_codes[IR_KEYTAB_SIZE] = {
+	[ 40 ] = KEY_KP1,
+	[ 24 ] = KEY_KP2,
+	[ 56 ] = KEY_KP3,
+	[ 36 ] = KEY_KP4,
+	[ 20 ] = KEY_KP5,
+	[ 52 ] = KEY_KP6,
+	[ 44 ] = KEY_KP7,
+	[ 28 ] = KEY_KP8,
+	[ 60 ] = KEY_KP9,
+	[ 34 ] = KEY_KP0,
+
+	[ 32 ] = KEY_TV,		// TV/FM
+	[ 16 ] = KEY_CD,		// CD
+	[ 48 ] = KEY_TEXT,		// TELETEXT
+	[  0 ] = KEY_POWER,		// POWER
+
+	[  8 ] = KEY_VIDEO,		// VIDEO
+	[  4 ] = KEY_AUDIO,		// AUDIO
+	[ 12 ] = KEY_ZOOM,		// FULL SCREEN
+
+	[ 18 ] = KEY_SUBTITLE,		// DISPLAY	- ???
+	[ 50 ] = KEY_REWIND,		// LOOP		- ???
+	[  2 ] = KEY_PRINT,		// PREVIEW	- ???
+
+	[ 42 ] = KEY_SEARCH,		// AUTOSCAN
+	[ 26 ] = KEY_SLEEP,		// FREEZE	- ???
+	[ 58 ] = KEY_SHUFFLE,		// SNAPSHOT	- ???
+	[ 10 ] = KEY_MUTE,		// MUTE
+
+	[ 38 ] = KEY_RECORD,		// RECORD
+	[ 22 ] = KEY_PAUSE,		// PAUSE
+	[ 54 ] = KEY_STOP,		// STOP
+	[  6 ] = KEY_PLAY,		// PLAY
+
+	[ 46 ] = KEY_RED,		// <RED>
+	[ 33 ] = KEY_GREEN,		// <GREEN>
+	[ 14 ] = KEY_YELLOW,		// <YELLOW>
+	[  1 ] = KEY_BLUE,		// <BLUE>
+
+	[ 30 ] = KEY_VOLUMEDOWN,	// VOLUME-
+	[ 62 ] = KEY_VOLUMEUP,		// VOLUME+
+	[ 17 ] = KEY_CHANNELDOWN,	// CHANNEL/PAGE-
+	[ 49 ] = KEY_CHANNELUP		// CHANNEL/PAGE+
+};
 /* ---------------------------------------------------------------------- */
 
 static int build_key(struct saa7134_dev *dev)
@@ -303,6 +352,16 @@
 		mask_keyup   = 0x000020;
 		polling      = 50; // ms
 		break;
+	case SAA7134_BOARD_MD2819:
+	case SAA7134_BOARD_AVERMEDIA_307:
+		ir_codes     = md2819_codes;
+		mask_keycode = 0x0007C8;
+		mask_keydown = 0x000010;
+		polling      = 50; // ms
+		/* Set GPIO pin2 to high to enable the IR controller */
+		saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
+		saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
+		break;
 	}
 	if (NULL == ir_codes) {
 		printk("%s: Oops: IR config error [card=%d]\n",
@@ -320,7 +379,7 @@
 	ir->mask_keydown = mask_keydown;
 	ir->mask_keyup   = mask_keyup;
         ir->polling      = polling;
-	
+
 	/* init input device */
 	snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
 		 saa7134_boards[dev->board].name);
@@ -359,7 +418,7 @@
 {
 	if (NULL == dev->remote)
 		return;
-	
+
 	input_unregister_device(&dev->remote->dev);
 	if (dev->remote->polling)
 		del_timer_sync(&dev->remote->timer);
diff -Nru a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
--- a/drivers/media/video/saa7134/saa7134-oss.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/media/video/saa7134/saa7134-oss.c	2004-12-24 13:36:49 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-oss.c,v 1.11 2004/11/07 13:17:15 kraxel Exp $
+ *
  * device driver for philips saa7134 based TV cards
  * oss dsp interface
  *
@@ -32,11 +34,11 @@
 /* ------------------------------------------------------------------ */
 
 static unsigned int oss_debug  = 0;
-MODULE_PARM(oss_debug,"i");
+module_param(oss_debug, int, 0644);
 MODULE_PARM_DESC(oss_debug,"enable debug messages [oss]");
 
 static unsigned int oss_rate  = 0;
-MODULE_PARM(oss_rate,"i");
+module_param(oss_rate, int, 0444);
 MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)");
 
 #define dprintk(fmt, arg...)	if (oss_debug) \
@@ -138,7 +140,7 @@
 	}
 
 	switch (dev->oss.afmt) {
-	case AFMT_S8:     
+	case AFMT_S8:
 	case AFMT_S16_LE:
 	case AFMT_S16_BE: sign = 1; break;
 	default:          sign = 0; break;
@@ -159,7 +161,7 @@
 		if (sign)
 			fmt |= 0x04;
 		fmt |= (TV == dev->oss.input) ? 0xc0 : 0x80;
-		
+
 		saa_writeb(SAA7134_NUM_SAMPLES0, (dev->oss.blksize & 0x0000ff));
 		saa_writeb(SAA7134_NUM_SAMPLES1, (dev->oss.blksize & 0x00ff00) >>  8);
 		saa_writeb(SAA7134_NUM_SAMPLES2, (dev->oss.blksize & 0xff0000) >> 16);
@@ -191,7 +193,7 @@
 	saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize);
 	saa_writel(SAA7134_RS_PITCH(6),0);
 	saa_writel(SAA7134_RS_CONTROL(6),control);
-	
+
 	/* start dma */
 	dev->oss.recording_on = 1;
 	spin_lock_irqsave(&dev->slock,flags);
@@ -367,7 +369,7 @@
 	void __user *argp = (void __user *) arg;
 	int __user *p = argp;
 	int val = 0;
-	
+
 	if (oss_debug > 1)
 		saa7134_print_ioctl(dev->name,cmd);
         switch (cmd) {
@@ -410,7 +412,7 @@
 		/* fall through */
         case SOUND_PCM_READ_CHANNELS:
 		return put_user(dev->oss.channels, p);
-		
+
         case SNDCTL_DSP_GETFMTS: /* Returns a mask */
 		return put_user(AFMT_U8     | AFMT_S8     |
 				AFMT_U16_LE | AFMT_U16_BE |
@@ -533,7 +535,7 @@
 mixer_recsrc_7134(struct saa7134_dev *dev)
 {
 	int analog_io,rate;
-	
+
 	switch (dev->oss.input) {
 	case TV:
 		saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0);
@@ -555,7 +557,7 @@
 mixer_recsrc_7133(struct saa7134_dev *dev)
 {
 	u32 value = 0xbbbbbb;
-	
+
 	switch (dev->oss.input) {
 	case TV:
 		value = 0xbbbb10;  /* MAIN */
@@ -653,7 +655,7 @@
 	int val,ret;
 	void __user *argp = (void __user *) arg;
 	int __user *p = argp;
-	
+
 	if (oss_debug > 1)
 		saa7134_print_ioctl(dev->name,cmd);
         switch (cmd) {
@@ -784,7 +786,7 @@
 	mixer_level(dev,LINE1,dev->oss.line1);
 	mixer_level(dev,LINE2,dev->oss.line2);
 	mixer_recsrc(dev, (dev->oss.rate == 32000) ? TV : LINE2);
-	
+
 	return 0;
 }
 
@@ -838,7 +840,7 @@
 	dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks;
 	dev->oss.read_count += dev->oss.blksize;
 	wake_up(&dev->oss.wq);
-	
+
  done:
 	spin_unlock(&dev->slock);
 }
diff -Nru a/drivers/media/video/saa7134/saa7134-reg.h b/drivers/media/video/saa7134/saa7134-reg.h
--- a/drivers/media/video/saa7134/saa7134-reg.h	2004-12-24 13:37:03 -08:00
+++ b/drivers/media/video/saa7134/saa7134-reg.h	2004-12-24 13:37:03 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-reg.h,v 1.2 2004/09/15 16:15:24 kraxel Exp $
+ *
  * philips saa7134 registers
  */
 
diff -Nru a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
--- a/drivers/media/video/saa7134/saa7134-ts.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/media/video/saa7134/saa7134-ts.c	2004-12-24 13:36:17 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-ts.c,v 1.12 2004/11/07 13:17:15 kraxel Exp $
+ *
  * device driver for philips saa7134 based TV cards
  * video4linux video interface
  *
@@ -29,24 +31,12 @@
 #include "saa7134-reg.h"
 #include "saa7134.h"
 
-#include <media/saa6752hs.h>
-
 /* ------------------------------------------------------------------ */
 
-#define TS_PACKET_SIZE 188 /* TS packets 188 bytes */
-
 static unsigned int ts_debug  = 0;
-MODULE_PARM(ts_debug,"i");
+module_param(ts_debug, int, 0644);
 MODULE_PARM_DESC(ts_debug,"enable debug messages [ts]");
 
-static unsigned int tsbufs = 4;
-MODULE_PARM(tsbufs,"i");
-MODULE_PARM_DESC(tsbufs,"number of ts buffers, range 2-32");
-
-static unsigned int ts_nr_packets = 30;
-MODULE_PARM(ts_nr_packets,"i");
-MODULE_PARM_DESC(ts_nr_packets,"size of a ts buffers (in ts packets)");
-
 #define dprintk(fmt, arg...)	if (ts_debug) \
 	printk(KERN_DEBUG "%s/ts: " fmt, dev->name , ## arg)
 
@@ -57,11 +47,11 @@
 			   struct saa7134_buf *next)
 {
 	u32 control;
-	
+
 	dprintk("buffer_activate [%p]",buf);
 	buf->vb.state = STATE_ACTIVE;
 	buf->top_seen = 0;
-	
+
         /* dma: setup channel 5 (= TS) */
         control = SAA7134_RS_CONTROL_BURST_16 |
                 SAA7134_RS_CONTROL_ME |
@@ -83,24 +73,24 @@
 
 	/* start DMA */
 	saa7134_set_dmabits(dev);
-	
+
 	mod_timer(&dev->ts_q.timeout, jiffies+BUFFER_TIMEOUT);
 	return 0;
 }
 
-static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,
+static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
 			  enum v4l2_field field)
 {
-	struct saa7134_dev *dev = file->private_data;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
+	struct saa7134_dev *dev = q->priv_data;
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
 	unsigned int lines, llength, size;
 	int err;
-	
+
 	dprintk("buffer_prepare [%p,%s]\n",buf,v4l2_field_names[field]);
 
 	llength = TS_PACKET_SIZE;
-	lines = ts_nr_packets;
-	
+	lines = dev->ts.nr_packets;
+
 	size = lines * llength;
 	if (0 != buf->vb.baddr  &&  buf->vb.bsize < size)
 		return -EINVAL;
@@ -136,320 +126,51 @@
 }
 
 static int
-buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
+buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
 {
-	*size = TS_PACKET_SIZE * ts_nr_packets;
+	struct saa7134_dev *dev = q->priv_data;
+
+	*size = TS_PACKET_SIZE * dev->ts.nr_packets;
 	if (0 == *count)
-		*count = tsbufs;
+		*count = dev->ts.nr_bufs;
 	*count = saa7134_buffer_count(*size,*count);
 	return 0;
 }
 
-static void buffer_queue(struct file *file, struct videobuf_buffer *vb)
+static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct saa7134_dev *dev = file->private_data;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
-	
+	struct saa7134_dev *dev = q->priv_data;
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
+
 	saa7134_buffer_queue(dev,&dev->ts_q,buf);
 }
 
-static void buffer_release(struct file *file, struct videobuf_buffer *vb)
+static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct saa7134_dev *dev = file->private_data;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
-	
+	struct saa7134_dev *dev = q->priv_data;
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
+
 	saa7134_dma_free(dev,buf);
 }
 
-static struct videobuf_queue_ops ts_qops = {
+struct videobuf_queue_ops saa7134_ts_qops = {
 	.buf_setup    = buffer_setup,
 	.buf_prepare  = buffer_prepare,
 	.buf_queue    = buffer_queue,
 	.buf_release  = buffer_release,
 };
-
-
-/* ------------------------------------------------------------------ */
-
-static void ts_reset_encoder(struct saa7134_dev* dev) 
-{
-	saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
-	mdelay(10);
-   	saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
-   	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ/10);
-}
-
-static int ts_init_encoder(struct saa7134_dev* dev, void* arg) 
-{
-	ts_reset_encoder(dev);
-	saa7134_i2c_call_clients(dev, MPEG_SETPARAMS, arg);
- 	return 0;
-}
-
-
-/* ------------------------------------------------------------------ */
-
-static int ts_open(struct inode *inode, struct file *file)
-{
-	int minor = iminor(inode);
-	struct saa7134_dev *h,*dev = NULL;
-	struct list_head *list;
-	int err;
-	
-	list_for_each(list,&saa7134_devlist) {
-		h = list_entry(list, struct saa7134_dev, devlist);
-		if (h->ts_dev && h->ts_dev->minor == minor)
-			dev = h;
-	}
-	if (NULL == dev)
-		return -ENODEV;
-
-	dprintk("open minor=%d\n",minor);
-	down(&dev->ts.ts.lock);
-	err = -EBUSY;
-	if (dev->ts.users)
-		goto done;
-
-	dev->ts.started = 0;
-	dev->ts.users++;
-	file->private_data = dev;
-	err = 0;
-
- done:
-	up(&dev->ts.ts.lock);
-	return err;
-}
-
-static int ts_release(struct inode *inode, struct file *file)
-{
-	struct saa7134_dev *dev = file->private_data;
-
-	if (dev->ts.ts.streaming)
-		videobuf_streamoff(file,&dev->ts.ts);
-	down(&dev->ts.ts.lock);
-	if (dev->ts.ts.reading)
-		videobuf_read_stop(file,&dev->ts.ts);
-	dev->ts.users--;
-
-	/* stop the encoder */
-	if (dev->ts.started)
-	      	ts_reset_encoder(dev);
-  
-	up(&dev->ts.ts.lock);
-	return 0;
-}
-
-static ssize_t
-ts_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
-{
-	struct saa7134_dev *dev = file->private_data;
-
-	if (!dev->ts.started) {
-		ts_init_encoder(dev, NULL);
-		dev->ts.started = 1;
-	}
-  
-	return videobuf_read_stream(file, &dev->ts.ts, data, count, ppos, 0);
-}
-
-static unsigned int
-ts_poll(struct file *file, struct poll_table_struct *wait)
-{
-	struct saa7134_dev *dev = file->private_data;
-
-	return videobuf_poll_stream(file, &dev->ts.ts, wait);
-}
-
-
-static int
-ts_mmap(struct file *file, struct vm_area_struct * vma)
-{
-	struct saa7134_dev *dev = file->private_data;
-
-	return videobuf_mmap_mapper(vma, &dev->ts.ts);
-}
-
-/*
- * This function is _not_ called directly, but from
- * video_generic_ioctl (and maybe others).  userspace
- * copying is done already, arg is a kernel pointer.
- */
-static int ts_do_ioctl(struct inode *inode, struct file *file,
-		       unsigned int cmd, void *arg)
-{
-	struct saa7134_dev *dev = file->private_data;
-
-	if (ts_debug > 1)
-		saa7134_print_ioctl(dev->name,cmd);
-	switch (cmd) {
-	case VIDIOC_QUERYCAP:
-	{
-		struct v4l2_capability *cap = arg;
-
-		memset(cap,0,sizeof(*cap));
-                strcpy(cap->driver, "saa7134");
-		strlcpy(cap->card, saa7134_boards[dev->board].name,
-			sizeof(cap->card));
-		sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
-		cap->version = SAA7134_VERSION_CODE;
-		cap->capabilities =
-			V4L2_CAP_VIDEO_CAPTURE |
-			V4L2_CAP_READWRITE |
-			V4L2_CAP_STREAMING;
-		return 0;
-	}
-
-	/* --- input switching --------------------------------------- */
-	case VIDIOC_ENUMINPUT:
-	{
-		struct v4l2_input *i = arg;
-		
-		if (i->index != 0)
-			return -EINVAL;
-		i->type = V4L2_INPUT_TYPE_CAMERA;
-		strcpy(i->name,"CCIR656");
-		return 0;
-	}
-	case VIDIOC_G_INPUT:
-	{
-		int *i = arg;
-		*i = 0;
-		return 0;
-	}
-	case VIDIOC_S_INPUT:
-	{
-		int *i = arg;
-		
-		if (*i != 0)
-			return -EINVAL;
-		return 0;
-	}
-	/* --- capture ioctls ---------------------------------------- */
-	
-	case VIDIOC_ENUM_FMT:
-	{
-		struct v4l2_fmtdesc *f = arg;
-		int index;
-
-		index = f->index;
-		if (index != 0)
-			return -EINVAL;
-		
-		memset(f,0,sizeof(*f));
-		f->index = index;
-		strlcpy(f->description, "MPEG TS", sizeof(f->description));
-		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-		f->pixelformat = V4L2_PIX_FMT_MPEG;
-		return 0;
-	}
-
-	case VIDIOC_G_FMT:
-	{
-		struct v4l2_format *f = arg;
-
-		memset(f,0,sizeof(*f));
-		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-		
-		/* FIXME: translate subsampling type EMPRESS into
-		 *        width/height: */
-		f->fmt.pix.width        = 720; /* D1 */
-		f->fmt.pix.height       = 576;
-		f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
-		f->fmt.pix.sizeimage    = TS_PACKET_SIZE*ts_nr_packets;
-		return 0;
-	}
-	
-	case VIDIOC_S_FMT:
-	{
-		struct v4l2_format *f = arg;
-
-		if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		    return -EINVAL;
-
-		/* 
-		  FIXME: translate and round width/height into EMPRESS
-		  subsample type:
-		 
-		          type  |   PAL   |  NTSC 
-			---------------------------
-			  SIF   | 352x288 | 352x240
-			 1/2 D1 | 352x576 | 352x480
-			 2/3 D1 | 480x576 | 480x480
-			  D1    | 720x576 | 720x480
-		*/
-
-		f->fmt.pix.width        = 720; /* D1 */
-		f->fmt.pix.height       = 576;
-		f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
-		f->fmt.pix.sizeimage    = TS_PACKET_SIZE*ts_nr_packets;
-		return 0;
-	}
-
-	case VIDIOC_REQBUFS:
-		return videobuf_reqbufs(file,&dev->ts.ts,arg);
-
-	case VIDIOC_QUERYBUF:
-		return videobuf_querybuf(&dev->ts.ts,arg);
-
-	case VIDIOC_QBUF:
-		return videobuf_qbuf(file,&dev->ts.ts,arg);
-
-	case VIDIOC_DQBUF:
-		return videobuf_dqbuf(file,&dev->ts.ts,arg);
-
-	case VIDIOC_STREAMON:
-		return videobuf_streamon(file,&dev->ts.ts);
-
-	case VIDIOC_STREAMOFF:
-		return videobuf_streamoff(file,&dev->ts.ts);
-
-	case VIDIOC_QUERYCTRL:
-	case VIDIOC_G_CTRL:
-	case VIDIOC_S_CTRL:
-		return saa7134_common_ioctl(dev, cmd, arg);
-
-	case MPEG_SETPARAMS:
-		return ts_init_encoder(dev, arg);
-
-	default:
-		return -ENOIOCTLCMD;
-	}
-	return 0;
-}
-
-static int ts_ioctl(struct inode *inode, struct file *file,
-		     unsigned int cmd, unsigned long arg)
-{
-	return video_usercopy(inode, file, cmd, arg, ts_do_ioctl);
-}
-
-
-static struct file_operations ts_fops =
-{
-	.owner	  = THIS_MODULE,
-	.open	  = ts_open,
-	.release  = ts_release,
-	.read	  = ts_read,
-	.poll	  = ts_poll,
-	.mmap	  = ts_mmap,
-	.ioctl	  = ts_ioctl,
-	.llseek   = no_llseek,
-};
-
+EXPORT_SYMBOL_GPL(saa7134_ts_qops);
 
 /* ----------------------------------------------------------- */
 /* exported stuff                                              */
 
-struct video_device saa7134_ts_template =
-{
-	.name          = "saa7134-ts",
-	.type          = 0 /* FIXME */,
-	.type2         = 0 /* FIXME */,
-	.hardware      = 0,
-	.fops          = &ts_fops,
-	.minor	       = -1,
-};
+static unsigned int tsbufs = 4;
+module_param(tsbufs, int, 0444);
+MODULE_PARM_DESC(tsbufs,"number of ts buffers, range 2-32");
+
+static unsigned int ts_nr_packets = 30;
+module_param(ts_nr_packets, int, 0444);
+MODULE_PARM_DESC(ts_nr_packets,"size of a ts buffers (in ts packets)");
 
 int saa7134_ts_init1(struct saa7134_dev *dev)
 {
@@ -462,6 +183,8 @@
 		ts_nr_packets = 4;
 	if (ts_nr_packets > 312)
 		ts_nr_packets = 312;
+	dev->ts.nr_bufs    = tsbufs;
+	dev->ts.nr_packets = ts_nr_packets;
 
 	INIT_LIST_HEAD(&dev->ts_q.queue);
 	init_timer(&dev->ts_q.timeout);
@@ -469,26 +192,21 @@
 	dev->ts_q.timeout.data     = (unsigned long)(&dev->ts_q);
 	dev->ts_q.dev              = dev;
 	dev->ts_q.need_two         = 1;
-	videobuf_queue_init(&dev->ts.ts, &ts_qops, dev->pci, &dev->slock,
-			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
-			    V4L2_FIELD_ALTERNATE,
-			    sizeof(struct saa7134_buf));
 	saa7134_pgtable_alloc(dev->pci,&dev->ts.pt_ts);
 
 	/* init TS hw */
 	saa_writeb(SAA7134_TS_SERIAL1, 0x00);  /* deactivate TS softreset */
 	saa_writeb(SAA7134_TS_PARALLEL, 0xec); /* TSSOP high active, TSVAL high active, TSLOCK ignored */
 	saa_writeb(SAA7134_TS_PARALLEL_SERIAL, (TS_PACKET_SIZE-1));
-	saa_writeb(SAA7134_TS_DMA0, ((ts_nr_packets-1)&0xff));
-	saa_writeb(SAA7134_TS_DMA1, (((ts_nr_packets-1)>>8)&0xff));
-	saa_writeb(SAA7134_TS_DMA2, ((((ts_nr_packets-1)>>16)&0x3f) | 0x00)); /* TSNOPIT=0, TSCOLAP=0 */
- 
+	saa_writeb(SAA7134_TS_DMA0, ((dev->ts.nr_packets-1)&0xff));
+	saa_writeb(SAA7134_TS_DMA1, (((dev->ts.nr_packets-1)>>8)&0xff));
+	saa_writeb(SAA7134_TS_DMA2, ((((dev->ts.nr_packets-1)>>16)&0x3f) | 0x00)); /* TSNOPIT=0, TSCOLAP=0 */
+
 	return 0;
 }
 
 int saa7134_ts_fini(struct saa7134_dev *dev)
 {
-	/* nothing */
 	saa7134_pgtable_free(dev->pci,&dev->ts.pt_ts);
 	return 0;
 }
diff -Nru a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c	2004-12-24 13:36:16 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-tvaudio.c,v 1.17 2004/11/07 13:17:15 kraxel Exp $
+ *
  * device driver for philips saa7134 based TV cards
  * tv audio decoder (fm stereo, nicam, ...)
  *
@@ -34,18 +36,18 @@
 /* ------------------------------------------------------------------ */
 
 static unsigned int audio_debug = 0;
-MODULE_PARM(audio_debug,"i");
+module_param(audio_debug, int, 0644);
 MODULE_PARM_DESC(audio_debug,"enable debug messages [tv audio]");
 
 static unsigned int audio_ddep = 0;
-MODULE_PARM(audio_ddep,"i");
+module_param(audio_ddep, int, 0644);
 MODULE_PARM_DESC(audio_ddep,"audio ddep overwrite");
 
 static int audio_clock_override = UNSET;
-MODULE_PARM(audio_clock_override, "i");
+module_param(audio_clock_override, int, 0644);
 
 static int audio_clock_tweak = 0;
-MODULE_PARM(audio_clock_tweak, "i");
+module_param(audio_clock_tweak, int, 0644);
 MODULE_PARM_DESC(audio_clock_tweak, "Audio clock tick fine tuning for cards with audio crystal that's slightly off (range [-1024 .. 1024])");
 
 #define dprintk(fmt, arg...)	if (audio_debug) \
@@ -56,9 +58,10 @@
 #define print_regb(reg) printk("%s:   reg 0x%03x [%-16s]: 0x%02x\n", \
 		dev->name,(SAA7134_##reg),(#reg),saa_readb((SAA7134_##reg)))
 
-#define SCAN_INITIAL_DELAY     (HZ)
-#define SCAN_SAMPLE_DELAY      (HZ/5)
-#define SCAN_SUBCARRIER_DELAY  (HZ*2)
+/* msecs */
+#define SCAN_INITIAL_DELAY     1000
+#define SCAN_SAMPLE_DELAY       200
+#define SCAN_SUBCARRIER_DELAY  2000
 
 /* ------------------------------------------------------------------ */
 /* saa7134 code                                                       */
@@ -281,7 +284,7 @@
 	saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD1, (acpf & 0x00ff00) >> 8);
 	saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD2, (acpf & 0x030000) >> 16);
 	tvaudio_setcarrier(dev,audio->carr1,audio->carr2);
-	
+
 	switch (audio->mode) {
 	case TVAUDIO_FM_MONO:
 	case TVAUDIO_FM_BG_STEREO:
@@ -321,14 +324,21 @@
 static int tvaudio_sleep(struct saa7134_dev *dev, int timeout)
 {
 	DECLARE_WAITQUEUE(wait, current);
-	
+
 	add_wait_queue(&dev->thread.wq, &wait);
 	if (dev->thread.scan1 == dev->thread.scan2 && !dev->thread.shutdown) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (timeout < 0)
+		if (timeout < 0) {
+			set_current_state(TASK_INTERRUPTIBLE);
 			schedule();
-		else
-			schedule_timeout(timeout);
+		} else {
+#if 0
+			/* hmm, that one doesn't return on wakeup ... */
+			msleep_interruptible(timeout);
+#else
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(msecs_to_jiffies(timeout));
+#endif
+		}
 	}
 	remove_wait_queue(&dev->thread.wq, &wait);
 	return dev->thread.scan1 != dev->thread.scan2;
@@ -404,7 +414,7 @@
 {
 	__u32 idp,nicam;
 	int retval = -1;
-	
+
 	switch (audio->mode) {
 	case TVAUDIO_FM_MONO:
 		return V4L2_TUNER_SUB_MONO;
@@ -602,7 +612,7 @@
 
 		lastmode = 42;
 		for (;;) {
-			if (tvaudio_sleep(dev,5*HZ))
+			if (tvaudio_sleep(dev,5000))
 				goto restart;
 			if (dev->thread.shutdown || signal_pending(current))
 				break;
@@ -641,7 +651,7 @@
 	[0x09] = "D/K NICAM",
 	[0x0a] = "L NICAM",
 	[0x0b] = "I NICAM",
-	
+
 	[0x0c] = "M Korea",
 	[0x0d] = "M BTSC ",
 	[0x0e] = "M EIAJ",
@@ -735,7 +745,8 @@
 static int mute_input_7133(struct saa7134_dev *dev)
 {
 	u32 reg = 0;
-	
+	int mask;
+
 	switch (dev->input->amux) {
 	case TV:    reg = 0x02; break;
 	case LINE1: reg = 0x00; break;
@@ -744,6 +755,14 @@
 	if (dev->ctl_mute)
 		reg = 0x07;
 	saa_writel(0x594 >> 2, reg);
+
+	/* switch gpio-connected external audio mux */
+        if (0 != card(dev).gpiomask) {
+        	mask = card(dev).gpiomask;
+        	saa_andorl(SAA7134_GPIO_GPMODE0 >> 2,   mask, mask);
+        	saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, dev->input->gpio);
+        	saa7134_track_gpio(dev,dev->input->name);
+	}
 	return 0;
 }
 
@@ -777,7 +796,10 @@
 			/* insmod option override */
 			norms = (audio_ddep << 2) | 0x01;
 			dprintk("ddep override: %s\n",stdres[audio_ddep]);
-		} else{
+		} else if (&card(dev).radio == dev->input) {
+			dprintk("FM Radio\n");
+			norms = (0x0f << 2) | 0x01;
+		} else {
 			/* (let chip) scan for sound carrier */
 			norms = 0;
 			if (dev->tvnorm->id & V4L2_STD_PAL) {
@@ -810,7 +832,7 @@
 		saa_dsp_writel(dev, 0x464 >> 2, 0x000000);
 		saa_dsp_writel(dev, 0x470 >> 2, 0x101010);
 
-		if (tvaudio_sleep(dev,3*HZ))
+		if (tvaudio_sleep(dev,3000))
 			goto restart;
 		value = saa_readl(0x528 >> 2) & 0xffffff;
 
@@ -830,12 +852,12 @@
 			(value & 0x002000) ? " BTSC stereo noise mute " : "",
 			(value & 0x004000) ? " SAP noise mute "         : "",
 			(value & 0x008000) ? " VDSP "                   : "",
-			
+
 			(value & 0x010000) ? " NICST "                  : "",
 			(value & 0x020000) ? " NICDU "                  : "",
 			(value & 0x040000) ? " NICAM muted "            : "",
 			(value & 0x080000) ? " NICAM reserve sound "    : "",
-			
+
 			(value & 0x100000) ? " init done "              : "");
 	}
 
@@ -850,7 +872,7 @@
 int saa7134_tvaudio_rx2mode(u32 rx)
 {
 	u32 mode;
-	
+
 	mode = V4L2_TUNER_MODE_MONO;
 	if (rx & V4L2_TUNER_SUB_STEREO)
 		mode = V4L2_TUNER_MODE_STEREO;
@@ -860,7 +882,7 @@
 		mode = V4L2_TUNER_MODE_LANG2;
 	return mode;
 }
-	
+
 void saa7134_tvaudio_setmute(struct saa7134_dev *dev)
 {
 	switch (dev->pci->device) {
@@ -925,14 +947,14 @@
 	int (*my_thread)(void *data) = NULL;
 
 	/* enable I2S audio output */
-	if (saa7134_boards[dev->board].has_ts) {
+	if (card_is_empress(dev)) {
 		int i2sform = (48000 == dev->oss.rate)
 			? 0x01 : 0x00;
-		
+
 		/* enable I2S output */
-		saa_writeb(SAA7134_I2S_OUTPUT_SELECT,  0x80); 
-		saa_writeb(SAA7134_I2S_OUTPUT_FORMAT,  i2sform); 
-		saa_writeb(SAA7134_I2S_OUTPUT_LEVEL,   0x0F);	
+		saa_writeb(SAA7134_I2S_OUTPUT_SELECT,  0x80);
+		saa_writeb(SAA7134_I2S_OUTPUT_FORMAT,  i2sform);
+		saa_writeb(SAA7134_I2S_OUTPUT_LEVEL,   0x0F);
 		saa_writeb(SAA7134_I2S_AUDIO_OUTPUT,   0x01);
 	}
 
diff -Nru a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c
--- a/drivers/media/video/saa7134/saa7134-vbi.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/media/video/saa7134/saa7134-vbi.c	2004-12-24 13:37:29 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-vbi.c,v 1.5 2004/11/07 13:17:15 kraxel Exp $
+ *
  * device driver for philips saa7134 based TV cards
  * video4linux video interface
  *
@@ -31,11 +33,11 @@
 /* ------------------------------------------------------------------ */
 
 static unsigned int vbi_debug  = 0;
-MODULE_PARM(vbi_debug,"i");
+module_param(vbi_debug, int, 0644);
 MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]");
 
 static unsigned int vbibufs = 4;
-MODULE_PARM(vbibufs,"i");
+module_param(vbibufs, int, 0444);
 MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32");
 
 #define dprintk(fmt, arg...)	if (vbi_debug) \
@@ -51,7 +53,7 @@
 		      int task)
 {
 	struct saa7134_tvnorm *norm = dev->tvnorm;
-	
+
 	/* setup video scaler */
 	saa_writeb(SAA7134_VBI_H_START1(task), norm->h_start     &  0xff);
 	saa_writeb(SAA7134_VBI_H_START2(task), norm->h_start     >> 8);
@@ -113,12 +115,13 @@
 	return 0;
 }
 
-static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,
+static int buffer_prepare(struct videobuf_queue *q,
+			  struct videobuf_buffer *vb,
 			  enum v4l2_field field)
 {
-	struct saa7134_fh *fh   = file->private_data;
+	struct saa7134_fh *fh   = q->priv_data;
 	struct saa7134_dev *dev = fh->dev;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
 	struct saa7134_tvnorm *norm = dev->tvnorm;
 	unsigned int lines, llength, size;
 	int err;
@@ -167,12 +170,12 @@
 }
 
 static int
-buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
+buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
 {
-	struct saa7134_fh *fh   = file->private_data;
+	struct saa7134_fh *fh   = q->priv_data;
 	struct saa7134_dev *dev = fh->dev;
 	int llength,lines;
-	
+
 	lines   = dev->tvnorm->vbi_v_stop - dev->tvnorm->vbi_v_start +1;
 #if 1
 	llength = VBI_LINE_LENGTH;
@@ -188,21 +191,21 @@
 	return 0;
 }
 
-static void buffer_queue(struct file *file, struct videobuf_buffer *vb)
+static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct saa7134_fh *fh = file->private_data;
+	struct saa7134_fh *fh = q->priv_data;
 	struct saa7134_dev *dev = fh->dev;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
-	
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
+
 	saa7134_buffer_queue(dev,&dev->vbi_q,buf);
 }
 
-static void buffer_release(struct file *file, struct videobuf_buffer *vb)
+static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct saa7134_fh *fh   = file->private_data;
+	struct saa7134_fh *fh   = q->priv_data;
 	struct saa7134_dev *dev = fh->dev;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
-	
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
+
 	saa7134_dma_free(dev,buf);
 }
 
diff -Nru a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
--- a/drivers/media/video/saa7134/saa7134-video.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/media/video/saa7134/saa7134-video.c	2004-12-24 13:36:19 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134-video.c,v 1.19 2004/11/07 14:44:59 kraxel Exp $
+ *
  * device driver for philips saa7134 based TV cards
  * video4linux video interface
  *
@@ -37,11 +39,11 @@
 static unsigned int noninterlaced = 0;
 static unsigned int gbufsize      = 720*576*4;
 static unsigned int gbufsize_max  = 720*576*4;
-MODULE_PARM(video_debug,"i");
+module_param(video_debug, int, 0644);
 MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
-MODULE_PARM(gbuffers,"i");
+module_param(gbuffers, int, 0444);
 MODULE_PARM_DESC(gbuffers,"number of capture buffers, range 2-32");
-MODULE_PARM(noninterlaced,"i");
+module_param(noninterlaced, int, 0644);
 MODULE_PARM_DESC(noninterlaced,"video input is noninterlaced");
 
 #define dprintk(fmt, arg...)	if (video_debug) \
@@ -53,7 +55,7 @@
 static int video_out[][9] = {
 	[CCIR656] = { 0x00, 0xb1, 0x00, 0xa1, 0x00, 0x04, 0x06, 0x00, 0x00 },
 };
-		
+
 static struct saa7134_format formats[] = {
 	{
 		.name     = "8 bpp gray",
@@ -371,7 +373,7 @@
 static const struct v4l2_queryctrl* ctrl_by_id(unsigned int id)
 {
 	unsigned int i;
-	
+
 	for (i = 0; i < CTRLS; i++)
 		if (video_ctrls[i].id == id)
 			return video_ctrls+i;
@@ -480,12 +482,12 @@
 	saa_writeb(SAA7134_HSYNC_START,           0xeb);
 	saa_writeb(SAA7134_HSYNC_STOP,            0xe0);
 	saa_writeb(SAA7134_SOURCE_TIMING1,        norm->src_timing);
-	
+
 	saa_writeb(SAA7134_SYNC_CTRL,             sync_control);
 	saa_writeb(SAA7134_LUMA_CTRL,             luma_control);
 	saa_writeb(SAA7134_DEC_LUMA_BRIGHT,       dev->ctl_bright);
 	saa_writeb(SAA7134_DEC_LUMA_CONTRAST,     dev->ctl_contrast);
- 
+
 	saa_writeb(SAA7134_DEC_CHROMA_SATURATION, dev->ctl_saturation);
 	saa_writeb(SAA7134_DEC_CHROMA_HUE,        dev->ctl_hue);
 	saa_writeb(SAA7134_CHROMA_CTRL1,          norm->chroma_ctrl1);
@@ -568,7 +570,7 @@
 static void set_v_scale(struct saa7134_dev *dev, int task, int yscale)
 {
 	int val,mirror;
-	
+
 	saa_writeb(SAA7134_V_SCALE_RATIO1(task), yscale &  0xff);
 	saa_writeb(SAA7134_V_SCALE_RATIO2(task), yscale >> 8);
 
@@ -622,7 +624,7 @@
 	saa_writeb(SAA7134_H_SCALE_INC1(task),      xscale &  0xff);
 	saa_writeb(SAA7134_H_SCALE_INC2(task),      xscale >> 8);
 	set_v_scale(dev,task,yscale);
-	
+
 	saa_writeb(SAA7134_VIDEO_PIXELS1(task),     width  & 0xff);
 	saa_writeb(SAA7134_VIDEO_PIXELS2(task),     width  >> 8);
 	saa_writeb(SAA7134_VIDEO_LINES1(task),      height/div & 0xff);
@@ -649,7 +651,7 @@
 {
 	struct cliplist swap;
 	int i,j,n;
-	
+
 	for (i = entries-2; i >= 0; i--) {
 		for (n = 0, j = 0; j <= i; j++) {
 			if (cl[j].position > cl[j+1].position) {
@@ -844,7 +846,7 @@
 	dprintk("buffer_activate buf=%p\n",buf);
 	buf->vb.state = STATE_ACTIVE;
 	buf->top_seen = 0;
-	
+
 	set_size(dev,TASK_A,buf->vb.width,buf->vb.height,
 		 V4L2_FIELD_HAS_BOTH(buf->vb.field));
 	if (buf->fmt->yuv)
@@ -916,15 +918,16 @@
 	return 0;
 }
 
-static int buffer_prepare(struct file *file, struct videobuf_buffer *vb,
+static int buffer_prepare(struct videobuf_queue *q,
+			  struct videobuf_buffer *vb,
 			  enum v4l2_field field)
 {
-	struct saa7134_fh *fh = file->private_data;
+	struct saa7134_fh *fh = q->priv_data;
 	struct saa7134_dev *dev = fh->dev;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
 	unsigned int size;
 	int err;
-	
+
 	/* sanity checks */
 	if (NULL == fh->fmt)
 		return -EINVAL;
@@ -978,9 +981,9 @@
 }
 
 static int
-buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
+buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
 {
-	struct saa7134_fh *fh = file->private_data;
+	struct saa7134_fh *fh = q->priv_data;
 
 	*size = fh->fmt->depth * fh->width * fh->height >> 3;
 	if (0 == *count)
@@ -989,19 +992,19 @@
 	return 0;
 }
 
-static void buffer_queue(struct file *file, struct videobuf_buffer *vb)
+static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct saa7134_fh *fh = file->private_data;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
-	
+	struct saa7134_fh *fh = q->priv_data;
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
+
 	saa7134_buffer_queue(fh->dev,&fh->dev->video_q,buf);
 }
 
-static void buffer_release(struct file *file, struct videobuf_buffer *vb)
+static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct saa7134_fh *fh = file->private_data;
-	struct saa7134_buf *buf = (struct saa7134_buf *)vb;
-	
+	struct saa7134_fh *fh = q->priv_data;
+	struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
+
 	saa7134_dma_free(fh->dev,buf);
 }
 
@@ -1158,7 +1161,7 @@
 static struct videobuf_queue* saa7134_queue(struct saa7134_fh *fh)
 {
 	struct videobuf_queue* q = NULL;
-	
+
 	switch (fh->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		q = &fh->cap;
@@ -1175,7 +1178,7 @@
 static int saa7134_resource(struct saa7134_fh *fh)
 {
 	int res = 0;
-	
+
 	switch (fh->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		res = RESOURCE_VIDEO;
@@ -1197,7 +1200,7 @@
 	struct list_head *list;
 	enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 	int radio = 0;
-	
+
 	list_for_each(list,&saa7134_devlist) {
 		h = list_entry(list, struct saa7134_dev, devlist);
 		if (h->video_dev && (h->video_dev->minor == minor))
@@ -1229,24 +1232,21 @@
 	fh->fmt      = format_by_fourcc(V4L2_PIX_FMT_BGR24);
 	fh->width    = 720;
 	fh->height   = 576;
-#ifdef VIDIOC_G_PRIORITY
 	v4l2_prio_open(&dev->prio,&fh->prio);
-#endif
 
 	videobuf_queue_init(&fh->cap, &video_qops,
 			    dev->pci, &dev->slock,
 			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
 			    V4L2_FIELD_INTERLACED,
-			    sizeof(struct saa7134_buf));
-	init_MUTEX(&fh->cap.lock);
-	saa7134_pgtable_alloc(dev->pci,&fh->pt_cap);
-
+			    sizeof(struct saa7134_buf),
+			    fh);
 	videobuf_queue_init(&fh->vbi, &saa7134_vbi_qops,
 			    dev->pci, &dev->slock,
 			    V4L2_BUF_TYPE_VBI_CAPTURE,
 			    V4L2_FIELD_SEQ_TB,
-			    sizeof(struct saa7134_buf));
-        init_MUTEX(&fh->vbi.lock);
+			    sizeof(struct saa7134_buf),
+			    fh);
+	saa7134_pgtable_alloc(dev->pci,&fh->pt_cap);
 	saa7134_pgtable_alloc(dev->pci,&fh->pt_vbi);
 
 	if (fh->radio) {
@@ -1269,13 +1269,15 @@
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		if (res_locked(fh->dev,RESOURCE_VIDEO))
 			return -EBUSY;
-		return videobuf_read_one(file, saa7134_queue(fh),
-					 data, count, ppos);
+		return videobuf_read_one(saa7134_queue(fh),
+					 data, count, ppos,
+					 file->f_flags & O_NONBLOCK);
 	case V4L2_BUF_TYPE_VBI_CAPTURE:
 		if (!res_get(fh->dev,fh,RESOURCE_VBI))
 			return -EBUSY;
-		return videobuf_read_stream(file, saa7134_queue(fh),
-					    data, count, ppos, 1);
+		return videobuf_read_stream(saa7134_queue(fh),
+					    data, count, ppos, 1,
+					    file->f_flags & O_NONBLOCK);
 		break;
 	default:
 		BUG();
@@ -1303,11 +1305,11 @@
                                 up(&fh->cap.lock);
                                 return POLLERR;
                         }
-                        if (0 != fh->cap.ops->buf_prepare(file,fh->cap.read_buf,fh->cap.field)) {
+                        if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) {
                                 up(&fh->cap.lock);
                                 return POLLERR;
                         }
-                        fh->cap.ops->buf_queue(file,fh->cap.read_buf);
+                        fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
                         fh->cap.read_off = 0;
 		}
 		up(&fh->cap.lock);
@@ -1340,29 +1342,27 @@
 
 	/* stop video capture */
 	if (res_check(fh, RESOURCE_VIDEO)) {
-		videobuf_streamoff(file,&fh->cap);
+		videobuf_streamoff(&fh->cap);
 		res_free(dev,fh,RESOURCE_VIDEO);
 	}
 	if (fh->cap.read_buf) {
-		buffer_release(file,fh->cap.read_buf);
+		buffer_release(&fh->cap,fh->cap.read_buf);
 		kfree(fh->cap.read_buf);
 	}
 
 	/* stop vbi capture */
 	if (res_check(fh, RESOURCE_VBI)) {
 		if (fh->vbi.streaming)
-			videobuf_streamoff(file,&fh->vbi);
+			videobuf_streamoff(&fh->vbi);
 		if (fh->vbi.reading)
-			videobuf_read_stop(file,&fh->vbi);
+			videobuf_read_stop(&fh->vbi);
 		res_free(dev,fh,RESOURCE_VBI);
 	}
 
 	saa7134_pgtable_free(dev->pci,&fh->pt_cap);
 	saa7134_pgtable_free(dev->pci,&fh->pt_vbi);
 
-#ifdef VIDIOC_G_PRIORITY
 	v4l2_prio_close(&dev->prio,&fh->prio);
-#endif
 	file->private_data = NULL;
 	kfree(fh);
 	return 0;
@@ -1372,8 +1372,8 @@
 video_mmap(struct file *file, struct vm_area_struct * vma)
 {
 	struct saa7134_fh *fh = file->private_data;
-	
-	return videobuf_mmap_mapper(vma,saa7134_queue(fh));
+
+	return videobuf_mmap_mapper(saa7134_queue(fh), vma);
 }
 
 /* ------------------------------------------------------------------ */
@@ -1431,7 +1431,7 @@
 		    struct v4l2_format *f)
 {
 	int err;
-	
+
 	switch (f->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 	{
@@ -1446,7 +1446,7 @@
 		field = f->fmt.pix.field;
 		maxw  = min(dev->crop_current.width*4,  dev->crop_bounds.width);
 		maxh  = min(dev->crop_current.height*4, dev->crop_bounds.height);
-		
+
 		if (V4L2_FIELD_ANY == field) {
 			field = (f->fmt.pix.height > maxh/2)
 				? V4L2_FIELD_INTERLACED
@@ -1476,7 +1476,7 @@
 			(f->fmt.pix.width * fmt->depth) >> 3;
 		f->fmt.pix.sizeimage =
 			f->fmt.pix.height * f->fmt.pix.bytesperline;
-		
+
 		return 0;
 	}
 	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
@@ -1497,13 +1497,13 @@
 {
 	unsigned long flags;
 	int err;
-	
+
 	switch (f->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
 		err = saa7134_try_fmt(dev,fh,f);
 		if (0 != err)
 			return err;
-			
+
 		fh->fmt       = format_by_fourcc(f->fmt.pix.pixelformat);
 		fh->width     = f->fmt.pix.width;
 		fh->height    = f->fmt.pix.height;
@@ -1545,7 +1545,7 @@
 			 unsigned int cmd, void *arg)
 {
 	int err;
-	
+
 	switch (cmd) {
 	case VIDIOC_QUERYCTRL:
 	{
@@ -1612,7 +1612,7 @@
 	case VIDIOC_S_INPUT:
 	{
 		int *i = arg;
-		
+
 		if (*i < 0  ||  *i >= SAA7134_INPUT_MAX)
 			return -EINVAL;
 		if (NULL == card_in(dev,*i).name)
@@ -1626,6 +1626,7 @@
 	}
 	return 0;
 }
+EXPORT_SYMBOL(saa7134_common_ioctl);
 
 /*
  * This function is _not_ called directly, but from
@@ -1643,7 +1644,6 @@
 	if (video_debug > 1)
 		saa7134_print_ioctl(dev->name,cmd);
 
-#ifdef VIDIOC_G_PRIORITY
 	switch (cmd) {
 	case VIDIOC_S_CTRL:
 	case VIDIOC_S_STD:
@@ -1654,13 +1654,12 @@
 		if (0 != err)
 			return err;
 	}
-#endif
 
 	switch (cmd) {
 	case VIDIOC_QUERYCAP:
 	{
 		struct v4l2_capability *cap = arg;
-		
+
 		memset(cap,0,sizeof(*cap));
                 strcpy(cap->driver, "saa7134");
 		strlcpy(cap->card, saa7134_boards[dev->board].name,
@@ -1672,7 +1671,7 @@
 			V4L2_CAP_VIDEO_OVERLAY |
 			V4L2_CAP_VBI_CAPTURE |
 			V4L2_CAP_TUNER |
-			V4L2_CAP_READWRITE | 
+			V4L2_CAP_READWRITE |
 			V4L2_CAP_STREAMING;
 		return 0;
 	}
@@ -1722,7 +1721,7 @@
 			set_tvnorm(dev,&tvnorms[i]);
 			start_preview(dev,fh);
 			spin_unlock_irqrestore(&dev->slock,flags);
-		} else 
+		} else
 			set_tvnorm(dev,&tvnorms[i]);
 		saa7134_tvaudio_do_scan(dev);
 		up(&dev->lock);
@@ -1868,7 +1867,7 @@
 		up(&dev->lock);
 		return 0;
 	}
-		
+
 	/* --- control ioctls ---------------------------------------- */
 	case VIDIOC_ENUMINPUT:
 	case VIDIOC_G_INPUT:
@@ -1895,7 +1894,6 @@
                 return 0;
         }
 
-#ifdef VIDIOC_G_PRIORITY
         case VIDIOC_G_PRIORITY:
         {
                 enum v4l2_priority *p = arg;
@@ -1909,7 +1907,6 @@
 
                 return v4l2_prio_change(&dev->prio, &fh->prio, *prio);
         }
-#endif
 
 	/* --- preview ioctls ---------------------------------------- */
 	case VIDIOC_ENUM_FMT:
@@ -1944,7 +1941,7 @@
 			strcpy(f->description,"vbi data");
 			break;
 		default:
-			return -EINVAL;	
+			return -EINVAL;
 		}
 		return 0;
 	}
@@ -1960,7 +1957,7 @@
 	{
 		struct v4l2_framebuffer *fb = arg;
 		struct saa7134_format *fmt;
-		
+
 		if(!capable(CAP_SYS_ADMIN) &&
 		   !capable(CAP_SYS_RAWIO))
 			return -EPERM;
@@ -2016,7 +2013,7 @@
 		struct v4l2_format *f = arg;
 		return saa7134_try_fmt(dev,fh,f);
 	}
-	
+
 	case VIDIOCGMBUF:
 	{
 		struct video_mbuf *mbuf = arg;
@@ -2029,7 +2026,7 @@
 		req.type   = q->type;
 		req.count  = gbuffers;
 		req.memory = V4L2_MEMORY_MMAP;
-		err = videobuf_reqbufs(file,q,&req);
+		err = videobuf_reqbufs(q,&req);
 		if (err < 0)
 			return err;
 		memset(mbuf,0,sizeof(*mbuf));
@@ -2042,16 +2039,17 @@
 		return 0;
 	}
 	case VIDIOC_REQBUFS:
-		return videobuf_reqbufs(file,saa7134_queue(fh),arg);
+		return videobuf_reqbufs(saa7134_queue(fh),arg);
 
 	case VIDIOC_QUERYBUF:
 		return videobuf_querybuf(saa7134_queue(fh),arg);
 
 	case VIDIOC_QBUF:
-		return videobuf_qbuf(file,saa7134_queue(fh),arg);
+		return videobuf_qbuf(saa7134_queue(fh),arg);
 
 	case VIDIOC_DQBUF:
-		return videobuf_dqbuf(file,saa7134_queue(fh),arg);
+		return videobuf_dqbuf(saa7134_queue(fh),arg,
+				      file->f_flags & O_NONBLOCK);
 
 	case VIDIOC_STREAMON:
 	{
@@ -2059,13 +2057,13 @@
 
                 if (!res_get(dev,fh,res))
 			return -EBUSY;
-		return videobuf_streamon(file,saa7134_queue(fh));
+		return videobuf_streamon(saa7134_queue(fh));
 	}
 	case VIDIOC_STREAMOFF:
 	{
 		int res = saa7134_resource(fh);
 
-		err = videobuf_streamoff(file,saa7134_queue(fh));
+		err = videobuf_streamoff(saa7134_queue(fh));
 		if (err < 0)
 			return err;
 		res_free(dev,fh,res);
@@ -2090,7 +2088,7 @@
 {
 	struct saa7134_fh *fh = file->private_data;
 	struct saa7134_dev *dev = fh->dev;
-	
+
 	if (video_debug > 1)
 		saa7134_print_ioctl(dev->name,cmd);
 	switch (cmd) {
@@ -2134,7 +2132,7 @@
 	case VIDIOC_ENUMINPUT:
 	{
 		struct v4l2_input *i = arg;
-		
+
 		if (i->index != 0)
 			return -EINVAL;
 		strcpy(i->name,"Radio");
@@ -2188,7 +2186,7 @@
 	case VIDIOC_G_FREQUENCY:
 	case VIDIOC_S_FREQUENCY:
 		return video_do_ioctl(inode,file,cmd,arg);
-		
+
 	default:
 		return v4l_compat_translate_ioctl(inode,file,cmd,arg,
 						  radio_do_ioctl);
@@ -2296,7 +2294,7 @@
 		saa_writeb(SAA7134_VIDEO_PORT_CTRL7, video_out[vo][7]);
 		saa_writeb(SAA7134_VIDEO_PORT_CTRL8, video_out[vo][8]);
 	}
- 
+
 	return 0;
 }
 
@@ -2324,7 +2322,7 @@
 
 	norm = saa_readb(SAA7134_STATUS_VIDEO1) & 0x03;
 	dprintk("DCSDT: %s\n",st[norm]);
-	
+
 	if (0 != norm) {
 		/* wake up tvaudio audio carrier scan thread */
 		saa7134_tvaudio_do_scan(dev);
@@ -2342,7 +2340,7 @@
 void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status)
 {
 	enum v4l2_field field;
-	
+
 	spin_lock(&dev->slock);
 	if (dev->video_q.curr) {
 		dev->video_fieldcount++;
diff -Nru a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
--- a/drivers/media/video/saa7134/saa7134.h	2004-12-24 13:37:03 -08:00
+++ b/drivers/media/video/saa7134/saa7134.h	2004-12-24 13:37:03 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: saa7134.h,v 1.27 2004/11/04 11:03:52 kraxel Exp $
+ *
  * v4l2 device driver for philips saa7134 based TV cards
  *
  * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
@@ -29,11 +31,12 @@
 
 #include <asm/io.h>
 
-#include <media/video-buf.h>
 #include <media/tuner.h>
 #include <media/audiochip.h>
 #include <media/id.h>
 #include <media/ir-common.h>
+#include <media/video-buf.h>
+#include <media/video-buf-dvb.h>
 
 #ifndef TRUE
 # define TRUE (1==1)
@@ -159,7 +162,15 @@
 #define SAA7134_BOARD_CINERGY200       38
 #define SAA7134_BOARD_FLYTVPLATINUM    39
 #define SAA7134_BOARD_VIDEOMATE_TV_PVR 40
+#define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS 41
+#define SAA7134_BOARD_SABRENT_SBTTVFM  42
+#define SAA7134_BOARD_ZOLID_XPERT_TV7134 43
+#define SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE 44
+#define SAA7134_BOARD_AVERMEDIA_307    45
+#define SAA7134_BOARD_AVERMEDIA_CARDBUS 46
+#define SAA7134_BOARD_CINERGY400_CARDBUS 47
 
+#define SAA7134_MAXBOARDS 8
 #define SAA7134_INPUT_MAX 8
 
 struct saa7134_input {
@@ -170,6 +181,12 @@
 	unsigned int            tv:1;
 };
 
+enum saa7134_mpeg_type {
+	SAA7134_MPEG_UNUSED,
+	SAA7134_MPEG_EMPRESS,
+	SAA7134_MPEG_DVB,
+};
+
 struct saa7134_board {
 	char                    *name;
 	unsigned int            audio_clock;
@@ -179,18 +196,20 @@
 	struct saa7134_input    inputs[SAA7134_INPUT_MAX];
 	struct saa7134_input    radio;
 	struct saa7134_input    mute;
-	
-	/* peripheral I/O */
-	unsigned int            has_ts;
-	enum saa7134_video_out  video_out;
 
 	/* i2c chip info */
 	unsigned int            tuner_type;
 	unsigned int            tda9887_conf;
+
+	/* peripheral I/O */
+	enum saa7134_video_out  video_out;
+	enum saa7134_mpeg_type  mpeg;
 };
 
 #define card_has_radio(dev)   (NULL != saa7134_boards[dev->board].radio.name)
-#define card_has_ts(dev)      (saa7134_boards[dev->board].has_ts)
+#define card_is_empress(dev)  (SAA7134_MPEG_EMPRESS == saa7134_boards[dev->board].mpeg)
+#define card_is_dvb(dev)      (SAA7134_MPEG_DVB     == saa7134_boards[dev->board].mpeg)
+#define card_has_mpeg(dev)    (SAA7134_MPEG_UNUSED  != saa7134_boards[dev->board].mpeg)
 #define card(dev)             (saa7134_boards[dev->board])
 #define card_in(dev,n)        (saa7134_boards[dev->board].inputs[n])
 
@@ -258,7 +277,7 @@
 	unsigned int               radio;
 	enum v4l2_buf_type         type;
 	unsigned int               resources;
-#ifdef VIDIOC_G_PRIORITY 
+#ifdef VIDIOC_G_PRIORITY
 	enum v4l2_priority	   prio;
 #endif
 
@@ -278,16 +297,6 @@
 	struct saa7134_pgtable     pt_vbi;
 };
 
-/* TS status */
-struct saa7134_ts {
-	unsigned int               users;
-
-	/* TS capture */
-	struct videobuf_queue      ts;
-	struct saa7134_pgtable     pt_ts;
-	int			   started;
-};
-
 /* oss dsp status */
 struct saa7134_oss {
         struct semaphore           lock;
@@ -332,23 +341,37 @@
         struct timer_list          timer;
 };
 
+/* ts/mpeg status */
+struct saa7134_ts {
+	/* TS capture */
+	struct saa7134_pgtable     pt_ts;
+	int                        nr_packets;
+	int                        nr_bufs;
+};
+
+/* ts/mpeg ops */
+struct saa7134_mpeg_ops {
+	enum saa7134_mpeg_type     type;
+	struct list_head           next;
+	int                        (*init)(struct saa7134_dev *dev);
+	int                        (*fini)(struct saa7134_dev *dev);
+};
+
 /* global device status */
 struct saa7134_dev {
 	struct list_head           devlist;
         struct semaphore           lock;
        	spinlock_t                 slock;
-#ifdef VIDIOC_G_PRIORITY 
+#ifdef VIDIOC_G_PRIORITY
 	struct v4l2_prio_state     prio;
 #endif
 
 	/* various device info */
 	unsigned int               resources;
 	struct video_device        *video_dev;
-	struct video_device        *ts_dev;
 	struct video_device        *radio_dev;
 	struct video_device        *vbi_dev;
 	struct saa7134_oss         oss;
-	struct saa7134_ts          ts;
 
 	/* infrared remote */
 	int                        has_remote;
@@ -356,10 +379,11 @@
 
 	/* pci i/o */
 	char                       name[32];
+	int                        nr;
 	struct pci_dev             *pci;
 	unsigned char              pci_rev,pci_lat;
-	__u32                      *lmmio;
-	__u8                       *bmmio;
+	__u32                      __iomem *lmmio;
+	__u8                       __iomem *bmmio;
 
 	/* config info */
 	unsigned int               board;
@@ -380,7 +404,6 @@
 
 	/* video+ts+vbi capture */
 	struct saa7134_dmaqueue    video_q;
-	struct saa7134_dmaqueue    ts_q;
 	struct saa7134_dmaqueue    vbi_q;
 	unsigned int               video_fieldcount;
 	unsigned int               vbi_fieldcount;
@@ -414,6 +437,19 @@
 	struct saa7134_input       *hw_input;
 	unsigned int               hw_mute;
 	int                        last_carrier;
+
+	/* SAA7134_MPEG_* */
+	struct saa7134_ts          ts;
+	struct saa7134_dmaqueue    ts_q;
+	struct saa7134_mpeg_ops    *mops;
+
+	/* SAA7134_MPEG_EMPRESS only */
+	struct video_device        *empress_dev;
+	struct videobuf_queue      empress_tsq;
+	unsigned int               empress_users;
+
+	/* SAA7134_MPEG_DVB only */
+	struct videobuf_dvb        dvb;
 };
 
 /* ----------------------------------------------------------- */
@@ -434,7 +470,7 @@
 #define saa_setb(reg,bit)          saa_andorb((reg),(bit),(bit))
 #define saa_clearb(reg,bit)        saa_andorb((reg),(bit),0)
 
-#define saa_wait(d) { udelay(d); }
+#define saa_wait(us) { udelay(us); }
 
 /* ----------------------------------------------------------- */
 /* saa7134-core.c                                              */
@@ -474,7 +510,8 @@
 extern const unsigned int saa7134_bcount;
 extern struct pci_device_id __devinitdata saa7134_pci_tbl[];
 
-extern int saa7134_board_init(struct saa7134_dev *dev);
+extern int saa7134_board_init1(struct saa7134_dev *dev);
+extern int saa7134_board_init2(struct saa7134_dev *dev);
 
 
 /* ----------------------------------------------------------- */
@@ -505,11 +542,16 @@
 /* ----------------------------------------------------------- */
 /* saa7134-ts.c                                                */
 
-extern struct video_device saa7134_ts_template;
+#define TS_PACKET_SIZE 188 /* TS packets 188 bytes */
+
+extern struct videobuf_queue_ops saa7134_ts_qops;
+
 int saa7134_ts_init1(struct saa7134_dev *dev);
 int saa7134_ts_fini(struct saa7134_dev *dev);
 void saa7134_irq_ts_done(struct saa7134_dev *dev, unsigned long status);
 
+int saa7134_ts_register(struct saa7134_mpeg_ops *ops);
+void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops);
 
 /* ----------------------------------------------------------- */
 /* saa7134-vbi.c                                               */
diff -Nru a/drivers/media/video/saa7146.h b/drivers/media/video/saa7146.h
--- a/drivers/media/video/saa7146.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/media/video/saa7146.h	2004-12-24 13:36:18 -08:00
@@ -78,7 +78,7 @@
 	unsigned char boardcfg[64];	/* 64 bytes of config from eeprom */
 	unsigned long saa7146_adr;   /* bus address of IO mem from PCI BIOS */
 	struct saa7146_window win;
-	unsigned char *saa7146_mem; /* pointer to mapped IO memory */
+	unsigned char __iomem *saa7146_mem; /* pointer to mapped IO memory */
 	struct device_open open_data[MAX_OPENS];
 #define MAX_MARKS 16
 	/* for a/v sync */
@@ -95,10 +95,10 @@
 #endif
 
 #ifdef _ALPHA_SAA7146
-#define saawrite(dat,adr)    writel((dat),(char *) (saa->saa7146_adr+(adr)))
+#define saawrite(dat,adr)    writel((dat), saa->saa7146_adr+(adr))
 #define saaread(adr)         readl(saa->saa7146_adr+(adr))
 #else
-#define saawrite(dat,adr)    writel((dat), (char *) (saa->saa7146_mem+(adr)))
+#define saawrite(dat,adr)    writel((dat), saa->saa7146_mem+(adr))
 #define saaread(adr)         readl(saa->saa7146_mem+(adr))
 #endif
 
diff -Nru a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
--- a/drivers/media/video/tda7432.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/media/video/tda7432.c	2004-12-24 13:37:02 -08:00
@@ -1,8 +1,8 @@
 /*
  * For the STS-Thompson TDA7432 audio processor chip
- * 
+ *
  * Handles audio functions: volume, balance, tone, loudness
- * This driver will not complain if used with any 
+ * This driver will not complain if used with any
  * other i2c device with the same address.
  *
  * Muting and tone control by Jonathan Isom <jisom@ematic.com>
@@ -106,7 +106,7 @@
  * output (for front and rear).  Since most vidcap cards probably
  * don't have 4 channel output, this driver will set front & rear
  * together (no independent control).
- */ 
+ */
 
 		/* Subaddresses for TDA7432 */
 
@@ -132,13 +132,13 @@
  * 0x03 - Mute  (Using Attenuators Plays better with modules)
  * Mono probably isn't used - I'm guessing only the stereo
  * input is connected on most cards, so we'll set it to stereo.
- * 
+ *
  * Bit 3 controls bass cut: 0/1 is non-symmetric/symmetric bass cut
  * Bit 4 controls bass range: 0/1 is extended/standard bass range
- * 
+ *
  * Highest 3 bits not used
  */
- 
+
 #define TDA7432_STEREO_IN	0
 #define TDA7432_MONO_IN		2	/* Probably won't be used */
 #define TDA7432_BASS_SYM	1 << 3
@@ -161,7 +161,7 @@
 #define TDA7432_LD_ON		1 << 7
 
 
-/* Subaddress 0x02 - Tone control */ 
+/* Subaddress 0x02 - Tone control */
 
 /* Bits 0,1,2 control absolute treble gain from 0dB to 14dB
  * 0x0 is 14dB, 0x7 is 0dB
@@ -173,23 +173,23 @@
  * Bits 4,5,6 control absolute bass gain from 0dB to 14dB
  * (This is only true for normal base range, set in 0x00)
  * 0x0 << 4 is 14dB, 0x7 is 0dB
- * 
+ *
  * Bit 7 controls bass attenuation/gain (sign)
  * 1 << 7 = gain (+)
- * 0 << 7 = attenuation (-) 
+ * 0 << 7 = attenuation (-)
  *
  * Example:
  * 1 1 0 1 0 1 0 1 is +4dB bass, -4dB treble
  */
 
-#define TDA7432_TREBLE_0DB		0xf 
+#define TDA7432_TREBLE_0DB		0xf
 #define TDA7432_TREBLE			7
 #define TDA7432_TREBLE_GAIN		1 << 3
 #define TDA7432_BASS_0DB		0xf
 #define TDA7432_BASS			7 << 4
 #define TDA7432_BASS_GAIN		1 << 7
 
- 
+
 /* Subaddress 0x03 - Left  Front attenuation */
 /* Subaddress 0x04 - Left  Rear  attenuation */
 /* Subaddress 0x05 - Right Front attenuation */
@@ -202,7 +202,7 @@
  * 0x1f is -37.5dB
  *
  * Bit 5 mutes that channel when set (1 = mute, 0 = unmute)
- * We'll use the mute on the input, though (above) 
+ * We'll use the mute on the input, though (above)
  * Bits 6,7 unused
  */
 
@@ -223,8 +223,8 @@
  *
  * Bits 5,6,7 unused
  */
- 
- 
+
+
 
 /* Begin code */
 
@@ -253,7 +253,7 @@
 		printk(KERN_WARNING "tda7432: I/O error, trying (read)\n");
 		return -1;
 	}
-	dprintk("tda7432: Read 0x%02x\n", buffer); 
+	dprintk("tda7432: Read 0x%02x\n", buffer);
 	return buffer;
 }
 #endif
@@ -263,8 +263,8 @@
 	struct tda7432 *t = i2c_get_clientdata(client);
 	unsigned char buf[16];
 	d2printk("tda7432: In tda7432_set\n");
-	
-	dprintk(KERN_INFO 
+
+	dprintk(KERN_INFO
 		"tda7432: 7432_set(0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n",
 		t->input,t->volume,t->bass,t->treble,t->lf,t->lr,t->rf,t->rr,t->loud);
 	buf[0]  = TDA7432_IN;
@@ -292,10 +292,10 @@
 
 	t->input  = TDA7432_STEREO_IN |  /* Main (stereo) input   */
 		    TDA7432_BASS_SYM  |  /* Symmetric bass cut    */
-		    TDA7432_BASS_NORM;   /* Normal bass range     */ 
+		    TDA7432_BASS_NORM;   /* Normal bass range     */
 	t->volume =  0x3b ;				 /* -27dB Volume            */
 	if (loudness)			 /* Turn loudness on?     */
-		t->volume |= TDA7432_LD_ON;	
+		t->volume |= TDA7432_LD_ON;
 	t->muted    = VIDEO_AUDIO_MUTE;
 	t->treble   = TDA7432_TREBLE_0DB; /* 0dB Treble            */
 	t->bass		= TDA7432_BASS_0DB; 	 /* 0dB Bass              */
@@ -328,7 +328,7 @@
         client->adapter = adap;
         client->addr = addr;
 	i2c_set_clientdata(client, t);
-	
+
 	do_tda7432_init(client);
 	printk(KERN_INFO "tda7432: init\n");
 
@@ -354,7 +354,7 @@
 
 	do_tda7432_init(client);
 	i2c_detach_client(client);
-	
+
 	kfree(t);
 	return 0;
 }
@@ -369,7 +369,7 @@
 	/* --- v4l ioctls --- */
 	/* take care: bttv does userspace copying, we'll get a
 	   kernel pointer here... */
-	
+
 	/* Query card - scale from TDA7432 settings to V4L settings */
 	case VIDIOCGAUDIO:
 	{
@@ -385,7 +385,7 @@
 		va->mode |= VIDEO_SOUND_STEREO;
 		/* Master volume control
 		 * V4L volume is min 0, max 65535
-		 * TDA7432 Volume: 
+		 * TDA7432 Volume:
 		 * Min (-79dB) is 0x6f
 		 * Max (+20dB) is 0x07 (630)
 		 * Max (0dB) is 0x20 (829)
@@ -396,7 +396,7 @@
 		} else {       /* max 0db   */
 			va->volume = ( 0x6f - (t->volume & 0x7F) ) * 829;
 		}
-		
+
 		/* Balance depends on L,R attenuation
 		 * V4L balance is 0 to 65535, middle is 32768
 		 * TDA7432 attenuation: min (0dB) is 0, max (-37.5dB) is 0x1f
@@ -404,15 +404,15 @@
 		 * attenuation exists for lf, lr, rf, rr
 		 * we use only lf and rf (front channels)
 		 */
-		
+
 		if ( (t->lf) < (t->rf) )
 			/* right is attenuated, balance shifted left */
 			va->balance = (32768 - 1057*(t->rf));
 		else
 			/* left is attenuated, balance shifted right */
 			va->balance = (32768 + 1057*(t->lf));
-		
-		/* Bass/treble 4 bits each */	
+
+		/* Bass/treble 4 bits each */
 		va->bass=t->bass;
 		if(va->bass >= 0x8)
 			va->bass = ~(va->bass - 0x8) & 0xf;
@@ -421,7 +421,7 @@
 		if(va->treble >= 0x8)
 			va->treble = ~(va->treble - 0x8) & 0xf;
 		va->treble = (va->treble << 12)+(va->treble << 8)+(va->treble << 4)+(va->treble);
-								
+
 		break; /* VIDIOCGAUDIO case */
 	}
 
@@ -437,13 +437,13 @@
 			} else {    /* max 0db   */
 				t->volume = 0x6f - ((va->volume)/829);
 			}
-		
+
 		if (loudness)		/* Turn on the loudness bit */
 			t->volume |= TDA7432_LD_ON;
-		
+
 			tda7432_write(client,TDA7432_VL, t->volume);
 		}
-		
+
 		if(va->flags & VIDEO_AUDIO_BASS)
 		{
 			t->bass = va->bass >> 12;
@@ -458,15 +458,15 @@
 		}
 		if(va->flags & (VIDEO_AUDIO_TREBLE| VIDEO_AUDIO_BASS))
 			tda7432_write(client,TDA7432_TN, 0x10 | (t->bass << 4) | t->treble );
-		
+
 		if(va->flags & VIDEO_AUDIO_BALANCE)	{
-		if (va->balance < 32768) 
+		if (va->balance < 32768)
 		{
 			/* shifted to left, attenuate right */
 			t->rr = (32768 - va->balance)/1057;
 			t->rf = t->rr;
 			t->lr = TDA7432_ATTEN_0DB;
-			t->lf = TDA7432_ATTEN_0DB;	
+			t->lf = TDA7432_ATTEN_0DB;
 		}
 		else if(va->balance > 32769)
 		{
@@ -474,22 +474,22 @@
 			t->lf = (va->balance - 32768)/1057;
 			t->lr = t->lf;
 			t->rr = TDA7432_ATTEN_0DB;
-			t->rf = TDA7432_ATTEN_0DB;		
+			t->rf = TDA7432_ATTEN_0DB;
 		}
-		else 
+		else
 		{
-			/* centered */		
+			/* centered */
 			t->rr = TDA7432_ATTEN_0DB;
 			t->rf = TDA7432_ATTEN_0DB;
 			t->lf = TDA7432_ATTEN_0DB;
 			t->lr = TDA7432_ATTEN_0DB;
 		}
 		}
-					
-	 	t->muted=(va->flags & VIDEO_AUDIO_MUTE);	
+
+	 	t->muted=(va->flags & VIDEO_AUDIO_MUTE);
 		if (t->muted)
 		{
-			/* Mute & update balance*/	
+			/* Mute & update balance*/
 			tda7432_write(client,TDA7432_LF, t->lf | TDA7432_MUTE);
 			tda7432_write(client,TDA7432_LR, t->lr | TDA7432_MUTE);
 			tda7432_write(client,TDA7432_RF, t->rf | TDA7432_MUTE);
@@ -500,7 +500,7 @@
 			tda7432_write(client,TDA7432_RF, t->rf);
 			tda7432_write(client,TDA7432_RR, t->rr);
 		}
-							
+
 		break;
 
 	} /* end of VIDEOCSAUDIO case */
@@ -529,7 +529,7 @@
 {
 	I2C_DEVNAME("tda7432"),
         .id         = -1,
-	.driver     = &driver, 
+	.driver     = &driver,
 };
 
 static int __init tda7432_init(void)
diff -Nru a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
--- a/drivers/media/video/tda9840.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/media/video/tda9840.c	2004-12-24 13:37:02 -08:00
@@ -1,5 +1,5 @@
  /*
-    tda9840.h - i2c-driver for the tda9840 by SGS Thomson   
+    tda9840 - i2c-driver for the tda9840 by SGS Thomson
 
     Copyright (C) 1998-2003 Michael Hunold <michael@mihu.de>
 
@@ -8,7 +8,7 @@
 
     For detailed informations download the specifications directly
     from SGS Thomson at http://www.st.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
@@ -22,21 +22,19 @@
     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/version.h>
 #include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/poll.h>
-#include <linux/slab.h>
+#include <linux/ioctl.h>
 #include <linux/i2c.h>
-#include <linux/init.h>
 
 #include "tda9840.h"
 
-static int debug = 0;	/* insmod parameter */
-MODULE_PARM(debug,"i");
-#define dprintk	if (debug) printk
+static int debug = 0;		/* insmod parameter */
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
+#define dprintk(args...) \
+            do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0)
 
 #define	SWITCH		0x00
 #define	LEVEL_ADJUST	0x02
@@ -44,168 +42,146 @@
 #define	TEST		0x04
 
 /* addresses to scan, found only at 0x42 (7-Bit) */
-static unsigned short normal_i2c[] = {I2C_TDA9840, I2C_CLIENT_END};
-static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
+static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 
 /* magic definition of all other variables and things */
 I2C_CLIENT_INSMOD;
 
+static struct i2c_driver driver;
+static struct i2c_client client_template;
+
 /* unique ID allocation */
 static int tda9840_id = 0;
 
-static struct i2c_driver driver;
-
-static int tda9840_command(struct i2c_client *client, unsigned int cmd, void* arg)
+static int command(struct i2c_client *client, unsigned int cmd, void *arg)
 {
-	int result = 0;
+	int result;
+	int byte = *(int *)arg;
 
 	switch (cmd) {
-		case TDA9840_SWITCH:
-		{
-			int byte = *(int*)arg;
-
-			dprintk("tda9840.o: TDA9840_SWITCH: 0x%02x\n",byte);
-
-			if (    byte != TDA9840_SET_MONO
-			     && byte != TDA9840_SET_MUTE
-			     && byte != TDA9840_SET_STEREO
-			     && byte != TDA9840_SET_LANG1
-			     && byte != TDA9840_SET_LANG2
-			     && byte != TDA9840_SET_BOTH
-			     && byte != TDA9840_SET_BOTH_R
-			     && byte != TDA9840_SET_EXTERNAL ) {
-				return -EINVAL;
-			}
-			
-			if ( 0 != (result = i2c_smbus_write_byte_data(client, SWITCH, byte))) {
-		 		printk("tda9840.o: TDA9840_SWITCH error.\n");
- 				return -EFAULT;
-			}
-			
-			return 0;
-		}
+	case TDA9840_SWITCH:
 
-		case TDA9840_LEVEL_ADJUST:
-		{
-			int  byte = *(int*)arg;
-
-			dprintk("tda9840.o: TDA9840_LEVEL_ADJUST: %d\n",byte);
-
-			/* check for correct range */
-			if ( byte > 25 || byte < -20 )
-				return -EINVAL;
-			
-			/* calculate actual value to set, see specs, page 18 */
-			byte /= 5;
-			if ( 0 < byte )
-				byte += 0x8;
-			else
-				byte = -byte;
-
-			if ( 0 != (result = i2c_smbus_write_byte_data(client, LEVEL_ADJUST, byte))) {
-		 		printk("tda9840.o: TDA9840_LEVEL_ADJUST error.\n");
- 				return -EFAULT;
-			}
-			
-			return 0;
+		dprintk("TDA9840_SWITCH: 0x%02x\n", byte);
+
+		if (byte != TDA9840_SET_MONO
+		    && byte != TDA9840_SET_MUTE
+		    && byte != TDA9840_SET_STEREO
+		    && byte != TDA9840_SET_LANG1
+		    && byte != TDA9840_SET_LANG2
+		    && byte != TDA9840_SET_BOTH
+		    && byte != TDA9840_SET_BOTH_R
+		    && byte != TDA9840_SET_EXTERNAL) {
+			return -EINVAL;
 		}
 
-		case TDA9840_STEREO_ADJUST:
-		{
-			int  byte = *(int*)arg;
-
-			dprintk("tda9840.o: TDA9840_STEREO_ADJUST: %d\n",byte);
-
-			/* check for correct range */
-			if ( byte > 25 || byte < -24 )
-				return -EINVAL;
-			
-			/* calculate actual value to set */
-			byte /= 5;
-			if ( 0 < byte )
-				byte += 0x20;
-			else
-				byte = -byte;
-
-			if ( 0 != (result = i2c_smbus_write_byte_data(client, STEREO_ADJUST, byte))) {
-		 		printk("tda9840.o: TDA9840_STEREO_ADJUST error.\n");
- 				return -EFAULT;
-			}
-			
-			return 0;
+		result = i2c_smbus_write_byte_data(client, SWITCH, byte);
+		if (result)
+			dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+		break;
+
+	case TDA9840_LEVEL_ADJUST:
+
+		dprintk("TDA9840_LEVEL_ADJUST: %d\n", byte);
+
+		/* check for correct range */
+		if (byte > 25 || byte < -20)
+			return -EINVAL;
+
+		/* calculate actual value to set, see specs, page 18 */
+		byte /= 5;
+		if (0 < byte)
+			byte += 0x8;
+		else
+			byte = -byte;
+
+		result = i2c_smbus_write_byte_data(client, LEVEL_ADJUST, byte);
+		if (result)
+			dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+		break;
+
+	case TDA9840_STEREO_ADJUST:
+
+		dprintk("TDA9840_STEREO_ADJUST: %d\n", byte);
+
+		/* check for correct range */
+		if (byte > 25 || byte < -24)
+			return -EINVAL;
+
+		/* calculate actual value to set */
+		byte /= 5;
+		if (0 < byte)
+			byte += 0x20;
+		else
+			byte = -byte;
+
+		result = i2c_smbus_write_byte_data(client, STEREO_ADJUST, byte);
+		if (result)
+			dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+		break;
+
+	case TDA9840_DETECT:
+
+		byte = i2c_smbus_read_byte_data(client, STEREO_ADJUST);
+		if (byte == -1) {
+			dprintk("i2c_smbus_read_byte_data() failed\n");
+			return -EIO;
 		}
 
-		case TDA9840_DETECT:
-		{
-			int byte = 0x0;
-
-			if ( -1 == (byte = i2c_smbus_read_byte_data(client, STEREO_ADJUST))) {
-		 		printk("tda9840.o: TDA9840_DETECT error while reading.\n");
-				return -EFAULT;
-			}			
-
-			if( 0 != (byte & 0x80)) {
-		 		dprintk("tda9840.o: TDA9840_DETECT, register contents invalid.\n");
-				return -EFAULT;
-			}
+		if (0 != (byte & 0x80)) {
+			dprintk("TDA9840_DETECT: register contents invalid\n");
+			return -EINVAL;
+		}
 
-			dprintk("tda9840.o: TDA9840_DETECT, result: 0x%02x (original byte)\n",byte);
+		dprintk("TDA9840_DETECT: byte: 0x%02x\n", byte);
+		return ((byte & 0x60) >> 5);
 
-			return ((byte & 0x60) >> 5);				
-		}
+	case TDA9840_TEST:
+		dprintk("TDA9840_TEST: 0x%02x\n", byte);
 
-		case TDA9840_TEST:
-		{
-			int  byte = *(int*)arg;
-
-			dprintk("tda9840.o: TDA9840_TEST: 0x%02x\n",byte);
-
-			/* mask out irrelevant bits */
-			byte &= 0x3;
-
-			if ( 0 != (result = i2c_smbus_write_byte_data(client, TEST, byte))) {
-		 		printk("tda9840.o: TDA9840_TEST error.\n");
- 				return -EFAULT;
-			}
-		
-			return 0;
-		}
+		/* mask out irrelevant bits */
+		byte &= 0x3;
 
-		default:
-			return -ENOIOCTLCMD;
+		result = i2c_smbus_write_byte_data(client, TEST, byte);
+		if (result)
+			dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+		break;
+	default:
+		return -ENOIOCTLCMD;
 	}
 
+	if (result)
+		return -EIO;
+
 	return 0;
 }
 
-static int tda9840_detect(struct i2c_adapter *adapter, int address, int kind)
+static int detect(struct i2c_adapter *adapter, int address, int kind)
 {
-	struct	i2c_client *client;
+	struct i2c_client *client;
 	int result = 0;
 
 	int byte = 0x0;
-			
+
 	/* let's see whether this adapter can support what we need */
-	if ( 0 == i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA|I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
+	if (0 == i2c_check_functionality(adapter,
+				    I2C_FUNC_SMBUS_READ_BYTE_DATA |
+				    I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
 		return 0;
 	}
 
 	/* allocate memory for client structure */
 	client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
-        if (0 == client) {
-		printk("tda9840.o: not enough kernel memory.\n");
+	if (0 == client) {
+		printk("not enough kernel memory\n");
 		return -ENOMEM;
 	}
-	memset(client, 0, sizeof(struct i2c_client));
-	
+
 	/* fill client structure */
-	sprintf(client->name,"tda9840 (0x%02x)", address);
+	memcpy(client, &client_template, sizeof(struct i2c_client));
 	client->id = tda9840_id++;
-	client->flags = 0;
 	client->addr = address;
 	client->adapter = adapter;
-	client->driver = &driver;
-	i2c_set_clientdata(client, NULL);
 
 	/* tell the i2c layer a new client has arrived */
 	if (0 != (result = i2c_attach_client(client))) {
@@ -215,71 +191,64 @@
 
 	/* set initial values for level & stereo - adjustment, mode */
 	byte = 0;
-	if ( 0 != (result = tda9840_command(client, TDA9840_LEVEL_ADJUST, &byte))) {
- 		printk("tda9840.o: could not initialize ic #1. continuing anyway. (result:%d)\n",result);
-	}
-	
-	if ( 0 != (result = tda9840_command(client, TDA9840_STEREO_ADJUST, &byte))) {
- 		printk("tda9840.o: could not initialize ic #2. continuing anyway. (result:%d)\n",result);
-	}
-
+	result  = command(client, TDA9840_LEVEL_ADJUST, &byte);
+	result += command(client, TDA9840_STEREO_ADJUST, &byte);
 	byte = TDA9840_SET_MONO;
-	if ( 0 != (result = tda9840_command(client, TDA9840_SWITCH, &byte))) {
- 		printk("tda9840.o: could not initialize ic #3. continuing anyway. (result:%d)\n",result);
-	} 
-	
-	printk("tda9840.o: detected @ 0x%02x on adapter %s\n",2*address,&client->adapter->name[0]);
+	result = command(client, TDA9840_SWITCH, &byte);
+	if (result) {
+		dprintk("could not initialize tda9840\n");
+		return -ENODEV;
+	}
 
+	printk("tda9840: detected @ 0x%02x on adapter %s\n", address, &client->adapter->name[0]);
 	return 0;
 }
 
-static int tda9840_attach(struct i2c_adapter *adapter)
+static int attach(struct i2c_adapter *adapter)
 {
 	/* let's see whether this is a know adapter we can attach to */
-	if( adapter->id != I2C_ALGO_SAA7146 ) {
-		dprintk("tda9840.o: refusing to probe on unknown adapter [name='%s',id=0x%x]\n",adapter->name,adapter->id);
+	if (adapter->id != I2C_ALGO_SAA7146) {
+		dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
 		return -ENODEV;
 	}
 
-	return i2c_probe(adapter,&addr_data,&tda9840_detect);
+	return i2c_probe(adapter, &addr_data, &detect);
 }
 
-static int tda9840_detach(struct i2c_client *client)
+static int detach(struct i2c_client *client)
 {
-	int err = 0;
-
-	if ( 0 != (err = i2c_detach_client(client))) {
-		printk("tda9840.o: Client deregistration failed, client not detached.\n");
-		return err;
-	}
-	
+	int ret = i2c_detach_client(client);
 	kfree(client);
-
-	return 0;
+	return ret;
 }
 
 static struct i2c_driver driver = {
-	.owner		= THIS_MODULE,
-	.name		= "tda9840 driver",
-	.id		= I2C_DRIVERID_TDA9840,
-	.flags		= I2C_DF_NOTIFY,
-        .attach_adapter = tda9840_attach,
-        .detach_client	= tda9840_detach,
-        .command	= tda9840_command,
+	.owner	= THIS_MODULE,
+	.name	= "tda9840",
+	.id	= I2C_DRIVERID_TDA9840,
+	.flags	= I2C_DF_NOTIFY,
+	.attach_adapter	= attach,
+	.detach_client	= detach,
+	.command	= command,
+};
+
+static struct i2c_client client_template = {
+	I2C_DEVNAME("tda9840"),
+	.driver = &driver,
 };
 
-static int __init tda9840_init_module(void)
+static int __init this_module_init(void)
 {
-        return i2c_add_driver(&driver);
+	return i2c_add_driver(&driver);
 }
 
-static void __exit tda9840_cleanup_module(void)
+static void __exit this_module_exit(void)
 {
-        i2c_del_driver(&driver);
+	i2c_del_driver(&driver);
 }
 
-module_init(tda9840_init_module);
-module_exit(tda9840_cleanup_module);
+module_init(this_module_init);
+module_exit(this_module_exit);
 
 MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
 MODULE_DESCRIPTION("tda9840 driver");
diff -Nru a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
--- a/drivers/media/video/tda9875.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/media/video/tda9875.c	2004-12-24 13:36:48 -08:00
@@ -1,19 +1,19 @@
 /*
  * For the TDA9875 chip
- * (The TDA9875 is used on the Diamond DTV2000 french version 
+ * (The TDA9875 is used on the Diamond DTV2000 french version
  * Other cards probably use these chips as well.)
- * This driver will not complain if used with any 
+ * This driver will not complain if used with any
  * other i2c device with the same address.
  *
  * Copyright (c) 2000 Guillaume Delvit based on Gerd Knorr source and
- * Eric Sandeen 
+ * Eric Sandeen
  * This code is placed under the terms of the GNU General Public License
  * Based on tda9855.c by Steve VanDeBogart (vandebo@uclink.berkeley.edu)
  * Which was based on tda8425.c by Greg Alexander (c) 1998
  *
  * OPTIONS:
  * debug   - set to 1 if you'd like to see debug messages
- * 
+ *
  *  Revision: 0.1 - original version
  */
 
@@ -64,7 +64,7 @@
  * http://www.semiconductors.philips.com
  * TDA9875: I2C-bus controlled DSP audio processor, FM demodulator
  *
- */ 
+ */
 
 		/* subaddresses for TDA9875 */
 #define TDA9875_MUT         0x12  /*General mute  (value --> 0b11001100*/
@@ -133,7 +133,7 @@
 		printk(KERN_WARNING "tda9875: I/O error, trying (read)\n");
 		return -1;
 	}
-	dprintk("Read 0x%02x\n", buffer); 
+	dprintk("Read 0x%02x\n", buffer);
 	return buffer;
 }
 #endif
@@ -178,7 +178,7 @@
 static void do_tda9875_init(struct i2c_client *client)
 {
 	struct tda9875 *t = i2c_get_clientdata(client);
-	dprintk("In tda9875_init\n"); 
+	dprintk("In tda9875_init\n");
 	tda9875_write(client, TDA9875_CFG, 0xd0 ); /*reg de config 0 (reset)*/
     	tda9875_write(client, TDA9875_MSR, 0x03 );    /* Monitor 0b00000XXX*/
 	tda9875_write(client, TDA9875_C1MSB, 0x00 );  /*Car1(FM) MSB XMHz*/
@@ -192,7 +192,7 @@
 	tda9875_write(client, TDA9875_FMAT, 0x00 );   /*FM Matrix reg 0x00*/
 	tda9875_write(client, TDA9875_SC1, 0x00 );    /* SCART 1 (SC1)*/
 	tda9875_write(client, TDA9875_SC2, 0x01 );    /* SCART 2 (sc2)*/
-        
+
 	tda9875_write(client, TDA9875_CH1V, 0x10 );  /* Channel volume 1 mute*/
 	tda9875_write(client, TDA9875_CH2V, 0x10 );  /* Channel volume 2 mute */
 	tda9875_write(client, TDA9875_DACOS, 0x02 ); /* sig DAC i/o(in:nicam)*/
@@ -204,14 +204,14 @@
 	tda9875_write(client, TDA9875_MVR, 0x03 );   /* Vol Main right 10dB*/
 	tda9875_write(client, TDA9875_MBA, 0x00 );   /* Main Bass Main 0dB*/
 	tda9875_write(client, TDA9875_MTR, 0x00 );   /* Main Treble Main 0dB*/
-	tda9875_write(client, TDA9875_ACS, 0x44 );   /* Aux chan select (dac)*/	
+	tda9875_write(client, TDA9875_ACS, 0x44 );   /* Aux chan select (dac)*/
 	tda9875_write(client, TDA9875_AVL, 0x00 );   /* Vol Aux left 0dB*/
 	tda9875_write(client, TDA9875_AVR, 0x00 );   /* Vol Aux right 0dB*/
 	tda9875_write(client, TDA9875_ABA, 0x00 );   /* Aux Bass Main 0dB*/
 	tda9875_write(client, TDA9875_ATR, 0x00 );   /* Aux Aigus Main 0dB*/
-	
+
 	tda9875_write(client, TDA9875_MUT, 0xcc );   /* General mute  */
-        
+
 	t->mode=AUDIO_UNMUTE;
 	t->lvol=t->rvol =0;  	/* 0dB */
 	t->bass=0; 		        /* 0dB */
@@ -262,7 +262,7 @@
 		kfree(t);
 		return 1;
 	}
-	
+
 	do_tda9875_init(client);
 	printk(KERN_INFO "tda9875: init\n");
 
@@ -288,7 +288,7 @@
 
 	do_tda9875_init(client);
 	i2c_detach_client(client);
-	
+
 	kfree(t);
 	return 0;
 }
@@ -298,9 +298,9 @@
 {
 	struct tda9875 *t = i2c_get_clientdata(client);
 
-	dprintk("In tda9875_command...\n"); 
+	dprintk("In tda9875_command...\n");
 
-	switch (cmd) {	
+	switch (cmd) {
         /* --- v4l ioctls --- */
 	/* take care: bttv does userspace copying, we'll get a
 	   kernel pointer here... */
@@ -335,7 +335,7 @@
 		struct video_audio *va = arg;
 		int left,right;
 
-		dprintk("VIDEOCSAUDIO...\n"); 
+		dprintk("VIDEOCSAUDIO...\n");
 		left = (min(65536 - va->balance,32768) *
 			va->volume) / 32768;
 		right = (min(va->balance,(__u16)32768) *
@@ -357,7 +357,7 @@
 		 t->bass = 15;
 		if (t->bass < -12)
 		 t->bass = -12 & 0xff;
-		
+
 		t->treble = ((va->treble/2700)-12) & 0xff;
 		if (t->treble > 12)
 		 t->treble = 12;
@@ -367,7 +367,7 @@
 
 
 //printk("tda9875 bal:%04x vol:%04x bass:%04x treble:%04x\n",va->balance,va->volume,va->bass,va->treble);
-		
+
 
                 tda9875_set(client);
 
diff -Nru a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
--- a/drivers/media/video/tda9887.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/media/video/tda9887.c	2004-12-24 13:37:43 -08:00
@@ -6,6 +6,7 @@
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 
 #include <media/audiochip.h>
 #include <media/tuner.h>
@@ -35,7 +36,7 @@
 
 /* insmod options */
 static unsigned int debug = 0;
-MODULE_PARM(debug,"i");
+module_param(debug, int, 0644);
 MODULE_LICENSE("GPL");
 
 /* ---------------------------------------------------------------------- */
@@ -245,6 +246,7 @@
 	printk(PREFIX "read: 0x%2x\n", buf[0]);
 	printk("  after power on : %s\n", (buf[0] & 0x01) ? "yes" : "no");
 	printk("  afc            : %s\n", afc[(buf[0] >> 1) & 0x0f]);
+	printk("  fmif level     : %s\n", (buf[0] & 0x20) ? "high" : "low");
 	printk("  afc window     : %s\n", (buf[0] & 0x40) ? "in" : "out");
 	printk("  vfi level      : %s\n", (buf[0] & 0x80) ? "high" : "low");
 }
@@ -376,10 +378,10 @@
 static unsigned int port2  = 1;
 static unsigned int qss    = UNSET;
 static unsigned int adjust = 0x10;
-MODULE_PARM(port1,"i");
-MODULE_PARM(port2,"i");
-MODULE_PARM(qss,"i");
-MODULE_PARM(adjust,"i");
+module_param(port1, int, 0644);
+module_param(port2, int, 0644);
+module_param(qss, int, 0644);
+module_param(adjust, int, 0644);
 
 static int tda9887_set_insmod(struct tda9887 *t, char *buf)
 {
@@ -459,10 +461,10 @@
 
 /* ---------------------------------------------------------------------- */
 
-static char *pal = "-";
-MODULE_PARM(pal,"s");
-static char *secam = "-";
-MODULE_PARM(secam,"s");
+static char pal[] = "-";
+module_param_string(pal, pal, 0644, sizeof(pal));
+static char secam[] = "-";
+module_param_string(secam, secam, 0644, sizeof(secam));
 
 static int tda9887_fixup_std(struct tda9887 *t)
 {
@@ -534,6 +536,11 @@
 	tda9887_set_config(t,buf);
 	tda9887_set_insmod(t,buf);
 
+	if (t->std & V4L2_STD_SECAM_L) {
+		/* secam fixup (FIXME: move this to tvnorms array?) */
+		buf[1] &= ~cOutputPort2Inactive;
+	}
+
 	dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n",
 		buf[1],buf[2],buf[3]);
 	if (debug > 1)
@@ -543,8 +550,7 @@
                 printk(PREFIX "i2c i/o error: rc == %d (should be 4)\n",rc);
 
 	if (debug > 2) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ);
+		msleep_interruptible(1000);
 		tda9887_status(t);
 	}
 	return 0;
@@ -565,11 +571,11 @@
                 return -ENOMEM;
 	memset(t,0,sizeof(*t));
 	t->client      = client_template;
-	t->std         = 0;;
+	t->std         = 0;
 	t->pinnacle_id = UNSET;
         i2c_set_clientdata(&t->client, t);
         i2c_attach_client(&t->client);
-        
+
 	return 0;
 }
 
@@ -618,7 +624,7 @@
 		t->radio = 1;
 		tda9887_configure(t);
 		break;
-		
+
 	case AUDC_CONFIG_PINNACLE:
 	{
 		int *i = arg;
@@ -712,6 +718,22 @@
 	return 0;
 }
 
+static int tda9887_suspend(struct device * dev, u32 state, u32 level)
+{
+	dprintk("tda9887: suspend\n");
+	return 0;
+}
+
+static int tda9887_resume(struct device * dev, u32 level)
+{
+	struct i2c_client *c = container_of(dev, struct i2c_client, dev);
+	struct tda9887 *t = i2c_get_clientdata(c);
+
+	dprintk("tda9887: resume\n");
+	tda9887_configure(t);
+	return 0;
+}
+
 /* ----------------------------------------------------------------------- */
 
 static struct i2c_driver driver = {
@@ -722,6 +744,10 @@
         .attach_adapter = tda9887_probe,
         .detach_client  = tda9887_detach,
         .command        = tda9887_command,
+	.driver = {
+		.suspend = tda9887_suspend,
+		.resume  = tda9887_resume,
+	},
 };
 static struct i2c_client client_template =
 {
diff -Nru a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
--- a/drivers/media/video/tea6415c.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/media/video/tea6415c.c	2004-12-24 13:37:04 -08:00
@@ -1,5 +1,5 @@
  /*
-    tea6415c.h - i2c-driver for the tea6415c by SGS Thomson   
+    tea6415c - i2c-driver for the tea6415c by SGS Thomson
 
     Copyright (C) 1998-2003 Michael Hunold <michael@mihu.de>
 
@@ -7,10 +7,10 @@
     with 8 inputs and 6 outputs.
     It is cascadable, i.e. it can be found at the addresses
     0x86 and 0x06 on the i2c-bus.
-    
+
     For detailed informations download the specifications directly
     from SGS Thomson at http://www.st.com
-        
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License vs published by
     the Free Software Foundation; either version 2 of the License, or
@@ -24,61 +24,58 @@
     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 Mvss Ave, Cambridge, MA 02139, USA.
- */
+  */
 
-#include <linux/version.h>
 #include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/poll.h>
-#include <linux/slab.h>
+#include <linux/ioctl.h>
 #include <linux/i2c.h>
-#include <linux/init.h>
+
 #include "tea6415c.h"
 
-static int debug = 0;	/* insmod parameter */
-MODULE_PARM(debug,"i");
-#define dprintk	if (debug) printk
+static int debug = 0;		/* insmod parameter */
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
+#define dprintk(args...) \
+            do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0)
 
 #define TEA6415C_NUM_INPUTS	8
 #define TEA6415C_NUM_OUTPUTS	6
 
 /* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */
-static unsigned short normal_i2c[] = {I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END};
-static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
+static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 
 /* magic definition of all other variables and things */
 I2C_CLIENT_INSMOD;
 
 static struct i2c_driver driver;
+static struct i2c_client client_template;
 
 /* unique ID allocation */
 static int tea6415c_id = 0;
 
 /* this function is called by i2c_probe */
-static int tea6415c_detect(struct i2c_adapter *adapter, int address, int kind)
+static int detect(struct i2c_adapter *adapter, int address, int kind)
 {
-	struct	i2c_client *client = NULL;
+	struct i2c_client *client = NULL;
 	int err = 0;
 
 	/* let's see whether this adapter can support what we need */
-	if ( 0 == i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE)) {
+	if (0 == i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE)) {
 		return 0;
 	}
 
 	/* allocate memory for client structure */
 	client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
-        if (0 == client) {
+	if (0 == client) {
 		return -ENOMEM;
 	}
-	memset(client, 0, sizeof(struct i2c_client));
 
 	/* fill client structure */
-	sprintf(client->name,"tea6415c (0x%02x)", address);
+	memcpy(client, &client_template, sizeof(struct i2c_client));
 	client->id = tea6415c_id++;
-	client->flags = 0;
 	client->addr = address;
 	client->adapter = adapter;
-	client->driver = &driver;
 
 	/* tell the i2c layer a new client has arrived */
 	if (0 != (err = i2c_attach_client(client))) {
@@ -86,151 +83,145 @@
 		return err;
 	}
 
-	printk("tea6415c.o: detected @ 0x%02x on adapter %s\n",2*address,&client->adapter->name[0]);
+	printk("tea6415c: detected @ 0x%02x on adapter %s\n", address, &client->adapter->name[0]);
 
 	return 0;
 }
 
-static int tea6415c_attach(struct i2c_adapter *adapter)
+static int attach(struct i2c_adapter *adapter)
 {
 	/* let's see whether this is a know adapter we can attach to */
-	if( adapter->id != I2C_ALGO_SAA7146 ) {
-		dprintk("tea6415c.o: refusing to probe on unknown adapter [name='%s',id=0x%x]\n",adapter->name,adapter->id);
+	if (adapter->id != I2C_ALGO_SAA7146) {
+		dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
 		return -ENODEV;
 	}
 
-	return i2c_probe(adapter,&addr_data,&tea6415c_detect);
+	return i2c_probe(adapter, &addr_data, &detect);
 }
 
-static int tea6415c_detach(struct i2c_client *client)
+static int detach(struct i2c_client *client)
 {
-	int err = 0;
-
-	if ( 0 != (err = i2c_detach_client(client))) {
-		printk("tea6415c.o: Client deregistration failed, client not detached.\n");
-		return err;
-	}
-	
+	int ret = i2c_detach_client(client);
 	kfree(client);
-
-	return 0;
+	return ret;
 }
 
 /* makes a connection between the input-pin 'i' and the output-pin 'o'
    for the tea6415c-client 'client' */
-static int tea6415c_switch(struct i2c_client *client, int i, int o)
+static int switch_matrix(struct i2c_client *client, int i, int o)
 {
-	u8 	byte = 0;
+	u8 byte = 0;
+	int ret;
 	
-	dprintk("tea6415c.o: tea6415c_switch: adr:0x%02x, i:%d, o:%d\n", client->addr, i, o);
-		
+	dprintk("adr:0x%02x, i:%d, o:%d\n", client->addr, i, o);
+
 	/* check if the pins are valid */
-	if ( 0 == ((  1 == i ||  3 == i ||  5 == i ||  6 == i ||  8 == i || 10 == i || 20 == i || 11 == i ) &&
-		    (18 == o || 17 == o || 16 == o || 15 == o || 14 == o || 13 == o )))
+	if (0 == ((1 == i ||  3 == i ||  5 == i ||  6 == i ||  8 == i || 10 == i || 20 == i || 11 == i)
+	      && (18 == o || 17 == o || 16 == o || 15 == o || 14 == o || 13 == o)))
 		return -1;
 
 	/* to understand this, have a look at the tea6415c-specs (p.5) */
-	switch(o) {
-		case 18:
-			byte = 0x00;
-			break;
-		case 14:
-			byte = 0x20;
-			break;
-		case 16:
-			byte = 0x10;
-			break;
-		case 17:
-			byte = 0x08;
-			break;
-		case 15:
-			byte = 0x18;
-			break;
-		case 13:
-			byte = 0x28;
-			break;
+	switch (o) {
+	case 18:
+		byte = 0x00;
+		break;
+	case 14:
+		byte = 0x20;
+		break;
+	case 16:
+		byte = 0x10;
+		break;
+	case 17:
+		byte = 0x08;
+		break;
+	case 15:
+		byte = 0x18;
+		break;
+	case 13:
+		byte = 0x28;
+		break;
 	};
-		
-	switch(i) {
-		case 5:
-			byte |= 0x00;
-			break;
-		case 8:
-			byte |= 0x04;
-			break;
-		case 3:
-			byte |= 0x02;
-			break;
-		case 20:
-			byte |= 0x06;
-			break;
-		case 6:
-			byte |= 0x01;
-			break;
-		case 10:
-			byte |= 0x05;
-			break;
-		case 1:
-			byte |= 0x03;
-			break;
-		case 11:
-			byte |= 0x07;
-			break;
+
+	switch (i) {
+	case 5:
+		byte |= 0x00;
+		break;
+	case 8:
+		byte |= 0x04;
+		break;
+	case 3:
+		byte |= 0x02;
+		break;
+	case 20:
+		byte |= 0x06;
+		break;
+	case 6:
+		byte |= 0x01;
+		break;
+	case 10:
+		byte |= 0x05;
+		break;
+	case 1:
+		byte |= 0x03;
+		break;
+	case 11:
+		byte |= 0x07;
+		break;
 	};
 
-	if ( 0 != i2c_smbus_write_byte(client,byte)) {
-		dprintk("tea6415c.o: tea6415c_switch: could not write to tea6415c\n");
-		return -1;
+	ret = i2c_smbus_write_byte(client, byte);
+	if (ret) {
+		dprintk("i2c_smbus_write_byte() failed, ret:%d\n", ret);
+		return -EIO;
 	}
 
-	return 0;
+	return ret;
 }
 
-static int tea6415c_command(struct i2c_client *client, unsigned int cmd, void* arg)
+static int command(struct i2c_client *client, unsigned int cmd, void *arg)
 {
-	struct tea6415c_multiplex *v = (struct tea6415c_multiplex*)arg;
+	struct tea6415c_multiplex *v = (struct tea6415c_multiplex *)arg;
 	int result = 0;
 
 	switch (cmd) {
-		case TEA6415C_SWITCH: {
-			result = tea6415c_switch(client,v->in,v->out);
-			break;
-		}
-		default: {
-			return -ENOIOCTLCMD;
-		}
+	case TEA6415C_SWITCH:
+		result = switch_matrix(client, v->in, v->out);
+		break;
+	default:
+		return -ENOIOCTLCMD;
 	}
 
-	if ( 0 != result )
-		return result;
-	
-	return 0;
+	return result;
 }
 
 static struct i2c_driver driver = {
-	.owner		= THIS_MODULE,
-	.name		= "tea6415c driver",
-	.id		= I2C_DRIVERID_TEA6415C,
-	.flags		= I2C_DF_NOTIFY,
-        .attach_adapter = tea6415c_attach,
-        .detach_client	= tea6415c_detach,
-        .command	= tea6415c_command,
+	.owner	= THIS_MODULE,
+	.name 	= "tea6415c",
+	.id 	= I2C_DRIVERID_TEA6415C,
+	.flags 	= I2C_DF_NOTIFY,
+	.attach_adapter	= attach,
+	.detach_client	= detach,
+	.command	= command,
+};
+
+static struct i2c_client client_template = {
+	I2C_DEVNAME("tea6415c"),
+	.driver = &driver,
 };
 
-static int __init tea6415c_init_module(void)
+static int __init this_module_init(void)
 {
 	return i2c_add_driver(&driver);
 }
 
-static void __exit tea6415c_cleanup_module(void)
+static void __exit this_module_exit(void)
 {
-        i2c_del_driver(&driver);
+	i2c_del_driver(&driver);
 }
 
-module_init(tea6415c_init_module);
-module_exit(tea6415c_cleanup_module);
+module_init(this_module_init);
+module_exit(this_module_exit);
 
 MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
 MODULE_DESCRIPTION("tea6415c driver");
 MODULE_LICENSE("GPL");
-
diff -Nru a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
--- a/drivers/media/video/tea6420.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/media/video/tea6420.c	2004-12-24 13:36:49 -08:00
@@ -1,5 +1,5 @@
  /*
-    tea6420.o - i2c-driver for the tea6420 by SGS Thomson
+    tea6420 - i2c-driver for the tea6420 by SGS Thomson
 
     Copyright (C) 1998-2003 Michael Hunold <michael@mihu.de>
 
@@ -7,10 +7,10 @@
     4 stereo outputs and gain control for each output.
     It is cascadable, i.e. it can be found at the adresses 0x98
     and 0x9a on the i2c-bus.
-    
+
     For detailed informations download the specifications directly
     from SGS Thomson at http://www.st.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
@@ -24,30 +24,29 @@
     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/version.h>
 #include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/poll.h>
-#include <linux/slab.h>
+#include <linux/ioctl.h>
 #include <linux/i2c.h>
-#include <linux/init.h>
 
 #include "tea6420.h"
 
-static int debug = 0;	/* insmod parameter */
-MODULE_PARM(debug,"i");
-#define dprintk	if (debug) printk
+static int debug = 0;		/* insmod parameter */
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
+#define dprintk(args...) \
+            do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0)
 
 /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */
-static unsigned short normal_i2c[] = {I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END};
-static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
+static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
 
 /* magic definition of all other variables and things */
 I2C_CLIENT_INSMOD;
 
 static struct i2c_driver driver;
+static struct i2c_client client_template;
 
 /* unique ID allocation */
 static int tea6420_id = 0;
@@ -56,39 +55,37 @@
    with gain 'g' for the tea6420-client 'client' (note: i = 6 means 'mute') */
 static int tea6420_switch(struct i2c_client *client, int i, int o, int g)
 {
-	u8 	byte = 0;
-	
-	int 	result = 0;
-	
-	dprintk("tea6420.o: tea6420_switch: adr:0x%02x, i:%d, o:%d, g:%d\n",client->addr,i,o,g);
+	u8 byte = 0;
+	int ret;
+
+	dprintk("adr:0x%02x, i:%d, o:%d, g:%d\n", client->addr, i, o, g);
 
 	/* check if the paramters are valid */
-	if ( i < 1 || i > 6 || o < 1 || o > 4 || g < 0 || g > 6 || g%2 != 0 )
+	if (i < 1 || i > 6 || o < 1 || o > 4 || g < 0 || g > 6 || g % 2 != 0)
 		return -1;
 
-	byte  = ((o-1)<<5);
-	byte |=  (i-1);
+	byte  = ((o - 1) << 5);
+	byte |= (i - 1);
 
 	/* to understand this, have a look at the tea6420-specs (p.5) */
-	switch(g) {
-		case 0:
-			byte |= (3<<3);
-			break;
-		case 2:
-			byte |= (2<<3);
-			break;
-		case 4:
-			byte |= (1<<3);
-			break;
-		case 6:
-			break;
-	}
-
-	/* fixme?: 1 != ... => 0 != */
-	if ( 0 != (result = i2c_smbus_write_byte(client,byte))) {
-		printk("tea6402:%d\n",result);
-		dprintk(KERN_ERR "tea6420.o: could not switch, result:%d\n",result);
-		return -EFAULT;
+	switch (g) {
+	case 0:
+		byte |= (3 << 3);
+		break;
+	case 2:
+		byte |= (2 << 3);
+		break;
+	case 4:
+		byte |= (1 << 3);
+		break;
+	case 6:
+		break;
+	}
+
+	ret = i2c_smbus_write_byte(client, byte);
+	if (ret) {
+		dprintk("i2c_smbus_write_byte() failed, ret:%d\n", ret);
+		return -EIO;
 	}
 	
 	return 0;
@@ -97,29 +94,26 @@
 /* this function is called by i2c_probe */
 static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
 {
-	struct	i2c_client *client;
+	struct i2c_client *client;
 	int err = 0, i = 0;
 
 	/* let's see whether this adapter can support what we need */
-	if ( 0 == i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE)) {
+	if (0 == i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE)) {
 		return 0;
 	}
 
 	/* allocate memory for client structure */
 	client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
-        if (0 == client) {
+	if (0 == client) {
 		return -ENOMEM;
 	}
-	memset(client, 0x0, sizeof(struct i2c_client));	
+	memset(client, 0x0, sizeof(struct i2c_client));
 
 	/* fill client structure */
-	sprintf(client->name,"tea6420 (0x%02x)", address);
+	memcpy(client, &client_template, sizeof(struct i2c_client));
 	client->id = tea6420_id++;
-	client->flags = 0;
 	client->addr = address;
 	client->adapter = adapter;
-	client->driver = &driver;
-	i2c_set_clientdata(client, NULL);
 
 	/* tell the i2c layer a new client has arrived */
 	if (0 != (err = i2c_attach_client(client))) {
@@ -129,86 +123,81 @@
 
 	/* set initial values: set "mute"-input to all outputs at gain 0 */
 	err = 0;
-	for(i = 1; i < 5; i++) {
+	for (i = 1; i < 5; i++) {
 		err += tea6420_switch(client, 6, i, 0);
 	}
-	if( 0 != err) {
-		printk("tea6420.o: could not initialize chipset. continuing anyway.\n");
+	if (err) {
+		dprintk("could not initialize tea6420\n");
+		kfree(client);
+		return -ENODEV;
 	}
-	
-	printk("tea6420.o: detected @ 0x%02x on adapter %s\n",2*address,&client->adapter->name[0]);
+
+	printk("tea6420: detected @ 0x%02x on adapter %s\n", address, &client->adapter->name[0]);
 
 	return 0;
 }
 
-static int tea6420_attach(struct i2c_adapter *adapter)
+static int attach(struct i2c_adapter *adapter)
 {
 	/* let's see whether this is a know adapter we can attach to */
-	if( adapter->id != I2C_ALGO_SAA7146 ) {
-		dprintk("tea6420.o: refusing to probe on unknown adapter [name='%s',id=0x%x]\n",adapter->name,adapter->id);
+	if (adapter->id != I2C_ALGO_SAA7146) {
+		dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
 		return -ENODEV;
 	}
 
-	return i2c_probe(adapter,&addr_data,&tea6420_detect);
+	return i2c_probe(adapter, &addr_data, &tea6420_detect);
 }
 
-static int tea6420_detach(struct i2c_client *client)
+static int detach(struct i2c_client *client)
 {
-	int err = 0;
-
-	if ( 0 != (err = i2c_detach_client(client))) {
-		printk("tea6420.o: Client deregistration failed, client not detached.\n");
-		return err;
-	}
-	
+	int ret = i2c_detach_client(client);
 	kfree(client);
-
-	return 0;
+	return ret;
 }
 
-static int tea6420_command(struct i2c_client *client, unsigned int cmd, void* arg)
+static int command(struct i2c_client *client, unsigned int cmd, void *arg)
 {
-	struct tea6420_multiplex *a = (struct tea6420_multiplex*)arg;
+	struct tea6420_multiplex *a = (struct tea6420_multiplex *)arg;
 	int result = 0;
 
 	switch (cmd) {
-		case TEA6420_SWITCH: {
-			result = tea6420_switch(client,a->in,a->out,a->gain);
-			break;
-		}
-		default: {
-			return -ENOIOCTLCMD;
-		}
+	case TEA6420_SWITCH:
+		result = tea6420_switch(client, a->in, a->out, a->gain);
+		break;
+	default:
+		return -ENOIOCTLCMD;
 	}
 
-	if ( 0 != result )
-		return result;
-	
-	return 0;
+	return result;
 }
 
 static struct i2c_driver driver = {
-	.owner		= THIS_MODULE,
-	.name		= "tea6420 driver",
-	.id		= I2C_DRIVERID_TEA6420,
-	.flags		= I2C_DF_NOTIFY,
-        .attach_adapter = tea6420_attach,
-        .detach_client	= tea6420_detach,
-        .command	= tea6420_command,
+	.owner	= THIS_MODULE,
+	.name	= "tea6420",
+	.id	= I2C_DRIVERID_TEA6420,
+	.flags	= I2C_DF_NOTIFY,
+	.attach_adapter	= attach,
+	.detach_client	= detach,
+	.command	= command,
+};
+
+static struct i2c_client client_template = {
+	I2C_DEVNAME("tea6420"),
+	.driver = &driver,
 };
 
-static int __init tea6420_init_module(void)
+static int __init this_module_init(void)
 {
 	return i2c_add_driver(&driver);
 }
 
-static void __exit tea6420_cleanup_module(void)
+static void __exit this_module_exit(void)
 {
-        i2c_del_driver(&driver);
+	i2c_del_driver(&driver);
 }
 
-module_init(tea6420_init_module);
-module_exit(tea6420_cleanup_module);
+module_init(this_module_init);
+module_exit(this_module_exit);
 
 MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
 MODULE_DESCRIPTION("tea6420 driver");
diff -Nru a/drivers/media/video/tuner.c b/drivers/media/video/tuner.c
--- a/drivers/media/video/tuner.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/media/video/tuner.c	2004-12-24 13:37:18 -08:00
@@ -1,4 +1,9 @@
+/*
+ * $Id: tuner.c,v 1.31 2004/11/10 11:07:24 kraxel Exp $
+ */
+
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/string.h>
@@ -15,30 +20,34 @@
 #include <media/tuner.h>
 #include <media/audiochip.h>
 
-/* Addresses to scan */
+#define UNSET (-1U)
+
+/* standard i2c insmod options */
 static unsigned short normal_i2c[] = {I2C_CLIENT_END};
 static unsigned short normal_i2c_range[] = {0x60,0x6f,I2C_CLIENT_END};
 I2C_CLIENT_INSMOD;
 
-#define UNSET (-1U)
-
-/* insmod options */
-static unsigned int debug =  0;
+/* insmod options used at init time => read/only */
 static unsigned int type  =  UNSET;
 static unsigned int addr  =  0;
+module_param(type, int, 0444);
+module_param(addr, int, 0444);
+
+/* insmod options used at runtime => read/write */
+static unsigned int debug         = 0;
+static unsigned int tv_antenna    = 1;
+static unsigned int radio_antenna = 0;
+static unsigned int optimize_vco  = 1;
+module_param(debug,             int, 0644);
+module_param(tv_antenna,        int, 0644);
+module_param(radio_antenna,     int, 0644);
+module_param(optimize_vco,      int, 0644);
+
 static unsigned int tv_range[2]    = { 44, 958 };
 static unsigned int radio_range[2] = { 65, 108 };
-static unsigned int tv_antenna = 1;
-static unsigned int radio_antenna = 0;
-MODULE_PARM(debug,"i");
-MODULE_PARM(type,"i");
-MODULE_PARM(addr,"i");
-MODULE_PARM(tv_range,"2i");
-MODULE_PARM(radio_range,"2i");
-MODULE_PARM(tv_antenna,"i");
-MODULE_PARM(radio_antenna,"i");
 
-#define optimize_vco 1
+module_param_array(tv_range,    int, NULL, 0644);
+module_param_array(radio_range, int, NULL, 0644);
 
 MODULE_DESCRIPTION("device driver for various TV and TV+FM radio tuners");
 MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer");
@@ -52,10 +61,10 @@
 	unsigned int freq;            /* keep track of the current settings */
 	v4l2_std_id  std;
 	int          using_v4l2;
-	
+
 	unsigned int radio;
 	unsigned int input;
-	
+
 	// only for MT2032
 	unsigned int xogc;
 	unsigned int radio_if2;
@@ -71,11 +80,11 @@
 
 /* tv standard selection for Temic 4046 FM5
    this value takes the low bits of control byte 2
-   from datasheet Rev.01, Feb.00 
+   from datasheet Rev.01, Feb.00
      standard     BG      I       L       L2      D
      picture IF   38.9    38.9    38.9    33.95   38.9
      sound 1      33.4    32.9    32.4    40.45   32.4
-     sound 2      33.16   
+     sound 2      33.16
      NICAM        33.05   32.348  33.05           33.05
  */
 #define TEMIC_SET_PAL_I         0x05
@@ -97,7 +106,7 @@
 #define PHILIPS_SET_PAL_I	0x01 /* Bit 2 always zero !*/
 #define PHILIPS_SET_PAL_BGDK	0x09
 #define PHILIPS_SET_PAL_L2	0x0a
-#define PHILIPS_SET_PAL_L	0x0b	
+#define PHILIPS_SET_PAL_L	0x0b
 
 /* system switching for Philips FI1216MF MK2
    from datasheet "1996 Jul 09",
@@ -115,21 +124,22 @@
 
 /* ---------------------------------------------------------------------- */
 
-struct tunertype 
+struct tunertype
 {
 	char *name;
 	unsigned char Vendor;
 	unsigned char Type;
-  
+
 	unsigned short thresh1;  /*  band switch VHF_LO <=> VHF_HI  */
 	unsigned short thresh2;  /*  band switch VHF_HI <=> UHF     */
 	unsigned char VHF_L;
 	unsigned char VHF_H;
 	unsigned char UHF;
-	unsigned char config; 
-	unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL, 
-				   732  =16*45.75 NTSCi, 
-				   940  =58.75 NTSC-Japan */
+	unsigned char config;
+	unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL,
+				   732  =16*45.75 NTSCi,
+				   940  =16*58.75 NTSC-Japan
+				   704  =16*44    ATSC */
 };
 
 /*
@@ -170,7 +180,7 @@
         { "Alps TSBC5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */
 	  16*133.25,16*351.25,0x01,0x02,0x08,0x8e,608},
 	{ "Temic PAL_BG (4006FH5)", TEMIC, PAL,
-	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, 
+	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
   	{ "Alps TSCH6",Alps,NTSC,
   	  16*137.25,16*385.25,0x14,0x12,0x11,0x8e,732},
 
@@ -244,10 +254,16 @@
 	{ "Panasonic VP27s/ENGE4324D", Panasonic, NTSC,
 	  16*160.00,16*454.00,0x01,0x02,0x08,0xce,940},
         { "LG NTSC (TAPE series)", LGINNOTEK, NTSC,
-          16*170.00, 16*450.00, 0x01,0x02,0x04,0x8e,732 },
+          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 },
 
         { "Tenna TNF 8831 BGFF)", Philips, PAL,
           16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623},
+	{ "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC,
+	  16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732},
+        { "TCL 2002N", TCL, NTSC,
+          16*172.00,16*448.00,0x01,0x02,0x08,0x8e,732},
+	{ "Philips PAL/SECAM_D (FM 1256 I-H3)", Philips, PAL,
+	  16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 },
 
 };
 #define TUNERS ARRAY_SIZE(tuners)
@@ -416,7 +432,7 @@
  	if(rfin >400*1000*1000)
                 buf[6]=0xe4;
         else
-                buf[6]=0xf4; // set PKEN per rev 1.2 
+                buf[6]=0xf4; // set PKEN per rev 1.2
 	buf[7]=8+xogc;
 	buf[8]=0xc3; //reserved
 	buf[9]=0x4e; //reserved
@@ -437,10 +453,10 @@
 		i2c_master_recv(c,buf,1);
 		dprintk("mt2032 Reg.E=0x%02x\n",buf[0]);
 		lock=buf[0] &0x06;
-		
+
 		if (lock==6)
 			break;
-		
+
 		dprintk("mt2032: pll wait 1ms for lock (0x%2x)\n",buf[0]);
 		udelay(1000);
 	}
@@ -462,7 +478,7 @@
 	if(tad1 ==1) return lock;
 
 	if(tad1==2) {
-		if(sel==0) 
+		if(sel==0)
 			return lock;
 		else sel--;
 	}
@@ -515,13 +531,13 @@
 	// wait for PLLs to lock (per manual), retry LINT if not.
 	for(lint_try=0; lint_try<2; lint_try++) {
 		lock=mt2032_check_lo_lock(c);
-		
+
 		if(optimize_vco)
 			lock=mt2032_optimize_vco(c,sel,lock);
 		if(lock==6) break;
-		
-		printk("mt2032: re-init PLLs by LINT\n"); 
-		buf[0]=7; 
+
+		printk("mt2032: re-init PLLs by LINT\n");
+		buf[0]=7;
 		buf[1]=0x80 +8+t->xogc; // set LINT to re-init PLLs
 		i2c_master_send(c,buf,2);
 		mdelay(10);
@@ -646,46 +662,46 @@
 	unsigned int f_lo1,f_lo2,lo1,lo2,f_lo1_modulo,f_lo2_modulo,num1,num2,div1a,div1b,div2a,div2b;
 	int ret;
 	unsigned char buf[6];
-	
+
 	dprintk("mt2050_set_if_freq freq=%d\n",freq);
-	
+
 	f_lo1=freq+if1;
 	f_lo1=(f_lo1/1000000)*1000000;
-	
+
 	f_lo2=f_lo1-freq-if2;
 	f_lo2=(f_lo2/50000)*50000;
-	
+
 	lo1=f_lo1/4000000;
 	lo2=f_lo2/4000000;
-	
+
 	f_lo1_modulo= f_lo1-(lo1*4000000);
 	f_lo2_modulo= f_lo2-(lo2*4000000);
-	
+
 	num1=4*f_lo1_modulo/4000000;
 	num2=4096*(f_lo2_modulo/1000)/4000;
-	
+
 	// todo spurchecks
-	
+
 	div1a=(lo1/12)-1;
 	div1b=lo1-(div1a+1)*12;
-	
+
 	div2a=(lo2/8)-1;
 	div2b=lo2-(div2a+1)*8;
-	
+
 	dprintk("lo1 lo2 = %d %d\n", lo1, lo2);
         dprintk("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n",num1,num2,div1a,div1b,div2a,div2b);
-	
-	
+
+
 	buf[0]=1;
 	buf[1]= 4*div1b + num1;
 	if(freq<275*1000*1000) buf[1] = buf[1]|0x80;
-	
+
 	buf[2]=div1a;
 	buf[3]=32*div2b + num2/256;
 	buf[4]=num2-(num2/256)*256;
 	buf[5]=div2a;
 	if(num2!=0) buf[5]=buf[5]|0x40;
-	
+
 	if(debug) {
 		int i;
 		printk("bufs is: ");
@@ -693,7 +709,7 @@
 			printk("%x ",buf[i]);
 		printk("\n");
 	}
-	
+
 	ret=i2c_master_send(c,buf,6);
         if (ret!=6)
                 printk("mt2050_set_if_freq failed with %d\n",ret);
@@ -703,7 +719,7 @@
 {
 	struct tuner *t = i2c_get_clientdata(c);
 	unsigned int if2;
-	
+
 	if (t->std & V4L2_STD_525_60) {
 		// NTSC
                 if2 = 45750*1000;
@@ -719,7 +735,7 @@
 {
 	struct tuner *t = i2c_get_clientdata(c);
 	int if2 = t->radio_if2;
-	
+
 	mt2050_set_if_freq(c, freq*62500, if2);
 	mt2050_set_antenna(c, radio_antenna);
 }
@@ -729,19 +745,19 @@
 	struct tuner *t = i2c_get_clientdata(c);
 	unsigned char buf[2];
 	int ret;
-	
+
 	buf[0]=6;
 	buf[1]=0x10;
 	ret=i2c_master_send(c,buf,2); //  power
-	
+
 	buf[0]=0x0f;
 	buf[1]=0x0f;
 	ret=i2c_master_send(c,buf,2); // m1lo
-	
+
 	buf[0]=0x0d;
 	ret=i2c_master_send(c,buf,1);
 	i2c_master_recv(c,buf,1);
-	
+
 	dprintk("mt2050: sro is %x\n",buf[0]);
 	t->tv_freq    = mt2050_set_tv_freq;
 	t->radio_freq = mt2050_set_radio_freq;
@@ -754,7 +770,7 @@
 	char *name;
         unsigned char buf[21];
 	int company_code;
-	
+
 	memset(buf,0,sizeof(buf));
 	t->tv_freq    = NULL;
 	t->radio_freq = NULL;
@@ -823,13 +839,17 @@
         unsigned char buffer[4];
 	int rc;
 
-	tun=&tuners[t->type];
-	if (freq < tun->thresh1) 
+	tun = &tuners[t->type];
+	if (freq < tun->thresh1) {
 		config = tun->VHF_L;
-	else if (freq < tun->thresh2) 
+		dprintk("tv: VHF lowrange\n");
+	} else if (freq < tun->thresh2) {
 		config = tun->VHF_H;
-	else
+		dprintk("tv: VHF high range\n");
+	} else {
 		config = tun->UHF;
+		dprintk("tv: UHF range\n");
+	}
 
 
 	/* tv norm specific stuff for multi-norm tuners */
@@ -882,13 +902,17 @@
 		/* 0x02 -> NTSC antenna input 1 */
 		/* 0x03 -> NTSC antenna input 2 */
 		config &= ~0x03;
-		if (t->std & V4L2_STD_ATSC)
+		if (!(t->std & V4L2_STD_ATSC))
 			config |= 2;
 		/* FIXME: input */
 		break;
+
+	case TUNER_MICROTUNE_4042FI5:
+		/* Set the charge pump for fast tuning */
+		tun->config |= 0x40;
+		break;
 	}
 
-	
 	/*
 	 * Philips FI1216MK2 remark from specification :
 	 * for channel selection involving band switching, and to ensure
@@ -921,6 +945,37 @@
         if (4 != (rc = i2c_master_send(c,buffer,4)))
                 printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
 
+	if (t->type == TUNER_MICROTUNE_4042FI5) {
+		// FIXME - this may also work for other tuners
+		unsigned long timeout = jiffies + msecs_to_jiffies(1);
+		u8 status_byte = 0;
+
+		/* Wait until the PLL locks */
+		for (;;) {
+			if (time_after(jiffies,timeout))
+				return;
+			if (1 != (rc = i2c_master_recv(c,&status_byte,1))) {
+				dprintk("tuner: i2c i/o read error: rc == %d (should be 1)\n",rc);
+				break;
+			}
+			/* bit 6 is PLL locked indicator */
+			if (status_byte & 0x40)
+				break;
+			udelay(10);
+		}
+
+		/* Set the charge pump for optimized phase noise figure */
+		tun->config &= ~0x40;
+		buffer[0] = (div>>8) & 0x7f;
+		buffer[1] = div      & 0xff;
+		buffer[2] = tun->config;
+		buffer[3] = config;
+		dprintk("tuner: tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
+			buffer[0],buffer[1],buffer[2],buffer[3]);
+
+		if (4 != (rc = i2c_master_send(c,buffer,4)))
+			dprintk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
+	}
 }
 
 static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
@@ -933,14 +988,18 @@
 
 	tun=&tuners[t->type];
 	div = freq + (int)(16*10.7);
-        buffer[0] = (div>>8) & 0x7f;
-        buffer[1] = div      & 0xff;
 	buffer[2] = tun->config;
+
 	switch (t->type) {
 	case TUNER_PHILIPS_FM1216ME_MK3:
 	case TUNER_PHILIPS_FM1236_MK3:
 		buffer[3] = 0x19;
 		break;
+	case TUNER_PHILIPS_FM1256_IH3:
+		div = (20 * freq)/16 + 333 * 2;
+	        buffer[2] = 0x80;
+		buffer[3] = 0x19;
+		break;
 	case TUNER_LG_PAL_FM:
 		buffer[3] = 0xa5;
 		break;
@@ -948,6 +1007,8 @@
 		buffer[3] = 0xa4;
 		break;
 	}
+        buffer[0] = (div>>8) & 0x7f;
+        buffer[1] = div      & 0xff;
 
 	dprintk("tuner: radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
 		buffer[0],buffer[1],buffer[2],buffer[3]);
@@ -1024,7 +1085,7 @@
 {
 	struct tuner *t = i2c_get_clientdata(c);
 
-	if (t->type != UNSET) {
+	if (t->type != UNSET && t->type != TUNER_ABSENT) {
 		if (t->type != type)
 			printk("tuner: type already set to %d, "
 			       "ignoring request for %d\n", t->type, type);
@@ -1049,8 +1110,8 @@
 	}
 }
 
-static char *pal = "-";
-MODULE_PARM(pal,"s");
+static char pal[] = "-";
+module_param_string(pal, pal, 0644, sizeof(pal));
 
 static int tuner_fixup_std(struct tuner *t)
 {
@@ -1091,7 +1152,7 @@
 	if (this_adap > 0)
 		return -1;
 	this_adap++;
-	
+
         client_template.adapter = adap;
         client_template.addr = addr;
 
@@ -1193,7 +1254,7 @@
 			break;
 		}
                 break;
-		
+
 	/* --- v4l ioctls --- */
 	/* take care: bttv does userspace copying, we'll get a
 	   kernel pointer here... */
@@ -1288,7 +1349,25 @@
 		/* nothing */
 		break;
 	}
-	
+
+	return 0;
+}
+
+static int tuner_suspend(struct device * dev, u32 state, u32 level)
+{
+	dprintk("tuner: suspend\n");
+	/* FIXME: power down ??? */
+	return 0;
+}
+
+static int tuner_resume(struct device * dev, u32 level)
+{
+	struct i2c_client *c = container_of(dev, struct i2c_client, dev);
+	struct tuner *t = i2c_get_clientdata(c);
+
+	dprintk("tuner: resume\n");
+	if (t->freq)
+		set_freq(c,t->freq);
 	return 0;
 }
 
@@ -1302,6 +1381,10 @@
         .attach_adapter = tuner_probe,
         .detach_client  = tuner_detach,
         .command        = tuner_command,
+	.driver = {
+		.suspend = tuner_suspend,
+		.resume  = tuner_resume,
+	},
 };
 static struct i2c_client client_template =
 {
diff -Nru a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
--- a/drivers/media/video/tvaudio.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/media/video/tvaudio.c	2004-12-24 13:36:34 -08:00
@@ -3,12 +3,12 @@
  *
  * Copyright (c) 2000 Gerd Knorr
  * based on code by:
- *   Eric Sandeen (eric_sandeen@bigfoot.com) 
+ *   Eric Sandeen (eric_sandeen@bigfoot.com)
  *   Steve VanDeBogart (vandebo@uclink.berkeley.edu)
  *   Greg Alexander (galexand@acm.org)
  *
  * This code is placed under the terms of the GNU General Public License
- * 
+ *
  * OPTIONS:
  *   debug - set to 1 if you'd like to see debug messages
  *
@@ -37,8 +37,8 @@
 /* ---------------------------------------------------------------------- */
 /* insmod args                                                            */
 
-MODULE_PARM(debug,"i");
 static int debug = 0;	/* insmod parameter */
+module_param(debug, int, 0644);
 
 MODULE_DESCRIPTION("device driver for various i2c TV sound decoder / audiomux chips");
 MODULE_AUTHOR("Eric Sandeen, Steve VanDeBogart, Greg Alexander, Gerd Knorr");
@@ -207,7 +207,7 @@
 		       i2c_clientname(&chip->c));
 		return -1;
 	}
-	dprintk("%s: chip_read: 0x%x\n",i2c_clientname(&chip->c),buffer); 
+	dprintk("%s: chip_read: 0x%x\n",i2c_clientname(&chip->c),buffer);
 	return buffer;
 }
 
@@ -227,14 +227,14 @@
 		return -1;
 	}
 	dprintk("%s: chip_read2: reg%d=0x%x\n",
-		i2c_clientname(&chip->c),subaddr,read[0]); 
+		i2c_clientname(&chip->c),subaddr,read[0]);
 	return read[0];
 }
 
 static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
 {
 	int i;
-	
+
 	if (0 == cmd->count)
 		return 0;
 
@@ -273,7 +273,7 @@
 	DECLARE_WAITQUEUE(wait, current);
         struct CHIPSTATE *chip = data;
 	struct CHIPDESC  *desc = chiplist + chip->type;
-	
+
 	daemonize("%s",i2c_clientname(&chip->c));
 	allow_signal(SIGTERM);
 	dprintk("%s: thread started\n", i2c_clientname(&chip->c));
@@ -292,10 +292,10 @@
 		/* don't do anything for radio or if mode != auto */
 		if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0)
 			continue;
-		
+
 		/* have a look what's going on */
 		desc->checkmode(chip);
-		
+
 		/* schedule next check */
 		mod_timer(&chip->wt, jiffies+2*HZ);
 	}
@@ -352,14 +352,14 @@
 static int tda9840_getmode(struct CHIPSTATE *chip)
 {
 	int val, mode;
-	
+
 	val = chip_read(chip);
 	mode = VIDEO_SOUND_MONO;
 	if (val & TDA9840_DS_DUAL)
 		mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
 	if (val & TDA9840_ST_STEREO)
 		mode |= VIDEO_SOUND_STEREO;
-	
+
 	dprintk ("tda9840_getmode(): raw chip read: %d, return: %d\n",
 		 val, mode);
 	return mode;
@@ -369,7 +369,7 @@
 {
 	int update = 1;
 	int t = chip->shadow.bytes[TDA9840_SW + 1] & ~0x7e;
-	
+
 	switch (mode) {
 	case VIDEO_SOUND_MONO:
 		t |= TDA9840_MONO;
@@ -419,7 +419,7 @@
  * in 1dB steps - mute is 0x27 */
 
 
-/* 0x02 - BA in TDA9855 */ 
+/* 0x02 - BA in TDA9855 */
 /* lower 5 bits control bass gain from -12dB (0x06) to 16.5dB (0x19)
  * in .5dB steps - 0 is 0x0E */
 
@@ -433,7 +433,7 @@
 /* Unique to TDA9855: */
 /* 4 bits << 2 control subwoofer/surround gain from -14db (0x1) to 14db (0xf)
  * in 3dB steps - mute is 0x0 */
- 
+
 /* Unique to TDA9850: */
 /* lower 4 bits control stereo noise threshold, over which stereo turns off
  * set to values of 0x00 through 0x0f for Ster1 through Ster16 */
@@ -446,7 +446,7 @@
 #define TDA9855_LOUD	1<<5 /* Loudness, 1==off */
 #define TDA9855_SUR	1<<3 /* Surround / Subwoofer 1==.5(L-R) 0==.5(L+R) */
 			     /* Bits 0 to 3 select various combinations
-                              * of line in and line out, only the 
+                              * of line in and line out, only the
                               * interesting ones are defined */
 #define TDA9855_EXT	1<<2 /* Selects inputs LIR and LIL.  Pins 41 & 12 */
 #define TDA9855_INT	0    /* Selects inputs LOR and LOL.  (internal) */
@@ -499,7 +499,7 @@
 {
 	int mode;
 
-	mode = ((TDA985x_STP | TDA985x_SAPP) & 
+	mode = ((TDA985x_STP | TDA985x_SAPP) &
 		chip_read(chip)) >> 4;
 	/* Add mono mode regardless of SAP and stereo */
 	/* Allows forced mono */
@@ -510,7 +510,7 @@
 {
 	int update = 1;
 	int c6 = chip->shadow.bytes[TDA985x_C6+1] & 0x3f;
-	
+
 	switch (mode) {
 	case VIDEO_SOUND_MONO:
 		c6 |= TDA985x_MONO;
@@ -538,7 +538,7 @@
 #define TDA9873_AD	0x01 /* Adjust                       */
 #define TDA9873_PT	0x02 /* Port                         */
 
-/* Subaddress 0x00: Switching Data 
+/* Subaddress 0x00: Switching Data
  * B7..B0:
  *
  * B1, B0: Input source selection
@@ -552,10 +552,10 @@
 #define TDA9873_EXT_MONO    1
 
 /*    B3, B2: output signal select
- * B4    : transmission mode 
+ * B4    : transmission mode
  *  0, 0, 1   Mono
  *  1, 0, 0   Stereo
- *  1, 1, 1   Stereo (reversed channel)    
+ *  1, 1, 1   Stereo (reversed channel)
  *  0, 0, 0   Dual AB
  *  0, 0, 1   Dual AA
  *  0, 1, 0   Dual BB
@@ -587,7 +587,7 @@
 
 #define	TDA9873_STEREO_ADJ	0x06 /* 0dB gain */
 
-/* Bits C6..C4 control FM stantard  
+/* Bits C6..C4 control FM stantard
  * C6, C5, C4
  *  0,  0,  0   B/G (PAL FM)
  *  0,  0,  1   M
@@ -609,7 +609,7 @@
 #define TDA9873_IDR_FAST 1 << 7
 
 
-/* Subaddress 0x02: Port data */ 
+/* Subaddress 0x02: Port data */
 
 /* E1, E0   free programmable ports P1/P2
     0,  0   both ports low
@@ -632,11 +632,11 @@
  */
 #define TDA9873_MOUT_MONO   0
 #define TDA9873_MOUT_FMONO  0
-#define TDA9873_MOUT_DUALA  0 
-#define TDA9873_MOUT_DUALB  1 << 3 
-#define TDA9873_MOUT_ST     1 << 4 
+#define TDA9873_MOUT_DUALA  0
+#define TDA9873_MOUT_DUALB  1 << 3
+#define TDA9873_MOUT_ST     1 << 4
 #define TDA9873_MOUT_EXTM   (1 << 4 ) & (1 << 3)
-#define TDA9873_MOUT_EXTL   1 << 5 
+#define TDA9873_MOUT_EXTL   1 << 5
 #define TDA9873_MOUT_EXTR   (1 << 5 ) & (1 << 3)
 #define TDA9873_MOUT_EXTLR  (1 << 5 ) & (1 << 4)
 #define TDA9873_MOUT_MUTE   (1 << 5 ) & (1 << 4) & (1 << 3)
@@ -670,13 +670,13 @@
 		dprintk("tda9873_setmode(): external input\n");
 		return;
 	}
-	
+
 	dprintk("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]);
 	dprintk("tda9873_setmode(): sw_data  = %d\n", sw_data);
 
 	switch (mode) {
 	case VIDEO_SOUND_MONO:
-		sw_data |= TDA9873_TR_MONO;   
+		sw_data |= TDA9873_TR_MONO;
 		break;
 	case VIDEO_SOUND_STEREO:
 		sw_data |= TDA9873_TR_STEREO;
@@ -764,9 +764,9 @@
 static unsigned int tda9874a_SIF   = UNSET;
 static unsigned int tda9874a_AMSEL = UNSET;
 static unsigned int tda9874a_STD   = UNSET;
-MODULE_PARM(tda9874a_SIF,"i");
-MODULE_PARM(tda9874a_AMSEL,"i");
-MODULE_PARM(tda9874a_STD,"i");
+module_param(tda9874a_SIF, int, 0444);
+module_param(tda9874a_AMSEL, int, 0444);
+module_param(tda9874a_STD, int, 0444);
 
 /*
  * initialization table for tda9874 decoder:
@@ -871,7 +871,7 @@
 		if(nsr & 0x02) /* NSR.S/MB=1 */
 			mode |= VIDEO_SOUND_STEREO;
 #endif
-		if(nsr & 0x01) /* NSR.D/SB=1 */ 
+		if(nsr & 0x01) /* NSR.D/SB=1 */
 			mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
 	} else {
 		if(dsr & 0x02) /* DSR.IDSTE=1 */
@@ -1082,7 +1082,7 @@
 static void tda8425_setmode(struct CHIPSTATE *chip, int mode)
 {
 	int s1 = chip->shadow.bytes[TDA8425_S1+1] & 0xe1;
-	
+
 	if (mode & VIDEO_SOUND_LANG1) {
 		s1 |= TDA8425_S1_ML_SOUND_A;
 		s1 |= TDA8425_S1_STEREO_PSEUDO;
@@ -1090,10 +1090,10 @@
 	} else if (mode & VIDEO_SOUND_LANG2) {
 		s1 |= TDA8425_S1_ML_SOUND_B;
 		s1 |= TDA8425_S1_STEREO_PSEUDO;
-		
+
 	} else {
 		s1 |= TDA8425_S1_ML_STEREO;
-		
+
 		if (mode & VIDEO_SOUND_MONO)
 			s1 |= TDA8425_S1_STEREO_MONO;
 		if (mode & VIDEO_SOUND_STEREO)
@@ -1152,7 +1152,7 @@
 static int ta8874z_getmode(struct CHIPSTATE *chip)
 {
 	int val, mode;
-	
+
 	val = chip_read(chip);
 	mode = VIDEO_SOUND_MONO;
 	if (val & TA8874Z_B1){
@@ -1218,16 +1218,16 @@
 int pic16c54 = 1;
 int ta8874z  = 0;  // address clash with tda9840
 
-MODULE_PARM(tda8425,"i");
-MODULE_PARM(tda9840,"i");
-MODULE_PARM(tda9850,"i");
-MODULE_PARM(tda9855,"i");
-MODULE_PARM(tda9873,"i");
-MODULE_PARM(tda9874a,"i");
-MODULE_PARM(tea6300,"i");
-MODULE_PARM(tea6420,"i");
-MODULE_PARM(pic16c54,"i");
-MODULE_PARM(ta8874z,"i");
+module_param(tda8425, int, 0444);
+module_param(tda9840, int, 0444);
+module_param(tda9850, int, 0444);
+module_param(tda9855, int, 0444);
+module_param(tda9873, int, 0444);
+module_param(tda9874a, int, 0444);
+module_param(tea6300, int, 0444);
+module_param(tea6420, int, 0444);
+module_param(pic16c54, int, 0444);
+module_param(ta8874z, int, 0444);
 
 static struct CHIPDESC chiplist[] = {
 	{
@@ -1264,7 +1264,7 @@
 		.inputmute  = TDA9873_MUTE | TDA9873_AUTOMUTE,
 		.inputmap   = {0xa0, 0xa2, 0xa0, 0xa0, 0xc0},
 		.inputmask  = TDA9873_INP_MASK|TDA9873_MUTE|TDA9873_AUTOMUTE,
-		
+
 	},
 	{
 		.name       = "tda9874h/a",
@@ -1497,6 +1497,10 @@
 
 static int chip_probe(struct i2c_adapter *adap)
 {
+	/* don't attach on saa7146 based cards,
+	   because dedicated drivers are used */
+	if ((adap->id & I2C_ALGO_SAA7146))
+		return 0;
 #ifdef I2C_CLASS_TV_ANALOG
 	if (adap->class & I2C_CLASS_TV_ANALOG)
 		return i2c_probe(adap, &addr_data, chip_attach);
@@ -1522,7 +1526,7 @@
 		wake_up_interruptible(&chip->wq);
 		wait_for_completion(&chip->texit);
 	}
-	
+
 	i2c_detach_client(&chip->c);
 	kfree(chip);
 	return 0;
@@ -1587,7 +1591,7 @@
 	case VIDIOCSAUDIO:
 	{
 		struct video_audio *va = arg;
-		
+
 		if (desc->flags & CHIP_HAS_VOLUME) {
 			chip->left = (min(65536 - va->balance,32768) *
 				      va->volume) / 32768;
@@ -1613,7 +1617,7 @@
 	case VIDIOCSCHAN:
 	{
 		struct video_channel *vc = arg;
-		
+
 		dprintk(KERN_DEBUG "tvaudio: VIDIOCSCHAN\n");
 		chip->norm = vc->norm;
 		break;
diff -Nru a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c
--- a/drivers/media/video/tvmixer.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/media/video/tvmixer.c	2004-12-24 13:37:19 -08:00
@@ -20,7 +20,7 @@
 #define DEV_MAX  4
 
 static int devnr = -1;
-MODULE_PARM(devnr,"i");
+module_param(devnr, int, 0644);
 
 MODULE_AUTHOR("Gerd Knorr");
 MODULE_LICENSE("GPL");
@@ -82,7 +82,7 @@
 
 	if (NULL == client)
 		return -ENODEV;
-	
+
         if (cmd == SOUND_MIXER_INFO) {
                 mixer_info info;
                 strlcpy(info.id, "tv card", sizeof(info.id));
@@ -148,7 +148,7 @@
 			 va.volume) / 32768;
 		ret = v4l_to_mix2(left,right);
 		break;
-		
+
 	case MIXER_WRITE(SOUND_MIXER_BASS):
 		va.bass = mix_to_v4l(val);
 		client->driver->command(client,VIDIOCSAUDIO,&va);
@@ -324,7 +324,7 @@
 	devices[i].dev   = client;
 	printk("tvmixer: %s (%s) registered with minor %d\n",
 	       client->name,client->adapter->name,minor);
-	
+
 	return 0;
 }
 
@@ -333,7 +333,7 @@
 static int __init tvmixer_init_module(void)
 {
 	int i;
-	
+
 	for (i = 0; i < DEV_MAX; i++)
 		devices[i].minor = -1;
 
@@ -343,7 +343,7 @@
 static void __exit tvmixer_cleanup_module(void)
 {
 	int i;
-	
+
 	i2c_del_driver(&driver);
 	for (i = 0; i < DEV_MAX; i++) {
 		if (devices[i].minor != -1) {
diff -Nru a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
--- a/drivers/media/video/v4l1-compat.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/media/video/v4l1-compat.c	2004-12-24 13:36:56 -08:00
@@ -44,7 +44,7 @@
 #endif
 
 static unsigned int debug  = 0;
-MODULE_PARM(debug,"i");
+module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug,"enable debug messages");
 MODULE_AUTHOR("Bill Dirks");
 MODULE_DESCRIPTION("v4l(1) compatibility layer for v4l2 drivers.");
@@ -116,7 +116,7 @@
 		if (value && qctrl2.type == V4L2_CTRL_TYPE_BOOLEAN)
 			value = 65535;
 		ctrl2.id = qctrl2.id;
-		ctrl2.value = 
+		ctrl2.value =
 			(value * (qctrl2.maximum - qctrl2.minimum)
 			 + 32767)
 			/ 65535;
@@ -256,7 +256,7 @@
 
 	memset(&desc2,0,sizeof(desc2));
 	memset(&fmt2,0,sizeof(fmt2));
-	
+
 	desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 	if (0 != drv(inode,file,VIDIOC_ENUM_FMT, &desc2))
 		goto done;
@@ -326,7 +326,7 @@
 			err = 0;
 		}
 
-		memcpy(cap->name, cap2->card, 
+		memcpy(cap->name, cap2->card,
 		       min(sizeof(cap->name), sizeof(cap2->card)));
 		cap->name[sizeof(cap->name) - 1] = 0;
 		if (cap2->capabilities & V4L2_CAP_VIDEO_CAPTURE)
@@ -383,7 +383,7 @@
 		if (0 != fbuf2.fmt.bytesperline)
 			buffer->bytesperline = fbuf2.fmt.bytesperline;
 		else {
-			buffer->bytesperline = 
+			buffer->bytesperline =
 				(buffer->width * buffer->depth + 7) & 7;
 			buffer->bytesperline >>= 3;
 		}
@@ -633,7 +633,7 @@
 		err = drv(inode, file, VIDIOC_G_FMT, fmt2);
 		if (err < 0)
 			dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err);
-		if (fmt2->fmt.pix.pixelformat != 
+		if (fmt2->fmt.pix.pixelformat !=
 		    palette_to_pixelformat(pict->palette)) {
 			fmt2->fmt.pix.pixelformat = palette_to_pixelformat(
 				pict->palette);
@@ -807,7 +807,7 @@
 
 		memset(&aud2,0,sizeof(aud2));
 		memset(&tun2,0,sizeof(tun2));
-		
+
 		aud2.index = aud->audio;
 		err = drv(inode, file, VIDIOC_S_AUDIO, &aud2);
 		if (err < 0) {
@@ -815,7 +815,7 @@
 			break;
 		}
 
-		set_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, 
+		set_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME,
 				aud->volume, drv);
 		set_v4l_control(inode, file, V4L2_CID_AUDIO_BASS,
 				aud->bass, drv);
@@ -863,16 +863,16 @@
 		fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL);
 		memset(&buf2,0,sizeof(buf2));
 		memset(fmt2,0,sizeof(*fmt2));
-		
+
 		fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 		err = drv(inode, file, VIDIOC_G_FMT, fmt2);
 		if (err < 0) {
 			dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n",err);
 			break;
 		}
-		if (mm->width   != fmt2->fmt.pix.width  || 
+		if (mm->width   != fmt2->fmt.pix.width  ||
 		    mm->height  != fmt2->fmt.pix.height ||
-		    palette_to_pixelformat(mm->format) != 
+		    palette_to_pixelformat(mm->format) !=
 		    fmt2->fmt.pix.pixelformat)
 		{/* New capture format...  */
 			fmt2->fmt.pix.width = mm->width;
@@ -955,11 +955,11 @@
 	case VIDIOCGVBIFMT: /* query VBI data capture format */
 	{
 		struct vbi_format      *fmt = arg;
-		
+
 		fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL);
 		memset(fmt2, 0, sizeof(*fmt2));
 		fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE;
-		
+
 		err = drv(inode, file, VIDIOC_G_FMT, fmt2);
 		if (err < 0) {
 			dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err);
@@ -979,7 +979,7 @@
 	case VIDIOCSVBIFMT:
 	{
 		struct vbi_format      *fmt = arg;
-		
+
 		fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL);
 		memset(fmt2, 0, sizeof(*fmt2));
 
@@ -987,10 +987,10 @@
 		fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line;
 		fmt2->fmt.vbi.sampling_rate    = fmt->sampling_rate;
 		fmt2->fmt.vbi.sample_format    = V4L2_PIX_FMT_GREY;
-		fmt2->fmt.vbi.start[0]         = fmt->start[0]; 
-		fmt2->fmt.vbi.count[0]         = fmt->count[0]; 
-		fmt2->fmt.vbi.start[1]         = fmt->start[1]; 
-		fmt2->fmt.vbi.count[1]         = fmt->count[1]; 
+		fmt2->fmt.vbi.start[0]         = fmt->start[0];
+		fmt2->fmt.vbi.count[0]         = fmt->count[0];
+		fmt2->fmt.vbi.start[1]         = fmt->start[1];
+		fmt2->fmt.vbi.count[1]         = fmt->count[1];
 		fmt2->fmt.vbi.flags            = fmt->flags;
 		err = drv(inode, file, VIDIOC_TRY_FMT, fmt2);
 		if (err < 0) {
@@ -1014,7 +1014,7 @@
 			dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err);
 		break;
 	}
-	
+
 	default:
 		err = -ENOIOCTLCMD;
 		break;
diff -Nru a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
--- a/drivers/media/video/v4l2-common.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/media/video/v4l2-common.c	2004-12-24 13:37:19 -08:00
@@ -36,7 +36,7 @@
 /*
  * Video4linux 1/2 integration by Justin Schoeman
  * <justin@suntiger.ee.up.ac.za>
- * 2.4 PROCFS support ported from 2.4 kernels by 
+ * 2.4 PROCFS support ported from 2.4 kernels by
  *  Iñaki García Etxebarria <garetxe@euskalnet.net>
  * Makefile fix by "W. Michael Petullo" <mike@flyn.org>
  * 2.4 devfs support ported from 2.4 kernels by
@@ -84,17 +84,20 @@
  *  Video Standard Operations (contributed by Michael Schimek)
  */
 
-/* This is the recommended method to deal with the framerate fields. More 
+#if 0 /* seems to have no users */
+/* This is the recommended method to deal with the framerate fields. More
    sophisticated drivers will access the fields directly. */
 unsigned int
 v4l2_video_std_fps(struct v4l2_standard *vs)
-{ 
+{
 	if (vs->frameperiod.numerator > 0)
-		return (((vs->frameperiod.denominator << 8) / 
-			 vs->frameperiod.numerator) + 
+		return (((vs->frameperiod.denominator << 8) /
+			 vs->frameperiod.numerator) +
 			(1 << 7)) / (1 << 8);
 	return 0;
 }
+EXPORT_SYMBOL(v4l2_video_std_fps);
+#endif
 
 /* Fill in the fields of a v4l2_standard structure according to the
    'id' and 'transmission' parameters.  Returns negative on error.  */
@@ -132,7 +135,7 @@
 	memset(global,0,sizeof(*global));
 	return 0;
 }
-	
+
 int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
 		     enum v4l2_priority new)
 {
@@ -259,7 +262,6 @@
 
 /* ----------------------------------------------------------------- */
 
-EXPORT_SYMBOL(v4l2_video_std_fps);
 EXPORT_SYMBOL(v4l2_video_std_construct);
 
 EXPORT_SYMBOL(v4l2_prio_init);
diff -Nru a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/media/video/video-buf-dvb.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,248 @@
+/*
+ * $Id: video-buf-dvb.c,v 1.5 2004/11/07 13:17:15 kraxel Exp $
+ *
+ * some helper function for simple DVB cards which simply DMA the
+ * complete transport stream and let the computer sort everything else
+ * (i.e. we are using the software demux, ...).  Also uses the
+ * video-buf to manage DMA buffers.
+ *
+ * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
+ *
+ * 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/init.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/kthread.h>
+#include <linux/file.h>
+#include <linux/suspend.h>
+
+#include <media/video-buf.h>
+#include <media/video-buf-dvb.h>
+
+/* ------------------------------------------------------------------ */
+
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+static unsigned int debug = 0;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug,"enable debug messages");
+
+#define dprintk(fmt, arg...)	if (debug)			\
+	printk(KERN_DEBUG "%s/dvb: " fmt, dvb->name, ## arg)
+
+/* ------------------------------------------------------------------ */
+
+static int videobuf_dvb_thread(void *data)
+{
+	struct videobuf_dvb *dvb = data;
+	struct videobuf_buffer *buf;
+	unsigned long flags;
+	int err;
+
+	dprintk("dvb thread started\n");
+	videobuf_read_start(&dvb->dvbq);
+
+	for (;;) {
+		/* fetch next buffer */
+		buf = list_entry(dvb->dvbq.stream.next,
+				 struct videobuf_buffer, stream);
+		list_del(&buf->stream);
+		err = videobuf_waiton(buf,0,1);
+		BUG_ON(0 != err);
+
+		/* no more feeds left or stop_feed() asked us to quit */
+		if (0 == dvb->nfeeds)
+			break;
+		if (kthread_should_stop())
+			break;
+		if (current->flags & PF_FREEZE)
+			refrigerator(PF_FREEZE);
+
+		/* feed buffer data to demux */
+		if (buf->state == STATE_DONE)
+			dvb_dmx_swfilter(&dvb->demux, buf->dma.vmalloc,
+					 buf->size);
+
+		/* requeue buffer */
+		list_add_tail(&buf->stream,&dvb->dvbq.stream);
+		spin_lock_irqsave(dvb->dvbq.irqlock,flags);
+		dvb->dvbq.ops->buf_queue(&dvb->dvbq,buf);
+		spin_unlock_irqrestore(dvb->dvbq.irqlock,flags);
+	}
+
+	videobuf_read_stop(&dvb->dvbq);
+	dprintk("dvb thread stopped\n");
+
+	/* Hmm, linux becomes *very* unhappy without this ... */
+	while (!kthread_should_stop()) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule();
+	}
+	return 0;
+}
+
+static int videobuf_dvb_start_feed(struct dvb_demux_feed *feed)
+{
+	struct dvb_demux *demux  = feed->demux;
+	struct videobuf_dvb *dvb = demux->priv;
+	int rc;
+
+	if (!demux->dmx.frontend)
+		return -EINVAL;
+
+	down(&dvb->lock);
+	dvb->nfeeds++;
+	rc = dvb->nfeeds;
+
+	if (NULL != dvb->thread)
+		goto out;
+	dvb->thread = kthread_run(videobuf_dvb_thread,
+				  dvb, "%s dvb", dvb->name);
+	if (IS_ERR(dvb->thread)) {
+		rc = PTR_ERR(dvb->thread);
+		dvb->thread = NULL;
+	}
+
+out:
+	up(&dvb->lock);
+	return rc;
+}
+
+static int videobuf_dvb_stop_feed(struct dvb_demux_feed *feed)
+{
+	struct dvb_demux *demux  = feed->demux;
+	struct videobuf_dvb *dvb = demux->priv;
+	int err = 0;
+
+	down(&dvb->lock);
+	dvb->nfeeds--;
+	if (0 == dvb->nfeeds  &&  NULL != dvb->thread) {
+		// FIXME: cx8802_cancel_buffers(dev);
+		err = kthread_stop(dvb->thread);
+		dvb->thread = NULL;
+	}
+	up(&dvb->lock);
+	return err;
+}
+
+/* ------------------------------------------------------------------ */
+
+int videobuf_dvb_register(struct videobuf_dvb *dvb)
+{
+	int result;
+
+	init_MUTEX(&dvb->lock);
+
+	/* register adapter */
+	result = dvb_register_adapter(&dvb->adapter, dvb->name, THIS_MODULE);
+	if (result < 0) {
+		printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n",
+		       dvb->name, result);
+		goto fail_adapter;
+	}
+
+	/* register frontend */
+	result = dvb_register_frontend(dvb->adapter, dvb->frontend);
+	if (result < 0) {
+		printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n",
+		       dvb->name, result);
+		goto fail_frontend;
+	}
+
+	/* register demux stuff */
+	dvb->demux.dmx.capabilities =
+		DMX_TS_FILTERING | DMX_SECTION_FILTERING |
+		DMX_MEMORY_BASED_FILTERING;
+	dvb->demux.priv       = dvb;
+	dvb->demux.filternum  = 256;
+	dvb->demux.feednum    = 256;
+	dvb->demux.start_feed = videobuf_dvb_start_feed;
+	dvb->demux.stop_feed  = videobuf_dvb_stop_feed;
+	result = dvb_dmx_init(&dvb->demux);
+	if (result < 0) {
+		printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n",
+		       dvb->name, result);
+		goto fail_dmx;
+	}
+
+	dvb->dmxdev.filternum    = 256;
+	dvb->dmxdev.demux        = &dvb->demux.dmx;
+	dvb->dmxdev.capabilities = 0;
+	result = dvb_dmxdev_init(&dvb->dmxdev, dvb->adapter);
+	if (result < 0) {
+		printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n",
+		       dvb->name, result);
+		goto fail_dmxdev;
+	}
+
+	dvb->fe_hw.source = DMX_FRONTEND_0;
+	result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw);
+	if (result < 0) {
+		printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
+		       dvb->name, result);
+		goto fail_fe_hw;
+	}
+
+	dvb->fe_mem.source = DMX_MEMORY_FE;
+	result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem);
+	if (result < 0) {
+		printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
+		       dvb->name, result);
+		goto fail_fe_mem;
+	}
+
+	result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw);
+	if (result < 0) {
+		printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n",
+		       dvb->name, result);
+		goto fail_fe_conn;
+	}
+
+	/* register network adapter */
+	dvb_net_init(dvb->adapter, &dvb->net, &dvb->demux.dmx);
+	return 0;
+
+fail_fe_conn:
+	dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
+fail_fe_mem:
+	dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
+fail_fe_hw:
+	dvb_dmxdev_release(&dvb->dmxdev);
+fail_dmxdev:
+	dvb_dmx_release(&dvb->demux);
+fail_dmx:
+	dvb_unregister_frontend(dvb->frontend);
+fail_frontend:
+	dvb_unregister_adapter(dvb->adapter);
+fail_adapter:
+	return result;
+}
+
+void videobuf_dvb_unregister(struct videobuf_dvb *dvb)
+{
+	dvb_net_release(&dvb->net);
+	dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
+	dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
+	dvb_dmxdev_release(&dvb->dmxdev);
+	dvb_dmx_release(&dvb->demux);
+	dvb_unregister_frontend(dvb->frontend);
+	dvb_unregister_adapter(dvb->adapter);
+}
+
+EXPORT_SYMBOL(videobuf_dvb_register);
+EXPORT_SYMBOL(videobuf_dvb_unregister);
+
+/* ------------------------------------------------------------------ */
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * compile-command: "make DVB=1"
+ * End:
+ */
diff -Nru a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
--- a/drivers/media/video/video-buf.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/media/video/video-buf.c	2004-12-24 13:36:49 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: video-buf.c,v 1.15 2004/11/07 14:45:00 kraxel Exp $
+ *
  * generic helper functions for video4linux capture buffers, to handle
  * memory management and PCI DMA.  Right now bttv + saa7134 use it.
  *
@@ -7,7 +9,7 @@
  * into PAGE_SIZE chunks).  They also assume the driver does not need
  * to touch the video data (thus it is probably not useful for USB 1.1
  * as data often must be uncompressed by the drivers).
- * 
+ *
  * (c) 2001-2004 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
  *
  * This program is free software; you can redistribute it and/or modify
@@ -34,11 +36,11 @@
 	{ printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); }
 
 static int debug = 0;
+module_param(debug, int, 0644);
 
 MODULE_DESCRIPTION("helper module to manage video4linux pci dma buffers");
 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug,"i");
 
 #define dprintk(level, fmt, arg...)	if (debug >= level) \
 	printk(KERN_DEBUG "vbuf: " fmt , ## arg)
@@ -64,7 +66,7 @@
 		sglist[i].length = PAGE_SIZE;
 	}
 	return sglist;
-	
+
  err:
 	kfree(sglist);
 	return NULL;
@@ -191,7 +193,7 @@
 {
 	MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
 	BUG_ON(0 == dma->nr_pages);
-	
+
 	if (dma->pages) {
 		dma->sglist = videobuf_pages_to_sg(dma->pages, dma->nr_pages,
 						   dma->offset);
@@ -287,7 +289,7 @@
 {
 	int retval = 0;
 	DECLARE_WAITQUEUE(wait, current);
-	
+
 	MAGIC_CHECK(vb->magic,MAGIC_BUFFER);
 	add_wait_queue(&vb->done, &wait);
 	while (vb->state == STATE_ACTIVE || vb->state == STATE_QUEUED) {
@@ -353,39 +355,39 @@
 	err = videobuf_dma_pci_map(pci,&vb->dma);
 	if (0 != err)
 		return err;
-		
+
 	return 0;
 }
 
 /* --------------------------------------------------------------------- */
 
-void
-videobuf_queue_init(struct videobuf_queue *q,
-		    struct videobuf_queue_ops *ops,
-		    struct pci_dev *pci,
-		    spinlock_t *irqlock,
-		    enum v4l2_buf_type type,
-		    enum v4l2_field field,
-		    unsigned int msize)
+void videobuf_queue_init(struct videobuf_queue* q,
+			 struct videobuf_queue_ops *ops,
+			 struct pci_dev *pci,
+			 spinlock_t *irqlock,
+			 enum v4l2_buf_type type,
+			 enum v4l2_field field,
+			 unsigned int msize,
+			 void *priv)
 {
 	memset(q,0,sizeof(*q));
-
 	q->irqlock = irqlock;
 	q->pci     = pci;
 	q->type    = type;
 	q->field   = field;
 	q->msize   = msize;
 	q->ops     = ops;
+	q->priv_data = priv;
 
 	init_MUTEX(&q->lock);
 	INIT_LIST_HEAD(&q->stream);
 }
 
-int 
+int
 videobuf_queue_is_busy(struct videobuf_queue *q)
 {
 	int i;
-	
+
 	if (q->streaming) {
 		dprintk(1,"busy: streaming active\n");
 		return 1;
@@ -418,7 +420,7 @@
 }
 
 void
-videobuf_queue_cancel(struct file *file, struct videobuf_queue *q)
+videobuf_queue_cancel(struct videobuf_queue *q)
 {
 	unsigned long flags;
 	int i;
@@ -439,7 +441,7 @@
 	for (i = 0; i < VIDEO_MAX_FRAME; i++) {
 		if (NULL == q->bufs[i])
 			continue;
-		q->ops->buf_release(file,q->bufs[i]);
+		q->ops->buf_release(q,q->bufs[i]);
 	}
 	INIT_LIST_HEAD(&q->stream);
 }
@@ -521,7 +523,7 @@
 }
 
 int
-videobuf_reqbufs(struct file *file, struct videobuf_queue *q,
+videobuf_reqbufs(struct videobuf_queue *q,
 		 struct v4l2_requestbuffers *req)
 {
 	unsigned int size,count;
@@ -546,12 +548,12 @@
 	if (count > VIDEO_MAX_FRAME)
 		count = VIDEO_MAX_FRAME;
 	size = 0;
-	q->ops->buf_setup(file,&count,&size);
+	q->ops->buf_setup(q,&count,&size);
 	size = PAGE_ALIGN(size);
 	dprintk(1,"reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
 		count, size, (count*size)>>PAGE_SHIFT);
 
-	retval = videobuf_mmap_setup(file,q,count,size,req->memory);
+	retval = videobuf_mmap_setup(q,count,size,req->memory);
 	if (retval < 0)
 		goto done;
 
@@ -576,7 +578,7 @@
 }
 
 int
-videobuf_qbuf(struct file *file, struct videobuf_queue *q,
+videobuf_qbuf(struct videobuf_queue *q,
 	      struct v4l2_buffer *b)
 {
 	struct videobuf_buffer *buf;
@@ -620,7 +622,7 @@
 		if (b->length < buf->bsize)
 			goto done;
 		if (STATE_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr)
-			q->ops->buf_release(file,buf);
+			q->ops->buf_release(q,buf);
 		buf->baddr = b->m.userptr;
 		break;
 	case V4L2_MEMORY_OVERLAY:
@@ -631,30 +633,30 @@
 	}
 
 	field = videobuf_next_field(q);
-	retval = q->ops->buf_prepare(file,buf,field);
+	retval = q->ops->buf_prepare(q,buf,field);
 	if (0 != retval)
 		goto done;
-	
+
 	list_add_tail(&buf->stream,&q->stream);
 	if (q->streaming) {
 		spin_lock_irqsave(q->irqlock,flags);
-		q->ops->buf_queue(file,buf);
+		q->ops->buf_queue(q,buf);
 		spin_unlock_irqrestore(q->irqlock,flags);
 	}
 	retval = 0;
-	
+
  done:
 	up(&q->lock);
 	return retval;
 }
 
 int
-videobuf_dqbuf(struct file *file, struct videobuf_queue *q,
-	       struct v4l2_buffer *b)
+videobuf_dqbuf(struct videobuf_queue *q,
+	       struct v4l2_buffer *b, int nonblocking)
 {
 	struct videobuf_buffer *buf;
 	int retval;
-	
+
 	down(&q->lock);
 	retval = -EBUSY;
 	if (q->reading)
@@ -665,7 +667,7 @@
 	if (list_empty(&q->stream))
 		goto done;
 	buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
-	retval = videobuf_waiton(buf, file->f_flags & O_NONBLOCK, 1);
+	retval = videobuf_waiton(buf, nonblocking, 1);
 	if (retval < 0)
 		goto done;
 	switch (buf->state) {
@@ -689,13 +691,13 @@
 	return retval;
 }
 
-int videobuf_streamon(struct file *file, struct videobuf_queue *q)
+int videobuf_streamon(struct videobuf_queue *q)
 {
 	struct videobuf_buffer *buf;
 	struct list_head *list;
 	unsigned long flags;
 	int retval;
-	
+
 	down(&q->lock);
 	retval = -EBUSY;
 	if (q->reading)
@@ -708,7 +710,7 @@
 	list_for_each(list,&q->stream) {
 		buf = list_entry(list, struct videobuf_buffer, stream);
 		if (buf->state == STATE_PREPARED)
-			q->ops->buf_queue(file,buf);
+			q->ops->buf_queue(q,buf);
 	}
 	spin_unlock_irqrestore(q->irqlock,flags);
 
@@ -717,14 +719,14 @@
 	return retval;
 }
 
-int videobuf_streamoff(struct file *file, struct videobuf_queue *q)
+int videobuf_streamoff(struct videobuf_queue *q)
 {
 	int retval = -EINVAL;
 
 	down(&q->lock);
 	if (!q->streaming)
 		goto done;
-	videobuf_queue_cancel(file,q);
+	videobuf_queue_cancel(q);
 	q->streaming = 0;
 	retval = 0;
 
@@ -734,8 +736,8 @@
 }
 
 static ssize_t
-videobuf_read_zerocopy(struct file *file, struct videobuf_queue *q,
-		       char __user *data, size_t count, loff_t *ppos)
+videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
+		       size_t count, loff_t *ppos)
 {
 	enum v4l2_field field;
 	unsigned long flags;
@@ -751,13 +753,13 @@
 	q->read_buf->baddr  = (unsigned long)data;
         q->read_buf->bsize  = count;
 	field = videobuf_next_field(q);
-	retval = q->ops->buf_prepare(file,q->read_buf,field);
+	retval = q->ops->buf_prepare(q,q->read_buf,field);
 	if (0 != retval)
 		goto done;
-	
+
         /* start capture & wait */
 	spin_lock_irqsave(q->irqlock,flags);
-	q->ops->buf_queue(file,q->read_buf);
+	q->ops->buf_queue(q,q->read_buf);
 	spin_unlock_irqrestore(q->irqlock,flags);
         retval = videobuf_waiton(q->read_buf,0,0);
         if (0 == retval) {
@@ -770,14 +772,15 @@
 
  done:
 	/* cleanup */
-	q->ops->buf_release(file,q->read_buf);
+	q->ops->buf_release(q,q->read_buf);
 	kfree(q->read_buf);
 	q->read_buf = NULL;
 	return retval;
 }
 
-ssize_t videobuf_read_one(struct file *file, struct videobuf_queue *q,
-			  char __user *data, size_t count, loff_t *ppos)
+ssize_t videobuf_read_one(struct videobuf_queue *q,
+			  char __user *data, size_t count, loff_t *ppos,
+			  int nonblocking)
 {
 	enum v4l2_field field;
 	unsigned long flags;
@@ -787,11 +790,11 @@
 	down(&q->lock);
 
 	nbufs = 1; size = 0;
-	q->ops->buf_setup(file,&nbufs,&size);
+	q->ops->buf_setup(q,&nbufs,&size);
 	if (NULL == q->read_buf  &&
 	    count >= size        &&
-	    !(file->f_flags & O_NONBLOCK)) {
-		retval = videobuf_read_zerocopy(file,q,data,count,ppos);
+	    !nonblocking) {
+		retval = videobuf_read_zerocopy(q,data,count,ppos);
 		if (retval >= 0  ||  retval == -EIO)
 			/* ok, all done */
 			goto done;
@@ -806,24 +809,24 @@
 			goto done;
 		q->read_buf->memory = V4L2_MEMORY_USERPTR;
 		field = videobuf_next_field(q);
-		retval = q->ops->buf_prepare(file,q->read_buf,field);
+		retval = q->ops->buf_prepare(q,q->read_buf,field);
 		if (0 != retval)
 			goto done;
 		spin_lock_irqsave(q->irqlock,flags);
-		q->ops->buf_queue(file,q->read_buf);
+		q->ops->buf_queue(q,q->read_buf);
 		spin_unlock_irqrestore(q->irqlock,flags);
 		q->read_off = 0;
 	}
 
 	/* wait until capture is done */
-        retval = videobuf_waiton(q->read_buf, file->f_flags & O_NONBLOCK, 1);
+        retval = videobuf_waiton(q->read_buf, nonblocking, 1);
 	if (0 != retval)
 		goto done;
 	videobuf_dma_pci_sync(q->pci,&q->read_buf->dma);
 
 	if (STATE_ERROR == q->read_buf->state) {
 		/* catch I/O errors */
-		q->ops->buf_release(file,q->read_buf);
+		q->ops->buf_release(q,q->read_buf);
 		kfree(q->read_buf);
 		q->read_buf = NULL;
 		retval = -EIO;
@@ -842,7 +845,7 @@
 	q->read_off += bytes;
 	if (q->read_off == q->read_buf->size) {
 		/* all data copied, cleanup */
-		q->ops->buf_release(file,q->read_buf);
+		q->ops->buf_release(q,q->read_buf);
 		kfree(q->read_buf);
 		q->read_buf = NULL;
 	}
@@ -852,43 +855,43 @@
 	return retval;
 }
 
-int videobuf_read_start(struct file *file, struct videobuf_queue *q)
+int videobuf_read_start(struct videobuf_queue *q)
 {
 	enum v4l2_field field;
 	unsigned long flags;
 	int count = 0, size = 0;
 	int err, i;
 
-	q->ops->buf_setup(file,&count,&size);
+	q->ops->buf_setup(q,&count,&size);
 	if (count < 2)
 		count = 2;
 	if (count > VIDEO_MAX_FRAME)
 		count = VIDEO_MAX_FRAME;
 	size = PAGE_ALIGN(size);
 
-	err = videobuf_mmap_setup(file, q, count, size, V4L2_MEMORY_USERPTR);
+	err = videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR);
 	if (err)
 		return err;
 	for (i = 0; i < count; i++) {
 		field = videobuf_next_field(q);
-		err = q->ops->buf_prepare(file,q->bufs[i],field);
+		err = q->ops->buf_prepare(q,q->bufs[i],field);
 		if (err)
 			return err;
 		list_add_tail(&q->bufs[i]->stream, &q->stream);
 	}
 	spin_lock_irqsave(q->irqlock,flags);
 	for (i = 0; i < count; i++)
-		q->ops->buf_queue(file,q->bufs[i]);
+		q->ops->buf_queue(q,q->bufs[i]);
 	spin_unlock_irqrestore(q->irqlock,flags);
 	q->reading = 1;
 	return 0;
 }
 
-void videobuf_read_stop(struct file *file, struct videobuf_queue *q)
+void videobuf_read_stop(struct videobuf_queue *q)
 {
 	int i;
-	
-	videobuf_queue_cancel(file,q);
+
+	videobuf_queue_cancel(q);
 	INIT_LIST_HEAD(&q->stream);
 	for (i = 0; i < VIDEO_MAX_FRAME; i++) {
 		if (NULL == q->bufs[i])
@@ -900,20 +903,21 @@
 	q->reading  = 0;
 }
 
-ssize_t videobuf_read_stream(struct file *file, struct videobuf_queue *q,
+ssize_t videobuf_read_stream(struct videobuf_queue *q,
 			     char __user *data, size_t count, loff_t *ppos,
-			     int vbihack)
+			     int vbihack, int nonblocking)
 {
 	unsigned int *fc, bytes;
 	int err, retval;
 	unsigned long flags;
-	
+
+	dprintk(2,"%s\n",__FUNCTION__);
 	down(&q->lock);
 	retval = -EBUSY;
 	if (q->streaming)
 		goto done;
 	if (!q->reading) {
-		retval = videobuf_read_start(file,q);
+		retval = videobuf_read_start(q);
 		if (retval < 0)
 			goto done;
 	}
@@ -928,8 +932,7 @@
 			list_del(&q->read_buf->stream);
 			q->read_off = 0;
 		}
-		err = videobuf_waiton(q->read_buf,
-				      file->f_flags & O_NONBLOCK,1);
+		err = videobuf_waiton(q->read_buf, nonblocking, 1);
 		if (err < 0) {
 			if (0 == retval)
 				retval = err;
@@ -947,7 +950,7 @@
 				*fc = q->read_buf->field_count >> 1;
 				dprintk(1,"vbihack: %d\n",*fc);
 			}
-			
+
 			/* copy stuff */
 			bytes = count;
 			if (bytes > q->read_buf->size - q->read_off)
@@ -974,7 +977,7 @@
 			list_add_tail(&q->read_buf->stream,
 				      &q->stream);
 			spin_lock_irqsave(q->irqlock,flags);
-			q->ops->buf_queue(file,q->read_buf);
+			q->ops->buf_queue(q,q->read_buf);
 			spin_unlock_irqrestore(q->irqlock,flags);
 			q->read_buf = NULL;
 		}
@@ -1001,7 +1004,7 @@
 					 struct videobuf_buffer, stream);
 	} else {
 		if (!q->reading)
-			videobuf_read_start(file,q);
+			videobuf_read_start(q);
 		if (!q->reading) {
 			rc = POLLERR;
 		} else if (NULL == q->read_buf) {
@@ -1042,29 +1045,30 @@
 videobuf_vm_close(struct vm_area_struct *vma)
 {
 	struct videobuf_mapping *map = vma->vm_private_data;
+	struct videobuf_queue *q = map->q;
 	int i;
 
 	dprintk(2,"vm_close %p [count=%d,vma=%08lx-%08lx]\n",map,
 		map->count,vma->vm_start,vma->vm_end);
 
-	/* down(&fh->lock); FIXME */
 	map->count--;
 	if (0 == map->count) {
-		dprintk(1,"munmap %p\n",map);
+		dprintk(1,"munmap %p q=%p\n",map,q);
+		down(&q->lock);
 		for (i = 0; i < VIDEO_MAX_FRAME; i++) {
-			if (NULL == map->q->bufs[i])
+			if (NULL == q->bufs[i])
 				continue;
-			if (map->q->bufs[i])
+			if (q->bufs[i])
 				;
-			if (map->q->bufs[i]->map != map)
+			if (q->bufs[i]->map != map)
 				continue;
-			map->q->bufs[i]->map   = NULL;
-			map->q->bufs[i]->baddr = 0;
-			map->q->ops->buf_release(vma->vm_file,map->q->bufs[i]);
+			q->bufs[i]->map   = NULL;
+			q->bufs[i]->baddr = 0;
+			q->ops->buf_release(q,q->bufs[i]);
 		}
+		up(&q->lock);
 		kfree(map);
 	}
-	/* up(&fh->lock); FIXME */
 	return;
 }
 
@@ -1100,14 +1104,14 @@
 	.nopage   = videobuf_vm_nopage,
 };
 
-int videobuf_mmap_setup(struct file *file, struct videobuf_queue *q,
+int videobuf_mmap_setup(struct videobuf_queue *q,
 			unsigned int bcount, unsigned int bsize,
 			enum v4l2_memory memory)
 {
 	unsigned int i;
 	int err;
 
-	err = videobuf_mmap_free(file,q);
+	err = videobuf_mmap_free(q);
 	if (0 != err)
 		return err;
 
@@ -1132,7 +1136,7 @@
 	return 0;
 }
 
-int videobuf_mmap_free(struct file *file, struct videobuf_queue *q)
+int videobuf_mmap_free(struct videobuf_queue *q)
 {
 	int i;
 
@@ -1142,15 +1146,15 @@
 	for (i = 0; i < VIDEO_MAX_FRAME; i++) {
 		if (NULL == q->bufs[i])
 			continue;
-		q->ops->buf_release(file,q->bufs[i]);
+		q->ops->buf_release(q,q->bufs[i]);
 		kfree(q->bufs[i]);
 		q->bufs[i] = NULL;
 	}
 	return 0;
 }
 
-int videobuf_mmap_mapper(struct vm_area_struct *vma,
-			 struct videobuf_queue *q)
+int videobuf_mmap_mapper(struct videobuf_queue *q,
+			 struct vm_area_struct *vma)
 {
 	struct videobuf_mapping *map;
 	unsigned int first,last,size,i;
@@ -1219,8 +1223,8 @@
 	vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED;
 	vma->vm_flags &= ~VM_IO; /* using shared anonymous pages */
 	vma->vm_private_data = map;
-	dprintk(1,"mmap %p: %08lx-%08lx pgoff %08lx bufs %d-%d\n",
-		map,vma->vm_start,vma->vm_end,vma->vm_pgoff,first,last);
+	dprintk(1,"mmap %p: q=%p %08lx-%08lx pgoff %08lx bufs %d-%d\n",
+		map,q,vma->vm_start,vma->vm_end,vma->vm_pgoff,first,last);
 	retval = 0;
 
  done:
diff -Nru a/drivers/media/video/videocodec.c b/drivers/media/video/videocodec.c
--- a/drivers/media/video/videocodec.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/media/video/videocodec.c	2004-12-24 13:36:56 -08:00
@@ -43,11 +43,6 @@
 #include <asm/uaccess.h>
 #endif
 
-#include <linux/version.h>
-#ifndef KERNEL_VERSION
-#define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c))
-#endif
-
 #include "videocodec.h"
 
 static int debug = 0;
diff -Nru a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
--- a/drivers/media/video/zoran.h	2004-12-24 13:37:03 -08:00
+++ b/drivers/media/video/zoran.h	2004-12-24 13:37:03 -08:00
@@ -407,7 +407,7 @@
 	struct pci_dev *pci_dev;	/* PCI device */
 	unsigned char revision;	/* revision of zr36057 */
 	unsigned int zr36057_adr;	/* bus address of IO mem returned by PCI BIOS */
-	unsigned char *zr36057_mem;	/* pointer to mapped IO memory */
+	unsigned char __iomem *zr36057_mem;/* pointer to mapped IO memory */
 
 	spinlock_t spinlock;	/* Spinlock */
 
@@ -499,10 +499,10 @@
   of _ALPHA_BUZ in the Makefile.*/
 
 #ifdef _ALPHA_BUZ
-#define btwrite(dat,adr)    writel((dat),(char *) (zr->zr36057_adr+(adr)))
+#define btwrite(dat,adr)    writel((dat), zr->zr36057_adr+(adr))
 #define btread(adr)         readl(zr->zr36057_adr+(adr))
 #else
-#define btwrite(dat,adr)    writel((dat), (char *) (zr->zr36057_mem+(adr)))
+#define btwrite(dat,adr)    writel((dat), zr->zr36057_mem+(adr))
 #define btread(adr)         readl(zr->zr36057_mem+(adr))
 #endif
 
diff -Nru a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
--- a/drivers/media/video/zoran_driver.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/media/video/zoran_driver.c	2004-12-24 13:37:04 -08:00
@@ -265,7 +265,7 @@
  * if more than one driver at a time has the idea to use this memory!!!!
  */
 
-	volatile unsigned char *mem;
+	volatile unsigned char __iomem *mem;
 	unsigned char c;
 	unsigned long hi_mem_ph;
 	unsigned long i;
@@ -285,21 +285,21 @@
 	for (i = 0; i < size; i++) {
 		/* Check if it is memory */
 		c = i & 0xff;
-		mem[i] = c;
-		if (mem[i] != c)
+		writeb(c, mem + i);
+		if (readb(mem + i) != c)
 			break;
 		c = 255 - c;
-		mem[i] = c;
-		if (mem[i] != c)
+		writeb(c, mem + i);
+		if (readb(mem + i) != c)
 			break;
-		mem[i] = 0;	/* zero out memory */
+		writeb(0, mem + i);	/* zero out memory */
 
 		/* give the kernel air to breath */
 		if ((i & 0x3ffff) == 0x3ffff)
 			schedule();
 	}
 
-	iounmap((void *) mem);
+	iounmap(mem);
 
 	if (i != size) {
 		dprintk(1,
@@ -1917,8 +1917,7 @@
 		decoder_command(zr, DECODER_SET_NORM, &norm);
 
 		/* let changes come into effect */
-		current->state = TASK_UNINTERRUPTIBLE;
-		schedule_timeout(2 * HZ);
+		ssleep(2);
 
 		decoder_command(zr, DECODER_GET_STATUS, &status);
 		if (!(status & DECODER_STATUS_GOOD)) {
@@ -2639,8 +2638,7 @@
 		decoder_command(zr, DECODER_SET_NORM, &norm);
 
 		/* sleep 1 second */
-		current->state = TASK_UNINTERRUPTIBLE;
-		schedule_timeout(1 * HZ);
+		ssleep(1);
 
 		/* Get status of video decoder */
 		decoder_command(zr, DECODER_GET_STATUS, &status);
@@ -4450,12 +4448,6 @@
 	.close = zoran_vm_close,
 };
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-#define zr_remap_page_range(a,b,c,d,e) remap_page_range(b,c,d,e)
-#else
-#define zr_remap_page_range(a,b,c,d,e) remap_page_range(a,b,c,d,e)
-#endif
-
 static int
 zoran_mmap (struct file           *file,
 	    struct vm_area_struct *vma)
@@ -4555,12 +4547,14 @@
 				pos =
 				    (unsigned long) fh->jpg_buffers.
 				    buffer[i].frag_tab[2 * j];
-				page = virt_to_phys(bus_to_virt(pos));	/* should just be pos on i386 */
-				if (zr_remap_page_range
-				    (vma, start, page, todo, PAGE_SHARED)) {
+				/* should just be pos on i386 */
+				page = virt_to_phys(bus_to_virt(pos))
+								>> PAGE_SHIFT;
+				if (remap_pfn_range(vma, start, page,
+							todo, PAGE_SHARED)) {
 					dprintk(1,
 						KERN_ERR
-						"%s: zoran_mmap(V4L) - remap_page_range failed\n",
+						"%s: zoran_mmap(V4L) - remap_pfn_range failed\n",
 						ZR_DEVNAME(zr));
 					res = -EAGAIN;
 					goto jpg_mmap_unlock_and_return;
@@ -4641,11 +4635,11 @@
 			if (todo > fh->v4l_buffers.buffer_size)
 				todo = fh->v4l_buffers.buffer_size;
 			page = fh->v4l_buffers.buffer[i].fbuffer_phys;
-			if (zr_remap_page_range
-			    (vma, start, page, todo, PAGE_SHARED)) {
+			if (remap_pfn_range(vma, start, page >> PAGE_SHIFT,
+							todo, PAGE_SHARED)) {
 				dprintk(1,
 					KERN_ERR
-					"%s: zoran_mmap(V4L)i - remap_page_range failed\n",
+					"%s: zoran_mmap(V4L)i - remap_pfn_range failed\n",
 					ZR_DEVNAME(zr));
 				res = -EAGAIN;
 				goto v4l_mmap_unlock_and_return;
diff -Nru a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c
--- a/drivers/media/video/zr36120.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/media/video/zr36120.c	2004-12-24 13:36:49 -08:00
@@ -145,14 +145,11 @@
 static
 void __init handle_chipset(void)
 {
-	struct pci_dev *dev = NULL;
-
 	/* Just in case some nut set this to something dangerous */
 	if (triton1)
 		triton1 = ZORAN_VDC_TRICOM;
 
-	while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437, dev)))
-	{
+	if (pci_pci_problems & PCIPCI_TRITON) {
 		printk(KERN_INFO "zoran: Host bridge 82437FX Triton PIIX\n");
 		triton1 = ZORAN_VDC_TRICOM;
 	}
@@ -819,8 +816,7 @@
          *      be sure its safe to free the buffer. We wait 5-6 fields
          *      which is more than sufficient to be sure.
          */
-        current->state = TASK_UNINTERRUPTIBLE;
-        schedule_timeout(HZ/10);        /* Wait 1/10th of a second */
+        msleep(100);			/* Wait 1/10th of a second */
 
 	/* free the allocated framebuffer */
 	if (ztv->fbuffer)
@@ -1475,8 +1471,8 @@
 	/* start mapping the whole shabang to user memory */
 	pos = (unsigned long)ztv->fbuffer;
 	while (size>0) {
-		unsigned long page = virt_to_phys((void*)pos);
-		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
+		unsigned long pfn = virt_to_phys((void*)pos) >> PAGE_SHIFT;
+		if (remap_pfn_range(vma, start, pfn, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 		start += PAGE_SIZE;
 		pos += PAGE_SIZE;
@@ -1568,8 +1564,7 @@
          *      be sure its safe to free the buffer. We wait 5-6 fields
          *      which is more than sufficient to be sure.
          */
-        current->state = TASK_UNINTERRUPTIBLE;
-        schedule_timeout(HZ/10);        /* Wait 1/10th of a second */
+        msleep(100);			/* Wait 1/10th of a second */
 
 	for (item=ztv->readinfo; item!=ztv->readinfo+ZORAN_VBI_BUFFERS; item++)
 	{
diff -Nru a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig
--- a/drivers/message/fusion/Kconfig	2004-12-24 13:37:44 -08:00
+++ b/drivers/message/fusion/Kconfig	2004-12-24 13:37:44 -08:00
@@ -29,7 +29,7 @@
 
 config FUSION_CTL
 	tristate "Fusion MPT misc device (ioctl) driver"
-	depends on MODULES && FUSION && m
+	depends on FUSION
 	---help---
 	  The Fusion MPT misc device driver provides specialized control
 	  of MPT adapters via system ioctl calls.  Use of ioctl calls to
diff -Nru a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
--- a/drivers/message/fusion/mptbase.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/message/fusion/mptbase.c	2004-12-24 13:37:43 -08:00
@@ -137,8 +137,6 @@
 
 struct proc_dir_entry *mpt_proc_root_dir;
 
-DmpServices_t *DmpService;
-
 #define WHOINIT_UNKNOWN		0xAA
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -157,7 +155,6 @@
 static MPT_RESETHANDLER		 MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS];
 static struct mpt_pci_driver 	*MptDeviceDriverHandlers[MPT_MAX_PROTOCOL_DRIVERS];
 
-static int	FusionInitCalled = 0;
 static int	mpt_base_index = -1;
 static int	last_drv_idx = -1;
 
@@ -169,7 +166,9 @@
  */
 static irqreturn_t mpt_interrupt(int irq, void *bus_id, struct pt_regs *r);
 static int	mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply);
-
+static int	mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes,
+			u32 *req, int replyBytes, u16 *u16reply, int maxwait,
+			int sleepFlag);
 static int	mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag);
 static void	mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev);
 static void	mpt_adapter_disable(MPT_ADAPTER *ioc);
@@ -337,15 +336,13 @@
 			ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus);
 			if (ioc_stat & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) {
 				u32	 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo);
-				if ((int)ioc->chip_type <= (int)FC929)
+				if (ioc->bus_type == FC)
 					mpt_fc_log_info(ioc, log_info);
-				else
+				else if (ioc->bus_type == SCSI)
 					mpt_sp_log_info(ioc, log_info);
 			}
 			if (ioc_stat & MPI_IOCSTATUS_MASK) {
-				if ((int)ioc->chip_type <= (int)FC929)
-						;
-				else
+				if (ioc->bus_type == SCSI)
 					mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf);
 			}
 		} else {
@@ -392,7 +389,7 @@
 		}
 
 #ifdef MPT_DEBUG_IRQ
-		if ((int)ioc->chip_type > (int)FC929) {
+		if (ioc->bus_type == SCSI) {
 			/* Verify mf, mr are reasonable.
 			 */
 			if ((mf) && ((mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))
@@ -437,7 +434,7 @@
 
 			/*  Put Request back on FreeQ!  */
 			spin_lock_irqsave(&ioc->FreeQlock, flags);
-			Q_ADD_TAIL(&ioc->FreeQ, &mf->u.frame.linkage, MPT_FRAME_HDR);
+			list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ);
 #ifdef MFCNT
 			ioc->mfcnt--;
 #endif
@@ -533,7 +530,7 @@
 			del_timer(&pCfg->timer);
 
 			spin_lock_irqsave(&ioc->FreeQlock, flags);
-			Q_DEL_ITEM(&pCfg->linkage);
+			list_del(&pCfg->linkage);
 			spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 
 			/*
@@ -603,22 +600,6 @@
 
 	last_drv_idx = -1;
 
-#ifndef MODULE
-	/*
-	 *  Handle possibility of the mptscsih_detect() routine getting
-	 *  called *before* fusion_init!
-	 */
-	if (!FusionInitCalled) {
-		dprintk((KERN_INFO MYNAM ": Hmmm, calling fusion_init from mpt_register!\n"));
-		/*
-		 *  NOTE! We'll get recursion here, as fusion_init()
-		 *  calls mpt_register()!
-		 */
-		fusion_init();
-		FusionInitCalled++;
-	}
-#endif
-
 	/*
 	 *  Search for empty callback slot in this order: {N,...,7,6,5,...,1}
 	 *  (slot/handle 0 is reserved!)
@@ -819,11 +800,12 @@
 		return NULL;
 
 	spin_lock_irqsave(&ioc->FreeQlock, flags);
-	if (! Q_IS_EMPTY(&ioc->FreeQ)) {
+	if (!list_empty(&ioc->FreeQ)) {
 		int req_offset;
 
-		mf = ioc->FreeQ.head;
-		Q_DEL_ITEM(&mf->u.frame.linkage);
+		mf = list_entry(ioc->FreeQ.next, MPT_FRAME_HDR,
+				u.frame.linkage.list);
+		list_del(&mf->u.frame.linkage.list);
 		mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle;	/* byte */
 		req_offset = (u8 *)mf - (u8 *)ioc->req_frames;
 								/* u16! */
@@ -919,7 +901,7 @@
 
 	/*  Put Request back on FreeQ!  */
 	spin_lock_irqsave(&ioc->FreeQlock, flags);
-	Q_ADD_TAIL(&ioc->FreeQ, &mf->u.frame.linkage, MPT_FRAME_HDR);
+	list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ);
 #ifdef MFCNT
 	ioc->mfcnt--;
 #endif
@@ -957,41 +939,6 @@
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *	mpt_add_chain - Place a chain SGE at address pAddr.
- *	@pAddr: virtual address for SGE
- *	@next: nextChainOffset value (u32's)
- *	@length: length of next SGL segment
- *	@dma_addr: Physical address
- *
- *	This routine places a MPT request frame back on the MPT adapter's
- *	FreeQ.
- */
-void
-mpt_add_chain(char *pAddr, u8 next, u16 length, dma_addr_t dma_addr)
-{
-	if (sizeof(dma_addr_t) == sizeof(u64)) {
-		SGEChain64_t *pChain = (SGEChain64_t *) pAddr;
-		u32 tmp = dma_addr & 0xFFFFFFFF;
-
-		pChain->Length = cpu_to_le16(length);
-		pChain->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT | mpt_addr_size();
-
-		pChain->NextChainOffset = next;
-
-		pChain->Address.Low = cpu_to_le32(tmp);
-		tmp = (u32) ((u64)dma_addr >> 32);
-		pChain->Address.High = cpu_to_le32(tmp);
-	} else {
-		SGEChain32_t *pChain = (SGEChain32_t *) pAddr;
-		pChain->Length = cpu_to_le16(length);
-		pChain->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT | mpt_addr_size();
-		pChain->NextChainOffset = next;
-		pChain->Address = cpu_to_le32(dma_addr);
-	}
-}
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/**
  *	mpt_send_handshake_request - Send MPT request via doorbell
  *	handshake method.
  *	@handle: Handle of registered MPT protocol driver
@@ -1130,7 +1077,7 @@
 mptbase_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	MPT_ADAPTER	*ioc;
-	u8		*mem;
+	u8		__iomem *mem;
 	unsigned long	 mem_phys;
 	unsigned long	 port;
 	u32		 msize;
@@ -1198,7 +1145,7 @@
 
 	/* Initialize the running configQ head.
 	 */
-	Q_INIT(&ioc->configQ, Q_ITEM);
+	INIT_LIST_HEAD(&ioc->configQ);
 
 	/* Find lookup slot. */
 	INIT_LIST_HEAD(&ioc->list);
@@ -1245,31 +1192,30 @@
 			&ioc->facts, &ioc->pfacts[0]));
 
 	ioc->mem_phys = mem_phys;
-	ioc->chip = (SYSIF_REGS*)mem;
+	ioc->chip = (SYSIF_REGS __iomem *)mem;
 
 	/* Save Port IO values in case we need to do downloadboot */
 	{
 		u8 *pmem = (u8*)port;
 		ioc->pio_mem_phys = port;
-		ioc->pio_chip = (SYSIF_REGS*)pmem;
+		ioc->pio_chip = (SYSIF_REGS __iomem *)pmem;
 	}
 
-	ioc->chip_type = FCUNK;
 	if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC909) {
-		ioc->chip_type = FC909;
 		ioc->prod_name = "LSIFC909";
+		ioc->bus_type = FC;
 	}
 	if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC929) {
-		ioc->chip_type = FC929;
 		ioc->prod_name = "LSIFC929";
+		ioc->bus_type = FC;
 	}
 	else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC919) {
-		ioc->chip_type = FC919;
 		ioc->prod_name = "LSIFC919";
+		ioc->bus_type = FC;
 	}
 	else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC929X) {
-		ioc->chip_type = FC929X;
 		pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
+		ioc->bus_type = FC;
 		if (revision < XL_929) {
 			ioc->prod_name = "LSIFC929X";
 			/* 929X Chip Fix. Set Split transactions level
@@ -1288,8 +1234,8 @@
 		}
 	}
 	else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC919X) {
-		ioc->chip_type = FC919X;
 		ioc->prod_name = "LSIFC919X";
+		ioc->bus_type = FC;
 		/* 919X Chip Fix. Set Split transactions level
 		 * for PCIX. Set MOST bits to zero.
 		 */
@@ -1298,8 +1244,8 @@
 		pci_write_config_byte(pdev, 0x6a, pcixcmd);
 	}
 	else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) {
-		ioc->chip_type = C1030;
 		ioc->prod_name = "LSI53C1030";
+		ioc->bus_type = SCSI;
 		/* 1030 Chip Fix. Disable Split transactions
 		 * for PCIX. Set MOST bits to zero if Rev < C0( = 8).
 		 */
@@ -1311,8 +1257,8 @@
 		}
 	}
 	else if (pdev->device == MPI_MANUFACTPAGE_DEVID_1030_53C1035) {
-		ioc->chip_type = C1035;
 		ioc->prod_name = "LSI53C1035";
+		ioc->bus_type = SCSI;
 	}
 
 	sprintf(ioc->name, "ioc%d", ioc->id);
@@ -1360,9 +1306,7 @@
 	/* NEW!  20010220 -sralston
 	 * Check for "bound ports" (929, 929X, 1030, 1035) to reduce redundant resets.
 	 */
-	if ((ioc->chip_type == FC929) || (ioc->chip_type == C1030)
-			|| (ioc->chip_type == C1035) || (ioc->chip_type == FC929X))
-		mpt_detect_bound_ports(ioc, pdev);
+	mpt_detect_bound_ports(ioc, pdev);
 
 	if ((r = mpt_do_ioc_recovery(ioc,
 	  MPT_HOSTEVENT_IOC_BRINGUP, CAN_SLEEP)) != 0) {
@@ -1517,7 +1461,7 @@
 		}
 	}
 
-	pci_save_state(pdev, ioc->PciState);
+	pci_save_state(pdev);
 
 	/* put ioc into READY_STATE */
 	if(SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) {
@@ -1557,7 +1501,7 @@
 		ioc->name, pdev, pci_name(pdev), device_state);
 
 	pci_set_power_state(pdev, 0);
-	pci_restore_state(pdev, ioc->PciState);
+	pci_restore_state(pdev);
 	pci_enable_device(pdev);
 
 	/* enable interrupts */
@@ -1794,7 +1738,7 @@
 	 *	and we try GetLanConfigPages again...
 	 */
 	if ((ret == 0) && (reason == MPT_HOSTEVENT_IOC_BRINGUP)) {
-		if ((int)ioc->chip_type <= (int)FC929) {
+		if (ioc->bus_type == FC) {
 			/*
 			 *  Pre-fetch FC port WWN and stuff...
 			 *  (FCPortPage0_t stuff)
@@ -2034,7 +1978,7 @@
 		}
 
 		if (ioc->memmap != NULL)
-			iounmap((u8 *) ioc->memmap);
+			iounmap(ioc->memmap);
 
 #if defined(CONFIG_MTRR) && 0
 		if (ioc->mtrr_reg > 0) {
@@ -2137,20 +2081,8 @@
 	}
 
 	/* Is it already READY? */
-	if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) {
-		if ((int)ioc->chip_type <= (int)FC929)
-			return 0;
-		else {
-			return 0;
-			/* Workaround from broken 1030 FW.
-			 * Force a diagnostic reset if fails.
-			 */
-/*			if ((r = SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) == 0)
-				return 0;
-			else
-				statefault = 4; */
-		}
-	}
+	if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) 
+		return 0;
 
 	/*
 	 *	Check to see if IOC is in FAULT state.
@@ -2229,8 +2161,7 @@
 		}
 
 		if (sleepFlag == CAN_SLEEP) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1 * HZ / 1000);
+			msleep_interruptible(1);
 		} else {
 			mdelay (1);	/* 1 msec delay */
 		}
@@ -2548,11 +2479,11 @@
 	ddlprintk((MYIOC_s_INFO_FMT "upload_fw %d facts.Flags=%x\n",
 		   ioc->name, ioc->upload_fw, ioc->facts.Flags));
 
-	if ((int)ioc->chip_type <= (int)FC929) {
+	if (ioc->bus_type == FC)
 		ioc_init.MaxDevices = MPT_MAX_FC_DEVICES;
-	} else {
+	else
 		ioc_init.MaxDevices = MPT_MAX_SCSI_DEVICES;
-	}
+	
 	ioc_init.MaxBuses = MPT_MAX_BUS;
 
 	ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz);	/* in BYTES */
@@ -2599,8 +2530,7 @@
 	state = mpt_GetIocState(ioc, 1);
 	while (state != MPI_IOC_STATE_OPERATIONAL && --cntdn) {
 		if (sleepFlag == CAN_SLEEP) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1 * HZ / 1000);
+			msleep_interruptible(1);
 		} else {
 			mdelay(1);
 		}
@@ -2658,7 +2588,7 @@
 
 	/* RAID FW may take a long time to enable
 	 */
-	if ((int)ioc->chip_type <= (int)FC929) {
+	if (ioc->bus_type == FC) {
 		ii = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable,
 				reply_sz, (u16*)&reply_buf, 65 /*seconds*/, sleepFlag);
 	} else {
@@ -2867,8 +2797,7 @@
 
 	/* wait 1 msec */
 	if (sleepFlag == CAN_SLEEP) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1 * HZ / 1000);
+		msleep_interruptible(1);
 	} else {
 		mdelay (1);
 	}
@@ -2885,8 +2814,7 @@
 		}
 		/* wait 1 sec */
 		if (sleepFlag == CAN_SLEEP) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1000 * HZ / 1000);
+			msleep_interruptible (1000);
 		} else {
 			mdelay (1000);
 		}
@@ -2986,8 +2914,7 @@
 			return 0;
 		}
 		if (sleepFlag == CAN_SLEEP) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(10 * HZ / 1000);
+			msleep_interruptible (10);
 		} else {
 			mdelay (10);
 		}
@@ -3031,15 +2958,14 @@
 	int cnt,cntdn;
 
 	dinitprintk((KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name));
-	if ((int)ioc->chip_type > (int)FC929) {
+	if (ioc->bus_type == SCSI) {
 		/* Always issue a Msg Unit Reset first. This will clear some
 		 * SCSI bus hang conditions.
 		 */
 		SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag);
 
 		if (sleepFlag == CAN_SLEEP) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1000 * HZ / 1000);
+			msleep_interruptible (1000);
 		} else {
 			mdelay (1000);
 		}
@@ -3061,8 +2987,7 @@
 			return hard_reset_done;
 		}
 		if (sleepFlag == CAN_SLEEP) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(10 * HZ / 1000);
+			msleep_interruptible (10);
 		} else {
 			mdelay (10);
 		}
@@ -3133,8 +3058,7 @@
 
 			/* wait 100 msec */
 			if (sleepFlag == CAN_SLEEP) {
-				set_current_state(TASK_INTERRUPTIBLE);
-				schedule_timeout(100 * HZ / 1000);
+				msleep_interruptible (100);
 			} else {
 				mdelay (100);
 			}
@@ -3241,8 +3165,7 @@
 
 				/* wait 1 sec */
 				if (sleepFlag == CAN_SLEEP) {
-					set_current_state(TASK_INTERRUPTIBLE);
-					schedule_timeout(1000 * HZ / 1000);
+					msleep_interruptible (1000);
 				} else {
 					mdelay (1000);
 				}
@@ -3276,8 +3199,7 @@
 
 		/* wait 100 msec */
 		if (sleepFlag == CAN_SLEEP) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(100 * HZ / 1000);
+			msleep_interruptible (100);
 		} else {
 			mdelay (100);
 		}
@@ -3371,8 +3293,7 @@
 		}
 
 		if (sleepFlag == CAN_SLEEP) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1 * HZ / 1000);
+			msleep_interruptible(1);
 		} else {
 			mdelay (1);	/* 1 msec delay */
 		}
@@ -3465,7 +3386,7 @@
 	dinitprintk((KERN_INFO MYNAM ": %s Now numSGE=%d num_sge=%d num_chain=%d\n",
 		ioc->name, numSGE, num_sge, num_chain));
 
-	if ((int) ioc->chip_type > (int) FC929)
+	if (ioc->bus_type == SCSI)
 		num_chain *= MPT_SCSI_CAN_QUEUE;
 	else
 		num_chain *= MPT_FC_CAN_QUEUE;
@@ -3592,14 +3513,14 @@
 		/* Initialize the free chain Q.
 	 	*/
 
-		Q_INIT(&ioc->FreeChainQ, MPT_FRAME_HDR);
+		INIT_LIST_HEAD(&ioc->FreeChainQ);
 
 		/* Post the chain buffers to the FreeChainQ.
 	 	*/
 		mem = (u8 *)ioc->ChainBuffer;
 		for (i=0; i < num_chain; i++) {
 			mf = (MPT_FRAME_HDR *) mem;
-			Q_ADD_TAIL(&ioc->FreeChainQ.head, &mf->u.frame.linkage, MPT_FRAME_HDR);
+			list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeChainQ);
 			mem += ioc->req_sz;
 		}
 
@@ -3609,12 +3530,13 @@
 		mem = (u8 *) ioc->req_frames;
 
 		spin_lock_irqsave(&ioc->FreeQlock, flags);
-		Q_INIT(&ioc->FreeQ, MPT_FRAME_HDR);
+		INIT_LIST_HEAD(&ioc->FreeQ);
 		for (i = 0; i < ioc->req_depth; i++) {
 			mf = (MPT_FRAME_HDR *) mem;
 
 			/*  Queue REQUESTs *internally*!  */
-			Q_ADD_TAIL(&ioc->FreeQ.head, &mf->u.frame.linkage, MPT_FRAME_HDR);
+			list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ);
+
 			mem += ioc->req_sz;
 		}
 		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
@@ -3688,7 +3610,7 @@
  *
  *	Returns 0 for success, non-zero for failure.
  */
-int
+static int
 mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
 				int replyBytes, u16 *u16reply, int maxwait, int sleepFlag)
 {
@@ -3808,8 +3730,7 @@
 			intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
 			if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
 				break;
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1 * HZ / 1000);
+			msleep_interruptible (1);
 			count++;
 		}
 	} else {
@@ -3858,8 +3779,7 @@
 			intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
 			if (intstat & MPI_HIS_DOORBELL_INTERRUPT)
 				break;
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1 * HZ / 1000);
+			msleep_interruptible(1);
 			count++;
 		}
 	} else {
@@ -4903,7 +4823,7 @@
 
 	/* Add to end of Q, set timer and then issue this command */
 	spin_lock_irqsave(&ioc->FreeQlock, flags);
-	Q_ADD_TAIL(&ioc->configQ.head, &pCfg->linkage, Q_ITEM);
+	list_add_tail(&pCfg->linkage, &ioc->configQ);
 	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 
 	add_timer(&pCfg->timer);
@@ -5014,7 +4934,7 @@
 
 	/* Add to end of Q, set timer and then issue this command */
 	spin_lock_irqsave(&ioc->FreeQlock, flags);
-	Q_ADD_TAIL(&ioc->configQ.head, &pCfg->linkage, Q_ITEM);
+	list_add_tail(&pCfg->linkage, &ioc->configQ);
 	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 
 	add_timer(&pCfg->timer);
@@ -5081,13 +5001,8 @@
 		 * the FIFO's are primed.
 		 */
 		spin_lock_irqsave(&ioc->FreeQlock, flags);
-		if (! Q_IS_EMPTY(&ioc->configQ)){
-			pCfg = (CONFIGPARMS *)ioc->configQ.head;
-			do {
-				del_timer(&pCfg->timer);
-				pCfg = (CONFIGPARMS *) (pCfg->linkage.forw);
-			} while (pCfg != (CONFIGPARMS *)&ioc->configQ);
-		}
+		list_for_each_entry(pCfg, &ioc->configQ, linkage)
+			del_timer(&pCfg->timer);
 		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 
 	} else {
@@ -5097,19 +5012,12 @@
 		 * Flush the Q, and wake up all suspended threads.
 		 */
 		spin_lock_irqsave(&ioc->FreeQlock, flags);
-		if (! Q_IS_EMPTY(&ioc->configQ)){
-			pCfg = (CONFIGPARMS *)ioc->configQ.head;
-			do {
-				pNext = (CONFIGPARMS *) pCfg->linkage.forw;
-
-				Q_DEL_ITEM(&pCfg->linkage);
-
-				pCfg->status = MPT_CONFIG_ERROR;
-				pCfg->wait_done = 1;
-				wake_up(&mpt_waitq);
+		list_for_each_entry_safe(pCfg, pNext, &ioc->configQ, linkage) {
+			list_del(&pCfg->linkage);
 
-				pCfg = pNext;
-			} while (pCfg != (CONFIGPARMS *)&ioc->configQ);
+			pCfg->status = MPT_CONFIG_ERROR;
+			pCfg->wait_done = 1;
+			wake_up(&mpt_waitq);
 		}
 		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 	}
@@ -5247,9 +5155,6 @@
 			case MPTCTL_DRIVER:
 				if (!ctl++) drvname = "ioctl";
 				break;
-			case MPTDMP_DRIVER:
-				if (!dmp++) drvname = "DMP";
-				break;
 			}
 
 			if (drvname)
@@ -5338,7 +5243,7 @@
 		len += sprintf(buf+len, "  PortNumber = %d (of %d)\n",
 				p+1,
 				ioc->facts.NumberOfPorts);
-		if ((int)ioc->chip_type <= (int)FC929) {
+		if (ioc->bus_type == FC) {
 			if (ioc->pfacts[p].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) {
 				u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;
 				len += sprintf(buf+len, "    LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n",
@@ -5930,7 +5835,6 @@
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 EXPORT_SYMBOL(ioc_list);
 EXPORT_SYMBOL(mpt_proc_root_dir);
-EXPORT_SYMBOL(DmpService);
 EXPORT_SYMBOL(mpt_register);
 EXPORT_SYMBOL(mpt_deregister);
 EXPORT_SYMBOL(mpt_event_register);
@@ -5943,9 +5847,7 @@
 EXPORT_SYMBOL(mpt_put_msg_frame);
 EXPORT_SYMBOL(mpt_free_msg_frame);
 EXPORT_SYMBOL(mpt_add_sge);
-EXPORT_SYMBOL(mpt_add_chain);
 EXPORT_SYMBOL(mpt_send_handshake_request);
-EXPORT_SYMBOL(mpt_handshake_req_reply_wait);
 EXPORT_SYMBOL(mpt_verify_adapter);
 EXPORT_SYMBOL(mpt_GetIocState);
 EXPORT_SYMBOL(mpt_print_ioc_summary);
@@ -5985,11 +5887,6 @@
 	int i;
 	int r;
 
-	if (FusionInitCalled++) {
-		dprintk((KERN_INFO MYNAM ": INFO - Driver late-init entry point called\n"));
-		return 0;
-	}
-
 	show_mptmod_ver(my_NAME, my_VERSION);
 	printk(KERN_INFO COPYRIGHT "\n");
 
@@ -5999,8 +5896,6 @@
 		MptEvHandlers[i] = NULL;
 		MptResetHandlers[i] = NULL;
 	}
-
-	DmpService = NULL;
 
 	/* NEW!  20010120 -sralston
 	 *  Register ourselves (mptbase) in order to facilitate
diff -Nru a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
--- a/drivers/message/fusion/mptbase.h	2004-12-24 13:36:19 -08:00
+++ b/drivers/message/fusion/mptbase.h	2004-12-24 13:36:19 -08:00
@@ -83,8 +83,8 @@
 #define COPYRIGHT	"Copyright (c) 1999-2004 " MODULEAUTHOR
 #endif
 
-#define MPT_LINUX_VERSION_COMMON	"3.01.16"
-#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.01.16"
+#define MPT_LINUX_VERSION_COMMON	"3.01.18"
+#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.01.18"
 #define WHAT_MAGIC_STRING		"@" "(" "#" ")"
 
 #define show_mptmod_ver(s,ver)  \
@@ -206,7 +206,6 @@
 	MPTSCSIH_DRIVER,	/* MPT SCSI host (initiator) class */
 	MPTLAN_DRIVER,		/* MPT LAN class */
 	MPTSTM_DRIVER,		/* MPT SCSI target mode class */
-	MPTDMP_DRIVER,		/* MPT Dynamic Multi-pathing class */
 	MPTUNKNOWN_DRIVER
 } MPT_DRIVER_CLASS;
 
@@ -226,8 +225,7 @@
 
 typedef union _MPT_FRAME_TRACKER {
 	struct {
-		struct _MPT_FRAME_HDR	*forw;
-		struct _MPT_FRAME_HDR	*back;
+		struct list_head	list;
 		u32			 arg1;
 		u32			 pad;
 		void			*argp1;
@@ -290,15 +288,6 @@
 
 #define MPT_REQ_MSGFLAGS_DROPME		0x80
 
-/* Used for tracking the free request frames
- * and free reply frames.
- */
-typedef struct _MPT_Q_TRACKER {
-	MPT_FRAME_HDR	*head;
-	MPT_FRAME_HDR	*tail;
-} MPT_Q_TRACKER;
-
-
 typedef struct _MPT_SGL_HDR {
 	SGESimple32_t	 sge[1];
 } MPT_SGL_HDR;
@@ -307,33 +296,6 @@
 	SGESimple64_t	 sge[1];
 } MPT_SGL64_HDR;
 
-
-typedef struct _Q_ITEM {
-	struct _Q_ITEM	*forw;
-	struct _Q_ITEM	*back;
-} Q_ITEM;
-
-typedef struct _Q_TRACKER {
-	struct _Q_ITEM	*head;
-	struct _Q_ITEM	*tail;
-} Q_TRACKER;
-
-/*
- *  Chip-specific stuff... FC929 delineates break between
- *  FC and Parallel SCSI parts. Do NOT re-order.
- */
-
-typedef enum {
-	FC919X = 0x0819,
-	FC929X = 0x0829,
-	FC909 = 0x0909,
-	FC919 = 0x0919,
-	FC929 = 0x0929,
-	C1030 = 0x1030,
-	C1035 = 0x1035,
-	FCUNK = 0xFBAD
-} CHIP_TYPE;
-
 /*
  *  System interface register set
  */
@@ -368,27 +330,6 @@
 /*
  *	Dynamic Multi-Pathing specific stuff...
  */
-#define DMP_MAX_PATHS	8
-
-typedef struct _PathInfo {
-	u8		 ioc;
-	u8		 target;
-	u8		 pad;
-	u8		 pflags;
-} PathInfo;
-
-#define PATHINFO_FLAGS_OWNED		0x01
-#define PATHINFO_FLAGS_EXISTS		0x02
-#define PATHINFO_FLAGS_AVAILABLE	0x04
-#define PATHINFO_FLAGS_SECONDARY	0x08
-
-#define PFLAGS_EXISTS_AND_AVAIL		(PATHINFO_FLAGS_EXISTS|PATHINFO_FLAGS_AVAILABLE)
-#define PFLAGS_AVAIL_AND_OWNED		(PATHINFO_FLAGS_AVAILABLE|PATHINFO_FLAGS_OWNED)
-
-typedef struct _ScsiCmndTracker {
-	void			*head;
-	void			*tail;
-} ScsiCmndTracker;
 
 /* VirtDevice negoFlags field */
 #define MPT_TARGET_NO_NEGO_WIDE		0x01
@@ -398,14 +339,9 @@
 
 /*
  *	VirtDevice - FC LUN device or SCSI target device
- *	(used to be FCSCSI_TARGET)
  */
 typedef struct _VirtDevice {
-	struct _VirtDevice	*forw;
-	struct _VirtDevice	*back;
 	struct scsi_device	*device;
-	rwlock_t		 VdevLock;
-	int			 ref_cnt;
 	u8			 tflags;
 	u8			 ioc_id;
 	u8			 target_id;
@@ -418,17 +354,8 @@
 	u8			 type;		/* byte 0 of Inquiry data */
 	u8			 cflags;	/* controller flags */
 	u8			 rsvd1raid;
-	int			 npaths;
 	u16			 fc_phys_lun;
 	u16			 fc_xlat_lun;
-	int			 stall_detected;
-	PathInfo		 path[DMP_MAX_PATHS];
-	struct timer_list	 stall_timer;
-	struct timer_list	 retry_timer;
-	struct timer_list	 gone_timer;
-	ScsiCmndTracker		 WaitQ;
-	ScsiCmndTracker		 SentQ;
-	ScsiCmndTracker		 DoneQ;
 	u32			 num_luns;
 	u32			 luns[8];		/* Max LUNs is 256 */
 	u8			 pad[4];
@@ -452,14 +379,6 @@
 #define MPT_TARGET_FLAGS_VALID_56	0x10
 #define MPT_TARGET_FLAGS_SAF_TE_ISSUED	0x20
 
-typedef struct _VirtDevTracker {
-	struct _VirtDevice	*head;
-	struct _VirtDevice	*tail;
-	rwlock_t		 VlistLock;
-	int			 pad;
-} VirtDevTracker;
-
-
 /*
  *	/proc/mpt interface
  */
@@ -575,14 +494,13 @@
  */
 typedef struct _MPT_ADAPTER
 {
-	struct _MPT_ADAPTER	*forw;
-	struct _MPT_ADAPTER	*back;
 	int			 id;		/* Unique adapter id N {0,1,2,...} */
 	int			 pci_irq;	/* This irq           */
 	char			 name[MPT_NAME_LENGTH];	/* "iocN"             */
 	char			*prod_name;	/* "LSIFC9x9"         */
 	SYSIF_REGS __iomem	*chip;		/* == c8817000 (mmap) */
 	SYSIF_REGS __iomem	*pio_chip;	/* Programmed IO (downloadboot) */
+	u8			 bus_type;
 	u32			 mem_phys;	/* == f4020000 (mmap) */
 	u32			 pio_mem_phys;	/* Programmed IO (downloadboot) */
 	int			 mem_size;	/* mmap memory size */
@@ -607,9 +525,8 @@
 	int			*ChainToChain;
 	u8			*ChainBuffer;
 	dma_addr_t		 ChainBufferDMA;
-	MPT_Q_TRACKER		 FreeChainQ;
+	struct list_head	 FreeChainQ;
 	spinlock_t		 FreeChainQlock;
-	CHIP_TYPE		 chip_type;
 		/* We (host driver) get to manage our own RequestQueue! */
 	dma_addr_t		 req_frames_dma;
 	MPT_FRAME_HDR		*req_frames;	/* Request msg frames - rounded up! */
@@ -617,7 +534,7 @@
 	int			 req_depth;	/* Number of request frames */
 	int			 req_sz;	/* Request frame size (bytes) */
 	spinlock_t		 FreeQlock;
-	MPT_Q_TRACKER		 FreeQ;
+	struct list_head	 FreeQ;
 		/* Pool of SCSI sense buffers for commands coming from
 		 * the SCSI mid-layer.  We have one 256 byte sense buffer
 		 * for each REQ entry.
@@ -627,7 +544,7 @@
 	u32			 sense_buf_low_dma;
 	int			 mtrr_reg;
 	struct pci_dev		*pcidev;	/* struct pci_dev pointer */
-	u8			*memmap;	/* mmap address */
+	u8			__iomem *memmap;	/* mmap address */
 	struct Scsi_Host	*sh;		/* Scsi Host pointer */
 	ScsiCfgData		spi_data;	/* Scsi config. data */
 	MPT_IOCTL		*ioctl;		/* ioctl data pointer */
@@ -639,16 +556,10 @@
 	int			 eventTypes;	/* Event logging parameters */
 	int			 eventContext;	/* Next event context */
 	int			 eventLogSize;	/* Max number of cached events */
-#ifdef MPTSCSIH_DBG_TIMEOUT
-	int			timeout_hard;
-	int			timeout_delta;
-	int			timeout_cnt;
-	int			timeout_maxcnt;
-#endif
 	struct _mpt_ioctl_events *events;	/* pointer to event log */
 	u8			*cached_fw;	/* Pointer to FW */
 	dma_addr_t	 	cached_fw_dma;
-	Q_TRACKER		 configQ;	/* linked list of config. requests */
+	struct list_head	 configQ;	/* linked list of config. requests */
 	int			 hs_reply_idx;
 #ifndef MFCNT
 	u32			 pad0;
@@ -663,9 +574,6 @@
 	FCPortPage0_t		 fc_port_page0[2];
 	LANPage0_t		 lan_cnfg_page0;
 	LANPage1_t		 lan_cnfg_page1;
-#ifdef CONFIG_PM
-	u32           		 PciState[64];     /* save PCI state to this area */
-#endif
 	u8			 FirstWhoInit;
 	u8			 upload_fw;	/* If set, do a fw upload */
 	u8			 reload_fw;	/* Force a FW Reload on next reset */
@@ -675,12 +583,6 @@
 	struct net_device	*netdev;
 } MPT_ADAPTER;
 
-
-typedef struct _MPT_ADAPTER_TRACKER {
-	MPT_ADAPTER	*head;
-	MPT_ADAPTER	*tail;
-} MPT_ADAPTER_TRACKER;
-
 /*
  *  New return value convention:
  *    1 = Ok to free associated request frame
@@ -902,41 +804,6 @@
 #define MPT_INDEX_2_RFPTR(ioc,idx) \
 	(MPT_FRAME_HDR*)( (u8*)(ioc)->reply_frames + (ioc)->req_sz * (idx) )
 
-#define Q_INIT(q,type)  (q)->head = (q)->tail = (type*)(q)
-#define Q_IS_EMPTY(q)   ((Q_ITEM*)(q)->head == (Q_ITEM*)(q))
-
-#define Q_ADD_TAIL(qt,i,type) { \
-	Q_TRACKER	*_qt = (Q_TRACKER*)(qt); \
-	Q_ITEM		*oldTail = _qt->tail; \
-	(i)->forw = (type*)_qt; \
-	(i)->back = (type*)oldTail; \
-	oldTail->forw = (Q_ITEM*)(i); \
-	_qt->tail = (Q_ITEM*)(i); \
-}
-
-#define Q_ADD_HEAD(qt,i,type) { \
-	Q_TRACKER	*_qt = (Q_TRACKER*)(qt); \
-	Q_ITEM		*oldHead = _qt->head; \
-	(i)->forw = (type*)oldHead; \
-	(i)->back = (type*)_qt; \
-	oldHead->back = (Q_ITEM*)(i); \
-	_qt->head = (Q_ITEM*)(i); \
-}
-
-#define Q_DEL_ITEM(i) { \
-	Q_ITEM  *_forw = (Q_ITEM*)(i)->forw; \
-	Q_ITEM  *_back = (Q_ITEM*)(i)->back; \
-	_back->forw = _forw; \
-	_forw->back = _back; \
-}
-
-#define SWAB4(value) \
-	(u32)(   (((value) & 0x000000ff) << 24) \
-	       | (((value) & 0x0000ff00) << 8)  \
-	       | (((value) & 0x00ff0000) >> 8)  \
-	       | (((value) & 0xff000000) >> 24) )
-
-
 #if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
 #define DBG_DUMP_REPLY_FRAME(mfp) \
 	{	u32 *m = (u32 *)(mfp);					\
@@ -1004,6 +871,12 @@
 #define	TM_STATE_IN_PROGRESS   (1)
 #define	TM_STATE_ERROR	       (2)
 
+typedef enum {
+	FC,
+	SCSI,
+	SAS
+} BUS_TYPE;
+
 typedef struct _MPT_SCSI_HOST {
 	MPT_ADAPTER		 *ioc;
 	int			  port;
@@ -1017,13 +890,10 @@
 		/* Pool of memory for holding SCpnts before doing
 		 * OS callbacks. freeQ is the free pool.
 		 */
-	MPT_Q_TRACKER		  taskQ;		/* TM request Q */
-	int			  taskQcnt;
 	u8			  tmPending;
 	u8			  resetPending;
-	u8			  is_spi;		/* Parallel SCSI i/f */
 	u8			  negoNvram;		/* DV disabled, nego NVRAM */
-	u8			  is_multipath;		/* Multi-path compatible */
+	u8			  pad1;
 	u8                        tmState;
 	u8			  rsvd[2];
 	MPT_FRAME_HDR		 *tmPtr;		/* Ptr to TM request*/
@@ -1044,32 +914,12 @@
 /* Forward decl, a strange C thing, to prevent gcc compiler warnings */
 struct scsi_cmnd;
 
-/*
- *	DMP service layer structure / API interface
- */
-typedef struct _DmpServices {
-	VirtDevTracker	  VdevList;
-	struct semaphore *Daemon;
-	int		(*ScsiPathSelect)
-				(struct scsi_cmnd *, MPT_SCSI_HOST **hd, int *target, int *lun);
-	int		(*DmpIoDoneChk)
-				(MPT_SCSI_HOST *, struct scsi_cmnd *,
-				 SCSIIORequest_t *,
-				 SCSIIOReply_t *);
-	void		(*mptscsih_scanVlist)
-				(MPT_SCSI_HOST *, int portnum);
-	int		(*ScsiAbort)
-				(struct scsi_cmnd *);
-	int		(*ScsiBusReset)
-				(struct scsi_cmnd *);
-} DmpServices_t;
-
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
  * Generic structure passed to the base mpt_config function.
  */
 typedef struct _x_config_parms {
-	Q_ITEM			 linkage;	/* linked list */
+	struct list_head	 linkage;	/* linked list */
 	struct timer_list	 timer;		/* timer function for this request  */
 	ConfigPageHeader_t	*hdr;
 	dma_addr_t		 physAddr;
@@ -1099,10 +949,8 @@
 extern void	 mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
 extern void	 mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
 extern void	 mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr);
-extern void	 mpt_add_chain(char *pAddr, u8 next, u16 length, dma_addr_t dma_addr);
 
 extern int	 mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag);
-extern int	 mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req, int replyBytes, u16 *u16reply, int maxwait, int sleepFlag);
 extern int	 mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp);
 extern u32	 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked);
 extern void	 mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan);
@@ -1119,20 +967,12 @@
  */
 extern struct list_head	  ioc_list;
 extern struct proc_dir_entry	*mpt_proc_root_dir;
-extern DmpServices_t		*DmpService;
 
 extern int		  mpt_lan_index;	/* needed by mptlan.c */
 extern int		  mpt_stm_index;	/* needed by mptstm.c */
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 #endif		/* } __KERNEL__ */
-
-/*
- *  More (public) macros...
- */
-#ifndef offsetof
-#define offsetof(t, m)	((size_t) (&((t *)0)->m))
-#endif
 
 #if defined(__alpha__) || defined(__sparc_v9__) || defined(__ia64__) || defined(__x86_64__)
 #define CAST_U32_TO_PTR(x)	((void *)(u64)x)
diff -Nru a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
--- a/drivers/message/fusion/mptctl.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/message/fusion/mptctl.c	2004-12-24 13:36:17 -08:00
@@ -1218,7 +1218,7 @@
 	/* Fill in the data and return the structure to the calling
 	 * program
 	 */
-	if ((int)ioc->chip_type <= (int) FC929)
+	if (ioc->bus_type == FC)
 		karg->adapterType = MPT_IOCTL_INTERFACE_FC;
 	else
 		karg->adapterType = MPT_IOCTL_INTERFACE_SCSI;
@@ -1518,7 +1518,7 @@
 #ifdef MFCNT
 	karg.chip_type = ioc->mfcnt;
 #else
-	karg.chip_type = ioc->chip_type;
+	karg.chip_type = ioc->pcidev->device;
 #endif
 	strncpy (karg.name, ioc->name, MPT_MAX_NAME);
 	karg.name[MPT_MAX_NAME-1]='\0';
@@ -2470,7 +2470,7 @@
 
 	karg.base_io_addr = pci_resource_start(pdev, 0);
 
-	if ((int)ioc->chip_type <= (int) FC929)
+	if (ioc->bus_type == FC)
 		karg.bus_phys_width = HP_BUS_WIDTH_UNK;
 	else
 		karg.bus_phys_width = HP_BUS_WIDTH_16;
@@ -2559,7 +2559,7 @@
 
 	/*  There is nothing to do for FCP parts.
 	 */
-	if ((int) ioc->chip_type <= (int) FC929)
+	if (ioc->bus_type == FC)
 		return 0;
 
 	if ((ioc->spi_data.sdp0length == 0) || (ioc->sh == NULL))
diff -Nru a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
--- a/drivers/message/fusion/mptscsih.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/message/fusion/mptscsih.c	2004-12-24 13:37:43 -08:00
@@ -96,10 +96,22 @@
 MODULE_DESCRIPTION(my_NAME);
 MODULE_LICENSE("GPL");
 
-/* Set string for command line args from insmod */
 #ifdef MODULE
-char *mptscsih = NULL;
-MODULE_PARM(mptscsih, "s");
+static int dv = MPTSCSIH_DOMAIN_VALIDATION;
+module_param(dv, int, 0);
+MODULE_PARM_DESC(dv, "DV Algorithm: enhanced = 1, basic = 0 (default=MPTSCSIH_DOMAIN_VALIDATION=1)");
+
+static int width = MPTSCSIH_MAX_WIDTH;
+module_param(width, int, 0);
+MODULE_PARM_DESC(width, "Max Bus Width: wide = 1, narrow = 0 (default=MPTSCSIH_MAX_WIDTH=1)");
+
+static ushort factor = MPTSCSIH_MIN_SYNC;
+module_param(factor, ushort, 0);
+MODULE_PARM_DESC(factor, "Min Sync Factor: (default=MPTSCSIH_MIN_SYNC=0x08)");
+
+static int saf_te = MPTSCSIH_SAF_TE;
+module_param(saf_te, int, 0);
+MODULE_PARM_DESC(saf_te, "Force enabling SEP Processor: (default=MPTSCSIH_SAF_TE=0)");
 #endif
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -200,9 +212,6 @@
 static void	mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage);
 static void	mptscsih_fillbuf(char *buffer, int size, int index, int width);
 #endif
-#ifdef MODULE
-static int	mptscsih_setup(char *str);
-#endif
 /* module entry point */
 static int  __init   mptscsih_init  (void);
 static void __exit   mptscsih_exit  (void);
@@ -245,15 +254,9 @@
 static int scandv_wait_done = 1;
 
 
-/* Driver default setup
+/* Driver command line structure
  */
-static struct mptscsih_driver_setup
-	driver_setup = MPTSCSIH_DRIVER_SETUP;
-
-#ifdef MPTSCSIH_DBG_TIMEOUT
-static struct scsi_cmnd *foo_to[8];
-#endif
-
+static struct mptscsih_driver_setup driver_setup;
 static struct scsi_host_template driver_template;
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -340,19 +343,18 @@
 	dsgprintk((MYIOC_s_INFO_FMT "getFreeChainBuffer called\n",
 			ioc->name));
 	spin_lock_irqsave(&ioc->FreeQlock, flags);
-	if (!Q_IS_EMPTY(&ioc->FreeChainQ)) {
-
+	if (!list_empty(&ioc->FreeChainQ)) {
 		int offset;
 
-		chainBuf = ioc->FreeChainQ.head;
-		Q_DEL_ITEM(&chainBuf->u.frame.linkage);
+		chainBuf = list_entry(ioc->FreeChainQ.next, MPT_FRAME_HDR,
+				u.frame.linkage.list);
+		list_del(&chainBuf->u.frame.linkage.list);
 		offset = (u8 *)chainBuf - (u8 *)ioc->ChainBuffer;
 		chain_idx = offset / ioc->req_sz;
 		rc = SUCCESS;
 		dsgprintk((MYIOC_s_INFO_FMT "getFreeChainBuffer (index %d), got buf=%p\n",
 			ioc->name, *retIndex, chainBuf));
-	}
-	else {
+	} else {
 		rc = FAILED;
 		chain_idx = MPT_HOST_NO_CHAIN;
 		dfailprintk((MYIOC_s_ERR_FMT "getFreeChainBuffer failed\n",
@@ -360,9 +362,7 @@
 	}
 	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 
-
 	*retIndex = chain_idx;
-
 	return rc;
 } /* mptscsih_getFreeChainBuffer() */
 
@@ -656,27 +656,6 @@
 	pScsiReq = (SCSIIORequest_t *) mf;
 	pScsiReply = (SCSIIOReply_t *) mr;
 
-#ifdef MPTSCSIH_DBG_TIMEOUT
-	if (ioc->timeout_cnt > 0) {
-		int ii, left = 0;
-
-		for (ii=0; ii < 8; ii++) {
-			if (sc == foo_to[ii]) {
-				printk(MYIOC_s_INFO_FMT "complete (%p, %ld)\n",
-					ioc->name, sc, jiffies);
-				foo_to[ii] = NULL;
-			}
-			if (foo_to[ii] != NULL)
-				left++;
-		}
-
-		if (left == 0) {
-			ioc->timeout_maxcnt = 0;
-			ioc->timeout_cnt = 0;
-		}
-	}
-#endif
-
 	if (pScsiReply == NULL) {
 		/* special context reply handling */
 		;
@@ -689,13 +668,14 @@
 		scsi_state = pScsiReply->SCSIState;
 		scsi_status = pScsiReply->SCSIStatus;
 		xfer_cnt = le32_to_cpu(pScsiReply->TransferCount);
+		sc->resid = sc->request_bufflen - xfer_cnt;
 
-		dreplyprintk((KERN_NOTICE " Reply (%d:%d:%d) mf=%p, mr=%p, sc=%p\n",
-				ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1],
-				mf, mr, sc));
-		dreplyprintk((KERN_NOTICE "IOCStatus=%04xh SCSIState=%02xh"
-				" SCSIStatus=%02xh xfer_cnt=%08xh\n",
-				status, scsi_state, scsi_status, xfer_cnt));
+		dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n"
+			"IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n"
+			"resid=%d bufflen=%d xfer_cnt=%d\n",
+			ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1],
+			status, scsi_state, scsi_status, sc->resid, 
+			sc->request_bufflen, xfer_cnt));
 
 		if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID)
 			copy_sense_data(sc, hd, mf, pScsiReply);
@@ -740,12 +720,11 @@
 			sc->result = DID_RESET << 16;
 
 			/* GEM Workaround. */
-			if (hd->is_spi)
+			if (ioc->bus_type == SCSI)
 				mptscsih_no_negotiate(hd, sc->device->id);
 			break;
 
 		case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH:	/* 0x0049 */
-			sc->resid = sc->request_bufflen - xfer_cnt;
 			if ( xfer_cnt >= sc->underflow ) {
 				/* Sufficient data transfer occurred */
 				sc->result = (DID_OK << 16) | scsi_status;
@@ -774,7 +753,7 @@
 				 */
 				;
 			} else {
-				if ( (xfer_cnt == 0) || (sc->underflow > xfer_cnt)) {
+				if (xfer_cnt < sc->underflow) {
 					sc->result = DID_SOFT_ERROR << 16;
 				}
 				if (scsi_state & (MPI_SCSI_STATE_AUTOSENSE_FAILED | MPI_SCSI_STATE_NO_SCSI_STATUS)) {
@@ -788,15 +767,9 @@
 				}
 			}
 
-			/* Give report and update residual count.
-			 */
 			dreplyprintk((KERN_NOTICE "  sc->underflow={report ERR if < %02xh bytes xfer'd}\n",
 					sc->underflow));
 			dreplyprintk((KERN_NOTICE "  ActBytesXferd=%02xh\n", xfer_cnt));
-
-			sc->resid = sc->request_bufflen - xfer_cnt;
-			dreplyprintk((KERN_NOTICE "  SET sc->resid=%02xh\n", sc->resid));
-			
 			/* Report Queue Full
 			 */
 			if (scsi_status == MPI_SCSI_STATUS_TASK_SET_FULL)
@@ -851,7 +824,7 @@
 			break;
 
 		case MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR:		/* 0x0047 */
-				sc->result = DID_SOFT_ERROR << 16;
+			sc->result = DID_SOFT_ERROR << 16;
 			break;
 
 		case MPI_IOCSTATUS_INVALID_FUNCTION:		/* 0x0001 */
@@ -1135,7 +1108,7 @@
 	 * max_lun = 1 + actual last lun,
 	 *	see hosts.h :o(
 	 */
-	if ((int)ioc->chip_type > (int)FC929) {
+	if (ioc->bus_type == SCSI) {
 		sh->max_id = MPT_MAX_SCSI_DEVICES;
 	} else {
 	/* For FC, increase the queue depth
@@ -1194,14 +1167,6 @@
 	hd = (MPT_SCSI_HOST *) sh->hostdata;
 	hd->ioc = ioc;
 
-	if ((int)ioc->chip_type > (int)FC929)
-	hd->is_spi = 1;
-
-	if (DmpService && (ioc->chip_type == FC919 ||
-	  ioc->chip_type == FC929)) {
-		hd->is_multipath = 1;
-	}
-
 	/* SCSI needs scsi_cmnd lookup table!
 	 * (with size equal to req_depth*PtrSz!)
 	 */
@@ -1218,12 +1183,6 @@
 	dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
 		 ioc->name, hd->ScsiLookup, sz));
 		
-	/* Initialize this Scsi_Host
-	 * internal task Q.
-	 */
-	Q_INIT(&hd->taskQ, MPT_FRAME_HDR);
-	hd->taskQcnt = 0;
-		
 	/* Allocate memory for the device structures.
 	 * A non-Null pointer at an offset
 	 * indicates a device exists.
@@ -1273,15 +1232,7 @@
 	/* Moved Earlier Pam D */
 	/* ioc->sh = sh;	*/
 
-#ifdef MPTSCSIH_DBG_TIMEOUT
-	ioc->timeout_hard = 0;
-	ioc->timeout_delta = 30 * HZ;
-	ioc->timeout_maxcnt = 0;
-	ioc->timeout_cnt = 0;
-	for (ii=0; ii < 8; ii++)
-		foo_to[ii] = NULL;
-#endif
-	if (hd->is_spi) {
+	if (ioc->bus_type == SCSI) {
 		/* Update with the driver setup
 		 * values.
 		 */
@@ -1292,9 +1243,9 @@
 		}
 
 		if (ioc->spi_data.minSyncFactor <
-		  driver_setup.min_sync_fac) {
+		  driver_setup.min_sync_factor) {
 			ioc->spi_data.minSyncFactor =
-			  driver_setup.min_sync_fac;
+			  driver_setup.min_sync_factor;
 		}
 
 		if (ioc->spi_data.minSyncFactor == MPT_ASYNC) {
@@ -1321,7 +1272,7 @@
 			"dv %x width %x factor %x saf_te %x\n",
 			ioc->name, driver_setup.dv,
 			driver_setup.max_width,
-			driver_setup.min_sync_fac,
+			driver_setup.min_sync_factor,
 			driver_setup.saf_te));
 	}
 
@@ -1388,11 +1339,11 @@
 
 	hd = (MPT_SCSI_HOST *)host->hostdata;
 	if (hd != NULL) {
-		int sz1, sz3, sztarget=0;
+		int sz1;
 
 		mptscsih_shutdown(&pdev->dev);
 
-		sz1 = sz3 = 0;
+		sz1=0;
 
 		if (hd->ScsiLookup != NULL) {
 			sz1 = hd->ioc->req_depth * sizeof(void *);
@@ -1401,36 +1352,16 @@
 		}
 
 		if (hd->Targets != NULL) {
-			int max, ii;
-
-			/*
-			 * Free any target structures that were allocated.
-			 */
-			if (hd->is_spi) {
-				max = MPT_MAX_SCSI_DEVICES;
-			} else {
-				max = MPT_MAX_FC_DEVICES<256 ? MPT_MAX_FC_DEVICES : 255;
-			}
-			for (ii=0; ii < max; ii++) {
-				if (hd->Targets[ii]) {
-					kfree(hd->Targets[ii]);
-					hd->Targets[ii] = NULL;
-					sztarget += sizeof(VirtDevice);
-				}
-			}
-
 			/*
 			 * Free pointer array.
 			 */
-			sz3 = max * sizeof(void *);
 			kfree(hd->Targets);
 			hd->Targets = NULL;
 		}
 
 		dprintk((MYIOC_s_INFO_FMT 
-		    "Free'd ScsiLookup (%d) Target (%d+%d) memory\n",
-		    hd->ioc->name, sz1, sz3, sztarget));
-		dprintk(("Free'd done and free Q (%d) memory\n", szQ));
+		    "Free'd ScsiLookup (%d) memory\n",
+		    hd->ioc->name, sz1));
 
 		/* NULL the Scsi_Host pointer
 		 */
@@ -1559,9 +1490,15 @@
 	}
 
 #ifdef MODULE
-	/* Evaluate the command line arguments, if any */
-	if (mptscsih)
-		mptscsih_setup(mptscsih);
+	dinitprintk((KERN_INFO MYNAM
+		": Command Line Args: dv=%d max_width=%d "
+		"factor=0x%x saf_te=%d\n",
+		dv, width, factor, saf_te));
+
+	driver_setup.dv = (dv) ? 1 : 0;
+	driver_setup.max_width = (width) ? 1 : 0;
+	driver_setup.min_sync_factor = factor;
+	driver_setup.saf_te = (saf_te) ? 1 : 0;;
 #endif
 
 	if(mpt_device_driver_register(&mptscsih_driver,
@@ -1690,129 +1627,6 @@
 	return ((info.pos > info.offset) ? info.pos - info.offset : 0);
 }
 
-#ifndef MPTSCSIH_DBG_TIMEOUT
-static int mptscsih_user_command(MPT_ADAPTER *ioc, char *pbuf, int len)
-{
-	/* Not yet implemented */
-	return len;
-}
-#else
-#define is_digit(c)	((c) >= '0' && (c) <= '9')
-#define digit_to_bin(c)	((c) - '0')
-#define is_space(c)	((c) == ' ' || (c) == '\t')
-
-#define UC_DBG_TIMEOUT		0x01
-#define UC_DBG_HARDRESET	0x02
-
-static int skip_spaces(char *ptr, int len)
-{
-	int cnt, c;
-
-	for (cnt = len; cnt > 0 && (c = *ptr++) && is_space(c); cnt --);
-
-	return (len - cnt);
-}
-
-static int get_int_arg(char *ptr, int len, ulong *pv)
-{
-	int cnt, c;
-	ulong	v;
-	for (v =  0, cnt = len; cnt > 0 && (c=*ptr++) && is_digit(c); cnt --) {
-		v = (v * 10) + digit_to_bin(c);
-	}
-
-	if (pv)
-		*pv = v;
-
-	return (len - cnt);
-}
-
-
-static int is_keyword(char *ptr, int len, char *verb)
-{
-	int verb_len = strlen(verb);
-
-	if (len >= strlen(verb) && !memcmp(verb, ptr, verb_len))
-		return verb_len;
-	else
-		return 0;
-}
-
-#define SKIP_SPACES(min_spaces)						\
-	if ((arg_len = skip_spaces(ptr,len)) < (min_spaces))		\
-		return -EINVAL;						\
-	ptr += arg_len;							\
-	len -= arg_len;
-
-#define GET_INT_ARG(v)							\
-	if (!(arg_len = get_int_arg(ptr,len, &(v))))			\
-		return -EINVAL;						\
-	ptr += arg_len;							\
-	len -= arg_len;
-
-static int mptscsih_user_command(MPT_ADAPTER *ioc, char *buffer, int length)
-{
-	char *ptr = buffer;
-	char btmp[24];	/* REMOVE */
-	int arg_len;
-	int len	= length;
-	int cmd;
-	ulong number = 1;
-	ulong delta = 10;
-
-	if ((len > 0) && (ptr[len -1] == '\n'))
-		--len;
-
-	if (len < 22) {
-		strncpy(btmp, buffer, len);
-		btmp[len+1]='\0';
-	} else {
-		strncpy(btmp, buffer, 22);
-		btmp[23]='\0';
-	}
-	printk("user_command:  ioc %d, buffer %s, length %d\n",
-			ioc->id, btmp, length);
-
-	if ((arg_len = is_keyword(ptr, len, "timeout")) != 0)
-		cmd = UC_DBG_TIMEOUT;
-	else if ((arg_len = is_keyword(ptr, len, "hardreset")) != 0)
-		cmd = UC_DBG_HARDRESET;
-	else
-		return -EINVAL;
-
-	ptr += arg_len;
-	len -= arg_len;
-
-	switch(cmd) {
-		case UC_DBG_TIMEOUT:
-			SKIP_SPACES(1);
-			GET_INT_ARG(number);
-			SKIP_SPACES(1);
-			GET_INT_ARG(delta);
-			break;
-	}
-
-	printk("user_command: cnt=%ld delta=%ld\n", number, delta);
-
-	if (len)
-		return -EINVAL;
-	else {
-		if (cmd == UC_DBG_HARDRESET) {
-			ioc->timeout_hard = 1;
-		} else if (cmd == UC_DBG_TIMEOUT) {
-			/* process this command ...
-			 */
-			ioc->timeout_maxcnt = 0;
-			ioc->timeout_delta = delta < 2 ? 2 : delta;
-			ioc->timeout_cnt = 0;
-			ioc->timeout_maxcnt = number < 8 ? number: 8;
-		}
-	}
-	/* Not yet implemented */
-	return length;
-}
-#endif
-
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *	mptscsih_proc_info - Return information about MPT adapter
@@ -1826,7 +1640,7 @@
  * 	hostno: scsi host number
  *	func:   if write = 1; if read = 0
  */
-static int 
+static int
 mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
 			int length, int func)
 {
@@ -1835,7 +1649,9 @@
 	int size = 0;
 
 	if (func) {
-		size = mptscsih_user_command(ioc, buffer, length);
+		/* 
+		 * write is not supported 
+		 */
 	} else {
 		if (start)
 			*start = buffer;
@@ -1846,7 +1662,6 @@
 	return size;
 }
 
-
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 #define ADD_INDEX_LOG(req_ent)	do { } while(0)
 
@@ -1877,11 +1692,7 @@
 	u32	 cmd_len;
 	int	 my_idx;
 	int	 ii;
-	int	 rc;
-	int	 did_errcode;
-	int	 issueCmd;
 
-	did_errcode = 0;
 	hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
 	target = SCpnt->device->id;
 	lun = SCpnt->device->lun;
@@ -1980,84 +1791,66 @@
 	/* Now add the SG list
 	 * Always have a SGE even if null length.
 	 */
-	rc = SUCCESS;
 	if (datalen == 0) {
 		/* Add a NULL SGE */
 		mptscsih_add_sge((char *)&pScsiReq->SGL, MPT_SGE_FLAGS_SSIMPLE_READ | 0,
 			(dma_addr_t) -1);
 	} else {
 		/* Add a 32 or 64 bit SGE */
-		rc = mptscsih_AddSGE(hd->ioc, SCpnt, pScsiReq, my_idx);
+		if (mptscsih_AddSGE(hd->ioc, SCpnt, pScsiReq, my_idx) != SUCCESS)
+			goto fail;
 	}
 
-
-	if (rc == SUCCESS) {
-		hd->ScsiLookup[my_idx] = SCpnt;
-		SCpnt->host_scribble = NULL;
-
-		/* SCSI specific processing */
-		issueCmd = 1;
-		if (hd->is_spi) {
-			int dvStatus = hd->ioc->spi_data.dvStatus[target];
-
-			if (dvStatus || hd->ioc->spi_data.forceDv) {
+	hd->ScsiLookup[my_idx] = SCpnt;
+	SCpnt->host_scribble = NULL;
 
 #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
-				if ((dvStatus & MPT_SCSICFG_NEED_DV) ||
-					(hd->ioc->spi_data.forceDv & MPT_SCSICFG_NEED_DV)) {
-					unsigned long lflags;
-					/* Schedule DV if necessary */
-					spin_lock_irqsave(&dvtaskQ_lock, lflags);
-					if (!dvtaskQ_active) {
-						dvtaskQ_active = 1;
-						spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
-						INIT_WORK(&mptscsih_dvTask, mptscsih_domainValidation, (void *) hd);
-
-						schedule_work(&mptscsih_dvTask);
-					} else {
-						spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
-					}
-					hd->ioc->spi_data.forceDv &= ~MPT_SCSICFG_NEED_DV;
-				}
+	if (hd->ioc->bus_type == SCSI) {
+		int dvStatus = hd->ioc->spi_data.dvStatus[target];
+		int issueCmd = 1;
+
+		if (dvStatus || hd->ioc->spi_data.forceDv) {
+
+			if ((dvStatus & MPT_SCSICFG_NEED_DV) ||
+				(hd->ioc->spi_data.forceDv & MPT_SCSICFG_NEED_DV)) {
+				unsigned long lflags;
+				/* Schedule DV if necessary */
+				spin_lock_irqsave(&dvtaskQ_lock, lflags);
+				if (!dvtaskQ_active) {
+					dvtaskQ_active = 1;
+					spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
+					INIT_WORK(&mptscsih_dvTask, mptscsih_domainValidation, (void *) hd);
 
-				/* Trying to do DV to this target, extend timeout.
-				 * Wait to issue until flag is clear
-				 */
-				if (dvStatus & MPT_SCSICFG_DV_PENDING) {
-					mod_timer(&SCpnt->eh_timeout, jiffies + 40 * HZ);
-					issueCmd = 0;
+					schedule_work(&mptscsih_dvTask);
+				} else {
+					spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
 				}
+				hd->ioc->spi_data.forceDv &= ~MPT_SCSICFG_NEED_DV;
+			}
 
-				/* Set the DV flags.
-				 */
-				if (dvStatus & MPT_SCSICFG_DV_NOT_DONE)
-					mptscsih_set_dvflags(hd, pScsiReq);
-#endif
+			/* Trying to do DV to this target, extend timeout.
+			 * Wait to issue until flag is clear
+			 */
+			if (dvStatus & MPT_SCSICFG_DV_PENDING) {
+				mod_timer(&SCpnt->eh_timeout, jiffies + 40 * HZ);
+				issueCmd = 0;
 			}
-		}
 
-#ifdef MPTSCSIH_DBG_TIMEOUT
-		if (hd->ioc->timeout_cnt < hd->ioc->timeout_maxcnt) {
-			foo_to[hd->ioc->timeout_cnt] = SCpnt;
-			hd->ioc->timeout_cnt++;
-			//mod_timer(&SCpnt->eh_timeout, jiffies + hd->ioc->timeout_delta);
-			issueCmd = 0;
-			printk(MYIOC_s_WARN_FMT
-				"to pendingQ: (sc=%p, mf=%p, time=%ld)\n",
-				hd->ioc->name, SCpnt, mf, jiffies);
+			/* Set the DV flags.
+			 */
+			if (dvStatus & MPT_SCSICFG_DV_NOT_DONE)
+				mptscsih_set_dvflags(hd, pScsiReq);
+
+			if (!issueCmd)
+				goto fail;
 		}
+	}
 #endif
 
-		if (issueCmd) {
-			mpt_put_msg_frame(ScsiDoneCtx, hd->ioc, mf);
-			dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
-					hd->ioc->name, SCpnt, mf, my_idx));
-			DBG_DUMP_REQUEST_FRAME(mf)
-		} else
-			goto fail;
-	} else
-		goto fail;
-
+	mpt_put_msg_frame(ScsiDoneCtx, hd->ioc, mf);
+	dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
+			hd->ioc->name, SCpnt, mf, my_idx));
+	DBG_DUMP_REQUEST_FRAME(mf)
 	return 0;
 
  fail:
@@ -2102,9 +1895,9 @@
 
 		chain = (MPT_FRAME_HDR *) (ioc->ChainBuffer
 					+ (chain_idx * ioc->req_sz));
+
 		spin_lock_irqsave(&ioc->FreeQlock, flags);
-		Q_ADD_TAIL(&ioc->FreeChainQ.head,
-					&chain->u.frame.linkage, MPT_FRAME_HDR);
+		list_add_tail(&chain->u.frame.linkage.list, &ioc->FreeChainQ);
 		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 
 		dmfprintk((MYIOC_s_INFO_FMT "FreeChainBuffers (index %d)\n",
@@ -2230,11 +2023,6 @@
 		}
 	}
 
-#ifdef MPTSCSIH_DBG_TIMEOUT
-	if (hd->ioc->timeout_hard)
-		rc = 1;
-#endif
-
 	/* Only fall through to the HRH if this is a bus reset
 	 */
 	if ((type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) && (rc ||
@@ -2471,9 +2259,9 @@
 	printk(KERN_WARNING MYNAM ": %s: >> Attempting target reset! (sc=%p)\n",
 	       hd->ioc->name, SCpnt);
 
-	/* Unsupported for SCSI. Supported for FCP
+	/* Supported for FC only.
 	 */
-	if (hd->is_spi)
+	if (hd->ioc->bus_type == SCSI) 
 		return FAILED;
 
 	spin_unlock_irq(host_lock);
@@ -2664,8 +2452,6 @@
 		if (hd->tmPtr) {
 			del_timer(&hd->TMtimer);
 		}
-		dtmprintk((MYIOC_s_WARN_FMT "taskQcnt (%d)\n",
-			ioc->name, hd->taskQcnt));
 	} else {
 		dtmprintk((MYIOC_s_WARN_FMT "TaskMgmt Complete: NULL Scsi Host Ptr\n",
 			ioc->name));
@@ -2783,43 +2569,56 @@
 mptscsih_slave_alloc(struct scsi_device *device)
 {
 	struct Scsi_Host	*host = device->host;
-	MPT_SCSI_HOST		*hd;
+	MPT_SCSI_HOST		*hd = (MPT_SCSI_HOST *)host->hostdata;
 	VirtDevice		*vdev;
-
-	hd = (MPT_SCSI_HOST *)host->hostdata;
+	uint			target = device->id;
 
 	if (hd == NULL)
 		return -ENODEV;
 
-	if ((vdev = hd->Targets[device->id]) == NULL) {
-		if ((vdev = kmalloc(sizeof(VirtDevice), GFP_ATOMIC)) == NULL) {
-			printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%d) FAILED!\n",
-			hd->ioc->name, (int)sizeof(VirtDevice));
-			return -ENOMEM;
-		} else {
-			memset(vdev, 0, sizeof(VirtDevice));
-			rwlock_init(&vdev->VdevLock);
-			Q_INIT(&vdev->WaitQ, void);
-			Q_INIT(&vdev->SentQ, void);
-			Q_INIT(&vdev->DoneQ, void);
-			vdev->tflags = MPT_TARGET_FLAGS_Q_YES;
-			vdev->ioc_id = hd->ioc->id;
-			vdev->target_id = device->id;
-			vdev->bus_id = device->channel;
-			vdev->raidVolume = 0;
-			hd->Targets[device->id] = vdev;
-			if (hd->is_spi) {
-				if (hd->ioc->spi_data.isRaid & (1 << device->id)) {
-					vdev->raidVolume = 1;
-					ddvtprintk((KERN_INFO
-					    "RAID Volume @ id %d\n", device->id));
-				}
-			} else {
-				vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
-			}
+	if ((vdev = hd->Targets[target]) != NULL)
+		goto out;
+
+	vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
+	if (!vdev) {
+		printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
+				hd->ioc->name, sizeof(VirtDevice));
+		return -ENOMEM;
+	}
+
+	memset(vdev, 0, sizeof(VirtDevice));
+	vdev->tflags = MPT_TARGET_FLAGS_Q_YES;
+	vdev->ioc_id = hd->ioc->id;
+	vdev->target_id = device->id;
+	vdev->bus_id = device->channel;
+	vdev->raidVolume = 0;
+	hd->Targets[device->id] = vdev;
+	if (hd->ioc->bus_type == SCSI) {
+		if (hd->ioc->spi_data.isRaid & (1 << device->id)) {
+			vdev->raidVolume = 1;
+			ddvtprintk((KERN_INFO
+			    "RAID Volume @ id %d\n", device->id));
 		}
+	} else {
+		vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
 	}
+
+ out:
 	vdev->num_luns++;
+	return 0;
+}
+
+static int mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id)
+{
+	int i;
+
+	if (!hd->ioc->spi_data.isRaid || !hd->ioc->spi_data.pIocPg3)
+		return 0;
+
+	for (i = 0; i < hd->ioc->spi_data.pIocPg3->NumPhysDisks; i++) {
+		if (id == hd->ioc->spi_data.pIocPg3->PhysDisk[i].PhysDiskID)
+			return 1;
+	}
 
 	return 0;
 }
@@ -2832,61 +2631,73 @@
 mptscsih_slave_destroy(struct scsi_device *device)
 {
 	struct Scsi_Host	*host = device->host;
-	MPT_SCSI_HOST		*hd;
+	MPT_SCSI_HOST		*hd = (MPT_SCSI_HOST *)host->hostdata;
 	VirtDevice		*vdev;
-	int 			raid_volume=0;
-
-	hd = (MPT_SCSI_HOST *)host->hostdata;
+	uint			target = device->id;
+	uint			lun = device->lun;
 
 	if (hd == NULL)
 		return;
 
-	mptscsih_search_running_cmds(hd, device->id, device->lun);
-
-	/* Free memory and reset all flags for this target
-	 */
-	if ((vdev = hd->Targets[device->id]) != NULL) {
-		vdev->num_luns--;
-
-		if (vdev->luns[0] & (1 << device->lun))
-			vdev->luns[0] &= ~(1 << device->lun);
-
-		/* Free device structure only if number of luns is 0.
-		 */
-		if (vdev->num_luns == 0) {
-			kfree(hd->Targets[device->id]);
-			hd->Targets[device->id] = NULL;
+	mptscsih_search_running_cmds(hd, target, lun);
 
-			if (!hd->is_spi)
-				return;
-
-			if((hd->ioc->spi_data.isRaid) && (hd->ioc->spi_data.pIocPg3)) {
-			int i;
-				for(i=0;i<hd->ioc->spi_data.pIocPg3->NumPhysDisks &&
-					raid_volume==0;i++)
-
-					if(device->id ==
-					  hd->ioc->spi_data.pIocPg3->PhysDisk[i].PhysDiskID) {
-						raid_volume=1;
-						hd->ioc->spi_data.forceDv |=
-						  MPT_SCSICFG_RELOAD_IOC_PG3;
-					}
-			}
+	vdev = hd->Targets[target];
+	vdev->luns[0] &= ~(1 << lun);
+	if (--vdev->num_luns)
+		return;
 
-			if(!raid_volume){
-				hd->ioc->spi_data.dvStatus[device->id] =
+	kfree(hd->Targets[target]);
+	hd->Targets[target] = NULL;
+	
+	if (hd->ioc->bus_type == SCSI) {
+		if (mptscsih_is_raid_volume(hd, target)) {
+			hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
+		} else {
+			hd->ioc->spi_data.dvStatus[target] =
 				MPT_SCSICFG_NEGOTIATE;
 
-				if (hd->negoNvram == 0)
-					hd->ioc->spi_data.dvStatus[device->id]
-					|= MPT_SCSICFG_DV_NOT_DONE;
+			if (!hd->negoNvram) {
+				hd->ioc->spi_data.dvStatus[target] |=
+					MPT_SCSICFG_DV_NOT_DONE;
 			}
 		}
 	}
+}
 
-	return;
+static void
+mptscsih_set_queue_depth(struct scsi_device *device, MPT_SCSI_HOST *hd,
+	VirtDevice *pTarget, int qdepth)
+{
+	int	max_depth;
+	int	tagged;
+
+	if (hd->ioc->bus_type == SCSI) {
+		if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
+			if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
+				max_depth = 1;
+			else if (((pTarget->inq_data[0] & 0x1f) == 0x00) &&
+			         (pTarget->minSyncFactor <= MPT_ULTRA160 ))
+				max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
+			else
+				max_depth = MPT_SCSI_CMD_PER_DEV_LOW;
+		} else {
+			/* error case - No Inq. Data */
+			max_depth = 1;
+		}
+	} else
+		max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
+
+	if (qdepth > max_depth)
+		qdepth = max_depth;
+	if (qdepth == 1)
+		tagged = 0;
+	else
+		tagged = MSG_SIMPLE_TAG;
+
+	scsi_adjust_queue_depth(device, tagged, qdepth);
 }
 
+
 /*
  *	OS entry point to adjust the queue_depths on a per-device basis.
  *	Called once per device the bus scan. Use it to force the queue_depth
@@ -2936,24 +2747,7 @@
 
 	mptscsih_initTarget(hd, device->channel, device->id, device->lun,
 		device->inquiry, device->inquiry_len );
-	scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
-		MPT_SCSI_CMD_PER_DEV_HIGH);
-	if ( hd->is_spi ) {
-		if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
-			if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
-				scsi_adjust_queue_depth(device, 0, 1);
-			else if (((pTarget->inq_data[0] & 0x1f) == 0x00)
-			  && (pTarget->minSyncFactor <= MPT_ULTRA160 ))
-				scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
-					MPT_SCSI_CMD_PER_DEV_HIGH);
-			else
-				scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
-					MPT_SCSI_CMD_PER_DEV_LOW);
-		} else {
-			/* error case - No Inq. Data */
-			scsi_adjust_queue_depth(device, 0, 1);
-		}
-	}
+	mptscsih_set_queue_depth(device, hd, pTarget, MPT_SCSI_CMD_PER_DEV_HIGH);
 
 	dsprintk((MYIOC_s_INFO_FMT
 		"Queue depth=%d, tflags=%x\n",
@@ -2973,6 +2767,24 @@
 	return 0;
 }
 
+static ssize_t
+mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+	int			 depth;
+	struct scsi_device	*sdev = to_scsi_device(dev);
+	MPT_SCSI_HOST		*hd = (MPT_SCSI_HOST *) sdev->host->hostdata;
+	VirtDevice		*pTarget;
+
+	depth = simple_strtoul(buf, NULL, 0);
+	if (depth == 0)
+		return -EINVAL;
+	pTarget = hd->Targets[sdev->id];
+	if (pTarget == NULL)
+		return -EINVAL;
+	mptscsih_set_queue_depth(sdev, (MPT_SCSI_HOST *) sdev->host->hostdata,
+		pTarget, depth);
+	return count;
+}
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
@@ -2997,8 +2809,6 @@
 	pReq = (SCSIIORequest_t *) mf;
 	index = (int) pReq->TargetID;
 	target = hd->Targets[index];
-	if (hd->is_multipath && sc->device->hostdata)
-		target = (VirtDevice *) sc->device->hostdata;
 
 	if (sense_count) {
 		u8 *sense_data;
@@ -3111,10 +2921,6 @@
 			mpt_free_msg_frame(ioc, hd->tmPtr);
 		}
 
-#ifdef MPTSCSIH_DBG_TIMEOUT
-		ioc->timeout_hard = 0;
-#endif
-
 		dtmprintk((MYIOC_s_WARN_FMT "Pre-Reset complete.\n", ioc->name));
 
 	} else {
@@ -3144,7 +2950,7 @@
 
 		/* 4. Renegotiate to all devices, if SCSI
 		 */
-		if (hd->is_spi) {
+		if (ioc->bus_type == SCSI) {
 			dnegoprintk(("writeSDP1: ALL_IDS USE_NVRAM\n"));
 			mptscsih_writeSDP1(hd, 0, 0, MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM);
 		}
@@ -3173,7 +2979,7 @@
 
 		/* 7. Set flag to force DV and re-read IOC Page 3
 		 */
-		if (hd->is_spi) {
+		if (ioc->bus_type == SCSI) {
 			ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
 			ddvtprintk(("Set reload IOC Pg3 Flag\n"));
 		}
@@ -3204,7 +3010,7 @@
 		hd = NULL;
 		if (ioc->sh) {
 			hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
-			if (hd && (hd->is_spi) && (hd->soft_resets < -1))
+			if (hd && (ioc->bus_type == SCSI) && (hd->soft_resets < -1))
 				hd->soft_resets++;
 		}
 		break;
@@ -3233,7 +3039,7 @@
 		if (ioc->sh)
 			hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
 
-		if (hd && (hd->is_spi) && (hd->negoNvram == 0)) {
+		if (hd && (ioc->bus_type == SCSI) && (hd->negoNvram == 0)) {
 			ScsiCfgData	*pSpi;
 			Ioc3PhysDisk_t	*pPDisk;
 			int		 numPDisk;
@@ -3302,6 +3108,19 @@
 	return 1;		/* currently means nothing really */
 }
 
+static struct device_attribute mptscsih_queue_depth_attr = {
+	.attr = {
+		.name = 	"queue_depth",
+		.mode =		S_IWUSR,
+	},
+	.store = mptscsih_store_queue_depth,
+};
+
+static struct device_attribute *mptscsih_dev_attrs[] = {
+	&mptscsih_queue_depth_attr,
+	NULL,
+};
+
 static struct scsi_host_template driver_template = {
 	.proc_name			= "mptscsih",
 	.proc_info			= mptscsih_proc_info,
@@ -3322,6 +3141,7 @@
 	.max_sectors			= 8192,
 	.cmd_per_lun			= 7,
 	.use_clustering			= ENABLE_CLUSTERING,
+	.sdev_attrs			= mptscsih_dev_attrs,
 };
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -3366,7 +3186,7 @@
 	indexed_lun = (lun % 32);
 	vdev->luns[lun_index] |= (1 << indexed_lun);
 
-	if (hd->is_spi) {
+	if (hd->ioc->bus_type == SCSI) {
 		if ((data[0] == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) {
 			/* Treat all Processors as SAF-TE if
 			 * command line option is set */
@@ -4647,7 +4467,7 @@
 	/* Write SDP1 for all SCSI devices
 	 * Alloc memory and set up config buffer
 	 */
-	if (hd->is_spi) {
+	if (ioc->bus_type == SCSI) {
 		if (ioc->spi_data.sdp1length > 0) {
 			pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev,
 					 ioc->spi_data.sdp1length * 4, &cfg1_dma_addr);
@@ -4790,7 +4610,7 @@
 			msleep(250);
 
 			/* DV only to SCSI adapters */
-			if ((int)ioc->chip_type <= (int)FC929)
+			if (ioc->bus_type != SCSI)
 				continue;
 
 			/* Make sure everything looks ok */
@@ -6261,107 +6081,6 @@
 #endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/* Commandline Parsing routines and defines.
- *
- * insmod format:
- *	insmod mptscsih mptscsih="width:1 dv:n factor:0x09 saf-te:1"
- *  boot format:
- *	mptscsih=width:1,dv:n,factor:0x8,saf-te:1
- *
- */
-#ifdef MODULE
-#define	ARG_SEP	' '
-#else
-#define	ARG_SEP	','
-#endif
-
-#ifdef MODULE
-static char setup_token[] __initdata =
-	"dv:"
-	"width:"
-	"factor:"
-	"saf-te:"
-       ;	/* DO NOT REMOVE THIS ';' */
-#endif
-       
-#define OPT_DV			1
-#define OPT_MAX_WIDTH		2
-#define OPT_MIN_SYNC_FACTOR	3
-#define OPT_SAF_TE		4
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-#ifdef MODULE
-static int
-get_setup_token(char *p)
-{
-	char *cur = setup_token;
-	char *pc;
-	int i = 0;
-
-	while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
-		++pc;
-		++i;
-		if (!strncmp(p, cur, pc - cur))
-			return i;
-		cur = pc;
-	}
-	return 0;
-}
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-static int
-mptscsih_setup(char *str)
-{
-	char *cur = str;
-	char *pc, *pv;
-	unsigned long val;
-	int  c;
-
-	while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
-		char *pe;
-
-		val = 0;
-		pv = pc;
-		c = *++pv;
-
-		if	(c == 'n')
-			val = 0;
-		else if	(c == 'y')
-			val = 1;
-		else
-			val = (int) simple_strtoul(pv, &pe, 0);
-
-		printk("Found Token: %s, value %x\n", cur, (int)val);
-		switch (get_setup_token(cur)) {
-		case OPT_DV:
-			driver_setup.dv = val;
-			break;
-
-		case OPT_MAX_WIDTH:
-			driver_setup.max_width = val;
-			break;
-
-		case OPT_MIN_SYNC_FACTOR:
-			driver_setup.min_sync_fac = val;
-			break;
-
-		case OPT_SAF_TE:
-			driver_setup.saf_te = val;
-			break;
-
-		default:
-			printk("mptscsih_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur);
-			break;
-		}
-
-		if ((cur = strchr(cur, ARG_SEP)) != NULL)
-			++cur;
-	}
-	return 1;
-}
-#endif
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-
 
 module_init(mptscsih_init);
 module_exit(mptscsih_exit);
diff -Nru a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
--- a/drivers/message/fusion/mptscsih.h	2004-12-24 13:37:32 -08:00
+++ b/drivers/message/fusion/mptscsih.h	2004-12-24 13:37:32 -08:00
@@ -95,17 +95,8 @@
 {
         u8      dv;
         u8      max_width;
-        u8      min_sync_fac;
+        u8      min_sync_factor;
         u8      saf_te;
 };
-
-
-#define MPTSCSIH_DRIVER_SETUP                   \
-{                                               \
-        MPTSCSIH_DOMAIN_VALIDATION,             \
-        MPTSCSIH_MAX_WIDTH,                     \
-        MPTSCSIH_MIN_SYNC,                      \
-        MPTSCSIH_SAF_TE,                        \
-}
 
 #endif
diff -Nru a/drivers/message/i2o/debug.c b/drivers/message/i2o/debug.c
--- a/drivers/message/i2o/debug.c	2004-12-24 13:36:58 -08:00
+++ b/drivers/message/i2o/debug.c	2004-12-24 13:36:58 -08:00
@@ -4,40 +4,14 @@
 #include <linux/pci.h>
 #include <linux/i2o.h>
 
-static int verbose;
 extern struct i2o_driver **i2o_drivers;
 extern unsigned int i2o_max_drivers;
 static void i2o_report_util_cmd(u8 cmd);
 static void i2o_report_exec_cmd(u8 cmd);
-void i2o_report_fail_status(u8 req_status, u32 * msg);
-void i2o_report_common_status(u8 req_status);
+static void i2o_report_fail_status(u8 req_status, u32 * msg);
+static void i2o_report_common_status(u8 req_status);
 static void i2o_report_common_dsc(u16 detailed_status);
 
-void i2o_dump_status_block(i2o_status_block * sb)
-{
-	pr_debug("Organization ID: %d\n", sb->org_id);
-	pr_debug("IOP ID:          %d\n", sb->iop_id);
-	pr_debug("Host Unit ID:    %d\n", sb->host_unit_id);
-	pr_debug("Segment Number:  %d\n", sb->segment_number);
-	pr_debug("I2O Version:     %d\n", sb->i2o_version);
-	pr_debug("IOP State:       %d\n", sb->iop_state);
-	pr_debug("Messanger Type:  %d\n", sb->msg_type);
-	pr_debug("Inbound Frame Size:      %d\n", sb->inbound_frame_size);
-	pr_debug("Init Code:               %d\n", sb->init_code);
-	pr_debug("Max Inbound MFrames:     %d\n", sb->max_inbound_frames);
-	pr_debug("Current Inbound MFrames: %d\n", sb->cur_inbound_frames);
-	pr_debug("Max Outbound MFrames:    %d\n", sb->max_outbound_frames);
-	pr_debug("Product ID String: %s\n", sb->product_id);
-	pr_debug("Expected LCT Size: %d\n", sb->expected_lct_size);
-	pr_debug("IOP Capabilities:  %d\n", sb->iop_capabilities);
-	pr_debug("Desired Private MemSize: %d\n", sb->desired_mem_size);
-	pr_debug("Current Private MemSize: %d\n", sb->current_mem_size);
-	pr_debug("Current Private MemBase: %d\n", sb->current_mem_base);
-	pr_debug("Desired Private IO Size: %d\n", sb->desired_io_size);
-	pr_debug("Current Private IO Size: %d\n", sb->current_io_size);
-	pr_debug("Current Private IO Base: %d\n", sb->current_io_base);
-};
-
 /*
  * Used for error reporting/debugging purposes.
  * Report Cmd name, Request status, Detailed Status.
@@ -54,7 +28,7 @@
 	if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
 		return;		// No status in this reply
 
-	printk("%s%s: ", severity, str);
+	printk(KERN_DEBUG "%s%s: ", severity, str);
 
 	if (cmd < 0x1F)		// Utility cmd
 		i2o_report_util_cmd(cmd);
@@ -62,7 +36,7 @@
 	else if (cmd >= 0xA0 && cmd <= 0xEF)	// Executive cmd
 		i2o_report_exec_cmd(cmd);
 	else
-		printk("Cmd = %0#2x, ", cmd);	// Other cmds
+		printk(KERN_DEBUG "Cmd = %0#2x, ", cmd);	// Other cmds
 
 	if (msg[0] & MSG_FAIL) {
 		i2o_report_fail_status(req_status, msg);
@@ -74,7 +48,8 @@
 	if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
 		i2o_report_common_dsc(detailed_status);
 	else
-		printk(" / DetailedStatus = %0#4x.\n", detailed_status);
+		printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
+		       detailed_status);
 }
 
 /* Used to dump a message to syslog during debugging */
@@ -90,71 +65,12 @@
 #endif
 }
 
-/**
- *	i2o_report_controller_unit - print information about a tid
- *	@c: controller
- *	@d: device
- *
- *	Dump an information block associated with a given unit (TID). The
- *	tables are read and a block of text is output to printk that is
- *	formatted intended for the user.
- */
-
-void i2o_report_controller_unit(struct i2o_controller *c, struct i2o_device *d)
-{
-	char buf[64];
-	char str[22];
-	int ret;
-
-	if (verbose == 0)
-		return;
-
-	printk(KERN_INFO "Target ID %03x.\n", d->lct_data.tid);
-	if ((ret = i2o_parm_field_get(d, 0xF100, 3, buf, 16)) >= 0) {
-		buf[16] = 0;
-		printk(KERN_INFO "     Vendor: %s\n", buf);
-	}
-	if ((ret = i2o_parm_field_get(d, 0xF100, 4, buf, 16)) >= 0) {
-		buf[16] = 0;
-		printk(KERN_INFO "     Device: %s\n", buf);
-	}
-	if (i2o_parm_field_get(d, 0xF100, 5, buf, 16) >= 0) {
-		buf[16] = 0;
-		printk(KERN_INFO "     Description: %s\n", buf);
-	}
-	if ((ret = i2o_parm_field_get(d, 0xF100, 6, buf, 8)) >= 0) {
-		buf[8] = 0;
-		printk(KERN_INFO "        Rev: %s\n", buf);
-	}
-
-	printk(KERN_INFO "    Class: ");
-	//sprintf(str, "%-21s", i2o_get_class_name(d->lct_data.class_id));
-	printk("%s\n", str);
-
-	printk(KERN_INFO "  Subclass: 0x%04X\n", d->lct_data.sub_class);
-	printk(KERN_INFO "     Flags: ");
-
-	if (d->lct_data.device_flags & (1 << 0))
-		printk("C");	// ConfigDialog requested
-	if (d->lct_data.device_flags & (1 << 1))
-		printk("U");	// Multi-user capable
-	if (!(d->lct_data.device_flags & (1 << 4)))
-		printk("P");	// Peer service enabled!
-	if (!(d->lct_data.device_flags & (1 << 5)))
-		printk("M");	// Mgmt service enabled!
-	printk("\n");
-}
-
-/*
-MODULE_PARM(verbose, "i");
-MODULE_PARM_DESC(verbose, "Verbose diagnostics");
-*/
 /*
  * Used for error reporting/debugging purposes.
  * Following fail status are common to all classes.
  * The preserved message must be handled in the reply handler.
  */
-void i2o_report_fail_status(u8 req_status, u32 * msg)
+static void i2o_report_fail_status(u8 req_status, u32 * msg)
 {
 	static char *FAIL_STATUS[] = {
 		"0x80",		/* not used */
@@ -177,9 +93,11 @@
 	};
 
 	if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
-		printk("TRANSPORT_UNKNOWN_FAILURE (%0#2x)\n.", req_status);
+		printk(KERN_DEBUG "TRANSPORT_UNKNOWN_FAILURE (%0#2x)\n.",
+		       req_status);
 	else
-		printk("TRANSPORT_%s.\n", FAIL_STATUS[req_status & 0x0F]);
+		printk(KERN_DEBUG "TRANSPORT_%s.\n",
+		       FAIL_STATUS[req_status & 0x0F]);
 
 	/* Dump some details */
 
@@ -192,16 +110,17 @@
 
 	printk(KERN_ERR "  Severity:  0x%02X ", (msg[4] >> 16) & 0xFF);
 	if (msg[4] & (1 << 16))
-		printk("(FormatError), "
+		printk(KERN_DEBUG "(FormatError), "
 		       "this msg can never be delivered/processed.\n");
 	if (msg[4] & (1 << 17))
-		printk("(PathError), "
+		printk(KERN_DEBUG "(PathError), "
 		       "this msg can no longer be delivered/processed.\n");
 	if (msg[4] & (1 << 18))
-		printk("(PathState), "
+		printk(KERN_DEBUG "(PathState), "
 		       "the system state does not allow delivery.\n");
 	if (msg[4] & (1 << 19))
-		printk("(Congestion), resources temporarily not available;"
+		printk(KERN_DEBUG
+		       "(Congestion), resources temporarily not available;"
 		       "do not retry immediately.\n");
 }
 
@@ -209,7 +128,7 @@
  * Used for error reporting/debugging purposes.
  * Following reply status are common to all classes.
  */
-void i2o_report_common_status(u8 req_status)
+static void i2o_report_common_status(u8 req_status)
 {
 	static char *REPLY_STATUS[] = {
 		"SUCCESS",
@@ -227,9 +146,9 @@
 	};
 
 	if (req_status >= ARRAY_SIZE(REPLY_STATUS))
-		printk("RequestStatus = %0#2x", req_status);
+		printk(KERN_DEBUG "RequestStatus = %0#2x", req_status);
 	else
-		printk("%s", REPLY_STATUS[req_status]);
+		printk(KERN_DEBUG "%s", REPLY_STATUS[req_status]);
 }
 
 /*
@@ -272,9 +191,10 @@
 	};
 
 	if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
-		printk(" / DetailedStatus = %0#4x.\n", detailed_status);
+		printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
+		       detailed_status);
 	else
-		printk(" / %s.\n", COMMON_DSC[detailed_status]);
+		printk(KERN_DEBUG " / %s.\n", COMMON_DSC[detailed_status]);
 }
 
 /*
@@ -284,49 +204,49 @@
 {
 	switch (cmd) {
 	case I2O_CMD_UTIL_NOP:
-		printk("UTIL_NOP, ");
+		printk(KERN_DEBUG "UTIL_NOP, ");
 		break;
 	case I2O_CMD_UTIL_ABORT:
-		printk("UTIL_ABORT, ");
+		printk(KERN_DEBUG "UTIL_ABORT, ");
 		break;
 	case I2O_CMD_UTIL_CLAIM:
-		printk("UTIL_CLAIM, ");
+		printk(KERN_DEBUG "UTIL_CLAIM, ");
 		break;
 	case I2O_CMD_UTIL_RELEASE:
-		printk("UTIL_CLAIM_RELEASE, ");
+		printk(KERN_DEBUG "UTIL_CLAIM_RELEASE, ");
 		break;
 	case I2O_CMD_UTIL_CONFIG_DIALOG:
-		printk("UTIL_CONFIG_DIALOG, ");
+		printk(KERN_DEBUG "UTIL_CONFIG_DIALOG, ");
 		break;
 	case I2O_CMD_UTIL_DEVICE_RESERVE:
-		printk("UTIL_DEVICE_RESERVE, ");
+		printk(KERN_DEBUG "UTIL_DEVICE_RESERVE, ");
 		break;
 	case I2O_CMD_UTIL_DEVICE_RELEASE:
-		printk("UTIL_DEVICE_RELEASE, ");
+		printk(KERN_DEBUG "UTIL_DEVICE_RELEASE, ");
 		break;
 	case I2O_CMD_UTIL_EVT_ACK:
-		printk("UTIL_EVENT_ACKNOWLEDGE, ");
+		printk(KERN_DEBUG "UTIL_EVENT_ACKNOWLEDGE, ");
 		break;
 	case I2O_CMD_UTIL_EVT_REGISTER:
-		printk("UTIL_EVENT_REGISTER, ");
+		printk(KERN_DEBUG "UTIL_EVENT_REGISTER, ");
 		break;
 	case I2O_CMD_UTIL_LOCK:
-		printk("UTIL_LOCK, ");
+		printk(KERN_DEBUG "UTIL_LOCK, ");
 		break;
 	case I2O_CMD_UTIL_LOCK_RELEASE:
-		printk("UTIL_LOCK_RELEASE, ");
+		printk(KERN_DEBUG "UTIL_LOCK_RELEASE, ");
 		break;
 	case I2O_CMD_UTIL_PARAMS_GET:
-		printk("UTIL_PARAMS_GET, ");
+		printk(KERN_DEBUG "UTIL_PARAMS_GET, ");
 		break;
 	case I2O_CMD_UTIL_PARAMS_SET:
-		printk("UTIL_PARAMS_SET, ");
+		printk(KERN_DEBUG "UTIL_PARAMS_SET, ");
 		break;
 	case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
-		printk("UTIL_REPLY_FAULT_NOTIFY, ");
+		printk(KERN_DEBUG "UTIL_REPLY_FAULT_NOTIFY, ");
 		break;
 	default:
-		printk("Cmd = %0#2x, ", cmd);
+		printk(KERN_DEBUG "Cmd = %0#2x, ", cmd);
 	}
 }
 
@@ -337,106 +257,106 @@
 {
 	switch (cmd) {
 	case I2O_CMD_ADAPTER_ASSIGN:
-		printk("EXEC_ADAPTER_ASSIGN, ");
+		printk(KERN_DEBUG "EXEC_ADAPTER_ASSIGN, ");
 		break;
 	case I2O_CMD_ADAPTER_READ:
-		printk("EXEC_ADAPTER_READ, ");
+		printk(KERN_DEBUG "EXEC_ADAPTER_READ, ");
 		break;
 	case I2O_CMD_ADAPTER_RELEASE:
-		printk("EXEC_ADAPTER_RELEASE, ");
+		printk(KERN_DEBUG "EXEC_ADAPTER_RELEASE, ");
 		break;
 	case I2O_CMD_BIOS_INFO_SET:
-		printk("EXEC_BIOS_INFO_SET, ");
+		printk(KERN_DEBUG "EXEC_BIOS_INFO_SET, ");
 		break;
 	case I2O_CMD_BOOT_DEVICE_SET:
-		printk("EXEC_BOOT_DEVICE_SET, ");
+		printk(KERN_DEBUG "EXEC_BOOT_DEVICE_SET, ");
 		break;
 	case I2O_CMD_CONFIG_VALIDATE:
-		printk("EXEC_CONFIG_VALIDATE, ");
+		printk(KERN_DEBUG "EXEC_CONFIG_VALIDATE, ");
 		break;
 	case I2O_CMD_CONN_SETUP:
-		printk("EXEC_CONN_SETUP, ");
+		printk(KERN_DEBUG "EXEC_CONN_SETUP, ");
 		break;
 	case I2O_CMD_DDM_DESTROY:
-		printk("EXEC_DDM_DESTROY, ");
+		printk(KERN_DEBUG "EXEC_DDM_DESTROY, ");
 		break;
 	case I2O_CMD_DDM_ENABLE:
-		printk("EXEC_DDM_ENABLE, ");
+		printk(KERN_DEBUG "EXEC_DDM_ENABLE, ");
 		break;
 	case I2O_CMD_DDM_QUIESCE:
-		printk("EXEC_DDM_QUIESCE, ");
+		printk(KERN_DEBUG "EXEC_DDM_QUIESCE, ");
 		break;
 	case I2O_CMD_DDM_RESET:
-		printk("EXEC_DDM_RESET, ");
+		printk(KERN_DEBUG "EXEC_DDM_RESET, ");
 		break;
 	case I2O_CMD_DDM_SUSPEND:
-		printk("EXEC_DDM_SUSPEND, ");
+		printk(KERN_DEBUG "EXEC_DDM_SUSPEND, ");
 		break;
 	case I2O_CMD_DEVICE_ASSIGN:
-		printk("EXEC_DEVICE_ASSIGN, ");
+		printk(KERN_DEBUG "EXEC_DEVICE_ASSIGN, ");
 		break;
 	case I2O_CMD_DEVICE_RELEASE:
-		printk("EXEC_DEVICE_RELEASE, ");
+		printk(KERN_DEBUG "EXEC_DEVICE_RELEASE, ");
 		break;
 	case I2O_CMD_HRT_GET:
-		printk("EXEC_HRT_GET, ");
+		printk(KERN_DEBUG "EXEC_HRT_GET, ");
 		break;
 	case I2O_CMD_ADAPTER_CLEAR:
-		printk("EXEC_IOP_CLEAR, ");
+		printk(KERN_DEBUG "EXEC_IOP_CLEAR, ");
 		break;
 	case I2O_CMD_ADAPTER_CONNECT:
-		printk("EXEC_IOP_CONNECT, ");
+		printk(KERN_DEBUG "EXEC_IOP_CONNECT, ");
 		break;
 	case I2O_CMD_ADAPTER_RESET:
-		printk("EXEC_IOP_RESET, ");
+		printk(KERN_DEBUG "EXEC_IOP_RESET, ");
 		break;
 	case I2O_CMD_LCT_NOTIFY:
-		printk("EXEC_LCT_NOTIFY, ");
+		printk(KERN_DEBUG "EXEC_LCT_NOTIFY, ");
 		break;
 	case I2O_CMD_OUTBOUND_INIT:
-		printk("EXEC_OUTBOUND_INIT, ");
+		printk(KERN_DEBUG "EXEC_OUTBOUND_INIT, ");
 		break;
 	case I2O_CMD_PATH_ENABLE:
-		printk("EXEC_PATH_ENABLE, ");
+		printk(KERN_DEBUG "EXEC_PATH_ENABLE, ");
 		break;
 	case I2O_CMD_PATH_QUIESCE:
-		printk("EXEC_PATH_QUIESCE, ");
+		printk(KERN_DEBUG "EXEC_PATH_QUIESCE, ");
 		break;
 	case I2O_CMD_PATH_RESET:
-		printk("EXEC_PATH_RESET, ");
+		printk(KERN_DEBUG "EXEC_PATH_RESET, ");
 		break;
 	case I2O_CMD_STATIC_MF_CREATE:
-		printk("EXEC_STATIC_MF_CREATE, ");
+		printk(KERN_DEBUG "EXEC_STATIC_MF_CREATE, ");
 		break;
 	case I2O_CMD_STATIC_MF_RELEASE:
-		printk("EXEC_STATIC_MF_RELEASE, ");
+		printk(KERN_DEBUG "EXEC_STATIC_MF_RELEASE, ");
 		break;
 	case I2O_CMD_STATUS_GET:
-		printk("EXEC_STATUS_GET, ");
+		printk(KERN_DEBUG "EXEC_STATUS_GET, ");
 		break;
 	case I2O_CMD_SW_DOWNLOAD:
-		printk("EXEC_SW_DOWNLOAD, ");
+		printk(KERN_DEBUG "EXEC_SW_DOWNLOAD, ");
 		break;
 	case I2O_CMD_SW_UPLOAD:
-		printk("EXEC_SW_UPLOAD, ");
+		printk(KERN_DEBUG "EXEC_SW_UPLOAD, ");
 		break;
 	case I2O_CMD_SW_REMOVE:
-		printk("EXEC_SW_REMOVE, ");
+		printk(KERN_DEBUG "EXEC_SW_REMOVE, ");
 		break;
 	case I2O_CMD_SYS_ENABLE:
-		printk("EXEC_SYS_ENABLE, ");
+		printk(KERN_DEBUG "EXEC_SYS_ENABLE, ");
 		break;
 	case I2O_CMD_SYS_MODIFY:
-		printk("EXEC_SYS_MODIFY, ");
+		printk(KERN_DEBUG "EXEC_SYS_MODIFY, ");
 		break;
 	case I2O_CMD_SYS_QUIESCE:
-		printk("EXEC_SYS_QUIESCE, ");
+		printk(KERN_DEBUG "EXEC_SYS_QUIESCE, ");
 		break;
 	case I2O_CMD_SYS_TAB_SET:
-		printk("EXEC_SYS_TAB_SET, ");
+		printk(KERN_DEBUG "EXEC_SYS_TAB_SET, ");
 		break;
 	default:
-		printk("Cmd = %#02x, ", cmd);
+		printk(KERN_DEBUG "Cmd = %#02x, ", cmd);
 	}
 }
 
@@ -445,46 +365,32 @@
 	printk(KERN_INFO "%s: State = ", c->name);
 	switch (((i2o_status_block *) c->status_block.virt)->iop_state) {
 	case 0x01:
-		printk("INIT\n");
+		printk(KERN_DEBUG "INIT\n");
 		break;
 	case 0x02:
-		printk("RESET\n");
+		printk(KERN_DEBUG "RESET\n");
 		break;
 	case 0x04:
-		printk("HOLD\n");
+		printk(KERN_DEBUG "HOLD\n");
 		break;
 	case 0x05:
-		printk("READY\n");
+		printk(KERN_DEBUG "READY\n");
 		break;
 	case 0x08:
-		printk("OPERATIONAL\n");
+		printk(KERN_DEBUG "OPERATIONAL\n");
 		break;
 	case 0x10:
-		printk("FAILED\n");
+		printk(KERN_DEBUG "FAILED\n");
 		break;
 	case 0x11:
-		printk("FAULTED\n");
+		printk(KERN_DEBUG "FAULTED\n");
 		break;
 	default:
-		printk("%x (unknown !!)\n",
+		printk(KERN_DEBUG "%x (unknown !!)\n",
 		       ((i2o_status_block *) c->status_block.virt)->iop_state);
 	}
 };
 
-void i2o_systab_debug(struct i2o_sys_tbl *sys_tbl)
-{
-	u32 *table;
-	int count;
-	u32 size;
-
-	table = (u32 *) sys_tbl;
-	size = sizeof(struct i2o_sys_tbl) + sys_tbl->num_entries
-	    * sizeof(struct i2o_sys_tbl_entry);
-
-	for (count = 0; count < (size >> 2); count++)
-		printk(KERN_INFO "sys_tbl[%d] = %0#10x\n", count, table[count]);
-}
-
 void i2o_dump_hrt(struct i2o_controller *c)
 {
 	u32 *rows = (u32 *) c->hrt.virt;
@@ -516,56 +422,60 @@
 		d = (u8 *) (rows + 2);
 		state = p[1] << 8 | p[0];
 
-		printk("TID %04X:[", state & 0xFFF);
+		printk(KERN_DEBUG "TID %04X:[", state & 0xFFF);
 		state >>= 12;
 		if (state & (1 << 0))
-			printk("H");	/* Hidden */
+			printk(KERN_DEBUG "H");	/* Hidden */
 		if (state & (1 << 2)) {
-			printk("P");	/* Present */
+			printk(KERN_DEBUG "P");	/* Present */
 			if (state & (1 << 1))
-				printk("C");	/* Controlled */
+				printk(KERN_DEBUG "C");	/* Controlled */
 		}
 		if (state > 9)
-			printk("*");	/* Hard */
+			printk(KERN_DEBUG "*");	/* Hard */
 
-		printk("]:");
+		printk(KERN_DEBUG "]:");
 
 		switch (p[3] & 0xFFFF) {
 		case 0:
 			/* Adapter private bus - easy */
-			printk("Local bus %d: I/O at 0x%04X Mem 0x%08X",
-			       p[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
+			printk(KERN_DEBUG
+			       "Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
+			       d[1] << 8 | d[0], *(u32 *) (d + 4));
 			break;
 		case 1:
 			/* ISA bus */
-			printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X",
-			       p[2], d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
+			printk(KERN_DEBUG
+			       "ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
+			       d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
 			break;
 
 		case 2:	/* EISA bus */
-			printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
+			printk(KERN_DEBUG
+			       "EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
 			       p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
 			break;
 
 		case 3:	/* MCA bus */
-			printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
-			       p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
+			printk(KERN_DEBUG
+			       "MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
+			       d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
 			break;
 
 		case 4:	/* PCI bus */
-			printk("PCI %d: Bus %d Device %d Function %d",
-			       p[2], d[2], d[1], d[0]);
+			printk(KERN_DEBUG
+			       "PCI %d: Bus %d Device %d Function %d", p[2],
+			       d[2], d[1], d[0]);
 			break;
 
 		case 0x80:	/* Other */
 		default:
-			printk("Unsupported bus type.");
+			printk(KERN_DEBUG "Unsupported bus type.");
 			break;
 		}
-		printk("\n");
+		printk(KERN_DEBUG "\n");
 		rows += length;
 	}
 }
 
-EXPORT_SYMBOL(i2o_dump_status_block);
 EXPORT_SYMBOL(i2o_dump_message);
diff -Nru a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
--- a/drivers/message/i2o/device.c	2004-12-24 13:36:57 -08:00
+++ b/drivers/message/i2o/device.c	2004-12-24 13:36:57 -08:00
@@ -15,6 +15,7 @@
 
 #include <linux/module.h>
 #include <linux/i2o.h>
+#include <linux/delay.h>
 
 /* Exec OSM functions */
 extern struct bus_type i2o_bus_type;
@@ -34,7 +35,7 @@
 static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
 					 u32 type)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 
 	m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET);
@@ -106,8 +107,7 @@
 		if (!rc)
 			break;
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ);
+		ssleep(1);
 	}
 
 	if (!rc)
@@ -211,8 +211,8 @@
  *	Returns a pointer to the I2O device on success or negative error code
  *	on failure.
  */
-struct i2o_device *i2o_device_add(struct i2o_controller *c,
-				  i2o_lct_entry * entry)
+static struct i2o_device *i2o_device_add(struct i2o_controller *c,
+					 i2o_lct_entry * entry)
 {
 	struct i2o_device *dev;
 
@@ -446,7 +446,7 @@
 int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
 		   int oplen, void *reslist, int reslen)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	u32 *res32 = (u32 *) reslist;
 	u32 *restmp = (u32 *) reslist;
@@ -547,47 +547,6 @@
 }
 
 /*
- *	Set a scalar group value or a whole group.
- */
-int i2o_parm_field_set(struct i2o_device *i2o_dev, int group, int field,
-		       void *buf, int buflen)
-{
-	u16 *opblk;
-	u8 resblk[8 + buflen];	/* 8 bytes for header */
-	int size;
-
-	opblk = kmalloc(buflen + 64, GFP_KERNEL);
-	if (opblk == NULL) {
-		printk(KERN_ERR "i2o: no memory for operation buffer.\n");
-		return -ENOMEM;
-	}
-
-	opblk[0] = 1;		/* operation count */
-	opblk[1] = 0;		/* pad */
-	opblk[2] = I2O_PARAMS_FIELD_SET;
-	opblk[3] = group;
-
-	if (field == -1) {	/* whole group */
-		opblk[4] = -1;
-		memcpy(opblk + 5, buf, buflen);
-	} else {		/* single field */
-
-		opblk[4] = 1;
-		opblk[5] = field;
-		memcpy(opblk + 6, buf, buflen);
-	}
-
-	size = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_SET, opblk,
-			      12 + buflen, resblk, sizeof(resblk));
-
-	kfree(opblk);
-	if (size > buflen)
-		return buflen;
-
-	return size;
-}
-
-/*
  * 	if oper == I2O_PARAMS_TABLE_GET, get from all rows
  * 		if fieldcount == -1 return all fields
  *			ibuf and ibuflen are unused (use NULL, 0)
@@ -669,6 +628,5 @@
 EXPORT_SYMBOL(i2o_device_claim);
 EXPORT_SYMBOL(i2o_device_claim_release);
 EXPORT_SYMBOL(i2o_parm_field_get);
-EXPORT_SYMBOL(i2o_parm_field_set);
 EXPORT_SYMBOL(i2o_parm_table_get);
 EXPORT_SYMBOL(i2o_parm_issue);
diff -Nru a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
--- a/drivers/message/i2o/driver.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/message/i2o/driver.c	2004-12-24 13:37:31 -08:00
@@ -18,14 +18,13 @@
 #include <linux/rwsem.h>
 #include <linux/i2o.h>
 
-
 /* max_drivers - Maximum I2O drivers (OSMs) which could be registered */
 unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
 module_param_named(max_drivers, i2o_max_drivers, uint, 0);
 MODULE_PARM_DESC(max_drivers, "maximum number of OSM's to support");
 
 /* I2O drivers lock and array */
-static spinlock_t i2o_drivers_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t i2o_drivers_lock;
 static struct i2o_driver **i2o_drivers;
 
 /**
@@ -146,7 +145,7 @@
 		struct i2o_device *i2o_dev;
 
 		list_for_each_entry(i2o_dev, &c->devices, list)
-			i2o_driver_notify_device_remove(drv, i2o_dev);
+		    i2o_driver_notify_device_remove(drv, i2o_dev);
 
 		i2o_driver_notify_controller_remove(drv, c);
 	}
@@ -176,7 +175,7 @@
  *	negative error code on failure (the message will be flushed too).
  */
 int i2o_driver_dispatch(struct i2o_controller *c, u32 m,
-			struct i2o_message *msg)
+			struct i2o_message __iomem *msg)
 {
 	struct i2o_driver *drv;
 	u32 context = readl(&msg->u.s.icntxt);
@@ -246,14 +245,15 @@
  *	Send notifications to all registered drivers that a new controller was
  *	added.
  */
-void i2o_driver_notify_controller_add_all(struct i2o_controller *c) {
+void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
+{
 	int i;
 	struct i2o_driver *drv;
 
-	for(i = 0; i < I2O_MAX_DRIVERS; i ++) {
+	for (i = 0; i < I2O_MAX_DRIVERS; i++) {
 		drv = i2o_drivers[i];
 
-		if(drv)
+		if (drv)
 			i2o_driver_notify_controller_add(drv, c);
 	}
 }
@@ -265,14 +265,15 @@
  *	Send notifications to all registered drivers that a controller was
  *	removed.
  */
-void i2o_driver_notify_controller_remove_all(struct i2o_controller *c) {
+void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
+{
 	int i;
 	struct i2o_driver *drv;
 
-	for(i = 0; i < I2O_MAX_DRIVERS; i ++) {
+	for (i = 0; i < I2O_MAX_DRIVERS; i++) {
 		drv = i2o_drivers[i];
 
-		if(drv)
+		if (drv)
 			i2o_driver_notify_controller_remove(drv, c);
 	}
 }
@@ -283,14 +284,15 @@
  *
  *	Send notifications to all registered drivers that a device was added.
  */
-void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev) {
+void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
+{
 	int i;
 	struct i2o_driver *drv;
 
-	for(i = 0; i < I2O_MAX_DRIVERS; i ++) {
+	for (i = 0; i < I2O_MAX_DRIVERS; i++) {
 		drv = i2o_drivers[i];
 
-		if(drv)
+		if (drv)
 			i2o_driver_notify_device_add(drv, i2o_dev);
 	}
 }
@@ -301,14 +303,15 @@
  *
  *	Send notifications to all registered drivers that a device was removed.
  */
-void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev) {
+void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev)
+{
 	int i;
 	struct i2o_driver *drv;
 
-	for(i = 0; i < I2O_MAX_DRIVERS; i ++) {
+	for (i = 0; i < I2O_MAX_DRIVERS; i++) {
 		drv = i2o_drivers[i];
 
-		if(drv)
+		if (drv)
 			i2o_driver_notify_device_remove(drv, i2o_dev);
 	}
 }
@@ -323,6 +326,8 @@
 int __init i2o_driver_init(void)
 {
 	int rc = 0;
+
+	spin_lock_init(&i2o_drivers_lock);
 
 	if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) ||
 	    ((i2o_max_drivers ^ (i2o_max_drivers - 1)) !=
diff -Nru a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
--- a/drivers/message/i2o/exec-osm.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/message/i2o/exec-osm.c	2004-12-24 13:37:01 -08:00
@@ -29,9 +29,12 @@
 
 #include <linux/module.h>
 #include <linux/i2o.h>
+#include <linux/delay.h>
 
 struct i2o_driver i2o_exec_driver;
 
+static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind);
+
 /* Module internal functions from other sources */
 extern int i2o_device_parse_lct(struct i2o_controller *);
 
@@ -45,7 +48,7 @@
 	u32 tcntxt;		/* transaction context from reply */
 	int complete;		/* 1 if reply received otherwise 0 */
 	u32 m;			/* message id */
-	struct i2o_message *msg;	/* pointer to the reply message */
+	struct i2o_message __iomem *msg;	/* pointer to the reply message */
 	struct list_head list;	/* node in global wait list */
 };
 
@@ -109,21 +112,20 @@
 			  timeout, struct i2o_dma *dma)
 {
 	DECLARE_WAIT_QUEUE_HEAD(wq);
-	DEFINE_WAIT(wait);
-	struct i2o_exec_wait *iwait;
+	struct i2o_exec_wait *wait;
 	static u32 tcntxt = 0x80000000;
-	struct i2o_message *msg = c->in_queue.virt + m;
+	struct i2o_message __iomem *msg = c->in_queue.virt + m;
 	int rc = 0;
 
-	iwait = i2o_exec_wait_alloc();
-	if (!iwait)
+	wait = i2o_exec_wait_alloc();
+	if (!wait)
 		return -ENOMEM;
 
 	if (tcntxt == 0xffffffff)
 		tcntxt = 0x80000000;
 
 	if (dma)
-		iwait->dma = *dma;
+		wait->dma = *dma;
 
 	/*
 	 * Fill in the message initiator context and transaction context.
@@ -131,8 +133,8 @@
 	 * so we could find a POST WAIT reply easier in the reply handler.
 	 */
 	writel(i2o_exec_driver.context, &msg->u.s.icntxt);
-	iwait->tcntxt = tcntxt++;
-	writel(iwait->tcntxt, &msg->u.s.tcntxt);
+	wait->tcntxt = tcntxt++;
+	writel(wait->tcntxt, &msg->u.s.tcntxt);
 
 	/*
 	 * Post the message to the controller. At some point later it will
@@ -140,31 +142,27 @@
 	 */
 	i2o_msg_post(c, m);
 
-	if (!iwait->complete) {
-		iwait->wq = &wq;
+	if (!wait->complete) {
+		wait->wq = &wq;
 		/*
 		 * we add elements add the head, because if a entry in the list
 		 * will never be removed, we have to iterate over it every time
 		 */
-		list_add(&iwait->list, &i2o_exec_wait_list);
+		list_add(&wait->list, &i2o_exec_wait_list);
 
-		prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
+		wait_event_interruptible_timeout(wq, wait->complete,
+			timeout * HZ);
 
-		if (!iwait->complete)
-			schedule_timeout(timeout * HZ);
-
-		finish_wait(&wq, &wait);
-
-		iwait->wq = NULL;
+		wait->wq = NULL;
 	}
 
 	barrier();
 
-	if (iwait->complete) {
-		if (readl(&iwait->msg->body[0]) >> 24)
-			rc = readl(&iwait->msg->body[0]) & 0xff;
-		i2o_flush_reply(c, iwait->m);
-		i2o_exec_wait_free(iwait);
+	if (wait->complete) {
+		if (readl(&wait->msg->body[0]) >> 24)
+			rc = readl(&wait->msg->body[0]) & 0xff;
+		i2o_flush_reply(c, wait->m);
+		i2o_exec_wait_free(wait);
 	} else {
 		/*
 		 * We cannot remove it now. This is important. When it does
@@ -201,13 +199,15 @@
  *	message must also be given back to the controller.
  */
 static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
-				      struct i2o_message *msg)
+				      struct i2o_message __iomem *msg)
 {
 	struct i2o_exec_wait *wait, *tmp;
-	static spinlock_t lock = SPIN_LOCK_UNLOCKED;
+	static spinlock_t lock;
 	int rc = 1;
 	u32 context;
 
+	spin_lock_init(&lock);
+
 	context = readl(&msg->u.s.tcntxt);
 
 	/*
@@ -322,13 +322,13 @@
 static int i2o_exec_reply(struct i2o_controller *c, u32 m,
 			  struct i2o_message *msg)
 {
-	if (readl(&msg->u.head[0]) & MSG_FAIL) {	// Fail bit is set
-		struct i2o_message *pmsg;	/* preserved message */
+	if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) {	// Fail bit is set
+		struct i2o_message __iomem *pmsg;	/* preserved message */
 		u32 pm;
 
-		pm = readl(&msg->body[3]);
+		pm = le32_to_cpu(msg->body[3]);
 
-		pmsg = c->in_queue.virt + pm;
+		pmsg = i2o_msg_in_to_virt(c, pm);
 
 		i2o_report_status(KERN_INFO, "i2o_core", msg);
 
@@ -339,10 +339,10 @@
 		return -1;
 	}
 
-	if (readl(&msg->u.s.tcntxt) & 0x80000000)
+	if (le32_to_cpu(msg->u.s.tcntxt) & 0x80000000)
 		return i2o_msg_post_wait_complete(c, m, msg);
 
-	if ((readl(&msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) {
+	if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) {
 		struct work_struct *work;
 
 		pr_debug("%s: LCT notify received\n", c->name);
@@ -395,7 +395,7 @@
  */
 int i2o_exec_lct_get(struct i2o_controller *c)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	int i = 0;
 	int rc = -EAGAIN;
@@ -435,11 +435,11 @@
  *	replies immediately after the request. If change_ind > 0 the reply is
  *	send after change indicator of the LCT is > change_ind.
  */
-int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
+static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
 {
 	i2o_status_block *sb = c->status_block.virt;
 	struct device *dev;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 
 	dev = &c->pdev->dev;
@@ -502,4 +502,3 @@
 
 EXPORT_SYMBOL(i2o_msg_post_wait_mem);
 EXPORT_SYMBOL(i2o_exec_lct_get);
-EXPORT_SYMBOL(i2o_exec_lct_notify);
diff -Nru a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
--- a/drivers/message/i2o/i2o_block.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/message/i2o/i2o_block.c	2004-12-24 13:37:02 -08:00
@@ -126,7 +126,7 @@
  */
 static int i2o_block_device_flush(struct i2o_device *dev)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 
 	m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET);
@@ -154,7 +154,7 @@
  */
 static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 
 	m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET);
@@ -183,7 +183,7 @@
  */
 static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 
 	m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET);
@@ -211,7 +211,7 @@
  */
 static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 
 	m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET);
@@ -240,7 +240,7 @@
 {
 	struct i2o_device *i2o_dev = dev->i2o_dev;
 	struct i2o_controller *c = i2o_dev->iop;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	int rc;
 
@@ -416,11 +416,10 @@
 	unsigned long flags;
 
 	/* FAILed message */
-	if (unlikely(readl(&msg->u.head[0]) & (1 << 13))) {
+	if (unlikely(le32_to_cpu(msg->u.head[0]) & (1 << 13))) {
 		struct i2o_message *pmsg;
 		u32 pm;
 
-		printk(KERN_WARNING "FAIL");
 		/*
 		 * FAILed message from controller
 		 * We increment the error count and abort it
@@ -431,10 +430,10 @@
 		 * better be on the safe side since no one really follows
 		 * the spec to the book :)
 		 */
-		pm = readl(&msg->body[3]);
-		pmsg = c->in_queue.virt + pm;
+		pm = le32_to_cpu(msg->body[3]);
+		pmsg = i2o_msg_in_to_virt(c, pm);
 
-		req = i2o_cntxt_list_get(c, readl(&pmsg->u.s.tcntxt));
+		req = i2o_cntxt_list_get(c, le32_to_cpu(pmsg->u.s.tcntxt));
 		if (unlikely(!req)) {
 			printk(KERN_ERR "block-osm: NULL reply received!\n");
 			return -1;
@@ -449,7 +448,7 @@
 		spin_lock_irqsave(q->queue_lock, flags);
 
 		while (end_that_request_chunk(req, !req->errors,
-					      readl(&pmsg->body[1]))) ;
+					      le32_to_cpu(pmsg->body[1]))) ;
 		end_that_request_last(req);
 
 		dev->open_queue_depth--;
@@ -464,7 +463,7 @@
 		return -1;
 	}
 
-	req = i2o_cntxt_list_get(c, readl(&msg->u.s.tcntxt));
+	req = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));
 	if (unlikely(!req)) {
 		printk(KERN_ERR "block-osm: NULL reply received!\n");
 		return -1;
@@ -487,7 +486,7 @@
 		       "I2O Block: Data transfer to deleted device!\n");
 		spin_lock_irqsave(q->queue_lock, flags);
 		while (end_that_request_chunk
-		       (req, !req->errors, readl(&msg->body[1]))) ;
+		       (req, !req->errors, le32_to_cpu(msg->body[1]))) ;
 		end_that_request_last(req);
 
 		dev->open_queue_depth--;
@@ -503,7 +502,7 @@
 	 *      request in the context.
 	 */
 
-	st = readl(&msg->body[0]) >> 24;
+	st = le32_to_cpu(msg->body[0]) >> 24;
 
 	if (st != 0) {
 		int err;
@@ -524,7 +523,7 @@
 			"Volume has changed, waiting for acknowledgement"
 		};
 
-		err = readl(&msg->body[0]) & 0xffff;
+		err = le32_to_cpu(msg->body[0]) & 0xffff;
 
 		/*
 		 *      Device not ready means two things. One is that the
@@ -538,17 +537,18 @@
 		 *      Don't stick a supertrak100 into cache aggressive modes
 		 */
 
-		printk(KERN_ERR "\n/dev/%s error: %s", dev->gd->disk_name,
-		       bsa_errors[readl(&msg->body[0]) & 0xffff]);
-		if (readl(&msg->body[0]) & 0x00ff0000)
-			printk(" - DDM attempted %d retries",
-			       (readl(&msg->body[0]) >> 16) & 0x00ff);
-		printk(".\n");
+		printk(KERN_ERR "/dev/%s error: %s", dev->gd->disk_name,
+		       bsa_errors[le32_to_cpu(msg->body[0]) & 0xffff]);
+		if (le32_to_cpu(msg->body[0]) & 0x00ff0000)
+			printk(KERN_ERR " - DDM attempted %d retries",
+			       (le32_to_cpu(msg->body[0]) >> 16) & 0x00ff);
+		printk(KERN_ERR ".\n");
 		req->errors++;
 	} else
 		req->errors = 0;
 
-	if (!end_that_request_chunk(req, !req->errors, readl(&msg->body[1]))) {
+	if (!end_that_request_chunk
+	    (req, !req->errors, le32_to_cpu(msg->body[1]))) {
 		add_disk_randomness(req->rq_disk);
 		spin_lock_irqsave(q->queue_lock, flags);
 
@@ -563,7 +563,7 @@
 		i2o_block_sglist_free(ireq);
 		i2o_block_request_free(ireq);
 	} else
-		printk(KERN_ERR "still remaining chunks\n");
+		printk(KERN_ERR "i2o_block: still remaining chunks\n");
 
 	return 1;
 };
@@ -573,174 +573,6 @@
 	printk(KERN_INFO "block-osm: event received\n");
 };
 
-#if 0
-static int i2o_block_event(void *dummy)
-{
-	unsigned int evt;
-	unsigned long flags;
-	struct i2o_block_device *dev;
-	int unit;
-	//The only event that has data is the SCSI_SMART event.
-	struct i2o_reply {
-		u32 header[4];
-		u32 evt_indicator;
-		u8 ASC;
-		u8 ASCQ;
-		u16 pad;
-		u8 data[16];
-	} *evt_local;
-
-	daemonize("i2oblock");
-	allow_signal(SIGKILL);
-
-	evt_running = 1;
-
-	while (1) {
-		if (down_interruptible(&i2ob_evt_sem)) {
-			evt_running = 0;
-			printk("exiting...");
-			break;
-		}
-
-		/*
-		 * Keep another CPU/interrupt from overwriting the
-		 * message while we're reading it
-		 *
-		 * We stuffed the unit in the TxContext and grab the event mask
-		 * None of the BSA we care about events have EventData
-		 */
-		spin_lock_irqsave(&i2ob_evt_lock, flags);
-		evt_local = (struct i2o_reply *)evt_msg;
-		spin_unlock_irqrestore(&i2ob_evt_lock, flags);
-
-		unit = le32_to_cpu(evt_local->header[3]);
-		evt = le32_to_cpu(evt_local->evt_indicator);
-
-		dev = &i2o_blk_dev[unit];
-		switch (evt) {
-			/*
-			 * New volume loaded on same TID, so we just re-install.
-			 * The TID/controller don't change as it is the same
-			 * I2O device.  It's just new media that we have to
-			 * rescan.
-			 */
-		case I2O_EVT_IND_BSA_VOLUME_LOAD:
-			{
-				i2ob_install_device(dev->i2o_device->iop,
-						    dev->i2o_device, unit);
-				add_disk(dev->gendisk);
-				break;
-			}
-
-			/*
-			 * No media, so set all parameters to 0 and set the media
-			 * change flag. The I2O device is still valid, just doesn't
-			 * have media, so we don't want to clear the controller or
-			 * device pointer.
-			 */
-		case I2O_EVT_IND_BSA_VOLUME_UNLOAD:
-			{
-				struct gendisk *p = dev->gendisk;
-				blk_queue_max_sectors(dev->gendisk->queue, 0);
-				del_gendisk(p);
-				put_disk(p);
-				dev->gendisk = NULL;
-				dev->media_change_flag = 1;
-				break;
-			}
-
-		case I2O_EVT_IND_BSA_VOLUME_UNLOAD_REQ:
-			printk(KERN_WARNING
-			       "%s: Attempt to eject locked media\n",
-			       dev->i2o_device->dev_name);
-			break;
-
-			/*
-			 * The capacity has changed and we are going to be
-			 * updating the max_sectors and other information
-			 * about this disk.  We try a revalidate first. If
-			 * the block device is in use, we don't want to
-			 * do that as there may be I/Os bound for the disk
-			 * at the moment.  In that case we read the size
-			 * from the device and update the information ourselves
-			 * and the user can later force a partition table
-			 * update through an ioctl.
-			 */
-		case I2O_EVT_IND_BSA_CAPACITY_CHANGE:
-			{
-				u64 size;
-
-				if (i2ob_query_device(dev, 0x0004, 0, &size, 8)
-				    != 0)
-					i2ob_query_device(dev, 0x0000, 4, &size,
-							  8);
-
-				spin_lock_irqsave(dev->req_queue->queue_lock,
-						  flags);
-				set_capacity(dev->gendisk, size >> 9);
-				spin_unlock_irqrestore(dev->req_queue->
-						       queue_lock, flags);
-				break;
-			}
-
-			/*
-			 * We got a SCSI SMART event, we just log the relevant
-			 * information and let the user decide what they want
-			 * to do with the information.
-			 */
-		case I2O_EVT_IND_BSA_SCSI_SMART:
-			{
-				char buf[16];
-				printk(KERN_INFO
-				       "I2O Block: %s received a SCSI SMART Event\n",
-				       dev->i2o_device->dev_name);
-				evt_local->data[16] = '\0';
-				sprintf(buf, "%s", &evt_local->data[0]);
-				printk(KERN_INFO "      Disk Serial#:%s\n",
-				       buf);
-				printk(KERN_INFO "      ASC 0x%02x \n",
-				       evt_local->ASC);
-				printk(KERN_INFO "      ASCQ 0x%02x \n",
-				       evt_local->ASCQ);
-				break;
-			}
-
-			/*
-			 *      Non event
-			 */
-
-		case 0:
-			break;
-
-			/*
-			 * An event we didn't ask for.  Call the card manufacturer
-			 * and tell them to fix their firmware :)
-			 */
-
-		case 0x20:
-			/*
-			 * If a promise card reports 0x20 event then the brown stuff
-			 * hit the fan big time. The card seems to recover but loses
-			 * the pending writes. Deeply ungood except for testing fsck
-			 */
-			if (dev->i2o_device->iop->promise)
-				panic
-				    ("I2O controller firmware failed. Reboot and force a filesystem check.\n");
-		default:
-			printk(KERN_INFO
-			       "%s: Received event 0x%X we didn't register for\n"
-			       KERN_INFO
-			       "   Blame the I2O card manufacturer 8)\n",
-			       dev->i2o_device->dev_name, evt);
-			break;
-		}
-	};
-
-	complete_and_exit(&i2ob_thread_dead, 0);
-	return 0;
-}
-#endif
-
 /*
  *	SCSI-CAM for ioctl geometry mapping
  *	Duplicated with SCSI - this should be moved into somewhere common
@@ -945,8 +777,8 @@
 	struct i2o_block_device *dev = req->rq_disk->private_data;
 	struct i2o_controller *c = dev->i2o_dev->iop;
 	int tid = dev->i2o_dev->lct_data.tid;
-	struct i2o_message *msg;
-	void *mptr;
+	struct i2o_message __iomem *msg;
+	void __iomem *mptr;
 	struct i2o_block_request *ireq = req->special;
 	struct scatterlist *sg;
 	int sgnum;
diff -Nru a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
--- a/drivers/message/i2o/i2o_config.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/message/i2o/i2o_config.c	2004-12-24 13:37:19 -08:00
@@ -50,8 +50,7 @@
 
 extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int);
 
-static spinlock_t i2o_config_lock = SPIN_LOCK_UNLOCKED;
-struct wait_queue *i2o_wait_queue;
+static spinlock_t i2o_config_lock;
 
 #define MODINC(x,y) ((x) = ((x) + 1) % (y))
 
@@ -74,102 +73,12 @@
 static struct i2o_cfg_info *open_files = NULL;
 static ulong i2o_cfg_info_id = 0;
 
-#if 0
-/*
- *	This is the callback for any message we have posted. The message itself
- *	will be returned to the message pool when we return from the IRQ
- *
- *	This runs in irq context so be short and sweet.
- */
-static void i2o_cfg_reply(struct i2o_handler *h, struct i2o_controller *c,
-			  struct i2o_message *m)
-{
-	u32 *msg = (u32 *) m;
-
-	if (msg[0] & MSG_FAIL) {
-		u32 *preserved_msg = (u32 *) (c->msg_virt + msg[7]);
-
-		printk(KERN_ERR "i2o_config: IOP failed to process the msg.\n");
-
-		/* Release the preserved msg frame by resubmitting it as a NOP */
-
-		preserved_msg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
-		preserved_msg[1] = I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | 0;
-		preserved_msg[2] = 0;
-		i2o_post_message(c, msg[7]);
-	}
-
-	if (msg[4] >> 24)	// ReqStatus != SUCCESS
-		i2o_report_status(KERN_INFO, "i2o_config", msg);
-
-	if (m->function == I2O_CMD_UTIL_EVT_REGISTER) {
-		struct i2o_cfg_info *inf;
-
-		for (inf = open_files; inf; inf = inf->next)
-			if (inf->q_id == i2o_cntxt_list_get(c, msg[3]))
-				break;
-
-		//
-		// If this is the case, it means that we're getting
-		// events for a file descriptor that's been close()'d
-		// w/o the user unregistering for events first.
-		// The code currently assumes that the user will
-		// take care of unregistering for events before closing
-		// a file.
-		//
-		// TODO:
-		// Should we track event registartion and deregister
-		// for events when a file is close()'d so this doesn't
-		// happen? That would get rid of the search through
-		// the linked list since file->private_data could point
-		// directly to the i2o_config_info data structure...but
-		// it would mean having all sorts of tables to track
-		// what each file is registered for...I think the
-		// current method is simpler. - DS
-		//
-		if (!inf)
-			return;
-
-		inf->event_q[inf->q_in].id.iop = c->unit;
-		inf->event_q[inf->q_in].id.tid = m->target_tid;
-		inf->event_q[inf->q_in].id.evt_mask = msg[4];
-
-		//
-		// Data size = msg size - reply header
-		//
-		inf->event_q[inf->q_in].data_size = (m->size - 5) * 4;
-		if (inf->event_q[inf->q_in].data_size)
-			memcpy(inf->event_q[inf->q_in].evt_data,
-			       (unsigned char *)(msg + 5),
-			       inf->event_q[inf->q_in].data_size);
-
-		spin_lock(&i2o_config_lock);
-		MODINC(inf->q_in, I2O_EVT_Q_LEN);
-		if (inf->q_len == I2O_EVT_Q_LEN) {
-			MODINC(inf->q_out, I2O_EVT_Q_LEN);
-			inf->q_lost++;
-		} else {
-			// Keep I2OEVTGET on another CPU from touching this
-			inf->q_len++;
-		}
-		spin_unlock(&i2o_config_lock);
-
-//              printk(KERN_INFO "File %p w/id %d has %d events\n",
-//                      inf->fp, inf->q_id, inf->q_len);
-
-		kill_fasync(&inf->fasync, SIGIO, POLL_IN);
-	}
-
-	return;
-}
-#endif
-
 /*
  *	Each of these describes an i2o message handler. They are
  *	multiplexed by the i2o_core code
  */
 
-struct i2o_driver i2o_config_driver = {
+static struct i2o_driver i2o_config_driver = {
 	.name = "Config-OSM"
 };
 
@@ -178,18 +87,17 @@
 	struct i2o_controller *c;
 	u8 __user *user_iop_table = (void __user *)arg;
 	u8 tmp[MAX_I2O_CONTROLLERS];
+	int ret = 0;
 
 	memset(tmp, 0, MAX_I2O_CONTROLLERS);
 
-	if (!access_ok(VERIFY_WRITE, user_iop_table, MAX_I2O_CONTROLLERS))
-		return -EFAULT;
-
 	list_for_each_entry(c, &i2o_controllers, list)
 	    tmp[c->unit] = 1;
 
-	__copy_to_user(user_iop_table, tmp, MAX_I2O_CONTROLLERS);
+	if (copy_to_user(user_iop_table, tmp, MAX_I2O_CONTROLLERS))
+		ret = -EFAULT;
 
-	return 0;
+	return ret;
 };
 
 static int i2o_cfg_gethrt(unsigned long arg)
@@ -338,7 +246,7 @@
 	struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
 	unsigned char maxfrag = 0, curfrag = 1;
 	struct i2o_dma buffer;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	unsigned int status = 0, swlen = 0, fragsize = 8192;
 	struct i2o_controller *c;
@@ -388,7 +296,7 @@
 	writel(0xD0000000 | fragsize, &msg->body[3]);
 	writel(buffer.phys, &msg->body[4]);
 
-//      printk("i2o_config: swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
+//      printk(KERN_INFO "i2o_config: swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
 	status = i2o_msg_post_wait_mem(c, m, 60, &buffer);
 
 	if (status != -ETIMEDOUT)
@@ -412,28 +320,29 @@
 	struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
 	unsigned char maxfrag = 0, curfrag = 1;
 	struct i2o_dma buffer;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	unsigned int status = 0, swlen = 0, fragsize = 8192;
 	struct i2o_controller *c;
+	int ret = 0;
 
 	if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer)))
-		return -EFAULT;
+		goto return_fault;
 
 	if (get_user(swlen, kxfer.swlen) < 0)
-		return -EFAULT;
+		goto return_fault;
 
 	if (get_user(maxfrag, kxfer.maxfrag) < 0)
-		return -EFAULT;
+		goto return_fault;
 
 	if (get_user(curfrag, kxfer.curfrag) < 0)
-		return -EFAULT;
+		goto return_fault;
 
 	if (curfrag == maxfrag)
 		fragsize = swlen - (maxfrag - 1) * 8192;
 
-	if (!kxfer.buf || !access_ok(VERIFY_WRITE, kxfer.buf, fragsize))
-		return -EFAULT;
+	if (!kxfer.buf)
+		goto return_fault;
 
 	c = i2o_find_iop(kxfer.iop);
 	if (!c)
@@ -461,7 +370,7 @@
 	writel(0xD0000000 | fragsize, &msg->body[3]);
 	writel(buffer.phys, &msg->body[4]);
 
-//      printk("i2o_config: swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
+//      printk(KERN_INFO "i2o_config: swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
 	status = i2o_msg_post_wait_mem(c, m, 60, &buffer);
 
 	if (status != I2O_POST_WAIT_OK) {
@@ -474,10 +383,16 @@
 		return status;
 	}
 
-	__copy_to_user(kxfer.buf, buffer.virt, fragsize);
+	if (copy_to_user(kxfer.buf, buffer.virt, fragsize))
+		ret = -EFAULT;
+
 	i2o_dma_free(&c->pdev->dev, &buffer);
 
-	return 0;
+return_ret:
+	return ret;
+return_fault:
+	ret = -EFAULT;
+	goto return_ret;
 };
 
 static int i2o_cfg_swdel(unsigned long arg)
@@ -485,7 +400,7 @@
 	struct i2o_controller *c;
 	struct i2o_sw_xfer kxfer;
 	struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	unsigned int swlen;
 	int token;
@@ -530,7 +445,7 @@
 {
 	int token;
 	int iop = (int)arg;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	struct i2o_controller *c;
 
@@ -561,7 +476,7 @@
 
 static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	struct i2o_evt_id __user *pdesc = (struct i2o_evt_id __user *)arg;
 	struct i2o_evt_id kdesc;
@@ -862,7 +777,7 @@
 	u32 i = 0;
 	void *p = NULL;
 	i2o_status_block *sb;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	unsigned int iop;
 
@@ -1212,6 +1127,8 @@
 {
 	printk(KERN_INFO "I2O configuration manager v 0.04.\n");
 	printk(KERN_INFO "  (C) Copyright 1999 Red Hat Software\n");
+
+	spin_lock_init(&i2o_config_lock);
 
 	if (misc_register(&i2o_miscdev) < 0) {
 		printk(KERN_ERR "i2o_config: can't register device.\n");
diff -Nru a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
--- a/drivers/message/i2o/i2o_proc.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/message/i2o/i2o_proc.c	2004-12-24 13:37:00 -08:00
@@ -290,7 +290,7 @@
 	"CARDBUS"
 };
 
-int i2o_seq_show_hrt(struct seq_file *seq, void *v)
+static int i2o_seq_show_hrt(struct seq_file *seq, void *v)
 {
 	struct i2o_controller *c = (struct i2o_controller *)seq->private;
 	i2o_hrt *hrt = (i2o_hrt *) c->hrt.virt;
@@ -391,7 +391,7 @@
 	return 0;
 }
 
-int i2o_seq_show_lct(struct seq_file *seq, void *v)
+static int i2o_seq_show_lct(struct seq_file *seq, void *v)
 {
 	struct i2o_controller *c = (struct i2o_controller *)seq->private;
 	i2o_lct *lct = (i2o_lct *) c->lct;
@@ -521,7 +521,7 @@
 	return 0;
 }
 
-int i2o_seq_show_status(struct seq_file *seq, void *v)
+static int i2o_seq_show_status(struct seq_file *seq, void *v)
 {
 	struct i2o_controller *c = (struct i2o_controller *)seq->private;
 	char prodstr[25];
@@ -718,7 +718,7 @@
 	return 0;
 }
 
-int i2o_seq_show_hw(struct seq_file *seq, void *v)
+static int i2o_seq_show_hw(struct seq_file *seq, void *v)
 {
 	struct i2o_controller *c = (struct i2o_controller *)seq->private;
 	static u32 work32[5];
@@ -775,7 +775,7 @@
 }
 
 /* Executive group 0003h - Executing DDM List (table) */
-int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
+static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
 {
 	struct i2o_controller *c = (struct i2o_controller *)seq->private;
 	int token;
@@ -851,7 +851,7 @@
 }
 
 /* Executive group 0004h - Driver Store (scalar) */
-int i2o_seq_show_driver_store(struct seq_file *seq, void *v)
+static int i2o_seq_show_driver_store(struct seq_file *seq, void *v)
 {
 	struct i2o_controller *c = (struct i2o_controller *)seq->private;
 	u32 work32[8];
@@ -874,7 +874,7 @@
 }
 
 /* Executive group 0005h - Driver Store Table (table) */
-int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
+static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
 {
 	typedef struct _i2o_driver_store {
 		u16 stored_ddm_index;
@@ -938,11 +938,6 @@
 			seq_printf(seq, "                ");
 		}
 
-#if 0
-		if (c->i2oversion == 0x02)
-			seq_printf(seq, "%-d", dst->module_state);
-#endif
-
 		seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
 		seq_printf(seq, "%-#8x", dst->module_id);
 		seq_printf(seq, "%-29s", chtostr(dst->module_name_version, 28));
@@ -950,10 +945,6 @@
 		seq_printf(seq, "%8d ", dst->module_size);
 		seq_printf(seq, "%8d ", dst->mpb_size);
 		seq_printf(seq, "0x%04x", dst->module_flags);
-#if 0
-		if (c->i2oversion == 0x02)
-			seq_printf(seq, "%d", dst->notification_level);
-#endif
 		seq_printf(seq, "\n");
 	}
 
@@ -962,7 +953,7 @@
 }
 
 /* Generic group F000h - Params Descriptor (table) */
-int i2o_seq_show_groups(struct seq_file *seq, void *v)
+static int i2o_seq_show_groups(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
@@ -1038,7 +1029,7 @@
 }
 
 /* Generic group F001h - Physical Device Table (table) */
-int i2o_seq_show_phys_device(struct seq_file *seq, void *v)
+static int i2o_seq_show_phys_device(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
@@ -1079,7 +1070,7 @@
 }
 
 /* Generic group F002h - Claimed Table (table) */
-int i2o_seq_show_claimed(struct seq_file *seq, void *v)
+static int i2o_seq_show_claimed(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
@@ -1119,7 +1110,7 @@
 }
 
 /* Generic group F003h - User Table (table) */
-int i2o_seq_show_users(struct seq_file *seq, void *v)
+static int i2o_seq_show_users(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
@@ -1173,7 +1164,7 @@
 }
 
 /* Generic group F005h - Private message extensions (table) (optional) */
-int i2o_seq_show_priv_msgs(struct seq_file *seq, void *v)
+static int i2o_seq_show_priv_msgs(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
@@ -1222,7 +1213,7 @@
 }
 
 /* Generic group F006h - Authorized User Table (table) */
-int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
+static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
@@ -1263,7 +1254,7 @@
 }
 
 /* Generic group F100h - Device Identity (scalar) */
-int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
+static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	static u32 work32[128];	// allow for "stuff" + up to 256 byte (max) serial number
@@ -1301,7 +1292,7 @@
 	return 0;
 }
 
-int i2o_seq_show_dev_name(struct seq_file *seq, void *v)
+static int i2o_seq_show_dev_name(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 
@@ -1311,7 +1302,7 @@
 }
 
 /* Generic group F101h - DDM Identity (scalar) */
-int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
+static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
@@ -1348,7 +1339,7 @@
 }
 
 /* Generic group F102h - User Information (scalar) */
-int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
+static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
@@ -1380,7 +1371,7 @@
 }
 
 /* Generic group F103h - SGL Operating Limits (scalar) */
-int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
+static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	static u32 work32[12];
@@ -1427,7 +1418,7 @@
 }
 
 /* Generic group F200h - Sensors (scalar) */
-int i2o_seq_show_sensors(struct seq_file *seq, void *v)
+static int i2o_seq_show_sensors(struct seq_file *seq, void *v)
 {
 	struct i2o_device *d = (struct i2o_device *)seq->private;
 	int token;
diff -Nru a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
--- a/drivers/message/i2o/i2o_scsi.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/message/i2o/i2o_scsi.c	2004-12-24 13:37:18 -08:00
@@ -274,53 +274,6 @@
 	return hostdata->iop->name;
 }
 
-#if 0
-/**
- *	i2o_retry_run		-	retry on timeout
- *	@f: unused
- *
- *	Retry congested frames. This actually needs pushing down into
- *	i2o core. We should only bother the OSM with this when we can't
- *	queue and retry the frame. Or perhaps we should call the OSM
- *	and its default handler should be this in the core, and this
- *	call a 2nd "I give up" handler in the OSM ?
- */
-
-static void i2o_retry_run(unsigned long f)
-{
-	int i;
-	unsigned long flags;
-
-	spin_lock_irqsave(&retry_lock, flags);
-	for (i = 0; i < retry_ct; i++)
-		i2o_post_message(retry_ctrl[i], virt_to_bus(retry[i]));
-	retry_ct = 0;
-	spin_unlock_irqrestore(&retry_lock, flags);
-}
-
-/**
- *	flush_pending		-	empty the retry queue
- *
- *	Turn each of the pending commands into a NOP and post it back
- *	to the controller to clear it.
- */
-
-static void flush_pending(void)
-{
-	int i;
-	unsigned long flags;
-
-	spin_lock_irqsave(&retry_lock, flags);
-	for (i = 0; i < retry_ct; i++) {
-		retry[i][0] &= ~0xFFFFFF;
-		retry[i][0] |= I2O_CMD_UTIL_NOP << 24;
-		i2o_post_message(retry_ctrl[i], virt_to_bus(retry[i]));
-	}
-	retry_ct = 0;
-	spin_unlock_irqrestore(&retry_lock, flags);
-}
-#endif
-
 /**
  *	i2o_scsi_reply - SCSI OSM message reply handler
  *	@c: controller issuing the reply
@@ -343,38 +296,41 @@
 	struct device *dev;
 	u8 as, ds, st;
 
-	cmd = i2o_cntxt_list_get(c, readl(&msg->u.s.tcntxt));
+	cmd = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));
 
 	if (msg->u.head[0] & (1 << 13)) {
-		struct i2o_message *pmsg;	/* preserved message */
+		struct i2o_message __iomem *pmsg;	/* preserved message */
 		u32 pm;
+		int err = DID_ERROR;
 
-		pm = readl(&msg->body[3]);
+		pm = le32_to_cpu(msg->body[3]);
 
-		pmsg = c->in_queue.virt + pm;
+		pmsg = i2o_msg_in_to_virt(c, pm);
 
-		printk("IOP fail.\n");
-		printk("From %d To %d Cmd %d.\n",
+		printk(KERN_ERR "IOP fail.\n");
+		printk(KERN_ERR "From %d To %d Cmd %d.\n",
 		       (msg->u.head[1] >> 12) & 0xFFF,
 		       msg->u.head[1] & 0xFFF, msg->u.head[1] >> 24);
-		printk("Failure Code %d.\n", msg->body[0] >> 24);
+		printk(KERN_ERR "Failure Code %d.\n", msg->body[0] >> 24);
 		if (msg->body[0] & (1 << 16))
-			printk("Format error.\n");
+			printk(KERN_ERR "Format error.\n");
 		if (msg->body[0] & (1 << 17))
-			printk("Path error.\n");
+			printk(KERN_ERR "Path error.\n");
 		if (msg->body[0] & (1 << 18))
-			printk("Path State.\n");
+			printk(KERN_ERR "Path State.\n");
 		if (msg->body[0] & (1 << 18))
-			printk("Congestion.\n");
+		{
+			printk(KERN_ERR "Congestion.\n");
+			err = DID_BUS_BUSY;
+		}
 
-		printk("Failing message is %p.\n", pmsg);
+		printk(KERN_DEBUG "Failing message is %p.\n", pmsg);
 
 		cmd = i2o_cntxt_list_get(c, readl(&pmsg->u.s.tcntxt));
 		if (!cmd)
 			return 1;
 
-		printk("Aborted %ld\n", cmd->serial_number);
-		cmd->result = DID_ERROR << 16;
+		cmd->result = err << 16;
 		cmd->scsi_done(cmd);
 
 		/* Now flush the message by making it a NOP */
@@ -387,9 +343,9 @@
 	 *      Low byte is device status, next is adapter status,
 	 *      (then one byte reserved), then request status.
 	 */
-	ds = (u8) readl(&msg->body[0]);
-	as = (u8) (readl(&msg->body[0]) >> 8);
-	st = (u8) (readl(&msg->body[0]) >> 24);
+	ds = (u8) le32_to_cpu(msg->body[0]);
+	as = (u8) (le32_to_cpu(msg->body[0]) >> 8);
+	st = (u8) (le32_to_cpu(msg->body[0]) >> 24);
 
 	/*
 	 *      Is this a control request coming back - eg an abort ?
@@ -398,7 +354,7 @@
 	if (!cmd) {
 		if (st)
 			printk(KERN_WARNING "SCSI abort: %08X",
-			       readl(&msg->body[0]));
+			       le32_to_cpu(msg->body[0]));
 		printk(KERN_INFO "SCSI abort completed.\n");
 		return -EFAULT;
 	}
@@ -411,21 +367,22 @@
 
 		switch (st) {
 		case 0x06:
-			count = readl(&msg->body[1]);
+			count = le32_to_cpu(msg->body[1]);
 			if (count < cmd->underflow) {
 				int i;
 				printk(KERN_ERR "SCSI: underflow 0x%08X 0x%08X"
 				       "\n", count, cmd->underflow);
-				printk("Cmd: ");
+				printk(KERN_DEBUG "Cmd: ");
 				for (i = 0; i < 15; i++)
-					printk("%02X ", cmd->cmnd[i]);
-				printk(".\n");
+					printk(KERN_DEBUG "%02X ",
+					       cmd->cmnd[i]);
+				printk(KERN_DEBUG ".\n");
 				cmd->result = (DID_ERROR << 16);
 			}
 			break;
 
 		default:
-			error = readl(&msg->body[0]);
+			error = le32_to_cpu(msg->body[0]);
 
 			printk(KERN_ERR "scsi-osm: SCSI error %08x\n", error);
 
@@ -503,7 +460,7 @@
  *	If a I2O controller is added, we catch the notification to add a
  *	corresponding Scsi_Host.
  */
-void i2o_scsi_notify_controller_add(struct i2o_controller *c)
+static void i2o_scsi_notify_controller_add(struct i2o_controller *c)
 {
 	struct i2o_scsi_host *i2o_shost;
 	int rc;
@@ -517,8 +474,7 @@
 
 	rc = scsi_add_host(i2o_shost->scsi_host, &c->device);
 	if (rc) {
-		printk(KERN_ERR "scsi-osm: Could not add SCSI "
-		       "host\n");
+		printk(KERN_ERR "scsi-osm: Could not add SCSI " "host\n");
 		scsi_host_put(i2o_shost->scsi_host);
 		return;
 	}
@@ -536,7 +492,7 @@
  *	If a I2O controller is removed, we catch the notification to remove the
  *	corresponding Scsi_Host.
  */
-void i2o_scsi_notify_controller_remove(struct i2o_controller *c)
+static void i2o_scsi_notify_controller_remove(struct i2o_controller *c)
 {
 	struct i2o_scsi_host *i2o_shost;
 	i2o_shost = i2o_scsi_get_host(c);
@@ -585,10 +541,11 @@
 	struct i2o_device *i2o_dev;
 	struct device *dev;
 	int tid;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	u32 scsi_flags, sg_flags;
-	u32 *mptr, *lenptr;
+	u32 __iomem *mptr;
+	u32 __iomem *lenptr;
 	u32 len, reqlen;
 	int i;
 
@@ -761,11 +718,11 @@
  *	Returns 0 if the command is successfully aborted or negative error code
  *	on failure.
  */
-int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
+static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
 {
 	struct i2o_device *i2o_dev;
 	struct i2o_controller *c;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	int tid;
 	int status = FAILED;
diff -Nru a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
--- a/drivers/message/i2o/iop.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/message/i2o/iop.c	2004-12-24 13:36:47 -08:00
@@ -27,6 +27,7 @@
 
 #include <linux/module.h>
 #include <linux/i2o.h>
+#include <linux/delay.h>
 
 /* global I2O controller list */
 LIST_HEAD(i2o_controllers);
@@ -37,6 +38,8 @@
  */
 static struct i2o_dma i2o_systab;
 
+static int i2o_hrt_get(struct i2o_controller *c);
+
 /* Module internal functions from other sources */
 extern struct i2o_driver i2o_exec_driver;
 extern int i2o_exec_lct_get(struct i2o_controller *);
@@ -62,7 +65,7 @@
  */
 void i2o_msg_nop(struct i2o_controller *c, u32 m)
 {
-	struct i2o_message *msg = c->in_queue.virt + m;
+	struct i2o_message __iomem *msg = c->in_queue.virt + m;
 
 	writel(THREE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
 	writel(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID,
@@ -86,7 +89,7 @@
  *	address from the read port (see the i2o spec). If no message is
  *	available returns I2O_QUEUE_EMPTY and msg is leaved untouched.
  */
-u32 i2o_msg_get_wait(struct i2o_controller *c, struct i2o_message **msg,
+u32 i2o_msg_get_wait(struct i2o_controller *c, struct i2o_message __iomem **msg,
 		     int wait)
 {
 	unsigned long timeout = jiffies + wait * HZ;
@@ -117,7 +120,7 @@
  *
  *	Returns context id > 0 on success or 0 on failure.
  */
-u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr)
+u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
 {
 	struct i2o_context_list_element *entry;
 	unsigned long flags;
@@ -162,7 +165,7 @@
  *
  *	Returns context id on succes or 0 on failure.
  */
-u32 i2o_cntxt_list_remove(struct i2o_controller *c, void *ptr)
+u32 i2o_cntxt_list_remove(struct i2o_controller * c, void *ptr)
 {
 	struct i2o_context_list_element *entry;
 	u32 context = 0;
@@ -303,7 +306,7 @@
  */
 static int i2o_iop_quiesce(struct i2o_controller *c)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	i2o_status_block *sb = c->status_block.virt;
 	int rc;
@@ -345,7 +348,7 @@
  */
 static int i2o_iop_enable(struct i2o_controller *c)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	i2o_status_block *sb = c->status_block.virt;
 	int rc;
@@ -417,7 +420,7 @@
  */
 static int i2o_iop_clear(struct i2o_controller *c)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	int rc;
 
@@ -458,7 +461,7 @@
 static int i2o_iop_reset(struct i2o_controller *c)
 {
 	u8 *status = c->status.virt;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	unsigned long timeout;
 	i2o_status_block *sb = c->status_block.virt;
@@ -470,7 +473,7 @@
 	if (m == I2O_QUEUE_EMPTY)
 		return -ETIMEDOUT;
 
-	memset(status, 0, 4);
+	memset(status, 0, 8);
 
 	/* Quiesce all IOPs first */
 	i2o_iop_quiesce_all();
@@ -495,6 +498,13 @@
 			rc = -ETIMEDOUT;
 			goto exit;
 		}
+
+		/* Promise bug */
+		if (status[1] || status[4]) {
+			*status = 0;
+			break;
+		}
+
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
 
@@ -556,11 +566,11 @@
  *
  *	Returns 0 on success or a negative errno code on failure.
  */
-int i2o_iop_init_outbound_queue(struct i2o_controller *c)
+static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
 {
 	u8 *status = c->status.virt;
 	u32 m;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	ulong timeout;
 	int i;
 
@@ -605,6 +615,7 @@
 	/* Post frames */
 	for (i = 0; i < NMBR_MSG_FRAMES; i++) {
 		i2o_flush_reply(c, m);
+		udelay(1);	/* Promise */
 		m += MSG_FRAME_SIZE * 4;
 	}
 
@@ -612,6 +623,23 @@
 }
 
 /**
+ *	i2o_iop_send_nop - send a core NOP message
+ *	@c: controller
+ *
+ *	Send a no-operation message with a reply set to cause no
+ *	action either. Needed for bringing up promise controllers.
+ */
+static int i2o_iop_send_nop(struct i2o_controller *c)
+{
+	struct i2o_message __iomem *msg;
+	u32 m = i2o_msg_get_wait(c, &msg, HZ);
+	if (m == I2O_QUEUE_EMPTY)
+		return -ETIMEDOUT;
+	i2o_msg_nop(c, m);
+	return 0;
+}
+
+/**
  *	i2o_iop_activate - Bring controller up to HOLD
  *	@c: controller
  *
@@ -622,8 +650,27 @@
  */
 static int i2o_iop_activate(struct i2o_controller *c)
 {
+	struct pci_dev *i960 = NULL;
 	i2o_status_block *sb = c->status_block.virt;
 	int rc;
+
+	if (c->promise) {
+		/* Beat up the hardware first of all */
+		i960 =
+		    pci_find_slot(c->pdev->bus->number,
+				  PCI_DEVFN(PCI_SLOT(c->pdev->devfn), 0));
+		if (i960)
+			pci_write_config_word(i960, 0x42, 0);
+
+		/* Follow this sequence precisely or the controller
+		   ceases to perform useful functions until reboot */
+		if ((rc = i2o_iop_send_nop(c)))
+			return rc;
+
+		if ((rc = i2o_iop_reset(c)))
+			return rc;
+	}
+
 	/* In INIT state, Wait Inbound Q to initialize (in i2o_status_get) */
 	/* In READY state, Get status */
 
@@ -659,13 +706,22 @@
 	if (rc)
 		return rc;
 
+	if (c->promise) {
+		if ((rc = i2o_iop_send_nop(c)))
+			return rc;
+
+		if ((rc = i2o_status_get(c)))
+			return rc;
+
+		if (i960)
+			pci_write_config_word(i960, 0x42, 0x3FF);
+	}
+
 	/* In HOLD state */
 
 	rc = i2o_hrt_get(c);
-	if (rc)
-		return rc;
 
-	return 0;
+	return rc;
 };
 
 /**
@@ -678,7 +734,7 @@
  */
 static int i2o_iop_systab_set(struct i2o_controller *c)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	i2o_status_block *sb = c->status_block.virt;
 	struct device *dev = &c->pdev->dev;
@@ -691,10 +747,11 @@
 		res->flags = IORESOURCE_MEM;
 		res->start = 0;
 		res->end = 0;
-		printk("%s: requires private memory resources.\n", c->name);
+		printk(KERN_INFO "%s: requires private memory resources.\n",
+		       c->name);
 		root = pci_find_parent_resource(c->pdev, res);
 		if (root == NULL)
-			printk("Can't find parent resource!\n");
+			printk(KERN_WARNING "Can't find parent resource!\n");
 		if (root && allocate_resource(root, res, sb->desired_mem_size, sb->desired_mem_size, sb->desired_mem_size, 1 << 20,	/* Unspecified, so use 1Mb and play safe */
 					      NULL, NULL) >= 0) {
 			c->mem_alloc = 1;
@@ -712,10 +769,11 @@
 		res->flags = IORESOURCE_IO;
 		res->start = 0;
 		res->end = 0;
-		printk("%s: requires private memory resources.\n", c->name);
+		printk(KERN_INFO "%s: requires private memory resources.\n",
+		       c->name);
 		root = pci_find_parent_resource(c->pdev, res);
 		if (root == NULL)
-			printk("Can't find parent resource!\n");
+			printk(KERN_WARNING "Can't find parent resource!\n");
 		if (root && allocate_resource(root, res, sb->desired_io_size, sb->desired_io_size, sb->desired_io_size, 1 << 20,	/* Unspecified, so use 1Mb and play safe */
 					      NULL, NULL) >= 0) {
 			c->io_alloc = 1;
@@ -754,7 +812,7 @@
 
 	writel(c->unit + 2, &msg->body[0]);
 	writel(0, &msg->body[1]);
-	writel(0x54000000 | i2o_systab.phys, &msg->body[2]);
+	writel(0x54000000 | i2o_systab.len, &msg->body[2]);
 	writel(i2o_systab.phys, &msg->body[3]);
 	writel(0x54000000 | sb->current_mem_size, &msg->body[4]);
 	writel(sb->current_mem_base, &msg->body[5]);
@@ -939,7 +997,7 @@
  */
 int i2o_status_get(struct i2o_controller *c)
 {
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 	u8 *status_block;
 	unsigned long timeout;
@@ -994,7 +1052,7 @@
  *
  *	Returns 0 on success or negativer error code on failure.
  */
-int i2o_hrt_get(struct i2o_controller *c)
+static int i2o_hrt_get(struct i2o_controller *c)
 {
 	int rc;
 	int i;
@@ -1003,7 +1061,7 @@
 	struct device *dev = &c->pdev->dev;
 
 	for (i = 0; i < I2O_HRT_GET_TRIES; i++) {
-		struct i2o_message *msg;
+		struct i2o_message __iomem *msg;
 		u32 m;
 
 		m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
@@ -1063,13 +1121,13 @@
 	memset(c, 0, sizeof(*c));
 
 	INIT_LIST_HEAD(&c->devices);
-	c->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&c->lock);
 	init_MUTEX(&c->lct_lock);
 	c->unit = unit++;
 	sprintf(c->name, "iop%d", c->unit);
 
 #if BITS_PER_LONG == 64
-	c->context_list_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&c->context_list_lock);
 	atomic_set(&c->context_list_counter, 0);
 	INIT_LIST_HEAD(&c->context_list);
 #endif
@@ -1158,7 +1216,7 @@
 		       int tcntxt, u32 evt_mask)
 {
 	struct i2o_controller *c = dev->iop;
-	struct i2o_message *msg;
+	struct i2o_message __iomem *msg;
 	u32 m;
 
 	m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
@@ -1254,5 +1312,4 @@
 EXPORT_SYMBOL(i2o_iop_find_device);
 EXPORT_SYMBOL(i2o_event_register);
 EXPORT_SYMBOL(i2o_status_get);
-EXPORT_SYMBOL(i2o_hrt_get);
 EXPORT_SYMBOL(i2o_controllers);
diff -Nru a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
--- a/drivers/message/i2o/pci.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/message/i2o/pci.c	2004-12-24 13:36:30 -08:00
@@ -138,13 +138,13 @@
 				 * If we know what card it is, set the size
 				 * correctly. Code is taken from dpt_i2o.c
 				 */
-				if(pdev->device == 0xa501) {
-					if(pdev->subsystem_device >= 0xc032 &&
-					   pdev->subsystem_device <= 0xc03b) {
-						if(c->base.len > 0x400000)
+				if (pdev->device == 0xa501) {
+					if (pdev->subsystem_device >= 0xc032 &&
+					    pdev->subsystem_device <= 0xc03b) {
+						if (c->base.len > 0x400000)
 							c->base.len = 0x400000;
 					} else {
-						if(c->base.len > 0x100000)
+						if (c->base.len > 0x100000)
 							c->base.len = 0x100000;
 					}
 				}
@@ -231,7 +231,7 @@
 	}
 #endif
 
-	if (i2o_dma_alloc(dev, &c->status, 4, GFP_KERNEL)) {
+	if (i2o_dma_alloc(dev, &c->status, 8, GFP_KERNEL)) {
 		i2o_pci_free(c);
 		return -ENOMEM;
 	}
@@ -277,7 +277,6 @@
 	struct device *dev = &c->pdev->dev;
 	struct i2o_message *m;
 	u32 mv;
-	u32 *msg;
 
 	/*
 	 * Old 960 steppings had a bug in the I2O unit that caused
@@ -298,11 +297,7 @@
 		 * Because bus_to_virt is deprecated, we have calculate the
 		 * location by ourself!
 		 */
-		m = (struct i2o_message *)(mv -
-					   (unsigned long)c->out_queue.phys +
-					   (unsigned long)c->out_queue.virt);
-
-		msg = (u32 *) m;
+		m = i2o_msg_out_to_virt(c, mv);
 
 		/*
 		 *      Ensure this message is seen coherently but cachably by
diff -Nru a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h
--- a/drivers/misc/ibmasm/ibmasm.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/misc/ibmasm/ibmasm.h	2004-12-24 13:36:18 -08:00
@@ -158,7 +158,7 @@
 struct service_processor {
 	struct list_head	node;
 	spinlock_t		lock;
-	void 			*base_address;
+	void __iomem		*base_address;
 	unsigned int		irq;
 	struct command		*current_command;
 	struct command		*heartbeat;
diff -Nru a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
--- a/drivers/misc/ibmasm/ibmasmfs.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/misc/ibmasm/ibmasmfs.c	2004-12-24 13:37:04 -08:00
@@ -173,13 +173,8 @@
 {
 	struct dentry *dentry;
 	struct inode *inode;
-	struct qstr qname;
 
-	qname.name = name;
-	qname.len = strlen (name);
-	qname.hash = full_name_hash(name, qname.len);
-
-	dentry = d_alloc(parent, &qname);
+	dentry = d_alloc_name(parent, name);
 	if (!dentry)
 		return NULL;
 
@@ -202,12 +197,8 @@
 {
 	struct dentry *dentry;
 	struct inode *inode;
-	struct qstr qname;
 
-	qname.name = name;
-	qname.len = strlen (name);
-	qname.hash = full_name_hash(name, qname.len);
-	dentry = d_alloc(parent, &qname);
+	dentry = d_alloc_name(parent, name);
 	if (!dentry)
 		return NULL;
 
@@ -520,7 +511,7 @@
 
 static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
 {
-	unsigned long address = (unsigned long)file->private_data;
+	void __iomem *address = (void __iomem *)file->private_data;
 	unsigned char *page;
 	int retval;
 	int len = 0;
@@ -554,7 +545,7 @@
 
 static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
 {
-	unsigned long address = (unsigned long)file->private_data;
+	void __iomem *address = (void __iomem *)file->private_data;
 	char *buff;
 	unsigned int value;
 
diff -Nru a/drivers/misc/ibmasm/lowlevel.c b/drivers/misc/ibmasm/lowlevel.c
--- a/drivers/misc/ibmasm/lowlevel.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/misc/ibmasm/lowlevel.c	2004-12-24 13:37:32 -08:00
@@ -58,7 +58,7 @@
 {
 	u32	mfa;
 	struct service_processor *sp = (struct service_processor *)dev_id;
-	void *base_address = sp->base_address;
+	void __iomem *base_address = sp->base_address;
 
 	if (!sp_interrupt_pending(base_address))
 		return IRQ_NONE;
diff -Nru a/drivers/misc/ibmasm/lowlevel.h b/drivers/misc/ibmasm/lowlevel.h
--- a/drivers/misc/ibmasm/lowlevel.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/misc/ibmasm/lowlevel.h	2004-12-24 13:36:18 -08:00
@@ -52,51 +52,51 @@
 #define SCOUT_COM_C_BASE         0x0200   
 #define SCOUT_COM_D_BASE         0x0300   
 
-static inline int sp_interrupt_pending(void *base_address)
+static inline int sp_interrupt_pending(void __iomem *base_address)
 {
 	return SP_INTR_MASK & readl(base_address + INTR_STATUS_REGISTER);
 }
 
-static inline int uart_interrupt_pending(void *base_address)
+static inline int uart_interrupt_pending(void __iomem *base_address)
 {
 	return UART_INTR_MASK & readl(base_address + INTR_STATUS_REGISTER);
 }
 
-static inline void ibmasm_enable_interrupts(void *base_address, int mask)
+static inline void ibmasm_enable_interrupts(void __iomem *base_address, int mask)
 {
-	void *ctrl_reg = base_address + INTR_CONTROL_REGISTER;
+	void __iomem *ctrl_reg = base_address + INTR_CONTROL_REGISTER;
 	writel( readl(ctrl_reg) & ~mask, ctrl_reg);
 }
 
-static inline void ibmasm_disable_interrupts(void *base_address, int mask)
+static inline void ibmasm_disable_interrupts(void __iomem *base_address, int mask)
 {
-	void *ctrl_reg = base_address + INTR_CONTROL_REGISTER;
+	void __iomem *ctrl_reg = base_address + INTR_CONTROL_REGISTER;
 	writel( readl(ctrl_reg) | mask, ctrl_reg);
 }
 
-static inline void enable_sp_interrupts(void *base_address)
+static inline void enable_sp_interrupts(void __iomem *base_address)
 {
 	ibmasm_enable_interrupts(base_address, SP_INTR_MASK);
 }
 
-static inline void disable_sp_interrupts(void *base_address)
+static inline void disable_sp_interrupts(void __iomem *base_address)
 {
 	ibmasm_disable_interrupts(base_address, SP_INTR_MASK);
 }
 
-static inline void enable_uart_interrupts(void *base_address)
+static inline void enable_uart_interrupts(void __iomem *base_address)
 {
 	ibmasm_enable_interrupts(base_address, UART_INTR_MASK); 
 }
 
-static inline void disable_uart_interrupts(void *base_address)
+static inline void disable_uart_interrupts(void __iomem *base_address)
 {
 	ibmasm_disable_interrupts(base_address, UART_INTR_MASK); 
 }
 
 #define valid_mfa(mfa)	( (mfa) != NO_MFAS_AVAILABLE )
 
-static inline u32 get_mfa_outbound(void *base_address)
+static inline u32 get_mfa_outbound(void __iomem *base_address)
 {
 	int retry;
 	u32 mfa;
@@ -109,12 +109,12 @@
 	return mfa;
 }
 
-static inline void set_mfa_outbound(void *base_address, u32 mfa)
+static inline void set_mfa_outbound(void __iomem *base_address, u32 mfa)
 {
    	writel(mfa, base_address + OUTBOUND_QUEUE_PORT);
 }
 
-static inline u32 get_mfa_inbound(void *base_address)
+static inline u32 get_mfa_inbound(void __iomem *base_address)
 {
 	u32 mfa = readl(base_address + INBOUND_QUEUE_PORT);
 
@@ -124,12 +124,12 @@
 	return mfa;
 }
 
-static inline void set_mfa_inbound(void *base_address, u32 mfa)
+static inline void set_mfa_inbound(void __iomem *base_address, u32 mfa)
 {
    	writel(mfa, base_address + INBOUND_QUEUE_PORT);
 }
 
-static inline struct i2o_message *get_i2o_message(void *base_address, u32 mfa)
+static inline struct i2o_message *get_i2o_message(void __iomem *base_address, u32 mfa)
 {
 	return (struct i2o_message *)(GET_MFA_ADDR(mfa) + base_address);
 }
diff -Nru a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
--- a/drivers/misc/ibmasm/module.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/misc/ibmasm/module.c	2004-12-24 13:37:00 -08:00
@@ -59,13 +59,13 @@
 
 static int __init ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-	int result = -ENOMEM;
+	int err, result = -ENOMEM;
 	struct service_processor *sp;
 
-	if (pci_enable_device(pdev)) {
+	if ((err = pci_enable_device(pdev))) {
 		printk(KERN_ERR "%s: can't enable PCI device at %s\n",
 			DRIVER_NAME, pci_name(pdev));
-		return -ENODEV;
+		return err;
 	}
 
 	sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
@@ -209,10 +209,9 @@
 		return result;
 	}
 	result = pci_register_driver(&ibmasm_driver);
-	if (result <= 0) {
-		pci_unregister_driver(&ibmasm_driver);
+	if (result) {
 		ibmasmfs_unregister();
-		return -ENODEV;
+		return result;
 	}
 	ibmasm_register_panic_notifier();
 	info(DRIVER_DESC " version " DRIVER_VERSION " loaded");
@@ -225,3 +224,4 @@
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
+
diff -Nru a/drivers/misc/ibmasm/uart.c b/drivers/misc/ibmasm/uart.c
--- a/drivers/misc/ibmasm/uart.c	2004-12-24 13:36:35 -08:00
+++ b/drivers/misc/ibmasm/uart.c	2004-12-24 13:36:35 -08:00
@@ -34,7 +34,7 @@
 void ibmasm_register_uart(struct service_processor *sp)
 {
 	struct serial_struct serial;
-	unsigned char *iomem_base;
+	void __iomem *iomem_base;
 
 	iomem_base = sp->base_address + SCOUT_COM_B_BASE;
 
diff -Nru a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
--- a/drivers/mmc/Kconfig	2004-12-24 13:37:43 -08:00
+++ b/drivers/mmc/Kconfig	2004-12-24 13:37:43 -08:00
@@ -49,4 +49,15 @@
 
 	  If unsure, say N.
 
+config MMC_WBSD
+	tristate "Winbond W83L51xD SD/MMC Card Interface support"
+	depends on MMC
+	help
+	  This selects the Winbond(R) W83L51xD Secure digital and
+          Multimedia card Interface.
+	  If you have a machine with a integrated W83L518D or W83L519D
+	  SD/MMC card reader, say Y or M here.
+
+	  If unsure, say N.
+
 endmenu
diff -Nru a/drivers/mmc/Makefile b/drivers/mmc/Makefile
--- a/drivers/mmc/Makefile	2004-12-24 13:37:01 -08:00
+++ b/drivers/mmc/Makefile	2004-12-24 13:37:01 -08:00
@@ -17,5 +17,6 @@
 #
 obj-$(CONFIG_MMC_ARMMMCI)	+= mmci.o
 obj-$(CONFIG_MMC_PXA)		+= pxamci.o
+obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
 
 mmc_core-y := mmc.o mmc_queue.o mmc_sysfs.o
diff -Nru a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
--- a/drivers/mmc/mmc_block.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/mmc/mmc_block.c	2004-12-24 13:37:43 -08:00
@@ -200,6 +200,9 @@
 		}
 		brq.mrq.stop = brq.data.blocks > 1 ? &brq.stop : NULL;
 
+		brq.data.sg = mq->sg;
+		brq.data.sg_len = blk_rq_map_sg(req->q, req, brq.data.sg);
+
 		mmc_wait_for_req(card->host, &brq.mrq);
 		if (brq.cmd.error) {
 			printk(KERN_ERR "%s: error %d sending read/write command\n",
diff -Nru a/drivers/mmc/mmc_queue.c b/drivers/mmc/mmc_queue.c
--- a/drivers/mmc/mmc_queue.c	2004-12-24 13:36:57 -08:00
+++ b/drivers/mmc/mmc_queue.c	2004-12-24 13:36:57 -08:00
@@ -80,7 +80,7 @@
 		set_current_state(TASK_INTERRUPTIBLE);
 		if (!blk_queue_plugged(q))
 			mq->req = req = elv_next_request(q);
-		spin_unlock(q->queue_lock);
+		spin_unlock_irq(q->queue_lock);
 
 		if (!req) {
 			if (mq->flags & MMC_QUEUE_EXIT)
@@ -147,19 +147,31 @@
 	mq->queue->queuedata = mq;
 	mq->req = NULL;
 
+	mq->sg = kmalloc(sizeof(struct scatterlist) * host->max_phys_segs,
+			 GFP_KERNEL);
+	if (!mq->sg) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
 	init_completion(&mq->thread_complete);
 	init_waitqueue_head(&mq->thread_wq);
 	init_MUTEX(&mq->thread_sem);
 
 	ret = kernel_thread(mmc_queue_thread, mq, CLONE_KERNEL);
-	if (ret < 0) {
-		blk_cleanup_queue(mq->queue);
-	} else {
+	if (ret >= 0) {
 		wait_for_completion(&mq->thread_complete);
 		init_completion(&mq->thread_complete);
 		ret = 0;
+		goto out;
 	}
 
+ cleanup:
+	kfree(mq->sg);
+	mq->sg = NULL;
+
+	blk_cleanup_queue(mq->queue);
+ out:
 	return ret;
 }
 EXPORT_SYMBOL(mmc_init_queue);
@@ -169,6 +181,10 @@
 	mq->flags |= MMC_QUEUE_EXIT;
 	wake_up(&mq->thread_wq);
 	wait_for_completion(&mq->thread_complete);
+
+	kfree(mq->sg);
+	mq->sg = NULL;
+
 	blk_cleanup_queue(mq->queue);
 
 	mq->card = NULL;
diff -Nru a/drivers/mmc/mmc_queue.h b/drivers/mmc/mmc_queue.h
--- a/drivers/mmc/mmc_queue.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/mmc/mmc_queue.h	2004-12-24 13:36:18 -08:00
@@ -15,6 +15,7 @@
 	int			(*issue_fn)(struct mmc_queue *, struct request *);
 	void			*data;
 	struct request_queue	*queue;
+	struct scatterlist	*sg;
 };
 
 struct mmc_io_request {
diff -Nru a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
--- a/drivers/mmc/mmci.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/mmc/mmci.c	2004-12-24 13:37:02 -08:00
@@ -69,7 +69,7 @@
 static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
 {
 	unsigned int datactrl, timeout, irqmask;
-	void *base;
+	void __iomem *base;
 
 	DBG(host, "blksz %04x blks %04x flags %08x\n",
 	    1 << data->blksz_bits, data->blocks, data->flags);
@@ -108,7 +108,7 @@
 static void
 mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
 {
-	void *base = host->base;
+	void __iomem *base = host->base;
 
 	DBG(host, "op %02x arg %08x flags %08x\n",
 	    cmd->opcode, cmd->arg, cmd->flags);
@@ -169,7 +169,7 @@
 mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
 	     unsigned int status)
 {
-	void *base = host->base;
+	void __iomem *base = host->base;
 
 	host->cmd = NULL;
 
@@ -193,7 +193,7 @@
 
 static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int remain)
 {
-	void *base = host->base;
+	void __iomem *base = host->base;
 	char *ptr = buffer;
 	u32 status;
 
@@ -222,7 +222,7 @@
 
 static int mmci_pio_write(struct mmci_host *host, char *buffer, unsigned int remain, u32 status)
 {
-	void *base = host->base;
+	void __iomem *base = host->base;
 	char *ptr = buffer;
 
 	do {
@@ -251,7 +251,7 @@
 static irqreturn_t mmci_pio_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct mmci_host *host = dev_id;
-	void *base = host->base;
+	void __iomem *base = host->base;
 	u32 status;
 
 	status = readl(base + MMCISTATUS);
@@ -501,7 +501,7 @@
 	 * We can do SGIO
 	 */
 	mmc->max_hw_segs = 16;
-	mmc->max_phys_segs = 16;
+	mmc->max_phys_segs = NR_SG;
 
 	/*
 	 * Since we only have a 16-bit data length register, we must
diff -Nru a/drivers/mmc/mmci.h b/drivers/mmc/mmci.h
--- a/drivers/mmc/mmci.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/mmc/mmci.h	2004-12-24 13:37:43 -08:00
@@ -120,7 +120,7 @@
 struct clk;
 
 struct mmci_host {
-	void			*base;
+	void __iomem		*base;
 	struct mmc_request	*mrq;
 	struct mmc_command	*cmd;
 	struct mmc_data		*data;
@@ -139,7 +139,6 @@
 	struct timer_list	timer;
 	unsigned int		oldstat;
 
-	struct scatterlist	sg[NR_SG];
 	unsigned int		sg_len;
 
 	/* pio stuff */
@@ -150,14 +149,11 @@
 
 static inline void mmci_init_sg(struct mmci_host *host, struct mmc_data *data)
 {
-	struct scatterlist *sg = host->sg;
-	struct request *req = data->req;
-
 	/*
 	 * Ideally, we want the higher levels to pass us a scatter list.
 	 */
-	host->sg_len = blk_rq_map_sg(req->q, req, sg);
-	host->sg_ptr = sg;
+	host->sg_len = data->sg_len;
+	host->sg_ptr = data->sg;
 	host->sg_off = 0;
 }
 
diff -Nru a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
--- a/drivers/mmc/pxamci.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/mmc/pxamci.c	2004-12-24 13:37:02 -08:00
@@ -44,6 +44,10 @@
 #define DBG(x...)	do { } while (0)
 #endif
 
+#define DRIVER_NAME	"pxa2xx-mci"
+
+#define NR_SG	1
+
 struct pxamci_host {
 	struct mmc_host		*mmc;
 	spinlock_t		lock;
@@ -63,17 +67,11 @@
 
 	dma_addr_t		sg_dma;
 	struct pxa_dma_desc	*sg_cpu;
+	unsigned int		dma_len;
 
-	dma_addr_t		dma_buf;
-	unsigned int		dma_size;
 	unsigned int		dma_dir;
 };
 
-/*
- * The base MMC clock rate
- */
-#define CLOCKRATE	20000000
-
 static inline unsigned int ns_to_clocks(unsigned int ns)
 {
 	return (ns * (CLOCKRATE / 1000000) + 999) / 1000;
@@ -122,8 +120,7 @@
 static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data)
 {
 	unsigned int nob = data->blocks;
-	unsigned int timeout, size;
-	dma_addr_t dma;
+	unsigned int timeout;
 	u32 dcmd;
 	int i;
 
@@ -152,35 +149,22 @@
 
 	dcmd |= DCMD_BURST32 | DCMD_WIDTH1;
 
-	host->dma_size = data->blocks << data->blksz_bits;
-	host->dma_buf = dma_map_single(mmc_dev(host->mmc), data->req->buffer,
-				       host->dma_size, host->dma_dir);
-
-	for (i = 0, size = host->dma_size, dma = host->dma_buf; size; i++) {
-		u32 len = size;
-
-		if (len > DCMD_LENGTH)
-			len = 0x1000;
+	host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
+				   host->dma_dir);
 
+	for (i = 0; i < host->dma_len; i++) {
 		if (data->flags & MMC_DATA_READ) {
 			host->sg_cpu[i].dsadr = host->res->start + MMC_RXFIFO;
-			host->sg_cpu[i].dtadr = dma;
+			host->sg_cpu[i].dtadr = sg_dma_address(&data->sg[i]);
 		} else {
-			host->sg_cpu[i].dsadr = dma;
+			host->sg_cpu[i].dsadr = sg_dma_address(&data->sg[i]);
 			host->sg_cpu[i].dtadr = host->res->start + MMC_TXFIFO;
 		}
-		host->sg_cpu[i].dcmd = dcmd | len;
-
-		dma += len;
-		size -= len;
-
-		if (size) {
-			host->sg_cpu[i].ddadr = host->sg_dma + (i + 1) *
-						 sizeof(struct pxa_dma_desc);
-		} else {
-			host->sg_cpu[i].ddadr = DDADR_STOP;
-		}
+		host->sg_cpu[i].dcmd = dcmd | sg_dma_len(&data->sg[i]);
+		host->sg_cpu[i].ddadr = host->sg_dma + (i + 1) *
+					sizeof(struct pxa_dma_desc);
 	}
+	host->sg_cpu[host->dma_len - 1].ddadr = DDADR_STOP;
 	wmb();
 
 	DDADR(host->dma) = host->sg_dma;
@@ -255,7 +239,24 @@
 	if (stat & STAT_TIME_OUT_RESPONSE) {
 		cmd->error = MMC_ERR_TIMEOUT;
 	} else if (stat & STAT_RES_CRC_ERR && cmd->flags & MMC_RSP_CRC) {
+#ifdef CONFIG_PXA27x
+		/*
+		 * workaround for erratum #42:
+		 * Intel PXA27x Family Processor Specification Update Rev 001
+		 */
+		if (cmd->opcode == MMC_ALL_SEND_CID ||
+		    cmd->opcode == MMC_SEND_CSD ||
+		    cmd->opcode == MMC_SEND_CID) {
+			/* a bogus CRC error can appear if the msb of
+			   the 15 byte response is a one */
+			if ((cmd->resp[0] & 0x80000000) == 0)
+				cmd->error = MMC_ERR_BADCRC;
+		} else {
+			DBG("ignoring CRC from command %d - *risky*\n",cmd->opcode);
+		}
+#else
 		cmd->error = MMC_ERR_BADCRC;
+#endif
 	}
 
 	pxamci_disable_irq(host, END_CMD_RES);
@@ -276,8 +277,8 @@
 		return 0;
 
 	DCSR(host->dma) = 0;
-	dma_unmap_single(mmc_dev(host->mmc), host->dma_buf, host->dma_size,
-			 host->dma_dir);
+	dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len,
+		     host->dma_dir);
 
 	if (stat & STAT_READ_TIME_OUT)
 		data->error = MMC_ERR_TIMEOUT;
@@ -374,15 +375,14 @@
 		if (CLOCKRATE / clk > ios->clock)
 			clk <<= 1;
 		host->clkrt = fls(clk) - 1;
+		pxa_set_cken(CKEN12_MMC, 1);
 
 		/*
 		 * we write clkrt on the next command
 		 */
-	} else if (readl(host->base + MMC_STAT) & STAT_CLK_EN) {
-		/*
-		 * Ensure that the clock is off.
-		 */
-		writel(STOP_CLOCK, host->base + MMC_STRPCL);
+	} else {
+		pxamci_stop_clock(host);
+		pxa_set_cken(CKEN12_MMC, 0);
 	}
 
 	if (host->power_mode != ios->power_mode) {
@@ -429,7 +429,7 @@
 	if (!r || irq == NO_IRQ)
 		return -ENXIO;
 
-	r = request_mem_region(r->start, SZ_4K, "PXAMCI");
+	r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
 	if (!r)
 		return -EBUSY;
 
@@ -440,8 +440,19 @@
 	}
 
 	mmc->ops = &pxamci_ops;
-	mmc->f_min = 312500;
-	mmc->f_max = 20000000;
+	mmc->f_min = CLOCKRATE_MIN;
+	mmc->f_max = CLOCKRATE_MAX;
+
+	/*
+	 * We can do SG-DMA, but we don't because we never know how much
+	 * data we successfully wrote to the card.
+	 */
+	mmc->max_phys_segs = NR_SG;
+
+	/*
+	 * Our hardware DMA can handle a maximum of one page per SG entry.
+	 */
+	mmc->max_seg_size = PAGE_SIZE;
 
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
@@ -460,8 +471,7 @@
 	spin_lock_init(&host->lock);
 	host->res = r;
 	host->irq = irq;
-	host->imask = TXFIFO_WR_REQ|RXFIFO_RD_REQ|CLK_IS_OFF|STOP_CMD|
-		      END_CMD_RES|PRG_DONE|DATA_TRAN_DONE;
+	host->imask = MMC_I_MASK_ALL;
 
 	host->base = ioremap(r->start, SZ_4K);
 	if (!host->base) {
@@ -478,17 +488,14 @@
 	writel(64, host->base + MMC_RESTO);
 	writel(host->imask, host->base + MMC_I_MASK);
 
-	pxa_gpio_mode(GPIO6_MMCCLK_MD);
-	pxa_gpio_mode(GPIO8_MMCCS0_MD);
-	pxa_set_cken(CKEN12_MMC, 1);
-
-	host->dma = pxa_request_dma("PXAMCI", DMA_PRIO_LOW, pxamci_dma_irq, host);
+	host->dma = pxa_request_dma(DRIVER_NAME, DMA_PRIO_LOW,
+				    pxamci_dma_irq, host);
 	if (host->dma < 0) {
 		ret = -EBUSY;
 		goto out;
 	}
 
-	ret = request_irq(host->irq, pxamci_irq, 0, "PXAMCI", host);
+	ret = request_irq(host->irq, pxamci_irq, 0, DRIVER_NAME, host);
 	if (ret)
 		goto out;
 
@@ -535,15 +542,14 @@
 		       END_CMD_RES|PRG_DONE|DATA_TRAN_DONE,
 		       host->base + MMC_I_MASK);
 
-		pxa_set_cken(CKEN12_MMC, 0);
+		DRCMRRXMMC = 0;
+		DRCMRTXMMC = 0;
 
 		free_irq(host->irq, host);
 		pxa_free_dma(host->dma);
 		iounmap(host->base);
 		dma_free_coherent(dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
 
-		pxa_set_cken(CKEN12_MMC, 0);
-
 		release_resource(host->res);
 
 		mmc_free_host(mmc);
@@ -579,7 +585,7 @@
 #endif
 
 static struct device_driver pxamci_driver = {
-	.name		= "pxa2xx-mci",
+	.name		= DRIVER_NAME,
 	.bus		= &platform_bus_type,
 	.probe		= pxamci_probe,
 	.remove		= pxamci_remove,
diff -Nru a/drivers/mmc/pxamci.h b/drivers/mmc/pxamci.h
--- a/drivers/mmc/pxamci.h	2004-12-24 13:36:33 -08:00
+++ b/drivers/mmc/pxamci.h	2004-12-24 13:36:33 -08:00
@@ -70,6 +70,16 @@
 #define BUF_PART_FULL		(1 << 0)
 
 #define MMC_I_MASK	0x0028
+
+/*PXA27x MMC interrupts*/
+#define SDIO_SUSPEND_ACK  	(1 << 12)
+#define SDIO_INT          	(1 << 11)
+#define RD_STALLED        	(1 << 10)
+#define RES_ERR           	(1 << 9)
+#define DAT_ERR           	(1 << 8)
+#define TINT              	(1 << 7)
+
+/*PXA2xx MMC interrupts*/
 #define TXFIFO_WR_REQ		(1 << 6)
 #define RXFIFO_RD_REQ		(1 << 5)
 #define CLK_IS_OFF		(1 << 4)
@@ -78,6 +88,12 @@
 #define PRG_DONE		(1 << 1)
 #define DATA_TRAN_DONE		(1 << 0)
 
+#ifdef CONFIG_PXA27x
+#define MMC_I_MASK_ALL          0x00001fff
+#else
+#define MMC_I_MASK_ALL          0x0000007f
+#endif
+
 #define MMC_I_REG	0x002c
 /* same as MMC_I_MASK */
 
@@ -92,3 +108,17 @@
 #define MMC_RXFIFO	0x0040	/* 8 bit */
 
 #define MMC_TXFIFO	0x0044	/* 8 bit */
+
+/*
+ * The base MMC clock rate
+ */
+#ifdef CONFIG_PXA27x
+#define CLOCKRATE_MIN	304688
+#define CLOCKRATE_MAX	19500000
+#else
+#define CLOCKRATE_MIN	312500
+#define CLOCKRATE_MAX	20000000
+#endif
+
+#define CLOCKRATE	CLOCKRATE_MAX
+
diff -Nru a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mmc/wbsd.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1596 @@
+/*
+ *  linux/drivers/mmc/wbsd.c
+ *
+ *  Copyright (C) 2004 Pierre Ossman, 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 version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/blkdev.h>
+
+#include <linux/mmc/host.h>
+#include <linux/mmc/protocol.h>
+
+#include <asm/io.h>
+#include <asm/dma.h>
+
+#include "wbsd.h"
+
+#define DRIVER_NAME "wbsd"
+#define DRIVER_VERSION "1.0"
+
+#ifdef CONFIG_MMC_DEBUG
+#define DBG(x...) \
+	printk(KERN_DEBUG DRIVER_NAME ": " x)
+#define DBGF(f, x...) \
+	printk(KERN_DEBUG DRIVER_NAME " [%s()]: " f, __func__, ##x)
+#else
+#define DBG(x...)	do { } while (0)
+#define DBGF(x...)	do { } while (0)
+#endif
+
+static unsigned int io = 0x248;
+static unsigned int irq = 6;
+static int dma = 2;
+
+#ifdef CONFIG_MMC_DEBUG
+void DBG_REG(int reg, u8 value)
+{
+	int i;
+	
+	printk(KERN_DEBUG "wbsd: Register %d: 0x%02X %3d '%c' ",
+		reg, (int)value, (int)value, (value < 0x20)?'.':value);
+	
+	for (i = 7;i >= 0;i--)
+	{
+		if (value & (1 << i))
+			printk("x");
+		else
+			printk(".");
+	}
+	
+	printk("\n");
+}
+#else
+#define DBG_REG(r, v) do {}  while (0)
+#endif
+
+/*
+ * Basic functions
+ */
+
+static inline void wbsd_unlock_config(struct wbsd_host* host)
+{
+	outb(host->unlock_code, host->config);
+	outb(host->unlock_code, host->config);
+}
+
+static inline void wbsd_lock_config(struct wbsd_host* host)
+{
+	outb(LOCK_CODE, host->config);
+}
+
+static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value)
+{
+	outb(reg, host->config);
+	outb(value, host->config + 1);
+}
+
+static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg)
+{
+	outb(reg, host->config);
+	return inb(host->config + 1);
+}
+
+static inline void wbsd_write_index(struct wbsd_host* host, u8 index, u8 value)
+{
+	outb(index, host->base + WBSD_IDXR);
+	outb(value, host->base + WBSD_DATAR);
+}
+
+static inline u8 wbsd_read_index(struct wbsd_host* host, u8 index)
+{
+	outb(index, host->base + WBSD_IDXR);
+	return inb(host->base + WBSD_DATAR);
+}
+
+/*
+ * Common routines
+ */
+
+static void wbsd_init_device(struct wbsd_host* host)
+{
+	u8 setup, ier;
+	
+	/*
+	 * Reset chip (SD/MMC part) and fifo.
+	 */
+	setup = wbsd_read_index(host, WBSD_IDX_SETUP);
+	setup |= WBSD_FIFO_RESET | WBSD_SOFT_RESET;
+	wbsd_write_index(host, WBSD_IDX_SETUP, setup);
+	
+	/*
+	 * Read back default clock.
+	 */
+	host->clk = wbsd_read_index(host, WBSD_IDX_CLK);
+
+	/*
+	 * Power down port.
+	 */
+	outb(WBSD_POWER_N, host->base + WBSD_CSR);
+	
+	/*
+	 * Set maximum timeout.
+	 */
+	wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F);
+	
+	/*
+	 * Enable interesting interrupts.
+	 */
+	ier = 0;
+	ier |= WBSD_EINT_CARD;
+	ier |= WBSD_EINT_FIFO_THRE;
+	ier |= WBSD_EINT_CCRC;
+	ier |= WBSD_EINT_TIMEOUT;
+	ier |= WBSD_EINT_CRC;
+	ier |= WBSD_EINT_TC;
+
+	outb(ier, host->base + WBSD_EIR);
+
+	/*
+	 * Clear interrupts.
+	 */
+	inb(host->base + WBSD_ISR);
+}
+
+static void wbsd_reset(struct wbsd_host* host)
+{
+	u8 setup;
+	
+	printk(KERN_ERR DRIVER_NAME ": Resetting chip\n");
+	
+	/*
+	 * Soft reset of chip (SD/MMC part).
+	 */
+	setup = wbsd_read_index(host, WBSD_IDX_SETUP);
+	setup |= WBSD_SOFT_RESET;
+	wbsd_write_index(host, WBSD_IDX_SETUP, setup);
+}
+
+static void wbsd_request_end(struct wbsd_host* host, struct mmc_request* mrq)
+{
+	unsigned long dmaflags;
+	
+	DBGF("Ending request, cmd (%x)\n", mrq->cmd->opcode);
+	
+	if (host->dma >= 0)
+	{
+		/*
+		 * Release ISA DMA controller.
+		 */
+		dmaflags = claim_dma_lock();
+		disable_dma(host->dma);
+		clear_dma_ff(host->dma);
+		release_dma_lock(dmaflags);
+
+		/*
+		 * Disable DMA on host.
+		 */
+		wbsd_write_index(host, WBSD_IDX_DMA, 0);
+	}
+	
+	host->mrq = NULL;
+
+	/*
+	 * MMC layer might call back into the driver so first unlock.
+	 */
+	spin_unlock(&host->lock);
+	mmc_request_done(host->mmc, mrq);
+	spin_lock(&host->lock);
+}
+
+/*
+ * Scatter/gather functions
+ */
+
+static inline void wbsd_init_sg(struct wbsd_host* host, struct mmc_data* data)
+{
+	struct request* req = data->req;
+	
+	/*
+	 * Get info. about SG list from data structure.
+	 */
+	host->cur_sg = data->sg;
+	host->num_sg = data->sg_len;
+
+	host->offset = 0;
+	host->remain = host->cur_sg->length;
+}
+
+static inline int wbsd_next_sg(struct wbsd_host* host)
+{
+	/*
+	 * Skip to next SG entry.
+	 */
+	host->cur_sg++;
+	host->num_sg--;
+
+	/*
+	 * Any entries left?
+	 */
+	if (host->num_sg > 0)
+	  {
+	    host->offset = 0;
+	    host->remain = host->cur_sg->length;
+	  }
+	
+	return host->num_sg;
+}
+
+static inline char* wbsd_kmap_sg(struct wbsd_host* host)
+{
+	return kmap_atomic(host->cur_sg->page, KM_BIO_SRC_IRQ) +
+		host->cur_sg->offset;
+}
+
+static inline void wbsd_kunmap_sg(struct wbsd_host* host)
+{
+	kunmap_atomic(host->cur_sg->page, KM_BIO_SRC_IRQ);
+}
+
+static inline void wbsd_sg_to_dma(struct wbsd_host* host, struct mmc_data* data)
+{
+	unsigned int len, i, size;
+	struct scatterlist* sg;
+	char* dmabuf = host->dma_buffer;
+	char* sgbuf;
+	
+	size = host->size;
+	
+	sg = data->sg;
+	len = data->sg_len;
+	
+	/*
+	 * Just loop through all entries. Size might not
+	 * be the entire list though so make sure that
+	 * we do not transfer too much.
+	 */
+	for (i = 0;i < len;i++)
+	{
+		sgbuf = kmap_atomic(sg[i].page, KM_BIO_SRC_IRQ) + sg[i].offset;
+		if (size < sg[i].length)
+			memcpy(dmabuf, sgbuf, size);
+		else
+			memcpy(dmabuf, sgbuf, sg[i].length);
+		kunmap_atomic(sg[i].page, KM_BIO_SRC_IRQ);
+		dmabuf += sg[i].length;
+		
+		if (size < sg[i].length)
+			size = 0;
+		else
+			size -= sg[i].length;
+	
+		if (size == 0)
+			break;
+	}
+	
+	/*
+	 * Check that we didn't get a request to transfer
+	 * more data than can fit into the SG list.
+	 */
+	
+	BUG_ON(size != 0);
+	
+	host->size -= size;
+}
+
+static inline void wbsd_dma_to_sg(struct wbsd_host* host, struct mmc_data* data)
+{
+	unsigned int len, i, size;
+	struct scatterlist* sg;
+	char* dmabuf = host->dma_buffer;
+	char* sgbuf;
+	
+	size = host->size;
+	
+	sg = data->sg;
+	len = data->sg_len;
+	
+	/*
+	 * Just loop through all entries. Size might not
+	 * be the entire list though so make sure that
+	 * we do not transfer too much.
+	 */
+	for (i = 0;i < len;i++)
+	{
+		sgbuf = kmap_atomic(sg[i].page, KM_BIO_SRC_IRQ) + sg[i].offset;
+		if (size < sg[i].length)
+			memcpy(sgbuf, dmabuf, size);
+		else
+			memcpy(sgbuf, dmabuf, sg[i].length);
+		kunmap_atomic(sg[i].page, KM_BIO_SRC_IRQ);
+		dmabuf += sg[i].length;
+		
+		if (size < sg[i].length)
+			size = 0;
+		else
+			size -= sg[i].length;
+		
+		if (size == 0)
+			break;
+	}
+	
+	/*
+	 * Check that we didn't get a request to transfer
+	 * more data than can fit into the SG list.
+	 */
+	
+	BUG_ON(size != 0);
+	
+	host->size -= size;
+}
+
+/*
+ * Command handling
+ */
+ 
+static inline void wbsd_get_short_reply(struct wbsd_host* host,
+	struct mmc_command* cmd)
+{
+	/*
+	 * Correct response type?
+	 */
+	if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_SHORT)
+	{
+		cmd->error = MMC_ERR_INVALID;
+		return;
+	}
+	
+	cmd->resp[0] =
+		wbsd_read_index(host, WBSD_IDX_RESP12) << 24;
+	cmd->resp[0] |=
+		wbsd_read_index(host, WBSD_IDX_RESP13) << 16;
+	cmd->resp[0] |=
+		wbsd_read_index(host, WBSD_IDX_RESP14) << 8;
+	cmd->resp[0] |=
+		wbsd_read_index(host, WBSD_IDX_RESP15) << 0;
+	cmd->resp[1] =
+		wbsd_read_index(host, WBSD_IDX_RESP16) << 24;
+}
+
+static inline void wbsd_get_long_reply(struct wbsd_host* host,
+	struct mmc_command* cmd)
+{
+	int i;
+	
+	/*
+	 * Correct response type?
+	 */
+	if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_LONG)
+	{
+		cmd->error = MMC_ERR_INVALID;
+		return;
+	}
+	
+	for (i = 0;i < 4;i++)
+	{
+		cmd->resp[i] =
+			wbsd_read_index(host, WBSD_IDX_RESP1 + i * 4) << 24;
+		cmd->resp[i] |=
+			wbsd_read_index(host, WBSD_IDX_RESP2 + i * 4) << 16;
+		cmd->resp[i] |=
+			wbsd_read_index(host, WBSD_IDX_RESP3 + i * 4) << 8;
+		cmd->resp[i] |=
+			wbsd_read_index(host, WBSD_IDX_RESP4 + i * 4) << 0;
+	}
+}
+
+static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs);
+
+static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd)
+{
+	int i;
+	u8 status, eir, isr;
+	
+	DBGF("Sending cmd (%x)\n", cmd->opcode);
+
+	/*
+	 * Disable interrupts as the interrupt routine
+	 * will destroy the contents of ISR.
+	 */
+	eir = inb(host->base + WBSD_EIR);
+	outb(0, host->base + WBSD_EIR);
+	
+	/*
+	 * Send the command (CRC calculated by host).
+	 */
+	outb(cmd->opcode, host->base + WBSD_CMDR);
+	for (i = 3;i >= 0;i--)
+		outb((cmd->arg >> (i * 8)) & 0xff, host->base + WBSD_CMDR);
+	
+	cmd->error = MMC_ERR_NONE;
+	
+	/*
+	 * Wait for the request to complete.
+	 */
+	do {
+		status = wbsd_read_index(host, WBSD_IDX_STATUS);
+	} while (status & WBSD_CARDTRAFFIC);
+
+	/*
+	 * Do we expect a reply?
+	 */
+	if ((cmd->flags & MMC_RSP_MASK) != MMC_RSP_NONE)
+	{
+		/*
+		 * Read back status.
+		 */
+		isr = inb(host->base + WBSD_ISR);
+		
+		/* Card removed? */
+		if (isr & WBSD_INT_CARD)
+			cmd->error = MMC_ERR_TIMEOUT;
+		/* Timeout? */
+		else if (isr & WBSD_INT_TIMEOUT)
+			cmd->error = MMC_ERR_TIMEOUT;
+		/* CRC? */
+		else if ((cmd->flags & MMC_RSP_CRC) && (isr & WBSD_INT_CRC))
+			cmd->error = MMC_ERR_BADCRC;
+		/* All ok */
+		else
+		{
+			if ((cmd->flags & MMC_RSP_MASK) == MMC_RSP_SHORT)
+				wbsd_get_short_reply(host, cmd);
+			else
+				wbsd_get_long_reply(host, cmd);
+		}
+	}
+
+	/*
+	 * Restore interrupt mask to previous value.
+	 */
+	outb(eir, host->base + WBSD_EIR);
+	
+	/*
+	 * Call the interrupt routine to jump start
+	 * interrupts.
+	 */
+	wbsd_irq(0, host, NULL);
+
+	DBGF("Sent cmd (%x), res %d\n", cmd->opcode, cmd->error);
+}
+
+/*
+ * Data functions
+ */
+
+static void wbsd_empty_fifo(struct wbsd_host* host)
+{
+	struct mmc_data* data = host->mrq->cmd->data;
+	char* buffer;
+	
+	/*
+	 * Handle excessive data.
+	 */
+	if (data->bytes_xfered == host->size)
+		return;
+	
+	buffer = wbsd_kmap_sg(host) + host->offset;
+
+	/*
+	 * Drain the fifo. This has a tendency to loop longer
+	 * than the FIFO length (usually one block).
+	 */
+	while (!(inb(host->base + WBSD_FSR) & WBSD_FIFO_EMPTY))
+	{
+		*buffer = inb(host->base + WBSD_DFR);
+		buffer++;
+		host->offset++;
+		host->remain--;
+
+		data->bytes_xfered++;
+		
+		/*
+		 * Transfer done?
+		 */
+		if (data->bytes_xfered == host->size)
+		{
+			wbsd_kunmap_sg(host);				
+			return;
+		}
+		
+		/*
+		 * End of scatter list entry?
+		 */
+		if (host->remain == 0)
+		{
+			wbsd_kunmap_sg(host);
+			
+			/*
+			 * Get next entry. Check if last.
+			 */
+			if (!wbsd_next_sg(host))
+			{
+				/*
+				 * We should never reach this point.
+				 * It means that we're trying to
+				 * transfer more blocks than can fit
+				 * into the scatter list.
+				 */
+				BUG_ON(1);
+				
+				host->size = data->bytes_xfered;
+				
+				return;
+			}
+			
+			buffer = wbsd_kmap_sg(host);
+		}
+	}
+	
+	wbsd_kunmap_sg(host);
+}
+
+static void wbsd_fill_fifo(struct wbsd_host* host)
+{
+	struct mmc_data* data = host->mrq->cmd->data;
+	char* buffer;
+	
+	/*
+	 * Check that we aren't being called after the
+	 * entire buffer has been transfered.
+	 */
+	if (data->bytes_xfered == host->size)
+		return;
+
+	buffer = wbsd_kmap_sg(host) + host->offset;
+
+	/*
+	 * Fill the fifo. This has a tendency to loop longer
+	 * than the FIFO length (usually one block).
+	 */
+	while (!(inb(host->base + WBSD_FSR) & WBSD_FIFO_FULL))
+	{
+		outb(*buffer, host->base + WBSD_DFR);
+		buffer++;
+		host->offset++;
+		host->remain--;
+		
+		data->bytes_xfered++;
+		
+		/*
+		 * Transfer done?
+		 */
+		if (data->bytes_xfered == host->size)
+		{
+			wbsd_kunmap_sg(host);
+			return;
+		}
+
+		/*
+		 * End of scatter list entry?
+		 */
+		if (host->remain == 0)
+		{
+			wbsd_kunmap_sg(host);
+			
+			/*
+			 * Get next entry. Check if last.
+			 */
+			if (!wbsd_next_sg(host))
+			{
+				/*
+				 * We should never reach this point.
+				 * It means that we're trying to
+				 * transfer more blocks than can fit
+				 * into the scatter list.
+				 */
+				BUG_ON(1);
+				
+				host->size = data->bytes_xfered;
+				
+				return;
+			}
+			
+			buffer = wbsd_kmap_sg(host);
+		}
+	}
+	
+	wbsd_kunmap_sg(host);
+}
+
+static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data)
+{
+	u16 blksize;
+	u8 setup;
+	unsigned long dmaflags;
+
+	DBGF("blksz %04x blks %04x flags %08x\n",
+		1 << data->blksz_bits, data->blocks, data->flags);
+	DBGF("tsac %d ms nsac %d clk\n",
+		data->timeout_ns / 1000000, data->timeout_clks);
+	
+	/*
+	 * Calculate size.
+	 */
+	host->size = data->blocks << data->blksz_bits;
+
+	/*
+	 * Check timeout values for overflow.
+	 * (Yes, some cards cause this value to overflow).
+	 */
+	if (data->timeout_ns > 127000000)
+		wbsd_write_index(host, WBSD_IDX_TAAC, 127);
+	else
+		wbsd_write_index(host, WBSD_IDX_TAAC, data->timeout_ns/1000000);
+	
+	if (data->timeout_clks > 255)
+		wbsd_write_index(host, WBSD_IDX_NSAC, 255);
+	else
+		wbsd_write_index(host, WBSD_IDX_NSAC, data->timeout_clks);
+	
+	/*
+	 * Inform the chip of how large blocks will be
+	 * sent. It needs this to determine when to
+	 * calculate CRC.
+	 *
+	 * Space for CRC must be included in the size.
+	 */
+	blksize = (1 << data->blksz_bits) + 2;
+	
+	wbsd_write_index(host, WBSD_IDX_PBSMSB, (blksize >> 4) & 0xF0);
+	wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
+
+	/*
+	 * Clear the FIFO. This is needed even for DMA
+	 * transfers since the chip still uses the FIFO
+	 * internally.
+	 */
+	setup = wbsd_read_index(host, WBSD_IDX_SETUP);
+	setup |= WBSD_FIFO_RESET;
+	wbsd_write_index(host, WBSD_IDX_SETUP, setup);
+	
+	/*
+	 * DMA transfer?
+	 */
+	if (host->dma >= 0)
+	{	
+		/*
+		 * The buffer for DMA is only 64 kB.
+		 */
+		BUG_ON(host->size > 0x10000);
+		if (host->size > 0x10000)
+		{
+			data->error = MMC_ERR_INVALID;
+			return;
+		}
+		
+		/*
+		 * Transfer data from the SG list to
+		 * the DMA buffer.
+		 */
+		if (data->flags & MMC_DATA_WRITE)
+			wbsd_sg_to_dma(host, data);
+		
+		/*
+		 * Initialise the ISA DMA controller.
+		 */	
+		dmaflags = claim_dma_lock();
+		disable_dma(host->dma);
+		clear_dma_ff(host->dma);
+		if (data->flags & MMC_DATA_READ)
+			set_dma_mode(host->dma, DMA_MODE_READ);
+		else
+			set_dma_mode(host->dma, DMA_MODE_WRITE);
+		set_dma_addr(host->dma, host->dma_addr);
+		set_dma_count(host->dma, host->size);
+
+		enable_dma(host->dma);
+		release_dma_lock(dmaflags);
+
+		/*
+		 * Enable DMA on the host.
+		 */
+		wbsd_write_index(host, WBSD_IDX_DMA,
+			WBSD_DMA_SINGLE | WBSD_DMA_ENABLE);
+	}
+	else
+	{
+		/*
+		 * This flag is used to keep printk
+		 * output to a minimum.
+		 */
+		host->firsterr = 1;
+		
+		/*
+		 * Initialise the SG list.
+		 */
+		wbsd_init_sg(host, data);
+	
+		/*
+		 * Turn off DMA.
+		 */
+		wbsd_write_index(host, WBSD_IDX_DMA, 0);
+	
+		/*
+		 * Set up FIFO threshold levels (and fill
+		 * buffer if doing a write).
+		 */
+		if (data->flags & MMC_DATA_READ)
+		{
+			wbsd_write_index(host, WBSD_IDX_FIFOEN,
+				WBSD_FIFOEN_FULL | 8);
+		}
+		else
+		{
+			wbsd_write_index(host, WBSD_IDX_FIFOEN,
+				WBSD_FIFOEN_EMPTY | 8);
+			wbsd_fill_fifo(host);
+		}
+	}	
+		
+	data->error = MMC_ERR_NONE;
+}
+
+static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data)
+{
+	unsigned long dmaflags;
+	int count;
+	
+	WARN_ON(host->mrq == NULL);
+
+	/*
+	 * Send a stop command if needed.
+	 */
+	if (data->stop)
+		wbsd_send_command(host, data->stop);
+	
+	/*
+	 * DMA transfer?
+	 */
+	if (host->dma >= 0)
+	{
+		/*
+		 * Disable DMA on the host.
+		 */
+		wbsd_write_index(host, WBSD_IDX_DMA, 0);
+		
+		/*
+		 * Turn of ISA DMA controller.
+		 */
+		dmaflags = claim_dma_lock();
+		disable_dma(host->dma);
+		clear_dma_ff(host->dma);
+		count = get_dma_residue(host->dma);
+		release_dma_lock(dmaflags);
+		
+		/*
+		 * Any leftover data?
+		 */
+		if (count)
+		{
+			printk(KERN_ERR DRIVER_NAME ": Incomplete DMA "
+				"transfer. %d bytes left.\n", count);
+			
+			data->error = MMC_ERR_FAILED;
+		}
+		else
+		{
+			/*
+			 * Transfer data from DMA buffer to
+			 * SG list.
+			 */
+			if (data->flags & MMC_DATA_READ)
+				wbsd_dma_to_sg(host, data);
+			
+			data->bytes_xfered = host->size;
+		}
+	}
+	
+	DBGF("Ending data transfer (%d bytes)\n", data->bytes_xfered);
+	
+	wbsd_request_end(host, host->mrq);
+}
+
+/*
+ * MMC Callbacks
+ */
+
+static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq)
+{
+	struct wbsd_host* host = mmc_priv(mmc);
+	struct mmc_command* cmd;
+
+	/*
+	 * Disable tasklets to avoid a deadlock.
+	 */
+	spin_lock_bh(&host->lock);
+
+	BUG_ON(host->mrq != NULL);
+
+	cmd = mrq->cmd;
+
+	host->mrq = mrq;
+	
+	/*
+	 * If there is no card in the slot then
+	 * timeout immediatly.
+	 */
+	if (!(inb(host->base + WBSD_CSR) & WBSD_CARDPRESENT))
+	{
+		cmd->error = MMC_ERR_TIMEOUT;
+		goto done;
+	}
+
+	/*
+	 * Does the request include data?
+	 */
+	if (cmd->data)
+	{
+		wbsd_prepare_data(host, cmd->data);
+		
+		if (cmd->data->error != MMC_ERR_NONE)
+			goto done;
+	}
+	
+	wbsd_send_command(host, cmd);
+
+	/*
+	 * If this is a data transfer the request
+	 * will be finished after the data has
+	 * transfered.
+	 */	
+	if (cmd->data && (cmd->error == MMC_ERR_NONE))
+	{		
+		spin_unlock_bh(&host->lock);
+
+		return;
+	}
+		
+done:
+	wbsd_request_end(host, mrq);
+
+	spin_unlock_bh(&host->lock);
+}
+
+static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
+{
+	struct wbsd_host* host = mmc_priv(mmc);
+	u8 clk, setup, pwr;
+	
+	DBGF("clock %uHz busmode %u powermode %u Vdd %u\n",
+		ios->clock, ios->bus_mode, ios->power_mode, ios->vdd);
+
+	spin_lock_bh(&host->lock);
+
+	/*
+	 * Reset the chip on each power off.
+	 * Should clear out any weird states.
+	 */
+	if (ios->power_mode == MMC_POWER_OFF)
+		wbsd_init_device(host);
+	
+	if (ios->clock >= 24000000)
+		clk = WBSD_CLK_24M;
+	else if (ios->clock >= 16000000)
+		clk = WBSD_CLK_16M;
+	else if (ios->clock >= 12000000)
+		clk = WBSD_CLK_12M;
+	else
+		clk = WBSD_CLK_375K;
+
+	/*
+	 * Only write to the clock register when
+	 * there is an actual change.
+	 */
+	if (clk != host->clk)
+	{
+		wbsd_write_index(host, WBSD_IDX_CLK, clk);
+		host->clk = clk;
+	}
+
+	if (ios->power_mode != MMC_POWER_OFF)
+	{
+		/*
+		 * Power up card.
+		 */
+		pwr = inb(host->base + WBSD_CSR);
+		pwr &= ~WBSD_POWER_N;
+		outb(pwr, host->base + WBSD_CSR);
+
+		/*
+		 * This behaviour is stolen from the
+		 * Windows driver. Don't know why, but
+		 * it is needed.
+		 */
+		setup = wbsd_read_index(host, WBSD_IDX_SETUP);
+		if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
+			setup |= WBSD_DAT3_H;
+		else
+			setup &= ~WBSD_DAT3_H;
+		wbsd_write_index(host, WBSD_IDX_SETUP, setup);
+
+		mdelay(1);
+	}
+
+	spin_unlock_bh(&host->lock);
+}
+
+/*
+ * Tasklets
+ */
+
+inline static struct mmc_data* wbsd_get_data(struct wbsd_host* host)
+{
+	WARN_ON(!host->mrq);
+	if (!host->mrq)
+		return NULL;
+
+	WARN_ON(!host->mrq->cmd);
+	if (!host->mrq->cmd)
+		return NULL;
+
+	WARN_ON(!host->mrq->cmd->data);
+	if (!host->mrq->cmd->data)
+		return NULL;
+	
+	return host->mrq->cmd->data;
+}
+
+static void wbsd_tasklet_card(unsigned long param)
+{
+	struct wbsd_host* host = (struct wbsd_host*)param;
+	u8 csr;
+	
+	spin_lock(&host->lock);
+	
+	csr = inb(host->base + WBSD_CSR);
+	WARN_ON(csr == 0xff);
+	
+	if (csr & WBSD_CARDPRESENT)
+		DBG("Card inserted\n");
+	else
+	{
+		DBG("Card removed\n");
+		
+		if (host->mrq)
+		{
+			printk(KERN_ERR DRIVER_NAME
+				": Card removed during transfer!\n");
+			wbsd_reset(host);
+			
+			host->mrq->cmd->error = MMC_ERR_FAILED;
+			tasklet_schedule(&host->finish_tasklet);
+		}
+	}
+	
+	/*
+	 * Unlock first since we might get a call back.
+	 */
+	spin_unlock(&host->lock);
+
+	mmc_detect_change(host->mmc);
+}
+
+static void wbsd_tasklet_fifo(unsigned long param)
+{
+	struct wbsd_host* host = (struct wbsd_host*)param;
+	struct mmc_data* data;
+	
+	spin_lock(&host->lock);
+		
+	if (!host->mrq)
+		goto end;
+	
+	data = wbsd_get_data(host);
+	if (!data)
+		goto end;
+
+	if (data->flags & MMC_DATA_WRITE)
+		wbsd_fill_fifo(host);
+	else
+		wbsd_empty_fifo(host);
+
+	/*
+	 * Done?
+	 */
+	if (host->size == data->bytes_xfered)
+	{
+		wbsd_write_index(host, WBSD_IDX_FIFOEN, 0);
+		tasklet_schedule(&host->finish_tasklet);
+	}
+
+end:	
+	spin_unlock(&host->lock);
+}
+
+static void wbsd_tasklet_crc(unsigned long param)
+{
+	struct wbsd_host* host = (struct wbsd_host*)param;
+	struct mmc_data* data;
+	
+	spin_lock(&host->lock);
+	
+	WARN_ON(!host->mrq);
+	if (!host->mrq)
+		goto end;
+	
+	data = wbsd_get_data(host);
+	if (!data)
+		goto end;
+	
+	DBGF("CRC error\n");
+
+	data->error = MMC_ERR_BADCRC;
+	
+	tasklet_schedule(&host->finish_tasklet);
+
+end:		
+	spin_unlock(&host->lock);
+}
+
+static void wbsd_tasklet_timeout(unsigned long param)
+{
+	struct wbsd_host* host = (struct wbsd_host*)param;
+	struct mmc_data* data;
+	
+	spin_lock(&host->lock);
+	
+	WARN_ON(!host->mrq);
+	if (!host->mrq)
+		goto end;
+	
+	data = wbsd_get_data(host);
+	if (!data)
+		goto end;
+	
+	DBGF("Timeout\n");
+
+	data->error = MMC_ERR_TIMEOUT;
+	
+	tasklet_schedule(&host->finish_tasklet);
+
+end:	
+	spin_unlock(&host->lock);
+}
+
+static void wbsd_tasklet_finish(unsigned long param)
+{
+	struct wbsd_host* host = (struct wbsd_host*)param;
+	struct mmc_data* data;
+	
+	spin_lock(&host->lock);
+	
+	WARN_ON(!host->mrq);
+	if (!host->mrq)
+		goto end;
+	
+	data = wbsd_get_data(host);
+	if (!data)
+		goto end;
+
+	wbsd_finish_data(host, data);
+	
+end:	
+	spin_unlock(&host->lock);
+}
+
+static void wbsd_tasklet_block(unsigned long param)
+{
+	struct wbsd_host* host = (struct wbsd_host*)param;
+	struct mmc_data* data;
+	
+	spin_lock(&host->lock);
+
+	if ((wbsd_read_index(host, WBSD_IDX_CRCSTATUS) & WBSD_CRC_MASK) !=
+		WBSD_CRC_OK)
+	{
+		data = wbsd_get_data(host);
+		if (!data)
+			goto end;
+		
+		DBGF("CRC error\n");
+
+		data->error = MMC_ERR_BADCRC;
+	
+		tasklet_schedule(&host->finish_tasklet);
+	}
+
+end:	
+	spin_unlock(&host->lock);
+}
+
+/*
+ * Interrupt handling
+ */
+
+static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct wbsd_host* host = dev_id;
+	int isr;
+	
+	isr = inb(host->base + WBSD_ISR);
+
+	/*
+	 * Was it actually our hardware that caused the interrupt?
+	 */
+	if (isr == 0xff || isr == 0x00)
+		return IRQ_NONE;
+
+	/*
+	 * Schedule tasklets as needed.
+	 */
+	if (isr & WBSD_INT_CARD)
+		tasklet_schedule(&host->card_tasklet);
+	if (isr & WBSD_INT_FIFO_THRE)
+		tasklet_hi_schedule(&host->fifo_tasklet);
+	if (isr & WBSD_INT_CRC)
+		tasklet_hi_schedule(&host->crc_tasklet);
+	if (isr & WBSD_INT_TIMEOUT)
+		tasklet_hi_schedule(&host->timeout_tasklet);
+	if (isr & WBSD_INT_BUSYEND)
+		tasklet_hi_schedule(&host->block_tasklet);
+	if (isr & WBSD_INT_TC)
+		tasklet_schedule(&host->finish_tasklet);
+	
+	return IRQ_HANDLED;
+}
+
+/*
+ * Support functions for probe
+ */
+
+static int wbsd_scan(struct wbsd_host* host)
+{
+	int i, j, k;
+	int id;
+	
+	/*
+	 * Iterate through all ports, all codes to
+	 * find hardware that is in our known list.
+	 */
+	for (i = 0;i < sizeof(config_ports)/sizeof(int);i++)
+	{
+		if (!request_region(config_ports[i], 2, DRIVER_NAME))
+			continue;
+			
+		for (j = 0;j < sizeof(unlock_codes)/sizeof(int);j++)
+		{
+			id = 0xFFFF;
+			
+			outb(unlock_codes[j], config_ports[i]);
+			outb(unlock_codes[j], config_ports[i]);
+			
+			outb(WBSD_CONF_ID_HI, config_ports[i]);
+			id = inb(config_ports[i] + 1) << 8;
+
+			outb(WBSD_CONF_ID_LO, config_ports[i]);
+			id |= inb(config_ports[i] + 1);
+			
+			for (k = 0;k < sizeof(valid_ids)/sizeof(int);k++)
+			{
+				if (id == valid_ids[k])
+				{				
+					host->chip_id = id;
+					host->config = config_ports[i];
+					host->unlock_code = unlock_codes[i];
+				
+					return 0;
+				}
+			}
+			
+			if (id != 0xFFFF)
+			{
+				DBG("Unknown hardware (id %x) found at %x\n",
+					id, config_ports[i]);
+			}
+
+			outb(LOCK_CODE, config_ports[i]);
+		}
+		
+		release_region(config_ports[i], 2);
+	}
+	
+	return -ENODEV;
+}
+
+static int wbsd_request_regions(struct wbsd_host* host)
+{
+	if (io & 0x7)
+		return -EINVAL;
+	
+	if (!request_region(io, 8, DRIVER_NAME))
+		return -EIO;
+	
+	host->base = io;
+		
+	return 0;
+}
+
+static void wbsd_release_regions(struct wbsd_host* host)
+{
+	if (host->base)
+		release_region(host->base, 8);
+
+	if (host->config)
+		release_region(host->config, 2);
+}
+
+static void wbsd_init_dma(struct wbsd_host* host)
+{
+	host->dma = -1;
+	
+	if (dma < 0)
+		return;
+	
+	if (request_dma(dma, DRIVER_NAME))
+		goto err;
+	
+	/*
+	 * We need to allocate a special buffer in
+	 * order for ISA to be able to DMA to it.
+	 */
+	host->dma_buffer = kmalloc(65536,
+		GFP_NOIO | GFP_DMA | __GFP_REPEAT | __GFP_NOWARN);
+	if (!host->dma_buffer)
+		goto free;
+
+	/*
+	 * Translate the address to a physical address.
+	 */
+	host->dma_addr = isa_virt_to_bus(host->dma_buffer);
+			
+	/*
+	 * ISA DMA must be aligned on a 64k basis.
+	 */
+	if ((host->dma_addr & 0xffff) != 0)
+		goto kfree;
+	/*
+	 * ISA cannot access memory above 16 MB.
+	 */
+	else if (host->dma_addr >= 0x1000000)
+		goto kfree;
+
+	host->dma = dma;
+	
+	return;
+	
+kfree:
+	/*
+	 * If we've gotten here then there is some kind of alignment bug
+	 */
+	BUG_ON(1);
+	
+	kfree(host->dma_buffer);
+	host->dma_buffer = NULL;
+
+free:
+	free_dma(dma);
+
+err:
+	printk(KERN_WARNING DRIVER_NAME ": Unable to allocate DMA %d. "
+		"Falling back on FIFO.\n", dma);
+}
+
+static struct mmc_host_ops wbsd_ops = {
+	.request	= wbsd_request,
+	.set_ios	= wbsd_set_ios,
+};
+
+/*
+ * Device probe
+ */
+
+static int wbsd_probe(struct device* dev)
+{
+	struct wbsd_host* host = NULL;
+	struct mmc_host* mmc = NULL;
+	int ret;
+	
+	/*
+	 * Allocate MMC structure.
+	 */
+	mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);
+	if (!mmc)
+		return -ENOMEM;
+	
+	host = mmc_priv(mmc);
+	host->mmc = mmc;
+	
+	/*
+	 * Scan for hardware.
+	 */
+	ret = wbsd_scan(host);
+	if (ret)
+		goto freemmc;
+
+	/*
+	 * Reset the chip.
+	 */	
+	wbsd_write_config(host, WBSD_CONF_SWRST, 1);
+	wbsd_write_config(host, WBSD_CONF_SWRST, 0);
+
+	/*
+	 * Allocate I/O ports.
+	 */
+	ret = wbsd_request_regions(host);
+	if (ret)
+		goto release;
+
+	/*
+	 * Set host parameters.
+	 */
+	mmc->ops = &wbsd_ops;
+	mmc->f_min = 375000;
+	mmc->f_max = 24000000;
+	mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34;
+	
+	spin_lock_init(&host->lock);
+
+	/*
+	 * Select SD/MMC function.
+	 */
+	wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
+	
+	/*
+	 * Set up card detection.
+	 */
+	wbsd_write_config(host, WBSD_CONF_PINS, 0x02);
+	
+	/*
+	 * Configure I/O port.
+	 */
+	wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8);
+	wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);
+
+	/*
+	 * Allocate interrupt.
+	 */
+	ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host);
+	if (ret)
+		goto release;
+	
+	host->irq = irq;
+	
+	/*
+	 * Set up tasklets.
+	 */
+	tasklet_init(&host->card_tasklet, wbsd_tasklet_card, (unsigned long)host);
+	tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, (unsigned long)host);
+	tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, (unsigned long)host);
+	tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host);
+	tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host);
+	tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host);
+	
+	/*
+	 * Configure interrupt.
+	 */
+	wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);
+	
+	/*
+	 * Allocate DMA.
+	 */
+	wbsd_init_dma(host);
+	
+	/*
+	 * If all went well, then configure DMA.
+	 */
+	if (host->dma >= 0)
+		wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);
+	
+	/*
+	 * Maximum number of segments. Worst case is one sector per segment
+	 * so this will be 64kB/512.
+	 */
+	mmc->max_hw_segs = NR_SG;
+	mmc->max_phys_segs = NR_SG;
+	
+	/*
+	 * Maximum number of sectors in one transfer. Also limited by 64kB
+	 * buffer.
+	 */
+	mmc->max_sectors = 128;
+	
+	/*
+	 * Maximum segment size. Could be one segment with the maximum number
+	 * of segments.
+	 */
+	mmc->max_seg_size = mmc->max_sectors * 512;
+	
+	/*
+	 * Enable chip.
+	 */
+	wbsd_write_config(host, WBSD_CONF_ENABLE, 1);
+	
+	/*
+	 * Power up chip.
+	 */
+	wbsd_write_config(host, WBSD_CONF_POWER, 0x20);
+	
+	/*
+	 * Power Management stuff. No idea how this works.
+	 * Not tested.
+	 */
+#ifdef CONFIG_PM
+	wbsd_write_config(host, WBSD_CONF_PME, 0xA0);
+#endif
+
+	/*
+	 * Reset the chip into a known state.
+	 */
+	wbsd_init_device(host);
+	
+	dev_set_drvdata(dev, mmc);
+	
+	/*
+	 * Add host to MMC layer.
+	 */
+	mmc_add_host(mmc);
+
+	printk(KERN_INFO "%s: W83L51xD id %x at 0x%x irq %d dma %d\n",
+		mmc->host_name, (int)host->chip_id, (int)host->base,
+		(int)host->irq, (int)host->dma);
+
+	return 0;
+
+release:
+	wbsd_release_regions(host);
+
+freemmc:
+	mmc_free_host(mmc);
+
+	return ret;
+}
+
+/*
+ * Device remove
+ */
+
+static int wbsd_remove(struct device* dev)
+{
+	struct mmc_host* mmc = dev_get_drvdata(dev);
+	struct wbsd_host* host;
+	
+	if (!mmc)
+		return 0;
+
+	host = mmc_priv(mmc);
+	
+	/*
+	 * Unregister host with MMC layer.
+	 */
+	mmc_remove_host(mmc);
+
+	/*
+	 * Power down the SD/MMC function.
+	 */
+	wbsd_unlock_config(host);
+	wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
+	wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
+	wbsd_lock_config(host);
+	
+	/*
+	 * Free resources.
+	 */
+	if (host->dma_buffer)
+		kfree(host->dma_buffer);
+	
+	if (host->dma >= 0)
+		free_dma(host->dma);
+
+	free_irq(host->irq, host);
+	
+	tasklet_kill(&host->card_tasklet);
+	tasklet_kill(&host->fifo_tasklet);
+	tasklet_kill(&host->crc_tasklet);
+	tasklet_kill(&host->timeout_tasklet);
+	tasklet_kill(&host->finish_tasklet);
+	tasklet_kill(&host->block_tasklet);
+	
+	wbsd_release_regions(host);
+	
+	mmc_free_host(mmc);
+
+	return 0;
+}
+
+/*
+ * Power management
+ */
+
+#ifdef CONFIG_PM
+static int wbsd_suspend(struct device *dev, u32 state, u32 level)
+{
+	DBGF("Not yet supported\n");
+
+	return 0;
+}
+
+static int wbsd_resume(struct device *dev, u32 level)
+{
+	DBGF("Not yet supported\n");
+
+	return 0;
+}
+#else
+#define wbsd_suspend NULL
+#define wbsd_resume NULL
+#endif
+
+static void wbsd_release(struct device *dev)
+{
+}
+
+static struct platform_device wbsd_device = {
+	.name		= DRIVER_NAME,
+	.id			= -1,
+	.dev		= {
+		.release = wbsd_release,
+	},
+};
+
+static struct device_driver wbsd_driver = {
+	.name		= DRIVER_NAME,
+	.bus		= &platform_bus_type,
+	.probe		= wbsd_probe,
+	.remove		= wbsd_remove,
+	
+	.suspend	= wbsd_suspend,
+	.resume		= wbsd_resume,
+};
+
+/*
+ * Module loading/unloading
+ */
+
+static int __init wbsd_drv_init(void)
+{
+	int result;
+	
+	printk(KERN_INFO DRIVER_NAME
+		": Winbond W83L51xD SD/MMC card interface driver, "
+		DRIVER_VERSION "\n");
+	printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
+	
+	result = driver_register(&wbsd_driver);
+	if (result < 0)
+		return result;
+
+	result = platform_device_register(&wbsd_device);
+	if (result < 0)
+		return result;
+
+	return 0;
+}
+
+static void __exit wbsd_drv_exit(void)
+{
+	platform_device_unregister(&wbsd_device);
+	
+	driver_unregister(&wbsd_driver);
+
+	DBG("unloaded\n");
+}
+
+module_init(wbsd_drv_init);
+module_exit(wbsd_drv_exit);
+module_param(io, uint, 0444);
+module_param(irq, uint, 0444);
+module_param(dma, int, 0444);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver");
+
+MODULE_PARM_DESC(io, "I/O base to allocate. Must be 8 byte aligned. (default 0x248)");
+MODULE_PARM_DESC(irq, "IRQ to allocate. (default 6)");
+MODULE_PARM_DESC(dma, "DMA channel to allocate. -1 for no DMA. (default 2)");
diff -Nru a/drivers/mmc/wbsd.h b/drivers/mmc/wbsd.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mmc/wbsd.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,177 @@
+/*
+ *  linux/drivers/mmc/wbsd.h
+ *
+ *  Copyright (C) 2004 Pierre Ossman, 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 version 2 as
+ * published by the Free Software Foundation.
+ */
+
+const int config_ports[] = { 0x2E, 0x4E };
+const int unlock_codes[] = { 0x83, 0x87 };
+
+const int valid_ids[] = {
+	0x7112,
+	};
+
+#define LOCK_CODE		0xAA
+
+#define WBSD_CONF_SWRST		0x02
+#define WBSD_CONF_DEVICE	0x07
+#define WBSD_CONF_ID_HI		0x20
+#define WBSD_CONF_ID_LO		0x21
+#define WBSD_CONF_POWER		0x22
+#define WBSD_CONF_PME		0x23
+#define WBSD_CONF_PMES		0x24
+
+#define WBSD_CONF_ENABLE	0x30
+#define WBSD_CONF_PORT_HI	0x60
+#define WBSD_CONF_PORT_LO	0x61
+#define WBSD_CONF_IRQ		0x70
+#define WBSD_CONF_DRQ		0x74
+
+#define WBSD_CONF_PINS		0xF0
+
+#define DEVICE_SD		0x03
+
+#define WBSD_CMDR		0x00
+#define WBSD_DFR		0x01
+#define WBSD_EIR		0x02
+#define WBSD_ISR		0x03
+#define WBSD_FSR		0x04
+#define WBSD_IDXR		0x05
+#define WBSD_DATAR		0x06
+#define WBSD_CSR		0x07
+
+#define WBSD_EINT_CARD		0x40
+#define WBSD_EINT_FIFO_THRE	0x20
+#define WBSD_EINT_CCRC		0x10
+#define WBSD_EINT_TIMEOUT	0x08
+#define WBSD_EINT_PROGEND	0x04
+#define WBSD_EINT_CRC		0x02
+#define WBSD_EINT_TC		0x01
+
+#define WBSD_INT_PENDING	0x80
+#define WBSD_INT_CARD		0x40
+#define WBSD_INT_FIFO_THRE	0x20
+#define WBSD_INT_CRC		0x10
+#define WBSD_INT_TIMEOUT	0x08
+#define WBSD_INT_PROGEND	0x04
+#define WBSD_INT_BUSYEND	0x02
+#define WBSD_INT_TC		0x01
+
+#define WBSD_FIFO_EMPTY		0x80
+#define WBSD_FIFO_FULL		0x40
+#define WBSD_FIFO_EMTHRE	0x20
+#define WBSD_FIFO_FUTHRE	0x10
+#define WBSD_FIFO_SZMASK	0x0F
+
+#define WBSD_MSLED		0x20
+#define WBSD_POWER_N		0x10
+#define WBSD_WRPT		0x04
+#define WBSD_CARDPRESENT	0x01
+
+#define WBSD_IDX_CLK		0x01
+#define WBSD_IDX_PBSMSB		0x02
+#define WBSD_IDX_TAAC		0x03
+#define WBSD_IDX_NSAC		0x04
+#define WBSD_IDX_PBSLSB		0x05
+#define WBSD_IDX_SETUP		0x06
+#define WBSD_IDX_DMA		0x07
+#define WBSD_IDX_FIFOEN		0x08
+#define WBSD_IDX_STATUS		0x10
+#define WBSD_IDX_RSPLEN		0x1E
+#define WBSD_IDX_RESP0		0x1F
+#define WBSD_IDX_RESP1		0x20
+#define WBSD_IDX_RESP2		0x21
+#define WBSD_IDX_RESP3		0x22
+#define WBSD_IDX_RESP4		0x23
+#define WBSD_IDX_RESP5		0x24
+#define WBSD_IDX_RESP6		0x25
+#define WBSD_IDX_RESP7		0x26
+#define WBSD_IDX_RESP8		0x27
+#define WBSD_IDX_RESP9		0x28
+#define WBSD_IDX_RESP10		0x29
+#define WBSD_IDX_RESP11		0x2A
+#define WBSD_IDX_RESP12		0x2B
+#define WBSD_IDX_RESP13		0x2C
+#define WBSD_IDX_RESP14		0x2D
+#define WBSD_IDX_RESP15		0x2E
+#define WBSD_IDX_RESP16		0x2F
+#define WBSD_IDX_CRCSTATUS	0x30
+#define WBSD_IDX_ISR		0x3F
+
+#define WBSD_CLK_375K		0x00
+#define WBSD_CLK_12M		0x01
+#define WBSD_CLK_16M		0x02
+#define WBSD_CLK_24M		0x03
+
+#define WBSD_DAT3_H		0x08
+#define WBSD_FIFO_RESET		0x04
+#define WBSD_SOFT_RESET		0x02
+#define WBSD_INC_INDEX		0x01
+
+#define WBSD_DMA_SINGLE		0x02
+#define WBSD_DMA_ENABLE		0x01
+
+#define WBSD_FIFOEN_EMPTY	0x20
+#define WBSD_FIFOEN_FULL	0x10
+#define WBSD_FIFO_THREMASK	0x0F
+
+#define WBSD_BUSY		0x20
+#define WBSD_CARDTRAFFIC	0x04
+#define WBSD_SENDCMD		0x02
+#define WBSD_RECVRES		0x01
+
+#define WBSD_RSP_SHORT		0x00
+#define WBSD_RSP_LONG		0x01
+
+#define WBSD_CRC_MASK		0x1F
+#define WBSD_CRC_OK		0x05 /* S010E (00101) */
+#define WBSD_CRC_FAIL		0x0B /* S101E (01011) */
+
+
+/* 64kB / 512 */
+#define NR_SG			128
+
+struct wbsd_host
+{
+	struct mmc_host*	mmc;		/* MMC structure */
+	
+	spinlock_t		lock;		/* Mutex */
+
+	struct mmc_request*	mrq;		/* Current request */
+	
+	struct scatterlist	sg[NR_SG];	/* SG list */
+	struct scatterlist*	cur_sg;		/* Current SG entry */
+	unsigned int		num_sg;		/* Number of entries left */
+	
+	unsigned int		offset;		/* Offset into current entry */
+	unsigned int		remain;		/* Data left in curren entry */
+
+	int			size;		/* Total size of transfer */
+	
+	char*			dma_buffer;	/* ISA DMA buffer */
+	dma_addr_t		dma_addr;	/* Physical address for same */
+
+	int			firsterr;	/* See fifo functions */
+	
+	u8			clk;		/* Current clock speed */
+	
+	int			config;		/* Config port */
+	u8			unlock_code;	/* Code to unlock config */
+
+	int			chip_id;	/* ID of controller */
+	
+	int			base;		/* I/O port base */
+	int			irq;		/* Interrupt */
+	int			dma;		/* DMA channel */
+	
+	struct tasklet_struct	card_tasklet;	/* Tasklet structures */
+	struct tasklet_struct	fifo_tasklet;
+	struct tasklet_struct	crc_tasklet;
+	struct tasklet_struct	timeout_tasklet;
+	struct tasklet_struct	finish_tasklet;
+	struct tasklet_struct	block_tasklet;
+};
diff -Nru a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
--- a/drivers/mtd/chips/cfi_cmdset_0001.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c	2004-12-24 13:36:31 -08:00
@@ -4,8 +4,9 @@
  *
  * (C) 2000 Red Hat. GPL'd
  *
- * $Id: cfi_cmdset_0001.c,v 1.154 2004/08/09 13:19:43 dwmw2 Exp $
- *
+ * $Id: cfi_cmdset_0001.c,v 1.160 2004/11/01 06:02:24 nico Exp $
+ * (+ suspend fix from v1.162)
+ * (+ partition detection fix from v1.163)
  * 
  * 10/10/2000	Nicolas Pitre <nico@cam.org>
  * 	- completely revamped method functions so they are aware and
@@ -39,6 +40,12 @@
 // debugging, turns off buffer write mode if set to 1
 #define FORCE_WORD_WRITE 0
 
+#define MANUFACTURER_INTEL	0x0089
+#define I82802AB	0x00ad
+#define I82802AC	0x00ac
+#define MANUFACTURER_ST         0x0020
+#define M50LPW080       0x002F
+
 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
 //static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
 //static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
@@ -55,14 +62,19 @@
 
 struct mtd_info *cfi_cmdset_0001(struct map_info *, int);
 
-static struct mtd_info *cfi_intelext_setup (struct map_info *);
-static int cfi_intelext_partition_fixup(struct map_info *, struct cfi_private **);
+static struct mtd_info *cfi_intelext_setup (struct mtd_info *);
+static int cfi_intelext_partition_fixup(struct mtd_info *, struct cfi_private **);
 
 static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len,
 		     size_t *retlen, u_char **mtdbuf);
 static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from,
 			size_t len);
 
+static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
+static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr);
+#include "fwh_lock.h"
+
+
 
 /*
  *  *********** SETUP AND PROBE BITS  ***********
@@ -123,8 +135,9 @@
 
 #ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
 /* Some Intel Strata Flash prior to FPO revision C has bugs in this area */ 
-static void fixup_intel_strataflash(struct map_info *map, void* param)
+static void fixup_intel_strataflash(struct mtd_info *mtd, void* param)
 {
+	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = map->fldrv_priv;
 	struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
 
@@ -134,16 +147,18 @@
 }
 #endif
 
-static void fixup_st_m28w320ct(struct map_info *map, void* param)
+static void fixup_st_m28w320ct(struct mtd_info *mtd, void* param)
 {
+	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = map->fldrv_priv;
 	
 	cfi->cfiq->BufWriteTimeoutTyp = 0;	/* Not supported */
 	cfi->cfiq->BufWriteTimeoutMax = 0;	/* Not supported */
 }
 
-static void fixup_st_m28w320cb(struct map_info *map, void* param)
+static void fixup_st_m28w320cb(struct mtd_info *mtd, void* param)
 {
+	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = map->fldrv_priv;
 	
 	/* Note this is done after the region info is endian swapped */
@@ -151,26 +166,113 @@
 		(cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e;
 };
 
-static struct cfi_fixup fixup_table[] = {
+static void fixup_use_point(struct mtd_info *mtd, void *param)
+{
+	struct map_info *map = mtd->priv;
+	if (!mtd->point && map_is_linear(map)) {
+		mtd->point   = cfi_intelext_point;
+		mtd->unpoint = cfi_intelext_unpoint;
+	}
+}
+
+static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
+{
+	struct map_info *map = mtd->priv;
+	struct cfi_private *cfi = map->fldrv_priv;
+	if (cfi->cfiq->BufWriteTimeoutTyp) {
+		printk(KERN_INFO "Using buffer write method\n" );
+		mtd->write = cfi_intelext_write_buffers;
+	}
+}
+
+static struct cfi_fixup cfi_fixup_table[] = {
 #ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
-	{
-		CFI_MFR_ANY, CFI_ID_ANY,
-		fixup_intel_strataflash, NULL
-	}, 
+	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL }, 
 #endif
-	{
-		0x0020,	/* STMicroelectronics */
-		0x00ba,	/* M28W320CT */
-		fixup_st_m28w320ct, NULL
-	}, {
-		0x0020,	/* STMicroelectronics */
-		0x00bb,	/* M28W320CB */
-		fixup_st_m28w320cb, NULL
-	}, {
-		0, 0, NULL, NULL
-	}
+#if !FORCE_WORD_WRITE
+	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL },
+#endif
+	{ CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct, NULL },
+	{ CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb, NULL },
+	{ 0, 0, NULL, NULL }
+};
+
+static struct cfi_fixup jedec_fixup_table[] = {
+	{ MANUFACTURER_INTEL, I82802AB,   fixup_use_fwh_lock, NULL, },
+	{ MANUFACTURER_INTEL, I82802AC,   fixup_use_fwh_lock, NULL, },
+	{ MANUFACTURER_ST,    M50LPW080,  fixup_use_fwh_lock, NULL, },
+	{ 0, 0, NULL, NULL }
+};
+static struct cfi_fixup fixup_table[] = {
+	/* The CFI vendor ids and the JEDEC vendor IDs appear
+	 * to be common.  It is like the devices id's are as
+	 * well.  This table is to pick all cases where
+	 * we know that is the case.
+	 */
+	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_point, NULL },
+	{ 0, 0, NULL, NULL }
 };
 
+static inline struct cfi_pri_intelext *
+read_pri_intelext(struct map_info *map, __u16 adr)
+{
+	struct cfi_pri_intelext *extp;
+	unsigned int extp_size = sizeof(*extp);
+
+ again:
+	extp = (struct cfi_pri_intelext *)cfi_read_pri(map, adr, extp_size, "Intel/Sharp");
+	if (!extp)
+		return NULL;
+
+	/* Do some byteswapping if necessary */
+	extp->FeatureSupport = le32_to_cpu(extp->FeatureSupport);
+	extp->BlkStatusRegMask = le16_to_cpu(extp->BlkStatusRegMask);
+	extp->ProtRegAddr = le16_to_cpu(extp->ProtRegAddr);
+
+	if (extp->MajorVersion == '1' && extp->MinorVersion == '3') {
+		unsigned int extra_size = 0;
+		int nb_parts, i;
+
+		/* Protection Register info */
+		extra_size += (extp->NumProtectionFields - 1) * (4 + 6);
+
+		/* Burst Read info */
+		extra_size += 6;
+
+		/* Number of hardware-partitions */
+		extra_size += 1;
+		if (extp_size < sizeof(*extp) + extra_size)
+			goto need_more;
+		nb_parts = extp->extra[extra_size - 1];
+
+		for (i = 0; i < nb_parts; i++) {
+			struct cfi_intelext_regioninfo *rinfo;
+			rinfo = (struct cfi_intelext_regioninfo *)&extp->extra[extra_size];
+			extra_size += sizeof(*rinfo);
+			if (extp_size < sizeof(*extp) + extra_size)
+				goto need_more;
+			rinfo->NumIdentPartitions=le16_to_cpu(rinfo->NumIdentPartitions);
+			extra_size += (rinfo->NumBlockTypes - 1)
+				      * sizeof(struct cfi_intelext_blockinfo);
+		}
+
+		if (extp_size < sizeof(*extp) + extra_size) {
+			need_more:
+			extp_size = sizeof(*extp) + extra_size;
+			kfree(extp);
+			if (extp_size > 4096) {
+				printk(KERN_ERR
+					"%s: cfi_pri_intelext is too fat\n",
+					__FUNCTION__);
+				return NULL;
+			}
+			goto again;
+		}
+	}
+		
+	return extp;
+}
+
 /* This routine is made available to other mtd code via
  * inter_module_register.  It must only be accessed through
  * inter_module_get which will bump the use count of this module.  The
@@ -181,8 +283,30 @@
 struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
+	struct mtd_info *mtd;
 	int i;
 
+	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+	if (!mtd) {
+		printk(KERN_ERR "Failed to allocate memory for MTD device\n");
+		return NULL;
+	}
+	memset(mtd, 0, sizeof(*mtd));
+	mtd->priv = map;
+	mtd->type = MTD_NORFLASH;
+
+	/* Fill in the default mtd operations */
+	mtd->erase   = cfi_intelext_erase_varsize;
+	mtd->read    = cfi_intelext_read;
+	mtd->write   = cfi_intelext_write_words;
+	mtd->sync    = cfi_intelext_sync;
+	mtd->lock    = cfi_intelext_lock;
+	mtd->unlock  = cfi_intelext_unlock;
+	mtd->suspend = cfi_intelext_suspend;
+	mtd->resume  = cfi_intelext_resume;
+	mtd->flags   = MTD_CAP_NORFLASH;
+	mtd->name    = map->name;
+	
 	if (cfi->cfi_mode == CFI_MODE_CFI) {
 		/* 
 		 * It's a real CFI chip, not one for which the probe
@@ -192,20 +316,17 @@
 		__u16 adr = primary?cfi->cfiq->P_ADR:cfi->cfiq->A_ADR;
 		struct cfi_pri_intelext *extp;
 
-		extp = (struct cfi_pri_intelext*)cfi_read_pri(map, adr, sizeof(*extp), "Intel/Sharp");
-		if (!extp)
+		extp = read_pri_intelext(map, adr);
+		if (!extp) {
+			kfree(mtd);
 			return NULL;
-		
-		/* Do some byteswapping if necessary */
-		extp->FeatureSupport = le32_to_cpu(extp->FeatureSupport);
-		extp->BlkStatusRegMask = le16_to_cpu(extp->BlkStatusRegMask);
-		extp->ProtRegAddr = le16_to_cpu(extp->ProtRegAddr);
+		}
 
 		/* Install our own private info structure */
 		cfi->cmdset_priv = extp;	
 
-		cfi_fixup(map, fixup_table);
-			
+		cfi_fixup(mtd, cfi_fixup_table);
+
 #ifdef DEBUG_CFI_FEATURES
 		/* Tell the user about it in lots of lovely detail */
 		cfi_tell_features(extp);
@@ -215,6 +336,12 @@
 			printk(KERN_NOTICE "cfi_cmdset_0001: Erase suspend on write enabled\n");
 		}
 	}
+	else if (cfi->cfi_mode == CFI_MODE_JEDEC) {
+		/* Apply jedec specific fixups */
+		cfi_fixup(mtd, jedec_fixup_table);
+	}
+	/* Apply generic fixups */
+	cfi_fixup(mtd, fixup_table);
 
 	for (i=0; i< cfi->numchips; i++) {
 		cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
@@ -225,28 +352,19 @@
 
 	map->fldrv = &cfi_intelext_chipdrv;
 	
-	return cfi_intelext_setup(map);
+	return cfi_intelext_setup(mtd);
 }
 
-static struct mtd_info *cfi_intelext_setup(struct map_info *map)
+static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
 {
+	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = map->fldrv_priv;
-	struct mtd_info *mtd;
 	unsigned long offset = 0;
 	int i,j;
 	unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave;
 
-	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
 	//printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips);
 
-	if (!mtd) {
-		printk(KERN_ERR "Failed to allocate memory for MTD device\n");
-		goto setup_err;
-	}
-
-	memset(mtd, 0, sizeof(*mtd));
-	mtd->priv = map;
-	mtd->type = MTD_NORFLASH;
 	mtd->size = devsize * cfi->numchips;
 
 	mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
@@ -286,38 +404,14 @@
 		       mtd->eraseregions[i].numblocks);
 	}
 
-	/* Also select the correct geometry setup too */ 
-	mtd->erase = cfi_intelext_erase_varsize;
-	mtd->read = cfi_intelext_read;
-
-	if (map_is_linear(map)) {
-		mtd->point = cfi_intelext_point;
-		mtd->unpoint = cfi_intelext_unpoint;
-	}
-
-	if ( cfi->cfiq->BufWriteTimeoutTyp && !FORCE_WORD_WRITE) {
-		printk(KERN_INFO "Using buffer write method\n" );
-		mtd->write = cfi_intelext_write_buffers;
-	} else {
-		printk(KERN_INFO "Using word write method\n" );
-		mtd->write = cfi_intelext_write_words;
-	}
 #if 0
 	mtd->read_user_prot_reg = cfi_intelext_read_user_prot_reg;
 	mtd->read_fact_prot_reg = cfi_intelext_read_fact_prot_reg;
 #endif
-	mtd->sync = cfi_intelext_sync;
-	mtd->lock = cfi_intelext_lock;
-	mtd->unlock = cfi_intelext_unlock;
-	mtd->suspend = cfi_intelext_suspend;
-	mtd->resume = cfi_intelext_resume;
-	mtd->flags = MTD_CAP_NORFLASH;
-	map->fldrv = &cfi_intelext_chipdrv;
-	mtd->name = map->name;
 
 	/* This function has the potential to distort the reality
 	   a bit and therefore should be called last. */
-	if (cfi_intelext_partition_fixup(map, &cfi) != 0)
+	if (cfi_intelext_partition_fixup(mtd, &cfi) != 0)
 		goto setup_err;
 
 	__module_get(THIS_MODULE);
@@ -333,20 +427,16 @@
 	return NULL;
 }
 
-static int cfi_intelext_partition_fixup(struct map_info *map,
+static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
 					struct cfi_private **pcfi)
 {
+	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = *pcfi;
 	struct cfi_pri_intelext *extp = cfi->cmdset_priv;
 
 	/*
 	 * Probing of multi-partition flash ships.
 	 *
-	 * This is extremely crude at the moment and should probably be
-	 * extracted entirely from the Intel extended query data instead.
-	 * Right now a L18 flash is assumed if multiple operations is
-	 * detected.
-	 *
 	 * To support multiple partitions when available, we simply arrange
 	 * for each of them to have their own flchip structure even if they
 	 * are on the same physical chip.  This means completely recreating
@@ -355,20 +445,49 @@
 	 * arrangement at this point. This can be rearranged in the future
 	 * if someone feels motivated enough.  --nico
 	 */
-	if (extp && extp->FeatureSupport & (1 << 9)) {
+	if (extp && extp->MajorVersion == '1' && extp->MinorVersion == '3'
+	    && extp->FeatureSupport & (1 << 9)) {
 		struct cfi_private *newcfi;
 		struct flchip *chip;
 		struct flchip_shared *shared;
-		int numparts, partshift, numvirtchips, i, j;
+		int offs, numregions, numparts, partshift, numvirtchips, i, j;
+
+		/* Protection Register info */
+		offs = (extp->NumProtectionFields - 1) * (4 + 6);
+
+		/* Burst Read info */
+		offs += 6;
+
+		/* Number of partition regions */
+		numregions = extp->extra[offs];
+		offs += 1;
+
+		/* Number of hardware partitions */
+		numparts = 0;
+		for (i = 0; i < numregions; i++) {
+			struct cfi_intelext_regioninfo *rinfo;
+			rinfo = (struct cfi_intelext_regioninfo *)&extp->extra[offs];
+			numparts += rinfo->NumIdentPartitions;
+			offs += sizeof(*rinfo)
+				+ (rinfo->NumBlockTypes - 1) *
+				  sizeof(struct cfi_intelext_blockinfo);
+		}
 
 		/*
-		 * The L18 flash memory array is divided
-		 * into multiple 8-Mbit partitions.
+		 * All functions below currently rely on all chips having
+		 * the same geometry so we'll just assume that all hardware
+		 * partitions are of the same size too.
 		 */
-		numparts = 1 << (cfi->cfiq->DevSize - 20);
-		partshift = 20 + __ffs(cfi->interleave);
-		numvirtchips = cfi->numchips * numparts;
+		partshift = cfi->chipshift - __ffs(numparts);
+
+		if ((1 << partshift) < mtd->erasesize) {
+			printk( KERN_ERR
+				"%s: bad number of hw partitions (%d)\n",
+				__FUNCTION__, numparts);
+			return -EINVAL;
+		}
 
+		numvirtchips = cfi->numchips * numparts;
 		newcfi = kmalloc(sizeof(struct cfi_private) + numvirtchips * sizeof(struct flchip), GFP_KERNEL);
 		if (!newcfi)
 			return -ENOMEM;
@@ -398,10 +517,10 @@
 			}
 		}
 
-		printk(KERN_DEBUG "%s: %d sets of %d interleaved chips "
-				  "--> %d partitions of %#x bytes\n",
+		printk(KERN_DEBUG "%s: %d set(s) of %d interleaved chips "
+				  "--> %d partitions of %d KiB\n",
 				  map->name, cfi->numchips, cfi->interleave,
-				  newcfi->numchips, 1<<newcfi->chipshift);
+				  newcfi->numchips, 1<<(newcfi->chipshift-10));
 
 		map->fldrv_priv = newcfi;
 		*pcfi = newcfi;
@@ -515,7 +634,8 @@
 		return 0;
 
 	case FL_ERASING:
-		if (!(cfip->FeatureSupport & 2) ||
+		if (!cfip ||
+		    !(cfip->FeatureSupport & 2) ||
 		    !(mode == FL_READY || mode == FL_POINT ||
 		     (mode == FL_WRITING && (cfip->SuspendCmdSupport & 1))))
 			goto sleep;
@@ -822,6 +942,7 @@
 	}
 	return ret;
 }
+
 #if 0
 static int cfi_intelext_read_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf, int base_offst, int reg_sz)
 {
@@ -884,7 +1005,7 @@
 	int base_offst,reg_sz;
 	
 	/* Check that we actually have some protection registers */
-	if(!(extp->FeatureSupport&64)){
+	if(!extp || !(extp->FeatureSupport&64)){
 		printk(KERN_WARNING "%s: This flash device has no protection data to read!\n",map->name);
 		return 0;
 	}
@@ -903,7 +1024,7 @@
 	int base_offst,reg_sz;
 	
 	/* Check that we actually have some protection registers */
-	if(!(extp->FeatureSupport&64)){
+	if(!extp || !(extp->FeatureSupport&64)){
 		printk(KERN_WARNING "%s: This flash device has no protection data to read!\n",map->name);
 		return 0;
 	}
@@ -989,6 +1110,7 @@
 
 	/* Done and happy. */
 	chip->state = FL_STATUS;
+
 	/* check for lock bit */
 	if (map_word_bitsset(map, status, CMD(0x02))) {
 		/* clear status */
@@ -1140,13 +1262,15 @@
 
 		if (++z > 20) {
 			/* Argh. Not ready for write to buffer */
+			map_word Xstatus;
 			map_write(map, CMD(0x70), cmd_adr);
 			chip->state = FL_STATUS;
-			printk(KERN_ERR "Chip not ready for buffer write. Xstatus = %lx, status = %lx\n",
-			       status.x[0], map_read(map, cmd_adr).x[0]);
+			Xstatus = map_read(map, cmd_adr);
 			/* Odd. Clear status bits */
 			map_write(map, CMD(0x50), cmd_adr);
 			map_write(map, CMD(0x70), cmd_adr);
+			printk(KERN_ERR "Chip not ready for buffer write. status = %lx, Xstatus = %lx\n",
+			       status.x[0], Xstatus.x[0]);
 			ret = -EIO;
 			goto out;
 		}
@@ -1308,102 +1432,6 @@
 	return 0;
 }
 
-typedef int (*varsize_frob_t)(struct map_info *map, struct flchip *chip,
-			      unsigned long adr, int len, void *thunk);
-
-static int cfi_intelext_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
-				     loff_t ofs, size_t len, void *thunk)
-{
-	struct map_info *map = mtd->priv;
-	struct cfi_private *cfi = map->fldrv_priv;
-	unsigned long adr;
-	int chipnum, ret = 0;
-	int i, first;
-	struct mtd_erase_region_info *regions = mtd->eraseregions;
-
-	if (ofs > mtd->size)
-		return -EINVAL;
-
-	if ((len + ofs) > mtd->size)
-		return -EINVAL;
-
-	/* Check that both start and end of the requested erase are
-	 * aligned with the erasesize at the appropriate addresses.
-	 */
-
-	i = 0;
-
-	/* Skip all erase regions which are ended before the start of 
-	   the requested erase. Actually, to save on the calculations,
-	   we skip to the first erase region which starts after the
-	   start of the requested erase, and then go back one.
-	*/
-	
-	while (i < mtd->numeraseregions && ofs >= regions[i].offset)
-	       i++;
-	i--;
-
-	/* OK, now i is pointing at the erase region in which this 
-	   erase request starts. Check the start of the requested
-	   erase range is aligned with the erase size which is in
-	   effect here.
-	*/
-
-	if (ofs & (regions[i].erasesize-1))
-		return -EINVAL;
-
-	/* Remember the erase region we start on */
-	first = i;
-
-	/* Next, check that the end of the requested erase is aligned
-	 * with the erase region at that address.
-	 */
-
-	while (i<mtd->numeraseregions && (ofs + len) >= regions[i].offset)
-		i++;
-
-	/* As before, drop back one to point at the region in which
-	   the address actually falls
-	*/
-	i--;
-	
-	if ((ofs + len) & (regions[i].erasesize-1))
-		return -EINVAL;
-
-	chipnum = ofs >> cfi->chipshift;
-	adr = ofs - (chipnum << cfi->chipshift);
-
-	i=first;
-
-	while(len) {
-		unsigned long chipmask;
-		int size = regions[i].erasesize;
-
-		ret = (*frob)(map, &cfi->chips[chipnum], adr, size, thunk);
-		
-		if (ret)
-			return ret;
-
-		adr += size;
-		len -= size;
-
-		chipmask = (1 << cfi->chipshift) - 1;
-		if ((adr & chipmask) == ((regions[i].offset + size * regions[i].numblocks) & chipmask))
-			i++;
-
-		if (adr >> cfi->chipshift) {
-			adr = 0;
-			chipnum++;
-			
-			if (chipnum >= cfi->numchips)
-			break;
-		}
-	}
-
-	return 0;
-}
-
-
 static int do_erase_oneblock(struct map_info *map, struct flchip *chip,
 			     unsigned long adr, int len, void *thunk)
 {
@@ -1470,16 +1498,17 @@
 		
 		/* OK Still waiting */
 		if (time_after(jiffies, timeo)) {
+			map_word Xstatus;
 			map_write(map, CMD(0x70), adr);
 			chip->state = FL_STATUS;
-			printk(KERN_ERR "waiting for erase at %08lx to complete timed out. Xstatus = %lx, status = %lx.\n",
-			       adr, status.x[0], map_read(map, adr).x[0]);
+			Xstatus = map_read(map, adr);
 			/* Clear status bits */
 			map_write(map, CMD(0x50), adr);
 			map_write(map, CMD(0x70), adr);
-			DISABLE_VPP(map);
-			spin_unlock(chip->mutex);
-			return -EIO;
+			printk(KERN_ERR "waiting for erase at %08lx to complete timed out. status = %lx, Xstatus = %lx.\n",
+			       adr, status.x[0], Xstatus.x[0]);
+			ret = -EIO;
+			goto out;
 		}
 		
 		/* Latency issues. Drop the lock, wait a while and retry */
@@ -1488,9 +1517,6 @@
 		schedule_timeout(1);
 		spin_lock(chip->mutex);
 	}
-	
-	DISABLE_VPP(map);
-	ret = 0;
 
 	/* We've broken this before. It doesn't hurt to be safe */
 	map_write(map, CMD(0x70), adr);
@@ -1499,7 +1525,13 @@
 
 	/* check for lock bit */
 	if (map_word_bitsset(map, status, CMD(0x3a))) {
-		unsigned char chipstatus = status.x[0];
+		unsigned char chipstatus;
+
+		/* Reset the error bits */
+		map_write(map, CMD(0x50), adr);
+		map_write(map, CMD(0x70), adr);
+
+		chipstatus = status.x[0];
 		if (!map_word_equal(map, status, CMD(chipstatus))) {
 			int i, w;
 			for (w=0; w<map_words(map); w++) {
@@ -1510,10 +1542,7 @@
 			printk(KERN_WARNING "Status is not identical for all chips: 0x%lx. Merging to give 0x%02x\n",
 			       status.x[0], chipstatus);
 		}
-		/* Reset the error bits */
-		map_write(map, CMD(0x50), adr);
-		map_write(map, CMD(0x70), adr);
-		
+
 		if ((chipstatus & 0x30) == 0x30) {
 			printk(KERN_NOTICE "Chip reports improper command sequence: status 0x%x\n", chipstatus);
 			ret = -EIO;
@@ -1528,16 +1557,18 @@
 			if (retries--) {
 				printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%x. Retrying...\n", adr, chipstatus);
 				timeo = jiffies + HZ;
-				chip->state = FL_STATUS;
+				put_chip(map, chip, adr);
 				spin_unlock(chip->mutex);
 				goto retry;
 			}
 			printk(KERN_DEBUG "Chip erase failed at 0x%08lx: status 0x%x\n", adr, chipstatus);
 			ret = -EIO;
 		}
+	} else {
+		ret = 0;
 	}
 
-	wake_up(&chip->wq);
+ out:	put_chip(map, chip, adr);
 	spin_unlock(chip->mutex);
 	return ret;
 }
@@ -1550,7 +1581,7 @@
 	ofs = instr->addr;
 	len = instr->len;
 
-	ret = cfi_intelext_varsize_frob(mtd, do_erase_oneblock, ofs, len, NULL);
+	ret = cfi_varsize_frob(mtd, do_erase_oneblock, ofs, len, NULL);
 	if (ret)
 		return ret;
 
@@ -1605,12 +1636,13 @@
 				       unsigned long adr, int len, void *thunk)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
-	int ofs_factor = cfi->interleave * cfi->device_type;
+	int status, ofs_factor = cfi->interleave * cfi->device_type;
 
 	cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
-	printk(KERN_DEBUG "block status register for 0x%08lx is %x\n",
-	       adr, cfi_read_query(map, adr+(2*ofs_factor)));
 	chip->state = FL_JEDEC_QUERY;
+	status = cfi_read_query(map, adr+(2*ofs_factor));
+	printk(KERN_DEBUG "block status register for 0x%08lx is %x\n",
+	       adr, status);
 	return 0;
 }
 #endif
@@ -1666,11 +1698,13 @@
 		
 		/* OK Still waiting */
 		if (time_after(jiffies, timeo)) {
+			map_word Xstatus;
 			map_write(map, CMD(0x70), adr);
 			chip->state = FL_STATUS;
-			printk(KERN_ERR "waiting for unlock to complete timed out. Xstatus = %lx, status = %lx.\n",
-			       status.x[0], map_read(map, adr).x[0]);
-			DISABLE_VPP(map);
+			Xstatus = map_read(map, adr);
+			printk(KERN_ERR "waiting for unlock to complete timed out. status = %lx, Xstatus = %lx.\n",
+			       status.x[0], Xstatus.x[0]);
+			put_chip(map, chip, adr);
 			spin_unlock(chip->mutex);
 			return -EIO;
 		}
@@ -1695,18 +1729,18 @@
 #ifdef DEBUG_LOCK_BITS
 	printk(KERN_DEBUG "%s: lock status before, ofs=0x%08llx, len=0x%08X\n",
 	       __FUNCTION__, ofs, len);
-	cfi_intelext_varsize_frob(mtd, do_printlockstatus_oneblock,
-				  ofs, len, 0);
+	cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
+		ofs, len, 0);
 #endif
 
-	ret = cfi_intelext_varsize_frob(mtd, do_xxlock_oneblock, 
-					ofs, len, DO_XXLOCK_ONEBLOCK_LOCK);
+	ret = cfi_varsize_frob(mtd, do_xxlock_oneblock, 
+		ofs, len, DO_XXLOCK_ONEBLOCK_LOCK);
 	
 #ifdef DEBUG_LOCK_BITS
 	printk(KERN_DEBUG "%s: lock status after, ret=%d\n",
 	       __FUNCTION__, ret);
-	cfi_intelext_varsize_frob(mtd, do_printlockstatus_oneblock,
-				  ofs, len, 0);
+	cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
+		ofs, len, 0);
 #endif
 
 	return ret;
@@ -1719,18 +1753,18 @@
 #ifdef DEBUG_LOCK_BITS
 	printk(KERN_DEBUG "%s: lock status before, ofs=0x%08llx, len=0x%08X\n",
 	       __FUNCTION__, ofs, len);
-	cfi_intelext_varsize_frob(mtd, do_printlockstatus_oneblock,
-				  ofs, len, 0);
+	cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
+		ofs, len, 0);
 #endif
 
-	ret = cfi_intelext_varsize_frob(mtd, do_xxlock_oneblock,
+	ret = cfi_varsize_frob(mtd, do_xxlock_oneblock,
 					ofs, len, DO_XXLOCK_ONEBLOCK_UNLOCK);
 	
 #ifdef DEBUG_LOCK_BITS
 	printk(KERN_DEBUG "%s: lock status after, ret=%d\n",
 	       __FUNCTION__, ret);
-	cfi_intelext_varsize_frob(mtd, do_printlockstatus_oneblock, 
-				  ofs, len, 0);
+	cfi_varsize_frob(mtd, do_printlockstatus_oneblock, 
+		ofs, len, 0);
 #endif
 	
 	return ret;
@@ -1761,9 +1795,18 @@
 				 * as the whole point is that nobody can do anything
 				 * with the chip now anyway.
 				 */
+			} else {
+				/* There seems to be an operation pending. We must wait for it. */
+				printk(KERN_NOTICE "Flash device refused suspend due to pending operation (oldstate %d)\n", chip->oldstate);
+				ret = -EAGAIN;
 			}
 			break;
 		default:
+			/* Should we actually wait? Once upon a time these routines weren't
+			   allowed to. Or should we return -EAGAIN, because the upper layers
+			   ought to have already shut down anything which was using the device
+			   anyway? The latter for now. */
+			printk(KERN_NOTICE "Flash device refused suspend due to active operation (state %d)\n", chip->oldstate);
 			ret = -EAGAIN;
 		case FL_PM_SUSPENDED:
 			break;
@@ -1784,6 +1827,7 @@
 				   because we're returning failure, and it didn't
 				   get power cycled */
 				chip->state = chip->oldstate;
+				chip->oldstate = FL_READY;
 				wake_up(&chip->wq);
 			}
 			spin_unlock(chip->mutex);
@@ -1809,7 +1853,7 @@
 		/* Go to known state. Chip may have been power cycled */
 		if (chip->state == FL_PM_SUSPENDED) {
 			map_write(map, CMD(0xFF), cfi->chips[i].start);
-			chip->state = FL_READY;
+			chip->oldstate = chip->state = FL_READY;
 			wake_up(&chip->wq);
 		}
 
diff -Nru a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
--- a/drivers/mtd/chips/cfi_cmdset_0002.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c	2004-12-24 13:36:48 -08:00
@@ -13,7 +13,7 @@
  *
  * This code is GPL
  *
- * $Id: cfi_cmdset_0002.c,v 1.106 2004/08/09 14:02:32 dwmw2 Exp $
+ * $Id: cfi_cmdset_0002.c,v 1.111 2004/11/16 18:29:00 dwmw2 Exp $
  *
  */
 
@@ -40,13 +40,15 @@
 
 #define MAX_WORD_RETRIES 3
 
+#define MANUFACTURER_AMD	0x0001
+#define MANUFACTURER_SST	0x00BF
+#define SST49LF004B	        0x0060
+
 static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
 static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
 static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
 static int cfi_amdstd_erase_chip(struct mtd_info *, struct erase_info *);
 static int cfi_amdstd_erase_varsize(struct mtd_info *, struct erase_info *);
-static int cfi_amdstd_lock_varsize(struct mtd_info *, loff_t, size_t);
-static int cfi_amdstd_unlock_varsize(struct mtd_info *, loff_t, size_t);
 static void cfi_amdstd_sync (struct mtd_info *);
 static int cfi_amdstd_suspend (struct mtd_info *);
 static void cfi_amdstd_resume (struct mtd_info *);
@@ -55,8 +57,11 @@
 static void cfi_amdstd_destroy(struct mtd_info *);
 
 struct mtd_info *cfi_cmdset_0002(struct map_info *, int);
-static struct mtd_info *cfi_amdstd_setup (struct map_info *);
+static struct mtd_info *cfi_amdstd_setup (struct mtd_info *);
 
+static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
+static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr);
+#include "fwh_lock.h"
 
 static struct mtd_chip_driver cfi_amdstd_chipdrv = {
 	.probe		= NULL, /* Not usable directly */
@@ -66,7 +71,6 @@
 };
 
 
-/* #define DEBUG_LOCK_BITS */
 /* #define DEBUG_CFI_FEATURES */
 
 
@@ -122,8 +126,9 @@
 
 #ifdef AMD_BOOTLOC_BUG
 /* Wheee. Bring me the head of someone at AMD. */
-static void fixup_amd_bootblock(struct map_info *map, void* param)
+static void fixup_amd_bootblock(struct mtd_info *mtd, void* param)
 {
+	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = map->fldrv_priv;
 	struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
 	__u8 major = extp->MajorVersion;
@@ -141,25 +146,92 @@
 }
 #endif
 
-static struct cfi_fixup fixup_table[] = {
+static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
+{
+	struct map_info *map = mtd->priv;
+	struct cfi_private *cfi = map->fldrv_priv;
+	if (cfi->cfiq->BufWriteTimeoutTyp) {
+		DEBUG(MTD_DEBUG_LEVEL1, "Using buffer write method\n" );
+		mtd->write = cfi_amdstd_write_buffers;
+	}
+}
+
+static void fixup_use_secsi(struct mtd_info *mtd, void *param)
+{
+	/* Setup for chips with a secsi area */
+	mtd->read_user_prot_reg = cfi_amdstd_secsi_read;
+	mtd->read_fact_prot_reg = cfi_amdstd_secsi_read;
+}
+
+static void fixup_use_erase_chip(struct mtd_info *mtd, void *param)
+{
+	struct map_info *map = mtd->priv;
+	struct cfi_private *cfi = map->fldrv_priv;
+	if ((cfi->cfiq->NumEraseRegions == 1) &&
+		((cfi->cfiq->EraseRegionInfo[0] & 0xffff) == 0)) {
+		mtd->erase = cfi_amdstd_erase_chip;
+	}
+	
+}
+
+static struct cfi_fixup cfi_fixup_table[] = {
 #ifdef AMD_BOOTLOC_BUG
-	{
-		0x0001,		/* AMD */
-		CFI_ID_ANY,
-		fixup_amd_bootblock, NULL
-	},
+	{ CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
+#endif
+	{ CFI_MFR_AMD, 0x0050, fixup_use_secsi, NULL, },
+	{ CFI_MFR_AMD, 0x0053, fixup_use_secsi, NULL, },
+	{ CFI_MFR_AMD, 0x0055, fixup_use_secsi, NULL, },
+	{ CFI_MFR_AMD, 0x0056, fixup_use_secsi, NULL, },
+	{ CFI_MFR_AMD, 0x005C, fixup_use_secsi, NULL, },
+	{ CFI_MFR_AMD, 0x005F, fixup_use_secsi, NULL, },
+#if !FORCE_WORD_WRITE
+	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
 #endif
 	{ 0, 0, NULL, NULL }
 };
+static struct cfi_fixup jedec_fixup_table[] = {
+	{ MANUFACTURER_SST, SST49LF004B, fixup_use_fwh_lock, NULL, },
+	{ 0, 0, NULL, NULL }
+};
+
+static struct cfi_fixup fixup_table[] = {
+	/* The CFI vendor ids and the JEDEC vendor IDs appear
+	 * to be common.  It is like the devices id's are as
+	 * well.  This table is to pick all cases where
+	 * we know that is the case.
+	 */
+	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_erase_chip, NULL },
+	{ 0, 0, NULL, NULL }
+};
 
 
 struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
-	unsigned char bootloc;
+	struct mtd_info *mtd;
 	int i;
 
+	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+	if (!mtd) {
+		printk(KERN_WARNING "Failed to allocate memory for MTD device\n");
+		return NULL;
+	}
+	memset(mtd, 0, sizeof(*mtd));
+	mtd->priv = map;
+	mtd->type = MTD_NORFLASH;
+
+	/* Fill in the default mtd operations */
+	mtd->erase   = cfi_amdstd_erase_varsize;
+	mtd->write   = cfi_amdstd_write_words;
+	mtd->read    = cfi_amdstd_read;
+	mtd->sync    = cfi_amdstd_sync;
+	mtd->suspend = cfi_amdstd_suspend;
+	mtd->resume  = cfi_amdstd_resume;
+	mtd->flags   = MTD_CAP_NORFLASH;
+	mtd->name    = map->name;
+
 	if (cfi->cfi_mode==CFI_MODE_CFI){
+		unsigned char bootloc;
 		/* 
 		 * It's a real CFI chip, not one for which the probe
 		 * routine faked a CFI structure. So we read the feature
@@ -169,13 +241,16 @@
 		struct cfi_pri_amdstd *extp;
 
 		extp = (struct cfi_pri_amdstd*)cfi_read_pri(map, adr, sizeof(*extp), "Amd/Fujitsu");
-		if (!extp)
+		if (!extp) {
+			kfree(mtd);
 			return NULL;
+		}
 
 		/* Install our own private info structure */
 		cfi->cmdset_priv = extp;	
 
-		cfi_fixup(map, fixup_table);
+		/* Apply cfi device specific fixups */
+		cfi_fixup(mtd, cfi_fixup_table);
 
 #ifdef DEBUG_CFI_FEATURES
 		/* Tell the user about it in lots of lovely detail */
@@ -201,43 +276,28 @@
 				cfi->cfiq->EraseRegionInfo[j] = swap;
 			}
 		}
-		/*
-		 * These might already be setup (more correctly) by
-		 * jedec_probe.c - still need it for cfi_probe.c path.
-		 */
-		if ( ! (cfi->addr_unlock1 && cfi->addr_unlock2) ) {
-			switch (cfi->device_type) {
-			case CFI_DEVICETYPE_X8:
-				cfi->addr_unlock1 = 0x555; 
-				cfi->addr_unlock2 = 0x2aa; 
-				break;
-			case CFI_DEVICETYPE_X16:
-				cfi->addr_unlock1 = 0xaaa;
-				if (map_bankwidth(map) == cfi_interleave(cfi)) {
-					/* X16 chip(s) in X8 mode */
-					cfi->addr_unlock2 = 0x555;
-				} else {
-					cfi->addr_unlock2 = 0x554;
-				}
-				break;
-			case CFI_DEVICETYPE_X32:
-				cfi->addr_unlock1 = 0x1554;
-				if (map_bankwidth(map) == cfi_interleave(cfi)*2) {
-					/* X32 chip(s) in X16 mode */
-					cfi->addr_unlock1 = 0xaaa;
-				} else {
-					cfi->addr_unlock2 = 0xaa8; 
-				}
-				break;
-			default:
-				printk(KERN_WARNING
-				       "MTD %s(): Unsupported device type %d\n",
-				       __func__, cfi->device_type);
-				return NULL;
-			}
+		/* Set the default CFI lock/unlock addresses */
+		cfi->addr_unlock1 = 0x555;
+		cfi->addr_unlock2 = 0x2aa;
+		/* Modify the unlock address if we are in compatibility mode */
+		if (	/* x16 in x8 mode */
+			((cfi->device_type == CFI_DEVICETYPE_X8) && 
+				(cfi->cfiq->InterfaceDesc == 2)) ||
+			/* x32 in x16 mode */
+			((cfi->device_type == CFI_DEVICETYPE_X16) &&
+				(cfi->cfiq->InterfaceDesc == 4))) 
+		{
+			cfi->addr_unlock1 = 0xaaa;
+			cfi->addr_unlock2 = 0x555;
 		}
 
 	} /* CFI mode */
+	else if (cfi->cfi_mode == CFI_MODE_JEDEC) {
+		/* Apply jedec specific fixups */
+		cfi_fixup(mtd, jedec_fixup_table);
+	}
+	/* Apply generic fixups */
+	cfi_fixup(mtd, fixup_table);
 
 	for (i=0; i< cfi->numchips; i++) {
 		cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
@@ -246,32 +306,22 @@
 	}		
 	
 	map->fldrv = &cfi_amdstd_chipdrv;
-
-	return cfi_amdstd_setup(map);
+	
+	return cfi_amdstd_setup(mtd);
 }
 
 
-static struct mtd_info *cfi_amdstd_setup(struct map_info *map)
+static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
 {
+	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = map->fldrv_priv;
-	struct mtd_info *mtd;
 	unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave;
 	unsigned long offset = 0;
 	int i,j;
 
-	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
 	printk(KERN_NOTICE "number of %s chips: %d\n", 
 	       (cfi->cfi_mode == CFI_MODE_CFI)?"CFI":"JEDEC",cfi->numchips);
-
-	if (!mtd) {
-		printk(KERN_WARNING "Failed to allocate memory for MTD device\n");
-		goto setup_err;
-	}
-
-	memset(mtd, 0, sizeof(*mtd));
-	mtd->priv = map;
-	mtd->type = MTD_NORFLASH;
-	/* Also select the correct geometry setup too */ 
+	/* Select the correct geometry setup */ 
 	mtd->size = devsize * cfi->numchips;
 
 	mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
@@ -312,54 +362,10 @@
 	}
 #endif
 
-	if (mtd->numeraseregions == 1
-	    && ((cfi->cfiq->EraseRegionInfo[0] & 0xffff) + 1) == 1) {
-		mtd->erase = cfi_amdstd_erase_chip;
-	} else {
-		mtd->erase = cfi_amdstd_erase_varsize;
-		mtd->lock = cfi_amdstd_lock_varsize;
-		mtd->unlock = cfi_amdstd_unlock_varsize;
-	}
-
-	if ( cfi->cfiq->BufWriteTimeoutTyp && !FORCE_WORD_WRITE) {
-		DEBUG(MTD_DEBUG_LEVEL1, "Using buffer write method\n" );
-		mtd->write = cfi_amdstd_write_buffers;
-	} else {
-		DEBUG(MTD_DEBUG_LEVEL1, "Using word write method\n" );
-		mtd->write = cfi_amdstd_write_words;
-	}
-
-	mtd->read = cfi_amdstd_read;
-
 	/* FIXME: erase-suspend-program is broken.  See
 	   http://lists.infradead.org/pipermail/linux-mtd/2003-December/009001.html */
 	printk(KERN_NOTICE "cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.\n");
 
-	/* does this chip have a secsi area? */
-	if(cfi->mfr==1){
-		
-		switch(cfi->id){
-		case 0x50:
-		case 0x53:
-		case 0x55:
-		case 0x56:
-		case 0x5C:
-		case 0x5F:
-			/* Yes */
-			mtd->read_user_prot_reg = cfi_amdstd_secsi_read;
-			mtd->read_fact_prot_reg = cfi_amdstd_secsi_read;
-		default:		       
-			;
-		}
-	}
-	
-		
-	mtd->sync = cfi_amdstd_sync;
-	mtd->suspend = cfi_amdstd_suspend;
-	mtd->resume = cfi_amdstd_resume;
-	mtd->flags = MTD_CAP_NORFLASH;
-	map->fldrv = &cfi_amdstd_chipdrv;
-	mtd->name = map->name;
 	__module_get(THIS_MODULE);
 	return mtd;
 
@@ -434,6 +440,7 @@
 			goto sleep;
 
 		if (!(mode == FL_READY || mode == FL_POINT
+		      || !cfip
 		      || (mode == FL_WRITING && (cfip->EraseSuspend & 0x2))
 		      || (mode == FL_WRITING && (cfip->EraseSuspend & 0x1))))
 			goto sleep;
@@ -624,14 +631,12 @@
 
 	chip->state = FL_READY;
 
-	/* should these be CFI_DEVICETYPE_X8 instead of cfi->device_type? */
 	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x88, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
 	
 	map_copy_from(map, buf, adr, len);
 
-	/* should these be CFI_DEVICETYPE_X8 instead of cfi->device_type? */
 	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x90, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
@@ -732,17 +737,9 @@
 
 	ENABLE_VPP(map);
  retry:
-	/*
-	 * The CFI_DEVICETYPE_X8 argument is needed even when
-	 * cfi->device_type != CFI_DEVICETYPE_X8.  The addresses for
-	 * command sequences don't scale even when the device is
-	 * wider.  This is the case for many of the cfi_send_gen_cmd()
-	 * below.  I'm not sure, however, why some use
-	 * cfi->device_type.
-	 */
-	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
+	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
 	map_write(map, datum, adr);
 	chip->state = FL_WRITING;
 
@@ -958,7 +955,7 @@
 	struct cfi_private *cfi = map->fldrv_priv;
 	unsigned long timeo = jiffies + HZ;
 	/* see comments in do_write_oneword() regarding uWriteTimeo. */
-	static unsigned long uWriteTimeout = ( HZ / 1000 ) + 1;
+	unsigned long uWriteTimeout = ( HZ / 1000 ) + 1;
 	int ret = -EIO;
 	unsigned long cmd_adr;
 	int z, words;
@@ -980,9 +977,9 @@
 	       __func__, adr, datum.x[0] );
 
 	ENABLE_VPP(map);
-	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	//cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
+	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
+	//cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
 
 	/* Write Buffer Load */
 	map_write(map, CMD(0x25), cmd_adr);
@@ -1081,8 +1078,8 @@
 		size_t local_len = (-ofs)&(map_bankwidth(map)-1);
 		if (local_len > len)
 			local_len = len;
-		ret = cfi_amdstd_write_words(mtd, to, local_len,
-					       retlen, buf);
+		ret = cfi_amdstd_write_words(mtd, ofs + (chipnum<<cfi->chipshift),
+					     local_len, retlen, buf);
 		if (ret)
 			return ret;
 		ofs += local_len;
@@ -1128,7 +1125,8 @@
 	if (len) {
 		size_t retlen_dregs = 0;
 
-		ret = cfi_amdstd_write_words(mtd, to, len, &retlen_dregs, buf);
+		ret = cfi_amdstd_write_words(mtd, ofs + (chipnum<<cfi->chipshift),
+					     len, &retlen_dregs, buf);
 
 		*retlen += retlen_dregs;
 		return ret;
@@ -1163,12 +1161,12 @@
 	       __func__, chip->start );
 
 	ENABLE_VPP(map);
-	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x10, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
+	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x10, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
 
 	chip->state = FL_ERASING;
 	chip->erase_suspended = 0;
@@ -1229,100 +1227,7 @@
 }
 
 
-typedef int (*frob_t)(struct map_info *map, struct flchip *chip,
-		      unsigned long adr, void *thunk);
-
-
-static int cfi_amdstd_varsize_frob(struct mtd_info *mtd, frob_t frob,
-				   loff_t ofs, size_t len, void *thunk)
-{
-	struct map_info *map = mtd->priv;
-	struct cfi_private *cfi = map->fldrv_priv;
-	unsigned long adr;
-	int chipnum, ret = 0;
-	int i, first;
-	struct mtd_erase_region_info *regions = mtd->eraseregions;
-
-	if (ofs > mtd->size)
-		return -EINVAL;
-
-	if ((len + ofs) > mtd->size)
-		return -EINVAL;
-
-	/* Check that both start and end of the requested erase are
-	 * aligned with the erasesize at the appropriate addresses.
-	 */
-
-	i = 0;
-
-	/* Skip all erase regions which are ended before the start of 
-	   the requested erase. Actually, to save on the calculations,
-	   we skip to the first erase region which starts after the
-	   start of the requested erase, and then go back one.
-	*/
-	
-	while (i < mtd->numeraseregions && ofs >= regions[i].offset)
-	       i++;
-	i--;
-
-	/* OK, now i is pointing at the erase region in which this 
-	   erase request starts. Check the start of the requested
-	   erase range is aligned with the erase size which is in
-	   effect here.
-	*/
-
-	if (ofs & (regions[i].erasesize-1))
-		return -EINVAL;
-
-	/* Remember the erase region we start on */
-	first = i;
-
-	/* Next, check that the end of the requested erase is aligned
-	 * with the erase region at that address.
-	 */
-
-	while (i<mtd->numeraseregions && (ofs + len) >= regions[i].offset)
-		i++;
-
-	/* As before, drop back one to point at the region in which
-	   the address actually falls
-	*/
-	i--;
-	
-	if ((ofs + len) & (regions[i].erasesize-1))
-		return -EINVAL;
-
-	chipnum = ofs >> cfi->chipshift;
-	adr = ofs - (chipnum << cfi->chipshift);
-
-	i=first;
-
-	while (len) {
-		ret = (*frob)(map, &cfi->chips[chipnum], adr, thunk);
-		
-		if (ret)
-			return ret;
-
-		adr += regions[i].erasesize;
-		len -= regions[i].erasesize;
-
-		if (adr % (1<< cfi->chipshift) == ((regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift)))
-			i++;
-
-		if (adr >> cfi->chipshift) {
-			adr = 0;
-			chipnum++;
-			
-			if (chipnum >= cfi->numchips)
-			break;
-		}
-	}
-
-	return 0;
-}
-
-
-static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr, void *thunk)
+static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr, int len, void *thunk)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
 	unsigned long timeo = jiffies + HZ;
@@ -1342,11 +1247,11 @@
 	       __func__, adr );
 
 	ENABLE_VPP(map);
-	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
-	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
+	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
+	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
 	map_write(map, CMD(0x30), adr);
 
 	chip->state = FL_ERASING;
@@ -1415,7 +1320,7 @@
 	ofs = instr->addr;
 	len = instr->len;
 
-	ret = cfi_amdstd_varsize_frob(mtd, do_erase_oneblock, ofs, len, NULL);
+	ret = cfi_varsize_frob(mtd, do_erase_oneblock, ofs, len, NULL);
 	if (ret)
 		return ret;
 
@@ -1588,137 +1493,6 @@
 	}
 }
 
-
-#ifdef DEBUG_LOCK_BITS
-
-static int do_printlockstatus_oneblock(struct map_info *map,
-				       struct flchip *chip,
-				       unsigned long adr,
-				       void *thunk)
-{
-	struct cfi_private *cfi = map->fldrv_priv;
-	int ofs_factor = cfi->interleave * cfi->device_type;
-
-	cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
-	printk(KERN_DEBUG "block status register for 0x%08lx is %x\n",
-	       adr, cfi_read_query(map, adr+(2*ofs_factor)));
-	cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
-	
-	return 0;
-}
-
-
-#define debug_dump_locks(mtd, frob, ofs, len, thunk) \
-	cfi_amdstd_varsize_frob((mtd), (frob), (ofs), (len), (thunk))
-
-#else
-
-#define debug_dump_locks(...)
-
-#endif /* DEBUG_LOCK_BITS */
-
-
-struct xxlock_thunk {
-	uint8_t val;
-	flstate_t state;
-};
-
-
-#define DO_XXLOCK_ONEBLOCK_LOCK   ((struct xxlock_thunk){0x01, FL_LOCKING})
-#define DO_XXLOCK_ONEBLOCK_UNLOCK ((struct xxlock_thunk){0x00, FL_UNLOCKING})
-
-
-/*
- * FIXME - this is *very* specific to a particular chip.  It likely won't
- * work for all chips that require unlock.  It also hasn't been tested
- * with interleaved chips.
- */
-static int do_xxlock_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr, void *thunk)
-{
-	struct cfi_private *cfi = map->fldrv_priv;
-	struct xxlock_thunk *xxlt = (struct xxlock_thunk *)thunk;
-	int ret;
-
-	/*
-	 * This is easy because these are writes to registers and not writes
-	 * to flash memory - that means that we don't have to check status
-	 * and timeout.
-	 */
-
-	adr += chip->start;
-	/*
-	 * lock block registers:
-	 * - on 64k boundariesand
-	 * - bit 1 set high
-	 * - block lock registers are 4MiB lower - overflow subtract (danger)
-	 */
-	adr = ((adr & ~0xffff) | 0x2) + ~0x3fffff;
-
-	cfi_spin_lock(chip->mutex);
-	ret = get_chip(map, chip, adr, FL_LOCKING);
-	if (ret) {
-		cfi_spin_unlock(chip->mutex);
-		return ret;
-	}
-
-	chip->state = xxlt->state;
-	map_write(map, CMD(xxlt->val), adr);
-	
-	/* Done and happy. */
-	chip->state = FL_READY;
-	put_chip(map, chip, adr);
-	cfi_spin_unlock(chip->mutex);
-	return 0;
-}
-
-
-static int cfi_amdstd_lock_varsize(struct mtd_info *mtd,
-				   loff_t ofs,
-				   size_t len)
-{
-	int ret;
-
-	DEBUG(MTD_DEBUG_LEVEL3,
-	      "%s: lock status before, ofs=0x%08llx, len=0x%08zX\n",
-	      __func__, ofs, len);
-	debug_dump_locks(mtd, do_printlockstatus_oneblock, ofs, len, 0);
-
-	ret = cfi_amdstd_varsize_frob(mtd, do_xxlock_oneblock, ofs, len,
-				      (void *)&DO_XXLOCK_ONEBLOCK_LOCK);
-	
-	DEBUG(MTD_DEBUG_LEVEL3,
-	      "%s: lock status after, ret=%d\n",
-	      __func__, ret);
-
-	debug_dump_locks(mtd, do_printlockstatus_oneblock, ofs, len, 0);
-
-	return ret;
-}
-
-
-static int cfi_amdstd_unlock_varsize(struct mtd_info *mtd,
-				     loff_t ofs,
-				     size_t len)
-{
-	int ret;
-
-	DEBUG(MTD_DEBUG_LEVEL3,
-	      "%s: lock status before, ofs=0x%08llx, len=0x%08zX\n",
-	      __func__, ofs, len);
-	debug_dump_locks(mtd, do_printlockstatus_oneblock, ofs, len, 0);
-
-	ret = cfi_amdstd_varsize_frob(mtd, do_xxlock_oneblock, ofs, len,
-				      (void *)&DO_XXLOCK_ONEBLOCK_UNLOCK);
-	
-	DEBUG(MTD_DEBUG_LEVEL3,
-	      "%s: lock status after, ret=%d\n",
-	      __func__, ret);
-	debug_dump_locks(mtd, do_printlockstatus_oneblock, ofs, len, 0);
-	
-	return ret;
-}
-
-
 static void cfi_amdstd_destroy(struct mtd_info *mtd)
 {
 	struct map_info *map = mtd->priv;
@@ -1732,7 +1506,7 @@
 static char im_name[]="cfi_cmdset_0002";
 
 
-int __init cfi_amdstd_init(void)
+static int __init cfi_amdstd_init(void)
 {
 	inter_module_register(im_name, THIS_MODULE, &cfi_cmdset_0002);
 	return 0;
diff -Nru a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
--- a/drivers/mtd/chips/cfi_cmdset_0020.c	2004-12-24 13:36:35 -08:00
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c	2004-12-24 13:36:35 -08:00
@@ -4,7 +4,7 @@
  *
  * (C) 2000 Red Hat. GPL'd
  *
- * $Id: cfi_cmdset_0020.c,v 1.15 2004/08/09 13:19:43 dwmw2 Exp $
+ * $Id: cfi_cmdset_0020.c,v 1.16 2004/11/16 18:29:00 dwmw2 Exp $
  * 
  * 10/10/2000	Nicolas Pitre <nico@cam.org>
  * 	- completely revamped method functions so they are aware and
@@ -1401,7 +1401,7 @@
 
 static char im_name[]="cfi_cmdset_0020";
 
-int __init cfi_staa_init(void)
+static int __init cfi_staa_init(void)
 {
 	inter_module_register(im_name, THIS_MODULE, &cfi_cmdset_0020);
 	return 0;
diff -Nru a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c
--- a/drivers/mtd/chips/cfi_probe.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/mtd/chips/cfi_probe.c	2004-12-24 13:37:18 -08:00
@@ -1,7 +1,7 @@
 /* 
    Common Flash Interface probe code.
    (C) 2000 Red Hat. GPL'd.
-   $Id: cfi_probe.c,v 1.77 2004/07/14 08:38:44 dwmw2 Exp $
+   $Id: cfi_probe.c,v 1.79 2004/10/20 23:04:01 dwmw2 Exp $
 */
 
 #include <linux/config.h>
@@ -39,25 +39,24 @@
 				struct cfi_private *cfi)
 {
 	int osf = cfi->interleave * cfi->device_type;	// scale factor
-	map_word val;
-	map_word qry;
+	map_word val[3];
+	map_word qry[3];
 
-	qry =  cfi_build_cmd('Q', map, cfi);
-	val = map_read(map, base + osf*0x10);
+	qry[0] = cfi_build_cmd('Q', map, cfi);
+	qry[1] = cfi_build_cmd('R', map, cfi);
+	qry[2] = cfi_build_cmd('Y', map, cfi);
+
+	val[0] = map_read(map, base + osf*0x10);
+	val[1] = map_read(map, base + osf*0x11);
+	val[2] = map_read(map, base + osf*0x12);
 
-	if (!map_word_equal(map, qry, val))
+	if (!map_word_equal(map, qry[0], val[0]))
 		return 0;
 
-	qry =  cfi_build_cmd('R', map, cfi);
-	val = map_read(map, base + osf*0x11);
-
-	if (!map_word_equal(map, qry, val))
+	if (!map_word_equal(map, qry[1], val[1]))
 		return 0;
 
-	qry =  cfi_build_cmd('Y', map, cfi);
-	val = map_read(map, base + osf*0x12);
-
-	if (!map_word_equal(map, qry, val))
+	if (!map_word_equal(map, qry[2], val[2]))
 		return 0;
 
 	return 1; 	// nothing found
@@ -243,12 +242,27 @@
 		
 	case P_ID_AMD_EXT:
 		return "AMD/Fujitsu Extended";
+
+	case P_ID_WINBOND:
+		return "Winbond Standard";
 		
+	case P_ID_ST_ADV:
+		return "ST Advanced";
+
 	case P_ID_MITSUBISHI_STD:
 		return "Mitsubishi Standard";
 		
 	case P_ID_MITSUBISHI_EXT:
 		return "Mitsubishi Extended";
+
+	case P_ID_SST_PAGE:
+		return "SST Page Write";
+
+	case P_ID_INTEL_PERFORMANCE:
+		return "Intel Performance Code";
+		
+	case P_ID_INTEL_DATA:
+		return "Intel Data";
 		
 	case P_ID_RESERVED:
 		return "Not Allowed / Reserved for Future Use";
@@ -325,6 +339,10 @@
 		
 	case 3:
 		printk("  - x32-only asynchronous interface\n");
+		break;
+		
+	case 4:
+		printk("  - supports x16 and x32 via Word# with asynchronous interface\n");
 		break;
 		
 	case 65535:
diff -Nru a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c
--- a/drivers/mtd/chips/cfi_util.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/mtd/chips/cfi_util.c	2004-12-24 13:37:00 -08:00
@@ -7,7 +7,7 @@
  *
  * This code is covered by the GPL.
  *
- * $Id: cfi_util.c,v 1.4 2004/07/14 08:38:44 dwmw2 Exp $
+ * $Id: cfi_util.c,v 1.5 2004/08/12 06:40:23 eric Exp $
  *
  */
 
@@ -22,6 +22,7 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/cfi.h>
 #include <linux/mtd/compatmac.h>
@@ -74,19 +75,114 @@
 
 EXPORT_SYMBOL(cfi_read_pri);
 
-void cfi_fixup(struct map_info *map, struct cfi_fixup* fixups)
+void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup *fixups)
 {
+	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = map->fldrv_priv;
 	struct cfi_fixup *f;
 
 	for (f=fixups; f->fixup; f++) {
 		if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi->mfr)) &&
 		    ((f->id  == CFI_ID_ANY)  || (f->id  == cfi->id))) {
-			f->fixup(map, f->param);
+			f->fixup(mtd, f->param);
 		}
 	}
 }
 
 EXPORT_SYMBOL(cfi_fixup);
+
+int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
+				     loff_t ofs, size_t len, void *thunk)
+{
+	struct map_info *map = mtd->priv;
+	struct cfi_private *cfi = map->fldrv_priv;
+	unsigned long adr;
+	int chipnum, ret = 0;
+	int i, first;
+	struct mtd_erase_region_info *regions = mtd->eraseregions;
+
+	if (ofs > mtd->size)
+		return -EINVAL;
+
+	if ((len + ofs) > mtd->size)
+		return -EINVAL;
+
+	/* Check that both start and end of the requested erase are
+	 * aligned with the erasesize at the appropriate addresses.
+	 */
+
+	i = 0;
+
+	/* Skip all erase regions which are ended before the start of 
+	   the requested erase. Actually, to save on the calculations,
+	   we skip to the first erase region which starts after the
+	   start of the requested erase, and then go back one.
+	*/
+	
+	while (i < mtd->numeraseregions && ofs >= regions[i].offset)
+	       i++;
+	i--;
+
+	/* OK, now i is pointing at the erase region in which this 
+	   erase request starts. Check the start of the requested
+	   erase range is aligned with the erase size which is in
+	   effect here.
+	*/
+
+	if (ofs & (regions[i].erasesize-1))
+		return -EINVAL;
+
+	/* Remember the erase region we start on */
+	first = i;
+
+	/* Next, check that the end of the requested erase is aligned
+	 * with the erase region at that address.
+	 */
+
+	while (i<mtd->numeraseregions && (ofs + len) >= regions[i].offset)
+		i++;
+
+	/* As before, drop back one to point at the region in which
+	   the address actually falls
+	*/
+	i--;
+	
+	if ((ofs + len) & (regions[i].erasesize-1))
+		return -EINVAL;
+
+	chipnum = ofs >> cfi->chipshift;
+	adr = ofs - (chipnum << cfi->chipshift);
+
+	i=first;
+
+	while(len) {
+		unsigned long chipmask;
+		int size = regions[i].erasesize;
+
+		ret = (*frob)(map, &cfi->chips[chipnum], adr, size, thunk);
+		
+		if (ret)
+			return ret;
+
+		adr += size;
+		len -= size;
+
+		chipmask = (1 << cfi->chipshift) - 1;
+		if ((adr & chipmask) == ((regions[i].offset + size * regions[i].numblocks) & chipmask))
+			i++;
+
+		if (adr >> cfi->chipshift) {
+			adr = 0;
+			chipnum++;
+			
+			if (chipnum >= cfi->numchips)
+			break;
+		}
+	}
+
+	return 0;
+}
+
+EXPORT_SYMBOL(cfi_varsize_frob);
 
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c
--- a/drivers/mtd/chips/chipreg.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/mtd/chips/chipreg.c	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: chipreg.c,v 1.16 2003/05/29 09:36:15 dwmw2 Exp $
+ * $Id: chipreg.c,v 1.17 2004/11/16 18:29:00 dwmw2 Exp $
  *
  * Registration for chip drivers
  *
@@ -15,7 +15,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/compatmac.h>
 
-spinlock_t chip_drvs_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t chip_drvs_lock = SPIN_LOCK_UNLOCKED;
 static LIST_HEAD(chip_drvs_list);
 
 void register_mtd_chip_driver(struct mtd_chip_driver *drv)
diff -Nru a/drivers/mtd/chips/fwh_lock.h b/drivers/mtd/chips/fwh_lock.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mtd/chips/fwh_lock.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,107 @@
+#ifndef FWH_LOCK_H
+#define FWH_LOCK_H
+
+
+enum fwh_lock_state {
+        FWH_UNLOCKED   = 0,
+	FWH_DENY_WRITE = 1,
+	FWH_IMMUTABLE  = 2,
+	FWH_DENY_READ  = 4,
+};
+
+struct fwh_xxlock_thunk {
+	enum fwh_lock_state val;
+	flstate_t state;
+};
+
+
+#define FWH_XXLOCK_ONEBLOCK_LOCK   ((struct fwh_xxlock_thunk){ FWH_DENY_WRITE, FL_LOCKING})
+#define FWH_XXLOCK_ONEBLOCK_UNLOCK ((struct fwh_xxlock_thunk){ FWH_UNLOCKED,   FL_UNLOCKING})
+
+/*
+ * This locking/unlock is specific to firmware hub parts.  Only one
+ * is known that supports the Intel command set.    Firmware
+ * hub parts cannot be interleaved as they are on the LPC bus
+ * so this code has not been tested with interleaved chips,
+ * and will likely fail in that context.
+ */
+static int fwh_xxlock_oneblock(struct map_info *map, struct flchip *chip, 
+	unsigned long adr, int len, void *thunk)
+{
+	struct cfi_private *cfi = map->fldrv_priv;
+	struct fwh_xxlock_thunk *xxlt = (struct fwh_xxlock_thunk *)thunk;
+	int ret;
+
+	/* Refuse the operation if the we cannot look behind the chip */
+	if (chip->start < 0x400000) {
+		DEBUG( MTD_DEBUG_LEVEL3,
+			"MTD %s(): chip->start: %lx wanted >= 0x400000\n",
+			__func__, chip->start );
+		return -EIO;
+	}
+	/*
+	 * lock block registers:
+	 * - on 64k boundariesand
+	 * - bit 1 set high
+	 * - block lock registers are 4MiB lower - overflow subtract (danger)
+	 * 
+	 * The address manipulation is first done on the logical address
+	 * which is 0 at the start of the chip, and then the offset of
+	 * the individual chip is addted to it.  Any other order a weird
+	 * map offset could cause problems.
+	 */
+	adr = (adr & ~0xffffUL) | 0x2;
+	adr += chip->start - 0x400000;
+
+	/*
+	 * This is easy because these are writes to registers and not writes
+	 * to flash memory - that means that we don't have to check status
+	 * and timeout.
+	 */
+	cfi_spin_lock(chip->mutex);
+	ret = get_chip(map, chip, adr, FL_LOCKING);
+	if (ret) {
+		cfi_spin_unlock(chip->mutex);
+		return ret;
+	}
+
+	chip->state = xxlt->state;
+	map_write(map, CMD(xxlt->val), adr);
+
+	/* Done and happy. */
+	chip->state = FL_READY;
+	put_chip(map, chip, adr);
+	cfi_spin_unlock(chip->mutex);
+	return 0;
+}
+
+
+static int fwh_lock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len)
+{
+	int ret;
+
+	ret = cfi_varsize_frob(mtd, fwh_xxlock_oneblock, ofs, len,
+		(void *)&FWH_XXLOCK_ONEBLOCK_LOCK);
+
+	return ret;
+}
+
+
+static int fwh_unlock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len)
+{
+	int ret;
+
+	ret = cfi_varsize_frob(mtd, fwh_xxlock_oneblock, ofs, len,
+		(void *)&FWH_XXLOCK_ONEBLOCK_UNLOCK);
+	
+	return ret;
+}
+
+static void fixup_use_fwh_lock(struct mtd_info *mtd, void *param)
+{
+	printk(KERN_NOTICE "using fwh lock/unlock method\n");
+	/* Setup for the chips with the fwh lock method */
+	mtd->lock   = fwh_lock_varsize;
+	mtd->unlock = fwh_unlock_varsize;
+}
+#endif /* FWH_LOCK_H */
diff -Nru a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c
--- a/drivers/mtd/chips/gen_probe.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/mtd/chips/gen_probe.c	2004-12-24 13:37:19 -08:00
@@ -2,7 +2,7 @@
  * Routines common to all CFI-type probes.
  * (C) 2001-2003 Red Hat, Inc.
  * GPL'd
- * $Id: gen_probe.c,v 1.19 2004/07/13 22:33:32 dwmw2 Exp $
+ * $Id: gen_probe.c,v 1.21 2004/08/14 15:14:05 dwmw2 Exp $
  */
 
 #include <linux/kernel.h>
@@ -64,7 +64,7 @@
 	   interleave and device type, etc. */
 	if (!genprobe_new_chip(map, cp, &cfi)) {
 		/* The probe didn't like it */
-		printk(KERN_WARNING "%s: Found no %s device at location zero\n",
+		printk(KERN_DEBUG "%s: Found no %s device at location zero\n",
 		       cp->name, map->name);
 		return NULL;
 	}		
@@ -169,8 +169,12 @@
 
 		cfi->interleave = nr_chips;
 
-		for (type = 0; type < 3; type++) {
-			cfi->device_type = 1<<type;
+		/* Minimum device size. Don't look for one 8-bit device
+		   in a 16-bit bus, etc. */
+		type = map_bankwidth(map) / nr_chips;
+
+		for (; type <= CFI_DEVICETYPE_X32; type<<=1) {
+			cfi->device_type = type;
 
 			if (cp->probe_chip(map, 0, NULL, cfi))
 				return 1;
diff -Nru a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c
--- a/drivers/mtd/chips/jedec_probe.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/mtd/chips/jedec_probe.c	2004-12-24 13:37:31 -08:00
@@ -1,7 +1,7 @@
 /* 
    Common Flash Interface probe code.
    (C) 2000 Red Hat. GPL'd.
-   $Id: jedec_probe.c,v 1.51 2004/07/14 14:44:30 thayne Exp $
+   $Id: jedec_probe.c,v 1.58 2004/11/16 18:29:00 dwmw2 Exp $
    See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5)
    for the standard this probe goes back to.
 
@@ -107,6 +107,7 @@
 #define I82802AC	0x00ac
 
 /* Macronix */
+#define MX29LV040C	0x004F
 #define MX29LV160T	0x22C4
 #define MX29LV160B	0x2249
 #define MX29F016	0x00AD
@@ -128,6 +129,7 @@
 #define M50FW040	0x002C
 #define M50FW080	0x002D
 #define M50FW016	0x002E
+#define M50LPW080       0x002F
 
 /* SST */
 #define SST29EE020	0x0010
@@ -181,8 +183,8 @@
 
 
 struct unlock_addr {
-	int addr1;
-	int addr2;
+	u32 addr1;
+	u32 addr2;
 };
 
 
@@ -512,12 +514,12 @@
 			ERASEINFO(0x10000,8),
 		}
 	}, {
-		.mfr_id = MANUFACTURER_AMD,
-		.dev_id = AM29F002T,
-		.name = "AMD AM29F002T",
-		.DevSize = SIZE_256KiB,
-		.NumEraseRegions = 4,
-		.regions = {ERASEINFO(0x10000,3),
+		mfr_id: MANUFACTURER_AMD,
+		dev_id: AM29F002T,
+		name: "AMD AM29F002T",
+		DevSize: SIZE_256KiB,
+		NumEraseRegions: 4,
+		regions: {ERASEINFO(0x10000,3),
 			  ERASEINFO(0x08000,1),
 			  ERASEINFO(0x02000,2),
 			  ERASEINFO(0x04000,1)
@@ -768,12 +770,12 @@
 			ERASEINFO(0x04000,1)
 		}
 	}, {
-		.mfr_id = MANUFACTURER_HYUNDAI,
-		.dev_id = HY29F002T,
-		.name = "Hyundai HY29F002T",
-		.DevSize = SIZE_256KiB,
-		.NumEraseRegions = 4,
-		.regions = {ERASEINFO(0x10000,3),
+		mfr_id: MANUFACTURER_HYUNDAI,
+		dev_id: HY29F002T,
+		name: "Hyundai HY29F002T",
+		DevSize: SIZE_256KiB,
+		NumEraseRegions: 4,
+		regions: {ERASEINFO(0x10000,3),
 			  ERASEINFO(0x08000,1),
 			  ERASEINFO(0x02000,2),
 			  ERASEINFO(0x04000,1)
@@ -1084,6 +1086,19 @@
 		}
 	}, {
 		.mfr_id		= MANUFACTURER_MACRONIX,
+		.dev_id		= MX29LV040C,
+		.name		= "Macronix MX29LV040C",
+		.uaddr		= {
+			[0] = MTD_UADDR_0x0555_0x02AA,  /* x8 */
+		},
+		.DevSize	= SIZE_512KiB,
+		.CmdSet		= P_ID_AMD_STD,
+		.NumEraseRegions= 1,
+		.regions	= {
+			ERASEINFO(0x10000,8),
+		}
+	}, {
+		.mfr_id		= MANUFACTURER_MACRONIX,
 		.dev_id		= MX29LV160T,
 		.name		= "MXIC MX29LV160T",
 		.uaddr		= {
@@ -1162,12 +1177,12 @@
 			ERASEINFO(0x10000,7),
 		}
 	}, {
-		.mfr_id = MANUFACTURER_MACRONIX,
-		.dev_id = MX29F002T,
-		.name = "Macronix MX29F002T",
-		.DevSize = SIZE_256KiB,
-		.NumEraseRegions = 4,
-		.regions = {ERASEINFO(0x10000,3),
+		mfr_id: MANUFACTURER_MACRONIX,
+		dev_id: MX29F002T,
+		name: "Macronix MX29F002T",
+		DevSize: SIZE_256KiB,
+		NumEraseRegions: 4,
+		regions: {ERASEINFO(0x10000,3),
 			  ERASEINFO(0x08000,1),
 			  ERASEINFO(0x02000,2),
 			  ERASEINFO(0x04000,1)
@@ -1247,7 +1262,7 @@
  		.DevSize	= SIZE_256KiB,
  		.CmdSet		= P_ID_SST_PAGE,
  		.NumEraseRegions= 1,
- 		.regions = {ERASEINFO(0x01000,64),
+ 		regions: {ERASEINFO(0x01000,64),
  		}
          }, {
  		.mfr_id		= MANUFACTURER_SST,
@@ -1259,7 +1274,7 @@
  		.DevSize	= SIZE_256KiB,
  		.CmdSet		= P_ID_SST_PAGE,
  		.NumEraseRegions= 1,
- 		.regions = {ERASEINFO(0x01000,64),
+ 		regions: {ERASEINFO(0x01000,64),
  		}
 	}, {
 		.mfr_id		= MANUFACTURER_SST,
@@ -1379,6 +1394,22 @@
 			ERASEINFO(0x01000,256),
 		}
 	}, {
+               .mfr_id         = MANUFACTURER_SST,     /* should be CFI */
+               .dev_id         = SST39LF160,
+               .name           = "SST 39LF160",
+               .uaddr          = {
+                       [0] = MTD_UADDR_0x5555_0x2AAA,  /* x8 */
+                       [1] = MTD_UADDR_0x5555_0x2AAA   /* x16 */
+               },
+               .DevSize        = SIZE_2MiB,
+               .CmdSet         = P_ID_AMD_STD,
+               .NumEraseRegions= 2,
+               .regions        = {
+                       ERASEINFO(0x1000,256),
+                       ERASEINFO(0x1000,256)
+               }
+
+       }, {
 		.mfr_id		= MANUFACTURER_ST,	/* FIXME - CFI device? */
 		.dev_id		= M29W800DT,
 		.name		= "ST M29W800DT",
@@ -1499,6 +1530,19 @@
 			ERASEINFO(0x10000,32),
 		}
 	}, {
+		.mfr_id		= MANUFACTURER_ST,
+		.dev_id		= M50LPW080,
+		.name		= "ST M50LPW080",
+		.uaddr		= {
+			[0] = MTD_UADDR_UNNECESSARY,    /* x8 */
+		},
+		.DevSize	= SIZE_1MiB,
+		.CmdSet		= P_ID_INTEL_EXT,
+		.NumEraseRegions= 1,
+		.regions	= {
+			ERASEINFO(0x10000,16),
+		}
+	}, {
 		.mfr_id		= MANUFACTURER_TOSHIBA,
 		.dev_id		= TC58FVT160,
 		.name		= "Toshiba TC58FVT160",
@@ -1617,27 +1661,27 @@
 static int jedec_probe_chip(struct map_info *map, __u32 base,
 			    unsigned long *chip_map, struct cfi_private *cfi);
 
-struct mtd_info *jedec_probe(struct map_info *map);
+static struct mtd_info *jedec_probe(struct map_info *map);
 
 static inline u32 jedec_read_mfr(struct map_info *map, __u32 base, 
 	struct cfi_private *cfi)
 {
 	map_word result;
 	unsigned long mask;
+	u32 ofs = cfi_build_cmd_addr(0, cfi_interleave(cfi), cfi->device_type);
 	mask = (1 << (cfi->device_type * 8)) -1;
-	result = map_read(map, base);
+	result = map_read(map, base + ofs);
 	return result.x[0] & mask;
 }
 
 static inline u32 jedec_read_id(struct map_info *map, __u32 base, 
 	struct cfi_private *cfi)
 {
-	int osf;
 	map_word result;
 	unsigned long mask;
-	osf = cfi->interleave *cfi->device_type;
+	u32 ofs = cfi_build_cmd_addr(1, cfi_interleave(cfi), cfi->device_type);
 	mask = (1 << (cfi->device_type * 8)) -1;
-	result = map_read(map, base + osf);
+	result = map_read(map, base + ofs);
 	return result.x[0] & mask;
 }
 
@@ -1653,9 +1697,11 @@
 	 * as they will ignore the writes and dont care what address
 	 * the F0 is written to */
 	if(cfi->addr_unlock1) {
-		/*printk("reset unlock called %x %x \n",cfi->addr_unlock1,cfi->addr_unlock2);*/
-		cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
-		cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
+		DEBUG( MTD_DEBUG_LEVEL3,
+		       "reset unlock called %x %x \n",
+		       cfi->addr_unlock1,cfi->addr_unlock2);
+		cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
+		cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, cfi->device_type, NULL);
 	}
 
 	cfi_send_gen_cmd(0xF0, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
@@ -1700,7 +1746,6 @@
 static int cfi_jedec_setup(struct cfi_private *p_cfi, int index)
 {
 	int i,num_erase_regions;
-	unsigned long mask;
 	__u8 uaddr;
 
 	printk("Found: %s\n",jedec_table[index].name);
@@ -1736,9 +1781,8 @@
 	}
 
 	/* Mask out address bits which are smaller than the device type */
-	mask = ~(p_cfi->device_type-1);
-	p_cfi->addr_unlock1 = unlock_addrs[uaddr].addr1 & mask;
-	p_cfi->addr_unlock2 = unlock_addrs[uaddr].addr2 & mask;
+	p_cfi->addr_unlock1 = unlock_addrs[uaddr].addr1;
+	p_cfi->addr_unlock2 = unlock_addrs[uaddr].addr2;
 
 	return 1; 	/* ok */
 }
@@ -1759,7 +1803,6 @@
 	int rc = 0;           /* failure until all tests pass */
 	u32 mfr, id;
 	__u8 uaddr;
-	unsigned long mask;
 
 	/*
 	 * The IDs must match.  For X16 and X32 devices operating in
@@ -1797,7 +1840,7 @@
 	DEBUG( MTD_DEBUG_LEVEL3,
 	       "MTD %s(): Check fit 0x%.8x + 0x%.8x = 0x%.8x\n",
 	       __func__, base, 1 << finfo->DevSize, base + (1 << finfo->DevSize) );
-	if ( base + cfi->interleave * ( 1 << finfo->DevSize ) > map->size ) {
+	if ( base + cfi_interleave(cfi) * ( 1 << finfo->DevSize ) > map->size ) {
 		DEBUG( MTD_DEBUG_LEVEL3,
 		       "MTD %s(): 0x%.4x 0x%.4x %dKiB doesn't fit\n",
 		       __func__, finfo->mfr_id, finfo->dev_id,
@@ -1810,18 +1853,16 @@
 		goto match_done;
 	}
 
-	mask = ~(cfi->device_type-1);
-
 	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): check unlock addrs 0x%.4x 0x%.4x\n",
 	       __func__, cfi->addr_unlock1, cfi->addr_unlock2 );
 	if ( MTD_UADDR_UNNECESSARY != uaddr && MTD_UADDR_DONT_CARE != uaddr
-	     && ( (unlock_addrs[uaddr].addr1 & mask) != cfi->addr_unlock1 ||
-		  (unlock_addrs[uaddr].addr2 & mask) != cfi->addr_unlock2 ) ) {
+	     && ( unlock_addrs[uaddr].addr1 != cfi->addr_unlock1 ||
+		  unlock_addrs[uaddr].addr2 != cfi->addr_unlock2 ) ) {
 		DEBUG( MTD_DEBUG_LEVEL3,
-		       "MTD %s(): 0x%.4lx 0x%.4lx did not match\n",
-		       __func__,
-		       unlock_addrs[uaddr].addr1 & mask,
-		       unlock_addrs[uaddr].addr2 & mask);
+			"MTD %s(): 0x%.4x 0x%.4x did not match\n",
+			__func__,
+			unlock_addrs[uaddr].addr1,
+			unlock_addrs[uaddr].addr2);
 		goto match_done;
 	}
 
@@ -1857,10 +1898,10 @@
 	 */
 	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): return to ID mode\n", __func__ );
 	if(cfi->addr_unlock1) {
-		cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
-		cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
+		cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
+		cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, cfi->device_type, NULL);
 	}
-	cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
+	cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
 	/* FIXME - should have a delay before continuing */
 
  match_done:	
@@ -1873,19 +1914,18 @@
 {
 	int i;
 	enum uaddr uaddr_idx = MTD_UADDR_NOT_SUPPORTED;
+	u32 probe_offset1, probe_offset2;
 
  retry:
 	if (!cfi->numchips) {
-		unsigned long mask = ~(cfi->device_type-1);
-
 		uaddr_idx++;
 
 		if (MTD_UADDR_UNNECESSARY == uaddr_idx)
 			return 0;
 
 		/* Mask out address bits which are smaller than the device type */
-		cfi->addr_unlock1 = unlock_addrs[uaddr_idx].addr1 & mask;
-		cfi->addr_unlock2 = unlock_addrs[uaddr_idx].addr2 & mask;
+		cfi->addr_unlock1 = unlock_addrs[uaddr_idx].addr1;
+		cfi->addr_unlock2 = unlock_addrs[uaddr_idx].addr2;
 	}
 
 	/* Make certain we aren't probing past the end of map */
@@ -1896,30 +1936,30 @@
 		return 0;
 		
 	}
-	if ((base + cfi->addr_unlock1) >= map->size) {
-		printk(KERN_NOTICE
-			"Probe at addr_unlock1(0x%08x + 0x%08x) past the end of the map(0x%08lx)\n",
-			base, cfi->addr_unlock1, map->size -1);
-
-		return 0;
+	/* Ensure the unlock addresses we try stay inside the map */
+	probe_offset1 = cfi_build_cmd_addr(
+		cfi->addr_unlock1, 
+		cfi_interleave(cfi), 
+		cfi->device_type);
+	probe_offset2 = cfi_build_cmd_addr(
+		cfi->addr_unlock1, 
+		cfi_interleave(cfi), 
+		cfi->device_type);
+	if (	((base + probe_offset1 + map_bankwidth(map)) >= map->size) ||
+		((base + probe_offset2 + map_bankwidth(map)) >= map->size))
+	{
+		goto retry;
 	}
-	if ((base + cfi->addr_unlock2) >= map->size) {
-		printk(KERN_NOTICE
-			"Probe at addr_unlock2(0x%08x + 0x%08x) past the end of the map(0x%08lx)\n",
-			base, cfi->addr_unlock2, map->size -1);
-		return 0;
 		
-	}
-
 	/* Reset */
 	jedec_reset(base, map, cfi);
 
 	/* Autoselect Mode */
 	if(cfi->addr_unlock1) {
-		cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
-		cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
+		cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
+		cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, cfi->device_type, NULL);
 	}
-	cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
+	cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
 	/* FIXME - should have a delay before continuing */
 
 	if (!cfi->numchips) {
@@ -1930,7 +1970,7 @@
 		cfi->id = jedec_read_id(map, base, cfi);
 		DEBUG(MTD_DEBUG_LEVEL3,
 		      "Search for id:(%02x %02x) interleave(%d) type(%d)\n", 
-			cfi->mfr, cfi->id, cfi->interleave, cfi->device_type);
+			cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type);
 		for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) {
 			if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) {
 				DEBUG( MTD_DEBUG_LEVEL3,
@@ -2004,7 +2044,7 @@
 	jedec_reset(base, map, cfi);
 
 	printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n",
-	       map->name, cfi->interleave, cfi->device_type*8, base, 
+	       map->name, cfi_interleave(cfi), cfi->device_type*8, base, 
 	       map->bankwidth*8);
 	
 	return 1;
@@ -2015,7 +2055,7 @@
 	.probe_chip = jedec_probe_chip
 };
 
-struct mtd_info *jedec_probe(struct map_info *map)
+static struct mtd_info *jedec_probe(struct map_info *map)
 {
 	/*
 	 * Just use the generic probe stuff to call our CFI-specific
@@ -2030,7 +2070,7 @@
 	.module	= THIS_MODULE
 };
 
-int __init jedec_probe_init(void)
+static int __init jedec_probe_init(void)
 {
 	register_mtd_chip_driver(&jedec_chipdrv);
 	return 0;
diff -Nru a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c
--- a/drivers/mtd/chips/map_absent.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/mtd/chips/map_absent.c	2004-12-24 13:37:03 -08:00
@@ -1,7 +1,7 @@
 /*
  * Common code to handle absent "placeholder" devices
  * Copyright 2001 Resilience Corporation <ebrower@resilience.com>
- * $Id: map_absent.c,v 1.4 2003/05/28 12:51:49 dwmw2 Exp $
+ * $Id: map_absent.c,v 1.5 2004/11/16 18:29:00 dwmw2 Exp $
  *
  * This map driver is used to allocate "placeholder" MTD
  * devices on systems that have socketed/removable media. 
@@ -98,7 +98,7 @@
 	/* nop */
 }
 
-int __init map_absent_init(void)
+static int __init map_absent_init(void)
 {
 	register_mtd_chip_driver(&map_absent_chipdrv);
 	return 0;
diff -Nru a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c
--- a/drivers/mtd/chips/map_ram.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/mtd/chips/map_ram.c	2004-12-24 13:36:33 -08:00
@@ -1,7 +1,7 @@
 /*
  * Common code to handle map devices which are simple RAM
  * (C) 2000 Red Hat. GPL'd.
- * $Id: map_ram.c,v 1.20 2004/08/09 13:19:43 dwmw2 Exp $
+ * $Id: map_ram.c,v 1.21 2004/11/16 18:29:00 dwmw2 Exp $
  */
 
 #include <linux/module.h>
@@ -124,7 +124,7 @@
 	/* Nothing to see here */
 }
 
-int __init map_ram_init(void)
+static int __init map_ram_init(void)
 {
 	register_mtd_chip_driver(&mapram_chipdrv);
 	return 0;
diff -Nru a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c
--- a/drivers/mtd/chips/map_rom.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/mtd/chips/map_rom.c	2004-12-24 13:37:00 -08:00
@@ -1,7 +1,7 @@
 /*
  * Common code to handle map devices which are simple ROM
  * (C) 2000 Red Hat. GPL'd.
- * $Id: map_rom.c,v 1.21 2004/07/12 14:06:01 dwmw2 Exp $
+ * $Id: map_rom.c,v 1.22 2004/11/16 18:29:00 dwmw2 Exp $
  */
 
 #include <linux/module.h>
@@ -19,7 +19,7 @@
 static int maprom_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
 static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
 static void maprom_nop (struct mtd_info *);
-struct mtd_info *map_rom_probe(struct map_info *map);
+static struct mtd_info *map_rom_probe(struct map_info *map);
 
 static struct mtd_chip_driver maprom_chipdrv = {
 	.probe	= map_rom_probe,
@@ -27,7 +27,7 @@
 	.module	= THIS_MODULE
 };
 
-struct mtd_info *map_rom_probe(struct map_info *map)
+static struct mtd_info *map_rom_probe(struct map_info *map)
 {
 	struct mtd_info *mtd;
 
@@ -75,7 +75,7 @@
 	return -EIO;
 }
 
-int __init map_rom_init(void)
+static int __init map_rom_init(void)
 {
 	register_mtd_chip_driver(&maprom_chipdrv);
 	return 0;
diff -Nru a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
--- a/drivers/mtd/cmdlinepart.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/mtd/cmdlinepart.c	2004-12-24 13:37:02 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: cmdlinepart.c,v 1.14 2004/07/12 12:34:23 dwmw2 Exp $
+ * $Id: cmdlinepart.c,v 1.16 2004/11/16 18:28:59 dwmw2 Exp $
  *
  * Read flash partition table from command line
  *
@@ -339,7 +339,7 @@
  * main.c::checksetup(). Note that we can not yet kmalloc() anything,
  * so we only save the commandline for later processing.
  */
-static int __init mtdpart_setup(char *s)
+static int mtdpart_setup(char *s)
 {
 	cmdline = s;
 	return 1;
diff -Nru a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
--- a/drivers/mtd/devices/Kconfig	2004-12-24 13:37:43 -08:00
+++ b/drivers/mtd/devices/Kconfig	2004-12-24 13:37:43 -08:00
@@ -1,5 +1,5 @@
 # drivers/mtd/maps/Kconfig
-# $Id: Kconfig,v 1.12 2004/08/10 13:12:18 dwmw2 Exp $
+# $Id: Kconfig,v 1.13 2004/10/01 21:47:13 gleixner Exp $
 
 menu "Self-contained MTD device drivers"
 	depends on MTD!=n
@@ -193,8 +193,8 @@
 
 config MTD_DOCECC
 	tristate
-	default m if MTD_DOCPROBE!=y && MTD_NAND_DISKONCHIP!=y && (MTD_DOCPROBE=m || MTD_NAND_DISKONCHIP=m)
-	default y if MTD_DOCPROBE=y || MTD_NAND_DISKONCHIP=y
+	default m if MTD_DOCPROBE=m
+	default y if MTD_DOCPROBE=y
 	help
 	  This isn't a real config option; it's derived.
 
diff -Nru a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c
--- a/drivers/mtd/devices/blkmtd.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/mtd/devices/blkmtd.c	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: blkmtd.c,v 1.23 2004/08/09 14:03:19 dwmw2 Exp $
+ * $Id: blkmtd.c,v 1.24 2004/11/16 18:29:01 dwmw2 Exp $
  *
  * blkmtd.c - use a block device as a fake MTD
  *
@@ -39,7 +39,7 @@
 
 /* Default erase size in K, always make it a multiple of PAGE_SIZE */
 #define CONFIG_MTD_BLKDEV_ERASESIZE (128 << 10)	/* 128KiB */
-#define VERSION "$Revision: 1.23 $"
+#define VERSION "$Revision: 1.24 $"
 
 /* Info for the block device */
 struct blkmtd_dev {
@@ -59,10 +59,10 @@
 #define MAX_DEVICES 4
 
 /* Module parameters passed by insmod/modprobe */
-char *device[MAX_DEVICES];    /* the block device to use */
-int erasesz[MAX_DEVICES];     /* optional default erase size */
-int ro[MAX_DEVICES];          /* optional read only flag */
-int sync;
+static char *device[MAX_DEVICES];    /* the block device to use */
+static int erasesz[MAX_DEVICES];     /* optional default erase size */
+static int ro[MAX_DEVICES];          /* optional read only flag */
+static int sync;
 
 
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
--- a/drivers/mtd/devices/doc2000.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/mtd/devices/doc2000.c	2004-12-24 13:36:16 -08:00
@@ -4,7 +4,7 @@
  * (c) 1999 Machine Vision Holdings, Inc.
  * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
  *
- * $Id: doc2000.c,v 1.62 2004/08/09 14:04:02 dwmw2 Exp $
+ * $Id: doc2000.c,v 1.64 2004/11/16 18:29:01 dwmw2 Exp $
  */
 
 #include <linux/kernel.h>
@@ -89,7 +89,7 @@
 /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
 static int _DoC_WaitReady(struct DiskOnChip *doc)
 {
-	unsigned long docptr = doc->virtadr;
+	void __iomem *docptr = doc->virtadr;
 	unsigned long timeo = jiffies + (HZ * 10);
 
 	DEBUG(MTD_DEBUG_LEVEL3,
@@ -114,7 +114,8 @@
 
 static inline int DoC_WaitReady(struct DiskOnChip *doc)
 {
-	unsigned long docptr = doc->virtadr;
+	void __iomem *docptr = doc->virtadr;
+
 	/* This is inline, to optimise the common case, where it's ready instantly */
 	int ret = 0;
 
@@ -140,7 +141,7 @@
 static inline int DoC_Command(struct DiskOnChip *doc, unsigned char command,
 			      unsigned char xtraflags)
 {
-	unsigned long docptr = doc->virtadr;
+	void __iomem *docptr = doc->virtadr;
 
 	if (DoC_is_2000(doc))
 		xtraflags |= CDSN_CTRL_FLASH_IO;
@@ -172,10 +173,8 @@
 static int DoC_Address(struct DiskOnChip *doc, int numbytes, unsigned long ofs,
 		       unsigned char xtraflags1, unsigned char xtraflags2)
 {
-	unsigned long docptr;
 	int i;
-
-	docptr = doc->virtadr;
+	void __iomem *docptr = doc->virtadr;
 
 	if (DoC_is_2000(doc))
 		xtraflags1 |= CDSN_CTRL_FLASH_IO;
@@ -240,11 +239,9 @@
 {
 	volatile int dummy;
 	int modulus = 0xffff;
-	unsigned long docptr;
+	void __iomem *docptr = doc->virtadr;
 	int i;
 
-	docptr = doc->virtadr;
-
 	if (len <= 0)
 		return;
 
@@ -271,11 +268,9 @@
 /* Write a buffer to DoC, taking care of Millennium odditys */
 static void DoC_WriteBuf(struct DiskOnChip *doc, const u_char * buf, int len)
 {
-	unsigned long docptr;
+	void __iomem *docptr = doc->virtadr;
 	int i;
 
-	docptr = doc->virtadr;
-
 	if (len <= 0)
 		return;
 
@@ -292,7 +287,7 @@
 
 static inline int DoC_SelectChip(struct DiskOnChip *doc, int chip)
 {
-	unsigned long docptr = doc->virtadr;
+	void __iomem *docptr = doc->virtadr;
 
 	/* Software requirement 11.4.4 before writing DeviceSelect */
 	/* Deassert the CE line to eliminate glitches on the FCE# outputs */
@@ -316,7 +311,7 @@
 
 static inline int DoC_SelectFloor(struct DiskOnChip *doc, int floor)
 {
-	unsigned long docptr = doc->virtadr;
+	void __iomem *docptr = doc->virtadr;
 
 	/* Select the floor (bank) of chips required */
 	WriteDOC(floor, docptr, FloorSelect);
@@ -639,15 +634,13 @@
 			size_t * retlen, u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel)
 {
 	struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;
-	unsigned long docptr;
+	void __iomem *docptr = this->virtadr;
 	struct Nand *mychip;
 	unsigned char syndrome[6];
 	volatile char dummy;
 	int i, len256 = 0, ret=0;
 	size_t left = len;
 
-	docptr = this->virtadr;
-
 	/* Don't allow read past end of device */
 	if (from >= this->totlen)
 		return -EINVAL;
@@ -799,15 +792,13 @@
 {
 	struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;
 	int di; /* Yes, DI is a hangover from when I was disassembling the binary driver */
-	unsigned long docptr;
+	void __iomem *docptr = this->virtadr;
 	volatile char dummy;
 	int len256 = 0;
 	struct Nand *mychip;
 	size_t left = len;
 	int status;
 
-	docptr = this->virtadr;
-
 	/* Don't allow write past end of device */
 	if (to >= this->totlen)
 		return -EINVAL;
@@ -1044,13 +1035,10 @@
 {
 	struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;
 	int len256 = 0, ret;
-	unsigned long docptr;
 	struct Nand *mychip;
 
 	down(&this->lock);
 
-	docptr = this->virtadr;
-
 	mychip = &this->chips[ofs >> this->chipshift];
 
 	if (this->curfloor != mychip->floor) {
@@ -1105,7 +1093,7 @@
 {
 	struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;
 	int len256 = 0;
-	unsigned long docptr = this->virtadr;
+	void __iomem *docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[ofs >> this->chipshift];
 	volatile int dummy;
 	int status;
@@ -1222,7 +1210,7 @@
 	__u32 ofs = instr->addr;
 	__u32 len = instr->len;
 	volatile int dummy;
-	unsigned long docptr;
+	void __iomem *docptr = this->virtadr;
 	struct Nand *mychip;
 	int status;
 
@@ -1235,8 +1223,6 @@
 
 	instr->state = MTD_ERASING;
 		
-	docptr = this->virtadr;
-
 	/* FIXME: Do this in the background. Use timers or schedule_task() */
 	while(len) {
 		mychip = &this->chips[ofs >> this->chipshift];
@@ -1290,7 +1276,7 @@
  *
  ****************************************************************************/
 
-int __init init_doc2000(void)
+static int __init init_doc2000(void)
 {
        inter_module_register(im_name, THIS_MODULE, &DoC2k_init);
        return 0;
diff -Nru a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
--- a/drivers/mtd/devices/doc2001.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/mtd/devices/doc2001.c	2004-12-24 13:36:32 -08:00
@@ -4,7 +4,7 @@
  * (c) 1999 Machine Vision Holdings, Inc.
  * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
  *
- * $Id: doc2001.c,v 1.44 2004/08/09 14:04:24 dwmw2 Exp $
+ * $Id: doc2001.c,v 1.46 2004/11/16 18:29:01 dwmw2 Exp $
  */
 
 #include <linux/kernel.h>
@@ -52,7 +52,7 @@
 static struct mtd_info *docmillist = NULL;
 
 /* Perform the required delay cycles by reading from the NOP register */
-static void DoC_Delay(unsigned long docptr, unsigned short cycles)
+static void DoC_Delay(void __iomem * docptr, unsigned short cycles)
 {
 	volatile char dummy;
 	int i;
@@ -62,7 +62,7 @@
 }
 
 /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
-static int _DoC_WaitReady(unsigned long docptr)
+static int _DoC_WaitReady(void __iomem * docptr)
 {
 	unsigned short c = 0xffff;
 
@@ -79,7 +79,7 @@
 	return (c == 0);
 }
 
-static inline int DoC_WaitReady(unsigned long docptr)
+static inline int DoC_WaitReady(void __iomem * docptr)
 {
 	/* This is inline, to optimise the common case, where it's ready instantly */
 	int ret = 0;
@@ -103,7 +103,7 @@
    with the internal pipeline. Each of 4 delay cycles (read from the NOP register) is
    required after writing to CDSN Control register, see Software Requirement 11.4 item 3. */
 
-static inline void DoC_Command(unsigned long docptr, unsigned char command,
+static inline void DoC_Command(void __iomem * docptr, unsigned char command,
 			       unsigned char xtraflags)
 {
 	/* Assert the CLE (Command Latch Enable) line to the flash chip */
@@ -123,7 +123,7 @@
    with the internal pipeline. Each of 4 delay cycles (read from the NOP register) is
    required after writing to CDSN Control register, see Software Requirement 11.4 item 3. */
 
-static inline void DoC_Address(unsigned long docptr, int numbytes, unsigned long ofs,
+static inline void DoC_Address(void __iomem * docptr, int numbytes, unsigned long ofs,
 			       unsigned char xtraflags1, unsigned char xtraflags2)
 {
 	/* Assert the ALE (Address Latch Enable) line to the flash chip */
@@ -161,7 +161,7 @@
 }
 
 /* DoC_SelectChip: Select a given flash chip within the current floor */
-static int DoC_SelectChip(unsigned long docptr, int chip)
+static int DoC_SelectChip(void __iomem * docptr, int chip)
 {
 	/* Select the individual flash chip requested */
 	WriteDOC(chip, docptr, CDSNDeviceSelect);
@@ -172,7 +172,7 @@
 }
 
 /* DoC_SelectFloor: Select a given floor (bank of flash chips) */
-static int DoC_SelectFloor(unsigned long docptr, int floor)
+static int DoC_SelectFloor(void __iomem * docptr, int floor)
 {
 	/* Select the floor (bank) of chips required */
 	WriteDOC(floor, docptr, FloorSelect);
@@ -417,7 +417,7 @@
 	volatile char dummy;
 	unsigned char syndrome[6];
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem *docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[from >> (this->chipshift)];
 
 	/* Don't allow read past end of device */
@@ -543,7 +543,7 @@
 	int i,ret = 0;
 	volatile char dummy;
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem *docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[to >> (this->chipshift)];
 
 	/* Don't allow write past end of device */
@@ -678,7 +678,7 @@
 #endif
 	volatile char dummy;
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem *docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[ofs >> this->chipshift];
 
 	/* Find the chip which is to be used and select it */
@@ -730,7 +730,7 @@
 	volatile char dummy;
 	int ret = 0;
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem *docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[ofs >> this->chipshift];
 
 	/* Find the chip which is to be used and select it */
@@ -799,7 +799,7 @@
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
 	__u32 ofs = instr->addr;
 	__u32 len = instr->len;
-	unsigned long docptr = this->virtadr;
+	void __iomem *docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[ofs >> this->chipshift];
 
 	if (len != mtd->erasesize) 
@@ -856,7 +856,7 @@
  *
  ****************************************************************************/
 
-int __init init_doc2001(void)
+static int __init init_doc2001(void)
 {
 	inter_module_register(im_name, THIS_MODULE, &DoCMil_init);
 	return 0;
diff -Nru a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c
--- a/drivers/mtd/devices/doc2001plus.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/mtd/devices/doc2001plus.c	2004-12-24 13:36:16 -08:00
@@ -6,7 +6,7 @@
  * (c) 1999 Machine Vision Holdings, Inc.
  * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
  *
- * $Id: doc2001plus.c,v 1.9 2004/08/09 13:19:44 dwmw2 Exp $
+ * $Id: doc2001plus.c,v 1.11 2004/11/16 18:29:01 dwmw2 Exp $
  *
  * Released under GPL
  */
@@ -57,7 +57,7 @@
 
 
 /* Perform the required delay cycles by writing to the NOP register */
-static void DoC_Delay(unsigned long docptr, int cycles)
+static void DoC_Delay(void __iomem * docptr, int cycles)
 {
 	int i;
 
@@ -68,7 +68,7 @@
 #define	CDSN_CTRL_FR_B_MASK	(CDSN_CTRL_FR_B0 | CDSN_CTRL_FR_B1)
 
 /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
-static int _DoC_WaitReady(unsigned long docptr)
+static int _DoC_WaitReady(void __iomem * docptr)
 {
 	unsigned int c = 0xffff;
 
@@ -85,7 +85,7 @@
 	return (c == 0);
 }
 
-static inline int DoC_WaitReady(unsigned long docptr)
+static inline int DoC_WaitReady(void __iomem * docptr)
 {
 	/* This is inline, to optimise the common case, where it's ready instantly */
 	int ret = 0;
@@ -106,7 +106,7 @@
  * can detect. M-systems suggest always check this on any block level
  * operation and setting to normal mode if in reset mode.
  */
-static inline void DoC_CheckASIC(unsigned long docptr)
+static inline void DoC_CheckASIC(void __iomem * docptr)
 {
 	/* Make sure the DoC is in normal mode */
 	if ((ReadDOC(docptr, Mplus_DOCControl) & DOC_MODE_NORMAL) == 0) {
@@ -118,7 +118,7 @@
 /* DoC_Command: Send a flash command to the flash chip through the Flash
  * command register. Need 2 Write Pipeline Terminates to complete send.
  */
-static inline void DoC_Command(unsigned long docptr, unsigned char command,
+static inline void DoC_Command(void __iomem * docptr, unsigned char command,
 			       unsigned char xtraflags)
 {
 	WriteDOC(command, docptr, Mplus_FlashCmd);
@@ -133,7 +133,7 @@
 			       unsigned long ofs, unsigned char xtraflags1,
 			       unsigned char xtraflags2)
 {
-	unsigned long docptr = doc->virtadr;
+	void __iomem * docptr = doc->virtadr;
 
 	/* Allow for possible Mill Plus internal flash interleaving */
 	ofs >>= doc->interleave;
@@ -163,14 +163,14 @@
 }
 
 /* DoC_SelectChip: Select a given flash chip within the current floor */
-static int DoC_SelectChip(unsigned long docptr, int chip)
+static int DoC_SelectChip(void __iomem * docptr, int chip)
 {
 	/* No choice for flash chip on Millennium Plus */
 	return 0;
 }
 
 /* DoC_SelectFloor: Select a given floor (bank of flash chips) */
-static int DoC_SelectFloor(unsigned long docptr, int floor)
+static int DoC_SelectFloor(void __iomem * docptr, int floor)
 {
 	WriteDOC((floor & 0x3), docptr, Mplus_DeviceSelect);
 	return 0;
@@ -253,7 +253,7 @@
 	return cmd;
 }
 
-static inline void MemReadDOC(unsigned long docptr, unsigned char *buf, int len)
+static inline void MemReadDOC(void __iomem * docptr, unsigned char *buf, int len)
 {
 #ifndef USE_MEMCPY
 	int i;
@@ -264,7 +264,7 @@
 #endif
 }
 
-static inline void MemWriteDOC(unsigned long docptr, unsigned char *buf, int len)
+static inline void MemWriteDOC(void __iomem * docptr, unsigned char *buf, int len)
 {
 #ifndef USE_MEMCPY
 	int i;
@@ -280,7 +280,7 @@
 {
 	int mfr, id, i, j;
 	volatile char dummy;
-	unsigned long docptr = doc->virtadr;
+	void __iomem * docptr = doc->virtadr;
 
 	/* Page in the required floor/chip */
 	DoC_SelectFloor(docptr, floor);
@@ -371,7 +371,7 @@
 		printk(KERN_NOTICE "Setting DiskOnChip Millennium Plus interleave to %s\n",
 		       this->interleave?"on (16-bit)":"off (8-bit)");
 		conf ^= 4;
-		WriteDOC(this->virtadr, conf, Mplus_Configuration);
+		WriteDOC(conf, this->virtadr, Mplus_Configuration);
 	}
 
 	/* For each floor, find the number of valid chips it contains */
@@ -531,7 +531,7 @@
 	int i;
 	loff_t fofs;
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem * docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[from >> (this->chipshift)];
 	unsigned char *bp, buf[1056];
 	char c[32];
@@ -616,7 +616,7 @@
 	loff_t fofs;
 	unsigned char syndrome[6];
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem * docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[from >> (this->chipshift)];
 
 	/* Don't allow read past end of device */
@@ -755,7 +755,7 @@
 	loff_t fto;
 	volatile char dummy;
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem * docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[to >> (this->chipshift)];
 
 	/* Don't allow write past end of device */
@@ -881,7 +881,7 @@
 {
 	loff_t fofs, base;
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem * docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[ofs >> this->chipshift];
 	size_t i, size, got, want;
 
@@ -959,7 +959,7 @@
 	volatile char dummy;
 	loff_t fofs, base;
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-	unsigned long docptr = this->virtadr;
+	void __iomem * docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[ofs >> this->chipshift];
 	size_t i, size, got, want;
 	int ret = 0;
@@ -1061,7 +1061,7 @@
 	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
 	__u32 ofs = instr->addr;
 	__u32 len = instr->len;
-	unsigned long docptr = this->virtadr;
+	void __iomem * docptr = this->virtadr;
 	struct Nand *mychip = &this->chips[ofs >> this->chipshift];
 
 	DoC_CheckASIC(docptr);
@@ -1122,7 +1122,7 @@
  *
  ****************************************************************************/
 
-int __init init_doc2001plus(void)
+static int __init init_doc2001plus(void)
 {
 	inter_module_register(im_name, THIS_MODULE, &DoCMilPlus_init);
 	return 0;
diff -Nru a/drivers/mtd/devices/docprobe.c b/drivers/mtd/devices/docprobe.c
--- a/drivers/mtd/devices/docprobe.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/mtd/devices/docprobe.c	2004-12-24 13:37:02 -08:00
@@ -4,7 +4,7 @@
 /* (C) 1999 Machine Vision Holdings, Inc.			*/
 /* (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>		*/
 
-/* $Id: docprobe.c,v 1.41 2003/12/03 10:19:57 dwmw2 Exp $	*/
+/* $Id: docprobe.c,v 1.43 2004/11/16 18:29:01 dwmw2 Exp $	*/
 
 
 
@@ -270,7 +270,7 @@
 		memset((char *)this, 0, sizeof(struct DiskOnChip));
 
 		mtd->priv = this;
-		this->virtadr = docptr;
+		this->virtadr = (void __iomem *)docptr;
 		this->physadr = physadr;
 		this->ChipID = ChipID;
 		sprintf(namebuf, "with ChipID %2.2X", ChipID);
@@ -328,7 +328,7 @@
  *
  ****************************************************************************/
 
-int __init init_doc(void)
+static int __init init_doc(void)
 {
 	int i;
 	
diff -Nru a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c
--- a/drivers/mtd/devices/mtdram.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/mtd/devices/mtdram.c	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,6 @@
 /*
  * mtdram - a test mtd device
- * $Id: mtdram.c,v 1.33 2004/08/09 13:19:44 dwmw2 Exp $
+ * $Id: mtdram.c,v 1.34 2004/11/16 18:29:01 dwmw2 Exp $
  * Author: Alexander Larsson <alex@cendio.se>
  *
  * Copyright (c) 1999 Alexander Larsson <alex@cendio.se>
@@ -153,7 +153,7 @@
 
 #if CONFIG_MTDRAM_TOTAL_SIZE > 0
 #if CONFIG_MTDRAM_ABS_POS > 0
-int __init init_mtdram(void)
+static int __init init_mtdram(void)
 {
   void *addr;
   int err;
@@ -186,7 +186,7 @@
 
 #else /* CONFIG_MTDRAM_ABS_POS > 0 */
 
-int __init init_mtdram(void)
+static int __init init_mtdram(void)
 {
   void *addr;
   int err;
@@ -220,7 +220,7 @@
 
 #else /* CONFIG_MTDRAM_TOTAL_SIZE > 0 */
 
-int __init init_mtdram(void)
+static int __init init_mtdram(void)
 {
   return 0;
 }
diff -Nru a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
--- a/drivers/mtd/devices/phram.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/mtd/devices/phram.c	2004-12-24 13:37:31 -08:00
@@ -1,6 +1,6 @@
 /**
  *
- * $Id: phram.c,v 1.2 2004/08/09 13:19:44 dwmw2 Exp $
+ * $Id: phram.c,v 1.3 2004/11/16 18:29:01 dwmw2 Exp $
  *
  * Copyright (c) Jochen Schaeuble <psionic@psionic.de>
  * 07/2003	rewritten by Joern Engel <joern@wh.fh-wedel.de>
@@ -39,7 +39,7 @@
 
 
 
-int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
+static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
 {
 	u_char *start = (u_char *)mtd->priv;
 
@@ -60,7 +60,7 @@
 	return 0;
 }
 
-int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
+static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
 		size_t *retlen, u_char **mtdbuf)
 {
 	u_char *start = (u_char *)mtd->priv;
@@ -73,11 +73,11 @@
 	return 0;
 }
 
-void phram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, size_t len)
+static void phram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, size_t len)
 {
 }
 
-int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
+static int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
 		size_t *retlen, u_char *buf)
 {
 	u_char *start = (u_char *)mtd->priv;
@@ -91,7 +91,7 @@
 	return 0;
 }
 
-int phram_write(struct mtd_info *mtd, loff_t to, size_t len,
+static int phram_write(struct mtd_info *mtd, loff_t to, size_t len,
 		size_t *retlen, const u_char *buf)
 {
 	u_char *start = (u_char *)mtd->priv;
@@ -340,7 +340,7 @@
 MODULE_PARM_DESC(slram, "List of memory regions to map. \"map=<name>,<start><length/end>\"");
 
 
-int __init init_phram(void)
+static int __init init_phram(void)
 {
 	printk(KERN_ERR "phram loaded\n");
 	return 0;
diff -Nru a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
--- a/drivers/mtd/devices/pmc551.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/mtd/devices/pmc551.c	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: pmc551.c,v 1.28 2004/08/09 13:19:44 dwmw2 Exp $
+ * $Id: pmc551.c,v 1.29 2004/11/16 18:29:01 dwmw2 Exp $
  *
  * PMC551 PCI Mezzanine Ram Device
  *
@@ -648,7 +648,7 @@
 /*
  * PMC551 Card Initialization
  */
-int __init init_pmc551(void)
+static int __init init_pmc551(void)
 {
         struct pci_dev *PCI_Device = NULL;
         struct mypriv *priv;
diff -Nru a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
--- a/drivers/mtd/devices/slram.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/mtd/devices/slram.c	2004-12-24 13:36:16 -08:00
@@ -1,6 +1,6 @@
 /*======================================================================
 
-  $Id: slram.c,v 1.31 2004/08/09 13:19:44 dwmw2 Exp $
+  $Id: slram.c,v 1.32 2004/11/16 18:29:01 dwmw2 Exp $
 
   This driver provides a method to access memory not used by the kernel
   itself (i.e. if the kernel commandline mem=xxx is used). To actually
@@ -75,13 +75,13 @@
 
 static slram_mtd_list_t *slram_mtdlist = NULL;
 
-int slram_erase(struct mtd_info *, struct erase_info *);
-int slram_point(struct mtd_info *, loff_t, size_t, size_t *, u_char **);
-void slram_unpoint(struct mtd_info *, u_char *, loff_t,	size_t);
-int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
-int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
+static int slram_erase(struct mtd_info *, struct erase_info *);
+static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, u_char **);
+static void slram_unpoint(struct mtd_info *, u_char *, loff_t,	size_t);
+static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
+static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
 
-int slram_erase(struct mtd_info *mtd, struct erase_info *instr)
+static int slram_erase(struct mtd_info *mtd, struct erase_info *instr)
 {
 	slram_priv_t *priv = mtd->priv;
 
@@ -103,7 +103,7 @@
 	return(0);
 }
 
-int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
+static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
 		size_t *retlen, u_char **mtdbuf)
 {
 	slram_priv_t *priv = (slram_priv_t *)mtd->priv;
@@ -113,11 +113,11 @@
 	return(0);
 }
 
-void slram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, size_t len)
+static void slram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, size_t len)
 {
 }
 
-int slram_read(struct mtd_info *mtd, loff_t from, size_t len,
+static int slram_read(struct mtd_info *mtd, loff_t from, size_t len,
 		size_t *retlen, u_char *buf)
 {
 	slram_priv_t *priv = (slram_priv_t *)mtd->priv;
@@ -128,7 +128,7 @@
 	return(0);
 }
 
-int slram_write(struct mtd_info *mtd, loff_t to, size_t len,
+static int slram_write(struct mtd_info *mtd, loff_t to, size_t len,
 		size_t *retlen, const u_char *buf)
 {
 	slram_priv_t *priv = (slram_priv_t *)mtd->priv;
@@ -141,7 +141,7 @@
 
 /*====================================================================*/
 
-int register_device(char *name, unsigned long start, unsigned long length)
+static int register_device(char *name, unsigned long start, unsigned long length)
 {
 	slram_mtd_list_t **curmtd;
 
@@ -213,7 +213,7 @@
 	return(0);	
 }
 
-void unregister_devices(void)
+static void unregister_devices(void)
 {
 	slram_mtd_list_t *nextitem;
 
@@ -228,7 +228,7 @@
 	}
 }
 
-unsigned long handle_unit(unsigned long value, char *unit)
+static unsigned long handle_unit(unsigned long value, char *unit)
 {
 	if ((*unit == 'M') || (*unit == 'm')) {
 		return(value * 1024 * 1024);
@@ -238,7 +238,7 @@
 	return(value);
 }
 
-int parse_cmdline(char *devname, char *szstart, char *szlength)
+static int parse_cmdline(char *devname, char *szstart, char *szlength)
 {
 	char *buffer;
 	unsigned long devstart;
@@ -285,7 +285,7 @@
 
 #endif
 
-int init_slram(void)
+static int init_slram(void)
 {
 	char *devname;
 	int i;
diff -Nru a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
--- a/drivers/mtd/ftl.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/mtd/ftl.c	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,5 @@
 /* This version ported to the Linux-MTD system by dwmw2@infradead.org
- * $Id: ftl.c,v 1.53 2004/08/09 13:55:43 dwmw2 Exp $
+ * $Id: ftl.c,v 1.54 2004/11/16 18:33:15 dwmw2 Exp $
  *
  * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups
@@ -1067,16 +1067,18 @@
 		partition->mbd.blksize = SECTOR_SIZE;
 		partition->mbd.tr = tr;
 		partition->mbd.devnum = -1;
-		if (add_mtd_blktrans_dev((void *)partition))
-			kfree(partition);
-	
-	} else
-		kfree(partition);
+		if (!add_mtd_blktrans_dev((void *)partition))
+			return;
+	}
+
+	ftl_freepart(partition);
+	kfree(partition);
 }
 
 static void ftl_remove_dev(struct mtd_blktrans_dev *dev)
 {
 	del_mtd_blktrans_dev(dev);
+	ftl_freepart((partition_t *)dev);
 	kfree(dev);
 }
 
@@ -1094,7 +1096,7 @@
 
 int init_ftl(void)
 {
-	DEBUG(0, "$Id: ftl.c,v 1.53 2004/08/09 13:55:43 dwmw2 Exp $\n");
+	DEBUG(0, "$Id: ftl.c,v 1.54 2004/11/16 18:33:15 dwmw2 Exp $\n");
 
 	return register_mtd_blktrans(&ftl_tr);
 }
diff -Nru a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
--- a/drivers/mtd/inftlcore.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/mtd/inftlcore.c	2004-12-24 13:36:18 -08:00
@@ -7,7 +7,7 @@
  * (c) 1999 Machine Vision Holdings, Inc.
  * Author: David Woodhouse <dwmw2@infradead.org>
  *
- * $Id: inftlcore.c,v 1.17 2004/08/09 13:56:48 dwmw2 Exp $
+ * $Id: inftlcore.c,v 1.18 2004/11/16 18:28:59 dwmw2 Exp $
  *
  * 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
@@ -352,7 +352,7 @@
 	return targetEUN;
 }
 
-u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock)
+static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock)
 {
 	/*
 	 * This is the part that needs some cleverness applied. 
@@ -877,7 +877,7 @@
 	return 0;
 }
 
-struct mtd_blktrans_ops inftl_tr = {
+static struct mtd_blktrans_ops inftl_tr = {
 	.name		= "inftl",
 	.major		= INFTL_MAJOR,
 	.part_bits	= INFTL_PARTN_BITS,
@@ -891,9 +891,9 @@
 
 extern char inftlmountrev[];
 
-int __init init_inftl(void)
+static int __init init_inftl(void)
 {
-	printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.17 $, "
+	printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.18 $, "
 		"inftlmount.c %s\n", inftlmountrev);
 
 	return register_mtd_blktrans(&inftl_tr);
diff -Nru a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
--- a/drivers/mtd/inftlmount.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/mtd/inftlmount.c	2004-12-24 13:36:17 -08:00
@@ -8,7 +8,7 @@
  * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 
  * Copyright (C) 2000 Netgem S.A.
  *
- * $Id: inftlmount.c,v 1.14 2004/08/09 13:57:42 dwmw2 Exp $
+ * $Id: inftlmount.c,v 1.15 2004/11/05 21:55:55 kalev Exp $
  *
  * 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
@@ -41,7 +41,7 @@
 #include <linux/mtd/inftl.h>
 #include <linux/mtd/compatmac.h>
 
-char inftlmountrev[]="$Revision: 1.14 $";
+char inftlmountrev[]="$Revision: 1.15 $";
 
 /*
  * find_boot_record: Find the INFTL Media Header and its Spare copy which
@@ -222,6 +222,8 @@
 			if (ip->Reserved0 != ip->firstUnit) {
 				struct erase_info *instr = &inftl->instr;
 
+				instr->mtd = inftl->mbd.mtd;
+
 				/*
 				 * 	Most likely this is using the
 				 * 	undocumented qiuck mount feature.
@@ -386,6 +388,8 @@
 	struct inftl_unittail uci;
 	struct erase_info *instr = &inftl->instr;
 	int physblock;
+
+	instr->mtd = inftl->mbd.mtd;
 
 	DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_formatblock(inftl=%p,"
 		"block=%d)\n", inftl, block);
diff -Nru a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
--- a/drivers/mtd/maps/Kconfig	2004-12-24 13:37:29 -08:00
+++ b/drivers/mtd/maps/Kconfig	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,5 @@
 # drivers/mtd/maps/Kconfig
-# $Id: Kconfig,v 1.30 2004/07/21 00:16:14 jwboyer Exp $
+# $Id: Kconfig,v 1.37 2004/10/20 22:57:18 dwmw2 Exp $
 
 menu "Mapping drivers for chip access"
 	depends on MTD!=n
@@ -92,6 +92,25 @@
 	  demonstration board. If you have one of these boards and would like 
 	  to use the flash chips on it, say 'Y'.
 
+config MTD_TS5500
+	tristate "JEDEC Flash device mapped on Technologic Systems TS-5500"
+	depends on X86 && MTD_JEDECPROBE && MTD_PARTITIONS
+	help
+	  This provides a driver for the on-board flash of the Technologic
+	  System's TS-5500 board. The flash is split into 3 partitions
+	  which are accessed as separate MTD devices.
+
+	  mtd0 and mtd2 are the two BIOS drives. Unfortunately the BIOS
+	  uses a proprietary flash translation layer from General Software,
+	  which is not supported (the drives cannot be mounted). You can
+	  create your own file system (jffs for example), but the BIOS
+	  won't be able to boot from it.
+
+	  mtd1 allows you to reprogram your BIOS. BE VERY CAREFUL.
+
+	  Note that jumper 3 ("Write Enable Drive A") must be set
+	  otherwise detection won't succeeed.
+
 config MTD_SBC_GXX
 	tristate "CFI Flash device mapped on Arcom SBC-GXx boards"
 	depends on X86 && MTD_CFI_INTELEXT && MTD_PARTITIONS && MTD_COMPLEX_MAPPINGS
@@ -160,7 +179,7 @@
 
 config MTD_ICHXROM
 	tristate "BIOS flash chip on Intel Controller Hub 2/3/4/5"
-	depends on X86 && MTD_JEDECPROBE && MTD_COMPLEX_MAPPINGS
+	depends on X86 && MTD_JEDECPROBE
 	help
 	  Support for treating the BIOS flash chip on ICHX motherboards
 	  as an MTD device - with this you can reprogram your BIOS.
@@ -355,13 +374,21 @@
 	  use the flash chips on it, say 'Y'.
 
 config MTD_EBONY
-	tristate "CFI Flash device mapped on IBM 440GP Ebony"
-	depends on MTD_CFI && PPC32 && 440 && EBONY
+	tristate "Flash devices mapped on IBM 440GP Ebony"
+	depends on MTD_CFI && PPC32 && 44x && EBONY
 	help
 	  This enables access routines for the flash chips on the IBM 440GP
 	  Ebony board. If you have one of these boards and would like to
 	  use the flash chips on it, say 'Y'.
 
+config MTD_OCOTEA
+	tristate "Flash devices mapped on IBM 440GX Ocotea"
+	depends on MTD_CFI && PPC32 && 44x && OCOTEA
+	help
+	  This enables access routines for the flash chips on the IBM 440GX
+	  Ocotea board. If you have one of these boards and would like to
+	  use the flash chips on it, say 'Y'.
+
 config MTD_REDWOOD
 	tristate "CFI Flash devices mapped on IBM Redwood"
 	depends on MTD_CFI && PPC32 && 4xx && 40x && ( REDWOOD_4 || REDWOOD_5 || REDWOOD_6 )
@@ -448,6 +475,12 @@
 	  the SA1100 and SA1110, including the Assabet and the Compaq iPAQ.
 	  If you have such a board, say 'Y'.
 
+config MTD_IPAQ
+	tristate "CFI Flash device mapped on Compaq/HP iPAQ"
+	depends on ARM && IPAQ_HANDHELD && MTD_CFI
+	help
+	  This provides a driver for the on-board flash of the iPAQ.
+
 config MTD_DC21285
 	tristate "CFI Flash device mapped on DC21285 Footbridge"
 	depends on ARM && MTD_CFI && ARCH_FOOTBRIDGE && MTD_COMPLEX_MAPPINGS
@@ -468,7 +501,7 @@
 	tristate "CFI Flash device mapped on Intel IXP4xx based systems"
 	depends on ARM && MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP4XX
 	help
-	  This eables MTD access to flash devices on platforms based 
+	  This enables MTD access to flash devices on platforms based 
 	  on Intel's IXP4xx family of network processors such as the
 	  IXDP425 and Coyote. If you have an IXP4xx based board and
 	  would like to use the flash chips on it, say 'Y'.
@@ -477,9 +510,9 @@
 	tristate "CFI Flash device mapped on Intel IXP2000 based systems"
 	depends on ARM && MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP2000
 	help
-	  This enables MTD access to flash devices on platforms based
+	  This enables MTD access to flash devices on platforms based 
 	  on Intel's IXP2000 family of network processors such as the
-	  IXDP2400 and IXDP2401. If you have an IXP2000 based board and
+	  IXDP425 and Coyote. If you have an IXP2000 based board and
 	  would like to use the flash chips on it, say 'Y'.
 
 config MTD_EPXA10DB
@@ -594,6 +627,23 @@
 	select MTD_CFI_AMDSTD
         help
           Map driver for Dy-4 SVME/DMV-182 board.
+
+config MTD_BAST
+	tristate "Map driver for Simtec BAST (EB2410ITX)"
+	depends on ARCH_BAST
+	select MTD_PARTITIONS
+	select MTD_MAP_BANK_WIDTH_16
+	select MTD_JEDECPROBE
+	help
+	  Map driver for NOR flash on the Simtec BAST (EB2410ITX).
+
+	  Note, this driver *cannot* over-ride the WP link on the
+	  board, or currently detect the state of the link.
+
+config MTD_BAST_MAXSIZE
+	int "Maximum size for BAST flash area (MiB)"
+	depends on MTD_BAST
+	default "4"
 
 endmenu
 
diff -Nru a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
--- a/drivers/mtd/maps/Makefile	2004-12-24 13:36:16 -08:00
+++ b/drivers/mtd/maps/Makefile	2004-12-24 13:36:16 -08:00
@@ -1,7 +1,7 @@
 #
 # linux/drivers/maps/Makefile
 #
-# $Id: Makefile.common,v 1.14 2004/07/12 16:07:31 dwmw2 Exp $
+# $Id: Makefile.common,v 1.19 2004/09/21 14:27:16 bjd Exp $
 
 ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y)
 obj-$(CONFIG_MTD)		+= map_funcs.o
@@ -10,6 +10,7 @@
 # Chip mappings
 obj-$(CONFIG_MTD_CDB89712)	+= cdb89712.o
 obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
+obj-$(CONFIG_MTD_BAST)		+= bast-flash.o
 obj-$(CONFIG_MTD_CFI_FLAGADM)	+= cfi_flagadm.o
 obj-$(CONFIG_MTD_CSTM_MIPS_IXX)	+= cstm_mips_ixx.o
 obj-$(CONFIG_MTD_DC21285)	+= dc21285.o
@@ -31,9 +32,11 @@
 obj-$(CONFIG_MTD_RPXLITE)	+= rpxlite.o
 obj-$(CONFIG_MTD_TQM8XXL)	+= tqm8xxl.o
 obj-$(CONFIG_MTD_SA1100)	+= sa1100-flash.o
+obj-$(CONFIG_MTD_IPAQ)		+= ipaq-flash.o
 obj-$(CONFIG_MTD_SBC_GXX)	+= sbc_gxx.o
 obj-$(CONFIG_MTD_SC520CDP)	+= sc520cdp.o
 obj-$(CONFIG_MTD_NETSC520)	+= netsc520.o
+obj-$(CONFIG_MTD_TS5500)	+= ts5500_flash.o
 obj-$(CONFIG_MTD_SUN_UFLASH)	+= sun_uflash.o
 obj-$(CONFIG_MTD_VMAX)		+= vmax301.o
 obj-$(CONFIG_MTD_SCx200_DOCFLASH)+= scx200_docflash.o
@@ -55,6 +58,7 @@
 obj-$(CONFIG_MTD_NETtel)	+= nettel.o
 obj-$(CONFIG_MTD_SCB2_FLASH)	+= scb2_flash.o
 obj-$(CONFIG_MTD_EBONY)		+= ebony.o
+obj-$(CONFIG_MTD_OCOTEA)	+= ocotea.o
 obj-$(CONFIG_MTD_BEECH)		+= beech-mtd.o
 obj-$(CONFIG_MTD_ARCTIC)	+= arctic-mtd.o
 obj-$(CONFIG_MTD_H720X)		+= h720x-flash.o
diff -Nru a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
--- a/drivers/mtd/maps/amd76xrom.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/mtd/maps/amd76xrom.c	2004-12-24 13:36:31 -08:00
@@ -2,7 +2,7 @@
  * amd76xrom.c
  *
  * Normal mappings of chips in physical memory
- * $Id: amd76xrom.c,v 1.12 2004/07/14 14:44:31 thayne Exp $
+ * $Id: amd76xrom.c,v 1.18 2004/11/16 18:29:02 dwmw2 Exp $
  */
 
 #include <linux/module.h>
@@ -12,61 +12,73 @@
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
+#include <linux/mtd/cfi.h>
+#include <linux/mtd/flashchip.h>
 #include <linux/config.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
+#include <linux/list.h>
 
 
 #define xstr(s) str(s)
 #define str(s) #s
 #define MOD_NAME xstr(KBUILD_BASENAME)
 
-#define MTD_DEV_NAME_LENGTH 16
+#define ADDRESS_NAME_LEN 18
+
+#define ROM_PROBE_STEP_SIZE (64*1024) /* 64KiB */
+
+struct amd76xrom_window {
+	void __iomem *virt;
+	unsigned long phys;
+	unsigned long size;
+	struct list_head maps;
+	struct resource rsrc;
+	struct pci_dev *pdev;
+};
 
 struct amd76xrom_map_info {
+	struct list_head list;
 	struct map_info map;
 	struct mtd_info *mtd;
-	void __iomem * window_addr;
-	u32 window_start, window_size;
-	struct pci_dev *pdev;
-	struct resource window_rsrc;
-	struct resource rom_rsrc;
-	char mtd_name[MTD_DEV_NAME_LENGTH];
+	struct resource rsrc;
+	char map_name[sizeof(MOD_NAME) + 2 + ADDRESS_NAME_LEN];
 };
 
-
-static struct amd76xrom_map_info amd76xrom_map = {
-	.map = {
-		.name = MOD_NAME,
-		.size = 0,
-		.bankwidth = 1,
-	}
-	/* remaining fields of structure are initialized to 0 */
+static struct amd76xrom_window amd76xrom_window = {
+	.maps = LIST_HEAD_INIT(amd76xrom_window.maps),
 };
 
-
-static void amd76xrom_cleanup(struct amd76xrom_map_info *info)
+static void amd76xrom_cleanup(struct amd76xrom_window *window)
 {
+	struct amd76xrom_map_info *map, *scratch;
 	u8 byte;
 
-	/* Disable writes through the rom window */
-	pci_read_config_byte(info->pdev, 0x40, &byte);
-	pci_write_config_byte(info->pdev, 0x40, byte & ~1);
-
-	if (info->mtd) {
-		del_mtd_device(info->mtd);
-		map_destroy(info->mtd);
-		info->mtd = NULL;
-		info->map.virt = NULL;
-	}
-	if (info->rom_rsrc.parent)
-		release_resource(&info->rom_rsrc);
-	if (info->window_rsrc.parent)
-		release_resource(&info->window_rsrc);
-
-	if (info->window_addr) {
-		iounmap(info->window_addr);
-		info->window_addr = NULL;
+	if (window->pdev) {
+		/* Disable writes through the rom window */
+		pci_read_config_byte(window->pdev, 0x40, &byte);
+		pci_write_config_byte(window->pdev, 0x40, byte & ~1);
+	}
+
+	/* Free all of the mtd devices */
+	list_for_each_entry_safe(map, scratch, &window->maps, list) {
+		if (map->rsrc.parent) {
+			release_resource(&map->rsrc);
+		}
+		del_mtd_device(map->mtd);
+		map_destroy(map->mtd);
+		list_del(&map->list);
+		kfree(map);
+	}
+	if (window->rsrc.parent) 
+		release_resource(&window->rsrc);
+
+	if (window->virt) {
+		iounmap(window->virt);
+		window->virt = NULL;
+		window->phys = 0;
+		window->size = 0;
+		window->pdev = NULL;
 	}
 }
 
@@ -74,167 +86,196 @@
 static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
 	const struct pci_device_id *ent)
 {
-	struct rom_window {
-		u32 start;
-		u32 size;
-		u8 segen_bits;
-	};
-	static struct rom_window rom_window[] = {
-		/*
-		 * Need the 5MiB window for chips that have block lock/unlock
-		 * registers located below 4MiB window.
-		 */
-		{ 0xffb00000, 5*1024*1024, (1<<7) | (1<<6), },
-		{ 0xffc00000, 4*1024*1024, (1<<7), },
-		{ 0xffff0000, 64*1024,     0 },
-		{ 0         , 0,           0 },
-	};
-	static const u32 rom_probe_sizes[] = { 
-		5*1024*1024, 4*1024*1024, 2*1024*1024, 1024*1024, 512*1024, 
-		256*1024, 128*1024, 64*1024, 0};
 	static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL };
 	u8 byte;
-	struct amd76xrom_map_info *info = &amd76xrom_map;
-	struct rom_window *window;
-	int i;
-	u32 rom_size;
-
-	info->pdev = pdev;
-	window = &rom_window[0];
-
-	while (window->size) {
-		/*
-		 * Try to reserve the window mem region.  If this fails then
-		 * it is likely due to a fragment of the window being
-		 * "reseved" by the BIOS.  In the case that the
-		 * request_mem_region() fails then once the rom size is
-		 * discovered we will try to reserve the unreserved fragment.
-		 */
-		info->window_rsrc.name = MOD_NAME;
-		info->window_rsrc.start = window->start;
-		info->window_rsrc.end = window->start + window->size - 1;
-		info->window_rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-		if (request_resource(&iomem_resource, &info->window_rsrc)) {
-			info->window_rsrc.parent = NULL;
-			printk(KERN_ERR MOD_NAME
-			       " %s(): Unable to register resource"
-			       " 0x%.08lx-0x%.08lx - kernel bug?\n",
-			       __func__,
-			       info->window_rsrc.start, info->window_rsrc.end);
-		}
-
-		/* Enable the selected rom window */
-		pci_read_config_byte(pdev, 0x43, &byte);
-		pci_write_config_byte(pdev, 0x43, byte | window->segen_bits);
-
-		/* Enable writes through the rom window */
-		pci_read_config_byte(pdev, 0x40, &byte);
-		pci_write_config_byte(pdev, 0x40, byte | 1);
-
-		/* FIXME handle registers 0x80 - 0x8C the bios region locks */
-
-		printk(KERN_NOTICE MOD_NAME " window : %x at %x\n", 
-		       window->size, window->start);
-		/* For write accesses caches are useless */
-		info->window_addr = ioremap_nocache(window->start,
-						       window->size);
-
-		if (!info->window_addr) {
-			printk(KERN_ERR "Failed to ioremap\n");
-			continue;
-		}
+	struct amd76xrom_window *window = &amd76xrom_window;
+	struct amd76xrom_map_info *map = NULL;
+	unsigned long map_top;
+
+	/* Remember the pci dev I find the window in */
+	window->pdev = pdev;
+
+	/* Assume the rom window is properly setup, and find it's size */
+	pci_read_config_byte(pdev, 0x43, &byte);
+	if ((byte & ((1<<7)|(1<<6))) == ((1<<7)|(1<<6))) {
+		window->phys = 0xffb00000; /* 5MiB */
+	}
+	else if ((byte & (1<<7)) == (1<<7)) {
+		window->phys = 0xffc00000; /* 4MiB */
+	}
+	else {
+		window->phys = 0xffff0000; /* 64KiB */
+	}
+	window->size = 0xffffffffUL - window->phys + 1UL;
+	
+	/*
+	 * Try to reserve the window mem region.  If this fails then
+	 * it is likely due to a fragment of the window being
+	 * "reseved" by the BIOS.  In the case that the
+	 * request_mem_region() fails then once the rom size is
+	 * discovered we will try to reserve the unreserved fragment.
+	 */
+	window->rsrc.name = MOD_NAME;
+	window->rsrc.start = window->phys;
+	window->rsrc.end   = window->phys + window->size - 1;
+	window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+	if (request_resource(&iomem_resource, &window->rsrc)) {
+		window->rsrc.parent = NULL;
+		printk(KERN_ERR MOD_NAME
+			" %s(): Unable to register resource"
+			" 0x%.08lx-0x%.08lx - kernel bug?\n",
+			__func__,
+			window->rsrc.start, window->rsrc.end);
+	}
 
-		info->mtd = NULL;
+#if 0
 
-		for(i = 0; (rom_size = rom_probe_sizes[i]); i++) {
-			char **chip_type;
-			if (rom_size > window->size) {
-				continue;
-			}
-			info->map.phys = window->start + window->size - rom_size;
-			info->map.virt = 
-				info->window_addr + window->size - rom_size;
-			info->map.size = rom_size;
-			simple_map_init(&info->map);
-			chip_type = rom_probe_types;
-			for(; !info->mtd && *chip_type; chip_type++) {
-				info->mtd = do_map_probe(*chip_type, &amd76xrom_map.map);
-			}
-			if (info->mtd) goto found_mtd;
-		}
-		iounmap(info->window_addr);
-		info->window_addr = NULL;
+	/* Enable the selected rom window */
+	pci_read_config_byte(pdev, 0x43, &byte);
+	pci_write_config_byte(pdev, 0x43, byte | rwindow->segen_bits);
+#endif
 
-		/* Disable writes through the rom window */
-		pci_read_config_byte(pdev, 0x40, &byte);
-		pci_write_config_byte(pdev, 0x40, byte & ~1);
+	/* Enable writes through the rom window */
+	pci_read_config_byte(pdev, 0x40, &byte);
+	pci_write_config_byte(pdev, 0x40, byte | 1);
+	
+	/* FIXME handle registers 0x80 - 0x8C the bios region locks */
+
+	/* For write accesses caches are useless */
+	window->virt = ioremap_nocache(window->phys, window->size);
+	if (!window->virt) {
+		printk(KERN_ERR MOD_NAME ": ioremap(%08lx, %08lx) failed\n",
+			window->phys, window->size);
+		goto out;
+	}
 
-		window++;
+	/* Get the first address to look for an rom chip at */
+	map_top = window->phys;
+#if 1
+	/* The probe sequence run over the firmware hub lock
+	 * registers sets them to 0x7 (no access).
+	 * Probe at most the last 4M of the address space.
+	 */
+	if (map_top < 0xffc00000) {
+		map_top = 0xffc00000;
 	}
-	goto failed;
+#endif
+	/* Loop  through and look for rom chips */
+	while((map_top - 1) < 0xffffffffUL) {
+		struct cfi_private *cfi;
+		unsigned long offset;
+		int i;
 
- found_mtd:
-	printk(KERN_NOTICE MOD_NAME " chip at offset: 0x%x\n",
-		window->size - rom_size);
-
-	info->mtd->owner = THIS_MODULE;
-
-	if (!info->window_rsrc.parent) {
-		/* failed to reserve entire window - try fragments */
-		info->window_rsrc.name = MOD_NAME;
-		info->window_rsrc.start = window->start;
-		info->window_rsrc.end = window->start + window->size - rom_size - 1;
-		info->window_rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-		if (request_resource(&iomem_resource, &info->window_rsrc)) {
-			printk(KERN_ERR MOD_NAME
-			       ": cannot reserve window resource fragment\n");
-#if 0
+		if (!map) {
+			map = kmalloc(sizeof(*map), GFP_KERNEL);
+		}
+		if (!map) {
+			printk(KERN_ERR MOD_NAME ": kmalloc failed");
+			goto out;
+		}
+		memset(map, 0, sizeof(*map));
+		INIT_LIST_HEAD(&map->list);
+		map->map.name = map->map_name;
+		map->map.phys = map_top;
+		offset = map_top - window->phys;
+		map->map.virt = (void __iomem *)
+			(((unsigned long)(window->virt)) + offset);
+		map->map.size = 0xffffffffUL - map_top + 1UL;
+		/* Set the name of the map to the address I am trying */
+		sprintf(map->map_name, "%s @%08lx",
+			MOD_NAME, map->map.phys);
+
+		/* There is no generic VPP support */
+		for(map->map.bankwidth = 32; map->map.bankwidth; 
+			map->map.bankwidth >>= 1)
+		{
+			char **probe_type;
+			/* Skip bankwidths that are not supported */
+			if (!map_bankwidth_supported(map->map.bankwidth))
+				continue;
+
+			/* Setup the map methods */
+			simple_map_init(&map->map);
+
+			/* Try all of the probe methods */
+			probe_type = rom_probe_types;
+			for(; *probe_type; probe_type++) {
+				map->mtd = do_map_probe(*probe_type, &map->map);
+				if (map->mtd)
+					goto found;
+			}
+		}
+		map_top += ROM_PROBE_STEP_SIZE;
+		continue;
+	found:
+		/* Trim the size if we are larger than the map */
+		if (map->mtd->size > map->map.size) {
+			printk(KERN_WARNING MOD_NAME
+				" rom(%u) larger than window(%lu). fixing...\n",
+				map->mtd->size, map->map.size);
+			map->mtd->size = map->map.size;
+		}
+		if (window->rsrc.parent) {
 			/*
-			 * The BIOS e820 usually reserves this so it isn't
-			 * usually an error.
+			 * Registering the MTD device in iomem may not be possible
+			 * if there is a BIOS "reserved" and BUSY range.  If this
+			 * fails then continue anyway.
 			 */
-			goto failed;
-#endif
+			map->rsrc.name  = map->map_name;
+			map->rsrc.start = map->map.phys;
+			map->rsrc.end   = map->map.phys + map->mtd->size - 1;
+			map->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+			if (request_resource(&window->rsrc, &map->rsrc)) {
+				printk(KERN_ERR MOD_NAME
+					": cannot reserve MTD resource\n");
+				map->rsrc.parent = NULL;
+			}
 		}
-	}
 
-	add_mtd_device(info->mtd);
-	info->window_start = window->start;
-	info->window_size = window->size;
-
-	if (info->window_rsrc.parent) {
-		/*
-		 * Registering the MTD device in iomem may not be possible
-		 * if there is a BIOS "reserved" and BUSY range.  If this
-		 * fails then continue anyway.
-		 */
-		snprintf(info->mtd_name, MTD_DEV_NAME_LENGTH,
-			 "mtd%d", info->mtd->index);
-
-		info->rom_rsrc.name = info->mtd_name;
-		info->rom_rsrc.start = window->start + window->size - rom_size;
-		info->rom_rsrc.end = window->start + window->size - 1;
-		info->rom_rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-		if (request_resource(&info->window_rsrc, &info->rom_rsrc)) {
-			printk(KERN_ERR MOD_NAME
-			       ": cannot reserve MTD resource\n");
-			info->rom_rsrc.parent = NULL;
+		/* Make the whole region visible in the map */
+		map->map.virt = window->virt;
+		map->map.phys = window->phys;
+		cfi = map->map.fldrv_priv;
+		for(i = 0; i < cfi->numchips; i++) {
+			cfi->chips[i].start += offset;
+		}
+		
+		/* Now that the mtd devices is complete claim and export it */
+		map->mtd->owner = THIS_MODULE;
+		if (add_mtd_device(map->mtd)) {
+			map_destroy(map->mtd);
+			map->mtd = NULL;
+			goto out;
 		}
+
+
+		/* Calculate the new value of map_top */
+		map_top += map->mtd->size;
+
+		/* File away the map structure */
+		list_add(&map->list, &window->maps);
+		map = NULL;
 	}
 
+ out:
+	/* Free any left over map structures */
+	if (map) {
+		kfree(map);
+	}
+	/* See if I have any map structures */
+	if (list_empty(&window->maps)) {
+		amd76xrom_cleanup(window);
+		return -ENODEV;
+	}
 	return 0;
-
- failed:
-	amd76xrom_cleanup(info);
-	return -ENODEV;
 }
 
 
 static void __devexit amd76xrom_remove_one (struct pci_dev *pdev)
 {
-	struct amd76xrom_map_info *info = &amd76xrom_map;
+	struct amd76xrom_window *window = &amd76xrom_window;
 
-	amd76xrom_cleanup(info);
+	amd76xrom_cleanup(window);
 }
 
 static struct pci_device_id amd76xrom_pci_tbl[] = {
@@ -257,7 +298,7 @@
 };
 #endif
 
-int __init init_amd76xrom(void)
+static int __init init_amd76xrom(void)
 {
 	struct pci_dev *pdev;
 	struct pci_device_id *id;
@@ -269,7 +310,6 @@
 		}
 	}
 	if (pdev) {
-		amd76xrom_map.pdev = pdev;
 		return amd76xrom_init_one(pdev, &amd76xrom_pci_tbl[0]);
 	}
 	return -ENXIO;
@@ -280,7 +320,7 @@
 
 static void __exit cleanup_amd76xrom(void)
 {
-	amd76xrom_remove_one(amd76xrom_map.pdev);
+	amd76xrom_remove_one(amd76xrom_window.pdev);
 }
 
 module_init(init_amd76xrom);
diff -Nru a/drivers/mtd/maps/arctic-mtd.c b/drivers/mtd/maps/arctic-mtd.c
--- a/drivers/mtd/maps/arctic-mtd.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/mtd/maps/arctic-mtd.c	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: arctic-mtd.c,v 1.11 2004/07/12 21:59:43 dwmw2 Exp $
+ * $Id: arctic-mtd.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $
  * 
  * drivers/mtd/maps/arctic-mtd.c MTD mappings and partition tables for 
  *                              IBM 405LP Arctic boards.
@@ -98,7 +98,7 @@
 {
 	printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);
 
-	arctic_mtd_map.virt = (unsigned long) ioremap(PADDR, SIZE);
+	arctic_mtd_map.virt = ioremap(PADDR, SIZE);
 
 	if (!arctic_mtd_map.virt) {
 		printk("%s: failed to ioremap 0x%x\n", NAME, PADDR);
diff -Nru a/drivers/mtd/maps/autcpu12-nvram.c b/drivers/mtd/maps/autcpu12-nvram.c
--- a/drivers/mtd/maps/autcpu12-nvram.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/mtd/maps/autcpu12-nvram.c	2004-12-24 13:37:19 -08:00
@@ -2,7 +2,7 @@
  * NV-RAM memory access on autcpu12 
  * (C) 2002 Thomas Gleixner (gleixner@autronix.de)
  *
- * $Id: autcpu12-nvram.c,v 1.6 2004/07/12 21:59:43 dwmw2 Exp $ 
+ * $Id: autcpu12-nvram.c,v 1.8 2004/11/04 13:24:14 gleixner Exp $ 
  *
  * 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
@@ -47,7 +47,7 @@
 {
 	int err, save0, save1;
 
-	autcpu12_sram_map.virt = (unsigned long)ioremap(0x12000000, SZ_128K);
+	autcpu12_sram_map.virt = ioremap(0x12000000, SZ_128K);
 	if (!autcpu12_sram_map.virt) {
 		printk("Failed to ioremap autcpu12 NV-RAM space\n");
 		err = -EIO;
@@ -76,7 +76,7 @@
 	/* We have a 128K found, restore 0x10000 and set size
 	 * to 128K
 	 */
-	ma[_write32(&autcpu12_sram_map,save1,0x10000);
+	map_write32(&autcpu12_sram_map,save1,0x10000);
 	autcpu12_sram_map.size = SZ_128K;
 
 map:
diff -Nru a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mtd/maps/bast-flash.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,227 @@
+/* linux/drivers/mtd/maps/bast_flash.c
+ *
+ * Copyright (c) 2004 Simtec Electronics
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * Simtec Bast (EB2410ITX) NOR MTD Mapping driver
+ *
+ * Changelog:
+ *	20-Sep-2004  BJD  Initial version
+ *
+ * $Id: bast-flash.c,v 1.1 2004/09/21 14:29:04 bjd Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <asm/mach/flash.h>
+
+#include <asm/arch/map.h>
+#include <asm/arch/bast-map.h>
+#include <asm/arch/bast-cpld.h>
+
+#ifdef CONFIG_MTD_BAST_MAXSIZE
+#define AREA_MAXSIZE (CONFIG_MTD_BAST_MAXSIZE * (1024*1024))
+#else
+#define AREA_MAXSIZE (32*1024*1024)
+#endif
+
+#define PFX "bast-flash: "
+
+struct bast_flash_info {
+	struct mtd_info		*mtd;
+	struct map_info		 map;
+	struct mtd_partition	*partitions;
+	struct resource		*area;
+};
+
+static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
+
+static struct bast_flash_info *to_bast_info(struct device *dev)
+{
+	return (struct bast_flash_info *)dev_get_drvdata(dev);
+}
+
+static void bast_flash_setrw(int to)
+{
+	unsigned int val;
+	unsigned long flags;
+
+	local_irq_save(flags);
+	val = __raw_readb(BAST_VA_CTRL3);
+	
+	if (to)
+		val |= BAST_CPLD_CTRL3_ROMWEN;
+	else
+		val &= ~BAST_CPLD_CTRL3_ROMWEN;
+
+	pr_debug("new cpld ctrl3=%02x\n", val);
+
+	__raw_writeb(val, BAST_VA_CTRL3);
+	local_irq_restore(flags);
+}
+
+static int bast_flash_remove(struct device *dev)
+{
+	struct bast_flash_info *info = to_bast_info(dev);
+
+	dev_set_drvdata(dev, NULL);
+
+	if (info == NULL) 
+		return 0;
+
+	if (info->map.virt != NULL)
+		iounmap(info->map.virt);
+
+	if (info->mtd) {
+		del_mtd_partitions(info->mtd);
+		map_destroy(info->mtd);
+	}
+
+	if (info->partitions)
+		kfree(info->partitions);
+
+	if (info->area) {
+		release_resource(info->area);
+		kfree(info->area);
+	}
+	
+	kfree(info);
+
+	return 0;
+}
+
+static int bast_flash_probe(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct bast_flash_info *info;
+	struct resource *res;
+	int err = 0;
+
+	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	if (info == NULL) {
+		printk(KERN_ERR PFX "no memory for flash info\n");
+		err = -ENOMEM;
+		goto exit_error;
+	}
+
+	memzero(info, sizeof(*info));
+	dev_set_drvdata(dev, info);
+
+	res = pdev->resource;  /* assume that the flash has one resource */
+
+	info->map.phys = res->start;
+	info->map.size = res->end - res->start + 1;
+	info->map.name = dev->bus_id;	
+	info->map.bankwidth = 2;
+	
+	if (info->map.size > AREA_MAXSIZE)
+		info->map.size = AREA_MAXSIZE;
+
+	pr_debug("%s: area %08lx, size %ld\n", __FUNCTION__,
+		 info->map.phys, info->map.size);
+	
+	info->area = request_mem_region(res->start, info->map.size,
+					pdev->name);
+	if (info->area == NULL) {
+		printk(KERN_ERR PFX "cannot reserve flash memory region\n");
+		err = -ENOENT;
+		goto exit_error;
+	}
+
+	info->map.virt = ioremap(res->start, info->map.size);
+	pr_debug("%s: virt at %08x\n", __FUNCTION__, (int)info->map.virt);
+
+	if (info->map.virt == 0) {
+		printk(KERN_ERR PFX "failed to ioremap() region\n");
+		err = -EIO;
+		goto exit_error;
+	}
+ 
+	simple_map_init(&info->map);
+
+	/* enable the write to the flash area */
+
+	bast_flash_setrw(1);
+
+	/* probe for the device(s) */
+
+	info->mtd = do_map_probe("jedec_probe", &info->map);
+	if (info->mtd == NULL)
+		info->mtd = do_map_probe("cfi_probe", &info->map);
+
+	if (info->mtd == NULL) {
+		printk(KERN_ERR PFX "map_probe() failed\n");
+		err = -ENXIO;
+		goto exit_error;
+	}
+
+	/* mark ourselves as the owner */
+	info->mtd->owner = THIS_MODULE;
+
+	err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0);
+	if (err > 0) {
+		err = add_mtd_partitions(info->mtd, info->partitions, err);
+		if (err) 
+			printk(KERN_ERR PFX "cannot add/parse partitions\n");
+	}
+
+	if (err == 0)
+		return 0;
+
+	/* fall through to exit error */
+
+ exit_error:
+	bast_flash_remove(dev);
+	return err;
+}
+
+static struct device_driver bast_flash_driver = {
+	.name		= "bast-nor",
+	.bus		= &platform_bus_type,
+	.probe		= bast_flash_probe,
+	.remove		= bast_flash_remove,
+};
+
+static int __init bast_flash_init(void)
+{
+	printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n");
+	return driver_register(&bast_flash_driver);
+}
+
+static void __exit bast_flash_exit(void)
+{
+	driver_unregister(&bast_flash_driver);
+}
+
+module_init(bast_flash_init);
+module_exit(bast_flash_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
+MODULE_DESCRIPTION("BAST MTD Map driver");
diff -Nru a/drivers/mtd/maps/beech-mtd.c b/drivers/mtd/maps/beech-mtd.c
--- a/drivers/mtd/maps/beech-mtd.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/mtd/maps/beech-mtd.c	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: beech-mtd.c,v 1.8 2004/07/12 21:59:43 dwmw2 Exp $
+ * $Id: beech-mtd.c,v 1.10 2004/11/04 13:24:14 gleixner Exp $
  * 
  * drivers/mtd/maps/beech-mtd.c MTD mappings and partition tables for 
  *                              IBM 405LP Beech boards.
@@ -74,7 +74,7 @@
 {
 	printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);
 
-	beech_mtd_map.virt = (unsigned long) ioremap(PADDR, SIZE);
+	beech_mtd_map.virt = ioremap(PADDR, SIZE);
 
 	if (!beech_mtd_map.virt) {
 		printk("%s: failed to ioremap 0x%x\n", NAME, PADDR);
diff -Nru a/drivers/mtd/maps/cdb89712.c b/drivers/mtd/maps/cdb89712.c
--- a/drivers/mtd/maps/cdb89712.c	2004-12-24 13:37:33 -08:00
+++ b/drivers/mtd/maps/cdb89712.c	2004-12-24 13:37:33 -08:00
@@ -1,7 +1,7 @@
 /*
  * Flash on Cirrus CDB89712
  *
- * $Id: cdb89712.c,v 1.8 2004/07/12 21:59:43 dwmw2 Exp $
+ * $Id: cdb89712.c,v 1.10 2004/11/04 13:24:14 gleixner Exp $
  */
 
 #include <linux/module.h>
@@ -44,7 +44,7 @@
 		goto out;
 	}
 	
-	cdb89712_flash_map.virt = (unsigned long)ioremap(FLASH_START, FLASH_SIZE);
+	cdb89712_flash_map.virt = ioremap(FLASH_START, FLASH_SIZE);
 	if (!cdb89712_flash_map.virt) {
 		printk(KERN_NOTICE "Failed to ioremap Cdb89712 FLASH space\n");
 		err = -EIO;
@@ -114,7 +114,7 @@
 		goto out;
 	}
 	
-	cdb89712_sram_map.virt = (unsigned long)ioremap(SRAM_START, SRAM_SIZE);
+	cdb89712_sram_map.virt = ioremap(SRAM_START, SRAM_SIZE);
 	if (!cdb89712_sram_map.virt) {
 		printk(KERN_NOTICE "Failed to ioremap Cdb89712 SRAM space\n");
 		err = -EIO;
@@ -182,7 +182,7 @@
 		goto out;
 	}
 	
-	cdb89712_bootrom_map.virt = (unsigned long)ioremap(BOOTROM_START, BOOTROM_SIZE);
+	cdb89712_bootrom_map.virt = ioremap(BOOTROM_START, BOOTROM_SIZE);
 	if (!cdb89712_bootrom_map.virt) {
 		printk(KERN_NOTICE "Failed to ioremap Cdb89712 BootROM space\n");
 		err = -EIO;
diff -Nru a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c
--- a/drivers/mtd/maps/ceiva.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/mtd/maps/ceiva.c	2004-12-24 13:36:47 -08:00
@@ -11,7 +11,7 @@
  *
  * (C) 2000 Nicolas Pitre <nico@cam.org>
  *
- * $Id: ceiva.c,v 1.10 2004/07/12 21:59:43 dwmw2 Exp $
+ * $Id: ceiva.c,v 1.11 2004/09/16 23:27:12 gleixner Exp $
  */
 
 #include <linux/config.h>
@@ -103,7 +103,7 @@
 	unsigned long base;
 	unsigned long size;
 	int width;
-	void __iomem *vbase;
+	void *vbase;
 	struct map_info *map;
 	struct mtd_info *mtd;
 	struct resource *res;
@@ -150,7 +150,7 @@
 			break;
 		}
 
-		clps[i].map->virt = clps[i].vbase;
+		clps[i].map->virt = (void __iomem *)clps[i].vbase;
 		clps[i].map->bankwidth = clps[i].width;
 		clps[i].map->size = clps[i].size;
 
diff -Nru a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c
--- a/drivers/mtd/maps/cfi_flagadm.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/mtd/maps/cfi_flagadm.c	2004-12-24 13:37:43 -08:00
@@ -1,7 +1,7 @@
 /*
  *  Copyright © 2001 Flaga hf. Medical Devices, Kári Davíðsson <kd@flaga.is>
  *
- *  $Id: cfi_flagadm.c,v 1.12 2004/07/12 21:59:43 dwmw2 Exp $
+ *  $Id: cfi_flagadm.c,v 1.14 2004/11/04 13:24:14 gleixner Exp $
  *  
  *  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
@@ -96,7 +96,7 @@
 			FLASH_SIZE, FLASH_PHYS_ADDR);
 	
 	flagadm_map.phys = FLASH_PHYS_ADDR;
-	flagadm_map.virt = (unsigned long)ioremap(FLASH_PHYS_ADDR,
+	flagadm_map.virt = ioremap(FLASH_PHYS_ADDR,
 					FLASH_SIZE);
 
 	if (!flagadm_map.virt) {
diff -Nru a/drivers/mtd/maps/cstm_mips_ixx.c b/drivers/mtd/maps/cstm_mips_ixx.c
--- a/drivers/mtd/maps/cstm_mips_ixx.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/mtd/maps/cstm_mips_ixx.c	2004-12-24 13:36:19 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: cstm_mips_ixx.c,v 1.10 2004/07/12 21:59:43 dwmw2 Exp $
+ * $Id: cstm_mips_ixx.c,v 1.12 2004/11/04 13:24:14 gleixner Exp $
  *
  * Mapping of a custom board with both AMD CFI and JEDEC flash in partitions.
  * Config with both CFI and JEDEC device support.
@@ -170,7 +170,7 @@
 
 
 		cstm_mips_ixx_map[i].phys = cstm_mips_ixx_board_desc[i].window_addr;
-		cstm_mips_ixx_map[i].virt = (unsigned long)ioremap(cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size);
+		cstm_mips_ixx_map[i].virt = ioremap(cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size);
 		if (!cstm_mips_ixx_map[i].virt) {
 			printk(KERN_WARNING "Failed to ioremap\n");
 			return -EIO;
diff -Nru a/drivers/mtd/maps/db1550-flash.c b/drivers/mtd/maps/db1550-flash.c
--- a/drivers/mtd/maps/db1550-flash.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/mtd/maps/db1550-flash.c	2004-12-24 13:36:31 -08:00
@@ -1,10 +1,10 @@
 /*
  * Flash memory access on Alchemy Db1550 board
  * 
- * $Id: db1550-flash.c,v 1.3 2004/07/14 17:45:40 dwmw2 Exp $
+ * $Id: db1550-flash.c,v 1.7 2004/11/04 13:24:14 gleixner Exp $
  *
  * (C) 2004 Embedded Edge, LLC, based on db1550-flash.c:
- * (C) 2003 Pete Popov <pete_popov@yahoo.com>
+ * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com>
  * 
  */
 
@@ -19,7 +19,6 @@
 #include <linux/mtd/partitions.h>
 
 #include <asm/io.h>
-#include <asm/au1000.h>
 
 #ifdef 	DEBUG_RW
 #define	DBG(x...)	printk(x)
@@ -132,7 +131,7 @@
 			window_addr = 0x1C000000;
 			window_size = 0x4000000; 
 #else /* USER ONLY */
-			window_addr = 0x1E000000;
+			window_addr = 0x18000000;
 			window_size = 0x4000000; 
 #endif
 	return 0;
@@ -160,10 +159,9 @@
 	 * Now let's probe for the actual flash.  Do it here since
 	 * specific machine settings might have been set above.
 	 */
-	printk(KERN_NOTICE "Pb1550 flash: probing %d-bit flash bus\n", 
+	printk(KERN_NOTICE "Db1550 flash: probing %d-bit flash bus\n", 
 			db1550_map.bankwidth*8);
-	db1550_map.virt = 
-		(unsigned long)ioremap(window_addr, window_size);
+	db1550_map.virt = ioremap(window_addr, window_size);
 	mymtd = do_map_probe("cfi_probe", &db1550_map);
 	if (!mymtd) return -ENXIO;
 	mymtd->owner = THIS_MODULE;
@@ -177,6 +175,7 @@
 	if (mymtd) {
 		del_mtd_partitions(mymtd);
 		map_destroy(mymtd);
+		iounmap((void *) db1550_map.virt);
 	}
 }
 
diff -Nru a/drivers/mtd/maps/db1x00-flash.c b/drivers/mtd/maps/db1x00-flash.c
--- a/drivers/mtd/maps/db1x00-flash.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/mtd/maps/db1x00-flash.c	2004-12-24 13:36:18 -08:00
@@ -1,9 +1,9 @@
 /*
  * Flash memory access on Alchemy Db1xxx boards
  * 
- * $Id: db1x00-flash.c,v 1.3 2004/07/14 17:45:40 dwmw2 Exp $
+ * $Id: db1x00-flash.c,v 1.6 2004/11/04 13:24:14 gleixner Exp $
  *
- * (C) 2003 Pete Popov <ppopov@pacbell.net>
+ * (C) 2003 Pete Popov <ppopov@embeddedalley.com>
  * 
  */
 
@@ -18,8 +18,6 @@
 #include <linux/mtd/partitions.h>
 
 #include <asm/io.h>
-#include <asm/au1000.h>
-#include <asm/db1x00.h>
 
 #ifdef 	DEBUG_RW
 #define	DBG(x...)	printk(x)
@@ -27,11 +25,20 @@
 #define	DBG(x...)	
 #endif
 
+/* MTD CONFIG OPTIONS */
+#if defined(CONFIG_MTD_DB1X00_BOOT) && defined(CONFIG_MTD_DB1X00_USER)
+#define DB1X00_BOTH_BANKS
+#elif defined(CONFIG_MTD_DB1X00_BOOT) && !defined(CONFIG_MTD_DB1X00_USER)
+#define DB1X00_BOOT_ONLY
+#elif !defined(CONFIG_MTD_DB1X00_BOOT) && defined(CONFIG_MTD_DB1X00_USER)
+#define DB1X00_USER_ONLY
+#endif
+
 static unsigned long window_addr;
 static unsigned long window_size;
 static unsigned long flash_size;
 
-static BCSR * const bcsr = (BCSR *)0xAE000000;
+static unsigned short *bcsr = (unsigned short *)0xAE000000;
 static unsigned char flash_bankwidth = 4;
 
 /* 
@@ -113,7 +120,7 @@
  */
 int setup_flash_params(void)
 {
-	switch ((bcsr->status >> 14) & 0x3) {
+	switch ((bcsr[2] >> 14) & 0x3) {
 		case 0: /* 64Mbit devices */
 			flash_size = 0x800000; /* 8MB per part */
 #if defined(DB1X00_BOTH_BANKS)
@@ -192,7 +199,7 @@
 	 */
 	printk(KERN_NOTICE "Db1xxx flash: probing %d-bit flash bus\n", 
 			db1xxx_mtd_map.bankwidth*8);
-	db1xxx_mtd_map.virt = (unsigned long)ioremap(window_addr, window_size);
+	db1xxx_mtd_map.virt = ioremap(window_addr, window_size);
 	db1xxx_mtd = do_map_probe("cfi_probe", &db1xxx_mtd_map);
 	if (!db1xxx_mtd) return -ENXIO;
 	db1xxx_mtd->owner = THIS_MODULE;
diff -Nru a/drivers/mtd/maps/dbox2-flash.c b/drivers/mtd/maps/dbox2-flash.c
--- a/drivers/mtd/maps/dbox2-flash.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/mtd/maps/dbox2-flash.c	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: dbox2-flash.c,v 1.11 2004/07/12 21:59:43 dwmw2 Exp $
+ * $Id: dbox2-flash.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $
  *
  * D-Box 2 flash driver
  */
@@ -75,7 +75,7 @@
 int __init init_dbox2_flash(void)
 {
        	printk(KERN_NOTICE "D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE, WINDOW_ADDR);
-	dbox2_flash_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
+	dbox2_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
 
 	if (!dbox2_flash_map.virt) {
 		printk("Failed to ioremap\n");
diff -Nru a/drivers/mtd/maps/dc21285.c b/drivers/mtd/maps/dc21285.c
--- a/drivers/mtd/maps/dc21285.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/mtd/maps/dc21285.c	2004-12-24 13:36:48 -08:00
@@ -5,7 +5,7 @@
  *
  * This code is GPL
  * 
- * $Id: dc21285.c,v 1.20 2004/07/12 22:38:29 dwmw2 Exp $
+ * $Id: dc21285.c,v 1.22 2004/11/01 13:39:21 rmk Exp $
  */
 #include <linux/config.h>
 #include <linux/module.h>
@@ -32,7 +32,8 @@
  * is unpredictible. So we have a 25us penalty per
  * write access.
  */
-static void nw_en_write(void) {
+static void nw_en_write(void)
+{
 	extern spinlock_t gpio_lock;
 	unsigned long flags;
 
@@ -55,53 +56,60 @@
 
 static map_word dc21285_read8(struct map_info *map, unsigned long ofs)
 {
-	return *(uint8_t*)(map->map_priv_1 + ofs);
+	map_word val;
+	val.x[0] = *(uint8_t*)(map->virt + ofs);
+	return val;
 }
 
 static map_word dc21285_read16(struct map_info *map, unsigned long ofs)
 {
-	return *(uint16_t*)(map->map_priv_1 + ofs);
+	map_word val;
+	val.x[0] = *(uint16_t*)(map->virt + ofs);
+	return val;
 }
 
 static map_word dc21285_read32(struct map_info *map, unsigned long ofs)
 {
-	return *(uint32_t*)(map->map_priv_1 + ofs);
+	map_word val;
+	val.x[0] = *(uint32_t*)(map->virt + ofs);
+	return val;
 }
 
 static void dc21285_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
 {
-	memcpy(to, (void*)(map->map_priv_1 + from), len);
+	memcpy(to, (void*)(map->virt + from), len);
 }
 
-static void dc21285_write(struct map_info *map, map_word d, unsigned long adr)
+static void dc21285_write8(struct map_info *map, const map_word d, unsigned long adr)
 {
 	if (machine_is_netwinder())
 		nw_en_write();
 	*CSR_ROMWRITEREG = adr & 3;
 	adr &= ~3;
-	*(uint8_t*)(map->map_priv_1 + adr) = d.x[0];
+	*(uint8_t*)(map->virt + adr) = d.x[0];
 }
 
-static void dc21285_write16(struct map_info *map, map_word d, unsigned long adr)
+static void dc21285_write16(struct map_info *map, const map_word d, unsigned long adr)
 {
 	if (machine_is_netwinder())
 		nw_en_write();
 	*CSR_ROMWRITEREG = adr & 3;
 	adr &= ~3;
-	*(uint16_t*)(map->map_priv_1 + adr) = d.x[0];
+	*(uint16_t*)(map->virt + adr) = d.x[0];
 }
 
-static void dc21285_write32(struct map_info *map, map_word d, unsigned long adr)
+static void dc21285_write32(struct map_info *map, const map_word d, unsigned long adr)
 {
 	if (machine_is_netwinder())
 		nw_en_write();
-	*(uint32_t*)(map->map_priv_1 + adr) = d.x[0];
+	*(uint32_t*)(map->virt + adr) = d.x[0];
 }
 
 static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const void *from, ssize_t len)
 {
 	while (len > 0) {
-		uint32_t d = *((uint32_t*)from)++;
+		map_word d;
+		d.x[0] = *((uint32_t*)from)++;
 		dc21285_write32(map, d, to);
 		to += 4;
 		len -= 4;
@@ -111,7 +119,8 @@
 static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const void *from, ssize_t len)
 {
 	while (len > 0) {
-		uint16_t d = *((uint16_t*)from)++;
+		map_word d;
+		d.x[0] = *((uint16_t*)from)++;
 		dc21285_write16(map, d, to);
 		to += 2;
 		len -= 2;
@@ -120,7 +129,8 @@
 
 static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)
 {
-	uint8_t d = *((uint8_t*)from)++;
+	map_word d;
+	d.x[0] = *((uint8_t*)from)++;
 	dc21285_write8(map, d, to);
 	to++;
 	len--;
@@ -135,8 +145,8 @@
 
 
 /* Partition stuff */
-static struct mtd_partition *dc21285_parts;
 #ifdef CONFIG_MTD_PARTITIONS
+static struct mtd_partition *dc21285_parts;
 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
 #endif
   
@@ -163,10 +173,10 @@
 			break;
 		case SA110_CNTL_ROMWIDTH_32: 
 			dc21285_map.bankwidth = 4; 
-			break;
 			dc21285_map.read = dc21285_read32;
 			dc21285_map.write = dc21285_write32;
 			dc21285_map.copy_to = dc21285_copy_to_32;
+			break;
 		default:
 			printk (KERN_ERR "DC21285 flash: undefined bankwidth\n");
 			return -ENXIO;
@@ -175,8 +185,8 @@
 		dc21285_map.bankwidth*8);
 
 	/* Let's map the flash area */
-	dc21285_map.map_priv_1 = (unsigned long)ioremap(DC21285_FLASH, 16*1024*1024);
-	if (!dc21285_map.map_priv_1) {
+	dc21285_map.virt = ioremap(DC21285_FLASH, 16*1024*1024);
+	if (!dc21285_map.virt) {
 		printk("Failed to ioremap\n");
 		return -EIO;
 	}
@@ -188,14 +198,14 @@
 	}
 
 	if (!dc21285_mtd) {
-		iounmap((void *)dc21285_map.map_priv_1);
+		iounmap(dc21285_map.virt);
 		return -ENXIO;
 	}	
 	
 	dc21285_mtd->owner = THIS_MODULE;
 
 #ifdef CONFIG_MTD_PARTITIONS
-	nrparts = parse_mtd_partitions(dc21285_mtd, probes, &dc21285_parts, (void *)0);
+	nrparts = parse_mtd_partitions(dc21285_mtd, probes, &dc21285_parts, 0);
 	if (nrparts > 0)
 		add_mtd_partitions(dc21285_mtd, dc21285_parts, nrparts);
 	else	
@@ -231,7 +241,7 @@
 		del_mtd_device(dc21285_mtd);
 
 	map_destroy(dc21285_mtd);
-	iounmap((void *)dc21285_map.map_priv_1);
+	iounmap(dc21285_map.virt);
 }
 
 module_init(init_dc21285);
diff -Nru a/drivers/mtd/maps/dilnetpc.c b/drivers/mtd/maps/dilnetpc.c
--- a/drivers/mtd/maps/dilnetpc.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/mtd/maps/dilnetpc.c	2004-12-24 13:36:31 -08:00
@@ -14,7 +14,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *
- * $Id: dilnetpc.c,v 1.13 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: dilnetpc.c,v 1.16 2004/11/04 13:24:14 gleixner Exp $
  *
  * The DIL/Net PC is a tiny embedded PC board made by SSV Embedded Systems
  * featuring the AMD Elan SC410 processor. There are two variants of this
@@ -403,7 +403,7 @@
 	printk(KERN_NOTICE "DIL/Net %s flash: 0x%lx at 0x%lx\n", 
 		is_dnp ? "DNPC" : "ADNP", dnpc_map.size, dnpc_map.phys);
 
-	dnpc_map.virt = (unsigned long)ioremap_nocache(dnpc_map.phys, dnpc_map.size);
+	dnpc_map.virt = ioremap_nocache(dnpc_map.phys, dnpc_map.size);
 
 	dnpc_map_flash(dnpc_map.phys, dnpc_map.size);
 
@@ -413,7 +413,7 @@
 	}
 	simple_map_init(&dnpc_map);
 
-	printk("FLASH virtual address: 0x%lx\n", dnpc_map.virt);
+	printk("FLASH virtual address: 0x%p\n", dnpc_map.virt);
 
 	mymtd = do_map_probe("jedec_probe", &dnpc_map);
 
@@ -430,7 +430,7 @@
 			mymtd->erasesize = 0x10000;
 
 	if (!mymtd) {
-		iounmap((void *)dnpc_map.virt);
+		iounmap(dnpc_map.virt);
 		return -ENXIO;
 	}
 		
@@ -481,9 +481,9 @@
 		map_destroy(mymtd);
 	}
 	if (dnpc_map.virt) {
-		iounmap((void *)dnpc_map.virt);
+		iounmap(dnpc_map.virt);
 		dnpc_unmap_flash();
-		dnpc_map.virt = 0;
+		dnpc_map.virt = NULL;
 	}
 }
 
diff -Nru a/drivers/mtd/maps/dmv182.c b/drivers/mtd/maps/dmv182.c
--- a/drivers/mtd/maps/dmv182.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/mtd/maps/dmv182.c	2004-12-24 13:36:18 -08:00
@@ -4,7 +4,7 @@
  * 
  * Flash map driver for the Dy4 SVME182 board
  * 
- * $Id: dmv182.c,v 1.3 2004/07/14 17:45:40 dwmw2 Exp $
+ * $Id: dmv182.c,v 1.5 2004/11/04 13:24:14 gleixner Exp $
  *
  * Copyright 2003-2004, TimeSys Corporation
  *
@@ -103,8 +103,7 @@
 
 	partitions = svme182_partitions;
 
-	svme182_map.virt = 
-		(unsigned long)ioremap(FLASH_BASE_ADDR, svme182_map.size);
+	svme182_map.virt = ioremap(FLASH_BASE_ADDR, svme182_map.size);
 		
 	if (svme182_map.virt == 0) {
 		printk("Failed to ioremap FLASH memory area.\n");
diff -Nru a/drivers/mtd/maps/ebony.c b/drivers/mtd/maps/ebony.c
--- a/drivers/mtd/maps/ebony.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/mtd/maps/ebony.c	2004-12-24 13:37:18 -08:00
@@ -1,11 +1,11 @@
 /*
- * $Id: ebony.c,v 1.10 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: ebony.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $
  * 
  * Mapping for Ebony user flash
  *
- * Matt Porter <mporter@mvista.com>
+ * Matt Porter <mporter@kernel.crashing.org>
  *
- * Copyright 2002 MontaVista Software Inc.
+ * Copyright 2002-2004 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
@@ -21,9 +21,10 @@
 #include <linux/mtd/map.h>
 #include <linux/mtd/partitions.h>
 #include <linux/config.h>
+#include <linux/version.h>
 #include <asm/io.h>
 #include <asm/ibm44x.h>
-#include <platforms/ebony.h>
+#include <platforms/4xx/ebony.h>
 
 static struct mtd_info *flash;
 
@@ -63,7 +64,7 @@
 int __init init_ebony(void)
 {
 	u8 fpga0_reg;
-	unsigned long fpga0_adr;
+	u8 __iomem *fpga0_adr;
 	unsigned long long small_flash_base, large_flash_base;
 
 	fpga0_adr = ioremap64(EBONY_FPGA_ADDR, 16);
@@ -92,8 +93,7 @@
 		large_flash_base = EBONY_LARGE_FLASH_HIGH;
 
 	ebony_small_map.phys = small_flash_base;
-	ebony_small_map.virt =
-		(unsigned long)ioremap64(small_flash_base,
+	ebony_small_map.virt = ioremap64(small_flash_base,
 					 ebony_small_map.size);
 
 	if (!ebony_small_map.virt) {
@@ -114,8 +114,7 @@
 	}
 
 	ebony_large_map.phys = large_flash_base;
-	ebony_large_map.virt =
-		(unsigned long)ioremap64(large_flash_base,
+	ebony_large_map.virt = ioremap64(large_flash_base,
 					 ebony_large_map.size);
 
 	if (!ebony_large_map.virt) {
@@ -146,13 +145,13 @@
 	}
 
 	if (ebony_small_map.virt) {
-		iounmap((void *)ebony_small_map.virt);
-		ebony_small_map.virt = 0;
+		iounmap(ebony_small_map.virt);
+		ebony_small_map.virt = NULL;
 	}
 
 	if (ebony_large_map.virt) {
-		iounmap((void *)ebony_large_map.virt);
-		ebony_large_map.virt = 0;
+		iounmap(ebony_large_map.virt);
+		ebony_large_map.virt = NULL;
 	}
 }
 
@@ -160,5 +159,5 @@
 module_exit(cleanup_ebony);
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Matt Porter <mporter@mvista.com>");
+MODULE_AUTHOR("Matt Porter <mporter@kernel.crashing.org>");
 MODULE_DESCRIPTION("MTD map and partitions for IBM 440GP Ebony boards");
diff -Nru a/drivers/mtd/maps/edb7312.c b/drivers/mtd/maps/edb7312.c
--- a/drivers/mtd/maps/edb7312.c	2004-12-24 13:37:34 -08:00
+++ b/drivers/mtd/maps/edb7312.c	2004-12-24 13:37:34 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: edb7312.c,v 1.11 2004/07/14 09:52:55 dwmw2 Exp $
+ * $Id: edb7312.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $
  *
  * Handle mapping of the NOR flash on Cogent EDB7312 boards
  *
@@ -71,19 +71,18 @@
 
 #endif
 
-static int mtd_parts_nb;
-static struct mtd_partition *mtd_parts;
+static int                   mtd_parts_nb = 0;
+static struct mtd_partition *mtd_parts    = 0;
 
 int __init init_edb7312nor(void)
 {
 	static const char *rom_probe_types[] = PROBETYPES;
 	const char **type;
-	const char *part_type = NULL;
+	const char *part_type = 0;
 
        	printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n", 
 	       WINDOW_SIZE, WINDOW_ADDR);
-	edb7312nor_map.virt = (unsigned long)
-	  ioremap(WINDOW_ADDR, WINDOW_SIZE);
+	edb7312nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
 
 	if (!edb7312nor_map.virt) {
 		printk(MSG_PREFIX "failed to ioremap\n");
@@ -92,7 +91,7 @@
 	
 	simple_map_init(&edb7312nor_map);
 
-	mymtd = NULL;
+	mymtd = 0;
 	type = rom_probe_types;
 	for(; !mymtd && *type; type++) {
 		mymtd = do_map_probe(*type, &edb7312nor_map);
diff -Nru a/drivers/mtd/maps/elan-104nc.c b/drivers/mtd/maps/elan-104nc.c
--- a/drivers/mtd/maps/elan-104nc.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/mtd/maps/elan-104nc.c	2004-12-24 13:36:49 -08:00
@@ -16,7 +16,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
-   $Id: elan-104nc.c,v 1.21 2004/07/12 22:38:29 dwmw2 Exp $
+   $Id: elan-104nc.c,v 1.24 2004/11/16 18:29:02 dwmw2 Exp $
 
 The ELAN-104NC has up to 8 Mibyte of Intel StrataFlash (28F320/28F640) in x16
 mode.  This drivers uses the CFI probe and Intel Extended Command Set drivers.
@@ -53,7 +53,7 @@
 #define PAGE_IO_SIZE 2
 
 static volatile int page_in_window = -1; // Current page in window.
-static unsigned long iomapadr;
+static void __iomem *iomapadr;
 static spinlock_t elan_104nc_spin = SPIN_LOCK_UNLOCKED;
 
 /* partition_info gives details on the logical partitions that the split the 
@@ -182,15 +182,15 @@
 		map_destroy( all_mtd );
 	}
 
-	iounmap((void *)iomapadr);
+	iounmap(iomapadr);
 }
 
-int __init init_elan_104nc(void)
+static int __init init_elan_104nc(void)
 {
 	/* Urg! We use I/O port 0x22 without request_region()ing it,
 	   because it's already allocated to the PIC. */
 
-  	iomapadr = (unsigned long)ioremap(WINDOW_START, WINDOW_LENGTH);
+  	iomapadr = ioremap(WINDOW_START, WINDOW_LENGTH);
 	if (!iomapadr) {
 		printk( KERN_ERR"%s: failed to ioremap memory region\n",
 			elan_104nc_map.name );
diff -Nru a/drivers/mtd/maps/epxa10db-flash.c b/drivers/mtd/maps/epxa10db-flash.c
--- a/drivers/mtd/maps/epxa10db-flash.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/mtd/maps/epxa10db-flash.c	2004-12-24 13:37:04 -08:00
@@ -5,7 +5,7 @@
  *  Copyright (C) 2001 Altera Corporation
  *  Copyright (C) 2001 Red Hat, Inc.
  *
- * $Id: epxa10db-flash.c,v 1.11 2004/07/12 21:59:44 dwmw2 Exp $ 
+ * $Id: epxa10db-flash.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $ 
  *
  * 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
@@ -62,7 +62,7 @@
 	
 	printk(KERN_NOTICE "%s flash device: 0x%x at 0x%x\n", BOARD_NAME, FLASH_SIZE, FLASH_START);
 
-	epxa_map.virt = (unsigned long)ioremap(FLASH_START, FLASH_SIZE);
+	epxa_map.virt = ioremap(FLASH_START, FLASH_SIZE);
 	if (!epxa_map.virt) {
 		printk("Failed to ioremap %s flash\n",BOARD_NAME);
 		return -EIO;
diff -Nru a/drivers/mtd/maps/fortunet.c b/drivers/mtd/maps/fortunet.c
--- a/drivers/mtd/maps/fortunet.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/mtd/maps/fortunet.c	2004-12-24 13:36:31 -08:00
@@ -1,6 +1,6 @@
 /* fortunet.c memory map
  *
- * $Id: fortunet.c,v 1.7 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: fortunet.c,v 1.9 2004/11/04 13:24:14 gleixner Exp $
  */
 
 #include <linux/module.h>
@@ -209,8 +209,8 @@
 
 			map_regions[ix].map_info.phys =	map_regions[ix].window_addr_physical,
 
-			map_regions[ix].map_info.virt =
-				(int)ioremap_nocache(
+			map_regions[ix].map_info.virt = 
+				ioremap_nocache(
 				map_regions[ix].window_addr_physical,
 				map_regions[ix].map_info.size);
 			if(!map_regions[ix].map_info.virt)
diff -Nru a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c
--- a/drivers/mtd/maps/h720x-flash.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/mtd/maps/h720x-flash.c	2004-12-24 13:36:19 -08:00
@@ -2,7 +2,7 @@
  * Flash memory access on Hynix GMS30C7201/HMS30C7202 based 
  * evaluation boards
  * 
- * $Id: h720x-flash.c,v 1.9 2004/07/14 17:45:40 dwmw2 Exp $
+ * $Id: h720x-flash.c,v 1.11 2004/11/04 13:24:14 gleixner Exp $
  *
  * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com>
  *     2003 Thomas Gleixner <tglx@linutronix.de>	
@@ -73,7 +73,7 @@
 
 	char	*part_type = NULL;
 	
-	h720x_map.virt = (unsigned long)ioremap(FLASH_PHYS, FLASH_SIZE);
+	h720x_map.virt = ioremap(FLASH_PHYS, FLASH_SIZE);
 
 	if (!h720x_map.virt) {
 		printk(KERN_ERR "H720x-MTD: ioremap failed\n");
diff -Nru a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
--- a/drivers/mtd/maps/ichxrom.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/mtd/maps/ichxrom.c	2004-12-24 13:36:17 -08:00
@@ -2,7 +2,7 @@
  * ichxrom.c
  *
  * Normal mappings of chips in physical memory
- * $Id: ichxrom.c,v 1.8 2004/07/16 17:43:11 dwmw2 Exp $
+ * $Id: ichxrom.c,v 1.15 2004/11/16 18:29:02 dwmw2 Exp $
  */
 
 #include <linux/module.h>
@@ -12,187 +12,87 @@
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
+#include <linux/mtd/cfi.h>
+#include <linux/mtd/flashchip.h>
 #include <linux/config.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/mtd/cfi.h>
+#include <linux/list.h>
 
 #define xstr(s) str(s)
 #define str(s) #s
 #define MOD_NAME xstr(KBUILD_BASENAME)
 
-#define MTD_DEV_NAME_LENGTH 16
-
-#define RESERVE_MEM_REGION 0
-
+#define ADDRESS_NAME_LEN 18
 
-#define MANUFACTURER_INTEL	0x0089
-#define I82802AB	0x00ad
-#define I82802AC	0x00ac
+#define ROM_PROBE_STEP_SIZE (64*1024) /* 64KiB */
 
-#define ICHX_FWH_REGION_START	0xFF000000UL
-#define ICHX_FWH_REGION_SIZE	0x01000000UL
 #define BIOS_CNTL	0x4e
 #define FWH_DEC_EN1	0xE3
 #define FWH_DEC_EN2	0xF0
 #define FWH_SEL1	0xE8
 #define FWH_SEL2	0xEE
 
-struct ichxrom_map_info {
-	struct map_info map;
-	struct mtd_info *mtd;
-	unsigned long window_addr;
+struct ichxrom_window {
+	void __iomem* virt;
+	unsigned long phys;
+	unsigned long size;
+	struct list_head maps;
+	struct resource rsrc;
 	struct pci_dev *pdev;
-	struct resource window_rsrc;
-	struct resource rom_rsrc;
-	char mtd_name[MTD_DEV_NAME_LENGTH];
 };
 
-static inline unsigned long addr(struct map_info *map, unsigned long ofs)
-{
-	unsigned long offset;
-	offset = ((8*1024*1024) - map->size) + ofs;
-	if (offset >= (4*1024*1024)) {
-		offset += 0x400000;
-	}
-	return map->map_priv_1 + 0x400000 + offset;
-}
-
-static inline unsigned long dbg_addr(struct map_info *map, unsigned long addr)
-{
-	return addr - map->map_priv_1 + ICHX_FWH_REGION_START;
-}
-	
-static map_word ichxrom_read(struct map_info *map, unsigned long ofs)
-{
-	map_word val;
-	int i;
-	switch(map->bankwidth) {
-	case 1:	 val.x[0] = __raw_readb(addr(map, ofs)); break;
-	case 2:	 val.x[0] = __raw_readw(addr(map, ofs)); break;
-	case 4:	 val.x[0] = __raw_readl(addr(map, ofs)); break;
-#if BITS_PER_LONG >= 64
-	case 8:	 val.x[0] = __raw_readq(addr(map, ofs)); break;
-#endif
-	default: val.x[0] = 0; break;
-	}
-	for(i = 1; i < map_words(map); i++) {
-		val.x[i] = 0;
-	}
-	return val;
-}
-
-static void ichxrom_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
-{
-	memcpy_fromio(to, addr(map, from), len);
-}
-
-static void ichxrom_write(struct map_info *map, map_word d, unsigned long ofs)
-{
-	switch(map->bankwidth) {
-	case 1: __raw_writeb(d.x[0], addr(map,ofs)); break;
-	case 2: __raw_writew(d.x[0], addr(map,ofs)); break;
-	case 4: __raw_writel(d.x[0], addr(map,ofs)); break;
-#if BITS_PER_LONG >= 64
-	case 8: __raw_writeq(d.x[0], addr(map,ofs)); break;
-#endif
-	}
-	mb();
-}
-
-static void ichxrom_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
-{
-	memcpy_toio(addr(map, to), from, len);
-}
-
-static struct ichxrom_map_info ichxrom_map = {
-	.map = {
-		.name = MOD_NAME,
-		.phys = NO_XIP,
-		.size = 0,
-		.bankwidth = 1,
-		.read = ichxrom_read,
-		.copy_from = ichxrom_copy_from,
-		.write = ichxrom_write,
-		.copy_to = ichxrom_copy_to,
-		/* Firmware hubs only use vpp when being programmed
-		 * in a factory setting.  So in-place programming
-		 * needs to use a different method.
-		 */
-	},
-	/* remaining fields of structure are initialized to 0 */
+struct ichxrom_map_info {
+	struct list_head list;
+	struct map_info map;
+	struct mtd_info *mtd;
+	struct resource rsrc;
+	char map_name[sizeof(MOD_NAME) + 2 + ADDRESS_NAME_LEN];
 };
 
-enum fwh_lock_state {
-	FWH_DENY_WRITE = 1,
-	FWH_IMMUTABLE  = 2,
-	FWH_DENY_READ  = 4,
+static struct ichxrom_window ichxrom_window = {
+	.maps = LIST_HEAD_INIT(ichxrom_window.maps),
 };
 
-static void ichxrom_cleanup(struct ichxrom_map_info *info)
+static void ichxrom_cleanup(struct ichxrom_window *window)
 {
+	struct ichxrom_map_info *map, *scratch;
 	u16 word;
 
 	/* Disable writes through the rom window */
-	pci_read_config_word(info->pdev, BIOS_CNTL, &word);
-	pci_write_config_word(info->pdev, BIOS_CNTL, word & ~1);
-
-	if (info->mtd) {
-		del_mtd_device(info->mtd);
-		map_destroy(info->mtd);
-		info->mtd = NULL;
-		info->map.virt = 0;
-	}
-	if (info->rom_rsrc.parent)
-		release_resource(&info->rom_rsrc);
-	if (info->window_rsrc.parent)
-		release_resource(&info->window_rsrc);
-
-	if (info->window_addr) {
-		iounmap((void *)(info->window_addr));
-		info->window_addr = 0;
-	}
-}
+	pci_read_config_word(window->pdev, BIOS_CNTL, &word);
+	pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1);
 
-
-static int ichxrom_set_lock_state(struct mtd_info *mtd, loff_t ofs, size_t len,
-	enum fwh_lock_state state)
-{
-	struct map_info *map = mtd->priv;
-	unsigned long start = ofs;
-	unsigned long end = start + len -1;
-
-	/* FIXME do I need to guard against concurrency here? */
-	/* round down to 64K boundaries */
-	start = start & ~0xFFFF;
-	end = end & ~0xFFFF;
-	while (start <= end) {
-		unsigned long ctrl_addr;
-		ctrl_addr = addr(map, start) - 0x400000 + 2;
-		writeb(state, ctrl_addr);
-		start = start + 0x10000;
+	/* Free all of the mtd devices */
+	list_for_each_entry_safe(map, scratch, &window->maps, list) {
+		if (map->rsrc.parent)
+			release_resource(&map->rsrc);
+		del_mtd_device(map->mtd);
+		map_destroy(map->mtd);
+		list_del(&map->list);
+		kfree(map);
+	}
+	if (window->rsrc.parent)
+		release_resource(&window->rsrc);
+	if (window->virt) {
+		iounmap(window->virt);
+		window->virt = NULL;
+		window->phys = 0;
+		window->size = 0;
+		window->pdev = NULL;
 	}
-	return 0;
 }
 
-static int ichxrom_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
-{
-	return ichxrom_set_lock_state(mtd, ofs, len, FWH_DENY_WRITE);
-}
-
-static int ichxrom_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
-{
-	return ichxrom_set_lock_state(mtd, ofs, len, 0);
-}
 
 static int __devinit ichxrom_init_one (struct pci_dev *pdev,
 	const struct pci_device_id *ent)
 {
+	static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL };
+	struct ichxrom_window *window = &ichxrom_window;
+	struct ichxrom_map_info *map = NULL;
+	unsigned long map_top;
+	u8 byte;
 	u16 word;
-	struct ichxrom_map_info *info = &ichxrom_map;
-	unsigned long map_size;
-	static char *probes[] = { "cfi_probe", "jedec_probe" };
-	struct cfi_private *cfi;
 
 	/* For now I just handle the ichx and I assume there
 	 * are not a lot of resources up at the top of the address
@@ -204,26 +104,56 @@
 	 * Also you can page firmware hubs if an 8MB window isn't enough 
 	 * but don't currently handle that case either.
 	 */
+	window->pdev = pdev;
 
-	info->pdev = pdev;
+	/* Find a region continuous to the end of the ROM window  */
+	window->phys = 0;
+	pci_read_config_byte(pdev, FWH_DEC_EN1, &byte);
+	if (byte == 0xff) {
+		window->phys = 0xffc00000;
+		pci_read_config_byte(pdev, FWH_DEC_EN2, &byte);
+		if ((byte & 0x0f) == 0x0f) {
+			window->phys = 0xff400000;
+		}
+		else if ((byte & 0x0e) == 0x0e) {
+			window->phys = 0xff500000;
+		}
+		else if ((byte & 0x0c) == 0x0c) {
+			window->phys = 0xff600000;
+		}
+		else if ((byte & 0x08) == 0x08) {
+			window->phys = 0xff700000;
+		}
+	}
+	else if ((byte & 0xfe) == 0xfe) {
+		window->phys = 0xffc80000;
+	}
+	else if ((byte & 0xfc) == 0xfc) {
+		window->phys = 0xffd00000;
+	}
+	else if ((byte & 0xf8) == 0xf8) {
+		window->phys = 0xffd80000;
+	}
+	else if ((byte & 0xf0) == 0xf0) {
+		window->phys = 0xffe00000;
+	}
+	else if ((byte & 0xe0) == 0xe0) {
+		window->phys = 0xffe80000;
+	}
+	else if ((byte & 0xc0) == 0xc0) {
+		window->phys = 0xfff00000;
+	}
+	else if ((byte & 0x80) == 0x80) {
+		window->phys = 0xfff80000; 
+	}
 
-	/*
-	 * Try to reserve the window mem region.  If this fails then
-	 * it is likely due to the window being "reseved" by the BIOS.
-	 */
-	info->window_rsrc.name = MOD_NAME;
-	info->window_rsrc.start = ICHX_FWH_REGION_START;
-	info->window_rsrc.end = ICHX_FWH_REGION_START + ICHX_FWH_REGION_SIZE - 1;
-	info->window_rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-	if (request_resource(&iomem_resource, &info->window_rsrc)) {
-		info->window_rsrc.parent = NULL;
-		printk(KERN_ERR MOD_NAME
-		       " %s(): Unable to register resource"
-		       " 0x%.08lx-0x%.08lx - kernel bug?\n",
-		       __func__,
-		       info->window_rsrc.start, info->window_rsrc.end);
+	if (window->phys == 0) {
+		printk(KERN_ERR MOD_NAME ": Rom window is closed\n");
+		goto out;
 	}
-	
+	window->phys -= 0x400000UL;
+	window->size = (0xffffffffUL - window->phys) + 1UL;
+
 	/* Enable writes through the rom window */
 	pci_read_config_word(pdev, BIOS_CNTL, &word);
 	if (!(word & 1)  && (word & (1<<1))) {
@@ -231,119 +161,167 @@
 		 * this device, so don't even try.
 		 */
 		printk(KERN_ERR MOD_NAME ": firmware access control, I can't enable writes\n");
-		goto failed;
+		goto out;
 	}
 	pci_write_config_word(pdev, BIOS_CNTL, word | 1);
 
-
-	/* Map the firmware hub into my address space. */
-	/* Does this use too much virtual address space? */
-	info->window_addr = (unsigned long)ioremap(
-		ICHX_FWH_REGION_START, ICHX_FWH_REGION_SIZE);
-	if (!info->window_addr) {
-		printk(KERN_ERR "Failed to ioremap\n");
-		goto failed;
+	/*
+	 * Try to reserve the window mem region.  If this fails then
+	 * it is likely due to the window being "reseved" by the BIOS.
+	 */
+	window->rsrc.name = MOD_NAME;
+	window->rsrc.start = window->phys;
+	window->rsrc.end   = window->phys + window->size - 1;
+	window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+	if (request_resource(&iomem_resource, &window->rsrc)) {
+		window->rsrc.parent = NULL;
+		printk(KERN_DEBUG MOD_NAME
+			": %s(): Unable to register resource"
+			" 0x%.08lx-0x%.08lx - kernel bug?\n",
+			__func__,
+			window->rsrc.start, window->rsrc.end);
 	}
 
-	/* For now assume the firmware has setup all relevant firmware
-	 * windows.  We don't have enough information to handle this case
-	 * intelligently.
+	/* Map the firmware hub into my address space. */
+	window->virt = ioremap_nocache(window->phys, window->size);
+	if (!window->virt) {
+		printk(KERN_ERR MOD_NAME ": ioremap(%08lx, %08lx) failed\n",
+			window->phys, window->size);
+		goto out;
+	}
+
+	/* Get the first address to look for an rom chip at */
+	map_top = window->phys;
+	if ((window->phys & 0x3fffff) != 0) {
+		map_top = window->phys + 0x400000;
+	}
+#if 1
+	/* The probe sequence run over the firmware hub lock
+	 * registers sets them to 0x7 (no access).
+	 * Probe at most the last 4M of the address space.
 	 */
+	if (map_top < 0xffc00000) {
+		map_top = 0xffc00000;
+	}
+#endif
+	/* Loop through and look for rom chips */
+	while((map_top - 1) < 0xffffffffUL) {
+		struct cfi_private *cfi;
+		unsigned long offset;
+		int i;
 
-	/* FIXME select the firmware hub and enable a window to it. */
-
-	info->mtd = NULL;
-	info->map.map_priv_1 = info->window_addr;
+		if (!map) {
+			map = kmalloc(sizeof(*map), GFP_KERNEL);
+		}
+		if (!map) {
+			printk(KERN_ERR MOD_NAME ": kmalloc failed");
+			goto out;
+		}
+		memset(map, 0, sizeof(*map));
+		INIT_LIST_HEAD(&map->list);
+		map->map.name = map->map_name;
+		map->map.phys = map_top;
+		offset = map_top - window->phys;
+		map->map.virt = (void __iomem *)
+			(((unsigned long)(window->virt)) + offset);
+		map->map.size = 0xffffffffUL - map_top + 1UL;
+		/* Set the name of the map to the address I am trying */
+		sprintf(map->map_name, "%s @%08lx",
+			MOD_NAME, map->map.phys);
 
-	/* Loop through the possible bankwidths */
-	for(ichxrom_map.map.bankwidth = 4; ichxrom_map.map.bankwidth; ichxrom_map.map.bankwidth >>= 1) {
-		map_size = ICHX_FWH_REGION_SIZE;
-		while(!info->mtd && (map_size > 0)) {
-			int i;
-			info->map.size = map_size;
-			for(i = 0; i < sizeof(probes)/sizeof(char *); i++) {
-				info->mtd = do_map_probe(probes[i], &ichxrom_map.map);
-				if (info->mtd)
-					break;
+		/* Firmware hubs only use vpp when being programmed
+		 * in a factory setting.  So in-place programming
+		 * needs to use a different method.
+		 */
+		for(map->map.bankwidth = 32; map->map.bankwidth; 
+			map->map.bankwidth >>= 1)
+		{
+			char **probe_type;
+			/* Skip bankwidths that are not supported */
+			if (!map_bankwidth_supported(map->map.bankwidth))
+				continue;
+
+			/* Setup the map methods */
+			simple_map_init(&map->map);
+
+			/* Try all of the probe methods */
+			probe_type = rom_probe_types;
+			for(; *probe_type; probe_type++) {
+				map->mtd = do_map_probe(*probe_type, &map->map);
+				if (map->mtd)
+					goto found;
 			}
-			map_size -= 512*1024;
 		}
-		if (info->mtd)
-			break;
-	}
-	if (!info->mtd) {
-		goto failed;
-	}
-	cfi = ichxrom_map.map.fldrv_priv;
-	if ((cfi->mfr == MANUFACTURER_INTEL) && (
-		    (cfi->id == I82802AB) ||
-		    (cfi->id == I82802AC))) 
-	{
-		/* If it is a firmware hub put in the special lock
-		 * and unlock routines.
-		 */
-		info->mtd->lock = ichxrom_lock;
-		info->mtd->unlock = ichxrom_unlock;
-	}
-	if (info->mtd->size > info->map.size) {
-		printk(KERN_WARNING MOD_NAME " rom(%u) larger than window(%lu). fixing...\n",
-		       info->mtd->size, info->map.size);
-		info->mtd->size = info->map.size;
-	}
+		map_top += ROM_PROBE_STEP_SIZE;
+		continue;
+	found:
+		/* Trim the size if we are larger than the map */
+		if (map->mtd->size > map->map.size) {
+			printk(KERN_WARNING MOD_NAME
+				" rom(%u) larger than window(%lu). fixing...\n",
+				map->mtd->size, map->map.size);
+			map->mtd->size = map->map.size;
+		}
+		if (window->rsrc.parent) {
+			/*
+			 * Registering the MTD device in iomem may not be possible
+			 * if there is a BIOS "reserved" and BUSY range.  If this
+			 * fails then continue anyway.
+			 */
+			map->rsrc.name  = map->map_name;
+			map->rsrc.start = map->map.phys;
+			map->rsrc.end   = map->map.phys + map->mtd->size - 1;
+			map->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+			if (request_resource(&window->rsrc, &map->rsrc)) {
+				printk(KERN_ERR MOD_NAME
+					": cannot reserve MTD resource\n");
+				map->rsrc.parent = NULL;
+			}
+		}
+
+		/* Make the whole region visible in the map */
+		map->map.virt = window->virt;
+		map->map.phys = window->phys;
+		cfi = map->map.fldrv_priv;
+		for(i = 0; i < cfi->numchips; i++) {
+			cfi->chips[i].start += offset;
+		}
 		
-	info->mtd->owner = THIS_MODULE;
-	add_mtd_device(info->mtd);
+		/* Now that the mtd devices is complete claim and export it */
+		map->mtd->owner = THIS_MODULE;
+		if (add_mtd_device(map->mtd)) {
+			map_destroy(map->mtd);
+			map->mtd = NULL;
+			goto out;
+		}
 
-	if (info->window_rsrc.parent) {
-		/*
-		 * Registering the MTD device in iomem may not be possible
-		 * if there is a BIOS "reserved" and BUSY range.  If this
-		 * fails then continue anyway.
-		 */
-		snprintf(info->mtd_name, MTD_DEV_NAME_LENGTH,
-			 "mtd%d", info->mtd->index);
 
-		info->rom_rsrc.name = info->mtd_name;
-		info->rom_rsrc.start = ICHX_FWH_REGION_START
-			+ ICHX_FWH_REGION_SIZE - map_size;
-		info->rom_rsrc.end = ICHX_FWH_REGION_START
-			+ ICHX_FWH_REGION_SIZE;
-		info->rom_rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-		if (request_resource(&info->window_rsrc, &info->rom_rsrc)) {
-			printk(KERN_ERR MOD_NAME
-			       ": cannot reserve MTD resource\n");
-			info->rom_rsrc.parent = NULL;
-		}
-	}
+		/* Calculate the new value of map_top */
+		map_top += map->mtd->size;
 
+		/* File away the map structure */
+		list_add(&map->list, &window->maps);
+		map = NULL;
+	}
+
+ out:
+	/* Free any left over map structures */
+	if (map) {
+		kfree(map);
+	}
+	/* See if I have any map structures */
+	if (list_empty(&window->maps)) {
+		ichxrom_cleanup(window);
+		return -ENODEV;
+	}
 	return 0;
-
- failed:
-	ichxrom_cleanup(info);
-	return -ENODEV;
 }
 
 
 static void __devexit ichxrom_remove_one (struct pci_dev *pdev)
 {
-	struct ichxrom_map_info *info = &ichxrom_map;
-	u16 word;
-
-	del_mtd_device(info->mtd);
-	map_destroy(info->mtd);
-	info->mtd = NULL;
-	info->map.map_priv_1 = 0;
-
-	iounmap((void *)(info->window_addr));
-	info->window_addr = 0;
-
-	/* Disable writes through the rom window */
-	pci_read_config_word(pdev, BIOS_CNTL, &word);
-	pci_write_config_word(pdev, BIOS_CNTL, word & ~1);
-
-#if RESERVE_MEM_REGION	
-	release_mem_region(ICHX_FWH_REGION_START, ICHX_FWH_REGION_SIZE);
-#endif
+	struct ichxrom_window *window = &ichxrom_window;
+	ichxrom_cleanup(window);
 }
 
 static struct pci_device_id ichxrom_pci_tbl[] __devinitdata = {
@@ -371,8 +349,7 @@
 };
 #endif
 
-static struct pci_dev *mydev;
-int __init init_ichxrom(void)
+static int __init init_ichxrom(void)
 {
 	struct pci_dev *pdev;
 	struct pci_device_id *id;
@@ -385,7 +362,6 @@
 		}
 	}
 	if (pdev) {
-		mydev = pdev;
 		return ichxrom_init_one(pdev, &ichxrom_pci_tbl[0]);
 	}
 	return -ENXIO;
@@ -396,7 +372,7 @@
 
 static void __exit cleanup_ichxrom(void)
 {
-	ichxrom_remove_one(mydev);
+	ichxrom_remove_one(ichxrom_window.pdev);
 }
 
 module_init(init_ichxrom);
diff -Nru a/drivers/mtd/maps/impa7.c b/drivers/mtd/maps/impa7.c
--- a/drivers/mtd/maps/impa7.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/mtd/maps/impa7.c	2004-12-24 13:36:30 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: impa7.c,v 1.11 2004/07/14 09:52:55 dwmw2 Exp $
+ * $Id: impa7.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $
  *
  * Handle mapping of the NOR flash on implementa A7 boards
  *
@@ -77,7 +77,7 @@
 {
 	static const char *rom_probe_types[] = PROBETYPES;
 	const char **type;
-	const char *part_type = NULL;
+	const char *part_type = 0;
 	int i;
 	static struct { u_long addr; u_long size; } pt[NUM_FLASHBANKS] = {
 	  { WINDOW_ADDR0, WINDOW_SIZE0 },
@@ -91,15 +91,14 @@
 		       pt[i].size, pt[i].addr);
 
 		impa7_map[i].phys = pt[i].addr;
-		impa7_map[i].virt = (unsigned long)
-		  ioremap(pt[i].addr, pt[i].size);
+		impa7_map[i].virt = ioremap(pt[i].addr, pt[i].size);
 		if (!impa7_map[i].virt) {
 			printk(MSG_PREFIX "failed to ioremap\n");
 			return -EIO;
 		}
 		simple_map_init(&impa7_map[i]);
 
-		impa7_mtd[i] = NULL;
+		impa7_mtd[i] = 0;
 		type = rom_probe_types;
 		for(; !impa7_mtd[i] && *type; type++) {
 			impa7_mtd[i] = do_map_probe(*type, &impa7_map[i]);
diff -Nru a/drivers/mtd/maps/integrator-flash-v24.c b/drivers/mtd/maps/integrator-flash-v24.c
--- a/drivers/mtd/maps/integrator-flash-v24.c	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,258 +0,0 @@
-/*======================================================================
-
-    drivers/mtd/maps/armflash.c: ARM Flash Layout/Partitioning
-  
-    Copyright (C) 2000 ARM Limited
-  
-   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
-  
-   This is access code for flashes using ARM's flash partitioning 
-   standards.
-
-   $Id: integrator-flash-v24.c,v 1.13 2004/07/12 21:59:44 dwmw2 Exp $
-
-======================================================================*/
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/partitions.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/system.h>
-
-// board specific stuff - sorry, it should be in arch/arm/mach-*.
-#ifdef CONFIG_ARCH_INTEGRATOR
-
-#define FLASH_BASE	INTEGRATOR_FLASH_BASE
-#define FLASH_SIZE	INTEGRATOR_FLASH_SIZE
-
-#define FLASH_PART_SIZE 0x400000
-
-#define SC_CTRLC	(IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_CTRLC_OFFSET)
-#define SC_CTRLS	(IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_CTRLS_OFFSET)
-#define EBI_CSR1	(IO_ADDRESS(INTEGRATOR_EBI_BASE) + INTEGRATOR_EBI_CSR1_OFFSET)
-#define EBI_LOCK	(IO_ADDRESS(INTEGRATOR_EBI_BASE) + INTEGRATOR_EBI_LOCK_OFFSET)
-
-/*
- * Initialise the flash access systems:
- *  - Disable VPP
- *  - Assert WP
- *  - Set write enable bit in EBI reg
- */
-static void armflash_flash_init(void)
-{
-	unsigned int tmp;
-
-	__raw_writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, SC_CTRLC);
-
-	tmp = __raw_readl(EBI_CSR1) | INTEGRATOR_EBI_WRITE_ENABLE;
-	__raw_writel(tmp, EBI_CSR1);
-
-	if (!(__raw_readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE)) {
-		__raw_writel(0xa05f, EBI_LOCK);
-		__raw_writel(tmp, EBI_CSR1);
-		__raw_writel(0, EBI_LOCK);
-	}
-}
-
-/*
- * Shutdown the flash access systems:
- *  - Disable VPP
- *  - Assert WP
- *  - Clear write enable bit in EBI reg
- */
-static void armflash_flash_exit(void)
-{
-	unsigned int tmp;
-
-	__raw_writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, SC_CTRLC);
-
-	/*
-	 * Clear the write enable bit in system controller EBI register.
-	 */
-	tmp = __raw_readl(EBI_CSR1) & ~INTEGRATOR_EBI_WRITE_ENABLE;
-	__raw_writel(tmp, EBI_CSR1);
-
-	if (__raw_readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE) {
-		__raw_writel(0xa05f, EBI_LOCK);
-		__raw_writel(tmp, EBI_CSR1);
-		__raw_writel(0, EBI_LOCK);
-	}
-}
-
-static void armflash_flash_wp(int on)
-{
-	unsigned int reg;
-
-	if (on)
-		reg = SC_CTRLC;
-	else
-		reg = SC_CTRLS;
-
-	__raw_writel(INTEGRATOR_SC_CTRL_nFLWP, reg);
-}
-
-static void armflash_set_vpp(struct map_info *map, int on)
-{
-	unsigned int reg;
-
-	if (on)
-		reg = SC_CTRLS;
-	else
-		reg = SC_CTRLC;
-
-	__raw_writel(INTEGRATOR_SC_CTRL_nFLVPPEN, reg);
-}
-#endif
-
-#ifdef CONFIG_ARCH_P720T
-
-#define FLASH_BASE		(0x04000000)
-#define FLASH_SIZE		(64*1024*1024)
-
-#define FLASH_PART_SIZE 	(4*1024*1024)
-#define FLASH_BLOCK_SIZE	(128*1024)
-
-static void armflash_flash_init(void)
-{
-}
-
-static void armflash_flash_exit(void)
-{
-}
-
-static void armflash_flash_wp(int on)
-{
-}
-
-static void armflash_set_vpp(struct map_info *map, int on)
-{
-}
-#endif
-
-
-static struct map_info armflash_map =
-{
-	.name =		"AFS",
-	.set_vpp =	armflash_set_vpp,
-	.phys =		FLASH_BASE,
-};
-
-static struct mtd_info *mtd;
-static struct mtd_partition *parts;
-static const char *probes[] = { "RedBoot", "afs", NULL };
-
-static int __init armflash_cfi_init(void *base, u_int size)
-{
-	int ret;
-
-	armflash_flash_init();
-	armflash_flash_wp(1);
-
-	/*
-	 * look for CFI based flash parts fitted to this board
-	 */
-	armflash_map.size       = size;
-	armflash_map.bankwidth   = 4;
-	armflash_map.virt = (unsigned long) base;
-
-	simple_map_init(&armflash_map);
-
-	/*
-	 * Also, the CFI layer automatically works out what size
-	 * of chips we have, and does the necessary identification
-	 * for us automatically.
-	 */
-	mtd = do_map_probe("cfi_probe", &armflash_map);
-	if (!mtd)
-		return -ENXIO;
-
-	mtd->owner = THIS_MODULE;
-
-	ret = parse_mtd_partitions(mtd, probes, &parts, (void *)0);
-	if (ret > 0) {
-		ret = add_mtd_partitions(mtd, parts, ret);
-		if (ret)
-			printk(KERN_ERR "mtd partition registration "
-				"failed: %d\n", ret);
-	}
-
-	/*
-	 * If we got an error, free all resources.
-	 */
-	if (ret < 0) {
-		del_mtd_partitions(mtd);
-		map_destroy(mtd);
-	}
-
-	return ret;
-}
-
-static void armflash_cfi_exit(void)
-{
-	if (mtd) {
-		del_mtd_partitions(mtd);
-		map_destroy(mtd);
-	}
-	if (parts)
-		kfree(parts);
-}
-
-static int __init armflash_init(void)
-{
-	int err = -EBUSY;
-	void *base;
-
-	if (request_mem_region(FLASH_BASE, FLASH_SIZE, "flash") == NULL)
-		goto out;
-
-	base = ioremap(FLASH_BASE, FLASH_SIZE);
-	err = -ENOMEM;
-	if (base == NULL)
-		goto release;
-
-	err = armflash_cfi_init(base, FLASH_SIZE);
-	if (err) {
-		iounmap(base);
-release:
-		release_mem_region(FLASH_BASE, FLASH_SIZE);
-	}
-out:
-	return err;
-}
-
-static void __exit armflash_exit(void)
-{
-	armflash_cfi_exit();
-	iounmap((void *)armflash_map.virt);
-	release_mem_region(FLASH_BASE, FLASH_SIZE);
-	armflash_flash_exit();
-}
-
-module_init(armflash_init);
-module_exit(armflash_exit);
-
-MODULE_AUTHOR("ARM Ltd");
-MODULE_DESCRIPTION("ARM Integrator CFI map driver");
-MODULE_LICENSE("GPL");
diff -Nru a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
--- a/drivers/mtd/maps/integrator-flash.c	2004-12-24 13:37:44 -08:00
+++ b/drivers/mtd/maps/integrator-flash.c	2004-12-24 13:37:44 -08:00
@@ -22,7 +22,7 @@
    This is access code for flashes using ARM's flash partitioning 
    standards.
 
-   $Id: integrator-flash.c,v 1.16 2004/07/12 21:59:44 dwmw2 Exp $
+   $Id: integrator-flash.c,v 1.18 2004/11/01 13:26:15 rmk Exp $
 
 ======================================================================*/
 
@@ -75,7 +75,7 @@
 	unsigned int size = res->end - res->start + 1;
 	struct armflash_info *info;
 	int err;
-	void *base;
+	void __iomem *base;
 
 	info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL);
 	if (!info) {
@@ -110,7 +110,7 @@
 	info->map.size		= size;
 	info->map.bankwidth	= plat->width;
 	info->map.phys		= res->start;
-	info->map.virt		= (unsigned long) base;
+	info->map.virt		= base;
 	info->map.name		= dev->dev.bus_id;
 	info->map.set_vpp	= armflash_set_vpp;
 
@@ -179,7 +179,7 @@
 		if (info->parts)
 			kfree(info->parts);
 
-		iounmap((void *)info->map.virt);
+		iounmap(info->map.virt);
 		release_resource(info->res);
 		kfree(info->res);
 
diff -Nru a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mtd/maps/ipaq-flash.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,464 @@
+/*
+ * Flash memory access on iPAQ Handhelds (either SA1100 or PXA250 based)
+ * 
+ * (C) 2000 Nicolas Pitre <nico@cam.org>
+ * (C) 2002 Hewlett-Packard Company <jamey.hicks@hp.com>
+ * (C) 2003 Christian Pellegrin <chri@ascensit.com>, <chri@infis.univ.ts.it>: concatenation of multiple flashes
+ * 
+ * $Id: ipaq-flash.c,v 1.3 2004/11/04 13:24:15 gleixner Exp $
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <asm/page.h>
+#include <asm/mach-types.h>
+#include <asm/system.h>
+#include <asm/errno.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+#ifdef CONFIG_MTD_CONCAT
+#include <linux/mtd/concat.h>
+#endif
+
+#include <asm/hardware.h>
+#include <asm/arch-sa1100/h3600.h>
+#include <asm/io.h>
+
+
+#ifndef CONFIG_IPAQ_HANDHELD
+#error This is for iPAQ Handhelds only
+#endif
+#ifdef CONFIG_SA1100_JORNADA56X
+
+static void jornada56x_set_vpp(struct map_info *map, int vpp)
+{
+	if (vpp)
+		GPSR = GPIO_GPIO26;
+	else
+		GPCR = GPIO_GPIO26;
+	GPDR |= GPIO_GPIO26;
+}
+
+#endif
+
+#ifdef CONFIG_SA1100_JORNADA720
+
+static void jornada720_set_vpp(struct map_info *map, int vpp)
+{
+	if (vpp)
+		PPSR |= 0x80;
+	else
+		PPSR &= ~0x80;
+	PPDR |= 0x80;
+}
+
+#endif
+
+#define MAX_IPAQ_CS 2		/* Number of CS we are going to test */
+
+#define IPAQ_MAP_INIT(X) \
+	{ \
+		name:		"IPAQ flash " X, \
+	}
+
+
+static struct map_info ipaq_map[MAX_IPAQ_CS] = {
+	IPAQ_MAP_INIT("bank 1"),
+	IPAQ_MAP_INIT("bank 2")
+};
+
+static struct mtd_info *my_sub_mtd[MAX_IPAQ_CS] = {
+	NULL,
+	NULL
+};
+
+/*
+ * Here are partition information for all known IPAQ-based devices.
+ * See include/linux/mtd/partitions.h for definition of the mtd_partition
+ * structure.
+ *
+ * The *_max_flash_size is the maximum possible mapped flash size which
+ * is not necessarily the actual flash size.  It must be no more than
+ * the value specified in the "struct map_desc *_io_desc" mapping
+ * definition for the corresponding machine.
+ *
+ * Please keep these in alphabetical order, and formatted as per existing
+ * entries.  Thanks.
+ */
+
+#ifdef CONFIG_IPAQ_HANDHELD
+static unsigned long h3xxx_max_flash_size = 0x04000000;
+static struct mtd_partition h3xxx_partitions[] = {
+	{
+		name:		"H3XXX boot firmware",
+#ifndef CONFIG_LAB
+		size:		0x00040000,
+#else
+		size:		0x00080000,
+#endif
+		offset:		0,
+#ifndef CONFIG_LAB
+		mask_flags:	MTD_WRITEABLE,  /* force read-only */
+#endif
+	}, 
+	{
+		name:		"H3XXX root jffs2",
+#ifndef CONFIG_LAB
+		size:		0x2000000 - 2*0x40000, /* Warning, this is fixed later */
+		offset:		0x00040000,
+#else
+		size:		0x2000000 - 0x40000 - 0x80000, /* Warning, this is fixed later */
+		offset:		0x00080000,
+#endif
+	},
+	{
+		name:		"asset",
+		size:		0x40000,
+		offset:		0x2000000 - 0x40000, /* Warning, this is fixed later */
+		mask_flags:	MTD_WRITEABLE,  /* force read-only */
+	}
+};
+
+#ifndef CONFIG_MTD_CONCAT
+static struct mtd_partition h3xxx_partitions_bank2[] = {
+	/* this is used only on 2 CS machines when concat is not present */
+	{
+		name:		"second H3XXX root jffs2",
+		size:		0x1000000 - 0x40000, /* Warning, this is fixed later */
+		offset:		0x00000000,
+	},
+	{
+		name:		"second asset",
+		size:		0x40000,
+		offset:		0x1000000 - 0x40000, /* Warning, this is fixed later */
+		mask_flags:	MTD_WRITEABLE,  /* force read-only */
+	}
+};
+#endif
+
+static spinlock_t ipaq_vpp_lock = SPIN_LOCK_UNLOCKED;
+
+static void h3xxx_set_vpp(struct map_info *map, int vpp)
+{
+	static int nest = 0;
+	
+	spin_lock(&ipaq_vpp_lock);
+	if (vpp)
+		nest++;
+	else
+		nest--;
+	if (nest)
+		assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, 1);
+	else
+		assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, 0);
+	spin_unlock(&ipaq_vpp_lock);
+}
+
+#endif
+
+#if defined(CONFIG_SA1100_JORNADA56X) || defined(CONFIG_SA1100_JORNADA720)
+static unsigned long jornada_max_flash_size = 0x02000000;
+static struct mtd_partition jornada_partitions[] = {
+	{
+		name:		"Jornada boot firmware",
+		size:		0x00040000,
+		offset:		0,
+		mask_flags:	MTD_WRITEABLE,  /* force read-only */
+	}, {
+		name:		"Jornada root jffs2",
+		size:		MTDPART_SIZ_FULL,
+		offset:		0x00040000,
+	}
+};
+#endif
+
+
+static struct mtd_partition *parsed_parts;
+static struct mtd_info *mymtd;
+
+static unsigned long cs_phys[] = {
+#ifdef CONFIG_ARCH_SA1100
+	SA1100_CS0_PHYS,
+	SA1100_CS1_PHYS,
+	SA1100_CS2_PHYS,
+	SA1100_CS3_PHYS,
+	SA1100_CS4_PHYS,
+	SA1100_CS5_PHYS,
+#else 
+	PXA_CS0_PHYS,
+	PXA_CS1_PHYS,
+	PXA_CS2_PHYS,
+	PXA_CS3_PHYS,
+	PXA_CS4_PHYS,
+	PXA_CS5_PHYS,
+#endif
+};
+
+static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
+
+static int __init h1900_special_case(void);
+
+int __init ipaq_mtd_init(void)
+{
+	struct mtd_partition *parts = NULL;
+	int nb_parts = 0;
+	int parsed_nr_parts = 0;
+	const char *part_type;
+	int i; /* used when we have >1 flash chips */
+	unsigned long tot_flashsize = 0; /* used when we have >1 flash chips */
+
+	/* Default flash bankwidth */
+	// ipaq_map.bankwidth = (MSC0 & MSC_RBW) ? 2 : 4;
+	
+	if (machine_is_h1900())
+	{
+		/* For our intents, the h1900 is not a real iPAQ, so we special-case it. */
+		return h1900_special_case();
+	}
+
+	if (machine_is_h3100() || machine_is_h1900())
+		for(i=0; i<MAX_IPAQ_CS; i++)
+			ipaq_map[i].bankwidth = 2;
+	else
+		for(i=0; i<MAX_IPAQ_CS; i++)
+			ipaq_map[i].bankwidth = 4;
+			
+	/*
+	 * Static partition definition selection
+	 */
+	part_type = "static";
+
+	simple_map_init(&ipaq_map[0]);
+	simple_map_init(&ipaq_map[1]);
+
+#ifdef CONFIG_IPAQ_HANDHELD
+	if (machine_is_ipaq()) {
+		parts = h3xxx_partitions;
+		nb_parts = ARRAY_SIZE(h3xxx_partitions);
+		for(i=0; i<MAX_IPAQ_CS; i++) {
+			ipaq_map[i].size = h3xxx_max_flash_size;
+			ipaq_map[i].set_vpp = h3xxx_set_vpp;
+			ipaq_map[i].phys = cs_phys[i];
+			ipaq_map[i].virt = __ioremap(cs_phys[i], 0x04000000, 0, 1);
+			if (machine_is_h3100 () || machine_is_h1900())
+				ipaq_map[i].bankwidth = 2;
+		}
+		if (machine_is_h3600()) {
+			/* No asset partition here */
+			h3xxx_partitions[1].size += 0x40000;
+			nb_parts--;
+		}
+	}
+#endif
+#ifdef CONFIG_ARCH_H5400
+	if (machine_is_h5400()) {
+		ipaq_map[0].size = 0x02000000;
+		ipaq_map[1].size = 0x02000000;
+		ipaq_map[1].phys = 0x02000000;
+		ipaq_map[1].virt = ipaq_map[0].virt + 0x02000000;
+	}
+#endif
+#ifdef CONFIG_ARCH_H1900
+	if (machine_is_h1900()) {
+		ipaq_map[0].size = 0x00400000;
+		ipaq_map[1].size = 0x02000000;
+		ipaq_map[1].phys = 0x00080000;
+		ipaq_map[1].virt = ipaq_map[0].virt + 0x00080000;
+	}
+#endif
+
+#ifdef CONFIG_SA1100_JORNADA56X
+	if (machine_is_jornada56x()) {
+		parts = jornada_partitions;
+		nb_parts = ARRAY_SIZE(jornada_partitions);
+		ipaq_map[0].size = jornada_max_flash_size;
+		ipaq_map[0].set_vpp = jornada56x_set_vpp;
+		ipaq_map[0].virt = (__u32)__ioremap(0x0, 0x04000000, 0, 1);
+	}
+#endif
+#ifdef CONFIG_SA1100_JORNADA720
+	if (machine_is_jornada720()) {
+		parts = jornada_partitions;
+		nb_parts = ARRAY_SIZE(jornada_partitions);
+		ipaq_map[0].size = jornada_max_flash_size;
+		ipaq_map[0].set_vpp = jornada720_set_vpp;
+	}
+#endif
+
+
+	if (machine_is_ipaq()) { /* for iPAQs only */
+		for(i=0; i<MAX_IPAQ_CS; i++) {
+			printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with CFI.\n", ipaq_map[i].bankwidth*8, ipaq_map[i].virt);
+			my_sub_mtd[i] = do_map_probe("cfi_probe", &ipaq_map[i]);
+			if (!my_sub_mtd[i]) {
+				printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with JEDEC.\n", ipaq_map[i].bankwidth*8, ipaq_map[i].virt);
+				my_sub_mtd[i] = do_map_probe("jedec_probe", &ipaq_map[i]);
+			}
+			if (!my_sub_mtd[i]) {
+				printk(KERN_NOTICE "iPAQ flash: failed to find flash.\n");
+				if (i)
+					break;
+				else
+					return -ENXIO;
+			} else
+				printk(KERN_NOTICE "iPAQ flash: found %d bytes\n", my_sub_mtd[i]->size);
+			
+			/* do we really need this debugging? --joshua 20030703 */
+			// printk("my_sub_mtd[%d]=%p\n", i, my_sub_mtd[i]);
+			my_sub_mtd[i]->owner = THIS_MODULE;
+			tot_flashsize += my_sub_mtd[i]->size;
+		}
+#ifdef CONFIG_MTD_CONCAT
+		/* fix the asset location */
+#	ifdef CONFIG_LAB
+		h3xxx_partitions[1].size = tot_flashsize - 0x40000 - 0x80000 /* extra big boot block */;
+#	else
+		h3xxx_partitions[1].size = tot_flashsize - 2 * 0x40000;
+#	endif
+		h3xxx_partitions[2].offset = tot_flashsize - 0x40000;
+		/* and concat the devices */
+		mymtd = mtd_concat_create(&my_sub_mtd[0], i,
+					  "ipaq");
+		if (!mymtd) {
+			printk("Cannot create iPAQ concat device\n");
+			return -ENXIO;
+		}
+#else
+		mymtd = my_sub_mtd[0];
+
+		/* 
+		 *In the very near future, command line partition parsing
+		 * will use the device name as 'mtd-id' instead of a value
+		 * passed to the parse_cmdline_partitions() routine. Since
+		 * the bootldr says 'ipaq', make sure it continues to work. 
+		 */
+		mymtd->name = "ipaq";
+
+		if ((machine_is_h3600())) {
+#	ifdef CONFIG_LAB
+			h3xxx_partitions[1].size = my_sub_mtd[0]->size - 0x80000;
+#	else
+			h3xxx_partitions[1].size = my_sub_mtd[0]->size - 0x40000;
+#	endif
+			nb_parts = 2;
+		} else {
+#	ifdef CONFIG_LAB
+			h3xxx_partitions[1].size = my_sub_mtd[0]->size - 0x40000 - 0x80000; /* extra big boot block */
+#	else
+			h3xxx_partitions[1].size = my_sub_mtd[0]->size - 2*0x40000;
+#	endif
+			h3xxx_partitions[2].offset = my_sub_mtd[0]->size - 0x40000;
+		}
+
+		if (my_sub_mtd[1]) {
+#	ifdef CONFIG_LAB
+			h3xxx_partitions_bank2[0].size = my_sub_mtd[1]->size - 0x80000;
+#	else
+			h3xxx_partitions_bank2[0].size = my_sub_mtd[1]->size - 0x40000;
+#	endif
+			h3xxx_partitions_bank2[1].offset = my_sub_mtd[1]->size - 0x40000;
+		}
+#endif
+	}
+	else {
+		/*
+		 * Now let's probe for the actual flash.  Do it here since
+		 * specific machine settings might have been set above.
+		 */
+		printk(KERN_NOTICE "IPAQ flash: probing %d-bit flash bus, window=%lx\n", ipaq_map[0].bankwidth*8, ipaq_map[0].virt);
+		mymtd = do_map_probe("cfi_probe", &ipaq_map[0]);
+		if (!mymtd)
+			return -ENXIO;
+		mymtd->owner = THIS_MODULE;
+	}
+
+
+	/*
+	 * Dynamic partition selection stuff (might override the static ones)
+	 */
+
+	 i = parse_mtd_partitions(mymtd, part_probes, &parsed_parts, 0);
+			
+	 if (i > 0) {
+		 nb_parts = parsed_nr_parts = i;
+		 parts = parsed_parts;
+		 part_type = "dynamic";
+	 }
+
+	 if (!parts) {
+		 printk(KERN_NOTICE "IPAQ flash: no partition info available, registering whole flash at once\n");
+		 add_mtd_device(mymtd);
+#ifndef CONFIG_MTD_CONCAT
+		 if (my_sub_mtd[1])
+			 add_mtd_device(my_sub_mtd[1]);
+#endif
+	 } else {
+		 printk(KERN_NOTICE "Using %s partition definition\n", part_type);
+		 add_mtd_partitions(mymtd, parts, nb_parts);
+#ifndef CONFIG_MTD_CONCAT
+		 if (my_sub_mtd[1])
+			 add_mtd_partitions(my_sub_mtd[1], h3xxx_partitions_bank2, ARRAY_SIZE(h3xxx_partitions_bank2));
+#endif
+	 }
+
+	 return 0;
+}
+
+static void __exit ipaq_mtd_cleanup(void)
+{
+	int i;
+
+	if (mymtd) {
+		del_mtd_partitions(mymtd);
+#ifndef CONFIG_MTD_CONCAT
+		if (my_sub_mtd[1])
+			del_mtd_partitions(my_sub_mtd[1]);
+#endif
+		map_destroy(mymtd);
+#ifdef CONFIG_MTD_CONCAT
+		for(i=0; i<MAX_IPAQ_CS; i++) 
+#else
+			for(i=1; i<MAX_IPAQ_CS; i++) 
+#endif		  
+			{
+				if (my_sub_mtd[i])
+					map_destroy(my_sub_mtd[i]);
+			}
+		if (parsed_parts)
+			kfree(parsed_parts);
+	}
+}
+
+static int __init h1900_special_case(void)
+{
+	/* The iPAQ h1900 is a special case - it has weird ROM. */
+	simple_map_init(&ipaq_map[0]);
+	ipaq_map[0].size = 0x80000;
+	ipaq_map[0].set_vpp = h3xxx_set_vpp;
+	ipaq_map[0].phys = 0x0;
+	ipaq_map[0].virt = __ioremap(0x0, 0x04000000, 0, 1);
+	ipaq_map[0].bankwidth = 2;
+	
+	printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with JEDEC.\n", ipaq_map[0].bankwidth*8, ipaq_map[0].virt);
+	mymtd = do_map_probe("jedec_probe", &ipaq_map[0]);
+	if (!mymtd)
+		return -ENODEV;
+	add_mtd_device(mymtd);
+	printk(KERN_NOTICE "iPAQ flash: registered h1910 flash\n");
+	
+	return 0;
+}
+
+module_init(ipaq_mtd_init);
+module_exit(ipaq_mtd_cleanup);
+
+MODULE_AUTHOR("Jamey Hicks");
+MODULE_DESCRIPTION("IPAQ CFI map driver");
+MODULE_LICENSE("MIT");
diff -Nru a/drivers/mtd/maps/iq80310.c b/drivers/mtd/maps/iq80310.c
--- a/drivers/mtd/maps/iq80310.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/mtd/maps/iq80310.c	2004-12-24 13:37:19 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: iq80310.c,v 1.18 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: iq80310.c,v 1.20 2004/11/04 13:24:15 gleixner Exp $
  *
  * Mapping for the Intel XScale IQ80310 evaluation board
  *
@@ -68,7 +68,7 @@
 	int parsed_nr_parts = 0;
 	int ret;
 
-	iq80310_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
+	iq80310_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
 	if (!iq80310_map.virt) {
 		printk("Failed to ioremap\n");
 		return -EIO;
diff -Nru a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
--- a/drivers/mtd/maps/ixp2000.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/mtd/maps/ixp2000.c	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: ixp2000.c,v 1.1 2004/09/02 00:13:41 dsaxena Exp $
+ * $Id: ixp2000.c,v 1.5 2004/11/16 17:15:48 dsaxena Exp $
  *
  * drivers/mtd/maps/ixp2000.c
  *
@@ -14,7 +14,7 @@
  * 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/module.h>
@@ -44,8 +44,8 @@
 };
 
 static inline unsigned long flash_bank_setup(struct map_info *map, unsigned long ofs)
-{
-	unsigned long (*set_bank)(unsigned long) =
+{	
+	unsigned long (*set_bank)(unsigned long) = 
 		(unsigned long(*)(unsigned long))map->map_priv_2;
 
 	return (set_bank ? set_bank(ofs) : ofs);
@@ -53,15 +53,15 @@
 
 #ifdef __ARMEB__
 /*
- * Rev A0 and A1 of IXP2400 silicon have a broken addressing unit which
- * causes the lower address bits to be XORed with 0x11 on 8 bit accesses
- * and XORed with 0x10 on 16 bit accesses. See the spec update, erratta 44.
+ * Rev A0 and A1 of IXP2400 silicon have a broken addressing unit which 
+ * causes the lower address bits to be XORed with 0x11 on 8 bit accesses 
+ * and XORed with 0x10 on 16 bit accesses. See the spec update, erratum 44.
  */
-static int errata44_workaround = 0;
+static int erratum44_workaround = 0;
 
 static inline unsigned long address_fix8_write(unsigned long addr)
 {
-	if (errata44_workaround) {
+	if (erratum44_workaround) {
 		return (addr ^ 3);
 	}
 	return addr;
@@ -88,7 +88,7 @@
 			      unsigned long from, ssize_t len)
 {
 	from = flash_bank_setup(map, from);
-	while(len--)
+	while(len--) 
 		*(__u8 *) to++ = *(__u8 *)(map->map_priv_1 + from++);
 }
 
@@ -127,8 +127,8 @@
 	if (info->map.map_priv_1)
 		iounmap((void *) info->map.map_priv_1);
 
-	if (info->partitions)
-		kfree(info->partitions);
+	if (info->partitions) {
+		kfree(info->partitions); }
 
 	if (info->res) {
 		release_resource(info->res);
@@ -147,11 +147,11 @@
 	static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
 	struct platform_device *dev = to_platform_device(_dev);
 	struct ixp2000_flash_data *ixp_data = dev->dev.platform_data;
-	struct flash_platform_data *plat;
+	struct flash_platform_data *plat; 
 	struct ixp2000_flash_info *info;
 	unsigned long window_size;
 	int err = -1;
-
+	
 	if (!ixp_data)
 		return -ENODEV;
 
@@ -160,7 +160,7 @@
 		return -ENODEV;
 
 	window_size = dev->resource->end - dev->resource->start + 1;
-	dev_info(_dev, "Probe of IXP2000 flash(%d banks x %dM)\n",
+	dev_info(_dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n", 
 			ixp_data->nr_banks, ((u32)window_size >> 20));
 
 	if (plat->width != 1) {
@@ -173,7 +173,7 @@
 	if(!info) {
 		err = -ENOMEM;
 		goto Error;
-	}
+	}	
 	memzero(info, sizeof(struct ixp2000_flash_info));
 
 	dev_set_drvdata(&dev->dev, info);
@@ -183,7 +183,7 @@
 	 * not attempt to do a direct access on us.
 	 */
 	info->map.phys = NO_XIP;
-
+	
 	info->nr_banks = ixp_data->nr_banks;
 	info->map.size = ixp_data->nr_banks * window_size;
 	info->map.bankwidth = 1;
@@ -191,7 +191,7 @@
 	/*
  	 * map_priv_2 is used to store a ptr to to the bank_setup routine
  	 */
-	info->map.map_priv_2 = (u32) ixp_data->bank_setup;
+	info->map.map_priv_2 = (void __iomem *) ixp_data->bank_setup;
 
 	info->map.name = dev->dev.bus_id;
 	info->map.read = ixp2000_flash_read8;
@@ -199,8 +199,8 @@
 	info->map.copy_from = ixp2000_flash_copy_from;
 	info->map.copy_to = ixp2000_flash_copy_to;
 
-	info->res = request_mem_region(dev->resource->start,
-			dev->resource->end - dev->resource->start + 1,
+	info->res = request_mem_region(dev->resource->start, 
+			dev->resource->end - dev->resource->start + 1, 
 			dev->dev.bus_id);
 	if (!info->res) {
 		dev_err(_dev, "Could not reserve memory region\n");
@@ -208,9 +208,8 @@
 		goto Error;
 	}
 
-	info->map.map_priv_1 =
-	    (unsigned long) ioremap(dev->resource->start,
-				    dev->resource->end - dev->resource->start + 1);
+	info->map.map_priv_1 = ioremap(dev->resource->start, 
+			    	dev->resource->end - dev->resource->start + 1);
 	if (!info->map.map_priv_1) {
 		dev_err(_dev, "Failed to ioremap flash region\n");
 		err = -EIO;
@@ -224,12 +223,12 @@
 
 #if defined(__ARMEB__)
 	/*
-	 * Enable errata 44 workaround for NPUs with broken slowport
+	 * Enable erratum 44 workaround for NPUs with broken slowport
 	 */
 
-	errata44_workaround = ixp2000_has_broken_slowport();
-	dev_info(_dev, "Errata 44 workaround %s\n",
-	       errata44_workaround ? "enabled" : "disabled");
+	erratum44_workaround = ixp2000_has_broken_slowport();
+	dev_info(_dev, "Erratum 44 workaround %s\n",
+	       erratum44_workaround ? "enabled" : "disabled");
 #endif
 
 	info->mtd = do_map_probe(plat->map_name, &info->map);
diff -Nru a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
--- a/drivers/mtd/maps/ixp4xx.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/mtd/maps/ixp4xx.c	2004-12-24 13:36:16 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: ixp4xx.c,v 1.6 2004/09/17 00:25:06 gleixner Exp $
+ * $Id: ixp4xx.c,v 1.7 2004/11/04 13:24:15 gleixner Exp $
  *
  * drivers/mtd/maps/ixp4xx.c
  *
@@ -69,7 +69,7 @@
 		dest[len - 1] = BYTE0(src[i]);
 }
 
-/*
+/* 
  * Unaligned writes are ignored, causing the 8-bit
  * probe to fail and proceed to the 16-bit probe (which succeeds).
  */
@@ -79,7 +79,7 @@
 	       *(__u16 *) (map->map_priv_1 + adr) = d.x[0];
 }
 
-/*
+/* 
  * Fast write16 function without the probing check above
  */
 static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
@@ -196,9 +196,8 @@
 		goto Error;
 	}
 
-	info->map.map_priv_1 =
-	    (void __iomem *) ioremap(dev->resource->start,
-				    dev->resource->end - dev->resource->start + 1);
+	info->map.map_priv_1 = ioremap(dev->resource->start,
+			    dev->resource->end - dev->resource->start + 1);
 	if (!info->map.map_priv_1) {
 		printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n");
 		err = -EIO;
@@ -212,7 +211,7 @@
 		goto Error;
 	}
 	info->mtd->owner = THIS_MODULE;
-
+	
 	/* Use the fast version */
 	info->map.write = ixp4xx_write16,
 
diff -Nru a/drivers/mtd/maps/l440gx.c b/drivers/mtd/maps/l440gx.c
--- a/drivers/mtd/maps/l440gx.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/mtd/maps/l440gx.c	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: l440gx.c,v 1.13 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: l440gx.c,v 1.16 2004/11/16 18:29:02 dwmw2 Exp $
  *
  * BIOS Flash chip on Intel 440GX board.
  *
@@ -30,7 +30,7 @@
 
 
 /* Is this really the vpp port? */
-void l440gx_set_vpp(struct map_info *map, int vpp)
+static void l440gx_set_vpp(struct map_info *map, int vpp)
 {
 	unsigned long l;
 
@@ -43,7 +43,7 @@
 	outl(l, VPP_PORT);
 }
 
-struct map_info l440gx_map = {
+static struct map_info l440gx_map = {
 	.name = "L440GX BIOS",
 	.size = WINDOW_SIZE,
 	.bankwidth = BUSWIDTH,
@@ -73,7 +73,7 @@
 		return -ENODEV;
 	}
 
-	l440gx_map.virt = (unsigned long)ioremap_nocache(WINDOW_ADDR, WINDOW_SIZE);
+	l440gx_map.virt = ioremap_nocache(WINDOW_ADDR, WINDOW_SIZE);
 
 	if (!l440gx_map.virt) {
 		printk(KERN_WARNING "Failed to ioremap L440GX flash region\n");
@@ -103,7 +103,7 @@
 		/* Allocate the resource region */
 		if (pci_assign_resource(pm_dev, PIIXE_IOBASE_RESOURCE) != 0) {
 			printk(KERN_WARNING "Could not allocate pm iobase resource\n");
-			iounmap((void *)l440gx_map.virt);
+			iounmap(l440gx_map.virt);
 			return -ENXIO;
 		}
 	}
@@ -137,7 +137,7 @@
 		return 0;
 	}
 
-	iounmap((void *)l440gx_map.virt);
+	iounmap(l440gx_map.virt);
 	return -ENXIO;
 }
 
@@ -146,7 +146,7 @@
 	del_mtd_device(mymtd);
 	map_destroy(mymtd);
 	
-	iounmap((void *)l440gx_map.virt);
+	iounmap(l440gx_map.virt);
 }
 
 module_init(init_l440gx);
diff -Nru a/drivers/mtd/maps/lasat.c b/drivers/mtd/maps/lasat.c
--- a/drivers/mtd/maps/lasat.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/mtd/maps/lasat.c	2004-12-24 13:36:19 -08:00
@@ -7,7 +7,7 @@
  * modify it under the terms of the GNU General Public License version
  * 2 as published by the Free Software Foundation.
  *
- * $Id: lasat.c,v 1.7 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: lasat.c,v 1.9 2004/11/04 13:24:15 gleixner Exp $
  *
  */
 
@@ -50,7 +50,7 @@
 	ENABLE_VPP((&lasat_map));
 
 	lasat_map.phys = lasat_flash_partition_start(LASAT_MTD_BOOTLOADER);
-	lasat_map.virt = (unsigned long)ioremap_nocache(
+	lasat_map.virt = ioremap_nocache(
 		        lasat_map.phys, lasat_board_info.li_flash_size);
 	lasat_map.size = lasat_board_info.li_flash_size;
 
diff -Nru a/drivers/mtd/maps/lubbock-flash.c b/drivers/mtd/maps/lubbock-flash.c
--- a/drivers/mtd/maps/lubbock-flash.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/mtd/maps/lubbock-flash.c	2004-12-24 13:37:02 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: lubbock-flash.c,v 1.18 2004/09/28 18:54:40 nico Exp $
+ * $Id: lubbock-flash.c,v 1.19 2004/11/04 13:24:15 gleixner Exp $
  *
  * Map driver for the Lubbock developer platform.
  *
@@ -84,7 +84,7 @@
 	lubbock_maps[flashboot].name = "Lubbock Boot ROM";
 
 	for (i = 0; i < 2; i++) {
-		lubbock_maps[i].virt = (void __iomem *)ioremap(lubbock_maps[i].phys, WINDOW_SIZE);
+		lubbock_maps[i].virt = ioremap(lubbock_maps[i].phys, WINDOW_SIZE);
 		if (!lubbock_maps[i].virt) {
 			printk(KERN_WARNING "Failed to ioremap %s\n", lubbock_maps[i].name);
 			if (!ret)
diff -Nru a/drivers/mtd/maps/mbx860.c b/drivers/mtd/maps/mbx860.c
--- a/drivers/mtd/maps/mbx860.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/mtd/maps/mbx860.c	2004-12-24 13:36:32 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: mbx860.c,v 1.6 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: mbx860.c,v 1.8 2004/11/04 13:24:15 gleixner Exp $
  *
  * Handle mapping of the flash on MBX860 boards
  *
@@ -60,7 +60,7 @@
 int __init init_mbx(void)
 {
 	printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR);
-	mbx_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
+	mbx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
 
 	if (!mbx_map.virt) {
 		printk("Failed to ioremap\n");
diff -Nru a/drivers/mtd/maps/mpc1211.c b/drivers/mtd/maps/mpc1211.c
--- a/drivers/mtd/maps/mpc1211.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/mtd/maps/mpc1211.c	2004-12-24 13:37:01 -08:00
@@ -1,7 +1,7 @@
 /*
  * Flash on MPC-1211
  *
- * $Id: mpc1211.c,v 1.3 2004/07/14 17:45:40 dwmw2 Exp $
+ * $Id: mpc1211.c,v 1.4 2004/09/16 23:27:13 gleixner Exp $
  *
  * (C) 2002 Interface, Saito.K & Jeanne
  *
@@ -44,7 +44,7 @@
 	int nr_parts;
 
 	mpc1211_flash_map.phys = 0;
-	mpc1211_flash_map.virt = P2SEGADDR(0);
+	mpc1211_flash_map.virt = (void __iomem *)P2SEGADDR(0);
 
 	simple_map_init(&mpc1211_flash_map);
 
diff -Nru a/drivers/mtd/maps/netsc520.c b/drivers/mtd/maps/netsc520.c
--- a/drivers/mtd/maps/netsc520.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/mtd/maps/netsc520.c	2004-12-24 13:37:18 -08:00
@@ -3,7 +3,7 @@
  * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com)
  *	based on sc520cdp.c by Sysgo Real-Time Solutions GmbH
  *
- * $Id: netsc520.c,v 1.10 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: netsc520.c,v 1.12 2004/11/04 13:24:15 gleixner Exp $
  *
  * 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
@@ -95,7 +95,7 @@
 static int __init init_netsc520(void)
 {
 	printk(KERN_NOTICE "NetSc520 flash device: 0x%lx at 0x%lx\n", netsc520_map.size, netsc520_map.phys);
-	netsc520_map.virt = (unsigned long)ioremap_nocache(netsc520_map.phys, netsc520_map.size);
+	netsc520_map.virt = ioremap_nocache(netsc520_map.phys, netsc520_map.size);
 
 	if (!netsc520_map.virt) {
 		printk("Failed to ioremap_nocache\n");
@@ -111,7 +111,7 @@
 		mymtd = do_map_probe("map_rom", &netsc520_map);
 
 	if (!mymtd) {
-		iounmap((void *)netsc520_map.virt);
+		iounmap(netsc520_map.virt);
 		return -ENXIO;
 	}
 		
@@ -127,8 +127,8 @@
 		map_destroy(mymtd);
 	}
 	if (netsc520_map.virt) {
-		iounmap((void *)netsc520_map.virt);
-		netsc520_map.virt = 0;
+		iounmap(netsc520_map.virt);
+		netsc520_map.virt = NULL;
 	}
 }
 
diff -Nru a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
--- a/drivers/mtd/maps/nettel.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/mtd/maps/nettel.c	2004-12-24 13:36:31 -08:00
@@ -6,7 +6,7 @@
  *      (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com)
  *      (C) Copyright 2001-2002, SnapGear (www.snapgear.com)
  *
- *	$Id: nettel.c,v 1.5 2004/07/12 21:59:44 dwmw2 Exp $
+ *	$Id: nettel.c,v 1.8 2004/11/04 13:24:15 gleixner Exp $
  */
 
 /****************************************************************************/
@@ -273,8 +273,7 @@
 	__asm__ ("wbinvd");
 
 	nettel_amd_map.phys = amdaddr;
-	nettel_amd_map.virt = (unsigned long)
-		ioremap_nocache(amdaddr, maxsize);
+	nettel_amd_map.virt = ioremap_nocache(amdaddr, maxsize);
 	if (!nettel_amd_map.virt) {
 		printk("SNAPGEAR: failed to ioremap() BOOTCS\n");
 		return(-EIO);
@@ -472,8 +471,8 @@
 		map_destroy(amd_mtd);
 	}
 	if (nettel_amd_map.virt) {
-		iounmap((void *)nettel_amd_map.virt);
-		nettel_amd_map.virt = 0;
+		iounmap(nettel_amd_map.virt);
+		nettel_amd_map.virt = NULL;
 	}
 #ifdef CONFIG_MTD_CFI_INTELEXT
 	if (intel_mtd) {
diff -Nru a/drivers/mtd/maps/ocelot.c b/drivers/mtd/maps/ocelot.c
--- a/drivers/mtd/maps/ocelot.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/mtd/maps/ocelot.c	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: ocelot.c,v 1.13 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: ocelot.c,v 1.15 2004/11/04 13:24:15 gleixner Exp $
  *
  * Flash on Momenco Ocelot
  */
@@ -81,7 +81,7 @@
 	iounmap(pld);
 
 	/* Now ioremap the NVRAM space */
-	ocelot_nvram_map.virt = (unsigned long)ioremap_nocache(NVRAM_WINDOW_ADDR, NVRAM_WINDOW_SIZE);
+	ocelot_nvram_map.virt = ioremap_nocache(NVRAM_WINDOW_ADDR, NVRAM_WINDOW_SIZE);
 	if (!ocelot_nvram_map.virt) {
 		printk(KERN_NOTICE "Failed to ioremap Ocelot NVRAM space\n");
 		return -EIO;
@@ -101,7 +101,7 @@
 	nvram_mtd->write = ocelot_ram_write;
 
 	/* Now map the flash space */
-	ocelot_flash_map.virt = (unsigned long)ioremap_nocache(FLASH_WINDOW_ADDR, FLASH_WINDOW_SIZE);
+	ocelot_flash_map.virt = ioremap_nocache(FLASH_WINDOW_ADDR, FLASH_WINDOW_SIZE);
 	if (!ocelot_flash_map.virt) {
 		printk(KERN_NOTICE "Failed to ioremap Ocelot flash space\n");
 		goto fail_2;
diff -Nru a/drivers/mtd/maps/ocotea.c b/drivers/mtd/maps/ocotea.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mtd/maps/ocotea.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,154 @@
+/*
+ * Mapping for Ocotea user flash
+ *
+ * Matt Porter <mporter@kernel.crashing.org>
+ *
+ * Copyright 2002-2004 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.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+#include <linux/config.h>
+#include <linux/version.h>
+#include <asm/io.h>
+#include <asm/ibm44x.h>
+#include <platforms/4xx/ocotea.h>
+
+static struct mtd_info *flash;
+
+static struct map_info ocotea_small_map = {
+	.name =		"Ocotea small flash",
+	.size =		OCOTEA_SMALL_FLASH_SIZE,
+	.buswidth =	1,
+};
+
+static struct map_info ocotea_large_map = {
+	.name =		"Ocotea large flash",
+	.size =		OCOTEA_LARGE_FLASH_SIZE,
+	.buswidth =	1,
+};
+
+static struct mtd_partition ocotea_small_partitions[] = {
+	{
+		.name =   "pibs",
+		.offset = 0x0,
+		.size =   0x100000,
+	}
+};
+
+static struct mtd_partition ocotea_large_partitions[] = {
+	{
+		.name =   "fs",
+		.offset = 0,
+		.size =   0x300000,
+	},
+	{
+		.name =   "firmware",
+		.offset = 0x300000,
+		.size =   0x100000,
+	}
+};
+
+#define NB_OF(x)  (sizeof(x)/sizeof(x[0]))
+
+int __init init_ocotea(void)
+{
+	u8 fpga0_reg;
+	u8 *fpga0_adr;
+	unsigned long long small_flash_base, large_flash_base;
+
+	fpga0_adr = ioremap64(OCOTEA_FPGA_ADDR, 16);
+	if (!fpga0_adr)
+		return -ENOMEM;
+
+	fpga0_reg = readb((unsigned long)fpga0_adr);
+	iounmap(fpga0_adr);
+
+	if (OCOTEA_BOOT_LARGE_FLASH(fpga0_reg)) {
+		small_flash_base = OCOTEA_SMALL_FLASH_HIGH;
+		large_flash_base = OCOTEA_LARGE_FLASH_LOW;
+	}
+	else {
+		small_flash_base = OCOTEA_SMALL_FLASH_LOW;
+		large_flash_base = OCOTEA_LARGE_FLASH_HIGH;
+	}
+
+	ocotea_small_map.phys = small_flash_base;
+	ocotea_small_map.virt = ioremap64(small_flash_base,
+					 ocotea_small_map.size);
+
+	if (!ocotea_small_map.virt) {
+		printk("Failed to ioremap flash\n");
+		return -EIO;
+	}
+
+	simple_map_init(&ocotea_small_map);
+
+	flash = do_map_probe("map_rom", &ocotea_small_map);
+	if (flash) {
+		flash->owner = THIS_MODULE;
+		add_mtd_partitions(flash, ocotea_small_partitions,
+					NB_OF(ocotea_small_partitions));
+	} else {
+		printk("map probe failed for flash\n");
+		return -ENXIO;
+	}
+
+	ocotea_large_map.phys = large_flash_base;
+	ocotea_large_map.virt = ioremap64(large_flash_base,
+					 ocotea_large_map.size);
+
+	if (!ocotea_large_map.virt) {
+		printk("Failed to ioremap flash\n");
+		return -EIO;
+	}
+
+	simple_map_init(&ocotea_large_map);
+
+	flash = do_map_probe("cfi_probe", &ocotea_large_map);
+	if (flash) {
+		flash->owner = THIS_MODULE;
+		add_mtd_partitions(flash, ocotea_large_partitions,
+					NB_OF(ocotea_large_partitions));
+	} else {
+		printk("map probe failed for flash\n");
+		return -ENXIO;
+	}
+
+	return 0;
+}
+
+static void __exit cleanup_ocotea(void)
+{
+	if (flash) {
+		del_mtd_partitions(flash);
+		map_destroy(flash);
+	}
+
+	if (ocotea_small_map.virt) {
+		iounmap((void *)ocotea_small_map.virt);
+		ocotea_small_map.virt = 0;
+	}
+
+	if (ocotea_large_map.virt) {
+		iounmap((void *)ocotea_large_map.virt);
+		ocotea_large_map.virt = 0;
+	}
+}
+
+module_init(init_ocotea);
+module_exit(cleanup_ocotea);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Matt Porter <mporter@kernel.crashing.org>");
+MODULE_DESCRIPTION("MTD map and partitions for IBM 440GX Ocotea boards");
diff -Nru a/drivers/mtd/maps/omap-toto-flash.c b/drivers/mtd/maps/omap-toto-flash.c
--- a/drivers/mtd/maps/omap-toto-flash.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/mtd/maps/omap-toto-flash.c	2004-12-24 13:36:31 -08:00
@@ -5,7 +5,7 @@
  *
  *  (C) 2002 MontVista Software, Inc.
  *
- * $Id: omap-toto-flash.c,v 1.2 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: omap-toto-flash.c,v 1.3 2004/09/16 23:27:13 gleixner Exp $
  */
 
 #include <linux/config.h>
@@ -35,7 +35,7 @@
 static struct map_info omap_toto_map_flash = {
 	.name =		"OMAP Toto flash",
 	.bankwidth =	2,
-	.virt =		OMAP_TOTO_FLASH_BASE,
+	.virt =		(void __iomem *)OMAP_TOTO_FLASH_BASE,
 };
 
  
diff -Nru a/drivers/mtd/maps/pb1550-flash.c b/drivers/mtd/maps/pb1550-flash.c
--- a/drivers/mtd/maps/pb1550-flash.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/mtd/maps/pb1550-flash.c	2004-12-24 13:37:00 -08:00
@@ -1,7 +1,7 @@
 /*
  * Flash memory access on Alchemy Pb1550 board
  * 
- * $Id: pb1550-flash.c,v 1.4 2004/07/14 17:45:40 dwmw2 Exp $
+ * $Id: pb1550-flash.c,v 1.6 2004/11/04 13:24:15 gleixner Exp $
  *
  * (C) 2004 Embedded Edge, LLC, based on pb1550-flash.c:
  * (C) 2003 Pete Popov <ppopov@pacbell.net>
@@ -178,8 +178,7 @@
 	 */
 	printk(KERN_NOTICE "Pb1550 flash: probing %d-bit flash bus\n", 
 			pb1550_map.bankwidth*8);
-	pb1550_map.virt = 
-		(unsigned long)ioremap(window_addr, window_size);
+	pb1550_map.virt = ioremap(window_addr, window_size);
 	mymtd = do_map_probe("cfi_probe", &pb1550_map);
 	if (!mymtd) return -ENXIO;
 	mymtd->owner = THIS_MODULE;
diff -Nru a/drivers/mtd/maps/pb1xxx-flash.c b/drivers/mtd/maps/pb1xxx-flash.c
--- a/drivers/mtd/maps/pb1xxx-flash.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/mtd/maps/pb1xxx-flash.c	2004-12-24 13:37:31 -08:00
@@ -3,7 +3,7 @@
  * 
  * (C) 2001 Pete Popov <ppopov@mvista.com>
  * 
- * $Id: pb1xxx-flash.c,v 1.11 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: pb1xxx-flash.c,v 1.14 2004/11/04 13:24:15 gleixner Exp $
  */
 
 #include <linux/config.h>
@@ -17,7 +17,6 @@
 #include <linux/mtd/partitions.h>
 
 #include <asm/io.h>
-#include <asm/au1000.h>
 
 #ifdef 	DEBUG_RW
 #define	DBG(x...)	printk(x)
@@ -150,7 +149,7 @@
 	 */
 	printk(KERN_NOTICE "Pb1xxx flash: probing %d-bit flash bus\n", 
 			BUSWIDTH*8);
-	pb1xxx_mtd_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
+	pb1xxx_mtd_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
 
 	simple_map_init(&pb1xxx_mtd_map);
 
diff -Nru a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c
--- a/drivers/mtd/maps/pci.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/mtd/maps/pci.c	2004-12-24 13:36:47 -08:00
@@ -33,7 +33,7 @@
 
 struct map_pci_info {
 	struct map_info map;
-	void *base;
+	void __iomem *base;
 	void (*exit)(struct pci_dev *dev, struct map_pci_info *map);
 	unsigned long (*translate)(struct map_pci_info *map, unsigned long ofs);
 	struct pci_dev *dev;
@@ -143,7 +143,7 @@
 intel_iq80310_exit(struct pci_dev *dev, struct map_pci_info *map)
 {
 	if (map->base)
-		iounmap((void *)map->base);
+		iounmap(map->base);
 	pci_write_config_dword(dev, 0x44, map->map.map_priv_2);
 }
 
@@ -236,7 +236,7 @@
 	u32 val;
 
 	if (map->base)
-		iounmap((void *)map->base);
+		iounmap(map->base);
 
 	/*
 	 * We need to undo the PCI BAR2/PCI ROM BAR address alteration.
diff -Nru a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
--- a/drivers/mtd/maps/physmap.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/mtd/maps/physmap.c	2004-12-24 13:37:00 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: physmap.c,v 1.34 2004/07/21 00:16:14 jwboyer Exp $
+ * $Id: physmap.c,v 1.36 2004/11/04 13:24:15 gleixner Exp $
  *
  * Normal mappings of chips in physical memory
  *
@@ -51,7 +51,7 @@
 	const char **type;
 
        	printk(KERN_NOTICE "physmap flash device: %lx at %lx\n", physmap_map.size, physmap_map.phys);
-	physmap_map.virt = (unsigned long)ioremap(physmap_map.phys, physmap_map.size);
+	physmap_map.virt = ioremap(physmap_map.phys, physmap_map.size);
 
 	if (!physmap_map.virt) {
 		printk("Failed to ioremap\n");
@@ -92,7 +92,7 @@
 		return 0;
 	}
 
-	iounmap((void *)physmap_map.virt);
+	iounmap(physmap_map.virt);
 	return -ENXIO;
 }
 
@@ -112,8 +112,8 @@
 #endif
 	map_destroy(mymtd);
 
-	iounmap((void *)physmap_map.virt);
-	physmap_map.virt = 0;
+	iounmap(physmap_map.virt);
+	physmap_map.virt = NULL;
 }
 
 module_init(init_physmap);
diff -Nru a/drivers/mtd/maps/pnc2000.c b/drivers/mtd/maps/pnc2000.c
--- a/drivers/mtd/maps/pnc2000.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/mtd/maps/pnc2000.c	2004-12-24 13:36:48 -08:00
@@ -5,7 +5,7 @@
  *
  * This code is GPL
  *
- * $Id: pnc2000.c,v 1.15 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: pnc2000.c,v 1.17 2004/11/16 18:29:02 dwmw2 Exp $
  */
 
 #include <linux/module.h>
@@ -26,12 +26,12 @@
  */
 
 
-struct map_info pnc_map = {
+static struct map_info pnc_map = {
 	.name = "PNC-2000",
 	.size = WINDOW_SIZE,
 	.bankwidth = 4,
 	.phys = 0xFFFFFFFF,
-	.virt = WINDOW_ADDR,
+	.virt = (void __iomem *)WINDOW_ADDR,
 };
 
 
@@ -62,7 +62,7 @@
  */
 static struct mtd_info *mymtd;
 
-int __init init_pnc2000(void)
+static int __init init_pnc2000(void)
 {
 	printk(KERN_NOTICE "Photron PNC-2000 flash mapping: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
 
diff -Nru a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c
--- a/drivers/mtd/maps/redwood.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/mtd/maps/redwood.c	2004-12-24 13:37:02 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: redwood.c,v 1.8 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: redwood.c,v 1.10 2004/11/04 13:24:15 gleixner Exp $
  *
  * drivers/mtd/maps/redwood.c
  *
@@ -131,8 +131,7 @@
 	printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
 			WINDOW_SIZE, WINDOW_ADDR);
 
-	redwood_flash_map.virt =
-		(unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
+	redwood_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
 
 	if (!redwood_flash_map.virt) {
 		printk("init_redwood_flash: failed to ioremap\n");
diff -Nru a/drivers/mtd/maps/rpxlite.c b/drivers/mtd/maps/rpxlite.c
--- a/drivers/mtd/maps/rpxlite.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/mtd/maps/rpxlite.c	2004-12-24 13:37:30 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: rpxlite.c,v 1.20 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: rpxlite.c,v 1.22 2004/11/04 13:24:15 gleixner Exp $
  *
  * Handle mapping of the flash on the RPX Lite and CLLF boards
  */
@@ -28,7 +28,7 @@
 int __init init_rpxlite(void)
 {
 	printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
-	rpxlite_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
+	rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
 
 	if (!rpxlite_map.virt) {
 		printk("Failed to ioremap\n");
diff -Nru a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
--- a/drivers/mtd/maps/sa1100-flash.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/mtd/maps/sa1100-flash.c	2004-12-24 13:36:31 -08:00
@@ -3,9 +3,8 @@
  * 
  * (C) 2000 Nicolas Pitre <nico@cam.org>
  * 
- * $Id: sa1100-flash.c,v 1.39 2004/07/12 21:59:44 dwmw2 Exp $
+ * $Id: sa1100-flash.c,v 1.47 2004/11/01 13:44:36 rmk Exp $
  */
-
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -14,177 +13,24 @@
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/err.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/concat.h>
 
-#include <asm/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/io.h>
 #include <asm/sizes.h>
+#include <asm/mach/flash.h>
 
-#include <asm/arch/h3600.h>
-
-#ifndef CONFIG_ARCH_SA1100
-#error This is for SA1100 architecture only
-#endif
-
+#if 0
 /*
- * This isnt complete yet, so...
+ * This is here for documentation purposes only - until these people
+ * submit their machine types.  It will be gone January 2005.
  */
-#define CONFIG_MTD_SA1100_STATICMAP 1
-
-#ifdef CONFIG_MTD_SA1100_STATICMAP
-/*
- * Here are partition information for all known SA1100-based devices.
- * See include/linux/mtd/partitions.h for definition of the mtd_partition
- * structure.
- *
- * Please note:
- *  1. We no longer support static flash mappings via the machine io_desc
- *     structure.
- *  2. The flash size given should be the largest flash size that can
- *     be accommodated.
- *
- * The MTD layer will detect flash chip aliasing and reduce the size of
- * the map accordingly.
- *
- * Please keep these in alphabetical order, and formatted as per existing
- * entries.  Thanks.
- */
-
-#ifdef CONFIG_SA1100_ADSBITSY
-static struct mtd_partition adsbitsy_partitions[] = {
-	{
-		.name		= "bootROM",
-		.size		= 0x80000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "zImage",
-		.size		= 0x100000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "ramdisk.gz",
-		.size		= 0x300000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "User FS",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
-#endif
-
-#ifdef CONFIG_SA1100_ASSABET
-/* Phase 4 Assabet has two 28F160B3 flash parts in bank 0: */
-static struct mtd_partition assabet4_partitions[] = {
-	{
-		.name		= "bootloader",
-		.size		= 0x00020000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "bootloader params",
-		.size		= 0x00020000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "jffs",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
-
-/* Phase 5 Assabet has two 28F128J3A flash parts in bank 0: */
-static struct mtd_partition assabet5_partitions[] = {
-	{
-		.name		= "bootloader",
-		.size		= 0x00040000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "bootloader params",
-		.size		= 0x00040000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "jffs",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
-
-#define assabet_partitions	assabet5_partitions
-#endif
-
-#ifdef CONFIG_SA1100_BADGE4
-/*
- * 1 x Intel 28F320C3 Advanced+ Boot Block Flash (32 Mi bit)
- *   Eight 4 KiW Parameter Bottom Blocks (64 KiB)
- *   Sixty-three 32 KiW Main Blocks (4032 Ki b)
- *
- * <or>
- *
- * 1 x Intel 28F640C3 Advanced+ Boot Block Flash (64 Mi bit)
- *   Eight 4 KiW Parameter Bottom Blocks (64 KiB)
- *   One-hundred-twenty-seven 32 KiW Main Blocks (8128 Ki b)
- */
-static struct mtd_partition badge4_partitions[] = {
-	{
-		.name		= "BLOB boot loader",
-		.offset		= 0,
-		.size		= 0x0000A000
-	}, {
-		.name		= "params",
-		.offset		= MTDPART_OFS_APPEND,
-		.size		= 0x00006000
-	}, {
-		.name		= "root",
-		.offset		= MTDPART_OFS_APPEND,
-		.size		= MTDPART_SIZ_FULL
-	}
-};
-#endif
-
-
-#ifdef CONFIG_SA1100_CERF
-#ifdef CONFIG_SA1100_CERF_FLASH_32MB
-#  define CERF_FLASH_SIZE	0x02000000
-#elif defined CONFIG_SA1100_CERF_FLASH_16MB
-#  define CERF_FLASH_SIZE	0x01000000
-#elif defined CONFIG_SA1100_CERF_FLASH_8MB
-#  define CERF_FLASH_SIZE	0x00800000
-#else
-#  error "Undefined flash size for CERF in sa1100-flash.c"
-#endif
-
-static struct mtd_partition cerf_partitions[] = {
-	{
-		.name		= "Bootloader",
-		.size		= 0x00020000,
-		.offset		= 0x00000000,
-	}, {
-		.name		= "Params",
-		.size		= 0x00040000,
-		.offset		= 0x00020000,
-	}, {
-		.name		= "Kernel",
-		.size		= 0x00100000,
-		.offset		= 0x00060000,
-	}, {
-		.name		= "Filesystem",
-		.size		= CERF_FLASH_SIZE-0x00160000,
-		.offset		= 0x00160000,
-	}
-};
-#endif
-
-#ifdef CONFIG_SA1100_CONSUS
 static struct mtd_partition consus_partitions[] = {
 	{
 		.name		= "Consus boot firmware",
@@ -219,108 +65,7 @@
 		 .mask_flags	= 0,
 	}
 };
-#endif
 
-#ifdef CONFIG_SA1100_FLEXANET
-/* Flexanet has two 28F128J3A flash parts in bank 0: */
-#define FLEXANET_FLASH_SIZE		0x02000000
-static struct mtd_partition flexanet_partitions[] = {
-	{
-		.name		= "bootloader",
-		.size		= 0x00040000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "bootloader params",
-		.size		= 0x00040000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "kernel",
-		.size		= 0x000C0000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "altkernel",
-		.size		= 0x000C0000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "root",
-		.size		= 0x00400000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "free1",
-		.size		= 0x00300000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "free2",
-		.size		= 0x00300000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}, {
-		.name		= "free3",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,
-	}
-};
-#endif
-
-#ifdef CONFIG_SA1100_FREEBIRD
-static struct mtd_partition freebird_partitions[] = {
-#ifdef CONFIG_SA1100_FREEBIRD_NEW
-	{
-		.name		= "firmware",
-		.size		= 0x00040000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "kernel",
-		.size		= 0x00080000,
-		.offset		= 0x00040000,
-	}, {
-		.name		= "params",
-		.size		= 0x00040000,
-		.offset		= 0x000C0000,
-	}, {
-		.name		= "initrd",
-		.size		= 0x00100000,
-		.offset		= 0x00100000,
-	}, {
-		.name		= "root cramfs",
-		.size		= 0x00300000,
-		.offset		= 0x00200000,
-	}, {
-		.name		= "usr cramfs",
-		.size		= 0x00C00000,
-		.offset		= 0x00500000,
-	}, {
-		.name		= "local",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= 0x01100000,
-	}
-#else
-	{
-		.size		= 0x00040000,
-		.offset		= 0,
-	}, {
-		.size		= 0x000c0000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.size		= 0x00400000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-#endif
-};
-#endif
-
-#ifdef CONFIG_SA1100_FRODO
 /* Frodo has 2 x 16M 28F128J3A flash chips in bank 0: */
 static struct mtd_partition frodo_partitions[] =
 {
@@ -350,1003 +95,358 @@
 		.offset		= MTDPART_OFS_APPEND
 	}
 };
-#endif
-
-#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-static struct mtd_partition graphicsclient_partitions[] = {
-	{
-		.name		= "zImage",
-		.size		= 0x100000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "ramdisk.gz",
-		.size		= 0x300000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "User FS",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
-#endif
 
-#ifdef CONFIG_SA1100_GRAPHICSMASTER
-static struct mtd_partition graphicsmaster_partitions[] = {
+static struct mtd_partition jornada56x_partitions[] = {
 	{
-		.name		= "zImage",
-		.size		= 0x100000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	},
-	{
-		.name		= "ramdisk.gz",
-		.size		= 0x300000,
-		.offset		= MTDPART_OFS_APPEND,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	},
-	{
-		.name		= "User FS",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
-#endif
-
-#ifdef CONFIG_SA1100_H3XXX
-static struct mtd_partition h3xxx_partitions[] = {
-	{
-		.name		= "H3XXX boot firmware",
+		.name		= "bootldr",
 		.size		= 0x00040000,
 		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-#ifdef CONFIG_MTD_2PARTS_IPAQ
-		.name		= "H3XXX root jffs2",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= 0x00040000,
-#else
-		.name		= "H3XXX kernel",
-		.size		= 0x00080000,
-		.offset		= 0x00040000,
-	}, {
-		.name		= "H3XXX params",
-		.size		= 0x00040000,
-		.offset		= 0x000C0000,
-	}, {
-#ifdef CONFIG_JFFS2_FS
-		.name		= "H3XXX root jffs2",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= 0x00100000,
-#else
-		.name		= "H3XXX initrd",
-		.size		= 0x00100000,
-		.offset		= 0x00100000,
-	}, {
-		.name		= "H3XXX root cramfs",
-		.size		= 0x00300000,
-		.offset		= 0x00200000,
-	}, {
-		.name		= "H3XXX usr cramfs",
-		.size		= 0x00800000,
-		.offset		= 0x00500000,
+		.mask_flags	= MTD_WRITEABLE,
 	}, {
-		.name		= "H3XXX usr local",
+		.name		= "rootfs",
 		.size		= MTDPART_SIZ_FULL,
-		.offset		= 0x00d00000,
-#endif
-#endif
+		.offset		= MTDPART_OFS_APPEND,
 	}
 };
 
-static void h3xxx_set_vpp(struct map_info *map, int vpp)
+static void jornada56x_set_vpp(int vpp)
 {
-	assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp);
+	if (vpp)
+		GPSR = GPIO_GPIO26;
+	else
+		GPCR = GPIO_GPIO26;
+	GPDR |= GPIO_GPIO26;
 }
-#else
-#define h3xxx_set_vpp NULL
-#endif
 
-#ifdef CONFIG_SA1100_HACKKIT
-static struct mtd_partition hackkit_partitions[] = {
-	{
-		.name		= "BLOB",
-		.size		= 0x00040000,
-		.offset		= 0x00000000,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "config",
-		.size		= 0x00040000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.name		= "kernel",
-		.size		= 0x00100000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.name		= "initrd",
-		.size		= 0x00180000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.name		= "rootfs",
-		.size		= 0x700000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.name		= "data",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
+/*
+ * Machine        Phys          Size    set_vpp
+ * Consus    : SA1100_CS0_PHYS SZ_32M
+ * Frodo     : SA1100_CS0_PHYS SZ_32M
+ * Jornada56x: SA1100_CS0_PHYS SZ_32M jornada56x_set_vpp
+ */
 #endif
 
-#ifdef CONFIG_SA1100_HUW_WEBPANEL
-static struct mtd_partition huw_webpanel_partitions[] = {
-	{
-		.name		= "Loader",
-		.size		= 0x00040000,
-		.offset		= 0,
-	}, {
-		.name		= "Sector 1",
-		.size		= 0x00040000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
+struct sa_subdev_info {
+	char name[16];
+	struct map_info map;
+	struct mtd_info *mtd;
+	struct flash_platform_data *data;
 };
-#endif
 
-#ifdef CONFIG_SA1100_JORNADA720
-static struct mtd_partition jornada720_partitions[] = {
-	{
-		.name		= "JORNADA720 boot firmware",
-		.size		= 0x00040000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "JORNADA720 kernel",
-		.size		= 0x000c0000,
-		.offset		= 0x00040000,
-	}, {
-		.name		= "JORNADA720 params",
-		.size		= 0x00040000,
-		.offset		= 0x00100000,
-	}, {
-		.name		= "JORNADA720 initrd",
-		.size		= 0x00100000,
-		.offset		= 0x00140000,
-	}, {
-		.name		= "JORNADA720 root cramfs",
-		.size		= 0x00300000,
-		.offset		= 0x00240000,
-	}, {
-		.name		= "JORNADA720 usr cramfs",
-		.size		= 0x00800000,
-		.offset		= 0x00540000,
-	}, {
-		.name		= "JORNADA720 usr local",
-		.size		= 0,  /* will expand to the end of the flash */
-		.offset		= 0x00d00000,
-	}
+struct sa_info {
+	struct mtd_partition	*parts;
+	struct mtd_info		*mtd;
+	int			num_subdev;
+	struct sa_subdev_info	subdev[0];
 };
 
-static void jornada720_set_vpp(struct map_info *map, int vpp)
+static void sa1100_set_vpp(struct map_info *map, int on)
 {
-	if (vpp)
-		PPSR |= 0x80;
-	else
-		PPSR &= ~0x80;
-	PPDR |= 0x80;
+	struct sa_subdev_info *subdev = container_of(map, struct sa_subdev_info, map);
+	subdev->data->set_vpp(on);
 }
-#else
-#define jornada720_set_vpp NULL
-#endif
 
-#ifdef CONFIG_SA1100_PANGOLIN
-static struct mtd_partition pangolin_partitions[] = {
-	{
-		.name		= "boot firmware",
-		.size		= 0x00080000,
-		.offset		= 0x00000000,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "kernel",
-		.size		= 0x00100000,
-		.offset		= 0x00080000,
-	}, {
-		.name		= "initrd",
-		.size		= 0x00280000,
-		.offset		= 0x00180000,
-	}, {
-		.name		= "initrd-test",
-		.size		= 0x03C00000,
-		.offset		= 0x00400000,
-	}
-};
-#endif
-
-#ifdef CONFIG_SA1100_PT_SYSTEM3
-/* erase size is 0x40000 == 256k partitions have to have this boundary */
-static struct mtd_partition system3_partitions[] = {
-	{
-		.name		= "BLOB",
-		.size		= 0x00040000,
-		.offset		= 0x00000000,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "config",
-		.size		= 0x00040000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.name		= "kernel",
-		.size		= 0x00100000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.name		= "root",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
-#endif
+static void sa1100_destroy_subdev(struct sa_subdev_info *subdev)
+{
+	if (subdev->mtd)
+		map_destroy(subdev->mtd);
+	if (subdev->map.virt)
+		iounmap(subdev->map.virt);
+	release_mem_region(subdev->map.phys, subdev->map.size);
+}
 
-#ifdef CONFIG_SA1100_SHANNON
-static struct mtd_partition shannon_partitions[] = {
-	{
-		.name		= "BLOB boot loader",
-		.offset		= 0,
-		.size		= 0x20000
-	},
-	{
-		.name		= "kernel",
-		.offset		= MTDPART_OFS_APPEND,
-		.size		= 0xe0000
-	},
-	{ 
-		.name		= "initrd",
-		.offset		= MTDPART_OFS_APPEND,	
-		.size		= MTDPART_SIZ_FULL
-	}
-};
+static int sa1100_probe_subdev(struct sa_subdev_info *subdev, struct resource *res)
+{
+	unsigned long phys;
+	unsigned int size;
+	int ret;
 
-#endif
+	phys = res->start;
+	size = res->end - phys + 1;
 
-#ifdef CONFIG_SA1100_SHERMAN
-static struct mtd_partition sherman_partitions[] = {
-	{
-		.size		= 0x50000,
-		.offset		= 0,
-	}, {
-		.size		= 0x70000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.size		= 0x600000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.size		= 0xA0000,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
-#endif
+	/*
+	 * Retrieve the bankwidth from the MSC registers.
+	 * We currently only implement CS0 and CS1 here.
+	 */
+	switch (phys) {
+	default:
+		printk(KERN_WARNING "SA1100 flash: unknown base address "
+		       "0x%08lx, assuming CS0\n", phys);
 
-#ifdef CONFIG_SA1100_SIMPAD
-static struct mtd_partition simpad_partitions[] = {
-	{
-		.name		= "SIMpad boot firmware",
-		.size		= 0x00080000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "SIMpad kernel",
-		.size		= 0x00100000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-#ifdef CONFIG_ROOT_CRAMFS
-		.name		= "SIMpad root cramfs",
-		.size	     	=0x00D80000,
-		.offset		= MTDPART_OFS_APPEND
+	case SA1100_CS0_PHYS:
+		subdev->map.bankwidth = (MSC0 & MSC_RBW) ? 2 : 4;
+		break;
 
-	}, {
-		.name		= "SIMpad local jffs2",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND
-#else
-		.name		= "SIMpad root jffs2",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND
-#endif
+	case SA1100_CS1_PHYS:
+		subdev->map.bankwidth = ((MSC0 >> 16) & MSC_RBW) ? 2 : 4;
+		break;
 	}
-};
-#endif /* CONFIG_SA1100_SIMPAD */
 
-#ifdef CONFIG_SA1100_STORK
-static struct mtd_partition stork_partitions[] = {
-	{
-		.name		= "STORK boot firmware",
-		.size		= 0x00040000,
-		.offset		= 0,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "STORK params",
-		.size		= 0x00040000,
-		.offset		= 0x00040000,
-	}, {
-		.name		= "STORK kernel",
-		.size		= 0x00100000,
-		.offset		= 0x00080000,
-	}, {
-#ifdef CONFIG_JFFS2_FS
-		.name		= "STORK root jffs2",
-		.offset		= 0x00180000,
-		.size		= MTDPART_SIZ_FULL,
-#else
-		.name		= "STORK initrd",
-		.size		= 0x00100000,
-		.offset		= 0x00180000,
-	}, {
-		.name		= "STORK root cramfs",
-		.size		= 0x00300000,
-		.offset		= 0x00280000,
-	}, {
-		.name		= "STORK usr cramfs",
-		.size		= 0x00800000,
-		.offset		= 0x00580000,
-	}, {
-		.name		= "STORK usr local",
-		.offset		= 0x00d80000,
-		.size		= MTDPART_SIZ_FULL,
-#endif
+	if (!request_mem_region(phys, size, subdev->name)) {
+		ret = -EBUSY;
+		goto out;
 	}
-};
-#endif
 
-#ifdef CONFIG_SA1100_TRIZEPS
-static struct mtd_partition trizeps_partitions[] = {
-	{
-		.name		= "Bootloader",
-		.size		= 0x00100000,
-		.offset		= 0,
-	}, {
-		.name		= "Kernel",
-		.size		= 0x00100000,
-		.offset		= MTDPART_OFS_APPEND,
-	}, {
-		.name		= "root",
-		.size		= MTDPART_SIZ_FULL,
-		.offset		= MTDPART_OFS_APPEND,
-	}
-};
-#endif
+	if (subdev->data->set_vpp)
+		subdev->map.set_vpp = sa1100_set_vpp;
 
-#ifdef CONFIG_SA1100_YOPY
-static struct mtd_partition yopy_partitions[] = {
-	{
-		.name		= "boot firmware",
-		.size		= 0x00040000,
-		.offset		= 0x00000000,
-		.mask_flags	= MTD_WRITEABLE,  /* force read-only */
-	}, {
-		.name		= "kernel",
-		.size		= 0x00080000,
-		.offset		= 0x00080000,
-	}, {
-		.name		= "initrd",
-		.size		= 0x00300000,
-		.offset		= 0x00100000,
-	}, {
-		.name		= "root",
-		.size		= 0x01000000,
-		.offset		= 0x00400000,
+	subdev->map.phys = phys;
+	subdev->map.size = size;
+	subdev->map.virt = ioremap(phys, size);
+	if (!subdev->map.virt) {
+		ret = -ENOMEM;
+		goto err;
 	}
-};
-#endif
 
-static int __init sa1100_static_partitions(struct mtd_partition **parts)
+	simple_map_init(&subdev->map);
+
+	/*
+	 * Now let's probe for the actual flash.  Do it here since
+	 * specific machine settings might have been set above.
+	 */
+	subdev->mtd = do_map_probe(subdev->data->map_name, &subdev->map);
+	if (subdev->mtd == NULL) {
+		ret = -ENXIO;
+		goto err;
+	}
+	subdev->mtd->owner = THIS_MODULE;
+
+	printk(KERN_INFO "SA1100 flash: CFI device at 0x%08lx, %dMiB, "
+		"%d-bit\n", phys, subdev->mtd->size >> 20,
+		subdev->map.bankwidth * 8);
+
+	return 0;
+
+ err:
+	sa1100_destroy_subdev(subdev);
+ out:
+	return ret;
+}
+
+static void sa1100_destroy(struct sa_info *info)
 {
-	int nb_parts = 0;
+	int i;
 
-#ifdef CONFIG_SA1100_ADSBITSY
-	if (machine_is_adsbitsy()) {
-		*parts       = adsbitsy_partitions;
-		nb_parts     = ARRAY_SIZE(adsbitsy_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_ASSABET
-	if (machine_is_assabet()) {
-		*parts       = assabet_partitions;
-		nb_parts     = ARRAY_SIZE(assabet_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_BADGE4
-	if (machine_is_badge4()) {
-		*parts       = badge4_partitions;
-		nb_parts     = ARRAY_SIZE(badge4_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_CERF
-	if (machine_is_cerf()) {
-		*parts       = cerf_partitions;
-		nb_parts     = ARRAY_SIZE(cerf_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_CONSUS
-	if (machine_is_consus()) {
-		*parts       = consus_partitions;
-		nb_parts     = ARRAY_SIZE(consus_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_FLEXANET
-	if (machine_is_flexanet()) {
-		*parts       = flexanet_partitions;
-		nb_parts     = ARRAY_SIZE(flexanet_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_FREEBIRD
-	if (machine_is_freebird()) {
-		*parts       = freebird_partitions;
-		nb_parts     = ARRAY_SIZE(freebird_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_FRODO
-	if (machine_is_frodo()) {
-		*parts       = frodo_partitions;
-		nb_parts     = ARRAY_SIZE(frodo_partitions);
-	}
-#endif	
-#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-	if (machine_is_graphicsclient()) {
-		*parts       = graphicsclient_partitions;
-		nb_parts     = ARRAY_SIZE(graphicsclient_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_GRAPHICSMASTER
-	if (machine_is_graphicsmaster()) {
-		*parts       = graphicsmaster_partitions;
-		nb_parts     = ARRAY_SIZE(graphicsmaster_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_H3XXX
-	if (machine_is_h3xxx()) {
-		*parts       = h3xxx_partitions;
-		nb_parts     = ARRAY_SIZE(h3xxx_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_HACKKIT
-	if (machine_is_hackkit()) {
-		*parts = hackkit_partitions;
-		nb_parts = ARRAY_SIZE(hackkit_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_HUW_WEBPANEL
-	if (machine_is_huw_webpanel()) {
-		*parts       = huw_webpanel_partitions;
-		nb_parts     = ARRAY_SIZE(huw_webpanel_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_JORNADA720
-	if (machine_is_jornada720()) {
-		*parts       = jornada720_partitions;
-		nb_parts     = ARRAY_SIZE(jornada720_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_PANGOLIN
-	if (machine_is_pangolin()) {
-		*parts       = pangolin_partitions;
-		nb_parts     = ARRAY_SIZE(pangolin_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_PT_SYSTEM3
-	if (machine_is_pt_system3()) {
-		*parts       = system3_partitions;
-		nb_parts     = ARRAY_SIZE(system3_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_SHANNON
-	if (machine_is_shannon()) {
-		*parts       = shannon_partitions;
-		nb_parts     = ARRAY_SIZE(shannon_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_SHERMAN
-	if (machine_is_sherman()) {
-		*parts       = sherman_partitions;
-		nb_parts     = ARRAY_SIZE(sherman_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_SIMPAD
-	if (machine_is_simpad()) {
-		*parts       = simpad_partitions;
-		nb_parts     = ARRAY_SIZE(simpad_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_STORK
-	if (machine_is_stork()) {
-		*parts       = stork_partitions;
-		nb_parts     = ARRAY_SIZE(stork_partitions);
-	}
-#endif
-#ifdef CONFIG_SA1100_TRIZEPS
-	if (machine_is_trizeps()) {
-		*parts       = trizeps_partitions;
-		nb_parts     = ARRAY_SIZE(trizeps_partitions);
-	}
+	if (info->mtd) {
+		del_mtd_partitions(info->mtd);
+
+#ifdef CONFIG_MTD_CONCAT
+		if (info->mtd != info->subdev[0].mtd)
+			mtd_concat_destroy(info->mtd);
 #endif
-#ifdef CONFIG_SA1100_YOPY
-	if (machine_is_yopy()) {
-		*parts       = yopy_partitions;
-		nb_parts     = ARRAY_SIZE(yopy_partitions);
 	}
-#endif
 
-	return nb_parts;
+	if (info->parts)
+		kfree(info->parts);
+
+	for (i = info->num_subdev - 1; i >= 0; i--)
+		sa1100_destroy_subdev(&info->subdev[i]);
+	kfree(info);
 }
-#endif
 
-struct sa_info {
-	unsigned long base;
-	unsigned long size;
-	int width;
-	void __iomem *vbase;
-        void (*set_vpp)(struct map_info *, int);
-	struct map_info *map;
-	struct mtd_info *mtd;
-	struct resource *res;
-};
+static struct sa_info *__init
+sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *flash)
+{
+	struct sa_info *info;
+	int nr, size, i, ret = 0;
 
-#define NR_SUBMTD 4
+	/*
+	 * Count number of devices.
+	 */
+	for (nr = 0; ; nr++)
+		if (!platform_get_resource(pdev, IORESOURCE_MEM, nr))
+			break;
 
-static struct sa_info info[NR_SUBMTD];
+	if (nr == 0) {
+		ret = -ENODEV;
+		goto out;
+	}
 
-static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info **rmtd)
-{
-	struct mtd_info *subdev[nr];
-	struct map_info *maps;
-	int i, found = 0, ret = 0;
+	size = sizeof(struct sa_info) + sizeof(struct sa_subdev_info) * nr;
 
 	/*
 	 * Allocate the map_info structs in one go.
 	 */
-	maps = kmalloc(sizeof(struct map_info) * nr, GFP_KERNEL);
-	if (!maps)
-		return -ENOMEM;
+	info = kmalloc(size, GFP_KERNEL);
+	if (!info) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
-	memset(maps, 0, sizeof(struct map_info) * nr);
+	memset(info, 0, size);
 
 	/*
 	 * Claim and then map the memory regions.
 	 */
 	for (i = 0; i < nr; i++) {
-		if (sa[i].base == (unsigned long)-1)
-			break;
+		struct sa_subdev_info *subdev = &info->subdev[i];
+		struct resource *res;
 
-		sa[i].res = request_mem_region(sa[i].base, sa[i].size, "sa1100 flash");
-		if (!sa[i].res) {
-			ret = -EBUSY;
+		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
+		if (!res)
 			break;
-		}
 
-		sa[i].map = maps + i;
+		subdev->map.name = subdev->name;
+		sprintf(subdev->name, "sa1100-%d", i);
+		subdev->data = flash;
 
-		sa[i].vbase = ioremap(sa[i].base, sa[i].size);
-		if (!sa[i].vbase) {
-			ret = -ENOMEM;
+		ret = sa1100_probe_subdev(subdev, res);
+		if (ret)
 			break;
-		}
-
-		sa[i].map->virt = sa[i].vbase;
-		sa[i].map->phys = sa[i].base;
-		sa[i].map->set_vpp = sa[i].set_vpp;
-		sa[i].map->bankwidth = sa[i].width;
-		sa[i].map->size = sa[i].size;
-
-		simple_map_init(sa[i].map);
-
-		/*
-		 * Now let's probe for the actual flash.  Do it here since
-		 * specific machine settings might have been set above.
-		 */
-		sa[i].mtd = do_map_probe("cfi_probe", sa[i].map);
-		if (sa[i].mtd == NULL) {
-			ret = -ENXIO;
-			break;
-		}
-		sa[i].mtd->owner = THIS_MODULE;
-		subdev[i] = sa[i].mtd;
-
-		printk(KERN_INFO "SA1100 flash: CFI device at 0x%08lx, %dMiB, "
-			"%d-bit\n", sa[i].base, sa[i].mtd->size >> 20,
-			sa[i].width * 8);
-		found += 1;
 	}
 
+	info->num_subdev = i;
+
 	/*
-	 * ENXIO is special.  It means we didn't find a chip when
-	 * we probed.  We need to tear down the mapping, free the
-	 * resource and mark it as such.
+	 * ENXIO is special.  It means we didn't find a chip when we probed.
 	 */
-	if (ret == -ENXIO) {
-		iounmap(sa[i].vbase);
-		sa[i].vbase = NULL;
-		release_resource(sa[i].res);
-		sa[i].res = NULL;
-	}
+	if (ret != 0 && !(ret == -ENXIO && info->num_subdev > 0))
+		goto err;
 
 	/*
-	 * If we found one device, don't bother with concat support.
-	 * If we found multiple devices, use concat if we have it
-	 * available, otherwise fail.
+	 * If we found one device, don't bother with concat support.  If
+	 * we found multiple devices, use concat if we have it available,
+	 * otherwise fail.  Either way, it'll be called "sa1100".
 	 */
-	if (ret == 0 || ret == -ENXIO) {
-		if (found == 1) {
-			*rmtd = subdev[0];
-			ret = 0;
-		} else if (found > 1) {
-			/*
-			 * We detected multiple devices.  Concatenate
-			 * them together.
-			 */
+	if (info->num_subdev == 1) {
+		strcpy(info->subdev[0].name, "sa1100");
+		info->mtd = info->subdev[0].mtd;
+		ret = 0;
+	} else if (info->num_subdev > 1) {
 #ifdef CONFIG_MTD_CONCAT
-			*rmtd = mtd_concat_create(subdev, found,
-						  "sa1100 flash");
-			if (*rmtd == NULL)
-				ret = -ENXIO;
-#else
-			printk(KERN_ERR "SA1100 flash: multiple devices "
-			       "found but MTD concat support disabled.\n");
+		struct mtd_info *cdev[nr];
+		/*
+		 * We detected multiple devices.  Concatenate them together.
+		 */
+		for (i = 0; i < info->num_subdev; i++)
+			cdev[i] = info->subdev[i].mtd;
+
+		info->mtd = mtd_concat_create(cdev, info->num_subdev,
+					      "sa1100");
+		if (info->mtd == NULL)
 			ret = -ENXIO;
+#else
+		printk(KERN_ERR "SA1100 flash: multiple devices "
+		       "found but MTD concat support disabled.\n");
+		ret = -ENXIO;
 #endif
-		}
 	}
 
-	/*
-	 * If we failed, clean up.
-	 */
-	if (ret) {
-		do {
-			if (sa[i].mtd)
-				map_destroy(sa[i].mtd);
-			if (sa[i].vbase)
-				iounmap(sa[i].vbase);
-			if (sa[i].res)
-				release_resource(sa[i].res);
-		} while (i--);
-
-		kfree(maps);
-	}
-
-	return ret;
-}
-
-static void __exit sa1100_destroy_mtd(struct sa_info *sa, struct mtd_info *mtd)
-{
-	int i;
-
-	del_mtd_partitions(mtd);
-
-#ifdef CONFIG_MTD_CONCAT
-	if (mtd != sa[0].mtd)
-		mtd_concat_destroy(mtd);
-#endif
+	if (ret == 0)
+		return info;
 
-	for (i = NR_SUBMTD; i >= 0; i--) {
-		if (sa[i].mtd)
-			map_destroy(sa[i].mtd);
-		if (sa[i].vbase)
-			iounmap(sa[i].vbase);
-		if (sa[i].res)
-			release_resource(sa[i].res);
-	}
-	kfree(sa[0].map);
+ err:
+	sa1100_destroy(info);
+ out:
+	return ERR_PTR(ret);
 }
 
-/*
- * A Thought: can we automatically detect the flash?
- *  - Check to see if the region is busy (yes -> failure)
- *  - Is the MSC setup for flash (no -> failure)
- *  - Probe for flash
- */
+static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
 
-static struct map_info sa1100_probe_map __initdata = {
-	.name		= "SA1100-flash",
-};
-
-static void __init sa1100_probe_one_cs(unsigned int msc, unsigned long phys)
-{
-	struct mtd_info *mtd;
-
-	printk(KERN_INFO "* Probing 0x%08lx: MSC = 0x%04x %d bit ",
-		phys, msc & 0xffff, msc & MSC_RBW ? 16 : 32);
-
-	if (check_mem_region(phys, 0x08000000)) {
-		printk("busy\n");
-		return;
-	}
-
-	if ((msc & 3) == 1) {
-		printk("wrong type\n");
-		return;
-	}
-
-	sa1100_probe_map.bankwidth = msc & MSC_RBW ? 2 : 4;
-	sa1100_probe_map.size = SZ_1M;
-	sa1100_probe_map.phys = phys;
-	sa1100_probe_map.virt = (unsigned long)ioremap(phys, SZ_1M);
-	if (sa1100_probe_map.virt == 0)
-		goto fail;
-	simple_map_init(&sa1100_probe_map);
-
-	/* Shame cfi_probe blurts out kernel messages... */
-	mtd = do_map_probe("cfi_probe", &sa1100_probe_map);
-	if (mtd)
-		map_destroy(mtd);
-	iounmap((void *)sa1100_probe_map.virt);
-
-	if (!mtd)
-		goto fail;
-
-	printk("pass\n");
-	return;
-
- fail:
-	printk("failed\n");
-}
-
-static void __init sa1100_probe_flash(void)
+static int __init sa1100_mtd_probe(struct device *dev)
 {
-	printk(KERN_INFO "-- SA11xx Flash probe.  Please report results.\n");
-	sa1100_probe_one_cs(MSC0, SA1100_CS0_PHYS);
-	sa1100_probe_one_cs(MSC0 >> 16, SA1100_CS1_PHYS);
-	sa1100_probe_one_cs(MSC1, SA1100_CS2_PHYS);
-	sa1100_probe_one_cs(MSC1 >> 16, SA1100_CS3_PHYS);
-	sa1100_probe_one_cs(MSC2, SA1100_CS4_PHYS);
-	sa1100_probe_one_cs(MSC2 >> 16, SA1100_CS5_PHYS);
-	printk(KERN_INFO "-- SA11xx Flash probe complete.\n");
-}
-
-static int __init sa1100_locate_flash(void)
-{
-	int i, nr = -ENODEV;
+	struct platform_device *pdev = to_platform_device(dev);
+	struct flash_platform_data *flash = pdev->dev.platform_data;
+	struct mtd_partition *parts;
+	const char *part_type = NULL;
+	struct sa_info *info;
+	int err, nr_parts = 0;
 
-	sa1100_probe_flash();
+	if (!flash)
+		return -ENODEV;
 
-	if (machine_is_adsbitsy()) {
-		info[0].base = SA1100_CS1_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_assabet()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		info[1].base = SA1100_CS1_PHYS; /* neponset */
-		info[1].size = SZ_32M;
-		nr = 2;
-	}
-	if (machine_is_badge4()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_64M;
-		nr = 1;
-	}
-	if (machine_is_cerf()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_consus()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_flexanet()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_freebird()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_frodo()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_graphicsclient()) {
-		info[0].base = SA1100_CS1_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_graphicsmaster()) {
-		info[0].base = SA1100_CS1_PHYS;
-		info[0].size = SZ_16M;
-		nr = 1;
-	}
-	if (machine_is_h3xxx()) {
-		info[0].set_vpp = h3xxx_set_vpp;
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_huw_webpanel()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_16M;
-		nr = 1;
-	}
-	if (machine_is_itsy()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_jornada720()) {
-		info[0].set_vpp = jornada720_set_vpp;
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_nanoengine()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[1].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_pangolin()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_64M;
-		nr = 1;
-	}
-	if (machine_is_pfs168()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_pleb()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_4M;
-		info[1].base = SA1100_CS1_PHYS;
-		info[1].size = SZ_4M;
-		nr = 2;
-	}
-	if (machine_is_pt_system3()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_16M;
-		nr = 1;
-	}
-	if (machine_is_shannon()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_4M;
-		nr = 1;
-	}
-	if (machine_is_sherman()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_simpad()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_16M;
-		info[1].base = SA1100_CS1_PHYS;
-		info[1].size = SZ_16M;
-		nr = 2;
-	}
-	if (machine_is_stork()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_32M;
-		nr = 1;
-	}
-	if (machine_is_trizeps()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_16M;
-		nr = 1;
-	}
-	if (machine_is_victor()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_2M;
-		nr = 1;
-	}
-	if (machine_is_yopy()) {
-		info[0].base = SA1100_CS0_PHYS;
-		info[0].size = SZ_64M;
-		info[1].base = SA1100_CS1_PHYS;
-		info[1].size = SZ_64M;
-		nr = 2;
+	info = sa1100_setup_mtd(pdev, flash);
+	if (IS_ERR(info)) {
+		err = PTR_ERR(info);
+		goto out;
 	}
 
-	if (nr < 0)
-		return nr;
-
 	/*
-	 * Retrieve the bankwidth from the MSC registers.
-	 * We currently only implement CS0 and CS1 here.
+	 * Partition selection stuff.
 	 */
-	for (i = 0; i < nr; i++) {
-		switch (info[i].base) {
-		default:
-			printk(KERN_WARNING "SA1100 flash: unknown base address "
-				"0x%08lx, assuming CS0\n", info[i].base);
-		case SA1100_CS0_PHYS:
-			info[i].width = (MSC0 & MSC_RBW) ? 2 : 4;
-			break;
-
-		case SA1100_CS1_PHYS:
-			info[i].width = ((MSC0 >> 16) & MSC_RBW) ? 2 : 4;
-			break;
-		}
-	}
-
-	return nr;
-}
-
-static struct mtd_partition *parsed_parts;
-const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
-
-static void __init sa1100_locate_partitions(struct mtd_info *mtd)
-{
-	const char *part_type = NULL;
-	int nr_parts = 0;
-
-	do {
-		/*
-		 * Partition selection stuff.
-		 */
 #ifdef CONFIG_MTD_PARTITIONS
-		nr_parts = parse_mtd_partitions(mtd, part_probes, &parsed_parts, 0);
-		if (nr_parts > 0) {
-			part_type = "dynamic";
-			break;
-		}
-#endif
-#ifdef CONFIG_MTD_SA1100_STATICMAP
-		nr_parts = sa1100_static_partitions(&parsed_parts);
-		if (nr_parts > 0) {
-			part_type = "static";
-			break;
-		}
+	nr_parts = parse_mtd_partitions(info->mtd, part_probes, &parts, 0);
+	if (nr_parts > 0) {
+		info->parts = parts;
+		part_type = "dynamic";
+	} else
 #endif
-	} while (0);
+	{
+		parts = flash->parts;
+		nr_parts = flash->nr_parts;
+		part_type = "static";
+	}
 
 	if (nr_parts == 0) {
 		printk(KERN_NOTICE "SA1100 flash: no partition info "
 			"available, registering whole flash\n");
-		add_mtd_device(mtd);
+		add_mtd_device(info->mtd);
 	} else {
 		printk(KERN_NOTICE "SA1100 flash: using %s partition "
 			"definition\n", part_type);
-		add_mtd_partitions(mtd, parsed_parts, nr_parts);
+		add_mtd_partitions(info->mtd, parts, nr_parts);
 	}
 
-	/* Always succeeds. */
+	dev_set_drvdata(dev, info);
+	err = 0;
+
+ out:
+	return err;
 }
 
-static void __exit sa1100_destroy_partitions(void)
+static int __exit sa1100_mtd_remove(struct device *dev)
 {
-	if (parsed_parts)
-		kfree(parsed_parts);
+	struct sa_info *info = dev_get_drvdata(dev);
+	dev_set_drvdata(dev, NULL);
+	sa1100_destroy(info);
+	return 0;
 }
 
-static struct mtd_info *mymtd;
-
-static int __init sa1100_mtd_init(void)
+#ifdef CONFIG_PM
+static int sa1100_mtd_suspend(struct device *dev, u32 state, u32 level)
 {
-	int ret;
-	int nr;
-
-	nr = sa1100_locate_flash();
-	if (nr < 0)
-		return nr;
+	struct sa_info *info = dev_get_drvdata(dev);
+	int ret = 0;
 
-	ret = sa1100_setup_mtd(info, nr, &mymtd);
-	if (ret == 0)
-		sa1100_locate_partitions(mymtd);
+	if (info && level == SUSPEND_SAVE_STATE)
+		ret = info->mtd->suspend(info->mtd);
 
 	return ret;
 }
 
-static void __exit sa1100_mtd_cleanup(void)
+static int sa1100_mtd_resume(struct device *dev, u32 level)
+{
+	struct sa_info *info = dev_get_drvdata(dev);
+	if (info && level == RESUME_RESTORE_STATE)
+		info->mtd->resume(info->mtd);
+	return 0;
+}
+#else
+#define sa1100_mtd_suspend NULL
+#define sa1100_mtd_resume  NULL
+#endif
+
+static struct device_driver sa1100_mtd_driver = {
+	.name		= "flash",
+	.bus		= &platform_bus_type,
+	.probe		= sa1100_mtd_probe,
+	.remove		= __exit_p(sa1100_mtd_remove),
+	.suspend	= sa1100_mtd_suspend,
+	.resume		= sa1100_mtd_resume,
+};
+
+static int __init sa1100_mtd_init(void)
+{
+	return driver_register(&sa1100_mtd_driver);
+}
+
+static void __exit sa1100_mtd_exit(void)
 {
-	sa1100_destroy_mtd(info, mymtd);
-	sa1100_destroy_partitions();
+	driver_unregister(&sa1100_mtd_driver);
 }
 
 module_init(sa1100_mtd_init);
-module_exit(sa1100_mtd_cleanup);
+module_exit(sa1100_mtd_exit);
 
 MODULE_AUTHOR("Nicolas Pitre");
 MODULE_DESCRIPTION("SA1100 CFI map driver");
diff -Nru a/drivers/mtd/maps/sbc_gxx.c b/drivers/mtd/maps/sbc_gxx.c
--- a/drivers/mtd/maps/sbc_gxx.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/mtd/maps/sbc_gxx.c	2004-12-24 13:37:00 -08:00
@@ -17,7 +17,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
-   $Id: sbc_gxx.c,v 1.29 2004/07/12 22:38:29 dwmw2 Exp $
+   $Id: sbc_gxx.c,v 1.32 2004/11/16 18:29:02 dwmw2 Exp $
 
 The SBC-MediaGX / SBC-GXx has up to 16 MiB of 
 Intel StrataFlash (28F320/28F640) in x8 mode.  
@@ -84,7 +84,7 @@
 // Globals
 
 static volatile int page_in_window = -1; // Current page in window.
-static unsigned long iomapadr;
+static void __iomem *iomapadr;
 static spinlock_t sbc_gxx_spin = SPIN_LOCK_UNLOCKED;
 
 /* partition_info gives details on the logical partitions that the split the 
@@ -189,13 +189,13 @@
 		map_destroy( all_mtd );
 	}
 
-	iounmap((void *)iomapadr);
+	iounmap(iomapadr);
 	release_region(PAGE_IO,PAGE_IO_SIZE);
 }
 
-int __init init_sbc_gxx(void)
+static int __init init_sbc_gxx(void)
 {
-  	iomapadr = (unsigned long)ioremap(WINDOW_START, WINDOW_LENGTH);
+  	iomapadr = ioremap(WINDOW_START, WINDOW_LENGTH);
 	if (!iomapadr) {
 		printk( KERN_ERR"%s: failed to ioremap memory region\n",
 			sbc_gxx_map.name );
@@ -206,7 +206,7 @@
 		printk( KERN_ERR"%s: IO ports 0x%x-0x%x in use\n",
 			sbc_gxx_map.name,
 			PAGE_IO, PAGE_IO+PAGE_IO_SIZE-1 );
-		iounmap((void *)iomapadr);
+		iounmap(iomapadr);
 		return -EAGAIN;
 	}
 		
diff -Nru a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c
--- a/drivers/mtd/maps/sc520cdp.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/mtd/maps/sc520cdp.c	2004-12-24 13:37:19 -08:00
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *
- * $Id: sc520cdp.c,v 1.16 2004/07/12 21:59:45 dwmw2 Exp $
+ * $Id: sc520cdp.c,v 1.18 2004/11/04 13:24:15 gleixner Exp $
  *
  *
  * The SC520CDP is an evaluation board for the Elan SC520 processor available
@@ -186,12 +186,12 @@
 
 static void sc520cdp_setup_par(void)
 {
-	volatile unsigned long *mmcr;
+	volatile unsigned long __iomem *mmcr;
 	unsigned long mmcr_val;
 	int i, j;
 
 	/* map in SC520's MMCR area */
-	mmcr = (unsigned long *)ioremap_nocache(SC520_MMCR_BASE, SC520_MMCR_EXTENT);
+	mmcr = ioremap_nocache(SC520_MMCR_BASE, SC520_MMCR_EXTENT);
 	if(!mmcr) { /* ioremap_nocache failed: skip the PAR reprogramming */
 		/* force physical address fields to BIOS defaults: */
 		for(i = 0; i < NUM_FLASH_BANKS; i++)
@@ -223,7 +223,7 @@
 			sc520cdp_map[i].phys = par_table[i].default_address;
 		}
 	}
-	iounmap((void *)mmcr);
+	iounmap(mmcr);
 }
 #endif
 
@@ -241,7 +241,7 @@
 		printk(KERN_NOTICE "SC520 CDP flash device: 0x%lx at 0x%lx\n",
 		       sc520cdp_map[i].size, sc520cdp_map[i].phys);
 
-		sc520cdp_map[i].virt = (unsigned long)ioremap_nocache(sc520cdp_map[i].phys, sc520cdp_map[i].size);
+		sc520cdp_map[i].virt = ioremap_nocache(sc520cdp_map[i].phys, sc520cdp_map[i].size);
 
 		if (!sc520cdp_map[i].virt) {
 			printk("Failed to ioremap_nocache\n");
@@ -261,7 +261,7 @@
 			++devices_found;
 		}
 		else {
-			iounmap((void *)sc520cdp_map[i].virt);
+			iounmap(sc520cdp_map[i].virt);
 		}
 	}
 	if(devices_found >= 2) {
@@ -290,8 +290,8 @@
 		if (mymtd[i])
 			map_destroy(mymtd[i]);
 		if (sc520cdp_map[i].virt) {
-			iounmap((void *)sc520cdp_map[i].virt);
-			sc520cdp_map[i].virt = 0;
+			iounmap(sc520cdp_map[i].virt);
+			sc520cdp_map[i].virt = NULL;
 		}
 	}
 }
diff -Nru a/drivers/mtd/maps/scb2_flash.c b/drivers/mtd/maps/scb2_flash.c
--- a/drivers/mtd/maps/scb2_flash.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/mtd/maps/scb2_flash.c	2004-12-24 13:36:56 -08:00
@@ -1,6 +1,6 @@
 /*
  * MTD map driver for BIOS Flash on Intel SCB2 boards
- * $Id: scb2_flash.c,v 1.8 2004/07/12 21:59:45 dwmw2 Exp $
+ * $Id: scb2_flash.c,v 1.10 2004/11/16 18:29:02 dwmw2 Exp $
  * Copyright (C) 2002 Sun Microsystems, Inc.
  * Tim Hockin <thockin@sun.com>
  *
@@ -62,9 +62,9 @@
 #define SCB2_WINDOW	0x00100000
 
 
-static void *scb2_ioaddr;
+static void __iomem *scb2_ioaddr;
 static struct mtd_info *scb2_mtd;
-struct map_info scb2_map = {
+static struct map_info scb2_map = {
 	.name =      "SCB2 BIOS Flash",
 	.size =      0,
 	.bankwidth =  1,
@@ -163,7 +163,7 @@
 	}
 
 	scb2_map.phys = SCB2_ADDR;
-	scb2_map.virt = (unsigned long)scb2_ioaddr;
+	scb2_map.virt = scb2_ioaddr;
 	scb2_map.size = SCB2_WINDOW;
 
 	simple_map_init(&scb2_map);
diff -Nru a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c
--- a/drivers/mtd/maps/scx200_docflash.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/mtd/maps/scx200_docflash.c	2004-12-24 13:37:02 -08:00
@@ -2,7 +2,7 @@
 
    Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
 
-   $Id: scx200_docflash.c,v 1.6 2004/07/12 21:59:45 dwmw2 Exp $ 
+   $Id: scx200_docflash.c,v 1.9 2004/11/16 18:29:02 dwmw2 Exp $ 
 
    National Semiconductor SCx200 flash mapped with DOCCS
 */
@@ -81,7 +81,7 @@
 	.name      = "NatSemi SCx200 DOCCS Flash",
 };
 
-int __init init_scx200_docflash(void)
+static int __init init_scx200_docflash(void)
 {
 	unsigned u;
 	unsigned base;
@@ -180,7 +180,7 @@
 	simple_map_init(&scx200_docflash_map);
 
 	scx200_docflash_map.phys = docmem.start;
-	scx200_docflash_map.virt = (unsigned long)ioremap(docmem.start, scx200_docflash_map.size);
+	scx200_docflash_map.virt = ioremap(docmem.start, scx200_docflash_map.size);
 	if (!scx200_docflash_map.virt) {
 		printk(KERN_ERR NAME ": failed to ioremap the flash\n");
 		release_resource(&docmem);
@@ -190,7 +190,7 @@
 	mymtd = do_map_probe(flashtype, &scx200_docflash_map);
 	if (!mymtd) {
 		printk(KERN_ERR NAME ": unable to detect flash\n");
-		iounmap((void *)scx200_docflash_map.virt);
+		iounmap(scx200_docflash_map.virt);
 		release_resource(&docmem);
 		return -ENXIO;
 	}
@@ -221,7 +221,7 @@
 		map_destroy(mymtd);
 	}
 	if (scx200_docflash_map.virt) {
-		iounmap((void *)scx200_docflash_map.virt);
+		iounmap(scx200_docflash_map.virt);
 		release_resource(&docmem);
 	}
 }
diff -Nru a/drivers/mtd/maps/solutionengine.c b/drivers/mtd/maps/solutionengine.c
--- a/drivers/mtd/maps/solutionengine.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/mtd/maps/solutionengine.c	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: solutionengine.c,v 1.13 2004/07/12 21:59:45 dwmw2 Exp $
+ * $Id: solutionengine.c,v 1.14 2004/09/16 23:27:14 gleixner Exp $
  *
  * Flash and EPROM on Hitachi Solution Engine and similar boards.
  *
@@ -62,9 +62,9 @@
 
 	/* First probe at offset 0 */
 	soleng_flash_map.phys = 0;
-	soleng_flash_map.virt = P2SEGADDR(0);
+	soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0);
 	soleng_eprom_map.phys = 0x01000000;
-	soleng_eprom_map.virt = P1SEGADDR(0x01000000);
+	soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000);
 	simple_map_init(&soleng_eprom_map);
 	simple_map_init(&soleng_flash_map);
 	
diff -Nru a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c
--- a/drivers/mtd/maps/sun_uflash.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/mtd/maps/sun_uflash.c	2004-12-24 13:37:01 -08:00
@@ -1,4 +1,4 @@
-/* $Id: sun_uflash.c,v 1.9 2004/07/12 21:59:45 dwmw2 Exp $
+/* $Id: sun_uflash.c,v 1.11 2004/11/04 13:24:15 gleixner Exp $
  *
  * sun_uflash - Driver implementation for user-programmable flash
  * present on many Sun Microsystems SME boardsets.
@@ -96,8 +96,7 @@
 		pdev->map.name = pdev->name;
 	}
 	pdev->map.phys = edev->resource[0].start;
-	pdev->map.virt = 
-		(unsigned long)ioremap_nocache(edev->resource[0].start, pdev->map.size);
+	pdev->map.virt = ioremap_nocache(edev->resource[0].start, pdev->map.size);
 	if(0 == pdev->map.virt) {
 		printk("%s: failed to map device\n", __FUNCTION__);
 		kfree(pdev->name);
diff -Nru a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c
--- a/drivers/mtd/maps/tqm8xxl.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/mtd/maps/tqm8xxl.c	2004-12-24 13:36:19 -08:00
@@ -2,7 +2,7 @@
  * Handle mapping of the flash memory access routines 
  * on TQM8xxL based devices.
  *
- * $Id: tqm8xxl.c,v 1.11 2004/07/12 21:59:45 dwmw2 Exp $
+ * $Id: tqm8xxl.c,v 1.13 2004/10/20 22:21:53 dwmw2 Exp $
  *
  * based on rpxlite.c
  *
diff -Nru a/drivers/mtd/maps/ts5500_flash.c b/drivers/mtd/maps/ts5500_flash.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mtd/maps/ts5500_flash.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,141 @@
+/*
+ * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
+ *
+ * Copyright (C) 2004 Sean Young <sean@mess.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 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
+ *
+ * Note:
+ * - In order for detection to work, jumper 3 must be set.
+ * - Drive A and B use a proprietary FTL from General Software which isn't 
+ *   supported as of yet so standard drives can't be mounted; you can create 
+ *   your own (e.g. jffs) file system.
+ * - If you have created your own jffs file system and the bios overwrites 
+ *   it during boot, try disabling Drive A: and B: in the boot order.
+ *
+ * $Id: ts5500_flash.c,v 1.1 2004/09/20 15:33:26 sean Exp $
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+
+#ifdef CONFIG_MTD_PARTITIONS
+#include <linux/mtd/partitions.h>
+#endif
+
+#define WINDOW_ADDR	0x09400000
+#define WINDOW_SIZE	0x00200000
+
+static struct map_info ts5500_map = {
+	.name = "TS-5500 Flash",
+	.size = WINDOW_SIZE,
+	.bankwidth = 1,
+	.phys = WINDOW_ADDR
+};
+
+#ifdef CONFIG_MTD_PARTITIONS
+static struct mtd_partition ts5500_partitions[] = {
+	{
+		.name = "Drive A",
+		.offset = 0,
+		.size = 0x0e0000
+	},
+	{
+		.name = "BIOS",
+		.offset = 0x0e0000,
+		.size = 0x020000,
+	},
+	{
+		.name = "Drive B",
+		.offset = 0x100000,
+		.size = 0x100000
+	}
+};
+
+#define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition))
+
+#endif
+
+static struct mtd_info *mymtd;
+
+static int __init init_ts5500_map(void)
+{
+	int rc = 0;
+
+	ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
+
+	if(!ts5500_map.virt) {
+		printk(KERN_ERR "Failed to ioremap_nocache\n");
+		rc = -EIO;
+		goto err_out_ioremap;
+	}
+
+	simple_map_init(&ts5500_map);
+
+	mymtd = do_map_probe("jedec_probe", &ts5500_map);
+	if(!mymtd)
+		mymtd = do_map_probe("map_rom", &ts5500_map);
+
+	if(!mymtd) {
+		rc = -ENXIO;
+		goto err_out_map;
+	}
+
+	mymtd->owner = THIS_MODULE;
+#ifdef CONFIG_MTD_PARTITIONS
+	add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS);
+#else	
+	add_mtd_device(mymtd);
+#endif
+
+	return 0;
+
+err_out_map:
+	map_destroy(mymtd);
+err_out_ioremap:
+	iounmap(ts5500_map.virt);
+
+	return rc;
+}
+
+static void __exit cleanup_ts5500_map(void)
+{
+	if (mymtd) {
+#ifdef CONFIG_MTD_PARTITIONS
+		del_mtd_partitions(mymtd);
+#else
+		del_mtd_device(mymtd);
+#endif
+		map_destroy(mymtd);
+	}
+
+	if (ts5500_map.virt) {
+		iounmap(ts5500_map.virt);
+		ts5500_map.virt = NULL;
+	}
+}
+
+module_init(init_ts5500_map);
+module_exit(cleanup_ts5500_map);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sean Young <sean@mess.org>");
+MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board");
+
diff -Nru a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c
--- a/drivers/mtd/maps/uclinux.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/mtd/maps/uclinux.c	2004-12-24 13:37:19 -08:00
@@ -5,7 +5,7 @@
  *
  *	(C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
  *
- * 	$Id: uclinux.c,v 1.7 2004/07/12 21:59:45 dwmw2 Exp $
+ * 	$Id: uclinux.c,v 1.9 2004/11/04 13:24:15 gleixner Exp $
  */
 
 /****************************************************************************/
@@ -71,7 +71,7 @@
 
 	mapp->virt = ioremap_nocache(mapp->phys, mapp->size);
 
-	if (!mapp->virt) {
+	if (mapp->virt == 0) {
 		printk("uclinux[mtd]: ioremap_nocache() failed\n");
 		return(-EIO);
 	}
@@ -81,7 +81,7 @@
 	mtd = do_map_probe("map_ram", mapp);
 	if (!mtd) {
 		printk("uclinux[mtd]: failed to find a mapping?\n");
-		iounmap(mapp->virt);
+		iounmap((void *) mapp->virt);
 		return(-ENXIO);
 	}
 		
diff -Nru a/drivers/mtd/maps/wr_sbc82xx_flash.c b/drivers/mtd/maps/wr_sbc82xx_flash.c
--- a/drivers/mtd/maps/wr_sbc82xx_flash.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/mtd/maps/wr_sbc82xx_flash.c	2004-12-24 13:36:16 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: wr_sbc82xx_flash.c,v 1.5 2004/07/15 14:52:02 dwmw2 Exp $
+ * $Id: wr_sbc82xx_flash.c,v 1.7 2004/11/04 13:24:15 gleixner Exp $
  *
  * Map for flash chips on Wind River PowerQUICC II SBC82xx board.
  *
@@ -116,7 +116,7 @@
 		}
 		printk(" at %08lx)\n",  sbc82xx_flash_map[i].phys);
 
-		sbc82xx_flash_map[i].virt = (unsigned long)ioremap(sbc82xx_flash_map[i].phys, sbc82xx_flash_map[i].size);
+		sbc82xx_flash_map[i].virt = ioremap(sbc82xx_flash_map[i].phys, sbc82xx_flash_map[i].size);
 
 		if (!sbc82xx_flash_map[i].virt) {
 			printk("Failed to ioremap\n");
diff -Nru a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
--- a/drivers/mtd/mtd_blkdevs.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/mtd/mtd_blkdevs.c	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: mtd_blkdevs.c,v 1.22 2004/07/12 12:35:28 dwmw2 Exp $
+ * $Id: mtd_blkdevs.c,v 1.24 2004/11/16 18:28:59 dwmw2 Exp $
  *
  * (C) 2003 David Woodhouse <dwmw2@infradead.org>
  *
@@ -81,7 +81,7 @@
 	struct request_queue *rq = tr->blkcore_priv->rq;
 
 	/* we might get involved when memory gets low, so use PF_MEMALLOC */
-	current->flags |= PF_MEMALLOC;
+	current->flags |= PF_MEMALLOC | PF_NOFREEZE;
 
 	daemonize("%sd", tr->name);
 
@@ -143,7 +143,7 @@
 }
 
 
-int blktrans_open(struct inode *i, struct file *f)
+static int blktrans_open(struct inode *i, struct file *f)
 {
 	struct mtd_blktrans_dev *dev;
 	struct mtd_blktrans_ops *tr;
@@ -174,7 +174,7 @@
 	return ret;
 }
 
-int blktrans_release(struct inode *i, struct file *f)
+static int blktrans_release(struct inode *i, struct file *f)
 {
 	struct mtd_blktrans_dev *dev;
 	struct mtd_blktrans_ops *tr;
@@ -326,7 +326,7 @@
 	return 0;
 }
 
-void blktrans_notify_remove(struct mtd_info *mtd)
+static void blktrans_notify_remove(struct mtd_info *mtd)
 {
 	struct list_head *this, *this2, *next;
 
@@ -342,7 +342,7 @@
 	}
 }
 
-void blktrans_notify_add(struct mtd_info *mtd)
+static void blktrans_notify_add(struct mtd_info *mtd)
 {
 	struct list_head *this;
 
diff -Nru a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
--- a/drivers/mtd/mtdblock.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/mtd/mtdblock.c	2004-12-24 13:36:47 -08:00
@@ -1,7 +1,7 @@
 /* 
  * Direct MTD block device access
  *
- * $Id: mtdblock.c,v 1.64 2003/10/04 17:14:14 dwmw2 Exp $
+ * $Id: mtdblock.c,v 1.65 2004/11/16 18:28:59 dwmw2 Exp $
  *
  * (C) 2000-2003 Nicolas Pitre <nico@cam.org>
  * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
@@ -361,7 +361,7 @@
 	kfree(dev);
 }
 
-struct mtd_blktrans_ops mtdblock_tr = {
+static struct mtd_blktrans_ops mtdblock_tr = {
 	.name		= "mtdblock",
 	.major		= 31,
 	.part_bits	= 0,
@@ -375,7 +375,7 @@
 	.owner		= THIS_MODULE,
 };
 
-int __init init_mtdblock(void)
+static int __init init_mtdblock(void)
 {
 	return register_mtd_blktrans(&mtdblock_tr);
 }
diff -Nru a/drivers/mtd/mtdblock.h b/drivers/mtd/mtdblock.h
--- a/drivers/mtd/mtdblock.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,35 +0,0 @@
-/*
- * drivers/mtd/mtdblock.h
- *
- * common defines for mtdblock-core and mtdblock-2x
- *
- * $Id: mtdblock.h,v 1.1 2002/11/27 10:33:37 gleixner Exp $
- *
- */
-
-#ifndef __MTD_MTDBLOCK_H__
-#define __MTD_MTDBLOCK_H__
-
-#define MAJOR_NR MTD_BLOCK_MAJOR
-#define DEVICE_NAME "mtdblock"
-
-struct mtdblk_dev {
-	struct mtd_info *mtd; /* Locked */
-	int count;
-	struct semaphore cache_sem;
-	unsigned char *cache_data;
-	unsigned long cache_offset;
-	unsigned int cache_size;
-	enum { STATE_EMPTY, STATE_CLEAN, STATE_DIRTY } cache_state;
-}; 
-
-extern int write_cached_data (struct mtdblk_dev *mtdblk);
-extern int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, 
-			    int len, const char *buf);
-extern int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, 
-			   int len, char *buf);
-
-extern void __exit cleanup_mtdblock(void);
-extern int __init init_mtdblock(void);
-
-#endif
diff -Nru a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c
--- a/drivers/mtd/mtdblock_ro.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/mtd/mtdblock_ro.c	2004-12-24 13:36:49 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: mtdblock_ro.c,v 1.18 2003/06/23 12:00:08 dwmw2 Exp $
+ * $Id: mtdblock_ro.c,v 1.19 2004/11/16 18:28:59 dwmw2 Exp $
  *
  * (C) 2003 David Woodhouse <dwmw2@infradead.org>
  *
@@ -58,7 +58,7 @@
 	kfree(dev);
 }
 
-struct mtd_blktrans_ops mtdblock_tr = {
+static struct mtd_blktrans_ops mtdblock_tr = {
 	.name		= "mtdblock",
 	.major		= 31,
 	.part_bits	= 0,
diff -Nru a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
--- a/drivers/mtd/mtdchar.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/mtd/mtdchar.c	2004-12-24 13:37:02 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: mtdchar.c,v 1.64 2004/08/09 13:59:46 dwmw2 Exp $
+ * $Id: mtdchar.c,v 1.65 2004/09/23 23:45:47 gleixner Exp $
  *
  * Character-device access to raw MTD devices.
  *
@@ -179,7 +179,13 @@
 			return -ENOMEM;
 		
 		ret = MTD_READ(mtd, *ppos, len, &retlen, kbuf);
-		if (!ret) {
+		/* Nand returns -EBADMSG on ecc errors, but it returns
+		 * the data. For our userspace tools it is important
+		 * to dump areas with ecc errors ! 
+		 * Userspace software which accesses NAND this way
+		 * must be aware of the fact that it deals with NAND
+		 */
+		if (!ret || (ret == -EBADMSG)) {
 			*ppos += retlen;
 			if (copy_to_user(buf, kbuf, retlen)) {
 			        kfree(kbuf);
@@ -198,7 +204,7 @@
 		
 		kfree(kbuf);
 	}
-	
+
 	return total_retlen;
 } /* mtd_read */
 
diff -Nru a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
--- a/drivers/mtd/mtdcore.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/mtd/mtdcore.c	2004-12-24 13:36:49 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: mtdcore.c,v 1.43 2004/07/23 15:20:46 dwmw2 Exp $
+ * $Id: mtdcore.c,v 1.44 2004/11/16 18:28:59 dwmw2 Exp $
  *
  * Core registration and callback routines for MTD
  * drivers and users.
@@ -382,7 +382,7 @@
 /*====================================================================*/
 /* Init code */
 
-int __init init_mtd(void)
+static int __init init_mtd(void)
 {
 #ifdef CONFIG_PROC_FS
 	if ((proc_mtd = create_proc_entry( "mtd", 0, NULL )))
diff -Nru a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
--- a/drivers/mtd/mtdpart.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/mtd/mtdpart.c	2004-12-24 13:37:04 -08:00
@@ -5,7 +5,7 @@
  *
  * This code is GPL
  *
- * $Id: mtdpart.c,v 1.50 2004/08/10 16:18:34 dwmw2 Exp $
+ * $Id: mtdpart.c,v 1.51 2004/11/16 18:28:59 dwmw2 Exp $
  *
  * 	02-21-2002	Thomas Gleixner <gleixner@autronix.de>
  *			added support for read_oob, write_oob
@@ -526,7 +526,7 @@
 static spinlock_t part_parser_lock = SPIN_LOCK_UNLOCKED;
 static LIST_HEAD(part_parsers);
 
-struct mtd_part_parser *get_partition_parser(const char *name)
+static struct mtd_part_parser *get_partition_parser(const char *name)
 {
 	struct list_head *this;
 	void *ret = NULL;
diff -Nru a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
--- a/drivers/mtd/nand/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/drivers/mtd/nand/Kconfig	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,5 @@
 # drivers/mtd/nand/Kconfig
-# $Id: Kconfig,v 1.17 2004/08/10 14:24:07 dwmw2 Exp $
+# $Id: Kconfig,v 1.22 2004/10/05 22:11:46 gleixner Exp $
 
 menu "NAND Flash Device Drivers"
 	depends on MTD!=n
@@ -36,6 +36,12 @@
 	  This enables the driver for the Cirrus Logic EBD7312 evaluation 
 	  board to access the onboard NAND Flash.
 
+config MTD_NAND_H1900
+	tristate "iPAQ H1900 flash"
+	depends on ARM && MTD_NAND && ARCH_PXA && MTD_PARTITIONS
+	help
+	  This enables the driver for the iPAQ h1900 flash.
+
 config MTD_NAND_SPIA
 	tristate "NAND Flash device on SPIA board"
 	depends on ARM && ARCH_P720T && MTD_NAND
@@ -74,15 +80,54 @@
 	  This enables the driver for the NAND flash controller on the
 	  AMD/Alchemy 1550 SOC.
 
+config MTD_NAND_RTC_FROM4
+	tristate "Renesas Flash ROM 4-slot interface board (FROM_BOARD4)"
+	depends on MTD_NAND && SH_SOLUTION_ENGINE
+	select REED_SOLOMON
+	select REED_SOLOMON_DEC8
+	help
+	  This enables the driver for the Renesas Technology AG-AND 
+	  flash interface board (FROM_BOARD4)
+
 config MTD_NAND_PPCHAMELEONEVB
 	tristate "NAND Flash device on PPChameleonEVB board"
 	depends on PPCHAMELEONEVB && MTD_NAND
 	help
-	  This enables the NAND flash driver on the PPChameleon EVB Board.	
+	  This enables the NAND flash driver on the PPChameleon EVB Board.
+
+config MTD_NAND_S3C2410
+	tristate "NAND Flash support for S3C2410 SoC"
+	depends on ARCH_S3C2410 && MTD_NAND
+	help
+	  This enables the NAND flash controller on the S3C2410.
+
+	  No board specfic support is done by this driver, each board
+	  must advertise a platform_device for the driver to attach. 
+
+config MTD_NAND_S3C2410_DEBUG
+	bool "S3C2410 NAND driver debug"
+	depends on MTD_NAND_S3C2410
+	help
+	  Enable debugging of the S3C2410 NAND driver
+
+config MTD_NAND_S3C2410_HWECC
+	bool "S3C2410 NAND Hardware ECC"
+	depends on MTD_NAND_S3C2410
+	help
+	  Enable the use of the S3C2410's internal ECC generator when
+	  using NAND. Early versions of the chip have had problems with
+	  incorrect ECC generation, and if using these, the default of
+	  software ECC is preferable.
+
+	  If you lay down a device with the hardware ECC, then you will
+	  currently not be able to switch to software, as there is no
+	  implementation for ECC method used by the S3C2410
 
 config MTD_NAND_DISKONCHIP
 	tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation) (EXPERIMENTAL)"
 	depends on MTD_NAND && EXPERIMENTAL
+	select REED_SOLOMON
+	select REED_SOLOMON_DEC16
 	help
 	  This is a reimplementation of M-Systems DiskOnChip 2000,
 	  Millennium and Millennium Plus as a standard NAND device driver,
diff -Nru a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
--- a/drivers/mtd/nand/Makefile	2004-12-24 13:36:17 -08:00
+++ b/drivers/mtd/nand/Makefile	2004-12-24 13:36:17 -08:00
@@ -1,7 +1,7 @@
 #
 # linux/drivers/nand/Makefile
 #
-# $Id: Makefile.common,v 1.9 2004/07/12 16:07:31 dwmw2 Exp $
+# $Id: Makefile.common,v 1.13 2004/09/28 22:04:23 bjd Exp $
 
 obj-$(CONFIG_MTD_NAND)			+= nand.o nand_ecc.o
 obj-$(CONFIG_MTD_NAND_IDS)		+= nand_ids.o
@@ -14,6 +14,9 @@
 obj-$(CONFIG_MTD_NAND_TX4938NDFMC)	+= tx4938ndfmc.o
 obj-$(CONFIG_MTD_NAND_AU1550)		+= au1550nd.o
 obj-$(CONFIG_MTD_NAND_PPCHAMELEONEVB)	+= ppchameleonevb.o
+obj-$(CONFIG_MTD_NAND_S3C2410)		+= s3c2410.o
 obj-$(CONFIG_MTD_NAND_DISKONCHIP)	+= diskonchip.o
+obj-$(CONFIG_MTD_NAND_H1900)		+= h1910.o
+obj-$(CONFIG_MTD_NAND_RTC_FROM4)	+= rtc_from4.o
 
 nand-objs = nand_base.o nand_bbt.o
diff -Nru a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
--- a/drivers/mtd/nand/au1550nd.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/mtd/nand/au1550nd.c	2004-12-24 13:36:18 -08:00
@@ -3,7 +3,7 @@
  *
  *  Copyright (C) 2004 Embedded Edge, LLC
  *
- * $Id: au1550nd.c,v 1.5 2004/05/17 07:19:35 ppopov Exp $
+ * $Id: au1550nd.c,v 1.11 2004/11/04 12:53:10 gleixner Exp $
  *
  * 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
@@ -18,6 +18,17 @@
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 #include <asm/io.h>
+
+/* fixme: this is ugly */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0)
+#include <asm/mach-au1x00/au1000.h>
+#ifdef CONFIG_MIPS_PB1550
+#include <asm/mach-pb1x00/pb1550.h> 
+#endif
+#ifdef CONFIG_MIPS_DB1550
+#include <asm/mach-db1x00/db1x00.h> 
+#endif
+#else
 #include <asm/au1000.h>
 #ifdef CONFIG_MIPS_PB1550
 #include <asm/pb1550.h> 
@@ -25,18 +36,16 @@
 #ifdef CONFIG_MIPS_DB1550
 #include <asm/db1x00.h> 
 #endif
-
+#endif
 
 /*
  * MTD structure for NAND controller
  */
 static struct mtd_info *au1550_mtd = NULL;
-static volatile u32 p_nand;
-static int nand_width = 1; /* default, only x8 supported for now */
+static void __iomem *p_nand;
+static int nand_width = 1; /* default x8*/
 
-/* Internal buffers. Page buffer and oob buffer for one block*/
-static u_char data_buf[512 + 16];
-static u_char oob_buf[16 * 32];
+#define NAND_CS 1
 
 /*
  * Define partitions for flash device
@@ -70,183 +79,262 @@
 #endif
 };
 
-static inline void write_cmd_reg(u8 cmd)
+
+/**
+ * au_read_byte -  read one byte from the chip
+ * @mtd:	MTD device structure
+ *
+ *  read function for 8bit buswith
+ */
+static u_char au_read_byte(struct mtd_info *mtd)
 {
-	if (nand_width)
-		*((volatile u8 *)(p_nand + MEM_STNAND_CMD)) = cmd;
-	else
-		*((volatile u16 *)(p_nand + MEM_STNAND_CMD)) = cmd;
+	struct nand_chip *this = mtd->priv;
+	u_char ret = readb(this->IO_ADDR_R);
 	au_sync();
+	return ret;
 }
 
-static inline void write_addr_reg(u8 addr)
+/**
+ * au_write_byte -  write one byte to the chip
+ * @mtd:	MTD device structure
+ * @byte:	pointer to data byte to write
+ *
+ *  write function for 8it buswith
+ */
+static void au_write_byte(struct mtd_info *mtd, u_char byte)
 {
-	if (nand_width)
-		*((volatile u8 *)(p_nand + MEM_STNAND_ADDR)) = addr;
-	else
-		*((volatile u16 *)(p_nand + MEM_STNAND_ADDR)) = addr;
+	struct nand_chip *this = mtd->priv;
+	writeb(byte, this->IO_ADDR_W);
 	au_sync();
 }
 
-static inline void write_data_reg(u8 data)
+/**
+ * au_read_byte16 -  read one byte endianess aware from the chip
+ * @mtd:	MTD device structure
+ *
+ *  read function for 16bit buswith with 
+ * endianess conversion
+ */
+static u_char au_read_byte16(struct mtd_info *mtd)
 {
-	if (nand_width)
-		*((volatile u8 *)(p_nand + MEM_STNAND_DATA)) = data;
-	else
-		*((volatile u16 *)(p_nand + MEM_STNAND_DATA)) = data;
+	struct nand_chip *this = mtd->priv;
+	u_char ret = (u_char) cpu_to_le16(readw(this->IO_ADDR_R));
 	au_sync();
+	return ret;
 }
 
-static inline u32 read_data_reg(void)
+/**
+ * au_write_byte16 -  write one byte endianess aware to the chip
+ * @mtd:	MTD device structure
+ * @byte:	pointer to data byte to write
+ *
+ *  write function for 16bit buswith with
+ * endianess conversion
+ */
+static void au_write_byte16(struct mtd_info *mtd, u_char byte)
 {
-	u32 data;
-	if (nand_width) {
-		data = *((volatile u8 *)(p_nand + MEM_STNAND_DATA));
-		au_sync();
-	}
-	else {
-		data = *((volatile u16 *)(p_nand + MEM_STNAND_DATA));
-		au_sync();
-	}
-	return data;
+	struct nand_chip *this = mtd->priv;
+	writew(le16_to_cpu((u16) byte), this->IO_ADDR_W);
+	au_sync();
 }
 
-void au1550_hwcontrol(struct mtd_info *mtd, int cmd)
+/**
+ * au_read_word -  read one word from the chip
+ * @mtd:	MTD device structure
+ *
+ *  read function for 16bit buswith without 
+ * endianess conversion
+ */
+static u16 au_read_word(struct mtd_info *mtd)
 {
+	struct nand_chip *this = mtd->priv;
+	u16 ret = readw(this->IO_ADDR_R);
+	au_sync();
+	return ret;
 }
 
-int au1550_device_ready(struct mtd_info *mtd)
+/**
+ * au_write_word -  write one word to the chip
+ * @mtd:	MTD device structure
+ * @word:	data word to write
+ *
+ *  write function for 16bit buswith without 
+ * endianess conversion
+ */
+static void au_write_word(struct mtd_info *mtd, u16 word)
 {
-	int ready;
-	ready = (au_readl(MEM_STSTAT) & 0x1) ? 1 : 0;
-	return ready;
+	struct nand_chip *this = mtd->priv;
+	writew(word, this->IO_ADDR_W);
+	au_sync();
 }
 
-static u_char au1550_nand_read_byte(struct mtd_info *mtd)
+/**
+ * au_write_buf -  write buffer to chip
+ * @mtd:	MTD device structure
+ * @buf:	data buffer
+ * @len:	number of bytes to write
+ *
+ *  write function for 8bit buswith
+ */
+static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
 {
-	u_char ret;
-	ret = read_data_reg();
-	return ret;
-}
+	int i;
+	struct nand_chip *this = mtd->priv;
 
-static void au1550_nand_write_byte(struct mtd_info *mtd, u_char byte)
-{
-	write_data_reg((u8)byte);
+	for (i=0; i<len; i++) {
+		writeb(buf[i], this->IO_ADDR_W);
+		au_sync();
+	}
 }
 
-static void 
-au1550_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
+/**
+ * au_read_buf -  read chip data into buffer 
+ * @mtd:	MTD device structure
+ * @buf:	buffer to store date
+ * @len:	number of bytes to read
+ *
+ *  read function for 8bit buswith
+ */
+static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len)
 {
 	int i;
+	struct nand_chip *this = mtd->priv;
 
-	for (i=0; i<len; i++)
-		write_data_reg(buf[i]);
+	for (i=0; i<len; i++) {
+		buf[i] = readb(this->IO_ADDR_R);
+		au_sync();	
+	}
 }
 
-static void 
-au1550_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
+/**
+ * au_verify_buf -  Verify chip data against buffer 
+ * @mtd:	MTD device structure
+ * @buf:	buffer containing the data to compare
+ * @len:	number of bytes to compare
+ *
+ *  verify function for 8bit buswith
+ */
+static int au_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
 {
 	int i;
+	struct nand_chip *this = mtd->priv;
+
+	for (i=0; i<len; i++) {
+		if (buf[i] != readb(this->IO_ADDR_R))
+			return -EFAULT;
+		au_sync();
+	}
 
-	for (i=0; i<len; i++)
-		buf[i] = (u_char)read_data_reg();
+	return 0;
 }
 
-static int 
-au1550_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
+/**
+ * au_write_buf16 -  write buffer to chip
+ * @mtd:	MTD device structure
+ * @buf:	data buffer
+ * @len:	number of bytes to write
+ *
+ *  write function for 16bit buswith
+ */
+static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
 {
 	int i;
+	struct nand_chip *this = mtd->priv;
+	u16 *p = (u16 *) buf;
+	len >>= 1;
+	
+	for (i=0; i<len; i++) {
+		writew(p[i], this->IO_ADDR_W);
+		au_sync();
+	}
+		
+}
 
-	for (i=0; i<len; i++)
-		if (buf[i] != (u_char)read_data_reg())
-			return -EFAULT;
+/**
+ * au_read_buf16 -  read chip data into buffer 
+ * @mtd:	MTD device structure
+ * @buf:	buffer to store date
+ * @len:	number of bytes to read
+ *
+ *  read function for 16bit buswith
+ */
+static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
+{
+	int i;
+	struct nand_chip *this = mtd->priv;
+	u16 *p = (u16 *) buf;
+	len >>= 1;
 
-	return 0;
+	for (i=0; i<len; i++) {
+		p[i] = readw(this->IO_ADDR_R);
+		au_sync();
+	}
 }
 
-static void au1550_nand_select_chip(struct mtd_info *mtd, int chip)
+/**
+ * au_verify_buf16 -  Verify chip data against buffer 
+ * @mtd:	MTD device structure
+ * @buf:	buffer containing the data to compare
+ * @len:	number of bytes to compare
+ *
+ *  verify function for 16bit buswith
+ */
+static int au_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len)
 {
-	switch(chip) {
-	case -1:
-		/* deassert chip enable */
-		au_writel(au_readl(MEM_STNDCTL) & ~0x20 , MEM_STNDCTL);
-		break;
-	case 0:
-		/* assert (force assert) chip enable */
-		au_writel(au_readl(MEM_STNDCTL) | 0x20 , MEM_STNDCTL);
-		break;
+	int i;
+	struct nand_chip *this = mtd->priv;
+	u16 *p = (u16 *) buf;
+	len >>= 1;
 
-	default:
-		BUG();
+	for (i=0; i<len; i++) {
+		if (p[i] != readw(this->IO_ADDR_R))
+			return -EFAULT;
+		au_sync();
 	}
+	return 0;
 }
 
-static void au1550_nand_command (struct mtd_info *mtd, unsigned command, 
-		int column, int page_addr)
+
+static void au1550_hwcontrol(struct mtd_info *mtd, int cmd)
 {
 	register struct nand_chip *this = mtd->priv;
 
-	/*
-	 * Write out the command to the device.
-	 */
-	if (command == NAND_CMD_SEQIN) {
-		int readcmd;
-
-		if (column >= mtd->oobblock) {
-			/* OOB area */
-			column -= mtd->oobblock;
-			readcmd = NAND_CMD_READOOB;
-		} else if (column < 256) {
-			/* First 256 bytes --> READ0 */
-			readcmd = NAND_CMD_READ0;
-		} else {
-			column -= 256;
-			readcmd = NAND_CMD_READ1;
-		}
-		write_cmd_reg(readcmd);
-	}
-	write_cmd_reg(command);
-
-	if (column != -1 || page_addr != -1) {
-
-		/* Serially input address */
-		if (column != -1)
-			write_addr_reg(column);
-		if (page_addr != -1) {
-			write_addr_reg((unsigned char) (page_addr & 0xff));
-			write_addr_reg(((page_addr >> 8) & 0xff));
-			/* One more address cycle for higher density devices */
-			if (mtd->size & 0x0c000000) 
-				write_addr_reg((unsigned char) ((page_addr >> 16) & 0x0f));
-		}
-	}
-	
-	switch (command) {
-			
-	case NAND_CMD_PAGEPROG:
-	case NAND_CMD_ERASE1:
-	case NAND_CMD_ERASE2:
-	case NAND_CMD_SEQIN:
-	case NAND_CMD_STATUS:
+	switch(cmd){
+
+	case NAND_CTL_SETCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_CMD; break;
+	case NAND_CTL_CLRCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; break;
+
+	case NAND_CTL_SETALE: this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR; break;
+	case NAND_CTL_CLRALE: 
+		this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; 
+		/* FIXME: Nobody knows why this is neccecary, 
+		 * but it works only that way */
+		udelay(1); 
 		break;
 
-	case NAND_CMD_RESET:
-		if (this->dev_ready)	
-			break;
-		udelay(this->chip_delay);
-		write_cmd_reg(NAND_CMD_STATUS);
-		while ( !(read_data_reg() & 0x40));
-		return;
-
-	/* This applies to read commands */	
-	default:
-		udelay (this->chip_delay);
+	case NAND_CTL_SETNCE: 
+		/* assert (force assert) chip enable */
+		au_writel((1<<(4+NAND_CS)) , MEM_STNDCTL); break;
+		break;
+
+	case NAND_CTL_CLRNCE: 
+ 		/* deassert chip enable */
+		au_writel(0, MEM_STNDCTL); break;
+		break;
 	}
+
+	this->IO_ADDR_R = this->IO_ADDR_W;
 	
-	/* wait until command is processed */
-	while (!this->dev_ready(mtd));
+	/* Drain the writebuffer */
+	au_sync();
 }
 
+int au1550_device_ready(struct mtd_info *mtd)
+{
+	int ret = (au_readl(MEM_STSTAT) & 0x1) ? 1 : 0;
+	au_sync();
+	return ret;
+}
 
 /*
  * Main initialization routine
@@ -255,7 +343,7 @@
 {
 	struct nand_chip *this;
 	u16 boot_swapboot = 0; /* default value */
-	u32 mem_time;
+	int retval;
 
 	/* Allocate memory for MTD device structure and private data */
 	au1550_mtd = kmalloc (sizeof(struct mtd_info) + 
@@ -275,11 +363,9 @@
 	/* Link the private data with the MTD structure */
 	au1550_mtd->priv = this;
 
-	/* disable interrupts */
-	au_writel(au_readl(MEM_STNDCTL) & ~(1<<8), MEM_STNDCTL);
 
-	/* disable NAND boot */
-	au_writel(au_readl(MEM_STNDCTL) & ~(1<<0), MEM_STNDCTL);
+	/* MEM_STNDCTL: disable ints, disable nand boot */
+	au_writel(0, MEM_STNDCTL);
 
 #ifdef CONFIG_MIPS_PB1550
 	/* set gpio206 high */
@@ -295,7 +381,6 @@
 		case 0xD:
 			/* x16 NAND Flash */
 			nand_width = 0;
-			printk("Pb1550 NAND: 16-bit NAND not supported by MTD\n");
 			break;
 		case 1:
 		case 9:
@@ -307,62 +392,62 @@
 			break;
 		default:
 			printk("Pb1550 NAND: bad boot:swap\n");
-			kfree(au1550_mtd);
-			return 1;
+			retval = -EINVAL;
+			goto outmem;
 	}
+#endif
 
 	/* Configure RCE1 - should be done by YAMON */
-	au_writel(0x5 | (nand_width << 22), MEM_STCFG1);
-	au_writel(NAND_TIMING, MEM_STTIME1);
-	mem_time = au_readl(MEM_STTIME1);
+	au_writel(0x5 | (nand_width << 22), 0xB4001010); /* MEM_STCFG1 */
+	au_writel(NAND_TIMING, 0xB4001014); /* MEM_STTIME1 */
 	au_sync();
 
-	/* setup and enable chip select */
+	/* setup and enable chip select, MEM_STADDR1 */
 	/* we really need to decode offsets only up till 0x20 */
 	au_writel((1<<28) | (NAND_PHYS_ADDR>>4) | 
 			(((NAND_PHYS_ADDR + 0x1000)-1) & (0x3fff<<18)>>18), 
 			MEM_STADDR1);
 	au_sync();
-#endif
-
-#ifdef CONFIG_MIPS_DB1550
-	/* Configure RCE1 - should be done by YAMON */
-	au_writel(0x00400005, MEM_STCFG1);
-	au_writel(0x00007774, MEM_STTIME1);
-	au_writel(0x12000FFF, MEM_STADDR1);
-#endif
 
-	p_nand = (volatile struct nand_regs *)ioremap(NAND_PHYS_ADDR, 0x1000);
+	p_nand = ioremap(NAND_PHYS_ADDR, 0x1000);
 
 	/* Set address of hardware control function */
 	this->hwcontrol = au1550_hwcontrol;
 	this->dev_ready = au1550_device_ready;
 	/* 30 us command delay time */
 	this->chip_delay = 30;		
-
-	this->cmdfunc = au1550_nand_command;
-	this->select_chip = au1550_nand_select_chip;
-	this->write_byte = au1550_nand_write_byte;
-	this->read_byte = au1550_nand_read_byte;
-	this->write_buf = au1550_nand_write_buf;
-	this->read_buf = au1550_nand_read_buf;
-	this->verify_buf = au1550_nand_verify_buf;
 	this->eccmode = NAND_ECC_SOFT;
 
-	/* Set internal data buffer */
-	this->data_buf = data_buf;
-	this->oob_buf = oob_buf;
+	this->options = NAND_NO_AUTOINCR;
+
+	if (!nand_width)
+		this->options |= NAND_BUSWIDTH_16;
+
+	this->read_byte = (!nand_width) ? au_read_byte16 : au_read_byte;
+	this->write_byte = (!nand_width) ? au_write_byte16 : au_write_byte;
+	this->write_word = au_write_word;
+	this->read_word = au_read_word;
+	this->write_buf = (!nand_width) ? au_write_buf16 : au_write_buf;
+	this->read_buf = (!nand_width) ? au_read_buf16 : au_read_buf;
+	this->verify_buf = (!nand_width) ? au_verify_buf16 : au_verify_buf;
 
 	/* Scan to find existence of the device */
 	if (nand_scan (au1550_mtd, 1)) {
-		kfree (au1550_mtd);
-		return -ENXIO;
+		retval = -ENXIO;
+		goto outio;
 	}
 
 	/* Register the partitions */
 	add_mtd_partitions(au1550_mtd, partition_info, NUM_PARTITIONS);
 
 	return 0;
+
+ outio:
+	iounmap ((void *)p_nand);
+	
+ outmem:
+	kfree (au1550_mtd);
+	return retval;
 }
 
 module_init(au1550_init);
@@ -375,16 +460,14 @@
 {
 	struct nand_chip *this = (struct nand_chip *) &au1550_mtd[1];
 
-	iounmap ((void *)p_nand);
-
-	/* Unregister partitions */
-	del_mtd_partitions(au1550_mtd);
-
-	/* Unregister the device */
-	del_mtd_device (au1550_mtd);
+	/* Release resources, unregister device */
+	nand_release (au1550_mtd);
 
 	/* Free the MTD device structure */
 	kfree (au1550_mtd);
+
+	/* Unmap */
+	iounmap ((void *)p_nand);
 }
 module_exit(au1550_cleanup);
 #endif
diff -Nru a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c
--- a/drivers/mtd/nand/autcpu12.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/mtd/nand/autcpu12.c	2004-12-24 13:36:19 -08:00
@@ -6,7 +6,7 @@
  *  Derived from drivers/mtd/spia.c
  * 	 Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
  * 
- * $Id: autcpu12.c,v 1.20 2004/07/20 02:44:26 dwmw2 Exp $
+ * $Id: autcpu12.c,v 1.22 2004/11/04 12:53:10 gleixner Exp $
  *
  * 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
@@ -48,17 +48,7 @@
 static int autcpu12_fio_pbase = AUTCPU12_PHYS_SMC;
 static int autcpu12_fio_ctrl = AUTCPU12_SMC_SELECT_OFFSET;
 static int autcpu12_pedr = AUTCPU12_SMC_PORT_OFFSET;
-static int autcpu12_fio_base;
-
-#ifdef MODULE
-MODULE_PARM(autcpu12_fio_pbase, "i");
-MODULE_PARM(autcpu12_fio_ctrl, "i");
-MODULE_PARM(autcpu12_pedr, "i");
-
-__setup("autcpu12_fio_pbase=",autcpu12_fio_pbase);
-__setup("autcpu12_fio_ctrl=",autcpu12_fio_ctrl);
-__setup("autcpu12_pedr=",autcpu12_pedr);
-#endif
+static void __iomem * autcpu12_fio_base;
 
 /*
  * Define partitions for flash devices
@@ -150,7 +140,7 @@
 	}
 
 	/* map physical adress */
-	autcpu12_fio_base=(unsigned long)ioremap(autcpu12_fio_pbase,SZ_1K);
+	autcpu12_fio_base = ioremap(autcpu12_fio_pbase,SZ_1K);
 	if(!autcpu12_fio_base){
 		printk("Ioremap autcpu12 SmartMedia Card failed\n");
 		err = -EIO;
diff -Nru a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
--- a/drivers/mtd/nand/diskonchip.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/mtd/nand/diskonchip.c	2004-12-24 13:36:32 -08:00
@@ -8,16 +8,22 @@
  * Author: David Woodhouse <dwmw2@infradead.org>
  * Additional Diskonchip 2000 and Millennium support by Dan Brown <dan_brown@ieee.org>
  * Diskonchip Millennium Plus support by Kalev Lember <kalev@smartlink.ee>
- *
+ * 
+ * Error correction code lifted from the old docecc code
+ * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 
+ * Copyright (C) 2000 Netgem S.A.
+ * converted to the generic Reed-Solomon library by Thomas Gleixner <tglx@linutronix.de>
+ *  
  * Interface to generic NAND code for M-Systems DiskOnChip devices
  *
- * $Id: diskonchip.c,v 1.34 2004/08/09 19:41:12 dbrown Exp $
+ * $Id: diskonchip.c,v 1.42 2004/11/16 18:29:03 dwmw2 Exp $
  */
 
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
+#include <linux/rslib.h>
 #include <asm/io.h>
 
 #include <linux/mtd/mtd.h>
@@ -62,7 +68,7 @@
 static struct mtd_info *doclist = NULL;
 
 struct doc_priv {
-	unsigned long virtadr;
+	void __iomem *virtadr;
 	unsigned long physadr;
 	u_char ChipID;
 	u_char CDSNControl;
@@ -96,28 +102,136 @@
 static void doc200x_select_chip(struct mtd_info *mtd, int chip);
 
 static int debug=0;
-MODULE_PARM(debug, "i");
+module_param(debug, int, 0);
 
 static int try_dword=1;
-MODULE_PARM(try_dword, "i");
+module_param(try_dword, int, 0);
 
 static int no_ecc_failures=0;
-MODULE_PARM(no_ecc_failures, "i");
+module_param(no_ecc_failures, int, 0);
 
+#ifdef CONFIG_MTD_PARTITIONS
 static int no_autopart=0;
-MODULE_PARM(no_autopart, "i");
+module_param(no_autopart, int, 0);
+#endif
 
 #ifdef MTD_NAND_DISKONCHIP_BBTWRITE
 static int inftl_bbt_write=1;
 #else
 static int inftl_bbt_write=0;
 #endif
-MODULE_PARM(inftl_bbt_write, "i");
+module_param(inftl_bbt_write, int, 0);
 
 static unsigned long doc_config_location = CONFIG_MTD_DISKONCHIP_PROBE_ADDRESS;
-MODULE_PARM(doc_config_location, "l");
+module_param(doc_config_location, ulong, 0);
 MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip");
 
+
+/* Sector size for HW ECC */
+#define SECTOR_SIZE 512
+/* The sector bytes are packed into NB_DATA 10 bit words */
+#define NB_DATA (((SECTOR_SIZE + 1) * 8 + 6) / 10)
+/* Number of roots */
+#define NROOTS 4
+/* First consective root */
+#define FCR 510
+/* Number of symbols */
+#define NN 1023
+
+/* the Reed Solomon control structure */
+static struct rs_control *rs_decoder;
+
+/* 
+ * The HW decoder in the DoC ASIC's provides us a error syndrome,
+ * which we must convert to a standard syndrom usable by the generic
+ * Reed-Solomon library code.
+ *
+ * Fabrice Bellard figured this out in the old docecc code. I added
+ * some comments, improved a minor bit and converted it to make use
+ * of the generic Reed-Solomon libary. tglx
+ */
+static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc)
+{
+	int i, j, nerr, errpos[8];
+	uint8_t parity;
+	uint16_t ds[4], s[5], tmp, errval[8], syn[4];
+
+	/* Convert the ecc bytes into words */
+	ds[0] = ((ecc[4] & 0xff) >> 0) | ((ecc[5] & 0x03) << 8);
+	ds[1] = ((ecc[5] & 0xfc) >> 2) | ((ecc[2] & 0x0f) << 6);
+	ds[2] = ((ecc[2] & 0xf0) >> 4) | ((ecc[3] & 0x3f) << 4);
+	ds[3] = ((ecc[3] & 0xc0) >> 6) | ((ecc[0] & 0xff) << 2);
+	parity = ecc[1];
+
+	/* Initialize the syndrom buffer */
+	for (i = 0; i < NROOTS; i++)
+		s[i] = ds[0];
+	/* 
+	 *  Evaluate 
+	 *  s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0]
+	 *  where x = alpha^(FCR + i)
+	 */
+	for(j = 1; j < NROOTS; j++) {
+		if(ds[j] == 0)
+			continue;
+		tmp = rs->index_of[ds[j]];
+		for(i = 0; i < NROOTS; i++)
+			s[i] ^= rs->alpha_to[rs_modnn(rs, tmp + (FCR + i) * j)];
+	}
+
+	/* Calc s[i] = s[i] / alpha^(v + i) */
+	for (i = 0; i < NROOTS; i++) {
+		if (syn[i])
+ 			syn[i] = rs_modnn(rs, rs->index_of[s[i]] + (NN - FCR - i));
+	}
+	/* Call the decoder library */
+	nerr = decode_rs16(rs, NULL, NULL, 1019, syn, 0, errpos, 0, errval);
+
+	/* Incorrectable errors ? */
+	if (nerr < 0)
+		return nerr;
+
+	/* 
+	 * Correct the errors. The bitpositions are a bit of magic,
+	 * but they are given by the design of the de/encoder circuit
+	 * in the DoC ASIC's.
+	 */
+	for(i = 0;i < nerr; i++) {
+		int index, bitpos, pos = 1015 - errpos[i];
+		uint8_t val;
+		if (pos >= NB_DATA && pos < 1019)
+			continue;
+		if (pos < NB_DATA) {
+			/* extract bit position (MSB first) */
+			pos = 10 * (NB_DATA - 1 - pos) - 6;
+			/* now correct the following 10 bits. At most two bytes
+			   can be modified since pos is even */
+			index = (pos >> 3) ^ 1;
+			bitpos = pos & 7;
+			if ((index >= 0 && index < SECTOR_SIZE) || 
+			    index == (SECTOR_SIZE + 1)) {
+				val = (uint8_t) (errval[i] >> (2 + bitpos));
+				parity ^= val;
+				if (index < SECTOR_SIZE)
+					data[index] ^= val;
+			}
+			index = ((pos >> 3) + 1) ^ 1;
+			bitpos = (bitpos + 10) & 7;
+			if (bitpos == 0)
+				bitpos = 8;
+			if ((index >= 0 && index < SECTOR_SIZE) || 
+			    index == (SECTOR_SIZE + 1)) {
+				val = (uint8_t)(errval[i] << (8 - bitpos));
+				parity ^= val;
+				if (index < SECTOR_SIZE)
+					data[index] ^= val;
+			}
+		}
+	}
+	/* If the parity is wrong, no rescue possible */
+	return parity ? -1 : nerr;
+}
+
 static void DoC_Delay(struct doc_priv *doc, unsigned short cycles)
 {
 	volatile char dummy;
@@ -139,7 +253,7 @@
 /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
 static int _DoC_WaitReady(struct doc_priv *doc)
 {
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	unsigned long timeo = jiffies + (HZ * 10);
 
 	if(debug) printk("_DoC_WaitReady...\n");
@@ -169,7 +283,7 @@
 
 static inline int DoC_WaitReady(struct doc_priv *doc)
 {
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int ret = 0;
 
 	if (DoC_is_MillenniumPlus(doc)) {
@@ -195,7 +309,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 
 	if(debug)printk("write_byte %02x\n", datum);
 	WriteDOC(datum, docptr, CDSNSlowIO);
@@ -206,7 +320,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	u_char ret;
 
 	ReadDOC(docptr, CDSNSlowIO);
@@ -221,7 +335,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 	if (debug)printk("writebuf of %d bytes: ", len);
 	for (i=0; i < len; i++) {
@@ -237,7 +351,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
  	int i;
 
 	if (debug)printk("readbuf of %d bytes: ", len);
@@ -252,7 +366,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
  	int i;
 
 	if (debug) printk("readbuf_dword of %d bytes: ", len);
@@ -273,7 +387,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 
 	for (i=0; i < len; i++)
@@ -305,7 +419,7 @@
 			uint32_t dword;
 			uint8_t byte[4];
 		} ident;
-		unsigned long docptr = doc->virtadr;
+		void __iomem *docptr = doc->virtadr;
 
 		doc200x_hwcontrol(mtd, NAND_CTL_SETCLE);
 		doc2000_write_byte(mtd, NAND_CMD_READID);
@@ -364,7 +478,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 
 	WriteDOC(datum, docptr, CDSNSlowIO);
 	WriteDOC(datum, docptr, Mil_CDSN_IO);
@@ -375,7 +489,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 
 	//ReadDOC(docptr, CDSNSlowIO);
 	/* 11.4.5 -- delay twice to allow extended length cycle */
@@ -390,7 +504,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 
 	for (i=0; i < len; i++)
@@ -404,7 +518,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 
 	/* Start read pipeline */
@@ -422,7 +536,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 
 	/* Start read pipeline */
@@ -442,7 +556,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	u_char ret;
 
         ReadDOC(docptr, Mplus_ReadPipeInit);
@@ -457,7 +571,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 
 	if (debug)printk("writebuf of %d bytes: ", len);
@@ -474,7 +588,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 
 	if (debug)printk("readbuf of %d bytes: ", len);
@@ -504,7 +618,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 
 	if (debug)printk("verifybuf of %d bytes: ", len);
@@ -530,7 +644,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int floor = 0;
 
 	if(debug)printk("select chip (%d)\n", chip);
@@ -556,7 +670,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int floor = 0;
 
 	if(debug)printk("select chip (%d)\n", chip);
@@ -583,7 +697,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 
 	switch(cmd) {
 	case NAND_CTL_SETNCE:
@@ -621,7 +735,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 
 	/*
 	 * Must terminate write pipeline before sending any commands
@@ -725,7 +839,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 
 	if (DoC_is_MillenniumPlus(doc)) {
 		/* 11.4.2 -- must NOP four times before checking FR/B# */
@@ -763,7 +877,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 
 	/* Prime the ECC engine */
 	switch(mode) {
@@ -782,7 +896,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 
 	/* Prime the ECC engine */
 	switch(mode) {
@@ -803,7 +917,7 @@
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	int i;
 	int emptymatch = 1;
 
@@ -861,7 +975,7 @@
 	int i, ret = 0;
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
-	unsigned long docptr = doc->virtadr;
+        void __iomem *docptr = doc->virtadr;
 	volatile u_char dummy;
 	int emptymatch = 1;
 	
@@ -914,7 +1028,7 @@
 		   erased block, in which case the ECC will not come out right.
 		   We'll suppress the error and tell the caller everything's
 		   OK.  Because it is. */
-		if (!emptymatch) ret = doc_decode_ecc (dat, calc_ecc);
+		if (!emptymatch) ret = doc_ecc_decode (rs_decoder, dat, calc_ecc);
 		if (ret > 0)
 			printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret);
 	}	
@@ -1385,13 +1499,13 @@
 	struct mtd_info *mtd;
 	struct nand_chip *nand;
 	struct doc_priv *doc;
-	unsigned long virtadr;
+	void __iomem *virtadr;
 	unsigned char save_control;
 	unsigned char tmp, tmpb, tmpc;
 	int reg, len, numchips;
 	int ret = 0;
 
-	virtadr = (unsigned long)ioremap(physadr, DOC_IOREMAP_LEN);
+	virtadr = ioremap(physadr, DOC_IOREMAP_LEN);
 	if (!virtadr) {
 		printk(KERN_ERR "Diskonchip ioremap failed: 0x%x bytes at 0x%lx\n", DOC_IOREMAP_LEN, physadr);
 		return -EIO;
@@ -1518,7 +1632,7 @@
 	      sizeof(struct nand_chip) +
 	      sizeof(struct doc_priv) +
 	      (2 * sizeof(struct nand_bbt_descr));
-	mtd = kmalloc(len, GFP_KERNEL);
+	mtd =  kmalloc(len, GFP_KERNEL);
 	if (!mtd) {
 		printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len);
 		ret = -ENOMEM;
@@ -1543,7 +1657,7 @@
 	nand->enable_hwecc	= doc200x_enable_hwecc;
 	nand->calculate_ecc	= doc200x_calculate_ecc;
 	nand->correct_data	= doc200x_correct_data;
-	//nand->data_buf
+
 	nand->autooob		= &doc200x_oobinfo;
 	nand->eccmode		= NAND_ECC_HW6_512;
 	nand->options		= NAND_USE_FLASH_BBT | NAND_HWECC_SYNDROME;
@@ -1589,13 +1703,47 @@
 	return ret;
 }
 
-int __init init_nanddoc(void)
+static void release_nanddoc(void)
 {
-	int i;
+ 	struct mtd_info *mtd, *nextmtd;
+	struct nand_chip *nand;
+	struct doc_priv *doc;
+
+	for (mtd = doclist; mtd; mtd = nextmtd) {
+		nand = mtd->priv;
+		doc = (void *)nand->priv;
+
+		nextmtd = doc->nextdoc;
+		nand_release(mtd);
+		iounmap((void *)doc->virtadr);
+		kfree(mtd);
+	}
+}
+
+static int __init init_nanddoc(void)
+{
+	int i, ret = 0;
+
+	/* We could create the decoder on demand, if memory is a concern.
+	 * This way we have it handy, if an error happens 
+	 *
+	 * Symbolsize is 10 (bits)
+	 * Primitve polynomial is x^10+x^3+1
+	 * first consecutive root is 510
+	 * primitve element to generate roots = 1
+	 * generator polinomial degree = 4
+	 */
+	rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS);
+ 	if (!rs_decoder) {
+		printk (KERN_ERR "DiskOnChip: Could not create a RS decoder\n");
+		return -ENOMEM;
+	}
 
 	if (doc_config_location) {
 		printk(KERN_INFO "Using configured DiskOnChip probe address 0x%lx\n", doc_config_location);
-		return doc_probe(doc_config_location);
+		ret = doc_probe(doc_config_location);
+		if (ret < 0)
+			goto outerr;
 	} else {
 		for (i=0; (doc_locations[i] != 0xffffffff); i++) {
 			doc_probe(doc_locations[i]);
@@ -1605,25 +1753,23 @@
 	   found, so the user knows we at least tried. */
 	if (!doclist) {
 		printk(KERN_INFO "No valid DiskOnChip devices found\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto outerr;
 	}
 	return 0;
+outerr:
+	free_rs(rs_decoder);
+	return ret;
 }
 
-void __exit cleanup_nanddoc(void)
+static void __exit cleanup_nanddoc(void)
 {
-	struct mtd_info *mtd, *nextmtd;
-	struct nand_chip *nand;
-	struct doc_priv *doc;
+	/* Cleanup the nand/DoC resources */
+	release_nanddoc();
 
-	for (mtd = doclist; mtd; mtd = nextmtd) {
-		nand = mtd->priv;
-		doc = (void *)nand->priv;
-
-		nextmtd = doc->nextdoc;
-		nand_release(mtd);
-		iounmap((void *)doc->virtadr);
-		kfree(mtd);
+	/* Free the reed solomon resources */
+	if (rs_decoder) {
+		free_rs(rs_decoder);
 	}
 }
 
diff -Nru a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
--- a/drivers/mtd/nand/edb7312.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/mtd/nand/edb7312.c	2004-12-24 13:37:30 -08:00
@@ -6,7 +6,7 @@
  *  Derived from drivers/mtd/nand/autcpu12.c
  *       Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
  *
- * $Id: edb7312.c,v 1.8 2004/07/12 15:03:26 dwmw2 Exp $
+ * $Id: edb7312.c,v 1.11 2004/11/04 12:53:10 gleixner Exp $
  *
  * 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
@@ -53,19 +53,9 @@
  * Module stuff
  */
 
-static int ep7312_fio_pbase = EP7312_FIO_PBASE;
-static int ep7312_pxdr = EP7312_PXDR;
-static int ep7312_pxddr = EP7312_PXDDR;
-
-#ifdef MODULE
-MODULE_PARM(ep7312_fio_pbase, "i");
-MODULE_PARM(ep7312_pxdr, "i");
-MODULE_PARM(ep7312_pxddr, "i");
-
-__setup("ep7312_fio_pbase=",ep7312_fio_pbase);
-__setup("ep7312_pxdr=",ep7312_pxdr);
-__setup("ep7312_pxddr=",ep7312_pxddr);
-#endif
+static unsigned long ep7312_fio_pbase = EP7312_FIO_PBASE;
+static void __iomem * ep7312_pxdr = (void __iomem *) EP7312_PXDR;
+static void __iomem * ep7312_pxddr = (void __iomem *) EP7312_PXDDR;
 
 #ifdef CONFIG_MTD_PARTITIONS
 /*
@@ -131,7 +121,7 @@
 	const char *part_type = 0;
 	int mtd_parts_nb = 0;
 	struct mtd_partition *mtd_parts = 0;
-	int ep7312_fio_base;
+	void __iomem * ep7312_fio_base;
 	
 	/* Allocate memory for MTD device structure and private data */
 	ep7312_mtd = kmalloc(sizeof(struct mtd_info) + 
@@ -143,7 +133,7 @@
 	}
 	
 	/* map physical adress */
-	ep7312_fio_base = (unsigned long)ioremap(ep7312_fio_pbase, SZ_1K);
+	ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K);
 	if(!ep7312_fio_base) {
 		printk("ioremap EDB7312 NAND flash failed\n");
 		kfree(ep7312_mtd);
@@ -181,16 +171,7 @@
 		return -ENXIO;
 	}
 	
-	/* Allocate memory for internal data buffer */
-	this->data_buf = kmalloc (sizeof(u_char) * (ep7312_mtd->oobblock + ep7312_mtd->oobsize), GFP_KERNEL);
-	if (!this->data_buf) {
-		printk("Unable to allocate NAND data buffer for EDB7312.\n");
-		iounmap((void *)ep7312_fio_base);
-		kfree (ep7312_mtd);
-		return -ENOMEM;
-	}
-	
-#ifdef CONFIG_PARTITIONS
+#ifdef CONFIG_MTD_PARTITIONS
 	ep7312_mtd->name = "edb7312-nand";
 	mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes,
 					    &mtd_parts, 0);
@@ -221,8 +202,8 @@
 {
 	struct nand_chip *this = (struct nand_chip *) &ep7312_mtd[1];
 	
-	/* Unregister the device */
-	del_mtd_device (ep7312_mtd);
+	/* Release resources, unregister device */
+	nand_release (ap7312_mtd);
 	
 	/* Free internal data buffer */
 	kfree (this->data_buf);
diff -Nru a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mtd/nand/h1910.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,208 @@
+/*
+ *  drivers/mtd/nand/h1910.c
+ *
+ *  Copyright (C) 2003 Joshua Wise (joshua@joshuawise.com)
+ *
+ *  Derived from drivers/mtd/nand/edb7312.c
+ *       Copyright (C) 2002 Marius Gröger (mag@sysgo.de)
+ *       Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
+ *
+ * $Id: h1910.c,v 1.5 2004/11/04 12:53:10 gleixner Exp $
+ *
+ * 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.
+ *
+ *  Overview:
+ *   This is a device driver for the NAND flash device found on the
+ *   iPAQ h1910 board which utilizes the Samsung K9F2808 part. This is
+ *   a 128Mibit (16MiB x 8 bits) NAND flash device.
+ */
+
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/partitions.h>
+#include <asm/io.h>
+#include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */
+#include <asm/sizes.h>
+#include <asm/arch/h1900-gpio.h>
+#include <asm/arch/ipaq.h>
+
+/*
+ * MTD structure for EDB7312 board
+ */
+static struct mtd_info *h1910_nand_mtd = NULL;
+
+/*
+ * Module stuff
+ */
+
+#ifdef CONFIG_MTD_PARTITIONS
+/*
+ * Define static partitions for flash device
+ */
+static struct mtd_partition partition_info[] = {
+	{ name: "h1910 NAND Flash",
+		  offset: 0,
+		  size: 16*1024*1024 }
+};
+#define NUM_PARTITIONS 1
+
+#endif
+
+
+/* 
+ *	hardware specific access to control-lines
+ */
+static void h1910_hwcontrol(struct mtd_info *mtd, int cmd) 
+{
+	struct nand_chip* this = (struct nand_chip *) (mtd->priv);
+	
+	switch(cmd) {
+		
+	case NAND_CTL_SETCLE: 
+		this->IO_ADDR_R |= (1 << 2);
+		this->IO_ADDR_W |= (1 << 2);
+		break;
+	case NAND_CTL_CLRCLE: 
+		this->IO_ADDR_R &= ~(1 << 2);
+		this->IO_ADDR_W &= ~(1 << 2);
+		break;
+		
+	case NAND_CTL_SETALE:
+		this->IO_ADDR_R |= (1 << 3);
+		this->IO_ADDR_W |= (1 << 3);
+		break;
+	case NAND_CTL_CLRALE:
+		this->IO_ADDR_R &= ~(1 << 3);
+		this->IO_ADDR_W &= ~(1 << 3);
+		break;
+		
+	case NAND_CTL_SETNCE:
+		break;
+	case NAND_CTL_CLRNCE:
+		break;
+	}
+}
+
+/*
+ *	read device ready pin
+ */
+#if 0
+static int h1910_device_ready(struct mtd_info *mtd)
+{
+	return (GPLR(55) & GPIO_bit(55));
+}
+#endif
+
+/*
+ * Main initialization routine
+ */
+static int __init h1910_init (void)
+{
+	struct nand_chip *this;
+	const char *part_type = 0;
+	int mtd_parts_nb = 0;
+	struct mtd_partition *mtd_parts = 0;
+	void __iomem *nandaddr;
+	
+	if (!machine_is_h1900())
+		return -ENODEV;
+		
+	nandaddr = __ioremap(0x08000000, 0x1000, 0, 1);
+	if (!nandaddr) {
+		printk("Failed to ioremap nand flash.\n");
+		return -ENOMEM;
+	}
+	
+	/* Allocate memory for MTD device structure and private data */
+	h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + 
+			     sizeof(struct nand_chip),
+			     GFP_KERNEL);
+	if (!h1910_nand_mtd) {
+		printk("Unable to allocate h1910 NAND MTD device structure.\n");
+		iounmap ((void *) nandaddr);
+		return -ENOMEM;
+	}
+	
+	/* Get pointer to private data */
+	this = (struct nand_chip *) (&h1910_nand_mtd[1]);
+	
+	/* Initialize structures */
+	memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info));
+	memset((char *) this, 0, sizeof(struct nand_chip));
+	
+	/* Link the private data with the MTD structure */
+	h1910_nand_mtd->priv = this;
+	
+	/*
+	 * Enable VPEN
+	 */
+	GPSR(37) = GPIO_bit(37);
+	
+	/* insert callbacks */
+	this->IO_ADDR_R = nandaddr;
+	this->IO_ADDR_W = nandaddr;
+	this->hwcontrol = h1910_hwcontrol;
+	this->dev_ready = NULL;	/* unknown whether that was correct or not so we will just do it like this */
+	/* 15 us command delay time */
+	this->chip_delay = 50;
+	this->eccmode = NAND_ECC_SOFT;
+	this->options = NAND_NO_AUTOINCR;
+	
+	/* Scan to find existence of the device */
+	if (nand_scan (h1910_nand_mtd, 1)) {
+		printk(KERN_NOTICE "No NAND device - returning -ENXIO\n");
+		kfree (h1910_nand_mtd);
+		iounmap ((void *) nandaddr);
+		return -ENXIO;
+	}
+	
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+	mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, 
+						"h1910-nand");
+	if (mtd_parts_nb > 0)
+	  part_type = "command line";
+	else
+	  mtd_parts_nb = 0;
+#endif
+	if (mtd_parts_nb == 0)
+	{
+		mtd_parts = partition_info;
+		mtd_parts_nb = NUM_PARTITIONS;
+		part_type = "static";
+	}
+	
+	/* Register the partitions */
+	printk(KERN_NOTICE "Using %s partition definition\n", part_type);
+	add_mtd_partitions(h1910_nand_mtd, mtd_parts, mtd_parts_nb);
+	
+	/* Return happy */
+	return 0;
+}
+module_init(h1910_init);
+
+/*
+ * Clean up routine
+ */
+static void __exit h1910_cleanup (void)
+{
+	struct nand_chip *this = (struct nand_chip *) &h1910_nand_mtd[1];
+	
+	/* Release resources, unregister device */
+	nand_release (h1910_nand_mtd);
+
+	/* Release io resource */
+	iounmap ((void *) this->IO_ADDR_W);
+
+	/* Free the MTD device structure */
+	kfree (h1910_nand_mtd);
+}
+module_exit(h1910_cleanup);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Joshua Wise <joshua at joshuawise dot com>");
+MODULE_DESCRIPTION("NAND flash driver for iPAQ h1910");
diff -Nru a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
--- a/drivers/mtd/nand/nand_base.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/mtd/nand/nand_base.c	2004-12-24 13:37:43 -08:00
@@ -24,6 +24,10 @@
  *  
  *  05-19-2004  tglx: Basic support for Renesas AG-AND chips
  *
+ *  09-24-2004  tglx: add support for hardware controllers (e.g. ECC) shared
+ *		among multiple independend devices. Suggestions and initial patch
+ *		from Ben Dooks <ben-mtd@fluff.org>
+ *
  * Credits:
  *	David Woodhouse for adding multichip support  
  *	
@@ -37,7 +41,7 @@
  *	The AG-AND chips have nice features for speed improvement,
  *	which are not supported yet. Read / program 4 pages in one go.
  *
- * $Id: nand_base.c,v 1.115 2004/08/09 13:19:45 dwmw2 Exp $
+ * $Id: nand_base.c,v 1.121 2004/10/06 19:53:11 gleixner Exp $
  *
  * 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
@@ -131,25 +135,31 @@
 #define nand_verify_pages(...) (0)
 #endif
 		
-static void nand_get_chip (struct nand_chip *this, struct mtd_info *mtd, int new_state);
+static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state);
 
 /**
- * nand_release_chip - [GENERIC] release chip
+ * nand_release_device - [GENERIC] release chip
  * @mtd:	MTD device structure
  * 
  * Deselect, release chip lock and wake up anyone waiting on the device 
  */
-static void nand_release_chip (struct mtd_info *mtd)
+static void nand_release_device (struct mtd_info *mtd)
 {
 	struct nand_chip *this = mtd->priv;
 
 	/* De-select the NAND device */
 	this->select_chip(mtd, -1);
+	/* Do we have a hardware controller ? */
+	if (this->controller) {
+		spin_lock(&this->controller->lock);
+		this->controller->active = NULL;
+		spin_unlock(&this->controller->lock);
+	}
 	/* Release the chip */
-	spin_lock_bh (&this->chip_lock);
+	spin_lock (&this->chip_lock);
 	this->state = FL_READY;
 	wake_up (&this->wq);
-	spin_unlock_bh (&this->chip_lock);
+	spin_unlock (&this->chip_lock);
 }
 
 /**
@@ -388,7 +398,7 @@
 		chipnr = (int)(ofs >> this->chip_shift);
 
 		/* Grab the lock and see if the device is available */
-		nand_get_chip (this, mtd, FL_READING);
+		nand_get_device (this, mtd, FL_READING);
 
 		/* Select the NAND device */
 		this->select_chip(mtd, chipnr);
@@ -410,7 +420,7 @@
 		
 	if (getchip) {
 		/* Deselect and wake up anyone waiting on the device */
-		nand_release_chip(mtd);
+		nand_release_device(mtd);
 	}	
 	
 	return res;
@@ -533,8 +543,8 @@
 		if (page_addr != -1) {
 			this->write_byte(mtd, (unsigned char) (page_addr & 0xff));
 			this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff));
-			/* One more address cycle for higher density devices */
-			if (this->chipsize & 0x0c000000) 
+			/* One more address cycle for devices > 32MiB */
+			if (this->chipsize > (32 << 20))
 				this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0x0f));
 		}
 		/* Latch in address */
@@ -689,15 +699,16 @@
 }
 
 /**
- * nand_get_chip - [GENERIC] Get chip for selected access
+ * nand_get_device - [GENERIC] Get chip for selected access
  * @this:	the nand chip descriptor
  * @mtd:	MTD device structure
  * @new_state:	the state which is requested 
  *
  * Get the device and lock it for exclusive access
  */
-static void nand_get_chip (struct nand_chip *this, struct mtd_info *mtd, int new_state)
+static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
 {
+	struct nand_chip *active = this;
 
 	DECLARE_WAITQUEUE (wait, current);
 
@@ -705,19 +716,29 @@
 	 * Grab the lock and see if the device is available 
 	*/
 retry:
-	spin_lock_bh (&this->chip_lock);
-
-	if (this->state == FL_READY) {
-		this->state = new_state;
-		spin_unlock_bh (&this->chip_lock);
-		return;
+	/* Hardware controller shared among independend devices */
+	if (this->controller) {
+		spin_lock (&this->controller->lock);
+		if (this->controller->active)
+			active = this->controller->active;
+		else
+			this->controller->active = this;
+		spin_unlock (&this->controller->lock);
 	}
-
+	
+	if (active == this) {
+		spin_lock (&this->chip_lock);
+		if (this->state == FL_READY) {
+			this->state = new_state;
+			spin_unlock (&this->chip_lock);
+			return;
+		}
+	}	
 	set_current_state (TASK_UNINTERRUPTIBLE);
-	add_wait_queue (&this->wq, &wait);
-	spin_unlock_bh (&this->chip_lock);
+	add_wait_queue (&active->wq, &wait);
+	spin_unlock (&active->chip_lock);
 	schedule ();
-	remove_wait_queue (&this->wq, &wait);
+	remove_wait_queue (&active->wq, &wait);
 	goto retry;
 }
 
@@ -747,7 +768,6 @@
 	 * any case on any machine. */
 	ndelay (100);
 
-	spin_lock_bh (&this->chip_lock);
 	if ((state == FL_ERASING) && (this->options & NAND_IS_AND))
 		this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1);
 	else	
@@ -755,24 +775,19 @@
 
 	while (time_before(jiffies, timeo)) {		
 		/* Check, if we were interrupted */
-		if (this->state != state) {
-			spin_unlock_bh (&this->chip_lock);
+		if (this->state != state)
 			return 0;
-		}
+
 		if (this->dev_ready) {
 			if (this->dev_ready(mtd))
+				break;	
+		} else {
+			if (this->read_byte(mtd) & NAND_STATUS_READY)
 				break;
 		}
-		if (this->read_byte(mtd) & NAND_STATUS_READY)
-			break;
-						
-		spin_unlock_bh (&this->chip_lock);
 		yield ();
-		spin_lock_bh (&this->chip_lock);
 	}
 	status = (int) this->read_byte(mtd);
-	spin_unlock_bh (&this->chip_lock);
-
 	return status;
 }
 
@@ -1051,7 +1066,7 @@
 	}
 
 	/* Grab the lock and see if the device is available */
-	nand_get_chip (this, mtd ,FL_READING);
+	nand_get_device (this, mtd ,FL_READING);
 
 	/* use userspace supplied oobinfo, if zero */
 	if (oobsel == NULL)
@@ -1281,7 +1296,7 @@
 	}
 
 	/* Deselect and wake up anyone waiting on the device */
-	nand_release_chip(mtd);
+	nand_release_device(mtd);
 
 	/*
 	 * Return success, if no ECC failures, else -EBADMSG
@@ -1328,7 +1343,7 @@
 	}
 
 	/* Grab the lock and see if the device is available */
-	nand_get_chip (this, mtd , FL_READING);
+	nand_get_device (this, mtd , FL_READING);
 
 	/* Select the NAND device */
 	this->select_chip(mtd, chipnr);
@@ -1379,7 +1394,7 @@
 	}
 
 	/* Deselect and wake up anyone waiting on the device */
-	nand_release_chip(mtd);
+	nand_release_device(mtd);
 
 	/* Return happy */
 	*retlen = len;
@@ -1413,7 +1428,7 @@
 	}
 
 	/* Grab the lock and see if the device is available */
-	nand_get_chip (this, mtd , FL_READING);
+	nand_get_device (this, mtd , FL_READING);
 
 	this->select_chip (mtd, chip);
 	
@@ -1442,7 +1457,7 @@
 	}
 
 	/* Deselect and wake up anyone waiting on the device */
-	nand_release_chip(mtd);
+	nand_release_device(mtd);
 	return 0;
 }
 
@@ -1564,7 +1579,7 @@
 	}
 
 	/* Grab the lock and see if the device is available */
-	nand_get_chip (this, mtd, FL_WRITING);
+	nand_get_device (this, mtd, FL_WRITING);
 
 	/* Calculate chipnr */
 	chipnr = (int)(to >> this->chip_shift);
@@ -1669,7 +1684,7 @@
 
 out:
 	/* Deselect and wake up anyone waiting on the device */
-	nand_release_chip(mtd);
+	nand_release_device(mtd);
 
 	return ret;
 }
@@ -1709,7 +1724,7 @@
 	}
 
 	/* Grab the lock and see if the device is available */
-	nand_get_chip (this, mtd, FL_WRITING);
+	nand_get_device (this, mtd, FL_WRITING);
 
 	/* Select the NAND device */
 	this->select_chip(mtd, chipnr);
@@ -1771,7 +1786,7 @@
 	ret = 0;
 out:
 	/* Deselect and wake up anyone waiting on the device */
-	nand_release_chip(mtd);
+	nand_release_device(mtd);
 
 	return ret;
 }
@@ -1838,7 +1853,7 @@
 	}
 
 	/* Grab the lock and see if the device is available */
-	nand_get_chip (this, mtd, FL_WRITING);
+	nand_get_device (this, mtd, FL_WRITING);
 
 	/* Get the current chip-nr */
 	chipnr = (int) (to >> this->chip_shift);
@@ -1952,7 +1967,7 @@
 	ret = 0;
 out:
 	/* Deselect and wake up anyone waiting on the device */
-	nand_release_chip(mtd);
+	nand_release_device(mtd);
 
 	*retlen = written;
 	return ret;
@@ -2041,7 +2056,7 @@
 	instr->fail_addr = 0xffffffff;
 
 	/* Grab the lock and see if the device is available */
-	nand_get_chip (this, mtd, FL_ERASING);
+	nand_get_device (this, mtd, FL_ERASING);
 
 	/* Shift to get first page */
 	page = (int) (instr->addr >> this->page_shift);
@@ -2112,7 +2127,7 @@
 		mtd_erase_callback(instr);
 
 	/* Deselect and wake up anyone waiting on the device */
-	nand_release_chip(mtd);
+	nand_release_device(mtd);
 
 	/* Return more or less happy */
 	return ret;
@@ -2127,43 +2142,13 @@
 static void nand_sync (struct mtd_info *mtd)
 {
 	struct nand_chip *this = mtd->priv;
-	DECLARE_WAITQUEUE (wait, current);
 
 	DEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n");
 
-retry:
-	/* Grab the spinlock */
-	spin_lock_bh (&this->chip_lock);
-
-	/* See what's going on */
-	switch (this->state) {
-	case FL_READY:
-	case FL_SYNCING:
-		this->state = FL_SYNCING;
-		spin_unlock_bh (&this->chip_lock);
-		break;
-
-	default:
-		/* Not an idle state */
-		add_wait_queue (&this->wq, &wait);
-		spin_unlock_bh (&this->chip_lock);
-		schedule ();
-
-		remove_wait_queue (&this->wq, &wait);
-		goto retry;
-	}
-
-	/* Lock the device */
-	spin_lock_bh (&this->chip_lock);
-
-	/* Set the device to be ready again */
-	if (this->state == FL_SYNCING) {
-		this->state = FL_READY;
-		wake_up (&this->wq);
-	}
-
-	/* Unlock the device */
-	spin_unlock_bh (&this->chip_lock);
+	/* Grab the lock and see if the device is available */
+	nand_get_device (this, mtd, FL_SYNCING);
+	/* Release it and go back */
+	nand_release_device (mtd);
 }
 
 
diff -Nru a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
--- a/drivers/mtd/nand/nand_bbt.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/mtd/nand/nand_bbt.c	2004-12-24 13:36:55 -08:00
@@ -6,7 +6,7 @@
  *   
  *  Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
  *
- * $Id: nand_bbt.c,v 1.24 2004/06/28 08:25:35 gleixner Exp $
+ * $Id: nand_bbt.c,v 1.26 2004/10/05 13:50:20 gleixner Exp $
  *
  * 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
@@ -114,6 +114,7 @@
  * @num:	the number of bbt descriptors to read
  * @bits:	number of bits per block
  * @offs:	offset in the memory table
+ * @reserved_block_code:	Pattern to identify reserved blocks
  *
  * Read the bad block table starting from page.
  *
@@ -796,7 +797,7 @@
 
 	len = mtd->size >> (this->bbt_erase_shift + 2);
 	/* Allocate memory (2bit per block) */
-	this->bbt = (uint8_t *) kmalloc (len, GFP_KERNEL);
+	this->bbt = kmalloc (len, GFP_KERNEL);
 	if (!this->bbt) {
 		printk (KERN_ERR "nand_scan_bbt: Out of memory\n");
 		return -ENOMEM;
diff -Nru a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c
--- a/drivers/mtd/nand/ppchameleonevb.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/mtd/nand/ppchameleonevb.c	2004-12-24 13:37:03 -08:00
@@ -6,7 +6,7 @@
  *  Derived from drivers/mtd/nand/edb7312.c
  *
  *
- * $Id: ppchameleonevb.c,v 1.2 2004/05/05 22:09:54 gleixner Exp $
+ * $Id: ppchameleonevb.c,v 1.6 2004/11/05 16:07:16 kalev Exp $
  *
  * 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
@@ -64,22 +64,17 @@
 /*
  * Module stuff
  */
-static int ppchameleon_fio_pbase 	= CFG_NAND0_PADDR;
-static int ppchameleonevb_fio_pbase = CFG_NAND1_PADDR;
+static unsigned long ppchameleon_fio_pbase 	= CFG_NAND0_PADDR;
+static unsigned long ppchameleonevb_fio_pbase = CFG_NAND1_PADDR;
 
 #ifdef MODULE
-MODULE_PARM(ppchameleon_fio_pbase, "i");
+module_param(ppchameleon_fio_pbase, ulong, 0);
+module_param(ppchameleonevb_fio_pbase, ulong, 0);
+#else
 __setup("ppchameleon_fio_pbase=",ppchameleon_fio_pbase);
-MODULE_PARM(ppchameleonevb_fio_pbase, "i");
 __setup("ppchameleonevb_fio_pbase=",ppchameleonevb_fio_pbase);
 #endif
 
-/* Internal buffers. Page buffer and oob buffer for one block */
-static u_char data_buf[2048 + 64];
-static u_char oob_buf[64 * 64];
-static u_char data_buf_evb[512 + 16];
-static u_char oob_buf_evb[16 * 32];
-
 #ifdef CONFIG_MTD_PARTITIONS
 /*
  * Define static partitions for flash devices
@@ -196,8 +191,8 @@
 	const char *part_type = 0;
 	int mtd_parts_nb = 0;
 	struct mtd_partition *mtd_parts = 0;
-	int ppchameleon_fio_base;
-	int ppchameleonevb_fio_base;
+	void __iomem *ppchameleon_fio_base;
+	void __iomem *ppchameleonevb_fio_base;
 
 
 	/*********************************
@@ -205,15 +200,14 @@
 	*********************************/
 	/* Allocate memory for MTD device structure and private data */
 	ppchameleon_mtd = kmalloc(sizeof(struct mtd_info) +
-			     sizeof(struct nand_chip),
-			     GFP_KERNEL);
+						      sizeof(struct nand_chip), GFP_KERNEL);
 	if (!ppchameleon_mtd) {
 		printk("Unable to allocate PPChameleon NAND MTD device structure.\n");
 		return -ENOMEM;
 	}
 
 	/* map physical address */
-	ppchameleon_fio_base = (unsigned long)ioremap(ppchameleon_fio_pbase, SZ_4M);
+	ppchameleon_fio_base = ioremap(ppchameleon_fio_pbase, SZ_4M);
 	if(!ppchameleon_fio_base) {
 		printk("ioremap PPChameleon NAND flash failed\n");
 		kfree(ppchameleon_mtd);
@@ -264,10 +258,6 @@
 	/* ECC mode */
 	this->eccmode = NAND_ECC_SOFT;
 
-	/* Set internal data buffer */
-	this->data_buf = data_buf;
-	this->oob_buf = oob_buf;
-
 	/* Scan to find existence of the device (it could not be mounted) */
 	if (nand_scan (ppchameleon_mtd, 1)) {
 		iounmap((void *)ppchameleon_fio_base);
@@ -309,15 +299,14 @@
 	****************************/
 	/* Allocate memory for MTD device structure and private data */
 	ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) +
-			     sizeof(struct nand_chip),
-			     GFP_KERNEL);
+							 sizeof(struct nand_chip), GFP_KERNEL);
 	if (!ppchameleonevb_mtd) {
 		printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n");
 		return -ENOMEM;
 	}
 
 	/* map physical address */
-	ppchameleonevb_fio_base = (unsigned long)ioremap(ppchameleonevb_fio_pbase, SZ_4M);
+	ppchameleonevb_fio_base = ioremap(ppchameleonevb_fio_pbase, SZ_4M);
 	if(!ppchameleonevb_fio_base) {
 		printk("ioremap PPChameleonEVB NAND flash failed\n");
 		kfree(ppchameleonevb_mtd);
@@ -349,7 +338,8 @@
 	out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xFFFFFFF0);
 	out_be32((volatile unsigned*)GPIO0_TSRL, in_be32((volatile unsigned*)GPIO0_TSRL) & 0x3FFFFFFF);
 	/* enable output driver */
-	out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_EVB_nCE_GPIO_PIN | NAND_EVB_CLE_GPIO_PIN | NAND_EVB_ALE_GPIO_PIN);
+	out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_EVB_nCE_GPIO_PIN | 
+		 NAND_EVB_CLE_GPIO_PIN | NAND_EVB_ALE_GPIO_PIN);
 #ifdef USE_READY_BUSY_PIN
 	/* three-state select */
 	out_be32((volatile unsigned*)GPIO0_TSRL, in_be32((volatile unsigned*)GPIO0_TSRL) & 0xFFFFFFFC);
@@ -359,7 +349,6 @@
 	out_be32((volatile unsigned*)GPIO0_ISR1L, (in_be32((volatile unsigned*)GPIO0_ISR1L) & 0xFFFFFFFC) | 0x00000001);
 #endif
 
-
 	/* insert callbacks */
 	this->IO_ADDR_R = ppchameleonevb_fio_base;
 	this->IO_ADDR_W = ppchameleonevb_fio_base;
@@ -372,10 +361,6 @@
 	/* ECC mode */
 	this->eccmode = NAND_ECC_SOFT;
 
-	/* Set internal data buffer */
-	this->data_buf = data_buf_evb;
-	this->oob_buf = oob_buf_evb;
-
 	/* Scan to find existence of the device */
 	if (nand_scan (ppchameleonevb_mtd, 1)) {
 		iounmap((void *)ppchameleonevb_fio_base);
@@ -412,15 +397,20 @@
  */
 static void __exit ppchameleonevb_cleanup (void)
 {
-	struct nand_chip *this = (struct nand_chip *) &ppchameleonevb_mtd[1];
-
-	/* Unregister the device */
-	del_mtd_device (ppchameleonevb_mtd);
+	struct nand_chip *this;
 
-	/* Free internal data buffer */
-	kfree (this->data_buf);
+	/* Release resources, unregister device(s) */
+	nand_release (ppchameleon_mtd);
+	nand_release (ppchameleonevb_mtd);
+	
+	/* Release iomaps */
+	this = (struct nand_chip *) &ppchameleon_mtd[1];
+	iounmap((void *) this->IO_ADDR_R;
+	this = (struct nand_chip *) &ppchameleonevb_mtd[1];
+	iounmap((void *) this->IO_ADDR_R;
 
 	/* Free the MTD device structure */
+	kfree (ppchameleon_mtd);
 	kfree (ppchameleonevb_mtd);
 }
 module_exit(ppchameleonevb_cleanup);
diff -Nru a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mtd/nand/rtc_from4.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,559 @@
+/*
+ *  drivers/mtd/nand/rtc_from4.c
+ *
+ *  Copyright (C) 2004  Red Hat, Inc.
+ * 
+ *  Derived from drivers/mtd/nand/spia.c
+ *       Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * $Id: rtc_from4.c,v 1.7 2004/11/04 12:53:10 gleixner Exp $
+ *
+ * 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.
+ *
+ * Overview:
+ *   This is a device driver for the AG-AND flash device found on the
+ *   Renesas Technology Corp. Flash ROM 4-slot interface board (FROM_BOARD4), 
+ *   which utilizes the Renesas HN29V1G91T-30 part. 
+ *   This chip is a 1 GBibit (128MiB x 8 bits) AG-AND flash device.
+ */
+
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/rslib.h>
+#include <linux/module.h>
+#include <linux/mtd/compatmac.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/partitions.h>
+#include <asm/io.h>
+
+/*
+ * MTD structure for Renesas board
+ */
+static struct mtd_info *rtc_from4_mtd = NULL;
+
+#define RTC_FROM4_MAX_CHIPS	2
+
+/* HS77x9 processor register defines */
+#define SH77X9_BCR1	((volatile unsigned short *)(0xFFFFFF60))
+#define SH77X9_BCR2	((volatile unsigned short *)(0xFFFFFF62))
+#define SH77X9_WCR1	((volatile unsigned short *)(0xFFFFFF64))
+#define SH77X9_WCR2	((volatile unsigned short *)(0xFFFFFF66))
+#define SH77X9_MCR	((volatile unsigned short *)(0xFFFFFF68))
+#define SH77X9_PCR	((volatile unsigned short *)(0xFFFFFF6C))
+#define SH77X9_FRQCR	((volatile unsigned short *)(0xFFFFFF80))
+
+/*
+ * Values specific to the Renesas Technology Corp. FROM_BOARD4 (used with HS77x9 processor)
+ */
+/* Address where flash is mapped */
+#define RTC_FROM4_FIO_BASE	0x14000000
+
+/* CLE and ALE are tied to address lines 5 & 4, respectively */
+#define RTC_FROM4_CLE		(1 << 5)
+#define RTC_FROM4_ALE		(1 << 4)
+
+/* address lines A24-A22 used for chip selection */
+#define RTC_FROM4_NAND_ADDR_SLOT3	(0x00800000)
+#define RTC_FROM4_NAND_ADDR_SLOT4	(0x00C00000)
+#define RTC_FROM4_NAND_ADDR_FPGA	(0x01000000)
+/* mask address lines A24-A22 used for chip selection */
+#define RTC_FROM4_NAND_ADDR_MASK	(RTC_FROM4_NAND_ADDR_SLOT3 | RTC_FROM4_NAND_ADDR_SLOT4 | RTC_FROM4_NAND_ADDR_FPGA)
+
+/* FPGA status register for checking device ready (bit zero) */
+#define RTC_FROM4_FPGA_SR		(RTC_FROM4_NAND_ADDR_FPGA | 0x00000002)
+#define RTC_FROM4_DEVICE_READY		0x0001
+
+/* FPGA Reed-Solomon ECC Control register */
+
+#define RTC_FROM4_RS_ECC_CTL		(RTC_FROM4_NAND_ADDR_FPGA | 0x00000050)
+#define RTC_FROM4_RS_ECC_CTL_CLR	(1 << 7)
+#define RTC_FROM4_RS_ECC_CTL_GEN	(1 << 6)
+#define RTC_FROM4_RS_ECC_CTL_FD_E	(1 << 5)
+
+/* FPGA Reed-Solomon ECC code base */
+#define RTC_FROM4_RS_ECC		(RTC_FROM4_NAND_ADDR_FPGA | 0x00000060)
+#define RTC_FROM4_RS_ECCN		(RTC_FROM4_NAND_ADDR_FPGA | 0x00000080)
+
+/* FPGA Reed-Solomon ECC check register */
+#define RTC_FROM4_RS_ECC_CHK		(RTC_FROM4_NAND_ADDR_FPGA | 0x00000070)
+#define RTC_FROM4_RS_ECC_CHK_ERROR	(1 << 7)
+
+/* Undefine for software ECC */
+#define RTC_FROM4_HWECC	1
+
+/*
+ * Module stuff
+ */
+static void __iomem *rtc_from4_fio_base = P2SEGADDR(RTC_FROM4_FIO_BASE);
+
+const static struct mtd_partition partition_info[] = {
+        {
+                .name   = "Renesas flash partition 1",
+                .offset = 0,
+                .size   = MTDPART_SIZ_FULL
+        },
+};
+#define NUM_PARTITIONS 1
+
+/* 
+ *	hardware specific flash bbt decriptors
+ *	Note: this is to allow debugging by disabling 
+ *		NAND_BBT_CREATE and/or NAND_BBT_WRITE
+ *
+ */
+static uint8_t bbt_pattern[] = {'B', 'b', 't', '0' };
+static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' };
+
+static struct nand_bbt_descr rtc_from4_bbt_main_descr = {
+	.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
+		| NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+	.offs = 40,
+	.len = 4,
+	.veroffs = 44,
+	.maxblocks = 4,
+	.pattern = bbt_pattern
+};
+
+static struct nand_bbt_descr rtc_from4_bbt_mirror_descr = {
+	.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
+		| NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+	.offs = 40,
+	.len = 4,
+	.veroffs = 44,
+	.maxblocks = 4,
+	.pattern = mirror_pattern
+};
+
+
+
+#ifdef RTC_FROM4_HWECC
+
+/* the Reed Solomon control structure */
+static struct rs_control *rs_decoder;
+
+/* 
+ *      hardware specific Out Of Band information
+ */
+static struct nand_oobinfo rtc_from4_nand_oobinfo = {
+	.useecc = MTD_NANDECC_AUTOPLACE,
+	.eccbytes = 32,
+	.eccpos = {
+		 0,  1,  2,  3,  4,  5,  6,  7,
+		 8,  9, 10, 11, 12, 13, 14, 15,
+		16, 17, 18, 19, 20, 21, 22, 23,
+		24, 25, 26, 27, 28, 29, 30, 31},
+	.oobfree = { {32, 32} }
+};
+
+/* Aargh. I missed the reversed bit order, when I
+ * was talking to Renesas about the FPGA.
+ *
+ * The table is used for bit reordering and inversion
+ * of the ecc byte which we get from the FPGA
+ */
+static uint8_t revbits[256] = {
+        0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+        0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+        0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+        0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+        0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+        0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+        0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+        0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+        0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+        0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+        0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+        0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+        0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+        0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+        0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+        0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+        0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+        0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+        0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+        0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+        0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+        0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+        0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+        0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+        0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+        0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+        0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+        0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+        0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+        0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+        0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+        0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+#endif
+
+
+
+/* 
+ * rtc_from4_hwcontrol - hardware specific access to control-lines
+ * @mtd:	MTD device structure
+ * @cmd:	hardware control command
+ *
+ * Address lines (A5 and A4) are used to control Command and Address Latch 
+ * Enable on this board, so set the read/write address appropriately.
+ *
+ * Chip Enable is also controlled by the Chip Select (CS5) and 
+ * Address lines (A24-A22), so no action is required here.
+ *
+ */
+static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd)
+{
+	struct nand_chip* this = (struct nand_chip *) (mtd->priv);
+	
+	switch(cmd) {
+		
+	case NAND_CTL_SETCLE: 
+		this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_CLE);
+		break;
+	case NAND_CTL_CLRCLE: 
+		this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_CLE);
+		break;
+		
+	case NAND_CTL_SETALE:
+		this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_ALE);
+		break;
+	case NAND_CTL_CLRALE:
+		this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_ALE);
+		break;
+		
+	case NAND_CTL_SETNCE:
+		break;
+	case NAND_CTL_CLRNCE:
+		break;
+
+	}
+}
+
+
+/*
+ * rtc_from4_nand_select_chip - hardware specific chip select
+ * @mtd:	MTD device structure
+ * @chip:	Chip to select (0 == slot 3, 1 == slot 4)
+ *
+ * The chip select is based on address lines A24-A22.
+ * This driver uses flash slots 3 and 4 (A23-A22).
+ *
+ */
+static void rtc_from4_nand_select_chip(struct mtd_info *mtd, int chip)
+{
+        struct nand_chip *this = mtd->priv;
+
+	this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R & ~RTC_FROM4_NAND_ADDR_MASK);
+	this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_NAND_ADDR_MASK);
+
+        switch(chip) {
+
+        case 0:		/* select slot 3 chip */
+		this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT3);
+		this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT3);
+                break;
+        case 1:		/* select slot 4 chip */
+		this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT4);
+		this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT4);
+                break;
+
+        }
+}
+
+
+
+/*
+ * rtc_from4_nand_device_ready - hardware specific ready/busy check
+ * @mtd:	MTD device structure
+ *
+ * This board provides the Ready/Busy state in the status register
+ * of the FPGA.  Bit zero indicates the RDY(1)/BSY(0) signal.
+ *
+ */
+static int rtc_from4_nand_device_ready(struct mtd_info *mtd)
+{
+	unsigned short status;
+
+	status = *((volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_FPGA_SR));
+
+	return (status & RTC_FROM4_DEVICE_READY);
+
+}
+
+#ifdef RTC_FROM4_HWECC
+/*
+ * rtc_from4_enable_hwecc - hardware specific hardware ECC enable function
+ * @mtd:	MTD device structure
+ * @mode:	I/O mode; read or write
+ *
+ * enable hardware ECC for data read or write 
+ *
+ */
+static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode)
+{
+	volatile unsigned short * rs_ecc_ctl = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CTL);
+	unsigned short status;
+
+	switch (mode) {
+	    case NAND_ECC_READ :
+		status =  RTC_FROM4_RS_ECC_CTL_CLR 
+			| RTC_FROM4_RS_ECC_CTL_FD_E;
+
+		*rs_ecc_ctl = status;
+		break;
+
+	    case NAND_ECC_READSYN :
+		status =  0x00;
+
+		*rs_ecc_ctl = status;
+		break;
+
+	    case NAND_ECC_WRITE :
+		status =  RTC_FROM4_RS_ECC_CTL_CLR 
+			| RTC_FROM4_RS_ECC_CTL_GEN 
+			| RTC_FROM4_RS_ECC_CTL_FD_E;
+
+		*rs_ecc_ctl = status;
+		break;
+
+	    default:
+		BUG();
+		break;
+	}
+
+}
+
+/*
+ * rtc_from4_calculate_ecc - hardware specific code to read ECC code
+ * @mtd:	MTD device structure
+ * @dat:	buffer containing the data to generate ECC codes
+ * @ecc_code	ECC codes calculated
+ *
+ * The ECC code is calculated by the FPGA.  All we have to do is read the values
+ * from the FPGA registers.
+ *
+ * Note: We read from the inverted registers, since data is inverted before
+ * the code is calculated. So all 0xff data (blank page) results in all 0xff rs code
+ *
+ */
+static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
+{
+	volatile unsigned short * rs_eccn = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECCN);
+	unsigned short value;
+	int i;
+
+	for (i = 0; i < 8; i++) {
+		value = *rs_eccn;
+		ecc_code[i] = (unsigned char)value;
+		rs_eccn++;
+	}
+	ecc_code[7] |= 0x0f;	/* set the last four bits (not used) */
+}
+
+/*
+ * rtc_from4_correct_data - hardware specific code to correct data using ECC code
+ * @mtd:	MTD device structure
+ * @buf:	buffer containing the data to generate ECC codes
+ * @ecc1	ECC codes read
+ * @ecc2	ECC codes calculated
+ *
+ * The FPGA tells us fast, if there's an error or not. If no, we go back happy
+ * else we read the ecc results from the fpga and call the rs library to decode
+ * and hopefully correct the error
+ *
+ * For now I use the code, which we read from the FLASH to use the RS lib,
+ * as the syndrom conversion has a unresolved issue.
+ */
+static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_char *ecc1, u_char *ecc2)
+{
+	int i, j, res;
+	unsigned short status; 
+	uint16_t par[6], syn[6], tmp;
+	uint8_t ecc[8];
+        volatile unsigned short *rs_ecc;
+
+	status = *((volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CHK));
+
+	if (!(status & RTC_FROM4_RS_ECC_CHK_ERROR)) {
+		return 0;
+	}
+
+	/* Read the syndrom pattern from the FPGA and correct the bitorder */
+	rs_ecc = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC);
+        for (i = 0; i < 8; i++) {
+                ecc[i] = revbits[(*rs_ecc) & 0xFF];
+                rs_ecc++;
+        }
+
+	/* convert into 6 10bit syndrome fields */
+	par[5] = rs_decoder->index_of[(((uint16_t)ecc[0] >> 0) & 0x0ff) | 
+				      (((uint16_t)ecc[1] << 8) & 0x300)];
+	par[4] = rs_decoder->index_of[(((uint16_t)ecc[1] >> 2) & 0x03f) |
+				      (((uint16_t)ecc[2] << 6) & 0x3c0)];
+	par[3] = rs_decoder->index_of[(((uint16_t)ecc[2] >> 4) & 0x00f) |
+				      (((uint16_t)ecc[3] << 4) & 0x3f0)];
+	par[2] = rs_decoder->index_of[(((uint16_t)ecc[3] >> 6) & 0x003) |
+				      (((uint16_t)ecc[4] << 2) & 0x3fc)];
+	par[1] = rs_decoder->index_of[(((uint16_t)ecc[5] >> 0) & 0x0ff) |
+				      (((uint16_t)ecc[6] << 8) & 0x300)];
+	par[0] = (((uint16_t)ecc[6] >> 2) & 0x03f) | (((uint16_t)ecc[7] << 6) & 0x3c0);
+
+	/* Convert to computable syndrome */
+	for (i = 0; i < 6; i++) {
+		syn[i] = par[0];
+		for (j = 1; j < 6; j++)
+			if (par[j] != rs_decoder->nn)
+				syn[i] ^= rs_decoder->alpha_to[rs_modnn(rs_decoder, par[j] + i * j)];
+
+		/* Convert to index form */
+		syn[i] = rs_decoder->index_of[syn[i]];
+	}
+
+	/* Let the library code do its magic.*/
+	res = decode_rs8(rs_decoder, buf, par, 512, syn, 0, NULL, 0xff, NULL);
+	if (res > 0) {
+		DEBUG (MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: " 
+			"ECC corrected %d errors on read\n", res);
+	}
+	return res;
+}
+#endif
+
+/*
+ * Main initialization routine
+ */
+int __init rtc_from4_init (void)
+{
+	struct nand_chip *this;
+	unsigned short bcr1, bcr2, wcr2;
+
+	/* Allocate memory for MTD device structure and private data */
+	rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof (struct nand_chip),
+				GFP_KERNEL);
+	if (!rtc_from4_mtd) {
+		printk ("Unable to allocate Renesas NAND MTD device structure.\n");
+		return -ENOMEM;
+	}
+
+	/* Get pointer to private data */
+	this = (struct nand_chip *) (&rtc_from4_mtd[1]);
+
+	/* Initialize structures */
+	memset((char *) rtc_from4_mtd, 0, sizeof(struct mtd_info));
+	memset((char *) this, 0, sizeof(struct nand_chip));
+
+	/* Link the private data with the MTD structure */
+	rtc_from4_mtd->priv = this;
+
+	/* set area 5 as PCMCIA mode to clear the spec of tDH(Data hold time;9ns min) */
+	bcr1 = *SH77X9_BCR1 & ~0x0002;
+	bcr1 |= 0x0002;
+	*SH77X9_BCR1 = bcr1;
+
+	/* set */
+	bcr2 = *SH77X9_BCR2 & ~0x0c00;
+	bcr2 |= 0x0800;
+	*SH77X9_BCR2 = bcr2;
+
+	/* set area 5 wait states */
+	wcr2 = *SH77X9_WCR2 & ~0x1c00;
+	wcr2 |= 0x1c00;
+	*SH77X9_WCR2 = wcr2;
+
+	/* Set address of NAND IO lines */
+	this->IO_ADDR_R = rtc_from4_fio_base;
+	this->IO_ADDR_W = rtc_from4_fio_base;
+	/* Set address of hardware control function */
+	this->hwcontrol = rtc_from4_hwcontrol;
+	/* Set address of chip select function */
+        this->select_chip = rtc_from4_nand_select_chip;
+	/* command delay time (in us) */
+	this->chip_delay = 100;
+	/* return the status of the Ready/Busy line */
+	this->dev_ready = rtc_from4_nand_device_ready;
+
+#ifdef RTC_FROM4_HWECC
+	printk(KERN_INFO "rtc_from4_init: using hardware ECC detection.\n");
+
+        this->eccmode = NAND_ECC_HW8_512;
+	this->options |= NAND_HWECC_SYNDROME;
+	/* set the nand_oobinfo to support FPGA H/W error detection */
+	this->autooob = &rtc_from4_nand_oobinfo;
+	this->enable_hwecc = rtc_from4_enable_hwecc;
+	this->calculate_ecc = rtc_from4_calculate_ecc;
+	this->correct_data = rtc_from4_correct_data;
+#else
+	printk(KERN_INFO "rtc_from4_init: using software ECC detection.\n");
+
+	this->eccmode = NAND_ECC_SOFT;
+#endif
+
+	/* set the bad block tables to support debugging */
+	this->bbt_td = &rtc_from4_bbt_main_descr;
+	this->bbt_md = &rtc_from4_bbt_mirror_descr;
+
+	/* Scan to find existence of the device */
+	if (nand_scan(rtc_from4_mtd, RTC_FROM4_MAX_CHIPS)) {
+		kfree(rtc_from4_mtd);
+		return -ENXIO;
+	}
+
+	/* Register the partitions */
+	add_mtd_partitions(rtc_from4_mtd, partition_info, NUM_PARTITIONS);
+
+#ifdef RTC_FROM4_HWECC
+	/* We could create the decoder on demand, if memory is a concern.
+	 * This way we have it handy, if an error happens 
+	 *
+	 * Symbolsize is 10 (bits)
+	 * Primitve polynomial is x^10+x^3+1
+	 * first consecutive root is 0
+	 * primitve element to generate roots = 1
+	 * generator polinomial degree = 6
+	 */
+	rs_decoder = init_rs(10, 0x409, 0, 1, 6);
+	if (!rs_decoder) {
+		printk (KERN_ERR "Could not create a RS decoder\n");
+		nand_release(rtc_from4_mtd);
+		kfree(rtc_from4_mtd);
+		return -ENOMEM;
+	}
+#endif
+	/* Return happy */
+	return 0;
+}
+module_init(rtc_from4_init);
+
+
+/*
+ * Clean up routine
+ */
+#ifdef MODULE
+static void __exit rtc_from4_cleanup (void)
+{
+	/* Release resource, unregister partitions */
+	nand_release(rtc_from4_mtd);
+
+	/* Free the MTD device structure */
+	kfree (rtc_from4_mtd);
+
+#ifdef RTC_FROM4_HWECC
+	/* Free the reed solomon resources */
+	if (rs_decoder) {
+		free_rs(rs_decoder);
+	}
+#endif
+}
+module_exit(rtc_from4_cleanup);
+#endif
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("d.marlin <dmarlin@redhat.com");
+MODULE_DESCRIPTION("Board-specific glue layer for AG-AND flash on Renesas FROM_BOARD4");
+
diff -Nru a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/mtd/nand/s3c2410.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,704 @@
+/* linux/drivers/mtd/nand/s3c2410.c
+ *
+ * Copyright (c) 2004 Simtec Electronics
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * Samsung S3C2410 NAND driver
+ *
+ * Changelog:
+ *	21-Sep-2004  BJD  Initial version
+ *	23-Sep-2004  BJD  Mulitple device support
+ *	28-Sep-2004  BJD  Fixed ECC placement for Hardware mode
+ *	12-Oct-2004  BJD  Fixed errors in use of platform data
+ *
+ * $Id: s3c2410.c,v 1.5 2004/10/12 10:10:15 bjd Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include <config/mtd/nand/s3c2410/hwecc.h>
+#include <config/mtd/nand/s3c2410/debug.h>
+
+#ifdef CONFIG_MTD_NAND_S3C2410_DEBUG
+#define DEBUG
+#endif
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/nand_ecc.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <asm/hardware/clock.h>
+
+#include <asm/arch/regs-nand.h>
+#include <asm/arch/nand.h>
+
+#define PFX "s3c2410-nand: "
+
+#ifdef CONFIG_MTD_NAND_S3C2410_HWECC
+static int hardware_ecc = 1;
+#else
+static int hardware_ecc = 0;
+#endif
+
+/* new oob placement block for use with hardware ecc generation
+ */
+
+static struct nand_oobinfo nand_hw_eccoob = {
+	.useecc = MTD_NANDECC_AUTOPLACE,
+	.eccbytes = 3,
+	.eccpos = {0, 1, 2 },
+	.oobfree = { {8, 8} }
+};
+
+/* controller and mtd information */
+
+struct s3c2410_nand_info;
+
+struct s3c2410_nand_mtd {
+	struct mtd_info			mtd;
+	struct nand_chip		chip;
+	struct s3c2410_nand_set		*set;
+	struct s3c2410_nand_info	*info;
+	int				scan_res;
+};
+
+/* overview of the s3c2410 nand state */
+
+struct s3c2410_nand_info {
+	/* mtd info */
+	struct nand_hw_control		controller;
+	struct s3c2410_nand_mtd		*mtds;
+	struct s3c2410_platform_nand	*platform;
+
+	/* device info */
+	struct device			*device;
+	struct resource			*area;
+	struct clk			*clk;
+	void				*regs;
+	int				mtd_count;
+};
+
+/* conversion functions */
+
+static struct s3c2410_nand_mtd *s3c2410_nand_mtd_toours(struct mtd_info *mtd)
+{
+	return container_of(mtd, struct s3c2410_nand_mtd, mtd);
+}
+
+static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd)
+{
+	return s3c2410_nand_mtd_toours(mtd)->info;
+}
+
+static struct s3c2410_nand_info *to_nand_info(struct device *dev)
+{
+	return (struct s3c2410_nand_info *)dev_get_drvdata(dev);
+}
+
+static struct s3c2410_platform_nand *to_nand_plat(struct device *dev)
+{
+	return (struct s3c2410_platform_nand *)dev->platform_data;
+}
+
+/* timing calculations */
+
+#define NS_IN_KHZ 10000000
+
+static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
+{
+	int result;
+
+	result = (wanted * NS_IN_KHZ) / clk;
+	result++;
+
+	pr_debug("result %d from %ld, %d\n", result, clk, wanted);
+
+	if (result > max) {
+		printk("%d ns is too big for current clock rate %ld\n",
+		       wanted, clk);
+		return -1;
+	}
+
+	if (result < 1)
+		result = 1;
+
+	return result;
+}
+
+#define to_ns(ticks,clk) (((clk) * (ticks)) / NS_IN_KHZ)
+
+/* controller setup */
+
+static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, 
+			       struct device *dev)
+{
+	struct s3c2410_platform_nand *plat = to_nand_plat(dev);
+	unsigned int tacls, twrph0, twrph1;
+	unsigned long clkrate = clk_get_rate(info->clk);
+	unsigned long cfg;
+
+	/* calculate the timing information for the controller */
+
+	if (plat != NULL) {
+		tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 8);
+		twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8);
+		twrph1 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8);
+	} else {
+		/* default timings */
+		tacls = 8;
+		twrph0 = 8;
+		twrph1 = 8;
+	}
+	
+	if (tacls < 0 || twrph0 < 0 || twrph1 < 0) {
+		printk(KERN_ERR PFX "cannot get timings suitable for board\n");
+		return -EINVAL;
+	}
+
+	printk(KERN_INFO PFX "timing: Tacls %ldns, Twrph0 %ldns, Twrph1 %ldns\n",
+	       to_ns(tacls, clkrate),
+	       to_ns(twrph0, clkrate),
+	       to_ns(twrph1, clkrate));
+
+	cfg  = S3C2410_NFCONF_EN;
+	cfg |= S3C2410_NFCONF_TACLS(tacls-1);
+	cfg |= S3C2410_NFCONF_TWRPH0(twrph0-1);
+	cfg |= S3C2410_NFCONF_TWRPH1(twrph1-1);
+
+	pr_debug(PFX "NF_CONF is 0x%lx\n", cfg);
+
+	writel(cfg, info->regs + S3C2410_NFCONF);
+	return 0;
+}
+
+/* select chip */
+
+static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
+{
+	struct s3c2410_nand_info *info;
+	struct s3c2410_nand_mtd *nmtd; 
+	struct nand_chip *this = mtd->priv;
+	unsigned long cur;
+
+	nmtd = (struct s3c2410_nand_mtd *)this->priv;
+	info = nmtd->info;
+
+	cur = readl(info->regs + S3C2410_NFCONF);
+
+	if (chip == -1) {
+		cur |= S3C2410_NFCONF_nFCE;
+	} else {
+		if (chip > nmtd->set->nr_chips) {
+			printk(KERN_ERR PFX "chip %d out of range\n", chip);
+			return;
+		}
+
+		if (info->platform != NULL) {
+			if (info->platform->select_chip != NULL)
+				(info->platform->select_chip)(nmtd->set, chip);
+		}
+
+		cur &= ~S3C2410_NFCONF_nFCE;
+	}
+
+	writel(cur, info->regs + S3C2410_NFCONF);
+}
+
+/* command and control functions */
+
+static void s3c2410_nand_hwcontrol(struct mtd_info *mtd, int cmd)
+{
+	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
+	unsigned long cur;
+
+	switch (cmd) {
+	case NAND_CTL_SETNCE:
+		cur = readl(info->regs + S3C2410_NFCONF);
+		cur &= ~S3C2410_NFCONF_nFCE;
+		writel(cur, info->regs + S3C2410_NFCONF);
+		break;
+
+	case NAND_CTL_CLRNCE:
+		cur = readl(info->regs + S3C2410_NFCONF);
+		cur |= S3C2410_NFCONF_nFCE;
+		writel(cur, info->regs + S3C2410_NFCONF);
+		break;
+
+		/* we don't need to implement these */
+	case NAND_CTL_SETCLE:
+	case NAND_CTL_CLRCLE:
+	case NAND_CTL_SETALE:
+	case NAND_CTL_CLRALE:
+		pr_debug(PFX "s3c2410_nand_hwcontrol(%d) unusedn", cmd);
+		break;
+	}
+}
+
+/* s3c2410_nand_command
+ *
+ * This function implements sending commands and the relevant address
+ * information to the chip, via the hardware controller. Since the
+ * S3C2410 generates the correct ALE/CLE signaling automatically, we
+ * do not need to use hwcontrol.
+*/
+
+static void s3c2410_nand_command (struct mtd_info *mtd, unsigned command,
+				  int column, int page_addr)
+{
+	register struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
+	register struct nand_chip *this = mtd->priv;
+
+	/*
+	 * Write out the command to the device.
+	 */
+	if (command == NAND_CMD_SEQIN) {
+		int readcmd;
+
+		if (column >= mtd->oobblock) {
+			/* OOB area */
+			column -= mtd->oobblock;
+			readcmd = NAND_CMD_READOOB;
+		} else if (column < 256) {
+			/* First 256 bytes --> READ0 */
+			readcmd = NAND_CMD_READ0;
+		} else {
+			column -= 256;
+			readcmd = NAND_CMD_READ1;
+		}
+		
+		writeb(readcmd, info->regs + S3C2410_NFCMD);
+	}
+	writeb(command, info->regs + S3C2410_NFCMD);
+
+	/* Set ALE and clear CLE to start address cycle */
+
+	if (column != -1 || page_addr != -1) {
+
+		/* Serially input address */
+		if (column != -1) {
+			/* Adjust columns for 16 bit buswidth */
+			if (this->options & NAND_BUSWIDTH_16)
+				column >>= 1;
+			writeb(column, info->regs + S3C2410_NFADDR);
+		}
+		if (page_addr != -1) {
+			writeb((unsigned char) (page_addr), info->regs + S3C2410_NFADDR);
+			writeb((unsigned char) (page_addr >> 8), info->regs + S3C2410_NFADDR);
+			/* One more address cycle for higher density devices */
+			if (this->chipsize & 0x0c000000) 
+				writeb((unsigned char) ((page_addr >> 16) & 0x0f),
+				       info->regs + S3C2410_NFADDR);
+		}
+		/* Latch in address */
+	}
+	
+	/* 
+	 * program and erase have their own busy handlers 
+	 * status and sequential in needs no delay
+	*/
+	switch (command) {
+			
+	case NAND_CMD_PAGEPROG:
+	case NAND_CMD_ERASE1:
+	case NAND_CMD_ERASE2:
+	case NAND_CMD_SEQIN:
+	case NAND_CMD_STATUS:
+		return;
+
+	case NAND_CMD_RESET:
+		if (this->dev_ready)	
+			break;
+
+		udelay(this->chip_delay);
+		writeb(NAND_CMD_STATUS, info->regs + S3C2410_NFCMD);
+
+		while ( !(this->read_byte(mtd) & 0x40));
+		return;
+
+	/* This applies to read commands */	
+	default:
+		/* 
+		 * If we don't have access to the busy pin, we apply the given
+		 * command delay
+		*/
+		if (!this->dev_ready) {
+			udelay (this->chip_delay);
+			return;
+		}	
+	}
+	
+	/* Apply this short delay always to ensure that we do wait tWB in
+	 * any case on any machine. */
+	ndelay (100);
+	/* wait until command is processed */
+	while (!this->dev_ready(mtd));
+}
+
+
+/* s3c2410_nand_devready()
+ *
+ * returns 0 if the nand is busy, 1 if it is ready
+*/
+
+static int s3c2410_nand_devready(struct mtd_info *mtd)
+{
+	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
+	
+	return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY;
+}
+
+/* ECC handling functions */
+
+static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
+				     u_char *read_ecc, u_char *calc_ecc)
+{
+	pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n",
+		 mtd, dat, read_ecc, calc_ecc);
+
+	pr_debug("eccs: read %02x,%02x,%02x vs calc %02x,%02x,%02x\n",
+		 read_ecc[0], read_ecc[1], read_ecc[2],
+		 calc_ecc[0], calc_ecc[1], calc_ecc[2]);
+
+	if (read_ecc[0] == calc_ecc[0] &&
+	    read_ecc[1] == calc_ecc[1] &&
+	    read_ecc[2] == calc_ecc[2]) 
+		return 0;
+
+	/* we curently have no method for correcting the error */
+
+	return -1;
+}
+
+static void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode)
+{
+	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
+	unsigned long ctrl;
+
+	ctrl = readl(info->regs + S3C2410_NFCONF);
+	ctrl |= S3C2410_NFCONF_INITECC;
+	writel(ctrl, info->regs + S3C2410_NFCONF);
+}
+
+static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd,
+				      const u_char *dat, u_char *ecc_code)
+{
+	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
+
+	ecc_code[0] = readb(info->regs + S3C2410_NFECC + 0);
+	ecc_code[1] = readb(info->regs + S3C2410_NFECC + 1);
+	ecc_code[2] = readb(info->regs + S3C2410_NFECC + 2);
+
+	pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n",
+		 ecc_code[0], ecc_code[1], ecc_code[2]);
+
+	return 0;
+}
+
+
+/* over-ride the standard functions for a little more speed? */
+
+static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
+{
+	struct nand_chip *this = (struct nand_chip *)mtd->priv;
+	readsb(this->IO_ADDR_R, buf, len);
+}
+
+static void s3c2410_nand_write_buf(struct mtd_info *mtd,
+				   const u_char *buf, int len)
+{
+	struct nand_chip *this = (struct nand_chip *)mtd->priv;
+	writesb(this->IO_ADDR_W, buf, len);
+}
+
+/* device management functions */
+
+static int s3c2410_nand_remove(struct device *dev)
+{
+	struct s3c2410_nand_info *info = to_nand_info(dev);
+
+	dev_set_drvdata(dev, NULL);
+
+	if (info == NULL) 
+		return 0;
+
+	/* first thing we need to do is release all our mtds
+	 * and their partitions, then go through freeing the
+	 * resources used 
+	 */
+	
+	if (info->mtds != NULL) {
+		struct s3c2410_nand_mtd *ptr = info->mtds;
+		int mtdno;
+
+		for (mtdno = 0; mtdno < info->mtd_count; mtdno++, ptr++) {
+			pr_debug("releasing mtd %d (%p)\n", mtdno, ptr);
+			nand_release(&ptr->mtd);
+		}
+
+		kfree(info->mtds);
+	}
+
+	/* free the common resources */
+
+	if (info->clk != NULL && !IS_ERR(info->clk)) {
+		clk_disable(info->clk);
+		clk_unuse(info->clk);
+		clk_put(info->clk);
+	}
+
+	if (info->regs != NULL) {
+		iounmap(info->regs);
+		info->regs = NULL;
+	}
+
+	if (info->area != NULL) {
+		release_resource(info->area);
+		kfree(info->area);
+		info->area = NULL;
+	}
+
+	kfree(info);
+
+	return 0;
+}
+
+#ifdef CONFIG_MTD_PARTITIONS
+static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
+				      struct s3c2410_nand_mtd *mtd,
+				      struct s3c2410_nand_set *set)
+{
+	if (set == NULL)
+		return add_mtd_device(&mtd->mtd);
+
+	if (set->nr_partitions > 0 && set->partitions != NULL) {
+		return add_mtd_partitions(&mtd->mtd,
+					  set->partitions,
+					  set->nr_partitions);
+	}
+
+	return add_mtd_device(&mtd->mtd);
+}
+#else
+static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
+				      struct s3c2410_nand_mtd *mtd,
+				      struct s3c2410_nand_set *set)
+{
+	return add_mtd_device(&mtd->mtd);
+}
+#endif
+
+/* s3c2410_nand_init_chip
+ *
+ * init a single instance of an chip 
+*/
+
+static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
+				   struct s3c2410_nand_mtd *nmtd,
+				   struct s3c2410_nand_set *set)
+{
+	struct nand_chip *chip = &nmtd->chip;
+
+	chip->IO_ADDR_R	   = (char *)info->regs + S3C2410_NFDATA;
+	chip->IO_ADDR_W    = (char *)info->regs + S3C2410_NFDATA;
+	chip->hwcontrol    = s3c2410_nand_hwcontrol;
+	chip->dev_ready    = s3c2410_nand_devready;
+	chip->cmdfunc      = s3c2410_nand_command;
+	chip->write_buf    = s3c2410_nand_write_buf;
+	chip->read_buf     = s3c2410_nand_read_buf;
+	chip->select_chip  = s3c2410_nand_select_chip;
+	chip->chip_delay   = 50;
+	chip->priv	   = nmtd;
+	chip->options	   = 0;
+	chip->controller   = &info->controller;
+
+	nmtd->info	   = info;
+	nmtd->mtd.priv	   = chip;
+	nmtd->set	   = set;
+
+	if (hardware_ecc) {
+		chip->correct_data  = s3c2410_nand_correct_data;
+		chip->enable_hwecc  = s3c2410_nand_enable_hwecc;
+		chip->calculate_ecc = s3c2410_nand_calculate_ecc;
+		chip->eccmode	    = NAND_ECC_HW3_512;
+		chip->autooob       = &nand_hw_eccoob;
+	} else {
+		chip->eccmode	    = NAND_ECC_SOFT;
+	}
+}
+
+/* s3c2410_nand_probe
+ *
+ * called by device layer when it finds a device matching
+ * one our driver can handled. This code checks to see if
+ * it can allocate all necessary resources then calls the
+ * nand layer to look for devices
+*/
+
+static int s3c2410_nand_probe(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct s3c2410_platform_nand *plat = to_nand_plat(dev);
+	struct s3c2410_nand_info *info;
+	struct s3c2410_nand_mtd *nmtd;
+	struct s3c2410_nand_set *sets;
+	struct resource *res;
+	int err = 0;
+	int size;
+	int nr_sets;
+	int setno;
+
+	pr_debug("s3c2410_nand_probe(%p)\n", dev);
+
+	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	if (info == NULL) {
+		printk(KERN_ERR PFX "no memory for flash info\n");
+		err = -ENOMEM;
+		goto exit_error;
+	}
+
+	memzero(info, sizeof(*info));
+	dev_set_drvdata(dev, info);
+
+	spin_lock_init(&info->controller.lock);
+
+	/* get the clock source and enable it */
+
+	info->clk = clk_get(dev, "nand");
+	if (IS_ERR(info->clk)) {
+		printk(KERN_ERR PFX "failed to get clock");
+		err = -ENOENT;
+		goto exit_error;
+	}
+
+	clk_use(info->clk);
+	clk_enable(info->clk);
+
+	/* allocate and map the resource */
+
+	res = pdev->resource;  /* assume that the flash has one resource */
+	size = res->end - res->start + 1;
+
+	info->area = request_mem_region(res->start, size, pdev->name);
+
+	if (info->area == NULL) {
+		printk(KERN_ERR PFX "cannot reserve register region\n");
+		err = -ENOENT;
+		goto exit_error;
+	}
+
+	info->device = dev;
+	info->platform = plat;
+	info->regs = ioremap(res->start, size);
+
+	if (info->regs == NULL) {
+		printk(KERN_ERR PFX "cannot reserve register region\n");
+		err = -EIO;
+		goto exit_error;
+	}		
+
+	printk(KERN_INFO PFX "mapped registers at %p\n", info->regs);
+
+	/* initialise the hardware */
+
+	err = s3c2410_nand_inithw(info, dev);
+	if (err != 0)
+		goto exit_error;
+
+	sets = (plat != NULL) ? plat->sets : NULL;
+	nr_sets = (plat != NULL) ? plat->nr_sets : 1;
+
+	info->mtd_count = nr_sets;
+
+	/* allocate our information */
+
+	size = nr_sets * sizeof(*info->mtds);
+	info->mtds = kmalloc(size, GFP_KERNEL);
+	if (info->mtds == NULL) {
+		printk(KERN_ERR PFX "failed to allocate mtd storage\n");
+		err = -ENOMEM;
+		goto exit_error;
+	}
+
+	memzero(info->mtds, size);
+
+	/* initialise all possible chips */
+
+	nmtd = info->mtds;
+
+	for (setno = 0; setno < nr_sets; setno++, nmtd++) {
+		pr_debug("initialising set %d (%p, info %p)\n",
+			 setno, nmtd, info);
+		
+		s3c2410_nand_init_chip(info, nmtd, sets);
+
+		nmtd->scan_res = nand_scan(&nmtd->mtd,
+					   (sets) ? sets->nr_chips : 1);
+
+		if (nmtd->scan_res == 0) {
+			s3c2410_nand_add_partition(info, nmtd, sets);
+		}
+
+		if (sets != NULL)
+			sets++;
+	}
+	
+	pr_debug("initialised ok\n");
+	return 0;
+
+ exit_error:
+	s3c2410_nand_remove(dev);
+
+	if (err == 0)
+		err = -EINVAL;
+	return err;
+}
+
+static struct device_driver s3c2410_nand_driver = {
+	.name		= "s3c2410-nand",
+	.bus		= &platform_bus_type,
+	.probe		= s3c2410_nand_probe,
+	.remove		= s3c2410_nand_remove,
+};
+
+static int __init s3c2410_nand_init(void)
+{
+	printk("S3C2410 NAND Driver, (c) 2004 Simtec Electronics\n");
+	return driver_register(&s3c2410_nand_driver);
+}
+
+static void __exit s3c2410_nand_exit(void)
+{
+	driver_unregister(&s3c2410_nand_driver);
+}
+
+module_init(s3c2410_nand_init);
+module_exit(s3c2410_nand_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
+MODULE_DESCRIPTION("S3C2410 MTD NAND driver");
diff -Nru a/drivers/mtd/nand/spia.c b/drivers/mtd/nand/spia.c
--- a/drivers/mtd/nand/spia.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/mtd/nand/spia.c	2004-12-24 13:37:43 -08:00
@@ -8,7 +8,7 @@
  *			to controllines	(due to change in nand.c)
  *			page_cache added
  *
- * $Id: spia.c,v 1.21 2003/07/11 15:12:29 dwmw2 Exp $
+ * $Id: spia.c,v 1.24 2004/11/04 12:53:10 gleixner Exp $
  *
  * 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
@@ -59,10 +59,10 @@
 static int spia_pedr = SPIA_PEDR;
 static int spia_peddr = SPIA_PEDDR;
 
-MODULE_PARM(spia_io_base, "i");
-MODULE_PARM(spia_fio_base, "i");
-MODULE_PARM(spia_pedr, "i");
-MODULE_PARM(spia_peddr, "i");
+module_param(spia_io_base, int, 0);
+module_param(spia_fio_base, int, 0);
+module_param(spia_pedr, int, 0);
+module_param(spia_peddr, int, 0);
 
 /*
  * Define partitions for flash device
@@ -132,8 +132,8 @@
 	(*(volatile unsigned char *) (spia_io_base + spia_peddr)) = 0x07;
 
 	/* Set address of NAND IO lines */
-	this->IO_ADDR_R = spia_fio_base;
-	this->IO_ADDR_W = spia_fio_base;
+	this->IO_ADDR_R = (void __iomem *) spia_fio_base;
+	this->IO_ADDR_W = (void __iomem *) spia_fio_base;
 	/* Set address of hardware control function */
 	this->hwcontrol = spia_hwcontrol;
 	/* 15 us command delay time */
@@ -145,14 +145,6 @@
 		return -ENXIO;
 	}
 
-	/* Allocate memory for internal data buffer */
-	this->data_buf = kmalloc (sizeof(u_char) * (spia_mtd->oobblock + spia_mtd->oobsize), GFP_KERNEL);
-	if (!this->data_buf) {
-		printk ("Unable to allocate NAND data buffer for SPIA.\n");
-		kfree (spia_mtd);
-		return -ENOMEM;
-	}
-
 	/* Register the partitions */
 	add_mtd_partitions(spia_mtd, partition_info, NUM_PARTITIONS);
 
@@ -167,13 +159,8 @@
 #ifdef MODULE
 static void __exit spia_cleanup (void)
 {
-	struct nand_chip *this = (struct nand_chip *) &spia_mtd[1];
-
-	/* Unregister the device */
-	del_mtd_device (spia_mtd);
-
-	/* Free internal data buffer */
-	kfree (this->data_buf);
+	/* Release resources, unregister device */
+	nand_release (spia_mtd);
 
 	/* Free the MTD device structure */
 	kfree (spia_mtd);
diff -Nru a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c
--- a/drivers/mtd/nand/toto.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/mtd/nand/toto.c	2004-12-24 13:37:30 -08:00
@@ -15,7 +15,7 @@
  *   This is a device driver for the NAND flash device found on the
  *   TI fido board. It supports 32MiB and 64MiB cards
  *
- * $Id: toto.c,v 1.2 2003/10/21 10:04:58 dwmw2 Exp $
+ * $Id: toto.c,v 1.4 2004/10/05 13:50:20 gleixner Exp $
  */
 
 #include <linux/slab.h>
@@ -37,7 +37,7 @@
  */
 static struct mtd_info *toto_mtd = NULL;
 
-static int toto_io_base = OMAP_FLASH_1_BASE;
+static unsigned long toto_io_base = OMAP_FLASH_1_BASE;
 
 #define CONFIG_NAND_WORKAROUND 1
 
@@ -155,14 +155,6 @@
 		goto out_mtd;
 	}
 
-	/* Allocate memory for internal data buffer */
-	this->data_buf = kmalloc (sizeof(u_char) * (toto_mtd->oobblock + toto_mtd->oobsize), GFP_KERNEL);
-	if (!this->data_buf) {
-		printk (KERN_WARNING "Unable to allocate NAND data buffer for toto.\n");
-		err = -ENOMEM;
-		goto out_mtd;
-	}
-
 	/* Register the partitions */
 	switch(toto_mtd->size){
 		case SZ_64M: add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); break; 
@@ -194,16 +186,8 @@
  */
 static void __exit toto_cleanup (void)
 {
-	struct nand_chip *this = (struct nand_chip *) &toto_mtd[1];
-
-	/* Unregister partitions */
-	del_mtd_partitions(toto_mtd);
-	
-	/* Unregister the device */
-	del_mtd_device (toto_mtd);
-
-	/* Free internal data buffers */
-	kfree (this->data_buf);
+	/* Release resources, unregister device */
+	nand_release (toto_mtd);
 
 	/* Free the MTD device structure */
 	kfree (toto_mtd);
diff -Nru a/drivers/mtd/nand/tx4925ndfmc.c b/drivers/mtd/nand/tx4925ndfmc.c
--- a/drivers/mtd/nand/tx4925ndfmc.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/mtd/nand/tx4925ndfmc.c	2004-12-24 13:36:48 -08:00
@@ -11,7 +11,7 @@
  * Derived from drivers/mtd/autcpu12.c
  *       Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
  *
- * $Id: tx4925ndfmc.c,v 1.3 2004/07/20 02:44:26 dwmw2 Exp $
+ * $Id: tx4925ndfmc.c,v 1.5 2004/10/05 13:50:20 gleixner Exp $
  *
  * Copyright (C) 2001 Toshiba Corporation 
  * 
@@ -340,8 +340,8 @@
 	tx4925ndfmc_mtd->priv = this;
 
 	/* Set address of NAND IO lines */
-	this->IO_ADDR_R = (unsigned long)&(tx4925_ndfmcptr->dtr);
-	this->IO_ADDR_W = (unsigned long)&(tx4925_ndfmcptr->dtr);
+	this->IO_ADDR_R = (void __iomem *)&(tx4925_ndfmcptr->dtr);
+	this->IO_ADDR_W = (void __iomem *)&(tx4925_ndfmcptr->dtr);
 	this->hwcontrol = tx4925ndfmc_hwcontrol;
 	this->enable_hwecc = tx4925ndfmc_enable_hwecc;
 	this->calculate_ecc = tx4925ndfmc_readecc;
@@ -363,14 +363,6 @@
 		goto out_ior;
 	}
 
-	/* Allocate memory for internal data buffer */
-	this->data_buf = kmalloc (sizeof(u_char) * (tx4925ndfmc_mtd->oobblock + tx4925ndfmc_mtd->oobsize), GFP_KERNEL);
-	if (!this->data_buf) {
-		printk ("Unable to allocate NAND data buffer for RBTX4925.\n");
-		err = -ENOMEM;
-		goto out_ior;
-	}
-
 	/* Register the partitions */
 #ifdef CONFIG_MTD_CMDLINE_PARTS
         {
@@ -391,14 +383,12 @@
 		default: {
 			printk ("Unsupported SmartMedia device\n"); 
 			err = -ENXIO;
-			goto out_buf;
+			goto out_ior;
 		}
 	}
 #endif /* ifdef CONFIG_MTD_CMDLINE_PARTS */
 	goto out;
 
-out_buf:
-	kfree (this->data_buf);    
 out_ior:
 out:
 	return err;
@@ -412,16 +402,8 @@
 #ifdef MODULE
 static void __exit tx4925ndfmc_cleanup (void)
 {
-	struct nand_chip *this = (struct nand_chip *) &tx4925ndfmc_mtd[1];
-
-	/* Unregister partitions */
-	del_mtd_partitions(tx4925ndfmc_mtd);
-	
-	/* Unregister the device */
-	del_mtd_device (tx4925ndfmc_mtd);
-
-	/* Free internal data buffers */
-	kfree (this->data_buf);
+	/* Release resources, unregister device */
+	nand_release (tx4925ndfmc_mtd);
 
 	/* Free the MTD device structure */
 	kfree (tx4925ndfmc_mtd);
diff -Nru a/drivers/mtd/nand/tx4938ndfmc.c b/drivers/mtd/nand/tx4938ndfmc.c
--- a/drivers/mtd/nand/tx4938ndfmc.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/mtd/nand/tx4938ndfmc.c	2004-12-24 13:37:43 -08:00
@@ -10,7 +10,7 @@
  *
  * Based on spia.c by Steven J. Hill
  *
- * $Id: tx4938ndfmc.c,v 1.2 2004/03/27 19:55:53 gleixner Exp $
+ * $Id: tx4938ndfmc.c,v 1.4 2004/10/05 13:50:20 gleixner Exp $
  *
  * Copyright (C) 2000-2001 Toshiba Corporation 
  *
@@ -365,14 +365,6 @@
 		return -ENXIO;
 	}
 
-	/* Allocate memory for internal data buffer */
-	this->data_buf = kmalloc (sizeof(u_char) * (tx4938ndfmc_mtd->oobblock + tx4938ndfmc_mtd->oobsize), GFP_KERNEL);
-	if (!this->data_buf) {
-		printk ("Unable to allocate NAND data buffer for TX4938.\n");
-		kfree (tx4938ndfmc_mtd);
-		return -ENOMEM;
-	}
-
 	if (protected) {
 		printk(KERN_INFO "TX4938 NDFMC: write protected.\n");
 		tx4938ndfmc_mtd->flags &= ~(MTD_WRITEABLE | MTD_ERASEABLE);
@@ -401,19 +393,11 @@
  */
 static void __exit tx4938ndfmc_cleanup (void)
 {
-	struct nand_chip *this = (struct nand_chip *) tx4938ndfmc_mtd->priv;
-
-	/* Unregister the device */
-#ifdef CONFIG_MTD_CMDLINE_PARTS
-	del_mtd_partitions(tx4938ndfmc_mtd);
-#endif
-	del_mtd_device (tx4938ndfmc_mtd);
+	/* Release resources, unregister device */
+	nand_release (tx4938ndfmc_mtd);
 
 	/* Free the MTD device structure */
 	kfree (tx4938ndfmc_mtd);
-
-	/* Free internal data buffer */
-	kfree (this->data_buf);
 }
 module_exit(tx4938ndfmc_cleanup);
 
diff -Nru a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
--- a/drivers/mtd/nftlcore.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/mtd/nftlcore.c	2004-12-24 13:36:17 -08:00
@@ -1,7 +1,7 @@
 /* Linux driver for NAND Flash Translation Layer      */
 /* (c) 1999 Machine Vision Holdings, Inc.             */
 /* Author: David Woodhouse <dwmw2@infradead.org>      */
-/* $Id: nftlcore.c,v 1.96 2004/06/28 13:52:55 dbrown Exp $ */
+/* $Id: nftlcore.c,v 1.97 2004/11/16 18:28:59 dwmw2 Exp $ */
 
 /*
   The contents of this file are distributed under the GNU General
@@ -421,7 +421,7 @@
 	return targetEUN;
 }
 
-u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
+static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
 {
 	/* This is the part that needs some cleverness applied. 
 	   For now, I'm doing the minimum applicable to actually
@@ -731,7 +731,7 @@
  ****************************************************************************/
 
 
-struct mtd_blktrans_ops nftl_tr = {
+static struct mtd_blktrans_ops nftl_tr = {
 	.name		= "nftl",
 	.major		= NFTL_MAJOR,
 	.part_bits	= NFTL_PARTN_BITS,
@@ -747,9 +747,9 @@
 
 extern char nftlmountrev[];
 
-int __init init_nftl(void)
+static int __init init_nftl(void)
 {
-	printk(KERN_INFO "NFTL driver: nftlcore.c $Revision: 1.96 $, nftlmount.c %s\n", nftlmountrev);
+	printk(KERN_INFO "NFTL driver: nftlcore.c $Revision: 1.97 $, nftlmount.c %s\n", nftlmountrev);
 
 	return register_mtd_blktrans(&nftl_tr);
 }
diff -Nru a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
--- a/drivers/mtd/nftlmount.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/mtd/nftlmount.c	2004-12-24 13:37:01 -08:00
@@ -4,7 +4,7 @@
  * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 
  * Copyright (C) 2000 Netgem S.A.
  *
- * $Id: nftlmount.c,v 1.36 2004/06/28 13:52:55 dbrown Exp $
+ * $Id: nftlmount.c,v 1.39 2004/11/05 22:51:41 kalev Exp $
  *
  * 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
@@ -31,7 +31,7 @@
 
 #define SECTORSIZE 512
 
-char nftlmountrev[]="$Revision: 1.36 $";
+char nftlmountrev[]="$Revision: 1.39 $";
 
 /* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the
  *	various device information of the NFTL partition and Bad Unit Table. Update
@@ -41,7 +41,6 @@
 static int find_boot_record(struct NFTLrecord *nftl)
 {
 	struct nftl_uci1 h1;
-	struct nftl_oob oob;
 	unsigned int block, boot_record_count = 0;
 	size_t retlen;
 	u8 buf[SECTORSIZE];
@@ -302,6 +301,8 @@
 	unsigned int nb_erases, erase_mark;
 	struct nftl_uci1 uci;
 	struct erase_info *instr = &nftl->instr;
+
+	instr->mtd = nftl->mbd.mtd;
 
 	/* Read the Unit Control Information #1 for Wear-Leveling */
 	if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8,
diff -Nru a/drivers/net/3c501.c b/drivers/net/3c501.c
--- a/drivers/net/3c501.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/3c501.c	2004-12-24 13:36:17 -08:00
@@ -124,9 +124,9 @@
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include <linux/netdevice.h>
diff -Nru a/drivers/net/3c505.c b/drivers/net/3c505.c
--- a/drivers/net/3c505.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/net/3c505.c	2004-12-24 13:37:32 -08:00
@@ -107,9 +107,9 @@
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/3c507.c b/drivers/net/3c507.c
--- a/drivers/net/3c507.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/3c507.c	2004-12-24 13:37:18 -08:00
@@ -59,8 +59,8 @@
 #include <linux/skbuff.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/system.h>
diff -Nru a/drivers/net/3c509.c b/drivers/net/3c509.c
--- a/drivers/net/3c509.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/3c509.c	2004-12-24 13:36:17 -08:00
@@ -90,9 +90,9 @@
 #include <linux/ethtool.h>
 #include <linux/device.h>
 #include <linux/eisa.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
@@ -197,9 +197,9 @@
 static int el3_close(struct net_device *dev);
 static void set_multicast_list(struct net_device *dev);
 static void el3_tx_timeout (struct net_device *dev);
-static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
 static void el3_down(struct net_device *dev);
 static void el3_up(struct net_device *dev);
+static struct ethtool_ops ethtool_ops;
 #ifdef CONFIG_PM
 static int el3_suspend(struct pm_dev *pdev);
 static int el3_resume(struct pm_dev *pdev);
@@ -321,7 +321,7 @@
 	dev->set_multicast_list = &set_multicast_list;
 	dev->tx_timeout = el3_tx_timeout;
 	dev->watchdog_timeo = TX_TIMEOUT;
-	dev->do_ioctl = netdev_ioctl;
+	SET_ETHTOOL_OPS(dev, &ethtool_ops);
 
 	err = register_netdev(dev);
 	if (err) {
@@ -1285,122 +1285,63 @@
 	return 0;
 }
 
-/**
- * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
- * @dev: network interface on which out-of-band action is to be performed
- * @useraddr: userspace address to which data is to be read and returned
- *
- * Process the various commands of the SIOCETHTOOL interface.
- */
+static void el3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+}
 
-static int
-netdev_ethtool_ioctl (struct net_device *dev, void __user *useraddr)
+static int el3_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
-	u32 ethcmd;
 	struct el3_private *lp = netdev_priv(dev);
+	int ret;
 
-	/* dev_ioctl() in ../../net/core/dev.c has already checked
-	   capable(CAP_NET_ADMIN), so don't bother with that here.  */
-
-	if (get_user(ethcmd, (u32 __user *)useraddr))
-		return -EFAULT;
-
-	switch (ethcmd) {
-
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-		strcpy (info.driver, DRV_NAME);
-		strcpy (info.version, DRV_VERSION);
-		if (copy_to_user (useraddr, &info, sizeof (info)))
-			return -EFAULT;
-		return 0;
-	}
-
-	/* get settings */
-	case ETHTOOL_GSET: {
-		int ret;
-		struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-		spin_lock_irq(&lp->lock);
-		ret = el3_netdev_get_ecmd(dev, &ecmd);
-		spin_unlock_irq(&lp->lock);
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return ret;
-	}
-
-	/* set settings */
-	case ETHTOOL_SSET: {
-		int ret;
-		struct ethtool_cmd ecmd;
-		if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-			return -EFAULT;
-		spin_lock_irq(&lp->lock);
-		ret = el3_netdev_set_ecmd(dev, &ecmd);
-		spin_unlock_irq(&lp->lock);
-		return ret;
-	}
-
-	/* get link status */
-	case ETHTOOL_GLINK: {
-		struct ethtool_value edata = { ETHTOOL_GLINK };
-		spin_lock_irq(&lp->lock);
-		edata.data = el3_link_ok(dev);
-		spin_unlock_irq(&lp->lock);
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-
-	/* get message-level */
-	case ETHTOOL_GMSGLVL: {
-		struct ethtool_value edata = {ETHTOOL_GMSGLVL};
-		edata.data = el3_debug;
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set message-level */
-	case ETHTOOL_SMSGLVL: {
-		struct ethtool_value edata;
-		if (copy_from_user(&edata, useraddr, sizeof(edata)))
-			return -EFAULT;
-		el3_debug = edata.data;
-		return 0;
-	}
+	spin_lock_irq(&lp->lock);
+	ret = el3_netdev_get_ecmd(dev, ecmd);
+	spin_unlock_irq(&lp->lock);
+	return ret;
+}
 
-	default:
-		break;
-	}
+static int el3_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct el3_private *lp = netdev_priv(dev);
+	int ret;
 
-	return -EOPNOTSUPP;
+	spin_lock_irq(&lp->lock);
+	ret = el3_netdev_set_ecmd(dev, ecmd);
+	spin_unlock_irq(&lp->lock);
+	return ret;
 }
 
-/**
- * netdev_ioctl: Handle network interface ioctls
- * @dev: network interface on which out-of-band action is to be performed
- * @rq: user request data
- * @cmd: command issued by user
- *
- * Process the various out-of-band ioctls passed to this driver.
- */
-
-static int
-netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
+static u32 el3_get_link(struct net_device *dev)
 {
-	int rc = 0;
+	struct el3_private *lp = netdev_priv(dev);
+	u32 ret;
 
-	switch (cmd) {
-	case SIOCETHTOOL:
-		rc = netdev_ethtool_ioctl(dev, rq->ifr_data);
-		break;
+	spin_lock_irq(&lp->lock);
+	ret = el3_link_ok(dev);
+	spin_unlock_irq(&lp->lock);
+	return ret;
+}
 
-	default:
-		rc = -EOPNOTSUPP;
-		break;
-	}
+static u32 el3_get_msglevel(struct net_device *dev)
+{
+	return el3_debug;
+}
 
-	return rc;
+static void el3_set_msglevel(struct net_device *dev, u32 v)
+{
+	el3_debug = v;
 }
+
+static struct ethtool_ops ethtool_ops = {
+	.get_drvinfo = el3_get_drvinfo,
+	.get_settings = el3_get_settings,
+	.set_settings = el3_set_settings,
+	.get_link = el3_get_link,
+	.get_msglevel = el3_get_msglevel,
+	.set_msglevel = el3_set_msglevel,
+};
 
 static void
 el3_down(struct net_device *dev)
diff -Nru a/drivers/net/3c515.c b/drivers/net/3c515.c
--- a/drivers/net/3c515.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/3c515.c	2004-12-24 13:36:18 -08:00
@@ -72,9 +72,9 @@
 #include <linux/interrupt.h>
 #include <linux/timer.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/3c523.c b/drivers/net/3c523.c
--- a/drivers/net/3c523.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/3c523.c	2004-12-24 13:36:49 -08:00
@@ -104,10 +104,10 @@
 #include <linux/delay.h>
 #include <linux/mca-legacy.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
 #include <asm/processor.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include "3c523.h"
diff -Nru a/drivers/net/3c527.c b/drivers/net/3c527.c
--- a/drivers/net/3c527.c	2004-12-24 13:36:57 -08:00
+++ b/drivers/net/3c527.c	2004-12-24 13:36:57 -08:00
@@ -102,11 +102,11 @@
 #include <linux/wait.h>
 #include <linux/ethtool.h>
 #include <linux/completion.h>
+#include <linux/bitops.h>
 
 #include <asm/semaphore.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/3c59x.c b/drivers/net/3c59x.c
--- a/drivers/net/3c59x.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/3c59x.c	2004-12-24 13:36:16 -08:00
@@ -257,8 +257,8 @@
 #include <linux/ethtool.h>
 #include <linux/highmem.h>
 #include <linux/eisa.h>
+#include <linux/bitops.h>
 #include <asm/irq.h>			/* For NR_IRQS only. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
@@ -798,7 +798,7 @@
 
 	/* PCI configuration space information. */
 	struct device *gendev;
-	char *cb_fn_base;					/* CardBus function status addr space. */
+	char __iomem *cb_fn_base;		/* CardBus function status addr space. */
 
 	/* Some values here only for performance evaluation and path-coverage */
 	int rx_nocopy, rx_copy, queued_packet, rx_csumhits;
@@ -817,7 +817,7 @@
 		partner_flow_ctrl:1,			/* Partner supports flow control */
 		has_nway:1,
 		enable_wol:1,					/* Wake-on-LAN is enabled */
-		pm_state_valid:1,				/* power_state[] has sane contents */
+		pm_state_valid:1,				/* pci_dev->saved_config_space has sane contents */
 		open:1,
 		medialock:1,
 		must_free_region:1,				/* Flag: if zero, Cardbus owns the I/O region */
@@ -834,7 +834,6 @@
 	u16 io_size;						/* Size of PCI region (for release_region) */
 	spinlock_t lock;					/* Serialise access to device & its vortex_private */
 	spinlock_t mdio_lock;				/* Serialise access to mdio hardware */
-	u32 power_state[16];
 };
 
 #ifdef CONFIG_PCI
@@ -1494,7 +1493,7 @@
 #endif
 	if (pdev && vp->enable_wol) {
 		vp->pm_state_valid = 1;
- 		pci_save_state(VORTEX_PCI(vp), vp->power_state);
+ 		pci_save_state(VORTEX_PCI(vp));
  		acpi_set_WOL(dev);
 	}
 	retval = register_netdev(dev);
@@ -1551,7 +1550,7 @@
 
 	if (VORTEX_PCI(vp) && vp->enable_wol) {
 		pci_set_power_state(VORTEX_PCI(vp), 0);	/* Go active */
-		pci_restore_state(VORTEX_PCI(vp), vp->power_state);
+		pci_restore_state(VORTEX_PCI(vp));
 	}
 
 	/* Before initializing select the active media port. */
@@ -2708,7 +2707,7 @@
 		outl(0, ioaddr + DownListPtr);
 
 	if (final_down && VORTEX_PCI(vp) && vp->enable_wol) {
-		pci_save_state(VORTEX_PCI(vp), vp->power_state);
+		pci_save_state(VORTEX_PCI(vp));
 		acpi_set_WOL(dev);
 	}
 }
@@ -2888,7 +2887,7 @@
 }
 
 static struct ethtool_ops vortex_ethtool_ops = {
-	.get_drvinfo =		vortex_get_drvinfo,
+	.get_drvinfo		= vortex_get_drvinfo,
 };
 
 #ifdef CONFIG_PCI
@@ -3166,7 +3165,7 @@
 	if (VORTEX_PCI(vp) && vp->enable_wol) {
 		pci_set_power_state(VORTEX_PCI(vp), 0);	/* Go active */
 		if (vp->pm_state_valid)
-			pci_restore_state(VORTEX_PCI(vp), vp->power_state);
+			pci_restore_state(VORTEX_PCI(vp));
 	}
 	/* Should really use issue_and_wait() here */
 	outw(TotalReset|0x14, dev->base_addr + EL3_CMD);
diff -Nru a/drivers/net/7990.c b/drivers/net/7990.c
--- a/drivers/net/7990.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/net/7990.c	2004-12-24 13:37:03 -08:00
@@ -14,7 +14,6 @@
  */
 #include <linux/crc32.h>
 #include <linux/delay.h>
-#include <linux/dio.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -30,26 +29,67 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/skbuff.h>
+#include <linux/irq.h>
 /* Used for the temporal inet entries and routing */
 #include <linux/socket.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/pgtable.h>
+#ifdef CONFIG_HP300
+#include <asm/blinken.h>
+#endif
 
 #include "7990.h"
 
+#define WRITERAP(lp,x) out_be16(lp->base + LANCE_RAP, (x))
+#define WRITERDP(lp,x) out_be16(lp->base + LANCE_RDP, (x))
+#define READRDP(lp) in_be16(lp->base + LANCE_RDP)
+
+#if defined(CONFIG_HPLANCE) || defined(CONFIG_HPLANCE_MODULE)
+#include "hplance.h"
+
+#undef WRITERAP
+#undef WRITERDP
+#undef READRDP
+
+#if defined(CONFIG_MVME147_NET) || defined(CONFIG_MVME147_NET_MODULE)
+
 /* Lossage Factor Nine, Mr Sulu. */
-#define WRITERAP(x) (lp->writerap(lp,x))
-#define WRITERDP(x) (lp->writerdp(lp,x))
-#define READRDP() (lp->readrdp(lp))
-/* These used to be ll->rap = x, ll->rdp = x, and (ll->rdp). Sigh. 
- * If you want to switch them back then 
- * #define DECLARE_LL volatile struct lance_regs *ll = lp->ll
- */
-#define DECLARE_LL /* nothing to declare */
+#define WRITERAP(lp,x) (lp->writerap(lp,x))
+#define WRITERDP(lp,x) (lp->writerdp(lp,x))
+#define READRDP(lp) (lp->readrdp(lp))
+
+#else
+
+/* These inlines can be used if only CONFIG_HPLANCE is defined */
+static inline void WRITERAP(struct lance_private *lp, __u16 value)
+{
+	do {
+		out_be16(lp->base + HPLANCE_REGOFF + LANCE_RAP, value);
+	} while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0);
+}
+
+static inline void WRITERDP(struct lance_private *lp, __u16 value)
+{
+	do {
+		out_be16(lp->base + HPLANCE_REGOFF + LANCE_RDP, value);
+	} while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0);
+}
+
+static inline __u16 READRDP(struct lance_private *lp)
+{
+	__u16 value;
+	do {
+		value = in_be16(lp->base + HPLANCE_REGOFF + LANCE_RDP);
+	} while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0);
+	return value;
+}
+
+#endif
+#endif /* CONFIG_HPLANCE || CONFIG_HPLANCE_MODULE */
 
 /* debugging output macros, various flavours */
 /* #define TEST_HITS */
@@ -79,19 +119,18 @@
 {
         volatile struct lance_init_block *aib = lp->lance_init_block;
         int leptr;
-        DECLARE_LL;
 
         leptr = LANCE_ADDR (aib);
 
-        WRITERAP(LE_CSR1);                        /* load address of init block */
-        WRITERDP(leptr & 0xFFFF);
-        WRITERAP(LE_CSR2);
-        WRITERDP(leptr >> 16);
-        WRITERAP(LE_CSR3);
-        WRITERDP(lp->busmaster_regval);           /* set byteswap/ALEctrl/byte ctrl */
+        WRITERAP(lp, LE_CSR1);                    /* load address of init block */
+        WRITERDP(lp, leptr & 0xFFFF);
+        WRITERAP(lp, LE_CSR2);
+        WRITERDP(lp, leptr >> 16);
+        WRITERAP(lp, LE_CSR3);
+        WRITERDP(lp, lp->busmaster_regval);       /* set byteswap/ALEctrl/byte ctrl */
 
         /* Point back to csr0 */
-        WRITERAP(LE_CSR0);
+        WRITERAP(lp, LE_CSR0);
 }
 
 /* #define to 0 or 1 appropriately */
@@ -192,24 +231,23 @@
 static int init_restart_lance (struct lance_private *lp)
 {
         int i;
-        DECLARE_LL;
 
-        WRITERAP(LE_CSR0);
-        WRITERDP(LE_C0_INIT);
+        WRITERAP(lp, LE_CSR0);
+        WRITERDP(lp, LE_C0_INIT);
 
         /* Need a hook here for sunlance ledma stuff */
 
         /* Wait for the lance to complete initialization */
-        for (i = 0; (i < 100) && !(READRDP() & (LE_C0_ERR | LE_C0_IDON)); i++)
+        for (i = 0; (i < 100) && !(READRDP(lp) & (LE_C0_ERR | LE_C0_IDON)); i++)
                 barrier();
-        if ((i == 100) || (READRDP() & LE_C0_ERR)) {
-                printk ("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, READRDP());
+        if ((i == 100) || (READRDP(lp) & LE_C0_ERR)) {
+                printk ("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, READRDP(lp));
                 return -1;
         }
 
         /* Clear IDON by writing a "1", enable interrupts and start lance */
-        WRITERDP(LE_C0_IDON);
-        WRITERDP(LE_C0_INEA | LE_C0_STRT);
+        WRITERDP(lp, LE_C0_IDON);
+        WRITERDP(lp, LE_C0_INEA | LE_C0_STRT);
 
         return 0;
 }
@@ -218,11 +256,10 @@
 {
         struct lance_private *lp = netdev_priv(dev);
         int status;
-        DECLARE_LL;
     
         /* Stop the lance */
-        WRITERAP(LE_CSR0);
-        WRITERDP(LE_C0_STOP);
+        WRITERAP(lp, LE_CSR0);
+        WRITERDP(lp, LE_C0_STOP);
 
         load_csrs (lp);
         lance_init_ring (dev);
@@ -245,7 +282,6 @@
 #ifdef TEST_HITS
         int i;
 #endif
-        DECLARE_LL;
 
 #ifdef TEST_HITS
         printk ("[");
@@ -259,8 +295,10 @@
         }
         printk ("]");
 #endif
-    
-        WRITERDP(LE_C0_RINT | LE_C0_INEA);     /* ack Rx int, reenable ints */
+#ifdef CONFIG_HP300
+	blinken_leds(0x40, 0);
+#endif    
+        WRITERDP(lp, LE_C0_RINT | LE_C0_INEA);     /* ack Rx int, reenable ints */
         for (rd = &ib->brx_ring [lp->rx_new];     /* For each Rx ring we own... */
              !((bits = rd->rmd1_bits) & LE_R1_OWN);
              rd = &ib->brx_ring [lp->rx_new]) {
@@ -321,10 +359,12 @@
         volatile struct lance_tx_desc *td;
         int i, j;
         int status;
-        DECLARE_LL;
 
+#ifdef CONFIG_HP300
+	blinken_leds(0x80, 0);
+#endif
         /* csr0 is 2f3 */
-        WRITERDP(LE_C0_TINT | LE_C0_INEA);
+        WRITERDP(lp, LE_C0_TINT | LE_C0_INEA);
         /* csr0 is 73 */
 
         j = lp->tx_old;
@@ -349,8 +389,8 @@
                                         printk("%s: Carrier Lost, trying %s\n",
                                                dev->name, lp->tpe?"TPE":"AUI");
                                         /* Stop the lance */
-                                        WRITERAP(LE_CSR0);
-                                        WRITERDP(LE_C0_STOP);
+                                        WRITERAP(lp, LE_CSR0);
+                                        WRITERDP(lp, LE_C0_STOP);
                                         lance_init_ring (dev);
                                         load_csrs (lp);
                                         init_restart_lance (lp);
@@ -366,8 +406,8 @@
                                 printk ("%s: Tx: ERR_BUF|ERR_UFL, restarting\n",
                                         dev->name);
                                 /* Stop the lance */
-                                WRITERAP(LE_CSR0);
-                                WRITERDP(LE_C0_STOP);
+                                WRITERAP(lp, LE_CSR0);
+                                WRITERDP(lp, LE_C0_STOP);
                                 lance_init_ring (dev);
                                 load_csrs (lp);
                                 init_restart_lance (lp);
@@ -393,7 +433,7 @@
                 j = (j + 1) & lp->tx_ring_mod_mask;
         }
         lp->tx_old = j;
-        WRITERDP(LE_C0_TINT | LE_C0_INEA);
+        WRITERDP(lp, LE_C0_TINT | LE_C0_INEA);
         return 0;
 }
 
@@ -403,26 +443,25 @@
         struct net_device *dev = (struct net_device *)dev_id;
         struct lance_private *lp = netdev_priv(dev);
         int csr0;
-        DECLARE_LL;
 
 	spin_lock (&lp->devlock);
 
-        WRITERAP(LE_CSR0);              /* LANCE Controller Status */
-        csr0 = READRDP();
+        WRITERAP(lp, LE_CSR0);              /* LANCE Controller Status */
+        csr0 = READRDP(lp);
 
         PRINT_RINGS();
         
         if (!(csr0 & LE_C0_INTR)) {     /* Check if any interrupt has */
-		spin_lock (&lp->devlock);
+		spin_unlock (&lp->devlock);
                 return IRQ_NONE;        /* been generated by the Lance. */
 	}
 
         /* Acknowledge all the interrupt sources ASAP */
-        WRITERDP(csr0 & ~(LE_C0_INEA|LE_C0_TDMD|LE_C0_STOP|LE_C0_STRT|LE_C0_INIT));
+        WRITERDP(lp, csr0 & ~(LE_C0_INEA|LE_C0_TDMD|LE_C0_STOP|LE_C0_STRT|LE_C0_INIT));
 
         if ((csr0 & LE_C0_ERR)) {
                 /* Clear the error condition */
-                WRITERDP(LE_C0_BABL|LE_C0_ERR|LE_C0_MISS|LE_C0_INEA);
+                WRITERDP(lp, LE_C0_BABL|LE_C0_ERR|LE_C0_MISS|LE_C0_INEA);
         }
 
         if (csr0 & LE_C0_RINT)
@@ -440,7 +479,7 @@
                 printk("%s: Bus master arbitration failure, status %4.4x.\n", 
                        dev->name, csr0);
                 /* Restart the chip. */
-                WRITERDP(LE_C0_STRT);
+                WRITERDP(lp, LE_C0_STRT);
         }
 
         if (lp->tx_full && netif_queue_stopped(dev) && (TX_BUFFS_AVAIL >= 0)) {
@@ -448,8 +487,8 @@
 		netif_wake_queue (dev);
         }
         
-        WRITERAP(LE_CSR0);
-        WRITERDP(LE_C0_BABL|LE_C0_CERR|LE_C0_MISS|LE_C0_MERR|LE_C0_IDON|LE_C0_INEA);
+        WRITERAP(lp, LE_CSR0);
+        WRITERDP(lp, LE_C0_BABL|LE_C0_CERR|LE_C0_MISS|LE_C0_MERR|LE_C0_IDON|LE_C0_INEA);
 
 	spin_unlock (&lp->devlock);
 	return IRQ_HANDLED;
@@ -459,14 +498,13 @@
 {
         struct lance_private *lp = netdev_priv(dev);
 	int res;
-        DECLARE_LL;
         
         /* Install the Interrupt handler. Or we could shunt this out to specific drivers? */
         if (request_irq(lp->irq, lance_interrupt, 0, lp->name, dev))
                 return -EAGAIN;
 
         res = lance_reset(dev);
-	lp->devlock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&lp->devlock);
 	netif_start_queue (dev);
 
 	return res;
@@ -475,13 +513,12 @@
 int lance_close (struct net_device *dev)
 {
         struct lance_private *lp = netdev_priv(dev);
-        DECLARE_LL;
         
 	netif_stop_queue (dev);
 
         /* Stop the LANCE */
-        WRITERAP(LE_CSR0);
-        WRITERDP(LE_C0_STOP);
+        WRITERAP(lp, LE_CSR0);
+        WRITERDP(lp, LE_C0_STOP);
 
         free_irq(lp->irq, dev);
 
@@ -504,7 +541,6 @@
         int entry, skblen, len;
         static int outs;
 	unsigned long flags;
-        DECLARE_LL;
 
         if (!TX_BUFFS_AVAIL)
                 return -1;
@@ -540,7 +576,7 @@
 
         outs++;
         /* Kick the lance: transmit now */
-        WRITERDP(LE_C0_INEA | LE_C0_TDMD);
+        WRITERDP(lp, LE_C0_INEA | LE_C0_TDMD);
         dev->trans_start = jiffies;
         dev_kfree_skb (skb);
     
@@ -604,7 +640,6 @@
         struct lance_private *lp = netdev_priv(dev);
         volatile struct lance_init_block *ib = lp->init_block;
 	int stopped;
-        DECLARE_LL;
 
 	stopped = netif_queue_stopped(dev);
 	if (!stopped)
@@ -613,8 +648,8 @@
         while (lp->tx_old != lp->tx_new)
                 schedule();
 
-        WRITERAP(LE_CSR0);
-        WRITERDP(LE_C0_STOP);
+        WRITERAP(lp, LE_CSR0);
+        WRITERDP(lp, LE_C0_STOP);
         lance_init_ring (dev);
 
         if (dev->flags & IFF_PROMISC) {
@@ -629,5 +664,18 @@
 	if (!stopped)
 		netif_start_queue (dev);
 }
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+void lance_poll(struct net_device *dev)
+{
+	struct lance_private *lp = netdev_priv(dev);
+
+	spin_lock (&lp->devlock);
+	WRITERAP(lp, LE_CSR0);
+	WRITERDP(lp, LE_C0_STRT);
+	spin_unlock (&lp->devlock);
+	lance_interrupt(dev->irq, dev, NULL);
+}
+#endif
 
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/net/7990.h b/drivers/net/7990.h
--- a/drivers/net/7990.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/7990.h	2004-12-24 13:36:18 -08:00
@@ -14,11 +14,8 @@
 #define _7990_H
 
 /* The lance only has two register locations. We communicate mostly via memory. */
-struct lance_regs 
-{
-        unsigned short rdp;                       /* Register Data Port */
-        unsigned short rap;                       /* Register Address Port */
-};
+#define LANCE_RDP	0	/* Register Data Port */
+#define LANCE_RAP	2	/* Register Address Port */
 
 /* Transmit/receive ring definitions.
  * We allow the specific drivers to override these defaults if they want to.
@@ -104,7 +101,7 @@
 struct lance_private
 {
         char *name;
-        volatile struct lance_regs *ll;
+	unsigned long base;
         volatile struct lance_init_block *init_block; /* CPU address of RAM */
         volatile struct lance_init_block *lance_init_block; /* LANCE address of RAM */
         
@@ -252,5 +249,8 @@
 extern struct net_device_stats *lance_get_stats (struct net_device *dev);
 extern void lance_set_multicast (struct net_device *dev);
 extern void lance_tx_timeout(struct net_device *dev);
+#ifdef CONFIG_NET_POLL_CONTROLLER
+extern void lance_poll(struct net_device *dev);
+#endif
 
 #endif /* ndef _7990_H */
diff -Nru a/drivers/net/8139cp.c b/drivers/net/8139cp.c
--- a/drivers/net/8139cp.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/8139cp.c	2004-12-24 13:36:48 -08:00
@@ -71,6 +71,7 @@
 #include <linux/udp.h>
 #include <linux/cache.h>
 #include <asm/io.h>
+#include <asm/irq.h>
 #include <asm/uaccess.h>
 
 /* VLAN tagging feature enable/disable */
@@ -335,7 +336,7 @@
 };
 
 struct cp_private {
-	void			*regs;
+	void			__iomem *regs;
 	struct net_device	*dev;
 	spinlock_t		lock;
 	u32			msg_enable;
@@ -366,7 +367,6 @@
 #endif
 
 	unsigned int		wol_enabled : 1; /* Is Wake-on-LAN enabled? */
-	u32			power_state[16];
 
 	struct mii_if_info	mii_if;
 };
@@ -1580,11 +1580,11 @@
 #define EE_READ_CMD		(6)
 #define EE_ERASE_CMD	(7)
 
-static int read_eeprom (void *ioaddr, int location, int addr_len)
+static int read_eeprom (void __iomem *ioaddr, int location, int addr_len)
 {
 	int i;
 	unsigned retval = 0;
-	void *ee_addr = ioaddr + Cfg9346;
+	void __iomem *ee_addr = ioaddr + Cfg9346;
 	int read_cmd = location | (EE_READ_CMD << addr_len);
 
 	writeb (EE_ENB & ~EE_CS, ee_addr);
@@ -1631,7 +1631,7 @@
 	struct net_device *dev;
 	struct cp_private *cp;
 	int rc;
-	void *regs;
+	void __iomem *regs;
 	long pciaddr;
 	unsigned int addr_len, i, pci_using_dac;
 	u8 pci_rev;
@@ -1845,7 +1845,7 @@
 	spin_unlock_irqrestore (&cp->lock, flags);
 
 	if (cp->pdev && cp->wol_enabled) {
-		pci_save_state (cp->pdev, cp->power_state);
+		pci_save_state (cp->pdev);
 		cp_set_d3_state (cp);
 	}
 
@@ -1864,7 +1864,7 @@
 	
 	if (cp->pdev && cp->wol_enabled) {
 		pci_set_power_state (cp->pdev, 0);
-		pci_restore_state (cp->pdev, cp->power_state);
+		pci_restore_state (cp->pdev);
 	}
 	
 	cp_init_hw (cp);
diff -Nru a/drivers/net/8139too.c b/drivers/net/8139too.c
--- a/drivers/net/8139too.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/8139too.c	2004-12-24 13:36:16 -08:00
@@ -567,7 +567,6 @@
 	void *mmio_addr;
 	int drv_flags;
 	struct pci_dev *pci_dev;
-	u32 pci_state[16];
 	u32 msg_enable;
 	struct net_device_stats stats;
 	unsigned char *rx_ring;
@@ -600,10 +599,10 @@
 MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM (multicast_filter_limit, "i");
-MODULE_PARM (media, "1-" __MODULE_STRING(MAX_UNITS) "i");
-MODULE_PARM (full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
-MODULE_PARM (debug, "i");
+module_param(multicast_filter_limit, int, 0);
+module_param_array(media, int, NULL, 0);
+module_param_array(full_duplex, int, NULL, 0);
+module_param(debug, int, 0);
 MODULE_PARM_DESC (debug, "8139too bitmapped message enable number");
 MODULE_PARM_DESC (multicast_filter_limit, "8139too maximum number of filtered multicast addresses");
 MODULE_PARM_DESC (media, "8139too: Bits 4+9: force full duplex, bit 5: 100Mbps");
@@ -2589,7 +2588,7 @@
 	void *ioaddr = tp->mmio_addr;
 	unsigned long flags;
 
-	pci_save_state (pdev, tp->pci_state);
+	pci_save_state (pdev);
 
 	if (!netif_running (dev))
 		return 0;
@@ -2617,9 +2616,8 @@
 static int rtl8139_resume (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
-	struct rtl8139_private *tp = dev->priv;
 
-	pci_restore_state (pdev, tp->pci_state);
+	pci_restore_state (pdev);
 	if (!netif_running (dev))
 		return 0;
 	pci_set_power_state (pdev, 0);
diff -Nru a/drivers/net/82596.c b/drivers/net/82596.c
--- a/drivers/net/82596.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/net/82596.c	2004-12-24 13:37:02 -08:00
@@ -53,8 +53,8 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/pgtable.h>
@@ -1260,7 +1260,7 @@
 	lp->scb.command = 0;
 	lp->scb.cmd = I596_NULL;
 	lp->scb.rfd = I596_NULL;
-	lp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&lp->lock);
 
 	err = register_netdev(dev);
 	if (err)
diff -Nru a/drivers/net/8390.c b/drivers/net/8390.c
--- a/drivers/net/8390.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/8390.c	2004-12-24 13:36:18 -08:00
@@ -58,9 +58,9 @@
 #include <linux/fs.h>
 #include <linux/types.h>
 #include <linux/string.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <linux/delay.h>
@@ -813,7 +813,7 @@
 	 * We wait at least 10ms.
 	 */
 
-	udelay(10*1000);
+	mdelay(10);
 
 	/*
 	 * Reset RBCR[01] back to zero as per magic incantation.
diff -Nru a/drivers/net/Kconfig b/drivers/net/Kconfig
--- a/drivers/net/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/Kconfig	2004-12-24 13:37:18 -08:00
@@ -288,7 +288,7 @@
 
 config APNE
 	tristate "PCMCIA NE2000 support"
-	depends on NETDEVICES && AMIGA_PCMCIA
+	depends on NET_ETHERNET && AMIGA_PCMCIA
 	select CRC32
 	help
 	  If you have a PCMCIA NE2000 compatible adapter, say Y.  Otherwise,
@@ -299,7 +299,7 @@
 
 config APOLLO_ELPLUS
 	tristate "Apollo 3c505 support"
-	depends on NETDEVICES && APOLLO
+	depends on NET_ETHERNET && APOLLO
 	help
 	  Say Y or M here if your Apollo has a 3Com 3c505 ISA Ethernet card.
 	  If you don't have one made for Apollos, you can use one from a PC,
@@ -308,7 +308,7 @@
 
 config MAC8390
 	bool "Macintosh NS 8390 based ethernet cards"
-	depends on NETDEVICES && MAC
+	depends on NET_ETHERNET && MAC
 	select CRC32
 	help
 	  If you want to include a driver to support Nubus or LC-PDS
@@ -318,7 +318,7 @@
 
 config MAC89x0
 	tristate "Macintosh CS89x0 based ethernet cards"
-	depends on NETDEVICES && MAC && BROKEN
+	depends on NET_ETHERNET && MAC && BROKEN
 	---help---
 	  Support for CS89x0 chipset based Ethernet cards.  If you have a
 	  Nubus or LC-PDS network (Ethernet) card of this type, say Y and
@@ -331,7 +331,7 @@
 
 config MACSONIC
 	tristate "Macintosh SONIC based ethernet (onboard, NuBus, LC, CS)"
-	depends on NETDEVICES && MAC
+	depends on NET_ETHERNET && MAC
 	---help---
 	  Support for NatSemi SONIC based Ethernet devices.  This includes
 	  the onboard Ethernet in many Quadras as well as some LC-PDS,
@@ -345,7 +345,7 @@
 
 config MACMACE
 	bool "Macintosh (AV) onboard MACE ethernet (EXPERIMENTAL)"
-	depends on NETDEVICES && MAC && EXPERIMENTAL
+	depends on NET_ETHERNET && MAC && EXPERIMENTAL
 	select CRC32
 	help
 	  Support for the onboard AMD 79C940 MACE Ethernet controller used in
@@ -355,7 +355,7 @@
 
 config MVME147_NET
 	tristate "MVME147 (Lance) Ethernet support"
-	depends on NETDEVICES && MVME147
+	depends on NET_ETHERNET && MVME147
 	select CRC32
 	help
 	  Support for the on-board Ethernet interface on the Motorola MVME147
@@ -365,7 +365,7 @@
 
 config MVME16x_NET
 	tristate "MVME16x Ethernet support"
-	depends on NETDEVICES && MVME16x
+	depends on NET_ETHERNET && MVME16x
 	help
 	  This is the driver for the Ethernet interface on the Motorola
 	  MVME162, 166, 167, 172 and 177 boards.  Say Y here to include the
@@ -374,7 +374,7 @@
 
 config BVME6000_NET
 	tristate "BVME6000 Ethernet support"
-	depends on NETDEVICES && BVME6000
+	depends on NET_ETHERNET && BVME6000
 	help
 	  This is the driver for the Ethernet interface on BVME4000 and
 	  BVME6000 VME boards.  Say Y here to include the driver for this chip
@@ -383,7 +383,7 @@
 
 config ATARILANCE
 	tristate "Atari Lance support"
-	depends on NETDEVICES && ATARI
+	depends on NET_ETHERNET && ATARI
 	help
 	  Say Y to include support for several Atari Ethernet adapters based
 	  on the AMD Lance chipset: RieblCard (with or without battery), or
@@ -391,7 +391,7 @@
 
 config ATARI_BIONET
 	tristate "BioNet-100 support"
-	depends on NETDEVICES && ATARI && ATARI_ACSI!=n && BROKEN
+	depends on NET_ETHERNET && ATARI && ATARI_ACSI && BROKEN
 	help
 	  Say Y to include support for BioData's BioNet-100 Ethernet adapter
 	  for the ACSI port. The driver works (has to work...) with a polled
@@ -399,7 +399,7 @@
 
 config ATARI_PAMSNET
 	tristate "PAMsNet support"
-	depends on NETDEVICES && ATARI && ATARI_ACSI!=n && BROKEN
+	depends on NET_ETHERNET && ATARI && ATARI_ACSI && BROKEN
 	help
 	  Say Y to include support for the PAMsNet Ethernet adapter for the
 	  ACSI port ("ACSI node"). The driver works (has to work...) with a
@@ -407,7 +407,7 @@
 
 config SUN3LANCE
 	tristate "Sun3/Sun3x on-board LANCE support"
-	depends on NETDEVICES && (SUN3 || SUN3X)
+	depends on NET_ETHERNET && (SUN3 || SUN3X)
 	help
 	  Most Sun3 and Sun3x motherboards (including the 3/50, 3/60 and 3/80)
 	  featured an AMD Lance 10Mbit Ethernet controller on board; say Y
@@ -420,7 +420,7 @@
 
 config SUN3_82586
 	tristate "Sun3 on-board Intel 82586 support"
-	depends on NETDEVICES && SUN3
+	depends on NET_ETHERNET && SUN3
 	help
 	  This driver enables support for the on-board Intel 82586 based
 	  Ethernet adapter found on Sun 3/1xx and 3/2xx motherboards.  Note
@@ -429,7 +429,7 @@
 
 config HPLANCE
 	bool "HP on-board LANCE support"
-	depends on NETDEVICES && HP300
+	depends on NET_ETHERNET && DIO
 	select CRC32
 	help
 	  If you want to use the builtin "LANCE" Ethernet controller on an
@@ -1413,66 +1413,17 @@
 	depends on NET_PCI && PCI
 	select MII
 	---help---
-	  This driver supports Intel(R) PRO/100 family of adapters, which 
-	  includes:
-
-	  Controller  Adapter Name                       Board IDs
-	  ----------  ------------                       ---------
-
-	  82558       PRO/100+ PCI Adapter               668081-xxx, 
-	  689661-xxx
-	  82558       PRO/100+ Management Adapter        691334-xxx, 
-	  701738-xxx,
-	  721383-xxx
-	  82558       PRO/100+ Dual Port Server Adapter  714303-xxx, 
-	  711269-xxx, 
-	  A28276-xxx
-	  82558       PRO/100+ PCI Server Adapter        710550-xxx
-	  82550       PRO/100 S Server Adapter           752438-xxx
-	  82559                                          A56831-xxx, 
-	  A10563-xxx,
-	  A12171-xxx, 
-	  A12321-xxx, 
-	  A12320-xxx, 
-	  A12170-xxx
-	  748568-xxx
-	  748565-xxx
-	  82550       PRO/100 S Desktop Adapter          751767-xxx
-	  82559                                          748592-xxx, 
-	  A12167-xxx, 
-	  A12318-xxx, 
-	  A12317-xxx, 
-	  A12165-xxx,
-	  748569-xxx 
-	  82559       PRO/100+ Server Adapter            729757-xxx
-	  82559       PRO/100 S Management Adapter       748566-xxx, 
-	  748564-xxx
-	  82550       PRO/100 S Dual Port Server Adapter A56831-xxx
-	  82551       PRO/100 M Desktop Adapter          A80897-xxx
-	  PRO/100 S Advanced Management Adapter 
-	  747842-xxx, 
-	  745171-xxx
-	  CNR         PRO/100 VE Desktop Adapter         A10386-xxx, 
-	  A10725-xxx, 
-	  A23801-xxx, 
-	  A19716-xxx
-	  PRO/100 VM Desktop Adapter         A14323-xxx, 
-	  A19725-xxx, 
-	  A23801-xxx, 
-	  A22220-xxx, 
-	  A23796-xxx
-
-
+	  This driver supports Intel(R) PRO/100 family of adapters.
 	  To verify that your adapter is supported, find the board ID number 
 	  on the adapter. Look for a label that has a barcode and a number 
-	  in the format 123456-001 (six digits hyphen three digits). Match 
-	  this to the list of numbers above.
+	  in the format 123456-001 (six digits hyphen three digits). 
 
-	  For more information on how to identify your adapter, go to the 
-	  Adapter & Driver ID Guide at:
+	  Use the above information and the Adapter & Driver ID Guide at:
 
 	  http://support.intel.com/support/network/adapter/pro100/21397.htm
 
+          to identify the adapter.
+
 	  For the latest Intel PRO/100 network driver for Linux, see:
 
 	  http://appsr.intel.com/scripts-df/support_intel.asp
@@ -1742,18 +1693,6 @@
 
 	  If unsure, say Y.
 
-config VIA_VELOCITY
-	tristate "VIA Velocity support"
-	depends on NET_PCI && PCI
-	select CRC32
-	select CRC_CCITT
-	select MII
-	help
-	  If you have a VIA "Velocity" based network card say Y here.
-
-	  To compile this driver as a module, choose M here. The module
-	  will be called via-velocity.
-
 config LAN_SAA9730
 	bool "Philips SAA9730 Ethernet support (EXPERIMENTAL)"
 	depends on NET_PCI && EXPERIMENTAL && MIPS
@@ -1933,29 +1872,8 @@
 	depends on PCI
 	---help---
 	  This driver supports Intel(R) PRO/1000 gigabit ethernet family of
-	  adapters, which includes:
-
-	  Controller  Adapter Name                         Board IDs
-	  ----------  ------------                         ---------
-	  82542       PRO/1000 Gigabit Server Adapter      700262-xxx,
-	  717037-xxx
-	  82543       PRO/1000 F Server Adapter            738640-xxx,
-	  A38888-xxx
-	  82543       PRO/1000 T Server Adapter            A19845-xxx,
-	  A33948-xxx
-	  82544       PRO/1000 XT Server Adapter           A51580-xxx
-	  82544       PRO/1000 XF Server Adapter           A50484-xxx
-	  82544       PRO/1000 T Desktop Adapter           A62947-xxx
-	  82540       PRO/1000 MT Desktop Adapter          A78408-xxx
-	  82541       PRO/1000 MT Desktop Adapter          C91016-xxx
-	  82545       PRO/1000 MT Server Adapter           A92165-xxx
-	  82546       PRO/1000 MT Dual Port Server Adapter A92111-xxx
-	  82545       PRO/1000 MF Server Adapter           A91622-xxx
-	  82545       PRO/1000 MF Server Adapter(LX)       A91624-xxx
-	  82546       PRO/1000 MF Dual Port Server Adapter A91620-xxx 
-
-	  For more information on how to identify your adapter, go to the
-	  Adapter & Driver ID Guide at:
+	  adapters.  For more information on how to identify your adapter, go 
+	  to the Adapter & Driver ID Guide at:
 
 	  <http://support.intel.com/support/network/adapter/pro100/21397.htm>
 
@@ -2140,6 +2058,18 @@
 	  say M here and read Documentation/kbuild/modules.txt. The module will
 	  be called sk98lin. This is recommended.
 
+config VIA_VELOCITY
+	tristate "VIA Velocity support"
+	depends on NET_PCI && PCI
+	select CRC32
+	select CRC_CCITT
+	select MII
+	help
+	  If you have a VIA "Velocity" based network card say Y here.
+
+	  To compile this driver as a module, choose M here. The module
+	  will be called via-velocity.
+
 config TIGON3
 	tristate "Broadcom Tigon3 support"
 	depends on PCI
@@ -2202,14 +2132,8 @@
 	depends on PCI
 	---help---
 	  This driver supports Intel(R) PRO/10GbE family of
-	  adapters, which includes:
-
-	  Controller  Adapter Name                           Board IDs
-	  ----------  ------------                           ---------
-	  82597EX     Intel(R) PRO/10GbE LR Server Adapter   A82505-xxx
-
-	  For more information on how to identify your adapter, go to the
-	  Adapter & Driver ID Guide at:
+	  adapters.  For more information on how to identify your adapter, go
+	  to the Adapter & Driver ID Guide at:
 
 	  <http://support.intel.com/support/network/adapter/pro100/21397.htm>
 
diff -Nru a/drivers/net/Makefile b/drivers/net/Makefile
--- a/drivers/net/Makefile	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/Makefile	2004-12-24 13:36:31 -08:00
@@ -194,5 +194,6 @@
 obj-$(CONFIG_NET_TULIP) += tulip/
 obj-$(CONFIG_HAMRADIO) += hamradio/
 obj-$(CONFIG_IRDA) += irda/
+obj-$(CONFIG_ETRAX_ETHERNET) += cris/
 
 obj-$(CONFIG_NETCONSOLE) += netconsole.o
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
--- a/drivers/net/Space.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/Space.c	2004-12-24 13:36:18 -08:00
@@ -284,9 +284,6 @@
 #ifdef CONFIG_ATARI_PAMSNET	/* Atari PAMsNet Ethernet board */
 	{pamsnet_probe, 0},
 #endif
-#ifdef CONFIG_HPLANCE		/* HP300 internal Ethernet */
-	{hplance_probe, 0},
-#endif
 #ifdef CONFIG_MVME147_NET	/* MVME147 internal Ethernet */
 	{mvme147lance_probe, 0},
 #endif
diff -Nru a/drivers/net/a2065.c b/drivers/net/a2065.c
--- a/drivers/net/a2065.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/net/a2065.c	2004-12-24 13:36:59 -08:00
@@ -52,8 +52,8 @@
 #include <linux/init.h>
 #include <linux/crc32.h>
 #include <linux/zorro.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/irq.h>
 #include <asm/amigaints.h>
 #include <asm/amigahw.h>
diff -Nru a/drivers/net/acenic.c b/drivers/net/acenic.c
--- a/drivers/net/acenic.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/acenic.c	2004-12-24 13:36:48 -08:00
@@ -427,14 +427,13 @@
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("AceNIC/3C985/GA620 Gigabit Ethernet driver");
 
-static int num_params;
-module_param_array(link, int, num_params, 0);
-module_param_array(trace, int, num_params, 0);
-module_param_array(tx_coal_tick, int, num_params, 0);
-module_param_array(max_tx_desc, int, num_params, 0);
-module_param_array(rx_coal_tick, int, num_params, 0);
-module_param_array(max_rx_desc, int, num_params, 0);
-module_param_array(tx_ratio, int, num_params, 0);
+module_param_array(link, int, NULL, 0);
+module_param_array(trace, int, NULL, 0);
+module_param_array(tx_coal_tick, int, NULL, 0);
+module_param_array(max_tx_desc, int, NULL, 0);
+module_param_array(rx_coal_tick, int, NULL, 0);
+module_param_array(max_rx_desc, int, NULL, 0);
+module_param_array(tx_ratio, int, NULL, 0);
 MODULE_PARM_DESC(link, "AceNIC/3C985/NetGear link state");
 MODULE_PARM_DESC(trace, "AceNIC/3C985/NetGear firmware trace level");
 MODULE_PARM_DESC(tx_coal_tick, "AceNIC/3C985/GA620 max clock ticks to wait from first tx descriptor arrives");
@@ -444,7 +443,7 @@
 MODULE_PARM_DESC(tx_ratio, "AceNIC/3C985/GA620 ratio of NIC memory used for TX/RX descriptors (range 0-63)");
 
 
-static char version[] __initdata = 
+static char version[] __devinitdata = 
   "acenic.c: v0.92 08/05/2002  Jes Sorensen, linux-acenic@SunSITE.dk\n"
   "                            http://home.cern.ch/~jes/gige/acenic.html\n";
 
@@ -458,6 +457,8 @@
 	.get_drvinfo = ace_get_drvinfo,
 };
 
+static void ace_watchdog(struct net_device *dev);
+
 static int __devinit acenic_probe_one(struct pci_dev *pdev,
 		const struct pci_device_id *id)
 {
@@ -486,7 +487,6 @@
 	dev->vlan_rx_kill_vid = ace_vlan_rx_kill_vid;
 #endif
 	if (1) {
-		static void ace_watchdog(struct net_device *dev);
 		dev->tx_timeout = &ace_watchdog;
 		dev->watchdog_timeo = 5*HZ;
 	}
@@ -539,7 +539,7 @@
 	 * addresses but who gives a damn.
 	 */
 	dev->base_addr = pci_resource_start(pdev, 0);
-	ap->regs = (struct ace_regs *)ioremap(dev->base_addr, 0x4000);
+	ap->regs = ioremap(dev->base_addr, 0x4000);
 	if (!ap->regs) {
 		printk(KERN_ERR "%s:  Unable to map I/O register, "
 		       "AceNIC %i will be disabled.\n",
@@ -632,7 +632,7 @@
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
 	struct ace_private *ap = netdev_priv(dev);
-	struct ace_regs *regs = ap->regs;
+	struct ace_regs __iomem *regs = ap->regs;
 	short i;
 
 	unregister_netdev(dev);
@@ -885,7 +885,7 @@
 /*
  * Commands are considered to be slow.
  */
-static inline void ace_issue_cmd(struct ace_regs *regs, struct cmd *cmd)
+static inline void ace_issue_cmd(struct ace_regs __iomem *regs, struct cmd *cmd)
 {
 	u32 idx;
 
@@ -898,10 +898,10 @@
 }
 
 
-static int __init ace_init(struct net_device *dev)
+static int __devinit ace_init(struct net_device *dev)
 {
 	struct ace_private *ap;
-	struct ace_regs *regs;
+	struct ace_regs __iomem *regs;
 	struct ace_info *info = NULL;
 	struct pci_dev *pdev;
 	unsigned long myjif;
@@ -1319,11 +1319,10 @@
 	writel(TX_RING_BASE, &regs->WinBase);
 
 	if (ACE_IS_TIGON_I(ap)) {
-		ap->tx_ring = (struct tx_desc *)regs->Window;
-		for (i = 0; i < (TIGON_I_TX_RING_ENTRIES * 
-				 sizeof(struct tx_desc) / 4); i++) {
-			writel(0, (unsigned long)ap->tx_ring + i * 4);
-		}
+		ap->tx_ring = (struct tx_desc *) regs->Window;
+		for (i = 0; i < (TIGON_I_TX_RING_ENTRIES 
+				 * sizeof(struct tx_desc)) / sizeof(u32); i++)
+			writel(0, (void __iomem *)ap->tx_ring  + i * 4);
 
 		set_aceaddr(&info->tx_ctrl.rngptr, TX_RING_BASE);
 	} else {
@@ -1550,14 +1549,9 @@
 
 static void ace_set_rxtx_parms(struct net_device *dev, int jumbo)
 {
-	struct ace_private *ap;
-	struct ace_regs *regs;
-	int board_idx;
-
-	ap = netdev_priv(dev);
-	regs = ap->regs;
-
-	board_idx = ap->board_idx;
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
+	int board_idx = ap->board_idx;
 
 	if (board_idx >= 0) {
 		if (!jumbo) {
@@ -1595,7 +1589,7 @@
 {
 	struct net_device *dev = data;
 	struct ace_private *ap = netdev_priv(dev);
-	struct ace_regs *regs = ap->regs;
+	struct ace_regs __iomem *regs = ap->regs;
 
 	/*
 	 * We haven't received a stats update event for more than 2.5
@@ -1618,7 +1612,7 @@
 
 static void ace_tasklet(unsigned long dev)
 {
-	struct ace_private *ap = ((struct net_device *)dev)->priv;
+	struct ace_private *ap = netdev_priv((struct net_device *)dev);
 	int cur_size;
 
 	cur_size = atomic_read(&ap->cur_rx_bufs);
@@ -1676,10 +1670,9 @@
  */
 static void ace_load_std_rx_ring(struct ace_private *ap, int nr_bufs)
 {
-	struct ace_regs *regs;
+	struct ace_regs __iomem *regs = ap->regs;
 	short i, idx;
-
-	regs = ap->regs;
+	
 
 	prefetchw(&ap->cur_rx_bufs);
 
@@ -1740,11 +1733,9 @@
 
 static void ace_load_mini_rx_ring(struct ace_private *ap, int nr_bufs)
 {
-	struct ace_regs *regs;
+	struct ace_regs __iomem *regs = ap->regs;
 	short i, idx;
 
-	regs = ap->regs;
-
 	prefetchw(&ap->cur_mini_bufs);
 
 	idx = ap->rx_mini_skbprd;
@@ -1799,11 +1790,9 @@
  */
 static void ace_load_jumbo_rx_ring(struct ace_private *ap, int nr_bufs)
 {
-	struct ace_regs *regs;
+	struct ace_regs __iomem *regs = ap->regs;
 	short i, idx;
 
-	regs = ap->regs;
-
 	idx = ap->rx_jumbo_skbprd;
 
 	for (i = 0; i < nr_bufs; i++) {
@@ -2083,8 +2072,7 @@
 	 * the 12.3.x Firmware - my Tigon I NICs seem to disagree!
 	 */
 	if (ACE_IS_TIGON_I(ap)) {
-		struct ace_regs *regs = ap->regs;
-		writel(idx, &regs->RxRetCsm);
+		writel(idx, &ap->regs->RxRetCsm);
 	}
 	ap->cur_rx = idx;
 
@@ -2164,16 +2152,13 @@
 
 static irqreturn_t ace_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
 {
-	struct ace_private *ap;
-	struct ace_regs *regs;
 	struct net_device *dev = (struct net_device *)dev_id;
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
 	u32 idx;
 	u32 txcsm, rxretcsm, rxretprd;
 	u32 evtcsm, evtprd;
 
-	ap = netdev_priv(dev);
-	regs = ap->regs;
-
 	/*
 	 * In case of PCI shared interrupts or spurious interrupts,
 	 * we want to make sure it is actually our interrupt before
@@ -2326,13 +2311,10 @@
 
 static int ace_open(struct net_device *dev)
 {
-	struct ace_private *ap;
-	struct ace_regs *regs;
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
 	struct cmd cmd;
 
-	ap = netdev_priv(dev);
-	regs = ap->regs;
-
 	if (!(ap->fw_running)) {
 		printk(KERN_WARNING "%s: Firmware not running!\n", dev->name);
 		return -EBUSY;
@@ -2384,8 +2366,8 @@
 
 static int ace_close(struct net_device *dev)
 {
-	struct ace_private *ap;
-	struct ace_regs *regs;
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
 	struct cmd cmd;
 	unsigned long flags;
 	short i;
@@ -2397,9 +2379,7 @@
 	 */
 	netif_stop_queue(dev);
 
-	ap = netdev_priv(dev);
-	regs = ap->regs;
-
+	
 	if (ap->promisc) {
 		cmd.evt = C_SET_PROMISC_MODE;
 		cmd.code = C_C_PROMISC_DISABLE;
@@ -2434,9 +2414,11 @@
 
 		if (mapping) {
 			if (ACE_IS_TIGON_I(ap)) {
-				writel(0, &ap->tx_ring[i].addr.addrhi);
-				writel(0, &ap->tx_ring[i].addr.addrlo);
-				writel(0, &ap->tx_ring[i].flagsize);
+				struct tx_desc __iomem *tx 
+					= (struct tx_desc __iomem *) &ap->tx_ring[i];
+				writel(0, &tx->addr.addrhi);
+				writel(0, &tx->addr.addrlo);
+				writel(0, &tx->flagsize);
 			} else
 				memset(ap->tx_ring + i, 0,
 				       sizeof(struct tx_desc));
@@ -2493,11 +2475,12 @@
 #endif
 
 	if (ACE_IS_TIGON_I(ap)) {
-		writel(addr >> 32, &desc->addr.addrhi);
-		writel(addr & 0xffffffff, &desc->addr.addrlo);
-		writel(flagsize, &desc->flagsize);
+		struct tx_desc __iomem *io = (struct tx_desc __iomem *) desc;
+		writel(addr >> 32, &io->addr.addrhi);
+		writel(addr & 0xffffffff, &io->addr.addrlo);
+		writel(flagsize, &io->flagsize);
 #if ACENIC_DO_VLAN
-		writel(vlan_tag, &desc->vlanres);
+		writel(vlan_tag, &io->vlanres);
 #endif
 	} else {
 		desc->addr.addrhi = addr >> 32;
@@ -2513,9 +2496,10 @@
 static int ace_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct ace_private *ap = netdev_priv(dev);
-	struct ace_regs *regs = ap->regs;
+	struct ace_regs __iomem *regs = ap->regs;
 	struct tx_desc *desc;
 	u32 idx, flagsize;
+	unsigned long maxjiff = jiffies + 3*HZ;
 
 restart:
 	idx = ap->tx_prd;
@@ -2523,10 +2507,7 @@
 	if (tx_ring_full(ap, ap->tx_ret_csm, idx))
 		goto overflow;
 
-#if MAX_SKB_FRAGS
-	if (!skb_shinfo(skb)->nr_frags)
-#endif
-	{
+	if (!skb_shinfo(skb)->nr_frags)	{
 		dma_addr_t mapping;
 		u32 vlan_tag = 0;
 
@@ -2548,9 +2529,7 @@
 			flagsize |= BD_FLG_COAL_NOW;
 
 		ace_load_tx_bd(ap, desc, mapping, flagsize, vlan_tag);
-	}
-#if MAX_SKB_FRAGS
-	else {
+	} else {
 		dma_addr_t mapping;
 		u32 vlan_tag = 0;
 		int i, len = 0;
@@ -2605,7 +2584,6 @@
 			ace_load_tx_bd(ap, desc, mapping, flagsize, vlan_tag);
 		}
 	}
-#endif
 
  	wmb();
  	ap->tx_prd = idx;
@@ -2625,7 +2603,7 @@
 	}
 
 	dev->trans_start = jiffies;
-	return 0;
+	return NETDEV_TX_OK;
 
 overflow:
 	/*
@@ -2644,15 +2622,22 @@
 	 * Alternative is to return with 1 not throttling queue. In this
 	 * case loop becomes longer, no more useful effects.
 	 */
-	barrier();
-	goto restart;
+	if (time_before(jiffies, maxjiff)) {
+		barrier();
+		cpu_relax();
+		goto restart;
+	}
+	
+	/* The ring is stuck full. */
+	printk(KERN_WARNING "%s: Transmit ring stuck full\n", dev->name);
+	return NETDEV_TX_BUSY;
 }
 
 
 static int ace_change_mtu(struct net_device *dev, int new_mtu)
 {
 	struct ace_private *ap = netdev_priv(dev);
-	struct ace_regs *regs = ap->regs;
+	struct ace_regs __iomem *regs = ap->regs;
 
 	if (new_mtu > ACE_JUMBO_MTU)
 		return -EINVAL;
@@ -2689,7 +2674,7 @@
 static int ace_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
 	struct ace_private *ap = netdev_priv(dev);
-	struct ace_regs *regs = ap->regs;
+	struct ace_regs __iomem *regs = ap->regs;
 	u32 link;
 
 	memset(ecmd, 0, sizeof(struct ethtool_cmd));
@@ -2742,7 +2727,7 @@
 static int ace_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
 	struct ace_private *ap = netdev_priv(dev);
-	struct ace_regs *regs = ap->regs;
+	struct ace_regs __iomem *regs = ap->regs;
 	u32 link, speed;
 
 	link = readl(&regs->GigLnkState);
@@ -2822,8 +2807,9 @@
  */
 static int ace_set_mac_addr(struct net_device *dev, void *p)
 {
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
 	struct sockaddr *addr=p;
-	struct ace_regs *regs;
 	u8 *da;
 	struct cmd cmd;
 
@@ -2834,7 +2820,6 @@
 
 	da = (u8 *)dev->dev_addr;
 
-	regs = ((struct ace_private *)netdev_priv(dev))->regs;
 	writel(da[0] << 8 | da[1], &regs->MacAddrHi);
 	writel((da[2] << 24) | (da[3] << 16) | (da[4] << 8) | da[5],
 	       &regs->MacAddrLo);
@@ -2851,7 +2836,7 @@
 static void ace_set_multicast_list(struct net_device *dev)
 {
 	struct ace_private *ap = netdev_priv(dev);
-	struct ace_regs *regs = ap->regs;
+	struct ace_regs __iomem *regs = ap->regs;
 	struct cmd cmd;
 
 	if ((dev->flags & IFF_ALLMULTI) && !(ap->mcast_all)) {
@@ -2905,8 +2890,8 @@
 static struct net_device_stats *ace_get_stats(struct net_device *dev)
 {
 	struct ace_private *ap = netdev_priv(dev);
-	struct ace_mac_stats *mac_stats =
-		(struct ace_mac_stats *)ap->regs->Stats;
+	struct ace_mac_stats __iomem *mac_stats =
+		(struct ace_mac_stats __iomem *)ap->regs->Stats;
 
 	ap->stats.rx_missed_errors = readl(&mac_stats->drop_space);
 	ap->stats.multicast = readl(&mac_stats->kept_mc);
@@ -2916,10 +2901,10 @@
 }
 
 
-static void __init ace_copy(struct ace_regs *regs, void *src,
+static void __devinit ace_copy(struct ace_regs __iomem *regs, void *src,
 			    u32 dest, int size)
 {
-	unsigned long tdest;
+	void __iomem *tdest;
 	u32 *wsrc;
 	short tsize, i;
 
@@ -2929,7 +2914,7 @@
 	while (size > 0) {
 		tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
 			    min_t(u32, size, ACE_WINDOW_SIZE));
-		tdest = (unsigned long)&regs->Window +
+		tdest = (void __iomem *) &regs->Window + 
 			(dest & (ACE_WINDOW_SIZE - 1));
 		writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase);
 		/*
@@ -2949,9 +2934,9 @@
 }
 
 
-static void __init ace_clear(struct ace_regs *regs, u32 dest, int size)
+static void __devinit ace_clear(struct ace_regs __iomem *regs, u32 dest, int size)
 {
-	unsigned long tdest;
+	void __iomem *tdest;
 	short tsize = 0, i;
 
 	if (size <= 0)
@@ -2960,7 +2945,7 @@
 	while (size > 0) {
 		tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
 				min_t(u32, size, ACE_WINDOW_SIZE));
-		tdest = (unsigned long)&regs->Window +
+		tdest = (void __iomem *) &regs->Window + 
 			(dest & (ACE_WINDOW_SIZE - 1));
 		writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase);
 
@@ -2982,13 +2967,10 @@
  * This operation requires the NIC to be halted and is performed with
  * interrupts disabled and with the spinlock hold.
  */
-int __init ace_load_firmware(struct net_device *dev)
+int __devinit ace_load_firmware(struct net_device *dev)
 {
-	struct ace_private *ap;
-	struct ace_regs *regs;
-
-	ap = netdev_priv(dev);
-	regs = ap->regs;
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
 
 	if (!(readl(&regs->CpuCtrl) & CPU_HALTED)) {
 		printk(KERN_ERR "%s: trying to download firmware while the "
@@ -3036,7 +3018,7 @@
  * Thanks to Stevarino Webinski for helping tracking down the bugs in the
  * code i2c readout code by beta testing all my hacks.
  */
-static void __init eeprom_start(struct ace_regs *regs)
+static void __devinit eeprom_start(struct ace_regs __iomem *regs)
 {
 	u32 local;
 
@@ -3065,7 +3047,7 @@
 }
 
 
-static void __init eeprom_prep(struct ace_regs *regs, u8 magic)
+static void __devinit eeprom_prep(struct ace_regs __iomem *regs, u8 magic)
 {
 	short i;
 	u32 local;
@@ -3102,7 +3084,7 @@
 }
 
 
-static int __init eeprom_check_ack(struct ace_regs *regs)
+static int __devinit eeprom_check_ack(struct ace_regs __iomem *regs)
 {
 	int state;
 	u32 local;
@@ -3130,7 +3112,7 @@
 }
 
 
-static void __init eeprom_stop(struct ace_regs *regs)
+static void __devinit eeprom_stop(struct ace_regs __iomem *regs)
 {
 	u32 local;
 
@@ -3165,11 +3147,11 @@
 /*
  * Read a whole byte from the EEPROM.
  */
-static int __init read_eeprom_byte(struct net_device *dev,
+static int __devinit read_eeprom_byte(struct net_device *dev,
 				   unsigned long offset)
 {
-	struct ace_private *ap;
-	struct ace_regs *regs;
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
 	unsigned long flags;
 	u32 local;
 	int result = 0;
@@ -3180,9 +3162,6 @@
 		result = -ENODEV;
 		goto out;
 	}
-
-	ap = netdev_priv(dev);
-	regs = ap->regs;
 
 	/*
 	 * Don't take interrupts on this CPU will bit banging
diff -Nru a/drivers/net/acenic.h b/drivers/net/acenic.h
--- a/drivers/net/acenic.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/acenic.h	2004-12-24 13:36:48 -08:00
@@ -10,11 +10,6 @@
  */
 #define USE_TX_COAL_NOW	 0
 
-#ifndef MAX_SKB_FRAGS
-#define MAX_SKB_FRAGS 0
-#endif
-
-
 /*
  * Addressing:
  *
@@ -638,7 +633,7 @@
 struct ace_private
 {
 	struct ace_info		*info;
-	struct ace_regs		*regs;		/* register base */
+	struct ace_regs	__iomem	*regs;		/* register base */
 	struct ace_skb		*skb;
 	dma_addr_t		info_dma;	/* 32/64 bit */
 
@@ -712,13 +707,7 @@
 }
 
 #define tx_free(ap) 		tx_space((ap)->tx_ret_csm, (ap)->tx_prd, ap)
-
-#if MAX_SKB_FRAGS
 #define tx_ring_full(ap, csm, prd)	(tx_space(ap, csm, prd) <= TX_RESERVED)
-#else
-#define tx_ring_full			0
-#endif
-
 
 static inline void set_aceaddr(aceaddr *aa, dma_addr_t addr)
 {
@@ -729,7 +718,7 @@
 }
 
 
-static inline void ace_set_txprd(struct ace_regs *regs,
+static inline void ace_set_txprd(struct ace_regs __iomem *regs,
 				 struct ace_private *ap, u32 value)
 {
 #ifdef INDEX_DEBUG
@@ -750,8 +739,8 @@
 
 static inline void ace_mask_irq(struct net_device *dev)
 {
-	struct ace_private *ap = dev->priv;
-	struct ace_regs *regs = ap->regs;
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
 
 	if (ACE_IS_TIGON_I(ap))
 		writel(1, &regs->MaskInt);
@@ -764,8 +753,8 @@
 
 static inline void ace_unmask_irq(struct net_device *dev)
 {
-	struct ace_private *ap = dev->priv;
-	struct ace_regs *regs = ap->regs;
+	struct ace_private *ap = netdev_priv(dev);
+	struct ace_regs __iomem *regs = ap->regs;
  
 	if (ACE_IS_TIGON_I(ap))
 		writel(0, &regs->MaskInt);
diff -Nru a/drivers/net/acenic_firmware.h b/drivers/net/acenic_firmware.h
--- a/drivers/net/acenic_firmware.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/acenic_firmware.h	2004-12-24 13:37:00 -08:00
@@ -23,7 +23,7 @@
 #define tigonFwRodata NULL
 #else
 /* Generated by genfw.c */
-static u32 tigonFwText[(MAX_TEXT_LEN/4) + 1] __initdata = {
+static u32 tigonFwText[(MAX_TEXT_LEN/4) + 1] __devinitdata = {
 0x10000003, 
 0x0, 0xd, 0xd, 0x3c1d0001, 
 0x8fbd5c54, 0x3a0f021, 0x3c100000, 0x26104000, 
diff -Nru a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
--- a/drivers/net/amd8111e.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/amd8111e.c	2004-12-24 13:37:43 -08:00
@@ -124,7 +124,7 @@
 */
 static int amd8111e_read_phy(struct amd8111e_priv* lp, int phy_id, int reg, u32* val)
 {
-	void * mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 	unsigned int reg_val;
 	unsigned int repeat= REPEAT_CNT;
 
@@ -155,7 +155,7 @@
 static int amd8111e_write_phy(struct amd8111e_priv* lp,int phy_id, int reg, u32 val)
 {
 	unsigned int repeat = REPEAT_CNT
-	void * mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 	unsigned int reg_val;
 
 	reg_val = readl(mmio + PHY_ACCESS);
@@ -211,7 +211,7 @@
 	u32 bmcr,advert,tmp;
 	
 	/* Determine mii register values to set the speed */
-	advert = amd8111e_mdio_read(dev, PHY_ID, MII_ADVERTISE);
+	advert = amd8111e_mdio_read(dev, lp->ext_phy_addr, MII_ADVERTISE);
 	tmp = advert & ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
 	switch (lp->ext_phy_option){
 
@@ -235,11 +235,11 @@
 	}
 
 	if(advert != tmp)
-		amd8111e_mdio_write(dev, PHY_ID, MII_ADVERTISE, tmp);
+		amd8111e_mdio_write(dev, lp->ext_phy_addr, MII_ADVERTISE, tmp);
 	/* Restart auto negotiation */
-	bmcr = amd8111e_mdio_read(dev, PHY_ID, MII_BMCR);
+	bmcr = amd8111e_mdio_read(dev, lp->ext_phy_addr, MII_BMCR);
 	bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
-	amd8111e_mdio_write(dev, PHY_ID, MII_BMCR, bmcr);
+	amd8111e_mdio_write(dev, lp->ext_phy_addr, MII_BMCR, bmcr);
 
 }
 
@@ -350,6 +350,7 @@
 
 		lp->rx_ring[i].buff_phy_addr = cpu_to_le32(lp->rx_dma_addr[i]);
 		lp->rx_ring[i].buff_count = cpu_to_le16(lp->rx_buff_len-2);
+		wmb();
 		lp->rx_ring[i].rx_flags = cpu_to_le16(OWN_BIT);
 	}
 
@@ -384,7 +385,7 @@
 	unsigned int event_count;
 
 	struct amd8111e_priv *lp = netdev_priv(dev);
-	void* mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 	struct amd8111e_coalesce_conf * coal_conf = &lp->coal_conf;
 
 
@@ -442,7 +443,7 @@
 static int amd8111e_restart(struct net_device *dev)
 {
 	struct amd8111e_priv *lp = netdev_priv(dev);
-	void * mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 	int i,reg_val;
 
 	/* stop the chip */
@@ -522,14 +523,14 @@
 {
 	unsigned int reg_val;
 	unsigned int logic_filter[2] ={0,};
-	void * mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 
 
         /* stop the chip */
 	writel(RUN, mmio + CMD0);
 
 	/* AUTOPOLL0 Register *//*TBD default value is 8100 in FPS */
-	writew( 0x8101, mmio + AUTOPOLL0);
+	writew( 0x8100 | lp->ext_phy_addr, mmio + AUTOPOLL0);
 
 	/* Clear RCV_RING_BASE_ADDR */
 	writel(0, mmio + RCV_RING_BASE_ADDR0);
@@ -723,9 +724,9 @@
 /* This function handles the driver receive operation in polling mode */
 static int amd8111e_rx_poll(struct net_device *dev, int * budget)
 {
-	struct amd8111e_priv *lp = dev->priv;
+	struct amd8111e_priv *lp = netdev_priv(dev);
 	int rx_index = lp->rx_idx & RX_RING_DR_MOD_MASK;
-	void * mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 	struct sk_buff *skb,*new_skb;
 	int min_pkt_len, status;
 	unsigned int intr0;
@@ -740,11 +741,11 @@
 	do{   
 		/* process receive packets until we use the quota*/
 		/* If we own the next entry, it's a new packet. Send it up. */
-		while(!(lp->rx_ring[rx_index].rx_flags & OWN_BIT)){
-	       
-			/* check if err summary bit is set */ 
-			if(le16_to_cpu(lp->rx_ring[rx_index].rx_flags) 
-								& ERR_BIT){
+		while(1) {
+			status = le16_to_cpu(lp->rx_ring[rx_index].rx_flags);
+			if (status & OWN_BIT)
+				break;
+
 			/* 
 			 * There is a tricky error noted by John Murphy,
 			 * <murf@perftech.com> to Russ Nelson: Even with
@@ -753,89 +754,88 @@
 			 * the last correctly noting the error.
 			 */
 
-			/* reseting flags */
-			lp->rx_ring[rx_index].rx_flags &=RESET_RX_FLAGS;
-			goto err_next_pkt;
-
+			if(status & ERR_BIT) {
+				/* reseting flags */
+				lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
+				goto err_next_pkt;
 			}
 			/* check for STP and ENP */
-		status = le16_to_cpu(lp->rx_ring[rx_index].rx_flags);
-		if(!((status & STP_BIT) && (status & ENP_BIT))){
-			/* reseting flags */
-			lp->rx_ring[rx_index].rx_flags &=RESET_RX_FLAGS;
-			goto err_next_pkt;
-		}
-		pkt_len = le16_to_cpu(lp->rx_ring[rx_index].msg_count) - 4;
+			if(!((status & STP_BIT) && (status & ENP_BIT))){
+				/* reseting flags */
+				lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
+				goto err_next_pkt;
+			}
+			pkt_len = le16_to_cpu(lp->rx_ring[rx_index].msg_count) - 4;
 
 #if AMD8111E_VLAN_TAG_USED		
-		vtag = le16_to_cpu(lp->rx_ring[rx_index].rx_flags) & TT_MASK;
-		/*MAC will strip vlan tag*/ 
-		if(lp->vlgrp != NULL && vtag !=0)
-			min_pkt_len =MIN_PKT_LEN - 4;
-		else
+			vtag = status & TT_MASK;
+			/*MAC will strip vlan tag*/ 
+			if(lp->vlgrp != NULL && vtag !=0)
+				min_pkt_len =MIN_PKT_LEN - 4;
+			else
 #endif
-			min_pkt_len =MIN_PKT_LEN;
+				min_pkt_len =MIN_PKT_LEN;
 
-		if (pkt_len < min_pkt_len) {
-			lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
-			lp->drv_rx_errors++;
-			goto err_next_pkt;
-		}
-		if(--rx_pkt_limit < 0)
-			goto rx_not_empty;
-		if(!(new_skb = dev_alloc_skb(lp->rx_buff_len))){
-			/* if allocation fail, 
-				ignore that pkt and go to next one */
-			lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
-			lp->drv_rx_errors++;
-			goto err_next_pkt;
-		}
+			if (pkt_len < min_pkt_len) {
+				lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
+				lp->drv_rx_errors++;
+				goto err_next_pkt;
+			}
+			if(--rx_pkt_limit < 0)
+				goto rx_not_empty;
+			if(!(new_skb = dev_alloc_skb(lp->rx_buff_len))){
+				/* if allocation fail, 
+				   ignore that pkt and go to next one */
+				lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
+				lp->drv_rx_errors++;
+				goto err_next_pkt;
+			}
 		
-		skb_reserve(new_skb, 2);
-		skb = lp->rx_skbuff[rx_index];
-		pci_unmap_single(lp->pci_dev,lp->rx_dma_addr[rx_index],
-			lp->rx_buff_len-2, PCI_DMA_FROMDEVICE);
-		skb_put(skb, pkt_len);
-		skb->dev = dev;
-		lp->rx_skbuff[rx_index] = new_skb;
-		new_skb->dev = dev;
-		lp->rx_dma_addr[rx_index] = pci_map_single(lp->pci_dev,
-			new_skb->data, lp->rx_buff_len-2,PCI_DMA_FROMDEVICE);
+			skb_reserve(new_skb, 2);
+			skb = lp->rx_skbuff[rx_index];
+			pci_unmap_single(lp->pci_dev,lp->rx_dma_addr[rx_index],
+					 lp->rx_buff_len-2, PCI_DMA_FROMDEVICE);
+			skb_put(skb, pkt_len);
+			skb->dev = dev;
+			lp->rx_skbuff[rx_index] = new_skb;
+			new_skb->dev = dev;
+			lp->rx_dma_addr[rx_index] = pci_map_single(lp->pci_dev,
+								   new_skb->data,
+								   lp->rx_buff_len-2,
+								   PCI_DMA_FROMDEVICE);
 	
-		skb->protocol = eth_type_trans(skb, dev);
+			skb->protocol = eth_type_trans(skb, dev);
 
 #if AMD8111E_VLAN_TAG_USED		
-		
-		vtag = lp->rx_ring[rx_index].rx_flags & TT_MASK;
-		if(lp->vlgrp != NULL && (vtag == TT_VLAN_TAGGED)){
-			amd8111e_vlan_rx(lp, skb,
-				    lp->rx_ring[rx_index].tag_ctrl_info);
-		} else
+			if(lp->vlgrp != NULL && (vtag == TT_VLAN_TAGGED)){
+				amd8111e_vlan_rx(lp, skb,
+					 le16_to_cpu(lp->rx_ring[rx_index].tag_ctrl_info));
+			} else
 #endif
-			
-			netif_receive_skb(skb);
-		/*COAL update rx coalescing parameters*/
-		lp->coal_conf.rx_packets++;
-		lp->coal_conf.rx_bytes += pkt_len;	
-		num_rx_pkt++;
-		dev->last_rx = jiffies;
+				netif_receive_skb(skb);
+			/*COAL update rx coalescing parameters*/
+			lp->coal_conf.rx_packets++;
+			lp->coal_conf.rx_bytes += pkt_len;	
+			num_rx_pkt++;
+			dev->last_rx = jiffies;
 	
-err_next_pkt:	
-		lp->rx_ring[rx_index].buff_phy_addr
-			 = cpu_to_le32(lp->rx_dma_addr[rx_index]);
-		lp->rx_ring[rx_index].buff_count = 
+		err_next_pkt:	
+			lp->rx_ring[rx_index].buff_phy_addr
+				= cpu_to_le32(lp->rx_dma_addr[rx_index]);
+			lp->rx_ring[rx_index].buff_count = 
 				cpu_to_le16(lp->rx_buff_len-2);
-		lp->rx_ring[rx_index].rx_flags |= cpu_to_le16(OWN_BIT);
-		rx_index = (++lp->rx_idx) & RX_RING_DR_MOD_MASK;
-	}
-	/* Check the interrupt status register for more packets in the 
-	mean time. Process them since we have not used up our quota.*/
-
-	intr0 = readl(mmio + INT0);
-	/*Ack receive packets */
-	writel(intr0 & RINT0,mmio + INT0);
+			wmb();
+			lp->rx_ring[rx_index].rx_flags |= cpu_to_le16(OWN_BIT);
+			rx_index = (++lp->rx_idx) & RX_RING_DR_MOD_MASK;
+		}
+		/* Check the interrupt status register for more packets in the 
+		   mean time. Process them since we have not used up our quota.*/
+
+		intr0 = readl(mmio + INT0);
+		/*Ack receive packets */
+		writel(intr0 & RINT0,mmio + INT0);
 
-	}while(intr0 & RINT0);
+	} while(intr0 & RINT0);
 
 	/* Receive descriptor is empty now */
 	dev->quota -= num_rx_pkt;
@@ -873,11 +873,12 @@
 	
 	/* If we own the next entry, it's a new packet. Send it up. */
 	while(++num_rx_pkt <= max_rx_pkt){
-		if(lp->rx_ring[rx_index].rx_flags & OWN_BIT)
+		status = le16_to_cpu(lp->rx_ring[rx_index].rx_flags);
+		if(status & OWN_BIT)
 			return 0;
 	       
 		/* check if err summary bit is set */ 
-		if(le16_to_cpu(lp->rx_ring[rx_index].rx_flags) & ERR_BIT){
+		if(status & ERR_BIT){
 			/* 
 			 * There is a tricky error noted by John Murphy,
 			 * <murf@perftech.com> to Russ Nelson: Even with full-sized
@@ -888,7 +889,6 @@
 			goto err_next_pkt;
 		}
 		/* check for STP and ENP */
-		status = le16_to_cpu(lp->rx_ring[rx_index].rx_flags);
 		if(!((status & STP_BIT) && (status & ENP_BIT))){
 			/* reseting flags */
 			lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
@@ -897,7 +897,7 @@
 		pkt_len = le16_to_cpu(lp->rx_ring[rx_index].msg_count) - 4;
 
 #if AMD8111E_VLAN_TAG_USED		
-		vtag = le16_to_cpu(lp->rx_ring[rx_index].rx_flags) & TT_MASK;
+		vtag = status & TT_MASK;
 		/*MAC will strip vlan tag*/ 
 		if(lp->vlgrp != NULL && vtag !=0)
 			min_pkt_len =MIN_PKT_LEN - 4;
@@ -931,12 +931,10 @@
 	
 		skb->protocol = eth_type_trans(skb, dev);
 
-#if AMD8111E_VLAN_TAG_USED		
-		
-		vtag = lp->rx_ring[rx_index].rx_flags & TT_MASK;
+#if AMD8111E_VLAN_TAG_USED				
 		if(lp->vlgrp != NULL && (vtag == TT_VLAN_TAGGED)){
 			amd8111e_vlan_rx(lp, skb,
-				    lp->rx_ring[rx_index].tag_ctrl_info);
+				 le16_to_cpu(lp->rx_ring[rx_index].tag_ctrl_info));
 		} else
 #endif
 			
@@ -952,6 +950,7 @@
 			 = cpu_to_le32(lp->rx_dma_addr[rx_index]);
 		lp->rx_ring[rx_index].buff_count = 
 				cpu_to_le16(lp->rx_buff_len-2);
+		wmb();
 		lp->rx_ring[rx_index].rx_flags |= cpu_to_le16(OWN_BIT);
 		rx_index = (++lp->rx_idx) & RX_RING_DR_MOD_MASK;
 	}
@@ -1004,7 +1003,7 @@
 /*
 This function reads the mib counters. 	 
 */
-static int amd8111e_read_mib(void* mmio, u8 MIB_COUNTER)
+static int amd8111e_read_mib(void __iomem *mmio, u8 MIB_COUNTER)
 {
 	unsigned int  status;
 	unsigned  int data;
@@ -1027,7 +1026,7 @@
 static struct net_device_stats *amd8111e_get_stats(struct net_device * dev)
 {
 	struct amd8111e_priv *lp = netdev_priv(dev);
-	void * mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 	unsigned long flags;
 	/* struct net_device_stats *prev_stats = &lp->prev_stats; */
 	struct net_device_stats* new_stats = &lp->stats;
@@ -1260,7 +1259,7 @@
 
 	struct net_device * dev = (struct net_device *) dev_id;
 	struct amd8111e_priv *lp = netdev_priv(dev);
-	void * mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 	unsigned int intr0;
 	unsigned int handled = 1;
 
@@ -1432,7 +1431,7 @@
 #if AMD8111E_VLAN_TAG_USED
 	if((lp->vlgrp != NULL) && vlan_tx_tag_present(skb)){
 		lp->tx_ring[tx_index].tag_ctrl_cmd |= 
-				cpu_to_le32(TCC_VLAN_INSERT);	
+				cpu_to_le16(TCC_VLAN_INSERT);	
 		lp->tx_ring[tx_index].tag_ctrl_info = 
 				cpu_to_le16(vlan_tx_tag_get(skb));
 
@@ -1444,6 +1443,7 @@
 	    (u32) cpu_to_le32(lp->tx_dma_addr[tx_index]);
 
 	/*  Set FCS and LTINT bits */
+	wmb();
 	lp->tx_ring[tx_index].tx_flags |=
 	    cpu_to_le16(OWN_BIT | STP_BIT | ENP_BIT|ADD_FCS_BIT|LTINT_BIT);
 
@@ -1464,32 +1464,25 @@
 /*
 This function returns all the memory mapped registers of the device.
 */
-static char* amd8111e_read_regs(struct amd8111e_priv* lp)
-{    	
-	void * mmio = lp->mmio;
-        u32 * reg_buff;
-
-     	reg_buff = kmalloc( AMD8111E_REG_DUMP_LEN,GFP_KERNEL);
-	if(NULL == reg_buff)
-		return NULL;
-
+static void amd8111e_read_regs(struct amd8111e_priv *lp, u32 *buf)
+{
+	void __iomem *mmio = lp->mmio;
 	/* Read only necessary registers */
-	reg_buff[0] = readl(mmio + XMT_RING_BASE_ADDR0);
-	reg_buff[1] = readl(mmio + XMT_RING_LEN0);
-	reg_buff[2] = readl(mmio + RCV_RING_BASE_ADDR0);
-	reg_buff[3] = readl(mmio + RCV_RING_LEN0);
-	reg_buff[4] = readl(mmio + CMD0);
-	reg_buff[5] = readl(mmio + CMD2);
-	reg_buff[6] = readl(mmio + CMD3);
-	reg_buff[7] = readl(mmio + CMD7);
-	reg_buff[8] = readl(mmio + INT0);
-	reg_buff[9] = readl(mmio + INTEN0);
-	reg_buff[10] = readl(mmio + LADRF);
-	reg_buff[11] = readl(mmio + LADRF+4);
-	reg_buff[12] = readl(mmio + STAT0);
-
-	return (char *)reg_buff;
+	buf[0] = readl(mmio + XMT_RING_BASE_ADDR0);
+	buf[1] = readl(mmio + XMT_RING_LEN0);
+	buf[2] = readl(mmio + RCV_RING_BASE_ADDR0);
+	buf[3] = readl(mmio + RCV_RING_LEN0);
+	buf[4] = readl(mmio + CMD0);
+	buf[5] = readl(mmio + CMD2);
+	buf[6] = readl(mmio + CMD3);
+	buf[7] = readl(mmio + CMD7);
+	buf[8] = readl(mmio + INT0);
+	buf[9] = readl(mmio + INTEN0);
+	buf[10] = readl(mmio + LADRF);
+	buf[11] = readl(mmio + LADRF+4);
+	buf[12] = readl(mmio + STAT0);
 }
+
 /*
 amd8111e crc generator implementation is different from the kernel
 ether_crc() function.
@@ -1567,131 +1560,101 @@
 
 }
 
-/*
-This function handles all the  ethtool ioctls. It gives driver info, gets/sets driver speed, gets memory mapped register values, forces auto negotiation, sets/gets WOL options for ethtool application. 
-*/
-	
-static int amd8111e_ethtool_ioctl(struct net_device* dev, void __user *useraddr)
+static void amd8111e_get_drvinfo(struct net_device* dev, struct ethtool_drvinfo *info)
 {
 	struct amd8111e_priv *lp = netdev_priv(dev);
 	struct pci_dev *pci_dev = lp->pci_dev;
-	u32 ethcmd;
-	
-	if( useraddr == NULL) 
-		return -EINVAL;
-	if(copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
-		return -EFAULT;
-	
-	switch(ethcmd){
-	
-	case ETHTOOL_GDRVINFO:{
-		struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-		strcpy (info.driver, MODULE_NAME);
-		strcpy (info.version, MODULE_VERS);
-		memset(&info.fw_version, 0, sizeof(info.fw_version));
-		sprintf(info.fw_version,"%u",chip_version);
-		strcpy (info.bus_info, pci_name(pci_dev));
-		info.eedump_len = 0;
-		info.regdump_len = AMD8111E_REG_DUMP_LEN;
-		if (copy_to_user (useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-	/* get settings */
-	case ETHTOOL_GSET: {
-		struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-		spin_lock_irq(&lp->lock);
-		mii_ethtool_gset(&lp->mii_if, &ecmd);
-		spin_unlock_irq(&lp->lock);
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set settings */
-	case ETHTOOL_SSET: {
-		int r;
-		struct ethtool_cmd ecmd;
-		if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-			return -EFAULT;
+	strcpy (info->driver, MODULE_NAME);
+	strcpy (info->version, MODULE_VERS);
+	sprintf(info->fw_version,"%u",chip_version);
+	strcpy (info->bus_info, pci_name(pci_dev));
+}
 
-		spin_lock_irq(&lp->lock);
-		r = mii_ethtool_sset(&lp->mii_if, &ecmd);
-		spin_unlock_irq(&lp->lock);
-		return r;
-	}
-	case ETHTOOL_GREGS: {
-		struct ethtool_regs regs;
-		u8 *regbuf;
-		int ret;
-
-		if (copy_from_user(&regs, useraddr, sizeof(regs)))
-			return -EFAULT;
-		if (regs.len > AMD8111E_REG_DUMP_LEN)
-			regs.len = AMD8111E_REG_DUMP_LEN;
-		regs.version = 0;
-		if (copy_to_user(useraddr, &regs, sizeof(regs)))
-			return -EFAULT;
-
-		regbuf = amd8111e_read_regs(lp);
-		if (!regbuf)
-			return -ENOMEM;
-
-		useraddr += offsetof(struct ethtool_regs, data);
-		ret = 0;
-		if (copy_to_user(useraddr, regbuf, regs.len))
-			ret = -EFAULT;
-		kfree(regbuf);
-		return ret;
-	}
-	/* restart autonegotiation */
-	case ETHTOOL_NWAY_RST: {
-		return mii_nway_restart(&lp->mii_if);
-	}
-	/* get link status */
-	case ETHTOOL_GLINK: {
-		struct ethtool_value val = {ETHTOOL_GLINK};
-		val.data = mii_link_ok(&lp->mii_if);
-		if (copy_to_user(useraddr, &val, sizeof(val)))
-			return -EFAULT;
-		return 0;
-	}
-	case ETHTOOL_GWOL: {
-		struct ethtool_wolinfo wol_info = { ETHTOOL_GWOL };
+static int amd8111e_get_regs_len(struct net_device *dev)
+{
+	return AMD8111E_REG_DUMP_LEN;
+}
 
-		wol_info.supported = WAKE_MAGIC|WAKE_PHY;
-		wol_info.wolopts = 0;
-		if (lp->options & OPTION_WOL_ENABLE)
-			wol_info.wolopts = WAKE_MAGIC;
-		memset(&wol_info.sopass, 0, sizeof(wol_info.sopass));
-		if (copy_to_user(useraddr, &wol_info, sizeof(wol_info)))
-			return -EFAULT;
-		return 0;
-	}
-	case ETHTOOL_SWOL: {
-		struct ethtool_wolinfo wol_info;
+static void amd8111e_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf)
+{
+	struct amd8111e_priv *lp = netdev_priv(dev);
+	regs->version = 0;
+	amd8111e_read_regs(lp, buf);
+}
 
-		if (copy_from_user(&wol_info, useraddr, sizeof(wol_info)))
-			return -EFAULT;
-		if (wol_info.wolopts & ~(WAKE_MAGIC |WAKE_PHY))
-			return -EINVAL;
-		spin_lock_irq(&lp->lock);
-		if(wol_info.wolopts & WAKE_MAGIC)
-			lp->options |= 
-				(OPTION_WOL_ENABLE | OPTION_WAKE_MAGIC_ENABLE);
-		else if(wol_info.wolopts & WAKE_PHY)
-			lp->options |= 
-				(OPTION_WOL_ENABLE | OPTION_WAKE_PHY_ENABLE);
-		else
-			lp->options &= ~OPTION_WOL_ENABLE; 
-		spin_unlock_irq(&lp->lock);
-		return 0;
-	}
-	
-	default:
-		break;
-	}
-		return -EOPNOTSUPP;
+static int amd8111e_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct amd8111e_priv *lp = netdev_priv(dev);
+	spin_lock_irq(&lp->lock);
+	mii_ethtool_gset(&lp->mii_if, ecmd);
+	spin_unlock_irq(&lp->lock);
+	return 0;
+}
+
+static int amd8111e_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct amd8111e_priv *lp = netdev_priv(dev);
+	int res;
+	spin_lock_irq(&lp->lock);
+	res = mii_ethtool_sset(&lp->mii_if, ecmd);
+	spin_unlock_irq(&lp->lock);
+	return res;
+}
+
+static int amd8111e_nway_reset(struct net_device *dev)
+{
+	struct amd8111e_priv *lp = netdev_priv(dev);
+	return mii_nway_restart(&lp->mii_if);
+}
+
+static u32 amd8111e_get_link(struct net_device *dev)
+{
+	struct amd8111e_priv *lp = netdev_priv(dev);
+	return mii_link_ok(&lp->mii_if);
 }
+
+static void amd8111e_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol_info)
+{
+	struct amd8111e_priv *lp = netdev_priv(dev);
+	wol_info->supported = WAKE_MAGIC|WAKE_PHY;
+	if (lp->options & OPTION_WOL_ENABLE)
+		wol_info->wolopts = WAKE_MAGIC;
+}
+
+static int amd8111e_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol_info)
+{
+	struct amd8111e_priv *lp = netdev_priv(dev);
+	if (wol_info->wolopts & ~(WAKE_MAGIC|WAKE_PHY))
+		return -EINVAL;
+	spin_lock_irq(&lp->lock);
+	if (wol_info->wolopts & WAKE_MAGIC)
+		lp->options |= 
+			(OPTION_WOL_ENABLE | OPTION_WAKE_MAGIC_ENABLE);
+	else if(wol_info->wolopts & WAKE_PHY)
+		lp->options |= 
+			(OPTION_WOL_ENABLE | OPTION_WAKE_PHY_ENABLE);
+	else
+		lp->options &= ~OPTION_WOL_ENABLE; 
+	spin_unlock_irq(&lp->lock);
+	return 0;
+}
+
+static struct ethtool_ops ops = {
+	.get_drvinfo = amd8111e_get_drvinfo,
+	.get_regs_len = amd8111e_get_regs_len,
+	.get_regs = amd8111e_get_regs,
+	.get_settings = amd8111e_get_settings,
+	.set_settings = amd8111e_set_settings,
+	.nway_reset = amd8111e_nway_reset,
+	.get_link = amd8111e_get_link,
+	.get_wol = amd8111e_get_wol,
+	.set_wol = amd8111e_set_wol,
+};
+
+/*
+This function handles all the  ethtool ioctls. It gives driver info, gets/sets driver speed, gets memory mapped register values, forces auto negotiation, sets/gets WOL options for ethtool application. 
+*/
+	
 static int amd8111e_ioctl(struct net_device * dev , struct ifreq *ifr, int cmd)
 {
 	struct mii_ioctl_data *data = if_mii(ifr);
@@ -1703,10 +1666,8 @@
 		return -EPERM;
 
 	switch(cmd) {
-	case SIOCETHTOOL:
-		return amd8111e_ethtool_ioctl(dev, ifr->ifr_data);
 	case SIOCGMIIPHY:
-		data->phy_id = PHY_ID;
+		data->phy_id = lp->ext_phy_addr;
 
 	/* fallthru */
 	case SIOCGMIIREG: 
@@ -1736,7 +1697,7 @@
 }
 static int amd8111e_set_mac_address(struct net_device *dev, void *p)
 {
-	struct amd8111e_priv *lp = dev->priv;
+	struct amd8111e_priv *lp = netdev_priv(dev);
 	int i;
 	struct sockaddr *addr = p;
 
@@ -1874,7 +1835,7 @@
 		pci_enable_wake(pci_dev, 4, 0); /* 4 == D3 cold */
 	}
 	
-	pci_save_state(pci_dev, lp->pm_state);
+	pci_save_state(pci_dev);
 	pci_set_power_state(pci_dev, 3);
 
 	return 0;
@@ -1888,7 +1849,7 @@
 		return 0;
 
 	pci_set_power_state(pci_dev, 0);
-	pci_restore_state(pci_dev, lp->pm_state);
+	pci_restore_state(pci_dev);
 
 	pci_enable_wake(pci_dev, 3, 0);
 	pci_enable_wake(pci_dev, 4, 0); /* D3 cold */
@@ -1912,7 +1873,7 @@
 	struct net_device *dev = pci_get_drvdata(pdev);
 	if (dev) {
 		unregister_netdev(dev);
-		iounmap((void *) ((struct amd8111e_priv *)(dev->priv))->mmio);
+		iounmap(((struct amd8111e_priv *)netdev_priv(dev))->mmio);
 		free_netdev(dev);
 		pci_release_regions(pdev);
 		pci_disable_device(pdev);
@@ -1923,7 +1884,7 @@
 {
 	struct amd8111e_priv *lp = netdev_priv(dev);
 	struct ipg_info* ipg_data = &lp->ipg_data;
-	void * mmio = lp->mmio;
+	void __iomem *mmio = lp->mmio;
 	unsigned int prev_col_cnt = ipg_data->col_cnt;
 	unsigned int total_col_cnt;
 	unsigned int tmp_ipg;
@@ -1979,6 +1940,26 @@
 
 }
 
+static void __devinit amd8111e_probe_ext_phy(struct net_device* dev)
+{
+	struct amd8111e_priv *lp = netdev_priv(dev);
+	int i;
+
+	for (i = 0x1e; i >= 0; i--) {
+		u32 id1, id2;
+
+		if (amd8111e_read_phy(lp, i, MII_PHYSID1, &id1))
+			continue;
+		if (amd8111e_read_phy(lp, i, MII_PHYSID2, &id2))
+			continue;
+		lp->ext_phy_id = (id1 << 16) | id2;
+		lp->ext_phy_addr = i;
+		return;
+	}
+	lp->ext_phy_id = 0;
+	lp->ext_phy_addr = 1;
+}
+
 static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
 				  const struct pci_device_id *ent)
 {
@@ -2049,12 +2030,6 @@
 	lp->amd8111e_net_dev = dev;
 	lp->pm_cap = pm_cap;
 
-	/* setting mii default values */
-	lp->mii_if.dev = dev;
-	lp->mii_if.mdio_read = amd8111e_mdio_read;
-	lp->mii_if.mdio_write = amd8111e_mdio_write;
-	lp->mii_if.phy_id = PHY_ID;
-
 	spin_lock_init(&lp->lock);
 
 	lp->mmio = ioremap(reg_addr, reg_len);
@@ -2085,6 +2060,7 @@
 	dev->set_mac_address = amd8111e_set_mac_address;
 	dev->do_ioctl = amd8111e_ioctl;
 	dev->change_mtu = amd8111e_change_mtu;
+	SET_ETHTOOL_OPS(dev, &ops);
 	dev->irq =pdev->irq;
 	dev->tx_timeout = amd8111e_tx_timeout; 
 	dev->watchdog_timeo = AMD8111E_TX_TIMEOUT; 
@@ -2101,7 +2077,15 @@
 	dev->vlan_rx_register =amd8111e_vlan_rx_register;
 	dev->vlan_rx_kill_vid = amd8111e_vlan_rx_kill_vid;
 #endif	
-	
+	/* Probe the external PHY */
+	amd8111e_probe_ext_phy(dev);
+
+	/* setting mii default values */
+	lp->mii_if.dev = dev;
+	lp->mii_if.mdio_read = amd8111e_mdio_read;
+	lp->mii_if.mdio_write = amd8111e_mdio_write;
+	lp->mii_if.phy_id = lp->ext_phy_addr;
+
 	/* Set receive buffer length and set jumbo option*/
 	amd8111e_set_rx_buff_len(dev);
 
@@ -2134,9 +2118,15 @@
     	for (i = 0; i < 6; i++)
 		printk("%2.2x%c",dev->dev_addr[i],i == 5 ? ' ' : ':');
     	printk( "\n");	
+	if (lp->ext_phy_id)
+		printk(KERN_INFO "%s: Found MII PHY ID 0x%08x at address 0x%02x\n",
+		       dev->name, lp->ext_phy_id, lp->ext_phy_addr);
+	else
+		printk(KERN_INFO "%s: Couldn't detect MII PHY, assuming address 0x01\n",
+		       dev->name);
     	return 0;
 err_iounmap:
-	iounmap((void *) lp->mmio);
+	iounmap(lp->mmio);
 
 err_free_dev:
 	free_netdev(dev);
diff -Nru a/drivers/net/amd8111e.h b/drivers/net/amd8111e.h
--- a/drivers/net/amd8111e.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/amd8111e.h	2004-12-24 13:36:18 -08:00
@@ -649,7 +649,6 @@
 #define TCC_MASK		0x0003
 
 /* driver ioctl parameters */
-#define PHY_ID 			0x01	/* currently it is fixed */
 #define AMD8111E_REG_DUMP_LEN	 13*sizeof(u32) 
 
 /* crc generator constants */
@@ -766,7 +765,7 @@
 	dma_addr_t tx_dma_addr[NUM_TX_BUFFERS];
 	dma_addr_t rx_dma_addr[NUM_RX_BUFFERS];
 	/* Reg memory mapped address */
-	void *  mmio;
+	void __iomem *mmio;
 	
 	spinlock_t lock;	/* Guard lock */
 	unsigned long rx_idx, tx_idx;	/* The next free ring entry */
@@ -777,10 +776,11 @@
 	int options;		/* Options enabled/disabled for the device */
 
 	unsigned long ext_phy_option;
+	int ext_phy_addr;
+	u32 ext_phy_id;
 	
 	struct amd8111e_link_config link_config;
 	int pm_cap;
-	u32 pm_state[12];
 
 	struct net_device *next;
 	int mii;
diff -Nru a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
--- a/drivers/net/appletalk/cops.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/appletalk/cops.c	2004-12-24 13:36:49 -08:00
@@ -69,9 +69,9 @@
 #include <linux/delay.h>	/* For udelay() */
 #include <linux/atalk.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
--- a/drivers/net/appletalk/ltpc.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/net/appletalk/ltpc.c	2004-12-24 13:36:32 -08:00
@@ -227,9 +227,9 @@
 #include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/atalk.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 
diff -Nru a/drivers/net/ariadne.c b/drivers/net/ariadne.c
--- a/drivers/net/ariadne.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/ariadne.c	2004-12-24 13:37:01 -08:00
@@ -47,8 +47,8 @@
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/zorro.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/amigaints.h>
 #include <asm/amigahw.h>
 #include <asm/irq.h>
diff -Nru a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
--- a/drivers/net/arm/am79c961a.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/arm/am79c961a.c	2004-12-24 13:37:18 -08:00
@@ -28,9 +28,9 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/irq.h>
 #include <asm/io.h>
 #include <asm/dma.h>
@@ -630,6 +630,16 @@
 	return IRQ_RETVAL(handled);
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void am79c961_poll_controller(struct net_device *dev)
+{
+	unsigned long flags;
+	local_irq_save(flags);
+	am79c961_interrupt(dev->irq, dev, NULL);
+	local_irq_restore(flags);
+}
+#endif
+
 /*
  * Initialise the chip.  Note that we always expect
  * to be entered with interrupts enabled.
@@ -721,6 +731,9 @@
 	dev->get_stats		= am79c961_getstats;
 	dev->set_multicast_list	= am79c961_setmulticastlist;
 	dev->tx_timeout		= am79c961_timeout;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	dev->poll_controller	= am79c961_poll_controller;
+#endif
 
 	ret = register_netdev(dev);
 	if (ret == 0)
diff -Nru a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c
--- a/drivers/net/arm/ether1.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/arm/ether1.c	2004-12-24 13:37:43 -08:00
@@ -48,9 +48,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/ecard.h>
diff -Nru a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c
--- a/drivers/net/arm/ether3.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/arm/ether3.c	2004-12-24 13:37:29 -08:00
@@ -64,9 +64,9 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/ecard.h>
 #include <asm/io.h>
 #include <asm/irq.h>
diff -Nru a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
--- a/drivers/net/arm/etherh.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/arm/etherh.c	2004-12-24 13:37:19 -08:00
@@ -40,13 +40,14 @@
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/ethtool.h>
 #include <linux/skbuff.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/ecard.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -56,14 +57,19 @@
 #define NET_DEBUG  0
 #define DEBUG_INIT 2
 
+#define DRV_NAME	"etherh"
+#define DRV_VERSION	"1.11"
+
 static unsigned int net_debug = NET_DEBUG;
 
 struct etherh_priv {
-	void		*ioc_fast;
-	void		*memc;
+	void __iomem	*ioc_fast;
+	void __iomem	*memc;
+	void __iomem	*dma_base;
 	unsigned int	id;
-	void		*ctrl_port;
+	void __iomem	*ctrl_port;
 	unsigned char	ctrl;
+	u32		supported;
 };
 
 struct etherh_data {
@@ -72,11 +78,7 @@
 	unsigned long	ctrlport_offset;
 	int		ctrl_ioc;
 	const char	name[16];
-	/*
-	 * netdev flags and port
-	 */
-	unsigned short	flags;
-	unsigned char	if_port;
+	u32		supported;
 	unsigned char	tx_start_page;
 	unsigned char	stop_page;
 };
@@ -86,7 +88,7 @@
 MODULE_LICENSE("GPL");
 
 static char version[] __initdata =
-	"EtherH/EtherM Driver (c) 2002 Russell King v1.09\n";
+	"EtherH/EtherM Driver (c) 2002-2004 Russell King " DRV_VERSION "\n";
 
 #define ETHERH500_DATAPORT	0x800	/* MEMC */
 #define ETHERH500_NS8390	0x000	/* MEMC */
@@ -166,7 +168,8 @@
 etherh_setif(struct net_device *dev)
 {
 	struct ei_device *ei_local = netdev_priv(dev);
-	unsigned long addr, flags;
+	unsigned long flags;
+	void __iomem *addr;
 
 	local_irq_save(flags);
 
@@ -174,7 +177,7 @@
 	switch (etherh_priv(dev)->id) {
 	case PROD_I3_ETHERLAN600:
 	case PROD_I3_ETHERLAN600A:
-		addr = dev->base_addr + EN0_RCNTHI;
+		addr = (void *)dev->base_addr + EN0_RCNTHI;
 
 		switch (dev->if_port) {
 		case IF_PORT_10BASE2:
@@ -209,17 +212,19 @@
 etherh_getifstat(struct net_device *dev)
 {
 	struct ei_device *ei_local = netdev_priv(dev);
+	void __iomem *addr;
 	int stat = 0;
 
 	switch (etherh_priv(dev)->id) {
 	case PROD_I3_ETHERLAN600:
 	case PROD_I3_ETHERLAN600A:
+		addr = (void *)dev->base_addr + EN0_RCNTHI;
 		switch (dev->if_port) {
 		case IF_PORT_10BASE2:
 			stat = 1;
 			break;
 		case IF_PORT_10BASET:
-			stat = readb(dev->base_addr+EN0_RCNTHI) & 4;
+			stat = readb(addr) & 4;
 			break;
 		}
 		break;
@@ -276,8 +281,9 @@
 etherh_reset(struct net_device *dev)
 {
 	struct ei_device *ei_local = netdev_priv(dev);
+	void __iomem *addr = (void *)dev->base_addr;
 
-	writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, dev->base_addr);
+	writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, addr);
 
 	/*
 	 * See if we need to change the interface type.
@@ -303,8 +309,8 @@
 etherh_block_output (struct net_device *dev, int count, const unsigned char *buf, int start_page)
 {
 	struct ei_device *ei_local = netdev_priv(dev);
-	unsigned int addr, dma_addr;
 	unsigned long dma_start;
+	void __iomem *dma_base, *addr;
 
 	if (ei_local->dmaing) {
 		printk(KERN_ERR "%s: DMAing conflict in etherh_block_input: "
@@ -321,8 +327,8 @@
 
 	ei_local->dmaing = 1;
 
-	addr = dev->base_addr;
-	dma_addr = dev->mem_start;
+	addr = (void *)dev->base_addr;
+	dma_base = etherh_priv(dev)->dma_base;
 
 	count = (count + 1) & ~1;
 	writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD);
@@ -343,9 +349,9 @@
 	writeb (E8390_RWRITE | E8390_START, addr + E8390_CMD);
 
 	if (ei_local->word16)
-		writesw (dma_addr, buf, count >> 1);
+		writesw (dma_base, buf, count >> 1);
 	else
-		writesb (dma_addr, buf, count);
+		writesb (dma_base, buf, count);
 
 	dma_start = jiffies;
 
@@ -369,8 +375,8 @@
 etherh_block_input (struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
 {
 	struct ei_device *ei_local = netdev_priv(dev);
-	unsigned int addr, dma_addr;
 	unsigned char *buf;
+	void __iomem *dma_base, *addr;
 
 	if (ei_local->dmaing) {
 		printk(KERN_ERR "%s: DMAing conflict in etherh_block_input: "
@@ -381,8 +387,8 @@
 
 	ei_local->dmaing = 1;
 
-	addr = dev->base_addr;
-	dma_addr = dev->mem_start;
+	addr = (void *)dev->base_addr;
+	dma_base = etherh_priv(dev)->dma_base;
 
 	buf = skb->data;
 	writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD);
@@ -393,11 +399,11 @@
 	writeb (E8390_RREAD | E8390_START, addr + E8390_CMD);
 
 	if (ei_local->word16) {
-		readsw (dma_addr, buf, count >> 1);
+		readsw (dma_base, buf, count >> 1);
 		if (count & 1)
-			buf[count - 1] = readb (dma_addr);
+			buf[count - 1] = readb (dma_base);
 	} else
-		readsb (dma_addr, buf, count);
+		readsb (dma_base, buf, count);
 
 	writeb (ENISR_RDC, addr + EN0_ISR);
 	ei_local->dmaing = 0;
@@ -410,7 +416,7 @@
 etherh_get_header (struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
 {
 	struct ei_device *ei_local = netdev_priv(dev);
-	unsigned int addr, dma_addr;
+	void __iomem *dma_base, *addr;
 
 	if (ei_local->dmaing) {
 		printk(KERN_ERR "%s: DMAing conflict in etherh_get_header: "
@@ -421,8 +427,8 @@
 
 	ei_local->dmaing = 1;
 
-	addr = dev->base_addr;
-	dma_addr = dev->mem_start;
+	addr = (void *)dev->base_addr;
+	dma_base = etherh_priv(dev)->dma_base;
 
 	writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD);
 	writeb (sizeof (*hdr), addr + EN0_RCNTLO);
@@ -432,9 +438,9 @@
 	writeb (E8390_RREAD | E8390_START, addr + E8390_CMD);
 
 	if (ei_local->word16)
-		readsw (dma_addr, hdr, sizeof (*hdr) >> 1);
+		readsw (dma_base, hdr, sizeof (*hdr) >> 1);
 	else
-		readsb (dma_addr, hdr, sizeof (*hdr));
+		readsb (dma_base, hdr, sizeof (*hdr));
 
 	writeb (ENISR_RDC, addr + EN0_ISR);
 	ei_local->dmaing = 0;
@@ -522,16 +528,30 @@
 	struct in_chunk_dir cd;
 	char *s;
 	
-	if (ecard_readchunk(&cd, ec, 0xf5, 0) && (s = strchr(cd.d.string, '('))) {
+	if (!ecard_readchunk(&cd, ec, 0xf5, 0)) {
+		printk(KERN_ERR "%s: unable to read podule description string\n",
+		       ec->dev.bus_id);
+		goto no_addr;
+	}
+
+	s = strchr(cd.d.string, '(');
+	if (s) {
 		int i;
+
 		for (i = 0; i < 6; i++) {
 			addr[i] = simple_strtoul(s + 1, &s, 0x10);
 			if (*s != (i == 5? ')' : ':'))
 				break;
 		}
+
 		if (i == 6)
 			return 0;
 	}
+
+	printk(KERN_ERR "%s: unable to parse MAC address: %s\n",
+	       ec->dev.bus_id, cd.d.string);
+
+ no_addr:
 	return -ENODEV;
 }
 
@@ -556,6 +576,62 @@
 	return 0;
 }
 
+static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
+	strlcpy(info->version, DRV_VERSION, sizeof(info->version));
+	strlcpy(info->bus_info, dev->class_dev.dev->bus_id,
+		sizeof(info->bus_info));
+}
+
+static int etherh_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	cmd->supported	= etherh_priv(dev)->supported;
+	cmd->speed	= SPEED_10;
+	cmd->duplex	= DUPLEX_HALF;
+	cmd->port	= dev->if_port == IF_PORT_10BASET ? PORT_TP : PORT_BNC;
+	cmd->autoneg	= dev->flags & IFF_AUTOMEDIA ? AUTONEG_ENABLE : AUTONEG_DISABLE;
+	return 0;
+}
+
+static int etherh_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	switch (cmd->autoneg) {
+	case AUTONEG_ENABLE:
+		dev->flags |= IFF_AUTOMEDIA;
+		break;
+
+	case AUTONEG_DISABLE:
+		switch (cmd->port) {
+		case PORT_TP:
+			dev->if_port = IF_PORT_10BASET;
+			break;
+
+		case PORT_BNC:
+			dev->if_port = IF_PORT_10BASE2;
+			break;
+
+		default:
+			return -EINVAL;
+		}
+		dev->flags &= ~IFF_AUTOMEDIA;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	etherh_setif(dev);
+
+	return 0;
+}
+
+static struct ethtool_ops etherh_ethtool_ops = {
+	.get_settings	= etherh_get_settings,
+	.set_settings	= etherh_set_settings,
+	.get_drvinfo	= etherh_get_drvinfo,
+};
+
 static u32 etherh_regoffsets[16];
 static u32 etherm_regoffsets[16];
 
@@ -587,10 +663,21 @@
 	dev->stop		= etherh_close;
 	dev->set_config		= etherh_set_config;
 	dev->irq		= ec->irq;
-	dev->if_port		= data->if_port;
-	dev->flags		|= data->flags;
+	dev->ethtool_ops	= &etherh_ethtool_ops;
+
+	if (data->supported & SUPPORTED_Autoneg)
+		dev->flags |= IFF_AUTOMEDIA;
+	if (data->supported & SUPPORTED_TP) {
+		dev->flags |= IFF_PORTSEL;
+		dev->if_port = IF_PORT_10BASET;
+	} else if (data->supported & SUPPORTED_BNC) {
+		dev->flags |= IFF_PORTSEL;
+		dev->if_port = IF_PORT_10BASE2;
+	} else
+		dev->if_port = IF_PORT_UNKNOWN;
 
 	eh = etherh_priv(dev);
+	eh->supported		= data->supported;
 	eh->ctrl		= 0;
 	eh->id			= ec->cid.product;
 	eh->memc		= ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), PAGE_SIZE);
@@ -610,7 +697,7 @@
 	}
 
 	dev->base_addr = (unsigned long)eh->memc + data->ns8390_offset;
-	dev->mem_start = (unsigned long)eh->memc + data->dataport_offset;
+	eh->dma_base = eh->memc + data->dataport_offset;
 	eh->ctrl_port += data->ctrlport_offset;
 
 	/*
@@ -701,7 +788,7 @@
 	.dataport_offset	= ETHERM_NS8390 + ETHERM_DATAPORT,
 	.ctrlport_offset	= ETHERM_NS8390 + ETHERM_CTRLPORT,
 	.name			= "ANT EtherM",
-	.if_port		= IF_PORT_UNKNOWN,
+	.supported		= SUPPORTED_10baseT_Half,
 	.tx_start_page		= ETHERM_TX_START_PAGE,
 	.stop_page		= ETHERM_STOP_PAGE,
 };
@@ -712,7 +799,7 @@
 	.ctrlport_offset	= ETHERH500_CTRLPORT,
 	.ctrl_ioc		= 1,
 	.name			= "i3 EtherH 500",
-	.if_port		= IF_PORT_UNKNOWN,
+	.supported		= SUPPORTED_10baseT_Half,
 	.tx_start_page		= ETHERH_TX_START_PAGE,
 	.stop_page		= ETHERH_STOP_PAGE,
 };
@@ -722,8 +809,7 @@
 	.dataport_offset	= ETHERH600_NS8390 + ETHERH600_DATAPORT,
 	.ctrlport_offset	= ETHERH600_NS8390 + ETHERH600_CTRLPORT,
 	.name			= "i3 EtherH 600",
-	.flags			= IFF_PORTSEL | IFF_AUTOMEDIA,
-	.if_port		= IF_PORT_10BASET,
+	.supported		= SUPPORTED_10baseT_Half | SUPPORTED_TP | SUPPORTED_BNC | SUPPORTED_Autoneg,
 	.tx_start_page		= ETHERH_TX_START_PAGE,
 	.stop_page		= ETHERH_STOP_PAGE,
 };
@@ -733,8 +819,7 @@
 	.dataport_offset	= ETHERH600_NS8390 + ETHERH600_DATAPORT,
 	.ctrlport_offset	= ETHERH600_NS8390 + ETHERH600_CTRLPORT,
 	.name			= "i3 EtherH 600A",
-	.flags			= IFF_PORTSEL | IFF_AUTOMEDIA,
-	.if_port		= IF_PORT_10BASET,
+	.supported		= SUPPORTED_10baseT_Half | SUPPORTED_TP | SUPPORTED_BNC | SUPPORTED_Autoneg,
 	.tx_start_page		= ETHERH_TX_START_PAGE,
 	.stop_page		= ETHERH_STOP_PAGE,
 };
@@ -752,7 +837,7 @@
 	.remove		= __devexit_p(etherh_remove),
 	.id_table	= etherh_ids,
 	.drv = {
-		.name	= "etherh",
+		.name	= DRV_NAME,
 	},
 };
 
diff -Nru a/drivers/net/at1700.c b/drivers/net/at1700.c
--- a/drivers/net/at1700.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/at1700.c	2004-12-24 13:36:47 -08:00
@@ -56,9 +56,9 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/atari_bionet.c b/drivers/net/atari_bionet.c
--- a/drivers/net/atari_bionet.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/atari_bionet.c	2004-12-24 13:37:00 -08:00
@@ -97,6 +97,7 @@
 #include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -105,7 +106,6 @@
 #include <asm/setup.h>
 #include <asm/pgtable.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/atarihw.h>
diff -Nru a/drivers/net/atari_pamsnet.c b/drivers/net/atari_pamsnet.c
--- a/drivers/net/atari_pamsnet.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/atari_pamsnet.c	2004-12-24 13:36:47 -08:00
@@ -88,9 +88,9 @@
 #include <linux/in.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <linux/errno.h>
diff -Nru a/drivers/net/atarilance.c b/drivers/net/atarilance.c
--- a/drivers/net/atarilance.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/atarilance.c	2004-12-24 13:37:43 -08:00
@@ -56,12 +56,12 @@
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/atarihw.h>
 #include <asm/atariints.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 /* Debug level:
@@ -606,7 +606,7 @@
 		printk( "      Use \"ifconfig hw ether ...\" to set the address.\n" );
 	}
 
-	lp->devlock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&lp->devlock);
 
 	MEM->init.mode = 0x0000;		/* Disable Rx and Tx. */
 	for( i = 0; i < 6; i++ )
diff -Nru a/drivers/net/atp.c b/drivers/net/atp.c
--- a/drivers/net/atp.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/net/atp.c	2004-12-24 13:37:31 -08:00
@@ -141,9 +141,9 @@
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
--- a/drivers/net/au1000_eth.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/au1000_eth.c	2004-12-24 13:36:55 -08:00
@@ -36,10 +36,10 @@
 #include <linux/skbuff.h>
 #include <linux/delay.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 
 #include <asm/mipsregs.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/au1000.h>
 
diff -Nru a/drivers/net/b44.c b/drivers/net/b44.c
--- a/drivers/net/b44.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/b44.c	2004-12-24 13:36:48 -08:00
@@ -8,6 +8,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
@@ -27,8 +28,8 @@
 
 #define DRV_MODULE_NAME		"b44"
 #define PFX DRV_MODULE_NAME	": "
-#define DRV_MODULE_VERSION	"0.94"
-#define DRV_MODULE_RELDATE	"May 4, 2004"
+#define DRV_MODULE_VERSION	"0.95"
+#define DRV_MODULE_RELDATE	"Aug 3, 2004"
 
 #define B44_DEF_MSG_ENABLE	  \
 	(NETIF_MSG_DRV		| \
@@ -57,6 +58,7 @@
 #define B44_DEF_TX_RING_PENDING		(B44_TX_RING_SIZE - 1)
 #define B44_TX_RING_BYTES	(sizeof(struct dma_desc) * \
 				 B44_TX_RING_SIZE)
+#define B44_DMA_MASK 0x3fffffff
 
 #define TX_RING_GAP(BP)	\
 	(B44_TX_RING_SIZE - (BP)->tx_pending)
@@ -67,6 +69,7 @@
 #define NEXT_TX(N)		(((N) + 1) & (B44_TX_RING_SIZE - 1))
 
 #define RX_PKT_BUF_SZ		(1536 + bp->rx_offset + 64)
+#define TX_PKT_BUF_SZ		(B44_MAX_MTU + ETH_HLEN + 8)
 
 /* minimum number of free TX descriptors required to wake up TX process */
 #define B44_TX_WAKEUP_THRESH		(B44_TX_RING_SIZE / 4)
@@ -74,13 +77,14 @@
 static char version[] __devinitdata =
 	DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
 
-MODULE_AUTHOR("David S. Miller (davem@redhat.com)");
+MODULE_AUTHOR("Florian Schirmer, Pekka Pietikainen, David S. Miller");
 MODULE_DESCRIPTION("Broadcom 4400 10/100 PCI ethernet driver");
 MODULE_LICENSE("GPL");
-MODULE_PARM(b44_debug, "i");
-MODULE_PARM_DESC(b44_debug, "B44 bitmapped debugging message enable value");
+MODULE_VERSION(DRV_MODULE_VERSION);
 
 static int b44_debug = -1;	/* -1 == use B44_DEF_MSG_ENABLE as value */
+module_param(b44_debug, int, 0);
+MODULE_PARM_DESC(b44_debug, "B44 bitmapped debugging message enable value");
 
 static struct pci_device_id b44_pci_tbl[] = {
 	{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401,
@@ -97,6 +101,10 @@
 static void b44_halt(struct b44 *);
 static void b44_init_rings(struct b44 *);
 static void b44_init_hw(struct b44 *);
+static int b44_poll(struct net_device *dev, int *budget);
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void b44_poll_controller(struct net_device *dev);
+#endif
 
 static inline unsigned long br32(const struct b44 *bp, unsigned long reg)
 {
@@ -141,41 +149,8 @@
  * interrupts disabled.
  */
 
-#define SBID_SDRAM		0
-#define SBID_PCI_MEM		1
-#define SBID_PCI_CFG		2
-#define SBID_PCI_DMA		3
-#define	SBID_SDRAM_SWAPPED	4
-#define SBID_ENUM		5
-#define SBID_REG_SDRAM		6
-#define SBID_REG_ILINE20	7
-#define SBID_REG_EMAC		8
-#define SBID_REG_CODEC		9
-#define SBID_REG_USB		10
-#define SBID_REG_PCI		11
-#define SBID_REG_MIPS		12
-#define SBID_REG_EXTIF		13
-#define	SBID_EXTIF		14
-#define	SBID_EJTAG		15
-#define	SBID_MAX		16
-
-static u32 ssb_get_addr(struct b44 *bp, u32 id, u32 instance)
-{
-	switch (id) {
-	case SBID_PCI_DMA:
-		return 0x40000000;
-	case SBID_ENUM:
-		return 0x18000000;
-	case SBID_REG_EMAC:
-		return 0x18000000;
-	case SBID_REG_CODEC:
-		return 0x18001000;
-	case SBID_REG_PCI:
-		return 0x18002000;
-	default:
-		return 0;
-	};
-}
+#define SB_PCI_DMA             0x40000000      /* Client Mode PCI memory access space (1 GB) */
+#define BCM4400_PCI_CORE_ADDR  0x18002000      /* Address of PCI core on BCM4400 cards */
 
 static u32 ssb_get_core_rev(struct b44 *bp)
 {
@@ -187,8 +162,7 @@
 	u32 bar_orig, pci_rev, val;
 
 	pci_read_config_dword(bp->pdev, SSB_BAR0_WIN, &bar_orig);
-	pci_write_config_dword(bp->pdev, SSB_BAR0_WIN,
-			       ssb_get_addr(bp, SBID_REG_PCI, 0));
+	pci_write_config_dword(bp->pdev, SSB_BAR0_WIN, BCM4400_PCI_CORE_ADDR);
 	pci_rev = ssb_get_core_rev(bp);
 
 	val = br32(bp, B44_SBINTVEC);
@@ -649,10 +623,30 @@
 	if (skb == NULL)
 		return -ENOMEM;
 
-	skb->dev = bp->dev;
 	mapping = pci_map_single(bp->pdev, skb->data,
 				 RX_PKT_BUF_SZ,
 				 PCI_DMA_FROMDEVICE);
+
+	/* Hardware bug work-around, the chip is unable to do PCI DMA
+	   to/from anything above 1GB :-( */
+	if(mapping+RX_PKT_BUF_SZ > B44_DMA_MASK) {
+		/* Sigh... */
+		pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE);
+		dev_kfree_skb_any(skb);
+		skb = __dev_alloc_skb(RX_PKT_BUF_SZ,GFP_DMA);
+		if (skb == NULL)
+			return -ENOMEM;
+		mapping = pci_map_single(bp->pdev, skb->data,
+					 RX_PKT_BUF_SZ,
+					 PCI_DMA_FROMDEVICE);
+		if(mapping+RX_PKT_BUF_SZ > B44_DMA_MASK) {
+			pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE);
+			dev_kfree_skb_any(skb);
+			return -ENOMEM;
+		}
+	}
+
+	skb->dev = bp->dev;
 	skb_reserve(skb, bp->rx_offset);
 
 	rh = (struct rx_header *)
@@ -930,6 +924,12 @@
 
 	entry = bp->tx_prod;
 	mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE);
+	if(mapping+len > B44_DMA_MASK) {
+		/* Chip can't handle DMA to/from >1GB, use bounce buffer */
+		pci_unmap_single(bp->pdev, mapping, len,PCI_DMA_TODEVICE);
+		memcpy(bp->tx_bufs+entry*TX_PKT_BUF_SZ,skb->data,skb->len);
+		mapping = pci_map_single(bp->pdev, bp->tx_bufs+entry*TX_PKT_BUF_SZ, len, PCI_DMA_TODEVICE);
+	}
 
 	bp->tx_buffers[entry].skb = skb;
 	pci_unmap_addr_set(&bp->tx_buffers[entry], mapping, mapping);
@@ -1077,6 +1077,11 @@
 				    bp->tx_ring, bp->tx_ring_dma);
 		bp->tx_ring = NULL;
 	}
+	if (bp->tx_bufs) {
+		pci_free_consistent(bp->pdev, B44_TX_RING_SIZE * TX_PKT_BUF_SZ,
+				    bp->tx_bufs, bp->tx_bufs_dma);
+		bp->tx_bufs = NULL;
+	}
 }
 
 /*
@@ -1099,6 +1104,12 @@
 		goto out_err;
 	memset(bp->tx_buffers, 0, size);
 
+	size = B44_TX_RING_SIZE * TX_PKT_BUF_SZ;
+	bp->tx_bufs = pci_alloc_consistent(bp->pdev, size, &bp->tx_bufs_dma);
+	if (!bp->tx_bufs)
+		goto out_err;
+	memset(bp->tx_bufs, 0, size);
+
 	size = DMA_TABLE_BYTES;
 	bp->rx_ring = pci_alloc_consistent(bp->pdev, size, &bp->rx_ring_dma);
 	if (!bp->rx_ring)
@@ -1297,6 +1308,19 @@
 }
 #endif
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/*
+ * Polling receive - used by netconsole and other diagnostic tools
+ * to allow network i/o with interrupts disabled.
+ */
+static void b44_poll_controller(struct net_device *dev)
+{
+	disable_irq(dev->irq);
+	b44_interrupt(dev->irq, dev, NULL);
+	enable_irq(dev->irq);
+}
+#endif
+
 static int b44_close(struct net_device *dev)
 {
 	struct b44 *bp = netdev_priv(dev);
@@ -1358,7 +1382,10 @@
 				   hwstat->rx_symbol_errs);
 
 	nstat->tx_aborted_errors = hwstat->tx_underruns;
+#if 0
+	/* Carrier lost counter seems to be broken for some devices */
 	nstat->tx_carrier_errors = hwstat->tx_carrier_lost;
+#endif
 
 	return nstat;
 }
@@ -1684,7 +1711,6 @@
 	bp->dev->dev_addr[5] = eeprom[82];
 
 	bp->phy_addr = eeprom[90] & 0x1f;
-	bp->mdc_port = (eeprom[90] >> 14) & 0x1;
 
 	/* With this, plus the rx_header prepended to the data by the
 	 * hardware, we'll land the ethernet header on a 2-byte boundary.
@@ -1694,7 +1720,7 @@
 	bp->imask = IMASK_DEF;
 
 	bp->core_unit = ssb_core_unit(bp);
-	bp->dma_offset = ssb_get_addr(bp, SBID_PCI_DMA, 0);
+	bp->dma_offset = SB_PCI_DMA;
 
 	/* XXX - really required? 
 	   bp->flags |= B44_FLAG_BUGGY_TXPTR;
@@ -1738,12 +1764,19 @@
 
 	pci_set_master(pdev);
 
-	err = pci_set_dma_mask(pdev, (u64) 0xffffffff);
+	err = pci_set_dma_mask(pdev, (u64) B44_DMA_MASK);
 	if (err) {
 		printk(KERN_ERR PFX "No usable DMA configuration, "
 		       "aborting.\n");
 		goto err_out_free_res;
 	}
+	
+	err = pci_set_consistent_dma_mask(pdev, (u64) B44_DMA_MASK);
+	if (err) {
+	  printk(KERN_ERR PFX "No usable DMA configuration, "
+		 "aborting.\n");
+	  goto err_out_free_res;
+	}
 
 	b44reg_base = pci_resource_start(pdev, 0);
 	b44reg_len = pci_resource_len(pdev, 0);
@@ -1793,6 +1826,9 @@
 	dev->poll = b44_poll;
 	dev->weight = 64;
 	dev->watchdog_timeo = B44_TX_TIMEOUT;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	dev->poll_controller = b44_poll_controller;
+#endif
 	dev->change_mtu = b44_change_mtu;
 	dev->irq = pdev->irq;
 	SET_ETHTOOL_OPS(dev, &b44_ethtool_ops);
@@ -1827,7 +1863,7 @@
 
 	pci_set_drvdata(pdev, dev);
 
-	pci_save_state(bp->pdev, bp->pci_cfg_state);
+	pci_save_state(bp->pdev);
 
 	printk(KERN_INFO "%s: Broadcom 4400 10/100BaseT Ethernet ", dev->name);
 	for (i = 0; i < 6; i++)
@@ -1870,7 +1906,7 @@
 static int b44_suspend(struct pci_dev *pdev, u32 state)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct b44 *bp = dev->priv;
+	struct b44 *bp = netdev_priv(dev);
 
         if (!netif_running(dev))
                  return 0;
@@ -1891,9 +1927,9 @@
 static int b44_resume(struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct b44 *bp = dev->priv;
+	struct b44 *bp = netdev_priv(dev);
 
-	pci_restore_state(pdev, bp->pci_cfg_state);
+	pci_restore_state(pdev);
 
 	if (!netif_running(dev))
 		return 0;
diff -Nru a/drivers/net/b44.h b/drivers/net/b44.h
--- a/drivers/net/b44.h	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/b44.h	2004-12-24 13:37:01 -08:00
@@ -223,21 +223,8 @@
 #define B44_RX_SYM	0x05D0UL /* MIB RX Symbol Errors */
 #define B44_RX_PAUSE	0x05D4UL /* MIB RX Pause Packets */
 #define B44_RX_NPAUSE	0x05D8UL /* MIB RX Non-Pause Packets */
-#define B44_SBIPSFLAG	0x0F08UL /* SB Initiator Port OCP Slave Flag */
-#define  SBIPSFLAG_IMASK1	0x0000003f /* Which sbflags --> mips interrupt 1 */
-#define  SBIPSFLAG_ISHIFT1	0
-#define  SBIPSFLAG_IMASK2	0x00003f00 /* Which sbflags --> mips interrupt 2 */
-#define  SBIPSFLAG_ISHIFT2	8
-#define  SBIPSFLAG_IMASK3	0x003f0000 /* Which sbflags --> mips interrupt 3 */
-#define  SBIPSFLAG_ISHIFT3	16
-#define  SBIPSFLAG_IMASK4	0x3f000000 /* Which sbflags --> mips interrupt 4 */
-#define  SBIPSFLAG_ISHIFT4	24
-#define B44_SBTPSFLAG	0x0F18UL /* SB Target Port OCP Slave Flag */
-#define  SBTPS_NUM0_MASK	0x0000003f
-#define  SBTPS_F0EN0		0x00000040
-#define B44_SBADMATCH3	0x0F60UL /* SB Address Match 3 */
-#define B44_SBADMATCH2	0x0F68UL /* SB Address Match 2 */
-#define B44_SBADMATCH1	0x0F70UL /* SB Address Match 1 */
+
+/* Silicon backplane register definitions */
 #define B44_SBIMSTATE	0x0F90UL /* SB Initiator Agent State */
 #define  SBIMSTATE_PC		0x0000000f /* Pipe Count */
 #define  SBIMSTATE_AP_MASK	0x00000030 /* Arbitration Priority */
@@ -269,86 +256,6 @@
 #define  SBTMSHIGH_GCR		0x20000000 /* Gated Clock Request */
 #define  SBTMSHIGH_BISTF	0x40000000 /* BIST Failed */
 #define  SBTMSHIGH_BISTD	0x80000000 /* BIST Done */
-#define B44_SBBWA0	0x0FA0UL /* SB Bandwidth Allocation Table 0 */
-#define  SBBWA0_TAB0_MASK	0x0000ffff /* Lookup Table 0 */
-#define  SBBWA0_TAB0_SHIFT	0
-#define  SBBWA0_TAB1_MASK	0xffff0000 /* Lookup Table 0 */
-#define  SBBWA0_TAB1_SHIFT	16
-#define B44_SBIMCFGLOW	0x0FA8UL /* SB Initiator Configuration Low */
-#define  SBIMCFGLOW_STO_MASK	0x00000003 /* Service Timeout */
-#define  SBIMCFGLOW_RTO_MASK	0x00000030 /* Request Timeout */
-#define  SBIMCFGLOW_RTO_SHIFT	4
-#define  SBIMCFGLOW_CID_MASK	0x00ff0000 /* Connection ID */
-#define  SBIMCFGLOW_CID_SHIFT	16
-#define B44_SBIMCFGHIGH	0x0FACUL /* SB Initiator Configuration High */
-#define  SBIMCFGHIGH_IEM_MASK	0x0000000c /* Inband Error Mode */
-#define  SBIMCFGHIGH_TEM_MASK	0x00000030 /* Timeout Error Mode */
-#define  SBIMCFGHIGH_TEM_SHIFT	4
-#define  SBIMCFGHIGH_BEM_MASK	0x000000c0 /* Bus Error Mode */
-#define  SBIMCFGHIGH_BEM_SHIFT	6
-#define B44_SBADMATCH0	0x0FB0UL /* SB Address Match 0 */
-#define  SBADMATCH0_TYPE_MASK	0x00000003 /* Address Type */
-#define  SBADMATCH0_AD64	0x00000004 /* Reserved */
-#define  SBADMATCH0_AI0_MASK	0x000000f8 /* Type0 Size */
-#define  SBADMATCH0_AI0_SHIFT	3
-#define  SBADMATCH0_AI1_MASK	0x000001f8 /* Type1 Size */
-#define  SBADMATCH0_AI1_SHIFT	3
-#define  SBADMATCH0_AI2_MASK	0x000001f8 /* Type2 Size */
-#define  SBADMATCH0_AI2_SHIFT	3
-#define  SBADMATCH0_ADEN	0x00000400 /* Enable */
-#define  SBADMATCH0_ADNEG	0x00000800 /* Negative Decode */
-#define  SBADMATCH0_BS0_MASK	0xffffff00 /* Type0 Base Address */
-#define  SBADMATCH0_BS0_SHIFT	8
-#define  SBADMATCH0_BS1_MASK	0xfffff000 /* Type1 Base Address */
-#define  SBADMATCH0_BS1_SHIFT	12
-#define  SBADMATCH0_BS2_MASK	0xffff0000 /* Type2 Base Address */
-#define  SBADMATCH0_BS2_SHIFT	16
-#define B44_SBTMCFGLOW	0x0FB8UL /* SB Target Configuration Low */
-#define  SBTMCFGLOW_CD_MASK	0x000000ff /* Clock Divide Mask */
-#define  SBTMCFGLOW_CO_MASK	0x0000f800 /* Clock Offset Mask */
-#define  SBTMCFGLOW_CO_SHIFT	11
-#define  SBTMCFGLOW_IF_MASK	0x00fc0000 /* Interrupt Flags Mask */
-#define  SBTMCFGLOW_IF_SHIFT	18
-#define  SBTMCFGLOW_IM_MASK	0x03000000 /* Interrupt Mode Mask */
-#define  SBTMCFGLOW_IM_SHIFT	24
-#define B44_SBTMCFGHIGH	0x0FBCUL /* SB Target Configuration High */
-#define  SBTMCFGHIGH_BM_MASK	0x00000003 /* Busy Mode */
-#define  SBTMCFGHIGH_RM_MASK	0x0000000C /* Retry Mode */
-#define  SBTMCFGHIGH_RM_SHIFT	2
-#define  SBTMCFGHIGH_SM_MASK	0x00000030 /* Stop Mode */
-#define  SBTMCFGHIGH_SM_SHIFT	4
-#define  SBTMCFGHIGH_EM_MASK	0x00000300 /* Error Mode */
-#define  SBTMCFGHIGH_EM_SHIFT	8
-#define  SBTMCFGHIGH_IM_MASK	0x00000c00 /* Interrupt Mode */
-#define  SBTMCFGHIGH_IM_SHIFT	10
-#define B44_SBBCFG	0x0FC0UL /* SB Broadcast Configuration */
-#define  SBBCFG_LAT_MASK	0x00000003 /* SB Latency */
-#define  SBBCFG_MAX0_MASK	0x000f0000 /* MAX Counter 0 */
-#define  SBBCFG_MAX0_SHIFT	16
-#define  SBBCFG_MAX1_MASK	0x00f00000 /* MAX Counter 1 */
-#define  SBBCFG_MAX1_SHIFT	20
-#define B44_SBBSTATE	0x0FC8UL /* SB Broadcast State */
-#define  SBBSTATE_SRD		0x00000001 /* ST Reg Disable */
-#define  SBBSTATE_HRD		0x00000002 /* Hold Reg Disable */
-#define B44_SBACTCNFG	0x0FD8UL /* SB Activate Configuration */
-#define B44_SBFLAGST	0x0FE8UL /* SB Current SBFLAGS */
-#define B44_SBIDLOW	0x0FF8UL /* SB Identification Low */
-#define  SBIDLOW_CS_MASK	0x00000003 /* Config Space Mask */
-#define  SBIDLOW_AR_MASK	0x00000038 /* Num Address Ranges Supported */
-#define  SBIDLOW_AR_SHIFT	3
-#define  SBIDLOW_SYNCH		0x00000040 /* Sync */
-#define  SBIDLOW_INIT		0x00000080 /* Initiator */
-#define  SBIDLOW_MINLAT_MASK	0x00000f00 /* Minimum Backplane Latency */
-#define  SBIDLOW_MINLAT_SHIFT	8
-#define  SBIDLOW_MAXLAT_MASK	0x0000f000 /* Maximum Backplane Latency */
-#define  SBIDLOW_MAXLAT_SHIFT	12
-#define  SBIDLOW_FIRST		0x00010000 /* This Initiator is First */
-#define  SBIDLOW_CW_MASK	0x000c0000 /* Cycle Counter Width */
-#define  SBIDLOW_CW_SHIFT	18
-#define  SBIDLOW_TP_MASK	0x00f00000 /* Target Ports */
-#define  SBIDLOW_TP_SHIFT	20
-#define  SBIDLOW_IP_MASK	0x0f000000 /* Initiator Ports */
-#define  SBIDLOW_IP_SHIFT	24
 #define B44_SBIDHIGH	0x0FFCUL /* SB Identification High */
 #define  SBIDHIGH_RC_MASK	0x0000000f /* Revision Code */
 #define  SBIDHIGH_CC_MASK	0x0000fff0 /* Core Code */
@@ -356,23 +263,13 @@
 #define  SBIDHIGH_VC_MASK	0xffff0000 /* Vendor Code */
 #define  SBIDHIGH_VC_SHIFT	16
 
-#define  CORE_CODE_ILINE20	0x801
-#define  CORE_CODE_SDRAM	0x803
-#define  CORE_CODE_PCI		0x804
-#define  CORE_CODE_MIPS		0x805
-#define  CORE_CODE_ENET		0x806
-#define  CORE_CODE_CODEC	0x807
-#define  CORE_CODE_USB		0x808
-#define  CORE_CODE_ILINE100	0x80a
-#define  CORE_CODE_EXTIF	0x811
-
 /* SSB PCI config space registers.  */
 #define	SSB_BAR0_WIN		0x80
 #define	SSB_BAR1_WIN		0x84
 #define	SSB_SPROM_CONTROL	0x88
 #define	SSB_BAR1_CONTROL	0x8c
 
-/* SSB core and hsot control registers.  */
+/* SSB core and host control registers.  */
 #define SSB_CONTROL		0x0000UL
 #define SSB_ARBCONTROL		0x0010UL
 #define SSB_ISTAT		0x0020UL
@@ -500,6 +397,7 @@
 
 	struct ring_info	*rx_buffers;
 	struct ring_info	*tx_buffers;
+	unsigned char		*tx_bufs; 
 
 	u32			dma_offset;
 	u32			flags;
@@ -531,13 +429,11 @@
 	struct pci_dev		*pdev;
 	struct net_device	*dev;
 
-	dma_addr_t		rx_ring_dma, tx_ring_dma;
+	dma_addr_t		rx_ring_dma, tx_ring_dma,tx_bufs_dma;
 
 	u32			rx_pending;
 	u32			tx_pending;
-	u32			pci_cfg_state[64 / sizeof(u32)];
 	u8			phy_addr;
-	u8			mdc_port;
 	u8			core_unit;
 
 	struct mii_if_info	mii_if;
diff -Nru a/drivers/net/bagetlance.c b/drivers/net/bagetlance.c
--- a/drivers/net/bagetlance.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/bagetlance.c	2004-12-24 13:36:17 -08:00
@@ -25,9 +25,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/baget/baget.h>
 
diff -Nru a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
--- a/drivers/net/bonding/bond_main.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/bonding/bond_main.c	2004-12-24 13:37:19 -08:00
@@ -469,6 +469,13 @@
  *	  * Add support for VLAN hardware acceleration capable slaves.
  *	  * Add capability to tag self generated packets in ALB/TLB modes.
  *	  Set version to 2.6.0.
+ * 2004/10/29 - Mitch Williams <mitch.a.williams at intel dot com>
+ *      - Fixed bug when unloading module while using 802.3ad.  If
+ *        spinlock debugging is turned on, this causes a stack dump.
+ *        Solution is to move call to dev_remove_pack outside of the
+ *        spinlock.
+ *        Set version to 2.6.1.
+ *
  */
 
 //#define BONDING_DEBUG 1
@@ -491,8 +498,8 @@
 #include <linux/socket.h>
 #include <linux/ctype.h>
 #include <linux/inet.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/uaccess.h>
@@ -3566,15 +3573,15 @@
 {
 	struct bonding *bond = bond_dev->priv;
 
-	write_lock_bh(&bond->lock);
-
-	bond_mc_list_destroy(bond);
-
 	if (bond->params.mode == BOND_MODE_8023AD) {
 		/* Unregister the receive of LACPDUs */
 		bond_unregister_lacpdu(bond);
 	}
 
+	write_lock_bh(&bond->lock);
+
+	bond_mc_list_destroy(bond);
+
 	/* signal timers not to re-arm */
 	bond->kill_timers = 1;
 
@@ -4700,6 +4707,7 @@
 module_init(bonding_init);
 module_exit(bonding_exit);
 MODULE_LICENSE("GPL");
+MODULE_VERSION(DRV_VERSION);
 MODULE_DESCRIPTION(DRV_DESCRIPTION ", v" DRV_VERSION);
 MODULE_AUTHOR("Thomas Davis, tadavis@lbl.gov and many others");
 MODULE_SUPPORTED_DEVICE("most ethernet devices");
diff -Nru a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
--- a/drivers/net/bonding/bonding.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/bonding/bonding.h	2004-12-24 13:36:31 -08:00
@@ -36,8 +36,8 @@
 #include "bond_3ad.h"
 #include "bond_alb.h"
 
-#define DRV_VERSION	"2.6.0"
-#define DRV_RELDATE	"January 14, 2004"
+#define DRV_VERSION	"2.6.1"
+#define DRV_RELDATE	"October 29, 2004"
 #define DRV_NAME	"bonding"
 #define DRV_DESCRIPTION	"Ethernet Channel Bonding Driver"
 
diff -Nru a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c
--- a/drivers/net/bsd_comp.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/bsd_comp.c	2004-12-24 13:36:48 -08:00
@@ -1160,7 +1160,7 @@
  * Module support routines
  *************************************************************/
 
-int __init bsdcomp_init(void)
+static int __init bsdcomp_init(void)
 {
 	int answer = ppp_register_compressor(&ppp_bsd_compress);
 	if (answer == 0)
@@ -1168,7 +1168,7 @@
 	return answer;
 }
 
-void __exit bsdcomp_cleanup(void)
+static void __exit bsdcomp_cleanup(void)
 {
 	ppp_unregister_compressor(&ppp_bsd_compress);
 }
diff -Nru a/drivers/net/cris/Makefile b/drivers/net/cris/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/net/cris/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1 @@
+obj-$(CONFIG_ETRAX_ARCH_V10) += eth_v10.o
diff -Nru a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/net/cris/eth_v10.c	2004-12-24 13:36:48 -08:00
@@ -0,0 +1,1836 @@
+/* $Id: ethernet.c,v 1.31 2004/10/18 14:49:03 starvik Exp $
+ *
+ * e100net.c: A network driver for the ETRAX 100LX network controller.
+ *
+ * Copyright (c) 1998-2002 Axis Communications AB.
+ *
+ * The outline of this driver comes from skeleton.c.
+ *
+ * $Log: ethernet.c,v $
+ * Revision 1.31  2004/10/18 14:49:03  starvik
+ * Use RX interrupt as random source
+ *
+ * Revision 1.30  2004/09/29 10:44:04  starvik
+ * Enabed MAC-address output again
+ *
+ * Revision 1.29  2004/08/24 07:14:05  starvik
+ * Make use of generic MDIO interface and constants.
+ *
+ * Revision 1.28  2004/08/20 09:37:11  starvik
+ * Added support for Intel LXT972A. Creds to Randy Scarborough.
+ *
+ * Revision 1.27  2004/08/16 12:37:22  starvik
+ * Merge of Linux 2.6.8
+ *
+ * Revision 1.25  2004/06/21 10:29:57  starvik
+ * Merge of Linux 2.6.7
+ *
+ * Revision 1.23  2004/06/09 05:29:22  starvik
+ * Avoid any race where R_DMA_CH1_FIRST is NULL (may trigger cache bug).
+ *
+ * Revision 1.22  2004/05/14 07:58:03  starvik
+ * Merge of changes from 2.4
+ *
+ * Revision 1.20  2004/03/11 11:38:40  starvik
+ * Merge of Linux 2.6.4
+ *
+ * Revision 1.18  2003/12/03 13:45:46  starvik
+ * Use hardware pad for short packets to prevent information leakage.
+ *
+ * Revision 1.17  2003/07/04 08:27:37  starvik
+ * Merge of Linux 2.5.74
+ *
+ * Revision 1.16  2003/04/24 08:28:22  starvik
+ * New LED behaviour: LED off when no link
+ *
+ * Revision 1.15  2003/04/09 05:20:47  starvik
+ * Merge of Linux 2.5.67
+ *
+ * Revision 1.13  2003/03/06 16:11:01  henriken
+ * Off by one error in group address register setting.
+ *
+ * Revision 1.12  2003/02/27 17:24:19  starvik
+ * Corrected Rev to Revision
+ *
+ * Revision 1.11  2003/01/24 09:53:21  starvik
+ * Oops. Initialize GA to 0, not to 1
+ *
+ * Revision 1.10  2003/01/24 09:50:55  starvik
+ * Initialize GA_0 and GA_1 to 0 to avoid matching of unwanted packets
+ *
+ * Revision 1.9  2002/12/13 07:40:58  starvik
+ * Added basic ethtool interface
+ * Handled out of memory when allocating new buffers
+ *
+ * Revision 1.8  2002/12/11 13:13:57  starvik
+ * Added arch/ to v10 specific includes
+ * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
+ *
+ * Revision 1.7  2002/11/26 09:41:42  starvik
+ * Added e100_set_config (standard interface to set media type)
+ * Added protection against preemptive scheduling
+ * Added standard MII ioctls
+ *
+ * Revision 1.6  2002/11/21 07:18:18  starvik
+ * Timers must be initialized in 2.5.48
+ *
+ * Revision 1.5  2002/11/20 11:56:11  starvik
+ * Merge of Linux 2.5.48
+ *
+ * Revision 1.4  2002/11/18 07:26:46  starvik
+ * Linux 2.5 port of latest Linux 2.4 ethernet driver
+ *
+ * Revision 1.33  2002/10/02 20:16:17  hp
+ * SETF, SETS: Use underscored IO_x_ macros rather than incorrect token concatenation
+ *
+ * Revision 1.32  2002/09/16 06:05:58  starvik
+ * Align memory returned by dev_alloc_skb
+ * Moved handling of sent packets to interrupt to avoid reference counting problem
+ *
+ * Revision 1.31  2002/09/10 13:28:23  larsv
+ * Return -EINVAL for unknown ioctls to avoid confusing tools that tests
+ * for supported functionality by issuing special ioctls, i.e. wireless
+ * extensions.
+ *
+ * Revision 1.30  2002/05/07 18:50:08  johana
+ * Correct spelling in comments.
+ *
+ * Revision 1.29  2002/05/06 05:38:49  starvik
+ * Performance improvements:
+ *    Large packets are not copied (breakpoint set to 256 bytes)
+ *    The cache bug workaround is delayed until half of the receive list
+ *      has been used
+ *    Added transmit list
+ *    Transmit interrupts are only enabled when transmit queue is full
+ *
+ * Revision 1.28.2.1  2002/04/30 08:15:51  starvik
+ * Performance improvements:
+ *   Large packets are not copied (breakpoint set to 256 bytes)
+ *   The cache bug workaround is delayed until half of the receive list
+ *     has been used.
+ *   Added transmit list
+ *   Transmit interrupts are only enabled when transmit queue is full
+ *
+ * Revision 1.28  2002/04/22 11:47:21  johana
+ * Fix according to 2.4.19-pre7. time_after/time_before and
+ * missing end of comment.
+ * The patch has a typo for ethernet.c in e100_clear_network_leds(),
+ *  that is fixed here.
+ *
+ * Revision 1.27  2002/04/12 11:55:11  bjornw
+ * Added TODO
+ *
+ * Revision 1.26  2002/03/15 17:11:02  bjornw
+ * Use prepare_rx_descriptor after the CPU has touched the receiving descs
+ *
+ * Revision 1.25  2002/03/08 13:07:53  bjornw
+ * Unnecessary spinlock removed
+ *
+ * Revision 1.24  2002/02/20 12:57:43  fredriks
+ * Replaced MIN() with min().
+ *
+ * Revision 1.23  2002/02/20 10:58:14  fredriks
+ * Strip the Ethernet checksum (4 bytes) before forwarding a frame to upper layers.
+ *
+ * Revision 1.22  2002/01/30 07:48:22  matsfg
+ * Initiate R_NETWORK_TR_CTRL
+ *
+ * Revision 1.21  2001/11/23 11:54:49  starvik
+ * Added IFF_PROMISC and IFF_ALLMULTI handling in set_multicast_list
+ * Removed compiler warnings
+ *
+ * Revision 1.20  2001/11/12 19:26:00  pkj
+ * * Corrected e100_negotiate() to not assign half to current_duplex when
+ *   it was supposed to compare them...
+ * * Cleaned up failure handling in e100_open().
+ * * Fixed compiler warnings.
+ *
+ * Revision 1.19  2001/11/09 07:43:09  starvik
+ * Added full duplex support
+ * Added ioctl to set speed and duplex
+ * Clear LED timer only runs when LED is lit
+ *
+ * Revision 1.18  2001/10/03 14:40:43  jonashg
+ * Update rx_bytes counter.
+ *
+ * Revision 1.17  2001/06/11 12:43:46  olof
+ * Modified defines for network LED behavior
+ *
+ * Revision 1.16  2001/05/30 06:12:46  markusl
+ * TxDesc.next should not be set to NULL
+ *
+ * Revision 1.15  2001/05/29 10:27:04  markusl
+ * Updated after review remarks:
+ * +Use IO_EXTRACT
+ * +Handle underrun
+ *
+ * Revision 1.14  2001/05/29 09:20:14  jonashg
+ * Use driver name on printk output so one can tell which driver that complains.
+ *
+ * Revision 1.13  2001/05/09 12:35:59  johana
+ * Use DMA_NBR and IRQ_NBR defines from dma.h and irq.h
+ *
+ * Revision 1.12  2001/04/05 11:43:11  tobiasa
+ * Check dev before panic.
+ *
+ * Revision 1.11  2001/04/04 11:21:05  markusl
+ * Updated according to review remarks
+ *
+ * Revision 1.10  2001/03/26 16:03:06  bjornw
+ * Needs linux/config.h
+ *
+ * Revision 1.9  2001/03/19 14:47:48  pkj
+ * * Make sure there is always a pause after the network LEDs are
+ *   changed so they will not look constantly lit during heavy traffic.
+ * * Always use HZ when setting times relative to jiffies.
+ * * Use LED_NETWORK_SET() when setting the network LEDs.
+ *
+ * Revision 1.8  2001/02/27 13:52:48  bjornw
+ * malloc.h -> slab.h
+ *
+ * Revision 1.7  2001/02/23 13:46:38  bjornw
+ * Spellling check
+ *
+ * Revision 1.6  2001/01/26 15:21:04  starvik
+ * Don't disable interrupts while reading MDIO registers (MDIO is slow)
+ * Corrected promiscuous mode
+ * Improved deallocation of IRQs ("ifconfig eth0 down" now works)
+ *
+ * Revision 1.5  2000/11/29 17:22:22  bjornw
+ * Get rid of the udword types legacy stuff
+ *
+ * Revision 1.4  2000/11/22 16:36:09  bjornw
+ * Please marketing by using the correct case when spelling Etrax.
+ *
+ * Revision 1.3  2000/11/21 16:43:04  bjornw
+ * Minor short->int change
+ *
+ * Revision 1.2  2000/11/08 14:27:57  bjornw
+ * 2.4 port
+ *
+ * Revision 1.1  2000/11/06 13:56:00  bjornw
+ * Verbatim copy of the 1.24 version of e100net.c from elinux
+ *
+ * Revision 1.24  2000/10/04 15:55:23  bjornw
+ * * Use virt_to_phys etc. for DMA addresses
+ * * Removed bogus CHECKSUM_UNNECESSARY
+ *
+ *
+ */
+
+#include <linux/config.h>
+
+#include <linux/module.h>
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/types.h>
+#include <linux/fcntl.h>
+#include <linux/interrupt.h>
+#include <linux/ptrace.h>
+#include <linux/ioport.h>
+#include <linux/in.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/spinlock.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+
+#include <linux/if.h>
+#include <linux/mii.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/ethtool.h>
+
+#include <asm/arch/svinto.h>/* DMA and register descriptions */
+#include <asm/io.h>         /* LED_* I/O functions */
+#include <asm/irq.h>
+#include <asm/dma.h>
+#include <asm/system.h>
+#include <asm/bitops.h>
+#include <asm/ethernet.h>
+#include <asm/cache.h>
+
+//#define ETHDEBUG
+#define D(x)
+
+/*
+ * The name of the card. Is used for messages and in the requests for
+ * io regions, irqs and dma channels
+ */
+
+static const char* cardname = "ETRAX 100LX built-in ethernet controller";
+
+/* A default ethernet address. Highlevel SW will set the real one later */
+
+static struct sockaddr default_mac = {
+	0,
+	{ 0x00, 0x40, 0x8C, 0xCD, 0x00, 0x00 }
+};
+
+/* Information that need to be kept for each board. */
+struct net_local {
+	struct net_device_stats stats;
+	struct mii_if_info mii_if;
+
+	/* Tx control lock.  This protects the transmit buffer ring
+	 * state along with the "tx full" state of the driver.  This
+	 * means all netif_queue flow control actions are protected
+	 * by this lock as well.
+	 */
+	spinlock_t lock;
+};
+
+typedef struct etrax_eth_descr
+{
+	etrax_dma_descr descr;
+	struct sk_buff* skb;
+} etrax_eth_descr;
+
+/* Some transceivers requires special handling */
+struct transceiver_ops
+{
+	unsigned int oui;
+	void (*check_speed)(struct net_device* dev);
+	void (*check_duplex)(struct net_device* dev);
+};
+
+struct transceiver_ops* transceiver;
+
+/* Duplex settings */
+enum duplex
+{
+	half,
+	full,
+	autoneg
+};
+
+/* Dma descriptors etc. */
+
+#define MAX_MEDIA_DATA_SIZE 1518
+
+#define MIN_PACKET_LEN      46
+#define ETHER_HEAD_LEN      14
+
+/*
+** MDIO constants.
+*/
+#define MDIO_START                          0x1
+#define MDIO_READ                           0x2
+#define MDIO_WRITE                          0x1
+#define MDIO_PREAMBLE              0xfffffffful
+
+/* Broadcom specific */
+#define MDIO_AUX_CTRL_STATUS_REG           0x18
+#define MDIO_BC_FULL_DUPLEX_IND             0x1
+#define MDIO_BC_SPEED                       0x2
+
+/* TDK specific */
+#define MDIO_TDK_DIAGNOSTIC_REG              18
+#define MDIO_TDK_DIAGNOSTIC_RATE          0x400
+#define MDIO_TDK_DIAGNOSTIC_DPLX          0x800
+
+/*Intel LXT972A specific*/
+#define MDIO_INT_STATUS_REG_2			0x0011
+#define MDIO_INT_FULL_DUPLEX_IND		( 1 << 9 )
+#define MDIO_INT_SPEED				( 1 << 14 )
+
+/* Network flash constants */
+#define NET_FLASH_TIME                  (HZ/50) /* 20 ms */
+#define NET_FLASH_PAUSE                (HZ/100) /* 10 ms */
+#define NET_LINK_UP_CHECK_INTERVAL       (2*HZ) /* 2 s   */
+#define NET_DUPLEX_CHECK_INTERVAL        (2*HZ) /* 2 s   */
+
+#define NO_NETWORK_ACTIVITY 0
+#define NETWORK_ACTIVITY    1
+
+#define NBR_OF_RX_DESC     64
+#define NBR_OF_TX_DESC     256
+
+/* Large packets are sent directly to upper layers while small packets are */
+/* copied (to reduce memory waste). The following constant decides the breakpoint */
+#define RX_COPYBREAK 256
+
+/* Due to a chip bug we need to flush the cache when descriptors are returned */
+/* to the DMA. To decrease performance impact we return descriptors in chunks. */
+/* The following constant determines the number of descriptors to return. */
+#define RX_QUEUE_THRESHOLD  NBR_OF_RX_DESC/2
+
+#define GET_BIT(bit,val)   (((val) >> (bit)) & 0x01)
+
+/* Define some macros to access ETRAX 100 registers */
+#define SETF(var, reg, field, val) var = (var & ~IO_MASK_(reg##_, field##_)) | \
+					  IO_FIELD_(reg##_, field##_, val)
+#define SETS(var, reg, field, val) var = (var & ~IO_MASK_(reg##_, field##_)) | \
+					  IO_STATE_(reg##_, field##_, _##val)
+
+static etrax_eth_descr *myNextRxDesc;  /* Points to the next descriptor to
+                                          to be processed */
+static etrax_eth_descr *myLastRxDesc;  /* The last processed descriptor */
+static etrax_eth_descr *myPrevRxDesc;  /* The descriptor right before myNextRxDesc */
+
+static etrax_eth_descr RxDescList[NBR_OF_RX_DESC] __attribute__ ((aligned(32)));
+
+static etrax_eth_descr* myFirstTxDesc; /* First packet not yet sent */
+static etrax_eth_descr* myLastTxDesc;  /* End of send queue */
+static etrax_eth_descr* myNextTxDesc;  /* Next descriptor to use */
+static etrax_eth_descr TxDescList[NBR_OF_TX_DESC] __attribute__ ((aligned(32)));
+
+static unsigned int network_rec_config_shadow = 0;
+static unsigned int mdio_phy_addr; /* Transciever address */
+
+static unsigned int network_tr_ctrl_shadow = 0;
+
+/* Network speed indication. */
+static struct timer_list speed_timer = TIMER_INITIALIZER(NULL, 0, 0);
+static struct timer_list clear_led_timer = TIMER_INITIALIZER(NULL, 0, 0);
+static int current_speed; /* Speed read from transceiver */
+static int current_speed_selection; /* Speed selected by user */
+static unsigned long led_next_time;
+static int led_active;
+static int rx_queue_len;
+
+/* Duplex */
+static struct timer_list duplex_timer = TIMER_INITIALIZER(NULL, 0, 0);
+static int full_duplex;
+static enum duplex current_duplex;
+
+/* Index to functions, as function prototypes. */
+
+static int etrax_ethernet_init(void);
+
+static int e100_open(struct net_device *dev);
+static int e100_set_mac_address(struct net_device *dev, void *addr);
+static int e100_send_packet(struct sk_buff *skb, struct net_device *dev);
+static irqreturn_t e100rxtx_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t e100nw_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static void e100_rx(struct net_device *dev);
+static int e100_close(struct net_device *dev);
+static int e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
+static int e100_ethtool_ioctl(struct net_device* dev, struct ifreq *ifr);
+static int e100_set_config(struct net_device* dev, struct ifmap* map);
+static void e100_tx_timeout(struct net_device *dev);
+static struct net_device_stats *e100_get_stats(struct net_device *dev);
+static void set_multicast_list(struct net_device *dev);
+static void e100_hardware_send_packet(char *buf, int length);
+static void update_rx_stats(struct net_device_stats *);
+static void update_tx_stats(struct net_device_stats *);
+static int e100_probe_transceiver(struct net_device* dev);
+
+static void e100_check_speed(unsigned long priv);
+static void e100_set_speed(struct net_device* dev, unsigned long speed);
+static void e100_check_duplex(unsigned long priv);
+static void e100_set_duplex(struct net_device* dev, enum duplex);
+static void e100_negotiate(struct net_device* dev);
+
+static int e100_get_mdio_reg(struct net_device *dev, int phy_id, int location);
+static void e100_set_mdio_reg(struct net_device *dev, int phy_id, int location, int value);
+
+static void e100_send_mdio_cmd(unsigned short cmd, int write_cmd);
+static void e100_send_mdio_bit(unsigned char bit);
+static unsigned char e100_receive_mdio_bit(void);
+static void e100_reset_transceiver(struct net_device* net);
+
+static void e100_clear_network_leds(unsigned long dummy);
+static void e100_set_network_leds(int active);
+
+static void broadcom_check_speed(struct net_device* dev);
+static void broadcom_check_duplex(struct net_device* dev);
+static void tdk_check_speed(struct net_device* dev);
+static void tdk_check_duplex(struct net_device* dev);
+static void intel_check_speed(struct net_device* dev);
+static void intel_check_duplex(struct net_device* dev);
+static void generic_check_speed(struct net_device* dev);
+static void generic_check_duplex(struct net_device* dev);
+
+struct transceiver_ops transceivers[] =
+{
+	{0x1018, broadcom_check_speed, broadcom_check_duplex},  /* Broadcom */
+	{0xC039, tdk_check_speed, tdk_check_duplex},            /* TDK 2120 */
+	{0x039C, tdk_check_speed, tdk_check_duplex},            /* TDK 2120C */
+        {0x04de, intel_check_speed, intel_check_duplex},     	/* Intel LXT972A*/
+	{0x0000, generic_check_speed, generic_check_duplex}     /* Generic, must be last */
+};
+
+#define tx_done(dev) (*R_DMA_CH0_CMD == 0)
+
+/*
+ * Check for a network adaptor of this type, and return '0' if one exists.
+ * If dev->base_addr == 0, probe all likely locations.
+ * If dev->base_addr == 1, always return failure.
+ * If dev->base_addr == 2, allocate space for the device and return success
+ * (detachable devices only).
+ */
+
+static int __init
+etrax_ethernet_init(void)
+{
+	struct net_device *dev;
+        struct net_local* np;
+	int i, err;
+
+	printk(KERN_INFO
+	       "ETRAX 100LX 10/100MBit ethernet v2.0 (c) 2000-2003 Axis Communications AB\n");
+
+	dev = alloc_etherdev(sizeof(struct net_local));
+	np = dev->priv;
+
+	if (!dev)
+		return -ENOMEM;
+
+	dev->base_addr = (unsigned int)R_NETWORK_SA_0; /* just to have something to show */
+
+	/* now setup our etrax specific stuff */
+
+	dev->irq = NETWORK_DMA_RX_IRQ_NBR; /* we really use DMATX as well... */
+	dev->dma = NETWORK_RX_DMA_NBR;
+
+	/* fill in our handlers so the network layer can talk to us in the future */
+
+	dev->open               = e100_open;
+	dev->hard_start_xmit    = e100_send_packet;
+	dev->stop               = e100_close;
+	dev->get_stats          = e100_get_stats;
+	dev->set_multicast_list = set_multicast_list;
+	dev->set_mac_address    = e100_set_mac_address;
+	dev->do_ioctl           = e100_ioctl;
+	dev->set_config		= e100_set_config;
+	dev->tx_timeout         = e100_tx_timeout;
+
+	/* Initialise the list of Etrax DMA-descriptors */
+
+	/* Initialise receive descriptors */
+
+	for (i = 0; i < NBR_OF_RX_DESC; i++) {
+		/* Allocate two extra cachelines to make sure that buffer used by DMA
+		 * does not share cacheline with any other data (to avoid cache bug)
+		 */
+		RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
+		RxDescList[i].descr.ctrl   = 0;
+		RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE;
+		RxDescList[i].descr.next   = virt_to_phys(&RxDescList[i + 1]);
+		RxDescList[i].descr.buf    = L1_CACHE_ALIGN(virt_to_phys(RxDescList[i].skb->data));
+		RxDescList[i].descr.status = 0;
+		RxDescList[i].descr.hw_len = 0;
+		prepare_rx_descriptor(&RxDescList[i].descr);
+	}
+
+	RxDescList[NBR_OF_RX_DESC - 1].descr.ctrl   = d_eol;
+	RxDescList[NBR_OF_RX_DESC - 1].descr.next   = virt_to_phys(&RxDescList[0]);
+	rx_queue_len = 0;
+
+	/* Initialize transmit descriptors */
+	for (i = 0; i < NBR_OF_TX_DESC; i++) {
+		TxDescList[i].descr.ctrl   = 0;
+		TxDescList[i].descr.sw_len = 0;
+		TxDescList[i].descr.next   = virt_to_phys(&TxDescList[i + 1].descr);
+		TxDescList[i].descr.buf    = 0;
+		TxDescList[i].descr.status = 0;
+		TxDescList[i].descr.hw_len = 0;
+		TxDescList[i].skb = 0;
+	}
+
+	TxDescList[NBR_OF_TX_DESC - 1].descr.ctrl   = d_eol;
+	TxDescList[NBR_OF_TX_DESC - 1].descr.next   = virt_to_phys(&TxDescList[0].descr);
+
+	/* Initialise initial pointers */
+
+	myNextRxDesc  = &RxDescList[0];
+	myLastRxDesc  = &RxDescList[NBR_OF_RX_DESC - 1];
+	myPrevRxDesc  = &RxDescList[NBR_OF_RX_DESC - 1];
+	myFirstTxDesc = &TxDescList[0];
+	myNextTxDesc  = &TxDescList[0];
+	myLastTxDesc  = &TxDescList[NBR_OF_TX_DESC - 1];
+
+	/* Register device */
+	err = register_netdev(dev);
+	if (err) {
+		free_netdev(dev);
+		return err;
+	}
+
+	/* set the default MAC address */
+
+	e100_set_mac_address(dev, &default_mac);
+
+	/* Initialize speed indicator stuff. */
+
+	current_speed = 10;
+	current_speed_selection = 0; /* Auto */
+	speed_timer.expires = jiffies + NET_LINK_UP_CHECK_INTERVAL;
+        duplex_timer.data = (unsigned long)dev;
+	speed_timer.function = e100_check_speed;
+
+	clear_led_timer.function = e100_clear_network_leds;
+
+	full_duplex = 0;
+	current_duplex = autoneg;
+	duplex_timer.expires = jiffies + NET_DUPLEX_CHECK_INTERVAL;
+        duplex_timer.data = (unsigned long)dev;
+	duplex_timer.function = e100_check_duplex;
+
+        /* Initialize mii interface */
+	np->mii_if.phy_id = mdio_phy_addr;
+	np->mii_if.phy_id_mask = 0x1f;
+	np->mii_if.reg_num_mask = 0x1f;
+	np->mii_if.dev = dev;
+	np->mii_if.mdio_read = e100_get_mdio_reg;
+	np->mii_if.mdio_write = e100_set_mdio_reg;
+
+	/* Initialize group address registers to make sure that no */
+	/* unwanted addresses are matched */
+	*R_NETWORK_GA_0 = 0x00000000;
+	*R_NETWORK_GA_1 = 0x00000000;
+	return 0;
+}
+
+/* set MAC address of the interface. called from the core after a
+ * SIOCSIFADDR ioctl, and from the bootup above.
+ */
+
+static int
+e100_set_mac_address(struct net_device *dev, void *p)
+{
+	struct net_local *np = (struct net_local *)dev->priv;
+	struct sockaddr *addr = p;
+	int i;
+
+	spin_lock(&np->lock); /* preemption protection */
+
+	/* remember it */
+
+	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+
+	/* Write it to the hardware.
+	 * Note the way the address is wrapped:
+	 * *R_NETWORK_SA_0 = a0_0 | (a0_1 << 8) | (a0_2 << 16) | (a0_3 << 24);
+	 * *R_NETWORK_SA_1 = a0_4 | (a0_5 << 8);
+	 */
+
+	*R_NETWORK_SA_0 = dev->dev_addr[0] | (dev->dev_addr[1] << 8) |
+		(dev->dev_addr[2] << 16) | (dev->dev_addr[3] << 24);
+	*R_NETWORK_SA_1 = dev->dev_addr[4] | (dev->dev_addr[5] << 8);
+	*R_NETWORK_SA_2 = 0;
+
+	/* show it in the log as well */
+
+	printk(KERN_INFO "%s: changed MAC to ", dev->name);
+
+	for (i = 0; i < 5; i++)
+		printk("%02X:", dev->dev_addr[i]);
+
+	printk("%02X\n", dev->dev_addr[i]);
+
+	spin_unlock(&np->lock);
+
+	return 0;
+}
+
+/*
+ * Open/initialize the board. This is called (in the current kernel)
+ * sometime after booting when the 'ifconfig' program is run.
+ *
+ * This routine should set everything up anew at each open, even
+ * registers that "should" only need to be set once at boot, so that
+ * there is non-reboot way to recover if something goes wrong.
+ */
+
+static int
+e100_open(struct net_device *dev)
+{
+	unsigned long flags;
+
+	/* enable the MDIO output pin */
+
+	*R_NETWORK_MGM_CTRL = IO_STATE(R_NETWORK_MGM_CTRL, mdoe, enable);
+
+	*R_IRQ_MASK0_CLR =
+		IO_STATE(R_IRQ_MASK0_CLR, overrun, clr) |
+		IO_STATE(R_IRQ_MASK0_CLR, underrun, clr) |
+		IO_STATE(R_IRQ_MASK0_CLR, excessive_col, clr);
+
+	/* clear dma0 and 1 eop and descr irq masks */
+	*R_IRQ_MASK2_CLR =
+		IO_STATE(R_IRQ_MASK2_CLR, dma0_descr, clr) |
+		IO_STATE(R_IRQ_MASK2_CLR, dma0_eop, clr) |
+		IO_STATE(R_IRQ_MASK2_CLR, dma1_descr, clr) |
+		IO_STATE(R_IRQ_MASK2_CLR, dma1_eop, clr);
+
+	/* Reset and wait for the DMA channels */
+
+	RESET_DMA(NETWORK_TX_DMA_NBR);
+	RESET_DMA(NETWORK_RX_DMA_NBR);
+	WAIT_DMA(NETWORK_TX_DMA_NBR);
+	WAIT_DMA(NETWORK_RX_DMA_NBR);
+
+	/* Initialise the etrax network controller */
+
+	/* allocate the irq corresponding to the receiving DMA */
+
+	if (request_irq(NETWORK_DMA_RX_IRQ_NBR, e100rxtx_interrupt,
+			SA_SAMPLE_RANDOM, cardname, (void *)dev)) {
+		goto grace_exit0;
+	}
+
+	/* allocate the irq corresponding to the transmitting DMA */
+
+	if (request_irq(NETWORK_DMA_TX_IRQ_NBR, e100rxtx_interrupt, 0,
+			cardname, (void *)dev)) {
+		goto grace_exit1;
+	}
+
+	/* allocate the irq corresponding to the network errors etc */
+
+	if (request_irq(NETWORK_STATUS_IRQ_NBR, e100nw_interrupt, 0,
+			cardname, (void *)dev)) {
+		goto grace_exit2;
+	}
+
+	/* give the HW an idea of what MAC address we want */
+
+	*R_NETWORK_SA_0 = dev->dev_addr[0] | (dev->dev_addr[1] << 8) |
+		(dev->dev_addr[2] << 16) | (dev->dev_addr[3] << 24);
+	*R_NETWORK_SA_1 = dev->dev_addr[4] | (dev->dev_addr[5] << 8);
+	*R_NETWORK_SA_2 = 0;
+
+#if 0
+	/* use promiscuous mode for testing */
+	*R_NETWORK_GA_0 = 0xffffffff;
+	*R_NETWORK_GA_1 = 0xffffffff;
+
+	*R_NETWORK_REC_CONFIG = 0xd; /* broadcast rec, individ. rec, ma0 enabled */
+#else
+	SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, broadcast, receive);
+	SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, ma0, enable);
+	SETF(network_rec_config_shadow, R_NETWORK_REC_CONFIG, duplex, full_duplex);
+	*R_NETWORK_REC_CONFIG = network_rec_config_shadow;
+#endif
+
+	*R_NETWORK_GEN_CONFIG =
+		IO_STATE(R_NETWORK_GEN_CONFIG, phy,    mii_clk) |
+		IO_STATE(R_NETWORK_GEN_CONFIG, enable, on);
+
+	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, clr);
+	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, delay, none);
+	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, cancel, dont);
+	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, cd, enable);
+	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, retry, enable);
+	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, pad, enable);
+	SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, crc, enable);
+	*R_NETWORK_TR_CTRL = network_tr_ctrl_shadow;
+
+	save_flags(flags);
+	cli();
+
+	/* enable the irq's for ethernet DMA */
+
+	*R_IRQ_MASK2_SET =
+		IO_STATE(R_IRQ_MASK2_SET, dma0_eop, set) |
+		IO_STATE(R_IRQ_MASK2_SET, dma1_eop, set);
+
+	*R_IRQ_MASK0_SET =
+		IO_STATE(R_IRQ_MASK0_SET, overrun,       set) |
+		IO_STATE(R_IRQ_MASK0_SET, underrun,      set) |
+		IO_STATE(R_IRQ_MASK0_SET, excessive_col, set);
+
+	/* make sure the irqs are cleared */
+
+	*R_DMA_CH0_CLR_INTR = IO_STATE(R_DMA_CH0_CLR_INTR, clr_eop, do);
+	*R_DMA_CH1_CLR_INTR = IO_STATE(R_DMA_CH1_CLR_INTR, clr_eop, do);
+
+	/* make sure the rec and transmit error counters are cleared */
+
+	(void)*R_REC_COUNTERS;  /* dummy read */
+	(void)*R_TR_COUNTERS;   /* dummy read */
+
+	/* start the receiving DMA channel so we can receive packets from now on */
+
+	*R_DMA_CH1_FIRST = virt_to_phys(myNextRxDesc);
+	*R_DMA_CH1_CMD = IO_STATE(R_DMA_CH1_CMD, cmd, start);
+
+	/* Set up transmit DMA channel so it can be restarted later */
+
+	*R_DMA_CH0_FIRST = 0;
+	*R_DMA_CH0_DESCR = virt_to_phys(myLastTxDesc);
+
+	restore_flags(flags);
+
+	/* Probe for transceiver */
+	if (e100_probe_transceiver(dev))
+		goto grace_exit3;
+
+	/* Start duplex/speed timers */
+	add_timer(&speed_timer);
+	add_timer(&duplex_timer);
+
+	/* We are now ready to accept transmit requeusts from
+	 * the queueing layer of the networking.
+	 */
+	netif_start_queue(dev);
+
+	return 0;
+
+grace_exit3:
+	free_irq(NETWORK_STATUS_IRQ_NBR, (void *)dev);
+grace_exit2:
+	free_irq(NETWORK_DMA_TX_IRQ_NBR, (void *)dev);
+grace_exit1:
+	free_irq(NETWORK_DMA_RX_IRQ_NBR, (void *)dev);
+grace_exit0:
+	return -EAGAIN;
+}
+
+
+static void
+generic_check_speed(struct net_device* dev)
+{
+	unsigned long data;
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_ADVERTISE);
+	if ((data & ADVERTISE_100FULL) ||
+	    (data & ADVERTISE_100HALF))
+		current_speed = 100;
+	else
+		current_speed = 10;
+}
+
+static void
+tdk_check_speed(struct net_device* dev)
+{
+	unsigned long data;
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_TDK_DIAGNOSTIC_REG);
+	current_speed = (data & MDIO_TDK_DIAGNOSTIC_RATE ? 100 : 10);
+}
+
+static void
+broadcom_check_speed(struct net_device* dev)
+{
+	unsigned long data;
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_AUX_CTRL_STATUS_REG);
+	current_speed = (data & MDIO_BC_SPEED ? 100 : 10);
+}
+
+static void
+intel_check_speed(struct net_device* dev)
+{
+	unsigned long data;
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_INT_STATUS_REG_2);
+	current_speed = (data & MDIO_INT_SPEED ? 100 : 10);
+}
+
+static void
+e100_check_speed(unsigned long priv)
+{
+	struct net_device* dev = (struct net_device*)priv;
+	static int led_initiated = 0;
+	unsigned long data;
+	int old_speed = current_speed;
+
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMSR);
+	if (!(data & BMSR_LSTATUS)) {
+		current_speed = 0;
+	} else {
+		transceiver->check_speed(dev);
+	}
+
+	if ((old_speed != current_speed) || !led_initiated) {
+		led_initiated = 1;
+		e100_set_network_leds(NO_NETWORK_ACTIVITY);
+	}
+
+	/* Reinitialize the timer. */
+	speed_timer.expires = jiffies + NET_LINK_UP_CHECK_INTERVAL;
+	add_timer(&speed_timer);
+}
+
+static void
+e100_negotiate(struct net_device* dev)
+{
+	unsigned short data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_ADVERTISE);
+
+	/* Discard old speed and duplex settings */
+	data &= ~(ADVERTISE_100HALF | ADVERTISE_100FULL |
+	          ADVERTISE_10HALF | ADVERTISE_10FULL);
+
+	switch (current_speed_selection) {
+		case 10 :
+			if (current_duplex == full)
+				data |= ADVERTISE_10FULL;
+			else if (current_duplex == half)
+				data |= ADVERTISE_10HALF;
+			else
+				data |= ADVERTISE_10HALF | ADVERTISE_10FULL;
+			break;
+
+		case 100 :
+			 if (current_duplex == full)
+				data |= ADVERTISE_100FULL;
+			else if (current_duplex == half)
+				data |= ADVERTISE_100HALF;
+			else
+				data |= ADVERTISE_100HALF | ADVERTISE_100FULL;
+			break;
+
+		case 0 : /* Auto */
+			 if (current_duplex == full)
+				data |= ADVERTISE_100FULL | ADVERTISE_10FULL;
+			else if (current_duplex == half)
+				data |= ADVERTISE_100HALF | ADVERTISE_10HALF;
+			else
+				data |= ADVERTISE_10HALF | ADVERTISE_10FULL |
+				  ADVERTISE_100HALF | ADVERTISE_100FULL;
+			break;
+
+		default : /* assume autoneg speed and duplex */
+			data |= ADVERTISE_10HALF | ADVERTISE_10FULL |
+				  ADVERTISE_100HALF | ADVERTISE_100FULL;
+	}
+
+	e100_set_mdio_reg(dev, mdio_phy_addr, MII_ADVERTISE, data);
+
+	/* Renegotiate with link partner */
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMCR);
+	data |= BMCR_ANENABLE | BMCR_ANRESTART;
+
+	e100_set_mdio_reg(dev, mdio_phy_addr, MII_BMCR, data);
+}
+
+static void
+e100_set_speed(struct net_device* dev, unsigned long speed)
+{
+	if (speed != current_speed_selection) {
+		current_speed_selection = speed;
+		e100_negotiate(dev);
+	}
+}
+
+static void
+e100_check_duplex(unsigned long priv)
+{
+	struct net_device *dev = (struct net_device *)priv;
+	struct net_local *np = (struct net_local *)dev->priv;
+	int old_duplex = full_duplex;
+	transceiver->check_duplex(dev);
+	if (old_duplex != full_duplex) {
+		/* Duplex changed */
+		SETF(network_rec_config_shadow, R_NETWORK_REC_CONFIG, duplex, full_duplex);
+		*R_NETWORK_REC_CONFIG = network_rec_config_shadow;
+	}
+
+	/* Reinitialize the timer. */
+	duplex_timer.expires = jiffies + NET_DUPLEX_CHECK_INTERVAL;
+	add_timer(&duplex_timer);
+	np->mii_if.full_duplex = full_duplex;
+}
+
+static void
+generic_check_duplex(struct net_device* dev)
+{
+	unsigned long data;
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_ADVERTISE);
+	if ((data & ADVERTISE_10FULL) ||
+	    (data & ADVERTISE_100FULL))
+		full_duplex = 1;
+	else
+		full_duplex = 0;
+}
+
+static void
+tdk_check_duplex(struct net_device* dev)
+{
+	unsigned long data;
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_TDK_DIAGNOSTIC_REG);
+	full_duplex = (data & MDIO_TDK_DIAGNOSTIC_DPLX) ? 1 : 0;
+}
+
+static void
+broadcom_check_duplex(struct net_device* dev)
+{
+	unsigned long data;
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_AUX_CTRL_STATUS_REG);
+	full_duplex = (data & MDIO_BC_FULL_DUPLEX_IND) ? 1 : 0;
+}
+
+static void
+intel_check_duplex(struct net_device* dev)
+{
+	unsigned long data;
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_INT_STATUS_REG_2);
+	full_duplex = (data & MDIO_INT_FULL_DUPLEX_IND) ? 1 : 0;
+}
+
+static void
+e100_set_duplex(struct net_device* dev, enum duplex new_duplex)
+{
+	if (new_duplex != current_duplex) {
+		current_duplex = new_duplex;
+		e100_negotiate(dev);
+	}
+}
+
+static int
+e100_probe_transceiver(struct net_device* dev)
+{
+	unsigned int phyid_high;
+	unsigned int phyid_low;
+	unsigned int oui;
+	struct transceiver_ops* ops = NULL;
+
+	/* Probe MDIO physical address */
+	for (mdio_phy_addr = 0; mdio_phy_addr <= 31; mdio_phy_addr++) {
+		if (e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMSR) != 0xffff)
+			break;
+	}
+	if (mdio_phy_addr == 32)
+		 return -ENODEV;
+
+	/* Get manufacturer */
+	phyid_high = e100_get_mdio_reg(dev, mdio_phy_addr, MII_PHYSID1);
+	phyid_low = e100_get_mdio_reg(dev, mdio_phy_addr, MII_PHYSID2);
+	oui = (phyid_high << 6) | (phyid_low >> 10);
+
+	for (ops = &transceivers[0]; ops->oui; ops++) {
+		if (ops->oui == oui)
+			break;
+	}
+	transceiver = ops;
+
+	return 0;
+}
+
+static int
+e100_get_mdio_reg(struct net_device *dev, int phy_id, int location)
+{
+	unsigned short cmd;    /* Data to be sent on MDIO port */
+	int data;   /* Data read from MDIO */
+	int bitCounter;
+
+	/* Start of frame, OP Code, Physical Address, Register Address */
+	cmd = (MDIO_START << 14) | (MDIO_READ << 12) | (phy_id << 7) |
+		(location << 2);
+
+	e100_send_mdio_cmd(cmd, 0);
+
+	data = 0;
+
+	/* Data... */
+	for (bitCounter=15; bitCounter>=0 ; bitCounter--) {
+		data |= (e100_receive_mdio_bit() << bitCounter);
+	}
+
+	return data;
+}
+
+static void
+e100_set_mdio_reg(struct net_device *dev, int phy_id, int location, int value)
+{
+	int bitCounter;
+	unsigned short cmd;
+
+	cmd = (MDIO_START << 14) | (MDIO_WRITE << 12) | (phy_id << 7) |
+	      (location << 2);
+
+	e100_send_mdio_cmd(cmd, 1);
+
+	/* Data... */
+	for (bitCounter=15; bitCounter>=0 ; bitCounter--) {
+		e100_send_mdio_bit(GET_BIT(bitCounter, value));
+	}
+
+}
+
+static void
+e100_send_mdio_cmd(unsigned short cmd, int write_cmd)
+{
+	int bitCounter;
+	unsigned char data = 0x2;
+
+	/* Preamble */
+	for (bitCounter = 31; bitCounter>= 0; bitCounter--)
+		e100_send_mdio_bit(GET_BIT(bitCounter, MDIO_PREAMBLE));
+
+	for (bitCounter = 15; bitCounter >= 2; bitCounter--)
+		e100_send_mdio_bit(GET_BIT(bitCounter, cmd));
+
+	/* Turnaround */
+	for (bitCounter = 1; bitCounter >= 0 ; bitCounter--)
+		if (write_cmd)
+			e100_send_mdio_bit(GET_BIT(bitCounter, data));
+		else
+			e100_receive_mdio_bit();
+}
+
+static void
+e100_send_mdio_bit(unsigned char bit)
+{
+	*R_NETWORK_MGM_CTRL =
+		IO_STATE(R_NETWORK_MGM_CTRL, mdoe, enable) |
+		IO_FIELD(R_NETWORK_MGM_CTRL, mdio, bit);
+	udelay(1);
+	*R_NETWORK_MGM_CTRL =
+		IO_STATE(R_NETWORK_MGM_CTRL, mdoe, enable) |
+		IO_MASK(R_NETWORK_MGM_CTRL, mdck) |
+		IO_FIELD(R_NETWORK_MGM_CTRL, mdio, bit);
+	udelay(1);
+}
+
+static unsigned char
+e100_receive_mdio_bit()
+{
+	unsigned char bit;
+	*R_NETWORK_MGM_CTRL = 0;
+	bit = IO_EXTRACT(R_NETWORK_STAT, mdio, *R_NETWORK_STAT);
+	udelay(1);
+	*R_NETWORK_MGM_CTRL = IO_MASK(R_NETWORK_MGM_CTRL, mdck);
+	udelay(1);
+	return bit;
+}
+
+static void
+e100_reset_transceiver(struct net_device* dev)
+{
+	unsigned short cmd;
+	unsigned short data;
+	int bitCounter;
+
+	data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMCR);
+
+	cmd = (MDIO_START << 14) | (MDIO_WRITE << 12) | (mdio_phy_addr << 7) | (MII_BMCR << 2);
+
+	e100_send_mdio_cmd(cmd, 1);
+
+	data |= 0x8000;
+
+	for (bitCounter = 15; bitCounter >= 0 ; bitCounter--) {
+		e100_send_mdio_bit(GET_BIT(bitCounter, data));
+	}
+}
+
+/* Called by upper layers if they decide it took too long to complete
+ * sending a packet - we need to reset and stuff.
+ */
+
+static void
+e100_tx_timeout(struct net_device *dev)
+{
+	struct net_local *np = (struct net_local *)dev->priv;
+	unsigned long flags;
+
+	spin_lock_irqsave(&np->lock, flags);
+
+	printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
+	       tx_done(dev) ? "IRQ problem" : "network cable problem");
+
+	/* remember we got an error */
+
+	np->stats.tx_errors++;
+
+	/* reset the TX DMA in case it has hung on something */
+
+	RESET_DMA(NETWORK_TX_DMA_NBR);
+	WAIT_DMA(NETWORK_TX_DMA_NBR);
+
+	/* Reset the transceiver. */
+
+	e100_reset_transceiver(dev);
+
+	/* and get rid of the packets that never got an interrupt */
+	while (myFirstTxDesc != myNextTxDesc)
+	{
+		dev_kfree_skb(myFirstTxDesc->skb);
+		myFirstTxDesc->skb = 0;
+		myFirstTxDesc = phys_to_virt(myFirstTxDesc->descr.next);
+	}
+
+	/* Set up transmit DMA channel so it can be restarted later */
+	*R_DMA_CH0_FIRST = 0;
+	*R_DMA_CH0_DESCR = virt_to_phys(myLastTxDesc);
+
+	/* tell the upper layers we're ok again */
+
+	netif_wake_queue(dev);
+	spin_unlock_irqrestore(&np->lock, flags);
+}
+
+
+/* This will only be invoked if the driver is _not_ in XOFF state.
+ * What this means is that we need not check it, and that this
+ * invariant will hold if we make sure that the netif_*_queue()
+ * calls are done at the proper times.
+ */
+
+static int
+e100_send_packet(struct sk_buff *skb, struct net_device *dev)
+{
+	struct net_local *np = (struct net_local *)dev->priv;
+	unsigned char *buf = skb->data;
+	unsigned long flags;
+
+#ifdef ETHDEBUG
+	printk("send packet len %d\n", length);
+#endif
+	spin_lock_irqsave(&np->lock, flags);  /* protect from tx_interrupt and ourself */
+
+	myNextTxDesc->skb = skb;
+
+	dev->trans_start = jiffies;
+
+	e100_hardware_send_packet(buf, skb->len);
+
+	myNextTxDesc = phys_to_virt(myNextTxDesc->descr.next);
+
+	/* Stop queue if full */
+	if (myNextTxDesc == myFirstTxDesc) {
+		netif_stop_queue(dev);
+	}
+
+	spin_unlock_irqrestore(&np->lock, flags);
+
+	return 0;
+}
+
+/*
+ * The typical workload of the driver:
+ *   Handle the network interface interrupts.
+ */
+
+static irqreturn_t
+e100rxtx_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+{
+	struct net_device *dev = (struct net_device *)dev_id;
+	struct net_local *np = (struct net_local *)dev->priv;
+	unsigned long irqbits = *R_IRQ_MASK2_RD;
+
+	/* Disable RX/TX IRQs to avoid reentrancy */
+	*R_IRQ_MASK2_CLR =
+	  IO_STATE(R_IRQ_MASK2_CLR, dma0_eop, clr) |
+	  IO_STATE(R_IRQ_MASK2_CLR, dma1_eop, clr);
+
+	/* Handle received packets */
+	if (irqbits & IO_STATE(R_IRQ_MASK2_RD, dma1_eop, active)) {
+		/* acknowledge the eop interrupt */
+
+		*R_DMA_CH1_CLR_INTR = IO_STATE(R_DMA_CH1_CLR_INTR, clr_eop, do);
+
+		/* check if one or more complete packets were indeed received */
+
+		while ((*R_DMA_CH1_FIRST != virt_to_phys(myNextRxDesc)) &&
+		       (myNextRxDesc != myLastRxDesc)) {
+			/* Take out the buffer and give it to the OS, then
+			 * allocate a new buffer to put a packet in.
+			 */
+			e100_rx(dev);
+			((struct net_local *)dev->priv)->stats.rx_packets++;
+			/* restart/continue on the channel, for safety */
+			*R_DMA_CH1_CMD = IO_STATE(R_DMA_CH1_CMD, cmd, restart);
+			/* clear dma channel 1 eop/descr irq bits */
+			*R_DMA_CH1_CLR_INTR =
+				IO_STATE(R_DMA_CH1_CLR_INTR, clr_eop, do) |
+				IO_STATE(R_DMA_CH1_CLR_INTR, clr_descr, do);
+
+			/* now, we might have gotten another packet
+			   so we have to loop back and check if so */
+		}
+	}
+
+	/* Report any packets that have been sent */
+	while (myFirstTxDesc != phys_to_virt(*R_DMA_CH0_FIRST) &&
+	       myFirstTxDesc != myNextTxDesc)
+	{
+		np->stats.tx_bytes += myFirstTxDesc->skb->len;
+		np->stats.tx_packets++;
+
+		/* dma is ready with the transmission of the data in tx_skb, so now
+		   we can release the skb memory */
+		dev_kfree_skb_irq(myFirstTxDesc->skb);
+		myFirstTxDesc->skb = 0;
+		myFirstTxDesc = phys_to_virt(myFirstTxDesc->descr.next);
+	}
+
+	if (irqbits & IO_STATE(R_IRQ_MASK2_RD, dma0_eop, active)) {
+		/* acknowledge the eop interrupt and wake up queue */
+		*R_DMA_CH0_CLR_INTR = IO_STATE(R_DMA_CH0_CLR_INTR, clr_eop, do);
+		netif_wake_queue(dev);
+	}
+
+	/* Enable RX/TX IRQs again */
+	*R_IRQ_MASK2_SET =
+	  IO_STATE(R_IRQ_MASK2_SET, dma0_eop, set) |
+	  IO_STATE(R_IRQ_MASK2_SET, dma1_eop, set);
+
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t
+e100nw_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+{
+	struct net_device *dev = (struct net_device *)dev_id;
+	struct net_local *np = (struct net_local *)dev->priv;
+	unsigned long irqbits = *R_IRQ_MASK0_RD;
+
+	/* check for underrun irq */
+	if (irqbits & IO_STATE(R_IRQ_MASK0_RD, underrun, active)) {
+		SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, clr);
+		*R_NETWORK_TR_CTRL = network_tr_ctrl_shadow;
+		SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, nop);
+		np->stats.tx_errors++;
+		D(printk("ethernet receiver underrun!\n"));
+	}
+
+	/* check for overrun irq */
+	if (irqbits & IO_STATE(R_IRQ_MASK0_RD, overrun, active)) {
+		update_rx_stats(&np->stats); /* this will ack the irq */
+		D(printk("ethernet receiver overrun!\n"));
+	}
+	/* check for excessive collision irq */
+	if (irqbits & IO_STATE(R_IRQ_MASK0_RD, excessive_col, active)) {
+		SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, clr);
+		*R_NETWORK_TR_CTRL = network_tr_ctrl_shadow;
+		SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, nop);
+		*R_NETWORK_TR_CTRL = IO_STATE(R_NETWORK_TR_CTRL, clr_error, clr);
+		np->stats.tx_errors++;
+		D(printk("ethernet excessive collisions!\n"));
+	}
+	return IRQ_HANDLED;
+}
+
+/* We have a good packet(s), get it/them out of the buffers. */
+static void
+e100_rx(struct net_device *dev)
+{
+	struct sk_buff *skb;
+	int length = 0;
+	struct net_local *np = (struct net_local *)dev->priv;
+	unsigned char *skb_data_ptr;
+#ifdef ETHDEBUG
+	int i;
+#endif
+
+	if (!led_active && time_after(jiffies, led_next_time)) {
+		/* light the network leds depending on the current speed. */
+		e100_set_network_leds(NETWORK_ACTIVITY);
+
+		/* Set the earliest time we may clear the LED */
+		led_next_time = jiffies + NET_FLASH_TIME;
+		led_active = 1;
+		mod_timer(&clear_led_timer, jiffies + HZ/10);
+	}
+
+	length = myNextRxDesc->descr.hw_len - 4;
+	((struct net_local *)dev->priv)->stats.rx_bytes += length;
+
+#ifdef ETHDEBUG
+	printk("Got a packet of length %d:\n", length);
+	/* dump the first bytes in the packet */
+	skb_data_ptr = (unsigned char *)phys_to_virt(myNextRxDesc->descr.buf);
+	for (i = 0; i < 8; i++) {
+		printk("%d: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", i * 8,
+		       skb_data_ptr[0],skb_data_ptr[1],skb_data_ptr[2],skb_data_ptr[3],
+		       skb_data_ptr[4],skb_data_ptr[5],skb_data_ptr[6],skb_data_ptr[7]);
+		skb_data_ptr += 8;
+	}
+#endif
+
+	if (length < RX_COPYBREAK) {
+		/* Small packet, copy data */
+		skb = dev_alloc_skb(length - ETHER_HEAD_LEN);
+		if (!skb) {
+			np->stats.rx_errors++;
+			printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
+			return;
+		}
+
+		skb_put(skb, length - ETHER_HEAD_LEN);        /* allocate room for the packet body */
+		skb_data_ptr = skb_push(skb, ETHER_HEAD_LEN); /* allocate room for the header */
+
+#ifdef ETHDEBUG
+		printk("head = 0x%x, data = 0x%x, tail = 0x%x, end = 0x%x\n",
+		  skb->head, skb->data, skb->tail, skb->end);
+		printk("copying packet to 0x%x.\n", skb_data_ptr);
+#endif
+
+		memcpy(skb_data_ptr, phys_to_virt(myNextRxDesc->descr.buf), length);
+	}
+	else {
+		/* Large packet, send directly to upper layers and allocate new
+		 * memory (aligned to cache line boundary to avoid bug).
+		 * Before sending the skb to upper layers we must make sure that
+		 * skb->data points to the aligned start of the packet.
+		 */
+		int align;
+		struct sk_buff *new_skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
+		if (!new_skb) {
+			np->stats.rx_errors++;
+			printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
+			return;
+		}
+		skb = myNextRxDesc->skb;
+		align = (int)phys_to_virt(myNextRxDesc->descr.buf) - (int)skb->data;
+		skb_put(skb, length + align);
+		skb_pull(skb, align); /* Remove alignment bytes */
+		myNextRxDesc->skb = new_skb;
+		myNextRxDesc->descr.buf = L1_CACHE_ALIGN(virt_to_phys(myNextRxDesc->skb->data));
+	}
+
+	skb->dev = dev;
+	skb->protocol = eth_type_trans(skb, dev);
+
+	/* Send the packet to the upper layers */
+	netif_rx(skb);
+
+	/* Prepare for next packet */
+	myNextRxDesc->descr.status = 0;
+	myPrevRxDesc = myNextRxDesc;
+	myNextRxDesc = phys_to_virt(myNextRxDesc->descr.next);
+
+	rx_queue_len++;
+
+	/* Check if descriptors should be returned */
+	if (rx_queue_len == RX_QUEUE_THRESHOLD) {
+		flush_etrax_cache();
+		myPrevRxDesc->descr.ctrl |= d_eol;
+		myLastRxDesc->descr.ctrl &= ~d_eol;
+		myLastRxDesc = myPrevRxDesc;
+		rx_queue_len = 0;
+	}
+}
+
+/* The inverse routine to net_open(). */
+static int
+e100_close(struct net_device *dev)
+{
+	struct net_local *np = (struct net_local *)dev->priv;
+
+	printk(KERN_INFO "Closing %s.\n", dev->name);
+
+	netif_stop_queue(dev);
+
+	*R_IRQ_MASK0_CLR =
+		IO_STATE(R_IRQ_MASK0_CLR, overrun, clr) |
+		IO_STATE(R_IRQ_MASK0_CLR, underrun, clr) |
+		IO_STATE(R_IRQ_MASK0_CLR, excessive_col, clr);
+
+	*R_IRQ_MASK2_CLR =
+		IO_STATE(R_IRQ_MASK2_CLR, dma0_descr, clr) |
+		IO_STATE(R_IRQ_MASK2_CLR, dma0_eop, clr) |
+		IO_STATE(R_IRQ_MASK2_CLR, dma1_descr, clr) |
+		IO_STATE(R_IRQ_MASK2_CLR, dma1_eop, clr);
+
+	/* Stop the receiver and the transmitter */
+
+	RESET_DMA(NETWORK_TX_DMA_NBR);
+	RESET_DMA(NETWORK_RX_DMA_NBR);
+
+	/* Flush the Tx and disable Rx here. */
+
+	free_irq(NETWORK_DMA_RX_IRQ_NBR, (void *)dev);
+	free_irq(NETWORK_DMA_TX_IRQ_NBR, (void *)dev);
+	free_irq(NETWORK_STATUS_IRQ_NBR, (void *)dev);
+
+	/* Update the statistics here. */
+
+	update_rx_stats(&np->stats);
+	update_tx_stats(&np->stats);
+
+	/* Stop speed/duplex timers */
+	del_timer(&speed_timer);
+	del_timer(&duplex_timer);
+
+	return 0;
+}
+
+static int
+e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+	struct mii_ioctl_data *data = if_mii(ifr);
+	struct net_local *np = netdev_priv(dev);
+
+	spin_lock(&np->lock); /* Preempt protection */
+	switch (cmd) {
+		case SIOCETHTOOL:
+			return e100_ethtool_ioctl(dev,ifr);
+		case SIOCGMIIPHY: /* Get PHY address */
+			data->phy_id = mdio_phy_addr;
+			break;
+		case SIOCGMIIREG: /* Read MII register */
+			data->val_out = e100_get_mdio_reg(dev, mdio_phy_addr, data->reg_num);
+			break;
+		case SIOCSMIIREG: /* Write MII register */
+			e100_set_mdio_reg(dev, mdio_phy_addr, data->reg_num, data->val_in);
+			break;
+		/* The ioctls below should be considered obsolete but are */
+		/* still present for compatability with old scripts/apps  */
+		case SET_ETH_SPEED_10:                  /* 10 Mbps */
+			e100_set_speed(dev, 10);
+			break;
+		case SET_ETH_SPEED_100:                /* 100 Mbps */
+			e100_set_speed(dev, 100);
+			break;
+		case SET_ETH_SPEED_AUTO:              /* Auto negotiate speed */
+			e100_set_speed(dev, 0);
+			break;
+		case SET_ETH_DUPLEX_HALF:              /* Half duplex. */
+			e100_set_duplex(dev, half);
+			break;
+		case SET_ETH_DUPLEX_FULL:              /* Full duplex. */
+			e100_set_duplex(dev, full);
+			break;
+		case SET_ETH_DUPLEX_AUTO:             /* Autonegotiate duplex*/
+			e100_set_duplex(dev, autoneg);
+			break;
+		default:
+			return -EINVAL;
+	}
+	spin_unlock(&np->lock);
+	return 0;
+}
+
+static int
+e100_ethtool_ioctl(struct net_device *dev, struct ifreq *ifr)
+{
+	struct ethtool_cmd ecmd;
+
+	if (copy_from_user(&ecmd, ifr->ifr_data, sizeof (ecmd)))
+		return -EFAULT;
+
+	switch (ecmd.cmd) {
+		case ETHTOOL_GSET:
+		{
+			memset((void *) &ecmd, 0, sizeof (ecmd));
+			ecmd.supported =
+			  SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII |
+			  SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
+			  SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full;
+			ecmd.port = PORT_TP;
+			ecmd.transceiver = XCVR_EXTERNAL;
+			ecmd.phy_address = mdio_phy_addr;
+			ecmd.speed = current_speed;
+			ecmd.duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
+			ecmd.advertising = ADVERTISED_TP;
+			if (current_duplex == autoneg && current_speed_selection == 0)
+				ecmd.advertising |= ADVERTISED_Autoneg;
+			else {
+				ecmd.advertising |=
+				  ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
+				  ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
+				if (current_speed_selection == 10)
+					ecmd.advertising &= ~(ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full);
+				else if (current_speed_selection == 100)
+					ecmd.advertising &= ~(ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full);
+				if (current_duplex == half)
+					ecmd.advertising &= ~(ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Full);
+				else if (current_duplex == full)
+					ecmd.advertising &= ~(ADVERTISED_10baseT_Half | ADVERTISED_100baseT_Half);
+			}
+			ecmd.autoneg = AUTONEG_ENABLE;
+			if (copy_to_user(ifr->ifr_data, &ecmd, sizeof (ecmd)))
+				return -EFAULT;
+		}
+		break;
+		case ETHTOOL_SSET:
+		{
+			if (!capable(CAP_NET_ADMIN)) {
+				return -EPERM;
+			}
+			if (ecmd.autoneg == AUTONEG_ENABLE) {
+				e100_set_duplex(dev, autoneg);
+				e100_set_speed(dev, 0);
+			} else {
+				e100_set_duplex(dev, ecmd.duplex == DUPLEX_HALF ? half : full);
+				e100_set_speed(dev, ecmd.speed == SPEED_10 ? 10: 100);
+			}
+		}
+		break;
+		case ETHTOOL_GDRVINFO:
+		{
+			struct ethtool_drvinfo info;
+			memset((void *) &info, 0, sizeof (info));
+			strncpy(info.driver, "ETRAX 100LX", sizeof(info.driver) - 1);
+			strncpy(info.version, "$Revision: 1.31 $", sizeof(info.version) - 1);
+			strncpy(info.fw_version, "N/A", sizeof(info.fw_version) - 1);
+			strncpy(info.bus_info, "N/A", sizeof(info.bus_info) - 1);
+			info.regdump_len = 0;
+			info.eedump_len = 0;
+			info.testinfo_len = 0;
+			if (copy_to_user(ifr->ifr_data, &info, sizeof (info)))
+				return -EFAULT;
+		}
+		break;
+		case ETHTOOL_NWAY_RST:
+			if (current_duplex == autoneg && current_speed_selection == 0)
+				e100_negotiate(dev);
+		break;
+		default:
+			return -EOPNOTSUPP;
+		break;
+	}
+	return 0;
+}
+
+static int
+e100_set_config(struct net_device *dev, struct ifmap *map)
+{
+	struct net_local *np = (struct net_local *)dev->priv;
+	spin_lock(&np->lock); /* Preempt protection */
+
+	switch(map->port) {
+		case IF_PORT_UNKNOWN:
+			/* Use autoneg */
+			e100_set_speed(dev, 0);
+			e100_set_duplex(dev, autoneg);
+			break;
+		case IF_PORT_10BASET:
+			e100_set_speed(dev, 10);
+			e100_set_duplex(dev, autoneg);
+			break;
+		case IF_PORT_100BASET:
+		case IF_PORT_100BASETX:
+			e100_set_speed(dev, 100);
+			e100_set_duplex(dev, autoneg);
+			break;
+		case IF_PORT_100BASEFX:
+		case IF_PORT_10BASE2:
+		case IF_PORT_AUI:
+			spin_unlock(&np->lock);
+			return -EOPNOTSUPP;
+			break;
+		default:
+			printk(KERN_ERR "%s: Invalid media selected", dev->name);
+			spin_unlock(&np->lock);
+			return -EINVAL;
+	}
+	spin_unlock(&np->lock);
+	return 0;
+}
+
+static void
+update_rx_stats(struct net_device_stats *es)
+{
+	unsigned long r = *R_REC_COUNTERS;
+	/* update stats relevant to reception errors */
+	es->rx_fifo_errors += IO_EXTRACT(R_REC_COUNTERS, congestion, r);
+	es->rx_crc_errors += IO_EXTRACT(R_REC_COUNTERS, crc_error, r);
+	es->rx_frame_errors += IO_EXTRACT(R_REC_COUNTERS, alignment_error, r);
+	es->rx_length_errors += IO_EXTRACT(R_REC_COUNTERS, oversize, r);
+}
+
+static void
+update_tx_stats(struct net_device_stats *es)
+{
+	unsigned long r = *R_TR_COUNTERS;
+	/* update stats relevant to transmission errors */
+	es->collisions +=
+		IO_EXTRACT(R_TR_COUNTERS, single_col, r) +
+		IO_EXTRACT(R_TR_COUNTERS, multiple_col, r);
+	es->tx_errors += IO_EXTRACT(R_TR_COUNTERS, deferred, r);
+}
+
+/*
+ * Get the current statistics.
+ * This may be called with the card open or closed.
+ */
+static struct net_device_stats *
+e100_get_stats(struct net_device *dev)
+{
+	struct net_local *lp = (struct net_local *)dev->priv;
+	unsigned long flags;
+	spin_lock_irqsave(&lp->lock, flags);
+
+	update_rx_stats(&lp->stats);
+	update_tx_stats(&lp->stats);
+
+	spin_unlock_irqrestore(&lp->lock, flags);
+	return &lp->stats;
+}
+
+/*
+ * Set or clear the multicast filter for this adaptor.
+ * num_addrs == -1	Promiscuous mode, receive all packets
+ * num_addrs == 0	Normal mode, clear multicast list
+ * num_addrs > 0	Multicast mode, receive normal and MC packets,
+ *			and do best-effort filtering.
+ */
+static void
+set_multicast_list(struct net_device *dev)
+{
+	struct net_local *lp = (struct net_local *)dev->priv;
+	int num_addr = dev->mc_count;
+	unsigned long int lo_bits;
+	unsigned long int hi_bits;
+	spin_lock(&lp->lock);
+	if (dev->flags & IFF_PROMISC)
+	{
+		/* promiscuous mode */
+		lo_bits = 0xfffffffful;
+		hi_bits = 0xfffffffful;
+
+		/* Enable individual receive */
+		SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, receive);
+		*R_NETWORK_REC_CONFIG = network_rec_config_shadow;
+	} else if (dev->flags & IFF_ALLMULTI) {
+		/* enable all multicasts */
+		lo_bits = 0xfffffffful;
+		hi_bits = 0xfffffffful;
+
+		/* Disable individual receive */
+		SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, discard);
+		*R_NETWORK_REC_CONFIG =  network_rec_config_shadow;
+	} else if (num_addr == 0) {
+		/* Normal, clear the mc list */
+		lo_bits = 0x00000000ul;
+		hi_bits = 0x00000000ul;
+
+		/* Disable individual receive */
+		SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, discard);
+		*R_NETWORK_REC_CONFIG =  network_rec_config_shadow;
+	} else {
+		/* MC mode, receive normal and MC packets */
+		char hash_ix;
+		struct dev_mc_list *dmi = dev->mc_list;
+		int i;
+		char *baddr;
+		lo_bits = 0x00000000ul;
+		hi_bits = 0x00000000ul;
+		for (i=0; i<num_addr; i++) {
+			/* Calculate the hash index for the GA registers */
+
+			hash_ix = 0;
+			baddr = dmi->dmi_addr;
+			hash_ix ^= (*baddr) & 0x3f;
+			hash_ix ^= ((*baddr) >> 6) & 0x03;
+			++baddr;
+			hash_ix ^= ((*baddr) << 2) & 0x03c;
+			hash_ix ^= ((*baddr) >> 4) & 0xf;
+			++baddr;
+			hash_ix ^= ((*baddr) << 4) & 0x30;
+			hash_ix ^= ((*baddr) >> 2) & 0x3f;
+			++baddr;
+			hash_ix ^= (*baddr) & 0x3f;
+			hash_ix ^= ((*baddr) >> 6) & 0x03;
+			++baddr;
+			hash_ix ^= ((*baddr) << 2) & 0x03c;
+			hash_ix ^= ((*baddr) >> 4) & 0xf;
+			++baddr;
+			hash_ix ^= ((*baddr) << 4) & 0x30;
+			hash_ix ^= ((*baddr) >> 2) & 0x3f;
+
+			hash_ix &= 0x3f;
+
+			if (hash_ix >= 32) {
+				hi_bits |= (1 << (hash_ix-32));
+			}
+			else {
+				lo_bits |= (1 << hash_ix);
+			}
+			dmi = dmi->next;
+		}
+		/* Disable individual receive */
+		SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, discard);
+		*R_NETWORK_REC_CONFIG = network_rec_config_shadow;
+	}
+	*R_NETWORK_GA_0 = lo_bits;
+	*R_NETWORK_GA_1 = hi_bits;
+	spin_unlock(&lp->lock);
+}
+
+void
+e100_hardware_send_packet(char *buf, int length)
+{
+	D(printk("e100 send pack, buf 0x%x len %d\n", buf, length));
+
+	if (!led_active && time_after(jiffies, led_next_time)) {
+		/* light the network leds depending on the current speed. */
+		e100_set_network_leds(NETWORK_ACTIVITY);
+
+		/* Set the earliest time we may clear the LED */
+		led_next_time = jiffies + NET_FLASH_TIME;
+		led_active = 1;
+		mod_timer(&clear_led_timer, jiffies + HZ/10);
+	}
+
+	/* configure the tx dma descriptor */
+	myNextTxDesc->descr.sw_len = length;
+	myNextTxDesc->descr.ctrl = d_eop | d_eol | d_wait;
+	myNextTxDesc->descr.buf = virt_to_phys(buf);
+
+        /* Move end of list */
+        myLastTxDesc->descr.ctrl &= ~d_eol;
+        myLastTxDesc = myNextTxDesc;
+
+	/* Restart DMA channel */
+	*R_DMA_CH0_CMD = IO_STATE(R_DMA_CH0_CMD, cmd, restart);
+}
+
+static void
+e100_clear_network_leds(unsigned long dummy)
+{
+	if (led_active && time_after(jiffies, led_next_time)) {
+		e100_set_network_leds(NO_NETWORK_ACTIVITY);
+
+		/* Set the earliest time we may set the LED */
+		led_next_time = jiffies + NET_FLASH_PAUSE;
+		led_active = 0;
+	}
+}
+
+static void
+e100_set_network_leds(int active)
+{
+#if defined(CONFIG_ETRAX_NETWORK_LED_ON_WHEN_LINK)
+	int light_leds = (active == NO_NETWORK_ACTIVITY);
+#elif defined(CONFIG_ETRAX_NETWORK_LED_ON_WHEN_ACTIVITY)
+	int light_leds = (active == NETWORK_ACTIVITY);
+#else
+#error "Define either CONFIG_ETRAX_NETWORK_LED_ON_WHEN_LINK or CONFIG_ETRAX_NETWORK_LED_ON_WHEN_ACTIVITY"
+#endif
+
+	if (!current_speed) {
+		/* Make LED red, link is down */
+#if defined(CONFIG_ETRAX_NETWORK_RED_ON_NO_CONNECTION)
+		LED_NETWORK_SET(LED_RED);
+#else
+		LED_NETWORK_SET(LED_OFF);
+#endif
+	}
+	else if (light_leds) {
+		if (current_speed == 10) {
+			LED_NETWORK_SET(LED_ORANGE);
+		} else {
+			LED_NETWORK_SET(LED_GREEN);
+		}
+	}
+	else {
+		LED_NETWORK_SET(LED_OFF);
+	}
+}
+
+static int
+etrax_init_module(void)
+{
+	return etrax_ethernet_init();
+}
+
+static int __init
+e100_boot_setup(char* str)
+{
+	struct sockaddr sa = {0};
+	int i;
+
+	/* Parse the colon separated Ethernet station address */
+	for (i = 0; i <  ETH_ALEN; i++) {
+		unsigned int tmp;
+		if (sscanf(str + 3*i, "%2x", &tmp) != 1) {
+			printk(KERN_WARNING "Malformed station address");
+			return 0;
+		}
+		sa.sa_data[i] = (char)tmp;
+	}
+
+	default_mac = sa;
+	return 1;
+}
+
+__setup("etrax100_eth=", e100_boot_setup);
+
+module_init(etrax_init_module);
diff -Nru a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
--- a/drivers/net/cs89x0.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/cs89x0.c	2004-12-24 13:37:18 -08:00
@@ -135,9 +135,9 @@
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #if ALLOW_DMA
 #include <asm/dma.h>
diff -Nru a/drivers/net/declance.c b/drivers/net/declance.c
--- a/drivers/net/declance.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/declance.c	2004-12-24 13:37:43 -08:00
@@ -812,12 +812,6 @@
 	}
 
 	status = init_restart_lance(lp);
-
-	/*
-	 * if (!status)
-	 *      MOD_INC_USE_COUNT;
-	 */
-
 	return status;
 }
 
@@ -849,9 +843,6 @@
 		free_irq(lp->dma_irq, dev);
 	}
 	free_irq(dev->irq, dev);
-	/*
-	   MOD_DEC_USE_COUNT;
-	 */
 	return 0;
 }
 
diff -Nru a/drivers/net/defxx.c b/drivers/net/defxx.c
--- a/drivers/net/defxx.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/defxx.c	2004-12-24 13:36:16 -08:00
@@ -19,7 +19,7 @@
  *   LVS	Lawrence V. Stefani <lstefani@yahoo.com>
  *
  * Maintainers:
- *   macro	Maciej W. Rozycki <macro@ds2.pg.gda.pl>
+ *   macro	Maciej W. Rozycki <macro@linux-mips.org>
  *
  * Credits:
  *   I'd like to thank Patricia Cross for helping me get started with
@@ -190,6 +190,7 @@
  *		Feb 2001			Skb allocation fixes
  *		Feb 2001	davej		PCI enable cleanups.
  *		04 Aug 2003	macro		Converted to the DMA API.
+ *		14 Aug 2004	macro		Fix device names reported.
  */
 
 /* Include files */
@@ -207,19 +208,21 @@
 #include <linux/netdevice.h>
 #include <linux/fddidevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include "defxx.h"
 
-/* Version information string - should be updated prior to each new release!!! */
+/* Version information string should be updated prior to each new release!  */
+#define DRV_NAME "defxx"
+#define DRV_VERSION "v1.07"
+#define DRV_RELDATE "2004/08/14"
 
 static char version[] __devinitdata =
-	"defxx.c:v1.06 2003/08/04  Lawrence V. Stefani and others\n";
-
-#define DRV_NAME "defxx"
+	DRV_NAME ": " DRV_VERSION " " DRV_RELDATE
+	"  Lawrence V. Stefani and others\n";
 
 #define DYNAMIC_BUFFERS 1
 
@@ -235,7 +238,7 @@
 static void		dfx_bus_init(struct net_device *dev);
 static void		dfx_bus_config_check(DFX_board_t *bp);
 
-static int		dfx_driver_init(struct net_device *dev);
+static int		dfx_driver_init(struct net_device *dev, const char *print_name);
 static int		dfx_adap_init(DFX_board_t *bp, int get_buffers);
 
 static int		dfx_open(struct net_device *dev);
@@ -404,24 +407,25 @@
  */
 static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
 {
+	static int version_disp;
+	char *print_name = DRV_NAME;
 	struct net_device *dev;
 	DFX_board_t	  *bp;			/* board pointer */
 	int alloc_size;				/* total buffer size used */
 	int err;
 
-#ifndef MODULE
-	static int version_disp;
-
-	if (!version_disp)	/* display version info if adapter is found */
-	{
+	if (!version_disp) {	/* display version info if adapter is found */
 		version_disp = 1;	/* set display flag to TRUE so that */
 		printk(version);	/* we only display this string ONCE */
 	}
-#endif
+
+	if (pdev != NULL)
+		print_name = pdev->slot_name;
 
 	dev = alloc_fddidev(sizeof(*bp));
 	if (!dev) {
-		printk (KERN_ERR "defxx: unable to allocate fddidev, aborting\n");
+		printk(KERN_ERR "%s: unable to allocate fddidev, aborting\n",
+		       print_name);
 		return -ENOMEM;
 	}
 
@@ -437,9 +441,12 @@
 
 	bp = dev->priv;
 
-	if (!request_region (ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, DRV_NAME)) {
-		printk (KERN_ERR "%s: Cannot reserve I/O resource 0x%x @ 0x%lx, aborting\n",
-			DRV_NAME, PFI_K_CSR_IO_LEN, ioaddr);
+	if (!request_region(ioaddr,
+			    pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN,
+			    print_name)) {
+		printk(KERN_ERR "%s: Cannot reserve I/O resource "
+		       "0x%x @ 0x%lx, aborting\n", print_name,
+		       pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, ioaddr);
 		err = -EBUSY;
 		goto err_out;
 	}
@@ -468,7 +475,7 @@
 		pci_set_master (pdev);
 	}
 
-	if (dfx_driver_init(dev) != DFX_K_SUCCESS) {
+	if (dfx_driver_init(dev, print_name) != DFX_K_SUCCESS) {
 		err = -ENODEV;
 		goto err_out_region;
 	}
@@ -477,6 +484,7 @@
 	if (err)
 		goto err_out_kfree;
 
+	printk("%s: registered as %s\n", print_name, dev->name);
 	return 0;
 
 err_out_kfree:
@@ -770,6 +778,7 @@
  *       
  * Arguments:
  *   dev - pointer to device information
+ *   print_name - printable device name
  *
  * Functional Description:
  *   This function allocates additional resources such as the host memory
@@ -792,7 +801,8 @@
  *   returning from this routine.
  */
 
-static int __devinit dfx_driver_init(struct net_device *dev)
+static int __devinit dfx_driver_init(struct net_device *dev,
+				     const char *print_name)
 {
 	DFX_board_t *bp = dev->priv;
 	int			alloc_size;			/* total buffer size needed */
@@ -841,26 +851,20 @@
 
 	/*  Read the factory MAC address from the adapter then save it */
 
-	if (dfx_hw_port_ctrl_req(bp,
-							PI_PCTRL_M_MLA,
-							PI_PDATA_A_MLA_K_LO,
-							0,
-							&data) != DFX_K_SUCCESS)
-		{
-		printk("%s: Could not read adapter factory MAC address!\n", dev->name);
+	if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_LO, 0,
+				 &data) != DFX_K_SUCCESS) {
+		printk("%s: Could not read adapter factory MAC address!\n",
+		       print_name);
 		return(DFX_K_FAILURE);
-		}
+	}
 	memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32));
 
-	if (dfx_hw_port_ctrl_req(bp,
-							PI_PCTRL_M_MLA,
-							PI_PDATA_A_MLA_K_HI,
-							0,
-							&data) != DFX_K_SUCCESS)
-		{
-		printk("%s: Could not read adapter factory MAC address!\n", dev->name);
+	if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0,
+				 &data) != DFX_K_SUCCESS) {
+		printk("%s: Could not read adapter factory MAC address!\n",
+		       print_name);
 		return(DFX_K_FAILURE);
-		}
+	}
 	memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16));
 
 	/*
@@ -872,27 +876,19 @@
 
 	memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
 	if (bp->bus_type == DFX_BUS_TYPE_EISA)
-		printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
-				dev->name,
-				dev->base_addr,
-				dev->irq,
-				dev->dev_addr[0],
-				dev->dev_addr[1],
-				dev->dev_addr[2],
-				dev->dev_addr[3],
-				dev->dev_addr[4],
-				dev->dev_addr[5]);
+		printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, "
+		       "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
+		       print_name, dev->base_addr, dev->irq,
+		       dev->dev_addr[0], dev->dev_addr[1],
+		       dev->dev_addr[2], dev->dev_addr[3],
+		       dev->dev_addr[4], dev->dev_addr[5]);
 	else
-		printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
-				dev->name,
-				dev->base_addr,
-				dev->irq,
-				dev->dev_addr[0],
-				dev->dev_addr[1],
-				dev->dev_addr[2],
-				dev->dev_addr[3],
-				dev->dev_addr[4],
-				dev->dev_addr[5]);
+		printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, "
+		       "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
+		       print_name, dev->base_addr, dev->irq,
+		       dev->dev_addr[0], dev->dev_addr[1],
+		       dev->dev_addr[2], dev->dev_addr[3],
+		       dev->dev_addr[4], dev->dev_addr[5]);
 
 	/*
 	 * Get memory for descriptor block, consumer block, and other buffers
@@ -909,11 +905,11 @@
 					(PI_ALIGN_K_DESC_BLK - 1);
 	bp->kmalloced = top_v = pci_alloc_consistent(bp->pci_dev, alloc_size,
 						     &bp->kmalloced_dma);
-	if (top_v == NULL)
-		{
-		printk("%s: Could not allocate memory for host buffers and structures!\n", dev->name);
+	if (top_v == NULL) {
+		printk("%s: Could not allocate memory for host buffers "
+		       "and structures!\n", print_name);
 		return(DFX_K_FAILURE);
-		}
+	}
 	memset(top_v, 0, alloc_size);	/* zero out memory before continuing */
 	top_p = bp->kmalloced_dma;	/* get physical address of buffer */
 
@@ -970,14 +966,20 @@
 
 	/* Display virtual and physical addresses if debug driver */
 
-	DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n",				dev->name, (long)bp->descr_block_virt,	bp->descr_block_phys);
-	DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n",			dev->name, (long)bp->cmd_req_virt,		bp->cmd_req_phys);
-	DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n",			dev->name, (long)bp->cmd_rsp_virt,		bp->cmd_rsp_phys);
-	DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n",			dev->name, (long)bp->rcv_block_virt,	bp->rcv_block_phys);
-	DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n",				dev->name, (long)bp->cons_block_virt,	bp->cons_block_phys);
+	DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n",
+		   print_name,
+		   (long)bp->descr_block_virt, bp->descr_block_phys);
+	DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n",
+		   print_name, (long)bp->cmd_req_virt, bp->cmd_req_phys);
+	DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n",
+		   print_name, (long)bp->cmd_rsp_virt, bp->cmd_rsp_phys);
+	DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n",
+		   print_name, (long)bp->rcv_block_virt, bp->rcv_block_phys);
+	DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n",
+		   print_name, (long)bp->cons_block_virt, bp->cons_block_phys);
 
 	return(DFX_K_SUCCESS);
-	}
+}
 
 
 /*
@@ -2668,12 +2670,12 @@
  
 static void my_skb_align(struct sk_buff *skb, int n)
 {
-	unsigned long x=(unsigned long)skb->data;	
+	unsigned long x = (unsigned long)skb->data;
 	unsigned long v;
 	
-	v=(x+n-1)&~(n-1);	/* Where we want to be */
+	v = ALIGN(x, n);	/* Where we want to be */
 	
-	skb_reserve(skb, v-x);
+	skb_reserve(skb, v - x);
 }
 
 
@@ -3428,11 +3430,6 @@
 {
 	int rc_pci, rc_eisa;
 
-/* when a module, this is printed whether or not devices are found in probe */
-#ifdef MODULE
-	printk(version);
-#endif
-
 	rc_pci = pci_module_init(&dfx_driver);
 	if (rc_pci >= 0) dfx_have_pci = 1;
 	
@@ -3453,6 +3450,9 @@
 
 module_init(dfx_init);
 module_exit(dfx_cleanup);
+MODULE_AUTHOR("Lawrence V. Stefani");
+MODULE_DESCRIPTION("DEC FDDIcontroller EISA/PCI (DEFEA/DEFPA) driver "
+		   DRV_VERSION " " DRV_RELDATE);
 MODULE_LICENSE("GPL");
 
 
diff -Nru a/drivers/net/defxx.h b/drivers/net/defxx.h
--- a/drivers/net/defxx.h	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/defxx.h	2004-12-24 13:36:55 -08:00
@@ -16,7 +16,7 @@
  *   LVS	Lawrence V. Stefani <lstefani@yahoo.com>
  *
  * Maintainers:
- *   macro	Maciej W. Rozycki <macro@ds2.pg.gda.pl>
+ *   macro	Maciej W. Rozycki <macro@linux-mips.org>
  *
  * Modification History:
  *		Date		Name	Description
diff -Nru a/drivers/net/depca.c b/drivers/net/depca.c
--- a/drivers/net/depca.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/depca.c	2004-12-24 13:36:55 -08:00
@@ -255,9 +255,9 @@
 #include <linux/ctype.h>
 #include <linux/moduleparam.h>
 #include <linux/device.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
@@ -666,7 +666,7 @@
 		outb(nicsr, DEPCA_NICSR);
 	}
 
-	lp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&lp->lock);
 	sprintf(lp->adapter_name, "%s (%s)",
 		depca_signature[lp->adapter], device->bus_id);
 	status = -EBUSY;
@@ -1222,10 +1222,10 @@
 		/* clear IDON by writing a "1", enable interrupts and start lance */
 		outw(IDON | INEA | STRT, DEPCA_DATA);
 		if (depca_debug > 2) {
-			printk("%s: DEPCA open after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, virt_to_phys(lp->sh_mem), inw(DEPCA_DATA));
+			printk("%s: DEPCA open after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, lp->mem_start, inw(DEPCA_DATA));
 		}
 	} else {
-		printk("%s: DEPCA unopen after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, virt_to_phys(lp->sh_mem), inw(DEPCA_DATA));
+		printk("%s: DEPCA unopen after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, lp->mem_start, inw(DEPCA_DATA));
 		status = -1;
 	}
 
@@ -1901,7 +1901,7 @@
 			}
 		}
 		printk("...0x%8.8x\n", readl(&lp->tx_ring[i].base));
-		printk("Initialisation block at 0x%8.8lx(Phys)\n", virt_to_phys(lp->sh_mem));
+		printk("Initialisation block at 0x%8.8lx(Phys)\n", lp->mem_start);
 		printk("        mode: 0x%4.4x\n", p->mode);
 		printk("        physical address: ");
 		for (i = 0; i < ETH_ALEN - 1; i++) {
@@ -1915,7 +1915,7 @@
 		printk("%2.2x\n", p->mcast_table[i]);
 		printk("        rx_ring at: 0x%8.8x\n", p->rx_ring);
 		printk("        tx_ring at: 0x%8.8x\n", p->tx_ring);
-		printk("buffers (Phys): 0x%8.8lx\n", virt_to_phys(lp->sh_mem) + lp->buffs_offset);
+		printk("buffers (Phys): 0x%8.8lx\n", lp->mem_start + lp->buffs_offset);
 		printk("Ring size:\nRX: %d  Log2(rxRingMask): 0x%8.8x\n", (int) lp->rxRingMask + 1, lp->rx_rlen);
 		printk("TX: %d  Log2(txRingMask): 0x%8.8x\n", (int) lp->txRingMask + 1, lp->tx_rlen);
 		outw(CSR2, DEPCA_ADDR);
diff -Nru a/drivers/net/dgrs.c b/drivers/net/dgrs.c
--- a/drivers/net/dgrs.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/dgrs.c	2004-12-24 13:36:17 -08:00
@@ -97,8 +97,8 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
@@ -1597,10 +1597,10 @@
 #endif
 #ifdef CONFIG_PCI
 	pcicount = pci_register_driver(&dgrs_pci_driver);
-	if (pcicount < 0)
+	if (pcicount)
 		return pcicount;
 #endif
-	return (eisacount + pcicount) == 0 ? -ENODEV : 0;
+	return 0;
 }
 
 static void __exit dgrs_cleanup_module (void)
diff -Nru a/drivers/net/dl2k.c b/drivers/net/dl2k.c
--- a/drivers/net/dl2k.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/dl2k.c	2004-12-24 13:36:48 -08:00
@@ -107,7 +107,6 @@
 static void set_multicast (struct net_device *dev);
 static struct net_device_stats *get_stats (struct net_device *dev);
 static int clear_stats (struct net_device *dev);
-static int rio_ethtool_ioctl (struct net_device *dev, void __user *useraddr);
 static int rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
 static int rio_close (struct net_device *dev);
 static int find_miiphy (struct net_device *dev);
@@ -122,6 +121,8 @@
 static int mii_write (struct net_device *dev, int phy_addr, int reg_num,
 		      u16 data);
 
+static struct ethtool_ops ethtool_ops;
+
 static int __devinit
 rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
@@ -168,7 +169,7 @@
 #endif
 	dev->base_addr = ioaddr;
 	dev->irq = irq;
-	np = dev->priv;
+	np = netdev_priv(dev);
 	np->chip_id = chip_idx;
 	np->pdev = pdev;
 	spin_lock_init (&np->tx_lock);
@@ -244,6 +245,7 @@
 	dev->tx_timeout = &rio_tx_timeout;
 	dev->watchdog_timeo = TX_TIMEOUT;
 	dev->change_mtu = &change_mtu;
+	SET_ETHTOOL_OPS(dev, &ethtool_ops);
 #if 0
 	dev->features = NETIF_F_IP_CSUM;
 #endif
@@ -335,7 +337,7 @@
 	int i, phy_found = 0;
 	struct netdev_private *np;
 	long ioaddr;
-	np = dev->priv;
+	np = netdev_priv(dev);
 	ioaddr = dev->base_addr;
 	np->phy_addr = 1;
 
@@ -362,7 +364,7 @@
 	u8 *psib;
 	u32 crc;
 	PSROM_t psrom = (PSROM_t) sromdata;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	int cid, next;
 
@@ -432,7 +434,7 @@
 static int
 rio_open (struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int i;
 	u16 macctrl;
@@ -516,7 +518,7 @@
 rio_timer (unsigned long data)
 {
 	struct net_device *dev = (struct net_device *)data;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	unsigned int entry;
 	int next_tick = 1*HZ;
 	unsigned long flags;
@@ -574,7 +576,7 @@
 static void
 alloc_list (struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int i;
 
 	np->cur_rx = np->cur_tx = 0;
@@ -631,7 +633,7 @@
 static int
 start_xmit (struct sk_buff *skb, struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	struct netdev_desc *txdesc;
 	unsigned entry;
 	u32 ioaddr;
@@ -711,7 +713,7 @@
 	int handled = 0;
 
 	ioaddr = dev->base_addr;
-	np = dev->priv;
+	np = netdev_priv(dev);
 	while (1) {
 		int_status = readw (ioaddr + IntStatus); 
 		writew (int_status, ioaddr + IntStatus);
@@ -745,7 +747,7 @@
 static void 
 rio_free_tx (struct net_device *dev, int irq) 
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int entry = np->old_tx % TX_RING_SIZE;
 	int tx_use = 0;
 	unsigned long flag = 0;
@@ -798,7 +800,7 @@
 	int frame_id;
 	int i;
 
-	np = dev->priv;
+	np = netdev_priv(dev);
 
 	frame_id = (tx_status & 0xffff0000);
 	printk (KERN_ERR "%s: Transmit error, TxStatus %4.4x, FrameId %d.\n",
@@ -855,7 +857,7 @@
 static int
 receive_packet (struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int entry = np->cur_rx % RX_RING_SIZE;
 	int cnt = 30;
 
@@ -965,7 +967,7 @@
 rio_error (struct net_device *dev, int int_status)
 {
 	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	u16 macctrl;
 
 	/* Link change event */
@@ -1016,7 +1018,7 @@
 get_stats (struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 #ifdef MEM_MAPPING
 	int i;
 #endif
@@ -1132,7 +1134,7 @@
 int
 change_mtu (struct net_device *dev, int new_mtu)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int max = (np->jumbo) ? MAX_JUMBO : 1536;
 
 	if ((new_mtu < 68) || (new_mtu > max)) {
@@ -1150,7 +1152,7 @@
 	long ioaddr = dev->base_addr;
 	u32 hash_table[2];
 	u16 rx_mode = 0;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	
 	hash_table[0] = hash_table[1] = 0;
 	/* RxFlowcontrol DA: 01-80-C2-00-00-01. Hash index=0x39 */
@@ -1194,137 +1196,118 @@
 	writew (rx_mode, ioaddr + ReceiveMode);
 }
 
-static int
-rio_ethtool_ioctl (struct net_device *dev, void __user *useraddr)
+static void rio_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	strcpy(info->driver, "DL2K");
+	strcpy(info->version, DRV_VERSION);
+	strcpy(info->bus_info, pci_name(np->pdev));
+}	
+
+static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-	struct netdev_private *np = dev->priv;
-       	u32 ethcmd;
+	struct netdev_private *np = netdev_priv(dev);
+	if (np->phy_media) {
+		/* fiber device */
+		cmd->supported = SUPPORTED_Autoneg | SUPPORTED_FIBRE;
+		cmd->advertising= ADVERTISED_Autoneg | ADVERTISED_FIBRE;
+		cmd->port = PORT_FIBRE;
+		cmd->transceiver = XCVR_INTERNAL;	
+	} else {
+		/* copper device */
+		cmd->supported = SUPPORTED_10baseT_Half | 
+			SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half
+			| SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full |
+			SUPPORTED_Autoneg | SUPPORTED_MII;
+		cmd->advertising = ADVERTISED_10baseT_Half |
+			ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Half |
+			ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full|
+			ADVERTISED_Autoneg | ADVERTISED_MII;
+		cmd->port = PORT_MII;
+		cmd->transceiver = XCVR_INTERNAL;
+	}
+	if ( np->link_status ) { 
+		cmd->speed = np->speed;
+		cmd->duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
+	} else {
+		cmd->speed = -1;
+		cmd->duplex = -1;
+	}
+	if ( np->an_enable)
+		cmd->autoneg = AUTONEG_ENABLE;
+	else
+		cmd->autoneg = AUTONEG_DISABLE;
 	
-	if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
-		return -EFAULT;
-	switch (ethcmd) {
-		case ETHTOOL_GDRVINFO: {
-			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-			strcpy(info.driver, "DL2K");
-			strcpy(info.version, DRV_VERSION);
-			strcpy(info.bus_info, pci_name(np->pdev));
-			memset(&info.fw_version, 0, sizeof(info.fw_version));
-			if (copy_to_user(useraddr, &info, sizeof(info)))
-				return -EFAULT;
+	cmd->phy_address = np->phy_addr;
+	return 0;				   
+}
+
+static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	netif_carrier_off(dev);
+	if (cmd->autoneg == AUTONEG_ENABLE) {
+		if (np->an_enable)
 			return 0;
+		else {
+			np->an_enable = 1;
+			mii_set_media(dev);
+			return 0;	
 		}	
- 	
-		case ETHTOOL_GSET: {
-			struct ethtool_cmd cmd = { ETHTOOL_GSET };
-			if (np->phy_media) {
-				/* fiber device */
-				cmd.supported = SUPPORTED_Autoneg | 
-							SUPPORTED_FIBRE;
-				cmd.advertising= ADVERTISED_Autoneg |
-							ADVERTISED_FIBRE;
-				cmd.port = PORT_FIBRE;
-				cmd.transceiver = XCVR_INTERNAL;	
-			} else {
-				/* copper device */
-				cmd.supported = SUPPORTED_10baseT_Half | 
-					SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half
-					| SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full |
-					SUPPORTED_Autoneg | SUPPORTED_MII;
-				cmd.advertising = ADVERTISED_10baseT_Half |
-					ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Half |
-					ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full|
-					ADVERTISED_Autoneg | ADVERTISED_MII;
-				cmd.port = PORT_MII;
-				cmd.transceiver = XCVR_INTERNAL;
-			}
-			if ( np->link_status ) { 
-				cmd.speed = np->speed;
-				cmd.duplex = np->full_duplex ? 
-						    DUPLEX_FULL : DUPLEX_HALF;
-			} else {
-				cmd.speed = -1;
-				cmd.duplex = -1;
-			}
-			if ( np->an_enable)
-				cmd.autoneg = AUTONEG_ENABLE;
-			else
-				cmd.autoneg = AUTONEG_DISABLE;
-			
-			cmd.phy_address = np->phy_addr;
-
-			if (copy_to_user(useraddr, &cmd,
-					sizeof(cmd)))
-				return -EFAULT;
-			return 0;				   
-		}
-		case ETHTOOL_SSET: {
-			struct ethtool_cmd cmd;
-			if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
-				return -EFAULT;
-			netif_carrier_off(dev);
-			if (cmd.autoneg == AUTONEG_ENABLE) {
-				if (np->an_enable)
-					return 0;
-				else {
-					np->an_enable = 1;
-					mii_set_media(dev);
-					return 0;	
-				}	
-			} else {
-				np->an_enable = 0;
-				if (np->speed == 1000){
-					cmd.speed = SPEED_100;			
-					cmd.duplex = DUPLEX_FULL;
-					printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manul 100Mbps, Full duplex.\n");
-					}
-				switch(cmd.speed + cmd.duplex){
-				
-				case SPEED_10 + DUPLEX_HALF:
-					np->speed = 10;
-					np->full_duplex = 0;
-					break;
-				
-				case SPEED_10 + DUPLEX_FULL:
-					np->speed = 10;
-					np->full_duplex = 1;
-					break;
-				case SPEED_100 + DUPLEX_HALF:
-					np->speed = 100;
-					np->full_duplex = 0;
-					break;
-				case SPEED_100 + DUPLEX_FULL:
-					np->speed = 100;
-					np->full_duplex = 1;
-					break;
-				case SPEED_1000 + DUPLEX_HALF:/* not supported */
-				case SPEED_1000 + DUPLEX_FULL:/* not supported */
-				default:
-					return -EINVAL;	
-				}
-				mii_set_media(dev);
-			}
-		return 0;		   
+	} else {
+		np->an_enable = 0;
+		if (np->speed == 1000) {
+			cmd->speed = SPEED_100;			
+			cmd->duplex = DUPLEX_FULL;
+			printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n");
 		}
-#ifdef ETHTOOL_GLINK		
-		case ETHTOOL_GLINK:{
-		struct ethtool_value link = { ETHTOOL_GLINK };
-		link.data = np->link_status;
-		if (copy_to_user(useraddr, &link, sizeof(link)))
-			return -EFAULT;
-		return 0;
-		}			   
-#endif
+		switch(cmd->speed + cmd->duplex) {
+		
+		case SPEED_10 + DUPLEX_HALF:
+			np->speed = 10;
+			np->full_duplex = 0;
+			break;
+		
+		case SPEED_10 + DUPLEX_FULL:
+			np->speed = 10;
+			np->full_duplex = 1;
+			break;
+		case SPEED_100 + DUPLEX_HALF:
+			np->speed = 100;
+			np->full_duplex = 0;
+			break;
+		case SPEED_100 + DUPLEX_FULL:
+			np->speed = 100;
+			np->full_duplex = 1;
+			break;
+		case SPEED_1000 + DUPLEX_HALF:/* not supported */
+		case SPEED_1000 + DUPLEX_FULL:/* not supported */
 		default:
-		return -EOPNOTSUPP;
-	}	
+			return -EINVAL;	
+		}
+		mii_set_media(dev);
+	}
+	return 0;
+}
+
+static u32 rio_get_link(struct net_device *dev)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	return np->link_status;
 }
 
+static struct ethtool_ops ethtool_ops = {
+	.get_drvinfo = rio_get_drvinfo,
+	.get_settings = rio_get_settings,
+	.set_settings = rio_set_settings,
+	.get_link = rio_get_link,
+};
 
 static int
 rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
 {
 	int phy_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	struct mii_data *miidata = (struct mii_data *) &rq->ifr_ifru;
 	
 	struct netdev_desc *desc;
@@ -1332,8 +1315,6 @@
 
 	phy_addr = np->phy_addr;
 	switch (cmd) {
-	case SIOCETHTOOL:
-		return rio_ethtool_ioctl(dev, rq->ifr_data);		
 	case SIOCDEVPRIVATE:
 		break;
 	
@@ -1490,7 +1471,7 @@
 	int phy_addr;
 	struct netdev_private *np;
 
-	np = dev->priv;
+	np = netdev_priv(dev);
 	phy_addr = np->phy_addr;
 
 	do {
@@ -1512,7 +1493,7 @@
 	int phy_addr;
 	struct netdev_private *np;
 
-	np = dev->priv;
+	np = netdev_priv(dev);
 	phy_addr = np->phy_addr;
 
 	bmsr.image = mii_read (dev, phy_addr, MII_BMSR);
@@ -1594,7 +1575,7 @@
 	ANAR_t anar;
 	int phy_addr;
 	struct netdev_private *np;
-	np = dev->priv;
+	np = netdev_priv(dev);
 	phy_addr = np->phy_addr;
 
 	/* Does user set speed? */
@@ -1684,7 +1665,7 @@
 	int phy_addr;
 	struct netdev_private *np;
 
-	np = dev->priv;
+	np = netdev_priv(dev);
 	phy_addr = np->phy_addr;
 
 	bmsr.image = mii_read (dev, phy_addr, PCS_BMSR);
@@ -1740,7 +1721,7 @@
 	ANAR_PCS_t anar;
 	int phy_addr;
 	struct netdev_private *np;
-	np = dev->priv;
+	np = netdev_priv(dev);
 	phy_addr = np->phy_addr;
 
 	/* Auto-Negotiation? */
@@ -1794,7 +1775,7 @@
 rio_close (struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	struct sk_buff *skb;
 	int i;
 
@@ -1840,7 +1821,7 @@
 	struct net_device *dev = pci_get_drvdata (pdev);
 
 	if (dev) {
-		struct netdev_private *np = dev->priv;
+		struct netdev_private *np = netdev_priv(dev);
 
 		unregister_netdev (dev);
 		pci_free_consistent (pdev, RX_TOTAL_SIZE, np->rx_ring,
diff -Nru a/drivers/net/dl2k.h b/drivers/net/dl2k.h
--- a/drivers/net/dl2k.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/dl2k.h	2004-12-24 13:37:19 -08:00
@@ -28,8 +28,8 @@
 #include <linux/init.h>
 #include <linux/crc32.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 #include <asm/processor.h>	/* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <linux/delay.h>
diff -Nru a/drivers/net/dummy.c b/drivers/net/dummy.c
--- a/drivers/net/dummy.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/dummy.c	2004-12-24 13:36:48 -08:00
@@ -77,7 +77,7 @@
 
 static int dummy_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct net_device_stats *stats = dev->priv;
+	struct net_device_stats *stats = netdev_priv(dev);
 
 	stats->tx_packets++;
 	stats->tx_bytes+=skb->len;
@@ -88,7 +88,7 @@
 
 static struct net_device_stats *dummy_get_stats(struct net_device *dev)
 {
-	return dev->priv;
+	return netdev_priv(dev);
 }
 
 static struct net_device **dummies;
diff -Nru a/drivers/net/e100.c b/drivers/net/e100.c
--- a/drivers/net/e100.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/net/e100.c	2004-12-24 13:37:31 -08:00
@@ -154,8 +154,8 @@
 
 
 #define DRV_NAME		"e100"
-#define DRV_EXT			"-NAPI"
-#define DRV_VERSION		"3.0.27-k2"DRV_EXT
+#define DRV_EXT		"-NAPI"
+#define DRV_VERSION		"3.2.3-k2"DRV_EXT
 #define DRV_DESCRIPTION		"Intel(R) PRO/100 Network Driver"
 #define DRV_COPYRIGHT		"Copyright(c) 1999-2004 Intel Corporation"
 #define PFX			DRV_NAME ": "
@@ -513,7 +513,7 @@
 
 	spinlock_t cb_lock			____cacheline_aligned;
 	spinlock_t cmd_lock;
-	struct csr *csr;
+	struct csr __iomem *csr;
 	enum scb_cmd_lo cuc_cmd;
 	unsigned int cbs_avail;
 	struct cb *cbs;
@@ -563,7 +563,6 @@
 	u16 leds;
 	u16 eeprom_wc;
 	u16 eeprom[256];
-	u32 pm_state[16];
 };
 
 static inline void e100_write_flush(struct nic *nic)
@@ -575,13 +574,21 @@
 
 static inline void e100_enable_irq(struct nic *nic)
 {
+	unsigned long flags;
+
+	spin_lock_irqsave(&nic->cmd_lock, flags);
 	writeb(irq_mask_none, &nic->csr->scb.cmd_hi);
+	spin_unlock_irqrestore(&nic->cmd_lock, flags);
 	e100_write_flush(nic);
 }
 
 static inline void e100_disable_irq(struct nic *nic)
 {
+	unsigned long flags;
+
+	spin_lock_irqsave(&nic->cmd_lock, flags);
 	writeb(irq_mask_all, &nic->csr->scb.cmd_hi);
+	spin_unlock_irqrestore(&nic->cmd_lock, flags);
 	e100_write_flush(nic);
 }
 
@@ -596,16 +603,6 @@
 	writel(software_reset, &nic->csr->port);
 	e100_write_flush(nic); udelay(20);
 
-	/* TCO workaround - 82559 and greater */
-	if(nic->mac >= mac_82559_D101M) {
-		/* Issue a redundant CU load base without setting
-		 * general pointer, and without waiting for scb to
-		 * clear.  This gets us into post-driver.  Finally,
-		 * wait 20 msec for reset to take effect. */
-		writeb(cuc_load_base, &nic->csr->scb.cmd_lo);
-		mdelay(20);
-	}
-
 	/* Mask off our interrupt line - it's unmasked after reset */
 	e100_disable_irq(nic);
 }
@@ -1254,8 +1251,13 @@
 	mii_check_link(&nic->mii);
 
 	/* Software generated interrupt to recover from (rare) Rx
-	 * allocation failure */
-	writeb(irq_sw_gen, &nic->csr->scb.cmd_hi);
+	* allocation failure.
+	* Unfortunately have to use a spinlock to not re-enable interrupts
+	* accidentally, due to hardware that shares a register between the
+	* interrupt mask bit and the SW Interrupt generation bit */
+	spin_lock_irq(&nic->cmd_lock);
+	writeb(readb(&nic->csr->scb.cmd_hi) | irq_sw_gen,&nic->csr->scb.cmd_hi);
+	spin_unlock_irq(&nic->cmd_lock);
 	e100_write_flush(nic);
 
 	e100_update_stats(nic);
@@ -1305,6 +1307,7 @@
 	switch(err) {
 	case -ENOSPC:
 		/* We queued the skb, but now we're out of space. */
+		DPRINTK(TX_ERR, DEBUG, "No space for CB\n");
 		netif_stop_queue(netdev);
 		break;
 	case -ENOMEM:
@@ -1425,14 +1428,12 @@
 #define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN)
 static inline int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
 {
-	unsigned int rx_offset = 2; /* u32 align protocol headers */
-
-	if(!(rx->skb = dev_alloc_skb(RFD_BUF_LEN + rx_offset)))
+	if(!(rx->skb = dev_alloc_skb(RFD_BUF_LEN + NET_IP_ALIGN)))
 		return -ENOMEM;
 
 	/* Align, init, and map the RFD. */
 	rx->skb->dev = nic->netdev;
-	skb_reserve(rx->skb, rx_offset);
+	skb_reserve(rx->skb, NET_IP_ALIGN);
 	memcpy(rx->skb->data, &nic->blank_rfd, sizeof(struct rfd));
 	rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data,
 		RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
@@ -1471,7 +1472,7 @@
 
 	/* If data isn't ready, nothing to indicate */
 	if(unlikely(!(rfd_status & cb_complete)))
-       		return -EAGAIN;
+		return -EAGAIN;
 
 	/* Get actual data size */
 	actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;
@@ -1763,7 +1764,7 @@
 
 	if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd),
 	   skb->data, ETH_DATA_LEN))
-       		err = -EAGAIN;
+		err = -EAGAIN;
 
 err_loopback_none:
 	mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 0);
@@ -1956,12 +1957,17 @@
 	struct param_range *rfds = &nic->params.rfds;
 	struct param_range *cbs = &nic->params.cbs;
 
+	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 
+		return -EINVAL;
+
 	if(netif_running(netdev))
 		e100_down(nic);
 	rfds->count = max(ring->rx_pending, rfds->min);
 	rfds->count = min(rfds->count, rfds->max);
 	cbs->count = max(ring->tx_pending, cbs->min);
 	cbs->count = min(cbs->count, cbs->max);
+	DPRINTK(DRV, INFO, "Ring Param settings: rx: %d, tx %d\n",
+	        rfds->count, cbs->count);
 	if(netif_running(netdev))
 		e100_up(nic);
 
@@ -2173,6 +2179,7 @@
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	netdev->poll_controller = e100_netpoll;
 #endif
+	strcpy(netdev->name, pci_name(pdev));
 
 	nic = netdev_priv(netdev);
 	nic->netdev = netdev;
@@ -2197,8 +2204,6 @@
 		goto err_out_disable_pdev;
 	}
 
-	pci_set_master(pdev);
-
 	if((err = pci_set_dma_mask(pdev, 0xFFFFFFFFULL))) {
 		DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n");
 		goto err_out_free_res;
@@ -2219,9 +2224,18 @@
 	else
 		nic->flags &= ~ich;
 
+	e100_get_defaults(nic);
+
 	spin_lock_init(&nic->cb_lock);
 	spin_lock_init(&nic->cmd_lock);
 
+	/* Reset the device before pci_set_master() in case device is in some
+	 * funky state and has an interrupt pending - hint: we don't have the
+	 * interrupt handler registered yet. */
+	e100_hw_reset(nic);
+
+	pci_set_master(pdev);
+
 	init_timer(&nic->watchdog);
 	nic->watchdog.function = e100_watchdog;
 	nic->watchdog.data = (unsigned long)nic;
@@ -2234,8 +2248,6 @@
 		goto err_out_iounmap;
 	}
 
-	e100_get_defaults(nic);
-	e100_hw_reset(nic);
 	e100_phy_init(nic);
 
 	if((err = e100_eeprom_load(nic)))
@@ -2256,6 +2268,7 @@
 
 	pci_enable_wake(pdev, 0, nic->flags & (wol_magic | e100_asf(nic)));
 
+	strcpy(netdev->name, "eth%d");
 	if((err = register_netdev(netdev))) {
 		DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n");
 		goto err_out_free;
@@ -2310,7 +2323,7 @@
 	e100_hw_reset(nic);
 	netif_device_detach(netdev);
 
-	pci_save_state(pdev, nic->pm_state);
+	pci_save_state(pdev);
 	pci_enable_wake(pdev, state, nic->flags & (wol_magic | e100_asf(nic)));
 	pci_disable_device(pdev);
 	pci_set_power_state(pdev, state);
@@ -2324,7 +2337,7 @@
 	struct nic *nic = netdev_priv(netdev);
 
 	pci_set_power_state(pdev, 0);
-	pci_restore_state(pdev, nic->pm_state);
+	pci_restore_state(pdev);
 	e100_hw_init(nic);
 
 	netif_device_attach(netdev);
@@ -2352,7 +2365,7 @@
 		printk(KERN_INFO PFX "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
 		printk(KERN_INFO PFX "%s\n", DRV_COPYRIGHT);
 	}
-        return pci_module_init(&e100_driver);
+	return pci_module_init(&e100_driver);
 }
 
 static void __exit e100_cleanup_module(void)
diff -Nru a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
--- a/drivers/net/e1000/e1000.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/e1000/e1000.h	2004-12-24 13:36:17 -08:00
@@ -54,7 +54,7 @@
 #include <linux/string.h>
 #include <linux/pagemap.h>
 #include <linux/dma-mapping.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <linux/capability.h>
@@ -64,7 +64,6 @@
 #include <linux/udp.h>
 #include <net/pkt_sched.h>
 #include <linux/list.h>
-#include <linux/rtnetlink.h>
 #include <linux/reboot.h>
 #ifdef NETIF_F_TSO
 #include <net/checksum.h>
@@ -73,7 +72,6 @@
 #include <linux/mii.h>
 #include <linux/ethtool.h>
 #include <linux/if_vlan.h>
-#include <linux/moduleparam.h>
 
 #define BAR_0		0
 #define BAR_1		1
@@ -254,7 +252,6 @@
 	struct e1000_desc_ring test_rx_ring;
 
 
-	uint32_t pci_state[16];
 	int msg_enable;
 };
 #endif /* _E1000_H_ */
diff -Nru a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
--- a/drivers/net/e1000/e1000_ethtool.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/e1000/e1000_ethtool.c	2004-12-24 13:36:48 -08:00
@@ -249,7 +249,8 @@
 			e1000_reset(adapter);
 	}
 	else
-		return e1000_force_mac_fc(hw);
+		return ((hw->media_type == e1000_media_type_fiber) ?
+			e1000_setup_link(hw) : e1000_force_mac_fc(hw));
 	
 	return 0;
 }
@@ -592,6 +593,9 @@
 	tx_old = adapter->tx_ring;
 	rx_old = adapter->rx_ring;
 
+	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 
+		return -EINVAL;
+
 	if(netif_running(adapter->netdev))
 		e1000_down(adapter);
 
@@ -637,7 +641,6 @@
 	return err;
 }
 
-
 #define REG_PATTERN_TEST(R, M, W)                                              \
 {                                                                              \
 	uint32_t pat, value;                                                   \
@@ -1017,8 +1020,8 @@
 		struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
 		struct sk_buff *skb;
 
-		if(!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN,
-				     GFP_KERNEL))) {
+		if(!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, 
+				GFP_KERNEL))) {
 			ret_val = 6;
 			goto err_nomem;
 		}
@@ -1442,6 +1445,8 @@
 	case E1000_DEV_ID_82543GC_COPPER:
 	case E1000_DEV_ID_82544EI_FIBER:
 	case E1000_DEV_ID_82546EB_QUAD_COPPER:
+	case E1000_DEV_ID_82545EM_FIBER:
+	case E1000_DEV_ID_82545EM_COPPER:
 		wol->supported = 0;
 		wol->wolopts   = 0;
 		return;
diff -Nru a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
--- a/drivers/net/e1000/e1000_hw.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/e1000/e1000_hw.c	2004-12-24 13:37:29 -08:00
@@ -65,6 +65,7 @@
 static void e1000_standby_eeprom(struct e1000_hw *hw);
 static int32_t e1000_id_led_init(struct e1000_hw * hw);
 static int32_t e1000_set_vco_speed(struct e1000_hw *hw);
+static int32_t e1000_polarity_reversal_workaround(struct e1000_hw *hw);
 static int32_t e1000_set_phy_mode(struct e1000_hw *hw);
 
 /* IGP cable length table */
@@ -1594,6 +1595,15 @@
         ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
         if(ret_val)
             return ret_val;
+
+        if((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
+           (!hw->autoneg) &&
+           (hw->forced_speed_duplex == e1000_10_full ||
+            hw->forced_speed_duplex == e1000_10_half)) {
+            ret_val = e1000_polarity_reversal_workaround(hw);
+            if(ret_val)
+                return ret_val;
+        }
     }
     return E1000_SUCCESS;
 }
@@ -1983,6 +1993,7 @@
     uint32_t ctrl;
     uint32_t status;
     uint32_t rctl;
+    uint32_t icr;
     uint32_t signal = 0;
     int32_t ret_val;
     uint16_t phy_data;
@@ -2032,6 +2043,25 @@
              * link-up */
             e1000_check_downshift(hw);
 
+            /* If we are on 82544 or 82543 silicon and speed/duplex
+             * are forced to 10H or 10F, then we will implement the polarity
+             * reversal workaround.  We disable interrupts first, and upon
+             * returning, place the devices interrupt state to its previous
+             * value except for the link status change interrupt which will
+             * happen due to the execution of this workaround.
+             */
+
+            if((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
+               (!hw->autoneg) &&
+               (hw->forced_speed_duplex == e1000_10_full ||
+                hw->forced_speed_duplex == e1000_10_half)) {
+                E1000_WRITE_REG(hw, IMC, 0xffffffff);
+                ret_val = e1000_polarity_reversal_workaround(hw);
+                icr = E1000_READ_REG(hw, ICR);
+                E1000_WRITE_REG(hw, ICS, (icr & ~E1000_ICS_LSC));
+                E1000_WRITE_REG(hw, IMS, IMS_ENABLE_MASK);
+            }
+
         } else {
             /* No link detected */
             e1000_config_dsp_after_link_change(hw, FALSE);
@@ -5191,28 +5221,88 @@
     return E1000_SUCCESS;
 }
 
-/******************************************************************************
- * Verifies the hardware needs to allow ARPs to be processed by the host
- *
- * hw - Struct containing variables accessed by shared code
- *
- * returns: - TRUE/FALSE
- *
- *****************************************************************************/
-uint32_t
-e1000_enable_mng_pass_thru(struct e1000_hw *hw)
+static int32_t
+e1000_polarity_reversal_workaround(struct e1000_hw *hw)
 {
-    uint32_t manc;
+    int32_t ret_val;
+    uint16_t mii_status_reg;
+    uint16_t i;
 
-    if (hw->asf_firmware_present) {
-        manc = E1000_READ_REG(hw, MANC);
+    /* Polarity reversal workaround for forced 10F/10H links. */
+
+    /* Disable the transmitter on the PHY */
+
+    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0019);
+    if(ret_val)
+        return ret_val;
+    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFFFF);
+    if(ret_val)
+        return ret_val;
+
+    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0000);
+    if(ret_val)
+        return ret_val;
+
+    /* This loop will early-out if the NO link condition has been met. */
+    for(i = PHY_FORCE_TIME; i > 0; i--) {
+        /* Read the MII Status Register and wait for Link Status bit
+         * to be clear.
+         */
+
+        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
+        if(ret_val)
+            return ret_val;
+
+        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
+        if(ret_val)
+            return ret_val;
+
+        if((mii_status_reg & ~MII_SR_LINK_STATUS) == 0) break;
+        msec_delay_irq(100);
+    }
+
+    /* Recommended delay time after link has been lost */
+    msec_delay_irq(1000);
+
+    /* Now we will re-enable th transmitter on the PHY */
+
+    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0019);
+    if(ret_val)
+        return ret_val;
+    msec_delay_irq(50);
+    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFFF0);
+    if(ret_val)
+        return ret_val;
+    msec_delay_irq(50);
+    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFF00);
+    if(ret_val)
+        return ret_val;
+    msec_delay_irq(50);
+    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0x0000);
+    if(ret_val)
+        return ret_val;
 
-        if (!(manc & E1000_MANC_RCV_TCO_EN) ||
-            !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
-            return FALSE;
-        if ((manc & E1000_MANC_SMBUS_EN) && !(manc & E1000_MANC_ASF_EN))
-            return TRUE;
+    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0000);
+    if(ret_val)
+        return ret_val;
+
+    /* This loop will early-out if the link condition has been met. */
+    for(i = PHY_FORCE_TIME; i > 0; i--) {
+        /* Read the MII Status Register and wait for Link Status bit
+         * to be set.
+         */
+
+        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
+        if(ret_val)
+            return ret_val;
+
+        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
+        if(ret_val)
+            return ret_val;
+
+        if(mii_status_reg & MII_SR_LINK_STATUS) break;
+        msec_delay_irq(100);
     }
-    return FALSE;
+    return E1000_SUCCESS;
 }
 
diff -Nru a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
--- a/drivers/net/e1000/e1000_hw.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/e1000/e1000_hw.h	2004-12-24 13:37:18 -08:00
@@ -970,7 +970,7 @@
 
 /* Structure containing variables used by the shared code (e1000_hw.c) */
 struct e1000_hw {
-    uint8_t *hw_addr;
+    uint8_t __iomem *hw_addr;
     e1000_mac_type mac_type;
     e1000_phy_type phy_type;
     uint32_t phy_init_script;
diff -Nru a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
--- a/drivers/net/e1000/e1000_main.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/e1000/e1000_main.c	2004-12-24 13:36:47 -08:00
@@ -48,7 +48,7 @@
 #else
 #define DRIVERNAPI "-NAPI"
 #endif
-char e1000_driver_version[] = "5.3.19-k2"DRIVERNAPI;
+char e1000_driver_version[] = "5.5.4-k2"DRIVERNAPI;
 char e1000_copyright[] = "Copyright (c) 1999-2004 Intel Corporation.";
 
 /* e1000_pci_tbl - PCI Device ID Table
@@ -311,7 +311,8 @@
 void
 e1000_reset(struct e1000_adapter *adapter)
 {
-	uint32_t pba, manc;
+	uint32_t pba;
+
 	/* Repartition Pba for greater than 9k mtu
 	 * To take effect CTRL.RST is required.
 	 */
@@ -354,12 +355,6 @@
 
 	e1000_reset_adaptive(&adapter->hw);
 	e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
-
-	if(adapter->en_mng_pt) {
-		manc = E1000_READ_REG(&adapter->hw, MANC);
-		manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
-		E1000_WRITE_REG(&adapter->hw, MANC, manc);
-	}
 }
 
 /**
@@ -422,11 +417,6 @@
 	adapter->hw.back = adapter;
 	adapter->msg_enable = (1 << debug) - 1;
 
-	rtnl_lock();
-	/* we need to set the name early for the DPRINTK macro */
-	if(dev_alloc_name(netdev, netdev->name) < 0)
-		goto err_free_unlock;
-
 	mmio_start = pci_resource_start(pdev, BAR_0);
 	mmio_len = pci_resource_len(pdev, BAR_0);
 
@@ -466,6 +456,7 @@
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	netdev->poll_controller = e1000_netpoll;
 #endif
+	strcpy(netdev->name, pci_name(pdev));
 
 	netdev->mem_start = mmio_start;
 	netdev->mem_end = mmio_start + mmio_len;
@@ -502,8 +493,6 @@
  	/* hard_start_xmit is safe against parallel locking */
  	netdev->features |= NETIF_F_LLTX; 
  
-	adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
-
 	/* before reading the EEPROM, reset the controller to 
 	 * put the device in a known good starting state */
 	
@@ -553,7 +542,6 @@
 	netif_carrier_off(netdev);
 	netif_stop_queue(netdev);
 
-	DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
 	e1000_check_options(adapter);
 
 	/* Initial Wake on LAN setting
@@ -586,12 +574,13 @@
 	/* reset the hardware with the new settings */
 	e1000_reset(adapter);
 
-	/* We're already holding the rtnl lock; call the no-lock version */
-	if((err = register_netdevice(netdev)))
+	strcpy(netdev->name, "eth%d");
+	if((err = register_netdev(netdev)))
 		goto err_register;
 
+	DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
+
 	cards_found++;
-	rtnl_unlock();
 	return 0;
 
 err_register:
@@ -599,8 +588,6 @@
 err_eeprom:
 	iounmap(adapter->hw.hw_addr);
 err_ioremap:
-err_free_unlock:
-	rtnl_unlock();
 	free_netdev(netdev);
 err_alloc_etherdev:
 	pci_release_regions(pdev);
@@ -641,6 +628,8 @@
 	pci_release_regions(pdev);
 
 	free_netdev(netdev);
+
+	pci_disable_device(pdev);
 }
 
 /**
@@ -2335,8 +2324,8 @@
 		if(unlikely(adapter->vlgrp &&
 			    (rx_desc->status & E1000_RXD_STAT_VP))) {
 			vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-						 le16_to_cpu(rx_desc->special &
-						 E1000_RXD_SPC_VLAN_MASK));
+					le16_to_cpu(rx_desc->special) &
+					E1000_RXD_SPC_VLAN_MASK);
 		} else {
 			netif_receive_skb(skb);
 		}
@@ -2344,8 +2333,8 @@
 		if(unlikely(adapter->vlgrp &&
 			    (rx_desc->status & E1000_RXD_STAT_VP))) {
 			vlan_hwaccel_rx(skb, adapter->vlgrp,
-					le16_to_cpu(rx_desc->special &
-					E1000_RXD_SPC_VLAN_MASK));
+					le16_to_cpu(rx_desc->special) &
+					E1000_RXD_SPC_VLAN_MASK);
 		} else {
 			netif_rx(skb);
 		}
@@ -2867,7 +2856,7 @@
 		pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
 	}
 
-	pci_save_state(pdev, adapter->pci_state);
+	pci_save_state(pdev);
 
 	if(adapter->hw.mac_type >= e1000_82540 &&
 	   adapter->hw.media_type == e1000_media_type_copper) {
@@ -2894,11 +2883,13 @@
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct e1000_adapter *adapter = netdev->priv;
-	uint32_t manc;
+	uint32_t manc, ret;
 
-	pci_enable_device(pdev);
 	pci_set_power_state(pdev, 0);
-	pci_restore_state(pdev, adapter->pci_state);
+	pci_restore_state(pdev);
+	ret = pci_enable_device(pdev);
+	if (pdev->is_busmaster)
+		pci_set_master(pdev);
 
 	pci_enable_wake(pdev, 3, 0);
 	pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
diff -Nru a/drivers/net/e1000/e1000_osdep.h b/drivers/net/e1000/e1000_osdep.h
--- a/drivers/net/e1000/e1000_osdep.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/e1000/e1000_osdep.h	2004-12-24 13:36:31 -08:00
@@ -49,6 +49,12 @@
 				set_current_state(TASK_UNINTERRUPTIBLE); \
 				schedule_timeout((x * HZ)/1000 + 2); \
 			} } while(0)
+/* Some workarounds require millisecond delays and are run during interrupt
+ * context.  Most notably, when establishing link, the phy may need tweaking
+ * but cannot process phy register reads/writes faster than millisecond
+ * intervals...and we establish link due to a "link status change" interrupt.
+ */
+#define msec_delay_irq(x) mdelay(x)
 #endif
 
 #define PCI_COMMAND_REGISTER   PCI_COMMAND
diff -Nru a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c
--- a/drivers/net/e1000/e1000_param.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/net/e1000/e1000_param.c	2004-12-24 13:37:02 -08:00
@@ -34,31 +34,21 @@
 
 #define E1000_MAX_NIC 32
 
-#define OPTION_UNSET    -1
+#define OPTION_UNSET   -1
 #define OPTION_DISABLED 0
 #define OPTION_ENABLED  1
 
-/* Module Parameters are always initialized to -1, so that the driver
- * can tell the difference between no user specified value or the
- * user asking for the default value.
- * The true default values are loaded in when e1000_check_options is called.
- *
- * This is a GCC extension to ANSI C.
- * See the item "Labeled Elements in Initializers" in the section
- * "Extensions to the C Language Family" of the GCC documentation.
- */
-
-#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
-
 /* All parameters are treated the same, as an integer array of values.
  * This macro just reduces the need to repeat the same declaration code
  * over and over (plus this helps to avoid typo bugs).
  */
 
-#define E1000_PARAM(X, S) \
-static const int __devinitdata X[E1000_MAX_NIC + 1] = E1000_PARAM_INIT; \
-MODULE_PARM(X, "1-" __MODULE_STRING(E1000_MAX_NIC) "i"); \
-MODULE_PARM_DESC(X, S);
+#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
+#define E1000_PARAM(X, desc) \
+	static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
+	static int num_##X = 0; \
+	module_param_array(X, int, &num_##X, 0); \
+	MODULE_PARM_DESC(X, desc);
 
 /* Transmit Descriptor Count
  *
@@ -305,7 +295,6 @@
 		DPRINTK(PROBE, NOTICE,
 		       "Warning: no configuration for board #%i\n", bd);
 		DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
-		bd = E1000_MAX_NIC;
 	}
 
 	{ /* Transmit Descriptor Count */
@@ -322,9 +311,14 @@
 		opt.arg.r.max = mac_type < e1000_82544 ?
 			E1000_MAX_TXD : E1000_MAX_82544_TXD;
 
-		tx_ring->count = TxDescriptors[bd];
-		e1000_validate_option(&tx_ring->count, &opt, adapter);
-		E1000_ROUNDUP(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE);
+		if (num_TxDescriptors > bd) {
+			tx_ring->count = TxDescriptors[bd];
+			e1000_validate_option(&tx_ring->count, &opt, adapter);
+			E1000_ROUNDUP(tx_ring->count, 
+						REQ_TX_DESCRIPTOR_MULTIPLE);
+		} else {
+			tx_ring->count = opt.def;
+		}
 	}
 	{ /* Receive Descriptor Count */
 		struct e1000_option opt = {
@@ -340,9 +334,14 @@
 		opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
 			E1000_MAX_82544_RXD;
 
-		rx_ring->count = RxDescriptors[bd];
-		e1000_validate_option(&rx_ring->count, &opt, adapter);
-		E1000_ROUNDUP(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE);
+		if (num_RxDescriptors > bd) {
+			rx_ring->count = RxDescriptors[bd];
+			e1000_validate_option(&rx_ring->count, &opt, adapter);
+			E1000_ROUNDUP(rx_ring->count, 
+						REQ_RX_DESCRIPTOR_MULTIPLE);
+		} else {
+			rx_ring->count = opt.def;
+		}
 	}
 	{ /* Checksum Offload Enable/Disable */
 		struct e1000_option opt = {
@@ -352,9 +351,13 @@
 			.def  = OPTION_ENABLED
 		};
 
-		int rx_csum = XsumRX[bd];
-		e1000_validate_option(&rx_csum, &opt, adapter);
-		adapter->rx_csum = rx_csum;
+		if (num_XsumRX > bd) {
+			int rx_csum = XsumRX[bd];
+			e1000_validate_option(&rx_csum, &opt, adapter);
+			adapter->rx_csum = rx_csum;
+		} else {
+			adapter->rx_csum = opt.def;
+		}
 	}
 	{ /* Flow Control */
 
@@ -374,9 +377,13 @@
 					 .p = fc_list }}
 		};
 
-		int fc = FlowControl[bd];
-		e1000_validate_option(&fc, &opt, adapter);
-		adapter->hw.fc = adapter->hw.original_fc = fc;
+		if (num_FlowControl > bd) {
+			int fc = FlowControl[bd];
+			e1000_validate_option(&fc, &opt, adapter);
+			adapter->hw.fc = adapter->hw.original_fc = fc;
+		} else {
+			adapter->hw.fc = opt.def;
+		}
 	}
 	{ /* Transmit Interrupt Delay */
 		struct e1000_option opt = {
@@ -388,8 +395,13 @@
 					 .max = MAX_TXDELAY }}
 		};
 
-		adapter->tx_int_delay = TxIntDelay[bd];
-		e1000_validate_option(&adapter->tx_int_delay, &opt, adapter);
+		if (num_TxIntDelay > bd) {
+			adapter->tx_int_delay = TxIntDelay[bd];
+			e1000_validate_option(&adapter->tx_int_delay, &opt, 
+								adapter);
+		} else {
+			adapter->tx_int_delay = opt.def;
+		}
 	}
 	{ /* Transmit Absolute Interrupt Delay */
 		struct e1000_option opt = {
@@ -401,8 +413,13 @@
 					 .max = MAX_TXABSDELAY }}
 		};
 
-		adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
-		e1000_validate_option(&adapter->tx_abs_int_delay, &opt, adapter);
+		if (num_TxAbsIntDelay > bd) {
+			adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
+			e1000_validate_option(&adapter->tx_abs_int_delay, &opt, 
+								adapter);
+		} else {
+			adapter->tx_abs_int_delay = opt.def;
+		}
 	}
 	{ /* Receive Interrupt Delay */
 		struct e1000_option opt = {
@@ -414,8 +431,13 @@
 					 .max = MAX_RXDELAY }}
 		};
 
-		adapter->rx_int_delay = RxIntDelay[bd];
-		e1000_validate_option(&adapter->rx_int_delay, &opt, adapter);
+		if (num_RxIntDelay > bd) {
+			adapter->rx_int_delay = RxIntDelay[bd];
+			e1000_validate_option(&adapter->rx_int_delay, &opt, 
+								adapter);
+		} else {
+			adapter->rx_int_delay = opt.def;
+		}
 	}
 	{ /* Receive Absolute Interrupt Delay */
 		struct e1000_option opt = {
@@ -427,8 +449,13 @@
 					 .max = MAX_RXABSDELAY }}
 		};
 
-		adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
-		e1000_validate_option(&adapter->rx_abs_int_delay, &opt, adapter);
+		if (num_RxAbsIntDelay > bd) {
+			adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
+			e1000_validate_option(&adapter->rx_abs_int_delay, &opt, 
+								adapter);
+		} else {
+			adapter->rx_abs_int_delay = opt.def;
+		}
 	}
 	{ /* Interrupt Throttling Rate */
 		struct e1000_option opt = {
@@ -440,20 +467,27 @@
 					 .max = MAX_ITR }}
 		};
 
-		adapter->itr = InterruptThrottleRate[bd];
-		switch(adapter->itr) {
-		case -1:
+		if (num_InterruptThrottleRate > bd) {
+			adapter->itr = InterruptThrottleRate[bd];
+			switch(adapter->itr) {
+			case -1:
+				adapter->itr = 1;
+				break;
+			case 0:
+				DPRINTK(PROBE, INFO, "%s turned off\n", 
+					opt.name);
+				break;
+			case 1:
+				DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", 
+					opt.name);
+				break;
+			default:
+				e1000_validate_option(&adapter->itr, &opt, 
+					adapter);
+				break;
+			}
+		} else {
 			adapter->itr = 1;
-			break;
-		case 0:
-			DPRINTK(PROBE, INFO, "%s turned off\n", opt.name);
-			break;
-		case 1:
-			DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", opt.name);
-			break;
-		default:
-			e1000_validate_option(&adapter->itr, &opt, adapter);
-			break;
 		}
 	}
 
@@ -481,17 +515,17 @@
 e1000_check_fiber_options(struct e1000_adapter *adapter)
 {
 	int bd = adapter->bd_number;
-	bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
-
-	if((Speed[bd] != OPTION_UNSET)) {
+	if(num_Speed > bd) {
 		DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
 		       "parameter ignored\n");
 	}
-	if((Duplex[bd] != OPTION_UNSET)) {
+
+	if(num_Duplex > bd) {
 		DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
 		       "parameter ignored\n");
 	}
-	if((AutoNeg[bd] != OPTION_UNSET) && (AutoNeg[bd] != 0x20)) {
+
+	if((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) {
 		DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is "
 				 "not valid for fiber adapters, "
 				 "parameter ignored\n");
@@ -510,7 +544,6 @@
 {
 	int speed, dplx;
 	int bd = adapter->bd_number;
-	bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
 
 	{ /* Speed */
 		struct e1000_opt_list speed_list[] = {{          0, "" },
@@ -527,8 +560,12 @@
 					 .p = speed_list }}
 		};
 
-		speed = Speed[bd];
-		e1000_validate_option(&speed, &opt, adapter);
+		if (num_Speed > bd) {
+			speed = Speed[bd];
+			e1000_validate_option(&speed, &opt, adapter);
+		} else {
+			speed = opt.def;
+		}
 	}
 	{ /* Duplex */
 		struct e1000_opt_list dplx_list[] = {{           0, "" },
@@ -544,11 +581,15 @@
 					 .p = dplx_list }}
 		};
 
-		dplx = Duplex[bd];
-		e1000_validate_option(&dplx, &opt, adapter);
+		if (num_Duplex > bd) {
+			dplx = Duplex[bd];
+			e1000_validate_option(&dplx, &opt, adapter);
+		} else {
+			dplx = opt.def;
+		}
 	}
 
-	if(AutoNeg[bd] != OPTION_UNSET && (speed != 0 || dplx != 0)) {
+	if((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) {
 		DPRINTK(PROBE, INFO,
 		       "AutoNeg specified along with Speed or Duplex, "
 		       "parameter ignored\n");
@@ -605,7 +646,7 @@
 	switch (speed + dplx) {
 	case 0:
 		adapter->hw.autoneg = adapter->fc_autoneg = 1;
-		if(Speed[bd] != OPTION_UNSET || Duplex[bd] != OPTION_UNSET)
+		if((num_Speed > bd) && (speed != 0 || dplx != 0))
 			DPRINTK(PROBE, INFO,
 			       "Speed and duplex autonegotiation enabled\n");
 		break;
diff -Nru a/drivers/net/eepro.c b/drivers/net/eepro.c
--- a/drivers/net/eepro.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/net/eepro.c	2004-12-24 13:37:04 -08:00
@@ -145,9 +145,9 @@
 #include <linux/spinlock.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/eepro100.c b/drivers/net/eepro100.c
--- a/drivers/net/eepro100.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/eepro100.c	2004-12-24 13:37:01 -08:00
@@ -102,8 +102,8 @@
 #include <linux/init.h>
 #include <linux/mii.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/irq.h>
@@ -490,9 +490,6 @@
 	unsigned short partner;			/* Link partner caps. */
 	struct mii_if_info mii_if;		/* MII API hooks, info */
 	u32 msg_enable;				/* debug message level */
-#ifdef CONFIG_PM
-	u32 pm_state[16];
-#endif
 };
 
 /* The parameters for a CmdConfigure operation.
@@ -541,6 +538,7 @@
 static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void set_rx_mode(struct net_device *dev);
 static void speedo_show_state(struct net_device *dev);
+static struct ethtool_ops ethtool_ops;
 
 
 
@@ -895,6 +893,7 @@
 	dev->get_stats = &speedo_get_stats;
 	dev->set_multicast_list = &set_rx_mode;
 	dev->do_ioctl = &speedo_ioctl;
+	SET_ETHTOOL_OPS(dev, &ethtool_ops);
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	dev->poll_controller = &poll_speedo;
 #endif
@@ -2010,82 +2009,68 @@
 	return &sp->stats;
 }
 
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void speedo_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	u32 ethcmd;
 	struct speedo_private *sp = netdev_priv(dev);
-		
-	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-		return -EFAULT;
-	
-        switch (ethcmd) {
-	/* get driver-specific version/etc. info */
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-		strncpy(info.driver, "eepro100", sizeof(info.driver)-1);
-		strncpy(info.version, version, sizeof(info.version)-1);
-		if (sp && sp->pdev)
-			strcpy(info.bus_info, pci_name(sp->pdev));
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-	
-	/* get settings */
-	case ETHTOOL_GSET: {
-		struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-		spin_lock_irq(&sp->lock);
-		mii_ethtool_gset(&sp->mii_if, &ecmd);
-		spin_unlock_irq(&sp->lock);
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set settings */
-	case ETHTOOL_SSET: {
-		int r;
-		struct ethtool_cmd ecmd;
-		if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-			return -EFAULT;
-		spin_lock_irq(&sp->lock);
-		r = mii_ethtool_sset(&sp->mii_if, &ecmd);
-		spin_unlock_irq(&sp->lock);
-		return r;
-	}
-	/* restart autonegotiation */
-	case ETHTOOL_NWAY_RST: {
-		return mii_nway_restart(&sp->mii_if);
-	}
-	/* get link status */
-	case ETHTOOL_GLINK: {
-		struct ethtool_value edata = {ETHTOOL_GLINK};
-		edata.data = mii_link_ok(&sp->mii_if);
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-	/* get message-level */
-	case ETHTOOL_GMSGLVL: {
-		struct ethtool_value edata = {ETHTOOL_GMSGLVL};
-		edata.data = sp->msg_enable;
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set message-level */
-	case ETHTOOL_SMSGLVL: {
-		struct ethtool_value edata;
-		if (copy_from_user(&edata, useraddr, sizeof(edata)))
-			return -EFAULT;
-		sp->msg_enable = edata.data;
-		return 0;
-	}
+	strncpy(info->driver, "eepro100", sizeof(info->driver)-1);
+	strncpy(info->version, version, sizeof(info->version)-1);
+	if (sp->pdev)
+		strcpy(info->bus_info, pci_name(sp->pdev));
+}
 
-        }
-	
-	return -EOPNOTSUPP;
+static int speedo_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct speedo_private *sp = netdev_priv(dev);
+	spin_lock_irq(&sp->lock);
+	mii_ethtool_gset(&sp->mii_if, ecmd);
+	spin_unlock_irq(&sp->lock);
+	return 0;
 }
 
+static int speedo_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct speedo_private *sp = netdev_priv(dev);
+	int res;
+	spin_lock_irq(&sp->lock);
+	res = mii_ethtool_sset(&sp->mii_if, ecmd);
+	spin_unlock_irq(&sp->lock);
+	return res;
+}
+
+static int speedo_nway_reset(struct net_device *dev)
+{
+	struct speedo_private *sp = netdev_priv(dev);
+	return mii_nway_restart(&sp->mii_if);
+}
+
+static u32 speedo_get_link(struct net_device *dev)
+{
+	struct speedo_private *sp = netdev_priv(dev);
+	return mii_link_ok(&sp->mii_if);
+}
+
+static u32 speedo_get_msglevel(struct net_device *dev)
+{
+	struct speedo_private *sp = netdev_priv(dev);
+	return sp->msg_enable;
+}
+
+static void speedo_set_msglevel(struct net_device *dev, u32 v)
+{
+	struct speedo_private *sp = netdev_priv(dev);
+	sp->msg_enable = v;
+}
+
+static struct ethtool_ops ethtool_ops = {
+	.get_drvinfo = speedo_get_drvinfo,
+	.get_settings = speedo_get_settings,
+	.set_settings = speedo_set_settings,
+	.nway_reset = speedo_nway_reset,
+	.get_link = speedo_get_link,
+	.get_msglevel = speedo_get_msglevel,
+	.set_msglevel = speedo_set_msglevel,
+};
+
 static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
 	struct speedo_private *sp = netdev_priv(dev);
@@ -2121,8 +2106,6 @@
 			add_timer(&sp->timer); /* may be set to the past  --SAW */
 		pci_set_power_state(sp->pdev, saved_acpi);
 		return 0;
-	case SIOCETHTOOL:
-		return netdev_ethtool_ioctl(dev, rq->ifr_data);
 	default:
 		return -EOPNOTSUPP;
 	}
@@ -2334,7 +2317,7 @@
 	struct speedo_private *sp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 
-	pci_save_state(pdev, sp->pm_state);
+	pci_save_state(pdev);
 
 	if (!netif_running(dev))
 		return 0;
@@ -2345,6 +2328,8 @@
 	outl(PortPartialReset, ioaddr + SCBPort);
 	
 	/* XXX call pci_set_power_state ()? */
+	pci_disable_device(pdev);
+	pci_set_power_state (pdev, 3);
 	return 0;
 }
 
@@ -2354,7 +2339,10 @@
 	struct speedo_private *sp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 
-	pci_restore_state(pdev, sp->pm_state);
+	pci_set_power_state(pdev, 0);
+	pci_restore_state(pdev);
+	pci_enable_device(pdev);
+	pci_set_master(pdev);
 
 	if (!netif_running(dev))
 		return 0;
diff -Nru a/drivers/net/eexpress.c b/drivers/net/eexpress.c
--- a/drivers/net/eexpress.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/eexpress.c	2004-12-24 13:36:16 -08:00
@@ -115,9 +115,9 @@
 #include <linux/slab.h>
 #include <linux/mca-legacy.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
diff -Nru a/drivers/net/epic100.c b/drivers/net/epic100.c
--- a/drivers/net/epic100.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/epic100.c	2004-12-24 13:36:48 -08:00
@@ -133,7 +133,7 @@
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/crc32.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
diff -Nru a/drivers/net/eql.c b/drivers/net/eql.c
--- a/drivers/net/eql.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/eql.c	2004-12-24 13:37:19 -08:00
@@ -164,12 +164,12 @@
 
 static void __init eql_setup(struct net_device *dev)
 {
-	equalizer_t *eql = dev->priv;
+	equalizer_t *eql = netdev_priv(dev);
 
 	SET_MODULE_OWNER(dev);
 
 	init_timer(&eql->timer);
-	eql->timer.data     	= (unsigned long) dev->priv;
+	eql->timer.data     	= (unsigned long) eql;
 	eql->timer.expires  	= jiffies + EQL_DEFAULT_RESCHED_IVAL;
 	eql->timer.function 	= eql_timer;
 
@@ -197,7 +197,7 @@
 
 static int eql_open(struct net_device *dev)
 {
-	equalizer_t *eql = dev->priv;
+	equalizer_t *eql = netdev_priv(dev);
 
 	/* XXX We should force this off automatically for the user. */
 	printk(KERN_INFO "%s: remember to turn off Van-Jacobson compression on "
@@ -241,7 +241,7 @@
 
 static int eql_close(struct net_device *dev)
 {
-	equalizer_t *eql = dev->priv;
+	equalizer_t *eql = netdev_priv(dev);
 
 	/*
 	 *	The timer has to be stopped first before we start hacking away
@@ -326,7 +326,7 @@
 
 static int eql_slave_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	equalizer_t *eql = dev->priv;
+	equalizer_t *eql = netdev_priv(dev);
 	slave_t *slave;
 
 	spin_lock(&eql->queue.lock);
@@ -352,7 +352,7 @@
 
 static struct net_device_stats * eql_get_stats(struct net_device *dev)
 {
-	equalizer_t *eql = dev->priv;
+	equalizer_t *eql = netdev_priv(dev);
 	return &eql->stats;
 }
 
@@ -378,7 +378,7 @@
 
 static inline int eql_is_full(slave_queue_t *queue)
 {
-	equalizer_t *eql = queue->master_dev->priv;
+	equalizer_t *eql = netdev_priv(queue->master_dev);
 
 	if (queue->num_slaves >= eql->max_slaves)
 		return 1;
@@ -420,7 +420,7 @@
 			if (!eql_is_master(slave_dev) &&
 			    !eql_is_slave(slave_dev)) {
 				slave_t *s = kmalloc(sizeof(*s), GFP_KERNEL);
-				equalizer_t *eql = master_dev->priv;
+				equalizer_t *eql = netdev_priv(master_dev);
 				int ret;
 
 				if (!s) {
@@ -453,7 +453,7 @@
 
 static int eql_emancipate(struct net_device *master_dev, slaving_request_t __user *srqp)
 {
-	equalizer_t *eql = master_dev->priv;
+	equalizer_t *eql = netdev_priv(master_dev);
 	struct net_device *slave_dev;
 	slaving_request_t srq;
 	int ret;
@@ -485,7 +485,7 @@
 
 static int eql_g_slave_cfg(struct net_device *dev, slave_config_t __user *scp)
 {
-	equalizer_t *eql = dev->priv;
+	equalizer_t *eql = netdev_priv(dev);
 	slave_t *slave;
 	struct net_device *slave_dev;
 	slave_config_t sc;
@@ -539,7 +539,7 @@
 	if (!slave_dev)
 		return ret;
 
-	eql = dev->priv;
+	eql = netdev_priv(dev);
 	spin_lock_bh(&eql->queue.lock);
 	if (eql_is_slave(slave_dev)) {
 		slave = __eql_find_slave_dev(&eql->queue, slave_dev);
@@ -561,7 +561,7 @@
 	master_config_t mc;
 
 	if (eql_is_master(dev)) {
-		eql = dev->priv;
+		eql = netdev_priv(dev);
 		mc.max_slaves = eql->max_slaves;
 		mc.min_slaves = eql->min_slaves;
 		if (copy_to_user(mcp, &mc, sizeof (master_config_t)))
@@ -580,7 +580,7 @@
 		return -EFAULT;
 
 	if (eql_is_master(dev)) {
-		eql = dev->priv;
+		eql = netdev_priv(dev);
 		eql->max_slaves = mc.max_slaves;
 		eql->min_slaves = mc.min_slaves;
 		return 0;
diff -Nru a/drivers/net/eth16i.c b/drivers/net/eth16i.c
--- a/drivers/net/eth16i.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/eth16i.c	2004-12-24 13:37:18 -08:00
@@ -160,9 +160,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>		  
-#include <asm/bitops.h>		  
 #include <asm/io.h>		  
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/ethertap.c b/drivers/net/ethertap.c
--- a/drivers/net/ethertap.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/ethertap.c	2004-12-24 13:36:31 -08:00
@@ -124,7 +124,7 @@
 	struct net_local *lp = netdev_priv(dev);
 
 	if (ethertap_debug > 2)
-		printk(KERN_DEBUG "%s: Doing ethertap_open()...", dev->name);
+		printk(KERN_DEBUG "%s: Doing ethertap_open()...\n", dev->name);
 
 	lp->nl = netlink_kernel_create(dev->base_addr, ethertap_rx);
 	if (lp->nl == NULL)
diff -Nru a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c
--- a/drivers/net/ewrk3.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/ewrk3.c	2004-12-24 13:37:29 -08:00
@@ -161,8 +161,8 @@
 #include <linux/types.h>
 #include <linux/unistd.h>
 #include <linux/ctype.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/uaccess.h>
@@ -305,6 +305,8 @@
 static struct net_device_stats *ewrk3_get_stats(struct net_device *dev);
 static void set_multicast_list(struct net_device *dev);
 static int ewrk3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+static struct ethtool_ops ethtool_ops_203;
+static struct ethtool_ops ethtool_ops;
 
 /*
    ** Private functions
@@ -532,7 +534,7 @@
 		printk("      is in I/O only mode");
 	}
 
-	lp = (struct ewrk3_private *) dev->priv;
+	lp = netdev_priv(dev);
 	lp->shmem_base = mem_start;
 	lp->shmem_length = shmem_length;
 	lp->lemac = lemac;
@@ -610,6 +612,10 @@
 	dev->get_stats = ewrk3_get_stats;
 	dev->set_multicast_list = set_multicast_list;
 	dev->do_ioctl = ewrk3_ioctl;
+	if (lp->adapter_name[4] == '3')
+		SET_ETHTOOL_OPS(dev, &ethtool_ops_203);
+	else
+		SET_ETHTOOL_OPS(dev, &ethtool_ops);
 	dev->tx_timeout = ewrk3_timeout;
 	dev->watchdog_timeo = QUEUE_PKT_TIMEOUT;
 	
@@ -621,7 +627,7 @@
 
 static int ewrk3_open(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	u_long iobase = dev->base_addr;
 	int i, status = 0;
 	u_char icr, csr;
@@ -684,7 +690,7 @@
  */
 static void ewrk3_init(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	u_char csr, page;
 	u_long iobase = dev->base_addr;
 	int i;
@@ -725,7 +731,7 @@
  
 static void ewrk3_timeout(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	u_char icr, csr;
 	u_long iobase = dev->base_addr;
 	
@@ -761,7 +767,7 @@
  */
 static int ewrk3_queue_pkt (struct sk_buff *skb, struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	u_long iobase = dev->base_addr;
 	u_long buf = 0;
 	u_char icr;
@@ -883,7 +889,7 @@
 	u_long iobase;
 	u_char icr, cr, csr;
 
-	lp = (struct ewrk3_private *) dev->priv;
+	lp = netdev_priv(dev);
 	iobase = dev->base_addr;
 
 	/* get the interrupt information */
@@ -931,7 +937,7 @@
 /* Called with lp->hw_lock held */
 static int ewrk3_rx(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	u_long iobase = dev->base_addr;
 	int i, status = 0;
 	u_char page;
@@ -1059,7 +1065,7 @@
 */
 static int ewrk3_tx(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	u_long iobase = dev->base_addr;
 	u_char tx_status;
 
@@ -1095,7 +1101,7 @@
 
 static int ewrk3_close(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	u_long iobase = dev->base_addr;
 	u_char icr, csr;
 
@@ -1130,7 +1136,7 @@
 
 static struct net_device_stats *ewrk3_get_stats(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 
 	/* Null body since there is no framing error counter */
 	return &lp->stats;
@@ -1141,7 +1147,7 @@
  */
 static void set_multicast_list(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	u_long iobase = dev->base_addr;
 	u_char csr;
 
@@ -1174,7 +1180,7 @@
  */
 static void SetMulticastFilter(struct net_device *dev)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	struct dev_mc_list *dmi = dev->mc_list;
 	u_long iobase = dev->base_addr;
 	int i;
@@ -1520,195 +1526,173 @@
 	return status;		/* return the device name string */
 }
 
-static int ewrk3_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void ewrk3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
-	u_long iobase = dev->base_addr;
-	u32 ethcmd;
-
-	if (get_user(ethcmd, (u32 __user *)useraddr))
-		return -EFAULT;
+	int fwrev = Read_EEPROM(dev->base_addr, EEPROM_REVLVL);
 
-	switch (ethcmd) {
-
-	/* Get driver info */
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-		int fwrev = Read_EEPROM(dev->base_addr, EEPROM_REVLVL);
-
-		strcpy(info.driver, DRV_NAME);
-		strcpy(info.version, DRV_VERSION);
-		sprintf(info.fw_version, "%d", fwrev);
-		strcpy(info.bus_info, "N/A");
-		info.eedump_len = EEPROM_MAX;
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-
-	/* Get settings */
-	case ETHTOOL_GSET: {
-		struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-		u_char cr = inb(EWRK3_CR);
-
-		switch (lp->adapter_name[4]) {
-		case '3': /* DE203 */
-			ecmd.supported = SUPPORTED_BNC;
-			ecmd.port = PORT_BNC;
-			break;
-
-		case '4': /* DE204 */
-			ecmd.supported = SUPPORTED_TP;
-			ecmd.port = PORT_TP;
-			break;
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+	sprintf(info->fw_version, "%d", fwrev);
+	strcpy(info->bus_info, "N/A");
+	info->eedump_len = EEPROM_MAX;
+}
 
-		case '5': /* DE205 */
-			ecmd.supported = SUPPORTED_TP | SUPPORTED_BNC | SUPPORTED_AUI;
-			ecmd.autoneg = !(cr & CR_APD);
-			/*
-			** Port is only valid if autoneg is disabled
-			** and even then we don't know if AUI is jumpered.
-			*/
-			if (!ecmd.autoneg)
-				ecmd.port = (cr & CR_PSEL) ? PORT_BNC : PORT_TP;
-			break;
-		}
+static int ewrk3_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct ewrk3_private *lp = netdev_priv(dev);
+	unsigned long iobase = dev->base_addr;
+	u8 cr = inb(EWRK3_CR);
 
-		ecmd.supported |= SUPPORTED_10baseT_Half;
-		ecmd.speed = SPEED_10;
-		ecmd.duplex = DUPLEX_HALF;
-
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-	}
-
-	/* Set settings */
-	case ETHTOOL_SSET: {
-		struct ethtool_cmd ecmd;
-		u_char cr;
-		u_long flags;
-
-		/* DE205 is the only card with anything to set */
-		if (lp->adapter_name[4] != '5')
-			return -EOPNOTSUPP;
-
-		if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-			return -EFAULT;
-
-		/* Sanity-check parameters */
-		if (ecmd.speed != SPEED_10)
-			return -EINVAL;
-		if (ecmd.port != PORT_TP && ecmd.port != PORT_BNC)
-			return -EINVAL; /* AUI is not software-selectable */
-		if (ecmd.transceiver != XCVR_INTERNAL)
-			return -EINVAL;
-		if (ecmd.duplex != DUPLEX_HALF)
-			return -EINVAL;
-		if (ecmd.phy_address != 0)
-			return -EINVAL;
+	switch (lp->adapter_name[4]) {
+	case '3': /* DE203 */
+		ecmd->supported = SUPPORTED_BNC;
+		ecmd->port = PORT_BNC;
+		break;
 
-		spin_lock_irqsave(&lp->hw_lock, flags);
-		cr = inb(EWRK3_CR);
+	case '4': /* DE204 */
+		ecmd->supported = SUPPORTED_TP;
+		ecmd->port = PORT_TP;
+		break;
 
-		/* If Autoneg is set, change to Auto Port mode */
-		/* Otherwise, disable Auto Port and set port explicitly */
-		if (ecmd.autoneg) {
-			cr &= ~CR_APD;
-		} else {
-			cr |= CR_APD;
-			if (ecmd.port == PORT_TP)
-				cr &= ~CR_PSEL;		/* Force TP */
-			else
-				cr |= CR_PSEL;		/* Force BNC */
-		}
+	case '5': /* DE205 */
+		ecmd->supported = SUPPORTED_TP | SUPPORTED_BNC | SUPPORTED_AUI;
+		ecmd->autoneg = !(cr & CR_APD);
+		/*
+		** Port is only valid if autoneg is disabled
+		** and even then we don't know if AUI is jumpered.
+		*/
+		if (!ecmd->autoneg)
+			ecmd->port = (cr & CR_PSEL) ? PORT_BNC : PORT_TP;
+		break;
+	}
 
-		/* Commit the changes */
-		outb(cr, EWRK3_CR);
+	ecmd->supported |= SUPPORTED_10baseT_Half;
+	ecmd->speed = SPEED_10;
+	ecmd->duplex = DUPLEX_HALF;
+	return 0;
+}
 
-		spin_unlock_irqrestore(&lp->hw_lock, flags);
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-	}
+static int ewrk3_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct ewrk3_private *lp = netdev_priv(dev);
+	unsigned long iobase = dev->base_addr;
+	unsigned long flags;
+	u8 cr;
 
-	/* Get link status */
-	case ETHTOOL_GLINK: {
-		struct ethtool_value edata = { ETHTOOL_GLINK };
-		u_char cmr = inb(EWRK3_CMR);
+	/* DE205 is the only card with anything to set */
+	if (lp->adapter_name[4] != '5')
+		return -EOPNOTSUPP;
 
-		/* DE203 has BNC only and link status does not apply */
-		if (lp->adapter_name[4] == '3')
-			return -EOPNOTSUPP;
+	/* Sanity-check parameters */
+	if (ecmd->speed != SPEED_10)
+		return -EINVAL;
+	if (ecmd->port != PORT_TP && ecmd->port != PORT_BNC)
+		return -EINVAL; /* AUI is not software-selectable */
+	if (ecmd->transceiver != XCVR_INTERNAL)
+		return -EINVAL;
+	if (ecmd->duplex != DUPLEX_HALF)
+		return -EINVAL;
+	if (ecmd->phy_address != 0)
+		return -EINVAL;
 
-		/* On DE204 this is always valid since TP is the only port. */
-		/* On DE205 this reflects TP status even if BNC or AUI is selected. */
-		edata.data = !(cmr & CMR_LINK);
+	spin_lock_irqsave(&lp->hw_lock, flags);
+	cr = inb(EWRK3_CR);
 
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
+	/* If Autoneg is set, change to Auto Port mode */
+	/* Otherwise, disable Auto Port and set port explicitly */
+	if (ecmd->autoneg) {
+		cr &= ~CR_APD;
+	} else {
+		cr |= CR_APD;
+		if (ecmd->port == PORT_TP)
+			cr &= ~CR_PSEL;		/* Force TP */
+		else
+			cr |= CR_PSEL;		/* Force BNC */
 	}
 
-	/* Blink LED for identification */
-	case ETHTOOL_PHYS_ID: {
-		struct ethtool_value edata;
-		u_long flags;
-		u_char cr;
-		int count;
+	/* Commit the changes */
+	outb(cr, EWRK3_CR);
+	spin_unlock_irqrestore(&lp->hw_lock, flags);
+	return 0;
+}
 
-		if (copy_from_user(&edata, useraddr, sizeof(edata)))
-			return -EFAULT;
+static u32 ewrk3_get_link(struct net_device *dev)
+{
+	unsigned long iobase = dev->base_addr;
+	u8 cmr = inb(EWRK3_CMR);
+	/* DE203 has BNC only and link status does not apply */
+	/* On DE204 this is always valid since TP is the only port. */
+	/* On DE205 this reflects TP status even if BNC or AUI is selected. */
+	return !(cmr & CMR_LINK);
+}
 
-		/* Toggle LED 4x per second */
-		count = edata.data << 2;
+static int ewrk3_phys_id(struct net_device *dev, u32 data)
+{
+	struct ewrk3_private *lp = netdev_priv(dev);
+	unsigned long iobase = dev->base_addr;
+	unsigned long flags;
+	u8 cr;
+	int count;
 
-		spin_lock_irqsave(&lp->hw_lock, flags);
+	/* Toggle LED 4x per second */
+	count = data << 2;
 
-		/* Bail if a PHYS_ID is already in progress */
-		if (lp->led_mask == 0) {
-			spin_unlock_irqrestore(&lp->hw_lock, flags);
-			return -EBUSY;
-		}
+	spin_lock_irqsave(&lp->hw_lock, flags);
 
-		/* Prevent ISR from twiddling the LED */
-		lp->led_mask = 0;
+	/* Bail if a PHYS_ID is already in progress */
+	if (lp->led_mask == 0) {
+		spin_unlock_irqrestore(&lp->hw_lock, flags);
+		return -EBUSY;
+	}
 
-		while (count--) {
-			/* Toggle the LED */
-			cr = inb(EWRK3_CR);
-			outb(cr ^ CR_LED, EWRK3_CR);
-
-			/* Wait a little while */
-			spin_unlock_irqrestore(&lp->hw_lock, flags);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ>>2);
-			spin_lock_irqsave(&lp->hw_lock, flags);
-
-			/* Exit if we got a signal */
-			if (signal_pending(current))
-				break;
-		}
+	/* Prevent ISR from twiddling the LED */
+	lp->led_mask = 0;
 
-		lp->led_mask = CR_LED;
+	while (count--) {
+		/* Toggle the LED */
 		cr = inb(EWRK3_CR);
-		outb(cr & ~CR_LED, EWRK3_CR);
+		outb(cr ^ CR_LED, EWRK3_CR);
+
+		/* Wait a little while */
 		spin_unlock_irqrestore(&lp->hw_lock, flags);
-		return signal_pending(current) ? -ERESTARTSYS : 0;
-	}
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(HZ>>2);
+		spin_lock_irqsave(&lp->hw_lock, flags);
 
+		/* Exit if we got a signal */
+		if (signal_pending(current))
+			break;
 	}
 
-	return -EOPNOTSUPP;
+	lp->led_mask = CR_LED;
+	cr = inb(EWRK3_CR);
+	outb(cr & ~CR_LED, EWRK3_CR);
+	spin_unlock_irqrestore(&lp->hw_lock, flags);
+	return signal_pending(current) ? -ERESTARTSYS : 0;
 }
 
+static struct ethtool_ops ethtool_ops_203 = {
+	.get_drvinfo = ewrk3_get_drvinfo,
+	.get_settings = ewrk3_get_settings,
+	.set_settings = ewrk3_set_settings,
+	.phys_id = ewrk3_phys_id,
+};
+
+static struct ethtool_ops ethtool_ops = {
+	.get_drvinfo = ewrk3_get_drvinfo,
+	.get_settings = ewrk3_get_settings,
+	.set_settings = ewrk3_set_settings,
+	.get_link = ewrk3_get_link,
+	.phys_id = ewrk3_phys_id,
+};
+
 /*
    ** Perform IOCTL call functions here. Some are privileged operations and the
    ** effective uid is checked in those cases.
  */
 static int ewrk3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
+	struct ewrk3_private *lp = netdev_priv(dev);
 	struct ewrk3_ioctl *ioc = (struct ewrk3_ioctl *) &rq->ifr_ifru;
 	u_long iobase = dev->base_addr;
 	int i, j, status = 0;
@@ -1721,11 +1705,7 @@
 	
 	union ewrk3_addr *tmp;
 
-	/* ethtool IOCTLs are handled elsewhere */
-	if (cmd == SIOCETHTOOL)
-		return ewrk3_ethtool_ioctl(dev, rq->ifr_data);
-
-	/* Other than ethtool, all we handle are private IOCTLs */
+	/* All we handle are private IOCTLs */
 	if (cmd != EWRK3IOCTL)
 		return -EOPNOTSUPP;
 
diff -Nru a/drivers/net/fealnx.c b/drivers/net/fealnx.c
--- a/drivers/net/fealnx.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/net/fealnx.c	2004-12-24 13:37:02 -08:00
@@ -85,9 +85,9 @@
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/processor.h>	/* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
diff -Nru a/drivers/net/fec.c b/drivers/net/fec.c
--- a/drivers/net/fec.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/fec.c	2004-12-24 13:36:18 -08:00
@@ -18,8 +18,8 @@
  * Much better multiple PHY support by Magnus Damm.
  * Copyright (c) 2000 Ericsson Radio Systems AB.
  *
- * Support for FEC controller of ColdFire/5272.
- * Copyrught (c) 2001-2002 Greg Ungerer (gerg@snapgear.com)
+ * Support for FEC controller of ColdFire/5270/5271/5272/5274/5275/5280/5282.
+ * Copyrught (c) 2001-2004 Greg Ungerer (gerg@snapgear.com)
  */
 
 #include <linux/config.h>
@@ -39,14 +39,14 @@
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
+#include <linux/bitops.h>
 
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
 
-#ifdef CONFIG_M5272
+#if defined(CONFIG_M527x) || defined(CONFIG_M5272) || defined(CONFIG_M528x)
 #include <asm/coldfire.h>
 #include <asm/mcfsim.h>
 #include "fec.h"
@@ -56,19 +56,31 @@
 #include "commproc.h"
 #endif
 
-static int opened = 0;
-static int found = 0;
+#if defined(CONFIG_FEC2)
+#define	FEC_MAX_PORTS	2
+#else
+#define	FEC_MAX_PORTS	1
+#endif
 
 /*
  * Define the fixed address of the FEC hardware.
  */
-#ifdef CONFIG_M5272
-static volatile fec_t   *fec_hwp = (volatile fec_t *) (MCF_MBAR + 0x840);
-static ushort		my_enet_addr[] = { 0x00d0, 0xcf00, 0x0072 };
+static unsigned int fec_hw[] = {
+#if defined(CONFIG_M5272)
+	(MCF_MBAR + 0x840),
+#elif defined(CONFIG_M527x)
+	(MCF_MBAR + 0x1000),
+	(MCF_MBAR + 0x1800),
+#elif defined(CONFIG_M528x)
+	(MCF_MBAR + 0x1000),
 #else
-static volatile fec_t	*fec_hwp = &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec)
-static ushort		my_enet_addr[3];
-#endif /* CONFIG_M5272 */
+	&(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec),
+#endif
+};
+
+static unsigned char	fec_mac_default[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
 
 /*
  * Some hardware gets it MAC address out of local flash memory.
@@ -76,10 +88,12 @@
  */
 #if defined(CONFIG_NETtel)
 #define	FEC_FLASHMAC	0xf0006006
-#elif defined(CONFIG_GILBARCONAP)
+#elif defined(CONFIG_GILBARCONAP) || defined(CONFIG_SCALES)
 #define	FEC_FLASHMAC	0xf0006000
 #elif defined (CONFIG_MTD_KeyTechnology)
 #define	FEC_FLASHMAC	0xffe04000
+#elif defined(CONFIG_CANCam)
+#define	FEC_FLASHMAC	0xf0020000
 #else
 #define	FEC_FLASHMAC	0
 #endif
@@ -110,21 +124,14 @@
  * We don't need to allocate pages for the transmitter.  We just use
  * the skbuffer directly.
  */
-#if 1
-#define FEC_ENET_RX_PAGES	4
-#define FEC_ENET_RX_FRSIZE	2048
-#define FEC_ENET_RX_FRPPG	(PAGE_SIZE / FEC_ENET_RX_FRSIZE)
-#define RX_RING_SIZE		(FEC_ENET_RX_FRPPG * FEC_ENET_RX_PAGES)
-#define TX_RING_SIZE		8	/* Must be power of two */
-#define TX_RING_MOD_MASK	7	/*   for this to work */
-#else
-#define FEC_ENET_RX_PAGES	16
+#define FEC_ENET_RX_PAGES	8
 #define FEC_ENET_RX_FRSIZE	2048
 #define FEC_ENET_RX_FRPPG	(PAGE_SIZE / FEC_ENET_RX_FRSIZE)
 #define RX_RING_SIZE		(FEC_ENET_RX_FRPPG * FEC_ENET_RX_PAGES)
+#define FEC_ENET_TX_FRSIZE	2048
+#define FEC_ENET_TX_FRPPG	(PAGE_SIZE / FEC_ENET_TX_FRSIZE)
 #define TX_RING_SIZE		16	/* Must be power of two */
 #define TX_RING_MOD_MASK	15	/*   for this to work */
-#endif
 
 /* Interrupt events/masks.
 */
@@ -145,6 +152,18 @@
 #define PKT_MINBUF_SIZE		64
 #define PKT_MAXBLR_SIZE		1520
 
+
+/*
+ * The 5270/5271/5280/5282 RX control register also contains maximum frame
+ * size bits. Other FEC hardware does not, so we need to take that into
+ * account when setting it.
+ */
+#if defined(CONFIG_M527x) || defined(CONFIG_M528x)
+#define	OPT_FRAME_SIZE	(PKT_MAXBUF_SIZE << 16)
+#else
+#define	OPT_FRAME_SIZE	0
+#endif
+
 /* The FEC buffer descriptors track the ring buffers.  The rx_bd_base and
  * tx_bd_base always point to the base of the buffer descriptors.  The
  * cur_rx and cur_tx point to the currently available buffer.
@@ -154,7 +173,11 @@
  * the buffer descriptor determines the actual condition.
  */
 struct fec_enet_private {
+	/* Hardware registers of the FEC device */
+	volatile fec_t	*hwp;
+
 	/* The saved address of a sent-in-place packet/buffer, for skfree(). */
+	unsigned char *tx_bounce[TX_RING_SIZE];
 	struct	sk_buff* tx_skbuff[TX_RING_SIZE];
 	ushort	skb_cur;
 	ushort	skb_dirty;
@@ -177,12 +200,16 @@
 	struct work_struct phy_task;
 
 	uint	sequence_done;
+	uint	mii_phy_task_queued;
 
 	uint	phy_addr;
 
+	int	index;
+	int	opened;
 	int	link;
 	int	old_link;
 	int	full_duplex;
+	unsigned char mac_addr[ETH_ALEN];
 };
 
 static int fec_enet_open(struct net_device *dev);
@@ -299,6 +326,18 @@
 	bdp->cbd_bufaddr = __pa(skb->data);
 	bdp->cbd_datlen = skb->len;
 
+	/*
+	 *	On some FEC implementations data must be aligned on
+	 *	4-byte boundaries. Use bounce buffers to copy data
+	 *	and get it aligned. Ugh.
+	 */
+	if (bdp->cbd_bufaddr & 0x3) {
+		unsigned int index;
+		index = bdp - fep->tx_bd_base;
+		memcpy(fep->tx_bounce[index], (void *) bdp->cbd_bufaddr, bdp->cbd_datlen);
+		bdp->cbd_bufaddr = __pa(fep->tx_bounce[index]);
+	}
+
 	/* Save skb pointer.
 	*/
 	fep->tx_skbuff[fep->skb_cur] = skb;
@@ -407,10 +446,6 @@
 	*/
 	while ((int_events = fecp->fec_ievent) != 0) {
 		fecp->fec_ievent = int_events;
-		if ((int_events & (FEC_ENET_HBERR | FEC_ENET_BABR |
-				   FEC_ENET_BABT | FEC_ENET_EBERR)) != 0) {
-			printk("FEC ERROR %x\n", int_events);
-		}
 
 		/* Handle receive event in its own function.
 		 */
@@ -542,7 +577,7 @@
 		printk("FEC ENET: rcv is not +last\n");
 #endif
 
-	if (!opened)
+	if (!fep->opened)
 		goto rx_processing_done;
 
 	/* Check for errors. */
@@ -646,7 +681,7 @@
 	uint		mii_reg;
 
 	fep = netdev_priv(dev);
-	ep = fec_hwp;
+	ep = fep->hwp;
 	mii_reg = ep->fec_mii_data;
 	
 	if ((mip = mii_head) == NULL) {
@@ -694,7 +729,7 @@
 		}
 		else {
 			mii_head = mii_tail = mip;
-			fec_hwp->fec_mii_data = regval;
+			fep->hwp->fec_mii_data = regval;
 		}
 	}
 	else {
@@ -1029,30 +1064,69 @@
 };
 
 /* ------------------------------------------------------------------------- */
+/* Kendin KS8721BL phy                                                       */
+
+/* register definitions for the 8721 */
+
+#define MII_KS8721BL_RXERCR	21
+#define MII_KS8721BL_ICSR	22
+#define	MII_KS8721BL_PHYCR	31
+
+static phy_info_t phy_info_ks8721bl = {
+	0x00022161, 
+	"KS8721BL",
+	
+	(const phy_cmd_t []) {  /* config */  
+		{ mk_mii_read(MII_REG_CR), mii_parse_cr },
+		{ mk_mii_read(MII_REG_ANAR), mii_parse_anar },
+		{ mk_mii_end, }
+	},
+	(const phy_cmd_t []) {  /* startup */
+		{ mk_mii_write(MII_KS8721BL_ICSR, 0xff00), NULL },
+		{ mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
+		{ mk_mii_read(MII_REG_SR), mii_parse_sr }, 
+		{ mk_mii_end, }
+	},
+	(const phy_cmd_t []) { /* ack_int */
+		/* find out the current status */
+		{ mk_mii_read(MII_REG_SR), mii_parse_sr },
+		/* we only need to read ISR to acknowledge */
+		{ mk_mii_read(MII_KS8721BL_ICSR), NULL },
+		{ mk_mii_end, }
+	},
+	(const phy_cmd_t []) {  /* shutdown */
+		{ mk_mii_write(MII_KS8721BL_ICSR, 0x0000), NULL },
+		{ mk_mii_end, }
+	},
+};
+
+/* ------------------------------------------------------------------------- */
 
 static phy_info_t *phy_info[] = {
 	&phy_info_lxt970,
 	&phy_info_lxt971,
 	&phy_info_qs6612,
 	&phy_info_am79c874,
+	&phy_info_ks8721bl,
 	NULL
 };
 
 /* ------------------------------------------------------------------------- */
 
-static void
 #ifdef CONFIG_RPXCLASSIC
+static void
 mii_link_interrupt(void *dev_id);
 #else
+static irqreturn_t
 mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs);
 #endif
 
-#ifdef CONFIG_M5272
+#if defined(CONFIG_M5272)
 
 /*
  *	Code specific to Coldfire 5272 setup.
  */
-static void __inline__ fec_request_intrs(struct net_device *dev, volatile fec_t *fecp)
+static void __inline__ fec_request_intrs(struct net_device *dev)
 {
 	volatile unsigned long *icrp;
 
@@ -1076,26 +1150,29 @@
 static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
 {
 	volatile fec_t *fecp;
-	fecp = fec_hwp;
 
-	fecp->fec_r_cntrl = 0x04;
+	fecp = fep->hwp;
+	fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;
 	fecp->fec_x_cntrl = 0x00;
 
-	/* Set MII speed to 2.5 MHz
-	*/
-	fecp->fec_mii_speed = fep->phy_speed = 0x0e;
+	/*
+	 * Set MII speed to 2.5 MHz
+	 * See 5272 manual section 11.5.8: MSCR
+	 */
+	fep->phy_speed = ((((MCF_CLK / 4) / (2500000 / 10)) + 5) / 10) * 2;
+	fecp->fec_mii_speed = fep->phy_speed;
 
 	fec_restart(dev, 0);
 }
 
-static void __inline__ fec_get_mac(struct net_device *dev, struct fec_enet_private *fep)
+static void __inline__ fec_get_mac(struct net_device *dev)
 {
+	struct fec_enet_private *fep = netdev_priv(dev);
 	volatile fec_t *fecp;
-	unsigned char *eap, *iap, tmpaddr[6];
+	unsigned char *iap, tmpaddr[6];
 	int i;
 
-	fecp = fec_hwp;
-	eap = (unsigned char *) my_enet_addr;
+	fecp = fep->hwp;
 
 	if (fec_flashmac) {
 		/*
@@ -1105,18 +1182,24 @@
 		iap = fec_flashmac;
 		if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) &&
 		    (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0))
-			iap = eap;
+			iap = fec_mac_default;
 		if ((iap[0] == 0xff) && (iap[1] == 0xff) && (iap[2] == 0xff) &&
 		    (iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff))
-			iap = eap;
+			iap = fec_mac_default;
 	} else {
 		*((unsigned long *) &tmpaddr[0]) = fecp->fec_addr_low;
 		*((unsigned short *) &tmpaddr[4]) = (fecp->fec_addr_high >> 16);
 		iap = &tmpaddr[0];
 	}
 
-	for (i=0; i<6; i++)
-		dev->dev_addr[i] = *eap++ = *iap++;
+	for (i=0; i<ETH_ALEN; i++)
+		dev->dev_addr[i] = fep->mac_addr[i] = *iap++;
+
+	/* Adjust MAC if using default MAC address */
+	if (iap == fec_mac_default) {
+		dev->dev_addr[ETH_ALEN-1] = fep->mac_addr[ETH_ALEN-1] =
+			iap[ETH_ALEN-1] + fep->index;
+	}
 }
 
 static void __inline__ fec_enable_phy_intr(void)
@@ -1151,12 +1234,167 @@
 
 /* ------------------------------------------------------------------------- */
 
+#elif defined(CONFIG_M527x) || defined(CONFIG_M528x)
+
+/*
+ *	Code specific to Coldfire 5270/5271/5274/5275 and 5280/5282 setups.
+ */
+static void __inline__ fec_request_intrs(struct net_device *dev)
+{
+	struct fec_enet_private *fep;
+	int b;
+
+	fep = netdev_priv(dev);
+	b = (fep->index) ? 128 : 64;
+
+	/* Setup interrupt handlers. */
+	if (request_irq(b+23, fec_enet_interrupt, 0, "fec(TXF)", dev) != 0)
+		printk("FEC: Could not allocate FEC(TXF) IRQ(%d+23)!\n", b);
+	if (request_irq(b+24, fec_enet_interrupt, 0, "fec(TXB)", dev) != 0)
+		printk("FEC: Could not allocate FEC(TXB) IRQ(%d+24)!\n", b);
+	if (request_irq(b+25, fec_enet_interrupt, 0, "fec(TXFIFO)", dev) != 0)
+		printk("FEC: Could not allocate FEC(TXFIFO) IRQ(%d+25)!\n", b);
+	if (request_irq(b+26, fec_enet_interrupt, 0, "fec(TXCR)", dev) != 0)
+		printk("FEC: Could not allocate FEC(TXCR) IRQ(%d+26)!\n", b);
+
+	if (request_irq(b+27, fec_enet_interrupt, 0, "fec(RXF)", dev) != 0)
+		printk("FEC: Could not allocate FEC(RXF) IRQ(%d+27)!\n", b);
+	if (request_irq(b+28, fec_enet_interrupt, 0, "fec(RXB)", dev) != 0)
+		printk("FEC: Could not allocate FEC(RXB) IRQ(%d+28)!\n", b);
+
+	if (request_irq(b+29, fec_enet_interrupt, 0, "fec(MII)", dev) != 0)
+		printk("FEC: Could not allocate FEC(MII) IRQ(%d+29)!\n", b);
+	if (request_irq(b+30, fec_enet_interrupt, 0, "fec(LC)", dev) != 0)
+		printk("FEC: Could not allocate FEC(LC) IRQ(%d+30)!\n", b);
+	if (request_irq(b+31, fec_enet_interrupt, 0, "fec(HBERR)", dev) != 0)
+		printk("FEC: Could not allocate FEC(HBERR) IRQ(%d+31)!\n", b);
+	if (request_irq(b+32, fec_enet_interrupt, 0, "fec(GRA)", dev) != 0)
+		printk("FEC: Could not allocate FEC(GRA) IRQ(%d+32)!\n", b);
+	if (request_irq(b+33, fec_enet_interrupt, 0, "fec(EBERR)", dev) != 0)
+		printk("FEC: Could not allocate FEC(EBERR) IRQ(%d+33)!\n", b);
+	if (request_irq(b+34, fec_enet_interrupt, 0, "fec(BABT)", dev) != 0)
+		printk("FEC: Could not allocate FEC(BABT) IRQ(%d+34)!\n", b);
+	if (request_irq(b+35, fec_enet_interrupt, 0, "fec(BABR)", dev) != 0)
+		printk("FEC: Could not allocate FEC(BABR) IRQ(%d+35)!\n", b);
+
+	/* Unmask interrupts at ColdFire 5280/5282 interrupt controller */
+	{
+		volatile unsigned char  *icrp;
+		volatile unsigned long  *imrp;
+		int i;
+
+		b = (fep->index) ? MCFICM_INTC1 : MCFICM_INTC0;
+		icrp = (volatile unsigned char *) (MCF_IPSBAR + b +
+			MCFINTC_ICR0);
+		for (i = 23; (i < 36); i++)
+			icrp[i] = 0x23;
+
+		imrp = (volatile unsigned long *) (MCF_IPSBAR + b +
+			MCFINTC_IMRH);
+		*imrp &= ~0x0000000f;
+		imrp = (volatile unsigned long *) (MCF_IPSBAR + b +
+			MCFINTC_IMRL);
+		*imrp &= ~0xff800001;
+	}
+
+#if defined(CONFIG_M528x)
+	/* Set up gpio outputs for MII lines */
+	{
+		volatile unsigned short *gpio_paspar;
+  
+		gpio_paspar = (volatile unsigned short *) (MCF_IPSBAR +
+			0x100056);
+		*gpio_paspar = 0x0f00;
+	}
+#endif
+}
+
+static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
+{
+	volatile fec_t *fecp;
+
+	fecp = fep->hwp;
+	fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;
+	fecp->fec_x_cntrl = 0x00;
+
+	/*
+	 * Set MII speed to 2.5 MHz
+	 * See 5282 manual section 17.5.4.7: MSCR
+	 */
+	fep->phy_speed = ((((MCF_CLK / 2) / (2500000 / 10)) + 5) / 10) * 2;
+	fecp->fec_mii_speed = fep->phy_speed;
+
+	fec_restart(dev, 0);
+}
+
+static void __inline__ fec_get_mac(struct net_device *dev)
+{
+	struct fec_enet_private *fep = netdev_priv(dev);
+	volatile fec_t *fecp;
+	unsigned char *iap, tmpaddr[6];
+	int i;
+
+	fecp = fep->hwp;
+
+	if (fec_flashmac) {
+		/*
+		 * Get MAC address from FLASH.
+		 * If it is all 1's or 0's, use the default.
+		 */
+		iap = fec_flashmac;
+		if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) &&
+		    (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0))
+			iap = fec_mac_default;
+		if ((iap[0] == 0xff) && (iap[1] == 0xff) && (iap[2] == 0xff) &&
+		    (iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff))
+			iap = fec_mac_default;
+	} else {
+		*((unsigned long *) &tmpaddr[0]) = fecp->fec_addr_low;
+		*((unsigned short *) &tmpaddr[4]) = (fecp->fec_addr_high >> 16);
+		iap = &tmpaddr[0];
+	}
+
+	for (i=0; i<ETH_ALEN; i++)
+		dev->dev_addr[i] = fep->mac_addr[i] = *iap++;
+
+	/* Adjust MAC if using default MAC address */
+	if (iap == fec_mac_default) {
+		dev->dev_addr[ETH_ALEN-1] = fep->mac_addr[ETH_ALEN-1] =
+			iap[ETH_ALEN-1] + fep->index;
+	}
+}
+
+static void __inline__ fec_enable_phy_intr(void)
+{
+}
+
+static void __inline__ fec_disable_phy_intr(void)
+{
+}
+
+static void __inline__ fec_phy_ack_intr(void)
+{
+}
+
+static void __inline__ fec_localhw_setup(void)
+{
+}
+
+/*
+ *	Do not need to make region uncached on 5272.
+ */
+static void __inline__ fec_uncache(unsigned long addr)
+{
+}
+
+/* ------------------------------------------------------------------------- */
+
 #else
 
 /*
  *	Code sepcific to the MPC860T setup.
  */
-static void __inline__ fec_request_intrs(struct net_device *dev, volatile fec_t *fecp)
+static void __inline__ fec_request_intrs(struct net_device *dev)
 {
 	volatile immap_t *immap;
 
@@ -1184,13 +1422,13 @@
 #endif
 }
 
-static void __inline__ fec_get_mac(struct net_device *dev, struct fec_enet_private *fep)
+static void __inline__ fec_get_mac(struct net_device *dev)
 {
-	unsigned char *eap, *iap, tmpaddr[6];
+	struct fec_enet_private *fep = netdev_priv(dev);
+	unsigned char *iap, tmpaddr[6];
 	bd_t *bd;
 	int i;
 
-	eap = (unsigned char *)my_enet_addr;
 	iap = bd->bi_enetaddr;
 	bd = (bd_t *)__res;
 
@@ -1208,7 +1446,7 @@
 #endif
 
 	for (i=0; i<6; i++)
-		dev->dev_addr[i] = *eap++ = *iap++;
+		dev->dev_addr[i] = fep->mac_addr[i] = *iap++;
 }
 
 static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
@@ -1217,7 +1455,7 @@
 	volatile immap_t *immap;
 	volatile fec_t *fecp;
 
-	fecp = fec_hwp;
+	fecp = fep->hwp;
 	immap = (immap_t *)IMAP_ADDR;	/* pointer to internal registers */
 
 	/* Configure all of port D for MII.
@@ -1240,7 +1478,8 @@
 static void __inline__ fec_enable_phy_intr(void)
 {
 	volatile fec_t *fecp;
-	fecp = fec_hwp;
+
+	fecp = fep->hwp;
 
 	/* Enable MII command finished interrupt 
 	*/
@@ -1258,8 +1497,8 @@
 static void __inline__ fec_localhw_setup(void)
 {
 	volatile fec_t *fecp;
-	fecp = fec_hwp;
 
+	fecp = fep->hwp;
 	fecp->fec_r_hash = PKT_MAXBUF_SIZE;
 	/* Enable big endian and don't care about SDMA FC.
 	*/
@@ -1319,6 +1558,11 @@
 	struct fec_enet_private *fep = netdev_priv(dev);
 	volatile uint *s = &(fep->phy_status);
 
+	/*
+	** When we get here, phy_task is already removed from
+	** the workqueue.  It is thus safe to allow to reuse it.
+	*/
+	fep->mii_phy_task_queued = 0;
 	printk("%s: config: auto-negotiation ", dev->name);
 
 	if (*s & PHY_CONF_ANE)
@@ -1350,6 +1594,11 @@
 	struct fec_enet_private *fep = netdev_priv(dev);
 	int duplex;
 
+	/*
+	** When we get here, phy_task is already removed from
+	** the workqueue.  It is thus safe to allow to reuse it.
+	*/
+	fep->mii_phy_task_queued = 0;
 	fep->link = (fep->phy_status & PHY_STAT_LINK) ? 1 : 0;
 	mii_display_status(dev);
 	fep->old_link = fep->link;
@@ -1370,18 +1619,35 @@
 
 }
 
+/* mii_queue_relink is called in interrupt context from mii_link_interrupt */
 static void mii_queue_relink(uint mii_reg, struct net_device *dev)
 {
 	struct fec_enet_private *fep = netdev_priv(dev);
 
+	/*
+	** We cannot queue phy_task twice in the workqueue.  It
+	** would cause an endless loop in the workqueue.
+	** Fortunately, if the last mii_relink entry has not yet been
+	** executed now, it will do the job for the current interrupt,
+	** which is just what we want.
+	*/
+	if (fep->mii_phy_task_queued)
+		return;
+
+	fep->mii_phy_task_queued = 1;
 	INIT_WORK(&fep->phy_task, (void*)mii_relink, dev);
 	schedule_work(&fep->phy_task);
 }
 
+/* mii_queue_config is called in user context from fec_enet_open */
 static void mii_queue_config(uint mii_reg, struct net_device *dev)
 {
 	struct fec_enet_private *fep = netdev_priv(dev);
 
+	if (fep->mii_phy_task_queued)
+		return;
+
+	fep->mii_phy_task_queued = 1;
 	INIT_WORK(&fep->phy_task, (void*)mii_display_config, dev);
 	schedule_work(&fep->phy_task);
 }
@@ -1401,7 +1667,7 @@
 mii_discover_phy3(uint mii_reg, struct net_device *dev)
 {
 	struct fec_enet_private *fep;
-	int	i;
+	int i;
 
 	fep = netdev_priv(dev);
 	fep->phy_id |= (mii_reg & 0xffff);
@@ -1432,7 +1698,7 @@
 	uint phytype;
 
 	fep = netdev_priv(dev);
-	fecp = fec_hwp;
+	fecp = fep->hwp;
 
 	if (fep->phy_addr < 32) {
 		if ((phytype = (mii_reg & 0xffff)) != 0xffff && phytype != 0) {
@@ -1458,10 +1724,11 @@
 
 /* This interrupt occurs when the PHY detects a link change.
 */
-static void
 #ifdef CONFIG_RPXCLASSIC
+static void
 mii_link_interrupt(void *dev_id)
 #else
+static irqreturn_t
 mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 #endif
 {
@@ -1477,6 +1744,7 @@
 	mii_do_cmd(dev, fep->phy->ack_int);
 	mii_do_cmd(dev, phy_cmd_relink);  /* restart and display status */
 
+	return IRQ_HANDLED;
 }
 
 static int
@@ -1487,7 +1755,6 @@
 	/* I should reset the ring buffers here, but I don't yet know
 	 * a simple way to do that.
 	 */
-
 	fec_set_mac_address(dev);
 
 	fep->sequence_done = 0;
@@ -1506,6 +1773,12 @@
 			schedule();
 
 		mii_do_cmd(dev, fep->phy->startup);
+
+		/* Set the initial link state to true. A lot of hardware
+		 * based on this device does not implement a PHY interrupt,
+		 * so we are never notified of link change.
+		 */
+		fep->link = 1;
 	} else {
 		fep->link = 1; /* lets just try it and see */
 		/* no phy,  go full duplex,  it's most likely a hub chip */
@@ -1513,16 +1786,18 @@
 	}
 
 	netif_start_queue(dev);
-	opened = 1;
+	fep->opened = 1;
 	return 0;		/* Success */
 }
 
 static int
 fec_enet_close(struct net_device *dev)
 {
+	struct fec_enet_private *fep = netdev_priv(dev);
+
 	/* Don't know what to do yet.
 	*/
-	opened = 0;
+	fep->opened = 0;
 	netif_stop_queue(dev);
 	fec_stop(dev);
 
@@ -1558,7 +1833,7 @@
 	unsigned char hash;
 
 	fep = netdev_priv(dev);
-	ep = fec_hwp;
+	ep = fep->hwp;
 
 	if (dev->flags&IFF_PROMISC) {
 		/* Log any net taps. */
@@ -1622,18 +1897,18 @@
 static void
 fec_set_mac_address(struct net_device *dev)
 {
-	int i;
+	struct fec_enet_private *fep;
 	volatile fec_t *fecp;
 
-	fecp = fec_hwp;
-
-	/* Set our copy of the Ethernet address */
-	for (i = 0; i < (ETH_ALEN / 2); i++)
-		my_enet_addr[i] = (dev->dev_addr[i*2] << 8) | dev->dev_addr[i*2 + 1];
+	fep = netdev_priv(dev);
+	fecp = fep->hwp;
 
 	/* Set station address. */
-	fecp->fec_addr_low = (my_enet_addr[0] << 16) | my_enet_addr[1];
-	fecp->fec_addr_high = my_enet_addr[2] << 16;
+	fecp->fec_addr_low = fep->mac_addr[3] | (fep->mac_addr[2] << 8) |
+		(fep->mac_addr[1] << 16) | (fep->mac_addr[0] << 24);
+	fecp->fec_addr_high = (fep->mac_addr[5] << 16) |
+		(fep->mac_addr[4] << 24);
+
 }
 
 /* Initialize the FEC Ethernet on 860T (or ColdFire 5272).
@@ -1649,14 +1924,18 @@
 	cbd_t		*cbd_base;
 	volatile fec_t	*fecp;
 	int 		i, j;
+	static int	index = 0;
 
 	/* Only allow us to be probed once. */
-	if (found)
-		return(-ENXIO);
+	if (index >= FEC_MAX_PORTS)
+		return -ENXIO;
 
 	/* Create an Ethernet device instance.
 	*/
-	fecp = fec_hwp;
+	fecp = (volatile fec_t *) fec_hw[index];
+
+	fep->index = index;
+	fep->hwp = fecp;
 
 	/* Whack a reset.  We should wait for this.
 	*/
@@ -1679,7 +1958,7 @@
 	 * This is our default MAC address unless the user changes
 	 * it via eth_mac_addr (our dev->set_mac_addr handler).
 	 */
-	fec_get_mac(dev, fep);
+	fec_get_mac(dev);
 
 	/* Allocate memory for buffer descriptors.
 	*/
@@ -1734,7 +2013,15 @@
 	/* ...and the same for transmmit.
 	*/
 	bdp = fep->tx_bd_base;
-	for (i=0; i<TX_RING_SIZE; i++) {
+	for (i=0, j=FEC_ENET_TX_FRPPG; i<TX_RING_SIZE; i++) {
+		if (j >= FEC_ENET_TX_FRPPG) {
+			mem_addr = __get_free_page(GFP_KERNEL);
+			j = 1;
+		} else {
+			mem_addr += FEC_ENET_TX_FRSIZE;
+			j++;
+		}
+		fep->tx_bounce[i] = (unsigned char *) mem_addr;
 
 		/* Initialize the BD for every fragment in the page.
 		*/
@@ -1756,7 +2043,7 @@
 	/* Install our interrupt handlers. This varies depending on
 	 * the architecture.
 	*/
-	fec_request_intrs(dev, fecp);
+	fec_request_intrs(dev);
 
 	dev->base_addr = (unsigned long)fecp;
 
@@ -1788,7 +2075,7 @@
 	fep->phy_addr = 0;
 	mii_queue(dev, mk_mii_read(MII_REG_PHYIR1), mii_discover_phy);
 
-	found++;
+	index++;
 	return 0;
 }
 
@@ -1800,14 +2087,12 @@
 fec_restart(struct net_device *dev, int duplex)
 {
 	struct fec_enet_private *fep;
-	int i;
-	unsigned char *eap;
 	volatile cbd_t *bdp;
 	volatile fec_t *fecp;
-
-	fecp = fec_hwp;
+	int i;
 
 	fep = netdev_priv(dev);
+	fecp = fep->hwp;
 
 	/* Whack a reset.  We should wait for this.
 	*/
@@ -1826,12 +2111,13 @@
 
 	/* Set station address.
 	*/
-	fecp->fec_addr_low = (my_enet_addr[0] << 16) | my_enet_addr[1];
-	fecp->fec_addr_high = (my_enet_addr[2] << 16);
+	fecp->fec_addr_low = fep->mac_addr[3] | (fep->mac_addr[2] << 8) |
+		(fep->mac_addr[1] << 16) | (fep->mac_addr[0] << 24);
+	fecp->fec_addr_high = (fep->mac_addr[5] << 16) |
+		(fep->mac_addr[4] << 24);
 
-	eap = (unsigned char *)&my_enet_addr[0];
-	for (i=0; i<6; i++)
-		dev->dev_addr[i] = *eap++;
+	for (i=0; i<ETH_ALEN; i++)
+		dev->dev_addr[i] = fep->mac_addr[i];
 
 	/* Reset all multicast.
 	*/
@@ -1898,11 +2184,12 @@
 	/* Enable MII mode.
 	*/
 	if (duplex) {
-		fecp->fec_r_cntrl = 0x04;	/* MII enable */
-		fecp->fec_x_cntrl = 0x04;	/* FD enable */
+		fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;/* MII enable */
+		fecp->fec_x_cntrl = 0x04;		  /* FD enable */
 	}
 	else {
-		fecp->fec_r_cntrl = 0x06;	/* MII enable|No Rcv on Xmit */
+		/* MII enable|No Rcv on Xmit */
+		fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x06;
 		fecp->fec_x_cntrl = 0x00;
 	}
 	fep->full_duplex = duplex;
@@ -1923,8 +2210,8 @@
 	volatile fec_t *fecp;
 	struct fec_enet_private *fep;
 
-	fecp = fec_hwp;
 	fep = netdev_priv(dev);
+	fecp = fep->hwp;
 
 	fecp->fec_x_cntrl = 0x01;	/* Graceful transmit stop */
 
@@ -1944,29 +2231,27 @@
 	fecp->fec_mii_speed = fep->phy_speed;
 }
 
-static struct net_device *fec_dev;
-
 static int __init fec_enet_module_init(void)
 {
 	struct net_device *dev;
-	int err;
+	int i, err;
 
-	dev = alloc_etherdev(sizeof(struct fec_enet_private));
-	if (!dev)
-		return -ENOMEM;
-	err = fec_enet_init(dev);
-	if (err) {
-		free_netdev(dev);
-		return err;
-	}
-
-	if (register_netdev(dev) != 0) {
-		/* XXX: missing cleanup here */
-		free_netdev(dev);
-		return -EIO;
+	for (i = 0; (i < FEC_MAX_PORTS); i++) {
+		dev = alloc_etherdev(sizeof(struct fec_enet_private));
+		if (!dev)
+			return -ENOMEM;
+		err = fec_enet_init(dev);
+		if (err) {
+			free_netdev(dev);
+			continue;
+		}
+		if (register_netdev(dev) != 0) {
+			/* XXX: missing cleanup here */
+			free_netdev(dev);
+			return -EIO;
+		}
 	}
-	fec_dev = dev;
-	return(0);
+	return 0;
 }
 
 module_init(fec_enet_module_init);
diff -Nru a/drivers/net/fec.h b/drivers/net/fec.h
--- a/drivers/net/fec.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/fec.h	2004-12-24 13:37:00 -08:00
@@ -1,8 +1,8 @@
 /****************************************************************************/
 
 /*
- *	fec.h  --  Fast Ethernet Controller for Motorola ColdFire 5272
- *		   and 5282..
+ *	fec.h  --  Fast Ethernet Controller for Motorola ColdFire 5270,
+		   5271, 5272, 5274, 5275, 5280 and 5282.
  *
  *	(C) Copyright 2000-2003, Greg Ungerer (gerg@snapgear.com)
  *	(C) Copyright 2000-2001, Lineo (www.lineo.com)
@@ -13,7 +13,7 @@
 #define	FEC_H
 /****************************************************************************/
 
-#ifdef CONFIG_M5282
+#if defined(CONFIG_M527x) || defined(CONFIG_M528x)
 /*
  *	Just figures, Motorola would have to change the offsets for
  *	registers in the same peripheral device on different models
diff -Nru a/drivers/net/fec_8xx/fec_8xx-netta.c b/drivers/net/fec_8xx/fec_8xx-netta.c
--- a/drivers/net/fec_8xx/fec_8xx-netta.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/net/fec_8xx/fec_8xx-netta.c	2004-12-24 13:37:30 -08:00
@@ -21,12 +21,12 @@
 #include <linux/spinlock.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <asm/8xx_immap.h>
 #include <asm/pgtable.h>
 #include <asm/mpc8xx.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/commproc.h>
 
diff -Nru a/drivers/net/fec_8xx/fec_main.c b/drivers/net/fec_8xx/fec_main.c
--- a/drivers/net/fec_8xx/fec_main.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/fec_8xx/fec_main.c	2004-12-24 13:36:31 -08:00
@@ -30,12 +30,12 @@
 #include <linux/spinlock.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <asm/8xx_immap.h>
 #include <asm/pgtable.h>
 #include <asm/mpc8xx.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/commproc.h>
 #include <asm/dma-mapping.h>
diff -Nru a/drivers/net/fec_8xx/fec_mii.c b/drivers/net/fec_8xx/fec_mii.c
--- a/drivers/net/fec_8xx/fec_mii.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/net/fec_8xx/fec_mii.c	2004-12-24 13:36:56 -08:00
@@ -30,12 +30,12 @@
 #include <linux/spinlock.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <asm/8xx_immap.h>
 #include <asm/pgtable.h>
 #include <asm/mpc8xx.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/commproc.h>
 
diff -Nru a/drivers/net/fmv18x.c b/drivers/net/fmv18x.c
--- a/drivers/net/fmv18x.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/fmv18x.c	2004-12-24 13:36:17 -08:00
@@ -51,9 +51,9 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
--- a/drivers/net/forcedeth.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/forcedeth.c	2004-12-24 13:36:17 -08:00
@@ -76,6 +76,9 @@
  *			   for registers, link status and other minor fixes.
  *	0.28: 21 Jun 2004: Big cleanup, making driver mostly endian safe
  *	0.29: 31 Aug 2004: Add backup timer for link change notification.
+ *	0.30: 25 Sep 2004: rx checksum support for nf 250 Gb. Add rx reset
+ *			   into nv_close, otherwise reenabling for wol can
+ *			   cause DMA to kfree'd memory.
  *
  * Known bugs:
  * We suspect that on some hardware no TX done interrupts are generated.
@@ -87,7 +90,7 @@
  * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
  * superfluous timer interrupts from the nic.
  */
-#define FORCEDETH_VERSION		"0.29"
+#define FORCEDETH_VERSION		"0.30"
 #define DRV_NAME			"forcedeth"
 
 #include <linux/module.h>
@@ -217,6 +220,7 @@
 #define NVREG_TXRXCTL_BIT2	0x0004
 #define NVREG_TXRXCTL_IDLE	0x0008
 #define NVREG_TXRXCTL_RESET	0x0010
+#define NVREG_TXRXCTL_RXCHECK	0x0400
 	NvRegMIIStatus = 0x180,
 #define NVREG_MIISTAT_ERROR		0x0001
 #define NVREG_MIISTAT_LINKCHANGE	0x0008
@@ -313,6 +317,10 @@
 #define NV_RX_ERROR		(1<<30)
 #define NV_RX_AVAIL		(1<<31)
 
+#define NV_RX2_CHECKSUMMASK	(0x1C000000)
+#define NV_RX2_CHECKSUMOK1	(0x10000000)
+#define NV_RX2_CHECKSUMOK2	(0x14000000)
+#define NV_RX2_CHECKSUMOK3	(0x18000000)
 #define NV_RX2_DESCRIPTORVALID	(1<<29)
 #define NV_RX2_SUBSTRACT1	(1<<25)
 #define NV_RX2_ERROR1		(1<<18)
@@ -371,8 +379,15 @@
 #define POLL_WAIT	(1+HZ/100)
 #define LINK_TIMEOUT	(3*HZ)
 
+/* 
+ * desc_ver values:
+ * This field has two purposes:
+ * - Newer nics uses a different ring layout. The layout is selected by
+ *   comparing np->desc_ver with DESC_VER_xy.
+ * - It contains bits that are forced on when writing to NvRegTxRxControl.
+ */
 #define DESC_VER_1	0x0
-#define DESC_VER_2	0x02100
+#define DESC_VER_2	(0x02100|NVREG_TXRXCTL_RXCHECK)
 
 /* PHY defines */
 #define PHY_OUI_MARVELL	0x5043
@@ -438,6 +453,8 @@
 	u32 irqmask;
 	u32 desc_ver;
 
+	void __iomem *base;
+
 	/* rx specific fields.
 	 * Locking: Within irq hander or disable_irq+spin_lock(&np->lock);
 	 */
@@ -472,15 +489,15 @@
 
 static inline struct fe_priv *get_nvpriv(struct net_device *dev)
 {
-	return (struct fe_priv *) dev->priv;
+	return netdev_priv(dev);
 }
 
-static inline u8 *get_hwbase(struct net_device *dev)
+static inline u8 __iomem *get_hwbase(struct net_device *dev)
 {
-	return (u8 *) dev->base_addr;
+	return get_nvpriv(dev)->base;
 }
 
-static inline void pci_push(u8 * base)
+static inline void pci_push(u8 __iomem *base)
 {
 	/* force out pending posted writes */
 	readl(base);
@@ -495,7 +512,7 @@
 static int reg_delay(struct net_device *dev, int offset, u32 mask, u32 target,
 				int delay, int delaymax, const char *msg)
 {
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	pci_push(base);
 	do {
@@ -517,7 +534,7 @@
  */
 static int mii_rw(struct net_device *dev, int addr, int miireg, int value)
 {
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 	u32 reg;
 	int retval;
 
@@ -588,7 +605,7 @@
 static int phy_init(struct net_device *dev)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 	u32 phyinterface, phy_reserved, mii_status, mii_control, mii_control_1000,reg;
 
 	/* set advertise register */
@@ -665,7 +682,7 @@
 static void nv_start_rx(struct net_device *dev)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	dprintk(KERN_DEBUG "%s: nv_start_rx\n", dev->name);
 	/* Already running? Stop it. */
@@ -683,7 +700,7 @@
 
 static void nv_stop_rx(struct net_device *dev)
 {
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	dprintk(KERN_DEBUG "%s: nv_stop_rx\n", dev->name);
 	writel(0, base + NvRegReceiverControl);
@@ -697,7 +714,7 @@
 
 static void nv_start_tx(struct net_device *dev)
 {
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	dprintk(KERN_DEBUG "%s: nv_start_tx\n", dev->name);
 	writel(NVREG_XMITCTL_START, base + NvRegTransmitterControl);
@@ -706,7 +723,7 @@
 
 static void nv_stop_tx(struct net_device *dev)
 {
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	dprintk(KERN_DEBUG "%s: nv_stop_tx\n", dev->name);
 	writel(0, base + NvRegTransmitterControl);
@@ -721,7 +738,7 @@
 static void nv_txrx_reset(struct net_device *dev)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name);
 	writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->desc_ver, base + NvRegTxRxControl);
@@ -748,91 +765,50 @@
 	return &np->stats;
 }
 
-static int nv_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
-	u32 ethcmd;
-
-	if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
-		return -EFAULT;
-
-	switch (ethcmd) {
-	case ETHTOOL_GDRVINFO:
-	{
-		struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-		strcpy(info.driver, "forcedeth");
-		strcpy(info.version, FORCEDETH_VERSION);
-		strcpy(info.bus_info, pci_name(np->pci_dev));
-		if (copy_to_user(useraddr, &info, sizeof (info)))
-			return -EFAULT;
-		return 0;
-	}
-	case ETHTOOL_GLINK:
-	{
-		struct ethtool_value edata = { ETHTOOL_GLINK };
-
-		edata.data = !!netif_carrier_ok(dev);
-
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-	case ETHTOOL_GWOL:
-	{
-		struct ethtool_wolinfo wolinfo;
-		memset(&wolinfo, 0, sizeof(wolinfo));
-		wolinfo.supported = WAKE_MAGIC;
-
-		spin_lock_irq(&np->lock);
-		if (np->wolenabled)
-			wolinfo.wolopts = WAKE_MAGIC;
-		spin_unlock_irq(&np->lock);
-
-		if (copy_to_user(useraddr, &wolinfo, sizeof(wolinfo)))
-			return -EFAULT;
-		return 0;
-	}
-	case ETHTOOL_SWOL:
-	{
-		struct ethtool_wolinfo wolinfo;
-		if (copy_from_user(&wolinfo, useraddr, sizeof(wolinfo)))
-			return -EFAULT;
-
-		spin_lock_irq(&np->lock);
-		if (wolinfo.wolopts == 0) {
-			writel(0, base + NvRegWakeUpFlags);
-			np->wolenabled = 0;
-		}
-		if (wolinfo.wolopts & WAKE_MAGIC) {
-			writel(NVREG_WAKEUPFLAGS_ENABLE, base + NvRegWakeUpFlags);
-			np->wolenabled = 1;
-		}
-		spin_unlock_irq(&np->lock);
-		return 0;
-	}
+	strcpy(info->driver, "forcedeth");
+	strcpy(info->version, FORCEDETH_VERSION);
+	strcpy(info->bus_info, pci_name(np->pci_dev));
+}
 
-	default:
-		break;
-	}
+static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	wolinfo->supported = WAKE_MAGIC;
 
-	return -EOPNOTSUPP;
+	spin_lock_irq(&np->lock);
+	if (np->wolenabled)
+		wolinfo->wolopts = WAKE_MAGIC;
+	spin_unlock_irq(&np->lock);
 }
-/*
- * nv_ioctl: dev->do_ioctl function
- * Called with rtnl_lock held.
- */
-static int nv_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+
+static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
 {
-	switch(cmd) {
-	case SIOCETHTOOL:
-		return nv_ethtool_ioctl(dev, rq->ifr_data);
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
-	default:
-		return -EOPNOTSUPP;
+	spin_lock_irq(&np->lock);
+	if (wolinfo->wolopts == 0) {
+		writel(0, base + NvRegWakeUpFlags);
+		np->wolenabled = 0;
+	}
+	if (wolinfo->wolopts & WAKE_MAGIC) {
+		writel(NVREG_WAKEUPFLAGS_ENABLE, base + NvRegWakeUpFlags);
+		np->wolenabled = 1;
 	}
+	spin_unlock_irq(&np->lock);
+	return 0;
 }
 
+static struct ethtool_ops ops = {
+	.get_drvinfo = nv_get_drvinfo,
+	.get_link = ethtool_op_get_link,
+	.get_wol = nv_get_wol,
+	.set_wol = nv_set_wol,
+};
+
 /*
  * nv_alloc_rx: fill rx ring entries.
  * Return 1 if the allocations for the skbs failed and the
@@ -1049,7 +1025,7 @@
 static void nv_tx_timeout(struct net_device *dev)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	dprintk(KERN_DEBUG "%s: Got tx_timeout. irq: %08x\n", dev->name,
 			readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK);
@@ -1181,6 +1157,15 @@
 					goto next_pkt;
 				}
 			}
+			Flags &= NV_RX2_CHECKSUMMASK;
+			if (Flags == NV_RX2_CHECKSUMOK1 ||
+					Flags == NV_RX2_CHECKSUMOK2 ||
+					Flags == NV_RX2_CHECKSUMOK3) {
+				dprintk(KERN_DEBUG "%s: hw checksum hit!.\n", dev->name);
+				np->rx_skbuff[i]->ip_summed = CHECKSUM_UNNECESSARY;
+			} else {
+				dprintk(KERN_DEBUG "%s: hwchecksum miss!.\n", dev->name);
+			}
 		}
 		/* got a valid packet - forward it to the network core */
 		skb = np->rx_skbuff[i];
@@ -1218,7 +1203,7 @@
 static void nv_set_multicast(struct net_device *dev)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 	u32 addr[2];
 	u32 mask[2];
 	u32 pff;
@@ -1278,7 +1263,7 @@
 static int nv_update_linkspeed(struct net_device *dev)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 	int adv, lpa;
 	int newls = np->linkspeed;
 	int newdup = np->duplex;
@@ -1413,7 +1398,7 @@
 
 static void nv_link_irq(struct net_device *dev)
 {
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 	u32 miistat;
 
 	miistat = readl(base + NvRegMIIStatus);
@@ -1429,7 +1414,7 @@
 {
 	struct net_device *dev = (struct net_device *) data;
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 	u32 events;
 	int i;
 
@@ -1501,7 +1486,7 @@
 {
 	struct net_device *dev = (struct net_device *) data;
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	disable_irq(dev->irq);
 	/* FIXME: Do we need synchronize_irq(dev->irq) here? */
@@ -1518,7 +1503,7 @@
 static int nv_open(struct net_device *dev)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 	int ret, oom, i;
 
 	dprintk(KERN_DEBUG "nv_open: begin\n");
@@ -1659,7 +1644,7 @@
 static int nv_close(struct net_device *dev)
 {
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base;
+	u8 __iomem *base;
 
 	spin_lock_irq(&np->lock);
 	np->in_shutdown = 1;
@@ -1673,9 +1658,10 @@
 	spin_lock_irq(&np->lock);
 	nv_stop_tx(dev);
 	nv_stop_rx(dev);
-	base = get_hwbase(dev);
+	nv_txrx_reset(dev);
 
 	/* disable interrupts on the nic or we will lock up */
+	base = get_hwbase(dev);
 	writel(0, base + NvRegIrqMask);
 	pci_push(base);
 	dprintk(KERN_INFO "%s: Irqmask is zero again\n", dev->name);
@@ -1699,7 +1685,7 @@
 	struct net_device *dev;
 	struct fe_priv *np;
 	unsigned long addr;
-	u8 *base;
+	u8 __iomem *base;
 	int err, i;
 
 	dev = alloc_etherdev(sizeof(struct fe_priv));
@@ -1761,9 +1747,10 @@
 		np->desc_ver = DESC_VER_2;
 
 	err = -ENOMEM;
-	dev->base_addr = (unsigned long) ioremap(addr, NV_PCI_REGSZ);
-	if (!dev->base_addr)
+	np->base = ioremap(addr, NV_PCI_REGSZ);
+	if (!np->base)
 		goto out_relreg;
+	dev->base_addr = (unsigned long)np->base;
 	dev->irq = pci_dev->irq;
 	np->rx_ring = pci_alloc_consistent(pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING),
 						&np->ring_addr);
@@ -1777,7 +1764,7 @@
 	dev->get_stats = nv_get_stats;
 	dev->change_mtu = nv_change_mtu;
 	dev->set_multicast_list = nv_set_multicast;
-	dev->do_ioctl = nv_ioctl;
+	SET_ETHTOOL_OPS(dev, &ops);
 	dev->tx_timeout = nv_tx_timeout;
 	dev->watchdog_timeo = NV_WATCHDOG_TIMEO;
 
@@ -1910,7 +1897,7 @@
 {
 	struct net_device *dev = pci_get_drvdata(pci_dev);
 	struct fe_priv *np = get_nvpriv(dev);
-	u8 *base = get_hwbase(dev);
+	u8 __iomem *base = get_hwbase(dev);
 
 	unregister_netdev(dev);
 
diff -Nru a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
--- a/drivers/net/gt96100eth.c	2004-12-24 13:37:44 -08:00
+++ b/drivers/net/gt96100eth.c	2004-12-24 13:37:44 -08:00
@@ -44,9 +44,9 @@
 #include <linux/skbuff.h>
 #include <linux/delay.h>
 #include <linux/ctype.h>
+#include <linux/bitops.h>
 
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #define DESC_BE 1
diff -Nru a/drivers/net/hamachi.c b/drivers/net/hamachi.c
--- a/drivers/net/hamachi.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/net/hamachi.c	2004-12-24 13:37:31 -08:00
@@ -170,10 +170,10 @@
 #include <linux/skbuff.h>
 #include <linux/ip.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
 #include <asm/processor.h>	/* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/unaligned.h>
 #include <asm/cache.h>
@@ -565,7 +565,8 @@
 static int hamachi_close(struct net_device *dev);
 static struct net_device_stats *hamachi_get_stats(struct net_device *dev);
 static void set_rx_mode(struct net_device *dev);
-
+static struct ethtool_ops ethtool_ops;
+static struct ethtool_ops ethtool_ops_no_mii;
 
 static int __devinit hamachi_init_one (struct pci_dev *pdev,
 				    const struct pci_device_id *ent)
@@ -631,7 +632,7 @@
 				   read_eeprom(ioaddr, i), i % 16 != 15 ? " " : "\n");
 #endif
 
-	hmp = dev->priv;
+	hmp = netdev_priv(dev);
 	spin_lock_init(&hmp->lock);
 
 	hmp->mii_if.dev = dev;
@@ -725,6 +726,10 @@
 	dev->get_stats = &hamachi_get_stats;
 	dev->set_multicast_list = &set_rx_mode;
 	dev->do_ioctl = &netdev_ioctl;
+	if (chip_tbl[hmp->chip_id].flags & CanHaveMII)
+		SET_ETHTOOL_OPS(dev, &ethtool_ops);
+	else
+		SET_ETHTOOL_OPS(dev, &ethtool_ops_no_mii);
 	dev->tx_timeout = &hamachi_tx_timeout;
 	dev->watchdog_timeo = TX_TIMEOUT;
 	if (mtu)
@@ -851,7 +856,7 @@
 
 static int hamachi_open(struct net_device *dev)
 {
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int i;
 	u32 rx_int_var, tx_int_var;
@@ -1000,7 +1005,7 @@
 
 static inline int hamachi_tx(struct net_device *dev)
 {
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 
 	/* Update the dirty pointer until we find an entry that is
 		still owned by the card */
@@ -1032,7 +1037,7 @@
 static void hamachi_timer(unsigned long data)
 {
 	struct net_device *dev = (struct net_device *)data;
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int next_tick = 10*HZ;
 
@@ -1057,7 +1062,7 @@
 static void hamachi_tx_timeout(struct net_device *dev)
 {
 	int i;
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 
 	printk(KERN_WARNING "%s: Hamachi transmit timed out, status %8.8x,"
@@ -1163,7 +1168,7 @@
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
 static void hamachi_init_ring(struct net_device *dev)
 {
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 	int i;
 
 	hmp->tx_full = 0;
@@ -1255,7 +1260,7 @@
 
 static int hamachi_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 	unsigned entry;
 	u16 status;
 
@@ -1383,7 +1388,7 @@
 #endif
 
 	ioaddr = dev->base_addr;
-	hmp = dev->priv;
+	hmp = netdev_priv(dev);
 	spin_lock(&hmp->lock);
 
 	do {
@@ -1477,7 +1482,7 @@
    for clarity and better register allocation. */
 static int hamachi_rx(struct net_device *dev)
 {
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 	int entry = hmp->cur_rx % RX_RING_SIZE;
 	int boguscnt = (hmp->dirty_rx + RX_RING_SIZE) - hmp->cur_rx;
 
@@ -1693,7 +1698,7 @@
 static void hamachi_error(struct net_device *dev, int intr_status)
 {
 	long ioaddr = dev->base_addr;
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 
 	if (intr_status & (LinkChange|NegotiationChange)) {
 		if (hamachi_debug > 1)
@@ -1727,7 +1732,7 @@
 static int hamachi_close(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 	struct sk_buff *skb;
 	int i;
 
@@ -1813,7 +1818,7 @@
 static struct net_device_stats *hamachi_get_stats(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct hamachi_private *hmp = dev->priv;
+	struct hamachi_private *hmp = netdev_priv(dev);
 
 	/* We should lock this segment of code for SMP eventually, although
 	   the vulnerability window is very small and statistics are
@@ -1867,84 +1872,76 @@
 	}
 }
 
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static int check_if_running(struct net_device *dev)
 {
-	struct hamachi_private *np = dev->priv;
-	u32 ethcmd;
-		
-	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-		return -EFAULT;
+	if (!netif_running(dev))
+		return -EINVAL;
+	return 0;
+}
 
-        switch (ethcmd) {
-        case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-		strcpy(info.driver, DRV_NAME);
-		strcpy(info.version, DRV_VERSION);
-		strcpy(info.bus_info, pci_name(np->pci_dev));
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-
-	/* get settings */
-	case ETHTOOL_GSET: {
-		struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-		if (!(chip_tbl[np->chip_id].flags & CanHaveMII))
-			return -EINVAL;
-		spin_lock_irq(&np->lock);
-		mii_ethtool_gset(&np->mii_if, &ecmd);
-		spin_unlock_irq(&np->lock);
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set settings */
-	case ETHTOOL_SSET: {
-		int r;
-		struct ethtool_cmd ecmd;
-		if (!(chip_tbl[np->chip_id].flags & CanHaveMII))
-			return -EINVAL;
-		if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-			return -EFAULT;
-		spin_lock_irq(&np->lock);
-		r = mii_ethtool_sset(&np->mii_if, &ecmd);
-		spin_unlock_irq(&np->lock);
-		return r;
-	}
-	/* restart autonegotiation */
-	case ETHTOOL_NWAY_RST: {
-		if (!(chip_tbl[np->chip_id].flags & CanHaveMII))
-			return -EINVAL;
-		return mii_nway_restart(&np->mii_if);
-	}
-	/* get link status */
-	case ETHTOOL_GLINK: {
-		struct ethtool_value edata = {ETHTOOL_GLINK};
-		if (!(chip_tbl[np->chip_id].flags & CanHaveMII))
-			return -EINVAL;
-		edata.data = mii_link_ok(&np->mii_if);
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-        }
-	
-	return -EOPNOTSUPP;
+static void hamachi_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	struct hamachi_private *np = netdev_priv(dev);
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+	strcpy(info->bus_info, pci_name(np->pci_dev));
 }
 
+static int hamachi_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct hamachi_private *np = netdev_priv(dev);
+	spin_lock_irq(&np->lock);
+	mii_ethtool_gset(&np->mii_if, ecmd);
+	spin_unlock_irq(&np->lock);
+	return 0;
+}
+
+static int hamachi_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct hamachi_private *np = netdev_priv(dev);
+	int res;
+	spin_lock_irq(&np->lock);
+	res = mii_ethtool_sset(&np->mii_if, ecmd);
+	spin_unlock_irq(&np->lock);
+	return res;
+}
+
+static int hamachi_nway_reset(struct net_device *dev)
+{
+	struct hamachi_private *np = netdev_priv(dev);
+	return mii_nway_restart(&np->mii_if);
+}
+
+static u32 hamachi_get_link(struct net_device *dev)
+{
+	struct hamachi_private *np = netdev_priv(dev);
+	return mii_link_ok(&np->mii_if);
+}
+
+static struct ethtool_ops ethtool_ops = {
+	.begin = check_if_running,
+	.get_drvinfo = hamachi_get_drvinfo,
+	.get_settings = hamachi_get_settings,
+	.set_settings = hamachi_set_settings,
+	.nway_reset = hamachi_nway_reset,
+	.get_link = hamachi_get_link,
+};
+
+static struct ethtool_ops ethtool_ops_no_mii = {
+	.begin = check_if_running,
+	.get_drvinfo = hamachi_get_drvinfo,
+};
+
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	struct hamachi_private *np = dev->priv;
+	struct hamachi_private *np = netdev_priv(dev);
 	struct mii_ioctl_data *data = if_mii(rq);
 	int rc;
 
 	if (!netif_running(dev))
 		return -EINVAL;
 
-	if (cmd == SIOCETHTOOL)
-		rc = netdev_ethtool_ioctl(dev, rq->ifr_data);
-
-	else if (cmd == (SIOCDEVPRIVATE+3)) { /* set rx,tx intr params */
+	if (cmd == (SIOCDEVPRIVATE+3)) { /* set rx,tx intr params */
 		u32 *d = (u32 *)&rq->ifr_ifru;
 		/* Should add this check here or an ordinary user can do nasty
 		 * things. -KDU
@@ -1976,7 +1973,7 @@
 	struct net_device *dev = pci_get_drvdata(pdev);
 
 	if (dev) {
-		struct hamachi_private *hmp = dev->priv;
+		struct hamachi_private *hmp = netdev_priv(dev);
 
 		pci_free_consistent(pdev, RX_TOTAL_SIZE, hmp->rx_ring, 
 			hmp->rx_ring_dma);
@@ -2009,10 +2006,7 @@
 #ifdef MODULE
 	printk(version);
 #endif
-	if (pci_register_driver(&hamachi_driver) > 0)
-		return 0;
-	pci_unregister_driver(&hamachi_driver);
-	return -ENODEV;
+	return pci_register_driver(&hamachi_driver);
 }
 
 static void __exit hamachi_exit (void)
diff -Nru a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
--- a/drivers/net/hamradio/6pack.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/net/hamradio/6pack.c	2004-12-24 13:36:19 -08:00
@@ -16,7 +16,7 @@
 #include <linux/module.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
@@ -152,13 +152,13 @@
 
 	if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) {
 		sp->led_state = 0x70;
-		sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+		sp->tty->driver->write(sp->tty, &sp->led_state, 1);
 		sp->tx_enable = 1;
-		actual = sp->tty->driver->write(sp->tty, 0, sp->xbuff, sp->status2);
+		actual = sp->tty->driver->write(sp->tty, sp->xbuff, sp->status2);
 		sp->xleft -= actual;
 		sp->xhead += actual;
 		sp->led_state = 0x60;
-		sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+		sp->tty->driver->write(sp->tty, &sp->led_state, 1);
 		sp->status2 = 0;
 	} else
 		sp_start_tx_timer(sp);
@@ -229,13 +229,13 @@
 	 */
 	if (sp->duplex == 1) {
 		sp->led_state = 0x70;
-		sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+		sp->tty->driver->write(sp->tty, &sp->led_state, 1);
 		sp->tx_enable = 1;
-		actual = sp->tty->driver->write(sp->tty, 0, sp->xbuff, count);
+		actual = sp->tty->driver->write(sp->tty, sp->xbuff, count);
 		sp->xleft = count - actual;
 		sp->xhead = sp->xbuff + actual;
 		sp->led_state = 0x60;
-		sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+		sp->tty->driver->write(sp->tty, &sp->led_state, 1);
 	} else {
 		sp->xleft = count;
 		sp->xhead = sp->xbuff;
@@ -493,7 +493,7 @@
 	}
 
 	if (sp->tx_enable == 1) {
-		actual = tty->driver->write(tty, 0, sp->xhead, sp->xleft);
+		actual = tty->driver->write(tty, sp->xhead, sp->xleft);
 		sp->xleft -= actual;
 		sp->xhead += actual;
 	}
@@ -652,8 +652,8 @@
 	/* resync the TNC */
 
 	sp->led_state = 0x60;
-	sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
-	sp->tty->driver->write(sp->tty, 0, &resync_cmd, 1);
+	sp->tty->driver->write(sp->tty, &sp->led_state, 1);
+	sp->tty->driver->write(sp->tty, &resync_cmd, 1);
 
 
 	/* Start resync timer again -- the TNC might be still absent */
@@ -669,7 +669,7 @@
 {
 	unsigned char inbyte = 0xe8;
 
-	sp->tty->driver->write(sp->tty, 0, &inbyte, 1);
+	sp->tty->driver->write(sp->tty, &inbyte, 1);
 
 	del_timer(&sp->resync_t);
 	sp->resync_t.data = (unsigned long) sp;
@@ -954,9 +954,9 @@
 	} else { /* output watchdog char if idle */
 		if ((sp->status2 != 0) && (sp->duplex == 1)) {
 			sp->led_state = 0x70;
-			sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+			sp->tty->driver->write(sp->tty, &sp->led_state, 1);
 			sp->tx_enable = 1;
-			actual = sp->tty->driver->write(sp->tty, 0, sp->xbuff, sp->status2);
+			actual = sp->tty->driver->write(sp->tty, sp->xbuff, sp->status2);
 			sp->xleft -= actual;
 			sp->xhead += actual;
 			sp->led_state = 0x60;
@@ -966,7 +966,7 @@
 	}
 
 	/* needed to trigger the TNC watchdog */
-	sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+	sp->tty->driver->write(sp->tty, &sp->led_state, 1);
 
         /* if the state byte has been received, the TNC is present,
            so the resync timer can be reset. */
@@ -996,12 +996,12 @@
 			if ((sp->status & SIXP_RX_DCD_MASK) ==
 				SIXP_RX_DCD_MASK) {
 				sp->led_state = 0x68;
-				sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+				sp->tty->driver->write(sp->tty, &sp->led_state, 1);
 			}
 		} else {
 			sp->led_state = 0x60;
 			/* fill trailing bytes with zeroes */
-			sp->tty->driver->write(sp->tty, 0, &sp->led_state, 1);
+			sp->tty->driver->write(sp->tty, &sp->led_state, 1);
 			rest = sp->rx_count;
 			if (rest != 0)
 				 for (i = rest; i <= 3; i++)
diff -Nru a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c
--- a/drivers/net/hamradio/baycom_par.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/hamradio/baycom_par.c	2004-12-24 13:37:29 -08:00
@@ -83,9 +83,9 @@
 #include <linux/hdlcdrv.h>
 #include <linux/baycom.h>
 #include <linux/parport.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 /* --------------------------------------------------------------------- */
diff -Nru a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
--- a/drivers/net/hamradio/dmascc.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/hamradio/dmascc.c	2004-12-24 13:36:48 -08:00
@@ -37,7 +37,6 @@
 #include <linux/rtnetlink.h>
 #include <linux/sockios.h>
 #include <linux/workqueue.h>
-#include <linux/version.h>
 #include <asm/atomic.h>
 #include <asm/bitops.h>
 #include <asm/dma.h>
diff -Nru a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
--- a/drivers/net/hamradio/hdlcdrv.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/hamradio/hdlcdrv.c	2004-12-24 13:37:43 -08:00
@@ -51,7 +51,7 @@
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 
 #include <linux/netdevice.h>
diff -Nru a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
--- a/drivers/net/hamradio/mkiss.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/hamradio/mkiss.c	2004-12-24 13:37:29 -08:00
@@ -30,7 +30,7 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <linux/string.h>
 #include <linux/mm.h>
@@ -379,7 +379,7 @@
 	}
 	
 	ax->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-	actual = ax->tty->driver->write(ax->tty, 0, ax->xbuff, count);
+	actual = ax->tty->driver->write(ax->tty, ax->xbuff, count);
 	ax->tx_packets++;
 	ax->tx_bytes+=actual;
 	ax->dev->trans_start = jiffies;
@@ -411,7 +411,7 @@
 		return;
 	}
 
-	actual = tty->driver->write(tty, 0, ax->xhead, ax->xleft);
+	actual = tty->driver->write(tty, ax->xhead, ax->xleft);
 	ax->xleft -= actual;
 	ax->xhead += actual;
 }
@@ -518,7 +518,7 @@
 
 	ax->flags   &= (1 << AXF_INUSE);      /* Clear ESCAPE & ERROR flags */
 
-	ax->buflock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&ax->buflock);
 
 	netif_start_queue(dev);
 	return 0;
diff -Nru a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
--- a/drivers/net/hamradio/scc.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/hamradio/scc.c	2004-12-24 13:37:18 -08:00
@@ -173,6 +173,7 @@
 #include <linux/kernel.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/bitops.h>
 
 #include <net/ax25.h>
 
@@ -180,7 +181,6 @@
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 
 #include "z8530.h"
 
diff -Nru a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
--- a/drivers/net/hamradio/yam.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/net/hamradio/yam.c	2004-12-24 13:37:04 -08:00
@@ -50,7 +50,7 @@
 #include <linux/if.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <linux/interrupt.h>
diff -Nru a/drivers/net/hp100.c b/drivers/net/hp100.c
--- a/drivers/net/hp100.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/hp100.c	2004-12-24 13:36:47 -08:00
@@ -114,8 +114,8 @@
 #include <linux/config.h>	/* for CONFIG_PCI */
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include "hp100.h"
@@ -161,7 +161,7 @@
 	u_char bus;
 	struct pci_dev *pci_dev;
 	short mem_mapped;	/* memory mapped access */
-	void *mem_ptr_virt;	/* virtual memory mapped area, maybe NULL */
+	void __iomem *mem_ptr_virt;	/* virtual memory mapped area, maybe NULL */
 	unsigned long mem_ptr_phys;	/* physical memory mapped area */
 	short lan_type;		/* 10Mb/s, 100Mb/s or -1 (error) */
 	int hub_status;		/* was login to hub successful? */
@@ -435,7 +435,7 @@
 	u_short local_mode, lsw;
 	short mem_mapped;
 	unsigned long mem_ptr_phys;
-	void **mem_ptr_virt;
+	void __iomem *mem_ptr_virt;
 	struct hp100_private *lp;
 
 #ifdef HP100_DEBUG_B
diff -Nru a/drivers/net/hplance.c b/drivers/net/hplance.c
--- a/drivers/net/hplance.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/hplance.c	2004-12-24 13:36:48 -08:00
@@ -40,9 +40,7 @@
 
 /* Our private data structure */
 struct hplance_private {
-  struct lance_private lance;
-  unsigned int scode;
-  void *base;
+	struct lance_private lance;
 };
 
 /* function prototypes... This is easy because all the grot is in the
@@ -50,89 +48,96 @@
  * plus board-specific init, open and close actions. 
  * Oh, and we need to tell the generic code how to read and write LANCE registers...
  */
-static void hplance_init(struct net_device *dev, int scode);
-static int hplance_open(struct net_device *dev);
-static int hplance_close(struct net_device *dev);
+static int __devinit hplance_init_one(struct dio_dev *d,
+				const struct dio_device_id *ent);
+static void __devinit hplance_init(struct net_device *dev, 
+				struct dio_dev *d);
+static void __devexit hplance_remove_one(struct dio_dev *d);
 static void hplance_writerap(void *priv, unsigned short value);
 static void hplance_writerdp(void *priv, unsigned short value);
 static unsigned short hplance_readrdp(void *priv);
+static int hplance_open(struct net_device *dev);
+static int hplance_close(struct net_device *dev);
 
-#ifdef MODULE
-static struct hplance_private *root_hplance_dev;
-#endif
+static struct dio_device_id hplance_dio_tbl[] = {
+	{ DIO_ID_LAN },
+	{ 0 }
+};
 
-static void cleanup_card(struct net_device *dev)
-{
-        struct hplance_private *lp = netdev_priv(dev);
-	dio_unconfig_board(lp->scode);
-}
+static struct dio_driver hplance_driver = {
+	.name      = "hplance",
+	.id_table  = hplance_dio_tbl,
+	.probe     = hplance_init_one,
+	.remove    = __devexit_p(hplance_remove_one),
+};
 
 /* Find all the HP Lance boards and initialise them... */
-struct net_device * __init hplance_probe(int unit)
+static int __devinit hplance_init_one(struct dio_dev *d,
+				const struct dio_device_id *ent)
 {
 	struct net_device *dev;
-
-        if (!MACH_IS_HP300)
-                return ERR_PTR(-ENODEV);
+	int err = -ENOMEM;
 
 	dev = alloc_etherdev(sizeof(struct hplance_private));
 	if (!dev)
-		return ERR_PTR(-ENOMEM);
+		goto out;
 
-	if (unit >= 0) {
-		sprintf(dev->name, "eth%d", unit);
-		netdev_boot_setup_check(dev);
-	}
+	err = -EBUSY;
+	if (!request_mem_region(dio_resource_start(d),
+				dio_resource_len(d), d->name))
+		goto out_free_netdev;
+
+	hplance_init(dev, d);
+	err = register_netdev(dev);
+	if (err)
+		goto out_release_mem_region;
+
+	dio_set_drvdata(d, dev);
+	return 0;
+
+ out_release_mem_region:
+	release_mem_region(dio_resource_start(d), dio_resource_len(d));
+ out_free_netdev:
+	free_netdev(dev);
+ out:
+	return err;
+}
 
-	SET_MODULE_OWNER(dev);
-        
-        /* Isn't DIO nice? */
-        for(;;)
-        {
-                int scode = dio_find(DIO_ID_LAN);
-                                
-                if (!scode)
-                        break;
-                
-		dio_config_board(scode);
-                hplance_init(dev, scode);
-		if (!register_netdev(dev)) {
-			struct hplance_private *lp = netdev_priv(dev);
-			lp->next_module = root_hplance_dev;
-			root_hplance_dev = lp;
-			return dev;
-		}
-		cleanup_card(dev);
-        }
+static void __devexit hplance_remove_one(struct dio_dev *d)
+{
+	struct net_device *dev = dio_get_drvdata(d);
+
+	unregister_netdev(dev);
+	release_mem_region(dio_resource_start(d), dio_resource_len(d));
 	free_netdev(dev);
-	return ERR_PTR(-ENODEV);
 }
 
-/* Initialise a single lance board at the given select code */
-static void __init hplance_init(struct net_device *dev, int scode)
+/* Initialise a single lance board at the given DIO device */
+static void __init hplance_init(struct net_device *dev, struct dio_dev *d)
 {
-        const char *name = dio_scodetoname(scode);
-        void *va = dio_scodetoviraddr(scode);
+        unsigned long va = (d->resource.start + DIO_VIRADDRBASE);
         struct hplance_private *lp;
         int i;
         
-        printk("%s: %s; select code %d, addr", dev->name, name, scode);
+        printk(KERN_INFO "%s: %s; select code %d, addr", dev->name, d->name, d->scode);
 
         /* reset the board */
         out_8(va+DIO_IDOFF, 0xff);
         udelay(100);                              /* ariba! ariba! udelay! udelay! */
 
         /* Fill the dev fields */
-        dev->base_addr = (unsigned long)va;
+        dev->base_addr = va;
         dev->open = &hplance_open;
         dev->stop = &hplance_close;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+        dev->poll_controller = lance_poll;
+#endif
         dev->hard_start_xmit = &lance_start_xmit;
         dev->get_stats = &lance_get_stats;
         dev->set_multicast_list = &lance_set_multicast;
         dev->dma = 0;
         
-        for (i=0; i<6; i++)
-        {
+        for (i=0; i<6; i++) {
                 /* The NVRAM holds our ethernet address, one nibble per byte,
                  * at bytes NVRAMOFF+1,3,5,7,9...
                  */
@@ -142,12 +147,12 @@
         }
         
         lp = netdev_priv(dev);
-        lp->lance.name = (char*)name;                   /* discards const, shut up gcc */
-        lp->lance.ll = (struct lance_regs *)(va + HPLANCE_REGOFF);
+        lp->lance.name = (char*)d->name;                /* discards const, shut up gcc */
+        lp->lance.base = va;
         lp->lance.init_block = (struct lance_init_block *)(va + HPLANCE_MEMOFF); /* CPU addr */
         lp->lance.lance_init_block = 0;                 /* LANCE addr of same RAM */
         lp->lance.busmaster_regval = LE_C3_BSWP;        /* we're bigendian */
-        lp->lance.irq = dio_scodetoipl(scode);
+        lp->lance.irq = d->ipl;
         lp->lance.writerap = hplance_writerap;
         lp->lance.writerdp = hplance_writerdp;
         lp->lance.readrdp = hplance_readrdp;
@@ -155,8 +160,6 @@
         lp->lance.lance_log_tx_bufs = LANCE_LOG_TX_BUFFERS;
         lp->lance.rx_ring_mod_mask = RX_RING_MOD_MASK;
         lp->lance.tx_ring_mod_mask = TX_RING_MOD_MASK;
-        lp->scode = scode;
-	lp->base = va;
 	printk(", irq %d\n", lp->lance.irq);
 }
 
@@ -165,78 +168,64 @@
  */
 static void hplance_writerap(void *priv, unsigned short value)
 {
-	struct hplance_private *lp = (struct hplance_private *)priv;
-        struct hplance_reg *hpregs = (struct hplance_reg *)lp->base;
-        do {
-                lp->lance.ll->rap = value;
-        } while ((hpregs->status & LE_ACK) == 0);
+	struct lance_private *lp = (struct lance_private *)priv;
+	do {
+		out_be16(lp->base + HPLANCE_REGOFF + LANCE_RAP, value);
+	} while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0);
 }
 
 static void hplance_writerdp(void *priv, unsigned short value)
 {
-	struct hplance_private *lp = (struct hplance_private *)priv;
-        struct hplance_reg *hpregs = (struct hplance_reg *)lp->base;
-        do {
-                lp->lance.ll->rdp = value;
-        } while ((hpregs->status & LE_ACK) == 0);
+	struct lance_private *lp = (struct lance_private *)priv;
+	do {
+		out_be16(lp->base + HPLANCE_REGOFF + LANCE_RDP, value);
+	} while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0);
 }
 
 static unsigned short hplance_readrdp(void *priv)
 {
-        unsigned short val;
-	struct hplance_private *lp = (struct hplance_private *)priv;
-        struct hplance_reg *hpregs = (struct hplance_reg *)lp->base;
-        do {
-                val = lp->lance.ll->rdp;
-        } while ((hpregs->status & LE_ACK) == 0);
-        return val;
+	struct lance_private *lp = (struct lance_private *)priv;
+	__u16 value;
+	do {
+		value = in_be16(lp->base + HPLANCE_REGOFF + LANCE_RDP);
+	} while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0);
+	return value;
 }
 
 static int hplance_open(struct net_device *dev)
 {
         int status;
-        struct hplance_private *lp = netdev_priv(dev);
-        struct hplance_reg *hpregs = (struct hplance_reg *)lp->base;
+        struct lance_private *lp = netdev_priv(dev);
         
         status = lance_open(dev);                 /* call generic lance open code */
         if (status)
                 return status;
         /* enable interrupts at board level. */
-        out_8(&(hpregs->status), LE_IE);
+        out_8(lp->base + HPLANCE_STATUS, LE_IE);
 
         return 0;
 }
 
 static int hplance_close(struct net_device *dev)
 {
-        struct hplance_private *lp = netdev_priv(dev);
-        struct hplance_reg *hpregs = (struct hplance_reg *)lp->base;
-        out_8(&(hpregs->status), 8);              /* disable interrupts at boardlevel */
+        struct lance_private *lp = netdev_priv(dev);
+
+        out_8(lp->base + HPLANCE_STATUS, 0);	/* disable interrupts at boardlevel */
         lance_close(dev);
         return 0;
 }
 
-#ifdef MODULE
-MODULE_LICENSE("GPL");
-int init_module(void)
+int __init hplance_init_module(void)
 {
-	int found = 0;
-	while (!IS_ERR(hplance_probe(-1)))
-		found++;
-	return found ? 0 : -ENODEV;
+	return dio_module_init(&hplance_driver);
 }
 
-void cleanup_module(void)
+void __exit hplance_cleanup_module(void)
 {
-        /* Walk the chain of devices, unregistering them */
-        struct hplance_private *lp;
-        while (root_hplance_dev) {
-                lp = root_hplance_dev->next_module;
-                unregister_netdev(root_lance_dev->dev);
-                cleanup_card(root_lance_dev->dev);
-                free_netdev(root_lance_dev->dev);
-                root_lance_dev = lp;
-        }
+        dio_unregister_driver(&hplance_driver);
 }
 
-#endif /* MODULE */
+module_init(hplance_init_module);
+module_exit(hplance_cleanup_module);
+
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/net/hplance.h b/drivers/net/hplance.h
--- a/drivers/net/hplance.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/hplance.h	2004-12-24 13:36:17 -08:00
@@ -4,15 +4,10 @@
  */
 
 /* Registers */
-struct hplance_reg
-{
-        u_char pad0;
-        volatile u_char id;                       /* DIO register: ID byte */
-        u_char pad1;
-        volatile u_char status;                   /* DIO register: interrupt enable */
-};
+#define HPLANCE_ID		0x01		/* DIO register: ID byte */
+#define HPLANCE_STATUS		0x03		/* DIO register: interrupt enable/status */
 
-/* Control and status bits for the hplance->status register */
+/* Control and status bits for the status register */
 #define LE_IE 0x80                                /* interrupt enable */
 #define LE_IR 0x40                                /* interrupt requested */
 #define LE_LOCK 0x08                              /* lock status register */
@@ -25,7 +20,7 @@
 /* These are the offsets for the DIO regs (hplance_reg), lance_ioreg,
  * memory and NVRAM:
  */
-#define HPLANCE_IDOFF 0                           /* board baseaddr, struct hplance_reg */
-#define HPLANCE_REGOFF 0x4000                     /* struct lance_regs */
+#define HPLANCE_IDOFF 0                           /* board baseaddr */
+#define HPLANCE_REGOFF 0x4000                     /* lance registers */
 #define HPLANCE_MEMOFF 0x8000                     /* struct lance_init_block */
 #define HPLANCE_NVRAMOFF 0xC008                   /* etheraddress as one *nibble* per byte */
diff -Nru a/drivers/net/hydra.c b/drivers/net/hydra.c
--- a/drivers/net/hydra.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/hydra.c	2004-12-24 13:36:48 -08:00
@@ -23,8 +23,8 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/amigaints.h>
diff -Nru a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
--- a/drivers/net/ibm_emac/ibm_emac_core.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/ibm_emac/ibm_emac_core.c	2004-12-24 13:36:17 -08:00
@@ -40,9 +40,9 @@
 #include <linux/dma-mapping.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
+#include <linux/bitops.h>
 
 #include <asm/processor.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
@@ -620,7 +620,7 @@
 
 static int emac_rx_clean(struct net_device *dev)
 {
-	int i, b, bnum, buf[6];
+	int i, b, bnum = 0, buf[6];
 	int error, frame_length;
 	struct ocp_enet_private *fep = dev->priv;
 	unsigned short ctrl;
@@ -1021,7 +1021,6 @@
 static int emac_adjust_to_link(struct ocp_enet_private *fep)
 {
 	emac_t *emacp = fep->emacp;
-	struct ibm_ocp_rgmii *rgmii;
 	unsigned long mode_reg;
 	int full_duplex, speed;
 
@@ -1038,21 +1037,23 @@
 		speed = fep->phy_mii.speed;
 	}
 
-	if (fep->rgmii_dev)
-		rgmii = RGMII_PRIV(fep->rgmii_dev);
 
 	/* set speed (default is 10Mb) */
 	switch (speed) {
 	case SPEED_1000:
 		mode_reg |= EMAC_M1_JUMBO_ENABLE | EMAC_M1_RFS_16K;
-		if ((rgmii->mode[fep->rgmii_input] == RTBI)
-		    || (rgmii->mode[fep->rgmii_input] == TBI))
-			mode_reg |= EMAC_M1_MF_1000GPCS;
-		else
-			mode_reg |= EMAC_M1_MF_1000MBPS;
-		if (fep->rgmii_dev)
+		if (fep->rgmii_dev) {
+			struct ibm_ocp_rgmii *rgmii = RGMII_PRIV(fep->rgmii_dev);
+
+			if ((rgmii->mode[fep->rgmii_input] == RTBI)
+			    || (rgmii->mode[fep->rgmii_input] == TBI))
+				mode_reg |= EMAC_M1_MF_1000GPCS;
+			else
+				mode_reg |= EMAC_M1_MF_1000MBPS;
+
 			emac_rgmii_port_speed(fep->rgmii_dev, fep->rgmii_input,
 					      1000);
+		}
 		break;
 	case SPEED_100:
 		mode_reg |= EMAC_M1_MF_100MBPS | EMAC_M1_RFS_4K;
diff -Nru a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
--- a/drivers/net/ibm_emac/ibm_emac_mal.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h	2004-12-24 13:36:18 -08:00
@@ -83,6 +83,7 @@
 		GET_MAL0_STANZA(dcrn) \
 		GET_MAL1_STANZA(dcrn) \
 	default: \
+		x = 0; \
 		BUG(); \
 	} \
 x; })
diff -Nru a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
--- a/drivers/net/ibmlana.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/ibmlana.c	2004-12-24 13:36:31 -08:00
@@ -88,9 +88,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/processor.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #define _IBM_LANA_DRIVER_
@@ -885,14 +885,6 @@
 	return &priv->stat;
 }
 
-/* we don't support runtime reconfiguration, since am MCA card can
-   be unambigously identified by its POS registers. */
-
-static int ibmlana_config(struct net_device *dev, struct ifmap *map)
-{
-	return 0;
-}
-
 /* switch receiver mode. */
 
 static void ibmlana_set_multicast_list(struct net_device *dev)
@@ -984,7 +976,6 @@
 
 	dev->open = ibmlana_open;
 	dev->stop = ibmlana_close;
-	dev->set_config = ibmlana_config;
 	dev->hard_start_xmit = ibmlana_tx;
 	dev->do_ioctl = NULL;
 	dev->get_stats = ibmlana_stats;
diff -Nru a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
--- a/drivers/net/ibmveth.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/ibmveth.c	2004-12-24 13:36:16 -08:00
@@ -96,6 +96,7 @@
 static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter);
 static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter);
 static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*);
 
 #ifdef CONFIG_PROC_FS
 #define IBMVETH_PROC_DIR "ibmveth"
@@ -104,7 +105,7 @@
 
 static const char ibmveth_driver_name[] = "ibmveth";
 static const char ibmveth_driver_string[] = "IBM i/pSeries Virtual Ethernet Driver";
-#define ibmveth_driver_version "1.02"
+#define ibmveth_driver_version "1.03"
 
 MODULE_AUTHOR("Santiago Leon <santil@us.ibm.com>");
 MODULE_DESCRIPTION("IBM i/pSeries Virtual Ethernet Driver");
@@ -271,6 +272,8 @@
 	adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8);
 
 	atomic_inc(&adapter->not_replenishing);
+
+	ibmveth_schedule_replenishing(adapter);
 }
 
 /* kick the replenish tasklet if we need replenishing and it isn't already running */
@@ -598,7 +601,7 @@
 }
 
 static u32 netdev_get_link(struct net_device *dev) {
-	return 0;
+	return 1;
 }
 
 static struct ethtool_ops netdev_ethtool_ops = {
diff -Nru a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
--- a/drivers/net/irda/au1k_ir.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/irda/au1k_ir.c	2004-12-24 13:37:19 -08:00
@@ -28,9 +28,9 @@
 #include <linux/rtnetlink.h>
 #include <linux/interrupt.h>
 #include <linux/pm.h>
+#include <linux/bitops.h>
 
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/au1000.h>
 #if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100)
diff -Nru a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
--- a/drivers/net/irda/irda-usb.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/irda/irda-usb.c	2004-12-24 13:36:55 -08:00
@@ -52,7 +52,7 @@
 /*------------------------------------------------------------------*/
 
 #include <linux/module.h>
-
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/init.h>
@@ -88,10 +88,10 @@
 
 /*
  * Important note :
- * Devices based on the SigmaTel chipset (0x66f, 0x4200) are not compliant
- * with the USB-IrDA specification (and actually very very different), and
- * there is no way this driver can support those devices, apart from
- * a complete rewrite...
+ * Devices based on the SigmaTel chipset (0x66f, 0x4200) are not designed
+ * using the "USB-IrDA specification" (yes, there exist such a thing), and
+ * therefore not supported by this driver (don't add them above).
+ * There is a Linux driver, stir4200, that support those USB devices.
  * Jean II
  */
 
@@ -1007,9 +1007,9 @@
 	}
 	/* Cancel Tx and speed URB - need to be synchronous to avoid races */
 	self->tx_urb->transfer_flags &= ~URB_ASYNC_UNLINK;
-	usb_unlink_urb(self->tx_urb);
+	usb_kill_urb(self->tx_urb);
 	self->speed_urb->transfer_flags &= ~URB_ASYNC_UNLINK;
-	usb_unlink_urb(self->speed_urb);
+	usb_kill_urb(self->speed_urb);
 
 	/* Stop and remove instance of IrLAP */
 	if (self->irlap)
@@ -1520,9 +1520,9 @@
 		/* Cancel Tx and speed URB.
 		 * Toggle flags to make sure it's synchronous. */
 		self->tx_urb->transfer_flags &= ~URB_ASYNC_UNLINK;
-		usb_unlink_urb(self->tx_urb);
+		usb_kill_urb(self->tx_urb);
 		self->speed_urb->transfer_flags &= ~URB_ASYNC_UNLINK;
-		usb_unlink_urb(self->speed_urb);
+		usb_kill_urb(self->speed_urb);
 	}
 
 	/* Cleanup the device stuff */
@@ -1593,7 +1593,7 @@
 /*
  * Module parameters
  */
-MODULE_PARM(qos_mtt_bits, "i");
+module_param(qos_mtt_bits, int, 0);
 MODULE_PARM_DESC(qos_mtt_bits, "Minimum Turn Time");
 MODULE_AUTHOR("Roman Weissgaerber <weissg@vienna.at>, Dag Brattli <dag@brattli.net> and Jean Tourrilhes <jt@hpl.hp.com>");
 MODULE_DESCRIPTION("IrDA-USB Dongle Driver"); 
diff -Nru a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c
--- a/drivers/net/irda/irport.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/irda/irport.c	2004-12-24 13:37:01 -08:00
@@ -51,9 +51,9 @@
 #include <linux/spinlock.h>
 #include <linux/delay.h>
 #include <linux/rtnetlink.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include <net/irda/irda.h>
diff -Nru a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
--- a/drivers/net/irda/irtty-sir.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/irda/irtty-sir.c	2004-12-24 13:36:16 -08:00
@@ -234,7 +234,7 @@
 	}
 	else
 		writelen = len;
-	return tty->driver->write(tty, 0, ptr, writelen);
+	return tty->driver->write(tty, ptr, writelen);
 }
 
 /* ------------------------------------------------------- */
diff -Nru a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
--- a/drivers/net/irda/nsc-ircc.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/irda/nsc-ircc.c	2004-12-24 13:36:16 -08:00
@@ -351,8 +351,9 @@
 	}
 	MESSAGE("IrDA: Registered device %s\n", dev->name);
 
-	/* Check if user has supplied the dongle id or not */
-	if (!dongle_id) {
+	/* Check if user has supplied a valid dongle id or not */
+	if ((dongle_id <= 0) ||
+	    (dongle_id >= (sizeof(dongle_types) / sizeof(dongle_types[0]))) ) {
 		dongle_id = nsc_ircc_read_dongle_id(self->io.fir_base);
 		
 		MESSAGE("%s, Found dongle: %s\n", driver_name,
diff -Nru a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
--- a/drivers/net/irda/sa1100_ir.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/irda/sa1100_ir.c	2004-12-24 13:36:47 -08:00
@@ -39,19 +39,7 @@
 #include <asm/irq.h>
 #include <asm/dma.h>
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
-
-#include <asm/arch/assabet.h>
-#include <asm/arch/h3600.h>
-#include <asm/arch/yopy.h>
-
-#ifndef GPIO_IRDA_FIR
-#define GPIO_IRDA_FIR		(0)
-#endif
-
-#ifndef GPIO_IRDA_POWER
-#define GPIO_IRDA_POWER		(0)
-#endif
+#include <asm/mach/irda.h>
 
 static int power_level = 3;
 static int tx_lpm;
@@ -75,6 +63,7 @@
 
 	struct net_device_stats	stats;
 	struct device		*dev;
+	struct irda_platform_data *pdata;
 	struct irlap_cb		*irlap;
 	struct qos_info		qos;
 
@@ -170,12 +159,8 @@
 		Ser2UTSR0 = UTSR0_REB | UTSR0_RBB | UTSR0_RID;
 		Ser2UTCR3 = UTCR3_RIE | UTCR3_RXE | UTCR3_TXE;
 
-		if (machine_is_assabet())
-			ASSABET_BCR_clear(ASSABET_BCR_IRDA_FSEL);
-		if (machine_is_h3xxx())
-			clr_h3600_egpio(IPAQ_EGPIO_IR_FSEL);
-		if (machine_is_yopy())
-			PPSR &= ~GPIO_IRDA_FIR;
+		if (si->pdata->set_speed)
+			si->pdata->set_speed(si->dev, speed);
 
 		si->speed = speed;
 
@@ -194,12 +179,8 @@
 
 		si->speed = speed;
 
-		if (machine_is_assabet())
-			ASSABET_BCR_set(ASSABET_BCR_IRDA_FSEL);
-		if (machine_is_h3xxx())
-			set_h3600_egpio(IPAQ_EGPIO_IR_FSEL);
-		if (machine_is_yopy())
-			PPSR |= GPIO_IRDA_FIR;
+		if (si->pdata->set_speed)
+			si->pdata->set_speed(si->dev, speed);
 
 		sa1100_irda_rx_alloc(si);
 		sa1100_irda_rx_dma_start(si);
@@ -216,51 +197,6 @@
 }
 
 /*
- * This sets the IRDA power level on the Assabet.
- */
-static inline int
-sa1100_irda_set_power_assabet(struct sa1100_irda *si, unsigned int state)
-{
-	static unsigned int bcr_state[4] = {
-		ASSABET_BCR_IRDA_MD0,
-		ASSABET_BCR_IRDA_MD1|ASSABET_BCR_IRDA_MD0,
-		ASSABET_BCR_IRDA_MD1,
-		0
-	};
-
-	if (state < 4) {
-		state = bcr_state[state];
-		ASSABET_BCR_clear(state ^ (ASSABET_BCR_IRDA_MD1|
-					   ASSABET_BCR_IRDA_MD0));
-		ASSABET_BCR_set(state);
-	}
-	return 0;
-}
-
-/*
- * This turns the IRDA power on or off on the Compaq H3600
- */
-static inline int
-sa1100_irda_set_power_h3600(struct sa1100_irda *si, unsigned int state)
-{
-	assign_h3600_egpio( IPAQ_EGPIO_IR_ON, state );
-	return 0;
-}
-
-/*
- * This turns the IRDA power on or off on the Yopy
- */
-static inline int
-sa1100_irda_set_power_yopy(struct sa1100_irda *si, unsigned int state)
-{
-	if (state)
-		PPSR &= ~GPIO_IRDA_POWER;
-	else
-		PPSR |= GPIO_IRDA_POWER;
-	return 0;
-}
-
-/*
  * Control the power state of the IrDA transmitter.
  * State:
  *  0 - off
@@ -274,14 +210,8 @@
 __sa1100_irda_set_power(struct sa1100_irda *si, unsigned int state)
 {
 	int ret = 0;
-
-	if (machine_is_assabet())
-		ret = sa1100_irda_set_power_assabet(si, state);
-	if (machine_is_h3xxx())
-		ret = sa1100_irda_set_power_h3600(si, state);
-	if (machine_is_yopy())
-		ret = sa1100_irda_set_power_yopy(si, state);
-
+	if (si->pdata->set_power)
+		ret = si->pdata->set_power(si->dev, state);
 	return ret;
 }
 
@@ -304,11 +234,8 @@
 	/*
 	 * Ensure that the ports for this device are setup correctly.
 	 */
-	if (machine_is_yopy()) {
-		PPDR |= GPIO_IRDA_POWER | GPIO_IRDA_FIR;
-		PPSR |= GPIO_IRDA_POWER | GPIO_IRDA_FIR;
-		PSDR |= GPIO_IRDA_POWER | GPIO_IRDA_FIR;
-	}
+	if (si->pdata->startup)
+		si->pdata->startup(si->dev);
 
 	/*
 	 * Configure PPC for IRDA - we want to drive TXD2 low.
@@ -333,10 +260,15 @@
 	Ser2UTSR0 = UTSR0_REB | UTSR0_RBB | UTSR0_RID;
 
 	ret = sa1100_irda_set_speed(si, si->speed = 9600);
-	if (ret)
-		return ret;
+	if (ret) {
+		Ser2UTCR3 = 0;
+		Ser2HSCR0 = 0;
 
-	return 0;
+		if (si->pdata->shutdown)
+			si->pdata->shutdown(si->dev);
+	}
+
+	return ret;
 }
 
 static void sa1100_irda_shutdown(struct sa1100_irda *si)
@@ -350,6 +282,9 @@
 	/* Disable the port. */
 	Ser2UTCR3 = 0;
 	Ser2HSCR0 = 0;
+
+	if (si->pdata->shutdown)
+		si->pdata->shutdown(si->dev);
 }
 
 #ifdef CONFIG_PM
@@ -959,6 +894,9 @@
 	unsigned int baudrate_mask;
 	int err;
 
+	if (!pdev->dev.platform_data)
+		return -EINVAL;
+
 	err = request_mem_region(__PREG(Ser2UTCR0), 0x24, "IrDA") ? 0 : -EBUSY;
 	if (err)
 		goto err_mem_1;
@@ -975,6 +913,7 @@
 
 	si = dev->priv;
 	si->dev = &pdev->dev;
+	si->pdata = pdev->dev.platform_data;
 
 	/*
 	 * Initialise the HP-SIR buffers
@@ -1028,7 +967,7 @@
 
 	err = register_netdev(dev);
 	if (err == 0)
-		dev_set_drvdata(&pdev->dev, si);
+		dev_set_drvdata(&pdev->dev, dev);
 
 	if (err) {
  err_mem_5:
@@ -1074,15 +1013,8 @@
 	.resume		= sa1100_irda_resume,
 };
 
-static struct platform_device sa1100ir_device = {
-	.name		= "sa11x0-ir",
-	.id		= 0,
-};
-
 static int __init sa1100_irda_init(void)
 {
-	int ret;
-
 	/*
 	 * Limit power level a sensible range.
 	 */
@@ -1091,19 +1023,12 @@
 	if (power_level > 3)
 		power_level = 3;
 
-	ret = driver_register(&sa1100ir_driver);
-	if (ret == 0) {
-		ret = platform_device_register(&sa1100ir_device);
-		if (ret)
-			driver_unregister(&sa1100ir_driver);
-	}
-	return ret;
+	return driver_register(&sa1100ir_driver);
 }
 
 static void __exit sa1100_irda_exit(void)
 {
 	driver_unregister(&sa1100ir_driver);
-	platform_device_unregister(&sa1100ir_device);
 }
 
 module_init(sa1100_irda_init);
diff -Nru a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
--- a/drivers/net/irda/stir4200.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/irda/stir4200.c	2004-12-24 13:36:31 -08:00
@@ -520,11 +520,6 @@
  found:
 	pr_debug("speed change from %d to %d\n", stir->speed, speed);
 
-	/* sometimes needed to get chip out of stuck state */
-	err = usb_reset_device(stir->usbdev);
-	if (err)
-		goto out;
-
 	/* Reset modulator */
 	err = write_reg(stir, REG_CTRL1, CTRL1_SRESET);
 	if (err)
@@ -575,7 +570,7 @@
  */
 static int stir_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
-	struct stir_cb *stir = netdev->priv;
+	struct stir_cb *stir = netdev_priv(netdev);
 
 	netif_stop_queue(netdev);
 
@@ -710,7 +705,7 @@
 static void receive_stop(struct stir_cb *stir)
 {
 	stir->receiving = 0;
-	usb_unlink_urb(stir->rx_urb);
+	usb_kill_urb(stir->rx_urb);
 
 	if (stir->rx_buff.in_frame) 
 		stir->stats.collisions++;
@@ -766,8 +761,9 @@
 	       && netif_device_present(dev)
 	       && !signal_pending(current))
 	{
+#ifdef CONFIG_PM
 		/* if suspending, then power off and wait */
-		if (current->flags & PF_FREEZE) {
+		if (unlikely(current->flags & PF_FREEZE)) {
 			if (stir->receiving)
 				receive_stop(stir);
 			else
@@ -780,6 +776,7 @@
 			if (change_speed(stir, stir->speed))
 				break;
 		}
+#endif
 
 		/* if something to send? */
 		skb = xchg(&stir->tx_pending, NULL);
@@ -874,7 +871,7 @@
  */
 static int stir_net_open(struct net_device *netdev)
 {
-	struct stir_cb *stir = netdev->priv;
+	struct stir_cb *stir = netdev_priv(netdev);
 	int err;
 	char hwname[16];
 
@@ -927,7 +924,7 @@
 	sprintf(hwname, "usb#%d", stir->usbdev->devnum);
 	stir->irlap = irlap_open(netdev, &stir->qos, hwname);
 	if (!stir->irlap) {
-		err("irlap_open failed");
+		err("stir4200: irlap_open failed");
 		goto err_out5;
 	}
 
@@ -936,7 +933,7 @@
 				      CLONE_FS|CLONE_FILES);
 	if (stir->thr_pid < 0) {
 		err = stir->thr_pid;
-		err("unable to start kernel thread");
+		err("stir4200: unable to start kernel thread");
 		goto err_out6;
 	}
 
@@ -966,7 +963,7 @@
  */
 static int stir_net_close(struct net_device *netdev)
 {
-	struct stir_cb *stir = netdev->priv;
+	struct stir_cb *stir = netdev_priv(netdev);
 
 	/* Stop transmit processing */
 	netif_stop_queue(netdev);
@@ -977,7 +974,7 @@
 	kfree(stir->fifo_status);
 
 	/* Mop up receive urb's */
-	usb_unlink_urb(stir->rx_urb);
+	usb_kill_urb(stir->rx_urb);
 	
 	kfree(stir->io_buf);
 	usb_free_urb(stir->rx_urb);
@@ -995,10 +992,10 @@
 /*
  * IOCTLs : Extra out-of-band network commands...
  */
-static int stir_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+static int stir_net_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 {
 	struct if_irda_req *irq = (struct if_irda_req *) rq;
-	struct stir_cb *stir = dev->priv;
+	struct stir_cb *stir = netdev_priv(netdev);
 	int ret = 0;
 
 	switch (cmd) {
@@ -1035,9 +1032,9 @@
 /*
  * Get device stats (for /proc/net/dev and ifconfig)
  */
-static struct net_device_stats *stir_net_get_stats(struct net_device *dev)
+static struct net_device_stats *stir_net_get_stats(struct net_device *netdev)
 {
-	struct stir_cb *stir = dev->priv;
+	struct stir_cb *stir = netdev_priv(netdev);
 	return &stir->stats;
 }
 
@@ -1063,13 +1060,13 @@
 
 	SET_MODULE_OWNER(net);
 	SET_NETDEV_DEV(net, &intf->dev);
-	stir = net->priv;
+	stir = netdev_priv(net);
 	stir->netdev = net;
 	stir->usbdev = dev;
 
 	ret = usb_reset_configuration(dev);
 	if (ret != 0) {
-		err("usb reset configuration failed");
+		err("stir4200: usb reset configuration failed");
 		goto err_out2;
 	}
 
@@ -1102,7 +1099,7 @@
 	if (ret != 0)
 		goto err_out2;
 
-	MESSAGE("IrDA: Registered SigmaTel device %s\n", net->name);
+	info("IrDA: Registered SigmaTel device %s", net->name);
 
 	usb_set_intfdata(intf, stir);
 
@@ -1130,7 +1127,7 @@
 	usb_set_intfdata(intf, NULL);
 }
 
-
+#ifdef CONFIG_PM
 /* Power management suspend, so power off the transmitter/receiver */
 static int stir_suspend(struct usb_interface *intf, u32 state)
 {
@@ -1150,6 +1147,7 @@
 	/* receiver restarted when send thread wakes up */
 	return 0;
 }
+#endif
 
 /*
  * USB device callbacks
@@ -1160,8 +1158,10 @@
 	.probe		= stir_probe,
 	.disconnect	= stir_disconnect,
 	.id_table	= dongles,
+#ifdef CONFIG_PM
 	.suspend	= stir_suspend,
 	.resume		= stir_resume,
+#endif
 };
 
 /*
@@ -1169,11 +1169,7 @@
  */
 static int __init stir_init(void)
 {
-	if (usb_register(&irda_driver) < 0)
-		return -1;
-
-	MESSAGE("SigmaTel support registered\n");
-	return 0;
+	return usb_register(&irda_driver);
 }
 module_init(stir_init);
 
diff -Nru a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
--- a/drivers/net/irda/via-ircc.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/irda/via-ircc.c	2004-12-24 13:36:16 -08:00
@@ -26,6 +26,16 @@
        jul/09/2002 : only implement two kind of dongle currently.
        Oct/02/2002 : work on VT8231 and VT8233 .
        Aug/06/2003 : change driver format to pci driver .
+
+2004-02-16: <sda@bdit.de>
+- Removed unneeded 'legacy' pci stuff.
+- Make sure SIR mode is set (hw_init()) before calling mode-dependant stuff.
+- On speed change from core, don't send SIR frame with new speed. 
+  Use current speed and change speeds later.
+- Make module-param dongle_id actually work.
+- New dongle_id 17 (0x11): TDFS4500. Single-ended SIR only. 
+  Tested with home-grown PCB on EPIA boards.
+- Code cleanup.
        
  ********************************************************************/
 #include <linux/module.h>
@@ -53,35 +63,27 @@
 
 #include "via-ircc.h"
 
-//#define DBG_IO	1
-//#define   DBGMSG 1
-//#define   DBGMSG_96 1
-//#define   DBGMSG_76 1
-//static int debug=0;
-
-
-#define DBG(x) {if (debug) x;}
+#define VIA_MODULE_NAME "via-ircc"
+#define CHIP_IO_EXTENT 0x40
 
-#define   VIA_MODULE_NAME "via-ircc"
-#define CHIP_IO_EXTENT 8
-#define BROKEN_DONGLE_ID
-
-static char *driver_name = "via-ircc";
+static char *driver_name = VIA_MODULE_NAME;
 
 /* Module parameters */
 static int qos_mtt_bits = 0x07;	/* 1 ms or more */
-static int dongle_id = 9;	//defalut IBM type
+static int dongle_id = 0;	/* default: probe */
 
-/* Resource is allocate by BIOS user only need to supply dongle_id*/
+/* We can't guess the type of connected dongle, user *must* supply it. */
 MODULE_PARM(dongle_id, "i");
 
+/* FIXME : we should not need this, because instances should be automatically
+ * managed by the PCI layer. Especially that we seem to only be using the
+ * first entry. Jean II */
 /* Max 4 instances for now */
 static struct via_ircc_cb *dev_self[] = { NULL, NULL, NULL, NULL };
 
 /* Some prototypes */
 static int via_ircc_open(int i, chipio_t * info, unsigned int id);
 static int __exit via_ircc_close(struct via_ircc_cb *self);
-static int via_ircc_setup(chipio_t * info, unsigned int id);
 static int via_ircc_dma_receive(struct via_ircc_cb *self);
 static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
 					 int iobase);
@@ -89,6 +91,7 @@
 				  struct net_device *dev);
 static int via_ircc_hard_xmit_fir(struct sk_buff *skb,
 				  struct net_device *dev);
+static void via_hw_init(struct via_ircc_cb *self);
 static void via_ircc_change_speed(struct via_ircc_cb *self, __u32 baud);
 static irqreturn_t via_ircc_interrupt(int irq, void *dev_id,
 				      struct pt_regs *regs);
@@ -110,7 +113,7 @@
 static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_device_id *id);
 static void __exit via_remove_one (struct pci_dev *pdev);
 
-/* Should use udelay() instead, even if we are x86 only - Jean II */
+/* FIXME : Should use udelay() instead, even if we are x86 only - Jean II */
 static void iodelay(int udelay)
 {
 	u8 data;
@@ -122,11 +125,11 @@
 }
 
 static struct pci_device_id via_pci_tbl[] = {
-	{ PCI_VENDOR_ID_VIA, DeviceID1, PCI_ANY_ID, PCI_ANY_ID,0,0,0 },
-	{ PCI_VENDOR_ID_VIA, DeviceID2, PCI_ANY_ID, PCI_ANY_ID,0,0,1 },
-	{ PCI_VENDOR_ID_VIA, DeviceID3, PCI_ANY_ID, PCI_ANY_ID,0,0,2 },
-	{ PCI_VENDOR_ID_VIA, DeviceID4, PCI_ANY_ID, PCI_ANY_ID,0,0,3 },
-	{ PCI_VENDOR_ID_VIA, DeviceID5, PCI_ANY_ID, PCI_ANY_ID,0,0,4 },
+	{ PCI_VENDOR_ID_VIA, 0x8231, PCI_ANY_ID, PCI_ANY_ID,0,0,0 },
+	{ PCI_VENDOR_ID_VIA, 0x3109, PCI_ANY_ID, PCI_ANY_ID,0,0,1 },
+	{ PCI_VENDOR_ID_VIA, 0x3074, PCI_ANY_ID, PCI_ANY_ID,0,0,2 },
+	{ PCI_VENDOR_ID_VIA, 0x3147, PCI_ANY_ID, PCI_ANY_ID,0,0,3 },
+	{ PCI_VENDOR_ID_VIA, 0x3177, PCI_ANY_ID, PCI_ANY_ID,0,0,4 },
 	{ 0, }
 };
 
@@ -150,22 +153,15 @@
 {
 	int rc;
 
-#ifdef	HEADMSG
-        DBG(printk(KERN_INFO "via_ircc_init ......\n"));
-#endif
-	rc = pci_register_driver (&via_driver);
-#ifdef	HEADMSG
-        DBG(printk(KERN_INFO "via_ircc_init :rc = %d......\n",rc));
-#endif
-	if (rc < 1) {
-#ifdef	HEADMSG
-        DBG(printk(KERN_INFO "via_ircc_init return -ENODEV......\n"));
-#endif
-		if (rc == 0)	pci_unregister_driver (&via_driver);
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+
+	rc = pci_register_driver(&via_driver);
+	if (rc < 0) {
+		IRDA_DEBUG(0, "%s(): error rc = %d, returning  -ENODEV...\n",
+			   __FUNCTION__, rc);
 		return -ENODEV;
 	}
 	return 0;
-
 }
 
 static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_device_id *id)
@@ -174,33 +170,24 @@
         u8 temp,oldPCI_40,oldPCI_44,bTmp,bTmp1;
 	u16 Chipset,FirDRQ1,FirDRQ0,FirIRQ,FirIOBase;
 	chipio_t info;
-	
-#ifdef	HEADMSG
-        DBG(printk(KERN_INFO "via_init_one : Device ID=(0X%X)\n",id->device));
-#endif
-	if(id->device != DeviceID1 && id->device != DeviceID2 &&
-	   id->device != DeviceID3 && id->device != DeviceID4 &&
-	   id->device != DeviceID5  ){
-#ifdef	HEADMSG
-		DBG(printk(KERN_INFO "via_init_one : Device ID(0X%X) not Supported\n",id->device));
-#endif
-	      return -ENODEV; //South not exist !!!!!
-	}
+
+	IRDA_DEBUG(2, "%s(): Device ID=(0X%X)\n", __FUNCTION__, id->device);
+
 	rc = pci_enable_device (pcidev);
-#ifdef	HEADMSG
-	DBG(printk(KERN_INFO "via_init_one : rc=%d\n",rc));
-#endif
-	if (rc)
-		return -ENODEV; 
-        //South Bridge exist
+	if (rc) {
+		IRDA_DEBUG(0, "%s(): error rc = %d\n", __FUNCTION__, rc);
+		return -ENODEV;
+	}
+
+	// South Bridge exist
         if ( ReadLPCReg(0x20) != 0x3C )
 		Chipset=0x3096;
 	else
 		Chipset=0x3076;
+
 	if (Chipset==0x3076) {
-#ifdef	HEADMSG
-		DBG(printk(KERN_INFO "via_init_one : 3076 ......\n"));
-#endif
+		IRDA_DEBUG(2, "%s(): Chipset = 3076\n", __FUNCTION__);
+
 		WriteLPCReg(7,0x0c );
 		temp=ReadLPCReg(0x30);//check if BIOS Enable Fir
 		if((temp&0x01)==1) {   // BIOS close or no FIR
@@ -236,9 +223,8 @@
 		} else
 			rc = -ENODEV; //IR not turn on	 
 	} else { //Not VT1211
-#ifdef	HEADMSG
-		DBG(printk(KERN_INFO "via_init_one : 3096 ......\n"));
-#endif
+		IRDA_DEBUG(2, "%s(): Chipset = 3096\n", __FUNCTION__);
+
 		pci_read_config_byte(pcidev,0x67,&bTmp);//check if BIOS Enable Fir
 		if((bTmp&0x01)==1) {  // BIOS enable FIR
 			//Enable Double DMA clock
@@ -276,9 +262,8 @@
 		} else
 			rc = -ENODEV; //IR not turn on !!!!!
 	}//Not VT1211
-#ifdef	HEADMSG
-	DBG(printk(KERN_INFO "via_init_one End : rc=%d\n",rc));
-#endif
+
+	IRDA_DEBUG(2, "%s(): End - rc = %d\n", __FUNCTION__, rc);
 	return rc;
 }
 
@@ -292,9 +277,8 @@
 {
 	int i;
 
-#ifdef	HEADMSG
-	DBG(printk(KERN_INFO "via_ircc_clean\n"));
-#endif
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+
 	for (i=0; i < 4; i++) {
 		if (dev_self[i])
 			via_ircc_close(dev_self[i]);
@@ -303,20 +287,29 @@
 
 static void __exit via_remove_one (struct pci_dev *pdev)
 {
-#ifdef	HEADMSG
-        DBG(printk(KERN_INFO "via_remove_one :  ......\n"));
-#endif
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+
+	/* FIXME : This is ugly. We should use pci_get_drvdata(pdev);
+	 * to get our driver instance and call directly via_ircc_close().
+	 * See vlsi_ir for details...
+	 * Jean II */
 	via_ircc_clean();
 
+	/* FIXME : This should be in via_ircc_close(), because here we may
+	 * theoritically disable still configured devices :-( - Jean II */
+	pci_disable_device(pdev);
 }
 
 static void __exit via_ircc_cleanup(void)
 {
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
-#ifdef	HEADMSG
-	DBG(printk(KERN_INFO "via_ircc_cleanup ......\n"));
-#endif
+	/* FIXME : This should be redundant, as pci_unregister_driver()
+	 * should call via_remove_one() on each device.
+	 * Jean II */
 	via_ircc_clean();
+
+	/* Cleanup all instances of the driver */
 	pci_unregister_driver (&via_driver); 
 }
 
@@ -332,8 +325,7 @@
 	struct via_ircc_cb *self;
 	int err;
 
-	if ((via_ircc_setup(info, id)) == -1)
-		return -1;
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
 	/* Allocate new instance of the driver */
 	dev = alloc_irdadev(sizeof(struct via_ircc_cb));
@@ -344,6 +336,10 @@
 	self->netdev = dev;
 	spin_lock_init(&self->lock);
 
+	/* FIXME : We should store our driver instance in the PCI layer,
+	 * using pci_set_drvdata(), not in this array.
+	 * See vlsi_ir for details... - Jean II */
+	/* FIXME : 'i' is always 0 (see via_init_one()) :-( - Jean II */
 	/* Need to store self somewhere */
 	dev_self[i] = self;
 	self->index = i;
@@ -361,19 +357,40 @@
 
 	/* Reserve the ioports that we need */
 	if (!request_region(self->io.fir_base, self->io.fir_ext, driver_name)) {
-//              WARNING("%s(), can't get iobase of 0x%03x\n", __FUNCTION__, self->io.fir_base);
+		IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
+			   __FUNCTION__, self->io.fir_base);
 		err = -ENODEV;
 		goto err_out1;
 	}
 	
 	/* Initialize QoS for this device */
 	irda_init_max_qos_capabilies(&self->qos);
+
+	/* Check if user has supplied the dongle id or not */
+	if (!dongle_id)
+		dongle_id = via_ircc_read_dongle_id(self->io.fir_base);
+	self->io.dongle_id = dongle_id;
+
 	/* The only value we must override it the baudrate */
-//      self->qos.baud_rate.bits = IR_9600;// May use this for testing
+	/* Maximum speeds and capabilities are dongle-dependant. */
+	switch( self->io.dongle_id ){
+	case 0x0d:
+		self->qos.baud_rate.bits =
+		    IR_9600 | IR_19200 | IR_38400 | IR_57600 | IR_115200 |
+		    IR_576000 | IR_1152000 | (IR_4000000 << 8);
+		break;
+	default:
+		self->qos.baud_rate.bits =
+		    IR_9600 | IR_19200 | IR_38400 | IR_57600 | IR_115200;
+		break;
+	}
 
-	self->qos.baud_rate.bits =
-	    IR_9600 | IR_19200 | IR_38400 | IR_57600 | IR_115200 |
-	    IR_576000 | IR_1152000 | (IR_4000000 << 8);
+	/* Following was used for testing:
+	 *
+	 *   self->qos.baud_rate.bits = IR_9600;
+	 *
+	 * Is is no good, as it prohibits (error-prone) speed-changes.
+	 */
 
 	self->qos.min_turn_time.bits = qos_mtt_bits;
 	irda_qos_bits_to_value(&self->qos);
@@ -424,15 +441,12 @@
 	if (err)
 		goto err_out4;
 
-	MESSAGE("IrDA: Registered device %s\n", dev->name);
-
-	/* Check if user has supplied the dongle id or not */
-	if (!dongle_id)
-		dongle_id = via_ircc_read_dongle_id(self->io.fir_base);
-	self->io.dongle_id = dongle_id;
-	via_ircc_change_dongle_speed(self->io.fir_base, 9600,
-				     self->io.dongle_id);
+	MESSAGE("IrDA: Registered device %s (via-ircc)\n", dev->name);
 
+	/* Initialise the hardware..
+	*/
+	self->io.speed = 9600;
+	via_hw_init(self);
 	return 0;
  err_out4:
 	dma_free_coherent(NULL, self->tx_buff.truesize,
@@ -458,7 +472,7 @@
 {
 	int iobase;
 
-	IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
 	ASSERT(self != NULL, return -1;);
 
@@ -469,7 +483,7 @@
 	unregister_netdev(self->netdev);
 
 	/* Release the PORT that this driver is using */
-	IRDA_DEBUG(4, "%s(), Releasing Region %03x\n",
+	IRDA_DEBUG(2, "%s(), Releasing Region %03x\n",
 		   __FUNCTION__, self->io.fir_base);
 	release_region(self->io.fir_base, self->io.fir_ext);
 	if (self->tx_buff.head)
@@ -486,14 +500,17 @@
 }
 
 /*
- * Function via_ircc_setup (info)
+ * Function via_hw_init(self)
  *
  *    Returns non-negative on success.
  *
+ * Formerly via_ircc_setup 
  */
-static int via_ircc_setup(chipio_t * info, unsigned int chip_id)
+static void via_hw_init(struct via_ircc_cb *self)
 {
-	int iobase = info->fir_base;
+	int iobase = self->io.fir_base;
+
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
 	SetMaxRxPacketSize(iobase, 0x0fff);	//set to max:4095
 	// FIFO Init
@@ -504,22 +521,40 @@
 	EnTXFIFOReadyInt(iobase, OFF);
 	InvertTX(iobase, OFF);
 	InvertRX(iobase, OFF);
+
 	if (ReadLPCReg(0x20) == 0x3c)
 		WriteLPCReg(0xF0, 0);	// for VT1211
-	if (IsSIROn(iobase)) {
-		SIRFilter(iobase, ON);
-		SIRRecvAny(iobase, ON);
-	} else {
-		SIRFilter(iobase, OFF);
-		SIRRecvAny(iobase, OFF);
-	}
-	//Int Init
+	/* Int Init */
 	EnRXSpecInt(iobase, ON);
-	//DMA Init Later....
-	WriteReg(iobase, I_ST_CT_0, 0x80);
-	EnableDMA(iobase, ON);
 
-	return 0;
+	/* The following is basically hwreset */
+	/* If this is the case, why not just call hwreset() ? Jean II */
+	ResetChip(iobase, 5);
+	EnableDMA(iobase, OFF);
+	EnableTX(iobase, OFF);
+	EnableRX(iobase, OFF);
+	EnRXDMA(iobase, OFF);
+	EnTXDMA(iobase, OFF);
+	RXStart(iobase, OFF);
+	TXStart(iobase, OFF);
+	InitCard(iobase);
+	CommonInit(iobase);
+	SIRFilter(iobase, ON);
+	SetSIR(iobase, ON);
+	CRC16(iobase, ON);
+	EnTXCRC(iobase, 0);
+	WriteReg(iobase, I_ST_CT_0, 0x00);
+	SetBaudRate(iobase, 9600);
+	SetPulseWidth(iobase, 12);
+	SetSendPreambleCount(iobase, 0);
+
+	self->io.speed = 9600;
+	self->st_fifo.len = 0;
+
+	via_ircc_change_dongle_speed(iobase, self->io.speed,
+				     self->io.dongle_id);
+
+	WriteReg(iobase, I_ST_CT_0, 0x80);
 }
 
 /*
@@ -528,8 +563,9 @@
  */
 static int via_ircc_read_dongle_id(int iobase)
 {
-	int dongle_id = 9;
+	int dongle_id = 9;	/* Default to IBM */
 
+	ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
 	return dongle_id;
 }
 
@@ -543,22 +579,16 @@
 {
 	u8 mode = 0;
 
-	WriteReg(iobase, I_ST_CT_0, 0x0);
-	switch (dongle_id) {	//HP1100
-	case 0x00:		/* same as */
-	case 0x01:		/* Differential serial interface */
-		break;
-	case 0x02:		/* same as */
-	case 0x03:		/* Reserved */
-		break;
-	case 0x04:		/* Sharp RY5HD01 */
-		break;
-	case 0x05:		/* Reserved, but this is what the Thinkpad reports */
-		break;
-	case 0x06:		/* Single-ended serial interface */
-		break;
-	case 0x07:		/* Consumer-IR only */
-		break;
+	/* speed is unused, as we use IsSIROn()/IsMIROn() */
+	speed = speed;
+
+	IRDA_DEBUG(1, "%s(): change_dongle_speed to %d for 0x%x, %d\n",
+		   __FUNCTION__, speed, iobase, dongle_id);
+
+	switch (dongle_id) {
+
+		/* Note: The dongle_id's listed here are derived from
+		 * nsc-ircc.c */ 
 
 	case 0x08:		/* HP HSDL-2300, HP HSDL-3600/HSDL-3610 */
 		UseOneRX(iobase, ON);	// use one RX pin   RX1,RX2
@@ -587,10 +617,12 @@
 			}
 		}
 		break;
+
 	case 0x09:		/* IBM31T1100 or Temic TFDS6000/TFDS6500 */
 		UseOneRX(iobase, ON);	//use ONE RX....RX1
 		InvertTX(iobase, OFF);
 		InvertRX(iobase, OFF);	// invert RX pin
+
 		EnRX2(iobase, ON);
 		EnGPIOtoRX2(iobase, OFF);
 		if (IsSIROn(iobase)) {	//sir
@@ -621,6 +653,7 @@
 			}
 		}
 		break;
+
 	case 0x0d:
 		UseOneRX(iobase, OFF);	// use two RX pin   RX1,RX2
 		InvertTX(iobase, OFF);
@@ -636,6 +669,31 @@
 			EnRX2(iobase, OFF);	//fir to rx
 		}
 		break;
+
+	case 0x11:		/* Temic TFDS4500 */
+
+		IRDA_DEBUG(2, "%s: Temic TFDS4500: One RX pin, TX normal, RX inverted.\n", __FUNCTION__);
+
+		UseOneRX(iobase, ON);	//use ONE RX....RX1
+		InvertTX(iobase, OFF);
+		InvertRX(iobase, ON);	// invert RX pin
+	
+		EnRX2(iobase, ON);	//sir to rx2
+		EnGPIOtoRX2(iobase, OFF);
+
+		if( IsSIROn(iobase) ){	//sir
+
+			// Mode select On
+			SlowIRRXLowActive(iobase, ON);
+			udelay(20);
+			// Mode select Off
+			SlowIRRXLowActive(iobase, OFF);
+
+		} else{
+			IRDA_DEBUG(0, "%s: Warning: TFDS4500 not running in SIR mode !\n", __FUNCTION__);
+		}
+		break;
+
 	case 0x0ff:		/* Vishay */
 		if (IsSIROn(iobase))
 			mode = 0;
@@ -646,9 +704,12 @@
 		else if (IsVFIROn(iobase))
 			mode = 5;	//VFIR-16
 		SI_SetMode(iobase, mode);
-	}
-	WriteReg(iobase, I_ST_CT_0, 0x80);
+		break;
 
+	default:
+		ERROR("%s: Error: dongle_id %d unsupported !\n",
+		      __FUNCTION__, dongle_id);
+	}
 }
 
 /*
@@ -666,46 +727,25 @@
 	iobase = self->io.fir_base;
 	/* Update accounting for new speed */
 	self->io.speed = speed;
-#ifdef	DBGMSG
-	DBG(printk(KERN_INFO "change_speed =%x......\n", speed));
-#endif
-
-#ifdef	DBG_IO
-	if (self->io.speed > 0x2580)
-		outb(0xaa, 0x90);
-	else
-		outb(0xbb, 0x90);
-#endif
+	IRDA_DEBUG(1, "%s: change_speed to %d bps.\n", __FUNCTION__, speed);
 
+	WriteReg(iobase, I_ST_CT_0, 0x0);
 
 	/* Controller mode sellection */
 	switch (speed) {
+	case 2400:
 	case 9600:
-		value = 11;
-		SetSIR(iobase, ON);
-		CRC16(iobase, ON);
-		break;
 	case 19200:
-		value = 5;
-		SetSIR(iobase, ON);
-		CRC16(iobase, ON);
-		break;
 	case 38400:
-		value = 2;
-		SetSIR(iobase, ON);
-		CRC16(iobase, ON);
-		break;
 	case 57600:
-		value = 1;
-		SetSIR(iobase, ON);
-		CRC16(iobase, ON);
-		break;
 	case 115200:
-		value = 0;
+		value = (115200/speed)-1;
 		SetSIR(iobase, ON);
 		CRC16(iobase, ON);
 		break;
 	case 576000:
+		/* FIXME: this can't be right, as it's the same as 115200,
+		 * and 576000 is MIR, not SIR. */
 		value = 0;
 		SetSIR(iobase, ON);
 		CRC16(iobase, ON);
@@ -713,6 +753,7 @@
 	case 1152000:
 		value = 0;
 		SetMIR(iobase, ON);
+		/* FIXME: CRC ??? */
 		break;
 	case 4000000:
 		value = 0;
@@ -725,19 +766,29 @@
 	case 16000000:
 		value = 0;
 		SetVFIR(iobase, ON);
+		/* FIXME: CRC ??? */
 		break;
 	default:
 		value = 0;
 		break;
 	}
+
 	/* Set baudrate to 0x19[2..7] */
 	bTmp = (ReadReg(iobase, I_CF_H_1) & 0x03);
-	bTmp = bTmp | (value << 2);
+	bTmp |= value << 2;
 	WriteReg(iobase, I_CF_H_1, bTmp);
+
+	/* Some dongles may need to be informed about speed changes. */
 	via_ircc_change_dongle_speed(iobase, speed, self->io.dongle_id);
-// EnTXFIFOHalfLevelInt(iobase,ON);
+
 	/* Set FIFO size to 64 */
 	SetFIFO(iobase, 64);
+
+	/* Enable IR */
+	WriteReg(iobase, I_ST_CT_0, 0x80);
+
+	// EnTXFIFOHalfLevelInt(iobase,ON);
+
 	/* Enable some interrupts so we can receive frames */
 	//EnAllInt(iobase,ON);
 
@@ -748,6 +799,7 @@
 		SIRFilter(iobase, OFF);
 		SIRRecvAny(iobase, OFF);
 	}
+
 	if (speed > 115200) {
 		/* Install FIR xmit handler */
 		dev->hard_start_xmit = via_ircc_hard_xmit_fir;
@@ -805,7 +857,8 @@
 			   self->tx_buff.truesize);
 
 	self->stats.tx_bytes += self->tx_buff.len;
-	SetBaudRate(iobase, speed);
+	/* Send this frame with old speed */
+	SetBaudRate(iobase, self->io.speed);
 	SetPulseWidth(iobase, 12);
 	SetSendPreambleCount(iobase, 0);
 	WriteReg(iobase, I_ST_CT_0, 0x80);
@@ -887,9 +940,6 @@
 
 static int via_ircc_dma_xmit(struct via_ircc_cb *self, u16 iobase)
 {
-//      int i;
-//      u8 *ch;
-
 	EnTXDMA(iobase, OFF);
 	self->io.direction = IO_XMIT;
 	EnPhys(iobase, ON);
@@ -907,18 +957,10 @@
 		       ((u8 *)self->tx_fifo.queue[self->tx_fifo.ptr].start -
 			self->tx_buff.head) + self->tx_buff_dma,
 		       self->tx_fifo.queue[self->tx_fifo.ptr].len, DMA_TX_MODE);
-#ifdef	DBGMSG
-	DBG(printk
-	    (KERN_INFO "dma_xmit:tx_fifo.ptr=%x,len=%x,tx_fifo.len=%x..\n",
-	     self->tx_fifo.ptr, self->tx_fifo.queue[self->tx_fifo.ptr].len,
-	     self->tx_fifo.len));
-/*   
-	ch = self->tx_fifo.queue[self->tx_fifo.ptr].start;
-	for(i=0 ; i < self->tx_fifo.queue[self->tx_fifo.ptr].len ; i++) {
-	    DBG(printk(KERN_INFO "%x..\n",ch[i]));
-	}
-*/
-#endif
+	IRDA_DEBUG(1, "%s: tx_fifo.ptr=%x,len=%x,tx_fifo.len=%x..\n",
+		   __FUNCTION__, self->tx_fifo.ptr,
+		   self->tx_fifo.queue[self->tx_fifo.ptr].len,
+		   self->tx_fifo.len);
 
 	SetSendByte(iobase, self->tx_fifo.queue[self->tx_fifo.ptr].len);
 	RXStart(iobase, OFF);
@@ -940,7 +982,8 @@
 	int ret = TRUE;
 	u8 Tx_status;
 
-	IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+
 	iobase = self->io.fir_base;
 	/* Disable DMA */
 //      DisableDmaChannel(self->io.dma);
@@ -970,12 +1013,10 @@
 			self->tx_fifo.ptr++;
 		}
 	}
-#ifdef	DBGMSG
-	DBG(printk
-	    (KERN_INFO
-	     "via_ircc_dma_xmit_complete:tx_fifo.len=%x ,tx_fifo.ptr=%x,tx_fifo.free=%x...\n",
-	     self->tx_fifo.len, self->tx_fifo.ptr, self->tx_fifo.free));
-#endif
+	IRDA_DEBUG(1,
+		   "%s: tx_fifo.len=%x ,tx_fifo.ptr=%x,tx_fifo.free=%x...\n",
+		   __FUNCTION__,
+		   self->tx_fifo.len, self->tx_fifo.ptr, self->tx_fifo.free);
 /* F01_S
 	// Any frames to be sent back-to-back? 
 	if (self->tx_fifo.len) {
@@ -1010,6 +1051,8 @@
 
 	iobase = self->io.fir_base;
 
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+
 	self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
 	self->tx_fifo.tail = self->tx_buff.head;
 	self->RxDataReady = 0;
@@ -1017,6 +1060,7 @@
 	self->rx_buff.data = self->rx_buff.head;
 	self->st_fifo.len = self->st_fifo.pending_bytes = 0;
 	self->st_fifo.tail = self->st_fifo.head = 0;
+
 	EnPhys(iobase, ON);
 	EnableTX(iobase, OFF);
 	EnableRX(iobase, ON);
@@ -1090,22 +1134,16 @@
 		if (len == 0)
 			return TRUE;	//interrupt only, data maybe move by RxT  
 		if (((len - 4) < 2) || ((len - 4) > 2048)) {
-#ifdef	DBGMSG
-			DBG(printk
-			    (KERN_INFO
-			     "receive_comple:Trouble:len=%x,CurCount=%x,LastCount=%x..\n",
-			     len, RxCurCount(iobase, self),
-			     self->RxLastCount));
-#endif
+			IRDA_DEBUG(1, "%s(): Trouble:len=%x,CurCount=%x,LastCount=%x..\n",
+				   __FUNCTION__, len, RxCurCount(iobase, self),
+				   self->RxLastCount);
 			hwreset(self);
 			return FALSE;
 		}
-#ifdef	DBGMSG
-		DBG(printk
-		    (KERN_INFO
-		     "recv_comple:fifo.len=%x,len=%x,CurCount=%x..\n",
-		     st_fifo->len, len - 4, RxCurCount(iobase, self)));
-#endif
+		IRDA_DEBUG(2, "%s(): fifo.len=%x,len=%x,CurCount=%x..\n",
+			   __FUNCTION__,
+			   st_fifo->len, len - 4, RxCurCount(iobase, self));
+
 		st_fifo->entries[st_fifo->tail].status = status;
 		st_fifo->entries[st_fifo->tail].len = len;
 		st_fifo->pending_bytes += len;
@@ -1148,16 +1186,11 @@
 		}
 		skb_reserve(skb, 1);
 		skb_put(skb, len - 4);
+
 		memcpy(skb->data, self->rx_buff.data, len - 4);
-#ifdef	DBGMSG
-		DBG(printk
-		    (KERN_INFO "RxT:len=%x.rx_buff=%x\n", len - 4,
-		     self->rx_buff.data));
-/*		for(i=0 ; i < (len-4) ; i++) {
-		    DBG(printk(KERN_INFO "%x..\n",self->rx_buff.data[i]));
-		}
-*/
-#endif
+		IRDA_DEBUG(2, "%s(): len=%x.rx_buff=%p\n", __FUNCTION__,
+			   len - 4, self->rx_buff.data);
+
 		// Move to next frame 
 		self->rx_buff.data += len;
 		self->stats.rx_bytes += len;
@@ -1185,9 +1218,8 @@
 
 	len = GetRecvByte(iobase, self);
 
-#ifdef	DBGMSG
-	DBG(printk(KERN_INFO "upload_rxdata: len=%x\n", len));
-#endif
+	IRDA_DEBUG(2, "%s(): len=%x\n", __FUNCTION__, len);
+
 	skb = dev_alloc_skb(len + 1);
 	if ((skb == NULL) || ((len - 4) < 2)) {
 		self->stats.rx_dropped++;
@@ -1265,11 +1297,10 @@
 			skb_reserve(skb, 1);
 			skb_put(skb, len - 4);
 			memcpy(skb->data, self->rx_buff.data, len - 4);
-#ifdef	DBGMSG
-			DBG(printk
-			    (KERN_INFO "RxT:len=%x.head=%x\n", len - 4,
-			     st_fifo->head));
-#endif
+
+			IRDA_DEBUG(2, "%s(): len=%x.head=%x\n", __FUNCTION__,
+				   len - 4, st_fifo->head);
+
 			// Move to next frame 
 			self->rx_buff.data += len;
 			self->stats.rx_bytes += len;
@@ -1280,12 +1311,12 @@
 			netif_rx(skb);
 		}		//while
 		self->RetryCount = 0;
-#ifdef	DBGMSG
-		DBG(printk
-		    (KERN_INFO
-		     "RxT:End of upload HostStatus=%x,RxStatus=%x\n",
-		     GetHostStatus(iobase), GetRXStatus(iobase)));
-#endif
+
+		IRDA_DEBUG(2,
+			   "%s(): End of upload HostStatus=%x,RxStatus=%x\n",
+			   __FUNCTION__,
+			   GetHostStatus(iobase), GetRXStatus(iobase));
+
 		/*
 		 * if frame is receive complete at this routine ,then upload
 		 * frame.
@@ -1328,6 +1359,14 @@
 	iobase = self->io.fir_base;
 	spin_lock(&self->lock);
 	iHostIntType = GetHostStatus(iobase);
+
+	IRDA_DEBUG(4, "%s(): iHostIntType %02x:  %s %s %s  %02x\n",
+		   __FUNCTION__, iHostIntType,
+		   (iHostIntType & 0x40) ? "Timer" : "",
+		   (iHostIntType & 0x20) ? "Tx" : "",
+		   (iHostIntType & 0x10) ? "Rx" : "",
+		   (iHostIntType & 0x0e) >> 1);
+
 	if ((iHostIntType & 0x40) != 0) {	//Timer Event
 		self->EventFlag.TimeOut++;
 		ClearTimerInt(iobase, 1);
@@ -1340,8 +1379,7 @@
 			 */
 			if (self->RxDataReady > 30) {
 				hwreset(self);
-				if (irda_device_txqueue_empty
-				    (self->netdev)) {
+				if (irda_device_txqueue_empty(self->netdev)) {
 					via_ircc_dma_receive(self);
 				}
 			} else {	// call this to upload frame.
@@ -1351,6 +1389,14 @@
 	}			//Timer Event
 	if ((iHostIntType & 0x20) != 0) {	//Tx Event
 		iTxIntType = GetTXStatus(iobase);
+
+		IRDA_DEBUG(4, "%s(): iTxIntType %02x:  %s %s %s %s\n",
+			   __FUNCTION__, iTxIntType,
+			   (iTxIntType & 0x08) ? "FIFO underr." : "",
+			   (iTxIntType & 0x04) ? "EOM" : "",
+			   (iTxIntType & 0x02) ? "FIFO ready" : "",
+			   (iTxIntType & 0x01) ? "Early EOM" : "");
+
 		if (iTxIntType & 0x4) {
 			self->EventFlag.EOMessage++;	// read and will auto clean
 			if (via_ircc_dma_xmit_complete(self)) {
@@ -1367,10 +1413,19 @@
 	if ((iHostIntType & 0x10) != 0) {	//Rx Event
 		/* Check if DMA has finished */
 		iRxIntType = GetRXStatus(iobase);
-#ifdef	DBGMSG
+
+		IRDA_DEBUG(4, "%s(): iRxIntType %02x:  %s %s %s %s %s %s %s\n",
+			   __FUNCTION__, iRxIntType,
+			   (iRxIntType & 0x80) ? "PHY err."	: "",
+			   (iRxIntType & 0x40) ? "CRC err"	: "",
+			   (iRxIntType & 0x20) ? "FIFO overr."	: "",
+			   (iRxIntType & 0x10) ? "EOF"		: "",
+			   (iRxIntType & 0x08) ? "RxData"	: "",
+			   (iRxIntType & 0x02) ? "RxMaxLen"	: "",
+			   (iRxIntType & 0x01) ? "SIR bad"	: "");
 		if (!iRxIntType)
-			DBG(printk(KERN_INFO " RxIRQ =0\n"));
-#endif
+			IRDA_DEBUG(3, "%s(): RxIRQ =0\n", __FUNCTION__);
+
 		if (iRxIntType & 0x10) {
 			if (via_ircc_dma_receive_complete(self, iobase)) {
 //F01       if(!(IsFIROn(iobase)))  via_ircc_dma_receive(self);
@@ -1378,14 +1433,11 @@
 			}
 		}		// No ERR     
 		else {		//ERR
-#ifdef	DBGMSG
-			DBG(printk
-			    (KERN_INFO
-			     " RxIRQ ERR:iRxIntType=%x,HostIntType=%x,CurCount=%x,RxLastCount=%x_____\n",
-			     iRxIntType, iHostIntType, RxCurCount(iobase,
-								  self),
-			     self->RxLastCount));
-#endif
+			IRDA_DEBUG(4, "%s(): RxIRQ ERR:iRxIntType=%x,HostIntType=%x,CurCount=%x,RxLastCount=%x_____\n",
+				   __FUNCTION__, iRxIntType, iHostIntType,
+				   RxCurCount(iobase, self),
+				   self->RxLastCount);
+
 			if (iRxIntType & 0x20) {	//FIFO OverRun ERR
 				ResetChip(iobase, 0);
 				ResetChip(iobase, 1);
@@ -1406,9 +1458,9 @@
 {
 	int iobase;
 	iobase = self->io.fir_base;
-#ifdef	DBGMSG
-	DBG(printk(KERN_INFO "hwreset  ....\n"));
-#endif
+
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
+
 	ResetChip(iobase, 5);
 	EnableDMA(iobase, OFF);
 	EnableTX(iobase, OFF);
@@ -1428,7 +1480,10 @@
 	SetPulseWidth(iobase, 12);
 	SetSendPreambleCount(iobase, 0);
 	WriteReg(iobase, I_ST_CT_0, 0x80);
+
+	/* Restore speed. */
 	via_ircc_change_speed(self, self->io.speed);
+
 	self->st_fifo.len = 0;
 }
 
@@ -1448,9 +1503,9 @@
 	iobase = self->io.fir_base;
 	if (CkRxRecv(iobase, self))
 		status = TRUE;
-#ifdef	DBGMSG
-	DBG(printk(KERN_INFO "is_receiving  status=%x....\n", status));
-#endif
+
+	IRDA_DEBUG(2, "%s(): status=%x....\n", __FUNCTION__, status);
+
 	return status;
 }
 
@@ -1467,15 +1522,14 @@
 	int iobase;
 	char hwname[32];
 
-	IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
 	ASSERT(dev != NULL, return -1;);
 	self = (struct via_ircc_cb *) dev->priv;
 	self->stats.rx_packets = 0;
 	ASSERT(self != NULL, return 0;);
 	iobase = self->io.fir_base;
-	if (request_irq
-	    (self->io.irq, via_ircc_interrupt, 0, dev->name, dev)) {
+	if (request_irq(self->io.irq, via_ircc_interrupt, 0, dev->name, dev)) {
 		WARNING("%s, unable to allocate irq=%d\n", driver_name,
 			self->io.irq);
 		return -EAGAIN;
@@ -1504,6 +1558,10 @@
 	EnAllInt(iobase, ON);
 	EnInternalLoop(iobase, OFF);
 	EnExternalLoop(iobase, OFF);
+
+	/* */
+	via_ircc_dma_receive(self);
+
 	/* Ready to play! */
 	netif_start_queue(dev);
 
@@ -1511,12 +1569,8 @@
 	 * Open new IrLAP layer instance, now that everything should be
 	 * initialized properly 
 	 */
-	sprintf(hwname, "VIA");
-	/*
-	 * for different kernel ,irlap_open have different parameter.
-	 */
+	sprintf(hwname, "VIA @ 0x%x", iobase);
 	self->irlap = irlap_open(dev, &self->qos, hwname);
-//      self->irlap = irlap_open(dev, &self->qos);
 
 	self->RxLastCount = 0;
 
@@ -1534,16 +1588,12 @@
 	struct via_ircc_cb *self;
 	int iobase;
 
-	IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
+	IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
 	ASSERT(dev != NULL, return -1;);
 	self = (struct via_ircc_cb *) dev->priv;
 	ASSERT(self != NULL, return 0;);
 
-#ifdef	DBG_IO
-	outb(0xff, 0x90);
-	outb(0xff, 0x94);
-#endif
 	/* Stop device */
 	netif_stop_queue(dev);
 	/* Stop and remove instance of IrLAP */
@@ -1580,7 +1630,7 @@
 	ASSERT(dev != NULL, return -1;);
 	self = dev->priv;
 	ASSERT(self != NULL, return -1;);
-	IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name,
+	IRDA_DEBUG(1, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name,
 		   cmd);
 	/* Disable interrupts & save flags */
 	spin_lock_irqsave(&self->lock, flags);
diff -Nru a/drivers/net/irda/via-ircc.h b/drivers/net/irda/via-ircc.h
--- a/drivers/net/irda/via-ircc.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/irda/via-ircc.h	2004-12-24 13:37:18 -08:00
@@ -170,17 +170,6 @@
 			// Sets bit to 1
 #define ResetBit(val,bit) val= (unsigned char ) (val & ~(0x1 << bit))
 			// Sets bit to 0
-#define PCI_CONFIG_ADDRESS 0xcf8
-#define PCI_CONFIG_DATA    0xcfc
-
-#define VenderID    0x1106
-#define DeviceID1   0x8231
-#define DeviceID2   0x3109
-#define DeviceID3   0x3074
-//F01_S
-#define DeviceID4   0x3147
-#define DeviceID5   0x3177
-//F01_E
 
 #define OFF   0
 #define ON   1
@@ -794,7 +783,7 @@
 		value = 0;	// will automatically be fixed in 4M
 	}
 	temp = (ReadReg(iobase, I_CF_H_1) & 0x03);
-	temp = temp | (value << 2);
+	temp |= value << 2;
 	WriteReg(iobase, I_CF_H_1, temp);
 }
 
@@ -805,9 +794,9 @@
 	temp = (ReadReg(iobase, I_CF_L_1) & 0x1f);
 	temp1 = (ReadReg(iobase, I_CF_H_1) & 0xfc);
 	temp2 = (width & 0x07) << 5;
-	temp = temp | temp2;
+	temp |= temp2;
 	temp2 = (width & 0x18) >> 3;
-	temp1 = temp1 | temp2;
+	temp1 |= temp2;
 	WriteReg(iobase, I_CF_L_1, temp);
 	WriteReg(iobase, I_CF_H_1, temp1);
 }
@@ -817,7 +806,7 @@
 	__u8 temp;
 
 	temp = ReadReg(iobase, I_CF_L_1) & 0xe0;
-	temp = temp | count;
+	temp |= count;
 	WriteReg(iobase, I_CF_L_1, temp);
 
 }
diff -Nru a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
--- a/drivers/net/irda/vlsi_ir.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/irda/vlsi_ir.c	2004-12-24 13:36:17 -08:00
@@ -1768,7 +1768,7 @@
 	if (netif_running(ndev)) {
 		netif_device_detach(ndev);
 		vlsi_stop_hw(idev);
-		pci_save_state(pdev, idev->cfg_space);
+		pci_save_state(pdev);
 		if (!idev->new_baud)
 			/* remember speed settings to restore on resume */
 			idev->new_baud = idev->baud;
@@ -1819,7 +1819,7 @@
 	}
 
 	if (netif_running(ndev)) {
-		pci_restore_state(pdev, idev->cfg_space);
+		pci_restore_state(pdev);
 		vlsi_start_hw(idev);
 		netif_device_attach(ndev);
 	}
diff -Nru a/drivers/net/irda/vlsi_ir.h b/drivers/net/irda/vlsi_ir.h
--- a/drivers/net/irda/vlsi_ir.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/irda/vlsi_ir.h	2004-12-24 13:37:00 -08:00
@@ -769,7 +769,6 @@
 	spinlock_t		lock;
 	struct semaphore	sem;
 
-	u32			cfg_space[64/sizeof(u32)];
 	u8			resume_ok;	
 	struct proc_dir_entry	*proc_entry;
 
diff -Nru a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c
--- a/drivers/net/isa-skeleton.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/isa-skeleton.c	2004-12-24 13:37:29 -08:00
@@ -55,9 +55,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
--- a/drivers/net/iseries_veth.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/net/iseries_veth.c	2004-12-24 13:36:59 -08:00
@@ -248,7 +248,7 @@
 {
 	struct veth_allocation vc = { COMPLETION_INITIALIZER(vc.c), 0 };
 
-	mf_allocateLpEvents(rlp, HvLpEvent_Type_VirtualLan,
+	mf_allocate_lp_events(rlp, HvLpEvent_Type_VirtualLan,
 			    sizeof(struct VethLpEvent), number,
 			    &veth_complete_allocation, &vc);
 	wait_for_completion(&vc.c);
@@ -662,12 +662,12 @@
 	del_timer_sync(&cnx->ack_timer);
 
 	if (cnx->num_events > 0)
-		mf_deallocateLpEvents(cnx->remote_lp,
+		mf_deallocate_lp_events(cnx->remote_lp,
 				      HvLpEvent_Type_VirtualLan,
 				      cnx->num_events,
 				      NULL, NULL);
 	if (cnx->num_ack_events > 0)
-		mf_deallocateLpEvents(cnx->remote_lp,
+		mf_deallocate_lp_events(cnx->remote_lp,
 				      HvLpEvent_Type_VirtualLan,
 				      cnx->num_ack_events,
 				      NULL, NULL);
@@ -747,60 +747,41 @@
 	write_unlock_irqrestore(&port->mcast_gate, flags);
 }
 
-static int veth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static void veth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-#ifdef SIOCETHTOOL
-	struct ethtool_cmd ecmd;
-
-	if (cmd != SIOCETHTOOL)
-		return -EOPNOTSUPP;
-	if (copy_from_user(&ecmd, ifr->ifr_data, sizeof (ecmd)))
-		return -EFAULT;
-	switch (ecmd.cmd) {
-	case ETHTOOL_GSET:
-		ecmd.supported = (SUPPORTED_1000baseT_Full
-				  | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
-		ecmd.advertising = (SUPPORTED_1000baseT_Full
-				    | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
-
-		ecmd.port = PORT_FIBRE;
-		ecmd.transceiver = XCVR_INTERNAL;
-		ecmd.phy_address = 0;
-		ecmd.speed = SPEED_1000;
-		ecmd.duplex = DUPLEX_FULL;
-		ecmd.autoneg = AUTONEG_ENABLE;
-		ecmd.maxtxpkt = 120;
-		ecmd.maxrxpkt = 120;
-		if (copy_to_user(ifr->ifr_data, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-
-	case ETHTOOL_GDRVINFO:{
-			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-			strncpy(info.driver, "veth", sizeof(info.driver) - 1);
-			info.driver[sizeof(info.driver) - 1] = '\0';
-			strncpy(info.version, "1.0", sizeof(info.version) - 1);
-			if (copy_to_user(ifr->ifr_data, &info, sizeof(info)))
-				return -EFAULT;
-			return 0;
-		}
-		/* get link status */
-	case ETHTOOL_GLINK:{
-			struct ethtool_value edata = { ETHTOOL_GLINK };
-			edata.data = 1;
-			if (copy_to_user(ifr->ifr_data, &edata, sizeof(edata)))
-				return -EFAULT;
-			return 0;
-		}
-
-	default:
-		break;
-	}
+	strncpy(info->driver, "veth", sizeof(info->driver) - 1);
+	info->driver[sizeof(info->driver) - 1] = '\0';
+	strncpy(info->version, "1.0", sizeof(info->version) - 1);
+}
+
+static int veth_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	ecmd->supported = (SUPPORTED_1000baseT_Full
+			  | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
+	ecmd->advertising = (SUPPORTED_1000baseT_Full
+			    | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
+	ecmd->port = PORT_FIBRE;
+	ecmd->transceiver = XCVR_INTERNAL;
+	ecmd->phy_address = 0;
+	ecmd->speed = SPEED_1000;
+	ecmd->duplex = DUPLEX_FULL;
+	ecmd->autoneg = AUTONEG_ENABLE;
+	ecmd->maxtxpkt = 120;
+	ecmd->maxrxpkt = 120;
+	return 0;
+}
 
-#endif
-	return -EOPNOTSUPP;
+static u32 veth_get_link(struct net_device *dev)
+{
+	return 1;
 }
 
+static struct ethtool_ops ops = {
+	.get_drvinfo = veth_get_drvinfo,
+	.get_settings = veth_get_settings,
+	.get_link = veth_get_link,
+};
+
 static void veth_tx_timeout(struct net_device *dev)
 {
 	struct veth_port *port = (struct veth_port *)dev->priv;
@@ -889,7 +870,7 @@
 	dev->change_mtu = veth_change_mtu;
 	dev->set_mac_address = NULL;
 	dev->set_multicast_list = veth_set_multicast_list;
-	dev->do_ioctl = veth_ioctl;
+	SET_ETHTOOL_OPS(dev, &ops);
 
 	dev->watchdog_timeo = 2 * (VETH_ACKTIMEOUT * HZ / 1000000);
 	dev->tx_timeout = veth_tx_timeout;
diff -Nru a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h
--- a/drivers/net/ixgb/ixgb.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/ixgb/ixgb.h	2004-12-24 13:36:47 -08:00
@@ -50,7 +50,7 @@
 #include <linux/string.h>
 #include <linux/pagemap.h>
 #include <linux/dma-mapping.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <linux/capability.h>
@@ -178,6 +178,5 @@
 	/* structs defined in ixgb_hw.h */
 	struct ixgb_hw hw;
 	struct ixgb_hw_stats stats;
-	uint32_t pci_state[16];
 };
 #endif				/* _IXGB_H_ */
diff -Nru a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
--- a/drivers/net/ixgb/ixgb_ethtool.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/ixgb/ixgb_ethtool.c	2004-12-24 13:37:19 -08:00
@@ -38,12 +38,6 @@
 extern int ixgb_up(struct ixgb_adapter *adapter);
 extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
 
-static inline int ixgb_eeprom_size(struct ixgb_hw *hw)
-{
-	/* return size in bytes */
-	return (IXGB_EEPROM_SIZE << 1);
-}
-
 struct ixgb_stats {
 	char stat_string[ETH_GSTRING_LEN];
 	int sizeof_stat;
@@ -94,9 +88,10 @@
 #define IXGB_STATS_LEN	\
 	sizeof(ixgb_gstrings_stats) / sizeof(struct ixgb_stats)
 
-static void
-ixgb_ethtool_gset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
+static int
+ixgb_ethtool_gset(struct net_device *netdev, struct ethtool_cmd *ecmd)
 {
+	struct ixgb_adapter *adapter = netdev->priv;
 	ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
 	ecmd->advertising = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
 	ecmd->port = PORT_FIBRE;
@@ -111,11 +106,13 @@
 	}
 
 	ecmd->autoneg = AUTONEG_DISABLE;
+	return 0;
 }
 
 static int
-ixgb_ethtool_sset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
+ixgb_ethtool_sset(struct net_device *netdev, struct ethtool_cmd *ecmd)
 {
+	struct ixgb_adapter *adapter = netdev->priv;
 	if (ecmd->autoneg == AUTONEG_ENABLE ||
 	    ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)
 		return -EINVAL;
@@ -123,14 +120,14 @@
 		ixgb_down(adapter, TRUE);
 		ixgb_up(adapter);
 	}
-
 	return 0;
 }
 
-static int
-ixgb_ethtool_gpause(struct ixgb_adapter *adapter,
+static void
+ixgb_ethtool_gpause(struct net_device *dev,
 		    struct ethtool_pauseparam *epause)
 {
+	struct ixgb_adapter *adapter = dev->priv;
 	struct ixgb_hw *hw = &adapter->hw;
 
 	epause->autoneg = AUTONEG_DISABLE;
@@ -143,14 +140,13 @@
 		epause->rx_pause = 1;
 		epause->tx_pause = 1;
 	}
-
-	return 0;
 }
 
 static int
-ixgb_ethtool_spause(struct ixgb_adapter *adapter,
+ixgb_ethtool_spause(struct net_device *dev,
 		    struct ethtool_pauseparam *epause)
 {
+	struct ixgb_adapter *adapter = dev->priv;
 	struct ixgb_hw *hw = &adapter->hw;
 
 	if (epause->autoneg == AUTONEG_ENABLE)
@@ -172,26 +168,23 @@
 }
 
 static void
-ixgb_ethtool_gdrvinfo(struct ixgb_adapter *adapter,
+ixgb_ethtool_gdrvinfo(struct net_device *netdev,
 		      struct ethtool_drvinfo *drvinfo)
 {
+	struct ixgb_adapter *adapter = netdev->priv;
 	strncpy(drvinfo->driver, ixgb_driver_name, 32);
 	strncpy(drvinfo->version, ixgb_driver_version, 32);
 	strncpy(drvinfo->fw_version, "N/A", 32);
 	strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
-	drvinfo->n_stats = IXGB_STATS_LEN;
-#define IXGB_REG_DUMP_LEN  136*sizeof(uint32_t)
-	drvinfo->regdump_len = IXGB_REG_DUMP_LEN;
-	drvinfo->eedump_len = ixgb_eeprom_size(&adapter->hw);
 }
 
 #define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
 static void
-ixgb_ethtool_gregs(struct ixgb_adapter *adapter,
-		   struct ethtool_regs *regs, uint32_t * regs_buff)
+ixgb_ethtool_gregs(struct net_device *dev, struct ethtool_regs *regs, void *buf)
 {
+	struct ixgb_adapter *adapter = dev->priv;
 	struct ixgb_hw *hw = &adapter->hw;
-	uint32_t *reg = regs_buff;
+	uint32_t *reg = buf;
 	uint32_t *reg_start = reg;
 	uint8_t i;
 
@@ -323,69 +316,37 @@
 }
 
 static int
-ixgb_ethtool_geeprom(struct ixgb_adapter *adapter,
-		     struct ethtool_eeprom *eeprom, uint16_t * eeprom_buff)
+ixgb_ethtool_geeprom(struct net_device *dev,
+		     struct ethtool_eeprom *eeprom, u8 *data)
 {
+	struct ixgb_adapter *adapter = dev->priv;
 	struct ixgb_hw *hw = &adapter->hw;
-	int i, max_len, first_word, last_word;
-	int ret_val = 0;
-
-	if (eeprom->len == 0) {
-		ret_val = -EINVAL;
-		goto geeprom_error;
-	}
 
 	eeprom->magic = hw->vendor_id | (hw->device_id << 16);
 
-	max_len = ixgb_eeprom_size(hw);
-
 	/* use our function to read the eeprom and update our cache */
 	ixgb_get_eeprom_data(hw);
-
-	if (eeprom->offset > eeprom->offset + eeprom->len) {
-		ret_val = -EINVAL;
-		goto geeprom_error;
-	}
-
-	if ((eeprom->offset + eeprom->len) > max_len)
-		eeprom->len = (max_len - eeprom->offset);
-
-	first_word = eeprom->offset >> 1;
-	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
-
-	for (i = 0; i <= (last_word - first_word); i++) {
-		eeprom_buff[i] = hw->eeprom[first_word + i];
-	}
-      geeprom_error:
-	return ret_val;
+	memcpy(data, (char *)hw->eeprom + eeprom->offset, eeprom->len);
+	return 0;
 }
 
 static int
-ixgb_ethtool_seeprom(struct ixgb_adapter *adapter,
-		     struct ethtool_eeprom *eeprom, void __user *user_data)
+ixgb_ethtool_seeprom(struct net_device *dev,
+		     struct ethtool_eeprom *eeprom, u8 *data)
 {
+	struct ixgb_adapter *adapter = dev->priv;
 	struct ixgb_hw *hw = &adapter->hw;
-	uint16_t eeprom_buff[256];
-	int i, max_len, first_word, last_word;
-	void *ptr;
+	/* We are under rtnl, so static is OK */
+	static uint16_t eeprom_buff[IXGB_EEPROM_SIZE];
+	int i, first_word, last_word;
+	char *ptr;
 
 	if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
 		return -EFAULT;
 
-	if (eeprom->len == 0)
-		return -EINVAL;
-
-	max_len = ixgb_eeprom_size(hw);
-
-	if (eeprom->offset > eeprom->offset + eeprom->len)
-		return -EINVAL;
-
-	if ((eeprom->offset + eeprom->len) > max_len)
-		eeprom->len = (max_len - eeprom->offset);
-
 	first_word = eeprom->offset >> 1;
 	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
-	ptr = (void *)eeprom_buff;
+	ptr = (char *)eeprom_buff;
 
 	if (eeprom->offset & 1) {
 		/* need read/modify/write of first changed EEPROM word */
@@ -399,8 +360,7 @@
 		eeprom_buff[last_word - first_word]
 		    = ixgb_read_eeprom(hw, last_word);
 	}
-	if (copy_from_user(ptr, user_data, eeprom->len))
-		return -EFAULT;
+	memcpy(ptr, data, eeprom->len);
 
 	for (i = 0; i <= (last_word - first_word); i++)
 		ixgb_write_eeprom(hw, first_word + i, eeprom_buff[i]);
@@ -431,8 +391,9 @@
 }
 
 static int
-ixgb_ethtool_led_blink(struct ixgb_adapter *adapter, struct ethtool_value *id)
+ixgb_ethtool_led_blink(struct net_device *netdev, u32 data)
 {
+	struct ixgb_adapter *adapter = netdev->priv;
 	if (!adapter->blink_timer.function) {
 		init_timer(&adapter->blink_timer);
 		adapter->blink_timer.function = ixgb_led_blink_callback;
@@ -442,8 +403,8 @@
 	mod_timer(&adapter->blink_timer, jiffies);
 
 	set_current_state(TASK_INTERRUPTIBLE);
-	if (id->data)
-		schedule_timeout(id->data * HZ);
+	if (data)
+		schedule_timeout(data * HZ);
 	else
 		schedule_timeout(MAX_SCHEDULE_TIMEOUT);
 
@@ -454,268 +415,141 @@
 	return 0;
 }
 
-int ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
+static int ixgb_nway_reset(struct net_device *netdev)
 {
-	struct ixgb_adapter *adapter = netdev->priv;
-	void __user *addr = ifr->ifr_data;
-	uint32_t cmd;
+	if (netif_running(netdev)) {
+		struct ixgb_adapter *adapter = netdev->priv;
+		ixgb_down(adapter, TRUE);
+		ixgb_up(adapter);
+	}
+	return 0;
+}
 
-	if (get_user(cmd, (uint32_t __user *) addr))
-		return -EFAULT;
+static int ixgb_get_stats_count(struct net_device *dev)
+{
+	return IXGB_STATS_LEN;
+}
 
-	switch (cmd) {
-	case ETHTOOL_GSET:{
-			struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-			ixgb_ethtool_gset(adapter, &ecmd);
-			if (copy_to_user(addr, &ecmd, sizeof(ecmd)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_SSET:{
-			struct ethtool_cmd ecmd;
-			if (copy_from_user(&ecmd, addr, sizeof(ecmd)))
-				return -EFAULT;
-			return ixgb_ethtool_sset(adapter, &ecmd);
-		}
-	case ETHTOOL_GDRVINFO:{
-			struct ethtool_drvinfo drvinfo = { ETHTOOL_GDRVINFO };
-			ixgb_ethtool_gdrvinfo(adapter, &drvinfo);
-			if (copy_to_user(addr, &drvinfo, sizeof(drvinfo)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_GSTRINGS:{
-			struct ethtool_gstrings gstrings = { ETHTOOL_GSTRINGS };
-			char *strings = NULL;
-			int err = 0;
-
-			if (copy_from_user(&gstrings, addr, sizeof(gstrings)))
-				return -EFAULT;
-			switch (gstrings.string_set) {
-			case ETH_SS_STATS:{
-					int i;
-					gstrings.len = IXGB_STATS_LEN;
-					strings =
-					    kmalloc(IXGB_STATS_LEN *
-						    ETH_GSTRING_LEN,
-						    GFP_KERNEL);
-					if (!strings)
-						return -ENOMEM;
-					for (i = 0; i < IXGB_STATS_LEN; i++) {
-						memcpy(&strings
-						       [i * ETH_GSTRING_LEN],
-						       ixgb_gstrings_stats[i].
-						       stat_string,
-						       ETH_GSTRING_LEN);
-					}
-					break;
-				}
-			default:
-				return -EOPNOTSUPP;
-			}
-			if (copy_to_user(addr, &gstrings, sizeof(gstrings)))
-				err = -EFAULT;
-			addr += offsetof(struct ethtool_gstrings, data);
-			if (!err && copy_to_user(addr, strings,
-						 gstrings.len *
-						 ETH_GSTRING_LEN))
-				err = -EFAULT;
-
-			kfree(strings);
-			return err;
-		}
-	case ETHTOOL_GREGS:{
-			struct ethtool_regs regs = { ETHTOOL_GREGS };
-			uint32_t regs_buff[IXGB_REG_DUMP_LEN];
-
-			if (copy_from_user(&regs, addr, sizeof(regs)))
-				return -EFAULT;
-			ixgb_ethtool_gregs(adapter, &regs, regs_buff);
-			if (copy_to_user(addr, &regs, sizeof(regs)))
-				return -EFAULT;
-
-			addr += offsetof(struct ethtool_regs, data);
-			if (copy_to_user(addr, regs_buff, regs.len))
-				return -EFAULT;
-
-			return 0;
-		}
-	case ETHTOOL_NWAY_RST:{
-			if (netif_running(netdev)) {
-				ixgb_down(adapter, TRUE);
-				ixgb_up(adapter);
-			}
-			return 0;
-		}
-	case ETHTOOL_PHYS_ID:{
-			struct ethtool_value id;
-			if (copy_from_user(&id, addr, sizeof(id)))
-				return -EFAULT;
-			return ixgb_ethtool_led_blink(adapter, &id);
-		}
-	case ETHTOOL_GLINK:{
-			struct ethtool_value link = { ETHTOOL_GLINK };
-			link.data = netif_carrier_ok(netdev);
-			if (copy_to_user(addr, &link, sizeof(link)))
-				return -EFAULT;
-			return 0;
-		}
-
-	case ETHTOOL_GEEPROM:{
-			struct ethtool_eeprom eeprom = { ETHTOOL_GEEPROM };
-			uint16_t eeprom_buff[IXGB_EEPROM_SIZE];
-			void *ptr;
-			int err = 0;
-
-			if (copy_from_user(&eeprom, addr, sizeof(eeprom)))
-				return -EFAULT;
-
-			if ((err =
-			     ixgb_ethtool_geeprom(adapter, &eeprom,
-						  eeprom_buff)) < 0)
-				return err;
-
-			if (copy_to_user(addr, &eeprom, sizeof(eeprom)))
-				return -EFAULT;
-
-			addr += offsetof(struct ethtool_eeprom, data);
-			ptr = ((void *)eeprom_buff) + (eeprom.offset & 1);
-
-			if (copy_to_user(addr, ptr, eeprom.len))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_SEEPROM:{
-			struct ethtool_eeprom eeprom;
-
-			if (copy_from_user(&eeprom, addr, sizeof(eeprom)))
-				return -EFAULT;
-
-			addr += offsetof(struct ethtool_eeprom, data);
-			return ixgb_ethtool_seeprom(adapter, &eeprom, addr);
-		}
-	case ETHTOOL_GPAUSEPARAM:{
-			struct ethtool_pauseparam epause =
-			    { ETHTOOL_GPAUSEPARAM };
-			ixgb_ethtool_gpause(adapter, &epause);
-			if (copy_to_user(addr, &epause, sizeof(epause)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_SPAUSEPARAM:{
-			struct ethtool_pauseparam epause;
-			if (copy_from_user(&epause, addr, sizeof(epause)))
-				return -EFAULT;
-			return ixgb_ethtool_spause(adapter, &epause);
-		}
-	case ETHTOOL_GSTATS:{
-			struct {
-				struct ethtool_stats eth_stats;
-				uint64_t data[IXGB_STATS_LEN];
-			} stats = { {
-			ETHTOOL_GSTATS, IXGB_STATS_LEN}};
-			int i;
-
-			for (i = 0; i < IXGB_STATS_LEN; i++)
-				stats.data[i] =
-				    (ixgb_gstrings_stats[i].sizeof_stat ==
-				     sizeof(uint64_t)) ? *(uint64_t *) ((char *)
-									adapter
-									+
-									ixgb_gstrings_stats
-									[i].
-									stat_offset)
-				    : *(uint32_t *) ((char *)adapter +
-						     ixgb_gstrings_stats[i].
-						     stat_offset);
-			if (copy_to_user(addr, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_GRXCSUM:{
-			struct ethtool_value edata = { ETHTOOL_GRXCSUM };
-
-			edata.data = adapter->rx_csum;
-			if (copy_to_user(addr, &edata, sizeof(edata)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_SRXCSUM:{
-			struct ethtool_value edata;
-
-			if (copy_from_user(&edata, addr, sizeof(edata)))
-				return -EFAULT;
-			adapter->rx_csum = edata.data;
-			ixgb_down(adapter, TRUE);
-			ixgb_up(adapter);
-			return 0;
-		}
-	case ETHTOOL_GTXCSUM:{
-			struct ethtool_value edata = { ETHTOOL_GTXCSUM };
-
-			edata.data = (netdev->features & NETIF_F_HW_CSUM) != 0;
-			if (copy_to_user(addr, &edata, sizeof(edata)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_STXCSUM:{
-			struct ethtool_value edata;
-
-			if (copy_from_user(&edata, addr, sizeof(edata)))
-				return -EFAULT;
-
-			if (edata.data)
-				netdev->features |= NETIF_F_HW_CSUM;
-			else
-				netdev->features &= ~NETIF_F_HW_CSUM;
-
-			return 0;
-		}
-	case ETHTOOL_GSG:{
-			struct ethtool_value edata = { ETHTOOL_GSG };
-
-			edata.data = (netdev->features & NETIF_F_SG) != 0;
-			if (copy_to_user(addr, &edata, sizeof(edata)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_SSG:{
-			struct ethtool_value edata;
-
-			if (copy_from_user(&edata, addr, sizeof(edata)))
-				return -EFAULT;
-
-			if (edata.data)
-				netdev->features |= NETIF_F_SG;
-			else
-				netdev->features &= ~NETIF_F_SG;
+static void ixgb_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+{
+	int i;
+	for (i = 0; i < IXGB_STATS_LEN; i++) {
+		memcpy(data + i * ETH_GSTRING_LEN,
+		       ixgb_gstrings_stats[i].stat_string,
+		       ETH_GSTRING_LEN);
+	}
+}
 
-			return 0;
-		}
-#ifdef NETIF_F_TSO
-	case ETHTOOL_GTSO:{
-			struct ethtool_value edata = { ETHTOOL_GTSO };
+static int ixgb_get_regs_len(struct net_device *dev)
+{
+	return 136*sizeof(uint32_t);
+}
+
+static int ixgb_get_eeprom_len(struct net_device *dev)
+{
+	/* return size in bytes */
+	return (IXGB_EEPROM_SIZE << 1);
+}
 
-			edata.data = (netdev->features & NETIF_F_TSO) != 0;
-			if (copy_to_user(addr, &edata, sizeof(edata)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_STSO:{
-			struct ethtool_value edata;
-
-			if (copy_from_user(&edata, addr, sizeof(edata)))
-				return -EFAULT;
-
-			if (edata.data)
-				netdev->features |= NETIF_F_TSO;
-			else
-				netdev->features &= ~NETIF_F_TSO;
+static void get_ethtool_stats(struct net_device *dev,
+		struct ethtool_stats *stats, u64 *data)
+{
+	struct ixgb_adapter *adapter = dev->priv;
+	int i;
 
-			return 0;
-		}
-#endif
-	default:
-		return -EOPNOTSUPP;
+	for (i = 0; i < IXGB_STATS_LEN; i++) {
+		void *p = (char *)adapter + ixgb_gstrings_stats[i].stat_offset;
+		stats->data[i] =
+		    (ixgb_gstrings_stats[i].sizeof_stat == sizeof(uint64_t))
+		    ? *(uint64_t *) p
+		    : *(uint32_t *) p;
 	}
 }
+
+static u32 ixgb_get_rx_csum(struct net_device *dev)
+{
+	struct ixgb_adapter *adapter = dev->priv;
+	return adapter->rx_csum;
+}
+
+static int ixgb_set_rx_csum(struct net_device *dev, u32 sum)
+{
+	struct ixgb_adapter *adapter = dev->priv;
+	adapter->rx_csum = sum;
+	ixgb_down(adapter, TRUE);
+	ixgb_up(adapter);
+	return 0;
+}
+
+static u32 ixgb_get_tx_csum(struct net_device *dev)
+{
+	return (dev->features & NETIF_F_HW_CSUM) != 0;
+}
+
+static int ixgb_set_tx_csum(struct net_device *dev, u32 sum)
+{
+	if (sum)
+		dev->features |= NETIF_F_HW_CSUM;
+	else
+		dev->features &= ~NETIF_F_HW_CSUM;
+	return 0;
+}
+
+static u32 ixgb_get_sg(struct net_device *dev)
+{
+	return (dev->features & NETIF_F_SG) != 0;
+}
+
+static int ixgb_set_sg(struct net_device *dev, u32 sum)
+{
+	if (sum)
+		dev->features |= NETIF_F_SG;
+	else
+		dev->features &= ~NETIF_F_SG;
+	return 0;
+}
+
+#ifdef NETIF_F_TSO
+static u32 ixgb_get_tso(struct net_device *dev)
+{
+	return (dev->features & NETIF_F_TSO) != 0;
+}
+
+static int ixgb_set_tso(struct net_device *dev, u32 sum)
+{
+	if (sum)
+		dev->features |= NETIF_F_TSO;
+	else
+		dev->features &= ~NETIF_F_TSO;
+	return 0;
+}
+#endif
+
+struct ethtool_ops ixgb_ethtool_ops = {
+	.get_settings = ixgb_ethtool_gset,
+	.set_settings = ixgb_ethtool_sset,
+	.get_drvinfo = ixgb_ethtool_gdrvinfo,
+	.nway_reset = ixgb_nway_reset,
+	.get_link = ethtool_op_get_link,
+	.phys_id = ixgb_ethtool_led_blink,
+	.get_strings = ixgb_get_strings,
+	.get_stats_count = ixgb_get_stats_count,
+	.get_regs = ixgb_ethtool_gregs,
+	.get_regs_len = ixgb_get_regs_len,
+	.get_eeprom_len = ixgb_get_eeprom_len,
+	.get_eeprom = ixgb_ethtool_geeprom,
+	.set_eeprom = ixgb_ethtool_seeprom,
+	.get_pauseparam = ixgb_ethtool_gpause,
+	.set_pauseparam = ixgb_ethtool_spause,
+	.get_ethtool_stats = get_ethtool_stats,
+	.get_rx_csum = ixgb_get_rx_csum,
+	.set_rx_csum = ixgb_set_rx_csum,
+	.get_tx_csum = ixgb_get_tx_csum,
+	.set_tx_csum = ixgb_set_tx_csum,
+	.get_sg = ixgb_get_sg,
+	.set_sg = ixgb_set_sg,
+#ifdef NETIF_F_TSO
+	.get_tso = ixgb_get_tso,
+	.set_tso = ixgb_set_tso,
+#endif
+};
diff -Nru a/drivers/net/ixgb/ixgb_hw.h b/drivers/net/ixgb/ixgb_hw.h
--- a/drivers/net/ixgb/ixgb_hw.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/ixgb/ixgb_hw.h	2004-12-24 13:36:16 -08:00
@@ -683,7 +683,7 @@
 };
 
 struct ixgb_hw {
-	uint8_t *hw_addr;	/* Base Address of the hardware     */
+	uint8_t __iomem *hw_addr;/* Base Address of the hardware     */
 	void *back;		/* Pointer to OS-dependent struct   */
 	struct ixgb_fc fc;	/* Flow control parameters          */
 	struct ixgb_bus bus;	/* Bus parameters                   */
diff -Nru a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
--- a/drivers/net/ixgb/ixgb_main.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/net/ixgb/ixgb_main.c	2004-12-24 13:36:30 -08:00
@@ -30,7 +30,7 @@
 
 char ixgb_driver_name[] = "ixgb";
 char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
-char ixgb_driver_version[] = "1.0.66";
+char ixgb_driver_version[] = "1.0.66-k2";
 char ixgb_copyright[] = "Copyright (c) 2001-2004 Intel Corporation.";
 
 /* ixgb_pci_tbl - PCI Device ID Table
@@ -97,7 +97,6 @@
 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
 #endif
 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
-static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
 static void ixgb_tx_timeout(struct net_device *dev);
 static void ixgb_tx_timeout_task(struct net_device *dev);
 static void ixgb_vlan_rx_register(struct net_device *netdev,
@@ -124,7 +123,7 @@
 /* Exported from other modules */
 
 extern void ixgb_check_options(struct ixgb_adapter *adapter);
-extern int ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr);
+extern struct ethtool_ops ixgb_ethtool_ops;
 
 static struct pci_driver ixgb_driver = {
 	.name = ixgb_driver_name,
@@ -372,9 +371,9 @@
 	netdev->set_multicast_list = &ixgb_set_multi;
 	netdev->set_mac_address = &ixgb_set_mac;
 	netdev->change_mtu = &ixgb_change_mtu;
-	netdev->do_ioctl = &ixgb_ioctl;
 	netdev->tx_timeout = &ixgb_tx_timeout;
 	netdev->watchdog_timeo = HZ;
+	SET_ETHTOOL_OPS(netdev, &ixgb_ethtool_ops);
 #ifdef CONFIG_IXGB_NAPI
 	netdev->poll = &ixgb_clean;
 	netdev->weight = 64;
@@ -1614,8 +1613,13 @@
 		__netif_rx_schedule(netdev);
 	}
 #else
-	for (i = 0; i < IXGB_MAX_INTR; i++)
-		if (!ixgb_clean_rx_irq(adapter) & !ixgb_clean_tx_irq(adapter))
+	/* yes, that is actually a & and it is meant to make sure that
+	 * every pass through this for loop checks both receive and
+	 * transmit queues for completed descriptors, intended to
+	 * avoid starvation issues and assist tx/rx fairness. */
+	for(i = 0; i < IXGB_MAX_INTR; i++)
+		if(!ixgb_clean_rx_irq(adapter) &
+		   !ixgb_clean_tx_irq(adapter))
 			break;
 	/* if RAIDC:EN == 1 and ICR:RXDMT0 == 1, we need to
 	 * set IMS:RXDMT0 to 1 to restart the RBD timer (POLL)
@@ -1677,7 +1681,7 @@
 	eop = tx_ring->buffer_info[i].next_to_watch;
 	eop_desc = IXGB_TX_DESC(*tx_ring, eop);
 
-	while (eop_desc->status & cpu_to_le32(IXGB_TX_DESC_STATUS_DD)) {
+	while (eop_desc->status & IXGB_TX_DESC_STATUS_DD) {
 
 		for (cleaned = FALSE; !cleaned;) {
 			tx_desc = IXGB_TX_DESC(*tx_ring, i);
@@ -1970,25 +1974,6 @@
 }
 
 /**
- * ixgb_ioctl - perform a command - e.g: ethtool:get_driver_info.
- * @param netdev network interface device structure
- * @param ifr data to be used/filled in by the ioctl command
- * @param cmd ioctl command to execute
- **/
-
-static int ixgb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
-{
-	switch (cmd) {
-	case SIOCETHTOOL:
-		return ixgb_ethtool_ioctl(netdev, ifr);
-	default:
-		return -EOPNOTSUPP;
-	}
-
-	return 0;
-}
-
-/**
  * ixgb_vlan_rx_register - enables or disables vlan tagging/stripping.
  * 
  * @param netdev network interface device structure
@@ -2117,7 +2102,7 @@
 	if (netif_running(netdev))
 		ixgb_down(adapter, TRUE);
 
-	pci_save_state(pdev, adapter->pci_state);
+	pci_save_state(pdev);
 
 	state = (state > 0) ? 3 : 0;
 	pci_set_power_state(pdev, state);
diff -Nru a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
--- a/drivers/net/jazzsonic.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/net/jazzsonic.c	2004-12-24 13:36:32 -08:00
@@ -27,10 +27,10 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/bootinfo.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/dma.h>
diff -Nru a/drivers/net/lance.c b/drivers/net/lance.c
--- a/drivers/net/lance.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/lance.c	2004-12-24 13:36:18 -08:00
@@ -56,8 +56,8 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
--- a/drivers/net/lasi_82596.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/lasi_82596.c	2004-12-24 13:36:18 -08:00
@@ -83,8 +83,8 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/types.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
 #include <asm/irq.h>
@@ -1218,7 +1218,7 @@
 	lp->scb.command = 0;
 	lp->scb.cmd = I596_NULL;
 	lp->scb.rfd = I596_NULL;
-	lp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&lp->lock);
 	lp->dma_addr = dma_addr;
 	lp->dev = gen_dev;
 
diff -Nru a/drivers/net/lp486e.c b/drivers/net/lp486e.c
--- a/drivers/net/lp486e.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/lp486e.c	2004-12-24 13:36:31 -08:00
@@ -70,8 +70,8 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/mac8390.c b/drivers/net/mac8390.c
--- a/drivers/net/mac8390.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/net/mac8390.c	2004-12-24 13:36:56 -08:00
@@ -32,19 +32,15 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/hwtest.h>
 #include <asm/macints.h>
 
 #include "8390.h"
-
-#if (LINUX_VERSION_CODE < 0x02030e)
-#define net_device device
-#endif
 
 #define WD_START_PG			0x00	/* First page of TX buffer */
 #define CABLETRON_RX_START_PG		0x00    /* First page of RX buffer */
diff -Nru a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
--- a/drivers/net/mac89x0.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/mac89x0.c	2004-12-24 13:36:55 -08:00
@@ -98,6 +98,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/delay.h>
 
 #include <asm/system.h>
 #include <asm/bitops.h>
@@ -308,8 +309,7 @@
 	writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
 
 	/* wait 30 ms */
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(30*HZ/1000);
+	msleep_interruptible(30);
 
 	/* Wait until the chip is reset */
 	reset_start_time = jiffies;
diff -Nru a/drivers/net/macsonic.c b/drivers/net/macsonic.c
--- a/drivers/net/macsonic.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/macsonic.c	2004-12-24 13:36:18 -08:00
@@ -42,10 +42,10 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/module.h>
+#include <linux/bitops.h>
 
 #include <asm/bootinfo.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/hwtest.h>
diff -Nru a/drivers/net/meth.c b/drivers/net/meth.c
--- a/drivers/net/meth.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/meth.c	2004-12-24 13:37:18 -08:00
@@ -368,31 +368,6 @@
 }
 
 /*
- * Configuration changes (passed on by ifconfig)
- */
-static int meth_config(struct net_device *dev, struct ifmap *map)
-{
-	if (dev->flags & IFF_UP) /* can't act on a running interface */
-		return -EBUSY;
-
-	/* Don't allow changing the I/O address */
-	if (map->base_addr != dev->base_addr) {
-		printk(KERN_WARNING "meth: Can't change I/O address\n");
-		return -EOPNOTSUPP;
-	}
-
-	/* Don't allow changing the IRQ */
-	if (map->irq != dev->irq) {
-		printk(KERN_WARNING "meth: Can't change IRQ\n");
-		return -EOPNOTSUPP;
-	}
-	DPRINTK("Configured\n");
-
-	/* ignore other fields */
-	return 0;
-}
-
-/*
  * Receive a packet: retrieve, encapsulate and pass over to upper levels
  */
 static void meth_rx(struct net_device* dev, unsigned long int_status)
@@ -813,7 +788,6 @@
 
 	dev->open            = meth_open;
 	dev->stop            = meth_release;
-	dev->set_config      = meth_config;
 	dev->hard_start_xmit = meth_tx;
 	dev->do_ioctl        = meth_ioctl;
 	dev->get_stats       = meth_stats;
diff -Nru a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
--- a/drivers/net/mv643xx_eth.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/mv643xx_eth.c	2004-12-24 13:36:47 -08:00
@@ -49,7 +49,7 @@
 #include <linux/etherdevice.h>
 #include <net/ip.h>
 
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/types.h>
 #include <asm/pgtable.h>
diff -Nru a/drivers/net/mvme147.c b/drivers/net/mvme147.c
--- a/drivers/net/mvme147.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/mvme147.c	2004-12-24 13:36:47 -08:00
@@ -18,7 +18,6 @@
 /* Used for the temporal inet entries and routing */
 #include <linux/socket.h>
 #include <linux/route.h>
-#include <linux/dio.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
@@ -40,7 +39,6 @@
 /* Our private data structure */
 struct m147lance_private {
 	struct lance_private lance;
-	void *base;
 	unsigned long ram;
 };
 
@@ -51,9 +49,9 @@
  */
 static int m147lance_open(struct net_device *dev);
 static int m147lance_close(struct net_device *dev);
-static void m147lance_writerap(struct m147lance_private *lp, unsigned short value);
-static void m147lance_writerdp(struct m147lance_private *lp, unsigned short value);
-static unsigned short m147lance_readrdp(struct m147lance_private *lp);
+static void m147lance_writerap(struct lance_private *lp, unsigned short value);
+static void m147lance_writerdp(struct lance_private *lp, unsigned short value);
+static unsigned short m147lance_readrdp(struct lance_private *lp);
 
 typedef void (*writerap_t)(void *, unsigned short);
 typedef void (*writerdp_t)(void *, unsigned short);
@@ -122,7 +120,7 @@
 	}
 
 	lp->lance.name = (char*)name;                   /* discards const, shut up gcc */
-	lp->lance.ll = (struct lance_regs *)(dev->base_addr);
+	lp->lance.base = dev->base_addr;
 	lp->lance.init_block = (struct lance_init_block *)(lp->ram); /* CPU addr */
 	lp->lance.lance_init_block = (struct lance_init_block *)(lp->ram);                 /* LANCE addr of same RAM */
 	lp->lance.busmaster_regval = LE_C3_BSWP;        /* we're bigendian */
@@ -145,19 +143,19 @@
 	return dev;
 }
 
-static void m147lance_writerap(struct m147lance_private *lp, unsigned short value)
+static void m147lance_writerap(struct lance_private *lp, unsigned short value)
 {
-	lp->lance.ll->rap = value;
+	out_be16(lp->base + LANCE_RAP, value);
 }
 
-static void m147lance_writerdp(struct m147lance_private *lp, unsigned short value)
+static void m147lance_writerdp(struct lance_private *lp, unsigned short value)
 {
-	lp->lance.ll->rdp = value;
+	out_be16(lp->base + LANCE_RDP, value);
 }
 
-static unsigned short m147lance_readrdp(struct m147lance_private *lp)
+static unsigned short m147lance_readrdp(struct lance_private *lp)
 {
-	return lp->lance.ll->rdp;
+	return in_be16(lp->base + LANCE_RDP);
 }
 
 static int m147lance_open(struct net_device *dev)
diff -Nru a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
--- a/drivers/net/myri_sbus.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/myri_sbus.c	2004-12-24 13:36:17 -08:00
@@ -22,6 +22,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <net/dst.h>
 #include <net/arp.h>
@@ -29,7 +30,6 @@
 #include <net/ipv6.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/byteorder.h>
diff -Nru a/drivers/net/natsemi.c b/drivers/net/natsemi.c
--- a/drivers/net/natsemi.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/natsemi.c	2004-12-24 13:36:17 -08:00
@@ -159,8 +159,8 @@
 #include <linux/rtnetlink.h>
 #include <linux/mii.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 #include <asm/processor.h>	/* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -768,6 +768,7 @@
 static int netdev_close(struct net_device *dev);
 static int netdev_get_regs(struct net_device *dev, u8 *buf);
 static int netdev_get_eeprom(struct net_device *dev, u8 *buf);
+static struct ethtool_ops ethtool_ops;
 
 static inline void __iomem *ns_ioaddr(struct net_device *dev)
 {
@@ -933,6 +934,7 @@
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	dev->poll_controller = &natsemi_poll_controller;
 #endif
+	SET_ETHTOOL_OPS(dev, &ethtool_ops);
 
 	if (mtu)
 		dev->mtu = mtu;
@@ -2477,177 +2479,136 @@
 	spin_unlock_irq(&np->lock);
 }
 
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	u32 cmd;
-
-	if (get_user(cmd, (u32 __user *)useraddr))
-		return -EFAULT;
-
-	switch (cmd) {
-	/* get driver info */
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-		strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN);
-		strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN);
-		info.fw_version[0] = '\0';
-		strncpy(info.bus_info, pci_name(np->pci_dev),
-			ETHTOOL_BUSINFO_LEN);
-		info.eedump_len = NATSEMI_EEPROM_SIZE;
-		info.regdump_len = NATSEMI_REGS_SIZE;
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-	/* get settings */
-	case ETHTOOL_GSET: {
-		struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-		spin_lock_irq(&np->lock);
-		netdev_get_ecmd(dev, &ecmd);
-		spin_unlock_irq(&np->lock);
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set settings */
-	case ETHTOOL_SSET: {
-		struct ethtool_cmd ecmd;
-		int r;
-		if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-			return -EFAULT;
-		spin_lock_irq(&np->lock);
-		r = netdev_set_ecmd(dev, &ecmd);
-		spin_unlock_irq(&np->lock);
-		return r;
-	}
-	/* get wake-on-lan */
-	case ETHTOOL_GWOL: {
-		struct ethtool_wolinfo wol = {ETHTOOL_GWOL};
-		spin_lock_irq(&np->lock);
-		netdev_get_wol(dev, &wol.supported, &wol.wolopts);
-		netdev_get_sopass(dev, wol.sopass);
-		spin_unlock_irq(&np->lock);
-		if (copy_to_user(useraddr, &wol, sizeof(wol)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set wake-on-lan */
-	case ETHTOOL_SWOL: {
-		struct ethtool_wolinfo wol;
-		int r;
-		if (copy_from_user(&wol, useraddr, sizeof(wol)))
-			return -EFAULT;
-		spin_lock_irq(&np->lock);
-		netdev_set_wol(dev, wol.wolopts);
-		r = netdev_set_sopass(dev, wol.sopass);
-		spin_unlock_irq(&np->lock);
-		return r;
-	}
-	/* get registers */
-	case ETHTOOL_GREGS: {
-		struct ethtool_regs regs;
-		u8 regbuf[NATSEMI_REGS_SIZE];
-		int r;
-
-		if (copy_from_user(&regs, useraddr, sizeof(regs)))
-			return -EFAULT;
-
-		if (regs.len > NATSEMI_REGS_SIZE) {
-			regs.len = NATSEMI_REGS_SIZE;
-		}
-		regs.version = NATSEMI_REGS_VER;
-		if (copy_to_user(useraddr, &regs, sizeof(regs)))
-			return -EFAULT;
+	strncpy(info->driver, DRV_NAME, ETHTOOL_BUSINFO_LEN);
+	strncpy(info->version, DRV_VERSION, ETHTOOL_BUSINFO_LEN);
+	strncpy(info->bus_info, pci_name(np->pci_dev), ETHTOOL_BUSINFO_LEN);
+}
 
-		useraddr += offsetof(struct ethtool_regs, data);
+static int get_regs_len(struct net_device *dev)
+{
+	return NATSEMI_REGS_SIZE;
+}
 
-		spin_lock_irq(&np->lock);
-		r = netdev_get_regs(dev, regbuf);
-		spin_unlock_irq(&np->lock);
+static int get_eeprom_len(struct net_device *dev)
+{
+	return NATSEMI_EEPROM_SIZE;
+}
 
-		if (r)
-			return r;
-		if (copy_to_user(useraddr, regbuf, regs.len))
-			return -EFAULT;
-		return 0;
-	}
-	/* get message-level */
-	case ETHTOOL_GMSGLVL: {
-		struct ethtool_value edata = {ETHTOOL_GMSGLVL};
-		edata.data = np->msg_enable;
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set message-level */
-	case ETHTOOL_SMSGLVL: {
-		struct ethtool_value edata;
-		if (copy_from_user(&edata, useraddr, sizeof(edata)))
-			return -EFAULT;
-		np->msg_enable = edata.data;
-		return 0;
-	}
-	/* restart autonegotiation */
-	case ETHTOOL_NWAY_RST: {
-		int tmp;
-		int r = -EINVAL;
-		/* if autoneg is off, it's an error */
-		tmp = mdio_read(dev, MII_BMCR);
-		if (tmp & BMCR_ANENABLE) {
-			tmp |= (BMCR_ANRESTART);
-			mdio_write(dev, MII_BMCR, tmp);
-			r = 0;
-		}
-		return r;
-	}
-	/* get link status */
-	case ETHTOOL_GLINK: {
-		struct ethtool_value edata = {ETHTOOL_GLINK};
-		/* LSTATUS is latched low until a read - so read twice */
-		mdio_read(dev, MII_BMSR);
-		edata.data = (mdio_read(dev, MII_BMSR)&BMSR_LSTATUS) ? 1:0;
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-	/* get EEPROM */
-	case ETHTOOL_GEEPROM: {
-		struct ethtool_eeprom eeprom;
-		u8 eebuf[NATSEMI_EEPROM_SIZE];
-		int r;
+static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	spin_lock_irq(&np->lock);
+	netdev_get_ecmd(dev, ecmd);
+	spin_unlock_irq(&np->lock);
+	return 0;
+}
 
-		if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
-			return -EFAULT;
+static int set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	int res;
+	spin_lock_irq(&np->lock);
+	res = netdev_set_ecmd(dev, ecmd);
+	spin_unlock_irq(&np->lock);
+	return res;
+}
 
-		if (eeprom.offset > eeprom.offset+eeprom.len)
-			return -EINVAL;
+static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	spin_lock_irq(&np->lock);
+	netdev_get_wol(dev, &wol->supported, &wol->wolopts);
+	netdev_get_sopass(dev, wol->sopass);
+	spin_unlock_irq(&np->lock);
+}
 
-		if ((eeprom.offset+eeprom.len) > NATSEMI_EEPROM_SIZE) {
-			eeprom.len = NATSEMI_EEPROM_SIZE-eeprom.offset;
-		}
-		eeprom.magic = PCI_VENDOR_ID_NS | (PCI_DEVICE_ID_NS_83815<<16);
-		if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
-			return -EFAULT;
+static int set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	int res;
+	spin_lock_irq(&np->lock);
+	netdev_set_wol(dev, wol->wolopts);
+	res = netdev_set_sopass(dev, wol->sopass);
+	spin_unlock_irq(&np->lock);
+	return res;
+}
 
-		useraddr += offsetof(struct ethtool_eeprom, data);
+static void get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	regs->version = NATSEMI_REGS_VER;
+	spin_lock_irq(&np->lock);
+	netdev_get_regs(dev, buf);
+	spin_unlock_irq(&np->lock);
+}
 
-		spin_lock_irq(&np->lock);
-		r = netdev_get_eeprom(dev, eebuf);
-		spin_unlock_irq(&np->lock);
+static u32 get_msglevel(struct net_device *dev)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	return np->msg_enable;
+}
 
-		if (r)
-			return r;
-		if (copy_to_user(useraddr, eebuf+eeprom.offset, eeprom.len))
-			return -EFAULT;
-		return 0;
-	}
+static void set_msglevel(struct net_device *dev, u32 val)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	np->msg_enable = val;
+}
 
+static int nway_reset(struct net_device *dev)
+{
+	int tmp;
+	int r = -EINVAL;
+	/* if autoneg is off, it's an error */
+	tmp = mdio_read(dev, MII_BMCR);
+	if (tmp & BMCR_ANENABLE) {
+		tmp |= (BMCR_ANRESTART);
+		mdio_write(dev, MII_BMCR, tmp);
+		r = 0;
 	}
+	return r;
+}
 
-	return -EOPNOTSUPP;
+static u32 get_link(struct net_device *dev)
+{
+	/* LSTATUS is latched low until a read - so read twice */
+	mdio_read(dev, MII_BMSR);
+	return (mdio_read(dev, MII_BMSR)&BMSR_LSTATUS) ? 1:0;
 }
 
+static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	u8 eebuf[NATSEMI_EEPROM_SIZE];
+	int res;
+
+	eeprom->magic = PCI_VENDOR_ID_NS | (PCI_DEVICE_ID_NS_83815<<16);
+	spin_lock_irq(&np->lock);
+	res = netdev_get_eeprom(dev, eebuf);
+	spin_unlock_irq(&np->lock);
+	if (!res)
+		memcpy(data, eebuf+eeprom->offset, eeprom->len);
+	return res;
+}
+
+static struct ethtool_ops ethtool_ops = {
+	.get_drvinfo = get_drvinfo,
+	.get_regs_len = get_regs_len,
+	.get_eeprom_len = get_eeprom_len,
+	.get_settings = get_settings,
+	.set_settings = set_settings,
+	.get_wol = get_wol,
+	.set_wol = set_wol,
+	.get_regs = get_regs,
+	.get_msglevel = get_msglevel,
+	.set_msglevel = set_msglevel,
+	.nway_reset = nway_reset,
+	.get_link = get_link,
+	.get_eeprom = get_eeprom,
+};
+
 static int netdev_set_wol(struct net_device *dev, u32 newval)
 {
 	struct netdev_private *np = netdev_priv(dev);
@@ -3002,8 +2963,6 @@
 	struct netdev_private *np = netdev_priv(dev);
 
 	switch(cmd) {
-	case SIOCETHTOOL:
-		return netdev_ethtool_ioctl(dev, rq->ifr_data);
 	case SIOCGMIIPHY:		/* Get address of MII PHY in use. */
 	case SIOCDEVPRIVATE:		/* for binary compat, remove in 2.5 */
 		data->phy_id = np->phy_addr_external;
diff -Nru a/drivers/net/ne2.c b/drivers/net/ne2.c
--- a/drivers/net/ne2.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/net/ne2.c	2004-12-24 13:37:31 -08:00
@@ -74,9 +74,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
--- a/drivers/net/ne2k-pci.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/ne2k-pci.c	2004-12-24 13:36:31 -08:00
@@ -653,12 +653,43 @@
 	pci_set_drvdata(pdev, NULL);
 }
 
+#ifdef CONFIG_PM
+static int ne2k_pci_suspend (struct pci_dev *pdev, u32 state)
+{
+	struct net_device *dev = pci_get_drvdata (pdev);
+
+	netif_device_detach(dev);
+	pci_save_state(pdev);
+	pci_set_power_state(pdev, state);
+
+	return 0;
+}
+
+static int ne2k_pci_resume (struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata (pdev);
+
+	pci_set_power_state(pdev, 0);
+	pci_restore_state(pdev);
+	NS8390_init(dev, 1);
+	netif_device_attach(dev);
+
+	return 0;
+}
+
+#endif /* CONFIG_PM */
+
 
 static struct pci_driver ne2k_driver = {
 	.name		= DRV_NAME,
 	.probe		= ne2k_pci_init_one,
 	.remove		= __devexit_p(ne2k_pci_remove_one),
 	.id_table	= ne2k_pci_tbl,
+#ifdef CONFIG_PM
+	.suspend	= ne2k_pci_suspend,
+	.resume		= ne2k_pci_resume,
+#endif /* CONFIG_PM */
+
 };
 
 
diff -Nru a/drivers/net/net_init.c b/drivers/net/net_init.c
--- a/drivers/net/net_init.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/net_init.c	2004-12-24 13:36:17 -08:00
@@ -105,260 +105,6 @@
 }
 EXPORT_SYMBOL(alloc_netdev);
 
-/**
- * alloc_etherdev - Allocates and sets up an ethernet device
- * @sizeof_priv: Size of additional driver-private structure to be allocated
- *	for this ethernet device
- *
- * Fill in the fields of the device structure with ethernet-generic
- * values. Basically does everything except registering the device.
- *
- * Constructs a new net device, complete with a private data area of
- * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
- * this private data area.
- */
-
-struct net_device *alloc_etherdev(int sizeof_priv)
-{
-	return alloc_netdev(sizeof_priv, "eth%d", ether_setup);
-}
-
-EXPORT_SYMBOL(alloc_etherdev);
-
-static int eth_mac_addr(struct net_device *dev, void *p)
-{
-	struct sockaddr *addr=p;
-	if (netif_running(dev))
-		return -EBUSY;
-	memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
-	return 0;
-}
-
-static int eth_change_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < 68) || (new_mtu > 1500))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return 0;
-}
-
-#ifdef CONFIG_FDDI
-
-/**
- * alloc_fddidev - Register FDDI device
- * @sizeof_priv: Size of additional driver-private structure to be allocated
- *	for this FDDI device
- *
- * Fill in the fields of the device structure with FDDI-generic values.
- *
- * Constructs a new net device, complete with a private data area of
- * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
- * this private data area.
- */
-
-struct net_device *alloc_fddidev(int sizeof_priv)
-{
-	return alloc_netdev(sizeof_priv, "fddi%d", fddi_setup);
-}
-
-EXPORT_SYMBOL(alloc_fddidev);
-
-static int fddi_change_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < FDDI_K_SNAP_HLEN) || (new_mtu > FDDI_K_SNAP_DLEN))
-		return(-EINVAL);
-	dev->mtu = new_mtu;
-	return(0);
-}
-
-#endif /* CONFIG_FDDI */
-
-#ifdef CONFIG_HIPPI
-
-static int hippi_change_mtu(struct net_device *dev, int new_mtu)
-{
-	/*
-	 * HIPPI's got these nice large MTUs.
-	 */
-	if ((new_mtu < 68) || (new_mtu > 65280))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return(0);
-}
-
-
-/*
- * For HIPPI we will actually use the lower 4 bytes of the hardware
- * address as the I-FIELD rather than the actual hardware address.
- */
-static int hippi_mac_addr(struct net_device *dev, void *p)
-{
-	struct sockaddr *addr = p;
-	if (netif_running(dev))
-		return -EBUSY;
-	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
-	return 0;
-}
-
-static int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p)
-{
-	/* Never send broadcast/multicast ARP messages */
-	p->mcast_probes = 0;
- 
-	/* In IPv6 unicast probes are valid even on NBMA,
-	* because they are encapsulated in normal IPv6 protocol.
-	* Should be a generic flag. 
-	*/
-	if (p->tbl->family != AF_INET6)
-		p->ucast_probes = 0;
-	return 0;
-}
-
-static void hippi_setup(struct net_device *dev)
-{
-	dev->set_multicast_list	= NULL;
-	dev->change_mtu			= hippi_change_mtu;
-	dev->hard_header		= hippi_header;
-	dev->rebuild_header 		= hippi_rebuild_header;
-	dev->set_mac_address 		= hippi_mac_addr;
-	dev->hard_header_parse		= NULL;
-	dev->hard_header_cache		= NULL;
-	dev->header_cache_update	= NULL;
-	dev->neigh_setup 		= hippi_neigh_setup_dev; 
-
-	/*
-	 * We don't support HIPPI `ARP' for the time being, and probably
-	 * never will unless someone else implements it. However we
-	 * still need a fake ARPHRD to make ifconfig and friends play ball.
-	 */
-	dev->type		= ARPHRD_HIPPI;
-	dev->hard_header_len 	= HIPPI_HLEN;
-	dev->mtu		= 65280;
-	dev->addr_len		= HIPPI_ALEN;
-	dev->tx_queue_len	= 25 /* 5 */;
-	memset(dev->broadcast, 0xFF, HIPPI_ALEN);
-
-
-	/*
-	 * HIPPI doesn't support broadcast+multicast and we only use
-	 * static ARP tables. ARP is disabled by hippi_neigh_setup_dev. 
-	 */
-	dev->flags = 0; 
-}
-
-/**
- * alloc_hippi_dev - Register HIPPI device
- * @sizeof_priv: Size of additional driver-private structure to be allocated
- *	for this HIPPI device
- *
- * Fill in the fields of the device structure with HIPPI-generic values.
- *
- * Constructs a new net device, complete with a private data area of
- * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
- * this private data area.
- */
-
-struct net_device *alloc_hippi_dev(int sizeof_priv)
-{
-	return alloc_netdev(sizeof_priv, "hip%d", hippi_setup);
-}
-
-EXPORT_SYMBOL(alloc_hippi_dev);
-
-#endif /* CONFIG_HIPPI */
-
-void ether_setup(struct net_device *dev)
-{
-	/* Fill in the fields of the device structure with ethernet-generic values.
-	   This should be in a common file instead of per-driver.  */
-	
-	dev->change_mtu		= eth_change_mtu;
-	dev->hard_header	= eth_header;
-	dev->rebuild_header 	= eth_rebuild_header;
-	dev->set_mac_address 	= eth_mac_addr;
-	dev->hard_header_cache	= eth_header_cache;
-	dev->header_cache_update= eth_header_cache_update;
-	dev->hard_header_parse	= eth_header_parse;
-
-	dev->type		= ARPHRD_ETHER;
-	dev->hard_header_len 	= ETH_HLEN;
-	dev->mtu		= 1500; /* eth_mtu */
-	dev->addr_len		= ETH_ALEN;
-	dev->tx_queue_len	= 1000;	/* Ethernet wants good queues */	
-	
-	memset(dev->broadcast,0xFF, ETH_ALEN);
-
-	/* New-style flags. */
-	dev->flags		= IFF_BROADCAST|IFF_MULTICAST;
-}
-EXPORT_SYMBOL(ether_setup);
-
-#ifdef CONFIG_FDDI
-
-void fddi_setup(struct net_device *dev)
-{
-	/*
-	 * Fill in the fields of the device structure with FDDI-generic values.
-	 * This should be in a common file instead of per-driver.
-	 */
-	
-	dev->change_mtu			= fddi_change_mtu;
-	dev->hard_header		= fddi_header;
-	dev->rebuild_header		= fddi_rebuild_header;
-
-	dev->type				= ARPHRD_FDDI;
-	dev->hard_header_len	= FDDI_K_SNAP_HLEN+3;	/* Assume 802.2 SNAP hdr len + 3 pad bytes */
-	dev->mtu				= FDDI_K_SNAP_DLEN;		/* Assume max payload of 802.2 SNAP frame */
-	dev->addr_len			= FDDI_K_ALEN;
-	dev->tx_queue_len		= 100;	/* Long queues on FDDI */
-	
-	memset(dev->broadcast, 0xFF, FDDI_K_ALEN);
-
-	/* New-style flags */
-	dev->flags		= IFF_BROADCAST | IFF_MULTICAST;
-}
-EXPORT_SYMBOL(fddi_setup);
-
-#endif /* CONFIG_FDDI */
-
-#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE)
-
-static int ltalk_change_mtu(struct net_device *dev, int mtu)
-{
-	return -EINVAL;
-}
-
-static int ltalk_mac_addr(struct net_device *dev, void *addr)
-{	
-	return -EINVAL;
-}
-
-
-void ltalk_setup(struct net_device *dev)
-{
-	/* Fill in the fields of the device structure with localtalk-generic values. */
-	
-	dev->change_mtu		= ltalk_change_mtu;
-	dev->hard_header	= NULL;
-	dev->rebuild_header 	= NULL;
-	dev->set_mac_address 	= ltalk_mac_addr;
-	dev->hard_header_cache	= NULL;
-	dev->header_cache_update= NULL;
-
-	dev->type		= ARPHRD_LOCALTLK;
-	dev->hard_header_len 	= LTALK_HLEN;
-	dev->mtu		= LTALK_MTU;
-	dev->addr_len		= LTALK_ALEN;
-	dev->tx_queue_len	= 10;	
-	
-	dev->broadcast[0]	= 0xFF;
-
-	dev->flags		= IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP;
-}
-EXPORT_SYMBOL(ltalk_setup);
-
-#endif /* CONFIG_ATALK || CONFIG_ATALK_MODULE */
-
 int register_netdev(struct net_device *dev)
 {
 	int err;
@@ -404,90 +150,3 @@
 
 EXPORT_SYMBOL(register_netdev);
 EXPORT_SYMBOL(unregister_netdev);
-
-#ifdef CONFIG_TR
-
-void tr_setup(struct net_device *dev)
-{
-	/*
-	 *	Configure and register
-	 */
-	
-	dev->hard_header	= tr_header;
-	dev->rebuild_header	= tr_rebuild_header;
-
-	dev->type		= ARPHRD_IEEE802_TR;
-	dev->hard_header_len	= TR_HLEN;
-	dev->mtu		= 2000;
-	dev->addr_len		= TR_ALEN;
-	dev->tx_queue_len	= 100;	/* Long queues on tr */
-	
-	memset(dev->broadcast,0xFF, TR_ALEN);
-
-	/* New-style flags. */
-	dev->flags		= IFF_BROADCAST | IFF_MULTICAST ;
-}
-
-/**
- * alloc_trdev - Register token ring device
- * @sizeof_priv: Size of additional driver-private structure to be allocated
- *	for this token ring device
- *
- * Fill in the fields of the device structure with token ring-generic values.
- *
- * Constructs a new net device, complete with a private data area of
- * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
- * this private data area.
- */
-
-struct net_device *alloc_trdev(int sizeof_priv)
-{
-	return alloc_netdev(sizeof_priv, "tr%d", tr_setup);
-}
-
-EXPORT_SYMBOL(tr_setup);
-EXPORT_SYMBOL(alloc_trdev);
-
-#endif /* CONFIG_TR */
-
-#ifdef CONFIG_NET_FC
-
-void fc_setup(struct net_device *dev)
-{
-	dev->hard_header        =        fc_header;
-        dev->rebuild_header  	=        fc_rebuild_header;
-                
-        dev->type               =        ARPHRD_IEEE802;
-	dev->hard_header_len    =        FC_HLEN;
-        dev->mtu                =        2024;
-        dev->addr_len           =        FC_ALEN;
-        dev->tx_queue_len       =        100; /* Long queues on fc */
-
-        memset(dev->broadcast,0xFF, FC_ALEN);
-
-        /* New-style flags. */
-        dev->flags              =        IFF_BROADCAST;
-}
-
-/**
- * alloc_fcdev - Register fibre channel device
- * @sizeof_priv: Size of additional driver-private structure to be allocated
- *	for this fibre channel device
- *
- * Fill in the fields of the device structure with fibre channel-generic values.
- *
- * Constructs a new net device, complete with a private data area of
- * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
- * this private data area.
- */
-
-struct net_device *alloc_fcdev(int sizeof_priv)
-{
-	return alloc_netdev(sizeof_priv, "fc%d", fc_setup);
-}
-
-EXPORT_SYMBOL(fc_setup);
-EXPORT_SYMBOL(alloc_fcdev);
-
-#endif /* CONFIG_NET_FC */
-
diff -Nru a/drivers/net/ni5010.c b/drivers/net/ni5010.c
--- a/drivers/net/ni5010.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/ni5010.c	2004-12-24 13:36:48 -08:00
@@ -59,7 +59,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/init.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/ni52.c b/drivers/net/ni52.c
--- a/drivers/net/ni52.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/ni52.c	2004-12-24 13:37:00 -08:00
@@ -115,7 +115,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/init.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 
 #include <linux/netdevice.h>
diff -Nru a/drivers/net/ni65.c b/drivers/net/ni65.c
--- a/drivers/net/ni65.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/ni65.c	2004-12-24 13:36:31 -08:00
@@ -73,8 +73,8 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/module.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/ns83820.c b/drivers/net/ns83820.c
--- a/drivers/net/ns83820.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/ns83820.c	2004-12-24 13:37:29 -08:00
@@ -64,6 +64,8 @@
  *				tuning
  *			0.20 -	fix stupid RFEN thinko.  i am such a smurf.
  *
+ *	20040828	0.21 -	add hardware vlan accleration
+ *				by Neil Horman <nhorman@redhat.com>
  * Driver Overview
  * ===============
  *
@@ -92,7 +94,9 @@
 //#define dprintk		printk
 #define dprintk(x...)		do { } while (0)
 
+#include <linux/config.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
@@ -108,6 +112,7 @@
 #include <linux/prefetch.h>
 #include <linux/ethtool.h>
 #include <linux/timer.h>
+#include <linux/if_vlan.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -115,7 +120,7 @@
 
 #define DRV_NAME "ns83820"
 
-/* Global parameters.  See MODULE_PARM near the bottom. */
+/* Global parameters.  See module_param near the bottom. */
 static int ihr = 2;
 static int reset_phy = 0;
 static int lnksts = 0;		/* CFG_LNKSTS bit polarity */
@@ -138,6 +143,9 @@
 
 /* tunables */
 #define RX_BUF_SIZE	1500	/* 8192 */
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+#define NS83820_VLAN_ACCEL_SUPPORT
+#endif
 
 /* Must not exceed ~65000. */
 #define NR_RX_DESC	64
@@ -262,6 +270,8 @@
 #define EXTSTS_UDPPKT	0x00200000
 #define EXTSTS_TCPPKT	0x00080000
 #define EXTSTS_IPPKT	0x00020000
+#define EXTSTS_VPKT	0x00010000
+#define EXTSTS_VTG_MASK	0x0000ffff
 
 #define SPDSTS_POLARITY	(CFG_SPDSTS1 | CFG_SPDSTS0 | CFG_DUPSTS | (lnksts ? CFG_LNKSTS : 0))
 
@@ -403,6 +413,7 @@
 #define CMDSTS_INTR	0x20000000
 #define CMDSTS_ERR	0x10000000
 #define CMDSTS_OK	0x08000000
+#define CMDSTS_RUNT	0x00200000
 #define CMDSTS_LEN_MASK	0x0000ffff
 
 #define CMDSTS_DEST_MASK	0x01800000
@@ -428,10 +439,14 @@
 
 struct ns83820 {
 	struct net_device_stats	stats;
-	u8			*base;
+	u8			__iomem *base;
 
 	struct pci_dev		*pci_dev;
 
+#ifdef NS83820_VLAN_ACCEL_SUPPORT
+	struct vlan_group	*vlgrp;
+#endif
+
 	struct rx_info		rx_info;
 	struct tasklet_struct	rx_tasklet;
 
@@ -494,6 +509,33 @@
 	(((NR_TX_DESC-2 + dev->tx_done_idx - dev->tx_free_idx) % NR_TX_DESC) > MIN_TX_DESC_FREE)
 
 
+#ifdef NS83820_VLAN_ACCEL_SUPPORT 
+static void ns83820_vlan_rx_register(struct net_device *ndev, struct vlan_group *grp)
+{
+	struct ns83820 *dev = PRIV(ndev);
+
+	spin_lock_irq(&dev->misc_lock);
+	spin_lock(&dev->tx_lock);
+
+	dev->vlgrp = grp;
+
+	spin_unlock(&dev->tx_lock);
+	spin_unlock_irq(&dev->misc_lock);
+}
+
+static void ns83820_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid)
+{
+	struct ns83820 *dev = PRIV(ndev);
+
+	spin_lock_irq(&dev->misc_lock);
+	spin_lock(&dev->tx_lock);
+	if (dev->vlgrp)
+		dev->vlgrp->vlan_devices[vid] = NULL;
+	spin_unlock(&dev->tx_lock);
+	spin_unlock_irq(&dev->misc_lock);
+}
+#endif
+
 /* Packet Receiver
  *
  * The hardware supports linked lists of receive descriptors for
@@ -836,6 +878,7 @@
 	struct ns83820 *dev = PRIV(ndev);
 	struct rx_info *info = &dev->rx_info;
 	unsigned next_rx;
+	int rx_rc, len;
 	u32 cmdsts, *desc;
 	unsigned long flags;
 	int nr = 0;
@@ -876,8 +919,24 @@
 
 		pci_unmap_single(dev->pci_dev, bufptr,
 				 RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
+		len = cmdsts & CMDSTS_LEN_MASK;
+#ifdef NS83820_VLAN_ACCEL_SUPPORT
+		/* NH: As was mentioned below, this chip is kinda
+		 * brain dead about vlan tag stripping.  Frames
+		 * that are 64 bytes with a vlan header appended
+		 * like arp frames, or pings, are flagged as Runts
+		 * when the tag is stripped and hardware.  This
+		 * also means that the OK bit in the descriptor 
+		 * is cleared when the frame comes in so we have
+		 * to do a specific length check here to make sure
+		 * the frame would have been ok, had we not stripped
+		 * the tag.
+		 */ 
+		if (likely((CMDSTS_OK & cmdsts) ||
+			((cmdsts & CMDSTS_RUNT) && len >= 56))) {   
+#else
 		if (likely(CMDSTS_OK & cmdsts)) {
-			int len = cmdsts & 0xffff;
+#endif
 			skb_put(skb, len);
 			if (unlikely(!skb))
 				goto netdev_mangle_me_harder_failed;
@@ -891,7 +950,18 @@
 				skb->ip_summed = CHECKSUM_NONE;
 			}
 			skb->protocol = eth_type_trans(skb, ndev);
-			if (NET_RX_DROP == netif_rx(skb)) {
+#ifdef NS83820_VLAN_ACCEL_SUPPORT 
+			if(extsts & EXTSTS_VPKT) {
+				unsigned short tag;
+				tag = ntohs(extsts & EXTSTS_VTG_MASK);
+				rx_rc = vlan_hwaccel_rx(skb,dev->vlgrp,tag);
+			} else {
+				rx_rc = netif_rx(skb);
+			}
+#else
+			rx_rc = netif_rx(skb);
+#endif
+			if (NET_RX_DROP == rx_rc) {
 netdev_mangle_me_harder_failed:
 				dev->stats.rx_dropped ++;
 			}
@@ -1099,6 +1169,17 @@
 			extsts |= EXTSTS_UDPPKT;
 	}
 
+#ifdef NS83820_VLAN_ACCEL_SUPPORT
+	if(vlan_tx_tag_present(skb)) {
+		/* fetch the vlan tag info out of the
+		 * ancilliary data if the vlan code
+		 * is using hw vlan acceleration
+		 */
+		short tag = vlan_tx_tag_get(skb);
+		extsts |= (EXTSTS_VPKT | htons(tag));
+	}
+#endif
+
 	len = skb->len;
 	if (nr_frags)
 		len -= skb->data_len;
@@ -1164,7 +1245,7 @@
 
 static void ns83820_update_stats(struct ns83820 *dev)
 {
-	u8 *base = dev->base;
+	u8 __iomem *base = dev->base;
 
 	/* the DP83820 will freeze counters, so we need to read all of them */
 	dev->stats.rx_errors		+= readl(base + 0x60) & 0xffff;
@@ -1192,59 +1273,26 @@
 	return &dev->stats;
 }
 
-static int ns83820_ethtool_ioctl (struct ns83820 *dev, void __user *useraddr)
+static void ns83820_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info)
 {
-	u32 ethcmd;
-
-	if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
-		return -EFAULT;
-
-	switch (ethcmd) {
-	case ETHTOOL_GDRVINFO:
-		{
-			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-			strcpy(info.driver, "ns83820");
-			strcpy(info.version, VERSION);
-			strcpy(info.bus_info, pci_name(dev->pci_dev));
-			if (copy_to_user(useraddr, &info, sizeof (info)))
-				return -EFAULT;
-			return 0;
-		}
-
-	/* get link status */
-	case ETHTOOL_GLINK: {
-		struct ethtool_value edata = { ETHTOOL_GLINK };
-		u32 cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY;
-
-		if (cfg & CFG_LNKSTS)
-			edata.data = 1;
-		else
-			edata.data = 0;
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-
-	default:
-		break;
-	}
-
-	return -EOPNOTSUPP;
+	struct ns83820 *dev = PRIV(ndev);
+	strcpy(info->driver, "ns83820");
+	strcpy(info->version, VERSION);
+	strcpy(info->bus_info, pci_name(dev->pci_dev));
 }
 
-static int ns83820_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
+static u32 ns83820_get_link(struct net_device *ndev)
 {
 	struct ns83820 *dev = PRIV(ndev);
-
-	switch(cmd) {
-	case SIOCETHTOOL:
-		return ns83820_ethtool_ioctl(dev, rq->ifr_data);
-
-	default:
-		return -EOPNOTSUPP;
-	}
+	u32 cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY;
+	return cfg & CFG_LNKSTS ? 1 : 0;
 }
 
+static struct ethtool_ops ops = {
+	.get_drvinfo = ns83820_get_drvinfo,
+	.get_link = ns83820_get_link
+};
+
 static void ns83820_mib_isr(struct ns83820 *dev)
 {
 	spin_lock(&dev->misc_lock);
@@ -1545,7 +1593,7 @@
 static void ns83820_set_multicast(struct net_device *ndev)
 {
 	struct ns83820 *dev = PRIV(ndev);
-	u8 *rfcr = dev->base + RFCR;
+	u8 __iomem *rfcr = dev->base + RFCR;
 	u32 and_mask = 0xffffffff;
 	u32 or_mask = 0;
 	u32 val;
@@ -1849,7 +1897,7 @@
 
 	dev->IMR_cache = 0;
 
-	setup_ee_mem_bitbanger(&dev->ee, (long)dev->base + MEAR, 3, 2, 1, 0,
+	setup_ee_mem_bitbanger(&dev->ee, dev->base + MEAR, 3, 2, 1, 0,
 		0);
 
 	err = request_irq(pci_dev->irq, ns83820_irq, SA_SHIRQ,
@@ -1884,10 +1932,9 @@
 	ndev->get_stats = ns83820_get_stats;
 	ndev->change_mtu = ns83820_change_mtu;
 	ndev->set_multicast_list = ns83820_set_multicast;
-	ndev->do_ioctl = ns83820_ioctl;
+	SET_ETHTOOL_OPS(ndev, &ops);
 	ndev->tx_timeout = ns83820_tx_timeout;
 	ndev->watchdog_timeo = 5 * HZ;
-
 	pci_set_drvdata(pci_dev, ndev);
 
 	ns83820_do_reset(dev, CR_RST);
@@ -2013,11 +2060,25 @@
 	 * a ping with a VLAN header) then the card, strips the 4 byte VLAN
 	 * tag and then checks the packet size, so if RXCFG_ARP is not enabled,
 	 * it discrards it!.  These guys......
+	 * also turn on tag stripping if hardware acceleration is enabled
 	 */
-	writel(VRCR_IPEN | VRCR_VTDEN, dev->base + VRCR);
+#ifdef NS83820_VLAN_ACCEL_SUPPORT
+#define VRCR_INIT_VALUE (VRCR_IPEN|VRCR_VTDEN|VRCR_VTREN) 
+#else
+#define VRCR_INIT_VALUE (VRCR_IPEN|VRCR_VTDEN)
+#endif
+	writel(VRCR_INIT_VALUE, dev->base + VRCR);
 
-	/* Enable per-packet TCP/UDP/IP checksumming */
-	writel(VTCR_PPCHK, dev->base + VTCR);
+	/* Enable per-packet TCP/UDP/IP checksumming
+	 * and per packet vlan tag insertion if
+	 * vlan hardware acceleration is enabled
+	 */
+#ifdef NS83820_VLAN_ACCEL_SUPPORT
+#define VTCR_INIT_VALUE (VTCR_PPCHK|VTCR_VPPTI)
+#else
+#define VTCR_INIT_VALUE VTCR_PPCHK
+#endif
+	writel(VTCR_INIT_VALUE, dev->base + VTCR);
 
 	/* Ramit : Enable async and sync pause frames */
 	/* writel(0, dev->base + PCR); */
@@ -2034,6 +2095,13 @@
 	ndev->features |= NETIF_F_SG;
 	ndev->features |= NETIF_F_IP_CSUM;
 
+#ifdef NS83820_VLAN_ACCEL_SUPPORT
+	/* We also support hardware vlan acceleration */
+	ndev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
+	ndev->vlan_rx_register = ns83820_vlan_rx_register;
+	ndev->vlan_rx_kill_vid = ns83820_vlan_rx_kill_vid;
+#endif
+
 	if (using_dac) {
 		printk(KERN_INFO "%s: using 64 bit addressing.\n",
 			ndev->name);
@@ -2142,13 +2210,13 @@
 
 MODULE_DEVICE_TABLE(pci, ns83820_pci_tbl);
 
-MODULE_PARM(lnksts, "i");
+module_param(lnksts, int, 0);
 MODULE_PARM_DESC(lnksts, "Polarity of LNKSTS bit");
 
-MODULE_PARM(ihr, "i");
+module_param(ihr, int, 0);
 MODULE_PARM_DESC(ihr, "Time in 100 us increments to delay interrupts (range 0-127)");
 
-MODULE_PARM(reset_phy, "i");
+module_param(reset_phy, int, 0);
 MODULE_PARM_DESC(reset_phy, "Set to 1 to reset the PHY on startup");
 
 module_init(ns83820_init);
diff -Nru a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
--- a/drivers/net/pci-skeleton.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/pci-skeleton.c	2004-12-24 13:36:17 -08:00
@@ -481,7 +481,6 @@
 	unsigned int mediasense:1;	/* Media sensing in progress. */
 	spinlock_t lock;
 	chip_t chipset;
-	u32 pci_state[16];	/* Data saved during suspend */
 };
 
 MODULE_AUTHOR ("Jeff Garzik <jgarzik@pobox.com>");
@@ -796,7 +795,7 @@
 	tp->pci_dev = pdev;
 	tp->board = ent->driver_data;
 	tp->mmio_addr = ioaddr;
-	tp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&tp->lock);
 
 	pci_set_drvdata(pdev, dev);
 
@@ -1921,7 +1920,7 @@
 
 	spin_unlock_irqrestore (&tp->lock, flags);
 
-	pci_save_state (pdev, tp->pci_state);
+	pci_save_state (pdev);
 	pci_set_power_state (pdev, 3);
 
 	return 0;
@@ -1936,7 +1935,7 @@
 	if (!netif_running(dev))
 		return 0;
 	pci_set_power_state (pdev, 0);
-	pci_restore_state (pdev, tp->pci_state);
+	pci_restore_state (pdev);
 	netif_device_attach (dev);
 	netdrv_hw_start (dev);
 
diff -Nru a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
--- a/drivers/net/pcmcia/3c574_cs.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/pcmcia/3c574_cs.c	2004-12-24 13:36:31 -08:00
@@ -84,6 +84,7 @@
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <pcmcia/version.h>
 #include <pcmcia/cs_types.h>
@@ -97,7 +98,6 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 /*====================================================================*/
 
diff -Nru a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
--- a/drivers/net/pcmcia/3c589_cs.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/pcmcia/3c589_cs.c	2004-12-24 13:37:29 -08:00
@@ -38,6 +38,7 @@
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
+#include <linux/bitops.h>
 
 #include <pcmcia/version.h>
 #include <pcmcia/cs_types.h>
@@ -50,7 +51,6 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 /* To minimize the size of the driver source I only define operating
    constants if they are used several times.  You'll need the manual
diff -Nru a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
--- a/drivers/net/pcmcia/axnet_cs.c	2004-12-24 13:36:57 -08:00
+++ b/drivers/net/pcmcia/axnet_cs.c	2004-12-24 13:36:57 -08:00
@@ -936,7 +936,7 @@
 static const char *version_8390 =
     "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@scyld.com)\n";
 
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/irq.h>
 #include <linux/fcntl.h>
 #include <linux/in.h>
diff -Nru a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
--- a/drivers/net/pcmcia/nmclan_cs.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/pcmcia/nmclan_cs.c	2004-12-24 13:36:18 -08:00
@@ -144,6 +144,7 @@
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
+#include <linux/bitops.h>
 
 #include <pcmcia/version.h>
 #include <pcmcia/cs_types.h>
@@ -155,7 +156,6 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 /* ----------------------------------------------------------------------------
 Defines
diff -Nru a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
--- a/drivers/net/pcmcia/smc91c92_cs.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/pcmcia/smc91c92_cs.c	2004-12-24 13:37:01 -08:00
@@ -304,6 +304,7 @@
 static int mdio_read(struct net_device *dev, int phy_id, int loc);
 static void mdio_write(struct net_device *dev, int phy_id, int loc, int value);
 static int smc_link_ok(struct net_device *dev);
+static struct ethtool_ops ethtool_ops;
 
 /*======================================================================
 
@@ -357,6 +358,7 @@
     dev->open = &smc_open;
     dev->stop = &smc_close;
     dev->do_ioctl = &smc_ioctl;
+    SET_ETHTOOL_OPS(dev, &ethtool_ops);
 #ifdef HAVE_TX_TIMEOUT
     dev->tx_timeout = smc_tx_timeout;
     dev->watchdog_timeo = TX_TIMEOUT;
@@ -2113,136 +2115,135 @@
 	tmp |= TCR_FDUPLX;
     else
 	tmp &= ~TCR_FDUPLX;
-    outw(ioaddr + TCR, tmp);
+    outw(tmp, ioaddr + TCR);
 	
     return 0;
 }
 
-static int smc_ethtool_ioctl (struct net_device *dev, void __user *useraddr)
+static int check_if_running(struct net_device *dev)
 {
-    u32 ethcmd;
-    struct smc_private *smc = netdev_priv(dev);
-
-    if (get_user(ethcmd, (u32 __user *)useraddr))
-	return -EFAULT;
-
-    switch (ethcmd) {
-
-    case ETHTOOL_GDRVINFO: {
-	struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-	strcpy(info.driver, DRV_NAME);
-	strcpy(info.version, DRV_VERSION);
-	if (copy_to_user(useraddr, &info, sizeof(info)))
-	    return -EFAULT;
+	if (!netif_running(dev))
+		return -EINVAL;
 	return 0;
-    }
+}
+
+static void smc_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+}
 
-    /* get settings */
-    case ETHTOOL_GSET: {
+static int smc_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct smc_private *smc = netdev_priv(dev);
+	ioaddr_t ioaddr = dev->base_addr;
+	u16 saved_bank = inw(ioaddr + BANK_SELECT);
 	int ret;
-	struct ethtool_cmd ecmd = { ETHTOOL_GSET };
+
+	SMC_SELECT_BANK(3);
 	spin_lock_irq(&smc->lock);
 	if (smc->cfg & CFG_MII_SELECT)
-	    ret = mii_ethtool_gset(&smc->mii_if, &ecmd);
+		ret = mii_ethtool_gset(&smc->mii_if, ecmd);
 	else
-	    ret = smc_netdev_get_ecmd(dev, &ecmd);
+		ret = smc_netdev_get_ecmd(dev, ecmd);
 	spin_unlock_irq(&smc->lock);
-	if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-	    return -EFAULT;
+	SMC_SELECT_BANK(saved_bank);
 	return ret;
-    }
+}
 
-    /* set settings */
-    case ETHTOOL_SSET: {
+static int smc_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct smc_private *smc = netdev_priv(dev);
+	ioaddr_t ioaddr = dev->base_addr;
+	u16 saved_bank = inw(ioaddr + BANK_SELECT);
 	int ret;
-	struct ethtool_cmd ecmd;
-	if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-	    return -EFAULT;
+
+	SMC_SELECT_BANK(3);
 	spin_lock_irq(&smc->lock);
 	if (smc->cfg & CFG_MII_SELECT)
-	    ret = mii_ethtool_sset(&smc->mii_if, &ecmd);
+		ret = mii_ethtool_sset(&smc->mii_if, ecmd);
 	else
-	    ret = smc_netdev_set_ecmd(dev, &ecmd);
+		ret = smc_netdev_set_ecmd(dev, ecmd);
 	spin_unlock_irq(&smc->lock);
+	SMC_SELECT_BANK(saved_bank);
 	return ret;
-    }
+}
+
+static u32 smc_get_link(struct net_device *dev)
+{
+	struct smc_private *smc = netdev_priv(dev);
+	ioaddr_t ioaddr = dev->base_addr;
+	u16 saved_bank = inw(ioaddr + BANK_SELECT);
+	u32 ret;
 
-    /* get link status */
-    case ETHTOOL_GLINK: {
-	struct ethtool_value edata = { ETHTOOL_GLINK };
+	SMC_SELECT_BANK(3);
 	spin_lock_irq(&smc->lock);
-	edata.data = smc_link_ok(dev);
+	ret = smc_link_ok(dev);
 	spin_unlock_irq(&smc->lock);
-	if (copy_to_user(useraddr, &edata, sizeof(edata)))
-	    return -EFAULT;
-	return 0;
-    }
+	SMC_SELECT_BANK(saved_bank);
+	return ret;
+}
 
 #ifdef PCMCIA_DEBUG
-    /* get message-level */
-    case ETHTOOL_GMSGLVL: {
-	struct ethtool_value edata = { ETHTOOL_GMSGLVL };
-	edata.data = pc_debug;
-	if (copy_to_user(useraddr, &edata, sizeof(edata)))
-	    return -EFAULT;
-	return 0;
-    }
+static u32 smc_get_msglevel(struct net_device *dev)
+{
+	return pc_debug;
+}
 
-    /* set message-level */
-    case ETHTOOL_SMSGLVL: {
-	struct ethtool_value edata;
-	if (copy_from_user(&edata, useraddr, sizeof(edata)))
-	    return -EFAULT;
-	pc_debug = edata.data;
-	return 0;
-    }
+static void smc_set_msglevel(struct net_device *dev, u32 val)
+{
+	pc_debug = val;
+}
 #endif
-    /* restart autonegotiation */
-    case ETHTOOL_NWAY_RST: {
-	if (smc->cfg & CFG_MII_SELECT)
-	    return mii_nway_restart(&smc->mii_if);
-	else
-	    return -EOPNOTSUPP;
-    }
-
-    default:
-	break;
-    }
 
-    return -EOPNOTSUPP;
-}
+static int smc_nway_reset(struct net_device *dev)
+{
+	struct smc_private *smc = netdev_priv(dev);
+	if (smc->cfg & CFG_MII_SELECT) {
+		ioaddr_t ioaddr = dev->base_addr;
+		u16 saved_bank = inw(ioaddr + BANK_SELECT);
+		int res;
+
+		SMC_SELECT_BANK(3);
+		res = mii_nway_restart(&smc->mii_if);
+		SMC_SELECT_BANK(saved_bank);
+
+		return res;
+	} else
+		return -EOPNOTSUPP;
+}
+
+static struct ethtool_ops ethtool_ops = {
+	.begin = check_if_running,
+	.get_drvinfo = smc_get_drvinfo,
+	.get_settings = smc_get_settings,
+	.set_settings = smc_set_settings,
+	.get_link = smc_get_link,
+#ifdef PCMCIA_DEBUG
+	.get_msglevel = smc_get_msglevel,
+	.set_msglevel = smc_set_msglevel,
+#endif
+	.nway_reset = smc_nway_reset,
+};
 
 static int smc_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
 {
-    struct smc_private *smc = netdev_priv(dev);
-    struct mii_ioctl_data *mii;
-    int rc = 0;
-    u_short saved_bank;
-    ioaddr_t ioaddr = dev->base_addr;
-
-    mii = if_mii(rq);
-    if (!netif_running(dev))
-    	return -EINVAL;
+	struct smc_private *smc = netdev_priv(dev);
+	struct mii_ioctl_data *mii = if_mii(rq);
+	int rc = 0;
+	u16 saved_bank;
+	ioaddr_t ioaddr = dev->base_addr;
 
-    switch (cmd) {
-    case SIOCETHTOOL:
-	saved_bank = inw(ioaddr + BANK_SELECT);
-	SMC_SELECT_BANK(3);
-	rc = smc_ethtool_ioctl(dev, rq->ifr_data);
-	SMC_SELECT_BANK(saved_bank);
-	break;
+	if (!netif_running(dev))
+		return -EINVAL;
 
-    default:
 	spin_lock_irq(&smc->lock);
 	saved_bank = inw(ioaddr + BANK_SELECT);
 	SMC_SELECT_BANK(3);
 	rc = generic_mii_ioctl(&smc->mii_if, mii, cmd, NULL);
 	SMC_SELECT_BANK(saved_bank);
 	spin_unlock_irq(&smc->lock);
-	break;
-    }
-
-    return rc;
+	return rc;
 }
 
 static struct pcmcia_driver smc91c92_cs_driver = {
diff -Nru a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
--- a/drivers/net/pcmcia/xirc2ps_cs.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/pcmcia/xirc2ps_cs.c	2004-12-24 13:36:47 -08:00
@@ -79,6 +79,7 @@
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
+#include <linux/bitops.h>
 
 #include <pcmcia/version.h>
 #include <pcmcia/cs_types.h>
@@ -89,7 +90,6 @@
 
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 #ifndef MANFID_COMPAQ
diff -Nru a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
--- a/drivers/net/pcnet32.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/pcnet32.c	2004-12-24 13:36:31 -08:00
@@ -47,8 +47,8 @@
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
 #include <linux/moduleparam.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -359,9 +359,9 @@
     struct net_device_stats stats;
     char		tx_full;
     int			options;
-    int	shared_irq:1,			/* shared irq possible */
-	dxsuflo:1,			/* disable transmit stop on uflo */
-	mii:1;				/* mii port available */
+    unsigned int	shared_irq:1,	/* shared irq possible */
+			dxsuflo:1,	/* disable transmit stop on uflo */
+			mii:1;		/* mii port available */
     struct net_device	*next;
     struct mii_if_info	mii_if;
     struct timer_list	watchdog_timer;
@@ -1010,7 +1010,11 @@
 	return -EBUSY;
     }
 
-    return pcnet32_probe1(ioaddr, 1, pdev);
+    err =  pcnet32_probe1(ioaddr, 1, pdev);
+    if (err < 0) {
+	pci_disable_device(pdev);
+    }
+    return err;
 }
 
 
@@ -2249,6 +2253,7 @@
 	release_region(dev->base_addr, PCNET32_TOTAL_SIZE);
 	pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
 	free_netdev(dev);
+	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
     }
 }
@@ -2264,7 +2269,6 @@
 static int debug = -1;
 static int tx_start_pt = -1;
 static int pcnet32_have_pci;
-static int num_params;
 
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, DRV_NAME " debug level");
@@ -2276,12 +2280,12 @@
 MODULE_PARM_DESC(tx_start_pt, DRV_NAME " transmit start point (0-3)");
 module_param(pcnet32vlb, int, 0);
 MODULE_PARM_DESC(pcnet32vlb, DRV_NAME " Vesa local bus (VLB) support (0/1)");
-module_param_array(options, int, num_params, 0);
+module_param_array(options, int, NULL, 0);
 MODULE_PARM_DESC(options, DRV_NAME " initial option setting(s) (0-15)");
-module_param_array(full_duplex, int, num_params, 0);
+module_param_array(full_duplex, int, NULL, 0);
 MODULE_PARM_DESC(full_duplex, DRV_NAME " full duplex setting(s) (1)");
 /* Module Parameter for HomePNA cards added by Patrick Simmons, 2004 */
-module_param_array(homepna, int, num_params, 0);
+module_param_array(homepna, int, NULL, 0);
 MODULE_PARM_DESC(homepna, DRV_NAME " mode for 79C978 cards (1 for HomePNA, 0 for Ethernet, default Ethernet");
 
 MODULE_AUTHOR("Thomas Bogendoerfer");
diff -Nru a/drivers/net/plip.c b/drivers/net/plip.c
--- a/drivers/net/plip.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/net/plip.c	2004-12-24 13:37:30 -08:00
@@ -109,11 +109,11 @@
 #include <linux/ioport.h>
 #include <linux/spinlock.h>
 #include <linux/parport.h>
+#include <linux/bitops.h>
 
 #include <net/neighbour.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/irq.h>
 #include <asm/byteorder.h>
 #include <asm/semaphore.h>
diff -Nru a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
--- a/drivers/net/ppp_async.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/net/ppp_async.c	2004-12-24 13:37:04 -08:00
@@ -238,6 +238,18 @@
 }
 
 /*
+ * Called on tty hangup in process context.
+ *
+ * Wait for I/O to driver to complete and unregister PPP channel.
+ * This is already done by the close routine, so just call that.
+ */
+static int ppp_asynctty_hangup(struct tty_struct *tty)
+{
+	ppp_asynctty_close(tty);
+	return 0;
+}
+
+/*
  * Read does nothing - no data is ever available this way.
  * Pppd reads and writes packets via /dev/ppp instead.
  */
@@ -254,7 +266,7 @@
  */
 static ssize_t
 ppp_asynctty_write(struct tty_struct *tty, struct file *file,
-		   const unsigned char __user *buf, size_t count)
+		   const unsigned char *buf, size_t count)
 {
 	return -EAGAIN;
 }
@@ -380,6 +392,7 @@
 	.name	= "ppp",
 	.open	= ppp_asynctty_open,
 	.close	= ppp_asynctty_close,
+	.hangup	= ppp_asynctty_hangup,
 	.read	= ppp_asynctty_read,
 	.write	= ppp_asynctty_write,
 	.ioctl	= ppp_asynctty_ioctl,
@@ -673,7 +686,7 @@
 		if (!tty_stuffed && ap->optr < ap->olim) {
 			avail = ap->olim - ap->optr;
 			set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-			sent = tty->driver->write(tty, 0, ap->optr, avail);
+			sent = tty->driver->write(tty, ap->optr, avail);
 			if (sent < 0)
 				goto flush;	/* error, e.g. loss of CD */
 			ap->optr += sent;
@@ -898,7 +911,9 @@
 			break;
 
 		c = buf[n];
-		if (c == PPP_FLAG) {
+		if (flags != NULL && flags[n] != 0) {
+			ap->state |= SC_TOSS;
+		} else if (c == PPP_FLAG) {
 			process_input_packet(ap);
 		} else if (c == PPP_ESCAPE) {
 			ap->state |= SC_ESCAPE;
diff -Nru a/drivers/net/ppp_deflate.c b/drivers/net/ppp_deflate.c
--- a/drivers/net/ppp_deflate.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/ppp_deflate.c	2004-12-24 13:37:19 -08:00
@@ -636,7 +636,7 @@
 	.owner =		THIS_MODULE
 };
 
-int __init deflate_init(void)
+static int __init deflate_init(void)
 {  
         int answer = ppp_register_compressor(&ppp_deflate);
         if (answer == 0)
@@ -646,7 +646,7 @@
         return answer;
 }
      
-void __exit deflate_cleanup(void)
+static void __exit deflate_cleanup(void)
 {
 	ppp_unregister_compressor(&ppp_deflate);
 	ppp_unregister_compressor(&ppp_deflate_draft);
diff -Nru a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
--- a/drivers/net/ppp_generic.c	2004-12-24 13:37:20 -08:00
+++ b/drivers/net/ppp_generic.c	2004-12-24 13:37:29 -08:00
@@ -19,7 +19,7 @@
  * PPP driver, written by Michael Callahan and Al Longyear, and
  * subsequently hacked by Paul Mackerras.
  *
- * ==FILEVERSION 20020217==
+ * ==FILEVERSION 20041108==
  */
 
 #include <linux/config.h>
@@ -412,6 +412,17 @@
 		ret = 0;
 		if (pf->dead)
 			break;
+		if (pf->kind == INTERFACE) {
+			/*
+			 * Return 0 (EOF) on an interface that has no
+			 * channels connected, unless it is looping
+			 * network traffic (demand mode).
+			 */
+			struct ppp *ppp = PF_TO_PPP(pf);
+			if (ppp->n_channels == 0
+			    && (ppp->flags & SC_LOOP_TRAFFIC) == 0)
+				break;
+		}
 		ret = -EAGAIN;
 		if (file->f_flags & O_NONBLOCK)
 			break;
@@ -491,6 +502,14 @@
 		mask |= POLLIN | POLLRDNORM;
 	if (pf->dead)
 		mask |= POLLHUP;
+	else if (pf->kind == INTERFACE) {
+		/* see comment in ppp_read */
+		struct ppp *ppp = PF_TO_PPP(pf);
+		if (ppp->n_channels == 0
+		    && (ppp->flags & SC_LOOP_TRAFFIC) == 0)
+			mask |= POLLIN | POLLRDNORM;
+	}
+
 	return mask;
 }
 
@@ -1920,7 +1939,7 @@
 #endif /* CONFIG_PPP_MULTILINK */
 	init_rwsem(&pch->chan_sem);
 	spin_lock_init(&pch->downl);
-	pch->upl = RW_LOCK_UNLOCKED;
+	rwlock_init(&pch->upl);
 	spin_lock_bh(&all_channels_lock);
 	pch->file.index = ++last_channel_index;
 	list_add(&pch->list, &new_channels);
@@ -2559,7 +2578,8 @@
 		/* remove it from the ppp unit's list */
 		ppp_lock(ppp);
 		list_del(&pch->clist);
-		--ppp->n_channels;
+		if (--ppp->n_channels == 0)
+			wake_up_interruptible(&ppp->file.rwait);
 		ppp_unlock(ppp);
 		if (atomic_dec_and_test(&ppp->file.refcnt))
 			ppp_destroy_interface(ppp);
diff -Nru a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
--- a/drivers/net/ppp_synctty.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/ppp_synctty.c	2004-12-24 13:36:48 -08:00
@@ -285,6 +285,18 @@
 }
 
 /*
+ * Called on tty hangup in process context.
+ *
+ * Wait for I/O to driver to complete and unregister PPP channel.
+ * This is already done by the close routine, so just call that.
+ */
+static int ppp_sync_hangup(struct tty_struct *tty)
+{
+	ppp_sync_close(tty);
+	return 0;
+}
+
+/*
  * Read does nothing - no data is ever available this way.
  * Pppd reads and writes packets via /dev/ppp instead.
  */
@@ -301,7 +313,7 @@
  */
 static ssize_t
 ppp_sync_write(struct tty_struct *tty, struct file *file,
-		const unsigned char __user *buf, size_t count)
+		const unsigned char *buf, size_t count)
 {
 	return -EAGAIN;
 }
@@ -422,6 +434,7 @@
 	.name	= "pppsync",
 	.open	= ppp_sync_open,
 	.close	= ppp_sync_close,
+	.hangup	= ppp_sync_hangup,
 	.read	= ppp_sync_read,
 	.write	= ppp_sync_write,
 	.ioctl	= ppp_synctty_ioctl,
@@ -651,7 +664,7 @@
 			tty_stuffed = 0;
 		if (!tty_stuffed && ap->tpkt != 0) {
 			set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-			sent = tty->driver->write(tty, 0, ap->tpkt->data, ap->tpkt->len);
+			sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len);
 			if (sent < 0)
 				goto flush;	/* error, e.g. loss of CD */
 			if (sent < ap->tpkt->len) {
diff -Nru a/drivers/net/r8169.c b/drivers/net/r8169.c
--- a/drivers/net/r8169.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/r8169.c	2004-12-24 13:36:55 -08:00
@@ -150,6 +150,7 @@
 
 static struct pci_device_id rtl8169_pci_tbl[] = {
 	{0x10ec, 0x8169, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{0x1186, 0x4300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{0,},
 };
 
diff -Nru a/drivers/net/rrunner.c b/drivers/net/rrunner.c
--- a/drivers/net/rrunner.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/rrunner.c	2004-12-24 13:36:31 -08:00
@@ -157,7 +157,7 @@
 	 * Remap the regs into kernel space.
 	 */
 
-	rrpriv->regs = (struct rr_regs *)ioremap(dev->base_addr, 0x1000);
+	rrpriv->regs = ioremap(dev->base_addr, 0x1000);
 
 	if (!rrpriv->regs){
 		printk(KERN_ERR "%s:  Unable to map I/O register, "
@@ -267,7 +267,7 @@
  */
 static void rr_issue_cmd(struct rr_private *rrpriv, struct cmd *cmd)
 {
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	u32 idx;
 
 	regs = rrpriv->regs;
@@ -304,7 +304,7 @@
 static int rr_reset(struct net_device *dev)
 {
 	struct rr_private *rrpriv;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	struct eeprom *hw = NULL;
 	u32 start_pc;
 	int i;
@@ -418,7 +418,7 @@
 				unsigned char *buf,
 				unsigned long length)
 {
-	struct rr_regs *regs = rrpriv->regs;
+	struct rr_regs __iomem *regs = rrpriv->regs;
 	u32 misc, io, host, i;
 
 	io = readl(&regs->ExtIo);
@@ -470,7 +470,7 @@
 				 unsigned char *buf,
 				 unsigned long length)
 {
-	struct rr_regs *regs = rrpriv->regs;
+	struct rr_regs __iomem *regs = rrpriv->regs;
 	u32 misc, io, data, i, j, ready, error = 0;
 
 	io = readl(&regs->ExtIo);
@@ -520,7 +520,7 @@
 static int __init rr_init(struct net_device *dev)
 {
 	struct rr_private *rrpriv;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	struct eeprom *hw = NULL;
 	u32 sram_size, rev;
 	int i;
@@ -589,7 +589,7 @@
 static int rr_init1(struct net_device *dev)
 {
 	struct rr_private *rrpriv;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	unsigned long myjif, flags;
 	struct cmd cmd;
 	u32 hostctrl;
@@ -759,7 +759,7 @@
 static u32 rr_handle_event(struct net_device *dev, u32 prodidx, u32 eidx)
 {
 	struct rr_private *rrpriv;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	u32 tmp;
 
 	rrpriv = netdev_priv(dev);
@@ -962,7 +962,7 @@
 static void rx_int(struct net_device *dev, u32 rxlimit, u32 index)
 {
 	struct rr_private *rrpriv = netdev_priv(dev);
-	struct rr_regs *regs = rrpriv->regs;
+	struct rr_regs __iomem *regs = rrpriv->regs;
 
 	do {
 		struct rx_desc *desc;
@@ -1057,7 +1057,7 @@
 static irqreturn_t rr_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 	struct rr_private *rrpriv;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	struct net_device *dev = (struct net_device *)dev_id;
 	u32 prodidx, rxindex, eidx, txcsmr, rxlimit, txcon;
 
@@ -1186,7 +1186,7 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct rr_private *rrpriv = netdev_priv(dev);
-	struct rr_regs *regs = rrpriv->regs;
+	struct rr_regs __iomem *regs = rrpriv->regs;
 	unsigned long flags;
 
 	if (readl(&regs->HostCtrl) & NIC_HALTED){
@@ -1214,7 +1214,7 @@
 {
 	struct rr_private *rrpriv = netdev_priv(dev);
 	struct pci_dev *pdev = rrpriv->pci_dev;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	int ecode = 0;
 	unsigned long flags;
 	dma_addr_t dma_addr;
@@ -1300,7 +1300,7 @@
 static void rr_dump(struct net_device *dev)
 {
 	struct rr_private *rrpriv;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	u32 index, cons;
 	short i;
 	int len;
@@ -1363,7 +1363,7 @@
 static int rr_close(struct net_device *dev)
 {
 	struct rr_private *rrpriv;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	unsigned long flags;
 	u32 tmp;
 	short i;
@@ -1428,7 +1428,7 @@
 static int rr_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct rr_private *rrpriv = netdev_priv(dev);
-	struct rr_regs *regs = rrpriv->regs;
+	struct rr_regs __iomem *regs = rrpriv->regs;
 	struct ring_ctrl *txctrl;
 	unsigned long flags;
 	u32 index, len = skb->len;
@@ -1513,7 +1513,7 @@
 static int rr_load_firmware(struct net_device *dev)
 {
 	struct rr_private *rrpriv;
-	struct rr_regs *regs;
+	struct rr_regs __iomem *regs;
 	unsigned long eptr, segptr;
 	int i, j;
 	u32 localctrl, sptr, len, tmp;
diff -Nru a/drivers/net/rrunner.h b/drivers/net/rrunner.h
--- a/drivers/net/rrunner.h	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/rrunner.h	2004-12-24 13:37:01 -08:00
@@ -510,7 +510,7 @@
 }
 
 
-static inline void set_rxaddr(struct rr_regs *regs, volatile dma_addr_t addr)
+static inline void set_rxaddr(struct rr_regs __iomem *regs, volatile dma_addr_t addr)
 {
 	unsigned long baddr = addr;
 #if (BITS_PER_LONG == 64) && defined(__LITTLE_ENDIAN)
@@ -527,7 +527,7 @@
 }
 
 
-static inline void set_infoaddr(struct rr_regs *regs, volatile dma_addr_t addr)
+static inline void set_infoaddr(struct rr_regs __iomem *regs, volatile dma_addr_t addr)
 {
 	unsigned long baddr = addr;
 #if (BITS_PER_LONG == 64) && defined(__LITTLE_ENDIAN)
@@ -808,7 +808,7 @@
 	/* Alignment ok ? */
 	struct sk_buff		*rx_skbuff[RX_RING_ENTRIES];
 	struct sk_buff		*tx_skbuff[TX_RING_ENTRIES];
-	struct rr_regs		*regs;		/* Register base */
+	struct rr_regs		__iomem *regs;		/* Register base */
 	struct ring_ctrl	*rx_ctrl;	/* Receive ring control */
 	struct rr_info		*info;		/* Shared info page */
 	dma_addr_t 		rx_ctrl_dma;
diff -Nru a/drivers/net/s2io.c b/drivers/net/s2io.c
--- a/drivers/net/s2io.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/s2io.c	2004-12-24 13:37:01 -08:00
@@ -1935,7 +1935,7 @@
 	schedule_timeout(HZ / 4);
 
 	/* Restore the PCI state saved during initializarion. */
-	pci_restore_state(sp->pdev, sp->config_space);
+	pci_restore_state(sp->pdev);
 	s2io_init_pci(sp);
 
 	set_current_state(TASK_UNINTERRUPTIBLE);
@@ -3983,14 +3983,14 @@
 
 MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@s2io.com>");
 MODULE_LICENSE("GPL");
-MODULE_PARM(ring_num, "1-" __MODULE_STRING(1) "i");
-MODULE_PARM(frame_len, "1-" __MODULE_STRING(8) "i");
-MODULE_PARM(ring_len, "1-" __MODULE_STRING(8) "i");
-MODULE_PARM(fifo_num, "1-" __MODULE_STRING(1) "i");
-MODULE_PARM(fifo_len, "1-" __MODULE_STRING(8) "i");
-MODULE_PARM(rx_prio, "1-" __MODULE_STRING(1) "i");
-MODULE_PARM(tx_prio, "1-" __MODULE_STRING(1) "i");
-MODULE_PARM(latency_timer, "1-" __MODULE_STRING(1) "i");
+module_param(ring_num, uint, 0);
+module_param_array(frame_len, uint, NULL, 0);
+module_param_array(ring_len, uint, NULL, 0);
+module_param(fifo_num, uint, 0);
+module_param_array(fifo_len, uint, NULL, 0);
+module_param(rx_prio, uint, 0);
+module_param(tx_prio, uint, 0);
+module_param(latency_timer, byte, 0);
 
 /*
 *  Input Argument/s: 
@@ -4238,7 +4238,7 @@
 		goto register_failed;
 	}
 
-	pci_save_state(sp->pdev, sp->config_space);
+	pci_save_state(sp->pdev);
 
 	/* Setting swapper control on the NIC, for proper reset operation */
 	if (s2io_set_swapper(sp)) {
diff -Nru a/drivers/net/s2io.h b/drivers/net/s2io.h
--- a/drivers/net/s2io.h	2004-12-24 13:36:32 -08:00
+++ b/drivers/net/s2io.h	2004-12-24 13:36:32 -08:00
@@ -667,7 +667,6 @@
 	u8 cache_line;
 	u32 rom_expansion;
 	u16 pcix_cmd;
-	u32 config_space[256 / sizeof(u32)];
 	u32 irq;
 	atomic_t rx_bufs_left[MAX_RX_RINGS];
 
diff -Nru a/drivers/net/sb1000.c b/drivers/net/sb1000.c
--- a/drivers/net/sb1000.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/sb1000.c	2004-12-24 13:36:17 -08:00
@@ -50,8 +50,8 @@
 #include <linux/etherdevice.h>
 #include <linux/pnp.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/uaccess.h>
diff -Nru a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
--- a/drivers/net/sb1250-mac.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/sb1250-mac.c	2004-12-24 13:37:19 -08:00
@@ -68,8 +68,8 @@
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/config.h>
+#include <linux/bitops.h>
 #include <asm/processor.h>		/* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/cache.h>
 
diff -Nru a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
--- a/drivers/net/seeq8005.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/net/seeq8005.c	2004-12-24 13:37:04 -08:00
@@ -45,9 +45,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
--- a/drivers/net/sgiseeq.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/sgiseeq.c	2004-12-24 13:37:19 -08:00
@@ -19,11 +19,11 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/sgi/hpc3.h>
diff -Nru a/drivers/net/sis900.c b/drivers/net/sis900.c
--- a/drivers/net/sis900.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/sis900.c	2004-12-24 13:36:48 -08:00
@@ -64,9 +64,9 @@
 #include <linux/delay.h>
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 
 #include <asm/processor.h>      /* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>	/* User space memory access functions */
 
@@ -140,9 +140,9 @@
 };
 
 typedef struct _BufferDesc {
-	u32	link;
-	u32	cmdsts;
-	u32	bufptr;
+	u32 link;
+	u32 cmdsts;
+	u32 bufptr;
 } BufferDesc;
 
 struct sis900_private {
@@ -156,7 +156,7 @@
 	unsigned int cur_phy;
 
 	struct timer_list timer; /* Link status detection timer. */
-	u8     autong_complete; /* 1: auto-negotiate complete  */
+	u8 autong_complete; /* 1: auto-negotiate complete  */
 
 	unsigned int cur_rx, dirty_rx; /* producer/comsumer pointers for Tx/Rx ring */
 	unsigned int cur_tx, dirty_tx;
@@ -170,9 +170,8 @@
 	dma_addr_t tx_ring_dma;
 	dma_addr_t rx_ring_dma;
 
-	unsigned int tx_full;			/* The Tx queue is full.    */
+	unsigned int tx_full; /* The Tx queue is full. */
 	u8 host_bridge_rev;
-	u32 pci_state[16];
 };
 
 MODULE_AUTHOR("Jim Huang <cmhuang@sis.com.tw>, Ollie Lho <ollie@sis.com.tw>");
@@ -256,19 +255,19 @@
  *	MAC address is read into @net_dev->dev_addr.
  */
 
-static int __devinit sis630e_get_mac_addr(struct pci_dev * pci_dev, struct net_device *net_dev)
+static int __devinit sis630e_get_mac_addr(struct pci_dev * pci_dev,
+					struct net_device *net_dev)
 {
 	struct pci_dev *isa_bridge = NULL;
 	u8 reg;
 	int i;
 
-	isa_bridge = pci_find_device(PCI_VENDOR_ID_SI, 0x0008, isa_bridge);
+	isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, 0x0008, isa_bridge);
+	if (!isa_bridge)
+		isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, 0x0018, isa_bridge);
 	if (!isa_bridge) {
-		isa_bridge = pci_find_device(PCI_VENDOR_ID_SI, 0x0018, isa_bridge);
-		if (!isa_bridge) {
-			printk("%s: Can not find ISA bridge\n", net_dev->name);
-			return 0;
-		}
+		printk("%s: Can not find ISA bridge\n", net_dev->name);
+		return 0;
 	}
 	pci_read_config_byte(isa_bridge, 0x48, &reg);
 	pci_write_config_byte(isa_bridge, 0x48, reg | 0x40);
@@ -278,6 +277,7 @@
 		((u8 *)(net_dev->dev_addr))[i] = inb(0x71); 
 	}
 	pci_write_config_byte(isa_bridge, 0x48, reg & ~0x40);
+	pci_dev_put(isa_bridge);
 
 	return 1;
 }
@@ -293,7 +293,8 @@
  *	@net_dev->dev_addr.
  */
 
-static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev, struct net_device *net_dev)
+static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev,
+					struct net_device *net_dev)
 {
 	long ioaddr = net_dev->base_addr;
 	u32 rfcrSave;
@@ -335,7 +336,8 @@
  *	MAC address is read into @net_dev->dev_addr.
  */
 
-static int __devinit sis96x_get_mac_addr(struct pci_dev * pci_dev, struct net_device *net_dev)
+static int __devinit sis96x_get_mac_addr(struct pci_dev * pci_dev,
+					struct net_device *net_dev)
 {
 	long ioaddr = net_dev->base_addr;
 	long ee_addr = ioaddr + mear;
@@ -372,7 +374,8 @@
  *	ie: sis900_open(), sis900_start_xmit(), sis900_close(), etc.
  */
 
-static int __devinit sis900_probe (struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
+static int __devinit sis900_probe(struct pci_dev *pci_dev,
+				const struct pci_device_id *pci_id)
 {
 	struct sis900_private *sis_priv;
 	struct net_device *net_dev;
@@ -485,9 +488,11 @@
 	}
 
 	/* save our host bridge revision */
-	dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
-	if (dev)
+	dev = pci_get_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
+	if (dev) {
 		pci_read_config_byte(dev, PCI_CLASS_REVISION, &sis_priv->host_bridge_rev);
+		pci_dev_put(dev);
+	}
 
 	/* print some information about our NIC */
 	printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ", net_dev->name,
@@ -523,7 +528,7 @@
  *	return error if it failed to found.
  */
 
-static int __init sis900_mii_probe (struct net_device * net_dev)
+static int __init sis900_mii_probe(struct net_device * net_dev)
 {
 	struct sis900_private * sis_priv = net_dev->priv;
 	u16 poll_bit = MII_STAT_LINK, status = 0;
@@ -573,9 +578,10 @@
 				mii_phy->phy_types = mii_chip_table[i].phy_types;
 				if (mii_chip_table[i].phy_types == MIX)
 					mii_phy->phy_types =
-						(mii_status & (MII_STAT_CAN_TX_FDX | MII_STAT_CAN_TX)) ? LAN : HOME;
+					    (mii_status & (MII_STAT_CAN_TX_FDX | MII_STAT_CAN_TX)) ? LAN : HOME;
 				printk(KERN_INFO "%s: %s transceiver found at address %d.\n",
-				       net_dev->name, mii_chip_table[i].name, phy_addr);
+				       net_dev->name, mii_chip_table[i].name,
+				       phy_addr);
 				break;
 			}
 			
@@ -588,7 +594,7 @@
 	
 	if (sis_priv->mii == NULL) {
 		printk(KERN_INFO "%s: No MII transceivers found!\n",
-		       net_dev->name);
+			net_dev->name);
 		return 0;
 	}
 
@@ -612,7 +618,8 @@
 
 			poll_bit ^= (mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS) & poll_bit);
 			if (time_after_eq(jiffies, timeout)) {
-				printk(KERN_WARNING "%s: reset phy and link down now\n", net_dev->name);
+				printk(KERN_WARNING "%s: reset phy and link down now\n",
+					net_dev->name);
 				return -ETIME;
 			}
 		}
@@ -648,38 +655,41 @@
 static u16 sis900_default_phy(struct net_device * net_dev)
 {
 	struct sis900_private * sis_priv = net_dev->priv;
- 	struct mii_phy *phy = NULL, *phy_home = NULL, *default_phy = NULL, *phy_lan = NULL;
+ 	struct mii_phy *phy = NULL, *phy_home = NULL, 
+		*default_phy = NULL, *phy_lan = NULL;
 	u16 status;
 
-        for( phy=sis_priv->first_mii; phy; phy=phy->next ){
+        for (phy=sis_priv->first_mii; phy; phy=phy->next) {
 		status = mdio_read(net_dev, phy->phy_addr, MII_STATUS);
 		status = mdio_read(net_dev, phy->phy_addr, MII_STATUS);
 
 		/* Link ON & Not select default PHY & not ghost PHY */
-		 if ( (status & MII_STAT_LINK) && !default_phy && (phy->phy_types != UNKNOWN) )
+		 if ((status & MII_STAT_LINK) && !default_phy &&
+					(phy->phy_types != UNKNOWN))
 		 	default_phy = phy;
-		 else{
+		 else {
 			status = mdio_read(net_dev, phy->phy_addr, MII_CONTROL);
 			mdio_write(net_dev, phy->phy_addr, MII_CONTROL,
 				status | MII_CNTL_AUTO | MII_CNTL_ISOLATE);
-			if( phy->phy_types == HOME )
+			if (phy->phy_types == HOME)
 				phy_home = phy;
-			else if (phy->phy_types == LAN)
+			else if(phy->phy_types == LAN)
 				phy_lan = phy;
 		 }
 	}
 
-	if( !default_phy && phy_home )
+	if (!default_phy && phy_home)
 		default_phy = phy_home;
-	else if( !default_phy && phy_lan )
+	else if (!default_phy && phy_lan)
 		default_phy = phy_lan;
-	else if ( !default_phy )
+	else if (!default_phy)
 		default_phy = sis_priv->first_mii;
 
-	if( sis_priv->mii != default_phy ){
+	if (sis_priv->mii != default_phy) {
 		sis_priv->mii = default_phy;
 		sis_priv->cur_phy = default_phy->phy_addr;
-		printk(KERN_INFO "%s: Using transceiver found at address %d as default\n", net_dev->name,sis_priv->cur_phy);
+		printk(KERN_INFO "%s: Using transceiver found at address %d as default\n",
+					net_dev->name,sis_priv->cur_phy);
 	}
 	
 	status = mdio_read(net_dev, sis_priv->cur_phy, MII_CONTROL);
@@ -702,7 +712,7 @@
  *	mii status register. It's necessary before auto-negotiate.
  */
  
-static void sis900_set_capability( struct net_device *net_dev , struct mii_phy *phy )
+static void sis900_set_capability(struct net_device *net_dev, struct mii_phy *phy)
 {
 	u16 cap;
 	u16 status;
@@ -852,7 +862,8 @@
  *	please see SiS7014 or ICS spec
  */
 
-static void mdio_write(struct net_device *net_dev, int phy_id, int location, int value)
+static void mdio_write(struct net_device *net_dev, int phy_id, int location,
+			int value)
 {
 	long mdio_addr = net_dev->base_addr + mear;
 	int mii_cmd = MIIwrite|(phy_id<<MIIpmdShift)|(location<<MIIregShift);
@@ -940,7 +951,8 @@
 	pci_read_config_byte(sis_priv->pci_dev, PCI_CLASS_REVISION, &revision);
 	sis630_set_eq(net_dev, revision);
 
-	ret = request_irq(net_dev->irq, &sis900_interrupt, SA_SHIRQ, net_dev->name, net_dev);
+	ret = request_irq(net_dev->irq, &sis900_interrupt, SA_SHIRQ,
+						net_dev->name, net_dev);
 	if (ret)
 		return ret;
 
@@ -1137,48 +1149,55 @@
 		return;
 
 	if (netif_carrier_ok(net_dev)) {
-		reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
-		mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (0x2200 | reg14h) & 0xBFFF);
+		reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
+		mdio_write(net_dev, sis_priv->cur_phy, MII_RESV,
+					(0x2200 | reg14h) & 0xBFFF);
 		for (i=0; i < maxcount; i++) {
-			eq_value=(0x00F8 & mdio_read(net_dev, sis_priv->cur_phy, MII_RESV)) >> 3;
+			eq_value = (0x00F8 & mdio_read(net_dev,
+					sis_priv->cur_phy, MII_RESV)) >> 3;
 			if (i == 0)
 				max_value=min_value=eq_value;
-			max_value=(eq_value > max_value) ? eq_value : max_value;
-			min_value=(eq_value < min_value) ? eq_value : min_value;
+			max_value = (eq_value > max_value) ?
+						eq_value : max_value;
+			min_value = (eq_value < min_value) ?
+						eq_value : min_value;
 		}
 		/* 630E rule to determine the equalizer value */
 		if (revision == SIS630E_900_REV || revision == SIS630EA1_900_REV ||
 		    revision == SIS630ET_900_REV) {
 			if (max_value < 5)
-				eq_value=max_value;
+				eq_value = max_value;
 			else if (max_value >= 5 && max_value < 15)
-				eq_value=(max_value == min_value) ? max_value+2 : max_value+1;
+				eq_value = (max_value == min_value) ?
+						max_value+2 : max_value+1;
 			else if (max_value >= 15)
-				eq_value=(max_value == min_value) ? max_value+6 : max_value+5;
+				eq_value=(max_value == min_value) ?
+						max_value+6 : max_value+5;
 		}
 		/* 630B0&B1 rule to determine the equalizer value */
 		if (revision == SIS630A_900_REV && 
 		    (sis_priv->host_bridge_rev == SIS630B0 || 
 		     sis_priv->host_bridge_rev == SIS630B1)) {
 			if (max_value == 0)
-				eq_value=3;
+				eq_value = 3;
 			else
-				eq_value=(max_value+min_value+1)/2;
+				eq_value = (max_value + min_value + 1)/2;
 		}
 		/* write equalizer value and setting */
-		reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
-		reg14h=(reg14h & 0xFF07) | ((eq_value << 3) & 0x00F8);
-		reg14h=(reg14h | 0x6000) & 0xFDFF;
+		reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
+		reg14h = (reg14h & 0xFF07) | ((eq_value << 3) & 0x00F8);
+		reg14h = (reg14h | 0x6000) & 0xFDFF;
 		mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, reg14h);
-	}
-	else {
-		reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
+	} else {
+		reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
 		if (revision == SIS630A_900_REV && 
 		    (sis_priv->host_bridge_rev == SIS630B0 || 
 		     sis_priv->host_bridge_rev == SIS630B1)) 
-			mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (reg14h | 0x2200) & 0xBFFF);
+			mdio_write(net_dev, sis_priv->cur_phy, MII_RESV,
+						(reg14h | 0x2200) & 0xBFFF);
 		else
-			mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (reg14h | 0x2000) & 0xBFFF);
+			mdio_write(net_dev, sis_priv->cur_phy, MII_RESV,
+						(reg14h | 0x2000) & 0xBFFF);
 	}
 	return;
 }
@@ -1206,7 +1225,8 @@
 		sis900_read_mode(net_dev, &speed, &duplex);
 		if (duplex){
 			sis900_set_mode(net_dev->base_addr, speed, duplex);
-			pci_read_config_byte(sis_priv->pci_dev, PCI_CLASS_REVISION, &revision);
+			pci_read_config_byte(sis_priv->pci_dev,
+						PCI_CLASS_REVISION, &revision);
 			sis630_set_eq(net_dev, revision);
 			netif_start_queue(net_dev);
 		}
@@ -1230,9 +1250,8 @@
 			sis900_check_mode(net_dev, mii_phy);
 			netif_carrier_on(net_dev);
 		}
-	}
+	} else {
 	/* Link ON -> OFF */
-	else {
                 if (!(status & MII_STAT_LINK)){
                 	netif_carrier_off(net_dev);
                 	printk(KERN_INFO "%s: Media Link Off\n", net_dev->name);
@@ -1242,7 +1261,8 @@
 			    ((mii_phy->phy_id1 & 0xFFF0) == 0x8000))
                			sis900_reset_phy(net_dev,  sis_priv->cur_phy);
   
-                	pci_read_config_byte(sis_priv->pci_dev, PCI_CLASS_REVISION, &revision);
+                	pci_read_config_byte(sis_priv->pci_dev,
+					PCI_CLASS_REVISION, &revision);
 			sis630_set_eq(net_dev, revision);
   
                 	goto LookForLink;
@@ -1265,18 +1285,18 @@
  *	and autong_complete should be set to 1.
  */
 
-static void sis900_check_mode (struct net_device *net_dev, struct mii_phy *mii_phy)
+static void sis900_check_mode(struct net_device *net_dev, struct mii_phy *mii_phy)
 {
 	struct sis900_private *sis_priv = net_dev->priv;
 	long ioaddr = net_dev->base_addr;
 	int speed, duplex;
 
-	if( mii_phy->phy_types == LAN  ){
-		outl( ~EXD & inl( ioaddr + cfg ), ioaddr + cfg);
+	if (mii_phy->phy_types == LAN) {
+		outl(~EXD & inl(ioaddr + cfg), ioaddr + cfg);
 		sis900_set_capability(net_dev , mii_phy);
 		sis900_auto_negotiate(net_dev, sis_priv->cur_phy);
-	}else{
-		outl(EXD | inl( ioaddr + cfg ), ioaddr + cfg);
+	} else {
+		outl(EXD | inl(ioaddr + cfg), ioaddr + cfg);
 		speed = HW_SPEED_HOME;
 		duplex = FDX_CAPABLE_HALF_SELECTED;
 		sis900_set_mode(ioaddr, speed, duplex);
@@ -1301,20 +1321,20 @@
 {
 	u32 tx_flags = 0, rx_flags = 0;
 
-	if( inl(ioaddr + cfg) & EDB_MASTER_EN ){
-		tx_flags = TxATP | (DMA_BURST_64 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
+	if (inl(ioaddr + cfg) & EDB_MASTER_EN) {
+		tx_flags = TxATP | (DMA_BURST_64 << TxMXDMA_shift) |
+					(TX_FILL_THRESH << TxFILLT_shift);
 		rx_flags = DMA_BURST_64 << RxMXDMA_shift;
-	}
-	else{
-		tx_flags = TxATP | (DMA_BURST_512 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
+	} else {
+		tx_flags = TxATP | (DMA_BURST_512 << TxMXDMA_shift) |
+					(TX_FILL_THRESH << TxFILLT_shift);
 		rx_flags = DMA_BURST_512 << RxMXDMA_shift;
 	}
 
-	if (speed == HW_SPEED_HOME || speed == HW_SPEED_10_MBPS ) {
+	if (speed == HW_SPEED_HOME || speed == HW_SPEED_10_MBPS) {
 		rx_flags |= (RxDRNT_10 << RxDRNT_shift);
 		tx_flags |= (TxDRNT_10 << TxDRNT_shift);
-	}
-	else {
+	} else {
 		rx_flags |= (RxDRNT_100 << RxDRNT_shift);
 		tx_flags |= (TxDRNT_100 << TxDRNT_shift);
 	}
@@ -1404,19 +1424,19 @@
 	sis_priv->autong_complete = 1;
 
 	/* Workaround for Realtek RTL8201 PHY issue */
-	if((phy->phy_id0 == 0x0000) && ((phy->phy_id1 & 0xFFF0) == 0x8200)){
-		if(mdio_read(net_dev, phy_addr, MII_CONTROL) & MII_CNTL_FDX)
+	if ((phy->phy_id0 == 0x0000) && ((phy->phy_id1 & 0xFFF0) == 0x8200)) {
+		if (mdio_read(net_dev, phy_addr, MII_CONTROL) & MII_CNTL_FDX)
 			*duplex = FDX_CAPABLE_FULL_SELECTED;
-		if(mdio_read(net_dev, phy_addr, 0x0019) & 0x01)
+		if (mdio_read(net_dev, phy_addr, 0x0019) & 0x01)
 			*speed = HW_SPEED_100_MBPS;
 	}
 
 	printk(KERN_INFO "%s: Media Link On %s %s-duplex \n",
-	       net_dev->name,
-	       *speed == HW_SPEED_100_MBPS ?
-	       "100mbps" : "10mbps",
-	       *duplex == FDX_CAPABLE_FULL_SELECTED ?
-	       "full" : "half");
+	       				net_dev->name,
+	       				*speed == HW_SPEED_100_MBPS ?
+	       					"100mbps" : "10mbps",
+	       				*duplex == FDX_CAPABLE_FULL_SELECTED ?
+	       					"full" : "half");
 }
 
 /**
@@ -1678,13 +1698,13 @@
 			sis_priv->stats.rx_bytes += rx_size;
 			sis_priv->stats.rx_packets++;
 
-			/* refill the Rx buffer, what if there is not enought memory for
-			   new socket buffer ?? */
+			/* refill the Rx buffer, what if there is not enought
+			 * memory for new socket buffer ?? */
 			if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
-				/* not enough memory for skbuff, this makes a "hole"
-				   on the buffer ring, it is not clear how the
-				   hardware will react to this kind of degenerated
-				   buffer */
+				/* not enough memory for skbuff, this makes a
+				 * "hole" on the buffer ring, it is not clear
+				 * how the hardware will react to this kind
+				 * of degenerated buffer */
 				printk(KERN_INFO "%s: Memory squeeze,"
 				       "deferring packet.\n",
 				       net_dev->name);
@@ -1708,8 +1728,8 @@
 		rx_status = sis_priv->rx_ring[entry].cmdsts;
 	} // while
 
-	/* refill the Rx buffer, what if the rate of refilling is slower than 
-	   consuming ?? */
+	/* refill the Rx buffer, what if the rate of refilling is slower
+	 * than consuming ?? */
 	for (;sis_priv->cur_rx - sis_priv->dirty_rx > 0; sis_priv->dirty_rx++) {
 		struct sk_buff *skb;
 
@@ -1717,10 +1737,10 @@
 
 		if (sis_priv->rx_skbuff[entry] == NULL) {
 			if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
-				/* not enough memory for skbuff, this makes a "hole"
-				   on the buffer ring, it is not clear how the 
-				   hardware will react to this kind of degenerated 
-				   buffer */
+				/* not enough memory for skbuff, this makes a
+				 * "hole" on the buffer ring, it is not clear
+				 * how the hardware will react to this kind
+				 * of degenerated buffer */
 				printk(KERN_INFO "%s: Memory squeeze,"
 				       "deferring packet.\n",
 				       net_dev->name);
@@ -1765,8 +1785,8 @@
 
 		if (tx_status & OWN) {
 			/* The packet is not transmitted yet (owned by hardware) !
-			   Note: the interrupt is generated only when Tx Machine
-			   is idle, so this is an almost impossible case */
+			 * Note: the interrupt is generated only when Tx Machine
+			 * is idle, so this is an almost impossible case */
 			break;
 		}
 
@@ -1804,8 +1824,8 @@
 
 	if (sis_priv->tx_full && netif_queue_stopped(net_dev) &&
 	    sis_priv->cur_tx - sis_priv->dirty_tx < NUM_TX_DESC - 4) {
-		/* The ring is no longer full, clear tx_full and schedule more transmission
-		   by netif_wake_queue(net_dev) */
+		/* The ring is no longer full, clear tx_full and schedule
+		 * more transmission by netif_wake_queue(net_dev) */
 		sis_priv->tx_full = 0;
 		netif_wake_queue (net_dev);
 	}
@@ -1819,8 +1839,7 @@
  *	free Tx and RX socket buffer
  */
 
-static int
-sis900_close(struct net_device *net_dev)
+static int sis900_close(struct net_device *net_dev)
 {
 	long ioaddr = net_dev->base_addr;
 	struct sis900_private *sis_priv = net_dev->priv;
@@ -1956,27 +1975,28 @@
 
 	if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) {
 		/* we switch on the ifmap->port field. I couldn't find anything
-		   like a definition or standard for the values of that field.
-		   I think the meaning of those values is device specific. But
-		   since I would like to change the media type via the ifconfig
-		   command I use the definition from linux/netdevice.h 
-		   (which seems to be different from the ifport(pcmcia) definition) 
-		*/
+		 * like a definition or standard for the values of that field.
+		 * I think the meaning of those values is device specific. But
+		 * since I would like to change the media type via the ifconfig
+		 * command I use the definition from linux/netdevice.h 
+		 * (which seems to be different from the ifport(pcmcia) definition) */
 		switch(map->port){
 		case IF_PORT_UNKNOWN: /* use auto here */   
 			dev->if_port = map->port;
-			/* we are going to change the media type, so the Link will
-			   be temporary down and we need to reflect that here. When
-			   the Link comes up again, it will be sensed by the sis_timer
-			   procedure, which also does all the rest for us */
+			/* we are going to change the media type, so the Link
+			 * will be temporary down and we need to reflect that
+			 * here. When the Link comes up again, it will be
+			 * sensed by the sis_timer procedure, which also does
+			 * all the rest for us */
 			netif_carrier_off(dev);
                 
 			/* read current state */
 			status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL);
                 
 			/* enable auto negotiation and reset the negotioation
-			   (I don't really know what the auto negatiotiation reset
-			   really means, but it sounds for me right to do one here)*/
+			 * (I don't really know what the auto negatiotiation
+			 * reset really means, but it sounds for me right to
+			 * do one here) */
 			mdio_write(dev, mii_phy->phy_addr,
 				   MII_CONTROL, status | MII_CNTL_AUTO | MII_CNTL_RST_AUTO);
 
@@ -1985,10 +2005,11 @@
 		case IF_PORT_10BASET: /* 10BaseT */         
 			dev->if_port = map->port;
                 
-			/* we are going to change the media type, so the Link will
-			   be temporary down and we need to reflect that here. When
-			   the Link comes up again, it will be sensed by the sis_timer
-			   procedure, which also does all the rest for us */
+			/* we are going to change the media type, so the Link
+			 * will be temporary down and we need to reflect that
+			 * here. When the Link comes up again, it will be
+			 * sensed by the sis_timer procedure, which also does
+			 * all the rest for us */
 			netif_carrier_off(dev);
         
 			/* set Speed to 10Mbps */
@@ -1997,24 +2018,27 @@
                 
 			/* disable auto negotiation and force 10MBit mode*/
 			mdio_write(dev, mii_phy->phy_addr,
-				   MII_CONTROL, status & ~(MII_CNTL_SPEED | MII_CNTL_AUTO));
+				   MII_CONTROL, status & ~(MII_CNTL_SPEED |
+					MII_CNTL_AUTO));
 			break;
             
 		case IF_PORT_100BASET: /* 100BaseT */
 		case IF_PORT_100BASETX: /* 100BaseTx */ 
 			dev->if_port = map->port;
                 
-			/* we are going to change the media type, so the Link will
-			   be temporary down and we need to reflect that here. When
-			   the Link comes up again, it will be sensed by the sis_timer
-			   procedure, which also does all the rest for us */
+			/* we are going to change the media type, so the Link
+			 * will be temporary down and we need to reflect that
+			 * here. When the Link comes up again, it will be
+			 * sensed by the sis_timer procedure, which also does
+			 * all the rest for us */
 			netif_carrier_off(dev);
                 
 			/* set Speed to 100Mbps */
 			/* disable auto negotiation and enable 100MBit Mode */
 			status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL);
 			mdio_write(dev, mii_phy->phy_addr,
-				   MII_CONTROL, (status & ~MII_CNTL_SPEED) | MII_CNTL_SPEED);
+				   MII_CONTROL, (status & ~MII_CNTL_SPEED) |
+				   MII_CNTL_SPEED);
                 
 			break;
             
@@ -2094,12 +2118,14 @@
 		for (i = 0; i < table_entries; i++)
 			mc_filter[i] = 0xffff;
 	} else {
-		/* Accept Broadcast packet, destination address matchs our MAC address,
-		   use Receive Filter to reject unwanted MCAST packet */
+		/* Accept Broadcast packet, destination address matchs our
+		 * MAC address, use Receive Filter to reject unwanted MCAST
+		 * packets */
 		struct dev_mc_list *mclist;
 		rx_mode = RFAAB;
-		for (i = 0, mclist = net_dev->mc_list; mclist && i < net_dev->mc_count;
-		     i++, mclist = mclist->next) {
+		for (i = 0, mclist = net_dev->mc_list;
+			mclist && i < net_dev->mc_count;
+			i++, mclist = mclist->next) {
 			unsigned int bit_nr =
 				sis900_mcast_bitnr(mclist->dmi_addr, revision);
 			mc_filter[bit_nr >> 4] |= (1 << (bit_nr & 0xf));
@@ -2115,7 +2141,8 @@
 
 	outl(RFEN | rx_mode, ioaddr + rfcr);
 
-	/* sis900 is capatable of looping back packet at MAC level for debugging purpose */
+	/* sis900 is capable of looping back packets at MAC level for
+	 * debugging purpose */
 	if (net_dev->flags & IFF_LOOPBACK) {
 		u32 cr_saved;
 		/* We must disable Tx/Rx before setting loopback mode */
@@ -2200,7 +2227,6 @@
 static int sis900_suspend(struct pci_dev *pci_dev, u32 state)
 {
 	struct net_device *net_dev = pci_get_drvdata(pci_dev);
-	struct sis900_private *sis_priv = net_dev->priv;
 	long ioaddr = net_dev->base_addr;
 
 	if(!netif_running(net_dev))
@@ -2213,7 +2239,7 @@
 	outl(RxDIS | TxDIS | inl(ioaddr + cr), ioaddr + cr);
 
 	pci_set_power_state(pci_dev, 3);
-	pci_save_state(pci_dev, sis_priv->pci_state);
+	pci_save_state(pci_dev);
 
 	return 0;
 }
@@ -2226,7 +2252,7 @@
 
 	if(!netif_running(net_dev))
 		return 0;
-	pci_restore_state(pci_dev, sis_priv->pci_state);
+	pci_restore_state(pci_dev);
 	pci_set_power_state(pci_dev, 0);
 
 	sis900_init_rxfilter(net_dev);
diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
--- a/drivers/net/sk98lin/h/skdrv1st.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/sk98lin/h/skdrv1st.h	2004-12-24 13:36:17 -08:00
@@ -66,8 +66,8 @@
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/bitops.h>
 #include <asm/byteorder.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -109,7 +109,7 @@
 #define SK_MAX_MACS		2
 #define SK_MAX_NETS		2
 
-#define SK_IOC			char*
+#define SK_IOC			char __iomem *
 
 typedef struct s_DrvRlmtMbuf SK_MBUF;
 
diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-12-24 13:37:30 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-12-24 13:37:30 -08:00
@@ -285,7 +285,7 @@
 	TXD		*pTxdRingPrev;	/* descriptor sent previously */
 	int		TxdRingFree;	/* # of free entrys */
 	spinlock_t	TxDesRingLock;	/* serialize descriptor accesses */
-	caddr_t		HwAddr;		/* bmu registers address */
+	SK_IOC		HwAddr;		/* bmu registers address */
 	int		PortIndex;	/* index number of port (0 or 1) */
 };
 
@@ -301,7 +301,7 @@
 	int		RxdRingFree;	/* # of free entrys */
 	spinlock_t	RxDesRingLock;	/* serialize descriptor accesses */
 	int		RxFillLimit;	/* limit for buffers in ring */
-	caddr_t		HwAddr;		/* bmu registers address */
+	SK_IOC		HwAddr;		/* bmu registers address */
 	int		PortIndex;	/* index number of port (0 or 1) */
 };
 
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-12-24 13:36:18 -08:00
@@ -72,8 +72,8 @@
  *		<linux/slab.h>
  *		<linux/interrupt.h>
  *		<linux/pci.h>
+ *		<linux/bitops.h>
  *		<asm/byteorder.h>
- *		<asm/bitops.h>
  *		<asm/io.h>
  *		<linux/netdevice.h>
  *		<linux/etherdevice.h>
@@ -303,7 +303,7 @@
 	/*
 	 * Remap the regs into kernel space.
 	 */
-	pAC->IoBase = (char*)ioremap_nocache(dev->mem_start, 0x4000);
+	pAC->IoBase = ioremap_nocache(dev->mem_start, 0x4000);
 
 	if (!pAC->IoBase){
 		retval = 3;
diff -Nru a/drivers/net/sk_g16.c b/drivers/net/sk_g16.c
--- a/drivers/net/sk_g16.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/sk_g16.c	2004-12-24 13:37:43 -08:00
@@ -72,10 +72,10 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/bitops.h> 
 
 #include "sk_g16.h"
 
diff -Nru a/drivers/net/sk_mca.c b/drivers/net/sk_mca.c
--- a/drivers/net/sk_mca.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/sk_mca.c	2004-12-24 13:37:01 -08:00
@@ -97,9 +97,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/processor.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #define _SK_MCA_DRIVER_
@@ -972,14 +972,6 @@
 	return &(priv->stat);
 }
 
-/* we don't support runtime reconfiguration, since an MCA card can
-   be unambigously identified by its POS registers. */
-
-static int skmca_config(struct net_device *dev, struct ifmap *map)
-{
-	return 0;
-}
-
 /* switch receiver mode.  We use the LANCE's multicast filter to prefilter
    multicast addresses. */
 
@@ -1147,7 +1139,6 @@
 	/* set methods */
 	dev->open = skmca_open;
 	dev->stop = skmca_close;
-	dev->set_config = skmca_config;
 	dev->hard_start_xmit = skmca_tx;
 	dev->do_ioctl = NULL;
 	dev->get_stats = skmca_stats;
diff -Nru a/drivers/net/skfp/hwmtm.c b/drivers/net/skfp/hwmtm.c
--- a/drivers/net/skfp/hwmtm.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/net/skfp/hwmtm.c	2004-12-24 13:36:56 -08:00
@@ -1901,7 +1901,8 @@
 	}
 
 	if (!smc->hw.mac_ring_is_up || frag_count > queue->tx_free) {
-		if (frame_status &= ~LAN_TX) {
+		frame_status &= ~LAN_TX;
+		if (frame_status) {
 			DB_TX("Ring is down: terminate LAN_TX",0,0,2) ;
 		}
 		else {
diff -Nru a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
--- a/drivers/net/skfp/skfddi.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/skfp/skfddi.c	2004-12-24 13:36:17 -08:00
@@ -83,9 +83,9 @@
 #include <linux/netdevice.h>
 #include <linux/fddidevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
diff -Nru a/drivers/net/slip.c b/drivers/net/slip.c
--- a/drivers/net/slip.c	2004-12-24 13:37:34 -08:00
+++ b/drivers/net/slip.c	2004-12-24 13:37:34 -08:00
@@ -57,10 +57,11 @@
 #define SL_CHECK_TRANSMIT
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
@@ -85,8 +86,8 @@
 
 static struct net_device **slip_devs;
 
-int slip_maxdev = SL_NRUNIT;		/* Can be overridden with insmod! */
-MODULE_PARM(slip_maxdev, "i");
+static int slip_maxdev = SL_NRUNIT;
+module_param(slip_maxdev, int, 0);
 MODULE_PARM_DESC(slip_maxdev, "Maximum number of slip devices");
 
 static int slip_esc(unsigned char *p, unsigned char *d, int len);
@@ -417,7 +418,7 @@
 	 *       14 Oct 1994  Dmitry Gorodchanin.
 	 */
 	sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-	actual = sl->tty->driver->write(sl->tty, 0, sl->xbuff, count);
+	actual = sl->tty->driver->write(sl->tty, sl->xbuff, count);
 #ifdef SL_CHECK_TRANSMIT
 	sl->dev->trans_start = jiffies;
 #endif
@@ -451,20 +452,18 @@
 		return;
 	}
 
-	actual = tty->driver->write(tty, 0, sl->xhead, sl->xleft);
+	actual = tty->driver->write(tty, sl->xhead, sl->xleft);
 	sl->xleft -= actual;
 	sl->xhead += actual;
 }
 
 static void sl_tx_timeout(struct net_device *dev)
 {
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 
 	spin_lock(&sl->lock);
 
 	if (netif_queue_stopped(dev)) {
-		struct slip *sl = (struct slip*)(dev->priv);
-
 		if (!netif_running(dev))
 			goto out;
 
@@ -494,7 +493,7 @@
 static int
 sl_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 
 	spin_lock(&sl->lock);
 	if (!netif_running(dev))  {
@@ -528,7 +527,7 @@
 static int
 sl_close(struct net_device *dev)
 {
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 
 	spin_lock_bh(&sl->lock);
 	if (sl->tty) {
@@ -547,7 +546,7 @@
 
 static int sl_open(struct net_device *dev)
 {
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 
 	if (sl->tty==NULL)
 		return -ENODEV;
@@ -561,7 +560,7 @@
 
 static int sl_change_mtu(struct net_device *dev, int new_mtu)
 {
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 
 	if (new_mtu < 68 || new_mtu > 65534)
 		return -EINVAL;
@@ -577,7 +576,7 @@
 sl_get_stats(struct net_device *dev)
 {
 	static struct net_device_stats stats;
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 #ifdef SL_INCLUDE_CSLIP
 	struct slcompress *comp;
 #endif
@@ -612,7 +611,7 @@
 
 static int sl_init(struct net_device *dev)
 {
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 
 	/*
 	 *	Finish setting up the DEVICE info. 
@@ -630,7 +629,7 @@
 
 static void sl_uninit(struct net_device *dev)
 {
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 
 	sl_free_bufs(sl);
 }
@@ -719,7 +718,7 @@
 		if ((dev = slip_devs[i]) == NULL)
 			break;
 
-		sl = dev->priv;
+		sl = netdev_priv(dev);
 		if (sl->tty || sl->leased)
 			continue;
 		if (dev->flags&IFF_UP)
@@ -746,7 +745,7 @@
 		if (dev == NULL)
 			break;
 
-		sl = dev->priv;
+		sl = netdev_priv(dev);
 		if (sl->leased) {
 			if (sl->line != line)
 				continue;
@@ -788,7 +787,7 @@
 		i = sel;
 		dev = slip_devs[i];
 		if (score > 1) {
-			sl = dev->priv;
+			sl = netdev_priv(dev);
 			sl->flags &= (1 << SLF_INUSE);
 			return sl;
 		}
@@ -799,7 +798,7 @@
 		return NULL;
 
 	if (dev) {
-		sl = dev->priv;
+		sl = netdev_priv(dev);
 		if (test_bit(SLF_INUSE, &sl->flags)) {
 			unregister_netdevice(dev);
 			dev = NULL;
@@ -817,7 +816,7 @@
 		dev->base_addr  = i;
 	}
 
-	sl = dev->priv;
+	sl = netdev_priv(dev);
 
 	/* Initialize channel control data */
 	sl->magic       = SLIP_MAGIC;
@@ -1260,7 +1259,7 @@
 
 static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
 {
-	struct slip *sl = (struct slip*)(dev->priv);
+	struct slip *sl = netdev_priv(dev);
 	unsigned long *p = (unsigned long *)&rq->ifr_ifru;
 
 	if (sl == NULL)		/* Allocation failed ?? */
@@ -1406,7 +1405,7 @@
 			dev = slip_devs[i];
 			if (!dev)
 				continue;
-			sl = dev->priv;
+			sl = netdev_priv(dev);
 			spin_lock_bh(&sl->lock);
 			if (sl->tty) {
 				busy++;
@@ -1423,7 +1422,7 @@
 			continue;
 		slip_devs[i] = NULL;
 
-		sl = dev->priv;
+		sl = netdev_priv(dev);
 		if (sl->tty) {
 			printk(KERN_ERR "%s: tty discipline still running\n",
 			       dev->name);
@@ -1475,7 +1474,7 @@
 			if (!netif_queue_stopped(sl->dev))
 			{
 				/* if device busy no outfill */
-				sl->tty->driver->write(sl->tty, 0, &s, 1);
+				sl->tty->driver->write(sl->tty, &s, 1);
 			}
 		}
 		else
diff -Nru a/drivers/net/smc9194.c b/drivers/net/smc9194.c
--- a/drivers/net/smc9194.c	2004-12-24 13:37:17 -08:00
+++ b/drivers/net/smc9194.c	2004-12-24 13:37:17 -08:00
@@ -72,8 +72,8 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include "smc9194.h"
diff -Nru a/drivers/net/smc91x.c b/drivers/net/smc91x.c
--- a/drivers/net/smc91x.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/net/smc91x.c	2004-12-24 13:37:30 -08:00
@@ -55,12 +55,10 @@
  *                                  smc_phy_configure
  *                                - clean up (and fix stack overrun) in PHY
  *                                  MII read/write functions
- *   09/15/04  Hayato Fujiwara    - Add m32r support.
- *                                - Modify for SMP kernel; Change spin-locked
- *                                  regions.
+ *   22/09/04  Nicolas Pitre      big update (see commit log for details)
  */
 static const char version[] =
-	"smc91x.c: v1.0, mar 07 2003 by Nicolas Pitre <nico@cam.org>\n";
+	"smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org>\n";
 
 /* Debugging level */
 #ifndef SMC_DEBUG
@@ -75,7 +73,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
-#include <linux/timer.h>
+#include <linux/interrupt.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/crc32.h>
@@ -83,6 +81,7 @@
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
+#include <linux/workqueue.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -177,7 +176,8 @@
 	 * packet, I will store the skbuff here, until I get the
 	 * desired memory.  Then, I'll send it out and free it.
 	 */
-	struct sk_buff *saved_skb;
+	struct sk_buff *pending_tx_skb;
+	struct tasklet_struct tx_task;
 
  	/*
 	 * these are things that the kernel wants me to keep, so users
@@ -203,6 +203,11 @@
 	u32	msg_enable;
 	u32	phy_type;
 	struct mii_if_info mii;
+
+	/* work queue */
+	struct work_struct phy_configure;
+	int	work_pending;
+
 	spinlock_t lock;
 
 #ifdef SMC_USE_PXA_DMA
@@ -215,7 +220,7 @@
 #define DBG(n, args...)					\
 	do {						\
 		if (SMC_DEBUG >= (n))			\
-			printk(KERN_DEBUG args);	\
+			printk(args);	\
 	} while (0)
 
 #define PRINTK(args...)   printk(args)
@@ -260,17 +265,21 @@
 /* this enables an interrupt in the interrupt mask register */
 #define SMC_ENABLE_INT(x) do {						\
 	unsigned char mask;						\
+	spin_lock_irq(&lp->lock);					\
 	mask = SMC_GET_INT_MASK();					\
 	mask |= (x);							\
 	SMC_SET_INT_MASK(mask);						\
+	spin_unlock_irq(&lp->lock);					\
 } while (0)
 
 /* this disables an interrupt from the interrupt mask register */
 #define SMC_DISABLE_INT(x) do {						\
 	unsigned char mask;						\
+	spin_lock_irq(&lp->lock);					\
 	mask = SMC_GET_INT_MASK();					\
 	mask &= ~(x);							\
 	SMC_SET_INT_MASK(mask);						\
+	spin_unlock_irq(&lp->lock);					\
 } while (0)
 
 /*
@@ -299,10 +308,17 @@
 static void smc_reset(struct net_device *dev)
 {
 	unsigned long ioaddr = dev->base_addr;
+	struct smc_local *lp = netdev_priv(dev);
 	unsigned int ctl, cfg;
 
 	DBG(2, "%s: %s\n", dev->name, __FUNCTION__);
 
+	/* Disable all interrupts */
+	spin_lock(&lp->lock);
+	SMC_SELECT_BANK(2);
+	SMC_SET_INT_MASK(0);
+	spin_unlock(&lp->lock);
+
 	/*
 	 * This resets the registers mostly to defaults, but doesn't
 	 * affect EEPROM.  That seems unnecessary
@@ -358,20 +374,24 @@
 	 * transmitted packets, to make the best use out of our limited
 	 * memory
 	 */
-#if ! THROTTLE_TX_PKTS
-	ctl |= CTL_AUTO_RELEASE;
-#else
-	ctl &= ~CTL_AUTO_RELEASE;
-#endif
+	if(!THROTTLE_TX_PKTS)
+		ctl |= CTL_AUTO_RELEASE;
+	else
+		ctl &= ~CTL_AUTO_RELEASE;
 	SMC_SET_CTL(ctl);
 
-	/* Disable all interrupts */
-	SMC_SELECT_BANK(2);
-	SMC_SET_INT_MASK(0);
-
 	/* Reset the MMU */
+	SMC_SELECT_BANK(2);
 	SMC_SET_MMU_CMD(MC_RESET);
 	SMC_WAIT_MMU_BUSY();
+
+	/* clear anything saved */
+	if (lp->pending_tx_skb != NULL) {
+		dev_kfree_skb (lp->pending_tx_skb);
+		lp->pending_tx_skb = NULL;
+		lp->stats.tx_errors++;
+		lp->stats.tx_aborted_errors++;
+	}
 }
 
 /*
@@ -390,24 +410,39 @@
 	SMC_SET_TCR(lp->tcr_cur_mode);
 	SMC_SET_RCR(lp->rcr_cur_mode);
 
+	SMC_SELECT_BANK(1);
+	SMC_SET_MAC_ADDR(dev->dev_addr);
+
 	/* now, enable interrupts */
 	mask = IM_EPH_INT|IM_RX_OVRN_INT|IM_RCV_INT;
 	if (lp->version >= (CHIP_91100 << 4))
 		mask |= IM_MDINT;
 	SMC_SELECT_BANK(2);
 	SMC_SET_INT_MASK(mask);
+
+	/*
+	 * From this point the register bank must _NOT_ be switched away
+	 * to something else than bank 2 without proper locking against
+	 * races with any tasklet or interrupt handlers until smc_shutdown()
+	 * or smc_reset() is called.
+	 */
 }
 
 /*
  * this puts the device in an inactive state
  */
-static void smc_shutdown(unsigned long ioaddr)
+static void smc_shutdown(struct net_device *dev)
 {
+	unsigned long ioaddr = dev->base_addr;
+	struct smc_local *lp = netdev_priv(dev);
+
 	DBG(2, "%s: %s\n", CARDNAME, __FUNCTION__);
 
 	/* no more interrupts for me */
+	spin_lock(&lp->lock);
 	SMC_SELECT_BANK(2);
 	SMC_SET_INT_MASK(0);
+	spin_unlock(&lp->lock);
 
 	/* and tell the card to stay away from that nasty outside world */
 	SMC_SELECT_BANK(0);
@@ -449,6 +484,8 @@
 		packet_len, packet_len);
 
 	if (unlikely(status & RS_ERRORS)) {
+		SMC_WAIT_MMU_BUSY();
+		SMC_SET_MMU_CMD(MC_RELEASE);
 		lp->stats.rx_errors++;
 		if (status & RS_ALGNERR)
 			lp->stats.rx_frame_errors++;
@@ -466,17 +503,21 @@
 			lp->stats.multicast++;
 
 		/*
-		 * Actual payload is packet_len - 4 (or 3 if odd byte).
+		 * Actual payload is packet_len - 6 (or 5 if odd byte).
 		 * We want skb_reserve(2) and the final ctrl word
 		 * (2 bytes, possibly containing the payload odd byte).
-		 * Ence packet_len - 4 + 2 + 2.
+		 * Furthermore, we add 2 bytes to allow rounding up to
+		 * multiple of 4 bytes on 32 bit buses.
+		 * Ence packet_len - 6 + 2 + 2 + 2.
 		 */
 		skb = dev_alloc_skb(packet_len);
 		if (unlikely(skb == NULL)) {
 			printk(KERN_NOTICE "%s: Low memory, packet dropped.\n",
 				dev->name);
+			SMC_WAIT_MMU_BUSY();
+			SMC_SET_MMU_CMD(MC_RELEASE);
 			lp->stats.rx_dropped++;
-			goto done;
+			return;
 		}
 
 		/* Align IP header to 32 bits */
@@ -487,14 +528,18 @@
 			status |= RS_ODDFRAME;
 
 		/*
-		 * If odd length: packet_len - 3,
-		 * otherwise packet_len - 4.
+		 * If odd length: packet_len - 5,
+		 * otherwise packet_len - 6.
+		 * With the trailing ctrl byte it's packet_len - 4.
 		 */
-		data_len = packet_len - ((status & RS_ODDFRAME) ? 3 : 4);
+		data_len = packet_len - ((status & RS_ODDFRAME) ? 5 : 6);
 		data = skb_put(skb, data_len);
-		SMC_PULL_DATA(data, packet_len - 2);
+		SMC_PULL_DATA(data, packet_len - 4);
+
+		SMC_WAIT_MMU_BUSY();
+		SMC_SET_MMU_CMD(MC_RELEASE);
 
-		PRINT_PKT(data, packet_len - 2);
+		PRINT_PKT(data, packet_len - 4);
 
 		dev->last_rx = jiffies;
 		skb->dev = dev;
@@ -503,34 +548,76 @@
 		lp->stats.rx_packets++;
 		lp->stats.rx_bytes += data_len;
 	}
-
-done:
-	SMC_WAIT_MMU_BUSY();
-	SMC_SET_MMU_CMD(MC_RELEASE);
 }
 
+#ifdef CONFIG_SMP
+/*
+ * On SMP we have the following problem:
+ *
+ * 	A = smc_hardware_send_pkt()
+ * 	B = smc_hard_start_xmit()
+ * 	C = smc_interrupt()
+ *
+ * A and B can never be executed simultaneously.  However, at least on UP,
+ * it is possible (and even desirable) for C to interrupt execution of
+ * A or B in order to have better RX reliability and avoid overruns.
+ * C, just like A and B, must have exclusive access to the chip and
+ * each of them must lock against any other concurrent access.
+ * Unfortunately this is not possible to have C suspend execution of A or
+ * B taking place on another CPU. On UP this is no an issue since A and B
+ * are run from softirq context and C from hard IRQ context, and there is
+ * no other CPU where concurrent access can happen.
+ * If ever there is a way to force at least B and C to always be executed
+ * on the same CPU then we could use read/write locks to protect against
+ * any other concurrent access and C would always interrupt B. But life
+ * isn't that easy in a SMP world...
+ */
+#define smc_special_trylock(lock)					\
+({									\
+	int __ret;							\
+	local_irq_disable();						\
+	__ret = spin_trylock(lock);					\
+	if (!__ret)							\
+		local_irq_enable();					\
+	__ret;								\
+})
+#define smc_special_lock(lock)		spin_lock_irq(lock)
+#define smc_special_unlock(lock)	spin_unlock_irq(lock)
+#else
+#define smc_special_trylock(lock)	(1)
+#define smc_special_lock(lock)		do { } while (0)
+#define smc_special_unlock(lock)	do { } while (0)
+#endif
+
 /*
  * This is called to actually send a packet to the chip.
- * Returns non-zero when successful.
  */
-static void smc_hardware_send_packet(struct net_device *dev)
+static void smc_hardware_send_pkt(unsigned long data)
 {
+	struct net_device *dev = (struct net_device *)data;
 	struct smc_local *lp = netdev_priv(dev);
 	unsigned long ioaddr = dev->base_addr;
-	struct sk_buff *skb = lp->saved_skb;
+	struct sk_buff *skb;
 	unsigned int packet_no, len;
 	unsigned char *buf;
 
 	DBG(3, "%s: %s\n", dev->name, __FUNCTION__);
 
+	if (!smc_special_trylock(&lp->lock)) {
+		netif_stop_queue(dev);
+		tasklet_schedule(&lp->tx_task);
+		return;
+	}
+
+	skb = lp->pending_tx_skb;
+	lp->pending_tx_skb = NULL;
 	packet_no = SMC_GET_AR();
 	if (unlikely(packet_no & AR_FAILED)) {
 		printk("%s: Memory allocation failed.\n", dev->name);
-		lp->saved_skb = NULL;
 		lp->stats.tx_errors++;
 		lp->stats.tx_fifo_errors++;
-		dev_kfree_skb_any(skb);
-		return;
+		smc_special_unlock(&lp->lock);
+		goto done;
 	}
 
 	/* point to the beginning of the packet */
@@ -555,15 +642,33 @@
 	/* Send final ctl word with the last byte if there is one */
 	SMC_outw(((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr, DATA_REG);
 
-	/* and let the chipset deal with it */
+	/*
+	 * If THROTTLE_TX_PKTS is set, we look at the TX_EMPTY flag
+	 * before queueing this packet for TX, and if it's clear then
+	 * we stop the queue here.  This will have the effect of
+	 * having at most 2 packets queued for TX in the chip's memory
+	 * at all time. If THROTTLE_TX_PKTS is not set then the queue
+	 * is stopped only when memory allocation (MC_ALLOC) does not
+	 * succeed right away.
+	 */
+	if (THROTTLE_TX_PKTS && !(SMC_GET_INT() & IM_TX_EMPTY_INT))
+		netif_stop_queue(dev);
+
+	/* queue the packet for TX */
 	SMC_SET_MMU_CMD(MC_ENQUEUE);
 	SMC_ACK_INT(IM_TX_EMPTY_INT);
+	smc_special_unlock(&lp->lock);
 
 	dev->trans_start = jiffies;
-	dev_kfree_skb_any(skb);
-	lp->saved_skb = NULL;
 	lp->stats.tx_packets++;
 	lp->stats.tx_bytes += len;
+
+	SMC_ENABLE_INT(IM_TX_INT | IM_TX_EMPTY_INT);
+
+done:	if (!THROTTLE_TX_PKTS)
+		netif_wake_queue(dev);
+
+	dev_kfree_skb(skb);
 }
 
 /*
@@ -576,15 +681,12 @@
 {
 	struct smc_local *lp = netdev_priv(dev);
 	unsigned long ioaddr = dev->base_addr;
-	unsigned int numPages, poll_count, status, saved_bank;
-	unsigned long flags;
+	unsigned int numPages, poll_count, status;
 
 	DBG(3, "%s: %s\n", dev->name, __FUNCTION__);
 
-	spin_lock_irqsave(&lp->lock, flags);
-
-	BUG_ON(lp->saved_skb != NULL);
-	lp->saved_skb = skb;
+	BUG_ON(lp->pending_tx_skb != NULL);
+	lp->pending_tx_skb = skb;
 
 	/*
 	 * The MMU wants the number of pages to be the number of 256 bytes
@@ -600,17 +702,16 @@
 	numPages = ((skb->len & ~1) + (6 - 1)) >> 8;
 	if (unlikely(numPages > 7)) {
 		printk("%s: Far too big packet error.\n", dev->name);
-		lp->saved_skb = NULL;
+		lp->pending_tx_skb = NULL;
 		lp->stats.tx_errors++;
 		lp->stats.tx_dropped++;
 		dev_kfree_skb(skb);
-		spin_unlock_irqrestore(&lp->lock, flags);
 		return 0;
 	}
 
+	smc_special_lock(&lp->lock);
+
 	/* now, try to allocate the memory */
-	saved_bank = SMC_CURRENT_BANK();
-	SMC_SELECT_BANK(2);
 	SMC_SET_MMU_CMD(MC_ALLOC | numPages);
 
 	/*
@@ -626,6 +727,8 @@
 		}
    	} while (--poll_count);
 
+	smc_special_unlock(&lp->lock);
+
    	if (!poll_count) {
 		/* oh well, wait until the chip finds memory later */
 		netif_stop_queue(dev);
@@ -635,25 +738,10 @@
 		/*
 		 * Allocation succeeded: push packet to the chip's own memory
 		 * immediately.
-		 *
-		 * If THROTTLE_TX_PKTS is selected that means we don't want
-		 * more than a single TX packet taking up space in the chip's
-		 * internal memory at all time, in which case we stop the
-		 * queue right here until we're notified of TX completion.
-		 *
-		 * Otherwise we're quite happy to feed more TX packets right
-		 * away for better TX throughput, in which case the queue is
-		 * left active.
 		 */  
-#if THROTTLE_TX_PKTS
-		netif_stop_queue(dev);
-#endif
-		smc_hardware_send_packet(dev);
-		SMC_ENABLE_INT(IM_TX_INT | IM_TX_EMPTY_INT);
+		smc_hardware_send_pkt((unsigned long)dev);
 	}
 
-	SMC_SELECT_BANK(saved_bank);
-	spin_unlock_irqrestore(&lp->lock, flags);
 	return 0;
 }
 
@@ -767,10 +855,8 @@
 static int smc_phy_read(struct net_device *dev, int phyaddr, int phyreg)
 {
 	unsigned long ioaddr = dev->base_addr;
-	unsigned int phydata, old_bank;
+	unsigned int phydata;
 
-	/* Save the current bank, and select bank 3 */
-	old_bank = SMC_CURRENT_BANK();
 	SMC_SELECT_BANK(3);
 
 	/* Idle - 32 ones */
@@ -785,12 +871,10 @@
 	/* Return to idle state */
 	SMC_SET_MII(SMC_GET_MII() & ~(MII_MCLK|MII_MDOE|MII_MDO));
 
-	/* And select original bank */
-	SMC_SELECT_BANK(old_bank);
-
 	DBG(3, "%s: phyaddr=0x%x, phyreg=0x%x, phydata=0x%x\n",
 		__FUNCTION__, phyaddr, phyreg, phydata);
 
+	SMC_SELECT_BANK(2);
 	return phydata;
 }
 
@@ -801,10 +885,7 @@
 			  int phydata)
 {
 	unsigned long ioaddr = dev->base_addr;
-	unsigned int old_bank;
 
-	/* Save the current bank, and select bank 3 */
-	old_bank = SMC_CURRENT_BANK();
 	SMC_SELECT_BANK(3);
 
 	/* Idle - 32 ones */
@@ -816,17 +897,16 @@
 	/* Return to idle state */
 	SMC_SET_MII(SMC_GET_MII() & ~(MII_MCLK|MII_MDOE|MII_MDO));
 
-	/* And select original bank */
-	SMC_SELECT_BANK(old_bank);
-
 	DBG(3, "%s: phyaddr=0x%x, phyreg=0x%x, phydata=0x%x\n",
 		__FUNCTION__, phyaddr, phyreg, phydata);
+
+	SMC_SELECT_BANK(2);
 }
 
 /*
  * Finds and reports the PHY address
  */
-static void smc_detect_phy(struct net_device *dev)
+static void smc_phy_detect(struct net_device *dev)
 {
 	struct smc_local *lp = netdev_priv(dev);
 	int phyaddr;
@@ -893,7 +973,9 @@
 	smc_phy_write(dev, phyaddr, MII_BMCR, bmcr);
 
 	/* Re-Configure the Receive/Phy Control register */
+	SMC_SELECT_BANK(0);
 	SMC_SET_RPC(lp->rpc_cur_mode);
+	SMC_SELECT_BANK(2);
 
 	return 1;
 }
@@ -941,13 +1023,10 @@
  */
 static void smc_phy_powerdown(struct net_device *dev, int phy)
 {
-	struct smc_local *lp = netdev_priv(dev);
 	unsigned int bmcr;
 
-	spin_lock_irq(&lp->lock);
 	bmcr = smc_phy_read(dev, phy, MII_BMCR);
 	smc_phy_write(dev, phy, MII_BMCR, bmcr | BMCR_PDOWN);
-	spin_unlock_irq(&lp->lock);
 }
 
 /*
@@ -964,8 +1043,6 @@
 	unsigned long ioaddr = dev->base_addr;
 
 	if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) {
-		unsigned int old_bank;
-
 		/* duplex state has changed */
 		if (lp->mii.full_duplex) {
 			lp->tcr_cur_mode |= TCR_SWFDUP;
@@ -973,10 +1050,8 @@
 			lp->tcr_cur_mode &= ~TCR_SWFDUP;
 		}
 
-		old_bank = SMC_CURRENT_BANK();
 		SMC_SELECT_BANK(0);
 		SMC_SET_TCR(lp->tcr_cur_mode);
-		SMC_SELECT_BANK(old_bank);
 	}
 }
 
@@ -989,8 +1064,9 @@
  * of autonegotiation.)  If the RPC ANEG bit is cleared, the selection
  * is controlled by the RPC SPEED and RPC DPLX bits.
  */
-static void smc_phy_configure(struct net_device *dev)
+static void smc_phy_configure(void *data)
 {
+	struct net_device *dev = data;
 	struct smc_local *lp = netdev_priv(dev);
 	unsigned long ioaddr = dev->base_addr;
 	int phyaddr = lp->mii.phy_id;
@@ -1082,6 +1158,7 @@
 
 smc_phy_configure_exit:
 	spin_unlock_irq(&lp->lock);
+	lp->work_pending = 0;
 }
 
 /*
@@ -1117,12 +1194,13 @@
 {
 	struct smc_local *lp = netdev_priv(dev);
 	unsigned long ioaddr = dev->base_addr;
-	unsigned int old_carrier, new_carrier, old_bank;
+	unsigned int old_carrier, new_carrier;
 
-	old_bank = SMC_CURRENT_BANK();
-	SMC_SELECT_BANK(0);
 	old_carrier = netif_carrier_ok(dev) ? 1 : 0;
+
+	SMC_SELECT_BANK(0);
 	new_carrier = SMC_inw(ioaddr, EPH_STATUS_REG) & ES_LINK_OK ? 1 : 0;
+	SMC_SELECT_BANK(2);
 
 	if (init || (old_carrier != new_carrier)) {
 		if (!new_carrier) {
@@ -1134,24 +1212,20 @@
 			printk(KERN_INFO "%s: link %s\n", dev->name,
 			       new_carrier ? "up" : "down");
 	}
-	SMC_SELECT_BANK(old_bank);
 }
 
 static void smc_eph_interrupt(struct net_device *dev)
 {
 	unsigned long ioaddr = dev->base_addr;
-	unsigned int old_bank, ctl;
+	unsigned int ctl;
 
 	smc_10bt_check_media(dev, 0);
 
-	old_bank = SMC_CURRENT_BANK();
 	SMC_SELECT_BANK(1);
-
 	ctl = SMC_GET_CTL();
 	SMC_SET_CTL(ctl & ~CTL_LE_ENABLE);
 	SMC_SET_CTL(ctl);
-
-	SMC_SELECT_BANK(old_bank);
+	SMC_SELECT_BANK(2);
 }
 
 /*
@@ -1164,14 +1238,17 @@
 	unsigned long ioaddr = dev->base_addr;
 	struct smc_local *lp = netdev_priv(dev);
 	int status, mask, timeout, card_stats;
-	int saved_bank, saved_pointer;
+	int saved_pointer;
 
 	DBG(3, "%s: %s\n", dev->name, __FUNCTION__);
 
 	spin_lock(&lp->lock);
 
-	saved_bank = SMC_CURRENT_BANK();
-	SMC_SELECT_BANK(2);
+	/* A preamble may be used when there is a potential race
+	 * between the interruptible transmit functions and this
+	 * ISR. */
+	SMC_INTERRUPT_PREAMBLE;
+
 	saved_pointer = SMC_GET_PTR();
 	mask = SMC_GET_INT_MASK();
 	SMC_SET_INT_MASK(0);
@@ -1182,7 +1259,7 @@
 	do {
 		status = SMC_GET_INT();
 
-		DBG(2, "%s: IRQ 0x%02x MASK 0x%02x MEM 0x%04x FIFO 0x%04x\n",
+		DBG(2, "%s: INT 0x%02x MASK 0x%02x MEM 0x%04x FIFO 0x%04x\n",
 			dev->name, status, mask,
 			({ int meminfo; SMC_SELECT_BANK(0);
 			   meminfo = SMC_GET_MIR();
@@ -1200,17 +1277,12 @@
 			DBG(3, "%s: TX int\n", dev->name);
 			smc_tx(dev);
 			SMC_ACK_INT(IM_TX_INT);
-#if THROTTLE_TX_PKTS
-			netif_wake_queue(dev);
-#endif
+			if (THROTTLE_TX_PKTS)
+				netif_wake_queue(dev);
 		} else if (status & IM_ALLOC_INT) {
 			DBG(3, "%s: Allocation irq\n", dev->name);
-			smc_hardware_send_packet(dev);
-			mask |= (IM_TX_INT | IM_TX_EMPTY_INT);
+			tasklet_hi_schedule(&lp->tx_task);
 			mask &= ~IM_ALLOC_INT;
-#if ! THROTTLE_TX_PKTS
-			netif_wake_queue(dev);
-#endif
 		} else if (status & IM_TX_EMPTY_INT) {
 			DBG(3, "%s: TX empty\n", dev->name);
 			mask &= ~IM_TX_EMPTY_INT;
@@ -1240,17 +1312,16 @@
 			SMC_ACK_INT(IM_ERCV_INT);
 			PRINTK("%s: UNSUPPORTED: ERCV INTERRUPT \n", dev->name);
 		}
-
 	} while (--timeout);
 
 	/* restore register states */
-	SMC_SET_INT_MASK(mask);
 	SMC_SET_PTR(saved_pointer);
-	SMC_SELECT_BANK(saved_bank);
+	SMC_SET_INT_MASK(mask);
+
+	spin_unlock(&lp->lock);
 
 	DBG(3, "%s: Interrupt done (%d loops)\n", dev->name, 8-timeout);
 
-	spin_unlock(&lp->lock);
 	/*
 	 * We return IRQ_HANDLED unconditionally here even if there was
 	 * nothing to do.  There is a possibility that a packet might
@@ -1266,101 +1337,42 @@
 static void smc_timeout(struct net_device *dev)
 {
 	struct smc_local *lp = netdev_priv(dev);
-	unsigned long flags;
+	unsigned long ioaddr = dev->base_addr;
+	int status, mask, meminfo, fifo;
 
-	spin_lock_irqsave(&lp->lock, flags);
 	DBG(2, "%s: %s\n", dev->name, __FUNCTION__);
 
+	spin_lock_irq(&lp->lock);
+	status = SMC_GET_INT();
+	mask = SMC_GET_INT_MASK();
+	fifo = SMC_GET_FIFO();
+	SMC_SELECT_BANK(0);
+	meminfo = SMC_GET_MIR();
+	SMC_SELECT_BANK(2);
+	spin_unlock_irq(&lp->lock);
+	PRINTK( "%s: INT 0x%02x MASK 0x%02x MEM 0x%04x FIFO 0x%04x\n",
+		dev->name, status, mask, meminfo, fifo );
+
 	smc_reset(dev);
 	smc_enable(dev);
 
-#if 0
 	/*
 	 * Reconfiguring the PHY doesn't seem like a bad idea here, but
-	 * it introduced a problem.  Now that this is a timeout routine,
-	 * we are getting called from within an interrupt context.
-	 * smc_phy_configure() calls msleep() which calls
-	 * schedule_timeout() which calls schedule().  When schedule()
-	 * is called from an interrupt context, it prints out
-	 * "Scheduling in interrupt" and then calls BUG().  This is
-	 * obviously not desirable.  This was worked around by removing
-	 * the call to smc_phy_configure() here because it didn't seem
-	 * absolutely necessary.  Ultimately, if msleep() is
-	 * supposed to be usable from an interrupt context (which it
-	 * looks like it thinks it should handle), it should be fixed.
+	 * smc_phy_configure() calls msleep() which calls schedule_timeout()
+	 * which calls schedule().  Hence we use a work queue.
 	 */
-	if (lp->phy_type != 0)
-		smc_phy_configure(dev);
-#endif
-
-	/* clear anything saved */
-	if (lp->saved_skb != NULL) {
-		dev_kfree_skb (lp->saved_skb);
-		lp->saved_skb = NULL;
-		lp->stats.tx_errors++;
-		lp->stats.tx_aborted_errors++;
+	if (lp->phy_type != 0) {
+		if (schedule_work(&lp->phy_configure)) {
+			lp->work_pending = 1;
+		}
 	}
+
 	/* We can accept TX packets again */
 	dev->trans_start = jiffies;
-
-	spin_unlock_irqrestore(&lp->lock, flags);
-
 	netif_wake_queue(dev);
 }
 
 /*
- *    This sets the internal hardware table to filter out unwanted multicast
- *    packets before they take up memory.
- *
- *    The SMC chip uses a hash table where the high 6 bits of the CRC of
- *    address are the offset into the table.  If that bit is 1, then the
- *    multicast packet is accepted.  Otherwise, it's dropped silently.
- *
- *    To use the 6 bits as an offset into the table, the high 3 bits are the
- *    number of the 8 bit register, while the low 3 bits are the bit within
- *    that register.
- *
- *    This routine is based very heavily on the one provided by Peter Cammaert.
- */
-static void
-smc_setmulticast(unsigned long ioaddr, int count, struct dev_mc_list *addrs)
-{
-	int i;
-	unsigned char multicast_table[8];
-	struct dev_mc_list *cur_addr;
-
-	/* table for flipping the order of 3 bits */
-	static unsigned char invert3[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
-	/* start with a table of all zeros: reject all */
-	memset(multicast_table, 0, sizeof(multicast_table));
-
-	cur_addr = addrs;
-	for (i = 0; i < count; i++, cur_addr = cur_addr->next) {
-		int position;
-
-		/* do we have a pointer here? */
-		if (!cur_addr)
-			break;
-		/* make sure this is a multicast address - shouldn't this
-		   be a given if we have it here ? */
-		if (!(*cur_addr->dmi_addr & 1))
-			continue;
-
-		/* only use the low order bits */
-		position = crc32_le(~0, cur_addr->dmi_addr, 6) & 0x3f;
-
-		/* do some messy swapping to put the bit in the right spot */
-		multicast_table[invert3[position&7]] |=
-					(1<<invert3[(position>>3)&7]);
-
-	}
-	/* now, the table can be loaded into the chipset */
-	SMC_SELECT_BANK(3);
-	SMC_SET_MCAST(multicast_table);
-}
-
-/*
  * This routine will, depending on the values passed to it,
  * either make it accept multicast packets, go into
  * promiscuous mode (for TCPDUMP and cousins) or accept
@@ -1370,14 +1382,14 @@
 {
 	struct smc_local *lp = netdev_priv(dev);
 	unsigned long ioaddr = dev->base_addr;
+	unsigned char multicast_table[8];
+	int update_multicast = 0;
 
 	DBG(2, "%s: %s\n", dev->name, __FUNCTION__);
 
-	SMC_SELECT_BANK(0);
 	if (dev->flags & IFF_PROMISC) {
 		DBG(2, "%s: RCR_PRMS\n", dev->name);
 		lp->rcr_cur_mode |= RCR_PRMS;
-		SMC_SET_RCR(lp->rcr_cur_mode);
 	}
 
 /* BUG?  I never disable promiscuous mode if multicasting was turned on.
@@ -1391,38 +1403,78 @@
 	 * checked before the table is
 	 */
 	else if (dev->flags & IFF_ALLMULTI || dev->mc_count > 16) {
-		lp->rcr_cur_mode |= RCR_ALMUL;
-		SMC_SET_RCR(lp->rcr_cur_mode);
 		DBG(2, "%s: RCR_ALMUL\n", dev->name);
+		lp->rcr_cur_mode |= RCR_ALMUL;
 	}
 
 	/*
-	 * We just get all multicast packets even if we only want them
-	 * from one source.  This will be changed at some future point.
+	 * This sets the internal hardware table to filter out unwanted
+	 * multicast packets before they take up memory.
+	 *
+	 * The SMC chip uses a hash table where the high 6 bits of the CRC of
+	 * address are the offset into the table.  If that bit is 1, then the
+	 * multicast packet is accepted.  Otherwise, it's dropped silently.
+	 *
+	 * To use the 6 bits as an offset into the table, the high 3 bits are
+	 * the number of the 8 bit register, while the low 3 bits are the bit
+	 * within that register.
 	 */
 	else if (dev->mc_count)  {
-		/* support hardware multicasting */
+		int i;
+		struct dev_mc_list *cur_addr;
+
+		/* table for flipping the order of 3 bits */
+		static const unsigned char invert3[] = {0, 4, 2, 6, 1, 5, 3, 7};
+
+		/* start with a table of all zeros: reject all */
+		memset(multicast_table, 0, sizeof(multicast_table));
+
+		cur_addr = dev->mc_list;
+		for (i = 0; i < dev->mc_count; i++, cur_addr = cur_addr->next) {
+			int position;
+
+			/* do we have a pointer here? */
+			if (!cur_addr)
+				break;
+			/* make sure this is a multicast address -
+		   	   shouldn't this be a given if we have it here ? */
+			if (!(*cur_addr->dmi_addr & 1))
+				continue;
+
+			/* only use the low order bits */
+			position = crc32_le(~0, cur_addr->dmi_addr, 6) & 0x3f;
+
+			/* do some messy swapping to put the bit in the right spot */
+			multicast_table[invert3[position&7]] |=
+				(1<<invert3[(position>>3)&7]);
+		}
 
 		/* be sure I get rid of flags I might have set */
 		lp->rcr_cur_mode &= ~(RCR_PRMS | RCR_ALMUL);
-		SMC_SET_RCR(lp->rcr_cur_mode);
-		/*
-		 * NOTE: this has to set the bank, so make sure it is the
-		 * last thing called.  The bank is set to zero at the top
-		 */
-		smc_setmulticast(ioaddr, dev->mc_count, dev->mc_list);
+
+		/* now, the table can be loaded into the chipset */
+		update_multicast = 1;
 	} else  {
 		DBG(2, "%s: ~(RCR_PRMS|RCR_ALMUL)\n", dev->name);
 		lp->rcr_cur_mode &= ~(RCR_PRMS | RCR_ALMUL);
-		SMC_SET_RCR(lp->rcr_cur_mode);
 
 		/*
 		 * since I'm disabling all multicast entirely, I need to
 		 * clear the multicast list
 		 */
+		memset(multicast_table, 0, sizeof(multicast_table));
+		update_multicast = 1;
+	}
+
+	spin_lock_irq(&lp->lock);
+	SMC_SELECT_BANK(0);
+	SMC_SET_RCR(lp->rcr_cur_mode);
+	if (update_multicast) {
 		SMC_SELECT_BANK(3);
-		SMC_CLEAR_MCAST();
+		SMC_SET_MCAST(multicast_table);
 	}
+	SMC_SELECT_BANK(2);
+	spin_unlock_irq(&lp->lock);
 }
 
 
@@ -1435,7 +1487,6 @@
 smc_open(struct net_device *dev)
 {
 	struct smc_local *lp = netdev_priv(dev);
-	unsigned long ioaddr = dev->base_addr;
 
 	DBG(2, "%s: %s\n", dev->name, __FUNCTION__);
 
@@ -1445,13 +1496,10 @@
 	 * address using ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
 	 */
 	if (!is_valid_ether_addr(dev->dev_addr)) {
-		DBG(2, "smc_open: no valid ethernet hw addr\n");
+		PRINTK("%s: no valid ethernet hw addr\n", __FUNCTION__);
 		return -EINVAL;
 	}
 
-	/* clear out all the junk that was put here before... */
-	lp->saved_skb = NULL;
-
 	/* Setup the default Register Modes */
 	lp->tcr_cur_mode = TCR_DEFAULT;
 	lp->rcr_cur_mode = RCR_DEFAULT;
@@ -1468,10 +1516,7 @@
 	smc_reset(dev);
 	smc_enable(dev);
 
-	SMC_SELECT_BANK(1);
-	SMC_SET_MAC_ADDR(dev->dev_addr);
-
-	/* Configure the PHY */
+	/* Configure the PHY, initialize the link state */
 	if (lp->phy_type != 0)
 		smc_phy_configure(dev);
 	else {
@@ -1480,12 +1525,6 @@
 		spin_unlock_irq(&lp->lock);
 	}
 
-	/*
-	 * make sure to initialize the link state with netif_carrier_off()
-	 * somewhere, too --jgarzik
-	 *
-	 * smc_phy_configure() and smc_10bt_check_media() does that. --rmk
-	 */
 	netif_start_queue(dev);
 	return 0;
 }
@@ -1507,10 +1546,28 @@
 	netif_carrier_off(dev);
 
 	/* clear everything */
-	smc_shutdown(dev->base_addr);
+	smc_shutdown(dev);
 
-	if (lp->phy_type != 0)
+	if (lp->phy_type != 0) {
+		/* We need to ensure that no calls to
+		   smc_phy_configure are pending.
+
+		   flush_scheduled_work() cannot be called because we
+		   are running with the netlink semaphore held (from
+		   devinet_ioctl()) and the pending work queue
+		   contains linkwatch_event() (scheduled by
+		   netif_carrier_off() above). linkwatch_event() also
+		   wants the netlink semaphore.
+		*/
+		while(lp->work_pending)
+			schedule();
 		smc_phy_powerdown(dev, lp->mii.phy_id);
+	}
+
+	if (lp->pending_tx_skb) {
+		dev_kfree_skb(lp->pending_tx_skb);
+		lp->pending_tx_skb = NULL;
+	}
 
 	return 0;
 }
@@ -1800,6 +1857,7 @@
 	/* fill in some of the fields */
 	dev->base_addr = ioaddr;
 	lp->version = revision_register & 0xff;
+	spin_lock_init(&lp->lock);
 
 	/* Get the MAC address */
 	SMC_SELECT_BANK(1);
@@ -1855,7 +1913,8 @@
 	dev->set_multicast_list = smc_set_multicast_list;
 	dev->ethtool_ops = &smc_ethtool_ops;
 
-	spin_lock_init(&lp->lock);
+	tasklet_init(&lp->tx_task, smc_hardware_send_pkt, (unsigned long)dev);
+	INIT_WORK(&lp->phy_configure, smc_phy_configure, dev);
 	lp->mii.phy_id_mask = 0x1f;
 	lp->mii.reg_num_mask = 0x1f;
 	lp->mii.force_media = 0;
@@ -1868,7 +1927,7 @@
 	 * Locate the phy, if any.
 	 */
 	if (lp->version >= (CHIP_91100 << 4))
-		smc_detect_phy(dev);
+		smc_phy_detect(dev);
 
 	/* Set default parameters */
 	lp->msg_enable = NETIF_MSG_LINK;
@@ -1885,9 +1944,8 @@
       	if (retval)
       		goto err_out;
 
-#if !defined(__m32r__)
 	set_irq_type(dev->irq, IRQT_RISING);
-#endif
+
 #ifdef SMC_USE_PXA_DMA
 	{
 		int dma = pxa_request_dma(dev->name, DMA_PRIO_LOW,
@@ -2121,7 +2179,7 @@
 	if (ndev && level == SUSPEND_DISABLE) {
 		if (netif_running(ndev)) {
 			netif_device_detach(ndev);
-			smc_shutdown(ndev->base_addr);
+			smc_shutdown(ndev);
 		}
 	}
 	return 0;
@@ -2134,15 +2192,12 @@
 
 	if (ndev && level == RESUME_ENABLE) {
 		struct smc_local *lp = netdev_priv(ndev);
-		unsigned long ioaddr = ndev->base_addr;
 
 		if (pdev->num_resources == 3)
 			smc_enable_device(pdev->resource[2].start);
 		if (netif_running(ndev)) {
 			smc_reset(ndev);
 			smc_enable(ndev);
-			SMC_SELECT_BANK(1);
-			SMC_SET_MAC_ADDR(ndev->dev_addr);
 			if (lp->phy_type != 0)
 				smc_phy_configure(ndev);
 			netif_device_attach(ndev);
diff -Nru a/drivers/net/smc91x.h b/drivers/net/smc91x.h
--- a/drivers/net/smc91x.h	2004-12-24 13:37:04 -08:00
+++ b/drivers/net/smc91x.h	2004-12-24 13:37:04 -08:00
@@ -39,11 +39,7 @@
  * Define your architecture specific bus configuration parameters here.
  */
 
-#if	defined(CONFIG_SA1100_GRAPHICSCLIENT) || \
-	defined(CONFIG_SA1100_PFS168) || \
-	defined(CONFIG_SA1100_FLEXANET) || \
-	defined(CONFIG_SA1100_GRAPHICSMASTER) || \
-	defined(CONFIG_ARCH_LUBBOCK)
+#if	defined(CONFIG_ARCH_LUBBOCK)
 
 /* We can only do 16-bit reads and writes in the static memory space. */
 #define SMC_CAN_USE_8BIT	0
@@ -96,6 +92,25 @@
 	} while (0)
 #define set_irq_type(irq, type)
 
+#elif defined(CONFIG_SA1100_PLEB)
+/* We can only do 16-bit reads and writes in the static memory space. */
+#define SMC_CAN_USE_8BIT	1
+#define SMC_CAN_USE_16BIT	1
+#define SMC_CAN_USE_32BIT	0
+#define SMC_IO_SHIFT		0
+#define SMC_NOWAIT		1
+
+#define SMC_inb(a, r)		inb((a) + (r))
+#define SMC_insb(a, r, p, l)	insb((a) + (r), p, (l))
+#define SMC_inw(a, r)		inw((a) + (r))
+#define SMC_insw(a, r, p, l)	insw((a) + (r), p, l)
+#define SMC_outb(v, a, r)	outb(v, (a) + (r))
+#define SMC_outsb(a, r, p, l)	outsb((a) + (r), p, (l))
+#define SMC_outw(v, a, r)	outw(v, (a) + (r))
+#define SMC_outsw(a, r, p, l)	outsw((a) + (r), p, l)
+
+#define set_irq_type(irq, type) do {} while (0)
+
 #elif defined(CONFIG_SA1100_ASSABET)
 
 #include <asm/arch/neponset.h>
@@ -173,6 +188,58 @@
 #define SMC_insw(a, r, p, l)	insw((a) + (r) - 0xa0000000, p, l)
 #define SMC_outsw(a, r, p, l)	outsw((a) + (r) - 0xa0000000, p, l)
 
+#define set_irq_type(irq, type)	do {} while(0)
+
+#define RPC_LSA_DEFAULT		RPC_LED_TX_RX
+#define RPC_LSB_DEFAULT		RPC_LED_100_10
+
+#elif	defined(CONFIG_MACH_LPD7A400) || defined(CONFIG_MACH_LPD7A404)
+
+/* The LPD7A40X_IOBARRIER is necessary to overcome a mismatch between
+ * the way that the CPU handles chip selects and the way that the SMC
+ * chip expects the chip select to operate.  Refer to
+ * Documentation/arm/Sharp-LH/IOBarrier for details.  The read from
+ * IOBARRIER is a byte as a least-common denominator of possible
+ * regions to use as the barrier.  It would be wasteful to read 32
+ * bits from a byte oriented region.
+ *
+ * There is no explicit protection against interrupts intervening
+ * between the writew and the IOBARRIER.  In SMC ISR there is a
+ * preamble that performs an IOBARRIER in the extremely unlikely event
+ * that the driver interrupts itself between a writew to the chip an
+ * the IOBARRIER that follows *and* the cache is large enough that the
+ * first off-chip access while handing the interrupt is to the SMC
+ * chip.  Other devices in the same address space as the SMC chip must
+ * be aware of the potential for trouble and perform a similar
+ * IOBARRIER on entry to their ISR.
+ */
+
+#include <asm/arch/constants.h>	/* IOBARRIER_VIRT */
+
+#define SMC_CAN_USE_8BIT	0
+#define SMC_CAN_USE_16BIT	1
+#define SMC_CAN_USE_32BIT	0
+#define SMC_NOWAIT		0
+#define LPD7A40X_IOBARRIER	readb (IOBARRIER_VIRT)
+
+#define SMC_inw(a,r)		readw ((void*) ((a) + (r)))
+#define SMC_insw(a,r,p,l)	readsw ((void*) ((a) + (r)), p, l)
+#define SMC_outw(v,a,r)	     ({ writew ((v), (a) + (r)); LPD7A40X_IOBARRIER; })
+
+static inline void SMC_outsw (unsigned long a, int r, unsigned char* p, int l)
+{
+	unsigned short* ps = (unsigned short*) p;
+	while (l-- > 0) {
+		writew (*ps++, a + r);
+		LPD7A40X_IOBARRIER;
+	}
+}
+
+#define SMC_INTERRUPT_PREAMBLE	LPD7A40X_IOBARRIER
+
+#define RPC_LSA_DEFAULT		RPC_LED_TX_RX
+#define RPC_LSB_DEFAULT		RPC_LED_100_10
+
 #else
 
 #define SMC_CAN_USE_8BIT	1
@@ -202,8 +269,9 @@
  * different and probably not worth it for that reason, and not as critical
  * as RX which can overrun memory and lose packets.
  */
-#include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <asm/dma.h>
+#include <asm/arch/pxa-regs.h>
 
 #ifdef SMC_insl
 #undef SMC_insl
@@ -223,21 +291,23 @@
 
 	/* 64 bit alignment is required for memory to memory DMA */
 	if ((long)buf & 4) {
-		*((u32 *)buf)++ = SMC_inl(ioaddr, reg);
+		*((u32 *)buf) = SMC_inl(ioaddr, reg);
+		buf += 4;
 		len--;
 	}
 
 	len *= 4;
-	dmabuf = dma_map_single(NULL, buf, len, PCI_DMA_FROMDEVICE);
+	dmabuf = dma_map_single(NULL, buf, len, DMA_FROM_DEVICE);
 	DCSR(dma) = DCSR_NODESC;
 	DTADR(dma) = dmabuf;
 	DSADR(dma) = physaddr + reg;
 	DCMD(dma) = (DCMD_INCTRGADDR | DCMD_BURST32 |
 		     DCMD_WIDTH4 | (DCMD_LENGTH & len));
 	DCSR(dma) = DCSR_NODESC | DCSR_RUN;
-	while (!(DCSR(dma) & DCSR_STOPSTATE));
+	while (!(DCSR(dma) & DCSR_STOPSTATE))
+		cpu_relax();
 	DCSR(dma) = 0;
-	dma_unmap_single(NULL, dmabuf, len, PCI_DMA_FROMDEVICE);
+	dma_unmap_single(NULL, dmabuf, len, DMA_FROM_DEVICE);
 }
 #endif
 
@@ -259,21 +329,23 @@
 
 	/* 64 bit alignment is required for memory to memory DMA */
 	while ((long)buf & 6) {
-		*((u16 *)buf)++ = SMC_inw(ioaddr, reg);
+		*((u16 *)buf) = SMC_inw(ioaddr, reg);
+		buf += 2;
 		len--;
 	}
 
 	len *= 2;
-	dmabuf = dma_map_single(NULL, buf, len, PCI_DMA_FROMDEVICE);
+	dmabuf = dma_map_single(NULL, buf, len, DMA_FROM_DEVICE);
 	DCSR(dma) = DCSR_NODESC;
 	DTADR(dma) = dmabuf;
 	DSADR(dma) = physaddr + reg;
 	DCMD(dma) = (DCMD_INCTRGADDR | DCMD_BURST32 |
 		     DCMD_WIDTH2 | (DCMD_LENGTH & len));
 	DCSR(dma) = DCSR_NODESC | DCSR_RUN;
-	while (!(DCSR(dma) & DCSR_STOPSTATE));
+	while (!(DCSR(dma) & DCSR_STOPSTATE))
+		cpu_relax();
 	DCSR(dma) = 0;
-	dma_unmap_single(NULL, dmabuf, len, PCI_DMA_FROMDEVICE);
+	dma_unmap_single(NULL, dmabuf, len, DMA_FROM_DEVICE);
 }
 #endif
 
@@ -762,16 +834,9 @@
 		SMC_outw( addr[4]|(addr[5] << 8), ioaddr, ADDR2_REG );	\
 	} while (0)
 
-#define SMC_CLEAR_MCAST()						\
-	do {								\
-		SMC_outw( 0, ioaddr, MCAST_REG1 );			\
-		SMC_outw( 0, ioaddr, MCAST_REG2 );			\
-		SMC_outw( 0, ioaddr, MCAST_REG3 );			\
-		SMC_outw( 0, ioaddr, MCAST_REG4 );			\
-	} while (0)
 #define SMC_SET_MCAST(x)						\
 	do {								\
-		unsigned char *mt = (x);				\
+		const unsigned char *mt = (x);				\
 		SMC_outw( mt[0] | (mt[1] << 8), ioaddr, MCAST_REG1 );	\
 		SMC_outw( mt[2] | (mt[3] << 8), ioaddr, MCAST_REG2 );	\
 		SMC_outw( mt[4] | (mt[5] << 8), ioaddr, MCAST_REG3 );	\
@@ -876,5 +941,8 @@
 	})
 #endif
 
+#if !defined (SMC_INTERRUPT_PREAMBLE)
+# define SMC_INTERRUPT_PREAMBLE
+#endif
 
 #endif  /* _SMC91X_H_ */
diff -Nru a/drivers/net/starfire.c b/drivers/net/starfire.c
--- a/drivers/net/starfire.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/starfire.c	2004-12-24 13:37:43 -08:00
@@ -312,9 +312,6 @@
 
 #include <linux/if_vlan.h>
 
-#define COMPAT_MOD_INC_USE_COUNT
-#define COMPAT_MOD_DEC_USE_COUNT
-
 #define init_tx_timer(dev, func, timeout) \
 	dev->tx_timeout = func; \
 	dev->watchdog_timeo = timeout;
@@ -799,12 +796,13 @@
 static int	netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int	netdev_close(struct net_device *dev);
 static void	netdev_media_change(struct net_device *dev);
+static struct ethtool_ops ethtool_ops;
 
 
 #ifdef VLAN_SUPPORT
 static void netdev_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
 {
-        struct netdev_private *np = dev->priv;
+        struct netdev_private *np = netdev_priv(dev);
 
         spin_lock(&np->lock);
 	if (debug > 2)
@@ -816,7 +814,7 @@
 
 static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	spin_lock(&np->lock);
 	if (debug > 1)
@@ -827,7 +825,7 @@
 
 static void netdev_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	spin_lock(&np->lock);
 	if (debug > 1)
@@ -951,7 +949,7 @@
 	dev->base_addr = ioaddr;
 	dev->irq = irq;
 
-	np = dev->priv;
+	np = netdev_priv(dev);
 	spin_lock_init(&np->lock);
 	pci_set_drvdata(pdev, dev);
 
@@ -1015,6 +1013,7 @@
 	dev->get_stats = &get_stats;
 	dev->set_multicast_list = &set_rx_mode;
 	dev->do_ioctl = &netdev_ioctl;
+	SET_ETHTOOL_OPS(dev, &ethtool_ops);
 
 	if (mtu)
 		dev->mtu = mtu;
@@ -1102,20 +1101,15 @@
 
 static int netdev_open(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int i, retval;
 	size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size;
 
 	/* Do we ever need to reset the chip??? */
-
-	COMPAT_MOD_INC_USE_COUNT;
-
 	retval = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev);
-	if (retval) {
-		COMPAT_MOD_DEC_USE_COUNT;
+	if (retval)
 		return retval;
-	}
 
 	/* Disable the Rx and Tx, and reset the chip. */
 	writel(0, ioaddr + GenCtrl);
@@ -1132,10 +1126,8 @@
 		rx_ring_size = sizeof(struct starfire_rx_desc) * RX_RING_SIZE;
 		np->queue_mem_size = tx_done_q_size + rx_done_q_size + tx_ring_size + rx_ring_size;
 		np->queue_mem = pci_alloc_consistent(np->pci_dev, np->queue_mem_size, &np->queue_mem_dma);
-		if (np->queue_mem == 0) {
-			COMPAT_MOD_DEC_USE_COUNT;
+		if (np->queue_mem == 0)
 			return -ENOMEM;
-		}
 
 		np->tx_done_q     = np->queue_mem;
 		np->tx_done_q_dma = np->queue_mem_dma;
@@ -1267,7 +1259,7 @@
 
 static void check_duplex(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	u16 reg0;
 	int silly_count = 1000;
 
@@ -1302,7 +1294,7 @@
 
 static void tx_timeout(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int old_debug;
 
@@ -1332,7 +1324,7 @@
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
 static void init_ring(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int i;
 
 	np->cur_rx = np->cur_tx = np->reap_tx = 0;
@@ -1378,7 +1370,7 @@
 
 static int start_tx(struct sk_buff *skb, struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	unsigned int entry;
 	u32 status;
 	int i;
@@ -1497,7 +1489,7 @@
 	int handled = 0;
 
 	ioaddr = dev->base_addr;
-	np = dev->priv;
+	np = netdev_priv(dev);
 
 	do {
 		u32 intr_status = readl(ioaddr + IntrClear);
@@ -1597,7 +1589,7 @@
    for clarity, code sharing between NAPI/non-NAPI, and better register allocation. */
 static int __netdev_rx(struct net_device *dev, int *quota)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	u32 desc_status;
 	int retcode = 0;
 
@@ -1752,7 +1744,7 @@
 
 static void refill_rx_ring(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	struct sk_buff *skb;
 	int entry = -1;
 
@@ -1780,7 +1772,7 @@
 
 static void netdev_media_change(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	u16 reg0, reg1, reg4, reg5;
 	u32 new_tx_mode;
@@ -1855,7 +1847,7 @@
 
 static void netdev_error(struct net_device *dev, int intr_status)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	/* Came close to underrunning the Tx FIFO, increase threshold. */
 	if (intr_status & IntrTxDataLow) {
@@ -1883,7 +1875,7 @@
 static struct net_device_stats *get_stats(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	/* This adapter architecture needs no SMP locks. */
 	np->stats.tx_bytes = readl(ioaddr + 0x57010);
@@ -1917,7 +1909,7 @@
 	struct dev_mc_list *mclist;
 	int i;
 #ifdef VLAN_SUPPORT
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	rx_mode |= VlanMode;
 	if (np->vlgrp) {
@@ -1996,106 +1988,89 @@
 	writel(rx_mode, ioaddr + RxFilterMode);
 }
 
+static int check_if_running(struct net_device *dev)
+{
+	if (!netif_running(dev))
+		return -EINVAL;
+	return 0;
+}
 
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	struct ethtool_cmd ecmd;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+	strcpy(info->bus_info, PCI_SLOT_NAME(np->pci_dev));
+}
 
-	if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-		return -EFAULT;
+static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	spin_lock_irq(&np->lock);
+	mii_ethtool_gset(&np->mii_if, ecmd);
+	spin_unlock_irq(&np->lock);
+	return 0;
+}
 
-	switch (ecmd.cmd) {
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info;
-		memset(&info, 0, sizeof(info));
-		info.cmd = ecmd.cmd;
-		strcpy(info.driver, DRV_NAME);
-		strcpy(info.version, DRV_VERSION);
-		*info.fw_version = 0;
-		strcpy(info.bus_info, PCI_SLOT_NAME(np->pci_dev));
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-		       return -EFAULT;
-		return 0;
-	}
+static int set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	int res;
+	spin_lock_irq(&np->lock);
+	res = mii_ethtool_sset(&np->mii_if, ecmd);
+	spin_unlock_irq(&np->lock);
+	check_duplex(dev);
+	return res;
+}
 
-	/* get settings */
-	case ETHTOOL_GSET: {
-		struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-		spin_lock_irq(&np->lock);
-		mii_ethtool_gset(&np->mii_if, &ecmd);
-		spin_unlock_irq(&np->lock);
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set settings */
-	case ETHTOOL_SSET: {
-		int r;
-		struct ethtool_cmd ecmd;
-		if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-			return -EFAULT;
-		spin_lock_irq(&np->lock);
-		r = mii_ethtool_sset(&np->mii_if, &ecmd);
-		spin_unlock_irq(&np->lock);
-		check_duplex(dev);
-		return r;
-	}
-	/* restart autonegotiation */
-	case ETHTOOL_NWAY_RST: {
-		return mii_nway_restart(&np->mii_if);
-	}
-	/* get link status */
-	case ETHTOOL_GLINK: {
-		struct ethtool_value edata = {ETHTOOL_GLINK};
-		edata.data = mii_link_ok(&np->mii_if);
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
+static int nway_reset(struct net_device *dev)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	return mii_nway_restart(&np->mii_if);
+}
 
-	/* get message-level */
-	case ETHTOOL_GMSGLVL: {
-		struct ethtool_value edata = {ETHTOOL_GMSGLVL};
-		edata.data = debug;
-		if (copy_to_user(useraddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-	}
-	/* set message-level */
-	case ETHTOOL_SMSGLVL: {
-		struct ethtool_value edata;
-		if (copy_from_user(&edata, useraddr, sizeof(edata)))
-			return -EFAULT;
-		debug = edata.data;
-		return 0;
-	}
-	default:
-		return -EOPNOTSUPP;
-	}
+static u32 get_link(struct net_device *dev)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	return mii_link_ok(&np->mii_if);
+}
+
+static u32 get_msglevel(struct net_device *dev)
+{
+	return debug;
 }
 
+static void set_msglevel(struct net_device *dev, u32 val)
+{
+	debug = val;
+}
+
+static struct ethtool_ops ethtool_ops = {
+	.begin = check_if_running,
+	.get_drvinfo = get_drvinfo,
+	.get_settings = get_settings,
+	.set_settings = set_settings,
+	.nway_reset = nway_reset,
+	.get_link = get_link,
+	.get_msglevel = get_msglevel,
+	.set_msglevel = set_msglevel,
+};
 
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
+	struct mii_ioctl_data *data = if_mii(rq);
 	int rc;
 
 	if (!netif_running(dev))
 		return -EINVAL;
 
-	if (cmd == SIOCETHTOOL)
-		rc = netdev_ethtool_ioctl(dev, rq->ifr_data);
-
-	else {
-		struct mii_ioctl_data *data = if_mii(rq);
-		spin_lock_irq(&np->lock);
-		rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL);
-		spin_unlock_irq(&np->lock);
+	spin_lock_irq(&np->lock);
+	rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL);
+	spin_unlock_irq(&np->lock);
 
-		if ((cmd == SIOCSMIIREG) && (data->phy_id == np->phys[0]))
-			check_duplex(dev);
-	}
+	if ((cmd == SIOCSMIIREG) && (data->phy_id == np->phys[0]))
+		check_duplex(dev);
 
 	return rc;
 }
@@ -2103,7 +2078,7 @@
 static int netdev_close(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int i;
 
 	netif_stop_queue(dev);
@@ -2165,8 +2140,6 @@
 		np->tx_info[i].skb = NULL;
 	}
 
-	COMPAT_MOD_DEC_USE_COUNT;
-
 	return 0;
 }
 
@@ -2174,16 +2147,16 @@
 static void __devexit starfire_remove_one (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct netdev_private *np;
+	struct netdev_private *np = netdev_priv(dev);
 
 	if (!dev)
 		BUG();
 
-	np = dev->priv;
+	unregister_netdev(dev);
+
 	if (np->queue_mem)
 		pci_free_consistent(pdev, np->queue_mem_size, np->queue_mem, np->queue_mem_dma);
 
-	unregister_netdev(dev);
 
 	/* XXX: add wakeup code -- requires firmware for MagicPacket */
 	pci_set_power_state(pdev, 3);	/* go to sleep in D3 mode */
diff -Nru a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c
--- a/drivers/net/sun3_82586.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/sun3_82586.c	2004-12-24 13:36:55 -08:00
@@ -39,7 +39,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/init.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/idprom.h>
 #include <asm/machines.h>
diff -Nru a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
--- a/drivers/net/sun3lance.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/sun3lance.c	2004-12-24 13:37:18 -08:00
@@ -36,10 +36,10 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
 #include <asm/dvma.h>
diff -Nru a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
--- a/drivers/net/sunbmac.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/sunbmac.c	2004-12-24 13:36:55 -08:00
@@ -22,9 +22,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/auxio.h>
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
 #include <asm/dma.h>
 #include <asm/idprom.h>
diff -Nru a/drivers/net/sundance.c b/drivers/net/sundance.c
--- a/drivers/net/sundance.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/sundance.c	2004-12-24 13:37:00 -08:00
@@ -162,9 +162,9 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/processor.h>		/* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
@@ -511,8 +511,7 @@
 static struct net_device_stats *get_stats(struct net_device *dev);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int  netdev_close(struct net_device *dev);
-
-
+static struct ethtool_ops ethtool_ops;
 
 static int __devinit sundance_probe1 (struct pci_dev *pdev,
 				      const struct pci_device_id *ent)
@@ -567,7 +566,7 @@
 	dev->base_addr = ioaddr;
 	dev->irq = irq;
 
-	np = dev->priv;
+	np = netdev_priv(dev);
 	np->pci_dev = pdev;
 	np->chip_id = chip_idx;
 	np->msg_enable = (1 << debug) - 1;
@@ -600,6 +599,7 @@
 	dev->get_stats = &get_stats;
 	dev->set_multicast_list = &set_rx_mode;
 	dev->do_ioctl = &netdev_ioctl;
+	SET_ETHTOOL_OPS(dev, &ethtool_ops);
 	dev->tx_timeout = &tx_timeout;
 	dev->watchdog_timeo = TX_TIMEOUT;
 	dev->change_mtu = &change_mtu;
@@ -787,7 +787,7 @@
 
 static int mdio_read(struct net_device *dev, int phy_id, int location)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long mdio_addr = dev->base_addr + MIICtrl;
 	int mii_cmd = (0xf6 << 10) | (phy_id << 5) | location;
 	int i, retval = 0;
@@ -817,7 +817,7 @@
 
 static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long mdio_addr = dev->base_addr + MIICtrl;
 	int mii_cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
 	int i;
@@ -846,7 +846,7 @@
 
 static int netdev_open(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int i;
 
@@ -879,7 +879,7 @@
 	if (dev->if_port == 0)
 		dev->if_port = np->default_port;
 
-	np->mcastlock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&np->mcastlock);
 
 	set_rx_mode(dev);
 	writew(0, ioaddr + IntrEnable);
@@ -916,7 +916,7 @@
 
 static void check_duplex(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int mii_lpa = mdio_read(dev, np->phys[0], MII_LPA);
 	int negotiated = mii_lpa & np->mii_if.advertising;
@@ -945,7 +945,7 @@
 static void netdev_timer(unsigned long data)
 {
 	struct net_device *dev = (struct net_device *)data;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int next_tick = 10*HZ;
 
@@ -962,7 +962,7 @@
 
 static void tx_timeout(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	unsigned long flag;
 	
@@ -1015,7 +1015,7 @@
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
 static void init_ring(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int i;
 
 	np->cur_rx = np->cur_tx = 0;
@@ -1058,7 +1058,7 @@
 static void tx_poll (unsigned long data)
 {
 	struct net_device *dev = (struct net_device *)data;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	unsigned head = np->cur_task % TX_RING_SIZE;
 	struct netdev_desc *txdesc = 
 		&np->tx_ring[(np->cur_tx - 1) % TX_RING_SIZE];
@@ -1085,7 +1085,7 @@
 static int
 start_tx (struct sk_buff *skb, struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	struct netdev_desc *txdesc;
 	unsigned entry;
 
@@ -1127,7 +1127,7 @@
 static int
 reset_tx (struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	struct sk_buff *skb;
 	int i;
@@ -1176,7 +1176,7 @@
 	int handled = 0;
 
 	ioaddr = dev->base_addr;
-	np = dev->priv;
+	np = netdev_priv(dev);
 
 	do {
 		int intr_status = readw(ioaddr + IntrStatus);
@@ -1301,7 +1301,7 @@
 static void rx_poll(unsigned long data)
 {
 	struct net_device *dev = (struct net_device *)data;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int entry = np->cur_rx % RX_RING_SIZE;
 	int boguscnt = np->budget;
 	long ioaddr = dev->base_addr;
@@ -1398,7 +1398,7 @@
 
 static void refill_rx (struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int entry;
 	int cnt = 0;
 
@@ -1429,7 +1429,7 @@
 static void netdev_error(struct net_device *dev, int intr_status)
 {
 	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	u16 mii_ctl, mii_advertise, mii_lpa;
 	int speed;
 
@@ -1483,7 +1483,7 @@
 
 static struct net_device_stats *get_stats(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int i;
 
@@ -1512,7 +1512,7 @@
 static void set_rx_mode(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	u16 mc_filter[4];			/* Multicast hash filter */
 	u32 rx_mode;
 	int i;
@@ -1565,91 +1565,79 @@
 	writew(addr16, dev->base_addr + StationAddr+4);
 	return 0;
 }
-	
 
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static int check_if_running(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
-	u32 ethcmd;
+	if (!netif_running(dev))
+		return -EINVAL;
+	return 0;
+}
 
-	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-		return -EFAULT;
+static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+	strcpy(info->bus_info, pci_name(np->pci_dev));
+}
 
-        switch (ethcmd) {
-		/* get constant driver settings/info */
-        	case ETHTOOL_GDRVINFO: {
-			struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-			strcpy(info.driver, DRV_NAME);
-			strcpy(info.version, DRV_VERSION);
-			strcpy(info.bus_info, pci_name(np->pci_dev));
-			memset(&info.fw_version, 0, sizeof(info.fw_version));
-			if (copy_to_user(useraddr, &info, sizeof(info)))
-				return -EFAULT;
-			return 0;
-		}
+static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	spin_lock_irq(&np->lock);
+	mii_ethtool_gset(&np->mii_if, ecmd);
+	spin_unlock_irq(&np->lock);
+	return 0;
+}
 
-		/* get media settings */
-		case ETHTOOL_GSET: {
-			struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-			spin_lock_irq(&np->lock);
-			mii_ethtool_gset(&np->mii_if, &ecmd);
-			spin_unlock_irq(&np->lock);
-			if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-				return -EFAULT;
-			return 0;
-		}
-		/* set media settings */
-		case ETHTOOL_SSET: {
-			int r;
-			struct ethtool_cmd ecmd;
-			if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-				return -EFAULT;
-			spin_lock_irq(&np->lock);
-			r = mii_ethtool_sset(&np->mii_if, &ecmd);
-			spin_unlock_irq(&np->lock);
-			return r;
-		}
-
-		/* restart autonegotiation */
-		case ETHTOOL_NWAY_RST: {
-			return mii_nway_restart(&np->mii_if);
-		}
-
-		/* get link status */
-		case ETHTOOL_GLINK: {
-			struct ethtool_value edata = {ETHTOOL_GLINK};
-			edata.data = mii_link_ok(&np->mii_if);
-			if (copy_to_user(useraddr, &edata, sizeof(edata)))
-				return -EFAULT;
-			return 0;
-		}
+static int set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	int res;
+	spin_lock_irq(&np->lock);
+	res = mii_ethtool_sset(&np->mii_if, ecmd);
+	spin_unlock_irq(&np->lock);
+	return res;
+}
 
-		/* get message-level */
-		case ETHTOOL_GMSGLVL: {
-			struct ethtool_value edata = {ETHTOOL_GMSGLVL};
-			edata.data = np->msg_enable;
-			if (copy_to_user(useraddr, &edata, sizeof(edata)))
-				return -EFAULT;
-			return 0;
-		}
-		/* set message-level */
-		case ETHTOOL_SMSGLVL: {
-			struct ethtool_value edata;
-			if (copy_from_user(&edata, useraddr, sizeof(edata)))
-				return -EFAULT;
-			np->msg_enable = edata.data;
-			return 0;
-		}
+static int nway_reset(struct net_device *dev)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	return mii_nway_restart(&np->mii_if);
+}
+
+static u32 get_link(struct net_device *dev)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	return mii_link_ok(&np->mii_if);
+}
 
-		default:
-		return -EOPNOTSUPP;
+static u32 get_msglevel(struct net_device *dev)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	return np->msg_enable;
+}
 
-        }
+static void set_msglevel(struct net_device *dev, u32 val)
+{
+	struct netdev_private *np = netdev_priv(dev);
+	np->msg_enable = val;
 }
 
+static struct ethtool_ops ethtool_ops = {
+	.begin = check_if_running,
+	.get_drvinfo = get_drvinfo,
+	.get_settings = get_settings,
+	.set_settings = set_settings,
+	.nway_reset = nway_reset,
+	.get_link = get_link,
+	.get_msglevel = get_msglevel,
+	.set_msglevel = set_msglevel,
+};
+
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int rc;
 	int i;
 	long ioaddr = dev->base_addr;
@@ -1657,14 +1645,9 @@
 	if (!netif_running(dev))
 		return -EINVAL;
 
-	if (cmd == SIOCETHTOOL)
-		rc = netdev_ethtool_ioctl(dev, rq->ifr_data);
-
-	else {
-		spin_lock_irq(&np->lock);
-		rc = generic_mii_ioctl(&np->mii_if, if_mii(rq), cmd, NULL);
-		spin_unlock_irq(&np->lock);
-	}
+	spin_lock_irq(&np->lock);
+	rc = generic_mii_ioctl(&np->mii_if, if_mii(rq), cmd, NULL);
+	spin_unlock_irq(&np->lock);
 	switch (cmd) {
 		case SIOCDEVPRIVATE:
 		for (i=0; i<TX_RING_SIZE; i++) {
@@ -1696,7 +1679,7 @@
 static int netdev_close(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	struct sk_buff *skb;
 	int i;
 
@@ -1775,7 +1758,7 @@
 	struct net_device *dev = pci_get_drvdata(pdev);
 
 	if (dev) {
-		struct netdev_private *np = dev->priv;
+		struct netdev_private *np = netdev_priv(dev);
 
 		unregister_netdev(dev);
         	pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring,
diff -Nru a/drivers/net/sungem.c b/drivers/net/sungem.c
--- a/drivers/net/sungem.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/sungem.c	2004-12-24 13:37:29 -08:00
@@ -37,9 +37,9 @@
 #include <linux/random.h>
 #include <linux/workqueue.h>
 #include <linux/if_vlan.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
@@ -2681,14 +2681,14 @@
 	return rc;
 }
 
-#if (!defined(__sparc__) && !defined(CONFIG_PPC))
+#if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC))
 /* Fetch MAC address from vital product data of PCI ROM. */
-static void find_eth_addr_in_vpd(void *rom_base, int len, unsigned char *dev_addr)
+static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr)
 {
 	int this_offset;
 
 	for (this_offset = 0x20; this_offset < len; this_offset++) {
-		void *p = rom_base + this_offset;
+		void __iomem *p = rom_base + this_offset;
 		int i;
 
 		if (readb(p + 0) != 0x90 ||
diff -Nru a/drivers/net/sunhme.c b/drivers/net/sunhme.c
--- a/drivers/net/sunhme.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/sunhme.c	2004-12-24 13:36:47 -08:00
@@ -36,9 +36,9 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/byteorder.h>
@@ -2948,12 +2948,12 @@
 }
 
 /* Fetch MAC address from vital product data of PCI ROM. */
-static void find_eth_addr_in_vpd(void *rom_base, int len, int index, unsigned char *dev_addr)
+static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr)
 {
 	int this_offset;
 
 	for (this_offset = 0x20; this_offset < len; this_offset++) {
-		void *p = rom_base + this_offset;
+		void __iomem *p = rom_base + this_offset;
 
 		if (readb(p + 0) != 0x90 ||
 		    readb(p + 1) != 0x00 ||
@@ -2980,7 +2980,7 @@
 static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr)
 {
 	u32 rom_reg_orig;
-	void *p;
+	void __iomem *p;
 	int index;
 
 	index = 0;
@@ -3257,7 +3257,7 @@
 	return 0;
 
 err_out_iounmap:
-	iounmap((void *)hp->gregs);
+	iounmap(hp->gregs);
 
 err_out_free_res:
 	pci_release_regions(pdev);
@@ -3390,7 +3390,7 @@
 					    PAGE_SIZE,
 					    hp->happy_block,
 					    hp->hblock_dvma);
-			iounmap((void *)hp->gregs);
+			iounmap(hp->gregs);
 			pci_release_regions(hp->happy_dev);
 		}
 #endif
diff -Nru a/drivers/net/sunlance.c b/drivers/net/sunlance.c
--- a/drivers/net/sunlance.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/net/sunlance.c	2004-12-24 13:36:32 -08:00
@@ -94,9 +94,9 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/pgtable.h>
diff -Nru a/drivers/net/sunqe.c b/drivers/net/sunqe.c
--- a/drivers/net/sunqe.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/sunqe.c	2004-12-24 13:36:47 -08:00
@@ -27,9 +27,9 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/byteorder.h>
diff -Nru a/drivers/net/tc35815.c b/drivers/net/tc35815.c
--- a/drivers/net/tc35815.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/tc35815.c	2004-12-24 13:36:16 -08:00
@@ -49,9 +49,9 @@
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/byteorder.h>
diff -Nru a/drivers/net/tg3.c b/drivers/net/tg3.c
--- a/drivers/net/tg3.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/net/tg3.c	2004-12-24 13:36:56 -08:00
@@ -12,7 +12,7 @@
 #include <linux/config.h>
 
 #include <linux/module.h>
-
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/compiler.h>
@@ -60,8 +60,8 @@
 
 #define DRV_MODULE_NAME		"tg3"
 #define PFX DRV_MODULE_NAME	": "
-#define DRV_MODULE_VERSION	"3.10"
-#define DRV_MODULE_RELDATE	"September 14, 2004"
+#define DRV_MODULE_VERSION	"3.14"
+#define DRV_MODULE_RELDATE	"November 15, 2004"
 
 #define TG3_DEF_MAC_MODE	0
 #define TG3_DEF_RX_MODE		0
@@ -141,10 +141,11 @@
 MODULE_AUTHOR("David S. Miller (davem@redhat.com) and Jeff Garzik (jgarzik@pobox.com)");
 MODULE_DESCRIPTION("Broadcom Tigon3 ethernet driver");
 MODULE_LICENSE("GPL");
-MODULE_PARM(tg3_debug, "i");
-MODULE_PARM_DESC(tg3_debug, "Tigon3 bitmapped debugging message enable value");
+MODULE_VERSION(DRV_MODULE_VERSION);
 
 static int tg3_debug = -1;	/* -1 == use TG3_DEF_MSG_ENABLE as value */
+module_param(tg3_debug, int, 0);
+MODULE_PARM_DESC(tg3_debug, "Tigon3 bitmapped debugging message enable value");
 
 static struct pci_device_id tg3_pci_tbl[] = {
 	{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5700,
@@ -205,6 +206,14 @@
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
 	{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5751F,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753F,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+	{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5781,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
 	{ PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
 	{ PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9MXX,
@@ -224,8 +233,8 @@
 
 MODULE_DEVICE_TABLE(pci, tg3_pci_tbl);
 
-struct {
-	char string[ETH_GSTRING_LEN];
+static struct {
+	const char string[ETH_GSTRING_LEN];
 } ethtool_stats_keys[TG3_NUM_STATS] = {
 	{ "rx_octets" },
 	{ "rx_fragments" },
@@ -417,6 +426,20 @@
 	tg3_cond_int(tp);
 }
 
+/* tg3_restart_ints
+ *  similar to tg3_enable_ints, but it can return without flushing the
+ *  PIO write which reenables interrupts
+ */
+static void tg3_restart_ints(struct tg3 *tp)
+{
+	tw32(TG3PCI_MISC_HOST_CTRL,
+		(tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT));
+	tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000);
+	mmiowb();
+
+	tg3_cond_int(tp);
+}
+
 static inline void tg3_netif_stop(struct tg3 *tp)
 {
 	netif_poll_disable(tp->dev);
@@ -866,34 +889,54 @@
 			      GRC_LCLCTRL_GPIO_OUTPUT1));
 			udelay(100);
 		} else {
+			int no_gpio2;
+			u32 grc_local_ctrl;
+
 			if (tp_peer != tp &&
 			    (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
 				return;
 
+			/* On 5753 and variants, GPIO2 cannot be used. */
+			no_gpio2 = (tp->nic_sram_data_cfg &
+				    NIC_SRAM_DATA_CFG_NO_GPIO2) != 0;
+
+			grc_local_ctrl = GRC_LCLCTRL_GPIO_OE0 |
+					 GRC_LCLCTRL_GPIO_OE1 |
+					 GRC_LCLCTRL_GPIO_OE2 |
+					 GRC_LCLCTRL_GPIO_OUTPUT1 |
+					 GRC_LCLCTRL_GPIO_OUTPUT2;
+			if (no_gpio2) {
+				grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 |
+						    GRC_LCLCTRL_GPIO_OUTPUT2);
+			}
 			tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
-			     (GRC_LCLCTRL_GPIO_OE0 |
-			      GRC_LCLCTRL_GPIO_OE1 |
-			      GRC_LCLCTRL_GPIO_OE2 |
-			      GRC_LCLCTRL_GPIO_OUTPUT1 |
-			      GRC_LCLCTRL_GPIO_OUTPUT2));
+			       grc_local_ctrl);
 			udelay(100);
 
+			grc_local_ctrl = GRC_LCLCTRL_GPIO_OE0 |
+					 GRC_LCLCTRL_GPIO_OE1 |
+					 GRC_LCLCTRL_GPIO_OE2 |
+					 GRC_LCLCTRL_GPIO_OUTPUT0 |
+					 GRC_LCLCTRL_GPIO_OUTPUT1 |
+					 GRC_LCLCTRL_GPIO_OUTPUT2;
+			if (no_gpio2) {
+				grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 |
+						    GRC_LCLCTRL_GPIO_OUTPUT2);
+			}
 			tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
-			     (GRC_LCLCTRL_GPIO_OE0 |
-			      GRC_LCLCTRL_GPIO_OE1 |
-			      GRC_LCLCTRL_GPIO_OE2 |
-			      GRC_LCLCTRL_GPIO_OUTPUT0 |
-			      GRC_LCLCTRL_GPIO_OUTPUT1 |
-			      GRC_LCLCTRL_GPIO_OUTPUT2));
+			       grc_local_ctrl);
 			udelay(100);
 
-			tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
-			     (GRC_LCLCTRL_GPIO_OE0 |
-			      GRC_LCLCTRL_GPIO_OE1 |
-			      GRC_LCLCTRL_GPIO_OE2 |
-			      GRC_LCLCTRL_GPIO_OUTPUT0 |
-			      GRC_LCLCTRL_GPIO_OUTPUT1));
-			udelay(100);
+			grc_local_ctrl = GRC_LCLCTRL_GPIO_OE0 |
+					 GRC_LCLCTRL_GPIO_OE1 |
+					 GRC_LCLCTRL_GPIO_OE2 |
+					 GRC_LCLCTRL_GPIO_OUTPUT0 |
+					 GRC_LCLCTRL_GPIO_OUTPUT1;
+			if (!no_gpio2) {
+				tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
+				       grc_local_ctrl);
+				udelay(100);
+			}
 		}
 	} else {
 		if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
@@ -2144,7 +2187,16 @@
 		tp->tg3_flags2 |= TG3_FLG2_PHY_JUST_INITTED;
 	} else if (mac_status & (MAC_STATUS_PCS_SYNCED |
 				 MAC_STATUS_SIGNAL_DET)) {
-		sg_dig_status = tr32(SG_DIG_STATUS);
+		int i;
+
+		/* Giver time to negotiate (~200ms) */
+		for (i = 0; i < 40000; i++) {
+			sg_dig_status = tr32(SG_DIG_STATUS);
+			if (sg_dig_status & (0x3))
+				break;
+			udelay(5);
+		}
+		mac_status = tr32(MAC_STATUS);
 
 		if ((sg_dig_status & (1 << 1)) &&
 		    (mac_status & MAC_STATUS_PCS_SYNCED)) {
@@ -2729,6 +2781,7 @@
 		tw32_rx_mbox(MAILBOX_RCV_JUMBO_PROD_IDX + TG3_64BIT_REG_LOW,
 			     sw_idx);
 	}
+	mmiowb();
 
 	return received;
 }
@@ -2787,7 +2840,7 @@
 	if (done) {
 		spin_lock_irqsave(&tp->lock, flags);
 		__netif_rx_complete(netdev);
-		tg3_enable_ints(tp);
+		tg3_restart_ints(tp);
 		spin_unlock_irqrestore(&tp->lock, flags);
 	}
 
@@ -3176,6 +3229,7 @@
 		netif_stop_queue(dev);
 
 out_unlock:
+    	mmiowb();
 	spin_unlock_irqrestore(&tp->tx_lock, flags);
 
 	dev->trans_start = jiffies;
@@ -3788,7 +3842,7 @@
 		val |= PCISTATE_RETRY_SAME_DMA;
 	pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, val);
 
-	pci_restore_state(tp->pdev, tp->pci_cfg_state);
+	pci_restore_state(tp->pdev);
 
 	/* Make sure PCI-X relaxed ordering bit is clear. */
 	pci_read_config_dword(tp->pdev, TG3PCI_X_CAPS, &val);
@@ -4504,7 +4558,7 @@
 	0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c, 0x00000000, 0x00000000,
 };
 
-u32 tg3TsoFwRodata[] = {
+static u32 tg3TsoFwRodata[] = {
 	0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
 	0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x496e0000, 0x73746b6f,
 	0x66662a2a, 0x00000000, 0x53774576, 0x656e7430, 0x00000000, 0x00000000,
@@ -4512,7 +4566,7 @@
 	0x00000000,
 };
 
-u32 tg3TsoFwData[] = {
+static u32 tg3TsoFwData[] = {
 	0x00000000, 0x73746b6f, 0x66666c64, 0x5f76312e, 0x362e3000, 0x00000000,
 	0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
 	0x00000000,
@@ -4693,14 +4747,14 @@
 	0x00000000, 0x00000000, 0x00000000,
 };
 
-u32 tg3Tso5FwRodata[(TG3_TSO5_FW_RODATA_LEN / 4) + 1] = {
+static u32 tg3Tso5FwRodata[(TG3_TSO5_FW_RODATA_LEN / 4) + 1] = {
 	0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
 	0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x00000000, 0x00000000,
 	0x73746b6f, 0x66666c64, 0x00000000, 0x00000000, 0x66617461, 0x6c457272,
 	0x00000000, 0x00000000, 0x00000000,
 };
 
-u32 tg3Tso5FwData[(TG3_TSO5_FW_DATA_LEN / 4) + 1] = {
+static u32 tg3Tso5FwData[(TG3_TSO5_FW_DATA_LEN / 4) + 1] = {
 	0x00000000, 0x73746b6f, 0x66666c64, 0x5f76312e, 0x322e3000, 0x00000000,
 	0x00000000, 0x00000000, 0x00000000,
 };
@@ -6319,11 +6373,11 @@
 	return EEPROM_CHIP_SIZE;
 }
 
-static int __devinit tg3_nvram_read_using_eeprom(struct tg3 *tp,
-						 u32 offset, u32 *val);
+static int tg3_nvram_read_using_eeprom(struct tg3 *tp,
+					u32 offset, u32 *val);
 static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data)
 {
-	struct tg3 *tp = dev->priv;
+	struct tg3 *tp = netdev_priv(dev);
 	int ret;
 	u8  *pd;
 	u32 i, offset, len, val, b_offset, b_count;
@@ -6685,7 +6739,7 @@
 static void tg3_get_ethtool_stats (struct net_device *dev,
 				   struct ethtool_stats *estats, u64 *tmp_stats)
 {
-	struct tg3 *tp = dev->priv;
+	struct tg3 *tp = netdev_priv(dev);
 	memcpy(tmp_stats, tg3_get_estats(tp), sizeof(tp->estats));
 }
 
@@ -6851,8 +6905,8 @@
 	}
 }
 
-static int __devinit tg3_nvram_read_using_eeprom(struct tg3 *tp,
-						 u32 offset, u32 *val)
+static int tg3_nvram_read_using_eeprom(struct tg3 *tp,
+					u32 offset, u32 *val)
 {
 	u32 tmp;
 	int i;
@@ -7593,7 +7647,8 @@
 	      tp->pdev->device == PCI_DEVICE_ID_TIGON3_5901_2 ||
 	      tp->pdev->device == PCI_DEVICE_ID_TIGON3_5705F)) ||
 	    (tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM &&
-	     tp->pdev->device == PCI_DEVICE_ID_TIGON3_5751F))
+	     (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5751F ||
+	      tp->pdev->device == PCI_DEVICE_ID_TIGON3_5753F)))
 		tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
 
 	err = tg3_phy_probe(tp);
@@ -7900,7 +7955,8 @@
 #endif
 
 	if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
-		tp->dma_rwctrl |= 0x001f0000;
+		/* DMA read watermark not used on PCIE */
+		tp->dma_rwctrl |= 0x00180000;
 	} else if (!(tp->tg3_flags & TG3_FLAG_PCIX_MODE)) {
 		if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
 		    GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
@@ -8223,7 +8279,7 @@
 	spin_lock_init(&tp->indirect_lock);
 	INIT_WORK(&tp->reset_task, tg3_reset_task, tp);
 
-	tp->regs = ioremap(tg3reg_base, tg3reg_len);
+	tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len);
 	if (tp->regs == 0UL) {
 		printk(KERN_ERR PFX "Cannot map device registers, "
 		       "aborting.\n");
@@ -8316,7 +8372,7 @@
 	 */
 	if ((tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE) ||
 	    (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
-		pci_save_state(tp->pdev, tp->pci_cfg_state);
+		pci_save_state(tp->pdev);
 		tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
 		tg3_halt(tp);
 	}
@@ -8355,7 +8411,7 @@
 	 * of the PCI config space.  We need to restore this after
 	 * GRC_MISC_CFG core clock resets and some resume events.
 	 */
-	pci_save_state(tp->pdev, tp->pci_cfg_state);
+	pci_save_state(tp->pdev);
 
 	printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (PCI%s:%s:%s) %sBaseT Ethernet ",
 	       dev->name,
@@ -8474,7 +8530,7 @@
 	if (!netif_running(dev))
 		return 0;
 
-	pci_restore_state(tp->pdev, tp->pci_cfg_state);
+	pci_restore_state(tp->pdev);
 
 	err = tg3_set_power_state(tp, 0);
 	if (err)
diff -Nru a/drivers/net/tg3.h b/drivers/net/tg3.h
--- a/drivers/net/tg3.h	2004-12-24 13:36:19 -08:00
+++ b/drivers/net/tg3.h	2004-12-24 13:36:19 -08:00
@@ -1436,6 +1436,7 @@
 #define  NIC_SRAM_DATA_CFG_EEPROM_WP		 0x00000100
 #define  NIC_SRAM_DATA_CFG_MINI_PCI		 0x00001000
 #define  NIC_SRAM_DATA_CFG_FIBER_WOL		 0x00004000
+#define  NIC_SRAM_DATA_CFG_NO_GPIO2		 0x00100000
 
 #define NIC_SRAM_DATA_PHY_ID		0x00000b74
 #define  NIC_SRAM_DATA_PHY_ID1_MASK	 0xffff0000
@@ -2120,7 +2121,6 @@
 	u8				pci_lat_timer;
 	u8				pci_hdr_type;
 	u8				pci_bist;
-	u32				pci_cfg_state[64 / sizeof(u32)];
 
 	int				pm_cap;
 
diff -Nru a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
--- a/drivers/net/tokenring/3c359.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/net/tokenring/3c359.c	2004-12-24 13:37:30 -08:00
@@ -61,12 +61,12 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 
 #include <net/checksum.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 #include "3c359.h"
 
diff -Nru a/drivers/net/tokenring/abyss.c b/drivers/net/tokenring/abyss.c
--- a/drivers/net/tokenring/abyss.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/tokenring/abyss.c	2004-12-24 13:36:31 -08:00
@@ -457,14 +457,7 @@
 
 static int __init abyss_init (void)
 {
-	int rc = pci_register_driver (&abyss_driver);
-	if (rc < 0)
-		return rc;
-	if (rc == 0) {
-		pci_unregister_driver (&abyss_driver);
-		return -ENODEV;
-	}
-	return 0;
+	return pci_register_driver(&abyss_driver);
 }
 
 static void __exit abyss_rmmod (void)
diff -Nru a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
--- a/drivers/net/tokenring/ibmtr.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/tokenring/ibmtr.c	2004-12-24 13:37:00 -08:00
@@ -895,7 +895,7 @@
 
 	ti->sram_virt &= ~1; /* to reverse what we do in tok_close */
 	/* init the spinlock */
-	ti->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&ti->lock);
 	init_timer(&ti->tr_timer);
 	
 	i = tok_init_card(dev);
diff -Nru a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
--- a/drivers/net/tokenring/lanstreamer.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/tokenring/lanstreamer.c	2004-12-24 13:37:29 -08:00
@@ -120,12 +120,12 @@
 #include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <linux/version.h>
+#include <linux/bitops.h>
 
 #include <net/checksum.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 #include "lanstreamer.h"
 
@@ -1606,7 +1606,7 @@
 				i += 2;
 			}
 
-			memcpy_fromio(skb_put(mac_frame, buffer_len),
+			memcpy(skb_put(mac_frame, buffer_len),
 				      frame_data, buffer_len);
 		} while (next_ptr && (buff_off = next_ptr));
 
diff -Nru a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
--- a/drivers/net/tokenring/olympic.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/tokenring/olympic.c	2004-12-24 13:37:18 -08:00
@@ -99,12 +99,12 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
+#include <linux/bitops.h>
 
 #include <net/checksum.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 #include "olympic.h"
 
@@ -1401,7 +1401,6 @@
 	u16 lan_status = 0, lan_status_diff  ; /* Initialize to stop compiler warning */
 	u8 fdx_prot_error ; 
 	u16 next_ptr;
-	int i ; 
 
 	arb_block = (olympic_priv->olympic_lap + olympic_priv->arb) ; 
 	asb_block = (olympic_priv->olympic_lap + olympic_priv->asb) ; 
diff -Nru a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
--- a/drivers/net/tokenring/smctr.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/tokenring/smctr.c	2004-12-24 13:36:49 -08:00
@@ -49,9 +49,9 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/trdevice.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
diff -Nru a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
--- a/drivers/net/tokenring/tms380tr.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/net/tokenring/tms380tr.c	2004-12-24 13:36:59 -08:00
@@ -96,9 +96,9 @@
 #include <linux/skbuff.h>
 #include <linux/trdevice.h>
 #include <linux/firmware.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
diff -Nru a/drivers/net/tokenring/tmspci.c b/drivers/net/tokenring/tmspci.c
--- a/drivers/net/tokenring/tmspci.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/tokenring/tmspci.c	2004-12-24 13:37:19 -08:00
@@ -243,14 +243,7 @@
 
 static int __init tms_pci_init (void)
 {
-	int rc = pci_register_driver (&tms_pci_driver);
-	if (rc < 0)
-		return rc;
-	if (rc == 0) {
-		pci_unregister_driver (&tms_pci_driver);
-		return -ENODEV;
-	}
-	return 0;
+	return pci_register_driver(&tms_pci_driver);
 }
 
 static void __exit tms_pci_rmmod (void)
diff -Nru a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
--- a/drivers/net/tulip/21142.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/tulip/21142.c	2004-12-24 13:36:31 -08:00
@@ -14,9 +14,9 @@
 
 */
 
-#include "tulip.h"
 #include <linux/pci.h>
 #include <linux/delay.h>
+#include "tulip.h"
 
 
 static u16 t21142_csr13[] = { 0x0001, 0x0009, 0x0009, 0x0000, 0x0001, };
@@ -30,8 +30,8 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
-	int csr12 = inl(ioaddr + CSR12);
+	void __iomem *ioaddr = tp->base_addr;
+	int csr12 = ioread32(ioaddr + CSR12);
 	int next_tick = 60*HZ;
 	int new_csr6 = 0;
 
@@ -69,18 +69,18 @@
 		if (!(csr12 & 4)) {		/* 10mbps link beat good. */
 			new_csr6 = 0x82420000;
 			dev->if_port = 0;
-			outl(0, ioaddr + CSR13);
-			outl(0x0003FFFF, ioaddr + CSR14);
-			outw(t21142_csr15[dev->if_port], ioaddr + CSR15);
-			outl(t21142_csr13[dev->if_port], ioaddr + CSR13);
+			iowrite32(0, ioaddr + CSR13);
+			iowrite32(0x0003FFFF, ioaddr + CSR14);
+			iowrite16(t21142_csr15[dev->if_port], ioaddr + CSR15);
+			iowrite32(t21142_csr13[dev->if_port], ioaddr + CSR13);
 		} else {
 			/* Select 100mbps port to check for link beat. */
 			new_csr6 = 0x83860000;
 			dev->if_port = 3;
-			outl(0, ioaddr + CSR13);
-			outl(0x0003FF7F, ioaddr + CSR14);
-			outw(8, ioaddr + CSR15);
-			outl(1, ioaddr + CSR13);
+			iowrite32(0, ioaddr + CSR13);
+			iowrite32(0x0003FF7F, ioaddr + CSR14);
+			iowrite16(8, ioaddr + CSR15);
+			iowrite32(1, ioaddr + CSR13);
 		}
 		if (tulip_debug > 1)
 			printk(KERN_INFO"%s: Testing new 21143 media %s.\n",
@@ -88,7 +88,7 @@
 		if (new_csr6 != (tp->csr6 & ~0x00D5)) {
 			tp->csr6 &= 0x00D5;
 			tp->csr6 |= new_csr6;
-			outl(0x0301, ioaddr + CSR12);
+			iowrite32(0x0301, ioaddr + CSR12);
 			tulip_restart_rxtx(tp);
 		}
 		next_tick = 3*HZ;
@@ -104,7 +104,7 @@
 void t21142_start_nway(struct net_device *dev)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	int csr14 = ((tp->sym_advertise & 0x0780) << 9)  |
 		((tp->sym_advertise & 0x0020) << 1) | 0xffbf;
 
@@ -114,17 +114,17 @@
 	if (tulip_debug > 1)
 		printk(KERN_DEBUG "%s: Restarting 21143 autonegotiation, csr14=%8.8x.\n",
 			   dev->name, csr14);
-	outl(0x0001, ioaddr + CSR13);
+	iowrite32(0x0001, ioaddr + CSR13);
 	udelay(100);
-	outl(csr14, ioaddr + CSR14);
+	iowrite32(csr14, ioaddr + CSR14);
 	tp->csr6 = 0x82420000 | (tp->sym_advertise & 0x0040 ? FullDuplex : 0);
-	outl(tp->csr6, ioaddr + CSR6);
+	iowrite32(tp->csr6, ioaddr + CSR6);
 	if (tp->mtable  &&  tp->mtable->csr15dir) {
-		outl(tp->mtable->csr15dir, ioaddr + CSR15);
-		outl(tp->mtable->csr15val, ioaddr + CSR15);
+		iowrite32(tp->mtable->csr15dir, ioaddr + CSR15);
+		iowrite32(tp->mtable->csr15val, ioaddr + CSR15);
 	} else
-		outw(0x0008, ioaddr + CSR15);
-	outl(0x1301, ioaddr + CSR12); 		/* Trigger NWAY. */
+		iowrite16(0x0008, ioaddr + CSR15);
+	iowrite32(0x1301, ioaddr + CSR12); 		/* Trigger NWAY. */
 }
 
 
@@ -132,12 +132,12 @@
 void t21142_lnk_change(struct net_device *dev, int csr5)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
-	int csr12 = inl(ioaddr + CSR12);
+	void __iomem *ioaddr = tp->base_addr;
+	int csr12 = ioread32(ioaddr + CSR12);
 
 	if (tulip_debug > 1)
 		printk(KERN_INFO"%s: 21143 link status interrupt %8.8x, CSR5 %x, "
-			   "%8.8x.\n", dev->name, csr12, csr5, inl(ioaddr + CSR14));
+			   "%8.8x.\n", dev->name, csr12, csr5, ioread32(ioaddr + CSR14));
 
 	/* If NWay finished and we have a negotiated partner capability. */
 	if (tp->nway  &&  !tp->nwayset  &&  (csr12 & 0x7000) == 0x5000) {
@@ -183,19 +183,19 @@
 			tp->csr6 = (dev->if_port & 1 ? 0x838E0000 : 0x82420000) | (tp->csr6 & 0x20ff);
 			if (tp->full_duplex)
 				tp->csr6 |= 0x0200;
-			outl(1, ioaddr + CSR13);
+			iowrite32(1, ioaddr + CSR13);
 		}
 #if 0							/* Restart shouldn't be needed. */
-		outl(tp->csr6 | RxOn, ioaddr + CSR6);
+		iowrite32(tp->csr6 | RxOn, ioaddr + CSR6);
 		if (tulip_debug > 2)
 			printk(KERN_DEBUG "%s:  Restarting Tx and Rx, CSR5 is %8.8x.\n",
-				   dev->name, inl(ioaddr + CSR5));
+				   dev->name, ioread32(ioaddr + CSR5));
 #endif
 		tulip_start_rxtx(tp);
 		if (tulip_debug > 2)
 			printk(KERN_DEBUG "%s:  Setting CSR6 %8.8x/%x CSR12 %8.8x.\n",
-				   dev->name, tp->csr6, inl(ioaddr + CSR6),
-				   inl(ioaddr + CSR12));
+				   dev->name, tp->csr6, ioread32(ioaddr + CSR6),
+				   ioread32(ioaddr + CSR12));
 	} else if ((tp->nwayset  &&  (csr5 & 0x08000000)
 				&& (dev->if_port == 3  ||  dev->if_port == 5)
 				&& (csr12 & 2) == 2) ||
@@ -216,7 +216,7 @@
 			tp->timer.expires = RUN_AT(3*HZ);
 			add_timer(&tp->timer);
 		} else if (dev->if_port == 5)
-			outl(inl(ioaddr + CSR14) & ~0x080, ioaddr + CSR14);
+			iowrite32(ioread32(ioaddr + CSR14) & ~0x080, ioaddr + CSR14);
 	} else if (dev->if_port == 0  ||  dev->if_port == 4) {
 		if ((csr12 & 4) == 0)
 			printk(KERN_INFO"%s: 21143 10baseT link beat good.\n",
@@ -236,8 +236,8 @@
 				   dev->name);
 		dev->if_port = 3;
 		tp->csr6 = 0x838E0000 | (tp->csr6 & 0x20ff);
-		outl(0x0003FF7F, ioaddr + CSR14);
-		outl(0x0301, ioaddr + CSR12);
+		iowrite32(0x0003FF7F, ioaddr + CSR14);
+		iowrite32(0x0301, ioaddr + CSR12);
 		tulip_restart_rxtx(tp);
 	}
 }
diff -Nru a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
--- a/drivers/net/tulip/de2104x.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/tulip/de2104x.c	2004-12-24 13:37:18 -08:00
@@ -287,7 +287,7 @@
 	unsigned		tx_tail;
 	unsigned		rx_tail;
 
-	void			*regs;
+	void			__iomem *regs;
 	struct net_device	*dev;
 	spinlock_t		lock;
 
@@ -1208,8 +1208,7 @@
 		pci_write_config_dword(de->pdev, PCIPM, pmctl);
 
 		/* de4x5.c delays, so we do too */
-		current->state = TASK_UNINTERRUPTIBLE;
-		schedule_timeout(msecs_to_jiffies(10));
+		msleep(10);
 	}
 }
 
@@ -1735,11 +1734,11 @@
 }
 
 /* Note: this routine returns extra data bits for size detection. */
-static unsigned __init tulip_read_eeprom(void *regs, int location, int addr_len)
+static unsigned __init tulip_read_eeprom(void __iomem *regs, int location, int addr_len)
 {
 	int i;
 	unsigned retval = 0;
-	void *ee_addr = regs + ROMCmd;
+	void __iomem *ee_addr = regs + ROMCmd;
 	int read_cmd = location | (EE_READ_CMD << addr_len);
 
 	writel(EE_ENB & ~EE_CS, ee_addr);
@@ -1932,7 +1931,7 @@
 	struct net_device *dev;
 	struct de_private *de;
 	int rc;
-	void *regs;
+	void __iomem *regs;
 	long pciaddr;
 	static int board_idx = -1;
 
diff -Nru a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
--- a/drivers/net/tulip/de4x5.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/tulip/de4x5.c	2004-12-24 13:36:17 -08:00
@@ -467,8 +467,8 @@
 #include <linux/ctype.h>
 #include <linux/dma-mapping.h>
 #include <linux/moduleparam.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/byteorder.h>
@@ -1141,7 +1141,7 @@
 	lp->asBitValid = TRUE;
 	lp->timeout = -1;
 	lp->gendev = gendev;
-	lp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&lp->lock);
 	init_timer(&lp->timer);
 	de4x5_parse_params(dev);
 
@@ -1316,7 +1316,7 @@
     ** Re-initialize the DE4X5... 
     */
     status = de4x5_init(dev);
-    lp->lock = SPIN_LOCK_UNLOCKED;
+    spin_lock_init(&lp->lock);
     lp->state = OPEN;
     de4x5_dbg_open(dev);
     
@@ -2242,8 +2242,8 @@
 		return -ENODEV;
 
 	/* Ok, the device seems to be for us. */
-	if (pci_enable_device (pdev))
-		return -ENODEV;
+	if ((error = pci_enable_device (pdev)))
+		return error;
 
 	if (!(dev = alloc_etherdev (sizeof (struct de4x5_private)))) {
 		error = -ENOMEM;
@@ -5089,7 +5089,7 @@
     lp->useMII = TRUE;
 
     /* Search the MII address space for possible PHY devices */
-    for (n=0, lp->mii_cnt=0, i=1; !((i==1) && (n==1)); i=(++i)%DE4X5_MAX_MII) {
+    for (n=0, lp->mii_cnt=0, i=1; !((i==1) && (n==1)); i=(i+1)%DE4X5_MAX_MII) {
 	lp->phy[lp->active].addr = i;
 	if (i==0) n++;                             /* Count cycles */
 	while (de4x5_reset_phy(dev)<0) udelay(100);/* Wait for reset */
diff -Nru a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
--- a/drivers/net/tulip/dmfe.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/tulip/dmfe.c	2004-12-24 13:37:19 -08:00
@@ -86,12 +86,13 @@
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 
 #include <asm/processor.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/uaccess.h>
+#include <asm/irq.h>
 
 
 /* Board/System/Debug information/definition ---------------- */
diff -Nru a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
--- a/drivers/net/tulip/eeprom.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/tulip/eeprom.c	2004-12-24 13:37:19 -08:00
@@ -14,6 +14,7 @@
 
 */
 
+#include <linux/pci.h>
 #include "tulip.h"
 #include <linux/init.h>
 #include <asm/unaligned.h>
@@ -312,7 +313,7 @@
 /* Delay between EEPROM clock transitions.
    Even at 33Mhz current PCI implementations don't overrun the EEPROM clock.
    We add a bus turn-around to insure that this remains true. */
-#define eeprom_delay()	inl(ee_addr)
+#define eeprom_delay()	ioread32(ee_addr)
 
 /* The EEPROM commands include the alway-set leading bit. */
 #define EE_READ_CMD		(6)
@@ -323,34 +324,34 @@
 	int i;
 	unsigned retval = 0;
 	struct tulip_private *tp = dev->priv;
-	long ee_addr = tp->base_addr + CSR9;
+	void __iomem *ee_addr = tp->base_addr + CSR9;
 	int read_cmd = location | (EE_READ_CMD << addr_len);
 
-	outl(EE_ENB & ~EE_CS, ee_addr);
-	outl(EE_ENB, ee_addr);
+	iowrite32(EE_ENB & ~EE_CS, ee_addr);
+	iowrite32(EE_ENB, ee_addr);
 
 	/* Shift the read command bits out. */
 	for (i = 4 + addr_len; i >= 0; i--) {
 		short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
-		outl(EE_ENB | dataval, ee_addr);
+		iowrite32(EE_ENB | dataval, ee_addr);
 		eeprom_delay();
-		outl(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
+		iowrite32(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
 		eeprom_delay();
-		retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0);
+		retval = (retval << 1) | ((ioread32(ee_addr) & EE_DATA_READ) ? 1 : 0);
 	}
-	outl(EE_ENB, ee_addr);
+	iowrite32(EE_ENB, ee_addr);
 	eeprom_delay();
 
 	for (i = 16; i > 0; i--) {
-		outl(EE_ENB | EE_SHIFT_CLK, ee_addr);
+		iowrite32(EE_ENB | EE_SHIFT_CLK, ee_addr);
 		eeprom_delay();
-		retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0);
-		outl(EE_ENB, ee_addr);
+		retval = (retval << 1) | ((ioread32(ee_addr) & EE_DATA_READ) ? 1 : 0);
+		iowrite32(EE_ENB, ee_addr);
 		eeprom_delay();
 	}
 
 	/* Terminate the EEPROM access. */
-	outl(EE_ENB & ~EE_CS, ee_addr);
+	iowrite32(EE_ENB & ~EE_CS, ee_addr);
 	return (tp->flags & HAS_SWAPPED_SEEPROM) ? swab16(retval) : retval;
 }
 
diff -Nru a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
--- a/drivers/net/tulip/interrupt.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/tulip/interrupt.c	2004-12-24 13:37:43 -08:00
@@ -14,10 +14,10 @@
 
 */
 
+#include <linux/pci.h>
 #include "tulip.h"
 #include <linux/config.h>
 #include <linux/etherdevice.h>
-#include <linux/pci.h>
 
 int tulip_rx_copybreak;
 unsigned int tulip_max_interrupt_work;
@@ -89,11 +89,11 @@
 		tp->rx_ring[entry].status = cpu_to_le32(DescOwned);
 	}
 	if(tp->chip_id == LC82C168) {
-		if(((inl(dev->base_addr + CSR5)>>17)&0x07) == 4) {
+		if(((ioread32(tp->base_addr + CSR5)>>17)&0x07) == 4) {
 			/* Rx stopped due to out of buffers,
 			 * restart it
 			 */
-			outl(0x01, dev->base_addr + CSR2);
+			iowrite32(0x01, tp->base_addr + CSR2);
 		}
 	}
 	return refilled;
@@ -133,12 +133,12 @@
 			   tp->rx_ring[entry].status);
 
        do {
-		if (inl(dev->base_addr + CSR5) == 0xffffffff) {
+		if (ioread32(tp->base_addr + CSR5) == 0xffffffff) {
 			printk(KERN_DEBUG " In tulip_poll(), hardware disappeared.\n");
 			break;
 		}
                /* Acknowledge current RX interrupt sources. */
-               outl((RxIntr | RxNoBuf), dev->base_addr + CSR5);
+               iowrite32((RxIntr | RxNoBuf), tp->base_addr + CSR5);
  
  
                /* If we own the next entry, it is a new packet. Send it up. */
@@ -258,7 +258,7 @@
                 * No idea how to fix this if "playing with fire" will fail
                 * tomorrow (night 011029). If it will not fail, we won
                 * finally: amount of IO did not increase at all. */
-       } while ((inl(dev->base_addr + CSR5) & RxIntr));
+       } while ((ioread32(tp->base_addr + CSR5) & RxIntr));
  
 done:
  
@@ -285,13 +285,13 @@
                  if( received > 1 ) {
                          if( ! tp->mit_on ) {
                                  tp->mit_on = 1;
-                                 outl(mit_table[MIT_TABLE], dev->base_addr + CSR11);
+                                 iowrite32(mit_table[MIT_TABLE], tp->base_addr + CSR11);
                          }
                   }
                  else {
                          if( tp->mit_on ) {
                                  tp->mit_on = 0;
-                                 outl(0, dev->base_addr + CSR11);
+                                 iowrite32(0, tp->base_addr + CSR11);
                          }
                   }
           }
@@ -309,7 +309,7 @@
          /* Remove us from polling list and enable RX intr. */
  
          netif_rx_complete(dev);
-         outl(tulip_tbl[tp->chip_id].valid_intrs, dev->base_addr+CSR7);
+         iowrite32(tulip_tbl[tp->chip_id].valid_intrs, tp->base_addr+CSR7);
  
          /* The last op happens after poll completion. Which means the following:
           * 1. it can race with disabling irqs in irq handler
@@ -474,19 +474,19 @@
 static inline unsigned int phy_interrupt (struct net_device *dev)
 {
 #ifdef __hppa__
-	int csr12 = inl(dev->base_addr + CSR12) & 0xff;
 	struct tulip_private *tp = netdev_priv(dev);
+	int csr12 = ioread32(tp->base_addr + CSR12) & 0xff;
 
 	if (csr12 != tp->csr12_shadow) {
 		/* ack interrupt */
-		outl(csr12 | 0x02, dev->base_addr + CSR12);
+		iowrite32(csr12 | 0x02, tp->base_addr + CSR12);
 		tp->csr12_shadow = csr12;
 		/* do link change stuff */
 		spin_lock(&tp->lock);
 		tulip_check_duplex(dev);
 		spin_unlock(&tp->lock);
 		/* clear irq ack bit */
-		outl(csr12 & ~0x02, dev->base_addr + CSR12);
+		iowrite32(csr12 & ~0x02, tp->base_addr + CSR12);
 
 		return 1;
 	}
@@ -501,7 +501,7 @@
 {
 	struct net_device *dev = (struct net_device *)dev_instance;
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	int csr5;
 	int missed;
 	int rx = 0;
@@ -519,7 +519,7 @@
 	unsigned int handled = 0;
 
 	/* Let's see whether the interrupt really is for us */
-	csr5 = inl(ioaddr + CSR5);
+	csr5 = ioread32(ioaddr + CSR5);
 
         if (tp->flags & HAS_PHY_IRQ) 
 	        handled = phy_interrupt (dev);
@@ -536,7 +536,7 @@
 		if (!rxd && (csr5 & (RxIntr | RxNoBuf))) {
 			rxd++;
 			/* Mask RX intrs and add the device to poll list. */
-			outl(tulip_tbl[tp->chip_id].valid_intrs&~RxPollInt, ioaddr + CSR7);
+			iowrite32(tulip_tbl[tp->chip_id].valid_intrs&~RxPollInt, ioaddr + CSR7);
 			netif_rx_schedule(dev);
 			
 			if (!(csr5&~(AbnormalIntr|NormalIntr|RxPollInt|TPLnkPass)))
@@ -546,11 +546,11 @@
                /* Acknowledge the interrupt sources we handle here ASAP
                   the poll function does Rx and RxNoBuf acking */
 		
-		outl(csr5 & 0x0001ff3f, ioaddr + CSR5);
+		iowrite32(csr5 & 0x0001ff3f, ioaddr + CSR5);
 
 #else 
 		/* Acknowledge all of the current interrupt sources ASAP. */
-		outl(csr5 & 0x0001ffff, ioaddr + CSR5);
+		iowrite32(csr5 & 0x0001ffff, ioaddr + CSR5);
 
 
 		if (csr5 & (RxIntr | RxNoBuf)) {
@@ -562,7 +562,7 @@
 		
 		if (tulip_debug > 4)
 			printk(KERN_DEBUG "%s: interrupt  csr5=%#8.8x new csr5=%#8.8x.\n",
-			       dev->name, csr5, inl(dev->base_addr + CSR5));
+			       dev->name, csr5, ioread32(ioaddr + CSR5));
 		
 
 		if (csr5 & (TxNoBuf | TxDied | TxIntr | TimerInt)) {
@@ -637,7 +637,7 @@
 				if (tulip_debug > 2)
 					printk(KERN_WARNING "%s: The transmitter stopped."
 						   "  CSR5 is %x, CSR6 %x, new CSR6 %x.\n",
-						   dev->name, csr5, inl(ioaddr + CSR6), tp->csr6);
+						   dev->name, csr5, ioread32(ioaddr + CSR6), tp->csr6);
 				tulip_restart_rxtx(tp);
 			}
 			spin_unlock(&tp->lock);
@@ -655,16 +655,16 @@
 					tp->csr6 |= 0x00200000;  /* Store-n-forward. */
 				/* Restart the transmit process. */
 				tulip_restart_rxtx(tp);
-				outl(0, ioaddr + CSR1);
+				iowrite32(0, ioaddr + CSR1);
 			}
 			if (csr5 & (RxDied | RxNoBuf)) {
 				if (tp->flags & COMET_MAC_ADDR) {
-					outl(tp->mc_filter[0], ioaddr + 0xAC);
-					outl(tp->mc_filter[1], ioaddr + 0xB0);
+					iowrite32(tp->mc_filter[0], ioaddr + 0xAC);
+					iowrite32(tp->mc_filter[1], ioaddr + 0xB0);
 				}
 			}
 			if (csr5 & RxDied) {		/* Missed a Rx frame. */
-                                tp->stats.rx_missed_errors += inl(ioaddr + CSR8) & 0xffff;
+                                tp->stats.rx_missed_errors += ioread32(ioaddr + CSR8) & 0xffff;
 				tp->stats.rx_errors++;
 				tulip_start_rxtx(tp);
 			}
@@ -692,7 +692,7 @@
 					dev->name, tp->nir, error);
 			}
 			/* Clear all error sources, included undocumented ones! */
-			outl(0x0800f7ba, ioaddr + CSR5);
+			iowrite32(0x0800f7ba, ioaddr + CSR5);
 			oi++;
 		}
 		if (csr5 & TimerInt) {
@@ -700,7 +700,7 @@
 			if (tulip_debug > 2)
 				printk(KERN_ERR "%s: Re-enabling interrupts, %8.8x.\n",
 					   dev->name, csr5);
-			outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
+			iowrite32(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
 			tp->ttimer = 0;
 			oi++;
 		}
@@ -710,20 +710,20 @@
 					   "csr5=0x%8.8x. (%lu) (%d,%d,%d)\n", dev->name, csr5, tp->nir, tx, rx, oi);
 
                        /* Acknowledge all interrupt sources. */
-                        outl(0x8001ffff, ioaddr + CSR5);
+                        iowrite32(0x8001ffff, ioaddr + CSR5);
                         if (tp->flags & HAS_INTR_MITIGATION) {
                      /* Josip Loncaric at ICASE did extensive experimentation
 			to develop a good interrupt mitigation setting.*/
-                                outl(0x8b240000, ioaddr + CSR11);
+                                iowrite32(0x8b240000, ioaddr + CSR11);
                         } else if (tp->chip_id == LC82C168) {
 				/* the LC82C168 doesn't have a hw timer.*/
-				outl(0x00, ioaddr + CSR7);
+				iowrite32(0x00, ioaddr + CSR7);
 				mod_timer(&tp->timer, RUN_AT(HZ/50));
 			} else {
                           /* Mask all interrupting sources, set timer to
 				re-enable. */
-                                outl(((~csr5) & 0x0001ebef) | AbnormalIntr | TimerInt, ioaddr + CSR7);
-                                outl(0x0012, ioaddr + CSR11);
+                                iowrite32(((~csr5) & 0x0001ebef) | AbnormalIntr | TimerInt, ioaddr + CSR7);
+                                iowrite32(0x0012, ioaddr + CSR11);
                         }
 			break;
 		}
@@ -732,7 +732,7 @@
 		if (work_count == 0)
 			break;
 
-		csr5 = inl(ioaddr + CSR5);
+		csr5 = ioread32(ioaddr + CSR5);
 
 #ifdef CONFIG_TULIP_NAPI
 		if (rxd)
@@ -758,29 +758,29 @@
 		if (tulip_debug > 1)
 			printk(KERN_WARNING "%s: in rx suspend mode: (%lu) (tp->cur_rx = %u, ttimer = %d, rx = %d) go/stay in suspend mode\n", dev->name, tp->nir, tp->cur_rx, tp->ttimer, rx);
 		if (tp->chip_id == LC82C168) {
-			outl(0x00, ioaddr + CSR7);
+			iowrite32(0x00, ioaddr + CSR7);
 			mod_timer(&tp->timer, RUN_AT(HZ/50));
 		} else {
-			if (tp->ttimer == 0 || (inl(ioaddr + CSR11) & 0xffff) == 0) {
+			if (tp->ttimer == 0 || (ioread32(ioaddr + CSR11) & 0xffff) == 0) {
 				if (tulip_debug > 1)
 					printk(KERN_WARNING "%s: in rx suspend mode: (%lu) set timer\n", dev->name, tp->nir);
-				outl(tulip_tbl[tp->chip_id].valid_intrs | TimerInt,
+				iowrite32(tulip_tbl[tp->chip_id].valid_intrs | TimerInt,
 					ioaddr + CSR7);
-				outl(TimerInt, ioaddr + CSR5);
-				outl(12, ioaddr + CSR11);
+				iowrite32(TimerInt, ioaddr + CSR5);
+				iowrite32(12, ioaddr + CSR11);
 				tp->ttimer = 1;
 			}
 		}
 	}
 #endif /* CONFIG_TULIP_NAPI */
 
-	if ((missed = inl(ioaddr + CSR8) & 0x1ffff)) {
+	if ((missed = ioread32(ioaddr + CSR8) & 0x1ffff)) {
 		tp->stats.rx_dropped += missed & 0x10000 ? 0x10000 : missed;
 	}
 
 	if (tulip_debug > 4)
 		printk(KERN_DEBUG "%s: exiting interrupt, csr5=%#4.4x.\n",
-			   dev->name, inl(ioaddr + CSR5));
+			   dev->name, ioread32(ioaddr + CSR5));
 
 	return IRQ_HANDLED;
 }
diff -Nru a/drivers/net/tulip/media.c b/drivers/net/tulip/media.c
--- a/drivers/net/tulip/media.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/tulip/media.c	2004-12-24 13:36:31 -08:00
@@ -18,13 +18,14 @@
 #include <linux/mii.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/pci.h>
 #include "tulip.h"
 
 
 /* The maximum data clock rate is 2.5 Mhz.  The minimum timing is usually
    met by back-to-back PCI I/O cycles, but we insert a delay to avoid
    "overclocking" issues or future 66Mhz PCI. */
-#define mdio_delay() inl(mdio_addr)
+#define mdio_delay() ioread32(mdio_addr)
 
 /* Read and write the MII registers using software-generated serial
    MDIO protocol.  It is just different enough from the EEPROM protocol
@@ -52,8 +53,8 @@
 	int i;
 	int read_cmd = (0xf6 << 10) | ((phy_id & 0x1f) << 5) | location;
 	int retval = 0;
-	long ioaddr = dev->base_addr;
-	long mdio_addr = ioaddr + CSR9;
+	void __iomem *ioaddr = tp->base_addr;
+	void __iomem *mdio_addr = ioaddr + CSR9;
 	unsigned long flags;
 
 	if (location & ~0x1f)
@@ -61,19 +62,19 @@
 
 	if (tp->chip_id == COMET  &&  phy_id == 30) {
 		if (comet_miireg2offset[location])
-			return inl(ioaddr + comet_miireg2offset[location]);
+			return ioread32(ioaddr + comet_miireg2offset[location]);
 		return 0xffff;
 	}
 
 	spin_lock_irqsave(&tp->mii_lock, flags);
 	if (tp->chip_id == LC82C168) {
 		int i = 1000;
-		outl(0x60020000 + (phy_id<<23) + (location<<18), ioaddr + 0xA0);
-		inl(ioaddr + 0xA0);
-		inl(ioaddr + 0xA0);
+		iowrite32(0x60020000 + (phy_id<<23) + (location<<18), ioaddr + 0xA0);
+		ioread32(ioaddr + 0xA0);
+		ioread32(ioaddr + 0xA0);
 		while (--i > 0) {
 			barrier();
-			if ( ! ((retval = inl(ioaddr + 0xA0)) & 0x80000000))
+			if ( ! ((retval = ioread32(ioaddr + 0xA0)) & 0x80000000))
 				break;
 		}
 		spin_unlock_irqrestore(&tp->mii_lock, flags);
@@ -82,26 +83,26 @@
 
 	/* Establish sync by sending at least 32 logic ones. */
 	for (i = 32; i >= 0; i--) {
-		outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
+		iowrite32(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
 		mdio_delay();
-		outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
+		iowrite32(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
 		mdio_delay();
 	}
 	/* Shift the read command bits out. */
 	for (i = 15; i >= 0; i--) {
 		int dataval = (read_cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
 
-		outl(MDIO_ENB | dataval, mdio_addr);
+		iowrite32(MDIO_ENB | dataval, mdio_addr);
 		mdio_delay();
-		outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
+		iowrite32(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
 		mdio_delay();
 	}
 	/* Read the two transition, 16 data, and wire-idle bits. */
 	for (i = 19; i > 0; i--) {
-		outl(MDIO_ENB_IN, mdio_addr);
+		iowrite32(MDIO_ENB_IN, mdio_addr);
 		mdio_delay();
-		retval = (retval << 1) | ((inl(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
-		outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
+		retval = (retval << 1) | ((ioread32(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
+		iowrite32(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
 		mdio_delay();
 	}
 
@@ -114,8 +115,8 @@
 	struct tulip_private *tp = netdev_priv(dev);
 	int i;
 	int cmd = (0x5002 << 16) | ((phy_id & 0x1f) << 23) | (location<<18) | (val & 0xffff);
-	long ioaddr = dev->base_addr;
-	long mdio_addr = ioaddr + CSR9;
+	void __iomem *ioaddr = tp->base_addr;
+	void __iomem *mdio_addr = ioaddr + CSR9;
 	unsigned long flags;
 
 	if (location & ~0x1f)
@@ -123,17 +124,17 @@
 
 	if (tp->chip_id == COMET && phy_id == 30) {
 		if (comet_miireg2offset[location])
-			outl(val, ioaddr + comet_miireg2offset[location]);
+			iowrite32(val, ioaddr + comet_miireg2offset[location]);
 		return;
 	}
 
 	spin_lock_irqsave(&tp->mii_lock, flags);
 	if (tp->chip_id == LC82C168) {
 		int i = 1000;
-		outl(cmd, ioaddr + 0xA0);
+		iowrite32(cmd, ioaddr + 0xA0);
 		do {
 			barrier();
-			if ( ! (inl(ioaddr + 0xA0) & 0x80000000))
+			if ( ! (ioread32(ioaddr + 0xA0) & 0x80000000))
 				break;
 		} while (--i > 0);
 		spin_unlock_irqrestore(&tp->mii_lock, flags);
@@ -142,24 +143,24 @@
 
 	/* Establish sync by sending 32 logic ones. */
 	for (i = 32; i >= 0; i--) {
-		outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
+		iowrite32(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
 		mdio_delay();
-		outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
+		iowrite32(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
 		mdio_delay();
 	}
 	/* Shift the command bits out. */
 	for (i = 31; i >= 0; i--) {
 		int dataval = (cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
-		outl(MDIO_ENB | dataval, mdio_addr);
+		iowrite32(MDIO_ENB | dataval, mdio_addr);
 		mdio_delay();
-		outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
+		iowrite32(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
 		mdio_delay();
 	}
 	/* Clear out extra bits. */
 	for (i = 2; i > 0; i--) {
-		outl(MDIO_ENB_IN, mdio_addr);
+		iowrite32(MDIO_ENB_IN, mdio_addr);
 		mdio_delay();
-		outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
+		iowrite32(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
 		mdio_delay();
 	}
 
@@ -170,8 +171,8 @@
 /* Set up the transceiver control registers for the selected media type. */
 void tulip_select_media(struct net_device *dev, int startup)
 {
-	long ioaddr = dev->base_addr;
 	struct tulip_private *tp = netdev_priv(dev);
+	void __iomem *ioaddr = tp->base_addr;
 	struct mediatable *mtable = tp->mtable;
 	u32 new_csr6;
 	int i;
@@ -187,8 +188,8 @@
 					   dev->name, p[1]);
 			dev->if_port = p[0];
 			if (startup)
-				outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
-			outl(p[1], ioaddr + CSR12);
+				iowrite32(mtable->csr12dir | 0x100, ioaddr + CSR12);
+			iowrite32(p[1], ioaddr + CSR12);
 			new_csr6 = 0x02000000 | ((p[2] & 0x71) << 18);
 			break;
 		case 2: case 4: {
@@ -208,7 +209,7 @@
 					printk(KERN_DEBUG "%s: Resetting the transceiver.\n",
 						   dev->name);
 				for (i = 0; i < rst[0]; i++)
-					outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
+					iowrite32(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
 			}
 			if (tulip_debug > 1)
 				printk(KERN_DEBUG "%s: 21143 non-MII %s transceiver control "
@@ -219,11 +220,11 @@
 				csr14val = setup[1];
 				csr15dir = (setup[3]<<16) | setup[2];
 				csr15val = (setup[4]<<16) | setup[2];
-				outl(0, ioaddr + CSR13);
-				outl(csr14val, ioaddr + CSR14);
-				outl(csr15dir, ioaddr + CSR15);	/* Direction */
-				outl(csr15val, ioaddr + CSR15);	/* Data */
-				outl(csr13val, ioaddr + CSR13);
+				iowrite32(0, ioaddr + CSR13);
+				iowrite32(csr14val, ioaddr + CSR14);
+				iowrite32(csr15dir, ioaddr + CSR15);	/* Direction */
+				iowrite32(csr15val, ioaddr + CSR15);	/* Data */
+				iowrite32(csr13val, ioaddr + CSR13);
 			} else {
 				csr13val = 1;
 				csr14val = 0;
@@ -232,12 +233,12 @@
 				if (dev->if_port <= 4)
 					csr14val = t21142_csr14[dev->if_port];
 				if (startup) {
-					outl(0, ioaddr + CSR13);
-					outl(csr14val, ioaddr + CSR14);
+					iowrite32(0, ioaddr + CSR13);
+					iowrite32(csr14val, ioaddr + CSR14);
 				}
-				outl(csr15dir, ioaddr + CSR15);	/* Direction */
-				outl(csr15val, ioaddr + CSR15);	/* Data */
-				if (startup) outl(csr13val, ioaddr + CSR13);
+				iowrite32(csr15dir, ioaddr + CSR15);	/* Direction */
+				iowrite32(csr15val, ioaddr + CSR15);	/* Data */
+				if (startup) iowrite32(csr13val, ioaddr + CSR13);
 			}
 			if (tulip_debug > 1)
 				printk(KERN_DEBUG "%s:  Setting CSR15 to %8.8x/%8.8x.\n",
@@ -262,21 +263,21 @@
 				misc_info = reset_sequence + reset_length;
 				if (startup)
 					for (i = 0; i < reset_length; i++)
-						outl(get_u16(&reset_sequence[i]) << 16, ioaddr + CSR15);
+						iowrite32(get_u16(&reset_sequence[i]) << 16, ioaddr + CSR15);
 				for (i = 0; i < init_length; i++)
-					outl(get_u16(&init_sequence[i]) << 16, ioaddr + CSR15);
+					iowrite32(get_u16(&init_sequence[i]) << 16, ioaddr + CSR15);
 			} else {
 				u8 *init_sequence = p + 2;
 				u8 *reset_sequence = p + 3 + init_length;
 				int reset_length = p[2 + init_length];
 				misc_info = (u16*)(reset_sequence + reset_length);
 				if (startup) {
-					outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
+					iowrite32(mtable->csr12dir | 0x100, ioaddr + CSR12);
 					for (i = 0; i < reset_length; i++)
-						outl(reset_sequence[i], ioaddr + CSR12);
+						iowrite32(reset_sequence[i], ioaddr + CSR12);
 				}
 				for (i = 0; i < init_length; i++)
-					outl(init_sequence[i], ioaddr + CSR12);
+					iowrite32(init_sequence[i], ioaddr + CSR12);
 			}
 			tmp_info = get_u16(&misc_info[1]);
 			if (tmp_info)
@@ -306,7 +307,7 @@
 					printk(KERN_DEBUG "%s: Resetting the transceiver.\n",
 						   dev->name);
 				for (i = 0; i < rst[0]; i++)
-					outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
+					iowrite32(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
 			}
 
 			break;
@@ -319,32 +320,32 @@
 		if (tulip_debug > 1)
 			printk(KERN_DEBUG "%s: Using media type %s, CSR12 is %2.2x.\n",
 				   dev->name, medianame[dev->if_port],
-				   inl(ioaddr + CSR12) & 0xff);
+				   ioread32(ioaddr + CSR12) & 0xff);
 	} else if (tp->chip_id == LC82C168) {
 		if (startup && ! tp->medialock)
 			dev->if_port = tp->mii_cnt ? 11 : 0;
 		if (tulip_debug > 1)
 			printk(KERN_DEBUG "%s: PNIC PHY status is %3.3x, media %s.\n",
-				   dev->name, inl(ioaddr + 0xB8), medianame[dev->if_port]);
+				   dev->name, ioread32(ioaddr + 0xB8), medianame[dev->if_port]);
 		if (tp->mii_cnt) {
 			new_csr6 = 0x810C0000;
-			outl(0x0001, ioaddr + CSR15);
-			outl(0x0201B07A, ioaddr + 0xB8);
+			iowrite32(0x0001, ioaddr + CSR15);
+			iowrite32(0x0201B07A, ioaddr + 0xB8);
 		} else if (startup) {
 			/* Start with 10mbps to do autonegotiation. */
-			outl(0x32, ioaddr + CSR12);
+			iowrite32(0x32, ioaddr + CSR12);
 			new_csr6 = 0x00420000;
-			outl(0x0001B078, ioaddr + 0xB8);
-			outl(0x0201B078, ioaddr + 0xB8);
+			iowrite32(0x0001B078, ioaddr + 0xB8);
+			iowrite32(0x0201B078, ioaddr + 0xB8);
 		} else if (dev->if_port == 3  ||  dev->if_port == 5) {
-			outl(0x33, ioaddr + CSR12);
+			iowrite32(0x33, ioaddr + CSR12);
 			new_csr6 = 0x01860000;
 			/* Trigger autonegotiation. */
-			outl(startup ? 0x0201F868 : 0x0001F868, ioaddr + 0xB8);
+			iowrite32(startup ? 0x0201F868 : 0x0001F868, ioaddr + 0xB8);
 		} else {
-			outl(0x32, ioaddr + CSR12);
+			iowrite32(0x32, ioaddr + CSR12);
 			new_csr6 = 0x00420000;
-			outl(0x1F078, ioaddr + 0xB8);
+			iowrite32(0x1F078, ioaddr + 0xB8);
 		}
 	} else {					/* Unknown chip type with no media table. */
 		if (tp->default_port == 0)
@@ -359,7 +360,7 @@
 			printk(KERN_DEBUG "%s: No media description table, assuming "
 				   "%s transceiver, CSR12 %2.2x.\n",
 				   dev->name, medianame[dev->if_port],
-				   inl(ioaddr + CSR12));
+				   ioread32(ioaddr + CSR12));
 	}
 
 	tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
diff -Nru a/drivers/net/tulip/pnic.c b/drivers/net/tulip/pnic.c
--- a/drivers/net/tulip/pnic.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/net/tulip/pnic.c	2004-12-24 13:37:02 -08:00
@@ -15,14 +15,15 @@
 */
 
 #include <linux/kernel.h>
+#include <linux/pci.h>
 #include "tulip.h"
 
 
 void pnic_do_nway(struct net_device *dev)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
-	u32 phy_reg = inl(ioaddr + 0xB8);
+	void __iomem *ioaddr = tp->base_addr;
+	u32 phy_reg = ioread32(ioaddr + 0xB8);
 	u32 new_csr6 = tp->csr6 & ~0x40C40200;
 
 	if (phy_reg & 0x78000000) { /* Ignore baseT4 */
@@ -32,9 +33,9 @@
 		else if (phy_reg & 0x08000000)	dev->if_port = 0;
 		tp->nwayset = 1;
 		new_csr6 = (dev->if_port & 1) ? 0x01860000 : 0x00420000;
-		outl(0x32 | (dev->if_port & 1), ioaddr + CSR12);
+		iowrite32(0x32 | (dev->if_port & 1), ioaddr + CSR12);
 		if (dev->if_port & 1)
-			outl(0x1F868, ioaddr + 0xB8);
+			iowrite32(0x1F868, ioaddr + 0xB8);
 		if (phy_reg & 0x30000000) {
 			tp->full_duplex = 1;
 			new_csr6 |= 0x00000200;
@@ -54,14 +55,14 @@
 void pnic_lnk_change(struct net_device *dev, int csr5)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
-	int phy_reg = inl(ioaddr + 0xB8);
+	void __iomem *ioaddr = tp->base_addr;
+	int phy_reg = ioread32(ioaddr + 0xB8);
 
 	if (tulip_debug > 1)
 		printk(KERN_DEBUG "%s: PNIC link changed state %8.8x, CSR5 %8.8x.\n",
 			   dev->name, phy_reg, csr5);
-	if (inl(ioaddr + CSR5) & TPLnkFail) {
-		outl((inl(ioaddr + CSR7) & ~TPLnkFail) | TPLnkPass, ioaddr + CSR7);
+	if (ioread32(ioaddr + CSR5) & TPLnkFail) {
+		iowrite32((ioread32(ioaddr + CSR7) & ~TPLnkFail) | TPLnkPass, ioaddr + CSR7);
 		/* If we use an external MII, then we mustn't use the
 		 * internal negotiation.
 		 */
@@ -69,12 +70,12 @@
 			return;
 		if (! tp->nwayset  ||  jiffies - dev->trans_start > 1*HZ) {
 			tp->csr6 = 0x00420000 | (tp->csr6 & 0x0000fdff);
-			outl(tp->csr6, ioaddr + CSR6);
-			outl(0x30, ioaddr + CSR12);
-			outl(0x0201F078, ioaddr + 0xB8); /* Turn on autonegotiation. */
+			iowrite32(tp->csr6, ioaddr + CSR6);
+			iowrite32(0x30, ioaddr + CSR12);
+			iowrite32(0x0201F078, ioaddr + 0xB8); /* Turn on autonegotiation. */
 			dev->trans_start = jiffies;
 		}
-	} else if (inl(ioaddr + CSR5) & TPLnkPass) {
+	} else if (ioread32(ioaddr + CSR5) & TPLnkPass) {
 		if (tulip_media_cap[dev->if_port] & MediaIsMII) {
 			spin_lock(&tp->lock);
 			tulip_check_duplex(dev);
@@ -82,7 +83,7 @@
 		} else {
 			pnic_do_nway(dev);
 		}
-		outl((inl(ioaddr + CSR7) & ~TPLnkPass) | TPLnkFail, ioaddr + CSR7);
+		iowrite32((ioread32(ioaddr + CSR7) & ~TPLnkPass) | TPLnkFail, ioaddr + CSR7);
 	}
 }
 
@@ -90,10 +91,10 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	int next_tick = 60*HZ;
 
-	if(!inl(ioaddr + CSR7)) {
+	if(!ioread32(ioaddr + CSR7)) {
 		/* the timer was called due to a work overflow
 		 * in the interrupt handler. Skip the connection
 		 * checks, the nic is definitively speaking with
@@ -108,17 +109,17 @@
 			next_tick = 3*HZ;
 		spin_unlock_irq(&tp->lock);
 	} else {
-		int csr12 = inl(ioaddr + CSR12);
+		int csr12 = ioread32(ioaddr + CSR12);
 		int new_csr6 = tp->csr6 & ~0x40C40200;
-		int phy_reg = inl(ioaddr + 0xB8);
-		int csr5 = inl(ioaddr + CSR5);
+		int phy_reg = ioread32(ioaddr + 0xB8);
+		int csr5 = ioread32(ioaddr + CSR5);
 
 		if (tulip_debug > 1)
 			printk(KERN_DEBUG "%s: PNIC timer PHY status %8.8x, %s "
 				   "CSR5 %8.8x.\n",
 				   dev->name, phy_reg, medianame[dev->if_port], csr5);
 		if (phy_reg & 0x04000000) {	/* Remote link fault */
-			outl(0x0201F078, ioaddr + 0xB8);
+			iowrite32(0x0201F078, ioaddr + 0xB8);
 			next_tick = 1*HZ;
 			tp->nwayset = 0;
 		} else if (phy_reg & 0x78000000) { /* Ignore baseT4 */
@@ -129,21 +130,21 @@
 				printk(KERN_DEBUG "%s: %s link beat failed, CSR12 %4.4x, "
 					   "CSR5 %8.8x, PHY %3.3x.\n",
 					   dev->name, medianame[dev->if_port], csr12,
-					   inl(ioaddr + CSR5), inl(ioaddr + 0xB8));
+					   ioread32(ioaddr + CSR5), ioread32(ioaddr + 0xB8));
 			next_tick = 3*HZ;
 			if (tp->medialock) {
 			} else if (tp->nwayset  &&  (dev->if_port & 1)) {
 				next_tick = 1*HZ;
 			} else if (dev->if_port == 0) {
 				dev->if_port = 3;
-				outl(0x33, ioaddr + CSR12);
+				iowrite32(0x33, ioaddr + CSR12);
 				new_csr6 = 0x01860000;
-				outl(0x1F868, ioaddr + 0xB8);
+				iowrite32(0x1F868, ioaddr + 0xB8);
 			} else {
 				dev->if_port = 0;
-				outl(0x32, ioaddr + CSR12);
+				iowrite32(0x32, ioaddr + CSR12);
 				new_csr6 = 0x00420000;
-				outl(0x1F078, ioaddr + 0xB8);
+				iowrite32(0x1F078, ioaddr + 0xB8);
 			}
 			if (tp->csr6 != new_csr6) {
 				tp->csr6 = new_csr6;
@@ -160,12 +161,12 @@
 	}
 too_good_connection:
 	mod_timer(&tp->timer, RUN_AT(next_tick));
-	if(!inl(ioaddr + CSR7)) {
+	if(!ioread32(ioaddr + CSR7)) {
 		if (tulip_debug > 1)
 			printk(KERN_INFO "%s: sw timer wakeup.\n", dev->name);
 		disable_irq(dev->irq);
 		tulip_refill_rx(dev);
 		enable_irq(dev->irq);
-		outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
+		iowrite32(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
 	}
 }
diff -Nru a/drivers/net/tulip/pnic2.c b/drivers/net/tulip/pnic2.c
--- a/drivers/net/tulip/pnic2.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/tulip/pnic2.c	2004-12-24 13:36:18 -08:00
@@ -76,8 +76,8 @@
 
 
 
-#include "tulip.h"
 #include <linux/pci.h>
+#include "tulip.h"
 #include <linux/delay.h>
 
 
@@ -85,12 +85,12 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	int next_tick = 60*HZ;
 
 	if (tulip_debug > 3)
 		printk(KERN_INFO"%s: PNIC2 negotiation status %8.8x.\n",
-                    dev->name,inl(ioaddr + CSR12));
+                    dev->name,ioread32(ioaddr + CSR12));
 
 	if (next_tick) {
 		mod_timer(&tp->timer, RUN_AT(next_tick));
@@ -101,7 +101,7 @@
 void pnic2_start_nway(struct net_device *dev)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
         int csr14;
         int csr12;
 
@@ -110,7 +110,7 @@
         /* load in csr14  and mask off bits not to touch
          * comment at top of file explains mask value
          */
-	csr14 = (inl(ioaddr + CSR14) & 0xfff0ee39);
+	csr14 = (ioread32(ioaddr + CSR14) & 0xfff0ee39);
 
         /* bit 17 - advetise 100baseTx-FD */
         if (tp->sym_advertise & 0x0100) csr14 |= 0x00020000;
@@ -137,7 +137,7 @@
 
         /* now we have to set up csr6 for NWAY state */
 
-	tp->csr6 = inl(ioaddr + CSR6);
+	tp->csr6 = ioread32(ioaddr + CSR6);
 	if (tulip_debug > 1)
 		printk(KERN_DEBUG "%s: On Entry to Nway, "
                       "csr6=%8.8x.\n", dev->name, tp->csr6);
@@ -156,8 +156,8 @@
          * and "Stop" - reset both Transmit (bit 13) and Receive (bit 1)
          */
         tp->csr6 |= 0x01000000;
-	outl(csr14, ioaddr + CSR14);
-	outl(tp->csr6, ioaddr + CSR6);
+	iowrite32(csr14, ioaddr + CSR14);
+	iowrite32(tp->csr6, ioaddr + CSR6);
         udelay(100);
 
         /* all set up so now force the negotiation to begin */
@@ -166,9 +166,9 @@
 	 * Autonegotiation bits 14:12.  Writing a 001 to those bits
          * should start the autonegotiation
          */
-        csr12 = (inl(ioaddr + CSR12) & 0xffff8fff);
+        csr12 = (ioread32(ioaddr + CSR12) & 0xffff8fff);
         csr12 |= 0x1000;
-	outl(csr12, ioaddr + CSR12);
+	iowrite32(csr12, ioaddr + CSR12);
 }
 
 
@@ -176,16 +176,16 @@
 void pnic2_lnk_change(struct net_device *dev, int csr5)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
         int csr14;
 
         /* read the staus register to find out what is up */
-	int csr12 = inl(ioaddr + CSR12);
+	int csr12 = ioread32(ioaddr + CSR12);
 
 	if (tulip_debug > 1)
 		printk(KERN_INFO"%s: PNIC2 link status interrupt %8.8x, "
                        " CSR5 %x, %8.8x.\n", dev->name, csr12,
-                       csr5, inl(ioaddr + CSR14));
+                       csr5, ioread32(ioaddr + CSR14));
 
 	/* If NWay finished and we have a negotiated partner capability.
          * check bits 14:12 for bit pattern 101 - all is good
@@ -243,8 +243,8 @@
                          * enable so we can properly end nway mode and
                          * set duplex (ie. use csr6<9> again)
                          */
-	                csr14 = (inl(ioaddr + CSR14) & 0xffffff7f);
-                        outl(csr14,ioaddr + CSR14);
+	                csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f);
+                        iowrite32(csr14,ioaddr + CSR14);
 
 
                         /* now set the data port and operating mode
@@ -255,7 +255,7 @@
 			/* get current csr6 and mask off bits not to touch */
 			/* see comment at top of file */
 
-			tp->csr6 = (inl(ioaddr + CSR6) & 0xfe3bd1fd);
+			tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd);
 
 			/* so if using if_port 3 or 5 then select the 100baseT
 			 * port else select the 10baseT port.
@@ -269,12 +269,12 @@
 			/* now set the full duplex bit appropriately */
 			if (tp->full_duplex) tp->csr6 |= 0x00000200;
 
-			outl(1, ioaddr + CSR13);
+			iowrite32(1, ioaddr + CSR13);
 
 			if (tulip_debug > 2)
 			        printk(KERN_DEBUG "%s:  Setting CSR6 %8.8x/%x CSR12 "
                                       "%8.8x.\n", dev->name, tp->csr6,
-                                      inl(ioaddr + CSR6), inl(ioaddr + CSR12));
+                                      ioread32(ioaddr + CSR6), ioread32(ioaddr + CSR12));
 
 			/* now the following actually writes out the
 			 * new csr6 values
@@ -291,8 +291,8 @@
                         /* remember to turn off bit 7 - autonegotiate
                          * enable so we don't forget
                          */
-	                csr14 = (inl(ioaddr + CSR14) & 0xffffff7f);
-                        outl(csr14,ioaddr + CSR14);
+	                csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f);
+                        iowrite32(csr14,ioaddr + CSR14);
 
                         /* what should we do when autonegotiate fails?
                          * should we try again or default to baseline
@@ -308,7 +308,7 @@
                          /* set to 10baseTx-HD - see Data Port Selection
                           * comment given at the top of the file
                           */
-	                 tp->csr6 = (inl(ioaddr + CSR6) & 0xfe3bd1fd);
+	                 tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd);
                          tp->csr6 |= 0x00400000;
 
 	                 tulip_restart_rxtx(tp);
@@ -393,13 +393,13 @@
 	dev->if_port = 0;
 
         /* make sure autonegotiate enable is off */
-	csr14 = (inl(ioaddr + CSR14) & 0xffffff7f);
-        outl(csr14,ioaddr + CSR14);
+	csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f);
+        iowrite32(csr14,ioaddr + CSR14);
 
         /* set to 10baseTx-HD - see Data Port Selection
          * comment given at the top of the file
          */
-	tp->csr6 = (inl(ioaddr + CSR6) & 0xfe3bd1fd);
+	tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd);
         tp->csr6 |= 0x00400000;
 
 	tulip_restart_rxtx(tp);
diff -Nru a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
--- a/drivers/net/tulip/timer.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/tulip/timer.c	2004-12-24 13:36:16 -08:00
@@ -14,6 +14,7 @@
 
 */
 
+#include <linux/pci.h>
 #include "tulip.h"
 
 
@@ -21,16 +22,16 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
-	u32 csr12 = inl(ioaddr + CSR12);
+	void __iomem *ioaddr = tp->base_addr;
+	u32 csr12 = ioread32(ioaddr + CSR12);
 	int next_tick = 2*HZ;
 
 	if (tulip_debug > 2) {
 		printk(KERN_DEBUG "%s: Media selection tick, %s, status %8.8x mode"
 			   " %8.8x SIA %8.8x %8.8x %8.8x %8.8x.\n",
-			   dev->name, medianame[dev->if_port], inl(ioaddr + CSR5),
-			   inl(ioaddr + CSR6), csr12, inl(ioaddr + CSR13),
-			   inl(ioaddr + CSR14), inl(ioaddr + CSR15));
+			   dev->name, medianame[dev->if_port], ioread32(ioaddr + CSR5),
+			   ioread32(ioaddr + CSR6), csr12, ioread32(ioaddr + CSR13),
+			   ioread32(ioaddr + CSR14), ioread32(ioaddr + CSR15));
 	}
 	switch (tp->chip_id) {
 	case DC21140:
@@ -48,7 +49,7 @@
 			if (tulip_debug > 2)
 				printk(KERN_DEBUG "%s: network media monitor CSR6 %8.8x "
 					   "CSR12 0x%2.2x.\n",
-					   dev->name, inl(ioaddr + CSR6), csr12 & 0xff);
+					   dev->name, ioread32(ioaddr + CSR6), csr12 & 0xff);
 			break;
 		}
 		mleaf = &tp->mtable->mleaf[tp->cur_index];
@@ -136,12 +137,12 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	int next_tick = 60*HZ;
 
 	if (tulip_debug > 3) {
 		printk(KERN_INFO"%s: MXIC negotiation status %8.8x.\n", dev->name,
-			   inl(ioaddr + CSR12));
+			   ioread32(ioaddr + CSR12));
 	}
 	if (next_tick) {
 		mod_timer(&tp->timer, RUN_AT(next_tick));
diff -Nru a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
--- a/drivers/net/tulip/tulip.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/tulip/tulip.h	2004-12-24 13:37:19 -08:00
@@ -149,6 +149,9 @@
 	TxIntr = 0x01,
 };
 
+/* bit mask for CSR5 TX/RX process state */
+#define CSR5_TS	0x00700000
+#define CSR5_RS	0x000e0000
 
 enum tulip_mode_bits {
 	TxThreshold		= (1 << 22),
@@ -379,7 +382,7 @@
 	int ttimer;
 	int susp_rx;
 	unsigned long nir;
-	unsigned long base_addr;
+	void __iomem *base_addr;
 	int csr12_shadow;
 	int pad0;		/* Used for 8-byte alignment */
 };
@@ -446,40 +449,33 @@
 void oom_timer(unsigned long data);
 extern u8 t21040_csr13[];
 
-#ifndef USE_IO_OPS
-#undef inb
-#undef inw
-#undef inl
-#undef outb
-#undef outw
-#undef outl
-#define inb(addr) readb((void*)(addr))
-#define inw(addr) readw((void*)(addr))
-#define inl(addr) readl((void*)(addr))
-#define outb(val,addr) writeb((val), (void*)(addr))
-#define outw(val,addr) writew((val), (void*)(addr))
-#define outl(val,addr) writel((val), (void*)(addr))
-#endif /* !USE_IO_OPS */
-
-
-
 static inline void tulip_start_rxtx(struct tulip_private *tp)
 {
-	long ioaddr = tp->base_addr;
-	outl(tp->csr6 | RxTx, ioaddr + CSR6);
+	void __iomem *ioaddr = tp->base_addr;
+	iowrite32(tp->csr6 | RxTx, ioaddr + CSR6);
 	barrier();
-	(void) inl(ioaddr + CSR6); /* mmio sync */
+	(void) ioread32(ioaddr + CSR6); /* mmio sync */
 }
 
 static inline void tulip_stop_rxtx(struct tulip_private *tp)
 {
-	long ioaddr = tp->base_addr;
-	u32 csr6 = inl(ioaddr + CSR6);
+	void __iomem *ioaddr = tp->base_addr;
+	u32 csr6 = ioread32(ioaddr + CSR6);
 
 	if (csr6 & RxTx) {
-		outl(csr6 & ~RxTx, ioaddr + CSR6);
+		unsigned i=1300/10;
+		iowrite32(csr6 & ~RxTx, ioaddr + CSR6);
 		barrier();
-		(void) inl(ioaddr + CSR6); /* mmio sync */
+		/* wait until in-flight frame completes.
+		 * Max time @ 10BT: 1500*8b/10Mbps == 1200us (+ 100us margin)
+		 * Typically expect this loop to end in < 50 us on 100BT.
+		 */
+		while (--i && (ioread32(ioaddr + CSR5) & (CSR5_TS|CSR5_RS)))
+			udelay(10);
+
+		if (!i)
+			printk(KERN_DEBUG "%s: tulip_stop_rxtx() failed\n",
+					tp->pdev->slot_name);
 	}
 }
 
diff -Nru a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
--- a/drivers/net/tulip/tulip_core.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/tulip/tulip_core.c	2004-12-24 13:37:00 -08:00
@@ -26,8 +26,8 @@
 
 
 #include <linux/module.h>
-#include "tulip.h"
 #include <linux/pci.h>
+#include "tulip.h"
 #include <linux/init.h>
 #include <linux/etherdevice.h>
 #include <linux/delay.h>
@@ -279,7 +279,7 @@
 static void tulip_up(struct net_device *dev)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	int next_tick = 3*HZ;
 	int i;
 
@@ -288,23 +288,23 @@
 
 	/* On some chip revs we must set the MII/SYM port before the reset!? */
 	if (tp->mii_cnt  ||  (tp->mtable  &&  tp->mtable->has_mii))
-		outl(0x00040000, ioaddr + CSR6);
+		iowrite32(0x00040000, ioaddr + CSR6);
 
 	/* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
-	outl(0x00000001, ioaddr + CSR0);
+	iowrite32(0x00000001, ioaddr + CSR0);
 	udelay(100);
 
 	/* Deassert reset.
 	   Wait the specified 50 PCI cycles after a reset by initializing
 	   Tx and Rx queues and the address filter list. */
-	outl(tp->csr0, ioaddr + CSR0);
+	iowrite32(tp->csr0, ioaddr + CSR0);
 	udelay(100);
 
 	if (tulip_debug > 1)
 		printk(KERN_DEBUG "%s: tulip_up(), irq==%d.\n", dev->name, dev->irq);
 
-	outl(tp->rx_ring_dma, ioaddr + CSR3);
-	outl(tp->tx_ring_dma, ioaddr + CSR4);
+	iowrite32(tp->rx_ring_dma, ioaddr + CSR3);
+	iowrite32(tp->tx_ring_dma, ioaddr + CSR4);
 	tp->cur_rx = tp->cur_tx = 0;
 	tp->dirty_rx = tp->dirty_tx = 0;
 
@@ -312,15 +312,15 @@
 		u32 addr_low = le32_to_cpu(get_unaligned((u32 *)dev->dev_addr));
 		u32 addr_high = le16_to_cpu(get_unaligned((u16 *)(dev->dev_addr+4)));
 		if (tp->chip_id == AX88140) {
-			outl(0, ioaddr + CSR13);
-			outl(addr_low,  ioaddr + CSR14);
-			outl(1, ioaddr + CSR13);
-			outl(addr_high, ioaddr + CSR14);
+			iowrite32(0, ioaddr + CSR13);
+			iowrite32(addr_low,  ioaddr + CSR14);
+			iowrite32(1, ioaddr + CSR13);
+			iowrite32(addr_high, ioaddr + CSR14);
 		} else if (tp->flags & COMET_MAC_ADDR) {
-			outl(addr_low,  ioaddr + 0xA4);
-			outl(addr_high, ioaddr + 0xA8);
-			outl(0, ioaddr + 0xAC);
-			outl(0, ioaddr + 0xB0);
+			iowrite32(addr_low,  ioaddr + 0xA4);
+			iowrite32(addr_high, ioaddr + 0xA8);
+			iowrite32(0, ioaddr + 0xAC);
+			iowrite32(0, ioaddr + 0xB0);
 		}
 	} else {
 		/* This is set_rx_mode(), but without starting the transmitter. */
@@ -390,9 +390,9 @@
 		if (tp->chip_id == DC21143  &&
 		    (tulip_media_cap[dev->if_port] & MediaIsMII)) {
 			/* We must reset the media CSRs when we force-select MII mode. */
-			outl(0x0000, ioaddr + CSR13);
-			outl(0x0000, ioaddr + CSR14);
-			outl(0x0008, ioaddr + CSR15);
+			iowrite32(0x0000, ioaddr + CSR13);
+			iowrite32(0x0000, ioaddr + CSR14);
+			iowrite32(0x0008, ioaddr + CSR15);
 		}
 		tulip_select_media(dev, 1);
 	} else if (tp->chip_id == DC21142) {
@@ -402,49 +402,49 @@
 				printk(KERN_INFO "%s: Using MII transceiver %d, status "
 					   "%4.4x.\n",
 					   dev->name, tp->phys[0], tulip_mdio_read(dev, tp->phys[0], 1));
-			outl(csr6_mask_defstate, ioaddr + CSR6);
+			iowrite32(csr6_mask_defstate, ioaddr + CSR6);
 			tp->csr6 = csr6_mask_hdcap;
 			dev->if_port = 11;
-			outl(0x0000, ioaddr + CSR13);
-			outl(0x0000, ioaddr + CSR14);
+			iowrite32(0x0000, ioaddr + CSR13);
+			iowrite32(0x0000, ioaddr + CSR14);
 		} else
 			t21142_start_nway(dev);
 	} else if (tp->chip_id == PNIC2) {
 	        /* for initial startup advertise 10/100 Full and Half */
 	        tp->sym_advertise = 0x01E0;
                 /* enable autonegotiate end interrupt */
-	        outl(inl(ioaddr+CSR5)| 0x00008010, ioaddr + CSR5);
-	        outl(inl(ioaddr+CSR7)| 0x00008010, ioaddr + CSR7);
+	        iowrite32(ioread32(ioaddr+CSR5)| 0x00008010, ioaddr + CSR5);
+	        iowrite32(ioread32(ioaddr+CSR7)| 0x00008010, ioaddr + CSR7);
 		pnic2_start_nway(dev);
 	} else if (tp->chip_id == LC82C168  &&  ! tp->medialock) {
 		if (tp->mii_cnt) {
 			dev->if_port = 11;
 			tp->csr6 = 0x814C0000 | (tp->full_duplex ? 0x0200 : 0);
-			outl(0x0001, ioaddr + CSR15);
-		} else if (inl(ioaddr + CSR5) & TPLnkPass)
+			iowrite32(0x0001, ioaddr + CSR15);
+		} else if (ioread32(ioaddr + CSR5) & TPLnkPass)
 			pnic_do_nway(dev);
 		else {
 			/* Start with 10mbps to do autonegotiation. */
-			outl(0x32, ioaddr + CSR12);
+			iowrite32(0x32, ioaddr + CSR12);
 			tp->csr6 = 0x00420000;
-			outl(0x0001B078, ioaddr + 0xB8);
-			outl(0x0201B078, ioaddr + 0xB8);
+			iowrite32(0x0001B078, ioaddr + 0xB8);
+			iowrite32(0x0201B078, ioaddr + 0xB8);
 			next_tick = 1*HZ;
 		}
 	} else if ((tp->chip_id == MX98713 || tp->chip_id == COMPEX9881)
 			   && ! tp->medialock) {
 		dev->if_port = 0;
 		tp->csr6 = 0x01880000 | (tp->full_duplex ? 0x0200 : 0);
-		outl(0x0f370000 | inw(ioaddr + 0x80), ioaddr + 0x80);
+		iowrite32(0x0f370000 | ioread16(ioaddr + 0x80), ioaddr + 0x80);
 	} else if (tp->chip_id == MX98715 || tp->chip_id == MX98725) {
 		/* Provided by BOLO, Macronix - 12/10/1998. */
 		dev->if_port = 0;
 		tp->csr6 = 0x01a80200;
-		outl(0x0f370000 | inw(ioaddr + 0x80), ioaddr + 0x80);
-		outl(0x11000 | inw(ioaddr + 0xa0), ioaddr + 0xa0);
+		iowrite32(0x0f370000 | ioread16(ioaddr + 0x80), ioaddr + 0x80);
+		iowrite32(0x11000 | ioread16(ioaddr + 0xa0), ioaddr + 0xa0);
 	} else if (tp->chip_id == COMET || tp->chip_id == CONEXANT) {
 		/* Enable automatic Tx underrun recovery. */
-		outl(inl(ioaddr + 0x88) | 1, ioaddr + 0x88);
+		iowrite32(ioread32(ioaddr + 0x88) | 1, ioaddr + 0x88);
 		dev->if_port = tp->mii_cnt ? 11 : 0;
 		tp->csr6 = 0x00040000;
 	} else if (tp->chip_id == AX88140) {
@@ -456,18 +456,18 @@
 	tulip_stop_rxtx(tp);
 	barrier();
 	udelay(5);
-	outl(tp->csr6 | TxOn, ioaddr + CSR6);
+	iowrite32(tp->csr6 | TxOn, ioaddr + CSR6);
 
 	/* Enable interrupts by setting the interrupt mask. */
-	outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR5);
-	outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
+	iowrite32(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR5);
+	iowrite32(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
 	tulip_start_rxtx(tp);
-	outl(0, ioaddr + CSR2);		/* Rx poll demand */
+	iowrite32(0, ioaddr + CSR2);		/* Rx poll demand */
 
 	if (tulip_debug > 2) {
 		printk(KERN_DEBUG "%s: Done tulip_up(), CSR0 %8.8x, CSR5 %8.8x CSR6 %8.8x.\n",
-			   dev->name, inl(ioaddr + CSR0), inl(ioaddr + CSR5),
-			   inl(ioaddr + CSR6));
+			   dev->name, ioread32(ioaddr + CSR0), ioread32(ioaddr + CSR5),
+			   ioread32(ioaddr + CSR6));
 	}
 
 	/* Set the timer to switch to check for link beat and perhaps switch
@@ -502,7 +502,7 @@
 static void tulip_tx_timeout(struct net_device *dev)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	unsigned long flags;
 
 	spin_lock_irqsave (&tp->lock, flags);
@@ -517,8 +517,8 @@
 			   || tp->chip_id == DM910X) {
 		printk(KERN_WARNING "%s: 21140 transmit timed out, status %8.8x, "
 			   "SIA %8.8x %8.8x %8.8x %8.8x, resetting...\n",
-			   dev->name, inl(ioaddr + CSR5), inl(ioaddr + CSR12),
-			   inl(ioaddr + CSR13), inl(ioaddr + CSR14), inl(ioaddr + CSR15));
+			   dev->name, ioread32(ioaddr + CSR5), ioread32(ioaddr + CSR12),
+			   ioread32(ioaddr + CSR13), ioread32(ioaddr + CSR14), ioread32(ioaddr + CSR15));
 		if ( ! tp->medialock  &&  tp->mtable) {
 			do
 				--tp->cur_index;
@@ -536,12 +536,12 @@
 	} else if (tp->chip_id == PNIC2) {
 		printk(KERN_WARNING "%s: PNIC2 transmit timed out, status %8.8x, "
 		       "CSR6/7 %8.8x / %8.8x CSR12 %8.8x, resetting...\n",
-		       dev->name, (int)inl(ioaddr + CSR5), (int)inl(ioaddr + CSR6),
-		       (int)inl(ioaddr + CSR7), (int)inl(ioaddr + CSR12));
+		       dev->name, (int)ioread32(ioaddr + CSR5), (int)ioread32(ioaddr + CSR6),
+		       (int)ioread32(ioaddr + CSR7), (int)ioread32(ioaddr + CSR12));
 	} else {
 		printk(KERN_WARNING "%s: Transmit timed out, status %8.8x, CSR12 "
 			   "%8.8x, resetting...\n",
-			   dev->name, inl(ioaddr + CSR5), inl(ioaddr + CSR12));
+			   dev->name, ioread32(ioaddr + CSR5), ioread32(ioaddr + CSR12));
 		dev->if_port = 0;
 	}
 
@@ -576,7 +576,7 @@
 
 	tulip_restart_rxtx(tp);
 	/* Trigger an immediate transmit demand. */
-	outl(0, ioaddr + CSR1);
+	iowrite32(0, ioaddr + CSR1);
 
 	tp->stats.tx_errors++;
 
@@ -678,7 +678,7 @@
 	tp->cur_tx++;
 
 	/* Trigger an immediate transmit demand. */
-	outl(0, dev->base_addr + CSR1);
+	iowrite32(0, tp->base_addr + CSR1);
 
 	spin_unlock_irq(&tp->lock);
 
@@ -725,8 +725,8 @@
 
 static void tulip_down (struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
 	struct tulip_private *tp = netdev_priv(dev);
+	void __iomem *ioaddr = tp->base_addr;
 	unsigned long flags;
 
 	del_timer_sync (&tp->timer);
@@ -736,7 +736,7 @@
 	spin_lock_irqsave (&tp->lock, flags);
 
 	/* Disable interrupts by clearing the interrupt mask. */
-	outl (0x00000000, ioaddr + CSR7);
+	iowrite32 (0x00000000, ioaddr + CSR7);
 
 	/* Stop the Tx and Rx processes. */
 	tulip_stop_rxtx(tp);
@@ -747,8 +747,8 @@
 	/* release any unconsumed transmit buffers */
 	tulip_clean_tx_ring(tp);
 
-	if (inl (ioaddr + CSR6) != 0xffffffff)
-		tp->stats.rx_missed_errors += inl (ioaddr + CSR8) & 0xffff;
+	if (ioread32 (ioaddr + CSR6) != 0xffffffff)
+		tp->stats.rx_missed_errors += ioread32 (ioaddr + CSR8) & 0xffff;
 
 	spin_unlock_irqrestore (&tp->lock, flags);
 
@@ -765,8 +765,8 @@
 
 static int tulip_close (struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
 	struct tulip_private *tp = netdev_priv(dev);
+	void __iomem *ioaddr = tp->base_addr;
 	int i;
 
 	netif_stop_queue (dev);
@@ -775,7 +775,7 @@
 
 	if (tulip_debug > 1)
 		printk (KERN_DEBUG "%s: Shutting down ethercard, status was %2.2x.\n",
-			dev->name, inl (ioaddr + CSR5));
+			dev->name, ioread32 (ioaddr + CSR5));
 
 	free_irq (dev->irq, dev);
 
@@ -814,14 +814,14 @@
 static struct net_device_stats *tulip_get_stats(struct net_device *dev)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 
 	if (netif_running(dev)) {
 		unsigned long flags;
 
 		spin_lock_irqsave (&tp->lock, flags);
 
-		tp->stats.rx_missed_errors += inl(ioaddr + CSR8) & 0xffff;
+		tp->stats.rx_missed_errors += ioread32(ioaddr + CSR8) & 0xffff;
 
 		spin_unlock_irqrestore(&tp->lock, flags);
 	}
@@ -830,44 +830,29 @@
 }
 
 
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void tulip_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
 	struct tulip_private *np = netdev_priv(dev);
-	u32 ethcmd;
-
-	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-		return -EFAULT;
-
-        switch (ethcmd) {
-        case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-		strcpy(info.driver, DRV_NAME);
-		strcpy(info.version, DRV_VERSION);
-		strcpy(info.bus_info, pci_name(np->pdev));
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-
-        }
-
-	return -EOPNOTSUPP;
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+	strcpy(info->bus_info, pci_name(np->pdev));
 }
 
+static struct ethtool_ops ops = {
+	.get_drvinfo = tulip_get_drvinfo
+};
+
 /* Provide ioctl() calls to examine the MII xcvr state. */
 static int private_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	struct mii_ioctl_data *data = if_mii(rq);
 	const unsigned int phy_idx = 0;
 	int phy = tp->phys[phy_idx] & 0x1f;
 	unsigned int regnum = data->reg_num;
 
 	switch (cmd) {
-	case SIOCETHTOOL:
-		return netdev_ethtool_ioctl(dev, rq->ifr_data);
-
 	case SIOCGMIIPHY:		/* Get address of MII PHY in use. */
 		if (tp->mii_cnt)
 			data->phy_id = phy;
@@ -880,8 +865,8 @@
 
 	case SIOCGMIIREG:		/* Read MII PHY register. */
 		if (data->phy_id == 32 && (tp->flags & HAS_NWAY)) {
-			int csr12 = inl (ioaddr + CSR12);
-			int csr14 = inl (ioaddr + CSR14);
+			int csr12 = ioread32 (ioaddr + CSR12);
+			int csr14 = ioread32 (ioaddr + CSR14);
 			switch (regnum) {
 			case 0:
                                 if (((csr14<<5) & 0x1000) ||
@@ -901,7 +886,7 @@
 			case 4:
                                 /* Advertised value, bogus 10baseTx-FD value from CSR6. */
                                 data->val_out =
-					((inl(ioaddr + CSR6) >> 3) & 0x0040) +
+					((ioread32(ioaddr + CSR6) >> 3) & 0x0040) +
 					((csr14 >> 1) & 0x20) + 1;
                                 data->val_out |= ((csr14 >> 9) & 0x03C0);
 				break;
@@ -1026,10 +1011,10 @@
 static void set_rx_mode(struct net_device *dev)
 {
 	struct tulip_private *tp = netdev_priv(dev);
-	long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = tp->base_addr;
 	int csr6;
 
-	csr6 = inl(ioaddr + CSR6) & ~0x00D5;
+	csr6 = ioread32(ioaddr + CSR6) & ~0x00D5;
 
 	tp->csr6 &= ~0x00D5;
 	if (dev->flags & IFF_PROMISC) {			/* Set promiscuous. */
@@ -1073,13 +1058,13 @@
 				mc_filter[1] == tp->mc_filter[1])
 				;				/* No change. */
 			else if (tp->flags & IS_ASIX) {
-				outl(2, ioaddr + CSR13);
-				outl(mc_filter[0], ioaddr + CSR14);
-				outl(3, ioaddr + CSR13);
-				outl(mc_filter[1], ioaddr + CSR14);
+				iowrite32(2, ioaddr + CSR13);
+				iowrite32(mc_filter[0], ioaddr + CSR14);
+				iowrite32(3, ioaddr + CSR13);
+				iowrite32(mc_filter[1], ioaddr + CSR14);
 			} else if (tp->flags & COMET_MAC_ADDR) {
-				outl(mc_filter[0], ioaddr + 0xAC);
-				outl(mc_filter[1], ioaddr + 0xB0);
+				iowrite32(mc_filter[0], ioaddr + 0xAC);
+				iowrite32(mc_filter[1], ioaddr + 0xB0);
 			}
 			tp->mc_filter[0] = mc_filter[0];
 			tp->mc_filter[1] = mc_filter[1];
@@ -1139,13 +1124,13 @@
 				netif_stop_queue(dev);
 
 			/* Trigger an immediate transmit demand. */
-			outl(0, ioaddr + CSR1);
+			iowrite32(0, ioaddr + CSR1);
 		}
 
 		spin_unlock_irqrestore(&tp->lock, flags);
 	}
 
-	outl(csr6, ioaddr + CSR6);
+	iowrite32(csr6, ioaddr + CSR6);
 }
 
 #ifdef CONFIG_TULIP_MWI
@@ -1236,6 +1221,11 @@
 	struct tulip_private *tp;
 	/* See note below on the multiport cards. */
 	static unsigned char last_phys_addr[6] = {0x00, 'L', 'i', 'n', 'u', 'x'};
+	static struct pci_device_id early_486_chipsets[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82424) },
+		{ PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496) },
+		{ },
+	};
 	static int last_irq;
 	static int multiport_cnt;	/* For four-port boards w/one EEPROM */
 	u8 chip_rev;
@@ -1243,7 +1233,7 @@
 	unsigned short sum;
 	unsigned char *ee_data;
 	struct net_device *dev;
-	long ioaddr;
+	void __iomem *ioaddr;
 	static int board_idx = -1;
 	int chip_idx = ent->driver_data;
 	const char *chip_name = tulip_tbl[chip_idx].chip_name;
@@ -1289,17 +1279,15 @@
 	 *	without the workarounds being on.
 	 */
 
-	/* Intel Saturn. Switch to 8 long words burst, 8 long word cache aligned
-	   Aries might need this too. The Saturn errata are not pretty reading but
-	   thankfully it's an old 486 chipset.
+	/* 1. Intel Saturn. Switch to 8 long words burst, 8 long word cache
+	      aligned.  Aries might need this too. The Saturn errata are not 
+	      pretty reading but thankfully it's an old 486 chipset.
+
+	   2. The dreaded SiS496 486 chipset. Same workaround as Intel
+	      Saturn.
 	*/
 
-	if (pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82424, NULL)) {
-		csr0 = MRL | MRM | (8 << BurstLenShift) | (1 << CALShift);
-		force_csr0 = 1;
-	}
-	/* The dreaded SiS496 486 chipset. Same workaround as above. */
-	if (pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496, NULL)) {
+	if (pci_dev_present(early_486_chipsets)) {
 		csr0 = MRL | MRM | (8 << BurstLenShift) | (1 << CALShift);
 		force_csr0 = 1;
 	}
@@ -1338,7 +1326,6 @@
 		return i;
 	}
 
-	ioaddr = pci_resource_start (pdev, 0);
 	irq = pdev->irq;
 
 	/* alloc_etherdev ensures aligned and zeroed private structures */
@@ -1364,11 +1351,12 @@
 		goto err_out_free_netdev;
 
 #ifndef USE_IO_OPS
-	ioaddr = (unsigned long) ioremap (pci_resource_start (pdev, 1),
-					  tulip_tbl[chip_idx].io_size);
+	ioaddr =  pci_iomap(pdev, 1, tulip_tbl[chip_idx].io_size);
+#else
+	ioaddr =  pci_iomap(pdev, 0, tulip_tbl[chip_idx].io_size);
+#endif
 	if (!ioaddr)
 		goto err_out_free_res;
-#endif
 
 	pci_read_config_byte (pdev, PCI_REVISION_ID, &chip_rev);
 
@@ -1399,7 +1387,7 @@
 	tp->timer.data = (unsigned long)dev;
 	tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
 
-	dev->base_addr = ioaddr;
+	dev->base_addr = (unsigned long)ioaddr;
 
 #ifdef CONFIG_TULIP_MWI
 	if (!force_csr0 && (tp->flags & HAS_PCI_MWI))
@@ -1433,7 +1421,7 @@
 #endif
 
 	/* Clear the missed-packet counter. */
-	inl(ioaddr + CSR8);
+	ioread32(ioaddr + CSR8);
 
 	/* The station address ROM is read byte serially.  The register must
 	   be polled, waiting for the value to be read bit serially from the
@@ -1444,17 +1432,17 @@
 	if (chip_idx == LC82C168) {
 		for (i = 0; i < 3; i++) {
 			int value, boguscnt = 100000;
-			outl(0x600 | i, ioaddr + 0x98);
+			iowrite32(0x600 | i, ioaddr + 0x98);
 			do
-				value = inl(ioaddr + CSR9);
+				value = ioread32(ioaddr + CSR9);
 			while (value < 0  && --boguscnt > 0);
 			put_unaligned(le16_to_cpu(value), ((u16*)dev->dev_addr) + i);
 			sum += value & 0xffff;
 		}
 	} else if (chip_idx == COMET) {
 		/* No need to read the EEPROM. */
-		put_unaligned(cpu_to_le32(inl(ioaddr + 0xA4)), (u32 *)dev->dev_addr);
-		put_unaligned(cpu_to_le16(inl(ioaddr + 0xA8)), (u16 *)(dev->dev_addr + 4));
+		put_unaligned(cpu_to_le32(ioread32(ioaddr + 0xA4)), (u32 *)dev->dev_addr);
+		put_unaligned(cpu_to_le16(ioread32(ioaddr + 0xA8)), (u16 *)(dev->dev_addr + 4));
 		for (i = 0; i < 6; i ++)
 			sum += dev->dev_addr[i];
 	} else {
@@ -1644,11 +1632,12 @@
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	dev->poll_controller = &poll_tulip;
 #endif
+	SET_ETHTOOL_OPS(dev, &ops);
 
 	if (register_netdev(dev))
 		goto err_out_free_ring;
 
-	printk(KERN_INFO "%s: %s rev %d at %#3lx,",
+	printk(KERN_INFO "%s: %s rev %d at %p,",
 	       dev->name, chip_name, chip_rev, ioaddr);
 	pci_set_drvdata(pdev, dev);
 
@@ -1671,43 +1660,43 @@
 	case DM910X:
 	default:
 		if (tp->mtable)
-			outl(tp->mtable->csr12dir | 0x100, ioaddr + CSR12);
+			iowrite32(tp->mtable->csr12dir | 0x100, ioaddr + CSR12);
 		break;
 	case DC21142:
 		if (tp->mii_cnt  ||  tulip_media_cap[dev->if_port] & MediaIsMII) {
-			outl(csr6_mask_defstate, ioaddr + CSR6);
-			outl(0x0000, ioaddr + CSR13);
-			outl(0x0000, ioaddr + CSR14);
-			outl(csr6_mask_hdcap, ioaddr + CSR6);
+			iowrite32(csr6_mask_defstate, ioaddr + CSR6);
+			iowrite32(0x0000, ioaddr + CSR13);
+			iowrite32(0x0000, ioaddr + CSR14);
+			iowrite32(csr6_mask_hdcap, ioaddr + CSR6);
 		} else
 			t21142_start_nway(dev);
 		break;
 	case PNIC2:
 	        /* just do a reset for sanity sake */
-		outl(0x0000, ioaddr + CSR13);
-		outl(0x0000, ioaddr + CSR14);
+		iowrite32(0x0000, ioaddr + CSR13);
+		iowrite32(0x0000, ioaddr + CSR14);
 		break;
 	case LC82C168:
 		if ( ! tp->mii_cnt) {
 			tp->nway = 1;
 			tp->nwayset = 0;
-			outl(csr6_ttm | csr6_ca, ioaddr + CSR6);
-			outl(0x30, ioaddr + CSR12);
-			outl(0x0001F078, ioaddr + CSR6);
-			outl(0x0201F078, ioaddr + CSR6); /* Turn on autonegotiation. */
+			iowrite32(csr6_ttm | csr6_ca, ioaddr + CSR6);
+			iowrite32(0x30, ioaddr + CSR12);
+			iowrite32(0x0001F078, ioaddr + CSR6);
+			iowrite32(0x0201F078, ioaddr + CSR6); /* Turn on autonegotiation. */
 		}
 		break;
 	case MX98713:
 	case COMPEX9881:
-		outl(0x00000000, ioaddr + CSR6);
-		outl(0x000711C0, ioaddr + CSR14); /* Turn on NWay. */
-		outl(0x00000001, ioaddr + CSR13);
+		iowrite32(0x00000000, ioaddr + CSR6);
+		iowrite32(0x000711C0, ioaddr + CSR14); /* Turn on NWay. */
+		iowrite32(0x00000001, ioaddr + CSR13);
 		break;
 	case MX98715:
 	case MX98725:
-		outl(0x01a80000, ioaddr + CSR6);
-		outl(0xFFFFFFFF, ioaddr + CSR14);
-		outl(0x00001000, ioaddr + CSR12);
+		iowrite32(0x01a80000, ioaddr + CSR6);
+		iowrite32(0xFFFFFFFF, ioaddr + CSR14);
+		iowrite32(0x00001000, ioaddr + CSR12);
 		break;
 	case COMET:
 		/* No initialization necessary. */
@@ -1728,11 +1717,9 @@
 err_out_mtable:
 	if (tp->mtable)
 		kfree (tp->mtable);
-#ifndef USE_IO_OPS
-	iounmap((void *)ioaddr);
+	pci_iounmap(pdev, ioaddr);
 
 err_out_free_res:
-#endif
 	pci_release_regions (pdev);
 
 err_out_free_netdev:
@@ -1790,9 +1777,7 @@
 			     tp->rx_ring, tp->rx_ring_dma);
 	if (tp->mtable)
 		kfree (tp->mtable);
-#ifndef USE_IO_OPS
-	iounmap((void *)dev->base_addr);
-#endif
+	pci_iounmap(pdev, tp->base_addr);
 	free_netdev (dev);
 	pci_release_regions (pdev);
 	pci_set_drvdata (pdev, NULL);
diff -Nru a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
--- a/drivers/net/tulip/winbond-840.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/net/tulip/winbond-840.c	2004-12-24 13:36:30 -08:00
@@ -130,9 +130,9 @@
 #include <linux/mii.h>
 #include <linux/rtnetlink.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/processor.h>		/* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
@@ -258,21 +258,6 @@
    work only with I/O space accesses.  Pass -DUSE_IO_OPS to use PCI I/O space
    accesses instead of memory space. */
 
-#ifdef USE_IO_OPS
-#undef readb
-#undef readw
-#undef readl
-#undef writeb
-#undef writew
-#undef writel
-#define readb inb
-#define readw inw
-#define readl inl
-#define writeb outb
-#define writew outw
-#define writel outl
-#endif
-
 /* Offsets to the Command and Status Registers, "CSRs".
    While similar to the Tulip, these registers are longword aligned.
    Note: It's not useful to define symbolic names for every register bit in
@@ -361,9 +346,10 @@
 	unsigned char phys[MII_CNT];		/* MII device addresses, but only the first is used */
 	u32 mii;
 	struct mii_if_info mii_if;
+	void __iomem *base_addr;
 };
 
-static int  eeprom_read(long ioaddr, int location);
+static int  eeprom_read(void __iomem *ioaddr, int location);
 static int  mdio_read(struct net_device *dev, int phy_id, int location);
 static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
 static int  netdev_open(struct net_device *dev);
@@ -397,7 +383,8 @@
 	int chip_idx = ent->driver_data;
 	int irq;
 	int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
-	long ioaddr;
+	void __iomem *ioaddr;
+	int bar = 1;
 
 	i = pci_enable_device(pdev);
 	if (i) return i;
@@ -419,27 +406,24 @@
 
 	if (pci_request_regions(pdev, DRV_NAME))
 		goto err_out_netdev;
-
 #ifdef USE_IO_OPS
-	ioaddr = pci_resource_start(pdev, 0);
-#else
-	ioaddr = pci_resource_start(pdev, 1);
-	ioaddr = (long) ioremap (ioaddr, pci_id_tbl[chip_idx].io_size);
+	bar = 0;
+#endif
+	ioaddr = pci_iomap(pdev, bar, pci_id_tbl[chip_idx].io_size);
 	if (!ioaddr)
 		goto err_out_free_res;
-#endif
 
 	for (i = 0; i < 3; i++)
 		((u16 *)dev->dev_addr)[i] = le16_to_cpu(eeprom_read(ioaddr, i));
 
 	/* Reset the chip to erase previous misconfiguration.
 	   No hold time required! */
-	writel(0x00000001, ioaddr + PCIBusCfg);
+	iowrite32(0x00000001, ioaddr + PCIBusCfg);
 
-	dev->base_addr = ioaddr;
+	dev->base_addr = (unsigned long)ioaddr;
 	dev->irq = irq;
 
-	np = dev->priv;
+	np = netdev_priv(dev);
 	np->pci_dev = pdev;
 	np->chip_id = chip_idx;
 	np->drv_flags = pci_id_tbl[chip_idx].drv_flags;
@@ -447,6 +431,7 @@
 	np->mii_if.dev = dev;
 	np->mii_if.mdio_read = mdio_read;
 	np->mii_if.mdio_write = mdio_write;
+	np->base_addr = ioaddr;
 	
 	pci_set_drvdata(pdev, dev);
 
@@ -482,7 +467,7 @@
 	if (i)
 		goto err_out_cleardev;
 
-	printk(KERN_INFO "%s: %s at 0x%lx, ",
+	printk(KERN_INFO "%s: %s at %p, ",
 		   dev->name, pci_id_tbl[chip_idx].name, ioaddr);
 	for (i = 0; i < 5; i++)
 			printk("%2.2x:", dev->dev_addr[i]);
@@ -515,10 +500,8 @@
 
 err_out_cleardev:
 	pci_set_drvdata(pdev, NULL);
-#ifndef USE_IO_OPS
-	iounmap((void *)ioaddr);
+	pci_iounmap(pdev, ioaddr);
 err_out_free_res:
-#endif
 	pci_release_regions(pdev);
 err_out_netdev:
 	free_netdev (dev);
@@ -537,7 +520,7 @@
    The old method of using an ISA access as a delay, __SLOW_DOWN_IO__, is
    depricated.
 */
-#define eeprom_delay(ee_addr)	readl(ee_addr)
+#define eeprom_delay(ee_addr)	ioread32(ee_addr)
 
 enum EEPROM_Ctrl_Bits {
 	EE_ShiftClk=0x02, EE_Write0=0x801, EE_Write1=0x805,
@@ -549,35 +532,35 @@
 	EE_WriteCmd=(5 << 6), EE_ReadCmd=(6 << 6), EE_EraseCmd=(7 << 6),
 };
 
-static int eeprom_read(long addr, int location)
+static int eeprom_read(void __iomem *addr, int location)
 {
 	int i;
 	int retval = 0;
-	long ee_addr = addr + EECtrl;
+	void __iomem *ee_addr = addr + EECtrl;
 	int read_cmd = location | EE_ReadCmd;
-	writel(EE_ChipSelect, ee_addr);
+	iowrite32(EE_ChipSelect, ee_addr);
 
 	/* Shift the read command bits out. */
 	for (i = 10; i >= 0; i--) {
 		short dataval = (read_cmd & (1 << i)) ? EE_Write1 : EE_Write0;
-		writel(dataval, ee_addr);
+		iowrite32(dataval, ee_addr);
 		eeprom_delay(ee_addr);
-		writel(dataval | EE_ShiftClk, ee_addr);
+		iowrite32(dataval | EE_ShiftClk, ee_addr);
 		eeprom_delay(ee_addr);
 	}
-	writel(EE_ChipSelect, ee_addr);
+	iowrite32(EE_ChipSelect, ee_addr);
 	eeprom_delay(ee_addr);
 
 	for (i = 16; i > 0; i--) {
-		writel(EE_ChipSelect | EE_ShiftClk, ee_addr);
+		iowrite32(EE_ChipSelect | EE_ShiftClk, ee_addr);
 		eeprom_delay(ee_addr);
-		retval = (retval << 1) | ((readl(ee_addr) & EE_DataIn) ? 1 : 0);
-		writel(EE_ChipSelect, ee_addr);
+		retval = (retval << 1) | ((ioread32(ee_addr) & EE_DataIn) ? 1 : 0);
+		iowrite32(EE_ChipSelect, ee_addr);
 		eeprom_delay(ee_addr);
 	}
 
 	/* Terminate the EEPROM access. */
-	writel(0, ee_addr);
+	iowrite32(0, ee_addr);
 	return retval;
 }
 
@@ -588,7 +571,7 @@
 
 	The maximum data clock rate is 2.5 Mhz.  The minimum timing is usually
 	met by back-to-back 33Mhz PCI cycles. */
-#define mdio_delay(mdio_addr) readl(mdio_addr)
+#define mdio_delay(mdio_addr) ioread32(mdio_addr)
 
 /* Set iff a MII transceiver on any interface requires mdio preamble.
    This only set with older transceivers, so the extra
@@ -600,22 +583,23 @@
 
 /* Generate the preamble required for initial synchronization and
    a few older transceivers. */
-static void mdio_sync(long mdio_addr)
+static void mdio_sync(void __iomem *mdio_addr)
 {
 	int bits = 32;
 
 	/* Establish sync by sending at least 32 logic ones. */
 	while (--bits >= 0) {
-		writel(MDIO_WRITE1, mdio_addr);
+		iowrite32(MDIO_WRITE1, mdio_addr);
 		mdio_delay(mdio_addr);
-		writel(MDIO_WRITE1 | MDIO_ShiftClk, mdio_addr);
+		iowrite32(MDIO_WRITE1 | MDIO_ShiftClk, mdio_addr);
 		mdio_delay(mdio_addr);
 	}
 }
 
 static int mdio_read(struct net_device *dev, int phy_id, int location)
 {
-	long mdio_addr = dev->base_addr + MIICtrl;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *mdio_addr = np->base_addr + MIICtrl;
 	int mii_cmd = (0xf6 << 10) | (phy_id << 5) | location;
 	int i, retval = 0;
 
@@ -626,17 +610,17 @@
 	for (i = 15; i >= 0; i--) {
 		int dataval = (mii_cmd & (1 << i)) ? MDIO_WRITE1 : MDIO_WRITE0;
 
-		writel(dataval, mdio_addr);
+		iowrite32(dataval, mdio_addr);
 		mdio_delay(mdio_addr);
-		writel(dataval | MDIO_ShiftClk, mdio_addr);
+		iowrite32(dataval | MDIO_ShiftClk, mdio_addr);
 		mdio_delay(mdio_addr);
 	}
 	/* Read the two transition, 16 data, and wire-idle bits. */
 	for (i = 20; i > 0; i--) {
-		writel(MDIO_EnbIn, mdio_addr);
+		iowrite32(MDIO_EnbIn, mdio_addr);
 		mdio_delay(mdio_addr);
-		retval = (retval << 1) | ((readl(mdio_addr) & MDIO_DataIn) ? 1 : 0);
-		writel(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
+		retval = (retval << 1) | ((ioread32(mdio_addr) & MDIO_DataIn) ? 1 : 0);
+		iowrite32(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
 		mdio_delay(mdio_addr);
 	}
 	return (retval>>1) & 0xffff;
@@ -644,8 +628,8 @@
 
 static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
 {
-	struct netdev_private *np = dev->priv;
-	long mdio_addr = dev->base_addr + MIICtrl;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *mdio_addr = np->base_addr + MIICtrl;
 	int mii_cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
 	int i;
 
@@ -659,16 +643,16 @@
 	for (i = 31; i >= 0; i--) {
 		int dataval = (mii_cmd & (1 << i)) ? MDIO_WRITE1 : MDIO_WRITE0;
 
-		writel(dataval, mdio_addr);
+		iowrite32(dataval, mdio_addr);
 		mdio_delay(mdio_addr);
-		writel(dataval | MDIO_ShiftClk, mdio_addr);
+		iowrite32(dataval | MDIO_ShiftClk, mdio_addr);
 		mdio_delay(mdio_addr);
 	}
 	/* Clear out extra bits. */
 	for (i = 2; i > 0; i--) {
-		writel(MDIO_EnbIn, mdio_addr);
+		iowrite32(MDIO_EnbIn, mdio_addr);
 		mdio_delay(mdio_addr);
-		writel(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
+		iowrite32(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
 		mdio_delay(mdio_addr);
 	}
 	return;
@@ -677,11 +661,11 @@
 
 static int netdev_open(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 	int i;
 
-	writel(0x00000001, ioaddr + PCIBusCfg);		/* Reset */
+	iowrite32(0x00000001, ioaddr + PCIBusCfg);		/* Reset */
 
 	netif_device_detach(dev);
 	i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev);
@@ -720,7 +704,7 @@
 
 static int update_link(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int duplex, fasteth, result, mii_reg;
 
 	/* BSMR */
@@ -783,8 +767,8 @@
 #define RXTX_TIMEOUT	2000
 static inline void update_csr6(struct net_device *dev, int new)
 {
-	struct netdev_private *np = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 	int limit = RXTX_TIMEOUT;
 
 	if (!netif_device_present(dev))
@@ -792,10 +776,10 @@
 	if (new==np->csr6)
 		return;
 	/* stop both Tx and Rx processes */
-	writel(np->csr6 & ~0x2002, ioaddr + NetworkConfig);
+	iowrite32(np->csr6 & ~0x2002, ioaddr + NetworkConfig);
 	/* wait until they have really stopped */
 	for (;;) {
-		int csr5 = readl(ioaddr + IntrStatus);
+		int csr5 = ioread32(ioaddr + IntrStatus);
 		int t;
 
 		t = (csr5 >> 17) & 0x07;
@@ -816,7 +800,7 @@
 	}
 	np->csr6 = new;
 	/* and restart them with the new configuration */
-	writel(np->csr6, ioaddr + NetworkConfig);
+	iowrite32(np->csr6, ioaddr + NetworkConfig);
 	if (new & 0x200)
 		np->mii_if.full_duplex = 1;
 }
@@ -824,14 +808,14 @@
 static void netdev_timer(unsigned long data)
 {
 	struct net_device *dev = (struct net_device *)data;
-	struct netdev_private *np = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 
 	if (debug > 2)
 		printk(KERN_DEBUG "%s: Media selection timer tick, status %8.8x "
 			   "config %8.8x.\n",
-			   dev->name, (int)readl(ioaddr + IntrStatus),
-			   (int)readl(ioaddr + NetworkConfig));
+			   dev->name, ioread32(ioaddr + IntrStatus),
+			   ioread32(ioaddr + NetworkConfig));
 	spin_lock_irq(&np->lock);
 	update_csr6(dev, update_link(dev));
 	spin_unlock_irq(&np->lock);
@@ -841,7 +825,7 @@
 
 static void init_rxtx_rings(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int i;
 
 	np->rx_head_desc = &np->rx_ring[0];
@@ -881,9 +865,9 @@
 	np->tx_full = 0;
 	np->tx_q_bytes = np->dirty_tx = np->cur_tx = 0;
 
-	writel(np->ring_dma_addr, dev->base_addr + RxRingPtr);
-	writel(np->ring_dma_addr+sizeof(struct w840_rx_desc)*RX_RING_SIZE,
-		dev->base_addr + TxRingPtr);
+	iowrite32(np->ring_dma_addr, np->base_addr + RxRingPtr);
+	iowrite32(np->ring_dma_addr+sizeof(struct w840_rx_desc)*RX_RING_SIZE,
+		np->base_addr + TxRingPtr);
 
 }
 
@@ -916,12 +900,12 @@
 
 static void init_registers(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 	int i;
 
 	for (i = 0; i < 6; i++)
-		writeb(dev->dev_addr[i], ioaddr + StationAddr + i);
+		iowrite8(dev->dev_addr[i], ioaddr + StationAddr + i);
 
 	/* Initialize other registers. */
 #ifdef __BIG_ENDIAN
@@ -958,7 +942,7 @@
 #warning Processor architecture undefined
 	i |= 0x4800;
 #endif
-	writel(i, ioaddr + PCIBusCfg);
+	iowrite32(i, ioaddr + PCIBusCfg);
 
 	np->csr6 = 0;
 	/* 128 byte Tx threshold; 
@@ -966,19 +950,19 @@
 	update_csr6(dev, 0x00022002 | update_link(dev) | __set_rx_mode(dev));
 
 	/* Clear and Enable interrupts by setting the interrupt mask. */
-	writel(0x1A0F5, ioaddr + IntrStatus);
-	writel(0x1A0F5, ioaddr + IntrEnable);
+	iowrite32(0x1A0F5, ioaddr + IntrStatus);
+	iowrite32(0x1A0F5, ioaddr + IntrEnable);
 
-	writel(0, ioaddr + RxStartDemand);
+	iowrite32(0, ioaddr + RxStartDemand);
 }
 
 static void tx_timeout(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 
 	printk(KERN_WARNING "%s: Transmit timed out, status %8.8x,"
-		   " resetting...\n", dev->name, (int)readl(ioaddr + IntrStatus));
+		   " resetting...\n", dev->name, ioread32(ioaddr + IntrStatus));
 
 	{
 		int i;
@@ -992,7 +976,7 @@
 	}
 	printk(KERN_DEBUG "Tx cur %d Tx dirty %d Tx Full %d, q bytes %d.\n",
 				np->cur_tx, np->dirty_tx, np->tx_full, np->tx_q_bytes);
-	printk(KERN_DEBUG "Tx Descriptor addr %xh.\n",readl(ioaddr+0x4C));
+	printk(KERN_DEBUG "Tx Descriptor addr %xh.\n",ioread32(ioaddr+0x4C));
 
 	disable_irq(dev->irq);
 	spin_lock_irq(&np->lock);
@@ -1002,7 +986,7 @@
 	 * everything.
 	 */
 
-	writel(1, dev->base_addr+PCIBusCfg);
+	iowrite32(1, np->base_addr+PCIBusCfg);
 	udelay(1);
 
 	free_rxtx_rings(np);
@@ -1020,7 +1004,7 @@
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
 static int alloc_ringdesc(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	np->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32);
 
@@ -1045,7 +1029,7 @@
 
 static int start_tx(struct sk_buff *skb, struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	unsigned entry;
 
 	/* Caution: the write order is important here, set the field
@@ -1086,7 +1070,7 @@
 	wmb(); /* flush length, buffer1, buffer2 */
 	np->tx_ring[entry].status = DescOwn;
 	wmb(); /* flush status and kick the hardware */
-	writel(0, dev->base_addr + TxStartDemand);
+	iowrite32(0, np->base_addr + TxStartDemand);
 	np->tx_q_bytes += skb->len;
 	/* Work around horrible bug in the chip by marking the queue as full
 	   when we do not have FIFO room for a maximum sized packet. */
@@ -1109,7 +1093,7 @@
 
 static void netdev_tx_done(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) {
 		int entry = np->dirty_tx % TX_RING_SIZE;
 		int tx_status = np->tx_ring[entry].status;
@@ -1162,18 +1146,18 @@
 static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
 {
 	struct net_device *dev = (struct net_device *)dev_instance;
-	struct netdev_private *np = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 	int work_limit = max_interrupt_work;
 	int handled = 0;
 
 	if (!netif_device_present(dev))
 		return IRQ_NONE;
 	do {
-		u32 intr_status = readl(ioaddr + IntrStatus);
+		u32 intr_status = ioread32(ioaddr + IntrStatus);
 
 		/* Acknowledge all of the current interrupt sources ASAP. */
-		writel(intr_status & 0x001ffff, ioaddr + IntrStatus);
+		iowrite32(intr_status & 0x001ffff, ioaddr + IntrStatus);
 
 		if (debug > 4)
 			printk(KERN_DEBUG "%s: Interrupt, status %4.4x.\n",
@@ -1187,7 +1171,7 @@
 		if (intr_status & (IntrRxDone | RxNoBuf))
 			netdev_rx(dev);
 		if (intr_status & RxNoBuf)
-			writel(0, ioaddr + RxStartDemand);
+			iowrite32(0, ioaddr + RxStartDemand);
 
 		if (intr_status & (TxIdle | IntrTxDone) &&
 			np->cur_tx != np->dirty_tx) {
@@ -1208,8 +1192,8 @@
 			   10*82usec ticks. */
 			spin_lock(&np->lock);
 			if (netif_device_present(dev)) {
-				writel(AbnormalIntr | TimerInt, ioaddr + IntrEnable);
-				writel(10, ioaddr + GPTimer);
+				iowrite32(AbnormalIntr | TimerInt, ioaddr + IntrEnable);
+				iowrite32(10, ioaddr + GPTimer);
 			}
 			spin_unlock(&np->lock);
 			break;
@@ -1218,7 +1202,7 @@
 
 	if (debug > 3)
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
-			   dev->name, (int)readl(ioaddr + IntrStatus));
+			   dev->name, ioread32(ioaddr + IntrStatus));
 	return IRQ_RETVAL(handled);
 }
 
@@ -1226,7 +1210,7 @@
    for clarity and better register allocation. */
 static int netdev_rx(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int entry = np->cur_rx % RX_RING_SIZE;
 	int work_limit = np->dirty_rx + RX_RING_SIZE - np->cur_rx;
 
@@ -1342,8 +1326,8 @@
 
 static void netdev_error(struct net_device *dev, int intr_status)
 {
-	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 
 	if (debug > 2)
 		printk(KERN_DEBUG "%s: Abnormal event, %8.8x.\n",
@@ -1377,22 +1361,22 @@
 	if (intr_status & TimerInt) {
 		/* Re-enable other interrupts. */
 		if (netif_device_present(dev))
-			writel(0x1A0F5, ioaddr + IntrEnable);
+			iowrite32(0x1A0F5, ioaddr + IntrEnable);
 	}
-	np->stats.rx_missed_errors += readl(ioaddr + RxMissed) & 0xffff;
-	writel(0, ioaddr + RxStartDemand);
+	np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
+	iowrite32(0, ioaddr + RxStartDemand);
 	spin_unlock(&np->lock);
 }
 
 static struct net_device_stats *get_stats(struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 
 	/* The chip only need report frame silently dropped. */
 	spin_lock_irq(&np->lock);
 	if (netif_running(dev) && netif_device_present(dev))
-		np->stats.rx_missed_errors += readl(ioaddr + RxMissed) & 0xffff;
+		np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
 	spin_unlock_irq(&np->lock);
 
 	return &np->stats;
@@ -1401,7 +1385,8 @@
 
 static u32 __set_rx_mode(struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 	u32 mc_filter[2];			/* Multicast hash filter */
 	u32 rx_mode;
 
@@ -1428,14 +1413,14 @@
 		}
 		rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
 	}
-	writel(mc_filter[0], ioaddr + MulticastFilter0);
-	writel(mc_filter[1], ioaddr + MulticastFilter1);
+	iowrite32(mc_filter[0], ioaddr + MulticastFilter0);
+	iowrite32(mc_filter[1], ioaddr + MulticastFilter1);
 	return rx_mode;
 }
 
 static void set_rx_mode(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	u32 rx_mode = __set_rx_mode(dev);
 	spin_lock_irq(&np->lock);
 	update_csr6(dev, (np->csr6 & ~0x00F8) | rx_mode);
@@ -1444,7 +1429,7 @@
 
 static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	strcpy (info->driver, DRV_NAME);
 	strcpy (info->version, DRV_VERSION);
@@ -1453,7 +1438,7 @@
 
 static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int rc;
 
 	spin_lock_irq(&np->lock);
@@ -1465,7 +1450,7 @@
 
 static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	int rc;
 
 	spin_lock_irq(&np->lock);
@@ -1477,13 +1462,13 @@
 
 static int netdev_nway_reset(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	return mii_nway_restart(&np->mii_if);
 }
 
 static u32 netdev_get_link(struct net_device *dev)
 {
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 	return mii_link_ok(&np->mii_if);
 }
 
@@ -1516,7 +1501,7 @@
 
 	switch(cmd) {
 	case SIOCGMIIPHY:		/* Get address of MII PHY in use. */
-		data->phy_id = ((struct netdev_private *)dev->priv)->phys[0] & 0x1f;
+		data->phy_id = ((struct netdev_private *)netdev_priv(dev))->phys[0] & 0x1f;
 		/* Fall Through */
 
 	case SIOCGMIIREG:		/* Read MII PHY register. */
@@ -1539,15 +1524,15 @@
 
 static int netdev_close(struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 
 	netif_stop_queue(dev);
 
 	if (debug > 1) {
 		printk(KERN_DEBUG "%s: Shutting down ethercard, status was %8.8x "
-			   "Config %8.8x.\n", dev->name, (int)readl(ioaddr + IntrStatus),
-			   (int)readl(ioaddr + NetworkConfig));
+			   "Config %8.8x.\n", dev->name, ioread32(ioaddr + IntrStatus),
+			   ioread32(ioaddr + NetworkConfig));
 		printk(KERN_DEBUG "%s: Queue pointers were Tx %d / %d,  Rx %d / %d.\n",
 			   dev->name, np->cur_tx, np->dirty_tx, np->cur_rx, np->dirty_rx);
 	}
@@ -1556,15 +1541,15 @@
 	spin_lock_irq(&np->lock);
 	netif_device_detach(dev);
 	update_csr6(dev, 0);
-	writel(0x0000, ioaddr + IntrEnable);
+	iowrite32(0x0000, ioaddr + IntrEnable);
 	spin_unlock_irq(&np->lock);
 
 	free_irq(dev->irq, dev);
 	wmb();
 	netif_device_attach(dev);
 
-	if (readl(ioaddr + NetworkConfig) != 0xffffffff)
-		np->stats.rx_missed_errors += readl(ioaddr + RxMissed) & 0xffff;
+	if (ioread32(ioaddr + NetworkConfig) != 0xffffffff)
+		np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
 
 #ifdef __i386__
 	if (debug > 2) {
@@ -1599,11 +1584,10 @@
 	struct net_device *dev = pci_get_drvdata(pdev);
 	
 	if (dev) {
+		struct netdev_private *np = netdev_priv(dev);
 		unregister_netdev(dev);
 		pci_release_regions(pdev);
-#ifndef USE_IO_OPS
-		iounmap((char *)(dev->base_addr));
-#endif
+		pci_iounmap(pdev, np->base_addr);
 		free_netdev(dev);
 	}
 
@@ -1638,8 +1622,8 @@
 static int w840_suspend (struct pci_dev *pdev, u32 state)
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
-	struct netdev_private *np = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base_addr;
 
 	rtnl_lock();
 	if (netif_running (dev)) {
@@ -1648,19 +1632,19 @@
 		spin_lock_irq(&np->lock);
 		netif_device_detach(dev);
 		update_csr6(dev, 0);
-		writel(0, ioaddr + IntrEnable);
+		iowrite32(0, ioaddr + IntrEnable);
 		netif_stop_queue(dev);
 		spin_unlock_irq(&np->lock);
 
 		spin_unlock_wait(&dev->xmit_lock);
 		synchronize_irq(dev->irq);
 	
-		np->stats.rx_missed_errors += readl(ioaddr + RxMissed) & 0xffff;
+		np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
 
 		/* no more hardware accesses behind this line. */
 
 		if (np->csr6) BUG();
-		if (readl(ioaddr + IntrEnable)) BUG();
+		if (ioread32(ioaddr + IntrEnable)) BUG();
 
 		/* pci_power_off(pdev, -1); */
 
@@ -1675,7 +1659,7 @@
 static int w840_resume (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
-	struct netdev_private *np = dev->priv;
+	struct netdev_private *np = netdev_priv(dev);
 
 	rtnl_lock();
 	if (netif_device_present(dev))
@@ -1685,8 +1669,8 @@
 	/*	pci_power_on(pdev); */
 
 		spin_lock_irq(&np->lock);
-		writel(1, dev->base_addr+PCIBusCfg);
-		readl(dev->base_addr+PCIBusCfg);
+		iowrite32(1, np->base_addr+PCIBusCfg);
+		ioread32(np->base_addr+PCIBusCfg);
 		udelay(1);
 		netif_device_attach(dev);
 		init_rxtx_rings(dev);
diff -Nru a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
--- a/drivers/net/tulip/xircom_cb.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/tulip/xircom_cb.c	2004-12-24 13:37:18 -08:00
@@ -28,9 +28,9 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/ethtool.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #ifdef DEBUG
@@ -117,6 +117,9 @@
 static int xircom_close(struct net_device *dev);
 static void xircom_up(struct xircom_private *card);
 static struct net_device_stats *xircom_get_stats(struct net_device *dev);
+#if CONFIG_NET_POLL_CONTROLLER
+static void xircom_poll_controller(struct net_device *dev);
+#endif
 
 static void investigate_read_descriptor(struct net_device *dev,struct xircom_private *card, int descnr, unsigned int bufferoffset);
 static void investigate_write_descriptor(struct net_device *dev, struct xircom_private *card, int descnr, unsigned int bufferoffset);
@@ -256,7 +259,7 @@
 	private->dev = dev;
 	private->pdev = pdev;
 	private->io_port = pci_resource_start(pdev, 0);
-	private->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&private->lock);
 	dev->irq = pdev->irq;
 	dev->base_addr = private->io_port;
 	
@@ -269,6 +272,9 @@
 	dev->stop = &xircom_close;
 	dev->get_stats = &xircom_get_stats;
 	dev->priv = private;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	dev->poll_controller = &xircom_poll_controller;
+#endif
 	SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
 	pci_set_drvdata(pdev, dev);
 
@@ -500,6 +506,14 @@
 } 
                                                  
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void xircom_poll_controller(struct net_device *dev)
+{
+	disable_irq(dev->irq);
+	xircom_interrupt(dev->irq, dev, NULL);
+	enable_irq(dev->irq);
+}
+#endif
 
 
 static void initialize_card(struct xircom_private *card)
diff -Nru a/drivers/net/tulip/xircom_tulip_cb.c b/drivers/net/tulip/xircom_tulip_cb.c
--- a/drivers/net/tulip/xircom_tulip_cb.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/tulip/xircom_tulip_cb.c	2004-12-24 13:36:18 -08:00
@@ -329,9 +329,6 @@
 	int saved_if_port;
 	struct pci_dev *pdev;
 	spinlock_t lock;
-#ifdef CONFIG_PM
-	u32 pci_state[16];
-#endif
 };
 
 static int mdio_read(struct net_device *dev, int phy_id, int location);
@@ -350,6 +347,7 @@
 static int xircom_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void set_rx_mode(struct net_device *dev);
 static void check_duplex(struct net_device *dev);
+static struct ethtool_ops ops;
 
 
 /* The Xircom cards are picky about when certain bits in CSR6 can be
@@ -450,7 +448,7 @@
  */
 static void find_mii_transceivers(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	int phy, phy_idx;
 
 	if (media_cap[tp->default_port] & MediaIsMII) {
@@ -505,7 +503,7 @@
  */
 static void transceiver_voodoo(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 
 	/* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
@@ -584,9 +582,9 @@
 	/* Clear the missed-packet counter. */
 	(volatile int)inl(ioaddr + CSR8);
 
-	tp = dev->priv;
+	tp = netdev_priv(dev);
 
-	tp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&tp->lock);
 	tp->pdev = pdev;
 	tp->chip_id = chip_idx;
 	/* BugFixes: The 21143-TD hangs with PCI Write-and-Invalidate cycles. */
@@ -626,6 +624,7 @@
 #endif
 	dev->tx_timeout = xircom_tx_timeout;
 	dev->watchdog_timeo = TX_TIMEOUT;
+	SET_ETHTOOL_OPS(dev, &ops);
 
 	transceiver_voodoo(dev);
 
@@ -749,7 +748,7 @@
 static void
 xircom_up(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int i;
 
@@ -804,7 +803,7 @@
 static int
 xircom_open(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 
 	if (request_irq(dev->irq, &xircom_interrupt, SA_SHIRQ, dev->name, dev))
 		return -EAGAIN;
@@ -818,7 +817,7 @@
 
 static void xircom_tx_timeout(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 
 	if (media_cap[dev->if_port] & MediaIsMII) {
@@ -870,7 +869,7 @@
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
 static void xircom_init_ring(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	int i;
 
 	tp->tx_full = 0;
@@ -919,7 +918,7 @@
 static int
 xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	int entry;
 	u32 flag;
 
@@ -971,7 +970,7 @@
 
 static void xircom_media_change(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	u16 reg0, reg1, reg4, reg5;
 	u32 csr6 = inl(ioaddr + CSR6), newcsr6;
@@ -1032,7 +1031,7 @@
 
 static void check_duplex(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	u16 reg0;
 
 	mdio_write(dev, tp->phys[0], MII_BMCR, BMCR_RESET);
@@ -1065,7 +1064,7 @@
 static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_instance;
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 	int csr5, work_budget = max_interrupt_work;
 	int handled = 0;
@@ -1203,7 +1202,7 @@
 static int
 xircom_rx(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	int entry = tp->cur_rx % RX_RING_SIZE;
 	int rx_work_limit = tp->dirty_rx + RX_RING_SIZE - tp->cur_rx;
 	int work_done = 0;
@@ -1303,7 +1302,7 @@
 xircom_down(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 
 	/* Disable interrupts by clearing the interrupt mask. */
 	outl(0, ioaddr + CSR7);
@@ -1321,7 +1320,7 @@
 xircom_close(struct net_device *dev)
 {
 	long ioaddr = dev->base_addr;
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	int i;
 
 	if (xircom_debug > 1)
@@ -1359,7 +1358,7 @@
 
 static struct net_device_stats *xircom_get_stats(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	long ioaddr = dev->base_addr;
 
 	if (netif_device_present(dev))
@@ -1368,18 +1367,10 @@
 	return &tp->stats;
 }
 
-
-static int xircom_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static int xircom_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
-	struct ethtool_cmd ecmd;
-	struct xircom_private *tp = dev->priv;
-
-	if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
-		return -EFAULT;
-
-	switch (ecmd.cmd) {
-	case ETHTOOL_GSET:
-		ecmd.supported =
+	struct xircom_private *tp = netdev_priv(dev);
+	ecmd->supported =
 			SUPPORTED_10baseT_Half |
 			SUPPORTED_10baseT_Full |
 			SUPPORTED_100baseT_Half |
@@ -1387,98 +1378,90 @@
 			SUPPORTED_Autoneg |
 			SUPPORTED_MII;
 
-		ecmd.advertising = ADVERTISED_MII;
-		if (tp->advertising[0] & ADVERTISE_10HALF)
-			ecmd.advertising |= ADVERTISED_10baseT_Half;
-		if (tp->advertising[0] & ADVERTISE_10FULL)
-			ecmd.advertising |= ADVERTISED_10baseT_Full;
-		if (tp->advertising[0] & ADVERTISE_100HALF)
-			ecmd.advertising |= ADVERTISED_100baseT_Half;
-		if (tp->advertising[0] & ADVERTISE_100FULL)
-			ecmd.advertising |= ADVERTISED_100baseT_Full;
-		if (tp->autoneg) {
-			ecmd.advertising |= ADVERTISED_Autoneg;
-			ecmd.autoneg = AUTONEG_ENABLE;
-		} else
-			ecmd.autoneg = AUTONEG_DISABLE;
-
-		ecmd.port = PORT_MII;
-		ecmd.transceiver = XCVR_INTERNAL;
-		ecmd.phy_address = tp->phys[0];
-		ecmd.speed = tp->speed100 ? SPEED_100 : SPEED_10;
-		ecmd.duplex = tp->full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
-		ecmd.maxtxpkt = TX_RING_SIZE / 2;
-		ecmd.maxrxpkt = 0;
+	ecmd->advertising = ADVERTISED_MII;
+	if (tp->advertising[0] & ADVERTISE_10HALF)
+		ecmd->advertising |= ADVERTISED_10baseT_Half;
+	if (tp->advertising[0] & ADVERTISE_10FULL)
+		ecmd->advertising |= ADVERTISED_10baseT_Full;
+	if (tp->advertising[0] & ADVERTISE_100HALF)
+		ecmd->advertising |= ADVERTISED_100baseT_Half;
+	if (tp->advertising[0] & ADVERTISE_100FULL)
+		ecmd->advertising |= ADVERTISED_100baseT_Full;
+	if (tp->autoneg) {
+		ecmd->advertising |= ADVERTISED_Autoneg;
+		ecmd->autoneg = AUTONEG_ENABLE;
+	} else
+		ecmd->autoneg = AUTONEG_DISABLE;
 
-		if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
+	ecmd->port = PORT_MII;
+	ecmd->transceiver = XCVR_INTERNAL;
+	ecmd->phy_address = tp->phys[0];
+	ecmd->speed = tp->speed100 ? SPEED_100 : SPEED_10;
+	ecmd->duplex = tp->full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
+	ecmd->maxtxpkt = TX_RING_SIZE / 2;
+	ecmd->maxrxpkt = 0;
+	return 0;
+}
 
-	case ETHTOOL_SSET: {
-		u16 autoneg, speed100, full_duplex;
+static int xircom_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct xircom_private *tp = netdev_priv(dev);
+	u16 autoneg, speed100, full_duplex;
 
-		autoneg = (ecmd.autoneg == AUTONEG_ENABLE);
-		speed100 = (ecmd.speed == SPEED_100);
-		full_duplex = (ecmd.duplex == DUPLEX_FULL);
-
-		tp->autoneg = autoneg;
-		if (speed100 != tp->speed100 ||
-		    full_duplex != tp->full_duplex) {
-			tp->speed100 = speed100;
-			tp->full_duplex = full_duplex;
-			/* change advertising bits */
-			tp->advertising[0] &= ~(ADVERTISE_10HALF |
-					     ADVERTISE_10FULL |
-					     ADVERTISE_100HALF |
-					     ADVERTISE_100FULL |
-					     ADVERTISE_100BASE4);
-			if (speed100) {
-				if (full_duplex)
-					tp->advertising[0] |= ADVERTISE_100FULL;
-				else
-					tp->advertising[0] |= ADVERTISE_100HALF;
-			} else {
-				if (full_duplex)
-					tp->advertising[0] |= ADVERTISE_10FULL;
-				else
-					tp->advertising[0] |= ADVERTISE_10HALF;
-			}
+	autoneg = (ecmd->autoneg == AUTONEG_ENABLE);
+	speed100 = (ecmd->speed == SPEED_100);
+	full_duplex = (ecmd->duplex == DUPLEX_FULL);
+
+	tp->autoneg = autoneg;
+	if (speed100 != tp->speed100 ||
+	    full_duplex != tp->full_duplex) {
+		tp->speed100 = speed100;
+		tp->full_duplex = full_duplex;
+		/* change advertising bits */
+		tp->advertising[0] &= ~(ADVERTISE_10HALF |
+				     ADVERTISE_10FULL |
+				     ADVERTISE_100HALF |
+				     ADVERTISE_100FULL |
+				     ADVERTISE_100BASE4);
+		if (speed100) {
+			if (full_duplex)
+				tp->advertising[0] |= ADVERTISE_100FULL;
+			else
+				tp->advertising[0] |= ADVERTISE_100HALF;
+		} else {
+			if (full_duplex)
+				tp->advertising[0] |= ADVERTISE_10FULL;
+			else
+				tp->advertising[0] |= ADVERTISE_10HALF;
 		}
-		check_duplex(dev);
-		return 0;
-	}
-
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info;
-		memset(&info, 0, sizeof(info));
-		info.cmd = ecmd.cmd;
-		strcpy(info.driver, DRV_NAME);
-		strcpy(info.version, DRV_VERSION);
-		*info.fw_version = 0;
-		strcpy(info.bus_info, pci_name(tp->pdev));
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-		       return -EFAULT;
-		return 0;
 	}
+	check_duplex(dev);
+	return 0;
+}
 
-	default:
-		return -EOPNOTSUPP;
-	}
+static void xircom_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	struct xircom_private *tp = netdev_priv(dev);
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+	strcpy(info->bus_info, pci_name(tp->pdev));
 }
 
+static struct ethtool_ops ops = {
+	.get_settings = xircom_get_settings,
+	.set_settings = xircom_set_settings,
+	.get_drvinfo = xircom_get_drvinfo,
+};
 
 /* Provide ioctl() calls to examine the MII xcvr state. */
 static int xircom_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	u16 *data = (u16 *)&rq->ifr_ifru;
 	int phy = tp->phys[0] & 0x1f;
 	unsigned long flags;
 
 	switch(cmd) {
-	case SIOCETHTOOL:
-		return xircom_ethtool_ioctl(dev, rq->ifr_data);
-
 	/* Legacy mii-diag interface */
 	case SIOCGMIIPHY:		/* Get address of MII PHY in use. */
 		if (tp->mii_cnt)
@@ -1531,7 +1514,7 @@
    when re-entered but still correct. */
 static void set_rx_mode(struct net_device *dev)
 {
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	struct dev_mc_list *mclist;
 	long ioaddr = dev->base_addr;
 	int csr6 = inl(ioaddr + CSR6);
@@ -1672,12 +1655,12 @@
 static int xircom_suspend(struct pci_dev *pdev, u32 state)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	printk(KERN_INFO "xircom_suspend(%s)\n", dev->name);
 	if (tp->open)
 		xircom_down(dev);
 
-	pci_save_state(pdev, tp->pci_state);
+	pci_save_state(pdev);
 	pci_disable_device(pdev);
 	pci_set_power_state(pdev, 3);
 
@@ -1688,12 +1671,12 @@
 static int xircom_resume(struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct xircom_private *tp = dev->priv;
+	struct xircom_private *tp = netdev_priv(dev);
 	printk(KERN_INFO "xircom_resume(%s)\n", dev->name);
 
 	pci_set_power_state(pdev,0);
 	pci_enable_device(pdev);
-	pci_restore_state(pdev, tp->pci_state);
+	pci_restore_state(pdev);
 
 	/* Bring the chip out of sleep mode.
 	   Caution: Snooze mode does not work with some boards! */
diff -Nru a/drivers/net/typhoon.c b/drivers/net/typhoon.c
--- a/drivers/net/typhoon.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/typhoon.c	2004-12-24 13:37:00 -08:00
@@ -1,6 +1,6 @@
 /* typhoon.c: A Linux Ethernet device driver for 3Com 3CR990 family of NICs */
 /*
-	Written 2002-2003 by David Dillow <dave@thedillows.org>
+	Written 2002-2004 by David Dillow <dave@thedillows.org>
 	Based on code written 1998-2000 by Donald Becker <becker@scyld.com> and
 	Linux 2.2.x driver by David P. McLean <davidpmclean@yahoo.com>.
 
@@ -33,8 +33,16 @@
 	*) Waiting for a command response takes 8ms due to non-preemptable
 		polling. Only significant for getting stats and creating
 		SAs, but an ugly wart never the less.
-	*) I've not tested multicast. I think it works, but reports welcome.
+
+	TODO:
 	*) Doesn't do IPSEC offloading. Yet. Keep yer pants on, it's coming.
+	*) Add more support for ethtool (especially for NIC stats)
+	*) Allow disabling of RX checksum offloading
+	*) Fix MAC changing to work while the interface is up
+		(Need to put commands on the TX ring, which changes
+		the locking)
+	*) Add in FCS to {rx,tx}_bytes, since the hardware doesn't. See
+		http://oss.sgi.com/cgi-bin/mesg.cgi?a=netdev&i=20031215152211.7003fe8e.rddunlap%40osdl.org
 */
 
 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
@@ -85,8 +93,8 @@
 #define PKT_BUF_SZ		1536
 
 #define DRV_MODULE_NAME		"typhoon"
-#define DRV_MODULE_VERSION 	"1.5.3"
-#define DRV_MODULE_RELDATE	"03/12/15"
+#define DRV_MODULE_VERSION 	"1.5.4"
+#define DRV_MODULE_RELDATE	"04/09/09"
 #define PFX			DRV_MODULE_NAME ": "
 #define ERR_PFX			KERN_ERR PFX
 
@@ -107,13 +115,14 @@
 #include <linux/ethtool.h>
 #include <linux/if_vlan.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 #include <asm/processor.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <linux/in6.h>
 #include <asm/checksum.h>
 #include <linux/version.h>
+#include <linux/dma-mapping.h>
 
 #include "typhoon.h"
 #include "typhoon-firmware.h"
@@ -279,7 +288,6 @@
 	u16			xcvr_select;
 	u16			wol_events;
 	u32			offload;
-	u32			pci_state[16];
 
 	/* unused stuff (future use) */
 	int			capabilities;
@@ -410,21 +418,22 @@
 out:
 	writel(TYPHOON_INTR_ALL, ioaddr + TYPHOON_REG_INTR_MASK);
 	writel(TYPHOON_INTR_ALL, ioaddr + TYPHOON_REG_INTR_STATUS);
-	udelay(100);
-	return err;
 
 	/* The 3XP seems to need a little extra time to complete the load
 	 * of the sleep image before we can reliably boot it. Failure to
 	 * do this occasionally results in a hung adapter after boot in
 	 * typhoon_init_one() while trying to read the MAC address or
 	 * putting the card to sleep. 3Com's driver waits 5ms, but
-	 * that seems to be overkill -- with a 50usec delay, it survives
-	 * 35000 typhoon_init_one() calls, where it only make it 25-100
-	 * without it.
-	 *
-	 * As it turns out, still occasionally getting a hung adapter,
-	 * so I'm bumping it to 100us.
+	 * that seems to be overkill. However, if we can sleep, we might
+	 * as well give it that much time. Otherwise, we'll give it 500us,
+	 * which should be enough (I've see it work well at 100us, but still
+	 * saw occasional problems.)
 	 */
+	if(wait_type == WaitSleep)
+		msleep(5);
+	else
+		udelay(500);
+	return err;
 }
 
 static int
@@ -688,7 +697,7 @@
 static void
 typhoon_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 	struct cmd_desc xp_cmd;
 	int err;
 
@@ -726,7 +735,7 @@
 static void
 typhoon_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 	spin_lock_bh(&tp->state_lock);
 	if(tp->vlgrp)
 		tp->vlgrp->vlan_devices[vid] = NULL;
@@ -757,7 +766,7 @@
 static int
 typhoon_start_tx(struct sk_buff *skb, struct net_device *dev)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 	struct transmit_ring *txRing;
 	struct tx_desc *txd, *first_txd;
 	dma_addr_t skb_dma;
@@ -908,7 +917,7 @@
 static void
 typhoon_set_rx_mode(struct net_device *dev)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 	struct cmd_desc xp_cmd;
 	u32 mc_filter[2];
 	u16 filter;
@@ -965,6 +974,9 @@
 
 	/* 3Com's Linux driver uses txMultipleCollisions as it's
 	 * collisions value, but there is some other collision info as well...
+	 *
+	 * The extra status reported would be a good candidate for
+	 * ethtool_ops->get_{strings,stats}()
 	 */
 	stats->tx_packets = le32_to_cpu(s->txPackets);
 	stats->tx_bytes = le32_to_cpu(s->txBytes);
@@ -1002,7 +1014,7 @@
 static struct net_device_stats *
 typhoon_get_stats(struct net_device *dev)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 	struct net_device_stats *stats = &tp->stats;
 	struct net_device_stats *saved = &tp->stats_saved;
 
@@ -1030,9 +1042,10 @@
 	return 0;
 }
 
-static inline void
-typhoon_ethtool_gdrvinfo(struct typhoon *tp, struct ethtool_drvinfo *info)
+static void
+typhoon_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
+	struct typhoon *tp = netdev_priv(dev);
 	struct pci_dev *pci_dev = tp->pdev;
 	struct cmd_desc xp_cmd;
 	struct resp_desc xp_resp[3];
@@ -1055,9 +1068,11 @@
 	strcpy(info->bus_info, pci_name(pci_dev));
 }
 
-static inline void
-typhoon_ethtool_gset(struct typhoon *tp, struct ethtool_cmd *cmd)
+static int
+typhoon_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
+	struct typhoon *tp = netdev_priv(dev);
+
 	cmd->supported = SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
 				SUPPORTED_Autoneg;
 
@@ -1107,15 +1122,19 @@
 		cmd->autoneg = AUTONEG_DISABLE;
 	cmd->maxtxpkt = 1;
 	cmd->maxrxpkt = 1;
+
+	return 0;
 }
 
-static inline int
-typhoon_ethtool_sset(struct typhoon *tp, struct ethtool_cmd *cmd)
+static int
+typhoon_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
+	struct typhoon *tp = netdev_priv(dev);
 	struct cmd_desc xp_cmd;
 	int xcvr;
 	int err;
 
+	err = -EINVAL;
 	if(cmd->autoneg == AUTONEG_ENABLE) {
 		xcvr = TYPHOON_XCVR_AUTONEG;
 	} else {
@@ -1125,23 +1144,23 @@
 			else if(cmd->speed == SPEED_100)
 				xcvr = TYPHOON_XCVR_100HALF;
 			else
-				return -EINVAL;
+				goto out;
 		} else if(cmd->duplex == DUPLEX_FULL) {
 			if(cmd->speed == SPEED_10)
 				xcvr = TYPHOON_XCVR_10FULL;
 			else if(cmd->speed == SPEED_100)
 				xcvr = TYPHOON_XCVR_100FULL;
 			else
-				return -EINVAL;
+				goto out;
 		} else
-			return -EINVAL;
+			goto out;
 	}
 
 	INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_XCVR_SELECT);
 	xp_cmd.parm1 = cpu_to_le16(xcvr);
 	err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL);
 	if(err < 0)
-		return err;
+		goto out;
 
 	tp->xcvr_select = xcvr;
 	if(cmd->autoneg == AUTONEG_ENABLE) {
@@ -1152,93 +1171,80 @@
 		tp->duplex = cmd->duplex;
 	}
 
-	return 0;
+out:
+	return err;
 }
 
-static inline int
-typhoon_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void
+typhoon_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
-	u32 ethcmd;
+	struct typhoon *tp = netdev_priv(dev);
 
-	if(copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-		return -EFAULT;
-
-	switch (ethcmd) {
-	case ETHTOOL_GDRVINFO: {
-			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-
-			typhoon_ethtool_gdrvinfo(tp, &info);
-			if(copy_to_user(useraddr, &info, sizeof(info)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_GSET: {
-			struct ethtool_cmd cmd = { ETHTOOL_GSET };
-
-			typhoon_ethtool_gset(tp, &cmd);
-			if(copy_to_user(useraddr, &cmd, sizeof(cmd)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_SSET: {
-			struct ethtool_cmd cmd;
-			if(copy_from_user(&cmd, useraddr, sizeof(cmd)))
-				return -EFAULT;
+	wol->supported = WAKE_PHY | WAKE_MAGIC;
+	wol->wolopts = 0;
+	if(tp->wol_events & TYPHOON_WAKE_LINK_EVENT)
+		wol->wolopts |= WAKE_PHY;
+	if(tp->wol_events & TYPHOON_WAKE_MAGIC_PKT)
+		wol->wolopts |= WAKE_MAGIC;
+	memset(&wol->sopass, 0, sizeof(wol->sopass));
+}
 
-			return typhoon_ethtool_sset(tp, &cmd);
-		}
-	case ETHTOOL_GLINK:{
-			struct ethtool_value edata = { ETHTOOL_GLINK };
+static int
+typhoon_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+	struct typhoon *tp = netdev_priv(dev);
 
-			edata.data = netif_carrier_ok(dev) ? 1 : 0;
-			if(copy_to_user(useraddr, &edata, sizeof(edata)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_GWOL: {
-			struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
+	if(wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
+		return -EINVAL;
 
-			if(tp->wol_events & TYPHOON_WAKE_LINK_EVENT)
-				wol.wolopts |= WAKE_PHY;
-			if(tp->wol_events & TYPHOON_WAKE_MAGIC_PKT)
-				wol.wolopts |= WAKE_MAGIC;
-			if(copy_to_user(useraddr, &wol, sizeof(wol)))
-				return -EFAULT;
-			return 0;
-	}
-	case ETHTOOL_SWOL: {
-			struct ethtool_wolinfo wol;
-
-			if(copy_from_user(&wol, useraddr, sizeof(wol)))
-				return -EFAULT;
-			tp->wol_events = 0;
-			if(wol.wolopts & WAKE_PHY)
-				tp->wol_events |= TYPHOON_WAKE_LINK_EVENT;
-			if(wol.wolopts & WAKE_MAGIC)
-				tp->wol_events |= TYPHOON_WAKE_MAGIC_PKT;
-			return 0;
-	}
-	default:
-		break;
-	}
+	tp->wol_events = 0;
+	if(wol->wolopts & WAKE_PHY)
+		tp->wol_events |= TYPHOON_WAKE_LINK_EVENT;
+	if(wol->wolopts & WAKE_MAGIC)
+		tp->wol_events |= TYPHOON_WAKE_MAGIC_PKT;
 
-	return -EOPNOTSUPP;
+	return 0;
 }
 
-static int
-typhoon_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static u32
+typhoon_get_rx_csum(struct net_device *dev)
 {
-	switch (cmd) {
-	case SIOCETHTOOL:
-		return typhoon_ethtool_ioctl(dev, ifr->ifr_data);
-	default:
-		break;
-	}
-
-	return -EOPNOTSUPP;
+	/* For now, we don't allow turning off RX checksums.
+	 */
+	return 1;
 }
 
+static void
+typhoon_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
+{
+	ering->rx_max_pending = RXENT_ENTRIES;
+	ering->rx_mini_max_pending = 0;
+	ering->rx_jumbo_max_pending = 0;
+	ering->tx_max_pending = TXLO_ENTRIES - 1;
+
+	ering->rx_pending = RXENT_ENTRIES;
+	ering->rx_mini_pending = 0;
+	ering->rx_jumbo_pending = 0;
+	ering->tx_pending = TXLO_ENTRIES - 1;
+}
+
+static struct ethtool_ops typhoon_ethtool_ops = {
+	.get_settings		= typhoon_get_settings,
+	.set_settings		= typhoon_set_settings,
+	.get_drvinfo		= typhoon_get_drvinfo,
+	.get_wol		= typhoon_get_wol,
+	.set_wol		= typhoon_set_wol,
+	.get_link		= ethtool_op_get_link,
+	.get_rx_csum		= typhoon_get_rx_csum,
+	.get_tx_csum		= ethtool_op_get_tx_csum,
+	.set_tx_csum		= ethtool_op_set_tx_csum,
+	.get_sg			= ethtool_op_get_sg,
+	.set_sg			= ethtool_op_set_sg,
+	.get_tso		= ethtool_op_get_tso,
+	.set_tso		= ethtool_op_set_tso,
+	.get_ringparam		= typhoon_get_ringparam,
+};
+
 static int
 typhoon_wait_interrupt(void __iomem *ioaddr)
 {
@@ -1756,7 +1762,7 @@
 static int
 typhoon_poll(struct net_device *dev, int *total_budget)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 	struct typhoon_indexes *indexes = tp->indexes;
 	int orig_budget = *total_budget;
 	int budget, work_done, done;
@@ -1894,7 +1900,7 @@
 	void __iomem *ioaddr = tp->ioaddr;
 
 	pci_set_power_state(pdev, 0);
-	pci_restore_state(pdev, tp->pci_state);
+	pci_restore_state(pdev);
 
 	/* Post 2.x.x versions of the Sleep Image require a reset before
 	 * we can download the Runtime Image. But let's not make users of
@@ -2069,7 +2075,7 @@
 static void
 typhoon_tx_timeout(struct net_device *dev)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 
 	if(typhoon_reset(tp->ioaddr, WaitNoSleep) < 0) {
 		printk(KERN_WARNING "%s: could not reset in tx timeout\n",
@@ -2099,7 +2105,7 @@
 static int
 typhoon_open(struct net_device *dev)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 	int err;
 
 	err = typhoon_wakeup(tp, WaitSleep);
@@ -2141,7 +2147,7 @@
 static int
 typhoon_close(struct net_device *dev)
 {
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 
 	netif_stop_queue(dev);
 
@@ -2169,7 +2175,7 @@
 typhoon_resume(struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 
 	/* If we're down, resume when we are upped.
 	 */
@@ -2201,7 +2207,7 @@
 typhoon_suspend(struct pci_dev *pdev, u32 state)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct typhoon *tp = (struct typhoon *) dev->priv;
+	struct typhoon *tp = netdev_priv(dev);
 	struct cmd_desc xp_cmd;
 
 	/* If we're down, we're already suspended.
@@ -2305,17 +2311,17 @@
 		goto error_out_dev;
 	}
 
-	/* If we transitioned from D3->D0 in pci_enable_device(),
-	 * we lost our configuration and need to restore it to the
-	 * conditions at boot.
-	 */
-	pci_restore_state(pdev, NULL);
+	err = pci_set_mwi(pdev);
+	if(err < 0) {
+		printk(ERR_PFX "%s: unable to set MWI\n", pci_name(pdev));
+		goto error_out_disable;
+	}
 
-	err = pci_set_dma_mask(pdev, 0xffffffffULL);
+	err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
 	if(err < 0) {
 		printk(ERR_PFX "%s: No usable DMA configuration\n",
 		       pci_name(pdev));
-		goto error_out_dev;
+		goto error_out_mwi;
 	}
 
 	/* sanity checks, resource #1 is our mmio area
@@ -2325,25 +2331,22 @@
 		       "%s: region #1 not a PCI MMIO resource, aborting\n",
 		       pci_name(pdev));
 		err = -ENODEV;
-		goto error_out_dev;
+		goto error_out_mwi;
 	}
 	if(pci_resource_len(pdev, 1) < 128) {
 		printk(ERR_PFX "%s: Invalid PCI MMIO region size, aborting\n",
 		       pci_name(pdev));
 		err = -ENODEV;
-		goto error_out_dev;
+		goto error_out_mwi;
 	}
 
 	err = pci_request_regions(pdev, "typhoon");
 	if(err < 0) {
 		printk(ERR_PFX "%s: could not request regions\n",
 		       pci_name(pdev));
-		goto error_out_dev;
+		goto error_out_mwi;
 	}
 
-	pci_set_master(pdev);
-	pci_set_mwi(pdev);
-
 	/* map our MMIO region
 	 */
 	ioaddr = pci_resource_start(pdev, 1);
@@ -2367,7 +2370,7 @@
 	}
 
 	dev->irq = pdev->irq;
-	tp = dev->priv;
+	tp = netdev_priv(dev);
 	tp->shared = (struct typhoon_shared *) shared;
 	tp->shared_dma = shared_dma;
 	tp->pdev = pdev;
@@ -2377,7 +2380,7 @@
 	tp->dev = dev;
 
 	/* need to be able to restore PCI state after a suspend */
-	pci_save_state(pdev, tp->pci_state);
+	pci_save_state(pdev);
 
 	/* Init sequence:
 	 * 1) Reset the adapter to clear any bad juju
@@ -2392,6 +2395,11 @@
 		goto error_out_dma;
 	}
 
+	/* Now that we've reset the 3XP and are sure it's not going to
+	 * write all over memory, enable bus mastering.
+	 */
+	pci_set_master(pdev);
+
 	/* dev->name is not valid until we register, but we need to
 	 * use some common routines to initialize the card. So that those
 	 * routines print the right name, we keep our oun pointer to the name
@@ -2465,9 +2473,9 @@
 	dev->watchdog_timeo	= TX_TIMEOUT;
 	dev->get_stats		= typhoon_get_stats;
 	dev->set_mac_address	= typhoon_set_mac_address;
-	dev->do_ioctl		= typhoon_ioctl;
 	dev->vlan_rx_register	= typhoon_vlan_rx_register;
 	dev->vlan_rx_kill_vid	= typhoon_vlan_rx_kill_vid;
+	SET_ETHTOOL_OPS(dev, &typhoon_ethtool_ops);
 
 	/* We can handle scatter gather, up to 16 entries, and
 	 * we can do IP checksumming (only version 4, doh...)
@@ -2528,6 +2536,10 @@
 	iounmap(ioaddr_mapped);
 error_out_regions:
 	pci_release_regions(pdev);
+error_out_mwi:
+	pci_clear_mwi(pdev);
+error_out_disable:
+	pci_disable_device(pdev);
 error_out_dev:
 	free_netdev(dev);
 error_out:
@@ -2538,16 +2550,17 @@
 typhoon_remove_one(struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct typhoon *tp = (struct typhoon *) (dev->priv);
+	struct typhoon *tp = netdev_priv(dev);
 
 	unregister_netdev(dev);
 	pci_set_power_state(pdev, 0);
-	pci_restore_state(pdev, tp->pci_state);
+	pci_restore_state(pdev);
 	typhoon_reset(tp->ioaddr, NoWait);
 	iounmap(tp->ioaddr);
 	pci_free_consistent(pdev, sizeof(struct typhoon_shared),
 			    tp->shared, tp->shared_dma);
 	pci_release_regions(pdev);
+	pci_clear_mwi(pdev);
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
 	free_netdev(dev);
diff -Nru a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
--- a/drivers/net/via-rhine.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/via-rhine.c	2004-12-24 13:37:29 -08:00
@@ -193,8 +193,8 @@
 #include <linux/mii.h>
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 #include <asm/processor.h>	/* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -627,7 +627,7 @@
 }
 
 #ifdef USE_MMIO
-static void __devinit enable_mmio(long pioaddr, u32 quirks)
+static void enable_mmio(long pioaddr, u32 quirks)
 {
 	int n;
 	if (quirks & rqRhineI) {
@@ -1951,12 +1951,13 @@
 		return 0;
 
 	netif_device_detach(dev);
-	pci_save_state(pdev, pdev->saved_config_space);
+	pci_save_state(pdev);
 
 	spin_lock_irqsave(&rp->lock, flags);
 	rhine_shutdown(&pdev->dev);
 	spin_unlock_irqrestore(&rp->lock, flags);
 
+	free_irq(dev->irq, dev);
 	return 0;
 }
 
@@ -1970,12 +1971,15 @@
 	if (!netif_running(dev))
 		return 0;
 
+        if (request_irq(dev->irq, rhine_interrupt, SA_SHIRQ, dev->name, dev))
+		printk(KERN_ERR "via-rhine %s: request_irq failed\n", dev->name);
+
 	ret = pci_set_power_state(pdev, 0);
 	if (debug > 1)
 		printk(KERN_INFO "%s: Entering power state D0 %s (%d).\n",
 			dev->name, ret ? "failed" : "succeeded", ret);
 
-	pci_restore_state(pdev, pdev->saved_config_space);
+	pci_restore_state(pdev);
 
 	spin_lock_irqsave(&rp->lock, flags);
 #ifdef USE_MMIO
diff -Nru a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
--- a/drivers/net/via-velocity.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/via-velocity.c	2004-12-24 13:37:18 -08:00
@@ -251,14 +251,14 @@
 static void mii_init(struct velocity_info *vptr, u32 mii_status);
 static u32 velocity_get_opt_media_mode(struct velocity_info *vptr);
 static void velocity_print_link_status(struct velocity_info *vptr);
-static void safe_disable_mii_autopoll(struct mac_regs * regs);
+static void safe_disable_mii_autopoll(struct mac_regs __iomem * regs);
 static void velocity_shutdown(struct velocity_info *vptr);
 static void enable_flow_control_ability(struct velocity_info *vptr);
-static void enable_mii_autopoll(struct mac_regs * regs);
-static int velocity_mii_read(struct mac_regs *, u8 byIdx, u16 * pdata);
-static int velocity_mii_write(struct mac_regs *, u8 byMiiAddr, u16 data);
-static u32 mii_check_media_mode(struct mac_regs * regs);
-static u32 check_connection_type(struct mac_regs * regs);
+static void enable_mii_autopoll(struct mac_regs __iomem * regs);
+static int velocity_mii_read(struct mac_regs __iomem *, u8 byIdx, u16 * pdata);
+static int velocity_mii_write(struct mac_regs __iomem *, u8 byMiiAddr, u16 data);
+static u32 mii_check_media_mode(struct mac_regs __iomem * regs);
+static u32 check_connection_type(struct mac_regs __iomem * regs);
 static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status);
 
 #ifdef CONFIG_PM
@@ -462,7 +462,7 @@
 
 static void velocity_init_cam_filter(struct velocity_info *vptr)
 {
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 
 	/* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */
 	WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, &regs->MCFG);
@@ -503,7 +503,7 @@
 static void velocity_rx_reset(struct velocity_info *vptr)
 {
 
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	int i;
 
 	vptr->rd_dirty = vptr->rd_filled = vptr->rd_curr = 0;
@@ -532,7 +532,7 @@
 static void velocity_init_registers(struct velocity_info *vptr, 
 				    enum velocity_init_type type)
 {
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	int i, mii_status;
 
 	mac_wol_reset(regs);
@@ -654,7 +654,7 @@
 
 static int velocity_soft_reset(struct velocity_info *vptr)
 {
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	int i = 0;
 
 	writel(CR0_SFRST, &regs->CR0Set);
@@ -690,7 +690,7 @@
 	int i;
 	struct velocity_info_tbl *info = (struct velocity_info_tbl *) ent->driver_data;
 	struct velocity_info *vptr;
-	struct mac_regs * regs;
+	struct mac_regs __iomem * regs;
 	int ret = -ENOMEM;
 
 	if (velocity_nics >= MAX_UNITS) {
@@ -1007,7 +1007,7 @@
 
 static inline void velocity_give_many_rx_descs(struct velocity_info *vptr)
 {
-	struct mac_regs *regs = vptr->mac_regs;
+	struct mac_regs __iomem *regs = vptr->mac_regs;
 	int avail, dirty, unusable;
 
 	/*
@@ -1608,7 +1608,7 @@
 {
 
 	if (status & ISR_TXSTLI) {
-		struct mac_regs * regs = vptr->mac_regs;
+		struct mac_regs __iomem * regs = vptr->mac_regs;
 
 		printk(KERN_ERR "TD structure errror TDindex=%hx\n", readw(&regs->TDIdx[0]));
 		BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR);
@@ -1620,7 +1620,7 @@
 	}
 
 	if (status & ISR_SRCI) {
-		struct mac_regs * regs = vptr->mac_regs;
+		struct mac_regs __iomem * regs = vptr->mac_regs;
 		int linked;
 
 		if (vptr->options.spd_dpx == SPD_DPX_AUTO) {
@@ -1838,7 +1838,7 @@
  
 static void velocity_shutdown(struct velocity_info *vptr)
 {
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	mac_disable_int(regs);
 	writel(CR0_STOP, &regs->CR0Set);
 	writew(0xFFFF, &regs->TDCSRClr);
@@ -2097,7 +2097,7 @@
 static void velocity_set_multi(struct net_device *dev)
 {
 	struct velocity_info *vptr = dev->priv;
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	u8 rx_mode;
 	int i;
 	struct dev_mc_list *mclist;
@@ -2351,7 +2351,7 @@
  *	Turn off the autopoll and wait for it to disable on the chip
  */
  
-static void safe_disable_mii_autopoll(struct mac_regs * regs)
+static void safe_disable_mii_autopoll(struct mac_regs __iomem * regs)
 {
 	u16 ww;
 
@@ -2372,7 +2372,7 @@
  *	hardware. Wait for it to enable.
  */
 
-static void enable_mii_autopoll(struct mac_regs * regs)
+static void enable_mii_autopoll(struct mac_regs __iomem * regs)
 {
 	int ii;
 
@@ -2405,7 +2405,7 @@
  *	on success or -ETIMEDOUT if the PHY did not respond.
  */
  
-static int velocity_mii_read(struct mac_regs * regs, u8 index, u16 *data)
+static int velocity_mii_read(struct mac_regs __iomem *regs, u8 index, u16 *data)
 {
 	u16 ww;
 
@@ -2441,7 +2441,7 @@
  *	on success or -ETIMEDOUT if the PHY did not respond.
  */
  
-static int velocity_mii_write(struct mac_regs * regs, u8 mii_addr, u16 data)
+static int velocity_mii_write(struct mac_regs __iomem *regs, u8 mii_addr, u16 data)
 {
 	u16 ww;
 
@@ -2576,7 +2576,7 @@
 static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
 {
 	u32 curr_status;
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 
 	vptr->mii_status = mii_check_media_mode(vptr->mac_regs);
 	curr_status = vptr->mii_status & (~VELOCITY_LINK_FAIL);
@@ -2683,7 +2683,7 @@
  *	accordingly
  */
  
-static u32 mii_check_media_mode(struct mac_regs * regs)
+static u32 mii_check_media_mode(struct mac_regs __iomem * regs)
 {
 	u32 status = 0;
 	u16 ANAR;
@@ -2719,7 +2719,7 @@
 	return status;
 }
 
-static u32 check_connection_type(struct mac_regs * regs)
+static u32 check_connection_type(struct mac_regs __iomem * regs)
 {
 	u32 status = 0;
 	u8 PHYSR0;
@@ -2764,7 +2764,7 @@
 static void enable_flow_control_ability(struct velocity_info *vptr)
 {
 
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 
 	switch (vptr->options.flow_cntl) {
 
@@ -2841,7 +2841,7 @@
 static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
 	struct velocity_info *vptr = dev->priv;
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	u32 status;
 	status = check_connection_type(vptr->mac_regs);
 
@@ -2889,7 +2889,7 @@
 static u32 velocity_get_link(struct net_device *dev)
 {
 	struct velocity_info *vptr = dev->priv;
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	return BYTE_REG_BITS_IS_ON(PHYSR0_LINKGD, &regs->PHYSR0)  ? 0 : 1;
 }
 
@@ -2985,7 +2985,7 @@
 static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
 	struct velocity_info *vptr = dev->priv;
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	unsigned long flags;
 	struct mii_ioctl_data *miidata = if_mii(ifr);
 	int err;
@@ -3031,9 +3031,9 @@
  
 static void velocity_save_context(struct velocity_info *vptr, struct velocity_context * context)
 {
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	u16 i;
-	u8 *ptr = (u8 *)regs;
+	u8 __iomem *ptr = (u8 __iomem *)regs;
 
 	for (i = MAC_REG_PAR; i < MAC_REG_CR0_CLR; i += 4)
 		*((u32 *) (context->mac_reg + i)) = readl(ptr + i);
@@ -3057,9 +3057,9 @@
  
 static void velocity_restore_context(struct velocity_info *vptr, struct velocity_context *context)
 {
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	int i;
-	u8 *ptr = (u8 *)regs;
+	u8 __iomem *ptr = (u8 __iomem *)regs;
 
 	for (i = MAC_REG_PAR; i < MAC_REG_CR0_SET; i += 4) {
 		writel(*((u32 *) (context->mac_reg + i)), ptr + i);
@@ -3135,7 +3135,7 @@
 
 static int velocity_set_wol(struct velocity_info *vptr)
 {
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 	static u8 buf[256];
 	int i;
 
@@ -3221,7 +3221,7 @@
 	netif_device_detach(vptr->dev);
 
 	spin_lock_irqsave(&vptr->lock, flags);
-	pci_save_state(pdev, vptr->pci_state);
+	pci_save_state(pdev);
 #ifdef ETHTOOL_GWOL
 	if (vptr->flags & VELOCITY_FLAGS_WOL_ENABLED) {
 		velocity_get_ip(vptr);
@@ -3254,7 +3254,7 @@
 
 	pci_set_power_state(pdev, 0);
 	pci_enable_wake(pdev, 0, 0);
-	pci_restore_state(pdev, vptr->pci_state);
+	pci_restore_state(pdev);
 
 	mac_wol_reset(vptr->mac_regs);
 
diff -Nru a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h
--- a/drivers/net/via-velocity.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/net/via-velocity.h	2004-12-24 13:37:31 -08:00
@@ -1270,7 +1270,7 @@
  *	provided mask buffer.
  */
 
-static inline void mac_get_cam_mask(struct mac_regs * regs, u8 * mask, enum velocity_cam_type cam_type)
+static inline void mac_get_cam_mask(struct mac_regs __iomem * regs, u8 * mask, enum velocity_cam_type cam_type)
 {
 	int i;
 	/* Select CAM mask */
@@ -1302,7 +1302,7 @@
  *	Store a new mask into a CAM
  */
 
-static inline void mac_set_cam_mask(struct mac_regs * regs, u8 * mask, enum velocity_cam_type cam_type)
+static inline void mac_set_cam_mask(struct mac_regs __iomem * regs, u8 * mask, enum velocity_cam_type cam_type)
 {
 	int i;
 	/* Select CAM mask */
@@ -1333,7 +1333,7 @@
  *	Load an address or vlan tag into a CAM
  */
 
-static inline void mac_set_cam(struct mac_regs * regs, int idx, u8 *addr, enum velocity_cam_type cam_type)
+static inline void mac_set_cam(struct mac_regs __iomem * regs, int idx, u8 *addr, enum velocity_cam_type cam_type)
 {
 	int i;
 
@@ -1375,7 +1375,7 @@
  *	the caller. VLAN tags are 2 bytes the address cam entries are 6.
  */
 
-static inline void mac_get_cam(struct mac_regs * regs, int idx, u8 *addr, enum velocity_cam_type cam_type)
+static inline void mac_get_cam(struct mac_regs __iomem * regs, int idx, u8 *addr, enum velocity_cam_type cam_type)
 {
 	int i;
 
@@ -1414,7 +1414,7 @@
  *	the rest of the logic from the result of sleep/wakeup
  */
 
-inline static void mac_wol_reset(struct mac_regs * regs)
+inline static void mac_wol_reset(struct mac_regs __iomem * regs)
 {
 
 	/* Turn off SWPTAG right after leaving power mode */
@@ -1739,10 +1739,6 @@
 	struct net_device *dev;
 	struct net_device_stats stats;
 
-#ifdef CONFIG_PM
-	u32 pci_state[16];
-#endif
-
 	dma_addr_t rd_pool_dma;
 	dma_addr_t td_pool_dma[TX_QUEUE_NO];
 
@@ -1752,7 +1748,7 @@
 	u8 ip_addr[4];
 	enum chip_type chip_id;
 
-	struct mac_regs * mac_regs;
+	struct mac_regs __iomem * mac_regs;
 	unsigned long memaddr;
 	unsigned long ioaddr;
 	u32 io_size;
@@ -1865,7 +1861,7 @@
 
 static inline void init_flow_control_register(struct velocity_info *vptr)
 {
-	struct mac_regs * regs = vptr->mac_regs;
+	struct mac_regs __iomem * regs = vptr->mac_regs;
 
 	/* Set {XHITH1, XHITH0, XLTH1, XLTH0} in FlowCR1 to {1, 0, 1, 1}
 	   depend on RD=64, and Turn on XNOEN in FlowCR1 */
diff -Nru a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c
--- a/drivers/net/wan/c101.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/net/wan/c101.c	2004-12-24 13:37:04 -08:00
@@ -56,7 +56,7 @@
 typedef struct card_s {
 	struct net_device *dev;
 	spinlock_t lock;	/* TX lock */
-	u8 *win0base;		/* ISA window base address */
+	u8 __iomem *win0base;	/* ISA window base address */
 	u32 phy_winbase;	/* ISA physical base address */
 	sync_serial_settings settings;
 	int rxpart;		/* partial frame received, next frame invalid*/
diff -Nru a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
--- a/drivers/net/wan/cosa.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/wan/cosa.c	2004-12-24 13:36:17 -08:00
@@ -156,7 +156,7 @@
 	unsigned short startaddr;	/* Firmware start address */
 	unsigned short busmaster;	/* Use busmastering? */
 	int nchannels;			/* # of channels on this card */
-	int driver_status;		/* For communicating with firware */
+	int driver_status;		/* For communicating with firmware */
 	int firmware_status;		/* Downloaded, reseted, etc. */
 	long int rxbitmap, txbitmap;	/* Bitmap of channels who are willing to send/receive data */
 	long int rxtx;			/* RX or TX in progress? */
diff -Nru a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c
--- a/drivers/net/wan/cycx_drv.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/wan/cycx_drv.c	2004-12-24 13:37:00 -08:00
@@ -70,8 +70,8 @@
 static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len);
 static void cycx_bootcfg(struct cycx_hw *hw);
 
-static int reset_cyc2x(void *addr);
-static int detect_cyc2x(void *addr);
+static int reset_cyc2x(void __iomem *addr);
+static int detect_cyc2x(void __iomem *addr);
 
 /* Miscellaneous functions */
 static void delay_cycx(int sec);
@@ -135,9 +135,8 @@
  * Return:	0	ok.
  *		< 0	error */
 EXPORT_SYMBOL(cycx_setup);
-int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len)
+int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len, unsigned long dpmbase)
 {
-	long dpmbase = (long)hw->dpmbase;
 	int err;
 
 	/* Verify IRQ configuration options */
@@ -203,7 +202,7 @@
  * o Set exec flag.
  * o Busy-wait until flag is reset. */
 EXPORT_SYMBOL(cycx_exec);
-int cycx_exec(void *addr)
+int cycx_exec(void __iomem *addr)
 {
 	u16 i = 0;
 	/* wait till addr content is zeroed */
@@ -249,7 +248,7 @@
 /* Load Aux Routines */
 /* Reset board hardware.
    return 1 if memory exists at addr and 0 if not. */
-static int memory_exists(void *addr)
+static int memory_exists(void __iomem *addr)
 {
 	int tries = 0;
 
@@ -267,9 +266,9 @@
 }
 
 /* Load reset code. */
-static void reset_load(void *addr, u8 *buffer, u32 cnt)
+static void reset_load(void __iomem *addr, u8 *buffer, u32 cnt)
 {
-	void *pt_code = addr + RESET_OFFSET;
+	void __iomem *pt_code = addr + RESET_OFFSET;
 	u16 i; /*, j; */
 
 	for (i = 0 ; i < cnt ; i++) {
@@ -281,7 +280,7 @@
 /* Load buffer using boot interface.
  * o copy data from buffer to Cyclom-X memory
  * o wait for reset code to copy it to right portion of memory */
-static int buffer_load(void *addr, u8 *buffer, u32 cnt)
+static int buffer_load(void __iomem *addr, u8 *buffer, u32 cnt)
 {
 	memcpy_toio(addr + DATA_OFFSET, buffer, cnt);
 	writew(GEN_BOOT_DAT, addr + CMD_OFFSET);
@@ -290,7 +289,7 @@
 }
 
 /* Set up entry point and kick start Cyclom-X CPU. */
-static void cycx_start(void *addr)
+static void cycx_start(void __iomem *addr)
 {
 	/* put in 0x30 offset the jump instruction to the code entry point */
 	writeb(0xea, addr + 0x30);
@@ -304,9 +303,9 @@
 }
 
 /* Load and boot reset code. */
-static void cycx_reset_boot(void *addr, u8 *code, u32 len)
+static void cycx_reset_boot(void __iomem *addr, u8 *code, u32 len)
 {
-	void *pt_start = addr + START_OFFSET;
+	void __iomem *pt_start = addr + START_OFFSET;
 
 	writeb(0xea, pt_start++); /* jmp to f000:3f00 */
 	writeb(0x00, pt_start++);
@@ -321,9 +320,9 @@
 }
 
 /* Load data.bin file through boot (reset) interface. */
-static int cycx_data_boot(void *addr, u8 *code, u32 len)
+static int cycx_data_boot(void __iomem *addr, u8 *code, u32 len)
 {
-	void *pt_boot_cmd = addr + CMD_OFFSET;
+	void __iomem *pt_boot_cmd = addr + CMD_OFFSET;
 	u32 i;
 
 	/* boot buffer lenght */
@@ -352,9 +351,9 @@
 
 
 /* Load code.bin file through boot (reset) interface. */
-static int cycx_code_boot(void *addr, u8 *code, u32 len)
+static int cycx_code_boot(void __iomem *addr, u8 *code, u32 len)
 {
-	void *pt_boot_cmd = addr + CMD_OFFSET;
+	void __iomem *pt_boot_cmd = addr + CMD_OFFSET;
 	u32 i;
 
 	/* boot buffer lenght */
@@ -391,7 +390,7 @@
 	u8 *reset_image,
 	   *data_image,
 	   *code_image;
-	void *pt_cycld = hw->dpmbase + 0x400;
+	void __iomem *pt_cycld = hw->dpmbase + 0x400;
 	u16 cksum;
 
 	/* Announce */
@@ -523,7 +522,7 @@
  *	Return 1 if detected o.k. or 0 if failed.
  *	Note:	This test is destructive! Adapter will be left in shutdown
  *		state after the test. */
-static int detect_cyc2x(void *addr)
+static int detect_cyc2x(void __iomem *addr)
 {
 	reset_cyc2x(addr);
 
@@ -545,7 +544,7 @@
 }
 
 /* Reset adapter's CPU. */
-static int reset_cyc2x(void *addr)
+static int reset_cyc2x(void __iomem *addr)
 {
 	writeb(0, addr + RST_ENABLE);
 	delay_cycx(2);
diff -Nru a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c
--- a/drivers/net/wan/cycx_main.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/wan/cycx_main.c	2004-12-24 13:36:49 -08:00
@@ -223,13 +223,12 @@
 	/* Configure hardware, load firmware, etc. */
 	memset(&card->hw, 0, sizeof(card->hw));
 	card->hw.irq	 = irq;
-	card->hw.dpmbase = (void *)conf->maddr;
 	card->hw.dpmsize = CYCX_WINDOWSIZE;
 	card->hw.fwid	 = CFID_X25_2X;
-	card->lock	 = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&card->lock);
 	init_waitqueue_head(&card->wait_stats);
 
-	rc = cycx_setup(&card->hw, conf->data, conf->data_size);
+	rc = cycx_setup(&card->hw, conf->data, conf->data_size, conf->maddr);
 	if (rc)
 		goto out_irq;
 
diff -Nru a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
--- a/drivers/net/wan/cycx_x25.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/net/wan/cycx_x25.c	2004-12-24 13:36:19 -08:00
@@ -92,6 +92,8 @@
 #include <linux/cyclomx.h>	/* Cyclom 2X common user API definitions */
 #include <linux/cycx_x25.h>	/* X.25 firmware API definitions */
 
+#include <net/x25device.h>
+
 /* Defines & Macros */
 #define CYCX_X25_MAX_CMD_RETRY 5
 #define CYCX_X25_CHAN_MTU 2048	/* unfragmented logical channel MTU */
@@ -231,7 +233,7 @@
 	/* Initialize protocol-specific fields */
 	card->mbox  = card->hw.dpmbase + X25_MBOX_OFFS;
 	card->u.x.connection_keys = 0;
-	card->u.x.lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&card->u.x.lock);
 
 	/* Configure adapter. Here we set reasonable defaults, then parse
 	 * device configuration structure and set configuration options.
@@ -1195,7 +1197,7 @@
 	     remotelen = strlen(chan->addr);
 	u8 key;
 
-	if (card->u.x.connection_keys == ~0UL) {
+	if (card->u.x.connection_keys == ~0U) {
 		printk(KERN_INFO "%s: too many simultaneous connection "
 				 "requests!\n", card->devname);
 		return -EAGAIN;
@@ -1486,11 +1488,7 @@
 	ptr  = skb_put(skb, 1);
 	*ptr = event;
 
-	skb->dev = dev;
-	skb->protocol = htons(ETH_P_X25);
-	skb->mac.raw = skb->data;
-	skb->pkt_type = PACKET_HOST;
-
+	skb->protocol = x25_type_trans(skb, dev);
 	netif_rx(skb);
 	dev->last_rx = jiffies;		/* timestamp */
 }
diff -Nru a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
--- a/drivers/net/wan/dlci.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/wan/dlci.c	2004-12-24 13:36:49 -08:00
@@ -45,11 +45,11 @@
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
 #include <linux/if_frad.h>
+#include <linux/bitops.h>
 
 #include <net/sock.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/uaccess.h>
diff -Nru a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
--- a/drivers/net/wan/dscc4.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/wan/dscc4.c	2004-12-24 13:37:43 -08:00
@@ -230,6 +230,7 @@
 	unsigned short parity;
 	struct net_device *dev;
 	sync_serial_settings settings;
+	void __iomem *base_addr;
 	u32 __pad __attribute__ ((aligned (4)));
 };
 
@@ -353,7 +354,7 @@
 /* Functions prototypes */
 static void dscc4_rx_irq(struct dscc4_pci_priv *, struct dscc4_dev_priv *);
 static void dscc4_tx_irq(struct dscc4_pci_priv *, struct dscc4_dev_priv *);
-static int dscc4_found1(struct pci_dev *, unsigned long ioaddr);
+static int dscc4_found1(struct pci_dev *, void __iomem *ioaddr);
 static int dscc4_init_one(struct pci_dev *, const struct pci_device_id *ent);
 static int dscc4_open(struct net_device *);
 static int dscc4_start_xmit(struct sk_buff *, struct net_device *);
@@ -390,7 +391,7 @@
 	state &= ~mask;
 	state |= value;
 	dpriv->scc_regs[offset >> 2] = state;
-	writel(state, dev->base_addr + SCC_REG_START(dpriv) + offset);
+	writel(state, dpriv->base_addr + SCC_REG_START(dpriv) + offset);
 }
 
 static void scc_writel(u32 bits, struct dscc4_dev_priv *dpriv,
@@ -401,7 +402,7 @@
 	 * As of 2002/02/16, there are no thread racing for access.
 	 */
 	dpriv->scc_regs[offset >> 2] = bits;
-	writel(bits, dev->base_addr + SCC_REG_START(dpriv) + offset);
+	writel(bits, dpriv->base_addr + SCC_REG_START(dpriv) + offset);
 }
 
 static inline u32 scc_readl(struct dscc4_dev_priv *dpriv, int offset)
@@ -412,8 +413,8 @@
 static u32 scc_readl_star(struct dscc4_dev_priv *dpriv, struct net_device *dev)
 {
 	/* Cf errata DS5 p.4 */
-	readl(dev->base_addr + SCC_REG_START(dpriv) + STAR);
-	return readl(dev->base_addr + SCC_REG_START(dpriv) + STAR);
+	readl(dpriv->base_addr + SCC_REG_START(dpriv) + STAR);
+	return readl(dpriv->base_addr + SCC_REG_START(dpriv) + STAR);
 }
 
 static inline void dscc4_do_tx(struct dscc4_dev_priv *dpriv,
@@ -421,9 +422,9 @@
 {
 	dpriv->ltda = dpriv->tx_fd_dma +
                       ((dpriv->tx_current-1)%TX_RING_SIZE)*sizeof(struct TxFD);
-	writel(dpriv->ltda, dev->base_addr + CH0LTDA + dpriv->dev_id*4);
+	writel(dpriv->ltda, dpriv->base_addr + CH0LTDA + dpriv->dev_id*4);
 	/* Flush posted writes *NOW* */
-	readl(dev->base_addr + CH0LTDA + dpriv->dev_id*4);
+	readl(dpriv->base_addr + CH0LTDA + dpriv->dev_id*4);
 }
 
 static inline void dscc4_rx_update(struct dscc4_dev_priv *dpriv,
@@ -431,7 +432,7 @@
 {
 	dpriv->lrda = dpriv->rx_fd_dma +
 		      ((dpriv->rx_dirty - 1)%RX_RING_SIZE)*sizeof(struct RxFD);
-	writel(dpriv->lrda, dev->base_addr + CH0LRDA + dpriv->dev_id*4);
+	writel(dpriv->lrda, dpriv->base_addr + CH0LRDA + dpriv->dev_id*4);
 }
 
 static inline unsigned int dscc4_tx_done(struct dscc4_dev_priv *dpriv)
@@ -442,7 +443,7 @@
 static inline unsigned int dscc4_tx_quiescent(struct dscc4_dev_priv *dpriv,
 					      struct net_device *dev)
 {
-	return readl(dev->base_addr + CH0FTDA + dpriv->dev_id*4) == dpriv->ltda;
+	return readl(dpriv->base_addr + CH0FTDA + dpriv->dev_id*4) == dpriv->ltda;
 }
 
 int state_check(u32 state, struct dscc4_dev_priv *dpriv, struct net_device *dev,
@@ -517,9 +518,7 @@
 	skb = dev_alloc_skb(len);
 	dpriv->rx_skbuff[dirty] = skb;
 	if (skb) {
-		skb->dev = dev;
 		skb->protocol = hdlc_type_trans(skb, dev);
-		skb->mac.raw = skb->data;
 		rx_fd->data = pci_map_single(dpriv->pci_priv->pdev, skb->data,
 					     len, PCI_DMA_FROMDEVICE);
 	} else {
@@ -554,7 +553,7 @@
 
 static int dscc4_do_action(struct net_device *dev, char *msg)
 {
-	unsigned long ioaddr = dev->base_addr;
+	void __iomem *ioaddr = dscc4_priv(dev)->base_addr;
 	s16 i = 0;
 
 	writel(Action, ioaddr + GCMDR);
@@ -603,11 +602,11 @@
 
 	spin_lock_irqsave(&dpriv->pci_priv->lock, flags);
 	/* Cf errata DS5 p.6 */
-	writel(0x00000000, dev->base_addr + CH0LRDA + dpriv->dev_id*4);
+	writel(0x00000000, dpriv->base_addr + CH0LRDA + dpriv->dev_id*4);
 	scc_patchl(PowerUp, 0, dpriv, dev, CCR0);
-	readl(dev->base_addr + CH0LRDA + dpriv->dev_id*4);
-	writel(MTFi|Rdr, dev->base_addr + dpriv->dev_id*0x0c + CH0CFG);
-	writel(Action, dev->base_addr + GCMDR);
+	readl(dpriv->base_addr + CH0LRDA + dpriv->dev_id*4);
+	writel(MTFi|Rdr, dpriv->base_addr + dpriv->dev_id*0x0c + CH0CFG);
+	writel(Action, dpriv->base_addr + GCMDR);
 	spin_unlock_irqrestore(&dpriv->pci_priv->lock, flags);
 }
 
@@ -629,7 +628,7 @@
 		wmb();
 	}
 
-	writel(MTFi|Rdt, dev->base_addr + dpriv->dev_id*0x0c + CH0CFG);
+	writel(MTFi|Rdt, dpriv->base_addr + dpriv->dev_id*0x0c + CH0CFG);
 	if (dscc4_do_action(dev, "Rdt") < 0)
 		printk(KERN_ERR "%s: Tx reset failed\n", dev->name);
 }
@@ -708,7 +707,7 @@
 	struct dscc4_pci_priv *priv;
 	struct dscc4_dev_priv *dpriv;
 	static int cards_found = 0;
-	unsigned long ioaddr;
+	void __iomem *ioaddr;
 	int i;
 
 	printk(KERN_DEBUG "%s", version);
@@ -727,7 +726,7 @@
 			DRV_NAME);
 	        goto err_out_free_mmio_region0;
 	}
-	ioaddr = (unsigned long)ioremap(pci_resource_start(pdev, 0),
+	ioaddr = ioremap(pci_resource_start(pdev, 0),
 					pci_resource_len(pdev, 0));
 	if (!ioaddr) {
 		printk(KERN_ERR "%s: cannot remap MMIO region %lx @ %lx\n",
@@ -828,7 +827,7 @@
 err_out_free1:
 	dscc4_free1(pdev);
 err_out_iounmap:
-	iounmap ((void *)ioaddr);
+	iounmap (ioaddr);
 err_out_free_mmio_region:
 	release_mem_region(pci_resource_start(pdev, 1),
 			   pci_resource_len(pdev, 1));
@@ -877,7 +876,7 @@
 	return ret;
 }
 
-static int dscc4_found1(struct pci_dev *pdev, unsigned long ioaddr)
+static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
 {
 	struct dscc4_pci_priv *ppriv;
 	struct dscc4_dev_priv *root;
@@ -917,7 +916,7 @@
 		struct net_device *d = dscc4_to_dev(dpriv);
 		hdlc_device *hdlc = dev_to_hdlc(d);
 
-	        d->base_addr = ioaddr;
+	        d->base_addr = (unsigned long)ioaddr;
 		d->init = NULL;
 	        d->irq = pdev->irq;
 	        d->open = dscc4_open;
@@ -931,6 +930,7 @@
 
 		dpriv->dev_id = i;
 		dpriv->pci_priv = ppriv;
+		dpriv->base_addr = ioaddr;
 		spin_lock_init(&dpriv->lock);
 
 		hdlc->xmit = dscc4_start_xmit;
@@ -1009,7 +1009,7 @@
  *
  * This code doesn't need to be efficient. Keep It Simple
  */
-static void dscc4_pci_reset(struct pci_dev *pdev, unsigned long ioaddr)
+static void dscc4_pci_reset(struct pci_dev *pdev, void __iomem *ioaddr)
 {
 	int i;
 
@@ -1476,7 +1476,7 @@
 	struct dscc4_dev_priv *root = token;
 	struct dscc4_pci_priv *priv;
 	struct net_device *dev;
-	unsigned long ioaddr;
+	void __iomem *ioaddr;
 	u32 state;
 	unsigned long flags;
 	int i, handled = 1;
@@ -1486,7 +1486,7 @@
 
 	spin_lock_irqsave(&priv->lock, flags);
 
-	ioaddr = dev->base_addr;
+	ioaddr = root->base_addr;
 
 	state = readl(ioaddr + GSTAR);
 	if (!state) {
@@ -1613,8 +1613,8 @@
 			dpriv->flags = NeedIDT;
 			/* Tx reset */
 			writel(MTFi | Rdt,
-			       dev->base_addr + 0x0c*dpriv->dev_id + CH0CFG);
-			writel(Action, dev->base_addr + GCMDR);
+			       dpriv->base_addr + 0x0c*dpriv->dev_id + CH0CFG);
+			writel(Action, dpriv->base_addr + GCMDR);
 			return;
 		}
 		if (state & Cts) {
@@ -1629,7 +1629,8 @@
 				goto try;
 		}
 		if (state & Xpr) {
-			unsigned long scc_addr, ring;
+			void __iomem *scc_addr;
+			unsigned long ring;
 			int i;
 
 			/*
@@ -1643,7 +1644,7 @@
 			if (!i)
 				printk(KERN_INFO "%s busy in irq\n", dev->name);
 
-			scc_addr = dev->base_addr + 0x0c*dpriv->dev_id;
+			scc_addr = dpriv->base_addr + 0x0c*dpriv->dev_id;
 			/* Keep this order: IDT before IDR */
 			if (dpriv->flags & NeedIDT) {
 				if (debug > 2)
@@ -1801,12 +1802,12 @@
 		 */
 		if (state & Rdo) {
 			struct RxFD *rx_fd;
-			u32 scc_addr;
+			void __iomem *scc_addr;
 			int cur;
 
 			//if (debug)
 			//	dscc4_rx_dump(dpriv);
-			scc_addr = dev->base_addr + 0x0c*dpriv->dev_id;
+			scc_addr = dpriv->base_addr + 0x0c*dpriv->dev_id;
 
 			scc_patchl(RxActivate, 0, dpriv, dev, CCR2);
 			/*
@@ -1970,13 +1971,13 @@
 {
 	struct dscc4_pci_priv *ppriv;
 	struct dscc4_dev_priv *root;
-	unsigned long ioaddr;
+	void __iomem *ioaddr;
 	int i;
 
 	ppriv = pci_get_drvdata(pdev);
 	root = ppriv->root;
 
-	ioaddr = dscc4_to_dev(root)->base_addr;
+	ioaddr = root->base_addr;
 
 	dscc4_pci_reset(pdev, ioaddr);
 
@@ -1995,7 +1996,7 @@
 
 	dscc4_free1(pdev);
 
-	iounmap((void *)ioaddr);
+	iounmap(ioaddr);
 
 	release_mem_region(pci_resource_start(pdev, 1),
 			   pci_resource_len(pdev, 1));
diff -Nru a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
--- a/drivers/net/wan/farsync.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/net/wan/farsync.c	2004-12-24 13:37:02 -08:00
@@ -411,7 +411,7 @@
 };
 
 /* Calculate offset of a buffer object within the shared memory window */
-#define BUF_OFFSET(X)   ((unsigned int)&(((struct buf_window *)BFM_BASE)->X))
+#define BUF_OFFSET(X)   (BFM_BASE + offsetof(struct buf_window, X))
 
 #pragma pack()
 
@@ -443,8 +443,8 @@
 /*      Per card information
  */
 struct fst_card_info {
-	char *mem;		/* Card memory mapped to kernel space */
-	char *ctlmem;		/* Control memory for PCI cards */
+	char __iomem *mem;	/* Card memory mapped to kernel space */
+	char __iomem *ctlmem;	/* Control memory for PCI cards */
 	unsigned int phys_mem;	/* Physical memory window address */
 	unsigned int phys_ctlmem;	/* Physical control memory address */
 	unsigned int irq;	/* Interrupt request line number */
@@ -781,7 +781,7 @@
 	}
 }
 
-/*      Process the result of trying to pass a recieved frame up the stack
+/*      Process the result of trying to pass a received frame up the stack
  */
 static void
 fst_process_rx_status(int rx_status, char *name)
@@ -857,6 +857,18 @@
 	dev->trans_start = jiffies;
 }
 
+/*
+ * Mark it for our own raw sockets interface
+ */
+static unsigned short farsync_type_trans(struct sk_buff *skb,
+					 struct net_device *dev)
+{
+	skb->dev = dev;
+	skb->mac.raw = skb->data;
+	skb->pkt_type = PACKET_HOST;
+	return htons(ETH_P_CUST);
+}
+
 /*      Rx dma complete interrupt
  */
 static void
@@ -881,17 +893,10 @@
 
 	/* Push upstream */
 	dbg(DBG_RX, "Pushing the frame up the stack\n");
-	skb->mac.raw = skb->data;
-	skb->dev = dev;
-	if (port->mode == FST_RAW) {
-		/*
-		 * Mark it for our own raw sockets interface
-		 */
-		skb->protocol = htons(ETH_P_CUST);
-		skb->pkt_type = PACKET_HOST;
-	} else {
-		skb->protocol = hdlc_type_trans(skb, skb->dev);
-	}
+	if (port->mode == FST_RAW)
+		skb->protocol = farsync_type_trans(skb, dev);
+	else
+		skb->protocol = hdlc_type_trans(skb, dev);
 	rx_status = netif_rx(skb);
 	fst_process_rx_status(rx_status, port_to_dev(port)->name);
 	if (rx_status == NET_RX_DROP)
@@ -1316,17 +1321,10 @@
 
 		/* Push upstream */
 		dbg(DBG_RX, "Pushing frame up the stack\n");
-		skb->mac.raw = skb->data;
-		skb->dev = dev;
-		if (port->mode == FST_RAW) {
-			/*
-			 * Mark it for our own raw sockets interface
-			 */
-			skb->protocol = htons(ETH_P_CUST);
-			skb->pkt_type = PACKET_HOST;
-		} else {
-			skb->protocol = hdlc_type_trans(skb, skb->dev);
-		}
+		if (port->mode == FST_RAW)
+			skb->protocol = farsync_type_trans(skb, dev);
+		else
+			skb->protocol = hdlc_type_trans(skb, dev);
 		rx_status = netif_rx(skb);
 		fst_process_rx_status(rx_status, port_to_dev(port)->name);
 		if (rx_status == NET_RX_DROP) {
diff -Nru a/drivers/net/wan/hd6457x.c b/drivers/net/wan/hd6457x.c
--- a/drivers/net/wan/hd6457x.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/net/wan/hd6457x.c	2004-12-24 13:36:31 -08:00
@@ -38,9 +38,9 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
@@ -148,13 +148,13 @@
 
 
 
-static inline pkt_desc* desc_address(port_t *port, u16 desc, int transmit)
+static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc, int transmit)
 {
 #ifdef PAGE0_ALWAYS_MAPPED
-	return (pkt_desc*)(win0base(port_to_card(port))
+	return (pkt_desc __iomem *)(win0base(port_to_card(port))
 			   + desc_offset(port, desc, transmit));
 #else
-	return (pkt_desc*)(winbase(port_to_card(port))
+	return (pkt_desc __iomem *)(winbase(port_to_card(port))
 			   + desc_offset(port, desc, transmit));
 #endif
 }
@@ -188,7 +188,7 @@
 			: card->rx_ring_buffers;
 
 		for (i = 0; i < buffs; i++) {
-			pkt_desc* desc = desc_address(port, i, transmit);
+			pkt_desc __iomem *desc = desc_address(port, i, transmit);
 			u16 chain_off = desc_offset(port, i + 1, transmit);
 			u32 buff_off = buffer_offset(port, i, transmit);
 
@@ -269,7 +269,7 @@
 
 
 
-static inline void sca_rx(card_t *card, port_t *port, pkt_desc *desc, u16 rxin)
+static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u16 rxin)
 {
 	struct net_device *dev = port_to_dev(port);
 	struct net_device_stats *stats = hdlc_stats(dev);
@@ -315,8 +315,6 @@
 #endif
 	stats->rx_packets++;
 	stats->rx_bytes += skb->len;
-	skb->mac.raw = skb->data;
-	skb->dev = dev;
 	skb->dev->last_rx = jiffies;
 	skb->protocol = hdlc_type_trans(skb, dev);
 	netif_rx(skb);
@@ -341,7 +339,7 @@
 
 	while (1) {
 		u32 desc_off = desc_offset(port, port->rxin, 0);
-		pkt_desc *desc;
+		pkt_desc __iomem *desc;
 		u32 cda = sca_ina(dmac + CDAL, card);
 
 		if ((cda >= desc_off) && (cda < desc_off + sizeof(pkt_desc)))
@@ -392,7 +390,7 @@
 		DSR_TX(phy_node(port)), card);
 
 	while (1) {
-		pkt_desc *desc;
+		pkt_desc __iomem *desc;
 
 		u32 desc_off = desc_offset(port, port->txlast, 1);
 		u32 cda = sca_ina(dmac + CDAL, card);
@@ -730,7 +728,7 @@
 {
 	port_t *port = dev_to_port(dev);
 	card_t *card = port_to_card(port);
-	pkt_desc *desc;
+	pkt_desc __iomem *desc;
 	u32 buff, len;
 #ifndef ALL_PAGES_ALWAYS_MAPPED
 	u8 page;
@@ -799,7 +797,7 @@
 
 
 #ifdef NEED_DETECT_RAM
-static u32 __devinit sca_detect_ram(card_t *card, u8 *rambase, u32 ramsize)
+static u32 __devinit sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize)
 {
 	/* Round RAM size to 32 bits, fill from end to start */
 	u32 i = ramsize &= ~3;
diff -Nru a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c
--- a/drivers/net/wan/hdlc_x25.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/net/wan/hdlc_x25.c	2004-12-24 13:37:32 -08:00
@@ -23,6 +23,8 @@
 #include <linux/rtnetlink.h>
 #include <linux/hdlc.h>
 
+#include <net/x25device.h>
+
 /* These functions are callbacks called by LAPB layer */
 
 static void x25_connect_disconnect(struct net_device *dev, int reason, int code)
@@ -38,11 +40,7 @@
 	ptr = skb_put(skb, 1);
 	*ptr = code;
 
-	skb->dev = dev;
-	skb->protocol = htons(ETH_P_X25);
-	skb->mac.raw = skb->data;
-	skb->pkt_type = PACKET_HOST;
-
+	skb->protocol = x25_type_trans(skb, dev);
 	netif_rx(skb);
 }
 
@@ -74,11 +72,7 @@
 	ptr  = skb->data;
 	*ptr = 0;
 
-	skb->dev = dev;
-	skb->protocol = htons(ETH_P_X25);
-	skb->mac.raw = skb->data;
-	skb->pkt_type = PACKET_HOST;
-
+	skb->protocol = x25_type_trans(skb, dev);
 	return netif_rx(skb);
 }
 
diff -Nru a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
--- a/drivers/net/wan/lapbether.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/wan/lapbether.c	2004-12-24 13:36:47 -08:00
@@ -43,6 +43,8 @@
 #include <linux/lapb.h>
 #include <linux/init.h>
 
+#include <net/x25device.h>
+
 static char bcast_addr[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
 
 /* If this number is made larger, check that the temporary string buffer
@@ -137,11 +139,7 @@
 	ptr  = skb->data;
 	*ptr = 0x00;
 
-	skb->dev      = dev;
-	skb->protocol = htons(ETH_P_X25);
-	skb->mac.raw  = skb->data;
-	skb->pkt_type = PACKET_HOST;
-
+	skb->protocol = x25_type_trans(skb, dev);
 	skb->dev->last_rx = jiffies;
 	return netif_rx(skb);
 }
@@ -233,11 +231,7 @@
 	ptr  = skb_put(skb, 1);
 	*ptr = 0x01;
 
-	skb->dev      = dev;
-	skb->protocol = htons(ETH_P_X25);
-	skb->mac.raw  = skb->data;
-	skb->pkt_type = PACKET_HOST;
-
+	skb->protocol = x25_type_trans(skb, dev);
 	skb->dev->last_rx = jiffies;
 	netif_rx(skb);
 }
@@ -255,11 +249,7 @@
 	ptr  = skb_put(skb, 1);
 	*ptr = 0x02;
 
-	skb->dev      = dev;
-	skb->protocol = htons(ETH_P_X25);
-	skb->mac.raw  = skb->data;
-	skb->pkt_type = PACKET_HOST;
-
+	skb->protocol = x25_type_trans(skb, dev);
 	skb->dev->last_rx = jiffies;
 	netif_rx(skb);
 }
diff -Nru a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
--- a/drivers/net/wan/lmc/lmc_main.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/net/wan/lmc/lmc_main.c	2004-12-24 13:36:34 -08:00
@@ -56,11 +56,11 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/inet.h>
+#include <linux/bitops.h>
 
 #include <net/syncppp.h>
 
 #include <asm/processor.h>             /* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/uaccess.h>
@@ -101,7 +101,6 @@
 static int lmc_close(struct net_device *dev);
 static struct net_device_stats *lmc_get_stats(struct net_device *dev);
 static irqreturn_t lmc_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
-static int lmc_set_config(struct net_device *dev, struct ifmap *map);
 static void lmc_initcsrs(lmc_softc_t * const sc, lmc_csrptr_t csr_base, size_t csr_size);
 static void lmc_softreset(lmc_softc_t * const);
 static void lmc_running_reset(struct net_device *dev);
@@ -814,7 +813,6 @@
     dev->stop = lmc_close;
     dev->get_stats = lmc_get_stats;
     dev->do_ioctl = lmc_ioctl;
-    dev->set_config = lmc_set_config;
     dev->tx_timeout = lmc_driver_timeout;
     dev->watchdog_timeo = (HZ); /* 1 second */
     
@@ -1973,13 +1971,6 @@
     LMC_CSR_WRITE (sc, csr_txlist, virt_to_bus (sc->lmc_txring));
 
     lmc_trace(sc->lmc_device, "lmc_softreset out");
-}
-
-static int lmc_set_config(struct net_device *dev, struct ifmap *map) /*fold00*/
-{
-    lmc_trace(dev, "lmc_set_config in");
-    lmc_trace(dev, "lmc_set_config out");
-    return -EOPNOTSUPP;
 }
 
 void lmc_gpio_mkinput(lmc_softc_t * const sc, u_int32_t bits) /*fold00*/
diff -Nru a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
--- a/drivers/net/wan/lmc/lmc_media.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/wan/lmc/lmc_media.c	2004-12-24 13:37:19 -08:00
@@ -16,11 +16,11 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/inet.h>
+#include <linux/bitops.h>
 
 #include <net/syncppp.h>
 
 #include <asm/processor.h>             /* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/net/wan/lmc/lmc_proto.c b/drivers/net/wan/lmc/lmc_proto.c
--- a/drivers/net/wan/lmc/lmc_proto.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/net/wan/lmc/lmc_proto.c	2004-12-24 13:36:56 -08:00
@@ -36,11 +36,11 @@
 #include <linux/inet.h>
 #include <linux/workqueue.h>
 #include <linux/proc_fs.h>
+#include <linux/bitops.h>
 
 #include <net/syncppp.h>
 
 #include <asm/processor.h>             /* Processor type for cache alignment. */
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <linux/smp.h>
diff -Nru a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
--- a/drivers/net/wan/n2.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/wan/n2.c	2004-12-24 13:36:31 -08:00
@@ -111,7 +111,7 @@
 
 
 typedef struct card_s {
-	u8 *winbase;		/* ISA window base address */
+	u8 __iomem *winbase;		/* ISA window base address */
 	u32 phy_winbase;	/* ISA physical base address */
 	u32 ram_size;		/* number of bytes */
 	u16 io;			/* IO Base address */
diff -Nru a/drivers/net/wan/pc300.h b/drivers/net/wan/pc300.h
--- a/drivers/net/wan/pc300.h	2004-12-24 13:36:32 -08:00
+++ b/drivers/net/wan/pc300.h	2004-12-24 13:36:32 -08:00
@@ -105,14 +105,10 @@
 
 #ifndef CY_TYPES
 #define CY_TYPES
-#if defined(__alpha__)
-typedef	unsigned long	ucdouble;	/* 64 bits, unsigned */
-typedef	unsigned int	uclong;		/* 32 bits, unsigned */
-#else
-typedef	unsigned long	uclong;		/* 32 bits, unsigned */
-#endif
-typedef	unsigned short	ucshort;	/* 16 bits, unsigned */
-typedef	unsigned char	ucchar;		/* 8 bits, unsigned */
+typedef	__u64	ucdouble;	/* 64 bits, unsigned */
+typedef	__u32	uclong;		/* 32 bits, unsigned */
+typedef	__u16	ucshort;	/* 16 bits, unsigned */
+typedef	__u8	ucchar;		/* 8 bits, unsigned */
 #endif /* CY_TYPES */
 
 #define PC300_PROTO_MLPPP 1		
diff -Nru a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
--- a/drivers/net/wan/pc300_drv.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/wan/pc300_drv.c	2004-12-24 13:37:29 -08:00
@@ -378,9 +378,9 @@
 	     i != ((next_bd + 1) & (N_DMA_TX_BUF - 1));
 	     i = (i + 1) & (N_DMA_TX_BUF - 1), 
 		 ptdescr = (card->hw.rambase + TX_BD_ADDR(ch, i))) {
-		printk("\n CH%d TX%d: next=0x%lx, ptbuf=0x%lx, ST=0x%x, len=%d",
-		       ch, i, (uclong) cpc_readl(&ptdescr->next),
-		       (uclong) cpc_readl(&ptdescr->ptbuf),
+		printk("\n CH%d TX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+		       ch, i, cpc_readl(&ptdescr->next),
+		       cpc_readl(&ptdescr->ptbuf),
 		       cpc_readb(&ptdescr->status), cpc_readw(&ptdescr->len));
 	}
 	printk("\n");
@@ -400,14 +400,14 @@
 	printk("#CH%d: f_bd = %d(0x%08x), n_bd = %d(0x%08x)\n", ch,
 	       first_bd, TX_BD_ADDR(ch, first_bd),
 	       next_bd, TX_BD_ADDR(ch, next_bd));
-	printk("TX_CDA=0x%08lx, TX_EDA=0x%08lx\n",
-	       (uclong) cpc_readl(scabase + DTX_REG(CDAL, ch)),
-	       (uclong) cpc_readl(scabase + DTX_REG(EDAL, ch)));
+	printk("TX_CDA=0x%08x, TX_EDA=0x%08x\n",
+	       cpc_readl(scabase + DTX_REG(CDAL, ch)),
+	       cpc_readl(scabase + DTX_REG(EDAL, ch)));
 	for (i = 0; i < N_DMA_TX_BUF; i++) {
 		ptdescr = (card->hw.rambase + TX_BD_ADDR(ch, i));
-		printk("\n CH%d TX%d: next=0x%lx, ptbuf=0x%lx, ST=0x%x, len=%d",
-		       ch, i, (uclong) cpc_readl(&ptdescr->next),
-		       (uclong) cpc_readl(&ptdescr->ptbuf),
+		printk("\n CH%d TX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+		       ch, i, cpc_readl(&ptdescr->next),
+		       cpc_readl(&ptdescr->ptbuf),
 		       cpc_readb(&ptdescr->status), cpc_readw(&ptdescr->len));
 	}
 	printk("\n");
@@ -428,9 +428,9 @@
 					      DMA_RX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
 	     i < N_DMA_RX_BUF; i++, ptdescr++) {
 		if (cpc_readb(&ptdescr->status) & DST_OSB)
-			printk ("\n CH%d RX%d: next=0x%lx, ptbuf=0x%lx, ST=0x%x, len=%d",
-				 ch, i, (uclong) cpc_readl(&ptdescr->next),
-				 (uclong) cpc_readl(&ptdescr->ptbuf),
+			printk ("\n CH%d RX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+				 ch, i, cpc_readl(&ptdescr->next),
+				 cpc_readl(&ptdescr->ptbuf),
 				 cpc_readb(&ptdescr->status),
 				 cpc_readw(&ptdescr->len));
 	}
@@ -1959,7 +1959,6 @@
 			cpc_trace(dev, skb, 'R');
 		}
 		stats->rx_packets++;
-		skb->mac.raw = skb->data;
 		skb->protocol = hdlc_type_trans(skb, dev);
 		netif_rx(skb);
 	}
@@ -2416,12 +2415,12 @@
 	printk ("ILAR=0x%02x, WCRL=0x%02x, PCR=0x%02x, BTCR=0x%02x, BOLR=0x%02x\n",
 		 ilar, cpc_readb(scabase + WCRL), cpc_readb(scabase + PCR),
 		 cpc_readb(scabase + BTCR), cpc_readb(scabase + BOLR));
-	printk("TX_CDA=0x%08lx, TX_EDA=0x%08lx\n",
-	       (uclong) cpc_readl(scabase + DTX_REG(CDAL, ch)),
-	       (uclong) cpc_readl(scabase + DTX_REG(EDAL, ch)));
-	printk("RX_CDA=0x%08lx, RX_EDA=0x%08lx, BFL=0x%04x\n",
-	       (uclong) cpc_readl(scabase + DRX_REG(CDAL, ch)),
-	       (uclong) cpc_readl(scabase + DRX_REG(EDAL, ch)),
+	printk("TX_CDA=0x%08x, TX_EDA=0x%08x\n",
+	       cpc_readl(scabase + DTX_REG(CDAL, ch)),
+	       cpc_readl(scabase + DTX_REG(EDAL, ch)));
+	printk("RX_CDA=0x%08x, RX_EDA=0x%08x, BFL=0x%04x\n",
+	       cpc_readl(scabase + DRX_REG(CDAL, ch)),
+	       cpc_readl(scabase + DRX_REG(EDAL, ch)),
 	       cpc_readw(scabase + DRX_REG(BFLL, ch)));
 	printk("DMER=0x%02x, DSR_TX=0x%02x, DSR_RX=0x%02x\n",
 	       cpc_readb(scabase + DMER), cpc_readb(scabase + DSR_TX(ch)),
@@ -2486,7 +2485,7 @@
 	       cpc_readb(scabase + M_REG(IE2, ch)),
 	       cpc_readb(scabase + M_REG(IE4, ch)),
 	       cpc_readb(scabase + M_REG(FIE, ch)));
-	printk("IER0=0x%08lx\n", (uclong) cpc_readl(scabase + IER0));
+	printk("IER0=0x%08x\n", cpc_readl(scabase + IER0));
 
 	if (ilar != 0) {
 		CPC_LOCK(card, flags);
@@ -3407,12 +3406,12 @@
 					printk("RSV ");
 					break;
 			}
-			printk (" #%d, %ldKB of RAM at 0x%08lx, IRQ%d, channel %d.\n",
+			printk (" #%d, %dKB of RAM at 0x%08x, IRQ%d, channel %d.\n",
 				 board_nbr, card->hw.ramsize / 1024,
 				 card->hw.ramphys, card->hw.irq, i + 1);
 			devcount++;
 		} else {
-			printk ("Dev%d on card(0x%08lx): unable to allocate i/f name.\n",
+			printk ("Dev%d on card(0x%08x): unable to allocate i/f name.\n",
 				 i + 1, card->hw.ramphys);
 			free_netdev(dev);
 			continue;
@@ -3492,7 +3491,7 @@
 	if (!request_region(card->hw.iophys, card->hw.iosize, "PLX Registers")) {
 		/* In case we can't allocate it, warn user */
 		printk("WARNING: couldn't allocate I/O region for PC300 board "
-		       "at 0x%08lx!\n", card->hw.ramphys);
+		       "at 0x%08x!\n", card->hw.ramphys);
 	}
 
 	if (card->hw.plxphys) {
@@ -3505,7 +3504,7 @@
 
 	if (!request_mem_region(card->hw.plxphys, card->hw.plxsize,
 				"PLX Registers")) {
-		printk("PC300 found at RAM 0x%08lx, "
+		printk("PC300 found at RAM 0x%08x, "
 		       "but could not allocate PLX mem region.\n",
 		       card->hw.ramphys);
 		err = -ENODEV;
@@ -3513,7 +3512,7 @@
 	}
 	if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize,
 				"On-board RAM")) {
-		printk("PC300 found at RAM 0x%08lx, "
+		printk("PC300 found at RAM 0x%08x, "
 		       "but could not allocate RAM mem region.\n",
 		       card->hw.ramphys);
 		err = -ENODEV;
@@ -3521,7 +3520,7 @@
 	}
 	if (!request_mem_region(card->hw.scaphys, card->hw.scasize,
 				"SCA-II Registers")) {
-		printk("PC300 found at RAM 0x%08lx, "
+		printk("PC300 found at RAM 0x%08x, "
 		       "but could not allocate SCA mem region.\n",
 		       card->hw.ramphys);
 		err = -ENODEV;
@@ -3601,7 +3600,7 @@
 
 	/* Allocate IRQ */
 	if (request_irq(card->hw.irq, cpc_intr, SA_SHIRQ, "Cyclades-PC300", card)) {
-		printk ("PC300 found at RAM 0x%08lx, but could not allocate IRQ%d.\n",
+		printk ("PC300 found at RAM 0x%08x, but could not allocate IRQ%d.\n",
 			 card->hw.ramphys, card->hw.irq);
 		goto err_io_unmap;
 	}
diff -Nru a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
--- a/drivers/net/wan/pc300_tty.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/net/wan/pc300_tty.c	2004-12-24 13:36:48 -08:00
@@ -120,8 +120,7 @@
 /* TTY functions prototype */
 static int cpc_tty_open(struct tty_struct *tty, struct file *flip);
 static void cpc_tty_close(struct tty_struct *tty, struct file *flip);
-static int cpc_tty_write(struct tty_struct *tty, int from_user,
-				const unsigned char *buf, int count);
+static int cpc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count);
 static int cpc_tty_write_room(struct tty_struct *tty);
 static int cpc_tty_chars_in_buffer(struct tty_struct *tty);
 static void cpc_tty_flush_buffer(struct tty_struct *tty);
@@ -427,8 +426,7 @@
  * o verify the DCD signal
  * o send characters to board and start the transmission
  */
-static int cpc_tty_write(struct tty_struct *tty, int from_user,
-			const unsigned char *buf, int count)
+static int cpc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	st_cpc_tty_area    *cpc_tty; 
 	pc300ch_t *pc300chan; 
@@ -454,8 +452,7 @@
 		return -EINVAL;        /* frame too big */ 
 	}
 
-	CPC_TTY_DBG("%s: cpc_tty_write %s data len=%i\n",cpc_tty->name,
-		(from_user)?"from user" : "from kernel",count);
+	CPC_TTY_DBG("%s: cpc_tty_write data len=%i\n",cpc_tty->name,count);
 	
 	pc300chan = (pc300ch_t *)((pc300dev_t*)cpc_tty->pc300dev)->chan; 
 	stats = hdlc_stats(((pc300dev_t*)cpc_tty->pc300dev)->dev);
@@ -482,27 +479,10 @@
 		return -EINVAL; 
 	}
 
-	if (from_user) { 
-		unsigned char *buf_tmp; 
-
-		buf_tmp = cpc_tty->buf_tx;
-		if (copy_from_user(buf_tmp, buf, count)) { 
-			/* failed to copy from user */
-			CPC_TTY_DBG("%s: error in copy from user\n",cpc_tty->name);
-			return -EINVAL; 
-		}
-
-		if (cpc_tty_send_to_card(cpc_tty->pc300dev, (void*) buf_tmp,count)) { 
-			/* failed to send */ 
-			CPC_TTY_DBG("%s: transmission error\n",cpc_tty->name);
-			return 0; 
-		}
-	} else {
-		if (cpc_tty_send_to_card(cpc_tty->pc300dev, (void*)buf, count)) { 
-		   /* failed to send */
-		   CPC_TTY_DBG("%s: trasmition error\n", cpc_tty->name);
-		   return 0;
-		}
+	if (cpc_tty_send_to_card(cpc_tty->pc300dev, (void*)buf, count)) { 
+	   /* failed to send */
+	   CPC_TTY_DBG("%s: trasmition error\n", cpc_tty->name);
+	   return 0;
 	}
 	return count; 
 } 
@@ -730,13 +710,13 @@
  */
 static void cpc_tty_rx_disc_frame(pc300ch_t *pc300chan)
 {
-	volatile pcsca_bd_t * ptdescr; 
+	volatile pcsca_bd_t __iomem * ptdescr; 
 	volatile unsigned char status; 
 	pc300_t *card = (pc300_t *)pc300chan->card; 
 	int ch = pc300chan->channel; 
 
 	/* dma buf read */ 
-	ptdescr = (pcsca_bd_t *)(card->hw.rambase + 
+	ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase + 
 				RX_BD_ADDR(ch, pc300chan->rx_first_bd)); 
 	while (pc300chan->rx_first_bd != pc300chan->rx_last_bd) { 
 		status = cpc_readb(&ptdescr->status); 
@@ -747,7 +727,7 @@
 		if (status & DST_EOM) { 
 			break; /* end of message */
 		}
-		ptdescr = (pcsca_bd_t *)(card->hw.rambase + cpc_readl(&ptdescr->next)); 
+		ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase + cpc_readl(&ptdescr->next)); 
 	}
 }
 
@@ -757,7 +737,7 @@
 	pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan; 
 	pc300_t *card = (pc300_t *)pc300chan->card; 
 	int ch = pc300chan->channel; 
-	volatile pcsca_bd_t * ptdescr; 
+	volatile pcsca_bd_t  __iomem * ptdescr; 
 	struct net_device_stats *stats = hdlc_stats(pc300dev->dev);
 	int rx_len, rx_aux; 
 	volatile unsigned char status; 
@@ -775,14 +755,14 @@
 
 	while (1) { 
 		rx_len = 0;
-		ptdescr = (pcsca_bd_t *)(card->hw.rambase + RX_BD_ADDR(ch, first_bd));
+		ptdescr = (pcsca_bd_t  __iomem *)(card->hw.rambase + RX_BD_ADDR(ch, first_bd));
 		while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {
 			rx_len += cpc_readw(&ptdescr->len);
 			first_bd = (first_bd + 1) & (N_DMA_RX_BUF - 1);
 			if (status & DST_EOM) {
 				break;
 			}
-			ptdescr=(pcsca_bd_t*)(card->hw.rambase+cpc_readl(&ptdescr->next));
+			ptdescr=(pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next));
 		}
 			
 		if (!rx_len) { 
@@ -814,7 +794,7 @@
 		}
 		
 		/* dma buf read */ 
-		ptdescr = (pcsca_bd_t *)(card->hw.rambase + 
+		ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase + 
 				RX_BD_ADDR(ch, pc300chan->rx_first_bd)); 
 
 		rx_len = 0;	/* counter frame size */
@@ -858,7 +838,7 @@
 			/* read the segment of the frame */
 			if (rx_aux != 0) {
 				memcpy_fromio((new->data + rx_len), 
-					(void *)(card->hw.rambase + 
+					(void __iomem *)(card->hw.rambase + 
 					 cpc_readl(&ptdescr->ptbuf)), rx_aux);
 				rx_len += rx_aux; 
 			}
@@ -868,7 +848,7 @@
 					(N_DMA_RX_BUF -1); 
 			if (status & DST_EOM)break;
 			
-			ptdescr = (pcsca_bd_t *) (card->hw.rambase + 
+			ptdescr = (pcsca_bd_t __iomem *) (card->hw.rambase + 
 					cpc_readl(&ptdescr->next)); 
 		}
 		/* update pointer */ 
@@ -936,7 +916,7 @@
 	int ch = chan->channel; 
 	struct net_device_stats *stats = hdlc_stats(dev->dev);
 	unsigned long flags; 
-	volatile pcsca_bd_t * ptdescr; 
+	volatile pcsca_bd_t __iomem *ptdescr; 
 	int i, nchar;
 	int tosend = len;
 	int nbuf = ((len - 1)/BD_DEF_LEN) + 1;
@@ -953,11 +933,11 @@
 	CPC_TTY_DBG("%s: call dma_buf_write\n",
 			(st_cpc_tty_area *)dev->cpc_tty->name);	
 	for (i = 0 ; i < nbuf ; i++) {
-		ptdescr = (pcsca_bd_t *)(card->hw.rambase + 
+		ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase + 
 			TX_BD_ADDR(ch, card->chan[ch].tx_next_bd));
 		nchar = (BD_DEF_LEN > tosend) ? tosend : BD_DEF_LEN;
 		if (cpc_readb(&ptdescr->status) & DST_OSB) {
-			memcpy_toio((void *)(card->hw.rambase + 
+			memcpy_toio((void __iomem *)(card->hw.rambase + 
 				cpc_readl(&ptdescr->ptbuf)), 
 				&pdata[len - tosend], 
 				nchar);
diff -Nru a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
--- a/drivers/net/wan/pci200syn.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/net/wan/pci200syn.c	2004-12-24 13:36:19 -08:00
@@ -90,9 +90,9 @@
 
 
 typedef struct card_s {
-	u8* rambase;		/* buffer memory base (virtual) */
-	u8* scabase;		/* SCA memory base (virtual) */
-	plx9052* plxbase;	/* PLX registers memory base (virtual) */
+	u8 __iomem *rambase;	/* buffer memory base (virtual) */
+	u8 __iomem *scabase;	/* SCA memory base (virtual) */
+	plx9052 __iomem *plxbase;/* PLX registers memory base (virtual) */
 	u16 rx_ring_buffers;	/* number of buffers in a ring */
 	u16 tx_ring_buffers;
 	u16 buff_offset;	/* offset of first buffer of first channel */
@@ -116,7 +116,7 @@
 #define get_port(card, port)	     (&card->ports[port])
 #define sca_flush(card)		     (sca_in(IER0, card));
 
-static inline void new_memcpy_toio(char *dest, char *src, int length)
+static inline void new_memcpy_toio(char __iomem *dest, char *src, int length)
 {
 	int len;
 	do {
@@ -295,7 +295,7 @@
 {
 	card_t *card;
 	u8 rev_id;
-	u32 *p;
+	u32 __iomem *p;
 	int i;
 	u32 ramsize;
 	u32 ramphys;		/* buffer memory base */
diff -Nru a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
--- a/drivers/net/wan/sbni.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/wan/sbni.c	2004-12-24 13:36:47 -08:00
@@ -294,7 +294,7 @@
 {
 	struct pci_dev  *pdev = NULL;
 
-	while( (pdev = pci_find_class( PCI_CLASS_NETWORK_OTHER << 8, pdev ))
+	while( (pdev = pci_get_class( PCI_CLASS_NETWORK_OTHER << 8, pdev ))
 	       != NULL ) {
 		int  pci_irq_line;
 		unsigned long  pci_ioaddr;
@@ -331,10 +331,14 @@
 		/* avoiding re-enable dual adapters */
 		if( (pci_ioaddr & 7) == 0  &&  pci_enable_device( pdev ) ) {
 			release_region( pci_ioaddr, SBNI_IO_EXTENT );
+			pci_dev_put( pdev );
 			return  -EIO;
 		}
 		if( sbni_probe1( dev, pci_ioaddr, pci_irq_line ) ) {
 			SET_NETDEV_DEV(dev, &pdev->dev);
+			/* not the best thing to do, but this is all messed up 
+			   for hotplug systems anyway... */
+			pci_dev_put( pdev );
 			return  0;
 		}
 	}
diff -Nru a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
--- a/drivers/net/wan/sdla.c	2004-12-24 13:37:33 -08:00
+++ b/drivers/net/wan/sdla.c	2004-12-24 13:37:33 -08:00
@@ -51,9 +51,9 @@
 #include <linux/if_arp.h>
 #include <linux/if_frad.h>
 #include <linux/sdla.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/uaccess.h>
diff -Nru a/drivers/net/wan/sdla_chdlc.c b/drivers/net/wan/sdla_chdlc.c
--- a/drivers/net/wan/sdla_chdlc.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/wan/sdla_chdlc.c	2004-12-24 13:36:49 -08:00
@@ -3739,8 +3739,7 @@
 	return 0;
 }
 
-static int wanpipe_tty_write(struct tty_struct * tty, int from_user,
-		    const unsigned char *buf, int count)
+static int wanpipe_tty_write(struct tty_struct * tty, const unsigned char *buf, int count)
 {
 	unsigned long smp_flags=0;
 	sdla_t *card=NULL;
@@ -3784,58 +3783,16 @@
 		return -EINVAL; 
 	}
 	
-	if (from_user) {
-		
-		unsigned char *tmp_buf;
-		
-		if ((tmp_buf=card->tty_buf)==NULL){
-			dbg_printk(KERN_INFO "No TTY BUF in Write\n");
-			
-			clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
-			
-			if(card->hw.type != SDLA_S514)
-				s508_unlock(card,&smp_flags);
-			
-			return -ENOMEM;
-		}
-		
-		if (copy_from_user(tmp_buf,buf,count)){
-			dbg_printk(KERN_INFO "%s: Failed to copy from user!\n",
-					card->devname);
-			
-			clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
-			
-			if(card->hw.type != SDLA_S514)
-				s508_unlock(card,&smp_flags);
-			
-			return -EINVAL;
-		}
-
-		if (chdlc_send(card,(void*)tmp_buf,count)){
-			dbg_printk(KERN_INFO "%s: Failed to send, retry later: user!\n",
-					card->devname);
-			
-			clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
-			
-			wanpipe_tty_trigger_tx_irq(card);
-			
-			if(card->hw.type != SDLA_S514)
-				s508_unlock(card,&smp_flags);
-			return 0;
-		}
+ 	if (chdlc_send(card,(void*)buf,count)){
+		dbg_printk(KERN_INFO "%s: Failed to send, retry later: kernel!\n",
+				card->devname);
+		clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
 
-	}else{
-	 	if (chdlc_send(card,(void*)buf,count)){
-			dbg_printk(KERN_INFO "%s: Failed to send, retry later: kernel!\n",
-					card->devname);
-			clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
-	
-			wanpipe_tty_trigger_tx_irq(card);
-			
-			if(card->hw.type != SDLA_S514)
-				s508_unlock(card,&smp_flags);
-			return 0;
-		}
+		wanpipe_tty_trigger_tx_irq(card);
+		
+		if(card->hw.type != SDLA_S514)
+			s508_unlock(card,&smp_flags);
+		return 0;
 	}
 	dbg_printk(KERN_INFO "%s: Packet sent OK: %i\n",card->devname,count);
 	clear_bit(SEND_CRIT,(void*)&card->wandev.critical);
diff -Nru a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
--- a/drivers/net/wan/wanxl.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/wan/wanxl.c	2004-12-24 13:37:19 -08:00
@@ -71,7 +71,7 @@
 	int n_ports;		/* 1, 2 or 4 ports */
 	u8 irq;
 
-	u8 *plx;		/* PLX PCI9060 virtual base address */
+	u8 __iomem *plx;	/* PLX PCI9060 virtual base address */
 	struct pci_dev *pdev;	/* for pdev->slot_name */
 	int rx_in;
 	struct sk_buff *rx_skbs[RX_QUEUE_LENGTH];
@@ -224,8 +224,6 @@
 #endif
 				stats->rx_packets++;
 				stats->rx_bytes += skb->len;
-				skb->mac.raw = skb->data;
-				skb->dev = dev;
 				dev->last_rx = jiffies;
 				skb->protocol = hdlc_type_trans(skb, dev);
 				netif_rx(skb);
@@ -399,7 +397,7 @@
 static int wanxl_open(struct net_device *dev)
 {
 	port_t *port = dev_to_port(dev);
-	u8 *dbr = port->card->plx + PLX_DOORBELL_TO_CARD;
+	u8 __iomem *dbr = port->card->plx + PLX_DOORBELL_TO_CARD;
 	unsigned long timeout;
 	int i;
 
@@ -562,7 +560,7 @@
 	unsigned long timeout;
 	u32 plx_phy;		/* PLX PCI base address */
 	u32 mem_phy;		/* memory PCI base addr */
-	u8 *mem;		/* memory virtual base addr */
+	u8 __iomem *mem;	/* memory virtual base addr */
 	int i, ports, alloc_size;
 
 #ifndef MODULE
diff -Nru a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
--- a/drivers/net/wan/x25_asy.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/wan/x25_asy.c	2004-12-24 13:36:31 -08:00
@@ -18,7 +18,7 @@
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
@@ -34,6 +34,8 @@
 #include <linux/init.h>
 #include "x25_asy.h"
 
+#include <net/x25device.h>
+
 static struct net_device **x25_asy_devs;
 static int x25_asy_maxdev = SL_NRUNIT;
 
@@ -209,10 +211,8 @@
 		return;
 	}
 	skb_push(skb,1);	/* LAPB internal control */
-	skb->dev = sl->dev;
 	memcpy(skb_put(skb,count), sl->rbuff, count);
-	skb->mac.raw=skb->data;
-	skb->protocol=htons(ETH_P_X25);
+	skb->protocol = x25_type_trans(skb, sl->dev);
 	if((err=lapb_data_received(skb->dev, skb))!=LAPB_OK)
 	{
 		kfree_skb(skb);
@@ -253,7 +253,7 @@
 	 *       14 Oct 1994  Dmitry Gorodchanin.
 	 */
 	sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
-	actual = sl->tty->driver->write(sl->tty, 0, sl->xbuff, count);
+	actual = sl->tty->driver->write(sl->tty, sl->xbuff, count);
 	sl->xleft = count - actual;
 	sl->xhead = sl->xbuff + actual;
 	/* VSV */
@@ -283,7 +283,7 @@
 		return;
 	}
 
-	actual = tty->driver->write(tty, 0, sl->xhead, sl->xleft);
+	actual = tty->driver->write(tty, sl->xhead, sl->xleft);
 	sl->xleft -= actual;
 	sl->xhead += actual;
 }
@@ -419,11 +419,7 @@
 	ptr  = skb_put(skb, 1);
 	*ptr = 0x01;
 
-	skb->dev      = sl->dev;
-	skb->protocol = htons(ETH_P_X25);
-	skb->mac.raw  = skb->data;
-	skb->pkt_type = PACKET_HOST;
-
+	skb->protocol = x25_type_trans(skb, sl->dev);
 	netif_rx(skb);
 	sl->dev->last_rx = jiffies;
 }
@@ -442,11 +438,7 @@
 	ptr  = skb_put(skb, 1);
 	*ptr = 0x02;
 
-	skb->dev      = sl->dev;
-	skb->protocol = htons(ETH_P_X25);
-	skb->mac.raw  = skb->data;
-	skb->pkt_type = PACKET_HOST;
-
+	skb->protocol = x25_type_trans(skb, sl->dev);
 	netif_rx(skb);
 	sl->dev->last_rx = jiffies;
 }
diff -Nru a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
--- a/drivers/net/wireless/airo.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/wireless/airo.c	2004-12-24 13:36:18 -08:00
@@ -35,9 +35,9 @@
 #include <linux/interrupt.h>
 #include <linux/suspend.h>
 #include <linux/in.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -1189,6 +1189,7 @@
 	struct iw_statistics	wstats;		// wireless stats
 	unsigned long		scan_timestamp;	/* Time started to scan */
 	struct iw_spy_data	spy_data;
+	struct iw_public_data	wireless_data;
 #endif /* WIRELESS_EXT */
 #ifdef MICSUPPORT
 	/* MIC stuff */
@@ -1210,7 +1211,6 @@
 	SsidRid			*SSID;
 	APListRid		*APList;
 #define	PCI_SHARED_LEN		2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE
-	u32			pci_state[16];
 	char			proc_name[IFNAMSIZ];
 };
 
@@ -2640,8 +2640,7 @@
 	dev->set_mac_address = &airo_set_mac_address;
 	dev->do_ioctl = &airo_ioctl;
 #ifdef WIRELESS_EXT
-	dev->get_wireless_stats = airo_get_wireless_stats;
-	dev->wireless_handlers = (struct iw_handler_def *)&airo_handler_def;
+	dev->wireless_handlers = &airo_handler_def;
 #endif /* WIRELESS_EXT */
 	dev->change_mtu = &airo_change_mtu;
 	dev->open = &airo_open;
@@ -2668,6 +2667,9 @@
 	dev->priv = ethdev->priv;
 	dev->irq = ethdev->irq;
 	dev->base_addr = ethdev->base_addr;
+#ifdef WIRELESS_EXT
+	dev->wireless_data = ethdev->wireless_data;
+#endif /* WIRELESS_EXT */
 	memcpy(dev->dev_addr, ethdev->dev_addr, dev->addr_len);
 	err = register_netdev(dev);
 	if (err<0) {
@@ -2720,7 +2722,7 @@
 		set_bit(FLAG_MPI, &ai->flags);
 	}
         ai->dev = dev;
-	ai->aux_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&ai->aux_lock);
 	sema_init(&ai->sem, 1);
 	ai->config.len = 0;
 	ai->pci = pci;
@@ -2747,8 +2749,9 @@
 	dev->set_mac_address = &airo_set_mac_address;
 	dev->do_ioctl = &airo_ioctl;
 #ifdef WIRELESS_EXT
-	dev->get_wireless_stats = airo_get_wireless_stats;
-	dev->wireless_handlers = (struct iw_handler_def *)&airo_handler_def;
+	dev->wireless_handlers = &airo_handler_def;
+	ai->wireless_data.spy_data = &ai->spy_data;
+	dev->wireless_data = &ai->wireless_data;
 #endif /* WIRELESS_EXT */
 	dev->change_mtu = &airo_change_mtu;
 	dev->open = &airo_open;
@@ -3231,7 +3234,7 @@
 					goto exitrx;
 				}
 			}
-#ifdef IW_WIRELESS_SPY		/* defined in iw_handler.h */
+#ifdef WIRELESS_SPY
 			if (apriv->spy_data.spy_number > 0) {
 				char *sa;
 				struct iw_quality wstats;
@@ -3251,7 +3254,7 @@
 				/* Update spy records */
 				wireless_spy_update(dev, sa, &wstats);
 			}
-#endif /* IW_WIRELESS_SPY */
+#endif /* WIRELESS_SPY */
 			OUT4500( apriv, EVACK, EV_RX);
 
 			if (test_bit(FLAG_802_11, &apriv->flags)) {
@@ -3476,7 +3479,7 @@
 #else
 		memcpy(buffer, ai->rxfids[0].virtual_host_addr, len);
 #endif
-#ifdef IW_WIRELESS_SPY		/* defined in iw_handler.h */
+#ifdef WIRELESS_SPY
 		if (ai->spy_data.spy_number > 0) {
 			char *sa;
 			struct iw_quality wstats;
@@ -3488,7 +3491,7 @@
 			/* Update spy records */
 			wireless_spy_update(ai->dev, sa, &wstats);
 		}
-#endif /* IW_WIRELESS_SPY */
+#endif /* WIRELESS_SPY */
 
 		skb->dev = ai->dev;
 		skb->ip_summed = CHECKSUM_NONE;
@@ -5492,7 +5495,7 @@
 	issuecommand(ai, &cmd, &rsp);
 
 	pci_enable_wake(pdev, state, 1);
-	pci_save_state(pdev, ai->pci_state);
+	pci_save_state(pdev);
 	return pci_set_power_state(pdev, state);
 }
 
@@ -5503,7 +5506,7 @@
 	Resp rsp;
 
 	pci_set_power_state(pdev, 0);
-	pci_restore_state(pdev, ai->pci_state);
+	pci_restore_state(pdev);
 	pci_enable_wake(pdev, ai->power, 0);
 
 	if (ai->power > 1) {
@@ -6520,6 +6523,13 @@
 		range->avg_qual.level = 176;	/* -80 dBm */
 	range->avg_qual.noise = 0;
 
+	/* Event capability (kernel + driver) */
+	range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
+				IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
+				IW_EVENT_CAPA_MASK(SIOCGIWAP) |
+				IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
+	range->event_capa[1] = IW_EVENT_CAPA_K_1;
+	range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVTXDROP);
 	return 0;
 }
 
@@ -6887,9 +6897,15 @@
 	while((!rc) && (BSSList.index != 0xffff)) {
 		/* Translate to WE format this entry */
 		current_ev = airo_translate_scan(dev, current_ev,
-						 extra + IW_SCAN_MAX_DATA,
+						 extra + dwrq->length,
 						 &BSSList);
 
+		/* Check if there is space for one more entry */
+		if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
+			/* Ask user space to try again with a bigger buffer */
+			return -E2BIG;
+		}
+
 		/* Read next entry */
 		rc = PC4500_readrid(ai, RID_BSSLISTNEXT,
 				    &BSSList, sizeof(BSSList), 1);
@@ -7025,12 +7041,10 @@
 	.num_standard	= sizeof(airo_handler)/sizeof(iw_handler),
 	.num_private	= sizeof(airo_private_handler)/sizeof(iw_handler),
 	.num_private_args = sizeof(airo_private_args)/sizeof(struct iw_priv_args),
-	.standard	= (iw_handler *) airo_handler,
-	.private	= (iw_handler *) airo_private_handler,
-	.private_args	= (struct iw_priv_args *) airo_private_args,
-	.spy_offset	= ((void *) (&((struct airo_info *) NULL)->spy_data) -
-			   (void *) NULL),
-
+	.standard	= airo_handler,
+	.private	= airo_private_handler,
+	.private_args	= airo_private_args,
+	.get_wireless_stats = airo_get_wireless_stats,
 };
 
 #endif /* WIRELESS_EXT */
diff -Nru a/drivers/net/wireless/arlan.h b/drivers/net/wireless/arlan.h
--- a/drivers/net/wireless/arlan.h	2004-12-24 13:36:57 -08:00
+++ b/drivers/net/wireless/arlan.h	2004-12-24 13:36:57 -08:00
@@ -19,8 +19,8 @@
 #include <linux/timer.h>
 
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
diff -Nru a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
--- a/drivers/net/wireless/atmel.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/net/wireless/atmel.c	2004-12-24 13:36:31 -08:00
@@ -1267,7 +1267,7 @@
 				build_wpa_mib(priv);
 			break;
 		case ISR_GENERIC_IRQ:
-			printk(KERN_INFO "%s: Generic_irq recieved.\n", dev->name);
+			printk(KERN_INFO "%s: Generic_irq received.\n", dev->name);
 			break;
 		}
 	}	
@@ -2567,7 +2567,7 @@
 	struct {
 		u8 BSSID[6];
 		u8 SSID[MAX_SSID_LENGTH];
-		u8 BSS_type; /* this is a short in a scan command - wierd */                                
+		u8 BSS_type; /* this is a short in a scan command - weird */
 		u8 channel;
 		u16 timeout;
 		u8 SSID_size;
diff -Nru a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
--- a/drivers/net/wireless/atmel_cs.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/wireless/atmel_cs.c	2004-12-24 13:36:49 -08:00
@@ -350,13 +350,10 @@
 /* This is strictly temporary, until PCMCIA devices get integrated into the device model. */
 static struct device *atmel_device(void)
 {
-	static char *kobj_name = "atmel_cs";
-
 	static struct device dev = {
 		.bus_id    = "pcmcia",
 	};
-	dev.kobj.k_name = kmalloc(strlen(kobj_name)+1, GFP_KERNEL);
-	strcpy(dev.kobj.k_name, kobj_name);
+	kobject_set_name(&dev.kobj, "atmel_cs");
 	kobject_init(&dev.kobj);
 	
 	return &dev;
diff -Nru a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
--- a/drivers/net/wireless/netwave_cs.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/wireless/netwave_cs.c	2004-12-24 13:37:29 -08:00
@@ -54,6 +54,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 #ifdef CONFIG_NET_RADIO
 #include <linux/wireless.h>
 #if WIRELESS_EXT > 12
@@ -70,7 +71,6 @@
 #include <pcmcia/mem_op.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
@@ -219,7 +219,6 @@
 /* Misc device stuff */
 static int netwave_open(struct net_device *dev);  /* Open the device */
 static int netwave_close(struct net_device *dev); /* Close the device */
-static int netwave_config(struct net_device *dev, struct ifmap *map);
 
 /* Packet transmission and Packet reception */
 static int netwave_start_xmit( struct sk_buff *skb, struct net_device *dev);
@@ -482,7 +481,6 @@
     /* Netwave specific entries in the device structure */
     SET_MODULE_OWNER(dev);
     dev->hard_start_xmit = &netwave_start_xmit;
-    dev->set_config = &netwave_config;
     dev->get_stats  = &netwave_get_stats;
     dev->set_multicast_list = &set_multicast_list;
     /* wireless extensions */
@@ -1286,16 +1284,6 @@
     /* Set the IENA bit in COR */
     wait_WOC(iobase);
     outb(corConfIENA + corConfLVLREQ, iobase + NETWAVE_REG_COR);
-}
-
-/*
- * Function netwave_config (dev, map)
- *
- *    Configure device, this work is done by netwave_pcmcia_config when a
- *    card is inserted
- */
-static int netwave_config(struct net_device *dev, struct ifmap *map) {
-    return 0; 
 }
 
 /*
diff -Nru a/drivers/net/wireless/prism54/isl_38xx.c b/drivers/net/wireless/prism54/isl_38xx.c
--- a/drivers/net/wireless/prism54/isl_38xx.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/wireless/prism54/isl_38xx.c	2004-12-24 13:36:49 -08:00
@@ -133,8 +133,8 @@
 		      readl(device_base + ISL38XX_CTRL_STAT_REG));
 		udelay(ISL38XX_WRITEIO_DELAY);
 
-		if (reg = readl(device_base + ISL38XX_INT_IDENT_REG),
-		    reg == 0xabadface) {
+		reg = readl(device_base + ISL38XX_INT_IDENT_REG);
+		if (reg == 0xabadface) {
 #if VERBOSE > SHOW_ERROR_MESSAGES
 			do_gettimeofday(&current_time);
 			DEBUG(SHOW_TRACING,
@@ -192,10 +192,8 @@
 void
 isl38xx_interface_reset(void __iomem *device_base, dma_addr_t host_address)
 {
-	u32 reg;
-
 #if VERBOSE > SHOW_ERROR_MESSAGES
-	DEBUG(SHOW_FUNCTION_CALLS, "isl38xx_interface_reset \n");
+	DEBUG(SHOW_FUNCTION_CALLS, "isl38xx_interface_reset\n");
 #endif
 
 	/* load the address of the control block in the device */
@@ -203,8 +201,7 @@
 	udelay(ISL38XX_WRITEIO_DELAY);
 
 	/* set the reset bit in the Device Interrupt Register */
-	isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_RESET,
-			  ISL38XX_DEV_INT_REG);
+	isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_RESET, ISL38XX_DEV_INT_REG);
 	udelay(ISL38XX_WRITEIO_DELAY);
 
 	/* enable the interrupt for detecting initialization */
@@ -212,9 +209,7 @@
 	/* Note: Do not enable other interrupts here. We want the
 	 * device to have come up first 100% before allowing any other 
 	 * interrupts. */
-	reg = ISL38XX_INT_IDENT_INIT;
-
-	isl38xx_w32_flush(device_base, reg, ISL38XX_INT_EN_REG);
+	isl38xx_w32_flush(device_base, ISL38XX_INT_IDENT_INIT, ISL38XX_INT_EN_REG);
 	udelay(ISL38XX_WRITEIO_DELAY);  /* allow complete full reset */
 }
 
diff -Nru a/drivers/net/wireless/prism54/isl_38xx.h b/drivers/net/wireless/prism54/isl_38xx.h
--- a/drivers/net/wireless/prism54/isl_38xx.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/net/wireless/prism54/isl_38xx.h	2004-12-24 13:37:43 -08:00
@@ -95,6 +95,10 @@
 #define ISL38XX_INT_SOURCES                     0x001E
 
 /* Control/Status register bits */
+/* Looks like there are other meaningful bits
+    0x20004400 seen in normal operation,
+    0x200044db at 'timeout waiting for mgmt response'
+*/
 #define ISL38XX_CTRL_STAT_SLEEPMODE             0x00000200
 #define	ISL38XX_CTRL_STAT_CLKRUN		0x00800000
 #define ISL38XX_CTRL_STAT_RESET                 0x10000000
diff -Nru a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
--- a/drivers/net/wireless/prism54/isl_ioctl.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/net/wireless/prism54/isl_ioctl.c	2004-12-24 13:36:33 -08:00
@@ -36,38 +36,6 @@
 
 #include <net/iw_handler.h>	/* New driver API */
 
-static int init_mode = CARD_DEFAULT_IW_MODE;
-static int init_channel = CARD_DEFAULT_CHANNEL;
-static int init_wep = CARD_DEFAULT_WEP;
-static int init_filter = CARD_DEFAULT_FILTER;
-static int init_authen = CARD_DEFAULT_AUTHEN;
-static int init_dot1x = CARD_DEFAULT_DOT1X;
-static int init_conformance = CARD_DEFAULT_CONFORMANCE;
-static int init_mlme = CARD_DEFAULT_MLME_MODE;
-
-module_param(init_mode, int, 0);
-MODULE_PARM_DESC(init_mode,
-		 "Set card mode:\n0: Auto\n1: Ad-Hoc\n2: Managed Client (Default)\n3: Master / Access Point\n4: Repeater (Not supported yet)\n5: Secondary (Not supported yet)\n6: Monitor");
-
-module_param(init_channel, int, 0);
-MODULE_PARM_DESC(init_channel,
-		 "Check `iwpriv ethx channel` for available channels");
-
-module_param(init_wep, int, 0);
-module_param(init_filter, int, 0);
-
-module_param(init_authen, int, 0);
-MODULE_PARM_DESC(init_authen,
-		 "Authentication method. Can be of seven types:\n0 0x0000: None\n1 0x0001: DOT11_AUTH_OS (Default)\n2 0x0002: DOT11_AUTH_SK\n3 0x0003: DOT11_AUTH_BOTH");
-
-module_param(init_dot1x, int, 0);
-MODULE_PARM_DESC(init_dot1x,
-		 "\n0: None/not set	(Default)\n1: DOT11_DOT1X_AUTHENABLED\n2: DOT11_DOT1X_KEYTXENABLED");
-
-module_param(init_mlme, int, 0);
-MODULE_PARM_DESC(init_mlme,
-		 "Sets the MAC layer management entity (MLME) mode of operation,\n0: DOT11_MLME_AUTO (Default)\n1: DOT11_MLME_INTERMEDIATE\n2: DOT11_MLME_EXTENDED");
-
 /**
  * prism54_mib_mode_helper - MIB change mode helper function
  * @mib: the &struct islpci_mib object to modify
@@ -141,36 +109,34 @@
 void
 prism54_mib_init(islpci_private *priv)
 {
-	u32 t;
+	u32 channel, authen, wep, filter, dot1x, mlme, conformance, power, mode;
 	struct obj_buffer psm_buffer = {
 		.size = PSM_BUFFER_SIZE,
 		.addr = priv->device_psm_buffer
 	};
 
-	mgt_set(priv, DOT11_OID_CHANNEL, &init_channel);
-	mgt_set(priv, DOT11_OID_AUTHENABLE, &init_authen);
-	mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &init_wep);
-
+	channel = CARD_DEFAULT_CHANNEL;
+	authen = CARD_DEFAULT_AUTHEN;
+	wep = CARD_DEFAULT_WEP;
+	filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */
+	dot1x = CARD_DEFAULT_DOT1X; 
+	mlme = CARD_DEFAULT_MLME_MODE;
+	conformance = CARD_DEFAULT_CONFORMANCE;
+	power = 127;
+	mode = CARD_DEFAULT_IW_MODE;
+
+	mgt_set(priv, DOT11_OID_CHANNEL, &channel);
+	mgt_set(priv, DOT11_OID_AUTHENABLE, &authen);
+	mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &wep);
 	mgt_set(priv, DOT11_OID_PSMBUFFER, &psm_buffer);
-	mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &init_filter);
-	mgt_set(priv, DOT11_OID_DOT1XENABLE, &init_dot1x);
-	mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &init_mlme);
-	mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &init_conformance);
-
-	t = 127;
-	mgt_set(priv, OID_INL_OUTPUTPOWER, &t);
-
-	/* Important: we are setting a default wireless mode and we are 
-	 * forcing a valid one, so prism54_mib_mode_helper should just set
-	 * mib values depending on what the wireless mode given is. No need
-	 * for it save old values */
-	if (init_mode > IW_MODE_MONITOR || init_mode < IW_MODE_AUTO) {
-		printk(KERN_DEBUG "%s(): You passed a non-valid init_mode. "
-		       "Using default mode\n", __FUNCTION__);
-		init_mode = CARD_DEFAULT_IW_MODE;
-	}
+	mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &filter);
+	mgt_set(priv, DOT11_OID_DOT1XENABLE, &dot1x);
+	mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlme);
+	mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &conformance);
+	mgt_set(priv, OID_INL_OUTPUTPOWER, &power);
+
 	/* This sets all of the mode-dependent values */
-	prism54_mib_mode_helper(priv, init_mode);
+	prism54_mib_mode_helper(priv, mode);
 }
 
 /* this will be executed outside of atomic context thanks to
@@ -374,7 +340,10 @@
 
 	mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
 
-	mgt_commit(priv);
+	if (mgt_commit(priv)) {
+		up_write(&priv->mib_sem);
+		return -EIO;
+	}
 	priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR)
 	    ? priv->monitor_type : ARPHRD_ETHER;
 	up_write(&priv->mib_sem);
@@ -485,6 +454,15 @@
 	/* txpower is supported in dBm's */
 	range->txpower_capa = IW_TXPOW_DBM;
 
+#if WIRELESS_EXT > 16
+	/* Event capability (kernel + driver) */
+	range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
+	IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
+	IW_EVENT_CAPA_MASK(SIOCGIWAP));
+	range->event_capa[1] = IW_EVENT_CAPA_K_1;
+	range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM);
+#endif /* WIRELESS_EXT > 16 */
+
 	if (islpci_get_state(priv) < PRV_STATE_INIT)
 		return 0;
 
@@ -629,8 +607,8 @@
 	current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, NULL);
 
 	/* Add frequency. (short) bss->channel is the frequency in MHz */
-	iwe.u.freq.m = channel_of_freq(bss->channel);
-	iwe.u.freq.e = 0;
+	iwe.u.freq.m = bss->channel;
+	iwe.u.freq.e = 6;
 	iwe.cmd = SIOCGIWFREQ;
 	current_ev =
 	    iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
@@ -690,19 +668,33 @@
 	rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
 	noise = r.u;
 
-	/* Ask the device for a list of known bss. We can report at most
-	 * IW_MAX_AP=64 to the range struct. But the device won't repport anything
-	 * if you change the value of IWMAX_BSS=24.
-	 */
+	/* Ask the device for a list of known bss.
+	* The old API, using SIOCGIWAPLIST, had a hard limit of IW_MAX_AP=64.
+	* The new API, using SIOCGIWSCAN, is only limited by the buffer size.
+	* WE-14->WE-16, the buffer is limited to IW_SCAN_MAX_DATA bytes.
+	* Starting with WE-17, the buffer can be as big as needed.
+	* But the device won't repport anything if you change the value
+	* of IWMAX_BSS=24. */
+	
 	rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
 	bsslist = r.ptr;
 
 	/* ok now, scan the list and translate its info */
-	for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++)
+	for (i = 0; i < (int) bsslist->nr; i++) {
 		current_ev = prism54_translate_bss(ndev, current_ev,
-						   extra + IW_SCAN_MAX_DATA,
+						   extra + dwrq->length,
 						   &(bsslist->bsslist[i]),
 						   noise);
+#if WIRELESS_EXT > 16
+		/* Check if there is space for one more entry */
+		if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
+			/* Ask user space to try again with a bigger buffer */
+			rvalue = -E2BIG;
+			break;
+		}
+#endif /* WIRELESS_EXT > 16 */
+	}
+
 	kfree(bsslist);
 	dwrq->length = (current_ev - extra);
 	dwrq->flags = 0;	/* todo */
@@ -1412,7 +1404,10 @@
 		mlmeautolevel = DOT11_MLME_EXTENDED;
 	mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
 	/* restart the card with our new policy */
-	mgt_commit(priv);
+	if (mgt_commit(priv)) {
+		up_write(&priv->mib_sem);
+		return -EIO;
+	}
 	up_write(&priv->mib_sem);
 
 	return 0;
@@ -1746,11 +1741,13 @@
 			    char *data)
 {
 	struct obj_mlme *mlme = (struct obj_mlme *) data;
-	size_t len;
-	u8 *payload, *pos = (u8 *) (mlme + 1);
-
-	len = pos[0] | (pos[1] << 8);	/* little endian data length */
-	payload = pos + 2;
+	struct obj_mlmeex *mlmeex = (struct obj_mlmeex *) data;
+	struct obj_mlmeex *confirm;
+	u8 wpa_ie[MAX_WPA_IE_LEN];
+	int wpa_ie_len;
+	size_t len = 0; /* u16, better? */
+	u8 *payload = 0, *pos = 0;
+	int ret;
 
 	/* I think all trapable objects are listed here.
 	 * Some oids have a EX version. The difference is that they are emitted
@@ -1760,9 +1757,14 @@
 	 * suited. We use the more flexible custom event facility.
 	 */
 
+	if (oid >= DOT11_OID_BEACON) {
+		len = mlmeex->size;
+		payload = pos = mlmeex->data;
+	}
+
 	/* I fear prism54_process_bss_data won't work with big endian data */
 	if ((oid == DOT11_OID_BEACON) || (oid == DOT11_OID_PROBE))
-		prism54_process_bss_data(priv, oid, mlme->address,
+		prism54_process_bss_data(priv, oid, mlmeex->address,
 					 payload, len);
 
 	mgt_le_to_cpu(isl_oid[oid].flags & OID_FLAG_TYPE, (void *) mlme);
@@ -1822,21 +1824,134 @@
 
 	case DOT11_OID_AUTHENTICATEEX:
 		handle_request(priv, mlme, oid);
-		send_formatted_event(priv, "Authenticate request", mlme, 1);
+		send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
+
+		if (priv->iw_mode != IW_MODE_MASTER 
+				&& mlmeex->state != DOT11_STATE_AUTHING)
+			break;
+
+		confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
+
+		if (!confirm) 
+			break;
+
+		memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
+		printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 
+				mlmeex->address[0],
+				mlmeex->address[1],
+				mlmeex->address[2],
+				mlmeex->address[3],
+				mlmeex->address[4],
+				mlmeex->address[5]
+				);
+		confirm->id = -1; /* or mlmeex->id ? */
+		confirm->state = 0; /* not used */
+		confirm->code = 0;
+		confirm->size = 6;
+		confirm->data[0] = 0x00;
+		confirm->data[1] = 0x00;
+		confirm->data[2] = 0x02;
+		confirm->data[3] = 0x00;
+		confirm->data[4] = 0x00;
+		confirm->data[5] = 0x00;
+
+		ret = mgt_set_varlen(priv, DOT11_OID_ASSOCIATEEX, confirm, 6);
+
+		kfree(confirm);
+		if (ret)
+			return ret;
 		break;
 
 	case DOT11_OID_DISASSOCIATEEX:
-		send_formatted_event(priv, "Disassociate request", mlme, 0);
+		send_formatted_event(priv, "Disassociate request (ex)", mlme, 0);
 		break;
 
 	case DOT11_OID_ASSOCIATEEX:
 		handle_request(priv, mlme, oid);
-		send_formatted_event(priv, "Associate request", mlme, 1);
+		send_formatted_event(priv, "Associate request (ex)", mlme, 1);
+
+		if (priv->iw_mode != IW_MODE_MASTER 
+				&& mlmeex->state != DOT11_STATE_AUTHING)
+			break;
+		
+		confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
+
+		if (!confirm)
+			break;
+
+		memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
+
+		confirm->id = ((struct obj_mlmeex *)mlme)->id;
+		confirm->state = 0; /* not used */
+		confirm->code = 0;
+
+		wpa_ie_len = prism54_wpa_ie_get(priv, mlmeex->address, wpa_ie);
+
+		if (!wpa_ie_len) {
+			printk(KERN_DEBUG "No WPA IE found from "
+					"address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 
+				mlmeex->address[0],
+				mlmeex->address[1],
+				mlmeex->address[2],
+				mlmeex->address[3],
+				mlmeex->address[4],
+				mlmeex->address[5]
+				);
+			kfree(confirm);
+			break;
+		}
+
+		confirm->size = wpa_ie_len;
+		memcpy(&confirm->data, wpa_ie, wpa_ie_len);
+
+		mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
+
+		kfree(confirm);
+		
 		break;
 
 	case DOT11_OID_REASSOCIATEEX:
 		handle_request(priv, mlme, oid);
-		send_formatted_event(priv, "Reassociate request", mlme, 1);
+		send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
+
+		if (priv->iw_mode != IW_MODE_MASTER 
+				&& mlmeex->state != DOT11_STATE_ASSOCING)
+			break;
+
+		confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
+
+		if (!confirm)
+			break;
+
+		memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
+
+		confirm->id = mlmeex->id;
+		confirm->state = 0; /* not used */
+		confirm->code = 0;
+
+		wpa_ie_len = prism54_wpa_ie_get(priv, mlmeex->address, wpa_ie);
+
+		if (!wpa_ie_len) {
+			printk(KERN_DEBUG "No WPA IE found from "
+					"address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 
+				mlmeex->address[0],
+				mlmeex->address[1],
+				mlmeex->address[2],
+				mlmeex->address[3],
+				mlmeex->address[4],
+				mlmeex->address[5]
+				);
+			kfree(confirm);
+			break;
+		}
+
+		confirm->size = wpa_ie_len; 
+		memcpy(&confirm->data, wpa_ie, wpa_ie_len);
+
+		mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
+
+		kfree(confirm);
+		
 		break;
 
 	default:
@@ -1879,23 +1994,367 @@
 	return ret;
 }
 
+/* Note: currently, use hostapd ioctl from the Host AP driver for WPA
+ * support. This is to be replaced with Linux wireless extensions once they
+ * get WPA support. */
+
+/* Note II: please leave all this together as it will be easier to remove later,
+ * once wireless extensions add WPA support -mcgrof */
+
+/* PRISM54_HOSTAPD ioctl() cmd: */
+enum {
+	PRISM2_SET_ENCRYPTION = 6,
+	PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12,
+	PRISM2_HOSTAPD_MLME = 13,
+	PRISM2_HOSTAPD_SCAN_REQ = 14,
+};
+
+#define PRISM54_SET_WPA			SIOCIWFIRSTPRIV+12
+#define PRISM54_HOSTAPD			SIOCIWFIRSTPRIV+25
+#define PRISM54_DROP_UNENCRYPTED	SIOCIWFIRSTPRIV+26
+
+#define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
+#define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
+((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
+
+/* Maximum length for algorithm names (-1 for nul termination) 
+ * used in ioctl() */
+#define HOSTAP_CRYPT_ALG_NAME_LEN 16
+	
+struct prism2_hostapd_param {
+	u32 cmd;
+	u8 sta_addr[ETH_ALEN];
+	union {
+	       struct {
+		       u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN];
+		       u32 flags;
+		       u32 err;
+		       u8 idx;
+		       u8 seq[8]; /* sequence counter (set: RX, get: TX) */
+		       u16 key_len;
+		       u8 key[0];
+		       } crypt;
+               struct {
+                       u8 len;
+                       u8 data[0];
+               } generic_elem;
+               struct {
+#define MLME_STA_DEAUTH 0
+#define MLME_STA_DISASSOC 1
+                       u16 cmd;
+                       u16 reason_code;
+               } mlme;
+               struct {
+                       u8 ssid_len;
+                       u8 ssid[32];
+               } scan_req;
+       } u;
+};
+
+
+static int
+prism2_ioctl_set_encryption(struct net_device *dev,
+	struct prism2_hostapd_param *param,
+	int param_len)
+{
+	islpci_private *priv = netdev_priv(dev);
+	int rvalue = 0, force = 0;
+	int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
+	union oid_res_t r;
+
+	/* with the new API, it's impossible to get a NULL pointer.
+	 * New version of iwconfig set the IW_ENCODE_NOKEY flag
+	 * when no key is given, but older versions don't. */
+
+	if (param->u.crypt.key_len > 0) {
+		/* we have a key to set */
+		int index = param->u.crypt.idx;
+		int current_index;
+		struct obj_key key = { DOT11_PRIV_TKIP, 0, "" };
+
+		/* get the current key index */
+		rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
+		current_index = r.u;
+		/* Verify that the key is not marked as invalid */
+		if (!(param->u.crypt.flags & IW_ENCODE_NOKEY)) {
+			key.length = param->u.crypt.key_len > sizeof (param->u.crypt.key) ?
+			    sizeof (param->u.crypt.key) : param->u.crypt.key_len;
+			memcpy(key.key, param->u.crypt.key, key.length);
+			if (key.length == 32)
+				/* we want WPA-PSK */
+				key.type = DOT11_PRIV_TKIP;
+			if ((index < 0) || (index > 3))
+				/* no index provided use the current one */
+				index = current_index;
+
+			/* now send the key to the card  */
+			rvalue |=
+			    mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
+					    &key);
+		}
+		/*
+		 * If a valid key is set, encryption should be enabled 
+		 * (user may turn it off later).
+		 * This is also how "iwconfig ethX key on" works
+		 */
+		if ((index == current_index) && (key.length > 0))
+			force = 1;
+	} else {
+		int index = (param->u.crypt.flags & IW_ENCODE_INDEX) - 1;
+		if ((index >= 0) && (index <= 3)) {
+			/* we want to set the key index */
+			rvalue |=
+			    mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
+					    &index);
+		} else {
+			if (!param->u.crypt.flags & IW_ENCODE_MODE) {
+				/* we cannot do anything. Complain. */
+				return -EINVAL;
+			}
+		}
+	}
+	/* now read the flags */
+	if (param->u.crypt.flags & IW_ENCODE_DISABLED) {
+		/* Encoding disabled, 
+		 * authen = DOT11_AUTH_OS;
+		 * invoke = 0;
+		 * exunencrypt = 0; */
+	}
+	if (param->u.crypt.flags & IW_ENCODE_OPEN)
+		/* Encode but accept non-encoded packets. No auth */
+		invoke = 1;
+	if ((param->u.crypt.flags & IW_ENCODE_RESTRICTED) || force) {
+		/* Refuse non-encoded packets. Auth */
+		authen = DOT11_AUTH_BOTH;
+		invoke = 1;
+		exunencrypt = 1;
+	}
+	/* do the change if requested  */
+	if ((param->u.crypt.flags & IW_ENCODE_MODE) || force) {
+		rvalue |=
+		    mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
+		rvalue |=
+		    mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
+		rvalue |=
+		    mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
+				    &exunencrypt);
+	}
+	return rvalue;
+}
+
+static int
+prism2_ioctl_set_generic_element(struct net_device *ndev,
+	struct prism2_hostapd_param *param,
+	int param_len)
+{
+       islpci_private *priv = netdev_priv(ndev);
+       int max_len, len, alen, ret=0;
+       struct obj_attachment *attach;
+
+       len = param->u.generic_elem.len;
+       max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
+       if (max_len < 0 || max_len < len)
+               return -EINVAL;
+
+       alen = sizeof(*attach) + len;
+       attach = kmalloc(alen, GFP_KERNEL);
+       if (attach == NULL)
+               return -ENOMEM;
+
+       memset(attach, 0, alen);
+#define WLAN_FC_TYPE_MGMT 0
+#define WLAN_FC_STYPE_ASSOC_REQ 0
+#define WLAN_FC_STYPE_REASSOC_REQ 2
+
+       /* Note: endianness is covered by mgt_set_varlen */
+
+       attach->type = (WLAN_FC_TYPE_MGMT << 2) |
+               (WLAN_FC_STYPE_ASSOC_REQ << 4);
+       attach->id = -1;
+       attach->size = len;
+       memcpy(attach->data, param->u.generic_elem.data, len);
+
+       ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
+
+       if (ret == 0) {
+               attach->type = (WLAN_FC_TYPE_MGMT << 2) |
+                       (WLAN_FC_STYPE_REASSOC_REQ << 4);
+
+	       ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
+
+	       if (ret == 0) 
+		       printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
+				       ndev->name);
+       }
+
+       kfree(attach);
+       return ret;
+
+}
+
+static int
+prism2_ioctl_mlme(struct net_device *dev, struct prism2_hostapd_param *param)
+{
+	return -EOPNOTSUPP;
+}
+
+static int
+prism2_ioctl_scan_req(struct net_device *ndev,
+                     struct prism2_hostapd_param *param)
+{
+	islpci_private *priv = netdev_priv(ndev);
+	int i, rvalue;
+	struct obj_bsslist *bsslist;
+	u32 noise = 0;
+	char *extra = "";
+	char *current_ev = "foo";
+	union oid_res_t r;
+
+	if (islpci_get_state(priv) < PRV_STATE_INIT) {
+		/* device is not ready, fail gently */
+		return 0;
+	}
+
+	/* first get the noise value. We will use it to report the link quality */
+	rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
+	noise = r.u;
+
+	/* Ask the device for a list of known bss. We can report at most
+	 * IW_MAX_AP=64 to the range struct. But the device won't repport anything
+	 * if you change the value of IWMAX_BSS=24.
+	 */
+	rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
+	bsslist = r.ptr;
+
+	/* ok now, scan the list and translate its info */
+	for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++)
+		current_ev = prism54_translate_bss(ndev, current_ev,
+						   extra + IW_SCAN_MAX_DATA,
+						   &(bsslist->bsslist[i]),
+						   noise);
+	kfree(bsslist);
+
+	return rvalue;
+}
+
+static int
+prism54_hostapd(struct net_device *ndev, struct iw_point *p)
+{
+       struct prism2_hostapd_param *param;
+       int ret = 0;
+       u32 uwrq;
+
+       printk(KERN_DEBUG "prism54_hostapd - len=%d\n", p->length);
+       if (p->length < sizeof(struct prism2_hostapd_param) ||
+           p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
+               return -EINVAL;
+
+       param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL);
+       if (param == NULL)
+               return -ENOMEM;
+
+       if (copy_from_user(param, p->pointer, p->length)) {
+               kfree(param);
+               return -EFAULT;
+       }
+
+       switch (param->cmd) {
+       case PRISM2_SET_ENCRYPTION:
+	       printk(KERN_DEBUG "%s: Caught WPA supplicant set encryption request\n",
+			       ndev->name);
+               ret = prism2_ioctl_set_encryption(ndev, param, p->length);
+               break;
+       case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT:
+	       printk(KERN_DEBUG "%s: Caught WPA supplicant set WPA IE request\n",
+			       ndev->name);
+               ret = prism2_ioctl_set_generic_element(ndev, param,
+                                                      p->length);
+               break;
+       case PRISM2_HOSTAPD_MLME:
+	       printk(KERN_DEBUG "%s: Caught WPA supplicant MLME request\n",
+			       ndev->name);
+               ret = prism2_ioctl_mlme(ndev, param);
+               break;
+       case PRISM2_HOSTAPD_SCAN_REQ:
+	       printk(KERN_DEBUG "%s: Caught WPA supplicant scan request\n",
+			       ndev->name);
+               ret = prism2_ioctl_scan_req(ndev, param);
+               break;
+	case PRISM54_SET_WPA:
+	       printk(KERN_DEBUG "%s: Caught WPA supplicant wpa init request\n",
+			       ndev->name);
+	       uwrq = 1;
+	       ret = prism54_set_wpa(ndev, NULL, &uwrq, NULL);
+	       break;
+	case PRISM54_DROP_UNENCRYPTED:
+	       printk(KERN_DEBUG "%s: Caught WPA drop unencrypted request\n",
+			       ndev->name);
+#if 0
+	       uwrq = 0x01;
+	       mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &uwrq);
+	       down_write(&priv->mib_sem);
+	       mgt_commit(priv);
+	       up_write(&priv->mib_sem);
+#endif
+	       /* Not necessary, as set_wpa does it, should we just do it here though? */
+	       ret = 0;
+	       break;
+       default:
+	       printk(KERN_DEBUG "%s: Caught a WPA supplicant request that is not supported\n",
+			       ndev->name);
+               ret = -EOPNOTSUPP;
+               break;
+       }
+
+       if (ret == 0 && copy_to_user(p->pointer, param, p->length))
+               ret = -EFAULT;
+
+       kfree(param);
+
+       return ret;
+}
+
 int
 prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
 		__u32 * uwrq, char *extra)
 {
 	islpci_private *priv = netdev_priv(ndev);
+	u32 mlme, authen, dot1x, filter, wep;
 
-	down_write(&priv->mib_sem);
+	if (islpci_get_state(priv) < PRV_STATE_INIT)
+		return 0;
+
+	wep = 1; /* For privacy invoked */
+	filter = 1; /* Filter out all unencrypted frames */
+	dot1x = 0x01; /* To enable eap filter */
+	mlme = DOT11_MLME_EXTENDED;
+	authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
 
+	down_write(&priv->mib_sem);
 	priv->wpa = *uwrq;
-	if (priv->wpa) {
-		u32 l = DOT11_MLME_EXTENDED;
-		mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &l);
+
+	switch (priv->wpa) {
+		default:
+		case 0: /* Clears/disables WPA and friends */
+			wep = 0;
+			filter = 0; /* Do not filter un-encrypted data */
+			dot1x = 0;
+			mlme = DOT11_MLME_AUTO;
+			printk("%s: Disabling WPA\n", ndev->name);
+			break;
+		case 2: 
+		case 1: /* WPA */
+			printk("%s: Enabling WPA\n", ndev->name);
+			break;
 	}
-	/* restart the card with new level. Needed ? */
-	mgt_commit(priv);
 	up_write(&priv->mib_sem);
 
+	mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
+	mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &wep);
+	mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &filter);
+	mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
+	mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlme);
+
 	return 0;
 }
 
@@ -1947,7 +2406,7 @@
 		      struct iw_point *data, char *extra)
 {
 	islpci_private *priv = netdev_priv(ndev);
-	struct islpci_mgmtframe *response = NULL;
+	struct islpci_mgmtframe *response;
 	int ret = -EIO;
 
 	printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid);
@@ -1983,7 +2442,7 @@
 		      struct iw_point *data, char *extra)
 {
 	islpci_private *priv = netdev_priv(ndev);
-	struct islpci_mgmtframe *response = NULL;
+	struct islpci_mgmtframe *response;
 	int ret = 0, response_op = PIMFOR_OP_ERROR;
 
 	printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid,
@@ -2256,14 +2715,24 @@
 	.standard = (iw_handler *) prism54_handler,
 	.private = (iw_handler *) prism54_private_handler,
 	.private_args = (struct iw_priv_args *) prism54_private_args,
+#if WIRELESS_EXT == 16
 	.spy_offset = offsetof(islpci_private, spy_data),
+#endif /* WIRELESS_EXT == 16 */
 };
 
-/* For ioctls that don't work with the new API */
+/* For wpa_supplicant */
 
 int
 prism54_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
 {
-
+	struct iwreq *wrq = (struct iwreq *) rq;
+	int ret = -1;
+	switch (cmd) {
+		case PRISM54_HOSTAPD:
+		if (!capable(CAP_NET_ADMIN))
+		return -EPERM;
+		ret = prism54_hostapd(ndev, &wrq->u.data);
+		return ret;
+	}
 	return -EOPNOTSUPP;
 }
diff -Nru a/drivers/net/wireless/prism54/isl_ioctl.h b/drivers/net/wireless/prism54/isl_ioctl.h
--- a/drivers/net/wireless/prism54/isl_ioctl.h	2004-12-24 13:36:55 -08:00
+++ b/drivers/net/wireless/prism54/isl_ioctl.h	2004-12-24 13:36:55 -08:00
@@ -48,6 +48,8 @@
 int prism54_set_mac_address(struct net_device *, void *);
 
 int prism54_ioctl(struct net_device *, struct ifreq *, int);
+int prism54_set_wpa(struct net_device *, struct iw_request_info *, 
+			__u32 *, char *);
 
 extern const struct iw_handler_def prism54_handler_def;
 
diff -Nru a/drivers/net/wireless/prism54/isl_oid.h b/drivers/net/wireless/prism54/isl_oid.h
--- a/drivers/net/wireless/prism54/isl_oid.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/net/wireless/prism54/isl_oid.h	2004-12-24 13:37:00 -08:00
@@ -91,6 +91,14 @@
 	u16 mhz[0];
 } __attribute__ ((packed));
 
+struct obj_attachment {
+	char type;
+	char reserved;
+	short id;
+	short size;
+	char data[0];
+} __attribute__((packed));
+
 /* 
  * in case everything's ok, the inlined function below will be
  * optimized away by the compiler...
@@ -472,6 +480,7 @@
 #define OID_TYPE_MLMEEX		0x09
 #define OID_TYPE_ADDR		0x0A
 #define OID_TYPE_RAW		0x0B
+#define OID_TYPE_ATTACH		0x0C
 
 /* OID_TYPE_MLMEEX is special because of a variable size field when sending.
  * Not yet implemented (not used in driver anyway).
diff -Nru a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
--- a/drivers/net/wireless/prism54/islpci_dev.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/net/wireless/prism54/islpci_dev.c	2004-12-24 13:36:17 -08:00
@@ -105,7 +105,7 @@
 			       "%s: firmware '%s' size is not multiple of 32bit, aborting!\n",
 			       "prism54", priv->firmware);
 			release_firmware(fw_entry);
-			return EILSEQ; /* Illegal byte sequence  */;
+			return -EILSEQ; /* Illegal byte sequence  */;
 		}
 
 		while (fw_len > 0) {
@@ -142,6 +142,10 @@
 
 		BUG_ON(fw_len != 0);
 
+		/* Firmware version is at offset 40 (also for "newmac") */
+		printk(KERN_DEBUG "%s: firmware version: %.8s\n",
+		       priv->ndev->name, fw_entry->data + 40);
+
 		release_firmware(fw_entry);
 	}
 
@@ -375,8 +379,6 @@
 	u32 rc;
 	islpci_private *priv = netdev_priv(ndev);
 
-	printk(KERN_DEBUG "%s: islpci_open()\n", ndev->name);
-
 	/* reset data structures, upload firmware and reset device */
 	rc = islpci_reset(priv,1);
 	if (rc) {
@@ -462,8 +464,7 @@
 		return rc;
 	}
 
-	printk(KERN_DEBUG
-	       "%s: firmware uploaded done, now triggering reset...\n",
+	printk(KERN_DEBUG "%s: firmware upload complete\n",
 	       priv->ndev->name);
 
 	islpci_set_state(priv, PRV_STATE_POSTBOOT);
@@ -489,6 +490,7 @@
 		/* The software reset acknowledge needs about 220 msec here.
 		 * Be conservative and wait for up to one second. */
 	
+		set_current_state(TASK_UNINTERRUPTIBLE);
 		remaining = schedule_timeout(HZ);
 
 		if(remaining > 0) {
@@ -499,15 +501,16 @@
 		/* If we're here it's because our IRQ hasn't yet gone through. 
 		 * Retry a bit more...
 		 */
-		 printk(KERN_ERR "%s: device soft reset timed out\n",
-		       priv->ndev->name);
-
+		printk(KERN_ERR "%s: no 'reset complete' IRQ seen - retrying\n",
+			priv->ndev->name);
 	}
 
 	finish_wait(&priv->reset_done, &wait);
 
-	if(result)
+	if (result) {
+		printk(KERN_ERR "%s: interface reset failure\n", priv->ndev->name);
 		return result;
+	}
 
 	islpci_set_state(priv, PRV_STATE_INIT);
 
@@ -519,11 +522,17 @@
 	isl38xx_enable_common_interrupts(priv->device_base);
 
 	down_write(&priv->mib_sem);
-	mgt_commit(priv);
+	result = mgt_commit(priv);
+	if (result) {
+		printk(KERN_ERR "%s: interface reset failure\n", priv->ndev->name);
+		up_write(&priv->mib_sem);
+		return result;
+	}
 	up_write(&priv->mib_sem);
 
 	islpci_set_state(priv, PRV_STATE_READY);
 
+	printk(KERN_DEBUG "%s: interface reset complete\n", priv->ndev->name);
 	return 0;
 }
 
@@ -584,18 +593,18 @@
 	/* now that the data structures are cleaned up, upload
 	 * firmware and reset interface */
 		rc = islpci_upload_fw(priv);
-		if (rc) 
+		if (rc) {
+			printk(KERN_ERR "%s: islpci_reset: failure\n",
+				priv->ndev->name);
 			return rc;
+		}
 	}
 
 	/* finally reset interface */
 	rc = islpci_reset_if(priv);
-	if (!rc) /* If successful */
-		return rc;
-	
-	printk(KERN_DEBUG  "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
+	if (rc)
+		printk(KERN_ERR "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
 	return rc;
-
 }
 
 struct net_device_stats *
@@ -604,7 +613,7 @@
 	islpci_private *priv = netdev_priv(ndev);
 
 #if VERBOSE > SHOW_ERROR_MESSAGES
-	DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics \n");
+	DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics\n");
 #endif
 
 	return &priv->statistics;
@@ -829,6 +838,12 @@
 	priv->monitor_type = ARPHRD_IEEE80211;
 	priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ?
 		priv->monitor_type : ARPHRD_ETHER;
+
+#if WIRELESS_EXT > 16
+	/* Add pointers to enable iwspy support. */
+	priv->wireless_data.spy_data = &priv->spy_data;
+	ndev->wireless_data = &priv->wireless_data;
+#endif /* WIRELESS_EXT > 16 */
 
 	/* save the start and end address of the PCI memory area */
 	ndev->mem_start = (unsigned long) priv->device_base;
diff -Nru a/drivers/net/wireless/prism54/islpci_dev.h b/drivers/net/wireless/prism54/islpci_dev.h
--- a/drivers/net/wireless/prism54/islpci_dev.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/wireless/prism54/islpci_dev.h	2004-12-24 13:36:47 -08:00
@@ -100,13 +100,16 @@
 
 	struct iw_spy_data spy_data; /* iwspy support */
 
+#if WIRELESS_EXT > 16
+	struct iw_public_data wireless_data;
+#endif /* WIRELESS_EXT > 16 */
+
 	int monitor_type; /* ARPHRD_IEEE80211 or ARPHRD_IEEE80211_PRISM */
 
 	struct islpci_acl acl;
 
 	/* PCI bus allocation & configuration members */
 	struct pci_dev *pdev;	/* PCI structure information */
-	u32 pci_state[16];	/* used for suspend/resume */
 	char firmware[33];
 
 	void __iomem *device_base;	/* ioremapped device base address */
diff -Nru a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
--- a/drivers/net/wireless/prism54/islpci_eth.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/net/wireless/prism54/islpci_eth.c	2004-12-24 13:36:18 -08:00
@@ -508,11 +508,12 @@
 	/* increment the transmit error counter */
 	statistics->tx_errors++;
 
+	printk(KERN_WARNING "%s: tx_timeout", ndev->name);
 	if (!priv->reset_task_pending) {
 		priv->reset_task_pending = 1;
+		printk(", scheduling a reset");
 		netif_stop_queue(ndev);
 		schedule_work(&priv->reset_task);
 	}
-
-	return;
+	printk("\n");
 }
diff -Nru a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c
--- a/drivers/net/wireless/prism54/islpci_hotplug.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/net/wireless/prism54/islpci_hotplug.c	2004-12-24 13:36:49 -08:00
@@ -107,9 +107,6 @@
 	islpci_private *priv;
 	int rvalue;
 
-	/* TRACE(DRV_NAME); */
-	
-	
 	/* Enable the pci device */
 	if (pci_enable_device(pdev)) {
 		printk(KERN_ERR "%s: pci_enable_device() failed.\n", DRV_NAME);
@@ -273,7 +270,7 @@
 	printk(KERN_NOTICE "%s: got suspend request (state %d)\n",
 	       ndev->name, state);
 
-	pci_save_state(pdev, priv->pci_state);
+	pci_save_state(pdev);
 
 	/* tell the device not to trigger interrupts for now... */
 	isl38xx_disable_interrupts(priv->device_base);
@@ -297,7 +294,7 @@
 
 	printk(KERN_NOTICE "%s: got resume request\n", ndev->name);
 
-	pci_restore_state(pdev, priv->pci_state);
+	pci_restore_state(pdev);
 
 	/* alright let's go into the PREBOOT state */
 	islpci_reset(priv, 1);
diff -Nru a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
--- a/drivers/net/wireless/prism54/islpci_mgt.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/net/wireless/prism54/islpci_mgt.c	2004-12-24 13:37:01 -08:00
@@ -319,8 +319,8 @@
 		}
 
 		/* Ensure the results of device DMA are visible to the CPU. */
-		pci_dma_sync_single(priv->pdev, buf->pci_addr,
-				    buf->size, PCI_DMA_FROMDEVICE);
+		pci_dma_sync_single_for_cpu(priv->pdev, buf->pci_addr,
+					    buf->size, PCI_DMA_FROMDEVICE);
 
 		/* Perform endianess conversion for PIMFOR header in-place. */
 		header = pimfor_decode_header(buf->mem, frag_len);
@@ -473,6 +473,7 @@
 		int timeleft;
 		struct islpci_mgmtframe *frame;
 
+		set_current_state(TASK_UNINTERRUPTIBLE);
 		timeleft = schedule_timeout(wait_cycle_jiffies);
 		frame = xchg(&priv->mgmt_received, NULL);
 		if (frame) {
diff -Nru a/drivers/net/wireless/prism54/islpci_mgt.h b/drivers/net/wireless/prism54/islpci_mgt.h
--- a/drivers/net/wireless/prism54/islpci_mgt.h	2004-12-24 13:36:19 -08:00
+++ b/drivers/net/wireless/prism54/islpci_mgt.h	2004-12-24 13:36:19 -08:00
@@ -31,8 +31,6 @@
 #define K_DEBUG(f, m, args...) do { if(f & m) printk(KERN_DEBUG args); } while(0)
 #define DEBUG(f, args...) K_DEBUG(f, pc_debug, args)
 
-#define TRACE(devname)   K_DEBUG(SHOW_TRACING, VERBOSE, "%s:  -> " __FUNCTION__ "()\n", devname)
-
 extern int pc_debug;
 #define init_wds 0	/* help compiler optimize away dead code */
 
diff -Nru a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c
--- a/drivers/net/wireless/prism54/oid_mgt.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/wireless/prism54/oid_mgt.c	2004-12-24 13:37:29 -08:00
@@ -201,7 +201,8 @@
 	OID_U32(DOT11_OID_STATIMEOUT, 0x19000000),
 	OID_U32_C(DOT11_OID_MLMEAUTOLEVEL, 0x19000001),
 	OID_U32(DOT11_OID_BSSTIMEOUT, 0x19000002),
-	OID_UNKNOWN(DOT11_OID_ATTACHMENT, 0x19000003),
+	[DOT11_OID_ATTACHMENT] = {0x19000003, 0,
+		sizeof(struct obj_attachment), OID_TYPE_ATTACH},
 	OID_STRUCT_C(DOT11_OID_PSMBUFFER, 0x19000004, struct obj_buffer,
 		     OID_TYPE_BUFFER),
 
@@ -329,6 +330,12 @@
 			mlme->size = le16_to_cpu(mlme->size);
 			break;
 		}
+	case OID_TYPE_ATTACH:{
+			struct obj_attachment *attach = data;
+			attach->id = le16_to_cpu(attach->id);
+			attach->size = le16_to_cpu(attach->size);; 
+			break;
+	}
 	case OID_TYPE_SSID:
 	case OID_TYPE_KEY:
 	case OID_TYPE_ADDR:
@@ -392,6 +399,12 @@
 			mlme->size = cpu_to_le16(mlme->size);
 			break;
 		}
+	case OID_TYPE_ATTACH:{
+			struct obj_attachment *attach = data;
+			attach->id = cpu_to_le16(attach->id);
+			attach->size = cpu_to_le16(attach->size);; 
+			break;
+	}
 	case OID_TYPE_SSID:
 	case OID_TYPE_KEY:
 	case OID_TYPE_ADDR:
@@ -465,6 +478,42 @@
 	return ret;
 }
 
+/* None of these are cached */
+int
+mgt_set_varlen(islpci_private *priv, enum oid_num_t n, void *data, int extra_len)
+{
+	int ret = 0;
+	struct islpci_mgmtframe *response;
+	int response_op = PIMFOR_OP_ERROR;
+	int dlen;
+	u32 oid;
+
+	BUG_ON(OID_NUM_LAST <= n);
+
+	dlen = isl_oid[n].size;
+	oid = isl_oid[n].oid;
+
+	mgt_cpu_to_le(isl_oid[n].flags & OID_FLAG_TYPE, data);
+
+	if (islpci_get_state(priv) >= PRV_STATE_READY) {
+		ret = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET, oid,
+					     data, dlen + extra_len, &response);
+		if (!ret) {
+			response_op = response->header->operation;
+			islpci_mgt_release(response);
+		}
+		if (ret || response_op == PIMFOR_OP_ERROR)
+			ret = -EIO;
+	} else 
+		ret = -EIO;
+
+	/* re-set given data to what it was */
+	if (data)
+		mgt_le_to_cpu(isl_oid[n].flags & OID_FLAG_TYPE, data);
+
+	return ret;
+}
+
 int
 mgt_get_request(islpci_private *priv, enum oid_num_t n, int extra, void *data,
 		union oid_res_t *res)
@@ -555,15 +604,18 @@
 		u32 oid = t->oid;
 		BUG_ON(data == NULL);
 		while (j <= t->range) {
-			response = NULL;
-			ret |= islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
+			int r = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
 						      oid, data, t->size,
 						      &response);
 			if (response) {
-				ret |= (response->header->operation ==
-					PIMFOR_OP_ERROR);
+				r |= (response->header->operation == PIMFOR_OP_ERROR);
 				islpci_mgt_release(response);
 			}
+			if (r)
+				printk(KERN_ERR "%s: mgt_commit_list: failure. "
+					"oid=%08x err=%d\n",
+					priv->ndev->name, oid, r);
+			ret |= r;
 			j++;
 			oid++;
 			data += t->size;
@@ -624,7 +676,7 @@
 static int
 mgt_update_addr(islpci_private *priv)
 {
-	struct islpci_mgmtframe *res = NULL;
+	struct islpci_mgmtframe *res;
 	int ret;
 
 	ret = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET,
@@ -638,26 +690,26 @@
 	if (res)
 		islpci_mgt_release(res);
 
+	if (ret)
+		printk(KERN_ERR "%s: mgt_update_addr: failure\n", priv->ndev->name);
 	return ret;
 }
 
-void
+#define VEC_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+int
 mgt_commit(islpci_private *priv)
 {
 	int rvalue;
 	u32 u;
 
 	if (islpci_get_state(priv) < PRV_STATE_INIT)
-		return;
+		return 0;
 
-	rvalue = mgt_commit_list(priv, commit_part1,
-				 sizeof (commit_part1) /
-				 sizeof (commit_part1[0]));
+	rvalue = mgt_commit_list(priv, commit_part1, VEC_SIZE(commit_part1));
 
 	if (priv->iw_mode != IW_MODE_MONITOR)
-		rvalue |= mgt_commit_list(priv, commit_part2,
-					  sizeof (commit_part2) /
-					  sizeof (commit_part2[0]));
+		rvalue |= mgt_commit_list(priv, commit_part2, VEC_SIZE(commit_part2));
 
 	u = OID_INL_MODE;
 	rvalue |= mgt_commit_list(priv, &u, 1);
@@ -666,9 +718,43 @@
 	if (rvalue) {
 		/* some request have failed. The device might be in an
 		   incoherent state. We should reset it ! */
-		printk(KERN_DEBUG "%s: mgt_commit has failed. Restart the "
-		       "device \n", priv->ndev->name);
+		printk(KERN_DEBUG "%s: mgt_commit: failure\n", priv->ndev->name);
 	}
+	return rvalue;
+}
+
+/* The following OIDs need to be "unlatched":
+ *
+ * MEDIUMLIMIT,BEACONPERIOD,DTIMPERIOD,ATIMWINDOW,LISTENINTERVAL
+ * FREQUENCY,EXTENDEDRATES.
+ *
+ * The way to do this is to set ESSID. Note though that they may get 
+ * unlatch before though by setting another OID. */
+void
+mgt_unlatch_all(islpci_private *priv)
+{
+	u32 u;
+	int rvalue = 0;
+
+	if (islpci_get_state(priv) < PRV_STATE_INIT)
+		return;
+
+	u = DOT11_OID_SSID;
+	rvalue = mgt_commit_list(priv, &u, 1);
+	/* Necessary if in MANUAL RUN mode? */
+#if 0
+	u = OID_INL_MODE;
+	rvalue |= mgt_commit_list(priv, &u, 1);
+
+	u = DOT11_OID_MLMEAUTOLEVEL;
+	rvalue |= mgt_commit_list(priv, &u, 1);
+
+	u = OID_INL_MODE;
+	rvalue |= mgt_commit_list(priv, &u, 1);
+#endif
+
+	if (rvalue)
+		printk(KERN_DEBUG "%s: Unlatching OIDs failed\n", priv->ndev->name);
 }
 
 /* This will tell you if you are allowed to answer a mlme(ex) request .*/
@@ -769,6 +855,14 @@
 					"id=0x%X\nstate=0x%X\n"
 					"code=0x%X\nsize=0x%X\n", mlme->id,
 					mlme->state, mlme->code, mlme->size);
+		}
+		break;
+	case OID_TYPE_ATTACH:{
+			struct obj_attachment *attach = r->ptr;
+			return snprintf(str, PRIV_STR_SIZE,
+					"id=%d\nsize=%d\n",
+					attach->id,
+					attach->size);
 		}
 		break;
 	case OID_TYPE_SSID:{
diff -Nru a/drivers/net/wireless/prism54/oid_mgt.h b/drivers/net/wireless/prism54/oid_mgt.h
--- a/drivers/net/wireless/prism54/oid_mgt.h	2004-12-24 13:37:29 -08:00
+++ b/drivers/net/wireless/prism54/oid_mgt.h	2004-12-24 13:37:29 -08:00
@@ -36,6 +36,8 @@
 void mgt_le_to_cpu(int, void *);
 
 int mgt_set_request(islpci_private *, enum oid_num_t, int, void *);
+int mgt_set_varlen(islpci_private *, enum oid_num_t, void *, int);
+
 
 int mgt_get_request(islpci_private *, enum oid_num_t, int, void *,
 		    union oid_res_t *);
@@ -46,7 +48,8 @@
 
 void mgt_get(islpci_private *, enum oid_num_t, void *);
 
-void mgt_commit(islpci_private *);
+int mgt_commit(islpci_private *);
+void mgt_unlatch_all(islpci_private *);
 
 int mgt_mlme_answer(islpci_private *);
 
diff -Nru a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
--- a/drivers/net/wireless/strip.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/net/wireless/strip.c	2004-12-24 13:37:02 -08:00
@@ -85,9 +85,9 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 
 # include <linux/ctype.h>
 #include <linux/string.h>
@@ -1250,7 +1250,7 @@
 			set_baud(tty, strip_info->user_baud);
 	}
 
-	tty->driver->write(tty, 0, s.string, s.length);
+	tty->driver->write(tty, s.string, s.length);
 #ifdef EXT_COUNTERS
 	strip_info->tx_ebytes += s.length;
 #endif
@@ -1272,7 +1272,7 @@
 
 	if (strip_info->tx_left > 0) {
 		int num_written =
-		    tty->driver->write(tty, 0, strip_info->tx_head,
+		    tty->driver->write(tty, strip_info->tx_head,
 				      strip_info->tx_left);
 		strip_info->tx_left -= num_written;
 		strip_info->tx_head += num_written;
diff -Nru a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
--- a/drivers/net/wireless/wavelan.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/net/wireless/wavelan.c	2004-12-24 13:37:19 -08:00
@@ -2172,6 +2172,11 @@
 	range->num_bitrates = 1;
 	range->bitrate[0] = 2000000;	/* 2 Mb/s */
 
+	/* Event capability (kernel + driver) */
+	range->event_capa[0] = (IW_EVENT_CAPA_MASK(0x8B02) |
+				IW_EVENT_CAPA_MASK(0x8B04));
+	range->event_capa[1] = IW_EVENT_CAPA_K_1;
+
 	/* Disable interrupts and save flags. */
 	spin_lock_irqsave(&lp->spinlock, flags);
 	
@@ -2403,11 +2408,10 @@
 	.num_standard	= sizeof(wavelan_handler)/sizeof(iw_handler),
 	.num_private	= sizeof(wavelan_private_handler)/sizeof(iw_handler),
 	.num_private_args = sizeof(wavelan_private_args)/sizeof(struct iw_priv_args),
-	.standard	= (iw_handler *) wavelan_handler,
-	.private	= (iw_handler *) wavelan_private_handler,
-	.private_args	= (struct iw_priv_args *) wavelan_private_args,
-	.spy_offset	= ((void *) (&((net_local *) NULL)->spy_data) -
-			   (void *) NULL),
+	.standard	= wavelan_handler,
+	.private	= wavelan_private_handler,
+	.private_args	= wavelan_private_args,
+	.get_wireless_stats = wavelan_get_wireless_stats,
 };
 
 /*------------------------------------------------------------------*/
@@ -4191,8 +4195,9 @@
 #endif				/* SET_MAC_ADDRESS */
 
 #ifdef WIRELESS_EXT		/* if wireless extension exists in the kernel */
-	dev->get_wireless_stats = wavelan_get_wireless_stats;
-	dev->wireless_handlers = (struct iw_handler_def *)&wavelan_handler_def;
+	dev->wireless_handlers = &wavelan_handler_def;
+	lp->wireless_data.spy_data = &lp->spy_data;
+	dev->wireless_data = &lp->wireless_data;
 #endif
 
 	dev->mtu = WAVELAN_MTU;
diff -Nru a/drivers/net/wireless/wavelan.p.h b/drivers/net/wireless/wavelan.p.h
--- a/drivers/net/wireless/wavelan.p.h	2004-12-24 13:37:02 -08:00
+++ b/drivers/net/wireless/wavelan.p.h	2004-12-24 13:37:02 -08:00
@@ -377,8 +377,8 @@
 #include	<linux/in.h>
 #include	<linux/string.h>
 #include	<linux/delay.h>
+#include	<linux/bitops.h>
 #include	<asm/system.h>
-#include	<asm/bitops.h>
 #include	<asm/io.h>
 #include	<asm/dma.h>
 #include	<asm/uaccess.h>
@@ -510,6 +510,7 @@
   iw_stats	wstats;		/* Wireless-specific statistics */
 
   struct iw_spy_data	spy_data;
+  struct iw_public_data	wireless_data;
 #endif
 
 #ifdef HISTOGRAM
@@ -614,6 +615,8 @@
 /* ------------------- IOCTL, STATS & RECONFIG ------------------- */
 static en_stats	*
 	wavelan_get_stats(struct net_device *);	/* Give stats /proc/net/dev */
+static iw_stats *
+	wavelan_get_wireless_stats(struct net_device *);
 static void
 	wavelan_set_multicast_list(struct net_device *);
 /* ----------------------- PACKET RECEPTION ----------------------- */
diff -Nru a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
--- a/drivers/net/wireless/wavelan_cs.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/net/wireless/wavelan_cs.c	2004-12-24 13:36:59 -08:00
@@ -502,7 +502,7 @@
   
 void wv_roam_init(struct net_device *dev)
 {
-  net_local  *lp= (net_local *)dev->priv;
+  net_local  *lp= netdev_priv(dev);
 
   /* Do not remove this unless you have a good reason */
   printk(KERN_NOTICE "%s: Warning, you have enabled roaming on"
@@ -532,7 +532,7 @@
 void wv_roam_cleanup(struct net_device *dev)
 {
   wavepoint_history *ptr,*old_ptr;
-  net_local *lp= (net_local *)dev->priv;
+  net_local *lp= netdev_priv(dev);
   
   printk(KERN_DEBUG "WaveLAN: Roaming Disabled on device %s\n",dev->name);
   
@@ -762,7 +762,7 @@
   unsigned short nwid=ntohs(beacon->nwid);  
   unsigned short sigqual=stats[2] & MMR_SGNL_QUAL;   /* SNR of beacon */
   wavepoint_history *wavepoint=NULL;                /* WavePoint table entry */
-  net_local *lp=(net_local *)dev->priv;              /* Device info */
+  net_local *lp = netdev_priv(dev);              /* Device info */
 
 #ifdef I_NEED_THIS_FEATURE
   /* Some people don't need this, some other may need it */
@@ -1006,7 +1006,7 @@
 static inline void
 wv_82593_reconfig(struct net_device *	dev)
 {
-  net_local *		lp = (net_local *)dev->priv;
+  net_local *		lp = netdev_priv(dev);
   dev_link_t *		link = lp->link;
   unsigned long		flags;
 
@@ -1135,7 +1135,7 @@
 wv_mmc_show(struct net_device *	dev)
 {
   ioaddr_t	base = dev->base_addr;
-  net_local *	lp = (net_local *)dev->priv;
+  net_local *	lp = netdev_priv(dev);
   mmr_t		m;
 
   /* Basic check */
@@ -1224,7 +1224,7 @@
 static void
 wv_ru_show(struct net_device *	dev)
 {
-  net_local *lp = (net_local *) dev->priv;
+  net_local *lp = netdev_priv(dev);
 
   printk(KERN_DEBUG "##### wavelan i82593 receiver status: #####\n");
   printk(KERN_DEBUG "ru: rfp %d stop %d", lp->rfp, lp->stop);
@@ -1258,9 +1258,7 @@
 static void
 wv_local_show(struct net_device *	dev)
 {
-  net_local *lp;
-
-  lp = (net_local *)dev->priv;
+  net_local *lp = netdev_priv(dev);
 
   printk(KERN_DEBUG "local:");
   /*
@@ -1418,7 +1416,7 @@
   printk(KERN_DEBUG "%s: <>wavelan_get_stats()\n", dev->name);
 #endif
 
-  return(&((net_local *) dev->priv)->stats);
+  return(&((net_local *)netdev_priv(dev))->stats);
 }
 
 /*------------------------------------------------------------------*/
@@ -1433,7 +1431,7 @@
 static void
 wavelan_set_multicast_list(struct net_device *	dev)
 {
-  net_local *	lp = (net_local *) dev->priv;
+  net_local *	lp = netdev_priv(dev);
 
 #ifdef DEBUG_IOCTL_TRACE
   printk(KERN_DEBUG "%s: ->wavelan_set_multicast_list()\n", dev->name);
@@ -1550,7 +1548,6 @@
 /*
  * Frequency setting (for hardware able of it)
  * It's a bit complicated and you don't really want to look into it...
- * (called in wavelan_ioctl)
  */
 static inline int
 wv_set_frequency(u_long		base,	/* i/o port of the card */
@@ -1826,7 +1823,7 @@
 wl_his_gather(struct net_device *	dev,
 	      u_char *	stats)		/* Statistics to gather */
 {
-  net_local *	lp = (net_local *) dev->priv;
+  net_local *	lp = netdev_priv(dev);
   u_char	level = stats[0] & MMR_SIGNAL_LVL;
   int		i;
 
@@ -1840,28 +1837,15 @@
 }
 #endif	/* HISTOGRAM */
 
-static inline int
-wl_netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void wl_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	u32 ethcmd;
-
-	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-		return -EFAULT;
-
-	switch (ethcmd) {
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-
-		strncpy(info.driver, "wavelan_cs", sizeof(info.driver)-1);
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-	}
-
-	return -EOPNOTSUPP;
+	strncpy(info->driver, "wavelan_cs", sizeof(info->driver)-1);
 }
 
+static struct ethtool_ops ops = {
+	.get_drvinfo = wl_get_drvinfo
+};
+
 /*------------------------------------------------------------------*/
 /*
  * Wireless Handler : get protocol name
@@ -1885,7 +1869,7 @@
 			    char *extra)
 {
 	ioaddr_t base = dev->base_addr;
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	psa_t psa;
 	mm_t m;
 	unsigned long flags;
@@ -1943,7 +1927,7 @@
 			    union iwreq_data *wrqu,
 			    char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	psa_t psa;
 	unsigned long flags;
 	int ret = 0;
@@ -1975,7 +1959,7 @@
 			    char *extra)
 {
 	ioaddr_t base = dev->base_addr;
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	unsigned long flags;
 	int ret;
 
@@ -2005,7 +1989,7 @@
 			    char *extra)
 {
 	ioaddr_t base = dev->base_addr;
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	psa_t psa;
 	unsigned long flags;
 	int ret = 0;
@@ -2051,7 +2035,7 @@
 			    char *extra)
 {
 	ioaddr_t base = dev->base_addr;
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	psa_t psa;
 	unsigned long flags;
 	int ret = 0;
@@ -2086,7 +2070,7 @@
 			    union iwreq_data *wrqu,
 			    char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	psa_t psa;
 	unsigned long flags;
 	int ret = 0;
@@ -2117,7 +2101,7 @@
 			      char *extra)
 {
 	ioaddr_t base = dev->base_addr;
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	unsigned long flags;
 	psa_t psa;
 	int ret = 0;
@@ -2187,7 +2171,7 @@
 			      char *extra)
 {
 	ioaddr_t base = dev->base_addr;
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	psa_t psa;
 	unsigned long flags;
 	int ret = 0;
@@ -2234,7 +2218,7 @@
 			     union iwreq_data *wrqu,
 			     char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	unsigned long flags;
 	int ret = 0;
 
@@ -2282,7 +2266,7 @@
 			     union iwreq_data *wrqu,
 			     char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 
 	/* Is the domain ID active ? */
 	wrqu->data.flags = lp->filter_domains;
@@ -2347,7 +2331,7 @@
 			    union iwreq_data *wrqu,
 			    char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	unsigned long flags;
 	int ret = 0;
 
@@ -2406,7 +2390,7 @@
 			     char *extra)
 {
 	ioaddr_t base = dev->base_addr;
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	struct iw_range *range = (struct iw_range *) extra;
 	unsigned long flags;
 	int ret = 0;
@@ -2438,6 +2422,12 @@
 	range->num_bitrates = 1;
 	range->bitrate[0] = 2000000;	/* 2 Mb/s */
 
+	/* Event capability (kernel + driver) */
+	range->event_capa[0] = (IW_EVENT_CAPA_MASK(0x8B02) |
+				IW_EVENT_CAPA_MASK(0x8B04) |
+				IW_EVENT_CAPA_MASK(0x8B06));
+	range->event_capa[1] = IW_EVENT_CAPA_K_1;
+
 	/* Disable interrupts and save flags. */
 	spin_lock_irqsave(&lp->spinlock, flags);
 	
@@ -2476,7 +2466,7 @@
 			    char *extra)
 {
 	ioaddr_t base = dev->base_addr;
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	psa_t psa;
 	unsigned long flags;
 
@@ -2507,7 +2497,7 @@
 			    union iwreq_data *wrqu,
 			    char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	psa_t psa;
 	unsigned long flags;
 
@@ -2535,7 +2525,7 @@
 			    union iwreq_data *wrqu,
 			    char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 	unsigned long flags;
 
 	/* Disable interrupts and save flags. */
@@ -2580,7 +2570,7 @@
 			     union iwreq_data *wrqu,
 			     char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 
 	/* Check the number of intervals. */
 	if (wrqu->data.length > 16) {
@@ -2623,7 +2613,7 @@
 			     union iwreq_data *wrqu,
 			     char *extra)
 {
-	net_local *lp = (net_local *) dev->priv;	/* lp is not unused */
+	net_local *lp = netdev_priv(dev);
 
 	/* Set the number of intervals. */
 	wrqu->data.length = lp->his_number;
@@ -2737,50 +2727,14 @@
 	.num_standard	= sizeof(wavelan_handler)/sizeof(iw_handler),
 	.num_private	= sizeof(wavelan_private_handler)/sizeof(iw_handler),
 	.num_private_args = sizeof(wavelan_private_args)/sizeof(struct iw_priv_args),
-	.standard	= (iw_handler *) wavelan_handler,
-	.private	= (iw_handler *) wavelan_private_handler,
-	.private_args	= (struct iw_priv_args *) wavelan_private_args,
-	.spy_offset	= ((void *) (&((net_local *) NULL)->spy_data) -
-			   (void *) NULL),
+	.standard	= wavelan_handler,
+	.private	= wavelan_private_handler,
+	.private_args	= wavelan_private_args,
+	.get_wireless_stats = wavelan_get_wireless_stats,
 };
 
 /*------------------------------------------------------------------*/
 /*
- * Perform ioctl : config & info stuff
- * This is here that are treated the wireless extensions (iwconfig)
- */
-static int
-wavelan_ioctl(struct net_device *	dev,	/* Device on wich the ioctl apply */
-	      struct ifreq *	rq,	/* Data passed */
-	      int		cmd)	/* Ioctl number */
-{
-  int			ret = 0;
-
-#ifdef DEBUG_IOCTL_TRACE
-  printk(KERN_DEBUG "%s: ->wavelan_ioctl(cmd=0x%X)\n", dev->name, cmd);
-#endif
-
-  /* Look what is the request */
-  switch(cmd)
-    {
-    case SIOCETHTOOL:
-      ret = wl_netdev_ethtool_ioctl(dev, rq->ifr_data);
-      break;
-
-      /* ------------------- OTHER IOCTL ------------------- */
-
-    default:
-      ret = -EOPNOTSUPP;
-    }
-
-#ifdef DEBUG_IOCTL_TRACE
-  printk(KERN_DEBUG "%s: <-wavelan_ioctl()\n", dev->name);
-#endif
-  return ret;
-}
-
-/*------------------------------------------------------------------*/
-/*
  * Get wireless statistics
  * Called by /proc/net/wireless...
  */
@@ -2788,7 +2742,7 @@
 wavelan_get_wireless_stats(struct net_device *	dev)
 {
   ioaddr_t		base = dev->base_addr;
-  net_local *		lp = (net_local *) dev->priv;
+  net_local *		lp = netdev_priv(dev);
   mmr_t			m;
   iw_stats *		wstats;
   unsigned long		flags;
@@ -2913,7 +2867,7 @@
 	       int		fd_p,
 	       int		sksize)
 {
-  net_local *		lp = (net_local *) dev->priv;
+  net_local *		lp = netdev_priv(dev);
   struct sk_buff *	skb;
 
 #ifdef DEBUG_RX_TRACE
@@ -3015,7 +2969,7 @@
 wv_packet_rcv(struct net_device *	dev)
 {
   ioaddr_t	base = dev->base_addr;
-  net_local *	lp = (net_local *) dev->priv;
+  net_local *	lp = netdev_priv(dev);
   int		newrfp;
   int		rp;
   int		len;
@@ -3150,7 +3104,7 @@
 		void *		buf,
 		short		length)
 {
-  net_local *		lp = (net_local *) dev->priv;
+  net_local *		lp = netdev_priv(dev);
   ioaddr_t		base = dev->base_addr;
   unsigned long		flags;
   int			clen = length;
@@ -3211,7 +3165,7 @@
 wavelan_packet_xmit(struct sk_buff *	skb,
 		    struct net_device *		dev)
 {
-  net_local *		lp = (net_local *)dev->priv;
+  net_local *		lp = netdev_priv(dev);
   unsigned long		flags;
 
 #ifdef DEBUG_TX_TRACE
@@ -3470,7 +3424,7 @@
 wv_ru_stop(struct net_device *	dev)
 {
   ioaddr_t	base = dev->base_addr;
-  net_local *	lp = (net_local *) dev->priv;
+  net_local *	lp = netdev_priv(dev);
   unsigned long	flags;
   int		status;
   int		spin;
@@ -3533,7 +3487,7 @@
 wv_ru_start(struct net_device *	dev)
 {
   ioaddr_t	base = dev->base_addr;
-  net_local *	lp = (net_local *) dev->priv;
+  net_local *	lp = netdev_priv(dev);
   unsigned long	flags;
 
 #ifdef DEBUG_CONFIG_TRACE
@@ -3621,7 +3575,7 @@
 wv_82593_config(struct net_device *	dev)
 {
   ioaddr_t			base = dev->base_addr;
-  net_local *			lp = (net_local *) dev->priv;
+  net_local *			lp = netdev_priv(dev);
   struct i82593_conf_block	cfblk;
   int				ret = TRUE;
 
@@ -3796,7 +3750,7 @@
 {
   int		i;
   conf_reg_t	reg = { 0, CS_READ, CISREG_COR, 0 };
-  dev_link_t *	link = ((net_local *) dev->priv)->link;
+  dev_link_t *	link = ((net_local *)netdev_priv(dev))->link;
 
 #ifdef DEBUG_CONFIG_TRACE
   printk(KERN_DEBUG "%s: ->wv_pcmcia_reset()\n", dev->name);
@@ -3856,7 +3810,7 @@
 static int
 wv_hw_config(struct net_device *	dev)
 {
-  net_local *		lp = (net_local *) dev->priv;
+  net_local *		lp = netdev_priv(dev);
   ioaddr_t		base = dev->base_addr;
   unsigned long		flags;
   int			ret = FALSE;
@@ -3963,7 +3917,7 @@
 static inline void
 wv_hw_reset(struct net_device *	dev)
 {
-  net_local *	lp = (net_local *) dev->priv;
+  net_local *	lp = netdev_priv(dev);
 
 #ifdef DEBUG_CONFIG_TRACE
   printk(KERN_DEBUG "%s: ->wv_hw_reset()\n", dev->name);
@@ -4131,8 +4085,8 @@
       return FALSE;
     }
 
-  strcpy(((net_local *) dev->priv)->node.dev_name, dev->name);
-  link->dev = &((net_local *) dev->priv)->node;
+  strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name);
+  link->dev = &((net_local *) netdev_priv(dev))->node;
 
 #ifdef DEBUG_CONFIG_TRACE
   printk(KERN_DEBUG "<-wv_pcmcia_config()\n");
@@ -4203,7 +4157,7 @@
   printk(KERN_DEBUG "%s: ->wavelan_interrupt()\n", dev->name);
 #endif
 
-  lp = (net_local *) dev->priv;
+  lp = netdev_priv(dev);
   base = dev->base_addr;
 
 #ifdef DEBUG_INTERRUPT_INFO
@@ -4453,7 +4407,7 @@
 static void
 wavelan_watchdog(struct net_device *	dev)
 {
-  net_local *		lp = (net_local *) dev->priv;
+  net_local *		lp = netdev_priv(dev);
   ioaddr_t		base = dev->base_addr;
   unsigned long		flags;
   int			aborted = FALSE;
@@ -4528,8 +4482,8 @@
 static int
 wavelan_open(struct net_device *	dev)
 {
-  dev_link_t *	link = ((net_local *) dev->priv)->link;
-  net_local *	lp = (net_local *)dev->priv;
+  net_local *	lp = netdev_priv(dev);
+  dev_link_t *	link = lp->link;
   ioaddr_t	base = dev->base_addr;
 
 #ifdef DEBUG_CALLBACK_TRACE
@@ -4583,7 +4537,7 @@
 static int
 wavelan_close(struct net_device *	dev)
 {
-  dev_link_t *	link = ((net_local *) dev->priv)->link;
+  dev_link_t *	link = ((net_local *)netdev_priv(dev))->link;
   ioaddr_t	base = dev->base_addr;
 
 #ifdef DEBUG_CALLBACK_TRACE
@@ -4686,7 +4640,7 @@
   }
   link->priv = link->irq.Instance = dev;
 
-  lp = dev->priv;
+  lp = netdev_priv(dev);
 
   /* Init specific data */
   lp->configured = 0;
@@ -4718,11 +4672,12 @@
   /* Set the watchdog timer */
   dev->tx_timeout	= &wavelan_watchdog;
   dev->watchdog_timeo	= WATCHDOG_JIFFIES;
+  SET_ETHTOOL_OPS(dev, &ops);
 
 #ifdef WIRELESS_EXT	/* If wireless extension exist in the kernel */
-  dev->wireless_handlers = (struct iw_handler_def *)&wavelan_handler_def;
-  dev->do_ioctl = wavelan_ioctl;	/* old wireless extensions */
-  dev->get_wireless_stats = wavelan_get_wireless_stats;
+  dev->wireless_handlers = &wavelan_handler_def;
+  lp->wireless_data.spy_data = &lp->spy_data;
+  dev->wireless_data = &lp->wireless_data;
 #endif
 
   /* Other specific data */
@@ -4820,8 +4775,8 @@
       if (link->dev)
 	unregister_netdev(dev);
       link->dev = NULL;
-      ((net_local *) dev->priv)->link = NULL;
-      ((net_local *) dev->priv)->dev = NULL;
+      ((net_local *)netdev_priv(dev))->link = NULL;
+      ((net_local *)netdev_priv(dev))->dev = NULL;
       free_netdev(dev);
     }
   kfree(link);
diff -Nru a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
--- a/drivers/net/wireless/wavelan_cs.p.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/net/wireless/wavelan_cs.p.h	2004-12-24 13:37:18 -08:00
@@ -428,10 +428,10 @@
 #include <linux/spinlock.h>
 #include <linux/in.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -629,6 +629,7 @@
   iw_stats	wstats;		/* Wireless specific stats */
 
   struct iw_spy_data	spy_data;
+  struct iw_public_data	wireless_data;
 #endif
 
 #ifdef HISTOGRAM
@@ -725,6 +726,8 @@
 /* ------------------- IOCTL, STATS & RECONFIG ------------------- */
 static en_stats	*
 	wavelan_get_stats(struct net_device *);	/* Give stats /proc/net/dev */
+static iw_stats *
+	wavelan_get_wireless_stats(struct net_device *);
 /* ----------------------- PACKET RECEPTION ----------------------- */
 static inline int
 	wv_start_of_frame(struct net_device *,	/* Seek beggining of current frame */
diff -Nru a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
--- a/drivers/net/wireless/wl3501_cs.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/wireless/wl3501_cs.c	2004-12-24 13:36:16 -08:00
@@ -1487,55 +1487,14 @@
 	return wstats;
 }
 
-static inline int wl3501_ethtool_ioctl(struct net_device *dev, void __user *uaddr)
+static void wl3501_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	u32 ethcmd;
-	int rc = -EFAULT;
-
-	if (copy_from_user(&ethcmd, uaddr, sizeof(ethcmd)))
-		goto out;
-
-	switch (ethcmd) {
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = { .cmd = ETHTOOL_GDRVINFO, };
-
-		strlcpy(info.driver, wl3501_dev_info, sizeof(info.driver));
-		rc = copy_to_user(uaddr, &info, sizeof(info)) ? -EFAULT : 1;
-	}
-	default:
-		rc = -EOPNOTSUPP;
-		break;
-	}
-out:
-	return rc;
+	strlcpy(info->driver, wl3501_dev_info, sizeof(info->driver));
 }
 
-/**
- * wl3501_ioctl - Perform IOCTL call functions
- * @dev - network device
- * @ifreq - request
- * @cmd - command
- *
- * Perform IOCTL call functions here. Some are privileged operations and the
- * effective uid is checked in those cases.
- *
- * This part is optional. Needed only if you want to run wlu (unix version).
- *
- * CAUTION: To prevent interrupted by wl3501_interrupt() and timer-based
- * wl3501_hard_start_xmit() from other interrupts, this should be run
- * single-threaded.
- */
-static int wl3501_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-{
-	int rc = -ENODEV;
-
-	if (netif_device_present(dev)) {
-		rc = -EOPNOTSUPP;
-		if (cmd == SIOCETHTOOL)
-			rc = wl3501_ethtool_ioctl(dev, rq->ifr_data);
-	}
-	return rc;
-}
+static struct ethtool_ops ops = {
+	.get_drvinfo = wl3501_get_drvinfo
+};
 
 /**
  * wl3501_detach - deletes a driver "instance"
@@ -2047,8 +2006,8 @@
 	dev->watchdog_timeo	= 5 * HZ;
 	dev->get_stats		= wl3501_get_stats;
 	dev->get_wireless_stats = wl3501_get_wireless_stats;
-	dev->do_ioctl		= wl3501_ioctl;
 	dev->wireless_handlers	= (struct iw_handler_def *)&wl3501_handler_def;
+	SET_ETHTOOL_OPS(dev, &ops);
 	netif_stop_queue(dev);
 	link->priv = link->irq.Instance = dev;
 
diff -Nru a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
--- a/drivers/net/yellowfin.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/net/yellowfin.c	2004-12-24 13:36:47 -08:00
@@ -124,10 +124,10 @@
 #include <linux/skbuff.h>
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/processor.h>		/* Processor type for cache alignment. */
 #include <asm/unaligned.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 /* These identify the driver base version and may not be removed. */
@@ -136,20 +136,6 @@
 KERN_INFO "  http://www.scyld.com/network/yellowfin.html\n"
 KERN_INFO "  (unofficial 2.4.x port, " DRV_VERSION ", " DRV_RELDATE ")\n";
 
-#ifndef USE_IO_OPS
-#undef inb
-#undef inw
-#undef inl
-#undef outb
-#undef outw
-#undef outl
-#define inb readb
-#define inw readw
-#define inl readl
-#define outb writeb
-#define outw writew
-#define outl writel
-#endif /* !USE_IO_OPS */
 MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
 MODULE_DESCRIPTION("Packet Engines Yellowfin G-NIC Gigabit Ethernet driver");
 MODULE_LICENSE("GPL");
@@ -389,11 +375,12 @@
 	u16 advertising;					/* NWay media advertisement */
 	unsigned char phys[MII_CNT];		/* MII device addresses, only first one used */
 	spinlock_t lock;
+	void __iomem *base;
 };
 
-static int read_eeprom(long ioaddr, int location);
-static int mdio_read(long ioaddr, int phy_id, int location);
-static void mdio_write(long ioaddr, int phy_id, int location, int value);
+static int read_eeprom(void __iomem *ioaddr, int location);
+static int mdio_read(void __iomem *ioaddr, int phy_id, int location);
+static void mdio_write(void __iomem *ioaddr, int phy_id, int location, int value);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int yellowfin_open(struct net_device *dev);
 static void yellowfin_timer(unsigned long data);
@@ -406,6 +393,7 @@
 static int yellowfin_close(struct net_device *dev);
 static struct net_device_stats *yellowfin_get_stats(struct net_device *dev);
 static void set_rx_mode(struct net_device *dev);
+static struct ethtool_ops ethtool_ops;
 
 
 static int __devinit yellowfin_init_one(struct pci_dev *pdev,
@@ -416,11 +404,16 @@
 	int irq;
 	int chip_idx = ent->driver_data;
 	static int find_cnt;
-	long ioaddr, real_ioaddr;
+	void __iomem *ioaddr;
 	int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
 	int drv_flags = pci_id_tbl[chip_idx].drv_flags;
         void *ring_space;
         dma_addr_t ring_dma;
+#ifdef USE_IO_OPS
+	int bar = 0;
+#else
+	int bar = 1;
+#endif
 	
 /* when built into the kernel, we only print version if device is found */
 #ifndef MODULE
@@ -440,26 +433,22 @@
 	SET_MODULE_OWNER(dev);
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
-	np = dev->priv;
+	np = netdev_priv(dev);
 
 	if (pci_request_regions(pdev, DRV_NAME))
 		goto err_out_free_netdev;
 
 	pci_set_master (pdev);
 
-#ifdef USE_IO_OPS
-	real_ioaddr = ioaddr = pci_resource_start (pdev, 0);
-#else
-	real_ioaddr = ioaddr = pci_resource_start (pdev, 1);
-	ioaddr = (long) ioremap(ioaddr, YELLOWFIN_SIZE);
+	ioaddr = pci_iomap(pdev, bar, YELLOWFIN_SIZE);
 	if (!ioaddr)
 		goto err_out_free_res;
-#endif
+
 	irq = pdev->irq;
 
 	if (drv_flags & DontUseEeprom)
 		for (i = 0; i < 6; i++)
-			dev->dev_addr[i] = inb(ioaddr + StnAddr + i);
+			dev->dev_addr[i] = ioread8(ioaddr + StnAddr + i);
 	else {
 		int ee_offset = (read_eeprom(ioaddr, 6) == 0xff ? 0x100 : 0);
 		for (i = 0; i < 6; i++)
@@ -467,9 +456,9 @@
 	}
 
 	/* Reset the chip. */
-	outl(0x80000000, ioaddr + DMACtrl);
+	iowrite32(0x80000000, ioaddr + DMACtrl);
 
-	dev->base_addr = ioaddr;
+	dev->base_addr = (unsigned long)ioaddr;
 	dev->irq = irq;
 
 	pci_set_drvdata(pdev, dev);
@@ -478,6 +467,7 @@
 	np->pci_dev = pdev;
 	np->chip_id = chip_idx;
 	np->drv_flags = drv_flags;
+	np->base = ioaddr;
 
 	ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
 	if (!ring_space)
@@ -521,6 +511,7 @@
 	dev->get_stats = &yellowfin_get_stats;
 	dev->set_multicast_list = &set_rx_mode;
 	dev->do_ioctl = &netdev_ioctl;
+	SET_ETHTOOL_OPS(dev, &ethtool_ops);
 	dev->tx_timeout = yellowfin_tx_timeout;
 	dev->watchdog_timeo = TX_TIMEOUT;
 
@@ -531,8 +522,9 @@
 	if (i)
 		goto err_out_unmap_status;
 
-	printk(KERN_INFO "%s: %s type %8x at 0x%lx, ",
-		   dev->name, pci_id_tbl[chip_idx].name, inl(ioaddr + ChipRev), ioaddr);
+	printk(KERN_INFO "%s: %s type %8x at %p, ",
+		   dev->name, pci_id_tbl[chip_idx].name,
+		   ioread32(ioaddr + ChipRev), ioaddr);
 	for (i = 0; i < 5; i++)
 			printk("%2.2x:", dev->dev_addr[i]);
 	printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq);
@@ -565,53 +557,51 @@
         pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma);
 err_out_cleardev:
 	pci_set_drvdata(pdev, NULL);
-#ifndef USE_IO_OPS
-	iounmap((void *)ioaddr);
+	pci_iounmap(pdev, ioaddr);
 err_out_free_res:
-#endif
 	pci_release_regions(pdev);
 err_out_free_netdev:
 	free_netdev (dev);
 	return -ENODEV;
 }
 
-static int __devinit read_eeprom(long ioaddr, int location)
+static int __devinit read_eeprom(void __iomem *ioaddr, int location)
 {
 	int bogus_cnt = 10000;		/* Typical 33Mhz: 1050 ticks */
 
-	outb(location, ioaddr + EEAddr);
-	outb(0x30 | ((location >> 8) & 7), ioaddr + EECtrl);
-	while ((inb(ioaddr + EEStatus) & 0x80)  &&  --bogus_cnt > 0)
+	iowrite8(location, ioaddr + EEAddr);
+	iowrite8(0x30 | ((location >> 8) & 7), ioaddr + EECtrl);
+	while ((ioread8(ioaddr + EEStatus) & 0x80)  &&  --bogus_cnt > 0)
 		;
-	return inb(ioaddr + EERead);
+	return ioread8(ioaddr + EERead);
 }
 
 /* MII Managemen Data I/O accesses.
    These routines assume the MDIO controller is idle, and do not exit until
    the command is finished. */
 
-static int mdio_read(long ioaddr, int phy_id, int location)
+static int mdio_read(void __iomem *ioaddr, int phy_id, int location)
 {
 	int i;
 
-	outw((phy_id<<8) + location, ioaddr + MII_Addr);
-	outw(1, ioaddr + MII_Cmd);
+	iowrite16((phy_id<<8) + location, ioaddr + MII_Addr);
+	iowrite16(1, ioaddr + MII_Cmd);
 	for (i = 10000; i >= 0; i--)
-		if ((inw(ioaddr + MII_Status) & 1) == 0)
+		if ((ioread16(ioaddr + MII_Status) & 1) == 0)
 			break;
-	return inw(ioaddr + MII_Rd_Data);
+	return ioread16(ioaddr + MII_Rd_Data);
 }
 
-static void mdio_write(long ioaddr, int phy_id, int location, int value)
+static void mdio_write(void __iomem *ioaddr, int phy_id, int location, int value)
 {
 	int i;
 
-	outw((phy_id<<8) + location, ioaddr + MII_Addr);
-	outw(value, ioaddr + MII_Wr_Data);
+	iowrite16((phy_id<<8) + location, ioaddr + MII_Addr);
+	iowrite16(value, ioaddr + MII_Wr_Data);
 
 	/* Wait for the command to finish. */
 	for (i = 10000; i >= 0; i--)
-		if ((inw(ioaddr + MII_Status) & 1) == 0)
+		if ((ioread16(ioaddr + MII_Status) & 1) == 0)
 			break;
 	return;
 }
@@ -619,12 +609,12 @@
 
 static int yellowfin_open(struct net_device *dev)
 {
-	struct yellowfin_private *yp = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct yellowfin_private *yp = netdev_priv(dev);
+	void __iomem *ioaddr = yp->base;
 	int i;
 
 	/* Reset the chip. */
-	outl(0x80000000, ioaddr + DMACtrl);
+	iowrite32(0x80000000, ioaddr + DMACtrl);
 
 	i = request_irq(dev->irq, &yellowfin_interrupt, SA_SHIRQ, dev->name, dev);
 	if (i) return i;
@@ -635,30 +625,30 @@
 
 	yellowfin_init_ring(dev);
 
-	outl(yp->rx_ring_dma, ioaddr + RxPtr);
-	outl(yp->tx_ring_dma, ioaddr + TxPtr);
+	iowrite32(yp->rx_ring_dma, ioaddr + RxPtr);
+	iowrite32(yp->tx_ring_dma, ioaddr + TxPtr);
 
 	for (i = 0; i < 6; i++)
-		outb(dev->dev_addr[i], ioaddr + StnAddr + i);
+		iowrite8(dev->dev_addr[i], ioaddr + StnAddr + i);
 
 	/* Set up various condition 'select' registers.
 	   There are no options here. */
-	outl(0x00800080, ioaddr + TxIntrSel); 	/* Interrupt on Tx abort */
-	outl(0x00800080, ioaddr + TxBranchSel);	/* Branch on Tx abort */
-	outl(0x00400040, ioaddr + TxWaitSel); 	/* Wait on Tx status */
-	outl(0x00400040, ioaddr + RxIntrSel);	/* Interrupt on Rx done */
-	outl(0x00400040, ioaddr + RxBranchSel);	/* Branch on Rx error */
-	outl(0x00400040, ioaddr + RxWaitSel);	/* Wait on Rx done */
+	iowrite32(0x00800080, ioaddr + TxIntrSel); 	/* Interrupt on Tx abort */
+	iowrite32(0x00800080, ioaddr + TxBranchSel);	/* Branch on Tx abort */
+	iowrite32(0x00400040, ioaddr + TxWaitSel); 	/* Wait on Tx status */
+	iowrite32(0x00400040, ioaddr + RxIntrSel);	/* Interrupt on Rx done */
+	iowrite32(0x00400040, ioaddr + RxBranchSel);	/* Branch on Rx error */
+	iowrite32(0x00400040, ioaddr + RxWaitSel);	/* Wait on Rx done */
 
 	/* Initialize other registers: with so many this eventually this will
 	   converted to an offset/value list. */
-	outl(dma_ctrl, ioaddr + DMACtrl);
-	outw(fifo_cfg, ioaddr + FIFOcfg);
+	iowrite32(dma_ctrl, ioaddr + DMACtrl);
+	iowrite16(fifo_cfg, ioaddr + FIFOcfg);
 	/* Enable automatic generation of flow control frames, period 0xffff. */
-	outl(0x0030FFFF, ioaddr + FlowCtrl);
+	iowrite32(0x0030FFFF, ioaddr + FlowCtrl);
 
 	yp->tx_threshold = 32;
-	outl(yp->tx_threshold, ioaddr + TxThreshold);
+	iowrite32(yp->tx_threshold, ioaddr + TxThreshold);
 
 	if (dev->if_port == 0)
 		dev->if_port = yp->default_port;
@@ -669,19 +659,19 @@
 	if (yp->drv_flags & IsGigabit) {
 		/* We are always in full-duplex mode with gigabit! */
 		yp->full_duplex = 1;
-		outw(0x01CF, ioaddr + Cnfg);
+		iowrite16(0x01CF, ioaddr + Cnfg);
 	} else {
-		outw(0x0018, ioaddr + FrameGap0); /* 0060/4060 for non-MII 10baseT */
-		outw(0x1018, ioaddr + FrameGap1);
-		outw(0x101C | (yp->full_duplex ? 2 : 0), ioaddr + Cnfg);
+		iowrite16(0x0018, ioaddr + FrameGap0); /* 0060/4060 for non-MII 10baseT */
+		iowrite16(0x1018, ioaddr + FrameGap1);
+		iowrite16(0x101C | (yp->full_duplex ? 2 : 0), ioaddr + Cnfg);
 	}
 	set_rx_mode(dev);
 
 	/* Enable interrupts by setting the interrupt mask. */
-	outw(0x81ff, ioaddr + IntrEnb);			/* See enum intr_status_bits */
-	outw(0x0000, ioaddr + EventStatus);		/* Clear non-interrupting events */
-	outl(0x80008000, ioaddr + RxCtrl);		/* Start Rx and Tx channels. */
-	outl(0x80008000, ioaddr + TxCtrl);
+	iowrite16(0x81ff, ioaddr + IntrEnb);			/* See enum intr_status_bits */
+	iowrite16(0x0000, ioaddr + EventStatus);		/* Clear non-interrupting events */
+	iowrite32(0x80008000, ioaddr + RxCtrl);		/* Start Rx and Tx channels. */
+	iowrite32(0x80008000, ioaddr + TxCtrl);
 
 	if (yellowfin_debug > 2) {
 		printk(KERN_DEBUG "%s: Done yellowfin_open().\n",
@@ -701,13 +691,13 @@
 static void yellowfin_timer(unsigned long data)
 {
 	struct net_device *dev = (struct net_device *)data;
-	struct yellowfin_private *yp = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct yellowfin_private *yp = netdev_priv(dev);
+	void __iomem *ioaddr = yp->base;
 	int next_tick = 60*HZ;
 
 	if (yellowfin_debug > 3) {
 		printk(KERN_DEBUG "%s: Yellowfin timer tick, status %8.8x.\n",
-			   dev->name, inw(ioaddr + IntrStatus));
+			   dev->name, ioread16(ioaddr + IntrStatus));
 	}
 
 	if (yp->mii_cnt) {
@@ -721,7 +711,7 @@
 
 		yp->full_duplex = mii_duplex(yp->duplex_lock, negotiated);
 			
-		outw(0x101C | (yp->full_duplex ? 2 : 0), ioaddr + Cnfg);
+		iowrite16(0x101C | (yp->full_duplex ? 2 : 0), ioaddr + Cnfg);
 
 		if (bmsr & BMSR_LSTATUS)
 			next_tick = 60*HZ;
@@ -735,13 +725,13 @@
 
 static void yellowfin_tx_timeout(struct net_device *dev)
 {
-	struct yellowfin_private *yp = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct yellowfin_private *yp = netdev_priv(dev);
+	void __iomem *ioaddr = yp->base;
 
 	printk(KERN_WARNING "%s: Yellowfin transmit timed out at %d/%d Tx "
 		   "status %4.4x, Rx status %4.4x, resetting...\n",
 		   dev->name, yp->cur_tx, yp->dirty_tx,
-		   inl(ioaddr + TxStatus), inl(ioaddr + RxStatus));
+		   ioread32(ioaddr + TxStatus), ioread32(ioaddr + RxStatus));
 
 	/* Note: these should be KERN_DEBUG. */
 	if (yellowfin_debug) {
@@ -761,7 +751,7 @@
 	dev->if_port = 0;
 
 	/* Wake the potentially-idle transmit channel. */
-	outl(0x10001000, dev->base_addr + TxCtrl);
+	iowrite32(0x10001000, yp->base + TxCtrl);
 	if (yp->cur_tx - yp->dirty_tx < TX_QUEUE_SIZE)
 		netif_wake_queue (dev);		/* Typical path */
 
@@ -772,7 +762,7 @@
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
 static void yellowfin_init_ring(struct net_device *dev)
 {
-	struct yellowfin_private *yp = dev->priv;
+	struct yellowfin_private *yp = netdev_priv(dev);
 	int i;
 
 	yp->tx_full = 0;
@@ -855,7 +845,7 @@
 
 static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct yellowfin_private *yp = dev->priv;
+	struct yellowfin_private *yp = netdev_priv(dev);
 	unsigned entry;
 	int len = skb->len;
 
@@ -920,7 +910,7 @@
 	/* Non-x86 Todo: explicitly flush cache lines here. */
 
 	/* Wake the potentially-idle transmit channel. */
-	outl(0x10001000, dev->base_addr + TxCtrl);
+	iowrite32(0x10001000, yp->base + TxCtrl);
 
 	if (yp->cur_tx - yp->dirty_tx < TX_QUEUE_SIZE)
 		netif_start_queue (dev);		/* Typical path */
@@ -941,7 +931,7 @@
 {
 	struct net_device *dev = dev_instance;
 	struct yellowfin_private *yp;
-	long ioaddr;
+	void __iomem *ioaddr;
 	int boguscnt = max_interrupt_work;
 	unsigned int handled = 0;
 
@@ -952,13 +942,13 @@
 	}
 #endif
 
-	ioaddr = dev->base_addr;
-	yp = dev->priv;
+	yp = netdev_priv(dev);
+	ioaddr = yp->base;
 	
 	spin_lock (&yp->lock);
 
 	do {
-		u16 intr_status = inw(ioaddr + IntrClear);
+		u16 intr_status = ioread16(ioaddr + IntrClear);
 
 		if (yellowfin_debug > 4)
 			printk(KERN_DEBUG "%s: Yellowfin interrupt, status %4.4x.\n",
@@ -970,7 +960,7 @@
 
 		if (intr_status & (IntrRxDone | IntrEarlyRx)) {
 			yellowfin_rx(dev);
-			outl(0x10001000, ioaddr + RxCtrl);		/* Wake Rx engine. */
+			iowrite32(0x10001000, ioaddr + RxCtrl);		/* Wake Rx engine. */
 		}
 
 #ifdef NO_TXSTATS
@@ -1085,7 +1075,7 @@
 
 	if (yellowfin_debug > 3)
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
-			   dev->name, inw(ioaddr + IntrStatus));
+			   dev->name, ioread16(ioaddr + IntrStatus));
 
 	spin_unlock (&yp->lock);
 	return IRQ_RETVAL(handled);
@@ -1095,7 +1085,7 @@
    for clarity and better register allocation. */
 static int yellowfin_rx(struct net_device *dev)
 {
-	struct yellowfin_private *yp = dev->priv;
+	struct yellowfin_private *yp = netdev_priv(dev);
 	int entry = yp->cur_rx % RX_RING_SIZE;
 	int boguscnt = yp->dirty_rx + RX_RING_SIZE - yp->cur_rx;
 
@@ -1239,7 +1229,7 @@
 
 static void yellowfin_error(struct net_device *dev, int intr_status)
 {
-	struct yellowfin_private *yp = dev->priv;
+	struct yellowfin_private *yp = netdev_priv(dev);
 
 	printk(KERN_ERR "%s: Something Wicked happened! %4.4x.\n",
 		   dev->name, intr_status);
@@ -1252,8 +1242,8 @@
 
 static int yellowfin_close(struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
-	struct yellowfin_private *yp = dev->priv;
+	struct yellowfin_private *yp = netdev_priv(dev);
+	void __iomem *ioaddr = yp->base;
 	int i;
 
 	netif_stop_queue (dev);
@@ -1261,18 +1251,19 @@
 	if (yellowfin_debug > 1) {
 		printk(KERN_DEBUG "%s: Shutting down ethercard, status was Tx %4.4x "
 			   "Rx %4.4x Int %2.2x.\n",
-			   dev->name, inw(ioaddr + TxStatus),
-			   inw(ioaddr + RxStatus), inw(ioaddr + IntrStatus));
+			   dev->name, ioread16(ioaddr + TxStatus),
+			   ioread16(ioaddr + RxStatus),
+			   ioread16(ioaddr + IntrStatus));
 		printk(KERN_DEBUG "%s: Queue pointers were Tx %d / %d,  Rx %d / %d.\n",
 			   dev->name, yp->cur_tx, yp->dirty_tx, yp->cur_rx, yp->dirty_rx);
 	}
 
 	/* Disable interrupts by clearing the interrupt mask. */
-	outw(0x0000, ioaddr + IntrEnb);
+	iowrite16(0x0000, ioaddr + IntrEnb);
 
 	/* Stop the chip's Tx and Rx processes. */
-	outl(0x80000000, ioaddr + RxCtrl);
-	outl(0x80000000, ioaddr + TxCtrl);
+	iowrite32(0x80000000, ioaddr + RxCtrl);
+	iowrite32(0x80000000, ioaddr + TxCtrl);
 
 	del_timer(&yp->timer);
 
@@ -1282,7 +1273,7 @@
 				(unsigned long long)yp->tx_ring_dma);
 		for (i = 0; i < TX_RING_SIZE*2; i++)
 			printk(" %c #%d desc. %8.8x %8.8x %8.8x %8.8x.\n",
-				   inl(ioaddr + TxPtr) == (long)&yp->tx_ring[i] ? '>' : ' ',
+				   ioread32(ioaddr + TxPtr) == (long)&yp->tx_ring[i] ? '>' : ' ',
 				   i, yp->tx_ring[i].dbdma_cmd, yp->tx_ring[i].addr,
 				   yp->tx_ring[i].branch_addr, yp->tx_ring[i].result_status);
 		printk(KERN_DEBUG "  Tx status %p:\n", yp->tx_status);
@@ -1295,7 +1286,7 @@
 				(unsigned long long)yp->rx_ring_dma);
 		for (i = 0; i < RX_RING_SIZE; i++) {
 			printk(KERN_DEBUG " %c #%d desc. %8.8x %8.8x %8.8x\n",
-				   inl(ioaddr + RxPtr) == (long)&yp->rx_ring[i] ? '>' : ' ',
+				   ioread32(ioaddr + RxPtr) == (long)&yp->rx_ring[i] ? '>' : ' ',
 				   i, yp->rx_ring[i].dbdma_cmd, yp->rx_ring[i].addr,
 				   yp->rx_ring[i].result_status);
 			if (yellowfin_debug > 6) {
@@ -1340,7 +1331,7 @@
 
 static struct net_device_stats *yellowfin_get_stats(struct net_device *dev)
 {
-	struct yellowfin_private *yp = dev->priv;
+	struct yellowfin_private *yp = netdev_priv(dev);
 	return &yp->stats;
 }
 
@@ -1348,19 +1339,19 @@
 
 static void set_rx_mode(struct net_device *dev)
 {
-	struct yellowfin_private *yp = dev->priv;
-	long ioaddr = dev->base_addr;
-	u16 cfg_value = inw(ioaddr + Cnfg);
+	struct yellowfin_private *yp = netdev_priv(dev);
+	void __iomem *ioaddr = yp->base;
+	u16 cfg_value = ioread16(ioaddr + Cnfg);
 
 	/* Stop the Rx process to change any value. */
-	outw(cfg_value & ~0x1000, ioaddr + Cnfg);
+	iowrite16(cfg_value & ~0x1000, ioaddr + Cnfg);
 	if (dev->flags & IFF_PROMISC) {			/* Set promiscuous. */
 		/* Unconditionally log net taps. */
 		printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
-		outw(0x000F, ioaddr + AddrMode);
+		iowrite16(0x000F, ioaddr + AddrMode);
 	} else if ((dev->mc_count > 64)  ||  (dev->flags & IFF_ALLMULTI)) {
 		/* Too many to filter well, or accept all multicasts. */
-		outw(0x000B, ioaddr + AddrMode);
+		iowrite16(0x000B, ioaddr + AddrMode);
 	} else if (dev->mc_count > 0) { /* Must use the multicast hash table. */
 		struct dev_mc_list *mclist;
 		u16 hash_table[4];
@@ -1385,48 +1376,34 @@
 		}
 		/* Copy the hash table to the chip. */
 		for (i = 0; i < 4; i++)
-			outw(hash_table[i], ioaddr + HashTbl + i*2);
-		outw(0x0003, ioaddr + AddrMode);
+			iowrite16(hash_table[i], ioaddr + HashTbl + i*2);
+		iowrite16(0x0003, ioaddr + AddrMode);
 	} else {					/* Normal, unicast/broadcast-only mode. */
-		outw(0x0001, ioaddr + AddrMode);
+		iowrite16(0x0001, ioaddr + AddrMode);
 	}
 	/* Restart the Rx process. */
-	outw(cfg_value | 0x1000, ioaddr + Cnfg);
+	iowrite16(cfg_value | 0x1000, ioaddr + Cnfg);
 }
 
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void yellowfin_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	struct yellowfin_private *np = dev->priv;
-	u32 ethcmd;
-		
-	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-		return -EFAULT;
-
-        switch (ethcmd) {
-        case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-		strcpy(info.driver, DRV_NAME);
-		strcpy(info.version, DRV_VERSION);
-		strcpy(info.bus_info, pci_name(np->pci_dev));
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-
-        }
-	
-	return -EOPNOTSUPP;
+	struct yellowfin_private *np = netdev_priv(dev);
+	strcpy(info->driver, DRV_NAME);
+	strcpy(info->version, DRV_VERSION);
+	strcpy(info->bus_info, pci_name(np->pci_dev));
 }
 
+static struct ethtool_ops ethtool_ops = {
+	.get_drvinfo = yellowfin_get_drvinfo
+};
+
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	struct yellowfin_private *np = dev->priv;
-	long ioaddr = dev->base_addr;
+	struct yellowfin_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->base;
 	struct mii_ioctl_data *data = if_mii(rq);
 
 	switch(cmd) {
-	case SIOCETHTOOL:
-		return netdev_ethtool_ioctl(dev, rq->ifr_data);
 	case SIOCGMIIPHY:		/* Get address of MII PHY in use. */
 		data->phy_id = np->phys[0] & 0x1f;
 		/* Fall Through */
@@ -1466,7 +1443,7 @@
 
 	if (!dev)
 		BUG();
-	np = dev->priv;
+	np = netdev_priv(dev);
 
         pci_free_consistent(pdev, STATUS_TOTAL_SIZE, np->tx_status, 
 		np->tx_status_dma);
@@ -1474,11 +1451,9 @@
 	pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma);
 	unregister_netdev (dev);
 
-	pci_release_regions (pdev);
+	pci_iounmap(pdev, np->base);
 
-#ifndef USE_IO_OPS
-	iounmap ((void *) dev->base_addr);
-#endif
+	pci_release_regions (pdev);
 
 	free_netdev (dev);
 	pci_set_drvdata(pdev, NULL);
diff -Nru a/drivers/net/znet.c b/drivers/net/znet.c
--- a/drivers/net/znet.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/net/znet.c	2004-12-24 13:36:16 -08:00
@@ -98,9 +98,9 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
@@ -421,7 +421,7 @@
 
 	znet->rx_dma = netinfo->dma1;
 	znet->tx_dma = netinfo->dma2;
-	znet->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&znet->lock);
 	znet->sia_base = 0xe6;	/* Magic address for the 82501 SIA */
 	znet->sia_size = 2;
 	/* maz: Despite the '593 being advertised above as using a
diff -Nru a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
--- a/drivers/oprofile/oprofilefs.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/oprofile/oprofilefs.c	2004-12-24 13:36:47 -08:00
@@ -135,11 +135,8 @@
 {
 	struct dentry * dentry;
 	struct inode * inode;
-	struct qstr qname;
-	qname.name = name;
-	qname.len = strlen(name);
-	qname.hash = full_name_hash(qname.name, qname.len);
-	dentry = d_alloc(root, &qname);
+
+	dentry = d_alloc_name(root, name);
 	if (!dentry)
 		return NULL;
 	inode = oprofilefs_get_inode(sb, S_IFREG | perm);
@@ -228,11 +225,8 @@
 {
 	struct dentry * dentry;
 	struct inode * inode;
-	struct qstr qname;
-	qname.name = name;
-	qname.len = strlen(name);
-	qname.hash = full_name_hash(qname.name, qname.len);
-	dentry = d_alloc(root, &qname);
+
+	dentry = d_alloc_name(root, name);
 	if (!dentry)
 		return NULL;
 	inode = oprofilefs_get_inode(sb, S_IFDIR | 0755);
diff -Nru a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
--- a/drivers/oprofile/timer_int.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/oprofile/timer_int.c	2004-12-24 13:36:47 -08:00
@@ -15,31 +15,24 @@
 #include <linux/init.h>
 #include <asm/ptrace.h>
  
-static int timer_notify(struct notifier_block * self, unsigned long val, void * data)
+static int timer_notify(struct pt_regs *regs)
 {
-	struct pt_regs * regs = (struct pt_regs *)data;
 	int cpu = smp_processor_id();
 	unsigned long eip = profile_pc(regs);
  
 	oprofile_add_sample(eip, !user_mode(regs), 0, cpu);
 	return 0;
 }
- 
- 
-static struct notifier_block timer_notifier = {
-	.notifier_call	= timer_notify,
-};
- 
 
 static int timer_start(void)
 {
-	return register_profile_notifier(&timer_notifier);
+	return register_timer_hook(timer_notify);
 }
 
 
 static void timer_stop(void)
 {
-	unregister_profile_notifier(&timer_notifier);
+	unregister_timer_hook(timer_notify);
 }
 
 
diff -Nru a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
--- a/drivers/parisc/lba_pci.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/parisc/lba_pci.c	2004-12-24 13:37:02 -08:00
@@ -1,4 +1,5 @@
 /*
+**
 **  PCI Lower Bus Adapter (LBA) manager
 **
 **	(c) Copyright 1999,2000 Grant Grundler
@@ -116,7 +117,7 @@
 ** bus number for each LBA depending on what firmware does.
 */
 
-#define MODULE_NAME "lba"
+#define MODULE_NAME "LBA"
 
 #define LBA_FUNC_ID	0x0000	/* function id */
 #define LBA_FCLASS	0x0008	/* function class, bist, header, rev... */
@@ -163,6 +164,7 @@
 #define LBA_EIOS_BASE	0x0260	/* Extra I/O port space */
 #define LBA_EIOS_MASK	0x0268
 
+#define LBA_GLOBAL_MASK	0x0270	/* Mercury only: Global Address Mask */
 #define LBA_DMA_CTL	0x0278	/* firmware sets this */
 
 #define LBA_IBASE	0x0300	/* SBA DMA support */
@@ -183,11 +185,7 @@
 #define LBA_IOSAPIC_BASE	0x800 /* Offset of IRQ logic */
 
 /* non-postable I/O port space, densely packed */
-#ifdef CONFIG_PARISC64
-#define LBA_ASTRO_PORT_BASE	(0xfffffffffee00000UL)
-#else
-#define LBA_ASTRO_PORT_BASE	(0xfee00000UL)
-#endif
+#define LBA_PORT_BASE	(PCI_F_EXTEND | 0xfee00000UL)
 
 #define ELROY_HVERS	0x782
 #define MERCURY_HVERS	0x783
@@ -283,8 +281,8 @@
 ** Extract LBA (Rope) number from HPA
 ** REVISIT: 16 ropes for Stretch/Ike?
 */
-#define ROPES_PER_SBA	8
-#define LBA_NUM(x)    ((((unsigned long) x) >> 13) & (ROPES_PER_SBA-1))
+#define ROPES_PER_IOC	8
+#define LBA_NUM(x)    ((((unsigned long) x) >> 13) & (ROPES_PER_IOC-1))
 
 
 static void
@@ -444,7 +442,8 @@
 }
 
 #define LBA_CFG_TR4_ADDR_SETUP(d, addr) \
-    WRITE_REG32(((addr) & ~3), (d)->hba.base_addr + LBA_PCI_CFG_ADDR)
+    WRITE_REG32(((addr) & ~3), (d)->hba.base_addr + LBA_PCI_CFG_ADDR); \
+    lba_t32 = READ_REG32((d)->hba.base_addr + LBA_PCI_CFG_ADDR)
 
 #define LBA_CFG_ADDR_SETUP(d, addr) {				\
     WRITE_REG32(((addr) & ~3), (d)->hba.base_addr + LBA_PCI_CFG_ADDR);	\
@@ -520,7 +519,16 @@
 	return(data);
 }
 
-#ifdef CONFIG_PARISC64
+
+#if USE_PAT_PDC_CFG
+
+/* PAT PDC needs to be relocated in order to perform properly.
+ * tg3 driver does about 1600 PCI Cfg writes to initialize the card.
+ * On 440Mhz A500, PDC takes ~20ms/write, or ~30 seconds per card.
+ * On PA8800, that takes about 5ms/write (8 seconds).
+ * But relocating PDC will burn at least 4MB of RAM.
+ * Easier/Cheaper to just maintain our own mercury cfg ops.
+ */
 #define pat_cfg_addr(bus, devfn, addr) (((bus) << 16) | ((devfn) << 8) | (addr))
 
 static int pat_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 *data)
@@ -553,11 +561,84 @@
 	.read =		pat_cfg_read,
 	.write =	pat_cfg_write,
 };
-#else
-/* keep the compiler from complaining about undeclared variables */
-#define pat_cfg_ops lba_cfg_ops
 #endif
 
+
+#ifdef CONFIG_PARISC64
+static int mercury_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 *data)
+{
+	struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge));
+	u32 local_bus = (bus->parent == NULL) ? 0 : bus->secondary;
+	u32 tok = LBA_CFG_TOK(local_bus, devfn);
+
+	/* Basic Algorithm
+	** Should only get here on fully working LBA rev.
+	** This is how simple the original LBA code should have been.
+	*/
+	LBA_CFG_TR4_ADDR_SETUP(d, tok | pos);
+	switch(size) {
+	case 1: *(u8 *)  data = READ_REG8(d->hba.base_addr + LBA_PCI_CFG_DATA
+							+ (pos & 3));
+		DBG_CFG("%s(%x+%2x) -> 0x%x (c)\n", __FUNCTION__, tok, pos,
+				*(u8 *)data);
+		return(*(u8 *)data == (u8) ~0U);
+	case 2: *(u16 *) data = READ_REG16(d->hba.base_addr + LBA_PCI_CFG_DATA
+							+ (pos & 2));
+		DBG_CFG("%s(%x+%2x) -> 0x%x (c)\n", __FUNCTION__, tok, pos,
+				*(u16 *)data);
+		return(*(u16 *)data == (u16) ~0U);
+	case 4: *(u32 *) data = READ_REG32(d->hba.base_addr + LBA_PCI_CFG_DATA);
+		DBG_CFG("%s(%x+%2x) -> 0x%x (c)\n", __FUNCTION__, tok, pos, *data);
+		return(*data == ~0U);
+	}
+	DBG_CFG("%s(%x+%2x) -> bad size (%d)\n", __FUNCTION__, tok, pos, size);
+	*data = ~0U;
+	return(!PCIBIOS_SUCCESSFUL);	/* failed */
+}
+
+/*
+ * LBA 4.0 config write code implements non-postable semantics
+ * by doing a read of CONFIG ADDR after the write.
+ */
+
+static int mercury_cfg_write(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 data)
+{
+	struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge));
+	unsigned long data_reg = d->hba.base_addr + LBA_PCI_CFG_DATA;
+	u32 local_bus = (bus->parent == NULL) ? 0 : bus->secondary;
+	u32 tok = LBA_CFG_TOK(local_bus,devfn);
+
+ 	ASSERT((tok & 0xff) == 0);
+	ASSERT(pos < 0x100);
+
+	DBG_CFG("%s(%x+%2x) <- 0x%x (c)\n", __FUNCTION__, tok, pos, data);
+
+	/* Basic Algorithm */
+	LBA_CFG_TR4_ADDR_SETUP(d, tok | pos);
+	switch(size) {
+	case 1:		WRITE_REG8 (data, data_reg + (pos & 3)); break;
+	case 2:		WRITE_REG16(data, data_reg + (pos & 2)); break;
+	case 4:		WRITE_REG32(data, data_reg);             break;
+	default: 
+		DBG_CFG("%s(%x+%2x) WTF! size %d\n", __FUNCTION__, tok, pos,
+				size);
+	}
+
+	/* flush posted write */
+	lba_t32 = READ_U32(d->hba.base_addr + LBA_PCI_CFG_ADDR);
+	return PCIBIOS_SUCCESSFUL;
+}
+
+
+static struct pci_ops mercury_cfg_ops = {
+	.read =		mercury_cfg_read,
+	.write =	mercury_cfg_write,
+};
+#else
+#define mercury_cfg_ops lba_cfg_ops
+#endif /* CONFIG_PARISC64 */
+
+
 static int lba_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 *data)
 {
 	struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge));
@@ -768,7 +849,7 @@
 		pci_read_bridge_bases(bus);
 	} else {
 		/* Host-PCI Bridge */
-		int err;
+		int err, i;
 
 		DBG("lba_fixup_bus() %s [%lx/%lx]/%x\n",
 			ldev->hba.io_space.name,
@@ -781,30 +862,65 @@
 
 		err = request_resource(&ioport_resource, &(ldev->hba.io_space));
 		if (err < 0) {
-			BUG();
 			lba_dump_res(&ioport_resource, 2);
+			BUG();
+		}
+
+		if (ldev->hba.elmmio_space.start) {
+			err = request_resource(&iomem_resource,
+					&(ldev->hba.elmmio_space));
+			if (err < 0) {
+
+				printk("FAILED: lba_fixup_bus() request for "
+						"elmmio_space [%lx/%lx]\n",
+						ldev->hba.elmmio_space.start,
+						ldev->hba.elmmio_space.end);
+
+				/* lba_dump_res(&iomem_resource, 2); */
+				/* BUG(); */
+			}
 		}
 
 		err = request_resource(&iomem_resource, &(ldev->hba.lmmio_space));
 		if (err < 0) {
-			BUG();
-			lba_dump_res(&iomem_resource, 2);
+			/*   FIXME  overlaps with elmmio will fail here.
+			 *   Need to prune (or disable) the distributed range.
+			 *
+			 *   BEWARE: conflicts with this lmmio range may be
+			 *   elmmio range which is pointing down another rope.
+			 */
+
+			printk("FAILED: lba_fixup_bus() request for "
+					"lmmio_space [%lx/%lx]\n",
+					ldev->hba.lmmio_space.start,
+					ldev->hba.lmmio_space.end);
+			/* lba_dump_res(&iomem_resource, 2); */
 		}
 
 #ifdef CONFIG_PARISC64
+		/* GMMIO is  distributed range. Every LBA/Rope gets part it. */
 		if (ldev->hba.gmmio_space.flags) {
 			err = request_resource(&iomem_resource, &(ldev->hba.gmmio_space));
 			if (err < 0) {
-				BUG();
+				printk("FAILED: lba_fixup_bus() request for "
+					"gmmio_space [%lx/%lx]\n",
+					ldev->hba.gmmio_space.start,
+					ldev->hba.gmmio_space.end);
 				lba_dump_res(&iomem_resource, 2);
+				BUG();
 			}
-			bus->resource[2] = &(ldev->hba.gmmio_space);
 		}
 #endif
 
 		/* advertize Host bridge resources to PCI bus */
 		bus->resource[0] = &(ldev->hba.io_space);
 		bus->resource[1] = &(ldev->hba.lmmio_space);
+		i=2;
+		if (ldev->hba.elmmio_space.start)
+			bus->resource[i++] = &(ldev->hba.elmmio_space);
+		if (ldev->hba.gmmio_space.start)
+			bus->resource[i++] = &(ldev->hba.gmmio_space);
+			
 	}
 
 	list_for_each(ln, &bus->devices) {
@@ -837,6 +953,9 @@
 				res->start = PCI_HOST_ADDR(HBA_DATA(ldev), res->start);
 				res->end   = PCI_HOST_ADDR(HBA_DATA(ldev), res->end);
 				DBG("[%lx/%lx]\n", res->start, res->end);
+			} else {
+				DBG("lba_fixup_bus() WTF? 0x%lx [%lx/%lx] XXX",
+					res->flags, res->start, res->end);
 			}
 		}
 
@@ -918,7 +1037,7 @@
 static u##size lba_astro_in##size (struct pci_hba_data *d, u16 addr) \
 { \
 	u##size t; \
-	t = READ_REG##size(LBA_ASTRO_PORT_BASE + addr); \
+	t = READ_REG##size(LBA_PORT_BASE + addr); \
 	DBG_PORT(" 0x%x\n", t); \
 	return (t); \
 }
@@ -960,7 +1079,7 @@
 { \
 	ASSERT(d != NULL); \
 	DBG_PORT("%s(0x%p, 0x%x, 0x%x)\n", __FUNCTION__, d, addr, val); \
-	WRITE_REG##size(val, LBA_ASTRO_PORT_BASE + addr); \
+	WRITE_REG##size(val, LBA_PORT_BASE + addr); \
 	if (LBA_DEV(d)->hw_rev < 3) \
 		lba_t32 = READ_U32(d->base_addr + LBA_FUNC_ID); \
 }
@@ -1001,7 +1120,6 @@
 static u##size lba_pat_in##size (struct pci_hba_data *l, u16 addr) \
 { \
 	u##size t; \
-	ASSERT(bus != NULL); \
 	DBG_PORT("%s(0x%p, 0x%x) ->", __FUNCTION__, l, addr); \
 	t = READ_REG##size(PIOP_TO_GMMIO(LBA_DEV(l), addr)); \
 	DBG_PORT(" 0x%x\n", t); \
@@ -1018,7 +1136,6 @@
 static void lba_pat_out##size (struct pci_hba_data *l, u16 addr, u##size val) \
 { \
 	void *where = (void *) PIOP_TO_GMMIO(LBA_DEV(l), addr); \
-	ASSERT(bus != NULL); \
 	DBG_PORT("%s(0x%p, 0x%x, 0x%x)\n", __FUNCTION__, l, addr, val); \
 	WRITE_REG##size(val, where); \
 	/* flush the I/O down to the elroy at least */ \
@@ -1099,10 +1216,23 @@
 
 		case PAT_LMMIO:
 			/* used to fix up pre-initialized MEM BARs */
-			lba_dev->hba.lmmio_space_offset = p->start - io->start;
+			if (!lba_dev->hba.lmmio_space.start) {
+				sprintf(lba_dev->hba.lmmio_name, "PCI%02x LMMIO",
+					(int) lba_dev->hba.bus_num.start);
+				lba_dev->hba.lmmio_space_offset = p->start - io->start;
+				r = &(lba_dev->hba.lmmio_space);
+				r->name  = lba_dev->hba.lmmio_name;
+			} else if (!lba_dev->hba.elmmio_space.start) {
+				sprintf(lba_dev->hba.elmmio_name, "PCI%02x ELMMIO",
+					(int) lba_dev->hba.bus_num.start);
+				r = &(lba_dev->hba.elmmio_space);
+				r->name  = lba_dev->hba.elmmio_name;
+			} else {
+				printk(KERN_WARNING MODULE_NAME
+					" only supports 2 LMMIO resources!\n");
+				break;
+			}
 
-			r = &(lba_dev->hba.lmmio_space);
-			r->name   = "LBA LMMIO";
 			r->start  = p->start;
 			r->end    = p->end;
 			r->flags  = IORESOURCE_MEM;
@@ -1111,8 +1241,10 @@
 
 		case PAT_GMMIO:
 			/* MMIO space > 4GB phys addr; for 64-bit BAR */
+			sprintf(lba_dev->hba.gmmio_name, "PCI%02x GMMIO",
+					(int) lba_dev->hba.bus_num.start);
 			r = &(lba_dev->hba.gmmio_space);
-			r->name   = "LBA GMMIO";
+			r->name  = lba_dev->hba.gmmio_name;
 			r->start  = p->start;
 			r->end    = p->end;
 			r->flags  = IORESOURCE_MEM;
@@ -1132,8 +1264,10 @@
 			*/
 			lba_dev->iop_base = p->start;
 
+			sprintf(lba_dev->hba.io_name, "PCI%02x Ports",
+					(int) lba_dev->hba.bus_num.start);
 			r = &(lba_dev->hba.io_space);
-			r->name   = "LBA I/O Port";
+			r->name  = lba_dev->hba.io_name;
 			r->start  = HBA_PORT_BASE(lba_dev->hba.hba_num);
 			r->end    = r->start + HBA_PORT_SPACE_SIZE - 1;
 			r->flags  = IORESOURCE_IO;
@@ -1155,24 +1289,17 @@
 #endif	/* CONFIG_PARISC64 */
 
 
+extern void sba_distributed_lmmio(struct parisc_device *, struct resource *);
+extern void sba_directed_lmmio(struct parisc_device *, struct resource *);
+
+
 static void
 lba_legacy_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev)
 {
 	struct resource *r;
-	unsigned long rsize;
 	int lba_num;
 
-#ifdef CONFIG_PARISC64
-	/*
-	** Sign extend all BAR values on "legacy" platforms.
-	** "Sprockets" PDC (Forte/Allegro) initializes everything
-	** for "legacy" 32-bit OS (HPUX 10.20).
-	** Upper 32-bits of 64-bit BAR will be zero too.
-	*/
-	lba_dev->hba.lmmio_space_offset = 0xffffffff00000000UL;
-#else
-	lba_dev->hba.lmmio_space_offset = 0UL;
-#endif
+	lba_dev->hba.lmmio_space_offset = PCI_F_EXTEND;
 
 	/*
 	** With "legacy" firmware, the lowest byte of FW_SCRATCH
@@ -1187,27 +1314,104 @@
 	r->start = lba_num & 0xff;
 	r->end = (lba_num>>8) & 0xff;
 
-	/* Set up local PCI Bus resources - we don't really need
-	** them for Legacy boxes but it's nice to see in /proc.
+	/* Set up local PCI Bus resources - we don't need them for
+	** Legacy boxes but it's nice to see in /proc/iomem.
 	*/
 	r = &(lba_dev->hba.lmmio_space);
-	r->name  = "LBA PCI LMMIO";
-	r->flags = IORESOURCE_MEM;
-	/* Ignore "Range Enable" bit in the BASE register */
-	r->start = PCI_HOST_ADDR(HBA_DATA(lba_dev),
-		((long) READ_REG32(pa_dev->hpa + LBA_LMMIO_BASE)) & ~1UL);
-	rsize =  ~READ_REG32(pa_dev->hpa + LBA_LMMIO_MASK) + 1;
-
+	sprintf(lba_dev->hba.lmmio_name, "PCI%02x LMMIO",
+					(int) lba_dev->hba.bus_num.start);
+	r->name  = lba_dev->hba.lmmio_name;
+
+#if 1
+	/* We want the CPU -> IO routing of addresses.
+	 * The SBA BASE/MASK registers control CPU -> IO routing.
+	 * Ask SBA what is routed to this rope/LBA.
+	 */
+	sba_distributed_lmmio(pa_dev, r);
+#else
 	/*
-	** Each rope only gets part of the distributed range.
-	** Adjust "window" for this rope
-	*/
-	rsize /= ROPES_PER_SBA;
-	r->start += rsize * LBA_NUM(pa_dev->hpa);
-	r->end = r->start + rsize - 1 ;
+	 * The LBA BASE/MASK registers control IO -> System routing.
+	 *
+	 * The following code works but doesn't get us what we want.
+	 * Well, only because firmware (v5.0) on C3000 doesn't program
+	 * the LBA BASE/MASE registers to be the exact inverse of 
+	 * the corresponding SBA registers. Other Astro/Pluto
+	 * based platform firmware may do it right.
+	 *
+	 * Should someone want to mess with MSI, they may need to
+	 * reprogram LBA BASE/MASK registers. Thus preserve the code
+	 * below until MSI is known to work on C3000/A500/N4000/RP3440.
+	 *
+	 * Using the code below, /proc/iomem shows:
+	 * ...
+	 * f0000000-f0ffffff : PCI00 LMMIO
+	 *   f05d0000-f05d0000 : lcd_data
+	 *   f05d0008-f05d0008 : lcd_cmd
+	 * f1000000-f1ffffff : PCI01 LMMIO
+	 * f4000000-f4ffffff : PCI02 LMMIO
+	 *   f4000000-f4001fff : sym53c8xx
+	 *   f4002000-f4003fff : sym53c8xx
+	 *   f4004000-f40043ff : sym53c8xx
+	 *   f4005000-f40053ff : sym53c8xx
+	 *   f4007000-f4007fff : ohci_hcd
+	 *   f4008000-f40083ff : tulip
+	 * f6000000-f6ffffff : PCI03 LMMIO
+	 * f8000000-fbffffff : PCI00 ELMMIO
+	 *   fa100000-fa4fffff : stifb mmio
+	 *   fb000000-fb1fffff : stifb fb
+	 *
+	 * But everything listed under PCI02 actually lives under PCI00.
+	 * This is clearly wrong.
+	 *
+	 * Asking SBA how things are routed tells the correct story:
+	 * LMMIO_BASE/MASK/ROUTE f4000001 fc000000 00000000
+	 * DIR0_BASE/MASK/ROUTE fa000001 fe000000 00000006
+	 * DIR1_BASE/MASK/ROUTE f9000001 ff000000 00000004
+	 * DIR2_BASE/MASK/ROUTE f0000000 fc000000 00000000
+	 * DIR3_BASE/MASK/ROUTE f0000000 fc000000 00000000
+	 *
+	 * Which looks like this in /proc/iomem:
+	 * f4000000-f47fffff : PCI00 LMMIO
+	 *   f4000000-f4001fff : sym53c8xx
+	 *   ...[deteled core devices - same as above]...
+	 *   f4008000-f40083ff : tulip
+	 * f4800000-f4ffffff : PCI01 LMMIO
+	 * f6000000-f67fffff : PCI02 LMMIO
+	 * f7000000-f77fffff : PCI03 LMMIO
+	 * f9000000-f9ffffff : PCI02 ELMMIO
+	 * fa000000-fbffffff : PCI03 ELMMIO
+	 *   fa100000-fa4fffff : stifb mmio
+	 *   fb000000-fb1fffff : stifb fb
+	 *
+	 * ie all Built-in core are under now correctly under PCI00.
+	 * The "PCI02 ELMMIO" directed range is for:
+	 *  +-[02]---03.0  3Dfx Interactive, Inc. Voodoo 2
+	 *
+	 * All is well now.
+	 */
+	r->start = (long) READ_REG32(pa_dev->hpa + LBA_LMMIO_BASE);
+	if (r->start & 1) {
+		unsigned long rsize;
+
+		r->flags = IORESOURCE_MEM;
+		/* mmio_mask also clears Enable bit */
+		r->start &= mmio_mask;
+		r->start = PCI_HOST_ADDR(HBA_DATA(lba_dev), r->start);
+		rsize = ~ READ_REG32(pa_dev->hpa + LBA_LMMIO_MASK);
+
+		/*
+		** Each rope only gets part of the distributed range.
+		** Adjust "window" for this rope.
+		*/
+		rsize /= ROPES_PER_IOC;
+		r->start += (rsize + 1) * LBA_NUM(pa_dev->hpa);
+		r->end = r->start + rsize;
+	} else {
+		r->end = r->start = 0;	/* Not enabled. */
+	}
+#endif
 
 	/*
-	** XXX FIXME - ignore LBA_ELMMIO_BASE for now
 	** "Directed" ranges are used when the "distributed range" isn't
 	** sufficient for all devices below a given LBA.  Typically devices
 	** like graphics cards or X25 may need a directed range when the
@@ -1216,35 +1420,38 @@
 	**
 	** The main reason for ignoring it now frigging complications.
 	** Directed ranges may overlap (and have precedence) over
-	** distributed ranges. Ie a distributed range assigned to a unused
+	** distributed ranges. Or a distributed range assigned to a unused
 	** rope may be used by a directed range on a different rope.
 	** Support for graphics devices may require fixing this
 	** since they may be assigned a directed range which overlaps
 	** an existing (but unused portion of) distributed range.
 	*/
 	r = &(lba_dev->hba.elmmio_space);
-	r->name  = "extra LBA PCI LMMIO";
-	r->flags = IORESOURCE_MEM;
+	sprintf(lba_dev->hba.elmmio_name, "PCI%02x ELMMIO",
+					(int) lba_dev->hba.bus_num.start);
+	r->name  = lba_dev->hba.elmmio_name;
+
+#if 1
+	/* See comment which precedes call to sba_directed_lmmio() */
+	sba_directed_lmmio(pa_dev, r);
+#else
 	r->start = READ_REG32(pa_dev->hpa + LBA_ELMMIO_BASE);
-	r->end   = 0;
 
-	/* check Range Enable bit */
 	if (r->start & 1) {
-		/* First baby step to getting Direct Ranges listed in /proc.
-		** AFAIK, only Sprockets PDC will setup a directed Range.
-		*/
-
-		r->start &= ~1;
-		r->end    = r->start;
-		r->end   += ~READ_REG32(pa_dev->hpa + LBA_ELMMIO_MASK);
-		printk(KERN_DEBUG "WARNING: Ignoring enabled ELMMIO BASE 0x%0lx  SIZE 0x%lx\n",
-			r->start,
-			r->end + 1);
-
+		unsigned long rsize;
+		r->flags = IORESOURCE_MEM;
+		/* mmio_mask also clears Enable bit */
+		r->start &= mmio_mask;
+		r->start = PCI_HOST_ADDR(HBA_DATA(lba_dev), r->start);
+		rsize = READ_REG32(pa_dev->hpa + LBA_ELMMIO_MASK);
+		r->end = r->start + ~rsize;
 	}
+#endif
 
 	r = &(lba_dev->hba.io_space);
-	r->name  = "LBA PCI I/O Ports";
+	sprintf(lba_dev->hba.io_name, "PCI%02x Ports",
+					(int) lba_dev->hba.bus_num.start);
+	r->name  = lba_dev->hba.io_name;
 	r->flags = IORESOURCE_IO;
 	r->start = READ_REG32(pa_dev->hpa + LBA_IOS_BASE) & ~1L;
 	r->end   = r->start + (READ_REG32(pa_dev->hpa + LBA_IOS_MASK) ^ (HBA_PORT_SPACE_SIZE - 1));
@@ -1478,11 +1685,16 @@
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
 		pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start,
-				is_pdc_pat() ? &pat_cfg_ops : &lba_cfg_ops,
+				IS_ELROY(dev) ? &lba_cfg_ops : &mercury_cfg_ops,
 				NULL);
 
+	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
 		/* assign resources to un-initialized devices */
+
+		DBG_PAT("LBA pci_bus_size_bridges()\n");
+		pci_bus_size_bridges(lba_bus);
+
 		DBG_PAT("LBA pci_bus_assign_resources()\n");
 		pci_bus_assign_resources(lba_bus);
 
@@ -1493,6 +1705,8 @@
 		lba_dump_res(&lba_dev->hba.lmmio_space, 2);
 #endif
 	}
+	pci_enable_bridges(lba_bus);
+
 
 	/*
 	** Once PCI register ops has walked the bus, access to config
diff -Nru a/drivers/parisc/power.c b/drivers/parisc/power.c
--- a/drivers/parisc/power.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/parisc/power.c	2004-12-24 13:36:18 -08:00
@@ -54,9 +54,9 @@
 
 
 #ifdef DEBUG
-# define DPRINTK(x) printk x
+# define DPRINTK(x...) printk(x)
 #else
-# define DPRINTK(x) do { } while (0)
+# define DPRINTK(x...)
 #endif
 
 
@@ -120,14 +120,14 @@
 static void process_shutdown(void)
 {
 	if (shutdown_timer == 0)
-		DPRINTK((KERN_INFO "Shutdown requested...\n"));
+		DPRINTK(KERN_INFO "Shutdown requested...\n");
 
 	shutdown_timer++;
 	
 	/* wait until the button was pressed for 1 second */
 	if (shutdown_timer == HZ) {
 		static char msg[] = "Shutting down...";
-		DPRINTK((KERN_INFO "%s\n", msg));
+		DPRINTK(KERN_INFO "%s\n", msg);
 #ifdef CONFIG_CHASSIS_LCD_LED
 		lcd_print(msg);
 #endif
diff -Nru a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
--- a/drivers/parisc/sba_iommu.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/parisc/sba_iommu.c	2004-12-24 13:37:04 -08:00
@@ -1,8 +1,9 @@
 /*
 **  System Bus Adapter (SBA) I/O MMU manager
 **
-**	(c) Copyright 2000 Grant Grundler
-**	(c) Copyright 2000 Hewlett-Packard Company
+**	(c) Copyright 2000-2004 Grant Grundler <grundler @ parisc-linux x org>
+**	(c) Copyright 2004 Naresh Kumar Inna <knaresh at india x hp x com>
+**	(c) Copyright 2000-2004 Hewlett-Packard Company
 **
 **	Portions (c) 1999 Dave S. Miller (from sparc64 I/O MMU code)
 **
@@ -167,11 +168,21 @@
 
 #define MAX_IOC		2	/* per Ike. Pluto/Astro only have 1. */
 
+#define ROPES_PER_IOC	8	/* per Ike half or Pluto/Astro */
+
 
 /*
 ** Offsets into MBIB (Function 0 on Ike and hopefully Astro)
 ** Firmware programs this stuff. Don't touch it.
 */
+#define LMMIO_DIRECT0_BASE  0x300
+#define LMMIO_DIRECT0_MASK  0x308
+#define LMMIO_DIRECT0_ROUTE 0x310
+
+#define LMMIO_DIST_BASE  0x360
+#define LMMIO_DIST_MASK  0x368
+#define LMMIO_DIST_ROUTE 0x370
+
 #define IOS_DIST_BASE	0x390
 #define IOS_DIST_MASK	0x398
 #define IOS_DIST_ROUTE	0x3A0
@@ -289,6 +300,9 @@
 	unsigned int		flags;  /* state/functionality enabled */
 	unsigned int		hw_rev;  /* HW revision of chip */
 
+	struct resource		chip_resv; /* MMIO reserved for chip */
+	struct resource		iommu_resv; /* MMIO reserved for iommu */
+
 	unsigned int		num_ioc;  /* number of on-board IOC's */
 	struct ioc		ioc[MAX_IOC];
 };
@@ -569,7 +583,7 @@
 		while(res_ptr < res_end)
 		{ 
 			DBG_RES("    %p %lx %lx\n", res_ptr, mask, *res_ptr);
-			ASSERT(0 != mask);
+			BUG_ON(0 == mask);
 			if(0 == ((*res_ptr) & mask)) {
 				*res_ptr |= mask;     /* mark resources busy! */
 				pide = ((unsigned long)res_ptr - (unsigned long)ioc->res_map);
@@ -1696,19 +1710,46 @@
 	} /* if !PLUTO */
 
 	if (IS_ASTRO(sba_dev->iodc)) {
+		int err;
 		/* PAT_PDC (L-class) also reports the same goofy base */
 		sba_dev->ioc[0].ioc_hpa = ASTRO_IOC_OFFSET;
 		num_ioc = 1;
+
+		sba_dev->chip_resv.name = "Astro Intr Ack";
+		sba_dev->chip_resv.start = PCI_F_EXTEND | 0xfef00000UL;
+		sba_dev->chip_resv.end   = PCI_F_EXTEND | (0xff000000UL - 1) ;
+		err = request_resource(&iomem_resource, &(sba_dev->chip_resv));
+		if (err < 0) {
+			BUG();
+		}
+
 	} else if (IS_PLUTO(sba_dev->iodc)) {
+		int err;
+
 		/* We use a negative value for IOC HPA so it gets 
                  * corrected when we add it with IKE's IOC offset.
 		 * Doesnt look clean, but fewer code. 
                  */
 		sba_dev->ioc[0].ioc_hpa = -PLUTO_IOC_OFFSET;
 		num_ioc = 1;
+
+		sba_dev->chip_resv.name = "Pluto Intr/PIOP/VGA";
+		sba_dev->chip_resv.start = PCI_F_EXTEND | 0xfee00000UL;
+		sba_dev->chip_resv.end   = PCI_F_EXTEND | (0xff200000UL - 1);
+		err = request_resource(&iomem_resource, &(sba_dev->chip_resv));
+		BUG_ON(err < 0);
+
+		sba_dev->iommu_resv.name = "IOVA Space";
+		sba_dev->iommu_resv.start = 0x40000000UL;
+		sba_dev->iommu_resv.end   = 0x50000000UL - 1;
+		err = request_resource(&iomem_resource, &(sba_dev->iommu_resv));
+		BUG_ON(err < 0);
 	} else {
+		/* IS_IKE (ie N-class, L3000, L1500) */
 		sba_dev->ioc[0].ioc_hpa = sba_dev->ioc[1].ioc_hpa = 0;
 		num_ioc = 2;
+
+		/* TODO - LOOKUP Ike/Stretch chipset mem map */
 	}
 
 	sba_dev->num_ioc = num_ioc;
@@ -1843,8 +1884,9 @@
 	struct sba_device *sba_dev = sba_list;
 	struct ioc *ioc = &sba_dev->ioc[0];	/* FIXME: Multi-IOC support! */
 	int total_pages = (int) (ioc->res_size << 3); /* 8 bits per byte */
+	unsigned long i;
 #ifdef SBA_COLLECT_STATS
-	unsigned long i = 0, avg = 0, min, max;
+	unsigned long avg = 0, min, max;
 #endif
 
 	sprintf(buf, "%s rev %d.%d\n",
@@ -1860,6 +1902,21 @@
 	sprintf(buf, "%sResource bitmap : %d bytes (%d pages)\n", 
 		buf, ioc->res_size, ioc->res_size << 3);   /* 8 bits per byte */
 
+	sprintf(buf, "%sLMMIO_BASE/MASK/ROUTE %08x %08x %08x\n",
+		buf,
+		READ_REG32(sba_dev->sba_hpa + LMMIO_DIST_BASE),
+		READ_REG32(sba_dev->sba_hpa + LMMIO_DIST_MASK),
+		READ_REG32(sba_dev->sba_hpa + LMMIO_DIST_ROUTE)
+		);
+
+	for (i=0; i<4; i++)
+		sprintf(buf, "%sDIR%ld_BASE/MASK/ROUTE %08x %08x %08x\n",
+			buf, i,
+			READ_REG32(sba_dev->sba_hpa + LMMIO_DIRECT0_BASE  + i*0x18),
+			READ_REG32(sba_dev->sba_hpa + LMMIO_DIRECT0_MASK  + i*0x18),
+			READ_REG32(sba_dev->sba_hpa + LMMIO_DIRECT0_ROUTE + i*0x18)
+		);
+
 #ifdef SBA_COLLECT_STATS
 	sprintf(buf, "%sIO PDIR entries : %ld free  %ld used (%d%%)\n", buf,
 		total_pages - ioc->used_pages, ioc->used_pages,
@@ -1949,7 +2006,7 @@
 };
 
 /*
-** Determine if lba should claim this chip (return 0) or not (return 1).
+** Determine if sba should claim this chip (return 0) or not (return 1).
 ** If so, initialize the chip and tell other partners in crime they
 ** have work to do.
 */
@@ -2062,17 +2119,95 @@
  * sba_get_iommu - Assign the iommu pointer for the pci bus controller.
  * @dev: The parisc device.
  *
- * This function searches through the registerd IOMMU's and returns the
- * appropriate IOMMU data for the given parisc PCI controller.
+ * Returns the appropriate IOMMU data for the given parisc PCI controller.
+ * This is cached and used later for PCI DMA Mapping.
  */
 void * sba_get_iommu(struct parisc_device *pci_hba)
 {
-	struct sba_device *sba = (struct sba_device *) pci_hba->parent->sysdata;
-	char t = pci_hba->parent->id.hw_type;
+	struct parisc_device *sba_dev = parisc_parent(pci_hba);
+	struct sba_device *sba = sba_dev->dev.driver_data;
+	char t = sba_dev->id.hw_type;
 	int iocnum = (pci_hba->hw_path >> 3);	/* rope # */
 
+	BUG_ON((t != HPHW_IOA) && (t != HPHW_BCPORT));
+
+	return &(sba->ioc[iocnum]);
+}
+
+
+/**
+ * sba_directed_lmmio - return first directed LMMIO range routed to rope
+ * @pa_dev: The parisc device.
+ * @r: resource PCI host controller wants start/end fields assigned.
+ *
+ * For the given parisc PCI controller, determine if any direct ranges
+ * are routed down the corresponding rope.
+ */
+void sba_directed_lmmio(struct parisc_device *pci_hba, struct resource *r)
+{
+	struct parisc_device *sba_dev = parisc_parent(pci_hba);
+	struct sba_device *sba = sba_dev->dev.driver_data;
+	char t = sba_dev->id.hw_type;
+	int i;
+	int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1));  /* rope # */
+
 	if ((t!=HPHW_IOA) && (t!=HPHW_BCPORT))
 		BUG();
 
-	return &(sba->ioc[iocnum]);
+	r->start = r->end = 0;
+
+	/* Astro has 4 directed ranges. Not sure about Ike/Pluto/et al */
+	for (i=0; i<4; i++) {
+		int base, size;
+		unsigned long reg = sba->sba_hpa + i*0x18;
+
+		base = READ_REG32(reg + LMMIO_DIRECT0_BASE);
+		if ((base & 1) == 0)
+			continue;	/* not enabled */
+
+		size = READ_REG32(reg + LMMIO_DIRECT0_ROUTE);
+
+		if ((size & (ROPES_PER_IOC-1)) != rope)
+			continue;	/* directed down different rope */
+		
+		r->start = (base & ~1UL) | PCI_F_EXTEND;
+		size = ~ READ_REG32(reg + LMMIO_DIRECT0_MASK);
+		r->end = r->start + size;
+	}
+}
+
+
+/**
+ * sba_distributed_lmmio - return portion of distributed LMMIO range
+ * @pa_dev: The parisc device.
+ * @r: resource PCI host controller wants start/end fields assigned.
+ *
+ * For the given parisc PCI controller, return portion of distributed LMMIO
+ * range. The distributed LMMIO is always present and it's just a question
+ * of the base address and size of the range.
+ */
+void sba_distributed_lmmio(struct parisc_device *pci_hba, struct resource *r )
+{
+	struct parisc_device *sba_dev = parisc_parent(pci_hba);
+	struct sba_device *sba = sba_dev->dev.driver_data;
+	char t = sba_dev->id.hw_type;
+	int base, size;
+	int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1));  /* rope # */
+
+	if ((t!=HPHW_IOA) && (t!=HPHW_BCPORT))
+		BUG();
+
+	r->start = r->end = 0;
+
+	base = READ_REG32(sba->sba_hpa + LMMIO_DIST_BASE);
+	if ((base & 1) == 0) {
+		BUG();	/* Gah! Distr Range wasn't enabled! */
+		return;
+	}
+
+	r->start = (base & ~1UL) | PCI_F_EXTEND;
+
+	size = (~READ_REG32(sba->sba_hpa + LMMIO_DIST_MASK)) / ROPES_PER_IOC;
+	r->start += rope * (size + 1);	/* adjust base for this rope */
+	r->end = r->start + size;
 }
diff -Nru a/drivers/parisc/superio.c b/drivers/parisc/superio.c
--- a/drivers/parisc/superio.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/parisc/superio.c	2004-12-24 13:37:01 -08:00
@@ -69,15 +69,12 @@
 #include <linux/tty.h>
 #include <linux/serial_core.h>
 #include <linux/delay.h>
-#include <linux/ide.h>
 
 #include <asm/io.h>
 #include <asm/hardware.h>
 #include <asm/irq.h>
 #include <asm/superio.h>
 
-#define SUPERIO_IDE_MAX_RETRIES 25
-
 static struct superio_device sio_dev;
 
 
@@ -101,16 +98,20 @@
 
 	results = inb(IC_PIC1+0);
 
+	/*
+	 * Bit    7:	1 = active Interrupt; 0 = no Interrupt pending
+	 * Bits 6-3:	zero
+	 * Bits 2-0:	highest priority, active requesting interrupt ID (0-7)
+	 */
 	if ((results & 0x80) == 0) {
-#ifndef CONFIG_SMP
-		/* HACK: need to investigate why this happens if SMP enabled */
-		BUG(); /* This shouldn't happen */
-#endif
+		/* I suspect "spurious" interrupts are from unmasking an IRQ.
+		 * We don't know if an interrupt was/is pending and thus
+		 * just call the handler for that IRQ as if it were pending.
+		 */
 		return IRQ_HANDLED;
 	}
 
 	/* Check to see which device is interrupting */
-
 	local_irq = results & 0x0f;
 
 	if (local_irq == 2 || local_irq > 7) {
@@ -136,8 +137,9 @@
 		sio->irq_region->data.irqbase + local_irq,
 		regs);
 
-	/* set EOI */
-
+	/* set EOI - forces a new interrupt if a lower priority device
+	 * still needs service.
+	 */
 	outb((OCW2_SEOI|local_irq),IC_PIC1 + 0);
 	return IRQ_HANDLED;
 }
@@ -469,11 +471,6 @@
 }
 
 
-static u8 superio_ide_inb (unsigned long port);
-static unsigned long superio_ide_status[2];
-static unsigned long superio_ide_select[2];
-static unsigned long superio_ide_dma_status[2];
-
 void superio_fixup_pci(struct pci_dev *pdev)
 {
 	u8 prog;
@@ -484,58 +481,8 @@
 	pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog);
 	printk("PCI: Enabled native mode for NS87415 (pif=0x%x)\n", prog);
 }
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415, superio_fixup_pci);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415, superio_fixup_pci);
 
-/* Because of a defect in Super I/O, all reads of the PCI DMA status 
- * registers, IDE status register and the IDE select register need to be 
- * retried
- */
-static u8 superio_ide_inb (unsigned long port)
-{
-	if (port == superio_ide_status[0] ||
-	    port == superio_ide_status[1] ||
-	    port == superio_ide_select[0] ||
-	    port == superio_ide_select[1] ||
-	    port == superio_ide_dma_status[0] ||
-	    port == superio_ide_dma_status[1]) {
-		u8 tmp;
-		int retries = SUPERIO_IDE_MAX_RETRIES;
-
-		/* printk(" [ reading port 0x%x with retry ] ", port); */
-
-		do {
-			tmp = inb(port);
-			if (tmp == 0)
-				udelay(50);
-		} while (tmp == 0 && retries-- > 0);
-
-		return tmp;
-	}
-
-	return inb(port);
-}
-
-void __init superio_ide_init_iops (struct hwif_s *hwif)
-{
-	u32 base, dmabase;
-	u8 tmp;
-	struct pci_dev *pdev = hwif->pci_dev;
-	u8 port = hwif->channel;
-
-	base = pci_resource_start(pdev, port * 2) & ~3;
-	dmabase = pci_resource_start(pdev, 4) & ~3;
-
-	superio_ide_status[port] = base + IDE_STATUS_OFFSET;
-	superio_ide_select[port] = base + IDE_SELECT_OFFSET;
-	superio_ide_dma_status[port] = dmabase + (!port ? 2 : 0xa);
-	
-	/* Clear error/interrupt, enable dma */
-	tmp = superio_ide_inb(superio_ide_dma_status[port]);
-	outb(tmp | 0x66, superio_ide_dma_status[port]);
-
-	/* We need to override inb to workaround a SuperIO errata */
-	hwif->INB = superio_ide_inb;
-}
 
 static int __devinit superio_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
diff -Nru a/drivers/parport/Kconfig b/drivers/parport/Kconfig
--- a/drivers/parport/Kconfig	2004-12-24 13:37:29 -08:00
+++ b/drivers/parport/Kconfig	2004-12-24 13:37:29 -08:00
@@ -34,7 +34,7 @@
 
 config PARPORT_PC
 	tristate "PC-style hardware"
-	depends on PARPORT && (!SPARC64 || PCI)
+	depends on PARPORT && (!SPARC64 || PCI) && (!SPARC32 || BROKEN)
 	---help---
 	  You should say Y here if you have a PC-style parallel port. All
 	  IBM PC compatible computers and some Alphas have PC-style
diff -Nru a/drivers/parport/daisy.c b/drivers/parport/daisy.c
--- a/drivers/parport/daisy.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/parport/daisy.c	2004-12-24 13:36:31 -08:00
@@ -207,8 +207,7 @@
  *
  *	This function is similar to parport_register_device(), except
  *	that it locates a device by its number rather than by the port
- *	it is attached to.  See parport_find_device() and
- *	parport_find_class().
+ *	it is attached to.
  *
  *	All parameters except for @devnum are the same as for
  *	parport_register_device().  The return value is the same as
@@ -305,53 +304,6 @@
 	return res;
 }
 
-/**
- *	parport_device_coords - convert canonical device number
- *	@devnum: device number
- *	@parport: pointer to storage for parallel port number
- *	@mux: pointer to storage for multiplexor port number
- *	@daisy: pointer to storage for daisy chain address
- *
- *	This function converts a device number into its coordinates in
- *	terms of which parallel port in the system it is attached to,
- *	which multiplexor port it is attached to if there is a
- *	multiplexor on that port, and which daisy chain address it has
- *	if it is in a daisy chain.
- *
- *	The caller must allocate storage for @parport, @mux, and
- *	@daisy.
- *
- *	If there is no device with the specified device number, -ENXIO
- *	is returned.  Otherwise, the values pointed to by @parport,
- *	@mux, and @daisy are set to the coordinates of the device,
- *	with -1 for coordinates with no value.
- *
- *	This function is not actually very useful, but this interface
- *	was suggested by IEEE 1284.3.
- **/
-
-int parport_device_coords (int devnum, int *parport, int *mux, int *daisy)
-{
-	struct daisydev *dev;
-
-	spin_lock(&topology_lock);
-
-	dev = topology;
-	while (dev && dev->devnum != devnum)
-		dev = dev->next;
-
-	if (!dev) {
-		spin_unlock(&topology_lock);
-		return -ENXIO;
-	}
-
-	if (parport) *parport = dev->port->portnum;
-	if (mux) *mux = dev->port->muxport;
-	if (daisy) *daisy = dev->daisy;
-	spin_unlock(&topology_lock);
-	return 0;
-}
-
 /* Send a daisy-chain-style CPP command packet. */
 static int cpp_daisy (struct parport *port, int cmd)
 {
@@ -558,108 +510,3 @@
 	kfree (deviceid);
 	return detected;
 }
-
-/* Find a device with a particular manufacturer and model string,
-   starting from a given device number.  Like the PCI equivalent,
-   'from' itself is skipped. */
-
-/**
- *	parport_find_device - find a specific device
- *	@mfg: required manufacturer string
- *	@mdl: required model string
- *	@from: previous device number found in search, or %NULL for
- *	       new search
- *
- *	This walks through the list of parallel port devices looking
- *	for a device whose 'MFG' string matches @mfg and whose 'MDL'
- *	string matches @mdl in their IEEE 1284 Device ID.
- *
- *	When a device is found matching those requirements, its device
- *	number is returned; if there is no matching device, a negative
- *	value is returned.
- *
- *	A new search it initiated by passing %NULL as the @from
- *	argument.  If @from is not %NULL, the search continues from
- *	that device.
- **/
-
-int parport_find_device (const char *mfg, const char *mdl, int from)
-{
-	struct daisydev *d;
-	int res = -1;
-
-	/* Find where to start. */
-
-	spin_lock(&topology_lock);
-	d = topology; /* sorted by devnum */
-	while (d && d->devnum <= from)
-		d = d->next;
-
-	/* Search. */
-	while (d) {
-		struct parport_device_info *info;
-		info = &d->port->probe_info[1 + d->daisy];
-		if ((!mfg || !strcmp (mfg, info->mfr)) &&
-		    (!mdl || !strcmp (mdl, info->model)))
-			break;
-
-		d = d->next;
-	}
-
-	if (d)
-		res = d->devnum;
-
-	spin_unlock(&topology_lock);
-	return res;
-}
-
-/**
- *	parport_find_class - find a device in a specified class
- *	@cls: required class
- *	@from: previous device number found in search, or %NULL for
- *	       new search
- *
- *	This walks through the list of parallel port devices looking
- *	for a device whose 'CLS' string matches @cls in their IEEE
- *	1284 Device ID.
- *
- *	When a device is found matching those requirements, its device
- *	number is returned; if there is no matching device, a negative
- *	value is returned.
- *
- *	A new search it initiated by passing %NULL as the @from
- *	argument.  If @from is not %NULL, the search continues from
- *	that device.
- **/
-
-int parport_find_class (parport_device_class cls, int from)
-{
-	struct daisydev *d;
-	int res = -1;
-
-	spin_lock(&topology_lock);
-	d = topology; /* sorted by devnum */
-	/* Find where to start. */
-	while (d && d->devnum <= from)
-		d = d->next;
-
-	/* Search. */
-	while (d && d->port->probe_info[1 + d->daisy].class != cls)
-		d = d->next;
-
-	if (d)
-		res = d->devnum;
-
-	spin_unlock(&topology_lock);
-	return res;
-}
-
-EXPORT_SYMBOL(parport_open);
-EXPORT_SYMBOL(parport_close);
-EXPORT_SYMBOL(parport_device_num);
-EXPORT_SYMBOL(parport_device_coords);
-EXPORT_SYMBOL(parport_daisy_deselect_all);
-EXPORT_SYMBOL(parport_daisy_select);
-EXPORT_SYMBOL(parport_daisy_init);
-EXPORT_SYMBOL(parport_find_device);
-EXPORT_SYMBOL(parport_find_class);
diff -Nru a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
--- a/drivers/parport/ieee1284.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/parport/ieee1284.c	2004-12-24 13:36:18 -08:00
@@ -40,7 +40,7 @@
 
 /* Make parport_wait_peripheral wake up.
  * It will be useful to call this from an interrupt handler. */
-void parport_ieee1284_wakeup (struct parport *port)
+static void parport_ieee1284_wakeup (struct parport *port)
 {
 	up (&port->physport->ieee1284.irq);
 }
@@ -813,9 +813,7 @@
 EXPORT_SYMBOL(parport_negotiate);
 EXPORT_SYMBOL(parport_write);
 EXPORT_SYMBOL(parport_read);
-EXPORT_SYMBOL(parport_ieee1284_wakeup);
 EXPORT_SYMBOL(parport_wait_peripheral);
-EXPORT_SYMBOL(parport_poll_peripheral);
 EXPORT_SYMBOL(parport_wait_event);
 EXPORT_SYMBOL(parport_set_timeout);
 EXPORT_SYMBOL(parport_ieee1284_interrupt);
diff -Nru a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
--- a/drivers/parport/parport_pc.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/parport/parport_pc.c	2004-12-24 13:37:29 -08:00
@@ -62,6 +62,7 @@
 
 #include <linux/parport.h>
 #include <linux/parport_pc.h>
+#include <linux/via.h>
 #include <asm/parport.h>
 
 #define PARPORT_PC_MAX_PORTS PARPORT_MAX
@@ -1194,7 +1195,7 @@
 
 #ifdef CONFIG_PARPORT_PC_SUPERIO
 /* Super-IO chipset detection, Winbond, SMSC */
-static int __devinit show_parconfig_smsc37c669(int io, int key)
+static void __devinit show_parconfig_smsc37c669(int io, int key)
 {
 	int cr1,cr4,cra,cr23,cr26,cr27,i=0;
 	static const char *modes[]={ "SPP and Bidirectional (PS/2)",	
@@ -1261,26 +1262,17 @@
 					superios[i].io = 0x278;
 					superios[i].irq = 5;
 			}
-			if (io != superios[i].io) {
-				/* how many bytes? */
-				if (!request_region(superios[i].io, 3, "smsc parport")) {
-					superios[i].io = 0;
-					return 0;
-				}
-			}
 			d=(cr26 &0x0f);
 			if((d==1) || (d==3)) 
 				superios[i].dma= d;
 			else
 				superios[i].dma= PARPORT_DMA_NONE;
-			return 1;
 		}
  	}
-	return 0;
 }
 
 
-static int __devinit show_parconfig_winbond(int io, int key)
+static void __devinit show_parconfig_winbond(int io, int key)
 {
 	int cr30,cr60,cr61,cr70,cr74,crf0,i=0;
 	static const char *modes[] = {
@@ -1336,23 +1328,14 @@
 			printk(KERN_INFO "Super-IO: too many chips!\n");
 		else {
 			superios[i].io = (cr60<<8)|cr61;
-			if (io != superios[i].io) {
-				/* how many bytes? */
-				if (!request_region(superios[i].io, 3, "winbond parport")) {
-					superios[i].io = 0;
-					return 0;
-				}
-			}
 			superios[i].irq = cr70&0x0f;
 			superios[i].dma = (((cr74 & 0x07) > 3) ?
 					   PARPORT_DMA_NONE : (cr74 & 0x07));
-			return 1;
 		}
 	}
-	return 0;
 }
 
-static int __devinit decode_winbond(int efer, int key, int devid, int devrev, int oldid)
+static void __devinit decode_winbond(int efer, int key, int devid, int devrev, int oldid)
 {
 	const char *type = "unknown";
 	int id,progif=2;
@@ -1360,7 +1343,7 @@
 	if (devid == devrev)
 		/* simple heuristics, we happened to read some
                    non-winbond register */
-		return 0;
+		return;
 
 	id=(devid<<8) | devrev;
 
@@ -1385,20 +1368,19 @@
 		       efer, key, devid, devrev, oldid, type);
 
 	if (progif == 2)
-		return show_parconfig_winbond(efer,key);
-	return 0;
+		show_parconfig_winbond(efer,key);
 }
 
-static int __devinit decode_smsc(int efer, int key, int devid, int devrev)
+static void __devinit decode_smsc(int efer, int key, int devid, int devrev)
 {
         const char *type = "unknown";
-	int (*func)(int io, int key);
+	void (*func)(int io, int key);
         int id;
 
         if (devid == devrev)
 		/* simple heuristics, we happened to read some
                    non-smsc register */
-		return 0;
+		return;
 
 	func=NULL;
         id=(devid<<8) | devrev;
@@ -1414,8 +1396,7 @@
 		       efer, key, devid, devrev, type);
 
 	if (func)
-		return func(efer,key);
-	return 0;
+		func(efer,key);
 }
 
 
@@ -1448,8 +1429,7 @@
 	if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid))
 		goto out; /* protection against false positives */
 
-	if (decode_winbond(io,key,devid,devrev,oldid));
-		return;
+	decode_winbond(io,key,devid,devrev,oldid);
 out:
 	release_region(io, 3);
 }
@@ -1482,8 +1462,7 @@
 	if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid))
 		goto out; /* protection against false positives */
 
-        if (decode_winbond(io,key,devid,devrev,oldid))
-		return;
+	decode_winbond(io,key,devid,devrev,oldid);
 out:
 	release_region(io, 3);
 }
@@ -1522,8 +1501,7 @@
 	    (x_oldid == oldid) && (x_rev == rev))
 		goto out; /* protection against false positives */
 
-        if (decode_smsc(io,key,oldid,oldrev))
-		return;
+        decode_smsc(io,key,oldid,oldrev);
 out:
 	release_region(io, 3);
 }
@@ -2401,7 +2379,7 @@
 
 /* ITE support maintained by Rich Liu <richliu@poorman.org> */
 static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
-					 int autodma)
+					 int autodma, struct parport_pc_via_data *via)
 {
 	short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 };
 	struct resource *base_res;
@@ -2504,71 +2482,161 @@
 	return 0;
 }
 
-/* Via support maintained by Jeff Garzik <jgarzik@pobox.com> */
-static int __devinit sio_via_686a_probe (struct pci_dev *pdev, int autoirq,
-					 int autodma)
+/* VIA 8231 support by Pavel Fedin <sonic_amiga@rambler.ru>
+   based on VIA 686a support code by Jeff Garzik <jgarzik@pobox.com> */
+static int __initdata parport_init_mode = 0;
+
+/* Data for two known VIA chips */
+static struct parport_pc_via_data via_686a_data __devinitdata = {
+	0x51,
+	0x50,
+	0x85,
+	0x02,
+	0xE2,
+	0xF0,
+	0xE6
+};
+static struct parport_pc_via_data via_8231_data __devinitdata = {
+	0x45,
+	0x44,
+	0x50,
+	0x04,
+	0xF2,
+	0xFA,
+	0xF6
+};
+
+static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
+					 int autodma, struct parport_pc_via_data *via)
 {
-	u8 tmp;
+	u8 tmp, tmp2, siofunc;
+	u8 ppcontrol = 0;
 	int dma, irq;
-	unsigned port1, port2, have_eppecp;
+	unsigned port1, port2;
+	unsigned have_epp = 0;
 
+	printk(KERN_DEBUG "parport_pc: VIA 686A/8231 detected\n");
+
+	switch(parport_init_mode)
+	{
+	case 1:
+	    printk(KERN_DEBUG "parport_pc: setting SPP mode\n");
+	    siofunc = VIA_FUNCTION_PARPORT_SPP;
+	    break;
+	case 2:
+	    printk(KERN_DEBUG "parport_pc: setting PS/2 mode\n");
+	    siofunc = VIA_FUNCTION_PARPORT_SPP;
+	    ppcontrol = VIA_PARPORT_BIDIR;
+	    break;
+	case 3:
+	    printk(KERN_DEBUG "parport_pc: setting EPP mode\n");
+	    siofunc = VIA_FUNCTION_PARPORT_EPP;
+	    ppcontrol = VIA_PARPORT_BIDIR;
+	    have_epp = 1;
+	    break;
+	case 4:
+	    printk(KERN_DEBUG "parport_pc: setting ECP mode\n");
+	    siofunc = VIA_FUNCTION_PARPORT_ECP;
+	    ppcontrol = VIA_PARPORT_BIDIR;
+	    break;
+	case 5:
+	    printk(KERN_DEBUG "parport_pc: setting EPP+ECP mode\n");
+	    siofunc = VIA_FUNCTION_PARPORT_ECP;
+	    ppcontrol = VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP;
+	    have_epp = 1;
+	    break;
+	 default:
+	    printk(KERN_DEBUG "parport_pc: probing current configuration\n");
+	    siofunc = VIA_FUNCTION_PROBE;
+	    break;
+	}
 	/*
-	 * unlock super i/o configuration, set 0x85_1
-	 */
-	pci_read_config_byte (pdev, 0x85, &tmp);
-	tmp |= (1 << 1);
-	pci_write_config_byte (pdev, 0x85, tmp);
-	
-	/* 
-	 * Super I/O configuration, index port == 3f0h, data port == 3f1h
+	 * unlock super i/o configuration
 	 */
+	pci_read_config_byte(pdev, via->via_pci_superio_config_reg, &tmp);
+	tmp |= via->via_pci_superio_config_data;
+	pci_write_config_byte(pdev, via->via_pci_superio_config_reg, tmp);
+
+	/* Bits 1-0: Parallel Port Mode / Enable */
+	outb(via->viacfg_function, VIA_CONFIG_INDEX);
+	tmp = inb (VIA_CONFIG_DATA);
+	/* Bit 5: EPP+ECP enable; bit 7: PS/2 bidirectional port enable */
+	outb(via->viacfg_parport_control, VIA_CONFIG_INDEX);
+	tmp2 = inb (VIA_CONFIG_DATA);
+	if (siofunc == VIA_FUNCTION_PROBE)
+	{
+	    siofunc = tmp & VIA_FUNCTION_PARPORT_DISABLE;
+	    ppcontrol = tmp2;
+	}
+	else
+	{
+	    tmp &= ~VIA_FUNCTION_PARPORT_DISABLE;
+	    tmp |= siofunc;
+	    outb(via->viacfg_function, VIA_CONFIG_INDEX);
+	    outb(tmp, VIA_CONFIG_DATA);
+	    tmp2 &= ~(VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP);
+	    tmp2 |= ppcontrol;
+	    outb(via->viacfg_parport_control, VIA_CONFIG_INDEX);
+	    outb(tmp2, VIA_CONFIG_DATA);
+	}
 	
-	/* 0xE2_1-0: Parallel Port Mode / Enable */
-	outb (0xE2, 0x3F0);
-	tmp = inb (0x3F1);
+	/* Parallel Port I/O Base Address, bits 9-2 */
+	outb(via->viacfg_parport_base, VIA_CONFIG_INDEX);
+	port1 = inb(VIA_CONFIG_DATA) << 2;
 	
-	if ((tmp & 0x03) == 0x03) {
-		printk (KERN_INFO "parport_pc: Via 686A parallel port disabled in BIOS\n");
+	printk (KERN_DEBUG "parport_pc: Current parallel port base: 0x%X\n",port1);
+	if ((port1 == 0x3BC) && have_epp)
+	{
+	    outb(via->viacfg_parport_base, VIA_CONFIG_INDEX);
+	    outb((0x378 >> 2), VIA_CONFIG_DATA);
+	    printk(KERN_DEBUG "parport_pc: Parallel port base changed to 0x378\n");
+	    port1 = 0x378;
+	}
+
+	/*
+	 * lock super i/o configuration
+	 */
+	pci_read_config_byte(pdev, via->via_pci_superio_config_reg, &tmp);
+	tmp &= ~via->via_pci_superio_config_data;
+	pci_write_config_byte(pdev, via->via_pci_superio_config_reg, tmp);
+
+	if (siofunc == VIA_FUNCTION_PARPORT_DISABLE) {
+		printk(KERN_INFO "parport_pc: VIA parallel port disabled in BIOS\n");
 		return 0;
 	}
 	
-	/* 0xE6: Parallel Port I/O Base Address, bits 9-2 */
-	outb (0xE6, 0x3F0);
-	port1 = inb (0x3F1) << 2;
-	
+	/* Bits 7-4: PnP Routing for Parallel Port IRQ */
+	pci_read_config_byte(pdev, via->via_pci_parport_irq_reg, &tmp);
+	irq = ((tmp & VIA_IRQCONTROL_PARALLEL) >> 4);
+
+	if (siofunc == VIA_FUNCTION_PARPORT_ECP)
+	{
+	    /* Bits 3-2: PnP Routing for Parallel Port DMA */
+	    pci_read_config_byte(pdev, via->via_pci_parport_dma_reg, &tmp);
+	    dma = ((tmp & VIA_DMACONTROL_PARALLEL) >> 2);
+	}
+	else
+	    /* if ECP not enabled, DMA is not enabled, assumed bogus 'dma' value */
+	    dma = PARPORT_DMA_NONE;
+
+	/* Let the user (or defaults) steer us away from interrupts and DMA */
+	if (autoirq == PARPORT_IRQ_NONE) {
+	    irq = PARPORT_IRQ_NONE;
+	    dma = PARPORT_DMA_NONE;
+	}
+	if (autodma == PARPORT_DMA_NONE)
+	    dma = PARPORT_DMA_NONE;
+
 	switch (port1) {
 	case 0x3bc: port2 = 0x7bc; break;
 	case 0x378: port2 = 0x778; break;
 	case 0x278: port2 = 0x678; break;
 	default:
-		printk (KERN_INFO "parport_pc: Weird Via 686A parport base 0x%X, ignoring\n",
+		printk(KERN_INFO "parport_pc: Weird VIA parport base 0x%X, ignoring\n",
 			port1);
 		return 0;
 	}
 
-	/* 0xF0_5: EPP+ECP enable */
-	outb (0xF0, 0x3F0);
-	have_eppecp = (inb (0x3F1) & (1 << 5));
-	
-	/*
-	 * lock super i/o configuration, clear 0x85_1
-	 */
-	pci_read_config_byte (pdev, 0x85, &tmp);
-	tmp &= ~(1 << 1);
-	pci_write_config_byte (pdev, 0x85, tmp);
-
-	/*
-	 * Get DMA and IRQ from PCI->ISA bridge PCI config registers
-	 */
-
-	/* 0x50_3-2: PnP Routing for Parallel Port DRQ */
-	pci_read_config_byte (pdev, 0x50, &tmp);
-	dma = ((tmp >> 2) & 0x03);
-	
-	/* 0x51_7-4: PnP Routing for Parallel Port IRQ */
-	pci_read_config_byte (pdev, 0x51, &tmp);
-	irq = ((tmp >> 4) & 0x0F);
-
 	/* filter bogus IRQs */
 	switch (irq) {
 	case 0:
@@ -2582,22 +2650,10 @@
 		break;
 	}
 
-	/* if ECP not enabled, DMA is not enabled, assumed bogus 'dma' value */
-	if (!have_eppecp)
-		dma = PARPORT_DMA_NONE;
-
-	/* Let the user (or defaults) steer us away from interrupts and DMA */
-	if (autoirq != PARPORT_IRQ_AUTO) {
-		irq = PARPORT_IRQ_NONE;
-		dma = PARPORT_DMA_NONE;
-	}
-	if (autodma != PARPORT_DMA_AUTO)
-		dma = PARPORT_DMA_NONE;
-
 	/* finally, do the probe with values obtained */
 	if (parport_pc_probe_port (port1, port2, irq, dma, NULL)) {
 		printk (KERN_INFO
-			"parport_pc: Via 686A parallel port: io=0x%X", port1);
+			"parport_pc: VIA parallel port: io=0x%X", port1);
 		if (irq != PARPORT_IRQ_NONE)
 			printk (", irq=%d", irq);
 		if (dma != PARPORT_DMA_NONE)
@@ -2606,7 +2662,7 @@
 		return 1;
 	}
 	
-	printk (KERN_WARNING "parport_pc: Strange, can't probe Via 686A parallel port: io=0x%X, irq=%d, dma=%d\n",
+	printk(KERN_WARNING "parport_pc: Strange, can't probe VIA parallel port: io=0x%X, irq=%d, dma=%d\n",
 		port1, irq, dma);
 	return 0;
 }
@@ -2614,19 +2670,21 @@
 
 enum parport_pc_sio_types {
 	sio_via_686a = 0,	/* Via VT82C686A motherboard Super I/O */
+	sio_via_8231,		/* Via VT8231 south bridge integrated Super IO */
 	sio_ite_8872,
 	last_sio
 };
 
 /* each element directly indexed from enum list, above */
 static struct parport_pc_superio {
-	int (*probe) (struct pci_dev *pdev, int autoirq, int autodma);
+	int (*probe) (struct pci_dev *pdev, int autoirq, int autodma, struct parport_pc_via_data *via);
+	struct parport_pc_via_data *via;
 } parport_pc_superio_info[] __devinitdata = {
-	{ sio_via_686a_probe, },
-	{ sio_ite_8872_probe, },
+	{ sio_via_probe, &via_686a_data, },
+	{ sio_via_probe, &via_8231_data, },
+	{ sio_ite_8872_probe, NULL, },
 };
 
-
 enum parport_pc_pci_cards {
 	siig_1p_10x = last_sio,
 	siig_2p_10x,
@@ -2760,6 +2818,7 @@
 static struct pci_device_id parport_pc_pci_tbl[] = {
 	/* Super-IO onboard chips */
 	{ 0x1106, 0x0686, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_686a },
+	{ 0x1106, 0x8231, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_8231 },
 	{ PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8872,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_ite_8872 },
 
@@ -2909,7 +2968,7 @@
 			continue;
 
 		if (parport_pc_superio_info[id->driver_data].probe
-			(pdev, autoirq, autodma)) {
+			(pdev, autoirq, autodma,parport_pc_superio_info[id->driver_data].via)) {
 			ret++;
 		}
 	}
@@ -2989,7 +3048,7 @@
 
 
 /* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */
-static int __init __attribute__((unused))
+static int __devinit __attribute__((unused))
 parport_pc_find_isa_ports (int autoirq, int autodma)
 {
 	int count = 0;
@@ -3039,10 +3098,10 @@
 	count += parport_pc_find_nonpci_ports (autoirq, autodma);
 
 	r = pci_register_driver (&parport_pc_pci_driver);
-	if (r >= 0) {
-		pci_registered_parport = 1;
-		count += r;
-	}
+	if (r)
+		return r;
+	pci_registered_parport = 1;
+	count += 1;
 
 	return count;
 }
@@ -3095,22 +3154,46 @@
 				     PARPORT_DMA_NONE, PARPORT_DMA_NOFIFO);
 }
 
+#ifdef CONFIG_PCI
+static int __init parport_init_mode_setup(char *str)
+{
+	printk(KERN_DEBUG "parport_pc.c: Specified parameter parport_init_mode=%s\n", str);
+
+	if (!strcmp (str, "spp"))
+		parport_init_mode=1;
+	if (!strcmp (str, "ps2"))
+		parport_init_mode=2;
+	if (!strcmp (str, "epp"))
+		parport_init_mode=3;
+	if (!strcmp (str, "ecp"))
+		parport_init_mode=4;
+	if (!strcmp (str, "ecpepp"))
+		parport_init_mode=5;
+	return 1;
+}
+#endif
+
 #ifdef MODULE
 static const char *irq[PARPORT_PC_MAX_PORTS];
 static const char *dma[PARPORT_PC_MAX_PORTS];
+static char *init_mode;
 
 MODULE_PARM_DESC(io, "Base I/O address (SPP regs)");
-MODULE_PARM(io, "1-" __MODULE_STRING(PARPORT_PC_MAX_PORTS) "i");
+module_param_array(io, int, NULL, 0);
 MODULE_PARM_DESC(io_hi, "Base I/O address (ECR)");
-MODULE_PARM(io_hi, "1-" __MODULE_STRING(PARPORT_PC_MAX_PORTS) "i");
+module_param_array(io_hi, int, NULL, 0);
 MODULE_PARM_DESC(irq, "IRQ line");
-MODULE_PARM(irq, "1-" __MODULE_STRING(PARPORT_PC_MAX_PORTS) "s");
+module_param_array(irq, charp, NULL, 0);
 MODULE_PARM_DESC(dma, "DMA channel");
-MODULE_PARM(dma, "1-" __MODULE_STRING(PARPORT_PC_MAX_PORTS) "s");
+module_param_array(dma, charp, NULL, 0);
 #if defined(CONFIG_PARPORT_PC_SUPERIO) || \
        (defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
 MODULE_PARM_DESC(verbose_probing, "Log chit-chat during initialisation");
-MODULE_PARM(verbose_probing, "i");
+module_param(verbose_probing, int, 0644);
+#endif
+#ifdef CONFIG_PCI
+MODULE_PARM_DESC(init_mode, "Initialise mode for VIA VT8231 port (spp, ps2, epp, ecp or ecpepp)");
+MODULE_PARM(init_mode, "s");
 #endif
 
 static int __init parse_parport_params(void)
@@ -3118,6 +3201,11 @@
 	unsigned int i;
 	int val;
 
+#ifdef CONFIG_PCI
+	if (init_mode)
+		parport_init_mode_setup(init_mode);
+#endif
+
 	for (i = 0; i < PARPORT_PC_MAX_PORTS && io[i]; i++) {
 		if (parport_parse_irq(irq[i], &val))
 			return 1;
@@ -3225,6 +3313,15 @@
 }
 
 __setup ("parport=", parport_setup);
+
+/*
+ * Acceptable parameters:
+ *
+ * parport_init_mode=[spp|ps2|epp|ecp|ecpepp]
+ */
+#ifdef CONFIG_PCI
+__setup("parport_init_mode=",parport_init_mode_setup);
+#endif
 #endif
 
 /* "Parser" ends here */
diff -Nru a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
--- a/drivers/parport/parport_sunbpp.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/parport/parport_sunbpp.c	2004-12-24 13:36:18 -08:00
@@ -52,7 +52,7 @@
 
 static void parport_sunbpp_disable_irq(struct parport *p)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 	u32 tmp;
 
 	tmp = sbus_readl(&regs->p_csr);
@@ -62,7 +62,7 @@
 
 static void parport_sunbpp_enable_irq(struct parport *p)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 	u32 tmp;
 
 	tmp = sbus_readl(&regs->p_csr);
@@ -72,7 +72,7 @@
 
 static void parport_sunbpp_write_data(struct parport *p, unsigned char d)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 
 	sbus_writeb(d, &regs->p_dr);
 	dprintk((KERN_DEBUG "wrote 0x%x\n", d));
@@ -80,7 +80,7 @@
 
 static unsigned char parport_sunbpp_read_data(struct parport *p)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 
 	return sbus_readb(&regs->p_dr);
 }
@@ -88,7 +88,7 @@
 #if 0
 static void control_pc_to_sunbpp(struct parport *p, unsigned char status)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 	unsigned char value_tcr = sbus_readb(&regs->p_tcr);
 	unsigned char value_or = sbus_readb(&regs->p_or);
 
@@ -108,7 +108,7 @@
 
 static unsigned char status_sunbpp_to_pc(struct parport *p)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 	unsigned char bits = 0;
 	unsigned char value_tcr = sbus_readb(&regs->p_tcr);
 	unsigned char value_ir = sbus_readb(&regs->p_ir);
@@ -131,7 +131,7 @@
 
 static unsigned char control_sunbpp_to_pc(struct parport *p)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 	unsigned char bits = 0;
 	unsigned char value_tcr = sbus_readb(&regs->p_tcr);
 	unsigned char value_or = sbus_readb(&regs->p_or);
@@ -159,7 +159,7 @@
 						 unsigned char mask,
 						 unsigned char val)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 	unsigned char value_tcr = sbus_readb(&regs->p_tcr);
 	unsigned char value_or = sbus_readb(&regs->p_or);
 
@@ -216,7 +216,7 @@
 
 static void parport_sunbpp_data_forward (struct parport *p)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 	unsigned char value_tcr = sbus_readb(&regs->p_tcr);
 
 	dprintk((KERN_DEBUG "forward\n"));
@@ -226,7 +226,7 @@
 
 static void parport_sunbpp_data_reverse (struct parport *p)
 {
-	struct bpp_regs *regs = (struct bpp_regs *)p->base;
+	struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
 	u8 val = sbus_readb(&regs->p_tcr);
 
 	dprintk((KERN_DEBUG "reverse\n"));
@@ -299,9 +299,9 @@
 	struct parport *p;
 	/* at least in theory there may be a "we don't dma" case */
 	struct parport_operations *ops;
-	unsigned long base;
+	void __iomem *base;
 	int irq, dma, err = 0, size;
-	struct bpp_regs *regs;
+	struct bpp_regs __iomem *regs;
 	unsigned char value_tcr;
 	Node *node;
 
@@ -328,7 +328,7 @@
         memcpy (ops, &parport_sunbpp_ops, sizeof (struct parport_operations));
 
 	dprintk(("register_port\n"));
-	if (!(p = parport_register_port(base, irq, dma, ops)))
+	if (!(p = parport_register_port((unsigned long)base, irq, dma, ops)))
 		goto out3;
 
 	p->size = size;
@@ -343,7 +343,7 @@
 	dprintk(("OK\n"));
 	parport_sunbpp_enable_irq(p);
 
-	regs = (struct bpp_regs *)p->base;
+	regs = (struct bpp_regs __iomem *)p->base;
 	dprintk((KERN_DEBUG "forward\n"));
 	value_tcr = sbus_readb(&regs->p_tcr);
 	value_tcr &= ~P_TCR_DIR;
@@ -395,7 +395,7 @@
 			parport_sunbpp_disable_irq(p);
 			free_irq(p->irq, p);
 		}
-		sbus_iounmap(p->base, p->size);
+		sbus_iounmap((void __iomem *)p->base, p->size);
 		parport_put_port(p);
 		kfree (ops);
 		list_del(&node->list);
diff -Nru a/drivers/parport/probe.c b/drivers/parport/probe.c
--- a/drivers/parport/probe.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/parport/probe.c	2004-12-24 13:36:32 -08:00
@@ -213,4 +213,3 @@
 	parport_close (dev);
 	return retval;
 }
-EXPORT_SYMBOL(parport_device_id);
diff -Nru a/drivers/parport/procfs.c b/drivers/parport/procfs.c
--- a/drivers/parport/procfs.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/parport/procfs.c	2004-12-24 13:36:31 -08:00
@@ -529,8 +529,5 @@
 }
 #endif
 
-EXPORT_SYMBOL(parport_device_proc_register);
-EXPORT_SYMBOL(parport_device_proc_unregister);
-
 module_init(parport_default_proc_register)
 module_exit(parport_default_proc_unregister)
diff -Nru a/drivers/parport/share.c b/drivers/parport/share.c
--- a/drivers/parport/share.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/parport/share.c	2004-12-24 13:36:49 -08:00
@@ -1007,7 +1007,6 @@
 EXPORT_SYMBOL(parport_unregister_driver);
 EXPORT_SYMBOL(parport_register_device);
 EXPORT_SYMBOL(parport_unregister_device);
-EXPORT_SYMBOL(parport_get_port);
 EXPORT_SYMBOL(parport_put_port);
 EXPORT_SYMBOL(parport_find_number);
 EXPORT_SYMBOL(parport_find_base);
diff -Nru a/drivers/pci/Makefile b/drivers/pci/Makefile
--- a/drivers/pci/Makefile	2004-12-24 13:37:19 -08:00
+++ b/drivers/pci/Makefile	2004-12-24 13:37:19 -08:00
@@ -3,7 +3,8 @@
 #
 
 obj-y		+= access.o bus.o probe.o remove.o pci.o quirks.o \
-			names.o pci-driver.o search.o pci-sysfs.o
+			names.o pci-driver.o search.o pci-sysfs.o \
+			rom.o
 obj-$(CONFIG_PROC_FS) += proc.o
 
 ifndef CONFIG_SPARC64
@@ -27,6 +28,11 @@
 obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o
 obj-$(CONFIG_X86_VISWS) += setup-irq.o
 obj-$(CONFIG_PCI_MSI) += msi.o
+
+#
+# ACPI Related PCI FW Functions
+#
+obj-$(CONFIG_ACPI)    += pci-acpi.o
 
 # Cardbus & CompactPCI use setup-bus
 obj-$(CONFIG_HOTPLUG) += setup-bus.o
diff -Nru a/drivers/pci/bus.c b/drivers/pci/bus.c
--- a/drivers/pci/bus.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/pci/bus.c	2004-12-24 13:37:29 -08:00
@@ -69,6 +69,25 @@
 }
 
 /**
+ * add a single device
+ * @dev: device to add
+ *
+ * This adds a single pci device to the global
+ * device list and adds sysfs and procfs entries
+ */
+void __devinit pci_bus_add_device(struct pci_dev *dev)
+{
+	device_add(&dev->dev);
+
+	spin_lock(&pci_bus_lock);
+	list_add_tail(&dev->global_list, &pci_devices);
+	spin_unlock(&pci_bus_lock);
+
+	pci_proc_attach_device(dev);
+	pci_create_sysfs_dev_files(dev);
+}
+
+/**
  * pci_bus_add_devices - insert newly discovered PCI devices
  * @bus: bus to check for new devices
  *
@@ -91,16 +110,7 @@
 		 */
 		if (!list_empty(&dev->global_list))
 			continue;
-
-		device_add(&dev->dev);
-
-		spin_lock(&pci_bus_lock);
-		list_add_tail(&dev->global_list, &pci_devices);
-		spin_unlock(&pci_bus_lock);
-
-		pci_proc_attach_device(dev);
-		pci_create_sysfs_dev_files(dev);
-
+		pci_bus_add_device(dev);
 	}
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
@@ -136,5 +146,6 @@
 }
 
 EXPORT_SYMBOL(pci_bus_alloc_resource);
+EXPORT_SYMBOL_GPL(pci_bus_add_device);
 EXPORT_SYMBOL(pci_bus_add_devices);
 EXPORT_SYMBOL(pci_enable_bridges);
diff -Nru a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
--- a/drivers/pci/hotplug/Makefile	2004-12-24 13:37:02 -08:00
+++ b/drivers/pci/hotplug/Makefile	2004-12-24 13:37:02 -08:00
@@ -51,7 +51,6 @@
 pciehp-objs		:=	pciehp_core.o	\
 				pciehp_ctrl.o	\
 				pciehp_pci.o	\
-				pciehp_sysfs.o	\
 				pciehp_hpc.o
 ifdef CONFIG_ACPI_BUS
 	pciehp-objs += pciehprm_acpi.o
diff -Nru a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
--- a/drivers/pci/hotplug/acpiphp_glue.c	2004-12-24 13:36:35 -08:00
+++ b/drivers/pci/hotplug/acpiphp_glue.c	2004-12-24 13:36:35 -08:00
@@ -389,7 +389,7 @@
 
 	bridge->pci_bus = pci_find_bus(seg, bus);
 
-	bridge->res_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&bridge->res_lock);
 
 	/* to be overridden when we decode _CRS	*/
 	bridge->sub = bridge->bus;
@@ -457,7 +457,7 @@
 		return;
 	}
 
-	bridge->res_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&bridge->res_lock);
 
 	bridge->bus = bridge->pci_bus->number;
 	bridge->sub = bridge->pci_bus->subordinate;
diff -Nru a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
--- a/drivers/pci/hotplug/acpiphp_ibm.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/pci/hotplug/acpiphp_ibm.c	2004-12-24 13:37:18 -08:00
@@ -64,6 +64,8 @@
 #define IBM_HARDWARE_ID1 "IBM37D0"
 #define IBM_HARDWARE_ID2 "IBM37D4"
 
+#define hpslot_to_sun(A) (((struct slot *)((A)->private))->acpi_slot->sun)
+
 /* union apci_descriptor - allows access to the
  * various device descriptors that are embedded in the
  * aPCI table
@@ -84,6 +86,7 @@
 		u8  attn;
 		u8  status[2];
 		u8  sun;
+		u8  res[3];
 	} slot;
 	struct {
 		u8 type;
@@ -128,6 +131,43 @@
 	.owner = THIS_MODULE,
 };
 
+/**
+ * ibm_slot_from_id - workaround for bad ibm hardware
+ * @id: the slot number that linux refers to the slot by
+ *
+ * Description: this method returns the aCPI slot descriptor
+ * corresponding to the Linux slot number.  This descriptor
+ * has info about the aPCI slot id and attention status.
+ * This descriptor must be freed using kfree when done.
+ **/
+static union apci_descriptor *ibm_slot_from_id(int id)
+{
+	int ind = 0, size;
+	union apci_descriptor *ret = NULL, *des;
+	char *table;
+
+	size = ibm_get_table_from_acpi(&table);
+	des = (union apci_descriptor *)table;
+	if (memcmp(des->header.sig, "aPCI", 4) != 0)
+		goto ibm_slot_done;
+
+	des = (union apci_descriptor *)&table[ind += des->header.len];
+	while (ind < size && (des->generic.type != 0x82 ||
+			des->slot.slot_num != id)) {
+		des = (union apci_descriptor *)&table[ind += des->generic.len];
+	}
+
+	if (ind < size && des->slot.slot_num == id)
+		ret = des;
+
+ibm_slot_done:
+	if (ret) {
+		ret = kmalloc(sizeof(union apci_descriptor), GFP_KERNEL);
+		memcpy(ret, des, sizeof(union apci_descriptor));
+	}
+	kfree(table);
+	return ret;
+}
 
 /**
  * ibm_set_attention_status - callback method to set the attention LED
@@ -139,32 +179,34 @@
  **/
 static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status)
 {
-	int retval = 0;
 	union acpi_object args[2]; 
 	struct acpi_object_list params = { .pointer = args, .count = 2 };
 	acpi_status stat; 
-	unsigned long rc = 0;
-	struct acpiphp_slot *acpi_slot;
+	unsigned long rc;
+	union apci_descriptor *ibm_slot;
 
-	acpi_slot = ((struct slot *)(slot->private))->acpi_slot;
+	ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot));
 
-	dbg("%s: set slot %d attention status to %d\n", __FUNCTION__,
-			acpi_slot->sun, (status ? 1 : 0));
+	dbg("%s: set slot %d (%d) attention status to %d\n", __FUNCTION__,
+			ibm_slot->slot.slot_num, ibm_slot->slot.slot_id,
+			(status ? 1 : 0));
 
 	args[0].type = ACPI_TYPE_INTEGER;
-	args[0].integer.value = acpi_slot->sun;
+	args[0].integer.value = ibm_slot->slot.slot_id;
 	args[1].type = ACPI_TYPE_INTEGER;
 	args[1].integer.value = (status) ? 1 : 0;
 
+	kfree(ibm_slot);
+
 	stat = acpi_evaluate_integer(ibm_acpi_handle, "APLS", &params, &rc);
 	if (ACPI_FAILURE(stat)) {
-		retval = -ENODEV;
 		err("APLS evaluation failed:  0x%08x\n", stat);
+		return -ENODEV;
 	} else if (!rc) {
-		retval = -ERANGE;
 		err("APLS method failed:  0x%08lx\n", rc);
+		return -ERANGE;
 	}
-	return retval;
+	return 0;
 }
 
 /**
@@ -181,38 +223,21 @@
  **/
 static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status)
 {
-	int retval = -EINVAL, ind = 0, size;
-	char *table = NULL;
-	struct acpiphp_slot *acpi_slot;
-	union apci_descriptor *des;
+	union apci_descriptor *ibm_slot;
 
-	acpi_slot = ((struct slot *)(slot->private))->acpi_slot;
+	ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot));
 
-	size = ibm_get_table_from_acpi(&table);
-	if (size <= 0 || !table)
-		goto get_attn_done;
-	// read the header
-	des = (union apci_descriptor *)&table[ind];
-	if (memcmp(des->header.sig, "aPCI", 4) != 0)
-		goto get_attn_done;
-	des = (union apci_descriptor *)&table[ind += des->header.len];
-	while (ind < size && (des->generic.type != 0x82 ||
-			des->slot.slot_id != acpi_slot->sun))
-		des = (union apci_descriptor *)&table[ind += des->generic.len];
-	if (ind < size && des->slot.slot_id == acpi_slot->sun) {
-		retval = 0;
-		if (des->slot.attn & 0xa0 || des->slot.status[1] & 0x08)
-			*status = 1;
-		else
-			*status = 0;
-	}
+	if (ibm_slot->slot.attn & 0xa0 || ibm_slot->slot.status[1] & 0x08)
+		*status = 1;
+	else
+		*status = 0;
 
-	dbg("%s: get slot %d attention status is %d retval=%x\n",
-			__FUNCTION__, acpi_slot->sun, *status, retval);
+	dbg("%s: get slot %d (%d) attention status is %d\n", __FUNCTION__,
+			ibm_slot->slot.slot_num, ibm_slot->slot.slot_id,
+			*status);
 
-get_attn_done:
-	kfree(table);
-	return retval;
+	kfree(ibm_slot);
+	return 0;
 }
 
 /**
diff -Nru a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
--- a/drivers/pci/hotplug/cpcihp_generic.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/pci/hotplug/cpcihp_generic.c	2004-12-24 13:36:55 -08:00
@@ -63,7 +63,7 @@
 
 /* local variables */
 static int debug;
-static char* bridge;
+static char *bridge;
 static u8 bridge_busnr;
 static u8 bridge_slot;
 static struct pci_bus *bus;
@@ -209,15 +209,15 @@
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
-MODULE_PARM(bridge, "s");
+module_param(bridge, charp, 0);
 MODULE_PARM_DESC(bridge, "Hotswap bus bridge device, <bus>:<slot> (bus and slot are in hexadecimal)");
-MODULE_PARM(first_slot, "b");
+module_param(first_slot, byte, 0);
 MODULE_PARM_DESC(first_slot, "Hotswap bus first slot number");
-MODULE_PARM(last_slot, "b");
+module_param(last_slot, byte, 0);
 MODULE_PARM_DESC(last_slot, "Hotswap bus last slot number");
-MODULE_PARM(port, "h");
+module_param(port, ushort, 0);
 MODULE_PARM_DESC(port, "#ENUM signal I/O port");
-MODULE_PARM(enum_bit, "i");
+module_param(enum_bit, uint, 0);
 MODULE_PARM_DESC(enum_bit, "#ENUM signal bit (0-7)");
diff -Nru a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
--- a/drivers/pci/hotplug/cpcihp_zt5550.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/pci/hotplug/cpcihp_zt5550.c	2004-12-24 13:37:00 -08:00
@@ -69,11 +69,11 @@
 static struct pci_dev *hc_dev;
 
 /* Host controller register addresses */
-static void *hc_registers;
-static void *csr_hc_index;
-static void *csr_hc_data;
-static void *csr_int_status;
-static void *csr_int_mask;
+static void __iomem *hc_registers;
+static void __iomem *csr_hc_index;
+static void __iomem *csr_hc_data;
+static void __iomem *csr_int_status;
+static void __iomem *csr_int_mask;
 
 
 static int zt5550_hc_config(struct pci_dev *pdev)
@@ -219,12 +219,13 @@
 	dbg("registered controller");
 
 	/* Look for first device matching cPCI bus's bridge vendor and device IDs */
-	if(!(bus0_dev = pci_find_device(PCI_VENDOR_ID_DEC,
+	if(!(bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC,
 					 PCI_DEVICE_ID_DEC_21154, NULL))) {
 		status = -ENODEV;
 		goto init_register_error;
 	}
 	bus0 = bus0_dev->subordinate;
+	pci_dev_put(bus0_dev);
 
 	status = cpci_hp_register_bus(bus0, 0x0a, 0x0f);
 	if(status != 0) {
@@ -282,7 +283,7 @@
 	if(!r)
 		return -EBUSY;
 
-	return pci_module_init(&zt5550_hc_driver);
+	return pci_register_driver(&zt5550_hc_driver);
 }
 
 static void __exit
diff -Nru a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
--- a/drivers/pci/hotplug/cpqphp.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/pci/hotplug/cpqphp.h	2004-12-24 13:37:18 -08:00
@@ -268,7 +268,7 @@
 	struct timer_list task_event;
 	u8 hp_slot;
 	struct controller *ctrl;
-	void *p_sm_slot;
+	void __iomem *p_sm_slot;
 	struct hotplug_slot *hotplug_slot;
 };
 
@@ -287,7 +287,7 @@
 	struct controller *next;
 	u32 ctrl_int_comp;
 	struct semaphore crit_sect;	/* critical section semaphore */
-	void *hpc_reg;			/* cookie for our pci controller location */
+	void __iomem *hpc_reg;		/* cookie for our pci controller location */
 	struct pci_resource *mem_head;
 	struct pci_resource *p_mem_head;
 	struct pci_resource *io_head;
@@ -405,7 +405,7 @@
 /* controller functions */
 extern void	cpqhp_pushbutton_thread		(unsigned long event_pointer);
 extern irqreturn_t cpqhp_ctrl_intr		(int IRQ, void *data, struct pt_regs *regs);
-extern int	cpqhp_find_available_resources	(struct controller *ctrl, void *rom_start);
+extern int	cpqhp_find_available_resources	(struct controller *ctrl, void __iomem *rom_start);
 extern int	cpqhp_event_start_thread	(void);
 extern void	cpqhp_event_stop_thread		(void);
 extern struct pci_func *cpqhp_slot_create	(unsigned char busnumber);
@@ -707,9 +707,8 @@
 
 	dbg("%s - start\n", __FUNCTION__);
 	add_wait_queue(&ctrl->queue, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
 	/* Sleep for up to 1 second to wait for the LED to change. */
-	schedule_timeout(1*HZ);
+	msleep_interruptible(1000);
 	remove_wait_queue(&ctrl->queue, &wait);
 	if (signal_pending(current))
 		retval =  -EINTR;
diff -Nru a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
--- a/drivers/pci/hotplug/cpqphp_core.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/pci/hotplug/cpqphp_core.c	2004-12-24 13:36:16 -08:00
@@ -55,9 +55,9 @@
 struct pci_func *cpqhp_slot_list[256];
 
 /* local variables */
-static void *smbios_table;
-static void *smbios_start;
-static void *cpqhp_rom_start;
+static void __iomem *smbios_table;
+static void __iomem *smbios_start;
+static void __iomem *cpqhp_rom_start;
 static int power_mode;
 static int debug;
 
@@ -123,10 +123,10 @@
  * Returns pointer to the head of the SMBIOS tables (or NULL)
  *
  */
-static void * detect_SMBIOS_pointer(void *begin, void *end)
+static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *end)
 {
-	void *fp;
-	void *endp;
+	void __iomem *fp;
+	void __iomem *endp;
 	u8 temp1, temp2, temp3, temp4;
 	int status = 0;
 
@@ -232,13 +232,14 @@
  *
  * returns a pointer to an SMBIOS structure or NULL if none found
  */
-static void *get_subsequent_smbios_entry(void *smbios_start,
-			void *smbios_table, void *curr)
+static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start,
+						void __iomem *smbios_table,
+						void __iomem *curr)
 {
 	u8 bail = 0;
 	u8 previous_byte = 1;
-	void *p_temp;
-	void *p_max;
+	void __iomem *p_temp;
+	void __iomem *p_max;
 
 	if (!smbios_table || !curr)
 		return(NULL);
@@ -282,8 +283,10 @@
  *
  * returns a pointer to an SMBIOS structure or %NULL if none found
  */
-static void *get_SMBIOS_entry(void *smbios_start, void *smbios_table, u8 type,
-			void * previous)
+static void __iomem *get_SMBIOS_entry(void __iomem *smbios_start,
+					void __iomem *smbios_table,
+					u8 type,
+					void __iomem *previous)
 {
 	if (!smbios_table)
 		return NULL;
@@ -319,8 +322,9 @@
 	kfree(slot);
 }
 
-static int ctrl_slot_setup(struct controller * ctrl, void *smbios_start,
-			void *smbios_table)
+static int ctrl_slot_setup(struct controller *ctrl,
+			void __iomem *smbios_start,
+			void __iomem *smbios_table)
 {
 	struct slot *new_slot;
 	u8 number_of_slots;
@@ -328,7 +332,7 @@
 	u8 slot_number;
 	u8 ctrl_slot;
 	u32 tempdword;
-	void *slot_entry= NULL;
+	void __iomem *slot_entry= NULL;
 	int result = -ENOMEM;
 
 	dbg("%s\n", __FUNCTION__);
@@ -1483,8 +1487,8 @@
 	cpqhp_debug = debug;
 
 	info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
-	result = pci_module_init(&cpqhpc_driver);
-	dbg("pci_module_init = %d\n", result);
+	result = pci_register_driver(&cpqhpc_driver);
+	dbg("pci_register_driver = %d\n", result);
 	return result;
 }
 
diff -Nru a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
--- a/drivers/pci/hotplug/cpqphp_ctrl.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c	2004-12-24 13:36:47 -08:00
@@ -69,10 +69,8 @@
 	init_waitqueue_head(&delay_wait);
 
 	add_wait_queue(&delay_wait, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(delay);
+	msleep_interruptible(jiffies_to_msecs(delay));
 	remove_wait_queue(&delay_wait, &wait);
-	set_current_state(TASK_RUNNING);
 	
 	up(&delay_sem);
 }
diff -Nru a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
--- a/drivers/pci/hotplug/cpqphp_nvram.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/pci/hotplug/cpqphp_nvram.c	2004-12-24 13:37:19 -08:00
@@ -92,7 +92,7 @@
 static u8 evbuffer_length;
 static u8 evbuffer[1024];
 
-static void *compaq_int15_entry_point;
+static void __iomem *compaq_int15_entry_point;
 
 static spinlock_t int15_lock;		/* lock for ordering int15_bios_call() */
 
@@ -141,7 +141,7 @@
  *
  * returns 0 for non-Compaq ROM, 1 for Compaq ROM
  */
-static int check_for_compaq_ROM (void *rom_start)
+static int check_for_compaq_ROM (void __iomem *rom_start)
 {
 	u8 temp1, temp2, temp3, temp4, temp5, temp6;
 	int result = 0;
@@ -197,7 +197,7 @@
  *
  * Read the hot plug Resource Table from NVRAM
  */
-static int load_HRT (void *rom_start)
+static int load_HRT (void __iomem *rom_start)
 {
 	u32 available;
 	u32 temp_dword;
@@ -231,7 +231,7 @@
  *
  * Save the hot plug Resource Table in NVRAM
  */
-static u32 store_HRT (void *rom_start)
+static u32 store_HRT (void __iomem *rom_start)
 {
 	u32 *buffer;
 	u32 *pFill;
@@ -423,7 +423,7 @@
 }
 
 
-void compaq_nvram_init (void *rom_start)
+void compaq_nvram_init (void __iomem *rom_start)
 {
 	if (rom_start) {
 		compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
@@ -435,7 +435,7 @@
 }
 
 
-int compaq_nvram_load (void *rom_start, struct controller *ctrl)
+int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
 {
 	u8 bus, device, function;
 	u8 nummem, numpmem, numio, numbus;
@@ -648,7 +648,7 @@
 }
 
 	
-int compaq_nvram_store (void *rom_start)
+int compaq_nvram_store (void __iomem *rom_start)
 {
 	int rc = 1;
 
diff -Nru a/drivers/pci/hotplug/cpqphp_nvram.h b/drivers/pci/hotplug/cpqphp_nvram.h
--- a/drivers/pci/hotplug/cpqphp_nvram.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/pci/hotplug/cpqphp_nvram.h	2004-12-24 13:37:00 -08:00
@@ -30,26 +30,26 @@
 
 #ifndef CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM
 
-static inline void compaq_nvram_init (void *rom_start)
+static inline void compaq_nvram_init (void __iomem *rom_start)
 {
 	return;
 }
 
-static inline int compaq_nvram_load (void *rom_start, struct controller *ctrl)
+static inline int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
 {
 	return 0;
 }
 
-static inline int compaq_nvram_store (void *rom_start)
+static inline int compaq_nvram_store (void __iomem *rom_start)
 {
 	return 0;
 }
 
 #else
 
-extern void compaq_nvram_init	(void *rom_start);
-extern int compaq_nvram_load	(void *rom_start, struct controller *ctrl);
-extern int compaq_nvram_store	(void *rom_start);
+extern void compaq_nvram_init	(void __iomem *rom_start);
+extern int compaq_nvram_load	(void __iomem *rom_start, struct controller *ctrl);
+extern int compaq_nvram_store	(void __iomem *rom_start);
 
 #endif
 
diff -Nru a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
--- a/drivers/pci/hotplug/cpqphp_pci.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/pci/hotplug/cpqphp_pci.c	2004-12-24 13:37:19 -08:00
@@ -51,10 +51,10 @@
  * find the Hot Plug Resource Table in the specified region of memory.
  *
  */
-static void *detect_HRT_floating_pointer(void *begin, void *end)
+static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iomem *end)
 {
-	void *fp;
-	void *endp;
+	void __iomem *fp;
+	void __iomem *endp;
 	u8 temp1, temp2, temp3, temp4;
 	int status = 0;
 
@@ -194,7 +194,7 @@
 
 static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev_num)
 {
-	u8 tdevice;
+	u16 tdevice;
 	u32 work;
 	u8 tbus;
 
@@ -1162,12 +1162,13 @@
  *
  * returns 0 if success
  */  
-int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start)
+int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_start)
 {
 	u8 temp;
 	u8 populated_slot;
 	u8 bridged_slot;
-	void *one_slot;
+	void __iomem *one_slot;
+	void __iomem *rom_resource_table;
 	struct pci_func *func = NULL;
 	int i = 10, index;
 	u32 temp_dword, rc;
@@ -1175,7 +1176,6 @@
 	struct pci_resource *p_mem_node;
 	struct pci_resource *io_node;
 	struct pci_resource *bus_node;
-	void *rom_resource_table;
 
 	rom_resource_table = detect_HRT_floating_pointer(rom_start, rom_start+0xffff);
 	dbg("rom_resource_table = %p\n", rom_resource_table);
diff -Nru a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
--- a/drivers/pci/hotplug/fakephp.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/pci/hotplug/fakephp.c	2004-12-24 13:37:01 -08:00
@@ -165,14 +165,123 @@
 		err("Problem unregistering a slot %s\n", dslot->slot->name);
 }
 
+/**
+ * Rescan slot.
+ * Tries hard not to re-enable already existing devices
+ * also handles scanning of subfunctions
+ *
+ * @param temp   Device template. Should be set: bus and devfn.
+ */
+static void pci_rescan_slot(struct pci_dev *temp)
+{
+	struct pci_bus *bus = temp->bus;
+	struct pci_dev *dev;
+	int func;
+	u8 hdr_type;
+	if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) {
+		temp->hdr_type = hdr_type & 0x7f;
+		if (!pci_find_slot(bus->number, temp->devfn)) {
+			dev = pci_scan_single_device(bus, temp->devfn);
+			if (dev) {
+				dbg("New device on %s function %x:%x\n",
+					bus->name, temp->devfn >> 3,
+					temp->devfn & 7);
+				pci_bus_add_device(dev);
+				add_slot(dev);
+			}
+		}
+		/* multifunction device? */
+		if (!(hdr_type & 0x80))
+			return;
+
+		/* continue scanning for other functions */
+		for (func = 1, temp->devfn++; func < 8; func++, temp->devfn++) {
+			if (pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type))
+				continue;
+			temp->hdr_type = hdr_type & 0x7f;
+
+			if (!pci_find_slot(bus->number, temp->devfn)) {
+				dev = pci_scan_single_device(bus, temp->devfn);
+				if (dev) {
+					dbg("New device on %s function %x:%x\n",
+						bus->name, temp->devfn >> 3,
+						temp->devfn & 7);
+					pci_bus_add_device(dev);
+					add_slot(dev);
+				}
+			}
+		}
+	}
+}
+
+
+/**
+ * Rescan PCI bus.
+ * call pci_rescan_slot for each possible function of the bus
+ *
+ * @param bus
+ */
+static void pci_rescan_bus(const struct pci_bus *bus)
+{
+	unsigned int devfn;
+	struct pci_dev *dev;
+	dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
+	if (!dev)
+		return;
+
+	memset(dev, 0, sizeof(dev));
+	dev->bus = (struct pci_bus*)bus;
+	dev->sysdata = bus->sysdata;
+	for (devfn = 0; devfn < 0x100; devfn += 8) {
+		dev->devfn = devfn;
+		pci_rescan_slot(dev);
+	}
+	kfree(dev);
+}
+
+/* recursively scan all buses */
+static void pci_rescan_buses(const struct list_head *list)
+{
+	const struct list_head *l;
+	list_for_each(l,list) {
+		const struct pci_bus *b = pci_bus_b(l);
+		pci_rescan_bus(b);
+		pci_rescan_buses(&b->children);
+	}
+}
+
+/* initiate rescan of all pci buses */
+static inline void pci_rescan(void) {
+	pci_rescan_buses(&pci_root_buses);
+}
+
+
 static int enable_slot(struct hotplug_slot *hotplug_slot)
 {
+	/* mis-use enable_slot for rescanning of the pci bus */
+	pci_rescan();
 	return -ENODEV;
 }
 
+/* find the hotplug_slot for the pci_dev */
+static struct hotplug_slot *get_slot_from_dev(struct pci_dev *dev)
+{
+	struct dummy_slot *dslot;
+
+	list_for_each_entry(dslot, &slot_list, node) {
+		if (dslot->dev == dev)
+			return dslot->slot;
+	}
+	return NULL;
+}
+
+
 static int disable_slot(struct hotplug_slot *slot)
 {
 	struct dummy_slot *dslot;
+	struct hotplug_slot *hslot;
+	struct pci_dev *dev;
+	int func;
 
 	if (!slot)
 		return -ENODEV;
@@ -185,6 +294,23 @@
 		err("Can't remove PCI devices with other PCI devices behind it yet.\n");
 		return -ENODEV;
 	}
+	/* search for subfunctions and disable them first */
+	if (!(dslot->dev->devfn & 7)) {
+		for (func = 1; func < 8; func++) {
+			dev = pci_find_slot(dslot->dev->bus->number,
+					dslot->dev->devfn + func);
+			if (dev) {
+				hslot = get_slot_from_dev(dev);
+				if (hslot)
+					disable_slot(hslot);
+				else {
+					err("Hotplug slot not found for subfunction of PCI device\n");
+					return -ENODEV;
+				}
+			} else
+				dbg("No device in slot found\n");
+		}
+	}
 
 	/* remove the device from the pci core */
 	pci_remove_bus_device(dslot->dev);
@@ -227,6 +353,6 @@
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
 
diff -Nru a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
--- a/drivers/pci/hotplug/ibmphp_core.c	2004-12-24 13:37:34 -08:00
+++ b/drivers/pci/hotplug/ibmphp_core.c	2004-12-24 13:37:34 -08:00
@@ -51,7 +51,7 @@
 int ibmphp_debug;
 
 static int debug;
-MODULE_PARM (debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC (debug, "Debugging mode enabled or not");
 MODULE_LICENSE ("GPL");
 MODULE_DESCRIPTION (DRIVER_DESC);
@@ -838,8 +838,11 @@
 	int rc;
 	u8 speed;
 	u8 cmd = 0x0;
-	struct pci_dev *dev = NULL;
 	int retval;
+	static struct pci_device_id ciobx[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 0x0101) },
+	        { },
+	};	
 
 	debug ("%s - entry slot # %d\n", __FUNCTION__, slot_cur->number);
 	if (SET_BUS_STATUS (slot_cur->ctrl) && is_bus_empty (slot_cur)) {
@@ -886,8 +889,7 @@
 				break;
 			case BUS_SPEED_133:
 				/* This is to take care of the bug in CIOBX chip */
-				while ((dev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS,
-							      0x0101, dev)) != NULL)
+				if (pci_dev_present(ciobx))
 					ibmphp_hpc_writeslot (slot_cur, HPC_BUS_100PCIXMODE);
 				cmd = HPC_BUS_133PCIXMODE;
 				break;
diff -Nru a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
--- a/drivers/pci/hotplug/ibmphp_ebda.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/pci/hotplug/ibmphp_ebda.c	2004-12-24 13:36:19 -08:00
@@ -63,7 +63,7 @@
 static LIST_HEAD (rio_lo_head);
 static LIST_HEAD (opt_vg_head);
 static LIST_HEAD (opt_lo_head);
-static void *io_mem;
+static void __iomem *io_mem;
 
 /* Local functions */
 static int ebda_rsrc_controller (void);
@@ -1246,7 +1246,7 @@
 	list_for_each (tmp, &ebda_hpc_head) {
 		ctrl = list_entry (tmp, struct controller, ebda_hpc_list);
 		if (ctrl->ctlr_type == 1) {
-			rc = pci_module_init (&ibmphp_driver);
+			rc = pci_register_driver(&ibmphp_driver);
 			break;
 		}
 	}
diff -Nru a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
--- a/drivers/pci/hotplug/ibmphp_hpc.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/pci/hotplug/ibmphp_hpc.c	2004-12-24 13:36:31 -08:00
@@ -108,8 +108,8 @@
 //----------------------------------------------------------------------------
 // local function prototypes
 //----------------------------------------------------------------------------
-static u8 i2c_ctrl_read (struct controller *, void *, u8);
-static u8 i2c_ctrl_write (struct controller *, void *, u8, u8);
+static u8 i2c_ctrl_read (struct controller *, void __iomem *, u8);
+static u8 i2c_ctrl_write (struct controller *, void __iomem *, u8, u8);
 static u8 hpc_writecmdtoindex (u8, u8);
 static u8 hpc_readcmdtoindex (u8, u8);
 static void get_hpc_access (void);
@@ -118,7 +118,7 @@
 static int process_changeinstatus (struct slot *, struct slot *);
 static int process_changeinlatch (u8, u8, struct controller *);
 static int hpc_poll_thread (void *);
-static int hpc_wait_ctlr_notworking (int, struct controller *, void *, u8 *);
+static int hpc_wait_ctlr_notworking (int, struct controller *, void __iomem *, u8 *);
 //----------------------------------------------------------------------------
 
 
@@ -147,11 +147,11 @@
 * Action:  read from HPC over I2C
 *
 *---------------------------------------------------------------------*/
-static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void *WPGBbar, u8 index)
+static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index)
 {
 	u8 status;
 	int i;
-	void *wpg_addr;		// base addr + offset
+	void __iomem *wpg_addr;	// base addr + offset
 	unsigned long wpg_data;	// data to/from WPG LOHI format
 	unsigned long ultemp;
 	unsigned long data;	// actual data HILO format
@@ -255,10 +255,10 @@
 *
 * Return   0 or error codes
 *---------------------------------------------------------------------*/
-static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void *WPGBbar, u8 index, u8 cmd)
+static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index, u8 cmd)
 {
 	u8 rc;
-	void *wpg_addr;		// base addr + offset
+	void __iomem *wpg_addr;	// base addr + offset
 	unsigned long wpg_data;	// data to/from WPG LOHI format 
 	unsigned long ultemp;
 	unsigned long data;	// actual data HILO format
@@ -399,7 +399,7 @@
 	return rc;
 }
 
-static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset)
+static u8 ctrl_read (struct controller *ctlr, void __iomem *base, u8 offset)
 {
 	u8 rc;
 	switch (ctlr->ctlr_type) {
@@ -419,7 +419,7 @@
 	return rc;
 }
 
-static u8 ctrl_write (struct controller *ctlr, void *base, u8 offset, u8 data)
+static u8 ctrl_write (struct controller *ctlr, void __iomem *base, u8 offset, u8 data)
 {
 	u8 rc = 0;
 	switch (ctlr->ctlr_type) {
@@ -536,7 +536,7 @@
 *---------------------------------------------------------------------*/
 int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus)
 {
-	void *wpg_bbar = NULL;
+	void __iomem *wpg_bbar = NULL;
 	struct controller *ctlr_ptr;
 	struct list_head *pslotlist;
 	u8 index, status;
@@ -660,7 +660,7 @@
 	
 	// remove physical to logical address mapping
 	if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4))
-		iounmap (wpg_bbar);	
+		iounmap (wpg_bbar);
 	
 	free_hpc_access ();
 
@@ -675,7 +675,7 @@
 *---------------------------------------------------------------------*/
 int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
 {
-	void *wpg_bbar = NULL;
+	void __iomem *wpg_bbar = NULL;
 	struct controller *ctlr_ptr;
 	u8 index, status;
 	int busindex;
@@ -764,7 +764,7 @@
 
 	// remove physical to logical address mapping
 	if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4))
-		iounmap (wpg_bbar);	
+		iounmap (wpg_bbar);
 	free_hpc_access ();
 
 	debug_polling ("%s - Exit rc[%d]\n", __FUNCTION__, rc);
@@ -1130,7 +1130,7 @@
 * Return   0, HPC_ERROR
 * Value:
 *---------------------------------------------------------------------*/
-static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, void *wpg_bbar,
+static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, void __iomem *wpg_bbar,
 				    u8 * pstatus)
 {
 	int rc = 0;
diff -Nru a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
--- a/drivers/pci/hotplug/pci_hotplug_core.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/pci/hotplug/pci_hotplug_core.c	2004-12-24 13:37:18 -08:00
@@ -568,7 +568,7 @@
 	if ((slot->info == NULL) || (slot->ops == NULL))
 		return -EINVAL;
 
-	kobject_set_name(&slot->kobj, slot->name);
+	kobject_set_name(&slot->kobj, "%s", slot->name);
 	kobj_set_kset_s(slot, pci_hotplug_slots_subsys);
 
 	/* this can fail if we have already registered a slot with the same name */
diff -Nru a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
--- a/drivers/pci/hotplug/pciehp.h	2004-12-24 13:37:02 -08:00
+++ b/drivers/pci/hotplug/pciehp.h	2004-12-24 13:37:02 -08:00
@@ -31,6 +31,7 @@
 
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/delay.h>
 #include <asm/semaphore.h>
 #include <asm/io.h>		
 #include "pci_hotplug.h"
@@ -126,8 +127,7 @@
 	enum pci_bus_speed speed;
 	u32 first_slot;		/* First physical slot number */  /* PCIE only has 1 slot */
 	u8 slot_bus;		/* Bus where the slots handled by this controller sit */
-	u8 push_flag;
-	u16 ctlrcap;
+	u8 ctrlcap;
 	u16 vendor_id;
 };
 
@@ -179,6 +179,21 @@
 
 #define DISABLE_CARD			1
 
+/* Field definitions in Slot Capabilities Register */
+#define ATTN_BUTTN_PRSN	0x00000001
+#define	PWR_CTRL_PRSN	0x00000002
+#define MRL_SENS_PRSN	0x00000004
+#define ATTN_LED_PRSN	0x00000008
+#define PWR_LED_PRSN	0x00000010
+#define HP_SUPR_RM_SUP	0x00000020
+
+#define ATTN_BUTTN(cap)		(cap & ATTN_BUTTN_PRSN)
+#define POWER_CTRL(cap)		(cap & PWR_CTRL_PRSN)
+#define MRL_SENS(cap)		(cap & MRL_SENS_PRSN)
+#define ATTN_LED(cap)		(cap & ATTN_LED_PRSN)
+#define PWR_LED(cap)		(cap & PWR_LED_PRSN) 
+#define HP_SUPR_RM(cap)		(cap & HP_SUPR_RM_SUP)
+
 /*
  * error Messages
  */
@@ -192,9 +207,6 @@
 #define msg_button_cancel	"PCI slot #%d - action canceled due to button press.\n"
 #define msg_button_ignore	"PCI slot #%d - button press ignored.  (action in progress...)\n"
 
-/* sysfs function for the hotplug controller info */
-extern void pciehp_create_ctrl_files	(struct controller *ctrl);
-
 /* controller functions */
 extern int	pciehprm_find_available_resources	(struct controller *ctrl);
 extern int	pciehp_event_start_thread	(void);
@@ -261,14 +273,12 @@
 
 	dbg("%s : start\n", __FUNCTION__);
 	add_wait_queue(&ctrl->queue, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
-	if (!pciehp_poll_mode) {
+	if (!pciehp_poll_mode)
 		/* Sleep for up to 1 second */
-		schedule_timeout(1*HZ);
-	} else
-		schedule_timeout(2.5*HZ);
+		msleep_interruptible(1000);
+	else
+		msleep_interruptible(2500);
 	
-	set_current_state(TASK_RUNNING);
 	remove_wait_queue(&ctrl->queue, &wait);
 	if (signal_pending(current))
 		retval =  -EINTR;
@@ -313,8 +323,7 @@
 		int *num_ctlr_slots,
 		int *first_device_num,
 		int *physical_slot_num,
-		int *updown,
-		int *flags);
+		u8 *ctrlcap);
 
 struct hpc_ops {
 	int	(*power_on_slot)	(struct slot *slot);
diff -Nru a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
--- a/drivers/pci/hotplug/pciehp_core.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/pci/hotplug/pciehp_core.c	2004-12-24 13:37:43 -08:00
@@ -204,11 +204,10 @@
 	int num_ctlr_slots;		/* Not needed; PCI Express has 1 slot per port*/
 	int first_device_num;		/* Not needed */
 	int physical_slot_num;
-	int updown;			/* Not needed */
+	u8 ctrlcap;			
 	int rc;
-	int flags;			/* Not needed */
 
-	rc = pcie_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &updown, &flags);
+	rc = pcie_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &ctrlcap);
 	if (rc) {
 		err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device);
 		return (-1);
@@ -217,10 +216,10 @@
 	ctrl->num_slots = num_ctlr_slots;	/* PCI Express has 1 slot per port */
 	ctrl->slot_device_offset = first_device_num;
 	ctrl->first_slot = physical_slot_num;
-	ctrl->slot_num_inc = updown; 	/* Not needed */		/* either -1 or 1 */
+	ctrl->ctrlcap = ctrlcap; 	
 
-	dbg("%s: bus(0x%x) num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n",
-		__FUNCTION__, ctrl->slot_bus, num_ctlr_slots, first_device_num, physical_slot_num, updown, 
+	dbg("%s: bus(0x%x) num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) ctrlcap(%x) for b:d (%x:%x)\n",
+		__FUNCTION__, ctrl->slot_bus, num_ctlr_slots, first_device_num, physical_slot_num, ctrlcap, 
 		ctrl->bus, ctrl->device);
 
 	return (0);
@@ -237,7 +236,9 @@
 	dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
 
 	hotplug_slot->info->attention_status = status;
-	slot->hpc_ops->set_attention_status(slot, status);
+	
+	if (ATTN_LED(slot->ctrl->ctrlcap)) 
+		slot->hpc_ops->set_attention_status(slot, status);
 
 	return 0;
 }
@@ -451,7 +452,8 @@
 
 	t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
 	dbg("%s: adpater value %x\n", __FUNCTION__, value);
-	if (!value) {
+	
+	if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
 		rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
 		if (rc) {
 			/* Done with exclusive hardware access */
@@ -602,8 +604,8 @@
 
 	retval = pciehprm_init(PCI);
 	if (!retval) {
-		retval = pci_module_init(&pcie_driver);
-		dbg("pci_module_init = %d\n", retval);
+		retval = pci_register_driver(&pcie_driver);
+		dbg("pci_register_driver = %d\n", retval);
 		info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
 	}
 
diff -Nru a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
--- a/drivers/pci/hotplug/pciehp_ctrl.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/pci/hotplug/pciehp_ctrl.c	2004-12-24 13:36:18 -08:00
@@ -38,6 +38,7 @@
 #include <linux/wait.h>
 #include <linux/smp_lock.h>
 #include <linux/pci.h>
+#include "../pci.h"
 #include "pciehp.h"
 #include "pciehprm.h"
 
@@ -51,6 +52,7 @@
 static struct semaphore event_exit;		/* guard ensure thread has exited before calling it quits */
 static int event_finished;
 static unsigned long pushbutton_pending;	/* = 0 */
+static unsigned long surprise_rm_pending;	/* = 0 */
 
 u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
 {
@@ -1063,25 +1065,29 @@
 	/* Wait for exclusive access to hardware */
 	down(&ctrl->crit_sect);
 
-	/* turn off slot, turn on Amber LED, turn off Green LED */
-	if (pslot->hpc_ops->power_off_slot(pslot)) {   
-		err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__);
-		up(&ctrl->crit_sect);
-		return;
+	/* turn off slot, turn on Amber LED, turn off Green LED if supported*/
+	if (POWER_CTRL(ctrl->ctrlcap)) {
+		if (pslot->hpc_ops->power_off_slot(pslot)) {   
+			err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__);
+			up(&ctrl->crit_sect);
+			return;
+		}
+		wait_for_ctrl_irq (ctrl);
 	}
-	wait_for_ctrl_irq (ctrl);
 
-	pslot->hpc_ops->green_led_off(pslot);   
-	
-	wait_for_ctrl_irq (ctrl);
+	if (PWR_LED(ctrl->ctrlcap)) {
+		pslot->hpc_ops->green_led_off(pslot);   
+		wait_for_ctrl_irq (ctrl);
+	}
 
-	/* turn on Amber LED */
-	if (pslot->hpc_ops->set_attention_status(pslot, 1)) {   
-		err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__);
-		up(&ctrl->crit_sect);
-		return;
+	if (ATTN_LED(ctrl->ctrlcap)) { 
+		if (pslot->hpc_ops->set_attention_status(pslot, 1)) {   
+			err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__);
+			up(&ctrl->crit_sect);
+			return;
+		}
+		wait_for_ctrl_irq (ctrl);
 	}
-	wait_for_ctrl_irq (ctrl);
 
 	/* Done with exclusive hardware access */
 	up(&ctrl->crit_sect);
@@ -1112,20 +1118,24 @@
 	/* Wait for exclusive access to hardware */
 	down(&ctrl->crit_sect);
 
-	/* Power on slot */
-	rc = p_slot->hpc_ops->power_on_slot(p_slot);
-	if (rc) {
-		up(&ctrl->crit_sect);
-		return -1;
-	}
+	if (POWER_CTRL(ctrl->ctrlcap)) {
+		/* Power on slot */
+		rc = p_slot->hpc_ops->power_on_slot(p_slot);
+		if (rc) {
+			up(&ctrl->crit_sect);
+			return -1;
+		}
 
-	/* Wait for the command to complete */
-	wait_for_ctrl_irq (ctrl);
+		/* Wait for the command to complete */
+		wait_for_ctrl_irq (ctrl);
+	}
 	
-	p_slot->hpc_ops->green_led_blink(p_slot);
+	if (PWR_LED(ctrl->ctrlcap)) {
+		p_slot->hpc_ops->green_led_blink(p_slot);
 			
-	/* Wait for the command to complete */
-	wait_for_ctrl_irq (ctrl);
+		/* Wait for the command to complete */
+		wait_for_ctrl_irq (ctrl);
+	}
 
 	/* Done with exclusive hardware access */
 	up(&ctrl->crit_sect);
@@ -1212,18 +1222,24 @@
 			}
 		} while (new_func);
 
-		/* Wait for exclusive access to hardware */
-		down(&ctrl->crit_sect);
-
-		p_slot->hpc_ops->green_led_on(p_slot);
-
-		/* Wait for the command to complete */
-		wait_for_ctrl_irq (ctrl);
-
-
-		/* Done with exclusive hardware access */
-		up(&ctrl->crit_sect);
-
+ 		/* 
+ 		 * Some PCI Express root ports require fixup after hot-plug operation.
+ 		 */
+ 		if (pcie_mch_quirk)
+ 			pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
+ 
+  		if (PWR_LED(ctrl->ctrlcap)) {
+  			/* Wait for exclusive access to hardware */
+  			down(&ctrl->crit_sect);
+   
+  			p_slot->hpc_ops->green_led_on(p_slot);
+  
+  			/* Wait for the command to complete */
+  			wait_for_ctrl_irq (ctrl);
+  	
+  			/* Done with exclusive hardware access */
+  			up(&ctrl->crit_sect);
+  		}
 	} else {
 		set_slot_off(ctrl, p_slot);
 		return -1;
@@ -1289,21 +1305,25 @@
 	/* Wait for exclusive access to hardware */
 	down(&ctrl->crit_sect);
 
-	/* power off slot */
-	rc = p_slot->hpc_ops->power_off_slot(p_slot);
-	if (rc) {
-		err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
-		up(&ctrl->crit_sect);
-		return rc;
+	if (POWER_CTRL(ctrl->ctrlcap)) {
+		/* power off slot */
+		rc = p_slot->hpc_ops->power_off_slot(p_slot);
+		if (rc) {
+			err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
+			up(&ctrl->crit_sect);
+			return rc;
+		}
+		/* Wait for the command to complete */
+		wait_for_ctrl_irq (ctrl);
 	}
-	/* Wait for the command to complete */
-	wait_for_ctrl_irq (ctrl);
 
-	/* turn off Green LED */
-	p_slot->hpc_ops->green_led_off(p_slot);
+	if (PWR_LED(ctrl->ctrlcap)) {
+		/* turn off Green LED */
+		p_slot->hpc_ops->green_led_off(p_slot);
 	
-	/* Wait for the command to complete */
-	wait_for_ctrl_irq (ctrl);
+		/* Wait for the command to complete */
+		wait_for_ctrl_irq (ctrl);
+	}
 
 	/* Done with exclusive hardware access */
 	up(&ctrl->crit_sect);
@@ -1368,7 +1388,6 @@
 	up(&event_semaphore);
 }
 
-
 /**
  * pciehp_pushbutton_thread
  *
@@ -1399,7 +1418,7 @@
 		p_slot->state = POWERON_STATE;
 		dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
 
-		if (pciehp_enable_slot(p_slot)) {
+		if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
 			/* Wait for exclusive access to hardware */
 			down(&p_slot->ctrl->crit_sect);
 
@@ -1417,6 +1436,55 @@
 	return;
 }
 
+/**
+ * pciehp_surprise_rm_thread
+ *
+ * Scheduled procedure to handle blocking stuff for the surprise removal
+ * Handles all pending events and exits.
+ *
+ */
+static void pciehp_surprise_rm_thread(unsigned long slot)
+{
+	struct slot *p_slot = (struct slot *) slot;
+	u8 getstatus;
+	
+	surprise_rm_pending = 0;
+
+	if (!p_slot) {
+		dbg("%s: Error! slot NULL\n", __FUNCTION__);
+		return;
+	}
+
+	p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
+	if (!getstatus) {
+		p_slot->state = POWEROFF_STATE;
+		dbg("In removing board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
+
+		pciehp_disable_slot(p_slot);
+		p_slot->state = STATIC_STATE;
+	} else {
+		p_slot->state = POWERON_STATE;
+		dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
+
+		if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
+			/* Wait for exclusive access to hardware */
+			down(&p_slot->ctrl->crit_sect);
+
+			p_slot->hpc_ops->green_led_off(p_slot);
+
+			/* Wait for the command to complete */
+			wait_for_ctrl_irq (p_slot->ctrl);
+
+			/* Done with exclusive hardware access */
+			up(&p_slot->ctrl->crit_sect);
+		}
+		p_slot->state = STATIC_STATE;
+	}
+
+	return;
+}
+
+
 
 /* this is the main worker thread */
 static int event_thread(void* data)
@@ -1436,6 +1504,8 @@
 		/* Do stuff here */
 		if (pushbutton_pending)
 			pciehp_pushbutton_thread(pushbutton_pending);
+		else if (surprise_rm_pending)
+			pciehp_surprise_rm_thread(surprise_rm_pending);
 		else
 			for (ctrl = pciehp_ctrl_list; ctrl; ctrl=ctrl->next)
 				interrupt_event_handler(ctrl);
@@ -1528,16 +1598,18 @@
 					case BLINKINGOFF_STATE:
 						/* Wait for exclusive access to hardware */
 						down(&ctrl->crit_sect);
-
-						p_slot->hpc_ops->green_led_on(p_slot);
-						/* Wait for the command to complete */
-						wait_for_ctrl_irq (ctrl);
-
-						p_slot->hpc_ops->set_attention_status(p_slot, 0);
-
-						/* Wait for the command to complete */
-						wait_for_ctrl_irq (ctrl);
-
+						
+						if (PWR_LED(ctrl->ctrlcap)) {
+							p_slot->hpc_ops->green_led_on(p_slot);
+							/* Wait for the command to complete */
+							wait_for_ctrl_irq (ctrl);
+						}
+						if (ATTN_LED(ctrl->ctrlcap)) {
+							p_slot->hpc_ops->set_attention_status(p_slot, 0);
+
+							/* Wait for the command to complete */
+							wait_for_ctrl_irq (ctrl);
+						}
 						/* Done with exclusive hardware access */
 						up(&ctrl->crit_sect);
 						break;
@@ -1545,14 +1617,16 @@
 						/* Wait for exclusive access to hardware */
 						down(&ctrl->crit_sect);
 
-						p_slot->hpc_ops->green_led_off(p_slot);
-						/* Wait for the command to complete */
-						wait_for_ctrl_irq (ctrl);
-
-						p_slot->hpc_ops->set_attention_status(p_slot, 0);
-						/* Wait for the command to complete */
-						wait_for_ctrl_irq (ctrl);
-
+						if (PWR_LED(ctrl->ctrlcap)) {
+							p_slot->hpc_ops->green_led_off(p_slot);
+							/* Wait for the command to complete */
+							wait_for_ctrl_irq (ctrl);
+						}
+						if (ATTN_LED(ctrl->ctrlcap)){
+							p_slot->hpc_ops->set_attention_status(p_slot, 0);
+							/* Wait for the command to complete */
+							wait_for_ctrl_irq (ctrl);
+						}
 						/* Done with exclusive hardware access */
 						up(&ctrl->crit_sect);
 
@@ -1566,59 +1640,83 @@
 				}
 				/* ***********Button Pressed (No action on 1st press...) */
 				else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) {
-					dbg("Button pressed\n");
-
-					p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
-					if (getstatus) {
-						/* slot is on */
-						dbg("slot is on\n");
-						p_slot->state = BLINKINGOFF_STATE;
-						info(msg_button_off, p_slot->number);
-					} else {
-						/* slot is off */
-						dbg("slot is off\n");
-						p_slot->state = BLINKINGON_STATE;
-						info(msg_button_on, p_slot->number);
-					}
-
-					/* Wait for exclusive access to hardware */
-					down(&ctrl->crit_sect);
-
-					/* blink green LED and turn off amber */
-					p_slot->hpc_ops->green_led_blink(p_slot);
-					/* Wait for the command to complete */
-					wait_for_ctrl_irq (ctrl);
 					
-					p_slot->hpc_ops->set_attention_status(p_slot, 0);
+					if (ATTN_BUTTN(ctrl->ctrlcap)) {
+						dbg("Button pressed\n");
+						p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
+						if (getstatus) {
+							/* slot is on */
+							dbg("slot is on\n");
+							p_slot->state = BLINKINGOFF_STATE;
+							info(msg_button_off, p_slot->number);
+						} else {
+							/* slot is off */
+							dbg("slot is off\n");
+							p_slot->state = BLINKINGON_STATE;
+							info(msg_button_on, p_slot->number);
+						}
 
-					/* Wait for the command to complete */
-					wait_for_ctrl_irq (ctrl);
+						/* Wait for exclusive access to hardware */
+						down(&ctrl->crit_sect);
+
+						/* blink green LED and turn off amber */
+						if (PWR_LED(ctrl->ctrlcap)) {
+							p_slot->hpc_ops->green_led_blink(p_slot);
+							/* Wait for the command to complete */
+							wait_for_ctrl_irq (ctrl);
+						}
+
+						if (ATTN_LED(ctrl->ctrlcap)) {
+							p_slot->hpc_ops->set_attention_status(p_slot, 0);
+
+							/* Wait for the command to complete */
+							wait_for_ctrl_irq (ctrl);
+						}
 
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
+						/* Done with exclusive hardware access */
+						up(&ctrl->crit_sect);
 
-					init_timer(&p_slot->task_event);
-					p_slot->task_event.expires = jiffies + 5 * HZ;   /* 5 second delay */
-					p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
-					p_slot->task_event.data = (unsigned long) p_slot;
+						init_timer(&p_slot->task_event);
+						p_slot->task_event.expires = jiffies + 5 * HZ;   /* 5 second delay */
+						p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
+						p_slot->task_event.data = (unsigned long) p_slot;
 
-					dbg("add_timer p_slot = %p\n", (void *) p_slot);
-					add_timer(&p_slot->task_event);
+						dbg("add_timer p_slot = %p\n", (void *) p_slot);
+						add_timer(&p_slot->task_event);
+					}
 				}
 				/***********POWER FAULT********************/
 				else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
-					dbg("power fault\n");
-					/* Wait for exclusive access to hardware */
-					down(&ctrl->crit_sect);
+					if (POWER_CTRL(ctrl->ctrlcap)) {
+						dbg("power fault\n");
+						/* Wait for exclusive access to hardware */
+						down(&ctrl->crit_sect);
 
-					p_slot->hpc_ops->set_attention_status(p_slot, 1);
-					wait_for_ctrl_irq (ctrl);
-						
-					p_slot->hpc_ops->green_led_off(p_slot);
-					wait_for_ctrl_irq (ctrl);
+						if (ATTN_LED(ctrl->ctrlcap)) {
+							p_slot->hpc_ops->set_attention_status(p_slot, 1);
+							wait_for_ctrl_irq (ctrl);
+						}
+
+						if (PWR_LED(ctrl->ctrlcap)) {
+							p_slot->hpc_ops->green_led_off(p_slot);
+							wait_for_ctrl_irq (ctrl);
+						}
 
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
+						/* Done with exclusive hardware access */
+						up(&ctrl->crit_sect);
+					}
+				}
+				/***********SURPRISE REMOVAL********************/
+				else if ((ctrl->event_queue[loop].event_type == INT_PRESENCE_ON) || 
+					(ctrl->event_queue[loop].event_type == INT_PRESENCE_OFF)) {
+					if (HP_SUPR_RM(ctrl->ctrlcap)) {
+						dbg("Surprise Removal\n");
+						if (p_slot) {
+							surprise_rm_pending = (unsigned long) p_slot;
+							up(&event_semaphore);
+							update_slot_info(p_slot);
+						}
+					}
 				} else {
 					/* refresh notification */
 					if (p_slot)
@@ -1648,25 +1746,29 @@
 
 	/* Check to see if (latch closed, card present, power off) */
 	down(&p_slot->ctrl->crit_sect);
+
 	rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
 		info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
 		up(&p_slot->ctrl->crit_sect);
 		return 1;
 	}
-	
-	rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
-	if (rc || getstatus) {
-		info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
-		up(&p_slot->ctrl->crit_sect);
-		return 1;
+	if (MRL_SENS(p_slot->ctrl->ctrlcap)) {	
+		rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
+		if (rc || getstatus) {
+			info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
+			up(&p_slot->ctrl->crit_sect);
+			return 1;
+		}
 	}
 	
-	rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
-	if (rc || getstatus) {
-		info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
-		up(&p_slot->ctrl->crit_sect);
-		return 1;
+	if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {	
+		rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
+		if (rc || getstatus) {
+			info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
+			up(&p_slot->ctrl->crit_sect);
+			return 1;
+		}
 	}
 	up(&p_slot->ctrl->crit_sect);
 
@@ -1735,26 +1837,33 @@
 	/* Check to see if (latch closed, card present, power on) */
 	down(&p_slot->ctrl->crit_sect);
 
-	ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
-	if (ret || !getstatus) {
-		info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
-		up(&p_slot->ctrl->crit_sect);
-		return 1;
+	if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) {	
+		ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
+		if (ret || !getstatus) {
+			info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
+			up(&p_slot->ctrl->crit_sect);
+			return 1;
+		}
 	}
 
-	ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
-	if (ret || getstatus) {
-		info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
-		up(&p_slot->ctrl->crit_sect);
-		return 1;
+	if (MRL_SENS(p_slot->ctrl->ctrlcap)) {	
+		ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
+		if (ret || getstatus) {
+			info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
+			up(&p_slot->ctrl->crit_sect);
+			return 1;
+		}
 	}
 
-	ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
-	if (ret || !getstatus) {
-		info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
-		up(&p_slot->ctrl->crit_sect);
-		return 1;
+	if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {	
+		ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
+		if (ret || !getstatus) {
+			info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
+			up(&p_slot->ctrl->crit_sect);
+			return 1;
+		}
 	}
+
 	up(&p_slot->ctrl->crit_sect);
 
 	func = pciehp_slot_find(p_slot->bus, p_slot->device, index++);
diff -Nru a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
--- a/drivers/pci/hotplug/pciehp_hpc.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/pci/hotplug/pciehp_hpc.c	2004-12-24 13:37:00 -08:00
@@ -182,7 +182,7 @@
 #define MRL_SENS_PRSN	0x00000004
 #define ATTN_LED_PRSN	0x00000008
 #define PWR_LED_PRSN	0x00000010
-#define HP_SUPR_RM	0x00000020
+#define HP_SUPR_RM_SUP	0x00000020
 #define HP_CAP		0x00000040
 #define SLOT_PWR_VALUE	0x000003F8
 #define SLOT_PWR_LIMIT	0x00000C00
@@ -237,8 +237,8 @@
 static spinlock_t hpc_event_lock;
 
 DEFINE_DBG_BUFFER		/* Debug string buffer for entire HPC defined here */
-static struct php_ctlr_state_s *php_ctlr_list_head;	/* HPC state linked list */
-static int ctlr_seq_num;	/* Controller sequence # */
+static struct php_ctlr_state_s *php_ctlr_list_head = 0;	/* HPC state linked list */
+static int ctlr_seq_num = 0;	/* Controller sequence # */
 static spinlock_t list_lock;
 
 static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs);
@@ -691,8 +691,7 @@
 	int *num_ctlr_slots,	/* number of slots in this HPC; only 1 in PCIE  */	
 	int *first_device_num,	/* PCI dev num of the first slot in this PCIE	*/
 	int *physical_slot_num,	/* phy slot num of the first slot in this PCIE	*/
-	int *updown,		/* physical_slot_num increament: 1 or -1	*/
-	int *flags)
+	u8 *ctrlcap)
 {
 	struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
 	u32 slot_cap;
@@ -716,8 +715,9 @@
 	}
 	
 	*physical_slot_num = slot_cap >> 19;
-
-	*updown = -1;
+	dbg("%s: PSN %d \n", __FUNCTION__, *physical_slot_num);
+	
+	*ctrlcap = slot_cap & 0x0000007f;
 
 	DBG_LEAVE_ROUTINE 
 	return 0;
@@ -741,6 +741,8 @@
 		if (php_ctlr->irq) {
 			free_irq(php_ctlr->irq, ctrl);
 			php_ctlr->irq = 0;
+			if (!pcie_mch_quirk) 
+				pci_disable_msi(php_ctlr->pci_dev);
 		}
 	}
 	if (php_ctlr->pci_dev) 
@@ -1259,7 +1261,7 @@
 	static int first = 1;
 	u16 temp_word;
 	u16 cap_reg;
-	u16 intr_enable;
+	u16 intr_enable = 0;
 	u32 slot_cap;
 	int cap_base, saved_cap_base;
 	u16 slot_status, slot_ctrl;
@@ -1345,6 +1347,9 @@
 	info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, 
 		pdev->subsystem_vendor, pdev->subsystem_device);
 
+	if (pci_enable_device(pdev))
+		goto abort_free_ctlr;
+	
 	init_MUTEX(&ctrl->crit_sect);
 	/* setup wait queue */
 	init_waitqueue_head(&ctrl->queue);
@@ -1402,8 +1407,8 @@
 		start_int_poll_timer( php_ctlr, 10 );   /* start with 10 second delay */
 	} else {
 		/* Installs the interrupt handler */
-		dbg("%s: pciehp_msi_quirk = %x\n", __FUNCTION__, pciehp_msi_quirk);
-		if (!pciehp_msi_quirk) {
+		dbg("%s: pcie_mch_quirk = %x\n", __FUNCTION__, pcie_mch_quirk);
+		if (!pcie_mch_quirk) {
 			rc = pci_enable_msi(pdev);
 			if (rc) {
 				info("Can't get msi for the hotplug controller\n");
@@ -1412,6 +1417,7 @@
 			} else 
 				php_ctlr->irq = pdev->irq;
 		}
+
 		rc = request_irq(php_ctlr->irq, pcie_isr, SA_SHIRQ, MY_NAME, (void *) ctrl);
 		dbg("%s: request_irq %d for hpc%d (returns %d)\n", __FUNCTION__, php_ctlr->irq, ctlr_seq_num, rc);
 		if (rc) {
@@ -1426,9 +1432,18 @@
 		goto abort_free_ctlr;
 	}
 	dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word);
+	dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap);
+
+	intr_enable = intr_enable | PRSN_DETECT_ENABLE;
 
-	intr_enable = ATTN_BUTTN_ENABLE | PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE |
-					PRSN_DETECT_ENABLE;
+	if (ATTN_BUTTN(slot_cap))
+		intr_enable = intr_enable | ATTN_BUTTN_ENABLE;
+	
+	if (POWER_CTRL(slot_cap))
+		intr_enable = intr_enable | PWR_FAULT_DETECT_ENABLE;
+	
+	if (MRL_SENS(slot_cap))
+		intr_enable = intr_enable | MRL_DETECT_ENABLE;
 
 	temp_word = (temp_word & ~intr_enable) | intr_enable; 
 
diff -Nru a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
--- a/drivers/pci/hotplug/pciehp_pci.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/pci/hotplug/pciehp_pci.c	2004-12-24 13:37:18 -08:00
@@ -82,9 +82,11 @@
 {
 	int rc = 0;
 	int j;
+	struct pci_bus *pbus;
 
 	dbg("%s: bus/dev/func = %x/%x/%x\n", __FUNCTION__, func->bus,
 				func->device, func->function);
+	pbus = func->pci_dev->bus;
 
 	for (j=0; j<8 ; j++) {
 		struct pci_dev* temp = pci_find_slot(func->bus,
@@ -93,6 +95,12 @@
 			pci_remove_bus_device(temp);
 		}
 	}
+	/* 
+	 * Some PCI Express root ports require fixup after hot-plug operation.
+	 */
+	if (pcie_mch_quirk) 
+		pci_fixup_device(pci_fixup_final, pbus->self);
+	
 	return rc;
 }
 
diff -Nru a/drivers/pci/hotplug/pciehp_sysfs.c b/drivers/pci/hotplug/pciehp_sysfs.c
--- a/drivers/pci/hotplug/pciehp_sysfs.c	2004-12-24 13:37:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,143 +0,0 @@
-/*
- * PCI Express Hot Plug Controller Driver
- *
- * Copyright (C) 1995,2001 Compaq Computer Corporation
- * Copyright (C) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (C) 2001 IBM Corp.
- *
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT.  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.
- *
- * Send feedback to <greg@kroah.com>
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/proc_fs.h>
-#include <linux/workqueue.h>
-#include <linux/pci.h>
-#include "pciehp.h"
-
-
-/* A few routines that create sysfs entries for the hot plug controller */
-
-static ssize_t show_ctrl (struct device *dev, char *buf)
-{
-	struct pci_dev *pci_dev;
-	struct controller *ctrl;
-	char * out = buf;
-	int index;
-	struct pci_resource *res;
-
-	pci_dev = container_of (dev, struct pci_dev, dev);
-	ctrl = pci_get_drvdata(pci_dev);
-
-	out += sprintf(buf, "Free resources: memory\n");
-	index = 11;
-	res = ctrl->mem_head;
-	while (res && index--) {
-		out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
-		res = res->next;
-	}
-	out += sprintf(out, "Free resources: prefetchable memory\n");
-	index = 11;
-	res = ctrl->p_mem_head;
-	while (res && index--) {
-		out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
-		res = res->next;
-	}
-	out += sprintf(out, "Free resources: IO\n");
-	index = 11;
-	res = ctrl->io_head;
-	while (res && index--) {
-		out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
-		res = res->next;
-	}
-	out += sprintf(out, "Free resources: bus numbers\n");
-	index = 11;
-	res = ctrl->bus_head;
-	while (res && index--) {
-		out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
-		res = res->next;
-	}
-
-	return out - buf;
-}
-static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
-
-static ssize_t show_dev (struct device *dev, char *buf)
-{
-	struct pci_dev *pci_dev;
-	struct controller *ctrl;
-	char * out = buf;
-	int index;
-	struct pci_resource *res;
-	struct pci_func *new_slot;
-	struct slot *slot;
-
-	pci_dev = container_of (dev, struct pci_dev, dev);
-	ctrl = pci_get_drvdata(pci_dev);
-
-	slot=ctrl->slot;
-
-	while (slot) {
-		new_slot = pciehp_slot_find(slot->bus, slot->device, 0);
-		if (!new_slot)
-			break;
-		out += sprintf(out, "assigned resources: memory\n");
-		index = 11;
-		res = new_slot->mem_head;
-		while (res && index--) {
-			out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
-			res = res->next;
-		}
-		out += sprintf(out, "assigned resources: prefetchable memory\n");
-		index = 11;
-		res = new_slot->p_mem_head;
-		while (res && index--) {
-			out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
-			res = res->next;
-		}
-		out += sprintf(out, "assigned resources: IO\n");
-		index = 11;
-		res = new_slot->io_head;
-		while (res && index--) {
-			out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
-			res = res->next;
-		}
-		out += sprintf(out, "assigned resources: bus numbers\n");
-		index = 11;
-		res = new_slot->bus_head;
-		while (res && index--) {
-			out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
-			res = res->next;
-		}
-		slot=slot->next;
-	}
-
-	return out - buf;
-}
-static DEVICE_ATTR (dev, S_IRUGO, show_dev, NULL);
-
-void pciehp_create_ctrl_files (struct controller *ctrl)
-{
-	device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl);
-	device_create_file (&ctrl->pci_dev->dev, &dev_attr_dev);
-}
diff -Nru a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c
--- a/drivers/pci/hotplug/pciehprm_acpi.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/pci/hotplug/pciehprm_acpi.c	2004-12-24 13:37:19 -08:00
@@ -32,6 +32,7 @@
 #include <linux/init.h>
 #include <linux/acpi.h>
 #include <linux/efi.h>
+#include <linux/pci-acpi.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #ifdef	CONFIG_IA64
@@ -50,6 +51,14 @@
 #define	METHOD_NAME__HPP	"_HPP"
 #define	METHOD_NAME_OSHP	"OSHP"
 
+/* Status code for running acpi method to gain native control */
+#define NC_NOT_RUN	0
+#define OSC_NOT_EXIST	1
+#define OSC_RUN_FAILED	2
+#define OSHP_NOT_EXIST	3
+#define OSHP_RUN_FAILED	4
+#define NC_RUN_SUCCESS	5
+
 #define	PHP_RES_BUS		0xA0
 #define	PHP_RES_IO		0xA1
 #define	PHP_RES_MEM		0xA2
@@ -125,7 +134,9 @@
 }
 
 static void acpi_get__hpp ( struct acpi_bridge	*ab);
-static void acpi_run_oshp ( struct acpi_bridge	*ab);
+static int acpi_run_oshp ( struct acpi_bridge	*ab);
+static int osc_run_status = NC_NOT_RUN;
+static int oshp_run_status = NC_NOT_RUN;
 
 static int acpi_add_slot_to_php_slots(
 	struct acpi_bridge	*ab,
@@ -158,8 +169,9 @@
 	ab->scanned += 1;
 	if (!ab->_hpp)
 		acpi_get__hpp(ab);
-
-	acpi_run_oshp(ab);
+	
+	if (osc_run_status == OSC_NOT_EXIST)
+		oshp_run_status = acpi_run_oshp(ab);
 
 	if (sun != samesun) {
 		info("acpi_pciehprm:   Slot sun(%x) at s:b:d:f=0x%02x:%02x:%02x:%02x\n", 
@@ -238,7 +250,7 @@
 	kfree(ret_buf.pointer);
 }
 
-static void acpi_run_oshp ( struct acpi_bridge	*ab)
+static int acpi_run_oshp ( struct acpi_bridge	*ab)
 {
 	acpi_status		status;
 	u8			*path_name = acpi_path_name(ab->handle);
@@ -248,9 +260,13 @@
 	status = acpi_evaluate_object(ab->handle, METHOD_NAME_OSHP, NULL, &ret_buf);
 	if (ACPI_FAILURE(status)) {
 		err("acpi_pciehprm:%s OSHP fails=0x%x\n", path_name, status);
-	} else
+		oshp_run_status = (status == AE_NOT_FOUND) ? OSHP_NOT_EXIST : OSHP_RUN_FAILED;
+	} else {
+		oshp_run_status = NC_RUN_SUCCESS;
 		dbg("acpi_pciehprm:%s OSHP passes =0x%x\n", path_name, status);
-	return;
+		dbg("acpi_pciehprm:%s oshp_run_status =0x%x\n", path_name, oshp_run_status);
+	}
+	return oshp_run_status;
 }
 
 static acpi_status acpi_evaluate_crs(
@@ -1056,6 +1072,16 @@
 		kfree(ab);
 		return NULL;
 	}
+
+	status = pci_osc_control_set (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL); 
+	if (ACPI_FAILURE(status)) {
+		err("%s: status %x\n", __FUNCTION__, status);
+		osc_run_status = (status == AE_NOT_FOUND) ? OSC_NOT_EXIST : OSC_RUN_FAILED;
+	} else {
+		osc_run_status = NC_RUN_SUCCESS;
+	}	
+	dbg("%s: osc_run_status %x\n", __FUNCTION__, osc_run_status);
+	
 	build_a_bridge(ab, ab);
 
 	return ab;
@@ -1140,6 +1166,11 @@
 	rc = pciehprm_acpi_scan_pci();
 	if (rc)
 		return rc;
+
+	if ((oshp_run_status != NC_RUN_SUCCESS) && (osc_run_status != NC_RUN_SUCCESS)) {
+		err("Fails to gain control of native hot-plug\n");
+		rc = -ENODEV;
+	}
 
 	dbg("pciehprm ACPI init %s\n", (rc)?"fail":"success");
 	return rc;
diff -Nru a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
--- a/drivers/pci/hotplug/rpadlpar_core.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/pci/hotplug/rpadlpar_core.c	2004-12-24 13:37:00 -08:00
@@ -25,6 +25,10 @@
 
 static DECLARE_MUTEX(rpadlpar_sem);
 
+#define NODE_TYPE_VIO  1
+#define NODE_TYPE_SLOT 2
+#define NODE_TYPE_PHB  3
+
 static struct device_node *find_php_slot_vio_node(char *drc_name)
 {
 	struct device_node *child;
@@ -44,21 +48,50 @@
 	return NULL;
 }
 
-static struct device_node *find_php_slot_pci_node(char *drc_name)
+/* Find dlpar-capable pci node that contains the specified name and type */
+static struct device_node *find_php_slot_pci_node(char *drc_name,
+						  char *drc_type)
 {
 	struct device_node *np = NULL;
 	char *name;
+	char *type;
+	int rc;
 
-	while ((np = of_find_node_by_type(np, "pci")))
-		if (is_hotplug_capable(np)) {
-			name = rpaphp_get_drc_name(np);
-			if (name && (!strcmp(drc_name, name)))
+	while ((np = of_find_node_by_type(np, "pci"))) {
+		rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL);
+		if (rc == 0)
+			if (!strcmp(drc_name, name) && !strcmp(drc_type, type))
 				break;
-		}
+	}
 
 	return np;
 }
 
+static struct device_node *find_newly_added_node(char *drc_name, int *node_type)
+{
+	struct device_node *dn;
+
+	dn = find_php_slot_pci_node(drc_name, "SLOT");
+	if (dn) {
+		*node_type = NODE_TYPE_SLOT;
+		return dn;
+	}
+
+	dn = find_php_slot_pci_node(drc_name, "PHB");
+	if (dn) {
+		*node_type = NODE_TYPE_PHB;
+		return dn;
+	}
+
+	dn = find_php_slot_vio_node(drc_name);
+	if (dn) {
+		*node_type = NODE_TYPE_VIO;
+		return dn;
+	}
+
+	return NULL;
+}
+
 static struct slot *find_slot(char *drc_name)
 {
 	struct list_head *tmp, *n;
@@ -125,12 +158,8 @@
 
 	dn->bussubno = child->number;
 
-	/* ioremap() for child bus */
-	if (remap_bus_range(child)) {
-		printk(KERN_ERR "%s: could not ioremap() child bus\n",
-			__FUNCTION__);
-		return 1;
-	}
+	/* ioremap() for child bus, which may or may not succeed */
+	remap_bus_range(child);
 
 	return 0;
 }
@@ -205,6 +234,71 @@
 	return 0;
 }
 
+static int dlpar_remove_root_bus(struct pci_controller *phb)
+{
+	struct pci_bus *phb_bus;
+	int rc;
+
+	phb_bus = phb->bus;
+	if (!(list_empty(&phb_bus->children) &&
+	      list_empty(&phb_bus->devices))) {
+		return -EBUSY;
+	}
+
+	rc = pcibios_remove_root_bus(phb);
+	if (rc)
+		return -EIO;
+
+	device_unregister(phb_bus->bridge);
+	pci_remove_bus(phb_bus);
+
+	return 0;
+}
+
+static int dlpar_remove_phb(struct slot *slot)
+{
+	struct pci_controller *phb;
+	struct device_node *dn;
+	int rc = 0;
+
+	dn = slot->dn;
+	if (!dn) {
+		printk(KERN_ERR "%s: unexpected NULL slot device node\n",
+				__FUNCTION__);
+		return -EIO;
+	}
+
+	phb = dn->phb;
+	if (!phb) {
+		printk(KERN_ERR "%s: unexpected NULL phb pointer\n",
+				__FUNCTION__);
+		return -EIO;
+	}
+
+	if (rpaphp_remove_slot(slot)) {
+		printk(KERN_ERR "%s: unable to remove hotplug slot %s\n",
+			__FUNCTION__, slot->location);
+		return -EIO;
+	}
+
+	rc = dlpar_remove_root_bus(phb);
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
+static int dlpar_add_phb(struct device_node *dn)
+{
+	struct pci_controller *phb;
+
+	phb = init_phb_dynamic(dn);
+	if (!phb)
+		return 1;
+
+	return 0;
+}
+
 /**
  * dlpar_add_slot - DLPAR add an I/O Slot
  * @drc_name: drc-name of newly added slot
@@ -220,7 +314,8 @@
  */
 int dlpar_add_slot(char *drc_name)
 {
-	struct device_node *dn;
+	struct device_node *dn = NULL;
+	int node_type;
 	int rc = 0;
 
 	if (down_interruptible(&rpadlpar_sem))
@@ -232,18 +327,27 @@
 		goto exit;
 	}
 
-	dn = find_php_slot_vio_node(drc_name);
+	dn = find_newly_added_node(drc_name, &node_type);
 	if (!dn) {
-		dn = find_php_slot_pci_node(drc_name);
-		if (dn)
+		rc = -ENODEV;
+		goto exit;
+	}
+
+	switch (node_type) {
+		case NODE_TYPE_VIO:
+			/* Just add hotplug slot */
+			break;
+		case NODE_TYPE_SLOT:
 			rc = dlpar_add_pci_slot(drc_name, dn);
-		else {
-			rc = -ENODEV;
-			goto exit;
-		}
+			break;
+		case NODE_TYPE_PHB:
+			rc = dlpar_add_phb(dn);
+			break;
+		default:
+			printk("%s: unexpected node type\n", __FUNCTION__);
+			return -EIO;
 	}
 
-	/* Add hotplug slot for new VIOA or PCI */
 	if (!rc && rpaphp_add_slot(dn)) {
 		printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
 			__FUNCTION__, drc_name);
@@ -337,7 +441,8 @@
 		return -ERESTARTSYS;
 
 	if (!find_php_slot_vio_node(drc_name) &&
-	    !find_php_slot_pci_node(drc_name)) {
+	    !find_php_slot_pci_node(drc_name, "SLOT") &&
+	    !find_php_slot_pci_node(drc_name, "PHB")) {
 		rc = -ENODEV;
 		goto exit;
 	}
@@ -348,17 +453,18 @@
 		goto exit;
 	}
 	
-	switch (slot->dev_type) {
-		case PCI_DEV:
-			rc = dlpar_remove_pci_slot(slot, drc_name);
-			break;
-
-		case VIO_DEV:
-			rc = dlpar_remove_vio_slot(slot, drc_name);
-			break;
+	if (slot->type == PHB) {
+		rc = dlpar_remove_phb(slot);
+	} else {
+		switch (slot->dev_type) {
+			case PCI_DEV:
+				rc = dlpar_remove_pci_slot(slot, drc_name);
+				break;
 
-		default:
-			rc = -EIO;
+			case VIO_DEV:
+				rc = dlpar_remove_vio_slot(slot, drc_name);
+				break;
+		}
 	}
 exit:
 	up(&rpadlpar_sem);
diff -Nru a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
--- a/drivers/pci/hotplug/rpaphp.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/pci/hotplug/rpaphp.h	2004-12-24 13:36:47 -08:00
@@ -30,6 +30,7 @@
 #include <linux/pci.h>
 #include "pci_hotplug.h"
 
+#define	PHB     2
 #define	HOTPLUG	1
 #define	EMBEDDED 0
 
@@ -129,7 +130,8 @@
 /* rpaphp_core.c */
 extern int rpaphp_add_slot(struct device_node *dn);
 extern int rpaphp_remove_slot(struct slot *slot);
-extern char *rpaphp_get_drc_name(struct device_node *dn);
+extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
+		char **drc_name, char **drc_type, int *drc_power_domain);
 
 /* rpaphp_vio.c */
 extern int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 * value);
diff -Nru a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
--- a/drivers/pci/hotplug/rpaphp_core.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/pci/hotplug/rpaphp_core.c	2004-12-24 13:37:29 -08:00
@@ -63,7 +63,6 @@
 static int get_attention_status(struct hotplug_slot *slot, u8 * value);
 static int get_adapter_status(struct hotplug_slot *slot, u8 * value);
 static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value);
-static int rpaphp_disable_slot(struct pci_dev *dev);
 
 struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
 	.owner = THIS_MODULE,
@@ -212,32 +211,91 @@
 	return deregister_slot(slot);
 }
 
-static int get_dn_properties(struct device_node *dn, int **indexes, int **names, 
-	int **types, int **power_domains)
+static int get_children_props(struct device_node *dn, int **drc_indexes,
+		int **drc_names, int **drc_types, int **drc_power_domains)
 {
-	*indexes = (int *) get_property(dn, "ibm,drc-indexes", NULL);
+	int *indexes, *names;
+	int *types, *domains;
 
-	/* &names[1] contains NULL terminated slot names */
-	*names = (int *) get_property(dn, "ibm,drc-names", NULL);
+	indexes = (int *) get_property(dn, "ibm,drc-indexes", NULL);
+	names = (int *) get_property(dn, "ibm,drc-names", NULL);
+	types = (int *) get_property(dn, "ibm,drc-types", NULL);
+	domains = (int *) get_property(dn, "ibm,drc-power-domains", NULL);
+
+	if (!indexes || !names || !types || !domains) {
+		/* Slot does not have dynamically-removable children */
+		return 1;
+	}
+	if (drc_indexes)
+		*drc_indexes = indexes;
+	if (drc_names)
+		/* &drc_names[1] contains NULL terminated slot names */
+		*drc_names = names;
+	if (drc_types)
+		/* &drc_types[1] contains NULL terminated slot types */
+		*drc_types = types;
+	if (drc_power_domains)
+		*drc_power_domains = domains;
 
-	/* &types[1] contains NULL terminated slot types */
-	*types = (int *) get_property(dn, "ibm,drc-types", NULL);
-
-	/* power_domains[1...n] are the slot power domains */
-	*power_domains = (int *) get_property(dn, "ibm,drc-power-domains", NULL);
-	
-	if (*indexes && *names && *types && *power_domains) 
-		return (1);
-	
-	return (0);
+	return 0;
+}
+
+/* To get the DRC props describing the current node, first obtain it's
+ * my-drc-index property.  Next obtain the DRC list from it's parent.  Use
+ * the my-drc-index for correlation, and obtain the requested properties.
+ */
+int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
+		char **drc_name, char **drc_type, int *drc_power_domain)
+{
+	int *indexes, *names;
+	int *types, *domains;
+	unsigned int *my_index;
+	char *name_tmp, *type_tmp;
+	int i, rc;
+
+	my_index = (int *) get_property(dn, "ibm,my-drc-index", NULL);
+	if (!my_index) {
+		/* Node isn't DLPAR/hotplug capable */
+		return 1;
+	}
+
+	rc = get_children_props(dn->parent, &indexes, &names, &types, &domains);
+	if (rc) {
+		return 1;
+	}
+
+	name_tmp = (char *) &names[1];
+	type_tmp = (char *) &types[1];
+
+	/* Iterate through parent properties, looking for my-drc-index */
+	for (i = 0; i < indexes[0]; i++) {
+		if ((unsigned int) indexes[i + 1] == *my_index) {
+			if (drc_name)
+                		*drc_name = name_tmp;
+			if (drc_type)
+				*drc_type = type_tmp;
+			if (drc_index)
+				*drc_index = *my_index;
+			if (drc_power_domain)
+				*drc_power_domain = domains[i+1];
+			return 0;
+		}
+		name_tmp += (strlen(name_tmp) + 1);
+		type_tmp += (strlen(type_tmp) + 1);
+	}
+
+	return 1;
 }
 
 static int is_php_dn(struct device_node *dn, int **indexes, int **names, int **types,
 	  int **power_domains)
 {
+	int rc;
+
 	if (!is_hotplug_capable(dn))
 		return (0);
-	if (!get_dn_properties(dn, indexes, names, types, power_domains))
+	rc = get_children_props(dn, indexes, names, types, power_domains);
+	if (rc)
 		return (0);
 	return (1);
 }
@@ -245,8 +303,7 @@
 static int is_dr_dn(struct device_node *dn, int **indexes, int **names, int **types,
 	  int **power_domains, int **my_drc_index)
 {
-	if (!is_hotplug_capable(dn))
-		return (0);
+	int rc;
 
 	*my_drc_index = (int *) get_property(dn, "ibm,my-drc-index", NULL);
 	if(!*my_drc_index) 		
@@ -255,7 +312,9 @@
 	if (!dn->parent)
 		return (0);
 
-	return get_dn_properties(dn->parent, indexes, names, types, power_domains);
+	rc = get_children_props(dn->parent, indexes, names, types,
+				power_domains);
+	return (rc == 0);
 }
 
 static inline int is_vdevice_root(struct device_node *dn)
@@ -263,34 +322,10 @@
 	return !strcmp(dn->name, "vdevice");
 }
 
-char *rpaphp_get_drc_name(struct device_node *dn)
+int is_dlpar_type(const char *type_str)
 {
-	char *name, *ptr = NULL;
-	int *drc_names, *drc_indexes, i;
-	struct device_node *parent = dn->parent;	
-	u32 *my_drc_index;
-
-	if (!parent)
-		return NULL;
-
-	my_drc_index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL);
-	if (!my_drc_index)
-		return NULL;	
-
-	drc_names = (int *) get_property(parent, "ibm,drc-names", NULL);
-	drc_indexes = (int *) get_property(parent, "ibm,drc-indexes", NULL);
-	if (!drc_names || !drc_indexes)
-		return NULL;
-
-	name = (char *) &drc_names[1];
-	for (i = 0; i < drc_indexes[0]; i++, name += (strlen(name) + 1)) {
-		if (drc_indexes[i + 1] == *my_drc_index) {
-			ptr = (char *) name;
-			break;
-		}
-	}
-
-	return ptr;
+	/* Only register DLPAR-capable nodes of drc-type PHB or SLOT */
+	return (!strcmp(type_str, "PHB") || !strcmp(type_str, "SLOT"));
 }
 
 /****************************************************************
@@ -329,15 +364,18 @@
 		for (i = 0; i < indexes[0]; i++,
 	     		name += (strlen(name) + 1), type += (strlen(type) + 1)) {
 
-			if ( slot_type == HOTPLUG || 
-				(slot_type == EMBEDDED && indexes[i + 1] == my_drc_index[0])) {
-				
+			if (slot_type == HOTPLUG ||
+			    (slot_type == EMBEDDED &&
+			     indexes[i + 1] == my_drc_index[0] &&
+			     is_dlpar_type(type))) {
 				if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name,
 					       power_domains[i + 1]))) {
 					retval = -ENOMEM;
 					goto exit;
 				}
-				if (slot_type == EMBEDDED)
+				if (!strcmp(type, "PHB"))
+					slot->type = PHB;
+				else if (slot_type == EMBEDDED)
 					slot->type = EMBEDDED;
 				else
 					slot->type = simple_strtoul(type, NULL, 10);
@@ -442,11 +480,6 @@
 	return retval;
 }
 
-static int rpaphp_disable_slot(struct pci_dev *dev)
-{
-	return disable_slot(rpaphp_find_hotplug_slot(dev));
-}
-
 static int disable_slot(struct hotplug_slot *hotplug_slot)
 {
 	int retval = -EINVAL;
@@ -483,4 +516,4 @@
 EXPORT_SYMBOL_GPL(rpaphp_add_slot);
 EXPORT_SYMBOL_GPL(rpaphp_remove_slot);
 EXPORT_SYMBOL_GPL(rpaphp_slot_head);
-EXPORT_SYMBOL_GPL(rpaphp_get_drc_name);
+EXPORT_SYMBOL_GPL(rpaphp_get_drc_props);
diff -Nru a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
--- a/drivers/pci/hotplug/rpaphp_pci.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/pci/hotplug/rpaphp_pci.c	2004-12-24 13:36:16 -08:00
@@ -31,18 +31,17 @@
 
 struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn)
 {
-	struct pci_dev *retval_dev = NULL, *dev = NULL;
+	struct pci_dev *dev = NULL;
 	char bus_id[BUS_ID_SIZE];
 
-	sprintf(bus_id, "%04x:%02x:%02x.%d",dn->phb->global_number,
+	sprintf(bus_id, "%04x:%02x:%02x.%d", dn->phb->global_number,
 		dn->busno, PCI_SLOT(dn->devfn), PCI_FUNC(dn->devfn));
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		if (!strcmp(pci_name(dev), bus_id)) {
-			retval_dev = dev;
 			break;
 		}
 	}
-	return retval_dev;
+	return dev;
 }
 
 EXPORT_SYMBOL_GPL(rpaphp_find_pci_dev);
@@ -117,33 +116,40 @@
 int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value)
 {
 	int state, rc;
-	*value = NOT_VALID;
+ 	struct device_node *child_dn;
+ 	struct pci_dev *child_dev = NULL;
 
+	*value = NOT_VALID;
 	rc = rpaphp_get_sensor_state(slot, &state);
 	if (rc)
 		goto exit;
-	if (state == PRESENT) {
+
+ 	if ((state == EMPTY) || (slot->type == PHB)) {
+ 		dbg("slot is empty\n");
+ 		*value = EMPTY;
+ 	}
+ 	else if (state == PRESENT) {
 		if (!is_init)
 			/* at run-time slot->state can be changed by */
 			/* config/unconfig adapter */
 			*value = slot->state;
 		else {
-			if (!slot->dn->child)
+ 			child_dn = slot->dn->child;
+ 			if (child_dn)
+ 				child_dev = rpaphp_find_pci_dev(child_dn);
+
+ 			if (child_dev)
+ 				*value = CONFIGURED;
+ 			else if (!child_dn)
 				dbg("%s: %s is not valid OFDT node\n",
 				    __FUNCTION__, slot->dn->full_name);
-			else if (rpaphp_find_pci_dev(slot->dn->child))
-				*value = CONFIGURED;
 			else {
 				err("%s: can't find pdev of adapter in slot[%s]\n", 
 					__FUNCTION__, slot->dn->full_name);
 				*value = NOT_CONFIGURED;
 			}
 		}
-	} else if (state == EMPTY) {
-		dbg("slot is empty\n");
-		*value = state;
 	}
-
 exit:
 	return rc;
 }
@@ -408,15 +414,52 @@
 	return 0;
 }
 
+static int set_phb_slot_name(struct slot *slot)
+{
+	struct device_node *dn;
+	struct pci_controller *phb;
+	struct pci_bus *bus;
+
+	dn = slot->dn;
+	if (!dn) {
+		return 1;
+	}
+	phb = dn->phb;
+	if (!phb) {
+		return 1;
+	}
+	bus = phb->bus;
+	if (!bus) {
+		return 1;
+	}
+
+	sprintf(slot->name, "%04x:%02x:%02x.%x", pci_domain_nr(bus),
+			bus->number, 0, 0);
+	return 0;
+}
+
 static int setup_pci_slot(struct slot *slot)
 {
-	slot->bridge = rpaphp_find_bridge_pdev(slot);
-	if (!slot->bridge) {	/* slot being added doesn't have pci_dev yet */
-		err("%s: no pci_dev for bridge dn %s\n", __FUNCTION__, slot->name);
-		goto exit_rc;
+	int rc;
+
+	if (slot->type == PHB) {
+		rc = set_phb_slot_name(slot);
+		if (rc) {
+			err("%s: failed to set phb slot name\n", __FUNCTION__);
+			goto exit_rc;
+		}
+	} else {
+		slot->bridge = rpaphp_find_bridge_pdev(slot);
+		if (!slot->bridge) {
+			/* slot being added doesn't have pci_dev yet */
+			err("%s: no pci_dev for bridge dn %s\n",
+					__FUNCTION__, slot->name);
+			goto exit_rc;
+		}
+		dbg("%s set slot->name to %s\n",  __FUNCTION__,
+				pci_name(slot->bridge));
+		strcpy(slot->name, pci_name(slot->bridge));
 	}
-	dbg("%s set slot->name to %s\n",  __FUNCTION__, pci_name(slot->bridge));
-	strcpy(slot->name, pci_name(slot->bridge));
 
 	/* find slot's pci_dev if it's not empty */
 	if (slot->hotplug_slot->info->adapter_status == EMPTY) {
@@ -470,10 +513,10 @@
 	int rc = 1;
 
 	slot->dev_type = PCI_DEV;
-	if (slot->type == EMBEDDED)
-		slot->removable = EMBEDDED;
+	if ((slot->type == EMBEDDED) || (slot->type == PHB))
+		slot->removable = 0;
 	else
-		slot->removable = HOTPLUG;
+		slot->removable = 1;
 	INIT_LIST_HEAD(&slot->dev.pci_funcs);
 	if (setup_pci_hotplug_slot_info(slot))
 		goto exit_rc;
diff -Nru a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
--- a/drivers/pci/hotplug/rpaphp_slot.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/pci/hotplug/rpaphp_slot.c	2004-12-24 13:36:55 -08:00
@@ -246,12 +246,7 @@
 {
 	int rc = 0, level;
 	
-	if (slot->type == EMBEDDED) {
-		dbg("%s set to POWER_ON for EMBEDDED slot %s\n",
-			__FUNCTION__, slot->location);
-		*value = POWER_ON;
-	}
-	else {
+	if (slot->type == HOTPLUG) {
 		rc = rtas_get_power_level(slot->power_domain, &level);
 		if (!rc) {
 			dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n",
@@ -260,6 +255,10 @@
 		} else
 			err("failed to get power-level for slot(%s), rc=0x%x\n",
 				slot->location, rc);
+	} else {
+		dbg("%s report POWER_ON for EMBEDDED or PHB slot %s\n",
+			__FUNCTION__, slot->location);
+		*value = (u8) POWER_ON;
 	}
 
 	return rc;
diff -Nru a/drivers/pci/hotplug/rpaphp_vio.c b/drivers/pci/hotplug/rpaphp_vio.c
--- a/drivers/pci/hotplug/rpaphp_vio.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/pci/hotplug/rpaphp_vio.c	2004-12-24 13:37:02 -08:00
@@ -74,8 +74,8 @@
 	int rc = 1;
 	struct slot *slot = NULL;
 	
-	name = rpaphp_get_drc_name(dn);
-	if (!name)
+	rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL);
+	if (rc)
 		goto exit_rc;
 	index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL);
 	if (!index)
diff -Nru a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
--- a/drivers/pci/hotplug/shpchp.h	2004-12-24 13:37:04 -08:00
+++ b/drivers/pci/hotplug/shpchp.h	2004-12-24 13:37:04 -08:00
@@ -31,6 +31,7 @@
 
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/delay.h>
 #include <asm/semaphore.h>
 #include <asm/io.h>		
 #include "pci_hotplug.h"
@@ -311,7 +312,7 @@
 	php_intr_callback_t presence_change_callback;
 	php_intr_callback_t power_fault_callback;
 	void *callback_instance_id;
-	void *creg;				/* Ptr to controller register space */
+	void __iomem *creg;			/* Ptr to controller register space */
 };
 /* Inline functions */
 
@@ -381,16 +382,14 @@
 	dbg("%s : start\n",__FUNCTION__);
 
 	add_wait_queue(&ctrl->queue, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
 
 	if (!shpchp_poll_mode) {
 		/* Sleep for up to 1 second */
-		schedule_timeout(1*HZ);
+		msleep_interruptible(1000);
 	} else {
 		/* Sleep for up to 2 seconds */
-		schedule_timeout(2*HZ);
+		msleep_interruptible(2000);
 	}
-	set_current_state(TASK_RUNNING);
 	remove_wait_queue(&ctrl->queue, &wait);
 	if (signal_pending(current))
 		retval =  -EINTR;
diff -Nru a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
--- a/drivers/pci/hotplug/shpchp_core.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/pci/hotplug/shpchp_core.c	2004-12-24 13:36:16 -08:00
@@ -599,8 +599,8 @@
 
 	retval = shpchprm_init(PCI);
 	if (!retval) {
-		retval = pci_module_init(&shpc_driver);
-		dbg("%s: pci_module_init = %d\n", __FUNCTION__, retval);
+		retval = pci_register_driver(&shpc_driver);
+		dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval);
 		info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
 	}
 
diff -Nru a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
--- a/drivers/pci/hotplug/shpchp_ctrl.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/pci/hotplug/shpchp_ctrl.c	2004-12-24 13:37:29 -08:00
@@ -1050,7 +1050,64 @@
 /* The following routines constitute the bulk of the 
    hotplug controller logic
  */
+static u32 change_bus_speed(struct controller *ctrl, struct slot *p_slot, enum pci_bus_speed speed)
+{ 
+	u32 rc = 0;
 
+	dbg("%s: change to speed %d\n", __FUNCTION__, speed);
+	down(&ctrl->crit_sect);
+	if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) {
+		err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
+		up(&ctrl->crit_sect);
+		return WRONG_BUS_FREQUENCY;
+	}
+	wait_for_ctrl_irq (ctrl);
+		
+	if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
+		err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
+			  __FUNCTION__);
+		err("%s: Error code (%d)\n", __FUNCTION__, rc);
+		up(&ctrl->crit_sect);
+		return WRONG_BUS_FREQUENCY;
+	}
+	up(&ctrl->crit_sect);
+	return rc;
+}
+
+static u32 fix_bus_speed(struct controller *ctrl, struct slot *pslot, u8 flag, 
+enum pci_bus_speed asp, enum pci_bus_speed bsp, enum pci_bus_speed msp)
+{ 
+	u32 rc = 0;
+	
+	if (flag != 0) { /* Other slots on the same bus are occupied */
+		if ( asp < bsp ) {
+			err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bsp, asp);
+			return WRONG_BUS_FREQUENCY;
+		}
+	} else {
+		/* Other slots on the same bus are empty */
+		if (msp == bsp) {
+		/* if adapter_speed >= bus_speed, do nothing */
+			if (asp < bsp) {
+				/* 
+				* Try to lower bus speed to accommodate the adapter if other slots 
+				* on the same controller are empty
+				*/
+				if ((rc = change_bus_speed(ctrl, pslot, asp)))
+					return rc;
+			} 
+		} else {
+			if (asp < msp) {
+				if ((rc = change_bus_speed(ctrl, pslot, asp)))
+					return rc;
+			} else {
+				if ((rc = change_bus_speed(ctrl, pslot, msp)))
+					return rc;
+			}
+		}
+	}
+	return rc;
+}
 
 /**
  * board_added - Called after a board has been added to the system.
@@ -1061,14 +1118,13 @@
  */
 static u32 board_added(struct pci_func * func, struct controller * ctrl)
 {
-	u8 hp_slot, slot;
+	u8 hp_slot;
 	u8 slots_not_empty = 0;
 	int index;
 	u32 temp_register = 0xFFFFFFFF;
 	u32 retval, rc = 0;
 	struct pci_func *new_func = NULL;
-	struct pci_func *t_func = NULL;
-	struct slot *p_slot, *pslot;
+	struct slot *p_slot;
 	struct resource_lists res_lists;
 	enum pci_bus_speed adapter_speed, bus_speed, max_bus_speed;
 	u8 pi, mode;
@@ -1101,6 +1157,40 @@
 		return -1;
 	}
 
+	
+	if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
+		if (slots_not_empty)
+			return WRONG_BUS_FREQUENCY;
+		
+		if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) {
+			err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
+			up(&ctrl->crit_sect);
+			return WRONG_BUS_FREQUENCY;
+		}
+		wait_for_ctrl_irq (ctrl);
+		
+		if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
+			err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
+				  __FUNCTION__);
+			err("%s: Error code (%d)\n", __FUNCTION__, rc);
+			up(&ctrl->crit_sect);
+			return WRONG_BUS_FREQUENCY;
+		}
+		/* turn on board, blink green LED, turn off Amber LED */
+		if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
+			err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
+			up(&ctrl->crit_sect);
+			return rc;
+		}
+		wait_for_ctrl_irq (ctrl);
+
+		if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
+			err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
+			up(&ctrl->crit_sect);
+			return rc;  
+		}
+	}
+ 
 	rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &adapter_speed);
 	/* 0 = PCI 33Mhz, 1 = PCI 66 Mhz, 2 = PCI-X 66 PA, 4 = PCI-X 66 ECC, */
 	/* 5 = PCI-X 133 PA, 7 = PCI-X 133 ECC,  0xa = PCI-X 133 Mhz 266, */
@@ -1132,258 +1222,72 @@
 	/* Done with exclusive hardware access */
 	up(&ctrl->crit_sect);
 
-	rc  = p_slot->hpc_ops->get_prog_int(p_slot, &pi);
-	if (rc) {
+	if ((rc  = p_slot->hpc_ops->get_prog_int(p_slot, &pi))) {
 		err("%s: Can't get controller programming interface, set it to 1\n", __FUNCTION__);
 		pi = 1;
 	}
+
+	/* Check if there are other slots or devices on the same bus */
+	if (!list_empty(&ctrl->pci_dev->subordinate->devices))
+		slots_not_empty = 1;
+
+	dbg("%s: slots_not_empty %d, pi %d\n", __FUNCTION__, 
+		slots_not_empty, pi);
+	dbg("adapter_speed %d, bus_speed %d, max_bus_speed %d\n", 
+		adapter_speed, bus_speed, max_bus_speed);
+
 	if (pi == 2) {
-		for ( slot = 0; slot < ctrl->num_slots; slot++) {
-			if (slot != hp_slot) {
-				pslot = shpchp_find_slot(ctrl, slot + ctrl->slot_device_offset);
-				t_func = shpchp_slot_find(pslot->bus, pslot->device, 0);
-				slots_not_empty |= t_func->is_a_board;
-			}
+		dbg("%s: In PI = %d\n", __FUNCTION__, pi);
+		if ((rc = p_slot->hpc_ops->get_mode1_ECC_cap(p_slot, &mode))) {
+			err("%s: Can't get Mode1_ECC, set mode to 0\n", __FUNCTION__);
+			mode = 0;
 		}
 
 		switch (adapter_speed) {
-		case PCI_SPEED_133MHz_PCIX_533:	
+		case PCI_SPEED_133MHz_PCIX_533:
 		case PCI_SPEED_133MHz_PCIX_266:
-			if ((( bus_speed < 0xa ) || (bus_speed < 0xd)) && (max_bus_speed > bus_speed) &&
-				((max_bus_speed <= 0xa) || (max_bus_speed <= 0xd)) && (!slots_not_empty)) {
-			
-				/* Wait for exclusive access to hardware */
-				down(&ctrl->crit_sect);
-
-				rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, max_bus_speed);
-				if (rc) {
-					err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);				
-					return WRONG_BUS_FREQUENCY;
-				}
-				
-				/* Wait for the command to complete */
-				wait_for_ctrl_irq (ctrl);
-		
-				rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-				if (rc) {
-					err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
-							  __FUNCTION__);
-					err("%s: Error code (%d)\n", __FUNCTION__, rc);
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);				
-					return WRONG_BUS_FREQUENCY;
-				}
-				/* Done with exclusive hardware access */
-				up(&ctrl->crit_sect);
-			}
-			break;
+			if ((bus_speed != adapter_speed) &&
+			   ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) 
+				return rc;
+			break;	
 		case PCI_SPEED_133MHz_PCIX_ECC:
 		case PCI_SPEED_133MHz_PCIX:
-
-			rc = p_slot->hpc_ops->get_mode1_ECC_cap(p_slot, &mode);
-
-			if (rc) {
-				err("%s: PI is 1 \n", __FUNCTION__);
-				return WRONG_BUS_FREQUENCY;
-			}
-
 			if (mode) { /* Bus - Mode 1 ECC */
-
-				if (bus_speed > 0x7)  {
-					err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
-					return WRONG_BUS_FREQUENCY;
-				}
-
-				if ((bus_speed < 0x7) && (max_bus_speed <= 0x7) &&
-					(bus_speed < max_bus_speed) && (!slots_not_empty)) {
-
-					/* Wait for exclusive access to hardware */
-					down(&ctrl->crit_sect);
-
-					rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, max_bus_speed);
-					if (rc) {
-						err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-						/* Done with exclusive hardware access */
-						up(&ctrl->crit_sect);				
-						return WRONG_BUS_FREQUENCY;
-					}
-				
-					/* Wait for the command to complete */
-					wait_for_ctrl_irq (ctrl);
-		
-					rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-					if (rc) {
-						err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
-							  __FUNCTION__);
-						err("%s: Error code (%d)\n", __FUNCTION__, rc);
-						/* Done with exclusive hardware access */
-						up(&ctrl->crit_sect);				
-						return WRONG_BUS_FREQUENCY;
-					}
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
-				}
+				if ((bus_speed != 0x7) &&
+				   ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) 
+					return rc;
 			} else {
-				if (bus_speed > 0x4) {
-					err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
-					return WRONG_BUS_FREQUENCY;
-				}
-
-				if ((bus_speed < 0x4) && (max_bus_speed <= 0x4) &&
-					(bus_speed < max_bus_speed) && (!slots_not_empty)) {
-
-					/* Wait for exclusive access to hardware */
-					down(&ctrl->crit_sect);
-
-					rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, max_bus_speed);
-					if (rc) {
-						err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-						/* Done with exclusive hardware access */
-						up(&ctrl->crit_sect);				
-						return WRONG_BUS_FREQUENCY;
-					}
-				
-					/* Wait for the command to complete */
-					wait_for_ctrl_irq (ctrl);
-		
-					rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-					if (rc) {
-						err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
-							  __FUNCTION__);
-						err("%s: Error code (%d)\n", __FUNCTION__, rc);
-						/* Done with exclusive hardware access */
-						up(&ctrl->crit_sect);				
-						return WRONG_BUS_FREQUENCY;
-					}
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
-				}
+				if ((bus_speed != 0x4) &&
+				   ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) 
+					return rc;
 			}
 			break;
 		case PCI_SPEED_66MHz_PCIX_ECC:
 		case PCI_SPEED_66MHz_PCIX:
-
-			rc = p_slot->hpc_ops->get_mode1_ECC_cap(p_slot, &mode);
-
-			if (rc) {
-				err("%s: PI is 1 \n", __FUNCTION__);
-				return WRONG_BUS_FREQUENCY;
-			}
-
 			if (mode) { /* Bus - Mode 1 ECC */
-
-				if (bus_speed > 0x5)  {
-					err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
-					return WRONG_BUS_FREQUENCY;
-				}
-
-				if ((bus_speed < 0x5) && (max_bus_speed <= 0x5) &&
-					(bus_speed < max_bus_speed) && (!slots_not_empty)) {
-
-					/* Wait for exclusive access to hardware */
-					down(&ctrl->crit_sect);
-
-					rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, max_bus_speed);
-					if (rc) {
-						err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-						/* Done with exclusive hardware access */
-						up(&ctrl->crit_sect);				
-						return WRONG_BUS_FREQUENCY;
-					}
-				
-					/* Wait for the command to complete */
-					wait_for_ctrl_irq (ctrl);
-		
-					rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-					if (rc) {
-						err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
-							  __FUNCTION__);
-						err("%s: Error code (%d)\n", __FUNCTION__, rc);
-						/* Done with exclusive hardware access */
-						up(&ctrl->crit_sect);				
-						return WRONG_BUS_FREQUENCY;
-					}
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
-				}
+				if ((bus_speed != 0x5) &&
+				   ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) 
+					return rc;
 			} else {
-				if (bus_speed > 0x2) {
-					err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
-					return WRONG_BUS_FREQUENCY;
-				}
-
-				if ((bus_speed < 0x2) && (max_bus_speed <= 0x2) &&
-					(bus_speed < max_bus_speed) && (!slots_not_empty)) {
-
-					/* Wait for exclusive access to hardware */
-					down(&ctrl->crit_sect);
-
-					rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, max_bus_speed);
-					if (rc) {
-						err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-						/* Done with exclusive hardware access */
-						up(&ctrl->crit_sect);				
-						return WRONG_BUS_FREQUENCY;
-					}
-				
-					/* Wait for the command to complete */
-					wait_for_ctrl_irq (ctrl);
-		
-					rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-					if (rc) {
-						err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
-							  __FUNCTION__);
-						err("%s: Error code (%d)\n", __FUNCTION__, rc);
-						/* Done with exclusive hardware access */
-						up(&ctrl->crit_sect);				
-						return WRONG_BUS_FREQUENCY;
-					}
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
-				}
+				if ((bus_speed != 0x2) &&
+				   ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) 
+					return rc;
 			}
 			break;
 		case PCI_SPEED_66MHz:
-			if (bus_speed > 0x1) {
-				err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
-				return WRONG_BUS_FREQUENCY;
-			}
-			if (bus_speed == 0x1)
-				;
-			if ((bus_speed == 0x0) && ( max_bus_speed == 0x1))  {
-				/* Wait for exclusive access to hardware */
-				down(&ctrl->crit_sect);
-
-				rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, max_bus_speed);
-				if (rc) {
-					err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);				
-					return WRONG_BUS_FREQUENCY;
-				}
-				
-				/* Wait for the command to complete */
-				wait_for_ctrl_irq (ctrl);
-		
-				rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-				if (rc) {
-					err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
-							  __FUNCTION__);
-					err("%s: Error code (%d)\n", __FUNCTION__, rc);
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);				
-					return WRONG_BUS_FREQUENCY;
-				}
-				/* Done with exclusive hardware access */
-				up(&ctrl->crit_sect);
-			}
+			if ((bus_speed != 0x1) &&
+			   ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) 
+				return rc;
 			break;	
 		case PCI_SPEED_33MHz:
 			if (bus_speed > 0x0) {
-				err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
-				return WRONG_BUS_FREQUENCY;
+				if (slots_not_empty == 0) {
+					if ((rc = change_bus_speed(ctrl, p_slot, adapter_speed)))
+						return rc;
+				} else {
+					err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
+					return WRONG_BUS_FREQUENCY;
+				}
 			}
 			break;
 		default:
@@ -1391,133 +1295,34 @@
 			return WRONG_BUS_FREQUENCY;
 		}
 	} else {
-		/* if adpater_speed == bus_speed, nothing to do here */
-		if (adapter_speed != bus_speed) {
-			for ( slot = 0; slot < ctrl->num_slots; slot++) {
-				if (slot != hp_slot) {
-					pslot = shpchp_find_slot(ctrl, slot + ctrl->slot_device_offset);
-					t_func = shpchp_slot_find(pslot->bus, pslot->device, 0);
-					slots_not_empty |= t_func->is_a_board;
-				}
-			}
-
-			if (slots_not_empty != 0) { /* Other slots on the same bus are occupied */
-				if ( adapter_speed < bus_speed ) {
-					err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
-					return WRONG_BUS_FREQUENCY;
-				}
-				/* Do nothing if adapter_speed >= bus_speed */
-			}
-		}
-			
-		if ((adapter_speed != bus_speed) && (slots_not_empty == 0))  {
-			/* Other slots on the same bus are empty */
-			
-			rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &max_bus_speed);
-			if (rc || max_bus_speed == PCI_SPEED_UNKNOWN) {
-				err("%s: Can't get max bus operation speed\n", __FUNCTION__);
-				max_bus_speed = bus_speed;
-			}
-
-			if (max_bus_speed == bus_speed) {
-				/* if adapter_speed >= bus_speed, do nothing */
-				if (adapter_speed < bus_speed) {
-				/* 
-				 * Try to lower bus speed to accommodate the adapter if other slots 
-				 * on the same controller are empty
-				 */
-					
-					/* Wait for exclusive access to hardware */
-					down(&ctrl->crit_sect);
-
-					rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, adapter_speed);
-					if (rc) {
-						err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-						up(&ctrl->crit_sect);
-						return WRONG_BUS_FREQUENCY;
-					}
-				
-					/* Wait for the command to complete */
-					wait_for_ctrl_irq (ctrl);
-		
-					rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-					if (rc) {
-						err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
-								  __FUNCTION__);
-						err("%s: Error code (%d)\n", __FUNCTION__, rc);
-						up(&ctrl->crit_sect);
-						return WRONG_BUS_FREQUENCY;
-					}
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
-
-				} 
-			} else {
-				/* Wait for exclusive access to hardware */
-				down(&ctrl->crit_sect);
-
-				/* max_bus_speed != bus_speed. Note: max_bus_speed should be > than bus_speed */
-				if (adapter_speed < max_bus_speed) 
-					rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, adapter_speed);
-				else  
-					rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, max_bus_speed);
-				
-				if (rc) {
-					err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
-					return WRONG_BUS_FREQUENCY;
-				}
-				
-				/* Wait for the command to complete */
-				wait_for_ctrl_irq (ctrl);
-		
-				rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-				if (rc) {
-					err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", 
-						__FUNCTION__);
-					err("%s: Error code (%d)\n", __FUNCTION__, rc);
-					/* Done with exclusive hardware access */
-					up(&ctrl->crit_sect);
-					return WRONG_BUS_FREQUENCY;
-				}
-				/* Done with exclusive hardware access */
-				up(&ctrl->crit_sect);
-
-			}
-		}
+		/* If adpater_speed == bus_speed, nothing to do here */
+		dbg("%s: In PI = %d\n", __FUNCTION__, pi);
+		if ((adapter_speed != bus_speed) &&
+		   ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
+				return rc;
 	}
 
-	/* Wait for exclusive access to hardware */
 	down(&ctrl->crit_sect);
-
 	/* turn on board, blink green LED, turn off Amber LED */
-	rc = p_slot->hpc_ops->slot_enable(p_slot);
-	
-	if (rc) {
+	if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
 		err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
-		/* Done with exclusive hardware access */
 		up(&ctrl->crit_sect);
 		return rc;
 	}
-	/* Wait for the command to complete */
 	wait_for_ctrl_irq (ctrl);
 
-	rc = p_slot->hpc_ops->check_cmd_status(ctrl);
-	if (rc) {
+	if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
 		err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
-		/* Done with exclusive hardware access */
 		up(&ctrl->crit_sect);
 		return rc;  
 	}
 
-	/* Done with exclusive hardware access */
 	up(&ctrl->crit_sect);
 
 	/* Wait for ~1 second */
 	dbg("%s: before long_delay\n", __FUNCTION__);
 	wait_for_ctrl_irq (ctrl);
-	dbg("%s: afterlong_delay\n", __FUNCTION__);
+	dbg("%s: after long_delay\n", __FUNCTION__);
 
 	dbg("%s: func status = %x\n", __FUNCTION__, func->status);
 	/* Check for a power fault */
diff -Nru a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
--- a/drivers/pci/hotplug/shpchp_hpc.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/pci/hotplug/shpchp_hpc.c	2004-12-24 13:36:32 -08:00
@@ -792,6 +792,7 @@
 		if (php_ctlr->irq) {
 			free_irq(php_ctlr->irq, ctrl);
 			php_ctlr->irq = 0;
+			pci_disable_msi(php_ctlr->pci_dev);
 		}
 	}
 	if (php_ctlr->pci_dev) {
@@ -1158,7 +1159,7 @@
 					hp_slot, php_ctlr->callback_instance_id);
 			
 			/* Clear all slot events */
-			temp_dword = 0xe01fffff;
+			temp_dword = 0xe01f3fff;
 			dbg("%s: Clearing slot events, temp_dword = %x\n",
 				__FUNCTION__, temp_dword); 
 			writel(temp_dword, php_ctlr->creg + SLOT1 + (4*hp_slot));
@@ -1486,14 +1487,16 @@
 
 	info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, 
 		pdev->subsystem_device);
+	
+	if (pci_enable_device(pdev))
+		goto abort_free_ctlr;
 
 	if (!request_mem_region(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0), MY_NAME)) {
 		err("%s: cannot reserve MMIO region\n", __FUNCTION__);
 		goto abort_free_ctlr;
 	}
 
-	php_ctlr->creg = (struct ctrl_reg *)
-		ioremap(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0));
+	php_ctlr->creg = ioremap(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0));
 	if (!php_ctlr->creg) {
 		err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, pci_resource_len(pdev, 0), 
 			pci_resource_start(pdev, 0) + shpc_base_offset);
@@ -1539,7 +1542,7 @@
 		slot_reg = readl(php_ctlr->creg + SLOT1 + 4*hp_slot );
 		dbg("%s: Default Logical Slot Register %d value %x\n", __FUNCTION__,
 			hp_slot, slot_reg);
-		tempdword = 0xffffffff;  
+		tempdword = 0xffff3fff;  
 		writel(tempdword, php_ctlr->creg + SLOT1 + (4*hp_slot));
 	}
 	
@@ -1592,7 +1595,7 @@
 		slot_reg = readl(php_ctlr->creg + SLOT1 + 4*hp_slot );
 		dbg("%s: Default Logical Slot Register %d value %x\n", __FUNCTION__,
 			hp_slot, slot_reg);
-		tempdword = 0xe01fffff;  
+		tempdword = 0xe01f3fff;  
 		writel(tempdword, php_ctlr->creg + SLOT1 + (4*hp_slot));
 	}
 	if (!shpchp_poll_mode) {
diff -Nru a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/shpchprm_acpi.c
--- a/drivers/pci/hotplug/shpchprm_acpi.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/pci/hotplug/shpchprm_acpi.c	2004-12-24 13:36:47 -08:00
@@ -1396,17 +1396,19 @@
 static int bind_pci_resources_to_slots ( struct controller *ctrl)
 {
 	struct pci_func *func, new_func;
-	int busn = ctrl->bus;
+	int busn = ctrl->slot_bus;
 	int devn, funn;
 	u32	vid;
 
 	for (devn = 0; devn < 32; devn++) {
 		for (funn = 0; funn < 8; funn++) {
+			/*
 			if (devn == ctrl->device && funn == ctrl->function)
 				continue;
+			*/
 			/* find out if this entry is for an occupied slot */
 			vid = 0xFFFFFFFF;
-			pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(devn, funn), PCI_VENDOR_ID, &vid);
+			pci_bus_read_config_dword(ctrl->pci_dev->subordinate, PCI_DEVFN(devn, funn), PCI_VENDOR_ID, &vid);
 
 			if (vid != 0xFFFFFFFF) {
 				func = shpchp_slot_find(busn, devn, funn);
diff -Nru a/drivers/pci/msi.c b/drivers/pci/msi.c
--- a/drivers/pci/msi.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/pci/msi.c	2004-12-24 13:37:19 -08:00
@@ -66,7 +66,7 @@
 		int		pos;
 		u32		mask_bits;
 
-		pos = entry->mask_base;
+		pos = (int)entry->mask_base;
 		pci_read_config_dword(entry->dev, pos, &mask_bits);
 		mask_bits &= ~(1);
 		mask_bits |= flag;
@@ -548,7 +548,7 @@
 	dev->irq = vector;
 	entry->dev = dev;
 	if (is_mask_bit_support(control)) {
-		entry->mask_base = msi_mask_bits_reg(pos,
+		entry->mask_base = (void __iomem *)msi_mask_bits_reg(pos,
 				is_64bit_address(control));
 	}
 	/* Replace with MSI handler */
@@ -606,7 +606,7 @@
 	u32 phys_addr, table_offset;
  	u16 control;
 	u8 bir;
-	void *base;
+	void __iomem *base;
 
    	pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
 	/* Request & Map MSI-X table region */
@@ -642,7 +642,7 @@
 		entry->msi_attrib.maskbit = 1;
 		entry->msi_attrib.default_vector = dev->irq;
 		entry->dev = dev;
-		entry->mask_base = (unsigned long)base;
+		entry->mask_base = base;
 		if (!head) {
 			entry->link.head = vector;
 			entry->link.tail = vector;
@@ -806,7 +806,7 @@
 {
 	struct msi_desc *entry;
 	int head, entry_nr, type;
-	unsigned long base = 0L;
+	void __iomem *base;
 	unsigned long flags;
 
 	spin_lock_irqsave(&msi_lock, flags);
@@ -857,7 +857,7 @@
 			phys_addr = pci_resource_start (dev, bir);
 			phys_addr += (u32)(table_offset &
 				~PCI_MSIX_FLAGS_BIRMASK);
-			iounmap((void*)base);
+			iounmap(base);
 			release_mem_region(phys_addr,
 				nr_entries * PCI_MSIX_ENTRY_SIZE);
 		}
@@ -869,8 +869,8 @@
 static int reroute_msix_table(int head, struct msix_entry *entries, int *nvec)
 {
 	int vector = head, tail = 0;
-	int i = 0, j = 0, nr_entries = 0;
-	unsigned long base = 0L;
+	int i, j = 0, nr_entries = 0;
+	void __iomem *base;
 	unsigned long flags;
 
 	spin_lock_irqsave(&msi_lock, flags);
@@ -1099,7 +1099,7 @@
    	if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 &&
 		!msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) {
 		int vector, head, tail = 0, warning = 0;
-		unsigned long base = 0L;
+		void __iomem *base = NULL;
 
 		vector = head = dev->irq;
 		while (head != tail) {
@@ -1129,7 +1129,7 @@
 			phys_addr = pci_resource_start (dev, bir);
 			phys_addr += (u32)(table_offset &
 				~PCI_MSIX_FLAGS_BIRMASK);
-			iounmap((void*)base);
+			iounmap(base);
 			release_mem_region(phys_addr, PCI_MSIX_ENTRY_SIZE *
 				multi_msix_capable(control));
 			printk(KERN_DEBUG "Driver[%d:%d:%d] unloaded wo doing free_irq on all vectors\n",
diff -Nru a/drivers/pci/msi.h b/drivers/pci/msi.h
--- a/drivers/pci/msi.h	2004-12-24 13:37:02 -08:00
+++ b/drivers/pci/msi.h	2004-12-24 13:37:02 -08:00
@@ -152,7 +152,7 @@
 		__u16	tail;
 	}link;
 
-	unsigned long mask_base;
+	void __iomem *mask_base;
 	struct pci_dev *dev;
 };
 
diff -Nru a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pci/pci-acpi.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,209 @@
+/*
+ * File:	pci-acpi.c
+ * Purpose:	Provide PCI supports in ACPI
+ *
+ * Copyright (C) 2004 Intel
+ * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
+ */
+
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/module.h>
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acresrc.h>
+#include <acpi/acpi_bus.h>
+
+#include <linux/pci-acpi.h>
+
+static u32 ctrlset_buf[3] = {0, 0, 0};
+static u32 global_ctrlsets = 0;
+u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
+
+static acpi_status  
+acpi_query_osc (
+	acpi_handle	handle,
+	u32		level,
+	void		*context,
+	void		**retval )
+{
+	acpi_status		status;
+	struct acpi_object_list	input;
+	union acpi_object 	in_params[4];
+	struct acpi_buffer	output;
+	union acpi_object 	out_obj;	
+	u32			osc_dw0;
+
+	/* Setting up output buffer */
+	output.length = sizeof(out_obj) + 3*sizeof(u32);  
+	output.pointer = &out_obj;
+	
+	/* Setting up input parameters */
+	input.count = 4;
+	input.pointer = in_params;
+	in_params[0].type 		= ACPI_TYPE_BUFFER;
+	in_params[0].buffer.length 	= 16;
+	in_params[0].buffer.pointer	= OSC_UUID;
+	in_params[1].type 		= ACPI_TYPE_INTEGER;
+	in_params[1].integer.value 	= 1;
+	in_params[2].type 		= ACPI_TYPE_INTEGER;
+	in_params[2].integer.value	= 3;
+	in_params[3].type		= ACPI_TYPE_BUFFER;
+	in_params[3].buffer.length 	= 12;
+	in_params[3].buffer.pointer 	= (u8 *)context;
+
+	status = acpi_evaluate_object(handle, "_OSC", &input, &output);
+	if (ACPI_FAILURE (status)) {
+		printk(KERN_DEBUG  
+			"Evaluate _OSC Set fails. Status = 0x%04x\n", status);
+		return status;
+	}
+	if (out_obj.type != ACPI_TYPE_BUFFER) {
+		printk(KERN_DEBUG  
+			"Evaluate _OSC returns wrong type\n");
+		return AE_TYPE;
+	}
+	osc_dw0 = *((u32 *) out_obj.buffer.pointer);
+	if (osc_dw0) {
+		if (osc_dw0 & OSC_REQUEST_ERROR)
+			printk(KERN_DEBUG "_OSC request fails\n"); 
+		if (osc_dw0 & OSC_INVALID_UUID_ERROR)
+			printk(KERN_DEBUG "_OSC invalid UUID\n"); 
+		if (osc_dw0 & OSC_INVALID_REVISION_ERROR)
+			printk(KERN_DEBUG "_OSC invalid revision\n"); 
+		if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) {
+			/* Update Global Control Set */
+			global_ctrlsets = *((u32 *)(out_obj.buffer.pointer+8));
+			return AE_OK;
+		}
+		return AE_ERROR;
+	}
+
+	/* Update Global Control Set */
+	global_ctrlsets = *((u32 *)(out_obj.buffer.pointer + 8));
+	return AE_OK;
+}
+
+
+static acpi_status  
+acpi_run_osc (
+	acpi_handle	handle,
+	u32		level,
+	void		*context,
+	void		**retval )
+{
+	acpi_status		status;
+	struct acpi_object_list	input;
+	union acpi_object 	in_params[4];
+	struct acpi_buffer	output;
+	union acpi_object 	out_obj;	
+	u32			osc_dw0;
+
+	/* Setting up output buffer */
+	output.length = sizeof(out_obj) + 3*sizeof(u32);  
+	output.pointer = &out_obj;
+	
+	/* Setting up input parameters */
+	input.count = 4;
+	input.pointer = in_params;
+	in_params[0].type 		= ACPI_TYPE_BUFFER;
+	in_params[0].buffer.length 	= 16;
+	in_params[0].buffer.pointer	= OSC_UUID;
+	in_params[1].type 		= ACPI_TYPE_INTEGER;
+	in_params[1].integer.value 	= 1;
+	in_params[2].type 		= ACPI_TYPE_INTEGER;
+	in_params[2].integer.value	= 3;
+	in_params[3].type		= ACPI_TYPE_BUFFER;
+	in_params[3].buffer.length 	= 12;
+	in_params[3].buffer.pointer 	= (u8 *)context;
+
+	status = acpi_evaluate_object(handle, "_OSC", &input, &output);
+	if (ACPI_FAILURE (status)) {
+		printk(KERN_DEBUG  
+			"Evaluate _OSC Set fails. Status = 0x%04x\n", status);
+		return status;
+	}
+	if (out_obj.type != ACPI_TYPE_BUFFER) {
+		printk(KERN_DEBUG  
+			"Evaluate _OSC returns wrong type\n");
+		return AE_TYPE;
+	}
+	osc_dw0 = *((u32 *) out_obj.buffer.pointer);
+	if (osc_dw0) {
+		if (osc_dw0 & OSC_REQUEST_ERROR)
+			printk(KERN_DEBUG "_OSC request fails\n"); 
+		if (osc_dw0 & OSC_INVALID_UUID_ERROR)
+			printk(KERN_DEBUG "_OSC invalid UUID\n"); 
+		if (osc_dw0 & OSC_INVALID_REVISION_ERROR)
+			printk(KERN_DEBUG "_OSC invalid revision\n"); 
+		if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) {
+			printk(KERN_DEBUG "_OSC FW not grant req. control\n");
+			return AE_SUPPORT;
+		}
+		return AE_ERROR;
+	}
+	return AE_OK;
+}
+
+/**
+ * pci_osc_support_set - register OS support to Firmware
+ * @flags: OS support bits
+ *
+ * Update OS support fields and doing a _OSC Query to obtain an update
+ * from Firmware on supported control bits.
+ **/
+acpi_status pci_osc_support_set(u32 flags)
+{
+	u32 temp;
+
+	if (!(flags & OSC_SUPPORT_MASKS)) {
+		return AE_TYPE;
+	}
+	ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS);
+
+	/* do _OSC query for all possible controls */
+	temp = ctrlset_buf[OSC_CONTROL_TYPE];
+	ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
+	ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
+	acpi_get_devices ( PCI_ROOT_HID_STRING,
+			acpi_query_osc,
+			ctrlset_buf,
+			NULL );
+	ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE;
+	ctrlset_buf[OSC_CONTROL_TYPE] = temp;
+	return AE_OK;
+}
+EXPORT_SYMBOL(pci_osc_support_set);
+
+/**
+ * pci_osc_control_set - commit requested control to Firmware
+ * @flags: driver's requested control bits
+ *
+ * Attempt to take control from Firmware on requested control bits.
+ **/
+acpi_status pci_osc_control_set(u32 flags)
+{
+	acpi_status	status;
+	u32		ctrlset;
+
+	ctrlset = (flags & OSC_CONTROL_MASKS);
+	if (!ctrlset) {
+		return AE_TYPE;
+	}
+	if (ctrlset_buf[OSC_SUPPORT_TYPE] && 
+	 	((global_ctrlsets & ctrlset) != ctrlset)) {
+		return AE_SUPPORT;
+	}
+	ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset;
+	status = acpi_get_devices ( PCI_ROOT_HID_STRING,
+				acpi_run_osc,
+				ctrlset_buf,
+				NULL );
+	if (ACPI_FAILURE (status)) {
+		ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset;
+	}
+	
+	return status;
+}
+EXPORT_SYMBOL(pci_osc_control_set);
diff -Nru a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
--- a/drivers/pci/pci-driver.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/pci/pci-driver.c	2004-12-24 13:37:02 -08:00
@@ -14,27 +14,6 @@
  *  Registration of PCI drivers and handling of hot-pluggable devices.
  */
 
-/**
- * pci_match_one_device - Tell if a PCI device structure has a matching
- *                        PCI device id structure
- * @id: single PCI device id structure to match
- * @dev: the PCI device structure to match against
- * 
- * Returns the matching pci_device_id structure or %NULL if there is no match.
- */
-
-static inline const struct pci_device_id *
-pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev)
-{
-	if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) &&
-	    (id->device == PCI_ANY_ID || id->device == dev->device) &&
-	    (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) &&
-	    (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) &&
-	    !((id->class ^ dev->class) & id->class_mask))
-		return id;
-	return NULL;
-}
-
 /*
  * Dynamic device IDs are disabled for !CONFIG_HOTPLUG
  */
@@ -291,6 +270,16 @@
 			drv->remove(pci_dev);
 		pci_dev->driver = NULL;
 	}
+
+	/*
+	 * We would love to complain here if pci_dev->is_enabled is set, that
+	 * the driver should have called pci_disable_device(), but the
+	 * unfortunate fact is there are too many odd BIOS and bridge setups
+	 * that don't like drivers doing that all of the time.  
+	 * Oh well, we can dream of sane hardware when we sleep, no matter how
+	 * horrible the crap we have to deal with is when we are awake...
+	 */
+
 	pci_dev_put(pci_dev);
 	return 0;
 }
@@ -316,8 +305,8 @@
 	dev_state = state_conversion[state];
 	if (drv && drv->suspend)
 		i = drv->suspend(pci_dev, dev_state);
-		
-	pci_save_state(pci_dev, pci_dev->saved_config_space);
+	else
+		pci_save_state(pci_dev);
 	return i;
 }
 
@@ -329,7 +318,7 @@
 static void pci_default_resume(struct pci_dev *pci_dev)
 {
 	/* restore the PCI config space */
-	pci_restore_state(pci_dev, pci_dev->saved_config_space);
+	pci_restore_state(pci_dev);
 	/* if the device was enabled before suspend, reenable */
 	if (pci_dev->is_enabled)
 		pci_enable_device(pci_dev);
@@ -404,30 +393,30 @@
  * @drv: the driver structure to register
  * 
  * Adds the driver structure to the list of registered drivers.
- * Returns a negative value on error. The driver remains registered
- * even if no device was claimed during registration.
+ * Returns a negative value on error, otherwise 0. 
+ * If no error occured, the driver remains registered even if 
+ * no device was claimed during registration.
  */
-int
-pci_register_driver(struct pci_driver *drv)
+int pci_register_driver(struct pci_driver *drv)
 {
-	int count = 0;
+	int error;
 
 	/* initialize common driver fields */
 	drv->driver.name = drv->name;
 	drv->driver.bus = &pci_bus_type;
 	drv->driver.probe = pci_device_probe;
 	drv->driver.remove = pci_device_remove;
+	drv->driver.owner = drv->owner;
 	drv->driver.kobj.ktype = &pci_driver_kobj_type;
 	pci_init_dynids(&drv->dynids);
 
 	/* register with core */
-	count = driver_register(&drv->driver);
+	error = driver_register(&drv->driver);
 
-	if (count >= 0) {
+	if (!error)
 		pci_populate_driver_dir(drv);
-	}
 
-	return count ? count : 1;
+	return error;
 }
 
 /**
@@ -512,16 +501,9 @@
  */
 struct pci_dev *pci_dev_get(struct pci_dev *dev)
 {
-	struct device *tmp;
-
-	if (!dev)
-		return NULL;
-
-	tmp = get_device(&dev->dev);
-	if (tmp)        
-		return to_pci_dev(tmp);
-	else
-		return NULL;
+	if (dev)
+		get_device(&dev->dev);
+	return dev;
 }
 
 /**
diff -Nru a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
--- a/drivers/pci/pci-sysfs.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/pci/pci-sysfs.c	2004-12-24 13:36:56 -08:00
@@ -5,6 +5,8 @@
  * (C) Copyright 2002-2004 IBM Corp.
  * (C) Copyright 2003 Matthew Wilcox
  * (C) Copyright 2003 Hewlett-Packard
+ * (C) Copyright 2004 Jon Smirl <jonsmirl@yahoo.com>
+ * (C) Copyright 2004 Silicon Graphics, Inc. Jesse Barnes <jbarnes@sgi.com>
  *
  * File attributes for PCI devices
  *
@@ -17,9 +19,12 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/stat.h>
+#include <linux/topology.h>
 
 #include "pci.h"
 
+static int sysfs_initialized;	/* = 0 */
+
 /* show configuration fields */
 #define pci_config_attr(field, format_string)				\
 static ssize_t								\
@@ -38,6 +43,14 @@
 pci_config_attr(class, "0x%06x\n");
 pci_config_attr(irq, "%u\n");
 
+static ssize_t local_cpus_show(struct device *dev, char *buf)
+{		
+	cpumask_t mask = pcibus_to_cpumask(to_pci_dev(dev)->bus->number);
+	int len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
+	strcat(buf,"\n"); 
+	return 1+len;
+}
+
 /* show resources */
 static ssize_t
 resource_show(struct device * dev, char * buf)
@@ -67,6 +80,7 @@
 	__ATTR_RO(subsystem_device),
 	__ATTR_RO(class),
 	__ATTR_RO(irq),
+	__ATTR_RO(local_cpus),
 	__ATTR_NULL,
 };
 
@@ -164,6 +178,65 @@
 	return count;
 }
 
+/**
+ * pci_write_rom - used to enable access to the PCI ROM display
+ * @kobj: kernel object handle
+ * @buf: user input
+ * @off: file offset
+ * @count: number of byte in input
+ *
+ * writing anything except 0 enables it
+ */
+static ssize_t
+pci_write_rom(struct kobject *kobj, char *buf, loff_t off, size_t count)
+{
+	struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
+
+	if ((off ==  0) && (*buf == '0') && (count == 2))
+		pdev->rom_attr_enabled = 0;
+	else
+		pdev->rom_attr_enabled = 1;
+
+	return count;
+}
+
+/**
+ * pci_read_rom - read a PCI ROM
+ * @kobj: kernel object handle
+ * @buf: where to put the data we read from the ROM
+ * @off: file offset
+ * @count: number of bytes to read
+ *
+ * Put @count bytes starting at @off into @buf from the ROM in the PCI
+ * device corresponding to @kobj.
+ */
+static ssize_t
+pci_read_rom(struct kobject *kobj, char *buf, loff_t off, size_t count)
+{
+	struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
+	void __iomem *rom;
+	size_t size;
+
+	if (!pdev->rom_attr_enabled)
+		return -EINVAL;
+	
+	rom = pci_map_rom(pdev, &size);	/* size starts out as PCI window size */
+	if (!rom)
+		return 0;
+		
+	if (off >= size)
+		count = 0;
+	else {
+		if (off + count > size)
+			count = size - off;
+		
+		memcpy_fromio(buf, rom + off, count);
+	}
+	pci_unmap_rom(pdev, rom);
+		
+	return count;
+}
+
 static struct bin_attribute pci_config_attr = {
 	.attr =	{
 		.name = "config",
@@ -186,13 +259,68 @@
 	.write = pci_write_config,
 };
 
-void pci_create_sysfs_dev_files (struct pci_dev *pdev)
+int pci_create_sysfs_dev_files (struct pci_dev *pdev)
 {
+	if (!sysfs_initialized)
+		return -EACCES;
+
 	if (pdev->cfg_size < 4096)
 		sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
 	else
 		sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);
 
+	/* If the device has a ROM, try to expose it in sysfs. */
+	if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) {
+		struct bin_attribute *rom_attr;
+		
+		rom_attr = kmalloc(sizeof(*rom_attr), GFP_ATOMIC);
+		if (rom_attr) {
+			pdev->rom_attr = rom_attr;
+			rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
+			rom_attr->attr.name = "rom";
+			rom_attr->attr.mode = S_IRUSR;
+			rom_attr->attr.owner = THIS_MODULE;
+			rom_attr->read = pci_read_rom;
+			rom_attr->write = pci_write_rom;
+			sysfs_create_bin_file(&pdev->dev.kobj, rom_attr);
+		}
+	}
 	/* add platform-specific attributes */
 	pcibios_add_platform_entries(pdev);
+	
+	return 0;
 }
+
+/**
+ * pci_remove_sysfs_dev_files - cleanup PCI specific sysfs files
+ * @pdev: device whose entries we should free
+ *
+ * Cleanup when @pdev is removed from sysfs.
+ */
+void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
+{
+	if (pdev->cfg_size < 4096)
+		sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
+	else
+		sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
+
+	if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) {
+		if (pdev->rom_attr) {
+			sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
+			kfree(pdev->rom_attr);
+		}
+	}
+}
+
+static int __init pci_sysfs_init(void)
+{
+	struct pci_dev *pdev = NULL;
+	
+	sysfs_initialized = 1;
+	while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL)
+		pci_create_sysfs_dev_files(pdev);
+
+	return 0;
+}
+
+__initcall(pci_sysfs_init);
diff -Nru a/drivers/pci/pci.c b/drivers/pci/pci.c
--- a/drivers/pci/pci.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/pci/pci.c	2004-12-24 13:36:31 -08:00
@@ -308,14 +308,12 @@
  * (>= 64 bytes).
  */
 int
-pci_save_state(struct pci_dev *dev, u32 *buffer)
+pci_save_state(struct pci_dev *dev)
 {
 	int i;
-	if (buffer) {
-		/* XXX: 100% dword access ok here? */
-		for (i = 0; i < 16; i++)
-			pci_read_config_dword(dev, i * 4,&buffer[i]);
-	}
+	/* XXX: 100% dword access ok here? */
+	for (i = 0; i < 16; i++)
+		pci_read_config_dword(dev, i * 4,&dev->saved_config_space[i]);
 	return 0;
 }
 
@@ -326,27 +324,12 @@
  *
  */
 int 
-pci_restore_state(struct pci_dev *dev, u32 *buffer)
+pci_restore_state(struct pci_dev *dev)
 {
 	int i;
 
-	if (buffer) {
-		for (i = 0; i < 16; i++)
-			pci_write_config_dword(dev,i * 4, buffer[i]);
-	}
-	/*
-	 * otherwise, write the context information we know from bootup.
-	 * This works around a problem where warm-booting from Windows
-	 * combined with a D3(hot)->D0 transition causes PCI config
-	 * header data to be forgotten.
-	 */	
-	else {
-		for (i = 0; i < 6; i ++)
-			pci_write_config_dword(dev,
-					       PCI_BASE_ADDRESS_0 + (i * 4),
-					       dev->resource[i].start);
-		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
-	}
+	for (i = 0; i < 16; i++)
+		pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]);
 	return 0;
 }
 
@@ -382,11 +365,26 @@
 int
 pci_enable_device(struct pci_dev *dev)
 {
+	int err;
+
 	dev->is_enabled = 1;
-	return pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
+	if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1)))
+		return err;
+	pci_fixup_device(pci_fixup_enable, dev);
+	return 0;
 }
 
 /**
+ * pcibios_disable_device - disable arch specific PCI resources for device dev
+ * @dev: the PCI device to disable
+ *
+ * Disables architecture specific PCI resources for the device. This
+ * is the default implementation. Architecture implementations can
+ * override this.
+ */
+void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {}
+
+/**
  * pci_disable_device - Disable PCI device after use
  * @dev: PCI device to be disabled
  *
@@ -406,6 +404,8 @@
 		pci_command &= ~PCI_COMMAND_MASTER;
 		pci_write_config_word(dev, PCI_COMMAND, pci_command);
 	}
+
+	pcibios_disable_device(dev);
 }
 
 /**
@@ -744,7 +744,7 @@
 {
 	struct pci_dev *dev = NULL;
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
 		pci_fixup_device(pci_fixup_final, dev);
 	}
 	return 0;
diff -Nru a/drivers/pci/pci.h b/drivers/pci/pci.h
--- a/drivers/pci/pci.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/pci/pci.h	2004-12-24 13:36:47 -08:00
@@ -2,7 +2,9 @@
 
 extern int pci_hotplug (struct device *dev, char **envp, int num_envp,
 			 char *buffer, int buffer_size);
-extern void pci_create_sysfs_dev_files(struct pci_dev *pdev);
+extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
+extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
+extern void pci_cleanup_rom(struct pci_dev *dev);
 extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
 				  unsigned long size, unsigned long align,
 				  unsigned long min, unsigned int type_mask,
@@ -61,5 +63,26 @@
 /* Lock for read/write access to pci device and bus lists */
 extern spinlock_t pci_bus_lock;
 
-extern int pciehp_msi_quirk;
+extern int pcie_mch_quirk;
 extern struct device_attribute pci_dev_attrs[];
+
+/**
+ * pci_match_one_device - Tell if a PCI device structure has a matching
+ *                        PCI device id structure
+ * @id: single PCI device id structure to match
+ * @dev: the PCI device structure to match against
+ * 
+ * Returns the matching pci_device_id structure or %NULL if there is no match.
+ */
+static inline const struct pci_device_id *
+pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev)
+{
+	if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) &&
+	    (id->device == PCI_ANY_ID || id->device == dev->device) &&
+	    (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) &&
+	    (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) &&
+	    !((id->class ^ dev->class) & id->class_mask))
+		return id;
+	return NULL;
+}
+
diff -Nru a/drivers/pci/pci.ids b/drivers/pci/pci.ids
--- a/drivers/pci/pci.ids	2004-12-24 13:36:55 -08:00
+++ b/drivers/pci/pci.ids	2004-12-24 13:36:55 -08:00
@@ -8429,9 +8429,9 @@
 	84e6  460GX - 82466GX Wide and fast PCI eXpander Bridge (WXB)
 	84ea  460GX - 84460GX AGP Bridge (GXB function 1)
 	8500  IXP4xx Family  Network Processor (IXP420, 421, 422, 425 and IXC1100)
-	9000  Intel IXP2000 Family Network Processor
-	9001  Intel IXP2400 Network Processor
-	9004  Intel IXP2800 Network Processor
+	9000  IXP2000 Family Network Processor
+	9001  IXP2400 Network Processor
+	9004  IXP2800 Network Processor
 	9621  Integrated RAID
 	9622  Integrated RAID
 	9641  Integrated RAID
@@ -8440,7 +8440,7 @@
 # observed, and documented in Intel revision note; new mask of 1011:0026
 	b154  21154 PCI-to-PCI Bridge
 	b555  21555 Non transparent PCI-to-PCI Bridge
-		1331 0030  Radisys ENP-2611
+		1331 0030  ENP-2611
 		4c53 1050  CT7 mainboard
 		4c53 1051  CE7 mainboard
 		e4bf 1000  CC8-1-BLUES
diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
--- a/drivers/pci/probe.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/pci/probe.c	2004-12-24 13:37:02 -08:00
@@ -144,9 +144,11 @@
 			pci_write_config_dword(dev, reg+4, ~0);
 			pci_read_config_dword(dev, reg+4, &sz);
 			pci_write_config_dword(dev, reg+4, l);
-			if (~sz)
-				res->end = res->start + 0xffffffff +
-						(((unsigned long) ~sz) << 32);
+			sz = pci_size(l, sz, 0xffffffff);
+			if (sz) {
+				/* This BAR needs > 4GB?  Wow. */
+				res->end |= (unsigned long)sz<<32;
+			}
 #else
 			if (l) {
 				printk(KERN_ERR "PCI: Unable to handle 64-bit address for device %s\n", pci_name(dev));
@@ -170,7 +172,7 @@
 		if (sz && sz != 0xffffffff) {
 			sz = pci_size(l, sz, PCI_ROM_ADDRESS_MASK);
 			if (sz) {
-				res->flags = (l & PCI_ROM_ADDRESS_ENABLE) |
+				res->flags = (l & IORESOURCE_ROM_ENABLE) |
 				  IORESOURCE_MEM | IORESOURCE_PREFETCH |
 				  IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
 				res->start = l & PCI_ROM_ADDRESS_MASK;
@@ -243,15 +245,23 @@
 		u32 mem_base_hi, mem_limit_hi;
 		pci_read_config_dword(dev, PCI_PREF_BASE_UPPER32, &mem_base_hi);
 		pci_read_config_dword(dev, PCI_PREF_LIMIT_UPPER32, &mem_limit_hi);
+
+		/*
+		 * Some bridges set the base > limit by default, and some
+		 * (broken) BIOSes do not initialize them.  If we find
+		 * this, just assume they are not being used.
+		 */
+		if (mem_base_hi <= mem_limit_hi) {
 #if BITS_PER_LONG == 64
-		base |= ((long) mem_base_hi) << 32;
-		limit |= ((long) mem_limit_hi) << 32;
+			base |= ((long) mem_base_hi) << 32;
+			limit |= ((long) mem_limit_hi) << 32;
 #else
-		if (mem_base_hi || mem_limit_hi) {
-			printk(KERN_ERR "PCI: Unable to handle 64-bit address space for %s\n", child->name);
-			return;
-		}
+			if (mem_base_hi || mem_limit_hi) {
+				printk(KERN_ERR "PCI: Unable to handle 64-bit address space for bridge %s\n", pci_name(dev));
+				return;
+			}
 #endif
+		}
 	}
 	if (base <= limit) {
 		res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM | IORESOURCE_PREFETCH;
@@ -478,6 +488,9 @@
 	/* "Unknown power state" */
 	dev->current_state = 4;
 
+	/* Early fixups, before probing the BARs */
+	pci_fixup_device(pci_fixup_early, dev);
+
 	switch (dev->hdr_type) {		    /* header type */
 	case PCI_HEADER_TYPE_NORMAL:		    /* standard header */
 		if (class == PCI_CLASS_BRIDGE_PCI)
@@ -753,6 +766,7 @@
 
 struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata)
 {
+	int error;
 	struct pci_bus *b;
 	struct device *dev;
 
@@ -772,9 +786,7 @@
 	if (pci_find_bus(pci_domain_nr(b), bus)) {
 		/* If we already got to this bus through a different bridge, ignore it */
 		DBG("PCI: Bus %02x already known\n", bus);
-		kfree(dev);
-		kfree(b);
-		return NULL;
+		goto err_out;
 	}
 	list_add_tail(&b->node, &pci_root_buses);
 
@@ -782,15 +794,23 @@
 	dev->parent = parent;
 	dev->release = pci_release_bus_bridge_dev;
 	sprintf(dev->bus_id, "pci%04x:%02x", pci_domain_nr(b), bus);
-	device_register(dev);
+	error = device_register(dev);
+	if (error)
+		goto dev_reg_err;
 	b->bridge = get_device(dev);
 
 	b->class_dev.class = &pcibus_class;
 	sprintf(b->class_dev.class_id, "%04x:%02x", pci_domain_nr(b), bus);
-	class_device_register(&b->class_dev);
-	class_device_create_file(&b->class_dev, &class_device_attr_cpuaffinity);
-
-	sysfs_create_link(&b->class_dev.kobj, &b->bridge->kobj, "bridge");
+	error = class_device_register(&b->class_dev);
+	if (error)
+		goto class_dev_reg_err;
+	error = class_device_create_file(&b->class_dev, &class_device_attr_cpuaffinity);
+	if (error)
+		goto class_dev_create_file_err;
+
+	error = sysfs_create_link(&b->class_dev.kobj, &b->bridge->kobj, "bridge");
+	if (error)
+		goto sys_create_link_err;
 
 	b->number = b->secondary = bus;
 	b->resource[0] = &ioport_resource;
@@ -801,6 +821,19 @@
 	pci_bus_add_devices(b);
 
 	return b;
+
+sys_create_link_err:
+	class_device_remove_file(&b->class_dev, &class_device_attr_cpuaffinity);
+class_dev_create_file_err:
+	class_device_unregister(&b->class_dev);
+class_dev_reg_err:
+	device_unregister(dev);
+dev_reg_err:
+	list_del(&b->node);
+err_out:
+	kfree(dev);
+	kfree(b);
+	return NULL;
 }
 EXPORT_SYMBOL(pci_scan_bus_parented);
 
diff -Nru a/drivers/pci/proc.c b/drivers/pci/proc.c
--- a/drivers/pci/proc.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/pci/proc.c	2004-12-24 13:36:59 -08:00
@@ -379,7 +379,7 @@
 	.show	= show_device
 };
 
-struct proc_dir_entry *proc_bus_pci_dir;
+static struct proc_dir_entry *proc_bus_pci_dir;
 
 int pci_proc_attach_device(struct pci_dev *dev)
 {
@@ -599,7 +599,7 @@
 	if (entry)
 		entry->proc_fops = &proc_bus_pci_dev_operations;
 	proc_initialized = 1;
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
 		pci_proc_attach_device(dev);
 	}
 	legacy_proc_init();
@@ -612,6 +612,5 @@
 EXPORT_SYMBOL(pci_proc_attach_device);
 EXPORT_SYMBOL(pci_proc_attach_bus);
 EXPORT_SYMBOL(pci_proc_detach_bus);
-EXPORT_SYMBOL(proc_bus_pci_dir);
 #endif
 
diff -Nru a/drivers/pci/quirks.c b/drivers/pci/quirks.c
--- a/drivers/pci/quirks.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/pci/quirks.c	2004-12-24 13:36:17 -08:00
@@ -30,7 +30,7 @@
 
 	/* We have to make sure a particular bit is set in the PIIX3
 	   ISA bridge, so we have to go out and find it. */
-	while ((d = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, d))) {
+	while ((d = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, d))) {
 		pci_read_config_byte(d, 0x82, &dlc);
 		if (!(dlc & 1<<1)) {
 			printk(KERN_ERR "PCI: PIIX3: Enabling Passive Release on %s\n", pci_name(d));
@@ -116,21 +116,21 @@
 	/* Ok we have a potential problem chipset here. Now see if we have
 	   a buggy southbridge */
 	   
-	p = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, NULL);
+	p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, NULL);
 	if (p!=NULL) {
 		pci_read_config_byte(p, PCI_CLASS_REVISION, &rev);
 		/* 0x40 - 0x4f == 686B, 0x10 - 0x2f == 686A; thanks Dan Hollis */
 		/* Check for buggy part revisions */
-		if (rev < 0x40 || rev > 0x42) 
-			return;
+		if (rev < 0x40 || rev > 0x42)
+			goto exit;
 	} else {
-		p = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
+		p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
 		if (p==NULL)	/* No problem parts */
-			return;
+			goto exit;
 		pci_read_config_byte(p, PCI_CLASS_REVISION, &rev);
 		/* Check for buggy part revisions */
 		if (rev < 0x10 || rev > 0x12) 
-			return;
+			goto exit;
 	}
 	
 	/*
@@ -153,6 +153,8 @@
 	busarb |= (1<<4);
 	pci_write_config_byte(dev, 0x76, busarb);
 	printk(KERN_INFO "Applying VIA southbridge workaround.\n");
+exit:
+	pci_dev_put(p);
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8363_0,	quirk_vialatency );
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8371_1,	quirk_vialatency );
@@ -477,7 +479,7 @@
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C586_3,	quirk_via_acpi );
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C686_4,	quirk_via_acpi );
 
-static void __devinit quirk_via_irqpic(struct pci_dev *dev)
+static void quirk_via_irqpic(struct pci_dev *dev)
 {
 	u8 irq, new_irq = dev->irq & 0xf;
 
@@ -491,9 +493,10 @@
 		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq);
 	}
 }
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C586_2,	quirk_via_irqpic );
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C686_5,	quirk_via_irqpic );
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C686_6,	quirk_via_irqpic );
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C586_2,	quirk_via_irqpic );
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C686_5,	quirk_via_irqpic );
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C686_6,	quirk_via_irqpic );
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8233_5,	quirk_via_irqpic );
 
 
 /*
@@ -769,6 +772,11 @@
 			case 0x1751: /* M2N notebook */
 				asus_hides_smbus = 1;
 			}
+		if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB)
+			switch (dev->subsystem_device) {
+			case 0x186a: /* M6Ne notebook */
+				asus_hides_smbus = 1;
+			}
 	} else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_HP)) {
 		if (dev->device ==  PCI_DEVICE_ID_INTEL_82855PM_HB)
 			switch(dev->subsystem_device) {
@@ -826,6 +834,234 @@
 	pci_read_config_byte(dev, 0x77, &val);
 }
 
+
+#define UHCI_USBLEGSUP		0xc0		/* legacy support */
+#define UHCI_USBCMD		0		/* command register */
+#define UHCI_USBSTS		2		/* status register */
+#define UHCI_USBINTR		4		/* interrupt register */
+#define UHCI_USBLEGSUP_DEFAULT	0x2000		/* only PIRQ enable set */
+#define UHCI_USBCMD_RUN		(1 << 0)	/* RUN/STOP bit */
+#define UHCI_USBCMD_GRESET	(1 << 2)	/* Global reset */
+#define UHCI_USBCMD_CONFIGURE	(1 << 6)	/* config semaphore */
+#define UHCI_USBSTS_HALTED	(1 << 5)	/* HCHalted bit */
+
+#define OHCI_CONTROL		0x04
+#define OHCI_CMDSTATUS		0x08
+#define OHCI_INTRSTATUS		0x0c
+#define OHCI_INTRENABLE		0x10
+#define OHCI_INTRDISABLE	0x14
+#define OHCI_OCR		(1 << 3)	/* ownership change request */
+#define OHCI_CTRL_IR		(1 << 8)	/* interrupt routing */
+#define OHCI_INTR_OC		(1 << 30)	/* ownership change */
+
+#define EHCI_HCC_PARAMS		0x08		/* extended capabilities */
+#define EHCI_USBCMD		0		/* command register */
+#define EHCI_USBCMD_RUN		(1 << 0)	/* RUN/STOP bit */
+#define EHCI_USBSTS		4		/* status register */
+#define EHCI_USBSTS_HALTED	(1 << 12)	/* HCHalted bit */
+#define EHCI_USBINTR		8		/* interrupt register */
+#define EHCI_USBLEGSUP		0		/* legacy support register */
+#define EHCI_USBLEGSUP_BIOS	(1 << 16)	/* BIOS semaphore */
+#define EHCI_USBLEGSUP_OS	(1 << 24)	/* OS semaphore */
+#define EHCI_USBLEGCTLSTS	4		/* legacy control/status */
+#define EHCI_USBLEGCTLSTS_SOOE	(1 << 13)	/* SMI on ownership change */
+
+int usb_early_handoff __devinitdata = 0;
+static int __init usb_handoff_early(char *str)
+{
+	usb_early_handoff = 1;
+	return 0;
+}
+__setup("usb-handoff", usb_handoff_early);
+
+static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev)
+{
+	unsigned long base = 0;
+	int wait_time, delta;
+	u16 val, sts;
+	int i;
+
+	for (i = 0; i < PCI_ROM_RESOURCE; i++)
+		if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
+			base = pci_resource_start(pdev, i);
+			break;
+		}
+
+	if (!base)
+		return;
+
+	/*
+	 * stop controller
+	 */
+	sts = inw(base + UHCI_USBSTS);
+	val = inw(base + UHCI_USBCMD);
+	val &= ~(u16)(UHCI_USBCMD_RUN | UHCI_USBCMD_CONFIGURE);
+	outw(val, base + UHCI_USBCMD);
+
+	/*
+	 * wait while it stops if it was running
+	 */
+	if ((sts & UHCI_USBSTS_HALTED) == 0)
+	{
+		wait_time = 1000;
+		delta = 100;
+
+		do {
+			outw(0x1f, base + UHCI_USBSTS);
+			udelay(delta);
+			wait_time -= delta;
+			val = inw(base + UHCI_USBSTS);
+			if (val & UHCI_USBSTS_HALTED)
+				break;
+		} while (wait_time > 0);
+	}
+
+	/*
+	 * disable interrupts & legacy support
+	 */
+	outw(0, base + UHCI_USBINTR);
+	outw(0x1f, base + UHCI_USBSTS);
+	pci_read_config_word(pdev, UHCI_USBLEGSUP, &val);
+	if (val & 0xbf) 
+		pci_write_config_word(pdev, UHCI_USBLEGSUP, UHCI_USBLEGSUP_DEFAULT);
+		
+}
+
+static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
+{
+	void __iomem *base;
+	int wait_time;
+
+	base = ioremap_nocache(pci_resource_start(pdev, 0),
+				     pci_resource_len(pdev, 0));
+	if (base == NULL) return;
+
+	if (readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) {
+		wait_time = 500; /* 0.5 seconds */
+		writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
+		writel(OHCI_OCR, base + OHCI_CMDSTATUS);
+		while (wait_time > 0 && 
+				readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) {
+			wait_time -= 10;
+			msleep(10);
+		}
+	}
+
+	/*
+	 * disable interrupts
+	 */
+	writel(~(u32)0, base + OHCI_INTRDISABLE);
+	writel(~(u32)0, base + OHCI_INTRSTATUS);
+
+	iounmap(base);
+}
+
+static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
+{
+	int wait_time, delta;
+	void __iomem *base, *op_reg_base;
+	u32 hcc_params, val, temp;
+	u8 cap_length;
+
+	base = ioremap_nocache(pci_resource_start(pdev, 0),
+				pci_resource_len(pdev, 0));
+	if (base == NULL) return;
+
+	cap_length = readb(base);
+	op_reg_base = base + cap_length;
+	hcc_params = readl(base + EHCI_HCC_PARAMS);
+	hcc_params = (hcc_params >> 8) & 0xff;
+	if (hcc_params) {
+		pci_read_config_dword(pdev, 
+					hcc_params + EHCI_USBLEGSUP,
+					&val);
+		if (((val & 0xff) == 1) && (val & EHCI_USBLEGSUP_BIOS)) {
+			/*
+			 * Ok, BIOS is in smm mode, try to hand off...
+			 */
+			pci_read_config_dword(pdev,
+						hcc_params + EHCI_USBLEGCTLSTS,
+						&temp);
+			pci_write_config_dword(pdev,
+						hcc_params + EHCI_USBLEGCTLSTS,
+						temp | EHCI_USBLEGCTLSTS_SOOE);
+			val |= EHCI_USBLEGSUP_OS;
+			pci_write_config_dword(pdev, 
+						hcc_params + EHCI_USBLEGSUP, 
+						val);
+
+			wait_time = 500;
+			do {
+				msleep(10);
+				wait_time -= 10;
+				pci_read_config_dword(pdev,
+						hcc_params + EHCI_USBLEGSUP,
+						&val);
+			} while (wait_time && (val & EHCI_USBLEGSUP_BIOS));
+			if (!wait_time) {
+				/*
+				 * well, possibly buggy BIOS...
+				 */
+				printk(KERN_WARNING "EHCI early BIOS handoff "
+						"failed (BIOS bug ?)\n");
+				pci_write_config_dword(pdev,
+						hcc_params + EHCI_USBLEGSUP,
+						EHCI_USBLEGSUP_OS);
+				pci_write_config_dword(pdev,
+						hcc_params + EHCI_USBLEGCTLSTS,
+						0);
+			}
+		}
+	}
+
+	/*
+	 * halt EHCI & disable its interrupts in any case
+	 */
+	val = readl(op_reg_base + EHCI_USBSTS);
+	if ((val & EHCI_USBSTS_HALTED) == 0) {
+		val = readl(op_reg_base + EHCI_USBCMD);
+		val &= ~EHCI_USBCMD_RUN;
+		writel(val, op_reg_base + EHCI_USBCMD);
+
+		wait_time = 2000;
+		delta = 100;
+		do {
+			writel(0x3f, op_reg_base + EHCI_USBSTS);
+			udelay(delta);
+			wait_time -= delta;
+			val = readl(op_reg_base + EHCI_USBSTS);
+			if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) {
+				break;
+			}
+		} while (wait_time > 0);
+	}
+	writel(0, op_reg_base + EHCI_USBINTR);
+	writel(0x3f, op_reg_base + EHCI_USBSTS);
+
+	iounmap(base);
+
+	return;
+}
+
+
+
+static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
+{
+	if (!usb_early_handoff)
+		return;
+
+	if (pdev->class == ((PCI_CLASS_SERIAL_USB << 8) | 0x00)) { /* UHCI */
+		quirk_usb_handoff_uhci(pdev);
+	} else if (pdev->class == ((PCI_CLASS_SERIAL_USB << 8) | 0x10)) { /* OHCI */
+		quirk_usb_handoff_ohci(pdev);
+	} else if (pdev->class == ((PCI_CLASS_SERIAL_USB << 8) | 0x20)) { /* EHCI */
+		quirk_usb_disable_ehci(pdev);
+	}
+
+	return;
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff);
+
 /*
  * ... This is further complicated by the fact that some SiS96x south
  * bridges pretend to be 85C503/5513 instead.  In that case see if we
@@ -905,7 +1141,7 @@
 #endif
 
 #ifdef CONFIG_SCSI_SATA
-static void __init quirk_intel_ide_combined(struct pci_dev *pdev)
+static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev)
 {
 	u8 prog, comb, tmp;
 	int ich = 0;
@@ -978,21 +1214,23 @@
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,    PCI_ANY_ID,	  quirk_intel_ide_combined );
 #endif /* CONFIG_SCSI_SATA */
 
-int pciehp_msi_quirk;
 
-static void __devinit quirk_pciehp_msi(struct pci_dev *pdev)
+int pcie_mch_quirk;
+
+static void __devinit quirk_pcie_mch(struct pci_dev *pdev)
 {
-	pciehp_msi_quirk = 1;
+	pcie_mch_quirk = 1;
 }
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_SMCH,	quirk_pciehp_msi );
-
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7520_MCH,	quirk_pcie_mch );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7320_MCH,	quirk_pcie_mch );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7525_MCH,	quirk_pcie_mch );
 
 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end)
 {
 	while (f < end) {
 		if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) &&
  		    (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
-			pr_debug(KERN_INFO "PCI: Calling quirk %p for %s\n", f->hook, pci_name(dev));
+			pr_debug("PCI: Calling quirk %p for %s\n", f->hook, pci_name(dev));
 			f->hook(dev);
 		}
 		f++;
@@ -1003,6 +1241,9 @@
 extern struct pci_fixup __end_pci_fixups_header[];
 extern struct pci_fixup __start_pci_fixups_final[];
 extern struct pci_fixup __end_pci_fixups_final[];
+extern struct pci_fixup __start_pci_fixups_enable[];
+extern struct pci_fixup __end_pci_fixups_enable[];
+
 
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
 {
@@ -1018,6 +1259,12 @@
 		start = __start_pci_fixups_final;
 		end = __end_pci_fixups_final;
 		break;
+
+	case pci_fixup_enable:
+		start = __start_pci_fixups_enable;
+		end = __end_pci_fixups_enable;
+		break;
+
 	default:
 		/* stupid compiler warning, you would think with an enum... */
 		return;
@@ -1025,4 +1272,7 @@
 	pci_do_fixups(dev, start, end);
 }
 
-EXPORT_SYMBOL(pciehp_msi_quirk);
+EXPORT_SYMBOL(pcie_mch_quirk);
+#ifdef CONFIG_HOTPLUG
+EXPORT_SYMBOL(pci_fixup_device);
+#endif
diff -Nru a/drivers/pci/remove.c b/drivers/pci/remove.c
--- a/drivers/pci/remove.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/pci/remove.c	2004-12-24 13:36:31 -08:00
@@ -16,6 +16,7 @@
 
  	msi_remove_pci_irq_vectors(dev);
 
+	pci_cleanup_rom(dev);
 	for (i = 0; i < PCI_NUM_RESOURCES; i++) {
 		struct resource *res = dev->resource + i;
 		if (res->parent)
@@ -26,6 +27,7 @@
 static void pci_destroy_dev(struct pci_dev *dev)
 {
 	pci_proc_detach_device(dev);
+	pci_remove_sysfs_dev_files(dev);
 	device_unregister(&dev->dev);
 
 	/* Remove the device from the device lists, and prevent any further
diff -Nru a/drivers/pci/rom.c b/drivers/pci/rom.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pci/rom.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,225 @@
+/*
+ * drivers/pci/rom.c
+ *
+ * (C) Copyright 2004 Jon Smirl <jonsmirl@yahoo.com>
+ * (C) Copyright 2004 Silicon Graphics, Inc. Jesse Barnes <jbarnes@sgi.com>
+ *
+ * PCI ROM access routines
+ *
+ */
+
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+
+#include "pci.h"
+
+/**
+ * pci_enable_rom - enable ROM decoding for a PCI device
+ * @dev: PCI device to enable
+ *
+ * Enable ROM decoding on @dev.  This involves simply turning on the last
+ * bit of the PCI ROM BAR.  Note that some cards may share address decoders
+ * between the ROM and other resources, so enabling it may disable access
+ * to MMIO registers or other card memory.
+ */
+static void
+pci_enable_rom(struct pci_dev *pdev)
+{
+	u32 rom_addr;
+	
+	pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
+	rom_addr |= PCI_ROM_ADDRESS_ENABLE;
+	pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr);
+}
+
+/**
+ * pci_disable_rom - disable ROM decoding for a PCI device
+ * @dev: PCI device to disable
+ *
+ * Disable ROM decoding on a PCI device by turning off the last bit in the
+ * ROM BAR.
+ */
+static void
+pci_disable_rom(struct pci_dev *pdev)
+{
+	u32 rom_addr;
+	pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
+	rom_addr &= ~PCI_ROM_ADDRESS_ENABLE;
+	pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr);
+}
+
+/**
+ * pci_map_rom - map a PCI ROM to kernel space
+ * @dev: pointer to pci device struct
+ * @size: pointer to receive size of pci window over ROM
+ * @return: kernel virtual pointer to image of ROM
+ *
+ * Map a PCI ROM into kernel space. If ROM is boot video ROM,
+ * the shadow BIOS copy will be returned instead of the 
+ * actual ROM.
+ */
+void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
+{
+	struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
+	loff_t start;
+	void __iomem *rom;
+	void __iomem *image;
+	int last_image;
+	
+	if (res->flags & IORESOURCE_ROM_SHADOW) {	/* IORESOURCE_ROM_SHADOW only set on x86 */
+		start = (loff_t)0xC0000; 	/* primary video rom always starts here */
+		*size = 0x20000;		/* cover C000:0 through E000:0 */
+	} else {
+		if (res->flags & IORESOURCE_ROM_COPY) {
+			*size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
+			return (void __iomem *)pci_resource_start(pdev, PCI_ROM_RESOURCE);
+		} else {
+			/* assign the ROM an address if it doesn't have one */
+			if (res->parent == NULL)
+				pci_assign_resource(pdev, PCI_ROM_RESOURCE);
+	
+			start = pci_resource_start(pdev, PCI_ROM_RESOURCE);
+			*size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
+			if (*size == 0)
+				return NULL;
+			
+			/* Enable ROM space decodes */
+			pci_enable_rom(pdev);
+		}
+	}
+	
+	rom = ioremap(start, *size);
+	if (!rom) {
+		/* restore enable if ioremap fails */
+		if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW | IORESOURCE_ROM_COPY)))
+			pci_disable_rom(pdev);
+		return NULL;
+	}		
+
+	/* Try to find the true size of the ROM since sometimes the PCI window */
+	/* size is much larger than the actual size of the ROM. */
+	/* True size is important if the ROM is going to be copied. */
+	image = rom;
+	do {
+		void __iomem *pds;
+		/* Standard PCI ROMs start out with these bytes 55 AA */
+		if (readb(image) != 0x55)
+			break;
+		if (readb(image + 1) != 0xAA)
+			break;
+		/* get the PCI data structure and check its signature */
+		pds = image + readw(image + 24);
+		if (readb(pds) != 'P')
+			break;
+		if (readb(pds + 1) != 'C')
+			break;
+		if (readb(pds + 2) != 'I')
+			break;
+		if (readb(pds + 3) != 'R')
+			break;
+		last_image = readb(pds + 21) & 0x80;
+		/* this length is reliable */
+		image += readw(pds + 16) * 512;
+	} while (!last_image);
+
+	*size = image - rom;
+
+	return rom;
+}
+
+/**
+ * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy
+ * @dev: pointer to pci device struct
+ * @size: pointer to receive size of pci window over ROM
+ * @return: kernel virtual pointer to image of ROM
+ *
+ * Map a PCI ROM into kernel space. If ROM is boot video ROM,
+ * the shadow BIOS copy will be returned instead of the 
+ * actual ROM.
+ */
+void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size)
+{
+	struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
+	void __iomem *rom;
+	
+	rom = pci_map_rom(pdev, size);
+	if (!rom)
+		return NULL;
+		
+	if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_SHADOW))
+		return rom;
+		
+	res->start = (unsigned long)kmalloc(*size, GFP_KERNEL);
+	if (!res->start) 
+		return rom;
+
+	res->end = res->start + *size; 
+	memcpy_fromio((void*)res->start, rom, *size);
+	pci_unmap_rom(pdev, rom);
+	res->flags |= IORESOURCE_ROM_COPY;
+	
+	return (void __iomem *)res->start;
+}
+
+/**
+ * pci_unmap_rom - unmap the ROM from kernel space
+ * @dev: pointer to pci device struct
+ * @rom: virtual address of the previous mapping
+ *
+ * Remove a mapping of a previously mapped ROM
+ */
+void 
+pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
+{
+	struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
+
+	if (res->flags & IORESOURCE_ROM_COPY)
+		return;
+		
+	iounmap(rom);
+		
+	/* Disable again before continuing, leave enabled if pci=rom */
+	if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW)))
+		pci_disable_rom(pdev);
+}
+
+/**
+ * pci_remove_rom - disable the ROM and remove its sysfs attribute
+ * @dev: pointer to pci device struct
+ *
+ */
+void 
+pci_remove_rom(struct pci_dev *pdev) 
+{
+	struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
+	
+	if (pci_resource_len(pdev, PCI_ROM_RESOURCE))
+		sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
+	if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW | IORESOURCE_ROM_COPY)))
+		pci_disable_rom(pdev);
+}
+
+/**
+ * pci_cleanup_rom - internal routine for freeing the ROM copy created 
+ * by pci_map_rom_copy called from remove.c
+ * @dev: pointer to pci device struct
+ *
+ */
+void 
+pci_cleanup_rom(struct pci_dev *pdev) 
+{
+	struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
+	if (res->flags & IORESOURCE_ROM_COPY) {
+		kfree((void*)res->start);
+		res->flags &= ~IORESOURCE_ROM_COPY;
+		res->start = 0;
+		res->end = 0;
+	}
+}
+
+EXPORT_SYMBOL(pci_map_rom);
+EXPORT_SYMBOL(pci_map_rom_copy);
+EXPORT_SYMBOL(pci_unmap_rom);
+EXPORT_SYMBOL(pci_remove_rom);
diff -Nru a/drivers/pci/search.c b/drivers/pci/search.c
--- a/drivers/pci/search.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/pci/search.c	2004-12-24 13:36:16 -08:00
@@ -1,16 +1,17 @@
 /*
  * 	PCI searching functions.
  *
- *	Copyright 1993 -- 1997 Drew Eckhardt, Frederic Potter,
- *				David Mosberger-Tang
- *	Copyright 1997 -- 2000 Martin Mares <mj@ucw.cz>
- *	Copyright 2003 -- Greg Kroah-Hartman <greg@kroah.com>
+ *	Copyright (C) 1993 -- 1997 Drew Eckhardt, Frederic Potter,
+ *					David Mosberger-Tang
+ *	Copyright (C) 1997 -- 2000 Martin Mares <mj@ucw.cz>
+ *	Copyright (C) 2003 -- 2004 Greg Kroah-Hartman <greg@kroah.com>
  */
 
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include "pci.h"
 
 spinlock_t pci_bus_lock = SPIN_LOCK_UNLOCKED;
 
@@ -156,10 +157,11 @@
  * the pci device returned by this function can disappear at any moment in
  * time.
  */
-struct pci_dev *
-pci_find_subsys(unsigned int vendor, unsigned int device,
-		unsigned int ss_vendor, unsigned int ss_device,
-		const struct pci_dev *from)
+static struct pci_dev * pci_find_subsys(unsigned int vendor,
+				        unsigned int device,
+					unsigned int ss_vendor,
+					unsigned int ss_device,
+					const struct pci_dev *from)
 {
 	struct list_head *n;
 	struct pci_dev *dev;
@@ -257,12 +259,6 @@
  * @from: Previous PCI device found in search, or %NULL for new search.
  *
  * Iterates through the list of known PCI devices.  If a PCI device is
- * found with a matching @vendor and @device, a pointer to its device structure is
- * returned.  Otherwise, %NULL is returned.
- * A new search is initiated by passing %NULL to the @from argument.
- * Otherwise if @from is not %NULL, searches continue from next device on the global list.
- *
- * Iterates through the list of known PCI devices.  If a PCI device is
  * found with a matching @vendor and @device, the reference count to the
  * device is incremented and a pointer to its device structure is returned.
  * Otherwise, %NULL is returned.  A new search is initiated by passing %NULL
@@ -312,25 +308,26 @@
 	return dev;
 }
 
-
 /**
- * pci_find_class - begin or continue searching for a PCI device by class
+ * pci_get_class - begin or continue searching for a PCI device by class
  * @class: search for a PCI device with this class designation
  * @from: Previous PCI device found in search, or %NULL for new search.
  *
  * Iterates through the list of known PCI devices.  If a PCI device is
- * found with a matching @class, a pointer to its device structure is
- * returned.  Otherwise, %NULL is returned.
+ * found with a matching @class, the reference count to the device is
+ * incremented and a pointer to its device structure is returned.
+ * Otherwise, %NULL is returned.
  * A new search is initiated by passing %NULL to the @from argument.
  * Otherwise if @from is not %NULL, searches continue from next device
- * on the global list.
+ * on the global list.  The reference count for @from is always decremented
+ * if it is not %NULL.
  */
-struct pci_dev *
-pci_find_class(unsigned int class, const struct pci_dev *from)
+struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
 {
 	struct list_head *n;
 	struct pci_dev *dev;
 
+	WARN_ON(in_interrupt());
 	spin_lock(&pci_bus_lock);
 	n = from ? from->global_list.next : pci_devices.next;
 
@@ -342,16 +339,50 @@
 	}
 	dev = NULL;
 exit:
+	pci_dev_put(from);
+	dev = pci_dev_get(dev);
 	spin_unlock(&pci_bus_lock);
 	return dev;
 }
 
+/**
+ * pci_dev_present - Returns 1 if device matching the device list is present, 0 if not.
+ * @ids: A pointer to a null terminated list of struct pci_device_id structures
+ * that describe the type of PCI device the caller is trying to find.
+ *
+ * Obvious fact: You do not have a reference to any device that might be found
+ * by this function, so if that device is removed from the system right after
+ * this function is finished, the value will be stale.  Use this function to
+ * find devices that are usually built into a system, or for a general hint as
+ * to if another device happens to be present at this specific moment in time.
+ */
+int pci_dev_present(const struct pci_device_id *ids)
+{
+	struct pci_dev *dev;
+	int found = 0;
+
+	WARN_ON(in_interrupt());
+	spin_lock(&pci_bus_lock);
+	while (ids->vendor || ids->subvendor || ids->class_mask) {
+		list_for_each_entry(dev, &pci_devices, global_list) {
+			if (pci_match_one_device(ids, dev)) {
+				found = 1;
+				goto exit;
+			}
+		}
+		ids++;
+	}
+exit:				
+	spin_unlock(&pci_bus_lock);
+	return found;
+}
+EXPORT_SYMBOL(pci_dev_present);
+
 EXPORT_SYMBOL(pci_find_bus);
-EXPORT_SYMBOL(pci_find_class);
 EXPORT_SYMBOL(pci_find_device);
 EXPORT_SYMBOL(pci_find_device_reverse);
 EXPORT_SYMBOL(pci_find_slot);
-EXPORT_SYMBOL(pci_find_subsys);
 EXPORT_SYMBOL(pci_get_device);
 EXPORT_SYMBOL(pci_get_subsys);
 EXPORT_SYMBOL(pci_get_slot);
+EXPORT_SYMBOL(pci_get_class);
diff -Nru a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
--- a/drivers/pci/setup-bus.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/pci/setup-bus.c	2004-12-24 13:37:29 -08:00
@@ -533,16 +533,16 @@
 void __init
 pci_assign_unassigned_resources(void)
 {
-	struct list_head *ln;
+	struct pci_bus *bus;
 
 	/* Depth first, calculate sizes and alignments of all
 	   subordinate buses. */
-	list_for_each(ln, &pci_root_buses) {
-		pci_bus_size_bridges(pci_bus_b(ln));
+	list_for_each_entry(bus, &pci_root_buses, node) {
+		pci_bus_size_bridges(bus);
 	}
 	/* Depth last, allocate resources and update the hardware. */
-	list_for_each(ln, &pci_root_buses) {
-		pci_bus_assign_resources(pci_bus_b(ln));
-		pci_enable_bridges(pci_bus_b(ln));
+	list_for_each_entry(bus, &pci_root_buses, node) {
+		pci_bus_assign_resources(bus);
+		pci_enable_bridges(bus);
 	}
 }
diff -Nru a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c
--- a/drivers/pci/setup-irq.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/pci/setup-irq.c	2004-12-24 13:36:48 -08:00
@@ -65,7 +65,7 @@
 	       int (*map_irq)(struct pci_dev *, u8, u8))
 {
 	struct pci_dev *dev = NULL;
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
 		pdev_fixup_irq(dev, swizzle, map_irq);
 	}
 }
diff -Nru a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
--- a/drivers/pci/setup-res.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/pci/setup-res.c	2004-12-24 13:37:19 -08:00
@@ -56,7 +56,7 @@
 	if (resno < 6) {
 		reg = PCI_BASE_ADDRESS_0 + 4 * resno;
 	} else if (resno == PCI_ROM_RESOURCE) {
-		new |= res->flags & PCI_ROM_ADDRESS_ENABLE;
+		new |= res->flags & IORESOURCE_ROM_ENABLE;
 		reg = dev->rom_base_reg;
 	} else {
 		/* Hmm, non-standard resource. */
diff -Nru a/drivers/pci/syscall.c b/drivers/pci/syscall.c
--- a/drivers/pci/syscall.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/pci/syscall.c	2004-12-24 13:36:18 -08:00
@@ -11,12 +11,14 @@
 #include <linux/errno.h>
 #include <linux/pci.h>
 #include <linux/smp_lock.h>
+#include <linux/syscalls.h>
 #include <asm/uaccess.h>
 
 
 asmlinkage long
 sys_pciconfig_read(unsigned long bus, unsigned long dfn,
-		   unsigned long off, unsigned long len, void *buf)
+		   unsigned long off, unsigned long len,
+		   void __user *buf)
 {
 	struct pci_dev *dev;
 	u8 byte;
@@ -88,7 +90,8 @@
 
 asmlinkage long
 sys_pciconfig_write(unsigned long bus, unsigned long dfn,
-		    unsigned long off, unsigned long len, void *buf)
+		    unsigned long off, unsigned long len,
+		    void __user *buf)
 {
 	struct pci_dev *dev;
 	u8 byte;
diff -Nru a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
--- a/drivers/pcmcia/Kconfig	2004-12-24 13:37:04 -08:00
+++ b/drivers/pcmcia/Kconfig	2004-12-24 13:37:04 -08:00
@@ -5,30 +5,24 @@
 # by the integrated kernel driver.
 #
 
-menu "PCMCIA/CardBus support"
+menu "PCCARD (PCMCIA/CardBus) support"
 	depends on HOTPLUG
 
-config PCMCIA
-	tristate "PCMCIA/CardBus support"
+config PCCARD
+	tristate "PCCard (PCMCIA/CardBus) support"
 	---help---
 	  Say Y here if you want to attach PCMCIA- or PC-cards to your Linux
 	  computer.  These are credit-card size devices such as network cards,
 	  modems or hard drives often used with laptops computers.  There are
 	  actually two varieties of these cards: the older 16 bit PCMCIA cards
-	  and the newer 32 bit CardBus cards.  If you want to use CardBus
-	  cards, you need to say Y here and also to "CardBus support" below.
-
-	  To use your PC-cards, you will need supporting software from David
-	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
-	  for location).  Please also read the PCMCIA-HOWTO, available from
-	  <http://www.tldp.org/docs.html#howto>.
+	  and the newer 32 bit CardBus cards.
 
 	  To compile this driver as modules, choose M here: the
-	  modules will be called pcmcia_core and ds.
+	  module will be called pcmcia_core.
 
 config PCMCIA_DEBUG
-	bool "Enable PCMCIA debugging"
-	depends on PCMCIA != n
+	bool "Enable PCCARD debugging"
+	depends on PCCARD != n
 	help
 	  Say Y here to enable PCMCIA subsystem debugging.  You
 	  will need to choose the debugging level either via the
@@ -45,29 +39,69 @@
 	  In all the above examples, N is the debugging verbosity
 	  level.
 
-config YENTA
-	tristate "CardBus yenta-compatible bridge support"
-	depends on PCMCIA && PCI
+config PCMCIA_OBSOLETE
+	bool "Enable obsolete PCCARD code"
+	depends on PCCARD != n
+	help
+	  Say Y here to enable some code found in the PCCARD subsystem
+	  which has no in-kernel usage, but might be needed for certain
+	  external PCMCIA drivers. If you do need to say Y here so that
+	  one such driver compiles and/or works correctly, please report
+	  this to linux-pcmcia <at> lists.infradead.org
+
+	  If unsure, say N
+
+config PCMCIA
+	tristate "16-bit PCMCIA support"
+	depends on PCCARD
+	default y
+	---help---
+	   This option enables support for 16-bit PCMCIA cards. Most older
+	   PC-cards are such 16-bit PCMCIA cards, so unless you know you're
+	   only using 32-bit CardBus cards, say Y or M here.
+
+	   To use 16-bit PCMCIA cards, you will need supporting software from 
+	   David Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
+ 	   for location).  Please also read the PCMCIA-HOWTO, available from
+	   <http://www.tldp.org/docs.html#howto>.
+
+	   To compile this driver as modules, choose M here: the
+	   module will be called pcmcia.
+
+	   If unsure, say Y.
+
+config CARDBUS
+	bool "32-bit CardBus support"	
+	depends on PCCARD && PCI
+	default y
 	---help---
 	  CardBus is a bus mastering architecture for PC-cards, which allows
 	  for 32 bit PC-cards (the original PCMCIA standard specifies only
 	  a 16 bit wide bus). Many newer PC-cards are actually CardBus cards.
 
-	  This option enables support for CardBus PC Cards, as well as support
-	  for CardBus host bridges.  Virtually all modern PCMCIA bridges are
-	  CardBus compatible.  A "bridge" is the hardware inside your computer
-	  that PCMCIA cards are plugged into.
-
-	  To use your PC-cards, you will need supporting software from David
-	  Hinds' pcmcia-cs package (see the file <file:Documentation/Changes>
-	  for location).
+	  To use 32 bit PC-cards, you also need a CardBus compatible host
+	  bridge. Virtually all modern PCMCIA bridges do this, and most of
+	  them are "yenta-compatible", so say Y or M there, too.
 
 	  If unsure, say Y.
 
-config CARDBUS
-	bool
-	depends on YENTA
-	default y if YENTA
+comment "PC-card bridges"
+
+config YENTA
+	tristate "CardBus yenta-compatible bridge support"
+	depends on PCCARD && PCI
+#fixme: remove dependendcy on CARDBUS
+	depends on CARDBUS
+	---help---
+	  This option enables support for CardBus host bridges.  Virtually
+	  all modern PCMCIA bridges are CardBus compatible.  A "bridge" is 
+	  the hardware inside your computer that PCMCIA cards are plugged 
+	  into.
+
+	  To compile this driver as modules, choose M here: the
+	  module will be called yenta_socket.
+
+	  If unsure, say Y.
 
 config PD6729
 	tristate "Cirrus PD6729 compatible bridge support"
@@ -133,10 +167,27 @@
 	help
 	  Say Y here to include support for the PXA2xx PCMCIA controller
 
-
 config PCMCIA_PROBE
 	bool
 	default y if ISA && !ARCH_SA1100 && !ARCH_CLPS711X
 
-endmenu
+config M32R_PCC
+	bool "M32R PCMCIA I/F"
+	depends on M32R && CHIP_M32700 && PCMCIA
+	help
+	  Say Y here to use the M32R PCMCIA controller.
+
+config M32R_CFC
+	bool "M32R CF I/F Controller"
+	depends on M32R && (PLAT_USRV || PLAT_M32700UT || PLAT_MAPPI2 || PLAT_OPSPUT)
+	help
+	  Say Y here to use the M32R CompactFlash controller.
 
+config M32R_CFC_NUM
+	int "M32R CF I/F number"
+	depends on M32R_CFC
+	default "1" if PLAT_USRV || PLAT_M32700UT || PLAT_MAPPI2 || PLAT_OPSPUT
+	help
+	  Set the number of M32R CF slots.
+
+endmenu
diff -Nru a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
--- a/drivers/pcmcia/Makefile	2004-12-24 13:37:18 -08:00
+++ b/drivers/pcmcia/Makefile	2004-12-24 13:37:18 -08:00
@@ -6,7 +6,16 @@
 EXTRA_CFLAGS += -DDEBUG
 endif
 
-obj-$(CONFIG_PCMCIA)				+= pcmcia_core.o ds.o
+pcmcia_core-y					+= cs.o cistpl.o rsrc_mgr.o socket_sysfs.o
+pcmcia_core-$(CONFIG_CARDBUS)			+= cardbus.o
+obj-$(CONFIG_PCCARD)				+= pcmcia_core.o
+
+pcmcia-y					+= ds.o bulkmem.o pcmcia_compat.o
+obj-$(CONFIG_PCMCIA)				+= pcmcia.o
+
+
+# socket drivers
+
 obj-$(CONFIG_YENTA) 				+= yenta_socket.o
 
 obj-$(CONFIG_PD6729)				+= pd6729.o
@@ -17,36 +26,23 @@
 obj-$(CONFIG_PCMCIA_SA1100)			+= sa11xx_core.o sa1100_cs.o
 obj-$(CONFIG_PCMCIA_SA1111)			+= sa11xx_core.o sa1111_cs.o
 obj-$(CONFIG_PCMCIA_PXA2XX)                     += pxa2xx_core.o pxa2xx_cs.o
-
-pcmcia_core-y					+= cistpl.o rsrc_mgr.o bulkmem.o cs.o socket_sysfs.o
-pcmcia_core-$(CONFIG_CARDBUS)			+= cardbus.o
+obj-$(CONFIG_M32R_PCC)				+= m32r_pcc.o
+obj-$(CONFIG_M32R_CFC)				+= m32r_cfc.o
 
 sa11xx_core-y					+= soc_common.o sa11xx_base.o
 pxa2xx_core-y					+= soc_common.o pxa2xx_base.o
 
 sa1111_cs-y					+= sa1111_generic.o
-sa1111_cs-$(CONFIG_SA1100_ADSBITSY)		+= sa1100_adsbitsy.o
 sa1111_cs-$(CONFIG_ASSABET_NEPONSET)		+= sa1100_neponset.o
 sa1111_cs-$(CONFIG_SA1100_BADGE4)		+= sa1100_badge4.o
-sa1111_cs-$(CONFIG_SA1100_GRAPHICSMASTER)	+= sa1100_graphicsmaster.o
 sa1111_cs-$(CONFIG_SA1100_JORNADA720)		+= sa1100_jornada720.o
-sa1111_cs-$(CONFIG_SA1100_PFS168)		+= sa1100_pfs168.o
-sa1111_cs-$(CONFIG_SA1100_PT_SYSTEM3)		+= sa1100_system3.o
-sa1111_cs-$(CONFIG_SA1100_XP860)		+= sa1100_xp860.o
 
 sa1100_cs-y					+= sa1100_generic.o
 sa1100_cs-$(CONFIG_SA1100_ASSABET)		+= sa1100_assabet.o
 sa1100_cs-$(CONFIG_SA1100_CERF)			+= sa1100_cerf.o
-sa1100_cs-$(CONFIG_SA1100_FLEXANET)		+= sa1100_flexanet.o
-sa1100_cs-$(CONFIG_SA1100_FREEBIRD)		+= sa1100_freebird.o
-sa1100_cs-$(CONFIG_SA1100_GRAPHICSCLIENT)	+= sa1100_graphicsclient.o
 sa1100_cs-$(CONFIG_SA1100_H3600)		+= sa1100_h3600.o
-sa1100_cs-$(CONFIG_SA1100_PANGOLIN)		+= sa1100_pangolin.o
 sa1100_cs-$(CONFIG_SA1100_SHANNON)		+= sa1100_shannon.o
 sa1100_cs-$(CONFIG_SA1100_SIMPAD)		+= sa1100_simpad.o
-sa1100_cs-$(CONFIG_SA1100_STORK)		+= sa1100_stork.o
-sa1100_cs-$(CONFIG_SA1100_TRIZEPS) 		+= sa1100_trizeps.o
-sa1100_cs-$(CONFIG_SA1100_YOPY)			+= sa1100_yopy.o
 
 pxa2xx_cs-$(CONFIG_ARCH_LUBBOCK)		+= pxa2xx_lubbock.o sa1111_generic.o
 pxa2xx_cs-$(CONFIG_MACH_MAINSTONE)		+= pxa2xx_mainstone.o
diff -Nru a/drivers/pcmcia/bulkmem.c b/drivers/pcmcia/bulkmem.c
--- a/drivers/pcmcia/bulkmem.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/pcmcia/bulkmem.c	2004-12-24 13:37:43 -08:00
@@ -48,276 +48,18 @@
 #include <pcmcia/cistpl.h>
 #include "cs_internal.h"
 
-static void retry_erase_list(erase_busy_t *list, u_int cause);
-
-/*======================================================================
-
-    This function handles submitting an MTD request, and retrying
-    requests when an MTD is busy.
-
-    An MTD request should never block.
-    
-======================================================================*/
-
-static int do_mtd_request(memory_handle_t handle, mtd_request_t *req,
-			  caddr_t buf)
-{
-    int ret, tries;
-    client_t *mtd;
-    struct pcmcia_socket *s;
-    
-    mtd = handle->mtd;
-    if (mtd == NULL)
-	return CS_GENERAL_FAILURE;
-    s = SOCKET(mtd);
-    for (ret = tries = 0; tries < 100; tries++) {
-	mtd->event_callback_args.mtdrequest = req;
-	mtd->event_callback_args.buffer = buf;
-	ret = EVENT(mtd, CS_EVENT_MTD_REQUEST, CS_EVENT_PRI_LOW);
-	if (ret != CS_BUSY)
-	    break;
-	switch (req->Status) {
-	case MTD_WAITREQ:
-	    /* Not that we should ever need this... */
-	    interruptible_sleep_on_timeout(&mtd->mtd_req, HZ);
-	    break;
-	case MTD_WAITTIMER:
-	case MTD_WAITRDY:
-	    interruptible_sleep_on_timeout(&mtd->mtd_req, req->Timeout*HZ/1000);
-	    req->Function |= MTD_REQ_TIMEOUT;
-	    break;
-	case MTD_WAITPOWER:
-	    interruptible_sleep_on(&mtd->mtd_req);
-	    break;
-	}
-	if (signal_pending(current))
-	    printk(KERN_NOTICE "cs: do_mtd_request interrupted!\n");
-    }
-    if (tries == 20) {
-	printk(KERN_NOTICE "cs: MTD request timed out!\n");
-	ret = CS_GENERAL_FAILURE;
-    }
-    wake_up_interruptible(&mtd->mtd_req);
-    retry_erase_list(&mtd->erase_busy, 0);
-    return ret;
-} /* do_mtd_request */
-
-/*======================================================================
-
-    This stuff is all for handling asynchronous erase requests.  It
-    is complicated because all the retry stuff has to be dealt with
-    in timer interrupts or in the card status event handler.
-
-======================================================================*/
-
-static void insert_queue(struct pcmcia_socket *s, erase_busy_t *head, erase_busy_t *entry)
-{
-    cs_dbg(s, 2, "adding 0x%p to queue 0x%p\n", entry, head);
-    entry->next = head;
-    entry->prev = head->prev;
-    head->prev->next = entry;
-    head->prev = entry;
-}
-
-static void remove_queue(struct pcmcia_socket *s, erase_busy_t *entry)
-{
-    cs_dbg(s, 2, "unqueueing 0x%p\n", entry);
-    entry->next->prev = entry->prev;
-    entry->prev->next = entry->next;
-}
-
-static void retry_erase(erase_busy_t *busy, u_int cause)
-{
-    eraseq_entry_t *erase = busy->erase;
-    mtd_request_t req;
-    client_t *mtd;
-    struct pcmcia_socket *s;
-    int ret;
-
-    mtd = erase->Handle->mtd;
-    s = SOCKET(mtd);
-
-    cs_dbg(s, 2, "trying erase request 0x%p...\n", busy);
-    if (busy->next)
-	remove_queue(s, busy);
-    req.Function = MTD_REQ_ERASE | cause;
-    req.TransferLength = erase->Size;
-    req.DestCardOffset = erase->Offset + erase->Handle->info.CardOffset;
-    req.MediaID = erase->Handle->MediaID;
-    mtd->event_callback_args.mtdrequest = &req;
-    ret = EVENT(mtd, CS_EVENT_MTD_REQUEST, CS_EVENT_PRI_LOW);
-    if (ret == CS_BUSY) {
-	cs_dbg(s, 2, "  Status = %d, requeueing.\n", req.Status);
-	switch (req.Status) {
-	case MTD_WAITREQ:
-	case MTD_WAITPOWER:
-	    insert_queue(s, &mtd->erase_busy, busy);
-	    break;
-	case MTD_WAITTIMER:
-	case MTD_WAITRDY:
-	    if (req.Status == MTD_WAITRDY)
-		insert_queue(s, &s->erase_busy, busy);
-	    mod_timer(&busy->timeout, jiffies + req.Timeout*HZ/1000);
-	    break;
-	}
-    } else {
-	/* update erase queue status */
-	cs_dbg(s, 2, "  Ret = %d\n", ret);
-	switch (ret) {
-	case CS_SUCCESS:
-	    erase->State = ERASE_PASSED; break;
-	case CS_WRITE_PROTECTED:
-	    erase->State = ERASE_MEDIA_WRPROT; break;
-	case CS_BAD_OFFSET:
-	    erase->State = ERASE_BAD_OFFSET; break;
-	case CS_BAD_SIZE:
-	    erase->State = ERASE_BAD_SIZE; break;
-	case CS_NO_CARD:
-	    erase->State = ERASE_BAD_SOCKET; break;
-	default:
-	    erase->State = ERASE_FAILED; break;
-	}
-	busy->client->event_callback_args.info = erase;
-	EVENT(busy->client, CS_EVENT_ERASE_COMPLETE, CS_EVENT_PRI_LOW);
-	kfree(busy);
-	/* Resubmit anything waiting for a request to finish */
-	wake_up_interruptible(&mtd->mtd_req);
-	retry_erase_list(&mtd->erase_busy, 0);
-    }
-} /* retry_erase */
-
-static void retry_erase_list(erase_busy_t *list, u_int cause)
-{
-    erase_busy_t tmp = *list;
-
-    cs_dbg(SOCKET(list->client), 2, "rescanning erase queue list 0x%p\n", list);
-    if (list->next == list)
-	return;
-    /* First, truncate the original list */
-    list->prev->next = &tmp;
-    list->next->prev = &tmp;
-    list->prev = list->next = list;
-    tmp.prev->next = &tmp;
-    tmp.next->prev = &tmp;
-
-    /* Now, retry each request, in order. */
-    while (tmp.next != &tmp)
-	retry_erase(tmp.next, cause);
-} /* retry_erase_list */
-
-static void handle_erase_timeout(u_long arg)
-{
-    erase_busy_t *busy = (erase_busy_t *)arg;
-    cs_dbg(SOCKET(busy->client), 0, "erase timeout for entry 0x%lx\n", arg);
-    retry_erase(busy, MTD_REQ_TIMEOUT);
-}
-
-static void setup_erase_request(client_handle_t handle, eraseq_entry_t *erase)
-{
-    erase_busy_t *busy;
-    region_info_t *info;
-    
-    if (CHECK_REGION(erase->Handle))
-	erase->State = ERASE_BAD_SOCKET;
-    else {
-	info = &erase->Handle->info;
-	if ((erase->Offset >= info->RegionSize) ||
-	    (erase->Offset & (info->BlockSize-1)))
-	    erase->State = ERASE_BAD_OFFSET;
-	else if ((erase->Offset+erase->Size > info->RegionSize) ||
-		 (erase->Size & (info->BlockSize-1)))
-	    erase->State = ERASE_BAD_SIZE;
-	else {
-	    erase->State = 1;
-	    busy = kmalloc(sizeof(erase_busy_t), GFP_KERNEL);
-	    if (!busy) {
-		erase->State = ERASE_FAILED;
-		return;
-	    }
-	    busy->erase = erase;
-	    busy->client = handle;
-	    init_timer(&busy->timeout);
-	    busy->timeout.data = (u_long)busy;
-	    busy->timeout.function = &handle_erase_timeout;
-	    busy->prev = busy->next = NULL;
-	    retry_erase(busy, 0);
-	}
-    }
-} /* setup_erase_request */
-
-/*======================================================================
-
-    MTD helper functions
-
-======================================================================*/
-
-static int mtd_modify_window(window_handle_t win, mtd_mod_win_t *req)
-{
-    if ((win == NULL) || (win->magic != WINDOW_MAGIC))
-	return CS_BAD_HANDLE;
-    win->ctl.flags = MAP_16BIT | MAP_ACTIVE;
-    if (req->Attributes & WIN_USE_WAIT)
-	win->ctl.flags |= MAP_USE_WAIT;
-    if (req->Attributes & WIN_MEMORY_TYPE)
-	win->ctl.flags |= MAP_ATTRIB;
-    win->ctl.speed = req->AccessSpeed;
-    win->ctl.card_start = req->CardOffset;
-    win->sock->ops->set_mem_map(win->sock, &win->ctl);
-    return CS_SUCCESS;
-}
-
-static int mtd_set_vpp(client_handle_t handle, mtd_vpp_req_t *req)
-{
-    struct pcmcia_socket *s;
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
-    if (req->Vpp1 != req->Vpp2)
-	return CS_BAD_VPP;
-    s = SOCKET(handle);
-    s->socket.Vpp = req->Vpp1;
-    if (s->ops->set_socket(s, &s->socket))
-	return CS_BAD_VPP;
-    return CS_SUCCESS;
-}
-
-static int mtd_rdy_mask(client_handle_t handle, mtd_rdy_req_t *req)
-{
-    struct pcmcia_socket *s;
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
-    s = SOCKET(handle);
-    if (req->Mask & CS_EVENT_READY_CHANGE)
-	s->socket.csc_mask |= SS_READY;
-    else
-	s->socket.csc_mask &= ~SS_READY;
-    if (s->ops->set_socket(s, &s->socket))
-	return CS_GENERAL_FAILURE;
-    return CS_SUCCESS;
-}
-
-int MTDHelperEntry(int func, void *a1, void *a2)
-{
-    switch (func) {
-    case MTDRequestWindow:
-    {
-	window_handle_t w;
-        int ret = pcmcia_request_window(a1, a2, &w);
-        a1 = w;
-	return  ret;
-    }
-        break;
-    case MTDReleaseWindow:
-	return pcmcia_release_window(a1);
-    case MTDModifyWindow:
-	return mtd_modify_window(a1, a2); break;
-    case MTDSetVpp:
-	return mtd_set_vpp(a1, a2); break;
-    case MTDRDYMask:
-	return mtd_rdy_mask(a1, a2); break;
-    default:
-	return CS_UNSUPPORTED_FUNCTION; break;
-    }
-} /* MTDHelperEntry */
+#ifdef DEBUG
+extern int ds_pc_debug;
+#define cs_socket_name(skt)	((skt)->dev.class_id)
+
+#define ds_dbg(skt, lvl, fmt, arg...) do {		\
+	if (ds_pc_debug >= lvl)				\
+		printk(KERN_DEBUG "ds: %s: " fmt, 	\
+		       cs_socket_name(skt) , ## arg);	\
+} while (0)
+#else
+#define ds_dbg(lvl, fmt, arg...) do { } while (0)
+#endif
 
 /*======================================================================
 
@@ -327,8 +69,8 @@
     
 ======================================================================*/
 
-static void setup_regions(client_handle_t handle, int attr,
-			  memory_handle_t *list)
+static void setup_regions(struct pcmcia_socket *s, unsigned int function,
+			  int attr,  memory_handle_t *list)
 {
     int i, code, has_jedec, has_geo;
     u_int offset;
@@ -337,22 +79,22 @@
     cistpl_device_geo_t geo;
     memory_handle_t r;
 
-    cs_dbg(SOCKET(handle), 1, "setup_regions(0x%p, %d, 0x%p)\n",
-	   handle, attr, list);
+    ds_dbg(s, 1, "setup_regions(0x%d, %d, 0x%p)\n",
+	   function, attr, list);
 
     code = (attr) ? CISTPL_DEVICE_A : CISTPL_DEVICE;
-    if (read_tuple(handle, code, &device) != CS_SUCCESS)
+    if (pccard_read_tuple(s, function, code, &device) != CS_SUCCESS)
 	return;
     code = (attr) ? CISTPL_JEDEC_A : CISTPL_JEDEC_C;
-    has_jedec = (read_tuple(handle, code, &jedec) == CS_SUCCESS);
+    has_jedec = (pccard_read_tuple(s, function, code, &jedec) == CS_SUCCESS);
     if (has_jedec && (device.ndev != jedec.nid)) {
-	cs_dbg(SOCKET(handle), 0, "Device info does not match JEDEC info.\n");
+	ds_dbg(s, 0, "Device info does not match JEDEC info.\n");
 	has_jedec = 0;
     }
     code = (attr) ? CISTPL_DEVICE_GEO_A : CISTPL_DEVICE_GEO;
-    has_geo = (read_tuple(handle, code, &geo) == CS_SUCCESS);
+    has_geo = (pccard_read_tuple(s, function, code, &geo) == CS_SUCCESS);
     if (has_geo && (device.ndev != geo.ngeo)) {
-	cs_dbg(SOCKET(handle), 0, "Device info does not match geometry tuple.\n");
+	ds_dbg(s, 0, "Device info does not match geometry tuple.\n");
 	has_geo = 0;
     }
     
@@ -400,6 +142,37 @@
     
 ======================================================================*/
 
+static int pccard_match_region(memory_handle_t list, region_info_t *match)
+{
+	if (list) {
+		*match = list->info;
+		return CS_SUCCESS;
+	}
+	return CS_NO_MORE_ITEMS;
+} /* match_region */
+
+int pccard_get_first_region(struct pcmcia_socket *s, region_info_t *rgn)
+{
+	if (!(s->state & SOCKET_REGION_INFO)) {
+		setup_regions(s, BIND_FN_ALL, 0, &s->c_region);
+		setup_regions(s, BIND_FN_ALL, 1, &s->a_region);
+		s->state |= SOCKET_REGION_INFO;
+	}
+
+	if (rgn->Attributes & REGION_TYPE_AM)
+		return pccard_match_region(s->a_region, rgn);
+	else
+		return pccard_match_region(s->c_region, rgn);
+} /* get_first_region */
+
+int pccard_get_next_region(struct pcmcia_socket *s, region_info_t *rgn)
+{
+    return pccard_match_region(rgn->next, rgn);
+} /* get_next_region */
+
+
+#ifdef CONFIG_PCMCIA_OBSOLETE
+
 static int match_region(client_handle_t handle, memory_handle_t list,
 			region_info_t *match)
 {
@@ -422,8 +195,8 @@
     
     if ((handle->Attributes & INFO_MASTER_CLIENT) &&
 	(!(s->state & SOCKET_REGION_INFO))) {
-	setup_regions(handle, 0, &s->c_region);
-	setup_regions(handle, 1, &s->a_region);
+	setup_regions(s, handle->Function, 0, &s->c_region);
+	setup_regions(s, handle->Function, 1, &s->a_region);
 	s->state |= SOCKET_REGION_INFO;
     }
 
@@ -432,6 +205,7 @@
     else
 	return match_region(handle, s->c_region, rgn);
 } /* get_first_region */
+EXPORT_SYMBOL(pcmcia_get_first_region);
 
 int pcmcia_get_next_region(client_handle_t handle, region_info_t *rgn)
 {
@@ -439,200 +213,6 @@
 	return CS_BAD_HANDLE;
     return match_region(handle, rgn->next, rgn);
 } /* get_next_region */
+EXPORT_SYMBOL(pcmcia_get_next_region);
 
-/*======================================================================
-
-    Connect an MTD with a memory region.
-    
-======================================================================*/
-
-int pcmcia_register_mtd(client_handle_t handle, mtd_reg_t *reg)
-{
-    memory_handle_t list;
-    struct pcmcia_socket *s;
-    
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
-    s = SOCKET(handle);
-    if (reg->Attributes & REGION_TYPE_AM)
-	list = s->a_region;
-    else
-	list = s->c_region;
-    cs_dbg(s, 1, "register_mtd(0x%p, '%s', 0x%x)\n",
-	  handle, handle->dev_info, reg->Offset);
-    while (list) {
-	if (list->info.CardOffset == reg->Offset) break;
-	list = list->info.next;
-    }
-    if (list && (list->mtd == NULL) &&
-	(strcmp(handle->dev_info, list->dev_info) == 0)) {
-	list->info.Attributes = reg->Attributes;
-	list->MediaID = reg->MediaID;
-	list->mtd = handle;
-	handle->mtd_count++;
-	return CS_SUCCESS;
-    } else
-	return CS_BAD_OFFSET;
-} /* register_mtd */
-
-/*======================================================================
-
-    Erase queue management functions
-    
-======================================================================*/
-
-int pcmcia_register_erase_queue(client_handle_t *handle, eraseq_hdr_t *header,
-                                 eraseq_handle_t *e)
-{
-    eraseq_t *queue;
-
-    if ((handle == NULL) || CHECK_HANDLE(*handle))
-	return CS_BAD_HANDLE;
-    queue = kmalloc(sizeof(*queue), GFP_KERNEL);
-    if (!queue) return CS_OUT_OF_RESOURCE;
-    queue->eraseq_magic = ERASEQ_MAGIC;
-    queue->handle = *handle;
-    queue->count = header->QueueEntryCnt;
-    queue->entry = header->QueueEntryArray;
-    *e = queue;
-    return CS_SUCCESS;
-} /* register_erase_queue */
-
-int pcmcia_deregister_erase_queue(eraseq_handle_t eraseq)
-{
-    int i;
-    if (CHECK_ERASEQ(eraseq))
-	return CS_BAD_HANDLE;
-    for (i = 0; i < eraseq->count; i++)
-	if (ERASE_IN_PROGRESS(eraseq->entry[i].State)) break;
-    if (i < eraseq->count)
-	return CS_BUSY;
-    eraseq->eraseq_magic = 0;
-    kfree(eraseq);
-    return CS_SUCCESS;
-} /* deregister_erase_queue */
-
-int pcmcia_check_erase_queue(eraseq_handle_t eraseq)
-{
-    int i;
-    if (CHECK_ERASEQ(eraseq))
-	return CS_BAD_HANDLE;
-    for (i = 0; i < eraseq->count; i++)
-	if (eraseq->entry[i].State == ERASE_QUEUED)
-	    setup_erase_request(eraseq->handle, &eraseq->entry[i]);
-    return CS_SUCCESS;
-} /* check_erase_queue */
-
-/*======================================================================
-
-    Look up the memory region matching the request, and return a
-    memory handle.
-    
-======================================================================*/
-
-int pcmcia_open_memory(client_handle_t *handle, open_mem_t *open, memory_handle_t *mh)
-{
-    struct pcmcia_socket *s;
-    memory_handle_t region;
-    
-    if ((handle == NULL) || CHECK_HANDLE(*handle))
-	return CS_BAD_HANDLE;
-    s = (*handle)->Socket;
-    if (open->Attributes & MEMORY_TYPE_AM)
-	region = s->a_region;
-    else
-	region = s->c_region;
-    while (region) {
-	if (region->info.CardOffset == open->Offset) break;
-	region = region->info.next;
-    }
-    if (region && region->mtd) {
-	*mh = region;
-	cs_dbg(s, 1, "open_memory(0x%p, 0x%x) = 0x%p\n",
-	       handle, open->Offset, region);
-	return CS_SUCCESS;
-    } else
-	return CS_BAD_OFFSET;
-} /* open_memory */
-
-/*======================================================================
-
-    Close a memory handle from an earlier call to OpenMemory.
-    
-    For the moment, I don't think this needs to do anything.
-    
-======================================================================*/
-
-int pcmcia_close_memory(memory_handle_t handle)
-{
-    cs_dbg(SOCKET(handle->mtd), 1, "cs: close_memory(0x%p)\n", handle);
-    if (CHECK_REGION(handle))
-	return CS_BAD_HANDLE;
-    return CS_SUCCESS;
-} /* close_memory */
-
-/*======================================================================
-
-    Read from a memory device, using a handle previously returned
-    by a call to OpenMemory.
-    
-======================================================================*/
-
-int pcmcia_read_memory(memory_handle_t handle, mem_op_t *req, caddr_t buf)
-{
-    mtd_request_t mtd;
-    if (CHECK_REGION(handle))
-	return CS_BAD_HANDLE;
-    if (req->Offset >= handle->info.RegionSize)
-	return CS_BAD_OFFSET;
-    if (req->Offset+req->Count > handle->info.RegionSize)
-	return CS_BAD_SIZE;
-    
-    mtd.SrcCardOffset = req->Offset + handle->info.CardOffset;
-    mtd.TransferLength = req->Count;
-    mtd.MediaID = handle->MediaID;
-    mtd.Function = MTD_REQ_READ;
-    if (req->Attributes & MEM_OP_BUFFER_KERNEL)
-	mtd.Function |= MTD_REQ_KERNEL;
-    return do_mtd_request(handle, &mtd, buf);
-} /* read_memory */
-
-/*======================================================================
-
-    Write to a memory device, using a handle previously returned by
-    a call to OpenMemory.
-    
-======================================================================*/
-
-int pcmcia_write_memory(memory_handle_t handle, mem_op_t *req, caddr_t buf)
-{
-    mtd_request_t mtd;
-    if (CHECK_REGION(handle))
-	return CS_BAD_HANDLE;
-    if (req->Offset >= handle->info.RegionSize)
-	return CS_BAD_OFFSET;
-    if (req->Offset+req->Count > handle->info.RegionSize)
-	return CS_BAD_SIZE;
-    
-    mtd.DestCardOffset = req->Offset + handle->info.CardOffset;
-    mtd.TransferLength = req->Count;
-    mtd.MediaID = handle->MediaID;
-    mtd.Function = MTD_REQ_WRITE;
-    if (req->Attributes & MEM_OP_BUFFER_KERNEL)
-	mtd.Function |= MTD_REQ_KERNEL;
-    return do_mtd_request(handle, &mtd, buf);
-} /* write_memory */
-
-/*======================================================================
-
-    This isn't needed for anything I could think of.
-    
-======================================================================*/
-
-int pcmcia_copy_memory(memory_handle_t handle, copy_op_t *req)
-{
-    if (CHECK_REGION(handle))
-	return CS_BAD_HANDLE;
-    return CS_UNSUPPORTED_FUNCTION;
-}
-
+#endif
diff -Nru a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
--- a/drivers/pcmcia/cistpl.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/pcmcia/cistpl.c	2004-12-24 13:36:33 -08:00
@@ -331,6 +331,14 @@
 		list_del(&cis->node);
 		kfree(cis);
 	}
+
+	/*
+	 * If there was a fake CIS, destroy that as well.
+	 */
+	if (s->fake_cis) {
+		kfree(s->fake_cis);
+		s->fake_cis = NULL;
+	}
 }
 
 /*======================================================================
@@ -376,12 +384,8 @@
     
 ======================================================================*/
 
-int pcmcia_replace_cis(client_handle_t handle, cisdump_t *cis)
+int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis)
 {
-    struct pcmcia_socket *s;
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
-    s = SOCKET(handle);
     if (s->fake_cis != NULL) {
 	kfree(s->fake_cis);
 	s->fake_cis = NULL;
@@ -414,14 +418,12 @@
 #define MFC_FN(f)	(((tuple_flags *)(&(f)))->mfc_fn)
 #define SPACE(f)	(((tuple_flags *)(&(f)))->space)
 
-int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple);
+int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple);
 
-int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple)
+int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple)
 {
-    struct pcmcia_socket *s;
-    if (CHECK_HANDLE(handle))
+    if (!s)
 	return CS_BAD_HANDLE;
-    s = SOCKET(handle);
     if (!(s->state & SOCKET_PRESENT))
 	return CS_NO_CARD;
     tuple->TupleLink = tuple->Flags = 0;
@@ -443,16 +445,17 @@
 	!(tuple->Attributes & TUPLE_RETURN_COMMON)) {
 	cisdata_t req = tuple->DesiredTuple;
 	tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
-	if (pcmcia_get_next_tuple(handle, tuple) == CS_SUCCESS) {
+	if (pccard_get_next_tuple(s, function, tuple) == CS_SUCCESS) {
 	    tuple->DesiredTuple = CISTPL_LINKTARGET;
-	    if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
+	    if (pccard_get_next_tuple(s, function, tuple) != CS_SUCCESS)
 		return CS_NO_MORE_ITEMS;
 	} else
 	    tuple->CISOffset = tuple->TupleLink = 0;
 	tuple->DesiredTuple = req;
     }
-    return pcmcia_get_next_tuple(handle, tuple);
+    return pccard_get_next_tuple(s, function, tuple);
 }
+EXPORT_SYMBOL(pccard_get_first_tuple);
 
 static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
 {
@@ -494,15 +497,13 @@
     return -1;
 }
 
-int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple)
+int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple)
 {
-    struct pcmcia_socket *s;
     u_char link[2], tmp;
     int ofs, i, attr;
-    
-    if (CHECK_HANDLE(handle))
+
+    if (!s)
 	return CS_BAD_HANDLE;
-    s = SOCKET(handle);
     if (!(s->state & SOCKET_PRESENT))
 	return CS_NO_CARD;
 
@@ -554,14 +555,14 @@
 	    case CISTPL_LONGLINK_MFC:
 		tuple->LinkOffset = ofs + 3;
 		LINK_SPACE(tuple->Flags) = attr;
-		if (handle->Function == BIND_FN_ALL) {
+		if (function == BIND_FN_ALL) {
 		    /* Follow all the MFC links */
 		    read_cis_cache(s, attr, ofs+2, 1, &tmp);
 		    MFC_FN(tuple->Flags) = tmp;
 		} else {
 		    /* Follow exactly one of the links */
 		    MFC_FN(tuple->Flags) = 1;
-		    tuple->LinkOffset += handle->Function * 5;
+		    tuple->LinkOffset += function * 5;
 		}
 		break;
 	    case CISTPL_NO_LINK:
@@ -589,20 +590,18 @@
     tuple->CISOffset = ofs + 2;
     return CS_SUCCESS;
 }
+EXPORT_SYMBOL(pccard_get_next_tuple);
 
 /*====================================================================*/
 
 #define _MIN(a, b)		(((a) < (b)) ? (a) : (b))
 
-int pcmcia_get_tuple_data(client_handle_t handle, tuple_t *tuple)
+int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple)
 {
-    struct pcmcia_socket *s;
     u_int len;
-    
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
 
-    s = SOCKET(handle);
+    if (!s)
+	return CS_BAD_HANDLE;
 
     if (tuple->TupleLink < tuple->TupleOffset)
 	return CS_NO_MORE_ITEMS;
@@ -615,6 +614,8 @@
 		   _MIN(len, tuple->TupleDataMax), tuple->TupleData);
     return CS_SUCCESS;
 }
+EXPORT_SYMBOL(pccard_get_tuple_data);
+
 
 /*======================================================================
 
@@ -1320,7 +1321,7 @@
 
 /*====================================================================*/
 
-int pcmcia_parse_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse)
 {
     int ret = CS_SUCCESS;
     
@@ -1401,6 +1402,7 @@
     }
     return ret;
 }
+EXPORT_SYMBOL(pccard_parse_tuple);
 
 /*======================================================================
 
@@ -1408,7 +1410,7 @@
     
 ======================================================================*/
 
-int read_tuple(client_handle_t handle, cisdata_t code, void *parse)
+int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse)
 {
     tuple_t tuple;
     cisdata_t *buf;
@@ -1419,18 +1421,19 @@
 	return CS_OUT_OF_RESOURCE;
     tuple.DesiredTuple = code;
     tuple.Attributes = TUPLE_RETURN_COMMON;
-    ret = pcmcia_get_first_tuple(handle, &tuple);
+    ret = pccard_get_first_tuple(s, function, &tuple);
     if (ret != CS_SUCCESS) goto done;
     tuple.TupleData = buf;
     tuple.TupleOffset = 0;
     tuple.TupleDataMax = 255;
-    ret = pcmcia_get_tuple_data(handle, &tuple);
+    ret = pccard_get_tuple_data(s, &tuple);
     if (ret != CS_SUCCESS) goto done;
-    ret = pcmcia_parse_tuple(handle, &tuple, parse);
+    ret = pccard_parse_tuple(&tuple, parse);
 done:
     kfree(buf);
     return ret;
 }
+EXPORT_SYMBOL(pccard_read_tuple);
 
 /*======================================================================
 
@@ -1442,14 +1445,15 @@
     
 ======================================================================*/
 
-int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info)
+int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_t *info)
 {
     tuple_t *tuple;
     cisparse_t *p;
     int ret, reserved, dev_ok = 0, ident_ok = 0;
 
-    if (CHECK_HANDLE(handle))
+    if (!s)
 	return CS_BAD_HANDLE;
+
     tuple = kmalloc(sizeof(*tuple), GFP_KERNEL);
     if (tuple == NULL)
 	return CS_OUT_OF_RESOURCE;
@@ -1462,30 +1466,30 @@
     info->Chains = reserved = 0;
     tuple->DesiredTuple = RETURN_FIRST_TUPLE;
     tuple->Attributes = TUPLE_RETURN_COMMON;
-    ret = pcmcia_get_first_tuple(handle, tuple);
+    ret = pccard_get_first_tuple(s, function, tuple);
     if (ret != CS_SUCCESS)
 	goto done;
 
     /* First tuple should be DEVICE; we should really have either that
        or a CFTABLE_ENTRY of some sort */
     if ((tuple->TupleCode == CISTPL_DEVICE) ||
-	(read_tuple(handle, CISTPL_CFTABLE_ENTRY, p) == CS_SUCCESS) ||
-	(read_tuple(handle, CISTPL_CFTABLE_ENTRY_CB, p) == CS_SUCCESS))
+	(pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == CS_SUCCESS) ||
+	(pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == CS_SUCCESS))
 	dev_ok++;
 
     /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2
        tuple, for card identification.  Certain old D-Link and Linksys
        cards have only a broken VERS_2 tuple; hence the bogus test. */
-    if ((read_tuple(handle, CISTPL_MANFID, p) == CS_SUCCESS) ||
-	(read_tuple(handle, CISTPL_VERS_1, p) == CS_SUCCESS) ||
-	(read_tuple(handle, CISTPL_VERS_2, p) != CS_NO_MORE_ITEMS))
+    if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == CS_SUCCESS) ||
+	(pccard_read_tuple(s, function, CISTPL_VERS_1, p) == CS_SUCCESS) ||
+	(pccard_read_tuple(s, function, CISTPL_VERS_2, p) != CS_NO_MORE_ITEMS))
 	ident_ok++;
 
     if (!dev_ok && !ident_ok)
 	goto done;
 
     for (info->Chains = 1; info->Chains < MAX_TUPLES; info->Chains++) {
-	ret = pcmcia_get_next_tuple(handle, tuple);
+	ret = pccard_get_next_tuple(s, function, tuple);
 	if (ret != CS_SUCCESS) break;
 	if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) ||
 	    ((tuple->TupleCode > 0x47) && (tuple->TupleCode < 0x80)) ||
@@ -1501,4 +1505,4 @@
     kfree(p);
     return CS_SUCCESS;
 }
-
+EXPORT_SYMBOL(pccard_validate_cis);
diff -Nru a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
--- a/drivers/pcmcia/cs.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/pcmcia/cs.c	2004-12-24 13:36:31 -08:00
@@ -249,7 +249,7 @@
 	/* base address = 0, map = 0 */
 	socket->cis_mem.flags = 0;
 	socket->cis_mem.speed = cis_speed;
-	socket->erase_busy.next = socket->erase_busy.prev = &socket->erase_busy;
+
 	INIT_LIST_HEAD(&socket->cis_cache);
 	spin_lock_init(&socket->lock);
 
@@ -364,10 +364,6 @@
     s->irq.AssignedIRQ = s->irq.Config = 0;
     s->lock_count = 0;
     destroy_cis_cache(s);
-    if (s->fake_cis) {
-	kfree(s->fake_cis);
-	s->fake_cis = NULL;
-    }
 #ifdef CONFIG_CARDBUS
     cb_free(s);
 #endif
@@ -613,10 +609,18 @@
 		 * FIXME: need a better check here for cardbus cards.
 		 */
 		if (verify_cis_cache(skt) != 0) {
+			cs_dbg(skt, 4, "cis mismatch - different card\n");
 			socket_remove_drivers(skt);
 			destroy_cis_cache(skt);
+			/*
+			 * Workaround: give DS time to schedule removal.
+			 * Remove me once the 100ms delay is eliminated
+			 * in ds.c
+			 */
+			msleep(200);
 			send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW);
 		} else {
+			cs_dbg(skt, 4, "cis matches cache\n");
 			send_event(skt, CS_EVENT_PM_RESUME, CS_EVENT_PRI_LOW);
 		}
 	} else {
@@ -846,23 +850,18 @@
     
 ======================================================================*/
 
-int pcmcia_access_configuration_register(client_handle_t handle,
+int pccard_access_configuration_register(struct pcmcia_socket *s,
+					 unsigned int function,
 					 conf_reg_t *reg)
 {
-    struct pcmcia_socket *s;
     config_t *c;
     int addr;
     u_char val;
-    
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
-    s = SOCKET(handle);
-    if (handle->Function == BIND_FN_ALL) {
-	if (reg->Function >= s->functions)
-	    return CS_BAD_ARGS;
-	c = &s->config[reg->Function];
-    } else
-	c = CONFIG(handle);
+
+    if (!s || !s->config)
+	return CS_NO_CARD;    
+
+    c = &s->config[function];
 
     if (c == NULL)
 	return CS_NO_CARD;
@@ -887,7 +886,7 @@
     }
     return CS_SUCCESS;
 } /* access_configuration_register */
-
+EXPORT_SYMBOL(pccard_access_configuration_register);
 
 /*====================================================================*/
 
@@ -895,7 +894,6 @@
 {
     client_t **client;
     struct pcmcia_socket *s;
-    memory_handle_t region;
     u_long flags;
     int i;
     
@@ -912,14 +910,6 @@
 	if (handle->state & CLIENT_WIN_REQ(i))
 	    return CS_IN_USE;
 
-    /* Disconnect all MTD links */
-    if (handle->mtd_count) {
-	for (region = s->a_region; region; region = region->info.next)
-	    if (region->mtd == handle) region->mtd = NULL;
-	for (region = s->c_region; region; region = region->info.next)
-	    if (region->mtd == handle) region->mtd = NULL;
-    }
-    
     if ((handle->state & CLIENT_STALE) ||
 	(handle->Attributes & INFO_MASTER_CLIENT)) {
 	spin_lock_irqsave(&s->lock, flags);
@@ -936,7 +926,6 @@
 	spin_unlock_irqrestore(&s->lock, flags);
     } else {
 	handle->state = CLIENT_UNBOUND;
-	handle->mtd_count = 0;
 	handle->event_handler = NULL;
     }
 
@@ -945,29 +934,20 @@
 
 /*====================================================================*/
 
-int pcmcia_get_configuration_info(client_handle_t handle,
+int pccard_get_configuration_info(struct pcmcia_socket *s,
+				  unsigned int function,
 				  config_info_t *config)
 {
-    struct pcmcia_socket *s;
     config_t *c;
     
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
-    s = SOCKET(handle);
     if (!(s->state & SOCKET_PRESENT))
 	return CS_NO_CARD;
 
-    if (handle->Function == BIND_FN_ALL) {
-	if (config->Function && (config->Function >= s->functions))
-	    return CS_BAD_ARGS;
-    } else
-	config->Function = handle->Function;
-    
+    config->Function = function;
+
 #ifdef CONFIG_CARDBUS
     if (s->state & SOCKET_CARDBUS) {
-	u_char fn = config->Function;
 	memset(config, 0, sizeof(config_info_t));
-	config->Function = fn;
 	config->Vcc = s->socket.Vcc;
 	config->Vpp1 = config->Vpp2 = s->socket.Vpp;
 	config->Option = s->cb_dev->subordinate->number;
@@ -984,7 +964,7 @@
     }
 #endif
     
-    c = (s->config != NULL) ? &s->config[config->Function] : NULL;
+    c = (s->config != NULL) ? &s->config[function] : NULL;
     
     if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
 	config->Attributes = 0;
@@ -1009,6 +989,7 @@
     
     return CS_SUCCESS;
 } /* get_configuration_info */
+EXPORT_SYMBOL(pccard_get_configuration_info);
 
 /*======================================================================
 
@@ -1033,6 +1014,8 @@
     return CS_SUCCESS;
 } /* get_card_services_info */
 
+#ifdef CONFIG_PCMCIA_OBSOLETE
+
 /*======================================================================
 
     Note that get_first_client() *does* recognize the Socket field
@@ -1056,6 +1039,7 @@
     *handle = socket->clients;
     return CS_SUCCESS;
 } /* get_first_client */
+EXPORT_SYMBOL(pcmcia_get_first_client);
 
 /*====================================================================*/
 
@@ -1075,20 +1059,17 @@
 	*handle = (*handle)->next;
     return CS_SUCCESS;
 } /* get_next_client */
+EXPORT_SYMBOL(pcmcia_get_next_client);
+#endif /* CONFIG_PCMCIA_OBSOLETE */
 
 /*====================================================================*/
 
-int pcmcia_get_window(window_handle_t *handle, int idx, win_req_t *req)
+int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req)
 {
-    struct pcmcia_socket *s;
     window_t *win;
     int w;
 
-    if (idx == 0)
-	s = ((client_handle_t)*handle)->Socket;
-    else
-	s = (*handle)->sock;
-    if (!(s->state & SOCKET_PRESENT))
+    if (!s || !(s->state & SOCKET_PRESENT))
 	return CS_NO_CARD;
     for (w = idx; w < MAX_WIN; w++)
 	if (s->state & SOCKET_WIN_REQ(w)) break;
@@ -1110,20 +1091,7 @@
     *handle = win;
     return CS_SUCCESS;
 } /* get_window */
-
-int pcmcia_get_first_window(window_handle_t *win, win_req_t *req)
-{
-    if ((win == NULL) || ((*win)->magic != WINDOW_MAGIC))
-	return CS_BAD_HANDLE;
-    return pcmcia_get_window(win, 0, req);
-}
-
-int pcmcia_get_next_window(window_handle_t *win, win_req_t *req)
-{
-    if ((win == NULL) || ((*win)->magic != WINDOW_MAGIC))
-	return CS_BAD_HANDLE;
-    return pcmcia_get_window(win, (*win)->index+1, req);
-}
+EXPORT_SYMBOL(pcmcia_get_window);
 
 /*=====================================================================
 
@@ -1133,14 +1101,9 @@
 
 #ifdef CONFIG_CARDBUS
 
-struct pci_bus *pcmcia_lookup_bus(client_handle_t handle)
+struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s)
 {
-	struct pcmcia_socket *s;
-
-	if (CHECK_HANDLE(handle))
-		return NULL;
-	s = SOCKET(handle);
-	if (!(s->state & SOCKET_CARDBUS))
+	if (!s || !(s->state & SOCKET_CARDBUS))
 		return NULL;
 
 	return s->cb_dev->subordinate;
@@ -1157,15 +1120,11 @@
     
 ======================================================================*/
 
-int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
+int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_t *status)
 {
-    struct pcmcia_socket *s;
     config_t *c;
     int val;
     
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
-    s = SOCKET(handle);
     s->ops->get_status(s, &val);
     status->CardState = status->SocketState = 0;
     status->CardState |= (val & SS_DETECT) ? CS_EVENT_CARD_DETECT : 0;
@@ -1177,13 +1136,7 @@
     if (!(s->state & SOCKET_PRESENT))
 	return CS_NO_CARD;
     
-    /* Get info from the PRR, if necessary */
-    if (handle->Function == BIND_FN_ALL) {
-	if (status->Function && (status->Function >= s->functions))
-	    return CS_BAD_ARGS;
-	c = (s->config != NULL) ? &s->config[status->Function] : NULL;
-    } else
-	c = CONFIG(handle);
+    c = (s->config != NULL) ? &s->config[function] : NULL;
     if ((c != NULL) && (c->state & CONFIG_LOCKED) &&
 	(c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) {
 	u_char reg;
@@ -1218,6 +1171,7 @@
 	(val & SS_READY) ? CS_EVENT_READY_CHANGE : 0;
     return CS_SUCCESS;
 } /* get_status */
+EXPORT_SYMBOL(pccard_get_status);
 
 /*======================================================================
 
@@ -1297,6 +1251,8 @@
     return CS_SUCCESS;
 } /* modify_configuration */
 
+#ifdef CONFIG_PCMCIA_OBSOLETE
+
 /*======================================================================
 
     Modify the attributes of a window returned by RequestWindow.
@@ -1322,6 +1278,10 @@
     
     return CS_SUCCESS;
 } /* modify_window */
+EXPORT_SYMBOL(pcmcia_modify_window);
+
+#endif /* CONFIG_PCMCIA_OBSOLETE */
+
 
 /*======================================================================
 
@@ -1371,7 +1331,7 @@
     if ((!(s->state & SOCKET_CARDBUS)) && (s->functions == 0) &&
 	(client->Function != BIND_FN_ALL)) {
 	cistpl_longlink_mfc_t mfc;
-	if (read_tuple(client, CISTPL_LONGLINK_MFC, &mfc)
+	if (pccard_read_tuple(s, client->Function, CISTPL_LONGLINK_MFC, &mfc)
 	    == CS_SUCCESS)
 	    s->functions = mfc.nfn;
 	else
@@ -1915,14 +1875,10 @@
     
 ======================================================================*/
 
-int pcmcia_reset_card(client_handle_t handle, client_req_t *req)
+int pccard_reset_card(struct pcmcia_socket *skt)
 {
-	struct pcmcia_socket *skt;
 	int ret;
     
-	if (CHECK_HANDLE(handle))
-		return CS_BAD_HANDLE;
-	skt = SOCKET(handle);
 	cs_dbg(skt, 1, "resetting socket\n");
 
 	down(&skt->skt_sem);
@@ -1947,15 +1903,13 @@
 				send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW);
 		}
 
-		handle->event_callback_args.info = (void *)(u_long)ret;
-		EVENT(handle, CS_EVENT_RESET_COMPLETE, CS_EVENT_PRI_LOW);
-
 		ret = CS_SUCCESS;
 	} while (0);
 	up(&skt->skt_sem);
 
 	return ret;
 } /* reset_card */
+EXPORT_SYMBOL(pccard_reset_card);
 
 /*======================================================================
 
@@ -2073,6 +2027,7 @@
     
 ======================================================================*/
 
+#ifdef CONFIG_PCMCIA_OBSOLETE
 int pcmcia_set_event_mask(client_handle_t handle, eventmask_t *mask)
 {
     u_int events, bit;
@@ -2090,6 +2045,9 @@
     }
     return CS_SUCCESS;
 } /* set_event_mask */
+EXPORT_SYMBOL(pcmcia_set_event_mask);
+
+#endif /* CONFIG_PCMCIA_OBSOLETE */
 
 /*======================================================================
 
@@ -2097,37 +2055,14 @@
     
 ======================================================================*/
 /* in alpha order */
-EXPORT_SYMBOL(pcmcia_access_configuration_register);
-EXPORT_SYMBOL(pcmcia_adjust_resource_info);
-EXPORT_SYMBOL(pcmcia_check_erase_queue);
-EXPORT_SYMBOL(pcmcia_close_memory);
-EXPORT_SYMBOL(pcmcia_copy_memory);
 EXPORT_SYMBOL(pcmcia_deregister_client);
-EXPORT_SYMBOL(pcmcia_deregister_erase_queue);
 EXPORT_SYMBOL(pcmcia_eject_card);
-EXPORT_SYMBOL(pcmcia_get_first_client);
 EXPORT_SYMBOL(pcmcia_get_card_services_info);
-EXPORT_SYMBOL(pcmcia_get_configuration_info);
 EXPORT_SYMBOL(pcmcia_get_mem_page);
-EXPORT_SYMBOL(pcmcia_get_next_client);
-EXPORT_SYMBOL(pcmcia_get_first_region);
-EXPORT_SYMBOL(pcmcia_get_first_tuple);
-EXPORT_SYMBOL(pcmcia_get_first_window);
-EXPORT_SYMBOL(pcmcia_get_next_region);
-EXPORT_SYMBOL(pcmcia_get_next_tuple);
-EXPORT_SYMBOL(pcmcia_get_next_window);
-EXPORT_SYMBOL(pcmcia_get_status);
-EXPORT_SYMBOL(pcmcia_get_tuple_data);
 EXPORT_SYMBOL(pcmcia_insert_card);
 EXPORT_SYMBOL(pcmcia_map_mem_page);
 EXPORT_SYMBOL(pcmcia_modify_configuration);
-EXPORT_SYMBOL(pcmcia_modify_window);
-EXPORT_SYMBOL(pcmcia_open_memory);
-EXPORT_SYMBOL(pcmcia_parse_tuple);
-EXPORT_SYMBOL(pcmcia_read_memory);
 EXPORT_SYMBOL(pcmcia_register_client);
-EXPORT_SYMBOL(pcmcia_register_erase_queue);
-EXPORT_SYMBOL(pcmcia_register_mtd);
 EXPORT_SYMBOL(pcmcia_release_configuration);
 EXPORT_SYMBOL(pcmcia_release_io);
 EXPORT_SYMBOL(pcmcia_release_irq);
@@ -2137,15 +2072,10 @@
 EXPORT_SYMBOL(pcmcia_request_io);
 EXPORT_SYMBOL(pcmcia_request_irq);
 EXPORT_SYMBOL(pcmcia_request_window);
-EXPORT_SYMBOL(pcmcia_reset_card);
 EXPORT_SYMBOL(pcmcia_resume_card);
-EXPORT_SYMBOL(pcmcia_set_event_mask);
 EXPORT_SYMBOL(pcmcia_suspend_card);
-EXPORT_SYMBOL(pcmcia_validate_cis);
-EXPORT_SYMBOL(pcmcia_write_memory);
 
 EXPORT_SYMBOL(dead_socket);
-EXPORT_SYMBOL(MTDHelperEntry);
 EXPORT_SYMBOL(pcmcia_parse_events);
 
 struct class pcmcia_socket_class = {
diff -Nru a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
--- a/drivers/pcmcia/cs_internal.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/pcmcia/cs_internal.h	2004-12-24 13:37:43 -08:00
@@ -21,14 +21,6 @@
 
 #include <linux/config.h>
 
-#define ERASEQ_MAGIC	0xFA67
-typedef struct eraseq_t {
-    u_short		eraseq_magic;
-    client_handle_t	handle;
-    int			count;
-    eraseq_entry_t	*entry;
-} eraseq_t;
-
 #define CLIENT_MAGIC 	0x51E6
 typedef struct client_t {
     u_short		client_magic;
@@ -42,9 +34,6 @@
 			 event_callback_args_t *);
     event_callback_args_t event_callback_args;
     struct client_t 	*next;
-    u_int		mtd_count;
-    wait_queue_head_t	mtd_req;
-    erase_busy_t	erase_busy;
 } client_t;
 
 /* Flags in client state */
@@ -157,27 +146,7 @@
 void release_cis_mem(struct pcmcia_socket *s);
 void destroy_cis_cache(struct pcmcia_socket *s);
 int verify_cis_cache(struct pcmcia_socket *s);
-void preload_cis_cache(struct pcmcia_socket *s);
-int get_first_tuple(client_handle_t handle, tuple_t *tuple);
-int get_next_tuple(client_handle_t handle, tuple_t *tuple);
-int get_tuple_data(client_handle_t handle, tuple_t *tuple);
-int parse_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse);
-int validate_cis(client_handle_t handle, cisinfo_t *info);
-int replace_cis(client_handle_t handle, cisdump_t *cis);
-int read_tuple(client_handle_t handle, cisdata_t code, void *parse);
-
-/* In bulkmem.c */
-int get_first_region(client_handle_t handle, region_info_t *rgn);
-int get_next_region(client_handle_t handle, region_info_t *rgn);
-int register_mtd(client_handle_t handle, mtd_reg_t *reg);
-int register_erase_queue(client_handle_t *handle, eraseq_hdr_t *header);
-int deregister_erase_queue(eraseq_handle_t eraseq);
-int check_erase_queue(eraseq_handle_t eraseq);
-int open_memory(client_handle_t *handle, open_mem_t *open);
-int close_memory(memory_handle_t handle);
-int read_memory(memory_handle_t handle, mem_op_t *req, caddr_t buf);
-int write_memory(memory_handle_t handle, mem_op_t *req, caddr_t buf);
-int copy_memory(memory_handle_t handle, copy_op_t *req);
+int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse);
 
 /* In rsrc_mgr */
 void pcmcia_validate_mem(struct pcmcia_socket *s);
@@ -198,6 +167,11 @@
 /* In cs.c */
 extern struct rw_semaphore pcmcia_socket_list_rwsem;
 extern struct list_head pcmcia_socket_list;
+int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req);
+int pccard_get_configuration_info(struct pcmcia_socket *s, unsigned int function, config_info_t *config);
+int pccard_reset_card(struct pcmcia_socket *skt);
+int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_t *status);
+int pccard_access_configuration_register(struct pcmcia_socket *s, unsigned int function, conf_reg_t *reg);
 
 #define cs_socket_name(skt)	((skt)->dev.class_id)
 
diff -Nru a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
--- a/drivers/pcmcia/ds.c	2004-12-24 13:37:17 -08:00
+++ b/drivers/pcmcia/ds.c	2004-12-24 13:37:17 -08:00
@@ -75,12 +75,12 @@
 MODULE_LICENSE("Dual MPL/GPL");
 
 #ifdef DEBUG
-static int pc_debug;
+int ds_pc_debug;
 
-module_param(pc_debug, int, 0644);
+module_param_named(pc_debug, ds_pc_debug, int, 0644);
 
 #define ds_dbg(lvl, fmt, arg...) do {				\
-	if (pc_debug > (lvl))					\
+	if (ds_pc_debug > (lvl))					\
 		printk(KERN_DEBUG "ds: " fmt , ## arg);		\
 } while (0)
 #else
@@ -134,8 +134,6 @@
 
 static int major_dev = -1;
 
-static struct proc_dir_entry *proc_pccard;
-
 /*====================================================================*/
 
 /* code which was in cs.c before */
@@ -167,9 +165,6 @@
 	client->Socket = s;
 	client->Function = req->Function;
 	client->state = CLIENT_UNBOUND;
-	client->erase_busy.next = &client->erase_busy;
-	client->erase_busy.prev = &client->erase_busy;
-	init_waitqueue_head(&client->mtd_req);
 	client->next = s->clients;
 	s->clients = client;
 	ds_dbg(1, "%s: bind_device(): client 0x%p, dev %s\n",
@@ -630,6 +625,8 @@
 
 /*====================================================================*/
 
+extern struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s);
+
 static int get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info, int first)
 {
     socket_bind_t *b;
@@ -643,7 +640,7 @@
     {
 	struct pci_bus *bus;
 
-	bus = pcmcia_lookup_bus(s->handle);
+	bus = pcmcia_lookup_bus(s->parent);
 	if (bus) {
 	    	struct list_head *list;
 		struct pci_dev *dev = NULL;
@@ -885,6 +882,10 @@
 
 /*====================================================================*/
 
+extern int pcmcia_adjust_resource_info(adjust_t *adj);
+extern int pccard_get_next_region(struct pcmcia_socket *s, region_info_t *rgn);
+extern int pccard_get_first_region(struct pcmcia_socket *s, region_info_t *rgn);
+
 static int ds_ioctl(struct inode * inode, struct file * file,
 		    u_int cmd, u_long arg)
 {
@@ -933,39 +934,47 @@
     
     switch (cmd) {
     case DS_ADJUST_RESOURCE_INFO:
-	ret = pcmcia_adjust_resource_info(s->handle, &buf.adjust);
+	ret = pcmcia_adjust_resource_info(&buf.adjust);
 	break;
     case DS_GET_CARD_SERVICES_INFO:
 	ret = pcmcia_get_card_services_info(&buf.servinfo);
 	break;
     case DS_GET_CONFIGURATION_INFO:
-	ret = pcmcia_get_configuration_info(s->handle, &buf.config);
+	if (buf.config.Function && 
+	   (buf.config.Function >= s->parent->functions))
+	    ret = CS_BAD_ARGS;
+	else
+	    ret = pccard_get_configuration_info(s->parent, buf.config.Function, &buf.config);
 	break;
     case DS_GET_FIRST_TUPLE:
 	pcmcia_validate_mem(s->parent);
-	ret = pcmcia_get_first_tuple(s->handle, &buf.tuple);
+	ret = pccard_get_first_tuple(s->parent, BIND_FN_ALL, &buf.tuple);
 	break;
     case DS_GET_NEXT_TUPLE:
-	ret = pcmcia_get_next_tuple(s->handle, &buf.tuple);
+	ret = pccard_get_next_tuple(s->parent, BIND_FN_ALL, &buf.tuple);
 	break;
     case DS_GET_TUPLE_DATA:
 	buf.tuple.TupleData = buf.tuple_parse.data;
 	buf.tuple.TupleDataMax = sizeof(buf.tuple_parse.data);
-	ret = pcmcia_get_tuple_data(s->handle, &buf.tuple);
+	ret = pccard_get_tuple_data(s->parent, &buf.tuple);
 	break;
     case DS_PARSE_TUPLE:
 	buf.tuple.TupleData = buf.tuple_parse.data;
-	ret = pcmcia_parse_tuple(s->handle, &buf.tuple, &buf.tuple_parse.parse);
+	ret = pccard_parse_tuple(&buf.tuple, &buf.tuple_parse.parse);
 	break;
     case DS_RESET_CARD:
-	ret = pcmcia_reset_card(s->handle, NULL);
+	ret = pccard_reset_card(s->parent);
 	break;
     case DS_GET_STATUS:
-	ret = pcmcia_get_status(s->handle, &buf.status);
+	if (buf.status.Function && 
+	   (buf.status.Function >= s->parent->functions))
+	    ret = CS_BAD_ARGS;
+	else
+	ret = pccard_get_status(s->parent, buf.status.Function, &buf.status);
 	break;
     case DS_VALIDATE_CIS:
 	pcmcia_validate_mem(s->parent);
-	ret = pcmcia_validate_cis(s->handle, &buf.cisinfo);
+	ret = pccard_validate_cis(s->parent, BIND_FN_ALL, &buf.cisinfo);
 	break;
     case DS_SUSPEND_CARD:
 	ret = pcmcia_suspend_card(s->parent);
@@ -982,27 +991,30 @@
     case DS_ACCESS_CONFIGURATION_REGISTER:
 	if ((buf.conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN))
 	    return -EPERM;
-	ret = pcmcia_access_configuration_register(s->handle, &buf.conf_reg);
+	if (buf.conf_reg.Function && 
+	   (buf.conf_reg.Function >= s->parent->functions))
+	    ret = CS_BAD_ARGS;
+	else
+	    ret = pccard_access_configuration_register(s->parent, buf.conf_reg.Function, &buf.conf_reg);
 	break;
     case DS_GET_FIRST_REGION:
-        ret = pcmcia_get_first_region(s->handle, &buf.region);
+        ret = pccard_get_first_region(s->parent, &buf.region);
 	break;
     case DS_GET_NEXT_REGION:
-	ret = pcmcia_get_next_region(s->handle, &buf.region);
+	ret = pccard_get_next_region(s->parent, &buf.region);
 	break;
     case DS_GET_FIRST_WINDOW:
-	buf.win_info.handle = (window_handle_t)s->handle;
-	ret = pcmcia_get_first_window(&buf.win_info.handle, &buf.win_info.window);
+	ret = pcmcia_get_window(s->parent, &buf.win_info.handle, 0, &buf.win_info.window);
 	break;
     case DS_GET_NEXT_WINDOW:
-	ret = pcmcia_get_next_window(&buf.win_info.handle, &buf.win_info.window);
+	ret = pcmcia_get_window(s->parent, &buf.win_info.handle, buf.win_info.handle->index + 1, &buf.win_info.window);
 	break;
     case DS_GET_MEM_PAGE:
 	ret = pcmcia_get_mem_page(buf.win_info.handle,
 			   &buf.win_info.map);
 	break;
     case DS_REPLACE_CIS:
-	ret = pcmcia_replace_cis(s->handle, &buf.cisdump);
+	ret = pcmcia_replace_cis(s->parent, &buf.cisdump);
 	break;
     case DS_BIND_REQUEST:
 	if (!capable(CAP_SYS_ADMIN)) return -EPERM;
@@ -1046,7 +1058,11 @@
 	}
     }
 
-    if (cmd & IOC_OUT) __copy_to_user(uarg, (char *)&buf, size);
+    if (cmd & IOC_OUT) {
+        if (__copy_to_user(uarg, (char *)&buf, size))
+            err = -EFAULT;
+    }
+
 
     return err;
 } /* ds_ioctl */
@@ -1244,3 +1260,5 @@
 		return cmp.drv;
 	return NULL;
 }
+
+MODULE_ALIAS("ds");
diff -Nru a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
--- a/drivers/pcmcia/i82365.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/pcmcia/i82365.c	2004-12-24 13:37:19 -08:00
@@ -48,9 +48,9 @@
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
+#include <linux/bitops.h>
 #include <asm/irq.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/system.h>
 
 #include <pcmcia/version.h>
@@ -134,7 +134,7 @@
 module_param(ignore, int, 0444);
 module_param(extra_sockets, int, 0444);
 module_param(irq_mask, int, 0444);
-module_param_array(irq_list, int, irq_list_count, 0444);
+module_param_array(irq_list, int, &irq_list_count, 0444);
 module_param(cs_irq, int, 0444);
 module_param(async_clock, int, 0444);
 module_param(cable_mode, int, 0444);
diff -Nru a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pcmcia/m32r_cfc.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,879 @@
+/*
+ *  drivers/pcmcia/m32r_cfc.c
+ *
+ *  Device driver for the CFC functionality of M32R.
+ *
+ *  Copyright (c) 2001, 2002, 2003, 2004
+ *    Hiroyuki Kondo, Naoto Sugai, Hayato Fujiwara
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/fcntl.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/timer.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/workqueue.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/bitops.h>
+#include <asm/system.h>
+
+#include <pcmcia/version.h>
+#include <pcmcia/cs_types.h>
+#include <pcmcia/ss.h>
+#include <pcmcia/cs.h>
+
+#undef MAX_IO_WIN	/* FIXME */
+#define MAX_IO_WIN 1
+#undef MAX_WIN		/* FIXME */
+#define MAX_WIN 1
+
+#include "m32r_cfc.h"
+
+#ifdef DEBUG
+static int m32r_cfc_debug;
+module_param(m32r_cfc_debug, int, 0644);
+#define debug(lvl, fmt, arg...) do {				\
+	if (m32r_cfc_debug > (lvl))				\
+		printk(KERN_DEBUG "m32r_cfc: " fmt , ## arg);	\
+} while (0)
+#else
+#define debug(n, args...) do { } while (0)
+#endif
+
+/* Poll status interval -- 0 means default to interrupt */
+static int poll_interval = 0;
+
+typedef enum pcc_space { as_none = 0, as_comm, as_attr, as_io } pcc_as_t;
+
+typedef struct pcc_socket {
+	u_short			type, flags;
+	struct pcmcia_socket	socket;
+	unsigned int		number;
+ 	ioaddr_t		ioaddr;
+	u_long			mapaddr;
+	u_long			base;	/* PCC register base */
+	u_char			cs_irq1, cs_irq2, intr;
+	pccard_io_map		io_map[MAX_IO_WIN];
+	pccard_mem_map		mem_map[MAX_WIN];
+	u_char			io_win;
+	u_char			mem_win;
+	pcc_as_t		current_space;
+	u_char			last_iodbex;
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *proc;
+#endif
+} pcc_socket_t;
+
+static int pcc_sockets = 0;
+static pcc_socket_t socket[M32R_MAX_PCC] = {
+	{ 0, }, /* ... */
+};
+
+/*====================================================================*/
+
+static unsigned int pcc_get(u_short, unsigned int);
+static void pcc_set(u_short, unsigned int , unsigned int );
+
+static spinlock_t pcc_lock = SPIN_LOCK_UNLOCKED;
+
+#if !defined(CONFIG_PLAT_USRV)
+static inline u_long pcc_port2addr(unsigned long port, int size) {
+	u_long addr = 0;
+	u_long odd;
+
+	if (size == 1) {	/* byte access */
+		odd = (port&1) << 11;
+		port -= port & 1;
+		addr = CFC_IO_MAPBASE_BYTE - CFC_IOPORT_BASE + odd + port;
+	} else if (size == 2)
+		addr = CFC_IO_MAPBASE_WORD - CFC_IOPORT_BASE + port;
+
+	return addr;
+}
+#else	/* CONFIG_PLAT_USRV */
+static inline u_long pcc_port2addr(unsigned long port, int size) {
+	u_long odd;
+	u_long addr = ((port - CFC_IOPORT_BASE) & 0xf000) << 8;
+
+	if (size == 1) {	/* byte access */
+		odd = port & 1;
+		port -= odd;
+		odd <<= 11;
+		addr = (addr | CFC_IO_MAPBASE_BYTE) + odd + (port & 0xfff);
+	} else if (size == 2)	/* word access */
+		addr = (addr | CFC_IO_MAPBASE_WORD) + (port & 0xfff);
+
+	return addr;
+}
+#endif	/* CONFIG_PLAT_USRV */
+
+void pcc_ioread_byte(int sock, unsigned long port, void *buf, size_t size,
+	size_t nmemb, int flag)
+{
+	u_long addr;
+	unsigned char *bp = (unsigned char *)buf;
+	unsigned long flags;
+
+	debug(3, "m32r_cfc: pcc_ioread_byte: sock=%d, port=%#lx, buf=%p, "
+		 "size=%u, nmemb=%d, flag=%d\n",
+		  sock, port, buf, size, nmemb, flag);
+
+	addr = pcc_port2addr(port, 1);
+	if (!addr) {
+		printk("m32r_cfc:ioread_byte null port :%#lx\n",port);
+		return;
+	}
+	debug(3, "m32r_cfc: pcc_ioread_byte: addr=%#lx\n", addr);
+
+	spin_lock_irqsave(&pcc_lock, flags);
+	/* read Byte */
+	while (nmemb--)
+		*bp++ = readb(addr);
+	spin_unlock_irqrestore(&pcc_lock, flags);
+}
+
+void pcc_ioread_word(int sock, unsigned long port, void *buf, size_t size,
+	size_t nmemb, int flag)
+{
+	u_long addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned long flags;
+
+	debug(3, "m32r_cfc: pcc_ioread_word: sock=%d, port=%#lx, "
+		 "buf=%p, size=%u, nmemb=%d, flag=%d\n",
+		 sock, port, buf, size, nmemb, flag);
+
+	if (size != 2)
+		printk("m32r_cfc: ioread_word :illigal size %u : %#lx\n", size,
+			port);
+	if (size == 9)
+		printk("m32r_cfc: ioread_word :insw \n");
+
+	addr = pcc_port2addr(port, 2);
+	if (!addr) {
+		printk("m32r_cfc:ioread_word null port :%#lx\n",port);
+		return;
+	}
+	debug(3, "m32r_cfc: pcc_ioread_word: addr=%#lx\n", addr);
+
+	spin_lock_irqsave(&pcc_lock, flags);
+	/* read Word */
+	while (nmemb--)
+		*bp++ = readw(addr);
+	spin_unlock_irqrestore(&pcc_lock, flags);
+}
+
+void pcc_iowrite_byte(int sock, unsigned long port, void *buf, size_t size,
+	size_t nmemb, int flag)
+{
+	u_long addr;
+	unsigned char *bp = (unsigned char *)buf;
+	unsigned long flags;
+
+	debug(3, "m32r_cfc: pcc_iowrite_byte: sock=%d, port=%#lx, "
+		 "buf=%p, size=%u, nmemb=%d, flag=%d\n",
+		 sock, port, buf, size, nmemb, flag);
+
+	/* write Byte */
+	addr = pcc_port2addr(port, 1);
+	if (!addr) {
+		printk("m32r_cfc:iowrite_byte null port:%#lx\n",port);
+		return;
+	}
+	debug(3, "m32r_cfc: pcc_iowrite_byte: addr=%#lx\n", addr);
+
+	spin_lock_irqsave(&pcc_lock, flags);
+	while (nmemb--)
+		writeb(*bp++, addr);
+	spin_unlock_irqrestore(&pcc_lock, flags);
+}
+
+void pcc_iowrite_word(int sock, unsigned long port, void *buf, size_t size,
+	size_t nmemb, int flag)
+{
+	u_long addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned long flags;
+
+	debug(3, "m32r_cfc: pcc_iowrite_word: sock=%d, port=%#lx, "
+		 "buf=%p, size=%u, nmemb=%d, flag=%d\n",
+		 sock, port, buf, size, nmemb, flag);
+
+	if(size != 2)
+		printk("m32r_cfc: iowrite_word :illigal size %u : %#lx\n",
+			size, port);
+	if(size == 9)
+		printk("m32r_cfc: iowrite_word :outsw \n");
+
+	addr = pcc_port2addr(port, 2);
+	if (!addr) {
+		printk("m32r_cfc:iowrite_word null addr :%#lx\n",port);
+		return;
+	}
+#if 1
+	if (addr & 1) {
+		printk("m32r_cfc:iowrite_word port addr (%#lx):%#lx\n", port,
+			addr);
+		return;
+	}
+#endif
+	debug(3, "m32r_cfc: pcc_iowrite_word: addr=%#lx\n", addr);
+
+	spin_lock_irqsave(&pcc_lock, flags);
+	while (nmemb--)
+		writew(*bp++, addr);
+	spin_unlock_irqrestore(&pcc_lock, flags);
+}
+
+/*====================================================================*/
+
+#define IS_ALIVE		0x8000
+
+typedef struct pcc_t {
+	char			*name;
+	u_short			flags;
+} pcc_t;
+
+static pcc_t pcc[] = {
+#if !defined(CONFIG_PLAT_USRV)
+	{ "m32r_cfc", 0 }, { "", 0 },
+#else	/* CONFIG_PLAT_USRV */
+	{ "m32r_cfc", 0 }, { "m32r_cfc", 0 }, { "m32r_cfc", 0 },
+	{ "m32r_cfc", 0 }, { "m32r_cfc", 0 }, { "", 0 },
+#endif	/* CONFIG_PLAT_USRV */
+};
+
+static irqreturn_t pcc_interrupt(int, void *, struct pt_regs *);
+
+/*====================================================================*/
+
+static struct timer_list poll_timer;
+
+static unsigned int pcc_get(u_short sock, unsigned int reg)
+{
+	unsigned int val = inw(reg);
+	debug(3, "m32r_cfc: pcc_get: reg(0x%08x)=0x%04x\n", reg, val);
+	return val;
+}
+
+
+static void pcc_set(u_short sock, unsigned int reg, unsigned int data)
+{
+	outw(data, reg);
+	debug(3, "m32r_cfc: pcc_set: reg(0x%08x)=0x%04x\n", reg, data);
+}
+
+/*======================================================================
+
+	See if a card is present, powered up, in IO mode, and already
+	bound to a (non PC Card) Linux driver.  We leave these alone.
+
+	We make an exception for cards that seem to be serial devices.
+
+======================================================================*/
+
+static int __init is_alive(u_short sock)
+{
+	unsigned int stat;
+
+	debug(3, "m32r_cfc: is_alive:\n");
+
+	printk("CF: ");
+	stat = pcc_get(sock, (unsigned int)PLD_CFSTS);
+	if (!stat)
+		printk("No ");
+	printk("Card is detected at socket %d : stat = 0x%08x\n", sock, stat);
+	debug(3, "m32r_cfc: is_alive: sock stat is 0x%04x\n", stat);
+
+	return 0;
+}
+
+static void add_pcc_socket(ulong base, int irq, ulong mapaddr, ioaddr_t ioaddr)
+{
+	pcc_socket_t *t = &socket[pcc_sockets];
+
+	debug(3, "m32r_cfc: add_pcc_socket: base=%#lx, irq=%d, "
+		 "mapaddr=%#lx, ioaddr=%08x\n",
+		 base, irq, mapaddr, ioaddr);
+
+	/* add sockets */
+	t->ioaddr = ioaddr;
+	t->mapaddr = mapaddr;
+#if !defined(CONFIG_PLAT_USRV)
+	t->base = 0;
+	t->flags = 0;
+	t->cs_irq1 = irq;		// insert irq
+	t->cs_irq2 = irq + 1;		// eject irq
+#else	/* CONFIG_PLAT_USRV */
+	t->base = base;
+	t->flags = 0;
+	t->cs_irq1 = 0;			// insert irq
+	t->cs_irq2 = 0;			// eject irq
+#endif	/* CONFIG_PLAT_USRV */
+
+	if (is_alive(pcc_sockets))
+		t->flags |= IS_ALIVE;
+
+	/* add pcc */
+#if !defined(CONFIG_PLAT_USRV)
+	request_region((unsigned int)PLD_CFRSTCR, 0x20, "m32r_cfc");
+#else	/* CONFIG_PLAT_USRV */
+	{
+		unsigned int reg_base;
+
+		reg_base = (unsigned int)PLD_CFRSTCR;
+		reg_base |= pcc_sockets << 8;
+		request_region(reg_base, 0x20, "m32r_cfc");
+	}
+#endif	/* CONFIG_PLAT_USRV */
+	printk(KERN_INFO "  %s ", pcc[pcc_sockets].name);
+	printk("pcc at 0x%08lx\n", t->base);
+
+	/* Update socket interrupt information, capabilities */
+	t->socket.features |= (SS_CAP_PCCARD | SS_CAP_STATIC_MAP);
+	t->socket.map_size = M32R_PCC_MAPSIZE;
+	t->socket.io_offset = ioaddr;	/* use for io access offset */
+	t->socket.irq_mask = 0;
+#if !defined(CONFIG_PLAT_USRV)
+	t->socket.pci_irq = PLD_IRQ_CFIREQ ;	/* card interrupt */
+#else	/* CONFIG_PLAT_USRV */
+	t->socket.pci_irq = PLD_IRQ_CF0 + pcc_sockets;
+#endif	/* CONFIG_PLAT_USRV */
+
+#ifndef CONFIG_PLAT_USRV
+	/* insert interrupt */
+	request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
+	/* eject interrupt */
+	request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
+
+	debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n");
+	pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01);
+#endif	/* CONFIG_PLAT_USRV */
+#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
+	pcc_set(pcc_sockets, (unsigned int)PLD_CFCR1, 0x0200);
+#endif
+	pcc_sockets++;
+
+	return;
+}
+
+
+/*====================================================================*/
+
+static irqreturn_t pcc_interrupt(int irq, void *dev, struct pt_regs *regs)
+{
+	int i;
+	u_int events = 0;
+	int handled = 0;
+
+	debug(3, "m32r_cfc: pcc_interrupt: irq=%d, dev=%p, regs=%p\n",
+		irq, dev, regs);
+	for (i = 0; i < pcc_sockets; i++) {
+		if (socket[i].cs_irq1 != irq && socket[i].cs_irq2 != irq)
+			continue;
+
+		handled = 1;
+		debug(3, "m32r_cfc: pcc_interrupt: socket %d irq 0x%02x ",
+			i, irq);
+		events |= SS_DETECT;	/* insert or eject */
+		if (events)
+			pcmcia_parse_events(&socket[i].socket, events);
+	}
+	debug(3, "m32r_cfc: pcc_interrupt: done\n");
+
+	return IRQ_RETVAL(handled);
+} /* pcc_interrupt */
+
+static void pcc_interrupt_wrapper(u_long data)
+{
+	debug(3, "m32r_cfc: pcc_interrupt_wrapper:\n");
+	pcc_interrupt(0, NULL, NULL);
+	init_timer(&poll_timer);
+	poll_timer.expires = jiffies + poll_interval;
+	add_timer(&poll_timer);
+}
+
+/*====================================================================*/
+
+static int _pcc_get_status(u_short sock, u_int *value)
+{
+	u_int status;
+
+	debug(3, "m32r_cfc: _pcc_get_status:\n");
+	status = pcc_get(sock, (unsigned int)PLD_CFSTS);
+	*value = (status) ? SS_DETECT : 0;
+ 	debug(3, "m32r_cfc: _pcc_get_status: status=0x%08x\n", status);
+
+#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
+	if ( status ) {
+		/* enable CF power */
+		status = inw((unsigned int)PLD_CPCR);
+		if (!(status & PLD_CPCR_CF)) {
+			debug(3, "m32r_cfc: _pcc_get_status: "
+				 "power on (CPCR=0x%08x)\n", status);
+			status |= PLD_CPCR_CF;
+			outw(status, (unsigned int)PLD_CPCR);
+			udelay(100);
+		}
+		*value |= SS_POWERON;
+
+		pcc_set(sock, (unsigned int)PLD_CFBUFCR,0);/* enable buffer */
+		udelay(100);
+
+		*value |= SS_READY; 		/* always ready */
+		*value |= SS_3VCARD;
+	} else {
+		/* disable CF power */
+		status = inw((unsigned int)PLD_CPCR);
+		status &= ~PLD_CPCR_CF;
+		outw(status, (unsigned int)PLD_CPCR);
+		udelay(100);
+		debug(3, "m32r_cfc: _pcc_get_status: "
+			 "power off (CPCR=0x%08x)\n", status);
+	}
+#elif defined(CONFIG_PLAT_MAPPI2)
+	if ( status ) {
+		status = pcc_get(sock, (unsigned int)PLD_CPCR);
+		if (status == 0) { /* power off */
+			pcc_set(sock, (unsigned int)PLD_CPCR, 1);
+			pcc_set(sock, (unsigned int)PLD_CFBUFCR,0); /* force buffer off for ZA-36 */
+			udelay(50);
+		}
+		status = pcc_get(sock, (unsigned int)PLD_CFBUFCR);
+		if (status != 0) { /* buffer off */
+			pcc_set(sock, (unsigned int)PLD_CFBUFCR,0);
+			udelay(50);
+			pcc_set(sock, (unsigned int)PLD_CFRSTCR, 0x0101);
+			udelay(25); /* for IDE reset */
+			pcc_set(sock, (unsigned int)PLD_CFRSTCR, 0x0100);
+			mdelay(2);  /* for IDE reset */
+		} else {
+			*value |= SS_POWERON;
+			*value |= SS_READY;
+		}
+	}
+#else
+#error no platform configuration
+#endif
+	debug(3, "m32r_cfc: _pcc_get_status: GetStatus(%d) = %#4.4x\n",
+		 sock, *value);
+	return 0;
+} /* _get_status */
+
+/*====================================================================*/
+
+static int _pcc_get_socket(u_short sock, socket_state_t *state)
+{
+//	pcc_socket_t *t = &socket[sock];
+
+#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
+	state->flags = 0;
+	state->csc_mask = SS_DETECT;
+	state->csc_mask |= SS_READY;
+	state->io_irq = 0;
+	state->Vcc = 33;	/* 3.3V fixed */
+	state->Vpp = 33;
+#endif
+	debug(3, "m32r_cfc: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
+		  "io_irq %d, csc_mask %#2.2x\n", sock, state->flags,
+		  state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
+	return 0;
+} /* _get_socket */
+
+/*====================================================================*/
+
+static int _pcc_set_socket(u_short sock, socket_state_t *state)
+{
+#if defined(CONFIG_PLAT_MAPPI2)
+	u_long reg = 0;
+#endif
+	debug(3, "m32r_cfc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
+		  "io_irq %d, csc_mask %#2.2x)\n", sock, state->flags,
+		  state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
+
+#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
+	if (state->Vcc) {
+		if ((state->Vcc != 50) && (state->Vcc != 33))
+			return -EINVAL;
+		/* accept 5V and 3.3V */
+	}
+#elif defined(CONFIG_PLAT_MAPPI2)
+	if (state->Vcc) {
+		/*
+		 * 5V only
+		 */
+		if (state->Vcc == 50) {
+			reg |= PCCSIGCR_VEN;
+		} else {
+			return -EINVAL;
+		}
+	}
+#endif
+
+	if (state->flags & SS_RESET) {
+		debug(3, ":RESET\n");
+		pcc_set(sock,(unsigned int)PLD_CFRSTCR,0x101);
+	}else{
+		pcc_set(sock,(unsigned int)PLD_CFRSTCR,0x100);
+	}
+	if (state->flags & SS_OUTPUT_ENA){
+		debug(3, ":OUTPUT_ENA\n");
+		/* bit clear */
+		pcc_set(sock,(unsigned int)PLD_CFBUFCR,0);
+	} else {
+		pcc_set(sock,(unsigned int)PLD_CFBUFCR,1);
+	}
+
+#ifdef DEBUG
+	if(state->flags & SS_IOCARD){
+		debug(3, ":IOCARD");
+	}
+	if (state->flags & SS_PWR_AUTO) {
+		debug(3, ":PWR_AUTO");
+	}
+	if (state->csc_mask & SS_DETECT)
+		debug(3, ":csc-SS_DETECT");
+	if (state->flags & SS_IOCARD) {
+		if (state->csc_mask & SS_STSCHG)
+			debug(3, ":STSCHG");
+	} else {
+		if (state->csc_mask & SS_BATDEAD)
+			debug(3, ":BATDEAD");
+		if (state->csc_mask & SS_BATWARN)
+			debug(3, ":BATWARN");
+		if (state->csc_mask & SS_READY)
+			debug(3, ":READY");
+	}
+	debug(3, "\n");
+#endif
+	return 0;
+} /* _set_socket */
+
+/*====================================================================*/
+
+static int _pcc_set_io_map(u_short sock, struct pccard_io_map *io)
+{
+	u_char map;
+
+	debug(3, "m32r_cfc: SetIOMap(%d, %d, %#2.2x, %d ns, "
+		  "%#4.4x-%#4.4x)\n", sock, io->map, io->flags,
+		  io->speed, io->start, io->stop);
+	map = io->map;
+
+	return 0;
+} /* _set_io_map */
+
+/*====================================================================*/
+
+static int _pcc_set_mem_map(u_short sock, struct pccard_mem_map *mem)
+{
+
+	u_char map = mem->map;
+	u_long addr;
+	pcc_socket_t *t = &socket[sock];
+
+	debug(3, "m32r_cfc: SetMemMap(%d, %d, %#2.2x, %d ns, "
+		 "%#5.5lx, %#5.5x)\n", sock, map, mem->flags,
+		 mem->speed, mem->static_start, mem->card_start);
+
+	/*
+	 * sanity check
+	 */
+	if ((map > MAX_WIN) || (mem->card_start > 0x3ffffff)){
+		return -EINVAL;
+	}
+
+	/*
+	 * de-activate
+	 */
+	if ((mem->flags & MAP_ACTIVE) == 0) {
+		t->current_space = as_none;
+		return 0;
+	}
+
+	/*
+	 * Set mode
+	 */
+	if (mem->flags & MAP_ATTRIB) {
+		t->current_space = as_attr;
+	} else {
+		t->current_space = as_comm;
+	}
+
+	/*
+	 * Set address
+	 */
+	addr = t->mapaddr + (mem->card_start & M32R_PCC_MAPMASK);
+	mem->static_start = addr + mem->card_start;
+
+	return 0;
+
+} /* _set_mem_map */
+
+#if 0 /* driver model ordering issue */
+/*======================================================================
+
+	Routines for accessing socket information and register dumps via
+	/proc/bus/pccard/...
+
+======================================================================*/
+
+static ssize_t show_info(struct class_device *class_dev, char *buf)
+{
+	pcc_socket_t *s = container_of(class_dev, struct pcc_socket,
+		socket.dev);
+
+	return sprintf(buf, "type:     %s\nbase addr:    0x%08lx\n",
+		pcc[s->type].name, s->base);
+}
+
+static ssize_t show_exca(struct class_device *class_dev, char *buf)
+{
+	/* FIXME */
+
+	return 0;
+}
+
+static CLASS_DEVICE_ATTR(info, S_IRUGO, show_info, NULL);
+static CLASS_DEVICE_ATTR(exca, S_IRUGO, show_exca, NULL);
+#endif
+
+/*====================================================================*/
+
+/* this is horribly ugly... proper locking needs to be done here at
+ * some time... */
+#define LOCKED(x) do {					\
+	int retval;					\
+	unsigned long flags;				\
+	spin_lock_irqsave(&pcc_lock, flags);		\
+	retval = x;					\
+	spin_unlock_irqrestore(&pcc_lock, flags);	\
+	return retval;					\
+} while (0)
+
+
+static int pcc_get_status(struct pcmcia_socket *s, u_int *value)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE) {
+		debug(3, "m32r_cfc: pcc_get_status: sock(%d) -EINVAL\n", sock);
+		*value = 0;
+		return -EINVAL;
+	}
+	debug(3, "m32r_cfc: pcc_get_status: sock(%d)\n", sock);
+	LOCKED(_pcc_get_status(sock, value));
+}
+
+static int pcc_get_socket(struct pcmcia_socket *s, socket_state_t *state)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE) {
+		debug(3, "m32r_cfc: pcc_get_socket: sock(%d) -EINVAL\n", sock);
+		return -EINVAL;
+	}
+	debug(3, "m32r_cfc: pcc_get_socket: sock(%d)\n", sock);
+	LOCKED(_pcc_get_socket(sock, state));
+}
+
+static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE) {
+		debug(3, "m32r_cfc: pcc_set_socket: sock(%d) -EINVAL\n", sock);
+		return -EINVAL;
+	}
+	debug(3, "m32r_cfc: pcc_set_socket: sock(%d)\n", sock);
+	LOCKED(_pcc_set_socket(sock, state));
+}
+
+static int pcc_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE) {
+		debug(3, "m32r_cfc: pcc_set_io_map: sock(%d) -EINVAL\n", sock);
+		return -EINVAL;
+	}
+	debug(3, "m32r_cfc: pcc_set_io_map: sock(%d)\n", sock);
+	LOCKED(_pcc_set_io_map(sock, io));
+}
+
+static int pcc_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE) {
+		debug(3, "m32r_cfc: pcc_set_mem_map: sock(%d) -EINVAL\n", sock);
+		return -EINVAL;
+	}
+	debug(3, "m32r_cfc: pcc_set_mem_map: sock(%d)\n", sock);
+	LOCKED(_pcc_set_mem_map(sock, mem));
+}
+
+static int pcc_init(struct pcmcia_socket *s)
+{
+	debug(3, "m32r_cfc: pcc_init()\n");
+	return 0;
+}
+
+static int pcc_suspend(struct pcmcia_socket *sock)
+{
+	debug(3, "m32r_cfc: pcc_suspend()\n");
+	return pcc_set_socket(sock, &dead_socket);
+}
+
+static struct pccard_operations pcc_operations = {
+	.init			= pcc_init,
+	.suspend		= pcc_suspend,
+	.get_status		= pcc_get_status,
+	.get_socket		= pcc_get_socket,
+	.set_socket		= pcc_set_socket,
+	.set_io_map		= pcc_set_io_map,
+	.set_mem_map		= pcc_set_mem_map,
+};
+
+/*====================================================================*/
+
+static int m32r_pcc_suspend(struct device *dev, u32 state, u32 level)
+{
+	int ret = 0;
+	if (level == SUSPEND_SAVE_STATE)
+		ret = pcmcia_socket_dev_suspend(dev, state);
+	return ret;
+}
+
+static int m32r_pcc_resume(struct device *dev, u32 level)
+{
+	int ret = 0;
+	if (level == RESUME_RESTORE_STATE)
+		ret = pcmcia_socket_dev_resume(dev);
+	return ret;
+}
+
+
+static struct device_driver pcc_driver = {
+	.name = "cfc",
+	.bus = &platform_bus_type,
+	.suspend = m32r_pcc_suspend,
+	.resume = m32r_pcc_resume,
+};
+
+static struct platform_device pcc_device = {
+	.name = "cfc",
+	.id = 0,
+};
+
+/*====================================================================*/
+
+static int __init init_m32r_pcc(void)
+{
+	int i, ret;
+
+	ret = driver_register(&pcc_driver);
+	if (ret)
+		return ret;
+
+	ret = platform_device_register(&pcc_device);
+	if (ret){
+		driver_unregister(&pcc_driver);
+		return ret;
+	}
+
+#if defined(CONFIG_PLAT_MAPPI2)
+	pcc_set(0, (unsigned int)PLD_CFCR0, 0x0f0f);
+	pcc_set(0, (unsigned int)PLD_CFCR1, 0x0200);
+#endif
+
+	pcc_sockets = 0;
+
+#if !defined(CONFIG_PLAT_USRV)
+	add_pcc_socket(M32R_PCC0_BASE, PLD_IRQ_CFC_INSERT, CFC_ATTR_MAPBASE,
+		       CFC_IOPORT_BASE);
+#else	/* CONFIG_PLAT_USRV */
+	{
+		ulong base, mapaddr;
+		ioaddr_t ioaddr;
+
+		for (i = 0 ; i < M32R_MAX_PCC ; i++) {
+			base = (ulong)PLD_CFRSTCR;
+			base = base | (i << 8);
+			ioaddr = (i + 1) << 12;
+			mapaddr = CFC_ATTR_MAPBASE | (i << 20);
+			add_pcc_socket(base, 0, mapaddr, ioaddr);
+		}
+	}
+#endif	/* CONFIG_PLAT_USRV */
+
+	if (pcc_sockets == 0) {
+		printk("socket is not found.\n");
+		platform_device_unregister(&pcc_device);
+		driver_unregister(&pcc_driver);
+		return -ENODEV;
+	}
+
+	/* Set up interrupt handler(s) */
+
+	for (i = 0 ; i < pcc_sockets ; i++) {
+		socket[i].socket.dev.dev = &pcc_device.dev;
+		socket[i].socket.ops = &pcc_operations;
+		socket[i].socket.owner = THIS_MODULE;
+		socket[i].number = i;
+		ret = pcmcia_register_socket(&socket[i].socket);
+		if (ret && i--) {
+			for (; i>= 0; i--)
+				pcmcia_unregister_socket(&socket[i].socket);
+			break;
+		}
+#if 0	/* driver model ordering issue */
+		class_device_create_file(&socket[i].socket.dev,
+					 &class_device_attr_info);
+		class_device_create_file(&socket[i].socket.dev,
+					 &class_device_attr_exca);
+#endif
+	}
+
+	/* Finally, schedule a polling interrupt */
+	if (poll_interval != 0) {
+		poll_timer.function = pcc_interrupt_wrapper;
+		poll_timer.data = 0;
+		init_timer(&poll_timer);
+		poll_timer.expires = jiffies + poll_interval;
+		add_timer(&poll_timer);
+	}
+
+	return 0;
+} /* init_m32r_pcc */
+
+static void __exit exit_m32r_pcc(void)
+{
+	int i;
+
+	for (i = 0; i < pcc_sockets; i++)
+		pcmcia_unregister_socket(&socket[i].socket);
+
+	platform_device_unregister(&pcc_device);
+	if (poll_interval != 0)
+		del_timer_sync(&poll_timer);
+
+	driver_unregister(&pcc_driver);
+} /* exit_m32r_pcc */
+
+module_init(init_m32r_pcc);
+module_exit(exit_m32r_pcc);
+MODULE_LICENSE("Dual MPL/GPL");
+/*====================================================================*/
diff -Nru a/drivers/pcmcia/m32r_cfc.h b/drivers/pcmcia/m32r_cfc.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pcmcia/m32r_cfc.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2001 by Hiroyuki Kondo
+ */
+
+#if !defined(CONFIG_M32R_CFC_NUM)
+#define M32R_MAX_PCC	2
+#else
+#define M32R_MAX_PCC	CONFIG_M32R_CFC_NUM
+#endif
+
+/*
+ * M32R PC Card Controler
+ */
+#define M32R_PCC0_BASE        0x00ef7000
+#define M32R_PCC1_BASE        0x00ef7020
+
+/*
+ * Register offsets
+ */
+#define PCCR            0x00
+#define PCADR           0x04
+#define PCMOD           0x08
+#define PCIRC           0x0c
+#define PCCSIGCR        0x10
+#define PCATCR          0x14
+
+/*
+ * PCCR
+ */
+#define PCCR_PCEN       (1UL<<(31-31))
+
+/*
+ * PCIRC
+ */
+#define PCIRC_BWERR     (1UL<<(31-7))
+#define PCIRC_CDIN1     (1UL<<(31-14))
+#define PCIRC_CDIN2     (1UL<<(31-15))
+#define PCIRC_BEIEN     (1UL<<(31-23))
+#define PCIRC_CIIEN     (1UL<<(31-30))
+#define PCIRC_COIEN     (1UL<<(31-31))
+
+/*
+ * PCCSIGCR
+ */
+#define PCCSIGCR_SEN    (1UL<<(31-3))
+#define PCCSIGCR_VEN    (1UL<<(31-7))
+#define PCCSIGCR_CRST   (1UL<<(31-15))
+#define PCCSIGCR_COCR   (1UL<<(31-31))
+
+/*
+ *
+ */
+#define PCMOD_AS_ATTRIB	(1UL<<(31-19))
+#define PCMOD_AS_IO	(1UL<<(31-18))
+
+#define PCMOD_CBSZ	(1UL<<(31-23)) /* set for 8bit */
+
+#define PCMOD_DBEX	(1UL<<(31-31)) /* set for excahnge */
+
+/*
+ * M32R PCC Map addr
+ */
+
+#define M32R_PCC0_MAPBASE        0x14000000
+#define M32R_PCC1_MAPBASE        0x16000000
+
+#define M32R_PCC_MAPMAX		 0x02000000
+
+#define M32R_PCC_MAPSIZE	 0x00001000 /* XXX */
+#define M32R_PCC_MAPMASK     	(~(M32R_PCC_MAPMAX-1))
+
+#define CFC_IOPORT_BASE		0x1000
+
+#if !defined(CONFIG_PLAT_USRV)
+#define CFC_ATTR_MAPBASE        0x0c014000
+#define CFC_IO_MAPBASE_BYTE     0xac012000
+#define CFC_IO_MAPBASE_WORD     0xac002000
+#else	/* CONFIG_PLAT_USRV */
+#define CFC_ATTR_MAPBASE	0x04014000
+#define CFC_IO_MAPBASE_BYTE	0xa4012000
+#define CFC_IO_MAPBASE_WORD	0xa4002000
+#endif	/* CONFIG_PLAT_USRV */
+
diff -Nru a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pcmcia/m32r_pcc.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,816 @@
+/*
+ *  drivers/pcmcia/m32r_pcc.c
+ *
+ *  Device driver for the PCMCIA functionality of M32R.
+ *
+ *  Copyright (c) 2001, 2002, 2003, 2004
+ *    Hiroyuki Kondo, Naoto Sugai, Hayato Fujiwara
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/fcntl.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/timer.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/workqueue.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/bitops.h>
+#include <asm/system.h>
+#include <asm/addrspace.h>
+
+#include <pcmcia/version.h>
+#include <pcmcia/cs_types.h>
+#include <pcmcia/ss.h>
+#include <pcmcia/cs.h>
+
+/* XXX: should be moved into asm/irq.h */
+#define PCC0_IRQ 24
+#define PCC1_IRQ 25
+
+#include "m32r_pcc.h"
+
+#define CHAOS_PCC_DEBUG
+#ifdef CHAOS_PCC_DEBUG
+	static volatile u_short dummy_readbuf;
+#endif
+
+#define PCC_DEBUG_DBEX
+
+#ifdef DEBUG
+static int m32r_pcc_debug;
+module_param(m32r_pcc_debug, int, 0644);
+#define debug(lvl, fmt, arg...) do {				\
+	if (m32r_pcc_debug > (lvl))				\
+		printk(KERN_DEBUG "m32r_pcc: " fmt , ## arg);	\
+} while (0)
+#else
+#define debug(n, args...) do { } while (0)
+#endif
+
+/* Poll status interval -- 0 means default to interrupt */
+static int poll_interval = 0;
+
+typedef enum pcc_space { as_none = 0, as_comm, as_attr, as_io } pcc_as_t;
+
+typedef struct pcc_socket {
+	u_short			type, flags;
+	struct pcmcia_socket	socket;
+	unsigned int		number;
+ 	ioaddr_t		ioaddr;
+	u_long			mapaddr;
+	u_long			base;	/* PCC register base */
+	u_char			cs_irq, intr;
+	pccard_io_map		io_map[MAX_IO_WIN];
+	pccard_mem_map		mem_map[MAX_WIN];
+	u_char			io_win;
+	u_char			mem_win;
+	pcc_as_t		current_space;
+	u_char			last_iodbex;
+#ifdef CHAOS_PCC_DEBUG
+	u_char			last_iosize;
+#endif
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *proc;
+#endif
+} pcc_socket_t;
+
+static int pcc_sockets = 0;
+static pcc_socket_t socket[M32R_MAX_PCC] = {
+	{ 0, }, /* ... */
+};
+
+/*====================================================================*/
+
+static unsigned int pcc_get(u_short, unsigned int);
+static void pcc_set(u_short, unsigned int , unsigned int );
+
+static spinlock_t pcc_lock = SPIN_LOCK_UNLOCKED;
+
+void pcc_iorw(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int wr, int flag)
+{
+	u_long addr;
+	u_long flags;
+	int need_ex;
+#ifdef PCC_DEBUG_DBEX
+	int _dbex;
+#endif
+	pcc_socket_t *t = &socket[sock];
+#ifdef CHAOS_PCC_DEBUG
+	int map_changed = 0;
+#endif
+
+	/* Need lock ? */
+	spin_lock_irqsave(&pcc_lock, flags);
+
+	/*
+	 * Check if need dbex
+	 */
+	need_ex = (size > 1 && flag == 0) ? PCMOD_DBEX : 0;
+#ifdef PCC_DEBUG_DBEX
+	_dbex = need_ex;
+	need_ex = 0;
+#endif
+
+	/*
+	 * calculate access address
+	 */
+	addr = t->mapaddr + port - t->ioaddr + KSEG1; /* XXX */
+
+	/*
+	 * Check current mapping
+	 */
+	if (t->current_space != as_io || t->last_iodbex != need_ex) {
+
+		u_long cbsz;
+
+		/*
+		 * Disable first
+		 */
+		pcc_set(sock, PCCR, 0);
+
+		/*
+		 * Set mode and io address
+		 */
+		cbsz = (t->flags & MAP_16BIT) ? 0 : PCMOD_CBSZ;
+		pcc_set(sock, PCMOD, PCMOD_AS_IO | cbsz | need_ex);
+		pcc_set(sock, PCADR, addr & 0x1ff00000);
+
+		/*
+		 * Enable and read it
+		 */
+		pcc_set(sock, PCCR, 1);
+
+#ifdef CHAOS_PCC_DEBUG
+#if 0
+		map_changed = (t->current_space == as_attr && size == 2); /* XXX */
+#else
+		map_changed = 1;
+#endif
+#endif
+		t->current_space = as_io;
+	}
+
+	/*
+	 * access to IO space
+	 */
+	if (size == 1) {
+		/* Byte */
+		unsigned char *bp = (unsigned char *)buf;
+
+#ifdef CHAOS_DEBUG
+		if (map_changed) {
+			dummy_readbuf = readb(addr);
+		}
+#endif
+		if (wr) {
+			/* write Byte */
+			while (nmemb--) {
+				writeb(*bp++, addr);
+			}
+		} else {
+			/* read Byte */
+			while (nmemb--) {
+	    		*bp++ = readb(addr);
+			}
+		}
+	} else {
+		/* Word */
+		unsigned short *bp = (unsigned short *)buf;
+
+#ifdef CHAOS_PCC_DEBUG
+		if (map_changed) {
+			dummy_readbuf = readw(addr);
+		}
+#endif
+		if (wr) {
+			/* write Word */
+			while (nmemb--) {
+#ifdef PCC_DEBUG_DBEX
+				if (_dbex) {
+					unsigned char *cp = (unsigned char *)bp;
+					unsigned short tmp;
+					tmp = cp[1] << 8 | cp[0];
+					writew(tmp, addr);
+					bp++;
+				} else
+#endif
+				writew(*bp++, addr);
+	    	}
+	    } else {
+	    	/* read Word */
+	    	while (nmemb--) {
+#ifdef  PCC_DEBUG_DBEX
+				if (_dbex) {
+					unsigned char *cp = (unsigned char *)bp;
+					unsigned short tmp;
+					tmp = readw(addr);
+					cp[0] = tmp & 0xff;
+					cp[1] = (tmp >> 8) & 0xff;
+					bp++;
+				} else
+#endif
+				*bp++ = readw(addr);
+	    	}
+	    }
+	}
+
+#if 1
+	/* addr is no longer used */
+	if ((addr = pcc_get(sock, PCIRC)) & PCIRC_BWERR) {
+	  printk("m32r_pcc: BWERR detected : port 0x%04lx : iosize %dbit\n",
+			 port, size * 8);
+	  pcc_set(sock, PCIRC, addr);
+	}
+#endif
+	/*
+	 * save state
+	 */
+	t->last_iosize = size;
+	t->last_iodbex = need_ex;
+
+	/* Need lock ? */
+
+	spin_unlock_irqrestore(&pcc_lock,flags);
+
+	return;
+}
+
+void pcc_ioread(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int flag) {
+	pcc_iorw(sock, port, buf, size, nmemb, 0, flag);
+}
+
+void pcc_iowrite(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int flag) {
+    pcc_iorw(sock, port, buf, size, nmemb, 1, flag);
+}
+
+/*====================================================================*/
+
+#define IS_ALIVE		0x8000
+
+typedef struct pcc_t {
+	char			*name;
+	u_short			flags;
+} pcc_t;
+
+static pcc_t pcc[] = {
+	{ "xnux2", 0 }, { "xnux2", 0 },
+};
+
+static irqreturn_t pcc_interrupt(int, void *, struct pt_regs *);
+
+/*====================================================================*/
+
+static struct timer_list poll_timer;
+
+static unsigned int pcc_get(u_short sock, unsigned int reg)
+{
+	return inl(socket[sock].base + reg);
+}
+
+
+static void pcc_set(u_short sock, unsigned int reg, unsigned int data)
+{
+  	outl(data, socket[sock].base + reg);
+}
+
+/*======================================================================
+
+	See if a card is present, powered up, in IO mode, and already
+	bound to a (non PC Card) Linux driver.  We leave these alone.
+
+	We make an exception for cards that seem to be serial devices.
+
+======================================================================*/
+
+static int __init is_alive(u_short sock)
+{
+	unsigned int stat;
+	unsigned int f;
+
+	stat = pcc_get(sock, PCIRC);
+	f = (stat & (PCIRC_CDIN1 | PCIRC_CDIN2)) >> 16;
+	if(!f){
+		printk("m32r_pcc: No Card is detected at socket %d : stat = 0x%08x\n",stat,sock);
+		return 0;
+	}
+	if(f!=3)
+		printk("m32r_pcc: Insertion fail (%.8x) at socket %d\n",stat,sock);
+	else
+		printk("m32r_pcc: Card is Inserted at socket %d(%.8x)\n",sock,stat);
+	return 0;
+}
+
+static void add_pcc_socket(ulong base, int irq, ulong mapaddr, ioaddr_t ioaddr)
+{
+  	pcc_socket_t *t = &socket[pcc_sockets];
+
+	/* add sockets */
+	t->ioaddr = ioaddr;
+	t->mapaddr = mapaddr;
+	t->base = base;
+#ifdef CHAOS_PCC_DEBUG
+	t->flags = MAP_16BIT;
+#else
+	t->flags = 0;
+#endif
+	if (is_alive(pcc_sockets))
+		t->flags |= IS_ALIVE;
+
+	/* add pcc */
+	if (t->base > 0) {
+		request_region(t->base, 0x20, "m32r-pcc");
+	}
+
+	printk(KERN_INFO "  %s ", pcc[pcc_sockets].name);
+	printk("pcc at 0x%08lx\n", t->base);
+
+	/* Update socket interrupt information, capabilities */
+	t->socket.features |= (SS_CAP_PCCARD | SS_CAP_STATIC_MAP);
+	t->socket.map_size = M32R_PCC_MAPSIZE;
+	t->socket.io_offset = ioaddr;	/* use for io access offset */
+	t->socket.irq_mask = 0;
+	t->socket.pci_irq = 2 + pcc_sockets; /* XXX */
+
+	request_irq(irq, pcc_interrupt, 0, "m32r-pcc", pcc_interrupt);
+
+	pcc_sockets++;
+
+	return;
+}
+
+
+/*====================================================================*/
+
+static irqreturn_t pcc_interrupt(int irq, void *dev, struct pt_regs *regs)
+{
+	int i, j, irc;
+	u_int events, active;
+	int handled = 0;
+
+	debug(4, "m32r: pcc_interrupt(%d)\n", irq);
+
+	for (j = 0; j < 20; j++) {
+		active = 0;
+		for (i = 0; i < pcc_sockets; i++) {
+			if ((socket[i].cs_irq != irq) &&
+				(socket[i].socket.pci_irq != irq))
+				continue;
+			handled = 1;
+			irc = pcc_get(i, PCIRC);
+			irc >>=16;
+			debug(2, "m32r-pcc:interrput: socket %d pcirc 0x%02x ", i, irc);
+			if (!irc)
+				continue;
+
+			events = (irc) ? SS_DETECT : 0;
+			events |= (pcc_get(i,PCCR) & PCCR_PCEN) ? SS_READY : 0;
+			debug(2, " event 0x%02x\n", events);
+
+			if (events)
+				pcmcia_parse_events(&socket[i].socket, events);
+
+			active |= events;
+			active = 0;
+		}
+		if (!active) break;
+	}
+	if (j == 20)
+		printk(KERN_NOTICE "m32r-pcc: infinite loop in interrupt handler\n");
+
+	debug(4, "m32r-pcc: interrupt done\n");
+
+	return IRQ_RETVAL(handled);
+} /* pcc_interrupt */
+
+static void pcc_interrupt_wrapper(u_long data)
+{
+	pcc_interrupt(0, NULL, NULL);
+	init_timer(&poll_timer);
+	poll_timer.expires = jiffies + poll_interval;
+	add_timer(&poll_timer);
+}
+
+/*====================================================================*/
+
+static int _pcc_get_status(u_short sock, u_int *value)
+{
+	u_int status;
+
+	status = pcc_get(sock,PCIRC);
+	*value = ((status & PCIRC_CDIN1) && (status & PCIRC_CDIN2))
+		? SS_DETECT : 0;
+
+	status = pcc_get(sock,PCCR);
+
+#if 0
+	*value |= (status & PCCR_PCEN) ? SS_READY : 0;
+#else
+	*value |= SS_READY; /* XXX: always */
+#endif
+
+	status = pcc_get(sock,PCCSIGCR);
+	*value |= (status & PCCSIGCR_VEN) ? SS_POWERON : 0;
+
+	debug(3, "m32r-pcc: GetStatus(%d) = %#4.4x\n", sock, *value);
+	return 0;
+} /* _get_status */
+
+/*====================================================================*/
+
+static int _pcc_get_socket(u_short sock, socket_state_t *state)
+{
+	debug(3, "m32r-pcc: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
+		  "io_irq %d, csc_mask %#2.2x\n", sock, state->flags,
+		  state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
+	return 0;
+} /* _get_socket */
+
+/*====================================================================*/
+
+static int _pcc_set_socket(u_short sock, socket_state_t *state)
+{
+	u_long reg = 0;
+
+	debug(3, "m32r-pcc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
+		  "io_irq %d, csc_mask %#2.2x)", sock, state->flags,
+		  state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
+
+	if (state->Vcc) {
+		/*
+		 * 5V only
+		 */
+		if (state->Vcc == 50) {
+			reg |= PCCSIGCR_VEN;
+		} else {
+			return -EINVAL;
+		}
+	}
+
+	if (state->flags & SS_RESET) {
+		debug(3, ":RESET\n");
+		reg |= PCCSIGCR_CRST;
+	}
+	if (state->flags & SS_OUTPUT_ENA){
+		debug(3, ":OUTPUT_ENA\n");
+		/* bit clear */
+	} else {
+		reg |= PCCSIGCR_SEN;
+	}
+
+	pcc_set(sock,PCCSIGCR,reg);
+
+#ifdef DEBUG
+	if(state->flags & SS_IOCARD){
+		debug(3, ":IOCARD");
+	}
+	if (state->flags & SS_PWR_AUTO) {
+		debug(3, ":PWR_AUTO");
+	}
+	if (state->csc_mask & SS_DETECT)
+		debug(3, ":csc-SS_DETECT");
+	if (state->flags & SS_IOCARD) {
+		if (state->csc_mask & SS_STSCHG)
+			debug(3, ":STSCHG");
+	} else {
+		if (state->csc_mask & SS_BATDEAD)
+			debug(3, ":BATDEAD");
+		if (state->csc_mask & SS_BATWARN)
+			debug(3, ":BATWARN");
+		if (state->csc_mask & SS_READY)
+			debug(3, ":READY");
+	}
+	debug(3, "\n");
+#endif
+	return 0;
+} /* _set_socket */
+
+/*====================================================================*/
+
+static int _pcc_set_io_map(u_short sock, struct pccard_io_map *io)
+{
+	u_char map;
+
+	debug(3, "m32r-pcc: SetIOMap(%d, %d, %#2.2x, %d ns, "
+		  "%#4.4x-%#4.4x)\n", sock, io->map, io->flags,
+		  io->speed, io->start, io->stop);
+	map = io->map;
+
+	return 0;
+} /* _set_io_map */
+
+/*====================================================================*/
+
+static int _pcc_set_mem_map(u_short sock, struct pccard_mem_map *mem)
+{
+
+	u_char map = mem->map;
+	u_long mode;
+	u_long addr;
+	pcc_socket_t *t = &socket[sock];
+#ifdef CHAOS_PCC_DEBUG
+#if 0
+	pcc_as_t last = t->current_space;
+#endif
+#endif
+
+	debug(3, "m32r-pcc: SetMemMap(%d, %d, %#2.2x, %d ns, "
+		 "%#5.5lx,  %#5.5x)\n", sock, map, mem->flags,
+		 mem->speed, mem->static_start, mem->card_start);
+
+	/*
+	 * sanity check
+	 */
+	if ((map > MAX_WIN) || (mem->card_start > 0x3ffffff)){
+		return -EINVAL;
+	}
+
+	/*
+	 * de-activate
+	 */
+	if ((mem->flags & MAP_ACTIVE) == 0) {
+		t->current_space = as_none;
+		return 0;
+	}
+
+	/*
+	 * Disable first
+	 */
+	pcc_set(sock, PCCR, 0);
+
+	/*
+	 * Set mode
+	 */
+	if (mem->flags & MAP_ATTRIB) {
+		mode = PCMOD_AS_ATTRIB | PCMOD_CBSZ;
+		t->current_space = as_attr;
+	} else {
+		mode = 0; /* common memory */
+		t->current_space = as_comm;
+	}
+	pcc_set(sock, PCMOD, mode);
+
+	/*
+	 * Set address
+	 */
+	addr = t->mapaddr + (mem->card_start & M32R_PCC_MAPMASK);
+	pcc_set(sock, PCADR, addr);
+
+	mem->static_start = addr + mem->card_start;
+
+	/*
+	 * Enable again
+	 */
+	pcc_set(sock, PCCR, 1);
+
+#ifdef CHAOS_PCC_DEBUG
+#if 0
+	if (last != as_attr) {
+#else
+	if (1) {
+#endif
+		dummy_readbuf = *(u_char *)(addr + KSEG1);
+	}
+#endif
+
+	return 0;
+
+} /* _set_mem_map */
+
+#if 0 /* driver model ordering issue */
+/*======================================================================
+
+	Routines for accessing socket information and register dumps via
+	/proc/bus/pccard/...
+
+======================================================================*/
+
+static ssize_t show_info(struct class_device *class_dev, char *buf)
+{
+	pcc_socket_t *s = container_of(class_dev, struct pcc_socket,
+		socket.dev);
+
+	return sprintf(buf, "type:     %s\nbase addr:    0x%08lx\n",
+		pcc[s->type].name, s->base);
+}
+
+static ssize_t show_exca(struct class_device *class_dev, char *buf)
+{
+	/* FIXME */
+
+	return 0;
+}
+
+static CLASS_DEVICE_ATTR(info, S_IRUGO, show_info, NULL);
+static CLASS_DEVICE_ATTR(exca, S_IRUGO, show_exca, NULL);
+#endif
+
+/*====================================================================*/
+
+/* this is horribly ugly... proper locking needs to be done here at
+ * some time... */
+#define LOCKED(x) do {					\
+	int retval;					\
+	unsigned long flags;				\
+	spin_lock_irqsave(&pcc_lock, flags);		\
+	retval = x;					\
+	spin_unlock_irqrestore(&pcc_lock, flags);	\
+	return retval;					\
+} while (0)
+
+
+static int pcc_get_status(struct pcmcia_socket *s, u_int *value)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE) {
+		*value = 0;
+		return -EINVAL;
+	}
+	LOCKED(_pcc_get_status(sock, value));
+}
+
+static int pcc_get_socket(struct pcmcia_socket *s, socket_state_t *state)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE)
+		return -EINVAL;
+	LOCKED(_pcc_get_socket(sock, state));
+}
+
+static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE)
+		return -EINVAL;
+
+	LOCKED(_pcc_set_socket(sock, state));
+}
+
+static int pcc_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE)
+		return -EINVAL;
+	LOCKED(_pcc_set_io_map(sock, io));
+}
+
+static int pcc_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem)
+{
+	unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
+
+	if (socket[sock].flags & IS_ALIVE)
+		return -EINVAL;
+	LOCKED(_pcc_set_mem_map(sock, mem));
+}
+
+static int pcc_init(struct pcmcia_socket *s)
+{
+	debug(4, "m32r-pcc: init call\n");
+	return 0;
+}
+
+static int pcc_suspend(struct pcmcia_socket *sock)
+{
+	return pcc_set_socket(sock, &dead_socket);
+}
+
+static struct pccard_operations pcc_operations = {
+	.init			= pcc_init,
+	.suspend		= pcc_suspend,
+	.get_status		= pcc_get_status,
+	.get_socket		= pcc_get_socket,
+	.set_socket		= pcc_set_socket,
+	.set_io_map		= pcc_set_io_map,
+	.set_mem_map		= pcc_set_mem_map,
+};
+
+/*====================================================================*/
+
+static int m32r_pcc_suspend(struct device *dev, u32 state, u32 level)
+{
+	int ret = 0;
+	if (level == SUSPEND_SAVE_STATE)
+		ret = pcmcia_socket_dev_suspend(dev, state);
+	return ret;
+}
+
+static int m32r_pcc_resume(struct device *dev, u32 level)
+{
+	int ret = 0;
+	if (level == RESUME_RESTORE_STATE)
+		ret = pcmcia_socket_dev_resume(dev);
+	return ret;
+}
+
+
+static struct device_driver pcc_driver = {
+	.name = "pcc",
+	.bus = &platform_bus_type,
+	.suspend = m32r_pcc_suspend,
+	.resume = m32r_pcc_resume,
+};
+
+static struct platform_device pcc_device = {
+	.name = "pcc",
+	.id = 0,
+};
+
+/*====================================================================*/
+
+static int __init init_m32r_pcc(void)
+{
+	int i, ret;
+
+	ret = driver_register(&pcc_driver);
+	if (ret)
+		return ret;
+
+	ret = platform_device_register(&pcc_device);
+	if (ret){
+		driver_unregister(&pcc_driver);
+		return ret;
+	}
+
+	printk(KERN_INFO "m32r PCC probe:\n");
+
+	pcc_sockets = 0;
+
+	add_pcc_socket(M32R_PCC0_BASE, PCC0_IRQ, M32R_PCC0_MAPBASE, 0x1000);
+
+#ifdef CONFIG_M32RPCC_SLOT2
+	add_pcc_socket(M32R_PCC1_BASE, PCC1_IRQ, M32R_PCC1_MAPBASE, 0x2000);
+#endif
+
+	if (pcc_sockets == 0) {
+		printk("socket is not found.\n");
+		platform_device_unregister(&pcc_device);
+		driver_unregister(&pcc_driver);
+		return -ENODEV;
+	}
+
+	/* Set up interrupt handler(s) */
+
+	for (i = 0 ; i < pcc_sockets ; i++) {
+		socket[i].socket.dev.dev = &pcc_device.dev;
+		socket[i].socket.ops = &pcc_operations;
+		socket[i].socket.owner = THIS_MODULE;
+		socket[i].number = i;
+		ret = pcmcia_register_socket(&socket[i].socket);
+		if (ret && i--) {
+			for (; i>= 0; i--)
+				pcmcia_unregister_socket(&socket[i].socket);
+			break;
+		}
+#if 0	/* driver model ordering issue */
+		class_device_create_file(&socket[i].socket.dev,
+					 &class_device_attr_info);
+		class_device_create_file(&socket[i].socket.dev,
+					 &class_device_attr_exca);
+#endif
+	}
+
+	/* Finally, schedule a polling interrupt */
+	if (poll_interval != 0) {
+		poll_timer.function = pcc_interrupt_wrapper;
+		poll_timer.data = 0;
+		init_timer(&poll_timer);
+		poll_timer.expires = jiffies + poll_interval;
+		add_timer(&poll_timer);
+	}
+
+	return 0;
+} /* init_m32r_pcc */
+
+static void __exit exit_m32r_pcc(void)
+{
+	int i;
+
+	for (i = 0; i < pcc_sockets; i++)
+		pcmcia_unregister_socket(&socket[i].socket);
+
+	platform_device_unregister(&pcc_device);
+	if (poll_interval != 0)
+		del_timer_sync(&poll_timer);
+
+	driver_unregister(&pcc_driver);
+} /* exit_m32r_pcc */
+
+module_init(init_m32r_pcc);
+module_exit(exit_m32r_pcc);
+MODULE_LICENSE("Dual MPL/GPL");
+/*====================================================================*/
diff -Nru a/drivers/pcmcia/m32r_pcc.h b/drivers/pcmcia/m32r_pcc.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pcmcia/m32r_pcc.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2001 by Hiroyuki Kondo
+ */
+
+#define M32R_MAX_PCC	2
+
+/*
+ * M32R PC Card Controler
+ */
+#define M32R_PCC0_BASE        0x00ef7000
+#define M32R_PCC1_BASE        0x00ef7020
+
+/*
+ * Register offsets
+ */
+#define PCCR            0x00
+#define PCADR           0x04
+#define PCMOD           0x08
+#define PCIRC           0x0c
+#define PCCSIGCR        0x10
+#define PCATCR          0x14
+
+/*
+ * PCCR
+ */
+#define PCCR_PCEN       (1UL<<(31-31))
+
+/*
+ * PCIRC
+ */
+#define PCIRC_BWERR     (1UL<<(31-7))
+#define PCIRC_CDIN1     (1UL<<(31-14))
+#define PCIRC_CDIN2     (1UL<<(31-15))
+#define PCIRC_BEIEN     (1UL<<(31-23))
+#define PCIRC_CIIEN     (1UL<<(31-30))
+#define PCIRC_COIEN     (1UL<<(31-31))
+
+/*
+ * PCCSIGCR
+ */
+#define PCCSIGCR_SEN    (1UL<<(31-3))
+#define PCCSIGCR_VEN    (1UL<<(31-7))
+#define PCCSIGCR_CRST   (1UL<<(31-15))
+#define PCCSIGCR_COCR   (1UL<<(31-31))
+
+/*
+ *
+ */
+#define PCMOD_AS_ATTRIB	(1UL<<(31-19))
+#define PCMOD_AS_IO	(1UL<<(31-18))
+
+#define PCMOD_CBSZ	(1UL<<(31-23)) /* set for 8bit */
+
+#define PCMOD_DBEX	(1UL<<(31-31)) /* set for excahnge */
+
+/*
+ * M32R PCC Map addr
+ */
+#define M32R_PCC0_MAPBASE        0x14000000
+#define M32R_PCC1_MAPBASE        0x16000000
+
+#define M32R_PCC_MAPMAX		 0x02000000
+
+#define M32R_PCC_MAPSIZE	 0x00001000 /* XXX */
+#define M32R_PCC_MAPMASK     	(~(M32R_PCC_MAPMAX-1))
diff -Nru a/drivers/pcmcia/o2micro.h b/drivers/pcmcia/o2micro.h
--- a/drivers/pcmcia/o2micro.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/pcmcia/o2micro.h	2004-12-24 13:37:18 -08:00
@@ -129,9 +129,24 @@
 	 * ok to write to both registers on all O2 bridges.
 	 * from Eric Still, 02Micro.
 	 */
+	u8 a, b;
+
 	if (PCI_FUNC(socket->dev->devfn) == 0) {
-		config_writeb(socket, 0x94, 0xCA);
-		config_writeb(socket, 0xD4, 0xCA);
+		a = config_readb(socket, 0x94);
+		b = config_readb(socket, 0xD4);
+
+		printk(KERN_INFO "Yenta O2: res at 0x94/0xD4: %02x/%02x\n", a, b);
+
+		switch (socket->dev->device) {
+		case PCI_DEVICE_ID_O2_6832:
+			printk(KERN_INFO "Yenta O2: old bridge, not enabling read prefetch / write burst\n");
+			break;
+
+		default:
+			printk(KERN_INFO "Yenta O2: enabling read prefetch/write burst\n");
+			config_writeb(socket, 0x94, a | 0x0a);
+			config_writeb(socket, 0xD4, b | 0x0a);
+		}
 	}
 
 	return 0;
diff -Nru a/drivers/pcmcia/pcmcia_compat.c b/drivers/pcmcia/pcmcia_compat.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pcmcia/pcmcia_compat.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,145 @@
+/*
+ * PCMCIA 16-bit compatibility functions
+ *
+ * The initial developer of the original code is David A. Hinds
+ * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
+ * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
+ *
+ * Copyright (C) 2004 Dominik Brodowski
+ *
+ * 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/init.h>
+
+#define IN_CARD_SERVICES
+#include <pcmcia/version.h>
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/bulkmem.h>
+#include <pcmcia/cistpl.h>
+#include <pcmcia/ds.h>
+#include <pcmcia/ss.h>
+
+#include "cs_internal.h"
+
+int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple)
+{
+	struct pcmcia_socket *s;
+	if (CHECK_HANDLE(handle))
+		return CS_BAD_HANDLE;
+	s = SOCKET(handle);
+	return pccard_get_first_tuple(s, handle->Function, tuple);
+}
+EXPORT_SYMBOL(pcmcia_get_first_tuple);
+
+int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple)
+{
+	struct pcmcia_socket *s;
+	if (CHECK_HANDLE(handle))
+		return CS_BAD_HANDLE;
+	s = SOCKET(handle);
+	return pccard_get_next_tuple(s, handle->Function, tuple);
+}
+EXPORT_SYMBOL(pcmcia_get_next_tuple);
+
+int pcmcia_get_tuple_data(client_handle_t handle, tuple_t *tuple)
+{
+	struct pcmcia_socket *s;
+	if (CHECK_HANDLE(handle))
+		return CS_BAD_HANDLE;
+	s = SOCKET(handle);
+	return pccard_get_tuple_data(s, tuple);
+}
+EXPORT_SYMBOL(pcmcia_get_tuple_data);
+
+int pcmcia_parse_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+{
+	return pccard_parse_tuple(tuple, parse);
+}
+EXPORT_SYMBOL(pcmcia_parse_tuple);
+
+int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info)
+{
+	struct pcmcia_socket *s;
+	if (CHECK_HANDLE(handle))
+		return CS_BAD_HANDLE;
+	s = SOCKET(handle);
+	return pccard_validate_cis(s, handle->Function, info);
+}
+EXPORT_SYMBOL(pcmcia_validate_cis);
+
+int pcmcia_get_configuration_info(client_handle_t handle,
+				  config_info_t *config)
+{
+	struct pcmcia_socket *s;
+
+	if ((CHECK_HANDLE(handle)) || !config)
+		return CS_BAD_HANDLE;
+	s = SOCKET(handle);
+	if (!s)
+		return CS_BAD_HANDLE;
+	return pccard_get_configuration_info(s, handle->Function, config);
+}
+EXPORT_SYMBOL(pcmcia_get_configuration_info);
+
+int pcmcia_reset_card(client_handle_t handle, client_req_t *req)
+{
+	struct pcmcia_socket *skt;
+    
+	if (CHECK_HANDLE(handle))
+		return CS_BAD_HANDLE;
+	skt = SOCKET(handle);
+	if (!skt)
+		return CS_BAD_HANDLE;
+
+	return pccard_reset_card(skt);
+}
+EXPORT_SYMBOL(pcmcia_reset_card);
+
+int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
+{
+	struct pcmcia_socket *s;
+	if (CHECK_HANDLE(handle))
+		return CS_BAD_HANDLE;
+	s = SOCKET(handle);
+	return pccard_get_status(s, handle->Function, status);
+}
+EXPORT_SYMBOL(pcmcia_get_status);
+
+int pcmcia_access_configuration_register(client_handle_t handle,
+					 conf_reg_t *reg)
+{
+	struct pcmcia_socket *s;
+	if (CHECK_HANDLE(handle))
+		return CS_BAD_HANDLE;
+	s = SOCKET(handle);
+	return pccard_access_configuration_register(s, handle->Function, reg);
+}
+EXPORT_SYMBOL(pcmcia_access_configuration_register);
+
+#ifdef CONFIG_PCMCIA_OBSOLETE
+
+int pcmcia_get_first_window(window_handle_t *win, win_req_t *req)
+{
+    if ((win == NULL) || ((*win)->magic != WINDOW_MAGIC))
+	return CS_BAD_HANDLE;
+
+    return pcmcia_get_window(((client_handle_t)*win)->Socket, win, 0, req);
+}
+EXPORT_SYMBOL(pcmcia_get_first_window);
+
+int pcmcia_get_next_window(window_handle_t *win, win_req_t *req)
+{
+    if ((win == NULL) || ((*win)->magic != WINDOW_MAGIC))
+	return CS_BAD_HANDLE;
+    return pcmcia_get_window((*win)->sock, win, (*win)->index+1, req);
+}
+EXPORT_SYMBOL(pcmcia_get_next_window);
+
+#endif
diff -Nru a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
--- a/drivers/pcmcia/pxa2xx_base.c	2004-12-24 13:37:44 -08:00
+++ b/drivers/pcmcia/pxa2xx_base.c	2004-12-24 13:37:44 -08:00
@@ -217,7 +217,13 @@
 {
 	int ret = 0;
 	if (level == RESUME_RESTORE_STATE)
+	{
+		struct pcmcia_low_level *ops = dev->platform_data;
+		int nr = ops ? ops->nr : 0;
+
+		MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
 		ret = pcmcia_socket_dev_resume(dev);
+	}
 	return ret;
 }
 
diff -Nru a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c
--- a/drivers/pcmcia/pxa2xx_lubbock.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/pcmcia/pxa2xx_lubbock.c	2004-12-24 13:37:18 -08:00
@@ -265,3 +265,5 @@
 
 	return ret;
 }
+
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
--- a/drivers/pcmcia/rsrc_mgr.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/pcmcia/rsrc_mgr.c	2004-12-24 13:37:00 -08:00
@@ -307,7 +307,7 @@
 	s->cis_mem.res = res;
 	s->cis_virt = ioremap(res->start, s->map_size);
 	if (s->cis_virt) {
-		ret = pcmcia_validate_cis(s->clients, info);
+		ret = pccard_validate_cis(s, BIND_FN_ALL, info);
 		/* invalidate mapping and CIS cache */
 		iounmap(s->cis_virt);
 		s->cis_virt = NULL;
@@ -973,11 +973,8 @@
 
 /*====================================================================*/
 
-int pcmcia_adjust_resource_info(client_handle_t handle, adjust_t *adj)
+int pcmcia_adjust_resource_info(adjust_t *adj)
 {
-    if (CHECK_HANDLE(handle))
-	return CS_BAD_HANDLE;
-    
     switch (adj->Resource) {
     case RES_MEMORY_RANGE:
 	return adjust_memory(adj);
@@ -991,6 +988,7 @@
     }
     return CS_UNSUPPORTED_FUNCTION;
 }
+EXPORT_SYMBOL(pcmcia_adjust_resource_info);
 
 /*====================================================================*/
 
diff -Nru a/drivers/pcmcia/sa1100_adsbitsy.c b/drivers/pcmcia/sa1100_adsbitsy.c
--- a/drivers/pcmcia/sa1100_adsbitsy.c	2004-12-24 13:37:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,103 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_adsbitsy.c
- *
- * PCMCIA implementation routines for ADS Bitsy
- *
- * 9/18/01 Woojung
- *         Fixed wrong PCMCIA voltage setting
- *
- * 7/5/01 Woojung Huh <whuh@applieddata.net>
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-
-#include "sa1111_generic.h"
-
-static int adsbitsy_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
-{
-	/* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
-	PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
-
-	/* Disable Power 3.3V/5V for PCMCIA/CF */
-	PA_DWR |= GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
-
-	/* Why? */			 
-	MECR = 0x09430943;
-
-	return sa1111_pcmcia_init(skt);
-}
-
-static int
-adsbitsy_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
-{
-	unsigned int pa_dwr_mask, pa_dwr_set;
-	int ret;
-
-	switch (skt->nr) {
-	case 0:
-		pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1;
-
-		switch (state->Vcc) {
-		default:
-		case 0:  pa_dwr_set = GPIO_GPIO0 | GPIO_GPIO1;	break;
-		case 33: pa_dwr_set = GPIO_GPIO1;		break;
-		case 50: pa_dwr_set = GPIO_GPIO0;		break;
-		}
-		break;
-
-	case 1:
-		pa_dwr_mask = GPIO_GPIO2 | GPIO_GPIO3;
-
-		switch (state->Vcc) {
-		default:
-		case 0:  pa_dwr_set = 0;			break;
-		case 33: pa_dwr_set = GPIO_GPIO2;		break;
-		case 50: pa_dwr_set = GPIO_GPIO3;		break;
-		}
-
-	default:
-		return -1;
-	}
-
-	if (state->Vpp != state->Vcc && state->Vpp != 0) {
-		printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n",
-			__FUNCTION__, state->Vpp);
-		return -1;
-	}
-
-	ret = sa1111_pcmcia_configure_socket(skt, state);
-	if (ret == 0) {
-		unsigned long flags;
-
-		local_irq_save(flags);
-		PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
-		local_irq_restore(flags);
-	}
-
-	return ret;
-}
-
-static struct pcmcia_low_level adsbitsy_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-	.hw_init		= adsbitsy_pcmcia_hw_init,
-	.hw_shutdown		= sa1111_pcmcia_hw_shutdown,
-	.socket_state		= sa1111_pcmcia_socket_state,
-	.configure_socket	= adsbitsy_pcmcia_configure_socket,
-	.socket_init		= sa1111_pcmcia_socket_init,
-	.socket_suspend		= sa1111_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_adsbitsy_init(struct device *dev)
-{
-	int ret = -ENODEV;
-	if (machine_is_adsbitsy())
-		ret = sa11xx_drv_pcmcia_probe(dev, &adsbitsy_pcmcia_ops, 0, 2);
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_flexanet.c b/drivers/pcmcia/sa1100_flexanet.c
--- a/drivers/pcmcia/sa1100_flexanet.c	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,168 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_flexanet.c
- *
- * PCMCIA implementation routines for Flexanet.
- * by Jordi Colomer, 09/05/2001
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include "sa1100_generic.h"
-
-static struct pcmcia_irqs irqs[] = {
-	{ 0, IRQ_GPIO_CF1_CD,   "CF1_CD"   },
-	{ 0, IRQ_GPIO_CF1_BVD1, "CF1_BVD1" },
-	{ 1, IRQ_GPIO_CF2_CD,   "CF2_CD"   },
-	{ 1, IRQ_GPIO_CF2_BVD1, "CF2_BVD1" }
-};
-
-/*
- * Socket initialization.
- *
- * Called by sa1100_pcmcia_driver_init on startup.
- */
-static int flexanet_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
-{
-	skt->irq = skt->nr ? IRQ_GPIO_CF2_IRQ : IRQ_GPIO_CF1_IRQ;
-
-	return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-
-/*
- * Socket shutdown
- */
-static void flexanet_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-
-/*
- * Get the state of the sockets.
- *
- *  Sockets in Flexanet are 3.3V only, without BVD2.
- *
- */
-static void
-flexanet_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
-			     struct pcmcia_state *state)
-{
-	unsigned long levels = GPLR; /* Sense the GPIOs, asynchronously */
-
-	switch (skt->nr) {
-	ase 0: /* Socket 0 */
-		state->detect = ((levels & GPIO_CF1_NCD)==0)?1:0;
-		state->ready  = (levels & GPIO_CF1_IRQ)?1:0;
-		state->bvd1   = (levels & GPIO_CF1_BVD1)?1:0;
-		state->bvd2   = 1;
-		state->wrprot = 0;
-		state->vs_3v  = 1;
-		state->vs_Xv  = 0;
-		break;
-
-	case 1: /* Socket 1 */
-		state->detect = ((levels & GPIO_CF2_NCD)==0)?1:0;
-		state->ready  = (levels & GPIO_CF2_IRQ)?1:0;
-		state->bvd1   = (levels & GPIO_CF2_BVD1)?1:0;
-		state->bvd2   = 1;
-		state->wrprot = 0;
-		state->vs_3v  = 1;
-		state->vs_Xv  = 0;
-		break;
-	}
-}
-
-
-/*
- *
- */
-static int
-flexanet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-				 const socket_state_t *state)
-{
-	unsigned long value, flags, mask;
-
-	/* Ignore the VCC level since it is 3.3V and always on */
-	switch (state->Vcc) {
-	case 0:
-		printk(KERN_WARNING "%s(): CS asked to power off.\n",
-			__FUNCTION__);
-		break;
-
-	case 50:
-		printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
-			__FUNCTION__);
-
-	case 33:
-		break;
-
-	default:
-		printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
-		       state->Vcc);
-		return -1;
-	}
-
-	/* Reset the slot(s) using the controls in the BCR */
-	mask = 0;
-
-	switch (skt->nr) {
-	case 0:
-		mask = FHH_BCR_CF1_RST;
-		break;
-	case 1:
-		mask = FHH_BCR_CF2_RST;
-		break;
-	}
-
-	local_irq_save(flags);
-
-	value = flexanet_BCR;
-	value = (state->flags & SS_RESET) ? (value | mask) : (value & ~mask);
-	FHH_BCR = flexanet_BCR = value;
-
-	local_irq_restore(flags);
-
-	return 0;
-}
-
-static void flexanet_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void flexanet_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-/*
- * The set of socket operations
- *
- */
-static struct pcmcia_low_level flexanet_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-	.hw_init		= flexanet_pcmcia_hw_init,
-	.hw_shutdown		= flexanet_pcmcia_hw_shutdown,
-	.socket_state		= flexanet_pcmcia_socket_state,
-	.configure_socket	= flexanet_pcmcia_configure_socket,
-	.socket_init		= flexanet_pcmcia_socket_init,
-	.socket_suspend		= flexanet_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_flexanet_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_flexanet())
-		ret = sa11xx_drv_pcmcia_probe(dev, &flexanet_pcmcia_ops, 0, 2);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_freebird.c b/drivers/pcmcia/sa1100_freebird.c
--- a/drivers/pcmcia/sa1100_freebird.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,135 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_freebird.c
- *
- * Created by Eric Peng <ericpeng@coventive.com>
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include "sa1100_generic.h"
-
-static struct pcmcia_irqs irqs[] = {
-	{ 0, IRQ_GPIO_FREEBIRD_CF_CD,  "CF_CD"   },
-	{ 0, IRQ_GPIO_FREEBIRD_CF_BVD, "CF_BVD1" },
-};
-
-static int freebird_pcmcia_init(struct soc_pcmcia_socket *skt)
-{
-	/* Enable Linkup CF card */
-	LINKUP_PRC = 0xc0;
-	mdelay(100);
-	LINKUP_PRC = 0xc1;
-	mdelay(100);
-	LINKUP_PRC = 0xd1;
-	mdelay(100);
-	LINKUP_PRC = 0xd1;
-	mdelay(100);
-	LINKUP_PRC = 0xc0;
-
-	skt->irq = IRQ_GPIO_FREEBIRD_CF_IRQ;
-
-	return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void freebird_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs);
-
-	/* Disable CF card */
-	LINKUP_PRC = 0x40;  /* SSP=1   SOE=0 */
-	mdelay(100);
-}
-
-static void
-freebird_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
-{
-	unsigned long levels = LINKUP_PRS;
-//	printk("LINKUP_PRS=%x\n",levels);
-
-	state->detect = ((levels & (LINKUP_CD1 | LINKUP_CD2))==0)?1:0;
-	state->ready  = (levels & LINKUP_RDY)?1:0;
-	state->bvd1   = (levels & LINKUP_BVD1)?1:0;
-	state->bvd2   = (levels & LINKUP_BVD2)?1:0;
-	state->wrprot = 0; /* Not available on Assabet. */
-	state->vs_3v  = 1;  /* Can only apply 3.3V on Assabet. */
-	state->vs_Xv  = 0;
-}
-
-static int
-freebird_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-				 socket_state_t *state)
-{
-	unsigned long value, flags;
-
-	local_irq_save(flags);
-
-	value = 0xc0;   /* SSP=1  SOE=1  CFE=1 */
-
-	switch (state->Vcc) {
-	case 0:
-		break;
-
-	case 50:
-		printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
-			__FUNCTION__);
-
-	case 33:  /* Can only apply 3.3V to the CF slot. */
-		value |= LINKUP_S1;
-		break;
-
-	default:
-		printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
-			__FUNCTION__, state->Vcc);
-		local_irq_restore(flags);
-		return -1;
-	}
-
-	if (state->flags & SS_RESET)
-		value |= LINKUP_RESET;
-
-	/* Silently ignore Vpp, output enable, speaker enable. */
-
-	LINKUP_PRC = value;
-//	printk("LINKUP_PRC=%x\n",value);
-	local_irq_restore(flags);
-
-	return 0;
-}
-
-static void freebird_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void freebird_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static struct pcmcia_low_level freebird_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-	.hw_init		= freebird_pcmcia_hw_init,
-	.hw_shutdown		= freebird_pcmcia_hw_shutdown,
-	.socket_state		= freebird_pcmcia_socket_state,
-	.configure_socket	= freebird_pcmcia_configure_socket,
-
-	.socket_init		= freebird_pcmcia_socket_init,
-	.socket_suspend		= freebird_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_freebird_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_freebird())
-		ret = sa11xx_drv_pcmcia_probe(dev, &freebird_pcmcia_ops, 0, 1);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
--- a/drivers/pcmcia/sa1100_generic.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/pcmcia/sa1100_generic.c	2004-12-24 13:37:00 -08:00
@@ -48,35 +48,14 @@
 #ifdef CONFIG_SA1100_CERF
 	pcmcia_cerf_init,
 #endif
-#ifdef CONFIG_SA1100_FLEXANET
-	pcmcia_flexanet_init,
-#endif
-#ifdef CONFIG_SA1100_FREEBIRD
-	pcmcia_freebird_init,
-#endif
-#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-	pcmcia_gcplus_init,
-#endif
 #ifdef CONFIG_SA1100_H3600
 	pcmcia_h3600_init,
 #endif
-#ifdef CONFIG_SA1100_PANGOLIN
-	pcmcia_pangolin_init,
-#endif
 #ifdef CONFIG_SA1100_SHANNON
 	pcmcia_shannon_init,
 #endif
 #ifdef CONFIG_SA1100_SIMPAD
 	pcmcia_simpad_init,
-#endif
-#ifdef CONFIG_SA1100_STORK
-	pcmcia_stork_init,
-#endif
-#ifdef CONFIG_SA1100_TRIZEPS
-	pcmcia_trizeps_init,
-#endif
-#ifdef CONFIG_SA1100_YOPY
-	pcmcia_yopy_init,
 #endif
 };
 
diff -Nru a/drivers/pcmcia/sa1100_graphicsclient.c b/drivers/pcmcia/sa1100_graphicsclient.c
--- a/drivers/pcmcia/sa1100_graphicsclient.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,154 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_graphicsclient.c
- *
- * PCMCIA implementation routines for Graphics Client Plus
- *
- * 9/12/01   Woojung
- *    Turn power OFF at startup
- * 1/31/2001 Woojung Huh
- *    Fix for GC Plus PCMCIA Reset Problem
- * 2/27/2001 Woojung Huh [whuh@applieddata.net]
- *    Fix
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include "sa1100_generic.h"
-
-#error This is broken!
-
-#define	S0_CD_IRQ		60				// Socket 0 Card Detect IRQ
-#define	S0_STS_IRQ		55				// Socket 0 PCMCIA IRQ
-
-static volatile unsigned long *PCMCIA_Status = 
-		((volatile unsigned long *) ADS_p2v(_ADS_CS_STATUS));
-
-static volatile unsigned long *PCMCIA_Power = 
-		((volatile unsigned long *) ADS_p2v(_ADS_CS_PR));
-
-static struct pcmcia_irqs irqs[] = {
-	{ 0, S0_CD_IRQ, "PCMCIA 0 CD" },
-};
-
-static int gcplus_pcmcia_init(struct soc_pcmcia_socket *skt)
-{
-	// Reset PCMCIA
-	// Reset Timing for CPLD(U2) version 8001E or later
-	*PCMCIA_Power &= ~ ADS_CS_PR_A_RESET;
-	udelay(12);			// 12 uSec
-
-	*PCMCIA_Power |= ADS_CS_PR_A_RESET;
-	mdelay(30);			// 30 mSec
-
-	// Turn off 5V
-	*PCMCIA_Power &= ~0x03;
-
-	skt->irq = S0_STS_IRQ;
-
-	/* Register interrupts */
-	return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void gcplus_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-	/* disable IRQs */
-	free_irq(S0_CD_IRQ, skt);
-  
-	/* Shutdown PCMCIA power */
-	mdelay(2);			// 2msec
-	*PCMCIA_Power &= ~0x03;
-}
-
-static void
-gcplus_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
-{
-	unsigned long levels = *PCMCIA_Status;
-
-	state->detect=(levels & ADS_CS_ST_A_CD)?1:0;
-	state->ready=(levels & ADS_CS_ST_A_READY)?1:0;
-	state->bvd1= 0;
-	state->bvd2= 0;
-	state->wrprot=0;
-	state->vs_3v=0;
-	state->vs_Xv=0;
-}
-
-static int
-gcplus_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-			       const socket_state_t *state)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	switch (state->Vcc) {
-	case 0:
-		*PCMCIA_Power &= ~(ADS_CS_PR_A_3V_POWER | ADS_CS_PR_A_5V_POWER);
-		break;
-
-	case 50:
-		*PCMCIA_Power &= ~(ADS_CS_PR_A_3V_POWER | ADS_CS_PR_A_5V_POWER);
-		*PCMCIA_Power |= ADS_CS_PR_A_5V_POWER;
-		break;
-
-	case 33:
-		*PCMCIA_Power &= ~(ADS_CS_PR_A_3V_POWER | ADS_CS_PR_A_5V_POWER);
-		*PCMCIA_Power |= ADS_CS_PR_A_3V_POWER;
-		break;
-
-	default:
-		printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
-			__FUNCTION__, state->Vcc);
-		local_irq_restore(flags);
-		return -1;
-	}
-
-	/* Silently ignore Vpp, output enable, speaker enable. */
-
-	// Reset PCMCIA
-	*PCMCIA_Power &= ~ ADS_CS_PR_A_RESET;
-	udelay(12);
-
-	*PCMCIA_Power |= ADS_CS_PR_A_RESET;
-	mdelay(30);
-
-	local_irq_restore(flags);
-
-	return 0;
-}
-
-static void gcplus_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-}
-
-static void gcplus_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-}
-
-static struct pcmcia_low_level gcplus_pcmcia_ops = { 
-	.owner			= THIS_MODULE,
-	.hw_init		= gcplus_pcmcia_hw_init,
-	.hw_shutdown		= gcplus_pcmcia_hw_shutdown,
-	.socket_state		= gcplus_pcmcia_socket_state,
-	.configure_socket	= gcplus_pcmcia_configure_socket,
-	.socket_init		= gcplus_pcmcia_socket_init,
-	.socket_suspend		= gcplus_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_gcplus_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_gcplus())
-		ret = sa11xx_drv_pcmcia_probe(dev, &gcplus_pcmcia_ops, 0, 1);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_graphicsmaster.c b/drivers/pcmcia/sa1100_graphicsmaster.c
--- a/drivers/pcmcia/sa1100_graphicsmaster.c	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,106 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_graphicsmaster.c
- *
- * PCMCIA implementation routines for GraphicsMaster
- *
- * 9/18/01 Woojung
- *         Fixed wrong PCMCIA voltage setting
- * 7/5/01 Woojung Huh <whuh@applieddata.net>
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-
-#include "sa1111_generic.h"
-
-static int graphicsmaster_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
-{
-  int return_val=0;
-
-  /* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
-  PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
-
-  /* Disable Power 3.3V/5V for PCMCIA/CF */
-  PA_DWR |= GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
-
-  /* why? */
-  MECR = 0x09430943;
-
-  return sa1111_pcmcia_hwinit(skt);
-}
-
-static int
-graphicsmaster_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-				       const socket_state_t *state)
-{
-	unsigned int pa_dwr_mask, pa_dwr_set;
-	int ret;
-
-	switch (skt->nr) {
-	case 0:
-		pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1;
-
-		switch (state->Vcc) {
-		default:
-		case 0:  pa_dwr_set = GPIO_GPIO0 | GPIO_GPIO1;	break;
-		case 33: pa_dwr_set = GPIO_GPIO1;		break;
-		case 50: pa_dwr_set = GPIO_GPIO0;		break;
-		}
-		break;
-
-	case 1:
-		pa_dwr_mask = GPIO_GPIO2 | GPIO_GPIO3;
-
-		switch (state->Vcc) {
-		default:
-		case 0:  pa_dwr_set = GPIO_GPIO2 | GPIO_GPIO3;	break;
-		case 33: pa_dwr_set = GPIO_GPIO3;		break;
-		case 50: pa_dwr_set = GPIO_GPIO2;		break;
-		}
-		break;
-	}
-
-	if (state->Vpp != state->Vcc && state->Vpp != 0) {
-		printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n",
-			__FUNCTION__, state->Vpp);
-		return -1;
-	}
-
-	ret = sa1111_pcmcia_configure_socket(skt, state);
-	if (ret == 0) {
-		unsigned long flags;
-
-		local_irq_save(flags);
-		PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
-		local_irq_restore(flags);
-	}
-
-	return ret;
-}
-
-static struct pcmcia_low_level graphicsmaster_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-	.hw_init		= graphicsmaster_pcmcia_init,
-	.hw_shutdown		= sa1111_pcmcia_hw_shutdown,
-	.socket_state		= sa1111_pcmcia_socket_state,
-	.configure_socket	= graphicsmaster_pcmcia_configure_socket,
-
-	.socket_init		= sa1111_pcmcia_socket_init,
-	.socket_suspend		= sa1111_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_graphicsmaster_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_graphicsmaster())
-		ret = sa11xx_drv_pcmcia_probe(dev, &graphicsmaster_pcmcia_ops, 0, 2);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_pangolin.c b/drivers/pcmcia/sa1100_pangolin.c
--- a/drivers/pcmcia/sa1100_pangolin.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,147 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_pangolin.c
- *
- * PCMCIA implementation routines for Pangolin
- *
- */
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include "sa1100_generic.h"
-
-#ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
-#define PANGOLIN_SOCK	1
-#else
-#define PANGOLIN_SOCK	0
-#endif
-
-static struct pcmcia_irqs irqs[] = {
-	{ PANGOLIN_SOCK, IRQ_PCMCIA_CD, "PCMCIA CD" },
-};
-
-static int pangolin_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
-{
-	int res;
-
-#ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
-	/* Enable PCMCIA bus: */
-	GPCR = GPIO_PCMCIA_BUS_ON;
-#endif
-
-	skt->irq = IRQ_PCMCIA_IRQ;
-
-	return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void pangolin_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
-
-#ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
-	/* Disable PCMCIA bus: */
-	GPSR = GPIO_PCMCIA_BUS_ON;
-#endif
-}
-
-static void
-pangolin_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
-			     struct pcmcia_state *state)
-{
-	unsigned long levels = GPLR;
-
-	state->detect=((levels & GPIO_PCMCIA_CD)==0)?1:0;
-	state->ready=(levels & GPIO_PCMCIA_IRQ)?1:0;
-	state->bvd1=1; /* Not available on Pangolin. */
-	state->bvd2=1; /* Not available on Pangolin. */
-	state->wrprot=0; /* Not available on Pangolin. */
-	state->vs_3v=1;  /* Can only apply 3.3V on Pangolin. */
-	state->vs_Xv=0;
-}
-
-static int
-pangolin_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-				 const socket_state_t *state)
-{
-	unsigned long value, flags;
-
-	local_irq_save(flags);
-
-	/* Murphy: BUS_ON different from POWER ? */
-
-	switch (state->Vcc) {
-	case 0:
-		break;
-#ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
-	case 50:
-		printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
-			__FUNCTION__);
-	case 33:  /* Can only apply 3.3V to the CF slot. */
-		break;
-#else
-	case 50:
-		printk(KERN_WARNING "%s(): CS asked for 5V, determinded by "
-			"jumper setting...\n", __FUNCTION__);
-		break;
-	case 33:
-		printk(KERN_WARNING "%s(): CS asked for 3.3V, determined by "
-			"jumper setting...\n", __FUNCTION__);
-		break;
-#endif
-	default:
-		printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
-			__FUNCTION__, state->Vcc);
-		local_irq_restore(flags);
-		return -1;
-	}
-#ifdef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
-	/* reset & unreset request */
-	if (skt->nr == 0) {
-		if (state->flags & SS_RESET) {
-			GPSR = GPIO_PCMCIA_RESET;
-		} else {
-			GPCR = GPIO_PCMCIA_RESET;
-		}
-	}
-#endif
-	/* Silently ignore Vpp, output enable, speaker enable. */
-	local_irq_restore(flags);
-	return 0;
-}
-
-static void pangolin_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void pangolin_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static struct pcmcia_low_level pangolin_pcmcia_ops = { 
-	.owner			= THIS_MODULE,
-	.hw_init		= pangolin_pcmcia_hw_init,
-	.hw_shutdown		= pangolin_pcmcia_hw_shutdown,
-	.socket_state		= pangolin_pcmcia_socket_state,
-	.configure_socket	= pangolin_pcmcia_configure_socket,
-
-	.socket_init		= pangolin_pcmcia_socket_init,
-	.socket_suspend		= pangolin_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_pangolin_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_pangolin())
-		ret = sa11xx_drv_pcmcia_probe(dev, &pangolin_pcmcia_ops, PANGOLIN_SOCK, 1);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_pfs168.c b/drivers/pcmcia/sa1100_pfs168.c
--- a/drivers/pcmcia/sa1100_pfs168.c	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,141 +0,0 @@
-#warning	"REVISIT_PFS168: Need to verify and test GPIO power encodings."
-/*
- * drivers/pcmcia/sa1100_pfs168.c
- *
- * PFS168 PCMCIA specific routines
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-
-#include "sa1111_generic.h"
-
-static int pfs168_pcmcia_init(struct soc_pcmcia_socket *skt)
-{
-  /* TPS2211 to standby mode: */
-  PA_DWR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
-
-  /* Set GPIO_A<3:0> to be outputs for PCMCIA (socket 0) power controller: */
-  PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
-
-  return sa1111_pcmcia_init(skt);
-}
-
-static int
-pfs168_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-			       const socket_state_t *state)
-{
-  unsigned int pa_dwr_mask = 0, pa_dwr_set = 0;
-  int ret;
-
-  /* PFS168 uses the Texas Instruments TPS2211 for PCMCIA (socket 0) voltage control only,
-   * with the following connections:
-   *
-   *   TPS2211      PFS168
-   *
-   *    -VCCD0      SA-1111 GPIO A<0>
-   *    -VCCD0      SA-1111 GPIO A<1>
-   *     VPPD0      SA-1111 GPIO A<2>
-   *     VPPD0      SA-1111 GPIO A<2>
-   *
-   */
-
-  switch (skt->nr) {
-  case 0:
-    pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
-
-    switch (state->Vcc) {
-    default:
-    case 0:	pa_dwr_set = 0;			break;
-    case 33:	pa_dwr_set = GPIO_GPIO0;	break;
-    case 50:	pa_dwr_set = GPIO_GPIO1;	break;
-    }
-
-    switch (state->Vpp) {
-    case 0:
-      break;
-
-    case 120:
-      printk(KERN_ERR "%s(): PFS-168 does not support VPP %uV\n",
-	     __FUNCTION__, state->Vpp / 10);
-      return -1;
-      break;
-
-    default:
-      if (state->Vpp == state->Vcc)
-        pa_dwr_set |= GPIO_GPIO3;
-      else {
-	printk(KERN_ERR "%s(): unrecognized VPP %u\n", __FUNCTION__,
-	       state->Vpp);
-	return -1;
-      }
-    }
-    break;
-
-  case 1:
-    pa_dwr_mask = 0;
-    pa_dwr_set = 0;
-
-    switch (conf->vcc) {
-    case 0:
-    case 33:
-      break;
-
-    case 50:
-      printk(KERN_ERR "%s(): PFS-168 CompactFlash socket does not support VCC %uV\n",
-	     __FUNCTION__, state->Vcc / 10);
-      return -1;
-
-    default:
-      printk(KERN_ERR "%s(): unrecognized VCC %u\n", __FUNCTION__,
-	     state->Vcc);
-      return -1;
-    }
-
-    if (state->Vpp != state->Vcc && state->Vpp != 0) {
-      printk(KERN_ERR "%s(): CompactFlash socket does not support VPP %uV\n",
-	     __FUNCTION__, state->Vpp / 10);
-      return -1;
-    }
-    break;
-  }
-
-  ret = sa1111_pcmcia_configure_socket(skt, state);
-  if (ret == 0) {
-    unsigned long flags;
-
-    local_irq_save(flags);
-    PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
-    local_irq_restore(flags);
-  }
-
-  return 0;
-}
-
-static struct pcmcia_low_level pfs168_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-	.hw_init		= pfs168_pcmcia_hw_init,
-	.hw_shutdown		= sa1111_pcmcia_hw_shutdown,
-	.socket_state		= sa1111_pcmcia_socket_state,
-	.configure_socket	= pfs168_pcmcia_configure_socket,
-	.socket_init		= sa1111_pcmcia_socket_init,
-	.socket_suspend		= sa1111_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_pfs168_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_pfs168())
-		ret = sa11xx_drv_pcmcia_probe(dev, &pfs168_pcmcia_ops, 0, 2);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_simpad.c b/drivers/pcmcia/sa1100_simpad.c
--- a/drivers/pcmcia/sa1100_simpad.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/pcmcia/sa1100_simpad.c	2004-12-24 13:37:29 -08:00
@@ -48,7 +48,7 @@
 			   struct pcmcia_state *state)
 {
 	unsigned long levels = GPLR;
-	unsigned long *cs3reg = CS3_BASE;
+	long cs3reg = get_cs3_shadow();
 
 	state->detect=((levels & GPIO_CF_CD)==0)?1:0;
 	state->ready=(levels & GPIO_CF_IRQ)?1:0;
@@ -56,7 +56,7 @@
 	state->bvd2=1; /* Not available on Simpad. */
 	state->wrprot=0; /* Not available on Simpad. */
   
-	if((*cs3reg & 0x0c) == 0x0c) {
+	if((cs3reg & 0x0c) == 0x0c) {
 		state->vs_3v=0;
 		state->vs_Xv=0;
 	} else {
diff -Nru a/drivers/pcmcia/sa1100_stork.c b/drivers/pcmcia/sa1100_stork.c
--- a/drivers/pcmcia/sa1100_stork.c	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,198 +0,0 @@
-/* 
- * drivers/pcmcia/sa1100_stork.c
- *
-    Copyright 2001 (C) Ken Gordon
-
-    This is derived from pre-existing drivers/pcmcia/sa1100_?????.c
-
-    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.
-
-    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.
-
- * 
- * PCMCIA implementation routines for stork
- *
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include "sa1100_generic.h"
-
-static int debug = 0;
-
-static struct pcmcia_irqs irqs[] = {
-	{ 0, IRQ_GPIO_STORK_PCMCIA_A_CARD_DETECT, "PCMCIA_CD0" },
-	{ 1, IRQ_GPIO_STORK_PCMCIA_B_CARD_DETECT, "PCMCIA_CD1" },
-};
-
-static int stork_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
-{
-	printk("in stork_pcmcia_init\n");
-
-	skt->irq = skt->nr ? IRQ_GPIO_STORK_PCMCIA_B_RDY
-			   : IRQ_GPIO_STORK_PCMCIA_A_RDY;
-
-	return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void stork_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-	int i;
-
-        printk("%s\n", __FUNCTION__);
-
-        /* disable IRQs */
-        soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
-  
-        /* Disable CF bus: */
-        storkClearLatchA(STORK_PCMCIA_PULL_UPS_POWER_ON);
-	storkClearLatchA(STORK_PCMCIA_A_POWER_ON);
-	storkClearLatchA(STORK_PCMCIA_B_POWER_ON);
-}
-
-static void
-stork_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
-			  struct pcmcia_state *state)
-{
-        unsigned long levels = GPLR;
-
-	if (debug > 1)
-		printk("%s GPLR=%x IRQ[1:0]=%x\n", __FUNCTION__, levels,
-			(levels & (GPIO_STORK_PCMCIA_A_RDY|GPIO_STORK_PCMCIA_B_RDY)));
-
-	switch (skt->nr) {
-	case 0:
-		state->detect=((levels & GPIO_STORK_PCMCIA_A_CARD_DETECT)==0)?1:0;
-		state->ready=(levels & GPIO_STORK_PCMCIA_A_RDY)?1:0;
-		state->bvd1= 1;
-		state->bvd2= 1;
-		state->wrprot=0;
-		state->vs_3v=1;
-		state->vs_Xv=0;
-		break;
-
-	case 1:
-		state->detect=((levels & GPIO_STORK_PCMCIA_B_CARD_DETECT)==0)?1:0;
-		state->ready=(levels & GPIO_STORK_PCMCIA_B_RDY)?1:0;
-		state->bvd1=1;
-		state->bvd2=1;
-		state->wrprot=0;
-		state->vs_3v=1;
-		state->vs_Xv=0;
-		break;
-	}
-}
-
-static int
-stork_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-			      const socket_state_t *state)
-{
-	unsigned long flags;
-        int DETECT, RDY, POWER, RESET;
-
-	printk("%s: socket=%d vcc=%d vpp=%d reset=%d\n", __FUNCTION__,
-		skt->nr, state->Vcc, state->Vpp, state->flags & SS_RESET ? 1 : 0);
-
-	local_irq_save(flags);
-
-        if (skt->nr == 0) {
-    	    DETECT = GPIO_STORK_PCMCIA_A_CARD_DETECT;
-    	    RDY = GPIO_STORK_PCMCIA_A_RDY;
-    	    POWER = STORK_PCMCIA_A_POWER_ON;
-    	    RESET = STORK_PCMCIA_A_RESET;
-        } else {
-    	    DETECT = GPIO_STORK_PCMCIA_B_CARD_DETECT;
-    	    RDY = GPIO_STORK_PCMCIA_B_RDY;
-    	    POWER = STORK_PCMCIA_B_POWER_ON;
-    	    RESET = STORK_PCMCIA_B_RESET;
-        }
-    
-/*
-        if (storkTestGPIO(DETECT)) {
-           printk("no card detected - but resetting anyway\r\n");
-        }
-*/
-	switch (state->Vcc) {
-	case 0:
-/*		storkClearLatchA(STORK_PCMCIA_PULL_UPS_POWER_ON); */
-                storkClearLatchA(POWER);
-		break;
-
-	case 50:
-	case 33:
-                storkSetLatchA(STORK_PCMCIA_PULL_UPS_POWER_ON);
-                storkSetLatchA(POWER);
-		break;
-
-	default:
-		printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
-		       state->Vcc);
-		local_irq_restore(flags);
-		return -1;
-	}
-
-	if (state->flags & SS_RESET)
-                storkSetLatchB(RESET);
-	else
-                storkClearLatchB(RESET);
-
-	local_irq_restore(flags);
-
-        /* silently ignore vpp and speaker enables. */
-
-        printk("%s: finished\n", __FUNCTION__);
-
-        return 0;
-}
-
-static void stork_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-        storkSetLatchA(STORK_PCMCIA_PULL_UPS_POWER_ON);
-
-        soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void stork_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-
-	/*
-	 * Hack!
-	 */
-	if (skt->nr == 1)
-	        storkClearLatchA(STORK_PCMCIA_PULL_UPS_POWER_ON);
-
-	return 0;
-}
-
-static struct pcmcia_low_level stork_pcmcia_ops = { 
-	.owner			= THIS_MODULE,
-	.hw_init		= stork_pcmcia_hw_init,
-	.hw_shutdown		= stork_pcmcia_hw_shutdown,
-	.socket_state		= stork_pcmcia_socket_state,
-	.configure_socket	= stork_pcmcia_configure_socket,
-
-	.socket_init		= stork_pcmcia_socket_init,
-	.socket_suspend		= stork_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_stork_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_stork())
-		ret = sa11xx_drv_pcmcia_probe(dev, &stork_pcmcia_ops, 0, 2);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_system3.c b/drivers/pcmcia/sa1100_system3.c
--- a/drivers/pcmcia/sa1100_system3.c	2004-12-24 13:37:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,115 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_system3.c
- *
- * PT Diagital Board PCMCIA specific routines
- *
- * Copyright (C) 2001 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
- *
- * $Id: sa1100_system3.c,v 1.1.4.2 2002/02/25 13:56:45 seletz Exp $
- *
- * 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.
- *
- * $Log: sa1100_system3.c,v $
- * Revision 1.1.4.2  2002/02/25 13:56:45  seletz
- * - more cleanups
- * - setup interrupts for CF card only ATM
- *
- * Revision 1.1.4.1  2002/02/14 02:23:27  seletz
- * - 2.5.2-rmk6 PCMCIA changes
- *
- * Revision 1.1.2.1  2002/02/13 23:49:33  seletz
- * - added from 2.4.16-rmk2
- * - cleanups
- *
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/ioport.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include <asm/hardware/sa1111.h>
-
-#include "sa1111_generic.h"
-
-#define DEBUG 0
-
-#ifdef DEBUG
-#	define DPRINTK( x, args... )	printk( "%s: line %d: "x, __FUNCTION__, __LINE__, ## args  );
-#else
-#	define DPRINTK( x, args... )	/* nix */
-#endif
-
-static int system3_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
-{
-	skt->irq = skt->nr ? IRQ_S1_READY_NINT : IRQ_S0_READY_NINT;
-
-	/* Don't need no CD and BVD* interrupts */
-	return 0;
-}
-
-void system3_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-}
-
-static void
-system3_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
-{
-	unsigned long status = PCSR;
-
-	switch (skt->nr) {
-#if 0 /* PCMCIA socket not yet connected */
-	case 0:
-		state->detect = status & PCSR_S0_DETECT ? 0 : 1;
-		state->ready  = status & PCSR_S0_READY  ? 1 : 0;
-		state->bvd1   = status & PCSR_S0_BVD1   ? 1 : 0;
-		state->bvd2   = 1;
-		state->wrprot = status & PCSR_S0_WP     ? 1 : 0;
-		state->vs_3v  = 1;
-		state->vs_Xv  = 0;
-		break;
-#endif
-
-	case 1:
-		state->detect = status & PCSR_S1_DETECT ? 0 : 1;
-		state->ready  = status & PCSR_S1_READY  ? 1 : 0;
-		state->bvd1   = status & PCSR_S1_BVD1   ? 1 : 0;
-		state->bvd2   = 1;
-		state->wrprot = status & PCSR_S1_WP     ? 1 : 0;
-		state->vs_3v  = 1;
-		state->vs_Xv  = 0;
-		break;
-	}
-
-	DPRINTK("Sock %d PCSR=0x%08lx, Sx_RDY_nIREQ=%d\n",
-		skt->nr, status, state->ready);
-}
-
-struct pcmcia_low_level system3_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-	.init			= system3_pcmcia_hw_init,
-	.shutdown		= system3_pcmcia_hw_shutdown,
-	.socket_state		= system3_pcmcia_socket_state,
-	.configure_socket	= sa1111_pcmcia_configure_socket,
-
-	.socket_init		= sa1111_pcmcia_socket_init,
-	.socket_suspend		= sa1111_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_system3_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_pt_system3())
-		/* only CF ATM */
-		ret = sa11xx_drv_pcmcia_probe(dev, &system3_pcmcia_ops, 1, 1);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_trizeps.c b/drivers/pcmcia/sa1100_trizeps.c
--- a/drivers/pcmcia/sa1100_trizeps.c	2004-12-24 13:36:59 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,165 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_trizeps.c
- *
- * PCMCIA implementation routines for Trizeps
- *
- * Authors:
- * Andreas Hofer <ho@dsa-ac.de>,
- * Peter Lueg <pl@dsa-ac.de>,
- * Guennadi Liakhovetski <gl@dsa-ac.de>
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/arch/trizeps.h>
-#include <asm/mach-types.h>
-#include <asm/system.h>
-#include <asm/irq.h>
-#include "sa1100_generic.h"
-
-#define NUMBER_OF_TRIZEPS_PCMCIA_SLOTS 1
-
-static struct pcmcia_irqs irqs[] = {
-	{ 0, TRIZEPS_IRQ_PCMCIA_CD0, "PCMCIA_CD0" },
-};
-
-/**
- *
- *
- ******************************************************/
-static int trizeps_pcmcia_init(struct soc_pcmcia_socket *skt)
-{
-	skt->irq = TRIZEPS_IRQ_PCMCIA_IRQ0;
-
-	/* Enable CF bus: */
-	TRIZEPS_BCR_clear(TRIZEPS_BCR1, TRIZEPS_nPCM_ENA_REG);
-
-	/* All those are inputs */
-	GPDR &= ~((GPIO_GPIO(TRIZEPS_GPIO_PCMCIA_CD0))
-		    | (GPIO_GPIO(TRIZEPS_GPIO_PCMCIA_IRQ0)));
-
-	return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-/**
- *
- *
- ******************************************************/
-static void trizeps_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
-{
-	printk(">>>>>PCMCIA TRIZEPS shutdown\n");
-
-	soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
-
-	/* Disable CF bus: */
-	TRIZEPS_BCR_set(TRIZEPS_BCR1, TRIZEPS_nPCM_ENA_REG);
-}
-
-/**
- *
- ******************************************************/
-static void
-trizeps_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
-			    struct pcmcia_state *state_array)
-{
-	unsigned long levels = GPLR;
-
-	state->detect = ((levels & GPIO_GPIO(TRIZEPS_GPIO_PCMCIA_CD0)) == 0) ? 1 : 0;
-	state->ready  = ((levels & GPIO_GPIO(TRIZEPS_GPIO_PCMCIA_IRQ0)) != 0) ? 1 : 0;
-	state->bvd1   = ((TRIZEPS_BCR1 & TRIZEPS_PCM_BVD1) !=0 ) ? 1 : 0;
-	state->bvd2   = ((TRIZEPS_BCR1 & TRIZEPS_PCM_BVD2) != 0) ? 1 : 0;
-	state->wrprot = 0; // not write protected
-	state->vs_3v  = ((TRIZEPS_BCR1 & TRIZEPS_nPCM_VS1) == 0) ? 1 : 0; //VS1=0 -> vs_3v=1
-	state->vs_Xv  = ((TRIZEPS_BCR1 & TRIZEPS_nPCM_VS2) == 0) ? 1 : 0; //VS2=0 -> vs_Xv=1
-}
-
-/**
- *
- *
- ******************************************************/
-static int
-trizeps_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-				const socket_state_t *state)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	switch (state->Vcc) {
-	case 0:
-		printk(">>> PCMCIA Power off\n");
-		TRIZEPS_BCR_clear(TRIZEPS_BCR1, TRIZEPS_PCM_V3_EN_REG);
-		TRIZEPS_BCR_clear(TRIZEPS_BCR1, TRIZEPS_PCM_V5_EN_REG);
-		break;
-
-	case 33:
-		// 3.3V Power on
-		TRIZEPS_BCR_clear(TRIZEPS_BCR1, TRIZEPS_PCM_V3_EN_REG);
-		TRIZEPS_BCR_set(TRIZEPS_BCR1, TRIZEPS_PCM_V5_EN_REG);
-		break;
-	case 50:
-		// 5.0V Power on
-		TRIZEPS_BCR_set(TRIZEPS_BCR1, TRIZEPS_PCM_V3_EN_REG);
-		TRIZEPS_BCR_clear(TRIZEPS_BCR1, TRIZEPS_PCM_V5_EN_REG);
-		break;
-	default:
-		printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
-		       state->Vcc);
-		local_irq_restore(flags);
-		return -1;
-	}
-
-	if (state->flags & SS_RESET)
-		TRIZEPS_BCR_set(TRIZEPS_BCR1, TRIZEPS_nPCM_RESET_DISABLE);   // Reset
-	else
-		TRIZEPS_BCR_clear(TRIZEPS_BCR1, TRIZEPS_nPCM_RESET_DISABLE); // no Reset
-	/*
-	  printk(" vcc=%u vpp=%u -->reset=%i\n",
-	  state->Vcc,
-	  state->Vpp,
-	  ((BCR_read(1) & nPCM_RESET_DISABLE)? 1:0));
-	*/
-	local_irq_restore(flags);
-
-	return 0;
-}
-
-static void trizeps_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void trizeps_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-/**
- * low-level PCMCIA interface
- *
- ******************************************************/
-struct pcmcia_low_level trizeps_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-	.hw_init		= trizeps_pcmcia_hw_init,
-	.hw_shutdown		= trizeps_pcmcia_hw_shutdown,
-	.socket_state		= trizeps_pcmcia_socket_state,
-	.configure_socket	= trizeps_pcmcia_configure_socket,
-	.socket_init		= trizeps_pcmcia_socket_init,
-	.socket_suspend		= trizeps_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_trizeps_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_trizeps())
-		ret = sa11xx_drv_pcmcia_probe(dev, &trizeps_pcmcia_ops, 0,
-					      NUMBER_OF_TRIZEPS_PCMCIA_SLOTS);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_xp860.c b/drivers/pcmcia/sa1100_xp860.c
--- a/drivers/pcmcia/sa1100_xp860.c	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,154 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_xp860.c
- *
- * XP860 PCMCIA specific routines
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include "sa1100_generic.h"
-
-#define NCR_A0VPP	(1<<16)
-#define NCR_A1VPP	(1<<17)
-
-static int xp860_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
-{
-  /* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
-  PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
-  
-  /* MAX1600 to standby mode: */
-  PA_DWR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
-
-#error Consider the following comment
-  /*
-   * 1- Please move GPDR initialisation  where it is interrupt or preemption
-   *    safe (like from xp860_map_io).
-   * 2- The GPCR line is bogus i.e. it will simply have absolutely no effect.
-   *    Please see its definition in the SA1110 manual.
-   * 3- Please do not use NCR_* values!
-   */
-  GPDR |= (NCR_A0VPP | NCR_A1VPP);
-  GPCR &= ~(NCR_A0VPP | NCR_A1VPP);
-
-  return sa1111_pcmcia_hw_init(skt);
-}
-
-static int
-xp860_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
-{
-  unsigned int gpio_mask, pa_dwr_mask;
-  unsigned int gpio_set, pa_dwr_set;
-  int ret;
-
-  /* Neponset uses the Maxim MAX1600, with the following connections:
-#warning ^^^ This isn't a neponset!
-   *
-   *   MAX1600      Neponset
-   *
-   *    A0VCC        SA-1111 GPIO A<1>
-   *    A1VCC        SA-1111 GPIO A<0>
-   *    A0VPP        CPLD NCR A0VPP
-   *    A1VPP        CPLD NCR A1VPP
-   *    B0VCC        SA-1111 GPIO A<2>
-   *    B1VCC        SA-1111 GPIO A<3>
-   *    B0VPP        ground (slot B is CF)
-   *    B1VPP        ground (slot B is CF)
-   *
-   *     VX          VCC (5V)
-   *     VY          VCC3_3 (3.3V)
-   *     12INA       12V
-   *     12INB       ground (slot B is CF)
-   *
-   * The MAX1600 CODE pin is tied to ground, placing the device in 
-   * "Standard Intel code" mode. Refer to the Maxim data sheet for
-   * the corresponding truth table.
-   */
-
-  switch (skt->nr) {
-  case 0:
-    pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1;
-    gpio_mask = NCR_A0VPP | NCR_A1VPP;
-
-    switch (state->Vcc) {
-    default:
-    case 0:	pa_dwr_set = 0;			break;
-    case 33:	pa_dwr_set = GPIO_GPIO1;	break;
-    case 50:	pa_dwr_set = GPIO_GPIO0;	break;
-    }
-
-    switch (state->Vpp) {
-    case 0:	gpio_set = 0;			break;
-    case 120:	gpio_set = NCR_A1VPP;		break;
-
-    default:
-      if (state->Vpp == state->Vcc)
-	gpio_set = NCR_A0VPP;
-      else {
-	printk(KERN_ERR "%s(): unrecognized Vpp %u\n",
-	       __FUNCTION__, state->Vpp);
-	return -1;
-      }
-    }
-    break;
-
-  case 1:
-    pa_dwr_mask = GPIO_GPIO2 | GPIO_GPIO3;
-    gpio_mask = 0;
-    gpio_set = 0;
-
-    switch (state->Vcc) {
-    default:
-    case 0:	pa_dwr_set = 0;			break;
-    case 33:	pa_dwr_set = GPIO_GPIO2;	break;
-    case 50:	pa_dwr_set = GPIO_GPIO3;	break;
-    }
-
-    if (state->Vpp != state->Vcc && state->Vpp != 0) {
-      printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n",
-	     __FUNCTION__, state->Vpp);
-      return -1;
-    }
-    break;
-  }
-
-  ret = sa1111_pcmcia_configure_socket(skt, state);
-  if (ret == 0) {
-    unsigned long flags;
-
-    local_irq_save(flags);
-    PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
-    GPSR = gpio_set;
-    GPCR = gpio_set ^ gpio_mask;
-    local_irq_restore(flags);
-  }
-
-  return ret;
-}
-
-static struct pcmcia_low_level xp860_pcmcia_ops = { 
-	.owner			= THIS_MODULE,
-	.hw_init		= xp860_pcmcia_hw_init,
-	.hw_shutdown		= sa1111_pcmcia_hw_shutdown,
-	.socket_state		= sa1111_pcmcia_socket_state,
-	.configure_socket	= xp860_pcmcia_configure_socket,
-	.socket_init		= sa1111_pcmcia_socket_init,
-	.socket_suspend		= sa1111_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_xp860_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_xp860())
-		ret = sa11xx_drv_pcmcia_probe(dev, &xp860_pcmcia_ops, 0, 2);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1100_yopy.c b/drivers/pcmcia/sa1100_yopy.c
--- a/drivers/pcmcia/sa1100_yopy.c	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,125 +0,0 @@
-/*
- * drivers/pcmcia/sa1100_yopy.c
- *
- * PCMCIA implementation routines for Yopy
- *
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include "sa1100_generic.h"
-
-
-static inline void pcmcia_power(int on) {
-	/* high for power up */
-	yopy_gpio_set(GPIO_CF_POWER, on);
-}
-
-static inline void pcmcia_reset(int reset)
-{
-	/* high for reset */
-	yopy_gpio_set(GPIO_CF_RESET, reset);
-}
-
-static struct pcmcia_irqs irqs[] = {
-	{ 0, IRQ_CF_CD,   "CF_CD"   },
-	{ 0, IRQ_CF_BVD2, "CF_BVD2" },
-	{ 0, IRQ_CF_BVD1, "CF_BVD1" },
-};
-
-static int yopy_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
-{
-	skt->irq = IRQ_CF_IREQ;
-
-	pcmcia_power(0);
-	pcmcia_reset(1);
-
-	return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void yopy_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
-
-	/* Disable CF */
-	pcmcia_reset(1);
-	pcmcia_power(0);
-}
-
-static void
-yopy_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
-			 struct pcmcia_state_array *state)
-{
-	unsigned long levels = GPLR;
-
-	state->detect = (levels & GPIO_CF_CD)    ? 0 : 1;
-	state->ready  = (levels & GPIO_CF_READY) ? 1 : 0;
-	state->bvd1   = (levels & GPIO_CF_BVD1)  ? 1 : 0;
-	state->bvd2   = (levels & GPIO_CF_BVD2)  ? 1 : 0;
-	state->wrprot = 0; /* Not available on Yopy. */
-	state->vs_3v  = 0; /* FIXME Can only apply 3.3V on Yopy. */
-	state->vs_Xv  = 0;
-}
-
-static int
-yopy_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
-			     const socket_state_t *state)
-{
-	switch (state->Vcc) {
-	case 0:	/* power off */
-		pcmcia_power(0);
-		break;
-	case 50:
-		printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __FUNCTION__);
-	case 33:
-		pcmcia_power(1);
-		break;
-	default:
-		printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
-		       __FUNCTION__, state->Vcc);
-		return -1;
-	}
-
-	pcmcia_reset(state->flags & SS_RESET ? 1 : 0);
-
-	/* Silently ignore Vpp, output enable, speaker enable. */
-
-	return 0;
-}
-
-static void yopy_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static void yopy_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
-{
-	soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
-}
-
-static struct pcmcia_low_level yopy_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-	.init			= yopy_pcmcia_init,
-	.shutdown		= yopy_pcmcia_shutdown,
-	.socket_state		= yopy_pcmcia_socket_state,
-	.configure_socket	= yopy_pcmcia_configure_socket,
-
-	.socket_init		= yopy_pcmcia_socket_init,
-	.socket_suspend		= yopy_pcmcia_socket_suspend,
-};
-
-int __init pcmcia_yopy_init(struct device *dev)
-{
-	int ret = -ENODEV;
-
-	if (machine_is_yopy())
-		ret = sa11xx_drv_pcmcia_probe(dev, &yopy_pcmcia_ops, 0, 1);
-
-	return ret;
-}
diff -Nru a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
--- a/drivers/pcmcia/sa1111_generic.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/pcmcia/sa1111_generic.c	2004-12-24 13:36:31 -08:00
@@ -136,15 +136,9 @@
 	sa1111_writel(PCSSR_S0_SLEEP | PCSSR_S1_SLEEP, base + SA1111_PCSSR);
 	sa1111_writel(PCCR_S0_FLT | PCCR_S1_FLT, base + SA1111_PCCR);
 
-#ifdef CONFIG_SA1100_ADSBITSY
-	pcmcia_adsbitsy_init(&dev->dev);
-#endif
 #ifdef CONFIG_SA1100_BADGE4
 	pcmcia_badge4_init(&dev->dev);
 #endif
-#ifdef CONFIG_SA1100_GRAPHICSMASTER
-	pcmcia_graphicsmaster_init(&dev->dev);
-#endif
 #ifdef CONFIG_SA1100_JORNADA720
 	pcmcia_jornada720_init(&dev->dev);
 #endif
@@ -153,15 +147,6 @@
 #endif
 #ifdef CONFIG_ASSABET_NEPONSET
 	pcmcia_neponset_init(dev);
-#endif
-#ifdef CONFIG_SA1100_PFS168
-	pcmcia_pfs_init(&dev->dev);
-#endif
-#ifdef CONFIG_SA1100_PT_SYSTEM3
-	pcmcia_system3_init(&dev->dev);
-#endif
-#ifdef CONFIG_SA1100_XP860
-	pcmcia_xp860_init(&dev->dev);
 #endif
 	return 0;
 }
diff -Nru a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
--- a/drivers/pcmcia/tcic.c	2004-12-24 13:36:57 -08:00
+++ b/drivers/pcmcia/tcic.c	2004-12-24 13:36:57 -08:00
@@ -45,9 +45,9 @@
 #include <linux/delay.h>
 #include <linux/workqueue.h>
 #include <linux/device.h>
+#include <linux/bitops.h>
 
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/system.h>
 
 #include <pcmcia/version.h>
@@ -109,7 +109,7 @@
 module_param(ignore, int, 0444);
 module_param(do_scan, int, 0444);
 module_param(irq_mask, int, 0444);
-module_param_array(irq_list, int, irq_list_count, 0444);
+module_param_array(irq_list, int, &irq_list_count, 0444);
 module_param(cs_irq, int, 0444);
 module_param(poll_interval, int, 0444);
 module_param(poll_quick, int, 0444);
diff -Nru a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
--- a/drivers/pcmcia/yenta_socket.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/pcmcia/yenta_socket.c	2004-12-24 13:37:00 -08:00
@@ -653,6 +653,7 @@
 	yenta_free_resources(sock);
 
 	pci_release_regions(dev);
+	pci_disable_device(dev);
 	pci_set_drvdata(dev, NULL);
 }
 
@@ -688,7 +689,7 @@
  * Different cardbus controllers have slightly different
  * initialization sequences etc details. List them here..
  */
-struct cardbus_type cardbus_type[] = {
+static struct cardbus_type cardbus_type[] = {
 	[CARDBUS_TYPE_TI]	= {
 		.override	= ti_override,
 		.save_state	= ti_save_state,
@@ -827,8 +828,7 @@
 	cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
 	cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
 	
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ/10);
+	msleep(100);
 
 	/* disable interrupts */
 	cb_writel(socket, CB_SOCKET_MASK, 0);
@@ -1023,10 +1023,16 @@
 			socket->type->save_state(socket);
 
 		/* FIXME: pci_save_state needs to have a better interface */
-		pci_save_state(dev, socket->saved_state);
-		pci_read_config_dword(dev, 16*4, &socket->saved_state[16]);
-		pci_read_config_dword(dev, 17*4, &socket->saved_state[17]);
-		pci_set_power_state(dev, 3);
+		pci_save_state(dev);
+		pci_read_config_dword(dev, 16*4, &socket->saved_state[0]);
+		pci_read_config_dword(dev, 17*4, &socket->saved_state[1]);
+
+		/*
+		 * Some laptops (IBM T22) do not like us putting the Cardbus
+		 * bridge into D3.  At a guess, some other laptop will
+		 * probably require this, so leave it commented out for now.
+		 */
+		/* pci_set_power_state(dev, 3); */
 	}
 
 	return ret;
@@ -1040,9 +1046,9 @@
 	if (socket) {
 		pci_set_power_state(dev, 0);
 		/* FIXME: pci_restore_state needs to have a better interface */
-		pci_restore_state(dev, socket->saved_state);
-		pci_write_config_dword(dev, 16*4, socket->saved_state[16]);
-		pci_write_config_dword(dev, 17*4, socket->saved_state[17]);
+		pci_restore_state(dev);
+		pci_write_config_dword(dev, 16*4, socket->saved_state[0]);
+		pci_write_config_dword(dev, 17*4, socket->saved_state[1]);
 
 		if (socket->type && socket->type->restore_state)
 			socket->type->restore_state(socket);
diff -Nru a/drivers/pcmcia/yenta_socket.h b/drivers/pcmcia/yenta_socket.h
--- a/drivers/pcmcia/yenta_socket.h	2004-12-24 13:36:34 -08:00
+++ b/drivers/pcmcia/yenta_socket.h	2004-12-24 13:36:34 -08:00
@@ -120,7 +120,7 @@
 	unsigned int private[8];
 
 	/* PCI saved state */
-	u32 saved_state[18];
+	u32 saved_state[2];
 };
 
 
diff -Nru a/drivers/pnp/Kconfig b/drivers/pnp/Kconfig
--- a/drivers/pnp/Kconfig	2004-12-24 13:36:49 -08:00
+++ b/drivers/pnp/Kconfig	2004-12-24 13:36:49 -08:00
@@ -6,7 +6,7 @@
 
 config PNP
 	bool "Plug and Play support"
-	depends on ISA
+	depends on ISA || ACPI_BUS
 	---help---
 	  Plug and Play (PnP) is a standard for peripherals which allows those
 	  peripherals to be configured by software, e.g. assign IRQ's or other
@@ -34,6 +34,8 @@
 source "drivers/pnp/isapnp/Kconfig"
 
 source "drivers/pnp/pnpbios/Kconfig"
+
+source "drivers/pnp/pnpacpi/Kconfig"
 
 endmenu
 
diff -Nru a/drivers/pnp/Makefile b/drivers/pnp/Makefile
--- a/drivers/pnp/Makefile	2004-12-24 13:36:16 -08:00
+++ b/drivers/pnp/Makefile	2004-12-24 13:36:16 -08:00
@@ -4,5 +4,6 @@
 
 obj-y		:= core.o card.o driver.o resource.o manager.o support.o interface.o quirks.o system.o
 
+obj-$(CONFIG_PNPACPI)		+= pnpacpi/
 obj-$(CONFIG_PNPBIOS)		+= pnpbios/
 obj-$(CONFIG_ISAPNP)		+= isapnp/
diff -Nru a/drivers/pnp/interface.c b/drivers/pnp/interface.c
--- a/drivers/pnp/interface.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/pnp/interface.c	2004-12-24 13:36:18 -08:00
@@ -60,8 +60,8 @@
 	int first = 1, i;
 
 	pnp_printf(buffer, "%sirq ", space);
-	for (i = 0; i < 16; i++)
-		if (irq->map & (1<<i)) {
+	for (i = 0; i < PNP_IRQ_NR; i++)
+		if (test_bit(i, irq->map)) {
 			if (!first) {
 				pnp_printf(buffer, ",");
 			} else {
@@ -72,7 +72,7 @@
 			else
 				pnp_printf(buffer, "%i", i);
 		}
-	if (!irq->map)
+	if (bitmap_empty(irq->map, PNP_IRQ_NR))
 		pnp_printf(buffer, "<none>");
 	if (irq->flags & IORESOURCE_IRQ_HIGHEDGE)
 		pnp_printf(buffer, " High-Edge");
diff -Nru a/drivers/pnp/isapnp/Kconfig b/drivers/pnp/isapnp/Kconfig
--- a/drivers/pnp/isapnp/Kconfig	2004-12-24 13:36:48 -08:00
+++ b/drivers/pnp/isapnp/Kconfig	2004-12-24 13:36:48 -08:00
@@ -3,7 +3,7 @@
 #
 config ISAPNP
 	bool "ISA Plug and Play support"
-	depends on PNP
+	depends on PNP && ISA
 	help
 	  Say Y here if you would like support for ISA Plug and Play devices.
 	  Some information is in <file:Documentation/isapnp.txt>.
diff -Nru a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
--- a/drivers/pnp/isapnp/core.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/pnp/isapnp/core.c	2004-12-24 13:36:56 -08:00
@@ -477,12 +477,14 @@
 {
 	unsigned char tmp[3];
 	struct pnp_irq *irq;
+	unsigned long bits;
 
 	isapnp_peek(tmp, size);
 	irq = isapnp_alloc(sizeof(struct pnp_irq));
 	if (!irq)
 		return;
-	irq->map = (tmp[1] << 8) | tmp[0];
+	bits = (tmp[1] << 8) | tmp[0];
+	bitmap_copy(irq->map, &bits, 16);
 	if (size > 2)
 		irq->flags = tmp[2];
 	else
diff -Nru a/drivers/pnp/manager.c b/drivers/pnp/manager.c
--- a/drivers/pnp/manager.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/pnp/manager.c	2004-12-24 13:37:29 -08:00
@@ -150,13 +150,19 @@
 	*flags |= rule->flags | IORESOURCE_IRQ;
 	*flags &=  ~IORESOURCE_UNSET;
 
-	if (!rule->map) {
+	if (bitmap_empty(rule->map, PNP_IRQ_NR)) {
 		*flags |= IORESOURCE_DISABLED;
 		return 1; /* skip disabled resource requests */
 	}
 
+	/* TBD: need check for >16 IRQ */
+	*start = find_next_bit(rule->map, PNP_IRQ_NR, 16);
+	if (*start < PNP_IRQ_NR) {
+		*end = *start;
+		return 1;
+	}
 	for (i = 0; i < 16; i++) {
-		if(rule->map & (1<<xtab[i])) {
+		if(test_bit(xtab[i], rule->map)) {
 			*start = *end = xtab[i];
 			if(pnp_check_irq(dev, idx))
 				return 1;
diff -Nru a/drivers/pnp/pnpacpi/Kconfig b/drivers/pnp/pnpacpi/Kconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pnp/pnpacpi/Kconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,18 @@
+#
+# Plug and Play ACPI configuration
+#
+config PNPACPI
+	bool "Plug and Play ACPI support (EXPERIMENTAL)"
+	depends on PNP && ACPI_BUS && EXPERIMENTAL
+	default y
+	---help---
+	  Linux uses the PNPACPI to autodetect built-in
+	  mainboard resources (e.g. parallel port resources).
+
+          Some features (e.g. real hotplug) are not currently
+          implemented.
+
+          If you would like the kernel to detect and allocate resources to
+          your mainboard devices (on some systems they are disabled by the
+          BIOS) say Y here.  Also the PNPACPI can help prevent resource
+          conflicts between mainboard devices and other bus devices.
diff -Nru a/drivers/pnp/pnpacpi/Makefile b/drivers/pnp/pnpacpi/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pnp/pnpacpi/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,5 @@
+#
+# Makefile for the kernel PNPACPI driver.
+#
+
+obj-y := core.o rsparser.o
diff -Nru a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pnp/pnpacpi/core.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,258 @@
+/*
+ * pnpacpi -- PnP ACPI driver
+ *
+ * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
+ * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.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, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+ 
+#include <linux/acpi.h>
+#include <linux/pnp.h>
+#include <acpi/acpi_bus.h>
+#include "pnpacpi.h"
+
+static int num = 0;
+
+static char __initdata excluded_id_list[] =
+	"PNP0C0A," /* Battery */
+	"PNP0C0C,PNP0C0E,PNP0C0D," /* Button */
+	"PNP0C09," /* EC */
+	"PNP0C0B," /* Fan */
+	"PNP0A03," /* PCI root */
+	"PNP0C0F," /* Link device */
+	"PNP0000," /* PIC */
+	"PNP0100," /* Timer */
+	;
+static inline int is_exclusive_device(struct acpi_device *dev)
+{
+	return (!acpi_match_ids(dev, excluded_id_list));
+}
+
+void *pnpacpi_kmalloc(size_t size, int f)
+{
+	void *p = kmalloc(size, f);
+	if (p)
+		memset(p, 0, size);
+	return p;
+}
+
+/*
+ * Compatible Device IDs
+ */
+#define TEST_HEX(c) \
+	if (!(('0' <= (c) && (c) <= '9') || ('A' <= (c) && (c) <= 'F'))) \
+		return 0
+#define TEST_ALPHA(c) \
+	if (!('@' <= (c) || (c) <= 'Z')) \
+		return 0
+static int __init ispnpidacpi(char *id)
+{
+	TEST_ALPHA(id[0]);
+	TEST_ALPHA(id[1]);
+	TEST_ALPHA(id[2]);
+	TEST_HEX(id[3]);
+	TEST_HEX(id[4]);
+	TEST_HEX(id[5]);
+	TEST_HEX(id[6]);
+	if (id[7] != '\0')
+		return 0;
+	return 1;
+}
+
+static void __init pnpidacpi_to_pnpid(char *id, char *str)
+{
+	str[0] = id[0];
+	str[1] = id[1];
+	str[2] = id[2];
+	str[3] = tolower(id[3]);
+	str[4] = tolower(id[4]);
+	str[5] = tolower(id[5]);
+	str[6] = tolower(id[6]);
+	str[7] = '\0';
+}
+
+static int pnpacpi_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res)
+{
+	acpi_status status;
+	status = pnpacpi_parse_allocated_resource((acpi_handle)dev->data, 
+		&dev->res);
+	return ACPI_FAILURE(status) ? -ENODEV : 0;
+}
+
+static int pnpacpi_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res)
+{
+	acpi_handle handle = dev->data;
+	struct acpi_buffer buffer;
+	int ret = 0;
+	acpi_status status;
+
+	ret = pnpacpi_build_resource_template(handle, &buffer);
+	if (ret)
+		return ret;
+	ret = pnpacpi_encode_resources(res, &buffer);
+	if (ret) {
+		kfree(buffer.pointer);
+		return ret;
+	}
+	status = acpi_set_current_resources(handle, &buffer);
+	if (ACPI_FAILURE(status))
+		ret = -EINVAL;
+	kfree(buffer.pointer);
+	return ret;
+}
+
+static int pnpacpi_disable_resources(struct pnp_dev *dev)
+{
+	acpi_status status;
+	
+	/* acpi_unregister_gsi(pnp_irq(dev, 0)); */
+	status = acpi_evaluate_object((acpi_handle)dev->data, 
+		"_DIS", NULL, NULL);
+	return ACPI_FAILURE(status) ? -ENODEV : 0;
+}
+
+struct pnp_protocol pnpacpi_protocol = {
+	.name	= "Plug and Play ACPI",
+	.get	= pnpacpi_get_resources,
+	.set	= pnpacpi_set_resources,
+	.disable = pnpacpi_disable_resources,
+};
+
+static int __init pnpacpi_add_device(struct acpi_device *device)
+{
+	acpi_handle temp = NULL;
+	acpi_status status;
+	struct pnp_id *dev_id;
+	struct pnp_dev *dev;
+
+	if (!ispnpidacpi(acpi_device_hid(device)) ||
+		is_exclusive_device(device))
+		return 0;
+
+	pnp_dbg("ACPI device : hid %s", acpi_device_hid(device));
+	dev =  pnpacpi_kmalloc(sizeof(struct pnp_dev), GFP_KERNEL);
+	if (!dev) {
+		pnp_err("Out of memory");
+		return -ENOMEM;
+	}
+	dev->data = device->handle;
+	/* .enabled means if the device can decode the resources */
+	dev->active = device->status.enabled;
+	status = acpi_get_handle(device->handle, "_SRS", &temp);
+	if (ACPI_SUCCESS(status))
+		dev->capabilities |= PNP_CONFIGURABLE;
+	dev->capabilities |= PNP_READ;
+	if (device->flags.dynamic_status)
+		dev->capabilities |= PNP_WRITE;
+	if (device->flags.removable)
+		dev->capabilities |= PNP_REMOVABLE;
+	status = acpi_get_handle(device->handle, "_DIS", &temp);
+	if (ACPI_SUCCESS(status))
+		dev->capabilities |= PNP_DISABLE;
+
+	dev->protocol = &pnpacpi_protocol;
+
+	if (strlen(acpi_device_name(device)))
+		strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
+	else
+		strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
+
+	dev->number = num;
+	
+	/* set the initial values for the PnP device */
+	dev_id = pnpacpi_kmalloc(sizeof(struct pnp_id), GFP_KERNEL);
+	if (!dev_id)
+		goto err;
+	pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
+	pnp_add_id(dev_id, dev);
+
+	if(dev->active) {
+		/* parse allocated resource */
+		status = pnpacpi_parse_allocated_resource(device->handle, &dev->res);
+		if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
+			pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s", dev_id->id);
+			goto err1;
+		}
+	}
+
+	if(dev->capabilities & PNP_CONFIGURABLE) {
+		status = pnpacpi_parse_resource_option_data(device->handle, 
+			dev);
+		if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
+			pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s", dev_id->id);
+			goto err1;
+		}
+	}
+	
+	/* parse compatible ids */
+	if (device->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
+		int i;
+
+		for (i = 0; i < cid_list->count; i++) {
+			if (!ispnpidacpi(cid_list->id[i].value))
+				continue;
+			dev_id = pnpacpi_kmalloc(sizeof(struct pnp_id), 
+				GFP_KERNEL);
+			if (!dev_id)
+				continue;
+
+			pnpidacpi_to_pnpid(cid_list->id[i].value, dev_id->id);
+			pnp_add_id(dev_id, dev);
+		}
+	}
+
+	/* clear out the damaged flags */
+	if (!dev->active)
+		pnp_init_resource_table(&dev->res);
+	pnp_add_device(dev);
+	num ++;
+
+	return AE_OK;
+err1:
+	kfree(dev_id);
+err:
+	kfree(dev);
+	return -EINVAL;
+}
+
+static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
+	u32 lvl, void *context, void **rv)
+{
+	struct acpi_device *device;
+
+	if (!acpi_bus_get_device(handle, &device))
+		pnpacpi_add_device(device);
+	return AE_OK;
+}
+
+int __init pnpacpi_init(void)
+{
+	if (acpi_disabled) {
+		pnp_info("PnP ACPI: ACPI disable");
+		return 0;
+	}
+	pnp_info("PnP ACPI init");
+	pnp_register_protocol(&pnpacpi_protocol);
+	acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+			ACPI_UINT32_MAX, pnpacpi_add_device_handler,
+			NULL, NULL);
+	pnp_info("PnP ACPI: found %d devices", num);
+	return 0;
+}
+subsys_initcall(pnpacpi_init);
+
+EXPORT_SYMBOL(pnpacpi_protocol);
diff -Nru a/drivers/pnp/pnpacpi/pnpacpi.h b/drivers/pnp/pnpacpi/pnpacpi.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pnp/pnpacpi/pnpacpi.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,13 @@
+#ifndef ACPI_PNP_H
+#define ACPI_PNP_H
+
+#include <acpi/acpi_bus.h>
+#include <linux/acpi.h>
+#include <linux/pnp.h>
+
+void *pnpacpi_kmalloc(size_t size, int f);
+acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*);
+acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*);
+int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *);
+int pnpacpi_build_resource_template(acpi_handle, struct acpi_buffer*);
+#endif
diff -Nru a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/pnp/pnpacpi/rsparser.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,820 @@
+/*
+ * pnpacpi -- PnP ACPI driver
+ *
+ * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
+ * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.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, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <linux/kernel.h>
+#include <linux/acpi.h>
+#include <linux/pci.h>
+#include "pnpacpi.h"
+
+#ifdef CONFIG_IA64
+#define valid_IRQ(i) (1)
+#else
+#define valid_IRQ(i) (((i) != 0) && ((i) != 2))
+#endif
+
+/*
+ * Allocated Resources
+ */
+static int irq_flags(int edge_level, int active_high_low)
+{
+	int flag;
+	if (edge_level == ACPI_LEVEL_SENSITIVE) {
+		if(active_high_low == ACPI_ACTIVE_LOW)
+			flag = IORESOURCE_IRQ_LOWLEVEL;
+		else
+			flag = IORESOURCE_IRQ_HIGHLEVEL;
+	}
+	else {
+		if(active_high_low == ACPI_ACTIVE_LOW)
+			flag = IORESOURCE_IRQ_LOWEDGE;
+		else
+			flag = IORESOURCE_IRQ_HIGHEDGE;
+	}
+	return flag;
+}
+
+static void decode_irq_flags(int flag, int *edge_level, int *active_high_low)
+{
+	switch (flag) {
+	case IORESOURCE_IRQ_LOWLEVEL:
+		*edge_level = ACPI_LEVEL_SENSITIVE;
+		*active_high_low = ACPI_ACTIVE_LOW;
+		break;
+	case IORESOURCE_IRQ_HIGHLEVEL:	
+		*edge_level = ACPI_LEVEL_SENSITIVE;
+		*active_high_low = ACPI_ACTIVE_HIGH;
+		break;
+	case IORESOURCE_IRQ_LOWEDGE:
+		*edge_level = ACPI_EDGE_SENSITIVE;
+		*active_high_low = ACPI_ACTIVE_LOW;
+		break;
+	case IORESOURCE_IRQ_HIGHEDGE:
+		*edge_level = ACPI_EDGE_SENSITIVE;
+		*active_high_low = ACPI_ACTIVE_HIGH;
+		break;
+	}
+}
+
+static void
+pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, int irq)
+{
+	int i = 0;
+	while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
+			i < PNP_MAX_IRQ)
+		i++;
+	if (i < PNP_MAX_IRQ) {
+		res->irq_resource[i].flags = IORESOURCE_IRQ;  //Also clears _UNSET flag
+		if (irq == -1) {
+			res->irq_resource[i].flags |= IORESOURCE_DISABLED;
+			return;
+		}
+		res->irq_resource[i].start =(unsigned long) irq;
+		res->irq_resource[i].end = (unsigned long) irq;
+	}
+}
+
+static void
+pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma)
+{
+	int i = 0;
+	while (!(res->dma_resource[i].flags & IORESOURCE_UNSET) &&
+			i < PNP_MAX_DMA)
+		i++;
+	if (i < PNP_MAX_DMA) {
+		res->dma_resource[i].flags = IORESOURCE_DMA;  // Also clears _UNSET flag
+		if (dma == -1) {
+			res->dma_resource[i].flags |= IORESOURCE_DISABLED;
+			return;
+		}
+		res->dma_resource[i].start =(unsigned long) dma;
+		res->dma_resource[i].end = (unsigned long) dma;
+	}
+}
+
+static void
+pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res,
+	int io, int len)
+{
+	int i = 0;
+	while (!(res->port_resource[i].flags & IORESOURCE_UNSET) &&
+			i < PNP_MAX_PORT)
+		i++;
+	if (i < PNP_MAX_PORT) {
+		res->port_resource[i].flags = IORESOURCE_IO;  // Also clears _UNSET flag
+		if (len <= 0 || (io + len -1) >= 0x10003) {
+			res->port_resource[i].flags |= IORESOURCE_DISABLED;
+			return;
+		}
+		res->port_resource[i].start = (unsigned long) io;
+		res->port_resource[i].end = (unsigned long)(io + len - 1);
+	}
+}
+
+static void
+pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res,
+	int mem, int len)
+{
+	int i = 0;
+	while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) &&
+			(i < PNP_MAX_MEM))
+		i++;
+	if (i < PNP_MAX_MEM) {
+		res->mem_resource[i].flags = IORESOURCE_MEM;  // Also clears _UNSET flag
+		if (len <= 0) {
+			res->mem_resource[i].flags |= IORESOURCE_DISABLED;
+			return;
+		}
+		res->mem_resource[i].start = (unsigned long) mem;
+		res->mem_resource[i].end = (unsigned long)(mem + len - 1);
+	}
+}
+
+
+static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
+	void *data)
+{
+	struct pnp_resource_table * res_table = (struct pnp_resource_table *)data;
+
+	switch (res->id) {
+	case ACPI_RSTYPE_IRQ:
+		if ((res->data.irq.number_of_interrupts > 0) &&
+			valid_IRQ(res->data.irq.interrupts[0])) {
+			pnpacpi_parse_allocated_irqresource(res_table, 
+				acpi_register_gsi(res->data.irq.interrupts[0],
+					res->data.irq.edge_level,
+					res->data.irq.active_high_low));
+			pcibios_penalize_isa_irq(res->data.irq.interrupts[0]);
+		}
+		break;
+
+	case ACPI_RSTYPE_EXT_IRQ:
+		if ((res->data.extended_irq.number_of_interrupts > 0) &&
+			valid_IRQ(res->data.extended_irq.interrupts[0])) {
+			pnpacpi_parse_allocated_irqresource(res_table, 
+				acpi_register_gsi(res->data.extended_irq.interrupts[0],
+					res->data.extended_irq.edge_level,
+					res->data.extended_irq.active_high_low));
+			pcibios_penalize_isa_irq(res->data.extended_irq.interrupts[0]);
+		}
+		break;
+	case ACPI_RSTYPE_DMA:
+		if (res->data.dma.number_of_channels > 0)
+			pnpacpi_parse_allocated_dmaresource(res_table, 
+					res->data.dma.channels[0]);
+		break;
+	case ACPI_RSTYPE_IO:
+		pnpacpi_parse_allocated_ioresource(res_table, 
+				res->data.io.min_base_address, 
+				res->data.io.range_length);
+		break;
+	case ACPI_RSTYPE_FIXED_IO:
+		pnpacpi_parse_allocated_ioresource(res_table, 
+				res->data.fixed_io.base_address, 
+				res->data.fixed_io.range_length);
+		break;
+	case ACPI_RSTYPE_MEM24:
+		pnpacpi_parse_allocated_memresource(res_table, 
+				res->data.memory24.min_base_address, 
+				res->data.memory24.range_length);
+		break;
+	case ACPI_RSTYPE_MEM32:
+		pnpacpi_parse_allocated_memresource(res_table, 
+				res->data.memory32.min_base_address, 
+				res->data.memory32.range_length);
+		break;
+	case ACPI_RSTYPE_FIXED_MEM32:
+		pnpacpi_parse_allocated_memresource(res_table, 
+				res->data.fixed_memory32.range_base_address, 
+				res->data.fixed_memory32.range_length);
+		break;
+	case ACPI_RSTYPE_ADDRESS16:
+		pnpacpi_parse_allocated_memresource(res_table, 
+				res->data.address16.min_address_range, 
+				res->data.address16.address_length);
+		break;
+	case ACPI_RSTYPE_ADDRESS32:
+		pnpacpi_parse_allocated_memresource(res_table, 
+				res->data.address32.min_address_range, 
+				res->data.address32.address_length);
+		break;
+	case ACPI_RSTYPE_ADDRESS64:
+		pnpacpi_parse_allocated_memresource(res_table, 
+		res->data.address64.min_address_range, 
+		res->data.address64.address_length);
+		break;
+	default:
+		pnp_warn("PnPACPI: Alloc type : %d not handle", 
+				res->id);
+		return AE_ERROR;
+	}
+			
+	return AE_OK;
+}
+
+acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table * res)
+{
+	/* Blank the resource table values */
+	pnp_init_resource_table(res);
+
+	return acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, res);
+}
+
+static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_resource_dma *p)
+{
+	int i;
+	struct pnp_dma * dma;
+
+	if (p->number_of_channels == 0)
+		return;
+	dma = pnpacpi_kmalloc(sizeof(struct pnp_dma), GFP_KERNEL);
+	if (!dma)
+		return;
+
+	for(i = 0; i < p->number_of_channels; i++)
+		dma->map |= 1 << p->channels[i];
+	dma->flags = 0;
+	if (p->bus_master)
+		dma->flags |= IORESOURCE_DMA_MASTER;
+	switch (p->type) {
+	case ACPI_COMPATIBILITY:
+		dma->flags |= IORESOURCE_DMA_COMPATIBLE;
+		break;
+	case ACPI_TYPE_A:
+		dma->flags |= IORESOURCE_DMA_TYPEA;
+		break;
+	case ACPI_TYPE_B:
+		dma->flags |= IORESOURCE_DMA_TYPEB;
+		break;
+	case ACPI_TYPE_F:
+		dma->flags |= IORESOURCE_DMA_TYPEF;
+		break;
+	default:
+		/* Set a default value ? */
+		dma->flags |= IORESOURCE_DMA_COMPATIBLE;
+		pnp_err("Invalid DMA type");
+	}
+	switch (p->transfer) {
+	case ACPI_TRANSFER_8:
+		dma->flags |= IORESOURCE_DMA_8BIT;
+		break;
+	case ACPI_TRANSFER_8_16:
+		dma->flags |= IORESOURCE_DMA_8AND16BIT;
+		break;
+	case ACPI_TRANSFER_16:
+		dma->flags |= IORESOURCE_DMA_16BIT;
+		break;
+	default:
+		/* Set a default value ? */
+		dma->flags |= IORESOURCE_DMA_8AND16BIT;
+		pnp_err("Invalid DMA transfer type");
+	}
+
+	pnp_register_dma_resource(option,dma);
+	return;
+}
+
+	
+static void pnpacpi_parse_irq_option(struct pnp_option *option,
+	struct acpi_resource_irq *p)
+{
+	int i;
+	struct pnp_irq * irq;
+	
+	if (p->number_of_interrupts == 0)
+		return;
+	irq = pnpacpi_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL);
+	if (!irq)
+		return;
+
+	for(i = 0; i < p->number_of_interrupts; i++)
+		if (p->interrupts[i])
+			__set_bit(p->interrupts[i], irq->map);
+	irq->flags = irq_flags(p->edge_level, p->active_high_low);
+
+	pnp_register_irq_resource(option, irq);
+	return;
+}
+
+static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
+	struct acpi_resource_ext_irq *p)
+{
+	int i;
+	struct pnp_irq * irq;
+
+	if (p->number_of_interrupts == 0)
+		return;
+	irq = pnpacpi_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL);
+	if (!irq)
+		return;
+
+	for(i = 0; i < p->number_of_interrupts; i++)
+		if (p->interrupts[i])
+			__set_bit(p->interrupts[i], irq->map);
+	irq->flags = irq_flags(p->edge_level, p->active_high_low);
+
+	pnp_register_irq_resource(option, irq);
+	return;
+}
+
+static void
+pnpacpi_parse_port_option(struct pnp_option *option,
+	struct acpi_resource_io *io)
+{
+	struct pnp_port * port;
+
+	if (io->range_length == 0)
+		return;
+	port = pnpacpi_kmalloc(sizeof(struct pnp_port), GFP_KERNEL);
+	if (!port)
+		return;
+	port->min = io->min_base_address;
+	port->max = io->max_base_address;
+	port->align = io->alignment;
+	port->size = io->range_length;
+	port->flags = ACPI_DECODE_16 == io->io_decode ? 
+		PNP_PORT_FLAG_16BITADDR : 0;
+	pnp_register_port_resource(option,port);
+	return;
+}
+
+static void
+pnpacpi_parse_fixed_port_option(struct pnp_option *option,
+	struct acpi_resource_fixed_io *io)
+{
+	struct pnp_port * port;
+
+	if (io->range_length == 0)
+		return;
+	port = pnpacpi_kmalloc(sizeof(struct pnp_port), GFP_KERNEL);
+	if (!port)
+		return;
+	port->min = port->max = io->base_address;
+	port->size = io->range_length;
+	port->align = 0;
+	port->flags = PNP_PORT_FLAG_FIXED;
+	pnp_register_port_resource(option,port);
+	return;
+}
+
+static void
+pnpacpi_parse_mem24_option(struct pnp_option *option,
+	struct acpi_resource_mem24 *p)
+{
+	struct pnp_mem * mem;
+
+	if (p->range_length == 0)
+		return;
+	mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL);
+	if (!mem)
+		return;
+	mem->min = p->min_base_address;
+	mem->max = p->max_base_address;
+	mem->align = p->alignment;
+	mem->size = p->range_length;
+
+	mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
+			IORESOURCE_MEM_WRITEABLE : 0;
+
+	pnp_register_mem_resource(option,mem);
+	return;
+}
+
+static void
+pnpacpi_parse_mem32_option(struct pnp_option *option,
+	struct acpi_resource_mem32 *p)
+{
+	struct pnp_mem * mem;
+
+	if (p->range_length == 0)
+		return;
+	mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL);
+	if (!mem)
+		return;
+	mem->min = p->min_base_address;
+	mem->max = p->max_base_address;
+	mem->align = p->alignment;
+	mem->size = p->range_length;
+
+	mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
+			IORESOURCE_MEM_WRITEABLE : 0;
+
+	pnp_register_mem_resource(option,mem);
+	return;
+}
+
+static void
+pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
+	struct acpi_resource_fixed_mem32 *p)
+{
+	struct pnp_mem * mem;
+
+	if (p->range_length == 0)
+		return;
+	mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL);
+	if (!mem)
+		return;
+	mem->min = mem->max = p->range_base_address;
+	mem->size = p->range_length;
+	mem->align = 0;
+
+	mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ?
+			IORESOURCE_MEM_WRITEABLE : 0;
+
+	pnp_register_mem_resource(option,mem);
+	return;
+}
+
+struct acpipnp_parse_option_s {
+	struct pnp_option *option;
+	struct pnp_dev *dev;
+};
+
+static acpi_status pnpacpi_option_resource(struct acpi_resource *res, 
+	void *data)
+{
+	int priority = 0;
+	struct acpipnp_parse_option_s *parse_data = (struct acpipnp_parse_option_s *)data;
+	struct pnp_dev *dev = parse_data->dev;
+	struct pnp_option *option = parse_data->option;
+
+	switch (res->id) {
+		case ACPI_RSTYPE_IRQ:
+			pnpacpi_parse_irq_option(option, &res->data.irq);
+			break;
+		case ACPI_RSTYPE_EXT_IRQ:
+			pnpacpi_parse_ext_irq_option(option,
+				&res->data.extended_irq);
+			break;
+		case ACPI_RSTYPE_DMA:
+			pnpacpi_parse_dma_option(option, &res->data.dma);	
+			break;
+		case ACPI_RSTYPE_IO:
+			pnpacpi_parse_port_option(option, &res->data.io);
+			break;
+		case ACPI_RSTYPE_FIXED_IO:
+			pnpacpi_parse_fixed_port_option(option,
+				&res->data.fixed_io);
+			break;
+		case ACPI_RSTYPE_MEM24:
+			pnpacpi_parse_mem24_option(option, &res->data.memory24);
+			break;
+		case ACPI_RSTYPE_MEM32:
+			pnpacpi_parse_mem32_option(option, &res->data.memory32);
+			break;
+		case ACPI_RSTYPE_FIXED_MEM32:
+			pnpacpi_parse_fixed_mem32_option(option,
+				&res->data.fixed_memory32);
+			break;
+		case ACPI_RSTYPE_START_DPF:
+			switch (res->data.start_dpf.compatibility_priority) {
+				case ACPI_GOOD_CONFIGURATION:
+					priority = PNP_RES_PRIORITY_PREFERRED;
+					break;
+					
+				case ACPI_ACCEPTABLE_CONFIGURATION:
+					priority = PNP_RES_PRIORITY_ACCEPTABLE;
+					break;
+
+				case ACPI_SUB_OPTIMAL_CONFIGURATION:
+					priority = PNP_RES_PRIORITY_FUNCTIONAL;
+					break;
+				default:
+					priority = PNP_RES_PRIORITY_INVALID;
+					break;
+			}
+			/* TBD: Considering performace/robustness bits */
+			option = pnp_register_dependent_option(dev, priority);
+			if (!option)
+				return AE_ERROR;
+			parse_data->option = option;	
+			break;
+		case ACPI_RSTYPE_END_DPF:
+			return AE_CTRL_TERMINATE;
+		default:
+			pnp_warn("PnPACPI:Option type: %d not handle", res->id);
+			return AE_ERROR;
+	}
+			
+	return AE_OK;
+}
+
+acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, 
+	struct pnp_dev *dev)
+{
+	acpi_status status;
+	struct acpipnp_parse_option_s parse_data;
+
+	parse_data.option = pnp_register_independent_option(dev);
+	if (!parse_data.option)
+		return AE_ERROR;
+	parse_data.dev = dev;
+	status = acpi_walk_resources(handle, METHOD_NAME__PRS, 
+		pnpacpi_option_resource, &parse_data);
+
+	return status;
+}
+
+/*
+ * Set resource
+ */
+static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
+	void *data)
+{
+	int *res_cnt = (int *)data;
+	switch (res->id) {
+	case ACPI_RSTYPE_IRQ:
+	case ACPI_RSTYPE_EXT_IRQ:
+	case ACPI_RSTYPE_DMA:
+	case ACPI_RSTYPE_IO:
+	case ACPI_RSTYPE_FIXED_IO:
+	case ACPI_RSTYPE_MEM24:
+	case ACPI_RSTYPE_MEM32:
+	case ACPI_RSTYPE_FIXED_MEM32:
+#if 0
+	case ACPI_RSTYPE_ADDRESS16:
+	case ACPI_RSTYPE_ADDRESS32:
+	case ACPI_RSTYPE_ADDRESS64:
+#endif
+		(*res_cnt) ++;
+	default:
+		return AE_OK;
+	}
+	return AE_OK;
+}
+
+static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
+	void *data)
+{
+	struct acpi_resource **resource = (struct acpi_resource **)data;	
+	switch (res->id) {
+	case ACPI_RSTYPE_IRQ:
+	case ACPI_RSTYPE_EXT_IRQ:
+	case ACPI_RSTYPE_DMA:
+	case ACPI_RSTYPE_IO:
+	case ACPI_RSTYPE_FIXED_IO:
+	case ACPI_RSTYPE_MEM24:
+	case ACPI_RSTYPE_MEM32:
+	case ACPI_RSTYPE_FIXED_MEM32:
+#if 0
+	case ACPI_RSTYPE_ADDRESS16:
+	case ACPI_RSTYPE_ADDRESS32:
+	case ACPI_RSTYPE_ADDRESS64:
+#endif
+		(*resource)->id = res->id;
+		(*resource)++;
+	default:
+		return AE_OK;
+	}
+
+	return AE_OK;
+}
+
+int pnpacpi_build_resource_template(acpi_handle handle, 
+	struct acpi_buffer *buffer)
+{
+	struct acpi_resource *resource;
+	int res_cnt = 0;
+	acpi_status status;
+
+	status = acpi_walk_resources(handle, METHOD_NAME__CRS, 
+		pnpacpi_count_resources, &res_cnt);
+	if (ACPI_FAILURE(status)) {
+		pnp_err("Evaluate _CRS failed");
+		return -EINVAL;
+	}
+	if (!res_cnt)
+		return -EINVAL;
+	buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1;
+	buffer->pointer = pnpacpi_kmalloc(buffer->length - 1, GFP_KERNEL);
+	if (!buffer->pointer)
+		return -ENOMEM;
+	pnp_dbg("Res cnt %d", res_cnt);
+	resource = (struct acpi_resource *)buffer->pointer;
+	status = acpi_walk_resources(handle, METHOD_NAME__CRS, 
+		pnpacpi_type_resources, &resource);
+	if (ACPI_FAILURE(status)) {
+		kfree(buffer->pointer);
+		pnp_err("Evaluate _CRS failed");
+		return -EINVAL;
+	}
+	/* resource will pointer the end resource now */
+	resource->id = ACPI_RSTYPE_END_TAG;
+
+	return 0;
+}
+
+static void pnpacpi_encode_irq(struct acpi_resource *resource, 
+	struct resource *p)
+{
+	int edge_level, active_high_low;
+	
+	decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 
+		&active_high_low);
+	resource->id = ACPI_RSTYPE_IRQ;
+	resource->length = sizeof(struct acpi_resource);
+	resource->data.irq.edge_level = edge_level;
+	resource->data.irq.active_high_low = active_high_low;
+	if (edge_level == ACPI_EDGE_SENSITIVE)
+		resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
+	else
+		resource->data.irq.shared_exclusive = ACPI_SHARED;
+	resource->data.irq.number_of_interrupts = 1;
+	resource->data.irq.interrupts[0] = p->start;
+}
+
+static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
+	struct resource *p)
+{
+	int edge_level, active_high_low;
+	
+	decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 
+		&active_high_low);
+	resource->id = ACPI_RSTYPE_EXT_IRQ;
+	resource->length = sizeof(struct acpi_resource);
+	resource->data.extended_irq.producer_consumer = ACPI_CONSUMER;
+	resource->data.extended_irq.edge_level = edge_level;
+	resource->data.extended_irq.active_high_low = active_high_low;
+	if (edge_level == ACPI_EDGE_SENSITIVE)
+		resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
+	else
+		resource->data.irq.shared_exclusive = ACPI_SHARED;
+	resource->data.extended_irq.number_of_interrupts = 1;
+	resource->data.extended_irq.interrupts[0] = p->start;
+}
+
+static void pnpacpi_encode_dma(struct acpi_resource *resource,
+	struct resource *p)
+{
+	resource->id = ACPI_RSTYPE_DMA;
+	resource->length = sizeof(struct acpi_resource);
+	/* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
+	if (p->flags & IORESOURCE_DMA_COMPATIBLE)
+		resource->data.dma.type = ACPI_COMPATIBILITY;
+	else if (p->flags & IORESOURCE_DMA_TYPEA)
+		resource->data.dma.type = ACPI_TYPE_A;
+	else if (p->flags & IORESOURCE_DMA_TYPEB)
+		resource->data.dma.type = ACPI_TYPE_B;
+	else if (p->flags & IORESOURCE_DMA_TYPEF)
+		resource->data.dma.type = ACPI_TYPE_F;
+	if (p->flags & IORESOURCE_DMA_8BIT)
+		resource->data.dma.transfer = ACPI_TRANSFER_8;
+	else if (p->flags & IORESOURCE_DMA_8AND16BIT)
+		resource->data.dma.transfer = ACPI_TRANSFER_8_16;
+	else if (p->flags & IORESOURCE_DMA_16BIT)
+		resource->data.dma.transfer = ACPI_TRANSFER_16;
+	resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER;
+	resource->data.dma.number_of_channels = 1;
+	resource->data.dma.channels[0] = p->start;
+}
+
+static void pnpacpi_encode_io(struct acpi_resource *resource,
+	struct resource *p)
+{
+	resource->id = ACPI_RSTYPE_IO;
+	resource->length = sizeof(struct acpi_resource);
+	/* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
+	resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)?
+		ACPI_DECODE_16 : ACPI_DECODE_10; 
+	resource->data.io.min_base_address = p->start;
+	resource->data.io.max_base_address = p->end;
+	resource->data.io.alignment = 0; /* Correct? */
+	resource->data.io.range_length = p->end - p->start + 1;
+}
+
+static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
+	struct resource *p)
+{
+	resource->id = ACPI_RSTYPE_FIXED_IO;
+	resource->length = sizeof(struct acpi_resource);
+	resource->data.fixed_io.base_address = p->start;
+	resource->data.fixed_io.range_length = p->end - p->start + 1;
+}
+
+static void pnpacpi_encode_mem24(struct acpi_resource *resource,
+	struct resource *p)
+{
+	resource->id = ACPI_RSTYPE_MEM24;
+	resource->length = sizeof(struct acpi_resource);
+	/* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
+	resource->data.memory24.read_write_attribute =
+		(p->flags & IORESOURCE_MEM_WRITEABLE) ?
+		ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
+	resource->data.memory24.min_base_address = p->start;
+	resource->data.memory24.max_base_address = p->end;
+	resource->data.memory24.alignment = 0;
+	resource->data.memory24.range_length = p->end - p->start + 1;
+}
+
+static void pnpacpi_encode_mem32(struct acpi_resource *resource,
+	struct resource *p)
+{
+	resource->id = ACPI_RSTYPE_MEM32;
+	resource->length = sizeof(struct acpi_resource);
+	resource->data.memory32.read_write_attribute =
+		(p->flags & IORESOURCE_MEM_WRITEABLE) ?
+		ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
+	resource->data.memory32.min_base_address = p->start;
+	resource->data.memory32.max_base_address = p->end;
+	resource->data.memory32.alignment = 0;
+	resource->data.memory32.range_length = p->end - p->start + 1;
+}
+
+static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
+	struct resource *p)
+{
+	resource->id = ACPI_RSTYPE_FIXED_MEM32;
+	resource->length = sizeof(struct acpi_resource);
+	resource->data.fixed_memory32.read_write_attribute =
+		(p->flags & IORESOURCE_MEM_WRITEABLE) ?
+		ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
+	resource->data.fixed_memory32.range_base_address = p->start;
+	resource->data.fixed_memory32.range_length = p->end - p->start + 1;
+}
+
+int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 
+	struct acpi_buffer *buffer)
+{
+	int i = 0;
+	/* pnpacpi_build_resource_template allocates extra mem */
+	int res_cnt = (buffer->length - 1)/sizeof(struct acpi_resource) - 1;
+	struct acpi_resource *resource = (struct acpi_resource*)buffer->pointer;
+	int port = 0, irq = 0, dma = 0, mem = 0;
+
+	pnp_dbg("res cnt %d", res_cnt);
+	while (i < res_cnt) {
+		switch(resource->id) {
+		case ACPI_RSTYPE_IRQ:
+			pnp_dbg("Encode irq");
+			pnpacpi_encode_irq(resource, 
+				&res_table->irq_resource[irq]);
+			irq++;
+			break;
+
+		case ACPI_RSTYPE_EXT_IRQ:
+			pnp_dbg("Encode ext irq");
+			pnpacpi_encode_ext_irq(resource, 
+				&res_table->irq_resource[irq]);
+			irq++;
+			break;
+		case ACPI_RSTYPE_DMA:
+			pnp_dbg("Encode dma");
+			pnpacpi_encode_dma(resource, 
+				&res_table->dma_resource[dma]);
+			dma ++;
+			break;
+		case ACPI_RSTYPE_IO:
+			pnp_dbg("Encode io");
+			pnpacpi_encode_io(resource, 
+				&res_table->port_resource[port]);
+			port ++;
+			break;
+		case ACPI_RSTYPE_FIXED_IO:
+			pnp_dbg("Encode fixed io");
+			pnpacpi_encode_fixed_io(resource,
+				&res_table->port_resource[port]);
+			port ++;
+			break;
+		case ACPI_RSTYPE_MEM24:
+			pnp_dbg("Encode mem24");
+			pnpacpi_encode_mem24(resource,
+				&res_table->mem_resource[mem]);
+			mem ++;
+			break;
+		case ACPI_RSTYPE_MEM32:
+			pnp_dbg("Encode mem32");
+			pnpacpi_encode_mem32(resource,
+				&res_table->mem_resource[mem]);
+			mem ++;
+			break;
+		case ACPI_RSTYPE_FIXED_MEM32:
+			pnp_dbg("Encode fixed mem32");
+			pnpacpi_encode_fixed_mem32(resource,
+				&res_table->mem_resource[mem]);
+			mem ++;
+			break;
+		default: /* other type */
+			pnp_warn("Invalid type");
+			return -EINVAL;
+		}
+		resource ++;
+		i ++;
+	}
+	return 0;
+}
diff -Nru a/drivers/pnp/pnpbios/Kconfig b/drivers/pnp/pnpbios/Kconfig
--- a/drivers/pnp/pnpbios/Kconfig	2004-12-24 13:37:17 -08:00
+++ b/drivers/pnp/pnpbios/Kconfig	2004-12-24 13:37:17 -08:00
@@ -3,7 +3,8 @@
 #
 config PNPBIOS
 	bool "Plug and Play BIOS support (EXPERIMENTAL)"
-	depends on PNP && X86 && EXPERIMENTAL
+	depends on PNP && ISA && X86 && EXPERIMENTAL
+	default n
 	---help---
 	  Linux uses the PNPBIOS as defined in "Plug and Play BIOS
 	  Specification Version 1.0A May 5, 1994" to autodetect built-in
diff -Nru a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
--- a/drivers/pnp/pnpbios/bioscalls.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/pnp/pnpbios/bioscalls.c	2004-12-24 13:37:02 -08:00
@@ -165,7 +165,7 @@
 	if(pnp_bios_is_utter_crap)
 	{
 		printk(KERN_ERR "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n");
-		printk(KERN_ERR "PnPBIOS: You may need to reboot with the \"nobiospnp\" option to operate stably\n");
+		printk(KERN_ERR "PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n");
 		printk(KERN_ERR "PnPBIOS: Check with your vendor for an updated BIOS\n");
 	}
 
diff -Nru a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
--- a/drivers/pnp/pnpbios/core.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/pnp/pnpbios/core.c	2004-12-24 13:36:17 -08:00
@@ -56,10 +56,11 @@
 #include <linux/mm.h>
 #include <linux/smp.h>
 #include <linux/slab.h>
-#include <linux/kmod.h>
+#include <linux/kobject_uevent.h>
 #include <linux/completion.h>
 #include <linux/spinlock.h>
 #include <linux/dmi.h>
+#include <linux/delay.h>
 
 #include <asm/page.h>
 #include <asm/desc.h>
@@ -177,8 +178,7 @@
 		/*
 		 * Poll every 2 seconds
 		 */
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ*2);
+		msleep_interruptible(2000);
 		if(signal_pending(current))
 			break;
 
@@ -538,6 +538,14 @@
 		return -ENODEV;
 	}
 
+#ifdef CONFIG_ACPI
+	if (!acpi_disabled) {
+		pnpbios_disabled = 1;
+		printk(KERN_INFO "PnPBIOS: Disabled by ACPI\n");
+		return -ENODEV;
+	}
+#endif /* CONFIG_ACPI */
+
 	/* scan the system for pnpbios support */
 	if (!pnpbios_probe_system())
 		return -ENODEV;
@@ -574,6 +582,8 @@
 
 static int __init pnpbios_thread_init(void)
 {
+	if (pnpbios_disabled)
+		return 0;
 #ifdef CONFIG_HOTPLUG
 	init_completion(&unload_sem);
 	if (kernel_thread(pnp_dock_thread, NULL, CLONE_KERNEL) > 0)
diff -Nru a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
--- a/drivers/pnp/pnpbios/rsparser.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/pnp/pnpbios/rsparser.c	2004-12-24 13:36:47 -08:00
@@ -7,6 +7,7 @@
 #include <linux/ctype.h>
 #include <linux/pnp.h>
 #include <linux/pnpbios.h>
+#include <linux/pci.h>
 
 #include "pnpbios.h"
 
@@ -58,6 +59,7 @@
 		}
 		res->irq_resource[i].start =
 		res->irq_resource[i].end = (unsigned long) irq;
+		pcibios_penalize_isa_irq(irq);
 	}
 }
 
@@ -285,10 +287,13 @@
 pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
 {
 	struct pnp_irq * irq;
+	unsigned long bits;
+
 	irq = pnpbios_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL);
 	if (!irq)
 		return;
-	irq->map = (p[2] << 8) | p[1];
+	bits = (p[2] << 8) | p[1];
+	bitmap_copy(irq->map, &bits, 16);
 	if (size > 2)
 		irq->flags = p[3];
 	else
diff -Nru a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
--- a/drivers/pnp/quirks.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/pnp/quirks.c	2004-12-24 13:37:18 -08:00
@@ -63,14 +63,17 @@
 static void quirk_cmi8330_resources(struct pnp_dev *dev)
 {
 	struct pnp_option *res = dev->dependent;
+	unsigned long tmp;
 
 	for ( ; res ; res = res->next ) {
 
 		struct pnp_irq *irq;
 		struct pnp_dma *dma;
 
-		for( irq = res->irq; irq; irq = irq->next )	// Valid irqs are 5, 7, 10
-			irq->map = 0x04A0;						// 0000 0100 1010 0000
+		for( irq = res->irq; irq; irq = irq->next ) {	// Valid irqs are 5, 7, 10
+			tmp = 0x04A0;
+			bitmap_copy(irq->map, &tmp, 16);	// 0000 0100 1010 0000
+		}
 
 		for( dma = res->dma; dma; dma = dma->next ) // Valid 8bit dma channels are 1,3
 			if( ( dma->flags & IORESOURCE_DMA_TYPE_MASK ) == IORESOURCE_DMA_8BIT )
diff -Nru a/drivers/pnp/resource.c b/drivers/pnp/resource.c
--- a/drivers/pnp/resource.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/pnp/resource.c	2004-12-24 13:36:59 -08:00
@@ -101,8 +101,8 @@
 	{
 		int i;
 
-		for (i=0; i<16; i++)
-			if (data->map & (1<<i))
+		for (i = 0; i < 16; i++)
+			if (test_bit(i, data->map))
 				pcibios_penalize_isa_irq(i);
 	}
 #endif
@@ -421,6 +421,7 @@
 
 int pnp_check_dma(struct pnp_dev * dev, int idx)
 {
+#ifndef CONFIG_IA64
 	int tmp;
 	struct pnp_dev *tdev;
 	unsigned long * dma = &dev->res.dma_resource[idx].start;
@@ -470,6 +471,10 @@
 	}
 
 	return 1;
+#else
+	/* IA64 hasn't legacy DMA */
+	return 0;
+#endif
 }
 
 
diff -Nru a/drivers/s390/Kconfig b/drivers/s390/Kconfig
--- a/drivers/s390/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/drivers/s390/Kconfig	2004-12-24 13:37:19 -08:00
@@ -51,6 +51,8 @@
 	  When not in use, each additional set of 256 PTYs occupy
 	  approximately 8 KB of kernel memory on 32-bit architectures.
 
+source "drivers/char/watchdog/Kconfig"
+
 comment "S/390 character device drivers"
 
 config TN3270
@@ -173,6 +175,23 @@
 	  Select this option if you want to access IBM 3480/3490 magnetic
 	  tape subsystems and 100% compatibles.
 	  It is safe to say "Y" here.
+
+
+
+config VMLOGRDR
+	tristate "Support for the z/VM recording system services (VM only)"
+	depends on IUCV
+	help
+	  Select this option if you want to be able to receive records collected
+	  by the z/VM recording system services, eg. from *LOGREC, *ACCOUNT or
+	  *SYMPTOM.
+	  This driver depends on the IUCV support driver.
+
+config MONREADER
+	tristate "API for reading z/VM monitor service records"
+	depends on IUCV
+	help
+	  Character device driver for reading z/VM monitor service records
 
 endmenu
 
diff -Nru a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
--- a/drivers/s390/block/dasd.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/s390/block/dasd.c	2004-12-24 13:36:48 -08:00
@@ -7,7 +7,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
  *
- * $Revision: 1.147 $
+ * $Revision: 1.151 $
  */
 
 #include <linux/config.h>
@@ -1103,13 +1103,16 @@
 dasd_end_request_cb(struct dasd_ccw_req * cqr, void *data)
 {
 	struct request *req;
+	struct dasd_device *device;
+	int status;
 
 	req = (struct request *) data;
-	dasd_profile_end(cqr->device, cqr, req);
-	spin_lock_irq(&cqr->device->request_queue_lock);
-	dasd_end_request(req, (cqr->status == DASD_CQR_DONE));
-	spin_unlock_irq(&cqr->device->request_queue_lock);
-	dasd_sfree_request(cqr, cqr->device);
+	device = cqr->device;
+	dasd_profile_end(device, cqr, req);
+	status = cqr->device->discipline->free_cp(cqr,req);
+	spin_lock_irq(&device->request_queue_lock);
+	dasd_end_request(req, status);
+	spin_unlock_irq(&device->request_queue_lock);
 }
 
 
@@ -1595,8 +1598,8 @@
 
 	device->request_queue->queuedata = device;
 #if 0
-	elevator_exit(device->request_queue);
-	rc = elevator_init(device->request_queue, &elevator_noop);
+	elevator_exit(device->request_queue->elevator);
+	rc = elevator_init(device->request_queue, "noop");
 	if (rc) {
 		blk_cleanup_queue(device->request_queue);
 		return rc;
@@ -1906,8 +1909,10 @@
 			dasd_schedule_bh(device);
 		} else {
 			list_for_each_entry(cqr, &device->ccw_queue, list)
-				if (cqr->status == DASD_CQR_IN_IO)
+				if (cqr->status == DASD_CQR_IN_IO) {
 					cqr->status = DASD_CQR_QUEUED;
+					cqr->retries++;
+				}
 			device->stopped |= DASD_STOPPED_DC_WAIT;
 			dasd_set_timer(device, 0);
 		}
diff -Nru a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
--- a/drivers/s390/block/dasd_3990_erp.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/s390/block/dasd_3990_erp.c	2004-12-24 13:37:18 -08:00
@@ -5,7 +5,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001
  *
- * $Revision: 1.33 $
+ * $Revision: 1.34 $
  */
 
 #include <linux/timer.h>
@@ -461,6 +461,12 @@
 			
 			dasd_3990_erp_block_queue(erp, 30*HZ);
 
+                } else if (sense[25] == 0x1E) {	/* busy */
+			DEV_MESSAGE(KERN_INFO, device,
+				    "busy - redriving request later, "
+				    "%d retries left",
+				    erp->retries);
+                        dasd_3990_erp_block_queue(erp, HZ);
 		} else {
 
 			/* no state change pending - retry */
@@ -1304,8 +1310,8 @@
 			    "fetch mode active");
 
 		/* not possible to handle this situation in Linux */
-		panic("No way to inform appliction about the possibly "
-		      "incorret data");
+		panic("No way to inform application about the possibly "
+		      "incorrect data");
 
 	} else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
 
@@ -2201,6 +2207,13 @@
 				    "for the subsystem or device");
 
 			erp = dasd_3990_erp_action_4(erp, sense);
+			break;
+
+		case 0x1E:	/* busy */
+                        DEV_MESSAGE(KERN_DEBUG, device, "%s",
+				    "Busy condition exists "
+				    "for the subsystem or device");
+                        erp = dasd_3990_erp_action_4(erp, sense);
 			break;
 
 		default:	/* all others errors - default erp  */
diff -Nru a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
--- a/drivers/s390/block/dasd_devmap.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/s390/block/dasd_devmap.c	2004-12-24 13:36:55 -08:00
@@ -11,7 +11,7 @@
  * functions may not be called from interrupt context. In particular
  * dasd_get_device is a no-no from interrupt context.
  *
- * $Revision: 1.30 $
+ * $Revision: 1.34 $
  */
 
 #include <linux/config.h>
@@ -26,6 +26,9 @@
 
 #include "dasd_int.h"
 
+kmem_cache_t *dasd_page_cache;
+EXPORT_SYMBOL(dasd_page_cache);
+
 /*
  * dasd_devmap_t is used to store the features and the relation
  * between device number and device index. To find a dasd_devmap_t
@@ -204,94 +207,144 @@
 }
 
 /*
- * Read comma separated list of dasd ranges.
+ * Try to match the first element on the comma separated parse string
+ * with one of the known keywords. If a keyword is found, take the approprate
+ * action and return a pointer to the residual string. If the first element
+ * could not be matched to any keyword then return an error code.
+ */
+static char *
+dasd_parse_keyword( char *parsestring ) {
+
+	char *nextcomma, *residual_str;
+	int length;
+
+	nextcomma = strchr(parsestring,',');
+	if (nextcomma) {
+		length = nextcomma - parsestring;
+		residual_str = nextcomma + 1;
+	} else {
+		length = strlen(parsestring);
+		residual_str = parsestring + length;
+        }
+	if (strncmp ("autodetect", parsestring, length) == 0) {
+		dasd_autodetect = 1;
+		MESSAGE (KERN_INFO, "%s",
+			 "turning to autodetection mode");
+                return residual_str;
+        }
+        if (strncmp ("probeonly", parsestring, length) == 0) {
+		dasd_probeonly = 1;
+		MESSAGE(KERN_INFO, "%s",
+			"turning to probeonly mode");
+                return residual_str;
+        }
+        if (strncmp ("fixedbuffers", parsestring, length) == 0) {
+		if (dasd_page_cache)
+			return residual_str;
+		dasd_page_cache =
+			kmem_cache_create("dasd_page_cache", PAGE_SIZE, 0,
+					  SLAB_CACHE_DMA, NULL, NULL );
+		if (!dasd_page_cache)
+			MESSAGE(KERN_WARNING, "%s", "Failed to create slab, "
+				"fixed buffer mode disabled.");
+		else
+			MESSAGE (KERN_INFO, "%s",
+				 "turning on fixed buffer mode");
+                return residual_str;
+        }
+	return ERR_PTR(-EINVAL);
+}
+
+/*
+ * Try to interprete the first element on the comma separated parse string
+ * as a device number or a range of devices. If the interpretation is
+ * successfull, create the matching dasd_devmap entries and return a pointer
+ * to the residual string.
+ * If interpretation fails or in case of an error, return an error code.
  */
-static inline int
-dasd_ranges_list(char *str)
-{
+static char *
+dasd_parse_range( char *parsestring ) {
+
 	struct dasd_devmap *devmap;
 	int from, from_id0, from_id1;
 	int to, to_id0, to_id1;
 	int features, rc;
-	char bus_id[BUS_ID_SIZE+1], *orig_str;
+	char bus_id[BUS_ID_SIZE+1], *str;
 
-	orig_str = str;
-	while (1) {
-		rc = dasd_busid(&str, &from_id0, &from_id1, &from);
-		if (rc == 0) {
-			to = from;
-			to_id0 = from_id0;
-			to_id1 = from_id1;
-			if (*str == '-') {
-				str++;
-				rc = dasd_busid(&str, &to_id0, &to_id1, &to);
-			}
+	str = parsestring;
+	rc = dasd_busid(&str, &from_id0, &from_id1, &from);
+	if (rc == 0) {
+		to = from;
+		to_id0 = from_id0;
+		to_id1 = from_id1;
+		if (*str == '-') {
+			str++;
+			rc = dasd_busid(&str, &to_id0, &to_id1, &to);
 		}
-		if (rc == 0 &&
-		    (from_id0 != to_id0 || from_id1 != to_id1 || from > to))
-			rc = -EINVAL;
-		if (rc) {
-			MESSAGE(KERN_ERR, "Invalid device range %s", orig_str);
-			return rc;
-		}
-		features = dasd_feature_list(str, &str);
-		if (features < 0)
-			return -EINVAL;
-		while (from <= to) {
-			sprintf(bus_id, "%01x.%01x.%04x",
-				from_id0, from_id1, from++);
-			devmap = dasd_add_busid(bus_id, features);
-			if (IS_ERR(devmap))
-				return PTR_ERR(devmap);
-		}
-		if (*str != ',')
-			break;
-		str++;
 	}
-	if (*str != '\0') {
-		MESSAGE(KERN_WARNING,
-			"junk at end of dasd parameter string: %s\n", str);
-		return -EINVAL;
+	if (rc == 0 &&
+	    (from_id0 != to_id0 || from_id1 != to_id1 || from > to))
+		rc = -EINVAL;
+	if (rc) {
+		MESSAGE(KERN_ERR, "Invalid device range %s", parsestring);
+		return ERR_PTR(rc);
 	}
-	return 0;
+	features = dasd_feature_list(str, &str);
+	if (features < 0)
+		return ERR_PTR(-EINVAL);
+	while (from <= to) {
+		sprintf(bus_id, "%01x.%01x.%04x",
+			from_id0, from_id1, from++);
+		devmap = dasd_add_busid(bus_id, features);
+		if (IS_ERR(devmap))
+			return (char *)devmap;
+	}
+	if (*str == ',')
+		return str + 1;
+	if (*str == '\0')
+		return str;
+	MESSAGE(KERN_WARNING,
+		"junk at end of dasd parameter string: %s\n", str);
+	return ERR_PTR(-EINVAL);
 }
 
-/*
- * Parse a single dasd= parameter.
- */
-static int
-dasd_parameter(char *str)
-{
-	if (strcmp ("autodetect", str) == 0) {
-		dasd_autodetect = 1;
-		MESSAGE (KERN_INFO, "%s",
-			 "turning to autodetection mode");
-		return 0;
-	}
-	if (strcmp ("probeonly", str) == 0) {
-		dasd_probeonly = 1;
-		MESSAGE(KERN_INFO, "%s",
-			"turning to probeonly mode");
-		return 0;
-	}
-	/* turn off autodetect mode and scan for dasd ranges */
-	dasd_autodetect = 0;
-	return dasd_ranges_list(str);
+static inline char *
+dasd_parse_next_element( char *parsestring ) {
+	char * residual_str;
+	residual_str = dasd_parse_keyword(parsestring);
+	if (!IS_ERR(residual_str))
+		return residual_str;
+	residual_str = dasd_parse_range(parsestring);
+	return residual_str;
 }
 
 /*
- * Parse parameters stored in dasd[] and dasd_disciplines[].
+ * Parse parameters stored in dasd[]
+ * The 'dasd=...' parameter allows to specify a comma separated list of
+ * keywords and device ranges. When the dasd driver is build into the kernel,
+ * the complete list will be stored as one element of the dasd[] array.
+ * When the dasd driver is build as a module, then the list is broken into
+ * it's elements and each dasd[] entry contains one element.
  */
 int
 dasd_parse(void)
 {
 	int rc, i;
+	char *parsestring;
 
 	rc = 0;
 	for (i = 0; i < 256; i++) {
 		if (dasd[i] == NULL)
 			break;
-		rc = dasd_parameter(dasd[i]);
+		parsestring = dasd[i];
+		/* loop over the comma separated list in the parsestring */
+		while (*parsestring) {
+			parsestring = dasd_parse_next_element(parsestring);
+			if(IS_ERR(parsestring)) {
+				rc = PTR_ERR(parsestring);
+				break;
+			}
+		}
 		if (rc) {
 			DBF_EVENT(DBF_ALERT, "%s", "invalid range found");
 			break;
diff -Nru a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
--- a/drivers/s390/block/dasd_diag.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/s390/block/dasd_diag.c	2004-12-24 13:36:17 -08:00
@@ -6,7 +6,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.38 $
+ * $Revision: 1.39 $
  */
 
 #include <linux/config.h>
@@ -414,6 +414,16 @@
 }
 
 static int
+dasd_diag_free_cp(struct dasd_ccw_req *cqr, struct request *req)
+{
+	int status;
+
+	status = cqr->status == DASD_CQR_DONE;
+	dasd_sfree_request(cqr, cqr->device);
+	return status;
+}
+
+static int
 dasd_diag_fill_info(struct dasd_device * device,
 		    struct dasd_information2_t * info)
 {
@@ -475,6 +485,7 @@
 	.erp_action = dasd_diag_erp_action,
 	.erp_postaction = dasd_diag_erp_postaction,
 	.build_cp = dasd_diag_build_cp,
+	.free_cp = dasd_diag_free_cp,
 	.dump_sense = dasd_diag_dump_sense,
 	.fill_info = dasd_diag_fill_info,
 };
diff -Nru a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
--- a/drivers/s390/block/dasd_eckd.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/s390/block/dasd_eckd.c	2004-12-24 13:36:16 -08:00
@@ -7,7 +7,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.61 $
+ * $Revision: 1.65 $
  */
 
 #include <linux/config.h>
@@ -1035,6 +1035,14 @@
 	}
 	rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) {
 		dst = page_address(bv->bv_page) + bv->bv_offset;
+		if (dasd_page_cache) {
+			char *copy = kmem_cache_alloc(dasd_page_cache,
+						      SLAB_DMA | __GFP_NOWARN);
+			if (copy && rq_data_dir(req) == WRITE)
+				memcpy(copy + bv->bv_offset, dst, bv->bv_len);
+			if (copy)
+				dst = copy + bv->bv_offset;
+		}
 		for (off = 0; off < bv->bv_len; off += blksize) {
 			sector_t trkid = recid;
 			unsigned int recoffs = sector_div(trkid, blk_per_trk);
@@ -1089,6 +1097,58 @@
 }
 
 static int
+dasd_eckd_free_cp(struct dasd_ccw_req *cqr, struct request *req)
+{
+	struct dasd_eckd_private *private;
+	struct ccw1 *ccw;
+	struct bio *bio;
+	struct bio_vec *bv;
+	char *dst, *cda;
+	unsigned int blksize, blk_per_trk, off;
+	sector_t recid;
+	int i, status;
+
+	if (!dasd_page_cache)
+		goto out;
+	private = (struct dasd_eckd_private *) cqr->device->private;
+	blksize = cqr->device->bp_block;
+	blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize);
+	recid = req->sector >> cqr->device->s2b_shift;
+	ccw = cqr->cpaddr;
+	/* Skip over define extent & locate record. */
+	ccw++;
+	if (private->uses_cdl == 0 || recid > 2*blk_per_trk)
+		ccw++;
+	rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) {
+		dst = page_address(bv->bv_page) + bv->bv_offset;
+		for (off = 0; off < bv->bv_len; off += blksize) {
+			/* Skip locate record. */
+			if (private->uses_cdl && recid <= 2*blk_per_trk)
+				ccw++;
+			if (dst) {
+				if (ccw->flags & CCW_FLAG_IDA)
+					cda = *((char **)((addr_t) ccw->cda));
+				else
+					cda = (char *)((addr_t) ccw->cda);
+				if (dst != cda) {
+					if (rq_data_dir(req) == READ)
+						memcpy(dst, cda, bv->bv_len);
+					kmem_cache_free(dasd_page_cache,
+					    (void *)((addr_t)cda & PAGE_MASK));
+				}
+				dst = NULL;
+			}
+			ccw++;
+			recid++;
+		}
+	}
+out:
+	status = cqr->status == DASD_CQR_DONE;
+	dasd_sfree_request(cqr, cqr->device);
+	return status;
+}
+
+static int
 dasd_eckd_fill_info(struct dasd_device * device,
 		    struct dasd_information2_t * info)
 {
@@ -1474,6 +1534,7 @@
 	.erp_action = dasd_eckd_erp_action,
 	.erp_postaction = dasd_eckd_erp_postaction,
 	.build_cp = dasd_eckd_build_cp,
+	.free_cp = dasd_eckd_free_cp,
 	.dump_sense = dasd_eckd_dump_sense,
 	.fill_info = dasd_eckd_fill_info,
 };
diff -Nru a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
--- a/drivers/s390/block/dasd_fba.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/s390/block/dasd_fba.c	2004-12-24 13:37:01 -08:00
@@ -4,7 +4,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.34 $
+ * $Revision: 1.37 $
  */
 
 #include <linux/config.h>
@@ -311,6 +311,14 @@
 	recid = first_rec;
 	rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) {
 		dst = page_address(bv->bv_page) + bv->bv_offset;
+		if (dasd_page_cache) {
+			char *copy = kmem_cache_alloc(dasd_page_cache,
+						      SLAB_DMA | __GFP_NOWARN);
+			if (copy && rq_data_dir(req) == WRITE)
+				memcpy(copy + bv->bv_offset, dst, bv->bv_len);
+			if (copy)
+				dst = copy + bv->bv_offset;
+		}
 		for (off = 0; off < bv->bv_len; off += blksize) {
 			/* Locate record for stupid devices. */
 			if (private->rdc_data.mode.bits.data_chain == 0) {
@@ -348,6 +356,54 @@
 }
 
 static int
+dasd_fba_free_cp(struct dasd_ccw_req *cqr, struct request *req)
+{
+	struct dasd_fba_private *private;
+	struct ccw1 *ccw;
+	struct bio *bio;
+	struct bio_vec *bv;
+	char *dst, *cda;
+	unsigned int blksize, off;
+	int i, status;
+
+	if (!dasd_page_cache)
+		goto out;
+	private = (struct dasd_fba_private *) cqr->device->private;
+	blksize = cqr->device->bp_block;
+	ccw = cqr->cpaddr;
+	/* Skip over define extent & locate record. */
+	ccw++;
+	if (private->rdc_data.mode.bits.data_chain != 0)
+		ccw++;
+	rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) {
+		dst = page_address(bv->bv_page) + bv->bv_offset;
+		for (off = 0; off < bv->bv_len; off += blksize) {
+			/* Skip locate record. */
+			if (private->rdc_data.mode.bits.data_chain == 0)
+				ccw++;
+			if (dst) {
+				if (ccw->flags & CCW_FLAG_IDA)
+					cda = *((char **)((addr_t) ccw->cda));
+				else
+					cda = (char *)((addr_t) ccw->cda);
+				if (dst != cda) {
+					if (rq_data_dir(req) == READ)
+						memcpy(dst, cda, bv->bv_len);
+					kmem_cache_free(dasd_page_cache,
+					    (void *)((addr_t)cda & PAGE_MASK));
+				}
+				dst = NULL;
+			}
+			ccw++;
+		}
+	}
+out:
+	status = cqr->status == DASD_CQR_DONE;
+	dasd_sfree_request(cqr, cqr->device);
+	return status;
+}
+
+static int
 dasd_fba_fill_info(struct dasd_device * device,
 		   struct dasd_information2_t * info)
 {
@@ -410,6 +466,7 @@
 	.erp_action = dasd_fba_erp_action,
 	.erp_postaction = dasd_fba_erp_postaction,
 	.build_cp = dasd_fba_build_cp,
+	.free_cp = dasd_fba_free_cp,
 	.dump_sense = dasd_fba_dump_sense,
 	.fill_info = dasd_fba_fill_info,
 };
diff -Nru a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
--- a/drivers/s390/block/dasd_int.h	2004-12-24 13:37:03 -08:00
+++ b/drivers/s390/block/dasd_int.h	2004-12-24 13:37:03 -08:00
@@ -6,7 +6,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.60 $
+ * $Revision: 1.61 $
  */
 
 #ifndef DASD_INT_H
@@ -240,7 +240,7 @@
 	int (*term_IO) (struct dasd_ccw_req *);
 	struct dasd_ccw_req *(*format_device) (struct dasd_device *,
 					       struct format_data_t *);
-
+	int (*free_cp) (struct dasd_ccw_req *, struct request *);
         /*
          * Error recovery functions. examine_error() returns a value that
          * indicates what to do for an error condition. If examine_error()
@@ -437,6 +437,8 @@
 extern struct dasd_profile_info_t dasd_global_profile;
 extern unsigned int dasd_profile_level;
 extern struct block_device_operations dasd_device_operations;
+
+extern kmem_cache_t *dasd_page_cache;
 
 struct dasd_ccw_req *
 dasd_kmalloc_request(char *, int, int, struct dasd_device *);
diff -Nru a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
--- a/drivers/s390/block/dcssblk.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/s390/block/dcssblk.c	2004-12-24 13:36:31 -08:00
@@ -140,6 +140,57 @@
 }
 
 /*
+ * print appropriate error message for segment_load()/segment_type()
+ * return code
+ */
+static void
+dcssblk_segment_warn(int rc, char* seg_name)
+{
+	switch (rc) {
+	case -ENOENT:
+		PRINT_WARN("cannot load/query segment %s, does not exist\n",
+			   seg_name);
+		break;
+	case -ENOSYS:
+		PRINT_WARN("cannot load/query segment %s, not running on VM\n",
+			   seg_name);
+		break;
+	case -EIO:
+		PRINT_WARN("cannot load/query segment %s, hardware error\n",
+			   seg_name);
+		break;
+	case -ENOTSUPP:
+		PRINT_WARN("cannot load/query segment %s, is a multi-part "
+			   "segment\n", seg_name);
+		break;
+	case -ENOSPC:
+		PRINT_WARN("cannot load/query segment %s, overlaps with "
+			   "storage\n", seg_name);
+		break;
+	case -EBUSY:
+		PRINT_WARN("cannot load/query segment %s, overlaps with "
+			   "already loaded dcss\n", seg_name);
+		break;
+	case -EPERM:
+		PRINT_WARN("cannot load/query segment %s, already loaded in "
+			   "incompatible mode\n", seg_name);
+		break;
+	case -ENOMEM:
+		PRINT_WARN("cannot load/query segment %s, out of memory\n",
+			   seg_name);
+		break;
+	case -ERANGE:
+		PRINT_WARN("cannot load/query segment %s, exceeds kernel "
+			   "mapping range\n", seg_name);
+		break;
+	default:
+		PRINT_WARN("cannot load/query segment %s, return value %i\n",
+			   seg_name, rc);
+		break;
+	}
+}
+
+/*
  * device attribute for switching shared/nonshared (exclusive)
  * operation (show + store)
  */
@@ -167,80 +218,50 @@
 	if (atomic_read(&dev_info->use_count)) {
 		PRINT_ERR("share: segment %s is busy!\n",
 			  dev_info->segment_name);
-		up_write(&dcssblk_devices_sem);
-		return -EBUSY;
-	}
-	if ((inbuf[0] == '1') && (dev_info->is_shared == 1)) {
-		PRINT_WARN("Segment %s already loaded in shared mode!\n",
-			   dev_info->segment_name);
-		up_write(&dcssblk_devices_sem);
-		return count;
-	}
-	if ((inbuf[0] == '0') && (dev_info->is_shared == 0)) {
-		PRINT_WARN("Segment %s already loaded in exclusive mode!\n",
-			   dev_info->segment_name);
-		up_write(&dcssblk_devices_sem);
-		return count;
+		rc = -EBUSY;
+		goto out;
 	}
 	if (inbuf[0] == '1') {
 		// reload segment in shared mode
-		segment_unload(dev_info->segment_name);
-		rc = segment_load(dev_info->segment_name, SEGMENT_SHARED_RO,
-					&dev_info->start, &dev_info->end);
+		rc = segment_modify_shared(dev_info->segment_name,
+					   SEGMENT_SHARED);
 		if (rc < 0) {
-			PRINT_ERR("Segment %s not reloaded, rc=%d\n",
-					dev_info->segment_name, rc);
-			goto removeseg;
+			BUG_ON(rc == -EINVAL);
+			if (rc == -EIO || rc == -ENOENT)
+				goto removeseg;
+		} else {
+			dev_info->is_shared = 1;
+			switch (dev_info->segment_type) {
+				case SEG_TYPE_SR:
+				case SEG_TYPE_ER:
+				case SEG_TYPE_SC:
+					set_disk_ro(dev_info->gd,1);
+			}
 		}
-		dev_info->is_shared = 1;
-		PRINT_INFO("Segment %s reloaded, shared mode.\n",
-			   dev_info->segment_name);
 	} else if (inbuf[0] == '0') {
 		// reload segment in exclusive mode
-		segment_unload(dev_info->segment_name);
-		rc = segment_load(dev_info->segment_name, SEGMENT_EXCLUSIVE_RW,
-					&dev_info->start, &dev_info->end);
+		if (dev_info->segment_type == SEG_TYPE_SC) {
+			PRINT_ERR("Segment type SC (%s) cannot be loaded in "
+				  "non-shared mode\n", dev_info->segment_name);
+			rc = -EINVAL;
+			goto out;
+		}
+		rc = segment_modify_shared(dev_info->segment_name,
+					   SEGMENT_EXCLUSIVE);
 		if (rc < 0) {
-			PRINT_ERR("Segment %s not reloaded, rc=%d\n",
-					dev_info->segment_name, rc);
-			goto removeseg;
+			BUG_ON(rc == -EINVAL);
+			if (rc == -EIO || rc == -ENOENT)
+				goto removeseg;
+		} else {
+			dev_info->is_shared = 0;
+			set_disk_ro(dev_info->gd, 0);
 		}
-		dev_info->is_shared = 0;
-		PRINT_INFO("Segment %s reloaded, exclusive (read-write) mode.\n",
-			   dev_info->segment_name);
 	} else {
-		up_write(&dcssblk_devices_sem);
 		PRINT_WARN("Invalid value, must be 0 or 1\n");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto out;
 	}
-	dev_info->segment_type = rc;
 	rc = count;
-
-	switch (dev_info->segment_type) {
-		case SEGMENT_SHARED_RO:
-		case SEGMENT_EXCLUSIVE_RO:
-			set_disk_ro(dev_info->gd, 1);
-			break;
-		case SEGMENT_SHARED_RW:
-		case SEGMENT_EXCLUSIVE_RW:
-			set_disk_ro(dev_info->gd, 0);
-			break;
-	}
-	if ((inbuf[0] == '1') &&
-	   ((dev_info->segment_type == SEGMENT_EXCLUSIVE_RO) ||
-	    (dev_info->segment_type == SEGMENT_EXCLUSIVE_RW))) {
-		PRINT_WARN("Could not get shared copy of segment %s\n",
-				dev_info->segment_name);
-		rc = -EPERM;
-	}
-	if ((inbuf[0] == '0') &&
-	   ((dev_info->segment_type == SEGMENT_SHARED_RO) ||
-	    (dev_info->segment_type == SEGMENT_SHARED_RW))) {
-		PRINT_WARN("Could not get exclusive copy of segment %s\n",
-				dev_info->segment_name);
-		rc = -EPERM;
-	}
-	up_write(&dcssblk_devices_sem);
 	goto out;
 
 removeseg:
@@ -254,8 +275,8 @@
 	put_disk(dev_info->gd);
 	device_unregister(dev);
 	put_device(dev);
-	up_write(&dcssblk_devices_sem);
 out:
+	up_write(&dcssblk_devices_sem);
 	return rc;
 }
 
@@ -292,7 +313,7 @@
 			// device is idle => we save immediately
 			PRINT_INFO("Saving segment %s\n",
 				   dev_info->segment_name);
-			segment_replace(dev_info->segment_name);
+			segment_save(dev_info->segment_name);
 		}  else {
 			// device is busy => we save it when it becomes
 			// idle in dcssblk_release
@@ -390,18 +411,17 @@
 	/*
 	 * load the segment
 	 */
-	rc = segment_load(local_buf, SEGMENT_SHARED_RO,
+	rc = segment_load(local_buf, SEGMENT_SHARED,
 				&dev_info->start, &dev_info->end);
 	if (rc < 0) {
-		PRINT_ERR("Segment %s not loaded, rc=%d\n", local_buf, rc);
+		dcssblk_segment_warn(rc, dev_info->segment_name);
 		goto dealloc_gendisk;
 	}
 	seg_byte_size = (dev_info->end - dev_info->start + 1);
 	set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors
-	PRINT_INFO("Loaded segment %s from %p to %p, size = %lu Byte, "
-		   "capacity = %lu sectors (512 Byte)\n", local_buf,
-		   	(void *) dev_info->start, (void *) dev_info->end,
-			seg_byte_size, seg_byte_size >> 9);
+	PRINT_INFO("Loaded segment %s, size = %lu Byte, "
+		   "capacity = %lu (512 Byte) sectors\n", local_buf,
+		   seg_byte_size, seg_byte_size >> 9);
 
 	dev_info->segment_type = rc;
 	dev_info->save_pending = 0;
@@ -451,12 +471,12 @@
 	blk_queue_hardsect_size(dev_info->dcssblk_queue, 4096);
 
 	switch (dev_info->segment_type) {
-		case SEGMENT_SHARED_RO:
-		case SEGMENT_EXCLUSIVE_RO:
+		case SEG_TYPE_SR:
+		case SEG_TYPE_ER:
+		case SEG_TYPE_SC:
 			set_disk_ro(dev_info->gd,1);
 			break;
-		case SEGMENT_SHARED_RW:
-		case SEGMENT_EXCLUSIVE_RW:
+		default:
 			set_disk_ro(dev_info->gd,0);
 			break;
 	}
@@ -589,7 +609,7 @@
 	    && (dev_info->save_pending)) {
 		PRINT_INFO("Segment %s became idle and is being saved now\n",
 			    dev_info->segment_name);
-		segment_replace(dev_info->segment_name);
+		segment_save(dev_info->segment_name);
 		dev_info->save_pending = 0;
 	}
 	up_write(&dcssblk_devices_sem);
diff -Nru a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
--- a/drivers/s390/block/xpram.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/s390/block/xpram.c	2004-12-24 13:37:04 -08:00
@@ -74,10 +74,9 @@
  */
 static int devs = XPRAM_DEVS;
 static unsigned int sizes[XPRAM_MAX_DEVS];
-static unsigned int sizes_count;
 
 module_param(devs, int, 0);
-module_param_array(sizes, int, sizes_count, 0);
+module_param_array(sizes, int, NULL, 0);
 
 MODULE_PARM_DESC(devs, "number of devices (\"partitions\"), " \
 		 "the default is " __MODULE_STRING(XPRAM_DEVS) "\n");
diff -Nru a/drivers/s390/char/Makefile b/drivers/s390/char/Makefile
--- a/drivers/s390/char/Makefile	2004-12-24 13:36:48 -08:00
+++ b/drivers/s390/char/Makefile	2004-12-24 13:36:48 -08:00
@@ -17,8 +17,12 @@
 obj-$(CONFIG_SCLP_VT220_TTY) += sclp_vt220.o
 obj-$(CONFIG_SCLP_CPI) += sclp_cpi.o
 
+obj-$(CONFIG_ZVM_WATCHDOG) += vmwatchdog.o
+obj-$(CONFIG_VMLOGRDR) += vmlogrdr.o
+
 tape-$(CONFIG_S390_TAPE_BLOCK) += tape_block.o
 tape-$(CONFIG_PROC_FS) += tape_proc.o
 tape-objs := tape_core.o tape_std.o tape_char.o $(tape-y)
 obj-$(CONFIG_S390_TAPE) += tape.o tape_class.o
 obj-$(CONFIG_S390_TAPE_34XX) += tape_34xx.o
+obj-$(CONFIG_MONREADER) += monreader.o
diff -Nru a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
--- a/drivers/s390/char/con3215.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/s390/char/con3215.c	2004-12-24 13:37:02 -08:00
@@ -983,35 +983,16 @@
  * String write routine for 3215 ttys
  */
 static int
-tty3215_write(struct tty_struct * tty, int from_user,
+tty3215_write(struct tty_struct * tty,
 	      const unsigned char *buf, int count)
 {
 	struct raw3215_info *raw;
-	int length, ret;
 
 	if (!tty)
 		return 0;
 	raw = (struct raw3215_info *) tty->driver_data;
-	if (!from_user) {
-		raw3215_write(raw, buf, count);
-		return count;
-	}
-	ret = 0;
-	while (count > 0) {
-		length = count < 80 ? count : 80;
-		length -= copy_from_user(raw->ubuffer,
-				(const unsigned char __user *)buf, length);
-		if (length == 0) {
-			if (!ret)
-				ret = -EFAULT;
-			break;
-		}
-		raw3215_write(raw, raw->ubuffer, count);
-		buf += length;
-		count -= length;
-		ret += length;
-	}
-	return ret;
+	raw3215_write(raw, buf, count);
+	return count;
 }
 
 /*
diff -Nru a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
--- a/drivers/s390/char/con3270.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/s390/char/con3270.c	2004-12-24 13:36:18 -08:00
@@ -73,14 +73,11 @@
 con3270_set_timer(struct con3270 *cp, int expires)
 {
 	if (expires == 0) {
-		if (timer_pending(&cp->timer))
-			del_timer(&cp->timer);
+		del_timer(&cp->timer);
 		return;
 	}
-	if (timer_pending(&cp->timer)) {
-		if (mod_timer(&cp->timer, jiffies + expires))
-			return;
-	}
+	if (mod_timer(&cp->timer, jiffies + expires))
+		return;
 	cp->timer.function = (void (*)(unsigned long)) con3270_update;
 	cp->timer.data = (unsigned long) cp;
 	cp->timer.expires = jiffies + expires;
diff -Nru a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/s390/char/monreader.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,662 @@
+/*
+ * drivers/s390/char/monreader.c
+ *
+ * Character device driver for reading z/VM *MONITOR service records.
+ *
+ * Copyright (C) 2004 IBM Corporation, IBM Deutschland Entwicklung GmbH.
+ *
+ * Author: Gerald Schaefer <geraldsc@de.ibm.com>
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/ctype.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <asm/uaccess.h>
+#include <asm/ebcdic.h>
+#include <asm/extmem.h>
+#include <linux/poll.h>
+#include "../net/iucv.h"
+
+
+//#define MON_DEBUG			/* Debug messages on/off */
+
+#define MON_NAME "monreader"
+
+#define P_INFO(x...)	printk(KERN_INFO MON_NAME " info: " x)
+#define P_ERROR(x...)	printk(KERN_ERR MON_NAME " error: " x)
+#define P_WARNING(x...)	printk(KERN_WARNING MON_NAME " warning: " x)
+
+#ifdef MON_DEBUG
+#define P_DEBUG(x...)   printk(KERN_DEBUG MON_NAME " debug: " x)
+#else
+#define P_DEBUG(x...)   do {} while (0)
+#endif
+
+#define MON_COLLECT_SAMPLE 0x80
+#define MON_COLLECT_EVENT  0x40
+#define MON_SERVICE	   "*MONITOR"
+#define MON_IN_USE	   0x01
+#define MON_MSGLIM	   255
+
+static char mon_dcss_name[9] = "MONDCSS\0";
+
+struct mon_msg {
+	u32 pos;
+	u32 mca_offset;
+	iucv_MessagePending local_eib;
+	char msglim_reached;
+	char replied_msglim;
+};
+
+struct mon_private {
+	u16 pathid;
+	iucv_handle_t iucv_handle;
+	struct mon_msg *msg_array[MON_MSGLIM];
+	unsigned int   write_index;
+	unsigned int   read_index;
+	atomic_t msglim_count;
+	atomic_t read_ready;
+	atomic_t iucv_connected;
+	atomic_t iucv_severed;
+};
+
+static unsigned long mon_in_use = 0;
+
+static unsigned long mon_dcss_start;
+static unsigned long mon_dcss_end;
+
+static DECLARE_WAIT_QUEUE_HEAD(mon_read_wait_queue);
+static DECLARE_WAIT_QUEUE_HEAD(mon_conn_wait_queue);
+
+static u8 iucv_host[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static u8 user_data_connect[16] = {
+	/* Version code, must be 0x01 for shared mode */
+	0x01,
+	/* what to collect */
+	MON_COLLECT_SAMPLE | MON_COLLECT_EVENT,
+	/* DCSS name in EBCDIC, 8 bytes padded with blanks */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+
+static u8 user_data_sever[16] = {
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+
+
+/******************************************************************************
+ *                             helper functions                               *
+ *****************************************************************************/
+/*
+ * Create the 8 bytes EBCDIC DCSS segment name from
+ * an ASCII name, incl. padding
+ */
+static inline void
+dcss_mkname(char *ascii_name, char *ebcdic_name)
+{
+	int i;
+
+	for (i = 0; i < 8; i++) {
+		if (ascii_name[i] == '\0')
+			break;
+		ebcdic_name[i] = toupper(ascii_name[i]);
+	};
+	for (; i < 8; i++)
+		ebcdic_name[i] = ' ';
+	ASCEBC(ebcdic_name, 8);
+}
+
+/*
+ * print appropriate error message for segment_load()/segment_type()
+ * return code
+ */
+static void
+mon_segment_warn(int rc, char* seg_name)
+{
+	switch (rc) {
+	case -ENOENT:
+		P_WARNING("cannot load/query segment %s, does not exist\n",
+			  seg_name);
+		break;
+	case -ENOSYS:
+		P_WARNING("cannot load/query segment %s, not running on VM\n",
+			  seg_name);
+		break;
+	case -EIO:
+		P_WARNING("cannot load/query segment %s, hardware error\n",
+			  seg_name);
+		break;
+	case -ENOTSUPP:
+		P_WARNING("cannot load/query segment %s, is a multi-part "
+			  "segment\n", seg_name);
+		break;
+	case -ENOSPC:
+		P_WARNING("cannot load/query segment %s, overlaps with "
+			  "storage\n", seg_name);
+		break;
+	case -EBUSY:
+		P_WARNING("cannot load/query segment %s, overlaps with "
+			  "already loaded dcss\n", seg_name);
+		break;
+	case -EPERM:
+		P_WARNING("cannot load/query segment %s, already loaded in "
+			  "incompatible mode\n", seg_name);
+		break;
+	case -ENOMEM:
+		P_WARNING("cannot load/query segment %s, out of memory\n",
+			  seg_name);
+		break;
+	case -ERANGE:
+		P_WARNING("cannot load/query segment %s, exceeds kernel "
+			  "mapping range\n", seg_name);
+		break;
+	default:
+		P_WARNING("cannot load/query segment %s, return value %i\n",
+			  seg_name, rc);
+		break;
+	}
+}
+
+static inline unsigned long
+mon_mca_start(struct mon_msg *monmsg)
+{
+	return monmsg->local_eib.ln1msg1.iprmmsg1_u32;
+}
+
+static inline unsigned long
+mon_mca_end(struct mon_msg *monmsg)
+{
+	return monmsg->local_eib.ln1msg2.ipbfln1f;
+}
+
+static inline u8
+mon_mca_type(struct mon_msg *monmsg, u8 index)
+{
+	return *((u8 *) mon_mca_start(monmsg) + monmsg->mca_offset + index);
+}
+
+static inline u32
+mon_mca_size(struct mon_msg *monmsg)
+{
+	return mon_mca_end(monmsg) - mon_mca_start(monmsg) + 1;
+}
+
+static inline u32
+mon_rec_start(struct mon_msg *monmsg)
+{
+	return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 4));
+}
+
+static inline u32
+mon_rec_end(struct mon_msg *monmsg)
+{
+	return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 8));
+}
+
+static inline int
+mon_check_mca(struct mon_msg *monmsg)
+{
+	if ((mon_rec_end(monmsg) <= mon_rec_start(monmsg)) ||
+	    (mon_rec_start(monmsg) < mon_dcss_start) ||
+	    (mon_rec_end(monmsg) > mon_dcss_end) ||
+	    (mon_mca_type(monmsg, 0) == 0) ||
+	    (mon_mca_size(monmsg) % 12 != 0) ||
+	    (mon_mca_end(monmsg) <= mon_mca_start(monmsg)) ||
+	    (mon_mca_end(monmsg) > mon_dcss_end) ||
+	    (mon_mca_start(monmsg) < mon_dcss_start) ||
+	    ((mon_mca_type(monmsg, 1) == 0) && (mon_mca_type(monmsg, 2) == 0)))
+	{
+		P_DEBUG("READ, IGNORED INVALID MCA\n\n");
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static inline int
+mon_send_reply(struct mon_msg *monmsg, struct mon_private *monpriv)
+{
+	u8 prmmsg[8];
+	int rc;
+
+	P_DEBUG("read, REPLY: pathid = 0x%04X, msgid = 0x%08X, trgcls = "
+		"0x%08X\n\n",
+		monmsg->local_eib.ippathid, monmsg->local_eib.ipmsgid,
+		monmsg->local_eib.iptrgcls);
+	rc = iucv_reply_prmmsg(monmsg->local_eib.ippathid,
+				monmsg->local_eib.ipmsgid,
+				monmsg->local_eib.iptrgcls,
+				0, prmmsg);
+	atomic_dec(&monpriv->msglim_count);
+	if (likely(!monmsg->msglim_reached)) {
+		monmsg->pos = 0;
+		monmsg->mca_offset = 0;
+		monpriv->read_index = (monpriv->read_index + 1) %
+				      MON_MSGLIM;
+		atomic_dec(&monpriv->read_ready);
+	} else
+		monmsg->replied_msglim = 1;
+	if (rc) {
+		P_ERROR("read, IUCV reply failed with rc = %i\n\n", rc);
+		return -EIO;
+	}
+	return 0;
+}
+
+static inline struct mon_private *
+mon_alloc_mem(void)
+{
+	int i,j;
+	struct mon_private *monpriv;
+
+	monpriv = kmalloc(sizeof(struct mon_private), GFP_KERNEL);
+	if (!monpriv) {
+		P_ERROR("no memory for monpriv\n");
+		return NULL;
+	}
+	memset(monpriv, 0, sizeof(struct mon_private));
+	for (i = 0; i < MON_MSGLIM; i++) {
+		monpriv->msg_array[i] = kmalloc(sizeof(struct mon_msg),
+						    GFP_KERNEL);
+		if (!monpriv->msg_array[i]) {
+			P_ERROR("open, no memory for msg_array\n");
+			for (j = 0; j < i; j++)
+				kfree(monpriv->msg_array[j]);
+			return NULL;
+		}
+		memset(monpriv->msg_array[i], 0, sizeof(struct mon_msg));
+	}
+	return monpriv;
+}
+
+static inline void
+mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv)
+{
+#ifdef MON_DEBUG
+	u8 msg_type[2], mca_type;
+	unsigned long records_len;
+
+	records_len = mon_rec_end(monmsg) - mon_rec_start(monmsg) + 1;
+
+	memcpy(msg_type, &monmsg->local_eib.iptrgcls, 2);
+	EBCASC(msg_type, 2);
+	mca_type = mon_mca_type(monmsg, 0);
+	EBCASC(&mca_type, 1);
+
+	P_DEBUG("read, mon_read_index = %i, mon_write_index = %i\n",
+		monpriv->read_index, monpriv->write_index);
+	P_DEBUG("read, pathid = 0x%04X, msgid = 0x%08X, trgcls = 0x%08X\n",
+		monmsg->local_eib.ippathid, monmsg->local_eib.ipmsgid,
+		monmsg->local_eib.iptrgcls);
+	P_DEBUG("read, msg_type = '%c%c', mca_type = '%c' / 0x%X / 0x%X\n",
+		msg_type[0], msg_type[1], mca_type ? mca_type : 'X',
+		mon_mca_type(monmsg, 1), mon_mca_type(monmsg, 2));
+	P_DEBUG("read, MCA: start = 0x%lX, end = 0x%lX\n",
+		mon_mca_start(monmsg), mon_mca_end(monmsg));
+	P_DEBUG("read, REC: start = 0x%X, end = 0x%X, len = %lu\n\n",
+		mon_rec_start(monmsg), mon_rec_end(monmsg), records_len);
+	if (mon_mca_size(monmsg) > 12)
+		P_DEBUG("READ, MORE THAN ONE MCA\n\n");
+#endif
+}
+
+static inline void
+mon_next_mca(struct mon_msg *monmsg)
+{
+	if (likely((mon_mca_size(monmsg) - monmsg->mca_offset) == 12))
+		return;
+	P_DEBUG("READ, NEXT MCA\n\n");
+	monmsg->mca_offset += 12;
+	monmsg->pos = 0;
+}
+
+static inline struct mon_msg *
+mon_next_message(struct mon_private *monpriv)
+{
+	struct mon_msg *monmsg;
+
+	if (!atomic_read(&monpriv->read_ready))
+		return NULL;
+	monmsg = monpriv->msg_array[monpriv->read_index];
+	if (unlikely(monmsg->replied_msglim)) {
+		monmsg->replied_msglim = 0;
+		monmsg->msglim_reached = 0;
+		monmsg->pos = 0;
+		monmsg->mca_offset = 0;
+		P_WARNING("read, message limit reached\n");
+		monpriv->read_index = (monpriv->read_index + 1) %
+				      MON_MSGLIM;
+		atomic_dec(&monpriv->read_ready);
+		return ERR_PTR(-EOVERFLOW);
+	}
+	return monmsg;
+}
+
+
+/******************************************************************************
+ *                               IUCV handler                                 *
+ *****************************************************************************/
+static void
+mon_iucv_ConnectionComplete(iucv_ConnectionComplete *eib, void *pgm_data)
+{
+	struct mon_private *monpriv = (struct mon_private *) pgm_data;
+
+	P_DEBUG("IUCV connection completed\n");
+	P_DEBUG("IUCV ACCEPT (from *MONITOR): Version = 0x%02X, Event = "
+		"0x%02X, Sample = 0x%02X\n",
+		eib->ipuser[0], eib->ipuser[1], eib->ipuser[2]);
+	atomic_set(&monpriv->iucv_connected, 1);
+	wake_up(&mon_conn_wait_queue);
+}
+
+static void
+mon_iucv_ConnectionSevered(iucv_ConnectionSevered *eib, void *pgm_data)
+{
+	struct mon_private *monpriv = (struct mon_private *) pgm_data;
+
+	P_ERROR("IUCV connection severed with rc = 0x%X\n",
+		(u8) eib->ipuser[0]);
+	atomic_set(&monpriv->iucv_severed, 1);
+	wake_up(&mon_conn_wait_queue);
+	wake_up_interruptible(&mon_read_wait_queue);
+}
+
+static void
+mon_iucv_MessagePending(iucv_MessagePending *eib, void *pgm_data)
+{
+	struct mon_private *monpriv = (struct mon_private *) pgm_data;
+
+	P_DEBUG("IUCV message pending\n");
+	memcpy(&monpriv->msg_array[monpriv->write_index]->local_eib, eib,
+	       sizeof(iucv_MessagePending));
+	if (atomic_inc_return(&monpriv->msglim_count) == MON_MSGLIM) {
+		P_WARNING("IUCV message pending, message limit (%i) reached\n",
+			  MON_MSGLIM);
+		monpriv->msg_array[monpriv->write_index]->msglim_reached = 1;
+	}
+	monpriv->write_index = (monpriv->write_index + 1) % MON_MSGLIM;
+	atomic_inc(&monpriv->read_ready);
+	wake_up_interruptible(&mon_read_wait_queue);
+}
+
+static iucv_interrupt_ops_t mon_iucvops = {
+	.ConnectionComplete = mon_iucv_ConnectionComplete,
+	.ConnectionSevered  = mon_iucv_ConnectionSevered,
+	.MessagePending     = mon_iucv_MessagePending,
+};
+
+/******************************************************************************
+ *                               file operations                              *
+ *****************************************************************************/
+static int
+mon_open(struct inode *inode, struct file *filp)
+{
+	int rc, i;
+	struct mon_private *monpriv;
+
+	/*
+	 * only one user allowed
+	 */
+	if (test_and_set_bit(MON_IN_USE, &mon_in_use))
+		return -EBUSY;
+
+	monpriv = mon_alloc_mem();
+	if (!monpriv)
+		return -ENOMEM;
+
+	/*
+	 * Register with IUCV and connect to *MONITOR service
+	 */
+	monpriv->iucv_handle = iucv_register_program("my_monreader    ",
+							MON_SERVICE,
+							NULL,
+							&mon_iucvops,
+							monpriv);
+	if (!monpriv->iucv_handle) {
+		P_ERROR("failed to register with iucv driver\n");
+		rc = -EIO;
+		goto out_error;
+	}
+	P_INFO("open, registered with IUCV\n");
+
+	rc = iucv_connect(&monpriv->pathid, MON_MSGLIM, user_data_connect,
+			  MON_SERVICE, iucv_host, IPRMDATA, NULL, NULL,
+			  monpriv->iucv_handle, NULL);
+	if (rc) {
+		P_ERROR("iucv connection to *MONITOR failed with "
+			"IPUSER SEVER code = %i\n", rc);
+		rc = -EIO;
+		goto out_unregister;
+	}
+	/*
+	 * Wait for connection confirmation
+	 */
+	wait_event(mon_conn_wait_queue,
+		   atomic_read(&monpriv->iucv_connected) ||
+		   atomic_read(&monpriv->iucv_severed));
+	if (atomic_read(&monpriv->iucv_severed)) {
+		atomic_set(&monpriv->iucv_severed, 0);
+		atomic_set(&monpriv->iucv_connected, 0);
+		rc = -EIO;
+		goto out_unregister;
+	}
+	P_INFO("open, established connection to *MONITOR service\n\n");
+	filp->private_data = monpriv;
+	return nonseekable_open(inode, filp);
+
+out_unregister:
+	iucv_unregister_program(monpriv->iucv_handle);
+out_error:
+	for (i = 0; i < MON_MSGLIM; i++)
+		kfree(monpriv->msg_array[i]);
+	kfree(monpriv);
+	clear_bit(MON_IN_USE, &mon_in_use);
+	return rc;
+}
+
+static int
+mon_close(struct inode *inode, struct file *filp)
+{
+	int rc, i;
+	struct mon_private *monpriv = filp->private_data;
+
+	/*
+	 * Close IUCV connection and unregister
+	 */
+	rc = iucv_sever(monpriv->pathid, user_data_sever);
+	if (rc)
+		P_ERROR("close, iucv_sever failed with rc = %i\n", rc);
+	else
+		P_INFO("close, terminated connection to *MONITOR service\n");
+
+	rc = iucv_unregister_program(monpriv->iucv_handle);
+	if (rc)
+		P_ERROR("close, iucv_unregister failed with rc = %i\n", rc);
+	else
+		P_INFO("close, unregistered with IUCV\n");
+
+	atomic_set(&monpriv->iucv_severed, 0);
+	atomic_set(&monpriv->iucv_connected, 0);
+	atomic_set(&monpriv->read_ready, 0);
+	atomic_set(&monpriv->msglim_count, 0);
+	monpriv->write_index  = 0;
+	monpriv->read_index   = 0;
+
+	for (i = 0; i < MON_MSGLIM; i++)
+		kfree(monpriv->msg_array[i]);
+	kfree(monpriv);
+	clear_bit(MON_IN_USE, &mon_in_use);
+	return 0;
+}
+
+static ssize_t
+mon_read(struct file *filp, char __user *data, size_t count, loff_t *ppos)
+{
+	struct mon_private *monpriv = filp->private_data;
+	struct mon_msg *monmsg;
+	int ret;
+	u32 mce_start;
+
+	monmsg = mon_next_message(monpriv);
+	if (IS_ERR(monmsg))
+		return PTR_ERR(monmsg);
+
+	if (!monmsg) {
+		if (filp->f_flags & O_NONBLOCK)
+			return -EAGAIN;
+		ret = wait_event_interruptible(mon_read_wait_queue,
+					atomic_read(&monpriv->read_ready) ||
+					atomic_read(&monpriv->iucv_severed));
+		if (ret)
+			return ret;
+		if (unlikely(atomic_read(&monpriv->iucv_severed)))
+			return -EIO;
+		monmsg = monpriv->msg_array[monpriv->read_index];
+	}
+
+	if (!monmsg->pos) {
+		monmsg->pos = mon_mca_start(monmsg) + monmsg->mca_offset;
+		mon_read_debug(monmsg, monpriv);
+	}
+	if (mon_check_mca(monmsg))
+		goto reply;
+
+	/* read monitor control element (12 bytes) first */
+	mce_start = mon_mca_start(monmsg) + monmsg->mca_offset;
+	if ((monmsg->pos >= mce_start) && (monmsg->pos < mce_start + 12)) {
+		count = min(count, (size_t) mce_start + 12 - monmsg->pos);
+		ret = copy_to_user(data, (void *) (unsigned long) monmsg->pos,
+				   count);
+		if (ret)
+			return -EFAULT;
+		monmsg->pos += count;
+		if (monmsg->pos == mce_start + 12)
+			monmsg->pos = mon_rec_start(monmsg);
+		goto out_copy;
+	}
+
+	/* read records */
+	if (monmsg->pos <= mon_rec_end(monmsg)) {
+		count = min(count, (size_t) mon_rec_end(monmsg) - monmsg->pos
+					    + 1);
+		ret = copy_to_user(data, (void *) (unsigned long) monmsg->pos,
+				   count);
+		if (ret)
+			return -EFAULT;
+		monmsg->pos += count;
+		if (monmsg->pos > mon_rec_end(monmsg))
+			mon_next_mca(monmsg);
+		goto out_copy;
+	}
+reply:
+	ret = mon_send_reply(monmsg, monpriv);
+	return ret;
+
+out_copy:
+	*ppos += count;
+	return count;
+}
+
+static unsigned int
+mon_poll(struct file *filp, struct poll_table_struct *p)
+{
+	struct mon_private *monpriv = filp->private_data;
+
+	poll_wait(filp, &mon_read_wait_queue, p);
+	if (unlikely(atomic_read(&monpriv->iucv_severed)))
+		return POLLERR;
+	if (atomic_read(&monpriv->read_ready))
+		return POLLIN | POLLRDNORM;
+	return 0;
+}
+
+static struct file_operations mon_fops = {
+	.owner   = THIS_MODULE,
+	.open    = &mon_open,
+	.release = &mon_close,
+	.read    = &mon_read,
+	.poll    = &mon_poll,
+};
+
+static struct miscdevice mon_dev = {
+	.name       = "monreader",
+	.devfs_name = "monreader",
+	.fops       = &mon_fops,
+	.minor      = MISC_DYNAMIC_MINOR,
+};
+
+/******************************************************************************
+ *                              module init/exit                              *
+ *****************************************************************************/
+static int __init
+mon_init(void)
+{
+	int rc;
+
+	if (!MACHINE_IS_VM) {
+		P_ERROR("not running under z/VM, driver not loaded\n");
+		return -ENODEV;
+	}
+
+	rc = segment_type(mon_dcss_name);
+	if (rc < 0) {
+		mon_segment_warn(rc, mon_dcss_name);
+		return rc;
+	}
+	if (rc != SEG_TYPE_SC) {
+		P_ERROR("segment %s has unsupported type, should be SC\n",
+			mon_dcss_name);
+		return -EINVAL;
+	}
+
+	rc = segment_load(mon_dcss_name, SEGMENT_SHARED,
+			  &mon_dcss_start, &mon_dcss_end);
+	if (rc < 0) {
+		mon_segment_warn(rc, mon_dcss_name);
+		return -EINVAL;
+	}
+	dcss_mkname(mon_dcss_name, &user_data_connect[8]);
+
+	rc = misc_register(&mon_dev);
+	if (rc < 0 ) {
+		P_ERROR("misc_register failed, rc = %i\n", rc);
+		goto out;
+	}
+	P_INFO("Loaded segment %s from %p to %p, size = %lu Byte\n",
+		mon_dcss_name, (void *) mon_dcss_start, (void *) mon_dcss_end,
+		mon_dcss_end - mon_dcss_start + 1);
+	return 0;
+
+out:
+	segment_unload(mon_dcss_name);
+	return rc;
+}
+
+static void __exit
+mon_exit(void)
+{
+	segment_unload(mon_dcss_name);
+	WARN_ON(misc_deregister(&mon_dev) != 0);
+	return;
+}
+
+
+module_init(mon_init);
+module_exit(mon_exit);
+
+module_param_string(mondcss, mon_dcss_name, 9, 0444);
+MODULE_PARM_DESC(mondcss, "Name of DCSS segment to be used for *MONITOR "
+		 "service, max. 8 chars. Default is MONDCSS");
+
+MODULE_AUTHOR("Gerald Schaefer <geraldsc@de.ibm.com>");
+MODULE_DESCRIPTION("Character device driver for reading z/VM "
+		   "monitor service records.");
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
--- a/drivers/s390/char/raw3270.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/s390/char/raw3270.c	2004-12-24 13:37:18 -08:00
@@ -65,7 +65,7 @@
 
 /* Module parameters */
 static int tubxcorrect = 0;
-MODULE_PARM(tubxcorrect, "i");
+module_param(tubxcorrect, bool, 0);
 
 /*
  * Wait queue for device init/delete, view delete.
@@ -347,8 +347,11 @@
 
 	if (IS_ERR(irb))
 		rc = RAW3270_IO_RETRY;
-	else if (irb->scsw.dstat ==  (DEV_STAT_CHN_END | DEV_STAT_DEV_END |
-				      DEV_STAT_UNIT_EXCEP)) {
+	else if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) {
+		rq->rc = -EIO;
+		rc = RAW3270_IO_DONE;
+	} else if (irb->scsw.dstat ==  (DEV_STAT_CHN_END | DEV_STAT_DEV_END |
+					DEV_STAT_UNIT_EXCEP)) {
 		/* Handle CE-DE-UE and subsequent UDE */
 		set_bit(RAW3270_FLAGS_BUSY, &rp->flags);
 		rc = RAW3270_IO_BUSY;
@@ -552,6 +555,8 @@
 	rc = wait_event_interruptible(wq, raw3270_request_final(rq));
 	if (rc == -ERESTARTSYS) {	/* Interrupted by a signal. */
 		raw3270_halt_io(view->dev, rq);
+		/* No wait for the halt to complete. */
+		wait_event(wq, raw3270_request_final(rq));
 		return -ERESTARTSYS;
 	}
 	return rq->rc;
@@ -809,9 +814,15 @@
 	if (rc)
 		return ERR_PTR(rc);
 	set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags);
-	raw3270_reset_device(rp);
-	raw3270_size_device(rp);
-	raw3270_reset_device(rp);
+	rc = raw3270_reset_device(rp);
+	if (rc)
+		return ERR_PTR(rc);
+	rc = raw3270_size_device(rp);
+	if (rc)
+		return ERR_PTR(rc);
+	rc = raw3270_reset_device(rp);
+	if (rc)
+		return ERR_PTR(rc);
 	set_bit(RAW3270_FLAGS_READY, &rp->flags);
 	return rp;
 }
@@ -1030,7 +1041,7 @@
 	}
 	spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
 	/* Wait for reference counter to drop to zero. */
-	atomic_sub(2, &view->ref_count);
+	atomic_dec(&view->ref_count);
 	wait_event(raw3270_wait_queue, atomic_read(&view->ref_count) == 0);
 	if (view->fn->free)
 		view->fn->free(view);
@@ -1165,13 +1176,20 @@
 {
 	struct raw3270 *rp;
 	struct raw3270_notifier *np;
+	int rc;
 
 	rp = raw3270_create_device(cdev);
 	if (IS_ERR(rp))
 		return PTR_ERR(rp);
-	raw3270_reset_device(rp);
-	raw3270_size_device(rp);
-	raw3270_reset_device(rp);
+	rc = raw3270_reset_device(rp);
+	if (rc)
+		return rc;
+	rc = raw3270_size_device(rp);
+	if (rc)
+		return rc;
+	rc = raw3270_reset_device(rp);
+	if (rc)
+		return rc;
 	raw3270_create_attributes(rp);
 	set_bit(RAW3270_FLAGS_READY, &rp->flags);
 	down(&raw3270_sem);
diff -Nru a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
--- a/drivers/s390/char/sclp_tty.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/s390/char/sclp_tty.c	2004-12-24 13:37:43 -08:00
@@ -395,36 +395,14 @@
  * routine will return the number of characters actually accepted for writing.
  */
 static int
-sclp_tty_write(struct tty_struct *tty, int from_user,
-	       const unsigned char *buf, int count)
+sclp_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
-	int length, ret;
-
 	if (sclp_tty_chars_count > 0) {
 		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count);
 		sclp_tty_chars_count = 0;
 	}
-	if (!from_user) {
-		sclp_tty_write_string(buf, count);
-		return count;
-	}
-	ret = 0;
-	while (count > 0) {
-		length = count < SCLP_TTY_BUF_SIZE ?
-			count : SCLP_TTY_BUF_SIZE;
-		length -= copy_from_user(sclp_tty_chars,
-				(const unsigned char __user *)buf, length);
-		if (length == 0) {
-			if (!ret)
-				ret = -EFAULT;
-			break;
-		}
-		sclp_tty_write_string(sclp_tty_chars, length);
-		buf += length;
-		count -= length;
-		ret += length;
-	}
-	return ret;
+	sclp_tty_write_string(buf, count);
+	return count;
 }
 
 /*
@@ -623,7 +601,7 @@
 
 	/* if set in ioctl write operators input to console  */
 	if (sclp_ioctls.echo)
-		sclp_tty_write(sclp_tty, 0, start, count);
+		sclp_tty_write(sclp_tty, start, count);
 
 	/* transfer input to high level driver */
 	sclp_tty_input(start, count);
diff -Nru a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
--- a/drivers/s390/char/sclp_vt220.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/s390/char/sclp_vt220.c	2004-12-24 13:36:33 -08:00
@@ -473,33 +473,9 @@
  * number of characters actually accepted for writing.
  */
 static int
-sclp_vt220_write(struct tty_struct *tty, int from_user,
-		 const unsigned char *buf, int count)
+sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
-	int length;
-	int ret;
-
-	if (!from_user)
-		return __sclp_vt220_write(buf, count, 1, 0);
-	/* Use intermediate buffer to prevent calling copy_from_user() while
-	 * holding a lock. */
-	ret = 0;
-	while (count > 0) {
-		length = count < SCLP_VT220_BUF_SIZE ?
-			 count : SCLP_VT220_BUF_SIZE;
-		length -= copy_from_user(tty->driver_data,
-				(const unsigned char __user *)buf, length);
-		if (length == 0) {
-			if (!ret)
-				return -EFAULT;
-			break;
-		}
-		length = __sclp_vt220_write(tty->driver_data, length, 1, 0);
-		buf += length;
-		count -= length;
-		ret += length;
-	}
-	return ret;
+	return __sclp_vt220_write(buf, count, 1, 0);
 }
 
 #define SCLP_VT220_SESSION_ENDED	0x01
diff -Nru a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
--- a/drivers/s390/char/tape_block.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/s390/char/tape_block.c	2004-12-24 13:37:04 -08:00
@@ -225,8 +225,8 @@
 	if (!blkdat->request_queue)
 		return -ENOMEM;
 
-	elevator_exit(blkdat->request_queue);
-	rc = elevator_init(blkdat->request_queue, &elevator_noop);
+	elevator_exit(blkdat->request_queue->elevator);
+	rc = elevator_init(blkdat->request_queue, "noop");
 	if (rc)
 		goto cleanup_queue;
 
diff -Nru a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
--- a/drivers/s390/char/tty3270.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/s390/char/tty3270.c	2004-12-24 13:36:31 -08:00
@@ -124,16 +124,12 @@
 tty3270_set_timer(struct tty3270 *tp, int expires)
 {
 	if (expires == 0) {
-		if (timer_pending(&tp->timer)) {
+		if (del_timer(&tp->timer))
 			raw3270_put_view(&tp->view);
-			del_timer(&tp->timer);
-		}
 		return;
 	}
-	if (timer_pending(&tp->timer)) {
-		if (mod_timer(&tp->timer, jiffies + expires))
-			return;
-	}
+	if (mod_timer(&tp->timer, jiffies + expires))
+		return;
 	raw3270_get_view(&tp->view);
 	tp->timer.function = (void (*)(unsigned long)) tty3270_update;
 	tp->timer.data = (unsigned long) tp;
@@ -1599,11 +1595,10 @@
  * String write routine for 3270 ttys
  */
 static int
-tty3270_write(struct tty_struct * tty, int from_user,
+tty3270_write(struct tty_struct * tty,
 	      const unsigned char *buf, int count)
 {
 	struct tty3270 *tp;
-	int length, ret;
 
 	tp = tty->driver_data;
 	if (!tp)
@@ -1612,26 +1607,8 @@
 		tty3270_do_write(tp, tp->char_buf, tp->char_count);
 		tp->char_count = 0;
 	}
-	if (!from_user) {
-		tty3270_do_write(tp, buf, count);
-		return count;
-	}
-	ret = 0;
-	while (count > 0) {
-		length = count < TTY3270_CHAR_BUF_SIZE ?
-			count : TTY3270_CHAR_BUF_SIZE;
-		length -= copy_from_user(tp->char_buf, buf, length);
-		if (length == 0) {
-			if (!ret)
-				ret = -EFAULT;
-			break;
-		}
-		tty3270_do_write(tp, tp->char_buf, count);
-		buf += length;
-		count -= length;
-		ret += length;
-	}
-	return ret;
+	tty3270_do_write(tp, buf, count);
+	return count;
 }
 
 /*
diff -Nru a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/s390/char/vmlogrdr.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,920 @@
+/*
+ * drivers/s390/char/vmlogrdr.c
+ *	character device driver for reading z/VM system service records
+ *
+ *
+ *	Copyright (C) 2004 IBM Corporation
+ *	character device driver for reading z/VM system service records,
+ *	Version 1.0
+ *	Author(s): Xenia Tkatschow <xenia@us.ibm.com>
+ *		   Stefan Weinhuber <wein@de.ibm.com>
+ *
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <asm/atomic.h>
+#include <asm/uaccess.h>
+#include <asm/cpcmd.h>
+#include <asm/debug.h>
+#include <asm/ebcdic.h>
+#include "../net/iucv.h"
+#include <linux/kmod.h>
+#include <linux/cdev.h>
+#include <linux/device.h>
+#include <linux/string.h>
+
+
+
+MODULE_AUTHOR
+	("(C) 2004 IBM Corporation by Xenia Tkatschow (xenia@us.ibm.com)\n"
+	 "                            Stefan Weinhuber (wein@de.ibm.com)");
+MODULE_DESCRIPTION ("Character device driver for reading z/VM "
+		    "system service records.");
+MODULE_LICENSE("GPL");
+
+
+/*
+ * The size of the buffer for iucv data transfer is one page,
+ * but in addition to the data we read from iucv we also
+ * place an integer and some characters into that buffer,
+ * so the maximum size for record data is a little less then
+ * one page.
+ */
+#define NET_BUFFER_SIZE	(PAGE_SIZE - sizeof(int) - sizeof(FENCE))
+
+/*
+ * The elements that are concurrently accessed by bottom halves are
+ * connection_established, iucv_path_severed, local_interrupt_buffer
+ * and receive_ready. The first three can be protected by
+ * priv_lock.  receive_ready is atomic, so it can be incremented and
+ * decremented without holding a lock.
+ * The variable dev_in_use needs to be protected by the lock, since
+ * it's a flag used by open to make sure that the device is opened only
+ * by one user at the same time.
+ */
+struct vmlogrdr_priv_t {
+	char system_service[8];
+	char internal_name[8];
+	char recording_name[8];
+	u16 pathid;
+	int connection_established;
+	int iucv_path_severed;
+	iucv_MessagePending local_interrupt_buffer;
+	atomic_t receive_ready;
+	iucv_handle_t iucv_handle;
+	int minor_num;
+	char * buffer;
+	char * current_position;
+	int remaining;
+	ulong residual_length;
+	int buffer_free;
+	int dev_in_use; /* 1: already opened, 0: not opened*/
+	spinlock_t priv_lock;
+	struct device  *device;
+	struct class_device  *class_device;
+	int autorecording;
+	int autopurge;
+};
+
+
+/*
+ * File operation structure for vmlogrdr devices
+ */
+static int vmlogrdr_open(struct inode *, struct file *);
+static int vmlogrdr_release(struct inode *, struct file *);
+static ssize_t vmlogrdr_read (struct file *filp, char *data, size_t count,
+			       loff_t * ppos);
+
+static struct file_operations vmlogrdr_fops = {
+	.owner   = THIS_MODULE,
+	.open    = vmlogrdr_open,
+	.release = vmlogrdr_release,
+	.read    = vmlogrdr_read,
+};
+
+
+static u8 iucvMagic[16] = {
+	0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
+	0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
+};
+
+
+static u8 mask[] = {
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+
+
+static u8 iucv_host[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+
+static void
+vmlogrdr_iucv_ConnectionComplete(iucv_ConnectionComplete *eib, void *pgm_data);
+static void
+vmlogrdr_iucv_ConnectionSevered(iucv_ConnectionSevered *eib, void *pgm_data);
+static void
+vmlogrdr_iucv_MessagePending(iucv_MessagePending *eib, void *pgm_data);
+
+
+static iucv_interrupt_ops_t vmlogrdr_iucvops = {
+	.ConnectionComplete = vmlogrdr_iucv_ConnectionComplete,
+	.ConnectionSevered  = vmlogrdr_iucv_ConnectionSevered,
+	.MessagePending     = vmlogrdr_iucv_MessagePending,
+};
+
+
+DECLARE_WAIT_QUEUE_HEAD(conn_wait_queue);
+DECLARE_WAIT_QUEUE_HEAD(read_wait_queue);
+
+/*
+ * pointer to system service private structure
+ * minor number 0 --> logrec
+ * minor number 1 --> account
+ * minor number 2 --> symptom
+ */
+
+static struct vmlogrdr_priv_t sys_ser[] = {
+	{ .system_service = "*LOGREC ",
+	  .internal_name  = "logrec",
+	  .recording_name = "EREP",
+	  .minor_num      = 0,
+	  .buffer_free    = 1,
+	  .priv_lock      = SPIN_LOCK_UNLOCKED,
+	  .autorecording  = 1,
+	  .autopurge      = 1,
+	},
+	{ .system_service = "*ACCOUNT",
+	  .internal_name  = "account",
+	  .recording_name = "ACCOUNT",
+	  .minor_num      = 1,
+	  .buffer_free    = 1,
+	  .priv_lock      = SPIN_LOCK_UNLOCKED,
+	  .autorecording  = 1,
+	  .autopurge      = 1,
+	},
+	{ .system_service = "*SYMPTOM",
+	  .internal_name  = "symptom",
+	  .recording_name = "SYMPTOM",
+	  .minor_num      = 2,
+	  .buffer_free    = 1,
+	  .priv_lock      = SPIN_LOCK_UNLOCKED,
+	  .autorecording  = 1,
+	  .autopurge      = 1,
+	}
+};
+
+#define MAXMINOR  (sizeof(sys_ser)/sizeof(struct vmlogrdr_priv_t))
+
+static char FENCE[] = {"EOR"};
+static int vmlogrdr_major = 0;
+static struct cdev  *vmlogrdr_cdev = NULL;
+static int recording_class_AB;
+
+
+static void
+vmlogrdr_iucv_ConnectionComplete (iucv_ConnectionComplete * eib,
+				   void * pgm_data)
+{
+	struct vmlogrdr_priv_t * logptr = pgm_data;
+	spin_lock(&logptr->priv_lock);
+	logptr->connection_established = 1;
+	spin_unlock(&logptr->priv_lock);
+	wake_up(&conn_wait_queue);
+	return;
+}
+
+
+static void
+vmlogrdr_iucv_ConnectionSevered (iucv_ConnectionSevered * eib, void * pgm_data)
+{
+	u8 reason = (u8) eib->ipuser[8];
+	struct vmlogrdr_priv_t * logptr = pgm_data;
+
+	printk (KERN_ERR "vmlogrdr: connection severed with"
+		" reason %i\n", reason);
+
+	spin_lock(&logptr->priv_lock);
+	logptr->connection_established = 0;
+	logptr->iucv_path_severed = 1;
+	spin_unlock(&logptr->priv_lock);
+
+	wake_up(&conn_wait_queue);
+	/* just in case we're sleeping waiting for a record */
+	wake_up_interruptible(&read_wait_queue);
+}
+
+
+static void
+vmlogrdr_iucv_MessagePending (iucv_MessagePending * eib, void * pgm_data)
+{
+	struct vmlogrdr_priv_t * logptr = pgm_data;
+
+	/*
+	 * This function is the bottom half so it should be quick.
+	 * Copy the external interrupt data into our local eib and increment
+	 * the usage count
+	 */
+	spin_lock(&logptr->priv_lock);
+	memcpy(&(logptr->local_interrupt_buffer), eib, sizeof(*eib));
+	atomic_inc(&logptr->receive_ready);
+	spin_unlock(&logptr->priv_lock);
+	wake_up_interruptible(&read_wait_queue);
+}
+
+
+static int
+vmlogrdr_get_recording_class_AB(void) {
+	char cp_command[]="QUERY COMMAND RECORDING ";
+	char cp_response[80];
+	char *tail;
+	int len,i;
+
+	printk (KERN_DEBUG "vmlogrdr: query command: %s\n", cp_command);
+	cpcmd(cp_command, cp_response, sizeof(cp_response));
+	printk (KERN_DEBUG "vmlogrdr: response: %s", cp_response);
+	len = strnlen(cp_response,sizeof(cp_response));
+	// now the parsing
+	tail=strnchr(cp_response,len,'=');
+	if (!tail)
+		return 0;
+	tail++;
+	if (!strncmp("ANY",tail,3))
+		return 1;
+	if (!strncmp("NONE",tail,4))
+		return 0;
+	/*
+	 * expect comma separated list of classes here, if one of them
+	 * is A or B return 1 otherwise 0
+	 */
+        for (i=tail-cp_response; i<len; i++)
+		if ( cp_response[i]=='A' || cp_response[i]=='B' )
+			return 1;
+	return 0;
+}
+
+
+static int
+vmlogrdr_recording(struct vmlogrdr_priv_t * logptr, int action, int purge) {
+
+	char cp_command[80];
+	char cp_response[160];
+	char *onoff, *qid_string;
+
+	memset(cp_command, 0x00, sizeof(cp_command));
+	memset(cp_response, 0x00, sizeof(cp_response));
+
+        onoff = ((action == 1) ? "ON" : "OFF");
+	qid_string = ((recording_class_AB == 1) ? " QID * " : "");
+
+        /*
+	 * The recording commands needs to be called with option QID
+	 * for guests that have previlege classes A or B.
+	 * Purging has to be done as separate step, because recording
+	 * can't be switched on as long as records are on the queue.
+	 * Doing both at the same time doesn't work.
+	 */
+
+	if (purge) {
+		snprintf(cp_command, sizeof(cp_command),
+			 "RECORDING %s PURGE %s",
+			 logptr->recording_name,
+			 qid_string);
+
+		printk (KERN_DEBUG "vmlogrdr: recording command: %s\n",
+			cp_command);
+		cpcmd(cp_command, cp_response, sizeof(cp_response));
+		printk (KERN_DEBUG "vmlogrdr: recording response: %s",
+			cp_response);
+	}
+
+	memset(cp_command, 0x00, sizeof(cp_command));
+	memset(cp_response, 0x00, sizeof(cp_response));
+	snprintf(cp_command, sizeof(cp_command), "RECORDING %s %s %s",
+		logptr->recording_name,
+		onoff,
+		qid_string);
+
+	printk (KERN_DEBUG "vmlogrdr: recording command: %s\n", cp_command);
+	cpcmd(cp_command, cp_response, sizeof(cp_response));
+	printk (KERN_DEBUG "vmlogrdr: recording response: %s",
+		cp_response);
+	/* The recording command will usually answer with 'Command complete'
+	 * on success, but when the specific service was never connected
+	 * before then there might be an additional informational message
+	 * 'HCPCRC8072I Recording entry not found' before the
+         * 'Command complete'. So I use strstr rather then the strncmp.
+	 */
+	if (strstr(cp_response,"Command complete"))
+		return 0;
+	else
+		return -EIO;
+
+}
+
+
+static int
+vmlogrdr_open (struct inode *inode, struct file *filp)
+{
+	int dev_num = 0;
+	struct vmlogrdr_priv_t * logptr = NULL;
+	int connect_rc = 0;
+	int ret;
+
+	dev_num = iminor(inode);
+	if (dev_num > MAXMINOR)
+		return -ENODEV;
+
+	logptr = &sys_ser[dev_num];
+	if (logptr == NULL)
+		return -ENODEV;
+
+	/*
+	 * only allow for blocking reads to be open
+	 */
+	if (filp->f_flags & O_NONBLOCK)
+		return -ENOSYS;
+
+	/* Besure this device hasn't already been opened */
+	spin_lock_bh(&logptr->priv_lock);
+	if (logptr->dev_in_use)	{
+		spin_unlock_bh(&logptr->priv_lock);
+		return -EBUSY;
+	} else {
+		logptr->dev_in_use = 1;
+		spin_unlock_bh(&logptr->priv_lock);
+	}
+
+	atomic_set(&logptr->receive_ready, 0);
+	logptr->buffer_free = 1;
+
+	/* set the file options */
+	filp->private_data = logptr;
+	filp->f_op = &vmlogrdr_fops;
+
+	/* start recording for this service*/
+	ret=0;
+	if (logptr->autorecording)
+		ret = vmlogrdr_recording(logptr,1,logptr->autopurge);
+	if (ret)
+		printk (KERN_WARNING "vmlogrdr: failed to start "
+			"recording automatically\n");
+
+	/* Register with iucv driver */
+	logptr->iucv_handle = iucv_register_program(iucvMagic,
+			logptr->system_service, mask, &vmlogrdr_iucvops,
+			logptr);
+
+	if (logptr->iucv_handle == NULL) {
+		printk (KERN_ERR "vmlogrdr: failed to register with"
+			"iucv driver\n");
+		goto not_registered;
+	}
+
+	/* create connection to the system service */
+	spin_lock_bh(&logptr->priv_lock);
+	logptr->connection_established = 0;
+	logptr->iucv_path_severed = 0;
+	spin_unlock_bh(&logptr->priv_lock);
+
+	connect_rc = iucv_connect (&(logptr->pathid), 10, iucvMagic,
+					logptr->system_service, iucv_host, 0,
+					NULL, NULL,
+					logptr->iucv_handle, NULL);
+	if (connect_rc) {
+		printk (KERN_ERR "vmlogrdr: iucv connection to %s "
+			"failed with rc %i \n", logptr->system_service,
+			connect_rc);
+		goto not_connected;
+	}
+
+	/* We've issued the connect and now we must wait for a
+	 * ConnectionComplete or ConnectinSevered Interrupt
+	 * before we can continue to process.
+	 */
+	wait_event(conn_wait_queue, (logptr->connection_established)
+		   || (logptr->iucv_path_severed));
+	if (logptr->iucv_path_severed) {
+		goto not_connected;
+	}
+
+	return 0;
+
+not_connected:
+	iucv_unregister_program(logptr->iucv_handle);
+	logptr->iucv_handle = NULL;
+not_registered:
+	if (logptr->autorecording)
+		vmlogrdr_recording(logptr,0,logptr->autopurge);
+	logptr->dev_in_use = 0;
+	return -EIO;
+
+
+}
+
+
+static int
+vmlogrdr_release (struct inode *inode, struct file *filp)
+{
+	int ret;
+
+	struct vmlogrdr_priv_t * logptr = filp->private_data;
+
+	iucv_unregister_program(logptr->iucv_handle);
+	logptr->iucv_handle = NULL;
+
+	if (logptr->autorecording) {
+		ret = vmlogrdr_recording(logptr,0,logptr->autopurge);
+		if (ret)
+			printk (KERN_WARNING "vmlogrdr: failed to stop "
+				"recording automatically\n");
+	}
+	logptr->dev_in_use = 0;
+
+	return 0;
+}
+
+
+static int
+vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) {
+	int rc, *temp;
+	/* we need to keep track of two data sizes here:
+	 * The number of bytes we need to receive from iucv and
+	 * the total number of bytes we actually write into the buffer.
+	 */
+	int user_data_count, iucv_data_count;
+	char * buffer;
+
+	if (atomic_read(&priv->receive_ready)) {
+		spin_lock_bh(&priv->priv_lock);
+		if (priv->residual_length){
+			/* receive second half of a record */
+			iucv_data_count = priv->residual_length;
+			user_data_count = 0;
+			buffer = priv->buffer;
+		} else {
+			/* receive a new record:
+			 * We need to return the total length of the record
+                         * + size of FENCE in the first 4 bytes of the buffer.
+		         */
+			iucv_data_count =
+				priv->local_interrupt_buffer.ln1msg2.ipbfln1f;
+			user_data_count = sizeof(int);
+			temp = (int*)priv->buffer;
+			*temp= iucv_data_count + sizeof(FENCE);
+			buffer = priv->buffer + sizeof(int);
+		}
+		/*
+		 * If the record is bigger then our buffer, we receive only
+		 * a part of it. We can get the rest later.
+		 */
+		if (iucv_data_count > NET_BUFFER_SIZE)
+			iucv_data_count = NET_BUFFER_SIZE;
+		rc = iucv_receive(priv->pathid,
+				  priv->local_interrupt_buffer.ipmsgid,
+				  priv->local_interrupt_buffer.iptrgcls,
+				  buffer,
+				  iucv_data_count,
+				  NULL,
+				  NULL,
+				  &priv->residual_length);
+		spin_unlock_bh(&priv->priv_lock);
+		/* An rc of 5 indicates that the record was bigger then
+		 * the buffer, which is OK for us. A 9 indicates that the
+		 * record was purged befor we could receive it.
+		 */
+		if (rc == 5)
+			rc = 0;
+		if (rc == 9)
+			atomic_set(&priv->receive_ready, 0);
+	} else {
+		rc = 1;
+	}
+	if (!rc) {
+		priv->buffer_free = 0;
+ 		user_data_count += iucv_data_count;
+		priv->current_position = priv->buffer;
+		if (priv->residual_length == 0){
+			/* the whole record has been captured,
+			 * now add the fence */
+			atomic_dec(&priv->receive_ready);
+			buffer = priv->buffer + user_data_count;
+			memcpy(buffer, FENCE, sizeof(FENCE));
+			user_data_count += sizeof(FENCE);
+		}
+		priv->remaining = user_data_count;
+	}
+
+	return rc;
+}
+
+
+static ssize_t
+vmlogrdr_read (struct file *filp, char *data, size_t count, loff_t * ppos)
+{
+	int rc;
+	struct vmlogrdr_priv_t * priv = filp->private_data;
+
+	while (priv->buffer_free) {
+		rc = vmlogrdr_receive_data(priv);
+		if (rc) {
+			rc = wait_event_interruptible(read_wait_queue,
+					atomic_read(&priv->receive_ready));
+			if (rc)
+				return rc;
+		}
+	}
+	/* copy only up to end of record */
+	if (count > priv->remaining)
+		count = priv->remaining;
+
+	if (copy_to_user(data, priv->current_position, count))
+		return -EFAULT;
+
+	*ppos += count;
+	priv->current_position += count;
+	priv->remaining -= count;
+
+	/* if all data has been transferred, set buffer free */
+	if (priv->remaining == 0)
+		priv->buffer_free = 1;
+
+	return count;
+}
+
+static ssize_t
+vmlogrdr_autopurge_store(struct device * dev, const char * buf, size_t count) {
+	struct vmlogrdr_priv_t *priv = dev->driver_data;
+	ssize_t ret = count;
+
+	switch (buf[0]) {
+	case '0':
+		priv->autopurge=0;
+		break;
+	case '1':
+		priv->autopurge=1;
+		break;
+	default:
+		ret = -EINVAL;
+	}
+	return ret;
+}
+
+
+static ssize_t
+vmlogrdr_autopurge_show(struct device *dev, char *buf) {
+	struct vmlogrdr_priv_t *priv = dev->driver_data;
+	return sprintf(buf, "%u\n", priv->autopurge);
+}
+
+
+static DEVICE_ATTR(autopurge, 0644, vmlogrdr_autopurge_show,
+		   vmlogrdr_autopurge_store);
+
+
+static ssize_t
+vmlogrdr_purge_store(struct device * dev, const char * buf, size_t count) {
+
+	char cp_command[80];
+	char cp_response[80];
+	struct vmlogrdr_priv_t *priv = dev->driver_data;
+
+	if (buf[0] != '1')
+		return -EINVAL;
+
+	memset(cp_command, 0x00, sizeof(cp_command));
+	memset(cp_response, 0x00, sizeof(cp_response));
+
+        /*
+	 * The recording command needs to be called with option QID
+	 * for guests that have previlege classes A or B.
+	 * Other guests will not recognize the command and we have to
+	 * issue the same command without the QID parameter.
+	 */
+
+	if (recording_class_AB)
+		snprintf(cp_command, sizeof(cp_command),
+			 "RECORDING %s PURGE QID * ",
+			 priv->recording_name);
+	else
+		snprintf(cp_command, sizeof(cp_command),
+			 "RECORDING %s PURGE ",
+			 priv->recording_name);
+
+	printk (KERN_DEBUG "vmlogrdr: recording command: %s\n", cp_command);
+	cpcmd(cp_command, cp_response, sizeof(cp_response));
+	printk (KERN_DEBUG "vmlogrdr: recording response: %s",
+		cp_response);
+
+	return count;
+}
+
+
+static DEVICE_ATTR(purge, 0200, NULL, vmlogrdr_purge_store);
+
+
+static ssize_t
+vmlogrdr_autorecording_store(struct device *dev, const char *buf,
+			     size_t count) {
+	struct vmlogrdr_priv_t *priv = dev->driver_data;
+	ssize_t ret = count;
+
+	switch (buf[0]) {
+	case '0':
+		priv->autorecording=0;
+		break;
+	case '1':
+		priv->autorecording=1;
+		break;
+	default:
+		ret = -EINVAL;
+	}
+	return ret;
+}
+
+
+static ssize_t
+vmlogrdr_autorecording_show(struct device *dev, char *buf) {
+	struct vmlogrdr_priv_t *priv = dev->driver_data;
+	return sprintf(buf, "%u\n", priv->autorecording);
+}
+
+
+static DEVICE_ATTR(autorecording, 0644, vmlogrdr_autorecording_show,
+		   vmlogrdr_autorecording_store);
+
+
+static ssize_t
+vmlogrdr_recording_store(struct device * dev, const char * buf, size_t count) {
+
+	struct vmlogrdr_priv_t *priv = dev->driver_data;
+	ssize_t ret;
+
+	switch (buf[0]) {
+	case '0':
+		ret = vmlogrdr_recording(priv,0,0);
+		break;
+	case '1':
+		ret = vmlogrdr_recording(priv,1,0);
+		break;
+	default:
+		ret = -EINVAL;
+	}
+	if (ret)
+		return ret;
+	else
+		return count;
+
+}
+
+
+static DEVICE_ATTR(recording, 0200, NULL, vmlogrdr_recording_store);
+
+
+static ssize_t
+vmlogrdr_recording_status_show(struct device_driver *driver, char *buf) {
+
+	char cp_command[] = "QUERY RECORDING ";
+	int len;
+
+	cpcmd(cp_command, buf, 4096);
+	len = strlen(buf);
+	return len;
+}
+
+
+static DRIVER_ATTR(recording_status, 0444, vmlogrdr_recording_status_show,
+		   NULL);
+
+static struct attribute *vmlogrdr_attrs[] = {
+	&dev_attr_autopurge.attr,
+	&dev_attr_purge.attr,
+	&dev_attr_autorecording.attr,
+	&dev_attr_recording.attr,
+	NULL,
+};
+
+static struct attribute_group vmlogrdr_attr_group = {
+	.attrs = vmlogrdr_attrs,
+};
+
+static struct class_simple *vmlogrdr_class;
+static struct device_driver vmlogrdr_driver = {
+	.name = "vmlogrdr",
+	.bus  = &iucv_bus,
+};
+
+
+static int
+vmlogrdr_register_driver(void) {
+	int ret;
+
+	ret = driver_register(&vmlogrdr_driver);
+	if (ret) {
+		printk(KERN_ERR "vmlogrdr: failed to register driver.\n");
+		return ret;
+	}
+
+	ret = driver_create_file(&vmlogrdr_driver,
+				 &driver_attr_recording_status);
+	if (ret) {
+		printk(KERN_ERR "vmlogrdr: failed to add driver attribute.\n");
+		goto unregdriver;
+	}
+
+	vmlogrdr_class = class_simple_create(THIS_MODULE, "vmlogrdr");
+	if (IS_ERR(vmlogrdr_class)) {
+		printk(KERN_ERR "vmlogrdr: failed to create class.\n");
+		ret=PTR_ERR(vmlogrdr_class);
+		vmlogrdr_class=NULL;
+		goto unregattr;
+	}
+	return 0;
+
+unregattr:
+	driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status);
+unregdriver:
+	driver_unregister(&vmlogrdr_driver);
+	return ret;
+}
+
+
+static void
+vmlogrdr_unregister_driver(void) {
+	class_simple_destroy(vmlogrdr_class);
+	vmlogrdr_class = NULL;
+	driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status);
+	driver_unregister(&vmlogrdr_driver);
+	return;
+}
+
+
+static int
+vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
+	struct device *dev;
+	int ret;
+
+	dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+	if (dev) {
+		memset(dev, 0, sizeof(struct device));
+		snprintf(dev->bus_id, BUS_ID_SIZE, "%s",
+			 priv->internal_name);
+		dev->bus = &iucv_bus;
+		dev->parent = iucv_root;
+		dev->driver = &vmlogrdr_driver;
+		/*
+		 * The release function could be called after the
+		 * module has been unloaded. It's _only_ task is to
+		 * free the struct. Therefore, we specify kfree()
+		 * directly here. (Probably a little bit obfuscating
+		 * but legitime ...).
+		 */
+		dev->release = (void (*)(struct device *))kfree;
+	} else
+		return -ENOMEM;
+	ret = device_register(dev);
+	if (ret)
+		return ret;
+
+	ret = sysfs_create_group(&dev->kobj, &vmlogrdr_attr_group);
+	if (ret) {
+		device_unregister(dev);
+		return ret;
+	}
+	priv->class_device = class_simple_device_add(
+				vmlogrdr_class,
+				MKDEV(vmlogrdr_major, priv->minor_num),
+				dev,
+				"%s", dev->bus_id );
+	if (IS_ERR(priv->class_device)) {
+		ret = PTR_ERR(priv->class_device);
+		priv->class_device=NULL;
+		sysfs_remove_group(&dev->kobj, &vmlogrdr_attr_group);
+		device_unregister(dev);
+		return ret;
+	}
+	dev->driver_data = priv;
+	priv->device = dev;
+	return 0;
+}
+
+
+static int
+vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv ) {
+	class_simple_device_remove(MKDEV(vmlogrdr_major, priv->minor_num));
+	if (priv->device != NULL) {
+		sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group);
+		device_unregister(priv->device);
+		priv->device=NULL;
+	}
+	return 0;
+}
+
+
+static int
+vmlogrdr_register_cdev(dev_t dev) {
+	int rc = 0;
+	vmlogrdr_cdev = cdev_alloc();
+	if (!vmlogrdr_cdev) {
+		return -ENOMEM;
+	}
+	vmlogrdr_cdev->owner = THIS_MODULE;
+	vmlogrdr_cdev->ops = &vmlogrdr_fops;
+	vmlogrdr_cdev->dev = dev;
+	rc = cdev_add(vmlogrdr_cdev, vmlogrdr_cdev->dev, MAXMINOR);
+	if (!rc)
+		return 0;
+
+	// cleanup: cdev is not fully registered, no cdev_del here!
+	kobject_put(&vmlogrdr_cdev->kobj);
+	vmlogrdr_cdev=NULL;
+	return rc;
+}
+
+
+static void
+vmlogrdr_cleanup(void) {
+        int i;
+	if (vmlogrdr_cdev) {
+		cdev_del(vmlogrdr_cdev);
+		vmlogrdr_cdev=NULL;
+	}
+	for (i=0; i < MAXMINOR; ++i ) {
+		vmlogrdr_unregister_device(&sys_ser[i]);
+		free_page((unsigned long)sys_ser[i].buffer);
+	}
+	vmlogrdr_unregister_driver();
+	if (vmlogrdr_major) {
+		unregister_chrdev_region(MKDEV(vmlogrdr_major, 0), MAXMINOR);
+		vmlogrdr_major=0;
+	}
+}
+
+
+static int
+vmlogrdr_init(void)
+{
+	int rc;
+	int i;
+	dev_t dev;
+
+	if (! MACHINE_IS_VM) {
+		printk (KERN_ERR "vmlogrdr: not running under VM, "
+				"driver not loaded.\n");
+		return -ENODEV;
+	}
+
+        recording_class_AB = vmlogrdr_get_recording_class_AB();
+
+	rc = alloc_chrdev_region(&dev, 0, MAXMINOR, "vmlogrdr");
+	if (rc)
+		return rc;
+	vmlogrdr_major = MAJOR(dev);
+
+	rc=vmlogrdr_register_driver();
+	if (rc)
+		goto cleanup;
+
+	for (i=0; i < MAXMINOR; ++i ) {
+		sys_ser[i].buffer = (char *) get_zeroed_page(GFP_KERNEL);
+		if (!sys_ser[i].buffer) {
+			rc = ENOMEM;
+			break;
+		}
+		sys_ser[i].current_position = sys_ser[i].buffer;
+		rc=vmlogrdr_register_device(&sys_ser[i]);
+		if (rc)
+			break;
+	}
+	if (rc)
+		goto cleanup;
+
+	rc = vmlogrdr_register_cdev(dev);
+	if (rc)
+		goto cleanup;
+	printk (KERN_INFO "vmlogrdr: driver loaded\n");
+	return 0;
+
+cleanup:
+	vmlogrdr_cleanup();
+	printk (KERN_ERR "vmlogrdr: driver not loaded.\n");
+	return rc;
+}
+
+
+static void
+vmlogrdr_exit(void)
+{
+	vmlogrdr_cleanup();
+	printk (KERN_INFO "vmlogrdr: driver unloaded\n");
+	return;
+}
+
+
+module_init(vmlogrdr_init);
+module_exit(vmlogrdr_exit);
diff -Nru a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/s390/char/vmwatchdog.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,292 @@
+/*
+ * Watchdog implementation based on z/VM Watchdog Timer API
+ *
+ * The user space watchdog daemon can use this driver as
+ * /dev/vmwatchdog to have z/VM execute the specified CP
+ * command when the timeout expires. The default command is
+ * "IPL", which which cause an immediate reboot.
+ */
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/watchdog.h>
+
+#include <asm/ebcdic.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+
+#define MAX_CMDLEN 240
+#define MIN_INTERVAL 15
+static char vmwdt_cmd[MAX_CMDLEN] = "IPL";
+static int vmwdt_conceal;
+
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
+static int vmwdt_nowayout = 1;
+#else
+static int vmwdt_nowayout = 0;
+#endif
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
+MODULE_DESCRIPTION("z/VM Watchdog Timer");
+module_param_string(cmd, vmwdt_cmd, MAX_CMDLEN, 0644);
+MODULE_PARM_DESC(cmd, "CP command that is run when the watchdog triggers");
+module_param_named(conceal, vmwdt_conceal, bool, 0644);
+MODULE_PARM_DESC(conceal, "Enable the CONCEAL CP option while the watchdog "
+		" is active");
+module_param_named(nowayout, vmwdt_nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"
+		" (default=CONFIG_WATCHDOG_NOWAYOUT)");
+MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+
+static unsigned int vmwdt_interval = 60;
+static unsigned long vmwdt_is_open;
+static int vmwdt_expect_close;
+
+enum vmwdt_func {
+	/* function codes */
+	wdt_init   = 0,
+	wdt_change = 1,
+	wdt_cancel = 2,
+	/* flags */
+	wdt_conceal = 0x80000000,
+};
+
+static int __diag288(enum vmwdt_func func, unsigned int timeout,
+			    char *cmd, size_t len)
+{
+	register unsigned long __func asm("2");
+	register unsigned long __timeout asm("3");
+	register unsigned long __cmdp asm("4");
+	register unsigned long __cmdl asm("5");
+	int err;
+
+	__func = func;
+	__timeout = timeout;
+	__cmdp = virt_to_phys(cmd);
+	__cmdl = len;
+	err = 0;
+	asm volatile (
+#ifdef __s390x__
+		       "diag %2,%4,0x288\n"
+		"1:	\n"
+		".section .fixup,\"ax\"\n"
+		"2:	lghi %0,%1\n"
+		"	jg 1b\n"
+		".previous\n"
+		".section __ex_table,\"a\"\n"
+		"	.align 8\n"
+		"	.quad 1b,2b\n"
+		".previous\n"
+#else
+		       "diag %2,%4,0x288\n"
+		"1:	\n"
+		".section .fixup,\"ax\"\n"
+		"2:	lhi %0,%1\n"
+		"	bras 1,3f\n"
+		"	.long 1b\n"
+		"3:	l 1,0(1)\n"
+		"	br 1\n"
+		".previous\n"
+		".section __ex_table,\"a\"\n"
+		"	.align 4\n"
+		"	.long 1b,2b\n"
+		".previous\n"
+#endif
+		: "+&d"(err)
+		: "i"(-EINVAL), "d"(__func), "d"(__timeout),
+		  "d"(__cmdp), "d"(__cmdl)
+		: "1", "cc");
+	return err;
+}
+
+static int vmwdt_keepalive(void)
+{
+	/* we allocate new memory every time to avoid having
+	 * to track the state. static allocation is not an
+	 * option since that might not be contiguous in real
+	 * storage in case of a modular build */
+	static char *ebc_cmd;
+	size_t len;
+	int ret;
+	unsigned int func;
+
+	ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL);
+	if (!ebc_cmd)
+		return -ENOMEM;
+
+	len = strlcpy(ebc_cmd, vmwdt_cmd, MAX_CMDLEN);
+	ASCEBC(ebc_cmd, MAX_CMDLEN);
+	EBC_TOUPPER(ebc_cmd, MAX_CMDLEN);
+
+	func = vmwdt_conceal ? (wdt_init | wdt_conceal) : wdt_init;
+	ret = __diag288(func, vmwdt_interval, ebc_cmd, len);
+	kfree(ebc_cmd);
+
+	if (ret) {
+		printk(KERN_WARNING "%s: problem setting interval %d, "
+			"cmd %s\n", __FUNCTION__, vmwdt_interval,
+			vmwdt_cmd);
+	}
+	return ret;
+}
+
+static int vmwdt_disable(void)
+{
+	int ret = __diag288(wdt_cancel, 0, "", 0);
+	if (ret) {
+		printk(KERN_WARNING "%s: problem disabling watchdog\n",
+			__FUNCTION__);
+	}
+	return ret;
+}
+
+static int __init vmwdt_probe(void)
+{
+	/* there is no real way to see if the watchdog is supported,
+	 * so we try initializing it with a NOP command ("BEGIN")
+	 * that won't cause any harm even if the following disable
+	 * fails for some reason */
+	static char __initdata ebc_begin[] = {
+		194, 197, 199, 201, 213
+	};
+	if (__diag288(wdt_init, 15, ebc_begin, sizeof(ebc_begin)) != 0) {
+		printk(KERN_INFO "z/VM watchdog not available\n");
+		return -EINVAL;
+	}
+	return vmwdt_disable();
+}
+
+static int vmwdt_open(struct inode *i, struct file *f)
+{
+	int ret;
+	if (test_and_set_bit(0, &vmwdt_is_open))
+		return -EBUSY;
+	ret = vmwdt_keepalive();
+	if (ret)
+		clear_bit(0, &vmwdt_is_open);
+	return ret ? ret : nonseekable_open(i, f);
+}
+
+static int vmwdt_close(struct inode *i, struct file *f)
+{
+	if (vmwdt_expect_close == 42)
+		vmwdt_disable();
+	vmwdt_expect_close = 0;
+	clear_bit(0, &vmwdt_is_open);
+	return 0;
+}
+
+static struct watchdog_info vmwdt_info = {
+	.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
+	.firmware_version = 0,
+	.identity = "z/VM Watchdog Timer",
+};
+
+static int vmwdt_ioctl(struct inode *i, struct file *f,
+			  unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case WDIOC_GETSUPPORT:
+		if (copy_to_user((void __user *)arg, &vmwdt_info,
+					sizeof(vmwdt_info)))
+			return -EFAULT;
+		return 0;
+	case WDIOC_GETSTATUS:
+	case WDIOC_GETBOOTSTATUS:
+		return put_user(0, (int *)arg);
+	case WDIOC_GETTEMP:
+		return -EINVAL;
+	case WDIOC_SETOPTIONS:
+		{
+			int options, ret;
+			if (get_user(options, (int __user *)arg))
+				return -EFAULT;
+			ret = -EINVAL;
+			if (options & WDIOS_DISABLECARD) {
+				ret = vmwdt_disable();
+				if (ret)
+					return ret;
+			}
+			if (options & WDIOS_ENABLECARD) {
+				ret = vmwdt_keepalive();
+			}
+			return ret;
+		}
+	case WDIOC_GETTIMEOUT:
+		return put_user(vmwdt_interval, (int __user *)arg);
+	case WDIOC_SETTIMEOUT:
+		{
+			int interval;
+			if (get_user(interval, (int __user *)arg))
+				return -EFAULT;
+			if (interval < MIN_INTERVAL)
+				return -EINVAL;
+			vmwdt_interval = interval;
+		}
+		return vmwdt_keepalive();
+	case WDIOC_KEEPALIVE:
+		return vmwdt_keepalive();
+	}
+
+	return -EINVAL;
+}
+
+static ssize_t vmwdt_write(struct file *f, const char __user *buf,
+				size_t count, loff_t *ppos)
+{
+	if(count) {
+		if (!vmwdt_nowayout) {
+			size_t i;
+
+			/* note: just in case someone wrote the magic character
+			 * five months ago... */
+			vmwdt_expect_close = 0;
+
+			for (i = 0; i != count; i++) {
+				char c;
+				if (get_user(c, buf+i))
+					return -EFAULT;
+				if (c == 'V')
+					vmwdt_expect_close = 42;
+			}
+		}
+		/* someone wrote to us, we should restart timer */
+		vmwdt_keepalive();
+	}
+	return count;
+}
+
+static struct file_operations vmwdt_fops = {
+	.open    = &vmwdt_open,
+	.release = &vmwdt_close,
+	.ioctl   = &vmwdt_ioctl,
+	.write   = &vmwdt_write,
+	.owner   = THIS_MODULE,
+};
+
+static struct miscdevice vmwdt_dev = {
+	.minor      = WATCHDOG_MINOR,
+	.name       = "watchdog",
+	.fops       = &vmwdt_fops,
+};
+
+static int __init vmwdt_init(void)
+{
+	int ret;
+
+	ret = vmwdt_probe();
+	if (ret)
+		return ret;
+	return misc_register(&vmwdt_dev);
+}
+module_init(vmwdt_init);
+
+static void __exit vmwdt_exit(void)
+{
+	WARN_ON(misc_deregister(&vmwdt_dev) != 0);
+}
+module_exit(vmwdt_exit);
diff -Nru a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
--- a/drivers/s390/cio/css.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/s390/cio/css.c	2004-12-24 13:37:43 -08:00
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/css.c
  *  driver for channel subsystem
- *   $Revision: 1.82 $
+ *   $Revision: 1.84 $
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *			 IBM Corporation
@@ -188,6 +188,12 @@
 			put_device(&sch->dev);
 		return 0; /* Already processed. */
 	}
+	/*
+	 * We've got a machine check, so running I/O won't get an interrupt.
+	 * Kill any pending timers.
+	 */
+	if (sch)
+		device_kill_pending_timer(sch);
 	if (!disc && !slow) {
 		if (sch)
 			put_device(&sch->dev);
diff -Nru a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
--- a/drivers/s390/cio/css.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/s390/cio/css.h	2004-12-24 13:37:43 -08:00
@@ -66,6 +66,7 @@
 struct ccw_device_private {
 	int state;		/* device state */
 	atomic_t onoff;
+	unsigned long registered;
 	__u16 devno;		/* device number */
 	__u16 irq;		/* subchannel number */
 	__u8 imask;		/* lpm mask for SNID/SID/SPGID */
@@ -136,6 +137,9 @@
 
 /* Helper functions for vary on/off. */
 void device_set_waiting(struct subchannel *);
+
+/* Machine check helper function. */
+void device_kill_pending_timer(struct subchannel *);
 
 /* Helper functions to build lists for the slow path. */
 int css_enqueue_subchannel_slow(unsigned long schid);
diff -Nru a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
--- a/drivers/s390/cio/device.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/s390/cio/device.c	2004-12-24 13:37:04 -08:00
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/device.c
  *  bus driver for ccw devices
- *   $Revision: 1.124 $
+ *   $Revision: 1.129 $
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *			 IBM Corporation
@@ -68,9 +68,6 @@
 	if (!cdev)
 		return -ENODEV;
 
-	if (cdev->private->state == DEV_STATE_NOT_OPER)
-		return -ENODEV;
-
 	/* what we want to pass to /sbin/hotplug */
 
 	envp[i++] = buffer;
@@ -501,9 +498,11 @@
 	if ((ret = device_add(dev)))
 		return ret;
 
-	if ((ret = device_add_files(dev)))
-		device_del(dev);
-
+	set_bit(1, &cdev->private->registered);
+	if ((ret = device_add_files(dev))) {
+		if (test_and_clear_bit(1, &cdev->private->registered))
+			device_del(dev);
+	}
 	return ret;
 }
 
@@ -526,8 +525,7 @@
 		cdev = to_ccwdev(dev);
 		if ((cdev->private->state == DEV_STATE_DISCONNECTED) &&
 		    (cdev->private->devno == devno) &&
-		    (!strncmp(cdev->dev.bus_id, sibling->dev.bus_id,
-			      BUS_ID_SIZE))) {
+		    (cdev != sibling)) {
 			cdev->private->state = DEV_STATE_NOT_OPER;
 			break;
 		}
@@ -540,6 +538,24 @@
 	return cdev;
 }
 
+static void
+ccw_device_add_changed(void *data)
+{
+
+	struct ccw_device *cdev;
+
+	cdev = (struct ccw_device *)data;
+	if (device_add(&cdev->dev)) {
+		put_device(&cdev->dev);
+		return;
+	}
+	set_bit(1, &cdev->private->registered);
+	if (device_add_files(&cdev->dev)) {
+		if (test_and_clear_bit(1, &cdev->private->registered))
+			device_unregister(&cdev->dev);
+	}
+}
+
 extern int css_get_ssd_info(struct subchannel *sch);
 
 void
@@ -589,16 +605,14 @@
 	} else
 		need_rename = 0;
 	device_remove_files(&cdev->dev);
-	device_del(&cdev->dev);
+	if (test_and_clear_bit(1, &cdev->private->registered))
+		device_del(&cdev->dev);
 	if (need_rename)
 		snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.0.%04x",
 			  sch->schib.pmcw.dev);
-	if (device_add(&cdev->dev)) {
-		put_device(&cdev->dev);
-		return;
-	}
-	if (device_add_files(&cdev->dev))
-		device_unregister(&cdev->dev);
+	PREPARE_WORK(&cdev->private->kick_work,
+		     ccw_device_add_changed, (void *)cdev);
+	queue_work(ccw_device_work, &cdev->private->kick_work);
 }
 
 static void
@@ -620,6 +634,7 @@
 	struct ccw_device *cdev;
 	struct subchannel *sch;
 	int ret;
+	unsigned long flags;
 
 	cdev = (struct ccw_device *) data;
 	sch = to_subchannel(cdev->dev.parent);
@@ -634,10 +649,14 @@
 		printk (KERN_WARNING "%s: could not register %s\n",
 			__func__, cdev->dev.bus_id);
 		put_device(&cdev->dev);
-		sch->dev.driver_data = 0;
+		spin_lock_irqsave(&sch->lock, flags);
+		sch->dev.driver_data = NULL;
+		spin_unlock_irqrestore(&sch->lock, flags);
 		kfree (cdev->private);
 		kfree (cdev);
 		put_device(&sch->dev);
+		if (atomic_dec_and_test(&ccw_device_init_count))
+			wake_up(&ccw_device_init_wq);
 		return;
 	}
 
@@ -650,6 +669,8 @@
 	cdev->private->flags.recog_done = 1;
 	put_device(&sch->dev);
 	wake_up(&cdev->private->wait_q);
+	if (atomic_dec_and_test(&ccw_device_init_count))
+		wake_up(&ccw_device_init_wq);
 }
 
 void
@@ -686,9 +707,11 @@
 		if (!get_device(&cdev->dev))
 			break;
 		sch = to_subchannel(cdev->dev.parent);
-		INIT_WORK(&cdev->private->kick_work,
-			  ccw_device_call_sch_unregister, (void *) cdev);
+		PREPARE_WORK(&cdev->private->kick_work,
+			     ccw_device_call_sch_unregister, (void *) cdev);
 		queue_work(slow_path_wq, &cdev->private->kick_work);
+		if (atomic_dec_and_test(&ccw_device_init_count))
+			wake_up(&ccw_device_init_wq);
 		break;
 	case DEV_STATE_BOXED:
 		/* Device did not respond in time. */
@@ -699,13 +722,11 @@
 		 */
 		if (!get_device(&cdev->dev))
 			break;
-		INIT_WORK(&cdev->private->kick_work,
-			  io_subchannel_register, (void *) cdev);
-		queue_work(ccw_device_work, &cdev->private->kick_work);
+		PREPARE_WORK(&cdev->private->kick_work,
+			     io_subchannel_register, (void *) cdev);
+		queue_work(slow_path_wq, &cdev->private->kick_work);
 		break;
 	}
-	if (atomic_dec_and_test(&ccw_device_init_count))
-		wake_up(&ccw_device_init_wq);
 }
 
 static int
@@ -750,6 +771,7 @@
 	struct subchannel *sch;
 	struct ccw_device *cdev;
 	int rc;
+	unsigned long flags;
 
 	sch = to_subchannel(pdev);
 	if (sch->dev.driver_data) {
@@ -790,6 +812,7 @@
 		.parent = pdev,
 		.release = ccw_device_release,
 	};
+	INIT_LIST_HEAD(&cdev->private->kick_work.entry);
 	/* Do first half of device_register. */
 	device_initialize(&cdev->dev);
 
@@ -801,7 +824,9 @@
 
 	rc = io_subchannel_recog(cdev, to_subchannel(pdev));
 	if (rc) {
-		sch->dev.driver_data = 0;
+		spin_lock_irqsave(&sch->lock, flags);
+		sch->dev.driver_data = NULL;
+		spin_unlock_irqrestore(&sch->lock, flags);
 		if (cdev->dev.release)
 			cdev->dev.release(&cdev->dev);
 	}
@@ -809,24 +834,40 @@
 	return rc;
 }
 
+static void
+ccw_device_unregister(void *data)
+{
+	struct ccw_device *cdev;
+
+	cdev = (struct ccw_device *)data;
+	if (test_and_clear_bit(1, &cdev->private->registered))
+		device_unregister(&cdev->dev);
+	put_device(&cdev->dev);
+}
+
 static int
 io_subchannel_remove (struct device *dev)
 {
 	struct ccw_device *cdev;
+	unsigned long flags;
 
 	if (!dev->driver_data)
 		return 0;
 	cdev = dev->driver_data;
 	/* Set ccw device to not operational and drop reference. */
+	spin_lock_irqsave(cdev->ccwlock, flags);
+	dev->driver_data = NULL;
 	cdev->private->state = DEV_STATE_NOT_OPER;
+	spin_unlock_irqrestore(cdev->ccwlock, flags);
 	/*
-	 * Careful here. Our ccw device might be yet unregistered when
-	 * de-registering its subchannel (machine check during device
-	 * recognition). Better look if the subchannel has children.
+	 * Put unregistration on workqueue to avoid livelocks on the css bus
+	 * semaphore.
 	 */
-	if (!list_empty(&dev->children))
-		device_unregister(&cdev->dev);
-	dev->driver_data = NULL;
+	if (get_device(&cdev->dev)) {
+		PREPARE_WORK(&cdev->private->kick_work,
+			     ccw_device_unregister, (void *) cdev);
+		queue_work(ccw_device_work, &cdev->private->kick_work);
+	}
 	return 0;
 }
 
diff -Nru a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
--- a/drivers/s390/cio/device_fsm.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/s390/cio/device_fsm.c	2004-12-24 13:36:55 -08:00
@@ -93,6 +93,18 @@
 	add_timer(&cdev->private->timer);
 }
 
+/* Kill any pending timers after machine check. */
+void
+device_kill_pending_timer(struct subchannel *sch)
+{
+	struct ccw_device *cdev;
+
+	if (!sch->dev.driver_data)
+		return;
+	cdev = sch->dev.driver_data;
+	ccw_device_set_timeout(cdev, 0);
+}
+
 /*
  * Cancel running i/o. This is called repeatedly since halt/clear are
  * asynchronous operations. We do one try with cio_cancel, two tries
@@ -142,7 +154,7 @@
 	panic("Can't stop i/o on subchannel.\n");
 }
 
-static void
+static int
 ccw_device_handle_oper(struct ccw_device *cdev)
 {
 	struct subchannel *sch;
@@ -162,9 +174,10 @@
 		PREPARE_WORK(&cdev->private->kick_work,
 			     ccw_device_do_unreg_rereg, (void *)cdev);
 		queue_work(ccw_device_work, &cdev->private->kick_work);
-		return;
+		return 0;
 	}
 	cdev->private->flags.donotify = 1;
+	return 1;
 }
 
 /*
@@ -194,7 +207,7 @@
 ccw_device_recog_done(struct ccw_device *cdev, int state)
 {
 	struct subchannel *sch;
-	int notify, old_lpm;
+	int notify, old_lpm, same_dev;
 
 	sch = to_subchannel(cdev->dev.parent);
 
@@ -224,6 +237,7 @@
 		/* Boxed devices don't need extra treatment. */
 	}
 	notify = 0;
+	same_dev = 0; /* Keep the compiler quiet... */
 	switch (state) {
 	case DEV_STATE_NOT_OPER:
 		CIO_DEBUG(KERN_WARNING, 2,
@@ -232,7 +246,7 @@
 		break;
 	case DEV_STATE_OFFLINE:
 		if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) {
-			ccw_device_handle_oper(cdev);
+			same_dev = ccw_device_handle_oper(cdev);
 			notify = 1;
 		}
 		/* fill out sense information */
@@ -243,10 +257,12 @@
 			.dev_model = cdev->private->senseid.dev_model,
 		};
 		if (notify) {
-			/* Get device online again. */
 			cdev->private->state = DEV_STATE_OFFLINE;
-			ccw_device_online(cdev);
-			wake_up(&cdev->private->wait_q);
+			if (same_dev) {
+				/* Get device online again. */
+				ccw_device_online(cdev);
+				wake_up(&cdev->private->wait_q);
+			}
 			return;
 		}
 		/* Issue device info message. */
@@ -452,7 +468,8 @@
 					     (void *)cdev);
 				queue_work(ccw_device_work,
 					   &cdev->private->kick_work);
-			}
+			} else
+				put_device(&sch->dev);
 		}
 	} else {
 		cio_disable_subchannel(sch);
@@ -1190,8 +1207,8 @@
 
 	CIO_TRACE_EVENT (3, "IRQ");
 	CIO_TRACE_EVENT (3, pdev->bus_id);
-
-	dev_fsm_event(cdev, DEV_EVENT_INTERRUPT);
+	if (cdev)
+		dev_fsm_event(cdev, DEV_EVENT_INTERRUPT);
 }
 
 EXPORT_SYMBOL_GPL(ccw_device_set_timeout);
diff -Nru a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
--- a/drivers/s390/cio/qdio.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/s390/cio/qdio.c	2004-12-24 13:37:00 -08:00
@@ -56,7 +56,7 @@
 #include "ioasm.h"
 #include "chsc.h"
 
-#define VERSION_QDIO_C "$Revision: 1.86 $"
+#define VERSION_QDIO_C "$Revision: 1.93 $"
 
 /****************** MODULE PARAMETER VARIABLES ********************/
 MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
@@ -605,8 +605,8 @@
 			sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no,
 				atomic_read(&q->busy_siga_counter));
 			QDIO_DBF_TEXT3(0,trace,dbf_text);
-			q->timing.busy_start=0;
 #endif /* CONFIG_QDIO_DEBUG */
+			q->timing.busy_start=0;
 			break;
 		case (2|QDIO_SIGA_ERROR_B_BIT_SET):
 			/* cc=2 and busy bit: */
@@ -808,7 +808,7 @@
 #endif /* QDIO_USE_PROCESSING_STATE */
 		/* 
 		 * not needed, as the inbound queue will be synced on the next
-		 * siga-r
+		 * siga-r, resp. tiqdio_is_inbound_q_done will do the siga-s
 		 */
 		/*SYNC_MEMORY;*/
 		f++;
@@ -899,7 +899,7 @@
 
 /* means, no more buffers to be filled */
 inline static int
-iqdio_is_inbound_q_done(struct qdio_q *q)
+tiqdio_is_inbound_q_done(struct qdio_q *q)
 {
 	int no_used;
 #ifdef CONFIG_QDIO_DEBUG
@@ -1139,7 +1139,7 @@
 		goto out;
 
 	qdio_kick_inbound_handler(q);
-	if (iqdio_is_inbound_q_done(q))
+	if (tiqdio_is_inbound_q_done(q))
 		if (!qdio_stop_polling(q)) {
 			/* 
 			 * we set the flags to get into the stuff next time,
@@ -2088,7 +2088,10 @@
 		u32 kc:4;
 		u32 reserved4:21;
 		u32 isc:3;
-		u32 reserved5[2];
+		u32 word_with_d_bit;
+		/* set to 0x10000000 to enable
+		 * time delay disablement facility */
+		u32 reserved5;
 		u32 subsystem_id;
 		u32 reserved6[1004];
 		struct chsc_header response;
@@ -2126,6 +2129,12 @@
 	scssc_area->kc = QDIO_STORAGE_KEY;
 	scssc_area->isc = TIQDIO_THININT_ISC;
 	scssc_area->subsystem_id = (1<<16) + irq_ptr->irq;
+	/* enables the time delay disablement facility. Don't care
+	 * whether it is really there (i.e. we haven't checked for
+	 * it) */
+	scssc_area->word_with_d_bit = 0x10000000;
+
+
 
 	result = chsc(scssc_area);
 	if (result) {
@@ -2620,6 +2629,7 @@
 
 	init_MUTEX(&irq_ptr->setting_up_sema);
 
+	/* QDR must be in DMA area since CCW data address is only 32 bit */
 	irq_ptr->qdr=kmalloc(sizeof(struct qdr), GFP_KERNEL | GFP_DMA);
   	if (!(irq_ptr->qdr)) {
    		kfree(irq_ptr);
diff -Nru a/drivers/s390/crypto/Makefile b/drivers/s390/crypto/Makefile
--- a/drivers/s390/crypto/Makefile	2004-12-24 13:36:47 -08:00
+++ b/drivers/s390/crypto/Makefile	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,5 @@
 #
-# S/390 miscellaneous devices
+# S/390 crypto devices
 #
 
 z90crypt-objs := z90main.o z90hardware.o
diff -Nru a/drivers/s390/crypto/z90common.h b/drivers/s390/crypto/z90common.h
--- a/drivers/s390/crypto/z90common.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/s390/crypto/z90common.h	2004-12-24 13:37:31 -08:00
@@ -1,11 +1,11 @@
 /*
- *  linux/drivers/s390/misc/z90common.h
+ *  linux/drivers/s390/crypto/z90common.h
  *
- *  z90crypt 1.3.1
+ *  z90crypt 1.3.2
  *
  *  Copyright (C)  2001, 2004 IBM Corporation
  *  Author(s): Robert Burroughs (burrough@us.ibm.com)
- *	       Eric Rossman (edrossma@us.ibm.com)
+ *             Eric Rossman (edrossma@us.ibm.com)
  *
  *  Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  *
@@ -16,7 +16,7 @@
  *
  * 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
+ * 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
@@ -24,15 +24,16 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifndef _Z90COMMON_
-#define _Z90COMMON_
+#ifndef _Z90COMMON_H_
+#define _Z90COMMON_H_
 
-#define VERSION_Z90COMMON_H "$Revision: 1.8 $"
+#define VERSION_Z90COMMON_H "$Revision: 1.16 $"
 
 
 #define RESPBUFFSIZE 256
 #define PCI_FUNC_KEY_DECRYPT 0x5044
 #define PCI_FUNC_KEY_ENCRYPT 0x504B
+extern int ext_bitlens;
 
 enum devstat {
 	DEV_GONE,
@@ -56,6 +57,7 @@
 	HD_TSQ_EXCEPTION
 };
 
+#define Z90C_NO_DEVICES		1
 #define Z90C_AMBIGUOUS_DOMAIN	2
 #define Z90C_INCORRECT_DOMAIN	3
 #define ENOTINIT		4
@@ -74,13 +76,13 @@
 #define REC_OPERAND_SIZE 9
 #define REC_EVEN_MOD	10
 #define REC_NO_WORK	11
-#define REC_HARDWAR_ERR 12
-#define REC_NO_RESPONSE 13
+#define REC_HARDWAR_ERR	12
+#define REC_NO_RESPONSE	13
 #define REC_RETRY_DEV	14
 #define REC_USER_GONE	15
-#define REC_BAD_MESSAGE 16
-#define REC_INVALID_PAD 17
-#define REC_RELEASED	28
+#define REC_BAD_MESSAGE	16
+#define REC_INVALID_PAD	17
+#define REC_USE_PCICA	18
 
 #define WRONG_DEVICE_TYPE 20
 
@@ -89,18 +91,55 @@
 #define TSQ_FATAL_ERROR 34
 #define RSQ_FATAL_ERROR 35
 
-#define PCICA	0
-#define PCICC	1
-#define PCIXCC	2
-#define NILDEV	-1
-#define ANYDEV	-1
+#define Z90CRYPT_NUM_TYPES	5
+#define PCICA		0
+#define PCICC		1
+#define PCIXCC_MCL2	2
+#define PCIXCC_MCL3	3
+#define CEX2C		4
+#define NILDEV		-1
+#define ANYDEV		-1
+#define PCIXCC_UNK	-2
 
 enum hdevice_type {
 	PCICC_HW  = 3,
 	PCICA_HW  = 4,
 	PCIXCC_HW = 5,
 	OTHER_HW  = 6,
-	OTHER2_HW = 7
+	CEX2C_HW  = 7
+};
+
+struct CPRBX {
+	unsigned short cprb_len;
+	unsigned char  cprb_ver_id;
+	unsigned char  pad_000[3];
+	unsigned char  func_id[2];
+	unsigned char  cprb_flags[4];
+	unsigned int   req_parml;
+	unsigned int   req_datal;
+	unsigned int   rpl_msgbl;
+	unsigned int   rpld_parml;
+	unsigned int   rpl_datal;
+	unsigned int   rpld_datal;
+	unsigned int   req_extbl;
+	unsigned char  pad_001[4];
+	unsigned int   rpld_extbl;
+	unsigned char  req_parmb[16];
+	unsigned char  req_datab[16];
+	unsigned char  rpl_parmb[16];
+	unsigned char  rpl_datab[16];
+	unsigned char  req_extb[16];
+	unsigned char  rpl_extb[16];
+	unsigned short ccp_rtcode;
+	unsigned short ccp_rscode;
+	unsigned int   mac_data_len;
+	unsigned char  logon_id[8];
+	unsigned char  mac_value[8];
+	unsigned char  mac_content_flgs;
+	unsigned char  pad_002;
+	unsigned short domain;
+	unsigned char  pad_003[12];
+	unsigned char  pad_004[36];
 };
 
 #ifndef DEV_NAME
diff -Nru a/drivers/s390/crypto/z90crypt.h b/drivers/s390/crypto/z90crypt.h
--- a/drivers/s390/crypto/z90crypt.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/s390/crypto/z90crypt.h	2004-12-24 13:36:31 -08:00
@@ -1,11 +1,11 @@
 /*
- *  linux/drivers/s390/misc/z90crypt.h
+ *  linux/drivers/s390/crypto/z90crypt.h
  *
- *  z90crypt 1.3.1
+ *  z90crypt 1.3.2
  *
  *  Copyright (C)  2001, 2004 IBM Corporation
  *  Author(s): Robert Burroughs (burrough@us.ibm.com)
- *	       Eric Rossman (edrossma@us.ibm.com)
+ *             Eric Rossman (edrossma@us.ibm.com)
  *
  *  Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  *
@@ -16,7 +16,7 @@
  *
  * 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
+ * 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
@@ -24,16 +24,25 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifndef _LINUX_Z90CRYPT_H_
-#define _LINUX_Z90CRYPT_H_
+#ifndef _Z90CRYPT_H_
+#define _Z90CRYPT_H_
 
 #include <linux/ioctl.h>
 
-#define VERSION_Z90CRYPT_H "$Revision: 1.2 $"
+#define VERSION_Z90CRYPT_H "$Revision: 1.11 $"
 
 #define z90crypt_VERSION 1
 #define z90crypt_RELEASE 3	// 2 = PCIXCC, 3 = rewrite for coding standards
-#define z90crypt_VARIANT 1
+#define z90crypt_VARIANT 2	// 2 = added PCIXCC MCL3 and CEX2C support
+
+/**
+ * If we are not using the sparse checker, __user has no use.
+ */
+#ifdef __CHECKER__
+# define __user		__attribute__((noderef, address_space(1)))
+#else
+# define __user
+#endif
 
 /**
  * struct ica_rsa_modexpo
@@ -93,16 +102,16 @@
  *     This takes an ica_rsa_modexpo struct as its arg.
  *
  *     NOTE: please refer to the comments preceding this structure
- *	     for the implementation details for the contents of the
- *	     block
+ *           for the implementation details for the contents of the
+ *           block
  *
  *   ICARSACRT
  *     Perform an RSA operation using a Chinese-Remainder Theorem key
  *     This takes an ica_rsa_modexpo_crt struct as its arg.
  *
  *     NOTE: please refer to the comments preceding this structure
- *	     for the implementation details for the contents of the
- *	     block
+ *           for the implementation details for the contents of the
+ *           block
  *
  *   Z90STAT_TOTALCOUNT
  *     Return an integer count of all device types together.
@@ -113,8 +122,14 @@
  *   Z90STAT_PCICCCOUNT
  *     Return an integer count of all PCICCs.
  *
- *   Z90STAT_PCIXCCCOUNT
- *     Return an integer count of all PCIXCCs.
+ *   Z90STAT_PCIXCCMCL2COUNT
+ *     Return an integer count of all MCL2 PCIXCCs.
+ *
+ *   Z90STAT_PCIXCCMCL3COUNT
+ *     Return an integer count of all MCL3 PCIXCCs.
+ *
+ *   Z90STAT_CEX2CCOUNT
+ *     Return an integer count of all CEX2Cs.
  *
  *   Z90STAT_REQUESTQ_COUNT
  *     Return an integer count of the number of entries waiting to be
@@ -133,10 +148,12 @@
  *   Z90STAT_STATUS_MASK
  *     Return an 64 element array of unsigned chars for the status of
  *     all devices.
- *	 0x01: PCICA
- *	 0x02: PCICC
- *	 0x03: PCIXCC
- *	 0x0d: device is disabled via the proc filesystem
+ *       0x01: PCICA
+ *       0x02: PCICC
+ *       0x03: PCIXCC_MCL2
+ *       0x04: PCIXCC_MCL3
+ *       0x05: CEX2C
+ *       0x0d: device is disabled via the proc filesystem
  *
  *   Z90STAT_QDEPTH_MASK
  *     Return an 64 element array of unsigned chars for the queue
@@ -152,18 +169,23 @@
  *     This takes an ica_z90_status struct as its arg.
  *
  *     NOTE: this ioctl() is deprecated, and has been replaced with
- *	     single ioctl()s for each type of status being requested
+ *           single ioctl()s for each type of status being requested
+ *
+ *   Z90STAT_PCIXCCCOUNT (deprecated)
+ *     Return an integer count of all PCIXCCs (MCL2 + MCL3).
+ *     This is DEPRECATED now that MCL3 PCIXCCs are treated differently from
+ *     MCL2 PCIXCCs.
  *
  *   Z90QUIESCE (not recommended)
  *     Quiesce the driver.  This is intended to stop all new
- *     requests from being processed.  Its use is not recommended,
+ *     requests from being processed.  Its use is NOT recommended,
  *     except in circumstances where there is no other way to stop
  *     callers from accessing the driver.  Its original use was to
  *     allow the driver to be "drained" of work in preparation for
  *     a system shutdown.
  *
  *     NOTE: once issued, this ban on new work cannot be undone
- *	     except by unloading and reloading the driver.
+ *           except by unloading and reloading the driver.
  */
 
 /**
@@ -172,8 +194,9 @@
 #define ICARSAMODEXPO	_IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x05, 0)
 #define ICARSACRT	_IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x06, 0)
 
-/* DEPRECATED status call (bound for removal SOON) */
+/* DEPRECATED status calls (bound for removal at some point) */
 #define ICAZ90STATUS	_IOR(Z90_IOCTL_MAGIC, 0x10, struct ica_z90_status)
+#define Z90STAT_PCIXCCCOUNT	_IOR(Z90_IOCTL_MAGIC, 0x43, int)
 
 /* unrelated to ICA callers */
 #define Z90QUIESCE	_IO(Z90_IOCTL_MAGIC, 0x11)
@@ -182,7 +205,9 @@
 #define Z90STAT_TOTALCOUNT	_IOR(Z90_IOCTL_MAGIC, 0x40, int)
 #define Z90STAT_PCICACOUNT	_IOR(Z90_IOCTL_MAGIC, 0x41, int)
 #define Z90STAT_PCICCCOUNT	_IOR(Z90_IOCTL_MAGIC, 0x42, int)
-#define Z90STAT_PCIXCCCOUNT	_IOR(Z90_IOCTL_MAGIC, 0x43, int)
+#define Z90STAT_PCIXCCMCL2COUNT	_IOR(Z90_IOCTL_MAGIC, 0x4b, int)
+#define Z90STAT_PCIXCCMCL3COUNT	_IOR(Z90_IOCTL_MAGIC, 0x4c, int)
+#define Z90STAT_CEX2CCOUNT	_IOR(Z90_IOCTL_MAGIC, 0x4d, int)
 #define Z90STAT_REQUESTQ_COUNT	_IOR(Z90_IOCTL_MAGIC, 0x44, int)
 #define Z90STAT_PENDINGQ_COUNT	_IOR(Z90_IOCTL_MAGIC, 0x45, int)
 #define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int)
@@ -199,8 +224,9 @@
 #define ERELEASED 131	// user released while ioctl pending
 #define EQUIESCE  132	// z90crypt quiescing (no more work allowed)
 #define ETIMEOUT  133	// request timed out
-#define EUNKNOWN  134	// some unrecognized error occured
-#define EGETBUFF  135	// Error getting buffer
+#define EUNKNOWN  134	// some unrecognized error occured (retry may succeed)
+#define EGETBUFF  135	// Error getting buffer or hardware lacks capability
+			// (retry in software)
 
 /**
  * DEPRECATED STRUCTURES
@@ -222,10 +248,11 @@
 	int pendingqWaitCount;
 	int totalOpenCount;
 	int cryptoDomain;
-	// status: 0=not there. 1=PCICA. 2=PCICC. 3=PCIXCC
+	// status: 0=not there, 1=PCICA, 2=PCICC, 3=PCIXCC_MCL2, 4=PCIXCC_MCL3,
+	//         5=CEX2C
 	unsigned char status[MASK_LENGTH];
 	// qdepth: # work elements waiting for each device
 	unsigned char qdepth[MASK_LENGTH];
 };
 
-#endif /* _LINUX_Z90CRYPT_H_ */
+#endif /* _Z90CRYPT_H_ */
diff -Nru a/drivers/s390/crypto/z90hardware.c b/drivers/s390/crypto/z90hardware.c
--- a/drivers/s390/crypto/z90hardware.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/s390/crypto/z90hardware.c	2004-12-24 13:36:17 -08:00
@@ -1,11 +1,11 @@
 /*
- *  linux/drivers/s390/misc/z90hardware.c
+ *  linux/drivers/s390/crypto/z90hardware.c
  *
- *  z90crypt 1.3.1
+ *  z90crypt 1.3.2
  *
  *  Copyright (C)  2001, 2004 IBM Corporation
  *  Author(s): Robert Burroughs (burrough@us.ibm.com)
- *	       Eric Rossman (edrossma@us.ibm.com)
+ *             Eric Rossman (edrossma@us.ibm.com)
  *
  *  Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  *
@@ -16,7 +16,7 @@
  *
  * 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
+ * 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
@@ -32,9 +32,9 @@
 #include "z90crypt.h"
 #include "z90common.h"
 
-#define VERSION_Z90HARDWARE_C "$Revision: 1.19 $"
+#define VERSION_Z90HARDWARE_C "$Revision: 1.33 $"
 
-char z90chardware_version[] __initdata =
+char z90hardware_version[] __initdata =
 	"z90hardware.o (" VERSION_Z90HARDWARE_C "/"
 	                  VERSION_Z90COMMON_H "/" VERSION_Z90CRYPT_H ")";
 
@@ -224,7 +224,7 @@
 	unsigned char right[4];
 	unsigned char reserved3[2];
 	unsigned char reserved4[2];
-	unsigned char pfs[4];
+	unsigned char apfs[4];
 	unsigned int  offset1;
 	unsigned int  offset2;
 	unsigned int  offset3;
@@ -278,39 +278,6 @@
 	unsigned char svr_name[8];
 };
 
-struct CPRBX {
-	unsigned short cprb_len;
-	unsigned char  cprb_ver_id;
-	unsigned char  pad_000[3];
-	unsigned char  func_id[2];
-	unsigned char  cprb_flags[4];
-	unsigned int   req_parml;
-	unsigned int   req_datal;
-	unsigned int   rpl_msgbl;
-	unsigned int   rpld_parml;
-	unsigned int   rpl_datal;
-	unsigned int   rpld_datal;
-	unsigned int   req_extbl;
-	unsigned char  pad_001[4];
-	unsigned int   rpld_extbl;
-	unsigned char  req_parmb[16];
-	unsigned char  req_datab[16];
-	unsigned char  rpl_parmb[16];
-	unsigned char  rpl_datab[16];
-	unsigned char  req_extb[16];
-	unsigned char  rpl_extb[16];
-	unsigned short ccp_rtcode;
-	unsigned short ccp_rscode;
-	unsigned int   mac_data_len;
-	unsigned char  logon_id[8];
-	unsigned char  mac_value[8];
-	unsigned char  mac_content_flgs;
-	unsigned char  pad_002;
-	unsigned short domain;
-	unsigned char  pad_003[12];
-	unsigned char  pad_004[36];
-};
-
 struct type6_msg {
 	struct type6_hdr header;
 	struct CPRB	 CPRB;
@@ -347,12 +314,13 @@
 #define REPLY_ERROR_FORMAT_FIELD     0x29
 #define REPLY_ERROR_INVALID_COMMAND  0x30
 #define REPLY_ERROR_MALFORMED_MSG    0x40
-#define REPLY_ERROR_RESERVED_FIELD   0x50
+#define REPLY_ERROR_RESERVED_FIELDO  0x50
 #define REPLY_ERROR_WORD_ALIGNMENT   0x60
 #define REPLY_ERROR_MESSAGE_LENGTH   0x80
 #define REPLY_ERROR_OPERAND_INVALID  0x82
 #define REPLY_ERROR_OPERAND_SIZE     0x84
 #define REPLY_ERROR_EVEN_MOD_IN_OPND 0x85
+#define REPLY_ERROR_RESERVED_FIELD   0x88
 #define REPLY_ERROR_TRANSPORT_FAIL   0x90
 #define REPLY_ERROR_PACKET_TRUNCATED 0xA0
 #define REPLY_ERROR_ZERO_BUFFER_LEN  0xB0
@@ -379,7 +347,7 @@
 	unsigned int	  offset2;
 	unsigned int	  count3;
 	unsigned int	  offset3;
-	unsigned int	  ount4;
+	unsigned int	  count4;
 	unsigned int	  offset4;
 };
 
@@ -546,18 +514,30 @@
 	 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
 };
 
-static struct function_and_rules_block static_pkd_function_and_rulesX = {
+static struct function_and_rules_block static_pkd_function_and_rulesX_MCL2 = {
 	{0x50,0x44},
 	{0x00,0x0A},
 	{'P','K','C','S','-','1','.','2'}
 };
 
-static struct function_and_rules_block static_pke_function_and_rulesX = {
+static struct function_and_rules_block static_pke_function_and_rulesX_MCL2 = {
 	{0x50,0x4B},
 	{0x00,0x0A},
 	{'Z','E','R','O','-','P','A','D'}
 };
 
+static struct function_and_rules_block static_pkd_function_and_rulesX = {
+	{0x50,0x44},
+	{0x00,0x0A},
+	{'Z','E','R','O','-','P','A','D'}
+};
+
+static struct function_and_rules_block static_pke_function_and_rulesX = {
+	{0x50,0x4B},
+	{0x00,0x0A},
+	{'M','R','P',' ',' ',' ',' ',' '}
+};
+
 struct T6_keyBlock_hdrX {
 	unsigned short blen;
 	unsigned short ulen;
@@ -701,11 +681,9 @@
 
 #define FIXED_TYPE6_CR_LENX 0x000001E3
 
-#ifndef MAX_RESPONSE_SIZE
 #define MAX_RESPONSE_SIZE 0x00000710
 
 #define MAX_RESPONSEX_SIZE 0x0000077C
-#endif
 
 #define RESPONSE_CPRB_SIZE  0x000006B8
 #define RESPONSE_CPRBX_SIZE 0x00000724
@@ -1063,7 +1041,6 @@
 			*q_depth = t_depth + 1;
 			switch (t_dev_type) {
 			case OTHER_HW:
-			case OTHER2_HW:
 				stat = HD_NOT_THERE;
 				*dev_type = NILDEV;
 				break;
@@ -1074,7 +1051,10 @@
 				*dev_type = PCICC;
 				break;
 			case PCIXCC_HW:
-				*dev_type = PCIXCC;
+				*dev_type = PCIXCC_UNK;
+				break;
+			case CEX2C_HW:
+				*dev_type = CEX2C;
 				break;
 			default:
 				*dev_type = NILDEV;
@@ -1133,6 +1113,7 @@
 		default:
 			stat = HD_NOT_THERE;
 			break_out = 1;
+			break;
 		}
 		if (break_out)
 			break;
@@ -1170,18 +1151,11 @@
 			switch (stat_word.response_code) {
 			case AP_RESPONSE_NORMAL:
 				stat = DEV_ONLINE;
-				if (stat_word.q_stat_flags &
-				    AP_Q_STATUS_EMPTY)
+				if (stat_word.q_stat_flags & AP_Q_STATUS_EMPTY)
 					break_out = 1;
 				break;
 			case AP_RESPONSE_Q_NOT_AVAIL:
-				stat = DEV_GONE;
-				break_out = 1;
-				break;
 			case AP_RESPONSE_DECONFIGURED:
-				stat = DEV_GONE;
-				break_out = 1;
-				break;
 			case AP_RESPONSE_CHECKSTOPPED:
 				stat = DEV_GONE;
 				break_out = 1;
@@ -1195,6 +1169,7 @@
 		default:
 			stat = DEV_GONE;
 			break_out = 1;
+			break;
 		}
 		if (break_out == 1)
 			break;
@@ -1251,7 +1226,7 @@
 	       msg_ext[0], msg_ext[1], msg_ext[2], msg_ext[3],
 	       msg_ext[4], msg_ext[5], msg_ext[6], msg_ext[7],
 	       msg_ext[8], msg_ext[9], msg_ext[10], msg_ext[11]);
-	print_buffer(msg_ext+12, msg_len);
+	print_buffer(msg_ext+CALLER_HEADER, msg_len);
 #endif
 
 	ccode = sen(msg_len, msg_ext, &stat_word);
@@ -1283,14 +1258,15 @@
 		break;
 	default:
 		stat = DEV_GONE;
+		break;
 	}
 
 	return stat;
 }
 
 enum devstat
-receive_from_AP(int dev_nr, int cdx, int resplen,
-		unsigned char *resp, unsigned char *psmid)
+receive_from_AP(int dev_nr, int cdx, int resplen, unsigned char *resp,
+		unsigned char *psmid)
 {
 	int ccode;
 	struct ap_status_word stat_word;
@@ -1543,6 +1519,7 @@
 	struct type6_hdr *tp6Hdr_p;
 	struct CPRB *cprb_p;
 	struct cca_private_ext_ME *key_p;
+	static int deprecated_msg_count = 0;
 
 	mod_len = icaMsg_p->inputdatalength;
 	tmp_size = FIXED_TYPE6_ME_LEN + mod_len;
@@ -1593,13 +1570,19 @@
 		return SEN_USER_ERROR;
 
 	if (is_common_public_key(temp, mod_len)) {
-		PRINTK("Common public key used for modex decrypt\n");
+		if (deprecated_msg_count < 20) {
+			PRINTK("Common public key used for modex decrypt\n");
+			deprecated_msg_count++;
+			if (deprecated_msg_count == 20)
+				PRINTK("No longer issuing messages about common"
+				       " public key for modex decrypt.\n");
+		}
 		return SEN_NOT_AVAIL;
 	}
 
 	temp = key_p->pvtMESec.modulus + sizeof(key_p->pvtMESec.modulus)
 	       - mod_len;
-	if (copy_from_user(temp, icaMsg_p->n_modulus, mod_len) != 0)
+	if (copy_from_user(temp, icaMsg_p->n_modulus, mod_len))
 		return SEN_RELEASED;
 	if (is_empty(temp, mod_len))
 		return SEN_USER_ERROR;
@@ -1617,24 +1600,33 @@
 {
 	int mod_len, vud_len, exp_len, key_len;
 	int pad_len, tmp_size, total_CPRB_len, parmBlock_l, i;
-	unsigned char temp_exp[256], *exp_p, *temp;
+	unsigned char *temp_exp, *exp_p, *temp;
 	struct type6_hdr *tp6Hdr_p;
 	struct CPRB *cprb_p;
 	struct cca_public_key *key_p;
 	struct T6_keyBlock_hdr *keyb_p;
 
+	temp_exp = kmalloc(256, GFP_KERNEL);
+	if (!temp_exp)
+		return EGETBUFF;
 	mod_len = icaMsg_p->inputdatalength;
-	if (copy_from_user(temp_exp, icaMsg_p->b_key, mod_len))
+	if (copy_from_user(temp_exp, icaMsg_p->b_key, mod_len)) {
+		kfree(temp_exp);
 		return SEN_RELEASED;
-	if (is_empty(temp_exp, mod_len))
+	}
+	if (is_empty(temp_exp, mod_len)) {
+		kfree(temp_exp);
 		return SEN_USER_ERROR;
+	}
 
 	exp_p = temp_exp;
 	for (i = 0; i < mod_len; i++)
 		if (exp_p[i])
 			break;
-	if (i >= mod_len)
+	if (i >= mod_len) {
+		kfree(temp_exp);
 		return SEN_USER_ERROR;
+	}
 
 	exp_len = mod_len - i;
 	exp_p += i;
@@ -1665,17 +1657,25 @@
 		 sizeof(struct function_and_rules_block));
 	temp += sizeof(struct function_and_rules_block);
 	temp += 2;
-	if (copy_from_user(temp, icaMsg_p->inputdata, mod_len))
+	if (copy_from_user(temp, icaMsg_p->inputdata, mod_len)) {
+		kfree(temp_exp);
 		return SEN_RELEASED;
-	if (is_empty(temp, mod_len))
+	}
+	if (is_empty(temp, mod_len)) {
+		kfree(temp_exp);
 		return SEN_USER_ERROR;
-	if (temp[0] != 0x00 || temp[1] != 0x02)
+	}
+	if ((temp[0] != 0x00) || (temp[1] != 0x02)) {
+		kfree(temp_exp);
 		return SEN_NOT_AVAIL;
+	}
 	for (i = 2; i < mod_len; i++)
 		if (temp[i] == 0x00)
 			break;
-	if ((i < 9) || (i > (mod_len - 2)))
+	if ((i < 9) || (i > (mod_len - 2))) {
+		kfree(temp_exp);
 		return SEN_NOT_AVAIL;
+	}
 	pad_len = i + 1;
 	vud_len = mod_len - pad_len;
 	memmove(temp, temp+pad_len, vud_len);
@@ -1689,6 +1689,7 @@
 	key_p = (struct cca_public_key *)temp;
 	temp = key_p->pubSec.exponent;
 	memcpy(temp, exp_p, exp_len);
+	kfree(temp_exp);
 	temp += exp_len;
 	if (copy_from_user(temp, icaMsg_p->n_modulus, mod_len))
 		return SEN_RELEASED;
@@ -1697,7 +1698,7 @@
 	key_p->pubSec.modulus_bit_len = 8 * mod_len;
 	key_p->pubSec.modulus_byte_len = mod_len;
 	key_p->pubSec.exponent_len = exp_len;
-	key_p->pubSec.section_length = 12 + mod_len + exp_len;
+	key_p->pubSec.section_length = CALLER_HEADER + mod_len + exp_len;
 	key_len = key_p->pubSec.section_length + sizeof(struct cca_token_hdr);
 	key_p->pubHdr.token_length = key_len;
 	key_len += 4;
@@ -1824,27 +1825,37 @@
 
 static int
 ICAMEX_msg_to_type6MEX_msgX(struct ica_rsa_modexpo *icaMsg_p, int cdx,
-			    int *z90cMsg_l_p, struct type6_msg *z90cMsg_p)
+			    int *z90cMsg_l_p, struct type6_msg *z90cMsg_p,
+			    int dev_type)
 {
 	int mod_len, exp_len, vud_len, tmp_size, total_CPRB_len, parmBlock_l;
 	int key_len, i;
-	unsigned char temp_exp[256], *tgt_p, *temp, *exp_p;
+	unsigned char *temp_exp, *tgt_p, *temp, *exp_p;
 	struct type6_hdr *tp6Hdr_p;
 	struct CPRBX *cprbx_p;
 	struct cca_public_key *key_p;
 	struct T6_keyBlock_hdrX *keyb_p;
 
+	temp_exp = kmalloc(256, GFP_KERNEL);
+	if (!temp_exp)
+		return EGETBUFF;
 	mod_len = icaMsg_p->inputdatalength;
-	if (copy_from_user(temp_exp, icaMsg_p->b_key, mod_len))
+	if (copy_from_user(temp_exp, icaMsg_p->b_key, mod_len)) {
+		kfree(temp_exp);
 		return SEN_RELEASED;
-	if (is_empty(temp_exp, mod_len))
+	}
+	if (is_empty(temp_exp, mod_len)) {
+		kfree(temp_exp);
 		return SEN_USER_ERROR;
+	}
 	exp_p = temp_exp;
 	for (i = 0; i < mod_len; i++)
 		if (exp_p[i])
 			break;
-	if (i >= mod_len)
+	if (i >= mod_len) {
+		kfree(temp_exp);
 		return SEN_USER_ERROR;
+	}
 	exp_len = mod_len - i;
 	exp_p += i;
 	PDEBUG("exp_len after computation: %08x\n", exp_len);
@@ -1867,15 +1878,23 @@
 	cprbx_p->domain = (unsigned short)cdx;
 	cprbx_p->rpl_msgbl = RESPONSE_CPRBX_SIZE;
 	tgt_p += sizeof(struct CPRBX);
-	memcpy(tgt_p, &static_pke_function_and_rulesX,
-	       sizeof(struct function_and_rules_block));
+	if (dev_type == PCIXCC_MCL2)
+		memcpy(tgt_p, &static_pke_function_and_rulesX_MCL2,
+		       sizeof(struct function_and_rules_block));
+	else
+		memcpy(tgt_p, &static_pke_function_and_rulesX,
+		       sizeof(struct function_and_rules_block));
 	tgt_p += sizeof(struct function_and_rules_block);
 
 	tgt_p += 2;
-	if (copy_from_user(tgt_p, icaMsg_p->inputdata, mod_len))
-	      return SEN_RELEASED;
-	if (is_empty(tgt_p, mod_len))
-	      return SEN_USER_ERROR;
+	if (copy_from_user(tgt_p, icaMsg_p->inputdata, mod_len)) {
+		kfree(temp_exp);
+		return SEN_RELEASED;
+	}
+	if (is_empty(tgt_p, mod_len)) {
+		kfree(temp_exp);
+		return SEN_USER_ERROR;
+	}
 	tgt_p -= 2;
 	*((short *)tgt_p) = (short) vud_len;
 	tgt_p += vud_len;
@@ -1885,15 +1904,16 @@
 	key_p = (struct cca_public_key *)tgt_p;
 	temp = key_p->pubSec.exponent;
 	memcpy(temp, exp_p, exp_len);
+	kfree(temp_exp);
 	temp += exp_len;
 	if (copy_from_user(temp, icaMsg_p->n_modulus, mod_len))
-	      return SEN_RELEASED;
+		return SEN_RELEASED;
 	if (is_empty(temp, mod_len))
-	      return SEN_USER_ERROR;
+		return SEN_USER_ERROR;
 	key_p->pubSec.modulus_bit_len = 8 * mod_len;
 	key_p->pubSec.modulus_byte_len = mod_len;
 	key_p->pubSec.exponent_len = exp_len;
-	key_p->pubSec.section_length = 12 + mod_len + exp_len;
+	key_p->pubSec.section_length = CALLER_HEADER + mod_len + exp_len;
 	key_len = key_p->pubSec.section_length + sizeof(struct cca_token_hdr);
 	key_p->pubHdr.token_length = key_len;
 	key_len += 4;
@@ -1908,7 +1928,8 @@
 
 static int
 ICACRT_msg_to_type6CRT_msgX(struct ica_rsa_modexpo_crt *icaMsg_p, int cdx,
-			    int *z90cMsg_l_p, struct type6_msg *z90cMsg_p)
+			    int *z90cMsg_l_p, struct type6_msg *z90cMsg_p,
+			    int dev_type)
 {
 	int mod_len, vud_len, tmp_size, total_CPRB_len, parmBlock_l, short_len;
 	int long_len, pad_len, keyPartsLen, tmp_l;
@@ -1943,8 +1964,12 @@
 	cprbx_p->req_parml = parmBlock_l;
 	cprbx_p->rpl_msgbl = parmBlock_l;
 	tgt_p += sizeof(struct CPRBX);
-	memcpy(tgt_p, &static_pkd_function_and_rulesX,
-	       sizeof(struct function_and_rules_block));
+	if (dev_type == PCIXCC_MCL2)
+		memcpy(tgt_p, &static_pkd_function_and_rulesX_MCL2,
+		       sizeof(struct function_and_rules_block));
+	else
+		memcpy(tgt_p, &static_pkd_function_and_rulesX,
+		       sizeof(struct function_and_rules_block));
 	tgt_p += sizeof(struct function_and_rules_block);
 	*((short *)tgt_p) = (short) vud_len;
 	tgt_p += 2;
@@ -2043,20 +2068,37 @@
 				(struct ica_rsa_modexpo *) buffer,
 				cdx, msg_l_p, (struct type6_msg *) msg_p);
 	}
-	if (dev_type == PCIXCC) {
+	if ((dev_type == PCIXCC_MCL2) ||
+	    (dev_type == PCIXCC_MCL3) ||
+	    (dev_type == CEX2C)) {
 		if (func == ICARSACRT)
 			return ICACRT_msg_to_type6CRT_msgX(
 				(struct ica_rsa_modexpo_crt *) buffer,
-				cdx, msg_l_p, (struct type6_msg *) msg_p);
+				cdx, msg_l_p, (struct type6_msg *) msg_p,
+				dev_type);
 		else
 			return ICAMEX_msg_to_type6MEX_msgX(
 				(struct ica_rsa_modexpo *) buffer,
-				cdx, msg_l_p, (struct type6_msg *) msg_p);
+				cdx, msg_l_p, (struct type6_msg *) msg_p,
+				dev_type);
 	}
 
 	return 0;
 }
 
+int ext_bitlens_msg_count = 0;
+static inline void
+unset_ext_bitlens(void)
+{
+	if (!ext_bitlens_msg_count) {
+		PRINTK("Unable to use coprocessors for extended bitlengths. "
+		       "Using PCICAs (if present) for extended bitlengths. "
+		       "This is not an error.\n");
+		ext_bitlens_msg_count++;
+	}
+	ext_bitlens = 0;
+}
+
 int
 convert_response(unsigned char *response, unsigned char *buffer,
 		 int *respbufflen_p, unsigned char *resp_buff)
@@ -2064,8 +2106,8 @@
 	struct ica_rsa_modexpo *icaMsg_p = (struct ica_rsa_modexpo *) buffer;
 	struct type82_hdr *t82h_p = (struct type82_hdr *) response;
 	struct type84_hdr *t84h_p = (struct type84_hdr *) response;
-	struct type86_hdr *t86h_p = (struct type86_hdr *) response;
-	int rv, reply_code, service_rc, service_rs, src_l;
+	struct type86_fmt2_msg *t86m_p =  (struct type86_fmt2_msg *) response;
+	int reply_code, service_rc, service_rs, src_l;
 	unsigned char *src_p, *tgt_p;
 	struct CPRB *cprb_p;
 	struct CPRBX *cprbx_p;
@@ -2075,11 +2117,9 @@
 	service_rc = 0;
 	service_rs = 0;
 	src_l = 0;
-	rv = 0;
 	switch (t82h_p->type) {
 	case TYPE82_RSP_CODE:
 		reply_code = t82h_p->reply_code;
-		rv = 4;
 		src_p = (unsigned char *)t82h_p;
 		PRINTK("Hardware error: Type 82 Message Header: "
 		       "%02x%02x%02x%02x%02x%02x%02x%02x\n",
@@ -2091,15 +2131,9 @@
 		src_p = response + (int)t84h_p->len - src_l;
 		break;
 	case TYPE86_RSP_CODE:
-		reply_code = t86h_p->reply_code;
-		if (t86h_p->format != TYPE86_FMT2) {
-			rv = 4;
-			break;
-		}
-		if (reply_code != 0) {
-			rv = 4;
+		reply_code = t86m_p->hdr.reply_code;
+		if (reply_code != 0)
 			break;
-		}
 		cprb_p = (struct CPRB *)
 			(response + sizeof(struct type86_fmt2_msg));
 		cprbx_p = (struct CPRBX *) cprb_p;
@@ -2108,11 +2142,22 @@
 			if (service_rc != 0) {
 				le2toI(cprb_p->ccp_rscode, &service_rs);
 				if ((service_rc == 8) && (service_rs == 66))
-					PDEBUG("8/66 on PCICC\n");
+					PDEBUG("Bad block format on PCICC\n");
+				else if ((service_rc == 8) && (service_rs == 770)) {
+					PDEBUG("Invalid key length on PCICC\n");
+					unset_ext_bitlens();
+					return REC_USE_PCICA;
+				}
+				else if ((service_rc == 8) && (service_rs == 783)) {
+					PDEBUG("Extended bitlengths not enabled"
+					       "on PCICC\n");
+					unset_ext_bitlens();
+					return REC_USE_PCICA;
+				}
 				else
 					PRINTK("service rc/rs: %d/%d\n",
 					       service_rc, service_rs);
-				rv = 8;
+				return REC_OPERAND_INV;
 			}
 			src_p = (unsigned char *)cprb_p + sizeof(struct CPRB);
 			src_p += 4;
@@ -2124,11 +2169,22 @@
 			if (service_rc != 0) {
 				service_rs = (int) cprbx_p->ccp_rscode;
 				if ((service_rc == 8) && (service_rs == 66))
-					PDEBUG("8/66 on PCIXCC\n");
+					PDEBUG("Bad block format on PCXICC\n");
+				else if ((service_rc == 8) && (service_rs == 770)) {
+					PDEBUG("Invalid key length on PCIXCC\n");
+					unset_ext_bitlens();
+					return REC_USE_PCICA;
+				}
+				else if ((service_rc == 8) && (service_rs == 783)) {
+					PDEBUG("Extended bitlengths not enabled"
+					       "on PCIXCC\n");
+					unset_ext_bitlens();
+					return REC_USE_PCICA;
+				}
 				else
 					PRINTK("service rc/rs: %d/%d\n",
 					       service_rc, service_rs);
-				rv = 8;
+				return REC_OPERAND_INV;
 			}
 			src_p = (unsigned char *)
 				cprbx_p + sizeof(struct CPRBX);
@@ -2139,12 +2195,10 @@
 		}
 		break;
 	default:
-		break;
+		return REC_BAD_MESSAGE;
 	}
 
-	if (rv == 8)
-		return 8;
-	if (rv == 4)
+	if (reply_code)
 		switch (reply_code) {
 		case REPLY_ERROR_OPERAND_INVALID:
 			return REC_OPERAND_INV;
@@ -2154,8 +2208,14 @@
 			return REC_EVEN_MOD;
 		case REPLY_ERROR_MESSAGE_TYPE:
 			return WRONG_DEVICE_TYPE;
+		case REPLY_ERROR_TRANSPORT_FAIL:
+			PRINTKW("Transport failed (APFS = %02X%02X%02X%02X)\n",
+				t86m_p->apfs[0], t86m_p->apfs[1],
+				t86m_p->apfs[2], t86m_p->apfs[3]);
+			return REC_HARDWAR_ERR;
 		default:
-			return 12;
+			PRINTKW("reply code = %d\n", reply_code);
+			return REC_HARDWAR_ERR;
 		}
 
 	if (service_rc != 0)
@@ -2171,14 +2231,13 @@
 	memcpy(tgt_p, src_p, src_l);
 	if ((t82h_p->type == TYPE86_RSP_CODE) && (resp_buff < tgt_p)) {
 		memset(resp_buff, 0, icaMsg_p->outputdatalength - src_l);
-		rv = pad_msg(resp_buff, icaMsg_p->outputdatalength, src_l);
-		if (rv != 0)
-			return rv;
+		if (pad_msg(resp_buff, icaMsg_p->outputdatalength, src_l))
+			return REC_INVALID_PAD;
 	}
 	*respbufflen_p = icaMsg_p->outputdatalength;
 	if (*respbufflen_p == 0)
 		PRINTK("Zero *respbufflen_p\n");
 
-	return rv;
+	return 0;
 }
 
diff -Nru a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
--- a/drivers/s390/crypto/z90main.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/s390/crypto/z90main.c	2004-12-24 13:36:17 -08:00
@@ -1,11 +1,11 @@
 /*
- *  linux/drivers/s390/misc/z90main.c
+ *  linux/drivers/s390/crypto/z90main.c
  *
- *  z90crypt 1.3.1
+ *  z90crypt 1.3.2
  *
  *  Copyright (C)  2001, 2004 IBM Corporation
  *  Author(s): Robert Burroughs (burrough@us.ibm.com)
- *	       Eric Rossman (edrossma@us.ibm.com)
+ *             Eric Rossman (edrossma@us.ibm.com)
  *
  *  Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  *
@@ -16,7 +16,7 @@
  *
  * 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
+ * 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
@@ -33,6 +33,7 @@
 #include <linux/ioctl32.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/kobject_uevent.h>
 #include <linux/proc_fs.h>
 #include <linux/syscalls.h>
 #include <linux/version.h>
@@ -50,13 +51,13 @@
 #  error "This kernel is too recent: not supported by this file"
 #endif
 
-#define VERSION_Z90MAIN_C "$Revision: 1.31 $"
+#define VERSION_Z90MAIN_C "$Revision: 1.57 $"
 
-static char z90cmain_version[] __initdata =
+static char z90main_version[] __initdata =
 	"z90main.o (" VERSION_Z90MAIN_C "/"
                       VERSION_Z90COMMON_H "/" VERSION_Z90CRYPT_H ")";
 
-extern char z90chardware_version[];
+extern char z90hardware_version[];
 
 /**
  * Defaults that may be modified.
@@ -96,7 +97,7 @@
  * older than CLEANUPTIME seconds in the past.
  */
 #ifndef CLEANUPTIME
-#define CLEANUPTIME 15
+#define CLEANUPTIME 20
 #endif
 
 /**
@@ -116,9 +117,15 @@
 
 /**
  * Reader should run every READERTIME milliseconds
+ * With the 100Hz patch for s390, z90crypt can lock the system solid while
+ * under heavy load. We'll try to avoid that.
  */
 #ifndef READERTIME
+#if HZ > 1000
 #define READERTIME 2
+#else
+#define READERTIME 10
+#endif
 #endif
 
 /**
@@ -209,18 +216,13 @@
 #ifndef Z90CRYPT_NUM_DEVS
 #define Z90CRYPT_NUM_DEVS Z90CRYPT_NUM_APS
 #endif
-#ifndef Z90CRYPT_NUM_TYPES
-#define Z90CRYPT_NUM_TYPES 3
-#endif
 
 /**
  * Buffer size for receiving responses. The maximum Response Size
  * is actually the maximum request size, since in an error condition
  * the request itself may be returned unchanged.
  */
-#ifndef MAX_RESPONSE_SIZE
 #define MAX_RESPONSE_SIZE 0x0000077C
-#endif
 
 /**
  * A count and status-byte mask
@@ -246,7 +248,8 @@
  * All devices are arranged in a single array: 64 APs
  */
 struct device {
-	int		 dev_type;	    // PCICA, PCICC, or PCIXCC
+	int		 dev_type;	    // PCICA, PCICC, PCIXCC_MCL2,
+					    // PCIXCC_MCL3, CEX2C
 	enum devstat	 dev_stat;	    // current device status
 	int		 dev_self_x;	    // Index in array
 	int		 disabled;	    // Set when device is in error
@@ -328,6 +331,7 @@
 static void destroy_z90crypt(void);
 static int refresh_index_array(struct status *, struct device_x *);
 static int probe_device_type(struct device *);
+static int probe_PCIXCC_type(struct device *);
 
 /**
  * proc fs definitions
@@ -449,9 +453,9 @@
 /**
  * Documentation values.
  */
-MODULE_AUTHOR("zLinux Crypto Team: Robert H. Burroughs, Eric D. Rossman"
+MODULE_AUTHOR("zSeries Linux Crypto Team: Robert H. Burroughs, Eric D. Rossman"
 	      "and Jochen Roehrig");
-MODULE_DESCRIPTION("zLinux Cryptographic Coprocessor device driver, "
+MODULE_DESCRIPTION("zSeries Linux Cryptographic Coprocessor device driver, "
 		   "Copyright 2001, 2004 IBM Corporation");
 MODULE_LICENSE("GPL");
 module_param(domain, int, 0);
@@ -554,7 +558,8 @@
 
 static int compatible_ioctls[] = {
 	ICAZ90STATUS, Z90QUIESCE, Z90STAT_TOTALCOUNT, Z90STAT_PCICACOUNT,
-	Z90STAT_PCICCCOUNT, Z90STAT_PCIXCCCOUNT, Z90STAT_REQUESTQ_COUNT,
+	Z90STAT_PCICCCOUNT, Z90STAT_PCIXCCCOUNT, Z90STAT_PCIXCCMCL2COUNT,
+	Z90STAT_PCIXCCMCL3COUNT, Z90STAT_CEX2CCOUNT, Z90STAT_REQUESTQ_COUNT,
 	Z90STAT_PENDINGQ_COUNT, Z90STAT_TOTALOPEN_COUNT, Z90STAT_DOMAIN_INDEX,
 	Z90STAT_STATUS_MASK, Z90STAT_QDEPTH_MASK, Z90STAT_PERDEV_REQCNT,
 };
@@ -575,20 +580,33 @@
 	int result, i;
 
 	result = register_ioctl32_conversion(ICARSAMODEXPO, trans_modexpo32);
+	if (result == -EBUSY) {
+		unregister_ioctl32_conversion(ICARSAMODEXPO);
+		result = register_ioctl32_conversion(ICARSAMODEXPO,
+						     trans_modexpo32);
+	}
 	if (result)
 		return result;
 	result = register_ioctl32_conversion(ICARSACRT, trans_modexpo_crt32);
+	if (result == -EBUSY) {
+		unregister_ioctl32_conversion(ICARSACRT);
+		result = register_ioctl32_conversion(ICARSACRT,
+						     trans_modexpo_crt32);
+	}
 	if (result)
 		return result;
 
 	for(i = 0; i < ARRAY_SIZE(compatible_ioctls); i++) {
-		result = register_ioctl32_conversion(compatible_ioctls[i],NULL);
-		if (result) {
-			z90_unregister_ioctl32s();
-			return result;
+		result = register_ioctl32_conversion(compatible_ioctls[i], 0);
+		if (result == -EBUSY) {
+			unregister_ioctl32_conversion(compatible_ioctls[i]);
+			result = register_ioctl32_conversion(
+						       compatible_ioctls[i], 0);
 		}
+		if (result)
+			return result;
 	}
-	return result;
+	return 0;
 }
 #else // !CONFIG_COMPAT
 static inline void z90_unregister_ioctl32s(void)
@@ -612,10 +630,15 @@
 
 	PDEBUG("PID %d\n", PID());
 
+	if ((domain < -1) || (domain > 15)) {
+		PRINTKW("Invalid param: domain = %d.  Not loading.\n", domain);
+		return -EINVAL;
+	}
+
 #ifndef Z90CRYPT_USE_HOTPLUG
 	/* Register as misc device with given minor (or get a dynamic one). */
 	result = misc_register(&z90crypt_misc_device);
-	if (result <0) {
+	if (result < 0) {
 		PRINTKW(KERN_ERR "misc_register (minor %d) failed with %d\n",
 			z90crypt_misc_device.minor, result);
 		return result;
@@ -647,8 +670,8 @@
 		PRINTKN("Version %d.%d.%d loaded, built on %s %s\n",
 			z90crypt_VERSION, z90crypt_RELEASE, z90crypt_VARIANT,
 			__DATE__, __TIME__);
-		PRINTKN("%s\n", z90cmain_version);
-		PRINTKN("%s\n", z90chardware_version);
+		PRINTKN("%s\n", z90main_version);
+		PRINTKN("%s\n", z90hardware_version);
 		PDEBUG("create_z90crypt (domain index %d) successful.\n",
 		       domain);
 	} else
@@ -923,7 +946,26 @@
 static inline int
 get_status_PCIXCCcount(void)
 {
-	return z90crypt.hdware_info->type_mask[PCIXCC].st_count;
+	return z90crypt.hdware_info->type_mask[PCIXCC_MCL2].st_count +
+	       z90crypt.hdware_info->type_mask[PCIXCC_MCL3].st_count;
+}
+
+static inline int
+get_status_PCIXCCMCL2count(void)
+{
+	return z90crypt.hdware_info->type_mask[PCIXCC_MCL2].st_count;
+}
+
+static inline int
+get_status_PCIXCCMCL3count(void)
+{
+	return z90crypt.hdware_info->type_mask[PCIXCC_MCL3].st_count;
+}
+
+static inline int
+get_status_CEX2Ccount(void)
+{
+	return z90crypt.hdware_info->type_mask[CEX2C].st_count;
 }
 
 static inline int
@@ -1016,8 +1058,8 @@
 	we_p->audit[2] = 0x00;
 	we_p->resp_buff_size = 0;
 	we_p->retcode = 0;
-	we_p->devindex = -1; // send_to_crypto selects the device
-	we_p->devtype = -1;  // getCryptoBuffer selects the type
+	we_p->devindex = -1;
+	we_p->devtype = -1;
 	atomic_set(&we_p->alarmrung, 0);
 	init_waitqueue_head(&we_p->waitq);
 	INIT_LIST_HEAD(&(we_p->liste));
@@ -1040,42 +1082,113 @@
 static inline void
 remove_device(struct device *device_p)
 {
-	if (!device_p || device_p->disabled != 0)
+	if (!device_p || (device_p->disabled != 0))
 		return;
 	device_p->disabled = 1;
 	z90crypt.hdware_info->type_mask[device_p->dev_type].disabled_count++;
 	z90crypt.hdware_info->hdware_mask.disabled_count++;
 }
 
+/**
+ * Bitlength limits for each card
+ *
+ * There are new MCLs which allow more bitlengths. See the table for details.
+ * The MCL must be applied and the newer bitlengths enabled for these to work.
+ *
+ * Card Type    Old limit    New limit
+ * PCICC         512-1024     512-2048
+ * PCIXCC_MCL2   512-2048     no change (applying this MCL == card is MCL3+)
+ * PCIXCC_MCL3   512-2048     128-2048
+ * CEX2C         512-2048     128-2048
+ *
+ * ext_bitlens (extended bitlengths) is a global, since you should not apply an
+ * MCL to just one card in a machine. We assume, at first, that all cards have
+ * these capabilities.
+ */
+int ext_bitlens = 1; // This is global
+#define PCIXCC_MIN_MOD_SIZE	 16	//  128 bits
+#define OLD_PCIXCC_MIN_MOD_SIZE	 64	//  512 bits
+#define PCICC_MIN_MOD_SIZE	 64	//  512 bits
+#define OLD_PCICC_MAX_MOD_SIZE	128	// 1024 bits
+#define MAX_MOD_SIZE		256	// 2048 bits
+
 static inline int
-select_device_type(int *dev_type_p)
+select_device_type(int *dev_type_p, int bytelength)
 {
+	static int count = 0;
+	int PCICA_avail, PCIXCC_MCL3_avail, CEX2C_avail, index_to_use;
 	struct status *stat;
 	if ((*dev_type_p != PCICC) && (*dev_type_p != PCICA) &&
-	    (*dev_type_p != PCIXCC) && (*dev_type_p != ANYDEV))
+	    (*dev_type_p != PCIXCC_MCL2) && (*dev_type_p != PCIXCC_MCL3) &&
+	    (*dev_type_p != CEX2C) && (*dev_type_p != ANYDEV))
 		return -1;
 	if (*dev_type_p != ANYDEV) {
 		stat = &z90crypt.hdware_info->type_mask[*dev_type_p];
 		if (stat->st_count >
-		    stat->disabled_count + stat->user_disabled_count)
+		    (stat->disabled_count + stat->user_disabled_count))
 			return 0;
 		return -1;
 	}
 
+	/* Assumption: PCICA, PCIXCC_MCL3, and CEX2C are all similar in speed */
 	stat = &z90crypt.hdware_info->type_mask[PCICA];
-	if (stat->st_count > stat->disabled_count + stat->user_disabled_count) {
-		*dev_type_p = PCICA;
+	PCICA_avail = stat->st_count -
+			(stat->disabled_count + stat->user_disabled_count);
+	stat = &z90crypt.hdware_info->type_mask[PCIXCC_MCL3];
+	PCIXCC_MCL3_avail = stat->st_count -
+			(stat->disabled_count + stat->user_disabled_count);
+	stat = &z90crypt.hdware_info->type_mask[CEX2C];
+	CEX2C_avail = stat->st_count -
+			(stat->disabled_count + stat->user_disabled_count);
+	if (PCICA_avail || PCIXCC_MCL3_avail || CEX2C_avail) {
+		/**
+		 * bitlength is a factor, PCICA is the most capable, even with
+		 * the new MCL.
+		 */
+		if ((bytelength < PCIXCC_MIN_MOD_SIZE) ||
+		    (!ext_bitlens && (bytelength < OLD_PCIXCC_MIN_MOD_SIZE))) {
+			if (!PCICA_avail)
+				return -1;
+			else {
+				*dev_type_p = PCICA;
+				return 0;
+			}
+		}
+
+		index_to_use = count % (PCICA_avail + PCIXCC_MCL3_avail +
+					CEX2C_avail);
+		if (index_to_use < PCICA_avail)
+			*dev_type_p = PCICA;
+		else if (index_to_use < (PCICA_avail + PCIXCC_MCL3_avail))
+			*dev_type_p = PCIXCC_MCL3;
+		else
+			*dev_type_p = CEX2C;
+		count++;
 		return 0;
 	}
 
-	stat = &z90crypt.hdware_info->type_mask[PCIXCC];
-	if (stat->st_count > stat->disabled_count + stat->user_disabled_count) {
-		*dev_type_p = PCIXCC;
+	/* Less than OLD_PCIXCC_MIN_MOD_SIZE cannot go to a PCIXCC_MCL2 */
+	if (bytelength < OLD_PCIXCC_MIN_MOD_SIZE)
+		return -1;
+	stat = &z90crypt.hdware_info->type_mask[PCIXCC_MCL2];
+	if (stat->st_count >
+	    (stat->disabled_count + stat->user_disabled_count)) {
+		*dev_type_p = PCIXCC_MCL2;
 		return 0;
 	}
 
+	/**
+	 * Less than PCICC_MIN_MOD_SIZE or more than OLD_PCICC_MAX_MOD_SIZE
+	 * (if we don't have the MCL applied and the newer bitlengths enabled)
+	 * cannot go to a PCICC
+	 */
+	if ((bytelength < PCICC_MIN_MOD_SIZE) ||
+	    (!ext_bitlens && (bytelength > OLD_PCICC_MAX_MOD_SIZE))) {
+		return -1;
+	}
 	stat = &z90crypt.hdware_info->type_mask[PCICC];
-	if (stat->st_count > stat->disabled_count + stat->user_disabled_count) {
+	if (stat->st_count >
+	    (stat->disabled_count + stat->user_disabled_count)) {
 		*dev_type_p = PCICC;
 		return 0;
 	}
@@ -1087,7 +1200,7 @@
  * Try the selected number, then the selected type (can be ANYDEV)
  */
 static inline int
-select_device(int *dev_type_p, int *device_nr_p)
+select_device(int *dev_type_p, int *device_nr_p, int bytelength)
 {
 	int i, indx, devTp, low_count, low_indx;
 	struct device_x *index_p;
@@ -1099,9 +1212,9 @@
 		dev_ptr = z90crypt.device_p[*device_nr_p];
 
 		if (dev_ptr &&
-		    dev_ptr->dev_stat != DEV_GONE &&
-		    dev_ptr->disabled == 0 &&
-		    dev_ptr->user_disabled == 0) {
+		    (dev_ptr->dev_stat != DEV_GONE) &&
+		    (dev_ptr->disabled == 0) &&
+		    (dev_ptr->user_disabled == 0)) {
 			PDEBUG("selected by number, index = %d\n",
 			       *device_nr_p);
 			*dev_type_p = dev_ptr->dev_type;
@@ -1111,7 +1224,7 @@
 	*device_nr_p = -1;
 	PDEBUG("trying type = %d\n", *dev_type_p);
 	devTp = *dev_type_p;
-	if (select_device_type(&devTp) == -1) {
+	if (select_device_type(&devTp, bytelength) == -1) {
 		PDEBUG("failed to select by type\n");
 		return -1;
 	}
@@ -1123,11 +1236,11 @@
 		indx = index_p->device_index[i];
 		dev_ptr = z90crypt.device_p[indx];
 		if (dev_ptr &&
-		    dev_ptr->dev_stat != DEV_GONE &&
-		    dev_ptr->disabled == 0 &&
-		    dev_ptr->user_disabled == 0 &&
-		    devTp == dev_ptr->dev_type &&
-		    low_count > dev_ptr->dev_caller_count) {
+		    (dev_ptr->dev_stat != DEV_GONE) &&
+		    (dev_ptr->disabled == 0) &&
+		    (dev_ptr->user_disabled == 0) &&
+		    (devTp == dev_ptr->dev_type) &&
+		    (low_count > dev_ptr->dev_caller_count)) {
 			low_count = dev_ptr->dev_caller_count;
 			low_indx = indx;
 		}
@@ -1142,12 +1255,13 @@
 	struct caller *caller_p;
 	struct device *device_p;
 	int dev_nr;
+	int bytelen = ((struct ica_rsa_modexpo *)we_p->buffer)->inputdatalength;
 
 	if (!we_p->requestptr)
 		return SEN_FATAL_ERROR;
 	caller_p = (struct caller *)we_p->requestptr;
 	dev_nr = we_p->devindex;
-	if (select_device(&we_p->devtype, &dev_nr) == -1) {
+	if (select_device(&we_p->devtype, &dev_nr, bytelen) == -1) {
 		if (z90crypt.hdware_info->hdware_mask.st_count != 0)
 			return SEN_RETRY;
 		else
@@ -1297,15 +1411,6 @@
 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 
 /**
- * MIN_MOD_SIZE is a PCICC and PCIXCC limit.
- * MAX_PCICC_MOD_SIZE is a hard limit for the PCICC.
- * MAX_MOD_SIZE is a hard limit for the PCIXCC and PCICA.
- */
-#define MIN_MOD_SIZE 64
-#define MAX_PCICC_MOD_SIZE 128
-#define MAX_MOD_SIZE 256
-
-/**
  * Used in device configuration functions
  */
 #define MAX_RESET 90
@@ -1361,7 +1466,8 @@
 	struct caller *caller_p = (struct caller *)we_p->requestptr;
 
 	if ((we_p->devtype != PCICC) && (we_p->devtype != PCICA) &&
-	    (we_p->devtype != PCIXCC))
+	    (we_p->devtype != PCIXCC_MCL2) && (we_p->devtype != PCIXCC_MCL3) &&
+	    (we_p->devtype != CEX2C))
 		return SEN_NOT_AVAIL;
 
 	memcpy(caller_p->caller_id, we_p->caller_id,
@@ -1393,9 +1499,8 @@
 		return;
 	if (caller_p->caller_liste.next && caller_p->caller_liste.prev)
 		if (!list_empty(&caller_p->caller_liste)) {
-			list_del(&caller_p->caller_liste);
+			list_del_init(&caller_p->caller_liste);
 			device_p->dev_caller_count--;
-			INIT_LIST_HEAD(&caller_p->caller_liste);
 		}
 	memset(caller_p->caller_id, 0, sizeof(caller_p->caller_id));
 }
@@ -1430,7 +1535,8 @@
 	}
 
 	if ((we_p->devtype != PCICA) && (we_p->devtype != PCICC) &&
-	    (we_p->devtype != PCIXCC) && (we_p->devtype != ANYDEV)) {
+	    (we_p->devtype != PCIXCC_MCL2) && (we_p->devtype != PCIXCC_MCL3) &&
+	    (we_p->devtype != CEX2C) && (we_p->devtype != ANYDEV)) {
 		PRINTK("invalid device type\n");
 		return SEN_USER_ERROR;
 	}
@@ -1494,7 +1600,7 @@
 	if (rv != 0)
 		return rv;
 
-	if (select_device_type(&we_p->devtype) < 0)
+	if (select_device_type(&we_p->devtype, mex_p->inputdatalength) < 0)
 		return SEN_NOT_AVAIL;
 
 	temp_buffer = (unsigned char *)we_p + sizeof(struct work_element) +
@@ -1510,13 +1616,19 @@
 		function = PCI_FUNC_KEY_ENCRYPT;
 		break;
 	/**
-	 * PCIXCC does all Mod-Expo form with a simple RSA mod-expo
+	 * PCIXCC_MCL2 does all Mod-Expo form with a simple RSA mod-expo
 	 * operation, and all CRT forms with a PKCS-1.2 format decrypt.
+	 * PCIXCC_MCL3 and CEX2C do all Mod-Expo and CRT forms with a simple RSA
+	 * mod-expo operation
 	 */
-	case PCIXCC:
-		/* Anything less than MIN_MOD_SIZE MUST go to a PCICA */
-		if (mex_p->inputdatalength < MIN_MOD_SIZE)
-			return SEN_NOT_AVAIL;
+	case PCIXCC_MCL2:
+		if (we_p->funccode == ICARSAMODEXPO)
+			function = PCI_FUNC_KEY_ENCRYPT;
+		else
+			function = PCI_FUNC_KEY_DECRYPT;
+		break;
+	case PCIXCC_MCL3:
+	case CEX2C:
 		if (we_p->funccode == ICARSAMODEXPO)
 			function = PCI_FUNC_KEY_ENCRYPT;
 		else
@@ -1526,14 +1638,6 @@
 	 * PCICC does everything as a PKCS-1.2 format request
 	 */
 	case PCICC:
-		/* Anything less than MIN_MOD_SIZE MUST go to a PCICA */
-		if (mex_p->inputdatalength < MIN_MOD_SIZE) {
-			return SEN_NOT_AVAIL;
-		}
-		/* Anythings over MAX_PCICC_MOD_SIZE MUST go to a PCICA */
-		if (mex_p->inputdatalength > MAX_PCICC_MOD_SIZE) {
-			return SEN_NOT_AVAIL;
-		}
 		/* PCICC cannot handle input that is is PKCS#1.1 padded */
 		if (is_PKCS11_padded(temp_buffer, mex_p->inputdatalength)) {
 			return SEN_NOT_AVAIL;
@@ -1593,6 +1697,7 @@
 		rv = -ENODEV;
 		break;
 	case SEN_NOT_AVAIL:
+	case EGETBUFF:
 		rv = -EGETBUFF;
 		break;
 	default:
@@ -1613,14 +1718,14 @@
 	spin_lock_irq(&queuespinlock);
 	list_for_each(lptr, &request_list) {
 		if (lptr == &we_p->liste) {
-			list_del(lptr);
+			list_del_init(lptr);
 			requestq_count--;
 			break;
 		}
 	}
 	list_for_each(lptr, &pending_list) {
 		if (lptr == &we_p->liste) {
-			list_del(lptr);
+			list_del_init(lptr);
 			pendingq_count--;
 			break;
 		}
@@ -1659,14 +1764,13 @@
 	if ((we_p->status[0] & STAT_FAILED)) {
 		switch (rv) {
 		/**
-		 * EINVAL *after* receive is almost always padding
-		 * error issued by a PCICC or PCIXCC. We convert this
-		 * return value to -EGETBUFF which should trigger a
-		 * fallback to software.
+		 * EINVAL *after* receive is almost always a padding error or
+		 * length error issued by a coprocessor (not an accelerator).
+		 * We convert this return value to -EGETBUFF which should
+		 * trigger a fallback to software.
 		 */
 		case -EINVAL:
-			if ((we_p->devtype == PCICC) ||
-			    (we_p->devtype == PCIXCC))
+			if (we_p->devtype != PCICA)
 				rv = -EGETBUFF;
 			break;
 		case -ETIMEOUT:
@@ -1710,7 +1814,8 @@
 	unsigned int *reqcnt;
 	struct ica_z90_status *pstat;
 	int ret, i, loopLim, tempstat;
-	static int deprecated_msg_count = 0;
+	static int deprecated_msg_count1 = 0;
+	static int deprecated_msg_count2 = 0;
 
 	PDEBUG("filp %p (PID %d), cmd 0x%08X\n", filp, PID(), cmd);
 	PDEBUG("cmd 0x%08X: dir %s, size 0x%04X, type 0x%02X, nr 0x%02X\n",
@@ -1765,8 +1870,20 @@
 			ret = -EFAULT;
 		break;
 
-	case Z90STAT_PCIXCCCOUNT:
-		tempstat = get_status_PCIXCCcount();
+	case Z90STAT_PCIXCCMCL2COUNT:
+		tempstat = get_status_PCIXCCMCL2count();
+		if (copy_to_user((int __user *)arg, &tempstat, sizeof(int)) != 0)
+			ret = -EFAULT;
+		break;
+
+	case Z90STAT_PCIXCCMCL3COUNT:
+		tempstat = get_status_PCIXCCMCL3count();
+		if (copy_to_user((int __user *)arg, &tempstat, sizeof(int)) != 0)
+			ret = -EFAULT;
+		break;
+
+	case Z90STAT_CEX2CCOUNT:
+		tempstat = get_status_CEX2Ccount();
 		if (copy_to_user((int __user *)arg, &tempstat, sizeof(int)) != 0)
 			ret = -EFAULT;
 		break;
@@ -1838,10 +1955,10 @@
 
 		/* THIS IS DEPRECATED.	USE THE NEW STATUS CALLS */
 	case ICAZ90STATUS:
-		if (deprecated_msg_count < 100) {
+		if (deprecated_msg_count1 < 20) {
 			PRINTK("deprecated call to ioctl (ICAZ90STATUS)!\n");
-			deprecated_msg_count++;
-			if (deprecated_msg_count == 100)
+			deprecated_msg_count1++;
+			if (deprecated_msg_count1 == 20)
 				PRINTK("No longer issuing messages related to "
 				       "deprecated call to ICAZ90STATUS.\n");
 		}
@@ -1869,6 +1986,21 @@
 		kfree(pstat);
 		break;
 
+		/* THIS IS DEPRECATED.	USE THE NEW STATUS CALLS */
+	case Z90STAT_PCIXCCCOUNT:
+		if (deprecated_msg_count2 < 20) {
+			PRINTK("deprecated ioctl (Z90STAT_PCIXCCCOUNT)!\n");
+			deprecated_msg_count2++;
+			if (deprecated_msg_count2 == 20)
+				PRINTK("No longer issuing messages about depre"
+				       "cated ioctl Z90STAT_PCIXCCCOUNT.\n");
+		}
+
+		tempstat = get_status_PCIXCCcount();
+		if (copy_to_user((int *)arg, &tempstat, sizeof(int)) != 0)
+			ret = -EFAULT;
+		break;
+
 	case Z90QUIESCE:
 		if (current->euid != 0) {
 			PRINTK("QUIESCE fails: euid %d\n",
@@ -1990,8 +2122,12 @@
 		get_status_PCICAcount());
 	len += sprintf(resp_buff+len, "PCICC count: %d\n",
 		get_status_PCICCcount());
-	len += sprintf(resp_buff+len, "PCIXCC count: %d\n",
-		get_status_PCIXCCcount());
+	len += sprintf(resp_buff+len, "PCIXCC MCL2 count: %d\n",
+		get_status_PCIXCCMCL2count());
+	len += sprintf(resp_buff+len, "PCIXCC MCL3 count: %d\n",
+		get_status_PCIXCCMCL3count());
+	len += sprintf(resp_buff+len, "CEX2C count: %d\n",
+		get_status_CEX2Ccount());
 	len += sprintf(resp_buff+len, "requestq count: %d\n",
 		get_status_requestq_count());
 	len += sprintf(resp_buff+len, "pendingq count: %d\n",
@@ -1999,7 +2135,8 @@
 	len += sprintf(resp_buff+len, "Total open handles: %d\n\n",
 		get_status_totalopen_count());
 	len += sprinthx(
-		"Online devices: 1 means PCICA, 2 means PCICC, 3 means PCIXCC",
+		"Online devices: 1: PCICA, 2: PCICC, 3: PCIXCC (MCL2), "
+		"4: PCIXCC (MCL3), 5: CEX2C",
 		resp_buff+len,
 		get_status_status_mask(workarea),
 		Z90CRYPT_NUM_APS);
@@ -2171,6 +2308,8 @@
 		case '1':
 		case '2':
 		case '3':
+		case '4':
+		case '5':
 			j++;
 			break;
 		case 'd':
@@ -2228,13 +2367,12 @@
 	dev_ptr = z90crypt.device_p[index];
 	rv = 0;
 	do {
-		PDEBUG("Dequeue called for device %d\n", index);
 		if (!dev_ptr || dev_ptr->disabled) {
-			rv = REC_NO_RESPONSE;
+			rv = REC_NO_WORK; // a disabled device can't return work
 			break;
 		}
 		if (dev_ptr->dev_self_x != index) {
-			PRINTK("Corrupt dev ptr in receive_from_AP\n");
+			PRINTKC("Corrupt dev ptr\n");
 			z90crypt.terminating = 1;
 			rv = REC_FATAL_ERROR;
 			break;
@@ -2244,6 +2382,7 @@
 			PRINTK("dev_resp_l = %d, dev_resp_p = %p\n",
 			       dev_ptr->dev_resp_l, dev_ptr->dev_resp_p);
 		} else {
+			PDEBUG("Dequeue called for device %d\n", index);
 			dv = receive_from_AP(index, z90crypt.cdx,
 					     dev_ptr->dev_resp_l,
 					     dev_ptr->dev_resp_p, psmid);
@@ -2283,15 +2422,18 @@
 			if (!memcmp(caller_p->caller_id, psmid,
 				    sizeof(caller_p->caller_id))) {
 				if (!list_empty(&caller_p->caller_liste)) {
-					list_del(ptr);
+					list_del_init(ptr);
 					dev_ptr->dev_caller_count--;
-					INIT_LIST_HEAD(&caller_p->caller_liste);
 					break;
 				}
 			}
 			caller_p = 0;
 		}
 		if (!caller_p) {
+			PRINTKW("Unable to locate PSMID %02X%02X%02X%02X%02X"
+				"%02X%02X%02X in device list\n",
+				psmid[0], psmid[1], psmid[2], psmid[3],
+				psmid[4], psmid[5], psmid[6], psmid[7]);
 			rv = REC_USER_GONE;
 			break;
 		}
@@ -2300,22 +2442,22 @@
 		rv = convert_response(dev_ptr->dev_resp_p,
 				      caller_p->caller_buf_p, buff_len_p, buff);
 		switch (rv) {
+		case REC_USE_PCICA:
+			break;
 		case REC_OPERAND_INV:
-			PDEBUG("dev %d: user error %d\n", index, rv);
+		case REC_OPERAND_SIZE:
+		case REC_EVEN_MOD:
+		case REC_INVALID_PAD:
+			PDEBUG("device %d: 'user error' %d\n", index, rv);
 			break;
 		case WRONG_DEVICE_TYPE:
 		case REC_HARDWAR_ERR:
 		case REC_BAD_MESSAGE:
-			PRINTK("dev %d: hardware error %d\n",
-			       index, rv);
+			PRINTKW("device %d: hardware error %d\n", index, rv);
 			rv = REC_NO_RESPONSE;
 			break;
-		case REC_RELEASED:
-			PDEBUG("dev %d: REC_RELEASED = %d\n",
-			       index, rv);
-			break;
 		default:
-			PDEBUG("dev %d: rv = %d\n", index, rv);
+			PDEBUG("device %d: rv = %d\n", index, rv);
 			break;
 		}
 	} while (0);
@@ -2329,6 +2471,7 @@
 			PRINTK("Zero *buff_len_p\n");
 		break;
 	case REC_NO_RESPONSE:
+		PRINTKW("Removing device %d from availability\n", index);
 		remove_device(dev_ptr);
 		break;
 	}
@@ -2349,7 +2492,7 @@
 		return;
 	requestq_count--;
 	rq_p = list_entry(request_list.next, struct work_element, liste);
-	list_del(&rq_p->liste);
+	list_del_init(&rq_p->liste);
 	rq_p->audit[1] |= FP_REMREQUEST;
 	if (rq_p->devtype == SHRT2DEVPTR(index)->dev_type) {
 		rq_p->devindex = SHRT2LONG(index);
@@ -2408,7 +2551,7 @@
 	list_for_each_safe(lptr, tptr, &pending_list) {
 		pq_p = list_entry(lptr, struct work_element, liste);
 		if (!memcmp(pq_p->caller_id, psmid, sizeof(pq_p->caller_id))) {
-			list_del(lptr);
+			list_del_init(lptr);
 			pendingq_count--;
 			pq_p->audit[1] |= FP_NOTPENDING;
 			break;
@@ -2441,6 +2584,10 @@
 			pq_p->retcode = -EINVAL;
 			pq_p->status[0] |= STAT_FAILED;
 			break;
+		case REC_USE_PCICA:
+			pq_p->retcode = -ERESTARTSYS;
+			pq_p->status[0] |= STAT_FAILED;
+			break;
 		case REC_NO_RESPONSE:
 		default:
 			if (z90crypt.mask.st_count > 1)
@@ -2461,7 +2608,7 @@
  * return TRUE if the work element should be removed from the queue
  */
 static inline int
-helper_receive_rc(int index, int *rc_p, int *workavail_p)
+helper_receive_rc(int index, int *rc_p)
 {
 	switch (*rc_p) {
 	case 0:
@@ -2469,26 +2616,26 @@
 	case REC_OPERAND_SIZE:
 	case REC_EVEN_MOD:
 	case REC_INVALID_PAD:
-		return 1;
+	case REC_USE_PCICA:
+		break;
 
 	case REC_BUSY:
 	case REC_NO_WORK:
 	case REC_EMPTY:
 	case REC_RETRY_DEV:
 	case REC_FATAL_ERROR:
-		break;
+		return 0;
 
 	case REC_NO_RESPONSE:
-		*workavail_p = 0;
 		break;
 
 	default:
-		PRINTK("rc %d, device %d\n", *rc_p, SHRT2LONG(index));
+		PRINTK("rc %d, device %d converted to REC_NO_RESPONSE\n",
+		       *rc_p, SHRT2LONG(index));
 		*rc_p = REC_NO_RESPONSE;
-		*workavail_p = 0;
 		break;
 	}
-	return 0;
+	return 1;
 }
 
 static inline void
@@ -2503,21 +2650,18 @@
 static void
 z90crypt_reader_task(unsigned long ptr)
 {
-	int workavail, remaining, index, rc, buff_len;
+	int workavail, index, rc, buff_len;
 	unsigned char	psmid[8];
 	unsigned char __user *resp_addr;
 	static unsigned char buff[1024];
 
-	PDEBUG("jiffies %ld\n", jiffies);
-
 	/**
 	 * we use workavail = 2 to ensure 2 passes with nothing dequeued before
-	 * exiting the loop. If remaining == 0 after the loop, there is no work
-	 * remaining on the queues.
+	 * exiting the loop. If pendingq_count == 0 after the loop, there is no
+	 * work remaining on the queues.
 	 */
 	resp_addr = 0;
 	workavail = 2;
-	remaining = 0;
 	buff_len = 0;
 	while (workavail) {
 		workavail--;
@@ -2535,7 +2679,7 @@
 							&resp_addr);
 			PDEBUG("Dequeued: rc = %d.\n", rc);
 
-			if (helper_receive_rc(index, &rc, &workavail)) {
+			if (helper_receive_rc(index, &rc)) {
 				if (rc != REC_NO_RESPONSE) {
 					helper_send_work(index);
 					workavail = 2;
@@ -2547,19 +2691,14 @@
 			}
 
 			if (rc == REC_FATAL_ERROR)
-				remaining = 0;
-			else if (rc != REC_NO_RESPONSE)
-				remaining +=
-					SHRT2DEVPTR(index)->dev_caller_count;
+				PRINTKW("REC_FATAL_ERROR from device %d!\n",
+					SHRT2LONG(index));
 		}
 		spin_unlock_irq(&queuespinlock);
 	}
 
-	if (remaining) {
-		spin_lock_irq(&queuespinlock);
+	if (pendingq_count)
 		z90crypt_schedule_reader_timer();
-		spin_unlock_irq(&queuespinlock);
-	}
 }
 
 static inline void
@@ -2606,7 +2745,7 @@
 		pq_p->status[0] |= STAT_FAILED;
 		unbuild_caller(LONG2DEVPTR(pq_p->devindex),
 			       (struct caller *)pq_p->requestptr);
-		list_del(lptr);
+		list_del_init(lptr);
 		pendingq_count--;
 		pq_p->audit[1] |= FP_NOTPENDING;
 		pq_p->audit[1] |= FP_AWAKENING;
@@ -2618,7 +2757,7 @@
 		pq_p = list_entry(lptr, struct work_element, liste);
 		pq_p->retcode = -ENODEV;
 		pq_p->status[0] |= STAT_FAILED;
-		list_del(lptr);
+		list_del_init(lptr);
 		requestq_count--;
 		pq_p->audit[1] |= FP_REMREQUEST;
 		pq_p->audit[1] |= FP_AWAKENING;
@@ -2640,12 +2779,21 @@
 		pq_p = list_entry(lptr, struct work_element, liste);
 		if (pq_p->requestsent >= timelimit)
 			break;
+		PRINTKW("Purging(PQ) PSMID %02X%02X%02X%02X%02X%02X%02X%02X\n",
+		       ((struct caller *)pq_p->requestptr)->caller_id[0],
+		       ((struct caller *)pq_p->requestptr)->caller_id[1],
+		       ((struct caller *)pq_p->requestptr)->caller_id[2],
+		       ((struct caller *)pq_p->requestptr)->caller_id[3],
+		       ((struct caller *)pq_p->requestptr)->caller_id[4],
+		       ((struct caller *)pq_p->requestptr)->caller_id[5],
+		       ((struct caller *)pq_p->requestptr)->caller_id[6],
+		       ((struct caller *)pq_p->requestptr)->caller_id[7]);
 		pq_p->retcode = -ETIMEOUT;
 		pq_p->status[0] |= STAT_FAILED;
 		/* get this off any caller queue it may be on */
 		unbuild_caller(LONG2DEVPTR(pq_p->devindex),
 			       (struct caller *) pq_p->requestptr);
-		list_del(lptr);
+		list_del_init(lptr);
 		pendingq_count--;
 		pq_p->audit[1] |= FP_TIMEDOUT;
 		pq_p->audit[1] |= FP_NOTPENDING;
@@ -2663,9 +2811,18 @@
 			pq_p = list_entry(lptr, struct work_element, liste);
 			if (pq_p->requestsent >= timelimit)
 				break;
+		PRINTKW("Purging(RQ) PSMID %02X%02X%02X%02X%02X%02X%02X%02X\n",
+		       ((struct caller *)pq_p->requestptr)->caller_id[0],
+		       ((struct caller *)pq_p->requestptr)->caller_id[1],
+		       ((struct caller *)pq_p->requestptr)->caller_id[2],
+		       ((struct caller *)pq_p->requestptr)->caller_id[3],
+		       ((struct caller *)pq_p->requestptr)->caller_id[4],
+		       ((struct caller *)pq_p->requestptr)->caller_id[5],
+		       ((struct caller *)pq_p->requestptr)->caller_id[6],
+		       ((struct caller *)pq_p->requestptr)->caller_id[7]);
 			pq_p->retcode = -ETIMEOUT;
 			pq_p->status[0] |= STAT_FAILED;
-			list_del(lptr);
+			list_del_init(lptr);
 			requestq_count--;
 			pq_p->audit[1] |= FP_TIMEDOUT;
 			pq_p->audit[1] |= FP_REMREQUEST;
@@ -2737,15 +2894,15 @@
 {
 	enum hdstat hd_stat;
 	int q_depth, dev_type;
-	int i, j, k;
+	int indx, chkdom, numdomains;
 
-	q_depth = dev_type = k = 0;
-	for (i = 0; i < z90crypt.max_count; i++) {
+	q_depth = dev_type = numdomains = 0;
+	for (chkdom = 0; chkdom <= 15; cdx_array[chkdom++] = -1);
+	for (indx = 0; indx < z90crypt.max_count; indx++) {
 		hd_stat = HD_NOT_THERE;
-		for (j = 0; j <= 15; cdx_array[j++] = -1);
-		k = 0;
-		for (j = 0; j <= 15; j++) {
-			hd_stat = query_online(i, j, MAX_RESET,
+		numdomains = 0;
+		for (chkdom = 0; chkdom <= 15; chkdom++) {
+			hd_stat = query_online(indx, chkdom, MAX_RESET,
 					       &q_depth, &dev_type);
 			if (hd_stat == HD_TSQ_EXCEPTION) {
 				z90crypt.terminating = 1;
@@ -2753,29 +2910,30 @@
 				break;
 			}
 			if (hd_stat == HD_ONLINE) {
-				cdx_array[k++] = j;
-				if (*cdx_p == j) {
+				cdx_array[numdomains++] = chkdom;
+				if (*cdx_p == chkdom) {
 					*correct_cdx_found  = 1;
 					break;
 				}
 			}
 		}
-		if ((*correct_cdx_found == 1) || (k != 0))
+		if ((*correct_cdx_found == 1) || (numdomains != 0))
 			break;
 		if (z90crypt.terminating)
 			break;
 	}
-	return k;
+	return numdomains;
 }
 
 static inline int
 probe_crypto_domain(int *cdx_p)
 {
 	int cdx_array[16];
-	int correct_cdx_found, k;
+	char cdx_array_text[53], temp[5];
+	int correct_cdx_found, numdomains;
 
 	correct_cdx_found = 0;
-	k = helper_scan_devices(cdx_array, cdx_p, &correct_cdx_found);
+	numdomains = helper_scan_devices(cdx_array, cdx_p, &correct_cdx_found);
 
 	if (z90crypt.terminating)
 		return TSQ_FATAL_ERROR;
@@ -2783,23 +2941,31 @@
 	if (correct_cdx_found)
 		return 0;
 
-	if (k == 0) {
-		*cdx_p = 0;
-		return 0;
+	if (numdomains == 0) {
+		PRINTKW("Unable to find crypto domain: No devices found\n");
+		return Z90C_NO_DEVICES;
 	}
 
-	if (k == 1) {
-		if ((*cdx_p == -1) || !z90crypt.domain_established) {
+	if (numdomains == 1) {
+		if (*cdx_p == -1) {
 			*cdx_p = cdx_array[0];
 			return 0;
 		}
-		if (*cdx_p != cdx_array[0]) {
-			PRINTK("incorrect domain: specified = %d, found = %d\n",
-			       *cdx_p, cdx_array[0]);
-			return Z90C_INCORRECT_DOMAIN;
-		}
+		PRINTKW("incorrect domain: specified = %d, found = %d\n",
+		       *cdx_p, cdx_array[0]);
+		return Z90C_INCORRECT_DOMAIN;
 	}
 
+	numdomains--;
+	sprintf(cdx_array_text, "%d", cdx_array[numdomains]);
+	while (numdomains) {
+		numdomains--;
+		sprintf(temp, ", %d", cdx_array[numdomains]);
+		strcat(cdx_array_text, temp);
+	}
+
+	PRINTKW("ambiguous domain detected: specified = %d, found array = %s\n",
+		*cdx_p, cdx_array_text);
 	return Z90C_AMBIGUOUS_DOMAIN;
 }
 
@@ -2807,7 +2973,7 @@
 refresh_z90crypt(int *cdx_p)
 {
 	int i, j, indx, rv;
-	struct status local_mask;
+	static struct status local_mask;
 	struct device *devPtr;
 	unsigned char oldStat, newStat;
 	int return_unchanged;
@@ -2818,25 +2984,14 @@
 		return TSQ_FATAL_ERROR;
 	rv = 0;
 	if (!z90crypt.hdware_info->hdware_mask.st_count &&
-	    !z90crypt.domain_established)
+	    !z90crypt.domain_established) {
 		rv = probe_crypto_domain(cdx_p);
-	if (z90crypt.terminating)
-		return TSQ_FATAL_ERROR;
-	if (rv) {
-		switch (rv) {
-		case Z90C_AMBIGUOUS_DOMAIN:
-			PRINTK("ambiguous domain detected\n");
-			break;
-		case Z90C_INCORRECT_DOMAIN:
-			PRINTK("incorrect domain specified\n");
-			break;
-		default:
-			PRINTK("probe domain returned %d\n", rv);
-			break;
-		}
-		return rv;
-	}
-	if (*cdx_p) {
+		if (z90crypt.terminating)
+			return TSQ_FATAL_ERROR;
+		if (rv == Z90C_NO_DEVICES)
+			return 0; // try later
+		if (rv)
+			return rv;
 		z90crypt.cdx = *cdx_p;
 		z90crypt.domain_established = 1;
 	}
@@ -2999,14 +3154,28 @@
 				return rv;
 			}
 		}
+		if (dev_ptr->dev_type == PCIXCC_UNK) {
+			rv = probe_PCIXCC_type(dev_ptr);
+			if (rv) {
+				PRINTK("rv = %d from probe_PCIXCC_type %d\n",
+				       rv, index);
+				kfree(dev_ptr->dev_resp_p);
+				kfree(dev_ptr);
+				return rv;
+			}
+		}
 		deviceType = dev_ptr->dev_type;
 		z90crypt.dev_type_array[index] = deviceType;
 		if (deviceType == PCICA)
 			z90crypt.hdware_info->device_type_array[index] = 1;
 		else if (deviceType == PCICC)
 			z90crypt.hdware_info->device_type_array[index] = 2;
-		else if (deviceType == PCIXCC)
+		else if (deviceType == PCIXCC_MCL2)
 			z90crypt.hdware_info->device_type_array[index] = 3;
+		else if (deviceType == PCIXCC_MCL3)
+			z90crypt.hdware_info->device_type_array[index] = 4;
+		else if (deviceType == CEX2C)
+			z90crypt.hdware_info->device_type_array[index] = 5;
 		else
 			z90crypt.hdware_info->device_type_array[index] = -1;
 	}
@@ -3086,7 +3255,7 @@
 	memset((void *)&z90crypt, 0, sizeof(z90crypt));
 }
 
-static unsigned char static_testmsg[] = {
+static unsigned char static_testmsg[384] = {
 0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x00,0x06,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x43,0x43,
@@ -3118,7 +3287,7 @@
 {
 	int rv, dv, i, index, length;
 	unsigned char psmid[8];
-	static unsigned char loc_testmsg[384];
+	static unsigned char loc_testmsg[sizeof(static_testmsg)];
 
 	index = devPtr->dev_self_x;
 	rv = 0;
@@ -3212,8 +3381,146 @@
 	return rv;
 }
 
+static unsigned char MCL3_testmsg[] = {
+0x00,0x00,0x00,0x00,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
+0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x43,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x50,0x4B,0x00,0x00,0x00,0x00,0x01,0xC4,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x24,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x02,0x00,0x00,0x00,0x54,0x32,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE8,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x24,
+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,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,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,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,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,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x04,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,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x50,0x4B,0x00,0x0A,0x4D,0x52,0x50,0x20,0x20,0x20,0x20,0x20,
+0x00,0x42,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,
+0x0E,0x0F,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,
+0xEE,0xFF,0xFF,0xEE,0xDD,0xCC,0xBB,0xAA,0x99,0x88,0x77,0x66,0x55,0x44,0x33,0x22,
+0x11,0x00,0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,0xFE,0xDC,0xBA,0x98,0x76,0x54,
+0x32,0x10,0x00,0x9A,0x00,0x98,0x00,0x00,0x1E,0x00,0x00,0x94,0x00,0x00,0x00,0x00,
+0x04,0x00,0x00,0x8C,0x00,0x00,0x00,0x40,0x02,0x00,0x00,0x40,0xBA,0xE8,0x23,0x3C,
+0x75,0xF3,0x91,0x61,0xD6,0x73,0x39,0xCF,0x7B,0x6D,0x8E,0x61,0x97,0x63,0x9E,0xD9,
+0x60,0x55,0xD6,0xC7,0xEF,0xF8,0x1E,0x63,0x95,0x17,0xCC,0x28,0x45,0x60,0x11,0xC5,
+0xC4,0x4E,0x66,0xC6,0xE6,0xC3,0xDE,0x8A,0x19,0x30,0xCF,0x0E,0xD7,0xAA,0xDB,0x01,
+0xD8,0x00,0xBB,0x8F,0x39,0x9F,0x64,0x28,0xF5,0x7A,0x77,0x49,0xCC,0x6B,0xA3,0x91,
+0x97,0x70,0xE7,0x60,0x1E,0x39,0xE1,0xE5,0x33,0xE1,0x15,0x63,0x69,0x08,0x80,0x4C,
+0x67,0xC4,0x41,0x8F,0x48,0xDF,0x26,0x98,0xF1,0xD5,0x8D,0x88,0xD9,0x6A,0xA4,0x96,
+0xC5,0x84,0xD9,0x30,0x49,0x67,0x7D,0x19,0xB1,0xB3,0x45,0x4D,0xB2,0x53,0x9A,0x47,
+0x3C,0x7C,0x55,0xBF,0xCC,0x85,0x00,0x36,0xF1,0x3D,0x93,0x53
+};
+
+static int
+probe_PCIXCC_type(struct device *devPtr)
+{
+	int rv, dv, i, index, length;
+	unsigned char psmid[8];
+	static unsigned char loc_testmsg[548];
+	struct CPRBX *cprbx_p;
+
+	index = devPtr->dev_self_x;
+	rv = 0;
+	do {
+		memcpy(loc_testmsg, MCL3_testmsg, sizeof(MCL3_testmsg));
+		length = sizeof(MCL3_testmsg) - 0x0C;
+		dv = send_to_AP(index, z90crypt.cdx, length, loc_testmsg);
+		if (dv) {
+			PDEBUG("dv returned = %d\n", dv);
+			if (dv == DEV_SEN_EXCEPTION) {
+				rv = SEN_FATAL_ERROR;
+				PRINTKC("exception in send to AP %d\n", index);
+				break;
+			}
+			PDEBUG("return value from send_to_AP: %d\n", rv);
+			switch (dv) {
+			case DEV_GONE:
+				PDEBUG("dev %d not available\n", index);
+				rv = SEN_NOT_AVAIL;
+				break;
+			case DEV_ONLINE:
+				rv = 0;
+				break;
+			case DEV_EMPTY:
+				rv = SEN_NOT_AVAIL;
+				break;
+			case DEV_NO_WORK:
+				rv = SEN_FATAL_ERROR;
+				break;
+			case DEV_BAD_MESSAGE:
+				rv = SEN_USER_ERROR;
+				break;
+			case DEV_QUEUE_FULL:
+				rv = SEN_QUEUE_FULL;
+				break;
+			default:
+				PRINTK("unknown dv=%d for dev %d\n", dv, index);
+				rv = SEN_NOT_AVAIL;
+				break;
+			}
+		}
+
+		if (rv)
+			break;
+
+		for (i = 0; i < 6; i++) {
+			mdelay(300);
+			dv = receive_from_AP(index, z90crypt.cdx,
+					     devPtr->dev_resp_l,
+					     devPtr->dev_resp_p, psmid);
+			PDEBUG("dv returned by DQ = %d\n", dv);
+			if (dv == DEV_REC_EXCEPTION) {
+				rv = REC_FATAL_ERROR;
+				PRINTKC("exception in dequeue %d\n",
+					index);
+				break;
+			}
+			switch (dv) {
+			case DEV_ONLINE:
+				rv = 0;
+				break;
+			case DEV_EMPTY:
+				rv = REC_EMPTY;
+				break;
+			case DEV_NO_WORK:
+				rv = REC_NO_WORK;
+				break;
+			case DEV_BAD_MESSAGE:
+			case DEV_GONE:
+			default:
+				rv = REC_NO_RESPONSE;
+				break;
+			}
+			if ((rv != 0) && (rv != REC_NO_WORK))
+				break;
+			if (rv == 0)
+				break;
+		}
+		if (rv)
+			break;
+		cprbx_p = (struct CPRBX *) (devPtr->dev_resp_p + 48);
+		if ((cprbx_p->ccp_rtcode == 8) && (cprbx_p->ccp_rscode == 33)) {
+			devPtr->dev_type = PCIXCC_MCL2;
+			PDEBUG("device %d is MCL2\n", index);
+		} else {
+			devPtr->dev_type = PCIXCC_MCL3;
+			PDEBUG("device %d is MCL3\n", index);
+		}
+	} while (0);
+	/* In a general error case, the card is not marked online */
+	return rv;
+}
+
 #ifdef Z90CRYPT_USE_HOTPLUG
-void
+static void
 z90crypt_hotplug_event(int dev_major, int dev_minor, int action)
 {
 #ifdef CONFIG_HOTPLUG
@@ -3241,6 +3548,7 @@
 		break;
 	default:
 		BUG();
+		break;
 	}
 	envp[3] = major;
 	envp[4] = minor;
diff -Nru a/drivers/s390/net/ctcdbug.h b/drivers/s390/net/ctcdbug.h
--- a/drivers/s390/net/ctcdbug.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/s390/net/ctcdbug.h	2004-12-24 13:36:47 -08:00
@@ -1,6 +1,6 @@
 /*
  *
- * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.3 $)
+ * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.4 $)
  *
  * CTC / ESCON network driver - s390 dbf exploit.
  *
@@ -9,7 +9,7 @@
  *    Author(s): Original Code written by
  *			  Peter Tiedemann (ptiedem@de.ibm.com)
  *
- *    $Revision: 1.3 $	 $Date: 2004/07/28 12:27:54 $
+ *    $Revision: 1.4 $	 $Date: 2004/10/15 09:26:58 $
  *
  * 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
@@ -59,7 +59,7 @@
 		debug_event(ctc_dbf_##name,level,(void*)(addr),len); \
 	} while (0)
 
-extern DEFINE_PER_CPU(char[256], ctc_dbf_txt_buf);
+DECLARE_PER_CPU(char[256], ctc_dbf_txt_buf);
 extern debug_info_t *ctc_dbf_setup;
 extern debug_info_t *ctc_dbf_data;
 extern debug_info_t *ctc_dbf_trace;
diff -Nru a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
--- a/drivers/s390/net/ctcmain.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/s390/net/ctcmain.c	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,5 @@
 /*
- * $Id: ctcmain.c,v 1.63 2004/07/28 12:27:54 ptiedem Exp $
+ * $Id: ctcmain.c,v 1.65 2004/10/27 09:12:48 mschwide Exp $
  *
  * CTC / ESCON network driver
  *
@@ -36,7 +36,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.63 $
+ * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.65 $
  *
  */
 
@@ -51,6 +51,7 @@
 #include <linux/interrupt.h>
 #include <linux/timer.h>
 #include <linux/sched.h>
+#include <linux/bitops.h>
 
 #include <linux/signal.h>
 #include <linux/string.h>
@@ -65,7 +66,6 @@
 #include <asm/io.h>
 #include <asm/ccwdev.h>
 #include <asm/ccwgroup.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 #include <asm/idals.h>
@@ -320,7 +320,7 @@
 print_banner(void)
 {
 	static int printed = 0;
-	char vbuf[] = "$Revision: 1.63 $";
+	char vbuf[] = "$Revision: 1.65 $";
 	char *version = vbuf;
 
 	if (printed)
@@ -1224,7 +1224,9 @@
 	fsm_deltimer(&ch->timer);
 	fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch);
 	fsm_newstate(fi, CH_STATE_SETUPWAIT);
-	if (event == CH_EVENT_TIMER)
+	saveflags = 0;	/* avoids compiler warning with
+			   spin_unlock_irqrestore */
+	if (event == CH_EVENT_TIMER)	// only for timer not yet locked
 		spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
 	rc = ccw_device_start(ch->cdev, &ch->ccw[6], (unsigned long) ch, 0xff, 0);
 	if (event == CH_EVENT_TIMER)
@@ -1335,7 +1337,9 @@
 	DBF_TEXT(trace, 3, __FUNCTION__);
 	fsm_deltimer(&ch->timer);
 	fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch);
-	if (event == CH_EVENT_STOP)
+	saveflags = 0;	/* avoids comp warning with
+			   spin_unlock_irqrestore */
+	if (event == CH_EVENT_STOP)	// only for STOP not yet locked
 		spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
 	oldstate = fsm_getstate(fi);
 	fsm_newstate(fi, CH_STATE_TERM);
@@ -1508,7 +1512,9 @@
 	fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch);
 	oldstate = fsm_getstate(fi);
 	fsm_newstate(fi, CH_STATE_STARTWAIT);
-	if (event == CH_EVENT_TIMER)
+	saveflags = 0;	/* avoids compiler warning with
+			   spin_unlock_irqrestore */
+	if (event == CH_EVENT_TIMER)	// only for timer not yet locked
 		spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
 	rc = ccw_device_halt(ch->cdev, (unsigned long) ch);
 	if (event == CH_EVENT_TIMER)
@@ -1674,7 +1680,9 @@
 				return;
 			}
 			fsm_addtimer(&ch->timer, 1000, CH_EVENT_TIMER, ch);
-			if (event == CH_EVENT_TIMER)
+			saveflags = 0;	/* avoids compiler warning with
+					   spin_unlock_irqrestore */
+			if (event == CH_EVENT_TIMER) // only for TIMER not yet locked
 				spin_lock_irqsave(get_ccwdev_lock(ch->cdev),
 						  saveflags);
 			rc = ccw_device_start(ch->cdev, &ch->ccw[3],
diff -Nru a/drivers/s390/net/ctctty.c b/drivers/s390/net/ctctty.c
--- a/drivers/s390/net/ctctty.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/s390/net/ctctty.c	2004-12-24 13:36:56 -08:00
@@ -489,7 +489,7 @@
  *  - If dialing, abort dial.
  */
 static int
-ctc_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int count)
+ctc_tty_write(struct tty_struct *tty, const u_char * buf, int count)
 {
 	int c;
 	int total = 0;
@@ -506,8 +506,6 @@
 		total = -ENODEV;
 		goto ex;
 	}
-	if (from_user)
-		down(&info->write_sem);
 	while (1) {
 		struct sk_buff *skb;
 		int skb_res;
@@ -526,11 +524,7 @@
 			break;
 		}
 		skb_reserve(skb, skb_res);
-		if (from_user)
-			copy_from_user(skb_put(skb, c),
-					(const u_char __user *)buf, c);
-		else
-			memcpy(skb_put(skb, c), buf, c);
+		memcpy(skb_put(skb, c), buf, c);
 		skb_queue_tail(&info->tx_queue, skb);
 		buf += c;
 		total += c;
@@ -540,8 +534,6 @@
 		info->lsr &= ~UART_LSR_TEMT;
 		tasklet_schedule(&info->tasklet);
 	}
-	if (from_user)
-		up(&info->write_sem);
 ex:
 	DBF_TEXT(trace, 6, __FUNCTION__);
 	return total;
diff -Nru a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
--- a/drivers/s390/net/iucv.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/s390/net/iucv.c	2004-12-24 13:36:18 -08:00
@@ -1,5 +1,5 @@
 /* 
- * $Id: iucv.c,v 1.40 2004/08/04 12:29:33 cborntra Exp $
+ * $Id: iucv.c,v 1.41 2004/08/11 14:54:14 geraldsc Exp $
  *
  * IUCV network driver
  *
@@ -29,7 +29,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.40 $
+ * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.41 $
  *
  */
 
@@ -355,7 +355,7 @@
 static void
 iucv_banner(void)
 {
-	char vbuf[] = "$Revision: 1.40 $";
+	char vbuf[] = "$Revision: 1.41 $";
 	char *version = vbuf;
 
 	if ((version = strchr(version, ':'))) {
@@ -2550,9 +2550,9 @@
 #if 0
 EXPORT_SYMBOL (iucv_reply);
 EXPORT_SYMBOL (iucv_reply_array);
-EXPORT_SYMBOL (iucv_reply_prmmsg);
 EXPORT_SYMBOL (iucv_resume);
 #endif
+EXPORT_SYMBOL (iucv_reply_prmmsg);
 EXPORT_SYMBOL (iucv_send);
 #if 0
 EXPORT_SYMBOL (iucv_send2way);
diff -Nru a/drivers/s390/net/iucv.h b/drivers/s390/net/iucv.h
--- a/drivers/s390/net/iucv.h	2004-12-24 13:37:32 -08:00
+++ b/drivers/s390/net/iucv.h	2004-12-24 13:37:32 -08:00
@@ -63,7 +63,7 @@
 		debug_event(iucv_dbf_##name,level,(void*)(addr),len); \
 	} while (0)
 
-extern DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);
+DECLARE_PER_CPU(char[256], iucv_dbf_txt_buf);
 
 #define IUCV_DBF_TEXT_(name,level,text...)				\
 	do {								\
@@ -231,7 +231,10 @@
 	uchar iptype;
 	u32 ipmsgid;
 	u32 iptrgcls;
-	uchar iprmmsg1[4];
+	union u2 {
+		u32 iprmmsg1_u32;
+		uchar iprmmsg1[4];
+	} ln1msg1;
 	union u1 {
 		u32 ipbfln1f;
 		uchar iprmmsg2[4];
diff -Nru a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
--- a/drivers/s390/net/lcs.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/s390/net/lcs.c	2004-12-24 13:36:18 -08:00
@@ -11,7 +11,7 @@
  *			  Frank Pavlic (pavlic@de.ibm.com) and
  *		 	  Martin Schwidefsky <schwidefsky@de.ibm.com>
  *
- *    $Revision: 1.92 $	 $Date: 2004/09/03 08:06:11 $
+ *    $Revision: 1.96 $	 $Date: 2004/11/11 13:42:33 $
  *
  * 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
@@ -59,7 +59,7 @@
 /**
  * initialization string for output
  */
-#define VERSION_LCS_C  "$Revision: 1.92 $"
+#define VERSION_LCS_C  "$Revision: 1.96 $"
 
 static char version[] __initdata = "LCS driver ("VERSION_LCS_C "/" VERSION_LCS_H ")";
 static char debug_buffer[255];
@@ -191,6 +191,7 @@
 		return NULL;
 	memset(card, 0, sizeof(struct lcs_card));
 	card->lan_type = LCS_FRAME_TYPE_AUTO;
+	card->pkt_seq = 0;
 	card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT;
 	/* Allocate io buffers for the read channel. */
 	rc = lcs_alloc_channel(&card->read);
@@ -549,6 +550,7 @@
 		return 0;
 	LCS_DBF_TEXT(4,trace,"haltsch");
 	LCS_DBF_TEXT_(4,trace,"%s", channel->ccwdev->dev.bus_id);
+	channel->state = CH_STATE_INIT;
 	spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
 	rc = ccw_device_halt(channel->ccwdev, (addr_t) channel);
 	spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
@@ -1357,6 +1359,7 @@
 
 	LCS_DBF_TEXT_(5, trace, "Rint%s",cdev->dev.bus_id);
 	LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.cstat, irb->scsw.dstat);
+	LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.fctl, irb->scsw.actl);
 
 	/* How far in the ccw chain have we processed? */
 	if ((channel->state != CH_STATE_INIT) &&
@@ -1624,8 +1627,6 @@
 	/* start/reset card */
 	if (card->dev)
 		netif_stop_queue(card->dev);
-	card->write.state = CH_STATE_INIT;
-	card->read.state = CH_STATE_INIT;
 	rc = lcs_stop_channels(card);
 	if (rc == 0) {
 		rc = lcs_start_channels(card);
@@ -1874,6 +1875,7 @@
 	skb->protocol =	card->lan_type_trans(skb, card->dev);
 	card->stats.rx_bytes += skb_len;
 	card->stats.rx_packets++;
+	*((__u32 *)skb->cb) = ++card->pkt_seq;
 	netif_rx(skb);
 }
 
diff -Nru a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
--- a/drivers/s390/net/lcs.h	2004-12-24 13:37:03 -08:00
+++ b/drivers/s390/net/lcs.h	2004-12-24 13:37:03 -08:00
@@ -6,7 +6,7 @@
 #include <linux/workqueue.h>
 #include <asm/ccwdev.h>
 
-#define VERSION_LCS_H "$Revision: 1.18 $"
+#define VERSION_LCS_H "$Revision: 1.19 $"
 
 #define LCS_DBF_TEXT(level, name, text) \
 	do { \
@@ -309,6 +309,7 @@
 	__u16 ip_assists_supported;
 	__u16 ip_assists_enabled;
 	__s8 lan_type;
+	__u32 pkt_seq;
 	__u16 sequence_no;
 	__s16 portno;
 	/* Some info copied from probeinfo */
diff -Nru a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
--- a/drivers/s390/net/netiucv.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/s390/net/netiucv.c	2004-12-24 13:36:59 -08:00
@@ -45,6 +45,7 @@
 #include <linux/interrupt.h>
 #include <linux/timer.h>
 #include <linux/sched.h>
+#include <linux/bitops.h>
 
 #include <linux/signal.h>
 #include <linux/string.h>
@@ -58,7 +59,6 @@
 #include <net/dst.h>
 
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 #include "iucv.h"
diff -Nru a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
--- a/drivers/s390/net/qeth.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/s390/net/qeth.h	2004-12-24 13:36:17 -08:00
@@ -15,7 +15,8 @@
 #include <net/addrconf.h>
 
 
-#include <asm/bitops.h>
+#include <linux/bitops.h>
+
 #include <asm/debug.h>
 #include <asm/qdio.h>
 #include <asm/ccwdev.h>
@@ -23,7 +24,7 @@
 
 #include "qeth_mpc.h"
 
-#define VERSION_QETH_H 		"$Revision: 1.113 $"
+#define VERSION_QETH_H 		"$Revision: 1.124 $"
 
 #ifdef CONFIG_QETH_IPV6
 #define QETH_VERSION_IPV6 	":IPv6"
@@ -43,7 +44,7 @@
 #define QETH_DBF_SETUP_LEN 8
 #define QETH_DBF_SETUP_INDEX 3
 #define QETH_DBF_SETUP_NR_AREAS 1
-#define QETH_DBF_SETUP_LEVEL 3
+#define QETH_DBF_SETUP_LEVEL 5
 
 #define QETH_DBF_MISC_NAME "qeth_misc"
 #define QETH_DBF_MISC_LEN 128
@@ -61,13 +62,13 @@
 #define QETH_DBF_CONTROL_LEN 256
 #define QETH_DBF_CONTROL_INDEX 3
 #define QETH_DBF_CONTROL_NR_AREAS 2
-#define QETH_DBF_CONTROL_LEVEL 2
+#define QETH_DBF_CONTROL_LEVEL 5
 
 #define QETH_DBF_TRACE_NAME "qeth_trace"
 #define QETH_DBF_TRACE_LEN 8
 #define QETH_DBF_TRACE_INDEX 2
 #define QETH_DBF_TRACE_NR_AREAS 2
-#define QETH_DBF_TRACE_LEVEL 3
+#define QETH_DBF_TRACE_LEVEL 5
 
 #define QETH_DBF_SENSE_NAME "qeth_sense"
 #define QETH_DBF_SENSE_LEN 64
@@ -91,7 +92,7 @@
 		debug_event(qeth_dbf_##name,level,(void*)(addr),len); \
 	} while (0)
 
-extern DEFINE_PER_CPU(char[256], qeth_dbf_txt_buf);
+DECLARE_PER_CPU(char[256], qeth_dbf_txt_buf);
 
 #define QETH_DBF_TEXT_(name,level,text...)				\
 	do {								\
@@ -329,12 +330,8 @@
 #define QETH_WATERMARK_PACK_FUZZ 1
 
 #define QETH_IP_HEADER_SIZE 40
-/* VLAN defines */
-#define QETH_EXT_HDR_VLAN_FRAME        0x01
-#define QETH_EXT_HDR_TOKEN_ID          0x02
-#define QETH_EXT_HDR_INCLUDE_VLAN_TAG  0x04
 
-struct qeth_hdr {
+struct qeth_hdr_layer3 {
 	__u8  id;
 	__u8  flags;
 	__u16 inbound_checksum;
@@ -347,6 +344,26 @@
 	__u8  dest_addr[16];
 } __attribute__ ((packed));
 
+struct qeth_hdr_layer2 {
+	__u8 id;
+	__u8 flags[3];
+	__u8 port_no;
+	__u8 hdr_length;
+	__u16 pkt_length;
+	__u16 seq_no;
+	__u16 vlan_id;
+	__u32 reserved;
+	__u8 reserved2[16];
+} __attribute__ ((packed));
+
+struct qeth_hdr {
+	union {
+		struct qeth_hdr_layer2 l2;
+		struct qeth_hdr_layer3 l3;
+	} hdr;
+} __attribute__ ((packed));
+
+
 /* flags for qeth_hdr.flags */
 #define QETH_HDR_PASSTHRU 0x10
 #define QETH_HDR_IPV6     0x80
@@ -359,11 +376,24 @@
 	QETH_CAST_NOCAST    = 0x00,
 };
 
+enum qeth_layer2_frame_flags {
+	QETH_LAYER2_FLAG_MULTICAST = 0x01,
+	QETH_LAYER2_FLAG_BROADCAST = 0x02,
+	QETH_LAYER2_FLAG_UNICAST   = 0x04,
+	QETH_LAYER2_FLAG_VLAN      = 0x10,
+};
+
+enum qeth_header_ids {
+	QETH_HEADER_TYPE_LAYER3 = 0x01,
+	QETH_HEADER_TYPE_LAYER2 = 0x02,
+};
 /* flags for qeth_hdr.ext_flags */
-#define QETH_HDR_EXT_VLAN_FRAME      0x01
-#define QETH_HDR_EXT_CSUM_HDR_REQ    0x10
-#define QETH_HDR_EXT_CSUM_TRANSP_REQ 0x20
-#define QETH_HDR_EXT_SRC_MAC_ADDR    0x08
+#define QETH_HDR_EXT_VLAN_FRAME       0x01
+#define QETH_HDR_EXT_TOKEN_ID         0x02
+#define QETH_HDR_EXT_INCLUDE_VLAN_TAG 0x04
+#define QETH_HDR_EXT_SRC_MAC_ADDR     0x08
+#define QETH_HDR_EXT_CSUM_HDR_REQ     0x10
+#define QETH_HDR_EXT_CSUM_TRANSP_REQ  0x20
 
 static inline int
 qeth_is_last_sbale(struct qdio_buffer_element *sbale)
@@ -525,6 +555,7 @@
 	QETH_IP_TYPE_NORMAL,
 	QETH_IP_TYPE_VIPA,
 	QETH_IP_TYPE_RXIP,
+	QETH_IP_TYPE_DEL_ALL_MC,
 };
 
 enum qeth_cmd_buffer_state {
@@ -645,6 +676,7 @@
 	__u16 func_level;
 	char mcl_level[QETH_MCL_LENGTH + 1];
 	int guestlan;
+	int layer2_mac_registered;
 	int portname_required;
 	int portno;
 	char portname[9];
@@ -672,6 +704,7 @@
 	int fake_broadcast;
 	int add_hhlen;
 	int fake_ll;
+	int layer2;
 };
 
 /*
@@ -679,8 +712,7 @@
  */
 enum qeth_threads {
 	QETH_SET_IP_THREAD  = 1,
-	QETH_SET_MC_THREAD  = 2,
-	QETH_RECOVER_THREAD = 4,
+	QETH_RECOVER_THREAD = 2,
 };
 
 struct qeth_card {
@@ -714,7 +746,7 @@
 	volatile unsigned long thread_running_mask;
 	spinlock_t ip_lock;
 	struct list_head ip_list;
-	struct list_head ip_tbd_list;
+	struct list_head *ip_tbd_list;
 	struct qeth_ipato ipato;
 	struct list_head cmd_waiter_list;
 	/* QDIO buffer handling */
@@ -779,9 +811,11 @@
 }
 
 inline static unsigned short
-qeth_get_netdev_flags(int cardtype)
+qeth_get_netdev_flags(struct qeth_card *card)
 {
-	switch (cardtype) {
+	if (card->options.layer2)
+		return 0;
+	switch (card->info.type) {
 	case QETH_CARD_TYPE_IQD:
 		return IFF_NOARP;
 #ifdef CONFIG_QETH_IPV6
diff -Nru a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
--- a/drivers/s390/net/qeth_main.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/s390/net/qeth_main.c	2004-12-24 13:36:49 -08:00
@@ -1,6 +1,6 @@
 /*
  *
- * linux/drivers/s390/net/qeth_main.c ($Revision: 1.145 $)
+ * linux/drivers/s390/net/qeth_main.c ($Revision: 1.170 $)
  *
  * Linux on zSeries OSA Express and HiperSockets support
  *
@@ -12,7 +12,7 @@
  *			  Frank Pavlic (pavlic@de.ibm.com) and
  *		 	  Thomas Spatzier <tspat@de.ibm.com>
  *
- *    $Revision: 1.145 $	 $Date: 2004/10/08 15:08:40 $
+ *    $Revision: 1.170 $	 $Date: 2004/11/17 09:54:06 $
  *
  * 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
@@ -29,7 +29,6 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-
 /***
  * eye catcher; just for debugging purposes
  */
@@ -79,7 +78,7 @@
 #include "qeth_mpc.h"
 #include "qeth_fs.h"
 
-#define VERSION_QETH_C "$Revision: 1.145 $"
+#define VERSION_QETH_C "$Revision: 1.170 $"
 static const char *version = "qeth S/390 OSA-Express driver";
 
 /**
@@ -161,6 +160,9 @@
 qeth_get_addr_buffer(enum qeth_prot_versions);
 
 static void
+qeth_set_multicast_list(struct net_device *);
+
+static void
 qeth_notify_processes(void)
 {
 	/*notify all  registered processes */
@@ -197,7 +199,7 @@
 {
 	struct qeth_notify_list_struct *n_entry;
 
-	QETH_DBF_TEXT(trace, 2, "notreg");
+
 	/*check first if entry already exists*/
 	spin_lock(&qeth_notify_lock);
 	list_for_each_entry(n_entry, &qeth_notify_list, list) {
@@ -250,6 +252,7 @@
 		free_netdev(card->dev);
 	qeth_clear_ip_list(card, 0, 0);
 	qeth_clear_ipato_list(card);
+	kfree(card->ip_tbd_list);
 	qeth_free_qdio_buffers(card);
 	kfree(card);
 }
@@ -661,7 +664,10 @@
 	struct qeth_ipaddr *tmp, *t;
 	int found = 0;
 
-	list_for_each_entry_safe(tmp, t, &card->ip_tbd_list, entry) {
+	list_for_each_entry_safe(tmp, t, card->ip_tbd_list, entry) {
+		if ((addr->type == QETH_IP_TYPE_DEL_ALL_MC) &&
+		    (tmp->type == QETH_IP_TYPE_DEL_ALL_MC))
+			return 0;
 		if ((tmp->proto        == QETH_PROT_IPV4)     &&
 		    (addr->proto       == QETH_PROT_IPV4)     &&
 		    (tmp->type         == addr->type)         &&
@@ -693,14 +699,18 @@
 		}
 		return 0;
 	} else {
-		if (addr->users == 0)
-			addr->users += add? 1:-1;
-		if (add && (addr->type == QETH_IP_TYPE_NORMAL) &&
-		    qeth_is_addr_covered_by_ipato(card, addr)){
-			QETH_DBF_TEXT(trace, 2, "tkovaddr");
-			addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG;
+		if (addr->type == QETH_IP_TYPE_DEL_ALL_MC)
+			list_add(&addr->entry, card->ip_tbd_list);
+		else {
+			if (addr->users == 0)
+				addr->users += add? 1:-1;
+			if (add && (addr->type == QETH_IP_TYPE_NORMAL) &&
+			    qeth_is_addr_covered_by_ipato(card, addr)){
+				QETH_DBF_TEXT(trace, 2, "tkovaddr");
+				addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG;
+			}
+			list_add_tail(&addr->entry, card->ip_tbd_list);
 		}
-		list_add_tail(&addr->entry, &card->ip_tbd_list);
 		return 1;
 	}
 }
@@ -718,8 +728,8 @@
 	if (addr->proto == QETH_PROT_IPV4)
 		QETH_DBF_HEX(trace,4,&addr->u.a4.addr,4);
 	else {
-		QETH_DBF_HEX(trace,4,&addr->u.a6.addr,4);
-		QETH_DBF_HEX(trace,4,((char *)&addr->u.a6.addr)+4,4);
+		QETH_DBF_HEX(trace,4,&addr->u.a6.addr,8);
+		QETH_DBF_HEX(trace,4,((char *)&addr->u.a6.addr)+8,8);
 	}
 	spin_lock_irqsave(&card->ip_lock, flags);
 	rc = __qeth_insert_ip_todo(card, addr, 0);
@@ -737,8 +747,8 @@
 	if (addr->proto == QETH_PROT_IPV4)
 		QETH_DBF_HEX(trace,4,&addr->u.a4.addr,4);
 	else {
-		QETH_DBF_HEX(trace,4,&addr->u.a6.addr,4);
-		QETH_DBF_HEX(trace,4,((char *)&addr->u.a6.addr)+4,4);
+		QETH_DBF_HEX(trace,4,&addr->u.a6.addr,8);
+		QETH_DBF_HEX(trace,4,((char *)&addr->u.a6.addr)+8,8);
 	}
 	spin_lock_irqsave(&card->ip_lock, flags);
 	rc = __qeth_insert_ip_todo(card, addr, 1);
@@ -746,19 +756,21 @@
 	return rc;
 }
 
-static void
-qeth_reinsert_todos(struct qeth_card *card, struct list_head *todos)
+static inline void
+__qeth_delete_all_mc(struct qeth_card *card, unsigned long *flags)
 {
-	struct qeth_ipaddr *todo, *tmp;
+	struct qeth_ipaddr *addr, *tmp;
+	int rc;
 
-	list_for_each_entry_safe(todo, tmp, todos, entry){
-		list_del_init(&todo->entry);
-		if (todo->users < 0) {
-			if (!qeth_delete_ip(card, todo))
-				kfree(todo);
-		} else {
-			if (!qeth_add_ip(card, todo))
-				kfree(todo);
+	list_for_each_entry_safe(addr, tmp, &card->ip_list, entry) {
+		if (addr->is_multicast) {
+			spin_unlock_irqrestore(&card->ip_lock, *flags);
+			rc = qeth_deregister_addr_entry(card, addr);
+			spin_lock_irqsave(&card->ip_lock, *flags);
+			if (!rc) {
+				list_del(&addr->entry);
+				kfree(addr);
+			}
 		}
 	}
 }
@@ -766,7 +778,7 @@
 static void
 qeth_set_ip_addr_list(struct qeth_card *card)
 {
-	struct list_head failed_todos;
+	struct list_head *tbd_list;
 	struct qeth_ipaddr *todo, *addr;
 	unsigned long flags;
 	int rc;
@@ -774,13 +786,25 @@
 	QETH_DBF_TEXT(trace, 2, "sdiplist");
 	QETH_DBF_HEX(trace, 2, &card, sizeof(void *));
 
-	INIT_LIST_HEAD(&failed_todos);
-
 	spin_lock_irqsave(&card->ip_lock, flags);
-	while (!list_empty(&card->ip_tbd_list)) {
-		todo = list_entry(card->ip_tbd_list.next,
-				  struct qeth_ipaddr, entry);
-		list_del_init(&todo->entry);
+	tbd_list = card->ip_tbd_list;
+	card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_ATOMIC);
+	if (!card->ip_tbd_list) {
+		QETH_DBF_TEXT(trace, 0, "silnomem");
+		card->ip_tbd_list = tbd_list;
+		spin_unlock_irqrestore(&card->ip_lock, flags);
+		return;
+	} else
+		INIT_LIST_HEAD(card->ip_tbd_list);
+
+	while (!list_empty(tbd_list)){
+		todo = list_entry(tbd_list->next, struct qeth_ipaddr, entry);
+		list_del(&todo->entry);
+		if (todo->type == QETH_IP_TYPE_DEL_ALL_MC){
+			__qeth_delete_all_mc(card, &flags);
+			kfree(todo);
+			continue;
+		}
 		rc = __qeth_ref_ip_on_card(card, todo, &addr);
 		if (rc == 0) {
 			/* nothing to be done; only adjusted refcount */
@@ -793,24 +817,22 @@
 			if (!rc)
 				list_add_tail(&todo->entry, &card->ip_list);
 			else
-				list_add_tail(&todo->entry, &failed_todos);
+				kfree(todo);
 		} else if (rc == -1) {
 			/* on-card entry to be removed */
 			list_del_init(&addr->entry);
 			spin_unlock_irqrestore(&card->ip_lock, flags);
 			rc = qeth_deregister_addr_entry(card, addr);
 			spin_lock_irqsave(&card->ip_lock, flags);
-			if (!rc) {
+			if (!rc)
 				kfree(addr);
-				kfree(todo);
-			} else {
+			else
 				list_add_tail(&addr->entry, &card->ip_list);
-				list_add_tail(&todo->entry, &failed_todos);
-			}
+			kfree(todo);
 		}
 	}
 	spin_unlock_irqrestore(&card->ip_lock, flags);
-	qeth_reinsert_todos(card, &failed_todos);
+	kfree(tbd_list);
 }
 
 static void qeth_delete_mc_addresses(struct qeth_card *);
@@ -888,28 +910,7 @@
 }
 
 static int
-qeth_register_mc_addresses(void *ptr)
-{
-	struct qeth_card *card;
-
-	card = (struct qeth_card *) ptr;
-	daemonize("qeth_reg_mcaddrs");
-	QETH_DBF_TEXT(trace,4,"regmcth1");
-	if (!qeth_do_run_thread(card, QETH_SET_MC_THREAD))
-		return 0;
-	QETH_DBF_TEXT(trace,4,"regmcth2");
-	qeth_delete_mc_addresses(card);
-	qeth_add_multicast_ipv4(card);
-#ifdef CONFIG_QETH_IPV6
-	qeth_add_multicast_ipv6(card);
-#endif
-	qeth_set_ip_addr_list(card);
-	qeth_clear_thread_running_bit(card, QETH_SET_MC_THREAD);
-	return 0;
-}
-
-static int
-qeth_register_ip_address(void *ptr)
+qeth_register_ip_addresses(void *ptr)
 {
 	struct qeth_card *card;
 
@@ -989,9 +990,7 @@
 		return;
 
 	if (qeth_do_start_thread(card, QETH_SET_IP_THREAD))
-		kernel_thread(qeth_register_ip_address, (void *) card, SIGCHLD);
-	if (qeth_do_start_thread(card, QETH_SET_MC_THREAD))
-		kernel_thread(qeth_register_mc_addresses, (void *)card,SIGCHLD);
+		kernel_thread(qeth_register_ip_addresses, (void *)card,SIGCHLD);
 	if (qeth_do_start_thread(card, QETH_RECOVER_THREAD))
 		kernel_thread(qeth_recover, (void *) card, SIGCHLD);
 }
@@ -1010,6 +1009,7 @@
 	card->options.fake_broadcast = 0;
 	card->options.add_hhlen = DEFAULT_ADD_HHLEN;
 	card->options.fake_ll = 0;
+	card->options.layer2 = 0;
 }
 
 /**
@@ -1041,7 +1041,12 @@
 	INIT_WORK(&card->kernel_thread_starter,
 		  (void *)qeth_start_kernel_thread,card);
 	INIT_LIST_HEAD(&card->ip_list);
-	INIT_LIST_HEAD(&card->ip_tbd_list);
+	card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL);
+	if (!card->ip_tbd_list) {
+		QETH_DBF_TEXT(setup, 0, "iptbdnom");
+		return -ENOMEM;
+	}
+	INIT_LIST_HEAD(card->ip_tbd_list);
 	INIT_LIST_HEAD(&card->cmd_waiter_list);
 	init_waitqueue_head(&card->wait_q);
 	/* intial options */
@@ -1575,9 +1580,8 @@
 	QETH_DBF_TEXT(trace, 2, "rstipadd");
 
 	qeth_clear_ip_list(card, 0, 1);
-	if ( (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) ||
-	     (qeth_set_thread_start_bit(card, QETH_SET_MC_THREAD) == 0) )
-		schedule_work(&card->kernel_thread_starter);
+	/* this function will also schedule the SET_IP_THREAD */
+	qeth_set_multicast_list(card->dev);
 }
 
 static struct qeth_ipa_cmd *
@@ -1600,10 +1604,7 @@
 					   card->info.if_name,
 					   card->info.chpid);
 				card->lan_online = 0;
-				if (netif_carrier_ok(card->dev)) {
-					netif_carrier_off(card->dev);
-					netif_stop_queue(card->dev);
-				}
+				netif_carrier_off(card->dev);
 				return NULL;
 			case IPA_CMD_STARTLAN:
 				PRINT_INFO("Link reestablished on %s "
@@ -1612,10 +1613,7 @@
 					   card->info.if_name,
 					   card->info.chpid);
 				card->lan_online = 1;
-				if (!netif_carrier_ok(card->dev)) {
-					netif_carrier_on(card->dev);
-					netif_wake_queue(card->dev);
-				}
+				netif_carrier_on(card->dev);
 				qeth_reset_ip_addresses(card);
 				return NULL;
 			case IPA_CMD_REGISTER_LOCAL_ADDR:
@@ -1815,10 +1813,18 @@
 		  void *reply_param)
 {
 	int rc;
+	char prot_type;
 
 	QETH_DBF_TEXT(trace,4,"sendipa");
 
 	memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE);
+
+	if (card->options.layer2)
+		prot_type = QETH_PROT_LAYER2;
+	else
+		prot_type = QETH_PROT_TCPIP;
+
+	memcpy(QETH_IPA_CMD_PROT_TYPE(iob->data),&prot_type,1);
 	memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data),
 	       &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH);
 
@@ -1951,6 +1957,7 @@
 qeth_ulp_enable(struct qeth_card *card)
 {
 	int rc;
+	char prot_type;
 	struct qeth_cmd_buffer *iob;
 
 	/*FIXME: trace view callbacks*/
@@ -1961,7 +1968,12 @@
 
 	*(QETH_ULP_ENABLE_LINKNUM(iob->data)) =
 		(__u8) card->info.portno;
+	if (card->options.layer2)
+		prot_type = QETH_PROT_LAYER2;
+	else
+		prot_type = QETH_PROT_TCPIP;
 
+	memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob->data),&prot_type,1);
 	memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob->data),
 	       &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH);
 	memcpy(QETH_ULP_ENABLE_FILTER_TOKEN(iob->data),
@@ -2084,7 +2096,11 @@
 	*hdr = element->addr + offset;
 
 	offset += sizeof(struct qeth_hdr);
-	skb_len = (*hdr)->length;
+	if (card->options.layer2)
+		skb_len = (*hdr)->hdr.l2.pkt_length;
+	else
+		skb_len = (*hdr)->hdr.l3.length;
+
 	if (!skb_len)
 		return NULL;
 	if (card->options.fake_ll){
@@ -2134,10 +2150,10 @@
 static inline unsigned short
 qeth_type_trans(struct sk_buff *skb, struct net_device *dev)
 {
-	struct ethhdr *eth;
 	struct qeth_card *card;
+	struct ethhdr *eth;
 
-	QETH_DBF_TEXT(trace,5,"typtrans");
+	QETH_DBF_TEXT(trace,6,"typtrans");
 
 	card = (struct qeth_card *)dev->priv;
 #ifdef CONFIG_TR
@@ -2145,9 +2161,8 @@
 	    (card->info.link_type == QETH_LINK_TYPE_LANE_TR))
 	 	return tr_type_trans(skb,dev);
 #endif /* CONFIG_TR */
-
 	skb->mac.raw = skb->data;
-	skb_pull(skb, ETH_ALEN * 2 + sizeof (short));
+	skb_pull(skb, ETH_HLEN );
 	eth = eth_hdr(skb);
 
 	if (*eth->h_dest & 1) {
@@ -2155,9 +2170,9 @@
 			skb->pkt_type = PACKET_BROADCAST;
 		else
 			skb->pkt_type = PACKET_MULTICAST;
-	} else {
+	} else if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN))
 		skb->pkt_type = PACKET_OTHERHOST;
-	}
+
 	if (ntohs(eth->h_proto) >= 1536)
 		return eth->h_proto;
 	if (*(unsigned short *) (skb->data) == 0xFFFF)
@@ -2206,8 +2221,8 @@
 		memcpy(fake_hdr->h_dest, card->dev->dev_addr, ETH_ALEN);
 	}
 	/* the source MAC address */
-	if (hdr->ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR)
-		memcpy(fake_hdr->h_source, &hdr->dest_addr[2], ETH_ALEN);
+	if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR)
+		memcpy(fake_hdr->h_source, &hdr->hdr.l3.dest_addr[2], ETH_ALEN);
 	else
 		memset(fake_hdr->h_source, 0, ETH_ALEN);
 	/* the protocol */
@@ -2221,28 +2236,52 @@
 #ifdef CONFIG_QETH_VLAN
 	u16 *vlan_tag;
 
-	if (hdr->ext_flags & QETH_HDR_EXT_VLAN_FRAME) {
+	if (hdr->hdr.l3.ext_flags &
+	    (QETH_HDR_EXT_VLAN_FRAME | QETH_HDR_EXT_INCLUDE_VLAN_TAG)) {
 		vlan_tag = (u16 *) skb_push(skb, VLAN_HLEN);
-		*vlan_tag = hdr->vlan_id;
+		*vlan_tag = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME)?
+			hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]);
 		*(vlan_tag + 1) = skb->protocol;
 		skb->protocol = __constant_htons(ETH_P_8021Q);
 	}
 #endif /* CONFIG_QETH_VLAN */
 }
 
+static inline __u16
+qeth_layer2_rebuild_skb(struct qeth_card *card, struct sk_buff *skb,
+			struct qeth_hdr *hdr)
+{
+	unsigned short vlan_id = 0;
+
+	skb->pkt_type = PACKET_HOST;
+	if (card->options.checksum_type == NO_CHECKSUMMING)
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
+	else
+		skb->ip_summed = CHECKSUM_NONE;
+#ifdef CONFIG_QETH_VLAN
+	if (hdr->hdr.l2.flags[2] & (QETH_LAYER2_FLAG_VLAN)) {
+		skb_pull(skb, VLAN_HLEN);
+		vlan_id = hdr->hdr.l2.vlan_id;
+	}
+#endif
+	skb->protocol = qeth_type_trans(skb, skb->dev);
+	return vlan_id;
+}
+
 static inline void
 qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb,
 		 struct qeth_hdr *hdr)
 {
 #ifdef CONFIG_QETH_IPV6
-	if (hdr->flags & QETH_HDR_PASSTHRU){
+	if (hdr->hdr.l3.flags & QETH_HDR_PASSTHRU) {
+		skb->pkt_type = PACKET_HOST;
 		skb->protocol = qeth_type_trans(skb, card->dev);
 		return;
 	}
 #endif /* CONFIG_QETH_IPV6 */
-	skb->protocol = htons((hdr->flags & QETH_HDR_IPV6)? ETH_P_IPV6 :
+	skb->protocol = htons((hdr->hdr.l3.flags & QETH_HDR_IPV6)? ETH_P_IPV6 :
 			      ETH_P_IP);
-	switch (hdr->flags & QETH_HDR_CAST_MASK){
+	switch (hdr->hdr.l3.flags & QETH_HDR_CAST_MASK){
 	case QETH_CAST_UNICAST:
 		skb->pkt_type = PACKET_HOST;
 		break;
@@ -2259,13 +2298,14 @@
 	default:
 		skb->pkt_type = PACKET_HOST;
 	}
+	qeth_rebuild_skb_vlan(card, skb, hdr);
 	if (card->options.fake_ll)
 		qeth_rebuild_skb_fake_ll(card, skb, hdr);
 	else
 		skb->mac.raw = skb->data;
 	skb->ip_summed = card->options.checksum_type;
 	if (card->options.checksum_type == HW_CHECKSUMMING){
-		if ( (hdr->ext_flags &
+		if ( (hdr->hdr.l3.ext_flags &
 		      (QETH_HDR_EXT_CSUM_HDR_REQ |
 		       QETH_HDR_EXT_CSUM_TRANSP_REQ)) ==
 		     (QETH_HDR_EXT_CSUM_HDR_REQ |
@@ -2274,7 +2314,6 @@
 		else
 			skb->ip_summed = SW_CHECKSUMMING;
 	}
-	qeth_rebuild_skb_vlan(card, skb, hdr);
 }
 
 static inline void
@@ -2282,10 +2321,11 @@
 			    struct qeth_qdio_buffer *buf, int index)
 {
 	struct qdio_buffer_element *element;
-	int offset;
 	struct sk_buff *skb;
 	struct qeth_hdr *hdr;
+	int offset;
 	int rxrc;
+	__u16 vlan_tag = 0;
 
 	/* get first element of current buffer */
 	element = (struct qdio_buffer_element *)&buf->buffer->element[0];
@@ -2294,14 +2334,22 @@
 	card->perf_stats.bufs_rec++;
 #endif
 	while((skb = qeth_get_next_skb(card, buf->buffer, &element,
-				       &offset, &hdr))){
-		qeth_rebuild_skb(card, skb, hdr);
+				       &offset, &hdr))) {
+		skb->dev = card->dev;
+		if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2)
+			vlan_tag = qeth_layer2_rebuild_skb(card, skb, hdr);
+		else
+			qeth_rebuild_skb(card, skb, hdr);
 		/* is device UP ? */
 		if (!(card->dev->flags & IFF_UP)){
 			dev_kfree_skb_any(skb);
 			continue;
 		}
-		skb->dev = card->dev;
+#ifdef CONFIG_QETH_VLAN
+		if (vlan_tag)
+			vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag);
+		else
+#endif
 		rxrc = netif_rx(skb);
 		card->dev->last_rx = jiffies;
 		card->stats.rx_packets++;
@@ -2759,7 +2807,8 @@
 	}
 	atomic_sub(count, &queue->used_buffers);
 	/* check if we need to do something on this outbound queue */
-	qeth_check_outbound_queue(queue);
+	if (card->info.type != QETH_CARD_TYPE_IQD)
+		qeth_check_outbound_queue(queue);
 
 	netif_wake_queue(card->dev);
 #ifdef CONFIG_QETH_PERF_STATS
@@ -3333,13 +3382,16 @@
 	if (skb==NULL) {
 		card->stats.tx_dropped++;
 		card->stats.tx_errors++;
-		return -EIO;
+		/* return OK; otherwise ksoftirqd goes to 100% */
+		return NETDEV_TX_OK;
 	}
-	if ((card->state != CARD_STATE_UP) || !netif_carrier_ok(dev)) {
+	if ((card->state != CARD_STATE_UP) || !card->lan_online) {
 		card->stats.tx_dropped++;
 		card->stats.tx_errors++;
 		card->stats.tx_carrier_errors++;
-		return -EIO;
+		dev_kfree_skb_any(skb);
+		/* return OK; otherwise ksoftirqd goes to 100% */
+		return NETDEV_TX_OK;
 	}
 #ifdef CONFIG_QETH_PERF_STATS
 	card->perf_stats.outbound_cnt++;
@@ -3350,8 +3402,18 @@
 	 * got our own synchronization on queues we can keep the stack's
 	 * queue running.
 	 */
-	if ((rc = qeth_send_packet(card, skb)))
-		netif_stop_queue(dev);
+	if ((rc = qeth_send_packet(card, skb))){
+		if (rc == -EBUSY) {
+			netif_stop_queue(dev);
+			rc = NETDEV_TX_BUSY;
+		} else {
+			card->stats.tx_errors++;
+			card->stats.tx_dropped++;
+			dev_kfree_skb_any(skb);
+			/* set to OK; otherwise ksoftirqd goes to 100% */
+			rc = NETDEV_TX_OK;
+		}
+	}
 
 #ifdef CONFIG_QETH_PERF_STATS
 	card->perf_stats.outbound_time += qeth_get_micros() -
@@ -3442,6 +3504,11 @@
 	if (card->state != CARD_STATE_SOFTSETUP)
 		return -ENODEV;
 
+	if ( (card->options.layer2) &&
+	     (!card->info.layer2_mac_registered)) {
+		QETH_DBF_TEXT(trace,4,"nomacadr");
+		return -EPERM;
+	}
 	card->dev->flags |= IFF_UP;
 	netif_start_queue(dev);
 	card->data.state = CH_STATE_UP;
@@ -3450,7 +3517,6 @@
 	if (!card->lan_online){
 		if (netif_carrier_ok(dev))
 			netif_carrier_off(dev);
-		netif_stop_queue(dev);
 	}
 	return 0;
 }
@@ -3491,12 +3557,12 @@
 	else if (skb->protocol == ETH_P_IP)
 		return ((skb->nh.raw[16] & 0xf0) == 0xe0) ? RTN_MULTICAST : 0;
 	/* ... */
-	if (!memcmp(skb->nh.raw, skb->dev->broadcast, 6))
+	if (!memcmp(skb->data, skb->dev->broadcast, 6))
 		return RTN_BROADCAST;
 	else {
 		u16 hdr_mac;
 
-	        hdr_mac = *((u16 *)skb->nh.raw);
+	        hdr_mac = *((u16 *)skb->data);
 	        /* tr multicast? */
 	        switch (card->info.link_type) {
 	        case QETH_LINK_TYPE_HSTR:
@@ -3581,7 +3647,8 @@
 		*skb = new_skb;
 	}
 #ifdef CONFIG_QETH_VLAN
-	if (card->vlangrp && vlan_tx_tag_present(*skb) && (ipv == 6)){
+	if (card->vlangrp && vlan_tx_tag_present(*skb) &&
+	    ((ipv == 6) || card->options.layer2) ) {
 		/*
 		 * Move the mac addresses (6 bytes src, 6 bytes dest)
 		 * to the beginning of the new header.  We are using three
@@ -3591,14 +3658,13 @@
 		memcpy((*skb)->data, (*skb)->data + 4, 4);
 		memcpy((*skb)->data + 4, (*skb)->data + 8, 4);
 		memcpy((*skb)->data + 8, (*skb)->data + 12, 4);
-		tag = (u16 *) (*skb)->data + 12;
+		tag = (u16 *)((*skb)->data + 12);
 		/*
 		 * first two bytes  = ETH_P_8021Q (0x8100)
 		 * second two bytes = VLANID
 		 */
 		*tag = __constant_htons(ETH_P_8021Q);
-		*(tag + 1) = vlan_tx_tag_get(*skb);
-		*(tag + 1) = htons(*(tag + 1));
+		*(tag + 1) = htons(vlan_tx_tag_get(*skb));
 	}
 #endif
 	*hdr = (struct qeth_hdr *) skb_push(*skb, sizeof(struct qeth_hdr));
@@ -3642,50 +3708,120 @@
 }
 
 static inline void
+qeth_layer2_get_packet_type(struct qeth_card *card, struct qeth_hdr *hdr,
+			    struct sk_buff *skb)
+{
+	__u16 hdr_mac;
+
+	if (!memcmp(skb->data+QETH_HEADER_SIZE,
+		    skb->dev->broadcast,6)) { /* broadcast? */
+		*(__u32 *)hdr->hdr.l2.flags |=
+			 QETH_LAYER2_FLAG_BROADCAST << 8;
+		return;
+	}
+	hdr_mac=*((__u16*)skb->data);
+	/* tr multicast? */
+	switch (card->info.link_type) {
+	case QETH_LINK_TYPE_HSTR:
+	case QETH_LINK_TYPE_LANE_TR:
+		if ((hdr_mac == QETH_TR_MAC_NC) ||
+		    (hdr_mac == QETH_TR_MAC_C) )
+			*(__u32 *)hdr->hdr.l2.flags |=
+				QETH_LAYER2_FLAG_MULTICAST << 8;
+		else
+			*(__u32 *)hdr->hdr.l2.flags |=
+				QETH_LAYER2_FLAG_UNICAST << 8;
+		break;
+		/* eth or so multicast? */
+	default:
+		if ( (hdr_mac==QETH_ETH_MAC_V4) ||
+		     (hdr_mac==QETH_ETH_MAC_V6) )
+			*(__u32 *)hdr->hdr.l2.flags |=
+				QETH_LAYER2_FLAG_MULTICAST << 8;
+		else
+			*(__u32 *)hdr->hdr.l2.flags |=
+				QETH_LAYER2_FLAG_UNICAST << 8;
+	}
+}
+
+static inline void
+qeth_layer2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
+			struct sk_buff *skb, int cast_type)
+{
+	memset(hdr, 0, sizeof(struct qeth_hdr));
+	hdr->hdr.l2.id = QETH_HEADER_TYPE_LAYER2;
+
+	/* set byte 0 to "0x02" and byte 3 to casting flags */
+	if (cast_type==RTN_MULTICAST)
+		*(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_MULTICAST << 8;
+	else if (cast_type==RTN_BROADCAST)
+		*(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_BROADCAST << 8;
+	 else
+		qeth_layer2_get_packet_type(card, hdr, skb);
+
+	hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE;
+#ifdef CONFIG_QETH_VLAN
+	/* VSWITCH relies on the VLAN
+	 * information to be present in
+	 * the QDIO header */
+	if ((card->vlangrp != NULL) &&
+	    vlan_tx_tag_present(skb)) {
+		*(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_VLAN << 8;
+		hdr->hdr.l2.vlan_id = vlan_tx_tag_get(skb);
+	}
+#endif
+}
+
+static inline void
 qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
 		struct sk_buff *skb, int ipv, int cast_type)
 {
-	hdr->id = 1;
-	hdr->ext_flags = 0;
-
 	QETH_DBF_TEXT(trace, 6, "fillhdr");
+
+	if (card->options.layer2) {
+		qeth_layer2_fill_header(card, hdr, skb, cast_type);
+		return;
+	}
+	hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3;
+	hdr->hdr.l3.ext_flags = 0;
 #ifdef CONFIG_QETH_VLAN
 	/*
 	 * before we're going to overwrite this location with next hop ip.
 	 * v6 uses passthrough, v4 sets the tag in the QDIO header.
 	 */
 	if (card->vlangrp && vlan_tx_tag_present(skb)) {
-		hdr->ext_flags = (ipv == 4)? QETH_EXT_HDR_VLAN_FRAME :
-					     QETH_EXT_HDR_INCLUDE_VLAN_TAG;
-		hdr->vlan_id = vlan_tx_tag_get(skb);
+		hdr->hdr.l3.ext_flags = (ipv == 4) ?
+			QETH_HDR_EXT_VLAN_FRAME :
+			QETH_HDR_EXT_INCLUDE_VLAN_TAG;
+		hdr->hdr.l3.vlan_id = vlan_tx_tag_get(skb);
 	}
 #endif /* CONFIG_QETH_VLAN */
-	hdr->length = skb->len - sizeof(struct qeth_hdr);
+	hdr->hdr.l3.length = skb->len - sizeof(struct qeth_hdr);
 	if (ipv == 4) {	 /* IPv4 */
-		hdr->flags = qeth_get_qeth_hdr_flags4(cast_type);
-		memset(hdr->dest_addr, 0, 12);
+		hdr->hdr.l3.flags = qeth_get_qeth_hdr_flags4(cast_type);
+		memset(hdr->hdr.l3.dest_addr, 0, 12);
 		if ((skb->dst) && (skb->dst->neighbour)) {
-			*((u32 *) (&hdr->dest_addr[12])) =
+			*((u32 *) (&hdr->hdr.l3.dest_addr[12])) =
 			    *((u32 *) skb->dst->neighbour->primary_key);
 		} else {
 			/* fill in destination address used in ip header */
-			*((u32 *) (&hdr->dest_addr[12])) = skb->nh.iph->daddr;
+			*((u32 *) (&hdr->hdr.l3.dest_addr[12])) = skb->nh.iph->daddr;
 		}
 	} else if (ipv == 6) { /* IPv6 or passthru */
-		hdr->flags = qeth_get_qeth_hdr_flags6(cast_type);
+		hdr->hdr.l3.flags = qeth_get_qeth_hdr_flags6(cast_type);
 		if ((skb->dst) && (skb->dst->neighbour)) {
-			memcpy(hdr->dest_addr,
+			memcpy(hdr->hdr.l3.dest_addr,
 			       skb->dst->neighbour->primary_key, 16);
 		} else {
 			/* fill in destination address used in ip header */
-			memcpy(hdr->dest_addr, &skb->nh.ipv6h->daddr, 16);
+			memcpy(hdr->hdr.l3.dest_addr, &skb->nh.ipv6h->daddr, 16);
 		}
 	} else { /* passthrough */
 		if (!memcmp(skb->data + sizeof(struct qeth_hdr),
 			    skb->dev->broadcast, 6)) {   /* broadcast? */
-			hdr->flags = QETH_CAST_BROADCAST | QETH_HDR_PASSTHRU;
+			hdr->hdr.l3.flags = QETH_CAST_BROADCAST | QETH_HDR_PASSTHRU;
 		} else {
- 			hdr->flags = (cast_type == RTN_MULTICAST) ?
+ 			hdr->hdr.l3.flags = (cast_type == RTN_MULTICAST) ?
  				QETH_CAST_MULTICAST | QETH_HDR_PASSTHRU :
  				QETH_CAST_UNICAST | QETH_HDR_PASSTHRU;
 		}
@@ -3874,7 +4010,7 @@
 static inline int
 qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
 {
-	int ipv;
+	int ipv = 0;
 	int cast_type;
 	struct qeth_qdio_out_q *queue;
 	struct qeth_hdr *hdr;
@@ -3883,7 +4019,8 @@
 
 	QETH_DBF_TEXT(trace, 6, "sendpkt");
 
-	ipv = qeth_get_ip_version(skb);
+	if (!card->options.layer2)
+		ipv = qeth_get_ip_version(skb);
 	cast_type = qeth_get_cast_type(card, skb);
 	queue = card->qdio.out_qs
 		[qeth_get_priority_queue(card, skb, ipv, cast_type)];
@@ -4226,8 +4363,8 @@
 	 * funcs flags); since all zeros is no valueable information,
 	 * we say EOPNOTSUPP for all ARP functions
 	 */
-	if (card->info.guestlan)
-		return -EOPNOTSUPP;
+	/*if (card->info.guestlan)
+		return -EOPNOTSUPP; */
 	if (!qeth_is_supported(card,/*IPA_QUERY_ARP_ADDR_INFO*/
 			       IPA_ARP_PROCESSING)) {
 		PRINT_WARN("ARP processing not supported "
@@ -4555,21 +4692,24 @@
 
 	switch (cmd){
 	case SIOC_QETH_ARP_SET_NO_ENTRIES:
-		if (!capable(CAP_NET_ADMIN)){
+		if ( !capable(CAP_NET_ADMIN) ||
+		     (card->options.layer2) ) {
 			rc = -EPERM;
 			break;
 		}
 		rc = qeth_arp_set_no_entries(card, rq->ifr_ifru.ifru_ivalue);
 		break;
 	case SIOC_QETH_ARP_QUERY_INFO:
-		if (!capable(CAP_NET_ADMIN)){
+		if ( !capable(CAP_NET_ADMIN) ||
+		     (card->options.layer2) ) {
 			rc = -EPERM;
 			break;
 		}
 		rc = qeth_arp_query(card, rq->ifr_ifru.ifru_data);
 		break;
 	case SIOC_QETH_ARP_ADD_ENTRY:
-		if (!capable(CAP_NET_ADMIN)){
+		if ( !capable(CAP_NET_ADMIN) ||
+		     (card->options.layer2) ) {
 			rc = -EPERM;
 			break;
 		}
@@ -4580,7 +4720,8 @@
 			rc = qeth_arp_add_entry(card, &arp_entry);
 		break;
 	case SIOC_QETH_ARP_REMOVE_ENTRY:
-		if (!capable(CAP_NET_ADMIN)){
+		if ( !capable(CAP_NET_ADMIN) ||
+		     (card->options.layer2) ) {
 			rc = -EPERM;
 			break;
 		}
@@ -4591,7 +4732,8 @@
 			rc = qeth_arp_remove_entry(card, &arp_entry);
 		break;
 	case SIOC_QETH_ARP_FLUSH_CACHE:
-		if (!capable(CAP_NET_ADMIN)){
+		if ( !capable(CAP_NET_ADMIN) ||
+		     (card->options.layer2) ) {
 			rc = -EPERM;
 			break;
 		}
@@ -4741,7 +4883,7 @@
 	in_dev = __in_dev_get(card->vlangrp->vlan_devices[vid]);
 	if (!in_dev)
 		goto out;
-	for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next){
+	for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
 		addr = qeth_get_addr_buffer(QETH_PROT_IPV4);
 		if (addr){
 			addr->u.a4.addr = ifa->ifa_address;
@@ -4783,12 +4925,69 @@
 }
 
 static void
+qeth_layer2_send_setdelvlan(struct qeth_card *card, __u16 i,
+			    enum qeth_ipa_cmds ipacmd)
+{
+ 	int rc;
+	struct qeth_ipa_cmd *cmd;
+	struct qeth_cmd_buffer *iob;
+
+	QETH_DBF_TEXT_(trace, 4, "L2sdv%x",ipacmd);
+	iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
+	cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
+        cmd->data.setdelvlan.vlan_id = i;
+
+	rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
+        if (rc) {
+                PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. "
+			  "Continuing\n",i, card->info.if_name, rc);
+		QETH_DBF_TEXT_(trace, 2, "L2VL%4x", ipacmd);
+		QETH_DBF_TEXT_(trace, 2, "L2%s", CARD_BUS_ID(card));
+		QETH_DBF_TEXT_(trace, 2, "err%d", rc);
+        }
+}
+
+static void
+qeth_layer2_process_vlans(struct qeth_card *card, int clear)
+{
+        unsigned short  i;
+
+	QETH_DBF_TEXT(trace, 3, "L2prcvln");
+
+	if (!card->vlangrp)
+		return;
+	for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+		if (card->vlangrp->vlan_devices[i] == NULL)
+			continue;
+		if (clear)
+			qeth_layer2_send_setdelvlan(card, i, IPA_CMD_DELVLAN);
+		else
+			qeth_layer2_send_setdelvlan(card, i, IPA_CMD_SETVLAN);
+        }
+}
+
+/*add_vid is layer 2 used only ....*/
+static void
+qeth_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
+{
+	struct qeth_card *card;
+
+	QETH_DBF_TEXT_(trace, 4, "aid:%d", vid);
+
+	card = (struct qeth_card *) dev->priv;
+	if (!card->options.layer2)
+		return;
+	qeth_layer2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN);
+}
+
+/*... kill_vid used for both modes*/
+static void
 qeth_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
 {
 	struct qeth_card *card;
 	unsigned long flags;
 
-	QETH_DBF_TEXT(trace,4,"vlkilvid");
+	QETH_DBF_TEXT_(trace, 4, "kid:%d", vid);
 
 	card = (struct qeth_card *) dev->priv;
 	/* free all skbs for the vlan device */
@@ -4800,12 +4999,30 @@
 	if (card->vlangrp)
 		card->vlangrp->vlan_devices[vid] = NULL;
 	spin_unlock_irqrestore(&card->vlanlock, flags);
- 	if ( (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) ||
-	     (qeth_set_thread_start_bit(card, QETH_SET_MC_THREAD) == 0) )
-		schedule_work(&card->kernel_thread_starter);
+	if (card->options.layer2)
+		qeth_layer2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN);
+	qeth_set_multicast_list(card->dev);
 }
 #endif
 
+/**
+ * set multicast address on card
+ */
+static void
+qeth_set_multicast_list(struct net_device *dev)
+{
+	struct qeth_card *card = (struct qeth_card *) dev->priv;
+
+	QETH_DBF_TEXT(trace,3,"setmulti");
+	qeth_delete_mc_addresses(card);
+	qeth_add_multicast_ipv4(card);
+#ifdef CONFIG_QETH_IPV6
+	qeth_add_multicast_ipv6(card);
+#endif
+ 	if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
+		schedule_work(&card->kernel_thread_starter);
+}
+
 static int
 qeth_neigh_setup(struct net_device *dev, struct neigh_parms *np)
 {
@@ -4861,24 +5078,19 @@
 static void
 qeth_delete_mc_addresses(struct qeth_card *card)
 {
-	struct qeth_ipaddr *ipm, *iptodo;
+	struct qeth_ipaddr *iptodo;
 	unsigned long flags;
 
 	QETH_DBF_TEXT(trace,4,"delmc");
-	spin_lock_irqsave(&card->ip_lock, flags);
-	list_for_each_entry(ipm, &card->ip_list, entry){
-		if (!ipm->is_multicast)
-			continue;
-		iptodo = qeth_get_addr_buffer(ipm->proto);
-		if (!iptodo) {
-			QETH_DBF_TEXT(trace, 2, "dmcnomem");
-			continue;
-		}
-		memcpy(iptodo, ipm, sizeof(struct qeth_ipaddr));
-		iptodo->users = iptodo->users * -1;
-		if (!__qeth_insert_ip_todo(card, iptodo, 0))
-			kfree(iptodo);
+	iptodo = qeth_get_addr_buffer(QETH_PROT_IPV4);
+	if (!iptodo) {
+		QETH_DBF_TEXT(trace, 2, "dmcnomem");
+		return;
 	}
+	iptodo->type = QETH_IP_TYPE_DEL_ALL_MC;
+	spin_lock_irqsave(&card->ip_lock, flags);
+	if (!__qeth_insert_ip_todo(card, iptodo, 0))
+		kfree(iptodo);
 	spin_unlock_irqrestore(&card->ip_lock, flags);
 }
 
@@ -4912,8 +5124,9 @@
 	int i;
 
 	QETH_DBF_TEXT(trace,4,"addmcvl");
-	if (!qeth_is_supported(card,IPA_FULL_VLAN) ||
-	    (card->vlangrp == NULL))
+	if ( ((card->options.layer2 == 0) &&
+	      (!qeth_is_supported(card,IPA_FULL_VLAN))) ||
+	     (card->vlangrp == NULL) )
 		return ;
 
 	vg = card->vlangrp;
@@ -4980,8 +5193,9 @@
 	int i;
 
 	QETH_DBF_TEXT(trace,4,"admc6vl");
-	if (!qeth_is_supported(card,IPA_FULL_VLAN) ||
-	    (card->vlangrp == NULL))
+	if ( ((card->options.layer2 == 0) &&
+	      (!qeth_is_supported(card,IPA_FULL_VLAN))) ||
+	     (card->vlangrp == NULL))
 		return ;
 
 	vg = card->vlangrp;
@@ -5020,19 +5234,72 @@
 }
 #endif /* CONFIG_QETH_IPV6 */
 
-/**
- * set multicast address on card
- */
-static void
-qeth_set_multicast_list(struct net_device *dev)
+static int
+qeth_layer2_send_setdelmac(struct qeth_card *card, __u8 *mac,
+			   enum qeth_ipa_cmds ipacmd)
+{
+	struct qeth_ipa_cmd *cmd;
+	struct qeth_cmd_buffer *iob;
+
+	QETH_DBF_TEXT(trace, 2, "L2sdmac");
+	iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
+	cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
+        cmd->data.setdelmac.mac_length = OSA_ADDR_LEN;
+        memcpy(&cmd->data.setdelmac.mac, mac, OSA_ADDR_LEN);
+	return qeth_send_ipa_cmd(card, iob, NULL, NULL);
+}
+
+
+static int
+qeth_layer2_set_mac_address(struct net_device *dev, void *p)
 {
+	struct sockaddr *addr = p;
 	struct qeth_card *card;
+	int rc = 0;
 
-	QETH_DBF_TEXT(trace,3,"setmulti");
+	QETH_DBF_TEXT(trace, 3, "setmac");
+
+	if (qeth_verify_dev(dev) != QETH_REAL_CARD) {
+		QETH_DBF_TEXT(trace, 3, "setmcINV");
+		return -EOPNOTSUPP;
+	}
 	card = (struct qeth_card *) dev->priv;
 
-	if (qeth_set_thread_start_bit(card, QETH_SET_MC_THREAD) == 0)
-		schedule_work(&card->kernel_thread_starter);
+	if (!card->options.layer2) {
+		PRINT_WARN("Setting MAC address on %s is not supported"
+			   "in Layer 3 mode.\n", dev->name);
+		QETH_DBF_TEXT(trace, 3, "setmcLY3");
+		return -EOPNOTSUPP;
+	}
+	QETH_DBF_TEXT_(trace, 3, "%s", CARD_BUS_ID(card));
+	QETH_DBF_HEX(trace, 3, addr->sa_data, OSA_ADDR_LEN);
+	if (card->info.layer2_mac_registered)
+		rc = qeth_layer2_send_setdelmac(card, &card->dev->dev_addr[0],
+						IPA_CMD_DELVMAC);
+	if (rc) {
+		PRINT_WARN("Error in deregistering MAC address on " \
+			   "device %s: x%x\n", CARD_BUS_ID(card), rc);
+		QETH_DBF_TEXT_(trace, 2, "err%d", rc);
+		return -EIO;
+	}
+	card->info.layer2_mac_registered = 0;
+
+	rc = qeth_layer2_send_setdelmac(card, addr->sa_data, IPA_CMD_SETVMAC);
+	if (rc) {
+		PRINT_WARN("Error in registering MAC address on " \
+			   "device %s: x%x\n", CARD_BUS_ID(card), rc);
+		QETH_DBF_TEXT_(trace, 2, "2err%d", rc);
+		return -EIO;
+	}
+	card->info.layer2_mac_registered = 1;
+	memcpy(dev->dev_addr, addr->sa_data, OSA_ADDR_LEN);
+	PRINT_INFO("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
+		   "successfully registered on device %s\n",
+		   dev->dev_addr[0],dev->dev_addr[1],dev->dev_addr[2],
+		   dev->dev_addr[3],dev->dev_addr[4],dev->dev_addr[5],
+		   dev->name);
+
+	return rc;
 }
 
 static void
@@ -5045,7 +5312,10 @@
 	cmd->hdr.seqno = card->seqno.ipa;
 	cmd->hdr.adapter_type = qeth_get_ipa_adp_type(card->info.link_type);
 	cmd->hdr.rel_adapter_no = (__u8) card->info.portno;
-	cmd->hdr.prim_version_no = 1;
+	if (card->options.layer2)
+		cmd->hdr.prim_version_no = 2;
+	else
+		cmd->hdr.prim_version_no = 1;
 	cmd->hdr.param_count = 1;
 	cmd->hdr.prot_version = prot;
 	cmd->hdr.ipa_supported = 0;
@@ -5136,7 +5406,53 @@
 }
 
 static int
-qeth_register_addr_entry(struct qeth_card *card, struct qeth_ipaddr *addr)
+qeth_layer2_register_addr_entry(struct qeth_card *card,
+				struct qeth_ipaddr *addr)
+{
+	int rc = 0;
+
+	if (!addr->is_multicast)
+		return 0;
+
+	QETH_DBF_TEXT(trace, 2, "setgmac");
+	QETH_DBF_HEX(trace,3,&addr->mac[0],OSA_ADDR_LEN);
+	rc = qeth_layer2_send_setdelmac(card, &addr->mac[0],
+					IPA_CMD_SETGMAC);
+	if (rc)
+		PRINT_ERR("Could not set group MAC " \
+			  "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
+			  addr->mac[0],addr->mac[1],addr->mac[2],
+			  addr->mac[3],addr->mac[4],addr->mac[5],
+			  card->info.if_name,rc);
+	return rc;
+}
+
+static int
+qeth_layer2_deregister_addr_entry(struct qeth_card *card,
+				  struct qeth_ipaddr *addr)
+{
+	int rc = 0;
+
+	if (!addr->is_multicast)
+		return 0;
+
+	QETH_DBF_TEXT(trace, 2, "delgmac");
+	QETH_DBF_HEX(trace,3,&addr->mac[0],OSA_ADDR_LEN);
+	rc = qeth_layer2_send_setdelmac(card, &addr->mac[0],
+					IPA_CMD_DELGMAC);
+	if (rc)
+		PRINT_ERR("Could not delete group MAC " \
+			  "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
+			  addr->mac[0],addr->mac[1],addr->mac[2],
+			  addr->mac[3],addr->mac[4],addr->mac[5],
+			  card->info.if_name,rc);
+	return rc;
+
+}
+
+static int
+qeth_layer3_register_addr_entry(struct qeth_card *card,
+				struct qeth_ipaddr *addr)
 {
 	//char buf[50];
 	int rc;
@@ -5175,7 +5491,8 @@
 }
 
 static int
-qeth_deregister_addr_entry(struct qeth_card *card, struct qeth_ipaddr *addr)
+qeth_layer3_deregister_addr_entry(struct qeth_card *card,
+				  struct qeth_ipaddr *addr)
 {
 	//char buf[50];
 	int rc;
@@ -5209,6 +5526,24 @@
 }
 
 static int
+qeth_register_addr_entry(struct qeth_card *card, struct qeth_ipaddr *addr)
+{
+	if (card->options.layer2)
+		return qeth_layer2_register_addr_entry(card, addr);
+
+	return qeth_layer3_register_addr_entry(card, addr);
+}
+
+static int
+qeth_deregister_addr_entry(struct qeth_card *card, struct qeth_ipaddr *addr)
+{
+	if (card->options.layer2)
+		return qeth_layer2_deregister_addr_entry(card, addr);
+
+	return qeth_layer3_deregister_addr_entry(card, addr);
+}
+
+static int
 qeth_netdev_init(struct net_device *dev)
 {
 	struct qeth_card *card;
@@ -5230,8 +5565,9 @@
 #ifdef CONFIG_QETH_VLAN
 	dev->vlan_rx_register = qeth_vlan_rx_register;
 	dev->vlan_rx_kill_vid = qeth_vlan_rx_kill_vid;
+	dev->vlan_rx_add_vid = qeth_vlan_rx_add_vid;
 #endif
-	if (qeth_get_netdev_flags(card->info.type) & IFF_NOARP) {
+	if (qeth_get_netdev_flags(card) & IFF_NOARP) {
 		dev->rebuild_header = NULL;
 		dev->hard_header = NULL;
 		dev->header_cache_update = NULL;
@@ -5246,14 +5582,13 @@
 
 #endif
 	dev->hard_header_parse = NULL;
-	dev->set_mac_address = NULL;
-	dev->flags |= qeth_get_netdev_flags(card->info.type);
+	dev->set_mac_address = qeth_layer2_set_mac_address;
+	dev->flags |= qeth_get_netdev_flags(card);
 	if ((card->options.fake_broadcast) ||
 	    (card->info.broadcast_capable))
 		dev->flags |= IFF_BROADCAST;
-
 	dev->hard_header_len =
-		qeth_get_hlen(card->info.link_type) + card->options.add_hhlen;
+			qeth_get_hlen(card->info.link_type) + card->options.add_hhlen;
 	dev->addr_len = OSA_ADDR_LEN;
 	dev->mtu = card->info.initial_mtu;
 
@@ -5560,6 +5895,37 @@
 	return rc;
 }
 
+static int
+qeth_layer2_initialize(struct qeth_card *card)
+{
+        int rc = 0;
+
+
+        QETH_DBF_TEXT(setup, 2, "doL2init");
+        QETH_DBF_TEXT_(setup, 2, "doL2%s", CARD_BUS_ID(card));
+
+	rc = qeth_setadpparms_change_macaddr(card);
+	if (rc) {
+		PRINT_WARN("couldn't get MAC address on "
+			   "device %s: x%x\n",
+			   CARD_BUS_ID(card), rc);
+		QETH_DBF_TEXT_(setup, 2,"1err%d",rc);
+		return rc;
+        }
+	QETH_DBF_HEX(setup,2, card->dev->dev_addr, OSA_ADDR_LEN);
+
+	rc = qeth_layer2_send_setdelmac(card, &card->dev->dev_addr[0],
+					IPA_CMD_SETVMAC);
+        if (rc) {
+		card->info.layer2_mac_registered = 0;
+                PRINT_WARN("Error in processing MAC address on " \
+                           "device %s: x%x\n",CARD_BUS_ID(card),rc);
+		QETH_DBF_TEXT_(setup, 2,"2err%d",rc);
+        } else
+		card->info.layer2_mac_registered = 1;
+        return 0;
+}
+
 
 static int
 qeth_send_startstoplan(struct qeth_card *card, enum qeth_ipa_cmds ipacmd,
@@ -5629,6 +5995,10 @@
 	struct qeth_cmd_buffer *iob;
 
 	QETH_DBF_TEXT_(setup, 2, "qipassi%i", prot);
+	if (card->options.layer2) {
+		QETH_DBF_TEXT(setup, 2, "noprmly2");
+		return -EPERM;
+	}
 
 	iob = qeth_get_ipacmd_buffer(card,IPA_CMD_QIPASSIST,prot);
 	rc = qeth_send_ipa_cmd(card, iob, qeth_query_ipassists_cb, NULL);
@@ -5807,7 +6177,10 @@
 			   card->info.if_name, rc);
 	} else {
 		PRINT_INFO("VLAN enabled \n");
-		card->dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
+		card->dev->features |=
+			NETIF_F_HW_VLAN_FILTER |
+			NETIF_F_HW_VLAN_TX |
+			NETIF_F_HW_VLAN_RX;
 	}
 #endif /* QETH_VLAN */
 	return rc;
@@ -6177,6 +6550,22 @@
 			return rc;
 	} else
 		card->lan_online = 1;
+	if (card->options.layer2) {
+		card->dev->features |=
+			NETIF_F_HW_VLAN_FILTER |
+			NETIF_F_HW_VLAN_TX |
+			NETIF_F_HW_VLAN_RX;
+		card->dev->flags|=IFF_MULTICAST|IFF_BROADCAST;
+		card->info.broadcast_capable=1;
+		if ((rc = qeth_layer2_initialize(card))) {
+			QETH_DBF_TEXT_(setup, 2, "L2err%d", rc);
+			return rc;
+		}
+#ifdef CONFIG_QETH_VLAN
+		qeth_layer2_process_vlans(card, 0);
+#endif
+		goto out;
+	}
 	if ((rc = qeth_setadapter_parms(card)))
 		QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
 	if ((rc = qeth_start_ipassists(card)))
@@ -6185,6 +6574,7 @@
 		QETH_DBF_TEXT_(setup, 2, "4err%d", rc);
 	if ((rc = qeth_setrouting_v6(card)))
 		QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
+out:
 	netif_stop_queue(card->dev);
 	return 0;
 }
@@ -6255,7 +6645,7 @@
 	QETH_DBF_TEXT(trace,4,"clearip");
 	spin_lock_irqsave(&card->ip_lock, flags);
 	/* clear todo list */
-	list_for_each_entry_safe(addr, tmp, &card->ip_tbd_list, entry){
+	list_for_each_entry_safe(addr, tmp, card->ip_tbd_list, entry){
 		list_del(&addr->entry);
 		kfree(addr);
 	}
@@ -6273,7 +6663,7 @@
 			kfree(addr);
 			continue;
 		}
-		list_add_tail(&addr->entry, &card->ip_tbd_list);
+		list_add_tail(&addr->entry, card->ip_tbd_list);
 	}
 	spin_unlock_irqrestore(&card->ip_lock, flags);
 }
@@ -6314,7 +6704,6 @@
 static int
 qeth_stop_card(struct qeth_card *card)
 {
-	int recover_flag = 0;
 	int rc = 0;
 
 	QETH_DBF_TEXT(setup ,2,"stopcard");
@@ -6326,22 +6715,31 @@
 	if (card->read.state == CH_STATE_UP &&
 	    card->write.state == CH_STATE_UP &&
 	    (card->state == CARD_STATE_UP)) {
-		recover_flag = 1;
 		rtnl_lock();
 		dev_close(card->dev);
 		rtnl_unlock();
-		if (!card->use_hard_stop)
+		if (!card->use_hard_stop) {
+			__u8 *mac = &card->dev->dev_addr[0];
+			if ((rc = qeth_layer2_send_setdelmac(card, mac,
+							    IPA_CMD_DELVMAC)));
+				QETH_DBF_TEXT_(setup, 2, "Lerr%d", rc);
 			if ((rc = qeth_send_stoplan(card)))
 				QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
+		}
 		card->state = CARD_STATE_SOFTSETUP;
 	}
 	if (card->state == CARD_STATE_SOFTSETUP) {
-		qeth_clear_ip_list(card, !card->use_hard_stop, recover_flag);
+#ifdef CONFIG_QETH_VLAN
+		if (card->options.layer2)
+			qeth_layer2_process_vlans(card, 1);
+#endif
+		qeth_clear_ip_list(card, !card->use_hard_stop, 1);
 		qeth_clear_ipacmd_list(card);
 		card->state = CARD_STATE_HARDSETUP;
 	}
 	if (card->state == CARD_STATE_HARDSETUP) {
-		if (!card->use_hard_stop)
+		if ((!card->use_hard_stop) &&
+		    (!card->options.layer2))
 			if ((rc = qeth_put_unique_id(card)))
 				QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
 		qeth_qdio_clear_card(card, 0);
@@ -6503,10 +6901,61 @@
 	rtnl_lock();
 	dev_open(card->dev);
 	rtnl_unlock();
- 	if (qeth_set_thread_start_bit(card, QETH_SET_MC_THREAD) == 0)
-		schedule_work(&card->kernel_thread_starter);
+	/* this also sets saved unicast addresses */
+	qeth_set_multicast_list(card->dev);
 }
 
+
+/* Layer 2 specific stuff */
+#define IGNORE_PARAM_EQ(option,value,reset_value,msg) \
+        if (card->options.option == value) { \
+                PRINT_ERR("%s not supported with layer 2 " \
+                          "functionality, ignoring option on read" \
+			  "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
+                card->options.option = reset_value; \
+        }
+#define IGNORE_PARAM_NEQ(option,value,reset_value,msg) \
+        if (card->options.option != value) { \
+                PRINT_ERR("%s not supported with layer 2 " \
+                          "functionality, ignoring option on read" \
+			  "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
+                card->options.option = reset_value; \
+        }
+
+
+static void qeth_make_parameters_consistent(struct qeth_card *card)
+{
+
+        if (card->options.layer2) {
+                if (card->info.type == QETH_CARD_TYPE_IQD) {
+                        PRINT_ERR("Device %s does not support " \
+                                  "layer 2 functionality. "  \
+                                  "Ignoring layer2 option.\n",CARD_BUS_ID(card));
+                }
+                IGNORE_PARAM_NEQ(route4.type, NO_ROUTER, NO_ROUTER,
+                                 "Routing options are");
+#ifdef CONFIG_QETH_IPV6
+                IGNORE_PARAM_NEQ(route6.type, NO_ROUTER, NO_ROUTER,
+                                 "Routing options are");
+#endif
+                IGNORE_PARAM_EQ(checksum_type, HW_CHECKSUMMING,
+                                QETH_CHECKSUM_DEFAULT,
+                                "Checksumming options are");
+                IGNORE_PARAM_NEQ(broadcast_mode, QETH_TR_BROADCAST_ALLRINGS,
+                                 QETH_TR_BROADCAST_ALLRINGS,
+                                 "Broadcast mode options are");
+                IGNORE_PARAM_NEQ(macaddr_mode, QETH_TR_MACADDR_NONCANONICAL,
+                                 QETH_TR_MACADDR_NONCANONICAL,
+                                 "Canonical MAC addr options are");
+                IGNORE_PARAM_NEQ(fake_broadcast, 0, 0,
+				 "Broadcast faking options are");
+                IGNORE_PARAM_NEQ(add_hhlen, DEFAULT_ADD_HHLEN,
+                                 DEFAULT_ADD_HHLEN,"Option add_hhlen is");
+                IGNORE_PARAM_NEQ(fake_ll, 0, 0,"Option fake_ll is");
+        }
+}
+
+
 static int
 qeth_set_online(struct ccwgroup_device *gdev)
 {
@@ -6533,40 +6982,43 @@
 		return -EIO;
 	}
 
+	if (card->options.layer2)
+		qeth_make_parameters_consistent(card);
+
 	if ((rc = qeth_hardsetup_card(card))){
 		QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
 		goto out_remove;
 	}
 	card->state = CARD_STATE_HARDSETUP;
 
-	if ((rc = qeth_query_ipassists(card,QETH_PROT_IPV4))){
-		QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
-		/*TODO: rc !=0*/
-	} else
+	if (!(rc = qeth_query_ipassists(card,QETH_PROT_IPV4)))
 		rc = qeth_get_unique_id(card);
 
-	if (rc) {
-		QETH_DBF_TEXT_(setup, 2, "4err%d", rc);
+	if (rc && card->options.layer2 == 0) {
+		QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
 		goto out_remove;
 	}
 	qeth_print_status_message(card);
 	if ((rc = qeth_register_netdev(card))){
-		QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
+		QETH_DBF_TEXT_(setup, 2, "4err%d", rc);
 		goto out_remove;
 	}
 	if ((rc = qeth_softsetup_card(card))){
-		QETH_DBF_TEXT_(setup, 2, "6err%d", rc);
+		QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
 		goto out_remove;
 	}
 	card->state = CARD_STATE_SOFTSETUP;
 
 	if ((rc = qeth_init_qdio_queues(card))){
-		QETH_DBF_TEXT_(setup, 2, "7err%d", rc);
+		QETH_DBF_TEXT_(setup, 2, "6err%d", rc);
 		goto out_remove;
 	}
 /*maybe it was set offline without ifconfig down
  * we can also use this state for recovery purposes*/
-	qeth_set_allowed_threads(card, 0xffffffff, 0);
+	if (card->options.layer2)
+		qeth_set_allowed_threads(card, QETH_RECOVER_THREAD, 0);
+	else
+		qeth_set_allowed_threads(card, 0xffffffff, 0);
 	if (recover_flag == CARD_STATE_RECOVER)
 		qeth_start_again(card);
 	qeth_notify_processes();
@@ -6714,10 +7166,13 @@
 	struct net_device *dev = neigh->dev;
 	struct in_device *in_dev;
 	struct neigh_parms *parms;
+	struct qeth_card *card;
 
-	if (!qeth_verify_dev(dev)) {
-		return qeth_old_arp_constructor(neigh);
-	}
+	card = qeth_get_card_from_dev(dev);
+	if (card == NULL)
+		goto out;
+	if(card->options.layer2)
+		goto out;
 
 	rcu_read_lock();
 	in_dev = rcu_dereference(__in_dev_get(dev));
@@ -6736,6 +7191,8 @@
 	neigh->ops = arp_direct_ops;
 	neigh->output = neigh->ops->queue_xmit;
 	return 0;
+out:
+	return qeth_old_arp_constructor(neigh);
 }
 #endif  /*CONFIG_QETH_IPV6*/
 
@@ -6888,7 +7345,7 @@
 		return -ENOMEM;
 	spin_lock_irqsave(&card->ip_lock, flags);
 	if (__qeth_address_exists_in_list(&card->ip_list, ipaddr, 0) ||
-	    __qeth_address_exists_in_list(&card->ip_tbd_list, ipaddr, 0))
+	    __qeth_address_exists_in_list(card->ip_tbd_list, ipaddr, 0))
 		rc = -EEXIST;
 	spin_unlock_irqrestore(&card->ip_lock, flags);
 	if (rc){
@@ -6961,7 +7418,7 @@
 		return -ENOMEM;
 	spin_lock_irqsave(&card->ip_lock, flags);
 	if (__qeth_address_exists_in_list(&card->ip_list, ipaddr, 0) ||
-	    __qeth_address_exists_in_list(&card->ip_tbd_list, ipaddr, 0))
+	    __qeth_address_exists_in_list(card->ip_tbd_list, ipaddr, 0))
 		rc = -EEXIST;
 	spin_unlock_irqrestore(&card->ip_lock, flags);
 	if (rc){
@@ -7018,6 +7475,8 @@
 	QETH_DBF_TEXT(trace,3,"ipevent");
 	card = qeth_get_card_from_dev(dev);
 	if (!card)
+		return NOTIFY_DONE;
+	if (card->options.layer2)
 		return NOTIFY_DONE;
 
 	addr = qeth_get_addr_buffer(QETH_PROT_IPV4);
diff -Nru a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h
--- a/drivers/s390/net/qeth_mpc.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/s390/net/qeth_mpc.h	2004-12-24 13:36:48 -08:00
@@ -14,7 +14,7 @@
 
 #include <asm/qeth.h>
 
-#define VERSION_QETH_MPC_H "$Revision: 1.36 $"
+#define VERSION_QETH_MPC_H "$Revision: 1.38 $"
 
 extern const char *VERSION_QETH_MPC_C;
 
@@ -105,6 +105,12 @@
 enum qeth_ipa_cmds {
 	IPA_CMD_STARTLAN              = 0x01,
 	IPA_CMD_STOPLAN               = 0x02,
+	IPA_CMD_SETVMAC 	      = 0x21,
+	IPA_CMD_DELVMAC 	      =	0x22,
+	IPA_CMD_SETGMAC  	      = 0x23,
+	IPA_CMD_DELGMAC 	      = 0x24,
+	IPA_CMD_SETVLAN 	      = 0x25,
+	IPA_CMD_DELVLAN 	      = 0x26,
 	IPA_CMD_SETIP                 = 0xb1,
 	IPA_CMD_DELIP                 = 0xb7,
 	IPA_CMD_QIPASSIST             = 0xb2,
@@ -239,6 +245,16 @@
 	__u8 ip4[4];
 } __attribute__ ((packed));
 
+struct qeth_ipacmd_layer2setdelmac {
+	__u32 mac_length;
+	__u8 mac[6];
+} __attribute__ ((packed));
+
+struct qeth_ipacmd_layer2setdelvlan {
+	__u16 vlan_id;
+} __attribute__ ((packed));
+
+
 struct qeth_ipacmd_setassparms_hdr {
 	__u32 assist_no;
 	__u16 length;
@@ -381,13 +397,15 @@
 struct qeth_ipa_cmd {
 	struct qeth_ipacmd_hdr hdr;
 	union {
-		struct qeth_ipacmd_setdelip4   	setdelip4;
-		struct qeth_ipacmd_setdelip6   	setdelip6;
-		struct qeth_ipacmd_setdelipm	setdelipm;
-		struct qeth_ipacmd_setassparms 	setassparms;
-		struct qeth_create_destroy_address create_destroy_addr;
-		struct qeth_ipacmd_setadpparms 	setadapterparms;
-		struct qeth_set_routing setrtg;
+		struct qeth_ipacmd_setdelip4   		setdelip4;
+		struct qeth_ipacmd_setdelip6   		setdelip6;
+		struct qeth_ipacmd_setdelipm		setdelipm;
+		struct qeth_ipacmd_setassparms 		setassparms;
+		struct qeth_ipacmd_layer2setdelmac  	setdelmac;
+		struct qeth_ipacmd_layer2setdelvlan 	setdelvlan;
+		struct qeth_create_destroy_address 	create_destroy_addr;
+		struct qeth_ipacmd_setadpparms 		setadapterparms;
+		struct qeth_set_routing 		setrtg;
 	} data;
 } __attribute__ ((packed));
 
@@ -459,6 +477,11 @@
 		(PDU_ENCAPSULATION(buffer) + 0x17)
 #define QETH_ULP_ENABLE_RESP_LINK_TYPE(buffer) \
 		(PDU_ENCAPSULATION(buffer)+ 0x2b)
+/* Layer 2 defintions */
+#define QETH_PROT_LAYER2 0x08
+#define QETH_PROT_TCPIP  0x03
+#define QETH_ULP_ENABLE_PROT_TYPE(buffer) (buffer+0x50)
+#define QETH_IPA_CMD_PROT_TYPE(buffer) (buffer+0x19)
 
 extern unsigned char ULP_SETUP[];
 #define ULP_SETUP_SIZE 0x6c
diff -Nru a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
--- a/drivers/s390/net/qeth_sys.c	2004-12-24 13:36:57 -08:00
+++ b/drivers/s390/net/qeth_sys.c	2004-12-24 13:36:57 -08:00
@@ -1,6 +1,6 @@
 /*
  *
- * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.33 $)
+ * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.40 $)
  *
  * Linux on zSeries OSA Express and HiperSockets support
  * This file contains code related to sysfs.
@@ -20,7 +20,7 @@
 #include "qeth_mpc.h"
 #include "qeth_fs.h"
 
-const char *VERSION_QETH_SYS_C = "$Revision: 1.33 $";
+const char *VERSION_QETH_SYS_C = "$Revision: 1.40 $";
 
 /*****************************************************************************/
 /*                                                                           */
@@ -694,6 +694,44 @@
 static DEVICE_ATTR(canonical_macaddr, 0644, qeth_dev_canonical_macaddr_show,
 		   qeth_dev_canonical_macaddr_store);
 
+static ssize_t
+qeth_dev_layer2_show(struct device *dev, char *buf)
+{
+	struct qeth_card *card = dev->driver_data;
+
+	if (!card)
+		return -EINVAL;
+
+	return sprintf(buf, "%i\n", card->options.layer2 ? 1:0);
+}
+
+static ssize_t
+qeth_dev_layer2_store(struct device *dev, const char *buf, size_t count)
+{
+	struct qeth_card *card = dev->driver_data;
+	char *tmp;
+	int i;
+
+	if (!card)
+		return -EINVAL;
+
+	if ((card->state != CARD_STATE_DOWN) &&
+	    (card->state != CARD_STATE_RECOVER))
+		return -EPERM;
+
+	i = simple_strtoul(buf, &tmp, 16);
+	if ((i == 0) || (i == 1))
+		card->options.layer2 = i;
+	else {
+		PRINT_WARN("layer2: write 0 or 1 to this file!\n");
+		return -EINVAL;
+	}
+	return count;
+}
+
+static DEVICE_ATTR(layer2, 0644, qeth_dev_layer2_show,
+		   qeth_dev_layer2_store);
+
 static struct device_attribute * qeth_device_attrs[] = {
 	&dev_attr_state,
 	&dev_attr_chpid,
@@ -714,6 +752,7 @@
 	&dev_attr_recover,
 	&dev_attr_broadcast_mode,
 	&dev_attr_canonical_macaddr,
+	&dev_attr_layer2,
 	NULL,
 };
 
@@ -729,6 +768,15 @@
 	.store	= _store,						     \
 };
 
+int
+qeth_check_layer2(struct qeth_card *card)
+{
+	if (card->options.layer2)
+		return -EPERM;
+	return 0;
+}
+
+
 static ssize_t
 qeth_dev_ipato_enable_show(struct device *dev, char *buf)
 {
@@ -737,6 +785,8 @@
 	if (!card)
 		return -EINVAL;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
 	return sprintf(buf, "%i\n", card->ipato.enabled? 1:0);
 }
 
@@ -753,6 +803,9 @@
 	    (card->state != CARD_STATE_RECOVER))
 		return -EPERM;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
 	tmp = strsep((char **) &buf, "\n");
 	if (!strcmp(tmp, "toggle")){
 		card->ipato.enabled = (card->ipato.enabled)? 0 : 1;
@@ -780,6 +833,9 @@
 	if (!card)
 		return -EINVAL;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
 	return sprintf(buf, "%i\n", card->ipato.invert4? 1:0);
 }
 
@@ -792,6 +848,9 @@
 	if (!card)
 		return -EINVAL;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
 	tmp = strsep((char **) &buf, "\n");
 	if (!strcmp(tmp, "toggle")){
 		card->ipato.invert4 = (card->ipato.invert4)? 0 : 1;
@@ -817,18 +876,31 @@
 {
 	struct qeth_ipato_entry *ipatoe;
 	unsigned long flags;
-	char addr_str[49];
+	char addr_str[40];
+	int entry_len; /* length of 1 entry string, differs between v4 and v6 */
 	int i = 0;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
+	entry_len = (proto == QETH_PROT_IPV4)? 12 : 40;
+	/* add strlen for "/<mask>\n" */
+	entry_len += (proto == QETH_PROT_IPV4)? 5 : 6;
 	spin_lock_irqsave(&card->ip_lock, flags);
 	list_for_each_entry(ipatoe, &card->ipato.entries, entry){
 		if (ipatoe->proto != proto)
 			continue;
+		/* String must not be longer than PAGE_SIZE. So we check if
+		 * string length gets near PAGE_SIZE. Then we can savely display
+		 * the next IPv6 address (worst case, compared to IPv4) */
+		if ((PAGE_SIZE - i) <= entry_len)
+			break;
 		qeth_ipaddr_to_string(proto, ipatoe->addr, addr_str);
-		i += sprintf(buf + i, "%s/%i\n", addr_str, ipatoe->mask_bits);
+		i += snprintf(buf + i, PAGE_SIZE - i,
+			      "%s/%i\n", addr_str, ipatoe->mask_bits);
 	}
 	spin_unlock_irqrestore(&card->ip_lock, flags);
-	i += sprintf(buf + i, "\n");
+	i += snprintf(buf + i, PAGE_SIZE - i, "\n");
 
 	return i;
 }
@@ -880,6 +952,8 @@
 	int mask_bits;
 	int rc;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
 	if ((rc = qeth_parse_ipatoe(buf, proto, addr, &mask_bits)))
 		return rc;
 
@@ -923,6 +997,8 @@
 	int mask_bits;
 	int rc;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
 	if ((rc = qeth_parse_ipatoe(buf, proto, addr, &mask_bits)))
 		return rc;
 
@@ -954,6 +1030,9 @@
 	if (!card)
 		return -EINVAL;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
 	return sprintf(buf, "%i\n", card->ipato.invert6? 1:0);
 }
 
@@ -966,6 +1045,9 @@
 	if (!card)
 		return -EINVAL;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
 	tmp = strsep((char **) &buf, "\n");
 	if (!strcmp(tmp, "toggle")){
 		card->ipato.invert6 = (card->ipato.invert6)? 0 : 1;
@@ -1050,21 +1132,32 @@
 			enum qeth_prot_versions proto)
 {
 	struct qeth_ipaddr *ipaddr;
-	char addr_str[49];
+	char addr_str[40];
+	int entry_len; /* length of 1 entry string, differs between v4 and v6 */
 	unsigned long flags;
 	int i = 0;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
+	entry_len = (proto == QETH_PROT_IPV4)? 12 : 40;
+	entry_len += 2; /* \n + terminator */
 	spin_lock_irqsave(&card->ip_lock, flags);
 	list_for_each_entry(ipaddr, &card->ip_list, entry){
 		if (ipaddr->proto != proto)
 			continue;
 		if (ipaddr->type != QETH_IP_TYPE_VIPA)
 			continue;
+		/* String must not be longer than PAGE_SIZE. So we check if
+		 * string length gets near PAGE_SIZE. Then we can savely display
+		 * the next IPv6 address (worst case, compared to IPv4) */
+		if ((PAGE_SIZE - i) <= entry_len)
+			break;
 		qeth_ipaddr_to_string(proto, (const u8 *)&ipaddr->u, addr_str);
-		i += sprintf(buf + i, "%s\n", addr_str);
+		i += snprintf(buf + i, PAGE_SIZE - i, "%s\n", addr_str);
 	}
 	spin_unlock_irqrestore(&card->ip_lock, flags);
-	i += sprintf(buf + i, "\n");
+	i += snprintf(buf + i, PAGE_SIZE - i, "\n");
 
 	return i;
 }
@@ -1098,6 +1191,8 @@
 	u8 addr[16] = {0, };
 	int rc;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
 	if ((rc = qeth_parse_vipae(buf, proto, addr)))
 		return rc;
 
@@ -1129,6 +1224,8 @@
 	u8 addr[16];
 	int rc;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
 	if ((rc = qeth_parse_vipae(buf, proto, addr)))
 		return rc;
 
@@ -1186,6 +1283,9 @@
 	if (!card)
 		return -EINVAL;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
 	return qeth_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV6);
 }
 
@@ -1213,21 +1313,32 @@
 		       enum qeth_prot_versions proto)
 {
 	struct qeth_ipaddr *ipaddr;
-	char addr_str[49];
+	char addr_str[40];
+	int entry_len; /* length of 1 entry string, differs between v4 and v6 */
 	unsigned long flags;
 	int i = 0;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
+
+	entry_len = (proto == QETH_PROT_IPV4)? 12 : 40;
+	entry_len += 2; /* \n + terminator */
 	spin_lock_irqsave(&card->ip_lock, flags);
 	list_for_each_entry(ipaddr, &card->ip_list, entry){
 		if (ipaddr->proto != proto)
 			continue;
 		if (ipaddr->type != QETH_IP_TYPE_RXIP)
 			continue;
+		/* String must not be longer than PAGE_SIZE. So we check if
+		 * string length gets near PAGE_SIZE. Then we can savely display
+		 * the next IPv6 address (worst case, compared to IPv4) */
+		if ((PAGE_SIZE - i) <= entry_len)
+			break;
 		qeth_ipaddr_to_string(proto, (const u8 *)&ipaddr->u, addr_str);
-		i += sprintf(buf + i, "%s\n", addr_str);
+		i += snprintf(buf + i, PAGE_SIZE - i, "%s\n", addr_str);
 	}
 	spin_unlock_irqrestore(&card->ip_lock, flags);
-	i += sprintf(buf + i, "\n");
+	i += snprintf(buf + i, PAGE_SIZE - i, "\n");
 
 	return i;
 }
@@ -1261,6 +1372,8 @@
 	u8 addr[16] = {0, };
 	int rc;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
 	if ((rc = qeth_parse_rxipe(buf, proto, addr)))
 		return rc;
 
@@ -1292,6 +1405,8 @@
 	u8 addr[16];
 	int rc;
 
+	if (qeth_check_layer2(card))
+		return -EPERM;
 	if ((rc = qeth_parse_rxipe(buf, proto, addr)))
 		return rc;
 
diff -Nru a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
--- a/drivers/s390/scsi/zfcp_aux.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/s390/scsi/zfcp_aux.c	2004-12-24 13:37:32 -08:00
@@ -12,6 +12,7 @@
  *            Wolfgang Taphorn
  *            Stefan Bader <stefan.bader@de.ibm.com>
  *            Heiko Carstens <heiko.carstens@de.ibm.com>
+ *            Andreas Herrmann <aherrman@de.ibm.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
@@ -28,8 +29,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-/* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_AUX_REVISION "$Revision: 1.129 $"
+#define ZFCP_AUX_REVISION "$Revision: 1.145 $"
 
 #include "zfcp_ext.h"
 
@@ -45,7 +45,6 @@
 static void zfcp_ns_gid_pn_handler(unsigned long);
 
 /* miscellaneous */
-
 static inline int zfcp_sg_list_alloc(struct zfcp_sg_list *, size_t);
 static inline void zfcp_sg_list_free(struct zfcp_sg_list *);
 static inline int zfcp_sg_list_copy_from_user(struct zfcp_sg_list *,
@@ -60,7 +59,7 @@
 #define ZFCP_CFDC_IOC \
 	_IOWR(ZFCP_CFDC_IOC_MAGIC, 0, struct zfcp_cfdc_sense_data)
 
-#ifdef CONFIG_S390_SUPPORT
+#ifdef CONFIG_COMPAT
 static struct ioctl_trans zfcp_ioctl_trans = {ZFCP_CFDC_IOC, (void*) sys_ioctl};
 #endif
 
@@ -80,6 +79,7 @@
 module_init(zfcp_module_init);
 
 MODULE_AUTHOR("Heiko Carstens <heiko.carstens@de.ibm.com>, "
+	      "Andreas Herrman <aherrman@de.ibm.com>, "
 	      "Martin Peschke <mpeschke@de.ibm.com>, "
 	      "Raimund Schroeder <raimund.schroeder@de.ibm.com>, "
 	      "Wolfgang Taphorn <taphorn@de.ibm.com>, "
@@ -145,7 +145,7 @@
 	int i;
 	unsigned long flags;
 
-	write_lock_irqsave(&adapter->cmd_dbf_lock, flags);
+	spin_lock_irqsave(&adapter->dbf_lock, flags);
 	if (zfcp_fsf_req_is_scsi_cmnd(fsf_req)) {
 		scsi_cmnd = fsf_req->data.send_fcp_command_task.scsi_cmnd;
 		debug_text_event(adapter->cmd_dbf, level, "fsferror");
@@ -164,7 +164,7 @@
 				    (char *) add_data + i,
 				    min(ZFCP_CMD_DBF_LENGTH, add_length - i));
 	}
-	write_unlock_irqrestore(&adapter->cmd_dbf_lock, flags);
+	spin_unlock_irqrestore(&adapter->dbf_lock, flags);
 }
 
 /* XXX additionally log unit if available */
@@ -181,7 +181,7 @@
 	adapter = (struct zfcp_adapter *) scsi_cmnd->device->host->hostdata[0];
 	req_data = (union zfcp_req_data *) scsi_cmnd->host_scribble;
 	fsf_req = (req_data ? req_data->send_fcp_command_task.fsf_req : NULL);
-	write_lock_irqsave(&adapter->cmd_dbf_lock, flags);
+	spin_lock_irqsave(&adapter->dbf_lock, flags);
 	debug_text_event(adapter->cmd_dbf, level, "hostbyte");
 	debug_text_event(adapter->cmd_dbf, level, text);
 	debug_event(adapter->cmd_dbf, level, &scsi_cmnd->result, sizeof (u32));
@@ -198,7 +198,7 @@
 		debug_text_event(adapter->cmd_dbf, level, "");
 		debug_text_event(adapter->cmd_dbf, level, "");
 	}
-	write_unlock_irqrestore(&adapter->cmd_dbf_lock, flags);
+	spin_unlock_irqrestore(&adapter->dbf_lock, flags);
 }
 
 void
@@ -278,7 +278,7 @@
 		goto out_unit;
 	up(&zfcp_data.config_sema);
 	ccw_device_set_online(adapter->ccw_device);
-	wait_event(unit->scsi_add_wq, atomic_read(&unit->scsi_add_work) == 0);
+	zfcp_erp_wait(adapter);
 	down(&zfcp_data.config_sema);
 	zfcp_unit_put(unit);
  out_unit:
@@ -308,14 +308,13 @@
 	if (!zfcp_transport_template)
 		return -ENODEV;
 
-#ifdef CONFIG_S390_SUPPORT
 	retval = register_ioctl32_conversion(zfcp_ioctl_trans.cmd,
 					     zfcp_ioctl_trans.handler);
 	if (retval != 0) {
 		ZFCP_LOG_INFO("registration of ioctl32 conversion failed\n");
-		goto out_ioctl32;
+		goto out;
 	}
-#endif
+
 	retval = misc_register(&zfcp_cfdc_misc);
 	if (retval != 0) {
 		ZFCP_LOG_INFO("registration of misc device "
@@ -350,11 +349,7 @@
  out_ccw_register:
 	misc_deregister(&zfcp_cfdc_misc);
  out_misc_register:
-#ifdef CONFIG_S390_SUPPORT
 	unregister_ioctl32_conversion(zfcp_ioctl_trans.cmd);
- out_ioctl32:
-#endif
-
  out:
 	return retval;
 }
@@ -379,7 +374,7 @@
 zfcp_cfdc_dev_ioctl(struct inode *inode, struct file *file,
                     unsigned int command, unsigned long buffer)
 {
-	struct zfcp_cfdc_sense_data sense_data, __user *sense_data_user;
+	struct zfcp_cfdc_sense_data *sense_data, __user *sense_data_user;
 	struct zfcp_adapter *adapter = NULL;
 	struct zfcp_fsf_req *fsf_req = NULL;
 	struct zfcp_sg_list *sg_list = NULL;
@@ -387,6 +382,12 @@
 	char *bus_id = NULL;
 	int retval = 0;
 
+	sense_data = kmalloc(sizeof(struct zfcp_cfdc_sense_data), GFP_KERNEL);
+	if (sense_data == NULL) {
+		retval = -ENOMEM;
+		goto out;
+	}
+
 	sg_list = kmalloc(sizeof(struct zfcp_sg_list), GFP_KERNEL);
 	if (sg_list == NULL) {
 		retval = -ENOMEM;
@@ -406,21 +407,21 @@
 		goto out;
 	}
 
-	retval = copy_from_user(&sense_data, sense_data_user,
+	retval = copy_from_user(sense_data, sense_data_user,
 				sizeof(struct zfcp_cfdc_sense_data));
 	if (retval) {
 		retval = -EFAULT;
 		goto out;
 	}
 
-	if (sense_data.signature != ZFCP_CFDC_SIGNATURE) {
+	if (sense_data->signature != ZFCP_CFDC_SIGNATURE) {
 		ZFCP_LOG_INFO("invalid sense data request signature 0x%08x\n",
 			      ZFCP_CFDC_SIGNATURE);
 		retval = -EINVAL;
 		goto out;
 	}
 
-	switch (sense_data.command) {
+	switch (sense_data->command) {
 
 	case ZFCP_CFDC_CMND_DOWNLOAD_NORMAL:
 		fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;
@@ -449,7 +450,7 @@
 
 	default:
 		ZFCP_LOG_INFO("invalid command code 0x%08x\n",
-			      sense_data.command);
+			      sense_data->command);
 		retval = -EINVAL;
 		goto out;
 	}
@@ -460,9 +461,9 @@
 		goto out;
 	}
 	snprintf(bus_id, BUS_ID_SIZE, "%d.%d.%04x",
-		(sense_data.devno >> 24),
-		(sense_data.devno >> 16) & 0xFF,
-		(sense_data.devno & 0xFFFF));
+		(sense_data->devno >> 24),
+		(sense_data->devno >> 16) & 0xFF,
+		(sense_data->devno & 0xFFFF));
 
 	read_lock_irq(&zfcp_data.config_lock);
 	adapter = zfcp_get_adapter_by_busid(bus_id);
@@ -478,7 +479,7 @@
 		goto out;
 	}
 
-	if (sense_data.command & ZFCP_CFDC_WITH_CONTROL_FILE) {
+	if (sense_data->command & ZFCP_CFDC_WITH_CONTROL_FILE) {
 		retval = zfcp_sg_list_alloc(sg_list,
 					    ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);
 		if (retval) {
@@ -487,8 +488,8 @@
 		}
 	}
 
-	if ((sense_data.command & ZFCP_CFDC_DOWNLOAD) &&
-	    (sense_data.command & ZFCP_CFDC_WITH_CONTROL_FILE)) {
+	if ((sense_data->command & ZFCP_CFDC_DOWNLOAD) &&
+	    (sense_data->command & ZFCP_CFDC_WITH_CONTROL_FILE)) {
 		retval = zfcp_sg_list_copy_from_user(
 			sg_list, &sense_data_user->control_file,
 			ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);
@@ -498,19 +499,10 @@
 		}
 	}
 
-	retval = zfcp_fsf_control_file(
-		adapter, &fsf_req, fsf_command, option, sg_list);
-	if (retval == -EOPNOTSUPP) {
-		ZFCP_LOG_INFO("adapter does not support cfdc\n");
-		goto out;
-	} else if (retval != 0) {
-		ZFCP_LOG_INFO("initiation of cfdc up/download failed\n");
-		retval = -EPERM;
+	retval = zfcp_fsf_control_file(adapter, &fsf_req, fsf_command,
+				       option, sg_list);
+	if (retval)
 		goto out;
-	}
-
-	wait_event(fsf_req->completion_wq,
-	           fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
 
 	if ((fsf_req->qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
 	    (fsf_req->qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
@@ -518,20 +510,20 @@
 		goto out;
 	}
 
-	sense_data.fsf_status = fsf_req->qtcb->header.fsf_status;
-	memcpy(&sense_data.fsf_status_qual,
+	sense_data->fsf_status = fsf_req->qtcb->header.fsf_status;
+	memcpy(&sense_data->fsf_status_qual,
 	       &fsf_req->qtcb->header.fsf_status_qual,
 	       sizeof(union fsf_status_qual));
-	memcpy(&sense_data.payloads, &fsf_req->qtcb->bottom.support.els, 256);
+	memcpy(&sense_data->payloads, &fsf_req->qtcb->bottom.support.els, 256);
 
-	retval = copy_to_user(sense_data_user, &sense_data,
+	retval = copy_to_user(sense_data_user, sense_data,
 		sizeof(struct zfcp_cfdc_sense_data));
 	if (retval) {
 		retval = -EFAULT;
 		goto out;
 	}
 
-	if (sense_data.command & ZFCP_CFDC_UPLOAD) {
+	if (sense_data->command & ZFCP_CFDC_UPLOAD) {
 		retval = zfcp_sg_list_copy_to_user(
 			&sense_data_user->control_file, sg_list,
 			ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);
@@ -553,6 +545,9 @@
 		kfree(sg_list);
 	}
 
+	if (sense_data != NULL)
+		kfree(sense_data);
+
 	return retval;
 }
 
@@ -588,18 +583,19 @@
 		retval = -ENOMEM;
 		goto out;
 	}
+	memset(sg_list->sg, sg_list->count * sizeof(struct scatterlist), 0);
 
 	for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) {
 		sg->length = min(size, PAGE_SIZE);
 		sg->offset = 0;
 		address = (void *) get_zeroed_page(GFP_KERNEL);
-		zfcp_address_to_sg(address, sg);
-		if (sg->page == NULL) {
+		if (address == NULL) {
 			sg_list->count = i;
 			zfcp_sg_list_free(sg_list);
 			retval = -ENOMEM;
 			goto out;
 		}
+		zfcp_address_to_sg(address, sg);
 		size -= sg->length;
 	}
 
@@ -624,7 +620,7 @@
 	BUG_ON(sg_list == NULL);
 
 	for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++)
-		__free_pages(sg->page, 0);
+		free_page((unsigned long) zfcp_sg_to_address(sg));
 
 	sg_list->count = 0;
 	kfree(sg_list->sg);
@@ -865,7 +861,6 @@
 		return NULL;
 	memset(unit, 0, sizeof (struct zfcp_unit));
 
-	init_waitqueue_head(&unit->scsi_add_wq);
 	/* initialise reference count stuff */
 	atomic_set(&unit->refcount, 0);
 	init_waitqueue_head(&unit->remove_wq);
@@ -1039,11 +1034,11 @@
 	char dbf_name[20];
 
 	/* debug feature area which records SCSI command failures (hostbyte) */
-	rwlock_init(&adapter->cmd_dbf_lock);
+	spin_lock_init(&adapter->dbf_lock);
+
 	sprintf(dbf_name, ZFCP_CMD_DBF_NAME "%s",
 		zfcp_get_busid_by_adapter(adapter));
-	adapter->cmd_dbf = debug_register(dbf_name,
-					  ZFCP_CMD_DBF_INDEX,
+	adapter->cmd_dbf = debug_register(dbf_name, ZFCP_CMD_DBF_INDEX,
 					  ZFCP_CMD_DBF_AREAS,
 					  ZFCP_CMD_DBF_LENGTH);
 	debug_register_view(adapter->cmd_dbf, &debug_hex_ascii_view);
@@ -1052,40 +1047,38 @@
 	/* debug feature area which records SCSI command aborts */
 	sprintf(dbf_name, ZFCP_ABORT_DBF_NAME "%s",
 		zfcp_get_busid_by_adapter(adapter));
-	adapter->abort_dbf = debug_register(dbf_name,
-					    ZFCP_ABORT_DBF_INDEX,
+	adapter->abort_dbf = debug_register(dbf_name, ZFCP_ABORT_DBF_INDEX,
 					    ZFCP_ABORT_DBF_AREAS,
 					    ZFCP_ABORT_DBF_LENGTH);
 	debug_register_view(adapter->abort_dbf, &debug_hex_ascii_view);
 	debug_set_level(adapter->abort_dbf, ZFCP_ABORT_DBF_LEVEL);
 
-	/* debug feature area which records SCSI command aborts */
+	/* debug feature area which records incoming ELS commands */
 	sprintf(dbf_name, ZFCP_IN_ELS_DBF_NAME "%s",
 		zfcp_get_busid_by_adapter(adapter));
-	adapter->in_els_dbf = debug_register(dbf_name,
-					     ZFCP_IN_ELS_DBF_INDEX,
+	adapter->in_els_dbf = debug_register(dbf_name, ZFCP_IN_ELS_DBF_INDEX,
 					     ZFCP_IN_ELS_DBF_AREAS,
 					     ZFCP_IN_ELS_DBF_LENGTH);
 	debug_register_view(adapter->in_els_dbf, &debug_hex_ascii_view);
 	debug_set_level(adapter->in_els_dbf, ZFCP_IN_ELS_DBF_LEVEL);
 
-
 	/* debug feature area which records erp events */
 	sprintf(dbf_name, ZFCP_ERP_DBF_NAME "%s",
 		zfcp_get_busid_by_adapter(adapter));
-	adapter->erp_dbf = debug_register(dbf_name,
-					  ZFCP_ERP_DBF_INDEX,
+	adapter->erp_dbf = debug_register(dbf_name, ZFCP_ERP_DBF_INDEX,
 					  ZFCP_ERP_DBF_AREAS,
 					  ZFCP_ERP_DBF_LENGTH);
 	debug_register_view(adapter->erp_dbf, &debug_hex_ascii_view);
 	debug_set_level(adapter->erp_dbf, ZFCP_ERP_DBF_LEVEL);
 
-	if (adapter->cmd_dbf && adapter->abort_dbf &&
-	    adapter->in_els_dbf && adapter->erp_dbf)
-		return 0;
+	if (!(adapter->cmd_dbf && adapter->abort_dbf &&
+	      adapter->in_els_dbf && adapter->erp_dbf)) {
+		zfcp_adapter_debug_unregister(adapter);
+		return -ENOMEM;
+	}
+
+	return 0;
 
-	zfcp_adapter_debug_unregister(adapter);
-	return -ENOMEM;
 }
 
 /**
@@ -1095,10 +1088,14 @@
 void
 zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter)
 {
-	debug_unregister(adapter->erp_dbf);
-	debug_unregister(adapter->cmd_dbf);
-	debug_unregister(adapter->abort_dbf);
-	debug_unregister(adapter->in_els_dbf);
+ 	debug_unregister(adapter->abort_dbf);
+ 	debug_unregister(adapter->cmd_dbf);
+ 	debug_unregister(adapter->erp_dbf);
+ 	debug_unregister(adapter->in_els_dbf);
+	adapter->abort_dbf = NULL;
+	adapter->cmd_dbf = NULL;
+	adapter->erp_dbf = NULL;
+	adapter->in_els_dbf = NULL;
 }
 
 void
@@ -1651,7 +1648,6 @@
 		zfcp_fsf_incoming_els_rscn(adapter, status_buffer);
 	else
 		zfcp_fsf_incoming_els_unknown(adapter, status_buffer);
-
 }
 
 
diff -Nru a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
--- a/drivers/s390/scsi/zfcp_ccw.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/s390/scsi/zfcp_ccw.c	2004-12-24 13:36:31 -08:00
@@ -10,6 +10,7 @@
  * Authors:
  *      Martin Peschke <mpeschke@de.ibm.com>
  *	Heiko Carstens <heiko.carstens@de.ibm.com>
+ *      Andreas Herrmann <aherrman@de.ibm.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
@@ -26,7 +27,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_CCW_C_REVISION "$Revision: 1.56 $"
+#define ZFCP_CCW_C_REVISION "$Revision: 1.58 $"
 
 #include "zfcp_ext.h"
 
@@ -301,9 +302,11 @@
 {
 	struct zfcp_adapter *adapter;
 
+	down(&zfcp_data.config_sema);
 	adapter = dev_get_drvdata(dev);
 	zfcp_erp_adapter_shutdown(adapter, 0);
 	zfcp_erp_wait(adapter);
+	up(&zfcp_data.config_sema);
 }
 
 #undef ZFCP_LOG_AREA
diff -Nru a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
--- a/drivers/s390/scsi/zfcp_def.h	2004-12-24 13:36:58 -08:00
+++ b/drivers/s390/scsi/zfcp_def.h	2004-12-24 13:36:58 -08:00
@@ -12,6 +12,8 @@
  *            Wolfgang Taphorn
  *            Stefan Bader <stefan.bader@de.ibm.com> 
  *            Heiko Carstens <heiko.carstens@de.ibm.com> 
+ *            Andreas Herrmann <aherrman@de.ibm.com>
+ *            Volker Sameske <sameske@de.ibm.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 
@@ -32,8 +34,7 @@
 #ifndef ZFCP_DEF_H
 #define ZFCP_DEF_H
 
-/* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_DEF_REVISION "$Revision: 1.91 $"
+#define ZFCP_DEF_REVISION "$Revision: 1.111 $"
 
 /*************************** INCLUDES *****************************************/
 
@@ -60,9 +61,7 @@
 #include <linux/mempool.h>
 #include <linux/syscalls.h>
 #include <linux/ioctl.h>
-#ifdef CONFIG_S390_SUPPORT
 #include <linux/ioctl32.h>
-#endif
 
 /************************ DEBUG FLAGS *****************************************/
 
@@ -71,7 +70,7 @@
 /********************* GENERAL DEFINES *********************************/
 
 /* zfcp version number, it consists of major, minor, and patch-level number */
-#define ZFCP_VERSION		"4.1.3"
+#define ZFCP_VERSION		"4.2.0"
 
 /**
  * zfcp_sg_to_address - determine kernel address from struct scatterlist
@@ -187,11 +186,11 @@
 #define UNTAGGED	5
 
 /* task management flags in FCP-2 FCP_CMND IU */
-#define CLEAR_ACA		0x40
-#define TARGET_RESET		0x20
-#define LOGICAL_UNIT_RESET	0x10
-#define CLEAR_TASK_SET		0x04
-#define ABORT_TASK_SET		0x02
+#define FCP_CLEAR_ACA		0x40
+#define FCP_TARGET_RESET	0x20
+#define FCP_LOGICAL_UNIT_RESET	0x10
+#define FCP_CLEAR_TASK_SET	0x04
+#define FCP_ABORT_TASK_SET	0x02
 
 #define FCP_CDB_LENGTH		16
 
@@ -289,11 +288,11 @@
 #define R_A_TOV				10 /* seconds */
 #define ZFCP_ELS_TIMEOUT		(2 * R_A_TOV)
 
-#define ZFCP_LS_RTV			0x0E
-#define ZFCP_LS_RLS			0x0F
-#define ZFCP_LS_PDISC			0x50
+#define ZFCP_LS_RLS			0x0f
 #define ZFCP_LS_ADISC			0x52
-#define ZFCP_LS_RTV_E_D_TOV_FLAG	0x04000000
+#define ZFCP_LS_RPS			0x56
+#define ZFCP_LS_RSCN			0x61
+#define ZFCP_LS_RNID			0x78
 
 struct zfcp_ls_rjt_par {
 	u8 action;
@@ -302,82 +301,22 @@
  	u8 vendor_unique;
 } __attribute__ ((packed));
 
-struct zfcp_ls_rtv {
-	u8		code;
-	u8		field[3];
-} __attribute__ ((packed));
-
-struct zfcp_ls_rtv_acc {
-	u8		code;
-	u8		field[3];
-	u32		r_a_tov;
-	u32		e_d_tov;
-	u32		qualifier;
-} __attribute__ ((packed));
-
-struct zfcp_ls_rls {
-	u8		code;
-	u8		field[3];
-	fc_id_t		port_id;
-} __attribute__ ((packed));
-
-struct zfcp_ls_rls_acc {
-	u8		code;
-	u8		field[3];
-	u32		link_failure_count;
-	u32		loss_of_sync_count;
-	u32		loss_of_signal_count;
-	u32		prim_seq_prot_error;
-	u32		invalid_transmition_word;
-	u32		invalid_crc_count;
-} __attribute__ ((packed));
-
-struct zfcp_ls_pdisc {
-	u8		code;
-	u8		field[3];
-	u8		common_svc_parm[16];
-		wwn_t	wwpn;
-	wwn_t		wwnn;
-	struct {
-		u8	class1[16];
-		u8	class2[16];
-		u8	class3[16];
-	} svc_parm;
-	u8		reserved[16];
-	u8		vendor_version[16];
-} __attribute__ ((packed));
-
-struct zfcp_ls_pdisc_acc {
-	u8		code;
-	u8		field[3];
-	u8		common_svc_parm[16];
-	wwn_t		wwpn;
-	wwn_t		wwnn;
-	struct {
-		u8	class1[16];
-		u8	class2[16];
-		u8	class3[16];
-	} svc_parm;
-	u8		reserved[16];
-	u8		vendor_version[16];
-} __attribute__ ((packed));
-
 struct zfcp_ls_adisc {
 	u8		code;
 	u8		field[3];
-	fc_id_t		hard_nport_id;
-	wwn_t		wwpn;
-	wwn_t		wwnn;
-	fc_id_t		nport_id;
+	u32		hard_nport_id;
+	u64		wwpn;
+	u64		wwnn;
+	u32		nport_id;
 } __attribute__ ((packed));
 
 struct zfcp_ls_adisc_acc {
 	u8		code;
 	u8		field[3];
-	fc_id_t		hard_nport_id;
-	wwn_t		wwpn;
-	wwn_t		wwnn;
-	fc_id_t		nport_id;
+	u32		hard_nport_id;
+	u64		wwpn;
+	u64		wwnn;
+	u32		nport_id;
 } __attribute__ ((packed));
 
 struct zfcp_rc_entry {
@@ -440,6 +379,9 @@
 
 #define ZFCP_NAME               "zfcp"
 
+/* read-only LUN sharing switch initial value */
+#define ZFCP_RO_LUN_SHARING_DEFAULTS 0
+
 /* independent log areas */
 #define ZFCP_LOG_AREA_OTHER	0
 #define ZFCP_LOG_AREA_SCSI	1
@@ -489,7 +431,7 @@
 /* logging routine for zfcp */
 #define _ZFCP_LOG(fmt, args...) \
 	printk(KERN_ERR ZFCP_NAME": %s(%d): " fmt, __FUNCTION__, \
-	       __LINE__ , ##args);
+	       __LINE__ , ##args)
 
 #define ZFCP_LOG(level, fmt, args...) \
 do { \
@@ -548,8 +490,8 @@
  * Note, the leftmost status byte is common among adapter, port 
  * and unit
  */
-#define ZFCP_COMMON_FLAGS                       0xff000000
-#define ZFCP_SPECIFIC_FLAGS                     0x00ffffff
+#define ZFCP_COMMON_FLAGS			0xfff00000
+#define ZFCP_SPECIFIC_FLAGS			0x000fffff
 
 /* common status bits */
 #define ZFCP_STATUS_COMMON_REMOVE		0x80000000
@@ -560,6 +502,7 @@
 #define ZFCP_STATUS_COMMON_OPEN                 0x04000000
 #define ZFCP_STATUS_COMMON_CLOSING              0x02000000
 #define ZFCP_STATUS_COMMON_ERP_INUSE		0x01000000
+#define ZFCP_STATUS_COMMON_ACCESS_DENIED	0x00800000
 
 /* adapter status */
 #define ZFCP_STATUS_ADAPTER_QDIOUP		0x00000002
@@ -590,6 +533,7 @@
 #define ZFCP_STATUS_PORT_NO_WWPN		0x00000008
 #define ZFCP_STATUS_PORT_NO_SCSI_ID		0x00000010
 #define ZFCP_STATUS_PORT_INVALID_WWPN		0x00000020
+#define ZFCP_STATUS_PORT_ACCESS_DENIED		0x00000040
 
 /* for ports with well known addresses */
 #define ZFCP_STATUS_PORT_WKA \
@@ -598,7 +542,9 @@
 
 /* logical unit status */
 #define ZFCP_STATUS_UNIT_NOTSUPPUNITRESET	0x00000001
-
+#define ZFCP_STATUS_UNIT_TEMPORARY		0x00000002
+#define ZFCP_STATUS_UNIT_SHARED			0x00000004
+#define ZFCP_STATUS_UNIT_READONLY		0x00000008
 
 /* FSF request status (this does not have a common part) */
 #define ZFCP_STATUS_FSFREQ_NOT_INIT		0x00000000
@@ -817,7 +763,8 @@
 
 /**
  * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els
- * @port: port where the request is sent to
+ * @adapter: adapter where request is sent from
+ * @d_id: destiniation id of port where request is sent to
  * @req: scatter-gather list for request
  * @resp: scatter-gather list for response
  * @req_count: number of elements in request scatter-gather list
@@ -830,7 +777,8 @@
  * @status: used to pass error status to calling function
  */
 struct zfcp_send_els {
-	struct zfcp_port *port;
+	struct zfcp_adapter *adapter;
+	fc_id_t d_id;
 	struct scatterlist *req;
 	struct scatterlist *resp;
 	unsigned int req_count;
@@ -952,7 +900,7 @@
 	debug_info_t            *abort_dbf;
 	debug_info_t            *in_els_dbf;
 	debug_info_t            *cmd_dbf;
-	rwlock_t                cmd_dbf_lock;
+	spinlock_t              dbf_lock;
 	struct zfcp_adapter_mempool	pool;      /* Adapter memory pools */
 	struct qdio_initialize  qdio_init_data;    /* for qdio_establish */
 	struct device           generic_services;  /* directory for WKA ports */
@@ -1002,8 +950,6 @@
         struct scsi_device     *device;        /* scsi device struct pointer */
 	struct zfcp_erp_action erp_action;     /* pending error recovery */
         atomic_t               erp_counter;
-	atomic_t               scsi_add_work;  /* used to synchronize */
-	wait_queue_head_t      scsi_add_wq;    /* wait for scsi_add_device */
 };
 
 /* FSF request */
@@ -1055,6 +1001,7 @@
 	char                    init_busid[BUS_ID_SIZE];
 	wwn_t                   init_wwpn;
 	fcp_lun_t               init_fcp_lun;
+	char 			*driver_version;
 };
 
 /**
diff -Nru a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
--- a/drivers/s390/scsi/zfcp_erp.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/s390/scsi/zfcp_erp.c	2004-12-24 13:36:30 -08:00
@@ -12,6 +12,7 @@
  *            Wolfgang Taphorn
  *            Stefan Bader <stefan.bader@de.ibm.com> 
  *            Heiko Carstens <heiko.carstens@de.ibm.com> 
+ *            Andreas Herrmann <aherrman@de.ibm.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 
@@ -30,13 +31,12 @@
 
 #define ZFCP_LOG_AREA			ZFCP_LOG_AREA_ERP
 
-/* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_ERP_REVISION "$Revision: 1.65 $"
+#define ZFCP_ERP_REVISION "$Revision: 1.85 $"
 
 #include "zfcp_ext.h"
 
-static int zfcp_els(struct zfcp_port *, u8);
-static void zfcp_els_handler(unsigned long);
+static int zfcp_erp_adisc(struct zfcp_adapter *, fc_id_t);
+static void zfcp_erp_adisc_handler(unsigned long);
 
 static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *, int);
 static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *, int);
@@ -293,256 +293,198 @@
 }
 
 
-/*
- * function:    zfcp_els
- *
- * purpose:     Originator of the ELS commands
- *
- * returns:     0       - Operation completed successfuly
- *              -EINVAL - Unknown IOCTL command or invalid sense data record
- *              -ENOMEM - Insufficient memory
- *              -EPERM  - Cannot create or queue FSF request
+/**
+ * zfcp_erp_adisc - send ADISC ELS command
+ * @adapter: adapter structure
+ * @d_id: d_id of port where ADISC is sent to
  */
 int
-zfcp_els(struct zfcp_port *port, u8 ls_code)
+zfcp_erp_adisc(struct zfcp_adapter *adapter, fc_id_t d_id)
 {
 	struct zfcp_send_els *send_els;
-	struct zfcp_ls_rls *rls;
-	struct zfcp_ls_pdisc *pdisc;
 	struct zfcp_ls_adisc *adisc;
-	struct page *page = NULL;
-	void *req;
+	void *address = NULL;
 	int retval = 0;
+	struct timer_list *timer;
 
 	send_els = kmalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC);
 	if (send_els == NULL)
 		goto nomem;
+	memset(send_els, 0, sizeof(*send_els));
 
 	send_els->req = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
 	if (send_els->req == NULL)
 		goto nomem;
-	send_els->req_count = 1;
+	memset(send_els->req, 0, sizeof(*send_els->req));
 
 	send_els->resp = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
 	if (send_els->resp == NULL)
 		goto nomem;
-	send_els->resp_count = 1;
+	memset(send_els->resp, 0, sizeof(*send_els->resp));
 
-	page = alloc_pages(GFP_ATOMIC, 0);
-	if (page == NULL)
+	address = (void *) get_zeroed_page(GFP_ATOMIC);
+	if (address == NULL)
 		goto nomem;
-	send_els->req->page = page;
-	send_els->resp->page = page;
-	send_els->req->offset = 0;
-	send_els->resp->offset = PAGE_SIZE >> 1;
-
-	send_els->port = port;
-	send_els->ls_code = ls_code;
-	send_els->handler = zfcp_els_handler;
-	send_els->handler_data = (unsigned long)send_els;
-	send_els->completion = NULL;
-
-	req = zfcp_sg_to_address(send_els->req);
-	memset(req, 0, PAGE_SIZE);
-
-	*(u32*)req = 0;
-	*(u8*)req = ls_code;
-
-	switch (ls_code) {
-
-	case ZFCP_LS_RTV:
-		send_els->req->length = sizeof(struct zfcp_ls_rtv);
-		send_els->resp->length = sizeof(struct zfcp_ls_rtv_acc);
-		ZFCP_LOG_INFO("RTV request from s_id 0x%08x to d_id 0x%08x\n",
-			      port->adapter->s_id, port->d_id);
-		break;
-
-	case ZFCP_LS_RLS:
-		send_els->req->length = sizeof(struct zfcp_ls_rls);
-		send_els->resp->length = sizeof(struct zfcp_ls_rls_acc);
-		rls = (struct zfcp_ls_rls*)req;
-		rls->port_id = port->adapter->s_id;
-		ZFCP_LOG_INFO("RLS request from s_id 0x%08x to d_id 0x%08x "
-			      "(port_id=0x%08x)\n",
-			      port->adapter->s_id, port->d_id, rls->port_id);
-		break;
-
-	case ZFCP_LS_PDISC:
-		send_els->req->length = sizeof(struct zfcp_ls_pdisc);
-		send_els->resp->length = sizeof(struct zfcp_ls_pdisc_acc);
-		pdisc = (struct zfcp_ls_pdisc*)req;
-		pdisc->wwpn = port->adapter->wwpn;
-		pdisc->wwnn = port->adapter->wwnn;
-		ZFCP_LOG_INFO("PDISC request from s_id 0x%08x to d_id 0x%08x "
-			      "(wwpn=0x%016Lx, wwnn=0x%016Lx)\n",
-			      port->adapter->s_id, port->d_id,
-			      pdisc->wwpn, pdisc->wwnn);
-		break;
-
-	case ZFCP_LS_ADISC:
-		send_els->req->length = sizeof(struct zfcp_ls_adisc);
-		send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc);
-		adisc = (struct zfcp_ls_adisc*)req;
-		adisc->hard_nport_id = port->adapter->s_id;
-		adisc->wwpn = port->adapter->wwpn;
-		adisc->wwnn = port->adapter->wwnn;
-		adisc->nport_id = port->adapter->s_id;
-		ZFCP_LOG_INFO("ADISC request from s_id 0x%08x to d_id 0x%08x "
-			      "(wwpn=0x%016Lx, wwnn=0x%016Lx, "
-			      "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
-			      port->adapter->s_id, port->d_id,
-			      adisc->wwpn, adisc->wwnn,
-			      adisc->hard_nport_id, adisc->nport_id);
-		break;
 
-	default:
-		ZFCP_LOG_NORMAL("ELS command code 0x%02x is not supported\n",
-				ls_code);
-		retval = -EINVAL;
-		goto invalid_ls_code;
-	}
+	zfcp_address_to_sg(address, send_els->req);
+	address += PAGE_SIZE >> 1;
+	zfcp_address_to_sg(address, send_els->resp);
+	send_els->req_count = send_els->resp_count = 1;
+
+	send_els->adapter = adapter;
+	send_els->d_id = d_id;
+	send_els->handler = zfcp_erp_adisc_handler;
+	send_els->handler_data = (unsigned long) send_els;
+
+	adisc = zfcp_sg_to_address(send_els->req);
+	send_els->ls_code = adisc->code = ZFCP_LS_ADISC;
+
+	send_els->req->length = sizeof(struct zfcp_ls_adisc);
+	send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc);
+
+	/* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
+	   without FC-AL-2 capability, so we don't set it */
+	adisc->wwpn = adapter->wwpn;
+	adisc->wwnn = adapter->wwnn;
+	adisc->nport_id = adapter->s_id;
+	ZFCP_LOG_INFO("ADISC request from s_id 0x%08x to d_id 0x%08x "
+		      "(wwpn=0x%016Lx, wwnn=0x%016Lx, "
+		      "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
+		      adapter->s_id, d_id, (wwn_t) adisc->wwpn,
+		      (wwn_t) adisc->wwnn, adisc->hard_nport_id,
+		      adisc->nport_id);
+
+	timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC);
+	if (!timer)
+		goto nomem;
+
+	init_timer(timer);
+	timer->function = zfcp_fsf_request_timeout_handler;
+	timer->data = (unsigned long) adapter;
+	timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
+	send_els->timer = timer;
 
 	retval = zfcp_fsf_send_els(send_els);
 	if (retval != 0) {
 		ZFCP_LOG_NORMAL("error: initiation of Send ELS failed for port "
-				"0x%016Lx on adapter %s\n",
-				port->wwpn, zfcp_get_busid_by_port(port));
-		retval = -EPERM;
+				"0x%08x on adapter %s\n", d_id,
+				zfcp_get_busid_by_adapter(adapter));
+		del_timer_sync(send_els->timer);
+		goto freemem;
 	}
 
 	goto out;
 
-nomem:
-	ZFCP_LOG_DEBUG("out of memory\n");
+ nomem:
 	retval = -ENOMEM;
-
-invalid_ls_code:
-	if (page != NULL)
-		__free_pages(page, 0);
+ freemem:
+	if (address != NULL)
+		__free_pages(send_els->req->page, 0);
 	if (send_els != NULL) {
-		if (send_els->req != NULL)
-			kfree(send_els->req);
-		if (send_els->resp != NULL)
-			kfree(send_els->resp);
+		kfree(send_els->timer);
+		kfree(send_els->req);
+		kfree(send_els->resp);
 		kfree(send_els);
 	}
-
-out:
+ out:
 	return retval;
 }
 
 
 /**
- * zfcp_els_handler - handler for ELS commands
+ * zfcp_erp_adisc_handler - handler for ADISC ELS command
  * @data: pointer to struct zfcp_send_els
- * If ELS failed (LS_RJT or timed out) forced reopen of the port is triggered.
+ *
+ * If ADISC failed (LS_RJT or timed out) forced reopen of the port is triggered.
  */
 void
-zfcp_els_handler(unsigned long data)
+zfcp_erp_adisc_handler(unsigned long data)
 {
-	struct zfcp_send_els *send_els = (struct zfcp_send_els*)data;
-	struct zfcp_port *port = send_els->port;
-	struct zfcp_ls_rtv_acc *rtv;
-	struct zfcp_ls_rls_acc *rls;
-	struct zfcp_ls_pdisc_acc *pdisc;
+	struct zfcp_send_els *send_els;
+	struct zfcp_port *port;
+	struct zfcp_adapter *adapter;
+	fc_id_t d_id;
 	struct zfcp_ls_adisc_acc *adisc;
-	void *req, *resp;
-	u8 req_code;
+
+	send_els = (struct zfcp_send_els *) data;
+
+	del_timer(send_els->timer);
+
+	adapter = send_els->adapter;
+	d_id = send_els->d_id;
+
+	read_lock(&zfcp_data.config_lock);
+	port = zfcp_get_port_by_did(send_els->adapter, send_els->d_id);
+	read_unlock(&zfcp_data.config_lock);
+
+	BUG_ON(port == NULL);
 
 	/* request rejected or timed out */
 	if (send_els->status != 0) {
-		ZFCP_LOG_NORMAL("ELS request timed out, force physical port "
-				"reopen of port 0x%016Lx on adapter %s\n",
-				port->wwpn, zfcp_get_busid_by_port(port));
-		debug_text_event(port->adapter->erp_dbf, 3, "forcreop");
+		ZFCP_LOG_NORMAL("ELS request rejected/timed out, "
+				"force physical port reopen "
+				"(adapter %s, port d_id=0x%08x)\n",
+				zfcp_get_busid_by_adapter(adapter), d_id);
+		debug_text_event(adapter->erp_dbf, 3, "forcreop");
 		if (zfcp_erp_port_forced_reopen(port, 0))
-			ZFCP_LOG_NORMAL("reopen of remote port 0x%016Lx "
-					"on adapter %s failed\n", port->wwpn,
-					zfcp_get_busid_by_port(port));
+			ZFCP_LOG_NORMAL("failed reopen of port "
+					"(adapter %s, wwpn=0x%016Lx)\n",
+					zfcp_get_busid_by_port(port),
+					port->wwpn);
 		goto out;
 	}
 
-	req = zfcp_sg_to_address(send_els->req);
-	resp = zfcp_sg_to_address(send_els->resp);
-	req_code = *(u8*)req;
-
-	switch (req_code) {
-
-	case ZFCP_LS_RTV:
-		rtv = (struct zfcp_ls_rtv_acc*)resp;
-		ZFCP_LOG_INFO("RTV response from d_id 0x%08x to s_id "
-			      "0x%08x (R_A_TOV=%ds E_D_TOV=%d%cs)\n",
-			      port->d_id, port->adapter->s_id,
-			      rtv->r_a_tov, rtv->e_d_tov,
-			      rtv->qualifier &
-			      ZFCP_LS_RTV_E_D_TOV_FLAG ? 'n' : 'm');
-		break;
-
-	case ZFCP_LS_RLS:
-		rls = (struct zfcp_ls_rls_acc*)resp;
-		ZFCP_LOG_INFO("RLS response from d_id 0x%08x to s_id "
-			      "0x%08x (link_failure_count=%u, "
-			      "loss_of_sync_count=%u, "
-			      "loss_of_signal_count=%u, "
-			      "primitive_sequence_protocol_error=%u, "
-			      "invalid_transmition_word=%u, "
-			      "invalid_crc_count=%u)\n",
-			      port->d_id, port->adapter->s_id,
-			      rls->link_failure_count,
-			      rls->loss_of_sync_count,
-			      rls->loss_of_signal_count,
-			      rls->prim_seq_prot_error,
-			      rls->invalid_transmition_word,
-			      rls->invalid_crc_count);
-		break;
-
-	case ZFCP_LS_PDISC:
-		pdisc = (struct zfcp_ls_pdisc_acc*)resp;
-		ZFCP_LOG_INFO("PDISC response from d_id 0x%08x to s_id "
-			      "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
-			      "vendor='%-16s')\n", port->d_id,
-			      port->adapter->s_id, pdisc->wwpn,
-			      pdisc->wwnn, pdisc->vendor_version);
-		break;
-
-	case ZFCP_LS_ADISC:
-		adisc = (struct zfcp_ls_adisc_acc*)resp;
-		ZFCP_LOG_INFO("ADISC response from d_id 0x%08x to s_id "
-			      "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
-			      "hard_nport_id=0x%08x, "
-			      "nport_id=0x%08x)\n", port->d_id,
-			      port->adapter->s_id, adisc->wwpn,
-			      adisc->wwnn, adisc->hard_nport_id,
-			      adisc->nport_id);
-		/* FIXME: set wwnn in during open port */
-		if (port->wwnn == 0)
-			port->wwnn = adisc->wwnn;
-		break;
+	adisc = zfcp_sg_to_address(send_els->resp);
+
+	ZFCP_LOG_INFO("ADISC response from d_id 0x%08x to s_id "
+		      "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
+		      "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
+		      d_id, adapter->s_id, (wwn_t) adisc->wwpn,
+		      (wwn_t) adisc->wwnn, adisc->hard_nport_id,
+		      adisc->nport_id);
+
+	/* set wwnn for port */
+	if (port->wwnn == 0)
+		port->wwnn = adisc->wwnn;
+
+	if (port->wwpn != adisc->wwpn) {
+		ZFCP_LOG_NORMAL("d_id assignment changed, reopening "
+				"port (adapter %s, wwpn=0x%016Lx, "
+				"adisc_resp_wwpn=0x%016Lx)\n",
+				zfcp_get_busid_by_port(port),
+				port->wwpn, (wwn_t) adisc->wwpn);
+		if (zfcp_erp_port_reopen(port, 0))
+			ZFCP_LOG_NORMAL("failed reopen of port "
+					"(adapter %s, wwpn=0x%016Lx)\n",
+					zfcp_get_busid_by_port(port),
+					port->wwpn);
 	}
 
  out:
+	zfcp_port_put(port);
 	__free_pages(send_els->req->page, 0);
+	kfree(send_els->timer);
 	kfree(send_els->req);
 	kfree(send_els->resp);
 	kfree(send_els);
 }
 
 
-/*
- * function:    zfcp_test_link
- *
- * purpose:     Test a status of a link to a remote port using the ELS command ADISC
+/**
+ * zfcp_test_link - lightweight link test procedure
+ * @port: port to be tested
  *
- * returns:     0       - Link is OK
- *              -EPERM  - Port forced reopen failed
+ * Test status of a link to a remote port using the ELS command ADISC.
  */
 int
 zfcp_test_link(struct zfcp_port *port)
 {
 	int retval;
 
-	retval = zfcp_els(port, ZFCP_LS_ADISC);
+	zfcp_port_get(port);
+	retval = zfcp_erp_adisc(port->adapter, port->d_id);
 	if (retval != 0) {
+		zfcp_port_put(port);
 		ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
 				"on adapter %s\n ", port->wwpn,
 				zfcp_get_busid_by_port(port));
@@ -1530,8 +1472,14 @@
 	zfcp_erp_modify_port_status(port,
 				    ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
 
-	ZFCP_LOG_NORMAL("port erp failed on port 0x%016Lx on adapter %s\n",
-			port->wwpn, zfcp_get_busid_by_port(port));
+	if (atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
+		ZFCP_LOG_NORMAL("port erp failed (adapter %s, "
+				"port d_id=0x%08x)\n",
+				zfcp_get_busid_by_port(port), port->d_id);
+	else
+		ZFCP_LOG_NORMAL("port erp failed (adapter %s, wwpn=0x%016Lx)\n",
+				zfcp_get_busid_by_port(port), port->wwpn);
+
 	debug_text_event(port->adapter->erp_dbf, 2, "p_pfail");
 	debug_event(port->adapter->erp_dbf, 2, &port->wwpn, sizeof (wwn_t));
 }
@@ -1667,63 +1615,6 @@
 	     !(ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status));
 }
 
-/**
- * zfcp_erp_scsi_add_device
- * @data: pointer to a struct zfcp_unit
- *
- * Registers a logical unit with the SCSI stack.
- */
-static void
-zfcp_erp_scsi_add_device(void *data)
-{
-	struct {
-		struct zfcp_unit  *unit;
-		struct work_struct work;
-	} *p;
-
-	p = data;
-	scsi_add_device(p->unit->port->adapter->scsi_host,
-			0, p->unit->port->scsi_id, p->unit->scsi_lun);
-	atomic_set(&p->unit->scsi_add_work, 0);
-	wake_up(&p->unit->scsi_add_wq);
-	zfcp_unit_put(p->unit);
-	kfree(p);
-}
-
-/**
- * zfcp_erp_schedule_work
- * @unit: pointer to unit which should be registered with SCSI stack
- *
- * Schedules work which registers a unit with the SCSI stack
- */
-static int
-zfcp_erp_schedule_work(struct zfcp_unit *unit)
-{
-	struct {
-		struct zfcp_unit * unit;
-		struct work_struct work;
-	} *p;
-
-	if (atomic_compare_and_swap(0, 1, &unit->scsi_add_work))
-		return 0;
-
-	if ((p = kmalloc(sizeof(*p), GFP_KERNEL)) == NULL) {
-		ZFCP_LOG_NORMAL("error: registration at SCSI stack failed for "
-				"unit 0x%016Lx on port 0x%016Lx on "
-				"adapter %s\n", unit->fcp_lun, unit->port->wwpn,
-				zfcp_get_busid_by_unit(unit));
-		atomic_set(&unit->scsi_add_work, 0);
-		return -ENOMEM;
-	}
-
-	zfcp_unit_get(unit);
-	memset(p, 0, sizeof(*p));
-	INIT_WORK(&p->work, zfcp_erp_scsi_add_device, p);
-	p->unit = unit;
-	schedule_work(&p->work);
-	return 0;
-}
-
 /*
  * function:	
  *
@@ -1893,34 +1784,22 @@
 static int
 zfcp_erp_strategy_check_queues(struct zfcp_adapter *adapter)
 {
-	int retval = 0;
 	unsigned long flags;
-	struct zfcp_port *nport = adapter->nameserver_port;
 
 	read_lock_irqsave(&zfcp_data.config_lock, flags);
 	read_lock(&adapter->erp_lock);
 	if (list_empty(&adapter->erp_ready_head) &&
 	    list_empty(&adapter->erp_running_head)) {
-		if (nport
-		    && atomic_test_mask(ZFCP_STATUS_COMMON_OPEN,
-					&nport->status)) {
-			debug_text_event(adapter->erp_dbf, 4, "a_cq_nspsd");
-			/* taking down nameserver port */
-			zfcp_erp_port_reopen_internal(nport,
-						      ZFCP_STATUS_COMMON_RUNNING |
-						      ZFCP_STATUS_COMMON_ERP_FAILED);
-		} else {
 			debug_text_event(adapter->erp_dbf, 4, "a_cq_wake");
 			atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
 					  &adapter->status);
 			wake_up(&adapter->erp_done_wqh);
-		}
 	} else
 		debug_text_event(adapter->erp_dbf, 5, "a_cq_notempty");
 	read_unlock(&adapter->erp_lock);
 	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
 
-	return retval;
+	return 0;
 }
 
 /**
@@ -2706,10 +2585,13 @@
 			/* nameserver port may live again */
 			atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING,
 					&adapter->nameserver_port->status);
-			if (zfcp_erp_port_reopen(adapter->nameserver_port, 0) >= 0) {
-				erp_action->step = ZFCP_ERP_STEP_NAMESERVER_OPEN;
+			if (zfcp_erp_port_reopen(adapter->nameserver_port, 0)
+			    >= 0) {
+				erp_action->step =
+					ZFCP_ERP_STEP_NAMESERVER_OPEN;
 				retval = ZFCP_ERP_CONTINUES;
-			} else  retval = ZFCP_ERP_FAILED;
+			} else
+				retval = ZFCP_ERP_FAILED;
 			break;
 		}
 		/* else nameserver port is already open, fall through */
@@ -2913,9 +2795,11 @@
 
 	atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
 			  ZFCP_STATUS_COMMON_CLOSING |
+			  ZFCP_STATUS_COMMON_ACCESS_DENIED |
 			  ZFCP_STATUS_PORT_DID_DID |
 			  ZFCP_STATUS_PORT_PHYS_CLOSING |
-			  ZFCP_STATUS_PORT_INVALID_WWPN, &port->status);
+			  ZFCP_STATUS_PORT_INVALID_WWPN,
+			  &port->status);
 	return retval;
 }
 
@@ -3119,7 +3003,11 @@
 	debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
 
 	atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
-			  ZFCP_STATUS_COMMON_CLOSING, &unit->status);
+			  ZFCP_STATUS_COMMON_CLOSING |
+			  ZFCP_STATUS_COMMON_ACCESS_DENIED |
+			  ZFCP_STATUS_UNIT_SHARED |
+			  ZFCP_STATUS_UNIT_READONLY,
+			  &unit->status);
 
 	return retval;
 }
@@ -3445,21 +3333,22 @@
 /**
  * zfcp_erp_action_cleanup
  *
- * registers unit with scsi stack if appropiate and fixes reference counts
+ * Register unit with scsi stack if appropiate and fix reference counts.
+ * Note: Temporary units are not registered with scsi stack.
  */
-
 static void
 zfcp_erp_action_cleanup(int action, struct zfcp_adapter *adapter,
 			struct zfcp_port *port, struct zfcp_unit *unit,
 			int result)
 {
-	if ((action == ZFCP_ERP_ACTION_REOPEN_UNIT)
-	    && (result == ZFCP_ERP_SUCCEEDED)
-	    && (!unit->device)) {
-		zfcp_erp_schedule_work(unit);
-	}
 	switch (action) {
 	case ZFCP_ERP_ACTION_REOPEN_UNIT:
+		if ((result == ZFCP_ERP_SUCCEEDED)
+		    && (!atomic_test_mask(ZFCP_STATUS_UNIT_TEMPORARY,
+					  &unit->status))
+		    && (!unit->device))
+ 			scsi_add_device(unit->port->adapter->scsi_host, 0,
+ 					unit->port->scsi_id, unit->scsi_lun);
 		zfcp_unit_put(unit);
 		break;
 	case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
@@ -3576,6 +3465,121 @@
 	debug_text_event(adapter->erp_dbf, 6, "a_tore");
 	debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
 	list_move(&erp_action->list, &erp_action->adapter->erp_ready_head);
+}
+
+/*
+ * function:	zfcp_erp_port_access_denied
+ *
+ * purpose:
+ */
+void
+zfcp_erp_port_access_denied(struct zfcp_port *port)
+{
+	struct zfcp_adapter *adapter = port->adapter;
+	unsigned long flags;
+
+	debug_text_event(adapter->erp_dbf, 3, "p_access_block");
+	debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
+	read_lock_irqsave(&zfcp_data.config_lock, flags);
+	zfcp_erp_modify_port_status(port, ZFCP_STATUS_COMMON_ERP_FAILED |
+				    ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET);
+	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
+}
+
+/*
+ * function:	zfcp_erp_unit_access_denied
+ *
+ * purpose:
+ */
+void
+zfcp_erp_unit_access_denied(struct zfcp_unit *unit)
+{
+	struct zfcp_adapter *adapter = unit->port->adapter;
+
+	debug_text_event(adapter->erp_dbf, 3, "u_access_block");
+	debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
+	zfcp_erp_modify_unit_status(unit, ZFCP_STATUS_COMMON_ERP_FAILED |
+				    ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET);
+}
+
+/*
+ * function:	zfcp_erp_adapter_access_changed
+ *
+ * purpose:
+ */
+void
+zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter)
+{
+	struct zfcp_port *port;
+	unsigned long flags;
+
+	debug_text_event(adapter->erp_dbf, 3, "a_access_unblock");
+	debug_event(adapter->erp_dbf, 3, &adapter->name, 8);
+
+	zfcp_erp_port_access_changed(adapter->nameserver_port);
+	read_lock_irqsave(&zfcp_data.config_lock, flags);
+	list_for_each_entry(port, &adapter->port_list_head, list)
+		if (port != adapter->nameserver_port)
+			zfcp_erp_port_access_changed(port);
+	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
+}
+
+/*
+ * function:	zfcp_erp_port_access_changed
+ *
+ * purpose:
+ */
+void
+zfcp_erp_port_access_changed(struct zfcp_port *port)
+{
+	struct zfcp_adapter *adapter = port->adapter;
+	struct zfcp_unit *unit;
+
+	debug_text_event(adapter->erp_dbf, 3, "p_access_unblock");
+	debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
+
+	if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
+			      &port->status)) {
+		if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
+			list_for_each_entry(unit, &port->unit_list_head, list)
+				zfcp_erp_unit_access_changed(unit);
+		return;
+	}
+
+	ZFCP_LOG_NORMAL("reopen of port 0x%016Lx on adapter %s "
+			"(due to ACT update)\n",
+			port->wwpn, zfcp_get_busid_by_adapter(adapter));
+	if (zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
+		ZFCP_LOG_NORMAL("failed reopen of port"
+				"(adapter %s, wwpn=0x%016Lx)\n",
+				zfcp_get_busid_by_adapter(adapter), port->wwpn);
+}
+
+/*
+ * function:	zfcp_erp_unit_access_changed
+ *
+ * purpose:
+ */
+void
+zfcp_erp_unit_access_changed(struct zfcp_unit *unit)
+{
+	struct zfcp_adapter *adapter = unit->port->adapter;
+
+	debug_text_event(adapter->erp_dbf, 3, "u_access_unblock");
+	debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
+
+	if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED, &unit->status))
+		return;
+
+	ZFCP_LOG_NORMAL("reopen of unit 0x%016Lx on port 0x%016Lx "
+			" on adapter %s (due to ACT update)\n",
+			unit->fcp_lun, unit->port->wwpn,
+			zfcp_get_busid_by_adapter(adapter));
+	if (zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
+		ZFCP_LOG_NORMAL("failed reopen of unit (adapter %s, "
+				"wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
+				zfcp_get_busid_by_adapter(adapter),
+				unit->port->wwpn, unit->fcp_lun);
 }
 
 #undef ZFCP_LOG_AREA
diff -Nru a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
--- a/drivers/s390/scsi/zfcp_ext.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/s390/scsi/zfcp_ext.h	2004-12-24 13:36:31 -08:00
@@ -12,6 +12,7 @@
  *            Wolfgang Taphorn
  *            Stefan Bader <stefan.bader@de.ibm.com> 
  *            Heiko Carstens <heiko.carstens@de.ibm.com> 
+ *            Andreas Herrmann <aherrman@de.ibm.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 
@@ -30,8 +31,8 @@
 
 #ifndef ZFCP_EXT_H
 #define ZFCP_EXT_H
-/* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_EXT_REVISION "$Revision: 1.57 $"
+
+#define ZFCP_EXT_REVISION "$Revision: 1.62 $"
 
 #include "zfcp_def.h"
 
@@ -169,6 +170,12 @@
 extern int  zfcp_erp_async_handler(struct zfcp_erp_action *, unsigned long);
 
 extern int  zfcp_test_link(struct zfcp_port *);
+
+extern void zfcp_erp_port_access_denied(struct zfcp_port *);
+extern void zfcp_erp_unit_access_denied(struct zfcp_unit *);
+extern void zfcp_erp_adapter_access_changed(struct zfcp_adapter *);
+extern void zfcp_erp_port_access_changed(struct zfcp_port *);
+extern void zfcp_erp_unit_access_changed(struct zfcp_unit *);
 
 /******************************** AUX ****************************************/
 extern void zfcp_cmd_dbf_event_fsf(const char *, struct zfcp_fsf_req *,
diff -Nru a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
--- a/drivers/s390/scsi/zfcp_fsf.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/s390/scsi/zfcp_fsf.c	2004-12-24 13:37:02 -08:00
@@ -12,6 +12,8 @@
  *            Wolfgang Taphorn
  *            Stefan Bader <stefan.bader@de.ibm.com>
  *            Heiko Carstens <heiko.carstens@de.ibm.com>
+ *            Andreas Herrmann <aherrman@de.ibm.com>
+ *            Volker Sameske <sameske@de.ibm.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
@@ -28,8 +30,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-/* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_FSF_C_REVISION "$Revision: 1.65 $"
+#define ZFCP_FSF_C_REVISION "$Revision: 1.88 $"
 
 #include "zfcp_ext.h"
 
@@ -783,12 +784,12 @@
 		zfcp_fsf_exchange_config_data_handler(fsf_req);
 		break;
 
-	case FSF_QTCB_EXCHANGE_PORT_DATA :
+	case FSF_QTCB_EXCHANGE_PORT_DATA:
 		ZFCP_LOG_FLAGS(2, "FSF_QTCB_EXCHANGE_PORT_DATA\n");
 		zfcp_fsf_exchange_port_data_handler(fsf_req);
 		break;
 
-	case FSF_QTCB_SEND_ELS :
+	case FSF_QTCB_SEND_ELS:
 		ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_ELS\n");
 		zfcp_fsf_send_els_handler(fsf_req);
 		break;
@@ -992,6 +993,15 @@
 		zfcp_fsf_incoming_els(fsf_req);
 		break;
 
+	case FSF_STATUS_READ_SENSE_DATA_AVAIL:
+		ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_SENSE_DATA_AVAIL\n");
+		debug_text_event(adapter->erp_dbf, 3, "unsol_sense:");
+		ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n",
+			      zfcp_get_busid_by_adapter(adapter));
+                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, (char *) status_buffer,
+                              sizeof(struct fsf_status_read_buffer));
+		break;
+
 	case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
 		ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_BIT_ERROR_THRESHOLD\n");
 		debug_text_event(adapter->erp_dbf, 3, "unsol_bit_err:");
@@ -1024,7 +1034,6 @@
 		zfcp_erp_adapter_reopen(adapter,
 					ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
 					| ZFCP_STATUS_COMMON_ERP_FAILED);
-
 		break;
 
 	case FSF_STATUS_READ_CFDC_UPDATED:
@@ -1032,6 +1041,7 @@
 		debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_update:");
 		ZFCP_LOG_INFO("CFDC has been updated on the adapter %s\n",
 			      zfcp_get_busid_by_adapter(adapter));
+		zfcp_erp_adapter_access_changed(adapter);
 		break;
 
 	case FSF_STATUS_READ_CFDC_HARDENED:
@@ -1289,6 +1299,22 @@
 		    | ZFCP_STATUS_FSFREQ_RETRY;
 		break;
 
+	case FSF_LUN_BOXED:
+                ZFCP_LOG_FLAGS(0, "FSF_LUN_BOXED\n");
+                ZFCP_LOG_INFO(
+                        "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
+                        "to be reopened\n",
+                        unit->fcp_lun, unit->port->wwpn,
+                        zfcp_get_busid_by_unit(unit));
+                debug_text_event(new_fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
+                zfcp_erp_unit_reopen(unit, 0);
+                zfcp_cmd_dbf_event_fsf("unitbox", new_fsf_req,
+                        &new_fsf_req->qtcb->header.fsf_status_qual,
+                        sizeof(union fsf_status_qual));
+                new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
+                        | ZFCP_STATUS_FSFREQ_RETRY;
+                break;
+
 	case FSF_ADAPTER_STATUS_AVAILABLE:
 		/* 2 */
 		ZFCP_LOG_FLAGS(0, "FSF_ADAPTER_STATUS_AVAILABLE\n");
@@ -1520,20 +1546,18 @@
 	header = &fsf_req->qtcb->header;
 	bottom = &fsf_req->qtcb->bottom.support;
 
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
-		/* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
+	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
 		goto skip_fsfstatus;
-	}
 
 	/* evaluate FSF status in QTCB */
 	switch (header->fsf_status) {
 
-        case FSF_GOOD :
+        case FSF_GOOD:
                 ZFCP_LOG_FLAGS(2,"FSF_GOOD\n");
                 retval = 0;
 		break;
 
-        case FSF_SERVICE_CLASS_NOT_SUPPORTED :
+        case FSF_SERVICE_CLASS_NOT_SUPPORTED:
 		ZFCP_LOG_FLAGS(2, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n");
 		if (adapter->fc_service_class <= 3) {
 			ZFCP_LOG_INFO("error: adapter %s does not support fc "
@@ -1549,21 +1573,21 @@
 		}
 		/* stop operation for this adapter */
 		debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
-		zfcp_erp_adapter_shutdown(port->adapter, 0);
+		zfcp_erp_adapter_shutdown(adapter, 0);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
-        case FSF_ADAPTER_STATUS_AVAILABLE :
+        case FSF_ADAPTER_STATUS_AVAILABLE:
                 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
                 switch (header->fsf_status_qual.word[0]){
-                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE :
+                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
 			ZFCP_LOG_FLAGS(2,"FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
 			/* reopening link to port */
 			debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
 			zfcp_test_link(port);
 			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 			break;
-                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED :
+                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
 			ZFCP_LOG_FLAGS(2,"FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
 			/* ERP strategy will escalate */
 			debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
@@ -1579,9 +1603,9 @@
 
 	case FSF_ACCESS_DENIED:
 		ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
-		ZFCP_LOG_NORMAL("Access denied, cannot send generic command "
-				"to port 0x%016Lx on adapter %s\n", port->wwpn,
-				zfcp_get_busid_by_port(port));
+		ZFCP_LOG_NORMAL("access denied, cannot send generic service "
+				"command (adapter %s, port d_id=0x%08x)\n",
+				zfcp_get_busid_by_port(port), port->d_id);
 		for (counter = 0; counter < 2; counter++) {
 			subtable = header->fsf_status_qual.halfword[counter * 2];
 			rule = header->fsf_status_qual.halfword[counter * 2 + 1];
@@ -1595,15 +1619,16 @@
 				break;
 			}
 		}
-		debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
+		debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
+		zfcp_erp_port_access_denied(port);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
-        case FSF_GENERIC_COMMAND_REJECTED :
+        case FSF_GENERIC_COMMAND_REJECTED:
 		ZFCP_LOG_FLAGS(2, "FSF_GENERIC_COMMAND_REJECTED\n");
-		ZFCP_LOG_INFO("warning: The port 0x%016Lx on adapter %s has "
-			      "rejected a generic services command.\n",
-			      port->wwpn, zfcp_get_busid_by_port(port));
+		ZFCP_LOG_INFO("generic service command rejected "
+			      "(adapter %s, port d_id=0x%08x)\n",
+			      zfcp_get_busid_by_port(port), port->d_id);
 		ZFCP_LOG_INFO("status qualifier:\n");
 		ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
 			      (char *) &header->fsf_status_qual,
@@ -1612,7 +1637,7 @@
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
-        case FSF_PORT_HANDLE_NOT_VALID :
+        case FSF_PORT_HANDLE_NOT_VALID:
 		ZFCP_LOG_FLAGS(2, "FSF_PORT_HANDLE_NOT_VALID\n");
 		ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
 			       "0x%016Lx on adapter %s invalid. This may "
@@ -1623,22 +1648,57 @@
 			      (char *) &header->fsf_status_qual,
 			      sizeof (union fsf_status_qual));
 		debug_text_event(adapter->erp_dbf, 1, "fsf_s_phandle_nv");
-		zfcp_erp_adapter_reopen(port->adapter, 0);
+		zfcp_erp_adapter_reopen(adapter, 0);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
-        case FSF_PORT_BOXED :
+        case FSF_PORT_BOXED:
 		ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
-		ZFCP_LOG_INFO("The remote port 0x%016Lx on adapter %s "
-			       "needs to be reopened\n",
-			       port->wwpn, zfcp_get_busid_by_port(port));
+		ZFCP_LOG_INFO("port needs to be reopened "
+			      "(adapter %s, port d_id=0x%08x)\n",
+			      zfcp_get_busid_by_port(port), port->d_id);
 		debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
 		zfcp_erp_port_reopen(port, 0);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
 		    | ZFCP_STATUS_FSFREQ_RETRY;
 		break;
 
-       default :
+	/* following states should never occure, all cases avoided
+	   in zfcp_fsf_send_ct - but who knows ... */
+	case FSF_PAYLOAD_SIZE_MISMATCH:
+		ZFCP_LOG_FLAGS(2, "FSF_PAYLOAD_SIZE_MISMATCH\n");
+		ZFCP_LOG_INFO("payload size mismatch (adapter: %s, "
+			      "req_buf_length=%d, resp_buf_length=%d)\n",
+			      zfcp_get_busid_by_adapter(adapter),
+			      bottom->req_buf_length, bottom->resp_buf_length);
+		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+		break;
+	case FSF_REQUEST_SIZE_TOO_LARGE:
+		ZFCP_LOG_FLAGS(2, "FSF_REQUEST_SIZE_TOO_LARGE\n");
+		ZFCP_LOG_INFO("request size too large (adapter: %s, "
+			      "req_buf_length=%d)\n",
+			      zfcp_get_busid_by_adapter(adapter),
+			      bottom->req_buf_length);
+		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+		break;
+	case FSF_RESPONSE_SIZE_TOO_LARGE:
+		ZFCP_LOG_FLAGS(2, "FSF_RESPONSE_SIZE_TOO_LARGE\n");
+		ZFCP_LOG_INFO("response size too large (adapter: %s, "
+			      "resp_buf_length=%d)\n",
+			      zfcp_get_busid_by_adapter(adapter),
+			      bottom->resp_buf_length);
+		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+		break;
+	case FSF_SBAL_MISMATCH:
+		ZFCP_LOG_FLAGS(2, "FSF_SBAL_MISMATCH\n");
+		ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
+			      "resp_buf_length=%d)\n",
+			      zfcp_get_busid_by_adapter(adapter),
+			      bottom->req_buf_length, bottom->resp_buf_length);
+		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+		break;
+
+       default:
 		ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
 				"(debug info 0x%x)\n", header->fsf_status);
 		debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval:");
@@ -1666,22 +1726,22 @@
 {
 	volatile struct qdio_buffer_element *sbale;
 	struct zfcp_fsf_req *fsf_req;
-	struct zfcp_port *port;
+	fc_id_t d_id;
 	struct zfcp_adapter *adapter;
 	unsigned long lock_flags;
         int bytes;
 	int ret = 0;
 
-	port = els->port;
-	adapter = port->adapter;
+	d_id = els->d_id;
+	adapter = els->adapter;
 
         ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS,
-				  ZFCP_WAIT_FOR_SBAL|ZFCP_REQ_AUTO_CLEANUP,
+				  ZFCP_REQ_AUTO_CLEANUP,
 				  NULL, &lock_flags, &fsf_req);
 	if (ret < 0) {
                 ZFCP_LOG_INFO("error: creation of ELS request failed "
 			      "(adapter %s, port d_id: 0x%08x)\n",
-                              zfcp_get_busid_by_adapter(adapter), port->d_id);
+                              zfcp_get_busid_by_adapter(adapter), d_id);
                 goto failed_req;
 	}
 
@@ -1706,8 +1766,7 @@
                 if (bytes <= 0) {
                         ZFCP_LOG_INFO("error: creation of ELS request failed "
 				      "(adapter %s, port d_id: 0x%08x)\n",
-				      zfcp_get_busid_by_adapter(adapter),
-				      port->d_id);
+				      zfcp_get_busid_by_adapter(adapter), d_id);
                         if (bytes == 0) {
                                 ret = -ENOMEM;
                         } else {
@@ -1724,8 +1783,7 @@
                 if (bytes <= 0) {
                         ZFCP_LOG_INFO("error: creation of ELS request failed "
 				      "(adapter %s, port d_id: 0x%08x)\n",
-				      zfcp_get_busid_by_adapter(adapter),
-				      port->d_id);
+				      zfcp_get_busid_by_adapter(adapter), d_id);
                         if (bytes == 0) {
                                 ret = -ENOMEM;
                         } else {
@@ -1739,13 +1797,13 @@
 		ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
                               ", ELS request too big (adapter %s, "
 			      "port d_id: 0x%08x)\n",
-			      zfcp_get_busid_by_adapter(adapter), port->d_id);
+			      zfcp_get_busid_by_adapter(adapter), d_id);
                 ret = -EOPNOTSUPP;
                 goto failed_send;
         }
 
 	/* settings in QTCB */
-	fsf_req->qtcb->bottom.support.d_id = port->d_id;
+	fsf_req->qtcb->bottom.support.d_id = d_id;
 	fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class;
 	fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT;
 	fsf_req->data.send_els = els;
@@ -1756,13 +1814,13 @@
 	ret = zfcp_fsf_req_send(fsf_req, els->timer);
 	if (ret) {
 		ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
-			       "(adapter %s, port 0x%016Lx)\n",
-			       zfcp_get_busid_by_adapter(adapter), port->wwpn);
+			       "(adapter %s, port d_id: 0x%08x)\n",
+			       zfcp_get_busid_by_adapter(adapter), d_id);
 		goto failed_send;
 	}
 
-	ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port 0x%016Lx)\n",
-		       zfcp_get_busid_by_adapter(adapter), port->wwpn);
+	ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: "
+		       "0x%08x)\n", zfcp_get_busid_by_adapter(adapter), d_id);
 	goto out;
 
  failed_send:
@@ -1788,6 +1846,7 @@
 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
 {
 	struct zfcp_adapter *adapter;
+	fc_id_t d_id;
 	struct zfcp_port *port;
 	struct fsf_qtcb_header *header;
 	struct fsf_qtcb_bottom_support *bottom;
@@ -1795,9 +1854,9 @@
 	int retval = -EINVAL;
 	u16 subtable, rule, counter;
 
-	adapter = fsf_req->adapter;
 	send_els = fsf_req->data.send_els;
-	port = send_els->port;
+	adapter = send_els->adapter;
+	d_id = send_els->d_id;
 	header = &fsf_req->qtcb->header;
 	bottom = &fsf_req->qtcb->bottom.support;
 
@@ -1816,35 +1875,38 @@
 		if (adapter->fc_service_class <= 3) {
 			ZFCP_LOG_INFO("error: adapter %s does "
 				      "not support fibrechannel class %d.\n",
-				      zfcp_get_busid_by_port(port),
+				      zfcp_get_busid_by_adapter(adapter),
 				      adapter->fc_service_class);
 		} else {
 			ZFCP_LOG_INFO("bug: The fibrechannel class at "
 				      "adapter %s is invalid. "
 				      "(debug info %d)\n",
-				      zfcp_get_busid_by_port(port),
+				      zfcp_get_busid_by_adapter(adapter),
 				      adapter->fc_service_class);
 		}
 		/* stop operation for this adapter */
 		debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
-		zfcp_erp_adapter_shutdown(port->adapter, 0);
+		zfcp_erp_adapter_shutdown(adapter, 0);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
 	case FSF_ADAPTER_STATUS_AVAILABLE:
 		ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
 		switch (header->fsf_status_qual.word[0]){
-		case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: {
+		case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
 			ZFCP_LOG_FLAGS(2,"FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
 			debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
-			if (send_els->ls_code != ZFCP_LS_ADISC)
-				zfcp_test_link(port);
+			if (send_els->ls_code != ZFCP_LS_ADISC) {
+				read_lock(&zfcp_data.config_lock);
+				port = zfcp_get_port_by_did(adapter, d_id);
+				if (port)
+					zfcp_test_link(port);
+				read_unlock(&zfcp_data.config_lock);
+			}
 			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 			break;
-		}
 		case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
 			ZFCP_LOG_FLAGS(2,"FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
-			/* ERP strategy will escalate */
 			debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
 			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 			retval =
@@ -1869,8 +1931,8 @@
 		ZFCP_LOG_FLAGS(2, "FSF_ELS_COMMAND_REJECTED\n");
 		ZFCP_LOG_INFO("ELS has been rejected because command filter "
 			      "prohibited sending "
-			      "(adapter: %s, wwpn=0x%016Lx)\n",
-			      zfcp_get_busid_by_port(port), port->wwpn);
+			      "(adapter: %s, port d_id: 0x%08x)\n",
+			      zfcp_get_busid_by_adapter(adapter), d_id);
 
 		break;
 
@@ -1880,7 +1942,7 @@
 			"ELS request size and ELS response size must be either "
 			"both 0, or both greater than 0 "
 			"(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
-			zfcp_get_busid_by_port(port),
+			zfcp_get_busid_by_adapter(adapter),
 			bottom->req_buf_length,
 			bottom->resp_buf_length);
 		break;
@@ -1893,7 +1955,7 @@
 			"exceeds the size of the buffers "
 			"that have been allocated for ELS request data "
 			"(adapter: %s, req_buf_length=%d)\n",
-			zfcp_get_busid_by_port(port),
+			zfcp_get_busid_by_adapter(adapter),
 			bottom->req_buf_length);
 		break;
 
@@ -1905,15 +1967,25 @@
 			"exceeds the size of the buffers "
 			"that have been allocated for ELS response data "
 			"(adapter: %s, resp_buf_length=%d)\n",
-			zfcp_get_busid_by_port(port),
+			zfcp_get_busid_by_adapter(adapter),
 			bottom->resp_buf_length);
 		break;
 
+	case FSF_SBAL_MISMATCH:
+		/* should never occure, avoided in zfcp_fsf_send_els */
+		ZFCP_LOG_FLAGS(2, "FSF_SBAL_MISMATCH\n");
+		ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
+			      "resp_buf_length=%d)\n",
+			      zfcp_get_busid_by_adapter(adapter),
+			      bottom->req_buf_length, bottom->resp_buf_length);
+		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+		break;
+
 	case FSF_ACCESS_DENIED:
 		ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
-		ZFCP_LOG_NORMAL("Access denied, cannot send ELS "
-				"(adapter: %s, wwpn=0x%016Lx)\n",
-				zfcp_get_busid_by_port(port), port->wwpn);
+		ZFCP_LOG_NORMAL("access denied, cannot send ELS command "
+				"(adapter %s, port d_id=0x%08x)\n",
+				zfcp_get_busid_by_adapter(adapter), d_id);
 		for (counter = 0; counter < 2; counter++) {
 			subtable = header->fsf_status_qual.halfword[counter * 2];
 			rule = header->fsf_status_qual.halfword[counter * 2 + 1];
@@ -1928,6 +2000,11 @@
 			}
 		}
 		debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
+		read_lock(&zfcp_data.config_lock);
+		port = zfcp_get_port_by_did(adapter, d_id);
+		if (port != NULL)
+			zfcp_erp_port_access_denied(port);
+		read_unlock(&zfcp_data.config_lock);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
@@ -1935,7 +2012,7 @@
 		ZFCP_LOG_NORMAL(
 			"bug: An unknown FSF Status was presented "
 			"(adapter: %s, fsf_status=0x%08x)\n",
-			zfcp_get_busid_by_port(port),
+			zfcp_get_busid_by_adapter(adapter),
 			header->fsf_status);
 		debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval");
 		debug_exception(adapter->erp_dbf, 0,
@@ -1988,7 +2065,7 @@
 
 	erp_action->fsf_req->erp_action = erp_action;
 	erp_action->fsf_req->qtcb->bottom.config.feature_selection =
-		FSF_FEATURE_CFDC;
+		(FSF_FEATURE_CFDC | FSF_FEATURE_LUN_SHARING);
 
 	/* start QDIO request for this FSF request */
 	retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
@@ -2287,7 +2364,7 @@
 		return;
 
 	switch (fsf_req->qtcb->header.fsf_status) {
-        case FSF_GOOD :
+        case FSF_GOOD:
                 ZFCP_LOG_FLAGS(2,"FSF_GOOD\n");
                 bottom = &fsf_req->qtcb->bottom.port;
                 memcpy(data, bottom, sizeof(*data));
@@ -2406,7 +2483,7 @@
 		ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
 		ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
 				"on adapter %s\n",
-			port->wwpn, zfcp_get_busid_by_port(port));
+				port->wwpn, zfcp_get_busid_by_port(port));
 		for (counter = 0; counter < 2; counter++) {
 			subtable = header->fsf_status_qual.halfword[counter * 2];
 			rule = header->fsf_status_qual.halfword[counter * 2 + 1];
@@ -2421,7 +2498,7 @@
 			}
 		}
 		debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
-		zfcp_erp_port_failed(port);
+		zfcp_erp_port_access_denied(port);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
@@ -2537,6 +2614,16 @@
 		}
 		break;
 
+	case FSF_UNKNOWN_OP_SUBTYPE:
+		/* should never occure, subtype not set in zfcp_fsf_open_port */
+		ZFCP_LOG_FLAGS(2, "FSF_UNKNOWN_OP_SUBTYPE\n");
+		ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
+			      "op_subtype=0x%x)\n",
+			      zfcp_get_busid_by_port(port),
+			      fsf_req->qtcb->bottom.support.operation_subtype);
+		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+		break;
+
 	default:
 		ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
 				"(debug info 0x%x)\n",
@@ -2803,9 +2890,8 @@
 	case FSF_ACCESS_DENIED:
 		ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
 		ZFCP_LOG_NORMAL("Access denied, cannot close "
-				"physical port 0x%016Lx on "
-				"adapter %s\n", port->wwpn,
-				zfcp_get_busid_by_port(port));
+				"physical port 0x%016Lx on adapter %s\n",
+				port->wwpn, zfcp_get_busid_by_port(port));
 		for (counter = 0; counter < 2; counter++) {
 			subtable = header->fsf_status_qual.halfword[counter * 2];
 			rule = header->fsf_status_qual.halfword[counter * 2 + 1];
@@ -2820,6 +2906,7 @@
 			}
 		}
 		debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
+		zfcp_erp_port_access_denied(port);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
@@ -2941,6 +3028,8 @@
 		erp_action->port->handle;
 	erp_action->fsf_req->qtcb->bottom.support.fcp_lun =
 		erp_action->unit->fcp_lun;
+	erp_action->fsf_req->qtcb->bottom.support.option =
+		FSF_OPEN_LUN_SUPPRESS_BOXING;
 	atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status);
 	erp_action->fsf_req->data.open_unit.unit = erp_action->unit;
 	erp_action->fsf_req->erp_action = erp_action;
@@ -2984,18 +3073,31 @@
 	struct zfcp_unit *unit;
 	struct fsf_qtcb_header *header;
 	struct fsf_qtcb_bottom_support *bottom;
+	struct fsf_queue_designator *queue_designator;
 	u16 subtable, rule, counter;
+	u32 allowed, exclusive, readwrite;
 
-	adapter = fsf_req->adapter;
 	unit = fsf_req->data.open_unit.unit;
-	header = &fsf_req->qtcb->header;
-	bottom = &fsf_req->qtcb->bottom.support;
 
 	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
 		/* don't change unit status in our bookkeeping */
 		goto skip_fsfstatus;
 	}
 
+	adapter = fsf_req->adapter;
+	header = &fsf_req->qtcb->header;
+	bottom = &fsf_req->qtcb->bottom.support;
+	queue_designator = &header->fsf_status_qual.fsf_queue_designator;
+
+	allowed   = bottom->lun_access_info & FSF_UNIT_ACCESS_OPEN_LUN_ALLOWED;
+	exclusive = bottom->lun_access_info & FSF_UNIT_ACCESS_EXCLUSIVE;
+	readwrite = bottom->lun_access_info & FSF_UNIT_ACCESS_OUTBOUND_TRANSFER;
+
+	atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
+			  ZFCP_STATUS_UNIT_SHARED |
+			  ZFCP_STATUS_UNIT_READONLY,
+			  &unit->status);
+
 	/* evaluate FSF status in QTCB */
 	switch (header->fsf_status) {
 
@@ -3046,7 +3148,9 @@
 			}
 		}
 		debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
-		zfcp_erp_unit_failed(unit);
+		zfcp_erp_unit_access_denied(unit);
+		atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
+                atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
@@ -3061,17 +3165,18 @@
 			ZFCP_STATUS_FSFREQ_RETRY;
 		break;
 
-	case FSF_LUN_SHARING_VIOLATION :
+	case FSF_LUN_SHARING_VIOLATION:
 		ZFCP_LOG_FLAGS(2, "FSF_LUN_SHARING_VIOLATION\n");
 		if (header->fsf_status_qual.word[0] != 0) {
 			ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
 					"with WWPN 0x%Lx "
 					"connected to the adapter %s "
-					"is already in use in LPAR%d\n",
+					"is already in use in LPAR%d, CSS%d\n",
 					unit->fcp_lun,
 					unit->port->wwpn,
 					zfcp_get_busid_by_unit(unit),
-					header->fsf_status_qual.fsf_queue_designator.hla);
+					queue_designator->hla,
+					queue_designator->cssid);
 		} else {
 			subtable = header->fsf_status_qual.halfword[4];
 			rule = header->fsf_status_qual.halfword[5];
@@ -3172,6 +3277,38 @@
 			       unit->handle);
 		/* mark unit as open */
 		atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
+
+		if (adapter->supported_features & FSF_FEATURE_LUN_SHARING){
+			if (!exclusive)
+		                atomic_set_mask(ZFCP_STATUS_UNIT_SHARED,
+						&unit->status);
+
+			if (!readwrite) {
+                		atomic_set_mask(ZFCP_STATUS_UNIT_READONLY,
+						&unit->status);
+                		ZFCP_LOG_NORMAL("read-only access for unit "
+						"(adapter %s, wwpn=0x%016Lx, "
+						"fcp_lun=0x%016Lx)\n",
+						zfcp_get_busid_by_unit(unit),
+						unit->port->wwpn,
+						unit->fcp_lun);
+        		}
+
+        		if (exclusive && !readwrite) {
+                		ZFCP_LOG_NORMAL("exclusive access of read-only "
+						"unit not supported\n");
+				zfcp_erp_unit_failed(unit);
+				fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+				zfcp_erp_unit_shutdown(unit, 0);
+        		} else if (!exclusive && readwrite) {
+                		ZFCP_LOG_NORMAL("shared access of read-write "
+						"unit not supported\n");
+                		zfcp_erp_unit_failed(unit);
+				fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
+				zfcp_erp_unit_shutdown(unit, 0);
+        		}
+		}
+
 		retval = 0;
 		break;
 
@@ -3185,7 +3322,7 @@
 		break;
 	}
 
-      skip_fsfstatus:
+ skip_fsfstatus:
 	atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &unit->status);
 	return retval;
 }
@@ -3421,6 +3558,7 @@
 	unsigned long lock_flags;
 	int real_bytes = 0;
 	int retval = 0;
+	int mask;
 
 	/* setup new FSF request */
 	retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
@@ -3505,14 +3643,14 @@
 	/* set FCP_LUN in FCP_CMND IU in QTCB */
 	fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
 
+	mask = ZFCP_STATUS_UNIT_READONLY | ZFCP_STATUS_UNIT_SHARED;
+
 	/* set task attributes in FCP_CMND IU in QTCB */
-	if (likely(scsi_cmnd->device->simple_tags)) {
+	if (likely((scsi_cmnd->device->simple_tags) ||
+		   (atomic_test_mask(mask, &unit->status))))
 		fcp_cmnd_iu->task_attribute = SIMPLE_Q;
-		ZFCP_LOG_TRACE("setting SIMPLE_Q task attribute\n");
-	} else {
+	else
 		fcp_cmnd_iu->task_attribute = UNTAGGED;
-		ZFCP_LOG_TRACE("setting UNTAGGED task attribute\n");
-	}
 
 	/* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
 	if (unlikely(scsi_cmnd->cmd_len > FCP_CDB_LENGTH)) {
@@ -3847,6 +3985,7 @@
 			}
 		}
 		debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
+		zfcp_erp_unit_access_denied(unit);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		break;
 
@@ -3906,16 +4045,15 @@
 
 	case FSF_LUN_BOXED:
 		ZFCP_LOG_FLAGS(0, "FSF_LUN_BOXED\n");
-		ZFCP_LOG_NORMAL(
-			"unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
-			"to be reopened\n",
-			unit->fcp_lun, unit->port->wwpn,
-			zfcp_get_busid_by_unit(unit));
+		ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
+				"wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
+				zfcp_get_busid_by_unit(unit),
+				unit->port->wwpn, unit->fcp_lun);
 		debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
 		zfcp_erp_unit_reopen(unit, 0);
 		zfcp_cmd_dbf_event_fsf("unitbox", fsf_req,
-			&header->fsf_status_qual,
-			sizeof(union fsf_status_qual));
+				       &header->fsf_status_qual,
+				       sizeof(union fsf_status_qual));
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
 			| ZFCP_STATUS_FSFREQ_RETRY;
 		break;
@@ -4306,7 +4444,7 @@
  *              -EOPNOTSUPP - The FCP adapter does not have Control File support
  *              -EINVAL     - Invalid direction specified
  *              -ENOMEM     - Insufficient memory
- *              -EPERM      - Cannot create FSF request or or place it in QDIO queue
+ *              -EPERM      - Cannot create FSF request or place it in QDIO queue
  */
 int
 zfcp_fsf_control_file(struct zfcp_adapter *adapter,
@@ -4318,17 +4456,17 @@
 	struct zfcp_fsf_req *fsf_req;
 	struct fsf_qtcb_bottom_support *bottom;
 	volatile struct qdio_buffer_element *sbale;
+	struct timer_list *timer;
 	unsigned long lock_flags;
 	int req_flags = 0;
 	int direction;
 	int retval = 0;
 
 	if (!(adapter->supported_features & FSF_FEATURE_CFDC)) {
-		ZFCP_LOG_INFO(
-			"Adapter %s does not support control file\n",
-			zfcp_get_busid_by_adapter(adapter));
+		ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
+			      zfcp_get_busid_by_adapter(adapter));
 		retval = -EOPNOTSUPP;
-		goto no_cfdc_support;
+		goto out;
 	}
 
 	switch (fsf_command) {
@@ -4346,9 +4484,16 @@
 
 	default:
 		ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command);
-		goto invalid_command;
+		retval = -EINVAL;
+		goto out;
 	}
 
+	timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
+	if (!timer) {
+		retval = -ENOMEM;
+		goto out;
+ 	}
+
 	retval = zfcp_fsf_req_create(adapter, fsf_command, req_flags,
 				     NULL, &lock_flags, &fsf_req);
 	if (retval < 0) {
@@ -4356,7 +4501,7 @@
 			      "adapter %s\n",
 			zfcp_get_busid_by_adapter(adapter));
 		retval = -EPERM;
-		goto out;
+		goto unlock_queue_lock;
 	}
 
 	sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
@@ -4378,40 +4523,46 @@
 				"SBALS for an FSF request to the adapter %s\n",
 				zfcp_get_busid_by_adapter(adapter));
 			retval = -ENOMEM;
-			goto sbals_failed;
+			goto free_fsf_req;
 		}
-	} else {
+	} else
 		sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
-	}
 
-	retval = zfcp_fsf_req_send(fsf_req, NULL);
+	init_timer(timer);
+	timer->function = zfcp_fsf_request_timeout_handler;
+	timer->data = (unsigned long) adapter;
+	timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
+
+	retval = zfcp_fsf_req_send(fsf_req, timer);
 	if (retval < 0) {
-		ZFCP_LOG_INFO(
-			"error: Could not send FSF request to the adapter %s\n",
-			zfcp_get_busid_by_adapter(adapter));
+		ZFCP_LOG_INFO("initiation of cfdc up/download failed"
+			      "(adapter %s)\n",
+			      zfcp_get_busid_by_adapter(adapter));
 		retval = -EPERM;
-		goto queue_failed;
+		goto free_fsf_req;
 	}
+	write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
 
-	ZFCP_LOG_NORMAL(
-		"Control file %s FSF request has been sent to the adapter %s\n",
-		fsf_command == FSF_QTCB_DOWNLOAD_CONTROL_FILE ?
+	ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
+			"adapter %s\n",
+			fsf_command == FSF_QTCB_DOWNLOAD_CONTROL_FILE ?
 			"download" : "upload",
-		zfcp_get_busid_by_adapter(adapter));
+			zfcp_get_busid_by_adapter(adapter));
 
-	*fsf_req_ptr = fsf_req;
+	wait_event(fsf_req->completion_wq,
+	           fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
 
-	goto out;
+	*fsf_req_ptr = fsf_req;
+	del_timer_sync(timer);
+	goto free_timer;
 
-sbals_failed:
-queue_failed:
+ free_fsf_req:
 	zfcp_fsf_req_free(fsf_req);
-
-out:
+ unlock_queue_lock:
 	write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
-
-invalid_command:
-no_cfdc_support:
+ free_timer:
+	kfree(timer);
+ out:
 	return retval;
 }
 
@@ -4550,11 +4701,10 @@
 
 	case FSF_UNKNOWN_OP_SUBTYPE:
 		ZFCP_LOG_FLAGS(2, "FSF_UNKNOWN_OP_SUBTYPE\n");
-		ZFCP_LOG_NORMAL(
-			"Invalid operation subtype 0x%x has been specified "
-			"in QTCB bottom sent to the adapter %s\n",
-			bottom->operation_subtype,
-			zfcp_get_busid_by_adapter(adapter));
+		ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
+				"op_subtype=0x%x)\n",
+				zfcp_get_busid_by_adapter(adapter),
+				bottom->operation_subtype);
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
 		retval = -EINVAL;
 		break;
@@ -4682,6 +4832,8 @@
 						       ZFCP_SBAL_TIMEOUT);
 		if (ret < 0)
 			return ret;
+		if (!ret)
+			return -EIO;
         } else if (!zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1))
                 return -EIO;
 
diff -Nru a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h
--- a/drivers/s390/scsi/zfcp_fsf.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/s390/scsi/zfcp_fsf.h	2004-12-24 13:37:18 -08:00
@@ -11,7 +11,9 @@
  *            Aron Zeh
  *            Wolfgang Taphorn
  *            Stefan Bader <stefan.bader@de.ibm.com> 
- *            Heiko Carstens <heiko.carstens@de.ibm.com> 
+ *            Heiko Carstens <heiko.carstens@de.ibm.com>
+ *            Andreas Herrmann <aherrman@de.ibm.com>
+ *            Volker Sameske <sameske@de.ibm.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 
@@ -105,6 +107,8 @@
 #define FSF_PAYLOAD_SIZE_MISMATCH		0x00000060
 #define FSF_REQUEST_SIZE_TOO_LARGE		0x00000061
 #define FSF_RESPONSE_SIZE_TOO_LARGE		0x00000062
+#define FSF_SBAL_MISMATCH			0x00000063
+#define FSF_OPEN_PORT_WITHOUT_PRLI		0x00000064
 #define FSF_ADAPTER_STATUS_AVAILABLE		0x000000AD
 #define FSF_FCP_RSP_AVAILABLE			0x000000AF
 #define FSF_UNKNOWN_COMMAND			0x000000E2
@@ -147,6 +151,7 @@
 /* status types in status read buffer */
 #define FSF_STATUS_READ_PORT_CLOSED		0x00000001
 #define FSF_STATUS_READ_INCOMING_ELS		0x00000002
+#define FSF_STATUS_READ_SENSE_DATA_AVAIL        0x00000003
 #define FSF_STATUS_READ_BIT_ERROR_THRESHOLD	0x00000004
 #define FSF_STATUS_READ_LINK_DOWN		0x00000005 /* FIXME: really? */
 #define FSF_STATUS_READ_LINK_UP          	0x00000006
@@ -189,11 +194,13 @@
 /* channel features */
 #define FSF_FEATURE_QTCB_SUPPRESSION            0x00000001
 #define FSF_FEATURE_CFDC			0x00000002
+#define FSF_FEATURE_LUN_SHARING			0x00000004
 #define FSF_FEATURE_HBAAPI_MANAGEMENT           0x00000010
 #define FSF_FEATURE_ELS_CT_CHAINED_SBALS        0x00000020
 
 /* option */
 #define FSF_OPEN_LUN_SUPPRESS_BOXING		0x00000001
+#define FSF_OPEN_LUN_REPLICATE_SENSE		0x00000002
 
 /* adapter types */
 #define FSF_ADAPTER_TYPE_FICON                  0x00000001
@@ -225,6 +232,11 @@
 #define FSF_IOSTAT_FABRIC_RJT			0x00000005
 #define FSF_IOSTAT_LS_RJT			0x00000009
 
+/* open LUN access flags*/
+#define FSF_UNIT_ACCESS_OPEN_LUN_ALLOWED	0x01000000
+#define FSF_UNIT_ACCESS_EXCLUSIVE		0x02000000
+#define FSF_UNIT_ACCESS_OUTBOUND_TRANSFER	0x10000000
+
 struct fsf_queue_designator;
 struct fsf_status_read_buffer;
 struct fsf_port_closed_payload;
@@ -378,7 +390,8 @@
 	u32 service_class;
 	u8  res3[3];
 	u8  timeout;
-	u8  res4[184];
+        u32 lun_access_info;
+        u8  res4[180];
 	u32 els1_length;
 	u32 els2_length;
 	u32 req_buf_length;
diff -Nru a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
--- a/drivers/s390/scsi/zfcp_qdio.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/s390/scsi/zfcp_qdio.c	2004-12-24 13:36:18 -08:00
@@ -12,6 +12,7 @@
  *      Raimund Schroeder <raimund.schroeder@de.ibm.com>
  *      Wolfgang Taphorn
  *      Heiko Carstens <heiko.carstens@de.ibm.com>
+ *      Andreas Herrmann <aherrman@de.ibm.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
@@ -28,7 +29,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_QDIO_C_REVISION "$Revision: 1.19 $"
+#define ZFCP_QDIO_C_REVISION "$Revision: 1.20 $"
 
 #include "zfcp_ext.h"
 
diff -Nru a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
--- a/drivers/s390/scsi/zfcp_scsi.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/s390/scsi/zfcp_scsi.c	2004-12-24 13:37:43 -08:00
@@ -12,6 +12,7 @@
  *            Wolfgang Taphorn
  *            Stefan Bader <stefan.bader@de.ibm.com> 
  *            Heiko Carstens <heiko.carstens@de.ibm.com> 
+ *            Andreas Herrmann <aherrman@de.ibm.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 
@@ -30,8 +31,7 @@
 
 #define ZFCP_LOG_AREA			ZFCP_LOG_AREA_SCSI
 
-/* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_SCSI_REVISION "$Revision: 1.68 $"
+#define ZFCP_SCSI_REVISION "$Revision: 1.74 $"
 
 #include "zfcp_ext.h"
 
@@ -48,6 +48,8 @@
 
 static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *, int, scsi_id_t,
 					  scsi_lun_t);
+static struct zfcp_port *zfcp_port_lookup(struct zfcp_adapter *, int,
+					  scsi_id_t);
 
 static struct device_attribute *zfcp_sysfs_sdev_attrs[];
 
@@ -79,7 +81,8 @@
 	      unchecked_isa_dma:       0,
 	      use_clustering:          1,
 	      sdev_attrs:              zfcp_sysfs_sdev_attrs,
-	}
+	},
+	.driver_version = ZFCP_VERSION,
 	/* rest initialised with zeros */
 };
 
@@ -331,8 +334,8 @@
 	scpnt->SCp.ptr = (void *) &wait;  /* silent re-use */
 	scpnt->scsi_done = zfcp_scsi_command_sync_handler;
 	ret = zfcp_scsi_command_async(unit->port->adapter, unit, scpnt, timer);
-	if ((ret == 0) && (scpnt->result == 0))
-	wait_for_completion(&wait);
+	if (ret == 0)
+		wait_for_completion(&wait);
 
 	scpnt->SCp.ptr = NULL;
 
@@ -399,6 +402,18 @@
 	return retval;
 }
 
+static struct zfcp_port *
+zfcp_port_lookup(struct zfcp_adapter *adapter, int channel, scsi_id_t id)
+{
+	struct zfcp_port *port;
+
+	list_for_each_entry(port, &adapter->port_list_head, list) {
+		if (id == port->scsi_id)
+			return port;
+	}
+	return (struct zfcp_port *) NULL;
+}
+
 /*
  * function:	zfcp_scsi_eh_abort_handler
  *
@@ -629,7 +644,7 @@
 	if (!atomic_test_mask(ZFCP_STATUS_UNIT_NOTSUPPUNITRESET,
 			      &unit->status)) {
 		retval =
-		    zfcp_task_management_function(unit, LOGICAL_UNIT_RESET);
+		    zfcp_task_management_function(unit, FCP_LOGICAL_UNIT_RESET);
 		if (retval) {
 			ZFCP_LOG_DEBUG("unit reset failed (unit=%p)\n", unit);
 			if (retval == -ENOTSUPP)
@@ -645,7 +660,7 @@
 			goto out;
 		}
 	}
-	retval = zfcp_task_management_function(unit, TARGET_RESET);
+	retval = zfcp_task_management_function(unit, FCP_TARGET_RESET);
 	if (retval) {
 		ZFCP_LOG_DEBUG("target reset failed (unit=%p)\n", unit);
 		retval = FAILED;
@@ -839,39 +854,63 @@
  * Support functions for FC transport class
  */
 static void
-zfcp_get_port_id(struct scsi_device *sdev)
+zfcp_get_port_id(struct scsi_target *starget)
 {
-	struct zfcp_unit *unit;
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct zfcp_adapter *adapter = (struct zfcp_adapter *)shost->hostdata[0];
+	struct zfcp_port *port;
+	unsigned long flags;
 
-	unit = (struct zfcp_unit *) sdev->hostdata;
-	fc_port_id(sdev) = unit->port->d_id;
+	read_lock_irqsave(&zfcp_data.config_lock, flags);
+	port = zfcp_port_lookup(adapter, starget->channel, starget->id);
+	if (port)
+		fc_starget_port_id(starget) = port->d_id;
+	else
+		fc_starget_port_id(starget) = -1;
+	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
 }
 
 static void
-zfcp_get_port_name(struct scsi_device *sdev)
+zfcp_get_port_name(struct scsi_target *starget)
 {
-	struct zfcp_unit *unit;
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct zfcp_adapter *adapter = (struct zfcp_adapter *)shost->hostdata[0];
+	struct zfcp_port *port;
+	unsigned long flags;
 
-	unit = (struct zfcp_unit *) sdev->hostdata;
-	fc_port_name(sdev) = unit->port->wwpn;
+	read_lock_irqsave(&zfcp_data.config_lock, flags);
+	port = zfcp_port_lookup(adapter, starget->channel, starget->id);
+	if (port)
+		fc_starget_port_name(starget) = port->wwpn;
+	else
+		fc_starget_port_name(starget) = -1;
+	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
 }
 
 static void
-zfcp_get_node_name(struct scsi_device *sdev)
+zfcp_get_node_name(struct scsi_target *starget)
 {
-	struct zfcp_unit *unit;
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct zfcp_adapter *adapter = (struct zfcp_adapter *)shost->hostdata[0];
+	struct zfcp_port *port;
+	unsigned long flags;
 
-	unit = (struct zfcp_unit *) sdev->hostdata;
-	fc_node_name(sdev) = unit->port->wwnn;
+	read_lock_irqsave(&zfcp_data.config_lock, flags);
+	port = zfcp_port_lookup(adapter, starget->channel, starget->id);
+	if (port)
+		fc_starget_node_name(starget) = port->wwnn;
+	else
+		fc_starget_node_name(starget) = -1;
+	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
 }
 
 struct fc_function_template zfcp_transport_functions = {
-	.get_port_id = zfcp_get_port_id,
-	.get_port_name = zfcp_get_port_name,
-	.get_node_name = zfcp_get_node_name,
-	.show_port_id = 1,
-	.show_port_name = 1,
-	.show_node_name = 1,
+	.get_starget_port_id = zfcp_get_port_id,
+	.get_starget_port_name = zfcp_get_port_name,
+	.get_starget_node_name = zfcp_get_node_name,
+	.show_starget_port_id = 1,
+	.show_starget_port_name = 1,
+	.show_starget_node_name = 1,
 };
 
 /**
diff -Nru a/drivers/s390/scsi/zfcp_sysfs_adapter.c b/drivers/s390/scsi/zfcp_sysfs_adapter.c
--- a/drivers/s390/scsi/zfcp_sysfs_adapter.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/s390/scsi/zfcp_sysfs_adapter.c	2004-12-24 13:36:17 -08:00
@@ -10,6 +10,7 @@
  * Authors:
  *      Martin Peschke <mpeschke@de.ibm.com>
  *	Heiko Carstens <heiko.carstens@de.ibm.com>
+ *      Andreas Herrmann <aherrman@de.ibm.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
@@ -26,7 +27,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_SYSFS_ADAPTER_C_REVISION "$Revision: 1.37 $"
+#define ZFCP_SYSFS_ADAPTER_C_REVISION "$Revision: 1.38 $"
 
 #include "zfcp_ext.h"
 
diff -Nru a/drivers/s390/scsi/zfcp_sysfs_driver.c b/drivers/s390/scsi/zfcp_sysfs_driver.c
--- a/drivers/s390/scsi/zfcp_sysfs_driver.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/s390/scsi/zfcp_sysfs_driver.c	2004-12-24 13:37:18 -08:00
@@ -10,6 +10,7 @@
  * Authors:
  *      Martin Peschke <mpeschke@de.ibm.com>
  *	Heiko Carstens <heiko.carstens@de.ibm.com>
+ *      Andreas Herrmann <aherrman@de.ibm.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
@@ -26,7 +27,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_SYSFS_DRIVER_C_REVISION "$Revision: 1.15 $"
+#define ZFCP_SYSFS_DRIVER_C_REVISION "$Revision: 1.17 $"
 
 #include "zfcp_ext.h"
 
@@ -85,7 +86,7 @@
 static ssize_t zfcp_sysfs_version_show(struct device_driver *dev,
 					      char *buf)
 {
-	return sprintf(buf, "%s\n", ZFCP_VERSION);
+	return sprintf(buf, "%s\n", zfcp_data.driver_version);
 }
 
 static DRIVER_ATTR(version, S_IRUGO, zfcp_sysfs_version_show, NULL);
diff -Nru a/drivers/s390/scsi/zfcp_sysfs_port.c b/drivers/s390/scsi/zfcp_sysfs_port.c
--- a/drivers/s390/scsi/zfcp_sysfs_port.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/s390/scsi/zfcp_sysfs_port.c	2004-12-24 13:37:29 -08:00
@@ -10,6 +10,8 @@
  * Authors:
  *      Martin Peschke <mpeschke@de.ibm.com>
  *	Heiko Carstens <heiko.carstens@de.ibm.com>
+ *      Andreas Herrmann <aherrman@de.ibm.com>
+ *      Volker Sameske <sameske@de.ibm.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
@@ -26,7 +28,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_SYSFS_PORT_C_REVISION "$Revision: 1.44 $"
+#define ZFCP_SYSFS_PORT_C_REVISION "$Revision: 1.47 $"
 
 #include "zfcp_ext.h"
 
@@ -68,6 +70,8 @@
 ZFCP_DEFINE_PORT_ATTR(scsi_id, "0x%x\n", port->scsi_id);
 ZFCP_DEFINE_PORT_ATTR(in_recovery, "%d\n", atomic_test_mask
 		      (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status));
+ZFCP_DEFINE_PORT_ATTR(access_denied, "%d\n", atomic_test_mask
+		      (ZFCP_STATUS_COMMON_ACCESS_DENIED, &port->status));
 
 /**
  * zfcp_sysfs_unit_add_store - add a unit to sysfs tree
@@ -244,6 +248,7 @@
 	&dev_attr_status.attr,
 	&dev_attr_wwnn.attr,
 	&dev_attr_d_id.attr,
+	&dev_attr_access_denied.attr,
 	NULL
 };
 
diff -Nru a/drivers/s390/scsi/zfcp_sysfs_unit.c b/drivers/s390/scsi/zfcp_sysfs_unit.c
--- a/drivers/s390/scsi/zfcp_sysfs_unit.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/s390/scsi/zfcp_sysfs_unit.c	2004-12-24 13:37:43 -08:00
@@ -10,6 +10,8 @@
  * Authors:
  *      Martin Peschke <mpeschke@de.ibm.com>
  *	Heiko Carstens <heiko.carstens@de.ibm.com>
+ *      Andreas Herrmann <aherrman@de.ibm.com>
+ *      Volker Sameske <sameske@de.ibm.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
@@ -26,7 +28,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_SYSFS_UNIT_C_REVISION "$Revision: 1.27 $"
+#define ZFCP_SYSFS_UNIT_C_REVISION "$Revision: 1.30 $"
 
 #include "zfcp_ext.h"
 
@@ -66,6 +68,12 @@
 ZFCP_DEFINE_UNIT_ATTR(scsi_lun, "0x%x\n", unit->scsi_lun);
 ZFCP_DEFINE_UNIT_ATTR(in_recovery, "%d\n", atomic_test_mask
 		      (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status));
+ZFCP_DEFINE_UNIT_ATTR(access_denied, "%d\n", atomic_test_mask
+		      (ZFCP_STATUS_COMMON_ACCESS_DENIED, &unit->status));
+ZFCP_DEFINE_UNIT_ATTR(access_shared, "%d\n", atomic_test_mask
+		      (ZFCP_STATUS_UNIT_SHARED, &unit->status));
+ZFCP_DEFINE_UNIT_ATTR(access_readonly, "%d\n", atomic_test_mask
+		      (ZFCP_STATUS_UNIT_READONLY, &unit->status));
 
 /**
  * zfcp_sysfs_unit_failed_store - failed state of unit
@@ -134,6 +142,9 @@
 	&dev_attr_failed.attr,
 	&dev_attr_in_recovery.attr,
 	&dev_attr_status.attr,
+	&dev_attr_access_denied.attr,
+	&dev_attr_access_shared.attr,
+	&dev_attr_access_readonly.attr,
 	NULL
 };
 
diff -Nru a/drivers/sbus/char/aurora.c b/drivers/sbus/char/aurora.c
--- a/drivers/sbus/char/aurora.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/sbus/char/aurora.c	2004-12-24 13:36:19 -08:00
@@ -60,12 +60,12 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/oplib.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/kdebug.h>
 #include <asm/sbus.h>
 #include <asm/uaccess.h>
@@ -1550,7 +1550,7 @@
 #endif
 }
 
-static int aurora_write(struct tty_struct * tty, int from_user, 
+static int aurora_write(struct tty_struct * tty, 
 			const unsigned char *buf, int count)
 {
 	struct Aurora_port *port = (struct Aurora_port *) tty->driver_data;
@@ -1573,51 +1573,22 @@
 		return 0;
 
 	save_flags(flags);
-	if (from_user) {
-		down(&tmp_buf_sem);
-		while (1) {
-			c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-					   SERIAL_XMIT_SIZE - port->xmit_head));
-			if (c <= 0)
-				break;
-
-			c -= copy_from_user(tmp_buf, buf, c);
-			if (!c) {
-				if (!total)
-					total = -EFAULT;
-				break;
-			}
-			cli();
-			c = MIN(c, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-				       SERIAL_XMIT_SIZE - port->xmit_head));
-			memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c);
-			port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-			port->xmit_cnt += c;
+	while (1) {
+		cli();
+		c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
+				   SERIAL_XMIT_SIZE - port->xmit_head));
+		if (c <= 0) {
 			restore_flags(flags);
-
-			buf += c;
-			count -= c;
-			total += c;
+			break;
 		}
-		up(&tmp_buf_sem);
-	} else {
-		while (1) {
-			cli();
-			c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-					   SERIAL_XMIT_SIZE - port->xmit_head));
-			if (c <= 0) {
-				restore_flags(flags);
-				break;
-			}
-			memcpy(port->xmit_buf + port->xmit_head, buf, c);
-			port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-			port->xmit_cnt += c;
-			restore_flags(flags);
+		memcpy(port->xmit_buf + port->xmit_head, buf, c);
+		port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
+		port->xmit_cnt += c;
+		restore_flags(flags);
 
-			buf += c;
-			count -= c;
-			total += c;
-		}
+		buf += c;
+		count -= c;
+		total += c;
 	}
 
 	cli();
@@ -2368,10 +2339,10 @@
 int irq1 = 0;
 int irq2 = 0;
 int irq3 = 0;
-MODULE_PARM(irq , "i");
-MODULE_PARM(irq1, "i");
-MODULE_PARM(irq2, "i");
-MODULE_PARM(irq3, "i");
+module_param(irq , int, 0);
+module_param(irq1, int, 0);
+module_param(irq2, int, 0);
+module_param(irq3, int, 0);
 
 static int __init aurora_init(void) 
 {
diff -Nru a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c
--- a/drivers/sbus/char/bbc_i2c.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/sbus/char/bbc_i2c.c	2004-12-24 13:37:18 -08:00
@@ -57,8 +57,8 @@
 	struct bbc_i2c_bus		*next;
 	int				index;
 	spinlock_t			lock;
-	void				*i2c_bussel_reg;
-	void				*i2c_control_regs;
+	void				__iomem *i2c_bussel_reg;
+	void				__iomem *i2c_control_regs;
 	unsigned char			own, clock;
 
 	wait_queue_head_t		wq;
diff -Nru a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c
--- a/drivers/sbus/char/bpp.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/sbus/char/bpp.c	2004-12-24 13:37:43 -08:00
@@ -89,7 +89,7 @@
 
 #if defined(__i386__)
 
-const unsigned short base_addrs[BPP_NO] = { 0x278, 0x378, 0x3bc };
+static const unsigned short base_addrs[BPP_NO] = { 0x278, 0x378, 0x3bc };
 
 /*
  * These are for data access.
@@ -246,7 +246,7 @@
 #define P_ERR_IRP       0x0002      /* RW1  1= rising edge */
 #define P_ERR_IRQ_EN    0x0001      /* RW   */
 
-unsigned long base_addrs[BPP_NO];
+static void __iomem *base_addrs[BPP_NO];
 
 #define bpp_outb_p(data, base)	sbus_writeb(data, (base) + BPP_DR)
 #define bpp_inb_p(base)		sbus_readb((base) + BPP_DR)
@@ -254,7 +254,7 @@
 
 static void set_pins(unsigned short pins, unsigned minor)
 {
-      unsigned long base = base_addrs[minor];
+      void __iomem *base = base_addrs[minor];
       unsigned char bits_tcr = 0, bits_or = 0;
 
       if (instances[minor].direction & 0x20) bits_tcr |= P_TCR_DIR;
@@ -275,7 +275,7 @@
  */
 static unsigned short get_pins(unsigned minor)
 {
-      unsigned long base = base_addrs[minor];
+      void __iomem *base = base_addrs[minor];
       unsigned short bits = 0;
       unsigned value_tcr = sbus_readb(base + BPP_TCR);
       unsigned value_ir = sbus_readb(base + BPP_IR);
@@ -940,7 +940,7 @@
 
 #if defined(__sparc__)
 
-static unsigned long map_bpp(struct sbus_dev *dev, int idx)
+static void __iomem *map_bpp(struct sbus_dev *dev, int idx)
 {
       return sbus_ioremap(&dev->resource[0], 0, BPP_SIZE, "bpp");
 }
@@ -969,7 +969,7 @@
 
 static void probeLptPort(unsigned idx)
 {
-      unsigned long rp = base_addrs[idx];
+      void __iomem *rp = base_addrs[idx];
       __u32 csr;
       char *brand;
 
@@ -983,7 +983,7 @@
       init_timer(&instances[idx].timer_list);
       instances[idx].timer_list.function = bpp_wake_up;
 
-      if (rp == 0) return;
+      if (!rp) return;
 
       instances[idx].present = 1;
       instances[idx].enhanced = 1;   /* Sure */
@@ -1014,7 +1014,7 @@
       default:
             brand = "Unknown";
       }
-      printk("bpp%d: %s at 0x%lx\n", idx, brand, rp);
+      printk("bpp%d: %s at %p\n", idx, brand, rp);
 
       /*
        * Leave the port in compat idle mode.
diff -Nru a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c
--- a/drivers/sbus/char/cpwatchdog.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/sbus/char/cpwatchdog.c	2004-12-24 13:37:19 -08:00
@@ -165,11 +165,11 @@
 static int wd2_timeout = 0;
 
 #ifdef MODULE
-MODULE_PARM		(wd0_timeout, "i");
+module_param	(wd0_timeout, int, 0);
 MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs");
-MODULE_PARM 	(wd1_timeout, "i");
+module_param 	(wd1_timeout, int, 0);
 MODULE_PARM_DESC(wd1_timeout, "Default watchdog1 timeout in 1/10secs");
-MODULE_PARM 	(wd2_timeout, "i");
+module_param 	(wd2_timeout, int, 0);
 MODULE_PARM_DESC(wd2_timeout, "Default watchdog2 timeout in 1/10secs");
 
 MODULE_AUTHOR
@@ -743,7 +743,7 @@
 	}
 
 	wd_dev.regs = 
-		ioremap(edev->resource[0].start, sizeof(struct wd_regblk));
+		ioremap(edev->resource[0].start, 4 * WD_TIMER_REGSZ); /* ? */
 
 	if(NULL == wd_dev.regs) {
 		printk("%s: unable to map registers\n", WD_OBPNAME);
diff -Nru a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
--- a/drivers/sbus/char/display7seg.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/sbus/char/display7seg.c	2004-12-24 13:37:03 -08:00
@@ -44,8 +44,8 @@
  * If you wish the device to operate as under Solaris,
  * omitting above features, set this parameter to non-zero.
  */
-MODULE_PARM
-	(sol_compat, "1i");
+module_param
+	(sol_compat, int, 0);
 MODULE_PARM_DESC
 	(sol_compat, 
 	 "Disables documented functionality omitted from Solaris driver");
diff -Nru a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c
--- a/drivers/sbus/char/flash.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/sbus/char/flash.c	2004-12-24 13:36:56 -08:00
@@ -66,7 +66,7 @@
 
 	if ((vma->vm_pgoff << PAGE_SHIFT) > size)
 		return -ENXIO;
-	addr += (vma->vm_pgoff << PAGE_SHIFT);
+	addr = vma->vm_pgoff + (addr >> PAGE_SHIFT);
 
 	if (vma->vm_end - (vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT)) > size)
 		size = vma->vm_end - (vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT));
@@ -75,7 +75,7 @@
 	pgprot_val(vma->vm_page_prot) |= _PAGE_E;
 	vma->vm_flags |= (VM_SHM | VM_LOCKED);
 
-	if (remap_page_range(vma, vma->vm_start, addr, size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start, addr, size, vma->vm_page_prot))
 		return -EAGAIN;
 		
 	return 0;
diff -Nru a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
--- a/drivers/sbus/char/jsflash.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/sbus/char/jsflash.c	2004-12-24 13:36:48 -08:00
@@ -21,7 +21,7 @@
  * as a silly safeguard.
  *
  * XXX The flash.c manipulates page caching characteristics in a certain
- * dubious way; also it assumes that remap_page_range() can remap
+ * dubious way; also it assumes that remap_pfn_range() can remap
  * PCI bus locations, which may be false. ioremap() must be used
  * instead. We should discuss this.
  */
diff -Nru a/drivers/sbus/char/riowatchdog.c b/drivers/sbus/char/riowatchdog.c
--- a/drivers/sbus/char/riowatchdog.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/sbus/char/riowatchdog.c	2004-12-24 13:36:49 -08:00
@@ -54,12 +54,12 @@
 
 static spinlock_t riowd_lock = SPIN_LOCK_UNLOCKED;
 
-static void *bbc_regs;
-static void *riowd_regs;
+static void __iomem *bbc_regs;
+static void __iomem *riowd_regs;
 #define WDTO_INDEX	0x05
 
 static int riowd_timeout = 1;		/* in minutes */
-MODULE_PARM(riowd_timeout,"i");
+module_param(riowd_timeout, int, 0);
 MODULE_PARM_DESC(riowd_timeout, "Watchdog timeout in minutes");
 
 #if 0 /* Currently unused. */
diff -Nru a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
--- a/drivers/scsi/3w-9xxx.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/3w-9xxx.c	2004-12-24 13:37:19 -08:00
@@ -1746,6 +1746,7 @@
 		twa_free_request_id(tw_dev, request_id);
 		SCpnt->result = (DID_ERROR << 16);
 		done(SCpnt);
+		retval = 0;
 	}
 
 	return retval;
diff -Nru a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
--- a/drivers/scsi/3w-9xxx.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/3w-9xxx.h	2004-12-24 13:37:43 -08:00
@@ -453,13 +453,13 @@
 
 /* Macros */
 #define TW_CONTROL_REG_ADDR(x) (x->base_addr)
-#define TW_STATUS_REG_ADDR(x) ((unsigned char *)x->base_addr + 0x4)
+#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4)
 #if BITS_PER_LONG > 32
-#define TW_COMMAND_QUEUE_REG_ADDR(x) ((unsigned char *)x->base_addr + 0x20)
+#define TW_COMMAND_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x20)
 #else
-#define TW_COMMAND_QUEUE_REG_ADDR(x) ((unsigned char *)x->base_addr + 0x8)
+#define TW_COMMAND_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x8)
 #endif
-#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char *)x->base_addr + 0xC)
+#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC)
 #define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
 #define TW_CLEAR_ATTENTION_INTERRUPT(x) (writel(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
 #define TW_CLEAR_HOST_INTERRUPT(x) (writel(TW_CONTROL_CLEAR_HOST_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
@@ -655,7 +655,7 @@
 } TW_Compatibility_Info;
 
 typedef struct TAG_TW_Device_Extension {
-	u32                     *base_addr;
+	u32                     __iomem *base_addr;
 	unsigned long	       	*generic_buffer_virt[TW_Q_LENGTH];
 	unsigned long	       	generic_buffer_phys[TW_Q_LENGTH];
 	TW_Command_Full	       	*command_packet_virt[TW_Q_LENGTH];
diff -Nru a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
--- a/drivers/scsi/3w-xxxx.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/3w-xxxx.c	2004-12-24 13:37:19 -08:00
@@ -184,84 +184,442 @@
    1.26.00.039 - Fix bug in tw_chrdev_ioctl() polling code.
                  Fix data_buffer_length usage in tw_chrdev_ioctl().
                  Update contact information.
+   1.26.02.000 - Convert driver to pci_driver format.
 */
 
 #include <linux/module.h>
-
-MODULE_AUTHOR ("3ware Inc.");
-#ifdef CONFIG_SMP
-MODULE_DESCRIPTION ("3ware Storage Controller Linux Driver (SMP)");
-#else
-MODULE_DESCRIPTION ("3ware Storage Controller Linux Driver");
-#endif
-MODULE_LICENSE("GPL");
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/time.h>
-#include <linux/proc_fs.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-#include <linux/string.h>
-#include <linux/delay.h>
-#include <linux/smp.h>
 #include <linux/reboot.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/moduleparam.h>
-
-#include <asm/errno.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/time.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/scsi_cmnd.h>
+#include "3w-xxxx.h"
 
-#define __3W_C			/* let 3w-xxxx.h know it is use */
+/* Globals */
+#define TW_DRIVER_VERSION "1.26.02.000"
+static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT];
+static int tw_device_extension_count = 0;
+static int twe_major = -1;
 
-#include "scsi.h"
-#include <scsi/scsi_host.h>
+/* Module parameters */
+MODULE_AUTHOR("AMCC");
+MODULE_DESCRIPTION("3ware Storage Controller Linux Driver");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(TW_DRIVER_VERSION);
 
-#include "3w-xxxx.h"
+/* Function prototypes */
+static int tw_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset);
+
+/* Functions */
+
+/* This function will check the status register for unexpected bits */
+static int tw_check_bits(u32 status_reg_value)
+{
+	if ((status_reg_value & TW_STATUS_EXPECTED_BITS) != TW_STATUS_EXPECTED_BITS) {  
+		dprintk(KERN_WARNING "3w-xxxx: tw_check_bits(): No expected bits (0x%x).\n", status_reg_value);
+		return 1;
+	}
+	if ((status_reg_value & TW_STATUS_UNEXPECTED_BITS) != 0) {
+		dprintk(KERN_WARNING "3w-xxxx: tw_check_bits(): Found unexpected bits (0x%x).\n", status_reg_value);
+		return 1;
+	}
+
+	return 0;
+} /* End tw_check_bits() */
+
+/* This function will print readable messages from status register errors */
+static int tw_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value, int print_host)
+{
+	char host[16];
+
+	dprintk(KERN_WARNING "3w-xxxx: tw_decode_bits()\n");
+
+	if (print_host)
+		sprintf(host, " scsi%d:", tw_dev->host->host_no);
+	else
+		host[0] = '\0';
+
+	if (status_reg_value & TW_STATUS_PCI_PARITY_ERROR) {
+		printk(KERN_WARNING "3w-xxxx:%s PCI Parity Error: clearing.\n", host);
+		outl(TW_CONTROL_CLEAR_PARITY_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
+	}
+
+	if (status_reg_value & TW_STATUS_PCI_ABORT) {
+		printk(KERN_WARNING "3w-xxxx:%s PCI Abort: clearing.\n", host);
+		outl(TW_CONTROL_CLEAR_PCI_ABORT, TW_CONTROL_REG_ADDR(tw_dev));
+		pci_write_config_word(tw_dev->tw_pci_dev, PCI_STATUS, TW_PCI_CLEAR_PCI_ABORT);
+	}
+
+	if (status_reg_value & TW_STATUS_QUEUE_ERROR) {
+		printk(KERN_WARNING "3w-xxxx:%s Controller Queue Error: clearing.\n", host);
+		outl(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
+	}
+
+	if (status_reg_value & TW_STATUS_SBUF_WRITE_ERROR) {
+		printk(KERN_WARNING "3w-xxxx:%s SBUF Write Error: clearing.\n", host);
+		outl(TW_CONTROL_CLEAR_SBUF_WRITE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
+	}
+
+	if (status_reg_value & TW_STATUS_MICROCONTROLLER_ERROR) {
+		if (tw_dev->reset_print == 0) {
+			printk(KERN_WARNING "3w-xxxx:%s Microcontroller Error: clearing.\n", host);
+			tw_dev->reset_print = 1;
+		}
+		return 1;
+	}
+	
+	return 0;
+} /* End tw_decode_bits() */
+
+/* This function will poll the status register for a flag */
+static int tw_poll_status(TW_Device_Extension *tw_dev, u32 flag, int seconds)
+{
+	u32 status_reg_value;
+	unsigned long before;
+	int retval = 1;
+
+	status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+	before = jiffies;
+
+	if (tw_check_bits(status_reg_value))
+		tw_decode_bits(tw_dev, status_reg_value, 0);
+
+	while ((status_reg_value & flag) != flag) {
+		status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+
+		if (tw_check_bits(status_reg_value))
+			tw_decode_bits(tw_dev, status_reg_value, 0);
+
+		if (time_after(jiffies, before + HZ * seconds))
+			goto out;
+
+		msleep(50);
+	}
+	retval = 0;
+out:
+	return retval;
+} /* End tw_poll_status() */
+
+/* This function will poll the status register for disappearance of a flag */
+static int tw_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds)
+{
+	u32 status_reg_value;
+	unsigned long before;
+	int retval = 1;
+
+	status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+	before = jiffies;
+
+	if (tw_check_bits(status_reg_value))
+		tw_decode_bits(tw_dev, status_reg_value, 0);
+
+	while ((status_reg_value & flag) != 0) {
+		status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+
+		if (tw_check_bits(status_reg_value))
+			tw_decode_bits(tw_dev, status_reg_value, 0);
+
+		if (time_after(jiffies, before + HZ * seconds))
+			goto out;
+
+		msleep(50);
+	}
+	retval = 0;
+out:
+	return retval;
+} /* End tw_poll_status_gone() */
+
+/* This function will attempt to post a command packet to the board */
+static int tw_post_command_packet(TW_Device_Extension *tw_dev, int request_id)
+{
+	u32 status_reg_value;
+	unsigned long command_que_value;
+
+	dprintk(KERN_NOTICE "3w-xxxx: tw_post_command_packet()\n");
+	command_que_value = tw_dev->command_packet_physical_address[request_id];
+	status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+
+	if (tw_check_bits(status_reg_value)) {
+		dprintk(KERN_WARNING "3w-xxxx: tw_post_command_packet(): Unexpected bits.\n");
+		tw_decode_bits(tw_dev, status_reg_value, 1);
+	}
+
+	if ((status_reg_value & TW_STATUS_COMMAND_QUEUE_FULL) == 0) {
+		/* We successfully posted the command packet */
+		outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
+		tw_dev->state[request_id] = TW_S_POSTED;
+		tw_dev->posted_request_count++;
+		if (tw_dev->posted_request_count > tw_dev->max_posted_request_count) {
+			tw_dev->max_posted_request_count = tw_dev->posted_request_count;
+		}
+	} else {
+		/* Couldn't post the command packet, so we do it in the isr */
+		if (tw_dev->state[request_id] != TW_S_PENDING) {
+			tw_dev->state[request_id] = TW_S_PENDING;
+			tw_dev->pending_request_count++;
+			if (tw_dev->pending_request_count > tw_dev->max_pending_request_count) {
+				tw_dev->max_pending_request_count = tw_dev->pending_request_count;
+			}
+			tw_dev->pending_queue[tw_dev->pending_tail] = request_id;
+			if (tw_dev->pending_tail == TW_Q_LENGTH-1) {
+				tw_dev->pending_tail = TW_Q_START;
+			} else {
+				tw_dev->pending_tail = tw_dev->pending_tail + 1;
+			}
+		} 
+		TW_UNMASK_COMMAND_INTERRUPT(tw_dev);
+		return 1;
+	}
+	return 0;
+} /* End tw_post_command_packet() */
+
+/* This function will return valid sense buffer information for failed cmds */
+static int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill_sense)
+{
+	int i;
+	TW_Command *command;
+
+        dprintk(KERN_WARNING "3w-xxxx: tw_decode_sense()\n");
+	command = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
+
+	printk(KERN_WARNING "3w-xxxx: scsi%d: Command failed: status = 0x%x, flags = 0x%x, unit #%d.\n", tw_dev->host->host_no, command->status, command->flags, TW_UNIT_OUT(command->unit__hostid));
+
+	/* Attempt to return intelligent sense information */
+	if (fill_sense) {
+		if ((command->status == 0xc7) || (command->status == 0xcb)) {
+			for (i=0;i<(sizeof(tw_sense_table)/sizeof(tw_sense_table[0]));i++) {
+				if (command->flags == tw_sense_table[i][0]) {
+
+					/* Valid bit and 'current errors' */
+					tw_dev->srb[request_id]->sense_buffer[0] = (0x1 << 7 | 0x70);
+
+					/* Sense key */
+					tw_dev->srb[request_id]->sense_buffer[2] = tw_sense_table[i][1];
+
+					/* Additional sense length */
+					tw_dev->srb[request_id]->sense_buffer[7] = 0xa; /* 10 bytes */
+
+					/* Additional sense code */
+					tw_dev->srb[request_id]->sense_buffer[12] = tw_sense_table[i][2];
+
+					/* Additional sense code qualifier */
+					tw_dev->srb[request_id]->sense_buffer[13] = tw_sense_table[i][3];
+
+					tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
+					return TW_ISR_DONT_RESULT; /* Special case for isr to not over-write result */
+				}
+			}
+		}
+
+		/* If no table match, error so we get a reset */
+		return 1;
+	}
+
+	return 0;
+} /* End tw_decode_sense() */
+
+/* This function will report controller error status */
+static int tw_check_errors(TW_Device_Extension *tw_dev) 
+{
+	u32 status_reg_value;
+  
+	status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+
+	if (TW_STATUS_ERRORS(status_reg_value) || tw_check_bits(status_reg_value)) {
+		tw_decode_bits(tw_dev, status_reg_value, 0);
+		return 1;
+	}
+
+	return 0;
+} /* End tw_check_errors() */
+
+/* This function will empty the response que */
+static void tw_empty_response_que(TW_Device_Extension *tw_dev) 
+{
+	u32 status_reg_value, response_que_value;
+
+	status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+
+	while ((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) {
+		response_que_value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
+		status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+	}
+} /* End tw_empty_response_que() */
+
+/* This function will free a request_id */
+static void tw_state_request_finish(TW_Device_Extension *tw_dev, int request_id)
+{
+	tw_dev->free_queue[tw_dev->free_tail] = request_id;
+	tw_dev->state[request_id] = TW_S_FINISHED;
+	tw_dev->free_tail = (tw_dev->free_tail + 1) % TW_Q_LENGTH;
+} /* End tw_state_request_finish() */
+
+/* This function will assign an available request_id */
+static void tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id)
+{
+	*request_id = tw_dev->free_queue[tw_dev->free_head];
+	tw_dev->free_head = (tw_dev->free_head + 1) % TW_Q_LENGTH;
+	tw_dev->state[*request_id] = TW_S_STARTED;
+} /* End tw_state_request_start() */
 
-static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
-static int tw_chrdev_open(struct inode *inode, struct file *file);
-static int tw_chrdev_release(struct inode *inode, struct file *file);
-static int tw_copy_info(TW_Info *info, char *fmt, ...);
-static void tw_copy_mem_info(TW_Info *info, char *data, int len);
-static int tw_halt(struct notifier_block *nb, ulong event, void *buf);
-static int tw_map_scsi_sg_data(struct pci_dev *pdev, Scsi_Cmnd *cmd);
-static u32 tw_map_scsi_single_data(struct pci_dev *pdev, Scsi_Cmnd *cmd);
-static void tw_unmap_scsi_data(struct pci_dev *pdev, Scsi_Cmnd *cmd);
-
-/* Notifier block to get a notify on system shutdown/halt/reboot */
-static struct notifier_block tw_notifier = {
-	tw_halt, NULL, 0
+/* Show some statistics about the card */
+static ssize_t tw_show_stats(struct class_device *class_dev, char *buf)
+{
+	struct Scsi_Host *host = class_to_shost(class_dev);
+	TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
+	unsigned long flags = 0;
+	ssize_t len;
+
+	spin_lock_irqsave(tw_dev->host->host_lock, flags);
+	len = snprintf(buf, PAGE_SIZE, "3w-xxxx Driver version: %s\n"
+		       "Current commands posted:   %4d\n"
+		       "Max commands posted:       %4d\n"
+		       "Current pending commands:  %4d\n"
+		       "Max pending commands:      %4d\n"
+		       "Last sgl length:           %4d\n"
+		       "Max sgl length:            %4d\n"
+		       "Last sector count:         %4d\n"
+		       "Max sector count:          %4d\n"
+		       "SCSI Host Resets:          %4d\n"
+		       "AEN's:                     %4d\n", 
+		       TW_DRIVER_VERSION,
+		       tw_dev->posted_request_count,
+		       tw_dev->max_posted_request_count,
+		       tw_dev->pending_request_count,
+		       tw_dev->max_pending_request_count,
+		       tw_dev->sgl_entries,
+		       tw_dev->max_sgl_entries,
+		       tw_dev->sector_count,
+		       tw_dev->max_sector_count,
+		       tw_dev->num_resets,
+		       tw_dev->aen_count);
+	spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
+	return len;
+} /* End tw_show_stats() */
+
+/* This function will set a devices queue depth */
+static ssize_t tw_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+	int queue_depth;
+	struct scsi_device *sdev = to_scsi_device(dev);
+
+	queue_depth = simple_strtoul(buf, NULL, 0);
+	if (queue_depth > TW_Q_LENGTH-2)
+		return -EINVAL;
+	scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth);
+
+	return count;
+} /* End tw_store_queue_depth() */
+
+/* Create sysfs 'queue_depth' entry */
+static struct device_attribute tw_queue_depth_attr = {
+	.attr = {
+		.name =		"queue_depth",
+		.mode =		S_IRUSR | S_IWUSR,
+	},
+	.store = tw_store_queue_depth
 };
 
-/* File operations struct for character device */
-static struct file_operations tw_fops = {
-	.owner		= THIS_MODULE,
-	.ioctl		= tw_chrdev_ioctl,
-	.open		= tw_chrdev_open,
-	.release	= tw_chrdev_release
+/* Device attributes initializer */
+static struct device_attribute *tw_dev_attrs[] = {
+	&tw_queue_depth_attr,
+	NULL,
 };
 
-/* Globals */
-char *tw_driver_version="1.26.00.039";
-TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT];
-int tw_device_extension_count = 0;
-static int twe_major = -1;
-static int cmds_per_lun;
+/* Create sysfs 'stats' entry */
+static struct class_device_attribute tw_host_stats_attr = {
+	.attr = {
+		.name = 	"stats",
+		.mode =		S_IRUGO,
+	},
+	.show = tw_show_stats
+};
 
-/* Module parameters */
-module_param(cmds_per_lun, int, 0);
-MODULE_PARM_DESC(cmds_per_lun, "Maximum commands per LUN");
+/* Host attributes initializer */
+static struct class_device_attribute *tw_host_attrs[] = {
+	&tw_host_stats_attr,
+	NULL,
+};
 
-/* Functions */
+/* This function will read the aen queue from the isr */
+static int tw_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) 
+{
+	TW_Command *command_packet;
+	TW_Param *param;
+	unsigned long command_que_value;
+	u32 status_reg_value;
+	unsigned long param_value = 0;
+
+	dprintk(KERN_NOTICE "3w-xxxx: tw_aen_read_queue()\n");
+
+	status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+	if (tw_check_bits(status_reg_value)) {
+		dprintk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Unexpected bits.\n");
+		tw_decode_bits(tw_dev, status_reg_value, 1);
+		return 1;
+	}
+	if (tw_dev->command_packet_virtual_address[request_id] == NULL) {
+		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad command packet virtual address.\n");
+		return 1;
+	}
+	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
+	memset(command_packet, 0, sizeof(TW_Sector));
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
+	command_packet->size = 4;
+	command_packet->request_id = request_id;
+	command_packet->status = 0;
+	command_packet->flags = 0;
+	command_packet->byte6.parameter_count = 1;
+	command_que_value = tw_dev->command_packet_physical_address[request_id];
+	if (command_que_value == 0) {
+		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad command packet physical address.\n");
+		return 1;
+	}
+	/* Now setup the param */
+	if (tw_dev->alignment_virtual_address[request_id] == NULL) {
+		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad alignment virtual address.\n");
+		return 1;
+	}
+	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
+	memset(param, 0, sizeof(TW_Sector));
+	param->table_id = 0x401; /* AEN table */
+	param->parameter_id = 2; /* Unit code */
+	param->parameter_size_bytes = 2;
+	param_value = tw_dev->alignment_physical_address[request_id];
+	if (param_value == 0) {
+		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad alignment physical address.\n");
+		return 1;
+	}
+	command_packet->byte8.param.sgl[0].address = param_value;
+	command_packet->byte8.param.sgl[0].length = sizeof(TW_Sector);
+
+	/* Now post the command packet */
+	if ((status_reg_value & TW_STATUS_COMMAND_QUEUE_FULL) == 0) {
+		dprintk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Post succeeded.\n");
+		tw_dev->srb[request_id] = NULL; /* Flag internal command */
+		tw_dev->state[request_id] = TW_S_POSTED;
+		outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
+	} else {
+		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Post failed, will retry.\n");
+		return 1;
+	}
+
+	return 0;
+} /* End tw_aen_read_queue() */
 
 /* This function will complete an aen request from the isr */
-int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id) 
+static int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id) 
 {
 	TW_Param *param;
 	unsigned short aen;
@@ -325,16 +683,14 @@
 } /* End tw_aen_complete() */
 
 /* This function will drain the aen queue after a soft reset */
-int tw_aen_drain_queue(TW_Device_Extension *tw_dev)
+static int tw_aen_drain_queue(TW_Device_Extension *tw_dev)
 {
 	TW_Command *command_packet;
 	TW_Param *param;
 	int request_id = 0;
-	u32 command_que_addr;
 	unsigned long command_que_value;
 	unsigned long param_value;
 	TW_Response_Queue response_queue;
-	u32 response_que_addr;
 	unsigned short aen;
 	unsigned short aen_code;
 	int finished = 0;
@@ -344,14 +700,11 @@
 
 	dprintk(KERN_NOTICE "3w-xxxx: tw_aen_drain_queue()\n");
 
-	command_que_addr = tw_dev->registers.command_que_addr;
-	response_que_addr = tw_dev->registers.response_que_addr;
-
 	if (tw_poll_status(tw_dev, TW_STATUS_ATTENTION_INTERRUPT | TW_STATUS_MICROCONTROLLER_READY, 30)) {
 		dprintk(KERN_WARNING "3w-xxxx: tw_aen_drain_queue(): No attention interrupt for card %d.\n", tw_device_extension_count);
 		return 1;
 	}
-	tw_clear_attention_interrupt(tw_dev);
+	TW_CLEAR_ATTENTION_INTERRUPT(tw_dev);
 
 	/* Empty response queue */
 	tw_empty_response_que(tw_dev);
@@ -363,12 +716,9 @@
 	}
 	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
 	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode = TW_OP_GET_PARAM;
-	command_packet->byte0.sgl_offset = 2;
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
 	command_packet->size = 4;
 	command_packet->request_id = request_id;
-	command_packet->byte3.unit = 0;
-	command_packet->byte3.host_id = 0;
 	command_packet->status = 0;
 	command_packet->flags = 0;
 	command_packet->byte6.parameter_count = 1;
@@ -399,12 +749,12 @@
 	/* Now drain the controller's aen queue */
 	do {
 		/* Post command packet */
-		outl(command_que_value, command_que_addr);
+		outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
 
 		/* Now poll for completion */
 		if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) {
-			response_queue.value = inl(response_que_addr);
-			request_id = (unsigned char)response_queue.u.response_id;
+			response_queue.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
+			request_id = TW_RESID_OUT(response_queue.response_id);
 
 			if (request_id != 0) {
 				/* Unexpected request id */
@@ -490,80 +840,8 @@
 	return 0;
 } /* End tw_aen_drain_queue() */
 
-/* This function will read the aen queue from the isr */
-int tw_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) 
-{
-	TW_Command *command_packet;
-	TW_Param *param;
-	u32 command_que_addr;
-	unsigned long command_que_value;
-	u32 status_reg_value = 0, status_reg_addr;
-	unsigned long param_value = 0;
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_aen_read_queue()\n");
-	command_que_addr = tw_dev->registers.command_que_addr;
-	status_reg_addr = tw_dev->registers.status_reg_addr;
-
-	status_reg_value = inl(status_reg_addr);
-	if (tw_check_bits(status_reg_value)) {
-		dprintk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Unexpected bits.\n");
-		tw_decode_bits(tw_dev, status_reg_value, 1);
-		return 1;
-	}
-	if (tw_dev->command_packet_virtual_address[request_id] == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad command packet virtual address.\n");
-		return 1;
-	}
-	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
-	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode = TW_OP_GET_PARAM;
-	command_packet->byte0.sgl_offset = 2;
-	command_packet->size = 4;
-	command_packet->request_id = request_id;
-	command_packet->byte3.unit = 0;
-	command_packet->byte3.host_id = 0;
-	command_packet->status = 0;
-	command_packet->flags = 0;
-	command_packet->byte6.parameter_count = 1;
-	command_que_value = tw_dev->command_packet_physical_address[request_id];
-	if (command_que_value == 0) {
-		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad command packet physical address.\n");
-		return 1;
-	}
-	/* Now setup the param */
-	if (tw_dev->alignment_virtual_address[request_id] == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad alignment virtual address.\n");
-		return 1;
-	}
-	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
-	memset(param, 0, sizeof(TW_Sector));
-	param->table_id = 0x401; /* AEN table */
-	param->parameter_id = 2; /* Unit code */
-	param->parameter_size_bytes = 2;
-	param_value = tw_dev->alignment_physical_address[request_id];
-	if (param_value == 0) {
-		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad alignment physical address.\n");
-		return 1;
-	}
-	command_packet->byte8.param.sgl[0].address = param_value;
-	command_packet->byte8.param.sgl[0].length = sizeof(TW_Sector);
-
-	/* Now post the command packet */
-	if ((status_reg_value & TW_STATUS_COMMAND_QUEUE_FULL) == 0) {
-		dprintk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Post succeeded.\n");
-		tw_dev->srb[request_id] = NULL; /* Flag internal command */
-		tw_dev->state[request_id] = TW_S_POSTED;
-		outl(command_que_value, command_que_addr);
-	} else {
-		printk(KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Post failed, will retry.\n");
-		return 1;
-	}
-
-	return 0;
-} /* End tw_aen_read_queue() */
-
 /* This function will allocate memory */
-int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
+static int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
 {
 	int i;
 	dma_addr_t dma_handle;
@@ -604,41 +882,10 @@
 	return 0;
 } /* End tw_allocate_memory() */
 
-/* This function will check the status register for unexpected bits */
-int tw_check_bits(u32 status_reg_value)
-{
-	if ((status_reg_value & TW_STATUS_EXPECTED_BITS) != TW_STATUS_EXPECTED_BITS) {  
-		dprintk(KERN_WARNING "3w-xxxx: tw_check_bits(): No expected bits (0x%x).\n", status_reg_value);
-		return 1;
-	}
-	if ((status_reg_value & TW_STATUS_UNEXPECTED_BITS) != 0) {
-		dprintk(KERN_WARNING "3w-xxxx: tw_check_bits(): Found unexpected bits (0x%x).\n", status_reg_value);
-		return 1;
-	}
-
-	return 0;
-} /* End tw_check_bits() */
-
-/* This function will report controller error status */
-int tw_check_errors(TW_Device_Extension *tw_dev) 
-{
-	u32 status_reg_addr, status_reg_value;
-  
-	status_reg_addr = tw_dev->registers.status_reg_addr;
-	status_reg_value = inl(status_reg_addr);
-
-	if (TW_STATUS_ERRORS(status_reg_value) || tw_check_bits(status_reg_value)) {
-		tw_decode_bits(tw_dev, status_reg_value, 0);
-		return 1;
-	}
-
-	return 0;
-} /* End tw_check_errors() */
-
 /* This function handles ioctl for the character device */
 static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
 {
-	int error, request_id;
+	int request_id;
 	dma_addr_t dma_handle;
 	unsigned short tw_aen_code;
 	unsigned long flags;
@@ -659,8 +906,7 @@
 		return -EINTR;
 
 	/* First copy down the buffer length */
-	error = copy_from_user(&data_buffer_length, argp, sizeof(unsigned int));
-	if (error)
+	if (copy_from_user(&data_buffer_length, argp, sizeof(unsigned int)))
 		goto out;
 
 	/* Check size */
@@ -673,7 +919,7 @@
 	data_buffer_length_adjusted = (data_buffer_length + 511) & ~511;
 	
 	/* Now allocate ioctl buf memory */
-	cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, &dma_handle);
+	cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, &dma_handle, GFP_KERNEL);
 	if (cpu_addr == NULL) {
 		retval = -ENOMEM;
 		goto out;
@@ -682,8 +928,7 @@
 	tw_ioctl = (TW_New_Ioctl *)cpu_addr;
 
 	/* Now copy down the entire ioctl */
-	error = copy_from_user(tw_ioctl, argp, data_buffer_length + sizeof(TW_New_Ioctl) - 1);
-	if (error)
+	if (copy_from_user(tw_ioctl, argp, data_buffer_length + sizeof(TW_New_Ioctl) - 1))
 		goto out2;
 
 	passthru = (TW_Passthru *)&tw_ioctl->firmware_command;
@@ -713,7 +958,7 @@
 			break;
 		case TW_CMD_PACKET_WITH_DATA:
 			dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl(): caught TW_CMD_PACKET_WITH_DATA.\n");
-			spin_lock_irqsave(&tw_dev->tw_lock, flags);
+			spin_lock_irqsave(tw_dev->host->host_lock, flags);
 
 			tw_state_request_start(tw_dev, &request_id);
 
@@ -726,7 +971,7 @@
 			tw_ioctl->firmware_command.request_id = request_id;
 
 			/* Load the sg list */
-			switch (tw_ioctl->firmware_command.byte0.sgl_offset) {
+			switch (TW_SGL_OUT(tw_ioctl->firmware_command.opcode__sgloffset)) {
 			case 2:
 				tw_ioctl->firmware_command.byte8.param.sgl[0].address = dma_handle + sizeof(TW_New_Ioctl) - 1;
 				tw_ioctl->firmware_command.byte8.param.sgl[0].length = data_buffer_length_adjusted;
@@ -745,13 +990,20 @@
 
 			/* Now post the command packet to the controller */
 			tw_post_command_packet(tw_dev, request_id);
-			spin_unlock_irqrestore(&tw_dev->tw_lock, flags);
+			spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
 
 			timeout = TW_IOCTL_CHRDEV_TIMEOUT*HZ;
 
 			/* Now wait for the command to complete */
 			timeout = wait_event_interruptible_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
 
+			/* See if we reset while waiting for the ioctl to complete */
+			if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
+				clear_bit(TW_IN_RESET, &tw_dev->flags);
+				retval = -ERESTARTSYS;
+				goto out2;
+			}
+
 			/* Check if we timed out, got a signal, or didn't get
 			   an interrupt */
 			if ((timeout <= 0) && (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE)) {
@@ -762,14 +1014,14 @@
 					printk(KERN_WARNING "3w-xxxx: scsi%d: Character ioctl (0x%x) timed out, resetting card.\n", tw_dev->host->host_no, cmd);
 					retval = -EIO;
 				}
-				spin_lock_irqsave(&tw_dev->tw_lock, flags);
+				spin_lock_irqsave(tw_dev->host->host_lock, flags);
 				tw_dev->state[request_id] = TW_S_COMPLETED;
 				tw_state_request_finish(tw_dev, request_id);
 				tw_dev->posted_request_count--;
-				if (tw_reset_device_extension(tw_dev)) {
+				spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
+				if (tw_reset_device_extension(tw_dev, 1)) {
 					printk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl(): Reset failed for card %d.\n", tw_dev->host->host_no);
 				}
-				spin_unlock_irqrestore(&tw_dev->tw_lock, flags);
 				goto out2;
 			}
 
@@ -777,11 +1029,11 @@
 			memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virtual_address[request_id], sizeof(TW_Command));
 
 			/* Now complete the io */
-			spin_lock_irqsave(&tw_dev->tw_lock, flags);
+			spin_lock_irqsave(tw_dev->host->host_lock, flags);
 			tw_dev->posted_request_count--;
 			tw_dev->state[request_id] = TW_S_COMPLETED;
 			tw_state_request_finish(tw_dev, request_id);
-			spin_unlock_irqrestore(&tw_dev->tw_lock, flags);
+			spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
 			break;
 		default:
 			retval = -ENOTTY;
@@ -789,12 +1041,12 @@
 	}
 
 	/* Now copy the response to userspace */
-	error = copy_to_user(argp, tw_ioctl, sizeof(TW_New_Ioctl) + data_buffer_length - 1);
-	if (error == 0)
-		retval = 0;
+	if (copy_to_user(argp, tw_ioctl, sizeof(TW_New_Ioctl) + data_buffer_length - 1))
+		goto out2;
+	retval = 0;
 out2:
 	/* Now free ioctl buf memory */
-	pci_free_consistent(tw_dev->tw_pci_dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle);
+	dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle);
 out:
 	up(&tw_dev->ioctl_sem);
 	return retval;
@@ -814,445 +1066,16 @@
 	return 0;
 } /* End tw_chrdev_open() */
 
-/* This function handles close for the character device */
-static int tw_chrdev_release(struct inode *inode, struct file *file)
-{
-	dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_release()\n");
-
-	return 0;
-} /* End tw_chrdev_release() */
-
-/* This function will clear all interrupts on the controller */
-void tw_clear_all_interrupts(TW_Device_Extension *tw_dev)
-{
-	u32 control_reg_addr, control_reg_value;
-
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = TW_STATUS_VALID_INTERRUPT;
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_clear_all_interrupts() */
-
-/* This function will clear the attention interrupt */
-void tw_clear_attention_interrupt(TW_Device_Extension *tw_dev)
-{
-	u32 control_reg_addr, control_reg_value;
-  
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = TW_CONTROL_CLEAR_ATTENTION_INTERRUPT;
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_clear_attention_interrupt() */
-
-/* This function will clear the host interrupt */
-void tw_clear_host_interrupt(TW_Device_Extension *tw_dev)
-{
-	u32 control_reg_addr, control_reg_value;
-
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = TW_CONTROL_CLEAR_HOST_INTERRUPT;
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_clear_host_interrupt() */
-
-/* This function is called by tw_scsi_proc_info */
-static int tw_copy_info(TW_Info *info, char *fmt, ...) 
-{
-	va_list args;
-	char buf[81];
-	int len;
-  
-	va_start(args, fmt);
-	len = vsprintf(buf, fmt, args);
-	va_end(args);
-	tw_copy_mem_info(info, buf, len);
-	return len;
-} /* End tw_copy_info() */
-
-/* This function is called by tw_scsi_proc_info */
-static void tw_copy_mem_info(TW_Info *info, char *data, int len)
-{
-	if (info->position + len > info->length)
-		len = info->length - info->position;
-
-	if (info->position + len < info->offset) {
-		info->position += len;
-		return;
-	}
-	if (info->position < info->offset) {
-		data += (info->offset - info->position);
-		len  -= (info->offset - info->position);
-	}
-	if (len > 0) {
-		memcpy(info->buffer + info->position, data, len);
-		info->position += len;
-	}
-} /* End tw_copy_mem_info() */
-
-/* This function will print readable messages from status register errors */
-int tw_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value, int print_host)
-{
-	char host[16];
-
-	dprintk(KERN_WARNING "3w-xxxx: tw_decode_bits()\n");
-
-	if (print_host)
-		sprintf(host, " scsi%d:", tw_dev->host->host_no);
-	else
-		host[0] = '\0';
-
-	if (status_reg_value & TW_STATUS_PCI_PARITY_ERROR) {
-		printk(KERN_WARNING "3w-xxxx:%s PCI Parity Error: clearing.\n", host);
-		outl(TW_CONTROL_CLEAR_PARITY_ERROR, tw_dev->registers.control_reg_addr);
-	}
-
-	if (status_reg_value & TW_STATUS_PCI_ABORT) {
-		printk(KERN_WARNING "3w-xxxx:%s PCI Abort: clearing.\n", host);
-		outl(TW_CONTROL_CLEAR_PCI_ABORT, tw_dev->registers.control_reg_addr);
-		pci_write_config_word(tw_dev->tw_pci_dev, PCI_STATUS, TW_PCI_CLEAR_PCI_ABORT);
-	}
-
-	if (status_reg_value & TW_STATUS_QUEUE_ERROR) {
-		printk(KERN_WARNING "3w-xxxx:%s Controller Queue Error: clearing.\n", host);
-		outl(TW_CONTROL_CLEAR_QUEUE_ERROR, tw_dev->registers.control_reg_addr);
-	}
-
-	if (status_reg_value & TW_STATUS_SBUF_WRITE_ERROR) {
-		printk(KERN_WARNING "3w-xxxx:%s SBUF Write Error: clearing.\n", host);
-		outl(TW_CONTROL_CLEAR_SBUF_WRITE_ERROR, tw_dev->registers.control_reg_addr);
-	}
-
-	if (status_reg_value & TW_STATUS_MICROCONTROLLER_ERROR) {
-		if (tw_dev->reset_print == 0) {
-			printk(KERN_WARNING "3w-xxxx:%s Microcontroller Error: clearing.\n", host);
-			tw_dev->reset_print = 1;
-		}
-		return 1;
-	}
-	
-	return 0;
-} /* End tw_decode_bits() */
-
-/* This function will return valid sense buffer information for failed cmds */
-int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill_sense)
-{
-	int i;
-	TW_Command *command;
-
-        dprintk(KERN_WARNING "3w-xxxx: tw_decode_sense()\n");
-	command = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
-
-	printk(KERN_WARNING "3w-xxxx: scsi%d: Command failed: status = 0x%x, flags = 0x%x, unit #%d.\n", tw_dev->host->host_no, command->status, command->flags, command->byte3.unit);
-
-	/* Attempt to return intelligent sense information */
-	if (fill_sense) {
-		if ((command->status == 0xc7) || (command->status == 0xcb)) {
-			for (i=0;i<(sizeof(tw_sense_table)/sizeof(tw_sense_table[0]));i++) {
-				if (command->flags == tw_sense_table[i][0]) {
-
-					/* Valid bit and 'current errors' */
-					tw_dev->srb[request_id]->sense_buffer[0] = (0x1 << 7 | 0x70);
-
-					/* Sense key */
-					tw_dev->srb[request_id]->sense_buffer[2] = tw_sense_table[i][1];
-
-					/* Additional sense length */
-					tw_dev->srb[request_id]->sense_buffer[7] = 0xa; /* 10 bytes */
-
-					/* Additional sense code */
-					tw_dev->srb[request_id]->sense_buffer[12] = tw_sense_table[i][2];
-
-					/* Additional sense code qualifier */
-					tw_dev->srb[request_id]->sense_buffer[13] = tw_sense_table[i][3];
-
-					tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
-					return TW_ISR_DONT_RESULT; /* Special case for isr to not over-write result */
-				}
-			}
-		}
-
-		/* If no table match, error so we get a reset */
-		return 1;
-	}
-
-	return 0;
-} /* End tw_decode_sense() */
-
-/* This function will disable interrupts on the controller */  
-void tw_disable_interrupts(TW_Device_Extension *tw_dev) 
-{
-	u32 control_reg_value, control_reg_addr;
-
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = TW_CONTROL_DISABLE_INTERRUPTS;
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_disable_interrupts() */
-
-/* This function will empty the response que */
-void tw_empty_response_que(TW_Device_Extension *tw_dev) 
-{
-	u32 status_reg_addr, status_reg_value;
-	u32 response_que_addr, response_que_value;
-
-	status_reg_addr = tw_dev->registers.status_reg_addr;
-	response_que_addr = tw_dev->registers.response_que_addr;
-  
-	status_reg_value = inl(status_reg_addr);
-
-	while ((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) {
-		response_que_value = inl(response_que_addr);
-		status_reg_value = inl(status_reg_addr);
-	}
-} /* End tw_empty_response_que() */
-
-/* This function will enable interrupts on the controller */
-void tw_enable_interrupts(TW_Device_Extension *tw_dev)
-{
-	u32 control_reg_value, control_reg_addr;
-
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = (TW_CONTROL_ENABLE_INTERRUPTS |
-			     TW_CONTROL_UNMASK_RESPONSE_INTERRUPT);
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_enable_interrupts() */
-
-/* This function will enable interrupts on the controller */
-void tw_enable_and_clear_interrupts(TW_Device_Extension *tw_dev)
-{
-	u32 control_reg_value, control_reg_addr;
-
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = (TW_CONTROL_CLEAR_ATTENTION_INTERRUPT |
-			     TW_CONTROL_UNMASK_RESPONSE_INTERRUPT |
-			     TW_CONTROL_ENABLE_INTERRUPTS);
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_enable_and_clear_interrupts() */
-
-/* This function will find and initialize all cards */
-int tw_findcards(Scsi_Host_Template *tw_host) 
-{
-	int numcards = 0, tries = 0, error = 0;
-	struct Scsi_Host *host;
-	TW_Device_Extension *tw_dev;
-	TW_Device_Extension *tw_dev2;
-	struct pci_dev *tw_pci_dev = NULL;
-	u32 status_reg_value;
-	unsigned char c = 1;
-	int i, j = -1;
-	u16 device[TW_NUMDEVICES] = { TW_DEVICE_ID, TW_DEVICE_ID2 };
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_findcards()\n");
-
-	for (i=0;i<TW_NUMDEVICES;i++) {
-		while ((tw_pci_dev = pci_find_device(TW_VENDOR_ID, device[i], tw_pci_dev))) {
-			j++;
-			if (pci_enable_device(tw_pci_dev))
-				continue;
-
-			/* We only need 32-bit addressing for 5,6,7xxx cards */
-			if (pci_set_dma_mask(tw_pci_dev, 0xffffffff)) {
-				printk(KERN_WARNING "3w-xxxx: No suitable DMA available.\n");
-				continue;
-			}
-
-			/* Prepare temporary device extension */
-			tw_dev=(TW_Device_Extension *)kmalloc(sizeof(TW_Device_Extension), GFP_ATOMIC);
-			if (tw_dev == NULL) {
-				printk(KERN_WARNING "3w-xxxx: tw_findcards(): kmalloc() failed for card %d.\n", j);
-				continue;
-			}
-			memset(tw_dev, 0, sizeof(TW_Device_Extension));
-			
-			/* Save pci_dev struct to device extension */
-			tw_dev->tw_pci_dev = tw_pci_dev;
-
-			error = tw_initialize_device_extension(tw_dev);
-			if (error) {
-				printk(KERN_WARNING "3w-xxxx: tw_findcards(): Couldn't initialize device extension for card %d.\n", j);
-				tw_free_device_extension(tw_dev);
-				kfree(tw_dev);
-				continue;
-			}
-
-			/* Calculate the cards register addresses */
-			tw_dev->registers.base_addr = pci_resource_start(tw_pci_dev, 0);
-			tw_dev->registers.control_reg_addr = pci_resource_start(tw_pci_dev, 0);
-			tw_dev->registers.status_reg_addr = pci_resource_start(tw_pci_dev, 0) + 0x4;
-			tw_dev->registers.command_que_addr = pci_resource_start(tw_pci_dev, 0) + 0x8;
-			tw_dev->registers.response_que_addr = pci_resource_start(tw_pci_dev, 0) + 0xC;
-
-			/* Check for errors and clear them */
-			status_reg_value = inl(tw_dev->registers.status_reg_addr);
-			if (TW_STATUS_ERRORS(status_reg_value))
-				tw_decode_bits(tw_dev, status_reg_value, 0);
-			
-			/* Poll status register for 60 secs for 'Controller Ready' flag */
-			if (tw_poll_status(tw_dev, TW_STATUS_MICROCONTROLLER_READY, 60)) {
-				printk(KERN_WARNING "3w-xxxx: tw_findcards(): Microcontroller not ready for card %d.\n", j);
-				tw_free_device_extension(tw_dev);
-				kfree(tw_dev);
-				continue;
-			}
-
-			/* Disable interrupts on the card */
-			tw_disable_interrupts(tw_dev);
-
-			tries = 0;
-
-			while (tries < TW_MAX_RESET_TRIES) {
-				/* Do soft reset */
-				tw_soft_reset(tw_dev);
-			  
-				error = tw_aen_drain_queue(tw_dev);
-				if (error) {
-					printk(KERN_WARNING "3w-xxxx: AEN drain failed for card %d.\n", j);
-					tries++;
-					continue;
-				}
-
-				/* Check for controller errors */
-				if (tw_check_errors(tw_dev)) {
-					printk(KERN_WARNING "3w-xxxx: Controller errors found, retrying for card %d.\n", j);
-					tries++;
-					continue;
-				}
-
-				/* Now the controller is in a good state */
-				break;
-			}
-
-			if (tries >= TW_MAX_RESET_TRIES) {
-				printk(KERN_WARNING "3w-xxxx: Controller errors, card not responding, check all cabling for card %d.\n", j);
-				tw_free_device_extension(tw_dev);
-				kfree(tw_dev);
-				continue;
-			}
-
-			/* Reserve the io address space */
-			if (!request_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE, TW_DEVICE_NAME)) {
-				printk(KERN_WARNING "3w-xxxx: tw_findcards(): Couldn't get io range 0x%lx-0x%lx for card %d.\n", 
-				       (tw_dev->tw_pci_dev->resource[0].start), 
-				       (tw_dev->tw_pci_dev->resource[0].start) + 
-				       TW_IO_ADDRESS_RANGE, j);
-				tw_free_device_extension(tw_dev);
-				kfree(tw_dev);
-				continue;
-			}
-
-			error = tw_initialize_units(tw_dev);
-			if (error) {
-				printk(KERN_WARNING "3w-xxxx: No valid units for for card %d.\n", j);
-			}
-
-			error = tw_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS);
-			if (error) {
-				printk(KERN_WARNING "3w-xxxx: Connection initialization failed for card %d.\n", j);
-				release_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE);
-				tw_free_device_extension(tw_dev);
-				kfree(tw_dev);
-				continue;
-			}
-
-			/* Set card status as online */
-			tw_dev->online = 1;
-
-			tw_dev->free_head = TW_Q_START;
-			tw_dev->free_tail = TW_Q_START;
-			tw_dev->free_wrap = TW_Q_LENGTH - 1;
-
-			/* Register the card with the kernel SCSI layer */
-			host = scsi_register(tw_host, sizeof(TW_Device_Extension));
-			if (host == NULL) {
-				printk(KERN_WARNING "3w-xxxx: tw_findcards(): scsi_register() failed for card %d.\n", j);
-				release_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE);
-				tw_free_device_extension(tw_dev);
-				kfree(tw_dev);
-				continue;
-			}
-
-			/* Set max target id's */
-			host->max_id = TW_MAX_UNITS;
-
-			/* Set max cdb size in bytes */
-			host->max_cmd_len = 16;
-
-			/* Set max sectors per io */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
-			host->max_sectors = TW_MAX_SECTORS;
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-			scsi_set_device(host, &tw_pci_dev->dev);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4)
-			scsi_set_pci_device(host, tw_pci_dev);
-#endif
-
-			status_reg_value = inl(tw_dev->registers.status_reg_addr);
-
-			printk(KERN_NOTICE "scsi%d : Found a 3ware Storage Controller at 0x%x, IRQ: %d, P-chip: %d.%d\n", host->host_no,
-				(u32)(tw_pci_dev->resource[0].start), tw_pci_dev->irq, 
-				(status_reg_value & TW_STATUS_MAJOR_VERSION_MASK) >> 28, 
-				(status_reg_value & TW_STATUS_MINOR_VERSION_MASK) >> 24);
-
-			if (host->hostdata) {
-				tw_dev2 = (TW_Device_Extension *)host->hostdata;
-				memcpy(tw_dev2, tw_dev, sizeof(TW_Device_Extension));
-				/* Need to init the sem/wqueue after the copy */
-				init_MUTEX(&tw_dev2->ioctl_sem);
-				init_waitqueue_head(&tw_dev2->ioctl_wqueue);
-
-				tw_device_extension_list[tw_device_extension_count] = tw_dev2;
-				numcards++;
-				tw_device_extension_count = numcards;
-				tw_dev2->host = host;
-			} else { 
-				printk(KERN_WARNING "3w-xxxx: tw_findcards(): Bad scsi host data for card %d.\n", j);
-				scsi_unregister(host);
-				release_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE);
-				tw_free_device_extension(tw_dev);
-				kfree(tw_dev);
-				continue;
-			}
-
-			/* Tell the firmware we support shutdown notification*/
-			error = tw_setfeature(tw_dev2, 2, 1, &c);
-			if (error) {
-				printk(KERN_WARNING "3w-xxxx: Unable to set features for card %d, old firmware or card.\n", j);
-			}
-
-			/* Now setup the interrupt handler */
-			error = tw_setup_irq(tw_dev2);
-			if (error) {
-				printk(KERN_WARNING "3w-xxxx: tw_findcards(): Error requesting irq for card %d.\n", j);
-				scsi_unregister(host);
-				release_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE);
-
-				tw_free_device_extension(tw_dev);
-				kfree(tw_dev);
-				numcards--;
-				continue;
-			}
-
-			/* Re-enable interrupts on the card */
-			tw_enable_interrupts(tw_dev2);
-
-			/* Free the temporary device extension */
-			if (tw_dev)
-				kfree(tw_dev);
-		}
-	}
-
-	if (numcards == 0) {
-		printk(KERN_WARNING "3w-xxxx: No cards found.\n");
-	} else {
-		register_reboot_notifier(&tw_notifier);
-		if ((twe_major = register_chrdev (0, "twe", &tw_fops)) < 0) {
-			printk(KERN_WARNING "3w-xxxx: Unable to register \"twe\" character device, error = %d.\n", twe_major);
-		}
-	}
-
-	return numcards;
-} /* End tw_findcards() */
+/* File operations struct for character device */
+static struct file_operations tw_fops = {
+	.owner		= THIS_MODULE,
+	.ioctl		= tw_chrdev_ioctl,
+	.open		= tw_chrdev_open,
+	.release	= NULL
+};
 
 /* This function will free up device extension resources */
-void tw_free_device_extension(TW_Device_Extension *tw_dev)
+static void tw_free_device_extension(TW_Device_Extension *tw_dev)
 {
 	dprintk(KERN_NOTICE "3w-xxxx: tw_free_device_extension()\n");
 
@@ -1264,36 +1087,15 @@
 		pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Sector)*TW_Q_LENGTH, tw_dev->alignment_virtual_address[0], tw_dev->alignment_physical_address[0]);
 } /* End tw_free_device_extension() */
 
-/* Clean shutdown routine */
-static int tw_halt(struct notifier_block *nb, ulong event, void *buf)
-{
-	int i;
-
-	for (i=0;i<tw_device_extension_count;i++) {
-		if (tw_device_extension_list[i]->online == 1) {
-			printk(KERN_NOTICE "3w-xxxx: Shutting down card %d.\n", i);
-			tw_shutdown_device(tw_device_extension_list[i]);
-			tw_device_extension_list[i]->online = 0;
-		}
-	}
-	unregister_reboot_notifier(&tw_notifier);
-
-	return NOTIFY_OK;
-} /* End tw_halt() */
-
 /* This function will send an initconnection command to controller */
-int tw_initconnection(TW_Device_Extension *tw_dev, int message_credits) 
+static int tw_initconnection(TW_Device_Extension *tw_dev, int message_credits) 
 {
 	unsigned long command_que_value;
-	u32 command_que_addr;
-	u32 response_que_addr;
 	TW_Command  *command_packet;
 	TW_Response_Queue response_queue;
 	int request_id = 0;
 
 	dprintk(KERN_NOTICE "3w-xxxx: tw_initconnection()\n");
-	command_que_addr = tw_dev->registers.command_que_addr;
-	response_que_addr = tw_dev->registers.response_que_addr;
 
 	/* Initialize InitConnection command packet */
 	if (tw_dev->command_packet_virtual_address[request_id] == NULL) {
@@ -1303,12 +1105,9 @@
 
 	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
 	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode = TW_OP_INIT_CONNECTION;
-	command_packet->byte0.sgl_offset = 0x0;
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(0, TW_OP_INIT_CONNECTION);
 	command_packet->size = TW_INIT_COMMAND_PACKET_SIZE;
 	command_packet->request_id = request_id;
-	command_packet->byte3.unit = 0x0;
-	command_packet->byte3.host_id = 0x0;
 	command_packet->status = 0x0;
 	command_packet->flags = 0x0;
 	command_packet->byte6.message_credits = message_credits; 
@@ -1321,12 +1120,13 @@
 	}
   
 	/* Send command packet to the board */
-	outl(command_que_value, command_que_addr);
+	outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
     
 	/* Poll for completion */
 	if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) {
-		response_queue.value = inl(response_que_addr);
-		request_id = (unsigned char)response_queue.u.response_id;
+		response_queue.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
+		request_id = TW_RESID_OUT(response_queue.response_id);
+
 		if (request_id != 0) {
 			/* unexpected request id */
 			printk(KERN_WARNING "3w-xxxx: tw_initconnection(): Unexpected request id.\n");
@@ -1341,111 +1141,64 @@
 	return 0;
 } /* End tw_initconnection() */
 
-/* This function will initialize the fields of a device extension */
-int tw_initialize_device_extension(TW_Device_Extension *tw_dev)
-{
-	int i, error=0;
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_initialize_device_extension()\n");
-
-	/* Initialize command packet buffers */
-	error = tw_allocate_memory(tw_dev, sizeof(TW_Command), 0);
-	if (error) {
-		printk(KERN_WARNING "3w-xxxx: Command packet memory allocation failed.\n");
-		return 1;
-	}
-
-	/* Initialize generic buffer */
-	error = tw_allocate_memory(tw_dev, sizeof(TW_Sector), 1);
-	if (error) {
-		printk(KERN_WARNING "3w-xxxx: Generic memory allocation failed.\n");
-		return 1;
-	}
-
-	for (i=0;i<TW_Q_LENGTH;i++) {
-		tw_dev->free_queue[i] = i;
-		tw_dev->state[i] = TW_S_INITIAL;
-	}
-
-	tw_dev->pending_head = TW_Q_START;
-	tw_dev->pending_tail = TW_Q_START;
-	spin_lock_init(&tw_dev->tw_lock);
-	tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
-
-	return 0;
-} /* End tw_initialize_device_extension() */
-
-/* This function will get unit info from the controller */
-int tw_initialize_units(TW_Device_Extension *tw_dev) 
+/* Set a value in the features table */
+static int tw_setfeature(TW_Device_Extension *tw_dev, int parm, int param_size,
+                  unsigned char *val)
 {
-	int found = 0;
-	unsigned char request_id = 0;
-	TW_Command *command_packet;
 	TW_Param *param;
-	int i, imax, num_units = 0;
-	unsigned long command_que_value;
-	u32 command_que_addr;
-	u32 response_que_addr;
+	TW_Command  *command_packet;
 	TW_Response_Queue response_queue;
+	int request_id = 0;
+	unsigned long command_que_value;
 	unsigned long param_value;
-	unsigned char *is_unit_present;
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_initialize_units()\n");
 
-	command_que_addr = tw_dev->registers.command_que_addr;
-	response_que_addr = tw_dev->registers.response_que_addr;
-  
-	/* Setup the command packet */
-	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
-	if (command_packet == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_initialize_units(): Bad command packet virtual address.\n");
+  	/* Initialize SetParam command packet */
+	if (tw_dev->command_packet_virtual_address[request_id] == NULL) {
+		printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet virtual address.\n");
 		return 1;
 	}
+	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
 	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode      = TW_OP_GET_PARAM;
-	command_packet->byte0.sgl_offset  = 2;
-	command_packet->size              = 4;
-	command_packet->request_id        = request_id;
-	command_packet->byte3.unit        = 0;
-	command_packet->byte3.host_id     = 0;
-	command_packet->status            = 0;
-	command_packet->flags             = 0;
-	command_packet->byte6.block_count = 1;
-
-	/* Now setup the param */
-	if (tw_dev->alignment_virtual_address[request_id] == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_initialize_units(): Bad alignment virtual address.\n");
-		return 1;
-	}
 	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
-	memset(param, 0, sizeof(TW_Sector));
-	param->table_id = 3;       /* unit summary table */
-	param->parameter_id = 3;   /* unitstatus parameter */
-	param->parameter_size_bytes = TW_MAX_UNITS;
+
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_SET_PARAM);
+	param->table_id = 0x404;  /* Features table */
+	param->parameter_id = parm;
+	param->parameter_size_bytes = param_size;
+	memcpy(param->data, val, param_size);
+
 	param_value = tw_dev->alignment_physical_address[request_id];
 	if (param_value == 0) {
-		printk(KERN_WARNING "3w-xxxx: tw_initialize_units(): Bad alignment physical address.\n");
-		return 1;
+		printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad alignment physical address.\n");
+		tw_dev->state[request_id] = TW_S_COMPLETED;
+		tw_state_request_finish(tw_dev, request_id);
+		tw_dev->srb[request_id]->result = (DID_OK << 16);
+		tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
 	}
-
 	command_packet->byte8.param.sgl[0].address = param_value;
 	command_packet->byte8.param.sgl[0].length = sizeof(TW_Sector);
 
-	/* Post the command packet to the board */
-	command_que_value = tw_dev->command_packet_physical_address[request_id];
+	command_packet->size = 4;
+	command_packet->request_id = request_id;
+	command_packet->byte6.parameter_count = 1;
+
+  	command_que_value = tw_dev->command_packet_physical_address[request_id];
 	if (command_que_value == 0) {
-		printk(KERN_WARNING "3w-xxxx: tw_initialize_units(): Bad command packet physical address.\n");
-		return 1;
+		printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet physical address.\n");
+	return 1;
 	}
-	outl(command_que_value, command_que_addr);
+
+	/* Send command packet to the board */
+	outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
 
 	/* Poll for completion */
 	if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) {
-		response_queue.value = inl(response_que_addr);
-		request_id = (unsigned char)response_queue.u.response_id;
+		response_queue.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
+		request_id = TW_RESID_OUT(response_queue.response_id);
+
 		if (request_id != 0) {
 			/* unexpected request id */
-			printk(KERN_WARNING "3w-xxxx: tw_initialize_units(): Unexpected request id.\n");
+			printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Unexpected request id.\n");
 			return 1;
 		}
 		if (command_packet->status != 0) {
@@ -1453,847 +1206,169 @@
 			tw_decode_sense(tw_dev, request_id, 0);
 			return 1;
 		}
-		found = 1;
-	}
-	if (found == 0) {
-		/* response never received */
-		printk(KERN_WARNING "3w-xxxx: tw_initialize_units(): No response.\n");
-		return 1;
-	}
-
-	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
-	is_unit_present = (unsigned char *)&(param->data[0]);
-  
-	/* Show all units present */
-	imax = TW_MAX_UNITS;
-	for(i=0; i<imax; i++) {
-		if (is_unit_present[i] == 0) {
-			tw_dev->is_unit_present[i] = FALSE;
-		} else {
-		  if (is_unit_present[i] & TW_UNIT_ONLINE) {
-			dprintk(KERN_NOTICE "3w-xxxx: tw_initialize_units(): Unit %d found.\n", i);
-			tw_dev->is_unit_present[i] = TRUE;
-			num_units++;
-		  }
-		}
-	}
-	tw_dev->num_units = num_units;
-
-	if (num_units == 0) {
-		dprintk(KERN_NOTICE "3w-xxxx: tw_initialize_units(): No units found.\n");
-		return 1;
 	}
 
 	return 0;
-} /* End tw_initialize_units() */
+} /* End tw_setfeature() */
 
-/* This function is the interrupt service routine */
-static irqreturn_t tw_interrupt(int irq, void *dev_instance,
-					struct pt_regs *regs) 
+/* This function will reset a controller */
+static int tw_reset_sequence(TW_Device_Extension *tw_dev) 
 {
-	int request_id;
-	u32 status_reg_addr, status_reg_value;
-	u32 response_que_addr;
-	TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance;
-	TW_Response_Queue response_que;
-	int error = 0, retval = 0;
-	unsigned long flags = 0;
-	TW_Command *command_packet;
-	int handled = 0;
-
-	dprintk(KERN_WARNING "3w-xxxx: tw_interrupt()\n");
-
-	/* See if we are already running on another processor */
-	if (test_and_set_bit(TW_IN_INTR, &tw_dev->flags))
-		return IRQ_NONE;
-
-	/* Get the host lock for io completions */
-	spin_lock_irqsave(tw_dev->host->host_lock, flags);
-
-	/* See if the interrupt matches this instance */
-	if (tw_dev->tw_pci_dev->irq == irq) {
-
-		handled = 1;
-		/* Make sure io isn't queueing */
-		spin_lock(&tw_dev->tw_lock);
-
-		/* Read the registers */
-		status_reg_addr = tw_dev->registers.status_reg_addr;
-		response_que_addr = tw_dev->registers.response_que_addr;
-		status_reg_value = inl(status_reg_addr);
-
-		/* Check if this is our interrupt, otherwise bail */
-		if (!(status_reg_value & TW_STATUS_VALID_INTERRUPT))
-			goto tw_interrupt_bail;
-
-		/* Check controller for errors */
-		if (tw_check_bits(status_reg_value)) {
-			dprintk(KERN_WARNING "3w-xxxx: tw_interrupt(): Unexpected bits.\n");
-			if (tw_decode_bits(tw_dev, status_reg_value, 1)) {
-				tw_clear_all_interrupts(tw_dev);
-				goto tw_interrupt_bail;
-			}
-		}
-
-		/* Handle host interrupt */
-		if (status_reg_value & TW_STATUS_HOST_INTERRUPT) {
-			dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): Received host interrupt.\n");
-			tw_clear_host_interrupt(tw_dev);
-		}
+	int error = 0;
+	int tries = 0;
+	unsigned char c = 1;
 
-		/* Handle attention interrupt */
-		if (status_reg_value & TW_STATUS_ATTENTION_INTERRUPT) {
-			dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): Received attention interrupt.\n");
-			tw_clear_attention_interrupt(tw_dev);
-			tw_state_request_start(tw_dev, &request_id);
-			error = tw_aen_read_queue(tw_dev, request_id);
-			if (error) {
-				printk(KERN_WARNING "3w-xxxx: scsi%d: Error reading aen queue.\n", tw_dev->host->host_no);
-				tw_dev->state[request_id] = TW_S_COMPLETED;
-				tw_state_request_finish(tw_dev, request_id);
-			}
-		}
+	/* Reset the board */
+	while (tries < TW_MAX_RESET_TRIES) {
+		TW_SOFT_RESET(tw_dev);
 
-		/* Handle command interrupt */
-		if (status_reg_value & TW_STATUS_COMMAND_INTERRUPT) {
-			/* Drain as many pending commands as we can */
-			while (tw_dev->pending_request_count > 0) {
-				request_id = tw_dev->pending_queue[tw_dev->pending_head];
-				if (tw_dev->state[request_id] != TW_S_PENDING) {
-					printk(KERN_WARNING "3w-xxxx: scsi%d: Found request id that wasn't pending.\n", tw_dev->host->host_no);
-					break;
-				}
-				if (tw_post_command_packet(tw_dev, request_id)==0) {
-					if (tw_dev->pending_head == TW_Q_LENGTH-1) {
-						tw_dev->pending_head = TW_Q_START;
-					} else {
-						tw_dev->pending_head = tw_dev->pending_head + 1;
-					}
-					tw_dev->pending_request_count--;
-				} else {
-					/* If we get here, we will continue re-posting on the next command interrupt */
-					break;
-				}
-			}
-			/* If there are no more pending requests, we mask command interrupt */
-			if (tw_dev->pending_request_count == 0) 
-				tw_mask_command_interrupt(tw_dev);
+		error = tw_aen_drain_queue(tw_dev);
+		if (error) {
+			printk(KERN_WARNING "3w-xxxx: scsi%d: AEN drain failed, retrying.\n", tw_dev->host->host_no);
+			tries++;
+			continue;
 		}
 
-		/* Handle response interrupt */
-		if (status_reg_value & TW_STATUS_RESPONSE_INTERRUPT) {
-			/* Drain the response queue from the board */
-			while ((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) {
-				/* Read response queue register */
-				response_que.value = inl(response_que_addr);
-				request_id = response_que.u.response_id;
-				command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
-				error = 0;
-
-				/* Check for bad response */
-				if (command_packet->status != 0) {
-					/* If internal command, don't error, don't fill sense */
-					if (tw_dev->srb[request_id] == 0) {
-						tw_decode_sense(tw_dev, request_id, 0);
-					} else {
-						error = tw_decode_sense(tw_dev, request_id, 1);
-					}
-				}
-
-				/* Check for correct state */
-				if (tw_dev->state[request_id] != TW_S_POSTED) {
-					/* Handle timed out ioctl's */
-					if (tw_dev->srb[request_id] != 0) {
-						if (tw_dev->srb[request_id]->cmnd[0] != TW_IOCTL) {
-							printk(KERN_WARNING "3w-xxxx: scsi%d: Received a request id (%d) (opcode = 0x%x) that wasn't posted.\n", tw_dev->host->host_no, request_id, command_packet->byte0.opcode);
-							error = 1;
-						}
-					}
-				}
-
-				dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): Response queue request id: %d.\n", request_id);
-
-				/* Check for internal command completion */
-				if (tw_dev->srb[request_id] == 0) {
-					dprintk(KERN_WARNING "3w-xxxx: tw_interrupt(): Found internally posted command.\n");
-					/* Check for chrdev ioctl completion */
-					if (request_id != tw_dev->chrdev_request_id) {
-						retval = tw_aen_complete(tw_dev, request_id);
-						if (retval) {
-							printk(KERN_WARNING "3w-xxxx: scsi%d: Error completing aen.\n", tw_dev->host->host_no);
-						}
-					} else {
-						tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
-						wake_up(&tw_dev->ioctl_wqueue);
-					}
-				} else {
-				switch (tw_dev->srb[request_id]->cmnd[0]) {
-					case READ_10:
-					case READ_6:
-						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught READ_10/READ_6\n");
-						break;
-					case WRITE_10:
-					case WRITE_6:
-						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught WRITE_10/WRITE_6\n");
-						break;
-					case TEST_UNIT_READY:
-						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught TEST_UNIT_READY\n");
-						error = tw_scsiop_test_unit_ready_complete(tw_dev, request_id);
-						break;
-					case INQUIRY:
-						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught INQUIRY\n");
-						error = tw_scsiop_inquiry_complete(tw_dev, request_id);
-						break;
-					case READ_CAPACITY:
-						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught READ_CAPACITY\n");
-						error = tw_scsiop_read_capacity_complete(tw_dev, request_id);
-						break;
-					case MODE_SENSE:
-						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught MODE_SENSE\n");
-						error = tw_scsiop_mode_sense_complete(tw_dev, request_id);
-						break;
-					case SYNCHRONIZE_CACHE:
-						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught SYNCHRONIZE_CACHE\n");
-						break;
-					case TW_IOCTL:
-						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught TW_IOCTL\n");
-						error = tw_ioctl_complete(tw_dev, request_id);
-						break;
-					default:
-						printk(KERN_WARNING "3w-xxxx: case slip in tw_interrupt()\n");
-						error = 1;
-					}
-
-					/* If no error command was a success */
-					if (error == 0) {
-						tw_dev->srb[request_id]->result = (DID_OK << 16);
-					}
-
-					/* If error, command failed */
-					if (error == 1) {
-						/* Ask for a host reset */
-						tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
-					}
-
-					/* Now complete the io */
-					if ((error != TW_ISR_DONT_COMPLETE)) {
-						tw_dev->state[request_id] = TW_S_COMPLETED;
-						tw_state_request_finish(tw_dev, request_id);
-						tw_dev->posted_request_count--;
-						tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
-
-						tw_unmap_scsi_data(tw_dev->tw_pci_dev, tw_dev->srb[request_id]);
-					}
-				}
-				
-				/* Check for valid status after each drain */
-				status_reg_value = inl(status_reg_addr);
-				if (tw_check_bits(status_reg_value)) {
-					dprintk(KERN_WARNING "3w-xxxx: tw_interrupt(): Unexpected bits.\n");
-					if (tw_decode_bits(tw_dev, status_reg_value, 1)) {
-						tw_clear_all_interrupts(tw_dev);
-						goto tw_interrupt_bail;
-					}
-				}
-			}
+		/* Check for controller errors */
+		if (tw_check_errors(tw_dev)) {
+			printk(KERN_WARNING "3w-xxxx: scsi%d: Controller errors found, retrying.\n", tw_dev->host->host_no);
+			tries++;
+			continue;
 		}
-tw_interrupt_bail:
-		spin_unlock(&tw_dev->tw_lock);
-	} else
-		dprintk(KERN_WARNING "3w-xxxx: tw_interrupt() called for wrong instance.\n");
-
-	spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
-	clear_bit(TW_IN_INTR, &tw_dev->flags);
-	return IRQ_RETVAL(handled);
-} /* End tw_interrupt() */
 
-/* This function handles ioctls from userspace to the driver */
-int tw_ioctl(TW_Device_Extension *tw_dev, int request_id)
-{
-	unsigned char opcode;
-	int bufflen, error = 0;
-	TW_Param *param;
-	TW_Command *command_packet, *command_save;
-	unsigned long param_value;
-	TW_Ioctl *ioctl = NULL;
-	TW_Passthru *passthru = NULL;
-	int tw_aen_code, i, use_sg;
-	unsigned long *data_ptr;
-	int total_bytes = 0, posted = 0;
-	dma_addr_t dma_handle;
-	struct timeval before, timeout;
-
-	ioctl = (TW_Ioctl *)tw_dev->srb[request_id]->request_buffer;
-	if (ioctl == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_ioctl(): Request buffer NULL.\n");
-		tw_dev->state[request_id] = TW_S_COMPLETED;
-		tw_state_request_finish(tw_dev, request_id);
-		tw_dev->srb[request_id]->result = (DID_OK << 16);
-		tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
-		return 0;
-	}
-	bufflen = tw_dev->srb[request_id]->request_bufflen;
-
-	/* Initialize command packet */
-	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
-	if (command_packet == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_ioctl(): Bad command packet virtual address.\n");
-		tw_dev->state[request_id] = TW_S_COMPLETED;
-		tw_state_request_finish(tw_dev, request_id);
-		tw_dev->srb[request_id]->result = (DID_OK << 16);
-		tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
-		return 0;
+		/* Now the controller is in a good state */
+		break;
 	}
-	memset(command_packet, 0, sizeof(TW_Sector));
 
-	/* Initialize param */
-	if (tw_dev->alignment_virtual_address[request_id] == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_ioctl(): Bad alignment virtual address.\n");
-		tw_dev->state[request_id] = TW_S_COMPLETED;
-		tw_state_request_finish(tw_dev, request_id);
-		tw_dev->srb[request_id]->result = (DID_OK << 16);
-		tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
-		return 0;
+	if (tries >= TW_MAX_RESET_TRIES) {
+		printk(KERN_WARNING "3w-xxxx: scsi%d: Controller errors, card not responding, check all cabling.\n", tw_dev->host->host_no);
+		return 1;
 	}
-	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
-	memset(param, 0, sizeof(TW_Sector));
-
-	dprintk(KERN_NOTICE "opcode = %d table_id = %d parameter_id = %d parameter_size_bytes = %d\n", ioctl->opcode, ioctl->table_id, ioctl->parameter_id, ioctl->parameter_size_bytes);
-	opcode = ioctl->opcode;
-
-	switch (opcode) {
-		case TW_OP_NOP:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_ioctl(): caught TW_OP_NOP.\n");
-			command_packet->byte0.opcode = TW_OP_NOP;
-			break;
-		case TW_OP_GET_PARAM:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_ioctl(): caught TW_OP_GET_PARAM.\n");
-			command_packet->byte0.opcode = TW_OP_GET_PARAM;
-			command_packet->byte3.unit = ioctl->unit_index;
-			param->table_id = ioctl->table_id;
-			param->parameter_id = ioctl->parameter_id;
-			param->parameter_size_bytes = ioctl->parameter_size_bytes;
-			tw_dev->ioctl_size[request_id] = ioctl->parameter_size_bytes;
-			dprintk(KERN_NOTICE "table_id = %d parameter_id = %d parameter_size_bytes %d\n", param->table_id, param->parameter_id, param->parameter_size_bytes);
-			break;
-		case TW_OP_SET_PARAM:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_ioctl(): caught TW_OP_SET_PARAM: table_id = %d, parameter_id = %d, parameter_size_bytes = %d.\n",
-			ioctl->table_id, ioctl->parameter_id, ioctl->parameter_size_bytes);
-			if (ioctl->data != NULL) {
-				command_packet->byte0.opcode = TW_OP_SET_PARAM;
-				param->table_id = ioctl->table_id;
-				param->parameter_id = ioctl->parameter_id;
-				param->parameter_size_bytes = ioctl->parameter_size_bytes;
-				memcpy(param->data, ioctl->data, ioctl->parameter_size_bytes);
-				break;
-			} else {
-				printk(KERN_WARNING "3w-xxxx: tw_ioctl(): ioctl->data NULL.\n");
-				return 1;
-			}
-		case TW_OP_AEN_LISTEN:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_ioctl(): caught TW_OP_AEN_LISTEN.\n");
-			if (tw_dev->aen_head == tw_dev->aen_tail) {
-				/* aen queue empty */
-				dprintk(KERN_NOTICE "3w-xxxx: tw_ioctl(): Aen queue empty.\n");
-				tw_aen_code = TW_AEN_QUEUE_EMPTY;
-				memcpy(tw_dev->srb[request_id]->request_buffer, &tw_aen_code, ioctl->parameter_size_bytes);
-			} else {
-				/* Copy aen queue entry to request buffer */
-				dprintk(KERN_NOTICE "3w-xxxx: tw_ioctl(): Returning aen 0x%x\n", tw_dev->aen_queue[tw_dev->aen_head]);
-				tw_aen_code = tw_dev->aen_queue[tw_dev->aen_head];
-				memcpy(tw_dev->srb[request_id]->request_buffer, &tw_aen_code, ioctl->parameter_size_bytes);
-				if (tw_dev->aen_head == TW_Q_LENGTH - 1) {
-					tw_dev->aen_head = TW_Q_START;
-				} else {
-					tw_dev->aen_head = tw_dev->aen_head + 1;
-				}
-			}
-			tw_dev->state[request_id] = TW_S_COMPLETED;
-			tw_state_request_finish(tw_dev, request_id);
-			tw_dev->srb[request_id]->result = (DID_OK << 16);
-			tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
-			return 0;
-		case TW_ATA_PASSTHRU:
-			if (ioctl->data != NULL) {
-				memcpy(command_packet, ioctl->data, sizeof(TW_Command));
-				command_packet->request_id = request_id;
-			} else {
-				printk(KERN_WARNING "3w-xxxx: tw_ioctl(): ioctl->data NULL.\n");
-				return 1;
-			}
-
-			passthru = (TW_Passthru *)tw_dev->command_packet_virtual_address[request_id];
-			/* Don't load sg_list for non-data ATA cmds */
-			if ((passthru->param != 0) && (passthru->param != 0x8)) {
-				passthru->sg_list[0].length = passthru->sector_count*512;
-				if (passthru->sg_list[0].length > TW_MAX_PASSTHRU_BYTES) {
-					printk(KERN_WARNING "3w-xxxx: tw_ioctl(): Passthru size (%d) too big.\n", passthru->sg_list[0].length);
-					return 1;
-				}
-				passthru->sg_list[0].address = tw_dev->alignment_physical_address[request_id];
-			}
-			tw_post_command_packet(tw_dev, request_id);
-			return 0;
-		case TW_CMD_PACKET:
-			dprintk(KERN_WARNING "3w-xxxx: tw_ioctl(): caught TW_CMD_PACKET.\n");
-			if (ioctl->data != NULL) {
-				memcpy(command_packet, ioctl->data, sizeof(TW_Command));
-				command_packet->request_id = request_id;
-				tw_post_command_packet(tw_dev, request_id);
-				return 0;
-			} else {
-				printk(KERN_WARNING "3w-xxxx: tw_ioctl(): ioctl->data NULL.\n");
-				return 1;
-			}
-		case TW_CMD_PACKET_WITH_DATA:
-			dprintk(KERN_WARNING "3w-xxxx: tw_ioctl(): caught TW_CMD_PACKET_WITH_DATA.\n");
-			command_save = (TW_Command *)tw_dev->alignment_virtual_address[request_id];
-			if (command_save == NULL) {
-				printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): Bad alignment virtual address.\n", tw_dev->host->host_no);
-				return 1;
-			}
-			if (ioctl->data != NULL) {
-				/* Copy down the command packet */
-				memcpy(command_packet, ioctl->data, sizeof(TW_Command));
-				memcpy(command_save, ioctl->data, sizeof(TW_Command));
-				command_packet->request_id = request_id;
-
-				/* Now deal with the two possible sglists */
-				if (command_packet->byte0.sgl_offset == 2) {
-					use_sg = command_packet->size - 3;
-					for (i=0;i<use_sg;i++)
-						total_bytes+=command_packet->byte8.param.sgl[i].length;
-					tw_dev->ioctl_data[request_id] = pci_alloc_consistent(tw_dev->tw_pci_dev, total_bytes, &dma_handle);
-
-					if (!tw_dev->ioctl_data[request_id]) {
-						printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): pci_alloc_consistent() failed for request_id %d.\n", tw_dev->host->host_no, request_id);
-						return 1;
-					}
-
-					/* Copy param sglist into the kernel */
-					data_ptr = tw_dev->ioctl_data[request_id];
-					for (i=0;i<use_sg;i++) {
-						if (command_packet->byte8.param.sgl[i].address != 0) {
-							error = copy_from_user(data_ptr, (void *)(unsigned long)command_packet->byte8.param.sgl[i].address, command_packet->byte8.param.sgl[i].length);
-							if (error) {
-								dprintk(KERN_WARNING "3w-xxxx: scsi%d: Error copying param sglist from userspace.\n", tw_dev->host->host_no);
-								goto tw_ioctl_bail;
-							}
-						} else {
-							printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): Bad param sgl address.\n", tw_dev->host->host_no);
-							tw_dev->srb[request_id]->result = (DID_RESET << 16);
-							goto tw_ioctl_bail;
-						}
-						data_ptr+=command_packet->byte8.param.sgl[i].length;
-					}
-					command_packet->size = 4;
-					command_packet->byte8.param.sgl[0].address = dma_handle;
-					command_packet->byte8.param.sgl[0].length = total_bytes;
-				}
-				if (command_packet->byte0.sgl_offset == 3) {
-					use_sg = command_packet->size - 4;
-					for (i=0;i<use_sg;i++)
-						total_bytes+=command_packet->byte8.io.sgl[i].length;
-					tw_dev->ioctl_data[request_id] = pci_alloc_consistent(tw_dev->tw_pci_dev, total_bytes, &dma_handle);
-
-					if (!tw_dev->ioctl_data[request_id]) {
-						printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): pci_alloc_consistent() failed for request_id %d.\n", tw_dev->host->host_no, request_id);
-						return 1;
-					}
-					if (command_packet->byte0.opcode == TW_OP_WRITE) {
-						/* Copy io sglist into the kernel */
-						data_ptr = tw_dev->ioctl_data[request_id];
-						for (i=0;i<use_sg;i++) {
-							if (command_packet->byte8.io.sgl[i].address != 0) {
-								error = copy_from_user(data_ptr, (void *)(unsigned long)command_packet->byte8.io.sgl[i].address, command_packet->byte8.io.sgl[i].length);
-								if (error) {
-									dprintk(KERN_WARNING "3w-xxxx: scsi%d: Error copying io sglist from userspace.\n", tw_dev->host->host_no);
-									goto tw_ioctl_bail;
-								}
-							} else {
-								printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): Bad io sgl address.\n", tw_dev->host->host_no);
-								tw_dev->srb[request_id]->result = (DID_RESET << 16);
-								goto tw_ioctl_bail;
-							}
-							data_ptr+=command_packet->byte8.io.sgl[i].length;
-						}
-					}
-					command_packet->size = 5;
-					command_packet->byte8.io.sgl[0].address = dma_handle;
-					command_packet->byte8.io.sgl[0].length = total_bytes;
-				}
-
-				spin_unlock(&tw_dev->tw_lock);
-				spin_unlock_irq(tw_dev->host->host_lock);
-
-				set_bit(TW_IN_IOCTL, &tw_dev->flags);
-
-				/* Finally post the command packet */
-				tw_post_command_packet(tw_dev, request_id);
-				posted = 1;
-				do_gettimeofday(&before);
-
-			tw_ioctl_retry:
-				mdelay(TW_IOCTL_WAIT_TIME);
-				if (test_bit(TW_IN_IOCTL, &tw_dev->flags)) {
-					do_gettimeofday(&timeout);
-					if (before.tv_sec + TW_IOCTL_TIMEOUT < timeout.tv_sec) {
-						spin_lock_irq(tw_dev->host->host_lock);
-						spin_lock(&tw_dev->tw_lock);
-						goto tw_ioctl_bail;
-					} else {
-						goto tw_ioctl_retry;
-					}
-				}
-
-				spin_lock_irq(tw_dev->host->host_lock);
-				spin_lock(&tw_dev->tw_lock);
-
-				if (signal_pending(current)) {
-					dprintk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): Signal pending, aborting ioctl().\n", tw_dev->host->host_no);
-					tw_dev->srb[request_id]->result = (DID_OK << 16);
-					goto tw_ioctl_bail;
-				}
-
-				tw_dev->srb[request_id]->result = (DID_OK << 16);
-				/* Now copy up the param or io sglist to userspace */
-				if (command_packet->byte0.sgl_offset == 2) {
-					use_sg = command_save->size - 3;
-					data_ptr = tw_dev->ioctl_data[request_id];
-					for (i=0;i<use_sg;i++) {
-						if (command_save->byte8.param.sgl[i].address != 0) {
-							error = copy_to_user((void *)(unsigned long)command_save->byte8.param.sgl[i].address, data_ptr, command_save->byte8.param.sgl[i].length);
-							if (error) {
-								dprintk(KERN_WARNING "3w-xxxx: scsi%d: Error copying param sglist to userspace.\n", tw_dev->host->host_no);
-								goto tw_ioctl_bail;
-							}
-							dprintk(KERN_WARNING "3w-xxxx: scsi%d: Copied %ld bytes to pid %d.\n", tw_dev->host->host_no, command_save->byte8.param.sgl[i].length, current->pid);
-							data_ptr+=command_save->byte8.param.sgl[i].length;
-						} else {
-							printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): Bad param sgl address.\n", tw_dev->host->host_no);
-							tw_dev->srb[request_id]->result = (DID_RESET << 16);
-							goto tw_ioctl_bail;
-						}
-					}
-				}
-				if (command_packet->byte0.sgl_offset == 3) {
-					use_sg = command_save->size - 4;
-					if (command_packet->byte0.opcode == TW_OP_READ) {
-						data_ptr = tw_dev->ioctl_data[request_id];
-						for(i=0;i<use_sg;i++) {
-							if (command_save->byte8.io.sgl[i].address != 0) {
-								error = copy_to_user((void *)(unsigned long)command_save->byte8.io.sgl[i].address, data_ptr, command_save->byte8.io.sgl[i].length);
-								if (error) {
-									dprintk(KERN_WARNING "3w-xxxx: scsi%d: Error copying io sglist to userspace.\n", tw_dev->host->host_no);
-									goto tw_ioctl_bail;
-								}
-								dprintk(KERN_WARNING "3w-xxxx: scsi%d: Copied %ld bytes to pid %d.\n", tw_dev->host->host_no, command_save->byte8.io.sgl[i].length, current->pid);
-								data_ptr+=command_save->byte8.io.sgl[i].length;
-							} else {
-								printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): Bad io sgl address.\n", tw_dev->host->host_no);
-								tw_dev->srb[request_id]->result = (DID_RESET << 16);
-								goto tw_ioctl_bail;
-							}
-						}
-					}
-				}
-				
-			tw_ioctl_bail:
 
-				/* Free up sglist memory */
-				if (tw_dev->ioctl_data[request_id])
-					pci_free_consistent(tw_dev->tw_pci_dev, total_bytes, tw_dev->ioctl_data[request_id], dma_handle);
-				else
-					printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl(): Error freeing ioctl data.\n", tw_dev->host->host_no);
-				
-				/* Now complete the io */
-				tw_dev->state[request_id] = TW_S_COMPLETED;
-				tw_state_request_finish(tw_dev, request_id);
-				if (posted)
-					tw_dev->posted_request_count--;
-				tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
-				return 0;
-			} else {
-				printk(KERN_WARNING "3w-xxxx: tw_ioctl(): ioctl->data NULL.\n");
-				return 1;
-			}
-		default:
-			dprintk(KERN_WARNING "3w-xxxx: Unknown ioctl 0x%x.\n", opcode);
-			tw_dev->state[request_id] = TW_S_COMPLETED;
-			tw_state_request_finish(tw_dev, request_id);
-			tw_dev->srb[request_id]->result = (DID_OK << 16);
-			tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
-			return 0;
+	error = tw_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS);
+	if (error) {
+		printk(KERN_WARNING "3w-xxxx: scsi%d: Connection initialization failed.\n", tw_dev->host->host_no);
+		return 1;
 	}
 
-	param_value = tw_dev->alignment_physical_address[request_id];
-	if (param_value == 0) {
-		printk(KERN_WARNING "3w-xxxx: tw_ioctl(): Bad alignment physical address.\n");
-		tw_dev->state[request_id] = TW_S_COMPLETED;
-		tw_state_request_finish(tw_dev, request_id);
-		tw_dev->srb[request_id]->result = (DID_OK << 16);
-		tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
+	error = tw_setfeature(tw_dev, 2, 1, &c);
+	if (error) {
+		printk(KERN_WARNING "3w-xxxx: Unable to set features for card, probable old firmware or card.\n");
 	}
 
-	command_packet->byte8.param.sgl[0].address = param_value;
-	command_packet->byte8.param.sgl[0].length = sizeof(TW_Sector);
-
-	command_packet->byte0.sgl_offset = 2;
-	command_packet->size = 4;
-	command_packet->request_id = request_id;
-	command_packet->byte3.host_id = 0;
-	command_packet->status = 0;
-	command_packet->flags = 0;
-	command_packet->byte6.parameter_count = 1;
-
-	/* Now try to post the command to the board */
-	tw_post_command_packet(tw_dev, request_id);
-
 	return 0;
-} /* End tw_ioctl() */
+} /* End tw_reset_sequence() */
 
-/* This function is called by the isr to complete ioctl requests */
-int tw_ioctl_complete(TW_Device_Extension *tw_dev, int request_id)
+/* This function will initialize the fields of a device extension */
+static int tw_initialize_device_extension(TW_Device_Extension *tw_dev)
 {
-	unsigned char *param_data;
-	unsigned char *buff;
-	TW_Param *param;
-	TW_Ioctl *ioctl = NULL;
-	TW_Passthru *passthru = NULL;
-	TW_Command *command_packet;
+	int i, error=0;
 
-	ioctl = (TW_Ioctl *)tw_dev->srb[request_id]->request_buffer;
-	dprintk(KERN_NOTICE "3w-xxxx: tw_ioctl_complete()\n");
-	buff = tw_dev->srb[request_id]->request_buffer;
-	if (buff == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_ioctl_complete(): Request buffer NULL.\n");
+	dprintk(KERN_NOTICE "3w-xxxx: tw_initialize_device_extension()\n");
+
+	/* Initialize command packet buffers */
+	error = tw_allocate_memory(tw_dev, sizeof(TW_Command), 0);
+	if (error) {
+		printk(KERN_WARNING "3w-xxxx: Command packet memory allocation failed.\n");
 		return 1;
 	}
 
-	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
-	if (command_packet == NULL) {
-		printk(KERN_WARNING "3w-xxxx: scsi%d: tw_ioctl_complete(): Bad command packet virtual address.\n", tw_dev->host->host_no);
+	/* Initialize generic buffer */
+	error = tw_allocate_memory(tw_dev, sizeof(TW_Sector), 1);
+	if (error) {
+		printk(KERN_WARNING "3w-xxxx: Generic memory allocation failed.\n");
 		return 1;
 	}
 
-	dprintk(KERN_NOTICE "3w-xxxx: tw_ioctl_complete(): Request_bufflen = %d\n", tw_dev->srb[request_id]->request_bufflen);
-
-	ioctl = (TW_Ioctl *)buff;
-	switch (ioctl->opcode) {
-		case TW_ATA_PASSTHRU:
-			passthru = (TW_Passthru *)ioctl->data;
-			/* Don't return data for non-data ATA cmds */
-			if ((passthru->param != 0) && (passthru->param != 0x8))
-				memcpy(buff, tw_dev->alignment_virtual_address[request_id], passthru->sector_count * 512);
-			else {
-				/* For non-data cmds, return cmd pkt */
-				if (tw_dev->srb[request_id]->request_bufflen >= sizeof(TW_Command))
-					memcpy(buff, tw_dev->command_packet_virtual_address[request_id], sizeof(TW_Command));
-			}
-			break;
-		case TW_CMD_PACKET_WITH_DATA:
-			dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_complete(): caught TW_CMD_PACKET_WITH_DATA.\n");
-			clear_bit(TW_IN_IOCTL, &tw_dev->flags);
-			return TW_ISR_DONT_COMPLETE; /* Special case for isr to not complete io */
-		default:
-			memset(buff, 0, tw_dev->srb[request_id]->request_bufflen);
-			param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
-			if (param == NULL) {
-				printk(KERN_WARNING "3w-xxxx: tw_ioctl_complete(): Bad alignment virtual address.\n");
-				return 1;
-			}
-			param_data = &(param->data[0]);
-			memcpy(buff, param_data, tw_dev->ioctl_size[request_id]);
+	for (i=0;i<TW_Q_LENGTH;i++) {
+		tw_dev->free_queue[i] = i;
+		tw_dev->state[i] = TW_S_INITIAL;
 	}
+
+	tw_dev->pending_head = TW_Q_START;
+	tw_dev->pending_tail = TW_Q_START;
+	tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
+
+	init_MUTEX(&tw_dev->ioctl_sem);
+	init_waitqueue_head(&tw_dev->ioctl_wqueue);
+
 	return 0;
-} /* End tw_ioctl_complete() */
+} /* End tw_initialize_device_extension() */
 
-static int tw_map_scsi_sg_data(struct pci_dev *pdev, Scsi_Cmnd *cmd)
+static int tw_map_scsi_sg_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 {
 	int use_sg;
-	int dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
 
 	dprintk(KERN_WARNING "3w-xxxx: tw_map_scsi_sg_data()\n");
 	
 	if (cmd->use_sg == 0)
 		return 0;
 
-	use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, dma_dir);
+	use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, DMA_BIDIRECTIONAL);
 	
 	if (use_sg == 0) {
 		printk(KERN_WARNING "3w-xxxx: tw_map_scsi_sg_data(): pci_map_sg() failed.\n");
 		return 0;
 	}
 
-	cmd->SCp.phase = 2;
+	cmd->SCp.phase = TW_PHASE_SGLIST;
 	cmd->SCp.have_data_in = use_sg;
 	
 	return use_sg;
 } /* End tw_map_scsi_sg_data() */
 
-static u32 tw_map_scsi_single_data(struct pci_dev *pdev, Scsi_Cmnd *cmd)
+static u32 tw_map_scsi_single_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 {
 	dma_addr_t mapping;
-	int dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
 
 	dprintk(KERN_WARNING "3w-xxxx: tw_map_scsi_single_data()\n");
 
 	if (cmd->request_bufflen == 0)
 		return 0;
 
-	mapping = pci_map_page(pdev, virt_to_page(cmd->request_buffer), offset_in_page(cmd->request_buffer), cmd->request_bufflen, dma_dir);
+	mapping = pci_map_page(pdev, virt_to_page(cmd->request_buffer), offset_in_page(cmd->request_buffer), cmd->request_bufflen, DMA_BIDIRECTIONAL);
 
 	if (mapping == 0) {
 		printk(KERN_WARNING "3w-xxxx: tw_map_scsi_single_data(): pci_map_page() failed.\n");
 		return 0;
 	}
 
-	cmd->SCp.phase = 1;
+	cmd->SCp.phase = TW_PHASE_SINGLE;
 	cmd->SCp.have_data_in = mapping;
 
 	return mapping;
 } /* End tw_map_scsi_single_data() */
 
-/* This function will mask the command interrupt */
-void tw_mask_command_interrupt(TW_Device_Extension *tw_dev)
-{
-	u32 control_reg_addr, control_reg_value;
-	
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = TW_CONTROL_MASK_COMMAND_INTERRUPT;
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_mask_command_interrupt() */
-
-/* This function will poll the status register for a flag */
-int tw_poll_status(TW_Device_Extension *tw_dev, u32 flag, int seconds)
+static void tw_unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 {
-	u32 status_reg_addr, status_reg_value;
-	struct timeval before, timeout;
-
-	status_reg_addr = tw_dev->registers.status_reg_addr;
-	do_gettimeofday(&before);
-	status_reg_value = inl(status_reg_addr);
-
-	if (tw_check_bits(status_reg_value)) {
-		dprintk(KERN_WARNING "3w-xxxx: tw_poll_status(): Unexpected bits.\n");
-		tw_decode_bits(tw_dev, status_reg_value, 0);
-	}
-		
-	while ((status_reg_value & flag) != flag) {
-		status_reg_value = inl(status_reg_addr);
-
-		if (tw_check_bits(status_reg_value)) {
-			dprintk(KERN_WARNING "3w-xxxx: tw_poll_status(): Unexpected bits.\n");
-			tw_decode_bits(tw_dev, status_reg_value, 0);
-		}
-
-		do_gettimeofday(&timeout);
-		if (before.tv_sec + seconds < timeout.tv_sec) { 
-			dprintk(KERN_WARNING "3w-xxxx: tw_poll_status(): Flag 0x%x not found.\n", flag);
-			return 1;
-		}
-		mdelay(5);
-	}
-	return 0;
-} /* End tw_poll_status() */
-
-/* This function will poll the status register for disappearance of a flag */
-int tw_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds)
-{
-	u32 status_reg_addr, status_reg_value;
-	struct timeval before, timeout;
-
-	status_reg_addr = tw_dev->registers.status_reg_addr;
-	do_gettimeofday(&before);
-	status_reg_value = inl(status_reg_addr);
-
-	if (tw_check_bits(status_reg_value)) {
-		dprintk(KERN_WARNING "3w-xxxx: tw_poll_status_gone(): Unexpected bits.\n");
-		tw_decode_bits(tw_dev, status_reg_value, 0);
-	}
-
-	while ((status_reg_value & flag) != 0) {
-		status_reg_value = inl(status_reg_addr);
-
-		if (tw_check_bits(status_reg_value)) {
-			dprintk(KERN_WARNING "3w-xxxx: tw_poll_status_gone(): Unexpected bits.\n");
-			tw_decode_bits(tw_dev, status_reg_value, 0);
-		}
-
-		do_gettimeofday(&timeout);
-		if (before.tv_sec + seconds < timeout.tv_sec) {
-			dprintk(KERN_WARNING "3w-xxxx: tw_poll_status_gone(): Flag 0x%x never disappeared.\n", flag);
-			return 1;
-		}
-		mdelay(5);
-	}
-	return 0;
-} /* End tw_poll_status_gone() */
-
-/* This function will attempt to post a command packet to the board */
-int tw_post_command_packet(TW_Device_Extension *tw_dev, int request_id)
-{
-	u32 status_reg_addr, status_reg_value;
-	unsigned long command_que_value;
-	u32 command_que_addr;
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_post_command_packet()\n");
-	command_que_addr = tw_dev->registers.command_que_addr;
-	command_que_value = tw_dev->command_packet_physical_address[request_id];
-	status_reg_addr = tw_dev->registers.status_reg_addr;
-	status_reg_value = inl(status_reg_addr);
-
-	if (tw_check_bits(status_reg_value)) {
-		dprintk(KERN_WARNING "3w-xxxx: tw_post_command_packet(): Unexpected bits.\n");
-		tw_decode_bits(tw_dev, status_reg_value, 1);
-	}
+	dprintk(KERN_WARNING "3w-xxxx: tw_unmap_scsi_data()\n");
 
-	if ((status_reg_value & TW_STATUS_COMMAND_QUEUE_FULL) == 0) {
-		/* We successfully posted the command packet */
-		outl(command_que_value, command_que_addr);
-		tw_dev->state[request_id] = TW_S_POSTED;
-		tw_dev->posted_request_count++;
-		if (tw_dev->posted_request_count > tw_dev->max_posted_request_count) {
-			tw_dev->max_posted_request_count = tw_dev->posted_request_count;
-		}
-	} else {
-		/* Couldn't post the command packet, so we do it in the isr */
-		if (tw_dev->state[request_id] != TW_S_PENDING) {
-			tw_dev->state[request_id] = TW_S_PENDING;
-			tw_dev->pending_request_count++;
-			if (tw_dev->pending_request_count > tw_dev->max_pending_request_count) {
-				tw_dev->max_pending_request_count = tw_dev->pending_request_count;
-			}
-			tw_dev->pending_queue[tw_dev->pending_tail] = request_id;
-			if (tw_dev->pending_tail == TW_Q_LENGTH-1) {
-				tw_dev->pending_tail = TW_Q_START;
-			} else {
-				tw_dev->pending_tail = tw_dev->pending_tail + 1;
-			}
-		} 
-		tw_unmask_command_interrupt(tw_dev);
-		return 1;
+	switch(cmd->SCp.phase) {
+		case TW_PHASE_SINGLE:
+			pci_unmap_page(pdev, cmd->SCp.have_data_in, cmd->request_bufflen, DMA_BIDIRECTIONAL);
+			break;
+		case TW_PHASE_SGLIST:
+			pci_unmap_sg(pdev, cmd->request_buffer, cmd->use_sg, DMA_BIDIRECTIONAL);
+			break;
 	}
-	return 0;
-} /* End tw_post_command_packet() */
+} /* End tw_unmap_scsi_data() */
 
 /* This function will reset a device extension */
-int tw_reset_device_extension(TW_Device_Extension *tw_dev) 
+static int tw_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset) 
 {
-	int imax = 0;
 	int i = 0;
-	Scsi_Cmnd *srb;
+	struct scsi_cmnd *srb;
+	unsigned long flags = 0;
 
 	dprintk(KERN_NOTICE "3w-xxxx: tw_reset_device_extension()\n");
-	imax = TW_Q_LENGTH;
 
-	if (tw_reset_sequence(tw_dev)) {
-		printk(KERN_WARNING "3w-xxxx: scsi%d: Reset sequence failed.\n", tw_dev->host->host_no);
-		return 1;
-	}
+	set_bit(TW_IN_RESET, &tw_dev->flags);
+	TW_DISABLE_INTERRUPTS(tw_dev);
+	TW_MASK_COMMAND_INTERRUPT(tw_dev);
+	spin_lock_irqsave(tw_dev->host->host_lock, flags);
 
 	/* Abort all requests that are in progress */
-	for (i=0;i<imax;i++) {
+	for (i=0;i<TW_Q_LENGTH;i++) {
 		if ((tw_dev->state[i] != TW_S_FINISHED) && 
 		    (tw_dev->state[i] != TW_S_INITIAL) &&
 		    (tw_dev->state[i] != TW_S_COMPLETED)) {
@@ -2307,7 +1382,7 @@
 	}
 
 	/* Reset queues and counts */
-	for (i=0;i<imax;i++) {
+	for (i=0;i<TW_Q_LENGTH;i++) {
 		tw_dev->free_queue[i] = i;
 		tw_dev->state[i] = TW_S_INITIAL;
 	}
@@ -2318,61 +1393,28 @@
 	tw_dev->pending_head = TW_Q_START;
 	tw_dev->pending_tail = TW_Q_START;
 	tw_dev->reset_print = 0;
-	tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
-
-	return 0;
-} /* End tw_reset_device_extension() */
-
-/* This function will reset a controller */
-int tw_reset_sequence(TW_Device_Extension *tw_dev) 
-{
-	int error = 0;
-	int tries = 0;
-
-	/* Disable interrupts */
-	tw_disable_interrupts(tw_dev);
-
-	/* Reset the board */
-	while (tries < TW_MAX_RESET_TRIES) {
-		tw_soft_reset(tw_dev);
 
-		error = tw_aen_drain_queue(tw_dev);
-		if (error) {
-			printk(KERN_WARNING "3w-xxxx: scsi%d: AEN drain failed, retrying.\n", tw_dev->host->host_no);
-			tries++;
-			continue;
-		}
-
-		/* Check for controller errors */
-		if (tw_check_errors(tw_dev)) {
-			printk(KERN_WARNING "3w-xxxx: scsi%d: Controller errors found, retrying.\n", tw_dev->host->host_no);
-			tries++;
-			continue;
-		}
-
-		/* Now the controller is in a good state */
-		break;
-	}
+	spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
 
-	if (tries >= TW_MAX_RESET_TRIES) {
-		printk(KERN_WARNING "3w-xxxx: scsi%d: Controller errors, card not responding, check all cabling.\n", tw_dev->host->host_no);
+	if (tw_reset_sequence(tw_dev)) {
+		printk(KERN_WARNING "3w-xxxx: scsi%d: Reset sequence failed.\n", tw_dev->host->host_no);
 		return 1;
 	}
+	TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
 
-	error = tw_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS);
-	if (error) {
-		printk(KERN_WARNING "3w-xxxx: scsi%d: Connection initialization failed.\n", tw_dev->host->host_no);
-		return 1;
+	/* Wake up any ioctl that was pending before the reset */
+	if ((tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE) || (ioctl_reset)) {
+		clear_bit(TW_IN_RESET, &tw_dev->flags);
+	} else {
+		tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
+		wake_up(&tw_dev->ioctl_wqueue);
 	}
 
-	/* Re-enable interrupts */
-	tw_enable_and_clear_interrupts(tw_dev);
-
 	return 0;
-} /* End tw_reset_sequence() */
+} /* End tw_reset_device_extension() */
 
 /* This funciton returns unit geometry in cylinders/heads/sectors */
-int tw_scsi_biosparam(struct scsi_device *sdev, struct block_device *bdev,
+static int tw_scsi_biosparam(struct scsi_device *sdev, struct block_device *bdev,
 		sector_t capacity, int geom[]) 
 {
 	int heads, sectors, cylinders;
@@ -2383,12 +1425,12 @@
 
 	heads = 64;
 	sectors = 32;
-	cylinders = (unsigned long)capacity / (heads * sectors);
+	cylinders = sector_div(capacity, heads * sectors);
 
 	if (capacity >= 0x200000) {
 		heads = 255;
 		sectors = 63;
-		cylinders = (unsigned long)capacity / (heads * sectors);
+		cylinders = sector_div(capacity, heads * sectors);
 	}
 
 	dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_biosparam(): heads = %d, sectors = %d, cylinders = %d\n", heads, sectors, cylinders);
@@ -2399,347 +1441,52 @@
 	return 0;
 } /* End tw_scsi_biosparam() */
 
-/* This function will find and initialize any cards */
-int tw_scsi_detect(Scsi_Host_Template *tw_host)
-{
-	int ret;
-	
-	dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_detect()\n");
-
-	printk(KERN_WARNING "3ware Storage Controller device driver for Linux v%s.\n", tw_driver_version);
-
-	ret = tw_findcards(tw_host);
-
-	return ret;
-} /* End tw_scsi_detect() */
-
-/* This is the new scsi eh abort function */
-int tw_scsi_eh_abort(Scsi_Cmnd *SCpnt) 
-{
-	TW_Device_Extension *tw_dev=NULL;
-	int i = 0;
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_eh_abort()\n");
-
-	if (!SCpnt) {
-		printk(KERN_WARNING "3w-xxxx: tw_scsi_eh_abort(): Invalid Scsi_Cmnd.\n");
-		return (FAILED);
-	}
-
-	tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
-	if (tw_dev == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_scsi_eh_abort(): Invalid device extension.\n");
-		return (FAILED);
-	}
-
-	spin_lock(&tw_dev->tw_lock);
-	tw_dev->num_aborts++;
-
-	/* If the command hasn't been posted yet, we can do the abort */
-	for (i=0;i<TW_Q_LENGTH;i++) {
-		if (tw_dev->srb[i] == SCpnt) {
-			if (tw_dev->state[i] == TW_S_STARTED) {
-				printk(KERN_WARNING "3w-xxxx: scsi%d: Unit #%d: Command (%p) timed out.\n", tw_dev->host->host_no, tw_dev->srb[i]==0 ? 0 : tw_dev->srb[i]->device->id, SCpnt);
-				tw_dev->state[i] = TW_S_COMPLETED;
-				tw_state_request_finish(tw_dev, i);
-				spin_unlock(&tw_dev->tw_lock);
-				return (SUCCESS);
-			}
-			if (tw_dev->state[i] == TW_S_PENDING) {
-				printk(KERN_WARNING "3w-xxxx: scsi%d: Unit #%d: Command (%p) timed out.\n", tw_dev->host->host_no, tw_dev->srb[i]==0 ? 0 : tw_dev->srb[i]->device->id, SCpnt);
-				if (tw_dev->pending_head == TW_Q_LENGTH-1) {
-					tw_dev->pending_head = TW_Q_START;
-				} else {
-					tw_dev->pending_head = tw_dev->pending_head + 1;
-				}
-				tw_dev->pending_request_count--;
-				tw_dev->state[i] = TW_S_COMPLETED;
-				tw_state_request_finish(tw_dev, i);
-				spin_unlock(&tw_dev->tw_lock);
-				return (SUCCESS);
-			}
-			if (tw_dev->state[i] == TW_S_POSTED) {
-				/* If the command has already been posted, we have to reset the card */
-				printk(KERN_WARNING "3w-xxxx: scsi%d: Unit #%d: Command (%p) timed out, resetting card.\n", tw_dev->host->host_no, tw_dev->srb[i]==0 ? 0 : tw_dev->srb[i]->device->id, SCpnt);
-				/* We have to let AEN requests through before the reset */
-				spin_unlock(&tw_dev->tw_lock);
-				spin_unlock_irq(tw_dev->host->host_lock);
-				mdelay(TW_AEN_WAIT_TIME);
-				spin_lock_irq(tw_dev->host->host_lock);
-				spin_lock(&tw_dev->tw_lock);
-
-				if (tw_reset_device_extension(tw_dev)) {
-					dprintk(KERN_WARNING "3w-xxxx: tw_scsi_eh_abort(): Reset failed for card %d.\n", tw_dev->host->host_no);
-					spin_unlock(&tw_dev->tw_lock);
-					return (FAILED);
-				}
-			}
-		}
-	}
-
-	spin_unlock(&tw_dev->tw_lock);
-	return (SUCCESS);
-} /* End tw_scsi_eh_abort() */
-
 /* This is the new scsi eh reset function */
-int tw_scsi_eh_reset(Scsi_Cmnd *SCpnt) 
+static int tw_scsi_eh_reset(struct scsi_cmnd *SCpnt) 
 {
 	TW_Device_Extension *tw_dev=NULL;
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_eh_reset()\n");
-
-	if (!SCpnt) {
-		printk(KERN_WARNING "3w-xxxx: tw_scsi_eh_reset(): Invalid Scsi_Cmnd.\n");
-		return (FAILED);
-	}
+	int retval = FAILED;
 
 	tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
-	if (tw_dev == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_scsi_eh_reset(): Invalid device extension.\n");
-		return (FAILED);
-	}
 
-	/* We have to let AEN requests through before the reset */
 	spin_unlock_irq(tw_dev->host->host_lock);
-	mdelay(TW_AEN_WAIT_TIME);
-	spin_lock_irq(tw_dev->host->host_lock);
 
-	spin_lock(&tw_dev->tw_lock);
 	tw_dev->num_resets++;
 
+	printk(KERN_WARNING "3w-xxxx: scsi%d: WARNING: Unit #%d: Command (0x%x) timed out, resetting card.\n", tw_dev->host->host_no, SCpnt->device->id, SCpnt->cmnd[0]);
+
 	/* Now reset the card and some of the device extension data */
-	if (tw_reset_device_extension(tw_dev)) {
+	if (tw_reset_device_extension(tw_dev, 0)) {
 		printk(KERN_WARNING "3w-xxxx: scsi%d: Reset failed.\n", tw_dev->host->host_no);
-		spin_unlock(&tw_dev->tw_lock);
-		return (FAILED);
+		goto out;
 	}
-	printk(KERN_WARNING "3w-xxxx: scsi%d: Reset succeeded.\n", tw_dev->host->host_no);
-	spin_unlock(&tw_dev->tw_lock);
 
-	return (SUCCESS);
+	retval = SUCCESS;
+out:
+	spin_lock_irq(tw_dev->host->host_lock);
+	return retval;
 } /* End tw_scsi_eh_reset() */
 
-/* This function handles input and output from /proc/scsi/3w-xxxx/x */
-int tw_scsi_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
-		      off_t offset, int length, int inout) 
-{
-	TW_Device_Extension *tw_dev = NULL;
-	TW_Info info;
-	int i;
-	int j;
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_proc_info()\n");
-
-	/* Find the correct device extension */
-	for (i=0;i<tw_device_extension_count;i++) 
-		if (tw_device_extension_list[i]->host->host_no == shost->host_no) 
-			tw_dev = tw_device_extension_list[i];
-	if (tw_dev == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_scsi_proc_info(): Couldn't locate device extension.\n");
-		return (-EINVAL);
-	}
-
-	info.buffer = buffer;
-	info.length = length;
-	info.offset = offset;
-	info.position = 0;
-	
-	if (inout) {
-		/* Write */
-		if (strncmp(buffer, "debug", 5) == 0) {
-			printk(KERN_INFO "3w-xxxx: Posted commands:\n");
-			for (j=0;j<TW_Q_LENGTH;j++) {
-				if (tw_dev->state[j] == TW_S_POSTED) {
-					TW_Command *command = (TW_Command *)tw_dev->command_packet_virtual_address[j];
-					printk(KERN_INFO "3w-xxxx: Request_id: %d\n", j);
-					printk(KERN_INFO "Opcode: 0x%x\n", command->byte0.opcode);
-					printk(KERN_INFO "Block_count: 0x%x\n", command->byte6.block_count);
-					printk(KERN_INFO "LBA: 0x%x\n", command->byte8.io.lba);
-					printk(KERN_INFO "Physical command packet addr: 0x%lx\n", tw_dev->command_packet_physical_address[j]);
-					printk(KERN_INFO "Scsi_Cmnd: %p\n", tw_dev->srb[j]);
-				}
-			}
-			printk(KERN_INFO "3w-xxxx: Free_head: %3d\n", tw_dev->free_head);
-			printk(KERN_INFO "3w-xxxx: Free_tail: %3d\n", tw_dev->free_tail);
-		} 
-		return length;
-	} else {
-		/* Read */
-		if (start) {
-			*start = buffer;
-		}
-		tw_copy_info(&info, "scsi%d: 3ware Storage Controller\n", shost->host_no);
-		tw_copy_info(&info, "Driver version: %s\n", tw_driver_version);
-		tw_copy_info(&info, "Current commands posted:       %3d\n", tw_dev->posted_request_count);
-		tw_copy_info(&info, "Max commands posted:           %3d\n", tw_dev->max_posted_request_count);
-		tw_copy_info(&info, "Current pending commands:      %3d\n", tw_dev->pending_request_count);
-		tw_copy_info(&info, "Max pending commands:          %3d\n", tw_dev->max_pending_request_count);
-		tw_copy_info(&info, "Last sgl length:               %3d\n", tw_dev->sgl_entries);
-		tw_copy_info(&info, "Max sgl length:                %3d\n", tw_dev->max_sgl_entries);
-		tw_copy_info(&info, "Last sector count:             %3d\n", tw_dev->sector_count);
-		tw_copy_info(&info, "Max sector count:              %3d\n", tw_dev->max_sector_count);
-		tw_copy_info(&info, "Resets:                        %3d\n", tw_dev->num_resets);
-		tw_copy_info(&info, "Aborts:                        %3d\n", tw_dev->num_aborts);
-		tw_copy_info(&info, "AEN's:                         %3d\n", tw_dev->aen_count);
-	}
-	if (info.position > info.offset) {
-		return (info.position - info.offset);
-	} else { 
-		return 0;
-	}
-} /* End tw_scsi_proc_info() */
-
-/* This is the main scsi queue function to handle scsi opcodes */
-int tw_scsi_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 
-{
-	unsigned char *command = SCpnt->cmnd;
-	int request_id = 0;
-	int error = 0;
-	TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
-
-	if (tw_dev == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_scsi_queue(): Invalid device extension.\n");
-		SCpnt->result = (DID_ERROR << 16);
-		done(SCpnt);
-		return 0;
-	}
-
-	spin_lock(&tw_dev->tw_lock);
-	dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue()\n");
-
-	/* Skip scsi command if it isn't for us */
-	if ((SCpnt->device->channel != 0) || (SCpnt->device->lun != 0)) {
-		SCpnt->result = (DID_BAD_TARGET << 16);
-		done(SCpnt);
-		spin_unlock(&tw_dev->tw_lock);
-		return 0;
-	}
-	
-	/* Save done function into Scsi_Cmnd struct */
-	SCpnt->scsi_done = done;
-		 
-	/* Queue the command and get a request id */
-	tw_state_request_start(tw_dev, &request_id);
-
-	/* Save the scsi command for use by the ISR */
-	tw_dev->srb[request_id] = SCpnt;
-
-	/* Initialize phase to zero */
-	SCpnt->SCp.phase = 0;
-
-	switch (*command) {
-		case READ_10:
-		case READ_6:
-		case WRITE_10:
-		case WRITE_6:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught READ/WRITE.\n");
-			error = tw_scsiop_read_write(tw_dev, request_id);
-			break;
-		case TEST_UNIT_READY:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught TEST_UNIT_READY.\n");
-			error = tw_scsiop_test_unit_ready(tw_dev, request_id);
-			break;
-		case INQUIRY:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught INQUIRY.\n");
-			error = tw_scsiop_inquiry(tw_dev, request_id);
-			break;
-		case READ_CAPACITY:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught READ_CAPACITY.\n");
-			error = tw_scsiop_read_capacity(tw_dev, request_id);
-			break;
-	        case REQUEST_SENSE:
-		        dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught REQUEST_SENSE.\n");
-		        error = tw_scsiop_request_sense(tw_dev, request_id);
-		        break;
-		case MODE_SENSE:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught MODE_SENSE.\n");
-			error = tw_scsiop_mode_sense(tw_dev, request_id);
-			break;
-		case SYNCHRONIZE_CACHE:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught SYNCHRONIZE_CACHE.\n");
-			error = tw_scsiop_synchronize_cache(tw_dev, request_id);
-			break;
-		case TW_IOCTL:
-			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught TW_SCSI_IOCTL.\n");
-			error = tw_ioctl(tw_dev, request_id);
-			break;
-		default:
-			printk(KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->host->host_no, *command);
-			tw_dev->state[request_id] = TW_S_COMPLETED;
-			tw_state_request_finish(tw_dev, request_id);
-			SCpnt->result = (DID_BAD_TARGET << 16);
-			done(SCpnt);
-	}
-	if (error) {
-		tw_dev->state[request_id] = TW_S_COMPLETED;
-		tw_state_request_finish(tw_dev, request_id);
-		SCpnt->result = (DID_ERROR << 16);
-		done(SCpnt);
-	}
-	spin_unlock(&tw_dev->tw_lock);
-
-	return 0;
-} /* End tw_scsi_queue() */
-
-/* This function will release the resources on an rmmod call */
-int tw_scsi_release(struct Scsi_Host *tw_host) 
-{
-	TW_Device_Extension *tw_dev;
-	tw_dev = (TW_Device_Extension *)tw_host->hostdata;
-
-	dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_release()\n");
-
-	/* Fake like we just shut down, so notify the card that
-	 * we "shut down cleanly".
-	 */
-	tw_halt(NULL, 0, NULL);  // parameters aren't actually used
-
-	/* Free up the IO region */
-	release_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE);
-
-	/* Free up the IRQ */
-	free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
-
-	/* Unregister character device */
-	if (twe_major >= 0) {
-		unregister_chrdev(twe_major, "twe");
-		twe_major = -1;
-	}
-
-	/* Free up device extension resources */
-	tw_free_device_extension(tw_dev);
-
-	/* Tell kernel scsi-layer we are gone */
-	scsi_unregister(tw_host);
-
-	return 0;
-} /* End tw_scsi_release() */
-
 /* This function handles scsi inquiry commands */
-int tw_scsiop_inquiry(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_inquiry(TW_Device_Extension *tw_dev, int request_id)
 {
 	TW_Param *param;
 	TW_Command *command_packet;
 	unsigned long command_que_value;
-	u32 command_que_addr;
 	unsigned long param_value;
 
 	dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_inquiry()\n");
 
 	/* Initialize command packet */
-	command_que_addr = tw_dev->registers.command_que_addr;
 	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
 	if (command_packet == NULL) {
 		printk(KERN_WARNING "3w-xxxx: tw_scsiop_inquiry(): Bad command packet virtual address.\n");
 		return 1;
 	}
 	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode = TW_OP_GET_PARAM;
-	command_packet->byte0.sgl_offset = 2;
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
 	command_packet->size = 4;
 	command_packet->request_id = request_id;
-	command_packet->byte3.unit = 0;
-	command_packet->byte3.host_id = 0;
 	command_packet->status = 0;
 	command_packet->flags = 0;
 	command_packet->byte6.parameter_count = 1;
@@ -2775,7 +1522,7 @@
 } /* End tw_scsiop_inquiry() */
 
 /* This function is called by the isr to complete an inquiry command */
-int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_id)
 {
 	unsigned char *is_unit_present;
 	unsigned char *request_buffer;
@@ -2796,7 +1543,7 @@
 	request_buffer[4] = 31;	       /* Additional length */
 	memcpy(&request_buffer[8], "3ware   ", 8);	 /* Vendor ID */
 	sprintf(&request_buffer[16], "Logical Disk %-2d ", tw_dev->srb[request_id]->device->id);
-	memcpy(&request_buffer[32], tw_driver_version, 3);
+	memcpy(&request_buffer[32], TW_DRIVER_VERSION, 3);
 
 	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
 	if (param == NULL) {
@@ -2806,9 +1553,9 @@
 	is_unit_present = &(param->data[0]);
 
 	if (is_unit_present[tw_dev->srb[request_id]->device->id] & TW_UNIT_ONLINE) {
-		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = TRUE;
+		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 1;
 	} else {
-		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = FALSE;
+		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 0;
 		tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16);
 		return TW_ISR_DONT_RESULT;
 	}
@@ -2817,7 +1564,7 @@
 } /* End tw_scsiop_inquiry_complete() */
 
 /* This function handles scsi mode_sense commands */
-int tw_scsiop_mode_sense(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_mode_sense(TW_Device_Extension *tw_dev, int request_id)
 {
 	TW_Param *param;
 	TW_Command *command_packet;
@@ -2844,12 +1591,9 @@
 
 	/* Setup the command packet */
 	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode = TW_OP_GET_PARAM;
-	command_packet->byte0.sgl_offset = 2;
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
 	command_packet->size = 4;
 	command_packet->request_id = request_id;
-	command_packet->byte3.unit = 0;
-	command_packet->byte3.host_id = 0;
 	command_packet->status = 0;
 	command_packet->flags = 0;
 	command_packet->byte6.parameter_count = 1;
@@ -2886,7 +1630,7 @@
 } /* End tw_scsiop_mode_sense() */
 
 /* This function is called by the isr to complete a mode sense command */
-int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int request_id)
 {
 	TW_Param *param;
 	unsigned char *flags;
@@ -2918,18 +1662,16 @@
 } /* End tw_scsiop_mode_sense_complete() */
 
 /* This function handles scsi read_capacity commands */
-int tw_scsiop_read_capacity(TW_Device_Extension *tw_dev, int request_id) 
+static int tw_scsiop_read_capacity(TW_Device_Extension *tw_dev, int request_id) 
 {
 	TW_Param *param;
 	TW_Command *command_packet;
 	unsigned long command_que_value;
-	u32 command_que_addr;
 	unsigned long param_value;
 
 	dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity()\n");
 
 	/* Initialize command packet */
-	command_que_addr = tw_dev->registers.command_que_addr;
 	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
 
 	if (command_packet == NULL) {
@@ -2937,12 +1679,10 @@
 		return 1;
 	}
 	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode = TW_OP_GET_PARAM;
-	command_packet->byte0.sgl_offset = 2;
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
 	command_packet->size = 4;
 	command_packet->request_id = request_id;
-	command_packet->byte3.unit = tw_dev->srb[request_id]->device->id;
-	command_packet->byte3.host_id = 0;
+	command_packet->unit__hostid = TW_UNITHOST_IN(0, tw_dev->srb[request_id]->device->id);
 	command_packet->status = 0;
 	command_packet->flags = 0;
 	command_packet->byte6.block_count = 1;
@@ -2979,7 +1719,7 @@
 } /* End tw_scsiop_read_capacity() */
 
 /* This function is called by the isr to complete a readcapacity command */
-int tw_scsiop_read_capacity_complete(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_read_capacity_complete(TW_Device_Extension *tw_dev, int request_id)
 {
 	unsigned char *param_data;
 	u32 capacity;
@@ -3025,14 +1765,13 @@
 } /* End tw_scsiop_read_capacity_complete() */
 
 /* This function handles scsi read or write commands */
-int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id) 
+static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id) 
 {
 	TW_Command *command_packet;
 	unsigned long command_que_value;
-	u32 command_que_addr = 0x0;
 	u32 lba = 0x0, num_sectors = 0x0, buffaddr = 0x0;
 	int i, use_sg;
-	Scsi_Cmnd *srb;
+	struct scsi_cmnd *srb;
 	struct scatterlist *sglist;
 
 	dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_read_write()\n");
@@ -3045,7 +1784,6 @@
 	srb = tw_dev->srb[request_id];
 
 	/* Initialize command packet */
-	command_que_addr = tw_dev->registers.command_que_addr;
 	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
 	if (command_packet == NULL) {
 		dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_read_write(): Bad command packet virtual address.\n");
@@ -3053,16 +1791,14 @@
 	}
 
 	if (srb->cmnd[0] == READ_6 || srb->cmnd[0] == READ_10) {
-		command_packet->byte0.opcode = TW_OP_READ;
+		command_packet->opcode__sgloffset = TW_OPSGL_IN(3, TW_OP_READ);
 	} else {
-		command_packet->byte0.opcode = TW_OP_WRITE;
+		command_packet->opcode__sgloffset = TW_OPSGL_IN(3, TW_OP_WRITE);
 	}
 
-	command_packet->byte0.sgl_offset = 3;
 	command_packet->size = 3;
 	command_packet->request_id = request_id;
-	command_packet->byte3.unit = srb->device->id;
-	command_packet->byte3.host_id = 0;
+	command_packet->unit__hostid = TW_UNITHOST_IN(0, srb->device->id);
 	command_packet->status = 0;
 	command_packet->flags = 0;
 
@@ -3131,7 +1867,7 @@
 } /* End tw_scsiop_read_write() */
 
 /* This function will handle the request sense scsi command */
-int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id)
 {
 	dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_request_sense()\n");
 
@@ -3148,7 +1884,7 @@
 } /* End tw_scsiop_request_sense() */
 
 /* This function will handle synchronize cache scsi command */
-int tw_scsiop_synchronize_cache(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_synchronize_cache(TW_Device_Extension *tw_dev, int request_id)
 {
 	TW_Command *command_packet;
 	unsigned long command_que_value;
@@ -3164,12 +1900,10 @@
 
 	/* Setup the command packet */
 	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode = TW_OP_FLUSH_CACHE;
-	command_packet->byte0.sgl_offset = 0;
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(0, TW_OP_FLUSH_CACHE);
 	command_packet->size = 2;
 	command_packet->request_id = request_id;
-	command_packet->byte3.unit = tw_dev->srb[request_id]->device->id;
-	command_packet->byte3.host_id = 0;
+	command_packet->unit__hostid = TW_UNITHOST_IN(0, tw_dev->srb[request_id]->device->id);
 	command_packet->status = 0;
 	command_packet->flags = 0;
 	command_packet->byte6.parameter_count = 1;
@@ -3186,30 +1920,25 @@
 } /* End tw_scsiop_synchronize_cache() */
 
 /* This function will handle test unit ready scsi command */
-int tw_scsiop_test_unit_ready(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_test_unit_ready(TW_Device_Extension *tw_dev, int request_id)
 {
 	TW_Param *param;
 	TW_Command *command_packet;
 	unsigned long command_que_value;
-	u32 command_que_addr;
 	unsigned long param_value;
 
 	dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_test_unit_ready()\n");
 
 	/* Initialize command packet */
-	command_que_addr = tw_dev->registers.command_que_addr;
 	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
 	if (command_packet == NULL) {
 		printk(KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad command packet virtual address.\n");
 		return 1;
 	}
 	memset(command_packet, 0, sizeof(TW_Sector));
-	command_packet->byte0.opcode = TW_OP_GET_PARAM;
-	command_packet->byte0.sgl_offset = 2;
+	command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
 	command_packet->size = 4;
 	command_packet->request_id = request_id;
-	command_packet->byte3.unit = 0;
-	command_packet->byte3.host_id = 0;
 	command_packet->status = 0;
 	command_packet->flags = 0;
 	command_packet->byte6.parameter_count = 1;
@@ -3245,7 +1974,7 @@
 } /* End tw_scsiop_test_unit_ready() */
 
 /* This function is called by the isr to complete a testunitready command */
-int tw_scsiop_test_unit_ready_complete(TW_Device_Extension *tw_dev, int request_id)
+static int tw_scsiop_test_unit_ready_complete(TW_Device_Extension *tw_dev, int request_id)
 {
 	unsigned char *is_unit_present;
 	TW_Param *param;
@@ -3260,9 +1989,9 @@
 	is_unit_present = &(param->data[0]);
 
 	if (is_unit_present[tw_dev->srb[request_id]->device->id] & TW_UNIT_ONLINE) {
-		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = TRUE;
+		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 1;
 	} else {
-		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = FALSE;
+		tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 0;
 		tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16);
 		return TW_ISR_DONT_RESULT;
 	}
@@ -3270,236 +1999,502 @@
 	return 0;
 } /* End tw_scsiop_test_unit_ready_complete() */
 
-/* Set a value in the features table */
-int tw_setfeature(TW_Device_Extension *tw_dev, int parm, int param_size,
-                  unsigned char *val)
+/* This is the main scsi queue function to handle scsi opcodes */
+static int tw_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 
 {
-	TW_Param *param;
-	TW_Command  *command_packet;
-	TW_Response_Queue response_queue;
+	unsigned char *command = SCpnt->cmnd;
 	int request_id = 0;
-	unsigned long command_que_value;
-	u32 command_que_addr;
-	u32 response_que_addr;
-	unsigned long param_value;
+	int retval = 1;
+	TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
 
-  	/* Initialize SetParam command packet */
-	if (tw_dev->command_packet_virtual_address[request_id] == NULL) {
-		printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet virtual address.\n");
-		return 1;
-	}
-	command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
-	memset(command_packet, 0, sizeof(TW_Sector));
-	param = (TW_Param *)tw_dev->alignment_virtual_address[request_id];
+	/* Save done function into Scsi_Cmnd struct */
+	SCpnt->scsi_done = done;
+		 
+	/* Queue the command and get a request id */
+	tw_state_request_start(tw_dev, &request_id);
 
-	command_packet->byte0.opcode = TW_OP_SET_PARAM;
-	command_packet->byte0.sgl_offset  = 2;
-	param->table_id = 0x404;  /* Features table */
-	param->parameter_id = parm;
-	param->parameter_size_bytes = param_size;
-	memcpy(param->data, val, param_size);
+	/* Save the scsi command for use by the ISR */
+	tw_dev->srb[request_id] = SCpnt;
 
-	param_value = tw_dev->alignment_physical_address[request_id];
-	if (param_value == 0) {
-		printk(KERN_WARNING "3w-xxxx: tw_ioctl(): Bad alignment physical address.\n");
+	/* Initialize phase to zero */
+	SCpnt->SCp.phase = TW_PHASE_INITIAL;
+
+	switch (*command) {
+		case READ_10:
+		case READ_6:
+		case WRITE_10:
+		case WRITE_6:
+			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught READ/WRITE.\n");
+			retval = tw_scsiop_read_write(tw_dev, request_id);
+			break;
+		case TEST_UNIT_READY:
+			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught TEST_UNIT_READY.\n");
+			retval = tw_scsiop_test_unit_ready(tw_dev, request_id);
+			break;
+		case INQUIRY:
+			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught INQUIRY.\n");
+			retval = tw_scsiop_inquiry(tw_dev, request_id);
+			break;
+		case READ_CAPACITY:
+			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught READ_CAPACITY.\n");
+			retval = tw_scsiop_read_capacity(tw_dev, request_id);
+			break;
+	        case REQUEST_SENSE:
+		        dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught REQUEST_SENSE.\n");
+		        retval = tw_scsiop_request_sense(tw_dev, request_id);
+		        break;
+		case MODE_SENSE:
+			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught MODE_SENSE.\n");
+			retval = tw_scsiop_mode_sense(tw_dev, request_id);
+			break;
+		case SYNCHRONIZE_CACHE:
+			dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught SYNCHRONIZE_CACHE.\n");
+			retval = tw_scsiop_synchronize_cache(tw_dev, request_id);
+			break;
+		case TW_IOCTL:
+			printk(KERN_WARNING "3w-xxxx: SCSI_IOCTL_SEND_COMMAND deprecated, please update your 3ware tools.\n");
+			break;
+		default:
+			printk(KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->host->host_no, *command);
+			tw_dev->state[request_id] = TW_S_COMPLETED;
+			tw_state_request_finish(tw_dev, request_id);
+			SCpnt->result = (DID_BAD_TARGET << 16);
+			done(SCpnt);
+			goto out;
+	}
+	if (retval) {
 		tw_dev->state[request_id] = TW_S_COMPLETED;
 		tw_state_request_finish(tw_dev, request_id);
-		tw_dev->srb[request_id]->result = (DID_OK << 16);
-		tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
+		SCpnt->result = (DID_ERROR << 16);
+		done(SCpnt);
+		retval = 0;
 	}
-	command_packet->byte8.param.sgl[0].address = param_value;
-	command_packet->byte8.param.sgl[0].length = sizeof(TW_Sector);
+out:
+	return retval;
+} /* End tw_scsi_queue() */
 
-	command_packet->size = 4;
-	command_packet->request_id = request_id;
-	command_packet->byte6.parameter_count = 1;
+/* This function is the interrupt service routine */
+static irqreturn_t tw_interrupt(int irq, void *dev_instance,
+		     struct pt_regs *regs) 
+{
+	int request_id;
+	u32 status_reg_value;
+	TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance;
+	TW_Response_Queue response_que;
+	int error = 0, retval = 0;
+	TW_Command *command_packet;
+	int handled = 0;
 
-  	command_que_value = tw_dev->command_packet_physical_address[request_id];
-	if (command_que_value == 0) {
-		printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet physical address.\n");
-	return 1;
-	}
-	command_que_addr = tw_dev->registers.command_que_addr;
-	response_que_addr = tw_dev->registers.response_que_addr;
+	/* Get the host lock for io completions */
+	spin_lock(tw_dev->host->host_lock);
 
-	/* Send command packet to the board */
-	outl(command_que_value, command_que_addr);
+	/* See if the interrupt matches this instance */
+	if (tw_dev->tw_pci_dev->irq == (unsigned int)irq) {
 
-	/* Poll for completion */
-	if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) {
-		response_queue.value = inl(response_que_addr);
-		request_id = (unsigned char)response_queue.u.response_id;
-		if (request_id != 0) {
-			/* unexpected request id */
-			printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Unexpected request id.\n");
-			return 1;
+		handled = 1;
+
+		/* Read the registers */
+		status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+
+		/* Check if this is our interrupt, otherwise bail */
+		if (!(status_reg_value & TW_STATUS_VALID_INTERRUPT))
+			goto tw_interrupt_bail;
+
+		/* Check controller for errors */
+		if (tw_check_bits(status_reg_value)) {
+			dprintk(KERN_WARNING "3w-xxxx: tw_interrupt(): Unexpected bits.\n");
+			if (tw_decode_bits(tw_dev, status_reg_value, 1)) {
+				TW_CLEAR_ALL_INTERRUPTS(tw_dev);
+				goto tw_interrupt_bail;
+			}
 		}
-		if (command_packet->status != 0) {
-			/* bad response */
-			tw_decode_sense(tw_dev, request_id, 0);
-			return 1;
+
+		/* Handle host interrupt */
+		if (status_reg_value & TW_STATUS_HOST_INTERRUPT) {
+			dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): Received host interrupt.\n");
+			TW_CLEAR_HOST_INTERRUPT(tw_dev);
 		}
-	}
 
-	return 0;
-} /* End tw_setfeature() */
+		/* Handle attention interrupt */
+		if (status_reg_value & TW_STATUS_ATTENTION_INTERRUPT) {
+			dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): Received attention interrupt.\n");
+			TW_CLEAR_ATTENTION_INTERRUPT(tw_dev);
+			tw_state_request_start(tw_dev, &request_id);
+			error = tw_aen_read_queue(tw_dev, request_id);
+			if (error) {
+				printk(KERN_WARNING "3w-xxxx: scsi%d: Error reading aen queue.\n", tw_dev->host->host_no);
+				tw_dev->state[request_id] = TW_S_COMPLETED;
+				tw_state_request_finish(tw_dev, request_id);
+			}
+		}
 
-/* This function will setup the interrupt handler */
-int tw_setup_irq(TW_Device_Extension *tw_dev)
-{
-	char *device = TW_DEVICE_NAME;
-	int error;
+		/* Handle command interrupt */
+		if (status_reg_value & TW_STATUS_COMMAND_INTERRUPT) {
+			/* Drain as many pending commands as we can */
+			while (tw_dev->pending_request_count > 0) {
+				request_id = tw_dev->pending_queue[tw_dev->pending_head];
+				if (tw_dev->state[request_id] != TW_S_PENDING) {
+					printk(KERN_WARNING "3w-xxxx: scsi%d: Found request id that wasn't pending.\n", tw_dev->host->host_no);
+					break;
+				}
+				if (tw_post_command_packet(tw_dev, request_id)==0) {
+					if (tw_dev->pending_head == TW_Q_LENGTH-1) {
+						tw_dev->pending_head = TW_Q_START;
+					} else {
+						tw_dev->pending_head = tw_dev->pending_head + 1;
+					}
+					tw_dev->pending_request_count--;
+				} else {
+					/* If we get here, we will continue re-posting on the next command interrupt */
+					break;
+				}
+			}
+			/* If there are no more pending requests, we mask command interrupt */
+			if (tw_dev->pending_request_count == 0) 
+				TW_MASK_COMMAND_INTERRUPT(tw_dev);
+		}
 
-	dprintk(KERN_NOTICE "3w-xxxx: tw_setup_irq()\n");
-	error = request_irq(tw_dev->tw_pci_dev->irq, tw_interrupt, SA_SHIRQ, device, tw_dev);
+		/* Handle response interrupt */
+		if (status_reg_value & TW_STATUS_RESPONSE_INTERRUPT) {
+			/* Drain the response queue from the board */
+			while ((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) {
+				/* Read response queue register */
+				response_que.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
+				request_id = TW_RESID_OUT(response_que.response_id);
+				command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id];
+				error = 0;
 
-	if (error < 0) {
-		printk(KERN_WARNING "3w-xxxx: scsi%d: Error requesting IRQ: %d.\n", tw_dev->host->host_no, tw_dev->tw_pci_dev->irq);
-		return 1;
+				/* Check for bad response */
+				if (command_packet->status != 0) {
+					/* If internal command, don't error, don't fill sense */
+					if (tw_dev->srb[request_id] == NULL) {
+						tw_decode_sense(tw_dev, request_id, 0);
+					} else {
+						error = tw_decode_sense(tw_dev, request_id, 1);
+					}
+				}
+
+				/* Check for correct state */
+				if (tw_dev->state[request_id] != TW_S_POSTED) {
+					if (tw_dev->srb[request_id] != NULL) {
+						printk(KERN_WARNING "3w-xxxx: scsi%d: Received a request id that wasn't posted.\n", tw_dev->host->host_no);
+						error = 1;
+					}
+				}
+
+				dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): Response queue request id: %d.\n", request_id);
+
+				/* Check for internal command completion */
+				if (tw_dev->srb[request_id] == NULL) {
+					dprintk(KERN_WARNING "3w-xxxx: tw_interrupt(): Found internally posted command.\n");
+					/* Check for chrdev ioctl completion */
+					if (request_id != tw_dev->chrdev_request_id) {
+						retval = tw_aen_complete(tw_dev, request_id);
+						if (retval) {
+							printk(KERN_WARNING "3w-xxxx: scsi%d: Error completing aen.\n", tw_dev->host->host_no);
+						}
+					} else {
+						tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
+						wake_up(&tw_dev->ioctl_wqueue);
+					}
+				} else {
+				switch (tw_dev->srb[request_id]->cmnd[0]) {
+					case READ_10:
+					case READ_6:
+						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught READ_10/READ_6\n");
+						break;
+					case WRITE_10:
+					case WRITE_6:
+						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught WRITE_10/WRITE_6\n");
+						break;
+					case TEST_UNIT_READY:
+						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught TEST_UNIT_READY\n");
+						error = tw_scsiop_test_unit_ready_complete(tw_dev, request_id);
+						break;
+					case INQUIRY:
+						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught INQUIRY\n");
+						error = tw_scsiop_inquiry_complete(tw_dev, request_id);
+						break;
+					case READ_CAPACITY:
+						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught READ_CAPACITY\n");
+						error = tw_scsiop_read_capacity_complete(tw_dev, request_id);
+						break;
+					case MODE_SENSE:
+						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught MODE_SENSE\n");
+						error = tw_scsiop_mode_sense_complete(tw_dev, request_id);
+						break;
+					case SYNCHRONIZE_CACHE:
+						dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught SYNCHRONIZE_CACHE\n");
+						break;
+					default:
+						printk(KERN_WARNING "3w-xxxx: case slip in tw_interrupt()\n");
+						error = 1;
+					}
+
+					/* If no error command was a success */
+					if (error == 0) {
+						tw_dev->srb[request_id]->result = (DID_OK << 16);
+					}
+
+					/* If error, command failed */
+					if (error == 1) {
+						/* Ask for a host reset */
+						tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
+					}
+
+					/* Now complete the io */
+					if ((error != TW_ISR_DONT_COMPLETE)) {
+						tw_dev->state[request_id] = TW_S_COMPLETED;
+						tw_state_request_finish(tw_dev, request_id);
+						tw_dev->posted_request_count--;
+						tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
+
+						tw_unmap_scsi_data(tw_dev->tw_pci_dev, tw_dev->srb[request_id]);
+					}
+				}
+				
+				/* Check for valid status after each drain */
+				status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
+				if (tw_check_bits(status_reg_value)) {
+					dprintk(KERN_WARNING "3w-xxxx: tw_interrupt(): Unexpected bits.\n");
+					if (tw_decode_bits(tw_dev, status_reg_value, 1)) {
+						TW_CLEAR_ALL_INTERRUPTS(tw_dev);
+						goto tw_interrupt_bail;
+					}
+				}
+			}
+		}
 	}
-	return 0;
-} /* End tw_setup_irq() */
+tw_interrupt_bail:
+	spin_unlock(tw_dev->host->host_lock);
+	return IRQ_RETVAL(handled);
+} /* End tw_interrupt() */
 
-/* This function will tell the controller we're shutting down by sending
-   initconnection with a 1 */
-int tw_shutdown_device(TW_Device_Extension *tw_dev)
+/* This function tells the controller to shut down */
+static void __tw_shutdown(TW_Device_Extension *tw_dev)
 {
-	int error;
-
 	/* Disable interrupts */
-	tw_disable_interrupts(tw_dev);
+	TW_DISABLE_INTERRUPTS(tw_dev);
 
-	/* poke the board */
-	error = tw_initconnection(tw_dev, 1);
-	if (error) {
-		printk(KERN_WARNING "3w-xxxx: scsi%d: Connection shutdown failed.\n", tw_dev->host->host_no);
+	printk(KERN_WARNING "3w-xxxx: Shutting down host %d.\n", tw_dev->host->host_no);
+
+	/* Tell the card we are shutting down */
+	if (tw_initconnection(tw_dev, 1)) {
+		printk(KERN_WARNING "3w-xxxx: Connection shutdown failed.\n");
 	} else {
-		printk(KERN_NOTICE "3w-xxxx: Shutdown complete.\n");
+		printk(KERN_WARNING "3w-xxxx: Shutdown complete.\n");
 	}
 
-	/* Re-enable interrupts */
-	tw_enable_and_clear_interrupts(tw_dev);
+	/* Clear all interrupts just before exit */
+	TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
+} /* End __tw_shutdown() */
 
-	return 0;
-} /* End tw_shutdown_device() */
+/* Wrapper for __tw_shutdown */
+static void tw_shutdown(struct device *dev)
+{
+	struct Scsi_Host *host = pci_get_drvdata(to_pci_dev(dev));
+	TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
 
-/* This function will configure individual target parameters */
-int tw_slave_configure(Scsi_Device *SDptr)
+	__tw_shutdown(tw_dev);
+} /* End tw_shutdown() */
+
+static struct scsi_host_template driver_template = {
+	.module			= THIS_MODULE,
+	.name			= "3ware Storage Controller",
+	.queuecommand		= tw_scsi_queue,
+	.eh_host_reset_handler	= tw_scsi_eh_reset,
+	.bios_param		= tw_scsi_biosparam,
+	.can_queue		= TW_Q_LENGTH-2,
+	.this_id		= -1,
+	.sg_tablesize		= TW_MAX_SGL_LENGTH,
+	.max_sectors		= TW_MAX_SECTORS,
+	.cmd_per_lun		= TW_MAX_CMDS_PER_LUN,	
+	.use_clustering		= ENABLE_CLUSTERING,
+	.shost_attrs		= tw_host_attrs,
+	.sdev_attrs		= tw_dev_attrs,
+	.emulated		= 1
+};
+
+/* This function will probe and initialize a card */
+static int __devinit tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
 {
-	int max_cmds;
+	struct Scsi_Host *host = NULL;
+	TW_Device_Extension *tw_dev;
+	int retval = -ENODEV;
 
-	dprintk(KERN_WARNING "3w-xxxx: tw_slave_configure()\n");
+	retval = pci_enable_device(pdev);
+	if (retval) {
+		printk(KERN_WARNING "3w-xxxx: Failed to enable pci device.");
+		goto out_disable_device;
+	}
 
-	if (cmds_per_lun) {
-		max_cmds = cmds_per_lun;
-		if (max_cmds > TW_MAX_CMDS_PER_LUN)
-			max_cmds = TW_MAX_CMDS_PER_LUN;
-	} else {
-		max_cmds = TW_MAX_CMDS_PER_LUN;
+	pci_set_master(pdev);
+
+	retval = pci_set_dma_mask(pdev, TW_DMA_MASK);
+	if (retval) {
+		printk(KERN_WARNING "3w-xxxx: Failed to set dma mask.");
+		goto out_disable_device;
 	}
-	scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG, max_cmds);
 
-	return 0;
-} /* End tw_slave_configure() */
+	host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
+	if (!host) {
+		printk(KERN_WARNING "3w-xxxx: Failed to allocate memory for device extension.");
+		retval = -ENOMEM;
+		goto out_disable_device;
+	}
+	tw_dev = (TW_Device_Extension *)host->hostdata;
 
-/* This function will soft reset the controller */
-void tw_soft_reset(TW_Device_Extension *tw_dev) 
-{
-	u32 control_reg_addr, control_reg_value;
+	memset(tw_dev, 0, sizeof(TW_Device_Extension));
 
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = (	TW_CONTROL_ISSUE_SOFT_RESET |
-				TW_CONTROL_CLEAR_HOST_INTERRUPT |
-				TW_CONTROL_CLEAR_ATTENTION_INTERRUPT |
-				TW_CONTROL_MASK_COMMAND_INTERRUPT |
-				TW_CONTROL_MASK_RESPONSE_INTERRUPT |
-				TW_CONTROL_CLEAR_ERROR_STATUS | 
-				TW_CONTROL_DISABLE_INTERRUPTS);
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_soft_reset() */
+	/* Save values to device extension */
+	tw_dev->host = host;
+	tw_dev->tw_pci_dev = pdev;
 
-/* This function will free a request_id */
-int tw_state_request_finish(TW_Device_Extension *tw_dev, int request_id)
-{
-	dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_finish()\n");
-  
-	tw_dev->free_queue[tw_dev->free_tail] = request_id;
-	tw_dev->state[request_id] = TW_S_FINISHED;
-	if (tw_dev->free_tail == tw_dev->free_wrap)
-		tw_dev->free_tail = TW_Q_START;
-	else
-		tw_dev->free_tail++;
+	if (tw_initialize_device_extension(tw_dev)) {
+		printk(KERN_WARNING "3w-xxxx: Failed to initialize device extension.");
+		goto out_free_device_extension;
+	}
 
-	dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_finish(): Freeing request_id %d\n", request_id);
+	/* Request IO regions */
+	retval = pci_request_regions(pdev, "3w-xxxx");
+	if (retval) {
+		printk(KERN_WARNING "3w-xxxx: Failed to get mem region.");
+		goto out_free_device_extension;
+	}
 
-	return 0;
-} /* End tw_state_request_finish() */
+	/* Save base address */
+	tw_dev->base_addr = pci_resource_start(pdev, 0);
+	if (!tw_dev->base_addr) {
+		printk(KERN_WARNING "3w-xxxx: Failed to get io address.");
+		goto out_release_mem_region;
+	}
 
-/* This function will assign an available request_id */
-int tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id)
-{
-	int id = 0;
+	/* Disable interrupts on the card */
+	TW_DISABLE_INTERRUPTS(tw_dev);
 
-	dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_start()\n");
-	
-	/* Obtain next free request_id */
-	id = tw_dev->free_queue[tw_dev->free_head];
-	if (tw_dev->free_head == tw_dev->free_wrap)
-		tw_dev->free_head = TW_Q_START;
-	else
-		tw_dev->free_head++;
+	/* Initialize the card */
+	if (tw_reset_sequence(tw_dev))
+		goto out_release_mem_region;
+
+	/* Set host specific parameters */
+	host->max_id = TW_MAX_UNITS;
+	host->max_cmd_len = TW_MAX_CDB_LEN;
 
-	*request_id = id;
-	tw_dev->state[id] = TW_S_STARTED;
+	/* Luns and channels aren't supported by adapter */
+	host->max_lun = 0;
+	host->max_channel = 0;
 
-	dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_start(): id = %d.\n", id);
+	/* Register the card with the kernel SCSI layer */
+	retval = scsi_add_host(host, &pdev->dev);
+	if (retval) {
+		printk(KERN_WARNING "3w-xxxx: scsi add host failed");
+		goto out_release_mem_region;
+	}
+
+	pci_set_drvdata(pdev, host);
+
+	printk(KERN_WARNING "3w-xxxx: scsi%d: Found a 3ware Storage Controller at 0x%x, IRQ: %d.\n", host->host_no, tw_dev->base_addr, pdev->irq);
+
+	/* Now setup the interrupt handler */
+	retval = request_irq(pdev->irq, tw_interrupt, SA_SHIRQ, "3w-xxxx", tw_dev);
+	if (retval) {
+		printk(KERN_WARNING "3w-xxxx: Error requesting IRQ.");
+		goto out_remove_host;
+	}
+
+	tw_device_extension_list[tw_device_extension_count] = tw_dev;
+	tw_device_extension_count++;
+
+	/* Re-enable interrupts on the card */
+	TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
+
+	/* Finally, scan the host */
+	scsi_scan_host(host);
+
+	if (twe_major == -1) {
+		if ((twe_major = register_chrdev (0, "twe", &tw_fops)) < 0)
+			printk(KERN_WARNING "3w-xxxx: Failed to register character device.");
+	}
 	return 0;
-} /* End tw_state_request_start() */
 
-static void tw_unmap_scsi_data(struct pci_dev *pdev, Scsi_Cmnd *cmd)
+out_remove_host:
+	scsi_remove_host(host);
+out_release_mem_region:
+	pci_release_regions(pdev);
+out_free_device_extension:
+	tw_free_device_extension(tw_dev);
+	scsi_host_put(host);
+out_disable_device:
+	pci_disable_device(pdev);
+
+	return retval;
+} /* End tw_probe() */
+
+/* This function is called to remove a device */
+static void tw_remove(struct pci_dev *pdev)
 {
-	int dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
+	struct Scsi_Host *host = pci_get_drvdata(pdev);
+	TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
 
-	dprintk(KERN_WARNING "3w-xxxx: tw_unmap_scsi_data()\n");
+	scsi_remove_host(tw_dev->host);
 
-	switch(cmd->SCp.phase) {
-		case 1:
-			pci_unmap_page(pdev, cmd->SCp.have_data_in, cmd->request_bufflen, dma_dir);
-			break;
-		case 2:
-			pci_unmap_sg(pdev, cmd->request_buffer, cmd->use_sg, dma_dir);
-			break;
+	__tw_shutdown(tw_dev);
+
+	/* Free up the IRQ */
+	free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
+
+	/* Free up the mem region */
+	pci_release_regions(pdev);
+
+	/* Free up device extension resources */
+	tw_free_device_extension(tw_dev);
+
+	/* Unregister character device */
+	if (twe_major >= 0) {
+		unregister_chrdev(twe_major, "twe");
+		twe_major = -1;
 	}
-} /* End tw_unmap_scsi_data() */
 
-/* This function will unmask the command interrupt on the controller */
-void tw_unmask_command_interrupt(TW_Device_Extension *tw_dev)
-{
-	u32 control_reg_addr, control_reg_value;
+	scsi_host_put(tw_dev->host);
+	pci_disable_device(pdev);
+	tw_device_extension_count--;
+} /* End tw_remove() */
+
+/* PCI Devices supported by this driver */
+static struct pci_device_id tw_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_1000,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_7000,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ }
+};
+MODULE_DEVICE_TABLE(pci, tw_pci_tbl);
 
-	control_reg_addr = tw_dev->registers.control_reg_addr;
-	control_reg_value = TW_CONTROL_UNMASK_COMMAND_INTERRUPT;
-	outl(control_reg_value, control_reg_addr);
-} /* End tw_unmask_command_interrupt() */
-
-static Scsi_Host_Template driver_template = {
-	.proc_name		= "3w-xxxx",
-	.proc_info		= tw_scsi_proc_info,
-	.name			= "3ware Storage Controller",
-	.detect			= tw_scsi_detect,
-	.release		= tw_scsi_release,
-	.queuecommand		= tw_scsi_queue,
-	.eh_abort_handler	= tw_scsi_eh_abort,
-	.eh_host_reset_handler	= tw_scsi_eh_reset,
-	.bios_param		= tw_scsi_biosparam,
-	.slave_configure	= tw_slave_configure,
-	.can_queue		= TW_Q_LENGTH-2,
-	.this_id		= -1,
-	.sg_tablesize		= TW_MAX_SGL_LENGTH,
-	.max_sectors		= TW_MAX_SECTORS,
-	.cmd_per_lun		= TW_MAX_CMDS_PER_LUN,	
-	.use_clustering		= ENABLE_CLUSTERING,
-	.emulated		= 1
+/* pci_driver initializer */
+static struct pci_driver tw_driver = {
+	.name		= "3w-xxxx",
+	.id_table	= tw_pci_tbl,
+	.probe		= tw_probe,
+	.remove		= tw_remove,
+	.driver		= {
+		.shutdown = tw_shutdown
+	}
 };
-#include "scsi_module.c"
+
+/* This function is called on driver initialization */
+static int __init tw_init(void)
+{
+	printk(KERN_WARNING "3ware Storage Controller device driver for Linux v%s.\n", TW_DRIVER_VERSION);
+
+	return pci_module_init(&tw_driver);
+} /* End tw_init() */
+
+/* This function is called on driver exit */
+static void __exit tw_exit(void)
+{
+	pci_unregister_driver(&tw_driver);
+} /* End tw_exit() */
+
+module_init(tw_init);
+module_exit(tw_exit);
 
diff -Nru a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h
--- a/drivers/scsi/3w-xxxx.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/3w-xxxx.h	2004-12-24 13:36:31 -08:00
@@ -180,7 +180,6 @@
 #define TW_OP_AEN_LISTEN      0x1c
 #define TW_OP_FLUSH_CACHE     0x0e
 #define TW_CMD_PACKET         0x1d
-#define TW_ATA_PASSTHRU       0x1e
 #define TW_CMD_PACKET_WITH_DATA 0x1f
 
 /* Asynchronous Event Notification (AEN) Codes */
@@ -197,6 +196,11 @@
 #define TW_AEN_SMART_FAIL        0x000F
 #define TW_AEN_SBUF_FAIL         0x0024
 
+/* Phase defines */
+#define TW_PHASE_INITIAL 0
+#define TW_PHASE_SINGLE 1
+#define TW_PHASE_SGLIST 2
+
 /* Misc defines */
 #define TW_ALIGNMENT_6000		      64 /* 64 bytes */
 #define TW_ALIGNMENT_7000                     4  /* 4 bytes */
@@ -207,7 +211,6 @@
 #define TW_POLL_MAX_RETRIES        	      20000
 #define TW_MAX_SGL_LENGTH		      62
 #define TW_ATA_PASS_SGL_MAX                   60
-#define TW_MAX_PASSTHRU_BYTES                 4096
 #define TW_Q_LENGTH			      256
 #define TW_Q_START			      0
 #define TW_MAX_SLOT			      32
@@ -221,7 +224,7 @@
 #define TW_IOCTL                              0x80
 #define TW_UNIT_ONLINE                        1
 #define TW_IN_INTR                            1
-#define TW_IN_IOCTL                           2
+#define TW_IN_RESET                           2
 #define TW_IN_CHRDEV_IOCTL                    3
 #define TW_MAX_SECTORS                        256
 #define TW_AEN_WAIT_TIME                      1000
@@ -231,8 +234,41 @@
 #define TW_IOCTL_TIMEOUT                      25 /* 25 seconds */
 #define TW_IOCTL_CHRDEV_TIMEOUT               60 /* 60 seconds */
 #define TW_IOCTL_CHRDEV_FREE                  -1
+#define TW_DMA_MASK			      DMA_32BIT_MASK
+#define TW_MAX_CDB_LEN			      16
+
+/* Bitmask macros to eliminate bitfields */
+
+/* opcode: 5, sgloffset: 3 */
+#define TW_OPSGL_IN(x,y) ((x << 5) | (y & 0x1f))
+#define TW_SGL_OUT(x) ((x >> 5) & 0x7)
+
+/* reserved_1: 4, response_id: 8, reserved_2: 20 */
+#define TW_RESID_OUT(x) ((x >> 4) & 0xff)
+
+/* unit: 4, host_id: 4 */
+#define TW_UNITHOST_IN(x,y) ((x << 4) | ( y & 0xf))
+#define TW_UNIT_OUT(x) (x & 0xf)
 
 /* Macros */
+#define TW_CONTROL_REG_ADDR(x) (x->base_addr)
+#define TW_STATUS_REG_ADDR(x) (x->base_addr + 0x4)
+#define TW_COMMAND_QUEUE_REG_ADDR(x) (x->base_addr + 0x8)
+#define TW_RESPONSE_QUEUE_REG_ADDR(x) (x->base_addr + 0xC)
+#define TW_CLEAR_ALL_INTERRUPTS(x) (outl(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
+#define TW_CLEAR_ATTENTION_INTERRUPT(x) (outl(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
+#define TW_CLEAR_HOST_INTERRUPT(x) (outl(TW_CONTROL_CLEAR_HOST_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
+#define TW_DISABLE_INTERRUPTS(x) (outl(TW_CONTROL_DISABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x)))
+#define TW_ENABLE_AND_CLEAR_INTERRUPTS(x) (outl(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT | TW_CONTROL_UNMASK_RESPONSE_INTERRUPT | TW_CONTROL_ENABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x)))
+#define TW_MASK_COMMAND_INTERRUPT(x) (outl(TW_CONTROL_MASK_COMMAND_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
+#define TW_UNMASK_COMMAND_INTERRUPT(x) (outl(TW_CONTROL_UNMASK_COMMAND_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
+#define TW_SOFT_RESET(x) (outl(TW_CONTROL_ISSUE_SOFT_RESET | \
+			TW_CONTROL_CLEAR_HOST_INTERRUPT | \
+			TW_CONTROL_CLEAR_ATTENTION_INTERRUPT | \
+			TW_CONTROL_MASK_COMMAND_INTERRUPT | \
+			TW_CONTROL_MASK_RESPONSE_INTERRUPT | \
+			TW_CONTROL_CLEAR_ERROR_STATUS | \
+			TW_CONTROL_DISABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x)))
 #define TW_STATUS_ERRORS(x) \
 	(((x & TW_STATUS_PCI_ABORT) || \
 	(x & TW_STATUS_PCI_PARITY_ERROR) || \
@@ -258,17 +294,10 @@
 
 /* Command Packet */
 typedef struct TW_Command {
-	/* First DWORD */
-	struct {
-		unsigned char opcode:5;
-		unsigned char sgl_offset:3;
-	} byte0;
+	unsigned char opcode__sgloffset;
 	unsigned char size;
 	unsigned char request_id;
-	struct {
-		unsigned char unit:4;
-		unsigned char host_id:4;
-	} byte3;
+	unsigned char unit__hostid;
 	/* Second DWORD */
 	unsigned char status;
 	unsigned char flags;
@@ -328,29 +357,10 @@
 
 /* Response queue */
 typedef union TAG_TW_Response_Queue {
-	struct {
-		u32 undefined_1: 4;
-		u32 response_id: 8;
-		u32 undefined_2: 20;
-	} u;
+	u32 response_id;
 	u32 value;
 } TW_Response_Queue;
 
-typedef struct TAG_TW_Registers {
-	u32 base_addr;
-	u32 control_reg_addr;
-	u32 status_reg_addr;
-	u32 command_que_addr;
-	u32 response_que_addr;
-} TW_Registers;
-
-typedef struct TAG_TW_Info {
-	char *buffer;
-	int length;
-	int offset;
-	int position;
-} TW_Info;
-
 typedef int TW_Cmd_State;
 
 #define TW_S_INITIAL   0x1  /* Initial state */
@@ -364,16 +374,10 @@
 /* Command header for ATA pass-thru */
 typedef struct TAG_TW_Passthru
 {
-	struct {
-		unsigned char opcode:5;
-		unsigned char sgloff:3;
-	} byte0;
+	unsigned char opcode__sgloffset;
 	unsigned char size;
 	unsigned char request_id;
-	struct {
-		unsigned char aport:4;
-		unsigned char host_id:4;
-	} byte3;
+	unsigned char aport__hostid;
 	unsigned char status;
 	unsigned char flags;
 	unsigned short param;
@@ -389,7 +393,7 @@
 } TW_Passthru;
 
 typedef struct TAG_TW_Device_Extension {
-	TW_Registers		registers;
+	u32			base_addr;
 	unsigned long		*alignment_virtual_address[TW_Q_LENGTH];
 	unsigned long		alignment_physical_address[TW_Q_LENGTH];
 	int			is_unit_present[TW_MAX_UNITS];
@@ -397,11 +401,10 @@
 	unsigned long		*command_packet_virtual_address[TW_Q_LENGTH];
 	unsigned long		command_packet_physical_address[TW_Q_LENGTH];
 	struct pci_dev		*tw_pci_dev;
-	Scsi_Cmnd		*srb[TW_Q_LENGTH];
+	struct scsi_cmnd	*srb[TW_Q_LENGTH];
 	unsigned char		free_queue[TW_Q_LENGTH];
 	unsigned char		free_head;
 	unsigned char		free_tail;
-	unsigned char           free_wrap;
 	unsigned char		pending_queue[TW_Q_LENGTH];
 	unsigned char		pending_head;
 	unsigned char		pending_tail;
@@ -413,83 +416,21 @@
 	u32			max_pending_request_count;
 	u32			max_sgl_entries;
 	u32			sgl_entries;
-	u32			num_aborts;
 	u32			num_resets;
 	u32			sector_count;
 	u32			max_sector_count;
 	u32			aen_count;
 	struct Scsi_Host	*host;
-	spinlock_t		tw_lock;
 	struct semaphore	ioctl_sem;
-	int		        ioctl_size[TW_Q_LENGTH];
 	unsigned short		aen_queue[TW_Q_LENGTH];
 	unsigned char		aen_head;
 	unsigned char		aen_tail;
 	volatile long		flags; /* long req'd for set_bit --RR */
-	unsigned long		*ioctl_data[TW_Q_LENGTH];
 	int			reset_print;
-	char                    online;
 	volatile int		chrdev_request_id;
 	wait_queue_head_t	ioctl_wqueue;
 } TW_Device_Extension;
 
 #pragma pack()
-
-/* Function prototypes */
-int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id);
-int tw_aen_drain_queue(TW_Device_Extension *tw_dev);
-int tw_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
-int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which);
-int tw_check_bits(u32 status_reg_value);
-int tw_check_errors(TW_Device_Extension *tw_dev);
-void tw_clear_all_interrupts(TW_Device_Extension *tw_dev);
-void tw_clear_attention_interrupt(TW_Device_Extension *tw_dev);
-void tw_clear_host_interrupt(TW_Device_Extension *tw_dev);
-int tw_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value, int print_host);
-int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill_sense);
-void tw_disable_interrupts(TW_Device_Extension *tw_dev);
-void tw_empty_response_que(TW_Device_Extension *tw_dev);
-void tw_enable_interrupts(TW_Device_Extension *tw_dev);
-void tw_enable_and_clear_interrupts(TW_Device_Extension *tw_dev);
-int tw_findcards(Scsi_Host_Template *tw_host);
-void tw_free_device_extension(TW_Device_Extension *tw_dev);
-int tw_initconnection(TW_Device_Extension *tw_dev, int message_credits);
-int tw_initialize_device_extension(TW_Device_Extension *tw_dev);
-int tw_initialize_units(TW_Device_Extension *tw_dev);
-int tw_ioctl(TW_Device_Extension *tw_dev, int request_id);
-int tw_ioctl_complete(TW_Device_Extension *tw_dev, int request_id);
-void tw_mask_command_interrupt(TW_Device_Extension *tw_dev);
-int tw_poll_status(TW_Device_Extension *tw_dev, u32 flag, int seconds);
-int tw_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds);
-int tw_post_command_packet(TW_Device_Extension *tw_dev, int request_id);
-int tw_reset_device_extension(TW_Device_Extension *tw_dev);
-int tw_reset_sequence(TW_Device_Extension *tw_dev);
-int tw_scsi_biosparam(struct scsi_device *sdev, struct block_device *bdev,
-		sector_t capacity, int geom[]);
-int tw_scsi_detect(Scsi_Host_Template *tw_host);
-int tw_scsi_eh_abort(Scsi_Cmnd *SCpnt);
-int tw_scsi_eh_reset(Scsi_Cmnd *SCpnt);
-int tw_scsi_queue(Scsi_Cmnd *cmd, void (*done) (Scsi_Cmnd *));
-int tw_scsi_release(struct Scsi_Host *tw_host);
-int tw_scsiop_inquiry(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_mode_sense(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_read_capacity(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_read_capacity_complete(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_synchronize_cache(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_test_unit_ready(TW_Device_Extension *tw_dev, int request_id);
-int tw_scsiop_test_unit_ready_complete(TW_Device_Extension *tw_dev, int request_id);
-int tw_setfeature(TW_Device_Extension *tw_dev, int parm, int param_size, 
-		  unsigned char *val);
-int tw_setup_irq(TW_Device_Extension *tw_dev);
-int tw_shutdown_device(TW_Device_Extension *tw_dev);
-int tw_slave_configure(Scsi_Device *SDptr);
-void tw_soft_reset(TW_Device_Extension *tw_dev);
-int tw_state_request_finish(TW_Device_Extension *tw_dev,int request_id);
-int tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id);
-void tw_unmask_command_interrupt(TW_Device_Extension *tw_dev);
 
 #endif /* _3W_XXXX_H */
diff -Nru a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
--- a/drivers/scsi/53c700.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/scsi/53c700.c	2004-12-24 13:36:19 -08:00
@@ -287,13 +287,15 @@
 	struct NCR_700_Host_Parameters *hostdata = 
 		(struct NCR_700_Host_Parameters *)SDp->host->hostdata[0];
 
-	return NCR_700_offset_period_to_sxfer(hostdata, spi_offset(SDp),
-					      spi_period(SDp));
+	return NCR_700_offset_period_to_sxfer(hostdata,
+					      spi_offset(SDp->sdev_target),
+					      spi_period(SDp->sdev_target));
 }
 
 struct Scsi_Host *
 NCR_700_detect(struct scsi_host_template *tpnt,
-	       struct NCR_700_Host_Parameters *hostdata)
+	       struct NCR_700_Host_Parameters *hostdata, struct device *dev,
+	       unsigned long irq, u8 scsi_id)
 {
 	dma_addr_t pScript, pSlots;
 	__u8 *memory;
@@ -320,6 +322,7 @@
 	 * if this isn't sufficient separation to avoid dma flushing issues */
 	BUG_ON(!dma_is_consistent(pScript) && L1_CACHE_BYTES < dma_get_cache_alignment());
 	hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET);
+	hostdata->dev = dev;
 		
 	pSlots = pScript + SLOTS_OFFSET;
 
@@ -386,6 +389,8 @@
 	host->unique_id = hostdata->base;
 	host->base = hostdata->base;
 	hostdata->eh_complete = NULL;
+	host->irq = irq;
+	host->this_id = scsi_id;
 	host->hostdata[0] = (unsigned long)hostdata;
 	/* kick the chip */
 	NCR_700_writeb(0xff, host, CTEST9_REG);
@@ -406,7 +411,28 @@
 	/* reset the chip */
 	NCR_700_chip_reset(host);
 
+	if (request_irq(irq, NCR_700_intr, SA_SHIRQ, dev->bus_id, host)) {
+		dev_printk(KERN_ERR, dev, "53c700: irq %lu request failed\n ",
+			   irq);
+		goto out_put_host;
+	}
+
+	if (scsi_add_host(host, dev)) {
+		dev_printk(KERN_ERR, dev, "53c700: scsi_add_host failed\n");
+		goto out_release_irq;
+	}
+
+	spi_signalling(host) = hostdata->differential ? SPI_SIGNAL_HVD :
+		SPI_SIGNAL_SE;
+
 	return host;
+
+ out_release_irq:
+	free_irq(irq, host);
+ out_put_host:
+	scsi_host_put(host);
+
+	return NULL;
 }
 
 int
@@ -803,7 +829,7 @@
 			}
 			
 			if(NCR_700_is_flag_set(SCp->device, NCR_700_DEV_PRINT_SYNC_NEGOTIATION)) {
-				if(spi_offset(SCp->device) != 0)
+				if(spi_offset(SCp->device->sdev_target) != 0)
 					printk(KERN_INFO "scsi%d: (%d:%d) Synchronous at offset %d, period %dns\n",
 					       host->host_no, pun, lun,
 					       offset, period*4);
@@ -813,8 +839,8 @@
 				NCR_700_clear_flag(SCp->device, NCR_700_DEV_PRINT_SYNC_NEGOTIATION);
 			}
 				
-			spi_offset(SCp->device) = offset;
-			spi_period(SCp->device) = period;
+			spi_offset(SCp->device->sdev_target) = offset;
+			spi_period(SCp->device->sdev_target) = period;
 			
 
 			NCR_700_set_flag(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC);
@@ -894,7 +920,8 @@
 	case A_REJECT_MSG:
 		if(SCp != NULL && NCR_700_is_flag_set(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION)) {
 			/* Rejected our sync negotiation attempt */
-			spi_period(SCp->device) = spi_offset(SCp->device) = 0;
+			spi_period(SCp->device->sdev_target) =
+				spi_offset(SCp->device->sdev_target) = 0;
 			NCR_700_set_flag(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC);
 			NCR_700_clear_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
 		} else if(SCp != NULL && NCR_700_is_flag_set(SCp->device, NCR_700_DEV_BEGIN_TAG_QUEUEING)) {
@@ -1420,8 +1447,8 @@
 	   NCR_700_is_flag_clear(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC)) {
 		memcpy(&hostdata->msgout[count], NCR_700_SDTR_msg,
 		       sizeof(NCR_700_SDTR_msg));
-		hostdata->msgout[count+3] = spi_period(SCp->device);
-		hostdata->msgout[count+4] = spi_offset(SCp->device);
+		hostdata->msgout[count+3] = spi_period(SCp->device->sdev_target);
+		hostdata->msgout[count+4] = spi_offset(SCp->device->sdev_target);
 		count += sizeof(NCR_700_SDTR_msg);
 		NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
 	}
@@ -1961,7 +1988,7 @@
 	 * reset via sg or something */
 	while(hostdata->eh_complete != NULL) {
 		spin_unlock_irq(SCp->device->host->host_lock);
-		schedule_timeout(HZ/10);
+		msleep_interruptible(100);
 		spin_lock_irq(SCp->device->host->host_lock);
 	}
 	hostdata->eh_complete = &complete;
@@ -1999,10 +2026,11 @@
 }
 
 STATIC void
-NCR_700_set_period(struct scsi_device *SDp, int period)
+NCR_700_set_period(struct scsi_target *STp, int period)
 {
+	struct Scsi_Host *SHp = dev_to_shost(STp->dev.parent);
 	struct NCR_700_Host_Parameters *hostdata = 
-		(struct NCR_700_Host_Parameters *)SDp->host->hostdata[0];
+		(struct NCR_700_Host_Parameters *)SHp->hostdata[0];
 	
 	if(!hostdata->fast)
 		return;
@@ -2010,17 +2038,18 @@
 	if(period < hostdata->min_period)
 		period = hostdata->min_period;
 
-	spi_period(SDp) = period;
-	NCR_700_clear_flag(SDp, NCR_700_DEV_NEGOTIATED_SYNC);
-	NCR_700_clear_flag(SDp, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
-	NCR_700_set_flag(SDp, NCR_700_DEV_PRINT_SYNC_NEGOTIATION);
+	spi_period(STp) = period;
+	spi_flags(STp) &= ~(NCR_700_DEV_NEGOTIATED_SYNC |
+			    NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
+	spi_flags(STp) |= NCR_700_DEV_PRINT_SYNC_NEGOTIATION;
 }
 
 STATIC void
-NCR_700_set_offset(struct scsi_device *SDp, int offset)
+NCR_700_set_offset(struct scsi_target *STp, int offset)
 {
+	struct Scsi_Host *SHp = dev_to_shost(STp->dev.parent);
 	struct NCR_700_Host_Parameters *hostdata = 
-		(struct NCR_700_Host_Parameters *)SDp->host->hostdata[0];
+		(struct NCR_700_Host_Parameters *)SHp->hostdata[0];
 	int max_offset = hostdata->chip710
 		? NCR_710_MAX_OFFSET : NCR_700_MAX_OFFSET;
 	
@@ -2031,14 +2060,14 @@
 		offset = max_offset;
 
 	/* if we're currently async, make sure the period is reasonable */
-	if(spi_offset(SDp) == 0 && (spi_period(SDp) < hostdata->min_period ||
-				    spi_period(SDp) > 0xff))
-		spi_period(SDp) = hostdata->min_period;
-
-	spi_offset(SDp) = offset;
-	NCR_700_clear_flag(SDp, NCR_700_DEV_NEGOTIATED_SYNC);
-	NCR_700_clear_flag(SDp, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
-	NCR_700_set_flag(SDp, NCR_700_DEV_PRINT_SYNC_NEGOTIATION);
+	if(spi_offset(STp) == 0 && (spi_period(STp) < hostdata->min_period ||
+				    spi_period(STp) > 0xff))
+		spi_period(STp) = hostdata->min_period;
+
+	spi_offset(STp) = offset;
+	spi_flags(STp) &= ~(NCR_700_DEV_NEGOTIATED_SYNC |
+			    NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
+	spi_flags(STp) |= NCR_700_DEV_PRINT_SYNC_NEGOTIATION;
 }
 
 
@@ -2058,10 +2087,11 @@
 	}
 	if(hostdata->fast) {
 		/* Find the correct offset and period via domain validation */
-		spi_dv_device(SDp);
+		if (!spi_initial_dv(SDp->sdev_target))
+			spi_dv_device(SDp);
 	} else {
-		spi_offset(SDp) = 0;
-		spi_period(SDp) = 0;
+		spi_offset(SDp->sdev_target) = 0;
+		spi_period(SDp->sdev_target) = 0;
 	}
 	return 0;
 }
diff -Nru a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h
--- a/drivers/scsi/53c700.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/53c700.h	2004-12-24 13:36:17 -08:00
@@ -60,7 +60,8 @@
 
 /* These are the externally used routines */
 struct Scsi_Host *NCR_700_detect(struct scsi_host_template *,
-		struct NCR_700_Host_Parameters *);
+		struct NCR_700_Host_Parameters *, struct device *,
+		unsigned long, u8);
 int NCR_700_release(struct Scsi_Host *host);
 irqreturn_t NCR_700_intr(int, void *, struct pt_regs *);
 
@@ -121,22 +122,22 @@
 static inline int
 NCR_700_is_flag_set(struct scsi_device *SDp, __u32 flag)
 {
-	return (((unsigned long)SDp->hostdata) & flag) == flag;
+	return (spi_flags(SDp->sdev_target) & flag) == flag;
 }
 static inline int
 NCR_700_is_flag_clear(struct scsi_device *SDp, __u32 flag)
 {
-	return (((unsigned long)SDp->hostdata) & flag) == 0;
+	return (spi_flags(SDp->sdev_target) & flag) == 0;
 }
 static inline void
 NCR_700_set_flag(struct scsi_device *SDp, __u32 flag)
 {
-	SDp->hostdata = (void *)((long)SDp->hostdata | (flag & 0xffff0000));
+	spi_flags(SDp->sdev_target) |= flag;
 }
 static inline void
 NCR_700_clear_flag(struct scsi_device *SDp, __u32 flag)
 {
-	SDp->hostdata = (void *)((long)SDp->hostdata & ~(flag & 0xffff0000));
+	spi_flags(SDp->sdev_target) &= ~flag;
 }
 
 struct NCR_700_command_slot {
diff -Nru a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
--- a/drivers/scsi/BusLogic.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/scsi/BusLogic.c	2004-12-24 13:37:29 -08:00
@@ -47,8 +47,11 @@
 #include <asm/io.h>
 #include <asm/system.h>
 
-#include "scsi.h"
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
 #include "BusLogic.h"
 #include "FlashPoint.c"
 
@@ -56,6 +59,8 @@
 #define FAILURE (-1)
 #endif
 
+static struct scsi_host_template Bus_Logic_template;
+
 /*
   BusLogic_DriverOptionsCount is a count of the number of BusLogic Driver
   Options specifications provided via the Linux Kernel Command Line or via
@@ -81,7 +86,7 @@
 MODULE_LICENSE("GPL");
 #ifdef MODULE
 static char *BusLogic;
-MODULE_PARM(BusLogic, "s");
+module_param(BusLogic, charp, 0);
 #endif
 
 
@@ -100,15 +105,7 @@
 
 static struct BusLogic_GlobalOptions BusLogic_GlobalOptions;
 
-
-/*
-  BusLogic_FirstRegisteredHostAdapter and BusLogic_LastRegisteredHostAdapter
-  are pointers to the first and last registered BusLogic Host Adapters.
-*/
-
-static struct BusLogic_HostAdapter *BusLogic_FirstRegisteredHostAdapter;
-static struct BusLogic_HostAdapter *BusLogic_LastRegisteredHostAdapter;
-
+static LIST_HEAD(BusLogic_host_list);
 
 /*
   BusLogic_ProbeInfoCount is the number of entries in BusLogic_ProbeInfoList.
@@ -158,47 +155,6 @@
 	return HostAdapter->FullModelName;
 }
 
-
-/*
-  BusLogic_RegisterHostAdapter adds Host Adapter to the list of registered
-  BusLogic Host Adapters.
-*/
-
-static void __init BusLogic_RegisterHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
-{
-	HostAdapter->Next = NULL;
-	if (BusLogic_FirstRegisteredHostAdapter == NULL) {
-		BusLogic_FirstRegisteredHostAdapter = HostAdapter;
-		BusLogic_LastRegisteredHostAdapter = HostAdapter;
-	} else {
-		BusLogic_LastRegisteredHostAdapter->Next = HostAdapter;
-		BusLogic_LastRegisteredHostAdapter = HostAdapter;
-	}
-}
-
-
-/*
-  BusLogic_UnregisterHostAdapter removes Host Adapter from the list of
-  registered BusLogic Host Adapters.
-*/
-
-static void BusLogic_UnregisterHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
-{
-	if (HostAdapter == BusLogic_FirstRegisteredHostAdapter) {
-		BusLogic_FirstRegisteredHostAdapter = BusLogic_FirstRegisteredHostAdapter->Next;
-		if (HostAdapter == BusLogic_LastRegisteredHostAdapter)
-			BusLogic_LastRegisteredHostAdapter = NULL;
-	} else {
-		struct BusLogic_HostAdapter *PreviousHostAdapter = BusLogic_FirstRegisteredHostAdapter;
-		while (PreviousHostAdapter != NULL && PreviousHostAdapter->Next != HostAdapter)
-			PreviousHostAdapter = PreviousHostAdapter->Next;
-		if (PreviousHostAdapter != NULL)
-			PreviousHostAdapter->Next = HostAdapter->Next;
-	}
-	HostAdapter->Next = NULL;
-}
-
-
 /*
   BusLogic_InitializeCCBs initializes a group of Command Control Blocks (CCBs)
   for Host Adapter from the BlockSize bytes located at BlockPointer.  The newly
@@ -347,12 +303,19 @@
 static void BusLogic_DeallocateCCB(struct BusLogic_CCB *CCB)
 {
 	struct BusLogic_HostAdapter *HostAdapter = CCB->HostAdapter;
-	if (CCB->Command->use_sg != 0) {
-		pci_unmap_sg(HostAdapter->PCI_Device, (struct scatterlist *) CCB->Command->request_buffer, CCB->Command->use_sg, scsi_to_pci_dma_dir(CCB->Command->sc_data_direction));
-	} else if (CCB->Command->request_bufflen != 0) {
-		pci_unmap_single(HostAdapter->PCI_Device, CCB->DataPointer, CCB->DataLength, scsi_to_pci_dma_dir(CCB->Command->sc_data_direction));
+	struct scsi_cmnd *cmd = CCB->Command;
+
+	if (cmd->use_sg != 0) {
+		pci_unmap_sg(HostAdapter->PCI_Device,
+				(struct scatterlist *)cmd->request_buffer,
+				cmd->use_sg, cmd->sc_data_direction);
+	} else if (cmd->request_bufflen != 0) {
+		pci_unmap_single(HostAdapter->PCI_Device, CCB->DataPointer,
+				CCB->DataLength, cmd->sc_data_direction);
 	}
-	pci_unmap_single(HostAdapter->PCI_Device, CCB->SenseDataPointer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
+	pci_unmap_single(HostAdapter->PCI_Device, CCB->SenseDataPointer,
+			CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
+
 	CCB->Command = NULL;
 	CCB->Status = BusLogic_CCB_Free;
 	CCB->Next = HostAdapter->Free_CCBs;
@@ -2208,17 +2171,23 @@
   registered.
 */
 
-static int __init BusLogic_DetectHostAdapter(struct scsi_host_template *HostTemplate)
+static int __init BusLogic_init(void)
 {
 	int BusLogicHostAdapterCount = 0, DriverOptionsIndex = 0, ProbeIndex;
 	struct BusLogic_HostAdapter *PrototypeHostAdapter;
+
+#ifdef MODULE
+	if (BusLogic)
+		BusLogic_Setup(BusLogic);
+#endif
+
 	if (BusLogic_ProbeOptions.NoProbe)
-		return 0;
+		return -ENODEV;
 	BusLogic_ProbeInfoList = (struct BusLogic_ProbeInfo *)
 	    kmalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_ATOMIC);
 	if (BusLogic_ProbeInfoList == NULL) {
 		BusLogic_Error("BusLogic: Unable to allocate Probe Info List\n", NULL);
-		return 0;
+		return -ENOMEM;
 	}
 	memset(BusLogic_ProbeInfoList, 0, BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo));
 	PrototypeHostAdapter = (struct BusLogic_HostAdapter *)
@@ -2226,7 +2195,7 @@
 	if (PrototypeHostAdapter == NULL) {
 		kfree(BusLogic_ProbeInfoList);
 		BusLogic_Error("BusLogic: Unable to allocate Prototype " "Host Adapter\n", NULL);
-		return 0;
+		return -ENOMEM;
 	}
 	memset(PrototypeHostAdapter, 0, sizeof(struct BusLogic_HostAdapter));
 #ifdef MODULE
@@ -2289,7 +2258,7 @@
 		   Register the SCSI Host structure.
 		 */
 
-		Host = scsi_host_alloc(HostTemplate, sizeof(struct BusLogic_HostAdapter));
+		Host = scsi_host_alloc(&Bus_Logic_template, sizeof(struct BusLogic_HostAdapter));
 		if (Host == NULL) {
 			release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
 			continue;
@@ -2302,7 +2271,8 @@
 		   Add Host Adapter to the end of the list of registered BusLogic
 		   Host Adapters.
 		 */
-		BusLogic_RegisterHostAdapter(HostAdapter);
+		list_add_tail(&HostAdapter->host_list, &BusLogic_host_list);
+
 		/*
 		   Read the Host Adapter Configuration, Configure the Host Adapter,
 		   Acquire the System Resources necessary to use the Host Adapter, then
@@ -2322,7 +2292,7 @@
 				printk(KERN_WARNING "BusLogic: Release and re-register of " "port 0x%04lx failed \n", (unsigned long) HostAdapter->IO_Address);
 				BusLogic_DestroyCCBs(HostAdapter);
 				BusLogic_ReleaseResources(HostAdapter);
-				BusLogic_UnregisterHostAdapter(HostAdapter);
+				list_del(&HostAdapter->host_list);
 				scsi_host_put(Host);
 			} else {
 				BusLogic_InitializeHostStructure(HostAdapter, Host);
@@ -2341,14 +2311,14 @@
 			 */
 			BusLogic_DestroyCCBs(HostAdapter);
 			BusLogic_ReleaseResources(HostAdapter);
-			BusLogic_UnregisterHostAdapter(HostAdapter);
+			list_del(&HostAdapter->host_list);
 			scsi_host_put(Host);
 		}
 	}
 	kfree(PrototypeHostAdapter);
 	kfree(BusLogic_ProbeInfoList);
 	BusLogic_ProbeInfoList = NULL;
-	return BusLogicHostAdapterCount;
+	return 0;
 }
 
 
@@ -2358,9 +2328,12 @@
   unregisters the BusLogic Host Adapter.
 */
 
-static int __exit BusLogic_ReleaseHostAdapter(struct Scsi_Host *Host)
+static int __exit BusLogic_ReleaseHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
 {
-	struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Host->hostdata;
+	struct Scsi_Host *Host = HostAdapter->SCSI_Host;
+
+	scsi_remove_host(Host);
+
 	/*
 	   FlashPoint Host Adapters must first be released by the FlashPoint
 	   SCCB Manager.
@@ -2380,7 +2353,9 @@
 	/*
 	   Remove Host Adapter from the list of registered BusLogic Host Adapters.
 	 */
-	BusLogic_UnregisterHostAdapter(HostAdapter);
+	list_del(&HostAdapter->host_list);
+
+	scsi_host_put(Host);
 	return 0;
 }
 
@@ -2656,7 +2631,7 @@
 	/*
 	   Acquire exclusive access to Host Adapter.
 	 */
-	BusLogic_AcquireHostAdapterLockIH(HostAdapter, &ProcessorFlags);
+	spin_lock_irqsave(HostAdapter->SCSI_Host->host_lock, ProcessorFlags);
 	/*
 	   Handle Interrupts appropriately for each Host Adapter type.
 	 */
@@ -2724,7 +2699,7 @@
 	/*
 	   Release exclusive access to Host Adapter.
 	 */
-	BusLogic_ReleaseHostAdapterLockIH(HostAdapter, &ProcessorFlags);
+	spin_unlock_irqrestore(HostAdapter->SCSI_Host->host_lock, ProcessorFlags);
 	return IRQ_HANDLED;
 }
 
@@ -2765,7 +2740,7 @@
 
 /* Error Handling (EH) support */
 
-static int BusLogic_host_reset(Scsi_Cmnd * SCpnt)
+static int BusLogic_host_reset(struct scsi_cmnd * SCpnt)
 {
 	struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) SCpnt->device->host->hostdata;
 
@@ -2812,9 +2787,9 @@
 	 */
 	CCB = BusLogic_AllocateCCB(HostAdapter);
 	if (CCB == NULL) {
-		BusLogic_ReleaseHostAdapterLock(HostAdapter);
+		spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
 		BusLogic_Delay(1);
-		BusLogic_AcquireHostAdapterLock(HostAdapter);
+		spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
 		CCB = BusLogic_AllocateCCB(HostAdapter);
 		if (CCB == NULL) {
 			Command->result = DID_ERROR << 16;
@@ -2828,12 +2803,15 @@
 	if (SegmentCount == 0 && BufferLength != 0) {
 		CCB->Opcode = BusLogic_InitiatorCCB;
 		CCB->DataLength = BufferLength;
-		CCB->DataPointer = pci_map_single(HostAdapter->PCI_Device, BufferPointer, BufferLength, scsi_to_pci_dma_dir(Command->sc_data_direction));
+		CCB->DataPointer = pci_map_single(HostAdapter->PCI_Device,
+				BufferPointer, BufferLength,
+				Command->sc_data_direction);
 	} else if (SegmentCount != 0) {
 		struct scatterlist *ScatterList = (struct scatterlist *) BufferPointer;
 		int Segment, Count;
 
-		Count = pci_map_sg(HostAdapter->PCI_Device, ScatterList, SegmentCount, scsi_to_pci_dma_dir(Command->sc_data_direction));
+		Count = pci_map_sg(HostAdapter->PCI_Device, ScatterList, SegmentCount,
+				Command->sc_data_direction);
 		CCB->Opcode = BusLogic_InitiatorCCB_ScatterGather;
 		CCB->DataLength = Count * sizeof(struct BusLogic_ScatterGatherSegment);
 		if (BusLogic_MultiMasterHostAdapterP(HostAdapter))
@@ -2938,10 +2916,10 @@
 		   error as a Host Adapter Hard Reset should be initiated soon.
 		 */
 		if (!BusLogic_WriteOutgoingMailbox(HostAdapter, BusLogic_MailboxStartCommand, CCB)) {
-			BusLogic_ReleaseHostAdapterLock(HostAdapter);
+			spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
 			BusLogic_Warning("Unable to write Outgoing Mailbox - " "Pausing for 1 second\n", HostAdapter);
 			BusLogic_Delay(1);
-			BusLogic_AcquireHostAdapterLock(HostAdapter);
+			spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
 			if (!BusLogic_WriteOutgoingMailbox(HostAdapter, BusLogic_MailboxStartCommand, CCB)) {
 				BusLogic_Warning("Still unable to write Outgoing Mailbox - " "Host Adapter Dead?\n", HostAdapter);
 				BusLogic_DeallocateCCB(CCB);
@@ -3079,9 +3057,9 @@
 	 */
 
 	if (HardReset) {
-		BusLogic_ReleaseHostAdapterLock(HostAdapter);
+		spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
 		BusLogic_Delay(HostAdapter->BusSettleTime);
-		BusLogic_AcquireHostAdapterLock(HostAdapter);
+		spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
 	}
 
 	for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
@@ -3181,17 +3159,11 @@
 
 static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *shost, char *ProcBuffer, char **StartPointer, off_t Offset, int BytesAvailable, int WriteFlag)
 {
-	struct BusLogic_HostAdapter *HostAdapter;
+	struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata;
 	struct BusLogic_TargetStatistics *TargetStatistics;
 	int TargetID, Length;
 	char *Buffer;
-	for (HostAdapter = BusLogic_FirstRegisteredHostAdapter; HostAdapter != NULL; HostAdapter = HostAdapter->Next)
-		if (HostAdapter->HostNumber == shost->host_no)
-			break;
-	if (HostAdapter == NULL) {
-		BusLogic_Error("Cannot find Host Adapter for SCSI Host %d\n", NULL, shost->host_no);
-		return 0;
-	}
+
 	TargetStatistics = HostAdapter->TargetStatistics;
 	if (WriteFlag) {
 		HostAdapter->ExternalHostAdapterResets = 0;
@@ -3547,7 +3519,7 @@
   Get it all started
 */
 
-static struct scsi_host_template driver_template = {
+static struct scsi_host_template Bus_Logic_template = {
 	.module = THIS_MODULE,
 	.proc_name = "BusLogic",
 	.proc_info = BusLogic_ProcDirectoryInfo,
@@ -3585,36 +3557,15 @@
 }
 
 /*
- * Initialization function
- */
-
-static int __init BusLogic_init(void)
-{
-
-#ifdef MODULE
-	if (BusLogic)
-		BusLogic_Setup(BusLogic);
-#endif
-
-	return BusLogic_DetectHostAdapter(&driver_template) ? 0 : -ENODEV;
-}
-
-/*
  * Exit function.  Deletes all hosts associated with this driver.
  */
 
 static void __exit BusLogic_exit(void)
 {
-	struct BusLogic_HostAdapter *HostAdapter;
-	for (HostAdapter = BusLogic_FirstRegisteredHostAdapter; HostAdapter != NULL; HostAdapter = HostAdapter->Next) {
-		struct Scsi_Host *host = HostAdapter->SCSI_Host;
-		scsi_remove_host(host);
+	struct BusLogic_HostAdapter *ha, *next;
 
-	}
-	for (HostAdapter = BusLogic_FirstRegisteredHostAdapter; HostAdapter != NULL; HostAdapter = HostAdapter->Next) {
-		struct Scsi_Host *host = HostAdapter->SCSI_Host;
-		BusLogic_ReleaseHostAdapter(host);
-	}
+	list_for_each_entry_safe(ha, next, &BusLogic_host_list, host_list)
+		BusLogic_ReleaseHostAdapter(ha);
 }
 
 __setup("BusLogic=", BusLogic_Setup);
diff -Nru a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h
--- a/drivers/scsi/BusLogic.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/BusLogic.h	2004-12-24 13:36:48 -08:00
@@ -1098,7 +1098,7 @@
 	struct BusLogic_DriverOptions *DriverOptions;
 	struct FlashPoint_Info FlashPointInfo;
 	FlashPoint_CardHandle_T CardHandle;
-	struct BusLogic_HostAdapter *Next;
+	struct list_head host_list;
 	struct BusLogic_CCB *All_CCBs;
 	struct BusLogic_CCB *Free_CCBs;
 	struct BusLogic_CCB *FirstCompletedCCB;
@@ -1169,46 +1169,6 @@
 	unsigned char ProductRevisionLevel[4];	/* Bytes 32-35 */
 };
 
-/*
-  BusLogic_AcquireHostAdapterLock acquires exclusive access to Host Adapter.
-*/
-
-static inline void BusLogic_AcquireHostAdapterLock(struct BusLogic_HostAdapter *HostAdapter)
-{
-	spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
-}
-
-/*
-  BusLogic_ReleaseHostAdapterLock releases exclusive access to Host Adapter.
-*/
-
-static inline void BusLogic_ReleaseHostAdapterLock(struct BusLogic_HostAdapter *HostAdapter)
-{
-	spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
-}
-
-
-/*
-  BusLogic_AcquireHostAdapterLockIH acquires exclusive access to Host Adapter,
-  but is only called from the interrupt handler.
-*/
-
-static inline void BusLogic_AcquireHostAdapterLockIH(struct BusLogic_HostAdapter *HostAdapter, unsigned long *ProcessorFlags)
-{
-	spin_lock_irqsave(HostAdapter->SCSI_Host->host_lock, *ProcessorFlags);
-}
-
-
-/*
-  BusLogic_ReleaseHostAdapterLockIH releases exclusive access to Host Adapter,
-  but is only called from the interrupt handler.
-*/
-
-static inline void BusLogic_ReleaseHostAdapterLockIH(struct BusLogic_HostAdapter *HostAdapter, unsigned long *ProcessorFlags)
-{
-	spin_unlock_irqrestore(HostAdapter->SCSI_Host->host_lock, *ProcessorFlags);
-}
-
 
 /*
   Define functions to provide an abstraction for reading and writing the
@@ -1386,8 +1346,6 @@
 */
 
 static const char *BusLogic_DriverInfo(struct Scsi_Host *);
-static int BusLogic_DetectHostAdapter(struct scsi_host_template *);
-static int BusLogic_ReleaseHostAdapter(struct Scsi_Host *);
 static int BusLogic_QueueCommand(struct scsi_cmnd *, void (*CompletionRoutine) (struct scsi_cmnd *));
 static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *);
 static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *, char *, char **, off_t, int, int);
diff -Nru a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
--- a/drivers/scsi/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/Kconfig	2004-12-24 13:37:19 -08:00
@@ -313,8 +313,8 @@
 	  module will be called aha1740.
 
 config SCSI_AACRAID
-	tristate "Adaptec AACRAID support (EXPERIMENTAL)"
-	depends on EXPERIMENTAL && SCSI && PCI
+	tristate "Adaptec AACRAID support"
+	depends on SCSI && PCI
 
 source "drivers/scsi/aic7xxx/Kconfig.aic7xxx"
 
@@ -399,16 +399,24 @@
 
 config SCSI_SATA
 	bool "Serial ATA (SATA) support"
-	depends on SCSI && EXPERIMENTAL
+	depends on SCSI
 	help
 	  This driver family supports Serial ATA host controllers
 	  and devices.
 
 	  If unsure, say N.
 
+config SCSI_SATA_AHCI
+	tristate "AHCI SATA support"
+	depends on SCSI_SATA && PCI
+	help
+	  This option enables support for AHCI Serial ATA.
+
+	  If unsure, say N.
+
 config SCSI_SATA_SVW
-	tristate "ServerWorks Frodo / Apple K2 SATA support (EXPERIMENTAL)"
-	depends on SCSI_SATA && PCI && EXPERIMENTAL
+	tristate "ServerWorks Frodo / Apple K2 SATA support"
+	depends on SCSI_SATA && PCI
 	help
 	  This option enables support for Broadcom/Serverworks/Apple K2
 	  SATA support.
@@ -459,15 +467,23 @@
 
 config SCSI_SATA_SIS
 	tristate "SiS 964/180 SATA support"
-	depends on SCSI_SATA && PCI
+	depends on SCSI_SATA && PCI && EXPERIMENTAL
 	help
 	  This option enables support for SiS Serial ATA 964/180.
 
 	  If unsure, say N.
 
+config SCSI_SATA_ULI
+	tristate "ULi Electronics SATA support"
+	depends on SCSI_SATA && PCI && EXPERIMENTAL
+	help
+	  This option enables support for ULi Electronics SATA.
+
+	  If unsure, say N.
+
 config SCSI_SATA_VIA
 	tristate "VIA SATA support"
-	depends on SCSI_SATA && PCI && EXPERIMENTAL
+	depends on SCSI_SATA && PCI
 	help
 	  This option enables support for VIA Serial ATA.
 
@@ -475,7 +491,7 @@
 
 config SCSI_SATA_VITESSE
 	tristate "VITESSE VSC-7174 SATA support"
-	depends on SCSI_SATA && PCI && EXPERIMENTAL
+	depends on SCSI_SATA && PCI
 	help
 	  This option enables support for Vitesse VSC7174 Serial ATA.
 
@@ -783,7 +799,7 @@
 
 config SCSI_INITIO
 	tristate "Initio 9100U(W) support"
-	depends on PCI && SCSI && BROKEN
+	depends on PCI && SCSI
 	help
 	  This is support for the Initio 91XXU(W) SCSI host adapter.  Please
 	  read the SCSI-HOWTO, available from
@@ -1028,6 +1044,7 @@
 config SCSI_ZALON
 	tristate "Zalon SCSI support"
 	depends on GSC && SCSI
+	select SCSI_SPI_ATTRS
 	help
 	  The Zalon is a GSC/HSC bus interface chip that sits between the
 	  PA-RISC processor and the NCR 53c720 SCSI controller on C100,
@@ -1038,6 +1055,7 @@
 config SCSI_NCR_Q720
 	tristate "NCR Quad 720 MCA SCSI support"
 	depends on MCA && SCSI
+	select SCSI_SPI_ATTRS
 	help
 	  This is a driver for the MicroChannel Quad 720 card produced by
 	  NCR and commonly used in 345x/35xx/4100 class machines.  It always
@@ -1222,7 +1240,7 @@
 	  module will be called qlogicfas.
 
 config SCSI_QLOGIC_ISP
-	tristate "Qlogic ISP SCSI support"
+	tristate "Qlogic ISP SCSI support (old driver)"
 	depends on PCI && SCSI
 	---help---
 	  This driver works for all QLogic PCI SCSI host adapters (IQ-PCI,
@@ -1239,6 +1257,9 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called qlogicisp.
 
+	  These days the hardware is also supported by the more modern qla1280
+	  driver.  In doubt use that one instead of qlogicisp.
+
 config SCSI_QLOGIC_FC
 	tristate "Qlogic ISP FC SCSI support"
 	depends on PCI && SCSI
@@ -1257,14 +1278,22 @@
 	  qlogicfc driver. This is required on some platforms.
 
 config SCSI_QLOGIC_1280
-	tristate "Qlogic QLA 1280 SCSI support"
+	tristate "Qlogic QLA 1240/1x80/1x160 SCSI support"
 	depends on PCI && SCSI
 	help
-	  Say Y if you have a QLogic ISP1x80/1x160 SCSI host adapter.
+	  Say Y if you have a QLogic ISP1240/1x80/1x160 SCSI host adapter.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called qla1280.
 
+config SCSI_QLOGIC_1280_1040
+	bool "Qlogic QLA 1020/1040 SCSI support"
+	depends on SCSI_QLOGIC_1280 && SCSI_QLOGIC_ISP!=y
+	help
+	  Say Y here if you have a QLogic ISP1020/1040 SCSI host adapter and
+	  do not want to use the old driver.  This option enables support in
+	  the qla1280 driver for those host adapters.
+
 config SCSI_QLOGICPTI
 	tristate "PTI Qlogic, ISP Driver"
 	depends on SBUS && SCSI
@@ -1494,7 +1523,7 @@
 
 config SCSI_MAC53C94
 	tristate "53C94 (Power Mac external SCSI) support"
-	depends on PPC_PMAC && SCSI
+	depends on PPC32 && PPC_PMAC && SCSI
 	help
 	  On Power Macintoshes (and clones) with two SCSI buses, the external
 	  SCSI bus is usually controlled by a 53C94 SCSI bus adaptor. Older
@@ -1738,7 +1767,7 @@
 
 config ZFCP
 	tristate "FCP host bus adapter driver for IBM eServer zSeries"
-	depends on ARCH_S390 && SCSI
+	depends on ARCH_S390 && QDIO && SCSI
 	select SCSI_FC_ATTRS
 	help
           If you want to access SCSI devices attached to your IBM eServer
diff -Nru a/drivers/scsi/Makefile b/drivers/scsi/Makefile
--- a/drivers/scsi/Makefile	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/Makefile	2004-12-24 13:37:18 -08:00
@@ -121,6 +121,7 @@
 obj-$(CONFIG_SCSI_NSP32)	+= nsp32.o
 obj-$(CONFIG_SCSI_IPR)		+= ipr.o
 obj-$(CONFIG_SCSI_IBMVSCSI)	+= ibmvscsi/
+obj-$(CONFIG_SCSI_SATA_AHCI)	+= libata.o ahci.o
 obj-$(CONFIG_SCSI_SATA_SVW)	+= libata.o sata_svw.o
 obj-$(CONFIG_SCSI_ATA_PIIX)	+= libata.o ata_piix.o
 obj-$(CONFIG_SCSI_SATA_PROMISE)	+= libata.o sata_promise.o
@@ -130,6 +131,7 @@
 obj-$(CONFIG_SCSI_SATA_SIS)	+= libata.o sata_sis.o
 obj-$(CONFIG_SCSI_SATA_SX4)	+= libata.o sata_sx4.o
 obj-$(CONFIG_SCSI_SATA_NV)	+= libata.o sata_nv.o
+obj-$(CONFIG_SCSI_SATA_ULI)	+= libata.o sata_uli.o
 
 obj-$(CONFIG_ARM)		+= arm/
 
@@ -148,8 +150,6 @@
 
 sd_mod-objs	:= sd.o
 sr_mod-objs	:= sr.o sr_ioctl.o sr_vendor.o
-initio-objs	:= ini9100u.o i91uscsi.o
-a100u2w-objs	:= inia100.o i60uscsi.o
 ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
 		:= -DCONFIG_NCR53C8XX_PREFETCH -DSCSI_NCR_BIG_ENDIAN \
 			-DCONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
diff -Nru a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
--- a/drivers/scsi/NCR5380.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/NCR5380.c	2004-12-24 13:36:31 -08:00
@@ -113,32 +113,18 @@
 
 /*
  * Design
- * Issues :
  *
- * The other Linux SCSI drivers were written when Linux was Intel PC-only,
- * and specifically for each board rather than each chip.  This makes their
- * adaptation to platforms like the Mac (Some of which use NCR5380's)
- * more difficult than it has to be.
- *
- * Also, many of the SCSI drivers were written before the command queuing
- * routines were implemented, meaning their implementations of queued 
- * commands were hacked on rather than designed in from the start.
- *
- * When I designed the Linux SCSI drivers I figured that 
- * while having two different SCSI boards in a system might be useful
- * for debugging things, two of the same type wouldn't be used.
- * Well, I was wrong and a number of users have mailed me about running
- * multiple high-performance SCSI boards in a server.
- *
- * Finally, when I get questions from users, I have no idea what 
- * revision of my driver they are running.
- *
- * This driver attempts to address these problems :
  * This is a generic 5380 driver.  To use it on a different platform, 
  * one simply writes appropriate system specific macros (ie, data
  * transfer - some PC's will use the I/O bus, 68K's must use 
  * memory mapped) and drops this file in their 'C' wrapper.
  *
+ * (Note from hch:  unfortunately it was not enough for the different
+ * m68k folks and instead of improving this driver they copied it
+ * and hacked it up for their needs.  As a consequence they lost
+ * most updates to this driver.  Maybe someone will fix all these
+ * drivers to use a common core one day..)
+ *
  * As far as command queueing, two queues are maintained for 
  * each 5380 in the system - commands that haven't been issued yet,
  * and commands that are currently executing.  This means that an 
@@ -148,17 +134,6 @@
  * allowing multiple commands to propagate all the way to a SCSI-II device 
  * while a command is already executing.
  *
- * To solve the multiple-boards-in-the-same-system problem, 
- * there is a separate instance structure for each instance
- * of a 5380 in the system.  So, multiple NCR5380 drivers will
- * be able to coexist with appropriate changes to the high level
- * SCSI code.  
- *
- * A NCR5380_PUBLIC_REVISION macro is provided, with the release
- * number (updated for each public release) printed by the 
- * NCR5380_print_options command, which should be called from the 
- * wrapper detect function, so that I know what release of the driver
- * users are using.
  *
  * Issues specific to the NCR5380 : 
  *
@@ -183,11 +158,10 @@
  * Architecture :
  *
  * At the heart of the design is a coroutine, NCR5380_main,
- * which is started when not running by the interrupt handler,
- * timer, and queue command function.  It attempts to establish
- * I_T_L or I_T_L_Q nexuses by removing the commands from the 
- * issue queue and calling NCR5380_select() if a nexus 
- * is not established. 
+ * which is started from a workqueue for each NCR5380 host in the
+ * system.  It attempts to establish I_T_L or I_T_L_Q nexuses by
+ * removing the commands from the issue queue and calling
+ * NCR5380_select() if a nexus is not established. 
  *
  * Once a nexus is established, the NCR5380_information_transfer()
  * phase goes through the various phases as instructed by the target.
@@ -289,27 +263,12 @@
  * NCR5380_pwrite(instance, src, count)
  * NCR5380_pread(instance, dst, count);
  *
- * If nothing specific to this implementation needs doing (ie, with external
- * hardware), you must also define 
- *  
- * NCR5380_queue_command
- * NCR5380_reset
- * NCR5380_abort
- * NCR5380_proc_info
- *
- * to be the global entry points into the specific driver, ie 
- * #define NCR5380_queue_command t128_queue_command.
- *
- * If this is not done, the routines will be defined as static functions
- * with the NCR5380* names and the user must provide a globally
- * accessible wrapper function.
- *
  * The generic driver is initialized by calling NCR5380_init(instance),
  * after setting the appropriate host specific fields and ID.  If the 
  * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance,
- * possible) function may be used.  Before the specific driver initialization
- * code finishes, NCR5380_print_options should be called.
+ * possible) function may be used.
  */
+
 static int do_abort(struct Scsi_Host *host);
 static void do_reset(struct Scsi_Host *host);
 
diff -Nru a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
--- a/drivers/scsi/NCR53c406a.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/scsi/NCR53c406a.c	2004-12-24 13:36:49 -08:00
@@ -46,9 +46,9 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
-#include <asm/bitops.h>
 #include <asm/irq.h>
 
 #include <linux/blkdev.h>
diff -Nru a/drivers/scsi/NCR_D700.c b/drivers/scsi/NCR_D700.c
--- a/drivers/scsi/NCR_D700.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/NCR_D700.c	2004-12-24 13:36:18 -08:00
@@ -99,6 +99,9 @@
 #include <linux/mca.h>
 #include <asm/io.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
 
 #include "53c700.h"
 #include "NCR_D700.h"
@@ -198,34 +201,20 @@
 	NCR_700_set_io_mapped(hostdata);
 
 	/* and register the siop */
-	host = NCR_700_detect(&NCR_D700_driver_template, hostdata);
+	host = NCR_700_detect(&NCR_D700_driver_template, hostdata,
+			      p->dev, irq,
+			      /* FIXME: read this from SUS */
+			      id_array[slot * 2 + siop]);
 	if (!host) {
 		ret = -ENOMEM;
 		goto detect_failed;
 	}
 
-	host->irq = irq;
-	/* FIXME: Read this from SUS */
-	host->this_id = id_array[slot * 2 + siop];
-	printk(KERN_NOTICE "NCR D700: SIOP%d, SCSI id is %d\n",
-			siop, host->this_id);
-	if (request_irq(irq, NCR_700_intr, SA_SHIRQ, "NCR_D700", host)) {
-		printk(KERN_ERR "NCR D700: SIOP%d: irq problem, "
-				"detatching\n", siop);
-		ret = -ENODEV;
-		goto irq_failed;
-	}
-
-	scsi_add_host(host, p->dev); /* XXX handle failure */
 	scsi_scan_host(host);
 
 	p->hosts[siop] = host;
-	hostdata->dev = p->dev;
 	return 0;
 
- irq_failed:
-	scsi_host_put(host);
-	NCR_700_release(host);
  detect_failed:
 	release_region(host->base, 64);
  region_failed:
diff -Nru a/drivers/scsi/NCR_Q720.c b/drivers/scsi/NCR_Q720.c
--- a/drivers/scsi/NCR_Q720.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/NCR_Q720.c	2004-12-24 13:36:18 -08:00
@@ -39,7 +39,7 @@
 /* We needs this helper because we have up to four hosts per struct device */
 struct NCR_Q720_private {
 	struct device		*dev;
-	__u32			mem_base;
+	void __iomem *		mem_base;
 	__u32			phys_mem_base;
 	__u32			mem_size;
 	__u8			irq;
@@ -75,7 +75,7 @@
 
 static int __init
 NCR_Q720_probe_one(struct NCR_Q720_private *p, int siop,
-		int irq, int slot, __u32 paddr, __u32 vaddr)
+		int irq, int slot, __u32 paddr, void __iomem *vaddr)
 {
 	struct ncr_device device;
 	__u8 scsi_id;
@@ -146,7 +146,7 @@
 	__u8 pos2, pos4, asr2, asr9, asr10;
 	__u16 io_base;
 	__u32 base_addr, mem_size;
-	__u32 mem_base;
+	void __iomem *mem_base;
 
 	p = kmalloc(sizeof(*p), GFP_KERNEL);
 	if (!p)
@@ -227,7 +227,7 @@
 	 */
 	mem_base = (__u32)dma_mark_declared_memory_occupied(dev, base_addr,
 							    1024);
-	if (IS_ERR((void *)mem_base)) {
+	if (IS_ERR(mem_base)) {
 		printk("NCR_Q720 failed to reserve memory mapped region\n");
 		goto out_release;
 	}
@@ -271,7 +271,7 @@
 	}
 	/* disable all the siop interrupts */
 	for(i = 0; i < siops; i++) {
-		__u32 reg_scsr1 = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET
+		void __iomem *reg_scsr1 = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET
 			+ i*NCR_Q720_SIOP_SHIFT + NCR_Q720_SCSR_OFFSET + 1;
 		__u8 scsr1 = readb(reg_scsr1);
 		scsr1 |= 0x01;
@@ -280,7 +280,7 @@
 
 	/* plumb in all 720 chips */
 	for (i = 0; i < siops; i++) {
-		__u32 siop_v_base = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET
+		void __iomem *siop_v_base = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET
 			+ i*NCR_Q720_SIOP_SHIFT;
 		__u32 siop_p_base = base_addr + NCR_Q720_CHIP_REGISTER_OFFSET
 			+ i*NCR_Q720_SIOP_SHIFT;
@@ -358,13 +358,19 @@
 static int __init
 NCR_Q720_init(void)
 {
-	return mca_register_driver(&NCR_Q720_driver);
+	int ret = ncr53c8xx_init();
+	if (!ret)
+		ret = mca_register_driver(&NCR_Q720_driver);
+	if (ret)
+		ncr53c8xx_exit();
+	return ret;
 }
 
 static void __exit
 NCR_Q720_exit(void)
 {
 	mca_unregister_driver(&NCR_Q720_driver);
+	ncr53c8xx_exit();
 }
 
 module_init(NCR_Q720_init);
diff -Nru a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/a100u2w.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1202 @@
+/*
+ * Initio A100 device driver for Linux.
+ *
+ * Copyright (c) 1994-1998 Initio Corporation
+ * Copyright (c) 2003-2004 Christoph Hellwig
+ * 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, 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; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Where this Software is combined with software released under the terms of 
+ * the GNU General Public License ("GPL") and the terms of the GPL would require the 
+ * combined work to also be released under the terms of the GPL, the terms
+ * and conditions of this License will apply in addition to those of the
+ * GPL with the exception of any terms or conditions of this License that
+ * conflict with, or are expressly prohibited by, the GPL.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ */
+
+/*
+ * Revision History:
+ * 07/02/98 hl	- v.91n Initial drivers.
+ * 09/14/98 hl - v1.01 Support new Kernel.
+ * 09/22/98 hl - v1.01a Support reset.
+ * 09/24/98 hl - v1.01b Fixed reset.
+ * 10/05/98 hl - v1.02 split the source code and release.
+ * 12/19/98 bv - v1.02a Use spinlocks for 2.1.95 and up
+ * 01/31/99 bv - v1.02b Use mdelay instead of waitForPause
+ * 08/08/99 bv - v1.02c Use waitForPause again.
+ * 06/25/02 Doug Ledford <dledford@redhat.com> - v1.02d
+ *          - Remove limit on number of controllers
+ *          - Port to DMA mapping API
+ *          - Clean up interrupt handler registration
+ *          - Fix memory leaks
+ *          - Fix allocation of scsi host structs and private data
+ * 11/18/03 Christoph Hellwig <hch@lst.de>
+ *	    - Port to new probing API
+ *	    - Fix some more leaks in init failure cases
+ * 9/28/04 Christoph Hellwig <hch@lst.de>
+ *	    - merge the two source files
+ *	    - remove internal queueing code
+ */
+
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/blkdev.h>
+#include <linux/spinlock.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+
+#include "a100u2w.h"
+
+
+#define JIFFIES_TO_MS(t) ((t) * 1000 / HZ)
+#define MS_TO_JIFFIES(j) ((j * HZ) / 1000)
+
+static ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp);
+static void inia100SCBPost(BYTE * pHcb, BYTE * pScb);
+
+static NVRAM nvram, *nvramp = &nvram;
+static UCHAR dftNvRam[64] =
+{
+/*----------header -------------*/
+	0x01,			/* 0x00: Sub System Vendor ID 0 */
+	0x11,			/* 0x01: Sub System Vendor ID 1 */
+	0x60,			/* 0x02: Sub System ID 0        */
+	0x10,			/* 0x03: Sub System ID 1        */
+	0x00,			/* 0x04: SubClass               */
+	0x01,			/* 0x05: Vendor ID 0            */
+	0x11,			/* 0x06: Vendor ID 1            */
+	0x60,			/* 0x07: Device ID 0            */
+	0x10,			/* 0x08: Device ID 1            */
+	0x00,			/* 0x09: Reserved               */
+	0x00,			/* 0x0A: Reserved               */
+	0x01,			/* 0x0B: Revision of Data Structure     */
+				/* -- Host Adapter Structure --- */
+	0x01,			/* 0x0C: Number Of SCSI Channel */
+	0x01,			/* 0x0D: BIOS Configuration 1   */
+	0x00,			/* 0x0E: BIOS Configuration 2   */
+	0x00,			/* 0x0F: BIOS Configuration 3   */
+				/* --- SCSI Channel 0 Configuration --- */
+	0x07,			/* 0x10: H/A ID                 */
+	0x83,			/* 0x11: Channel Configuration  */
+	0x20,			/* 0x12: MAX TAG per target     */
+	0x0A,			/* 0x13: SCSI Reset Recovering time     */
+	0x00,			/* 0x14: Channel Configuration4 */
+	0x00,			/* 0x15: Channel Configuration5 */
+				/* SCSI Channel 0 Target Configuration  */
+				/* 0x16-0x25                    */
+	0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
+	0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
+				/* --- SCSI Channel 1 Configuration --- */
+	0x07,			/* 0x26: H/A ID                 */
+	0x83,			/* 0x27: Channel Configuration  */
+	0x20,			/* 0x28: MAX TAG per target     */
+	0x0A,			/* 0x29: SCSI Reset Recovering time     */
+	0x00,			/* 0x2A: Channel Configuration4 */
+	0x00,			/* 0x2B: Channel Configuration5 */
+				/* SCSI Channel 1 Target Configuration  */
+				/* 0x2C-0x3B                    */
+	0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
+	0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
+	0x00,			/* 0x3C: Reserved               */
+	0x00,			/* 0x3D: Reserved               */
+	0x00,			/* 0x3E: Reserved               */
+	0x00			/* 0x3F: Checksum               */
+};
+
+
+/***************************************************************************/
+static void waitForPause(unsigned amount)
+{
+	ULONG the_time = jiffies + MS_TO_JIFFIES(amount);
+	while (time_before_eq(jiffies, the_time))
+		cpu_relax();
+}
+
+/***************************************************************************/
+static UCHAR waitChipReady(ORC_HCS * hcsp)
+{
+	int i;
+
+	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
+		if (ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & HOSTSTOP)	/* Wait HOSTSTOP set */
+			return 1;
+		waitForPause(100);	/* wait 100ms before try again  */
+	}
+	return 0;
+}
+
+/***************************************************************************/
+static UCHAR waitFWReady(ORC_HCS * hcsp)
+{
+	int i;
+
+	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
+		if (ORC_RD(hcsp->HCS_Base, ORC_HSTUS) & RREADY)		/* Wait READY set */
+			return 1;
+		waitForPause(100);	/* wait 100ms before try again  */
+	}
+	return 0;
+}
+
+/***************************************************************************/
+static UCHAR waitSCSIRSTdone(ORC_HCS * hcsp)
+{
+	int i;
+
+	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
+		if (!(ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & SCSIRST))	/* Wait SCSIRST done */
+			return 1;
+		waitForPause(100);	/* wait 100ms before try again  */
+	}
+	return 0;
+}
+
+/***************************************************************************/
+static UCHAR waitHDOoff(ORC_HCS * hcsp)
+{
+	int i;
+
+	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
+		if (!(ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & HDO))		/* Wait HDO off */
+			return 1;
+		waitForPause(100);	/* wait 100ms before try again  */
+	}
+	return 0;
+}
+
+/***************************************************************************/
+static UCHAR waitHDIset(ORC_HCS * hcsp, UCHAR * pData)
+{
+	int i;
+
+	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
+		if ((*pData = ORC_RD(hcsp->HCS_Base, ORC_HSTUS)) & HDI)
+			return 1;	/* Wait HDI set */
+		waitForPause(100);	/* wait 100ms before try again  */
+	}
+	return 0;
+}
+
+/***************************************************************************/
+static unsigned short get_FW_version(ORC_HCS * hcsp)
+{
+	UCHAR bData;
+	union {
+		unsigned short sVersion;
+		unsigned char cVersion[2];
+	} Version;
+
+	ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_VERSION);
+	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
+	if (waitHDOoff(hcsp) == 0)	/* Wait HDO off   */
+		return 0;
+
+	if (waitHDIset(hcsp, &bData) == 0)	/* Wait HDI set   */
+		return 0;
+	Version.cVersion[0] = ORC_RD(hcsp->HCS_Base, ORC_HDATA);
+	ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData);	/* Clear HDI            */
+
+	if (waitHDIset(hcsp, &bData) == 0)	/* Wait HDI set   */
+		return 0;
+	Version.cVersion[1] = ORC_RD(hcsp->HCS_Base, ORC_HDATA);
+	ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData);	/* Clear HDI            */
+
+	return (Version.sVersion);
+}
+
+/***************************************************************************/
+static UCHAR set_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char value)
+{
+	ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_SET_NVM);	/* Write command */
+	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
+	if (waitHDOoff(hcsp) == 0)	/* Wait HDO off   */
+		return 0;
+
+	ORC_WR(hcsp->HCS_Base + ORC_HDATA, address);	/* Write address */
+	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
+	if (waitHDOoff(hcsp) == 0)	/* Wait HDO off   */
+		return 0;
+
+	ORC_WR(hcsp->HCS_Base + ORC_HDATA, value);	/* Write value  */
+	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
+	if (waitHDOoff(hcsp) == 0)	/* Wait HDO off   */
+		return 0;
+
+	return 1;
+}
+
+/***************************************************************************/
+static UCHAR get_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char *pDataIn)
+{
+	unsigned char bData;
+
+	ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_GET_NVM);	/* Write command */
+	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
+	if (waitHDOoff(hcsp) == 0)	/* Wait HDO off   */
+		return 0;
+
+	ORC_WR(hcsp->HCS_Base + ORC_HDATA, address);	/* Write address */
+	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
+	if (waitHDOoff(hcsp) == 0)	/* Wait HDO off   */
+		return 0;
+
+	if (waitHDIset(hcsp, &bData) == 0)	/* Wait HDI set   */
+		return 0;
+	*pDataIn = ORC_RD(hcsp->HCS_Base, ORC_HDATA);
+	ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData);	/* Clear HDI    */
+
+	return 1;
+}
+
+/***************************************************************************/
+static void orc_exec_scb(ORC_HCS * hcsp, ORC_SCB * scbp)
+{
+	scbp->SCB_Status = ORCSCB_POST;
+	ORC_WR(hcsp->HCS_Base + ORC_PQUEUE, scbp->SCB_ScbIdx);
+	return;
+}
+
+
+/***********************************************************************
+ Read SCSI H/A configuration parameters from serial EEPROM
+************************************************************************/
+static int se2_rd_all(ORC_HCS * hcsp)
+{
+	int i;
+	UCHAR *np, chksum = 0;
+
+	np = (UCHAR *) nvramp;
+	for (i = 0; i < 64; i++, np++) {	/* <01> */
+		if (get_NVRAM(hcsp, (unsigned char) i, np) == 0)
+			return -1;
+//      *np++ = get_NVRAM(hcsp, (unsigned char ) i);
+	}
+
+/*------ Is ckecksum ok ? ------*/
+	np = (UCHAR *) nvramp;
+	for (i = 0; i < 63; i++)
+		chksum += *np++;
+
+	if (nvramp->CheckSum != (UCHAR) chksum)
+		return -1;
+	return 1;
+}
+
+/************************************************************************
+ Update SCSI H/A configuration parameters from serial EEPROM
+*************************************************************************/
+static void se2_update_all(ORC_HCS * hcsp)
+{				/* setup default pattern  */
+	int i;
+	UCHAR *np, *np1, chksum = 0;
+
+	/* Calculate checksum first   */
+	np = (UCHAR *) dftNvRam;
+	for (i = 0; i < 63; i++)
+		chksum += *np++;
+	*np = chksum;
+
+	np = (UCHAR *) dftNvRam;
+	np1 = (UCHAR *) nvramp;
+	for (i = 0; i < 64; i++, np++, np1++) {
+		if (*np != *np1) {
+			set_NVRAM(hcsp, (unsigned char) i, *np);
+		}
+	}
+	return;
+}
+
+/*************************************************************************
+ Function name  : read_eeprom
+**************************************************************************/
+static void read_eeprom(ORC_HCS * hcsp)
+{
+	if (se2_rd_all(hcsp) != 1) {
+		se2_update_all(hcsp);	/* setup default pattern        */
+		se2_rd_all(hcsp);	/* load again                   */
+	}
+}
+
+
+/***************************************************************************/
+static UCHAR load_FW(ORC_HCS * hcsp)
+{
+	U32 dData;
+	USHORT wBIOSAddress;
+	USHORT i;
+	UCHAR *pData, bData;
+
+
+	bData = ORC_RD(hcsp->HCS_Base, ORC_GCFG);
+	ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData | EEPRG);	/* Enable EEPROM programming */
+	ORC_WR(hcsp->HCS_Base + ORC_EBIOSADR2, 0x00);
+	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x00);
+	if (ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA) != 0x55) {
+		ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData);	/* Disable EEPROM programming */
+		return 0;
+	}
+	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x01);
+	if (ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA) != 0xAA) {
+		ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData);	/* Disable EEPROM programming */
+		return 0;
+	}
+	ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST | DOWNLOAD);	/* Enable SRAM programming */
+	pData = (UCHAR *) & dData;
+	dData = 0;		/* Initial FW address to 0 */
+	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x10);
+	*pData = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);		/* Read from BIOS */
+	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x11);
+	*(pData + 1) = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);	/* Read from BIOS */
+	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x12);
+	*(pData + 2) = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);	/* Read from BIOS */
+	ORC_WR(hcsp->HCS_Base + ORC_EBIOSADR2, *(pData + 2));
+	ORC_WRLONG(hcsp->HCS_Base + ORC_FWBASEADR, dData);	/* Write FW address */
+
+	wBIOSAddress = (USHORT) dData;	/* FW code locate at BIOS address + ? */
+	for (i = 0, pData = (UCHAR *) & dData;	/* Download the code    */
+	     i < 0x1000;	/* Firmware code size = 4K      */
+	     i++, wBIOSAddress++) {
+		ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, wBIOSAddress);
+		*pData++ = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);	/* Read from BIOS */
+		if ((i % 4) == 3) {
+			ORC_WRLONG(hcsp->HCS_Base + ORC_RISCRAM, dData);	/* Write every 4 bytes */
+			pData = (UCHAR *) & dData;
+		}
+	}
+
+	ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST | DOWNLOAD);	/* Reset program count 0 */
+	wBIOSAddress -= 0x1000;	/* Reset the BIOS adddress      */
+	for (i = 0, pData = (UCHAR *) & dData;	/* Check the code       */
+	     i < 0x1000;	/* Firmware code size = 4K      */
+	     i++, wBIOSAddress++) {
+		ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, wBIOSAddress);
+		*pData++ = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);	/* Read from BIOS */
+		if ((i % 4) == 3) {
+			if (ORC_RDLONG(hcsp->HCS_Base, ORC_RISCRAM) != dData) {
+				ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST);	/* Reset program to 0 */
+				ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData);	/*Disable EEPROM programming */
+				return 0;
+			}
+			pData = (UCHAR *) & dData;
+		}
+	}
+	ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST);	/* Reset program to 0   */
+	ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData);	/* Disable EEPROM programming */
+	return 1;
+}
+
+/***************************************************************************/
+static void setup_SCBs(ORC_HCS * hcsp)
+{
+	ORC_SCB *pVirScb;
+	int i;
+	ESCB *pVirEscb;
+	dma_addr_t pPhysEscb;
+
+	/* Setup SCB HCS_Base and SCB Size registers */
+	ORC_WR(hcsp->HCS_Base + ORC_SCBSIZE, ORC_MAXQUEUE);	/* Total number of SCBs */
+	/* SCB HCS_Base address 0      */
+	ORC_WRLONG(hcsp->HCS_Base + ORC_SCBBASE0, hcsp->HCS_physScbArray);
+	/* SCB HCS_Base address 1      */
+	ORC_WRLONG(hcsp->HCS_Base + ORC_SCBBASE1, hcsp->HCS_physScbArray);
+
+	/* setup scatter list address with one buffer */
+	pVirScb = hcsp->HCS_virScbArray;
+	pVirEscb = hcsp->HCS_virEscbArray;
+
+	for (i = 0; i < ORC_MAXQUEUE; i++) {
+		pPhysEscb = (hcsp->HCS_physEscbArray + (sizeof(ESCB) * i));
+		pVirScb->SCB_SGPAddr = (U32) pPhysEscb;
+		pVirScb->SCB_SensePAddr = (U32) pPhysEscb;
+		pVirScb->SCB_EScb = pVirEscb;
+		pVirScb->SCB_ScbIdx = i;
+		pVirScb++;
+		pVirEscb++;
+	}
+
+	return;
+}
+
+/***************************************************************************/
+static void initAFlag(ORC_HCS * hcsp)
+{
+	UCHAR i, j;
+
+	for (i = 0; i < MAX_CHANNELS; i++) {
+		for (j = 0; j < 8; j++) {
+			hcsp->BitAllocFlag[i][j] = 0xffffffff;
+		}
+	}
+}
+
+/***************************************************************************/
+static int init_orchid(ORC_HCS * hcsp)
+{
+	UBYTE *readBytep;
+	USHORT revision;
+	UCHAR i;
+
+	initAFlag(hcsp);
+	ORC_WR(hcsp->HCS_Base + ORC_GIMSK, 0xFF);	/* Disable all interrupt        */
+	if (ORC_RD(hcsp->HCS_Base, ORC_HSTUS) & RREADY) {	/* Orchid is ready              */
+		revision = get_FW_version(hcsp);
+		if (revision == 0xFFFF) {
+			ORC_WR(hcsp->HCS_Base + ORC_HCTRL, DEVRST);	/* Reset Host Adapter   */
+			if (waitChipReady(hcsp) == 0)
+				return (-1);
+			load_FW(hcsp);	/* Download FW                  */
+			setup_SCBs(hcsp);	/* Setup SCB HCS_Base and SCB Size registers */
+			ORC_WR(hcsp->HCS_Base + ORC_HCTRL, 0);	/* clear HOSTSTOP       */
+			if (waitFWReady(hcsp) == 0)
+				return (-1);
+			/* Wait for firmware ready     */
+		} else {
+			setup_SCBs(hcsp);	/* Setup SCB HCS_Base and SCB Size registers */
+		}
+	} else {		/* Orchid is not Ready          */
+		ORC_WR(hcsp->HCS_Base + ORC_HCTRL, DEVRST);	/* Reset Host Adapter   */
+		if (waitChipReady(hcsp) == 0)
+			return (-1);
+		load_FW(hcsp);	/* Download FW                  */
+		setup_SCBs(hcsp);	/* Setup SCB HCS_Base and SCB Size registers */
+		ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);	/* Do Hardware Reset &  */
+
+		/*     clear HOSTSTOP  */
+		if (waitFWReady(hcsp) == 0)		/* Wait for firmware ready      */
+			return (-1);
+	}
+
+/*------------- get serial EEProm settting -------*/
+
+	read_eeprom(hcsp);
+
+	if (nvramp->Revision != 1)
+		return (-1);
+
+	hcsp->HCS_SCSI_ID = nvramp->SCSI0Id;
+	hcsp->HCS_BIOS = nvramp->BIOSConfig1;
+	hcsp->HCS_MaxTar = MAX_TARGETS;
+	readBytep = (UCHAR *) & (nvramp->Target00Config);
+	for (i = 0; i < 16; readBytep++, i++) {
+		hcsp->TargetFlag[i] = *readBytep;
+		hcsp->MaximumTags[i] = ORC_MAXTAGS;
+	}			/* for                          */
+
+	if (nvramp->SCSI0Config & NCC_BUSRESET) {	/* Reset SCSI bus               */
+		hcsp->HCS_Flags |= HCF_SCSI_RESET;
+	}
+	ORC_WR(hcsp->HCS_Base + ORC_GIMSK, 0xFB);	/* enable RP FIFO interrupt     */
+	return (0);
+}
+
+/*****************************************************************************
+ Function name  : orc_reset_scsi_bus
+ Description    : Reset registers, reset a hanging bus and
+                  kill active and disconnected commands for target w/o soft reset
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static int orc_reset_scsi_bus(ORC_HCS * pHCB)
+{				/* I need Host Control Block Information */
+	ULONG flags;
+
+	spin_lock_irqsave(&(pHCB->BitAllocFlagLock), flags);
+
+	initAFlag(pHCB);
+	/* reset scsi bus */
+	ORC_WR(pHCB->HCS_Base + ORC_HCTRL, SCSIRST);
+	if (waitSCSIRSTdone(pHCB) == 0) {
+		spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
+		return FAILED;
+	} else {
+		spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
+		return SUCCESS;
+	}
+}
+
+/*****************************************************************************
+ Function name  : orc_device_reset
+ Description    : Reset registers, reset a hanging bus and
+                  kill active and disconnected commands for target w/o soft reset
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static int orc_device_reset(ORC_HCS * pHCB, struct scsi_cmnd *SCpnt, unsigned int target)
+{				/* I need Host Control Block Information */
+	ORC_SCB *pScb;
+	ESCB *pVirEscb;
+	ORC_SCB *pVirScb;
+	UCHAR i;
+	ULONG flags;
+
+	spin_lock_irqsave(&(pHCB->BitAllocFlagLock), flags);
+	pScb = (ORC_SCB *) NULL;
+	pVirEscb = (ESCB *) NULL;
+
+	/* setup scatter list address with one buffer */
+	pVirScb = pHCB->HCS_virScbArray;
+
+	initAFlag(pHCB);
+	/* device reset */
+	for (i = 0; i < ORC_MAXQUEUE; i++) {
+		pVirEscb = pVirScb->SCB_EScb;
+		if ((pVirScb->SCB_Status) && (pVirEscb->SCB_Srb == SCpnt))
+			break;
+		pVirScb++;
+	}
+
+	if (i == ORC_MAXQUEUE) {
+		printk("Unable to Reset - No SCB Found\n");
+		spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
+		return FAILED;
+	}
+	if ((pScb = orc_alloc_scb(pHCB)) == NULL) {
+		spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
+		return FAILED;
+	}
+	pScb->SCB_Opcode = ORC_BUSDEVRST;
+	pScb->SCB_Target = target;
+	pScb->SCB_HaStat = 0;
+	pScb->SCB_TaStat = 0;
+	pScb->SCB_Status = 0x0;
+	pScb->SCB_Link = 0xFF;
+	pScb->SCB_Reserved0 = 0;
+	pScb->SCB_Reserved1 = 0;
+	pScb->SCB_XferLen = 0;
+	pScb->SCB_SGLen = 0;
+
+	pVirEscb->SCB_Srb = NULL;
+	pVirEscb->SCB_Srb = SCpnt;
+	orc_exec_scb(pHCB, pScb);	/* Start execute SCB            */
+	spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
+	return SUCCESS;
+}
+
+
+/***************************************************************************/
+static ORC_SCB *__orc_alloc_scb(ORC_HCS * hcsp)
+{
+	ORC_SCB *pTmpScb;
+	UCHAR Ch;
+	ULONG idx;
+	UCHAR index;
+	UCHAR i;
+
+	Ch = hcsp->HCS_Index;
+	for (i = 0; i < 8; i++) {
+		for (index = 0; index < 32; index++) {
+			if ((hcsp->BitAllocFlag[Ch][i] >> index) & 0x01) {
+				hcsp->BitAllocFlag[Ch][i] &= ~(1 << index);
+				break;
+			}
+		}
+		idx = index + 32 * i;
+		pTmpScb = (ORC_SCB *) ((ULONG) hcsp->HCS_virScbArray + (idx * sizeof(ORC_SCB)));
+		return (pTmpScb);
+	}
+	return (NULL);
+}
+
+static ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp)
+{
+	ORC_SCB *pTmpScb;
+	ULONG flags;
+
+	spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags);
+	pTmpScb = __orc_alloc_scb(hcsp);
+	spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
+	return (pTmpScb);
+}
+
+
+/***************************************************************************/
+static void orc_release_scb(ORC_HCS * hcsp, ORC_SCB * scbp)
+{
+	ULONG flags;
+	UCHAR Index;
+	UCHAR i;
+	UCHAR Ch;
+
+	spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags);
+	Ch = hcsp->HCS_Index;
+	Index = scbp->SCB_ScbIdx;
+	i = Index / 32;
+	Index %= 32;
+	hcsp->BitAllocFlag[Ch][i] |= (1 << Index);
+	spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
+}
+
+/*****************************************************************************
+ Function name  : abort_SCB
+ Description    : Abort a queued command.
+	                 (commands that are on the bus can't be aborted easily)
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static int abort_SCB(ORC_HCS * hcsp, ORC_SCB * pScb)
+{
+	unsigned char bData, bStatus;
+
+	ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_ABORT_SCB);	/* Write command */
+	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
+	if (waitHDOoff(hcsp) == 0)	/* Wait HDO off   */
+		return 0;
+
+	ORC_WR(hcsp->HCS_Base + ORC_HDATA, pScb->SCB_ScbIdx);	/* Write address */
+	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
+	if (waitHDOoff(hcsp) == 0)	/* Wait HDO off   */
+		return 0;
+
+	if (waitHDIset(hcsp, &bData) == 0)	/* Wait HDI set   */
+		return 0;
+	bStatus = ORC_RD(hcsp->HCS_Base, ORC_HDATA);
+	ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData);	/* Clear HDI    */
+
+	if (bStatus == 1)	/* 0 - Successfully               */
+		return 0;	/* 1 - Fail                     */
+	return 1;
+}
+
+/*****************************************************************************
+ Function name  : inia100_abort
+ Description    : Abort a queued command.
+	                 (commands that are on the bus can't be aborted easily)
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static int orc_abort_srb(ORC_HCS * hcsp, struct scsi_cmnd *SCpnt)
+{
+	ESCB *pVirEscb;
+	ORC_SCB *pVirScb;
+	UCHAR i;
+	ULONG flags;
+
+	spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags);
+
+	pVirScb = hcsp->HCS_virScbArray;
+
+	for (i = 0; i < ORC_MAXQUEUE; i++, pVirScb++) {
+		pVirEscb = pVirScb->SCB_EScb;
+		if ((pVirScb->SCB_Status) && (pVirEscb->SCB_Srb == SCpnt)) {
+			if (pVirScb->SCB_TagMsg == 0) {
+				spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
+				return FAILED;
+			} else {
+				if (abort_SCB(hcsp, pVirScb)) {
+					pVirEscb->SCB_Srb = NULL;
+					spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
+					return SUCCESS;
+				} else {
+					spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
+					return FAILED;
+				}
+			}
+		}
+	}
+	spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
+	return FAILED;
+}
+
+/***********************************************************************
+ Routine Description:
+	  This is the interrupt service routine for the Orchid SCSI adapter.
+	  It reads the interrupt register to determine if the adapter is indeed
+	  the source of the interrupt and clears the interrupt at the device.
+ Arguments:
+	  HwDeviceExtension - HBA miniport driver's adapter data storage
+ Return Value:
+***********************************************************************/
+static void orc_interrupt(
+			  ORC_HCS * hcsp
+)
+{
+	BYTE bScbIdx;
+	ORC_SCB *pScb;
+
+	if (ORC_RD(hcsp->HCS_Base, ORC_RQUEUECNT) == 0) {
+		return;		// 0;
+
+	}
+	do {
+		bScbIdx = ORC_RD(hcsp->HCS_Base, ORC_RQUEUE);
+
+		pScb = (ORC_SCB *) ((ULONG) hcsp->HCS_virScbArray + (ULONG) (sizeof(ORC_SCB) * bScbIdx));
+		pScb->SCB_Status = 0x0;
+
+		inia100SCBPost((BYTE *) hcsp, (BYTE *) pScb);
+	} while (ORC_RD(hcsp->HCS_Base, ORC_RQUEUECNT));
+	return;			//1;
+
+}				/* End of I1060Interrupt() */
+
+/*****************************************************************************
+ Function name  : inia100BuildSCB
+ Description    : 
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static void inia100BuildSCB(ORC_HCS * pHCB, ORC_SCB * pSCB, struct scsi_cmnd * SCpnt)
+{				/* Create corresponding SCB     */
+	struct scatterlist *pSrbSG;
+	ORC_SG *pSG;		/* Pointer to SG list           */
+	int i, count_sg;
+	ESCB *pEScb;
+
+	pEScb = pSCB->SCB_EScb;
+	pEScb->SCB_Srb = SCpnt;
+	pSG = NULL;
+
+	pSCB->SCB_Opcode = ORC_EXECSCSI;
+	pSCB->SCB_Flags = SCF_NO_DCHK;	/* Clear done bit               */
+	pSCB->SCB_Target = SCpnt->device->id;
+	pSCB->SCB_Lun = SCpnt->device->lun;
+	pSCB->SCB_Reserved0 = 0;
+	pSCB->SCB_Reserved1 = 0;
+	pSCB->SCB_SGLen = 0;
+
+	if ((pSCB->SCB_XferLen = (U32) SCpnt->request_bufflen)) {
+		pSG = (ORC_SG *) & pEScb->ESCB_SGList[0];
+		if (SCpnt->use_sg) {
+			pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
+			count_sg = pci_map_sg(pHCB->pdev, pSrbSG, SCpnt->use_sg,
+					SCpnt->sc_data_direction);
+			pSCB->SCB_SGLen = (U32) (count_sg * 8);
+			for (i = 0; i < count_sg; i++, pSG++, pSrbSG++) {
+				pSG->SG_Ptr = (U32) sg_dma_address(pSrbSG);
+				pSG->SG_Len = (U32) sg_dma_len(pSrbSG);
+			}
+		} else if (SCpnt->request_bufflen != 0) {/* Non SG */
+			pSCB->SCB_SGLen = 0x8;
+			SCpnt->SCp.dma_handle = pci_map_single(pHCB->pdev,
+					SCpnt->request_buffer,
+					SCpnt->request_bufflen,
+					SCpnt->sc_data_direction);
+			pSG->SG_Ptr = (U32) SCpnt->SCp.dma_handle;
+			pSG->SG_Len = (U32) SCpnt->request_bufflen;
+		} else {
+			pSCB->SCB_SGLen = 0;
+			pSG->SG_Ptr = 0;
+			pSG->SG_Len = 0;
+		}
+	}
+	pSCB->SCB_SGPAddr = (U32) pSCB->SCB_SensePAddr;
+	pSCB->SCB_HaStat = 0;
+	pSCB->SCB_TaStat = 0;
+	pSCB->SCB_Link = 0xFF;
+	pSCB->SCB_SenseLen = SENSE_SIZE;
+	pSCB->SCB_CDBLen = SCpnt->cmd_len;
+	if (pSCB->SCB_CDBLen >= IMAX_CDB) {
+		printk("max cdb length= %x\b", SCpnt->cmd_len);
+		pSCB->SCB_CDBLen = IMAX_CDB;
+	}
+	pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW;
+	if (SCpnt->device->tagged_supported) {	/* Tag Support                  */
+		pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG;	/* Do simple tag only   */
+	} else {
+		pSCB->SCB_TagMsg = 0;	/* No tag support               */
+	}
+	memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, pSCB->SCB_CDBLen);
+	return;
+}
+
+/*****************************************************************************
+ Function name  : inia100_queue
+ Description    : Queue a command and setup interrupts for a free bus.
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static int inia100_queue(struct scsi_cmnd * SCpnt, void (*done) (struct scsi_cmnd *))
+{
+	register ORC_SCB *pSCB;
+	ORC_HCS *pHCB;		/* Point to Host adapter control block */
+
+	pHCB = (ORC_HCS *) SCpnt->device->host->hostdata;
+	SCpnt->scsi_done = done;
+	/* Get free SCSI control block  */
+	if ((pSCB = orc_alloc_scb(pHCB)) == NULL)
+		return SCSI_MLQUEUE_HOST_BUSY;
+
+	inia100BuildSCB(pHCB, pSCB, SCpnt);
+	orc_exec_scb(pHCB, pSCB);	/* Start execute SCB            */
+
+	return (0);
+}
+
+/*****************************************************************************
+ Function name  : inia100_abort
+ Description    : Abort a queued command.
+	                 (commands that are on the bus can't be aborted easily)
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static int inia100_abort(struct scsi_cmnd * SCpnt)
+{
+	ORC_HCS *hcsp;
+
+	hcsp = (ORC_HCS *) SCpnt->device->host->hostdata;
+	return orc_abort_srb(hcsp, SCpnt);
+}
+
+/*****************************************************************************
+ Function name  : inia100_reset
+ Description    : Reset registers, reset a hanging bus and
+                  kill active and disconnected commands for target w/o soft reset
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static int inia100_bus_reset(struct scsi_cmnd * SCpnt)
+{				/* I need Host Control Block Information */
+	ORC_HCS *pHCB;
+	pHCB = (ORC_HCS *) SCpnt->device->host->hostdata;
+	return orc_reset_scsi_bus(pHCB);
+}
+
+/*****************************************************************************
+ Function name  : inia100_device_reset
+ Description    : Reset the device
+ Input          : pHCB  -       Pointer to host adapter structure
+ Output         : None.
+ Return         : pSRB  -       Pointer to SCSI request block.
+*****************************************************************************/
+static int inia100_device_reset(struct scsi_cmnd * SCpnt)
+{				/* I need Host Control Block Information */
+	ORC_HCS *pHCB;
+	pHCB = (ORC_HCS *) SCpnt->device->host->hostdata;
+	return orc_device_reset(pHCB, SCpnt, SCpnt->device->id);
+
+}
+
+/*****************************************************************************
+ Function name  : inia100SCBPost
+ Description    : This is callback routine be called when orc finish one
+			SCSI command.
+ Input          : pHCB  -       Pointer to host adapter control block.
+		  pSCB  -       Pointer to SCSI control block.
+ Output         : None.
+ Return         : None.
+*****************************************************************************/
+static void inia100SCBPost(BYTE * pHcb, BYTE * pScb)
+{
+	struct scsi_cmnd *pSRB;	/* Pointer to SCSI request block */
+	ORC_HCS *pHCB;
+	ORC_SCB *pSCB;
+	ESCB *pEScb;
+
+	pHCB = (ORC_HCS *) pHcb;
+	pSCB = (ORC_SCB *) pScb;
+	pEScb = pSCB->SCB_EScb;
+	if ((pSRB = (struct scsi_cmnd *) pEScb->SCB_Srb) == 0) {
+		printk("inia100SCBPost: SRB pointer is empty\n");
+		orc_release_scb(pHCB, pSCB);	/* Release SCB for current channel */
+		return;
+	}
+	pEScb->SCB_Srb = NULL;
+
+	switch (pSCB->SCB_HaStat) {
+	case 0x0:
+	case 0xa:		/* Linked command complete without error and linked normally */
+	case 0xb:		/* Linked command complete without error interrupt generated */
+		pSCB->SCB_HaStat = 0;
+		break;
+
+	case 0x11:		/* Selection time out-The initiator selection or target
+				   reselection was not complete within the SCSI Time out period */
+		pSCB->SCB_HaStat = DID_TIME_OUT;
+		break;
+
+	case 0x14:		/* Target bus phase sequence failure-An invalid bus phase or bus
+				   phase sequence was requested by the target. The host adapter
+				   will generate a SCSI Reset Condition, notifying the host with
+				   a SCRD interrupt */
+		pSCB->SCB_HaStat = DID_RESET;
+		break;
+
+	case 0x1a:		/* SCB Aborted. 07/21/98 */
+		pSCB->SCB_HaStat = DID_ABORT;
+		break;
+
+	case 0x12:		/* Data overrun/underrun-The target attempted to transfer more data
+				   than was allocated by the Data Length field or the sum of the
+				   Scatter / Gather Data Length fields. */
+	case 0x13:		/* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
+	case 0x16:		/* Invalid CCB Operation Code-The first byte of the CCB was invalid. */
+
+	default:
+		printk("inia100: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat);
+		pSCB->SCB_HaStat = DID_ERROR;	/* Couldn't find any better */
+		break;
+	}
+
+	if (pSCB->SCB_TaStat == 2) {	/* Check condition              */
+		memcpy((unsigned char *) &pSRB->sense_buffer[0],
+		   (unsigned char *) &pEScb->ESCB_SGList[0], SENSE_SIZE);
+	}
+	pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16);
+
+	if (pSRB->use_sg) {
+		pci_unmap_sg(pHCB->pdev,
+			     (struct scatterlist *)pSRB->request_buffer,
+			     pSRB->use_sg, pSRB->sc_data_direction);
+	} else if (pSRB->request_bufflen != 0) {
+		pci_unmap_single(pHCB->pdev, pSRB->SCp.dma_handle,
+				 pSRB->request_bufflen,
+				 pSRB->sc_data_direction);
+	}
+
+	pSRB->scsi_done(pSRB);	/* Notify system DONE           */
+
+	orc_release_scb(pHCB, pSCB);	/* Release SCB for current channel */
+}
+
+/*
+ * Interrupt handler (main routine of the driver)
+ */
+static irqreturn_t inia100_intr(int irqno, void *devid, struct pt_regs *regs)
+{
+	struct Scsi_Host *host = (struct Scsi_Host *)devid;
+	ORC_HCS *pHcb = (ORC_HCS *)host->hostdata;
+	unsigned long flags;
+
+	spin_lock_irqsave(host->host_lock, flags);
+	orc_interrupt(pHcb);
+	spin_unlock_irqrestore(host->host_lock, flags);
+
+	return IRQ_HANDLED;
+}
+
+static struct scsi_host_template inia100_template = {
+	.proc_name		= "inia100",
+	.name			= inia100_REVID,
+	.queuecommand		= inia100_queue,
+	.eh_abort_handler	= inia100_abort,
+	.eh_bus_reset_handler	= inia100_bus_reset,
+	.eh_device_reset_handler = inia100_device_reset,
+	.can_queue		= 1,
+	.this_id		= 1,
+	.sg_tablesize		= SG_ALL,
+	.cmd_per_lun 		= 1,
+	.use_clustering		= ENABLE_CLUSTERING,
+};
+
+static int __devinit inia100_probe_one(struct pci_dev *pdev,
+		const struct pci_device_id *id)
+{
+	struct Scsi_Host *shost;
+	ORC_HCS *pHCB;
+	unsigned long port, bios;
+	int error = -ENODEV;
+	u32 sz;
+	unsigned long dBiosAdr;
+	char *pbBiosAdr;
+
+	if (pci_enable_device(pdev))
+		goto out;
+	if (pci_set_dma_mask(pdev, 0xffffffffULL)) {
+		printk(KERN_WARNING "Unable to set 32bit DMA "
+				    "on inia100 adapter, ignoring.\n");
+		goto out_disable_device;
+	}
+
+	pci_set_master(pdev);
+
+	port = pci_resource_start(pdev, 0);
+	if (!request_region(port, 256, "inia100")) {
+		printk(KERN_WARNING "inia100: io port 0x%lx, is busy.\n", port);
+		goto out_disable_device;
+	}
+
+	/* <02> read from base address + 0x50 offset to get the bios balue. */
+	bios = ORC_RDWORD(port, 0x50);
+
+
+	shost = scsi_host_alloc(&inia100_template, sizeof(ORC_HCS));
+	if (!shost)
+		goto out_release_region;
+
+	pHCB = (ORC_HCS *)shost->hostdata;
+	pHCB->pdev = pdev;
+	pHCB->HCS_Base = port;
+	pHCB->HCS_BIOS = bios;
+	spin_lock_init(&pHCB->BitAllocFlagLock);
+
+	/* Get total memory needed for SCB */
+	sz = ORC_MAXQUEUE * sizeof(ORC_SCB);
+	pHCB->HCS_virScbArray = pci_alloc_consistent(pdev, sz,
+			&pHCB->HCS_physScbArray);
+	if (!pHCB->HCS_virScbArray) {
+		printk("inia100: SCB memory allocation error\n");
+		goto out_host_put;
+	}
+	memset(pHCB->HCS_virScbArray, 0, sz);
+
+	/* Get total memory needed for ESCB */
+	sz = ORC_MAXQUEUE * sizeof(ESCB);
+	pHCB->HCS_virEscbArray = pci_alloc_consistent(pdev, sz,
+			&pHCB->HCS_physEscbArray);
+	if (!pHCB->HCS_virEscbArray) {
+		printk("inia100: ESCB memory allocation error\n");
+		goto out_free_scb_array;
+	}
+	memset(pHCB->HCS_virEscbArray, 0, sz);
+
+	dBiosAdr = pHCB->HCS_BIOS;
+	dBiosAdr = (dBiosAdr << 4);
+	pbBiosAdr = phys_to_virt(dBiosAdr);
+	if (init_orchid(pHCB)) {	/* Initialize orchid chip */
+		printk("inia100: initial orchid fail!!\n");
+		goto out_free_escb_array;
+	}
+
+	shost->io_port = pHCB->HCS_Base;
+	shost->n_io_port = 0xff;
+	shost->can_queue = ORC_MAXQUEUE;
+	shost->unique_id = shost->io_port;
+	shost->max_id = pHCB->HCS_MaxTar;
+	shost->max_lun = 16;
+	shost->irq = pHCB->HCS_Intr = pdev->irq;
+	shost->this_id = pHCB->HCS_SCSI_ID;	/* Assign HCS index */
+	shost->sg_tablesize = TOTAL_SG_ENTRY;
+
+	/* Initial orc chip           */
+	error = request_irq(pdev->irq, inia100_intr, SA_SHIRQ,
+			"inia100", shost);
+	if (error < 0) {
+		printk(KERN_WARNING "inia100: unable to get irq %d\n",
+				pdev->irq);
+		goto out_free_escb_array;
+	}
+
+	pci_set_drvdata(pdev, shost);
+
+	error = scsi_add_host(shost, &pdev->dev);
+	if (error)
+		goto out_free_irq;
+
+	scsi_scan_host(shost);
+	return 0;
+
+ out_free_irq:
+        free_irq(shost->irq, shost);
+ out_free_escb_array:
+	pci_free_consistent(pdev, ORC_MAXQUEUE * sizeof(ESCB),
+			pHCB->HCS_virEscbArray, pHCB->HCS_physEscbArray);
+ out_free_scb_array:
+	pci_free_consistent(pdev, ORC_MAXQUEUE * sizeof(ORC_SCB),
+			pHCB->HCS_virScbArray, pHCB->HCS_physScbArray);
+ out_host_put:
+	scsi_host_put(shost);
+ out_release_region:
+        release_region(port, 256);
+ out_disable_device:
+	pci_disable_device(pdev);
+ out:
+	return error;
+}
+
+static void __devexit inia100_remove_one(struct pci_dev *pdev)
+{
+	struct Scsi_Host *shost = pci_get_drvdata(pdev);
+	ORC_HCS *pHCB = (ORC_HCS *)shost->hostdata;
+
+	scsi_remove_host(shost);
+
+        free_irq(shost->irq, shost);
+	pci_free_consistent(pdev, ORC_MAXQUEUE * sizeof(ESCB),
+			pHCB->HCS_virEscbArray, pHCB->HCS_physEscbArray);
+	pci_free_consistent(pdev, ORC_MAXQUEUE * sizeof(ORC_SCB),
+			pHCB->HCS_virScbArray, pHCB->HCS_physScbArray);
+        release_region(shost->io_port, 256);
+
+	scsi_host_put(shost);
+} 
+
+static struct pci_device_id inia100_pci_tbl[] = {
+	{PCI_VENDOR_ID_INIT, 0x1060, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{0,}
+};
+MODULE_DEVICE_TABLE(pci, inia100_pci_tbl);
+
+static struct pci_driver inia100_pci_driver = {
+	.name		= "inia100",
+	.id_table	= inia100_pci_tbl,
+	.probe		= inia100_probe_one,
+	.remove		= __devexit_p(inia100_remove_one),
+};
+
+static int __init inia100_init(void)
+{
+	return pci_module_init(&inia100_pci_driver);
+}
+
+static void __exit inia100_exit(void)
+{
+	pci_unregister_driver(&inia100_pci_driver);
+}
+
+MODULE_DESCRIPTION("Initio A100U2W SCSI driver");
+MODULE_AUTHOR("Initio Corporation");
+MODULE_LICENSE("Dual BSD/GPL");
+
+module_init(inia100_init);
+module_exit(inia100_exit);
diff -Nru a/drivers/scsi/a100u2w.h b/drivers/scsi/a100u2w.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/a100u2w.h	2004-12-24 13:36:16 -08:00
@@ -0,0 +1,416 @@
+/*
+ * Initio A100 device driver for Linux.
+ *
+ * Copyright (c) 1994-1998 Initio Corporation
+ * 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, 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; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Where this Software is combined with software released under the terms of 
+ * the GNU General Public License ("GPL") and the terms of the GPL would require the 
+ * combined work to also be released under the terms of the GPL, the terms
+ * and conditions of this License will apply in addition to those of the
+ * GPL with the exception of any terms or conditions of this License that
+ * conflict with, or are expressly prohibited by, the GPL.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ */
+
+/*
+ * Revision History:
+ * 06/18/98 HL, Initial production Version 1.02
+ * 12/19/98 bv, Use spinlocks for 2.1.95 and up
+ * 06/25/02 Doug Ledford <dledford@redhat.com>
+ *	 - This and the i60uscsi.h file are almost identical,
+ *	   merged them into a single header used by both .c files.
+ */
+
+#define inia100_REVID "Initio INI-A100U2W SCSI device driver; Revision: 1.02d"
+
+#define ULONG   unsigned long
+#define USHORT  unsigned short
+#define UCHAR   unsigned char
+#define BYTE    unsigned char
+#define WORD    unsigned short
+#define DWORD   unsigned long
+#define UBYTE   unsigned char
+#define UWORD   unsigned short
+#define UDWORD  unsigned long
+#define U32     u32
+
+#if 1
+#define ORC_MAXQUEUE		245
+#define ORC_MAXTAGS		64
+#else
+#define ORC_MAXQUEUE		25
+#define ORC_MAXTAGS		8
+#endif
+
+#define TOTAL_SG_ENTRY		32
+#define MAX_TARGETS		16
+#define IMAX_CDB			15
+#define SENSE_SIZE		14
+
+/************************************************************************/
+/*              Scatter-Gather Element Structure                        */
+/************************************************************************/
+typedef struct ORC_SG_Struc {
+	U32 SG_Ptr;		/* Data Pointer */
+	U32 SG_Len;		/* Data Length */
+} ORC_SG;
+
+/* SCSI related definition                                              */
+#define DISC_NOT_ALLOW          0x80	/* Disconnect is not allowed    */
+#define DISC_ALLOW              0xC0	/* Disconnect is allowed        */
+
+
+#define ORC_OFFSET_SCB			16
+#define ORC_MAX_SCBS		    250
+#define MAX_CHANNELS       2
+#define MAX_ESCB_ELE				64
+#define TCF_DRV_255_63     0x0400
+
+/********************************************************/
+/*      Orchid Host Command Set                         */
+/********************************************************/
+#define ORC_CMD_NOP		0x00	/* Host command - NOP             */
+#define ORC_CMD_VERSION		0x01	/* Host command - Get F/W version */
+#define ORC_CMD_ECHO		0x02	/* Host command - ECHO            */
+#define ORC_CMD_SET_NVM		0x03	/* Host command - Set NVRAM       */
+#define ORC_CMD_GET_NVM		0x04	/* Host command - Get NVRAM       */
+#define ORC_CMD_GET_BUS_STATUS	0x05	/* Host command - Get SCSI bus status */
+#define ORC_CMD_ABORT_SCB	0x06	/* Host command - Abort SCB       */
+#define ORC_CMD_ISSUE_SCB	0x07	/* Host command - Issue SCB       */
+
+/********************************************************/
+/*              Orchid Register Set                     */
+/********************************************************/
+#define ORC_GINTS	0xA0	/* Global Interrupt Status        */
+#define QINT		0x04	/* Reply Queue Interrupt  */
+#define ORC_GIMSK	0xA1	/* Global Interrupt MASK  */
+#define MQINT		0x04	/* Mask Reply Queue Interrupt     */
+#define	ORC_GCFG	0xA2	/* Global Configure               */
+#define EEPRG		0x01	/* Enable EEPROM programming */
+#define	ORC_GSTAT	0xA3	/* Global status          */
+#define WIDEBUS		0x10	/* Wide SCSI Devices connected    */
+#define ORC_HDATA	0xA4	/* Host Data                      */
+#define ORC_HCTRL	0xA5	/* Host Control                   */
+#define SCSIRST		0x80	/* SCSI bus reset         */
+#define HDO			0x40	/* Host data out          */
+#define HOSTSTOP		0x02	/* Host stop RISC engine  */
+#define DEVRST		0x01	/* Device reset                   */
+#define ORC_HSTUS	0xA6	/* Host Status                    */
+#define HDI			0x02	/* Host data in                   */
+#define RREADY		0x01	/* RISC engine is ready to receive */
+#define	ORC_NVRAM	0xA7	/* Nvram port address             */
+#define SE2CS		0x008
+#define SE2CLK		0x004
+#define SE2DO		0x002
+#define SE2DI		0x001
+#define ORC_PQUEUE	0xA8	/* Posting queue FIFO             */
+#define ORC_PQCNT	0xA9	/* Posting queue FIFO Cnt */
+#define ORC_RQUEUE	0xAA	/* Reply queue FIFO               */
+#define ORC_RQUEUECNT	0xAB	/* Reply queue FIFO Cnt           */
+#define	ORC_FWBASEADR	0xAC	/* Firmware base address  */
+
+#define	ORC_EBIOSADR0 0xB0	/* External Bios address */
+#define	ORC_EBIOSADR1 0xB1	/* External Bios address */
+#define	ORC_EBIOSADR2 0xB2	/* External Bios address */
+#define	ORC_EBIOSDATA 0xB3	/* External Bios address */
+
+#define	ORC_SCBSIZE	0xB7	/* SCB size register              */
+#define	ORC_SCBBASE0	0xB8	/* SCB base address 0             */
+#define	ORC_SCBBASE1	0xBC	/* SCB base address 1             */
+
+#define	ORC_RISCCTL	0xE0	/* RISC Control                   */
+#define PRGMRST		0x002
+#define DOWNLOAD		0x001
+#define	ORC_PRGMCTR0	0xE2	/* RISC program counter           */
+#define	ORC_PRGMCTR1	0xE3	/* RISC program counter           */
+#define	ORC_RISCRAM	0xEC	/* RISC RAM data port 4 bytes     */
+
+typedef struct orc_extended_scb {	/* Extended SCB                 */
+	ORC_SG ESCB_SGList[TOTAL_SG_ENTRY];	/*0 Start of SG list              */
+	struct scsi_cmnd *SCB_Srb;	/*50 SRB Pointer */
+} ESCB;
+
+/***********************************************************************
+		SCSI Control Block
+************************************************************************/
+typedef struct orc_scb {	/* Scsi_Ctrl_Blk                */
+	UBYTE SCB_Opcode;	/*00 SCB command code&residual  */
+	UBYTE SCB_Flags;	/*01 SCB Flags                  */
+	UBYTE SCB_Target;	/*02 Target Id                  */
+	UBYTE SCB_Lun;		/*03 Lun                        */
+	U32 SCB_Reserved0;	/*04 Reserved for ORCHID must 0 */
+	U32 SCB_XferLen;	/*08 Data Transfer Length       */
+	U32 SCB_Reserved1;	/*0C Reserved for ORCHID must 0 */
+	U32 SCB_SGLen;		/*10 SG list # * 8              */
+	U32 SCB_SGPAddr;	/*14 SG List Buf physical Addr  */
+	U32 SCB_SGPAddrHigh;	/*18 SG Buffer high physical Addr */
+	UBYTE SCB_HaStat;	/*1C Host Status                */
+	UBYTE SCB_TaStat;	/*1D Target Status              */
+	UBYTE SCB_Status;	/*1E SCB status                 */
+	UBYTE SCB_Link;		/*1F Link pointer, default 0xFF */
+	UBYTE SCB_SenseLen;	/*20 Sense Allocation Length    */
+	UBYTE SCB_CDBLen;	/*21 CDB Length                 */
+	UBYTE SCB_Ident;	/*22 Identify                   */
+	UBYTE SCB_TagMsg;	/*23 Tag Message                */
+	UBYTE SCB_CDB[IMAX_CDB];	/*24 SCSI CDBs                  */
+	UBYTE SCB_ScbIdx;	/*3C Index for this ORCSCB      */
+	U32 SCB_SensePAddr;	/*34 Sense Buffer physical Addr */
+
+	ESCB *SCB_EScb;		/*38 Extended SCB Pointer       */
+#ifndef ALPHA
+	UBYTE SCB_Reserved2[4];	/*3E Reserved for Driver use    */
+#endif
+} ORC_SCB;
+
+/* Opcodes of ORCSCB_Opcode */
+#define ORC_EXECSCSI	0x00	/* SCSI initiator command with residual */
+#define ORC_BUSDEVRST	0x01	/* SCSI Bus Device Reset  */
+
+/* Status of ORCSCB_Status */
+#define ORCSCB_COMPLETE	0x00	/* SCB request completed  */
+#define ORCSCB_POST	0x01	/* SCB is posted by the HOST      */
+
+/* Bit Definition for ORCSCB_Flags */
+#define SCF_DISINT	0x01	/* Disable HOST interrupt */
+#define SCF_DIR		0x18	/* Direction bits         */
+#define SCF_NO_DCHK	0x00	/* Direction determined by SCSI   */
+#define SCF_DIN		0x08	/* From Target to Initiator       */
+#define SCF_DOUT	0x10	/* From Initiator to Target       */
+#define SCF_NO_XF	0x18	/* No data transfer               */
+#define SCF_POLL   0x40
+
+/* Error Codes for ORCSCB_HaStat */
+#define HOST_SEL_TOUT	0x11
+#define HOST_DO_DU	0x12
+#define HOST_BUS_FREE	0x13
+#define HOST_BAD_PHAS	0x14
+#define HOST_INV_CMD	0x16
+#define HOST_SCSI_RST	0x1B
+#define HOST_DEV_RST	0x1C
+
+
+/* Error Codes for ORCSCB_TaStat */
+#define TARGET_CHK_COND	0x02
+#define TARGET_BUSY	0x08
+#define TARGET_TAG_FULL	0x28
+
+
+/***********************************************************************
+		Target Device Control Structure
+**********************************************************************/
+
+typedef struct ORC_Tar_Ctrl_Struc {
+	UBYTE TCS_DrvDASD;	/* 6 */
+	UBYTE TCS_DrvSCSI;	/* 7 */
+	UBYTE TCS_DrvHead;	/* 8 */
+	UWORD TCS_DrvFlags;	/* 4 */
+	UBYTE TCS_DrvSector;	/* 7 */
+} ORC_TCS;
+
+/* Bit Definition for TCF_DrvFlags */
+#define	TCS_DF_NODASD_SUPT	0x20	/* Suppress OS/2 DASD Mgr support */
+#define	TCS_DF_NOSCSI_SUPT	0x40	/* Suppress OS/2 SCSI Mgr support */
+
+
+/***********************************************************************
+              Host Adapter Control Structure
+************************************************************************/
+typedef struct ORC_Ha_Ctrl_Struc {
+	USHORT HCS_Base;	/* 00 */
+	UBYTE HCS_Index;	/* 02 */
+	UBYTE HCS_Intr;		/* 04 */
+	UBYTE HCS_SCSI_ID;	/* 06    H/A SCSI ID */
+	UBYTE HCS_BIOS;		/* 07    BIOS configuration */
+
+	UBYTE HCS_Flags;	/* 0B */
+	UBYTE HCS_HAConfig1;	/* 1B    SCSI0MAXTags */
+	UBYTE HCS_MaxTar;	/* 1B    SCSI0MAXTags */
+
+	USHORT HCS_Units;	/* Number of units this adapter  */
+	USHORT HCS_AFlags;	/* Adapter info. defined flags   */
+	ULONG HCS_Timeout;	/* Adapter timeout value   */
+	ORC_SCB *HCS_virScbArray;	/* 28 Virtual Pointer to SCB array */
+	dma_addr_t HCS_physScbArray;	/* Scb Physical address */
+	ESCB *HCS_virEscbArray;	/* Virtual pointer to ESCB Scatter list */
+	dma_addr_t HCS_physEscbArray;	/* scatter list Physical address */
+	UBYTE TargetFlag[16];	/* 30  target configuration, TCF_EN_TAG */
+	UBYTE MaximumTags[16];	/* 40  ORC_MAX_SCBS */
+	UBYTE ActiveTags[16][16];	/* 50 */
+	ORC_TCS HCS_Tcs[16];	/* 28 */
+	U32 BitAllocFlag[MAX_CHANNELS][8];	/* Max STB is 256, So 256/32 */
+	spinlock_t BitAllocFlagLock;
+	struct pci_dev *pdev;
+} ORC_HCS;
+
+/* Bit Definition for HCS_Flags */
+
+#define HCF_SCSI_RESET	0x01	/* SCSI BUS RESET         */
+#define HCF_PARITY    	0x02	/* parity card                    */
+#define HCF_LVDS     	0x10	/* parity card                    */
+
+/* Bit Definition for TargetFlag */
+
+#define TCF_EN_255	    0x08
+#define TCF_EN_TAG	    0x10
+#define TCF_BUSY	      0x20
+#define TCF_DISCONNECT	0x40
+#define TCF_SPIN_UP	  0x80
+
+/* Bit Definition for HCS_AFlags */
+#define	HCS_AF_IGNORE		0x01	/* Adapter ignore         */
+#define	HCS_AF_DISABLE_RESET	0x10	/* Adapter disable reset  */
+#define	HCS_AF_DISABLE_ADPT	0x80	/* Adapter disable                */
+
+typedef struct _NVRAM {
+/*----------header ---------------*/
+        UCHAR SubVendorID0;     /* 00 - Sub Vendor ID           */
+        UCHAR SubVendorID1;     /* 00 - Sub Vendor ID           */
+        UCHAR SubSysID0;        /* 02 - Sub System ID           */
+        UCHAR SubSysID1;        /* 02 - Sub System ID           */
+        UCHAR SubClass;         /* 04 - Sub Class               */
+        UCHAR VendorID0;        /* 05 - Vendor ID               */
+        UCHAR VendorID1;        /* 05 - Vendor ID               */
+        UCHAR DeviceID0;        /* 07 - Device ID               */
+        UCHAR DeviceID1;        /* 07 - Device ID               */
+        UCHAR Reserved0[2];     /* 09 - Reserved                */
+        UCHAR Revision;         /* 0B - Revision of data structure */
+        /* ----Host Adapter Structure ---- */
+        UCHAR NumOfCh;          /* 0C - Number of SCSI channel  */
+        UCHAR BIOSConfig1;      /* 0D - BIOS configuration 1    */
+        UCHAR BIOSConfig2;      /* 0E - BIOS boot channel&target ID */
+        UCHAR BIOSConfig3;      /* 0F - BIOS configuration 3    */
+        /* ----SCSI channel Structure ---- */
+        /* from "CTRL-I SCSI Host Adapter SetUp menu "  */
+        UCHAR SCSI0Id;          /* 10 - Channel 0 SCSI ID       */
+        UCHAR SCSI0Config;      /* 11 - Channel 0 SCSI configuration */
+        UCHAR SCSI0MaxTags;     /* 12 - Channel 0 Maximum tags  */
+        UCHAR SCSI0ResetTime;   /* 13 - Channel 0 Reset recovering time */
+        UCHAR ReservedforChannel0[2];   /* 14 - Reserved                */
+
+        /* ----SCSI target Structure ----  */
+        /* from "CTRL-I SCSI device SetUp menu "                        */
+        UCHAR Target00Config;   /* 16 - Channel 0 Target 0 config */
+        UCHAR Target01Config;   /* 17 - Channel 0 Target 1 config */
+        UCHAR Target02Config;   /* 18 - Channel 0 Target 2 config */
+        UCHAR Target03Config;   /* 19 - Channel 0 Target 3 config */
+        UCHAR Target04Config;   /* 1A - Channel 0 Target 4 config */
+        UCHAR Target05Config;   /* 1B - Channel 0 Target 5 config */
+        UCHAR Target06Config;   /* 1C - Channel 0 Target 6 config */
+        UCHAR Target07Config;   /* 1D - Channel 0 Target 7 config */
+        UCHAR Target08Config;   /* 1E - Channel 0 Target 8 config */
+        UCHAR Target09Config;   /* 1F - Channel 0 Target 9 config */
+        UCHAR Target0AConfig;   /* 20 - Channel 0 Target A config */
+        UCHAR Target0BConfig;   /* 21 - Channel 0 Target B config */
+        UCHAR Target0CConfig;   /* 22 - Channel 0 Target C config */
+        UCHAR Target0DConfig;   /* 23 - Channel 0 Target D config */
+        UCHAR Target0EConfig;   /* 24 - Channel 0 Target E config */
+        UCHAR Target0FConfig;   /* 25 - Channel 0 Target F config */
+
+        UCHAR SCSI1Id;          /* 26 - Channel 1 SCSI ID       */
+        UCHAR SCSI1Config;      /* 27 - Channel 1 SCSI configuration */
+        UCHAR SCSI1MaxTags;     /* 28 - Channel 1 Maximum tags  */
+        UCHAR SCSI1ResetTime;   /* 29 - Channel 1 Reset recovering time */
+        UCHAR ReservedforChannel1[2];   /* 2A - Reserved                */
+
+        /* ----SCSI target Structure ----  */
+        /* from "CTRL-I SCSI device SetUp menu "                                          */
+        UCHAR Target10Config;   /* 2C - Channel 1 Target 0 config */
+        UCHAR Target11Config;   /* 2D - Channel 1 Target 1 config */
+        UCHAR Target12Config;   /* 2E - Channel 1 Target 2 config */
+        UCHAR Target13Config;   /* 2F - Channel 1 Target 3 config */
+        UCHAR Target14Config;   /* 30 - Channel 1 Target 4 config */
+        UCHAR Target15Config;   /* 31 - Channel 1 Target 5 config */
+        UCHAR Target16Config;   /* 32 - Channel 1 Target 6 config */
+        UCHAR Target17Config;   /* 33 - Channel 1 Target 7 config */
+        UCHAR Target18Config;   /* 34 - Channel 1 Target 8 config */
+        UCHAR Target19Config;   /* 35 - Channel 1 Target 9 config */
+        UCHAR Target1AConfig;   /* 36 - Channel 1 Target A config */
+        UCHAR Target1BConfig;   /* 37 - Channel 1 Target B config */
+        UCHAR Target1CConfig;   /* 38 - Channel 1 Target C config */
+        UCHAR Target1DConfig;   /* 39 - Channel 1 Target D config */
+        UCHAR Target1EConfig;   /* 3A - Channel 1 Target E config */
+        UCHAR Target1FConfig;   /* 3B - Channel 1 Target F config */
+        UCHAR reserved[3];      /* 3C - Reserved                */
+        /* ---------- CheckSum ----------       */
+        UCHAR CheckSum;         /* 3F - Checksum of NVRam       */
+} NVRAM, *PNVRAM;
+
+/* Bios Configuration for nvram->BIOSConfig1                            */
+#define NBC_BIOSENABLE  0x01    /* BIOS enable                    */
+#define NBC_CDROM       0x02    /* Support bootable CDROM */
+#define NBC_REMOVABLE   0x04    /* Support removable drive        */
+
+/* Bios Configuration for nvram->BIOSConfig2                            */
+#define NBB_TARGET_MASK 0x0F    /* Boot SCSI target ID number     */
+#define NBB_CHANL_MASK  0xF0    /* Boot SCSI channel number       */
+
+/* Bit definition for nvram->SCSIConfig                                 */
+#define NCC_BUSRESET    0x01    /* Reset SCSI bus at power up     */
+#define NCC_PARITYCHK   0x02    /* SCSI parity enable             */
+#define NCC_LVDS        0x10    /* Enable LVDS                    */
+#define NCC_ACTTERM1    0x20    /* Enable active terminator 1     */
+#define NCC_ACTTERM2    0x40    /* Enable active terminator 2     */
+#define NCC_AUTOTERM    0x80    /* Enable auto termination        */
+
+/* Bit definition for nvram->TargetxConfig                              */
+#define NTC_PERIOD      0x07    /* Maximum Sync. Speed            */
+#define NTC_1GIGA       0x08    /* 255 head / 63 sectors (64/32) */
+#define NTC_NO_SYNC     0x10    /* NO SYNC. NEGO          */
+#define NTC_NO_WIDESYNC 0x20    /* NO WIDE SYNC. NEGO             */
+#define NTC_DISC_ENABLE 0x40    /* Enable SCSI disconnect */
+#define NTC_SPINUP      0x80    /* Start disk drive               */
+
+/* Default NVRam values                                                 */
+#define NBC_DEFAULT     (NBC_ENABLE)
+#define NCC_DEFAULT     (NCC_BUSRESET | NCC_AUTOTERM | NCC_PARITYCHK)
+#define NCC_MAX_TAGS    0x20    /* Maximum tags per target        */
+#define NCC_RESET_TIME  0x0A    /* SCSI RESET recovering time     */
+#define NTC_DEFAULT     (NTC_1GIGA | NTC_NO_WIDESYNC | NTC_DISC_ENABLE)
+
+#define ORC_RD(x,y)             (UCHAR)(inb(  (int)((ULONG)((ULONG)x+(UCHAR)y)) ))
+#define ORC_RDWORD(x,y)         (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
+#define ORC_RDLONG(x,y)         (long)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
+
+#define ORC_WR(     adr,data)   outb( (UCHAR)(data), (int)(adr))
+#define ORC_WRSHORT(adr,data)   outw( (UWORD)(data), (int)(adr))
+#define ORC_WRLONG( adr,data)   outl( (ULONG)(data), (int)(adr))
diff -Nru a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
--- a/drivers/scsi/aacraid/aachba.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/aacraid/aachba.c	2004-12-24 13:36:48 -08:00
@@ -131,47 +131,10 @@
 	u8 inqd_prl[4];	/* Product Revision Level */
 };
 
-struct sense_data {
-	u8 error_code;		/* 70h (current errors), 71h(deferred errors) */
-	u8 valid:1;		/* A valid bit of one indicates that the information  */
-				/* field contains valid information as defined in the
-				 * SCSI-2 Standard.
-				 */
-	u8 segment_number;	/* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */
-	u8 sense_key:4;		/* Sense Key */
-	u8 reserved:1;
-	u8 ILI:1;		/* Incorrect Length Indicator */
-	u8 EOM:1;		/* End Of Medium - reserved for random access devices */
-	u8 filemark:1;		/* Filemark - reserved for random access devices */
-
-	u8 information[4];	/* for direct-access devices, contains the unsigned 
-				 * logical block address or residue associated with 
-				 * the sense key 
-				 */
-	u8 add_sense_len;	/* number of additional sense bytes to follow this field */
-	u8 cmnd_info[4];	/* not used */
-	u8 ASC;			/* Additional Sense Code */
-	u8 ASCQ;		/* Additional Sense Code Qualifier */
-	u8 FRUC;		/* Field Replaceable Unit Code - not used */
-	u8 bit_ptr:3;		/* indicates which byte of the CDB or parameter data
-				 * was in error
-				 */
-	u8 BPV:1;		/* bit pointer valid (BPV): 1- indicates that 
-				 * the bit_ptr field has valid value
-				 */
-	u8 reserved2:2;
-	u8 CD:1;		/* command data bit: 1- illegal parameter in CDB.
-				 * 0- illegal parameter in data.
-				 */
-	u8 SKSV:1;
-	u8 field_ptr[2];	/* byte of the CDB or parameter data in error */
-};
-
 /*
  *              M O D U L E   G L O B A L S
  */
  
-static struct sense_data sense_data[MAXIMUM_NUM_CONTAINERS];
 static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* sgmap);
 static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg);
 static int aac_send_srb_fib(struct scsi_cmnd* scsicmd);
@@ -193,6 +156,80 @@
 static int nondasd = -1;
 static int dacmode = -1;
 
+static int commit = -1;
+
+/**
+ *	aac_get_config_status	-	check the adapter configuration
+ *	@common: adapter to query
+ *
+ *	Query config status, and commit the configuration if needed.
+ */
+int aac_get_config_status(struct aac_dev *dev)
+{
+	int status = 0;
+	struct fib * fibptr;
+
+	if (!(fibptr = fib_alloc(dev)))
+		return -ENOMEM;
+
+	fib_init(fibptr);
+	{
+		struct aac_get_config_status *dinfo;
+		dinfo = (struct aac_get_config_status *) fib_data(fibptr);
+
+		dinfo->command = cpu_to_le32(VM_ContainerConfig);
+		dinfo->type = cpu_to_le32(CT_GET_CONFIG_STATUS);
+		dinfo->count = cpu_to_le32(sizeof(((struct aac_get_config_status_resp *)NULL)->data));
+	}
+
+	status = fib_send(ContainerCommand,
+			    fibptr,
+			    sizeof (struct aac_get_config_status),
+			    FsaNormal,
+			    1, 1,
+			    NULL, NULL);
+	if (status < 0 ) {
+		printk(KERN_WARNING "aac_get_config_status: SendFIB failed.\n");
+	} else {
+		struct aac_get_config_status_resp *reply
+		  = (struct aac_get_config_status_resp *) fib_data(fibptr);
+		dprintk((KERN_WARNING
+		  "aac_get_config_status: response=%d status=%d action=%d\n",
+		  reply->response, reply->status, reply->data.action));
+		if ((reply->response != ST_OK)
+		 || (reply->status != CT_OK)
+		 || (reply->data.action > CFACT_PAUSE)) {
+			printk(KERN_WARNING "aac_get_config_status: Will not issue the Commit Configuration\n");
+			status = -EINVAL;
+		}
+	}
+	fib_complete(fibptr);
+	/* Send a CT_COMMIT_CONFIG to enable discovery of devices */
+	if (status >= 0) {
+		if (commit == 1) {
+			struct aac_commit_config * dinfo;
+			fib_init(fibptr);
+			dinfo = (struct aac_commit_config *) fib_data(fibptr);
+	
+			dinfo->command = cpu_to_le32(VM_ContainerConfig);
+			dinfo->type = cpu_to_le32(CT_COMMIT_CONFIG);
+	
+			status = fib_send(ContainerCommand,
+				    fibptr,
+				    sizeof (struct aac_commit_config),
+				    FsaNormal,
+				    1, 1,
+				    NULL, NULL);
+			fib_complete(fibptr);
+		} else if (commit == 0) {
+			printk(KERN_WARNING
+			  "aac_get_config_status: Foreign device configurations are being ignored\n");
+		}
+	}
+	fib_free(fibptr);
+	return status;
+}
+
 /**
  *	aac_get_containers	-	list containers
  *	@common: adapter to probe
@@ -201,21 +238,57 @@
  */
 int aac_get_containers(struct aac_dev *dev)
 {
-	struct fsa_scsi_hba *fsa_dev_ptr;
+	struct fsa_dev_info *fsa_dev_ptr;
 	u32 index; 
 	int status = 0;
-	struct aac_query_mount *dinfo;
-	struct aac_mount *dresp;
 	struct fib * fibptr;
 	unsigned instance;
+	struct aac_get_container_count *dinfo;
+	struct aac_get_container_count_resp *dresp;
+	int maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
 
-	fsa_dev_ptr = &(dev->fsa_dev);
 	instance = dev->scsi_host_ptr->unique_id;
 
 	if (!(fibptr = fib_alloc(dev)))
 		return -ENOMEM;
 
-	for (index = 0; index < MAXIMUM_NUM_CONTAINERS; index++) {
+	fib_init(fibptr);
+	dinfo = (struct aac_get_container_count *) fib_data(fibptr);
+	dinfo->command = cpu_to_le32(VM_ContainerConfig);
+	dinfo->type = cpu_to_le32(CT_GET_CONTAINER_COUNT);
+
+	status = fib_send(ContainerCommand,
+		    fibptr,
+		    sizeof (struct aac_get_container_count),
+		    FsaNormal,
+		    1, 1,
+		    NULL, NULL);
+	if (status >= 0) {
+		dresp = (struct aac_get_container_count_resp *)fib_data(fibptr);
+		maximum_num_containers = dresp->ContainerSwitchEntries;
+		fib_complete(fibptr);
+	}
+
+	if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)
+		maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
+
+	fsa_dev_ptr = (struct fsa_dev_info *) kmalloc(
+	  sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL);
+	if (!fsa_dev_ptr) {
+		fib_free(fibptr);
+		return -ENOMEM;
+	}
+	memset(fsa_dev_ptr, 0, sizeof(*fsa_dev_ptr) * maximum_num_containers);
+
+	dev->fsa_dev = fsa_dev_ptr;
+	dev->maximum_num_containers = maximum_num_containers;
+
+	for (index = 0; index < dev->maximum_num_containers; index++) {
+		struct aac_query_mount *dinfo;
+		struct aac_mount *dresp;
+
+		fsa_dev_ptr[index].devname[0] = '\0';
+
 		fib_init(fibptr);
 		dinfo = (struct aac_query_mount *) fib_data(fibptr);
 
@@ -235,14 +308,20 @@
 		}
 		dresp = (struct aac_mount *)fib_data(fibptr);
 
+		dprintk ((KERN_DEBUG
+		  "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%u\n",
+		  (int)index, (int)le32_to_cpu(dresp->status),
+		  (int)le32_to_cpu(dresp->mnt[0].vol),
+		  (int)le32_to_cpu(dresp->mnt[0].state),
+		  (unsigned)le32_to_cpu(dresp->mnt[0].capacity)));
 		if ((le32_to_cpu(dresp->status) == ST_OK) &&
 		    (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
 		    (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
-			fsa_dev_ptr->valid[index] = 1;
-			fsa_dev_ptr->type[index] = le32_to_cpu(dresp->mnt[0].vol);
-			fsa_dev_ptr->size[index] = le32_to_cpu(dresp->mnt[0].capacity);
+			fsa_dev_ptr[index].valid = 1;
+			fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol);
+			fsa_dev_ptr[index].size = le32_to_cpu(dresp->mnt[0].capacity);
 			if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
-				    fsa_dev_ptr->ro[index] = 1;
+				    fsa_dev_ptr[index].ro = 1;
 		}
 		fib_complete(fibptr);
 		/*
@@ -256,25 +335,111 @@
 	return status;
 }
 
+static void aac_io_done(struct scsi_cmnd * scsicmd)
+{
+	unsigned long cpu_flags;
+	struct Scsi_Host *host = scsicmd->device->host;
+	spin_lock_irqsave(host->host_lock, cpu_flags);
+	scsicmd->scsi_done(scsicmd);
+	spin_unlock_irqrestore(host->host_lock, cpu_flags);
+}
+
+static void get_container_name_callback(void *context, struct fib * fibptr)
+{
+	struct aac_get_name_resp * get_name_reply;
+	struct scsi_cmnd * scsicmd;
+
+	scsicmd = (struct scsi_cmnd *) context;
+
+	dprintk((KERN_DEBUG "get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies));
+	if (fibptr == NULL)
+		BUG();
+
+	get_name_reply = (struct aac_get_name_resp *) fib_data(fibptr);
+	/* Failure is irrelevant, using default value instead */
+	if ((le32_to_cpu(get_name_reply->status) == CT_OK)
+	 && (get_name_reply->data[0] != '\0')) {
+		int    count;
+		char * dp;
+		char * sp = get_name_reply->data;
+		sp[sizeof(((struct aac_get_name_resp *)NULL)->data)-1] = '\0';
+		while (*sp == ' ')
+			++sp;
+		count = sizeof(((struct inquiry_data *)NULL)->inqd_pid);
+		dp = ((struct inquiry_data *)scsicmd->request_buffer)->inqd_pid;
+		if (*sp) do {
+			*dp++ = (*sp) ? *sp++ : ' ';
+		} while (--count > 0);
+	}
+	scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
+
+	fib_complete(fibptr);
+	fib_free(fibptr);
+	aac_io_done(scsicmd);
+}
+
+/**
+ *	aac_get_container_name	-	get container name, none blocking.
+ */
+static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid)
+{
+	int status;
+	struct aac_get_name *dinfo;
+	struct fib * cmd_fibcontext;
+	struct aac_dev * dev;
+
+	dev = (struct aac_dev *)scsicmd->device->host->hostdata;
+
+	if (!(cmd_fibcontext = fib_alloc(dev)))
+		return -ENOMEM;
+
+	fib_init(cmd_fibcontext);
+	dinfo = (struct aac_get_name *) fib_data(cmd_fibcontext);
+
+	dinfo->command = cpu_to_le32(VM_ContainerConfig);
+	dinfo->type = cpu_to_le32(CT_READ_NAME);
+	dinfo->cid = cpu_to_le32(cid);
+	dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));
+
+	status = fib_send(ContainerCommand, 
+		  cmd_fibcontext, 
+		  sizeof (struct aac_get_name),
+		  FsaNormal, 
+		  0, 1, 
+		  (fib_callback) get_container_name_callback, 
+		  (void *) scsicmd);
+	
+	/*
+	 *	Check that the command queued to the controller
+	 */
+	if (status == -EINPROGRESS) 
+		return 0;
+		
+	printk(KERN_WARNING "aac_get_container_name: fib_send failed with status: %d.\n", status);
+	fib_complete(cmd_fibcontext);
+	fib_free(cmd_fibcontext);
+	return -1;
+}
+
 /**
  *	probe_container		-	query a logical volume
  *	@dev: device to query
  *	@cid: container identifier
  *
  *	Queries the controller about the given volume. The volume information
- *	is updated in the struct fsa_scsi_hba structure rather than returned.
+ *	is updated in the struct fsa_dev_info structure rather than returned.
  */
  
 static int probe_container(struct aac_dev *dev, int cid)
 {
-	struct fsa_scsi_hba *fsa_dev_ptr;
+	struct fsa_dev_info *fsa_dev_ptr;
 	int status;
 	struct aac_query_mount *dinfo;
 	struct aac_mount *dresp;
 	struct fib * fibptr;
 	unsigned instance;
 
-	fsa_dev_ptr = &(dev->fsa_dev);
+	fsa_dev_ptr = dev->fsa_dev;
 	instance = dev->scsi_host_ptr->unique_id;
 
 	if (!(fibptr = fib_alloc(dev)))
@@ -304,11 +469,11 @@
 	if ((le32_to_cpu(dresp->status) == ST_OK) &&
 	    (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
 	    (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
-		fsa_dev_ptr->valid[cid] = 1;
-		fsa_dev_ptr->type[cid] = le32_to_cpu(dresp->mnt[0].vol);
-		fsa_dev_ptr->size[cid] = le32_to_cpu(dresp->mnt[0].capacity);
+		fsa_dev_ptr[cid].valid = 1;
+		fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol);
+		fsa_dev_ptr[cid].size = le32_to_cpu(dresp->mnt[0].capacity);
 		if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
-			fsa_dev_ptr->ro[cid] = 1;
+			fsa_dev_ptr[cid].ro = 1;
 	}
 
 error:
@@ -367,14 +532,13 @@
  * Arguments: [1] pointer to void [1] int
  *
  * Purpose: Sets SCSI inquiry data strings for vendor, product
- * and revision level. Allows strings to be set in platform dependent
- * files instead of in OS dependent driver source.
+ * and revision level. Allows strings to be set in platform dependant
+ * files instead of in OS dependant driver source.
  */
 
 static void setinqstr(int devtype, void *data, int tindex)
 {
 	struct scsi_inq *str;
-	char *findit;
 	struct aac_driver_ident *mp;
 
 	mp = aac_get_driver_ident(devtype);
@@ -384,13 +548,14 @@
 	inqstrcpy (mp->vname, str->vid); 
 	inqstrcpy (mp->model, str->pid); /* last six chars reserved for vol type */
 
-	findit = str->pid;
-
-	for ( ; *findit != ' '; findit++); /* walk till we find a space then incr by 1 */
-		findit++;
-	
 	if (tindex < (sizeof(container_types)/sizeof(char *))){
-		inqstrcpy (container_types[tindex], findit);
+		char *findit = str->pid;
+
+		for ( ; *findit != ' '; findit++); /* walk till we find a space */
+		/* RAID is superfluous in the context of a RAID device */
+		if (memcmp(findit-4, "RAID", 4) == 0)
+			*(findit -= 4) = ' ';
+		inqstrcpy (container_types[tindex], findit + 1);
 	}
 	inqstrcpy ("V1.0", str->prl);
 }
@@ -435,20 +600,6 @@
 	}
 }
 
-static void aac_io_done(struct scsi_cmnd * scsicmd)
-{
-	unsigned long cpu_flags;
-	struct Scsi_Host *host = scsicmd->device->host;
-	spin_lock_irqsave(host->host_lock, cpu_flags);
-	scsicmd->scsi_done(scsicmd);
-	spin_unlock_irqrestore(host->host_lock, cpu_flags);
-}
-
-static void __aac_io_done(struct scsi_cmnd * scsicmd)
-{
-	scsicmd->scsi_done(scsicmd);
-}
-
 int aac_get_adapter_info(struct aac_dev* dev)
 {
 	struct fib* fibptr;
@@ -494,9 +645,31 @@
 			dev->adapter_info.serial[1]);
 
 	dev->nondasd_support = 0;
+	dev->raid_scsi_mode = 0;
 	if(dev->adapter_info.options & AAC_OPT_NONDASD){
 		dev->nondasd_support = 1;
 	}
+
+	/*
+	 * If the firmware supports ROMB RAID/SCSI mode and we are currently
+	 * in RAID/SCSI mode, set the flag. For now if in this mode we will
+	 * force nondasd support on. If we decide to allow the non-dasd flag
+	 * additional changes changes will have to be made to support
+	 * RAID/SCSI.  the function aac_scsi_cmd in this module will have to be
+	 * changed to support the new dev->raid_scsi_mode flag instead of
+	 * leaching off of the dev->nondasd_support flag. Also in linit.c the
+	 * function aac_detect will have to be modified where it sets up the
+	 * max number of channels based on the aac->nondasd_support flag only.
+	 */
+	if ((dev->adapter_info.options & AAC_OPT_SCSI_MANAGED) &&
+	    (dev->adapter_info.options & AAC_OPT_RAID_SCSI_MODE)) {
+		dev->nondasd_support = 1;
+		dev->raid_scsi_mode = 1;
+	}
+	if (dev->raid_scsi_mode != 0)
+		printk(KERN_INFO "%s%d: ROMB RAID/SCSI mode enabled\n",
+				dev->name, dev->id);
+		
 	if(nondasd != -1) {  
 		dev->nondasd_support = (nondasd!=0);
 	}
@@ -571,12 +744,15 @@
 	else {
 		printk(KERN_WARNING "read_callback: read failed, status = %d\n", readreply->status);
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
-		set_sense((u8 *) &sense_data[cid],
+		set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
 				    HARDWARE_ERROR,
 				    SENCODE_INTERNAL_TARGET_FAILURE,
 				    ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
 				    0, 0);
-		memcpy(scsicmd->sense_buffer, &sense_data[cid], sizeof(struct sense_data));
+		memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
+		  (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
+		    ? sizeof(scsicmd->sense_buffer)
+		    : sizeof(dev->fsa_dev[cid].sense_data));
 	}
 	fib_complete(fibptr);
 	fib_free(fibptr);
@@ -617,12 +793,13 @@
 	else {
 		printk(KERN_WARNING "write_callback: write failed, status = %d\n", writereply->status);
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
-		set_sense((u8 *) &sense_data[cid],
+		set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
 				    HARDWARE_ERROR,
 				    SENCODE_INTERNAL_TARGET_FAILURE,
 				    ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
 				    0, 0);
-		memcpy(scsicmd->sense_buffer, &sense_data[cid], sizeof(struct sense_data));
+		memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 
+				sizeof(struct sense_data));
 	}
 
 	fib_complete(fibptr);
@@ -739,7 +916,7 @@
 	aac_io_done(scsicmd);
 	fib_complete(cmd_fibcontext);
 	fib_free(cmd_fibcontext);
-	return -1;
+	return 0;
 }
 
 static int aac_write(struct scsi_cmnd * scsicmd, int cid)
@@ -773,7 +950,7 @@
 	if (!(cmd_fibcontext = fib_alloc(dev))) {
 		scsicmd->result = DID_ERROR << 16;
 		aac_io_done(scsicmd);
-		return -1;
+		return 0;
 	}
 	fib_init(cmd_fibcontext);
 
@@ -849,7 +1026,7 @@
 
 	fib_complete(cmd_fibcontext);
 	fib_free(cmd_fibcontext);
-	return -1;
+	return 0;
 }
 
 
@@ -864,11 +1041,11 @@
 int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
 {
 	u32 cid = 0;
-	int ret;
 	struct Scsi_Host *host = scsicmd->device->host;
 	struct aac_dev *dev = (struct aac_dev *)host->hostdata;
-	struct fsa_scsi_hba *fsa_dev_ptr = &dev->fsa_dev;
+	struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
 	int cardtype = dev->cardtype;
+	int ret;
 	
 	/*
 	 *	If the bus, id or lun is out of range, return fail
@@ -877,9 +1054,9 @@
 	 */
 	if (scsicmd->device->id != host->this_id) {
 		if ((scsicmd->device->channel == 0) ){
-			if( (scsicmd->device->id >= MAXIMUM_NUM_CONTAINERS) || (scsicmd->device->lun != 0)){ 
+			if( (scsicmd->device->id >= dev->maximum_num_containers) || (scsicmd->device->lun != 0)){ 
 				scsicmd->result = DID_NO_CONNECT << 16;
-				__aac_io_done(scsicmd);
+				scsicmd->scsi_done(scsicmd);
 				return 0;
 			}
 			cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
@@ -888,7 +1065,7 @@
 			 *	If the target container doesn't exist, it may have
 			 *	been newly created
 			 */
-			if (fsa_dev_ptr->valid[cid] == 0) {
+			if ((fsa_dev_ptr[cid].valid & 1) == 0) {
 				switch (scsicmd->cmnd[0]) {
 				case INQUIRY:
 				case READ_CAPACITY:
@@ -896,9 +1073,9 @@
 					spin_unlock_irq(host->host_lock);
 					probe_container(dev, cid);
 					spin_lock_irq(host->host_lock);
-					if (fsa_dev_ptr->valid[cid] == 0) {
+					if (fsa_dev_ptr[cid].valid == 0) {
 						scsicmd->result = DID_NO_CONNECT << 16;
-						__aac_io_done(scsicmd);
+						scsicmd->scsi_done(scsicmd);
 						return 0;
 					}
 				default:
@@ -909,9 +1086,9 @@
 			 *	If the target container still doesn't exist, 
 			 *	return failure
 			 */
-			if (fsa_dev_ptr->valid[cid] == 0) {
+			if (fsa_dev_ptr[cid].valid == 0) {
 				scsicmd->result = DID_BAD_TARGET << 16;
-				__aac_io_done(scsicmd);
+				scsicmd->scsi_done(scsicmd);
 				return 0;
 			}
 		} else {  /* check for physical non-dasd devices */
@@ -919,7 +1096,7 @@
 				return aac_send_srb_fib(scsicmd);
 			} else {
 				scsicmd->result = DID_NO_CONNECT << 16;
-				__aac_io_done(scsicmd);
+				scsicmd->scsi_done(scsicmd);
 				return 0;
 			}
 		}
@@ -932,12 +1109,15 @@
 	{
 		dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
-		set_sense((u8 *) &sense_data[cid],
+		set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
 			    ILLEGAL_REQUEST,
 			    SENCODE_INVALID_COMMAND,
 			    ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
-		__aac_io_done(scsicmd);
-		memcpy(scsicmd->sense_buffer, &sense_data[cid], sizeof(struct sense_data));
+		memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
+		  (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
+		    ? sizeof(scsicmd->sense_buffer)
+		    : sizeof(dev->fsa_dev[cid].sense_data));
+		scsicmd->scsi_done(scsicmd);
 		return 0;
 	}
 
@@ -962,22 +1142,27 @@
 		 *	Set the Vendor, Product, and Revision Level
 		 *	see: <vendor>.c i.e. aac.c
 		 */
-		setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), fsa_dev_ptr->type[cid]);
-		if (scsicmd->device->id == host->this_id)
+		if (scsicmd->device->id == host->this_id) {
+			setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), (sizeof(container_types)/sizeof(char *)));
 			inq_data_ptr->inqd_pdt = INQD_PDT_PROC;	/* Processor device */
-		else
-			inq_data_ptr->inqd_pdt = INQD_PDT_DA;	/* Direct/random access device */
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
-		__aac_io_done(scsicmd);
-		return 0;
+			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
+			scsicmd->scsi_done(scsicmd);
+			return 0;
+		}
+		setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), fsa_dev_ptr[cid].type);
+		inq_data_ptr->inqd_pdt = INQD_PDT_DA;	/* Direct/random access device */
+		return aac_get_container_name(scsicmd, cid);
 	}
 	case READ_CAPACITY:
 	{
-		int capacity;
+		u32 capacity;
 		char *cp;
 
 		dprintk((KERN_DEBUG "READ CAPACITY command.\n"));
-		capacity = fsa_dev_ptr->size[cid] - 1;
+		if (fsa_dev_ptr[cid].size <= 0x100000000LL)
+			capacity = fsa_dev_ptr[cid].size - 1;
+		else
+			capacity = (u32)-1;
 		cp = scsicmd->request_buffer;
 		cp[0] = (capacity >> 24) & 0xff;
 		cp[1] = (capacity >> 16) & 0xff;
@@ -989,7 +1174,7 @@
 		cp[7] = 0;
 
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
-		__aac_io_done(scsicmd);
+		scsicmd->scsi_done(scsicmd);
 
 		return 0;
 	}
@@ -1006,7 +1191,7 @@
 		mode_buf[3] = 0;	/* Block descriptor length */
 
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
-		__aac_io_done(scsicmd);
+		scsicmd->scsi_done(scsicmd);
 
 		return 0;
 	}
@@ -1026,27 +1211,27 @@
 		mode_buf[7] = 0;	/* Block descriptor length (LSB) */
 
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
-		__aac_io_done(scsicmd);
+		scsicmd->scsi_done(scsicmd);
 
 		return 0;
 	}
 	case REQUEST_SENSE:
 		dprintk((KERN_DEBUG "REQUEST SENSE command.\n"));
-		memcpy(scsicmd->sense_buffer, &sense_data[cid], sizeof (struct sense_data));
-		memset(&sense_data[cid], 0, sizeof (struct sense_data));
+		memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, sizeof (struct sense_data));
+		memset(&dev->fsa_dev[cid].sense_data, 0, sizeof (struct sense_data));
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
-		__aac_io_done(scsicmd);
+		scsicmd->scsi_done(scsicmd);
 		return 0;
 
 	case ALLOW_MEDIUM_REMOVAL:
 		dprintk((KERN_DEBUG "LOCK command.\n"));
 		if (scsicmd->cmnd[4])
-			fsa_dev_ptr->locked[cid] = 1;
+			fsa_dev_ptr[cid].locked = 1;
 		else
-			fsa_dev_ptr->locked[cid] = 0;
+			fsa_dev_ptr[cid].locked = 0;
 
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
-		__aac_io_done(scsicmd);
+		scsicmd->scsi_done(scsicmd);
 		return 0;
 	/*
 	 *	These commands are all No-Ops
@@ -1059,7 +1244,7 @@
 	case SEEK_10:
 	case START_STOP:
 		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
-		__aac_io_done(scsicmd);
+		scsicmd->scsi_done(scsicmd);
 		return 0;
 	}
 
@@ -1075,7 +1260,7 @@
 			 
 			spin_unlock_irq(host->host_lock);
 			if  (scsicmd->request->rq_disk)
-				memcpy(fsa_dev_ptr->devname[cid],
+				memcpy(fsa_dev_ptr[cid].devname,
 					scsicmd->request->rq_disk->disk_name,
 					8);
 
@@ -1095,12 +1280,14 @@
 			 */
 			printk(KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]);
 			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
-			set_sense((u8 *) &sense_data[cid],
+			set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
 				ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
-			ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
-			memcpy(scsicmd->sense_buffer, &sense_data[cid],
-				sizeof(struct sense_data));
-			__aac_io_done(scsicmd);
+				ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
+			memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
+			  (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
+			    ? sizeof(scsicmd->sense_buffer)
+			    : sizeof(dev->fsa_dev[cid].sense_data));
+			scsicmd->scsi_done(scsicmd);
 			return 0;
 	}
 }
@@ -1108,16 +1295,16 @@
 static int query_disk(struct aac_dev *dev, void __user *arg)
 {
 	struct aac_query_disk qd;
-	struct fsa_scsi_hba *fsa_dev_ptr;
+	struct fsa_dev_info *fsa_dev_ptr;
 
-	fsa_dev_ptr = &(dev->fsa_dev);
+	fsa_dev_ptr = dev->fsa_dev;
 	if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk)))
 		return -EFAULT;
 	if (qd.cnum == -1)
 		qd.cnum = ID_LUN_TO_CONTAINER(qd.id, qd.lun);
 	else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1)) 
 	{
-		if (qd.cnum < 0 || qd.cnum >= MAXIMUM_NUM_CONTAINERS)
+		if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)
 			return -EINVAL;
 		qd.instance = dev->scsi_host_ptr->host_no;
 		qd.bus = 0;
@@ -1126,16 +1313,17 @@
 	}
 	else return -EINVAL;
 
-	qd.valid = fsa_dev_ptr->valid[qd.cnum];
-	qd.locked = fsa_dev_ptr->locked[qd.cnum];
-	qd.deleted = fsa_dev_ptr->deleted[qd.cnum];
+	qd.valid = fsa_dev_ptr[qd.cnum].valid;
+	qd.locked = fsa_dev_ptr[qd.cnum].locked;
+	qd.deleted = fsa_dev_ptr[qd.cnum].deleted;
 
-	if (fsa_dev_ptr->devname[qd.cnum][0] == '\0')
+	if (fsa_dev_ptr[qd.cnum].devname[0] == '\0')
 		qd.unmapped = 1;
 	else
 		qd.unmapped = 0;
 
-	strlcpy(qd.name, fsa_dev_ptr->devname[qd.cnum], sizeof(qd.name));
+	strlcpy(qd.name, fsa_dev_ptr[qd.cnum].devname,
+	  min(sizeof(qd.name), sizeof(fsa_dev_ptr[qd.cnum].devname) + 1));
 
 	if (copy_to_user(arg, &qd, sizeof (struct aac_query_disk)))
 		return -EFAULT;
@@ -1145,49 +1333,49 @@
 static int force_delete_disk(struct aac_dev *dev, void __user *arg)
 {
 	struct aac_delete_disk dd;
-	struct fsa_scsi_hba *fsa_dev_ptr;
+	struct fsa_dev_info *fsa_dev_ptr;
 
-	fsa_dev_ptr = &(dev->fsa_dev);
+	fsa_dev_ptr = dev->fsa_dev;
 
 	if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk)))
 		return -EFAULT;
 
-	if (dd.cnum >= MAXIMUM_NUM_CONTAINERS)
+	if (dd.cnum >= dev->maximum_num_containers)
 		return -EINVAL;
 	/*
 	 *	Mark this container as being deleted.
 	 */
-	fsa_dev_ptr->deleted[dd.cnum] = 1;
+	fsa_dev_ptr[dd.cnum].deleted = 1;
 	/*
 	 *	Mark the container as no longer valid
 	 */
-	fsa_dev_ptr->valid[dd.cnum] = 0;
+	fsa_dev_ptr[dd.cnum].valid = 0;
 	return 0;
 }
 
 static int delete_disk(struct aac_dev *dev, void __user *arg)
 {
 	struct aac_delete_disk dd;
-	struct fsa_scsi_hba *fsa_dev_ptr;
+	struct fsa_dev_info *fsa_dev_ptr;
 
-	fsa_dev_ptr = &(dev->fsa_dev);
+	fsa_dev_ptr = dev->fsa_dev;
 
 	if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk)))
 		return -EFAULT;
 
-	if (dd.cnum >= MAXIMUM_NUM_CONTAINERS)
+	if (dd.cnum >= dev->maximum_num_containers)
 		return -EINVAL;
 	/*
 	 *	If the container is locked, it can not be deleted by the API.
 	 */
-	if (fsa_dev_ptr->locked[dd.cnum])
+	if (fsa_dev_ptr[dd.cnum].locked)
 		return -EBUSY;
 	else {
 		/*
 		 *	Mark the container as no longer being valid.
 		 */
-		fsa_dev_ptr->valid[dd.cnum] = 0;
-		fsa_dev_ptr->devname[dd.cnum][0] = '\0';
+		fsa_dev_ptr[dd.cnum].valid = 0;
+		fsa_dev_ptr[dd.cnum].devname[0] = '\0';
 		return 0;
 	}
 }
@@ -1280,8 +1468,17 @@
 			if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER 
 					|| (b==TYPE_DISK && (b1&0x80)) ){
 				scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
+			/*
+			 * We will allow disk devices if in RAID/SCSI mode and
+			 * the channel is 2
+			 */
+			} else if ((dev->raid_scsi_mode) &&
+					(scsicmd->device->channel == 2)) {
+				scsicmd->result = DID_OK << 16 | 
+						COMMAND_COMPLETE << 8;
 			} else {
-				scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
+				scsicmd->result = DID_NO_CONNECT << 16 | 
+						COMMAND_COMPLETE << 8;
 			}
 		} else {
 			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
@@ -1313,8 +1510,17 @@
 			if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER
 					|| (b==TYPE_DISK && (b1&0x80)) ){
 				scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
+			/*
+			 * We will allow disk devices if in RAID/SCSI mode and
+			 * the channel is 2
+			 */
+			} else if ((dev->raid_scsi_mode) &&
+					(scsicmd->device->channel == 2)) {
+				scsicmd->result = DID_OK << 16 | 
+						COMMAND_COMPLETE << 8;
 			} else {
-				scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
+				scsicmd->result = DID_NO_CONNECT << 16 | 
+						COMMAND_COMPLETE << 8;
 			}
 			break;
 		}
@@ -1426,7 +1632,7 @@
 
 	if( scsicmd->device->id > 15 || scsicmd->device->lun > 7) {
 		scsicmd->result = DID_NO_CONNECT << 16;
-		__aac_io_done(scsicmd);
+		scsicmd->scsi_done(scsicmd);
 		return 0;
 	}
 
diff -Nru a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
--- a/drivers/scsi/aacraid/aacraid.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/aacraid/aacraid.h	2004-12-24 13:36:31 -08:00
@@ -7,7 +7,6 @@
  *----------------------------------------------------------------------------*/
 
 #define MAXIMUM_NUM_CONTAINERS	32
-#define MAXIMUM_NUM_ADAPTERS	8
 
 #define AAC_NUM_FIB		(256 + 64)
 #define AAC_NUM_IO_FIB		100
@@ -57,6 +56,7 @@
 #define		CT_VOLUME_OF_MIRRORS	12	/* volume of mirror */
 #define		CT_PSEUDO_RAID		13	/* really raid4 */
 #define		CT_LAST_VOLUME_TYPE	14
+#define 	CT_OK        		218
 
 /*
  *	Types of objects addressable in some fashion by the client.
@@ -421,8 +421,6 @@
 {
 	void (*adapter_interrupt)(struct aac_dev *dev);
 	void (*adapter_notify)(struct aac_dev *dev, u32 event);
-	void (*adapter_enable_int)(struct aac_dev *dev, u32 event);
-	void (*adapter_disable_int)(struct aac_dev *dev, u32 event);
 	int  (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 *status);
 	int  (*adapter_check_health)(struct aac_dev *dev);
 };
@@ -662,14 +660,53 @@
 	struct list_head	fib_list;	// this holds fibs and their attachd hw_fibs
 };
 
-struct fsa_scsi_hba {
-	u32		size[MAXIMUM_NUM_CONTAINERS];
-	u32		type[MAXIMUM_NUM_CONTAINERS];
-	u8		valid[MAXIMUM_NUM_CONTAINERS];
-	u8		ro[MAXIMUM_NUM_CONTAINERS];
-	u8		locked[MAXIMUM_NUM_CONTAINERS];
-	u8		deleted[MAXIMUM_NUM_CONTAINERS];
-	char		devname[MAXIMUM_NUM_CONTAINERS][8];
+struct sense_data {
+	u8 error_code;		/* 70h (current errors), 71h(deferred errors) */
+	u8 valid:1;		/* A valid bit of one indicates that the information  */
+				/* field contains valid information as defined in the
+				 * SCSI-2 Standard.
+				 */
+	u8 segment_number;	/* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */
+	u8 sense_key:4;		/* Sense Key */
+	u8 reserved:1;
+	u8 ILI:1;		/* Incorrect Length Indicator */
+	u8 EOM:1;		/* End Of Medium - reserved for random access devices */
+	u8 filemark:1;		/* Filemark - reserved for random access devices */
+
+	u8 information[4];	/* for direct-access devices, contains the unsigned 
+				 * logical block address or residue associated with 
+				 * the sense key 
+				 */
+	u8 add_sense_len;	/* number of additional sense bytes to follow this field */
+	u8 cmnd_info[4];	/* not used */
+	u8 ASC;			/* Additional Sense Code */
+	u8 ASCQ;		/* Additional Sense Code Qualifier */
+	u8 FRUC;		/* Field Replaceable Unit Code - not used */
+	u8 bit_ptr:3;		/* indicates which byte of the CDB or parameter data
+				 * was in error
+				 */
+	u8 BPV:1;		/* bit pointer valid (BPV): 1- indicates that 
+				 * the bit_ptr field has valid value
+				 */
+	u8 reserved2:2;
+	u8 CD:1;		/* command data bit: 1- illegal parameter in CDB.
+				 * 0- illegal parameter in data.
+				 */
+	u8 SKSV:1;
+	u8 field_ptr[2];	/* byte of the CDB or parameter data in error */
+};
+
+struct fsa_dev_info {
+	u64		last;
+	u64		size;
+	u32		type;
+	u16		queue_depth;
+	u8		valid;
+	u8		ro;
+	u8		locked;
+	u8		deleted;
+	char		devname[8];
+	struct sense_data sense_data;
 };
 
 struct fib {
@@ -768,10 +805,12 @@
 #define AAC_OPT_SGMAP_HOST64		cpu_to_le32(1<<10)
 #define AAC_OPT_ALARM			cpu_to_le32(1<<11)
 #define AAC_OPT_NONDASD			cpu_to_le32(1<<12)
+#define AAC_OPT_SCSI_MANAGED    	cpu_to_le32(1<<13)
+#define AAC_OPT_RAID_SCSI_MODE		cpu_to_le32(1<<14)
 
 struct aac_dev
 {
-	struct aac_dev		*next;
+	struct list_head	entry;
 	const char		*name;
 	int			id;
 
@@ -814,7 +853,8 @@
 	size_t			comm_size;
 
 	struct Scsi_Host	*scsi_host_ptr;
-	struct fsa_scsi_hba	fsa_dev;
+	int			maximum_num_containers;
+	struct fsa_dev_info	*fsa_dev;
 	pid_t			thread_pid;
 	int			cardtype;
 	
@@ -823,9 +863,9 @@
 	 */
 	union
 	{
-		struct sa_registers *sa;
-		struct rx_registers *rx;
-		struct rkt_registers *rkt;
+		struct sa_registers __iomem *sa;
+		struct rx_registers __iomem *rx;
+		struct rkt_registers __iomem *rkt;
 	} regs;
 	u32			OIMR; /* Mask Register Cache */
 	/*
@@ -839,25 +879,15 @@
 	 */
 	u8			nondasd_support; 
 	u8			dac_support;
+	u8			raid_scsi_mode;
 };
 
-#define AllocateAndMapFibSpace(dev, MapFibContext) \
-	(dev)->a_ops.AllocateAndMapFibSpace(dev, MapFibContext)
-
-#define UnmapAndFreeFibSpace(dev, MapFibContext) \
-	(dev)->a_ops.UnmapAndFreeFibSpace(dev, MapFibContext)
-
 #define aac_adapter_interrupt(dev) \
 	(dev)->a_ops.adapter_interrupt(dev)
 
 #define aac_adapter_notify(dev, event) \
 	(dev)->a_ops.adapter_notify(dev, event)
 
-#define aac_adapter_enable_int(dev, event) \
-	(dev)->a_ops.adapter_enable_int(dev, event)
-
-#define aac_adapter_disable_int(dev, event) \
-	dev->a_ops.adapter_disable_int(dev, event)
 
 #define aac_adapter_check_health(dev) \
 	(dev)->a_ops.adapter_check_health(dev)
@@ -1169,6 +1199,71 @@
 };
 
 /*
+ *	Query for Container Configuration Status
+ */
+
+#define CT_GET_CONFIG_STATUS 147
+struct aac_get_config_status {
+	u32		command;	/* VM_ContainerConfig */
+	u32		type;		/* CT_GET_CONFIG_STATUS */
+	u32		parm1;
+	u32		parm2;
+	u32		parm3;
+	u32		parm4;
+	u32		parm5;
+	u32		count;	/* sizeof(((struct aac_get_config_status_resp *)NULL)->data) */
+};
+
+#define CFACT_CONTINUE 0
+#define CFACT_PAUSE    1
+#define CFACT_ABORT    2
+struct aac_get_config_status_resp {
+	u32		response; /* ST_OK */
+	u32		dummy0;
+	u32		status;	/* CT_OK */
+	u32		parm1;
+	u32		parm2;
+	u32		parm3;
+	u32		parm4;
+	u32		parm5;
+	struct {
+		u32	action; /* CFACT_CONTINUE, CFACT_PAUSE or CFACT_ABORT */
+		u16	flags;
+		s16	count;
+	}		data;
+};
+
+/*
+ *	Accept the configuration as-is
+ */
+
+#define CT_COMMIT_CONFIG 152
+
+struct aac_commit_config {
+	u32		command;	/* VM_ContainerConfig */
+	u32		type;		/* CT_COMMIT_CONFIG */
+};
+
+/*
+ *	Query for Container Configuration Count
+ */
+
+#define CT_GET_CONTAINER_COUNT 4
+struct aac_get_container_count {
+	u32		command;	/* VM_ContainerConfig */
+	u32		type;		/* CT_GET_CONTAINER_COUNT */
+};
+
+struct aac_get_container_count_resp {
+	u32		response; /* ST_OK */
+	u32		dummy0;
+	u32		MaxContainers;
+	u32		ContainerSwitchEntries;
+	u32		MaxPartitions;
+};
+
+
+/*
  *	Query for "mountable" objects, ie, objects that are typically
  *	associated with a drive letter on the client (host) side.
  */
@@ -1202,6 +1297,31 @@
 	struct aac_mntent mnt[1];
 };
 
+#define CT_READ_NAME 130
+struct aac_get_name {
+	u32		command;	/* VM_ContainerConfig */
+	u32		type;		/* CT_READ_NAME */
+	u32		cid;
+	u32		parm1;
+	u32		parm2;
+	u32		parm3;
+	u32		parm4;
+	u32		count;	/* sizeof(((struct aac_get_name_resp *)NULL)->data) */
+};
+
+#define CT_OK        218
+struct aac_get_name_resp {
+	u32		dummy0;
+	u32		dummy1;
+	u32		status;	/* CT_OK */
+	u32		parm1;
+	u32		parm2;
+	u32		parm3;
+	u32		parm4;
+	u32		parm5;
+	u8		data[16];
+};
+
 /*
  * The following command is sent to shut down each container.
  */
@@ -1443,6 +1563,7 @@
 int fib_complete(struct fib * context);
 #define fib_data(fibctx) ((void *)(fibctx)->hw_fib->data)
 struct aac_dev *aac_init_adapter(struct aac_dev *dev);
+int aac_get_config_status(struct aac_dev *dev);
 int aac_get_containers(struct aac_dev *dev);
 int aac_scsi_cmd(struct scsi_cmnd *cmd);
 int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg);
diff -Nru a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
--- a/drivers/scsi/aacraid/linit.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/aacraid/linit.c	2004-12-24 13:36:47 -08:00
@@ -65,8 +65,7 @@
 MODULE_LICENSE("GPL");
 MODULE_VERSION(AAC_DRIVER_VERSION);
 
-struct aac_dev *aac_devices[MAXIMUM_NUM_ADAPTERS];
-static unsigned aac_count;
+static LIST_HEAD(aac_devices);
 static int aac_cfg_major = -1;
 
 /*
@@ -452,11 +451,18 @@
 
 static int aac_cfg_open(struct inode *inode, struct file *file)
 {
+	struct aac_dev *aac;
 	unsigned minor = iminor(inode);
+	int err = -ENODEV;
+
+	list_for_each_entry(aac, &aac_devices, entry) {
+		if (aac->id == minor) {
+			file->private_data = aac;
+			err = 0;
+			break;
+		}
+	}
 
-	if (minor >= aac_count)
-		return -ENODEV;
-	file->private_data = aac_devices[minor];
 	return 0;
 }
 
@@ -515,10 +521,18 @@
 {
 	unsigned index = id->driver_data;
 	struct Scsi_Host *shost;
-	struct fsa_scsi_hba *fsa_dev_ptr;
 	struct aac_dev *aac;
-	int container;
+	struct list_head *insert = &aac_devices;
 	int error = -ENODEV;
+	int unique_id = 0;
+
+	list_for_each_entry(aac, &aac_devices, entry) {
+		if (aac->id > unique_id) {
+			insert = &aac->entry;
+			break;
+		}
+		unique_id++;
+	}
 
 	if (pci_enable_device(pdev))
 		goto out;
@@ -537,16 +551,13 @@
 	
 	pci_set_master(pdev);
 
-	/* Increment the host adapter count */
-	aac_count++;
-
 	shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));
 	if (!shost)
 		goto out_disable_pdev;
 
 	shost->irq = pdev->irq;
 	shost->base = pci_resource_start(pdev, 0);
-	shost->unique_id = aac_count - 1;
+	shost->unique_id = unique_id;
 
 	aac = (struct aac_dev *)shost->hostdata;
 	aac->scsi_host_ptr = shost;	
@@ -554,17 +565,13 @@
 	aac->name = aac_driver_template.name;
 	aac->id = shost->unique_id;
 	aac->cardtype =  index;
+	INIT_LIST_HEAD(&aac->entry);
 
 	aac->fibs = kmalloc(sizeof(struct fib) * AAC_NUM_FIB, GFP_KERNEL);
 	if (!aac->fibs)
 		goto out_free_host;
 	spin_lock_init(&aac->fib_lock);
 
-	/* Initialize the ordinal number of the device to -1 */
-	fsa_dev_ptr = &aac->fsa_dev;
-	for (container = 0; container < MAXIMUM_NUM_CONTAINERS; container++)
-		fsa_dev_ptr->devname[container][0] = '\0';
-
 	if ((*aac_drivers[index].init)(aac))
 		goto out_free_fibs;
 
@@ -589,26 +596,32 @@
 	else
 		shost->max_channel = 1;
 
+	aac_get_config_status(aac);
 	aac_get_containers(aac);
-	aac_devices[aac_count-1] = aac;
+	list_add(&aac->entry, insert);
+
+	shost->max_id = aac->maximum_num_containers;
+	if (shost->max_id < MAXIMUM_NUM_CONTAINERS)
+		shost->max_id = MAXIMUM_NUM_CONTAINERS;
+	else
+		shost->this_id = shost->max_id;
 
 	/*
 	 * dmb - we may need to move the setting of these parms somewhere else once
 	 * we get a fib that can report the actual numbers
 	 */
-	shost->max_id = MAXIMUM_NUM_CONTAINERS;
 	shost->max_lun = AAC_MAX_LUN;
 
+	pci_set_drvdata(pdev, shost);
+
 	error = scsi_add_host(shost, &pdev->dev);
 	if (error)
 		goto out_deinit;
-
-	pci_set_drvdata(pdev, shost);
 	scsi_scan_host(shost);
 
 	return 0;
 
- out_deinit:
+out_deinit:
 	kill_proc(aac->thread_pid, SIGKILL, 0);
 	wait_for_completion(&aac->aif_completion);
 
@@ -617,14 +630,14 @@
 	pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys);
 	kfree(aac->queues);
 	free_irq(pdev->irq, aac);
-	iounmap((void * )aac->regs.sa);
+	iounmap(aac->regs.sa);
  out_free_fibs:
 	kfree(aac->fibs);
+	kfree(aac->fsa_dev);
  out_free_host:
 	scsi_host_put(shost);
  out_disable_pdev:
 	pci_disable_device(pdev);
-	aac_count--;
  out:
 	return error;
 }
@@ -646,22 +659,13 @@
 	kfree(aac->queues);
 
 	free_irq(pdev->irq, aac);
-	iounmap((void * )aac->regs.sa);
+	iounmap(aac->regs.sa);
 	
 	kfree(aac->fibs);
 	
+	list_del(&aac->entry);
 	scsi_host_put(shost);
 	pci_disable_device(pdev);
-
-	/*
-	 * We don't decrement aac_count here because adapters can be unplugged
-	 * in a different order than they were detected.  If we're ever going
-	 * to overflow MAXIMUM_NUM_ADAPTERS we'll have to consider using a
-	 * bintmap of free aac_devices slots.
-	 */
-#if 0
-	aac_count--;
-#endif
 }
 
 static struct pci_driver aac_pci_driver = {
diff -Nru a/drivers/scsi/aacraid/rkt.c b/drivers/scsi/aacraid/rkt.c
--- a/drivers/scsi/aacraid/rkt.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/aacraid/rkt.c	2004-12-24 13:37:18 -08:00
@@ -88,66 +88,6 @@
 }
 
 /**
- *	aac_rkt_enable_interrupt	-	Enable event reporting
- *	@dev: Adapter
- *	@event: Event to enable
- *
- *	Enable event reporting from the i960 for a given event.
- */
- 
-static void aac_rkt_enable_interrupt(struct aac_dev * dev, u32 event)
-{
-	switch (event) {
-
-	case HostNormCmdQue:
-		dev->irq_mask &= ~(OUTBOUNDDOORBELL_1);
-		break;
-
-	case HostNormRespQue:
-		dev->irq_mask &= ~(OUTBOUNDDOORBELL_2);
-		break;
-
-	case AdapNormCmdNotFull:
-		dev->irq_mask &= ~(OUTBOUNDDOORBELL_3);
-		break;
-
-	case AdapNormRespNotFull:
-		dev->irq_mask &= ~(OUTBOUNDDOORBELL_4);
-		break;
-	}
-}
-
-/**
- *	aac_rkt_disable_interrupt	-	Disable event reporting
- *	@dev: Adapter
- *	@event: Event to enable
- *
- *	Disable event reporting from the i960 for a given event.
- */
-
-static void aac_rkt_disable_interrupt(struct aac_dev *dev, u32 event)
-{
-	switch (event) {
-
-	case HostNormCmdQue:
-		dev->irq_mask |= (OUTBOUNDDOORBELL_1);
-		break;
-
-	case HostNormRespQue:
-		dev->irq_mask |= (OUTBOUNDDOORBELL_2);
-		break;
-
-	case AdapNormCmdNotFull:
-		dev->irq_mask |= (OUTBOUNDDOORBELL_3);
-		break;
-
-	case AdapNormRespNotFull:
-		dev->irq_mask |= (OUTBOUNDDOORBELL_4);
-		break;
-	}
-}
-
-/**
  *	rkt_sync_cmd	-	send a command and wait
  *	@dev: Adapter
  *	@command: Command to execute
@@ -180,7 +120,7 @@
 	/*
 	 *	Disable doorbell interrupts
 	 */
-	rkt_writeb(dev, MUnit.OIMR, dev->OIMR |= 0x04);
+	rkt_writeb(dev, MUnit.OIMR, dev->OIMR = 0xff);
 	/*
 	 *	Force the completion of the mask register write before issuing
 	 *	the interrupt.
@@ -221,13 +161,14 @@
 		/*
 		 *	Restore interrupt mask even though we timed out
 		 */
-		rkt_writeb(dev, MUnit.OIMR, dev->OIMR &= 0xfb);
+		rkt_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb);
 		return -ETIMEDOUT;
 	}
 	/*
 	 *	Pull the synch status from Mailbox 0.
 	 */
-	*status = le32_to_cpu(rkt_readl(dev, IndexRegs.Mailbox[0]));
+	if (status)
+		*status = le32_to_cpu(rkt_readl(dev, IndexRegs.Mailbox[0]));
 	/*
 	 *	Clear the synch command doorbell.
 	 */
@@ -235,7 +176,7 @@
 	/*
 	 *	Restore interrupt mask
 	 */
-	rkt_writeb(dev, MUnit.OIMR, dev->OIMR &= 0xfb);
+	rkt_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb);
 	return 0;
 
 }
@@ -334,7 +275,7 @@
  */
 static int aac_rkt_check_health(struct aac_dev *dev)
 {
-	long status = rkt_readl(dev, IndexRegs.Mailbox[7]);
+	u32 status = le32_to_cpu(rkt_readl(dev, MUnit.OMRx[0]));
 
 	/*
 	 *	Check to see if the board failed any self tests.
@@ -344,34 +285,42 @@
 	/*
 	 *	Check to see if the board panic'd.
 	 */
-	if (status & KERNEL_PANIC)
-	{
-		char * buffer = kmalloc(512, GFP_KERNEL|__GFP_DMA);
+	if (status & KERNEL_PANIC) {
+		char * buffer;
 		struct POSTSTATUS {
 			u32 Post_Command;
 			u32 Post_Address;
-		} * post = kmalloc(sizeof(struct POSTSTATUS), GFP_KERNEL);
-		dma_addr_t paddr = pci_map_single(dev->pdev, post, sizeof(struct POSTSTATUS), 2);
-		dma_addr_t baddr = pci_map_single(dev->pdev, buffer, 512, 1);
-		u32 status = -1;
-		int ret = -2;
-		
-		memset(buffer, 0, 512);
-		post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS);
-		post->Post_Address = cpu_to_le32(baddr);
-		rkt_writel(dev, MUnit.IMRx[0], cpu_to_le32(paddr));
-		rkt_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, &status);
-		pci_unmap_single(dev->pdev, paddr, sizeof(struct POSTSTATUS),2);
-		kfree(post);
-		if ((buffer[0] == '0') && (buffer[1] == 'x')) {
-			ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10);
-			ret <<= 4;
-			ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10);
+		} * post;
+		dma_addr_t paddr, baddr;
+		int ret;
+
+		if ((status & 0xFF000000L) == 0xBC000000L)
+			return (status >> 16) & 0xFF;
+		buffer = pci_alloc_consistent(dev->pdev, 512, &baddr);
+		ret = -2;
+		if (buffer == NULL)
+			return ret;
+		post = pci_alloc_consistent(dev->pdev,
+		  sizeof(struct POSTSTATUS), &paddr);
+		if (post == NULL) {
+			pci_free_consistent(dev->pdev, 512, buffer, baddr);
+			return ret;
 		}
-		pci_unmap_single(dev->pdev, baddr, 512, 1);
-		kfree(buffer);
-		return ret;
-	}
+                memset(buffer, 0, 512);
+                post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS);
+                post->Post_Address = cpu_to_le32(baddr);
+                rkt_writel(dev, MUnit.IMRx[0], cpu_to_le32(paddr));
+                rkt_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, &status);
+		pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
+		  post, paddr);
+                if ((buffer[0] == '0') && (buffer[1] == 'x')) {
+                        ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10);
+                        ret <<= 4;
+                        ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10);
+                }
+		pci_free_consistent(dev->pdev, 512, buffer, baddr);
+                return ret;
+        }
 	/*
 	 *	Wait for the adapter to be up and running.
 	 */
@@ -405,7 +354,7 @@
 	/*
 	 *	Map in the registers from the adapter.
 	 */
-	if((dev->regs.rkt = (struct rkt_registers *)ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL)
+	if((dev->regs.rkt = ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL)
 	{	
 		printk(KERN_WARNING "aacraid: unable to map i960.\n" );
 		goto error_iounmap;
@@ -455,8 +404,6 @@
 	 *	Fill in the function dispatch table.
 	 */
 	dev->a_ops.adapter_interrupt = aac_rkt_interrupt_adapter;
-	dev->a_ops.adapter_enable_int = aac_rkt_enable_interrupt;
-	dev->a_ops.adapter_disable_int = aac_rkt_disable_interrupt;
 	dev->a_ops.adapter_notify = aac_rkt_notify_adapter;
 	dev->a_ops.adapter_sync_cmd = rkt_sync_cmd;
 	dev->a_ops.adapter_check_health = aac_rkt_check_health;
diff -Nru a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
--- a/drivers/scsi/aacraid/rx.c	2004-12-24 13:37:44 -08:00
+++ b/drivers/scsi/aacraid/rx.c	2004-12-24 13:37:44 -08:00
@@ -88,66 +88,6 @@
 }
 
 /**
- *	aac_rx_enable_interrupt	-	Enable event reporting
- *	@dev: Adapter
- *	@event: Event to enable
- *
- *	Enable event reporting from the i960 for a given event.
- */
- 
-static void aac_rx_enable_interrupt(struct aac_dev * dev, u32 event)
-{
-	switch (event) {
-
-	case HostNormCmdQue:
-		dev->irq_mask &= ~(OUTBOUNDDOORBELL_1);
-		break;
-
-	case HostNormRespQue:
-		dev->irq_mask &= ~(OUTBOUNDDOORBELL_2);
-		break;
-
-	case AdapNormCmdNotFull:
-		dev->irq_mask &= ~(OUTBOUNDDOORBELL_3);
-		break;
-
-	case AdapNormRespNotFull:
-		dev->irq_mask &= ~(OUTBOUNDDOORBELL_4);
-		break;
-	}
-}
-
-/**
- *	aac_rx_disable_interrupt	-	Disable event reporting
- *	@dev: Adapter
- *	@event: Event to enable
- *
- *	Disable event reporting from the i960 for a given event.
- */
-
-static void aac_rx_disable_interrupt(struct aac_dev *dev, u32 event)
-{
-	switch (event) {
-
-	case HostNormCmdQue:
-		dev->irq_mask |= (OUTBOUNDDOORBELL_1);
-		break;
-
-	case HostNormRespQue:
-		dev->irq_mask |= (OUTBOUNDDOORBELL_2);
-		break;
-
-	case AdapNormCmdNotFull:
-		dev->irq_mask |= (OUTBOUNDDOORBELL_3);
-		break;
-
-	case AdapNormRespNotFull:
-		dev->irq_mask |= (OUTBOUNDDOORBELL_4);
-		break;
-	}
-}
-
-/**
  *	rx_sync_cmd	-	send a command and wait
  *	@dev: Adapter
  *	@command: Command to execute
@@ -334,7 +274,7 @@
  */
 static int aac_rx_check_health(struct aac_dev *dev)
 {
-	long status = rx_readl(dev, IndexRegs.Mailbox[7]);
+	u32 status = le32_to_cpu(rx_readl(dev, MUnit.OMRx[0]));
 
 	/*
 	 *	Check to see if the board failed any self tests.
@@ -345,29 +285,39 @@
 	 *	Check to see if the board panic'd.
 	 */
 	if (status & KERNEL_PANIC) {
-		char * buffer = kmalloc(512, GFP_KERNEL);
+		char * buffer;
 		struct POSTSTATUS {
 			u32 Post_Command;
 			u32 Post_Address;
-		} * post = kmalloc(sizeof(struct POSTSTATUS), GFP_KERNEL);
-		dma_addr_t paddr = pci_map_single(dev->pdev, post, sizeof(struct POSTSTATUS), 2);
-		dma_addr_t baddr = pci_map_single(dev->pdev, buffer, 512, 1);
-		u32 status = -1;
-		int ret = -2;
+		} * post;
+		dma_addr_t paddr, baddr;
+		int ret;
+
+		if ((status & 0xFF000000L) == 0xBC000000L)
+			return (status >> 16) & 0xFF;
+		buffer = pci_alloc_consistent(dev->pdev, 512, &baddr);
+		ret = -2;
+		if (buffer == NULL)
+			return ret;
+		post = pci_alloc_consistent(dev->pdev,
+		  sizeof(struct POSTSTATUS), &paddr);
+		if (post == NULL) {
+			pci_free_consistent(dev->pdev, 512, buffer, baddr);
+			return ret;
+		}
 		memset(buffer, 0, 512);
 		post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS);
 		post->Post_Address = cpu_to_le32(baddr);
 		rx_writel(dev, MUnit.IMRx[0], cpu_to_le32(paddr));
 		rx_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, &status);
-		pci_unmap_single(dev->pdev, paddr, sizeof(struct POSTSTATUS), 2);
-		kfree(post);
+		pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
+		  post, paddr);
 		if ((buffer[0] == '0') && (buffer[1] == 'x')) {
 			ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10);
 			ret <<= 4;
 			ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10);
 		}
-		pci_unmap_single(dev->pdev, baddr, 512, 1);
-		kfree(buffer);
+		pci_free_consistent(dev->pdev, 512, buffer, baddr);
 		return ret;
 	}
 	/*
@@ -379,7 +329,7 @@
 	 *	Everything is OK
 	 */
 	return 0;
-} /* aac_rx_check_health */
+}
 
 /**
  *	aac_rx_init	-	initialize an i960 based AAC card
@@ -403,7 +353,7 @@
 	/*
 	 *	Map in the registers from the adapter.
 	 */
-	if((dev->regs.rx = (struct rx_registers *)ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL)
+	if((dev->regs.rx = ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL)
 	{	
 		printk(KERN_WARNING "aacraid: unable to map i960.\n" );
 		return -1;
@@ -454,8 +404,6 @@
 	 *	Fill in the function dispatch table.
 	 */
 	dev->a_ops.adapter_interrupt = aac_rx_interrupt_adapter;
-	dev->a_ops.adapter_enable_int = aac_rx_enable_interrupt;
-	dev->a_ops.adapter_disable_int = aac_rx_disable_interrupt;
 	dev->a_ops.adapter_notify = aac_rx_notify_adapter;
 	dev->a_ops.adapter_sync_cmd = rx_sync_cmd;
 	dev->a_ops.adapter_check_health = aac_rx_check_health;
diff -Nru a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
--- a/drivers/scsi/aacraid/sa.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/scsi/aacraid/sa.c	2004-12-24 13:36:59 -08:00
@@ -82,68 +82,6 @@
 }
 
 /**
- *	aac_sa_enable_interrupt	-	enable an interrupt event
- *	@dev: Which adapter to enable.
- *	@event: Which adapter event.
- *
- *	This routine will enable the corresponding adapter event to cause an interrupt on 
- * 	the host.
- */
- 
-void aac_sa_enable_interrupt(struct aac_dev *dev, u32 event)
-{
-	switch (event) {
-
-	case HostNormCmdQue:
-		sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, DOORBELL_1);
-		break;
-
-	case HostNormRespQue:
-		sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, DOORBELL_2);
-		break;
-
-	case AdapNormCmdNotFull:
-		sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, DOORBELL_3);
-		break;
-
-	case AdapNormRespNotFull:
-		sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, DOORBELL_4);
-		break;
-	}
-}
-
-/**
- *	aac_sa_disable_interrupt	-	disable an interrupt event
- *	@dev: Which adapter to enable.
- *	@event: Which adapter event.
- *
- *	This routine will enable the corresponding adapter event to cause an interrupt on 
- * 	the host.
- */
-
-void aac_sa_disable_interrupt (struct aac_dev *dev, u32 event)
-{
-	switch (event) {
-
-	case HostNormCmdQue:
-		sa_writew(dev, SaDbCSR.PRISETIRQMASK, DOORBELL_1);
-		break;
-
-	case HostNormRespQue:
-		sa_writew(dev, SaDbCSR.PRISETIRQMASK, DOORBELL_2);
-		break;
-
-	case AdapNormCmdNotFull:
-		sa_writew(dev, SaDbCSR.PRISETIRQMASK, DOORBELL_3);
-		break;
-
-	case AdapNormRespNotFull:
-		sa_writew(dev, SaDbCSR.PRISETIRQMASK, DOORBELL_4);
-		break;
-	}
-}
-
-/**
  *	aac_sa_notify_adapter		-	handle adapter notification
  *	@dev:	Adapter that notification is for
  *	@event:	Event to notidy
@@ -357,7 +295,7 @@
 	 */
 	dprintk(("PREMAP\n"));
 
-	if((dev->regs.sa = (struct sa_registers *)ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL)
+	if((dev->regs.sa = ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL)
 	{	
 		printk(KERN_WARNING "aacraid: unable to map ARM.\n" );
 		goto error_iounmap;
@@ -401,8 +339,6 @@
 	 */
 
 	dev->a_ops.adapter_interrupt = aac_sa_interrupt_adapter;
-	dev->a_ops.adapter_enable_int = aac_sa_enable_interrupt;
-	dev->a_ops.adapter_disable_int = aac_sa_disable_interrupt;
 	dev->a_ops.adapter_notify = aac_sa_notify_adapter;
 	dev->a_ops.adapter_sync_cmd = sa_sync_cmd;
 	dev->a_ops.adapter_check_health = aac_sa_check_health;
diff -Nru a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
--- a/drivers/scsi/advansys.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/scsi/advansys.c	2004-12-24 13:36:32 -08:00
@@ -796,6 +796,7 @@
 
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
+#include <scsi/scsi_tcq.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 #include "advansys.h"
@@ -4566,7 +4567,7 @@
             boardp->id = asc_board_count - 1;
 
             /* Initialize spinlock. */
-            boardp->lock = SPIN_LOCK_UNLOCKED;
+            spin_lock_init(&boardp->lock);
 
             /*
              * Handle both narrow and wide boards.
diff -Nru a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
--- a/drivers/scsi/aha152x.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/aha152x.c	2004-12-24 13:36:17 -08:00
@@ -3830,10 +3830,15 @@
 	if (setup_count<ARRAY_SIZE(setup)) {
 #if !defined(SKIP_BIOSTEST)
 		ok = 0;
-		for (i = 0; i < ARRAY_SIZE(addresses) && !ok; i++)
+		for (i = 0; i < ARRAY_SIZE(addresses) && !ok; i++) {
+			void __iomem *p = ioremap(addresses[i], 0x4000);
+			if (!p)
+				continue;
 			for (j = 0; j<ARRAY_SIZE(signatures) && !ok; j++)
-				ok = isa_check_signature(addresses[i] + signatures[j].sig_offset,
+				ok = check_signature(p + signatures[j].sig_offset,
 								signatures[j].signature, signatures[j].sig_length);
+			iounmap(p);
+		}
 		if (!ok && setup_count == 0)
 			return 0;
 
diff -Nru a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
--- a/drivers/scsi/aha1542.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/scsi/aha1542.c	2004-12-24 13:36:55 -08:00
@@ -129,8 +129,8 @@
  */
 
 #if defined(MODULE)
-int isapnp = 0;
-int aha1542[] = {0x330, 11, 4, -1};
+static int isapnp = 0;
+static int aha1542[] = {0x330, 11, 4, -1};
 MODULE_PARM(aha1542, "1-4i");
 MODULE_PARM(isapnp, "i");
 
@@ -951,7 +951,7 @@
 static char *setup_str[MAXBOARDS] __initdata;
 static int setup_idx = 0;
 
-void __init aha1542_setup(char *str, int *ints)
+static void __init aha1542_setup(char *str, int *ints)
 {
 	const char *ahausage = "aha1542: usage: aha1542=<PORTBASE>[,<BUSON>,<BUSOFF>[,<DMASPEED>]]\n";
 	int setup_portbase;
diff -Nru a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/ahci.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1040 @@
+/*
+ *  ahci.c - AHCI SATA support
+ *
+ *  Copyright 2004 Red Hat, Inc.
+ *
+ *  The contents of this file are subject to the Open
+ *  Software License version 1.1 that can be found at
+ *  http://www.opensource.org/licenses/osl-1.1.txt and is included herein
+ *  by reference.
+ *
+ *  Alternatively, the contents of this file may be used under the terms
+ *  of the GNU General Public License version 2 (the "GPL") as distributed
+ *  in the kernel source COPYING file, in which case the provisions of
+ *  the GPL are applicable instead of the above.  If you wish to allow
+ *  the use of your version of this file only under the terms of the
+ *  GPL and not to allow others to use your version of this file under
+ *  the OSL, indicate your decision by deleting the provisions above and
+ *  replace them with the notice and other provisions required by the GPL.
+ *  If you do not delete the provisions above, a recipient may use your
+ *  version of this file under either the OSL or the GPL.
+ *
+ * Version 1.0 of the AHCI specification:
+ * http://www.intel.com/technology/serialata/pdf/rev1_0.pdf
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+#include "scsi.h"
+#include <scsi/scsi_host.h>
+#include <linux/libata.h>
+#include <asm/io.h>
+
+#define DRV_NAME	"ahci"
+#define DRV_VERSION	"1.00"
+
+
+enum {
+	AHCI_PCI_BAR		= 5,
+	AHCI_MAX_SG		= 168, /* hardware max is 64K */
+	AHCI_DMA_BOUNDARY	= 0xffffffff,
+	AHCI_USE_CLUSTERING	= 0,
+	AHCI_CMD_SLOT_SZ	= 32 * 32,
+	AHCI_RX_FIS_SZ		= 256,
+	AHCI_CMD_TBL_HDR	= 0x80,
+	AHCI_CMD_TBL_SZ		= AHCI_CMD_TBL_HDR + (AHCI_MAX_SG * 16),
+	AHCI_PORT_PRIV_DMA_SZ	= AHCI_CMD_SLOT_SZ + AHCI_CMD_TBL_SZ +
+				  AHCI_RX_FIS_SZ,
+	AHCI_IRQ_ON_SG		= (1 << 31),
+	AHCI_CMD_ATAPI		= (1 << 5),
+	AHCI_CMD_WRITE		= (1 << 6),
+
+	RX_FIS_D2H_REG		= 0x40,	/* offset of D2H Register FIS data */
+
+	board_ahci		= 0,
+
+	/* global controller registers */
+	HOST_CAP		= 0x00, /* host capabilities */
+	HOST_CTL		= 0x04, /* global host control */
+	HOST_IRQ_STAT		= 0x08, /* interrupt status */
+	HOST_PORTS_IMPL		= 0x0c, /* bitmap of implemented ports */
+	HOST_VERSION		= 0x10, /* AHCI spec. version compliancy */
+
+	/* HOST_CTL bits */
+	HOST_RESET		= (1 << 0),  /* reset controller; self-clear */
+	HOST_IRQ_EN		= (1 << 1),  /* global IRQ enable */
+	HOST_AHCI_EN		= (1 << 31), /* AHCI enabled */
+
+	/* HOST_CAP bits */
+	HOST_CAP_64		= (1 << 31), /* PCI DAC (64-bit DMA) support */
+
+	/* registers for each SATA port */
+	PORT_LST_ADDR		= 0x00, /* command list DMA addr */
+	PORT_LST_ADDR_HI	= 0x04, /* command list DMA addr hi */
+	PORT_FIS_ADDR		= 0x08, /* FIS rx buf addr */
+	PORT_FIS_ADDR_HI	= 0x0c, /* FIS rx buf addr hi */
+	PORT_IRQ_STAT		= 0x10, /* interrupt status */
+	PORT_IRQ_MASK		= 0x14, /* interrupt enable/disable mask */
+	PORT_CMD		= 0x18, /* port command */
+	PORT_TFDATA		= 0x20,	/* taskfile data */
+	PORT_SIG		= 0x24,	/* device TF signature */
+	PORT_CMD_ISSUE		= 0x38, /* command issue */
+	PORT_SCR		= 0x28, /* SATA phy register block */
+	PORT_SCR_STAT		= 0x28, /* SATA phy register: SStatus */
+	PORT_SCR_CTL		= 0x2c, /* SATA phy register: SControl */
+	PORT_SCR_ERR		= 0x30, /* SATA phy register: SError */
+	PORT_SCR_ACT		= 0x34, /* SATA phy register: SActive */
+
+	/* PORT_IRQ_{STAT,MASK} bits */
+	PORT_IRQ_COLD_PRES	= (1 << 31), /* cold presence detect */
+	PORT_IRQ_TF_ERR		= (1 << 30), /* task file error */
+	PORT_IRQ_HBUS_ERR	= (1 << 29), /* host bus fatal error */
+	PORT_IRQ_HBUS_DATA_ERR	= (1 << 28), /* host bus data error */
+	PORT_IRQ_IF_ERR		= (1 << 27), /* interface fatal error */
+	PORT_IRQ_IF_NONFATAL	= (1 << 26), /* interface non-fatal error */
+	PORT_IRQ_OVERFLOW	= (1 << 24), /* xfer exhausted available S/G */
+	PORT_IRQ_BAD_PMP	= (1 << 23), /* incorrect port multiplier */
+
+	PORT_IRQ_PHYRDY		= (1 << 22), /* PhyRdy changed */
+	PORT_IRQ_DEV_ILCK	= (1 << 7), /* device interlock */
+	PORT_IRQ_CONNECT	= (1 << 6), /* port connect change status */
+	PORT_IRQ_SG_DONE	= (1 << 5), /* descriptor processed */
+	PORT_IRQ_UNK_FIS	= (1 << 4), /* unknown FIS rx'd */
+	PORT_IRQ_SDB_FIS	= (1 << 3), /* Set Device Bits FIS rx'd */
+	PORT_IRQ_DMAS_FIS	= (1 << 2), /* DMA Setup FIS rx'd */
+	PORT_IRQ_PIOS_FIS	= (1 << 1), /* PIO Setup FIS rx'd */
+	PORT_IRQ_D2H_REG_FIS	= (1 << 0), /* D2H Register FIS rx'd */
+
+	PORT_IRQ_FATAL		= PORT_IRQ_TF_ERR |
+				  PORT_IRQ_HBUS_ERR |
+				  PORT_IRQ_HBUS_DATA_ERR |
+				  PORT_IRQ_IF_ERR,
+	DEF_PORT_IRQ		= PORT_IRQ_FATAL | PORT_IRQ_PHYRDY |
+				  PORT_IRQ_CONNECT | PORT_IRQ_SG_DONE |
+				  PORT_IRQ_UNK_FIS | PORT_IRQ_SDB_FIS |
+				  PORT_IRQ_DMAS_FIS | PORT_IRQ_PIOS_FIS |
+				  PORT_IRQ_D2H_REG_FIS,
+
+	/* PORT_CMD bits */
+	PORT_CMD_LIST_ON	= (1 << 15), /* cmd list DMA engine running */
+	PORT_CMD_FIS_ON		= (1 << 14), /* FIS DMA engine running */
+	PORT_CMD_FIS_RX		= (1 << 4), /* Enable FIS receive DMA engine */
+	PORT_CMD_POWER_ON	= (1 << 2), /* Power up device */
+	PORT_CMD_SPIN_UP	= (1 << 1), /* Spin up device */
+	PORT_CMD_START		= (1 << 0), /* Enable port DMA engine */
+
+	PORT_CMD_ICC_ACTIVE	= (0x1 << 28), /* Put i/f in active state */
+	PORT_CMD_ICC_PARTIAL	= (0x2 << 28), /* Put i/f in partial state */
+	PORT_CMD_ICC_SLUMBER	= (0x6 << 28), /* Put i/f in slumber state */
+};
+
+struct ahci_cmd_hdr {
+	u32			opts;
+	u32			status;
+	u32			tbl_addr;
+	u32			tbl_addr_hi;
+	u32			reserved[4];
+};
+
+struct ahci_sg {
+	u32			addr;
+	u32			addr_hi;
+	u32			reserved;
+	u32			flags_size;
+};
+
+struct ahci_host_priv {
+	unsigned long		flags;
+	u32			cap;	/* cache of HOST_CAP register */
+	u32			port_map; /* cache of HOST_PORTS_IMPL reg */
+};
+
+struct ahci_port_priv {
+	struct ahci_cmd_hdr	*cmd_slot;
+	dma_addr_t		cmd_slot_dma;
+	void			*cmd_tbl;
+	dma_addr_t		cmd_tbl_dma;
+	struct ahci_sg		*cmd_tbl_sg;
+	void			*rx_fis;
+	dma_addr_t		rx_fis_dma;
+};
+
+static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg);
+static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
+static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
+static int ahci_qc_issue(struct ata_queued_cmd *qc);
+static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
+static void ahci_phy_reset(struct ata_port *ap);
+static void ahci_irq_clear(struct ata_port *ap);
+static void ahci_eng_timeout(struct ata_port *ap);
+static int ahci_port_start(struct ata_port *ap);
+static void ahci_port_stop(struct ata_port *ap);
+static void ahci_host_stop(struct ata_host_set *host_set);
+static void ahci_qc_prep(struct ata_queued_cmd *qc);
+static u8 ahci_check_status(struct ata_port *ap);
+static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
+
+static Scsi_Host_Template ahci_sht = {
+	.module			= THIS_MODULE,
+	.name			= DRV_NAME,
+	.ioctl			= ata_scsi_ioctl,
+	.queuecommand		= ata_scsi_queuecmd,
+	.eh_strategy_handler	= ata_scsi_error,
+	.can_queue		= ATA_DEF_QUEUE,
+	.this_id		= ATA_SHT_THIS_ID,
+	.sg_tablesize		= AHCI_MAX_SG,
+	.max_sectors		= ATA_MAX_SECTORS,
+	.cmd_per_lun		= ATA_SHT_CMD_PER_LUN,
+	.emulated		= ATA_SHT_EMULATED,
+	.use_clustering		= AHCI_USE_CLUSTERING,
+	.proc_name		= DRV_NAME,
+	.dma_boundary		= AHCI_DMA_BOUNDARY,
+	.slave_configure	= ata_scsi_slave_config,
+	.bios_param		= ata_std_bios_param,
+};
+
+static struct ata_port_operations ahci_ops = {
+	.port_disable		= ata_port_disable,
+
+	.check_status		= ahci_check_status,
+	.dev_select		= ata_noop_dev_select,
+
+	.phy_reset		= ahci_phy_reset,
+
+	.qc_prep		= ahci_qc_prep,
+	.qc_issue		= ahci_qc_issue,
+
+	.eng_timeout		= ahci_eng_timeout,
+
+	.irq_handler		= ahci_interrupt,
+	.irq_clear		= ahci_irq_clear,
+
+	.scr_read		= ahci_scr_read,
+	.scr_write		= ahci_scr_write,
+
+	.port_start		= ahci_port_start,
+	.port_stop		= ahci_port_stop,
+	.host_stop		= ahci_host_stop,
+};
+
+static struct ata_port_info ahci_port_info[] = {
+	/* board_ahci */
+	{
+		.sht		= &ahci_sht,
+		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+				  ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
+				  ATA_FLAG_PIO_DMA,
+		.pio_mask	= 0x03, /* pio3-4 */
+		.udma_mask	= 0x7f, /* udma0-6 ; FIXME */
+		.port_ops	= &ahci_ops,
+	},
+};
+
+static struct pci_device_id ahci_pci_tbl[] = {
+	{ PCI_VENDOR_ID_INTEL, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+	  board_ahci },
+	{ PCI_VENDOR_ID_INTEL, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+	  board_ahci },
+	{ }	/* terminate list */
+};
+
+
+static struct pci_driver ahci_pci_driver = {
+	.name			= DRV_NAME,
+	.id_table		= ahci_pci_tbl,
+	.probe			= ahci_init_one,
+	.remove			= ata_pci_remove_one,
+};
+
+
+static inline unsigned long ahci_port_base_ul (unsigned long base, unsigned int port)
+{
+	return base + 0x100 + (port * 0x80);
+}
+
+static inline void *ahci_port_base (void *base, unsigned int port)
+{
+	return (void *) ahci_port_base_ul((unsigned long)base, port);
+}
+
+static void ahci_host_stop(struct ata_host_set *host_set)
+{
+	struct ahci_host_priv *hpriv = host_set->private_data;
+	kfree(hpriv);
+}
+
+static int ahci_port_start(struct ata_port *ap)
+{
+	struct device *dev = ap->host_set->dev;
+	struct ahci_host_priv *hpriv = ap->host_set->private_data;
+	struct ahci_port_priv *pp;
+	int rc;
+	void *mem, *mmio = ap->host_set->mmio_base;
+	void *port_mmio = ahci_port_base(mmio, ap->port_no);
+	dma_addr_t mem_dma;
+
+	rc = ata_port_start(ap);
+	if (rc)
+		return rc;
+
+	pp = kmalloc(sizeof(*pp), GFP_KERNEL);
+	if (!pp) {
+		rc = -ENOMEM;
+		goto err_out;
+	}
+	memset(pp, 0, sizeof(*pp));
+
+	mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL);
+	if (!mem) {
+		rc = -ENOMEM;
+		goto err_out_kfree;
+	}
+	memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
+
+	/*
+	 * First item in chunk of DMA memory: 32-slot command table,
+	 * 32 bytes each in size
+	 */
+	pp->cmd_slot = mem;
+	pp->cmd_slot_dma = mem_dma;
+
+	mem += AHCI_CMD_SLOT_SZ;
+	mem_dma += AHCI_CMD_SLOT_SZ;
+
+	/*
+	 * Second item: Received-FIS area
+	 */
+	pp->rx_fis = mem;
+	pp->rx_fis_dma = mem_dma;
+
+	mem += AHCI_RX_FIS_SZ;
+	mem_dma += AHCI_RX_FIS_SZ;
+
+	/*
+	 * Third item: data area for storing a single command
+	 * and its scatter-gather table
+	 */
+	pp->cmd_tbl = mem;
+	pp->cmd_tbl_dma = mem_dma;
+
+	pp->cmd_tbl_sg = mem + AHCI_CMD_TBL_HDR;
+
+	ap->private_data = pp;
+
+	if (hpriv->cap & HOST_CAP_64)
+		writel((pp->cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI);
+	writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
+	readl(port_mmio + PORT_LST_ADDR); /* flush */
+
+	if (hpriv->cap & HOST_CAP_64)
+		writel((pp->rx_fis_dma >> 16) >> 16, port_mmio + PORT_FIS_ADDR_HI);
+	writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
+	readl(port_mmio + PORT_FIS_ADDR); /* flush */
+
+	writel(PORT_CMD_ICC_ACTIVE | PORT_CMD_FIS_RX |
+	       PORT_CMD_POWER_ON | PORT_CMD_SPIN_UP |
+	       PORT_CMD_START, port_mmio + PORT_CMD);
+	readl(port_mmio + PORT_CMD); /* flush */
+
+	return 0;
+
+err_out_kfree:
+	kfree(pp);
+err_out:
+	ata_port_stop(ap);
+	return rc;
+}
+
+
+static void ahci_port_stop(struct ata_port *ap)
+{
+	struct device *dev = ap->host_set->dev;
+	struct ahci_port_priv *pp = ap->private_data;
+	void *mmio = ap->host_set->mmio_base;
+	void *port_mmio = ahci_port_base(mmio, ap->port_no);
+	u32 tmp;
+
+	tmp = readl(port_mmio + PORT_CMD);
+	tmp &= ~(PORT_CMD_START | PORT_CMD_FIS_RX);
+	writel(tmp, port_mmio + PORT_CMD);
+	readl(port_mmio + PORT_CMD); /* flush */
+
+	/* spec says 500 msecs for each PORT_CMD_{START,FIS_RX} bit, so
+	 * this is slightly incorrect.
+	 */
+	msleep(500);
+
+	ap->private_data = NULL;
+	dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
+			  pp->cmd_slot, pp->cmd_slot_dma);
+	kfree(pp);
+	ata_port_stop(ap);
+}
+
+static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
+{
+	unsigned int sc_reg;
+
+	switch (sc_reg_in) {
+	case SCR_STATUS:	sc_reg = 0; break;
+	case SCR_CONTROL:	sc_reg = 1; break;
+	case SCR_ERROR:		sc_reg = 2; break;
+	case SCR_ACTIVE:	sc_reg = 3; break;
+	default:
+		return 0xffffffffU;
+	}
+
+	return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4));
+}
+
+
+static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
+			       u32 val)
+{
+	unsigned int sc_reg;
+
+	switch (sc_reg_in) {
+	case SCR_STATUS:	sc_reg = 0; break;
+	case SCR_CONTROL:	sc_reg = 1; break;
+	case SCR_ERROR:		sc_reg = 2; break;
+	case SCR_ACTIVE:	sc_reg = 3; break;
+	default:
+		return;
+	}
+
+	writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4));
+}
+
+static void ahci_phy_reset(struct ata_port *ap)
+{
+	void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+	struct ata_taskfile tf;
+	struct ata_device *dev = &ap->device[0];
+	u32 tmp;
+
+	__sata_phy_reset(ap);
+
+	if (ap->flags & ATA_FLAG_PORT_DISABLED)
+		return;
+
+	tmp = readl(port_mmio + PORT_SIG);
+	tf.lbah		= (tmp >> 24)	& 0xff;
+	tf.lbam		= (tmp >> 16)	& 0xff;
+	tf.lbal		= (tmp >> 8)	& 0xff;
+	tf.nsect	= (tmp)		& 0xff;
+
+	dev->class = ata_dev_classify(&tf);
+	if (!ata_dev_present(dev))
+		ata_port_disable(ap);
+}
+
+static u8 ahci_check_status(struct ata_port *ap)
+{
+	void *mmio = (void *) ap->ioaddr.cmd_addr;
+
+	return readl(mmio + PORT_TFDATA) & 0xFF;
+}
+
+static void ahci_fill_sg(struct ata_queued_cmd *qc)
+{
+	struct ahci_port_priv *pp = qc->ap->private_data;
+	unsigned int i;
+
+	VPRINTK("ENTER\n");
+
+	/*
+	 * Next, the S/G list.
+	 */
+	for (i = 0; i < qc->n_elem; i++) {
+		u32 sg_len;
+		dma_addr_t addr;
+
+		addr = sg_dma_address(&qc->sg[i]);
+		sg_len = sg_dma_len(&qc->sg[i]);
+
+		pp->cmd_tbl_sg[i].addr = cpu_to_le32(addr & 0xffffffff);
+		pp->cmd_tbl_sg[i].addr_hi = cpu_to_le32((addr >> 16) >> 16);
+		pp->cmd_tbl_sg[i].flags_size = cpu_to_le32(sg_len - 1);
+	}
+}
+
+static void ahci_qc_prep(struct ata_queued_cmd *qc)
+{
+	struct ahci_port_priv *pp = qc->ap->private_data;
+	u32 opts;
+	const u32 cmd_fis_len = 5; /* five dwords */
+
+	/*
+	 * Fill in command slot information (currently only one slot,
+	 * slot 0, is currently since we don't do queueing)
+	 */
+
+	opts = (qc->n_elem << 16) | cmd_fis_len;
+	if (qc->tf.flags & ATA_TFLAG_WRITE)
+		opts |= AHCI_CMD_WRITE;
+
+	switch (qc->tf.protocol) {
+	case ATA_PROT_ATAPI:
+	case ATA_PROT_ATAPI_NODATA:
+	case ATA_PROT_ATAPI_DMA:
+		opts |= AHCI_CMD_ATAPI;
+		break;
+
+	default:
+		/* do nothing */
+		break;
+	}
+
+	pp->cmd_slot[0].opts = cpu_to_le32(opts);
+	pp->cmd_slot[0].status = 0;
+	pp->cmd_slot[0].tbl_addr = cpu_to_le32(pp->cmd_tbl_dma & 0xffffffff);
+	pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16);
+
+	/*
+	 * Fill in command table information.  First, the header,
+	 * a SATA Register - Host to Device command FIS.
+	 */
+	ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0);
+
+	if (!(qc->flags & ATA_QCFLAG_DMAMAP))
+		return;
+
+	ahci_fill_sg(qc);
+}
+
+static inline void ahci_dma_complete (struct ata_port *ap,
+                                     struct ata_queued_cmd *qc,
+				     int have_err)
+{
+	/* get drive status; clear intr; complete txn */
+	ata_qc_complete(ata_qc_from_tag(ap, ap->active_tag),
+			have_err ? ATA_ERR : 0);
+}
+
+static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
+{
+	void *mmio = ap->host_set->mmio_base;
+	void *port_mmio = ahci_port_base(mmio, ap->port_no);
+	u32 tmp;
+	int work;
+
+	/* stop DMA */
+	tmp = readl(port_mmio + PORT_CMD);
+	tmp &= PORT_CMD_START | PORT_CMD_FIS_RX;
+	writel(tmp, port_mmio + PORT_CMD);
+
+	/* wait for engine to stop.  TODO: this could be
+	 * as long as 500 msec
+	 */
+	work = 1000;
+	while (work-- > 0) {
+		tmp = readl(port_mmio + PORT_CMD);
+		if ((tmp & PORT_CMD_LIST_ON) == 0)
+			break;
+		udelay(10);
+	}
+
+	/* clear SATA phy error, if any */
+	tmp = readl(port_mmio + PORT_SCR_ERR);
+	writel(tmp, port_mmio + PORT_SCR_ERR);
+
+	/* if DRQ/BSY is set, device needs to be reset.
+	 * if so, issue COMRESET
+	 */
+	tmp = readl(port_mmio + PORT_TFDATA);
+	if (tmp & (ATA_BUSY | ATA_DRQ)) {
+		writel(0x301, port_mmio + PORT_SCR_CTL);
+		readl(port_mmio + PORT_SCR_CTL); /* flush */
+		udelay(10);
+		writel(0x300, port_mmio + PORT_SCR_CTL);
+		readl(port_mmio + PORT_SCR_CTL); /* flush */
+	}
+
+	/* re-start DMA */
+	tmp = readl(port_mmio + PORT_CMD);
+	tmp |= PORT_CMD_START | PORT_CMD_FIS_RX;
+	writel(tmp, port_mmio + PORT_CMD);
+	readl(port_mmio + PORT_CMD); /* flush */
+
+	printk(KERN_WARNING "ata%u: error occurred, port reset\n", ap->port_no);
+}
+
+static void ahci_eng_timeout(struct ata_port *ap)
+{
+	void *mmio = ap->host_set->mmio_base;
+	void *port_mmio = ahci_port_base(mmio, ap->port_no);
+	struct ata_queued_cmd *qc;
+
+	DPRINTK("ENTER\n");
+
+	ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT));
+
+	qc = ata_qc_from_tag(ap, ap->active_tag);
+	if (!qc) {
+		printk(KERN_ERR "ata%u: BUG: timeout without command\n",
+		       ap->id);
+	} else {
+		/* hack alert!  We cannot use the supplied completion
+	 	 * function from inside the ->eh_strategy_handler() thread.
+	 	 * libata is the only user of ->eh_strategy_handler() in
+	 	 * any kernel, so the default scsi_done() assumes it is
+	 	 * not being called from the SCSI EH.
+	 	 */
+		qc->scsidone = scsi_finish_command;
+		ata_qc_complete(qc, ATA_ERR);
+	}
+
+}
+
+static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
+{
+	void *mmio = ap->host_set->mmio_base;
+	void *port_mmio = ahci_port_base(mmio, ap->port_no);
+	u32 status, serr, ci;
+
+	serr = readl(port_mmio + PORT_SCR_ERR);
+	writel(serr, port_mmio + PORT_SCR_ERR);
+
+	status = readl(port_mmio + PORT_IRQ_STAT);
+	writel(status, port_mmio + PORT_IRQ_STAT);
+
+	ci = readl(port_mmio + PORT_CMD_ISSUE);
+	if (likely((ci & 0x1) == 0)) {
+		if (qc) {
+			ata_qc_complete(qc, 0);
+			qc = NULL;
+		}
+	}
+
+	if (status & PORT_IRQ_FATAL) {
+		ahci_intr_error(ap, status);
+		if (qc)
+			ata_qc_complete(qc, ATA_ERR);
+	}
+
+	return 1;
+}
+
+static void ahci_irq_clear(struct ata_port *ap)
+{
+	/* TODO */
+}
+
+static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
+{
+	struct ata_host_set *host_set = dev_instance;
+	struct ahci_host_priv *hpriv;
+	unsigned int i, handled = 0;
+	void *mmio;
+	u32 irq_stat, irq_ack = 0;
+
+	VPRINTK("ENTER\n");
+
+	hpriv = host_set->private_data;
+	mmio = host_set->mmio_base;
+
+	/* sigh.  0xffffffff is a valid return from h/w */
+	irq_stat = readl(mmio + HOST_IRQ_STAT);
+	irq_stat &= hpriv->port_map;
+	if (!irq_stat)
+		return IRQ_NONE;
+
+        spin_lock(&host_set->lock);
+
+        for (i = 0; i < host_set->n_ports; i++) {
+		struct ata_port *ap;
+		u32 tmp;
+
+		VPRINTK("port %u\n", i);
+		ap = host_set->ports[i];
+		tmp = irq_stat & (1 << i);
+		if (tmp && ap) {
+			struct ata_queued_cmd *qc;
+			qc = ata_qc_from_tag(ap, ap->active_tag);
+			if (ahci_host_intr(ap, qc))
+				irq_ack |= (1 << i);
+		}
+	}
+
+	if (irq_ack) {
+		writel(irq_ack, mmio + HOST_IRQ_STAT);
+		handled = 1;
+	}
+
+        spin_unlock(&host_set->lock);
+
+	VPRINTK("EXIT\n");
+
+	return IRQ_RETVAL(handled);
+}
+
+static int ahci_qc_issue(struct ata_queued_cmd *qc)
+{
+	struct ata_port *ap = qc->ap;
+	void *port_mmio = (void *) ap->ioaddr.cmd_addr;
+
+	writel(1, port_mmio + PORT_SCR_ACT);
+	readl(port_mmio + PORT_SCR_ACT);	/* flush */
+
+	writel(1, port_mmio + PORT_CMD_ISSUE);
+	readl(port_mmio + PORT_CMD_ISSUE);	/* flush */
+
+	return 0;
+}
+
+static void ahci_setup_port(struct ata_ioports *port, unsigned long base,
+			    unsigned int port_idx)
+{
+	VPRINTK("ENTER, base==0x%lx, port_idx %u\n", base, port_idx);
+	base = ahci_port_base_ul(base, port_idx);
+	VPRINTK("base now==0x%lx\n", base);
+
+	port->cmd_addr		= base;
+	port->scr_addr		= base + PORT_SCR;
+
+	VPRINTK("EXIT\n");
+}
+
+static int ahci_host_init(struct ata_probe_ent *probe_ent)
+{
+	struct ahci_host_priv *hpriv = probe_ent->private_data;
+	struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
+	void __iomem *mmio = probe_ent->mmio_base;
+	u32 tmp, cap_save;
+	u16 tmp16;
+	unsigned int i, j, using_dac;
+	int rc;
+	void __iomem *port_mmio;
+
+	cap_save = readl(mmio + HOST_CAP);
+	cap_save &= ( (1<<28) | (1<<17) );
+	cap_save |= (1 << 27);
+
+	/* global controller reset */
+	tmp = readl(mmio + HOST_CTL);
+	if ((tmp & HOST_RESET) == 0) {
+		writel(tmp | HOST_RESET, mmio + HOST_CTL);
+		readl(mmio + HOST_CTL); /* flush */
+	}
+
+	/* reset must complete within 1 second, or
+	 * the hardware should be considered fried.
+	 */
+	ssleep(1);
+
+	tmp = readl(mmio + HOST_CTL);
+	if (tmp & HOST_RESET) {
+		printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n",
+			pci_name(pdev), tmp);
+		return -EIO;
+	}
+
+	writel(HOST_AHCI_EN, mmio + HOST_CTL);
+	(void) readl(mmio + HOST_CTL);	/* flush */
+	writel(cap_save, mmio + HOST_CAP);
+	writel(0xf, mmio + HOST_PORTS_IMPL);
+	(void) readl(mmio + HOST_PORTS_IMPL);	/* flush */
+
+	pci_read_config_word(pdev, 0x92, &tmp16);
+	tmp16 |= 0xf;
+	pci_write_config_word(pdev, 0x92, tmp16);
+
+	hpriv->cap = readl(mmio + HOST_CAP);
+	hpriv->port_map = readl(mmio + HOST_PORTS_IMPL);
+	probe_ent->n_ports = (hpriv->cap & 0x1f) + 1;
+
+	VPRINTK("cap 0x%x  port_map 0x%x  n_ports %d\n",
+		hpriv->cap, hpriv->port_map, probe_ent->n_ports);
+
+	using_dac = hpriv->cap & HOST_CAP_64;
+	if (using_dac &&
+	    !pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) {
+		rc = pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL);
+		if (rc) {
+			rc = pci_set_consistent_dma_mask(pdev, 0xffffffffULL);
+			if (rc) {
+				printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n",
+					pci_name(pdev));
+				return rc;
+			}
+		}
+
+		hpriv->flags |= HOST_CAP_64;
+	} else {
+		rc = pci_set_dma_mask(pdev, 0xffffffffULL);
+		if (rc) {
+			printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n",
+				pci_name(pdev));
+			return rc;
+		}
+		rc = pci_set_consistent_dma_mask(pdev, 0xffffffffULL);
+		if (rc) {
+			printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n",
+				pci_name(pdev));
+			return rc;
+		}
+	}
+
+	for (i = 0; i < probe_ent->n_ports; i++) {
+#if 0 /* BIOSen initialize this incorrectly */
+		if (!(hpriv->port_map & (1 << i)))
+			continue;
+#endif
+
+		port_mmio = ahci_port_base(mmio, i);
+		VPRINTK("mmio %p  port_mmio %p\n", mmio, port_mmio);
+
+		ahci_setup_port(&probe_ent->port[i],
+				(unsigned long) mmio, i);
+
+		/* make sure port is not active */
+		tmp = readl(port_mmio + PORT_CMD);
+		VPRINTK("PORT_CMD 0x%x\n", tmp);
+		if (tmp & (PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
+			   PORT_CMD_FIS_RX | PORT_CMD_START)) {
+			tmp &= ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
+				 PORT_CMD_FIS_RX | PORT_CMD_START);
+			writel(tmp, port_mmio + PORT_CMD);
+			readl(port_mmio + PORT_CMD); /* flush */
+
+			/* spec says 500 msecs for each bit, so
+			 * this is slightly incorrect.
+			 */
+			msleep(500);
+		}
+
+		writel(PORT_CMD_SPIN_UP, port_mmio + PORT_CMD);
+
+		j = 0;
+		while (j < 100) {
+			msleep(10);
+			tmp = readl(port_mmio + PORT_SCR_STAT);
+			if ((tmp & 0xf) == 0x3)
+				break;
+			j++;
+		}
+
+		tmp = readl(port_mmio + PORT_SCR_ERR);
+		VPRINTK("PORT_SCR_ERR 0x%x\n", tmp);
+		writel(tmp, port_mmio + PORT_SCR_ERR);
+
+		/* ack any pending irq events for this port */
+		tmp = readl(port_mmio + PORT_IRQ_STAT);
+		VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
+		if (tmp)
+			writel(tmp, port_mmio + PORT_IRQ_STAT);
+
+		writel(1 << i, mmio + HOST_IRQ_STAT);
+
+		/* set irq mask (enables interrupts) */
+		writel(DEF_PORT_IRQ, port_mmio + PORT_IRQ_MASK);
+	}
+
+	tmp = readl(mmio + HOST_CTL);
+	VPRINTK("HOST_CTL 0x%x\n", tmp);
+	writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
+	tmp = readl(mmio + HOST_CTL);
+	VPRINTK("HOST_CTL 0x%x\n", tmp);
+
+	pci_set_master(pdev);
+
+	return 0;
+}
+
+/* move to PCI layer, integrate w/ MSI stuff */
+static void pci_enable_intx(struct pci_dev *pdev)
+{
+	u16 pci_command;
+
+	pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
+	if (pci_command & PCI_COMMAND_INTX_DISABLE) {
+		pci_command &= ~PCI_COMMAND_INTX_DISABLE;
+		pci_write_config_word(pdev, PCI_COMMAND, pci_command);
+	}
+}
+
+static void ahci_print_info(struct ata_probe_ent *probe_ent)
+{
+	struct ahci_host_priv *hpriv = probe_ent->private_data;
+	struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
+	void *mmio = probe_ent->mmio_base;
+	u32 vers, cap, impl, speed;
+	const char *speed_s;
+	u16 cc;
+	const char *scc_s;
+
+	vers = readl(mmio + HOST_VERSION);
+	cap = hpriv->cap;
+	impl = hpriv->port_map;
+
+	speed = (cap >> 20) & 0xf;
+	if (speed == 1)
+		speed_s = "1.5";
+	else if (speed == 2)
+		speed_s = "3";
+	else
+		speed_s = "?";
+
+	pci_read_config_word(pdev, 0x0a, &cc);
+	if (cc == 0x0101)
+		scc_s = "IDE";
+	else if (cc == 0x0106)
+		scc_s = "SATA";
+	else if (cc == 0x0104)
+		scc_s = "RAID";
+	else
+		scc_s = "unknown";
+
+	printk(KERN_INFO DRV_NAME "(%s) AHCI %02x%02x.%02x%02x "
+		"%u slots %u ports %s Gbps 0x%x impl %s mode\n"
+	       	,
+	       	pci_name(pdev),
+
+	       	(vers >> 24) & 0xff,
+	       	(vers >> 16) & 0xff,
+	       	(vers >> 8) & 0xff,
+	       	vers & 0xff,
+
+		((cap >> 8) & 0x1f) + 1,
+		(cap & 0x1f) + 1,
+		speed_s,
+		impl,
+		scc_s);
+
+	printk(KERN_INFO DRV_NAME "(%s) flags: "
+	       	"%s%s%s%s%s%s"
+	       	"%s%s%s%s%s%s%s\n"
+	       	,
+	       	pci_name(pdev),
+
+		cap & (1 << 31) ? "64bit " : "",
+		cap & (1 << 30) ? "ncq " : "",
+		cap & (1 << 28) ? "ilck " : "",
+		cap & (1 << 27) ? "stag " : "",
+		cap & (1 << 26) ? "pm " : "",
+		cap & (1 << 25) ? "led " : "",
+
+		cap & (1 << 24) ? "clo " : "",
+		cap & (1 << 19) ? "nz " : "",
+		cap & (1 << 18) ? "only " : "",
+		cap & (1 << 17) ? "pmp " : "",
+		cap & (1 << 15) ? "pio " : "",
+		cap & (1 << 14) ? "slum " : "",
+		cap & (1 << 13) ? "part " : ""
+		);
+}
+
+static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	static int printed_version;
+	struct ata_probe_ent *probe_ent = NULL;
+	struct ahci_host_priv *hpriv;
+	unsigned long base;
+	void *mmio_base;
+	unsigned int board_idx = (unsigned int) ent->driver_data;
+	int rc;
+
+	VPRINTK("ENTER\n");
+
+	if (!printed_version++)
+		printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
+
+	rc = pci_enable_device(pdev);
+	if (rc)
+		return rc;
+
+	rc = pci_request_regions(pdev, DRV_NAME);
+	if (rc)
+		goto err_out;
+
+	pci_enable_intx(pdev);
+
+	probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
+	if (probe_ent == NULL) {
+		rc = -ENOMEM;
+		goto err_out_regions;
+	}
+
+	memset(probe_ent, 0, sizeof(*probe_ent));
+	probe_ent->dev = pci_dev_to_dev(pdev);
+	INIT_LIST_HEAD(&probe_ent->node);
+
+	mmio_base = ioremap(pci_resource_start(pdev, AHCI_PCI_BAR),
+		            pci_resource_len(pdev, AHCI_PCI_BAR));
+	if (mmio_base == NULL) {
+		rc = -ENOMEM;
+		goto err_out_free_ent;
+	}
+	base = (unsigned long) mmio_base;
+
+	hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
+	if (!hpriv) {
+		rc = -ENOMEM;
+		goto err_out_iounmap;
+	}
+	memset(hpriv, 0, sizeof(*hpriv));
+
+	probe_ent->sht		= ahci_port_info[board_idx].sht;
+	probe_ent->host_flags	= ahci_port_info[board_idx].host_flags;
+	probe_ent->pio_mask	= ahci_port_info[board_idx].pio_mask;
+	probe_ent->udma_mask	= ahci_port_info[board_idx].udma_mask;
+	probe_ent->port_ops	= ahci_port_info[board_idx].port_ops;
+
+       	probe_ent->irq = pdev->irq;
+       	probe_ent->irq_flags = SA_SHIRQ;
+	probe_ent->mmio_base = mmio_base;
+	probe_ent->private_data = hpriv;
+
+	/* initialize adapter */
+	rc = ahci_host_init(probe_ent);
+	if (rc)
+		goto err_out_hpriv;
+
+	ahci_print_info(probe_ent);
+
+	/* FIXME: check ata_device_add return value */
+	ata_device_add(probe_ent);
+	kfree(probe_ent);
+
+	return 0;
+
+err_out_hpriv:
+	kfree(hpriv);
+err_out_iounmap:
+	iounmap(mmio_base);
+err_out_free_ent:
+	kfree(probe_ent);
+err_out_regions:
+	pci_release_regions(pdev);
+err_out:
+	pci_disable_device(pdev);
+	return rc;
+}
+
+
+static int __init ahci_init(void)
+{
+	return pci_module_init(&ahci_pci_driver);
+}
+
+
+static void __exit ahci_exit(void)
+{
+	pci_unregister_driver(&ahci_pci_driver);
+}
+
+
+MODULE_AUTHOR("Jeff Garzik");
+MODULE_DESCRIPTION("AHCI SATA low-level driver");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(pci, ahci_pci_tbl);
+
+module_init(ahci_init);
+module_exit(ahci_exit);
diff -Nru a/drivers/scsi/aic7xxx/aic7770_osm.c b/drivers/scsi/aic7xxx/aic7770_osm.c
--- a/drivers/scsi/aic7xxx/aic7770_osm.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/scsi/aic7xxx/aic7770_osm.c	2004-12-24 13:37:01 -08:00
@@ -185,10 +185,8 @@
 		return (ENOMEM);
 	strcpy(name, buf);
 	ahc = ahc_alloc(&aic7xxx_driver_template, name);
-	if (ahc == NULL) {
-		free(name, M_DEVBUF);
+	if (ahc == NULL)
 		return (ENOMEM);
-	}
 	error = aic7770_config(ahc, entry, eisaBase);
 	if (error != 0) {
 		ahc->bsh.ioport = 0;
diff -Nru a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h
--- a/drivers/scsi/aic7xxx/aic79xx.h	2004-12-24 13:37:01 -08:00
+++ b/drivers/scsi/aic7xxx/aic79xx.h	2004-12-24 13:37:01 -08:00
@@ -549,7 +549,7 @@
 
 struct map_node {
 	bus_dmamap_t		 dmamap;
-	bus_addr_t		 physaddr;
+	dma_addr_t		 physaddr;
 	uint8_t			*vaddr;
 	SLIST_ENTRY(map_node)	 links;
 };
@@ -626,8 +626,8 @@
 	struct map_node	 	 *sense_map;
 	void			 *sg_list;
 	uint8_t			 *sense_data;
-	bus_addr_t		  sg_list_busaddr;
-	bus_addr_t		  sense_busaddr;
+	dma_addr_t		  sg_list_busaddr;
+	dma_addr_t		  sense_busaddr;
 	u_int			  sg_count;/* How full ahd_dma_seg is */
 #define	AHD_MAX_LQ_CRC_ERRORS 5
 	u_int			  crc_retry_count;
@@ -1198,7 +1198,7 @@
 	bus_dma_tag_t		  parent_dmat;
 	bus_dma_tag_t		  shared_data_dmat;
 	bus_dmamap_t		  shared_data_dmamap;
-	bus_addr_t		  shared_data_busaddr;
+	dma_addr_t		  shared_data_busaddr;
 
 	/* Information saved through suspend/resume cycles */
 	struct ahd_suspend_state  suspend_state;
diff -Nru a/drivers/scsi/aic7xxx/aic79xx.reg b/drivers/scsi/aic7xxx/aic79xx.reg
--- a/drivers/scsi/aic7xxx/aic79xx.reg	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/aic7xxx/aic79xx.reg	2004-12-24 13:37:19 -08:00
@@ -1199,7 +1199,7 @@
 
 /*
  * LQ Packet In
- * The last LQ Packet recieved
+ * The last LQ Packet received
  */
 register LQIN {
 	address			0x020
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
--- a/drivers/scsi/aic7xxx/aic79xx_core.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c	2004-12-24 13:36:16 -08:00
@@ -5270,7 +5270,6 @@
 	default:
 	case 5:
 		ahd_shutdown(ahd);
-		TAILQ_REMOVE(&ahd_tailq, ahd, links);
 		/* FALLTHROUGH */
 	case 4:
 		ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
@@ -5493,9 +5492,9 @@
 static void
 ahd_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) 
 {
-	bus_addr_t *baddr;
+	dma_addr_t *baddr;
 
-	baddr = (bus_addr_t *)arg;
+	baddr = (dma_addr_t *)arg;
 	*baddr = segs->ds_addr;
 }
 
@@ -5926,9 +5925,9 @@
 	struct map_node *sense_map;
 	uint8_t		*segs;
 	uint8_t		*sense_data;
-	bus_addr_t	 hscb_busaddr;
-	bus_addr_t	 sg_busaddr;
-	bus_addr_t	 sense_busaddr;
+	dma_addr_t	 hscb_busaddr;
+	dma_addr_t	 sg_busaddr;
+	dma_addr_t	 sense_busaddr;
 	int		 newcount;
 	int		 i;
 
@@ -6161,7 +6160,7 @@
 {
 	uint8_t		*base_vaddr;
 	uint8_t		*next_vaddr;
-	bus_addr_t	 next_baddr;
+	dma_addr_t	 next_baddr;
 	size_t		 driver_data_size;
 	int		 i;
 	int		 error;
@@ -6205,7 +6204,7 @@
 	if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
 			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
 			       /*lowaddr*/ahd->flags & AHD_39BIT_ADDRESSING
-					? (bus_addr_t)0x7FFFFFFFFFULL
+					? (dma_addr_t)0x7FFFFFFFFFULL
 					: BUS_SPACE_MAXADDR_32BIT,
 			       /*highaddr*/BUS_SPACE_MAXADDR,
 			       /*filter*/NULL, /*filterarg*/NULL,
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_inline.h b/drivers/scsi/aic7xxx/aic79xx_inline.h
--- a/drivers/scsi/aic7xxx/aic79xx_inline.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/aic7xxx/aic79xx_inline.h	2004-12-24 13:36:48 -08:00
@@ -231,7 +231,7 @@
 
 /*********************** Scatter Gather List Handling *************************/
 static __inline void	*ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
-				      void *sgptr, bus_addr_t addr,
+				      void *sgptr, dma_addr_t addr,
 				      bus_size_t len, int last);
 static __inline void	 ahd_setup_scb_common(struct ahd_softc *ahd,
 					      struct scb *scb);
@@ -242,10 +242,10 @@
 
 static __inline void *
 ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
-	     void *sgptr, bus_addr_t addr, bus_size_t len, int last)
+	     void *sgptr, dma_addr_t addr, bus_size_t len, int last)
 {
 	scb->sg_count++;
-	if (sizeof(bus_addr_t) > 4
+	if (sizeof(dma_addr_t) > 4
 	 && (ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
 		struct ahd_dma64_seg *sg;
 
@@ -361,7 +361,7 @@
 static __inline void *
 ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
 {
-	bus_addr_t sg_offset;
+	dma_addr_t sg_offset;
 
 	/* sg_list_phys points to entry 1, not 0 */
 	sg_offset = sg_busaddr - (scb->sg_list_busaddr - ahd_sg_size(ahd));
@@ -371,7 +371,7 @@
 static __inline uint32_t
 ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
 {
-	bus_addr_t sg_offset;
+	dma_addr_t sg_offset;
 
 	/* sg_list_phys points to entry 1, not 0 */
 	sg_offset = ((uint8_t *)sg - (uint8_t *)scb->sg_list)
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c	2004-12-24 13:36:56 -08:00
@@ -52,9 +52,7 @@
  */
 #include "aiclib.c"
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 #include <linux/init.h>		/* __setup */
-#endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 #include "sd.h"			/* For geometry detection */
@@ -68,14 +66,6 @@
  */
 spinlock_t ahd_list_spinlock;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-struct proc_dir_entry proc_scsi_aic79xx = {
-	PROC_SCSI_AIC79XX, 7, "aic79xx",
-	S_IFDIR | S_IRUGO | S_IXUGO, 2,
-	0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-};
-#endif
-
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 /* For dynamic sglist size calculation. */
 u_int ahd_linux_nseg;
@@ -561,7 +551,7 @@
 
 static __inline int ahd_linux_map_seg(struct ahd_softc *ahd, struct scb *scb,
 		 		      struct ahd_dma_seg *sg,
-				      bus_addr_t addr, bus_size_t len);
+				      dma_addr_t addr, bus_size_t len);
 
 static __inline void
 ahd_schedule_completeq(struct ahd_softc *ahd)
@@ -579,31 +569,20 @@
 static __inline void
 ahd_schedule_runq(struct ahd_softc *ahd)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	tasklet_schedule(&ahd->platform_data->runq_tasklet);
-#else
-	/*
-	 * Tasklets are not available, so run inline.
-	 */
-	ahd_runq_tasklet((unsigned long)ahd);
-#endif
 }
 
 static __inline
 void ahd_setup_runq_tasklet(struct ahd_softc *ahd)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	tasklet_init(&ahd->platform_data->runq_tasklet, ahd_runq_tasklet,
 		     (unsigned long)ahd);
-#endif
 }
 
 static __inline void
 ahd_teardown_runq_tasklet(struct ahd_softc *ahd)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	tasklet_kill(&ahd->platform_data->runq_tasklet);
-#endif
 }
 
 static __inline struct ahd_linux_device*
@@ -734,7 +713,7 @@
 
 static __inline int
 ahd_linux_map_seg(struct ahd_softc *ahd, struct scb *scb,
-		  struct ahd_dma_seg *sg, bus_addr_t addr, bus_size_t len)
+		  struct ahd_dma_seg *sg, dma_addr_t addr, bus_size_t len)
 {
 	int	 consumed;
 
@@ -746,7 +725,7 @@
 	sg->addr = ahd_htole32(addr & 0xFFFFFFFF);
 	scb->platform_data->xfer_len += len;
 
-	if (sizeof(bus_addr_t) > 4
+	if (sizeof(dma_addr_t) > 4
 	 && (ahd->flags & AHD_39BIT_ADDRESSING) != 0)
 		len |= (addr >> 8) & AHD_SG_HIGH_ADDR_MASK;
 
@@ -851,6 +830,7 @@
 {
 	struct	ahd_softc *ahd;
 	int     found;
+	int	error = 0;
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	/*
@@ -889,11 +869,7 @@
 "aic79xx: insmod or else it might trash certain memory areas.\n");
 #endif
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
 	template->proc_name = "aic79xx";
-#else
-	template->proc_dir = &proc_scsi_aic79xx;
-#endif
 
 	/*
 	 * Initialize our softc list lock prior to
@@ -902,7 +878,9 @@
 	ahd_list_lockinit();
 
 #ifdef CONFIG_PCI
-	ahd_linux_pci_init();
+	error = ahd_linux_pci_init();
+	if (error)
+		return error;
 #endif
 
 	/*
@@ -919,7 +897,7 @@
 	spin_lock_irq(&io_request_lock);
 #endif
 	aic79xx_detect_complete++;
-	return (found);
+	return 0;
 }
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
@@ -1560,6 +1538,8 @@
 
 	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
 	recovery_cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK);
+	if (!recovery_cmd)
+		return (FAILED);
 	memset(recovery_cmd, 0, sizeof(struct scsi_cmnd));
 	recovery_cmd->device = cmd->device;
 	recovery_cmd->scsi_done = ahd_linux_dev_reset_complete;
@@ -1575,10 +1555,12 @@
 				   cmd->device->lun, /*alloc*/FALSE);
 	if (dev == NULL) {
 		ahd_midlayer_entrypoint_unlock(ahd, &s);
+		kfree(recovery_cmd);
 		return (FAILED);
 	}
 	if ((scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX)) == NULL) {
 		ahd_midlayer_entrypoint_unlock(ahd, &s);
+		kfree(recovery_cmd);
 		return (FAILED);
 	}
 	tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
@@ -1694,35 +1676,27 @@
 {
 	struct ahd_softc* ahd;
 	struct ahd_linux_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	u_long flags;
-#endif
 
 	ahd = (struct ahd_softc *)data;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	ahd_lock(ahd, &flags);
-#endif
 	while ((dev = ahd_linux_next_device_to_run(ahd)) != NULL) {
 	
 		TAILQ_REMOVE(&ahd->platform_data->device_runq, dev, links);
 		dev->flags &= ~AHD_DEV_ON_RUN_LIST;
 		ahd_linux_check_device_queue(ahd, dev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 		/* Yeild to our interrupt handler */
 		ahd_unlock(ahd, &flags);
 		ahd_lock(ahd, &flags);
-#endif
 	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	ahd_unlock(ahd, &flags);
-#endif
 }
 
 /******************************** Bus DMA *************************************/
 int
 ahd_dma_tag_create(struct ahd_softc *ahd, bus_dma_tag_t parent,
 		   bus_size_t alignment, bus_size_t boundary,
-		   bus_addr_t lowaddr, bus_addr_t highaddr,
+		   dma_addr_t lowaddr, dma_addr_t highaddr,
 		   bus_dma_filter_t *filter, void *filterarg,
 		   bus_size_t maxsize, int nsegments,
 		   bus_size_t maxsegsz, int flags, bus_dma_tag_t *ret_tag)
@@ -1759,7 +1733,6 @@
 {
 	bus_dmamap_t map;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT);
 	if (map == NULL)
 		return (ENOMEM);
@@ -1771,28 +1744,20 @@
 	 * our dma mask when doing allocations.
 	 */
 	if (ahd->dev_softc != NULL)
-		if (ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF)) {
+		if (pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF)) {
 			printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
+			kfree(map);
 			return (ENODEV);
 		}
 	*vaddr = pci_alloc_consistent(ahd->dev_softc,
 				      dmat->maxsize, &map->bus_addr);
 	if (ahd->dev_softc != NULL)
-		if (ahd_pci_set_dma_mask(ahd->dev_softc,
+		if (pci_set_dma_mask(ahd->dev_softc,
 				     ahd->platform_data->hw_dma_mask)) {
 			printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
+			kfree(map);
 			return (ENODEV);
 		}
-#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
-	/*
-	 * At least in 2.2.14, malloc is a slab allocator so all
-	 * allocations are aligned.  We assume for these kernel versions
-	 * that all allocations will be bellow 4Gig, physically contiguous,
-	 * and accessible via DMA by the controller.
-	 */
-	map = NULL; /* No additional information to store */
-	*vaddr = malloc(dmat->maxsize, M_DEVBUF, M_NOWAIT);
-#endif
 	if (*vaddr == NULL)
 		return (ENOMEM);
 	*mapp = map;
@@ -1803,12 +1768,8 @@
 ahd_dmamem_free(struct ahd_softc *ahd, bus_dma_tag_t dmat,
 		void* vaddr, bus_dmamap_t map)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	pci_free_consistent(ahd->dev_softc, dmat->maxsize,
 			    vaddr, map->bus_addr);
-#else
-	free(vaddr, M_DEVBUF);
-#endif
 }
 
 int
@@ -1822,12 +1783,7 @@
 	 */
 	bus_dma_segment_t stack_sg;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	stack_sg.ds_addr = map->bus_addr;
-#else
-#define VIRT_TO_BUS(a) (uint32_t)virt_to_bus((void *)(a))
-	stack_sg.ds_addr = VIRT_TO_BUS(buf);
-#endif
 	stack_sg.ds_len = dmat->maxsize;
 	cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0);
 	return (0);
@@ -2059,9 +2015,7 @@
 	return 1;
 }
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
 __setup("aic79xx=", aic79xx_setup);
-#endif
 
 uint32_t aic79xx_verbose;
 
@@ -2104,8 +2058,7 @@
 		ahd_set_name(ahd, new_name);
 	}
 	host->unique_id = ahd->unit;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) && \
-    LINUX_VERSION_CODE  < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	scsi_set_pci_device(host, ahd->dev_softc);
 #endif
 	ahd_linux_setup_user_rd_strm_settings(ahd);
@@ -2257,15 +2210,9 @@
 	ahd->platform_data->completeq_timer.data = (u_long)ahd;
 	ahd->platform_data->completeq_timer.function =
 	    (ahd_linux_callback_t *)ahd_linux_thread_run_complete_queue;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	init_MUTEX_LOCKED(&ahd->platform_data->eh_sem);
 	init_MUTEX_LOCKED(&ahd->platform_data->dv_sem);
 	init_MUTEX_LOCKED(&ahd->platform_data->dv_cmd_sem);
-#else
-	ahd->platform_data->eh_sem = MUTEX_LOCKED;
-	ahd->platform_data->dv_sem = MUTEX_LOCKED;
-	ahd->platform_data->dv_cmd_sem = MUTEX_LOCKED;
-#endif
 	ahd_setup_runq_tasklet(ahd);
 	ahd->seltime = (aic79xx_seltime & 0x3) << 4;
 	return (0);
@@ -2320,18 +2267,11 @@
 			release_region(ahd->bshs[1].ioport, 256);
 		if (ahd->tags[0] == BUS_SPACE_MEMIO
 		 && ahd->bshs[0].maddr != NULL) {
-			u_long base_addr;
-
-			base_addr = (u_long)ahd->bshs[0].maddr;
-			base_addr &= PAGE_MASK;
-			iounmap((void *)base_addr);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+			iounmap(ahd->bshs[0].maddr);
 			release_mem_region(ahd->platform_data->mem_busaddr,
 					   0x1000);
-#endif
 		}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) && \
-    LINUX_VERSION_CODE  < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
     		/*
 		 * In 2.4 we detach from the scsi midlayer before the PCI
 		 * layer invokes our remove callback.  No per-instance
@@ -4121,7 +4061,7 @@
 					  cmd->use_sg, dir);
 			scb->platform_data->xfer_len = 0;
 			for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) {
-				bus_addr_t addr;
+				dma_addr_t addr;
 				bus_size_t len;
 
 				addr = sg_dma_address(cur_seg);
@@ -4132,7 +4072,7 @@
 			}
 		} else if (cmd->request_bufflen != 0) {
 			void *sg;
-			bus_addr_t addr;
+			dma_addr_t addr;
 			int dir;
 
 			sg = scb->sg_list;
@@ -4366,7 +4306,7 @@
 		WARN_ON(lun != CAM_LUN_WILDCARD);
 		scsi_report_device_reset(ahd->platform_data->host,
 					 channel - 'A', target);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
+#else
 		Scsi_Device *scsi_dev;
 
 		/*
@@ -4387,12 +4327,10 @@
 		break;
 	}
         case AC_BUS_RESET:
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 		if (ahd->platform_data->host != NULL) {
 			scsi_report_bus_reset(ahd->platform_data->host,
 					      channel - 'A');
 		}
-#endif
                 break;
         default:
                 panic("ahd_send_async: Unexpected async event");
@@ -5073,7 +5011,7 @@
 ahd_linux_init(void)
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-       return (ahd_linux_detect(&aic79xx_driver_template) ? 0 : -ENODEV);
+	return ahd_linux_detect(&aic79xx_driver_template);
 #else
 	scsi_register_module(MODULE_SCSI_HA, &aic79xx_driver_template);
 	if (aic79xx_driver_template.present == 0) {
@@ -5090,7 +5028,6 @@
 ahd_linux_exit(void)
 {
 	struct ahd_softc *ahd;
-	u_long l;
 
 	/*
 	 * Shutdown DV threads before going into the SCSI mid-layer.
@@ -5098,12 +5035,11 @@
 	 * kernel so that waiting for our DV threads to exit leads
 	 * to deadlock.
 	 */
-	ahd_list_lock(&l);
 	TAILQ_FOREACH(ahd, &ahd_tailq, links) {
 
 		ahd_linux_kill_dv_thread(ahd);
 	}
-	ahd_list_unlock(&l);
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	/*
 	 * In 2.4 we have to unregister from the PCI core _after_
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h	2004-12-24 13:37:00 -08:00
@@ -53,17 +53,9 @@
 #include <asm/byteorder.h>
 #include <asm/io.h>
 
-#ifndef KERNEL_VERSION
-#define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 #include <linux/interrupt.h> /* For tasklet support. */
 #include <linux/config.h>
 #include <linux/slab.h>
-#else
-#include <linux/malloc.h>
-#endif
 
 /* Core SCSI definitions */
 #define AIC_LIB_PREFIX ahd
@@ -144,11 +136,6 @@
 
 /***************************** Bus Space/DMA **********************************/
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,17)
-typedef dma_addr_t bus_addr_t;
-#else
-typedef uint32_t bus_addr_t;
-#endif
 typedef uint32_t bus_size_t;
 
 typedef enum {
@@ -158,12 +145,12 @@
 
 typedef union {
 	u_long		  ioport;
-	volatile uint8_t *maddr;
+	volatile uint8_t __iomem *maddr;
 } bus_space_handle_t;
 
 typedef struct bus_dma_segment
 {
-	bus_addr_t	ds_addr;
+	dma_addr_t	ds_addr;
 	bus_size_t	ds_len;
 } bus_dma_segment_t;
 
@@ -177,11 +164,11 @@
 
 struct ahd_linux_dmamap
 {
-	bus_addr_t	bus_addr;
+	dma_addr_t	bus_addr;
 };
 typedef struct ahd_linux_dmamap* bus_dmamap_t;
 
-typedef int bus_dma_filter_t(void*, bus_addr_t);
+typedef int bus_dma_filter_t(void*, dma_addr_t);
 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
 
 #define BUS_DMA_WAITOK		0x0
@@ -198,7 +185,7 @@
 
 int	ahd_dma_tag_create(struct ahd_softc *, bus_dma_tag_t /*parent*/,
 			   bus_size_t /*alignment*/, bus_size_t /*boundary*/,
-			   bus_addr_t /*lowaddr*/, bus_addr_t /*highaddr*/,
+			   dma_addr_t /*lowaddr*/, dma_addr_t /*highaddr*/,
 			   bus_dma_filter_t*/*filter*/, void */*filterarg*/,
 			   bus_size_t /*maxsize*/, int /*nsegments*/,
 			   bus_size_t /*maxsegsz*/, int /*flags*/,
@@ -280,11 +267,7 @@
 }
 
 /***************************** SMP support ************************************/
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
 #include <linux/spinlock.h>
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
-#include <linux/smp.h>
-#endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK))
 #define AHD_SCSI_HAS_HOST_LOCK 1
@@ -509,11 +492,8 @@
 
 struct scb_platform_data {
 	struct ahd_linux_device	*dev;
-	bus_addr_t		 buf_busaddr;
+	dma_addr_t		 buf_busaddr;
 	uint32_t		 xfer_len;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-	uint32_t		 resid;		/* Transfer residual */
-#endif
 	uint32_t		 sense_resid;	/* Auto-Sense residual */
 	ahd_linux_scb_flags	 flags;
 };
@@ -543,9 +523,7 @@
 	struct ahd_completeq	 completeq;
 
 	spinlock_t		 spin_lock;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	struct tasklet_struct	 runq_tasklet;
-#endif
 	u_int			 qfrozen;
 	pid_t			 dv_pid;
 	struct timer_list	 completeq_timer;
@@ -562,7 +540,7 @@
 	uint32_t		 irq;		/* IRQ for this adapter */
 	uint32_t		 bios_address;
 	uint32_t		 mem_busaddr;	/* Mem Base Addr */
-	bus_addr_t		 hw_dma_mask;
+	uint64_t		 hw_dma_mask;
 	ahd_linux_softc_flags	 flags;
 };
 
@@ -859,9 +837,7 @@
 #define PCIXM_STATUS_MAXCRDS	0x1C00	/* Maximum Cumulative Read Size */
 #define PCIXM_STATUS_RCVDSCEM	0x2000	/* Received a Split Comp w/Error msg */
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 extern struct pci_driver aic79xx_pci_driver;
-#endif
 
 typedef enum
 {
@@ -965,25 +941,6 @@
 	ahd_inb(ahd, INTSTAT);
 }
 
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0)
-#define pci_map_sg(pdev, sg_list, nseg, direction) (nseg)
-#define pci_unmap_sg(pdev, sg_list, nseg, direction)
-#define sg_dma_address(sg) (VIRT_TO_BUS((sg)->address))
-#define sg_dma_len(sg) ((sg)->length)
-#define pci_map_single(pdev, buffer, bufflen, direction) \
-	(VIRT_TO_BUS(buffer))
-#define pci_unmap_single(pdev, buffer, buflen, direction)
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3)
-#define ahd_pci_set_dma_mask pci_set_dma_mask
-#else
-/*
- * Always "return" 0 for success.
- */
-#define ahd_pci_set_dma_mask(dev_softc, mask)	\
-	(((dev_softc)->dma_mask = mask) && 0)
-#endif
 /**************************** Proc FS Support *********************************/
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 int	ahd_linux_proc_info(char *, char **, off_t, int, int, int);
@@ -1091,35 +1048,13 @@
 static __inline
 int ahd_get_transfer_dir(struct scb *scb)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,40)
 	return (scb->io_ctx->sc_data_direction);
-#else
-	if (scb->io_ctx->bufflen == 0)
-		return (CAM_DIR_NONE);
-
-	switch(scb->io_ctx->cmnd[0]) {
-	case 0x08:  /* READ(6)  */
-	case 0x28:  /* READ(10) */
-	case 0xA8:  /* READ(12) */
-		return (CAM_DIR_IN);
-        case 0x0A:  /* WRITE(6)  */
-        case 0x2A:  /* WRITE(10) */
-        case 0xAA:  /* WRITE(12) */
-		return (CAM_DIR_OUT);
-        default:
-		return (CAM_DIR_NONE);
-        }
-#endif
 }
 
 static __inline
 void ahd_set_residual(struct scb *scb, u_long resid)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	scb->io_ctx->resid = resid;
-#else
-	scb->platform_data->resid = resid;
-#endif
 }
 
 static __inline
@@ -1131,11 +1066,7 @@
 static __inline
 u_long ahd_get_residual(struct scb *scb)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	return (scb->io_ctx->resid);
-#else
-	return (scb->platform_data->resid);
-#endif
 }
 
 static __inline
@@ -1212,4 +1143,5 @@
 #endif
 #define bootverbose aic79xx_verbose
 extern uint32_t aic79xx_verbose;
+
 #endif /* _AIC79XX_LINUX_H_ */
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c	2004-12-24 13:36:31 -08:00
@@ -41,12 +41,7 @@
 
 #include "aic79xx_osm.h"
 #include "aic79xx_inline.h"
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-struct pci_device_id
-{
-};
-#endif
+#include "aic79xx_pci.h"
 
 static int	ahd_linux_pci_dev_probe(struct pci_dev *pdev,
 					const struct pci_device_id *ent);
@@ -54,16 +49,34 @@
 						 u_long *base, u_long *base2);
 static int	ahd_linux_pci_reserve_mem_region(struct ahd_softc *ahd,
 						 u_long *bus_addr,
-						 uint8_t **maddr);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+						 uint8_t __iomem **maddr);
 static void	ahd_linux_pci_dev_remove(struct pci_dev *pdev);
 
-/* We do our own ID filtering.  So, grab all SCSI storage class devices. */
+/* Define the macro locally since it's different for different class of chips.
+ */
+#define ID(x)            \
+	ID2C(x),         \
+	ID2C(IDIROC(x))
+
 static struct pci_device_id ahd_linux_pci_id_table[] = {
-	{
-		0x9005, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-		PCI_CLASS_STORAGE_SCSI << 8, 0xFFFF00, 0
-	},
+	/* aic7901 based controllers */
+	ID(ID_AHA_29320A),
+	ID(ID_AHA_29320ALP),
+	/* aic7902 based controllers */
+	ID(ID_AHA_29320),
+	ID(ID_AHA_29320B),
+	ID(ID_AHA_29320LP),
+	ID(ID_AHA_39320),
+	ID(ID_AHA_39320_B),
+	ID(ID_AHA_39320A),
+	ID(ID_AHA_39320D),
+	ID(ID_AHA_39320D_HP),
+	ID(ID_AHA_39320D_B),
+	ID(ID_AHA_39320D_B_HP),
+	/* Generic chip probes for devices we don't know exactly. */
+	ID16(ID_AIC7901 & ID_9005_GENERIC_MASK),
+	ID(ID_AIC7901A & ID_DEV_VENDOR_MASK),
+	ID16(ID_AIC7902 & ID_9005_GENERIC_MASK),
 	{ 0 }
 };
 
@@ -92,14 +105,15 @@
 	if (ahd != NULL) {
 		u_long s;
 
+		TAILQ_REMOVE(&ahd_tailq, ahd, links);
+		ahd_list_unlock(&l);
 		ahd_lock(ahd, &s);
 		ahd_intr_enable(ahd, FALSE);
 		ahd_unlock(ahd, &s);
 		ahd_free(ahd);
-	}
-	ahd_list_unlock(&l);
+	} else
+		ahd_list_unlock(&l);
 }
-#endif /* !LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) */
 
 static int
 ahd_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -148,42 +162,37 @@
 	ahd = ahd_alloc(NULL, name);
 	if (ahd == NULL)
 		return (-ENOMEM);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	if (pci_enable_device(pdev)) {
 		ahd_free(ahd);
 		return (-ENODEV);
 	}
 	pci_set_master(pdev);
 
-	if (sizeof(bus_addr_t) > 4) {
+	if (sizeof(dma_addr_t) > 4) {
 		uint64_t   memsize;
-		bus_addr_t mask_64bit;
-		bus_addr_t mask_39bit;
+		const uint64_t mask_39bit = 0x7FFFFFFFFFULL;
 
 		memsize = ahd_linux_get_memsize();
-		mask_64bit = (bus_addr_t)0xFFFFFFFFFFFFFFFFULL;
-		mask_39bit = (bus_addr_t)0x7FFFFFFFFFULL;
+
 		if (memsize >= 0x8000000000ULL
-	 	 && ahd_pci_set_dma_mask(pdev, mask_64bit) == 0) {
+	 	 && pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
 			ahd->flags |= AHD_64BIT_ADDRESSING;
-			ahd->platform_data->hw_dma_mask = mask_64bit;
+			ahd->platform_data->hw_dma_mask = DMA_64BIT_MASK;
 		} else if (memsize > 0x80000000
-			&& ahd_pci_set_dma_mask(pdev, mask_39bit) == 0) {
+			&& pci_set_dma_mask(pdev, mask_39bit) == 0) {
 			ahd->flags |= AHD_39BIT_ADDRESSING;
 			ahd->platform_data->hw_dma_mask = mask_39bit;
 		}
 	} else {
-		ahd_pci_set_dma_mask(pdev, 0xFFFFFFFF);
-		ahd->platform_data->hw_dma_mask = 0xFFFFFFFF;
+		pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+		ahd->platform_data->hw_dma_mask = DMA_32BIT_MASK;
 	}
-#endif
 	ahd->dev_softc = pci;
 	error = ahd_pci_config(ahd, entry);
 	if (error != 0) {
 		ahd_free(ahd);
 		return (-error);
 	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	pci_set_drvdata(pdev, ahd);
 	if (aic79xx_detect_complete) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
@@ -194,38 +203,13 @@
 		return (-ENODEV);
 #endif
 	}
-#endif
 	return (0);
 }
 
 int
 ahd_linux_pci_init(void)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	return (pci_module_init(&aic79xx_pci_driver));
-#else
-	struct pci_dev *pdev;
-	u_int class;
-	int found;
-
-	/* If we don't have a PCI bus, we can't find any adapters. */
-	if (pci_present() == 0)
-		return (0);
-
-	found = 0;
-	pdev = NULL;
-	class = PCI_CLASS_STORAGE_SCSI << 8;
-	while ((pdev = pci_find_class(class, pdev)) != NULL) {
-		ahd_dev_softc_t pci;
-		int error;
-
-		pci = pdev;
-		error = ahd_linux_pci_dev_probe(pdev, /*pci_devid*/NULL);
-		if (error == 0)
-			found++;
-	}
-	return (found);
-#endif
 }
 
 void
@@ -238,7 +222,6 @@
 ahd_linux_pci_reserve_io_regions(struct ahd_softc *ahd, u_long *base,
 				 u_long *base2)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	*base = pci_resource_start(ahd->dev_softc, 0);
 	/*
 	 * This is really the 3rd bar and should be at index 2,
@@ -246,35 +229,21 @@
 	 * bars.
 	 */
 	*base2 = pci_resource_start(ahd->dev_softc, 3);
-#else
-	*base = ahd_pci_read_config(ahd->dev_softc, AHD_PCI_IOADDR0, 4);
-	*base2 = ahd_pci_read_config(ahd->dev_softc, AHD_PCI_IOADDR1, 4);
-	*base &= PCI_BASE_ADDRESS_IO_MASK;
-	*base2 &= PCI_BASE_ADDRESS_IO_MASK;
-#endif
 	if (*base == 0 || *base2 == 0)
 		return (ENOMEM);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-	if (check_region(*base, 256) != 0
-	 || check_region(*base2, 256) != 0)
-		return (ENOMEM);
-	request_region(*base, 256, "aic79xx");
-	request_region(*base2, 256, "aic79xx");
-#else
 	if (request_region(*base, 256, "aic79xx") == 0)
 		return (ENOMEM);
 	if (request_region(*base2, 256, "aic79xx") == 0) {
 		release_region(*base2, 256);
 		return (ENOMEM);
 	}
-#endif
 	return (0);
 }
 
 static int
 ahd_linux_pci_reserve_mem_region(struct ahd_softc *ahd,
 				 u_long *bus_addr,
-				 uint8_t **maddr)
+				 uint8_t __iomem **maddr)
 {
 	u_long	start;
 	u_long	base_page;
@@ -288,29 +257,18 @@
 		return (ENOMEM);
 
 	error = 0;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	start = pci_resource_start(ahd->dev_softc, 1);
 	base_page = start & PAGE_MASK;
 	base_offset = start - base_page;
-#else
-	start = ahd_pci_read_config(ahd->dev_softc, PCIR_MAPS+4, 4);
-	base_offset = start & PCI_BASE_ADDRESS_MEM_MASK;
-	base_page = base_offset & PAGE_MASK;
-	base_offset -= base_page;
-#endif
 	if (start != 0) {
 		*bus_addr = start;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 		if (request_mem_region(start, 0x1000, "aic79xx") == 0)
 			error = ENOMEM;
-#endif
 		if (error == 0) {
 			*maddr = ioremap_nocache(base_page, base_offset + 256);
 			if (*maddr == NULL) {
 				error = ENOMEM;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 				release_mem_region(start, 0x1000);
-#endif
 			} else
 				*maddr += base_offset;
 		}
@@ -324,7 +282,7 @@
 {
 	uint32_t command;
 	u_long	 base;
-	uint8_t	*maddr;
+	uint8_t	__iomem *maddr;
 	int	 error;
 
 	/*
@@ -351,11 +309,9 @@
 			       ahd_get_pci_bus(ahd->dev_softc),
 			       ahd_get_pci_slot(ahd->dev_softc),
 			       ahd_get_pci_function(ahd->dev_softc));
-			iounmap((void *)((u_long)maddr & PAGE_MASK));
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+			iounmap(maddr);
 			release_mem_region(ahd->platform_data->mem_busaddr,
 					   0x1000);
-#endif
 			ahd->bshs[0].maddr = NULL;
 			maddr = NULL;
 		} else
@@ -408,38 +364,5 @@
 void
 ahd_power_state_change(struct ahd_softc *ahd, ahd_power_state new_state)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	pci_set_power_state(ahd->dev_softc, new_state);
-#else
-	uint32_t cap;
-	u_int cap_offset;
-
-	/*
-	 * Traverse the capability list looking for
-	 * the power management capability.
-	 */
-	cap = 0;
-	cap_offset = ahd_pci_read_config(ahd->dev_softc,
-					 PCIR_CAP_PTR, /*bytes*/1);
-	while (cap_offset != 0) {
-
-		cap = ahd_pci_read_config(ahd->dev_softc,
-					  cap_offset, /*bytes*/4);
-		if ((cap & 0xFF) == 1
-		 && ((cap >> 16) & 0x3) > 0) {
-			uint32_t pm_control;
-
-			pm_control = ahd_pci_read_config(ahd->dev_softc,
-							 cap_offset + 4,
-							 /*bytes*/4);
-			pm_control &= ~0x3;
-			pm_control |= new_state;
-			ahd_pci_write_config(ahd->dev_softc,
-					     cap_offset + 4,
-					     pm_control, /*bytes*/2);
-			break;
-		}
-		cap_offset = (cap >> 8) & 0xFF;
-	}
-#endif 
 }
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c	2004-12-24 13:36:48 -08:00
@@ -51,6 +51,8 @@
 #include <dev/aic7xxx/aic79xx_inline.h>
 #endif
 
+#include "aic79xx_pci.h"
+
 static __inline uint64_t
 ahd_compose_id(u_int device, u_int vendor, u_int subdevice, u_int subvendor)
 {
@@ -64,34 +66,12 @@
 	return (id);
 }
 
-#define ID_ALL_MASK			0xFFFFFFFFFFFFFFFFull
-#define ID_ALL_IROC_MASK		0xFFFFFF7FFFFFFFFFull
-#define ID_DEV_VENDOR_MASK		0xFFFFFFFF00000000ull
-#define ID_9005_GENERIC_MASK		0xFFF0FFFF00000000ull
-#define ID_9005_GENERIC_IROC_MASK	0xFFF0FF7F00000000ull
-
-#define ID_AIC7901			0x800F9005FFFF9005ull
-#define ID_AHA_29320A			0x8000900500609005ull
-#define ID_AHA_29320ALP			0x8017900500449005ull
-
-#define ID_AIC7901A			0x801E9005FFFF9005ull
-#define ID_AHA_29320			0x8012900500429005ull
-#define ID_AHA_29320B			0x8013900500439005ull
-#define ID_AHA_29320LP			0x8014900500449005ull
-
-#define ID_AIC7902			0x801F9005FFFF9005ull
-#define ID_AIC7902_B			0x801D9005FFFF9005ull
-#define ID_AHA_39320			0x8010900500409005ull
-#define ID_AHA_39320_B			0x8015900500409005ull
-#define ID_AHA_39320A			0x8016900500409005ull
-#define ID_AHA_39320D			0x8011900500419005ull
-#define ID_AHA_39320D_B			0x801C900500419005ull
-#define ID_AHA_39320D_HP		0x8011900500AC0E11ull
-#define ID_AHA_39320D_B_HP		0x801C900500AC0E11ull
 #define ID_AIC7902_PCI_REV_A4		0x3
 #define ID_AIC7902_PCI_REV_B0		0x10
 #define SUBID_HP			0x0E11
 
+#define DEVID_9005_HOSTRAID(id) ((id) & 0x80)
+
 #define DEVID_9005_TYPE(id) ((id) & 0xF)
 #define		DEVID_9005_TYPE_HBA		0x0	/* Standard Card */
 #define		DEVID_9005_TYPE_HBA_2EXT	0x1	/* 2 External Ports */
@@ -134,18 +114,18 @@
 		"Adaptec 29320ALP Ultra320 SCSI adapter",
 		ahd_aic7901_setup
 	},
-	/* aic7901A based controllers */
+	/* aic7902 based controllers */	
 	{
 		ID_AHA_29320,
 		ID_ALL_MASK,
 		"Adaptec 29320 Ultra320 SCSI adapter",
-		ahd_aic7901A_setup
+		ahd_aic7902_setup
 	},
 	{
 		ID_AHA_29320B,
 		ID_ALL_MASK,
 		"Adaptec 29320B Ultra320 SCSI adapter",
-		ahd_aic7901A_setup
+		ahd_aic7902_setup
 	},
 	{
 		ID_AHA_29320LP,
@@ -153,7 +133,6 @@
 		"Adaptec 29320LP Ultra320 SCSI adapter",
 		ahd_aic7901A_setup
 	},
-	/* aic7902 based controllers */	
 	{
 		ID_AHA_39320,
 		ID_ALL_MASK,
@@ -196,22 +175,10 @@
 		"Adaptec (HP OEM) 39320D Ultra320 SCSI adapter",
 		ahd_aic7902_setup
 	},
-	{
-		ID_AHA_29320,
-		ID_ALL_MASK,
-		"Adaptec 29320 Ultra320 SCSI adapter",
-		ahd_aic7902_setup
-	},
-	{
-		ID_AHA_29320B,
-		ID_ALL_MASK,
-		"Adaptec 29320B Ultra320 SCSI adapter",
-		ahd_aic7902_setup
-	},
 	/* Generic chip probes for devices we don't know 'exactly' */
 	{
-		ID_AIC7901 & ID_DEV_VENDOR_MASK,
-		ID_DEV_VENDOR_MASK,
+		ID_AIC7901 & ID_9005_GENERIC_MASK,
+		ID_9005_GENERIC_MASK,
 		"Adaptec AIC7901 Ultra320 SCSI adapter",
 		ahd_aic7901_setup
 	},
@@ -293,6 +260,12 @@
 				 vendor,
 				 subdevice,
 				 subvendor);
+
+	/*
+	 * Controllers, mask out the IROC/HostRAID bit
+	 */
+	
+	full_id &= ID_ALL_IROC_MASK;
 
 	for (i = 0; i < ahd_num_pci_devs; i++) {
 		entry = &ahd_pci_ident_table[i];
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_pci.h b/drivers/scsi/aic7xxx/aic79xx_pci.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,70 @@
+/*
+ * Adaptec AIC79xx device driver for Linux.
+ *
+ * Copyright (c) 2000-2001 Adaptec Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ *
+ * $Id$
+ *
+ */
+#ifndef _AIC79XX_PCI_H_
+#define _AIC79XX_PCI_H_
+
+#define ID_ALL_MASK			0xFFFFFFFFFFFFFFFFull
+#define ID_ALL_IROC_MASK		0xFF7FFFFFFFFFFFFFull
+#define ID_DEV_VENDOR_MASK		0xFFFFFFFF00000000ull
+#define ID_9005_GENERIC_MASK		0xFFF0FFFF00000000ull
+#define ID_9005_GENERIC_IROC_MASK	0xFF70FFFF00000000ull
+
+#define ID_AIC7901			0x800F9005FFFF9005ull
+#define ID_AHA_29320A			0x8000900500609005ull
+#define ID_AHA_29320ALP			0x8017900500449005ull
+
+#define ID_AIC7901A			0x801E9005FFFF9005ull
+#define ID_AHA_29320			0x8012900500429005ull
+#define ID_AHA_29320B			0x8013900500439005ull
+#define ID_AHA_29320LP			0x8014900500449005ull
+
+#define ID_AIC7902			0x801F9005FFFF9005ull
+#define ID_AIC7902_B			0x801D9005FFFF9005ull
+#define ID_AHA_39320			0x8010900500409005ull
+#define ID_AHA_39320_B			0x8015900500409005ull
+#define ID_AHA_39320A			0x8016900500409005ull
+#define ID_AHA_39320D			0x8011900500419005ull
+#define ID_AHA_39320D_B			0x801C900500419005ull
+#define ID_AHA_39320D_HP		0x8011900500AC0E11ull
+#define ID_AHA_39320D_B_HP		0x801C900500AC0E11ull
+
+#endif /* _AIC79XX_PCI_H_ */
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h
--- a/drivers/scsi/aic7xxx/aic7xxx.h	2004-12-24 13:36:55 -08:00
+++ b/drivers/scsi/aic7xxx/aic7xxx.h	2004-12-24 13:36:55 -08:00
@@ -521,7 +521,7 @@
 
 struct sg_map_node {
 	bus_dmamap_t		 sg_dmamap;
-	bus_addr_t		 sg_physaddr;
+	dma_addr_t		 sg_physaddr;
 	struct ahc_dma_seg*	 sg_vaddr;
 	SLIST_ENTRY(sg_map_node) links;
 };
@@ -584,7 +584,7 @@
 	struct scb_platform_data *platform_data;
 	struct sg_map_node	 *sg_map;
 	struct ahc_dma_seg 	 *sg_list;
-	bus_addr_t		  sg_list_phys;
+	dma_addr_t		  sg_list_phys;
 	u_int			  sg_count;/* How full ahc_dma_seg is */
 };
 
@@ -611,10 +611,10 @@
 	 */
 	bus_dma_tag_t	 hscb_dmat;	/* dmat for our hardware SCB array */
 	bus_dmamap_t	 hscb_dmamap;
-	bus_addr_t	 hscb_busaddr;
+	dma_addr_t	 hscb_busaddr;
 	bus_dma_tag_t	 sense_dmat;
 	bus_dmamap_t	 sense_dmamap;
-	bus_addr_t	 sense_busaddr;
+	dma_addr_t	 sense_busaddr;
 	bus_dma_tag_t	 sg_dmat;	/* dmat for our sg segments */
 	SLIST_HEAD(, sg_map_node) sg_maps;
 	uint8_t	numscbs;
@@ -1069,14 +1069,14 @@
 	bus_dma_tag_t		  parent_dmat;
 	bus_dma_tag_t		  shared_data_dmat;
 	bus_dmamap_t		  shared_data_dmamap;
-	bus_addr_t		  shared_data_busaddr;
+	dma_addr_t		  shared_data_busaddr;
 
 	/*
 	 * Bus address of the one byte buffer used to
 	 * work-around a DMA bug for chips <= aic7880
 	 * in target mode.
 	 */
-	bus_addr_t		  dma_bug_buf;
+	dma_addr_t		  dma_bug_buf;
 
 	/* Number of enabled target mode device on this card */
 	u_int			  enabled_luns;
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c	2004-12-24 13:36:48 -08:00
@@ -3973,7 +3973,6 @@
 	default:
 	case 5:
 		ahc_shutdown(ahc);
-		TAILQ_REMOVE(&ahc_tailq, ahc, links);
 		/* FALLTHROUGH */
 	case 4:
 		ahc_dmamap_unload(ahc, ahc->shared_data_dmat,
@@ -4199,9 +4198,9 @@
 static void
 ahc_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) 
 {
-	bus_addr_t *baddr;
+	dma_addr_t *baddr;
 
-	baddr = (bus_addr_t *)arg;
+	baddr = (dma_addr_t *)arg;
 	*baddr = segs->ds_addr;
 }
 
@@ -4456,7 +4455,7 @@
 	struct scb_data *scb_data;
 	struct scb *next_scb;
 	struct sg_map_node *sg_map;
-	bus_addr_t physaddr;
+	dma_addr_t physaddr;
 	struct ahc_dma_seg *segs;
 	int newcount;
 	int i;
@@ -4820,7 +4819,7 @@
 	if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,
 			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
 			       /*lowaddr*/ahc->flags & AHC_39BIT_ADDRESSING
-					? (bus_addr_t)0x7FFFFFFFFFULL
+					? (dma_addr_t)0x7FFFFFFFFFULL
 					: BUS_SPACE_MAXADDR_32BIT,
 			       /*highaddr*/BUS_SPACE_MAXADDR,
 			       /*filter*/NULL, /*filterarg*/NULL,
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c	2004-12-24 13:36:18 -08:00
@@ -129,10 +129,7 @@
  */
 #include "aiclib.c"
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 #include <linux/init.h>		/* __setup */
-#endif
-
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 #include "sd.h"			/* For geometry detection */
@@ -152,14 +149,6 @@
 u_int ahc_linux_nseg;
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-struct proc_dir_entry proc_scsi_aic7xxx = {
-	PROC_SCSI_AIC7XXX, 7, "aic7xxx",
-	S_IFDIR | S_IRUGO | S_IXUGO, 2,
-	0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-};
-#endif
-
 /*
  * Set this to the delay in seconds after SCSI bus reset.
  * Note, we honor this only for the initial bus reset.
@@ -449,7 +438,7 @@
 MODULE_DESCRIPTION("Adaptec Aic77XX/78XX SCSI Host Bus Adapter driver");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(AIC7XXX_DRIVER_VERSION);
-MODULE_PARM(aic7xxx, "s");
+module_param(aic7xxx, charp, 0444);
 MODULE_PARM_DESC(aic7xxx,
 "period delimited, options string.\n"
 "	verbose			Enable verbose/diagnostic logging\n"
@@ -572,7 +561,7 @@
 
 static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
 		 		      struct ahc_dma_seg *sg,
-				      bus_addr_t addr, bus_size_t len);
+				      dma_addr_t addr, bus_size_t len);
 
 static __inline void
 ahc_schedule_completeq(struct ahc_softc *ahc)
@@ -590,14 +579,7 @@
 static __inline void
 ahc_schedule_runq(struct ahc_softc *ahc)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	tasklet_schedule(&ahc->platform_data->runq_tasklet);
-#else
-	/*
-	 * Tasklets are not available, so run inline.
-	 */
-	ahc_runq_tasklet((unsigned long)ahc);
-#endif
 }
 
 static __inline struct ahc_linux_device*
@@ -728,7 +710,7 @@
 
 static __inline int
 ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
-		  struct ahc_dma_seg *sg, bus_addr_t addr, bus_size_t len)
+		  struct ahc_dma_seg *sg, dma_addr_t addr, bus_size_t len)
 {
 	int	 consumed;
 
@@ -740,7 +722,7 @@
 	sg->addr = ahc_htole32(addr & 0xFFFFFFFF);
 	scb->platform_data->xfer_len += len;
 
-	if (sizeof(bus_addr_t) > 4
+	if (sizeof(dma_addr_t) > 4
 	 && (ahc->flags & AHC_39BIT_ADDRESSING) != 0)
 		len |= (addr >> 8) & AHC_SG_HIGH_ADDR_MASK;
 
@@ -863,7 +845,6 @@
 		return (0);
 	}
 	ahc_linux_size_nseg();
-#ifdef MODULE
 	/*
 	 * If we've been passed any parameters, process them now.
 	 */
@@ -875,13 +856,8 @@
 "aic7xxx: to see the proper way to specify options to the aic7xxx module\n"
 "aic7xxx: Specifically, don't use any commas when passing arguments to\n"
 "aic7xxx: insmod or else it might trash certain memory areas.\n");
-#endif
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
 	template->proc_name = "aic7xxx";
-#else
-	template->proc_dir = &proc_scsi_aic7xxx;
-#endif
 
 	/*
 	 * Initialize our softc list lock prior to
@@ -1323,28 +1299,20 @@
 {
 	struct ahc_softc* ahc;
 	struct ahc_linux_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	u_long flags;
-#endif
 
 	ahc = (struct ahc_softc *)data;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	ahc_lock(ahc, &flags);
-#endif
 	while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) {
 	
 		TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links);
 		dev->flags &= ~AHC_DEV_ON_RUN_LIST;
 		ahc_linux_check_device_queue(ahc, dev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 		/* Yeild to our interrupt handler */
 		ahc_unlock(ahc, &flags);
 		ahc_lock(ahc, &flags);
-#endif
 	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	ahc_unlock(ahc, &flags);
-#endif
 }
 
 /******************************** Macros **************************************/
@@ -1357,7 +1325,7 @@
 int
 ahc_dma_tag_create(struct ahc_softc *ahc, bus_dma_tag_t parent,
 		   bus_size_t alignment, bus_size_t boundary,
-		   bus_addr_t lowaddr, bus_addr_t highaddr,
+		   dma_addr_t lowaddr, dma_addr_t highaddr,
 		   bus_dma_filter_t *filter, void *filterarg,
 		   bus_size_t maxsize, int nsegments,
 		   bus_size_t maxsegsz, int flags, bus_dma_tag_t *ret_tag)
@@ -1394,7 +1362,6 @@
 {
 	bus_dmamap_t map;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT);
 	if (map == NULL)
 		return (ENOMEM);
@@ -1406,28 +1373,20 @@
 	 * our dma mask when doing allocations.
 	 */
 	if (ahc->dev_softc != NULL)
-		if (ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) {
+		if (pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) {
 			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
+			kfree(map);
 			return (ENODEV);
 		}
 	*vaddr = pci_alloc_consistent(ahc->dev_softc,
 				      dmat->maxsize, &map->bus_addr);
 	if (ahc->dev_softc != NULL)
-		if (ahc_pci_set_dma_mask(ahc->dev_softc,
+		if (pci_set_dma_mask(ahc->dev_softc,
 				     ahc->platform_data->hw_dma_mask)) {
 			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
+			kfree(map);
 			return (ENODEV);
 		}
-#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
-	/*
-	 * At least in 2.2.14, malloc is a slab allocator so all
-	 * allocations are aligned.  We assume for these kernel versions
-	 * that all allocations will be bellow 4Gig, physically contiguous,
-	 * and accessible via DMA by the controller.
-	 */
-	map = NULL; /* No additional information to store */
-	*vaddr = malloc(dmat->maxsize, M_DEVBUF, M_NOWAIT);
-#endif
 	if (*vaddr == NULL)
 		return (ENOMEM);
 	*mapp = map;
@@ -1438,12 +1397,8 @@
 ahc_dmamem_free(struct ahc_softc *ahc, bus_dma_tag_t dmat,
 		void* vaddr, bus_dmamap_t map)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	pci_free_consistent(ahc->dev_softc, dmat->maxsize,
 			    vaddr, map->bus_addr);
-#else
-	free(vaddr, M_DEVBUF);
-#endif
 }
 
 int
@@ -1457,12 +1412,7 @@
 	 */
 	bus_dma_segment_t stack_sg;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	stack_sg.ds_addr = map->bus_addr;
-#else
-#define VIRT_TO_BUS(a) (uint32_t)virt_to_bus((void *)(a))
-	stack_sg.ds_addr = VIRT_TO_BUS(buf);
-#endif
 	stack_sg.ds_len = dmat->maxsize;
 	cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0);
 	return (0);
@@ -1473,9 +1423,10 @@
 {
 	/*
 	 * The map may is NULL in our < 2.3.X implementation.
+	 * Now it's 2.6.5, but just in case...
 	 */
-	if (map != NULL)
-		free(map, M_DEVBUF);
+	BUG_ON(map == NULL);
+	free(map, M_DEVBUF);
 }
 
 int
@@ -1691,9 +1642,7 @@
 	return 1;
 }
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
 __setup("aic7xxx=", aic7xxx_setup);
-#endif
 
 uint32_t aic7xxx_verbose;
 
@@ -1736,8 +1685,7 @@
 		ahc_set_name(ahc, new_name);
 	}
 	host->unique_id = ahc->unit;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) && \
-    LINUX_VERSION_CODE  < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	scsi_set_pci_device(host, ahc->dev_softc);
 #endif
 	ahc_linux_initialize_scsi_bus(ahc);
@@ -1923,19 +1871,11 @@
 	ahc->platform_data->completeq_timer.data = (u_long)ahc;
 	ahc->platform_data->completeq_timer.function =
 	    (ahc_linux_callback_t *)ahc_linux_thread_run_complete_queue;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	init_MUTEX_LOCKED(&ahc->platform_data->eh_sem);
 	init_MUTEX_LOCKED(&ahc->platform_data->dv_sem);
 	init_MUTEX_LOCKED(&ahc->platform_data->dv_cmd_sem);
-#else
-	ahc->platform_data->eh_sem = MUTEX_LOCKED;
-	ahc->platform_data->dv_sem = MUTEX_LOCKED;
-	ahc->platform_data->dv_cmd_sem = MUTEX_LOCKED;
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	tasklet_init(&ahc->platform_data->runq_tasklet, ahc_runq_tasklet,
 		     (unsigned long)ahc);
-#endif
 	ahc->seltime = (aic7xxx_seltime & 0x3) << 4;
 	ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4;
 	if (aic7xxx_pci_parity == 0)
@@ -1954,9 +1894,7 @@
 	if (ahc->platform_data != NULL) {
 		del_timer_sync(&ahc->platform_data->completeq_timer);
 		ahc_linux_kill_dv_thread(ahc);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 		tasklet_kill(&ahc->platform_data->runq_tasklet);
-#endif
 		if (ahc->platform_data->host != NULL) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
 			scsi_remove_host(ahc->platform_data->host);
@@ -1992,18 +1930,11 @@
 			release_region(ahc->bsh.ioport, 256);
 		if (ahc->tag == BUS_SPACE_MEMIO
 		 && ahc->bsh.maddr != NULL) {
-			u_long base_addr;
-
-			base_addr = (u_long)ahc->bsh.maddr;
-			base_addr &= PAGE_MASK;
-			iounmap((void *)base_addr);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+			iounmap(ahc->bsh.maddr);
 			release_mem_region(ahc->platform_data->mem_busaddr,
 					   0x1000);
-#endif
 		}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) && \
-    LINUX_VERSION_CODE  < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 		/*
 		 * In 2.4 we detach from the scsi midlayer before the PCI
 		 * layer invokes our remove callback.  No per-instance
@@ -3749,7 +3680,7 @@
 			 * a transfer crosses a 32bit page.
 			 */ 
 			while (cur_seg < end_seg) {
-				bus_addr_t addr;
+				dma_addr_t addr;
 				bus_size_t len;
 				int consumed;
 
@@ -3778,7 +3709,7 @@
 			scb->hscb->datacnt = scb->sg_list->len;
 		} else if (cmd->request_bufflen != 0) {
 			struct	 ahc_dma_seg *sg;
-			bus_addr_t addr;
+			dma_addr_t addr;
 
 			sg = scb->sg_list;
 			addr = pci_map_single(ahc->dev_softc,
@@ -4062,7 +3993,7 @@
 		WARN_ON(lun != CAM_LUN_WILDCARD);
 		scsi_report_device_reset(ahc->platform_data->host,
 					 channel - 'A', target);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
+#else
 		Scsi_Device *scsi_dev;
 
 		/*
@@ -4083,12 +4014,10 @@
 		break;
 	}
         case AC_BUS_RESET:
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 		if (ahc->platform_data->host != NULL) {
 			scsi_report_bus_reset(ahc->platform_data->host,
 					      channel - 'A');
 		}
-#endif
                 break;
         default:
                 panic("ahc_send_async: Unexpected async event");
@@ -5098,7 +5027,6 @@
 ahc_linux_exit(void)
 {
 	struct ahc_softc *ahc;
-	u_long l;
 
 	/*
 	 * Shutdown DV threads before going into the SCSI mid-layer.
@@ -5106,12 +5034,10 @@
 	 * kernel so that waiting for our DV threads to exit leads
 	 * to deadlock.
 	 */
-	ahc_list_lock(&l);
 	TAILQ_FOREACH(ahc, &ahc_tailq, links) {
 
 		ahc_linux_kill_dv_thread(ahc);
 	}
-	ahc_list_unlock(&l);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	/*
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h	2004-12-24 13:36:47 -08:00
@@ -70,17 +70,9 @@
 #include <asm/byteorder.h>
 #include <asm/io.h>
 
-#ifndef KERNEL_VERSION
-#define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 #include <linux/interrupt.h> /* For tasklet support. */
 #include <linux/config.h>
 #include <linux/slab.h>
-#else
-#include <linux/malloc.h>
-#endif
 
 /* Core SCSI definitions */
 #define AIC_LIB_PREFIX ahc
@@ -156,11 +148,6 @@
 
 /***************************** Bus Space/DMA **********************************/
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,17)
-typedef dma_addr_t bus_addr_t;
-#else
-typedef uint32_t bus_addr_t;
-#endif
 typedef uint32_t bus_size_t;
 
 typedef enum {
@@ -170,12 +157,12 @@
 
 typedef union {
 	u_long		  ioport;
-	volatile uint8_t *maddr;
+	volatile uint8_t __iomem *maddr;
 } bus_space_handle_t;
 
 typedef struct bus_dma_segment
 {
-	bus_addr_t	ds_addr;
+	dma_addr_t	ds_addr;
 	bus_size_t	ds_len;
 } bus_dma_segment_t;
 
@@ -189,11 +176,11 @@
 
 struct ahc_linux_dmamap
 {
-	bus_addr_t	bus_addr;
+	dma_addr_t	bus_addr;
 };
 typedef struct ahc_linux_dmamap* bus_dmamap_t;
 
-typedef int bus_dma_filter_t(void*, bus_addr_t);
+typedef int bus_dma_filter_t(void*, dma_addr_t);
 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
 
 #define BUS_DMA_WAITOK		0x0
@@ -210,7 +197,7 @@
 
 int	ahc_dma_tag_create(struct ahc_softc *, bus_dma_tag_t /*parent*/,
 			   bus_size_t /*alignment*/, bus_size_t /*boundary*/,
-			   bus_addr_t /*lowaddr*/, bus_addr_t /*highaddr*/,
+			   dma_addr_t /*lowaddr*/, dma_addr_t /*highaddr*/,
 			   bus_dma_filter_t*/*filter*/, void */*filterarg*/,
 			   bus_size_t /*maxsize*/, int /*nsegments*/,
 			   bus_size_t /*maxsegsz*/, int /*flags*/,
@@ -292,11 +279,7 @@
 }
 
 /***************************** SMP support ************************************/
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
 #include <linux/spinlock.h>
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
-#include <linux/smp.h>
-#endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK))
 #define AHC_SCSI_HAS_HOST_LOCK 1
@@ -515,11 +498,8 @@
 
 struct scb_platform_data {
 	struct ahc_linux_device	*dev;
-	bus_addr_t		 buf_busaddr;
+	dma_addr_t		 buf_busaddr;
 	uint32_t		 xfer_len;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-	uint32_t		 resid;		/* Transfer residual */
-#endif
 	uint32_t		 sense_resid;	/* Auto-Sense residual */
 	ahc_linux_scb_flags	 flags;
 };
@@ -549,9 +529,7 @@
 	struct ahc_completeq	 completeq;
 
 	spinlock_t		 spin_lock;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	struct tasklet_struct	 runq_tasklet;
-#endif
 	u_int			 qfrozen;
 	pid_t			 dv_pid;
 	struct timer_list	 completeq_timer;
@@ -567,7 +545,7 @@
 	uint32_t		 irq;		/* IRQ for this adapter */
 	uint32_t		 bios_address;
 	uint32_t		 mem_busaddr;	/* Mem Base Addr */
-	bus_addr_t		 hw_dma_mask;
+	uint64_t		 hw_dma_mask;
 	ahc_linux_softc_flags	 flags;
 };
 
@@ -819,9 +797,7 @@
 #define PCIR_SUBVEND_0	0x2c
 #define PCIR_SUBDEV_0	0x2e
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 extern struct pci_driver aic7xxx_pci_driver;
-#endif
 
 typedef enum
 {
@@ -954,25 +930,6 @@
 	ahc_inb(ahc, INTSTAT);
 }
 
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0)
-#define pci_map_sg(pdev, sg_list, nseg, direction) (nseg)
-#define pci_unmap_sg(pdev, sg_list, nseg, direction)
-#define sg_dma_address(sg) (VIRT_TO_BUS((sg)->address))
-#define sg_dma_len(sg) ((sg)->length)
-#define pci_map_single(pdev, buffer, bufflen, direction) \
-	(VIRT_TO_BUS(buffer))
-#define pci_unmap_single(pdev, buffer, buflen, direction)
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3)
-#define ahc_pci_set_dma_mask pci_set_dma_mask
-#else
-/*
- * Always "return" 0 for success.
- */
-#define ahc_pci_set_dma_mask(dev_softc, mask)  			\
-	(((dev_softc)->dma_mask = mask) && 0)
-#endif
 /**************************** Proc FS Support *********************************/
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 int	ahc_linux_proc_info(char *, char **, off_t, int, int, int);
@@ -1080,35 +1037,13 @@
 static __inline
 int ahc_get_transfer_dir(struct scb *scb)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,40)
 	return (scb->io_ctx->sc_data_direction);
-#else
-	if (scb->io_ctx->bufflen == 0)
-		return (CAM_DIR_NONE);
-
-	switch(scb->io_ctx->cmnd[0]) {
-	case 0x08:  /* READ(6)  */
-	case 0x28:  /* READ(10) */
-	case 0xA8:  /* READ(12) */
-		return (CAM_DIR_IN);
-        case 0x0A:  /* WRITE(6)  */
-        case 0x2A:  /* WRITE(10) */
-        case 0xAA:  /* WRITE(12) */
-		return (CAM_DIR_OUT);
-        default:
-		return (CAM_DIR_NONE);
-        }
-#endif
 }
 
 static __inline
 void ahc_set_residual(struct scb *scb, u_long resid)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	scb->io_ctx->resid = resid;
-#else
-	scb->platform_data->resid = resid;
-#endif
 }
 
 static __inline
@@ -1120,11 +1055,7 @@
 static __inline
 u_long ahc_get_residual(struct scb *scb)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	return (scb->io_ctx->resid);
-#else
-	return (scb->platform_data->resid);
-#endif
 }
 
 static __inline
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c	2004-12-24 13:36:32 -08:00
@@ -40,6 +40,7 @@
  */
 
 #include "aic7xxx_osm.h"
+#include "aic7xxx_pci.h"
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 struct pci_device_id
@@ -53,20 +54,84 @@
 						u_long *base);
 static int	ahc_linux_pci_reserve_mem_region(struct ahc_softc *ahc,
 						 u_long *bus_addr,
-						 uint8_t **maddr);
+						 uint8_t __iomem **maddr);
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 static void	ahc_linux_pci_dev_remove(struct pci_dev *pdev);
 
-/* We do our own ID filtering.  So, grab all SCSI storage class devices. */
+/* Define the macro locally since it's different for different class of chips.
+*/
+#define ID(x)	ID_C(x, PCI_CLASS_STORAGE_SCSI)
+
 static struct pci_device_id ahc_linux_pci_id_table[] = {
-	{
-		0x9004, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-		PCI_CLASS_STORAGE_SCSI << 8, 0xFFFF00, 0
-	},
-	{
-		0x9005, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-		PCI_CLASS_STORAGE_SCSI << 8, 0xFFFF00, 0
-	},
+	/* aic7850 based controllers */
+	ID(ID_AHA_2902_04_10_15_20C_30C),
+	/* aic7860 based controllers */
+	ID(ID_AHA_2930CU),
+	ID(ID_AHA_1480A & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_2940AU_0 & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_2940AU_CN & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_2930C_VAR & ID_DEV_VENDOR_MASK),
+	/* aic7870 based controllers */
+	ID(ID_AHA_2940),
+	ID(ID_AHA_3940),
+	ID(ID_AHA_398X),
+	ID(ID_AHA_2944),
+	ID(ID_AHA_3944),
+	ID(ID_AHA_4944),
+	/* aic7880 based controllers */
+	ID(ID_AHA_2940U & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_3940U & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_2944U & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_3944U & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_398XU & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_4944U & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_2930U & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_2940U_PRO & ID_DEV_VENDOR_MASK),
+	ID(ID_AHA_2940U_CN & ID_DEV_VENDOR_MASK),
+	/* aic7890 based controllers */
+	ID(ID_AHA_2930U2),
+	ID(ID_AHA_2940U2B),
+	ID(ID_AHA_2940U2_OEM),
+	ID(ID_AHA_2940U2),
+	ID(ID_AHA_2950U2B),
+	ID16(ID_AIC7890_ARO & ID_AIC7895_ARO_MASK),
+	ID(ID_AAA_131U2),
+	/* aic7890 based controllers */
+	ID(ID_AHA_29160),
+	ID(ID_AHA_29160_CPQ),
+	ID(ID_AHA_29160N),
+	ID(ID_AHA_29160C),
+	ID(ID_AHA_29160B),
+	ID(ID_AHA_19160B),
+	ID(ID_AIC7892_ARO),
+	/* aic7892 based controllers */
+	ID(ID_AHA_2940U_DUAL),
+	ID(ID_AHA_3940AU),
+	ID(ID_AHA_3944AU),
+	ID(ID_AIC7895_ARO),
+	ID(ID_AHA_3950U2B_0),
+	ID(ID_AHA_3950U2B_1),
+	ID(ID_AHA_3950U2D_0),
+	ID(ID_AHA_3950U2D_1),
+	ID(ID_AIC7896_ARO),
+	/* aic7899 based controllers */
+	ID(ID_AHA_3960D),
+	ID(ID_AHA_3960D_CPQ),
+	ID(ID_AIC7899_ARO),
+	/* Generic chip probes for devices we don't know exactly. */
+	ID(ID_AIC7850 & ID_DEV_VENDOR_MASK),
+	ID(ID_AIC7855 & ID_DEV_VENDOR_MASK),
+	ID(ID_AIC7859 & ID_DEV_VENDOR_MASK),
+	ID(ID_AIC7860 & ID_DEV_VENDOR_MASK),
+	ID(ID_AIC7870 & ID_DEV_VENDOR_MASK),
+	ID(ID_AIC7880 & ID_DEV_VENDOR_MASK),
+ 	ID16(ID_AIC7890 & ID_9005_GENERIC_MASK),
+ 	ID16(ID_AIC7892 & ID_9005_GENERIC_MASK),
+	ID(ID_AIC7895 & ID_DEV_VENDOR_MASK),
+	ID16(ID_AIC7896 & ID_9005_GENERIC_MASK),
+	ID16(ID_AIC7899 & ID_9005_GENERIC_MASK),
+	ID(ID_AIC7810 & ID_DEV_VENDOR_MASK),
+	ID(ID_AIC7815 & ID_DEV_VENDOR_MASK),
 	{ 0 }
 };
 
@@ -95,12 +160,14 @@
 	if (ahc != NULL) {
 		u_long s;
 
+		TAILQ_REMOVE(&ahc_tailq, ahc, links);
+		ahc_list_unlock(&l);
 		ahc_lock(ahc, &s);
 		ahc_intr_enable(ahc, FALSE);
 		ahc_unlock(ahc, &s);
 		ahc_free(ahc);
-	}
-	ahc_list_unlock(&l);
+	} else
+		ahc_list_unlock(&l);
 }
 #endif /* !LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) */
 
@@ -108,7 +175,7 @@
 ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	char		 buf[80];
-	bus_addr_t	 mask_39bit;
+	const uint64_t	 mask_39bit = 0x7FFFFFFFFFULL;
 	struct		 ahc_softc *ahc;
 	ahc_dev_softc_t	 pci;
 	struct		 ahc_pci_identity *entry;
@@ -159,18 +226,17 @@
 	}
 	pci_set_master(pdev);
 
-	mask_39bit = (bus_addr_t)0x7FFFFFFFFFULL;
-	if (sizeof(bus_addr_t) > 4
+	if (sizeof(dma_addr_t) > 4
 	 && ahc_linux_get_memsize() > 0x80000000
-	 && ahc_pci_set_dma_mask(pdev, mask_39bit) == 0) {
+	 && pci_set_dma_mask(pdev, mask_39bit) == 0) {
 		ahc->flags |= AHC_39BIT_ADDRESSING;
 		ahc->platform_data->hw_dma_mask = mask_39bit;
 	} else {
-		if (ahc_pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
+		if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
 			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
                 	return (-ENODEV);
 		}
-		ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;
+		ahc->platform_data->hw_dma_mask = DMA_32BIT_MASK;
 	}
 #endif
 	ahc->dev_softc = pci;
@@ -259,24 +325,13 @@
 static int
 ahc_linux_pci_reserve_mem_region(struct ahc_softc *ahc,
 				 u_long *bus_addr,
-				 uint8_t **maddr)
+				 uint8_t __iomem **maddr)
 {
 	u_long	start;
-	u_long	base_page;
-	u_long	base_offset;
 	int	error;
 
 	error = 0;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	start = pci_resource_start(ahc->dev_softc, 1);
-	base_page = start & PAGE_MASK;
-	base_offset = start - base_page;
-#else
-	start = ahc_pci_read_config(ahc->dev_softc, PCIR_MAPS+4, 4);
-	base_offset = start & PCI_BASE_ADDRESS_MEM_MASK;
-	base_page = base_offset & PAGE_MASK;
-	base_offset -= base_page;
-#endif
 	if (start != 0) {
 		*bus_addr = start;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
@@ -284,14 +339,13 @@
 			error = ENOMEM;
 #endif
 		if (error == 0) {
-			*maddr = ioremap_nocache(base_page, base_offset + 256);
+			*maddr = ioremap_nocache(start, 256);
 			if (*maddr == NULL) {
 				error = ENOMEM;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 				release_mem_region(start, 0x1000);
 #endif
-			} else
-				*maddr += base_offset;
+			}
 		}
 	} else
 		error = ENOMEM;
@@ -303,7 +357,7 @@
 {
 	uint32_t command;
 	u_long	 base;
-	uint8_t	*maddr;
+	uint8_t	__iomem *maddr;
 	int	 error;
 
 	/*
@@ -332,7 +386,7 @@
 			       ahc_get_pci_bus(ahc->dev_softc),
 			       ahc_get_pci_slot(ahc->dev_softc),
 			       ahc_get_pci_function(ahc->dev_softc));
-			iounmap((void *)((u_long)maddr & PAGE_MASK));
+			iounmap(maddr);
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 			release_mem_region(ahc->platform_data->mem_busaddr,
 					   0x1000);
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c
--- a/drivers/scsi/aic7xxx/aic7xxx_pci.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c	2004-12-24 13:36:17 -08:00
@@ -54,8 +54,7 @@
 #include <dev/aic7xxx/aic7xxx_93cx6.h>
 #endif
 
-#define AHC_PCI_IOADDR	PCIR_MAPS	/* I/O Address */
-#define AHC_PCI_MEMADDR	(PCIR_MAPS + 4)	/* Mem I/O Address */
+#include "aic7xxx_pci.h"
 
 static __inline uint64_t
 ahc_compose_id(u_int device, u_int vendor, u_int subdevice, u_int subvendor)
@@ -70,84 +69,8 @@
 	return (id);
 }
 
-#define ID_ALL_MASK			0xFFFFFFFFFFFFFFFFull
-#define ID_DEV_VENDOR_MASK		0xFFFFFFFF00000000ull
-#define ID_9005_GENERIC_MASK		0xFFF0FFFF00000000ull
-#define ID_9005_SISL_MASK		0x000FFFFF00000000ull
-#define ID_9005_SISL_ID			0x0005900500000000ull
-#define ID_AIC7850			0x5078900400000000ull
-#define ID_AHA_2902_04_10_15_20C_30C	0x5078900478509004ull
-#define ID_AIC7855			0x5578900400000000ull
-#define ID_AIC7859			0x3860900400000000ull
-#define ID_AHA_2930CU			0x3860900438699004ull
-#define ID_AIC7860			0x6078900400000000ull
-#define ID_AIC7860C			0x6078900478609004ull
-#define ID_AHA_1480A			0x6075900400000000ull
-#define ID_AHA_2940AU_0			0x6178900400000000ull
-#define ID_AHA_2940AU_1			0x6178900478619004ull
-#define ID_AHA_2940AU_CN		0x2178900478219004ull
-#define ID_AHA_2930C_VAR		0x6038900438689004ull
-
-#define ID_AIC7870			0x7078900400000000ull
-#define ID_AHA_2940			0x7178900400000000ull
-#define ID_AHA_3940			0x7278900400000000ull
-#define ID_AHA_398X			0x7378900400000000ull
-#define ID_AHA_2944			0x7478900400000000ull
-#define ID_AHA_3944			0x7578900400000000ull
-#define ID_AHA_4944			0x7678900400000000ull
-
-#define ID_AIC7880			0x8078900400000000ull
-#define ID_AIC7880_B			0x8078900478809004ull
-#define ID_AHA_2940U			0x8178900400000000ull
-#define ID_AHA_3940U			0x8278900400000000ull
-#define ID_AHA_2944U			0x8478900400000000ull
-#define ID_AHA_3944U			0x8578900400000000ull
-#define ID_AHA_398XU			0x8378900400000000ull
-#define ID_AHA_4944U			0x8678900400000000ull
-#define ID_AHA_2940UB			0x8178900478819004ull
-#define ID_AHA_2930U			0x8878900478889004ull
-#define ID_AHA_2940U_PRO		0x8778900478879004ull
-#define ID_AHA_2940U_CN			0x0078900478009004ull
-
-#define ID_AIC7895			0x7895900478959004ull
-#define ID_AIC7895_ARO			0x7890900478939004ull
-#define ID_AIC7895_ARO_MASK		0xFFF0FFFFFFFFFFFFull
-#define ID_AHA_2940U_DUAL		0x7895900478919004ull
-#define ID_AHA_3940AU			0x7895900478929004ull
-#define ID_AHA_3944AU			0x7895900478949004ull
-
-#define ID_AIC7890			0x001F9005000F9005ull
-#define ID_AIC7890_ARO			0x00139005000F9005ull
-#define ID_AAA_131U2			0x0013900500039005ull
-#define ID_AHA_2930U2			0x0011900501819005ull
-#define ID_AHA_2940U2B			0x00109005A1009005ull
-#define ID_AHA_2940U2_OEM		0x0010900521809005ull
-#define ID_AHA_2940U2			0x00109005A1809005ull
-#define ID_AHA_2950U2B			0x00109005E1009005ull
-
-#define ID_AIC7892			0x008F9005FFFF9005ull
-#define ID_AIC7892_ARO			0x00839005FFFF9005ull
-#define ID_AHA_29160			0x00809005E2A09005ull
-#define ID_AHA_29160_CPQ		0x00809005E2A00E11ull
-#define ID_AHA_29160N			0x0080900562A09005ull
-#define ID_AHA_29160C			0x0080900562209005ull
-#define ID_AHA_29160B			0x00809005E2209005ull
-#define ID_AHA_19160B			0x0081900562A19005ull
-
-#define ID_AIC7896			0x005F9005FFFF9005ull
-#define ID_AIC7896_ARO			0x00539005FFFF9005ull
-#define ID_AHA_3950U2B_0		0x00509005FFFF9005ull
-#define ID_AHA_3950U2B_1		0x00509005F5009005ull
-#define ID_AHA_3950U2D_0		0x00519005FFFF9005ull
-#define ID_AHA_3950U2D_1		0x00519005B5009005ull
-
-#define ID_AIC7899			0x00CF9005FFFF9005ull
-#define ID_AIC7899_ARO			0x00C39005FFFF9005ull
-#define ID_AHA_3960D			0x00C09005F6209005ull
-#define ID_AHA_3960D_CPQ		0x00C09005F6200E11ull
-
-#define ID_AIC7810			0x1078900400000000ull
-#define ID_AIC7815			0x7815900400000000ull
+#define AHC_PCI_IOADDR	PCIR_MAPS	/* I/O Address */
+#define AHC_PCI_MEMADDR	(PCIR_MAPS + 4)	/* Mem I/O Address */
 
 #define DEVID_9005_TYPE(id) ((id) & 0xF)
 #define		DEVID_9005_TYPE_HBA		0x0	/* Standard Card */
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_pci.h b/drivers/scsi/aic7xxx/aic7xxx_pci.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/aic7xxx/aic7xxx_pci.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,124 @@
+/*
+ * Adaptec AIC7xxx device driver for Linux.
+ *
+ * Copyright (c) 2000-2001 Adaptec Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ *
+ * $Id$
+ *
+ */
+#ifndef _AIC7XXX_PCI_H_
+#define _AIC7XXX_PCI_H_
+
+#define ID_ALL_MASK			0xFFFFFFFFFFFFFFFFull
+#define ID_DEV_VENDOR_MASK		0xFFFFFFFF00000000ull
+#define ID_9005_GENERIC_MASK		0xFFF0FFFF00000000ull
+#define ID_9005_SISL_MASK		0x000FFFFF00000000ull
+#define ID_9005_SISL_ID			0x0005900500000000ull
+#define ID_AIC7850			0x5078900400000000ull
+#define ID_AHA_2902_04_10_15_20C_30C	0x5078900478509004ull
+#define ID_AIC7855			0x5578900400000000ull
+#define ID_AIC7859			0x3860900400000000ull
+#define ID_AHA_2930CU			0x3860900438699004ull
+#define ID_AIC7860			0x6078900400000000ull
+#define ID_AIC7860C			0x6078900478609004ull
+#define ID_AHA_1480A			0x6075900400000000ull
+#define ID_AHA_2940AU_0			0x6178900400000000ull
+#define ID_AHA_2940AU_1			0x6178900478619004ull
+#define ID_AHA_2940AU_CN		0x2178900478219004ull
+#define ID_AHA_2930C_VAR		0x6038900438689004ull
+
+#define ID_AIC7870			0x7078900400000000ull
+#define ID_AHA_2940			0x7178900400000000ull
+#define ID_AHA_3940			0x7278900400000000ull
+#define ID_AHA_398X			0x7378900400000000ull
+#define ID_AHA_2944			0x7478900400000000ull
+#define ID_AHA_3944			0x7578900400000000ull
+#define ID_AHA_4944			0x7678900400000000ull
+
+#define ID_AIC7880			0x8078900400000000ull
+#define ID_AIC7880_B			0x8078900478809004ull
+#define ID_AHA_2940U			0x8178900400000000ull
+#define ID_AHA_3940U			0x8278900400000000ull
+#define ID_AHA_2944U			0x8478900400000000ull
+#define ID_AHA_3944U			0x8578900400000000ull
+#define ID_AHA_398XU			0x8378900400000000ull
+#define ID_AHA_4944U			0x8678900400000000ull
+#define ID_AHA_2940UB			0x8178900478819004ull
+#define ID_AHA_2930U			0x8878900478889004ull
+#define ID_AHA_2940U_PRO		0x8778900478879004ull
+#define ID_AHA_2940U_CN			0x0078900478009004ull
+
+#define ID_AIC7895			0x7895900478959004ull
+#define ID_AIC7895_ARO			0x7890900478939004ull
+#define ID_AIC7895_ARO_MASK		0xFFF0FFFFFFFFFFFFull
+#define ID_AHA_2940U_DUAL		0x7895900478919004ull
+#define ID_AHA_3940AU			0x7895900478929004ull
+#define ID_AHA_3944AU			0x7895900478949004ull
+
+#define ID_AIC7890			0x001F9005000F9005ull
+#define ID_AIC7890_ARO			0x00139005000F9005ull
+#define ID_AAA_131U2			0x0013900500039005ull
+#define ID_AHA_2930U2			0x0011900501819005ull
+#define ID_AHA_2940U2B			0x00109005A1009005ull
+#define ID_AHA_2940U2_OEM		0x0010900521809005ull
+#define ID_AHA_2940U2			0x00109005A1809005ull
+#define ID_AHA_2950U2B			0x00109005E1009005ull
+
+#define ID_AIC7892			0x008F9005FFFF9005ull
+#define ID_AIC7892_ARO			0x00839005FFFF9005ull
+#define ID_AHA_29160			0x00809005E2A09005ull
+#define ID_AHA_29160_CPQ		0x00809005E2A00E11ull
+#define ID_AHA_29160N			0x0080900562A09005ull
+#define ID_AHA_29160C			0x0080900562209005ull
+#define ID_AHA_29160B			0x00809005E2209005ull
+#define ID_AHA_19160B			0x0081900562A19005ull
+
+#define ID_AIC7896			0x005F9005FFFF9005ull
+#define ID_AIC7896_ARO			0x00539005FFFF9005ull
+#define ID_AHA_3950U2B_0		0x00509005FFFF9005ull
+#define ID_AHA_3950U2B_1		0x00509005F5009005ull
+#define ID_AHA_3950U2D_0		0x00519005FFFF9005ull
+#define ID_AHA_3950U2D_1		0x00519005B5009005ull
+
+#define ID_AIC7899			0x00CF9005FFFF9005ull
+#define ID_AIC7899_ARO			0x00C39005FFFF9005ull
+#define ID_AHA_3960D			0x00C09005F6209005ull
+#define ID_AHA_3960D_CPQ		0x00C09005F6200E11ull
+
+#define ID_AIC7810			0x1078900400000000ull
+#define ID_AIC7815			0x7815900400000000ull
+
+#endif /* _AIC7XXX_PCI_H_ */
diff -Nru a/drivers/scsi/aic7xxx/aiclib.h b/drivers/scsi/aic7xxx/aiclib.h
--- a/drivers/scsi/aic7xxx/aiclib.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/aic7xxx/aiclib.h	2004-12-24 13:36:17 -08:00
@@ -1043,4 +1043,43 @@
 	return (rv);
 }
 
+/* Macros for generating the elements of the PCI ID tables. */
+
+#define GETID(v, s) (unsigned)(((v) >> (s)) & 0xFFFF ?: PCI_ANY_ID)
+
+#define ID_C(x, c)						\
+{								\
+	GETID(x,32), GETID(x,48), GETID(x,0), GETID(x,16),	\
+	(c) << 8, 0xFFFF00, 0					\
+}
+
+#define ID2C(x)                          \
+	ID_C(x, PCI_CLASS_STORAGE_SCSI), \
+	ID_C(x, PCI_CLASS_STORAGE_RAID)
+
+#define IDIROC(x)  ((x) | ~ID_ALL_IROC_MASK)
+
+/* Generate IDs for all 16 possibilites.
+ * The argument has already masked out
+ * the 4 least significant bits of the device id.
+ * (e.g., mask: ID_9005_GENERIC_MASK).
+ */
+#define ID16(x)                          \
+	ID(x),                           \
+	ID((x) | 0x0001000000000000ull), \
+	ID((x) | 0x0002000000000000ull), \
+	ID((x) | 0x0003000000000000ull), \
+	ID((x) | 0x0004000000000000ull), \
+	ID((x) | 0x0005000000000000ull), \
+	ID((x) | 0x0006000000000000ull), \
+	ID((x) | 0x0007000000000000ull), \
+	ID((x) | 0x0008000000000000ull), \
+	ID((x) | 0x0009000000000000ull), \
+	ID((x) | 0x000A000000000000ull), \
+	ID((x) | 0x000B000000000000ull), \
+	ID((x) | 0x000C000000000000ull), \
+	ID((x) | 0x000D000000000000ull), \
+	ID((x) | 0x000E000000000000ull), \
+	ID((x) | 0x000F000000000000ull)
+
 #endif /*_AICLIB_H */
diff -Nru a/drivers/scsi/aic7xxx/cam.h b/drivers/scsi/aic7xxx/cam.h
--- a/drivers/scsi/aic7xxx/cam.h	2004-12-24 13:36:49 -08:00
+++ b/drivers/scsi/aic7xxx/cam.h	2004-12-24 13:36:49 -08:00
@@ -85,12 +85,6 @@
 	CAM_STATUS_MASK		= 0x3F
 } cam_status;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-#define	SCSI_DATA_READ	1
-#define	SCSI_DATA_WRITE 2
-#define SCSI_DATA_NONE  3
-#endif
-
 /*
  * Definitions for the asynchronous callback CCB fields.
  */
diff -Nru a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
--- a/drivers/scsi/aic7xxx_old.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/aic7xxx_old.c	2004-12-24 13:37:43 -08:00
@@ -924,7 +924,7 @@
   volatile long            flags;
   ahc_feature              features;         /* chip features */
   unsigned long            base;             /* card base address */
-  volatile unsigned char  *maddr;            /* memory mapped address */
+  volatile unsigned char  __iomem *maddr;            /* memory mapped address */
   unsigned long            isr_count;        /* Interrupt count */
   unsigned long            spurious_int;
   scb_data_type           *scb_data;
@@ -1233,7 +1233,7 @@
  */
 #ifdef MODULE
 static char * aic7xxx = NULL;
-MODULE_PARM(aic7xxx, "s");
+module_param(aic7xxx, charp, 0);
 #endif
 
 #define VERBOSE_NORMAL         0x0000
@@ -7967,8 +7967,8 @@
     printk(KERN_INFO "(scsi%d) BIOS %sabled, IO Port 0x%lx, IRQ %d\n",
       p->host_no, (p->flags & AHC_BIOS_ENABLED) ? "en" : "dis",
       p->base, p->irq);
-    printk(KERN_INFO "(scsi%d) IO Memory at 0x%lx, MMAP Memory at 0x%lx\n",
-      p->host_no, p->mbase, (unsigned long)p->maddr);
+    printk(KERN_INFO "(scsi%d) IO Memory at 0x%lx, MMAP Memory at %p\n",
+      p->host_no, p->mbase, p->maddr);
   }
 
 #ifdef CONFIG_PCI
@@ -9243,6 +9243,7 @@
 	    {
               /* duplicate PCI entry, skip it */
 	      kfree(temp_p);
+	      temp_p = NULL;
               continue;
 	    }
 	    current_p = current_p->next;
@@ -9310,14 +9311,9 @@
                ((temp_p->chip != (AHC_AIC7870 | AHC_PCI)) &&
                 (temp_p->chip != (AHC_AIC7880 | AHC_PCI))) )
           {
-            unsigned long page_offset, base;
-
-            base = temp_p->mbase & PAGE_MASK;
-            page_offset = temp_p->mbase - base;
-            temp_p->maddr = ioremap_nocache(base, page_offset + 256);
+            temp_p->maddr = ioremap_nocache(temp_p->mbase, 256);
             if(temp_p->maddr)
             {
-              temp_p->maddr += page_offset;
               /*
                * We need to check the I/O with the MMAPed address.  Some machines
                * simply fail to work with MMAPed I/O and certain controllers.
@@ -9334,7 +9330,7 @@
                   PCI_FUNC(temp_p->pci_device_fn));
                 printk(KERN_INFO "aic7xxx: MMAPed I/O failed, reverting to "
                                  "Programmed I/O.\n");
-                iounmap((void *) (((unsigned long) temp_p->maddr) & PAGE_MASK));
+                iounmap(temp_p->maddr);
                 temp_p->maddr = NULL;
                 if(temp_p->base == 0)
                 {
@@ -10964,7 +10960,7 @@
 #ifdef MMAPIO
   if(p->maddr)
   {
-    iounmap((void *) (((unsigned long) p->maddr) & PAGE_MASK));
+    iounmap(p->maddr);
   }
 #endif /* MMAPIO */
   if(!p->pdev)
diff -Nru a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
--- a/drivers/scsi/arm/acornscsi.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/scsi/arm/acornscsi.c	2004-12-24 13:36:55 -08:00
@@ -142,8 +142,8 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
diff -Nru a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c
--- a/drivers/scsi/arm/arxescsi.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/scsi/arm/arxescsi.c	2004-12-24 13:36:55 -08:00
@@ -286,14 +286,12 @@
 	unsigned char *base;
 	int ret;
 
-	resbase = ecard_resource_start(ec, ECARD_RES_MEMC);
-	reslen = ecard_resource_len(ec, ECARD_RES_MEMC);
-
-	if (!request_mem_region(resbase, reslen, "arxescsi")) {
-		ret = -EBUSY;
+	ret = ecard_request_resources(ec);
+	if (ret)
 		goto out;
-	}
 
+	resbase = ecard_resource_start(ec, ECARD_RES_MEMC);
+	reslen = ecard_resource_len(ec, ECARD_RES_MEMC);
 	base = ioremap(resbase, reslen);
 	if (!base) {
 		ret = -ENOMEM;
@@ -345,7 +343,7 @@
  out_unmap:
 	iounmap(base);
  out_region:
-	release_mem_region(resbase, reslen);
+	ecard_release_resources(ec);
  out:
 	return ret;
 }
@@ -353,20 +351,15 @@
 static void __devexit arxescsi_remove(struct expansion_card *ec)
 {
 	struct Scsi_Host *host = ecard_get_drvdata(ec);
-	unsigned long resbase, reslen;
 
 	ecard_set_drvdata(ec, NULL);
 	fas216_remove(host);
 
 	iounmap((void *)host->base);
 
-	resbase = ecard_resource_start(ec, ECARD_RES_MEMC);
-	reslen = ecard_resource_len(ec, ECARD_RES_MEMC);
-
-	release_mem_region(resbase, reslen);
-
 	fas216_release(host);
 	scsi_host_put(host);
+	ecard_release_resources(ec);
 }
 
 static const struct ecard_id arxescsi_cids[] = {
diff -Nru a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c
--- a/drivers/scsi/arm/cumana_2.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/scsi/arm/cumana_2.c	2004-12-24 13:37:03 -08:00
@@ -408,14 +408,12 @@
 	unsigned char *base;
 	int ret;
 
-	resbase = ecard_resource_start(ec, ECARD_RES_MEMC);
-	reslen = ecard_resource_len(ec, ECARD_RES_MEMC);
-
-	if (!request_mem_region(resbase, reslen, "cumanascsi2")) {
-		ret = -EBUSY;
+	ret = ecard_request_resources(ec);
+	if (ret)
 		goto out;
-	}
 
+	resbase = ecard_resource_start(ec, ECARD_RES_MEMC);
+	reslen = ecard_resource_len(ec, ECARD_RES_MEMC);
 	base = ioremap(resbase, reslen);
 	if (!base) {
 		ret = -ENOMEM;
@@ -504,7 +502,7 @@
 	iounmap(base);
 
  out_region:
-	release_mem_region(resbase, reslen);
+	ecard_release_resources(ec);
 
  out:
 	return ret;
@@ -514,7 +512,6 @@
 {
 	struct Scsi_Host *host = ecard_get_drvdata(ec);
 	struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
-	unsigned long resbase, reslen;
 
 	ecard_set_drvdata(ec, NULL);
 	fas216_remove(host);
@@ -525,13 +522,9 @@
 
 	iounmap((void *)host->base);
 
-	resbase = ecard_resource_start(ec, ECARD_RES_MEMC);
-	reslen = ecard_resource_len(ec, ECARD_RES_MEMC);
-
-	release_mem_region(resbase, reslen);
-
 	fas216_release(host);
 	scsi_host_put(host);
+	ecard_release_resources(ec);
 }
 
 static const struct ecard_id cumanascsi2_cids[] = {
diff -Nru a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c
--- a/drivers/scsi/arm/eesox.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/scsi/arm/eesox.c	2004-12-24 13:37:30 -08:00
@@ -525,14 +525,12 @@
 	unsigned char *base;
 	int ret;
 
-	resbase = ecard_resource_start(ec, ECARD_RES_IOCFAST);
-	reslen = ecard_resource_len(ec, ECARD_RES_IOCFAST);
-
-	if (!request_mem_region(resbase, reslen, "eesoxscsi")) {
-		ret = -EBUSY;
+	ret = ecard_request_resources(ec);
+	if (ret)
 		goto out;
-	}
 
+	resbase = ecard_resource_start(ec, ECARD_RES_IOCFAST);
+	reslen = ecard_resource_len(ec, ECARD_RES_IOCFAST);
 	base = ioremap(resbase, reslen);
 	if (!base) {
 		ret = -ENOMEM;
@@ -622,7 +620,7 @@
 	iounmap(base);
 
  out_region:
-	release_mem_region(resbase, reslen);
+	ecard_release_resources(ec);
 
  out:
 	return ret;
@@ -632,7 +630,6 @@
 {
 	struct Scsi_Host *host = ecard_get_drvdata(ec);
 	struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata;
-	unsigned long resbase, reslen;
 
 	ecard_set_drvdata(ec, NULL);
 	fas216_remove(host);
@@ -645,13 +642,9 @@
 
 	iounmap((void *)host->base);
 
-	resbase = ecard_resource_start(ec, ECARD_RES_IOCFAST);
-	reslen = ecard_resource_len(ec, ECARD_RES_IOCFAST);
-
-	release_mem_region(resbase, reslen);
-
 	fas216_release(host);
 	scsi_host_put(host);
+	ecard_release_resources(ec);
 }
 
 static const struct ecard_id eesoxscsi_cids[] = {
diff -Nru a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
--- a/drivers/scsi/arm/fas216.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/arm/fas216.c	2004-12-24 13:36:47 -08:00
@@ -96,7 +96,7 @@
 
 static int level_mask = LOG_ERROR;
 
-MODULE_PARM(level_mask, "i");
+module_param(level_mask, int, 0644);
 
 static int __init fas216_log_setup(char *str)
 {
diff -Nru a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c
--- a/drivers/scsi/arm/powertec.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/scsi/arm/powertec.c	2004-12-24 13:37:01 -08:00
@@ -318,14 +318,12 @@
 	unsigned char *base;
 	int ret;
 
-	resbase = ecard_resource_start(ec, ECARD_RES_IOCFAST);
-	reslen = ecard_resource_len(ec, ECARD_RES_IOCFAST);
-
-	if (!request_mem_region(resbase, reslen, "powertecscsi")) {
-		ret = -EBUSY;
+	ret = ecard_request_resources(ec);
+	if (ret)
 		goto out;
-	}
 
+	resbase = ecard_resource_start(ec, ECARD_RES_IOCFAST);
+	reslen = ecard_resource_len(ec, ECARD_RES_IOCFAST);
 	base = ioremap(resbase, reslen);
 	if (!base) {
 		ret = -ENOMEM;
@@ -413,7 +411,7 @@
 	iounmap(base);
 
  out_region:
-	release_mem_region(resbase, reslen);
+	ecard_release_resources(ec);
 
  out:
 	return ret;
@@ -423,7 +421,6 @@
 {
 	struct Scsi_Host *host = ecard_get_drvdata(ec);
 	struct powertecscsi_info *info = (struct powertecscsi_info *)host->hostdata;
-	unsigned long resbase, reslen;
 
 	ecard_set_drvdata(ec, NULL);
 	fas216_remove(host);
@@ -436,13 +433,9 @@
 
 	iounmap((void *)host->base);
 
-	resbase = ecard_resource_start(ec, ECARD_RES_IOCFAST);
-	reslen = ecard_resource_len(ec, ECARD_RES_IOCFAST);
-
-	release_mem_region(resbase, reslen);
-
 	fas216_release(host);
 	scsi_host_put(host);
+	ecard_release_resources(ec);
 }
 
 static const struct ecard_id powertecscsi_cids[] = {
diff -Nru a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
--- a/drivers/scsi/ata_piix.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/scsi/ata_piix.c	2004-12-24 13:36:49 -08:00
@@ -32,7 +32,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME	"ata_piix"
-#define DRV_VERSION	"1.02"
+#define DRV_VERSION	"1.03"
 
 enum {
 	PIIX_IOCFG		= 0x54, /* IDE I/O configuration register */
@@ -184,7 +184,7 @@
 #else
 		.mwdma_mask	= 0x00, /* mwdma broken */
 #endif
-		.udma_mask	= ATA_UDMA_MASK_40C, /* FIXME: cbl det */
+		.udma_mask	= 0x3f, /* udma0-5 */
 		.port_ops	= &piix_pata_ops,
 	},
 
@@ -209,7 +209,7 @@
 #else
 		.mwdma_mask	= 0x00, /* mwdma broken */
 #endif
-		.udma_mask	= ATA_UDMA_MASK_40C, /* FIXME: cbl det */
+		.udma_mask	= ATA_UDMA_MASK_40C,
 		.port_ops	= &piix_pata_ops,
 	},
 
@@ -247,12 +247,13 @@
 MODULE_DESCRIPTION("SCSI low-level driver for Intel PIIX/ICH ATA controllers");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
 /**
  *	piix_pata_cbl_detect - Probe host controller cable detect info
  *	@ap: Port for which cable detect info is desired
  *
- *	Read 80c cable indicator from SATA PCI device's PCI config
+ *	Read 80c cable indicator from ATA PCI device's PCI config
  *	register.  This register is normally set by firmware (BIOS).
  *
  *	LOCKING:
@@ -260,7 +261,7 @@
  */
 static void piix_pata_cbl_detect(struct ata_port *ap)
 {
-	struct pci_dev *pdev = ap->host_set->pdev;
+	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u8 tmp, mask;
 
 	/* no 80c support in host controller? */
@@ -268,7 +269,7 @@
 		goto cbl40;
 
 	/* check BIOS cable detect results */
-	mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
+	mask = ap->hard_port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
 	pci_read_config_byte(pdev, PIIX_IOCFG, &tmp);
 	if ((tmp & mask) == 0)
 		goto cbl40;
@@ -293,8 +294,9 @@
 
 static void piix_pata_phy_reset(struct ata_port *ap)
 {
-	if (!pci_test_config_bits(ap->host_set->pdev,
-				  &piix_enable_bits[ap->port_no])) {
+	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
+
+	if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->hard_port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return;
@@ -322,13 +324,13 @@
  */
 static int piix_sata_probe (struct ata_port *ap)
 {
-	struct pci_dev *pdev = ap->host_set->pdev;
+	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	int combined = (ap->flags & ATA_FLAG_SLAVE_POSS);
 	int orig_mask, mask, i;
 	u8 pcs;
 
-	mask = (PIIX_PORT_PRESENT << ap->port_no) |
-	       (PIIX_PORT_ENABLED << ap->port_no);
+	mask = (PIIX_PORT_PRESENT << ap->hard_port_no) |
+	       (PIIX_PORT_ENABLED << ap->hard_port_no);
 
 	pci_read_config_byte(pdev, ICH5_PCS, &pcs);
 	orig_mask = (int) pcs & 0xff;
@@ -345,7 +347,7 @@
 		mask = (PIIX_PORT_PRESENT << i) | (PIIX_PORT_ENABLED << i);
 
 		if ((orig_mask & mask) == mask)
-			if (combined || (i == ap->port_no))
+			if (combined || (i == ap->hard_port_no))
 				return 1;
 	}
 
@@ -392,9 +394,9 @@
 static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
 {
 	unsigned int pio	= adev->pio_mode - XFER_PIO_0;
-	struct pci_dev *dev	= ap->host_set->pdev;
+	struct pci_dev *dev	= to_pci_dev(ap->host_set->dev);
 	unsigned int is_slave	= (adev->devno != 0);
-	unsigned int master_port= ap->port_no ? 0x42 : 0x40;
+	unsigned int master_port= ap->hard_port_no ? 0x42 : 0x40;
 	unsigned int slave_port	= 0x44;
 	u16 master_data;
 	u8 slave_data;
@@ -412,10 +414,10 @@
 		/* enable PPE, IE and TIME */
 		master_data |= 0x0070;
 		pci_read_config_byte(dev, slave_port, &slave_data);
-		slave_data &= (ap->port_no ? 0x0f : 0xf0);
+		slave_data &= (ap->hard_port_no ? 0x0f : 0xf0);
 		slave_data |=
 			(timings[pio][0] << 2) |
-			(timings[pio][1] << (ap->port_no ? 4 : 0));
+			(timings[pio][1] << (ap->hard_port_no ? 4 : 0));
 	} else {
 		master_data &= 0xccf8;
 		/* enable PPE, IE and TIME */
@@ -444,10 +446,10 @@
 static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 {
 	unsigned int udma	= adev->dma_mode; /* FIXME: MWDMA too */
-	struct pci_dev *dev	= ap->host_set->pdev;
-	u8 maslave		= ap->port_no ? 0x42 : 0x40;
+	struct pci_dev *dev	= to_pci_dev(ap->host_set->dev);
+	u8 maslave		= ap->hard_port_no ? 0x42 : 0x40;
 	u8 speed		= udma;
-	unsigned int drive_dn	= (ap->port_no ? 2 : 0) + adev->devno;
+	unsigned int drive_dn	= (ap->hard_port_no ? 2 : 0) + adev->devno;
 	int a_speed		= 3 << (drive_dn * 4);
 	int u_flag		= 1 << drive_dn;
 	int v_flag		= 0x01 << drive_dn;
diff -Nru a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
--- a/drivers/scsi/atari_scsi.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/scsi/atari_scsi.c	2004-12-24 13:37:32 -08:00
@@ -91,6 +91,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/nvram.h>
+#include <linux/bitops.h>
 
 #include <asm/setup.h>
 #include <asm/atarihw.h>
@@ -99,7 +100,6 @@
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/traps.h>
-#include <asm/bitops.h>
 
 #include "scsi.h"
 #include <scsi/scsi_host.h>
diff -Nru a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
--- a/drivers/scsi/atp870u.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/atp870u.c	2004-12-24 13:36:48 -08:00
@@ -1085,7 +1085,7 @@
 
 }
 
-void is870(struct Scsi_Host *host, unsigned int wkport)
+static void is870(struct Scsi_Host *host, unsigned int wkport)
 {
 	unsigned int tmport;
 	unsigned char i, j, k, rmb, n;
diff -Nru a/drivers/scsi/cpqfcTSinit.c b/drivers/scsi/cpqfcTSinit.c
--- a/drivers/scsi/cpqfcTSinit.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/cpqfcTSinit.c	2004-12-24 13:36:17 -08:00
@@ -367,7 +367,7 @@
       Cpqfc_initHBAdata( cpqfcHBAdata, PciDev ); // fill MOST fields
      
       cpqfcHBAdata->HBAnum = NumberOfAdapters;
-      cpqfcHBAdata->hba_spinlock = SPIN_LOCK_UNLOCKED;
+      spin_lock_init(&cpqfcHBAdata->hba_spinlock);
 
       // request necessary resources and check for conflicts
       if( request_irq( HostAdapter->irq,
diff -Nru a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
--- a/drivers/scsi/dc395x.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/dc395x.c	2004-12-24 13:36:18 -08:00
@@ -295,8 +295,8 @@
 struct AdapterCtlBlk {
 	struct Scsi_Host *scsi_host;
 
-	u16 io_port_base;
-	u16 io_port_len;
+	unsigned long io_port_base;
+	unsigned long io_port_len;
 
 	struct list_head dcb_list;		/* head of going dcb list */
 	struct DeviceCtlBlk *dcb_run_robin;
@@ -311,7 +311,7 @@
 
 	u8 sel_timeout;
 
-	u8 irq_level;
+	unsigned int irq_level;
 	u8 tag_max_num;
 	u8 acb_flag;
 	u8 gmode2;
@@ -3931,7 +3931,7 @@
  *
  * @io_port: base I/O address
  **/
-static void __init trms1040_wait_30us(u16 io_port)
+static void __init trms1040_wait_30us(unsigned long io_port)
 {
 	/* ScsiPortStallExecution(30); wait 30 us */
 	outb(5, io_port + TRM_S1040_GEN_TIMER);
@@ -3948,7 +3948,7 @@
  * @cmd:	SB + op code (command) to send
  * @addr:	address to send
  **/
-static void __init trms1040_write_cmd(u16 io_port, u8 cmd, u8 addr)
+static void __init trms1040_write_cmd(unsigned long io_port, u8 cmd, u8 addr)
 {
 	int i;
 	u8 send_data;
@@ -3993,7 +3993,7 @@
  * @addr:	offset into EEPROM
  * @byte:	bytes to write
  **/
-static void __init trms1040_set_data(u16 io_port, u8 addr, u8 byte)
+static void __init trms1040_set_data(unsigned long io_port, u8 addr, u8 byte)
 {
 	int i;
 	u8 send_data;
@@ -4047,7 +4047,7 @@
  * @eeprom:	the data to write
  * @io_port:	the base io port
  **/
-static void __init trms1040_write_all(struct NvRamType *eeprom, u16 io_port)
+static void __init trms1040_write_all(struct NvRamType *eeprom, unsigned long io_port)
 {
 	u8 *b_eeprom = (u8 *)eeprom;
 	u8 addr;
@@ -4087,7 +4087,7 @@
  *
  * Returns the the byte read.
  **/
-static u8 __init trms1040_get_data(u16 io_port, u8 addr)
+static u8 __init trms1040_get_data(unsigned long io_port, u8 addr)
 {
 	int i;
 	u8 read_byte;
@@ -4125,7 +4125,7 @@
  * @eeprom:	where to store the data
  * @io_port:	the base io port
  **/
-static void __init trms1040_read_all(struct NvRamType *eeprom, u16 io_port)
+static void __init trms1040_read_all(struct NvRamType *eeprom, unsigned long io_port)
 {
 	u8 *b_eeprom = (u8 *)eeprom;
 	u8 addr;
@@ -4155,7 +4155,7 @@
  * @eeprom:	caller allocated strcuture to read the eeprom data into
  * @io_port:	io port to read from
  **/
-static void __init check_eeprom(struct NvRamType *eeprom, u16 io_port)
+static void __init check_eeprom(struct NvRamType *eeprom, unsigned long io_port)
 {
 	u16 *w_eeprom = (u16 *)eeprom;
 	u16 w_addr;
@@ -4447,7 +4447,7 @@
  *
  * @acb: The adapter which we are to init.
  **/
-void __init adapter_init_chip(struct AdapterCtlBlk *acb)
+static void __init adapter_init_chip(struct AdapterCtlBlk *acb)
 {
         struct NvRamType *eeprom = &acb->eeprom;
         
@@ -4500,11 +4500,11 @@
  * Returns 0 if the initialization succeeds, any other value on
  * failure.
  **/
-static int __init adapter_init(struct AdapterCtlBlk *acb, u32 io_port,
-		u32 io_port_len, u8 irq)
+static int __init adapter_init(struct AdapterCtlBlk *acb,
+	unsigned long io_port, u32 io_port_len, unsigned int irq)
 {
 	if (!request_region(io_port, io_port_len, DC395X_NAME)) {
-		dprintkl(KERN_ERR, "Failed to reserve IO region 0x%x\n", io_port);
+		dprintkl(KERN_ERR, "Failed to reserve IO region 0x%lx\n", io_port);
 		goto failed;
 	}
 	/* store port base to indicate we have registered it */
@@ -4520,7 +4520,7 @@
 	acb->irq_level = irq;
 
 	/* get eeprom configuration information and command line settings etc */
-	check_eeprom(&acb->eeprom, (u16)io_port);
+	check_eeprom(&acb->eeprom, io_port);
  	print_eeprom_settings(&acb->eeprom);
 
 	/* setup adapter control block */	
@@ -4638,8 +4638,8 @@
 	SPRINTF("SCSI Host Nr %i, ", host->host_no);
 	SPRINTF("DC395U/UW/F DC315/U %s\n",
 		(acb->config & HCC_WIDE_CARD) ? "Wide" : "");
-	SPRINTF("io_port_base 0x%04x, ", acb->io_port_base);
-	SPRINTF("irq_level 0x%02x, ", acb->irq_level);
+	SPRINTF("io_port_base 0x%04lx, ", acb->io_port_base);
+	SPRINTF("irq_level 0x%04x, ", acb->irq_level);
 	SPRINTF(" SelTimeout %ims\n", (1638 * acb->sel_timeout) / 1000);
 
 	SPRINTF("MaxID %i, MaxLUN %i, ", host->max_id, host->max_lun);
@@ -4792,11 +4792,11 @@
 static int __devinit dc395x_init_one(struct pci_dev *dev,
 		const struct pci_device_id *id)
 {
-	struct Scsi_Host *scsi_host;
-	struct AdapterCtlBlk *acb;
-	unsigned int io_port_base;
+	struct Scsi_Host *scsi_host = NULL;
+	struct AdapterCtlBlk *acb = NULL;
+	unsigned long io_port_base;
 	unsigned int io_port_len;
-	u8 irq;
+	unsigned int irq;
 	
 	dprintkdbg(DBG_0, "Init one instance (%s)\n", pci_name(dev));
 	banner_display();
@@ -4809,23 +4809,23 @@
 	io_port_base = pci_resource_start(dev, 0) & PCI_BASE_ADDRESS_IO_MASK;
 	io_port_len = pci_resource_len(dev, 0);
 	irq = dev->irq;
-	dprintkdbg(DBG_0, "IO_PORT=%04x, IRQ=%x\n", io_port_base, dev->irq);
+	dprintkdbg(DBG_0, "IO_PORT=0x%04lx, IRQ=0x%x\n", io_port_base, dev->irq);
 
 	/* allocate scsi host information (includes out adapter) */
 	scsi_host = scsi_host_alloc(&dc395x_driver_template,
 				    sizeof(struct AdapterCtlBlk));
 	if (!scsi_host) {
 		dprintkl(KERN_INFO, "scsi_host_alloc failed\n");
-		return -ENOMEM;
+		goto fail;
 	}
  	acb = (struct AdapterCtlBlk*)scsi_host->hostdata;
  	acb->scsi_host = scsi_host;
+ 	acb->dev = dev;
 
 	/* initialise the adapter and everything we need */
  	if (adapter_init(acb, io_port_base, io_port_len, irq)) {
 		dprintkl(KERN_INFO, "adapter init failed\n");
-		scsi_host_put(scsi_host);
-		return -ENODEV;
+		goto fail;
 	}
 
 	pci_set_master(dev);
@@ -4833,14 +4833,20 @@
 	/* get the scsi mid level to scan for new devices on the bus */
 	if (scsi_add_host(scsi_host, &dev->dev)) {
 		dprintkl(KERN_ERR, "scsi_add_host failed\n");
-		adapter_uninit(acb);
-		scsi_host_put(scsi_host);
-		return -ENODEV;
+		goto fail;
 	}
 	pci_set_drvdata(dev, scsi_host);
 	scsi_scan_host(scsi_host);
         	
 	return 0;
+
+fail:
+	if (acb != NULL)
+		adapter_uninit(acb);
+	if (scsi_host != NULL)
+		scsi_host_put(scsi_host);
+	pci_disable_device(dev);
+	return -ENODEV;
 }
 
 
@@ -4859,6 +4865,7 @@
 
 	scsi_remove_host(scsi_host);
 	adapter_uninit(acb);
+	pci_disable_device(dev);
 	scsi_host_put(scsi_host);
 	pci_set_drvdata(dev, NULL);
 }
diff -Nru a/drivers/scsi/dec_esp.c b/drivers/scsi/dec_esp.c
--- a/drivers/scsi/dec_esp.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/scsi/dec_esp.c	2004-12-24 13:37:02 -08:00
@@ -120,7 +120,7 @@
 }
 
 static Scsi_Host_Template driver_template = {
-	.proc_name		= "esp",
+	.proc_name		= "dec_esp",
 	.proc_info		= &esp_proc_info,
 	.name			= "NCR53C94",
 	.detect			= dec_esp_detect,
diff -Nru a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c
--- a/drivers/scsi/dmx3191d.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/scsi/dmx3191d.c	2004-12-24 13:36:59 -08:00
@@ -1,7 +1,7 @@
-
 /*
-    dmx3191d.c - midlevel driver for the Domex DMX3191D SCSI card.
+    dmx3191d.c - driver for the Domex DMX3191D SCSI card.
     Copyright (C) 2000 by Massimo Piccioni <dafastidio@libero.it>
+    Portions Copyright (C) 2004 by Christoph Hellwig <hch@lst.de>
 
     Based on the generic NCR5380 driver by Drew Eckhardt et al.
 
@@ -20,118 +20,154 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#include <asm/io.h>
-#include <asm/system.h>
-#include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/stat.h>
 #include <linux/interrupt.h>
-#include <linux/delay.h>
+#include <asm/io.h>
 
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 
-#include "dmx3191d.h"
+/*
+ * Defintions for the generic 5380 driver.
+ */
+#define AUTOSENSE
+
+#define NCR5380_read(reg)		inb(port + reg)
+#define NCR5380_write(reg, value)	outb(value, port + reg)
+
+#define NCR5380_implementation_fields	unsigned int port
+#define NCR5380_local_declare()		NCR5380_implementation_fields
+#define NCR5380_setup(instance)		port = instance->io_port
 
-/* play with these values to tune up your system performances */
-/* default setting from g_NCR5380.c */
 /*
-#define USLEEP
-#define USLEEP_POLL		1
-#define USLEEP_SLEEP		20
-#define USLEEP_WAITLONG		500
-*/
+ * Includes needed for NCR5380.[ch] (XXX: Move them to NCR5380.h)
+ */
+#include <linux/delay.h>
+#include "scsi.h"
 
-#define AUTOSENSE
 #include "NCR5380.h"
 #include "NCR5380.c"
 
+#define DMX3191D_DRIVER_NAME	"dmx3191d"
+#define DMX3191D_REGION_LEN	8
+
 
-static int __init dmx3191d_detect(Scsi_Host_Template *tmpl) {
-	int boards = 0;
-	struct Scsi_Host *instance = NULL;
-	struct pci_dev *pdev = NULL;
-
-	tmpl->proc_name = DMX3191D_DRIVER_NAME;
-
-	while ((pdev = pci_find_device(PCI_VENDOR_ID_DOMEX,
-			PCI_DEVICE_ID_DOMEX_DMX3191D, pdev))) {
-
-		unsigned long port;
-		if (pci_enable_device(pdev))
-			continue;
-
-		port = pci_resource_start (pdev, 0);
-		
-		if (!request_region(port, DMX3191D_REGION, DMX3191D_DRIVER_NAME)) {
-			printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
-				port, port + DMX3191D_REGION);
-			continue;
-		}
-
-		instance = scsi_register(tmpl, sizeof(struct NCR5380_hostdata));
-		if(instance == NULL)
-		{
-			release_region(port, DMX3191D_REGION);
-			continue;
-		}
-		scsi_set_device(instance, &pdev->dev);
-		instance->io_port = port;
-		instance->irq = pdev->irq;
-		NCR5380_init(instance, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E);
-
-		if (request_irq(pdev->irq, dmx3191d_intr, SA_SHIRQ,
-				DMX3191D_DRIVER_NAME, instance)) {
-			printk(KERN_WARNING "dmx3191: IRQ %d not available - switching to polled mode.\n", pdev->irq);
-			/* Steam powered scsi controllers run without an IRQ
-			   anyway */
-			instance->irq = SCSI_IRQ_NONE;
-		}
+static struct scsi_host_template dmx3191d_driver_template = {
+	.proc_name		= DMX3191D_DRIVER_NAME,
+	.name			= "Domex DMX3191D",
+	.queuecommand		= NCR5380_queue_command,
+	.eh_abort_handler	= NCR5380_abort,
+	.eh_bus_reset_handler	= NCR5380_bus_reset,
+	.eh_device_reset_handler= NCR5380_device_reset,
+	.eh_host_reset_handler	= NCR5380_host_reset,
+	.can_queue		= 32,
+	.this_id		= 7,
+	.sg_tablesize		= SG_ALL,
+	.cmd_per_lun		= 2,
+	.use_clustering		= DISABLE_CLUSTERING,
+};
 
-		boards++;
+static int __devinit dmx3191d_probe_one(struct pci_dev *pdev,
+		const struct pci_device_id *id)
+{
+	struct Scsi_Host *shost;
+	unsigned long io;
+	int error = -ENODEV;
+
+	if (pci_enable_device(pdev))
+		goto out;
+
+	io = pci_resource_start(pdev, 0);
+	if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
+		printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
+				io, io + DMX3191D_REGION_LEN);
+		goto out_disable_device;
 	}
-	return boards;
-}
 
-static const char * dmx3191d_info(struct Scsi_Host *host) {
-	static const char *info ="Domex DMX3191D";
+	shost = scsi_host_alloc(&dmx3191d_driver_template,
+			sizeof(struct NCR5380_hostdata));
+	if (!shost)
+		goto out_release_region;       
+	shost->io_port = io;
+	shost->irq = pdev->irq;
+
+	NCR5380_init(shost, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E);
+
+	if (request_irq(pdev->irq, NCR5380_intr, SA_SHIRQ,
+				DMX3191D_DRIVER_NAME, shost)) {
+		/*
+		 * Steam powered scsi controllers run without an IRQ anyway
+		 */
+		printk(KERN_WARNING "dmx3191: IRQ %d not available - "
+				    "switching to polled mode.\n", pdev->irq);
+		shost->irq = SCSI_IRQ_NONE;
+	}
+
+	pci_set_drvdata(pdev, shost);
+
+	error = scsi_add_host(shost, &pdev->dev);
+	if (error)
+		goto out_free_irq;
+
+	scsi_scan_host(shost);
+	return 0;
 
-	return info;
+ out_free_irq:
+	free_irq(shost->irq, shost);
+ out_release_region:
+	release_region(shost->io_port, DMX3191D_REGION_LEN);
+ out_disable_device:
+	pci_disable_device(pdev);
+ out:
+	return error;
 }
 
-static int dmx3191d_release_resources(struct Scsi_Host *instance)
+static void __devexit dmx3191d_remove_one(struct pci_dev *pdev)
 {
-	if(instance->irq!=SCSI_IRQ_NONE)
-		free_irq(instance->irq, instance);
-	NCR5380_exit(instance);
-	release_region(instance->io_port, DMX3191D_REGION);
+	struct Scsi_Host *shost = pci_get_drvdata(pdev);
 
-	return 0;
+	scsi_remove_host(shost);
+
+	NCR5380_exit(shost);
+
+	if (shost->irq != SCSI_IRQ_NONE)
+		free_irq(shost->irq, shost);
+	release_region(shost->io_port, DMX3191D_REGION_LEN);
+	pci_disable_device(pdev);
+
+	scsi_host_put(shost);
 }
 
-MODULE_LICENSE("GPL");
+static struct pci_device_id dmx3191d_pci_tbl[] = {
+	{PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
+	{ }
+};
+MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
 
-static Scsi_Host_Template driver_template = {
-	.proc_info		= dmx3191d_proc_info,
-	.name			= "Domex DMX3191D",
-	.detect			= dmx3191d_detect,
-	.release		= dmx3191d_release_resources,
-	.info			= dmx3191d_info,
-	.queuecommand		= dmx3191d_queue_command,
-	.eh_abort_handler	= dmx3191d_abort,
-	.eh_bus_reset_handler	= dmx3191d_bus_reset,
-	.eh_device_reset_handler = dmx3191d_device_reset,
-	.eh_host_reset_handler	= dmx3191d_host_reset,
-	.can_queue		= 32,
-        .this_id		= 7,
-        .sg_tablesize		= SG_ALL,
-	.cmd_per_lun		= 2,
-        .use_clustering		= DISABLE_CLUSTERING,
+static struct pci_driver dmx3191d_pci_driver = {
+	.name		= DMX3191D_DRIVER_NAME,
+	.id_table	= dmx3191d_pci_tbl,
+	.probe		= dmx3191d_probe_one,
+	.remove		= __devexit_p(dmx3191d_remove_one),
 };
-#include "scsi_module.c"
 
+static int __init dmx3191d_init(void)
+{
+	return pci_module_init(&dmx3191d_pci_driver);
+}
+
+static void __exit dmx3191d_exit(void)
+{
+	pci_unregister_driver(&dmx3191d_pci_driver);
+}
+
+module_init(dmx3191d_init);
+module_exit(dmx3191d_exit);
+
+MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
+MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/scsi/dmx3191d.h b/drivers/scsi/dmx3191d.h
--- a/drivers/scsi/dmx3191d.h	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,48 +0,0 @@
-/*
-    dmx3191d.h - defines for the Domex DMX3191D SCSI card.
-    Copyright (C) 2000 by Massimo Piccioni <dafastidio@libero.it>
-
-    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.
-*/
-
-#ifndef __DMX3191D_H
-#define __DMX3191D_H
-
-#define DMX3191D_DRIVER_NAME	"dmx3191d"
-#define DMX3191D_REGION		8
-
-#ifndef PCI_VENDOR_ID_DOMEX
-#define PCI_VENDOR_ID_DOMEX		0x134a
-#define PCI_DEVICE_ID_DOMEX_DMX3191D	0x0001
-#endif
-
-static int dmx3191d_abort(Scsi_Cmnd *);
-static int dmx3191d_detect(Scsi_Host_Template *);
-static const char* dmx3191d_info(struct Scsi_Host *);
-static int dmx3191d_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
-static int dmx3191d_release_resources(struct Scsi_Host *);
-static int dmx3191d_bus_reset(Scsi_Cmnd *);
-static int dmx3191d_host_reset(Scsi_Cmnd *);
-static int dmx3191d_device_reset(Scsi_Cmnd *);
-
-#define NCR5380_read(reg)			inb(port + reg)
-#define NCR5380_write(reg, value)		outb(value, port + reg)
-
-#define NCR5380_implementation_fields		unsigned int port
-#define NCR5380_local_declare()			NCR5380_implementation_fields
-#define NCR5380_setup(instance)			port = instance->io_port
-
-#define NCR5380_abort				dmx3191d_abort
-#define do_NCR5380_intr				dmx3191d_do_intr
-#define NCR5380_intr				dmx3191d_intr
-#define NCR5380_proc_info			dmx3191d_proc_info
-#define NCR5380_queue_command			dmx3191d_queue_command
-#define NCR5380_host_reset			dmx3191d_host_reset
-#define NCR5380_bus_reset			dmx3191d_bus_reset
-#define NCR5380_device_reset			dmx3191d_device_reset
-
-#endif	/* __DMX3191D_H */
-
diff -Nru a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
--- a/drivers/scsi/dpt_i2o.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/dpt_i2o.c	2004-12-24 13:37:18 -08:00
@@ -872,8 +872,8 @@
 	ulong base_addr1_phys = 0;
 	u32 hba_map0_area_size = 0;
 	u32 hba_map1_area_size = 0;
-	ulong base_addr_virt = 0;
-	ulong msg_addr_virt = 0;
+	void __iomem *base_addr_virt = NULL;
+	void __iomem *msg_addr_virt = NULL;
 
 	int raptorFlag = FALSE;
 	int i;
@@ -907,17 +907,17 @@
 	}
 
 
-	base_addr_virt = (ulong)ioremap(base_addr0_phys,hba_map0_area_size);
-	if(base_addr_virt == 0) {
+	base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size);
+	if (!base_addr_virt) {
 		PERROR("dpti: adpt_config_hba: io remap failed\n");
 		return -EINVAL;
 	}
 
         if(raptorFlag == TRUE) {
-		msg_addr_virt = (ulong)ioremap(base_addr1_phys, hba_map1_area_size );
-		if(msg_addr_virt == 0) {
+		msg_addr_virt = ioremap(base_addr1_phys, hba_map1_area_size );
+		if (!msg_addr_virt) {
 			PERROR("dpti: adpt_config_hba: io remap failed on BAR1\n");
-			iounmap((void*)base_addr_virt);
+			iounmap(base_addr_virt);
 			return -EINVAL;
 		}
 	} else {
@@ -928,9 +928,9 @@
 	pHba = kmalloc(sizeof(adpt_hba), GFP_KERNEL);
 	if( pHba == NULL) {
 		if(msg_addr_virt != base_addr_virt){
-			iounmap((void*)msg_addr_virt);
+			iounmap(msg_addr_virt);
 		}
-		iounmap((void*)base_addr_virt);
+		iounmap(base_addr_virt);
 		return -ENOMEM;
 	}
 	memset(pHba, 0, sizeof(adpt_hba));
@@ -961,10 +961,10 @@
 
 	// Set up the Virtual Base Address of the I2O Device
 	pHba->base_addr_virt = base_addr_virt;
-	pHba->msg_addr_virt = msg_addr_virt;  
-	pHba->irq_mask = (ulong)(base_addr_virt+0x30);
-	pHba->post_port = (ulong)(base_addr_virt+0x40);
-	pHba->reply_port = (ulong)(base_addr_virt+0x44);
+	pHba->msg_addr_virt = msg_addr_virt;
+	pHba->irq_mask = base_addr_virt+0x30;
+	pHba->post_port = base_addr_virt+0x40;
+	pHba->reply_port = base_addr_virt+0x44;
 
 	pHba->hrt = NULL;
 	pHba->lct = NULL;
@@ -980,12 +980,12 @@
 	spin_lock_init(&adpt_post_wait_lock);
 
 	if(raptorFlag == 0){
-		printk(KERN_INFO"Adaptec I2O RAID controller %d at %lx size=%x irq=%d\n", 
+		printk(KERN_INFO"Adaptec I2O RAID controller %d at %p size=%x irq=%d\n", 
 			hba_count-1, base_addr_virt, hba_map0_area_size, pDev->irq);
 	} else {
 		printk(KERN_INFO"Adaptec I2O RAID controller %d irq=%d\n",hba_count-1, pDev->irq);
-		printk(KERN_INFO"     BAR0 %lx - size= %x\n",base_addr_virt,hba_map0_area_size);
-		printk(KERN_INFO"     BAR1 %lx - size= %x\n",msg_addr_virt,hba_map1_area_size);
+		printk(KERN_INFO"     BAR0 %p - size= %x\n",base_addr_virt,hba_map0_area_size);
+		printk(KERN_INFO"     BAR1 %p - size= %x\n",msg_addr_virt,hba_map1_area_size);
 	}
 
 	if (request_irq (pDev->irq, adpt_isr, SA_SHIRQ, pHba->name, pHba)) {
@@ -1036,9 +1036,9 @@
 	hba_count--;
 	up(&adpt_configuration_lock);
 
-	iounmap((void*)pHba->base_addr_virt);
+	iounmap(pHba->base_addr_virt);
 	if(pHba->msg_addr_virt != pHba->base_addr_virt){
-		iounmap((void*)pHba->msg_addr_virt);
+		iounmap(pHba->msg_addr_virt);
 	}
 	if(pHba->hrt) {
 		kfree(pHba->hrt);
@@ -1222,7 +1222,7 @@
 {
 
 	u32 m = EMPTY_QUEUE;
-	u32 *msg;
+	u32 __iomem *msg;
 	ulong timeout = jiffies + 30*HZ;
 	do {
 		rmb();
@@ -1238,7 +1238,7 @@
 		schedule_timeout(1);
 	} while(m == EMPTY_QUEUE);
 		
-	msg = (u32*) (pHba->msg_addr_virt + m);
+	msg = pHba->msg_addr_virt + m;
 	memcpy_toio(msg, data, len);
 	wmb();
 
@@ -2638,7 +2638,7 @@
 
 static s32 adpt_send_nop(adpt_hba*pHba,u32 m)
 {
-	u32 *msg;
+	u32 __iomem *msg;
 	ulong timeout = jiffies + 5*HZ;
 
 	while(m == EMPTY_QUEUE){
@@ -2654,7 +2654,7 @@
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
 	}
-	msg = (u32*)(pHba->msg_addr_virt + m);
+	msg = (u32 __iomem *)(pHba->msg_addr_virt + m);
 	writel( THREE_WORD_MSG_SIZE | SGL_OFFSET_0,&msg[0]);
 	writel( I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | 0,&msg[1]);
 	writel( 0,&msg[2]);
@@ -2668,7 +2668,7 @@
 static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
 {
 	u8 *status;
-	u32 *msg = NULL;
+	u32 __iomem *msg = NULL;
 	int i;
 	ulong timeout = jiffies + TMOUT_INITOUTBOUND*HZ;
 	u32* ptr;
@@ -2690,7 +2690,7 @@
 		schedule_timeout(1);
 	} while(m == EMPTY_QUEUE);
 
-	msg=(u32 *)(pHba->msg_addr_virt+m);
+	msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
 
 	status = kmalloc(4,GFP_KERNEL|ADDR32);
 	if (status==NULL) {
@@ -2775,7 +2775,7 @@
 {
 	ulong timeout;
 	u32 m;
-	u32 *msg;
+	u32 __iomem *msg;
 	u8 *status_block=NULL;
 	ulong status_block_bus;
 
@@ -2809,7 +2809,7 @@
 	} while(m==EMPTY_QUEUE);
 
 	
-	msg=(u32*)(pHba->msg_addr_virt+m);
+	msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
 
 	writel(NINE_WORD_MSG_SIZE|SGL_OFFSET_0, &msg[0]);
 	writel(I2O_CMD_STATUS_GET<<24|HOST_TID<<12|ADAPTER_TID, &msg[1]);
diff -Nru a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
--- a/drivers/scsi/dpti.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/dpti.h	2004-12-24 13:36:16 -08:00
@@ -228,12 +228,12 @@
 	char name[32];
 	char detail[55];
 
-	ulong base_addr_virt;
-	ulong msg_addr_virt;
+	void __iomem *base_addr_virt;
+	void __iomem *msg_addr_virt;
 	ulong base_addr_phys;
-	ulong  post_port;
-	ulong  reply_port;
-	ulong  irq_mask;
+	void __iomem *post_port;
+	void __iomem *reply_port;
+	void __iomem *irq_mask;
 	u16  post_count;
 	u32  post_fifo_size;
 	u32  reply_fifo_size;
@@ -251,12 +251,12 @@
 	struct adpt_channel channel[MAX_CHANNEL];
 	struct proc_dir_entry* proc_entry;	/* /proc dir */
 
-	ulong FwDebugBuffer_P;	// Virtual Address Of FW Debug Buffer
+	void __iomem *FwDebugBuffer_P;	// Virtual Address Of FW Debug Buffer
 	u32   FwDebugBufferSize;	// FW Debug Buffer Size In Bytes
-	ulong FwDebugStrLength_P;	// Virtual Addr Of FW Debug String Len
-	ulong FwDebugFlags_P;	// Virtual Address Of FW Debug Flags 
-	ulong FwDebugBLEDflag_P;	// Virtual Addr Of FW Debug BLED
-	ulong FwDebugBLEDvalue_P;	// Virtual Addr Of FW Debug BLED
+	void __iomem *FwDebugStrLength_P;// Virtual Addr Of FW Debug String Len
+	void __iomem *FwDebugFlags_P;	// Virtual Address Of FW Debug Flags 
+	void __iomem *FwDebugBLEDflag_P;// Virtual Addr Of FW Debug BLED
+	void __iomem *FwDebugBLEDvalue_P;// Virtual Addr Of FW Debug BLED
 	u32 FwDebugFlags;
 } adpt_hba;
 
diff -Nru a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c
--- a/drivers/scsi/dtc.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/scsi/dtc.c	2004-12-24 13:37:03 -08:00
@@ -219,44 +219,58 @@
 {
 	static int current_override = 0, current_base = 0;
 	struct Scsi_Host *instance;
-	unsigned int base;
+	unsigned int addr;
+	void __iomem *base;
 	int sig, count;
 
 	tpnt->proc_name = "dtc3x80";
 	tpnt->proc_info = &dtc_proc_info;
 
 	for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
-		base = 0;
+		addr = 0;
+		base = NULL;
 
-		if (overrides[current_override].address)
-			base = overrides[current_override].address;
-		else
-			for (; !base && (current_base < NO_BASES); ++current_base) {
+		if (overrides[current_override].address) {
+			addr = overrides[current_override].address;
+			base = ioremap(addr, 0x2000);
+			if (!base)
+				addr = 0;
+		} else
+			for (; !addr && (current_base < NO_BASES); ++current_base) {
 #if (DTCDEBUG & DTCDEBUG_INIT)
 				printk("scsi-dtc : probing address %08x\n", bases[current_base].address);
 #endif
-				for (sig = 0; sig < NO_SIGNATURES; ++sig)
-					if (!bases[current_base].noauto && isa_check_signature(bases[current_base].address + signatures[sig].offset, signatures[sig].string, strlen(signatures[sig].string))) {
-						base = bases[current_base].address;
+				if (bases[current_base].noauto)
+					continue;
+				base = ioremap(bases[current_base].address, 0x2000);
+				if (!base)
+					continue;
+				for (sig = 0; sig < NO_SIGNATURES; ++sig) {
+					if (check_signature(base + signatures[sig].offset, signatures[sig].string, strlen(signatures[sig].string))) {
+						addr = bases[current_base].address;
 #if (DTCDEBUG & DTCDEBUG_INIT)
 						printk("scsi-dtc : detected board.\n");
 #endif
-						break;
+						goto found;
 					}
+				}
+				iounmap(base);
 			}
 
 #if defined(DTCDEBUG) && (DTCDEBUG & DTCDEBUG_INIT)
-		printk("scsi-dtc : base = %08x\n", base);
+		printk("scsi-dtc : base = %08x\n", addr);
 #endif
 
-		if (!base)
+		if (!addr)
 			break;
 
+found:
 		instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata));
 		if (instance == NULL)
 			break;
 
-		instance->base = base;
+		instance->base = addr;
+		((struct NCR5380_hostdata *)(instance)->hostdata)->base = base;
 
 		NCR5380_init(instance, 0);
 
@@ -372,7 +386,7 @@
 		while (NCR5380_read(DTC_CONTROL_REG) & CSR_HOST_BUF_NOT_RDY)
 			++i;
 		rtrc(3);
-		isa_memcpy_fromio(d, base + DTC_DATA_BUF, 128);
+		memcpy_fromio(d, base + DTC_DATA_BUF, 128);
 		d += 128;
 		len -= 128;
 		rtrc(7);
@@ -423,7 +437,7 @@
 		while (NCR5380_read(DTC_CONTROL_REG) & CSR_HOST_BUF_NOT_RDY)
 			++i;
 		rtrc(3);
-		isa_memcpy_toio(base + DTC_DATA_BUF, src, 128);
+		memcpy_toio(base + DTC_DATA_BUF, src, 128);
 		src += 128;
 		len -= 128;
 	}
@@ -449,12 +463,15 @@
 
 static int dtc_release(struct Scsi_Host *shost)
 {
+	NCR5380_local_declare();
+	NCR5380_setup(shost);
 	if (shost->irq)
 		free_irq(shost->irq, NULL);
 	NCR5380_exit(shost);
 	if (shost->io_port && shost->n_io_port)
 		release_region(shost->io_port, shost->n_io_port);
 	scsi_unregister(shost);
+	iounmap(base);
 	return 0;
 }
 
diff -Nru a/drivers/scsi/dtc.h b/drivers/scsi/dtc.h
--- a/drivers/scsi/dtc.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/dtc.h	2004-12-24 13:36:18 -08:00
@@ -46,40 +46,40 @@
 #endif
 
 #define NCR5380_implementation_fields \
-    unsigned int base
+    void __iomem *base
 
 #define NCR5380_local_declare() \
-    unsigned int base
+    void __iomem *base
 
 #define NCR5380_setup(instance) \
-    base = (unsigned int)(instance)->base
+    base = ((struct NCR5380_hostdata *)(instance)->hostdata)->base
 
 #define DTC_address(reg) (base + DTC_5380_OFFSET + reg)
 
 #define dbNCR5380_read(reg)                                              \
-    (rval=isa_readb(DTC_address(reg)), \
-     (((unsigned char) printk("DTC : read register %d at addr %08x is: %02x\n"\
-    , (reg), (int)DTC_address(reg), rval)), rval ) )
+    (rval=readb(DTC_address(reg)), \
+     (((unsigned char) printk("DTC : read register %d at addr %p is: %02x\n"\
+    , (reg), DTC_address(reg), rval)), rval ) )
 
 #define dbNCR5380_write(reg, value) do {                                  \
-    printk("DTC : write %02x to register %d at address %08x\n",         \
-            (value), (reg), (int)DTC_address(reg));     \
-    isa_writeb(value, DTC_address(reg));} while(0)
+    printk("DTC : write %02x to register %d at address %p\n",         \
+            (value), (reg), DTC_address(reg));     \
+    writeb(value, DTC_address(reg));} while(0)
 
 
 #if !(DTCDEBUG & DTCDEBUG_TRANSFER) 
-#define NCR5380_read(reg) (isa_readb(DTC_address(reg)))
-#define NCR5380_write(reg, value) (isa_writeb(value, DTC_address(reg)))
+#define NCR5380_read(reg) (readb(DTC_address(reg)))
+#define NCR5380_write(reg, value) (writeb(value, DTC_address(reg)))
 #else
-#define NCR5380_read(reg) (isa_readb(DTC_address(reg)))
+#define NCR5380_read(reg) (readb(DTC_address(reg)))
 #define xNCR5380_read(reg)						\
-    (((unsigned char) printk("DTC : read register %d at address %08x\n"\
-    , (reg), DTC_address(reg))), isa_readb(DTC_address(reg)))
+    (((unsigned char) printk("DTC : read register %d at address %p\n"\
+    , (reg), DTC_address(reg))), readb(DTC_address(reg)))
 
 #define NCR5380_write(reg, value) do {					\
-    printk("DTC : write %02x to register %d at address %08x\n", 	\
-	    (value), (reg), (int)DTC_address(reg));	\
-    isa_writeb(value, DTC_address(reg));} while(0)
+    printk("DTC : write %02x to register %d at address %p\n", 	\
+	    (value), (reg), DTC_address(reg));	\
+    writeb(value, DTC_address(reg));} while(0)
 #endif
 
 #define NCR5380_intr			dtc_intr
diff -Nru a/drivers/scsi/eata.c b/drivers/scsi/eata.c
--- a/drivers/scsi/eata.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/eata.c	2004-12-24 13:37:19 -08:00
@@ -474,7 +474,7 @@
  *  The boards are named EATA0, EATA1,... according to the detection order.
  *
  *  In order to support multiple ISA boards in a reliable way,
- *  the driver sets host->wish_block = TRUE for all ISA boards.
+ *  the driver sets host->wish_block = 1 for all ISA boards.
  */
 
 #include <linux/config.h>
@@ -482,9 +482,6 @@
 #include <linux/kernel.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
-#include <asm/io.h>
-#include <asm/system.h>
-#include <asm/byteorder.h>
 #include <linux/proc_fs.h>
 #include <linux/blkdev.h>
 #include <linux/interrupt.h>
@@ -493,22 +490,29 @@
 #include <linux/init.h>
 #include <linux/ctype.h>
 #include <linux/spinlock.h>
-#include <scsi/scsicam.h>
-#include "scsi.h"
-#include <scsi/scsi_host.h>
+#include <asm/byteorder.h>
 #include <asm/dma.h>
+#include <asm/io.h>
 #include <asm/irq.h>
 
-static int eata2x_detect(Scsi_Host_Template *);
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/scsicam.h>
+
+static int eata2x_detect(struct scsi_host_template *);
 static int eata2x_release(struct Scsi_Host *);
-static int eata2x_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
-static int eata2x_eh_abort(Scsi_Cmnd *);
-static int eata2x_eh_host_reset(Scsi_Cmnd *);
+static int eata2x_queuecommand(struct scsi_cmnd *,
+		void (*done)(struct scsi_cmnd *));
+static int eata2x_eh_abort(struct scsi_cmnd *);
+static int eata2x_eh_host_reset(struct scsi_cmnd *);
 static int eata2x_bios_param(struct scsi_device *, struct block_device *,
                              sector_t, int *);
-static int eata2x_slave_configure(Scsi_Device *);
+static int eata2x_slave_configure(struct scsi_device *);
 
-static Scsi_Host_Template driver_template = {
+static struct scsi_host_template driver_template = {
                 .name                    = "EATA/DMA 2.0x rev. 8.10.00 ",
                 .detect                  = eata2x_detect,
                 .release                 = eata2x_release,
@@ -558,8 +562,6 @@
 #define MAX_TAGGED_CMD_PER_LUN (MAX_MAILBOXES - MAX_CMD_PER_LUN)
 
 #define SKIP ULONG_MAX
-#define FALSE 0
-#define TRUE 1
 #define FREE 0
 #define IN_USE   1
 #define LOCKED   2
@@ -766,7 +768,7 @@
    u_int32_t sense_addr; /* Address where Sense Data is DMA'ed on error */
 
    /* Additional fields begin here. */
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    /* All the cp structure is zero filled by queuecommand except the
       following CP_TAIL_SIZE bytes, initialized by detect */
@@ -785,12 +787,12 @@
    char board_name[16];                 /* Name of this board */
    int in_reset;                        /* True if board is doing a reset */
    int target_to[MAX_TARGET][MAX_CHANNEL]; /* N. of timeout errors on target */
-   int target_redo[MAX_TARGET][MAX_CHANNEL]; /* If TRUE redo i/o on target */
+   int target_redo[MAX_TARGET][MAX_CHANNEL]; /* If 1 redo i/o on target */
    unsigned int retries;                /* Number of internal retries */
    unsigned long last_retried_pid;      /* Pid of last retried command */
    unsigned char subversion;            /* Bus type, either ISA or EISA/PCI */
    unsigned char protocol_rev;          /* EATA 2.0 rev., 'A' or 'B' or 'C' */
-   unsigned char is_pci;                /* TRUE is bus type is PCI */
+   unsigned char is_pci;                /* 1 is bus type is PCI */
    struct pci_dev *pdev;                /* pdev for PCI bus, NULL otherwise */
    struct mssp *sp_cpu_addr;            /* cpu addr for DMA buffer sp */
    dma_addr_t sp_dma_addr;              /* dma handle for DMA buffer sp */
@@ -842,12 +844,12 @@
 #define REG2H(x)   le16_to_cpu(x)
 
 static irqreturn_t do_interrupt_handler(int, void *, struct pt_regs *);
-static void flush_dev(Scsi_Device *, unsigned long, unsigned int, unsigned int);
-static int do_trace = FALSE;
-static int setup_done = FALSE;
+static void flush_dev(struct scsi_device *, unsigned long, unsigned int, unsigned int);
+static int do_trace = 0;
+static int setup_done = 0;
 static int link_statistics;
-static int ext_tran = FALSE;
-static int rev_scan = TRUE;
+static int ext_tran = 0;
+static int rev_scan = 1;
 
 #if defined(CONFIG_SCSI_EATA_TAGGED_QUEUE)
 static int tag_mode = TAG_SIMPLE;
@@ -856,9 +858,9 @@
 #endif
 
 #if defined(CONFIG_SCSI_EATA_LINKED_COMMANDS)
-static int linked_comm = TRUE;
+static int linked_comm = 1;
 #else
-static int linked_comm = FALSE;
+static int linked_comm = 0;
 #endif
 
 #if defined(CONFIG_SCSI_EATA_MAX_TAGS)
@@ -868,21 +870,21 @@
 #endif
 
 #if defined(CONFIG_ISA)
-static int isa_probe = TRUE;
+static int isa_probe = 1;
 #else
-static int isa_probe = FALSE;
+static int isa_probe = 0;
 #endif
 
 #if defined(CONFIG_EISA)
-static int eisa_probe = TRUE;
+static int eisa_probe = 1;
 #else
-static int eisa_probe = FALSE;
+static int eisa_probe = 0;
 #endif
 
 #if defined(CONFIG_PCI)
-static int pci_probe = TRUE;
+static int pci_probe = 1;
 #else
-static int pci_probe = FALSE;
+static int pci_probe = 0;
 #endif
 
 #define MAX_INT_PARAM 10
@@ -902,7 +904,7 @@
 
 #endif
 
-static int eata2x_slave_configure(Scsi_Device *dev) {
+static int eata2x_slave_configure(struct scsi_device *dev) {
    int j, tqd, utqd;
    char *tag_suffix, *link_suffix;
    struct Scsi_Host *host = dev->host;
@@ -948,24 +950,24 @@
           BN(j), host->host_no, dev->channel, dev->id, dev->lun,
           dev->queue_depth, link_suffix, tag_suffix);
 
-   return FALSE;
+   return 0;
 }
 
 static int wait_on_busy(unsigned long iobase, unsigned int loop) {
 
    while (inb(iobase + REG_AUX_STATUS) & ABSY_ASSERTED) {
       udelay(1L);
-      if (--loop == 0) return TRUE;
+      if (--loop == 0) return 1;
       }
 
-   return FALSE;
+   return 0;
 }
 
 static int do_dma(unsigned long iobase, unsigned long addr, unchar cmd) {
    unsigned char *byaddr;
    unsigned long devaddr;
 
-   if (wait_on_busy(iobase, (addr ? MAXLOOP * 100 : MAXLOOP))) return TRUE;
+   if (wait_on_busy(iobase, (addr ? MAXLOOP * 100 : MAXLOOP))) return 1;
 
    if (addr) {
       devaddr = H2DEV(addr);
@@ -977,7 +979,7 @@
       }
 
    outb(cmd, iobase + REG_CMD);
-   return FALSE;
+   return 0;
 }
 
 static int read_pio(unsigned long iobase, ushort *start, ushort *end) {
@@ -988,14 +990,14 @@
 
       while (!(inb(iobase + REG_STATUS) & DRQ_ASSERTED)) {
          udelay(1L);
-         if (--loop == 0) return TRUE;
+         if (--loop == 0) return 1;
          }
 
       loop = MAXLOOP;
       *p = REG2H(inw(iobase));
       }
 
-   return FALSE;
+   return 0;
 }
 
 static struct pci_dev *get_pci_dev(unsigned long port_base) {
@@ -1005,7 +1007,7 @@
    unsigned int addr;
    struct pci_dev *dev = NULL;
 
-   while((dev = pci_find_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) {
+   while((dev = pci_get_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) {
       addr = pci_resource_start (dev, 0);
 
 #if defined(DEBUG_PCI_DETECT)
@@ -1013,6 +1015,11 @@
              driver_name, dev->bus->number, dev->devfn, addr);
 #endif
 
+      /* we are in so much trouble for a pci hotplug system with this driver
+       * anyway, so doing this at least lets people unload the driver and not
+       * cause memory problems, but in general this is a bad thing to do (this
+       * driver needs to be converted to the proper PCI api someday... */
+      pci_dev_put(dev);
       if (addr + PCI_BASE_ADDRESS_0 == port_base) return dev;
       }
 
@@ -1027,7 +1034,7 @@
 
    struct pci_dev *dev = NULL;
 
-   while((dev = pci_find_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) {
+   while((dev = pci_get_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) {
 
 #if defined(DEBUG_PCI_DETECT)
       printk("%s: enable_pci_ports, bus %d, devfn 0x%x.\n",
@@ -1043,8 +1050,8 @@
 }
 
 static int port_detect \
-      (unsigned long port_base, unsigned int j, Scsi_Host_Template *tpnt) {
-   unsigned char irq, dma_channel, subversion, i, is_pci = FALSE;
+      (unsigned long port_base, unsigned int j, struct scsi_host_template *tpnt) {
+   unsigned char irq, dma_channel, subversion, i, is_pci = 0;
    unsigned char protocol_rev;
    struct eata_info info;
    char *bus_type, dma_name[16];
@@ -1112,12 +1119,12 @@
    if (protocol_rev != 'A' && info.forcaddr) {
       printk("%s: warning, port address has been forced.\n", name);
       bus_type = "PCI";
-      is_pci = TRUE;
+      is_pci = 1;
       subversion = ESA;
       }
    else if (port_base > MAX_EISA_ADDR || (protocol_rev == 'C' && info.pci)) {
       bus_type = "PCI";
-      is_pci = TRUE;
+      is_pci = 1;
       subversion = ESA;
       }
    else if (port_base >= MIN_EISA_ADDR || (protocol_rev == 'C' && info.eisa)) {
@@ -1130,7 +1137,7 @@
       }
    else if (port_base > MAX_ISA_ADDR) {
       bus_type = "PCI";
-      is_pci = TRUE;
+      is_pci = 1;
       subversion = ESA;
       }
    else {
@@ -1212,7 +1219,7 @@
    /* Set board configuration */
    memset((char *)cf, 0, sizeof(struct eata_config));
    cf->len = (ushort) H2DEV16((ushort)510);
-   cf->ocena = TRUE;
+   cf->ocena = 1;
 
    if (do_dma(port_base, cf_dma_addr, SET_CONFIG_DMA)) {
       printk("%s: busy timeout sending configuration, detaching.\n", name);
@@ -1249,10 +1256,10 @@
    HD(j)->board_number = j;
 
    if (HD(j)->subversion == ESA)
-      sh[j]->unchecked_isa_dma = FALSE;
+      sh[j]->unchecked_isa_dma = 0;
    else {
       unsigned long flags;
-      sh[j]->unchecked_isa_dma = TRUE;
+      sh[j]->unchecked_isa_dma = 1;
 
       flags=claim_dma_lock();
       disable_dma(dma_channel);
@@ -1373,7 +1380,7 @@
          printk("%s: warning, pci_set_dma_mask failed.\n", BN(j));
       }
 
-   return TRUE;
+   return 1;
 
 freedma:
    if (subversion == ISA) free_dma(dma_channel);
@@ -1383,11 +1390,11 @@
    spin_unlock_irq(&driver_lock);
    release_region(port_base, REGION_SIZE);
 fail:
-   return FALSE;
+   return 0;
 
 release:
    eata2x_release(sh[j]);
-   return FALSE;
+   return 0;
 }
 
 static void internal_setup(char *str, int *ints) {
@@ -1401,14 +1408,14 @@
       for (i = 0; i < argc; i++) io_port[i] = ints[i + 1];
 
       io_port[i] = 0;
-      setup_done = TRUE;
+      setup_done = 1;
       }
 
    while (cur && (pc = strchr(cur, ':'))) {
       int val = 0, c = *++pc;
 
-      if (c == 'n' || c == 'N') val = FALSE;
-      else if (c == 'y' || c == 'Y') val = TRUE;
+      if (c == 'n' || c == 'N') val = 0;
+      else if (c == 'y' || c == 'Y') val = 1;
       else val = (int) simple_strtoul(pc, NULL, 0);
 
       if (!strncmp(cur, "lc:", 3)) linked_comm = val;
@@ -1454,7 +1461,7 @@
 
    for (k = 0; k < MAX_PCI; k++) {
 
-      if (!(dev = pci_find_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) break;
+      if (!(dev = pci_get_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) break;
 
       if (pci_enable_device (dev)) {
 
@@ -1478,12 +1485,13 @@
              addr + PCI_BASE_ADDRESS_0;
       }
 
+   pci_dev_put(dev);
 #endif /* end CONFIG_PCI */
 
    return;
 }
 
-static int eata2x_detect(Scsi_Host_Template *tpnt) {
+static int eata2x_detect(struct scsi_host_template *tpnt) {
    unsigned int j = 0, k;
 
    tpnt->proc_name = "eata2x";
@@ -1493,7 +1501,7 @@
 #if defined(MODULE)
    /* io_port could have been modified when loading as a module */
    if(io_port[0] != SKIP) {
-      setup_done = TRUE;
+      setup_done = 1;
       io_port[MAX_INT_PARAM] = 0;
       }
 #endif
@@ -1529,10 +1537,10 @@
    unsigned int k, count, pci_dir;
    struct scatterlist *sgpnt;
    struct mscp *cpp;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
-   pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction);
+   pci_dir = SCpnt->sc_data_direction;
 
    if (SCpnt->sense_buffer)
       cpp->sense_addr = H2DEV(pci_map_single(HD(j)->pdev, SCpnt->sense_buffer,
@@ -1561,7 +1569,7 @@
       cpp->sglist[k].num_bytes = H2DEV(sg_dma_len(&sgpnt[k]));
       }
 
-   cpp->sg = TRUE;
+   cpp->sg = 1;
    cpp->data_address = H2DEV(pci_map_single(HD(j)->pdev, cpp->sglist,
                              SCpnt->use_sg * sizeof(struct sg_list), pci_dir));
    cpp->data_len = H2DEV((SCpnt->use_sg * sizeof(struct sg_list)));
@@ -1570,10 +1578,10 @@
 static void unmap_dma(unsigned int i, unsigned int j) {
    unsigned int pci_dir;
    struct mscp *cpp;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
-   pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction);
+   pci_dir = SCpnt->sc_data_direction;
 
    if (DEV2H(cpp->sense_addr))
       pci_unmap_single(HD(j)->pdev, DEV2H(cpp->sense_addr),
@@ -1592,10 +1600,10 @@
 static void sync_dma(unsigned int i, unsigned int j) {
    unsigned int pci_dir;
    struct mscp *cpp;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
-   pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction);
+   pci_dir = SCpnt->sc_data_direction;
 
    if (DEV2H(cpp->sense_addr))
       pci_dma_sync_single_for_cpu(HD(j)->pdev, DEV2H(cpp->sense_addr),
@@ -1628,45 +1636,45 @@
       };
 
    struct mscp *cpp;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
 
-   if (SCpnt->sc_data_direction == SCSI_DATA_READ) {
-      cpp->din  = TRUE;
-      cpp->dout = FALSE;
+   if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
+      cpp->din  = 1;
+      cpp->dout = 0;
       return;
       }
-   else if (SCpnt->sc_data_direction == SCSI_DATA_WRITE) {
-      cpp->din  = FALSE;
-      cpp->dout = TRUE;
+   else if (SCpnt->sc_data_direction == DMA_TO_DEVICE) {
+      cpp->din  = 0;
+      cpp->dout = 1;
       return;
       }
-   else if (SCpnt->sc_data_direction == SCSI_DATA_NONE) {
-      cpp->din  = FALSE;
-      cpp->dout = FALSE;
+   else if (SCpnt->sc_data_direction == DMA_NONE) {
+      cpp->din  = 0;
+      cpp->dout = 0;
       return;
       }
 
-   if (SCpnt->sc_data_direction != SCSI_DATA_UNKNOWN)
+   if (SCpnt->sc_data_direction != DMA_BIDIRECTIONAL)
       panic("%s: qcomm, invalid SCpnt->sc_data_direction.\n", BN(j));
 
    for (k = 0; k < ARRAY_SIZE(data_out_cmds); k++)
       if (SCpnt->cmnd[0] == data_out_cmds[k]) {
-         cpp->dout = TRUE;
+         cpp->dout = 1;
          break;
          }
 
    if ((cpp->din = !cpp->dout))
       for (k = 0; k < ARRAY_SIZE(data_none_cmds); k++)
          if (SCpnt->cmnd[0] == data_none_cmds[k]) {
-            cpp->din = FALSE;
+            cpp->din = 0;
             break;
             }
 
 }
 
-static int eata2x_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) {
+static int eata2x_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) {
    unsigned int i, j, k;
    struct mscp *cpp;
 
@@ -1712,12 +1720,12 @@
                         BN(j), i, SCpnt->device->channel, SCpnt->device->id,
                         SCpnt->device->lun, SCpnt->pid);
 
-   cpp->reqsen = TRUE;
-   cpp->dispri = TRUE;
+   cpp->reqsen = 1;
+   cpp->dispri = 1;
 #if 0
-   if (SCpnt->device->type == TYPE_TAPE) cpp->hbaci = TRUE;
+   if (SCpnt->device->type == TYPE_TAPE) cpp->hbaci = 1;
 #endif
-   cpp->one = TRUE;
+   cpp->one = 1;
    cpp->channel = SCpnt->device->channel;
    cpp->target = SCpnt->device->id;
    cpp->lun = SCpnt->device->lun;
@@ -1733,7 +1741,7 @@
    if (linked_comm && SCpnt->device->queue_depth > 2
                                      && TLDEV(SCpnt->device->type)) {
       HD(j)->cp_stat[i] = READY;
-      flush_dev(SCpnt->device, SCpnt->request->sector, j, FALSE);
+      flush_dev(SCpnt->device, SCpnt->request->sector, j, 0);
       return 0;
       }
 
@@ -1750,7 +1758,7 @@
    return 0;
 }
 
-static int eata2x_eh_abort(Scsi_Cmnd *SCarg) {
+static int eata2x_eh_abort(struct scsi_cmnd *SCarg) {
    unsigned int i, j;
 
    j = ((struct hostdata *) SCarg->device->host->hostdata)->board_number;
@@ -1824,10 +1832,10 @@
    panic("%s: abort, mbox %d, invalid cp_stat.\n", BN(j), i);
 }
 
-static int eata2x_eh_host_reset(Scsi_Cmnd *SCarg) {
+static int eata2x_eh_host_reset(struct scsi_cmnd *SCarg) {
    unsigned int i, j, time, k, c, limit = 0;
-   int arg_done = FALSE;
-   Scsi_Cmnd *SCpnt;
+   int arg_done = 0;
+   struct scsi_cmnd *SCpnt;
 
    j = ((struct hostdata *) SCarg->device->host->hostdata)->board_number;
    printk("%s: reset, enter, target %d.%d:%d, pid %ld.\n",
@@ -1850,7 +1858,7 @@
 
    for (c = 0; c <= sh[j]->max_channel; c++)
       for (k = 0; k < sh[j]->max_id; k++) {
-         HD(j)->target_redo[k][c] = TRUE;
+         HD(j)->target_redo[k][c] = 1;
          HD(j)->target_to[k][c] = 0;
          }
 
@@ -1888,7 +1896,7 @@
       if (SCpnt->scsi_done == NULL)
          panic("%s: reset, mbox %d, SCpnt->scsi_done == NULL.\n", BN(j), i);
 
-      if (SCpnt == SCarg) arg_done = TRUE;
+      if (SCpnt == SCarg) arg_done = 1;
       }
 
    if (do_dma(sh[j]->io_port, 0, RESET_PIO)) {
@@ -1899,10 +1907,10 @@
    printk("%s: reset, board reset done, enabling interrupts.\n", BN(j));
 
 #if defined(DEBUG_RESET)
-   do_trace = TRUE;
+   do_trace = 1;
 #endif
 
-   HD(j)->in_reset = TRUE;
+   HD(j)->in_reset = 1;
 
    spin_unlock_irq(sh[j]->host_lock);
    time = jiffies;
@@ -1947,8 +1955,8 @@
       SCpnt->scsi_done(SCpnt);
       }
 
-   HD(j)->in_reset = FALSE;
-   do_trace = FALSE;
+   HD(j)->in_reset = 0;
+   do_trace = 0;
 
    if (arg_done) printk("%s: reset, exit, pid %ld done.\n", BN(j), SCarg->pid);
    else          printk("%s: reset, exit.\n", BN(j));
@@ -1971,7 +1979,7 @@
            dkinfo[0], dkinfo[1], dkinfo[2]);
 #endif
 
-   return FALSE;
+   return 0;
 }
 
 static void sort(unsigned long sk[], unsigned int da[], unsigned int n,
@@ -2001,11 +2009,11 @@
 
 static int reorder(unsigned int j, unsigned long cursec,
                  unsigned int ihdlr, unsigned int il[], unsigned int n_ready) {
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
    struct mscp *cpp;
    unsigned int k, n;
-   unsigned int rev = FALSE, s = TRUE, r = TRUE;
-   unsigned int input_only = TRUE, overlap = FALSE;
+   unsigned int rev = 0, s = 1, r = 1;
+   unsigned int input_only = 1, overlap = 0;
    unsigned long sl[n_ready], pl[n_ready], ll[n_ready];
    unsigned long maxsec = 0, minsec = ULONG_MAX, seek = 0, iseek = 0;
    unsigned long ioseek = 0;
@@ -2022,12 +2030,12 @@
              seeknosort / (readycount + 1),
              seeksorted / (readycount + 1));
 
-   if (n_ready <= 1) return FALSE;
+   if (n_ready <= 1) return 0;
 
    for (n = 0; n < n_ready; n++) {
       k = il[n]; cpp = &HD(j)->cp[k]; SCpnt = cpp->SCpnt;
 
-      if (!cpp->din) input_only = FALSE;
+      if (!cpp->din) input_only = 0;
 
       if (SCpnt->request->sector < minsec) minsec = SCpnt->request->sector;
       if (SCpnt->request->sector > maxsec) maxsec = SCpnt->request->sector;
@@ -2037,8 +2045,8 @@
 
       if (!n) continue;
 
-      if (sl[n] < sl[n - 1]) s = FALSE;
-      if (sl[n] > sl[n - 1]) r = FALSE;
+      if (sl[n] < sl[n - 1]) s = 0;
+      if (sl[n] > sl[n - 1]) r = 0;
 
       if (link_statistics) {
          if (sl[n] > sl[n - 1])
@@ -2053,9 +2061,9 @@
       if (cursec > sl[0]) seek += cursec - sl[0]; else seek += sl[0] - cursec;
       }
 
-   if (cursec > ((maxsec + minsec) / 2)) rev = TRUE;
+   if (cursec > ((maxsec + minsec) / 2)) rev = 1;
 
-   if (ioseek > ((maxsec - minsec) / 2)) rev = FALSE;
+   if (ioseek > ((maxsec - minsec) / 2)) rev = 0;
 
    if (!((rev && r) || (!rev && s))) sort(sl, il, n_ready, rev);
 
@@ -2066,10 +2074,10 @@
       if (!n) continue;
 
       if ((sl[n] == sl[n - 1]) || (!rev && ((sl[n - 1] + ll[n - 1]) > sl[n]))
-          || (rev && ((sl[n] + ll[n]) > sl[n - 1]))) overlap = TRUE;
+          || (rev && ((sl[n] + ll[n]) > sl[n - 1]))) overlap = 1;
       }
 
-   if (overlap) sort(pl, il, n_ready, FALSE);
+   if (overlap) sort(pl, il, n_ready, 0);
 
    if (link_statistics) {
       if (cursec > sl[0]) iseek = cursec - sl[0]; else iseek = sl[0] - cursec;
@@ -2097,9 +2105,9 @@
    return overlap;
 }
 
-static void flush_dev(Scsi_Device *dev, unsigned long cursec, unsigned int j,
+static void flush_dev(struct scsi_device *dev, unsigned long cursec, unsigned int j,
                       unsigned int ihdlr) {
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
    struct mscp *cpp;
    unsigned int k, n, n_ready = 0, il[MAX_MAILBOXES];
 
@@ -2135,7 +2143,7 @@
 }
 
 static irqreturn_t ihdlr(int irq, unsigned int j) {
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
    unsigned int i, k, c, status, tstatus, reg;
    struct mssp *spp;
    struct mscp *cpp;
@@ -2184,13 +2192,13 @@
 #endif
 
    /* Reject any sp with supspect data */
-   if (spp->eoc == FALSE && HD(j)->iocount > 1)
-      printk("%s: ihdlr, spp->eoc == FALSE, irq %d, reg 0x%x, count %d.\n",
+   if (spp->eoc == 0 && HD(j)->iocount > 1)
+      printk("%s: ihdlr, spp->eoc == 0, irq %d, reg 0x%x, count %d.\n",
              BN(j), irq, reg, HD(j)->iocount);
    if (spp->cpp_index < 0 || spp->cpp_index >= sh[j]->can_queue)
       printk("%s: ihdlr, bad spp->cpp_index %d, irq %d, reg 0x%x, count %d.\n",
              BN(j), spp->cpp_index, irq, reg, HD(j)->iocount);
-   if (spp->eoc == FALSE || spp->cpp_index < 0
+   if (spp->eoc == 0 || spp->cpp_index < 0
                          || spp->cpp_index >= sh[j]->can_queue) goto handled;
 
    /* Find the mailbox to be serviced on this board */
@@ -2240,7 +2248,7 @@
 
    if (linked_comm && SCpnt->device->queue_depth > 2
                                      && TLDEV(SCpnt->device->type))
-      flush_dev(SCpnt->device, SCpnt->request->sector, j, TRUE);
+      flush_dev(SCpnt->device, SCpnt->request->sector, j, 1);
 
    tstatus = status_byte(spp->target_status);
 
@@ -2271,7 +2279,7 @@
             status = DID_OK << 16;
 
          if (tstatus == GOOD)
-            HD(j)->target_redo[SCpnt->device->id][SCpnt->device->channel] = FALSE;
+            HD(j)->target_redo[SCpnt->device->id][SCpnt->device->channel] = 0;
 
          if (spp->target_status && SCpnt->device->type == TYPE_DISK &&
              (!(tstatus == CHECK_CONDITION && HD(j)->iocount <= 1000 &&
@@ -2305,7 +2313,7 @@
 
          for (c = 0; c <= sh[j]->max_channel; c++)
             for (k = 0; k < sh[j]->max_id; k++)
-               HD(j)->target_redo[k][c] = TRUE;
+               HD(j)->target_redo[k][c] = 1;
 
          if (SCpnt->device->type != TYPE_TAPE
              && HD(j)->retries < MAX_INTERNAL_RETRIES) {
@@ -2408,7 +2416,7 @@
 
    release_region(sh[j]->io_port, sh[j]->n_io_port);
    scsi_unregister(sh[j]);
-   return FALSE;
+   return 0;
 }
 
 #include "scsi_module.c"
diff -Nru a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
--- a/drivers/scsi/fdomain.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/scsi/fdomain.c	2004-12-24 13:37:02 -08:00
@@ -384,6 +384,7 @@
 /* .bss will zero all the static variables below */
 static int               port_base;
 static unsigned long     bios_base;
+static void __iomem *    bios_mem;
 static int               bios_major;
 static int               bios_minor;
 static int               PCI_bus;
@@ -400,20 +401,6 @@
 static volatile int      in_interrupt_flag;
 #endif
 
-static int               SCSI_Mode_Cntl_port;
-static int               FIFO_Data_Count_port;
-static int               Interrupt_Cntl_port;
-static int               Interrupt_Status_port;
-static int               Read_FIFO_port;
-static int               Read_SCSI_Data_port;
-static int               SCSI_Cntl_port;
-static int               SCSI_Data_NoACK_port;
-static int               SCSI_Status_port;
-static int               TMC_Cntl_port;
-static int               TMC_Status_port;
-static int               Write_FIFO_port;
-static int               Write_SCSI_Data_port;
-
 static int               FIFO_Size = 0x2000; /* 8k FIFO for
 						pre-tmc18c30 chips */
 
@@ -472,7 +459,7 @@
 
 */
 
-struct signature {
+static struct signature {
    const char *signature;
    int  sig_offset;
    int  sig_length;
@@ -585,12 +572,12 @@
 
 inline static void fdomain_make_bus_idle( void )
 {
-   outb( 0, SCSI_Cntl_port );
-   outb( 0, SCSI_Mode_Cntl_port );
+   outb(0, port_base + SCSI_Cntl);
+   outb(0, port_base + SCSI_Mode_Cntl);
    if (chip == tmc18c50 || chip == tmc18c30)
-	 outb( 0x21 | PARITY_MASK, TMC_Cntl_port ); /* Clear forced intr. */
+	 outb(0x21 | PARITY_MASK, port_base + TMC_Cntl); /* Clear forced intr. */
    else
-	 outb( 0x01 | PARITY_MASK, TMC_Cntl_port );
+	 outb(0x01 | PARITY_MASK, port_base + TMC_Cntl);
 }
 
 static int fdomain_is_valid_port( int port )
@@ -690,12 +677,15 @@
    printk( "scsi: <fdomain> fdomain_isa_detect:" );
 #endif
 
-   for (i = 0; !bios_base && i < ADDRESS_COUNT; i++) {
+   for (i = 0; i < ADDRESS_COUNT; i++) {
+      void __iomem *p = ioremap(addresses[i], 0x2000);
+      if (!p)
+	continue;
 #if DEBUG_DETECT
       printk( " %lx(%lx),", addresses[i], bios_base );
 #endif
-      for (j = 0; !bios_base && j < SIGNATURE_COUNT; j++) {
-	 if (isa_check_signature(addresses[i] + signatures[j].sig_offset,
+      for (j = 0; j < SIGNATURE_COUNT; j++) {
+	 if (check_signature(p + signatures[j].sig_offset,
 			     signatures[j].signature,
 			     signatures[j].sig_length )) {
 	    bios_major = signatures[j].major_bios_version;
@@ -703,10 +693,14 @@
 	    PCI_bus    = (signatures[j].flag == 1);
 	    Quantum    = (signatures[j].flag > 1) ? signatures[j].flag : 0;
 	    bios_base  = addresses[i];
+	    bios_mem   = p;
+	    goto found;
 	 }
       }
+      iounmap(p);
    }
-   
+ 
+found:
    if (bios_major == 2) {
       /* The TMC-1660/TMC-1680 has a RAM area just after the BIOS ROM.
 	 Assuming the ROM is enabled (otherwise we wouldn't have been
@@ -719,13 +713,13 @@
       switch (Quantum) {
       case 2:			/* ISA_200S */
       case 3:			/* ISA_250MG */
-	 base = isa_readb(bios_base + 0x1fa2) + (isa_readb(bios_base + 0x1fa3) << 8);
+	 base = readb(bios_mem + 0x1fa2) + (readb(bios_mem + 0x1fa3) << 8);
 	 break;
       case 4:			/* ISA_200S (another one) */
-	 base = isa_readb(bios_base + 0x1fa3) + (isa_readb(bios_base + 0x1fa4) << 8);
+	 base = readb(bios_mem + 0x1fa3) + (readb(bios_mem + 0x1fa4) << 8);
 	 break;
       default:
-	 base = isa_readb(bios_base + 0x1fcc) + (isa_readb(bios_base + 0x1fcd) << 8);
+	 base = readb(bios_mem + 0x1fcc) + (readb(bios_mem + 0x1fcd) << 8);
 	 break;
       }
    
@@ -910,20 +904,6 @@
       }
    }
 
-   SCSI_Mode_Cntl_port   = port_base + SCSI_Mode_Cntl;
-   FIFO_Data_Count_port  = port_base + FIFO_Data_Count;
-   Interrupt_Cntl_port   = port_base + Interrupt_Cntl;
-   Interrupt_Status_port = port_base + Interrupt_Status;
-   Read_FIFO_port        = port_base + Read_FIFO;
-   Read_SCSI_Data_port   = port_base + Read_SCSI_Data;
-   SCSI_Cntl_port        = port_base + SCSI_Cntl;
-   SCSI_Data_NoACK_port  = port_base + SCSI_Data_NoACK;
-   SCSI_Status_port      = port_base + SCSI_Status;
-   TMC_Cntl_port         = port_base + TMC_Cntl;
-   TMC_Status_port       = port_base + TMC_Status;
-   Write_FIFO_port       = port_base + Write_FIFO;
-   Write_SCSI_Data_port  = port_base + Write_SCSI_Data;
-
    fdomain_16x0_bus_reset(NULL);
 
    if (fdomain_test_loopback()) {
@@ -1032,13 +1012,13 @@
    printk( "fdomain_arbitrate()\n" );
 #endif
    
-   outb( 0x00, SCSI_Cntl_port );              /* Disable data drivers */
-   outb( adapter_mask, port_base + SCSI_Data_NoACK ); /* Set our id bit */
-   outb( 0x04 | PARITY_MASK, TMC_Cntl_port ); /* Start arbitration */
+   outb(0x00, port_base + SCSI_Cntl);              /* Disable data drivers */
+   outb(adapter_mask, port_base + SCSI_Data_NoACK); /* Set our id bit */
+   outb(0x04 | PARITY_MASK, port_base + TMC_Cntl); /* Start arbitration */
 
    timeout = 500;
    do {
-      status = inb( TMC_Status_port );        /* Read adapter status */
+      status = inb(port_base + TMC_Status);        /* Read adapter status */
       if (status & 0x02)		      /* Arbitration complete */
 	    return 0;
       mdelay(1);			/* Wait one millisecond */
@@ -1065,19 +1045,19 @@
    static int    flag = 0;
 #endif
 
-   outb( 0x82, SCSI_Cntl_port ); /* Bus Enable + Select */
-   outb( adapter_mask | (1 << target), SCSI_Data_NoACK_port );
+   outb(0x82, port_base + SCSI_Cntl); /* Bus Enable + Select */
+   outb(adapter_mask | (1 << target), port_base + SCSI_Data_NoACK);
 
    /* Stop arbitration and enable parity */
-   outb( PARITY_MASK, TMC_Cntl_port ); 
+   outb(PARITY_MASK, port_base + TMC_Cntl); 
 
    timeout = 350;			/* 350 msec */
 
    do {
-      status = inb( SCSI_Status_port ); /* Read adapter status */
+      status = inb(port_base + SCSI_Status); /* Read adapter status */
       if (status & 1) {			/* Busy asserted */
 	 /* Enable SCSI Bus (on error, should make bus idle with 0) */
-	 outb( 0x80, SCSI_Cntl_port );
+	 outb(0x80, port_base + SCSI_Cntl);
 	 return 0;
       }
       mdelay(1);			/* wait one msec */
@@ -1102,7 +1082,7 @@
 {
    if (in_command) {
       in_command = 0;
-      outb( 0x00, Interrupt_Cntl_port );
+      outb(0x00, port_base + Interrupt_Cntl);
       fdomain_make_bus_idle();
       current_SC->result = error;
       if (current_SC->scsi_done)
@@ -1131,11 +1111,11 @@
 				   running. */
 
    /* Check for other IRQ sources */
-   if((inb(TMC_Status_port)&0x01)==0)   
+   if ((inb(port_base + TMC_Status) & 0x01) == 0)
    	return IRQ_NONE;
 
    /* It is our IRQ */   	
-   outb( 0x00, Interrupt_Cntl_port );
+   outb(0x00, port_base + Interrupt_Cntl);
 
    /* We usually have one spurious interrupt after each command.  Ignore it. */
    if (!in_command || !current_SC) {	/* Spurious interrupt */
@@ -1160,7 +1140,7 @@
 #endif
 
    if (current_SC->SCp.phase & in_arbitration) {
-      status = inb( TMC_Status_port );        /* Read adapter status */
+      status = inb(port_base + TMC_Status);        /* Read adapter status */
       if (!(status & 0x02)) {
 #if EVERY_ACCESS
 	 printk( " AFAIL " );
@@ -1172,19 +1152,19 @@
       }
       current_SC->SCp.phase = in_selection;
       
-      outb( 0x40 | FIFO_COUNT, Interrupt_Cntl_port );
+      outb(0x40 | FIFO_COUNT, port_base + Interrupt_Cntl);
 
-      outb( 0x82, SCSI_Cntl_port ); /* Bus Enable + Select */
-      outb( adapter_mask | (1 << current_SC->device->id), SCSI_Data_NoACK_port );
+      outb(0x82, port_base + SCSI_Cntl); /* Bus Enable + Select */
+      outb(adapter_mask | (1 << current_SC->device->id), port_base + SCSI_Data_NoACK);
       
       /* Stop arbitration and enable parity */
-      outb( 0x10 | PARITY_MASK, TMC_Cntl_port );
+      outb(0x10 | PARITY_MASK, port_base + TMC_Cntl);
 #if DEBUG_RACE
       in_interrupt_flag = 0;
 #endif
       return IRQ_HANDLED;
    } else if (current_SC->SCp.phase & in_selection) {
-      status = inb( SCSI_Status_port );
+      status = inb(port_base + SCSI_Status);
       if (!(status & 0x01)) {
 	 /* Try again, for slow devices */
 	 if (fdomain_select( current_SC->device->id )) {
@@ -1200,12 +1180,12 @@
 	    printk( " AltSel " );
 #endif
 	    /* Stop arbitration and enable parity */
-	    outb( 0x10 | PARITY_MASK, TMC_Cntl_port );
+	    outb(0x10 | PARITY_MASK, port_base + TMC_Cntl);
 	 }
       }
       current_SC->SCp.phase = in_other;
-      outb( 0x90 | FIFO_COUNT, Interrupt_Cntl_port );
-      outb( 0x80, SCSI_Cntl_port );
+      outb(0x90 | FIFO_COUNT, port_base + Interrupt_Cntl);
+      outb(0x80, port_base + SCSI_Cntl);
 #if DEBUG_RACE
       in_interrupt_flag = 0;
 #endif
@@ -1214,15 +1194,15 @@
    
    /* current_SC->SCp.phase == in_other: this is the body of the routine */
    
-   status = inb( SCSI_Status_port );
+   status = inb(port_base + SCSI_Status);
    
    if (status & 0x10) {	/* REQ */
       
       switch (status & 0x0e) {
        
       case 0x08:		/* COMMAND OUT */
-	 outb( current_SC->cmnd[current_SC->SCp.sent_command++],
-	       Write_SCSI_Data_port );
+	 outb(current_SC->cmnd[current_SC->SCp.sent_command++],
+	      port_base + Write_SCSI_Data);
 #if EVERY_ACCESS
 	 printk( "CMD = %x,",
 		 current_SC->cmnd[ current_SC->SCp.sent_command - 1] );
@@ -1231,17 +1211,17 @@
       case 0x00:		/* DATA OUT -- tmc18c50/tmc18c30 only */
 	 if (chip != tmc1800 && !current_SC->SCp.have_data_in) {
 	    current_SC->SCp.have_data_in = -1;
-	    outb( 0xd0 | PARITY_MASK, TMC_Cntl_port );
+	    outb(0xd0 | PARITY_MASK, port_base + TMC_Cntl);
 	 }
 	 break;
       case 0x04:		/* DATA IN -- tmc18c50/tmc18c30 only */
 	 if (chip != tmc1800 && !current_SC->SCp.have_data_in) {
 	    current_SC->SCp.have_data_in = 1;
-	    outb( 0x90 | PARITY_MASK, TMC_Cntl_port );
+	    outb(0x90 | PARITY_MASK, port_base + TMC_Cntl);
 	 }
 	 break;
       case 0x0c:		/* STATUS IN */
-	 current_SC->SCp.Status = inb( Read_SCSI_Data_port );
+	 current_SC->SCp.Status = inb(port_base + Read_SCSI_Data);
 #if EVERY_ACCESS
 	 printk( "Status = %x, ", current_SC->SCp.Status );
 #endif
@@ -1257,10 +1237,10 @@
 #endif
 	       break;
       case 0x0a:		/* MESSAGE OUT */
-	 outb( MESSAGE_REJECT, Write_SCSI_Data_port ); /* Reject */
+	 outb(MESSAGE_REJECT, port_base + Write_SCSI_Data); /* Reject */
 	 break;
       case 0x0e:		/* MESSAGE IN */
-	 current_SC->SCp.Message = inb( Read_SCSI_Data_port );
+	 current_SC->SCp.Message = inb(port_base + Read_SCSI_Data);
 #if EVERY_ACCESS
 	 printk( "Message = %x, ", current_SC->SCp.Message );
 #endif
@@ -1281,17 +1261,17 @@
       if(current_SC->sc_data_direction == DMA_TO_DEVICE)
       {
 	 current_SC->SCp.have_data_in = -1;
-	 outb( 0xd0 | PARITY_MASK, TMC_Cntl_port );
+	 outb(0xd0 | PARITY_MASK, port_base + TMC_Cntl);
       }
       else
       {
 	 current_SC->SCp.have_data_in = 1;
-	 outb( 0x90 | PARITY_MASK, TMC_Cntl_port );
+	 outb(0x90 | PARITY_MASK, port_base + TMC_Cntl);
       }
    }
 
    if (current_SC->SCp.have_data_in == -1) { /* DATA OUT */
-      while ( (data_count = FIFO_Size - inw( FIFO_Data_Count_port )) > 512 ) {
+      while ((data_count = FIFO_Size - inw(port_base + FIFO_Data_Count)) > 512) {
 #if EVERY_ACCESS
 	 printk( "DC=%d, ", data_count ) ;
 #endif
@@ -1302,11 +1282,11 @@
 	    printk( "%d OUT, ", data_count );
 #endif
 	    if (data_count == 1) {
-	       outb( *current_SC->SCp.ptr++, Write_FIFO_port );
+	       outb(*current_SC->SCp.ptr++, port_base + Write_FIFO);
 	       --current_SC->SCp.this_residual;
 	    } else {
 	       data_count >>= 1;
-	       outsw( Write_FIFO_port, current_SC->SCp.ptr, data_count );
+	       outsw(port_base + Write_FIFO, current_SC->SCp.ptr, data_count);
 	       current_SC->SCp.ptr += 2 * data_count;
 	       current_SC->SCp.this_residual -= 2 * data_count;
 	    }
@@ -1324,7 +1304,7 @@
    }
    
    if (current_SC->SCp.have_data_in == 1) { /* DATA IN */
-      while ((data_count = inw( FIFO_Data_Count_port )) > 0) {
+      while ((data_count = inw(port_base + FIFO_Data_Count)) > 0) {
 #if EVERY_ACCESS
 	 printk( "DC=%d, ", data_count );
 #endif
@@ -1335,11 +1315,11 @@
 	    printk( "%d IN, ", data_count );
 #endif
 	    if (data_count == 1) {
-	       *current_SC->SCp.ptr++ = inb( Read_FIFO_port );
+	       *current_SC->SCp.ptr++ = inb(port_base + Read_FIFO);
 	       --current_SC->SCp.this_residual;
 	    } else {
 	       data_count >>= 1; /* Number of words */
-	       insw( Read_FIFO_port, current_SC->SCp.ptr, data_count );
+	       insw(port_base + Read_FIFO, current_SC->SCp.ptr, data_count);
 	       current_SC->SCp.ptr += 2 * data_count;
 	       current_SC->SCp.this_residual -= 2 * data_count;
 	    }
@@ -1399,10 +1379,10 @@
       
    } else {
       if (current_SC->SCp.phase & disconnect) {
-	 outb( 0xd0 | FIFO_COUNT, Interrupt_Cntl_port );
-	 outb( 0x00, SCSI_Cntl_port );
+	 outb(0xd0 | FIFO_COUNT, port_base + Interrupt_Cntl);
+	 outb(0x00, port_base + SCSI_Cntl);
       } else {
-	 outb( 0x90 | FIFO_COUNT, Interrupt_Cntl_port );
+	 outb(0x90 | FIFO_COUNT, port_base + Interrupt_Cntl);
       }
    }
 #if DEBUG_RACE
@@ -1453,12 +1433,12 @@
    current_SC->SCp.phase               = in_arbitration;
 
    /* Start arbitration */
-   outb( 0x00, Interrupt_Cntl_port );
-   outb( 0x00, SCSI_Cntl_port );              /* Disable data drivers */
-   outb( adapter_mask, SCSI_Data_NoACK_port ); /* Set our id bit */
+   outb(0x00, port_base + Interrupt_Cntl);
+   outb(0x00, port_base + SCSI_Cntl);              /* Disable data drivers */
+   outb(adapter_mask, port_base + SCSI_Data_NoACK); /* Set our id bit */
    ++in_command;
-   outb( 0x20, Interrupt_Cntl_port );
-   outb( 0x14 | PARITY_MASK, TMC_Cntl_port ); /* Start arbitration */
+   outb(0x20, port_base + Interrupt_Cntl);
+   outb(0x14 | PARITY_MASK, port_base + TMC_Cntl); /* Start arbitration */
 
    return 0;
 }
@@ -1514,17 +1494,17 @@
 	 printk( " (masked)" );
    printk( ", IRR = 0x%04x, ISR = 0x%04x\n", irr, isr );
 
-   printk( "SCSI Status      = 0x%02x\n", inb( SCSI_Status_port ) );
-   printk( "TMC Status       = 0x%02x", inb( TMC_Status_port ) );
-   if (inb( TMC_Status_port & 1))
+   printk( "SCSI Status      = 0x%02x\n", inb(port_base + SCSI_Status));
+   printk( "TMC Status       = 0x%02x", inb(port_base + TMC_Status));
+   if (inb((port_base + TMC_Status) & 1))
 	 printk( " (interrupt)" );
    printk( "\n" );
-   printk( "Interrupt Status = 0x%02x", inb( Interrupt_Status_port ) );
-   if (inb( Interrupt_Status_port ) & 0x08)
+   printk("Interrupt Status = 0x%02x", inb(port_base + Interrupt_Status));
+   if (inb(port_base + Interrupt_Status) & 0x08)
 	 printk( " (enabled)" );
    printk( "\n" );
    if (chip == tmc18c50 || chip == tmc18c30) {
-      printk( "FIFO Status      = 0x%02x\n", inb( port_base + FIFO_Status ) );
+      printk("FIFO Status      = 0x%02x\n", inb(port_base + FIFO_Status));
       printk( "Int. Condition   = 0x%02x\n",
 	      inb( port_base + Interrupt_Cond ) );
    }
@@ -1563,12 +1543,12 @@
 
 int fdomain_16x0_bus_reset(struct scsi_cmnd *SCpnt)
 {
-   outb( 1, SCSI_Cntl_port );
+   outb(1, port_base + SCSI_Cntl);
    do_pause( 2 );
-   outb( 0, SCSI_Cntl_port );
+   outb(0, port_base + SCSI_Cntl);
    do_pause( 115 );
-   outb( 0, SCSI_Mode_Cntl_port );
-   outb( PARITY_MASK, TMC_Cntl_port );
+   outb(0, port_base + SCSI_Mode_Cntl);
+   outb(PARITY_MASK, port_base + TMC_Cntl);
    return SUCCESS;
 }
 
@@ -1639,26 +1619,26 @@
       case 2:			/* ISA_200S */
 				/* The value of 25 has never been verified.
 				   It should probably be 15. */
-	 offset = bios_base + 0x1f33 + drive * 25;
+	 offset = 0x1f33 + drive * 25;
 	 break;
       case 3:			/* ISA_250MG */
-	 offset = bios_base + 0x1f36 + drive * 15;
+	 offset = 0x1f36 + drive * 15;
 	 break;
       case 4:			/* ISA_200S (another one) */
-	 offset = bios_base + 0x1f34 + drive * 15;
+	 offset = 0x1f34 + drive * 15;
 	 break;
       default:
-	 offset = bios_base + 0x1f31 + drive * 25;
+	 offset = 0x1f31 + drive * 25;
 	 break;
       }
-      isa_memcpy_fromio( &i, offset, sizeof( struct drive_info ) );
+      memcpy_fromio( &i, bios_mem + offset, sizeof( struct drive_info ) );
       info_array[0] = i.heads;
       info_array[1] = i.sectors;
       info_array[2] = i.cylinders;
    } else if (bios_major == 3
 	      && bios_minor >= 0
 	      && bios_minor < 4) { /* 3.0 and 3.2 BIOS */
-      memcpy_fromio( &i, bios_base + 0x1f71 + drive * 10,
+      memcpy_fromio( &i, bios_mem + 0x1f71 + drive * 10,
 		     sizeof( struct drive_info ) );
       info_array[0] = i.heads + 1;
       info_array[1] = i.sectors;
diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
--- a/drivers/scsi/hosts.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/hosts.c	2004-12-24 13:36:17 -08:00
@@ -50,11 +50,6 @@
 	.release	= scsi_host_cls_release,
 };
 
-static int scsi_device_cancel_cb(struct device *dev, void *data)
-{
-	return scsi_device_cancel(to_scsi_device(dev), *(int *)data);
-}
-
 /**
  * scsi_host_cancel - cancel outstanding IO to this host
  * @shost:	pointer to struct Scsi_Host
@@ -62,9 +57,12 @@
  **/
 void scsi_host_cancel(struct Scsi_Host *shost, int recovery)
 {
+	struct scsi_device *sdev;
+
 	set_bit(SHOST_CANCEL, &shost->shost_state);
-	device_for_each_child(&shost->shost_gendev, &recovery,
-			      scsi_device_cancel_cb);
+	shost_for_each_device(sdev, shost) {
+		scsi_device_cancel(sdev, recovery);
+	}
 	wait_event(shost->host_wait, (!test_bit(SHOST_RECOVERY,
 						&shost->shost_state)));
 }
@@ -82,6 +80,8 @@
 	set_bit(SHOST_DEL, &shost->shost_state);
 
 	class_device_unregister(&shost->shost_classdev);
+	if (shost->transport_classdev.class)
+		class_device_unregister(&shost->transport_classdev);
 	device_del(&shost->shost_gendev);
 }
 
@@ -96,7 +96,7 @@
 int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
 {
 	struct scsi_host_template *sht = shost->hostt;
-	int error;
+	int error = -EINVAL;
 
 	printk(KERN_INFO "scsi%d : %s\n", shost->host_no,
 			sht->info ? sht->info(shost) : sht->name);
@@ -104,7 +104,7 @@
 	if (!shost->can_queue) {
 		printk(KERN_ERR "%s: can_queue = 0 no longer supported\n",
 				sht->name);
-		return -EINVAL;
+		goto out;
 	}
 
 	if (!shost->shost_gendev.parent)
@@ -123,6 +123,14 @@
 
 	get_device(&shost->shost_gendev);
 
+	if (shost->transportt->host_size &&
+	    (shost->shost_data = kmalloc(shost->transportt->host_size,
+					 GFP_KERNEL)) == NULL)
+		goto out_del_classdev;
+
+	if (shost->transportt->host_setup)
+		shost->transportt->host_setup(shost);
+
 	error = scsi_sysfs_add_host(shost);
 	if (error)
 		goto out_del_classdev;
@@ -154,6 +162,7 @@
 
 	scsi_proc_hostdir_rm(shost->hostt);
 	scsi_destroy_command_freelist(shost);
+	kfree(shost->shost_data);
 
 	/*
 	 * Some drivers (eg aha1542) do scsi_register()/scsi_unregister()
@@ -221,10 +230,8 @@
 	shost->max_id = 8;
 	shost->max_lun = 8;
 
-	/* Give each shost a default transportt if the driver
-	 * doesn't yet support Transport Attributes */
-	if (!shost->transportt) 
-		shost->transportt = &blank_transport_template;
+	/* Give each shost a default transportt */
+	shost->transportt = &blank_transport_template;
 
 	/*
 	 * All drivers right now should be able to handle 12 byte
@@ -284,6 +291,7 @@
 		goto fail_destroy_freelist;
 	wait_for_completion(&complete);
 	shost->eh_notify = NULL;
+
 	scsi_proc_hostdir_add(shost->hostt);
 	return shost;
 
diff -Nru a/drivers/scsi/i60uscsi.c b/drivers/scsi/i60uscsi.c
--- a/drivers/scsi/i60uscsi.c	2004-12-24 13:36:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,805 +0,0 @@
-/**************************************************************************
- * Initio A100 device driver for Linux.
- *
- * Copyright (c) 1994-1998 Initio Corporation
- * 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, 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; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * --------------------------------------------------------------------------
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU General Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- *************************************************************************
- *
- * module: i60uscsi.c 
- * DESCRIPTION:
- * 	This is the Linux low-level SCSI driver for Initio INIA100 SCSI host
- * adapters
- *
- * 07/02/98 hl	- v.91n Initial drivers.
- * 09/14/98 hl - v1.01 Support new Kernel.
- * 09/22/98 hl - v1.01a Support reset.
- * 09/24/98 hl - v1.01b Fixed reset.
- * 10/05/98 hl - v1.02 split the source code and release.
- * 12/19/98 bv - v1.02a Use spinlocks for 2.1.95 and up
- * 01/31/99 bv - v1.02b Use mdelay instead of waitForPause
- * 08/08/99 bv - v1.02c Use waitForPause again.
- * 06/25/02 Doug Ledford <dledford@redhat.com> - v1.02d
- *          - Remove limit on number of controllers
- *          - Port to DMA mapping API
- *          - Clean up interrupt handler registration
- *          - Fix memory leaks
- *          - Fix allocation of scsi host structs and private data
- **************************************************************************/
-
-#include <linux/module.h>
-#include <asm/irq.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <asm/io.h>
-#include <linux/blkdev.h>
-#include "scsi.h"
-#include <scsi/scsi_host.h>
-#include "inia100.h"
-
-#define JIFFIES_TO_MS(t) ((t) * 1000 / HZ)
-#define MS_TO_JIFFIES(j) ((j * HZ) / 1000)
-
-/* ---- INTERNAL FUNCTIONS ---- */
-static UCHAR waitChipReady(ORC_HCS * hcsp);
-static UCHAR waitFWReady(ORC_HCS * hcsp);
-static UCHAR waitFWReady(ORC_HCS * hcsp);
-static UCHAR waitSCSIRSTdone(ORC_HCS * hcsp);
-static UCHAR waitHDOoff(ORC_HCS * hcsp);
-static UCHAR waitHDIset(ORC_HCS * hcsp, UCHAR * pData);
-static unsigned short get_FW_version(ORC_HCS * hcsp);
-static UCHAR set_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char value);
-static UCHAR get_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char *pDataIn);
-static int se2_rd_all(ORC_HCS * hcsp);
-static void se2_update_all(ORC_HCS * hcsp);	/* setup default pattern        */
-static void read_eeprom(ORC_HCS * hcsp);
-static UCHAR load_FW(ORC_HCS * hcsp);
-static void setup_SCBs(ORC_HCS * hcsp);
-static void initAFlag(ORC_HCS * hcsp);
-ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp);
-
-/* ---- EXTERNAL FUNCTIONS ---- */
-extern void inia100SCBPost(BYTE * pHcb, BYTE * pScb);
-
-NVRAM nvram, *nvramp = &nvram;
-static UCHAR dftNvRam[64] =
-{
-/*----------header -------------*/
-	0x01,			/* 0x00: Sub System Vendor ID 0 */
-	0x11,			/* 0x01: Sub System Vendor ID 1 */
-	0x60,			/* 0x02: Sub System ID 0        */
-	0x10,			/* 0x03: Sub System ID 1        */
-	0x00,			/* 0x04: SubClass               */
-	0x01,			/* 0x05: Vendor ID 0            */
-	0x11,			/* 0x06: Vendor ID 1            */
-	0x60,			/* 0x07: Device ID 0            */
-	0x10,			/* 0x08: Device ID 1            */
-	0x00,			/* 0x09: Reserved               */
-	0x00,			/* 0x0A: Reserved               */
-	0x01,			/* 0x0B: Revision of Data Structure     */
-				/* -- Host Adapter Structure --- */
-	0x01,			/* 0x0C: Number Of SCSI Channel */
-	0x01,			/* 0x0D: BIOS Configuration 1   */
-	0x00,			/* 0x0E: BIOS Configuration 2   */
-	0x00,			/* 0x0F: BIOS Configuration 3   */
-				/* --- SCSI Channel 0 Configuration --- */
-	0x07,			/* 0x10: H/A ID                 */
-	0x83,			/* 0x11: Channel Configuration  */
-	0x20,			/* 0x12: MAX TAG per target     */
-	0x0A,			/* 0x13: SCSI Reset Recovering time     */
-	0x00,			/* 0x14: Channel Configuration4 */
-	0x00,			/* 0x15: Channel Configuration5 */
-				/* SCSI Channel 0 Target Configuration  */
-				/* 0x16-0x25                    */
-	0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
-	0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
-				/* --- SCSI Channel 1 Configuration --- */
-	0x07,			/* 0x26: H/A ID                 */
-	0x83,			/* 0x27: Channel Configuration  */
-	0x20,			/* 0x28: MAX TAG per target     */
-	0x0A,			/* 0x29: SCSI Reset Recovering time     */
-	0x00,			/* 0x2A: Channel Configuration4 */
-	0x00,			/* 0x2B: Channel Configuration5 */
-				/* SCSI Channel 1 Target Configuration  */
-				/* 0x2C-0x3B                    */
-	0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
-	0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
-	0x00,			/* 0x3C: Reserved               */
-	0x00,			/* 0x3D: Reserved               */
-	0x00,			/* 0x3E: Reserved               */
-	0x00			/* 0x3F: Checksum               */
-};
-
-
-/***************************************************************************/
-static void waitForPause(unsigned amount)
-{
-	ULONG the_time = jiffies + MS_TO_JIFFIES(amount);
-	while (time_before_eq(jiffies, the_time))
-		cpu_relax();
-}
-
-/***************************************************************************/
-UCHAR waitChipReady(ORC_HCS * hcsp)
-{
-	int i;
-
-	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
-		if (ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & HOSTSTOP)	/* Wait HOSTSTOP set */
-			return (TRUE);
-		waitForPause(100);	/* wait 100ms before try again  */
-	}
-	return (FALSE);
-}
-
-/***************************************************************************/
-UCHAR waitFWReady(ORC_HCS * hcsp)
-{
-	int i;
-
-	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
-		if (ORC_RD(hcsp->HCS_Base, ORC_HSTUS) & RREADY)		/* Wait READY set */
-			return (TRUE);
-		waitForPause(100);	/* wait 100ms before try again  */
-	}
-	return (FALSE);
-}
-
-/***************************************************************************/
-UCHAR waitSCSIRSTdone(ORC_HCS * hcsp)
-{
-	int i;
-
-	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
-		if (!(ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & SCSIRST))	/* Wait SCSIRST done */
-			return (TRUE);
-		waitForPause(100);	/* wait 100ms before try again  */
-	}
-	return (FALSE);
-}
-
-/***************************************************************************/
-UCHAR waitHDOoff(ORC_HCS * hcsp)
-{
-	int i;
-
-	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
-		if (!(ORC_RD(hcsp->HCS_Base, ORC_HCTRL) & HDO))		/* Wait HDO off */
-			return (TRUE);
-		waitForPause(100);	/* wait 100ms before try again  */
-	}
-	return (FALSE);
-}
-
-/***************************************************************************/
-UCHAR waitHDIset(ORC_HCS * hcsp, UCHAR * pData)
-{
-	int i;
-
-	for (i = 0; i < 10; i++) {	/* Wait 1 second for report timeout     */
-		if ((*pData = ORC_RD(hcsp->HCS_Base, ORC_HSTUS)) & HDI)
-			return (TRUE);	/* Wait HDI set */
-		waitForPause(100);	/* wait 100ms before try again  */
-	}
-	return (FALSE);
-}
-
-/***************************************************************************/
-unsigned short get_FW_version(ORC_HCS * hcsp)
-{
-	UCHAR bData;
-	union {
-		unsigned short sVersion;
-		unsigned char cVersion[2];
-	} Version;
-
-	ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_VERSION);
-	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
-	if (waitHDOoff(hcsp) == FALSE)	/* Wait HDO off   */
-		return (FALSE);
-
-	if (waitHDIset(hcsp, &bData) == FALSE)	/* Wait HDI set   */
-		return (FALSE);
-	Version.cVersion[0] = ORC_RD(hcsp->HCS_Base, ORC_HDATA);
-	ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData);	/* Clear HDI            */
-
-	if (waitHDIset(hcsp, &bData) == FALSE)	/* Wait HDI set   */
-		return (FALSE);
-	Version.cVersion[1] = ORC_RD(hcsp->HCS_Base, ORC_HDATA);
-	ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData);	/* Clear HDI            */
-
-	return (Version.sVersion);
-}
-
-/***************************************************************************/
-UCHAR set_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char value)
-{
-	ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_SET_NVM);	/* Write command */
-	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
-	if (waitHDOoff(hcsp) == FALSE)	/* Wait HDO off   */
-		return (FALSE);
-
-	ORC_WR(hcsp->HCS_Base + ORC_HDATA, address);	/* Write address */
-	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
-	if (waitHDOoff(hcsp) == FALSE)	/* Wait HDO off   */
-		return (FALSE);
-
-	ORC_WR(hcsp->HCS_Base + ORC_HDATA, value);	/* Write value  */
-	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
-	if (waitHDOoff(hcsp) == FALSE)	/* Wait HDO off   */
-		return (FALSE);
-
-	return (TRUE);
-}
-
-/***************************************************************************/
-UCHAR get_NVRAM(ORC_HCS * hcsp, unsigned char address, unsigned char *pDataIn)
-{
-	unsigned char bData;
-
-	ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_GET_NVM);	/* Write command */
-	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
-	if (waitHDOoff(hcsp) == FALSE)	/* Wait HDO off   */
-		return (FALSE);
-
-	ORC_WR(hcsp->HCS_Base + ORC_HDATA, address);	/* Write address */
-	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
-	if (waitHDOoff(hcsp) == FALSE)	/* Wait HDO off   */
-		return (FALSE);
-
-	if (waitHDIset(hcsp, &bData) == FALSE)	/* Wait HDI set   */
-		return (FALSE);
-	*pDataIn = ORC_RD(hcsp->HCS_Base, ORC_HDATA);
-	ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData);	/* Clear HDI    */
-
-	return (TRUE);
-}
-
-/***************************************************************************/
-void orc_exec_scb(ORC_HCS * hcsp, ORC_SCB * scbp)
-{
-	scbp->SCB_Status = ORCSCB_POST;
-	ORC_WR(hcsp->HCS_Base + ORC_PQUEUE, scbp->SCB_ScbIdx);
-	return;
-}
-
-
-/***********************************************************************
- Read SCSI H/A configuration parameters from serial EEPROM
-************************************************************************/
-int se2_rd_all(ORC_HCS * hcsp)
-{
-	int i;
-	UCHAR *np, chksum = 0;
-
-	np = (UCHAR *) nvramp;
-	for (i = 0; i < 64; i++, np++) {	/* <01> */
-		if (get_NVRAM(hcsp, (unsigned char) i, np) == FALSE)
-			return -1;
-//      *np++ = get_NVRAM(hcsp, (unsigned char ) i);
-	}
-
-/*------ Is ckecksum ok ? ------*/
-	np = (UCHAR *) nvramp;
-	for (i = 0; i < 63; i++)
-		chksum += *np++;
-
-	if (nvramp->CheckSum != (UCHAR) chksum)
-		return -1;
-	return 1;
-}
-
-/************************************************************************
- Update SCSI H/A configuration parameters from serial EEPROM
-*************************************************************************/
-void se2_update_all(ORC_HCS * hcsp)
-{				/* setup default pattern  */
-	int i;
-	UCHAR *np, *np1, chksum = 0;
-
-	/* Calculate checksum first   */
-	np = (UCHAR *) dftNvRam;
-	for (i = 0; i < 63; i++)
-		chksum += *np++;
-	*np = chksum;
-
-	np = (UCHAR *) dftNvRam;
-	np1 = (UCHAR *) nvramp;
-	for (i = 0; i < 64; i++, np++, np1++) {
-		if (*np != *np1) {
-			set_NVRAM(hcsp, (unsigned char) i, *np);
-		}
-	}
-	return;
-}
-
-/*************************************************************************
- Function name  : read_eeprom
-**************************************************************************/
-void read_eeprom(ORC_HCS * hcsp)
-{
-	if (se2_rd_all(hcsp) != 1) {
-		se2_update_all(hcsp);	/* setup default pattern        */
-		se2_rd_all(hcsp);	/* load again                   */
-	}
-}
-
-
-/***************************************************************************/
-UCHAR load_FW(ORC_HCS * hcsp)
-{
-	U32 dData;
-	USHORT wBIOSAddress;
-	USHORT i;
-	UCHAR *pData, bData;
-
-
-	bData = ORC_RD(hcsp->HCS_Base, ORC_GCFG);
-	ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData | EEPRG);	/* Enable EEPROM programming */
-	ORC_WR(hcsp->HCS_Base + ORC_EBIOSADR2, 0x00);
-	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x00);
-	if (ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA) != 0x55) {
-		ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData);	/* Disable EEPROM programming */
-		return (FALSE);
-	}
-	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x01);
-	if (ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA) != 0xAA) {
-		ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData);	/* Disable EEPROM programming */
-		return (FALSE);
-	}
-	ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST | DOWNLOAD);	/* Enable SRAM programming */
-	pData = (UCHAR *) & dData;
-	dData = 0;		/* Initial FW address to 0 */
-	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x10);
-	*pData = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);		/* Read from BIOS */
-	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x11);
-	*(pData + 1) = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);	/* Read from BIOS */
-	ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, 0x12);
-	*(pData + 2) = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);	/* Read from BIOS */
-	ORC_WR(hcsp->HCS_Base + ORC_EBIOSADR2, *(pData + 2));
-	ORC_WRLONG(hcsp->HCS_Base + ORC_FWBASEADR, dData);	/* Write FW address */
-
-	wBIOSAddress = (USHORT) dData;	/* FW code locate at BIOS address + ? */
-	for (i = 0, pData = (UCHAR *) & dData;	/* Download the code    */
-	     i < 0x1000;	/* Firmware code size = 4K      */
-	     i++, wBIOSAddress++) {
-		ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, wBIOSAddress);
-		*pData++ = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);	/* Read from BIOS */
-		if ((i % 4) == 3) {
-			ORC_WRLONG(hcsp->HCS_Base + ORC_RISCRAM, dData);	/* Write every 4 bytes */
-			pData = (UCHAR *) & dData;
-		}
-	}
-
-	ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST | DOWNLOAD);	/* Reset program count 0 */
-	wBIOSAddress -= 0x1000;	/* Reset the BIOS adddress      */
-	for (i = 0, pData = (UCHAR *) & dData;	/* Check the code       */
-	     i < 0x1000;	/* Firmware code size = 4K      */
-	     i++, wBIOSAddress++) {
-		ORC_WRSHORT(hcsp->HCS_Base + ORC_EBIOSADR0, wBIOSAddress);
-		*pData++ = ORC_RD(hcsp->HCS_Base, ORC_EBIOSDATA);	/* Read from BIOS */
-		if ((i % 4) == 3) {
-			if (ORC_RDLONG(hcsp->HCS_Base, ORC_RISCRAM) != dData) {
-				ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST);	/* Reset program to 0 */
-				ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData);	/*Disable EEPROM programming */
-				return (FALSE);
-			}
-			pData = (UCHAR *) & dData;
-		}
-	}
-	ORC_WR(hcsp->HCS_Base + ORC_RISCCTL, PRGMRST);	/* Reset program to 0   */
-	ORC_WR(hcsp->HCS_Base + ORC_GCFG, bData);	/* Disable EEPROM programming */
-	return (TRUE);
-}
-
-/***************************************************************************/
-void setup_SCBs(ORC_HCS * hcsp)
-{
-	ORC_SCB *pVirScb;
-	int i;
-	ESCB *pVirEscb;
-	dma_addr_t pPhysEscb;
-
-	/* Setup SCB HCS_Base and SCB Size registers */
-	ORC_WR(hcsp->HCS_Base + ORC_SCBSIZE, ORC_MAXQUEUE);	/* Total number of SCBs */
-	/* SCB HCS_Base address 0      */
-	ORC_WRLONG(hcsp->HCS_Base + ORC_SCBBASE0, hcsp->HCS_physScbArray);
-	/* SCB HCS_Base address 1      */
-	ORC_WRLONG(hcsp->HCS_Base + ORC_SCBBASE1, hcsp->HCS_physScbArray);
-
-	/* setup scatter list address with one buffer */
-	pVirScb = (ORC_SCB *) hcsp->HCS_virScbArray;
-	pVirEscb = (ESCB *) hcsp->HCS_virEscbArray;
-
-	for (i = 0; i < ORC_MAXQUEUE; i++) {
-		pPhysEscb = (hcsp->HCS_physEscbArray + (sizeof(ESCB) * i));
-		pVirScb->SCB_SGPAddr = (U32) pPhysEscb;
-		pVirScb->SCB_SensePAddr = (U32) pPhysEscb;
-		pVirScb->SCB_EScb = pVirEscb;
-		pVirScb->SCB_ScbIdx = i;
-		pVirScb++;
-		pVirEscb++;
-	}
-
-	return;
-}
-
-/***************************************************************************/
-static void initAFlag(ORC_HCS * hcsp)
-{
-	UCHAR i, j;
-
-	for (i = 0; i < MAX_CHANNELS; i++) {
-		for (j = 0; j < 8; j++) {
-			hcsp->BitAllocFlag[i][j] = 0xffffffff;
-		}
-	}
-}
-
-/***************************************************************************/
-int init_orchid(ORC_HCS * hcsp)
-{
-	UBYTE *readBytep;
-	USHORT revision;
-	UCHAR i;
-
-	initAFlag(hcsp);
-	ORC_WR(hcsp->HCS_Base + ORC_GIMSK, 0xFF);	/* Disable all interrupt        */
-	if (ORC_RD(hcsp->HCS_Base, ORC_HSTUS) & RREADY) {	/* Orchid is ready              */
-		revision = get_FW_version(hcsp);
-		if (revision == 0xFFFF) {
-			ORC_WR(hcsp->HCS_Base + ORC_HCTRL, DEVRST);	/* Reset Host Adapter   */
-			if (waitChipReady(hcsp) == FALSE)
-				return (-1);
-			load_FW(hcsp);	/* Download FW                  */
-			setup_SCBs(hcsp);	/* Setup SCB HCS_Base and SCB Size registers */
-			ORC_WR(hcsp->HCS_Base + ORC_HCTRL, 0);	/* clear HOSTSTOP       */
-			if (waitFWReady(hcsp) == FALSE)
-				return (-1);
-			/* Wait for firmware ready     */
-		} else {
-			setup_SCBs(hcsp);	/* Setup SCB HCS_Base and SCB Size registers */
-		}
-	} else {		/* Orchid is not Ready          */
-		ORC_WR(hcsp->HCS_Base + ORC_HCTRL, DEVRST);	/* Reset Host Adapter   */
-		if (waitChipReady(hcsp) == FALSE)
-			return (-1);
-		load_FW(hcsp);	/* Download FW                  */
-		setup_SCBs(hcsp);	/* Setup SCB HCS_Base and SCB Size registers */
-		ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);	/* Do Hardware Reset &  */
-
-		/*     clear HOSTSTOP  */
-		if (waitFWReady(hcsp) == FALSE)		/* Wait for firmware ready      */
-			return (-1);
-	}
-
-/*------------- get serial EEProm settting -------*/
-
-	read_eeprom(hcsp);
-
-	if (nvramp->Revision != 1)
-		return (-1);
-
-	hcsp->HCS_SCSI_ID = nvramp->SCSI0Id;
-	hcsp->HCS_BIOS = nvramp->BIOSConfig1;
-	hcsp->HCS_MaxTar = MAX_TARGETS;
-	readBytep = (UCHAR *) & (nvramp->Target00Config);
-	for (i = 0; i < 16; readBytep++, i++) {
-		hcsp->TargetFlag[i] = *readBytep;
-		hcsp->MaximumTags[i] = ORC_MAXTAGS;
-	}			/* for                          */
-
-	if (nvramp->SCSI0Config & NCC_BUSRESET) {	/* Reset SCSI bus               */
-		hcsp->HCS_Flags |= HCF_SCSI_RESET;
-	}
-	ORC_WR(hcsp->HCS_Base + ORC_GIMSK, 0xFB);	/* enable RP FIFO interrupt     */
-	return (0);
-}
-
-/*****************************************************************************
- Function name  : orc_reset_scsi_bus
- Description    : Reset registers, reset a hanging bus and
-                  kill active and disconnected commands for target w/o soft reset
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-int orc_reset_scsi_bus(ORC_HCS * pHCB)
-{				/* I need Host Control Block Information */
-	ULONG flags;
-
-	spin_lock_irqsave(&(pHCB->BitAllocFlagLock), flags);
-
-	initAFlag(pHCB);
-	/* reset scsi bus */
-	ORC_WR(pHCB->HCS_Base + ORC_HCTRL, SCSIRST);
-	if (waitSCSIRSTdone(pHCB) == FALSE) {
-		spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
-		return FAILED;
-	} else {
-		spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
-		return SUCCESS;
-	}
-}
-
-/*****************************************************************************
- Function name  : orc_device_reset
- Description    : Reset registers, reset a hanging bus and
-                  kill active and disconnected commands for target w/o soft reset
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-int orc_device_reset(ORC_HCS * pHCB, Scsi_Cmnd *SCpnt, unsigned int target)
-{				/* I need Host Control Block Information */
-	ORC_SCB *pScb;
-	ESCB *pVirEscb;
-	ORC_SCB *pVirScb;
-	UCHAR i;
-	ULONG flags;
-
-	spin_lock_irqsave(&(pHCB->BitAllocFlagLock), flags);
-	pScb = (ORC_SCB *) NULL;
-	pVirEscb = (ESCB *) NULL;
-
-	/* setup scatter list address with one buffer */
-	pVirScb = (ORC_SCB *) pHCB->HCS_virScbArray;
-
-	initAFlag(pHCB);
-	/* device reset */
-	for (i = 0; i < ORC_MAXQUEUE; i++) {
-		pVirEscb = pVirScb->SCB_EScb;
-		if ((pVirScb->SCB_Status) && (pVirEscb->SCB_Srb == SCpnt))
-			break;
-		pVirScb++;
-	}
-
-	if (i == ORC_MAXQUEUE) {
-		printk("Unable to Reset - No SCB Found\n");
-		spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
-		return FAILED;
-	}
-	if ((pScb = orc_alloc_scb(pHCB)) == NULL) {
-		spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
-		return FAILED;
-	}
-	pScb->SCB_Opcode = ORC_BUSDEVRST;
-	pScb->SCB_Target = target;
-	pScb->SCB_HaStat = 0;
-	pScb->SCB_TaStat = 0;
-	pScb->SCB_Status = 0x0;
-	pScb->SCB_Link = 0xFF;
-	pScb->SCB_Reserved0 = 0;
-	pScb->SCB_Reserved1 = 0;
-	pScb->SCB_XferLen = 0;
-	pScb->SCB_SGLen = 0;
-
-	pVirEscb->SCB_Srb = NULL;
-	pVirEscb->SCB_Srb = SCpnt;
-	orc_exec_scb(pHCB, pScb);	/* Start execute SCB            */
-	spin_unlock_irqrestore(&(pHCB->BitAllocFlagLock), flags);
-	return SUCCESS;
-}
-
-
-/***************************************************************************/
-ORC_SCB *__orc_alloc_scb(ORC_HCS * hcsp)
-{
-	ORC_SCB *pTmpScb;
-	UCHAR Ch;
-	ULONG idx;
-	UCHAR index;
-	UCHAR i;
-
-	Ch = hcsp->HCS_Index;
-	for (i = 0; i < 8; i++) {
-		for (index = 0; index < 32; index++) {
-			if ((hcsp->BitAllocFlag[Ch][i] >> index) & 0x01) {
-				hcsp->BitAllocFlag[Ch][i] &= ~(1 << index);
-				break;
-			}
-		}
-		idx = index + 32 * i;
-		pTmpScb = (PVOID) ((ULONG) hcsp->HCS_virScbArray + (idx * sizeof(ORC_SCB)));
-		return (pTmpScb);
-	}
-	return (NULL);
-}
-
-ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp)
-{
-	ORC_SCB *pTmpScb;
-	ULONG flags;
-
-	spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags);
-	pTmpScb = __orc_alloc_scb(hcsp);
-	spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
-	return (pTmpScb);
-}
-
-
-/***************************************************************************/
-void orc_release_scb(ORC_HCS * hcsp, ORC_SCB * scbp)
-{
-	ULONG flags;
-	UCHAR Index;
-	UCHAR i;
-	UCHAR Ch;
-
-	spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags);
-	Ch = hcsp->HCS_Index;
-	Index = scbp->SCB_ScbIdx;
-	i = Index / 32;
-	Index %= 32;
-	hcsp->BitAllocFlag[Ch][i] |= (1 << Index);
-	spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
-}
-
-
-/***************************************************************************/
-void orc_release_dma(ORC_HCS * hcsp, Scsi_Cmnd * SCpnt)
-{
-	struct scatterlist *pSrbSG;
-
-	if (SCpnt->use_sg) {
-		pSrbSG = (struct scatterlist *)SCpnt->request_buffer;
-		pci_unmap_sg(hcsp->pdev, pSrbSG, SCpnt->use_sg,
-			scsi_to_pci_dma_dir(SCpnt->sc_data_direction));
-	} else if (SCpnt->request_bufflen != 0) {
-		pci_unmap_single(hcsp->pdev, (U32)SCpnt->host_scribble,
-			SCpnt->request_bufflen,
-			scsi_to_pci_dma_dir(SCpnt->sc_data_direction));
-	}
-}
-
-/*****************************************************************************
- Function name  : abort_SCB
- Description    : Abort a queued command.
-	                 (commands that are on the bus can't be aborted easily)
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-int abort_SCB(ORC_HCS * hcsp, ORC_SCB * pScb)
-{
-	unsigned char bData, bStatus;
-
-	ORC_WR(hcsp->HCS_Base + ORC_HDATA, ORC_CMD_ABORT_SCB);	/* Write command */
-	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
-	if (waitHDOoff(hcsp) == FALSE)	/* Wait HDO off   */
-		return (FALSE);
-
-	ORC_WR(hcsp->HCS_Base + ORC_HDATA, pScb->SCB_ScbIdx);	/* Write address */
-	ORC_WR(hcsp->HCS_Base + ORC_HCTRL, HDO);
-	if (waitHDOoff(hcsp) == FALSE)	/* Wait HDO off   */
-		return (FALSE);
-
-	if (waitHDIset(hcsp, &bData) == FALSE)	/* Wait HDI set   */
-		return (FALSE);
-	bStatus = ORC_RD(hcsp->HCS_Base, ORC_HDATA);
-	ORC_WR(hcsp->HCS_Base + ORC_HSTUS, bData);	/* Clear HDI    */
-
-	if (bStatus == 1)	/* 0 - Successfully               */
-		return (FALSE);	/* 1 - Fail                     */
-	return (TRUE);
-}
-
-/*****************************************************************************
- Function name  : inia100_abort
- Description    : Abort a queued command.
-	                 (commands that are on the bus can't be aborted easily)
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-int orc_abort_srb(ORC_HCS * hcsp, Scsi_Cmnd *SCpnt)
-{
-	ESCB *pVirEscb;
-	ORC_SCB *pVirScb;
-	UCHAR i;
-	ULONG flags;
-
-	spin_lock_irqsave(&(hcsp->BitAllocFlagLock), flags);
-
-	pVirScb = (ORC_SCB *) hcsp->HCS_virScbArray;
-
-	for (i = 0; i < ORC_MAXQUEUE; i++, pVirScb++) {
-		pVirEscb = pVirScb->SCB_EScb;
-		if ((pVirScb->SCB_Status) && (pVirEscb->SCB_Srb == SCpnt)) {
-			if (pVirScb->SCB_TagMsg == 0) {
-				spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
-				return FAILED;
-			} else {
-				if (abort_SCB(hcsp, pVirScb)) {
-					pVirEscb->SCB_Srb = NULL;
-					spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
-					return SUCCESS;
-				} else {
-					spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
-					return FAILED;
-				}
-			}
-		}
-	}
-	spin_unlock_irqrestore(&(hcsp->BitAllocFlagLock), flags);
-	return FAILED;
-}
-
-/***********************************************************************
- Routine Description:
-	  This is the interrupt service routine for the Orchid SCSI adapter.
-	  It reads the interrupt register to determine if the adapter is indeed
-	  the source of the interrupt and clears the interrupt at the device.
- Arguments:
-	  HwDeviceExtension - HBA miniport driver's adapter data storage
- Return Value:
-***********************************************************************/
-void orc_interrupt(
-			  ORC_HCS * hcsp
-)
-{
-	BYTE bScbIdx;
-	ORC_SCB *pScb;
-
-	if (ORC_RD(hcsp->HCS_Base, ORC_RQUEUECNT) == 0) {
-		return;		// (FALSE);
-
-	}
-	do {
-		bScbIdx = ORC_RD(hcsp->HCS_Base, ORC_RQUEUE);
-
-		pScb = (ORC_SCB *) ((ULONG) hcsp->HCS_virScbArray + (ULONG) (sizeof(ORC_SCB) * bScbIdx));
-		pScb->SCB_Status = 0x0;
-
-		inia100SCBPost((BYTE *) hcsp, (BYTE *) pScb);
-	} while (ORC_RD(hcsp->HCS_Base, ORC_RQUEUECNT));
-	return;			//(TRUE);
-
-}				/* End of I1060Interrupt() */
diff -Nru a/drivers/scsi/i91uscsi.c b/drivers/scsi/i91uscsi.c
--- a/drivers/scsi/i91uscsi.c	2004-12-24 13:36:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,2672 +0,0 @@
-/**************************************************************************
- * Initio 9100 device driver for Linux.
- *
- * Copyright (c) 1994-1998 Initio Corporation
- * Copyright (c) 1998 Bas Vermeulen <bvermeul@blackstar.xs4all.nl>
- * 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, 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; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * --------------------------------------------------------------------------
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU General Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- ************************************************************************
-    Module: i91uscsi.c
-    Description: PCI I/F for INI-910 SCSI Bus Master Controller
-    Revision History:
-	11/09/94 Tim Chen, Initiali Version 0.90A
-	01/17/95 TC, release ver 1.01
-	02/09/95 TC  modify ReadPCIConfig, try both mechanisms;
-	02/15/95 TC  add support for INI-9100W
-	06/04/96 HC, Change to fit LINUX from jaspci.c
-	11/18/96 HC, Port for tulip
-	07/08/98 hc, Support 0002134A
-        07/23/98 wh, Change the abort_srb routine.
-	09/16/98 hl, Support ALPHA, Rewrite the returnNumberAdapters	<01>
-	12/09/98 bv, Removed unused code, changed tul_se2_wait to
-		     use udelay(30) and tul_do_pause to enable 
-		     interrupts for >= 2.1.95
-	12/13/98 bv, Use spinlocks instead of cli() for serialized
-		     access to HCS_Semaph, HCS_FirstAvail and HCS_LastAvail
-		     members of the HCS structure.
-	01/09/98 bv, Fix a deadlock on SMP system.
-**********************************************************************/
-
-#define DEBUG_INTERRUPT 0
-#define DEBUG_QUEUE     0
-#define DEBUG_STATE     0
-#define INT_DISC	0
-
-#include <linux/jiffies.h>
-#include <linux/delay.h>
-#include <linux/blkdev.h>
-#include <asm/io.h>
-
-#include "i91uscsi.h"
-
-/*--- external functions --*/
-static void tul_se2_wait(void);
-
-/*--- forward refrence ---*/
-static SCB *tul_find_busy_scb(HCS * pCurHcb, WORD tarlun);
-static SCB *tul_find_done_scb(HCS * pCurHcb);
-
-static int tulip_main(HCS * pCurHcb);
-
-static int tul_next_state(HCS * pCurHcb);
-static int tul_state_1(HCS * pCurHcb);
-static int tul_state_2(HCS * pCurHcb);
-static int tul_state_3(HCS * pCurHcb);
-static int tul_state_4(HCS * pCurHcb);
-static int tul_state_5(HCS * pCurHcb);
-static int tul_state_6(HCS * pCurHcb);
-static int tul_state_7(HCS * pCurHcb);
-static int tul_xfer_data_in(HCS * pCurHcb);
-static int tul_xfer_data_out(HCS * pCurHcb);
-static int tul_xpad_in(HCS * pCurHcb);
-static int tul_xpad_out(HCS * pCurHcb);
-static int tul_status_msg(HCS * pCurHcb);
-
-static int tul_msgin(HCS * pCurHcb);
-static int tul_msgin_sync(HCS * pCurHcb);
-static int tul_msgin_accept(HCS * pCurHcb);
-static int tul_msgout_reject(HCS * pCurHcb);
-static int tul_msgin_extend(HCS * pCurHcb);
-
-static int tul_msgout_ide(HCS * pCurHcb);
-static int tul_msgout_abort_targ(HCS * pCurHcb);
-static int tul_msgout_abort_tag(HCS * pCurHcb);
-
-static int tul_bus_device_reset(HCS * pCurHcb);
-static void tul_select_atn(HCS * pCurHcb, SCB * pCurScb);
-static void tul_select_atn3(HCS * pCurHcb, SCB * pCurScb);
-static void tul_select_atn_stop(HCS * pCurHcb, SCB * pCurScb);
-static int int_tul_busfree(HCS * pCurHcb);
-int int_tul_scsi_rst(HCS * pCurHcb);
-static int int_tul_bad_seq(HCS * pCurHcb);
-static int int_tul_resel(HCS * pCurHcb);
-static int tul_sync_done(HCS * pCurHcb);
-static int wdtr_done(HCS * pCurHcb);
-static int wait_tulip(HCS * pCurHcb);
-static int tul_wait_done_disc(HCS * pCurHcb);
-static int tul_wait_disc(HCS * pCurHcb);
-static void tulip_scsi(HCS * pCurHcb);
-static int tul_post_scsi_rst(HCS * pCurHcb);
-
-static void tul_se2_ew_en(WORD CurBase);
-static void tul_se2_ew_ds(WORD CurBase);
-static int tul_se2_rd_all(WORD CurBase);
-static void tul_se2_update_all(WORD CurBase);	/* setup default pattern */
-static void tul_read_eeprom(WORD CurBase);
-
-				/* ---- EXTERNAL VARIABLES ---- */
-HCS tul_hcs[MAX_SUPPORTED_ADAPTERS];
-				/* ---- INTERNAL VARIABLES ---- */
-static INI_ADPT_STRUCT i91u_adpt[MAX_SUPPORTED_ADAPTERS];
-
-/*NVRAM nvram, *nvramp = &nvram; */
-static NVRAM i91unvram;
-static NVRAM *i91unvramp;
-
-
-
-static UCHAR i91udftNvRam[64] =
-{
-/*----------- header -----------*/
-	0x25, 0xc9,		/* Signature    */
-	0x40,			/* Size         */
-	0x01,			/* Revision     */
-	/* -- Host Adapter Structure -- */
-	0x95,			/* ModelByte0   */
-	0x00,			/* ModelByte1   */
-	0x00,			/* ModelInfo    */
-	0x01,			/* NumOfCh      */
-	NBC1_DEFAULT,		/* BIOSConfig1  */
-	0,			/* BIOSConfig2  */
-	0,			/* HAConfig1    */
-	0,			/* HAConfig2    */
-	/* SCSI channel 0 and target Structure  */
-	7,			/* SCSIid       */
-	NCC1_DEFAULT,		/* SCSIconfig1  */
-	0,			/* SCSIconfig2  */
-	0x10,			/* NumSCSItarget */
-
-	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
-	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
-	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
-	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
-
-	/* SCSI channel 1 and target Structure  */
-	7,			/* SCSIid       */
-	NCC1_DEFAULT,		/* SCSIconfig1  */
-	0,			/* SCSIconfig2  */
-	0x10,			/* NumSCSItarget */
-
-	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
-	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
-	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
-	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0};			/*      - CheckSum -            */
-
-
-static UCHAR tul_rate_tbl[8] =	/* fast 20      */
-{
-				/* nanosecond devide by 4 */
-	12,			/* 50ns,  20M   */
-	18,			/* 75ns,  13.3M */
-	25,			/* 100ns, 10M   */
-	31,			/* 125ns, 8M    */
-	37,			/* 150ns, 6.6M  */
-	43,			/* 175ns, 5.7M  */
-	50,			/* 200ns, 5M    */
-	62			/* 250ns, 4M    */
-};
-
-extern int tul_num_ch;
-
-
-static void tul_do_pause(unsigned amount)
-{				/* Pause for amount jiffies */
-	unsigned long the_time = jiffies + amount;
-
-	while (time_before_eq(jiffies, the_time));
-}
-
-/*-- forward reference --*/
-
-/*******************************************************************
-	Use memeory refresh time        ~ 15us * 2
-********************************************************************/
-void tul_se2_wait()
-{
-#if 1
-	udelay(30);
-#else
-	UCHAR readByte;
-
-	readByte = TUL_RD(0, 0x61);
-	if ((readByte & 0x10) == 0x10) {
-		for (;;) {
-			readByte = TUL_RD(0, 0x61);
-			if ((readByte & 0x10) == 0x10)
-				break;
-		}
-		for (;;) {
-			readByte = TUL_RD(0, 0x61);
-			if ((readByte & 0x10) != 0x10)
-				break;
-		}
-	} else {
-		for (;;) {
-			readByte = TUL_RD(0, 0x61);
-			if ((readByte & 0x10) == 0x10)
-				break;
-		}
-		for (;;) {
-			readByte = TUL_RD(0, 0x61);
-			if ((readByte & 0x10) != 0x10)
-				break;
-		}
-	}
-#endif
-}
-
-
-/******************************************************************
- Input: instruction for  Serial E2PROM
-
- EX: se2_rd(0 call se2_instr() to send address and read command
-
-	 StartBit  OP_Code   Address                Data
-	 --------- --------  ------------------     -------
-	 1         1 , 0     A5,A4,A3,A2,A1,A0      D15-D0
-
-		 +-----------------------------------------------------
-		 |
- CS -----+
-			+--+  +--+  +--+  +--+  +--+
-			^  |  ^  |  ^  |  ^  |  ^  |
-			|  |  |  |  |  |  |  |  |  |
- CLK -------+  +--+  +--+  +--+  +--+  +--
- (leading edge trigger)
-
-		 +--1-----1--+
-		 | SB    OP  |  OP    A5    A4
- DI  ----+           +--0------------------
- (address and cmd sent to nvram)
-
-	 -------------------------------------------+
-												|
- DO                                             +---
- (data sent from nvram)
-
-
-******************************************************************/
-void tul_se2_instr(WORD CurBase, UCHAR instr)
-{
-	int i;
-	UCHAR b;
-
-	TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2DO);	/* cs+start bit */
-	tul_se2_wait();
-	TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK | SE2DO);	/* +CLK */
-	tul_se2_wait();
-
-	for (i = 0; i < 8; i++) {
-		if (instr & 0x80)
-			b = SE2CS | SE2DO;	/* -CLK+dataBit */
-		else
-			b = SE2CS;	/* -CLK */
-		TUL_WR(CurBase + TUL_NVRAM, b);
-		tul_se2_wait();
-		TUL_WR(CurBase + TUL_NVRAM, b | SE2CLK);	/* +CLK */
-		tul_se2_wait();
-		instr <<= 1;
-	}
-	TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK */
-	tul_se2_wait();
-	return;
-}
-
-
-/******************************************************************
- Function name  : tul_se2_ew_en
- Description    : Enable erase/write state of serial EEPROM
-******************************************************************/
-void tul_se2_ew_en(WORD CurBase)
-{
-	tul_se2_instr(CurBase, 0x30);	/* EWEN */
-	TUL_WR(CurBase + TUL_NVRAM, 0);		/* -CS  */
-	tul_se2_wait();
-	return;
-}
-
-
-/************************************************************************
- Disable erase/write state of serial EEPROM
-*************************************************************************/
-void tul_se2_ew_ds(WORD CurBase)
-{
-	tul_se2_instr(CurBase, 0);	/* EWDS */
-	TUL_WR(CurBase + TUL_NVRAM, 0);		/* -CS  */
-	tul_se2_wait();
-	return;
-}
-
-
-/******************************************************************
-	Input  :address of Serial E2PROM
-	Output :value stored in  Serial E2PROM
-*******************************************************************/
-USHORT tul_se2_rd(WORD CurBase, ULONG adr)
-{
-	UCHAR instr, readByte;
-	USHORT readWord;
-	int i;
-
-	instr = (UCHAR) (adr | 0x80);
-	tul_se2_instr(CurBase, instr);	/* READ INSTR */
-	readWord = 0;
-
-	for (i = 15; i >= 0; i--) {
-		TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK);	/* +CLK */
-		tul_se2_wait();
-		TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK */
-
-		/* sample data after the following edge of clock  */
-		readByte = TUL_RD(CurBase, TUL_NVRAM);
-		readByte &= SE2DI;
-		readWord += (readByte << i);
-		tul_se2_wait();	/* 6/20/95 */
-	}
-
-	TUL_WR(CurBase + TUL_NVRAM, 0);		/* no chip select */
-	tul_se2_wait();
-	return readWord;
-}
-
-
-/******************************************************************
- Input: new value in  Serial E2PROM, address of Serial E2PROM
-*******************************************************************/
-void tul_se2_wr(WORD CurBase, UCHAR adr, USHORT writeWord)
-{
-	UCHAR readByte;
-	UCHAR instr;
-	int i;
-
-	instr = (UCHAR) (adr | 0x40);
-	tul_se2_instr(CurBase, instr);	/* WRITE INSTR */
-	for (i = 15; i >= 0; i--) {
-		if (writeWord & 0x8000)
-			TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2DO);	/* -CLK+dataBit 1 */
-		else
-			TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK+dataBit 0 */
-		tul_se2_wait();
-		TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK);	/* +CLK */
-		tul_se2_wait();
-		writeWord <<= 1;
-	}
-	TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK */
-	tul_se2_wait();
-	TUL_WR(CurBase + TUL_NVRAM, 0);		/* -CS  */
-	tul_se2_wait();
-
-	TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* +CS  */
-	tul_se2_wait();
-
-	for (;;) {
-		TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK);	/* +CLK */
-		tul_se2_wait();
-		TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK */
-		tul_se2_wait();
-		if ((readByte = TUL_RD(CurBase, TUL_NVRAM)) & SE2DI)
-			break;	/* write complete */
-	}
-	TUL_WR(CurBase + TUL_NVRAM, 0);		/* -CS */
-	return;
-}
-
-
-/***********************************************************************
- Read SCSI H/A configuration parameters from serial EEPROM
-************************************************************************/
-int tul_se2_rd_all(WORD CurBase)
-{
-	int i;
-	ULONG chksum = 0;
-	USHORT *np;
-
-	i91unvramp = &i91unvram;
-	np = (USHORT *) i91unvramp;
-	for (i = 0; i < 32; i++) {
-		*np++ = tul_se2_rd(CurBase, i);
-	}
-
-/*--------------------Is signature "ini" ok ? ----------------*/
-	if (i91unvramp->NVM_Signature != INI_SIGNATURE)
-		return -1;
-/*---------------------- Is ckecksum ok ? ----------------------*/
-	np = (USHORT *) i91unvramp;
-	for (i = 0; i < 31; i++)
-		chksum += *np++;
-	if (i91unvramp->NVM_CheckSum != (USHORT) chksum)
-		return -1;
-	return 1;
-}
-
-
-/***********************************************************************
- Update SCSI H/A configuration parameters from serial EEPROM
-************************************************************************/
-void tul_se2_update_all(WORD CurBase)
-{				/* setup default pattern */
-	int i;
-	ULONG chksum = 0;
-	USHORT *np, *np1;
-
-	i91unvramp = &i91unvram;
-	/* Calculate checksum first */
-	np = (USHORT *) i91udftNvRam;
-	for (i = 0; i < 31; i++)
-		chksum += *np++;
-	*np = (USHORT) chksum;
-	tul_se2_ew_en(CurBase);	/* Enable write  */
-
-	np = (USHORT *) i91udftNvRam;
-	np1 = (USHORT *) i91unvramp;
-	for (i = 0; i < 32; i++, np++, np1++) {
-		if (*np != *np1) {
-			tul_se2_wr(CurBase, i, *np);
-		}
-	}
-
-	tul_se2_ew_ds(CurBase);	/* Disable write   */
-	return;
-}
-
-/*************************************************************************
- Function name  : read_eeprom
-**************************************************************************/
-void tul_read_eeprom(WORD CurBase)
-{
-	UCHAR gctrl;
-
-	i91unvramp = &i91unvram;
-/*------Enable EEProm programming ---*/
-	gctrl = TUL_RD(CurBase, TUL_GCTRL);
-	TUL_WR(CurBase + TUL_GCTRL, gctrl | TUL_GCTRL_EEPROM_BIT);
-	if (tul_se2_rd_all(CurBase) != 1) {
-		tul_se2_update_all(CurBase);	/* setup default pattern */
-		tul_se2_rd_all(CurBase);	/* load again  */
-	}
-/*------ Disable EEProm programming ---*/
-	gctrl = TUL_RD(CurBase, TUL_GCTRL);
-	TUL_WR(CurBase + TUL_GCTRL, gctrl & ~TUL_GCTRL_EEPROM_BIT);
-}				/* read_eeprom */
-
-int Addi91u_into_Adapter_table(WORD wBIOS, WORD wBASE, BYTE bInterrupt,
-			       BYTE bBus, BYTE bDevice)
-{
-	int i, j;
-
-	for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) {
-		if (i91u_adpt[i].ADPT_BIOS < wBIOS)
-			continue;
-		if (i91u_adpt[i].ADPT_BIOS == wBIOS) {
-			if (i91u_adpt[i].ADPT_BASE == wBASE) {
-				if (i91u_adpt[i].ADPT_Bus != 0xFF)
-					return (FAILURE);
-			} else if (i91u_adpt[i].ADPT_BASE < wBASE)
-					continue;
-		}
-		for (j = MAX_SUPPORTED_ADAPTERS - 1; j > i; j--) {
-			i91u_adpt[j].ADPT_BASE = i91u_adpt[j - 1].ADPT_BASE;
-			i91u_adpt[j].ADPT_INTR = i91u_adpt[j - 1].ADPT_INTR;
-			i91u_adpt[j].ADPT_BIOS = i91u_adpt[j - 1].ADPT_BIOS;
-			i91u_adpt[j].ADPT_Bus = i91u_adpt[j - 1].ADPT_Bus;
-			i91u_adpt[j].ADPT_Device = i91u_adpt[j - 1].ADPT_Device;
-		}
-		i91u_adpt[i].ADPT_BASE = wBASE;
-		i91u_adpt[i].ADPT_INTR = bInterrupt;
-		i91u_adpt[i].ADPT_BIOS = wBIOS;
-		i91u_adpt[i].ADPT_Bus = bBus;
-		i91u_adpt[i].ADPT_Device = bDevice;
-		return (SUCCESSFUL);
-	}
-	return (FAILURE);
-}
-
-void init_i91uAdapter_table(void)
-{
-	int i;
-
-	for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) {	/* Initialize adapter structure */
-		i91u_adpt[i].ADPT_BIOS = 0xffff;
-		i91u_adpt[i].ADPT_BASE = 0xffff;
-		i91u_adpt[i].ADPT_INTR = 0xff;
-		i91u_adpt[i].ADPT_Bus = 0xff;
-		i91u_adpt[i].ADPT_Device = 0xff;
-	}
-	return;
-}
-
-void tul_stop_bm(HCS * pCurHcb)
-{
-
-	if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) {	/* if DMA xfer is pending, abort DMA xfer */
-		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT | TAX_X_CLR_FIFO);
-		/* wait Abort DMA xfer done */
-		while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & XABT) == 0);
-	}
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-}
-
-/***************************************************************************/
-void get_tulipPCIConfig(HCS * pCurHcb, int ch_idx)
-{
-	pCurHcb->HCS_Base = i91u_adpt[ch_idx].ADPT_BASE;	/* Supply base address  */
-	pCurHcb->HCS_BIOS = i91u_adpt[ch_idx].ADPT_BIOS;	/* Supply BIOS address  */
-	pCurHcb->HCS_Intr = i91u_adpt[ch_idx].ADPT_INTR;	/* Supply interrupt line */
-	return;
-}
-
-/***************************************************************************/
-int tul_reset_scsi(HCS * pCurHcb, int seconds)
-{
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_RST_BUS);
-
-	while (!((pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt)) & TSS_SCSIRST_INT));
-	/* reset tulip chip */
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, 0);
-
-	/* Stall for a while, wait for target's firmware ready,make it 2 sec ! */
-	/* SONY 5200 tape drive won't work if only stall for 1 sec */
-	tul_do_pause(seconds * HZ);
-
-	TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
-
-	return (SCSI_RESET_SUCCESS);
-}
-
-/***************************************************************************/
-int init_tulip(HCS * pCurHcb, SCB * scbp, int tul_num_scb, BYTE * pbBiosAdr, int seconds)
-{
-	int i;
-	BYTE *pwFlags;
-	BYTE *pbHeads;
-	SCB *pTmpScb, *pPrevScb = NULL;
-
-	pCurHcb->HCS_NumScbs = tul_num_scb;
-	pCurHcb->HCS_Semaph = 1;
-	pCurHcb->HCS_SemaphLock = SPIN_LOCK_UNLOCKED;
-	pCurHcb->HCS_JSStatus0 = 0;
-	pCurHcb->HCS_Scb = scbp;
-	pCurHcb->HCS_NxtPend = scbp;
-	pCurHcb->HCS_NxtAvail = scbp;
-	for (i = 0, pTmpScb = scbp; i < tul_num_scb; i++, pTmpScb++) {
-		pTmpScb->SCB_TagId = i;
-		if (i != 0)
-			pPrevScb->SCB_NxtScb = pTmpScb;
-		pPrevScb = pTmpScb;
-	}
-	pPrevScb->SCB_NxtScb = NULL;
-	pCurHcb->HCS_ScbEnd = pTmpScb;
-	pCurHcb->HCS_FirstAvail = scbp;
-	pCurHcb->HCS_LastAvail = pPrevScb;
-	pCurHcb->HCS_AvailLock = SPIN_LOCK_UNLOCKED;
-	pCurHcb->HCS_FirstPend = NULL;
-	pCurHcb->HCS_LastPend = NULL;
-	pCurHcb->HCS_FirstBusy = NULL;
-	pCurHcb->HCS_LastBusy = NULL;
-	pCurHcb->HCS_FirstDone = NULL;
-	pCurHcb->HCS_LastDone = NULL;
-	pCurHcb->HCS_ActScb = NULL;
-	pCurHcb->HCS_ActTcs = NULL;
-
-	tul_read_eeprom(pCurHcb->HCS_Base);
-/*---------- get H/A configuration -------------*/
-	if (i91unvramp->NVM_SCSIInfo[0].NVM_NumOfTarg == 8)
-		pCurHcb->HCS_MaxTar = 8;
-	else
-		pCurHcb->HCS_MaxTar = 16;
-
-	pCurHcb->HCS_Config = i91unvramp->NVM_SCSIInfo[0].NVM_ChConfig1;
-
-	pCurHcb->HCS_SCSI_ID = i91unvramp->NVM_SCSIInfo[0].NVM_ChSCSIID;
-	pCurHcb->HCS_IdMask = ~(1 << pCurHcb->HCS_SCSI_ID);
-
-#if CHK_PARITY
-	/* Enable parity error response */
-	TUL_WR(pCurHcb->HCS_Base + TUL_PCMD, TUL_RD(pCurHcb->HCS_Base, TUL_PCMD) | 0x40);
-#endif
-
-	/* Mask all the interrupt       */
-	TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
-
-	tul_stop_bm(pCurHcb);
-	/* --- Initialize the tulip --- */
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_RST_CHIP);
-
-	/* program HBA's SCSI ID        */
-	TUL_WR(pCurHcb->HCS_Base + TUL_SScsiId, pCurHcb->HCS_SCSI_ID << 4);
-
-	/* Enable Initiator Mode ,phase latch,alternate sync period mode,
-	   disable SCSI reset */
-	if (pCurHcb->HCS_Config & HCC_EN_PAR)
-		pCurHcb->HCS_SConf1 = (TSC_INITDEFAULT | TSC_EN_SCSI_PAR);
-	else
-		pCurHcb->HCS_SConf1 = (TSC_INITDEFAULT);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_SConf1);
-
-	/* Enable HW reselect           */
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, 0);
-
-	/* selection time out = 250 ms */
-	TUL_WR(pCurHcb->HCS_Base + TUL_STimeOut, 153);
-
-/*--------- Enable SCSI terminator -----*/
-	TUL_WR(pCurHcb->HCS_Base + TUL_XCtrl, (pCurHcb->HCS_Config & (HCC_ACT_TERM1 | HCC_ACT_TERM2)));
-	TUL_WR(pCurHcb->HCS_Base + TUL_GCTRL1,
-	       ((pCurHcb->HCS_Config & HCC_AUTO_TERM) >> 4) | (TUL_RD(pCurHcb->HCS_Base, TUL_GCTRL1) & 0xFE));
-
-	for (i = 0,
-	     pwFlags = & (i91unvramp->NVM_SCSIInfo[0].NVM_Targ0Config),
-	     pbHeads = pbBiosAdr + 0x180;
-	     i < pCurHcb->HCS_MaxTar;
-	     i++, pwFlags++) {
-		pCurHcb->HCS_Tcs[i].TCS_Flags = *pwFlags & ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
-		if (pCurHcb->HCS_Tcs[i].TCS_Flags & TCF_EN_255)
-			pCurHcb->HCS_Tcs[i].TCS_DrvFlags = TCF_DRV_255_63;
-		else
-			pCurHcb->HCS_Tcs[i].TCS_DrvFlags = 0;
-		pCurHcb->HCS_Tcs[i].TCS_JS_Period = 0;
-		pCurHcb->HCS_Tcs[i].TCS_SConfig0 = pCurHcb->HCS_SConf1;
-		pCurHcb->HCS_Tcs[i].TCS_DrvHead = *pbHeads++;
-		if (pCurHcb->HCS_Tcs[i].TCS_DrvHead == 255)
-			pCurHcb->HCS_Tcs[i].TCS_DrvFlags = TCF_DRV_255_63;
-		else
-			pCurHcb->HCS_Tcs[i].TCS_DrvFlags = 0;
-		pCurHcb->HCS_Tcs[i].TCS_DrvSector = *pbHeads++;
-		pCurHcb->HCS_Tcs[i].TCS_Flags &= ~TCF_BUSY;
-		pCurHcb->HCS_ActTags[i] = 0;
-		pCurHcb->HCS_MaxTags[i] = 0xFF;
-	}			/* for                          */
-	printk("i91u: PCI Base=0x%04X, IRQ=%d, BIOS=0x%04X0, SCSI ID=%d\n",
-	       pCurHcb->HCS_Base, pCurHcb->HCS_Intr,
-	       pCurHcb->HCS_BIOS, pCurHcb->HCS_SCSI_ID);
-/*------------------- reset SCSI Bus ---------------------------*/
-	if (pCurHcb->HCS_Config & HCC_SCSI_RESET) {
-		printk("i91u: Reset SCSI Bus ... \n");
-		tul_reset_scsi(pCurHcb, seconds);
-	}
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCFG1, 0x17);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SIntEnable, 0xE9);
-	return (0);
-}
-
-/***************************************************************************/
-SCB *tul_alloc_scb(HCS * hcsp)
-{
-	SCB *pTmpScb;
-	ULONG flags;
-	spin_lock_irqsave(&(hcsp->HCS_AvailLock), flags);
-	if ((pTmpScb = hcsp->HCS_FirstAvail) != NULL) {
-#if DEBUG_QUEUE
-		printk("find scb at %08lx\n", (ULONG) pTmpScb);
-#endif
-		if ((hcsp->HCS_FirstAvail = pTmpScb->SCB_NxtScb) == NULL)
-			hcsp->HCS_LastAvail = NULL;
-		pTmpScb->SCB_NxtScb = NULL;
-		pTmpScb->SCB_Status = SCB_RENT;
-	}
-	spin_unlock_irqrestore(&(hcsp->HCS_AvailLock), flags);
-	return (pTmpScb);
-}
-
-/***************************************************************************/
-void tul_release_scb(HCS * hcsp, SCB * scbp)
-{
-	ULONG flags;
-
-#if DEBUG_QUEUE
-	printk("Release SCB %lx; ", (ULONG) scbp);
-#endif
-	spin_lock_irqsave(&(hcsp->HCS_AvailLock), flags);
-	scbp->SCB_Srb = 0;
-	scbp->SCB_Status = 0;
-	scbp->SCB_NxtScb = NULL;
-	if (hcsp->HCS_LastAvail != NULL) {
-		hcsp->HCS_LastAvail->SCB_NxtScb = scbp;
-		hcsp->HCS_LastAvail = scbp;
-	} else {
-		hcsp->HCS_FirstAvail = scbp;
-		hcsp->HCS_LastAvail = scbp;
-	}
-	spin_unlock_irqrestore(&(hcsp->HCS_AvailLock), flags);
-}
-
-/***************************************************************************/
-void tul_append_pend_scb(HCS * pCurHcb, SCB * scbp)
-{
-
-#if DEBUG_QUEUE
-	printk("Append pend SCB %lx; ", (ULONG) scbp);
-#endif
-	scbp->SCB_Status = SCB_PEND;
-	scbp->SCB_NxtScb = NULL;
-	if (pCurHcb->HCS_LastPend != NULL) {
-		pCurHcb->HCS_LastPend->SCB_NxtScb = scbp;
-		pCurHcb->HCS_LastPend = scbp;
-	} else {
-		pCurHcb->HCS_FirstPend = scbp;
-		pCurHcb->HCS_LastPend = scbp;
-	}
-}
-
-/***************************************************************************/
-void tul_push_pend_scb(HCS * pCurHcb, SCB * scbp)
-{
-
-#if DEBUG_QUEUE
-	printk("Push pend SCB %lx; ", (ULONG) scbp);
-#endif
-	scbp->SCB_Status = SCB_PEND;
-	if ((scbp->SCB_NxtScb = pCurHcb->HCS_FirstPend) != NULL) {
-		pCurHcb->HCS_FirstPend = scbp;
-	} else {
-		pCurHcb->HCS_FirstPend = scbp;
-		pCurHcb->HCS_LastPend = scbp;
-	}
-}
-
-/***************************************************************************/
-SCB *tul_find_first_pend_scb(HCS * pCurHcb)
-{
-	SCB *pFirstPend;
-
-
-	pFirstPend = pCurHcb->HCS_FirstPend;
-	while (pFirstPend != NULL) {
-		if (pFirstPend->SCB_Opcode != ExecSCSI) {
-			return (pFirstPend);
-		}
-		if (pFirstPend->SCB_TagMsg == 0) {
-			if ((pCurHcb->HCS_ActTags[pFirstPend->SCB_Target] == 0) &&
-			    !(pCurHcb->HCS_Tcs[pFirstPend->SCB_Target].TCS_Flags & TCF_BUSY)) {
-				return (pFirstPend);
-			}
-		} else {
-			if ((pCurHcb->HCS_ActTags[pFirstPend->SCB_Target] >=
-			  pCurHcb->HCS_MaxTags[pFirstPend->SCB_Target]) |
-			    (pCurHcb->HCS_Tcs[pFirstPend->SCB_Target].TCS_Flags & TCF_BUSY)) {
-				pFirstPend = pFirstPend->SCB_NxtScb;
-				continue;
-			}
-			return (pFirstPend);
-		}
-		pFirstPend = pFirstPend->SCB_NxtScb;
-	}
-
-
-	return (pFirstPend);
-}
-/***************************************************************************/
-SCB *tul_pop_pend_scb(HCS * pCurHcb)
-{
-	SCB *pTmpScb;
-
-	if ((pTmpScb = pCurHcb->HCS_FirstPend) != NULL) {
-		if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL)
-			pCurHcb->HCS_LastPend = NULL;
-		pTmpScb->SCB_NxtScb = NULL;
-	}
-#if DEBUG_QUEUE
-	printk("Pop pend SCB %lx; ", (ULONG) pTmpScb);
-#endif
-	return (pTmpScb);
-}
-
-
-/***************************************************************************/
-void tul_unlink_pend_scb(HCS * pCurHcb, SCB * pCurScb)
-{
-	SCB *pTmpScb, *pPrevScb;
-
-#if DEBUG_QUEUE
-	printk("unlink pend SCB %lx; ", (ULONG) pCurScb);
-#endif
-
-	pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend;
-	while (pTmpScb != NULL) {
-		if (pCurScb == pTmpScb) {	/* Unlink this SCB              */
-			if (pTmpScb == pCurHcb->HCS_FirstPend) {
-				if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL)
-					pCurHcb->HCS_LastPend = NULL;
-			} else {
-				pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
-				if (pTmpScb == pCurHcb->HCS_LastPend)
-					pCurHcb->HCS_LastPend = pPrevScb;
-			}
-			pTmpScb->SCB_NxtScb = NULL;
-			break;
-		}
-		pPrevScb = pTmpScb;
-		pTmpScb = pTmpScb->SCB_NxtScb;
-	}
-	return;
-}
-/***************************************************************************/
-void tul_append_busy_scb(HCS * pCurHcb, SCB * scbp)
-{
-
-#if DEBUG_QUEUE
-	printk("append busy SCB %lx; ", (ULONG) scbp);
-#endif
-	if (scbp->SCB_TagMsg)
-		pCurHcb->HCS_ActTags[scbp->SCB_Target]++;
-	else
-		pCurHcb->HCS_Tcs[scbp->SCB_Target].TCS_Flags |= TCF_BUSY;
-	scbp->SCB_Status = SCB_BUSY;
-	scbp->SCB_NxtScb = NULL;
-	if (pCurHcb->HCS_LastBusy != NULL) {
-		pCurHcb->HCS_LastBusy->SCB_NxtScb = scbp;
-		pCurHcb->HCS_LastBusy = scbp;
-	} else {
-		pCurHcb->HCS_FirstBusy = scbp;
-		pCurHcb->HCS_LastBusy = scbp;
-	}
-}
-
-/***************************************************************************/
-SCB *tul_pop_busy_scb(HCS * pCurHcb)
-{
-	SCB *pTmpScb;
-
-
-	if ((pTmpScb = pCurHcb->HCS_FirstBusy) != NULL) {
-		if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL)
-			pCurHcb->HCS_LastBusy = NULL;
-		pTmpScb->SCB_NxtScb = NULL;
-		if (pTmpScb->SCB_TagMsg)
-			pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--;
-		else
-			pCurHcb->HCS_Tcs[pTmpScb->SCB_Target].TCS_Flags &= ~TCF_BUSY;
-	}
-#if DEBUG_QUEUE
-	printk("Pop busy SCB %lx; ", (ULONG) pTmpScb);
-#endif
-	return (pTmpScb);
-}
-
-/***************************************************************************/
-void tul_unlink_busy_scb(HCS * pCurHcb, SCB * pCurScb)
-{
-	SCB *pTmpScb, *pPrevScb;
-
-#if DEBUG_QUEUE
-	printk("unlink busy SCB %lx; ", (ULONG) pCurScb);
-#endif
-
-	pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;
-	while (pTmpScb != NULL) {
-		if (pCurScb == pTmpScb) {	/* Unlink this SCB              */
-			if (pTmpScb == pCurHcb->HCS_FirstBusy) {
-				if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL)
-					pCurHcb->HCS_LastBusy = NULL;
-			} else {
-				pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
-				if (pTmpScb == pCurHcb->HCS_LastBusy)
-					pCurHcb->HCS_LastBusy = pPrevScb;
-			}
-			pTmpScb->SCB_NxtScb = NULL;
-			if (pTmpScb->SCB_TagMsg)
-				pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--;
-			else
-				pCurHcb->HCS_Tcs[pTmpScb->SCB_Target].TCS_Flags &= ~TCF_BUSY;
-			break;
-		}
-		pPrevScb = pTmpScb;
-		pTmpScb = pTmpScb->SCB_NxtScb;
-	}
-	return;
-}
-
-/***************************************************************************/
-SCB *tul_find_busy_scb(HCS * pCurHcb, WORD tarlun)
-{
-	SCB *pTmpScb, *pPrevScb;
-	WORD scbp_tarlun;
-
-
-	pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;
-	while (pTmpScb != NULL) {
-		scbp_tarlun = (pTmpScb->SCB_Lun << 8) | (pTmpScb->SCB_Target);
-		if (scbp_tarlun == tarlun) {	/* Unlink this SCB              */
-			break;
-		}
-		pPrevScb = pTmpScb;
-		pTmpScb = pTmpScb->SCB_NxtScb;
-	}
-#if DEBUG_QUEUE
-	printk("find busy SCB %lx; ", (ULONG) pTmpScb);
-#endif
-	return (pTmpScb);
-}
-
-/***************************************************************************/
-void tul_append_done_scb(HCS * pCurHcb, SCB * scbp)
-{
-
-#if DEBUG_QUEUE
-	printk("append done SCB %lx; ", (ULONG) scbp);
-#endif
-
-	scbp->SCB_Status = SCB_DONE;
-	scbp->SCB_NxtScb = NULL;
-	if (pCurHcb->HCS_LastDone != NULL) {
-		pCurHcb->HCS_LastDone->SCB_NxtScb = scbp;
-		pCurHcb->HCS_LastDone = scbp;
-	} else {
-		pCurHcb->HCS_FirstDone = scbp;
-		pCurHcb->HCS_LastDone = scbp;
-	}
-}
-
-/***************************************************************************/
-SCB *tul_find_done_scb(HCS * pCurHcb)
-{
-	SCB *pTmpScb;
-
-
-	if ((pTmpScb = pCurHcb->HCS_FirstDone) != NULL) {
-		if ((pCurHcb->HCS_FirstDone = pTmpScb->SCB_NxtScb) == NULL)
-			pCurHcb->HCS_LastDone = NULL;
-		pTmpScb->SCB_NxtScb = NULL;
-	}
-#if DEBUG_QUEUE
-	printk("find done SCB %lx; ", (ULONG) pTmpScb);
-#endif
-	return (pTmpScb);
-}
-
-/***************************************************************************/
-int tul_abort_srb(HCS * pCurHcb, ULONG srbp)
-{
-	ULONG flags;
-	SCB *pTmpScb, *pPrevScb;
-
-	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-
-	if ((pCurHcb->HCS_Semaph == 0) && (pCurHcb->HCS_ActScb == NULL)) {
-		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
-		/* disable Jasmin SCSI Int        */
-
-                spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-
-		tulip_main(pCurHcb);
-
-        	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-
-		pCurHcb->HCS_Semaph = 1;
-		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
-
-		spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-
-		return SCSI_ABORT_SNOOZE;
-	}
-	pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend;	/* Check Pend queue */
-	while (pTmpScb != NULL) {
-		/* 07/27/98 */
-		if (pTmpScb->SCB_Srb == (unsigned char *) srbp) {
-			if (pTmpScb == pCurHcb->HCS_ActScb) {
-				spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-				return SCSI_ABORT_BUSY;
-			} else if (pTmpScb == pCurHcb->HCS_FirstPend) {
-				if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL)
-					pCurHcb->HCS_LastPend = NULL;
-			} else {
-				pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
-				if (pTmpScb == pCurHcb->HCS_LastPend)
-					pCurHcb->HCS_LastPend = pPrevScb;
-			}
-			pTmpScb->SCB_HaStat = HOST_ABORTED;
-			pTmpScb->SCB_Flags |= SCF_DONE;
-			if (pTmpScb->SCB_Flags & SCF_POST)
-				(*pTmpScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pTmpScb);
-			spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-			return SCSI_ABORT_SUCCESS;
-		}
-		pPrevScb = pTmpScb;
-		pTmpScb = pTmpScb->SCB_NxtScb;
-	}
-
-	pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;	/* Check Busy queue */
-	while (pTmpScb != NULL) {
-
-		if (pTmpScb->SCB_Srb == (unsigned char *) srbp) {
-
-			if (pTmpScb == pCurHcb->HCS_ActScb) {
-				spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-				return SCSI_ABORT_BUSY;
-			} else if (pTmpScb->SCB_TagMsg == 0) {
-				spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-				return SCSI_ABORT_BUSY;
-			} else {
-				pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--;
-				if (pTmpScb == pCurHcb->HCS_FirstBusy) {
-					if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL)
-						pCurHcb->HCS_LastBusy = NULL;
-				} else {
-					pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
-					if (pTmpScb == pCurHcb->HCS_LastBusy)
-						pCurHcb->HCS_LastBusy = pPrevScb;
-				}
-				pTmpScb->SCB_NxtScb = NULL;
-
-
-				pTmpScb->SCB_HaStat = HOST_ABORTED;
-				pTmpScb->SCB_Flags |= SCF_DONE;
-				if (pTmpScb->SCB_Flags & SCF_POST)
-					(*pTmpScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pTmpScb);
-				spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-				return SCSI_ABORT_SUCCESS;
-			}
-		}
-		pPrevScb = pTmpScb;
-		pTmpScb = pTmpScb->SCB_NxtScb;
-	}
-	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-	return (SCSI_ABORT_NOT_RUNNING);
-}
-
-/***************************************************************************/
-int tul_bad_seq(HCS * pCurHcb)
-{
-	SCB *pCurScb;
-
-	printk("tul_bad_seg c=%d\n", pCurHcb->HCS_Index);
-
-	if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) {
-		tul_unlink_busy_scb(pCurHcb, pCurScb);
-		pCurScb->SCB_HaStat = HOST_BAD_PHAS;
-		pCurScb->SCB_TaStat = 0;
-		tul_append_done_scb(pCurHcb, pCurScb);
-	}
-	tul_stop_bm(pCurHcb);
-
-	tul_reset_scsi(pCurHcb, 8);	/* 7/29/98 */
-
-	return (tul_post_scsi_rst(pCurHcb));
-}
-
-/************************************************************************/
-int tul_device_reset(HCS * pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags)
-{
-	ULONG flags;
-	SCB *pScb;
-	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-
-	if (ResetFlags & SCSI_RESET_ASYNCHRONOUS) {
-
-		if ((pCurHcb->HCS_Semaph == 0) && (pCurHcb->HCS_ActScb == NULL)) {
-			TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
-			/* disable Jasmin SCSI Int        */
-
-        		spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-
-			tulip_main(pCurHcb);
-
-        		spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-
-			pCurHcb->HCS_Semaph = 1;
-			TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
-
-			spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-
-			return SCSI_RESET_SNOOZE;
-		}
-		pScb = pCurHcb->HCS_FirstBusy;	/* Check Busy queue */
-		while (pScb != NULL) {
-			if (pScb->SCB_Srb == (unsigned char *) pSrb)
-				break;
-			pScb = pScb->SCB_NxtScb;
-		}
-		if (pScb == NULL) {
-			printk("Unable to Reset - No SCB Found\n");
-
-			spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-			return SCSI_RESET_NOT_RUNNING;
-		}
-	}
-	if ((pScb = tul_alloc_scb(pCurHcb)) == NULL) {
-		spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-		return SCSI_RESET_NOT_RUNNING;
-	}
-	pScb->SCB_Opcode = BusDevRst;
-	pScb->SCB_Flags = SCF_POST;
-	pScb->SCB_Target = target;
-	pScb->SCB_Mode = 0;
-
-	pScb->SCB_Srb = 0;
-	if (ResetFlags & SCSI_RESET_SYNCHRONOUS) {
-		pScb->SCB_Srb = (unsigned char *) pSrb;
-	}
-	tul_push_pend_scb(pCurHcb, pScb);	/* push this SCB to Pending queue */
-
-	if (pCurHcb->HCS_Semaph == 1) {
-		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
-		/* disable Jasmin SCSI Int        */
-		pCurHcb->HCS_Semaph = 0;
-
-        	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-
-		tulip_main(pCurHcb);
-
-                spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-
-		pCurHcb->HCS_Semaph = 1;
-		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
-	}
-	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-	return SCSI_RESET_PENDING;
-}
-
-int tul_reset_scsi_bus(HCS * pCurHcb)
-{
-	ULONG flags;
-
-	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-	TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
-	pCurHcb->HCS_Semaph = 0;
-
-	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-
-	tul_stop_bm(pCurHcb);
-
-	tul_reset_scsi(pCurHcb, 2);	/* 7/29/98 */
-
-	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-	tul_post_scsi_rst(pCurHcb);
-
-        spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-
-	tulip_main(pCurHcb);
-
-        spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-
-	pCurHcb->HCS_Semaph = 1;
-	TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
-	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-	return (SCSI_RESET_SUCCESS | SCSI_RESET_HOST_RESET);
-}
-
-/************************************************************************/
-void tul_exec_scb(HCS * pCurHcb, SCB * pCurScb)
-{
-	ULONG flags;
-
-	pCurScb->SCB_Mode = 0;
-
-	pCurScb->SCB_SGIdx = 0;
-	pCurScb->SCB_SGMax = pCurScb->SCB_SGLen;
-
-	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-
-	tul_append_pend_scb(pCurHcb, pCurScb);	/* Append this SCB to Pending queue */
-
-/* VVVVV 07/21/98 */
-	if (pCurHcb->HCS_Semaph == 1) {
-		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
-		/* disable Jasmin SCSI Int        */
-		pCurHcb->HCS_Semaph = 0;
-
-        	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-
-		tulip_main(pCurHcb);
-
-        	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
-
-		pCurHcb->HCS_Semaph = 1;
-		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
-	}
-	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
-	return;
-}
-
-/***************************************************************************/
-int tul_isr(HCS * pCurHcb)
-{
-	/* Enter critical section       */
-
-	if (TUL_RD(pCurHcb->HCS_Base, TUL_Int) & TSS_INT_PENDING) {
-		if (pCurHcb->HCS_Semaph == 1) {
-			TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
-			/* Disable Tulip SCSI Int */
-			pCurHcb->HCS_Semaph = 0;
-
-			tulip_main(pCurHcb);
-
-			pCurHcb->HCS_Semaph = 1;
-			TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
-			return (1);
-		}
-	}
-	return (0);
-}
-
-/***************************************************************************/
-int tulip_main(HCS * pCurHcb)
-{
-	SCB *pCurScb;
-
-	for (;;) {
-
-		tulip_scsi(pCurHcb);	/* Call tulip_scsi              */
-
-		while ((pCurScb = tul_find_done_scb(pCurHcb)) != NULL) {	/* find done entry */
-			if (pCurScb->SCB_TaStat == QUEUE_FULL) {
-				pCurHcb->HCS_MaxTags[pCurScb->SCB_Target] =
-				    pCurHcb->HCS_ActTags[pCurScb->SCB_Target] - 1;
-				pCurScb->SCB_TaStat = 0;
-				tul_append_pend_scb(pCurHcb, pCurScb);
-				continue;
-			}
-			if (!(pCurScb->SCB_Mode & SCM_RSENS)) {		/* not in auto req. sense mode */
-				if (pCurScb->SCB_TaStat == 2) {
-
-					/* clr sync. nego flag */
-
-					if (pCurScb->SCB_Flags & SCF_SENSE) {
-						BYTE len;
-						len = pCurScb->SCB_SenseLen;
-						if (len == 0)
-							len = 1;
-						pCurScb->SCB_BufLen = pCurScb->SCB_SenseLen;
-						pCurScb->SCB_BufPtr = pCurScb->SCB_SensePtr;
-						pCurScb->SCB_Flags &= ~(SCF_SG | SCF_DIR);	/* for xfer_data_in */
-/*                      pCurScb->SCB_Flags |= SCF_NO_DCHK;      */
-						/* so, we won't report worng direction in xfer_data_in,
-						   and won't report HOST_DO_DU in state_6 */
-						pCurScb->SCB_Mode = SCM_RSENS;
-						pCurScb->SCB_Ident &= 0xBF;	/* Disable Disconnect */
-						pCurScb->SCB_TagMsg = 0;
-						pCurScb->SCB_TaStat = 0;
-						pCurScb->SCB_CDBLen = 6;
-						pCurScb->SCB_CDB[0] = SCSICMD_RequestSense;
-						pCurScb->SCB_CDB[1] = 0;
-						pCurScb->SCB_CDB[2] = 0;
-						pCurScb->SCB_CDB[3] = 0;
-						pCurScb->SCB_CDB[4] = len;
-						pCurScb->SCB_CDB[5] = 0;
-						tul_push_pend_scb(pCurHcb, pCurScb);
-						break;
-					}
-				}
-			} else {	/* in request sense mode */
-
-				if (pCurScb->SCB_TaStat == 2) {		/* check contition status again after sending
-									   requset sense cmd 0x3 */
-					pCurScb->SCB_HaStat = HOST_BAD_PHAS;
-				}
-				pCurScb->SCB_TaStat = 2;
-			}
-			pCurScb->SCB_Flags |= SCF_DONE;
-			if (pCurScb->SCB_Flags & SCF_POST) {
-				(*pCurScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pCurScb);
-			}
-		}		/* while */
-
-		/* find_active: */
-		if (TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0) & TSS_INT_PENDING)
-			continue;
-
-		if (pCurHcb->HCS_ActScb) {	/* return to OS and wait for xfer_done_ISR/Selected_ISR */
-			return 1;	/* return to OS, enable interrupt */
-		}
-		/* Check pending SCB            */
-		if (tul_find_first_pend_scb(pCurHcb) == NULL) {
-			return 1;	/* return to OS, enable interrupt */
-		}
-	}			/* End of for loop */
-	/* statement won't reach here */
-}
-
-
-
-
-/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-/***************************************************************************/
-/***************************************************************************/
-/***************************************************************************/
-/***************************************************************************/
-
-/***************************************************************************/
-void tulip_scsi(HCS * pCurHcb)
-{
-	SCB *pCurScb;
-	TCS *pCurTcb;
-
-	/* make sure to service interrupt asap */
-
-	if ((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0)) & TSS_INT_PENDING) {
-
-		pCurHcb->HCS_Phase = pCurHcb->HCS_JSStatus0 & TSS_PH_MASK;
-		pCurHcb->HCS_JSStatus1 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1);
-		pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
-		if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) {	/* SCSI bus reset detected      */
-			int_tul_scsi_rst(pCurHcb);
-			return;
-		}
-		if (pCurHcb->HCS_JSInt & TSS_RESEL_INT) {	/* if selected/reselected interrupt */
-			if (int_tul_resel(pCurHcb) == 0)
-				tul_next_state(pCurHcb);
-			return;
-		}
-		if (pCurHcb->HCS_JSInt & TSS_SEL_TIMEOUT) {
-			int_tul_busfree(pCurHcb);
-			return;
-		}
-		if (pCurHcb->HCS_JSInt & TSS_DISC_INT) {	/* BUS disconnection            */
-			int_tul_busfree(pCurHcb);	/* unexpected bus free or sel timeout */
-			return;
-		}
-		if (pCurHcb->HCS_JSInt & (TSS_FUNC_COMP | TSS_BUS_SERV)) {	/* func complete or Bus service */
-			if ((pCurScb = pCurHcb->HCS_ActScb) != NULL)
-				tul_next_state(pCurHcb);
-			return;
-		}
-	}
-	if (pCurHcb->HCS_ActScb != NULL)
-		return;
-
-	if ((pCurScb = tul_find_first_pend_scb(pCurHcb)) == NULL)
-		return;
-
-	/* program HBA's SCSI ID & target SCSI ID */
-	TUL_WR(pCurHcb->HCS_Base + TUL_SScsiId,
-	     (pCurHcb->HCS_SCSI_ID << 4) | (pCurScb->SCB_Target & 0x0F));
-	if (pCurScb->SCB_Opcode == ExecSCSI) {
-		pCurTcb = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target];
-
-		if (pCurScb->SCB_TagMsg)
-			pCurTcb->TCS_DrvFlags |= TCF_DRV_EN_TAG;
-		else
-			pCurTcb->TCS_DrvFlags &= ~TCF_DRV_EN_TAG;
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurTcb->TCS_JS_Period);
-		if ((pCurTcb->TCS_Flags & (TCF_WDTR_DONE | TCF_NO_WDTR)) == 0) {	/* do wdtr negotiation          */
-			tul_select_atn_stop(pCurHcb, pCurScb);
-		} else {
-			if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) {	/* do sync negotiation          */
-				tul_select_atn_stop(pCurHcb, pCurScb);
-			} else {
-				if (pCurScb->SCB_TagMsg)
-					tul_select_atn3(pCurHcb, pCurScb);
-				else
-					tul_select_atn(pCurHcb, pCurScb);
-			}
-		}
-		if (pCurScb->SCB_Flags & SCF_POLL) {
-			while (wait_tulip(pCurHcb) != -1) {
-				if (tul_next_state(pCurHcb) == -1)
-					break;
-			}
-		}
-	} else if (pCurScb->SCB_Opcode == BusDevRst) {
-		tul_select_atn_stop(pCurHcb, pCurScb);
-		pCurScb->SCB_NxtStat = 8;
-		if (pCurScb->SCB_Flags & SCF_POLL) {
-			while (wait_tulip(pCurHcb) != -1) {
-				if (tul_next_state(pCurHcb) == -1)
-					break;
-			}
-		}
-	} else if (pCurScb->SCB_Opcode == AbortCmd) {
-		ULONG srbp;
-
-		srbp = (ULONG) pCurScb->SCB_Srb;
-/* 08/03/98 */
-		if (tul_abort_srb(pCurHcb, srbp) != 0) {
-
-
-			tul_unlink_pend_scb(pCurHcb, pCurScb);
-
-			tul_release_scb(pCurHcb, pCurScb);
-		} else {
-			pCurScb->SCB_Opcode = BusDevRst;
-			tul_select_atn_stop(pCurHcb, pCurScb);
-			pCurScb->SCB_NxtStat = 8;
-		}
-
-/* 08/03/98 */
-	} else {
-		tul_unlink_pend_scb(pCurHcb, pCurScb);
-		pCurScb->SCB_HaStat = 0x16;	/* bad command */
-		tul_append_done_scb(pCurHcb, pCurScb);
-	}
-	return;
-}
-
-
-/***************************************************************************/
-int tul_next_state(HCS * pCurHcb)
-{
-	int next;
-
-	next = pCurHcb->HCS_ActScb->SCB_NxtStat;
-	for (;;) {
-		switch (next) {
-		case 1:
-			next = tul_state_1(pCurHcb);
-			break;
-		case 2:
-			next = tul_state_2(pCurHcb);
-			break;
-		case 3:
-			next = tul_state_3(pCurHcb);
-			break;
-		case 4:
-			next = tul_state_4(pCurHcb);
-			break;
-		case 5:
-			next = tul_state_5(pCurHcb);
-			break;
-		case 6:
-			next = tul_state_6(pCurHcb);
-			break;
-		case 7:
-			next = tul_state_7(pCurHcb);
-			break;
-		case 8:
-			return (tul_bus_device_reset(pCurHcb));
-		default:
-			return (tul_bad_seq(pCurHcb));
-		}
-		if (next <= 0)
-			return next;
-	}
-}
-
-
-/***************************************************************************/
-/* sTate after selection with attention & stop */
-int tul_state_1(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
-#if DEBUG_STATE
-	printk("-s1-");
-#endif
-
-	tul_unlink_pend_scb(pCurHcb, pCurScb);
-	tul_append_busy_scb(pCurHcb, pCurScb);
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0);
-	/* ATN on */
-	if (pCurHcb->HCS_Phase == MSG_OUT) {
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, (TSC_EN_BUS_IN | TSC_HW_RESELECT));
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident);
-
-		if (pCurScb->SCB_TagMsg) {
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagMsg);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagId);
-		}
-		if ((pCurTcb->TCS_Flags & (TCF_WDTR_DONE | TCF_NO_WDTR)) == 0) {
-
-			pCurTcb->TCS_Flags |= TCF_WDTR_DONE;
-
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 2);	/* Extended msg length */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);	/* Sync request */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1);	/* Start from 16 bits */
-		} else if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) {
-
-			pCurTcb->TCS_Flags |= TCF_SYNC_DONE;
-
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);	/* extended msg length */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1);	/* sync request */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, tul_rate_tbl[pCurTcb->TCS_Flags & TCF_SCSI_RATE]);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MAX_OFFSET);	/* REQ/ACK offset */
-		}
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-		if (wait_tulip(pCurHcb) == -1)
-			return (-1);
-	}
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)));
-	return (3);
-}
-
-
-/***************************************************************************/
-/* state after selection with attention */
-/* state after selection with attention3 */
-int tul_state_2(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
-#if DEBUG_STATE
-	printk("-s2-");
-#endif
-
-	tul_unlink_pend_scb(pCurHcb, pCurScb);
-	tul_append_busy_scb(pCurHcb, pCurScb);
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0);
-
-	if (pCurHcb->HCS_JSStatus1 & TSS_CMD_PH_CMP) {
-		return (4);
-	}
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)));
-	return (3);
-}
-
-/***************************************************************************/
-/* state before CDB xfer is done */
-int tul_state_3(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
-	int i;
-
-#if DEBUG_STATE
-	printk("-s3-");
-#endif
-	for (;;) {
-		switch (pCurHcb->HCS_Phase) {
-		case CMD_OUT:	/* Command out phase            */
-			for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++)
-				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-			if (wait_tulip(pCurHcb) == -1)
-				return (-1);
-			if (pCurHcb->HCS_Phase == CMD_OUT) {
-				return (tul_bad_seq(pCurHcb));
-			}
-			return (4);
-
-		case MSG_IN:	/* Message in phase             */
-			pCurScb->SCB_NxtStat = 3;
-			if (tul_msgin(pCurHcb) == -1)
-				return (-1);
-			break;
-
-		case STATUS_IN:	/* Status phase                 */
-			if (tul_status_msg(pCurHcb) == -1)
-				return (-1);
-			break;
-
-		case MSG_OUT:	/* Message out phase            */
-			if (pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) {
-
-				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP);		/* msg nop */
-				TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-				if (wait_tulip(pCurHcb) == -1)
-					return (-1);
-
-			} else {
-				pCurTcb->TCS_Flags |= TCF_SYNC_DONE;
-
-				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
-				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);	/* ext. msg len */
-				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1);	/* sync request */
-				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, tul_rate_tbl[pCurTcb->TCS_Flags & TCF_SCSI_RATE]);
-				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MAX_OFFSET);	/* REQ/ACK offset */
-				TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-				if (wait_tulip(pCurHcb) == -1)
-					return (-1);
-				TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-				TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7));
-
-			}
-			break;
-
-		default:
-			return (tul_bad_seq(pCurHcb));
-		}
-	}
-}
-
-
-/***************************************************************************/
-int tul_state_4(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-
-#if DEBUG_STATE
-	printk("-s4-");
-#endif
-	if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_NO_XF) {
-		return (6);	/* Go to state 6                */
-	}
-	for (;;) {
-		if (pCurScb->SCB_BufLen == 0)
-			return (6);	/* Go to state 6                */
-
-		switch (pCurHcb->HCS_Phase) {
-
-		case STATUS_IN:	/* Status phase                 */
-			if ((pCurScb->SCB_Flags & SCF_DIR) != 0) {	/* if direction bit set then report data underrun */
-				pCurScb->SCB_HaStat = HOST_DO_DU;
-			}
-			if ((tul_status_msg(pCurHcb)) == -1)
-				return (-1);
-			break;
-
-		case MSG_IN:	/* Message in phase             */
-			pCurScb->SCB_NxtStat = 0x4;
-			if (tul_msgin(pCurHcb) == -1)
-				return (-1);
-			break;
-
-		case MSG_OUT:	/* Message out phase            */
-			if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) {
-				pCurScb->SCB_BufLen = 0;
-				pCurScb->SCB_HaStat = HOST_DO_DU;
-				if (tul_msgout_ide(pCurHcb) == -1)
-					return (-1);
-				return (6);	/* Go to state 6                */
-			} else {
-				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP);		/* msg nop */
-				TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-				if (wait_tulip(pCurHcb) == -1)
-					return (-1);
-			}
-			break;
-
-		case DATA_IN:	/* Data in phase                */
-			return (tul_xfer_data_in(pCurHcb));
-
-		case DATA_OUT:	/* Data out phase               */
-			return (tul_xfer_data_out(pCurHcb));
-
-		default:
-			return (tul_bad_seq(pCurHcb));
-		}
-	}
-}
-
-
-/***************************************************************************/
-/* state after dma xfer done or phase change before xfer done */
-int tul_state_5(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-	long cnt, xcnt;		/* cannot use unsigned !! code: if (xcnt < 0) */
-
-#if DEBUG_STATE
-	printk("-s5-");
-#endif
-/*------ get remaining count -------*/
-
-	cnt = TUL_RDLONG(pCurHcb->HCS_Base, TUL_SCnt0) & 0x0FFFFFF;
-
-	if (TUL_RD(pCurHcb->HCS_Base, TUL_XCmd) & 0x20) {
-		/* ----------------------- DATA_IN ----------------------------- */
-		/* check scsi parity error */
-		if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) {
-			pCurScb->SCB_HaStat = HOST_DO_DU;
-		}
-		if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) {	/* DMA xfer pending, Send STOP  */
-			/* tell Hardware  scsi xfer has been terminated */
-			TUL_WR(pCurHcb->HCS_Base + TUL_XCtrl, TUL_RD(pCurHcb->HCS_Base, TUL_XCtrl) | 0x80);
-			/* wait until DMA xfer not pending */
-			while (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND);
-		}
-	} else {
-/*-------- DATA OUT -----------*/
-		if ((TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1) & TSS_XFER_CMP) == 0) {
-			if (pCurHcb->HCS_ActTcs->TCS_JS_Period & TSC_WIDE_SCSI)
-				cnt += (TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F) << 1;
-			else
-				cnt += (TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F);
-		}
-		if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) {	/* if DMA xfer is pending, abort DMA xfer */
-			TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT);
-			/* wait Abort DMA xfer done */
-			while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & XABT) == 0);
-		}
-		if ((cnt == 1) && (pCurHcb->HCS_Phase == DATA_OUT)) {
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-			if (wait_tulip(pCurHcb) == -1) {
-				return (-1);
-			}
-			cnt = 0;
-		} else {
-			if ((TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1) & TSS_XFER_CMP) == 0)
-				TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-		}
-	}
-
-	if (cnt == 0) {
-		pCurScb->SCB_BufLen = 0;
-		return (6);	/* Go to state 6                */
-	}
-	/* Update active data pointer */
-	xcnt = (long) pCurScb->SCB_BufLen - cnt;	/* xcnt== bytes already xferred */
-	pCurScb->SCB_BufLen = (U32) cnt;	/* cnt == bytes left to be xferred */
-	if (pCurScb->SCB_Flags & SCF_SG) {
-		register SG *sgp;
-		ULONG i;
-
-		sgp = &pCurScb->SCB_SGList[pCurScb->SCB_SGIdx];
-		for (i = pCurScb->SCB_SGIdx; i < pCurScb->SCB_SGMax; sgp++, i++) {
-			xcnt -= (long) sgp->SG_Len;
-			if (xcnt < 0) {		/* this sgp xfer half done */
-				xcnt += (long) sgp->SG_Len;	/* xcnt == bytes xferred in this sgp */
-				sgp->SG_Ptr += (U32) xcnt;	/* new ptr to be xfer */
-				sgp->SG_Len -= (U32) xcnt;	/* new len to be xfer */
-				pCurScb->SCB_BufPtr += ((U32) (i - pCurScb->SCB_SGIdx) << 3);
-				/* new SG table ptr */
-				pCurScb->SCB_SGLen = (BYTE) (pCurScb->SCB_SGMax - i);
-				/* new SG table len */
-				pCurScb->SCB_SGIdx = (WORD) i;
-				/* for next disc and come in this loop */
-				return (4);	/* Go to state 4                */
-			}
-			/* else (xcnt >= 0 , i.e. this sgp already xferred */
-		}		/* for */
-		return (6);	/* Go to state 6                */
-	} else {
-		pCurScb->SCB_BufPtr += (U32) xcnt;
-	}
-	return (4);		/* Go to state 4                */
-}
-
-/***************************************************************************/
-/* state after Data phase */
-int tul_state_6(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-
-#if DEBUG_STATE
-	printk("-s6-");
-#endif
-	for (;;) {
-		switch (pCurHcb->HCS_Phase) {
-		case STATUS_IN:	/* Status phase                 */
-			if ((tul_status_msg(pCurHcb)) == -1)
-				return (-1);
-			break;
-
-		case MSG_IN:	/* Message in phase             */
-			pCurScb->SCB_NxtStat = 6;
-			if ((tul_msgin(pCurHcb)) == -1)
-				return (-1);
-			break;
-
-		case MSG_OUT:	/* Message out phase            */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP);		/* msg nop */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-			if (wait_tulip(pCurHcb) == -1)
-				return (-1);
-			break;
-
-		case DATA_IN:	/* Data in phase                */
-			return (tul_xpad_in(pCurHcb));
-
-		case DATA_OUT:	/* Data out phase               */
-			return (tul_xpad_out(pCurHcb));
-
-		default:
-			return (tul_bad_seq(pCurHcb));
-		}
-	}
-}
-
-/***************************************************************************/
-int tul_state_7(HCS * pCurHcb)
-{
-	int cnt, i;
-
-#if DEBUG_STATE
-	printk("-s7-");
-#endif
-	/* flush SCSI FIFO */
-	cnt = TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F;
-	if (cnt) {
-		for (i = 0; i < cnt; i++)
-			TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
-	}
-	switch (pCurHcb->HCS_Phase) {
-	case DATA_IN:		/* Data in phase                */
-	case DATA_OUT:		/* Data out phase               */
-		return (tul_bad_seq(pCurHcb));
-	default:
-		return (6);	/* Go to state 6                */
-	}
-}
-
-/***************************************************************************/
-int tul_xfer_data_in(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-
-	if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_DOUT) {
-		return (6);	/* wrong direction */
-	}
-	TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, pCurScb->SCB_BufLen);
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_DMA_IN);	/* 7/25/95 */
-
-	if (pCurScb->SCB_Flags & SCF_SG) {	/* S/G xfer */
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, ((ULONG) pCurScb->SCB_SGLen) << 3);
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr);
-		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_SG_IN);
-	} else {
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, pCurScb->SCB_BufLen);
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr);
-		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_IN);
-	}
-	pCurScb->SCB_NxtStat = 0x5;
-	return (0);		/* return to OS, wait xfer done , let jas_isr come in */
-}
-
-
-/***************************************************************************/
-int tul_xfer_data_out(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-
-	if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_DIN) {
-		return (6);	/* wrong direction */
-	}
-	TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, pCurScb->SCB_BufLen);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_DMA_OUT);
-
-	if (pCurScb->SCB_Flags & SCF_SG) {	/* S/G xfer */
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, ((ULONG) pCurScb->SCB_SGLen) << 3);
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr);
-		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_SG_OUT);
-	} else {
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, pCurScb->SCB_BufLen);
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr);
-		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_OUT);
-	}
-
-	pCurScb->SCB_NxtStat = 0x5;
-	return (0);		/* return to OS, wait xfer done , let jas_isr come in */
-}
-
-
-/***************************************************************************/
-int tul_xpad_in(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
-
-	if ((pCurScb->SCB_Flags & SCF_DIR) != SCF_NO_DCHK) {
-		pCurScb->SCB_HaStat = HOST_DO_DU;	/* over run             */
-	}
-	for (;;) {
-		if (pCurTcb->TCS_JS_Period & TSC_WIDE_SCSI)
-			TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 2);
-		else
-			TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
-		if ((wait_tulip(pCurHcb)) == -1) {
-			return (-1);
-		}
-		if (pCurHcb->HCS_Phase != DATA_IN) {
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-			return (6);
-		}
-		TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
-	}
-}
-
-int tul_xpad_out(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
-
-	if ((pCurScb->SCB_Flags & SCF_DIR) != SCF_NO_DCHK) {
-		pCurScb->SCB_HaStat = HOST_DO_DU;	/* over run             */
-	}
-	for (;;) {
-		if (pCurTcb->TCS_JS_Period & TSC_WIDE_SCSI)
-			TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 2);
-		else
-			TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 0);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-		if ((wait_tulip(pCurHcb)) == -1) {
-			return (-1);
-		}
-		if (pCurHcb->HCS_Phase != DATA_OUT) {	/* Disable wide CPU to allow read 16 bits */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-			return (6);
-		}
-	}
-}
-
-
-/***************************************************************************/
-int tul_status_msg(HCS * pCurHcb)
-{				/* status & MSG_IN */
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-	BYTE msg;
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_CMD_COMP);
-	if ((wait_tulip(pCurHcb)) == -1) {
-		return (-1);
-	}
-	/* get status */
-	pCurScb->SCB_TaStat = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
-
-	if (pCurHcb->HCS_Phase == MSG_OUT) {
-		if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) {
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_PARITY);
-		} else {
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP);
-		}
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-		return (wait_tulip(pCurHcb));
-	}
-	if (pCurHcb->HCS_Phase == MSG_IN) {
-		msg = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
-		if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) {	/* Parity error                 */
-			if ((tul_msgin_accept(pCurHcb)) == -1)
-				return (-1);
-			if (pCurHcb->HCS_Phase != MSG_OUT)
-				return (tul_bad_seq(pCurHcb));
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_PARITY);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-			return (wait_tulip(pCurHcb));
-		}
-		if (msg == 0) {	/* Command complete             */
-
-			if ((pCurScb->SCB_TaStat & 0x18) == 0x10) {	/* No link support              */
-				return (tul_bad_seq(pCurHcb));
-			}
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT);
-			return tul_wait_done_disc(pCurHcb);
-
-		}
-		if ((msg == MSG_LINK_COMP) || (msg == MSG_LINK_FLAG)) {
-			if ((pCurScb->SCB_TaStat & 0x18) == 0x10)
-				return (tul_msgin_accept(pCurHcb));
-		}
-	}
-	return (tul_bad_seq(pCurHcb));
-}
-
-
-/***************************************************************************/
-/* scsi bus free */
-int int_tul_busfree(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-
-	if (pCurScb != NULL) {
-		if (pCurScb->SCB_Status & SCB_SELECT) {		/* selection timeout */
-			tul_unlink_pend_scb(pCurHcb, pCurScb);
-			pCurScb->SCB_HaStat = HOST_SEL_TOUT;
-			tul_append_done_scb(pCurHcb, pCurScb);
-		} else {	/* Unexpected bus free          */
-			tul_unlink_busy_scb(pCurHcb, pCurScb);
-			pCurScb->SCB_HaStat = HOST_BUS_FREE;
-			tul_append_done_scb(pCurHcb, pCurScb);
-		}
-		pCurHcb->HCS_ActScb = NULL;
-		pCurHcb->HCS_ActTcs = NULL;
-	}
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
-	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
-	return (-1);
-}
-
-
-/***************************************************************************/
-/* scsi bus reset */
-int int_tul_scsi_rst(HCS * pCurHcb)
-{
-	SCB *pCurScb;
-	int i;
-
-	/* if DMA xfer is pending, abort DMA xfer */
-	if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & 0x01) {
-		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT | TAX_X_CLR_FIFO);
-		/* wait Abort DMA xfer done */
-		while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & 0x04) == 0);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-	}
-	/* Abort all active & disconnected scb */
-	while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) {
-		pCurScb->SCB_HaStat = HOST_BAD_PHAS;
-		tul_append_done_scb(pCurHcb, pCurScb);
-	}
-	pCurHcb->HCS_ActScb = NULL;
-	pCurHcb->HCS_ActTcs = NULL;
-
-	/* clr sync nego. done flag */
-	for (i = 0; i < pCurHcb->HCS_MaxTar; i++) {
-		pCurHcb->HCS_Tcs[i].TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
-	}
-	return (-1);
-}
-
-
-/***************************************************************************/
-/* scsi reselection */
-int int_tul_resel(HCS * pCurHcb)
-{
-	SCB *pCurScb;
-	TCS *pCurTcb;
-	BYTE tag, msg = 0;
-	BYTE tar, lun;
-
-	if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) {
-		if (pCurScb->SCB_Status & SCB_SELECT) {		/* if waiting for selection complete */
-			pCurScb->SCB_Status &= ~SCB_SELECT;
-		}
-		pCurHcb->HCS_ActScb = NULL;
-	}
-	/* --------- get target id---------------------- */
-	tar = TUL_RD(pCurHcb->HCS_Base, TUL_SBusId);
-	/* ------ get LUN from Identify message----------- */
-	lun = TUL_RD(pCurHcb->HCS_Base, TUL_SIdent) & 0x0F;
-	/* 07/22/98 from 0x1F -> 0x0F */
-	pCurTcb = &pCurHcb->HCS_Tcs[tar];
-	pCurHcb->HCS_ActTcs = pCurTcb;
-	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurTcb->TCS_JS_Period);
-
-
-	/* ------------- tag queueing ? ------------------- */
-	if (pCurTcb->TCS_DrvFlags & TCF_DRV_EN_TAG) {
-		if ((tul_msgin_accept(pCurHcb)) == -1)
-			return (-1);
-		if (pCurHcb->HCS_Phase != MSG_IN)
-			goto no_tag;
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
-		if ((wait_tulip(pCurHcb)) == -1)
-			return (-1);
-		msg = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);	/* Read Tag Message    */
-
-		if ((msg < MSG_STAG) || (msg > MSG_OTAG))	/* Is simple Tag      */
-			goto no_tag;
-
-		if ((tul_msgin_accept(pCurHcb)) == -1)
-			return (-1);
-
-		if (pCurHcb->HCS_Phase != MSG_IN)
-			goto no_tag;
-
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
-		if ((wait_tulip(pCurHcb)) == -1)
-			return (-1);
-		tag = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);	/* Read Tag ID       */
-		pCurScb = pCurHcb->HCS_Scb + tag;
-		if ((pCurScb->SCB_Target != tar) || (pCurScb->SCB_Lun != lun)) {
-			return tul_msgout_abort_tag(pCurHcb);
-		}
-		if (pCurScb->SCB_Status != SCB_BUSY) {	/* 03/24/95             */
-			return tul_msgout_abort_tag(pCurHcb);
-		}
-		pCurHcb->HCS_ActScb = pCurScb;
-		if ((tul_msgin_accept(pCurHcb)) == -1)
-			return (-1);
-	} else {		/* No tag               */
-	      no_tag:
-		if ((pCurScb = tul_find_busy_scb(pCurHcb, tar | (lun << 8))) == NULL) {
-			return tul_msgout_abort_targ(pCurHcb);
-		}
-		pCurHcb->HCS_ActScb = pCurScb;
-		if (!(pCurTcb->TCS_DrvFlags & TCF_DRV_EN_TAG)) {
-			if ((tul_msgin_accept(pCurHcb)) == -1)
-				return (-1);
-		}
-	}
-	return 0;
-}
-
-
-/***************************************************************************/
-int int_tul_bad_seq(HCS * pCurHcb)
-{				/* target wrong phase           */
-	SCB *pCurScb;
-	int i;
-
-	tul_reset_scsi(pCurHcb, 10);
-
-	while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) {
-		pCurScb->SCB_HaStat = HOST_BAD_PHAS;
-		tul_append_done_scb(pCurHcb, pCurScb);
-	}
-	for (i = 0; i < pCurHcb->HCS_MaxTar; i++) {
-		pCurHcb->HCS_Tcs[i].TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
-	}
-	return (-1);
-}
-
-
-/***************************************************************************/
-int tul_msgout_abort_targ(HCS * pCurHcb)
-{
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
-	if (tul_msgin_accept(pCurHcb) == -1)
-		return (-1);
-	if (pCurHcb->HCS_Phase != MSG_OUT)
-		return (tul_bad_seq(pCurHcb));
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_ABORT);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-
-	return tul_wait_disc(pCurHcb);
-}
-
-/***************************************************************************/
-int tul_msgout_abort_tag(HCS * pCurHcb)
-{
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
-	if (tul_msgin_accept(pCurHcb) == -1)
-		return (-1);
-	if (pCurHcb->HCS_Phase != MSG_OUT)
-		return (tul_bad_seq(pCurHcb));
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_ABORT_TAG);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-
-	return tul_wait_disc(pCurHcb);
-
-}
-
-/***************************************************************************/
-int tul_msgin(HCS * pCurHcb)
-{
-	TCS *pCurTcb;
-
-	for (;;) {
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
-		if ((wait_tulip(pCurHcb)) == -1)
-			return (-1);
-
-		switch (TUL_RD(pCurHcb->HCS_Base, TUL_SFifo)) {
-		case MSG_DISC:	/* Disconnect msg */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT);
-
-			return tul_wait_disc(pCurHcb);
-
-		case MSG_SDP:
-		case MSG_RESTORE:
-		case MSG_NOP:
-			tul_msgin_accept(pCurHcb);
-			break;
-
-		case MSG_REJ:	/* Clear ATN first              */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SSignal,
-			       (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)));
-			pCurTcb = pCurHcb->HCS_ActTcs;
-			if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) {	/* do sync nego */
-				TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
-			}
-			tul_msgin_accept(pCurHcb);
-			break;
-
-		case MSG_EXTEND:	/* extended msg */
-			tul_msgin_extend(pCurHcb);
-			break;
-
-		case MSG_IGNOREWIDE:
-			tul_msgin_accept(pCurHcb);
-			break;
-
-			/* get */
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
-			if (wait_tulip(pCurHcb) == -1)
-				return -1;
-
-			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 0);	/* put pad  */
-			TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);	/* get IGNORE field */
-			TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);	/* get pad */
-
-			tul_msgin_accept(pCurHcb);
-			break;
-
-		case MSG_COMP:
-			{
-				TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-				TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT);
-				return tul_wait_done_disc(pCurHcb);
-			}
-		default:
-			tul_msgout_reject(pCurHcb);
-			break;
-		}
-		if (pCurHcb->HCS_Phase != MSG_IN)
-			return (pCurHcb->HCS_Phase);
-	}
-	/* statement won't reach here */
-}
-
-
-
-
-/***************************************************************************/
-int tul_msgout_reject(HCS * pCurHcb)
-{
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
-
-	if ((tul_msgin_accept(pCurHcb)) == -1)
-		return (-1);
-
-	if (pCurHcb->HCS_Phase == MSG_OUT) {
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_REJ);		/* Msg reject           */
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-		return (wait_tulip(pCurHcb));
-	}
-	return (pCurHcb->HCS_Phase);
-}
-
-
-
-/***************************************************************************/
-int tul_msgout_ide(HCS * pCurHcb)
-{
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_IDE);		/* Initiator Detected Error */
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-	return (wait_tulip(pCurHcb));
-}
-
-
-/***************************************************************************/
-int tul_msgin_extend(HCS * pCurHcb)
-{
-	BYTE len, idx;
-
-	if (tul_msgin_accept(pCurHcb) != MSG_IN)
-		return (pCurHcb->HCS_Phase);
-
-	/* Get extended msg length      */
-	TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
-	if (wait_tulip(pCurHcb) == -1)
-		return (-1);
-
-	len = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
-	pCurHcb->HCS_Msg[0] = len;
-	for (idx = 1; len != 0; len--) {
-
-		if ((tul_msgin_accept(pCurHcb)) != MSG_IN)
-			return (pCurHcb->HCS_Phase);
-		TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
-		if (wait_tulip(pCurHcb) == -1)
-			return (-1);
-		pCurHcb->HCS_Msg[idx++] = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
-	}
-	if (pCurHcb->HCS_Msg[1] == 1) {		/* if it's synchronous data transfer request */
-		if (pCurHcb->HCS_Msg[0] != 3)	/* if length is not right */
-			return (tul_msgout_reject(pCurHcb));
-		if (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_SYNC_NEGO) {	/* Set OFFSET=0 to do async, nego back */
-			pCurHcb->HCS_Msg[3] = 0;
-		} else {
-			if ((tul_msgin_sync(pCurHcb) == 0) &&
-			    (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_SYNC_DONE)) {
-				tul_sync_done(pCurHcb);
-				return (tul_msgin_accept(pCurHcb));
-			}
-		}
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
-		if ((tul_msgin_accept(pCurHcb)) != MSG_OUT)
-			return (pCurHcb->HCS_Phase);
-		/* sync msg out */
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
-
-		tul_sync_done(pCurHcb);
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[2]);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[3]);
-
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-		return (wait_tulip(pCurHcb));
-	}
-	if ((pCurHcb->HCS_Msg[0] != 2) || (pCurHcb->HCS_Msg[1] != 3))
-		return (tul_msgout_reject(pCurHcb));
-	/* if it's WIDE DATA XFER REQ   */
-	if (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_WDTR) {
-		pCurHcb->HCS_Msg[2] = 0;
-	} else {
-		if (pCurHcb->HCS_Msg[2] > 2)	/* > 32 bits            */
-			return (tul_msgout_reject(pCurHcb));
-		if (pCurHcb->HCS_Msg[2] == 2) {		/* == 32                */
-			pCurHcb->HCS_Msg[2] = 1;
-		} else {
-			if ((pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_WDTR) == 0) {
-				wdtr_done(pCurHcb);
-				if ((pCurHcb->HCS_ActTcs->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0)
-					TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
-				return (tul_msgin_accept(pCurHcb));
-			}
-		}
-	}
-	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
-
-	if (tul_msgin_accept(pCurHcb) != MSG_OUT)
-		return (pCurHcb->HCS_Phase);
-	/* WDTR msg out                 */
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 2);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[2]);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-	return (wait_tulip(pCurHcb));
-}
-
-/***************************************************************************/
-int tul_msgin_sync(HCS * pCurHcb)
-{
-	char default_period;
-
-	default_period = tul_rate_tbl[pCurHcb->HCS_ActTcs->TCS_Flags & TCF_SCSI_RATE];
-	if (pCurHcb->HCS_Msg[3] > MAX_OFFSET) {
-		pCurHcb->HCS_Msg[3] = MAX_OFFSET;
-		if (pCurHcb->HCS_Msg[2] < default_period) {
-			pCurHcb->HCS_Msg[2] = default_period;
-			return 1;
-		}
-		if (pCurHcb->HCS_Msg[2] >= 59) {	/* Change to async              */
-			pCurHcb->HCS_Msg[3] = 0;
-		}
-		return 1;
-	}
-	/* offset requests asynchronous transfers ? */
-	if (pCurHcb->HCS_Msg[3] == 0) {
-		return 0;
-	}
-	if (pCurHcb->HCS_Msg[2] < default_period) {
-		pCurHcb->HCS_Msg[2] = default_period;
-		return 1;
-	}
-	if (pCurHcb->HCS_Msg[2] >= 59) {
-		pCurHcb->HCS_Msg[3] = 0;
-		return 1;
-	}
-	return 0;
-}
-
-
-/***************************************************************************/
-int wdtr_done(HCS * pCurHcb)
-{
-	pCurHcb->HCS_ActTcs->TCS_Flags &= ~TCF_SYNC_DONE;
-	pCurHcb->HCS_ActTcs->TCS_Flags |= TCF_WDTR_DONE;
-
-	pCurHcb->HCS_ActTcs->TCS_JS_Period = 0;
-	if (pCurHcb->HCS_Msg[2]) {	/* if 16 bit */
-		pCurHcb->HCS_ActTcs->TCS_JS_Period |= TSC_WIDE_SCSI;
-	}
-	pCurHcb->HCS_ActTcs->TCS_SConfig0 &= ~TSC_ALT_PERIOD;
-	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_ActTcs->TCS_SConfig0);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurHcb->HCS_ActTcs->TCS_JS_Period);
-
-	return 1;
-}
-
-/***************************************************************************/
-int tul_sync_done(HCS * pCurHcb)
-{
-	int i;
-
-	pCurHcb->HCS_ActTcs->TCS_Flags |= TCF_SYNC_DONE;
-
-	if (pCurHcb->HCS_Msg[3]) {
-		pCurHcb->HCS_ActTcs->TCS_JS_Period |= pCurHcb->HCS_Msg[3];
-		for (i = 0; i < 8; i++) {
-			if (tul_rate_tbl[i] >= pCurHcb->HCS_Msg[2])	/* pick the big one */
-				break;
-		}
-		pCurHcb->HCS_ActTcs->TCS_JS_Period |= (i << 4);
-		pCurHcb->HCS_ActTcs->TCS_SConfig0 |= TSC_ALT_PERIOD;
-	}
-	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_ActTcs->TCS_SConfig0);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurHcb->HCS_ActTcs->TCS_JS_Period);
-
-	return (-1);
-}
-
-
-int tul_post_scsi_rst(HCS * pCurHcb)
-{
-	SCB *pCurScb;
-	TCS *pCurTcb;
-	int i;
-
-	pCurHcb->HCS_ActScb = 0;
-	pCurHcb->HCS_ActTcs = 0;
-	pCurHcb->HCS_Flags = 0;
-
-	while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) {
-		pCurScb->SCB_HaStat = HOST_BAD_PHAS;
-		tul_append_done_scb(pCurHcb, pCurScb);
-	}
-	/* clear sync done flag         */
-	pCurTcb = &pCurHcb->HCS_Tcs[0];
-	for (i = 0; i < pCurHcb->HCS_MaxTar; pCurTcb++, i++) {
-		pCurTcb->TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
-		/* Initialize the sync. xfer register values to an asyn xfer */
-		pCurTcb->TCS_JS_Period = 0;
-		pCurTcb->TCS_SConfig0 = pCurHcb->HCS_SConf1;
-		pCurHcb->HCS_ActTags[0] = 0;	/* 07/22/98 */
-		pCurHcb->HCS_Tcs[i].TCS_Flags &= ~TCF_BUSY;	/* 07/22/98 */
-	}			/* for */
-
-	return (-1);
-}
-
-/***************************************************************************/
-void tul_select_atn_stop(HCS * pCurHcb, SCB * pCurScb)
-{
-	pCurScb->SCB_Status |= SCB_SELECT;
-	pCurScb->SCB_NxtStat = 0x1;
-	pCurHcb->HCS_ActScb = pCurScb;
-	pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target];
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SELATNSTOP);
-	return;
-}
-
-
-/***************************************************************************/
-void tul_select_atn(HCS * pCurHcb, SCB * pCurScb)
-{
-	int i;
-
-	pCurScb->SCB_Status |= SCB_SELECT;
-	pCurScb->SCB_NxtStat = 0x2;
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident);
-	for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++)
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]);
-	pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target];
-	pCurHcb->HCS_ActScb = pCurScb;
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SEL_ATN);
-	return;
-}
-
-/***************************************************************************/
-void tul_select_atn3(HCS * pCurHcb, SCB * pCurScb)
-{
-	int i;
-
-	pCurScb->SCB_Status |= SCB_SELECT;
-	pCurScb->SCB_NxtStat = 0x2;
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagMsg);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagId);
-	for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++)
-		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]);
-	pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target];
-	pCurHcb->HCS_ActScb = pCurScb;
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SEL_ATN3);
-	return;
-}
-
-/***************************************************************************/
-/* SCSI Bus Device Reset */
-int tul_bus_device_reset(HCS * pCurHcb)
-{
-	SCB *pCurScb = pCurHcb->HCS_ActScb;
-	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
-	SCB *pTmpScb, *pPrevScb;
-	BYTE tar;
-
-	if (pCurHcb->HCS_Phase != MSG_OUT) {
-		return (int_tul_bad_seq(pCurHcb));	/* Unexpected phase             */
-	}
-	tul_unlink_pend_scb(pCurHcb, pCurScb);
-	tul_release_scb(pCurHcb, pCurScb);
-
-
-	tar = pCurScb->SCB_Target;	/* target                       */
-	pCurTcb->TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE | TCF_BUSY);
-	/* clr sync. nego & WDTR flags  07/22/98 */
-
-	/* abort all SCB with same target */
-	pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;	/* Check Busy queue */
-	while (pTmpScb != NULL) {
-
-		if (pTmpScb->SCB_Target == tar) {
-			/* unlink it */
-			if (pTmpScb == pCurHcb->HCS_FirstBusy) {
-				if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL)
-					pCurHcb->HCS_LastBusy = NULL;
-			} else {
-				pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
-				if (pTmpScb == pCurHcb->HCS_LastBusy)
-					pCurHcb->HCS_LastBusy = pPrevScb;
-			}
-			pTmpScb->SCB_HaStat = HOST_ABORTED;
-			tul_append_done_scb(pCurHcb, pTmpScb);
-		}
-		/* Previous haven't change      */
-		else {
-			pPrevScb = pTmpScb;
-		}
-		pTmpScb = pTmpScb->SCB_NxtScb;
-	}
-
-	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_DEVRST);
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
-
-	return tul_wait_disc(pCurHcb);
-
-}
-
-/***************************************************************************/
-int tul_msgin_accept(HCS * pCurHcb)
-{
-	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT);
-	return (wait_tulip(pCurHcb));
-}
-
-/***************************************************************************/
-int wait_tulip(HCS * pCurHcb)
-{
-
-	while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0))
-		 & TSS_INT_PENDING));
-
-	pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
-	pCurHcb->HCS_Phase = pCurHcb->HCS_JSStatus0 & TSS_PH_MASK;
-	pCurHcb->HCS_JSStatus1 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1);
-
-	if (pCurHcb->HCS_JSInt & TSS_RESEL_INT) {	/* if SCSI bus reset detected   */
-		return (int_tul_resel(pCurHcb));
-	}
-	if (pCurHcb->HCS_JSInt & TSS_SEL_TIMEOUT) {	/* if selected/reselected timeout interrupt */
-		return (int_tul_busfree(pCurHcb));
-	}
-	if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) {	/* if SCSI bus reset detected   */
-		return (int_tul_scsi_rst(pCurHcb));
-	}
-	if (pCurHcb->HCS_JSInt & TSS_DISC_INT) {	/* BUS disconnection            */
-		if (pCurHcb->HCS_Flags & HCF_EXPECT_DONE_DISC) {
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
-			tul_unlink_busy_scb(pCurHcb, pCurHcb->HCS_ActScb);
-			pCurHcb->HCS_ActScb->SCB_HaStat = 0;
-			tul_append_done_scb(pCurHcb, pCurHcb->HCS_ActScb);
-			pCurHcb->HCS_ActScb = NULL;
-			pCurHcb->HCS_ActTcs = NULL;
-			pCurHcb->HCS_Flags &= ~HCF_EXPECT_DONE_DISC;
-			TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
-			return (-1);
-		}
-		if (pCurHcb->HCS_Flags & HCF_EXPECT_DISC) {
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
-			pCurHcb->HCS_ActScb = NULL;
-			pCurHcb->HCS_ActTcs = NULL;
-			pCurHcb->HCS_Flags &= ~HCF_EXPECT_DISC;
-			TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
-			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
-			return (-1);
-		}
-		return (int_tul_busfree(pCurHcb));
-	}
-	if (pCurHcb->HCS_JSInt & (TSS_FUNC_COMP | TSS_BUS_SERV)) {
-		return (pCurHcb->HCS_Phase);
-	}
-	return (pCurHcb->HCS_Phase);
-}
-/***************************************************************************/
-int tul_wait_disc(HCS * pCurHcb)
-{
-
-	while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0))
-		 & TSS_INT_PENDING));
-
-
-	pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
-
-	if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) {	/* if SCSI bus reset detected   */
-		return (int_tul_scsi_rst(pCurHcb));
-	}
-	if (pCurHcb->HCS_JSInt & TSS_DISC_INT) {	/* BUS disconnection            */
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
-		TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
-		pCurHcb->HCS_ActScb = NULL;
-		return (-1);
-	}
-	return (tul_bad_seq(pCurHcb));
-}
-
-/***************************************************************************/
-int tul_wait_done_disc(HCS * pCurHcb)
-{
-
-
-	while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0))
-		 & TSS_INT_PENDING));
-
-	pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
-
-
-	if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) {	/* if SCSI bus reset detected   */
-		return (int_tul_scsi_rst(pCurHcb));
-	}
-	if (pCurHcb->HCS_JSInt & TSS_DISC_INT) {	/* BUS disconnection            */
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
-		TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
-		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
-		tul_unlink_busy_scb(pCurHcb, pCurHcb->HCS_ActScb);
-
-		tul_append_done_scb(pCurHcb, pCurHcb->HCS_ActScb);
-		pCurHcb->HCS_ActScb = NULL;
-		return (-1);
-	}
-	return (tul_bad_seq(pCurHcb));
-}
-
-/**************************** EOF *********************************/
diff -Nru a/drivers/scsi/i91uscsi.h b/drivers/scsi/i91uscsi.h
--- a/drivers/scsi/i91uscsi.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,843 +0,0 @@
-/**************************************************************************
- * Initio 9100 device driver for Linux.
- *
- * Copyright (c) 1994-1998 Initio Corporation
- * 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, 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; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * --------------------------------------------------------------------------
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU General Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- **************************************************************************/
-
-#include <linux/config.h>
-#include <linux/types.h>
-
-#define ULONG   unsigned long
-#define USHORT  unsigned short
-#define UCHAR   unsigned char
-#define BYTE    unsigned char
-#define WORD    unsigned short
-#define DWORD   unsigned long
-#define UBYTE   unsigned char
-#define UWORD   unsigned short
-#define UDWORD  unsigned long
-#define U32     u32
-
-#ifndef FAILURE
-#define FAILURE  (-1)
-#endif
-
-#define TOTAL_SG_ENTRY		32
-#define MAX_SUPPORTED_ADAPTERS  8
-#define MAX_OFFSET		15
-#define MAX_TARGETS		16
-
-#define INI_VENDOR_ID   0x1101	/* Initio's PCI vendor ID       */
-#define I950_DEVICE_ID	0x9500	/* Initio's inic-950 product ID   */
-#define I940_DEVICE_ID	0x9400	/* Initio's inic-940 product ID   */
-#define I935_DEVICE_ID	0x9401	/* Initio's inic-935 product ID   */
-
-#define	_I91USCSI_H
-
-typedef struct {
-	unsigned short base;
-	unsigned short vec;
-} i91u_config;
-
-/***************************************/
-/*  Tulip Configuration Register Set */
-/***************************************/
-#define TUL_PVID        0x00	/* Vendor ID                    */
-#define TUL_PDID        0x02	/* Device ID                    */
-#define TUL_PCMD        0x04	/* Command                      */
-#define TUL_PSTUS       0x06	/* Status                       */
-#define TUL_PRID        0x08	/* Revision number              */
-#define TUL_PPI         0x09	/* Programming interface        */
-#define TUL_PSC         0x0A	/* Sub Class                    */
-#define TUL_PBC         0x0B	/* Base Class                   */
-#define TUL_PCLS        0x0C	/* Cache line size              */
-#define TUL_PLTR        0x0D	/* Latency timer                */
-#define TUL_PHDT        0x0E	/* Header type                  */
-#define TUL_PBIST       0x0F	/* BIST                         */
-#define TUL_PBAD        0x10	/* Base address                 */
-#define TUL_PBAD1       0x14	/* Base address                 */
-#define TUL_PBAD2       0x18	/* Base address                 */
-#define TUL_PBAD3       0x1C	/* Base address                 */
-#define TUL_PBAD4       0x20	/* Base address                 */
-#define TUL_PBAD5       0x24	/* Base address                 */
-#define TUL_PRSVD       0x28	/* Reserved                     */
-#define TUL_PRSVD1      0x2C	/* Reserved                     */
-#define TUL_PRAD        0x30	/* Expansion ROM base address   */
-#define TUL_PRSVD2      0x34	/* Reserved                     */
-#define TUL_PRSVD3      0x38	/* Reserved                     */
-#define TUL_PINTL       0x3C	/* Interrupt line               */
-#define TUL_PINTP       0x3D	/* Interrupt pin                */
-#define TUL_PIGNT       0x3E	/* MIN_GNT                      */
-#define TUL_PMGNT       0x3F	/* MAX_GNT                      */
-
-/************************/
-/*  Jasmin Register Set */
-/************************/
-#define TUL_HACFG0      0x40	/* H/A Configuration Register 0         */
-#define TUL_HACFG1      0x41	/* H/A Configuration Register 1         */
-#define TUL_HACFG2      0x42	/* H/A Configuration Register 2         */
-
-#define TUL_SDCFG0      0x44	/* SCSI Device Configuration 0          */
-#define TUL_SDCFG1      0x45	/* SCSI Device Configuration 1          */
-#define TUL_SDCFG2      0x46	/* SCSI Device Configuration 2          */
-#define TUL_SDCFG3      0x47	/* SCSI Device Configuration 3          */
-
-#define TUL_GINTS       0x50	/* Global Interrupt Status Register     */
-#define TUL_GIMSK       0x52	/* Global Interrupt MASK Register       */
-#define TUL_GCTRL       0x54	/* Global Control Register              */
-#define TUL_GCTRL_EEPROM_BIT    0x04
-#define TUL_GCTRL1      0x55	/* Global Control Register              */
-#define TUL_DMACFG      0x5B	/* DMA configuration                    */
-#define TUL_NVRAM       0x5D	/* Non-volatile RAM port                */
-
-#define TUL_SCnt0       0x80	/* 00 R/W Transfer Counter Low          */
-#define TUL_SCnt1       0x81	/* 01 R/W Transfer Counter Mid          */
-#define TUL_SCnt2       0x82	/* 02 R/W Transfer Count High           */
-#define TUL_SFifoCnt    0x83	/* 03 R   FIFO counter                  */
-#define TUL_SIntEnable  0x84	/* 03 W   Interrupt enble               */
-#define TUL_SInt        0x84	/* 04 R   Interrupt Register            */
-#define TUL_SCtrl0      0x85	/* 05 W   Control 0                     */
-#define TUL_SStatus0    0x85	/* 05 R   Status 0                      */
-#define TUL_SCtrl1      0x86	/* 06 W   Control 1                     */
-#define TUL_SStatus1    0x86	/* 06 R   Status 1                      */
-#define TUL_SConfig     0x87	/* 07 W   Configuration                 */
-#define TUL_SStatus2    0x87	/* 07 R   Status 2                      */
-#define TUL_SPeriod     0x88	/* 08 W   Sync. Transfer Period & Offset */
-#define TUL_SOffset     0x88	/* 08 R   Offset                        */
-#define TUL_SScsiId     0x89	/* 09 W   SCSI ID                       */
-#define TUL_SBusId      0x89	/* 09 R   SCSI BUS ID                   */
-#define TUL_STimeOut    0x8A	/* 0A W   Sel/Resel Time Out Register   */
-#define TUL_SIdent      0x8A	/* 0A R   Identify Message Register     */
-#define TUL_SAvail      0x8A	/* 0A R   Availiable Counter Register   */
-#define TUL_SData       0x8B	/* 0B R/W SCSI data in/out              */
-#define TUL_SFifo       0x8C	/* 0C R/W FIFO                          */
-#define TUL_SSignal     0x90	/* 10 R/W SCSI signal in/out            */
-#define TUL_SCmd        0x91	/* 11 R/W Command                       */
-#define TUL_STest0      0x92	/* 12 R/W Test0                         */
-#define TUL_STest1      0x93	/* 13 R/W Test1                         */
-#define TUL_SCFG1	0x94	/* 14 R/W Configuration                 */
-
-#define TUL_XAddH       0xC0	/*DMA Transfer Physical Address         */
-#define TUL_XAddW       0xC8	/*DMA Current Transfer Physical Address */
-#define TUL_XCntH       0xD0	/*DMA Transfer Counter                  */
-#define TUL_XCntW       0xD4	/*DMA Current Transfer Counter          */
-#define TUL_XCmd        0xD8	/*DMA Command Register                  */
-#define TUL_Int         0xDC	/*Interrupt Register                    */
-#define TUL_XStatus     0xDD	/*DMA status Register                   */
-#define TUL_Mask        0xE0	/*Interrupt Mask Register               */
-#define TUL_XCtrl       0xE4	/*DMA Control Register                  */
-#define TUL_XCtrl1      0xE5	/*DMA Control Register 1                */
-#define TUL_XFifo       0xE8	/*DMA FIFO                              */
-
-#define TUL_WCtrl       0xF7	/*Bus master wait state control         */
-#define TUL_DCtrl       0xFB	/*DMA delay control                     */
-
-/*----------------------------------------------------------------------*/
-/*   bit definition for Command register of Configuration Space Header  */
-/*----------------------------------------------------------------------*/
-#define BUSMS           0x04	/* BUS MASTER Enable                    */
-#define IOSPA           0x01	/* IO Space Enable                      */
-
-/*----------------------------------------------------------------------*/
-/* Command Codes of Tulip SCSI Command register                         */
-/*----------------------------------------------------------------------*/
-#define TSC_EN_RESEL    0x80	/* Enable Reselection                   */
-#define TSC_CMD_COMP    0x84	/* Command Complete Sequence            */
-#define TSC_SEL         0x01	/* Select Without ATN Sequence          */
-#define TSC_SEL_ATN     0x11	/* Select With ATN Sequence             */
-#define TSC_SEL_ATN_DMA 0x51	/* Select With ATN Sequence with DMA    */
-#define TSC_SEL_ATN3    0x31	/* Select With ATN3 Sequence            */
-#define TSC_SEL_ATNSTOP 0x12	/* Select With ATN and Stop Sequence    */
-#define TSC_SELATNSTOP  0x1E	/* Select With ATN and Stop Sequence    */
-
-#define TSC_SEL_ATN_DIRECT_IN   0x95	/* Select With ATN Sequence     */
-#define TSC_SEL_ATN_DIRECT_OUT  0x15	/* Select With ATN Sequence     */
-#define TSC_SEL_ATN3_DIRECT_IN  0xB5	/* Select With ATN3 Sequence    */
-#define TSC_SEL_ATN3_DIRECT_OUT 0x35	/* Select With ATN3 Sequence    */
-#define TSC_XF_DMA_OUT_DIRECT   0x06	/* DMA Xfer Infomation out      */
-#define TSC_XF_DMA_IN_DIRECT    0x86	/* DMA Xfer Infomation in       */
-
-#define TSC_XF_DMA_OUT  0x43	/* DMA Xfer Infomation out              */
-#define TSC_XF_DMA_IN   0xC3	/* DMA Xfer Infomation in               */
-#define TSC_XF_FIFO_OUT 0x03	/* FIFO Xfer Infomation out             */
-#define TSC_XF_FIFO_IN  0x83	/* FIFO Xfer Infomation in              */
-
-#define TSC_MSG_ACCEPT  0x0F	/* Message Accept                       */
-
-/*----------------------------------------------------------------------*/
-/* bit definition for Tulip SCSI Control 0 Register                     */
-/*----------------------------------------------------------------------*/
-#define TSC_RST_SEQ     0x20	/* Reset sequence counter               */
-#define TSC_FLUSH_FIFO  0x10	/* Flush FIFO                           */
-#define TSC_ABT_CMD     0x04	/* Abort command (sequence)             */
-#define TSC_RST_CHIP    0x02	/* Reset SCSI Chip                      */
-#define TSC_RST_BUS     0x01	/* Reset SCSI Bus                       */
-
-/*----------------------------------------------------------------------*/
-/* bit definition for Tulip SCSI Control 1 Register                     */
-/*----------------------------------------------------------------------*/
-#define TSC_EN_SCAM     0x80	/* Enable SCAM                          */
-#define TSC_TIMER       0x40	/* Select timeout unit                  */
-#define TSC_EN_SCSI2    0x20	/* SCSI-2 mode                          */
-#define TSC_PWDN        0x10	/* Power down mode                      */
-#define TSC_WIDE_CPU    0x08	/* Wide CPU                             */
-#define TSC_HW_RESELECT 0x04	/* Enable HW reselect                   */
-#define TSC_EN_BUS_OUT  0x02	/* Enable SCSI data bus out latch       */
-#define TSC_EN_BUS_IN   0x01	/* Enable SCSI data bus in latch        */
-
-/*----------------------------------------------------------------------*/
-/* bit definition for Tulip SCSI Configuration Register                 */
-/*----------------------------------------------------------------------*/
-#define TSC_EN_LATCH    0x80	/* Enable phase latch                   */
-#define TSC_INITIATOR   0x40	/* Initiator mode                       */
-#define TSC_EN_SCSI_PAR 0x20	/* Enable SCSI parity                   */
-#define TSC_DMA_8BIT    0x10	/* Alternate dma 8-bits mode            */
-#define TSC_DMA_16BIT   0x08	/* Alternate dma 16-bits mode           */
-#define TSC_EN_WDACK    0x04	/* Enable DACK while wide SCSI xfer     */
-#define TSC_ALT_PERIOD  0x02	/* Alternate sync period mode           */
-#define TSC_DIS_SCSIRST 0x01	/* Disable SCSI bus reset us            */
-
-#define TSC_INITDEFAULT (TSC_INITIATOR | TSC_EN_LATCH | TSC_ALT_PERIOD | TSC_DIS_SCSIRST)
-
-#define TSC_WIDE_SCSI   0x80	/* Enable Wide SCSI                     */
-
-/*----------------------------------------------------------------------*/
-/* bit definition for Tulip SCSI signal Register                        */
-/*----------------------------------------------------------------------*/
-#define TSC_RST_ACK     0x00	/* Release ACK signal                   */
-#define TSC_RST_ATN     0x00	/* Release ATN signal                   */
-#define TSC_RST_BSY     0x00	/* Release BSY signal                   */
-
-#define TSC_SET_ACK     0x40	/* ACK signal                           */
-#define TSC_SET_ATN     0x08	/* ATN signal                           */
-
-#define TSC_REQI        0x80	/* REQ signal                           */
-#define TSC_ACKI        0x40	/* ACK signal                           */
-#define TSC_BSYI        0x20	/* BSY signal                           */
-#define TSC_SELI        0x10	/* SEL signal                           */
-#define TSC_ATNI        0x08	/* ATN signal                           */
-#define TSC_MSGI        0x04	/* MSG signal                           */
-#define TSC_CDI         0x02	/* C/D signal                           */
-#define TSC_IOI         0x01	/* I/O signal                           */
-
-
-/*----------------------------------------------------------------------*/
-/* bit definition for Tulip SCSI Status 0 Register                      */
-/*----------------------------------------------------------------------*/
-#define TSS_INT_PENDING 0x80	/* Interrupt pending            */
-#define TSS_SEQ_ACTIVE  0x40	/* Sequencer active             */
-#define TSS_XFER_CNT    0x20	/* Transfer counter zero        */
-#define TSS_FIFO_EMPTY  0x10	/* FIFO empty                   */
-#define TSS_PAR_ERROR   0x08	/* SCSI parity error            */
-#define TSS_PH_MASK     0x07	/* SCSI phase mask              */
-
-/*----------------------------------------------------------------------*/
-/* bit definition for Tulip SCSI Status 1 Register                      */
-/*----------------------------------------------------------------------*/
-#define TSS_STATUS_RCV  0x08	/* Status received              */
-#define TSS_MSG_SEND    0x40	/* Message sent                 */
-#define TSS_CMD_PH_CMP  0x20	/* command phase done              */
-#define TSS_DATA_PH_CMP 0x10	/* Data phase done              */
-#define TSS_STATUS_SEND 0x08	/* Status sent                  */
-#define TSS_XFER_CMP    0x04	/* Transfer completed           */
-#define TSS_SEL_CMP     0x02	/* Selection completed          */
-#define TSS_ARB_CMP     0x01	/* Arbitration completed        */
-
-/*----------------------------------------------------------------------*/
-/* bit definition for Tulip SCSI Status 2 Register                      */
-/*----------------------------------------------------------------------*/
-#define TSS_CMD_ABTED   0x80	/* Command aborted              */
-#define TSS_OFFSET_0    0x40	/* Offset counter zero          */
-#define TSS_FIFO_FULL   0x20	/* FIFO full                    */
-#define TSS_TIMEOUT_0   0x10	/* Timeout counter zero         */
-#define TSS_BUSY_RLS    0x08	/* Busy release                 */
-#define TSS_PH_MISMATCH 0x04	/* Phase mismatch               */
-#define TSS_SCSI_BUS_EN 0x02	/* SCSI data bus enable         */
-#define TSS_SCSIRST     0x01	/* SCSI bus reset in progress   */
-
-/*----------------------------------------------------------------------*/
-/* bit definition for Tulip SCSI Interrupt Register                     */
-/*----------------------------------------------------------------------*/
-#define TSS_RESEL_INT   0x80	/* Reselected interrupt         */
-#define TSS_SEL_TIMEOUT 0x40	/* Selected/reselected timeout  */
-#define TSS_BUS_SERV    0x20
-#define TSS_SCSIRST_INT 0x10	/* SCSI bus reset detected      */
-#define TSS_DISC_INT    0x08	/* Disconnected interrupt       */
-#define TSS_SEL_INT     0x04	/* Select interrupt             */
-#define TSS_SCAM_SEL    0x02	/* SCAM selected                */
-#define TSS_FUNC_COMP   0x01
-
-/*----------------------------------------------------------------------*/
-/* SCSI Phase Codes.                                                    */
-/*----------------------------------------------------------------------*/
-#define DATA_OUT        0
-#define DATA_IN         1	/* 4                            */
-#define CMD_OUT         2
-#define STATUS_IN       3	/* 6                            */
-#define MSG_OUT         6	/* 3                            */
-#define MSG_IN          7
-
-
-
-/*----------------------------------------------------------------------*/
-/* Command Codes of Tulip xfer Command register                         */
-/*----------------------------------------------------------------------*/
-#define TAX_X_FORC      0x02
-#define TAX_X_ABT       0x04
-#define TAX_X_CLR_FIFO  0x08
-
-#define TAX_X_IN        0x21
-#define TAX_X_OUT       0x01
-#define TAX_SG_IN       0xA1
-#define TAX_SG_OUT      0x81
-
-/*----------------------------------------------------------------------*/
-/* Tulip Interrupt Register                                             */
-/*----------------------------------------------------------------------*/
-#define XCMP            0x01
-#define FCMP            0x02
-#define XABT            0x04
-#define XERR            0x08
-#define SCMP            0x10
-#define IPEND           0x80
-
-/*----------------------------------------------------------------------*/
-/* Tulip DMA Status Register                                            */
-/*----------------------------------------------------------------------*/
-#define XPEND           0x01	/* Transfer pending             */
-#define FEMPTY          0x02	/* FIFO empty                   */
-
-
-
-/*----------------------------------------------------------------------*/
-/* bit definition for TUL_GCTRL                                         */
-/*----------------------------------------------------------------------*/
-#define EXTSG           0x80
-#define EXTAD           0x60
-#define SEG4K           0x08
-#define EEPRG           0x04
-#define MRMUL           0x02
-
-/*----------------------------------------------------------------------*/
-/* bit definition for TUL_NVRAM                                         */
-/*----------------------------------------------------------------------*/
-#define SE2CS           0x08
-#define SE2CLK          0x04
-#define SE2DO           0x02
-#define SE2DI           0x01
-
-
-/************************************************************************/
-/*              Scatter-Gather Element Structure                        */
-/************************************************************************/
-typedef struct SG_Struc {
-	U32 SG_Ptr;		/* Data Pointer */
-	U32 SG_Len;		/* Data Length */
-} SG;
-
-/***********************************************************************
-		SCSI Control Block
-************************************************************************/
-typedef struct Scsi_Ctrl_Blk {
-	struct Scsi_Ctrl_Blk *SCB_NxtScb;
-	UBYTE SCB_Status;	/*4 */
-	UBYTE SCB_NxtStat;	/*5 */
-	UBYTE SCB_Mode;		/*6 */
-	UBYTE SCB_Msgin;	/*7 SCB_Res0 */
-	UWORD SCB_SGIdx;	/*8 */
-	UWORD SCB_SGMax;	/*A */
-#ifdef ALPHA
-	U32 SCB_Reserved[2];	/*C */
-#else
-	U32 SCB_Reserved[3];	/*C */
-#endif
-
-	U32 SCB_XferLen;	/*18 Current xfer len           */
-	U32 SCB_TotXLen;	/*1C Total xfer len             */
-	U32 SCB_PAddr;		/*20 SCB phy. Addr. */
-
-	UBYTE SCB_Opcode;	/*24 SCB command code */
-	UBYTE SCB_Flags;	/*25 SCB Flags */
-	UBYTE SCB_Target;	/*26 Target Id */
-	UBYTE SCB_Lun;		/*27 Lun */
-	U32 SCB_BufPtr;		/*28 Data Buffer Pointer */
-	U32 SCB_BufLen;		/*2C Data Allocation Length */
-	UBYTE SCB_SGLen;	/*30 SG list # */
-	UBYTE SCB_SenseLen;	/*31 Sense Allocation Length */
-	UBYTE SCB_HaStat;	/*32 */
-	UBYTE SCB_TaStat;	/*33 */
-	UBYTE SCB_CDBLen;	/*34 CDB Length */
-	UBYTE SCB_Ident;	/*35 Identify */
-	UBYTE SCB_TagMsg;	/*36 Tag Message */
-	UBYTE SCB_TagId;	/*37 Queue Tag */
-	UBYTE SCB_CDB[12];	/*38 */
-	U32 SCB_SGPAddr;	/*44 SG List/Sense Buf phy. Addr. */
-	U32 SCB_SensePtr;	/*48 Sense data pointer */
-	void (*SCB_Post) (BYTE *, BYTE *);	/*4C POST routine */
-	unsigned char *SCB_Srb;	/*50 SRB Pointer */
-	SG SCB_SGList[TOTAL_SG_ENTRY];	/*54 Start of SG list */
-} SCB;
-
-/* Bit Definition for SCB_Status */
-#define SCB_RENT        0x01
-#define SCB_PEND        0x02
-#define SCB_CONTIG      0x04	/* Contigent Allegiance */
-#define SCB_SELECT      0x08
-#define SCB_BUSY        0x10
-#define SCB_DONE        0x20
-
-
-/* Opcodes of SCB_Opcode */
-#define ExecSCSI        0x1
-#define BusDevRst       0x2
-#define AbortCmd        0x3
-
-
-/* Bit Definition for SCB_Mode */
-#define SCM_RSENS       0x01	/* request sense mode */
-
-
-/* Bit Definition for SCB_Flags */
-#define SCF_DONE        0x01
-#define SCF_POST        0x02
-#define SCF_SENSE       0x04
-#define SCF_DIR         0x18
-#define SCF_NO_DCHK     0x00
-#define SCF_DIN         0x08
-#define SCF_DOUT        0x10
-#define SCF_NO_XF       0x18
-#define SCF_WR_VF       0x20	/* Write verify turn on         */
-#define SCF_POLL        0x40
-#define SCF_SG          0x80
-
-/* Error Codes for SCB_HaStat */
-#define HOST_SEL_TOUT   0x11
-#define HOST_DO_DU      0x12
-#define HOST_BUS_FREE   0x13
-#define HOST_BAD_PHAS   0x14
-#define HOST_INV_CMD    0x16
-#define HOST_ABORTED    0x1A	/* 07/21/98 */
-#define HOST_SCSI_RST   0x1B
-#define HOST_DEV_RST    0x1C
-
-/* Error Codes for SCB_TaStat */
-#define TARGET_CHKCOND  0x02
-#define TARGET_BUSY     0x08
-#define QUEUE_FULL	0x28
-
-/* SCSI MESSAGE */
-#define MSG_COMP        0x00
-#define MSG_EXTEND      0x01
-#define MSG_SDP         0x02
-#define MSG_RESTORE     0x03
-#define MSG_DISC        0x04
-#define MSG_IDE         0x05
-#define MSG_ABORT       0x06
-#define MSG_REJ         0x07
-#define MSG_NOP         0x08
-#define MSG_PARITY      0x09
-#define MSG_LINK_COMP   0x0A
-#define MSG_LINK_FLAG   0x0B
-#define MSG_DEVRST      0x0C
-#define MSG_ABORT_TAG   0x0D
-
-/* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */
-#define MSG_STAG        0x20
-#define MSG_HTAG        0x21
-#define MSG_OTAG        0x22
-
-#define MSG_IGNOREWIDE  0x23
-
-#define MSG_IDENT   0x80
-
-/***********************************************************************
-		Target Device Control Structure
-**********************************************************************/
-
-typedef struct Tar_Ctrl_Struc {
-	UWORD TCS_Flags;	/* 0 */
-	UBYTE TCS_JS_Period;	/* 2 */
-	UBYTE TCS_SConfig0;	/* 3 */
-
-	UWORD TCS_DrvFlags;	/* 4 */
-	UBYTE TCS_DrvHead;	/* 6 */
-	UBYTE TCS_DrvSector;	/* 7 */
-} TCS;
-
-/***********************************************************************
-		Target Device Control Structure
-**********************************************************************/
-
-/* Bit Definition for TCF_Flags */
-#define TCF_SCSI_RATE           0x0007
-#define TCF_EN_DISC             0x0008
-#define TCF_NO_SYNC_NEGO        0x0010
-#define TCF_NO_WDTR             0x0020
-#define TCF_EN_255              0x0040
-#define TCF_EN_START            0x0080
-#define TCF_WDTR_DONE           0x0100
-#define TCF_SYNC_DONE           0x0200
-#define TCF_BUSY                0x0400
-
-
-/* Bit Definition for TCF_DrvFlags */
-#define TCF_DRV_BUSY            0x01	/* Indicate target busy(driver) */
-#define TCF_DRV_EN_TAG          0x0800
-#define TCF_DRV_255_63          0x0400
-
-typedef struct I91u_Adpt_Struc {
-	UWORD ADPT_BIOS;	/* 0 */
-	UWORD ADPT_BASE;	/* 1 */
-	UBYTE ADPT_Bus;		/* 2 */
-	UBYTE ADPT_Device;	/* 3 */
-	UBYTE ADPT_INTR;	/* 4 */
-} INI_ADPT_STRUCT;
-
-
-/***********************************************************************
-	      Host Adapter Control Structure
-************************************************************************/
-typedef struct Ha_Ctrl_Struc {
-	UWORD HCS_Base;		/* 00 */
-	UWORD HCS_BIOS;		/* 02 */
-	UBYTE HCS_Intr;		/* 04 */
-	UBYTE HCS_SCSI_ID;	/* 05 */
-	UBYTE HCS_MaxTar;	/* 06 */
-	UBYTE HCS_NumScbs;	/* 07 */
-
-	UBYTE HCS_Flags;	/* 08 */
-	UBYTE HCS_Index;	/* 09 */
-	UBYTE HCS_HaId;		/* 0A */
-	UBYTE HCS_Config;	/* 0B */
-	UWORD HCS_IdMask;	/* 0C */
-	UBYTE HCS_Semaph;	/* 0E */
-	UBYTE HCS_Phase;	/* 0F */
-	UBYTE HCS_JSStatus0;	/* 10 */
-	UBYTE HCS_JSInt;	/* 11 */
-	UBYTE HCS_JSStatus1;	/* 12 */
-	UBYTE HCS_SConf1;	/* 13 */
-
-	UBYTE HCS_Msg[8];	/* 14 */
-	SCB *HCS_NxtAvail;	/* 1C */
-	SCB *HCS_Scb;		/* 20 */
-	SCB *HCS_ScbEnd;	/* 24 */
-	SCB *HCS_NxtPend;	/* 28 */
-	SCB *HCS_NxtContig;	/* 2C */
-	SCB *HCS_ActScb;	/* 30 */
-	TCS *HCS_ActTcs;	/* 34 */
-
-	SCB *HCS_FirstAvail;	/* 38 */
-	SCB *HCS_LastAvail;	/* 3C */
-	SCB *HCS_FirstPend;	/* 40 */
-	SCB *HCS_LastPend;	/* 44 */
-	SCB *HCS_FirstBusy;	/* 48 */
-	SCB *HCS_LastBusy;	/* 4C */
-	SCB *HCS_FirstDone;	/* 50 */
-	SCB *HCS_LastDone;	/* 54 */
-	UBYTE HCS_MaxTags[16];	/* 58 */
-	UBYTE HCS_ActTags[16];	/* 68 */
-	TCS HCS_Tcs[MAX_TARGETS];	/* 78 */
-	ULONG pSRB_head;	/* SRB save queue header     */
-	ULONG pSRB_tail;	/* SRB save queue tail       */
-	spinlock_t HCS_AvailLock;
-	spinlock_t HCS_SemaphLock;
-	spinlock_t pSRB_lock;	/* SRB queue lock            */
-} HCS;
-
-/* Bit Definition for HCB_Config */
-#define HCC_SCSI_RESET          0x01
-#define HCC_EN_PAR              0x02
-#define HCC_ACT_TERM1           0x04
-#define HCC_ACT_TERM2           0x08
-#define HCC_AUTO_TERM           0x10
-#define HCC_EN_PWR              0x80
-
-/* Bit Definition for HCB_Flags */
-#define HCF_EXPECT_DISC         0x01
-#define HCF_EXPECT_SELECT       0x02
-#define HCF_EXPECT_RESET        0x10
-#define HCF_EXPECT_DONE_DISC    0x20
-
-/******************************************************************
-	Serial EEProm
-*******************************************************************/
-
-typedef struct _NVRAM_SCSI {	/* SCSI channel configuration   */
-	UCHAR NVM_ChSCSIID;	/* 0Ch -> Channel SCSI ID       */
-	UCHAR NVM_ChConfig1;	/* 0Dh -> Channel config 1      */
-	UCHAR NVM_ChConfig2;	/* 0Eh -> Channel config 2      */
-	UCHAR NVM_NumOfTarg;	/* 0Fh -> Number of SCSI target */
-	/* SCSI target configuration    */
-	UCHAR NVM_Targ0Config;	/* 10h -> Target 0 configuration */
-	UCHAR NVM_Targ1Config;	/* 11h -> Target 1 configuration */
-	UCHAR NVM_Targ2Config;	/* 12h -> Target 2 configuration */
-	UCHAR NVM_Targ3Config;	/* 13h -> Target 3 configuration */
-	UCHAR NVM_Targ4Config;	/* 14h -> Target 4 configuration */
-	UCHAR NVM_Targ5Config;	/* 15h -> Target 5 configuration */
-	UCHAR NVM_Targ6Config;	/* 16h -> Target 6 configuration */
-	UCHAR NVM_Targ7Config;	/* 17h -> Target 7 configuration */
-	UCHAR NVM_Targ8Config;	/* 18h -> Target 8 configuration */
-	UCHAR NVM_Targ9Config;	/* 19h -> Target 9 configuration */
-	UCHAR NVM_TargAConfig;	/* 1Ah -> Target A configuration */
-	UCHAR NVM_TargBConfig;	/* 1Bh -> Target B configuration */
-	UCHAR NVM_TargCConfig;	/* 1Ch -> Target C configuration */
-	UCHAR NVM_TargDConfig;	/* 1Dh -> Target D configuration */
-	UCHAR NVM_TargEConfig;	/* 1Eh -> Target E configuration */
-	UCHAR NVM_TargFConfig;	/* 1Fh -> Target F configuration */
-} NVRAM_SCSI;
-
-typedef struct _NVRAM {
-/*----------header ---------------*/
-	USHORT NVM_Signature;	/* 0,1: Signature */
-	UCHAR NVM_Size;		/* 2:   Size of data structure */
-	UCHAR NVM_Revision;	/* 3:   Revision of data structure */
-	/* ----Host Adapter Structure ---- */
-	UCHAR NVM_ModelByte0;	/* 4:   Model number (byte 0) */
-	UCHAR NVM_ModelByte1;	/* 5:   Model number (byte 1) */
-	UCHAR NVM_ModelInfo;	/* 6:   Model information         */
-	UCHAR NVM_NumOfCh;	/* 7:   Number of SCSI channel */
-	UCHAR NVM_BIOSConfig1;	/* 8:   BIOS configuration 1  */
-	UCHAR NVM_BIOSConfig2;	/* 9:   BIOS configuration 2  */
-	UCHAR NVM_HAConfig1;	/* A:   Hoat adapter configuration 1 */
-	UCHAR NVM_HAConfig2;	/* B:   Hoat adapter configuration 2 */
-	NVRAM_SCSI NVM_SCSIInfo[2];
-	UCHAR NVM_reserved[10];
-	/* ---------- CheckSum ----------       */
-	USHORT NVM_CheckSum;	/* 0x3E, 0x3F: Checksum of NVRam        */
-} NVRAM, *PNVRAM;
-
-/* Bios Configuration for nvram->BIOSConfig1                            */
-#define NBC1_ENABLE             0x01	/* BIOS enable                  */
-#define NBC1_8DRIVE             0x02	/* Support more than 2 drives   */
-#define NBC1_REMOVABLE          0x04	/* Support removable drive      */
-#define NBC1_INT19              0x08	/* Intercept int 19h            */
-#define NBC1_BIOSSCAN           0x10	/* Dynamic BIOS scan            */
-#define NBC1_LUNSUPPORT         0x40	/* Support LUN                  */
-
-/* HA Configuration Byte 1                                              */
-#define NHC1_BOOTIDMASK 0x0F	/* Boot ID number               */
-#define NHC1_LUNMASK    0x70	/* Boot LUN number              */
-#define NHC1_CHANMASK   0x80	/* Boot Channel number          */
-
-/* Bit definition for nvram->SCSIconfig1                                */
-#define NCC1_BUSRESET           0x01	/* Reset SCSI bus at power up   */
-#define NCC1_PARITYCHK          0x02	/* SCSI parity enable           */
-#define NCC1_ACTTERM1           0x04	/* Enable active terminator 1   */
-#define NCC1_ACTTERM2           0x08	/* Enable active terminator 2   */
-#define NCC1_AUTOTERM           0x10	/* Enable auto terminator       */
-#define NCC1_PWRMGR             0x80	/* Enable power management      */
-
-/* Bit definition for SCSI Target configuration byte                    */
-#define NTC_DISCONNECT          0x08	/* Enable SCSI disconnect       */
-#define NTC_SYNC                0x10	/* SYNC_NEGO                    */
-#define NTC_NO_WDTR             0x20	/* SYNC_NEGO                    */
-#define NTC_1GIGA               0x40	/* 255 head / 63 sectors (64/32) */
-#define NTC_SPINUP              0x80	/* Start disk drive             */
-
-/*      Default NVRam values                                            */
-#define INI_SIGNATURE           0xC925
-#define NBC1_DEFAULT            (NBC1_ENABLE)
-#define NCC1_DEFAULT            (NCC1_BUSRESET | NCC1_AUTOTERM | NCC1_PARITYCHK)
-#define NTC_DEFAULT             (NTC_NO_WDTR | NTC_1GIGA | NTC_DISCONNECT)
-
-/* SCSI related definition                                              */
-#define DISC_NOT_ALLOW          0x80	/* Disconnect is not allowed    */
-#define DISC_ALLOW              0xC0	/* Disconnect is allowed        */
-#define SCSICMD_RequestSense    0x03
-
-
-/*----------------------------------------------------------------------*/
-/*                              PCI                                     */
-/*----------------------------------------------------------------------*/
-#define PCI_FUNCTION_ID         0xB1
-#define PCI_BIOS_PRESENT        0x01
-#define FIND_PCI_DEVICE         0x02
-#define FIND_PCI_CLASS_CODE     0x03
-#define GENERATE_SPECIAL_CYCLE  0x06
-#define READ_CONFIG_BYTE        0x08
-#define READ_CONFIG_WORD        0x09
-#define READ_CONFIG_DWORD       0x0A
-#define WRITE_CONFIG_BYTE       0x0B
-#define WRITE_CONFIG_WORD       0x0C
-#define WRITE_CONFIG_DWORD      0x0D
-
-#define SUCCESSFUL              0x00
-#define FUNC_NOT_SUPPORTED      0x81
-#define BAD_VENDOR_ID           0x83	/* Bad vendor ID                */
-#define DEVICE_NOT_FOUND        0x86	/* PCI device not found         */
-#define BAD_REGISTER_NUMBER     0x87
-
-#define MAX_PCI_DEVICES         21	/* Maximum devices supportted   */
-
-#define MAX_PCI_CHANL           4
-
-typedef struct _BIOS32_ENTRY_STRUCTURE {
-	DWORD Signatures;	/* Should be "_32_"             */
-	DWORD BIOS32Entry;	/* 32-bit physical address      */
-	BYTE Revision;		/* Revision level, should be 0  */
-	BYTE Length;		/* Multiply of 16, should be 1  */
-	BYTE CheckSum;		/* Checksum of whole structure  */
-	BYTE Reserved[5];	/* Reserved                     */
-} BIOS32_ENTRY_STRUCTURE, *PBIOS32_ENTRY_STRUCTURE;
-
-typedef struct {
-	union {
-		unsigned int eax;
-		struct {
-			unsigned short ax;
-		} word;
-		struct {
-			unsigned char al;
-			unsigned char ah;
-		} byte;
-	} eax;
-	union {
-		unsigned int ebx;
-		struct {
-			unsigned short bx;
-		} word;
-		struct {
-			unsigned char bl;
-			unsigned char bh;
-		} byte;
-	} ebx;
-	union {
-		unsigned int ecx;
-		struct {
-			unsigned short cx;
-		} word;
-		struct {
-			unsigned char cl;
-			unsigned char ch;
-		} byte;
-	} ecx;
-	union {
-		unsigned int edx;
-		struct {
-			unsigned short dx;
-		} word;
-		struct {
-			unsigned char dl;
-			unsigned char dh;
-		} byte;
-	} edx;
-	union {
-		unsigned int edi;
-		struct {
-			unsigned short di;
-		} word;
-	} edi;
-	union {
-		unsigned int esi;
-		struct {
-			unsigned short si;
-		} word;
-	} esi;
-} REGS;
-
-typedef union {			/* Union define for mechanism 1 */
-	struct {
-		unsigned char RegNum;
-		unsigned char FcnNum:3;
-		unsigned char DeviceNum:5;
-		unsigned char BusNum;
-		unsigned char Reserved:7;
-		unsigned char Enable:1;
-	} sConfigAdr;
-	unsigned long lConfigAdr;
-} CONFIG_ADR;
-
-typedef union {			/* Union define for mechanism 2 */
-	struct {
-		unsigned char RegNum;
-		unsigned char DeviceNum;
-		unsigned short Reserved;
-	} sHostAdr;
-	unsigned long lHostAdr;
-} HOST_ADR;
-
-typedef struct _HCSinfo {
-	ULONG base;
-	UCHAR vec;
-	UCHAR bios;		/* High byte of BIOS address */
-	USHORT BaseAndBios;	/* high byte: pHcsInfo->bios,low byte:pHcsInfo->base */
-} HCSINFO;
-
-#define TUL_RD(x,y)             (UCHAR)(inb(  (int)((ULONG)(x+y)) ))
-#define TUL_RDLONG(x,y)         (ULONG)(inl((int)((ULONG)(x+y)) ))
-#define TUL_WR(     adr,data)   outb( (UCHAR)(data), (int)(adr))
-#define TUL_WRSHORT(adr,data)   outw( (UWORD)(data), (int)(adr))
-#define TUL_WRLONG( adr,data)   outl( (ULONG)(data), (int)(adr))
-
-#define SCSI_ABORT_SNOOZE 0
-#define SCSI_ABORT_SUCCESS 1
-#define SCSI_ABORT_PENDING 2
-#define SCSI_ABORT_BUSY 3
-#define SCSI_ABORT_NOT_RUNNING 4
-#define SCSI_ABORT_ERROR 5
-
-#define SCSI_RESET_SNOOZE 0
-#define SCSI_RESET_PUNT 1
-#define SCSI_RESET_SUCCESS 2
-#define SCSI_RESET_PENDING 3
-#define SCSI_RESET_WAKEUP 4
-#define SCSI_RESET_NOT_RUNNING 5
-#define SCSI_RESET_ERROR 6
-
-#define SCSI_RESET_SYNCHRONOUS		0x01
-#define SCSI_RESET_ASYNCHRONOUS		0x02
-#define SCSI_RESET_SUGGEST_BUS_RESET	0x04
-#define SCSI_RESET_SUGGEST_HOST_RESET	0x08
-
-#define SCSI_RESET_BUS_RESET 0x100
-#define SCSI_RESET_HOST_RESET 0x200
-#define SCSI_RESET_ACTION   0xff
diff -Nru a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c	2004-12-24 13:37:02 -08:00
@@ -204,7 +204,7 @@
 	}
 
 	queue->cur = 0;
-	queue->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&queue->lock);
 
 	tasklet_init(&hostdata->srp_task, (void *)ibmvscsi_task,
 		     (unsigned long)hostdata);
diff -Nru a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
--- a/drivers/scsi/ide-scsi.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/ide-scsi.c	2004-12-24 13:37:00 -08:00
@@ -45,13 +45,17 @@
 #include <linux/hdreg.h>
 #include <linux/slab.h>
 #include <linux/ide.h>
+#include <linux/scatterlist.h>
 
 #include <asm/io.h>
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
 
-#include "scsi.h"
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
 #include <scsi/sg.h>
 
 #define IDESCSI_DEBUG_LOG		0
@@ -66,8 +70,8 @@
 	u8 *current_position;			/* Pointer into the above buffer */
 	struct scatterlist *sg;			/* Scatter gather table */
 	int b_count;				/* Bytes transferred from current entry */
-	Scsi_Cmnd *scsi_cmd;			/* SCSI command */
-	void (*done)(Scsi_Cmnd *);		/* Scsi completion routine */
+	struct scsi_cmnd *scsi_cmd;		/* SCSI command */
+	void (*done)(struct scsi_cmnd *);	/* Scsi completion routine */
 	unsigned long flags;			/* Status/Action flags */
 	unsigned long timeout;			/* Command timeout */
 } idescsi_pc_t;
@@ -250,17 +254,6 @@
 		kfree(atapi_buf);
 }
 
-static inline void idescsi_free_bio (struct bio *bio)
-{
-	struct bio *bhp;
-
-	while (bio) {
-		bhp = bio;
-		bio = bio->bi_next;
-		bio_put(bhp);
-	}
-}
-
 static void hexdump(u8 *x, int len)
 {
 	int i;
@@ -418,7 +411,6 @@
 	spin_lock_irqsave(host->host_lock, flags);
 	pc->done(pc->scsi_cmd);
 	spin_unlock_irqrestore(host->host_lock, flags);
-	idescsi_free_bio(rq->bio);
 	kfree(pc);
 	kfree(rq);
 	scsi->pc = NULL;
@@ -552,6 +544,7 @@
 
 static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
 {
+	ide_hwif_t *hwif = drive->hwif;
 	idescsi_scsi_t *scsi = drive_to_idescsi(drive);
 	idescsi_pc_t *pc = scsi->pc;
 	atapi_ireason_t ireason;
@@ -576,20 +569,64 @@
 	atapi_output_bytes(drive, scsi->pc->c, 12);
 	if (test_bit (PC_DMA_OK, &pc->flags)) {
 		set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
-		(void) (HWIF(drive)->ide_dma_begin(drive));
+		hwif->dma_start(drive);
 	}
 	return ide_started;
 }
 
+static inline int idescsi_set_direction(idescsi_pc_t *pc)
+{
+	switch (pc->c[0]) {
+		case READ_6: case READ_10: case READ_12:
+			clear_bit(PC_WRITING, &pc->flags);
+			return 0;
+		case WRITE_6: case WRITE_10: case WRITE_12:
+			set_bit(PC_WRITING, &pc->flags);
+			return 0;
+		default:
+			return 1;
+	}
+}
+
+static int idescsi_map_sg(ide_drive_t *drive, idescsi_pc_t *pc)
+{
+	ide_hwif_t *hwif = drive->hwif;
+	struct scatterlist *sg, *scsi_sg;
+	int segments;
+
+	if (!pc->request_transfer || pc->request_transfer % 1024)
+		return 1;
+
+	if (idescsi_set_direction(pc))
+		return 1;
+
+	sg = hwif->sg_table;
+	scsi_sg = pc->scsi_cmd->request_buffer;
+	segments = pc->scsi_cmd->use_sg;
+
+	if (segments > hwif->sg_max_nents)
+		return 1;
+
+	if (!segments) {
+		hwif->sg_nents = 1;
+		sg_init_one(sg, pc->scsi_cmd->request_buffer, pc->request_transfer);
+	} else {
+		hwif->sg_nents = segments;
+		memcpy(sg, scsi_sg, sizeof(*sg) * segments);
+	}
+
+	return 0;
+}
+
 /*
  *	Issue a packet command
  */
 static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
 {
 	idescsi_scsi_t *scsi = drive_to_idescsi(drive);
+	ide_hwif_t *hwif = drive->hwif;
 	atapi_feature_t feature;
 	atapi_bcount_t bcount;
-	struct request *rq = pc->rq;
 
 	scsi->pc=pc;							/* Set the current packet command */
 	pc->actually_transferred=0;					/* We haven't transferred any data yet */
@@ -597,11 +634,10 @@
 	bcount.all = min(pc->request_transfer, 63 * 1024);		/* Request to transfer the entire buffer at once */
 
 	feature.all = 0;
-	if (drive->using_dma && rq->bio) {
-		if (test_bit(PC_WRITING, &pc->flags))
-			feature.b.dma = !HWIF(drive)->ide_dma_write(drive);
-		else
-			feature.b.dma = !HWIF(drive)->ide_dma_read(drive);
+	if (drive->using_dma && !idescsi_map_sg(drive, pc)) {
+		hwif->sg_mapped = 1;
+		feature.b.dma = !hwif->dma_setup(drive);
+		hwif->sg_mapped = 0;
 	}
 
 	SELECT_DRIVE(drive);
@@ -747,7 +783,7 @@
 
 static int idescsi_attach(ide_drive_t *drive);
 
-static int idescsi_slave_configure(Scsi_Device * sdp)
+static int idescsi_slave_configure(struct scsi_device * sdp)
 {
 	/* Configure detected device */
 	scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, sdp->host->cmd_per_lun);
@@ -759,7 +795,7 @@
 	return "SCSI host adapter emulation for IDE ATAPI devices";
 }
 
-static int idescsi_ioctl (Scsi_Device *dev, int cmd, void __user *arg)
+static int idescsi_ioctl (struct scsi_device *dev, int cmd, void __user *arg)
 {
 	idescsi_scsi_t *scsi = scsihost_to_idescsi(dev->host);
 
@@ -774,82 +810,7 @@
 	return -EINVAL;
 }
 
-static inline struct bio *idescsi_kmalloc_bio (int count)
-{
-	struct bio *bh, *bhp, *first_bh;
-
-	if ((first_bh = bhp = bh = bio_alloc(GFP_ATOMIC, 1)) == NULL)
-		goto abort;
-	bio_init(bh);
-	bh->bi_vcnt = 1;
-	while (--count) {
-		if ((bh = bio_alloc(GFP_ATOMIC, 1)) == NULL)
-			goto abort;
-		bio_init(bh);
-		bh->bi_vcnt = 1;
-		bhp->bi_next = bh;
-		bhp = bh;
-		bh->bi_next = NULL;
-	}
-	return first_bh;
-abort:
-	idescsi_free_bio (first_bh);
-	return NULL;
-}
-
-static inline int idescsi_set_direction (idescsi_pc_t *pc)
-{
-	switch (pc->c[0]) {
-		case READ_6: case READ_10: case READ_12:
-			clear_bit (PC_WRITING, &pc->flags);
-			return 0;
-		case WRITE_6: case WRITE_10: case WRITE_12:
-			set_bit (PC_WRITING, &pc->flags);
-			return 0;
-		default:
-			return 1;
-	}
-}
-
-static inline struct bio *idescsi_dma_bio(ide_drive_t *drive, idescsi_pc_t *pc)
-{
-	struct bio *bh = NULL, *first_bh = NULL;
-	int segments = pc->scsi_cmd->use_sg;
-	struct scatterlist *sg = pc->scsi_cmd->request_buffer;
-
-	if (!drive->using_dma || !pc->request_transfer || pc->request_transfer % 1024)
-		return NULL;
-	if (idescsi_set_direction(pc))
-		return NULL;
-	if (segments) {
-		if ((first_bh = bh = idescsi_kmalloc_bio (segments)) == NULL)
-			return NULL;
-#if IDESCSI_DEBUG_LOG
-		printk ("ide-scsi: %s: building DMA table, %d segments, %dkB total\n", drive->name, segments, pc->request_transfer >> 10);
-#endif /* IDESCSI_DEBUG_LOG */
-		while (segments--) {
-			bh->bi_io_vec[0].bv_page = sg->page;
-			bh->bi_io_vec[0].bv_len = sg->length;
-			bh->bi_io_vec[0].bv_offset = sg->offset;
-			bh->bi_size = sg->length;
-			bh = bh->bi_next;
-			sg++;
-		}
-	} else {
-		if ((first_bh = bh = idescsi_kmalloc_bio (1)) == NULL)
-			return NULL;
-#if IDESCSI_DEBUG_LOG
-		printk ("ide-scsi: %s: building DMA table for a single buffer (%dkB)\n", drive->name, pc->request_transfer >> 10);
-#endif /* IDESCSI_DEBUG_LOG */
-		bh->bi_io_vec[0].bv_page = virt_to_page(pc->scsi_cmd->request_buffer);
-		bh->bi_io_vec[0].bv_offset = offset_in_page(pc->scsi_cmd->request_buffer);
-		bh->bi_io_vec[0].bv_len = pc->request_transfer;
-		bh->bi_size = pc->request_transfer;
-	}
-	return first_bh;
-}
-
-static inline int should_transform(ide_drive_t *drive, Scsi_Cmnd *cmd)
+static inline int should_transform(ide_drive_t *drive, struct scsi_cmnd *cmd)
 {
 	idescsi_scsi_t *scsi = drive_to_idescsi(drive);
 
@@ -867,7 +828,8 @@
 	return test_bit(IDESCSI_TRANSFORM, &scsi->transform);
 }
 
-static int idescsi_queue (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
+static int idescsi_queue (struct scsi_cmnd *cmd,
+		void (*done)(struct scsi_cmnd *))
 {
 	struct Scsi_Host *host = cmd->device->host;
 	idescsi_scsi_t *scsi = scsihost_to_idescsi(host);
@@ -919,7 +881,6 @@
 
 	ide_init_drive_cmd (rq);
 	rq->special = (char *) pc;
-	rq->bio = idescsi_dma_bio (drive, pc);
 	rq->flags = REQ_SPECIAL;
 	spin_unlock_irq(host->host_lock);
 	(void) ide_do_drive_cmd (drive, rq, ide_end);
@@ -930,10 +891,10 @@
 	if (rq) kfree (rq);
 	cmd->result = DID_ERROR << 16;
 	done(cmd);
-	return 1;
+	return 0;
 }
 
-static int idescsi_eh_abort (Scsi_Cmnd *cmd)
+static int idescsi_eh_abort (struct scsi_cmnd *cmd)
 {
 	idescsi_scsi_t *scsi  = scsihost_to_idescsi(cmd->device->host);
 	ide_drive_t    *drive = scsi->drive;
@@ -973,7 +934,6 @@
 		 */
 		printk (KERN_ERR "ide-scsi: cmd aborted!\n");
 
-		idescsi_free_bio(scsi->pc->rq->bio);
 		if (scsi->pc->rq->flags & REQ_SENSE)
 			kfree(scsi->pc->buffer);
 		kfree(scsi->pc->rq);
@@ -992,7 +952,7 @@
 	return ret;
 }
 
-static int idescsi_eh_reset (Scsi_Cmnd *cmd)
+static int idescsi_eh_reset (struct scsi_cmnd *cmd)
 {
 	struct request *req;
 	idescsi_scsi_t *scsi  = scsihost_to_idescsi(cmd->device->host);
@@ -1022,7 +982,6 @@
 	/* kill current request */
 	blkdev_dequeue_request(req);
 	end_that_request_last(req);
-	idescsi_free_bio(req->bio);
 	if (req->flags & REQ_SENSE)
 		kfree(scsi->pc->buffer);
 	kfree(scsi->pc);
@@ -1075,7 +1034,7 @@
 	return 0;
 }
 
-static Scsi_Host_Template idescsi_template = {
+static struct scsi_host_template idescsi_template = {
 	.module			= THIS_MODULE,
 	.name			= "idescsi",
 	.info			= idescsi_info,
diff -Nru a/drivers/scsi/imm.c b/drivers/scsi/imm.c
--- a/drivers/scsi/imm.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/scsi/imm.c	2004-12-24 13:37:30 -08:00
@@ -1140,6 +1140,10 @@
 	.use_clustering		= ENABLE_CLUSTERING,
 	.can_queue		= 1,
 	.slave_alloc		= imm_adjust_queue,
+	.unchecked_isa_dma	= 1, /* imm cannot deal with highmem, so
+				      * this is an easy trick to ensure
+				      * all io pages for this host reside
+				      * in low memory */
 };
 
 /***************************************************************************
diff -Nru a/drivers/scsi/ini9100u.c b/drivers/scsi/ini9100u.c
--- a/drivers/scsi/ini9100u.c	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,727 +0,0 @@
-/**************************************************************************
- * Initio 9100 device driver for Linux.
- *
- * Copyright (c) 1994-1998 Initio Corporation
- * Copyright (c) 1998 Bas Vermeulen <bvermeul@blackstar.xs4all.nl>
- * 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, 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; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * --------------------------------------------------------------------------
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU General Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- *************************************************************************
- *
- * DESCRIPTION:
- *
- * This is the Linux low-level SCSI driver for Initio INI-9X00U/UW SCSI host
- * adapters
- *
- * 08/06/97 hc	- v1.01h
- *		- Support inic-940 and inic-935
- * 09/26/97 hc	- v1.01i
- *		- Make correction from J.W. Schultz suggestion
- * 10/13/97 hc	- Support reset function
- * 10/21/97 hc	- v1.01j
- *		- Support 32 LUN (SCSI 3)
- * 01/14/98 hc	- v1.01k
- *		- Fix memory allocation problem
- * 03/04/98 hc	- v1.01l
- *		- Fix tape rewind which will hang the system problem
- *		- Set can_queue to tul_num_scb
- * 06/25/98 hc	- v1.01m
- *		- Get it work for kernel version >= 2.1.75
- *		- Dynamic assign SCSI bus reset holding time in init_tulip()
- * 07/02/98 hc	- v1.01n
- *		- Support 0002134A
- * 08/07/98 hc  - v1.01o
- *		- Change the tul_abort_srb routine to use scsi_done. <01>
- * 09/07/98 hl  - v1.02
- *              - Change the INI9100U define and proc_dir_entry to
- *                reflect the newer Kernel 2.1.118, but the v1.o1o
- *                should work with Kernel 2.1.118.
- * 09/20/98 wh  - v1.02a
- *              - Support Abort command.
- *              - Handle reset routine.
- * 09/21/98 hl  - v1.03
- *              - remove comments.
- * 12/09/98 bv	- v1.03a
- *		- Removed unused code
- * 12/13/98 bv	- v1.03b
- *		- Remove cli() locking for kernels >= 2.1.95. This uses
- *		  spinlocks to serialize access to the pSRB_head and
- *		  pSRB_tail members of the HCS structure.
- * 09/01/99 bv	- v1.03d
- *		- Fixed a deadlock problem in SMP.
- * 21/01/99 bv	- v1.03e
- *		- Add support for the Domex 3192U PCI SCSI
- *		  This is a slightly modified patch by
- *		  Brian Macy <bmacy@sunshinecomputing.com>
- * 22/02/99 bv	- v1.03f
- *		- Didn't detect the INIC-950 in 2.0.x correctly.
- *		  Now fixed.
- * 05/07/99 bv	- v1.03g
- *		- Changed the assumption that HZ = 100
- * 10/17/03 mc	- v1.04
- *		- added new DMA API support
- * 06/01/04 jmd	- v1.04a
- *		- Re-add reset_bus support
- **************************************************************************/
-
-#define CVT_LINUX_VERSION(V,P,S)        (V * 65536 + P * 256 + S)
-
-#ifndef LINUX_VERSION_CODE
-#include <linux/version.h>
-#endif
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/blkdev.h>
-#include <linux/spinlock.h>
-#include <linux/stat.h>
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/proc_fs.h>
-#include <linux/string.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-
-#include <asm/io.h>
-
-#include "scsi.h"
-#include <scsi/scsi_host.h>
-#include "ini9100u.h"
-
-#ifdef DEBUG_i91u
-unsigned int i91u_debug = DEBUG_DEFAULT;
-#endif
-
-static Scsi_Host_Template driver_template = {
-	.proc_name	= "INI9100U",
-	.name		= i91u_REVID,
-	.detect		= i91u_detect,
-	.release	= i91u_release,
-	.queuecommand	= i91u_queue,
-//	.abort		= i91u_abort,
-//	.reset		= i91u_reset,
-	.eh_bus_reset_handler = i91u_bus_reset,
-	.bios_param	= i91u_biosparam,
-	.can_queue	= 1,
-	.this_id	= 1,
-	.sg_tablesize	= SG_ALL,
-	.cmd_per_lun 	= 1,
-	.use_clustering	= ENABLE_CLUSTERING,
-};
-#include "scsi_module.c"
-
-char *i91uCopyright = "Copyright (C) 1996-98";
-char *i91uInitioName = "by Initio Corporation";
-char *i91uProductName = "INI-9X00U/UW";
-char *i91uVersion = "v1.04a";
-
-#define TULSZ(sz)     (sizeof(sz) / sizeof(sz[0]))
-#define TUL_RDWORD(x,y)         (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
-
-/* set by i91_setup according to the command line */
-static int setup_called = 0;
-
-static int tul_num_ch = 4;	/* Maximum 4 adapters           */
-static int tul_num_scb;
-static int tul_tag_enable = 1;
-static SCB *tul_scb;
-
-#ifdef DEBUG_i91u
-static int setup_debug = 0;
-#endif
-
-static char *setup_str = (char *) NULL;
-
-static void i91u_panic(char *msg);
-
-static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
-
-				/* ---- EXTERNAL FUNCTIONS ---- */
-					/* Get total number of adapters */
-extern void init_i91uAdapter_table(void);
-extern int Addi91u_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE);
-extern int tul_ReturnNumberOfAdapters(void);
-extern void get_tulipPCIConfig(HCS * pHCB, int iChannel_index);
-extern int init_tulip(HCS * pHCB, SCB * pSCB, int tul_num_scb, BYTE * pbBiosAdr, int reset_time);
-extern SCB *tul_alloc_scb(HCS * pHCB);
-extern int tul_abort_srb(HCS * pHCB, Scsi_Cmnd * pSRB);
-extern void tul_exec_scb(HCS * pHCB, SCB * pSCB);
-extern void tul_release_scb(HCS * pHCB, SCB * pSCB);
-extern void tul_stop_bm(HCS * pHCB);
-extern int tul_reset_scsi(HCS * pCurHcb, int seconds);
-extern int tul_isr(HCS * pHCB);
-extern int tul_reset(HCS * pHCB, Scsi_Cmnd * pSRB, unsigned char target);
-extern int tul_reset_scsi_bus(HCS * pCurHcb);
-extern int tul_device_reset(HCS * pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags);
-				/* ---- EXTERNAL VARIABLES ---- */
-extern HCS tul_hcs[];
-
-const PCI_ID i91u_pci_devices[] = {
-	{ INI_VENDOR_ID, I950_DEVICE_ID },
-	{ INI_VENDOR_ID, I940_DEVICE_ID },
-	{ INI_VENDOR_ID, I935_DEVICE_ID },
-	{ INI_VENDOR_ID, I920_DEVICE_ID },
-	{ DMX_VENDOR_ID, I920_DEVICE_ID },
-};
-
-/*
- *  queue services:
- */
-/*****************************************************************************
- Function name  : i91uAppendSRBToQueue
- Description    : This function will push current request into save list
- Input          : pSRB  -       Pointer to SCSI request block.
-		  pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : None.
-*****************************************************************************/
-static void i91uAppendSRBToQueue(HCS * pHCB, Scsi_Cmnd * pSRB)
-{
-	ULONG flags;
-	spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
-
-	pSRB->host_scribble = NULL;	/* Pointer to next */
-
-	if (pHCB->pSRB_head == NULL)
-		pHCB->pSRB_head = pSRB;
-	else
-		pHCB->pSRB_tail->host_scribble = (char *)pSRB;	/* Pointer to next */
-	pHCB->pSRB_tail = pSRB;
-
-	spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
-	return;
-}
-
-/*****************************************************************************
- Function name  : i91uPopSRBFromQueue
- Description    : This function will pop current request from save list
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-static Scsi_Cmnd *i91uPopSRBFromQueue(HCS * pHCB)
-{
-	Scsi_Cmnd *pSRB;
-	ULONG flags;
-
-	spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
-
-	if ((pSRB = pHCB->pSRB_head) != NULL) {
-		pHCB->pSRB_head = (struct scsi_cmnd *)pHCB->pSRB_head->host_scribble;
-		pSRB->host_scribble = NULL;
-	}
-	spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
-
-	return (pSRB);
-}
-
-static irqreturn_t i91u_intr(int irqno, void *dev_id, struct pt_regs *regs)
-{
-	struct Scsi_Host *dev = dev_id;
-	unsigned long flags;
-	
-	spin_lock_irqsave(dev->host_lock, flags);
-	tul_isr((HCS *)dev->base);
-	spin_unlock_irqrestore(dev->host_lock, flags);
-	return IRQ_HANDLED;
-}
-
-/* called from init/main.c */
-
-void i91u_setup(char *str, int *ints)
-{
-	if (setup_called)
-		i91u_panic("i91u: i91u_setup called twice.\n");
-
-	setup_called = ints[0];
-	setup_str = str;
-
-#ifdef DEBUG_i91u
-	setup_debug = ints[0] >= 1 ? ints[1] : DEBUG_DEFAULT;
-#endif
-}
-
-int tul_NewReturnNumberOfAdapters(void)
-{
-	struct pci_dev *pDev = NULL;	/* Start from none              */
-	int iAdapters = 0;
-	long dRegValue;
-	WORD wBIOS;
-	int i = 0;
-
-	init_i91uAdapter_table();
-
-	for (i = 0; i < TULSZ(i91u_pci_devices); i++)
-	{
-		while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) {
-			if (pci_enable_device(pDev))
-				continue;
-			pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
-			wBIOS = (UWORD) (dRegValue & 0xFF);
-			if (((dRegValue & 0xFF00) >> 8) == 0xFF)
-				dRegValue = 0;
-			wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8));
-			if (pci_set_dma_mask(pDev, 0xffffffff)) {
-				printk(KERN_WARNING 
-				       "i91u: Could not set 32 bit DMA mask\n");
-				continue;
-			}
-
-			if (Addi91u_into_Adapter_table(wBIOS,
-							(pDev->resource[0].start),
-						       	pDev->irq,
-						       	pDev->bus->number,
-					       		(pDev->devfn >> 3)
-		    		) == 0)
-				iAdapters++;
-		}
-	}
-
-	return (iAdapters);
-}
-
-int i91u_detect(Scsi_Host_Template * tpnt)
-{
-	HCS *pHCB;
-	struct Scsi_Host *hreg;
-	unsigned long i;	/* 01/14/98                     */
-	int ok = 0, iAdapters;
-	ULONG dBiosAdr;
-	BYTE *pbBiosAdr;
-
-	tpnt->proc_name = "INI9100U";
-
-	if (setup_called) {	/* Setup by i91u_setup          */
-		printk("i91u: processing commandline: ");
-
-#ifdef DEBUG_i91u
-		if (setup_called > 1) {
-			printk("\ni91u: %s\n", setup_str);
-			printk("i91u: usage: i91u[=<DEBUG>]\n");
-			i91u_panic("i91u panics in line %d", __LINE__);
-		}
-		i91u_debug = setup_debug;
-#endif
-	}
-	/* Get total number of adapters in the motherboard */
-	iAdapters = tul_NewReturnNumberOfAdapters();
-	if (iAdapters == 0)	/* If no tulip founded, return */
-		return (0);
-
-	tul_num_ch = (iAdapters > tul_num_ch) ? tul_num_ch : iAdapters;
-	/* Update actually channel number */
-	if (tul_tag_enable) {	/* 1.01i                  */
-		tul_num_scb = MAX_TARGETS * i91u_MAXQUEUE;
-	} else {
-		tul_num_scb = MAX_TARGETS + 3;	/* 1-tape, 1-CD_ROM, 1- extra */
-	}			/* Update actually SCBs per adapter */
-
-	/* Get total memory needed for HCS */
-	i = tul_num_ch * sizeof(HCS);
-	memset((unsigned char *) &tul_hcs[0], 0, i);	/* Initialize tul_hcs 0 */
-	/* Get total memory needed for SCB */
-
-	for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) {
-		i = tul_num_ch * tul_num_scb * sizeof(SCB);
-		if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL)
-			break;
-	}
-	if (tul_scb == NULL) {
-		printk("i91u: SCB memory allocation error\n");
-		return (0);
-	}
-	memset((unsigned char *) tul_scb, 0, i);
-
-	for (i = 0, pHCB = &tul_hcs[0];		/* Get pointer for control block */
-	     i < tul_num_ch;
-	     i++, pHCB++) {
-		pHCB->pSRB_head = NULL;		/* Initial SRB save queue       */
-		pHCB->pSRB_tail = NULL;		/* Initial SRB save queue       */
-		pHCB->pSRB_lock = SPIN_LOCK_UNLOCKED;	/* SRB save queue lock */
-		get_tulipPCIConfig(pHCB, i);
-
-		dBiosAdr = pHCB->HCS_BIOS;
-		dBiosAdr = (dBiosAdr << 4);
-
-		pbBiosAdr = phys_to_virt(dBiosAdr);
-
-		init_tulip(pHCB, tul_scb + (i * tul_num_scb), tul_num_scb, pbBiosAdr, 10);
-		request_region(pHCB->HCS_Base, 256, "i91u"); /* Register */ 
-
-		pHCB->HCS_Index = i;	/* 7/29/98 */
-		hreg = scsi_register(tpnt, sizeof(HCS));
-		if(hreg == NULL) {
-			release_region(pHCB->HCS_Base, 256);
-			return 0;
-		}
-		hreg->io_port = pHCB->HCS_Base;
-		hreg->n_io_port = 0xff;
-		hreg->can_queue = tul_num_scb;	/* 03/05/98                      */
-		hreg->unique_id = pHCB->HCS_Base;
-		hreg->max_id = pHCB->HCS_MaxTar;
-		hreg->max_lun = 32;	/* 10/21/97                     */
-		hreg->irq = pHCB->HCS_Intr;
-		hreg->this_id = pHCB->HCS_SCSI_ID;	/* Assign HCS index           */
-		hreg->base = (unsigned long)pHCB;
-		hreg->sg_tablesize = TOTAL_SG_ENTRY;	/* Maximun support is 32 */
-
-		/* Initial tulip chip           */
-		ok = request_irq(pHCB->HCS_Intr, i91u_intr, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
-		if (ok < 0) {
-			printk(KERN_WARNING "i91u: unable to request IRQ %d\n\n", pHCB->HCS_Intr);
-			return 0;
-		}
-	}
-
-	tpnt->this_id = -1;
-	tpnt->can_queue = 1;
-
-	return 1;
-}
-
-static void i91uBuildSCB(HCS * pHCB, SCB * pSCB, Scsi_Cmnd * SCpnt)
-{				/* Create corresponding SCB     */
-	struct scatterlist *pSrbSG;
-	SG *pSG;		/* Pointer to SG list           */
-	int i;
-	long TotalLen;
-	dma_addr_t dma_addr;
-
-	pSCB->SCB_Post = i91uSCBPost;	/* i91u's callback routine      */
-	pSCB->SCB_Srb = SCpnt;
-	pSCB->SCB_Opcode = ExecSCSI;
-	pSCB->SCB_Flags = SCF_POST;	/* After SCSI done, call post routine */
-	pSCB->SCB_Target = SCpnt->device->id;
-	pSCB->SCB_Lun = SCpnt->device->lun;
-	pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW;
-
-	pSCB->SCB_Flags |= SCF_SENSE;	/* Turn on auto request sense   */
-	dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->sense_buffer,
-				  SENSE_SIZE, DMA_FROM_DEVICE);
-	pSCB->SCB_SensePtr = cpu_to_le32((u32)dma_addr);
-	pSCB->SCB_SenseLen = cpu_to_le32(SENSE_SIZE);
-	SCpnt->SCp.ptr = (char *)(unsigned long)dma_addr;
-
-	pSCB->SCB_CDBLen = SCpnt->cmd_len;
-	pSCB->SCB_HaStat = 0;
-	pSCB->SCB_TaStat = 0;
-	memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, SCpnt->cmd_len);
-
-	if (SCpnt->device->tagged_supported) {	/* Tag Support                  */
-		pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG;	/* Do simple tag only   */
-	} else {
-		pSCB->SCB_TagMsg = 0;	/* No tag support               */
-	}
-	/* todo handle map_sg error */
-	if (SCpnt->use_sg) {
-		dma_addr = dma_map_single(&pHCB->pci_dev->dev, &pSCB->SCB_SGList[0],
-					  sizeof(struct SG_Struc) * TOTAL_SG_ENTRY,
-					  DMA_BIDIRECTIONAL);
-		pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
-		SCpnt->SCp.dma_handle = dma_addr;
-
-		pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
-		pSCB->SCB_SGLen = dma_map_sg(&pHCB->pci_dev->dev, pSrbSG,
-					     SCpnt->use_sg, SCpnt->sc_data_direction);
-
-		pSCB->SCB_Flags |= SCF_SG;	/* Turn on SG list flag       */
-		for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0];	/* 1.01g */
-		     i < pSCB->SCB_SGLen; i++, pSG++, pSrbSG++) {
-			pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG));
-			TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG));
-		}
-
-		pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ?
-		    TotalLen : SCpnt->request_bufflen;
-	} else if (SCpnt->request_bufflen) {		/* Non SG */
-		dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->request_buffer,
-					  SCpnt->request_bufflen,
-					  SCpnt->sc_data_direction);
-		SCpnt->SCp.dma_handle = dma_addr;
-		pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
-		pSCB->SCB_BufLen = cpu_to_le32((u32)SCpnt->request_bufflen);
-		pSCB->SCB_SGLen = 0;
-	} else {
-		pSCB->SCB_BufLen = 0;
-		pSCB->SCB_SGLen = 0;
-	}
-}
-
-/* 
- *  Queue a command and setup interrupts for a free bus.
- */
-int i91u_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
-{
-	register SCB *pSCB;
-	HCS *pHCB;		/* Point to Host adapter control block */
-
-	if (SCpnt->device->lun > 16) {	/* 07/22/98 */
-
-		SCpnt->result = (DID_TIME_OUT << 16);
-		done(SCpnt);	/* Notify system DONE           */
-		return (0);
-	}
-	pHCB = (HCS *) SCpnt->device->host->base;
-
-	SCpnt->scsi_done = done;
-	/* Get free SCSI control block  */
-	if ((pSCB = tul_alloc_scb(pHCB)) == NULL) {
-		i91uAppendSRBToQueue(pHCB, SCpnt);	/* Buffer this request  */
-		return (0);
-	}
-	i91uBuildSCB(pHCB, pSCB, SCpnt);
-	tul_exec_scb(pHCB, pSCB);	/* Start execute SCB            */
-	return (0);
-}
-
-/*
- *  Abort a queued command
- *  (commands that are on the bus can't be aborted easily)
- */
-int i91u_abort(Scsi_Cmnd * SCpnt)
-{
-	HCS *pHCB;
-
-	pHCB = (HCS *) SCpnt->device->host->base;
-	return tul_abort_srb(pHCB, SCpnt);
-}
-
-/*
- *  Reset registers, reset a hanging bus and
- *  kill active and disconnected commands for target w/o soft reset
- */
-int i91u_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags)
-{				/* I need Host Control Block Information */
-	HCS *pHCB;
-
-	pHCB = (HCS *) SCpnt->device->host->base;
-
-	if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET | SCSI_RESET_SUGGEST_HOST_RESET))
-		return tul_reset_scsi_bus(pHCB);
-	else
-		return tul_device_reset(pHCB, (ULONG) SCpnt, SCpnt->device->id, reset_flags);
-}
-
-int i91u_bus_reset(Scsi_Cmnd * SCpnt)
-{
-	HCS *pHCB;
-
-	pHCB = (HCS *) SCpnt->device->host->base;
-	tul_reset_scsi(pHCB, 0);
-	return SUCCESS;
-}
-
-/*
- * Return the "logical geometry"
- */
-int i91u_biosparam(struct scsi_device *sdev, struct block_device *dev,
-		sector_t capacity, int *info_array)
-{
-	HCS *pHcb;		/* Point to Host adapter control block */
-	TCS *pTcb;
-
-	pHcb = (HCS *) sdev->host->base;
-	pTcb = &pHcb->HCS_Tcs[sdev->id];
-
-	if (pTcb->TCS_DrvHead) {
-		info_array[0] = pTcb->TCS_DrvHead;
-		info_array[1] = pTcb->TCS_DrvSector;
-		info_array[2] = (unsigned long)capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector;
-	} else {
-		if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) {
-			info_array[0] = 255;
-			info_array[1] = 63;
-			info_array[2] = (unsigned long)capacity / 255 / 63;
-		} else {
-			info_array[0] = 64;
-			info_array[1] = 32;
-			info_array[2] = (unsigned long)capacity >> 11;
-		}
-	}
-
-#if defined(DEBUG_BIOSPARAM)
-	if (i91u_debug & debug_biosparam) {
-		printk("bios geometry: head=%d, sec=%d, cyl=%d\n",
-		       info_array[0], info_array[1], info_array[2]);
-		printk("WARNING: check, if the bios geometry is correct.\n");
-	}
-#endif
-
-	return 0;
-}
-
-static void i91u_unmap_cmnd(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd)
-{
-	/* auto sense buffer */
-	if (cmnd->SCp.ptr) {
-		dma_unmap_single(&pci_dev->dev,
-				 (dma_addr_t)((unsigned long)cmnd->SCp.ptr),
-				 SENSE_SIZE, SCSI_DATA_READ);
-		cmnd->SCp.ptr = NULL;
-	}
-
-	/* request buffer */
-	if (cmnd->use_sg) {
-		dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle,
-				 sizeof(struct SG_Struc) * TOTAL_SG_ENTRY,
-				 DMA_BIDIRECTIONAL);
-
-		dma_unmap_sg(&pci_dev->dev, cmnd->request_buffer,
-			     cmnd->use_sg,
-			     cmnd->sc_data_direction);
-	} else if (cmnd->request_bufflen) {
-		dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle,
-				 cmnd->request_bufflen,
-				 cmnd->sc_data_direction);
-	}
-}
-
-/*****************************************************************************
- Function name  : i91uSCBPost
- Description    : This is callback routine be called when tulip finish one
-			SCSI command.
- Input          : pHCB  -       Pointer to host adapter control block.
-		  pSCB  -       Pointer to SCSI control block.
- Output         : None.
- Return         : None.
-*****************************************************************************/
-static void i91uSCBPost(BYTE * pHcb, BYTE * pScb)
-{
-	Scsi_Cmnd *pSRB;	/* Pointer to SCSI request block */
-	HCS *pHCB;
-	SCB *pSCB;
-
-	pHCB = (HCS *) pHcb;
-	pSCB = (SCB *) pScb;
-	if ((pSRB = pSCB->SCB_Srb) == 0) {
-		printk("i91uSCBPost: SRB pointer is empty\n");
-
-		tul_release_scb(pHCB, pSCB);	/* Release SCB for current channel */
-		return;
-	}
-	switch (pSCB->SCB_HaStat) {
-	case 0x0:
-	case 0xa:		/* Linked command complete without error and linked normally */
-	case 0xb:		/* Linked command complete without error interrupt generated */
-		pSCB->SCB_HaStat = 0;
-		break;
-
-	case 0x11:		/* Selection time out-The initiator selection or target
-				   reselection was not complete within the SCSI Time out period */
-		pSCB->SCB_HaStat = DID_TIME_OUT;
-		break;
-
-	case 0x14:		/* Target bus phase sequence failure-An invalid bus phase or bus
-				   phase sequence was requested by the target. The host adapter
-				   will generate a SCSI Reset Condition, notifying the host with
-				   a SCRD interrupt */
-		pSCB->SCB_HaStat = DID_RESET;
-		break;
-
-	case 0x1a:		/* SCB Aborted. 07/21/98 */
-		pSCB->SCB_HaStat = DID_ABORT;
-		break;
-
-	case 0x12:		/* Data overrun/underrun-The target attempted to transfer more data
-				   than was allocated by the Data Length field or the sum of the
-				   Scatter / Gather Data Length fields. */
-	case 0x13:		/* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
-	case 0x16:		/* Invalid SCB Operation Code. */
-
-	default:
-		printk("ini9100u: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat);
-		pSCB->SCB_HaStat = DID_ERROR;	/* Couldn't find any better */
-		break;
-	}
-
-	pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16);
-
-	if (pSRB == NULL) {
-		printk("pSRB is NULL\n");
-	}
-
-	i91u_unmap_cmnd(pHCB->pci_dev, pSRB);
-	pSRB->scsi_done(pSRB);	/* Notify system DONE           */
-	if ((pSRB = i91uPopSRBFromQueue(pHCB)) != NULL)
-		/* Find the next pending SRB    */
-	{			/* Assume resend will success   */
-		/* Reuse old SCB                */
-		i91uBuildSCB(pHCB, pSCB, pSRB);		/* Create corresponding SCB     */
-
-		tul_exec_scb(pHCB, pSCB);	/* Start execute SCB            */
-	} else {		/* No Pending SRB               */
-		tul_release_scb(pHCB, pSCB);	/* Release SCB for current channel */
-	}
-	return;
-}
-
-/* 
- * Dump the current driver status and panic...
- */
-static void i91u_panic(char *msg)
-{
-	printk("\ni91u_panic: %s\n", msg);
-	panic("i91u panic");
-}
-
-/*
- * Release ressources
- */
-int i91u_release(struct Scsi_Host *hreg)
-{
-	free_irq(hreg->irq, hreg);
-	release_region(hreg->io_port, 256);
-	return 0;
-}
-MODULE_LICENSE("Dual BSD/GPL");
diff -Nru a/drivers/scsi/ini9100u.h b/drivers/scsi/ini9100u.h
--- a/drivers/scsi/ini9100u.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,251 +0,0 @@
-/**************************************************************************
- * Initio 9100 device driver for Linux.
- *
- * Copyright (c) 1994-1998 Initio Corporation
- * 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, 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; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * --------------------------------------------------------------------------
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU General Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- *************************************************************************
- *
- * Module: ini9100u.h
- * Description: INI-9100U/UW LINUX device driver header
- * Revision History:
- * 06/18/96 Harry Chen, Initial Version 1.00A (Beta)
- * 06/23/98 hc	- v1.01k
- *		- Get it work for kernel version >= 2.1.75
- * 12/09/98 bv	- v1.03a
- *		- Removed unused code
- * 12/13/98 bv	- v1.03b
- *		- Add spinlocks to HCS structure.
- * 21/01/99 bv	- v1.03e
- *		- Added PCI_ID structure
- **************************************************************************/
-
-#ifndef	CVT_LINUX_VERSION
-#define	CVT_LINUX_VERSION(V,P,S)	(((V) * 65536) + ((P) * 256) + (S))
-#endif
-
-#ifndef	LINUX_VERSION_CODE
-#include <linux/version.h>
-#endif
-#include <linux/types.h>
-
-extern int i91u_detect(Scsi_Host_Template *);
-extern int i91u_release(struct Scsi_Host *);
-extern int i91u_command(Scsi_Cmnd *);
-extern int i91u_queue(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
-extern int i91u_abort(Scsi_Cmnd *);
-extern int i91u_reset(Scsi_Cmnd *, unsigned int);
-extern int i91u_bus_reset(Scsi_Cmnd *);
-extern int i91u_biosparam(struct scsi_device *, struct block_device *,
-		sector_t, int *);
-
-#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.04a"
-
-#define VIRT_TO_BUS(i)  (unsigned int) virt_to_bus((void *)(i))
-#define ULONG   unsigned long
-#define USHORT  unsigned short
-#define UCHAR   unsigned char
-#define BYTE    u8
-#define WORD    unsigned short
-#define DWORD   unsigned long
-#define UBYTE   u8
-#define UWORD   unsigned short
-#define UDWORD  unsigned long
-#define U32   u32
-
-#ifndef TRUE
-#define TRUE     (1)		/* boolean true  */
-#endif
-#ifndef FALSE
-#define FALSE    (0)		/* boolean false */
-#endif
-#ifndef FAILURE
-#define FAILURE  (-1)
-#endif
-
-#define i91u_MAXQUEUE		2
-#define TOTAL_SG_ENTRY		32
-#define MAX_TARGETS		16
-#define SENSE_SIZE		14
-
-#define INI_VENDOR_ID   0x1101	/* Initio's PCI vendor ID       */
-#define DMX_VENDOR_ID	0x134a	/* Domex's PCI vendor ID	*/
-#define I950_DEVICE_ID	0x9500	/* Initio's inic-950 product ID   */
-#define I940_DEVICE_ID	0x9400	/* Initio's inic-940 product ID   */
-#define I935_DEVICE_ID	0x9401	/* Initio's inic-935 product ID   */
-#define I920_DEVICE_ID	0x0002	/* Initio's other product ID      */
-
-/************************************************************************/
-/*              Vendor ID/Device ID Pair Structure			*/
-/************************************************************************/
-typedef struct PCI_ID_Struc {
-	unsigned short vendor_id;
-	unsigned short device_id;
-} PCI_ID;
-
-/************************************************************************/
-/*              Scatter-Gather Element Structure                        */
-/************************************************************************/
-typedef struct SG_Struc {
-	U32 SG_Ptr;		/* Data Pointer */
-	U32 SG_Len;		/* Data Length */
-} SG;
-
-/***********************************************************************
-		SCSI Control Block
-************************************************************************/
-typedef struct Scsi_Ctrl_Blk {
-	U32 SCB_InitioReserved[9];	/* 0 */
-
-	UBYTE SCB_Opcode;	/*24 SCB command code */
-	UBYTE SCB_Flags;	/*25 SCB Flags */
-	UBYTE SCB_Target;	/*26 Target Id */
-	UBYTE SCB_Lun;		/*27 Lun */
-	U32 SCB_BufPtr;		/*28 Data Buffer Pointer */
-	U32 SCB_BufLen;		/*2C Data Allocation Length */
-	UBYTE SCB_SGLen;	/*30 SG list # */
-	UBYTE SCB_SenseLen;	/*31 Sense Allocation Length */
-	UBYTE SCB_HaStat;	/*32 */
-	UBYTE SCB_TaStat;	/*33 */
-	UBYTE SCB_CDBLen;	/*34 CDB Length */
-	UBYTE SCB_Ident;	/*35 Identify */
-	UBYTE SCB_TagMsg;	/*36 Tag Message */
-	UBYTE SCB_TagId;	/*37 Queue Tag */
-	UBYTE SCB_CDB[12];	/*38 */
-	U32 SCB_SGPAddr;	/*44 SG List/Sense Buf phy. Addr. */
-	U32 SCB_SensePtr;	/*48 Sense data pointer */
-	void (*SCB_Post) (BYTE *, BYTE *);	/*4C POST routine */
-	Scsi_Cmnd *SCB_Srb;	/*50 SRB Pointer */
-	SG SCB_SGList[TOTAL_SG_ENTRY];	/*54 Start of SG list */
-} SCB;
-
-/* Opcodes of SCB_Opcode */
-#define ExecSCSI        0x1
-#define BusDevRst       0x2
-#define AbortCmd        0x3
-
-/* Bit Definition for SCB_Flags */
-#define SCF_DONE        0x01
-#define SCF_POST        0x02
-#define SCF_SENSE       0x04
-#define SCF_DIR         0x18
-#define SCF_NO_DCHK     0x00
-#define SCF_DIN         0x08
-#define SCF_DOUT        0x10
-#define SCF_NO_XF       0x18
-#define SCF_POLL        0x40
-#define SCF_SG          0x80
-
-/* Error Codes for SCB_HaStat */
-#define HOST_SEL_TOUT   0x11
-#define HOST_DO_DU      0x12
-#define HOST_BUS_FREE   0x13
-#define HOST_BAD_PHAS   0x14
-#define HOST_INV_CMD    0x16
-#define HOST_SCSI_RST   0x1B
-#define HOST_DEV_RST    0x1C
-
-/* Error Codes for SCB_TaStat */
-#define TARGET_CHKCOND  0x02
-#define TARGET_BUSY     0x08
-
-/* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */
-#define MSG_STAG        0x20
-#define MSG_HTAG        0x21
-#define MSG_OTAG        0x22
-
-/***********************************************************************
-		Target Device Control Structure
-**********************************************************************/
-
-typedef struct Tar_Ctrl_Struc {
-	ULONG TCS_InitioReserved;	/* 0 */
-
-	UWORD TCS_DrvFlags;	/* 4 */
-	UBYTE TCS_DrvHead;	/* 6 */
-	UBYTE TCS_DrvSector;	/* 7 */
-} TCS;
-
-/***********************************************************************
-		Target Device Control Structure
-**********************************************************************/
-/* Bit Definition for TCF_DrvFlags */
-#define TCF_DRV_255_63          0x0400
-
-/***********************************************************************
-	      Host Adapter Control Structure
-************************************************************************/
-typedef struct Ha_Ctrl_Struc {
-	UWORD HCS_Base;		/* 00 */
-	UWORD HCS_BIOS;		/* 02 */
-	UBYTE HCS_Intr;		/* 04 */
-	UBYTE HCS_SCSI_ID;	/* 05 */
-	UBYTE HCS_MaxTar;	/* 06 */
-	UBYTE HCS_NumScbs;	/* 07 */
-
-	UBYTE HCS_Flags;	/* 08 */
-	UBYTE HCS_Index;	/* 09 */
-	UBYTE HCS_Reserved[2];	/* 0a */
-	ULONG HCS_InitioReserved[27];	/* 0C */
-	TCS HCS_Tcs[16];	/* 78 -> 16 Targets */
-	Scsi_Cmnd *pSRB_head;	/* SRB save queue header     */
-	Scsi_Cmnd *pSRB_tail;	/* SRB save queue tail       */
-	spinlock_t HCS_AvailLock;
-	spinlock_t HCS_SemaphLock;
-	spinlock_t pSRB_lock;
-	struct pci_dev *pci_dev;
-} HCS;
-
-/* Bit Definition for HCB_Flags */
-#define HCF_EXPECT_RESET        0x10
-
-/* SCSI related definition                                              */
-#define DISC_NOT_ALLOW          0x80	/* Disconnect is not allowed    */
-#define DISC_ALLOW              0xC0	/* Disconnect is allowed        */
diff -Nru a/drivers/scsi/inia100.c b/drivers/scsi/inia100.c
--- a/drivers/scsi/inia100.c	2004-12-24 13:36:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,580 +0,0 @@
-/**************************************************************************
- * Initio A100 device driver for Linux.
- *
- * Copyright (c) 1994-1998 Initio Corporation
- * 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, 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; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * --------------------------------------------------------------------------
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU General Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- **************************************************************************
- * 
- * module: inia100.c
- * DESCRIPTION:
- * 	This is the Linux low-level SCSI driver for Initio INIA100 SCSI host
- * 	adapters
- * 09/24/98 hl - v1.02 initial production release.
- * 12/19/98 bv - v1.02a Use spinlocks for 2.1.95 and up.
- * 06/25/02 Doug Ledford <dledford@redhat.com> - v1.02d
- *          - Remove limit on number of controllers
- *          - Port to DMA mapping API
- *          - Clean up interrupt handler registration
- *          - Fix memory leaks
- *          - Fix allocation of scsi host structs and private data
- * 18/11/03 Christoph Hellwig <hch@lst.de>
- *	    - Port to new probing API
- *	    - Fix some more leaks in init failure cases
- * TODO:
- *	    - use list.h macros for SCB queue
- *	  ( - merge with i60uscsi.c )
- **************************************************************************/
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/blkdev.h>
-#include <linux/spinlock.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_host.h>
-
-#include "inia100.h"
-
-#define ORC_RDWORD(x,y)         (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
-
-char *inia100_Copyright = "Copyright (C) 1998-99";
-char *inia100_InitioName = "by Initio Corporation";
-char *inia100_ProductName = "INI-A100U2W";
-char *inia100_Version = "v1.02d";
-
-/* ---- EXTERNAL FUNCTIONS ---- */
-extern void inia100SCBPost(BYTE * pHcb, BYTE * pScb);
-extern int init_inia100Adapter_table(int);
-extern ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp);
-extern void orc_exec_scb(ORC_HCS * hcsp, ORC_SCB * scbp);
-extern void orc_release_scb(ORC_HCS * hcsp, ORC_SCB * scbp);
-extern void orc_release_dma(ORC_HCS * hcsp, struct scsi_cmnd * cmnd);
-extern void orc_interrupt(ORC_HCS * hcsp);
-extern int orc_device_reset(ORC_HCS * pHCB, struct scsi_cmnd *SCpnt, unsigned int target);
-extern int orc_reset_scsi_bus(ORC_HCS * pHCB);
-extern int abort_SCB(ORC_HCS * hcsp, ORC_SCB * pScb);
-extern int orc_abort_srb(ORC_HCS * hcsp, struct scsi_cmnd *SCpnt);
-extern int init_orchid(ORC_HCS * hcsp);
-
-/*****************************************************************************
- Function name  : inia100AppendSRBToQueue
- Description    : This function will push current request into save list
- Input          : pSRB  -       Pointer to SCSI request block.
-		  pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : None.
-*****************************************************************************/
-static void inia100AppendSRBToQueue(ORC_HCS * pHCB, struct scsi_cmnd * pSRB)
-{
-	ULONG flags;
-
-	spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
-
-	pSRB->SCp.ptr = NULL;	/* Pointer to next */
-	if (pHCB->pSRB_head == NULL)
-		pHCB->pSRB_head = pSRB;
-	else
-		pHCB->pSRB_tail->SCp.ptr = (char *)pSRB;	/* Pointer to next */
-	pHCB->pSRB_tail = pSRB;
-	spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
-	return;
-}
-
-/*****************************************************************************
- Function name  : inia100PopSRBFromQueue
- Description    : This function will pop current request from save list
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-static struct scsi_cmnd *inia100PopSRBFromQueue(ORC_HCS * pHCB)
-{
-	struct scsi_cmnd *pSRB;
-	ULONG flags;
-	spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
-	if ((pSRB = (struct scsi_cmnd *) pHCB->pSRB_head) != NULL) {
-		pHCB->pSRB_head = (struct scsi_cmnd *) pHCB->pSRB_head->SCp.ptr;
-		pSRB->SCp.ptr = NULL;
-	}
-	spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
-	return (pSRB);
-}
-
-/*****************************************************************************
- Function name  : inia100BuildSCB
- Description    : 
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-static void inia100BuildSCB(ORC_HCS * pHCB, ORC_SCB * pSCB, struct scsi_cmnd * SCpnt)
-{				/* Create corresponding SCB     */
-	struct scatterlist *pSrbSG;
-	ORC_SG *pSG;		/* Pointer to SG list           */
-	int i, count_sg;
-	U32 TotalLen;
-	ESCB *pEScb;
-
-	pEScb = pSCB->SCB_EScb;
-	pEScb->SCB_Srb = SCpnt;
-	pSG = NULL;
-
-	pSCB->SCB_Opcode = ORC_EXECSCSI;
-	pSCB->SCB_Flags = SCF_NO_DCHK;	/* Clear done bit               */
-	pSCB->SCB_Target = SCpnt->device->id;
-	pSCB->SCB_Lun = SCpnt->device->lun;
-	pSCB->SCB_Reserved0 = 0;
-	pSCB->SCB_Reserved1 = 0;
-	pSCB->SCB_SGLen = 0;
-
-	if ((pSCB->SCB_XferLen = (U32) SCpnt->request_bufflen)) {
-		pSG = (ORC_SG *) & pEScb->ESCB_SGList[0];
-		if (SCpnt->use_sg) {
-			TotalLen = 0;
-			pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
-			count_sg = pci_map_sg(pHCB->pdev, pSrbSG, SCpnt->use_sg,
-					SCpnt->sc_data_direction);
-			pSCB->SCB_SGLen = (U32) (count_sg * 8);
-			for (i = 0; i < count_sg; i++, pSG++, pSrbSG++) {
-				pSG->SG_Ptr = (U32) sg_dma_address(pSrbSG);
-				pSG->SG_Len = (U32) sg_dma_len(pSrbSG);
-				TotalLen += (U32) sg_dma_len(pSrbSG);
-			}
-		} else if (SCpnt->request_bufflen != 0) {/* Non SG */
-			pSCB->SCB_SGLen = 0x8;
-			pSG->SG_Ptr = (U32) pci_map_single(pHCB->pdev,
-				SCpnt->request_buffer, SCpnt->request_bufflen,
-				SCpnt->sc_data_direction);
-			SCpnt->host_scribble = (void *)pSG->SG_Ptr;
-			pSG->SG_Len = (U32) SCpnt->request_bufflen;
-		} else {
-			pSCB->SCB_SGLen = 0;
-			pSG->SG_Ptr = 0;
-			pSG->SG_Len = 0;
-		}
-	}
-	pSCB->SCB_SGPAddr = (U32) pSCB->SCB_SensePAddr;
-	pSCB->SCB_HaStat = 0;
-	pSCB->SCB_TaStat = 0;
-	pSCB->SCB_Link = 0xFF;
-	pSCB->SCB_SenseLen = SENSE_SIZE;
-	pSCB->SCB_CDBLen = SCpnt->cmd_len;
-	if (pSCB->SCB_CDBLen >= IMAX_CDB) {
-		printk("max cdb length= %x\b", SCpnt->cmd_len);
-		pSCB->SCB_CDBLen = IMAX_CDB;
-	}
-	pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW;
-	if (SCpnt->device->tagged_supported) {	/* Tag Support                  */
-		pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG;	/* Do simple tag only   */
-	} else {
-		pSCB->SCB_TagMsg = 0;	/* No tag support               */
-	}
-	memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, pSCB->SCB_CDBLen);
-	return;
-}
-
-/*****************************************************************************
- Function name  : inia100_queue
- Description    : Queue a command and setup interrupts for a free bus.
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-static int inia100_queue(struct scsi_cmnd * SCpnt, void (*done) (struct scsi_cmnd *))
-{
-	register ORC_SCB *pSCB;
-	ORC_HCS *pHCB;		/* Point to Host adapter control block */
-
-	pHCB = (ORC_HCS *) SCpnt->device->host->hostdata;
-	SCpnt->scsi_done = done;
-	/* Get free SCSI control block  */
-	if ((pSCB = orc_alloc_scb(pHCB)) == NULL) {
-		inia100AppendSRBToQueue(pHCB, SCpnt);	/* Buffer this request  */
-		/* printk("inia100_entry: can't allocate SCB\n"); */
-		return (0);
-	}
-	inia100BuildSCB(pHCB, pSCB, SCpnt);
-	orc_exec_scb(pHCB, pSCB);	/* Start execute SCB            */
-
-	return (0);
-}
-
-/*****************************************************************************
- Function name  : inia100_abort
- Description    : Abort a queued command.
-	                 (commands that are on the bus can't be aborted easily)
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-static int inia100_abort(struct scsi_cmnd * SCpnt)
-{
-	ORC_HCS *hcsp;
-
-	hcsp = (ORC_HCS *) SCpnt->device->host->hostdata;
-	return orc_abort_srb(hcsp, SCpnt);
-}
-
-/*****************************************************************************
- Function name  : inia100_reset
- Description    : Reset registers, reset a hanging bus and
-                  kill active and disconnected commands for target w/o soft reset
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-static int inia100_bus_reset(struct scsi_cmnd * SCpnt)
-{				/* I need Host Control Block Information */
-	ORC_HCS *pHCB;
-	pHCB = (ORC_HCS *) SCpnt->device->host->hostdata;
-	return orc_reset_scsi_bus(pHCB);
-}
-
-/*****************************************************************************
- Function name  : inia100_device_reset
- Description    : Reset the device
- Input          : pHCB  -       Pointer to host adapter structure
- Output         : None.
- Return         : pSRB  -       Pointer to SCSI request block.
-*****************************************************************************/
-static int inia100_device_reset(struct scsi_cmnd * SCpnt)
-{				/* I need Host Control Block Information */
-	ORC_HCS *pHCB;
-	pHCB = (ORC_HCS *) SCpnt->device->host->hostdata;
-	return orc_device_reset(pHCB, SCpnt, SCpnt->device->id);
-
-}
-
-/*****************************************************************************
- Function name  : inia100SCBPost
- Description    : This is callback routine be called when orc finish one
-			SCSI command.
- Input          : pHCB  -       Pointer to host adapter control block.
-		  pSCB  -       Pointer to SCSI control block.
- Output         : None.
- Return         : None.
-*****************************************************************************/
-void inia100SCBPost(BYTE * pHcb, BYTE * pScb)
-{
-	struct scsi_cmnd *pSRB;	/* Pointer to SCSI request block */
-	ORC_HCS *pHCB;
-	ORC_SCB *pSCB;
-	ESCB *pEScb;
-
-	pHCB = (ORC_HCS *) pHcb;
-	pSCB = (ORC_SCB *) pScb;
-	pEScb = pSCB->SCB_EScb;
-	if ((pSRB = (struct scsi_cmnd *) pEScb->SCB_Srb) == 0) {
-		printk("inia100SCBPost: SRB pointer is empty\n");
-		orc_release_scb(pHCB, pSCB);	/* Release SCB for current channel */
-		return;
-	}
-	pEScb->SCB_Srb = NULL;
-
-	switch (pSCB->SCB_HaStat) {
-	case 0x0:
-	case 0xa:		/* Linked command complete without error and linked normally */
-	case 0xb:		/* Linked command complete without error interrupt generated */
-		pSCB->SCB_HaStat = 0;
-		break;
-
-	case 0x11:		/* Selection time out-The initiator selection or target
-				   reselection was not complete within the SCSI Time out period */
-		pSCB->SCB_HaStat = DID_TIME_OUT;
-		break;
-
-	case 0x14:		/* Target bus phase sequence failure-An invalid bus phase or bus
-				   phase sequence was requested by the target. The host adapter
-				   will generate a SCSI Reset Condition, notifying the host with
-				   a SCRD interrupt */
-		pSCB->SCB_HaStat = DID_RESET;
-		break;
-
-	case 0x1a:		/* SCB Aborted. 07/21/98 */
-		pSCB->SCB_HaStat = DID_ABORT;
-		break;
-
-	case 0x12:		/* Data overrun/underrun-The target attempted to transfer more data
-				   than was allocated by the Data Length field or the sum of the
-				   Scatter / Gather Data Length fields. */
-	case 0x13:		/* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
-	case 0x16:		/* Invalid CCB Operation Code-The first byte of the CCB was invalid. */
-
-	default:
-		printk("inia100: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat);
-		pSCB->SCB_HaStat = DID_ERROR;	/* Couldn't find any better */
-		break;
-	}
-
-	if (pSCB->SCB_TaStat == 2) {	/* Check condition              */
-		memcpy((unsigned char *) &pSRB->sense_buffer[0],
-		   (unsigned char *) &pEScb->ESCB_SGList[0], SENSE_SIZE);
-	}
-	pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16);
-	orc_release_dma(pHCB, pSRB);  /* release DMA before we call scsi_done */
-	pSRB->scsi_done(pSRB);	/* Notify system DONE           */
-
-	/* Find the next pending SRB    */
-	if ((pSRB = inia100PopSRBFromQueue(pHCB)) != NULL) {	/* Assume resend will success   */
-		inia100BuildSCB(pHCB, pSCB, pSRB);	/* Create corresponding SCB     */
-		orc_exec_scb(pHCB, pSCB);	/* Start execute SCB            */
-	} else {
-		orc_release_scb(pHCB, pSCB);	/* Release SCB for current channel */
-	}
-	return;
-}
-
-/*
- * Interrupt handler (main routine of the driver)
- */
-static irqreturn_t inia100_intr(int irqno, void *devid, struct pt_regs *regs)
-{
-	struct Scsi_Host *host = (struct Scsi_Host *)devid;
-	ORC_HCS *pHcb = (ORC_HCS *)host->hostdata;
-	unsigned long flags;
-
-	spin_lock_irqsave(host->host_lock, flags);
-	orc_interrupt(pHcb);
-	spin_unlock_irqrestore(host->host_lock, flags);
-
-	return IRQ_HANDLED;
-}
-
-static struct scsi_host_template inia100_template = {
-	.proc_name		= "inia100",
-	.name			= inia100_REVID,
-	.queuecommand		= inia100_queue,
-	.eh_abort_handler	= inia100_abort,
-	.eh_bus_reset_handler	= inia100_bus_reset,
-	.eh_device_reset_handler = inia100_device_reset,
-	.can_queue		= 1,
-	.this_id		= 1,
-	.sg_tablesize		= SG_ALL,
-	.cmd_per_lun 		= 1,
-	.use_clustering		= ENABLE_CLUSTERING,
-};
-
-static int __devinit inia100_probe_one(struct pci_dev *pdev,
-		const struct pci_device_id *id)
-{
-	struct Scsi_Host *shost;
-	ORC_HCS *pHCB;
-	unsigned long port, bios;
-	int error = -ENODEV;
-	u32 sz;
-	unsigned long dBiosAdr;
-	char *pbBiosAdr;
-
-	if (pci_enable_device(pdev))
-		goto out;
-	if (pci_set_dma_mask(pdev, 0xffffffffULL)) {
-		printk(KERN_WARNING "Unable to set 32bit DMA "
-				    "on inia100 adapter, ignoring.\n");
-		goto out_disable_device;
-	}
-
-	pci_set_master(pdev);
-
-	port = pci_resource_start(pdev, 0);
-	if (!request_region(port, 256, "inia100")) {
-		printk(KERN_WARNING "inia100: io port 0x%lx, is busy.\n", port);
-		goto out_disable_device;
-	}
-
-	/* <02> read from base address + 0x50 offset to get the bios balue. */
-	bios = ORC_RDWORD(port, 0x50);
-
-
-	shost = scsi_host_alloc(&inia100_template, sizeof(ORC_HCS));
-	if (!shost)
-		goto out_release_region;
-
-	pHCB = (ORC_HCS *)shost->hostdata;
-	pHCB->pdev = pdev;
-	pHCB->HCS_Base = port;
-	pHCB->HCS_BIOS = bios;
-	pHCB->pSRB_head = NULL;	/* Initial SRB save queue       */
-	pHCB->pSRB_tail = NULL;	/* Initial SRB save queue       */
-	pHCB->pSRB_lock = SPIN_LOCK_UNLOCKED; /* SRB save queue lock */
-	pHCB->BitAllocFlagLock = SPIN_LOCK_UNLOCKED;
-
-	/* Get total memory needed for SCB */
-	sz = ORC_MAXQUEUE * sizeof(ORC_SCB);
-	pHCB->HCS_virScbArray = pci_alloc_consistent(pdev, sz,
-			&pHCB->HCS_physScbArray);
-	if (!pHCB->HCS_virScbArray) {
-		printk("inia100: SCB memory allocation error\n");
-		goto out_host_put;
-	}
-	memset(pHCB->HCS_virScbArray, 0, sz);
-
-	/* Get total memory needed for ESCB */
-	sz = ORC_MAXQUEUE * sizeof(ESCB);
-	pHCB->HCS_virEscbArray = pci_alloc_consistent(pdev, sz,
-			&pHCB->HCS_physEscbArray);
-	if (!pHCB->HCS_virEscbArray) {
-		printk("inia100: ESCB memory allocation error\n");
-		goto out_free_scb_array;
-	}
-	memset(pHCB->HCS_virEscbArray, 0, sz);
-
-	dBiosAdr = pHCB->HCS_BIOS;
-	dBiosAdr = (dBiosAdr << 4);
-	pbBiosAdr = phys_to_virt(dBiosAdr);
-	if (init_orchid(pHCB)) {	/* Initialize orchid chip */
-		printk("inia100: initial orchid fail!!\n");
-		goto out_free_escb_array;
-	}
-
-	shost->io_port = pHCB->HCS_Base;
-	shost->n_io_port = 0xff;
-	shost->can_queue = ORC_MAXQUEUE;
-	shost->unique_id = shost->io_port;
-	shost->max_id = pHCB->HCS_MaxTar;
-	shost->max_lun = 16;
-	shost->irq = pHCB->HCS_Intr = pdev->irq;
-	shost->this_id = pHCB->HCS_SCSI_ID;	/* Assign HCS index */
-	shost->sg_tablesize = TOTAL_SG_ENTRY;
-
-	/* Initial orc chip           */
-	error = request_irq(pdev->irq, inia100_intr, SA_SHIRQ,
-			"inia100", shost);
-	if (error < 0) {
-		printk(KERN_WARNING "inia100: unable to get irq %d\n",
-				pdev->irq);
-		goto out_free_escb_array;
-	}
-
-	pci_set_drvdata(pdev, shost);
-
-	error = scsi_add_host(shost, &pdev->dev);
-	if (error)
-		goto out_free_irq;
-
-	scsi_scan_host(shost);
-	return 0;
-
- out_free_irq:
-        free_irq(shost->irq, shost);
- out_free_escb_array:
-	pci_free_consistent(pdev, ORC_MAXQUEUE * sizeof(ESCB),
-			pHCB->HCS_virEscbArray, pHCB->HCS_physEscbArray);
- out_free_scb_array:
-	pci_free_consistent(pdev, ORC_MAXQUEUE * sizeof(ORC_SCB),
-			pHCB->HCS_virScbArray, pHCB->HCS_physScbArray);
- out_host_put:
-	scsi_host_put(shost);
- out_release_region:
-        release_region(port, 256);
- out_disable_device:
-	pci_disable_device(pdev);
- out:
-	return error;
-}
-
-static void __devexit inia100_remove_one(struct pci_dev *pdev)
-{
-	struct Scsi_Host *shost = pci_get_drvdata(pdev);
-	ORC_HCS *pHCB = (ORC_HCS *)shost->hostdata;
-
-	scsi_remove_host(shost);
-
-        free_irq(shost->irq, shost);
-	pci_free_consistent(pdev, ORC_MAXQUEUE * sizeof(ESCB),
-			pHCB->HCS_virEscbArray, pHCB->HCS_physEscbArray);
-	pci_free_consistent(pdev, ORC_MAXQUEUE * sizeof(ORC_SCB),
-			pHCB->HCS_virScbArray, pHCB->HCS_physScbArray);
-        release_region(shost->io_port, 256);
-
-	scsi_host_put(shost);
-} 
-
-static struct pci_device_id inia100_pci_tbl[] = {
-	{ORC_VENDOR_ID, ORC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0,}
-};
-MODULE_DEVICE_TABLE(pci, inia100_pci_tbl);
-
-static struct pci_driver inia100_pci_driver = {
-	.name		= "inia100",
-	.id_table	= inia100_pci_tbl,
-	.probe		= inia100_probe_one,
-	.remove		= __devexit_p(inia100_remove_one),
-};
-
-static int __init inia100_init(void)
-{
-	return pci_module_init(&inia100_pci_driver);
-}
-
-static void __exit inia100_exit(void)
-{
-	pci_unregister_driver(&inia100_pci_driver);
-}
-
-MODULE_DESCRIPTION("Initio A100U2W SCSI driver");
-MODULE_AUTHOR("Initio Corporation");
-MODULE_LICENSE("Dual BSD/GPL");
-
-module_init(inia100_init);
-module_exit(inia100_exit);
diff -Nru a/drivers/scsi/inia100.h b/drivers/scsi/inia100.h
--- a/drivers/scsi/inia100.h	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,533 +0,0 @@
-/**************************************************************************
- * Initio A100 device driver for Linux.
- *
- * Copyright (c) 1994-1998 Initio Corporation
- * 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, 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; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * --------------------------------------------------------------------------
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU General Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- **************************************************************************
- *
- * Module: inia100.h
- * Description: INI-A100U2W LINUX device driver header
- * Revision History:
- *	06/18/98 HL, Initial production Version 1.02
- *	12/19/98 bv, Use spinlocks for 2.1.95 and up
- *	06/25/02 Doug Ledford <dledford@redhat.com>
- *		 - This and the i60uscsi.h file are almost identical,
- *		   merged them into a single header used by both .c files.
- ****************************************************************************/
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-
-#define inia100_REVID "Initio INI-A100U2W SCSI device driver; Revision: 1.02d"
-
-#define ULONG   unsigned long
-#define PVOID   void *
-#define USHORT  unsigned short
-#define UCHAR   unsigned char
-#define BYTE    unsigned char
-#define WORD    unsigned short
-#define DWORD   unsigned long
-#define UBYTE   unsigned char
-#define UWORD   unsigned short
-#define UDWORD  unsigned long
-#define U32     u32
-
-#ifndef FAILURE
-#define FAILURE  (-1)
-#endif
-#if 1
-#define ORC_MAXQUEUE		245
-#define ORC_MAXTAGS		64
-#else
-#define ORC_MAXQUEUE		25
-#define ORC_MAXTAGS		8
-#endif
-
-#define TOTAL_SG_ENTRY		32
-#define MAX_TARGETS		16
-#define IMAX_CDB			15
-#define SENSE_SIZE		14
-#define SUCCESSFUL              0x00
-
-#define I920_DEVICE_ID	0x0002	/* Initio's inic-950 product ID   */
-
-/************************************************************************/
-/*              Scatter-Gather Element Structure                        */
-/************************************************************************/
-typedef struct ORC_SG_Struc {
-	U32 SG_Ptr;		/* Data Pointer */
-	U32 SG_Len;		/* Data Length */
-} ORC_SG;
-
-/* SCSI related definition                                              */
-#define DISC_NOT_ALLOW          0x80	/* Disconnect is not allowed    */
-#define DISC_ALLOW              0xC0	/* Disconnect is allowed        */
-
-
-#define ORC_OFFSET_SCB			16
-#define ORC_MAX_SCBS		    250
-#define MAX_CHANNELS       2
-#define MAX_ESCB_ELE				64
-#define TCF_DRV_255_63     0x0400
-
-/********************************************************/
-/*      Orchid Configuration Register Set               */
-/********************************************************/
-#define ORC_PVID	0x00	/* Vendor ID                      */
-#define ORC_VENDOR_ID	0x1101	/* Orchid vendor ID               */
-#define ORC_PDID        0x02	/* Device ID                    */
-#define ORC_DEVICE_ID	0x1060	/* Orchid device ID               */
-#define ORC_COMMAND	0x04	/* Command                        */
-#define BUSMS		0x04	/* BUS MASTER Enable              */
-#define IOSPA		0x01	/* IO Space Enable                */
-#define ORC_STATUS	0x06	/* Status register                */
-#define ORC_REVISION	0x08	/* Revision number                */
-#define ORC_BASE	0x10	/* Base address                   */
-#define ORC_BIOS	0x50	/* Expansion ROM base address     */
-#define ORC_INT_NUM	0x3C	/* Interrupt line         */
-#define ORC_INT_PIN	0x3D	/* Interrupt pin          */
-
-/********************************************************/
-/*      Orchid Host Command Set                         */
-/********************************************************/
-#define ORC_CMD_NOP		0x00	/* Host command - NOP             */
-#define ORC_CMD_VERSION		0x01	/* Host command - Get F/W version */
-#define ORC_CMD_ECHO		0x02	/* Host command - ECHO            */
-#define ORC_CMD_SET_NVM		0x03	/* Host command - Set NVRAM       */
-#define ORC_CMD_GET_NVM		0x04	/* Host command - Get NVRAM       */
-#define ORC_CMD_GET_BUS_STATUS	0x05	/* Host command - Get SCSI bus status */
-#define ORC_CMD_ABORT_SCB	0x06	/* Host command - Abort SCB       */
-#define ORC_CMD_ISSUE_SCB	0x07	/* Host command - Issue SCB       */
-
-/********************************************************/
-/*              Orchid Register Set                     */
-/********************************************************/
-#define ORC_GINTS	0xA0	/* Global Interrupt Status        */
-#define QINT		0x04	/* Reply Queue Interrupt  */
-#define ORC_GIMSK	0xA1	/* Global Interrupt MASK  */
-#define MQINT		0x04	/* Mask Reply Queue Interrupt     */
-#define	ORC_GCFG	0xA2	/* Global Configure               */
-#define EEPRG		0x01	/* Enable EEPROM programming */
-#define	ORC_GSTAT	0xA3	/* Global status          */
-#define WIDEBUS		0x10	/* Wide SCSI Devices connected    */
-#define ORC_HDATA	0xA4	/* Host Data                      */
-#define ORC_HCTRL	0xA5	/* Host Control                   */
-#define SCSIRST		0x80	/* SCSI bus reset         */
-#define HDO			0x40	/* Host data out          */
-#define HOSTSTOP		0x02	/* Host stop RISC engine  */
-#define DEVRST		0x01	/* Device reset                   */
-#define ORC_HSTUS	0xA6	/* Host Status                    */
-#define HDI			0x02	/* Host data in                   */
-#define RREADY		0x01	/* RISC engine is ready to receive */
-#define	ORC_NVRAM	0xA7	/* Nvram port address             */
-#define SE2CS		0x008
-#define SE2CLK		0x004
-#define SE2DO		0x002
-#define SE2DI		0x001
-#define ORC_PQUEUE	0xA8	/* Posting queue FIFO             */
-#define ORC_PQCNT	0xA9	/* Posting queue FIFO Cnt */
-#define ORC_RQUEUE	0xAA	/* Reply queue FIFO               */
-#define ORC_RQUEUECNT	0xAB	/* Reply queue FIFO Cnt           */
-#define	ORC_FWBASEADR	0xAC	/* Firmware base address  */
-
-#define	ORC_EBIOSADR0 0xB0	/* External Bios address */
-#define	ORC_EBIOSADR1 0xB1	/* External Bios address */
-#define	ORC_EBIOSADR2 0xB2	/* External Bios address */
-#define	ORC_EBIOSDATA 0xB3	/* External Bios address */
-
-#define	ORC_SCBSIZE	0xB7	/* SCB size register              */
-#define	ORC_SCBBASE0	0xB8	/* SCB base address 0             */
-#define	ORC_SCBBASE1	0xBC	/* SCB base address 1             */
-
-#define	ORC_RISCCTL	0xE0	/* RISC Control                   */
-#define PRGMRST		0x002
-#define DOWNLOAD		0x001
-#define	ORC_PRGMCTR0	0xE2	/* RISC program counter           */
-#define	ORC_PRGMCTR1	0xE3	/* RISC program counter           */
-#define	ORC_RISCRAM	0xEC	/* RISC RAM data port 4 bytes     */
-
-typedef struct orc_extended_scb {	/* Extended SCB                 */
-	ORC_SG ESCB_SGList[TOTAL_SG_ENTRY];	/*0 Start of SG list              */
-	struct scsi_cmnd *SCB_Srb;	/*50 SRB Pointer */
-} ESCB;
-
-/***********************************************************************
-		SCSI Control Block
-************************************************************************/
-typedef struct orc_scb {	/* Scsi_Ctrl_Blk                */
-	UBYTE SCB_Opcode;	/*00 SCB command code&residual  */
-	UBYTE SCB_Flags;	/*01 SCB Flags                  */
-	UBYTE SCB_Target;	/*02 Target Id                  */
-	UBYTE SCB_Lun;		/*03 Lun                        */
-	U32 SCB_Reserved0;	/*04 Reserved for ORCHID must 0 */
-	U32 SCB_XferLen;	/*08 Data Transfer Length       */
-	U32 SCB_Reserved1;	/*0C Reserved for ORCHID must 0 */
-	U32 SCB_SGLen;		/*10 SG list # * 8              */
-	U32 SCB_SGPAddr;	/*14 SG List Buf physical Addr  */
-	U32 SCB_SGPAddrHigh;	/*18 SG Buffer high physical Addr */
-	UBYTE SCB_HaStat;	/*1C Host Status                */
-	UBYTE SCB_TaStat;	/*1D Target Status              */
-	UBYTE SCB_Status;	/*1E SCB status                 */
-	UBYTE SCB_Link;		/*1F Link pointer, default 0xFF */
-	UBYTE SCB_SenseLen;	/*20 Sense Allocation Length    */
-	UBYTE SCB_CDBLen;	/*21 CDB Length                 */
-	UBYTE SCB_Ident;	/*22 Identify                   */
-	UBYTE SCB_TagMsg;	/*23 Tag Message                */
-	UBYTE SCB_CDB[IMAX_CDB];	/*24 SCSI CDBs                  */
-	UBYTE SCB_ScbIdx;	/*3C Index for this ORCSCB      */
-	U32 SCB_SensePAddr;	/*34 Sense Buffer physical Addr */
-
-	ESCB *SCB_EScb;		/*38 Extended SCB Pointer       */
-#ifndef ALPHA
-	UBYTE SCB_Reserved2[4];	/*3E Reserved for Driver use    */
-#endif
-} ORC_SCB;
-
-/* Opcodes of ORCSCB_Opcode */
-#define ORC_EXECSCSI	0x00	/* SCSI initiator command with residual */
-#define ORC_BUSDEVRST	0x01	/* SCSI Bus Device Reset  */
-
-/* Status of ORCSCB_Status */
-#define ORCSCB_COMPLETE	0x00	/* SCB request completed  */
-#define ORCSCB_POST	0x01	/* SCB is posted by the HOST      */
-
-/* Bit Definition for ORCSCB_Flags */
-#define SCF_DISINT	0x01	/* Disable HOST interrupt */
-#define SCF_DIR		0x18	/* Direction bits         */
-#define SCF_NO_DCHK	0x00	/* Direction determined by SCSI   */
-#define SCF_DIN		0x08	/* From Target to Initiator       */
-#define SCF_DOUT	0x10	/* From Initiator to Target       */
-#define SCF_NO_XF	0x18	/* No data transfer               */
-#define SCF_POLL   0x40
-
-/* Error Codes for ORCSCB_HaStat */
-#define HOST_SEL_TOUT	0x11
-#define HOST_DO_DU	0x12
-#define HOST_BUS_FREE	0x13
-#define HOST_BAD_PHAS	0x14
-#define HOST_INV_CMD	0x16
-#define HOST_SCSI_RST	0x1B
-#define HOST_DEV_RST	0x1C
-
-
-/* Error Codes for ORCSCB_TaStat */
-#define TARGET_CHK_COND	0x02
-#define TARGET_BUSY	0x08
-#define TARGET_TAG_FULL	0x28
-
-
-/* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */
-#define MSG_STAG	0x20
-#define MSG_HTAG	0x21
-#define MSG_OTAG	0x22
-
-#define MSG_IGNOREWIDE	0x23
-
-#define MSG_IDENT	0x80
-#define MSG_DISC	0x40	/* Disconnect allowed             */
-
-
-/* SCSI MESSAGE */
-#define	MSG_EXTEND	0x01
-#define	MSG_SDP		0x02
-#define	MSG_ABORT	0x06
-#define	MSG_REJ		0x07
-#define	MSG_NOP		0x08
-#define	MSG_PARITY	0x09
-#define	MSG_DEVRST	0x0C
-#define	MSG_STAG	0x20
-
-/***********************************************************************
-		Target Device Control Structure
-**********************************************************************/
-
-typedef struct ORC_Tar_Ctrl_Struc {
-	UBYTE TCS_DrvDASD;	/* 6 */
-	UBYTE TCS_DrvSCSI;	/* 7 */
-	UBYTE TCS_DrvHead;	/* 8 */
-	UWORD TCS_DrvFlags;	/* 4 */
-	UBYTE TCS_DrvSector;	/* 7 */
-} ORC_TCS, *PORC_TCS;
-
-/* Bit Definition for TCF_DrvFlags */
-#define	TCS_DF_NODASD_SUPT	0x20	/* Suppress OS/2 DASD Mgr support */
-#define	TCS_DF_NOSCSI_SUPT	0x40	/* Suppress OS/2 SCSI Mgr support */
-
-
-/***********************************************************************
-              Host Adapter Control Structure
-************************************************************************/
-typedef struct ORC_Ha_Ctrl_Struc {
-	USHORT HCS_Base;	/* 00 */
-	UBYTE HCS_Index;	/* 02 */
-	UBYTE HCS_Intr;		/* 04 */
-	UBYTE HCS_SCSI_ID;	/* 06    H/A SCSI ID */
-	UBYTE HCS_BIOS;		/* 07    BIOS configuration */
-
-	UBYTE HCS_Flags;	/* 0B */
-	UBYTE HCS_HAConfig1;	/* 1B    SCSI0MAXTags */
-	UBYTE HCS_MaxTar;	/* 1B    SCSI0MAXTags */
-
-	USHORT HCS_Units;	/* Number of units this adapter  */
-	USHORT HCS_AFlags;	/* Adapter info. defined flags   */
-	ULONG HCS_Timeout;	/* Adapter timeout value   */
-	PVOID HCS_virScbArray;	/* 28 Virtual Pointer to SCB array     */
-	dma_addr_t HCS_physScbArray;	/* Scb Physical address */
-	PVOID HCS_virEscbArray;	/* Virtual pointer to ESCB Scatter list */
-	dma_addr_t HCS_physEscbArray;	/* scatter list Physical address */
-	UBYTE TargetFlag[16];	/* 30  target configuration, TCF_EN_TAG */
-	UBYTE MaximumTags[16];	/* 40  ORC_MAX_SCBS */
-	UBYTE ActiveTags[16][16];	/* 50 */
-	ORC_TCS HCS_Tcs[16];	/* 28 */
-	U32 BitAllocFlag[MAX_CHANNELS][8];	/* Max STB is 256, So 256/32 */
-	spinlock_t BitAllocFlagLock;
-	struct scsi_cmnd *pSRB_head;
-	struct scsi_cmnd *pSRB_tail;
-	spinlock_t pSRB_lock;
-	struct pci_dev *pdev;
-} ORC_HCS;
-
-/* Bit Definition for HCS_Flags */
-
-#define HCF_SCSI_RESET	0x01	/* SCSI BUS RESET         */
-#define HCF_PARITY    	0x02	/* parity card                    */
-#define HCF_LVDS     	0x10	/* parity card                    */
-
-/* Bit Definition for TargetFlag */
-
-#define TCF_EN_255	    0x08
-#define TCF_EN_TAG	    0x10
-#define TCF_BUSY	      0x20
-#define TCF_DISCONNECT	0x40
-#define TCF_SPIN_UP	  0x80
-
-/* Bit Definition for HCS_AFlags */
-#define	HCS_AF_IGNORE		0x01	/* Adapter ignore         */
-#define	HCS_AF_DISABLE_RESET	0x10	/* Adapter disable reset  */
-#define	HCS_AF_DISABLE_ADPT	0x80	/* Adapter disable                */
-
-
-/*---------------------------------------*/
-/* TimeOut for RESET to complete (30s)   */
-/*                                       */
-/* After a RESET the drive is checked    */
-/* every 200ms.                          */
-/*---------------------------------------*/
-#define DELAYED_RESET_MAX       (30*1000L)
-#define DELAYED_RESET_INTERVAL  200L
-
-/*----------------------------------------------*/
-/* TimeOut for IRQ from last interrupt (5s)     */
-/*----------------------------------------------*/
-#define IRQ_TIMEOUT_INTERVAL    (5*1000L)
-
-/*----------------------------------------------*/
-/* Retry Delay interval (200ms)                 */
-/*----------------------------------------------*/
-#define DELAYED_RETRY_INTERVAL  200L
-
-#define	INQUIRY_SIZE		36
-#define	CAPACITY_SIZE		8
-#define	DEFAULT_SENSE_LEN	14
-
-#define	DEVICE_NOT_FOUND	0x86
-
-/*----------------------------------------------*/
-/* Definition for PCI device                    */
-/*----------------------------------------------*/
-#define	MAX_PCI_DEVICES	21
-#define	MAX_PCI_BUSES	8
-
-typedef struct Adpt_Struc {
-        USHORT ADPT_BIOS;       /* 0 */
-        UBYTE ADPT_BASE;        /* 1 */
-        UBYTE ADPT_Bus;         /* 2 */
-        UBYTE ADPT_Device;      /* 3 */
-        UBYTE ADPT_Reserved[3];
-} JACS, *PJACS;
-
-typedef struct _NVRAM {
-/*----------header ---------------*/
-        UCHAR SubVendorID0;     /* 00 - Sub Vendor ID           */
-        UCHAR SubVendorID1;     /* 00 - Sub Vendor ID           */
-        UCHAR SubSysID0;        /* 02 - Sub System ID           */
-        UCHAR SubSysID1;        /* 02 - Sub System ID           */
-        UCHAR SubClass;         /* 04 - Sub Class               */
-        UCHAR VendorID0;        /* 05 - Vendor ID               */
-        UCHAR VendorID1;        /* 05 - Vendor ID               */
-        UCHAR DeviceID0;        /* 07 - Device ID               */
-        UCHAR DeviceID1;        /* 07 - Device ID               */
-        UCHAR Reserved0[2];     /* 09 - Reserved                */
-        UCHAR Revision;         /* 0B - Revision of data structure */
-        /* ----Host Adapter Structure ---- */
-        UCHAR NumOfCh;          /* 0C - Number of SCSI channel  */
-        UCHAR BIOSConfig1;      /* 0D - BIOS configuration 1    */
-        UCHAR BIOSConfig2;      /* 0E - BIOS boot channel&target ID */
-        UCHAR BIOSConfig3;      /* 0F - BIOS configuration 3    */
-        /* ----SCSI channel Structure ---- */
-        /* from "CTRL-I SCSI Host Adapter SetUp menu "  */
-        UCHAR SCSI0Id;          /* 10 - Channel 0 SCSI ID       */
-        UCHAR SCSI0Config;      /* 11 - Channel 0 SCSI configuration */
-        UCHAR SCSI0MaxTags;     /* 12 - Channel 0 Maximum tags  */
-        UCHAR SCSI0ResetTime;   /* 13 - Channel 0 Reset recovering time */
-        UCHAR ReservedforChannel0[2];   /* 14 - Reserved                */
-
-        /* ----SCSI target Structure ----  */
-        /* from "CTRL-I SCSI device SetUp menu "                        */
-        UCHAR Target00Config;   /* 16 - Channel 0 Target 0 config */
-        UCHAR Target01Config;   /* 17 - Channel 0 Target 1 config */
-        UCHAR Target02Config;   /* 18 - Channel 0 Target 2 config */
-        UCHAR Target03Config;   /* 19 - Channel 0 Target 3 config */
-        UCHAR Target04Config;   /* 1A - Channel 0 Target 4 config */
-        UCHAR Target05Config;   /* 1B - Channel 0 Target 5 config */
-        UCHAR Target06Config;   /* 1C - Channel 0 Target 6 config */
-        UCHAR Target07Config;   /* 1D - Channel 0 Target 7 config */
-        UCHAR Target08Config;   /* 1E - Channel 0 Target 8 config */
-        UCHAR Target09Config;   /* 1F - Channel 0 Target 9 config */
-        UCHAR Target0AConfig;   /* 20 - Channel 0 Target A config */
-        UCHAR Target0BConfig;   /* 21 - Channel 0 Target B config */
-        UCHAR Target0CConfig;   /* 22 - Channel 0 Target C config */
-        UCHAR Target0DConfig;   /* 23 - Channel 0 Target D config */
-        UCHAR Target0EConfig;   /* 24 - Channel 0 Target E config */
-        UCHAR Target0FConfig;   /* 25 - Channel 0 Target F config */
-
-        UCHAR SCSI1Id;          /* 26 - Channel 1 SCSI ID       */
-        UCHAR SCSI1Config;      /* 27 - Channel 1 SCSI configuration */
-        UCHAR SCSI1MaxTags;     /* 28 - Channel 1 Maximum tags  */
-        UCHAR SCSI1ResetTime;   /* 29 - Channel 1 Reset recovering time */
-        UCHAR ReservedforChannel1[2];   /* 2A - Reserved                */
-
-        /* ----SCSI target Structure ----  */
-        /* from "CTRL-I SCSI device SetUp menu "                                          */
-        UCHAR Target10Config;   /* 2C - Channel 1 Target 0 config */
-        UCHAR Target11Config;   /* 2D - Channel 1 Target 1 config */
-        UCHAR Target12Config;   /* 2E - Channel 1 Target 2 config */
-        UCHAR Target13Config;   /* 2F - Channel 1 Target 3 config */
-        UCHAR Target14Config;   /* 30 - Channel 1 Target 4 config */
-        UCHAR Target15Config;   /* 31 - Channel 1 Target 5 config */
-        UCHAR Target16Config;   /* 32 - Channel 1 Target 6 config */
-        UCHAR Target17Config;   /* 33 - Channel 1 Target 7 config */
-        UCHAR Target18Config;   /* 34 - Channel 1 Target 8 config */
-        UCHAR Target19Config;   /* 35 - Channel 1 Target 9 config */
-        UCHAR Target1AConfig;   /* 36 - Channel 1 Target A config */
-        UCHAR Target1BConfig;   /* 37 - Channel 1 Target B config */
-        UCHAR Target1CConfig;   /* 38 - Channel 1 Target C config */
-        UCHAR Target1DConfig;   /* 39 - Channel 1 Target D config */
-        UCHAR Target1EConfig;   /* 3A - Channel 1 Target E config */
-        UCHAR Target1FConfig;   /* 3B - Channel 1 Target F config */
-        UCHAR reserved[3];      /* 3C - Reserved                */
-        /* ---------- CheckSum ----------       */
-        UCHAR CheckSum;         /* 3F - Checksum of NVRam       */
-} NVRAM, *PNVRAM;
-
-/* Bios Configuration for nvram->BIOSConfig1                            */
-#define NBC_BIOSENABLE  0x01    /* BIOS enable                    */
-#define NBC_CDROM       0x02    /* Support bootable CDROM */
-#define NBC_REMOVABLE   0x04    /* Support removable drive        */
-
-/* Bios Configuration for nvram->BIOSConfig2                            */
-#define NBB_TARGET_MASK 0x0F    /* Boot SCSI target ID number     */
-#define NBB_CHANL_MASK  0xF0    /* Boot SCSI channel number       */
-
-/* Bit definition for nvram->SCSIConfig                                 */
-#define NCC_BUSRESET    0x01    /* Reset SCSI bus at power up     */
-#define NCC_PARITYCHK   0x02    /* SCSI parity enable             */
-#define NCC_LVDS        0x10    /* Enable LVDS                    */
-#define NCC_ACTTERM1    0x20    /* Enable active terminator 1     */
-#define NCC_ACTTERM2    0x40    /* Enable active terminator 2     */
-#define NCC_AUTOTERM    0x80    /* Enable auto termination        */
-
-/* Bit definition for nvram->TargetxConfig                              */
-#define NTC_PERIOD      0x07    /* Maximum Sync. Speed            */
-#define NTC_1GIGA       0x08    /* 255 head / 63 sectors (64/32) */
-#define NTC_NO_SYNC     0x10    /* NO SYNC. NEGO          */
-#define NTC_NO_WIDESYNC 0x20    /* NO WIDE SYNC. NEGO             */
-#define NTC_DISC_ENABLE 0x40    /* Enable SCSI disconnect */
-#define NTC_SPINUP      0x80    /* Start disk drive               */
-
-/* Default NVRam values                                                 */
-#define NBC_DEFAULT     (NBC_ENABLE)
-#define NCC_DEFAULT     (NCC_BUSRESET | NCC_AUTOTERM | NCC_PARITYCHK)
-#define NCC_MAX_TAGS    0x20    /* Maximum tags per target        */
-#define NCC_RESET_TIME  0x0A    /* SCSI RESET recovering time     */
-#define NTC_DEFAULT     (NTC_1GIGA | NTC_NO_WIDESYNC | NTC_DISC_ENABLE)
-
-typedef union {                 /* Union define for mechanism 1   */
-        struct {
-                unsigned char RegNum;
-                unsigned char FcnNum:3;
-                unsigned char DeviceNum:5;
-                unsigned char BusNum;
-                unsigned char Reserved:7;
-                unsigned char Enable:1;
-        } sConfigAdr;
-        unsigned long lConfigAdr;
-} CONFIG_ADR;
-
-typedef union {                 /* Union define for mechanism 2   */
-        struct {
-                unsigned char RegNum;
-                unsigned char DeviceNum;
-                unsigned short Reserved;
-        } sHostAdr;
-        unsigned long lHostAdr;
-} HOST_ADR;
-
-#define ORC_RD(x,y)             (UCHAR)(inb(  (int)((ULONG)((ULONG)x+(UCHAR)y)) ))
-#define ORC_RDLONG(x,y)         (long)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
-
-#define ORC_WR(     adr,data)   outb( (UCHAR)(data), (int)(adr))
-#define ORC_WRSHORT(adr,data)   outw( (UWORD)(data), (int)(adr))
-#define ORC_WRLONG( adr,data)   outl( (ULONG)(data), (int)(adr))
-
-
-
diff -Nru a/drivers/scsi/initio.c b/drivers/scsi/initio.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/initio.c	2004-12-24 13:36:31 -08:00
@@ -0,0 +1,3184 @@
+/**************************************************************************
+ * Initio 9100 device driver for Linux.
+ *
+ * Copyright (c) 1994-1998 Initio Corporation
+ * Copyright (c) 1998 Bas Vermeulen <bvermeul@blackstar.xs4all.nl>
+ * 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, 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; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Where this Software is combined with software released under the terms of 
+ * the GNU General Public License ("GPL") and the terms of the GPL would require the 
+ * combined work to also be released under the terms of the GPL, the terms
+ * and conditions of this License will apply in addition to those of the
+ * GPL with the exception of any terms or conditions of this License that
+ * conflict with, or are expressly prohibited by, the GPL.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ *
+ *************************************************************************
+ *
+ * DESCRIPTION:
+ *
+ * This is the Linux low-level SCSI driver for Initio INI-9X00U/UW SCSI host
+ * adapters
+ *
+ * 08/06/97 hc	- v1.01h
+ *		- Support inic-940 and inic-935
+ * 09/26/97 hc	- v1.01i
+ *		- Make correction from J.W. Schultz suggestion
+ * 10/13/97 hc	- Support reset function
+ * 10/21/97 hc	- v1.01j
+ *		- Support 32 LUN (SCSI 3)
+ * 01/14/98 hc	- v1.01k
+ *		- Fix memory allocation problem
+ * 03/04/98 hc	- v1.01l
+ *		- Fix tape rewind which will hang the system problem
+ *		- Set can_queue to tul_num_scb
+ * 06/25/98 hc	- v1.01m
+ *		- Get it work for kernel version >= 2.1.75
+ *		- Dynamic assign SCSI bus reset holding time in init_tulip()
+ * 07/02/98 hc	- v1.01n
+ *		- Support 0002134A
+ * 08/07/98 hc  - v1.01o
+ *		- Change the tul_abort_srb routine to use scsi_done. <01>
+ * 09/07/98 hl  - v1.02
+ *              - Change the INI9100U define and proc_dir_entry to
+ *                reflect the newer Kernel 2.1.118, but the v1.o1o
+ *                should work with Kernel 2.1.118.
+ * 09/20/98 wh  - v1.02a
+ *              - Support Abort command.
+ *              - Handle reset routine.
+ * 09/21/98 hl  - v1.03
+ *              - remove comments.
+ * 12/09/98 bv	- v1.03a
+ *		- Removed unused code
+ * 12/13/98 bv	- v1.03b
+ *		- Remove cli() locking for kernels >= 2.1.95. This uses
+ *		  spinlocks to serialize access to the pSRB_head and
+ *		  pSRB_tail members of the HCS structure.
+ * 09/01/99 bv	- v1.03d
+ *		- Fixed a deadlock problem in SMP.
+ * 21/01/99 bv	- v1.03e
+ *		- Add support for the Domex 3192U PCI SCSI
+ *		  This is a slightly modified patch by
+ *		  Brian Macy <bmacy@sunshinecomputing.com>
+ * 22/02/99 bv	- v1.03f
+ *		- Didn't detect the INIC-950 in 2.0.x correctly.
+ *		  Now fixed.
+ * 05/07/99 bv	- v1.03g
+ *		- Changed the assumption that HZ = 100
+ * 10/17/03 mc	- v1.04
+ *		- added new DMA API support
+ * 06/01/04 jmd	- v1.04a
+ *		- Re-add reset_bus support
+ **************************************************************************/
+
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/blkdev.h>
+#include <linux/spinlock.h>
+#include <linux/stat.h>
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/proc_fs.h>
+#include <linux/string.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <asm/io.h>
+
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
+
+#include "initio.h"
+
+#define SENSE_SIZE		14
+
+#define i91u_MAXQUEUE		2
+#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.04a"
+
+#define INI_VENDOR_ID   0x1101	/* Initio's PCI vendor ID       */
+#define DMX_VENDOR_ID	0x134a	/* Domex's PCI vendor ID	*/
+#define I950_DEVICE_ID	0x9500	/* Initio's inic-950 product ID   */
+#define I940_DEVICE_ID	0x9400	/* Initio's inic-940 product ID   */
+#define I935_DEVICE_ID	0x9401	/* Initio's inic-935 product ID   */
+#define I920_DEVICE_ID	0x0002	/* Initio's other product ID      */
+
+#ifdef DEBUG_i91u
+static unsigned int i91u_debug = DEBUG_DEFAULT;
+#endif
+
+#define TULSZ(sz)     (sizeof(sz) / sizeof(sz[0]))
+#define TUL_RDWORD(x,y)         (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
+
+typedef struct PCI_ID_Struc {
+	unsigned short vendor_id;
+	unsigned short device_id;
+} PCI_ID;
+
+static int tul_num_ch = 4;	/* Maximum 4 adapters           */
+static int tul_num_scb;
+static int tul_tag_enable = 1;
+static SCB *tul_scb;
+
+#ifdef DEBUG_i91u
+static int setup_debug = 0;
+#endif
+
+static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
+
+static const PCI_ID i91u_pci_devices[] = {
+	{ INI_VENDOR_ID, I950_DEVICE_ID },
+	{ INI_VENDOR_ID, I940_DEVICE_ID },
+	{ INI_VENDOR_ID, I935_DEVICE_ID },
+	{ INI_VENDOR_ID, I920_DEVICE_ID },
+	{ DMX_VENDOR_ID, I920_DEVICE_ID },
+};
+
+#define DEBUG_INTERRUPT 0
+#define DEBUG_QUEUE     0
+#define DEBUG_STATE     0
+#define INT_DISC	0
+
+/*--- external functions --*/
+static void tul_se2_wait(void);
+
+/*--- forward refrence ---*/
+static SCB *tul_find_busy_scb(HCS * pCurHcb, WORD tarlun);
+static SCB *tul_find_done_scb(HCS * pCurHcb);
+
+static int tulip_main(HCS * pCurHcb);
+
+static int tul_next_state(HCS * pCurHcb);
+static int tul_state_1(HCS * pCurHcb);
+static int tul_state_2(HCS * pCurHcb);
+static int tul_state_3(HCS * pCurHcb);
+static int tul_state_4(HCS * pCurHcb);
+static int tul_state_5(HCS * pCurHcb);
+static int tul_state_6(HCS * pCurHcb);
+static int tul_state_7(HCS * pCurHcb);
+static int tul_xfer_data_in(HCS * pCurHcb);
+static int tul_xfer_data_out(HCS * pCurHcb);
+static int tul_xpad_in(HCS * pCurHcb);
+static int tul_xpad_out(HCS * pCurHcb);
+static int tul_status_msg(HCS * pCurHcb);
+
+static int tul_msgin(HCS * pCurHcb);
+static int tul_msgin_sync(HCS * pCurHcb);
+static int tul_msgin_accept(HCS * pCurHcb);
+static int tul_msgout_reject(HCS * pCurHcb);
+static int tul_msgin_extend(HCS * pCurHcb);
+
+static int tul_msgout_ide(HCS * pCurHcb);
+static int tul_msgout_abort_targ(HCS * pCurHcb);
+static int tul_msgout_abort_tag(HCS * pCurHcb);
+
+static int tul_bus_device_reset(HCS * pCurHcb);
+static void tul_select_atn(HCS * pCurHcb, SCB * pCurScb);
+static void tul_select_atn3(HCS * pCurHcb, SCB * pCurScb);
+static void tul_select_atn_stop(HCS * pCurHcb, SCB * pCurScb);
+static int int_tul_busfree(HCS * pCurHcb);
+int int_tul_scsi_rst(HCS * pCurHcb);
+static int int_tul_bad_seq(HCS * pCurHcb);
+static int int_tul_resel(HCS * pCurHcb);
+static int tul_sync_done(HCS * pCurHcb);
+static int wdtr_done(HCS * pCurHcb);
+static int wait_tulip(HCS * pCurHcb);
+static int tul_wait_done_disc(HCS * pCurHcb);
+static int tul_wait_disc(HCS * pCurHcb);
+static void tulip_scsi(HCS * pCurHcb);
+static int tul_post_scsi_rst(HCS * pCurHcb);
+
+static void tul_se2_ew_en(WORD CurBase);
+static void tul_se2_ew_ds(WORD CurBase);
+static int tul_se2_rd_all(WORD CurBase);
+static void tul_se2_update_all(WORD CurBase);	/* setup default pattern */
+static void tul_read_eeprom(WORD CurBase);
+
+				/* ---- EXTERNAL VARIABLES ---- */
+HCS tul_hcs[MAX_SUPPORTED_ADAPTERS];
+				/* ---- INTERNAL VARIABLES ---- */
+static INI_ADPT_STRUCT i91u_adpt[MAX_SUPPORTED_ADAPTERS];
+
+/*NVRAM nvram, *nvramp = &nvram; */
+static NVRAM i91unvram;
+static NVRAM *i91unvramp;
+
+
+
+static UCHAR i91udftNvRam[64] =
+{
+/*----------- header -----------*/
+	0x25, 0xc9,		/* Signature    */
+	0x40,			/* Size         */
+	0x01,			/* Revision     */
+	/* -- Host Adapter Structure -- */
+	0x95,			/* ModelByte0   */
+	0x00,			/* ModelByte1   */
+	0x00,			/* ModelInfo    */
+	0x01,			/* NumOfCh      */
+	NBC1_DEFAULT,		/* BIOSConfig1  */
+	0,			/* BIOSConfig2  */
+	0,			/* HAConfig1    */
+	0,			/* HAConfig2    */
+	/* SCSI channel 0 and target Structure  */
+	7,			/* SCSIid       */
+	NCC1_DEFAULT,		/* SCSIconfig1  */
+	0,			/* SCSIconfig2  */
+	0x10,			/* NumSCSItarget */
+
+	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
+	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
+	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
+	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
+
+	/* SCSI channel 1 and target Structure  */
+	7,			/* SCSIid       */
+	NCC1_DEFAULT,		/* SCSIconfig1  */
+	0,			/* SCSIconfig2  */
+	0x10,			/* NumSCSItarget */
+
+	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
+	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
+	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
+	NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT, NTC_DEFAULT,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0};			/*      - CheckSum -            */
+
+
+static UCHAR tul_rate_tbl[8] =	/* fast 20      */
+{
+				/* nanosecond devide by 4 */
+	12,			/* 50ns,  20M   */
+	18,			/* 75ns,  13.3M */
+	25,			/* 100ns, 10M   */
+	31,			/* 125ns, 8M    */
+	37,			/* 150ns, 6.6M  */
+	43,			/* 175ns, 5.7M  */
+	50,			/* 200ns, 5M    */
+	62			/* 250ns, 4M    */
+};
+
+static void tul_do_pause(unsigned amount)
+{				/* Pause for amount jiffies */
+	unsigned long the_time = jiffies + amount;
+
+	while (time_before_eq(jiffies, the_time));
+}
+
+/*-- forward reference --*/
+
+/*******************************************************************
+	Use memeory refresh time        ~ 15us * 2
+********************************************************************/
+void tul_se2_wait(void)
+{
+#if 1
+	udelay(30);
+#else
+	UCHAR readByte;
+
+	readByte = TUL_RD(0, 0x61);
+	if ((readByte & 0x10) == 0x10) {
+		for (;;) {
+			readByte = TUL_RD(0, 0x61);
+			if ((readByte & 0x10) == 0x10)
+				break;
+		}
+		for (;;) {
+			readByte = TUL_RD(0, 0x61);
+			if ((readByte & 0x10) != 0x10)
+				break;
+		}
+	} else {
+		for (;;) {
+			readByte = TUL_RD(0, 0x61);
+			if ((readByte & 0x10) == 0x10)
+				break;
+		}
+		for (;;) {
+			readByte = TUL_RD(0, 0x61);
+			if ((readByte & 0x10) != 0x10)
+				break;
+		}
+	}
+#endif
+}
+
+
+/******************************************************************
+ Input: instruction for  Serial E2PROM
+
+ EX: se2_rd(0 call se2_instr() to send address and read command
+
+	 StartBit  OP_Code   Address                Data
+	 --------- --------  ------------------     -------
+	 1         1 , 0     A5,A4,A3,A2,A1,A0      D15-D0
+
+		 +-----------------------------------------------------
+		 |
+ CS -----+
+			+--+  +--+  +--+  +--+  +--+
+			^  |  ^  |  ^  |  ^  |  ^  |
+			|  |  |  |  |  |  |  |  |  |
+ CLK -------+  +--+  +--+  +--+  +--+  +--
+ (leading edge trigger)
+
+		 +--1-----1--+
+		 | SB    OP  |  OP    A5    A4
+ DI  ----+           +--0------------------
+ (address and cmd sent to nvram)
+
+	 -------------------------------------------+
+												|
+ DO                                             +---
+ (data sent from nvram)
+
+
+******************************************************************/
+void tul_se2_instr(WORD CurBase, UCHAR instr)
+{
+	int i;
+	UCHAR b;
+
+	TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2DO);	/* cs+start bit */
+	tul_se2_wait();
+	TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK | SE2DO);	/* +CLK */
+	tul_se2_wait();
+
+	for (i = 0; i < 8; i++) {
+		if (instr & 0x80)
+			b = SE2CS | SE2DO;	/* -CLK+dataBit */
+		else
+			b = SE2CS;	/* -CLK */
+		TUL_WR(CurBase + TUL_NVRAM, b);
+		tul_se2_wait();
+		TUL_WR(CurBase + TUL_NVRAM, b | SE2CLK);	/* +CLK */
+		tul_se2_wait();
+		instr <<= 1;
+	}
+	TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK */
+	tul_se2_wait();
+	return;
+}
+
+
+/******************************************************************
+ Function name  : tul_se2_ew_en
+ Description    : Enable erase/write state of serial EEPROM
+******************************************************************/
+void tul_se2_ew_en(WORD CurBase)
+{
+	tul_se2_instr(CurBase, 0x30);	/* EWEN */
+	TUL_WR(CurBase + TUL_NVRAM, 0);		/* -CS  */
+	tul_se2_wait();
+	return;
+}
+
+
+/************************************************************************
+ Disable erase/write state of serial EEPROM
+*************************************************************************/
+void tul_se2_ew_ds(WORD CurBase)
+{
+	tul_se2_instr(CurBase, 0);	/* EWDS */
+	TUL_WR(CurBase + TUL_NVRAM, 0);		/* -CS  */
+	tul_se2_wait();
+	return;
+}
+
+
+/******************************************************************
+	Input  :address of Serial E2PROM
+	Output :value stored in  Serial E2PROM
+*******************************************************************/
+USHORT tul_se2_rd(WORD CurBase, ULONG adr)
+{
+	UCHAR instr, readByte;
+	USHORT readWord;
+	int i;
+
+	instr = (UCHAR) (adr | 0x80);
+	tul_se2_instr(CurBase, instr);	/* READ INSTR */
+	readWord = 0;
+
+	for (i = 15; i >= 0; i--) {
+		TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK);	/* +CLK */
+		tul_se2_wait();
+		TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK */
+
+		/* sample data after the following edge of clock  */
+		readByte = TUL_RD(CurBase, TUL_NVRAM);
+		readByte &= SE2DI;
+		readWord += (readByte << i);
+		tul_se2_wait();	/* 6/20/95 */
+	}
+
+	TUL_WR(CurBase + TUL_NVRAM, 0);		/* no chip select */
+	tul_se2_wait();
+	return readWord;
+}
+
+
+/******************************************************************
+ Input: new value in  Serial E2PROM, address of Serial E2PROM
+*******************************************************************/
+void tul_se2_wr(WORD CurBase, UCHAR adr, USHORT writeWord)
+{
+	UCHAR readByte;
+	UCHAR instr;
+	int i;
+
+	instr = (UCHAR) (adr | 0x40);
+	tul_se2_instr(CurBase, instr);	/* WRITE INSTR */
+	for (i = 15; i >= 0; i--) {
+		if (writeWord & 0x8000)
+			TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2DO);	/* -CLK+dataBit 1 */
+		else
+			TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK+dataBit 0 */
+		tul_se2_wait();
+		TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK);	/* +CLK */
+		tul_se2_wait();
+		writeWord <<= 1;
+	}
+	TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK */
+	tul_se2_wait();
+	TUL_WR(CurBase + TUL_NVRAM, 0);		/* -CS  */
+	tul_se2_wait();
+
+	TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* +CS  */
+	tul_se2_wait();
+
+	for (;;) {
+		TUL_WR(CurBase + TUL_NVRAM, SE2CS | SE2CLK);	/* +CLK */
+		tul_se2_wait();
+		TUL_WR(CurBase + TUL_NVRAM, SE2CS);	/* -CLK */
+		tul_se2_wait();
+		if ((readByte = TUL_RD(CurBase, TUL_NVRAM)) & SE2DI)
+			break;	/* write complete */
+	}
+	TUL_WR(CurBase + TUL_NVRAM, 0);		/* -CS */
+	return;
+}
+
+
+/***********************************************************************
+ Read SCSI H/A configuration parameters from serial EEPROM
+************************************************************************/
+int tul_se2_rd_all(WORD CurBase)
+{
+	int i;
+	ULONG chksum = 0;
+	USHORT *np;
+
+	i91unvramp = &i91unvram;
+	np = (USHORT *) i91unvramp;
+	for (i = 0; i < 32; i++) {
+		*np++ = tul_se2_rd(CurBase, i);
+	}
+
+/*--------------------Is signature "ini" ok ? ----------------*/
+	if (i91unvramp->NVM_Signature != INI_SIGNATURE)
+		return -1;
+/*---------------------- Is ckecksum ok ? ----------------------*/
+	np = (USHORT *) i91unvramp;
+	for (i = 0; i < 31; i++)
+		chksum += *np++;
+	if (i91unvramp->NVM_CheckSum != (USHORT) chksum)
+		return -1;
+	return 1;
+}
+
+
+/***********************************************************************
+ Update SCSI H/A configuration parameters from serial EEPROM
+************************************************************************/
+void tul_se2_update_all(WORD CurBase)
+{				/* setup default pattern */
+	int i;
+	ULONG chksum = 0;
+	USHORT *np, *np1;
+
+	i91unvramp = &i91unvram;
+	/* Calculate checksum first */
+	np = (USHORT *) i91udftNvRam;
+	for (i = 0; i < 31; i++)
+		chksum += *np++;
+	*np = (USHORT) chksum;
+	tul_se2_ew_en(CurBase);	/* Enable write  */
+
+	np = (USHORT *) i91udftNvRam;
+	np1 = (USHORT *) i91unvramp;
+	for (i = 0; i < 32; i++, np++, np1++) {
+		if (*np != *np1) {
+			tul_se2_wr(CurBase, i, *np);
+		}
+	}
+
+	tul_se2_ew_ds(CurBase);	/* Disable write   */
+	return;
+}
+
+/*************************************************************************
+ Function name  : read_eeprom
+**************************************************************************/
+void tul_read_eeprom(WORD CurBase)
+{
+	UCHAR gctrl;
+
+	i91unvramp = &i91unvram;
+/*------Enable EEProm programming ---*/
+	gctrl = TUL_RD(CurBase, TUL_GCTRL);
+	TUL_WR(CurBase + TUL_GCTRL, gctrl | TUL_GCTRL_EEPROM_BIT);
+	if (tul_se2_rd_all(CurBase) != 1) {
+		tul_se2_update_all(CurBase);	/* setup default pattern */
+		tul_se2_rd_all(CurBase);	/* load again  */
+	}
+/*------ Disable EEProm programming ---*/
+	gctrl = TUL_RD(CurBase, TUL_GCTRL);
+	TUL_WR(CurBase + TUL_GCTRL, gctrl & ~TUL_GCTRL_EEPROM_BIT);
+}				/* read_eeprom */
+
+int Addi91u_into_Adapter_table(WORD wBIOS, WORD wBASE, BYTE bInterrupt,
+			       BYTE bBus, BYTE bDevice)
+{
+	int i, j;
+
+	for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) {
+		if (i91u_adpt[i].ADPT_BIOS < wBIOS)
+			continue;
+		if (i91u_adpt[i].ADPT_BIOS == wBIOS) {
+			if (i91u_adpt[i].ADPT_BASE == wBASE) {
+				if (i91u_adpt[i].ADPT_Bus != 0xFF)
+					return 1;
+			} else if (i91u_adpt[i].ADPT_BASE < wBASE)
+					continue;
+		}
+		for (j = MAX_SUPPORTED_ADAPTERS - 1; j > i; j--) {
+			i91u_adpt[j].ADPT_BASE = i91u_adpt[j - 1].ADPT_BASE;
+			i91u_adpt[j].ADPT_INTR = i91u_adpt[j - 1].ADPT_INTR;
+			i91u_adpt[j].ADPT_BIOS = i91u_adpt[j - 1].ADPT_BIOS;
+			i91u_adpt[j].ADPT_Bus = i91u_adpt[j - 1].ADPT_Bus;
+			i91u_adpt[j].ADPT_Device = i91u_adpt[j - 1].ADPT_Device;
+		}
+		i91u_adpt[i].ADPT_BASE = wBASE;
+		i91u_adpt[i].ADPT_INTR = bInterrupt;
+		i91u_adpt[i].ADPT_BIOS = wBIOS;
+		i91u_adpt[i].ADPT_Bus = bBus;
+		i91u_adpt[i].ADPT_Device = bDevice;
+		return 0;
+	}
+	return 1;
+}
+
+void init_i91uAdapter_table(void)
+{
+	int i;
+
+	for (i = 0; i < MAX_SUPPORTED_ADAPTERS; i++) {	/* Initialize adapter structure */
+		i91u_adpt[i].ADPT_BIOS = 0xffff;
+		i91u_adpt[i].ADPT_BASE = 0xffff;
+		i91u_adpt[i].ADPT_INTR = 0xff;
+		i91u_adpt[i].ADPT_Bus = 0xff;
+		i91u_adpt[i].ADPT_Device = 0xff;
+	}
+	return;
+}
+
+void tul_stop_bm(HCS * pCurHcb)
+{
+
+	if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) {	/* if DMA xfer is pending, abort DMA xfer */
+		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT | TAX_X_CLR_FIFO);
+		/* wait Abort DMA xfer done */
+		while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & XABT) == 0);
+	}
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+}
+
+/***************************************************************************/
+void get_tulipPCIConfig(HCS * pCurHcb, int ch_idx)
+{
+	pCurHcb->HCS_Base = i91u_adpt[ch_idx].ADPT_BASE;	/* Supply base address  */
+	pCurHcb->HCS_BIOS = i91u_adpt[ch_idx].ADPT_BIOS;	/* Supply BIOS address  */
+	pCurHcb->HCS_Intr = i91u_adpt[ch_idx].ADPT_INTR;	/* Supply interrupt line */
+	return;
+}
+
+/***************************************************************************/
+int tul_reset_scsi(HCS * pCurHcb, int seconds)
+{
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_RST_BUS);
+
+	while (!((pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt)) & TSS_SCSIRST_INT));
+	/* reset tulip chip */
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, 0);
+
+	/* Stall for a while, wait for target's firmware ready,make it 2 sec ! */
+	/* SONY 5200 tape drive won't work if only stall for 1 sec */
+	tul_do_pause(seconds * HZ);
+
+	TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
+
+	return (SCSI_RESET_SUCCESS);
+}
+
+/***************************************************************************/
+int init_tulip(HCS * pCurHcb, SCB * scbp, int tul_num_scb, BYTE * pbBiosAdr, int seconds)
+{
+	int i;
+	BYTE *pwFlags;
+	BYTE *pbHeads;
+	SCB *pTmpScb, *pPrevScb = NULL;
+
+	pCurHcb->HCS_NumScbs = tul_num_scb;
+	pCurHcb->HCS_Semaph = 1;
+	spin_lock_init(&pCurHcb->HCS_SemaphLock);
+	pCurHcb->HCS_JSStatus0 = 0;
+	pCurHcb->HCS_Scb = scbp;
+	pCurHcb->HCS_NxtPend = scbp;
+	pCurHcb->HCS_NxtAvail = scbp;
+	for (i = 0, pTmpScb = scbp; i < tul_num_scb; i++, pTmpScb++) {
+		pTmpScb->SCB_TagId = i;
+		if (i != 0)
+			pPrevScb->SCB_NxtScb = pTmpScb;
+		pPrevScb = pTmpScb;
+	}
+	pPrevScb->SCB_NxtScb = NULL;
+	pCurHcb->HCS_ScbEnd = pTmpScb;
+	pCurHcb->HCS_FirstAvail = scbp;
+	pCurHcb->HCS_LastAvail = pPrevScb;
+	spin_lock_init(&pCurHcb->HCS_AvailLock);
+	pCurHcb->HCS_FirstPend = NULL;
+	pCurHcb->HCS_LastPend = NULL;
+	pCurHcb->HCS_FirstBusy = NULL;
+	pCurHcb->HCS_LastBusy = NULL;
+	pCurHcb->HCS_FirstDone = NULL;
+	pCurHcb->HCS_LastDone = NULL;
+	pCurHcb->HCS_ActScb = NULL;
+	pCurHcb->HCS_ActTcs = NULL;
+
+	tul_read_eeprom(pCurHcb->HCS_Base);
+/*---------- get H/A configuration -------------*/
+	if (i91unvramp->NVM_SCSIInfo[0].NVM_NumOfTarg == 8)
+		pCurHcb->HCS_MaxTar = 8;
+	else
+		pCurHcb->HCS_MaxTar = 16;
+
+	pCurHcb->HCS_Config = i91unvramp->NVM_SCSIInfo[0].NVM_ChConfig1;
+
+	pCurHcb->HCS_SCSI_ID = i91unvramp->NVM_SCSIInfo[0].NVM_ChSCSIID;
+	pCurHcb->HCS_IdMask = ~(1 << pCurHcb->HCS_SCSI_ID);
+
+#if CHK_PARITY
+	/* Enable parity error response */
+	TUL_WR(pCurHcb->HCS_Base + TUL_PCMD, TUL_RD(pCurHcb->HCS_Base, TUL_PCMD) | 0x40);
+#endif
+
+	/* Mask all the interrupt       */
+	TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
+
+	tul_stop_bm(pCurHcb);
+	/* --- Initialize the tulip --- */
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_RST_CHIP);
+
+	/* program HBA's SCSI ID        */
+	TUL_WR(pCurHcb->HCS_Base + TUL_SScsiId, pCurHcb->HCS_SCSI_ID << 4);
+
+	/* Enable Initiator Mode ,phase latch,alternate sync period mode,
+	   disable SCSI reset */
+	if (pCurHcb->HCS_Config & HCC_EN_PAR)
+		pCurHcb->HCS_SConf1 = (TSC_INITDEFAULT | TSC_EN_SCSI_PAR);
+	else
+		pCurHcb->HCS_SConf1 = (TSC_INITDEFAULT);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_SConf1);
+
+	/* Enable HW reselect           */
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, 0);
+
+	/* selection time out = 250 ms */
+	TUL_WR(pCurHcb->HCS_Base + TUL_STimeOut, 153);
+
+/*--------- Enable SCSI terminator -----*/
+	TUL_WR(pCurHcb->HCS_Base + TUL_XCtrl, (pCurHcb->HCS_Config & (HCC_ACT_TERM1 | HCC_ACT_TERM2)));
+	TUL_WR(pCurHcb->HCS_Base + TUL_GCTRL1,
+	       ((pCurHcb->HCS_Config & HCC_AUTO_TERM) >> 4) | (TUL_RD(pCurHcb->HCS_Base, TUL_GCTRL1) & 0xFE));
+
+	for (i = 0,
+	     pwFlags = & (i91unvramp->NVM_SCSIInfo[0].NVM_Targ0Config),
+	     pbHeads = pbBiosAdr + 0x180;
+	     i < pCurHcb->HCS_MaxTar;
+	     i++, pwFlags++) {
+		pCurHcb->HCS_Tcs[i].TCS_Flags = *pwFlags & ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
+		if (pCurHcb->HCS_Tcs[i].TCS_Flags & TCF_EN_255)
+			pCurHcb->HCS_Tcs[i].TCS_DrvFlags = TCF_DRV_255_63;
+		else
+			pCurHcb->HCS_Tcs[i].TCS_DrvFlags = 0;
+		pCurHcb->HCS_Tcs[i].TCS_JS_Period = 0;
+		pCurHcb->HCS_Tcs[i].TCS_SConfig0 = pCurHcb->HCS_SConf1;
+		pCurHcb->HCS_Tcs[i].TCS_DrvHead = *pbHeads++;
+		if (pCurHcb->HCS_Tcs[i].TCS_DrvHead == 255)
+			pCurHcb->HCS_Tcs[i].TCS_DrvFlags = TCF_DRV_255_63;
+		else
+			pCurHcb->HCS_Tcs[i].TCS_DrvFlags = 0;
+		pCurHcb->HCS_Tcs[i].TCS_DrvSector = *pbHeads++;
+		pCurHcb->HCS_Tcs[i].TCS_Flags &= ~TCF_BUSY;
+		pCurHcb->HCS_ActTags[i] = 0;
+		pCurHcb->HCS_MaxTags[i] = 0xFF;
+	}			/* for                          */
+	printk("i91u: PCI Base=0x%04X, IRQ=%d, BIOS=0x%04X0, SCSI ID=%d\n",
+	       pCurHcb->HCS_Base, pCurHcb->HCS_Intr,
+	       pCurHcb->HCS_BIOS, pCurHcb->HCS_SCSI_ID);
+/*------------------- reset SCSI Bus ---------------------------*/
+	if (pCurHcb->HCS_Config & HCC_SCSI_RESET) {
+		printk("i91u: Reset SCSI Bus ... \n");
+		tul_reset_scsi(pCurHcb, seconds);
+	}
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCFG1, 0x17);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SIntEnable, 0xE9);
+	return (0);
+}
+
+/***************************************************************************/
+SCB *tul_alloc_scb(HCS * hcsp)
+{
+	SCB *pTmpScb;
+	ULONG flags;
+	spin_lock_irqsave(&(hcsp->HCS_AvailLock), flags);
+	if ((pTmpScb = hcsp->HCS_FirstAvail) != NULL) {
+#if DEBUG_QUEUE
+		printk("find scb at %08lx\n", (ULONG) pTmpScb);
+#endif
+		if ((hcsp->HCS_FirstAvail = pTmpScb->SCB_NxtScb) == NULL)
+			hcsp->HCS_LastAvail = NULL;
+		pTmpScb->SCB_NxtScb = NULL;
+		pTmpScb->SCB_Status = SCB_RENT;
+	}
+	spin_unlock_irqrestore(&(hcsp->HCS_AvailLock), flags);
+	return (pTmpScb);
+}
+
+/***************************************************************************/
+void tul_release_scb(HCS * hcsp, SCB * scbp)
+{
+	ULONG flags;
+
+#if DEBUG_QUEUE
+	printk("Release SCB %lx; ", (ULONG) scbp);
+#endif
+	spin_lock_irqsave(&(hcsp->HCS_AvailLock), flags);
+	scbp->SCB_Srb = NULL;
+	scbp->SCB_Status = 0;
+	scbp->SCB_NxtScb = NULL;
+	if (hcsp->HCS_LastAvail != NULL) {
+		hcsp->HCS_LastAvail->SCB_NxtScb = scbp;
+		hcsp->HCS_LastAvail = scbp;
+	} else {
+		hcsp->HCS_FirstAvail = scbp;
+		hcsp->HCS_LastAvail = scbp;
+	}
+	spin_unlock_irqrestore(&(hcsp->HCS_AvailLock), flags);
+}
+
+/***************************************************************************/
+void tul_append_pend_scb(HCS * pCurHcb, SCB * scbp)
+{
+
+#if DEBUG_QUEUE
+	printk("Append pend SCB %lx; ", (ULONG) scbp);
+#endif
+	scbp->SCB_Status = SCB_PEND;
+	scbp->SCB_NxtScb = NULL;
+	if (pCurHcb->HCS_LastPend != NULL) {
+		pCurHcb->HCS_LastPend->SCB_NxtScb = scbp;
+		pCurHcb->HCS_LastPend = scbp;
+	} else {
+		pCurHcb->HCS_FirstPend = scbp;
+		pCurHcb->HCS_LastPend = scbp;
+	}
+}
+
+/***************************************************************************/
+void tul_push_pend_scb(HCS * pCurHcb, SCB * scbp)
+{
+
+#if DEBUG_QUEUE
+	printk("Push pend SCB %lx; ", (ULONG) scbp);
+#endif
+	scbp->SCB_Status = SCB_PEND;
+	if ((scbp->SCB_NxtScb = pCurHcb->HCS_FirstPend) != NULL) {
+		pCurHcb->HCS_FirstPend = scbp;
+	} else {
+		pCurHcb->HCS_FirstPend = scbp;
+		pCurHcb->HCS_LastPend = scbp;
+	}
+}
+
+/***************************************************************************/
+SCB *tul_find_first_pend_scb(HCS * pCurHcb)
+{
+	SCB *pFirstPend;
+
+
+	pFirstPend = pCurHcb->HCS_FirstPend;
+	while (pFirstPend != NULL) {
+		if (pFirstPend->SCB_Opcode != ExecSCSI) {
+			return (pFirstPend);
+		}
+		if (pFirstPend->SCB_TagMsg == 0) {
+			if ((pCurHcb->HCS_ActTags[pFirstPend->SCB_Target] == 0) &&
+			    !(pCurHcb->HCS_Tcs[pFirstPend->SCB_Target].TCS_Flags & TCF_BUSY)) {
+				return (pFirstPend);
+			}
+		} else {
+			if ((pCurHcb->HCS_ActTags[pFirstPend->SCB_Target] >=
+			  pCurHcb->HCS_MaxTags[pFirstPend->SCB_Target]) |
+			    (pCurHcb->HCS_Tcs[pFirstPend->SCB_Target].TCS_Flags & TCF_BUSY)) {
+				pFirstPend = pFirstPend->SCB_NxtScb;
+				continue;
+			}
+			return (pFirstPend);
+		}
+		pFirstPend = pFirstPend->SCB_NxtScb;
+	}
+
+
+	return (pFirstPend);
+}
+/***************************************************************************/
+SCB *tul_pop_pend_scb(HCS * pCurHcb)
+{
+	SCB *pTmpScb;
+
+	if ((pTmpScb = pCurHcb->HCS_FirstPend) != NULL) {
+		if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL)
+			pCurHcb->HCS_LastPend = NULL;
+		pTmpScb->SCB_NxtScb = NULL;
+	}
+#if DEBUG_QUEUE
+	printk("Pop pend SCB %lx; ", (ULONG) pTmpScb);
+#endif
+	return (pTmpScb);
+}
+
+
+/***************************************************************************/
+void tul_unlink_pend_scb(HCS * pCurHcb, SCB * pCurScb)
+{
+	SCB *pTmpScb, *pPrevScb;
+
+#if DEBUG_QUEUE
+	printk("unlink pend SCB %lx; ", (ULONG) pCurScb);
+#endif
+
+	pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend;
+	while (pTmpScb != NULL) {
+		if (pCurScb == pTmpScb) {	/* Unlink this SCB              */
+			if (pTmpScb == pCurHcb->HCS_FirstPend) {
+				if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL)
+					pCurHcb->HCS_LastPend = NULL;
+			} else {
+				pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
+				if (pTmpScb == pCurHcb->HCS_LastPend)
+					pCurHcb->HCS_LastPend = pPrevScb;
+			}
+			pTmpScb->SCB_NxtScb = NULL;
+			break;
+		}
+		pPrevScb = pTmpScb;
+		pTmpScb = pTmpScb->SCB_NxtScb;
+	}
+	return;
+}
+/***************************************************************************/
+void tul_append_busy_scb(HCS * pCurHcb, SCB * scbp)
+{
+
+#if DEBUG_QUEUE
+	printk("append busy SCB %lx; ", (ULONG) scbp);
+#endif
+	if (scbp->SCB_TagMsg)
+		pCurHcb->HCS_ActTags[scbp->SCB_Target]++;
+	else
+		pCurHcb->HCS_Tcs[scbp->SCB_Target].TCS_Flags |= TCF_BUSY;
+	scbp->SCB_Status = SCB_BUSY;
+	scbp->SCB_NxtScb = NULL;
+	if (pCurHcb->HCS_LastBusy != NULL) {
+		pCurHcb->HCS_LastBusy->SCB_NxtScb = scbp;
+		pCurHcb->HCS_LastBusy = scbp;
+	} else {
+		pCurHcb->HCS_FirstBusy = scbp;
+		pCurHcb->HCS_LastBusy = scbp;
+	}
+}
+
+/***************************************************************************/
+SCB *tul_pop_busy_scb(HCS * pCurHcb)
+{
+	SCB *pTmpScb;
+
+
+	if ((pTmpScb = pCurHcb->HCS_FirstBusy) != NULL) {
+		if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL)
+			pCurHcb->HCS_LastBusy = NULL;
+		pTmpScb->SCB_NxtScb = NULL;
+		if (pTmpScb->SCB_TagMsg)
+			pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--;
+		else
+			pCurHcb->HCS_Tcs[pTmpScb->SCB_Target].TCS_Flags &= ~TCF_BUSY;
+	}
+#if DEBUG_QUEUE
+	printk("Pop busy SCB %lx; ", (ULONG) pTmpScb);
+#endif
+	return (pTmpScb);
+}
+
+/***************************************************************************/
+void tul_unlink_busy_scb(HCS * pCurHcb, SCB * pCurScb)
+{
+	SCB *pTmpScb, *pPrevScb;
+
+#if DEBUG_QUEUE
+	printk("unlink busy SCB %lx; ", (ULONG) pCurScb);
+#endif
+
+	pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;
+	while (pTmpScb != NULL) {
+		if (pCurScb == pTmpScb) {	/* Unlink this SCB              */
+			if (pTmpScb == pCurHcb->HCS_FirstBusy) {
+				if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL)
+					pCurHcb->HCS_LastBusy = NULL;
+			} else {
+				pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
+				if (pTmpScb == pCurHcb->HCS_LastBusy)
+					pCurHcb->HCS_LastBusy = pPrevScb;
+			}
+			pTmpScb->SCB_NxtScb = NULL;
+			if (pTmpScb->SCB_TagMsg)
+				pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--;
+			else
+				pCurHcb->HCS_Tcs[pTmpScb->SCB_Target].TCS_Flags &= ~TCF_BUSY;
+			break;
+		}
+		pPrevScb = pTmpScb;
+		pTmpScb = pTmpScb->SCB_NxtScb;
+	}
+	return;
+}
+
+/***************************************************************************/
+SCB *tul_find_busy_scb(HCS * pCurHcb, WORD tarlun)
+{
+	SCB *pTmpScb, *pPrevScb;
+	WORD scbp_tarlun;
+
+
+	pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;
+	while (pTmpScb != NULL) {
+		scbp_tarlun = (pTmpScb->SCB_Lun << 8) | (pTmpScb->SCB_Target);
+		if (scbp_tarlun == tarlun) {	/* Unlink this SCB              */
+			break;
+		}
+		pPrevScb = pTmpScb;
+		pTmpScb = pTmpScb->SCB_NxtScb;
+	}
+#if DEBUG_QUEUE
+	printk("find busy SCB %lx; ", (ULONG) pTmpScb);
+#endif
+	return (pTmpScb);
+}
+
+/***************************************************************************/
+void tul_append_done_scb(HCS * pCurHcb, SCB * scbp)
+{
+
+#if DEBUG_QUEUE
+	printk("append done SCB %lx; ", (ULONG) scbp);
+#endif
+
+	scbp->SCB_Status = SCB_DONE;
+	scbp->SCB_NxtScb = NULL;
+	if (pCurHcb->HCS_LastDone != NULL) {
+		pCurHcb->HCS_LastDone->SCB_NxtScb = scbp;
+		pCurHcb->HCS_LastDone = scbp;
+	} else {
+		pCurHcb->HCS_FirstDone = scbp;
+		pCurHcb->HCS_LastDone = scbp;
+	}
+}
+
+/***************************************************************************/
+SCB *tul_find_done_scb(HCS * pCurHcb)
+{
+	SCB *pTmpScb;
+
+
+	if ((pTmpScb = pCurHcb->HCS_FirstDone) != NULL) {
+		if ((pCurHcb->HCS_FirstDone = pTmpScb->SCB_NxtScb) == NULL)
+			pCurHcb->HCS_LastDone = NULL;
+		pTmpScb->SCB_NxtScb = NULL;
+	}
+#if DEBUG_QUEUE
+	printk("find done SCB %lx; ", (ULONG) pTmpScb);
+#endif
+	return (pTmpScb);
+}
+
+/***************************************************************************/
+int tul_abort_srb(HCS * pCurHcb, struct scsi_cmnd *srbp)
+{
+	ULONG flags;
+	SCB *pTmpScb, *pPrevScb;
+
+	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+
+	if ((pCurHcb->HCS_Semaph == 0) && (pCurHcb->HCS_ActScb == NULL)) {
+		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
+		/* disable Jasmin SCSI Int        */
+
+                spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+
+		tulip_main(pCurHcb);
+
+        	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+
+		pCurHcb->HCS_Semaph = 1;
+		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
+
+		spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+
+		return SCSI_ABORT_SNOOZE;
+	}
+	pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend;	/* Check Pend queue */
+	while (pTmpScb != NULL) {
+		/* 07/27/98 */
+		if (pTmpScb->SCB_Srb == srbp) {
+			if (pTmpScb == pCurHcb->HCS_ActScb) {
+				spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+				return SCSI_ABORT_BUSY;
+			} else if (pTmpScb == pCurHcb->HCS_FirstPend) {
+				if ((pCurHcb->HCS_FirstPend = pTmpScb->SCB_NxtScb) == NULL)
+					pCurHcb->HCS_LastPend = NULL;
+			} else {
+				pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
+				if (pTmpScb == pCurHcb->HCS_LastPend)
+					pCurHcb->HCS_LastPend = pPrevScb;
+			}
+			pTmpScb->SCB_HaStat = HOST_ABORTED;
+			pTmpScb->SCB_Flags |= SCF_DONE;
+			if (pTmpScb->SCB_Flags & SCF_POST)
+				(*pTmpScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pTmpScb);
+			spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+			return SCSI_ABORT_SUCCESS;
+		}
+		pPrevScb = pTmpScb;
+		pTmpScb = pTmpScb->SCB_NxtScb;
+	}
+
+	pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;	/* Check Busy queue */
+	while (pTmpScb != NULL) {
+
+		if (pTmpScb->SCB_Srb == srbp) {
+
+			if (pTmpScb == pCurHcb->HCS_ActScb) {
+				spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+				return SCSI_ABORT_BUSY;
+			} else if (pTmpScb->SCB_TagMsg == 0) {
+				spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+				return SCSI_ABORT_BUSY;
+			} else {
+				pCurHcb->HCS_ActTags[pTmpScb->SCB_Target]--;
+				if (pTmpScb == pCurHcb->HCS_FirstBusy) {
+					if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL)
+						pCurHcb->HCS_LastBusy = NULL;
+				} else {
+					pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
+					if (pTmpScb == pCurHcb->HCS_LastBusy)
+						pCurHcb->HCS_LastBusy = pPrevScb;
+				}
+				pTmpScb->SCB_NxtScb = NULL;
+
+
+				pTmpScb->SCB_HaStat = HOST_ABORTED;
+				pTmpScb->SCB_Flags |= SCF_DONE;
+				if (pTmpScb->SCB_Flags & SCF_POST)
+					(*pTmpScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pTmpScb);
+				spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+				return SCSI_ABORT_SUCCESS;
+			}
+		}
+		pPrevScb = pTmpScb;
+		pTmpScb = pTmpScb->SCB_NxtScb;
+	}
+	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+	return (SCSI_ABORT_NOT_RUNNING);
+}
+
+/***************************************************************************/
+int tul_bad_seq(HCS * pCurHcb)
+{
+	SCB *pCurScb;
+
+	printk("tul_bad_seg c=%d\n", pCurHcb->HCS_Index);
+
+	if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) {
+		tul_unlink_busy_scb(pCurHcb, pCurScb);
+		pCurScb->SCB_HaStat = HOST_BAD_PHAS;
+		pCurScb->SCB_TaStat = 0;
+		tul_append_done_scb(pCurHcb, pCurScb);
+	}
+	tul_stop_bm(pCurHcb);
+
+	tul_reset_scsi(pCurHcb, 8);	/* 7/29/98 */
+
+	return (tul_post_scsi_rst(pCurHcb));
+}
+
+/************************************************************************/
+int tul_device_reset(HCS * pCurHcb, struct scsi_cmnd *pSrb,
+		unsigned int target, unsigned int ResetFlags)
+{
+	ULONG flags;
+	SCB *pScb;
+	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+
+	if (ResetFlags & SCSI_RESET_ASYNCHRONOUS) {
+
+		if ((pCurHcb->HCS_Semaph == 0) && (pCurHcb->HCS_ActScb == NULL)) {
+			TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
+			/* disable Jasmin SCSI Int        */
+
+        		spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+
+			tulip_main(pCurHcb);
+
+        		spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+
+			pCurHcb->HCS_Semaph = 1;
+			TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
+
+			spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+
+			return SCSI_RESET_SNOOZE;
+		}
+		pScb = pCurHcb->HCS_FirstBusy;	/* Check Busy queue */
+		while (pScb != NULL) {
+			if (pScb->SCB_Srb == pSrb)
+				break;
+			pScb = pScb->SCB_NxtScb;
+		}
+		if (pScb == NULL) {
+			printk("Unable to Reset - No SCB Found\n");
+
+			spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+			return SCSI_RESET_NOT_RUNNING;
+		}
+	}
+	if ((pScb = tul_alloc_scb(pCurHcb)) == NULL) {
+		spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+		return SCSI_RESET_NOT_RUNNING;
+	}
+	pScb->SCB_Opcode = BusDevRst;
+	pScb->SCB_Flags = SCF_POST;
+	pScb->SCB_Target = target;
+	pScb->SCB_Mode = 0;
+
+	pScb->SCB_Srb = NULL;
+	if (ResetFlags & SCSI_RESET_SYNCHRONOUS) {
+		pScb->SCB_Srb = pSrb;
+	}
+	tul_push_pend_scb(pCurHcb, pScb);	/* push this SCB to Pending queue */
+
+	if (pCurHcb->HCS_Semaph == 1) {
+		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
+		/* disable Jasmin SCSI Int        */
+		pCurHcb->HCS_Semaph = 0;
+
+        	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+
+		tulip_main(pCurHcb);
+
+                spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+
+		pCurHcb->HCS_Semaph = 1;
+		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
+	}
+	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+	return SCSI_RESET_PENDING;
+}
+
+int tul_reset_scsi_bus(HCS * pCurHcb)
+{
+	ULONG flags;
+
+	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+	TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
+	pCurHcb->HCS_Semaph = 0;
+
+	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+
+	tul_stop_bm(pCurHcb);
+
+	tul_reset_scsi(pCurHcb, 2);	/* 7/29/98 */
+
+	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+	tul_post_scsi_rst(pCurHcb);
+
+        spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+
+	tulip_main(pCurHcb);
+
+        spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+
+	pCurHcb->HCS_Semaph = 1;
+	TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
+	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+	return (SCSI_RESET_SUCCESS | SCSI_RESET_HOST_RESET);
+}
+
+/************************************************************************/
+void tul_exec_scb(HCS * pCurHcb, SCB * pCurScb)
+{
+	ULONG flags;
+
+	pCurScb->SCB_Mode = 0;
+
+	pCurScb->SCB_SGIdx = 0;
+	pCurScb->SCB_SGMax = pCurScb->SCB_SGLen;
+
+	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+
+	tul_append_pend_scb(pCurHcb, pCurScb);	/* Append this SCB to Pending queue */
+
+/* VVVVV 07/21/98 */
+	if (pCurHcb->HCS_Semaph == 1) {
+		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
+		/* disable Jasmin SCSI Int        */
+		pCurHcb->HCS_Semaph = 0;
+
+        	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+
+		tulip_main(pCurHcb);
+
+        	spin_lock_irqsave(&(pCurHcb->HCS_SemaphLock), flags);
+
+		pCurHcb->HCS_Semaph = 1;
+		TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
+	}
+	spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
+	return;
+}
+
+/***************************************************************************/
+int tul_isr(HCS * pCurHcb)
+{
+	/* Enter critical section       */
+
+	if (TUL_RD(pCurHcb->HCS_Base, TUL_Int) & TSS_INT_PENDING) {
+		if (pCurHcb->HCS_Semaph == 1) {
+			TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x1F);
+			/* Disable Tulip SCSI Int */
+			pCurHcb->HCS_Semaph = 0;
+
+			tulip_main(pCurHcb);
+
+			pCurHcb->HCS_Semaph = 1;
+			TUL_WR(pCurHcb->HCS_Base + TUL_Mask, 0x0F);
+			return (1);
+		}
+	}
+	return (0);
+}
+
+/***************************************************************************/
+int tulip_main(HCS * pCurHcb)
+{
+	SCB *pCurScb;
+
+	for (;;) {
+
+		tulip_scsi(pCurHcb);	/* Call tulip_scsi              */
+
+		while ((pCurScb = tul_find_done_scb(pCurHcb)) != NULL) {	/* find done entry */
+			if (pCurScb->SCB_TaStat == INI_QUEUE_FULL) {
+				pCurHcb->HCS_MaxTags[pCurScb->SCB_Target] =
+				    pCurHcb->HCS_ActTags[pCurScb->SCB_Target] - 1;
+				pCurScb->SCB_TaStat = 0;
+				tul_append_pend_scb(pCurHcb, pCurScb);
+				continue;
+			}
+			if (!(pCurScb->SCB_Mode & SCM_RSENS)) {		/* not in auto req. sense mode */
+				if (pCurScb->SCB_TaStat == 2) {
+
+					/* clr sync. nego flag */
+
+					if (pCurScb->SCB_Flags & SCF_SENSE) {
+						BYTE len;
+						len = pCurScb->SCB_SenseLen;
+						if (len == 0)
+							len = 1;
+						pCurScb->SCB_BufLen = pCurScb->SCB_SenseLen;
+						pCurScb->SCB_BufPtr = pCurScb->SCB_SensePtr;
+						pCurScb->SCB_Flags &= ~(SCF_SG | SCF_DIR);	/* for xfer_data_in */
+/*                      pCurScb->SCB_Flags |= SCF_NO_DCHK;      */
+						/* so, we won't report worng direction in xfer_data_in,
+						   and won't report HOST_DO_DU in state_6 */
+						pCurScb->SCB_Mode = SCM_RSENS;
+						pCurScb->SCB_Ident &= 0xBF;	/* Disable Disconnect */
+						pCurScb->SCB_TagMsg = 0;
+						pCurScb->SCB_TaStat = 0;
+						pCurScb->SCB_CDBLen = 6;
+						pCurScb->SCB_CDB[0] = SCSICMD_RequestSense;
+						pCurScb->SCB_CDB[1] = 0;
+						pCurScb->SCB_CDB[2] = 0;
+						pCurScb->SCB_CDB[3] = 0;
+						pCurScb->SCB_CDB[4] = len;
+						pCurScb->SCB_CDB[5] = 0;
+						tul_push_pend_scb(pCurHcb, pCurScb);
+						break;
+					}
+				}
+			} else {	/* in request sense mode */
+
+				if (pCurScb->SCB_TaStat == 2) {		/* check contition status again after sending
+									   requset sense cmd 0x3 */
+					pCurScb->SCB_HaStat = HOST_BAD_PHAS;
+				}
+				pCurScb->SCB_TaStat = 2;
+			}
+			pCurScb->SCB_Flags |= SCF_DONE;
+			if (pCurScb->SCB_Flags & SCF_POST) {
+				(*pCurScb->SCB_Post) ((BYTE *) pCurHcb, (BYTE *) pCurScb);
+			}
+		}		/* while */
+
+		/* find_active: */
+		if (TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0) & TSS_INT_PENDING)
+			continue;
+
+		if (pCurHcb->HCS_ActScb) {	/* return to OS and wait for xfer_done_ISR/Selected_ISR */
+			return 1;	/* return to OS, enable interrupt */
+		}
+		/* Check pending SCB            */
+		if (tul_find_first_pend_scb(pCurHcb) == NULL) {
+			return 1;	/* return to OS, enable interrupt */
+		}
+	}			/* End of for loop */
+	/* statement won't reach here */
+}
+
+
+
+
+/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+/***************************************************************************/
+/***************************************************************************/
+/***************************************************************************/
+/***************************************************************************/
+
+/***************************************************************************/
+void tulip_scsi(HCS * pCurHcb)
+{
+	SCB *pCurScb;
+	TCS *pCurTcb;
+
+	/* make sure to service interrupt asap */
+
+	if ((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0)) & TSS_INT_PENDING) {
+
+		pCurHcb->HCS_Phase = pCurHcb->HCS_JSStatus0 & TSS_PH_MASK;
+		pCurHcb->HCS_JSStatus1 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1);
+		pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
+		if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) {	/* SCSI bus reset detected      */
+			int_tul_scsi_rst(pCurHcb);
+			return;
+		}
+		if (pCurHcb->HCS_JSInt & TSS_RESEL_INT) {	/* if selected/reselected interrupt */
+			if (int_tul_resel(pCurHcb) == 0)
+				tul_next_state(pCurHcb);
+			return;
+		}
+		if (pCurHcb->HCS_JSInt & TSS_SEL_TIMEOUT) {
+			int_tul_busfree(pCurHcb);
+			return;
+		}
+		if (pCurHcb->HCS_JSInt & TSS_DISC_INT) {	/* BUS disconnection            */
+			int_tul_busfree(pCurHcb);	/* unexpected bus free or sel timeout */
+			return;
+		}
+		if (pCurHcb->HCS_JSInt & (TSS_FUNC_COMP | TSS_BUS_SERV)) {	/* func complete or Bus service */
+			if ((pCurScb = pCurHcb->HCS_ActScb) != NULL)
+				tul_next_state(pCurHcb);
+			return;
+		}
+	}
+	if (pCurHcb->HCS_ActScb != NULL)
+		return;
+
+	if ((pCurScb = tul_find_first_pend_scb(pCurHcb)) == NULL)
+		return;
+
+	/* program HBA's SCSI ID & target SCSI ID */
+	TUL_WR(pCurHcb->HCS_Base + TUL_SScsiId,
+	     (pCurHcb->HCS_SCSI_ID << 4) | (pCurScb->SCB_Target & 0x0F));
+	if (pCurScb->SCB_Opcode == ExecSCSI) {
+		pCurTcb = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target];
+
+		if (pCurScb->SCB_TagMsg)
+			pCurTcb->TCS_DrvFlags |= TCF_DRV_EN_TAG;
+		else
+			pCurTcb->TCS_DrvFlags &= ~TCF_DRV_EN_TAG;
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurTcb->TCS_JS_Period);
+		if ((pCurTcb->TCS_Flags & (TCF_WDTR_DONE | TCF_NO_WDTR)) == 0) {	/* do wdtr negotiation          */
+			tul_select_atn_stop(pCurHcb, pCurScb);
+		} else {
+			if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) {	/* do sync negotiation          */
+				tul_select_atn_stop(pCurHcb, pCurScb);
+			} else {
+				if (pCurScb->SCB_TagMsg)
+					tul_select_atn3(pCurHcb, pCurScb);
+				else
+					tul_select_atn(pCurHcb, pCurScb);
+			}
+		}
+		if (pCurScb->SCB_Flags & SCF_POLL) {
+			while (wait_tulip(pCurHcb) != -1) {
+				if (tul_next_state(pCurHcb) == -1)
+					break;
+			}
+		}
+	} else if (pCurScb->SCB_Opcode == BusDevRst) {
+		tul_select_atn_stop(pCurHcb, pCurScb);
+		pCurScb->SCB_NxtStat = 8;
+		if (pCurScb->SCB_Flags & SCF_POLL) {
+			while (wait_tulip(pCurHcb) != -1) {
+				if (tul_next_state(pCurHcb) == -1)
+					break;
+			}
+		}
+	} else if (pCurScb->SCB_Opcode == AbortCmd) {
+		if (tul_abort_srb(pCurHcb, pCurScb->SCB_Srb) != 0) {
+
+
+			tul_unlink_pend_scb(pCurHcb, pCurScb);
+
+			tul_release_scb(pCurHcb, pCurScb);
+		} else {
+			pCurScb->SCB_Opcode = BusDevRst;
+			tul_select_atn_stop(pCurHcb, pCurScb);
+			pCurScb->SCB_NxtStat = 8;
+		}
+
+/* 08/03/98 */
+	} else {
+		tul_unlink_pend_scb(pCurHcb, pCurScb);
+		pCurScb->SCB_HaStat = 0x16;	/* bad command */
+		tul_append_done_scb(pCurHcb, pCurScb);
+	}
+	return;
+}
+
+
+/***************************************************************************/
+int tul_next_state(HCS * pCurHcb)
+{
+	int next;
+
+	next = pCurHcb->HCS_ActScb->SCB_NxtStat;
+	for (;;) {
+		switch (next) {
+		case 1:
+			next = tul_state_1(pCurHcb);
+			break;
+		case 2:
+			next = tul_state_2(pCurHcb);
+			break;
+		case 3:
+			next = tul_state_3(pCurHcb);
+			break;
+		case 4:
+			next = tul_state_4(pCurHcb);
+			break;
+		case 5:
+			next = tul_state_5(pCurHcb);
+			break;
+		case 6:
+			next = tul_state_6(pCurHcb);
+			break;
+		case 7:
+			next = tul_state_7(pCurHcb);
+			break;
+		case 8:
+			return (tul_bus_device_reset(pCurHcb));
+		default:
+			return (tul_bad_seq(pCurHcb));
+		}
+		if (next <= 0)
+			return next;
+	}
+}
+
+
+/***************************************************************************/
+/* sTate after selection with attention & stop */
+int tul_state_1(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
+#if DEBUG_STATE
+	printk("-s1-");
+#endif
+
+	tul_unlink_pend_scb(pCurHcb, pCurScb);
+	tul_append_busy_scb(pCurHcb, pCurScb);
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0);
+	/* ATN on */
+	if (pCurHcb->HCS_Phase == MSG_OUT) {
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, (TSC_EN_BUS_IN | TSC_HW_RESELECT));
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident);
+
+		if (pCurScb->SCB_TagMsg) {
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagMsg);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagId);
+		}
+		if ((pCurTcb->TCS_Flags & (TCF_WDTR_DONE | TCF_NO_WDTR)) == 0) {
+
+			pCurTcb->TCS_Flags |= TCF_WDTR_DONE;
+
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 2);	/* Extended msg length */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);	/* Sync request */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1);	/* Start from 16 bits */
+		} else if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) {
+
+			pCurTcb->TCS_Flags |= TCF_SYNC_DONE;
+
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);	/* extended msg length */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1);	/* sync request */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, tul_rate_tbl[pCurTcb->TCS_Flags & TCF_SCSI_RATE]);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MAX_OFFSET);	/* REQ/ACK offset */
+		}
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+		if (wait_tulip(pCurHcb) == -1)
+			return (-1);
+	}
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)));
+	return (3);
+}
+
+
+/***************************************************************************/
+/* state after selection with attention */
+/* state after selection with attention3 */
+int tul_state_2(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
+#if DEBUG_STATE
+	printk("-s2-");
+#endif
+
+	tul_unlink_pend_scb(pCurHcb, pCurScb);
+	tul_append_busy_scb(pCurHcb, pCurScb);
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0);
+
+	if (pCurHcb->HCS_JSStatus1 & TSS_CMD_PH_CMP) {
+		return (4);
+	}
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)));
+	return (3);
+}
+
+/***************************************************************************/
+/* state before CDB xfer is done */
+int tul_state_3(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
+	int i;
+
+#if DEBUG_STATE
+	printk("-s3-");
+#endif
+	for (;;) {
+		switch (pCurHcb->HCS_Phase) {
+		case CMD_OUT:	/* Command out phase            */
+			for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++)
+				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+			if (wait_tulip(pCurHcb) == -1)
+				return (-1);
+			if (pCurHcb->HCS_Phase == CMD_OUT) {
+				return (tul_bad_seq(pCurHcb));
+			}
+			return (4);
+
+		case MSG_IN:	/* Message in phase             */
+			pCurScb->SCB_NxtStat = 3;
+			if (tul_msgin(pCurHcb) == -1)
+				return (-1);
+			break;
+
+		case STATUS_IN:	/* Status phase                 */
+			if (tul_status_msg(pCurHcb) == -1)
+				return (-1);
+			break;
+
+		case MSG_OUT:	/* Message out phase            */
+			if (pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) {
+
+				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP);		/* msg nop */
+				TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+				if (wait_tulip(pCurHcb) == -1)
+					return (-1);
+
+			} else {
+				pCurTcb->TCS_Flags |= TCF_SYNC_DONE;
+
+				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
+				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);	/* ext. msg len */
+				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1);	/* sync request */
+				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, tul_rate_tbl[pCurTcb->TCS_Flags & TCF_SCSI_RATE]);
+				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MAX_OFFSET);	/* REQ/ACK offset */
+				TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+				if (wait_tulip(pCurHcb) == -1)
+					return (-1);
+				TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+				TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7));
+
+			}
+			break;
+
+		default:
+			return (tul_bad_seq(pCurHcb));
+		}
+	}
+}
+
+
+/***************************************************************************/
+int tul_state_4(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+
+#if DEBUG_STATE
+	printk("-s4-");
+#endif
+	if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_NO_XF) {
+		return (6);	/* Go to state 6                */
+	}
+	for (;;) {
+		if (pCurScb->SCB_BufLen == 0)
+			return (6);	/* Go to state 6                */
+
+		switch (pCurHcb->HCS_Phase) {
+
+		case STATUS_IN:	/* Status phase                 */
+			if ((pCurScb->SCB_Flags & SCF_DIR) != 0) {	/* if direction bit set then report data underrun */
+				pCurScb->SCB_HaStat = HOST_DO_DU;
+			}
+			if ((tul_status_msg(pCurHcb)) == -1)
+				return (-1);
+			break;
+
+		case MSG_IN:	/* Message in phase             */
+			pCurScb->SCB_NxtStat = 0x4;
+			if (tul_msgin(pCurHcb) == -1)
+				return (-1);
+			break;
+
+		case MSG_OUT:	/* Message out phase            */
+			if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) {
+				pCurScb->SCB_BufLen = 0;
+				pCurScb->SCB_HaStat = HOST_DO_DU;
+				if (tul_msgout_ide(pCurHcb) == -1)
+					return (-1);
+				return (6);	/* Go to state 6                */
+			} else {
+				TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP);		/* msg nop */
+				TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+				if (wait_tulip(pCurHcb) == -1)
+					return (-1);
+			}
+			break;
+
+		case DATA_IN:	/* Data in phase                */
+			return (tul_xfer_data_in(pCurHcb));
+
+		case DATA_OUT:	/* Data out phase               */
+			return (tul_xfer_data_out(pCurHcb));
+
+		default:
+			return (tul_bad_seq(pCurHcb));
+		}
+	}
+}
+
+
+/***************************************************************************/
+/* state after dma xfer done or phase change before xfer done */
+int tul_state_5(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+	long cnt, xcnt;		/* cannot use unsigned !! code: if (xcnt < 0) */
+
+#if DEBUG_STATE
+	printk("-s5-");
+#endif
+/*------ get remaining count -------*/
+
+	cnt = TUL_RDLONG(pCurHcb->HCS_Base, TUL_SCnt0) & 0x0FFFFFF;
+
+	if (TUL_RD(pCurHcb->HCS_Base, TUL_XCmd) & 0x20) {
+		/* ----------------------- DATA_IN ----------------------------- */
+		/* check scsi parity error */
+		if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) {
+			pCurScb->SCB_HaStat = HOST_DO_DU;
+		}
+		if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) {	/* DMA xfer pending, Send STOP  */
+			/* tell Hardware  scsi xfer has been terminated */
+			TUL_WR(pCurHcb->HCS_Base + TUL_XCtrl, TUL_RD(pCurHcb->HCS_Base, TUL_XCtrl) | 0x80);
+			/* wait until DMA xfer not pending */
+			while (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND);
+		}
+	} else {
+/*-------- DATA OUT -----------*/
+		if ((TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1) & TSS_XFER_CMP) == 0) {
+			if (pCurHcb->HCS_ActTcs->TCS_JS_Period & TSC_WIDE_SCSI)
+				cnt += (TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F) << 1;
+			else
+				cnt += (TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F);
+		}
+		if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & XPEND) {	/* if DMA xfer is pending, abort DMA xfer */
+			TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT);
+			/* wait Abort DMA xfer done */
+			while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & XABT) == 0);
+		}
+		if ((cnt == 1) && (pCurHcb->HCS_Phase == DATA_OUT)) {
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+			if (wait_tulip(pCurHcb) == -1) {
+				return (-1);
+			}
+			cnt = 0;
+		} else {
+			if ((TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1) & TSS_XFER_CMP) == 0)
+				TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+		}
+	}
+
+	if (cnt == 0) {
+		pCurScb->SCB_BufLen = 0;
+		return (6);	/* Go to state 6                */
+	}
+	/* Update active data pointer */
+	xcnt = (long) pCurScb->SCB_BufLen - cnt;	/* xcnt== bytes already xferred */
+	pCurScb->SCB_BufLen = (U32) cnt;	/* cnt == bytes left to be xferred */
+	if (pCurScb->SCB_Flags & SCF_SG) {
+		register SG *sgp;
+		ULONG i;
+
+		sgp = &pCurScb->SCB_SGList[pCurScb->SCB_SGIdx];
+		for (i = pCurScb->SCB_SGIdx; i < pCurScb->SCB_SGMax; sgp++, i++) {
+			xcnt -= (long) sgp->SG_Len;
+			if (xcnt < 0) {		/* this sgp xfer half done */
+				xcnt += (long) sgp->SG_Len;	/* xcnt == bytes xferred in this sgp */
+				sgp->SG_Ptr += (U32) xcnt;	/* new ptr to be xfer */
+				sgp->SG_Len -= (U32) xcnt;	/* new len to be xfer */
+				pCurScb->SCB_BufPtr += ((U32) (i - pCurScb->SCB_SGIdx) << 3);
+				/* new SG table ptr */
+				pCurScb->SCB_SGLen = (BYTE) (pCurScb->SCB_SGMax - i);
+				/* new SG table len */
+				pCurScb->SCB_SGIdx = (WORD) i;
+				/* for next disc and come in this loop */
+				return (4);	/* Go to state 4                */
+			}
+			/* else (xcnt >= 0 , i.e. this sgp already xferred */
+		}		/* for */
+		return (6);	/* Go to state 6                */
+	} else {
+		pCurScb->SCB_BufPtr += (U32) xcnt;
+	}
+	return (4);		/* Go to state 4                */
+}
+
+/***************************************************************************/
+/* state after Data phase */
+int tul_state_6(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+
+#if DEBUG_STATE
+	printk("-s6-");
+#endif
+	for (;;) {
+		switch (pCurHcb->HCS_Phase) {
+		case STATUS_IN:	/* Status phase                 */
+			if ((tul_status_msg(pCurHcb)) == -1)
+				return (-1);
+			break;
+
+		case MSG_IN:	/* Message in phase             */
+			pCurScb->SCB_NxtStat = 6;
+			if ((tul_msgin(pCurHcb)) == -1)
+				return (-1);
+			break;
+
+		case MSG_OUT:	/* Message out phase            */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP);		/* msg nop */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+			if (wait_tulip(pCurHcb) == -1)
+				return (-1);
+			break;
+
+		case DATA_IN:	/* Data in phase                */
+			return (tul_xpad_in(pCurHcb));
+
+		case DATA_OUT:	/* Data out phase               */
+			return (tul_xpad_out(pCurHcb));
+
+		default:
+			return (tul_bad_seq(pCurHcb));
+		}
+	}
+}
+
+/***************************************************************************/
+int tul_state_7(HCS * pCurHcb)
+{
+	int cnt, i;
+
+#if DEBUG_STATE
+	printk("-s7-");
+#endif
+	/* flush SCSI FIFO */
+	cnt = TUL_RD(pCurHcb->HCS_Base, TUL_SFifoCnt) & 0x1F;
+	if (cnt) {
+		for (i = 0; i < cnt; i++)
+			TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
+	}
+	switch (pCurHcb->HCS_Phase) {
+	case DATA_IN:		/* Data in phase                */
+	case DATA_OUT:		/* Data out phase               */
+		return (tul_bad_seq(pCurHcb));
+	default:
+		return (6);	/* Go to state 6                */
+	}
+}
+
+/***************************************************************************/
+int tul_xfer_data_in(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+
+	if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_DOUT) {
+		return (6);	/* wrong direction */
+	}
+	TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, pCurScb->SCB_BufLen);
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_DMA_IN);	/* 7/25/95 */
+
+	if (pCurScb->SCB_Flags & SCF_SG) {	/* S/G xfer */
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, ((ULONG) pCurScb->SCB_SGLen) << 3);
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr);
+		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_SG_IN);
+	} else {
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, pCurScb->SCB_BufLen);
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr);
+		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_IN);
+	}
+	pCurScb->SCB_NxtStat = 0x5;
+	return (0);		/* return to OS, wait xfer done , let jas_isr come in */
+}
+
+
+/***************************************************************************/
+int tul_xfer_data_out(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+
+	if ((pCurScb->SCB_Flags & SCF_DIR) == SCF_DIN) {
+		return (6);	/* wrong direction */
+	}
+	TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, pCurScb->SCB_BufLen);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_DMA_OUT);
+
+	if (pCurScb->SCB_Flags & SCF_SG) {	/* S/G xfer */
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, ((ULONG) pCurScb->SCB_SGLen) << 3);
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr);
+		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_SG_OUT);
+	} else {
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XCntH, pCurScb->SCB_BufLen);
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_XAddH, pCurScb->SCB_BufPtr);
+		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_OUT);
+	}
+
+	pCurScb->SCB_NxtStat = 0x5;
+	return (0);		/* return to OS, wait xfer done , let jas_isr come in */
+}
+
+
+/***************************************************************************/
+int tul_xpad_in(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
+
+	if ((pCurScb->SCB_Flags & SCF_DIR) != SCF_NO_DCHK) {
+		pCurScb->SCB_HaStat = HOST_DO_DU;	/* over run             */
+	}
+	for (;;) {
+		if (pCurTcb->TCS_JS_Period & TSC_WIDE_SCSI)
+			TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 2);
+		else
+			TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
+		if ((wait_tulip(pCurHcb)) == -1) {
+			return (-1);
+		}
+		if (pCurHcb->HCS_Phase != DATA_IN) {
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+			return (6);
+		}
+		TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
+	}
+}
+
+int tul_xpad_out(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
+
+	if ((pCurScb->SCB_Flags & SCF_DIR) != SCF_NO_DCHK) {
+		pCurScb->SCB_HaStat = HOST_DO_DU;	/* over run             */
+	}
+	for (;;) {
+		if (pCurTcb->TCS_JS_Period & TSC_WIDE_SCSI)
+			TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 2);
+		else
+			TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 0);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+		if ((wait_tulip(pCurHcb)) == -1) {
+			return (-1);
+		}
+		if (pCurHcb->HCS_Phase != DATA_OUT) {	/* Disable wide CPU to allow read 16 bits */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+			return (6);
+		}
+	}
+}
+
+
+/***************************************************************************/
+int tul_status_msg(HCS * pCurHcb)
+{				/* status & MSG_IN */
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+	BYTE msg;
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_CMD_COMP);
+	if ((wait_tulip(pCurHcb)) == -1) {
+		return (-1);
+	}
+	/* get status */
+	pCurScb->SCB_TaStat = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
+
+	if (pCurHcb->HCS_Phase == MSG_OUT) {
+		if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) {
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_PARITY);
+		} else {
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_NOP);
+		}
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+		return (wait_tulip(pCurHcb));
+	}
+	if (pCurHcb->HCS_Phase == MSG_IN) {
+		msg = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
+		if (pCurHcb->HCS_JSStatus0 & TSS_PAR_ERROR) {	/* Parity error                 */
+			if ((tul_msgin_accept(pCurHcb)) == -1)
+				return (-1);
+			if (pCurHcb->HCS_Phase != MSG_OUT)
+				return (tul_bad_seq(pCurHcb));
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_PARITY);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+			return (wait_tulip(pCurHcb));
+		}
+		if (msg == 0) {	/* Command complete             */
+
+			if ((pCurScb->SCB_TaStat & 0x18) == 0x10) {	/* No link support              */
+				return (tul_bad_seq(pCurHcb));
+			}
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT);
+			return tul_wait_done_disc(pCurHcb);
+
+		}
+		if ((msg == MSG_LINK_COMP) || (msg == MSG_LINK_FLAG)) {
+			if ((pCurScb->SCB_TaStat & 0x18) == 0x10)
+				return (tul_msgin_accept(pCurHcb));
+		}
+	}
+	return (tul_bad_seq(pCurHcb));
+}
+
+
+/***************************************************************************/
+/* scsi bus free */
+int int_tul_busfree(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+
+	if (pCurScb != NULL) {
+		if (pCurScb->SCB_Status & SCB_SELECT) {		/* selection timeout */
+			tul_unlink_pend_scb(pCurHcb, pCurScb);
+			pCurScb->SCB_HaStat = HOST_SEL_TOUT;
+			tul_append_done_scb(pCurHcb, pCurScb);
+		} else {	/* Unexpected bus free          */
+			tul_unlink_busy_scb(pCurHcb, pCurScb);
+			pCurScb->SCB_HaStat = HOST_BUS_FREE;
+			tul_append_done_scb(pCurHcb, pCurScb);
+		}
+		pCurHcb->HCS_ActScb = NULL;
+		pCurHcb->HCS_ActTcs = NULL;
+	}
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
+	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
+	return (-1);
+}
+
+
+/***************************************************************************/
+/* scsi bus reset */
+int int_tul_scsi_rst(HCS * pCurHcb)
+{
+	SCB *pCurScb;
+	int i;
+
+	/* if DMA xfer is pending, abort DMA xfer */
+	if (TUL_RD(pCurHcb->HCS_Base, TUL_XStatus) & 0x01) {
+		TUL_WR(pCurHcb->HCS_Base + TUL_XCmd, TAX_X_ABT | TAX_X_CLR_FIFO);
+		/* wait Abort DMA xfer done */
+		while ((TUL_RD(pCurHcb->HCS_Base, TUL_Int) & 0x04) == 0);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+	}
+	/* Abort all active & disconnected scb */
+	while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) {
+		pCurScb->SCB_HaStat = HOST_BAD_PHAS;
+		tul_append_done_scb(pCurHcb, pCurScb);
+	}
+	pCurHcb->HCS_ActScb = NULL;
+	pCurHcb->HCS_ActTcs = NULL;
+
+	/* clr sync nego. done flag */
+	for (i = 0; i < pCurHcb->HCS_MaxTar; i++) {
+		pCurHcb->HCS_Tcs[i].TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
+	}
+	return (-1);
+}
+
+
+/***************************************************************************/
+/* scsi reselection */
+int int_tul_resel(HCS * pCurHcb)
+{
+	SCB *pCurScb;
+	TCS *pCurTcb;
+	BYTE tag, msg = 0;
+	BYTE tar, lun;
+
+	if ((pCurScb = pCurHcb->HCS_ActScb) != NULL) {
+		if (pCurScb->SCB_Status & SCB_SELECT) {		/* if waiting for selection complete */
+			pCurScb->SCB_Status &= ~SCB_SELECT;
+		}
+		pCurHcb->HCS_ActScb = NULL;
+	}
+	/* --------- get target id---------------------- */
+	tar = TUL_RD(pCurHcb->HCS_Base, TUL_SBusId);
+	/* ------ get LUN from Identify message----------- */
+	lun = TUL_RD(pCurHcb->HCS_Base, TUL_SIdent) & 0x0F;
+	/* 07/22/98 from 0x1F -> 0x0F */
+	pCurTcb = &pCurHcb->HCS_Tcs[tar];
+	pCurHcb->HCS_ActTcs = pCurTcb;
+	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurTcb->TCS_SConfig0);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurTcb->TCS_JS_Period);
+
+
+	/* ------------- tag queueing ? ------------------- */
+	if (pCurTcb->TCS_DrvFlags & TCF_DRV_EN_TAG) {
+		if ((tul_msgin_accept(pCurHcb)) == -1)
+			return (-1);
+		if (pCurHcb->HCS_Phase != MSG_IN)
+			goto no_tag;
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
+		if ((wait_tulip(pCurHcb)) == -1)
+			return (-1);
+		msg = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);	/* Read Tag Message    */
+
+		if ((msg < MSG_STAG) || (msg > MSG_OTAG))	/* Is simple Tag      */
+			goto no_tag;
+
+		if ((tul_msgin_accept(pCurHcb)) == -1)
+			return (-1);
+
+		if (pCurHcb->HCS_Phase != MSG_IN)
+			goto no_tag;
+
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
+		if ((wait_tulip(pCurHcb)) == -1)
+			return (-1);
+		tag = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);	/* Read Tag ID       */
+		pCurScb = pCurHcb->HCS_Scb + tag;
+		if ((pCurScb->SCB_Target != tar) || (pCurScb->SCB_Lun != lun)) {
+			return tul_msgout_abort_tag(pCurHcb);
+		}
+		if (pCurScb->SCB_Status != SCB_BUSY) {	/* 03/24/95             */
+			return tul_msgout_abort_tag(pCurHcb);
+		}
+		pCurHcb->HCS_ActScb = pCurScb;
+		if ((tul_msgin_accept(pCurHcb)) == -1)
+			return (-1);
+	} else {		/* No tag               */
+	      no_tag:
+		if ((pCurScb = tul_find_busy_scb(pCurHcb, tar | (lun << 8))) == NULL) {
+			return tul_msgout_abort_targ(pCurHcb);
+		}
+		pCurHcb->HCS_ActScb = pCurScb;
+		if (!(pCurTcb->TCS_DrvFlags & TCF_DRV_EN_TAG)) {
+			if ((tul_msgin_accept(pCurHcb)) == -1)
+				return (-1);
+		}
+	}
+	return 0;
+}
+
+
+/***************************************************************************/
+int int_tul_bad_seq(HCS * pCurHcb)
+{				/* target wrong phase           */
+	SCB *pCurScb;
+	int i;
+
+	tul_reset_scsi(pCurHcb, 10);
+
+	while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) {
+		pCurScb->SCB_HaStat = HOST_BAD_PHAS;
+		tul_append_done_scb(pCurHcb, pCurScb);
+	}
+	for (i = 0; i < pCurHcb->HCS_MaxTar; i++) {
+		pCurHcb->HCS_Tcs[i].TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
+	}
+	return (-1);
+}
+
+
+/***************************************************************************/
+int tul_msgout_abort_targ(HCS * pCurHcb)
+{
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
+	if (tul_msgin_accept(pCurHcb) == -1)
+		return (-1);
+	if (pCurHcb->HCS_Phase != MSG_OUT)
+		return (tul_bad_seq(pCurHcb));
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_ABORT);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+
+	return tul_wait_disc(pCurHcb);
+}
+
+/***************************************************************************/
+int tul_msgout_abort_tag(HCS * pCurHcb)
+{
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
+	if (tul_msgin_accept(pCurHcb) == -1)
+		return (-1);
+	if (pCurHcb->HCS_Phase != MSG_OUT)
+		return (tul_bad_seq(pCurHcb));
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_ABORT_TAG);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+
+	return tul_wait_disc(pCurHcb);
+
+}
+
+/***************************************************************************/
+int tul_msgin(HCS * pCurHcb)
+{
+	TCS *pCurTcb;
+
+	for (;;) {
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
+		if ((wait_tulip(pCurHcb)) == -1)
+			return (-1);
+
+		switch (TUL_RD(pCurHcb->HCS_Base, TUL_SFifo)) {
+		case MSG_DISC:	/* Disconnect msg */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT);
+
+			return tul_wait_disc(pCurHcb);
+
+		case MSG_SDP:
+		case MSG_RESTORE:
+		case MSG_NOP:
+			tul_msgin_accept(pCurHcb);
+			break;
+
+		case MSG_REJ:	/* Clear ATN first              */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SSignal,
+			       (TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)));
+			pCurTcb = pCurHcb->HCS_ActTcs;
+			if ((pCurTcb->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) {	/* do sync nego */
+				TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
+			}
+			tul_msgin_accept(pCurHcb);
+			break;
+
+		case MSG_EXTEND:	/* extended msg */
+			tul_msgin_extend(pCurHcb);
+			break;
+
+		case MSG_IGNOREWIDE:
+			tul_msgin_accept(pCurHcb);
+			break;
+
+			/* get */
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
+			if (wait_tulip(pCurHcb) == -1)
+				return -1;
+
+			TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 0);	/* put pad  */
+			TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);	/* get IGNORE field */
+			TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);	/* get pad */
+
+			tul_msgin_accept(pCurHcb);
+			break;
+
+		case MSG_COMP:
+			{
+				TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+				TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT);
+				return tul_wait_done_disc(pCurHcb);
+			}
+		default:
+			tul_msgout_reject(pCurHcb);
+			break;
+		}
+		if (pCurHcb->HCS_Phase != MSG_IN)
+			return (pCurHcb->HCS_Phase);
+	}
+	/* statement won't reach here */
+}
+
+
+
+
+/***************************************************************************/
+int tul_msgout_reject(HCS * pCurHcb)
+{
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
+
+	if ((tul_msgin_accept(pCurHcb)) == -1)
+		return (-1);
+
+	if (pCurHcb->HCS_Phase == MSG_OUT) {
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_REJ);		/* Msg reject           */
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+		return (wait_tulip(pCurHcb));
+	}
+	return (pCurHcb->HCS_Phase);
+}
+
+
+
+/***************************************************************************/
+int tul_msgout_ide(HCS * pCurHcb)
+{
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_IDE);		/* Initiator Detected Error */
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+	return (wait_tulip(pCurHcb));
+}
+
+
+/***************************************************************************/
+int tul_msgin_extend(HCS * pCurHcb)
+{
+	BYTE len, idx;
+
+	if (tul_msgin_accept(pCurHcb) != MSG_IN)
+		return (pCurHcb->HCS_Phase);
+
+	/* Get extended msg length      */
+	TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
+	if (wait_tulip(pCurHcb) == -1)
+		return (-1);
+
+	len = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
+	pCurHcb->HCS_Msg[0] = len;
+	for (idx = 1; len != 0; len--) {
+
+		if ((tul_msgin_accept(pCurHcb)) != MSG_IN)
+			return (pCurHcb->HCS_Phase);
+		TUL_WRLONG(pCurHcb->HCS_Base + TUL_SCnt0, 1);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_IN);
+		if (wait_tulip(pCurHcb) == -1)
+			return (-1);
+		pCurHcb->HCS_Msg[idx++] = TUL_RD(pCurHcb->HCS_Base, TUL_SFifo);
+	}
+	if (pCurHcb->HCS_Msg[1] == 1) {		/* if it's synchronous data transfer request */
+		if (pCurHcb->HCS_Msg[0] != 3)	/* if length is not right */
+			return (tul_msgout_reject(pCurHcb));
+		if (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_SYNC_NEGO) {	/* Set OFFSET=0 to do async, nego back */
+			pCurHcb->HCS_Msg[3] = 0;
+		} else {
+			if ((tul_msgin_sync(pCurHcb) == 0) &&
+			    (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_SYNC_DONE)) {
+				tul_sync_done(pCurHcb);
+				return (tul_msgin_accept(pCurHcb));
+			}
+		}
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
+		if ((tul_msgin_accept(pCurHcb)) != MSG_OUT)
+			return (pCurHcb->HCS_Phase);
+		/* sync msg out */
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);
+
+		tul_sync_done(pCurHcb);
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 1);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[2]);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[3]);
+
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+		return (wait_tulip(pCurHcb));
+	}
+	if ((pCurHcb->HCS_Msg[0] != 2) || (pCurHcb->HCS_Msg[1] != 3))
+		return (tul_msgout_reject(pCurHcb));
+	/* if it's WIDE DATA XFER REQ   */
+	if (pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_WDTR) {
+		pCurHcb->HCS_Msg[2] = 0;
+	} else {
+		if (pCurHcb->HCS_Msg[2] > 2)	/* > 32 bits            */
+			return (tul_msgout_reject(pCurHcb));
+		if (pCurHcb->HCS_Msg[2] == 2) {		/* == 32                */
+			pCurHcb->HCS_Msg[2] = 1;
+		} else {
+			if ((pCurHcb->HCS_ActTcs->TCS_Flags & TCF_NO_WDTR) == 0) {
+				wdtr_done(pCurHcb);
+				if ((pCurHcb->HCS_ActTcs->TCS_Flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0)
+					TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
+				return (tul_msgin_accept(pCurHcb));
+			}
+		}
+	}
+	TUL_WR(pCurHcb->HCS_Base + TUL_SSignal, ((TUL_RD(pCurHcb->HCS_Base, TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN));
+
+	if (tul_msgin_accept(pCurHcb) != MSG_OUT)
+		return (pCurHcb->HCS_Phase);
+	/* WDTR msg out                 */
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_EXTEND);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 2);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, 3);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurHcb->HCS_Msg[2]);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+	return (wait_tulip(pCurHcb));
+}
+
+/***************************************************************************/
+int tul_msgin_sync(HCS * pCurHcb)
+{
+	char default_period;
+
+	default_period = tul_rate_tbl[pCurHcb->HCS_ActTcs->TCS_Flags & TCF_SCSI_RATE];
+	if (pCurHcb->HCS_Msg[3] > MAX_OFFSET) {
+		pCurHcb->HCS_Msg[3] = MAX_OFFSET;
+		if (pCurHcb->HCS_Msg[2] < default_period) {
+			pCurHcb->HCS_Msg[2] = default_period;
+			return 1;
+		}
+		if (pCurHcb->HCS_Msg[2] >= 59) {	/* Change to async              */
+			pCurHcb->HCS_Msg[3] = 0;
+		}
+		return 1;
+	}
+	/* offset requests asynchronous transfers ? */
+	if (pCurHcb->HCS_Msg[3] == 0) {
+		return 0;
+	}
+	if (pCurHcb->HCS_Msg[2] < default_period) {
+		pCurHcb->HCS_Msg[2] = default_period;
+		return 1;
+	}
+	if (pCurHcb->HCS_Msg[2] >= 59) {
+		pCurHcb->HCS_Msg[3] = 0;
+		return 1;
+	}
+	return 0;
+}
+
+
+/***************************************************************************/
+int wdtr_done(HCS * pCurHcb)
+{
+	pCurHcb->HCS_ActTcs->TCS_Flags &= ~TCF_SYNC_DONE;
+	pCurHcb->HCS_ActTcs->TCS_Flags |= TCF_WDTR_DONE;
+
+	pCurHcb->HCS_ActTcs->TCS_JS_Period = 0;
+	if (pCurHcb->HCS_Msg[2]) {	/* if 16 bit */
+		pCurHcb->HCS_ActTcs->TCS_JS_Period |= TSC_WIDE_SCSI;
+	}
+	pCurHcb->HCS_ActTcs->TCS_SConfig0 &= ~TSC_ALT_PERIOD;
+	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_ActTcs->TCS_SConfig0);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurHcb->HCS_ActTcs->TCS_JS_Period);
+
+	return 1;
+}
+
+/***************************************************************************/
+int tul_sync_done(HCS * pCurHcb)
+{
+	int i;
+
+	pCurHcb->HCS_ActTcs->TCS_Flags |= TCF_SYNC_DONE;
+
+	if (pCurHcb->HCS_Msg[3]) {
+		pCurHcb->HCS_ActTcs->TCS_JS_Period |= pCurHcb->HCS_Msg[3];
+		for (i = 0; i < 8; i++) {
+			if (tul_rate_tbl[i] >= pCurHcb->HCS_Msg[2])	/* pick the big one */
+				break;
+		}
+		pCurHcb->HCS_ActTcs->TCS_JS_Period |= (i << 4);
+		pCurHcb->HCS_ActTcs->TCS_SConfig0 |= TSC_ALT_PERIOD;
+	}
+	TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, pCurHcb->HCS_ActTcs->TCS_SConfig0);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SPeriod, pCurHcb->HCS_ActTcs->TCS_JS_Period);
+
+	return (-1);
+}
+
+
+int tul_post_scsi_rst(HCS * pCurHcb)
+{
+	SCB *pCurScb;
+	TCS *pCurTcb;
+	int i;
+
+	pCurHcb->HCS_ActScb = NULL;
+	pCurHcb->HCS_ActTcs = NULL;
+	pCurHcb->HCS_Flags = 0;
+
+	while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) {
+		pCurScb->SCB_HaStat = HOST_BAD_PHAS;
+		tul_append_done_scb(pCurHcb, pCurScb);
+	}
+	/* clear sync done flag         */
+	pCurTcb = &pCurHcb->HCS_Tcs[0];
+	for (i = 0; i < pCurHcb->HCS_MaxTar; pCurTcb++, i++) {
+		pCurTcb->TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
+		/* Initialize the sync. xfer register values to an asyn xfer */
+		pCurTcb->TCS_JS_Period = 0;
+		pCurTcb->TCS_SConfig0 = pCurHcb->HCS_SConf1;
+		pCurHcb->HCS_ActTags[0] = 0;	/* 07/22/98 */
+		pCurHcb->HCS_Tcs[i].TCS_Flags &= ~TCF_BUSY;	/* 07/22/98 */
+	}			/* for */
+
+	return (-1);
+}
+
+/***************************************************************************/
+void tul_select_atn_stop(HCS * pCurHcb, SCB * pCurScb)
+{
+	pCurScb->SCB_Status |= SCB_SELECT;
+	pCurScb->SCB_NxtStat = 0x1;
+	pCurHcb->HCS_ActScb = pCurScb;
+	pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target];
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SELATNSTOP);
+	return;
+}
+
+
+/***************************************************************************/
+void tul_select_atn(HCS * pCurHcb, SCB * pCurScb)
+{
+	int i;
+
+	pCurScb->SCB_Status |= SCB_SELECT;
+	pCurScb->SCB_NxtStat = 0x2;
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident);
+	for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++)
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]);
+	pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target];
+	pCurHcb->HCS_ActScb = pCurScb;
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SEL_ATN);
+	return;
+}
+
+/***************************************************************************/
+void tul_select_atn3(HCS * pCurHcb, SCB * pCurScb)
+{
+	int i;
+
+	pCurScb->SCB_Status |= SCB_SELECT;
+	pCurScb->SCB_NxtStat = 0x2;
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_Ident);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagMsg);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_TagId);
+	for (i = 0; i < (int) pCurScb->SCB_CDBLen; i++)
+		TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, pCurScb->SCB_CDB[i]);
+	pCurHcb->HCS_ActTcs = &pCurHcb->HCS_Tcs[pCurScb->SCB_Target];
+	pCurHcb->HCS_ActScb = pCurScb;
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_SEL_ATN3);
+	return;
+}
+
+/***************************************************************************/
+/* SCSI Bus Device Reset */
+int tul_bus_device_reset(HCS * pCurHcb)
+{
+	SCB *pCurScb = pCurHcb->HCS_ActScb;
+	TCS *pCurTcb = pCurHcb->HCS_ActTcs;
+	SCB *pTmpScb, *pPrevScb;
+	BYTE tar;
+
+	if (pCurHcb->HCS_Phase != MSG_OUT) {
+		return (int_tul_bad_seq(pCurHcb));	/* Unexpected phase             */
+	}
+	tul_unlink_pend_scb(pCurHcb, pCurScb);
+	tul_release_scb(pCurHcb, pCurScb);
+
+
+	tar = pCurScb->SCB_Target;	/* target                       */
+	pCurTcb->TCS_Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE | TCF_BUSY);
+	/* clr sync. nego & WDTR flags  07/22/98 */
+
+	/* abort all SCB with same target */
+	pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;	/* Check Busy queue */
+	while (pTmpScb != NULL) {
+
+		if (pTmpScb->SCB_Target == tar) {
+			/* unlink it */
+			if (pTmpScb == pCurHcb->HCS_FirstBusy) {
+				if ((pCurHcb->HCS_FirstBusy = pTmpScb->SCB_NxtScb) == NULL)
+					pCurHcb->HCS_LastBusy = NULL;
+			} else {
+				pPrevScb->SCB_NxtScb = pTmpScb->SCB_NxtScb;
+				if (pTmpScb == pCurHcb->HCS_LastBusy)
+					pCurHcb->HCS_LastBusy = pPrevScb;
+			}
+			pTmpScb->SCB_HaStat = HOST_ABORTED;
+			tul_append_done_scb(pCurHcb, pTmpScb);
+		}
+		/* Previous haven't change      */
+		else {
+			pPrevScb = pTmpScb;
+		}
+		pTmpScb = pTmpScb->SCB_NxtScb;
+	}
+
+	TUL_WR(pCurHcb->HCS_Base + TUL_SFifo, MSG_DEVRST);
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_XF_FIFO_OUT);
+
+	return tul_wait_disc(pCurHcb);
+
+}
+
+/***************************************************************************/
+int tul_msgin_accept(HCS * pCurHcb)
+{
+	TUL_WR(pCurHcb->HCS_Base + TUL_SCmd, TSC_MSG_ACCEPT);
+	return (wait_tulip(pCurHcb));
+}
+
+/***************************************************************************/
+int wait_tulip(HCS * pCurHcb)
+{
+
+	while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0))
+		 & TSS_INT_PENDING));
+
+	pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
+	pCurHcb->HCS_Phase = pCurHcb->HCS_JSStatus0 & TSS_PH_MASK;
+	pCurHcb->HCS_JSStatus1 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus1);
+
+	if (pCurHcb->HCS_JSInt & TSS_RESEL_INT) {	/* if SCSI bus reset detected   */
+		return (int_tul_resel(pCurHcb));
+	}
+	if (pCurHcb->HCS_JSInt & TSS_SEL_TIMEOUT) {	/* if selected/reselected timeout interrupt */
+		return (int_tul_busfree(pCurHcb));
+	}
+	if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) {	/* if SCSI bus reset detected   */
+		return (int_tul_scsi_rst(pCurHcb));
+	}
+	if (pCurHcb->HCS_JSInt & TSS_DISC_INT) {	/* BUS disconnection            */
+		if (pCurHcb->HCS_Flags & HCF_EXPECT_DONE_DISC) {
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
+			tul_unlink_busy_scb(pCurHcb, pCurHcb->HCS_ActScb);
+			pCurHcb->HCS_ActScb->SCB_HaStat = 0;
+			tul_append_done_scb(pCurHcb, pCurHcb->HCS_ActScb);
+			pCurHcb->HCS_ActScb = NULL;
+			pCurHcb->HCS_ActTcs = NULL;
+			pCurHcb->HCS_Flags &= ~HCF_EXPECT_DONE_DISC;
+			TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
+			return (-1);
+		}
+		if (pCurHcb->HCS_Flags & HCF_EXPECT_DISC) {
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
+			pCurHcb->HCS_ActScb = NULL;
+			pCurHcb->HCS_ActTcs = NULL;
+			pCurHcb->HCS_Flags &= ~HCF_EXPECT_DISC;
+			TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
+			TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
+			return (-1);
+		}
+		return (int_tul_busfree(pCurHcb));
+	}
+	if (pCurHcb->HCS_JSInt & (TSS_FUNC_COMP | TSS_BUS_SERV)) {
+		return (pCurHcb->HCS_Phase);
+	}
+	return (pCurHcb->HCS_Phase);
+}
+/***************************************************************************/
+int tul_wait_disc(HCS * pCurHcb)
+{
+
+	while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0))
+		 & TSS_INT_PENDING));
+
+
+	pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
+
+	if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) {	/* if SCSI bus reset detected   */
+		return (int_tul_scsi_rst(pCurHcb));
+	}
+	if (pCurHcb->HCS_JSInt & TSS_DISC_INT) {	/* BUS disconnection            */
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
+		TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
+		pCurHcb->HCS_ActScb = NULL;
+		return (-1);
+	}
+	return (tul_bad_seq(pCurHcb));
+}
+
+/***************************************************************************/
+int tul_wait_done_disc(HCS * pCurHcb)
+{
+
+
+	while (!((pCurHcb->HCS_JSStatus0 = TUL_RD(pCurHcb->HCS_Base, TUL_SStatus0))
+		 & TSS_INT_PENDING));
+
+	pCurHcb->HCS_JSInt = TUL_RD(pCurHcb->HCS_Base, TUL_SInt);
+
+
+	if (pCurHcb->HCS_JSInt & TSS_SCSIRST_INT) {	/* if SCSI bus reset detected   */
+		return (int_tul_scsi_rst(pCurHcb));
+	}
+	if (pCurHcb->HCS_JSInt & TSS_DISC_INT) {	/* BUS disconnection            */
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl0, TSC_FLUSH_FIFO);		/* Flush SCSI FIFO  */
+		TUL_WR(pCurHcb->HCS_Base + TUL_SConfig, TSC_INITDEFAULT);
+		TUL_WR(pCurHcb->HCS_Base + TUL_SCtrl1, TSC_HW_RESELECT);	/* Enable HW reselect       */
+		tul_unlink_busy_scb(pCurHcb, pCurHcb->HCS_ActScb);
+
+		tul_append_done_scb(pCurHcb, pCurHcb->HCS_ActScb);
+		pCurHcb->HCS_ActScb = NULL;
+		return (-1);
+	}
+	return (tul_bad_seq(pCurHcb));
+}
+
+static irqreturn_t i91u_intr(int irqno, void *dev_id, struct pt_regs *regs)
+{
+	struct Scsi_Host *dev = dev_id;
+	unsigned long flags;
+	
+	spin_lock_irqsave(dev->host_lock, flags);
+	tul_isr((HCS *)dev->base);
+	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
+}
+
+static int tul_NewReturnNumberOfAdapters(void)
+{
+	struct pci_dev *pDev = NULL;	/* Start from none              */
+	int iAdapters = 0;
+	long dRegValue;
+	WORD wBIOS;
+	int i = 0;
+
+	init_i91uAdapter_table();
+
+	for (i = 0; i < TULSZ(i91u_pci_devices); i++)
+	{
+		while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) {
+			if (pci_enable_device(pDev))
+				continue;
+			pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
+			wBIOS = (UWORD) (dRegValue & 0xFF);
+			if (((dRegValue & 0xFF00) >> 8) == 0xFF)
+				dRegValue = 0;
+			wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8));
+			if (pci_set_dma_mask(pDev, 0xffffffff)) {
+				printk(KERN_WARNING 
+				       "i91u: Could not set 32 bit DMA mask\n");
+				continue;
+			}
+
+			if (Addi91u_into_Adapter_table(wBIOS,
+							(pDev->resource[0].start),
+						       	pDev->irq,
+						       	pDev->bus->number,
+					       		(pDev->devfn >> 3)
+		    		) == 0)
+				iAdapters++;
+		}
+	}
+
+	return (iAdapters);
+}
+
+static int i91u_detect(struct scsi_host_template * tpnt)
+{
+	HCS *pHCB;
+	struct Scsi_Host *hreg;
+	unsigned long i;	/* 01/14/98                     */
+	int ok = 0, iAdapters;
+	ULONG dBiosAdr;
+	BYTE *pbBiosAdr;
+
+	/* Get total number of adapters in the motherboard */
+	iAdapters = tul_NewReturnNumberOfAdapters();
+	if (iAdapters == 0)	/* If no tulip founded, return */
+		return (0);
+
+	tul_num_ch = (iAdapters > tul_num_ch) ? tul_num_ch : iAdapters;
+	/* Update actually channel number */
+	if (tul_tag_enable) {	/* 1.01i                  */
+		tul_num_scb = MAX_TARGETS * i91u_MAXQUEUE;
+	} else {
+		tul_num_scb = MAX_TARGETS + 3;	/* 1-tape, 1-CD_ROM, 1- extra */
+	}			/* Update actually SCBs per adapter */
+
+	/* Get total memory needed for HCS */
+	i = tul_num_ch * sizeof(HCS);
+	memset((unsigned char *) &tul_hcs[0], 0, i);	/* Initialize tul_hcs 0 */
+	/* Get total memory needed for SCB */
+
+	for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) {
+		i = tul_num_ch * tul_num_scb * sizeof(SCB);
+		if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL)
+			break;
+	}
+	if (tul_scb == NULL) {
+		printk("i91u: SCB memory allocation error\n");
+		return (0);
+	}
+	memset((unsigned char *) tul_scb, 0, i);
+
+	for (i = 0, pHCB = &tul_hcs[0];		/* Get pointer for control block */
+	     i < tul_num_ch;
+	     i++, pHCB++) {
+		get_tulipPCIConfig(pHCB, i);
+
+		dBiosAdr = pHCB->HCS_BIOS;
+		dBiosAdr = (dBiosAdr << 4);
+
+		pbBiosAdr = phys_to_virt(dBiosAdr);
+
+		init_tulip(pHCB, tul_scb + (i * tul_num_scb), tul_num_scb, pbBiosAdr, 10);
+		request_region(pHCB->HCS_Base, 256, "i91u"); /* Register */ 
+
+		pHCB->HCS_Index = i;	/* 7/29/98 */
+		hreg = scsi_register(tpnt, sizeof(HCS));
+		if(hreg == NULL) {
+			release_region(pHCB->HCS_Base, 256);
+			return 0;
+		}
+		hreg->io_port = pHCB->HCS_Base;
+		hreg->n_io_port = 0xff;
+		hreg->can_queue = tul_num_scb;	/* 03/05/98                      */
+		hreg->unique_id = pHCB->HCS_Base;
+		hreg->max_id = pHCB->HCS_MaxTar;
+		hreg->max_lun = 32;	/* 10/21/97                     */
+		hreg->irq = pHCB->HCS_Intr;
+		hreg->this_id = pHCB->HCS_SCSI_ID;	/* Assign HCS index           */
+		hreg->base = (unsigned long)pHCB;
+		hreg->sg_tablesize = TOTAL_SG_ENTRY;	/* Maximun support is 32 */
+
+		/* Initial tulip chip           */
+		ok = request_irq(pHCB->HCS_Intr, i91u_intr, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
+		if (ok < 0) {
+			printk(KERN_WARNING "i91u: unable to request IRQ %d\n\n", pHCB->HCS_Intr);
+			return 0;
+		}
+	}
+
+	tpnt->this_id = -1;
+	tpnt->can_queue = 1;
+
+	return 1;
+}
+
+static void i91uBuildSCB(HCS * pHCB, SCB * pSCB, struct scsi_cmnd * SCpnt)
+{				/* Create corresponding SCB     */
+	struct scatterlist *pSrbSG;
+	SG *pSG;		/* Pointer to SG list           */
+	int i;
+	long TotalLen;
+	dma_addr_t dma_addr;
+
+	pSCB->SCB_Post = i91uSCBPost;	/* i91u's callback routine      */
+	pSCB->SCB_Srb = SCpnt;
+	pSCB->SCB_Opcode = ExecSCSI;
+	pSCB->SCB_Flags = SCF_POST;	/* After SCSI done, call post routine */
+	pSCB->SCB_Target = SCpnt->device->id;
+	pSCB->SCB_Lun = SCpnt->device->lun;
+	pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW;
+
+	pSCB->SCB_Flags |= SCF_SENSE;	/* Turn on auto request sense   */
+	dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->sense_buffer,
+				  SENSE_SIZE, DMA_FROM_DEVICE);
+	pSCB->SCB_SensePtr = cpu_to_le32((u32)dma_addr);
+	pSCB->SCB_SenseLen = cpu_to_le32(SENSE_SIZE);
+	SCpnt->SCp.ptr = (char *)(unsigned long)dma_addr;
+
+	pSCB->SCB_CDBLen = SCpnt->cmd_len;
+	pSCB->SCB_HaStat = 0;
+	pSCB->SCB_TaStat = 0;
+	memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, SCpnt->cmd_len);
+
+	if (SCpnt->device->tagged_supported) {	/* Tag Support                  */
+		pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG;	/* Do simple tag only   */
+	} else {
+		pSCB->SCB_TagMsg = 0;	/* No tag support               */
+	}
+	/* todo handle map_sg error */
+	if (SCpnt->use_sg) {
+		dma_addr = dma_map_single(&pHCB->pci_dev->dev, &pSCB->SCB_SGList[0],
+					  sizeof(struct SG_Struc) * TOTAL_SG_ENTRY,
+					  DMA_BIDIRECTIONAL);
+		pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
+		SCpnt->SCp.dma_handle = dma_addr;
+
+		pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
+		pSCB->SCB_SGLen = dma_map_sg(&pHCB->pci_dev->dev, pSrbSG,
+					     SCpnt->use_sg, SCpnt->sc_data_direction);
+
+		pSCB->SCB_Flags |= SCF_SG;	/* Turn on SG list flag       */
+		for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0];	/* 1.01g */
+		     i < pSCB->SCB_SGLen; i++, pSG++, pSrbSG++) {
+			pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG));
+			TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG));
+		}
+
+		pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ?
+		    TotalLen : SCpnt->request_bufflen;
+	} else if (SCpnt->request_bufflen) {		/* Non SG */
+		dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->request_buffer,
+					  SCpnt->request_bufflen,
+					  SCpnt->sc_data_direction);
+		SCpnt->SCp.dma_handle = dma_addr;
+		pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
+		pSCB->SCB_BufLen = cpu_to_le32((u32)SCpnt->request_bufflen);
+		pSCB->SCB_SGLen = 0;
+	} else {
+		pSCB->SCB_BufLen = 0;
+		pSCB->SCB_SGLen = 0;
+	}
+}
+
+static int i91u_queuecommand(struct scsi_cmnd *cmd,
+		void (*done)(struct scsi_cmnd *))
+{
+	HCS *pHCB = (HCS *) cmd->device->host->base;
+	register SCB *pSCB;
+
+	cmd->scsi_done = done;
+
+	pSCB = tul_alloc_scb(pHCB);
+	if (!pSCB)
+		return SCSI_MLQUEUE_HOST_BUSY;
+
+	i91uBuildSCB(pHCB, pSCB, cmd);
+	tul_exec_scb(pHCB, pSCB);
+	return 0;
+}
+
+#if 0 /* no new EH yet */
+/*
+ *  Abort a queued command
+ *  (commands that are on the bus can't be aborted easily)
+ */
+static int i91u_abort(struct scsi_cmnd * SCpnt)
+{
+	HCS *pHCB;
+
+	pHCB = (HCS *) SCpnt->device->host->base;
+	return tul_abort_srb(pHCB, SCpnt);
+}
+
+/*
+ *  Reset registers, reset a hanging bus and
+ *  kill active and disconnected commands for target w/o soft reset
+ */
+static int i91u_reset(struct scsi_cmnd * SCpnt, unsigned int reset_flags)
+{				/* I need Host Control Block Information */
+	HCS *pHCB;
+
+	pHCB = (HCS *) SCpnt->device->host->base;
+
+	if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET | SCSI_RESET_SUGGEST_HOST_RESET))
+		return tul_reset_scsi_bus(pHCB);
+	else
+		return tul_device_reset(pHCB, SCpnt, SCpnt->device->id, reset_flags);
+}
+#endif
+
+static int i91u_bus_reset(struct scsi_cmnd * SCpnt)
+{
+	HCS *pHCB;
+
+	pHCB = (HCS *) SCpnt->device->host->base;
+	tul_reset_scsi(pHCB, 0);
+	return SUCCESS;
+}
+
+/*
+ * Return the "logical geometry"
+ */
+static int i91u_biosparam(struct scsi_device *sdev, struct block_device *dev,
+		sector_t capacity, int *info_array)
+{
+	HCS *pHcb;		/* Point to Host adapter control block */
+	TCS *pTcb;
+
+	pHcb = (HCS *) sdev->host->base;
+	pTcb = &pHcb->HCS_Tcs[sdev->id];
+
+	if (pTcb->TCS_DrvHead) {
+		info_array[0] = pTcb->TCS_DrvHead;
+		info_array[1] = pTcb->TCS_DrvSector;
+		info_array[2] = (unsigned long)capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector;
+	} else {
+		if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) {
+			info_array[0] = 255;
+			info_array[1] = 63;
+			info_array[2] = (unsigned long)capacity / 255 / 63;
+		} else {
+			info_array[0] = 64;
+			info_array[1] = 32;
+			info_array[2] = (unsigned long)capacity >> 11;
+		}
+	}
+
+#if defined(DEBUG_BIOSPARAM)
+	if (i91u_debug & debug_biosparam) {
+		printk("bios geometry: head=%d, sec=%d, cyl=%d\n",
+		       info_array[0], info_array[1], info_array[2]);
+		printk("WARNING: check, if the bios geometry is correct.\n");
+	}
+#endif
+
+	return 0;
+}
+
+static void i91u_unmap_cmnd(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd)
+{
+	/* auto sense buffer */
+	if (cmnd->SCp.ptr) {
+		dma_unmap_single(&pci_dev->dev,
+				 (dma_addr_t)((unsigned long)cmnd->SCp.ptr),
+				 SENSE_SIZE, DMA_FROM_DEVICE);
+		cmnd->SCp.ptr = NULL;
+	}
+
+	/* request buffer */
+	if (cmnd->use_sg) {
+		dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle,
+				 sizeof(struct SG_Struc) * TOTAL_SG_ENTRY,
+				 DMA_BIDIRECTIONAL);
+
+		dma_unmap_sg(&pci_dev->dev, cmnd->request_buffer,
+			     cmnd->use_sg,
+			     cmnd->sc_data_direction);
+	} else if (cmnd->request_bufflen) {
+		dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle,
+				 cmnd->request_bufflen,
+				 cmnd->sc_data_direction);
+	}
+}
+
+/*****************************************************************************
+ Function name  : i91uSCBPost
+ Description    : This is callback routine be called when tulip finish one
+			SCSI command.
+ Input          : pHCB  -       Pointer to host adapter control block.
+		  pSCB  -       Pointer to SCSI control block.
+ Output         : None.
+ Return         : None.
+*****************************************************************************/
+static void i91uSCBPost(BYTE * pHcb, BYTE * pScb)
+{
+	struct scsi_cmnd *pSRB;	/* Pointer to SCSI request block */
+	HCS *pHCB;
+	SCB *pSCB;
+
+	pHCB = (HCS *) pHcb;
+	pSCB = (SCB *) pScb;
+	if ((pSRB = pSCB->SCB_Srb) == 0) {
+		printk("i91uSCBPost: SRB pointer is empty\n");
+
+		tul_release_scb(pHCB, pSCB);	/* Release SCB for current channel */
+		return;
+	}
+	switch (pSCB->SCB_HaStat) {
+	case 0x0:
+	case 0xa:		/* Linked command complete without error and linked normally */
+	case 0xb:		/* Linked command complete without error interrupt generated */
+		pSCB->SCB_HaStat = 0;
+		break;
+
+	case 0x11:		/* Selection time out-The initiator selection or target
+				   reselection was not complete within the SCSI Time out period */
+		pSCB->SCB_HaStat = DID_TIME_OUT;
+		break;
+
+	case 0x14:		/* Target bus phase sequence failure-An invalid bus phase or bus
+				   phase sequence was requested by the target. The host adapter
+				   will generate a SCSI Reset Condition, notifying the host with
+				   a SCRD interrupt */
+		pSCB->SCB_HaStat = DID_RESET;
+		break;
+
+	case 0x1a:		/* SCB Aborted. 07/21/98 */
+		pSCB->SCB_HaStat = DID_ABORT;
+		break;
+
+	case 0x12:		/* Data overrun/underrun-The target attempted to transfer more data
+				   than was allocated by the Data Length field or the sum of the
+				   Scatter / Gather Data Length fields. */
+	case 0x13:		/* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
+	case 0x16:		/* Invalid SCB Operation Code. */
+
+	default:
+		printk("ini9100u: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat);
+		pSCB->SCB_HaStat = DID_ERROR;	/* Couldn't find any better */
+		break;
+	}
+
+	pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16);
+
+	if (pSRB == NULL) {
+		printk("pSRB is NULL\n");
+	}
+
+	i91u_unmap_cmnd(pHCB->pci_dev, pSRB);
+	pSRB->scsi_done(pSRB);	/* Notify system DONE           */
+
+	tul_release_scb(pHCB, pSCB);	/* Release SCB for current channel */
+}
+
+/*
+ * Release ressources
+ */
+static int i91u_release(struct Scsi_Host *hreg)
+{
+	free_irq(hreg->irq, hreg);
+	release_region(hreg->io_port, 256);
+	return 0;
+}
+MODULE_LICENSE("Dual BSD/GPL");
+
+static struct scsi_host_template driver_template = {
+	.proc_name	= "INI9100U",
+	.name		= i91u_REVID,
+	.detect		= i91u_detect,
+	.release	= i91u_release,
+	.queuecommand	= i91u_queuecommand,
+//	.abort		= i91u_abort,
+//	.reset		= i91u_reset,
+	.eh_bus_reset_handler = i91u_bus_reset,
+	.bios_param	= i91u_biosparam,
+	.can_queue	= 1,
+	.this_id	= 1,
+	.sg_tablesize	= SG_ALL,
+	.cmd_per_lun 	= 1,
+	.use_clustering	= ENABLE_CLUSTERING,
+};
+#include "scsi_module.c"
+
diff -Nru a/drivers/scsi/initio.h b/drivers/scsi/initio.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/initio.h	2004-12-24 13:36:55 -08:00
@@ -0,0 +1,739 @@
+/**************************************************************************
+ * Initio 9100 device driver for Linux.
+ *
+ * Copyright (c) 1994-1998 Initio Corporation
+ * 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, 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; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Where this Software is combined with software released under the terms of 
+ * the GNU General Public License ("GPL") and the terms of the GPL would require the 
+ * combined work to also be released under the terms of the GPL, the terms
+ * and conditions of this License will apply in addition to those of the
+ * GPL with the exception of any terms or conditions of this License that
+ * conflict with, or are expressly prohibited by, the GPL.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ *
+ **************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/types.h>
+
+#define ULONG   unsigned long
+#define USHORT  unsigned short
+#define UCHAR   unsigned char
+#define BYTE    unsigned char
+#define WORD    unsigned short
+#define DWORD   unsigned long
+#define UBYTE   unsigned char
+#define UWORD   unsigned short
+#define UDWORD  unsigned long
+#define U32     u32
+
+#define TOTAL_SG_ENTRY		32
+#define MAX_SUPPORTED_ADAPTERS  8
+#define MAX_OFFSET		15
+#define MAX_TARGETS		16
+
+typedef struct {
+	unsigned short base;
+	unsigned short vec;
+} i91u_config;
+
+/***************************************/
+/*  Tulip Configuration Register Set */
+/***************************************/
+#define TUL_PVID        0x00	/* Vendor ID                    */
+#define TUL_PDID        0x02	/* Device ID                    */
+#define TUL_PCMD        0x04	/* Command                      */
+#define TUL_PSTUS       0x06	/* Status                       */
+#define TUL_PRID        0x08	/* Revision number              */
+#define TUL_PPI         0x09	/* Programming interface        */
+#define TUL_PSC         0x0A	/* Sub Class                    */
+#define TUL_PBC         0x0B	/* Base Class                   */
+#define TUL_PCLS        0x0C	/* Cache line size              */
+#define TUL_PLTR        0x0D	/* Latency timer                */
+#define TUL_PHDT        0x0E	/* Header type                  */
+#define TUL_PBIST       0x0F	/* BIST                         */
+#define TUL_PBAD        0x10	/* Base address                 */
+#define TUL_PBAD1       0x14	/* Base address                 */
+#define TUL_PBAD2       0x18	/* Base address                 */
+#define TUL_PBAD3       0x1C	/* Base address                 */
+#define TUL_PBAD4       0x20	/* Base address                 */
+#define TUL_PBAD5       0x24	/* Base address                 */
+#define TUL_PRSVD       0x28	/* Reserved                     */
+#define TUL_PRSVD1      0x2C	/* Reserved                     */
+#define TUL_PRAD        0x30	/* Expansion ROM base address   */
+#define TUL_PRSVD2      0x34	/* Reserved                     */
+#define TUL_PRSVD3      0x38	/* Reserved                     */
+#define TUL_PINTL       0x3C	/* Interrupt line               */
+#define TUL_PINTP       0x3D	/* Interrupt pin                */
+#define TUL_PIGNT       0x3E	/* MIN_GNT                      */
+#define TUL_PMGNT       0x3F	/* MAX_GNT                      */
+
+/************************/
+/*  Jasmin Register Set */
+/************************/
+#define TUL_HACFG0      0x40	/* H/A Configuration Register 0         */
+#define TUL_HACFG1      0x41	/* H/A Configuration Register 1         */
+#define TUL_HACFG2      0x42	/* H/A Configuration Register 2         */
+
+#define TUL_SDCFG0      0x44	/* SCSI Device Configuration 0          */
+#define TUL_SDCFG1      0x45	/* SCSI Device Configuration 1          */
+#define TUL_SDCFG2      0x46	/* SCSI Device Configuration 2          */
+#define TUL_SDCFG3      0x47	/* SCSI Device Configuration 3          */
+
+#define TUL_GINTS       0x50	/* Global Interrupt Status Register     */
+#define TUL_GIMSK       0x52	/* Global Interrupt MASK Register       */
+#define TUL_GCTRL       0x54	/* Global Control Register              */
+#define TUL_GCTRL_EEPROM_BIT    0x04
+#define TUL_GCTRL1      0x55	/* Global Control Register              */
+#define TUL_DMACFG      0x5B	/* DMA configuration                    */
+#define TUL_NVRAM       0x5D	/* Non-volatile RAM port                */
+
+#define TUL_SCnt0       0x80	/* 00 R/W Transfer Counter Low          */
+#define TUL_SCnt1       0x81	/* 01 R/W Transfer Counter Mid          */
+#define TUL_SCnt2       0x82	/* 02 R/W Transfer Count High           */
+#define TUL_SFifoCnt    0x83	/* 03 R   FIFO counter                  */
+#define TUL_SIntEnable  0x84	/* 03 W   Interrupt enble               */
+#define TUL_SInt        0x84	/* 04 R   Interrupt Register            */
+#define TUL_SCtrl0      0x85	/* 05 W   Control 0                     */
+#define TUL_SStatus0    0x85	/* 05 R   Status 0                      */
+#define TUL_SCtrl1      0x86	/* 06 W   Control 1                     */
+#define TUL_SStatus1    0x86	/* 06 R   Status 1                      */
+#define TUL_SConfig     0x87	/* 07 W   Configuration                 */
+#define TUL_SStatus2    0x87	/* 07 R   Status 2                      */
+#define TUL_SPeriod     0x88	/* 08 W   Sync. Transfer Period & Offset */
+#define TUL_SOffset     0x88	/* 08 R   Offset                        */
+#define TUL_SScsiId     0x89	/* 09 W   SCSI ID                       */
+#define TUL_SBusId      0x89	/* 09 R   SCSI BUS ID                   */
+#define TUL_STimeOut    0x8A	/* 0A W   Sel/Resel Time Out Register   */
+#define TUL_SIdent      0x8A	/* 0A R   Identify Message Register     */
+#define TUL_SAvail      0x8A	/* 0A R   Availiable Counter Register   */
+#define TUL_SData       0x8B	/* 0B R/W SCSI data in/out              */
+#define TUL_SFifo       0x8C	/* 0C R/W FIFO                          */
+#define TUL_SSignal     0x90	/* 10 R/W SCSI signal in/out            */
+#define TUL_SCmd        0x91	/* 11 R/W Command                       */
+#define TUL_STest0      0x92	/* 12 R/W Test0                         */
+#define TUL_STest1      0x93	/* 13 R/W Test1                         */
+#define TUL_SCFG1	0x94	/* 14 R/W Configuration                 */
+
+#define TUL_XAddH       0xC0	/*DMA Transfer Physical Address         */
+#define TUL_XAddW       0xC8	/*DMA Current Transfer Physical Address */
+#define TUL_XCntH       0xD0	/*DMA Transfer Counter                  */
+#define TUL_XCntW       0xD4	/*DMA Current Transfer Counter          */
+#define TUL_XCmd        0xD8	/*DMA Command Register                  */
+#define TUL_Int         0xDC	/*Interrupt Register                    */
+#define TUL_XStatus     0xDD	/*DMA status Register                   */
+#define TUL_Mask        0xE0	/*Interrupt Mask Register               */
+#define TUL_XCtrl       0xE4	/*DMA Control Register                  */
+#define TUL_XCtrl1      0xE5	/*DMA Control Register 1                */
+#define TUL_XFifo       0xE8	/*DMA FIFO                              */
+
+#define TUL_WCtrl       0xF7	/*Bus master wait state control         */
+#define TUL_DCtrl       0xFB	/*DMA delay control                     */
+
+/*----------------------------------------------------------------------*/
+/*   bit definition for Command register of Configuration Space Header  */
+/*----------------------------------------------------------------------*/
+#define BUSMS           0x04	/* BUS MASTER Enable                    */
+#define IOSPA           0x01	/* IO Space Enable                      */
+
+/*----------------------------------------------------------------------*/
+/* Command Codes of Tulip SCSI Command register                         */
+/*----------------------------------------------------------------------*/
+#define TSC_EN_RESEL    0x80	/* Enable Reselection                   */
+#define TSC_CMD_COMP    0x84	/* Command Complete Sequence            */
+#define TSC_SEL         0x01	/* Select Without ATN Sequence          */
+#define TSC_SEL_ATN     0x11	/* Select With ATN Sequence             */
+#define TSC_SEL_ATN_DMA 0x51	/* Select With ATN Sequence with DMA    */
+#define TSC_SEL_ATN3    0x31	/* Select With ATN3 Sequence            */
+#define TSC_SEL_ATNSTOP 0x12	/* Select With ATN and Stop Sequence    */
+#define TSC_SELATNSTOP  0x1E	/* Select With ATN and Stop Sequence    */
+
+#define TSC_SEL_ATN_DIRECT_IN   0x95	/* Select With ATN Sequence     */
+#define TSC_SEL_ATN_DIRECT_OUT  0x15	/* Select With ATN Sequence     */
+#define TSC_SEL_ATN3_DIRECT_IN  0xB5	/* Select With ATN3 Sequence    */
+#define TSC_SEL_ATN3_DIRECT_OUT 0x35	/* Select With ATN3 Sequence    */
+#define TSC_XF_DMA_OUT_DIRECT   0x06	/* DMA Xfer Infomation out      */
+#define TSC_XF_DMA_IN_DIRECT    0x86	/* DMA Xfer Infomation in       */
+
+#define TSC_XF_DMA_OUT  0x43	/* DMA Xfer Infomation out              */
+#define TSC_XF_DMA_IN   0xC3	/* DMA Xfer Infomation in               */
+#define TSC_XF_FIFO_OUT 0x03	/* FIFO Xfer Infomation out             */
+#define TSC_XF_FIFO_IN  0x83	/* FIFO Xfer Infomation in              */
+
+#define TSC_MSG_ACCEPT  0x0F	/* Message Accept                       */
+
+/*----------------------------------------------------------------------*/
+/* bit definition for Tulip SCSI Control 0 Register                     */
+/*----------------------------------------------------------------------*/
+#define TSC_RST_SEQ     0x20	/* Reset sequence counter               */
+#define TSC_FLUSH_FIFO  0x10	/* Flush FIFO                           */
+#define TSC_ABT_CMD     0x04	/* Abort command (sequence)             */
+#define TSC_RST_CHIP    0x02	/* Reset SCSI Chip                      */
+#define TSC_RST_BUS     0x01	/* Reset SCSI Bus                       */
+
+/*----------------------------------------------------------------------*/
+/* bit definition for Tulip SCSI Control 1 Register                     */
+/*----------------------------------------------------------------------*/
+#define TSC_EN_SCAM     0x80	/* Enable SCAM                          */
+#define TSC_TIMER       0x40	/* Select timeout unit                  */
+#define TSC_EN_SCSI2    0x20	/* SCSI-2 mode                          */
+#define TSC_PWDN        0x10	/* Power down mode                      */
+#define TSC_WIDE_CPU    0x08	/* Wide CPU                             */
+#define TSC_HW_RESELECT 0x04	/* Enable HW reselect                   */
+#define TSC_EN_BUS_OUT  0x02	/* Enable SCSI data bus out latch       */
+#define TSC_EN_BUS_IN   0x01	/* Enable SCSI data bus in latch        */
+
+/*----------------------------------------------------------------------*/
+/* bit definition for Tulip SCSI Configuration Register                 */
+/*----------------------------------------------------------------------*/
+#define TSC_EN_LATCH    0x80	/* Enable phase latch                   */
+#define TSC_INITIATOR   0x40	/* Initiator mode                       */
+#define TSC_EN_SCSI_PAR 0x20	/* Enable SCSI parity                   */
+#define TSC_DMA_8BIT    0x10	/* Alternate dma 8-bits mode            */
+#define TSC_DMA_16BIT   0x08	/* Alternate dma 16-bits mode           */
+#define TSC_EN_WDACK    0x04	/* Enable DACK while wide SCSI xfer     */
+#define TSC_ALT_PERIOD  0x02	/* Alternate sync period mode           */
+#define TSC_DIS_SCSIRST 0x01	/* Disable SCSI bus reset us            */
+
+#define TSC_INITDEFAULT (TSC_INITIATOR | TSC_EN_LATCH | TSC_ALT_PERIOD | TSC_DIS_SCSIRST)
+
+#define TSC_WIDE_SCSI   0x80	/* Enable Wide SCSI                     */
+
+/*----------------------------------------------------------------------*/
+/* bit definition for Tulip SCSI signal Register                        */
+/*----------------------------------------------------------------------*/
+#define TSC_RST_ACK     0x00	/* Release ACK signal                   */
+#define TSC_RST_ATN     0x00	/* Release ATN signal                   */
+#define TSC_RST_BSY     0x00	/* Release BSY signal                   */
+
+#define TSC_SET_ACK     0x40	/* ACK signal                           */
+#define TSC_SET_ATN     0x08	/* ATN signal                           */
+
+#define TSC_REQI        0x80	/* REQ signal                           */
+#define TSC_ACKI        0x40	/* ACK signal                           */
+#define TSC_BSYI        0x20	/* BSY signal                           */
+#define TSC_SELI        0x10	/* SEL signal                           */
+#define TSC_ATNI        0x08	/* ATN signal                           */
+#define TSC_MSGI        0x04	/* MSG signal                           */
+#define TSC_CDI         0x02	/* C/D signal                           */
+#define TSC_IOI         0x01	/* I/O signal                           */
+
+
+/*----------------------------------------------------------------------*/
+/* bit definition for Tulip SCSI Status 0 Register                      */
+/*----------------------------------------------------------------------*/
+#define TSS_INT_PENDING 0x80	/* Interrupt pending            */
+#define TSS_SEQ_ACTIVE  0x40	/* Sequencer active             */
+#define TSS_XFER_CNT    0x20	/* Transfer counter zero        */
+#define TSS_FIFO_EMPTY  0x10	/* FIFO empty                   */
+#define TSS_PAR_ERROR   0x08	/* SCSI parity error            */
+#define TSS_PH_MASK     0x07	/* SCSI phase mask              */
+
+/*----------------------------------------------------------------------*/
+/* bit definition for Tulip SCSI Status 1 Register                      */
+/*----------------------------------------------------------------------*/
+#define TSS_STATUS_RCV  0x08	/* Status received              */
+#define TSS_MSG_SEND    0x40	/* Message sent                 */
+#define TSS_CMD_PH_CMP  0x20	/* command phase done              */
+#define TSS_DATA_PH_CMP 0x10	/* Data phase done              */
+#define TSS_STATUS_SEND 0x08	/* Status sent                  */
+#define TSS_XFER_CMP    0x04	/* Transfer completed           */
+#define TSS_SEL_CMP     0x02	/* Selection completed          */
+#define TSS_ARB_CMP     0x01	/* Arbitration completed        */
+
+/*----------------------------------------------------------------------*/
+/* bit definition for Tulip SCSI Status 2 Register                      */
+/*----------------------------------------------------------------------*/
+#define TSS_CMD_ABTED   0x80	/* Command aborted              */
+#define TSS_OFFSET_0    0x40	/* Offset counter zero          */
+#define TSS_FIFO_FULL   0x20	/* FIFO full                    */
+#define TSS_TIMEOUT_0   0x10	/* Timeout counter zero         */
+#define TSS_BUSY_RLS    0x08	/* Busy release                 */
+#define TSS_PH_MISMATCH 0x04	/* Phase mismatch               */
+#define TSS_SCSI_BUS_EN 0x02	/* SCSI data bus enable         */
+#define TSS_SCSIRST     0x01	/* SCSI bus reset in progress   */
+
+/*----------------------------------------------------------------------*/
+/* bit definition for Tulip SCSI Interrupt Register                     */
+/*----------------------------------------------------------------------*/
+#define TSS_RESEL_INT   0x80	/* Reselected interrupt         */
+#define TSS_SEL_TIMEOUT 0x40	/* Selected/reselected timeout  */
+#define TSS_BUS_SERV    0x20
+#define TSS_SCSIRST_INT 0x10	/* SCSI bus reset detected      */
+#define TSS_DISC_INT    0x08	/* Disconnected interrupt       */
+#define TSS_SEL_INT     0x04	/* Select interrupt             */
+#define TSS_SCAM_SEL    0x02	/* SCAM selected                */
+#define TSS_FUNC_COMP   0x01
+
+/*----------------------------------------------------------------------*/
+/* SCSI Phase Codes.                                                    */
+/*----------------------------------------------------------------------*/
+#define DATA_OUT        0
+#define DATA_IN         1	/* 4                            */
+#define CMD_OUT         2
+#define STATUS_IN       3	/* 6                            */
+#define MSG_OUT         6	/* 3                            */
+#define MSG_IN          7
+
+
+
+/*----------------------------------------------------------------------*/
+/* Command Codes of Tulip xfer Command register                         */
+/*----------------------------------------------------------------------*/
+#define TAX_X_FORC      0x02
+#define TAX_X_ABT       0x04
+#define TAX_X_CLR_FIFO  0x08
+
+#define TAX_X_IN        0x21
+#define TAX_X_OUT       0x01
+#define TAX_SG_IN       0xA1
+#define TAX_SG_OUT      0x81
+
+/*----------------------------------------------------------------------*/
+/* Tulip Interrupt Register                                             */
+/*----------------------------------------------------------------------*/
+#define XCMP            0x01
+#define FCMP            0x02
+#define XABT            0x04
+#define XERR            0x08
+#define SCMP            0x10
+#define IPEND           0x80
+
+/*----------------------------------------------------------------------*/
+/* Tulip DMA Status Register                                            */
+/*----------------------------------------------------------------------*/
+#define XPEND           0x01	/* Transfer pending             */
+#define FEMPTY          0x02	/* FIFO empty                   */
+
+
+
+/*----------------------------------------------------------------------*/
+/* bit definition for TUL_GCTRL                                         */
+/*----------------------------------------------------------------------*/
+#define EXTSG           0x80
+#define EXTAD           0x60
+#define SEG4K           0x08
+#define EEPRG           0x04
+#define MRMUL           0x02
+
+/*----------------------------------------------------------------------*/
+/* bit definition for TUL_NVRAM                                         */
+/*----------------------------------------------------------------------*/
+#define SE2CS           0x08
+#define SE2CLK          0x04
+#define SE2DO           0x02
+#define SE2DI           0x01
+
+
+/************************************************************************/
+/*              Scatter-Gather Element Structure                        */
+/************************************************************************/
+typedef struct SG_Struc {
+	U32 SG_Ptr;		/* Data Pointer */
+	U32 SG_Len;		/* Data Length */
+} SG;
+
+/***********************************************************************
+		SCSI Control Block
+************************************************************************/
+typedef struct Scsi_Ctrl_Blk {
+	struct Scsi_Ctrl_Blk *SCB_NxtScb;
+	UBYTE SCB_Status;	/*4 */
+	UBYTE SCB_NxtStat;	/*5 */
+	UBYTE SCB_Mode;		/*6 */
+	UBYTE SCB_Msgin;	/*7 SCB_Res0 */
+	UWORD SCB_SGIdx;	/*8 */
+	UWORD SCB_SGMax;	/*A */
+#ifdef ALPHA
+	U32 SCB_Reserved[2];	/*C */
+#else
+	U32 SCB_Reserved[3];	/*C */
+#endif
+
+	U32 SCB_XferLen;	/*18 Current xfer len           */
+	U32 SCB_TotXLen;	/*1C Total xfer len             */
+	U32 SCB_PAddr;		/*20 SCB phy. Addr. */
+
+	UBYTE SCB_Opcode;	/*24 SCB command code */
+	UBYTE SCB_Flags;	/*25 SCB Flags */
+	UBYTE SCB_Target;	/*26 Target Id */
+	UBYTE SCB_Lun;		/*27 Lun */
+	U32 SCB_BufPtr;		/*28 Data Buffer Pointer */
+	U32 SCB_BufLen;		/*2C Data Allocation Length */
+	UBYTE SCB_SGLen;	/*30 SG list # */
+	UBYTE SCB_SenseLen;	/*31 Sense Allocation Length */
+	UBYTE SCB_HaStat;	/*32 */
+	UBYTE SCB_TaStat;	/*33 */
+	UBYTE SCB_CDBLen;	/*34 CDB Length */
+	UBYTE SCB_Ident;	/*35 Identify */
+	UBYTE SCB_TagMsg;	/*36 Tag Message */
+	UBYTE SCB_TagId;	/*37 Queue Tag */
+	UBYTE SCB_CDB[12];	/*38 */
+	U32 SCB_SGPAddr;	/*44 SG List/Sense Buf phy. Addr. */
+	U32 SCB_SensePtr;	/*48 Sense data pointer */
+	void (*SCB_Post) (BYTE *, BYTE *);	/*4C POST routine */
+	struct scsi_cmnd *SCB_Srb;	/*50 SRB Pointer */
+	SG SCB_SGList[TOTAL_SG_ENTRY];	/*54 Start of SG list */
+} SCB;
+
+/* Bit Definition for SCB_Status */
+#define SCB_RENT        0x01
+#define SCB_PEND        0x02
+#define SCB_CONTIG      0x04	/* Contigent Allegiance */
+#define SCB_SELECT      0x08
+#define SCB_BUSY        0x10
+#define SCB_DONE        0x20
+
+
+/* Opcodes of SCB_Opcode */
+#define ExecSCSI        0x1
+#define BusDevRst       0x2
+#define AbortCmd        0x3
+
+
+/* Bit Definition for SCB_Mode */
+#define SCM_RSENS       0x01	/* request sense mode */
+
+
+/* Bit Definition for SCB_Flags */
+#define SCF_DONE        0x01
+#define SCF_POST        0x02
+#define SCF_SENSE       0x04
+#define SCF_DIR         0x18
+#define SCF_NO_DCHK     0x00
+#define SCF_DIN         0x08
+#define SCF_DOUT        0x10
+#define SCF_NO_XF       0x18
+#define SCF_WR_VF       0x20	/* Write verify turn on         */
+#define SCF_POLL        0x40
+#define SCF_SG          0x80
+
+/* Error Codes for SCB_HaStat */
+#define HOST_SEL_TOUT   0x11
+#define HOST_DO_DU      0x12
+#define HOST_BUS_FREE   0x13
+#define HOST_BAD_PHAS   0x14
+#define HOST_INV_CMD    0x16
+#define HOST_ABORTED    0x1A	/* 07/21/98 */
+#define HOST_SCSI_RST   0x1B
+#define HOST_DEV_RST    0x1C
+
+/* Error Codes for SCB_TaStat */
+#define TARGET_CHKCOND  0x02
+#define TARGET_BUSY     0x08
+#define INI_QUEUE_FULL	0x28
+
+/* SCSI MESSAGE */
+#define MSG_COMP        0x00
+#define MSG_EXTEND      0x01
+#define MSG_SDP         0x02
+#define MSG_RESTORE     0x03
+#define MSG_DISC        0x04
+#define MSG_IDE         0x05
+#define MSG_ABORT       0x06
+#define MSG_REJ         0x07
+#define MSG_NOP         0x08
+#define MSG_PARITY      0x09
+#define MSG_LINK_COMP   0x0A
+#define MSG_LINK_FLAG   0x0B
+#define MSG_DEVRST      0x0C
+#define MSG_ABORT_TAG   0x0D
+
+/* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */
+#define MSG_STAG        0x20
+#define MSG_HTAG        0x21
+#define MSG_OTAG        0x22
+
+#define MSG_IGNOREWIDE  0x23
+
+#define MSG_IDENT   0x80
+
+/***********************************************************************
+		Target Device Control Structure
+**********************************************************************/
+
+typedef struct Tar_Ctrl_Struc {
+	UWORD TCS_Flags;	/* 0 */
+	UBYTE TCS_JS_Period;	/* 2 */
+	UBYTE TCS_SConfig0;	/* 3 */
+
+	UWORD TCS_DrvFlags;	/* 4 */
+	UBYTE TCS_DrvHead;	/* 6 */
+	UBYTE TCS_DrvSector;	/* 7 */
+} TCS;
+
+/***********************************************************************
+		Target Device Control Structure
+**********************************************************************/
+
+/* Bit Definition for TCF_Flags */
+#define TCF_SCSI_RATE           0x0007
+#define TCF_EN_DISC             0x0008
+#define TCF_NO_SYNC_NEGO        0x0010
+#define TCF_NO_WDTR             0x0020
+#define TCF_EN_255              0x0040
+#define TCF_EN_START            0x0080
+#define TCF_WDTR_DONE           0x0100
+#define TCF_SYNC_DONE           0x0200
+#define TCF_BUSY                0x0400
+
+
+/* Bit Definition for TCF_DrvFlags */
+#define TCF_DRV_BUSY            0x01	/* Indicate target busy(driver) */
+#define TCF_DRV_EN_TAG          0x0800
+#define TCF_DRV_255_63          0x0400
+
+typedef struct I91u_Adpt_Struc {
+	UWORD ADPT_BIOS;	/* 0 */
+	UWORD ADPT_BASE;	/* 1 */
+	UBYTE ADPT_Bus;		/* 2 */
+	UBYTE ADPT_Device;	/* 3 */
+	UBYTE ADPT_INTR;	/* 4 */
+} INI_ADPT_STRUCT;
+
+
+/***********************************************************************
+	      Host Adapter Control Structure
+************************************************************************/
+typedef struct Ha_Ctrl_Struc {
+	UWORD HCS_Base;		/* 00 */
+	UWORD HCS_BIOS;		/* 02 */
+	UBYTE HCS_Intr;		/* 04 */
+	UBYTE HCS_SCSI_ID;	/* 05 */
+	UBYTE HCS_MaxTar;	/* 06 */
+	UBYTE HCS_NumScbs;	/* 07 */
+
+	UBYTE HCS_Flags;	/* 08 */
+	UBYTE HCS_Index;	/* 09 */
+	UBYTE HCS_HaId;		/* 0A */
+	UBYTE HCS_Config;	/* 0B */
+	UWORD HCS_IdMask;	/* 0C */
+	UBYTE HCS_Semaph;	/* 0E */
+	UBYTE HCS_Phase;	/* 0F */
+	UBYTE HCS_JSStatus0;	/* 10 */
+	UBYTE HCS_JSInt;	/* 11 */
+	UBYTE HCS_JSStatus1;	/* 12 */
+	UBYTE HCS_SConf1;	/* 13 */
+
+	UBYTE HCS_Msg[8];	/* 14 */
+	SCB *HCS_NxtAvail;	/* 1C */
+	SCB *HCS_Scb;		/* 20 */
+	SCB *HCS_ScbEnd;	/* 24 */
+	SCB *HCS_NxtPend;	/* 28 */
+	SCB *HCS_NxtContig;	/* 2C */
+	SCB *HCS_ActScb;	/* 30 */
+	TCS *HCS_ActTcs;	/* 34 */
+
+	SCB *HCS_FirstAvail;	/* 38 */
+	SCB *HCS_LastAvail;	/* 3C */
+	SCB *HCS_FirstPend;	/* 40 */
+	SCB *HCS_LastPend;	/* 44 */
+	SCB *HCS_FirstBusy;	/* 48 */
+	SCB *HCS_LastBusy;	/* 4C */
+	SCB *HCS_FirstDone;	/* 50 */
+	SCB *HCS_LastDone;	/* 54 */
+	UBYTE HCS_MaxTags[16];	/* 58 */
+	UBYTE HCS_ActTags[16];	/* 68 */
+	TCS HCS_Tcs[MAX_TARGETS];	/* 78 */
+	spinlock_t HCS_AvailLock;
+	spinlock_t HCS_SemaphLock;
+	struct pci_dev *pci_dev;
+} HCS;
+
+/* Bit Definition for HCB_Config */
+#define HCC_SCSI_RESET          0x01
+#define HCC_EN_PAR              0x02
+#define HCC_ACT_TERM1           0x04
+#define HCC_ACT_TERM2           0x08
+#define HCC_AUTO_TERM           0x10
+#define HCC_EN_PWR              0x80
+
+/* Bit Definition for HCB_Flags */
+#define HCF_EXPECT_DISC         0x01
+#define HCF_EXPECT_SELECT       0x02
+#define HCF_EXPECT_RESET        0x10
+#define HCF_EXPECT_DONE_DISC    0x20
+
+/******************************************************************
+	Serial EEProm
+*******************************************************************/
+
+typedef struct _NVRAM_SCSI {	/* SCSI channel configuration   */
+	UCHAR NVM_ChSCSIID;	/* 0Ch -> Channel SCSI ID       */
+	UCHAR NVM_ChConfig1;	/* 0Dh -> Channel config 1      */
+	UCHAR NVM_ChConfig2;	/* 0Eh -> Channel config 2      */
+	UCHAR NVM_NumOfTarg;	/* 0Fh -> Number of SCSI target */
+	/* SCSI target configuration    */
+	UCHAR NVM_Targ0Config;	/* 10h -> Target 0 configuration */
+	UCHAR NVM_Targ1Config;	/* 11h -> Target 1 configuration */
+	UCHAR NVM_Targ2Config;	/* 12h -> Target 2 configuration */
+	UCHAR NVM_Targ3Config;	/* 13h -> Target 3 configuration */
+	UCHAR NVM_Targ4Config;	/* 14h -> Target 4 configuration */
+	UCHAR NVM_Targ5Config;	/* 15h -> Target 5 configuration */
+	UCHAR NVM_Targ6Config;	/* 16h -> Target 6 configuration */
+	UCHAR NVM_Targ7Config;	/* 17h -> Target 7 configuration */
+	UCHAR NVM_Targ8Config;	/* 18h -> Target 8 configuration */
+	UCHAR NVM_Targ9Config;	/* 19h -> Target 9 configuration */
+	UCHAR NVM_TargAConfig;	/* 1Ah -> Target A configuration */
+	UCHAR NVM_TargBConfig;	/* 1Bh -> Target B configuration */
+	UCHAR NVM_TargCConfig;	/* 1Ch -> Target C configuration */
+	UCHAR NVM_TargDConfig;	/* 1Dh -> Target D configuration */
+	UCHAR NVM_TargEConfig;	/* 1Eh -> Target E configuration */
+	UCHAR NVM_TargFConfig;	/* 1Fh -> Target F configuration */
+} NVRAM_SCSI;
+
+typedef struct _NVRAM {
+/*----------header ---------------*/
+	USHORT NVM_Signature;	/* 0,1: Signature */
+	UCHAR NVM_Size;		/* 2:   Size of data structure */
+	UCHAR NVM_Revision;	/* 3:   Revision of data structure */
+	/* ----Host Adapter Structure ---- */
+	UCHAR NVM_ModelByte0;	/* 4:   Model number (byte 0) */
+	UCHAR NVM_ModelByte1;	/* 5:   Model number (byte 1) */
+	UCHAR NVM_ModelInfo;	/* 6:   Model information         */
+	UCHAR NVM_NumOfCh;	/* 7:   Number of SCSI channel */
+	UCHAR NVM_BIOSConfig1;	/* 8:   BIOS configuration 1  */
+	UCHAR NVM_BIOSConfig2;	/* 9:   BIOS configuration 2  */
+	UCHAR NVM_HAConfig1;	/* A:   Hoat adapter configuration 1 */
+	UCHAR NVM_HAConfig2;	/* B:   Hoat adapter configuration 2 */
+	NVRAM_SCSI NVM_SCSIInfo[2];
+	UCHAR NVM_reserved[10];
+	/* ---------- CheckSum ----------       */
+	USHORT NVM_CheckSum;	/* 0x3E, 0x3F: Checksum of NVRam        */
+} NVRAM, *PNVRAM;
+
+/* Bios Configuration for nvram->BIOSConfig1                            */
+#define NBC1_ENABLE             0x01	/* BIOS enable                  */
+#define NBC1_8DRIVE             0x02	/* Support more than 2 drives   */
+#define NBC1_REMOVABLE          0x04	/* Support removable drive      */
+#define NBC1_INT19              0x08	/* Intercept int 19h            */
+#define NBC1_BIOSSCAN           0x10	/* Dynamic BIOS scan            */
+#define NBC1_LUNSUPPORT         0x40	/* Support LUN                  */
+
+/* HA Configuration Byte 1                                              */
+#define NHC1_BOOTIDMASK 0x0F	/* Boot ID number               */
+#define NHC1_LUNMASK    0x70	/* Boot LUN number              */
+#define NHC1_CHANMASK   0x80	/* Boot Channel number          */
+
+/* Bit definition for nvram->SCSIconfig1                                */
+#define NCC1_BUSRESET           0x01	/* Reset SCSI bus at power up   */
+#define NCC1_PARITYCHK          0x02	/* SCSI parity enable           */
+#define NCC1_ACTTERM1           0x04	/* Enable active terminator 1   */
+#define NCC1_ACTTERM2           0x08	/* Enable active terminator 2   */
+#define NCC1_AUTOTERM           0x10	/* Enable auto terminator       */
+#define NCC1_PWRMGR             0x80	/* Enable power management      */
+
+/* Bit definition for SCSI Target configuration byte                    */
+#define NTC_DISCONNECT          0x08	/* Enable SCSI disconnect       */
+#define NTC_SYNC                0x10	/* SYNC_NEGO                    */
+#define NTC_NO_WDTR             0x20	/* SYNC_NEGO                    */
+#define NTC_1GIGA               0x40	/* 255 head / 63 sectors (64/32) */
+#define NTC_SPINUP              0x80	/* Start disk drive             */
+
+/*      Default NVRam values                                            */
+#define INI_SIGNATURE           0xC925
+#define NBC1_DEFAULT            (NBC1_ENABLE)
+#define NCC1_DEFAULT            (NCC1_BUSRESET | NCC1_AUTOTERM | NCC1_PARITYCHK)
+#define NTC_DEFAULT             (NTC_NO_WDTR | NTC_1GIGA | NTC_DISCONNECT)
+
+/* SCSI related definition                                              */
+#define DISC_NOT_ALLOW          0x80	/* Disconnect is not allowed    */
+#define DISC_ALLOW              0xC0	/* Disconnect is allowed        */
+#define SCSICMD_RequestSense    0x03
+
+typedef struct _HCSinfo {
+	ULONG base;
+	UCHAR vec;
+	UCHAR bios;		/* High byte of BIOS address */
+	USHORT BaseAndBios;	/* high byte: pHcsInfo->bios,low byte:pHcsInfo->base */
+} HCSINFO;
+
+#define TUL_RD(x,y)             (UCHAR)(inb(  (int)((ULONG)(x+y)) ))
+#define TUL_RDLONG(x,y)         (ULONG)(inl((int)((ULONG)(x+y)) ))
+#define TUL_WR(     adr,data)   outb( (UCHAR)(data), (int)(adr))
+#define TUL_WRSHORT(adr,data)   outw( (UWORD)(data), (int)(adr))
+#define TUL_WRLONG( adr,data)   outl( (ULONG)(data), (int)(adr))
+
+#define SCSI_ABORT_SNOOZE 0
+#define SCSI_ABORT_SUCCESS 1
+#define SCSI_ABORT_PENDING 2
+#define SCSI_ABORT_BUSY 3
+#define SCSI_ABORT_NOT_RUNNING 4
+#define SCSI_ABORT_ERROR 5
+
+#define SCSI_RESET_SNOOZE 0
+#define SCSI_RESET_PUNT 1
+#define SCSI_RESET_SUCCESS 2
+#define SCSI_RESET_PENDING 3
+#define SCSI_RESET_WAKEUP 4
+#define SCSI_RESET_NOT_RUNNING 5
+#define SCSI_RESET_ERROR 6
+
+#define SCSI_RESET_SYNCHRONOUS		0x01
+#define SCSI_RESET_ASYNCHRONOUS		0x02
+#define SCSI_RESET_SUGGEST_BUS_RESET	0x04
+#define SCSI_RESET_SUGGEST_HOST_RESET	0x08
+
+#define SCSI_RESET_BUS_RESET 0x100
+#define SCSI_RESET_HOST_RESET 0x200
+#define SCSI_RESET_ACTION   0xff
+
+extern void init_i91uAdapter_table(void);
+extern int Addi91u_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE);
+extern int tul_ReturnNumberOfAdapters(void);
+extern void get_tulipPCIConfig(HCS * pHCB, int iChannel_index);
+extern int init_tulip(HCS * pHCB, SCB * pSCB, int tul_num_scb, BYTE * pbBiosAdr, int reset_time);
+extern SCB *tul_alloc_scb(HCS * pHCB);
+extern int tul_abort_srb(HCS * pHCB, struct scsi_cmnd * pSRB);
+extern void tul_exec_scb(HCS * pHCB, SCB * pSCB);
+extern void tul_release_scb(HCS * pHCB, SCB * pSCB);
+extern void tul_stop_bm(HCS * pHCB);
+extern int tul_reset_scsi(HCS * pCurHcb, int seconds);
+extern int tul_isr(HCS * pHCB);
+extern int tul_reset(HCS * pHCB, struct scsi_cmnd * pSRB, unsigned char target);
+extern int tul_reset_scsi_bus(HCS * pCurHcb);
+extern int tul_device_reset(HCS * pCurHcb, struct scsi_cmnd *pSrb,
+		unsigned int target, unsigned int ResetFlags);
+				/* ---- EXTERNAL VARIABLES ---- */
+extern HCS tul_hcs[];
diff -Nru a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
--- a/drivers/scsi/ipr.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/ipr.c	2004-12-24 13:37:43 -08:00
@@ -4935,7 +4935,7 @@
 	int rc;
 
 	ENTER;
-	rc = pci_restore_state(ioa_cfg->pdev, ioa_cfg->pci_cfg_buf);
+	rc = pci_restore_state(ioa_cfg->pdev);
 
 	if (rc != PCIBIOS_SUCCESSFUL) {
 		ipr_cmd->ioasa.ioasc = cpu_to_be32(IPR_IOASC_PCI_ACCESS_ERROR);
@@ -5433,7 +5433,7 @@
 
 	ENTER;
 	free_irq(pdev->irq, ioa_cfg);
-	iounmap((void *) ioa_cfg->hdw_dma_regs);
+	iounmap(ioa_cfg->hdw_dma_regs);
 	pci_release_regions(pdev);
 	ipr_free_mem(ioa_cfg);
 	scsi_host_put(ioa_cfg->host);
@@ -5624,6 +5624,10 @@
 static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
 				       struct Scsi_Host *host, struct pci_dev *pdev)
 {
+	const struct ipr_interrupt_offsets *p;
+	struct ipr_interrupts *t;
+	void __iomem *base;
+
 	ioa_cfg->host = host;
 	ioa_cfg->pdev = pdev;
 	ioa_cfg->log_level = ipr_log_level;
@@ -5655,17 +5659,19 @@
 	host->max_cmd_len = IPR_MAX_CDB_LEN;
 	pci_set_drvdata(pdev, ioa_cfg);
 
-	memcpy(&ioa_cfg->regs, &ioa_cfg->chip_cfg->regs, sizeof(ioa_cfg->regs));
-
-	ioa_cfg->regs.set_interrupt_mask_reg += ioa_cfg->hdw_dma_regs;
-	ioa_cfg->regs.clr_interrupt_mask_reg += ioa_cfg->hdw_dma_regs;
-	ioa_cfg->regs.sense_interrupt_mask_reg += ioa_cfg->hdw_dma_regs;
-	ioa_cfg->regs.clr_interrupt_reg += ioa_cfg->hdw_dma_regs;
-	ioa_cfg->regs.sense_interrupt_reg += ioa_cfg->hdw_dma_regs;
-	ioa_cfg->regs.ioarrin_reg += ioa_cfg->hdw_dma_regs;
-	ioa_cfg->regs.sense_uproc_interrupt_reg += ioa_cfg->hdw_dma_regs;
-	ioa_cfg->regs.set_uproc_interrupt_reg += ioa_cfg->hdw_dma_regs;
-	ioa_cfg->regs.clr_uproc_interrupt_reg += ioa_cfg->hdw_dma_regs;
+	p = &ioa_cfg->chip_cfg->regs;
+	t = &ioa_cfg->regs;
+	base = ioa_cfg->hdw_dma_regs;
+
+	t->set_interrupt_mask_reg = base + p->set_interrupt_mask_reg;
+	t->clr_interrupt_mask_reg = base + p->clr_interrupt_mask_reg;
+	t->sense_interrupt_mask_reg = base + p->sense_interrupt_mask_reg;
+	t->clr_interrupt_reg = base + p->clr_interrupt_reg;
+	t->sense_interrupt_reg = base + p->sense_interrupt_reg;
+	t->ioarrin_reg = base + p->ioarrin_reg;
+	t->sense_uproc_interrupt_reg = base + p->sense_uproc_interrupt_reg;
+	t->set_uproc_interrupt_reg = base + p->set_uproc_interrupt_reg;
+	t->clr_uproc_interrupt_reg = base + p->clr_uproc_interrupt_reg;
 }
 
 /**
@@ -5681,7 +5687,8 @@
 {
 	struct ipr_ioa_cfg *ioa_cfg;
 	struct Scsi_Host *host;
-	unsigned long ipr_regs, ipr_regs_pci;
+	unsigned long ipr_regs_pci;
+	void __iomem *ipr_regs;
 	u32 rc = PCIBIOS_SUCCESSFUL;
 
 	ENTER;
@@ -5715,8 +5722,7 @@
 		goto out_scsi_host_put;
 	}
 
-	ipr_regs = (unsigned long)ioremap(ipr_regs_pci,
-					  pci_resource_len(pdev, 0));
+	ipr_regs = ioremap(ipr_regs_pci, pci_resource_len(pdev, 0));
 
 	if (!ipr_regs) {
 		dev_err(&pdev->dev,
@@ -5749,7 +5755,7 @@
 	}
 
 	/* Save away PCI config space for use following IOA reset */
-	rc = pci_save_state(pdev, ioa_cfg->pci_cfg_buf);
+	rc = pci_save_state(pdev);
 
 	if (rc != PCIBIOS_SUCCESSFUL) {
 		dev_err(&pdev->dev, "Failed to save PCI config space\n");
@@ -5790,7 +5796,7 @@
 cleanup_nolog:
 	ipr_free_mem(ioa_cfg);
 cleanup_nomem:
-	iounmap((void *) ipr_regs);
+	iounmap(ipr_regs);
 out_release_regions:
 	pci_release_regions(pdev);
 out_scsi_host_put:
diff -Nru a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
--- a/drivers/scsi/ipr.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/ipr.h	2004-12-24 13:36:31 -08:00
@@ -749,7 +749,7 @@
 	struct ipr_supported_device supp_dev;
 };
 
-struct ipr_interrupts {
+struct ipr_interrupt_offsets {
 	unsigned long set_interrupt_mask_reg;
 	unsigned long clr_interrupt_mask_reg;
 	unsigned long sense_interrupt_mask_reg;
@@ -762,10 +762,23 @@
 	unsigned long clr_uproc_interrupt_reg;
 };
 
+struct ipr_interrupts {
+	void __iomem *set_interrupt_mask_reg;
+	void __iomem *clr_interrupt_mask_reg;
+	void __iomem *sense_interrupt_mask_reg;
+	void __iomem *clr_interrupt_reg;
+
+	void __iomem *sense_interrupt_reg;
+	void __iomem *ioarrin_reg;
+	void __iomem *sense_uproc_interrupt_reg;
+	void __iomem *set_uproc_interrupt_reg;
+	void __iomem *clr_uproc_interrupt_reg;
+};
+
 struct ipr_chip_cfg_t {
 	u32 mailbox;
 	u8 cache_line_size;
-	struct ipr_interrupts regs;
+	struct ipr_interrupt_offsets regs;
 };
 
 enum ipr_shutdown_type {
@@ -884,12 +897,11 @@
 
 	const struct ipr_chip_cfg_t *chip_cfg;
 
-	unsigned long hdw_dma_regs;	/* iomapped PCI memory space */
+	void __iomem *hdw_dma_regs;	/* iomapped PCI memory space */
 	unsigned long hdw_dma_regs_pci;	/* raw PCI memory space */
-	unsigned long ioa_mailbox;
+	void __iomem *ioa_mailbox;
 	struct ipr_interrupts regs;
 
-	u32 pci_cfg_buf[64];
 	u16 saved_pcix_cmd_reg;
 	u16 reset_retries;
 
diff -Nru a/drivers/scsi/ips.c b/drivers/scsi/ips.c
--- a/drivers/scsi/ips.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/ips.c	2004-12-24 13:36:16 -08:00
@@ -133,6 +133,10 @@
 /* 6.10.00  - Remove 1G Addressing Limitations                               */
 /* 6.11.xx  - Get VersionInfo buffer off the stack !              DDTS 60401 */
 /* 6.11.xx  - Make Logical Drive Info structure safe for DMA      DDTS 60639 */
+/* 7.10.xx  - Add highmem_io flag in SCSI Templete for 2.4 kernels           */
+/*          - Fix path/name for scsi_hosts.h include for 2.6 kernels         */
+/*          - Fix sort order of 7k                                           */
+/*          - Remove 3 unused "inline" functions                             */
 /*****************************************************************************/
 
 /*
@@ -176,7 +180,13 @@
 #include <scsi/sg.h>
 
 #include "scsi.h"
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
+#include "hosts.h"
+#else
 #include <scsi/scsi_host.h>
+#endif
+
 #include "ips.h"
 
 #include <linux/module.h>
@@ -191,14 +201,14 @@
 
 #ifdef MODULE
 static char *ips = NULL;
-MODULE_PARM(ips, "s");
+module_param(ips, charp, 0);
 #endif
 
 /*
  * DRIVER_VER
  */
-#define IPS_VERSION_HIGH        "7.00"
-#define IPS_VERSION_LOW         ".15 "
+#define IPS_VERSION_HIGH        "7.10"
+#define IPS_VERSION_LOW         ".18 "
 
 #if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__)
 #warning "This driver has only been tested on the x86/ia64/x86_64 platforms"
@@ -278,6 +288,9 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	.use_new_eh_code	= 1,
 #endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)  &&  LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+    .highmem_io          = 1,   
+#endif
 };
 
 IPS_DEFINE_COMPAT_TABLE( Compatable );	/* Version Compatability Table      */
@@ -6904,7 +6917,6 @@
 			for (j = position; j < ips_num_controllers; j++) {
 				switch (ips_ha[j]->ad_type) {
 				case IPS_ADTYPE_SERVERAID6M:
-				case IPS_ADTYPE_SERVERAID7k:
 				case IPS_ADTYPE_SERVERAID7M:
 					if (nvram->adapter_order[i] == 'M') {
 						ips_shift_controllers(position,
@@ -6925,6 +6937,7 @@
 				case IPS_ADTYPE_SERVERAID6I:
 				case IPS_ADTYPE_SERVERAID5I2:
 				case IPS_ADTYPE_SERVERAID5I1:
+				case IPS_ADTYPE_SERVERAID7k:
 					if (nvram->adapter_order[i] == 'S') {
 						ips_shift_controllers(position,
 								      j);
@@ -7162,8 +7175,8 @@
 	int j;
 	int index;
 	dma_addr_t dma_address;
-	char *ioremap_ptr;
-	char *mem_ptr;
+	char __iomem *ioremap_ptr;
+	char __iomem *mem_ptr;
 	uint32_t IsDead;
 
 	METHOD_TRACE("ips_init_phase1", 1);
@@ -7452,6 +7465,13 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
 MODULE_LICENSE("GPL");
 #endif
+
+MODULE_DESCRIPTION("IBM ServeRAID Adapter Driver " IPS_VER_STRING);
+
+#ifdef MODULE_VERSION
+MODULE_VERSION(IPS_VER_STRING);
+#endif
+
 
 /*
  * Overrides for Emacs so that we almost follow Linus's tabbing style.
diff -Nru a/drivers/scsi/ips.h b/drivers/scsi/ips.h
--- a/drivers/scsi/ips.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/ips.h	2004-12-24 13:36:31 -08:00
@@ -96,7 +96,11 @@
    #endif
 
    #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-      typedef void irqreturn_t;
+   
+      #ifndef irqreturn_t
+         typedef void irqreturn_t;
+      #endif 
+      
       #define IRQ_NONE
       #define IRQ_HANDLED
       #define IRQ_RETVAL(x)
@@ -1113,8 +1117,8 @@
    uint32_t           mem_addr;           /* Memory mapped address      */
    uint32_t           io_len;             /* Size of IO Address         */
    uint32_t           mem_len;            /* Size of memory address     */
-   char              *mem_ptr;            /* Memory mapped Ptr          */
-   char              *ioremap_ptr;        /* ioremapped memory pointer  */
+   char              __iomem *mem_ptr;    /* Memory mapped Ptr          */
+   char              __iomem *ioremap_ptr;/* ioremapped memory pointer  */
    ips_hw_func_t      func;               /* hw function pointers       */
    struct pci_dev    *pcidev;             /* PCI device handle          */
    char              *flash_data;         /* Save Area for flash data   */
@@ -1210,13 +1214,13 @@
 
 #define IPS_VER_MAJOR 7
 #define IPS_VER_MAJOR_STRING "7"
-#define IPS_VER_MINOR 00
-#define IPS_VER_MINOR_STRING "00"
-#define IPS_VER_BUILD 15
-#define IPS_VER_BUILD_STRING "15"
-#define IPS_VER_STRING "7.00.15"
+#define IPS_VER_MINOR 10
+#define IPS_VER_MINOR_STRING "10"
+#define IPS_VER_BUILD 18
+#define IPS_VER_BUILD_STRING "18"
+#define IPS_VER_STRING "7.10.18"
 #define IPS_RELEASE_ID 0x00020000
-#define IPS_BUILD_IDENT 625
+#define IPS_BUILD_IDENT 731
 #define IPS_LEGALCOPYRIGHT_STRING "(C) Copyright IBM Corp. 1994, 2002. All Rights Reserved."
 #define IPS_ADAPTECCOPYRIGHT_STRING "(c) Copyright Adaptec, Inc. 2002 to 2004. All Rights Reserved."
 #define IPS_DELLCOPYRIGHT_STRING "(c) Copyright Dell 2004. All Rights Reserved."
@@ -1227,32 +1231,35 @@
 #define IPS_VER_SERVERAID2 "2.88.13"
 #define IPS_VER_NAVAJO "2.88.13"
 #define IPS_VER_SERVERAID3 "6.10.24"
-#define IPS_VER_SERVERAID4H "7.00.15"
-#define IPS_VER_SERVERAID4MLx "7.00.15"
-#define IPS_VER_SARASOTA "7.00.15"
-#define IPS_VER_MARCO "7.00.15"
-#define IPS_VER_SEBRING "7.00.15"
+#define IPS_VER_SERVERAID4H "7.10.11"
+#define IPS_VER_SERVERAID4MLx "7.10.18"
+#define IPS_VER_SARASOTA "7.10.18"
+#define IPS_VER_MARCO "7.10.18"
+#define IPS_VER_SEBRING "7.10.18"
+#define IPS_VER_KEYWEST "7.10.18"
 
 /* Compatability IDs for various adapters */
 #define IPS_COMPAT_UNKNOWN ""
-#define IPS_COMPAT_CURRENT "SB610"
+#define IPS_COMPAT_CURRENT "KW710"
 #define IPS_COMPAT_SERVERAID1 "2.25.01"
 #define IPS_COMPAT_SERVERAID2 "2.88.13"
 #define IPS_COMPAT_NAVAJO  "2.88.13"
 #define IPS_COMPAT_KIOWA "2.88.13"
 #define IPS_COMPAT_SERVERAID3H  "SB610"
 #define IPS_COMPAT_SERVERAID3L  "SB610"
-#define IPS_COMPAT_SERVERAID4H  "SB610"
-#define IPS_COMPAT_SERVERAID4M  "SB610"
-#define IPS_COMPAT_SERVERAID4L  "SB610"
-#define IPS_COMPAT_SERVERAID4Mx "SB610"
-#define IPS_COMPAT_SERVERAID4Lx "SB610"
-#define IPS_COMPAT_SARASOTA     "SB610"
-#define IPS_COMPAT_MARCO        "SB610"
-#define IPS_COMPAT_SEBRING      "SB610"
-#define IPS_COMPAT_BIOS "SB610"
+#define IPS_COMPAT_SERVERAID4H  "KW710"
+#define IPS_COMPAT_SERVERAID4M  "KW710"
+#define IPS_COMPAT_SERVERAID4L  "KW710"
+#define IPS_COMPAT_SERVERAID4Mx "KW710"
+#define IPS_COMPAT_SERVERAID4Lx "KW710"
+#define IPS_COMPAT_SARASOTA     "KW710"
+#define IPS_COMPAT_MARCO        "KW710"
+#define IPS_COMPAT_SEBRING      "KW710"
+#define IPS_COMPAT_TAMPA        "KW710"
+#define IPS_COMPAT_KEYWEST      "KW710"
+#define IPS_COMPAT_BIOS "KW710"
 
-#define IPS_COMPAT_MAX_ADAPTER_TYPE 16
+#define IPS_COMPAT_MAX_ADAPTER_TYPE 18
 #define IPS_COMPAT_ID_LENGTH 8
 
 #define IPS_DEFINE_COMPAT_TABLE(tablename) \
@@ -1272,7 +1279,9 @@
       IPS_COMPAT_SARASOTA,         /* one-channel variety of SARASOTA */  \
       IPS_COMPAT_SARASOTA,         /* two-channel variety of SARASOTA */  \
       IPS_COMPAT_MARCO, \
-      IPS_COMPAT_SEBRING \
+      IPS_COMPAT_SEBRING, \
+      IPS_COMPAT_TAMPA, \
+      IPS_COMPAT_KEYWEST \
    }
 
 
diff -Nru a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c
--- a/drivers/scsi/jazz_esp.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/jazz_esp.c	2004-12-24 13:36:18 -08:00
@@ -286,7 +286,7 @@
 }
 
 static Scsi_Host_Template driver_template = {
-	.proc_name		= "esp",
+	.proc_name		= "jazz_esp",
 	.proc_info		= &esp_proc_info,
 	.name			= "ESP 100/100a/200",
 	.detect			= jazz_esp_detect,
diff -Nru a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c
--- a/drivers/scsi/lasi700.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/lasi700.c	2004-12-24 13:36:18 -08:00
@@ -50,6 +50,9 @@
 #include <asm/delay.h>
 
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
 
 #include "lasi700.h"
 #include "53c700.h"
@@ -104,29 +107,16 @@
 
 	NCR_700_set_mem_mapped(hostdata);
 
-	host = NCR_700_detect(&lasi700_template, hostdata);
+	host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev,
+			      dev->irq, 7);
 	if (!host)
 		goto out_kfree;
 
-	host->irq = dev->irq;
-	if (request_irq(dev->irq, NCR_700_intr, SA_SHIRQ,
-				dev->dev.bus_id, host)) {
-		printk(KERN_ERR "%s: irq problem, detaching\n",
-		       dev->dev.bus_id);
-		goto out_put_host;
-	}
-
-	if (scsi_add_host(host, &dev->dev))
-		goto out_free_irq;
 	dev_set_drvdata(&dev->dev, host);
 	scsi_scan_host(host);
 
 	return 0;
 
- out_free_irq:
-	free_irq(host->irq, host);
- out_put_host:
-	scsi_host_put(host);
  out_kfree:
 	kfree(hostdata);
 	return -ENODEV;
diff -Nru a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
--- a/drivers/scsi/libata-core.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/libata-core.c	2004-12-24 13:36:16 -08:00
@@ -39,6 +39,7 @@
 #include <linux/workqueue.h>
 #include <scsi/scsi.h>
 #include "scsi.h"
+#include "scsi_priv.h"
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <asm/io.h>
@@ -58,6 +59,7 @@
 				u8 *xfer_mode_out,
 				unsigned int *xfer_shift_out);
 static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat);
+static void __ata_qc_complete(struct ata_queued_cmd *qc);
 
 static unsigned int ata_unique_id = 1;
 static struct workqueue_struct *ata_wq;
@@ -65,6 +67,7 @@
 MODULE_AUTHOR("Jeff Garzik");
 MODULE_DESCRIPTION("Library module for ATA devices");
 MODULE_LICENSE("GPL");
+MODULE_VERSION(DRV_VERSION);
 
 /**
  *	ata_tf_load - send taskfile registers to host controller
@@ -579,7 +582,7 @@
 
 /**
  *	ata_udma_string - convert UDMA bit offset to string
- *	@udma_mask: mask of bits supported; only highest bit counts.
+ *	@mask: mask of bits supported; only highest bit counts.
  *
  *	Determine string which represents the highest speed
  *	(highest bit in @udma_mask).
@@ -816,7 +819,7 @@
 
 /**
  *	ata_dev_id_string - Convert IDENTIFY DEVICE page into string
- *	@dev: Device whose IDENTIFY DEVICE results we will examine
+ *	@id: IDENTIFY DEVICE results we will examine
  *	@s: string into which data is output
  *	@ofs: offset into identify device page
  *	@len: length of string to return. must be an even number.
@@ -829,17 +832,17 @@
  *	caller.
  */
 
-void ata_dev_id_string(struct ata_device *dev, unsigned char *s,
+void ata_dev_id_string(u16 *id, unsigned char *s,
 		       unsigned int ofs, unsigned int len)
 {
 	unsigned int c;
 
 	while (len > 0) {
-		c = dev->id[ofs] >> 8;
+		c = id[ofs] >> 8;
 		*s = c;
 		s++;
 
-		c = dev->id[ofs] & 0xff;
+		c = id[ofs] & 0xff;
 		*s = c;
 		s++;
 
@@ -1015,7 +1018,7 @@
 	BUG_ON(qc == NULL);
 
 	ata_sg_init_one(qc, dev->id, sizeof(dev->id));
-	qc->pci_dma_dir = PCI_DMA_FROMDEVICE;
+	qc->dma_dir = DMA_FROM_DEVICE;
 	qc->tf.protocol = ATA_PROT_PIO;
 	qc->nsect = 1;
 
@@ -1082,7 +1085,7 @@
 	 */
 
 	/* we require LBA and DMA support (bits 8 & 9 of word 49) */
-	if (!ata_id_has_dma(dev) || !ata_id_has_lba(dev)) {
+	if (!ata_id_has_dma(dev->id) || !ata_id_has_lba(dev->id)) {
 		printk(KERN_DEBUG "ata%u: no dma/lba\n", ap->id);
 		goto err_out_nosup;
 	}
@@ -1100,7 +1103,7 @@
 
 	/* ATA-specific feature tests */
 	if (dev->class == ATA_DEV_ATA) {
-		if (!ata_id_is_ata(dev))	/* sanity check */
+		if (!ata_id_is_ata(dev->id))	/* sanity check */
 			goto err_out_nosup;
 
 		tmp = dev->id[ATA_ID_MAJOR_VER];
@@ -1114,11 +1117,11 @@
 			goto err_out_nosup;
 		}
 
-		if (ata_id_has_lba48(dev)) {
+		if (ata_id_has_lba48(dev->id)) {
 			dev->flags |= ATA_DFLAG_LBA48;
-			dev->n_sectors = ata_id_u64(dev, 100);
+			dev->n_sectors = ata_id_u64(dev->id, 100);
 		} else {
-			dev->n_sectors = ata_id_u32(dev, 60);
+			dev->n_sectors = ata_id_u32(dev->id, 60);
 		}
 
 		ap->host->max_cmd_len = 16;
@@ -1133,7 +1136,7 @@
 
 	/* ATAPI-specific feature tests */
 	else {
-		if (ata_id_is_ata(dev))		/* sanity check */
+		if (ata_id_is_ata(dev->id))		/* sanity check */
 			goto err_out_nosup;
 
 		rc = atapi_cdb_len(dev->id);
@@ -1763,8 +1766,10 @@
 }
 
 /**
- *	ata_choose_xfer_mode -
- *	@ap:
+ *	ata_choose_xfer_mode - attempt to find best transfer mode
+ *	@ap: Port for which an xfer mode will be selected
+ *	@xfer_mode_out: (output) SET FEATURES - XFER MODE code
+ *	@xfer_shift_out: (output) bit shift that selects this mode
  *
  *	LOCKING:
  *
@@ -1847,7 +1852,7 @@
 {
 	struct ata_port *ap = qc->ap;
 	struct scatterlist *sg = qc->sg;
-	int dir = qc->pci_dma_dir;
+	int dir = qc->dma_dir;
 
 	assert(qc->flags & ATA_QCFLAG_DMAMAP);
 	assert(sg != NULL);
@@ -1858,9 +1863,9 @@
 	DPRINTK("unmapping %u sg elements\n", qc->n_elem);
 
 	if (qc->flags & ATA_QCFLAG_SG)
-		pci_unmap_sg(ap->host_set->pdev, sg, qc->n_elem, dir);
+		dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir);
 	else
-		pci_unmap_single(ap->host_set->pdev, sg_dma_address(&sg[0]),
+		dma_unmap_single(ap->host_set->dev, sg_dma_address(&sg[0]),
 				 sg_dma_len(&sg[0]), dir);
 
 	qc->flags &= ~ATA_QCFLAG_DMAMAP;
@@ -1945,8 +1950,6 @@
 	sg->page = virt_to_page(buf);
 	sg->offset = (unsigned long) buf & ~PAGE_MASK;
 	sg_dma_len(sg) = buflen;
-
-	WARN_ON(buflen > PAGE_SIZE);
 }
 
 void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
@@ -1971,13 +1974,13 @@
 static int ata_sg_setup_one(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
-	int dir = qc->pci_dma_dir;
+	int dir = qc->dma_dir;
 	struct scatterlist *sg = qc->sg;
 	dma_addr_t dma_address;
 
-	dma_address = pci_map_single(ap->host_set->pdev, qc->buf_virt,
+	dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt,
 				     sg_dma_len(sg), dir);
-	if (pci_dma_mapping_error(dma_address))
+	if (dma_mapping_error(dma_address))
 		return -1;
 
 	sg_dma_address(sg) = dma_address;
@@ -2008,8 +2011,8 @@
 	VPRINTK("ENTER, ata%u\n", ap->id);
 	assert(qc->flags & ATA_QCFLAG_SG);
 
-	dir = qc->pci_dma_dir;
-	n_elem = pci_map_sg(ap->host_set->pdev, sg, qc->n_elem, dir);
+	dir = qc->dma_dir;
+	n_elem = dma_map_sg(ap->host_set->dev, sg, qc->n_elem, dir);
 	if (n_elem < 1)
 		return -1;
 
@@ -2167,14 +2170,20 @@
 	struct scatterlist *sg = qc->sg;
 	struct ata_port *ap = qc->ap;
 	struct page *page;
+	unsigned int offset;
 	unsigned char *buf;
 
 	if (qc->cursect == (qc->nsect - 1))
 		ap->pio_task_state = PIO_ST_LAST;
 
 	page = sg[qc->cursg].page;
-	buf = kmap(page) +
-	      sg[qc->cursg].offset + (qc->cursg_ofs * ATA_SECT_SIZE);
+	offset = sg[qc->cursg].offset + qc->cursg_ofs * ATA_SECT_SIZE;
+
+	/* get the current page and offset */
+	page = nth_page(page, (offset >> PAGE_SHIFT));
+	offset %= PAGE_SIZE;
+
+	buf = kmap(page) + offset;
 
 	qc->cursect++;
 	qc->cursg_ofs++;
@@ -2193,11 +2202,64 @@
 	kunmap(page);
 }
 
-static void atapi_pio_sector(struct ata_queued_cmd *qc)
+static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
+{
+	int do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
+	struct scatterlist *sg = qc->sg;
+	struct ata_port *ap = qc->ap;
+	struct page *page;
+	unsigned char *buf;
+	unsigned int offset, count;
+
+	if (qc->curbytes == qc->nbytes - bytes)
+		ap->pio_task_state = PIO_ST_LAST;
+
+next_sg:
+	sg = &qc->sg[qc->cursg];
+
+next_page:
+	page = sg->page;
+	offset = sg->offset + qc->cursg_ofs;
+
+	/* get the current page and offset */
+	page = nth_page(page, (offset >> PAGE_SHIFT));
+	offset %= PAGE_SIZE;
+
+	count = min(sg_dma_len(sg) - qc->cursg_ofs, bytes);
+
+	/* don't cross page boundaries */
+	count = min(count, (unsigned int)PAGE_SIZE - offset);
+
+	buf = kmap(page) + offset;
+
+	bytes -= count;
+	qc->curbytes += count;
+	qc->cursg_ofs += count;
+
+	if (qc->cursg_ofs == sg_dma_len(sg)) {
+		qc->cursg++;
+		qc->cursg_ofs = 0;
+	}
+
+	DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
+
+	/* do the actual data transfer */
+	ata_data_xfer(ap, buf, count, do_write);
+
+	kunmap(page);
+
+	if (bytes) {
+		if (qc->cursg_ofs < sg_dma_len(sg))
+			goto next_page;
+		goto next_sg;
+	}
+}
+
+static void atapi_pio_bytes(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
 	struct ata_device *dev = qc->dev;
-	unsigned int i, ireason, bc_lo, bc_hi, bytes;
+	unsigned int ireason, bc_lo, bc_hi, bytes;
 	int i_write, do_write = (qc->tf.flags & ATA_TFLAG_WRITE) ? 1 : 0;
 
 	ap->ops->tf_read(ap, &qc->tf);
@@ -2215,16 +2277,7 @@
 	if (do_write != i_write)
 		goto err_out;
 
-	/* make sure byte count is multiple of sector size; not
-	* required by standard (warning! warning!), but IDE driver
-	* does this to simplify things a bit.  We are lazy, and
-	* follow suit.
-	*/
-	if (bytes & (ATA_SECT_SIZE - 1))
-		goto err_out;
-
-	for (i = 0; i < (bytes >> 9); i++)
-		ata_pio_sector(qc);
+	__atapi_pio_bytes(qc, bytes);
 
 	return;
 
@@ -2265,19 +2318,30 @@
 		}
 	}
 
-	/* handle BSY=0, DRQ=0 as error */
-	if ((status & ATA_DRQ) == 0) {
-		ap->pio_task_state = PIO_ST_ERR;
-		return;
-	}
-
 	qc = ata_qc_from_tag(ap, ap->active_tag);
 	assert(qc != NULL);
 
-	if (is_atapi_taskfile(&qc->tf))
-		atapi_pio_sector(qc);
-	else
+	if (is_atapi_taskfile(&qc->tf)) {
+		/* no more data to transfer or unsupported ATAPI command */
+		if ((status & ATA_DRQ) == 0) {
+			ap->pio_task_state = PIO_ST_IDLE;
+
+			ata_irq_on(ap);
+
+			ata_qc_complete(qc, status);
+			return;
+		}
+
+		atapi_pio_bytes(qc);
+	} else {
+		/* handle BSY=0, DRQ=0 as error */
+		if ((status & ATA_DRQ) == 0) {
+			ap->pio_task_state = PIO_ST_ERR;
+			return;
+		}
+
 		ata_pio_sector(qc);
+	}
 }
 
 static void ata_pio_error(struct ata_port *ap)
@@ -2335,6 +2399,59 @@
 	}
 }
 
+static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
+				struct scsi_cmnd *cmd)
+{
+	DECLARE_COMPLETION(wait);
+	struct ata_queued_cmd *qc;
+	unsigned long flags;
+	int using_pio = dev->flags & ATA_DFLAG_PIO;
+	int rc;
+
+	DPRINTK("ATAPI request sense\n");
+
+	qc = ata_qc_new_init(ap, dev);
+	BUG_ON(qc == NULL);
+
+	/* FIXME: is this needed? */
+	memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
+
+	ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
+	qc->dma_dir = DMA_FROM_DEVICE;
+
+	memset(&qc->cdb, 0, sizeof(ap->cdb_len));
+	qc->cdb[0] = REQUEST_SENSE;
+	qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
+
+	qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+	qc->tf.command = ATA_CMD_PACKET;
+
+	if (using_pio) {
+		qc->tf.protocol = ATA_PROT_ATAPI;
+		qc->tf.lbam = (8 * 1024) & 0xff;
+		qc->tf.lbah = (8 * 1024) >> 8;
+
+		qc->nbytes = SCSI_SENSE_BUFFERSIZE;
+	} else {
+		qc->tf.protocol = ATA_PROT_ATAPI_DMA;
+		qc->tf.feature |= ATAPI_PKT_DMA;
+	}
+
+	qc->waiting = &wait;
+	qc->complete_fn = ata_qc_complete_noop;
+
+	spin_lock_irqsave(&ap->host_set->lock, flags);
+	rc = ata_qc_issue(qc);
+	spin_unlock_irqrestore(&ap->host_set->lock, flags);
+
+	if (rc)
+		ata_port_disable(ap);
+	else
+		wait_for_completion(&wait);
+
+	DPRINTK("EXIT\n");
+}
+
 /**
  *	ata_qc_timeout - Handle timeout of queued command
  *	@qc: Command that timed out
@@ -2356,10 +2473,29 @@
 static void ata_qc_timeout(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
+	struct ata_device *dev = qc->dev;
 	u8 host_stat = 0, drv_stat;
 
 	DPRINTK("ENTER\n");
 
+	/* FIXME: doesn't this conflict with timeout handling? */
+	if (qc->dev->class == ATA_DEV_ATAPI && qc->scsicmd) {
+		struct scsi_cmnd *cmd = qc->scsicmd;
+
+		if (!scsi_eh_eflags_chk(cmd, SCSI_EH_CANCEL_CMD)) {
+
+			/* finish completing original command */
+			__ata_qc_complete(qc);
+
+			atapi_request_sense(ap, dev, cmd);
+
+			cmd->result = (CHECK_CONDITION << 1) | (DID_OK << 16);
+			scsi_finish_command(cmd);
+
+			goto out;
+		}
+	}
+
 	/* hack alert!  We cannot use the supplied completion
 	 * function from inside the ->eh_strategy_handler() thread.
 	 * libata is the only user of ->eh_strategy_handler() in
@@ -2393,7 +2529,7 @@
 		ata_qc_complete(qc, drv_stat);
 		break;
 	}
-
+out:
 	DPRINTK("EXIT\n");
 }
 
@@ -2482,6 +2618,7 @@
 		qc->dev = dev;
 		qc->cursect = qc->cursg = qc->cursg_ofs = 0;
 		qc->nsect = 0;
+		qc->nbytes = qc->curbytes = 0;
 
 		ata_tf_init(ap, &qc->tf, dev->devno);
 
@@ -2497,6 +2634,30 @@
 	return 0;
 }
 
+static void __ata_qc_complete(struct ata_queued_cmd *qc)
+{
+	struct ata_port *ap = qc->ap;
+	unsigned int tag, do_clear = 0;
+
+	qc->flags = 0;
+	tag = qc->tag;
+	if (likely(ata_tag_valid(tag))) {
+		if (tag == ap->active_tag)
+			ap->active_tag = ATA_TAG_POISON;
+		qc->tag = ATA_TAG_POISON;
+		do_clear = 1;
+	}
+
+	if (qc->waiting) {
+		struct completion *waiting = qc->waiting;
+		qc->waiting = NULL;
+		complete(waiting);
+	}
+
+	if (likely(do_clear))
+		clear_bit(tag, &ap->qactive);
+}
+
 /**
  *	ata_qc_complete - Complete an active ATA command
  *	@qc: Command to complete
@@ -2508,8 +2669,6 @@
 
 void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
 {
-	struct ata_port *ap = qc->ap;
-	unsigned int tag, do_clear = 0;
 	int rc;
 
 	assert(qc != NULL);	/* ata_qc_from_tag _might_ return NULL */
@@ -2527,25 +2686,33 @@
 	if (rc != 0)
 		return;
 
-	qc->flags = 0;
-	tag = qc->tag;
-	if (likely(ata_tag_valid(tag))) {
-		if (tag == ap->active_tag)
-			ap->active_tag = ATA_TAG_POISON;
-		qc->tag = ATA_TAG_POISON;
-		do_clear = 1;
-	}
+	__ata_qc_complete(qc);
 
-	if (qc->waiting) {
-		struct completion *waiting = qc->waiting;
-		qc->waiting = NULL;
-		complete(waiting);
-	}
+	VPRINTK("EXIT\n");
+}
 
-	if (likely(do_clear))
-		clear_bit(tag, &ap->qactive);
+static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
+{
+	struct ata_port *ap = qc->ap;
 
-	VPRINTK("EXIT\n");
+	switch (qc->tf.protocol) {
+	case ATA_PROT_DMA:
+	case ATA_PROT_ATAPI_DMA:
+		return 1;
+
+	case ATA_PROT_ATAPI:
+	case ATA_PROT_PIO:
+	case ATA_PROT_PIO_MULT:
+		if (ap->flags & ATA_FLAG_PIO_DMA)
+			return 1;
+
+		/* fall through */
+	
+	default:
+		return 0;
+	}
+
+	/* never reached */
 }
 
 /**
@@ -2568,12 +2735,16 @@
 {
 	struct ata_port *ap = qc->ap;
 
-	if (qc->flags & ATA_QCFLAG_SG) {
-		if (ata_sg_setup(qc))
-			goto err_out;
-	} else if (qc->flags & ATA_QCFLAG_SINGLE) {
-		if (ata_sg_setup_one(qc))
-			goto err_out;
+	if (ata_should_dma_map(qc)) {
+		if (qc->flags & ATA_QCFLAG_SG) {
+			if (ata_sg_setup(qc))
+				goto err_out;
+		} else if (qc->flags & ATA_QCFLAG_SINGLE) {
+			if (ata_sg_setup_one(qc))
+				goto err_out;
+		}
+	} else {
+		qc->flags &= ~ATA_QCFLAG_DMAMAP;
 	}
 
 	ap->ops->qc_prep(qc);
@@ -2962,9 +3133,9 @@
 
 int ata_port_start (struct ata_port *ap)
 {
-	struct pci_dev *pdev = ap->host_set->pdev;
+	struct device *dev = ap->host_set->dev;
 
-	ap->prd = pci_alloc_consistent(pdev, ATA_PRD_TBL_SZ, &ap->prd_dma);
+	ap->prd = dma_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, GFP_KERNEL);
 	if (!ap->prd)
 		return -ENOMEM;
 
@@ -2975,9 +3146,9 @@
 
 void ata_port_stop (struct ata_port *ap)
 {
-	struct pci_dev *pdev = ap->host_set->pdev;
+	struct device *dev = ap->host_set->dev;
 
-	pci_free_consistent(pdev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
+	dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
 }
 
 /**
@@ -3023,7 +3194,7 @@
 	host->max_channel = 1;
 	host->unique_id = ata_unique_id++;
 	host->max_cmd_len = 12;
-	scsi_set_device(host, &ent->pdev->dev);
+	scsi_set_device(host, ent->dev);
 	scsi_assign_lock(host, &host_set->lock);
 
 	ap->flags = ATA_FLAG_PORT_DISABLED;
@@ -3032,6 +3203,8 @@
 	ap->ctl = ATA_DEVCTL_OBS;
 	ap->host_set = host_set;
 	ap->port_no = port_no;
+	ap->hard_port_no =
+		ent->legacy_mode ? ent->hard_port_no : port_no;
 	ap->pio_mask = ent->pio_mask;
 	ap->mwdma_mask = ent->mwdma_mask;
 	ap->udma_mask = ent->udma_mask;
@@ -3108,7 +3281,7 @@
 int ata_device_add(struct ata_probe_ent *ent)
 {
 	unsigned int count = 0, i;
-	struct pci_dev *pdev = ent->pdev;
+	struct device *dev = ent->dev;
 	struct ata_host_set *host_set;
 
 	DPRINTK("ENTER\n");
@@ -3120,7 +3293,7 @@
 	memset(host_set, 0, sizeof(struct ata_host_set) + (ent->n_ports * sizeof(void *)));
 	spin_lock_init(&host_set->lock);
 
-	host_set->pdev = pdev;
+	host_set->dev = dev;
 	host_set->n_ports = ent->n_ports;
 	host_set->irq = ent->irq;
 	host_set->mmio_base = ent->mmio_base;
@@ -3188,7 +3361,7 @@
 			 */
 		}
 
-		rc = scsi_add_host(ap->host, &pdev->dev);
+		rc = scsi_add_host(ap->host, dev);
 		if (rc) {
 			printk(KERN_ERR "ata%u: scsi_add_host failed\n",
 			       ap->id);
@@ -3208,7 +3381,7 @@
 		scsi_scan_host(ap->host);
 	}
 
-	pci_set_drvdata(pdev, host_set);
+	dev_set_drvdata(dev, host_set);
 
 	VPRINTK("EXIT, returning %u\n", ent->n_ports);
 	return ent->n_ports; /* success */
@@ -3269,7 +3442,7 @@
 }
 
 static struct ata_probe_ent *
-ata_probe_ent_alloc(int n, struct pci_dev *pdev, struct ata_port_info **port)
+ata_probe_ent_alloc(int n, struct device *dev, struct ata_port_info **port)
 {
 	struct ata_probe_ent *probe_ent;
 	int i;
@@ -3277,7 +3450,7 @@
 	probe_ent = kmalloc(sizeof(*probe_ent) * n, GFP_KERNEL);
 	if (!probe_ent) {
 		printk(KERN_ERR DRV_NAME "(%s): out of memory\n",
-		       pci_name(pdev));
+		       kobject_name(&(dev->kobj)));
 		return NULL;
 	}
 
@@ -3285,7 +3458,7 @@
 
 	for (i = 0; i < n; i++) {
 		INIT_LIST_HEAD(&probe_ent[i].node);
-		probe_ent[i].pdev = pdev;
+		probe_ent[i].dev = dev;
 
 		probe_ent[i].sht = port[i]->sht;
 		probe_ent[i].host_flags = port[i]->host_flags;
@@ -3299,10 +3472,12 @@
 	return probe_ent;
 }
 
+#ifdef CONFIG_PCI
 struct ata_probe_ent *
 ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port)
 {
-	struct ata_probe_ent *probe_ent = ata_probe_ent_alloc(1, pdev, port);
+	struct ata_probe_ent *probe_ent =
+		ata_probe_ent_alloc(1, pci_dev_to_dev(pdev), port);
 	if (!probe_ent)
 		return NULL;
 
@@ -3331,16 +3506,23 @@
 struct ata_probe_ent *
 ata_pci_init_legacy_mode(struct pci_dev *pdev, struct ata_port_info **port)
 {
-	struct ata_probe_ent *probe_ent = ata_probe_ent_alloc(2, pdev, port);
+	struct ata_probe_ent *probe_ent =
+		ata_probe_ent_alloc(2, pci_dev_to_dev(pdev), port);
 	if (!probe_ent)
 		return NULL;
 
 	probe_ent[0].n_ports = 1;
 	probe_ent[0].irq = 14;
 
+	probe_ent[0].hard_port_no = 0;
+	probe_ent[0].legacy_mode = 1;
+
 	probe_ent[1].n_ports = 1;
 	probe_ent[1].irq = 15;
 
+	probe_ent[1].hard_port_no = 1;
+	probe_ent[1].legacy_mode = 1;
+
 	probe_ent[0].port[0].cmd_addr = 0x1f0;
 	probe_ent[0].port[0].altstatus_addr =
 	probe_ent[0].port[0].ctl_addr = 0x3f6;
@@ -3501,7 +3683,8 @@
 
 void ata_pci_remove_one (struct pci_dev *pdev)
 {
-	struct ata_host_set *host_set = pci_get_drvdata(pdev);
+	struct device *dev = pci_dev_to_dev(pdev);
+	struct ata_host_set *host_set = dev_get_drvdata(dev);
 	struct ata_port *ap;
 	unsigned int i;
 
@@ -3542,7 +3725,7 @@
 
 	kfree(host_set);
 	pci_disable_device(pdev);
-	pci_set_drvdata(pdev, NULL);
+	dev_set_drvdata(dev, NULL);
 }
 
 /* move to PCI subsystem */
@@ -3578,6 +3761,7 @@
 
 	return (tmp == bits->val) ? 1 : 0;
 }
+#endif /* CONFIG_PCI */
 
 
 /**
@@ -3614,7 +3798,6 @@
  * Do not depend on ABI/API stability.
  */
 
-EXPORT_SYMBOL_GPL(pci_test_config_bits);
 EXPORT_SYMBOL_GPL(ata_std_bios_param);
 EXPORT_SYMBOL_GPL(ata_std_ports);
 EXPORT_SYMBOL_GPL(ata_device_add);
@@ -3629,8 +3812,6 @@
 EXPORT_SYMBOL_GPL(ata_std_dev_select);
 EXPORT_SYMBOL_GPL(ata_tf_to_fis);
 EXPORT_SYMBOL_GPL(ata_tf_from_fis);
-EXPORT_SYMBOL_GPL(ata_pci_init_legacy_mode);
-EXPORT_SYMBOL_GPL(ata_pci_init_native_mode);
 EXPORT_SYMBOL_GPL(ata_check_status);
 EXPORT_SYMBOL_GPL(ata_exec_command);
 EXPORT_SYMBOL_GPL(ata_port_start);
@@ -3645,8 +3826,6 @@
 EXPORT_SYMBOL_GPL(__sata_phy_reset);
 EXPORT_SYMBOL_GPL(ata_bus_reset);
 EXPORT_SYMBOL_GPL(ata_port_disable);
-EXPORT_SYMBOL_GPL(ata_pci_init_one);
-EXPORT_SYMBOL_GPL(ata_pci_remove_one);
 EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
 EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
 EXPORT_SYMBOL_GPL(ata_scsi_error);
@@ -3655,3 +3834,12 @@
 EXPORT_SYMBOL_GPL(ata_host_intr);
 EXPORT_SYMBOL_GPL(ata_dev_classify);
 EXPORT_SYMBOL_GPL(ata_dev_id_string);
+EXPORT_SYMBOL_GPL(ata_scsi_simulate);
+
+#ifdef CONFIG_PCI
+EXPORT_SYMBOL_GPL(pci_test_config_bits);
+EXPORT_SYMBOL_GPL(ata_pci_init_legacy_mode);
+EXPORT_SYMBOL_GPL(ata_pci_init_native_mode);
+EXPORT_SYMBOL_GPL(ata_pci_init_one);
+EXPORT_SYMBOL_GPL(ata_pci_remove_one);
+#endif /* CONFIG_PCI */
diff -Nru a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
--- a/drivers/scsi/libata-scsi.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/libata-scsi.c	2004-12-24 13:36:48 -08:00
@@ -34,9 +34,6 @@
 #include "libata.h"
 
 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, u8 *scsicmd);
-static void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev,
-			      struct scsi_cmnd *cmd,
-			      void (*done)(struct scsi_cmnd *));
 static struct ata_device *
 ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev);
 
@@ -100,7 +97,7 @@
 		return 0;
 
 	default:
-		rc = -EOPNOTSUPP;
+		rc = -ENOTTY;
 		break;
 	}
 
@@ -159,6 +156,7 @@
 /**
  *	ata_to_sense_error - convert ATA error to SCSI error
  *	@qc: Command that we are erroring out
+ *	@drv_stat: value contained in ATA status register
  *
  *	Converts an ATA error into a SCSI error. While we are at it
  *	we decode and dump the ATA error for the user so that they
@@ -411,7 +409,7 @@
 	tf->protocol = ATA_PROT_NODATA;
 
 	if ((tf->flags & ATA_TFLAG_LBA48) &&
-	    (ata_id_has_flush_ext(qc->dev)))
+	    (ata_id_has_flush_ext(qc->dev->id)))
 		tf->command = ATA_CMD_FLUSH_EXT;
 	else
 		tf->command = ATA_CMD_FLUSH;
@@ -681,7 +679,7 @@
 			ata_sg_init_one(qc, cmd->request_buffer,
 					cmd->request_bufflen);
 
-		qc->pci_dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction);
+		qc->dma_dir = cmd->sc_data_direction;
 	}
 
 	qc->complete_fn = ata_scsi_qc_complete;
@@ -731,7 +729,6 @@
 		buflen = cmd->request_bufflen;
 	}
 
-	memset(buf, 0, buflen);
 	*buf_out = buf;
 	return buflen;
 }
@@ -739,6 +736,7 @@
 /**
  *	ata_scsi_rbuf_put - Unmap response buffer.
  *	@cmd: SCSI command containing buffer to be unmapped.
+ *	@buf: buffer to unmap
  *
  *	Unmaps response buffer contained within @cmd.
  *
@@ -746,19 +744,19 @@
  *	spin_lock_irqsave(host_set lock)
  */
 
-static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd)
+static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
 {
 	if (cmd->use_sg) {
 		struct scatterlist *sg;
 
 		sg = (struct scatterlist *) cmd->request_buffer;
-		kunmap_atomic(sg->page, KM_USER0);
+		kunmap_atomic(buf - sg->offset, KM_USER0);
 	}
 }
 
 /**
  *	ata_scsi_rbuf_fill - wrapper for SCSI command simulators
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@actor: Callback hook for desired SCSI command simulator
  *
  *	Takes care of the hard work of simulating a SCSI command...
@@ -780,8 +778,9 @@
 	struct scsi_cmnd *cmd = args->cmd;
 
 	buflen = ata_scsi_rbuf_get(cmd, &rbuf);
+	memset(rbuf, 0, buflen);
 	rc = actor(args, rbuf, buflen);
-	ata_scsi_rbuf_put(cmd);
+	ata_scsi_rbuf_put(cmd, rbuf);
 
 	if (rc)
 		ata_bad_cdb(cmd, args->done);
@@ -793,7 +792,7 @@
 
 /**
  *	ata_scsiop_inq_std - Simulate INQUIRY command
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
@@ -807,8 +806,6 @@
 unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
 			       unsigned int buflen)
 {
-	struct ata_device *dev = args->dev;
-
 	u8 hdr[] = {
 		TYPE_DISK,
 		0,
@@ -818,7 +815,7 @@
 	};
 
 	/* set scsi removeable (RMB) bit per ata bit */
-	if (ata_id_removeable(dev))
+	if (ata_id_removeable(args->id))
 		hdr[1] |= (1 << 7);
 
 	VPRINTK("ENTER\n");
@@ -827,8 +824,8 @@
 
 	if (buflen > 35) {
 		memcpy(&rbuf[8], "ATA     ", 8);
-		ata_dev_id_string(dev, &rbuf[16], ATA_ID_PROD_OFS, 16);
-		ata_dev_id_string(dev, &rbuf[32], ATA_ID_FW_REV_OFS, 4);
+		ata_dev_id_string(args->id, &rbuf[16], ATA_ID_PROD_OFS, 16);
+		ata_dev_id_string(args->id, &rbuf[32], ATA_ID_FW_REV_OFS, 4);
 		if (rbuf[32] == 0 || rbuf[32] == ' ')
 			memcpy(&rbuf[32], "n/a ", 4);
 	}
@@ -852,7 +849,7 @@
 
 /**
  *	ata_scsiop_inq_00 - Simulate INQUIRY EVPD page 0, list of pages
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
@@ -880,7 +877,7 @@
 
 /**
  *	ata_scsiop_inq_80 - Simulate INQUIRY EVPD page 80, device serial number
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
@@ -901,8 +898,8 @@
 	};
 	memcpy(rbuf, hdr, sizeof(hdr));
 
-	if (buflen > (ATA_SERNO_LEN + 4))
-		ata_dev_id_string(args->dev, (unsigned char *) &rbuf[4],
+	if (buflen > (ATA_SERNO_LEN + 4 - 1))
+		ata_dev_id_string(args->id, (unsigned char *) &rbuf[4],
 				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
 
 	return 0;
@@ -912,7 +909,7 @@
 
 /**
  *	ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
@@ -930,7 +927,7 @@
 	rbuf[3] = 4 + strlen(inq_83_str);	/* page len */
 
 	/* our one and only identification descriptor (vendor-specific) */
-	if (buflen > (strlen(inq_83_str) + 4 + 4)) {
+	if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
 		rbuf[4 + 0] = 2;	/* code set: ASCII */
 		rbuf[4 + 3] = strlen(inq_83_str);
 		memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
@@ -941,7 +938,7 @@
 
 /**
  *	ata_scsiop_noop -
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
@@ -989,7 +986,7 @@
 
 /**
  *	ata_msense_caching - Simulate MODE SENSE caching info page
- *	@dev: Device associated with this MODE SENSE command
+ *	@id: device IDENTIFY data
  *	@ptr_io: (input/output) Location to store more output data
  *	@last: End of output data buffer
  *
@@ -1001,7 +998,7 @@
  *	None.
  */
 
-static unsigned int ata_msense_caching(struct ata_device *dev, u8 **ptr_io,
+static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io,
 				       const u8 *last)
 {
 	u8 page[] = {
@@ -1011,9 +1008,9 @@
 		0, 0, 0, 0, 0, 0, 0, 0		/* 8 zeroes */
 	};
 
-	if (ata_id_wcache_enabled(dev))
+	if (ata_id_wcache_enabled(id))
 		page[2] |= (1 << 2);	/* write cache enable */
-	if (!ata_id_rahead_enabled(dev))
+	if (!ata_id_rahead_enabled(id))
 		page[12] |= (1 << 5);	/* disable read ahead */
 
 	ata_msense_push(ptr_io, last, page, sizeof(page));
@@ -1067,7 +1064,7 @@
 
 /**
  *	ata_scsiop_mode_sense - Simulate MODE SENSE 6, 10 commands
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
@@ -1081,7 +1078,6 @@
 				  unsigned int buflen)
 {
 	u8 *scsicmd = args->cmd->cmnd, *p, *last;
-	struct ata_device *dev = args->dev;
 	unsigned int page_control, six_byte, output_len;
 
 	VPRINTK("ENTER\n");
@@ -1109,7 +1105,7 @@
 		break;
 
 	case 0x08:		/* caching */
-		output_len += ata_msense_caching(dev, &p, last);
+		output_len += ata_msense_caching(args->id, &p, last);
 		break;
 
 	case 0x0a: {		/* control mode */
@@ -1119,7 +1115,7 @@
 
 	case 0x3f:		/* all pages */
 		output_len += ata_msense_rw_recovery(&p, last);
-		output_len += ata_msense_caching(dev, &p, last);
+		output_len += ata_msense_caching(args->id, &p, last);
 		output_len += ata_msense_ctl_mode(&p, last);
 		break;
 
@@ -1141,7 +1137,7 @@
 
 /**
  *	ata_scsiop_read_cap - Simulate READ CAPACITY[ 16] commands
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
@@ -1154,11 +1150,15 @@
 unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
 			        unsigned int buflen)
 {
-	u64 n_sectors = args->dev->n_sectors;
+	u64 n_sectors;
 	u32 tmp;
 
 	VPRINTK("ENTER\n");
 
+	if (ata_id_has_lba48(args->id))
+		n_sectors = ata_id_u64(args->id, 100);
+	else
+		n_sectors = ata_id_u32(args->id, 60);
 	n_sectors--;		/* ATA TotalUserSectors - 1 */
 
 	tmp = n_sectors;	/* note: truncates, if lba48 */
@@ -1196,7 +1196,7 @@
 
 /**
  *	ata_scsiop_report_luns - Simulate REPORT LUNS command
- *	@args: Port / device / SCSI command of interest.
+ *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
@@ -1248,9 +1248,15 @@
 {
 	struct scsi_cmnd *cmd = qc->scsicmd;
 
-	if (unlikely(drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ)))
+	if (unlikely(drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ))) {
+		DPRINTK("request check condition\n");
+
 		cmd->result = SAM_STAT_CHECK_CONDITION;
-	else {
+
+		qc->scsidone(cmd);
+
+		return 1;
+	} else {
 		u8 *scsicmd = cmd->cmnd;
 
 		if (scsicmd[0] == INQUIRY) {
@@ -1260,7 +1266,7 @@
 			buflen = ata_scsi_rbuf_get(cmd, &buf);
 			buf[2] = 0x5;
 			buf[3] = (buf[3] & 0xf0) | 2;
-			ata_scsi_rbuf_put(cmd);
+			ata_scsi_rbuf_put(cmd, buf);
 		}
 		cmd->result = SAM_STAT_GOOD;
 	}
@@ -1322,13 +1328,15 @@
 #endif
 	}
 
+	qc->nbytes = cmd->bufflen;
+
 	return 0;
 }
 
 /**
  *	ata_scsi_find_dev - lookup ata_device from scsi_cmnd
  *	@ap: ATA port to which the device is attached
- *	@cmd: SCSI command to be sent to the device
+ *	@scsidev: SCSI device from which we derive the ATA device
  *
  *	Given various information provided in struct scsi_cmnd,
  *	map that onto an ATA bus, and using that mapping
@@ -1472,7 +1480,7 @@
 		if (xlat_func)
 			ata_scsi_translate(ap, dev, cmd, done, xlat_func);
 		else
-			ata_scsi_simulate(ap, dev, cmd, done);
+			ata_scsi_simulate(dev->id, cmd, done);
 	} else
 		ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
 
@@ -1482,8 +1490,7 @@
 
 /**
  *	ata_scsi_simulate - simulate SCSI command on ATA device
- *	@ap: Port to which ATA device is attached.
- *	@dev: Target device for CDB.
+ *	@id: current IDENTIFY data for target device.
  *	@cmd: SCSI command being sent to device.
  *	@done: SCSI command completion function.
  *
@@ -1494,15 +1501,14 @@
  *	spin_lock_irqsave(host_set lock)
  */
 
-static void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev,
-			      struct scsi_cmnd *cmd,
-			      void (*done)(struct scsi_cmnd *))
+void ata_scsi_simulate(u16 *id,
+		      struct scsi_cmnd *cmd,
+		      void (*done)(struct scsi_cmnd *))
 {
 	struct ata_scsi_args args;
 	u8 *scsicmd = cmd->cmnd;
 
-	args.ap = ap;
-	args.dev = dev;
+	args.id = id;
 	args.cmd = cmd;
 	args.done = done;
 
diff -Nru a/drivers/scsi/libata.h b/drivers/scsi/libata.h
--- a/drivers/scsi/libata.h	2004-12-24 13:36:30 -08:00
+++ b/drivers/scsi/libata.h	2004-12-24 13:36:30 -08:00
@@ -26,12 +26,11 @@
 #define __LIBATA_H__
 
 #define DRV_NAME	"libata"
-#define DRV_VERSION	"1.02"	/* must be exactly four chars */
+#define DRV_VERSION	"1.10"	/* must be exactly four chars */
 
 struct ata_scsi_args {
-	struct ata_port		*ap;
-	struct ata_device	*dev;
-	struct scsi_cmnd		*cmd;
+	u16			*id;
+	struct scsi_cmnd	*cmd;
 	void			(*done)(struct scsi_cmnd *);
 };
 
diff -Nru a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
--- a/drivers/scsi/mac53c94.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/mac53c94.c	2004-12-24 13:36:17 -08:00
@@ -41,9 +41,9 @@
 };
 
 struct fsc_state {
-	struct	mac53c94_regs *regs;
+	struct	mac53c94_regs __iomem *regs;
 	int	intr;
-	struct	dbdma_regs *dma;
+	struct	dbdma_regs __iomem *dma;
 	int	dmaintr;
 	int	clk_freq;
 	struct	Scsi_Host *host;
@@ -106,10 +106,10 @@
 static int mac53c94_host_reset(struct scsi_cmnd *cmd)
 {
 	struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata;
-	struct mac53c94_regs *regs = state->regs;
-	struct dbdma_regs *dma = state->dma;
+	struct mac53c94_regs __iomem *regs = state->regs;
+	struct dbdma_regs __iomem *dma = state->dma;
 
-	st_le32(&dma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
+	writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control);
 	writeb(CMD_SCSI_RESET, &regs->command);	/* assert RST */
 	udelay(100);			/* leave it on for a while (>= 25us) */
 	writeb(CMD_RESET, &regs->command);
@@ -121,8 +121,8 @@
 
 static void mac53c94_init(struct fsc_state *state)
 {
-	struct mac53c94_regs *regs = state->regs;
-	struct dbdma_regs *dma = state->dma;
+	struct mac53c94_regs __iomem *regs = state->regs;
+	struct dbdma_regs __iomem *dma = state->dma;
 	int x;
 
 	writeb(state->host->this_id | CF1_PAR_ENABLE, &regs->config1);
@@ -143,7 +143,7 @@
 static void mac53c94_start(struct fsc_state *state)
 {
 	struct scsi_cmnd *cmd;
-	struct mac53c94_regs *regs = state->regs;
+	struct mac53c94_regs __iomem *regs = state->regs;
 	int i;
 
 	if (state->phase != idle || state->current_req != NULL)
@@ -191,8 +191,8 @@
 static void mac53c94_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 	struct fsc_state *state = (struct fsc_state *) dev_id;
-	struct mac53c94_regs *regs = state->regs;
-	struct dbdma_regs *dma = state->dma;
+	struct mac53c94_regs __iomem *regs = state->regs;
+	struct dbdma_regs __iomem *dma = state->dma;
 	struct scsi_cmnd *cmd = state->current_req;
 	int nb, stat, seq, intr;
 	static int mac53c94_errors;
@@ -458,10 +458,10 @@
 	state->pdev = pdev;
 	state->mdev = mdev;
 
-	state->regs = (struct mac53c94_regs *)
+	state->regs = (struct mac53c94_regs __iomem *)
 		ioremap(macio_resource_start(mdev, 0), 0x1000);
 	state->intr = macio_irq(mdev, 0);
-	state->dma = (struct dbdma_regs *)
+	state->dma = (struct dbdma_regs __iomem *)
 		ioremap(macio_resource_start(mdev, 1), 0x1000);
 	state->dmaintr = macio_irq(mdev, 1);
 	if (state->regs == NULL || state->dma == NULL) {
diff -Nru a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
--- a/drivers/scsi/mac_esp.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/scsi/mac_esp.c	2004-12-24 13:36:49 -08:00
@@ -731,7 +731,7 @@
 }
 
 static Scsi_Host_Template driver_template = {
-	.proc_name		= "esp",
+	.proc_name		= "mac_esp",
 	.name			= "Mac 53C9x SCSI",
 	.detect			= mac_esp_detect,
 	.slave_alloc		= esp_slave_alloc,
diff -Nru a/drivers/scsi/mca_53c9x.c b/drivers/scsi/mca_53c9x.c
--- a/drivers/scsi/mca_53c9x.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/mca_53c9x.c	2004-12-24 13:36:31 -08:00
@@ -445,7 +445,7 @@
 }
 
 static Scsi_Host_Template driver_template = {
-	.proc_name		= "esp",
+	.proc_name		= "mca_53c9x",
 	.name			= "NCR 53c9x SCSI",
 	.detect			= mca_esp_detect,
 	.slave_alloc		= esp_slave_alloc,
diff -Nru a/drivers/scsi/megaraid/megaraid_ioctl.h b/drivers/scsi/megaraid/megaraid_ioctl.h
--- a/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-24 13:36:33 -08:00
+++ b/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-24 13:36:33 -08:00
@@ -142,9 +142,11 @@
 
 	caddr_t			buf_vaddr;
 	dma_addr_t		buf_paddr;
-	uint8_t			pool_index;
+	int8_t			pool_index;
 	uint8_t			free_buf;
 
+	uint8_t			timedout;
+
 } __attribute__ ((aligned(1024),packed)) uioc_t;
 
 
@@ -247,6 +249,7 @@
  * @pdev		: pci dev; used for allocating dma'ble memory
  * @issue_uioc		: Driver supplied routine to issue uioc_t commands
  *			: issue_uioc(drvr_data, kioc, ISSUE/ABORT, uioc_done)
+ * @quiescent		: flag to indicate if ioctl can be issued to this adp
  * @list		: attach with the global list of adapters
  * @kioc_list		: block of mem for @max_kioc number of kiocs
  * @kioc_pool		: pool of free kiocs
@@ -264,7 +267,7 @@
 	uint32_t		unique_id;
 	uint32_t		drvr_type;
 	unsigned long		drvr_data;
-	uint8_t			timeout;
+	uint16_t		timeout;
 	uint8_t			max_kioc;
 
 	struct pci_dev		*pdev;
@@ -272,6 +275,7 @@
 	int(*issue_uioc)(unsigned long, uioc_t *, uint32_t);
 
 /* Maintained by common module */
+	uint32_t		quiescent;
 
 	struct list_head	list;
 	uioc_t			*kioc_list;
diff -Nru a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
--- a/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-24 13:36:34 -08:00
@@ -10,7 +10,7 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mbox.c
- * Version	: v2.20.4 (September 27 2004)
+ * Version	: v2.20.4.1 (Nov 04 2004)
  *
  * Authors:
  * 	Atul Mukker		<Atul.Mukker@lsil.com>
@@ -295,6 +295,12 @@
 		PCI_SUBSYS_ID_PERC3_SC,
 	},
 	{
+		PCI_VENDOR_ID_AMI,
+		PCI_DEVICE_ID_AMI_MEGARAID3,
+		PCI_VENDOR_ID_AMI,
+		PCI_SUBSYS_ID_PERC3_SC,
+	},
+	{
 		PCI_VENDOR_ID_LSI_LOGIC,
 		PCI_DEVICE_ID_MEGARAID_SCSI_320_0,
 		PCI_VENDOR_ID_LSI_LOGIC,
@@ -872,8 +878,7 @@
 		goto out_free_raid_dev;
 	}
 
-	raid_dev->baseaddr = (unsigned long)
-			ioremap_nocache(raid_dev->baseport, 128);
+	raid_dev->baseaddr = ioremap_nocache(raid_dev->baseport, 128);
 
 	if (!raid_dev->baseaddr) {
 
@@ -996,7 +1001,7 @@
 out_free_irq:
 	free_irq(adapter->irq, adapter);
 out_iounmap:
-	iounmap((caddr_t)raid_dev->baseaddr);
+	iounmap(raid_dev->baseaddr);
 out_release_regions:
 	pci_release_regions(pdev);
 out_free_raid_dev:
@@ -1024,7 +1029,7 @@
 
 	free_irq(adapter->irq, adapter);
 
-	iounmap((caddr_t)raid_dev->baseaddr);
+	iounmap(raid_dev->baseaddr);
 
 	pci_release_regions(adapter->pdev);
 
@@ -1554,12 +1559,12 @@
 
 	if (scb->dma_direction == PCI_DMA_TODEVICE) {
 		if (!scb->scp->use_sg) {	// sg list not used
-			pci_dma_sync_single(adapter->pdev, ccb->buf_dma_h,
+			pci_dma_sync_single_for_device(adapter->pdev, ccb->buf_dma_h,
 					scb->scp->request_bufflen,
 					PCI_DMA_TODEVICE);
 		}
 		else {
-			pci_dma_sync_sg(adapter->pdev, scb->scp->request_buffer,
+			pci_dma_sync_sg_for_device(adapter->pdev, scb->scp->request_buffer,
 				scb->scp->use_sg, PCI_DMA_TODEVICE);
 		}
 	}
@@ -1618,6 +1623,7 @@
 
 	if (!scb) {	// command already completed
 		done(scp);
+		return 0;
 	}
 
 	return if_busy;
@@ -2332,7 +2338,7 @@
 
 	case MRAID_DMA_WBUF:
 		if (scb->dma_direction == PCI_DMA_FROMDEVICE) {
-			pci_dma_sync_single(adapter->pdev,
+			pci_dma_sync_single_for_cpu(adapter->pdev,
 					ccb->buf_dma_h,
 					scb->scp->request_bufflen,
 					PCI_DMA_FROMDEVICE);
@@ -2345,7 +2351,7 @@
 
 	case MRAID_DMA_WSG:
 		if (scb->dma_direction == PCI_DMA_FROMDEVICE) {
-			pci_dma_sync_sg(adapter->pdev,
+			pci_dma_sync_sg_for_cpu(adapter->pdev,
 					scb->scp->request_buffer,
 					scb->scp->use_sg, PCI_DMA_FROMDEVICE);
 		}
@@ -3591,7 +3597,7 @@
 	adp.drvr_data		= (unsigned long)adapter;
 	adp.pdev		= adapter->pdev;
 	adp.issue_uioc		= megaraid_mbox_mm_handler;
-	adp.timeout		= 30;
+	adp.timeout		= 300;
 	adp.max_kioc		= MBOX_MAX_USER_CMDS;
 
 	if ((rval = mraid_mm_register_adp(&adp)) != 0) {
diff -Nru a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h
--- a/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-24 13:36:34 -08:00
+++ b/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-24 13:36:34 -08:00
@@ -21,8 +21,8 @@
 #include "megaraid_ioctl.h"
 
 
-#define MEGARAID_VERSION	"2.20.4.0"
-#define MEGARAID_EXT_VERSION	"(Release Date: Mon Sep 27 22:15:07 EDT 2004)"
+#define MEGARAID_VERSION	"2.20.4.1"
+#define MEGARAID_EXT_VERSION	"(Release Date: Thu Nov  4 17:44:59 EST 2004)"
 
 
 /*
@@ -231,7 +231,7 @@
 	dma_addr_t			mbox_dma;
 	spinlock_t			mailbox_lock;
 	unsigned long			baseport;
-	unsigned long			baseaddr;
+	void __iomem *			baseaddr;
 	struct mraid_pci_blk		mbox_pool[MBOX_MAX_SCSI_CMDS];
 	struct dma_pool			*mbox_pool_handle;
 	struct mraid_pci_blk		epthru_pool[MBOX_MAX_SCSI_CMDS];
diff -Nru a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
--- a/drivers/scsi/megaraid/megaraid_mm.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/megaraid/megaraid_mm.c	2004-12-24 13:37:00 -08:00
@@ -10,7 +10,7 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mm.c
- * Version	: v2.20.2.0 (August 19 2004)
+ * Version	: v2.20.2.3 (Dec 09 2004)
  *
  * Common management module
  */
@@ -60,7 +60,7 @@
 EXPORT_SYMBOL(mraid_mm_unregister_adp);
 
 static int majorno;
-static uint32_t drvr_ver	= 0x02200100;
+static uint32_t drvr_ver	= 0x02200201;
 
 static int adapters_count_g;
 static struct list_head adapters_list_g;
@@ -156,6 +156,17 @@
 	}
 
 	/*
+	 * Check if adapter can accept ioctl. We may have marked it offline
+	 * if any previous kioc had timedout on this controller.
+	 */
+	if (!adp->quiescent) {
+		con_log(CL_ANN, (KERN_WARNING
+			"megaraid cmm: controller cannot accept cmds due to "
+			"earlier errors\n" ));
+		return -EFAULT;
+	}
+
+	/*
 	 * The following call will block till a kioc is available
 	 */
 	kioc = mraid_mm_alloc_kioc(adp);
@@ -171,10 +182,15 @@
 	kioc->done = ioctl_done;
 
 	/*
-	 * Issue the IOCTL to the low level driver
+	 * Issue the IOCTL to the low level driver. After the IOCTL completes
+	 * release the kioc if and only if it was _not_ timedout. If it was
+	 * timedout, that means that resources are still with low level driver.
 	 */
 	if ((rval = lld_ioctl(adp, kioc))) {
-		mraid_mm_dealloc_kioc(adp, kioc);
+
+		if (!kioc->timedout)
+			mraid_mm_dealloc_kioc(adp, kioc);
+
 		return rval;
 	}
 
@@ -581,6 +597,7 @@
 	kioc->user_data		= NULL;
 	kioc->user_data_len	= 0;
 	kioc->user_pthru	= NULL;
+	kioc->timedout		= 0;
 
 	return kioc;
 }
@@ -597,23 +614,27 @@
 	mm_dmapool_t	*pool;
 	unsigned long	flags;
 
-	pool = &adp->dma_pool_list[kioc->pool_index];
+	if (kioc->pool_index != -1) {
+		pool = &adp->dma_pool_list[kioc->pool_index];
 
-	/* This routine may be called in non-isr context also */
-	spin_lock_irqsave(&pool->lock, flags);
+		/* This routine may be called in non-isr context also */
+		spin_lock_irqsave(&pool->lock, flags);
 
-	/*
-	 * While attaching the dma buffer, if we didn't get the required
-	 * buffer from the pool, we would have allocated it at the run time
-	 * and set the free_buf flag. We must free that buffer. Otherwise,
-	 * just mark that the buffer is not in use
-	 */
-	if (kioc->free_buf == 1)
-		pci_pool_free(pool->handle, kioc->buf_vaddr, kioc->buf_paddr);
-	else
-		pool->in_use = 0;
+		/*
+		 * While attaching the dma buffer, if we didn't get the 
+		 * required buffer from the pool, we would have allocated 
+		 * it at the run time and set the free_buf flag. We must 
+		 * free that buffer. Otherwise, just mark that the buffer is 
+		 * not in use
+		 */
+		if (kioc->free_buf == 1)
+			pci_pool_free(pool->handle, kioc->buf_vaddr, 
+							kioc->buf_paddr);
+		else
+			pool->in_use = 0;
 
-	spin_unlock_irqrestore(&pool->lock, flags);
+		spin_unlock_irqrestore(&pool->lock, flags);
+	}
 
 	/* Return the kioc to the free pool */
 	spin_lock_irqsave(&adp->kioc_pool_lock, flags);
@@ -667,6 +688,14 @@
 		del_timer_sync(tp);
 	}
 
+	/*
+	 * If the command had timedout, we mark the controller offline
+	 * before returning
+	 */
+	if (kioc->timedout) {
+		adp->quiescent = 0;
+	}
+
 	return kioc->status;
 }
 
@@ -679,6 +708,10 @@
 static void
 ioctl_done(uioc_t *kioc)
 {
+	uint32_t	adapno;
+	int		iterator;
+	mraid_mmadp_t*	adapter;
+
 	/*
 	 * When the kioc returns from driver, make sure it still doesn't
 	 * have ENODATA in status. Otherwise, driver will hang on wait_event
@@ -691,7 +724,32 @@
 		kioc->status = -EINVAL;
 	}
 
-	wake_up(&wait_q);
+	/*
+	 * Check if this kioc was timedout before. If so, nobody is waiting
+	 * on this kioc. We don't have to wake up anybody. Instead, we just
+	 * have to free the kioc
+	 */
+	if (kioc->timedout) {
+		iterator	= 0;
+		adapter		= NULL;
+		adapno		= kioc->adapno;
+
+		con_log(CL_ANN, ( KERN_WARNING "megaraid cmm: completed "
+					"ioctl that was timedout before\n"));
+
+		list_for_each_entry(adapter, &adapters_list_g, list) {
+			if (iterator++ == adapno) break;
+		}
+
+		kioc->timedout = 0;
+
+		if (adapter) {
+			mraid_mm_dealloc_kioc( adapter, kioc );
+		}
+	}
+	else {
+		wake_up(&wait_q);
+	}
 }
 
 
@@ -706,6 +764,7 @@
 	uioc_t *kioc	= (uioc_t *)ptr;
 
 	kioc->status 	= -ETIME;
+	kioc->timedout	= 1;
 
 	con_log(CL_ANN, (KERN_WARNING "megaraid cmm: ioctl timed out\n"));
 
@@ -850,6 +909,7 @@
 	adapter->issue_uioc	= lld_adp->issue_uioc;
 	adapter->timeout	= lld_adp->timeout;
 	adapter->max_kioc	= lld_adp->max_kioc;
+	adapter->quiescent	= 1;
 
 	/*
 	 * Allocate single blocks of memory for all required kiocs,
@@ -1120,9 +1180,7 @@
 
 	INIT_LIST_HEAD(&adapters_list_g);
 
-#ifdef CONFIG_COMPAT
 	register_ioctl32_conversion(MEGAIOCCMD, mraid_mm_compat_ioctl);
-#endif
 
 	return 0;
 }
diff -Nru a/drivers/scsi/megaraid/megaraid_mm.h b/drivers/scsi/megaraid/megaraid_mm.h
--- a/drivers/scsi/megaraid/megaraid_mm.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/megaraid/megaraid_mm.h	2004-12-24 13:36:17 -08:00
@@ -29,10 +29,9 @@
 #include "megaraid_ioctl.h"
 
 
-#define LSI_COMMON_MOD_VERSION	"2.20.2.0"
+#define LSI_COMMON_MOD_VERSION	"2.20.2.3"
 #define LSI_COMMON_MOD_EXT_VERSION	\
-		"(Release Date: Thu Aug 19 09:58:33 EDT 2004)"
-
+		"(Release Date: Thu Dec  9 19:02:14 EST 2004)"
 
 #define LSI_DBGLVL			dbglevel
 
diff -Nru a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
--- a/drivers/scsi/megaraid.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/megaraid.c	2004-12-24 13:36:16 -08:00
@@ -58,16 +58,16 @@
 MODULE_VERSION(MEGARAID_MODULE_VERSION);
 
 static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN;
-MODULE_PARM(max_cmd_per_lun, "i");
+module_param(max_cmd_per_lun, uint, 0);
 MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)");
 
 static unsigned short int max_sectors_per_io = MAX_SECTORS_PER_IO;
-MODULE_PARM(max_sectors_per_io, "h");
+module_param(max_sectors_per_io, ushort, 0);
 MODULE_PARM_DESC(max_sectors_per_io, "Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)");
 
 
 static unsigned short int max_mbox_busy_wait = MBOX_BUSY_WAIT;
-MODULE_PARM(max_mbox_busy_wait, "h");
+module_param(max_mbox_busy_wait, ushort, 0);
 MODULE_PARM_DESC(max_mbox_busy_wait, "Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)");
 
 #define RDINDOOR(adapter)		readl((adapter)->base + 0x20)
@@ -634,11 +634,7 @@
 			}
 
 			if(!(scb = mega_allocate_scb(adapter, cmd))) {
-
-				cmd->result = (DID_ERROR << 16);
-				cmd->scsi_done(cmd);
 				*busy = 1;
-
 				return NULL;
 			}
 
@@ -677,11 +673,7 @@
 
 			/* Allocate a SCB and initialize passthru */
 			if(!(scb = mega_allocate_scb(adapter, cmd))) {
-
-				cmd->result = (DID_ERROR << 16);
-				cmd->scsi_done(cmd);
 				*busy = 1;
-
 				return NULL;
 			}
 			pthru = scb->pthru;
@@ -723,11 +715,7 @@
 
 			/* Allocate a SCB and initialize mailbox */
 			if(!(scb = mega_allocate_scb(adapter, cmd))) {
-
-				cmd->result = (DID_ERROR << 16);
-				cmd->scsi_done(cmd);
 				*busy = 1;
-
 				return NULL;
 			}
 			mbox = (mbox_t *)scb->raw_mbox;
@@ -867,11 +855,7 @@
 
 			/* Allocate a SCB and initialize mailbox */
 			if(!(scb = mega_allocate_scb(adapter, cmd))) {
-
-				cmd->result = (DID_ERROR << 16);
-				cmd->scsi_done(cmd);
 				*busy = 1;
-
 				return NULL;
 			}
 
@@ -899,11 +883,7 @@
 	else {
 		/* Allocate a SCB and initialize passthru */
 		if(!(scb = mega_allocate_scb(adapter, cmd))) {
-
-			cmd->result = (DID_ERROR << 16);
-			cmd->scsi_done(cmd);
 			*busy = 1;
-
 			return NULL;
 		}
 
@@ -4006,7 +3986,7 @@
 	mbox->m_out.xferaddr = (u32)adapter->buf_dma_handle;
 
 	/*
-	 * Non-ROMB firware fail this command, so all channels
+	 * Non-ROMB firmware fail this command, so all channels
 	 * must be shown RAID
 	 */
 	adapter->mega_ch_class = 0xFF;
diff -Nru a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
--- a/drivers/scsi/mesh.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/scsi/mesh.c	2004-12-24 13:37:01 -08:00
@@ -60,23 +60,23 @@
 MODULE_DESCRIPTION("PowerMac MESH SCSI driver");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(sync_rate, "i");
-MODULE_PARM_DESC(sync_rate, "Synchronous rate (0..10, 0=async)");
-MODULE_PARM(sync_targets, "i");
-MODULE_PARM_DESC(sync_targets, "Bitmask of targets allowed to set synchronous");
-MODULE_PARM(resel_targets, "i");
-MODULE_PARM_DESC(resel_targets, "Bitmask of targets allowed to set disconnect");
-MODULE_PARM(debug_targets, "i");
-MODULE_PARM_DESC(debug_targets, "Bitmask of debugged targets");
-MODULE_PARM(init_reset_delay, "i");
-MODULE_PARM_DESC(init_reset_delay, "Initial bus reset delay (0=no reset)");
-
 static int sync_rate = CONFIG_SCSI_MESH_SYNC_RATE;
 static int sync_targets = 0xff;
 static int resel_targets = 0xff;
 static int debug_targets = 0;	/* print debug for these targets */
 static int init_reset_delay = CONFIG_SCSI_MESH_RESET_DELAY_MS;
 
+module_param(sync_rate, int, 0);
+MODULE_PARM_DESC(sync_rate, "Synchronous rate (0..10, 0=async)");
+module_param(sync_targets, int, 0);
+MODULE_PARM_DESC(sync_targets, "Bitmask of targets allowed to set synchronous");
+module_param(resel_targets, int, 0);
+MODULE_PARM_DESC(resel_targets, "Bitmask of targets allowed to set disconnect");
+module_param(debug_targets, int, 0644);
+MODULE_PARM_DESC(debug_targets, "Bitmask of debugged targets");
+module_param(init_reset_delay, int, 0);
+MODULE_PARM_DESC(init_reset_delay, "Initial bus reset delay (0=no reset)");
+
 static int mesh_sync_period = 100;
 static int mesh_sync_offset = 0;
 static unsigned char use_active_neg = 0;  /* bit mask for SEQ_ACTIVE_NEG if used */
@@ -144,9 +144,9 @@
 };
 
 struct mesh_state {
-	volatile struct	mesh_regs *mesh;
+	volatile struct	mesh_regs __iomem *mesh;
 	int	meshintr;
-	volatile struct	dbdma_regs *dma;
+	volatile struct	dbdma_regs __iomem *dma;
 	int	dmaintr;
 	struct	Scsi_Host *host;
 	struct	mesh_state *next;
@@ -304,8 +304,8 @@
 static void
 mesh_dump_regs(struct mesh_state *ms)
 {
-	volatile struct mesh_regs *mr = ms->mesh;
-	volatile struct dbdma_regs *md = ms->dma;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
+	volatile struct dbdma_regs __iomem *md = ms->dma;
 	int t;
 	struct mesh_target *tp;
 
@@ -338,7 +338,7 @@
 /*
  * Flush write buffers on the bus path to the mesh
  */
-static inline void mesh_flush_io(volatile struct mesh_regs *mr)
+static inline void mesh_flush_io(volatile struct mesh_regs __iomem *mr)
 {
 	(void)in_8(&mr->mesh_id);
 }
@@ -359,8 +359,8 @@
  */
 static void mesh_init(struct mesh_state *ms)
 {
-	volatile struct mesh_regs *mr = ms->mesh;
-	volatile struct dbdma_regs *md = ms->dma;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
+	volatile struct dbdma_regs __iomem *md = ms->dma;
 
 	mesh_flush_io(mr);
 	udelay(100);
@@ -388,8 +388,7 @@
 		mesh_flush_io(mr);
 
 		/* Wait for bus to come back */
-		current->state = TASK_UNINTERRUPTIBLE;
-		schedule_timeout((init_reset_delay * HZ) / 1000);
+		msleep(init_reset_delay);
 	}
 	
 	/* Reconfigure controller */
@@ -407,7 +406,7 @@
 
 static void mesh_start_cmd(struct mesh_state *ms, struct scsi_cmnd *cmd)
 {
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	int t, id;
 
 	id = cmd->device->id;
@@ -468,7 +467,7 @@
 				dlog(ms, "intr b4 arb, intr/exc/err/fc=%.8x",
 				     MKWORD(mr->interrupt, mr->exception,
 					    mr->error, mr->fifo_count));
-				mesh_interrupt(0, (void *)ms, 0);
+				mesh_interrupt(0, (void *)ms, NULL);
 				if (ms->phase != arbitrating)
 					return;
 			}
@@ -506,7 +505,7 @@
 		dlog(ms, "intr after disresel, intr/exc/err/fc=%.8x",
 		     MKWORD(mr->interrupt, mr->exception,
 			    mr->error, mr->fifo_count));
-		mesh_interrupt(0, (void *)ms, 0);
+		mesh_interrupt(0, (void *)ms, NULL);
 		if (ms->phase != arbitrating)
 			return;
 		dlog(ms, "after intr after disresel, intr/exc/err/fc=%.8x",
@@ -596,8 +595,8 @@
 	struct mesh_target *tp = &ms->tgts[ms->conn_tgt];
 
 	cmd = ms->current_req;
-	ms->current_req = 0;
-	tp->current_req = 0;
+	ms->current_req = NULL;
+	tp->current_req = NULL;
 	if (cmd) {
 		cmd->result = (ms->stat << 16) + cmd->SCp.Status;
 		if (ms->stat == DID_OK)
@@ -639,7 +638,7 @@
 static void set_sdtr(struct mesh_state *ms, int period, int offset)
 {
 	struct mesh_target *tp = &ms->tgts[ms->conn_tgt];
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	int v, tr;
 
 	tp->sdtr_state = sdtr_done;
@@ -680,8 +679,8 @@
 static void start_phase(struct mesh_state *ms)
 {
 	int i, seq, nb;
-	volatile struct mesh_regs *mr = ms->mesh;
-	volatile struct dbdma_regs *md = ms->dma;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
+	volatile struct dbdma_regs __iomem *md = ms->dma;
 	struct scsi_cmnd *cmd = ms->current_req;
 	struct mesh_target *tp = &ms->tgts[ms->conn_tgt];
 
@@ -824,7 +823,7 @@
 
 static inline void get_msgin(struct mesh_state *ms)
 {
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	int i, n;
 
 	n = mr->fifo_count;
@@ -856,7 +855,7 @@
 
 static void reselected(struct mesh_state *ms)
 {
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	struct scsi_cmnd *cmd;
 	struct mesh_target *tp;
 	int b, t, prev;
@@ -989,7 +988,7 @@
 	int tgt;
 	struct mesh_target *tp;
 	struct scsi_cmnd *cmd;
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 
 	for (tgt = 0; tgt < 8; ++tgt) {
 		tp = &ms->tgts[tgt];
@@ -1031,7 +1030,7 @@
 static void handle_error(struct mesh_state *ms)
 {
 	int err, exc, count;
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 
 	err = in_8(&mr->error);
 	exc = in_8(&mr->exception);
@@ -1125,7 +1124,7 @@
 static void handle_exception(struct mesh_state *ms)
 {
 	int exc;
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 
 	exc = in_8(&mr->exception);
 	out_8(&mr->interrupt, INT_EXCEPTION | INT_CMDDONE);
@@ -1232,8 +1231,8 @@
 			} else if (code != cmd->device->lun + IDENTIFY_BASE) {
 				printk(KERN_WARNING "mesh: lun mismatch "
 				       "(%d != %d) on reselection from "
-				       "target %d\n", i, cmd->device->lun,
-				       ms->conn_tgt);
+				       "target %d\n", code - IDENTIFY_BASE,
+				       cmd->device->lun, ms->conn_tgt);
 			}
 			break;
 		}
@@ -1325,8 +1324,8 @@
 
 static void halt_dma(struct mesh_state *ms)
 {
-	volatile struct dbdma_regs *md = ms->dma;
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct dbdma_regs __iomem *md = ms->dma;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	struct scsi_cmnd *cmd = ms->current_req;
 	int t, nb;
 
@@ -1374,7 +1373,7 @@
 
 static void phase_mismatch(struct mesh_state *ms)
 {
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	int phase;
 
 	dlog(ms, "phasemm ch/cl/seq/fc=%.8x",
@@ -1453,7 +1452,7 @@
 
 static void cmd_complete(struct mesh_state *ms)
 {
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	struct scsi_cmnd *cmd = ms->current_req;
 	struct mesh_target *tp = &ms->tgts[ms->conn_tgt];
 	int seq, n, t;
@@ -1619,7 +1618,7 @@
 			mesh_done(ms, 1);
 			return;
 		case disconnecting:
-			ms->current_req = 0;
+			ms->current_req = NULL;
 			ms->phase = idle;
 			mesh_start(ms);
 			return;
@@ -1666,7 +1665,7 @@
 static void mesh_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 	struct mesh_state *ms = (struct mesh_state *) dev_id;
-	volatile struct mesh_regs *mr = ms->mesh;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	int intr;
 
 #if 0
@@ -1714,8 +1713,8 @@
 static int mesh_host_reset(struct scsi_cmnd *cmd)
 {
 	struct mesh_state *ms = (struct mesh_state *) cmd->device->host->hostdata;
-	volatile struct mesh_regs *mr = ms->mesh;
-	volatile struct dbdma_regs *md = ms->dma;
+	volatile struct mesh_regs __iomem *mr = ms->mesh;
+	volatile struct dbdma_regs __iomem *md = ms->dma;
 
 	printk(KERN_DEBUG "mesh_host_reset\n");
 
@@ -1749,12 +1748,10 @@
 		return;
 	if (state) {
 		pmac_call_feature(PMAC_FTR_MESH_ENABLE, macio_get_of_node(ms->mdev), 0, 1);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/5);
+		msleep(200);
 	} else {
 		pmac_call_feature(PMAC_FTR_MESH_ENABLE, macio_get_of_node(ms->mdev), 0, 0);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	}
 }			
 
@@ -1765,15 +1762,14 @@
 	struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
 	unsigned long flags;
 
-	if (state == mdev->ofdev.dev.power_state || state < 2)
+	if (state == mdev->ofdev.dev.power.power_state || state < 2)
 		return 0;
 
 	scsi_block_requests(ms->host);
 	spin_lock_irqsave(ms->host->host_lock, flags);
 	while(ms->phase != idle) {
 		spin_unlock_irqrestore(ms->host->host_lock, flags);
-		current->state = TASK_UNINTERRUPTIBLE;
-		schedule_timeout(HZ/100);
+		msleep(10);
 		spin_lock_irqsave(ms->host->host_lock, flags);
 	}
 	ms->phase = sleeping;
@@ -1781,7 +1777,7 @@
 	disable_irq(ms->meshintr);
 	set_mesh_power(ms, 0);
 
-	mdev->ofdev.dev.power_state = state;
+	mdev->ofdev.dev.power.power_state = state;
 
 	return 0;
 }
@@ -1791,7 +1787,7 @@
 	struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
 	unsigned long flags;
 
-	if (mdev->ofdev.dev.power_state == 0)
+	if (mdev->ofdev.dev.power.power_state == 0)
 		return 0;
 
 	set_mesh_power(ms, 1);
@@ -1802,7 +1798,7 @@
 	enable_irq(ms->meshintr);
 	scsi_unblock_requests(ms->host);
 
-	mdev->ofdev.dev.power_state = 0;
+	mdev->ofdev.dev.power.power_state = 0;
 
 	return 0;
 }
@@ -1817,7 +1813,7 @@
 static int mesh_shutdown(struct macio_dev *mdev)
 {
 	struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
-	volatile struct mesh_regs *mr;
+	volatile struct mesh_regs __iomem *mr;
 	unsigned long flags;
 
        	printk(KERN_INFO "resetting MESH scsi bus(es)\n");
@@ -1896,17 +1892,15 @@
 	ms->mdev = mdev;
 	ms->pdev = pdev;
 	
-	ms->mesh = (volatile struct mesh_regs *)
-		ioremap(macio_resource_start(mdev, 0), 0x1000);
+	ms->mesh = ioremap(macio_resource_start(mdev, 0), 0x1000);
 	if (ms->mesh == NULL) {
 		printk(KERN_ERR "mesh: can't map registers\n");
 		goto out_free;
 	}		
-	ms->dma = (volatile struct dbdma_regs *)
-	       	ioremap(macio_resource_start(mdev, 1), 0x1000);
+	ms->dma = ioremap(macio_resource_start(mdev, 1), 0x1000);
 	if (ms->dma == NULL) {
 		printk(KERN_ERR "mesh: can't map registers\n");
-		iounmap((void *)ms->mesh);
+		iounmap(ms->mesh);
 		goto out_free;
 	}
 
@@ -1938,7 +1932,7 @@
        	for (tgt = 0; tgt < 8; ++tgt) {
 	       	ms->tgts[tgt].sdtr_state = do_sdtr;
 	       	ms->tgts[tgt].sync_params = ASYNC_PARAMS;
-	       	ms->tgts[tgt].current_req = 0;
+	       	ms->tgts[tgt].current_req = NULL;
        	}
 
 	if ((cfp = (int *) get_property(mesh, "clock-frequency", NULL)))
@@ -1972,8 +1966,8 @@
 	return 0;
 
 out_unmap:
-	iounmap((void *)ms->dma);
-	iounmap((void *)ms->mesh);
+	iounmap(ms->dma);
+	iounmap(ms->mesh);
 out_free:
 	scsi_host_put(mesh_host);
 out_release:
@@ -1998,8 +1992,8 @@
 	set_mesh_power(ms, 0);
 
 	/* Unmap registers & dma controller */
-	iounmap((void *) ms->mesh);
-       	iounmap((void *) ms->dma);
+	iounmap(ms->mesh);
+       	iounmap(ms->dma);
 
 	/* Free DMA commands memory */
 	pci_free_consistent(macio_get_pci_dev(mdev), ms->dma_cmd_size,
diff -Nru a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
--- a/drivers/scsi/ncr53c8xx.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/scsi/ncr53c8xx.c	2004-12-24 13:36:32 -08:00
@@ -83,11 +83,6 @@
 **
 **	Supported NCR/SYMBIOS chips:
 **		53C720		(Wide,   Fast SCSI-2, intfly problems)
-**
-**	Other features:
-**		Memory mapped IO (linux-1.3.X and above only)
-**		Module
-**		Shared IRQ (since linux-1.3.72)
 */
 
 /* Name and version of the driver */
@@ -124,23 +119,17 @@
 #include <asm/io.h>
 #include <asm/system.h>
 
-#include "scsi.h"
-#include <scsi/scsi_host.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
 
 #include "ncr53c8xx.h"
 
-/*
-**	Donnot compile integrity checking code for Linux-2.3.0 
-**	and above since SCSI data structures are not ready yet.
-*/
-/* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
-#if 0
-#define	SCSI_NCR_INTEGRITY_CHECKING
-#endif
-
 #define NAME53C			"ncr53c"
 #define NAME53C8XX		"ncr53c8xx"
-#define DRIVER_SMP_LOCK		ncr53c8xx_lock
 
 #include "sym53c8xx_comm.h"
 
@@ -316,10 +305,6 @@
 
 #define ScsiResult(host_code, scsi_code) (((host_code) << 16) + ((scsi_code) & 0x7f))
 
-static void ncr53c8xx_timeout(unsigned long np);
-static int ncr53c8xx_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
-			int length, int func);
-
 #define initverbose (driver_setup.verbose)
 #define bootverbose (np->verbose)
 
@@ -415,31 +400,6 @@
 
 /*==========================================================
 **
-**	"Special features" of targets.
-**	quirks field		of struct tcb.
-**	actualquirks field	of struct ccb.
-**
-**==========================================================
-*/
-
-#define	QUIRK_AUTOSAVE	(0x01)
-#define	QUIRK_NOMSG	(0x02)
-#define QUIRK_NOSYNC	(0x10)
-#define QUIRK_NOWIDE16	(0x20)
-
-/*==========================================================
-**
-**	Capability bits in Inquire response byte 7.
-**
-**==========================================================
-*/
-
-#define	INQ7_QUEUE	(0x02)
-#define	INQ7_SYNC	(0x10)
-#define	INQ7_WIDE16	(0x20)
-
-/*==========================================================
-**
 **	Misc.
 **
 **==========================================================
@@ -454,6 +414,8 @@
 **==========================================================
 */
 
+static struct scsi_transport_template *ncr53c8xx_transport_template = NULL;
+
 struct tcb;
 struct lcb;
 struct ccb;
@@ -531,8 +493,6 @@
 	*/
 	struct link     jump_lcb[4];	/* JUMPs for reselection	*/
 	struct lcb *	lp[MAX_LUN];	/* The lcb's of this tcb	*/
-	u_char		inq_done;	/* Target capabilities received	*/
-	u_char		inq_byte7;	/* Contains these capabilities	*/
 
 	/*----------------------------------------------------------------
 	**	Pointer to the ccb used for negotiation.
@@ -571,18 +531,12 @@
 /*3*/	u_char	wval;
 #endif
 
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-	u_char 	ic_min_sync;
-	u_char 	ic_max_width;
-	u_char 	ic_maximums_set;
-	u_char 	ic_done;
-#endif
-
 	/* User settable limits and options.  */
 	u_char	usrsync;
 	u_char	usrwide;
 	u_char	usrtags;
 	u_char	usrflag;
+	struct scsi_target *starget;
 };
 
 /*========================================================================
@@ -626,10 +580,10 @@
 	**	CCB queue management.
 	**----------------------------------------------------------------
 	*/
-	XPT_QUEHEAD	free_ccbq;	/* Queue of available CCBs	*/
-	XPT_QUEHEAD	busy_ccbq;	/* Queue of busy CCBs		*/
-	XPT_QUEHEAD	wait_ccbq;	/* Queue of waiting for IO CCBs	*/
-	XPT_QUEHEAD	skip_ccbq;	/* Queue of skipped CCBs	*/
+	struct list_head free_ccbq;	/* Queue of available CCBs	*/
+	struct list_head busy_ccbq;	/* Queue of busy CCBs		*/
+	struct list_head wait_ccbq;	/* Queue of waiting for IO CCBs	*/
+	struct list_head skip_ccbq;	/* Queue of skipped CCBs	*/
 	u_char		actccbs;	/* Number of allocated CCBs	*/
 	u_char		busyccbs;	/* CCBs busy for this lun	*/
 	u_char		queuedccbs;	/* CCBs queued to the controller*/
@@ -649,7 +603,6 @@
 	u_char		usetags;	/* Command queuing is active	*/
 	u_char		maxtags;	/* Max nr of tags asked by user	*/
 	u_char		numtags;	/* Current number of tags	*/
-	u_char		inq_byte7;	/* Store unit CmdQ capabitility	*/
 
 	/*----------------------------------------------------------------
 	**	QUEUE FULL control and ORDERED tag control.
@@ -920,7 +873,7 @@
 	u_char		queued;
 	u_char		auto_sense;
 	struct ccb *	link_ccb;	/* Host adapter CCB chain	*/
-	XPT_QUEHEAD	link_ccbq;	/* Link to unit CCB queue	*/
+	struct list_head link_ccbq;	/* Link to unit CCB queue	*/
 	u32		startp;		/* Initial data pointer		*/
 	u_long		magic;		/* Free / busy  CCB flag	*/
 };
@@ -997,11 +950,11 @@
 	**	Virtual and physical bus addresses of the chip.
 	**----------------------------------------------------------------
 	*/
-	vm_offset_t	vaddr;		/* Virtual and bus address of	*/
-	vm_offset_t     paddr;		/*  chip's IO registers.	*/
-	vm_offset_t     paddr2;		/* On-chip RAM bus address.	*/
+	void __iomem *vaddr;		/* Virtual and bus address of	*/
+	unsigned long	paddr;		/*  chip's IO registers.	*/
+	unsigned long	paddr2;		/* On-chip RAM bus address.	*/
 	volatile			/* Pointer to volatile for 	*/
-	struct ncr_reg	*reg;		/*  memory mapped IO.		*/
+	struct ncr_reg	__iomem *reg;	/*  memory mapped IO.		*/
 
 	/*----------------------------------------------------------------
 	**	SCRIPTS virtual and physical bus addresses.
@@ -1096,17 +1049,6 @@
 	struct ccb	*ccb;		/* Global CCB			*/
 	struct usrcmd	user;		/* Command from user		*/
 	volatile u_char	release_stage;	/* Synchronisation stage on release  */
-
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-	/*----------------------------------------------------------------
-	**	Fields that are used for integrity check
-	**----------------------------------------------------------------
-	*/
-	unsigned char check_integrity; /* Enable midlayer integ.check on
-					* bus scan. */
-	unsigned char check_integ_par;  /* Set if par or Init. Det. error
-					 * used only during integ check */
-#endif
 };
 
 #define NCB_SCRIPT_PHYS(np,lbl)	 (np->p_script  + offsetof (struct script, lbl))
@@ -1186,7 +1128,7 @@
 #endif
 	ncrcmd  save_dp		[  7];
 	ncrcmd  restore_dp	[  5];
-	ncrcmd  disconnect	[ 17];
+	ncrcmd  disconnect	[ 10];
 	ncrcmd	msg_out		[  9];
 	ncrcmd	msg_out_done	[  7];
 	ncrcmd  idle		[  2];
@@ -1274,8 +1216,7 @@
 static	void	ncr_init_ccb	(struct ncb *np, struct ccb *cp);
 static	void	ncr_init_tcb	(struct ncb *np, u_char tn);
 static	struct lcb *	ncr_alloc_lcb	(struct ncb *np, u_char tn, u_char ln);
-static	struct lcb *	ncr_setup_lcb	(struct ncb *np, u_char tn, u_char ln,
-				 u_char *inq_data);
+static	struct lcb *	ncr_setup_lcb	(struct ncb *np, struct scsi_device *sdev);
 static	void	ncr_getclock	(struct ncb *np, int mult);
 static	void	ncr_selectclock	(struct ncb *np, u_char scntl3);
 static	struct ccb *ncr_get_ccb	(struct ncb *np, u_char tn, u_char ln);
@@ -1286,12 +1227,8 @@
 static	void	ncr_int_ma	(struct ncb *np);
 static	void	ncr_int_sir	(struct ncb *np);
 static  void    ncr_int_sto     (struct ncb *np);
-static	u_long	ncr_lookup	(char* id);
 static	void	ncr_negotiate	(struct ncb* np, struct tcb* tp);
 static	int	ncr_prepare_nego(struct ncb *np, struct ccb *cp, u_char *msgptr);
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-static	int	ncr_ic_nego(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd, u_char *msgptr);
-#endif
 
 static	void	ncr_script_copy_and_bind
 				(struct ncb *np, ncrcmd *src, ncrcmd *dst, int len);
@@ -1299,7 +1236,7 @@
 static	int	ncr_scatter	(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd);
 static	void	ncr_getsync	(struct ncb *np, u_char sfac, u_char *fakp, u_char *scntl3p);
 static	void	ncr_setsync	(struct ncb *np, struct ccb *cp, u_char scntl3, u_char sxfer);
-static	void	ncr_setup_tags	(struct ncb *np, u_char tn, u_char ln);
+static	void	ncr_setup_tags	(struct ncb *np, struct scsi_device *sdev);
 static	void	ncr_setwide	(struct ncb *np, struct ccb *cp, u_char wide, u_char ack);
 static	int	ncr_show_msg	(u_char * msg);
 static  void    ncr_print_msg   (struct ccb *cp, char *label, u_char *msg);
@@ -1882,21 +1819,6 @@
 	*/
 	SCR_LOAD_REG (HS_REG, HS_DISCONNECT),
 		0,
-	/*
-	**	If QUIRK_AUTOSAVE is set,
-	**	do an "save pointer" operation.
-	*/
-	SCR_FROM_REG (QU_REG),
-		0,
-	SCR_JUMP ^ IFFALSE (MASK (QUIRK_AUTOSAVE, QUIRK_AUTOSAVE)),
-		PADDR (cleanup_ok),
-	/*
-	**	like SAVE_DP message:
-	**	Copy TEMP register to SAVEP in header.
-	*/
-	SCR_COPY (4),
-		RADDR (temp),
-		NADDR (header.savep),
 	SCR_JUMP,
 		PADDR (cleanup_ok),
 
@@ -2826,7 +2748,7 @@
 		*p++ =PADDR (idle);
 	};
 
-	assert ((u_long)p == (u_long)&scrh->tryloop + sizeof (scrh->tryloop));
+	BUG_ON((u_long)p != (u_long)&scrh->tryloop + sizeof (scrh->tryloop));
 
 #ifdef SCSI_NCR_CCB_DONE_SUPPORT
 
@@ -2839,7 +2761,7 @@
 		*p++ =PADDR (done_end);
 	}
 
-	assert ((u_long)p ==(u_long)&scrh->done_queue+sizeof(scrh->done_queue));
+	BUG_ON((u_long)p != (u_long)&scrh->done_queue+sizeof(scrh->done_queue));
 
 #endif /* SCSI_NCR_CCB_DONE_SUPPORT */
 
@@ -2850,7 +2772,8 @@
 		*p++ =SCR_MOVE_TBL ^ SCR_DATA_IN;
 		*p++ =offsetof (struct dsb, data[i]);
 	};
-	assert ((u_long)p == (u_long)&scrh->hdata_in + sizeof (scrh->hdata_in));
+
+	BUG_ON((u_long)p != (u_long)&scrh->hdata_in + sizeof (scrh->hdata_in));
 
 	p = scr->data_in;
 	for (i=MAX_SCATTERH; i<MAX_SCATTERH+MAX_SCATTERL; i++) {
@@ -2859,7 +2782,8 @@
 		*p++ =SCR_MOVE_TBL ^ SCR_DATA_IN;
 		*p++ =offsetof (struct dsb, data[i]);
 	};
-	assert ((u_long)p == (u_long)&scr->data_in + sizeof (scr->data_in));
+
+	BUG_ON((u_long)p != (u_long)&scr->data_in + sizeof (scr->data_in));
 
 	p = scrh->hdata_out;
 	for (i=0; i<MAX_SCATTERH; i++) {
@@ -2868,7 +2792,8 @@
 		*p++ =SCR_MOVE_TBL ^ SCR_DATA_OUT;
 		*p++ =offsetof (struct dsb, data[i]);
 	};
-	assert ((u_long)p==(u_long)&scrh->hdata_out + sizeof (scrh->hdata_out));
+
+	BUG_ON((u_long)p != (u_long)&scrh->hdata_out + sizeof (scrh->hdata_out));
 
 	p = scr->data_out;
 	for (i=MAX_SCATTERH; i<MAX_SCATTERH+MAX_SCATTERL; i++) {
@@ -2878,7 +2803,7 @@
 		*p++ =offsetof (struct dsb, data[i]);
 	};
 
-	assert ((u_long)p == (u_long)&scr->data_out + sizeof (scr->data_out));
+	BUG_ON((u_long) p != (u_long)&scr->data_out + sizeof (scr->data_out));
 }
 
 /*==========================================================
@@ -2916,7 +2841,7 @@
 		if (opcode == 0) {
 			printk (KERN_ERR "%s: ERROR0 IN SCRIPT at %d.\n",
 				ncr_name(np), (int) (src-start-1));
-			MDELAY (1000);
+			mdelay(1000);
 		};
 
 		if (DEBUG_FLAGS & DEBUG_SCRIPT)
@@ -2946,7 +2871,7 @@
 			if ((tmp1 ^ tmp2) & 3) {
 				printk (KERN_ERR"%s: ERROR1 IN SCRIPT at %d.\n",
 					ncr_name(np), (int) (src-start-1));
-				MDELAY (1000);
+				mdelay(1000);
 			}
 			/*
 			**	If PREFETCH feature not enabled, remove 
@@ -3036,21 +2961,8 @@
 	};
 }
 
-/*==========================================================
-**
-**
-**      Auto configuration:  attach and init a host adapter.
-**
-**
-**==========================================================
-*/
-
 /*
 **	Linux host data structure
-**
-**	The script area is allocated in the host data structure
-**	because kmalloc() returns NULL during scsi initialisations
-**	with Linux 1.2.X
 */
 
 struct host_data {
@@ -3439,182 +3351,6 @@
 /*==========================================================
 **
 **
-**	Prepare the next negotiation message for integrity check,
-**	if needed.
-**
-**	Fill in the part of message buffer that contains the 
-**	negotiation and the nego_status field of the CCB.
-**	Returns the size of the message in bytes.
-**
-**
-**==========================================================
-*/
-
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-static int ncr_ic_nego(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd, u_char *msgptr)
-{
-	struct tcb *tp = &np->target[cp->target];
-	int msglen = 0;
-	int nego = 0;
-	u_char no_increase;
-
-	if (tp->inq_done) {
-
-		if (!tp->ic_maximums_set) {
-			tp->ic_maximums_set = 1;
-
-			/* check target and host adapter capabilities */
-			if ( (tp->inq_byte7 & INQ7_WIDE16) && 
-					np->maxwide && tp->usrwide ) 
-				tp->ic_max_width = 1;
-			else
-				tp->ic_max_width = 0;
-
-			if ((tp->inq_byte7 & INQ7_SYNC) && tp->maxoffs) {
-				tp->ic_min_sync   = (tp->minsync < np->minsync) ?
-							np->minsync : tp->minsync;
-			}
-			else 
-				tp->ic_min_sync   = 255;
-			
-			tp->period   = 1;
-			tp->widedone = 1;
-		}
-
-		if (DEBUG_FLAGS & DEBUG_IC) {
-			printk("%s: cmd->ic_nego %d, 1st byte 0x%2X\n",
-				ncr_name(np), cmd->ic_nego, cmd->cmnd[0]);
-		}
-
-		/* First command from integrity check routine will request
-		 * a PPR message.  Disable.
-		 */
-		if ((cmd->ic_nego & NS_PPR) == NS_PPR)
-			cmd->ic_nego &= ~NS_PPR;
-		/* Previous command recorded a parity or an initiator
-		 * detected error condition. Force bus to narrow for this
-		 * target. Clear flag. Negotation on request sense.
-		 * Note: kernel forces 2 bus resets :o( but clears itself out.
-		 * Minor bug? in scsi_obsolete.c (ugly)
-		 */
-		if (np->check_integ_par) {
-			printk("%s: Parity Error. Target set to narrow.\n",
-				ncr_name(np));
-			tp->ic_max_width = 0;
-			tp->widedone = tp->period = 0;
-		}
-		
-		/* In case of a bus reset, ncr_negotiate will reset 
-		 * the flags tp->widedone and tp->period to 0, forcing
-		 * a new negotiation. 
-		 */
-		no_increase = 0;
-		if (tp->widedone == 0) {
-			cmd->ic_nego = NS_WIDE;
-			tp->widedone = 1;
-			no_increase = 1;
-		}
-		else if (tp->period == 0) {
-			cmd->ic_nego = NS_SYNC;
-			tp->period = 1;
-			no_increase = 1;
-		}
-			
-		switch (cmd->ic_nego) {
-		case NS_WIDE:
-			/*
-			**	negotiate wide transfers ?
-			**	Do NOT negotiate if device only supports
-			**	narrow.	
-			*/
-			if (tp->ic_max_width | np->check_integ_par) {
-				nego = NS_WIDE;
-
-				msgptr[msglen++] = M_EXTENDED;
-				msgptr[msglen++] = 2;
-				msgptr[msglen++] = M_X_WIDE_REQ;
-				msgptr[msglen++] = cmd->ic_nego_width & tp->ic_max_width;
-			}
-			else
-				cmd->ic_nego_width &= tp->ic_max_width;
-
-			break;
-
-		case NS_SYNC:
-			/*
-			**	negotiate synchronous transfers?
-			**	Target must support sync transfers.
-			**
-			**	If period becomes longer than max, reset to async
-			*/
-
-			if (tp->inq_byte7 & INQ7_SYNC) {
-
-				nego = NS_SYNC;
-
-				msgptr[msglen++] = M_EXTENDED;
-				msgptr[msglen++] = 3;
-				msgptr[msglen++] = M_X_SYNC_REQ;
-
-				switch (cmd->ic_nego_sync) {
-				case 2: /* increase the period */
-					if (!no_increase) {
-					  if (tp->ic_min_sync <= 0x0A)
-					      tp->ic_min_sync = 0x0C;
-					  else if (tp->ic_min_sync <= 0x0C)
-					      tp->ic_min_sync = 0x19;
-					  else if (tp->ic_min_sync <= 0x19)
-					      tp->ic_min_sync *= 2;
-					  else {
-						tp->ic_min_sync = 255;
-						cmd->ic_nego_sync = 0;
-						tp->maxoffs = 0;
-					   }
-					}
-					msgptr[msglen++] = tp->maxoffs?tp->ic_min_sync:0;
-					msgptr[msglen++] = tp->maxoffs;
-					break;
-
-				case 1: /* nego. to maximum */
-					msgptr[msglen++] = tp->maxoffs?tp->ic_min_sync:0;
-					msgptr[msglen++] = tp->maxoffs;
-					break;
-
-				case 0:	/* nego to async */
-				default:
-					msgptr[msglen++] = 0;
-					msgptr[msglen++] = 0;
-					break;
-				};
-			}
-			else
-				cmd->ic_nego_sync = 0;
-			break;
-
-		case NS_NOCHANGE:
-		default:
-			break;
-		};
-	};
-
-	cp->nego_status = nego;
-	np->check_integ_par = 0;
-
-	if (nego) {
-		tp->nego_cp = cp;
-		if (DEBUG_FLAGS & DEBUG_NEGO) {
-			ncr_print_msg(cp, nego == NS_WIDE ?
-			  "wide/narrow msgout": "sync/async msgout", msgptr);
-		};
-	};
-
-	return msglen;
-}
-#endif /* SCSI_NCR_INTEGRITY_CHECKING */
-
-/*==========================================================
-**
-**
 **	Prepare the next negotiation message if needed.
 **
 **	Fill in the part of message buffer that contains the 
@@ -3631,20 +3367,17 @@
 	struct tcb *tp = &np->target[cp->target];
 	int msglen = 0;
 	int nego = 0;
+	struct scsi_target *starget = tp->starget;
 
-	if (tp->inq_done) {
+	if (likely(starget)) {
 
 		/*
 		**	negotiate wide transfers ?
 		*/
 
 		if (!tp->widedone) {
-			if (tp->inq_byte7 & INQ7_WIDE16) {
+			if (spi_support_wide(starget)) {
 				nego = NS_WIDE;
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-				if (tp->ic_done)
-		       			 tp->usrwide &= tp->ic_max_width;
-#endif
 			} else
 				tp->widedone=1;
 
@@ -3655,13 +3388,8 @@
 		*/
 
 		if (!nego && !tp->period) {
-			if (tp->inq_byte7 & INQ7_SYNC) {
+			if (spi_support_sync(starget)) {
 				nego = NS_SYNC;
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-				if ((tp->ic_done) &&
-				 	      (tp->minsync < tp->ic_min_sync))
-		       			 tp->minsync = tp->ic_min_sync;
-#endif
 			} else {
 				tp->period  =0xffff;
 				PRINT_TARGET(np, cp->target);
@@ -3843,8 +3571,8 @@
 	**----------------------------------------------------
 	*/
 
-	direction = scsi_data_direction(cmd);
-	if (direction != SCSI_DATA_NONE) {
+	direction = cmd->sc_data_direction;
+	if (direction != DMA_NONE) {
 		segments = ncr_scatter(np, cp, cp->cmd);
 		if (segments < 0) {
 			ncr_free_ccb(np, cp);
@@ -3867,72 +3595,9 @@
 
 	cp->nego_status = 0;
 
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-	if ((np->check_integrity && tp->ic_done) || !np->check_integrity) {
-		 if ((!tp->widedone || !tp->period) && !tp->nego_cp && lp) {
-			msglen += ncr_prepare_nego (np, cp, msgptr + msglen);
-		 }
-	}
-	else if (np->check_integrity && (cmd->ic_in_progress)) { 
-		msglen += ncr_ic_nego (np, cp, cmd, msgptr + msglen);
-	}
-	else if (np->check_integrity && cmd->ic_complete) {
-		/*
-		 * Midlayer signal to the driver that all of the scsi commands
-		 * for the integrity check have completed. Save the negotiated
-		 * parameters (extracted from sval and wval). 
-		 */ 
-
-		{
-			u_char idiv;
-			idiv = (tp->wval>>4) & 0x07;
-			if ((tp->sval&0x1f) && idiv )
-				tp->period = (((tp->sval>>5)+4)  
-						*div_10M[idiv-1])/np->clock_khz;
-			else
-				tp->period = 0xffff;
-		}
-		/*
-		 * tp->period contains 10 times the transfer period, 
-		 * which itself is 4 * the requested negotiation rate.
-		 */
-		if	(tp->period <= 250)	tp->ic_min_sync = 10;
-		else if	(tp->period <= 303)	tp->ic_min_sync = 11;
-		else if	(tp->period <= 500)	tp->ic_min_sync = 12;
-		else				
-				tp->ic_min_sync = (tp->period + 40 - 1) / 40;
-
-
-		/*
-		 * Negotiation for this target it complete.
-		 */
-		tp->ic_max_width =  (tp->wval & EWS) ? 1: 0;
-		tp->ic_done = 1;
-		tp->widedone = 1;
-
-		printk("%s: Integrity Check Complete: \n", ncr_name(np)); 
-
-		printk("%s: %s %s SCSI", ncr_name(np), 
-				(tp->sval&0x1f)?"SYNC":"ASYNC",
-				tp->ic_max_width?"WIDE":"NARROW");
-
-		if (tp->sval&0x1f) {
-			u_long mbs = 10000 * (tp->ic_max_width + 1);
-
-			printk(" %d.%d  MB/s", (int) (mbs / tp->period),
-					(int) (mbs % tp->period));
-
-			printk(" (%d ns, %d offset)\n", 
-				  tp->period/10, tp->sval&0x1f);
-		} else {
-			printk(" %d MB/s. \n ", (tp->ic_max_width+1)*5);
-		}
-	}
-#else
 	if ((!tp->widedone || !tp->period) && !tp->nego_cp && lp) {
 		msglen += ncr_prepare_nego (np, cp, msgptr + msglen);
 	}
-#endif /* SCSI_NCR_INTEGRITY_CHECKING */
 
 	/*----------------------------------------------------
 	**
@@ -3941,17 +3606,17 @@
 	**----------------------------------------------------
 	*/
 	if (!cp->data_len)
-		direction = SCSI_DATA_NONE;
+		direction = DMA_NONE;
 
 	/*
-	**	If data direction is UNKNOWN, speculate DATA_READ 
-	**	but prepare alternate pointers for WRITE in case 
+	**	If data direction is BIDIRECTIONAL, speculate FROM_DEVICE
+	**	but prepare alternate pointers for TO_DEVICE in case 
 	**	of our speculation will be just wrong.
 	**	SCRIPTS will swap values if needed.
 	*/
 	switch(direction) {
-	case SCSI_DATA_UNKNOWN:
-	case SCSI_DATA_WRITE:
+	case DMA_BIDIRECTIONAL:
+	case DMA_TO_DEVICE:
 		goalp = NCB_SCRIPT_PHYS (np, data_out2) + 8;
 		if (segments <= MAX_SCATTERL)
 			lastp = goalp - 8 - (segments * 16);
@@ -3959,12 +3624,12 @@
 			lastp = NCB_SCRIPTH_PHYS (np, hdata_out2);
 			lastp -= (segments - MAX_SCATTERL) * 16;
 		}
-		if (direction != SCSI_DATA_UNKNOWN)
+		if (direction != DMA_BIDIRECTIONAL)
 			break;
 		cp->phys.header.wgoalp	= cpu_to_scr(goalp);
 		cp->phys.header.wlastp	= cpu_to_scr(lastp);
 		/* fall through */
-	case SCSI_DATA_READ:
+	case DMA_FROM_DEVICE:
 		goalp = NCB_SCRIPT_PHYS (np, data_in2) + 8;
 		if (segments <= MAX_SCATTERL)
 			lastp = goalp - 8 - (segments * 16);
@@ -3974,7 +3639,7 @@
 		}
 		break;
 	default:
-	case SCSI_DATA_NONE:
+	case DMA_NONE:
 		lastp = goalp = NCB_SCRIPT_PHYS (np, no_data);
 		break;
 	}
@@ -3986,7 +3651,7 @@
 	cp->phys.header.lastp = cpu_to_scr(lastp);
 	cp->phys.header.goalp = cpu_to_scr(goalp);
 
-	if (direction == SCSI_DATA_UNKNOWN)
+	if (direction == DMA_BIDIRECTIONAL)
 		cp->phys.header.savep = 
 			cpu_to_scr(NCB_SCRIPTH_PHYS (np, data_io));
 	else
@@ -4036,7 +3701,7 @@
 	/*
 	**	status
 	*/
-	cp->actualquirks		= tp->quirks;
+	cp->actualquirks		= 0;
 	cp->host_status			= cp->nego_status ? HS_NEGOTIATE : HS_BUSY;
 	cp->scsi_status			= S_ILLEGAL;
 	cp->parity_status		= 0;
@@ -4089,19 +3754,19 @@
 
 static void ncr_start_next_ccb(struct ncb *np, struct lcb *lp, int maxn)
 {
-	XPT_QUEHEAD *qp;
+	struct list_head *qp;
 	struct ccb *cp;
 
 	if (lp->held_ccb)
 		return;
 
 	while (maxn-- && lp->queuedccbs < lp->queuedepth) {
-		qp = xpt_remque_head(&lp->wait_ccbq);
+		qp = ncr_list_pop(&lp->wait_ccbq);
 		if (!qp)
 			break;
 		++lp->queuedccbs;
-		cp = xpt_que_entry(qp, struct ccb, link_ccbq);
-		xpt_insque_tail(qp, &lp->busy_ccbq);
+		cp = list_entry(qp, struct ccb, link_ccbq);
+		list_add_tail(qp, &lp->busy_ccbq);
 		lp->jump_ccb[cp->tag == NO_TAG ? 0 : cp->tag] =
 			cpu_to_scr(CCB_PHYS (cp, restart));
 		ncr_put_start_queue(np, cp);
@@ -4152,7 +3817,7 @@
 			ncr_name(np), settle_delay);
 
 	ncr_chip_reset(np, 100);
-	UDELAY (2000);	/* The 895 needs time for the bus mode to settle */
+	udelay(2000);	/* The 895 needs time for the bus mode to settle */
 	if (enab_int)
 		OUTW (nc_sien, RST);
 	/*
@@ -4161,7 +3826,7 @@
 	*/
 	OUTB (nc_stest3, TE);
 	OUTB (nc_scntl1, CRST);
-	UDELAY (200);
+	udelay(200);
 
 	if (!driver_setup.bus_check)
 		goto out;
@@ -4280,6 +3945,7 @@
 	return SUCCESS;
 }
 
+#if 0 /* unused and broken.. */
 /*==========================================================
 **
 **
@@ -4360,17 +4026,7 @@
 
 	return retv;
 }
-
-/*==========================================================
-**
-**	Linux release module stuff.
-**
-**	Called before unloading the module
-**	Detach the host.
-**	We have to free resources and halt the NCR chip
-**
-**==========================================================
-*/
+#endif
 
 static void ncr_detach(struct ncb *np)
 {
@@ -4395,7 +4051,8 @@
 	printk("%s: stopping the timer\n", ncr_name(np));
 #endif
 	np->release_stage = 1;
-	for (i = 50 ; i && np->release_stage != 2 ; i--) MDELAY (100);
+	for (i = 50 ; i && np->release_stage != 2 ; i--)
+		mdelay(100);
 	if (np->release_stage != 2)
 		printk("%s: the timer seems to be already stopped\n", ncr_name(np));
 	else np->release_stage = 2;
@@ -4536,8 +4193,7 @@
 
 	if (lp && lp->held_ccb) {
 		if (cp == lp->held_ccb) {
-			xpt_que_splice(&lp->skip_ccbq, &lp->wait_ccbq);
-			xpt_que_init(&lp->skip_ccbq);
+			list_splice_init(&lp->skip_ccbq, &lp->wait_ccbq);
 			lp->held_ccb = NULL;
 		}
 	}
@@ -4609,19 +4265,6 @@
 		if (!lp)
 			ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun);
 
-		/*
-		**	On standard INQUIRY response (EVPD and CmDt 
-		**	not set), setup logical unit according to 
-		**	announced capabilities (we need the 1rst 7 bytes).
-		*/
-		if (cmd->cmnd[0] == 0x12 && !(cmd->cmnd[1] & 0x3) &&
-		    cmd->cmnd[4] >= 7 && !cmd->use_sg) {
-			sync_scsi_data_for_cpu(np, cmd);	/* SYNC the data */
-			ncr_setup_lcb (np, cmd->device->id, cmd->device->lun,
-				       (char *) cmd->request_buffer);
-			sync_scsi_data_for_device(np, cmd);	/* SYNC the data */
-		}
-
 		tp->bytes     += cp->data_len;
 		tp->transfers ++;
 
@@ -4634,7 +4277,7 @@
 			if (lp->num_good >= 1000) {
 				lp->num_good = 0;
 				++lp->numtags;
-				ncr_setup_tags (np, cmd->device->id, cmd->device->lun);
+				ncr_setup_tags (np, cmd->device);
 			}
 		}
 	} else if ((cp->host_status == HS_COMPLETE)
@@ -4748,7 +4391,7 @@
 	**	requeue awaiting scsi commands for this lun.
 	*/
 	if (lp && lp->queuedccbs < lp->queuedepth &&
-	    !xpt_que_empty(&lp->wait_ccbq))
+	    !list_empty(&lp->wait_ccbq))
 		ncr_start_next_ccb(np, lp, 2);
 
 	/*
@@ -4785,8 +4428,8 @@
 		cp->host_status &= ~HS_SKIPMASK;
 		cp->start.schedule.l_paddr = 
 			cpu_to_scr(NCB_SCRIPT_PHYS (np, select));
-		xpt_remque(&cp->link_ccbq);
-		xpt_insque_tail(&cp->link_ccbq, &lp->skip_ccbq);
+		list_del(&cp->link_ccbq);
+		list_add_tail(&cp->link_ccbq, &lp->skip_ccbq);
 		if (cp->queued) {
 			--lp->queuedccbs;
 		}
@@ -4871,7 +4514,7 @@
 static void ncr_chip_reset(struct ncb *np, int delay)
 {
 	OUTB (nc_istat,  SRST);
-	UDELAY (delay);
+	udelay(delay);
 	OUTB (nc_istat,  0   );
 
 	if (np->features & FE_EHP)
@@ -4900,7 +4543,7 @@
 
 	if (reset) {
 		OUTB (nc_istat,  SRST);
-		UDELAY (100);
+		udelay(100);
 	}
 	else {
 		OUTB (nc_stest3, TE|CSF);
@@ -5084,8 +4727,11 @@
 	if (minsync > np->maxsync)
 		minsync = 255;
 
+	if (tp->maxoffs > np->maxoffs)
+		tp->maxoffs = np->maxoffs;
+
 	tp->minsync = minsync;
-	tp->maxoffs = (minsync<255 ? np->maxoffs : 0);
+	tp->maxoffs = (minsync<255 ? tp->maxoffs : 0);
 
 	/*
 	**	period=0: has to negotiate sync transfer
@@ -5215,18 +4861,12 @@
 
 static void ncr_setsync (struct ncb *np, struct ccb *cp, u_char scntl3, u_char sxfer)
 {
-	struct scsi_cmnd *cmd;
+	struct scsi_cmnd *cmd = cp->cmd;
 	struct tcb *tp;
 	u_char target = INB (nc_sdid) & 0x0f;
 	u_char idiv;
 
-	assert (cp && cp->cmd);
-	if (!cp) return;
-
-	cmd = cp->cmd;
-	if (!cmd) return;
-
-	assert (target == (cmd->device->id & 0xf));
+	BUG_ON(target != (cmd->device->id & 0xf));
 
 	tp = &np->target[target];
 
@@ -5299,19 +4939,13 @@
 
 static void ncr_setwide (struct ncb *np, struct ccb *cp, u_char wide, u_char ack)
 {
-	struct scsi_cmnd *cmd;
+	struct scsi_cmnd *cmd = cp->cmd;
 	u16 target = INB (nc_sdid) & 0x0f;
 	struct tcb *tp;
 	u_char	scntl3;
 	u_char	sxfer;
 
-	assert (cp && cp->cmd);
-	if (!cp) return;
-
-	cmd = cp->cmd;
-	if (!cmd) return;
-
-	assert (target == (cmd->device->id & 0xf));
+	BUG_ON(target != (cmd->device->id & 0xf));
 
 	tp = &np->target[target];
 	tp->widedone  =  wide+1;
@@ -5351,8 +4985,9 @@
 **==========================================================
 */
 
-static void ncr_setup_tags (struct ncb *np, u_char tn, u_char ln)
+static void ncr_setup_tags (struct ncb *np, struct scsi_device *sdev)
 {
+	unsigned char tn = sdev->id, ln = sdev->lun;
 	struct tcb *tp = &np->target[tn];
 	struct lcb *lp = tp->lp[ln];
 	u_char   reqtags, maxdepth;
@@ -5360,7 +4995,7 @@
 	/*
 	**	Just in case ...
 	*/
-	if ((!tp) || (!lp))
+	if ((!tp) || (!lp) || !sdev)
 		return;
 
 	/*
@@ -5384,7 +5019,7 @@
 	**	only devices capable of tagged commands
 	**	only if enabled by user ..
 	*/
-	if ((lp->inq_byte7 & INQ7_QUEUE) && lp->numtags > 1) {
+	if (sdev->tagged_supported && lp->numtags > 1) {
 		reqtags = lp->numtags;
 	} else {
 		reqtags = 1;
@@ -5438,86 +5073,6 @@
 	}
 }
 
-/*----------------------------------------------------
-**
-**	handle user commands
-**
-**----------------------------------------------------
-*/
-
-#ifdef SCSI_NCR_USER_COMMAND_SUPPORT
-
-static void ncr_usercmd (struct ncb *np)
-{
-	u_char t;
-	struct tcb *tp;
-
-	switch (np->user.cmd) {
-
-	case 0: return;
-
-	case UC_SETSYNC:
-		for (t=0; t<MAX_TARGET; t++) {
-			if (!((np->user.target>>t)&1)) continue;
-			tp = &np->target[t];
-			tp->usrsync = np->user.data;
-			ncr_negotiate (np, tp);
-		};
-		break;
-
-	case UC_SETTAGS:
-		for (t=0; t<MAX_TARGET; t++) {
-			int ln;
-			if (!((np->user.target>>t)&1)) continue;
-			np->target[t].usrtags = np->user.data;
-			for (ln = 0; ln < MAX_LUN; ln++) {
-				struct lcb *lp = np->target[t].lp[ln];
-				if (!lp)
-					continue;
-				lp->maxtags = lp->numtags = np->user.data;
-				ncr_setup_tags (np, t, ln);
-			}
- 		};
-		break;
-
-	case UC_SETDEBUG:
-#ifdef SCSI_NCR_DEBUG_INFO_SUPPORT
-		ncr_debug = np->user.data;
-#endif
-		break;
-
-	case UC_SETORDER:
-		np->order = np->user.data;
-		break;
-
-	case UC_SETVERBOSE:
-		np->verbose = np->user.data;
-		break;
-
-	case UC_SETWIDE:
-		for (t=0; t<MAX_TARGET; t++) {
-			u_long size;
-			if (!((np->user.target>>t)&1)) continue;
-			tp = &np->target[t];
-			size = np->user.data;
-			if (size > np->maxwide) size=np->maxwide;
-			tp->usrwide = size;
-			ncr_negotiate (np, tp);
-		};
-		break;
-
-	case UC_SETFLAG:
-		for (t=0; t<MAX_TARGET; t++) {
-			if (!((np->user.target>>t)&1)) continue;
-			tp = &np->target[t];
-			tp->usrflag = np->user.data;
-		};
-		break;
-	}
-	np->user.cmd=0;
-}
-#endif
-
 /*==========================================================
 **
 **
@@ -6002,13 +5557,6 @@
 	else
 		msg = M_ID_ERROR;
 
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-	/*
-	**      Save error message. For integrity check use only.
-	*/
-	if (np->check_integrity)
-		np->check_integ_par = msg;
-#endif
 
 	/*
 	 *	If the NCR stopped on a MOVE ^ DATA_IN, we jump to a 
@@ -6353,7 +5901,7 @@
 	struct scsi_cmnd *cmd	= cp->cmd;
 	struct tcb *tp	= &np->target[cmd->device->id];
 	struct lcb *lp	= tp->lp[cmd->device->lun];
-	XPT_QUEHEAD	*qp;
+	struct list_head *qp;
 	struct ccb *	cp2;
 	int		disc_cnt = 0;
 	int		busy_cnt = 0;
@@ -6367,10 +5915,10 @@
 	**	are before cp and busy ones after.
 	*/
 	if (lp) {
-		qp = lp->busy_ccbq.blink;
+		qp = lp->busy_ccbq.prev;
 		while (qp != &lp->busy_ccbq) {
-			cp2 = xpt_que_entry(qp, struct ccb, link_ccbq);
-			qp  = qp->blink;
+			cp2 = list_entry(qp, struct ccb, link_ccbq);
+			qp  = qp->prev;
 			++busy_cnt;
 			if (cp2 == cp)
 				break;
@@ -6398,7 +5946,7 @@
 		if (disc_cnt < lp->numtags) {
 			lp->numtags	= disc_cnt > 2 ? disc_cnt : 2;
 			lp->num_good	= 0;
-			ncr_setup_tags (np, cmd->device->id, cmd->device->lun);
+			ncr_setup_tags (np, cmd->device);
 		}
 		/*
 		**	Requeue the command to the start queue.
@@ -6450,7 +5998,7 @@
 		/*
 		**	sense data
 		*/
-		bzero(cp->sense_buf, sizeof(cp->sense_buf));
+		memset(cp->sense_buf, 0, sizeof(cp->sense_buf));
 		cp->phys.sense.addr	= cpu_to_scr(CCB_PHYS(cp,sense_buf[0]));
 		cp->phys.sense.size	= cpu_to_scr(sizeof(cp->sense_buf));
 
@@ -6475,7 +6023,7 @@
 		/*
 		**	Select without ATN for quirky devices.
 		*/
-		if (tp->quirks & QUIRK_NOMSG)
+		if (cmd->device->select_no_atn)
 			cp->start.schedule.l_paddr =
 			cpu_to_scr(NCB_SCRIPTH_PHYS (np, select_no_atn));
 
@@ -6537,6 +6085,7 @@
 	u_long	dsa    = INL (nc_dsa);
 	u_char	target = INB (nc_sdid) & 0x0f;
 	struct tcb *tp     = &np->target[target];
+	struct scsi_target *starget = tp->starget;
 
 	if (DEBUG_FLAGS & DEBUG_TINY) printk ("I#%d", num);
 
@@ -6591,7 +6140,8 @@
 		while (cp && (CCB_PHYS (cp, phys) != dsa))
 			cp = cp->link_ccb;
 
-		assert (cp && cp == np->header.cp);
+		BUG_ON(!cp);
+		BUG_ON(cp != np->header.cp);
 
 		if (!cp || cp != np->header.cp)
 			goto out;
@@ -6693,10 +6243,13 @@
 
 		case NS_SYNC:
 			ncr_setsync (np, cp, 0, 0xe0);
+			spi_period(starget) = 0;
+			spi_offset(starget) = 0;
 			break;
 
 		case NS_WIDE:
 			ncr_setwide (np, cp, 0, 0);
+			spi_width(starget) = 0;
 			break;
 
 		};
@@ -6731,8 +6284,8 @@
 		**	      it CAN transfer synch.
 		*/
 
-		if (ofs)
-			tp->inq_byte7 |= INQ7_SYNC;
+		if (ofs && tp->starget)
+			spi_support_sync(tp->starget) = 1;
 
 		/*
 		**	check values against driver limits.
@@ -6783,18 +6336,23 @@
 					**	Answer wasn't acceptable.
 					*/
 					ncr_setsync (np, cp, 0, 0xe0);
+					spi_period(starget) = 0;
+					spi_offset(starget) = 0;
 					OUTL_DSP (NCB_SCRIPT_PHYS (np, msg_bad));
 				} else {
 					/*
 					**	Answer is ok.
 					*/
 					ncr_setsync (np, cp, scntl3, (fak<<5)|ofs);
+					spi_period(starget) = per;
+					spi_offset(starget) = ofs;
 					OUTL_DSP (NCB_SCRIPT_PHYS (np, clrack));
 				};
 				return;
 
 			case NS_WIDE:
 				ncr_setwide (np, cp, 0, 0);
+				spi_width(starget) = 0;
 				break;
 			};
 		};
@@ -6805,6 +6363,8 @@
 		*/
 
 		ncr_setsync (np, cp, scntl3, (fak<<5)|ofs);
+		spi_period(starget) = per;
+		spi_offset(starget) = ofs;
 
 		np->msgout[0] = M_EXTENDED;
 		np->msgout[1] = 3;
@@ -6852,8 +6412,8 @@
 		**	      it CAN transfer wide.
 		*/
 
-		if (wide)
-			tp->inq_byte7 |= INQ7_WIDE16;
+		if (wide && tp->starget)
+			spi_support_wide(tp->starget) = 1;
 
 		/*
 		**	check values against driver limits.
@@ -6880,18 +6440,22 @@
 					**	Answer wasn't acceptable.
 					*/
 					ncr_setwide (np, cp, 0, 1);
+					spi_width(starget) = 0;
 					OUTL_DSP (NCB_SCRIPT_PHYS (np, msg_bad));
 				} else {
 					/*
 					**	Answer is ok.
 					*/
 					ncr_setwide (np, cp, wide, 1);
+					spi_width(starget) = wide;
 					OUTL_DSP (NCB_SCRIPT_PHYS (np, clrack));
 				};
 				return;
 
 			case NS_SYNC:
 				ncr_setsync (np, cp, 0, 0xe0);
+				spi_period(starget) = 0;
+				spi_offset(starget) = 0;
 				break;
 			};
 		};
@@ -6902,6 +6466,7 @@
 		*/
 
 		ncr_setwide (np, cp, wide, 1);
+		spi_width(starget) = wide;
 
 		np->msgout[0] = M_EXTENDED;
 		np->msgout[1] = 2;
@@ -7017,7 +6582,7 @@
 	**	Lun structure available ?
 	*/
 	if (lp) {
-		XPT_QUEHEAD *qp;
+		struct list_head *qp;
 		/*
 		**	Keep from using more tags than we can handle.
 		*/
@@ -7027,29 +6592,21 @@
 		/*
 		**	Allocate a new CCB if needed.
 		*/
-		if (xpt_que_empty(&lp->free_ccbq))
+		if (list_empty(&lp->free_ccbq))
 			ncr_alloc_ccb(np, tn, ln);
 
 		/*
-		**	Tune tag mode if asked by user.
-		*/
-		if (lp->queuedepth != lp->numtags) {
-			ncr_setup_tags(np, tn, ln);
-		}
-			
-		/*
 		**	Look for free CCB
 		*/
-		qp = xpt_remque_head(&lp->free_ccbq);
+		qp = ncr_list_pop(&lp->free_ccbq);
 		if (qp) {
-			cp = xpt_que_entry(qp, struct ccb, link_ccbq);
+			cp = list_entry(qp, struct ccb, link_ccbq);
 			if (cp->magic) {
 				PRINT_LUN(np, tn, ln);
 				printk ("ccb free list corrupted (@%p)\n", cp);
 				cp = NULL;
-			}
-			else {
-				xpt_insque_tail(qp, &lp->wait_ccbq);
+			} else {
+				list_add_tail(qp, &lp->wait_ccbq);
 				++lp->busyccbs;
 			}
 		}
@@ -7159,10 +6716,8 @@
 	*/
 
 	if (lp) {
-		if (cp != np->ccb) {
-			xpt_remque(&cp->link_ccbq);
-			xpt_insque_head(&cp->link_ccbq, &lp->free_ccbq);
-		}
+		if (cp != np->ccb)
+			list_move(&cp->link_ccbq, &lp->free_ccbq);
 		--lp->busyccbs;
 		if (cp->queued) {
 			--lp->queuedccbs;
@@ -7200,9 +6755,9 @@
 	cp->phys.header.cp = cp;
 
 	/*
-	**	This allows xpt_remque to work for the default ccb.
+	**	This allows list_del to work for the default ccb.
 	*/
-	xpt_que_init(&cp->link_ccbq);
+	INIT_LIST_HEAD(&cp->link_ccbq);
 
 	/*
 	**	Initialyze the start and restart launch script.
@@ -7246,7 +6801,7 @@
 	*/
 	lp->actccbs++;
 	np->actccbs++;
-	bzero (cp, sizeof (*cp));
+	memset(cp, 0, sizeof (*cp));
 	ncr_init_ccb(np, cp);
 
 	/*
@@ -7256,8 +6811,7 @@
 	cp->link_ccb      = np->ccb->link_ccb;
 	np->ccb->link_ccb = cp;
 
-	xpt_insque_head(&cp->link_ccbq, &lp->free_ccbq);
-	ncr_setup_tags (np, tn, ln);
+	list_add(&cp->link_ccbq, &lp->free_ccbq);
 }
 
 /*==========================================================
@@ -7345,15 +6899,15 @@
 	**	These assert's should be moved at driver initialisations.
 	*/
 #ifdef SCSI_NCR_BIG_ENDIAN
-	assert (( (offsetof(struct ncr_reg, nc_sxfer) ^
-		offsetof(struct tcb    , sval    )) &3) == 3);
-	assert (( (offsetof(struct ncr_reg, nc_scntl3) ^
-		offsetof(struct tcb    , wval    )) &3) == 3);
+	BUG_ON(((offsetof(struct ncr_reg, nc_sxfer) ^
+		 offsetof(struct tcb    , sval    )) &3) != 3);
+	BUG_ON(((offsetof(struct ncr_reg, nc_scntl3) ^
+		 offsetof(struct tcb    , wval    )) &3) != 3);
 #else
-	assert (( (offsetof(struct ncr_reg, nc_sxfer) ^
-		offsetof(struct tcb    , sval    )) &3) == 0);
-	assert (( (offsetof(struct ncr_reg, nc_scntl3) ^
-		offsetof(struct tcb    , wval    )) &3) == 0);
+	BUG_ON(((offsetof(struct ncr_reg, nc_sxfer) ^
+		 offsetof(struct tcb    , sval    )) &3) != 0);
+	BUG_ON(((offsetof(struct ncr_reg, nc_scntl3) ^
+		 offsetof(struct tcb    , wval    )) &3) != 0);
 #endif
 }
 
@@ -7384,7 +6938,7 @@
 	lp = m_calloc_dma(sizeof(struct lcb), "LCB");
 	if (!lp)
 		goto fail;
-	bzero(lp, sizeof(*lp));
+	memset(lp, 0, sizeof(*lp));
 	tp->lp[ln] = lp;
 
 	/*
@@ -7396,10 +6950,10 @@
 	/*
 	**	Initialize the CCB queue headers.
 	*/
-	xpt_que_init(&lp->free_ccbq);
-	xpt_que_init(&lp->busy_ccbq);
-	xpt_que_init(&lp->wait_ccbq);
-	xpt_que_init(&lp->skip_ccbq);
+	INIT_LIST_HEAD(&lp->free_ccbq);
+	INIT_LIST_HEAD(&lp->busy_ccbq);
+	INIT_LIST_HEAD(&lp->wait_ccbq);
+	INIT_LIST_HEAD(&lp->skip_ccbq);
 
 	/*
 	**	Set max CCBs to 1 and use the default 1 entry 
@@ -7455,11 +7009,12 @@
 **	will play with CHANGE DEFINITION commands. :-)
 **------------------------------------------------------------------------
 */
-static struct lcb *ncr_setup_lcb (struct ncb *np, u_char tn, u_char ln, u_char *inq_data)
+static struct lcb *ncr_setup_lcb (struct ncb *np, struct scsi_device *sdev)
 {
+	unsigned char tn = sdev->id, ln = sdev->lun;
 	struct tcb *tp = &np->target[tn];
 	struct lcb *lp = tp->lp[ln];
-	u_char inq_byte7;
+	struct scsi_target *starget = tp->starget;
 
 	/*
 	**	If no lcb, try to allocate it.
@@ -7468,55 +7023,16 @@
 		goto fail;
 
 	/*
-	**	Get device quirks from a speciality table.
-	*/
-	tp->quirks = ncr_lookup (inq_data);
-	if (tp->quirks && bootverbose) {
-		PRINT_LUN(np, tn, ln);
-		printk ("quirks=%x.\n", tp->quirks);
-	}
-
-	/*
-	**	Evaluate trustable target/unit capabilities.
-	**	We only believe device version >= SCSI-2 that 
-	**	use appropriate response data format (2).
-	**	But it seems that some CCS devices also 
-	**	support SYNC and I donnot want to frustrate 
-	**	anybody. ;-)
-	*/
-	inq_byte7 = 0;
-	if	((inq_data[2] & 0x7) >= 2 && (inq_data[3] & 0xf) == 2)
-		inq_byte7 = inq_data[7];
-	else if ((inq_data[2] & 0x7) == 1 && (inq_data[3] & 0xf) == 1)
-		inq_byte7 = INQ7_SYNC;
-
-	/*
-	**	Throw away announced LUN capabilities if we are told 
-	**	that there is no real device supported by the logical unit.
-	*/
-	if ((inq_data[0] & 0xe0) > 0x20 || (inq_data[0] & 0x1f) == 0x1f)
-		inq_byte7 &= (INQ7_SYNC | INQ7_WIDE16);
-
-	/*
-	**	If user is wanting SYNC, force this feature.
+	**	Prepare negotiation
 	*/
-	if (driver_setup.force_sync_nego)
-		inq_byte7 |= INQ7_SYNC;
-
-	/*
-	**	Prepare negotiation if SIP capabilities have changed.
-	*/
-	tp->inq_done = 1;
-	if ((inq_byte7 ^ tp->inq_byte7) & (INQ7_SYNC | INQ7_WIDE16)) {
-		tp->inq_byte7 = inq_byte7;
+	if (spi_support_wide(starget) || spi_support_sync(starget))
 		ncr_negotiate(np, tp);
-	}
 
 	/*
 	**	If unit supports tagged commands, allocate the 
 	**	CCB JUMP table if not yet.
 	*/
-	if ((inq_byte7 & INQ7_QUEUE) && lp->jump_ccb == &lp->jump_ccb_0) {
+	if (sdev->tagged_supported && lp->jump_ccb == &lp->jump_ccb_0) {
 		int i;
 		lp->jump_ccb = m_calloc_dma(256, "JUMP_CCB");
 		if (!lp->jump_ccb) {
@@ -7531,16 +7047,9 @@
 			lp->cb_tags[i] = i;
 		lp->maxnxs = MAX_TAGS;
 		lp->tags_stime = ktime_get(3*HZ);
+		ncr_setup_tags (np, sdev);
 	}
 
-	/*
-	**	Adjust tagged queueing status if needed.
-	*/
-	if ((inq_byte7 ^ lp->inq_byte7) & INQ7_QUEUE) {
-		lp->inq_byte7 = inq_byte7;
-		lp->numtags   = lp->maxtags;
-		ncr_setup_tags (np, tn, ln);
-	}
 
 fail:
 	return lp;
@@ -7748,62 +7257,6 @@
 
 /*==========================================================
 **
-**
-**	Device lookup.
-**
-**	@GENSCSI@ should be integrated to scsiconf.c
-**
-**
-**==========================================================
-*/
-
-struct table_entry {
-	char *	manufacturer;
-	char *	model;
-	char *	version;
-	u_long	info;
-};
-
-static struct table_entry device_tab[] =
-{
-#if 0
-	{"", "", "", QUIRK_NOMSG},
-#endif
-	{"SONY", "SDT-5000", "3.17", QUIRK_NOMSG},
-	{"WangDAT", "Model 2600", "01.7", QUIRK_NOMSG},
-	{"WangDAT", "Model 3200", "02.2", QUIRK_NOMSG},
-	{"WangDAT", "Model 1300", "02.4", QUIRK_NOMSG},
-	{"", "", "", 0} /* catch all: must be last entry. */
-};
-
-static u_long ncr_lookup(char * id)
-{
-	struct table_entry * p = device_tab;
-	char *d, *r, c;
-
-	for (;;p++) {
-
-		d = id+8;
-		r = p->manufacturer;
-		while ((c=*r++)) if (c!=*d++) break;
-		if (c) continue;
-
-		d = id+16;
-		r = p->model;
-		while ((c=*r++)) if (c!=*d++) break;
-		if (c) continue;
-
-		d = id+32;
-		r = p->version;
-		while ((c=*r++)) if (c!=*d++) break;
-		if (c) continue;
-
-		return (p->info);
-	}
-}
-
-/*==========================================================
-**
 **	Determine the ncr's clock frequency.
 **	This is essential for the negotiation
 **	of the synchronous transfer rate.
@@ -7842,11 +7295,11 @@
 	if (np->multiplier > 2) {  /* Poll bit 5 of stest4 for quadrupler */
 		int i = 20;
 		while (!(INB(nc_stest4) & LCKFRQ) && --i > 0)
-			UDELAY (20);
+			udelay(20);
 		if (!i)
 			printk("%s: the chip cannot lock the frequency\n", ncr_name(np));
 	} else			/* Wait 20 micro-seconds for doubler	*/
-		UDELAY (20);
+		udelay(20);
 	OUTB(nc_stest3, HSC);		/* Halt the scsi clock		*/
 	OUTB(nc_scntl3,	scntl3);
 	OUTB(nc_stest1, (DBLEN|DBLSEL));/* Select clock multiplier	*/
@@ -7887,7 +7340,7 @@
 	OUTB (nc_stime1, gen);	/* set to nominal delay of 1<<gen * 125us */
 	while (!(INW(nc_sist) & GEN) && ms++ < 100000) {
 		for (count = 0; count < 10; count ++)
-			UDELAY (100);	/* count ms */
+			udelay(100);	/* count ms */
 	}
 	OUTB (nc_stime1, 0);	/* disable general purpose timer */
  	/*
@@ -7971,21 +7424,17 @@
 
 /*===================== LINUX ENTRY POINTS SECTION ==========================*/
 
-/*
-**   Linux select queue depths function
-*/
-
-int ncr53c8xx_slave_configure(struct scsi_device *device)
+static int ncr53c8xx_slave_configure(struct scsi_device *device)
 {
 	struct Scsi_Host *host = device->host;
-	struct ncb *np;
-	struct tcb *tp;
-	struct lcb *lp;
+	struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
+	struct tcb *tp = &np->target[device->id];
+	struct lcb *lp = tp->lp[device->lun];
 	int numtags, depth_to_use;
 
-	np = ((struct host_data *) host->hostdata)->ncb;
-	tp = &np->target[device->id];
-	lp = tp->lp[device->lun];
+	tp->starget = device->sdev_target;
+
+	ncr_setup_lcb(np, device);
 
 	/*
 	**	Select queue depth from driver setup.
@@ -8013,26 +7462,29 @@
 	**	Since the queue depth is not tunable under Linux,
 	**	we need to know this value in order not to 
 	**	announce stupid things to user.
+	**
+	**	XXX(hch): As of Linux 2.6 it certainly _is_ tunable..
+	**		  In fact we just tuned it, or did I miss
+	**		  something important? :)
 	*/
 	if (lp) {
 		lp->numtags = lp->maxtags = numtags;
 		lp->scdev_depth = depth_to_use;
 	}
-	ncr_setup_tags (np, device->id, device->lun);
+	ncr_setup_tags (np, device);
 
 #ifdef DEBUG_NCR53C8XX
 	printk("ncr53c8xx_select_queue_depth: host=%d, id=%d, lun=%d, depth=%d\n",
 	       np->unit, device->id, device->lun, depth_to_use);
 #endif
 
+	if (spi_support_sync(device->sdev_target) &&
+	    !spi_initial_dv(device->sdev_target))
+		spi_dv_device(device);
 	return 0;
 }
 
-/*
-**   Linux entry point of queuecommand() function
-*/
-
-int ncr53c8xx_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
+static int ncr53c8xx_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
 {
      struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
      unsigned long flags;
@@ -8047,7 +7499,7 @@
      cmd->__data_mapped = 0;
      cmd->__data_mapping = 0;
 
-     NCR_LOCK_NCB(np, flags);
+     spin_lock_irqsave(&np->smp_lock, flags);
 
      if ((sts = ncr_queue_command(np, cmd)) != DID_OK) {
 	  cmd->result = ScsiResult(sts, 0);
@@ -8060,24 +7512,17 @@
 printk("ncr53c8xx : command successfully queued\n");
 #endif
 
-     NCR_UNLOCK_NCB(np, flags);
+     spin_unlock_irqrestore(&np->smp_lock, flags);
 
      if (sts != DID_OK) {
           unmap_scsi_data(np, cmd);
           done(cmd);
+	  sts = 0;
      }
 
      return sts;
 }
 
-/*
-**   Linux entry point of the interrupt handler.
-**   Since linux versions > 1.3.70, we trust the kernel for 
-**   passing the internal host descriptor as 'dev_id'.
-**   Otherwise, we scan the host list and call the interrupt 
-**   routine for each host that uses this IRQ.
-*/
-
 irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs)
 {
      unsigned long flags;
@@ -8092,58 +7537,42 @@
 
      if (DEBUG_FLAGS & DEBUG_TINY) printk ("[");
 
-     NCR_LOCK_NCB(np, flags);
+     spin_lock_irqsave(&np->smp_lock, flags);
      ncr_exception(np);
      done_list     = np->done_list;
      np->done_list = NULL;
-     NCR_UNLOCK_NCB(np, flags);
+     spin_unlock_irqrestore(&np->smp_lock, flags);
 
      if (DEBUG_FLAGS & DEBUG_TINY) printk ("]\n");
 
-     if (done_list) {
-          NCR_LOCK_SCSI_DONE(done_list->device->host, flags);
-          ncr_flush_done_cmds(done_list);
-          NCR_UNLOCK_SCSI_DONE(done_list->device->host, flags);
-     }
+     if (done_list)
+	     ncr_flush_done_cmds(done_list);
      return IRQ_HANDLED;
 }
 
-/*
-**   Linux entry point of the timer handler
-*/
-
 static void ncr53c8xx_timeout(unsigned long npref)
 {
-     struct ncb *np = (struct ncb *) npref;
-     unsigned long flags;
-     struct scsi_cmnd *done_list;
+	struct ncb *np = (struct ncb *) npref;
+	unsigned long flags;
+	struct scsi_cmnd *done_list;
 
-     NCR_LOCK_NCB(np, flags);
-     ncr_timeout(np);
-     done_list     = np->done_list;
-     np->done_list = NULL;
-     NCR_UNLOCK_NCB(np, flags);
+	spin_lock_irqsave(&np->smp_lock, flags);
+	ncr_timeout(np);
+	done_list     = np->done_list;
+	np->done_list = NULL;
+	spin_unlock_irqrestore(&np->smp_lock, flags);
 
-     if (done_list) {
-          NCR_LOCK_SCSI_DONE(done_list->device->host, flags);
-          ncr_flush_done_cmds(done_list);
-          NCR_UNLOCK_SCSI_DONE(done_list->device->host, flags);
-     }
+	if (done_list)
+		ncr_flush_done_cmds(done_list);
 }
 
-/*
-**   Linux entry point of reset() function
-*/
-
-int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd)
+static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd)
 {
 	struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
 	int sts;
 	unsigned long flags;
 	struct scsi_cmnd *done_list;
 
-	NCR_LOCK_NCB(np, flags);
-
 	/*
 	 * If the mid-level driver told us reset is synchronous, it seems 
 	 * that we must call the done() callback for the involved command, 
@@ -8151,22 +7580,20 @@
 	 * before returning SUCCESS.
 	 */
 
+	spin_lock_irqsave(&np->smp_lock, flags);
 	sts = ncr_reset_bus(np, cmd, 1);
 
 	done_list     = np->done_list;
 	np->done_list = NULL;
-	NCR_UNLOCK_NCB(np, flags);
+	spin_unlock_irqrestore(&np->smp_lock, flags);
 
 	ncr_flush_done_cmds(done_list);
 
 	return sts;
 }
 
-/*
-**   Linux entry point of abort() function
-*/
-
-int ncr53c8xx_abort(struct scsi_cmnd *cmd)
+#if 0 /* unused and broken */
+static int ncr53c8xx_abort(struct scsi_cmnd *cmd)
 {
 	struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
 	int sts;
@@ -8202,6 +7629,7 @@
 
 	return sts;
 }
+#endif
 
 
 /*
@@ -8286,291 +7714,23 @@
 
 #undef next_wcmd
 
-#ifdef SCSI_NCR_PROC_INFO_SUPPORT
-
-/*=========================================================================
-**	Proc file system stuff
-**
-**	A read operation returns profile information.
-**	A write operation is a control command.
-**	The string is parsed in the driver code and the command is passed 
-**	to the ncr_usercmd() function.
-**=========================================================================
-*/
-
-#ifdef SCSI_NCR_USER_COMMAND_SUPPORT
-
-#define is_digit(c)	((c) >= '0' && (c) <= '9')
-#define digit_to_bin(c)	((c) - '0')
-#define is_space(c)	((c) == ' ' || (c) == '\t')
-
-static int skip_spaces(char *ptr, int len)
-{
-	int cnt, c;
-
-	for (cnt = len; cnt > 0 && (c = *ptr++) && is_space(c); cnt--);
-
-	return (len - cnt);
-}
-
-static int get_int_arg(char *ptr, int len, u_long *pv)
-{
-	int	cnt, c;
-	u_long	v;
-
-	for (v = 0, cnt = len; cnt > 0 && (c = *ptr++) && is_digit(c); cnt--) {
-		v = (v * 10) + digit_to_bin(c);
-	}
-
-	if (pv)
-		*pv = v;
-
-	return (len - cnt);
-}
-
-static int is_keyword(char *ptr, int len, char *verb)
-{
-	int verb_len = strlen(verb);
-
-	if (len >= strlen(verb) && !memcmp(verb, ptr, verb_len))
-		return verb_len;
-	else
-		return 0;
-
-}
-
-#define SKIP_SPACES(min_spaces)						\
-	if ((arg_len = skip_spaces(ptr, len)) < (min_spaces))		\
-		return -EINVAL;						\
-	ptr += arg_len; len -= arg_len;
-
-#define GET_INT_ARG(v)							\
-	if (!(arg_len = get_int_arg(ptr, len, &(v))))			\
-		return -EINVAL;						\
-	ptr += arg_len; len -= arg_len;
-
-
-/*
-**	Parse a control command
-*/
-
-static int ncr_user_command(struct ncb *np, char *buffer, int length)
-{
-	char *ptr	= buffer;
-	int len		= length;
-	struct usrcmd	 *uc = &np->user;
-	int		arg_len;
-	u_long 		target;
-
-	bzero(uc, sizeof(*uc));
-
-	if (len > 0 && ptr[len-1] == '\n')
-		--len;
-
-	if	((arg_len = is_keyword(ptr, len, "setsync")) != 0)
-		uc->cmd = UC_SETSYNC;
-	else if	((arg_len = is_keyword(ptr, len, "settags")) != 0)
-		uc->cmd = UC_SETTAGS;
-	else if	((arg_len = is_keyword(ptr, len, "setorder")) != 0)
-		uc->cmd = UC_SETORDER;
-	else if	((arg_len = is_keyword(ptr, len, "setverbose")) != 0)
-		uc->cmd = UC_SETVERBOSE;
-	else if	((arg_len = is_keyword(ptr, len, "setwide")) != 0)
-		uc->cmd = UC_SETWIDE;
-	else if	((arg_len = is_keyword(ptr, len, "setdebug")) != 0)
-		uc->cmd = UC_SETDEBUG;
-	else if	((arg_len = is_keyword(ptr, len, "setflag")) != 0)
-		uc->cmd = UC_SETFLAG;
-	else
-		arg_len = 0;
-
-#ifdef DEBUG_PROC_INFO
-printk("ncr_user_command: arg_len=%d, cmd=%ld\n", arg_len, uc->cmd);
-#endif
-
-	if (!arg_len)
-		return -EINVAL;
-	ptr += arg_len; len -= arg_len;
-
-	switch(uc->cmd) {
-	case UC_SETSYNC:
-	case UC_SETTAGS:
-	case UC_SETWIDE:
-	case UC_SETFLAG:
-		SKIP_SPACES(1);
-		if ((arg_len = is_keyword(ptr, len, "all")) != 0) {
-			ptr += arg_len; len -= arg_len;
-			uc->target = ~0;
-		} else {
-			GET_INT_ARG(target);
-			uc->target = (1<<target);
-#ifdef DEBUG_PROC_INFO
-printk("ncr_user_command: target=%ld\n", target);
-#endif
-		}
-		break;
-	}
-
-	switch(uc->cmd) {
-	case UC_SETVERBOSE:
-	case UC_SETSYNC:
-	case UC_SETTAGS:
-	case UC_SETWIDE:
-		SKIP_SPACES(1);
-		GET_INT_ARG(uc->data);
-#ifdef DEBUG_PROC_INFO
-printk("ncr_user_command: data=%ld\n", uc->data);
-#endif
-		break;
-	case UC_SETORDER:
-		SKIP_SPACES(1);
-		if	((arg_len = is_keyword(ptr, len, "simple")))
-			uc->data = M_SIMPLE_TAG;
-		else if	((arg_len = is_keyword(ptr, len, "ordered")))
-			uc->data = M_ORDERED_TAG;
-		else if	((arg_len = is_keyword(ptr, len, "default")))
-			uc->data = 0;
-		else
-			return -EINVAL;
-		break;
-	case UC_SETDEBUG:
-		while (len > 0) {
-			SKIP_SPACES(1);
-			if	((arg_len = is_keyword(ptr, len, "alloc")))
-				uc->data |= DEBUG_ALLOC;
-			else if	((arg_len = is_keyword(ptr, len, "phase")))
-				uc->data |= DEBUG_PHASE;
-			else if	((arg_len = is_keyword(ptr, len, "queue")))
-				uc->data |= DEBUG_QUEUE;
-			else if	((arg_len = is_keyword(ptr, len, "result")))
-				uc->data |= DEBUG_RESULT;
-			else if	((arg_len = is_keyword(ptr, len, "scatter")))
-				uc->data |= DEBUG_SCATTER;
-			else if	((arg_len = is_keyword(ptr, len, "script")))
-				uc->data |= DEBUG_SCRIPT;
-			else if	((arg_len = is_keyword(ptr, len, "tiny")))
-				uc->data |= DEBUG_TINY;
-			else if	((arg_len = is_keyword(ptr, len, "timing")))
-				uc->data |= DEBUG_TIMING;
-			else if	((arg_len = is_keyword(ptr, len, "nego")))
-				uc->data |= DEBUG_NEGO;
-			else if	((arg_len = is_keyword(ptr, len, "tags")))
-				uc->data |= DEBUG_TAGS;
-			else
-				return -EINVAL;
-			ptr += arg_len; len -= arg_len;
-		}
-#ifdef DEBUG_PROC_INFO
-printk("ncr_user_command: data=%ld\n", uc->data);
-#endif
-		break;
-	case UC_SETFLAG:
-		while (len > 0) {
-			SKIP_SPACES(1);
-			if	((arg_len = is_keyword(ptr, len, "trace")))
-				uc->data |= UF_TRACE;
-			else if	((arg_len = is_keyword(ptr, len, "no_disc")))
-				uc->data |= UF_NODISC;
-			else
-				return -EINVAL;
-			ptr += arg_len; len -= arg_len;
-		}
-		break;
-	default:
-		break;
-	}
-
-	if (len)
-		return -EINVAL;
-	else {
-		unsigned long flags;
-
-		NCR_LOCK_NCB(np, flags);
-		ncr_usercmd (np);
-		NCR_UNLOCK_NCB(np, flags);
-	}
-	return length;
-}
-
-#endif	/* SCSI_NCR_USER_COMMAND_SUPPORT */
-
-
-#ifdef SCSI_NCR_USER_INFO_SUPPORT
-/*
-**	Copy formatted information into the input buffer.
-*/
-
-static int ncr_host_info(struct ncb *np, char *ptr, off_t offset, int len)
+static ssize_t show_ncr53c8xx_revision(struct class_device *dev, char *buf)
 {
-	struct info_str info;
-
-	info.buffer	= ptr;
-	info.length	= len;
-	info.offset	= offset;
-	info.pos	= 0;
-
-	copy_info(&info, "  Chip NCR53C720, revision id 0x%x, IRQ %d\n",
-			 np->revision_id, (int) np->irq);
-	copy_info(&info, "  Synchronous period factor %d, "
-			 "max commands per lun %d\n",
-			 (int) np->minsync, MAX_TAGS);
-
-	if (driver_setup.debug || driver_setup.verbose > 1) {
-		copy_info(&info, "  Debug flags 0x%x, verbosity level %d\n",
-			  driver_setup.debug, driver_setup.verbose);
-	}
-
-	return info.pos > info.offset? info.pos - info.offset : 0;
-}
-
-#endif /* SCSI_NCR_USER_INFO_SUPPORT */
-
-/*
-**	Entry point of the scsi proc fs of the driver.
-**	- func = 0 means read  (returns profile data)
-**	- func = 1 means write (parse user control command)
-*/
-
-static int ncr53c8xx_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
-			int length, int func)
-{
-	struct host_data *host_data;
-	struct ncb *ncb = NULL;
-	int retv;
-
-#ifdef DEBUG_PROC_INFO
-printk("ncr53c8xx_proc_info: hostno=%d, func=%d\n", host->host_no, func);
-#endif
-
-	host_data = (struct host_data *) host->hostdata;
-	ncb = host_data->ncb;
-
-	if (func) {
-#ifdef	SCSI_NCR_USER_COMMAND_SUPPORT
-		retv = ncr_user_command(ncb, buffer, length);
-#else
-		retv = -EINVAL;
-#endif
-	}
-	else {
-		if (start)
-			*start = buffer;
-#ifdef SCSI_NCR_USER_INFO_SUPPORT
-		retv = ncr_host_info(ncb, buffer, offset, length);
-#else
-		retv = -EINVAL;
-#endif
-	}
-
-	return retv;
-}
-
-/*=========================================================================
-**	End of proc file system stuff
-**=========================================================================
-*/
-#endif
-
+	struct Scsi_Host *host = class_to_shost(dev);
+	struct host_data *host_data = (struct host_data *)host->hostdata;
+  
+	return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id);
+}
+  
+static struct class_device_attribute ncr53c8xx_revision_attr = {
+	.attr	= { .name = "revision", .mode = S_IRUGO, },
+	.show	= show_ncr53c8xx_revision,
+};
+  
+static struct class_device_attribute *ncr53c8xx_host_attrs[] = {
+	&ncr53c8xx_revision_attr,
+	NULL
+};
 
 /*==========================================================
 **
@@ -8580,10 +7740,10 @@
 */
 #ifdef	MODULE
 char *ncr53c8xx;	/* command line passed by insmod */
-MODULE_PARM(ncr53c8xx, "s");
+module_param(ncr53c8xx, charp, 0);
 #endif
 
-int __init ncr53c8xx_setup(char *str)
+static int __init ncr53c8xx_setup(char *str)
 {
 	return sym53c8xx__setup(str);
 }
@@ -8592,17 +7752,6 @@
 __setup("ncr53c8xx=", ncr53c8xx_setup);
 #endif
 
-/*==========================================================
-**
-**   Entry point for info() function
-**
-**==========================================================
-*/
-const char *ncr53c8xx_info (struct Scsi_Host *host)
-{
-	return SCSI_NCR_DRIVER_NAME;
-}
-
 
 /*
  *	Host attach and initialisations.
@@ -8622,13 +7771,14 @@
 	u_long flags = 0;
 	int i;
 
-#ifdef SCSI_NCR_PROC_INFO_SUPPORT
-	tpnt->proc_info		= ncr53c8xx_proc_info,
-#endif
-	tpnt->info 		= ncr53c8xx_info;
+	if (!tpnt->name)
+		tpnt->name	= SCSI_NCR_DRIVER_NAME;
+	if (!tpnt->shost_attrs)
+		tpnt->shost_attrs = ncr53c8xx_host_attrs;
+
 	tpnt->queuecommand	= ncr53c8xx_queue_command;
 	tpnt->slave_configure	= ncr53c8xx_slave_configure;
-	tpnt->eh_bus_reset_handler	= ncr53c8xx_bus_reset;
+	tpnt->eh_bus_reset_handler = ncr53c8xx_bus_reset;
 	tpnt->can_queue		= SCSI_NCR_CAN_QUEUE;
 	tpnt->this_id		= 7;
 	tpnt->sg_tablesize	= SCSI_NCR_SG_TABLESIZE;
@@ -8649,7 +7799,7 @@
 	np = __m_calloc_dma(device->dev, sizeof(struct ncb), "NCB");
 	if (!np)
 		goto attach_error;
-	NCR_INIT_LOCK_NCB(np);
+	spin_lock_init(&np->smp_lock);
 	np->dev = device->dev;
 	np->p_ncb = vtobus(np);
 	host_data->ncb = np;
@@ -8689,7 +7839,7 @@
 	if (device->slot.base_v)
 		np->vaddr = device->slot.base_v;
 	else
-		np->vaddr = (unsigned long)ioremap(device->slot.base_c, 128);
+		np->vaddr = ioremap(device->slot.base_c, 128);
 
 	if (!np->vaddr) {
 		printk(KERN_ERR
@@ -8705,7 +7855,7 @@
 	 * OUTB OUTW OUTL macros can be used safely.
 	 */
 
-	np->reg = (struct ncr_reg*) np->vaddr;
+	np->reg = (struct ncr_reg __iomem *)np->vaddr;
 
 	/* Do chip dependent initialization.  */
 	ncr_prepare_setting(np);
@@ -8716,7 +7866,6 @@
 			ncr_name(np));
 	}
 
-	/* Fill Linux host instance structure */
 	instance->max_channel	= 0;
 	instance->this_id       = np->myaddr;
 	instance->max_id	= np->maxwide ? 16 : 8;
@@ -8727,19 +7876,12 @@
 	instance->dma_channel	= 0;
 	instance->cmd_per_lun	= MAX_TAGS;
 	instance->can_queue	= (MAX_START-4);
+	/* This can happen if you forget to call ncr53c8xx_init from
+	 * your module_init */
+	BUG_ON(!ncr53c8xx_transport_template);
+	instance->transportt	= ncr53c8xx_transport_template;
 	scsi_set_device(instance, device->dev);
 
-#ifdef SCSI_NCR_INTEGRITY_CHECKING
-	np->check_integrity	  = 0;
-	instance->check_integrity = 0;
-
-#ifdef SCSI_NCR_ENABLE_INTEGRITY_CHECK
-	if ( !(driver_setup.bus_check & 0x04) ) {
-		np->check_integrity	  = 1;
-		instance->check_integrity = 1;
-	}
-#endif
-#endif
 	/* Patch script to physical addresses */
 	ncr_script_fill(&script0, &scripth0);
 
@@ -8797,11 +7939,11 @@
 	 * Process the reset exception if interrupts are not enabled yet.
 	 * Then enable disconnects.
 	 */
-	NCR_LOCK_NCB(np, flags);
+	spin_lock_irqsave(&np->smp_lock, flags);
 	if (ncr_reset_scsi_bus(np, 0, driver_setup.settle_delay) != 0) {
 		printk(KERN_ERR "%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr_name(np));
 
-		NCR_UNLOCK_NCB(np, flags);
+		spin_unlock_irqrestore(&np->smp_lock, flags);
 		goto attach_error;
 	}
 	ncr_exception(np);
@@ -8815,7 +7957,7 @@
 	if (driver_setup.settle_delay > 2) {
 		printk(KERN_INFO "%s: waiting %d seconds for scsi devices to settle...\n",
 			ncr_name(np), driver_setup.settle_delay);
-		MDELAY (1000 * driver_setup.settle_delay);
+		mdelay(1000 * driver_setup.settle_delay);
 	}
 
 	/* start the timeout daemon */
@@ -8827,7 +7969,7 @@
 	np->order = M_SIMPLE_TAG;
 #endif
 
-	NCR_UNLOCK_NCB(np, flags);
+	spin_unlock_irqrestore(&np->smp_lock, flags);
 
 	return instance;
 
@@ -8865,4 +8007,74 @@
 	if (host_data && host_data->ncb)
 		ncr_detach(host_data->ncb);
 	return 1;
+}
+
+static void ncr53c8xx_set_period(struct scsi_target *starget, int period)
+{
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct tcb *tp = &np->target[starget->id];
+
+	if (period > np->maxsync)
+		period = np->maxsync;
+	else if (period < np->minsync)
+		period = np->minsync;
+
+	tp->usrsync = period;
+
+	ncr_negotiate(np, tp);
+}
+
+static void ncr53c8xx_set_offset(struct scsi_target *starget, int offset)
+{
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct tcb *tp = &np->target[starget->id];
+
+	if (offset > np->maxoffs)
+		offset = np->maxoffs;
+	else if (offset < 0)
+		offset = 0;
+
+	tp->maxoffs = offset;
+
+	ncr_negotiate(np, tp);
+}
+
+static void ncr53c8xx_set_width(struct scsi_target *starget, int width)
+{
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct tcb *tp = &np->target[starget->id];
+
+	if (width > np->maxwide)
+		width = np->maxwide;
+	else if (width < 0)
+		width = 0;
+
+	tp->usrwide = width;
+
+	ncr_negotiate(np, tp);
+}
+
+static struct spi_function_template ncr53c8xx_transport_functions =  {
+	.set_period	= ncr53c8xx_set_period,
+	.show_period	= 1,
+	.set_offset	= ncr53c8xx_set_offset,
+	.show_offset	= 1,
+	.set_width	= ncr53c8xx_set_width,
+	.show_width	= 1,
+};
+
+int __init ncr53c8xx_init(void)
+{
+	ncr53c8xx_transport_template = spi_attach_transport(&ncr53c8xx_transport_functions);
+	if (!ncr53c8xx_transport_template)
+		return -ENODEV;
+	return 0;
+}
+
+void ncr53c8xx_exit(void)
+{
+	spi_release_transport(ncr53c8xx_transport_template);
 }
diff -Nru a/drivers/scsi/ncr53c8xx.h b/drivers/scsi/ncr53c8xx.h
--- a/drivers/scsi/ncr53c8xx.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/ncr53c8xx.h	2004-12-24 13:36:47 -08:00
@@ -44,8 +44,6 @@
 
 #include <scsi/scsi_host.h>
 
-typedef	u_long		vm_offset_t;
-
 #include "sym53c8xx_defs.h"
 
 /*
@@ -72,11 +70,11 @@
 	u_long	base_2;
 	u_long	base_c;
 	u_long	base_2_c;
-	u_long	base_v;
-	u_long	base_2_v;
+	void __iomem *base_v;
+	void __iomem *base_2_v;
 	int	irq;
 /* port and reg fields to use INB, OUTB macros */
-	volatile struct ncr_reg	*reg;
+	volatile struct ncr_reg	__iomem *reg;
 };
 
 /*==========================================================
@@ -97,5 +95,7 @@
 extern struct Scsi_Host *ncr_attach(struct scsi_host_template *tpnt, int unit, struct ncr_device *device);
 extern int ncr53c8xx_release(struct Scsi_Host *host);
 irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs);
+extern int ncr53c8xx_init(void);
+extern void ncr53c8xx_exit(void);
 
 #endif /* NCR53C8XX_H */
diff -Nru a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
--- a/drivers/scsi/nsp32.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/nsp32.c	2004-12-24 13:36:47 -08:00
@@ -43,10 +43,11 @@
 #include <asm/system.h>
 #include <asm/io.h>
 
-#include "scsi.h"
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_ioctl.h>
-#include <scsi/scsi.h>
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
 # include <linux/blk.h>
@@ -209,37 +210,38 @@
 #else
 static int         nsp32_detect      (Scsi_Host_Template *);
 #endif
-static int         nsp32_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
+static int         nsp32_queuecommand(struct scsi_cmnd *,
+		void (*done)(struct scsi_cmnd *));
 static const char *nsp32_info        (struct Scsi_Host *);
 static int         nsp32_release     (struct Scsi_Host *);
 
 /* SCSI error handler */
-static int         nsp32_eh_abort     (Scsi_Cmnd *);
-static int         nsp32_eh_bus_reset (Scsi_Cmnd *);
-static int         nsp32_eh_host_reset(Scsi_Cmnd *);
+static int         nsp32_eh_abort     (struct scsi_cmnd *);
+static int         nsp32_eh_bus_reset (struct scsi_cmnd *);
+static int         nsp32_eh_host_reset(struct scsi_cmnd *);
 
 /* generate SCSI message */
-static void nsp32_build_identify(Scsi_Cmnd *);
-static void nsp32_build_nop     (Scsi_Cmnd *);
-static void nsp32_build_reject  (Scsi_Cmnd *);
-static void nsp32_build_sdtr    (Scsi_Cmnd *, unsigned char, unsigned char);
+static void nsp32_build_identify(struct scsi_cmnd *);
+static void nsp32_build_nop     (struct scsi_cmnd *);
+static void nsp32_build_reject  (struct scsi_cmnd *);
+static void nsp32_build_sdtr    (struct scsi_cmnd *, unsigned char, unsigned char);
 
 /* SCSI message handler */
-static int  nsp32_busfree_occur(Scsi_Cmnd *, unsigned short);
-static void nsp32_msgout_occur (Scsi_Cmnd *);
-static void nsp32_msgin_occur  (Scsi_Cmnd *, unsigned long, unsigned short);
-
-static int  nsp32_setup_sg_table    (Scsi_Cmnd *);
-static int  nsp32_selection_autopara(Scsi_Cmnd *);
-static int  nsp32_selection_autoscsi(Scsi_Cmnd *);
-static void nsp32_scsi_done         (Scsi_Cmnd *);
-static int  nsp32_arbitration       (Scsi_Cmnd *, unsigned int);
-static int  nsp32_reselection       (Scsi_Cmnd *, unsigned char);
-static void nsp32_adjust_busfree    (Scsi_Cmnd *, unsigned int);
-static void nsp32_restart_autoscsi  (Scsi_Cmnd *, unsigned short);
+static int  nsp32_busfree_occur(struct scsi_cmnd *, unsigned short);
+static void nsp32_msgout_occur (struct scsi_cmnd *);
+static void nsp32_msgin_occur  (struct scsi_cmnd *, unsigned long, unsigned short);
+
+static int  nsp32_setup_sg_table    (struct scsi_cmnd *);
+static int  nsp32_selection_autopara(struct scsi_cmnd *);
+static int  nsp32_selection_autoscsi(struct scsi_cmnd *);
+static void nsp32_scsi_done         (struct scsi_cmnd *);
+static int  nsp32_arbitration       (struct scsi_cmnd *, unsigned int);
+static int  nsp32_reselection       (struct scsi_cmnd *, unsigned char);
+static void nsp32_adjust_busfree    (struct scsi_cmnd *, unsigned int);
+static void nsp32_restart_autoscsi  (struct scsi_cmnd *, unsigned short);
 
 /* SCSI SDTR */
-static void nsp32_analyze_sdtr       (Scsi_Cmnd *);
+static void nsp32_analyze_sdtr       (struct scsi_cmnd *);
 static int  nsp32_search_period_entry(nsp32_hw_data *, nsp32_target *, unsigned char);
 static void nsp32_set_async          (nsp32_hw_data *, nsp32_target *);
 static void nsp32_set_max_sync       (nsp32_hw_data *, nsp32_target *, unsigned char *, unsigned char *);
@@ -279,7 +281,7 @@
 /*
  * max_sectors is currently limited up to 128.
  */
-static Scsi_Host_Template nsp32_template = {
+static struct scsi_host_template nsp32_template = {
 	.proc_name			= "nsp32",
 	.name				= "Workbit NinjaSCSI-32Bi/UDE",
 	.proc_info			= nsp32_proc_info,
@@ -388,7 +390,7 @@
 /*
  * IDENTIFY Message
  */
-static void nsp32_build_identify(Scsi_Cmnd *SCpnt)
+static void nsp32_build_identify(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	int pos             = data->msgout_len;
@@ -407,7 +409,7 @@
 /*
  * SDTR Message Routine
  */
-static void nsp32_build_sdtr(Scsi_Cmnd    *SCpnt,
+static void nsp32_build_sdtr(struct scsi_cmnd    *SCpnt,
 			     unsigned char period,
 			     unsigned char offset)
 {
@@ -426,7 +428,7 @@
 /*
  * No Operation Message
  */
-static void nsp32_build_nop(Scsi_Cmnd *SCpnt)
+static void nsp32_build_nop(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	int            pos  = data->msgout_len;
@@ -444,7 +446,7 @@
 /*
  * Reject Message
  */
-static void nsp32_build_reject(Scsi_Cmnd *SCpnt)
+static void nsp32_build_reject(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	int            pos  = data->msgout_len;
@@ -457,7 +459,7 @@
  * timer
  */
 #if 0
-static void nsp32_start_timer(Scsi_Cmnd *SCpnt, int time)
+static void nsp32_start_timer(struct scsi_cmnd *SCpnt, int time)
 {
 	unsigned int base = SCpnt->host->io_port;
 
@@ -475,7 +477,7 @@
 /*
  * set SCSI command and other parameter to asic, and start selection phase
  */
-static int nsp32_selection_autopara(Scsi_Cmnd *SCpnt)
+static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data  *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int	base    = SCpnt->device->host->io_port;
@@ -606,7 +608,7 @@
 /*
  * Selection with AUTO SCSI (without AUTO PARAMETER)
  */
-static int nsp32_selection_autoscsi(Scsi_Cmnd *SCpnt)
+static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data  *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int	base    = SCpnt->device->host->io_port;
@@ -781,7 +783,7 @@
  *	 arbitration delay time is defined minimal 2.4us in SCSI
  *	 specification, thus udelay works as coarse grained wait timer.
  */
-static int nsp32_arbitration(Scsi_Cmnd *SCpnt, unsigned int base)
+static int nsp32_arbitration(struct scsi_cmnd *SCpnt, unsigned int base)
 {
 	unsigned char arbit;
 	int	      status = TRUE;
@@ -830,7 +832,7 @@
  *	 reselection target id&lun must be already set.
  *	 SCSI-2 says IDENTIFY implies RESTORE_POINTER operation.
  */
-static int nsp32_reselection(Scsi_Cmnd *SCpnt, unsigned char newlun)
+static int nsp32_reselection(struct scsi_cmnd *SCpnt, unsigned char newlun)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int   host_id = SCpnt->device->host->this_id;
@@ -884,7 +886,7 @@
  *
  * Note: NinjaSCSI-32Bi/UDE bus master can not transfer over 64KB at a time.
  */
-static int nsp32_setup_sg_table(Scsi_Cmnd *SCpnt)
+static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	struct scatterlist   *sgl;
@@ -904,7 +906,7 @@
 	if (SCpnt->use_sg) {
 		sgl = (struct scatterlist *)SCpnt->request_buffer;
 		num = pci_map_sg(data->Pci, sgl, SCpnt->use_sg,
-				 scsi_to_pci_dma_dir(SCpnt->sc_data_direction));
+				 SCpnt->sc_data_direction);
 		for (i = 0; i < num; i++) {
 			/*
 			 * Build nsp32_sglist, substitute sg dma addresses.
@@ -932,7 +934,7 @@
 	} else {
 		SCpnt->SCp.have_data_in	= pci_map_single(data->Pci,
 			SCpnt->request_buffer, SCpnt->request_bufflen,
-			scsi_to_pci_dma_dir(SCpnt->sc_data_direction));
+			SCpnt->sc_data_direction);
 
 		sgt[0].addr = cpu_to_le32(SCpnt->SCp.have_data_in);
 		sgt[0].len  = cpu_to_le32(SCpnt->request_bufflen | SGTEND); /* set end mark */
@@ -950,7 +952,7 @@
 	return TRUE;
 }
 
-static int nsp32_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
+static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	nsp32_target *target;
@@ -968,8 +970,7 @@
 		data->CurrentSC = NULL;
 		SCpnt->result   = DID_NO_CONNECT << 16;
 		done(SCpnt);
-
-		return SCSI_MLQUEUE_HOST_BUSY;
+		return 0;
 	}
 
 	/* check target ID is not same as this initiator ID */
@@ -977,7 +978,7 @@
 		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "terget==host???");
 		SCpnt->result = DID_BAD_TARGET << 16;
 		done(SCpnt);
-		return SCSI_MLQUEUE_DEVICE_BUSY;
+		return 0;
 	}
 
 	/* check target LUN is allowable value */
@@ -985,7 +986,7 @@
 		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "no more lun");
 		SCpnt->result = DID_BAD_TARGET << 16;
 		done(SCpnt);
-		return SCSI_MLQUEUE_DEVICE_BUSY;
+		return 0;
 	}
 
 	show_command(SCpnt);
@@ -1017,7 +1018,7 @@
 		nsp32_msg(KERN_ERR, "SGT fail");
 		SCpnt->result = DID_ERROR << 16;
 		nsp32_scsi_done(SCpnt);
-		return SCSI_MLQUEUE_HOST_BUSY;
+		return 0;
 	}
 
 	/* Build IDENTIFY */
@@ -1087,7 +1088,6 @@
 	if (ret != TRUE) {
 		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "selection fail");
 		nsp32_scsi_done(SCpnt);
-		return SCSI_MLQUEUE_DEVICE_BUSY;
 	}
 
 	return 0;
@@ -1205,7 +1205,7 @@
 {
 	nsp32_hw_data *data = dev_id;
 	unsigned int base = data->BaseAddress;
-	Scsi_Cmnd *SCpnt = data->CurrentSC;
+	struct scsi_cmnd *SCpnt = data->CurrentSC;
 	unsigned short auto_stat, irq_stat, trans_stat;
 	unsigned char busmon, busphase;
 	unsigned long flags;
@@ -1622,7 +1622,7 @@
  * Reset parameters and call scsi_done for data->cur_lunt.
  * Be careful setting SCpnt->result = DID_* before calling this function.
  */
-static void nsp32_scsi_done(Scsi_Cmnd *SCpnt)
+static void nsp32_scsi_done(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int   base = SCpnt->device->host->io_port;
@@ -1637,13 +1637,12 @@
 	if (SCpnt->use_sg) {
 		pci_unmap_sg(data->Pci,
 			     (struct scatterlist *)SCpnt->buffer,
-			     SCpnt->use_sg,
-			     scsi_to_pci_dma_dir(SCpnt->sc_data_direction));
+			     SCpnt->use_sg, SCpnt->sc_data_direction);
 	} else {
 		pci_unmap_single(data->Pci,
 				 (u32)SCpnt->SCp.have_data_in,
 				 SCpnt->request_bufflen,
-				 scsi_to_pci_dma_dir(SCpnt->sc_data_direction));
+				 SCpnt->sc_data_direction);
 	}
 
  skip:
@@ -1678,7 +1677,7 @@
  *	MsgIn 04: Diconnect.
  * In other case, unexpected BUSFREE is detected.
  */
-static int nsp32_busfree_occur(Scsi_Cmnd *SCpnt, unsigned short execph)
+static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int base   = SCpnt->device->host->io_port;
@@ -1836,7 +1835,7 @@
  * Note: This driver adjust the SG table using SCSI ACK
  *       counter instead of BMCNT counter!
  */
-static void nsp32_adjust_busfree(Scsi_Cmnd *SCpnt, unsigned int s_sacklen)
+static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	int                   old_entry = data->cur_entry;
@@ -1909,7 +1908,7 @@
  * message out phase. It, however, has more than 3 messages,
  * HBA creates the interrupt and we have to process by hand.
  */
-static void nsp32_msgout_occur(Scsi_Cmnd *SCpnt)
+static void nsp32_msgout_occur(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int base   = SCpnt->device->host->io_port;
@@ -1985,7 +1984,7 @@
  * Note: Restarting AutoSCSI needs set:
  *		SYNC_REG, ACK_WIDTH, SGT_ADR, TRANSFER_CONTROL
  */
-static void nsp32_restart_autoscsi(Scsi_Cmnd *SCpnt, unsigned short command)
+static void nsp32_restart_autoscsi(struct scsi_cmnd *SCpnt, unsigned short command)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int   base = data->BaseAddress;
@@ -2051,7 +2050,7 @@
 /*
  * cannot run automatically message in occur
  */
-static void nsp32_msgin_occur(Scsi_Cmnd     *SCpnt,
+static void nsp32_msgin_occur(struct scsi_cmnd     *SCpnt,
 			      unsigned long  irq_status,
 			      unsigned short execph)
 {
@@ -2348,7 +2347,7 @@
 /*
  * 
  */
-static void nsp32_analyze_sdtr(Scsi_Cmnd *SCpnt)
+static void nsp32_analyze_sdtr(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data   *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	nsp32_target     *target     = data->cur_target;
@@ -2720,7 +2719,7 @@
 	host->io_port   = data->BaseAddress;
 	host->unique_id = data->BaseAddress;
 	host->n_io_port	= data->NumAddress;
-	host->base      = data->MmioAddress;
+	host->base      = (unsigned long)data->MmioAddress;
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,63))
 	scsi_set_device(host, &PCIDEV->dev);
 #else
@@ -2938,8 +2937,8 @@
 		release_region(host->io_port, host->n_io_port);
 	}
 
-	if (data->MmioAddress != 0) {
-		iounmap((void *)(data->MmioAddress));
+	if (data->MmioAddress) {
+		iounmap(data->MmioAddress);
 	}
 
 	return 0;
@@ -2956,7 +2955,7 @@
 /****************************************************************************
  * error handler
  */
-static int nsp32_eh_abort(Scsi_Cmnd *SCpnt)
+static int nsp32_eh_abort(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int   base = SCpnt->device->host->io_port;
@@ -2984,7 +2983,7 @@
 	return SUCCESS;
 }
 
-static int nsp32_eh_bus_reset(Scsi_Cmnd *SCpnt)
+static int nsp32_eh_bus_reset(struct scsi_cmnd *SCpnt)
 {
 	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
 	unsigned int   base = SCpnt->device->host->io_port;
@@ -3041,7 +3040,7 @@
 	data->CurrentSC = NULL;
 }
 
-static int nsp32_eh_host_reset(Scsi_Cmnd *SCpnt)
+static int nsp32_eh_host_reset(struct scsi_cmnd *SCpnt)
 {
 	struct Scsi_Host *host = SCpnt->device->host;
 	unsigned int      base = SCpnt->device->host->io_port;
@@ -3439,11 +3438,10 @@
 static int nsp32_suspend(struct pci_dev *pdev, u32 state)
 {
 	struct Scsi_Host *host = pci_get_drvdata(pdev);
-	nsp32_hw_data    *data = (nsp32_hw_data *)host->hostdata;
 
 	nsp32_msg(KERN_INFO, "pci-suspend: pdev=0x%p, state=%ld, slot=%s, host=0x%p", pdev, state, pci_name(pdev), host);
 
-	pci_save_state     (pdev, data->PciState);
+	pci_save_state     (pdev);
 	pci_disable_device (pdev);
 	pci_set_power_state(pdev, state);
 
@@ -3461,7 +3459,7 @@
 
 	pci_set_power_state(pdev, 0);
 	pci_enable_wake    (pdev, 0, 0);
-	pci_restore_state  (pdev, data->PciState);
+	pci_restore_state  (pdev);
 
 	reg = nsp32_read2(data->BaseAddress, INDEX_REG);
 
@@ -3512,8 +3510,7 @@
 	data->IrqNumber   = pdev->irq;
 	data->BaseAddress = pci_resource_start(pdev, 0);
 	data->NumAddress  = pci_resource_len  (pdev, 0);
-	data->MmioAddress = 
-		(unsigned long)ioremap_nocache(pci_resource_start(pdev, 1),
+	data->MmioAddress = ioremap_nocache(pci_resource_start(pdev, 1),
 					       pci_resource_len  (pdev, 1));
 	data->MmioLength  = pci_resource_len  (pdev, 1);
 
@@ -3525,7 +3522,7 @@
 	ret = scsi_register_host(&nsp32_template);
 #endif
 
-	nsp32_msg(KERN_INFO, "irq: %i mmio: 0x%lx+0x%lx slot: %s model: %s",
+	nsp32_msg(KERN_INFO, "irq: %i mmio: %p+0x%lx slot: %s model: %s",
 		  pdev->irq,
 		  data->MmioAddress, data->MmioLength,
 		  pci_name(pdev),
diff -Nru a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h
--- a/drivers/scsi/nsp32.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/nsp32.h	2004-12-24 13:36:16 -08:00
@@ -499,7 +499,7 @@
 #define MSGIN03			BIT(1)		/* Auto Msg In 03 Flag  */
 
 typedef struct _nsp32_lunt {
-	Scsi_Cmnd	*SCpnt;	    /* Current Handling Scsi_Cmnd */
+	struct scsi_cmnd	*SCpnt;	    /* Current Handling struct scsi_cmnd */
 	unsigned long	 save_datp;  /* Save Data Pointer - saved position from initial address */
 	int		 msgin03;	/* auto msg in 03 flag     */
 	unsigned int	 sg_num;	/* Total number of SG entries */
@@ -563,11 +563,11 @@
 	int           IrqNumber;
 	int           BaseAddress;
 	int           NumAddress;
-	unsigned long MmioAddress;
+	void __iomem *MmioAddress;
 #define NSP32_MMIO_OFFSET 0x0800
 	unsigned long MmioLength;
 
-	Scsi_Cmnd *CurrentSC;
+	struct scsi_cmnd *CurrentSC;
 
 	struct pci_dev             *Pci;
 	const struct pci_device_id *pci_devid;
@@ -605,9 +605,6 @@
 	unsigned char msginbuf [MSGINBUF_MAX];	/* megin buffer     */
 	char	      msgin_len;		/* msginbuf length  */
 
-#ifdef CONFIG_PM
-	u32           PciState[16];     /* save PCI state to this area */
-#endif
 } nsp32_hw_data;
 
 /*
diff -Nru a/drivers/scsi/osst.c b/drivers/scsi/osst.c
--- a/drivers/scsi/osst.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/scsi/osst.c	2004-12-24 13:36:49 -08:00
@@ -47,6 +47,7 @@
 #include <linux/vmalloc.h>
 #include <linux/blkdev.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/delay.h>
 #include <asm/uaccess.h>
 #include <asm/dma.h>
 #include <asm/system.h>
@@ -81,13 +82,13 @@
 MODULE_DESCRIPTION("OnStream {DI-|FW-|SC-|USB}{30|50} Tape Driver");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(max_dev, "i");
+module_param(max_dev, int, 0);
 MODULE_PARM_DESC(max_dev, "Maximum number of OnStream Tape Drives to attach (4)");
 
-MODULE_PARM(write_threshold_kbs, "i");
+module_param(write_threshold_kbs, int, 0);
 MODULE_PARM_DESC(write_threshold_kbs, "Asynchronous write threshold (KB; 32)");
 
-MODULE_PARM(max_sg_segs, "i");
+module_param(max_sg_segs, int, 0);
 MODULE_PARM_DESC(max_sg_segs, "Maximum number of scatter/gather segments to use (9)");
 #else
 static struct osst_dev_parm {
@@ -472,7 +473,7 @@
 	char           * name = tape_name(STp);
 	os_aux_t       * aux  = STp->buffer->aux;
 	os_partition_t * par  = &(aux->partition);
-	ST_partstat    * STps = &(STp->ps[STp->partition]);
+	struct st_partstat    * STps = &(STp->ps[STp->partition]);
 	int		 blk_cnt, blk_sz, i;
 
 	if (STp->raw) {
@@ -613,10 +614,8 @@
 	printk(OSST_DEB_MSG "%s:D: Reached onstream wait ready\n", name);
 #endif
 
-	if (initial_delay > 0) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(initial_delay);
-	}
+	if (initial_delay > 0)
+		msleep(jiffies_to_msecs(initial_delay));
 
 	memset(cmd, 0, MAX_COMMAND_SIZE);
 	cmd[0] = TEST_UNIT_READY;
@@ -637,8 +636,7 @@
 		debugging = 0;
 	    }
 #endif
-	    set_current_state(TASK_INTERRUPTIBLE);
-	    schedule_timeout(HZ / 10);
+	    msleep(100);
 
 	    memset(cmd, 0, MAX_COMMAND_SIZE);
 	    cmd[0] = TEST_UNIT_READY;
@@ -697,8 +695,7 @@
 		debugging = 0;
 	    }
 #endif
-	    set_current_state(TASK_INTERRUPTIBLE);
-	    schedule_timeout(HZ / 10);
+	    msleep(100);
 
 	    memset(cmd, 0, MAX_COMMAND_SIZE);
 	    cmd[0] = TEST_UNIT_READY;
@@ -818,8 +815,7 @@
 			notyetprinted--;
 		}
 #endif
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout (HZ / OSST_POLL_PER_SEC);
+		msleep(1000 / OSST_POLL_PER_SEC);
 	}
 #if DEBUG
 	printk (OSST_DEB_MSG "%s:D: Fail wait f fr %i (>%i): %i-%i %i: %3li.%li s\n",
@@ -906,7 +902,7 @@
 
 static int osst_initiate_read(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
 {
-	ST_partstat   * STps   = &(STp->ps[STp->partition]);
+	struct st_partstat   * STps   = &(STp->ps[STp->partition]);
 	Scsi_Request  * SRpnt  ;
 	unsigned char	cmd[MAX_COMMAND_SIZE];
 	int		retval = 0;
@@ -944,7 +940,7 @@
 
 static int osst_get_logical_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int frame_seq_number, int quiet)
 {
-	ST_partstat * STps  = &(STp->ps[STp->partition]);
+	struct st_partstat * STps  = &(STp->ps[STp->partition]);
 	char        * name  = tape_name(STp);
 	int           cnt   = 0,
 		      bad   = 0,
@@ -1070,7 +1066,7 @@
 
 static int osst_seek_logical_blk(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int logical_blk_num)
 {
-        ST_partstat * STps = &(STp->ps[STp->partition]);
+        struct st_partstat * STps = &(STp->ps[STp->partition]);
 	char        * name = tape_name(STp);
 	int	retries    = 0;
 	int	frame_seq_estimate, ppos_estimate, move;
@@ -1209,7 +1205,7 @@
 
 static int osst_seek_sector(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int sector)
 {
-        ST_partstat   * STps   = &(STp->ps[STp->partition]);
+        struct st_partstat   * STps   = &(STp->ps[STp->partition]);
 	int		frame  = sector >> OSST_FRAME_SHIFT,
 			offset = (sector & OSST_SECTOR_MASK) << OSST_SECTOR_SHIFT, 
 			r;
@@ -1420,8 +1416,7 @@
 					if (SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 4 &&
 					    (SRpnt->sr_sense_buffer[13] == 1 || SRpnt->sr_sense_buffer[13] == 8)) {
 						/* in the process of becoming ready */
-						set_current_state(TASK_INTERRUPTIBLE);
-						schedule_timeout(HZ / 10);
+						msleep(100);
 						continue;
 					}
 					if (STp->buffer->syscall_result)
@@ -1571,7 +1566,7 @@
 static int osst_write_error_recovery(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int pending)
 {
 	Scsi_Request * SRpnt  = * aSRpnt;
-	ST_partstat  * STps   = & STp->ps[STp->partition];
+	struct st_partstat  * STps   = & STp->ps[STp->partition];
 	char         * name   = tape_name(STp);
 	int            retval = 0;
 	int            rw_state;
@@ -2761,7 +2756,7 @@
 {
 	unsigned char	scmd[MAX_COMMAND_SIZE];
 	Scsi_Request  * SRpnt;
-	ST_partstat   * STps;
+	struct st_partstat   * STps;
 	int		result = 0;
 	int		pp     = (ppos == 3000 && !skip)? 0 : ppos;
 	char          * name   = tape_name(STp);
@@ -2817,7 +2812,7 @@
 
 static int osst_write_trailer(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, int leave_at_EOT)
 {
-	ST_partstat * STps = &(STp->ps[STp->partition]);
+	struct st_partstat * STps = &(STp->ps[STp->partition]);
 	int result = 0;
 
 	if (STp->write_type != OS_WRITE_NEW_MARK) {
@@ -2848,7 +2843,7 @@
 	int            result = 0;
 	unsigned char  cmd[MAX_COMMAND_SIZE];
 	Scsi_Request * SRpnt = *aSRpnt;
-	ST_partstat  * STps;
+	struct st_partstat  * STps;
 	char         * name = tape_name(STp);
 
 	if ((STp->buffer)->writing) {
@@ -2974,7 +2969,7 @@
    seek_next is true. */
 static int osst_flush_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int seek_next)
 {
-	ST_partstat * STps;
+	struct st_partstat * STps;
 	int           backspace = 0, result = 0;
 #if DEBUG
 	char        * name = tape_name(STp);
@@ -3139,7 +3134,7 @@
 static void reset_state(OS_Scsi_Tape *STp)
 {
 	int i;
-	ST_partstat *STps;
+	struct st_partstat *STps;
 
 	STp->pos_unknown = 0;
 	for (i = 0; i < ST_NBR_PARTITIONS; i++) {
@@ -3165,8 +3160,8 @@
 	int            doing_write = 0;
 	const char   __user * b_point;
 	Scsi_Request * SRpnt = NULL;
-	ST_mode      * STm;
-	ST_partstat  * STps;
+	struct st_modedef   * STm;
+	struct st_partstat  * STps;
 	OS_Scsi_Tape * STp  = filp->private_data;
 	char         * name = tape_name(STp);
 
@@ -3485,8 +3480,8 @@
 	ssize_t        total, retval = 0;
 	ssize_t        i, transfer;
 	int            special;
-	ST_mode      * STm;
-	ST_partstat  * STps;
+	struct st_modedef      * STm;
+	struct st_partstat  * STps;
 	Scsi_Request * SRpnt = NULL;
 	OS_Scsi_Tape * STp   = filp->private_data;
 	char         * name  = tape_name(STp);
@@ -3665,7 +3660,8 @@
 
 
 /* Set the driver options */
-static void osst_log_options(OS_Scsi_Tape *STp, ST_mode *STm, char *name)
+static void osst_log_options(OS_Scsi_Tape *STp, struct st_modedef *STm,
+			     char *name)
 {
   printk(KERN_INFO
 "%s:I: Mode %d options: buffer writes: %d, async writes: %d, read ahead: %d\n",
@@ -3692,12 +3688,12 @@
 {
 	int       value;
 	long      code;
-	ST_mode * STm;
+	struct st_modedef * STm;
 	char    * name = tape_name(STp);
 
 	STm = &(STp->modes[STp->current_mode]);
 	if (!STm->defined) {
-		memcpy(STm, &(STp->modes[0]), sizeof(ST_mode));
+		memcpy(STm, &(STp->modes[0]), sizeof(*STm));
 		modes_defined = TRUE;
 #if DEBUG
 		if (debugging)
@@ -3852,7 +3848,7 @@
 	int            chg_eof = TRUE;
 	unsigned char  cmd[MAX_COMMAND_SIZE];
 	Scsi_Request * SRpnt = * aSRpnt;
-	ST_partstat  * STps;
+	struct st_partstat  * STps;
 	int            fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num;
 	int            datalen = 0, direction = SCSI_DATA_NONE;
 	char         * name = tape_name(STp);
@@ -4236,8 +4232,8 @@
 	unsigned char  cmd[MAX_COMMAND_SIZE];
 	Scsi_Request * SRpnt = NULL;
 	OS_Scsi_Tape * STp;
-	ST_mode      * STm;
-	ST_partstat  * STps;
+	struct st_modedef      * STm;
+	struct st_partstat  * STps;
 	char         * name;
 	int            dev  = TAPE_NR(inode);
 	int            mode = TAPE_MODE(inode);
@@ -4594,8 +4590,8 @@
 {
 	int            result = 0, result2;
 	OS_Scsi_Tape * STp  = filp->private_data;
-	ST_mode      * STm  = &(STp->modes[STp->current_mode]);
-	ST_partstat  * STps = &(STp->ps[STp->partition]);
+	struct st_modedef      * STm  = &(STp->modes[STp->current_mode]);
+	struct st_partstat  * STps = &(STp->ps[STp->partition]);
 	Scsi_Request * SRpnt = NULL;
 	char         * name = tape_name(STp);
 
@@ -4709,8 +4705,8 @@
 {
 	int            i, cmd_nr, cmd_type, retval = 0;
 	unsigned int   blk;
-	ST_mode      * STm;
-	ST_partstat  * STps;
+	struct st_modedef      * STm;
+	struct st_partstat  * STps;
 	Scsi_Request * SRpnt = NULL;
 	OS_Scsi_Tape * STp   = file->private_data;
 	char         * name  = tape_name(STp);
@@ -5417,8 +5413,8 @@
 {
 	Scsi_Device    * SDp = to_scsi_device(dev);
 	OS_Scsi_Tape   * tpnt;
-	ST_mode        * STm;
-	ST_partstat    * STps;
+	struct st_modedef        * STm;
+	struct st_partstat    * STps;
 	OSST_buffer    * buffer;
 	struct gendisk * drive;
 	int              i, mode, dev_num;
diff -Nru a/drivers/scsi/osst.h b/drivers/scsi/osst.h
--- a/drivers/scsi/osst.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/osst.h	2004-12-24 13:37:00 -08:00
@@ -552,14 +552,14 @@
   int long_timeout;		/* timeout for commands known to take long time*/
 
   /* Mode characteristics */
-  ST_mode modes[ST_NBR_MODES];
+  struct st_modedef modes[ST_NBR_MODES];
   int current_mode;
 
   /* Status variables */
   int partition;
   int new_partition;
   int nbr_partitions;    /* zero until partition support enabled */
-  ST_partstat ps[ST_NBR_PARTITIONS];
+  struct st_partstat ps[ST_NBR_PARTITIONS];
   unsigned char dirty;
   unsigned char ready;
   unsigned char write_prot;
diff -Nru a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c
--- a/drivers/scsi/pas16.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/pas16.c	2004-12-24 13:36:17 -08:00
@@ -633,7 +633,7 @@
 #include "scsi_module.c"
 
 #ifdef MODULE
-MODULE_PARM(pas16_addr, "h");
-MODULE_PARM(pas16_irq, "i");
+module_param(pas16_addr, ushort, 0);
+module_param(pas16_irq, int, 0);
 #endif
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
--- a/drivers/scsi/pcmcia/aha152x_stub.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/pcmcia/aha152x_stub.c	2004-12-24 13:37:19 -08:00
@@ -58,7 +58,7 @@
 
 #ifdef PCMCIA_DEBUG
 static int pc_debug = PCMCIA_DEBUG;
-MODULE_PARM(pc_debug, "i");
+module_param(pc_debug, int, 0644);
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 static char *version =
 "aha152x_cs.c 1.54 2000/06/12 21:27:25 (David Hinds)";
diff -Nru a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
--- a/drivers/scsi/pcmcia/nsp_cs.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/scsi/pcmcia/nsp_cs.c	2004-12-24 13:37:30 -08:00
@@ -226,7 +226,7 @@
 		nsp_msg(KERN_DEBUG, "CurrentSC!=NULL this can't be happen");
 		SCpnt->result   = DID_BAD_TARGET << 16;
 		nsp_scsi_done(SCpnt);
-		return SCSI_MLQUEUE_HOST_BUSY;
+		return 0;
 	}
 
 #if 0
@@ -273,7 +273,7 @@
 		nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "selection fail");
 		SCpnt->result   = DID_BUS_BUSY << 16;
 		nsp_scsi_done(SCpnt);
-		return SCSI_MLQUEUE_DEVICE_BUSY;
+		return 0;
 	}
 
 
diff -Nru a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
--- a/drivers/scsi/pcmcia/qlogic_stub.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/scsi/pcmcia/qlogic_stub.c	2004-12-24 13:36:55 -08:00
@@ -66,7 +66,7 @@
 
 #ifdef PCMCIA_DEBUG
 static int pc_debug = PCMCIA_DEBUG;
-MODULE_PARM(pc_debug, "i");
+module_param(pc_debug, int, 0644);
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 static char *version = "qlogic_cs.c 1.79-ac 2002/10/26 (David Hinds)";
 #else
diff -Nru a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
--- a/drivers/scsi/pcmcia/sym53c500_cs.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c	2004-12-24 13:37:04 -08:00
@@ -85,7 +85,7 @@
 module_param(pc_debug, int, 0);
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 static char *version =
-"sym53c500_cs.c 0.9b 2004/05/10 (Bob Tracy)";
+"sym53c500_cs.c 0.9c 2004/10/27 (Bob Tracy)";
 #else
 #define DEBUG(n, args...)
 #endif
@@ -95,13 +95,12 @@
 /* Parameters that can be set with 'insmod' */
 
 /* Bit map of interrupts to choose from */
-static unsigned int irq_mask = 0xdeb8;	/* 3, 6, 7, 9-12, 14, 15 */
+static unsigned int irq_mask = 0xdeb8;	/* 3-5, 7, 9-12, 14, 15 */
 static int irq_list[4] = { -1 };
-static int num_irqs = 1;
 
 module_param(irq_mask, int, 0);
 MODULE_PARM_DESC(irq_mask, "IRQ mask bits (default: 0xdeb8)");
-module_param_array(irq_list, int, num_irqs, 0);
+module_param_array(irq_list, int, NULL, 0);
 MODULE_PARM_DESC(irq_list, "Comma-separated list of up to 4 IRQs to try (default: auto select).");
 
 /* ================================================================== */
@@ -830,7 +829,7 @@
 	data = (struct sym53c500_data *)host->hostdata;
 
 	if (irq_level > 0) {
-		if (request_irq(irq_level, SYM53C500_intr, 0, "SYM53C500", host)) {
+		if (request_irq(irq_level, SYM53C500_intr, SA_SHIRQ, "SYM53C500", host)) {
 			printk("SYM53C500: unable to allocate IRQ %d\n", irq_level);
 			goto err_free_scsi;
 		}
diff -Nru a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c
--- a/drivers/scsi/psi240i.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/scsi/psi240i.c	2004-12-24 13:37:02 -08:00
@@ -642,41 +642,6 @@
 }
 
 /****************************************************************
- *	Name:	Psi240i_Abort
- *
- *	Description:	Process the Abort command from the SCSI manager.
- *
- *	Parameters:		SCpnt - Pointer to SCSI command structure.
- *
- *	Returns:		Allways snooze.
- *
- ****************************************************************/
-int Psi240i_Abort (Scsi_Cmnd *SCpnt)
-	{
-	DEB (printk ("psi240i_abort\n"));
-	return SCSI_ABORT_SNOOZE;
-	}
-/****************************************************************
- *	Name:	Psi240i_Reset
- *
- *	Description:	Process the Reset command from the SCSI manager.
- *
- *	Parameters:		SCpnt - Pointer to SCSI command structure.
- *					flags - Flags about the reset command
- *
- *	Returns:		No active command at this time, so this means
- *					that each time we got some kind of response the
- *					last time through.  Tell the mid-level code to
- *					request sense information in order to decide what
- *					to do next.
- *
- ****************************************************************/
-int Psi240i_Reset (Scsi_Cmnd *SCpnt, unsigned int reset_flags)
-	{
-	return SCSI_RESET_PUNT;
-	}
-
-/****************************************************************
  *	Name:	Psi240i_BiosParam
  *
  *	Description:	Process the biosparam request from the SCSI manager to
@@ -710,8 +675,6 @@
 	.detect			= Psi240i_Detect,
 	.release		= Psi240i_Release,
 	.queuecommand		= Psi240i_QueueCommand,
-	.abort	  		= Psi240i_Abort,
-	.reset	  		= Psi240i_Reset,
 	.bios_param	  	= Psi240i_BiosParam,
 	.can_queue	  	= 1,
 	.this_id	  	= -1,
diff -Nru a/drivers/scsi/ql1040_fw.h b/drivers/scsi/ql1040_fw.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/ql1040_fw.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2099 @@
+/**************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * Copyright (C) 2004 QLogic Corporation
+ * (www.qlogic.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, 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.
+ *
+ *************************************************************************/
+
+/************************************************************************
+ *									*
+ * 	        --- ISP1040 Initiator/Target Firmware ---               *
+ *			    32 LUN Support				*
+ *									*
+ ************************************************************************
+ */
+
+/*
+ *	Firmware Version 7.65.00 (14:17 Jul 20, 1999)
+ */
+
+static unsigned char firmware_version[] = {7,65,0};
+
+#define FW_VERSION_STRING "7.65.0"
+
+static unsigned short risc_code_addr01 = 0x1000 ;
+
+static unsigned short risc_code01[] = { 
+	0x0078, 0x103a, 0x0000, 0x4057, 0x0000, 0x2043, 0x4f50, 0x5952,
+	0x4947, 0x4854, 0x2031, 0x3939, 0x3520, 0x514c, 0x4f47, 0x4943,
+	0x2043, 0x4f52, 0x504f, 0x5241, 0x5449, 0x4f4e, 0x2049, 0x5350,
+	0x3130, 0x3230, 0x2049, 0x2f54, 0x2046, 0x6972, 0x6d77, 0x6172,
+	0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030, 0x372e, 0x3635,
+	0x2020, 0x2043, 0x7573, 0x746f, 0x6d65, 0x7220, 0x4e6f, 0x2e20,
+	0x3030, 0x2050, 0x726f, 0x6475, 0x6374, 0x204e, 0x6f2e, 0x2020,
+	0x3031, 0x2024, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005, 0x0048,
+	0x1045, 0x0038, 0x104b, 0x0078, 0x1047, 0x0028, 0x104b, 0x20b9,
+	0x1212, 0x0078, 0x104d, 0x20b9, 0x2222, 0x20c1, 0x0008, 0x2071,
+	0x0010, 0x70c3, 0x0004, 0x20c9, 0x77ff, 0x2089, 0x1186, 0x70c7,
+	0x4953, 0x70cb, 0x5020, 0x70cf, 0x2020, 0x70d3, 0x0007, 0x3f00,
+	0x70d6, 0x20c1, 0x0008, 0x2019, 0x0000, 0x2009, 0xfeff, 0x2100,
+	0x200b, 0xa5a5, 0xa1ec, 0x7fff, 0x2d64, 0x206b, 0x0a0a, 0xaddc,
+	0x3fff, 0x2b54, 0x205b, 0x5050, 0x2114, 0xa286, 0xa5a5, 0x0040,
+	0x10bf, 0xa386, 0x000f, 0x0040, 0x1085, 0x2c6a, 0x2a5a, 0x20c1,
+	0x0000, 0x2019, 0x000f, 0x0078, 0x1065, 0x2c6a, 0x2a5a, 0x20c1,
+	0x0008, 0x2009, 0x7fff, 0x2148, 0x2944, 0x204b, 0x0a0a, 0xa9bc,
+	0x3fff, 0x2734, 0x203b, 0x5050, 0x2114, 0xa286, 0x0a0a, 0x0040,
+	0x10a9, 0x284a, 0x263a, 0x20c1, 0x0004, 0x2009, 0x3fff, 0x2134,
+	0x200b, 0x5050, 0x2114, 0xa286, 0x5050, 0x0040, 0x10aa, 0x0078,
+	0x118e, 0x284a, 0x263a, 0x98c0, 0xa188, 0x1000, 0x212c, 0x200b,
+	0xa5a5, 0x2114, 0xa286, 0xa5a5, 0x0040, 0x10bc, 0x250a, 0xa18a,
+	0x1000, 0x98c1, 0x0078, 0x10c1, 0x250a, 0x0078, 0x10c1, 0x2c6a,
+	0x2a5a, 0x2130, 0xa18a, 0x0040, 0x2128, 0xa1a2, 0x5100, 0x8424,
+	0x8424, 0x8424, 0x8424, 0x8424, 0x8424, 0xa192, 0x7800, 0x2009,
+	0x0000, 0x2001, 0x0031, 0x1078, 0x1cba, 0x2218, 0x2079, 0x5100,
+	0x2fa0, 0x2408, 0x2011, 0x0000, 0x20a9, 0x0040, 0x42a4, 0x8109,
+	0x00c0, 0x10dc, 0x7ef2, 0x8528, 0x7de6, 0x7cea, 0x7bee, 0x7883,
+	0x0000, 0x2031, 0x0030, 0x78cf, 0x0101, 0x780b, 0x0002, 0x780f,
+	0x0002, 0x784f, 0x0003, 0x2069, 0x5140, 0x2001, 0x04fd, 0x2004,
+	0xa082, 0x0005, 0x0048, 0x1104, 0x0038, 0x1100, 0x0078, 0x1108,
+	0x681b, 0x003c, 0x0078, 0x110a, 0x00a8, 0x1108, 0x681b, 0x003c,
+	0x681b, 0x0028, 0x6807, 0x0007, 0x680b, 0x00fa, 0x680f, 0x0008,
+	0x6813, 0x0005, 0x6823, 0x0000, 0x6827, 0x0006, 0x6817, 0x0008,
+	0x682b, 0x0000, 0x681f, 0x0019, 0x2069, 0x5380, 0x2011, 0x0020,
+	0x2009, 0x0010, 0x680b, 0x080c, 0x680f, 0x0019, 0x6803, 0xfd00,
+	0x6807, 0x0018, 0x6a1a, 0x2d00, 0xa0e8, 0x0008, 0xa290, 0x0004,
+	0x8109, 0x00c0, 0x1122, 0x2069, 0x5400, 0x2009, 0x0002, 0x20a9,
+	0x0100, 0x6837, 0x0000, 0x680b, 0x0040, 0x7bf0, 0xa386, 0xfeff,
+	0x00c0, 0x1148, 0x6817, 0x0100, 0x681f, 0x0064, 0x0078, 0x114c,
+	0x6817, 0x0064, 0x681f, 0x0002, 0xade8, 0x0010, 0x0070, 0x1152,
+	0x0078, 0x1139, 0x8109, 0x00c0, 0x1137, 0x1078, 0x220a, 0x1078,
+	0x482c, 0x1078, 0x1963, 0x1078, 0x4d22, 0x3200, 0xa085, 0x000d,
+	0x2090, 0x70c3, 0x0000, 0x0090, 0x116c, 0x70c0, 0xa086, 0x0002,
+	0x00c0, 0x116c, 0x1078, 0x1284, 0x1078, 0x1196, 0x78cc, 0xa005,
+	0x00c0, 0x117a, 0x1078, 0x1ce3, 0x0010, 0x1180, 0x0068, 0x1180,
+	0x1078, 0x20e9, 0x0010, 0x1180, 0x0068, 0x1180, 0x1078, 0x1a48,
+	0x00e0, 0x116c, 0x1078, 0x4ba9, 0x0078, 0x116c, 0x118e, 0x1190,
+	0x240b, 0x240b, 0x48ad, 0x48ad, 0x240b, 0x240b, 0x0078, 0x118e,
+	0x0078, 0x1190, 0x0078, 0x1192, 0x0078, 0x1194, 0x0068, 0x1201,
+	0x2061, 0x0000, 0x6018, 0xa084, 0x0001, 0x00c0, 0x1201, 0x7814,
+	0xa005, 0x00c0, 0x11a7, 0x0010, 0x1202, 0x0078, 0x1201, 0x2009,
+	0x515b, 0x2104, 0xa005, 0x00c0, 0x1201, 0x2009, 0x5164, 0x200b,
+	0x0000, 0x7914, 0xa186, 0x0042, 0x00c0, 0x11cc, 0x7816, 0x2009,
+	0x5162, 0x2164, 0x200b, 0x0000, 0x6018, 0x70c6, 0x6014, 0x70ca,
+	0x611c, 0xa18c, 0xff00, 0x6020, 0xa084, 0x00ff, 0xa105, 0x70ce,
+	0x1078, 0x1948, 0x0078, 0x11ff, 0x7814, 0xa086, 0x0018, 0x00c0,
+	0x11d3, 0x1078, 0x165a, 0x7817, 0x0000, 0x2009, 0x5162, 0x2104,
+	0xa065, 0x0040, 0x11ef, 0x0c7e, 0x609c, 0x2060, 0x1078, 0x19b3,
+	0x0c7f, 0x609f, 0x0000, 0x1078, 0x1730, 0x2009, 0x000c, 0x6007,
+	0x0103, 0x1078, 0x1924, 0x00c0, 0x11fb, 0x1078, 0x1948, 0x2009,
+	0x5162, 0x200b, 0x0000, 0x2009, 0x515c, 0x2104, 0x200b, 0x0000,
+	0xa005, 0x0040, 0x11ff, 0x2001, 0x4005, 0x0078, 0x1286, 0x0078,
+	0x1284, 0x007c, 0x70c3, 0x0000, 0x70c7, 0x0000, 0x70cb, 0x0000,
+	0x70cf, 0x0000, 0x70c0, 0xa0bc, 0xffc0, 0x00c0, 0x1252, 0x2038,
+	0x0079, 0x1212, 0x1284, 0x12e5, 0x12a9, 0x12fe, 0x130d, 0x1313,
+	0x12a0, 0x1748, 0x1317, 0x1298, 0x12ad, 0x12af, 0x12b1, 0x12b3,
+	0x174d, 0x1298, 0x1329, 0x1360, 0x1672, 0x1742, 0x12b5, 0x1591,
+	0x15ad, 0x15c9, 0x15f4, 0x154a, 0x1558, 0x156c, 0x1580, 0x13df,
+	0x1298, 0x138d, 0x1393, 0x1398, 0x139d, 0x13a3, 0x13a8, 0x13ad,
+	0x13b2, 0x13b7, 0x13bb, 0x13d0, 0x13dc, 0x1298, 0x1298, 0x1298,
+	0x1298, 0x13eb, 0x13f4, 0x1403, 0x1429, 0x1433, 0x143a, 0x1480,
+	0x148f, 0x149e, 0x14b0, 0x152a, 0x153a, 0x1298, 0x1298, 0x1298,
+	0x1298, 0x153f, 0xa0bc, 0xffa0, 0x00c0, 0x1298, 0x2038, 0xa084,
+	0x001f, 0x0079, 0x125b, 0x1786, 0x1789, 0x1799, 0x1298, 0x1298,
+	0x18df, 0x18fc, 0x1298, 0x1298, 0x1298, 0x1900, 0x1908, 0x1298,
+	0x1298, 0x1298, 0x1298, 0x12db, 0x12f4, 0x131f, 0x1356, 0x1668,
+	0x1764, 0x1778, 0x1298, 0x1829, 0x190e, 0x18bb, 0x18c5, 0x18c9,
+	0x18d7, 0x1298, 0x1298, 0x72ca, 0x71c6, 0x2001, 0x4006, 0x0078,
+	0x1286, 0x73ce, 0x72ca, 0x71c6, 0x2001, 0x4000, 0x70c2, 0x0068,
+	0x1287, 0x2061, 0x0000, 0x601b, 0x0001, 0x2091, 0x5000, 0x00e0,
+	0x128f, 0x00e0, 0x1291, 0x0068, 0x1291, 0x2091, 0x4080, 0x007c,
+	0x70c3, 0x4001, 0x0078, 0x1287, 0x70c3, 0x4006, 0x0078, 0x1287,
+	0x2099, 0x0041, 0x20a1, 0x0041, 0x20a9, 0x0005, 0x53a3, 0x0078,
+	0x1284, 0x70c4, 0x70c3, 0x0004, 0x007a, 0x0078, 0x1284, 0x0078,
+	0x1284, 0x0078, 0x1284, 0x0078, 0x1284, 0x2091, 0x8000, 0x70c3,
+	0x0000, 0x70c7, 0x4953, 0x70cb, 0x5020, 0x70cf, 0x2020, 0x70d3,
+	0x0007, 0x3f00, 0x70d6, 0x2079, 0x0000, 0x781b, 0x0001, 0x2031,
+	0x0030, 0x2059, 0x1000, 0x2029, 0x0457, 0x2051, 0x0470, 0x2061,
+	0x0472, 0x20b9, 0xffff, 0x20c1, 0x0000, 0x2091, 0x5000, 0x2091,
+	0x4080, 0x0078, 0x0455, 0x1078, 0x1b53, 0x00c0, 0x129c, 0x75d8,
+	0x74dc, 0x75da, 0x74de, 0x0078, 0x12e8, 0x2029, 0x0000, 0x2520,
+	0x71d0, 0x73c8, 0x72cc, 0x70c4, 0x1078, 0x1a8d, 0x0040, 0x1284,
+	0x70c3, 0x4002, 0x0078, 0x1284, 0x1078, 0x1b53, 0x00c0, 0x129c,
+	0x75d8, 0x74dc, 0x75da, 0x74de, 0x0078, 0x1301, 0x2029, 0x0000,
+	0x2520, 0x71d0, 0x73c8, 0x72cc, 0x70c4, 0x1078, 0x1aed, 0x0040,
+	0x1284, 0x70c3, 0x4002, 0x0078, 0x1284, 0x71c4, 0x70c8, 0x2114,
+	0x200a, 0x0078, 0x1282, 0x71c4, 0x2114, 0x0078, 0x1282, 0x70c7,
+	0x0007, 0x70cb, 0x0041, 0x70cf, 0x0000, 0x0078, 0x1284, 0x1078,
+	0x1b53, 0x00c0, 0x129c, 0x75d8, 0x76dc, 0x75da, 0x76de, 0x0078,
+	0x132c, 0x2029, 0x0000, 0x2530, 0x70c4, 0x72c8, 0x73cc, 0x74d0,
+	0x70c6, 0x72ca, 0x73ce, 0x74d2, 0xa005, 0x0040, 0x1350, 0x8001,
+	0x7892, 0xa084, 0xfc00, 0x0040, 0x1345, 0x78cc, 0xa085, 0x0001,
+	0x78ce, 0x2001, 0x4005, 0x0078, 0x1286, 0x7a9a, 0x7b9e, 0x7da2,
+	0x7ea6, 0x7c96, 0x78cc, 0xa084, 0xfffc, 0x78ce, 0x0078, 0x1354,
+	0x78cc, 0xa085, 0x0001, 0x78ce, 0x0078, 0x1284, 0x1078, 0x1b53,
+	0x00c0, 0x129c, 0x75d8, 0x76dc, 0x75da, 0x76de, 0x0078, 0x1363,
+	0x2029, 0x0000, 0x2530, 0x70c4, 0x72c8, 0x73cc, 0x74d4, 0x70c6,
+	0x72ca, 0x73ce, 0x74d6, 0xa005, 0x0040, 0x1387, 0x8001, 0x78ae,
+	0xa084, 0xfc00, 0x0040, 0x137c, 0x78cc, 0xa085, 0x0100, 0x78ce,
+	0x2001, 0x4005, 0x0078, 0x1286, 0x7ab6, 0x7bba, 0x7dbe, 0x7ec2,
+	0x7cb2, 0x78cc, 0xa084, 0xfcff, 0x78ce, 0x0078, 0x138b, 0x78cc,
+	0xa085, 0x0100, 0x78ce, 0x0078, 0x1284, 0x2009, 0x5161, 0x210c,
+	0x7aec, 0x0078, 0x1282, 0x2009, 0x5141, 0x210c, 0x0078, 0x1283,
+	0x2009, 0x5142, 0x210c, 0x0078, 0x1283, 0x2061, 0x5140, 0x610c,
+	0x6210, 0x0078, 0x1282, 0x2009, 0x5145, 0x210c, 0x0078, 0x1283,
+	0x2009, 0x5146, 0x210c, 0x0078, 0x1283, 0x2009, 0x5148, 0x210c,
+	0x0078, 0x1283, 0x2009, 0x5149, 0x210c, 0x0078, 0x1283, 0x7908,
+	0x7a0c, 0x0078, 0x1282, 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003,
+	0x8003, 0x8003, 0xa0e8, 0x5380, 0x6a00, 0x6804, 0xa084, 0x0008,
+	0x0040, 0x13cd, 0x6b08, 0x0078, 0x13ce, 0x6b0c, 0x0078, 0x1281,
+	0x77c4, 0x1078, 0x1973, 0x2091, 0x8000, 0x6b1c, 0x6a14, 0x2091,
+	0x8001, 0x2708, 0x0078, 0x1281, 0x794c, 0x0078, 0x1283, 0x77c4,
+	0x1078, 0x1973, 0x2091, 0x8000, 0x6908, 0x6a18, 0x6b10, 0x2091,
+	0x8001, 0x0078, 0x1281, 0x71c4, 0xa182, 0x0010, 0x00c8, 0x127c,
+	0x1078, 0x22e2, 0x0078, 0x1281, 0x71c4, 0xa182, 0x0010, 0x00c8,
+	0x127c, 0x2011, 0x5141, 0x2204, 0x007e, 0x2112, 0x1078, 0x229b,
+	0x017f, 0x0078, 0x1283, 0x71c4, 0x2011, 0x1421, 0x20a9, 0x0008,
+	0x2204, 0xa106, 0x0040, 0x1413, 0x8210, 0x0070, 0x1411, 0x0078,
+	0x1408, 0x0078, 0x127c, 0xa292, 0x1421, 0x027e, 0x2011, 0x5142,
+	0x2204, 0x2112, 0x017f, 0x007e, 0x1078, 0x22a7, 0x017f, 0x0078,
+	0x1283, 0x03e8, 0x00fa, 0x01f4, 0x02ee, 0x0064, 0x0019, 0x0032,
+	0x004b, 0x2061, 0x5140, 0x610c, 0x6210, 0x70c4, 0x600e, 0x70c8,
+	0x6012, 0x0078, 0x1282, 0x2061, 0x5140, 0x6114, 0x70c4, 0x6016,
+	0x0078, 0x1283, 0x2061, 0x5140, 0x71c4, 0x2011, 0x0004, 0x601f,
+	0x0019, 0x2019, 0x1212, 0xa186, 0x0028, 0x0040, 0x145b, 0x2011,
+	0x0005, 0x601f, 0x0019, 0x2019, 0x1212, 0xa186, 0x0032, 0x0040,
+	0x145b, 0x2011, 0x0006, 0x601f, 0x000c, 0x2019, 0x2222, 0xa186,
+	0x003c, 0x00c0, 0x127c, 0x6018, 0x007e, 0x611a, 0x7800, 0xa084,
+	0x0001, 0x00c0, 0x1476, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005,
+	0x0048, 0x146e, 0x0038, 0x1472, 0x0078, 0x1476, 0x0028, 0x1472,
+	0x0078, 0x1476, 0x2019, 0x2222, 0x0078, 0x1478, 0x2019, 0x1212,
+	0x23b8, 0x1078, 0x22b8, 0x1078, 0x4d22, 0x017f, 0x0078, 0x1283,
+	0x71c4, 0xa184, 0xffcf, 0x00c0, 0x127c, 0x2011, 0x5148, 0x2204,
+	0x2112, 0x007e, 0x1078, 0x22da, 0x017f, 0x0078, 0x1283, 0x71c4,
+	0xa182, 0x0010, 0x00c8, 0x127c, 0x2011, 0x5149, 0x2204, 0x007e,
+	0x2112, 0x1078, 0x22c9, 0x017f, 0x0078, 0x1283, 0x71c4, 0x72c8,
+	0xa184, 0xfffd, 0x00c0, 0x127b, 0xa284, 0xfffd, 0x00c0, 0x127b,
+	0x2100, 0x7908, 0x780a, 0x2200, 0x7a0c, 0x780e, 0x0078, 0x1282,
+	0x71c4, 0x8107, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e8,
+	0x5380, 0x2019, 0x0000, 0x72c8, 0xa284, 0x0080, 0x0040, 0x14c6,
+	0x6c14, 0x84ff, 0x00c0, 0x14c6, 0x6817, 0x0040, 0xa284, 0x0040,
+	0x0040, 0x14d0, 0x6c10, 0x84ff, 0x00c0, 0x14d0, 0x6813, 0x0001,
+	0x6800, 0x007e, 0xa226, 0x0040, 0x14f3, 0x6a02, 0xa484, 0x2000,
+	0x0040, 0x14dc, 0xa39d, 0x0010, 0xa484, 0x1000, 0x0040, 0x14e2,
+	0xa39d, 0x0008, 0xa484, 0x4000, 0x0040, 0x14f3, 0x810f, 0xa284,
+	0x4000, 0x0040, 0x14ef, 0x1078, 0x22fc, 0x0078, 0x14f3, 0x1078,
+	0x22ee, 0x0078, 0x14f3, 0x72cc, 0x6808, 0xa206, 0x0040, 0x1522,
+	0xa2a4, 0x00ff, 0x2061, 0x5140, 0x6118, 0xa186, 0x0028, 0x0040,
+	0x1509, 0xa186, 0x0032, 0x0040, 0x150f, 0xa186, 0x003c, 0x0040,
+	0x1515, 0xa482, 0x0064, 0x0048, 0x151f, 0x0078, 0x1519, 0xa482,
+	0x0050, 0x0048, 0x151f, 0x0078, 0x1519, 0xa482, 0x0043, 0x0048,
+	0x151f, 0x71c4, 0x71c6, 0x027f, 0x72ca, 0x0078, 0x127d, 0x6a0a,
+	0xa39d, 0x000a, 0x6804, 0xa305, 0x6806, 0x027f, 0x6b0c, 0x71c4,
+	0x0078, 0x1281, 0x77c4, 0x1078, 0x1973, 0x2091, 0x8000, 0x6a14,
+	0x6b1c, 0x2091, 0x8001, 0x70c8, 0x6816, 0x70cc, 0x681e, 0x2708,
+	0x0078, 0x1281, 0x70c4, 0x794c, 0x784e, 0x0078, 0x1283, 0x71c4,
+	0x72c8, 0x73cc, 0xa182, 0x0010, 0x00c8, 0x127c, 0x1078, 0x230a,
+	0x0078, 0x1281, 0x77c4, 0x1078, 0x1973, 0x2091, 0x8000, 0x6a08,
+	0xa295, 0x0002, 0x6a0a, 0x2091, 0x8001, 0x2708, 0x0078, 0x1282,
+	0x77c4, 0x1078, 0x1973, 0x2091, 0x8000, 0x6a08, 0xa294, 0xfff9,
+	0x6a0a, 0x6804, 0xa005, 0x0040, 0x1567, 0x1078, 0x21d2, 0x2091,
+	0x8001, 0x2708, 0x0078, 0x1282, 0x77c4, 0x1078, 0x1973, 0x2091,
+	0x8000, 0x6a08, 0xa295, 0x0004, 0x6a0a, 0x6804, 0xa005, 0x0040,
+	0x157b, 0x1078, 0x21d2, 0x2091, 0x8001, 0x2708, 0x0078, 0x1282,
+	0x77c4, 0x2041, 0x0001, 0x2049, 0x0005, 0x2051, 0x0020, 0x2091,
+	0x8000, 0x1078, 0x1980, 0x2091, 0x8001, 0x2708, 0x6a08, 0x0078,
+	0x1282, 0x77c4, 0x72c8, 0x73cc, 0x77c6, 0x72ca, 0x73ce, 0x1078,
+	0x19e1, 0x00c0, 0x15a9, 0x6818, 0xa005, 0x0040, 0x15a9, 0x2708,
+	0x1078, 0x231a, 0x00c0, 0x15a9, 0x7817, 0x0015, 0x2091, 0x8001,
+	0x007c, 0x2091, 0x8001, 0x0078, 0x1284, 0x77c4, 0x77c6, 0x2041,
+	0x0021, 0x2049, 0x0005, 0x2051, 0x0020, 0x2091, 0x8000, 0x1078,
+	0x1980, 0x2061, 0x5140, 0x606f, 0x0003, 0x6782, 0x6093, 0x000f,
+	0x6073, 0x0000, 0x7817, 0x0016, 0x1078, 0x21d2, 0x2091, 0x8001,
+	0x007c, 0x77c8, 0x77ca, 0x77c4, 0x77c6, 0xa7bc, 0xff00, 0x2091,
+	0x8000, 0x2061, 0x5140, 0x606f, 0x0002, 0x6073, 0x0000, 0x6782,
+	0x6093, 0x000f, 0x7817, 0x0017, 0x1078, 0x21d2, 0x2091, 0x8001,
+	0x2041, 0x0021, 0x2049, 0x0004, 0x2051, 0x0010, 0x2091, 0x8000,
+	0x1078, 0x1980, 0x70c8, 0x6836, 0x8738, 0xa784, 0x001f, 0x00c0,
+	0x15e8, 0x2091, 0x8001, 0x007c, 0x78cc, 0xa084, 0x0003, 0x00c0,
+	0x1618, 0x2039, 0x0000, 0x2041, 0x0021, 0x2049, 0x0004, 0x2051,
+	0x0008, 0x1078, 0x1973, 0x2091, 0x8000, 0x6808, 0xa80d, 0x690a,
+	0x2091, 0x8001, 0x8738, 0xa784, 0x001f, 0x00c0, 0x1601, 0xa7bc,
+	0xff00, 0x873f, 0x8738, 0x873f, 0xa784, 0x0f00, 0x00c0, 0x1601,
+	0x2091, 0x8000, 0x2069, 0x0100, 0x6830, 0xa084, 0x0040, 0x0040,
+	0x1641, 0x684b, 0x0004, 0x20a9, 0x0014, 0x6848, 0xa084, 0x0004,
+	0x0040, 0x162e, 0x0070, 0x162e, 0x0078, 0x1625, 0x684b, 0x0009,
+	0x20a9, 0x0014, 0x6848, 0xa084, 0x0001, 0x0040, 0x163b, 0x0070,
+	0x163b, 0x0078, 0x1632, 0x20a9, 0x00fa, 0x0070, 0x1641, 0x0078,
+	0x163d, 0x2079, 0x5100, 0x7817, 0x0018, 0x2061, 0x5140, 0x606f,
+	0x0001, 0x6073, 0x0000, 0x6093, 0x000f, 0x78cc, 0xa085, 0x0002,
+	0x78ce, 0x6808, 0xa084, 0xfffd, 0x680a, 0x681b, 0x0048, 0x2091,
+	0x8001, 0x007c, 0x78cc, 0xa084, 0xfffd, 0x78ce, 0xa084, 0x0001,
+	0x00c0, 0x1664, 0x1078, 0x1a2b, 0x71c4, 0x71c6, 0x794a, 0x007c,
+	0x1078, 0x1b53, 0x00c0, 0x129c, 0x75d8, 0x74dc, 0x75da, 0x74de,
+	0x0078, 0x1675, 0x2029, 0x0000, 0x2520, 0x71c4, 0x73c8, 0x72cc,
+	0x71c6, 0x73ca, 0x72ce, 0x2079, 0x5100, 0x2091, 0x8000, 0x1078,
+	0x192e, 0x2091, 0x8001, 0x0040, 0x172c, 0x20a9, 0x0005, 0x20a1,
+	0x5118, 0x2091, 0x8000, 0x41a1, 0x2091, 0x8001, 0x2009, 0x0020,
+	0x1078, 0x1929, 0x0040, 0x1698, 0x1078, 0x1948, 0x0078, 0x172c,
+	0x6004, 0xa084, 0xff00, 0x8007, 0x8009, 0x0040, 0x16fb, 0x0c7e,
+	0x2c68, 0x2091, 0x8000, 0x1078, 0x192e, 0x2091, 0x8001, 0x0040,
+	0x16cc, 0x2c00, 0x689e, 0x8109, 0x00c0, 0x16a0, 0x609f, 0x0000,
+	0x0c7f, 0x0c7e, 0x7218, 0x731c, 0x7420, 0x7524, 0x2c68, 0x689c,
+	0xa065, 0x0040, 0x16fa, 0x2009, 0x0020, 0x1078, 0x1929, 0x00c0,
+	0x16e3, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0002, 0x00c0, 0x16cc,
+	0x2d00, 0x6002, 0x0078, 0x16b2, 0x0c7f, 0x0c7e, 0x609c, 0x2060,
+	0x1078, 0x19b3, 0x0c7f, 0x609f, 0x0000, 0x1078, 0x1730, 0x2009,
+	0x000c, 0x6008, 0xa085, 0x0200, 0x600a, 0x1078, 0x1924, 0x1078,
+	0x1948, 0x0078, 0x172c, 0x0c7f, 0x0c7e, 0x609c, 0x2060, 0x1078,
+	0x19b3, 0x0c7f, 0x609f, 0x0000, 0x1078, 0x1730, 0x2009, 0x000c,
+	0x6007, 0x0103, 0x601b, 0x0003, 0x1078, 0x1924, 0x1078, 0x1948,
+	0x0078, 0x172c, 0x0c7f, 0x74c4, 0x73c8, 0x72cc, 0x6014, 0x2091,
+	0x8000, 0x7817, 0x0012, 0x0e7e, 0x2071, 0x5140, 0x706f, 0x0005,
+	0x7073, 0x0000, 0x7376, 0x727a, 0x747e, 0x7082, 0x7087, 0x0000,
+	0x2c00, 0x708a, 0x708f, 0x0000, 0xa02e, 0x2530, 0x611c, 0x61a2,
+	0xa184, 0x0060, 0x0040, 0x171e, 0x1078, 0x47c2, 0x0e7f, 0x6596,
+	0x65a6, 0x669a, 0x66aa, 0x60af, 0x0000, 0x60b3, 0x0000, 0x1078,
+	0x21d2, 0x2091, 0x8001, 0x007c, 0x70c3, 0x4005, 0x0078, 0x1287,
+	0x20a9, 0x0005, 0x2099, 0x5118, 0x2091, 0x8000, 0x530a, 0x2091,
+	0x8001, 0x2100, 0xa210, 0xa399, 0x0000, 0xa4a1, 0x0000, 0xa5a9,
+	0x0000, 0x007c, 0x71c4, 0x70c7, 0x0000, 0x7906, 0x0078, 0x1284,
+	0x71c4, 0x71c6, 0x2168, 0x0078, 0x174f, 0x2069, 0x1000, 0x690c,
+	0xa016, 0x2d04, 0xa210, 0x8d68, 0x8109, 0x00c0, 0x1751, 0xa285,
+	0x0000, 0x00c0, 0x175f, 0x70c3, 0x4000, 0x0078, 0x1761, 0x70c3,
+	0x4003, 0x70ca, 0x0078, 0x1287, 0x2011, 0x5167, 0x220c, 0x70c4,
+	0x8003, 0x0048, 0x1771, 0x1078, 0x3b7f, 0xa184, 0x7fff, 0x0078,
+	0x1775, 0x1078, 0x3b72, 0xa185, 0x8000, 0x2012, 0x0078, 0x1283,
+	0x71c4, 0x1078, 0x3b69, 0x6100, 0x2001, 0x5167, 0x2004, 0xa084,
+	0x8000, 0xa10d, 0x6204, 0x6308, 0x0078, 0x1281, 0x79e4, 0x0078,
+	0x1283, 0x71c4, 0x71c6, 0x2198, 0x20a1, 0x0042, 0x20a9, 0x0004,
+	0x53a3, 0x21a0, 0x2099, 0x0042, 0x20a9, 0x0004, 0x53a3, 0x0078,
+	0x1284, 0x70c4, 0x2068, 0x2079, 0x5100, 0x2091, 0x8000, 0x1078,
+	0x192e, 0x2091, 0x8001, 0x0040, 0x1825, 0x6007, 0x0001, 0x600b,
+	0x0000, 0x602b, 0x0000, 0x601b, 0x0006, 0x6a10, 0xa28c, 0x000f,
+	0xa284, 0x00f0, 0x8003, 0x8003, 0x8003, 0x8003, 0xa105, 0x6016,
+	0xa284, 0x0800, 0x0040, 0x17c0, 0x601b, 0x000a, 0x0078, 0x17c6,
+	0xa284, 0x1000, 0x0040, 0x17c6, 0x601b, 0x000c, 0xa284, 0x0300,
+	0x0040, 0x17cf, 0x602b, 0x0001, 0x8004, 0x8004, 0x8004, 0xa085,
+	0x0001, 0x601e, 0x6023, 0x0000, 0x6027, 0x0000, 0xa284, 0x0400,
+	0x0040, 0x17dc, 0x602b, 0x0000, 0x20a9, 0x0006, 0xac80, 0x000b,
+	0x20a0, 0xad80, 0x0005, 0x2098, 0x53a3, 0xa284, 0x0300, 0x00c0,
+	0x17f1, 0x6046, 0x604a, 0x604e, 0x6052, 0x6096, 0x609a, 0x0078,
+	0x17fb, 0x6800, 0x6046, 0x6804, 0x604a, 0x6e08, 0x664e, 0x6d0c,
+	0x6552, 0x6596, 0x669a, 0x6014, 0x2091, 0x8000, 0x7817, 0x0042,
+	0x2c08, 0x2061, 0x5140, 0x606f, 0x0005, 0x6073, 0x0000, 0x6077,
+	0x0000, 0x607b, 0x0000, 0x607f, 0x0000, 0x6082, 0x618a, 0xa284,
+	0x0400, 0x608e, 0x2091, 0x8001, 0x0e7e, 0x2071, 0x0020, 0x7007,
+	0x000a, 0x7007, 0x0002, 0x7003, 0x0000, 0x0e7f, 0x2091, 0x8000,
+	0x1078, 0x21d2, 0x2091, 0x8001, 0x007c, 0x70c3, 0x4005, 0x0078,
+	0x1287, 0x0c7e, 0x0d7e, 0x0e7e, 0x0f7e, 0x2091, 0x8000, 0x2071,
+	0x5140, 0x2079, 0x0100, 0x2061, 0x0010, 0x70a0, 0xa06d, 0x0040,
+	0x18b1, 0x6a04, 0xa294, 0x00ff, 0xa286, 0x0007, 0x0040, 0x1844,
+	0xa286, 0x000f, 0x00c0, 0x18b1, 0x691c, 0xa184, 0x0080, 0x00c0,
+	0x18b1, 0x6824, 0xa18c, 0xff00, 0xa085, 0x0019, 0x6826, 0x71b0,
+	0x81ff, 0x0040, 0x1867, 0x0d7e, 0x2069, 0x0020, 0x6807, 0x0010,
+	0x6908, 0x6808, 0xa106, 0x00c0, 0x1858, 0x690c, 0x680c, 0xa106,
+	0x00c0, 0x185d, 0xa184, 0x00ff, 0x00c0, 0x185d, 0x0d7f, 0x78b8,
+	0xa084, 0x801f, 0x00c0, 0x1867, 0x7848, 0xa085, 0x000c, 0x784a,
+	0x71b0, 0x81ff, 0x0040, 0x188a, 0x70b3, 0x0000, 0x0d7e, 0x2069,
+	0x0020, 0x6807, 0x0018, 0x6804, 0xa084, 0x0008, 0x00c0, 0x187b,
+	0x6807, 0x0008, 0x6804, 0xa084, 0x0008, 0x00c0, 0x1882, 0x6807,
+	0x0002, 0x0d7f, 0x61c4, 0x62c8, 0x63cc, 0x61c6, 0x62ca, 0x63ce,
+	0x0e7e, 0x2071, 0x5100, 0x7266, 0x736a, 0xae80, 0x0019, 0x0e7f,
+	0x7848, 0xa084, 0x000c, 0x00c0, 0x1898, 0x1078, 0x46db, 0x78a3,
+	0x0000, 0x7858, 0xa084, 0xedff, 0x785a, 0x70b4, 0xa080, 0x00df,
+	0x781a, 0x0f7f, 0x0e7f, 0x0d7f, 0x0c7f, 0x2091, 0x8001, 0x0078,
+	0x1284, 0x0f7f, 0x0e7f, 0x0d7f, 0x0c7f, 0x2091, 0x8001, 0x2001,
+	0x4005, 0x0078, 0x1286, 0x7980, 0x71c6, 0x71c4, 0xa182, 0x0003,
+	0x00c8, 0x127c, 0x7982, 0x0078, 0x1284, 0x7980, 0x71c6, 0x0078,
+	0x1284, 0x7974, 0x71c6, 0x71c4, 0x7976, 0x7978, 0x71ca, 0x71c8,
+	0x797a, 0x797c, 0x71ce, 0x71cc, 0x797e, 0x0078, 0x1284, 0x7974,
+	0x71c6, 0x7978, 0x71ca, 0x797c, 0x71ce, 0x0078, 0x1284, 0x7900,
+	0x71c6, 0x71c4, 0x7902, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005,
+	0x0048, 0x18ee, 0x0038, 0x18f0, 0x0078, 0x18fa, 0x00a8, 0x18fa,
+	0xa18c, 0x0001, 0x00c0, 0x18f8, 0x20b9, 0x2222, 0x0078, 0x18fa,
+	0x20b9, 0x1212, 0x0078, 0x1284, 0x7900, 0x71c6, 0x0078, 0x1284,
+	0x2009, 0x5174, 0x2104, 0x70c6, 0x70c4, 0x200a, 0x0078, 0x1284,
+	0x2009, 0x5174, 0x2104, 0x70c6, 0x0078, 0x1284, 0x71c4, 0x8107,
+	0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e8, 0x5380, 0x6a14,
+	0xd2b4, 0x0040, 0x191f, 0x2011, 0x0001, 0x0078, 0x1921, 0x2011,
+	0x0000, 0x6b0c, 0x0078, 0x1281, 0xac80, 0x0001, 0x1078, 0x1b0f,
+	0x007c, 0xac80, 0x0001, 0x1078, 0x1aaf, 0x007c, 0x7850, 0xa065,
+	0x0040, 0x1936, 0x2c04, 0x7852, 0x2063, 0x0000, 0x007c, 0x0f7e,
+	0x2079, 0x5100, 0x7850, 0xa06d, 0x0040, 0x1946, 0x2d04, 0x7852,
+	0x6803, 0x0000, 0x6807, 0x0000, 0x680b, 0x0000, 0x0f7f, 0x007c,
+	0x2091, 0x8000, 0x0f7e, 0x2079, 0x5100, 0x7850, 0x2062, 0x2c00,
+	0xa005, 0x00c0, 0x1955, 0x1078, 0x23eb, 0x7852, 0x0f7f, 0x2091,
+	0x8001, 0x007c, 0x0f7e, 0x2079, 0x5100, 0x7850, 0x206a, 0x2d00,
+	0x7852, 0x0f7f, 0x007c, 0x2011, 0x7800, 0x7a52, 0x7bec, 0x8319,
+	0x0040, 0x1970, 0xa280, 0x0031, 0x2012, 0x2010, 0x0078, 0x1967,
+	0x2013, 0x0000, 0x007c, 0xa784, 0x0f00, 0x800b, 0xa784, 0x001f,
+	0x8003, 0x8003, 0x8003, 0x8003, 0xa105, 0xa0e8, 0x5400, 0x007c,
+	0x1078, 0x1973, 0x2900, 0x682a, 0x2a00, 0x682e, 0x6808, 0xa084,
+	0xffef, 0xa80d, 0x690a, 0x2009, 0x5152, 0x210c, 0x6804, 0xa005,
+	0x0040, 0x19b2, 0xa116, 0x00c0, 0x199d, 0x2060, 0x6000, 0x6806,
+	0x017e, 0x200b, 0x0000, 0x0078, 0x19a0, 0x2009, 0x0000, 0x017e,
+	0x6804, 0xa065, 0x0040, 0x19af, 0x6000, 0x6806, 0x1078, 0x19c0,
+	0x1078, 0x1c5f, 0x6810, 0x8001, 0x6812, 0x00c0, 0x19a0, 0x017f,
+	0x6902, 0x6906, 0x007c, 0xa065, 0x0040, 0x19bf, 0x609c, 0x609f,
+	0x0000, 0x2008, 0x1078, 0x1948, 0x2100, 0x0078, 0x19b3, 0x007c,
+	0x6007, 0x0103, 0x608f, 0x0000, 0x20a9, 0x001c, 0xac80, 0x0005,
+	0x20a0, 0x2001, 0x0000, 0x40a4, 0x6828, 0x601a, 0x682c, 0x6022,
+	0x007c, 0x0e7e, 0x2071, 0x5140, 0x704c, 0xa08c, 0x0200, 0x00c0,
+	0x19df, 0xa088, 0x5180, 0x2d0a, 0x8000, 0x704e, 0xa006, 0x0e7f,
+	0x007c, 0x1078, 0x1973, 0x2091, 0x8000, 0x6804, 0x781e, 0xa065,
+	0x0040, 0x1a2a, 0x0078, 0x19f2, 0x2c00, 0x781e, 0x6000, 0xa065,
+	0x0040, 0x1a2a, 0x600c, 0xa306, 0x00c0, 0x19ec, 0x6010, 0xa206,
+	0x00c0, 0x19ec, 0x2c28, 0x2001, 0x5152, 0x2004, 0xac06, 0x00c0,
+	0x1a03, 0x0078, 0x1a28, 0x6804, 0xac06, 0x00c0, 0x1a10, 0x6000,
+	0xa065, 0x6806, 0x00c0, 0x1a1a, 0x6803, 0x0000, 0x0078, 0x1a1a,
+	0x6400, 0x781c, 0x2060, 0x6402, 0xa486, 0x0000, 0x00c0, 0x1a1a,
+	0x2c00, 0x6802, 0x2560, 0x1078, 0x19c0, 0x601b, 0x0005, 0x6023,
+	0x0020, 0x1078, 0x1c5f, 0x6810, 0x8001, 0x1050, 0x23eb, 0x6812,
+	0xa085, 0xffff, 0x007c, 0x2039, 0x0000, 0x2041, 0x0021, 0x2049,
+	0x0004, 0x2051, 0x0008, 0x2091, 0x8000, 0x1078, 0x1980, 0x8738,
+	0xa784, 0x001f, 0x00c0, 0x1a35, 0xa7bc, 0xff00, 0x873f, 0x8738,
+	0x873f, 0xa784, 0x0f00, 0x00c0, 0x1a35, 0x2091, 0x8001, 0x007c,
+	0x2061, 0x0000, 0x6018, 0xa084, 0x0001, 0x00c0, 0x1a59, 0x2091,
+	0x8000, 0x78e0, 0x78e3, 0x0000, 0x2091, 0x8001, 0xa005, 0x00c0,
+	0x1a5a, 0x007c, 0xa08c, 0xfff0, 0x0040, 0x1a60, 0x1078, 0x23eb,
+	0x0079, 0x1a62, 0x1a72, 0x1a75, 0x1a7b, 0x1a7f, 0x1a73, 0x1a83,
+	0x1a89, 0x1a73, 0x1a73, 0x1c29, 0x1c4d, 0x1c51, 0x1a73, 0x1a73,
+	0x1a73, 0x1a73, 0x007c, 0x1078, 0x23eb, 0x1078, 0x1a2b, 0x2001,
+	0x8001, 0x0078, 0x1c57, 0x2001, 0x8003, 0x0078, 0x1c57, 0x2001,
+	0x8004, 0x0078, 0x1c57, 0x1078, 0x1a2b, 0x2001, 0x8006, 0x0078,
+	0x1c57, 0x2001, 0x8007, 0x0078, 0x1c57, 0x2030, 0x2138, 0xa782,
+	0x0021, 0x0048, 0x1a95, 0x2009, 0x0020, 0x2600, 0x1078, 0x1aaf,
+	0x00c0, 0x1aae, 0xa7ba, 0x0020, 0x0048, 0x1aad, 0x0040, 0x1aad,
+	0x2708, 0xa6b0, 0x0020, 0xa290, 0x0040, 0xa399, 0x0000, 0xa4a1,
+	0x0000, 0xa5a9, 0x0000, 0x0078, 0x1a8f, 0xa006, 0x007c, 0x81ff,
+	0x0040, 0x1aea, 0x2099, 0x0030, 0x20a0, 0x700c, 0xa084, 0x00ff,
+	0x0040, 0x1ac1, 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0,
+	0x1abc, 0x21a8, 0x7017, 0x0000, 0x810b, 0x7112, 0x721a, 0x731e,
+	0x7422, 0x7526, 0x780c, 0xa085, 0x0001, 0x7002, 0x7007, 0x0001,
+	0x2001, 0x04fd, 0x2004, 0xa082, 0x0005, 0x00c8, 0x1ade, 0x2009,
+	0x0022, 0x2104, 0xa084, 0x4000, 0x00c0, 0x1ad0, 0x7008, 0x800b,
+	0x00c8, 0x1ad0, 0x7007, 0x0002, 0xa08c, 0x01e0, 0x00c0, 0x1aea,
+	0x53a5, 0xa006, 0x7003, 0x0000, 0x007c, 0x2030, 0x2138, 0xa782,
+	0x0021, 0x0048, 0x1af5, 0x2009, 0x0020, 0x2600, 0x1078, 0x1b0f,
+	0x00c0, 0x1b0e, 0xa7ba, 0x0020, 0x0048, 0x1b0d, 0x0040, 0x1b0d,
+	0x2708, 0xa6b0, 0x0020, 0xa290, 0x0040, 0xa399, 0x0000, 0xa4a1,
+	0x0000, 0xa5a9, 0x0000, 0x0078, 0x1aef, 0xa006, 0x007c, 0x81ff,
+	0x0040, 0x1b50, 0x2098, 0x20a1, 0x0030, 0x700c, 0xa084, 0x00ff,
+	0x0040, 0x1b21, 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0,
+	0x1b1c, 0x21a8, 0x7017, 0x0000, 0x810b, 0x7112, 0x721a, 0x731e,
+	0x7422, 0x7526, 0x780c, 0xa085, 0x0000, 0x7002, 0x53a6, 0x7007,
+	0x0001, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005, 0x00c8, 0x1b3f,
+	0x2009, 0x0022, 0x2104, 0xa084, 0x4000, 0x00c0, 0x1b31, 0x7010,
+	0xa084, 0xf000, 0x0040, 0x1b48, 0x7007, 0x0008, 0x0078, 0x1b4c,
+	0x7108, 0x8103, 0x00c8, 0x1b31, 0x7007, 0x0002, 0xa184, 0x01e0,
+	0x7003, 0x0000, 0x007c, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0004,
+	0x00c8, 0x1b5c, 0x0078, 0x1b5f, 0xa006, 0x0078, 0x1b61, 0xa085,
+	0x0001, 0x007c, 0x0e7e, 0x2071, 0x5100, 0x2d08, 0x7058, 0x6802,
+	0xa005, 0x00c0, 0x1b6c, 0x715e, 0x715a, 0x0e7f, 0x007c, 0x2c08,
+	0x7858, 0x6002, 0xa005, 0x00c0, 0x1b76, 0x795e, 0x795a, 0x007c,
+	0x2091, 0x8000, 0x6003, 0x0000, 0x2c08, 0x785c, 0xa065, 0x00c0,
+	0x1b84, 0x795a, 0x0078, 0x1b85, 0x6102, 0x795e, 0x2091, 0x8001,
+	0x1078, 0x21ef, 0x007c, 0x0e7e, 0x2071, 0x5100, 0x7058, 0xa06d,
+	0x0040, 0x1b99, 0x6800, 0x705a, 0xa005, 0x00c0, 0x1b98, 0x705e,
+	0x8dff, 0x0e7f, 0x007c, 0x0d7e, 0x0c7e, 0x0f7e, 0x2079, 0x5100,
+	0xaf80, 0x0016, 0x2060, 0x6000, 0xa005, 0x0040, 0x1bc9, 0x2068,
+	0x6814, 0xa306, 0x00c0, 0x1bb2, 0x6828, 0xa084, 0x00ff, 0xa406,
+	0x0040, 0x1bb5, 0x2d60, 0x0078, 0x1ba3, 0x6800, 0xa005, 0x6002,
+	0x00c0, 0x1bc1, 0xaf80, 0x0016, 0xac06, 0x0040, 0x1bc0, 0x2c00,
+	0x785e, 0x0d7e, 0x689c, 0xa005, 0x0040, 0x1bc8, 0x1078, 0x19b3,
+	0x007f, 0x0f7f, 0x0c7f, 0x0d7f, 0xa005, 0x007c, 0x0d7e, 0x0c7e,
+	0x0f7e, 0x2079, 0x5100, 0xaf80, 0x0016, 0x2060, 0x6000, 0xa005,
+	0x0040, 0x1bf8, 0x2068, 0x6814, 0xa084, 0x00ff, 0xa306, 0x0040,
+	0x1be4, 0x2d60, 0x0078, 0x1bd6, 0x6800, 0xa005, 0x6002, 0x00c0,
+	0x1bf0, 0xaf80, 0x0016, 0xac06, 0x0040, 0x1bef, 0x2c00, 0x785e,
+	0x0d7e, 0x689c, 0xa005, 0x0040, 0x1bf7, 0x1078, 0x19b3, 0x007f,
+	0x0f7f, 0x0c7f, 0x0d7f, 0xa005, 0x007c, 0x0d7e, 0x0c7e, 0x0f7e,
+	0x2079, 0x5100, 0xaf80, 0x0016, 0x2060, 0x6000, 0xa06d, 0x0040,
+	0x1c24, 0x6814, 0xa306, 0x0040, 0x1c10, 0x2d60, 0x0078, 0x1c05,
+	0x6800, 0xa005, 0x6002, 0x00c0, 0x1c1c, 0xaf80, 0x0016, 0xac06,
+	0x0040, 0x1c1b, 0x2c00, 0x785e, 0x0d7e, 0x689c, 0xa005, 0x0040,
+	0x1c23, 0x1078, 0x19b3, 0x007f, 0x0f7f, 0x0c7f, 0x0d7f, 0xa005,
+	0x007c, 0x2091, 0x8000, 0x2069, 0x5140, 0x6800, 0xa086, 0x0000,
+	0x0040, 0x1c37, 0x2091, 0x8001, 0x78e3, 0x0009, 0x007c, 0x6880,
+	0xa0bc, 0xff00, 0x2041, 0x0021, 0x2049, 0x0004, 0x2051, 0x0010,
+	0x1078, 0x1980, 0x8738, 0xa784, 0x001f, 0x00c0, 0x1c40, 0x2091,
+	0x8001, 0x2001, 0x800a, 0x0078, 0x1c57, 0x2001, 0x800c, 0x0078,
+	0x1c57, 0x1078, 0x1a2b, 0x2001, 0x800d, 0x0078, 0x1c57, 0x70c2,
+	0x2061, 0x0000, 0x601b, 0x0001, 0x2091, 0x4080, 0x007c, 0x6004,
+	0x2c08, 0x2063, 0x0000, 0x7884, 0x8000, 0x7886, 0x7888, 0xa005,
+	0x798a, 0x0040, 0x1c6e, 0x2c02, 0x0078, 0x1c6f, 0x798e, 0x007c,
+	0x6807, 0x0103, 0x0c7e, 0x2061, 0x5100, 0x2d08, 0x206b, 0x0000,
+	0x6084, 0x8000, 0x6086, 0x6088, 0xa005, 0x618a, 0x0040, 0x1c83,
+	0x2d02, 0x0078, 0x1c84, 0x618e, 0x0c7f, 0x007c, 0x1078, 0x1c97,
+	0x0040, 0x1c96, 0x0c7e, 0x609c, 0xa065, 0x0040, 0x1c91, 0x1078,
+	0x19b3, 0x0c7f, 0x609f, 0x0000, 0x1078, 0x1948, 0x007c, 0x788c,
+	0xa065, 0x0040, 0x1ca9, 0x2091, 0x8000, 0x7884, 0x8001, 0x7886,
+	0x2c04, 0x788e, 0xa005, 0x00c0, 0x1ca7, 0x788a, 0x8000, 0x2091,
+	0x8001, 0x007c, 0x20a9, 0x0010, 0xa006, 0x8004, 0x8086, 0x818e,
+	0x00c8, 0x1cb3, 0xa200, 0x0070, 0x1cb7, 0x0078, 0x1cae, 0x8086,
+	0x818e, 0x007c, 0x157e, 0x20a9, 0x0010, 0xa005, 0x0040, 0x1cdd,
+	0xa11a, 0x00c8, 0x1cdd, 0x8213, 0x818d, 0x0048, 0x1cce, 0xa11a,
+	0x00c8, 0x1ccf, 0x0070, 0x1cd5, 0x0078, 0x1cc3, 0xa11a, 0x2308,
+	0x8210, 0x0070, 0x1cd5, 0x0078, 0x1cc3, 0x007e, 0x3200, 0xa084,
+	0xf7ff, 0x2080, 0x007f, 0x157f, 0x007c, 0x007e, 0x3200, 0xa085,
+	0x0800, 0x0078, 0x1cd9, 0x7994, 0x70d0, 0xa106, 0x0040, 0x1d51,
+	0x2091, 0x8000, 0x2071, 0x0020, 0x7004, 0xa005, 0x00c0, 0x1d51,
+	0x7008, 0x7208, 0xa206, 0x00c0, 0x1d51, 0xa286, 0x0008, 0x00c0,
+	0x1d51, 0x2071, 0x0010, 0x1078, 0x192e, 0x0040, 0x1d51, 0x7a9c,
+	0x7b98, 0x7ca4, 0x7da0, 0xa184, 0xff00, 0x0040, 0x1d1f, 0x2031,
+	0x0000, 0x810b, 0x86b5, 0x810b, 0x86b5, 0x810b, 0x86b5, 0x810b,
+	0x86b5, 0x810b, 0x86b5, 0x810b, 0x86b5, 0x2100, 0xa210, 0x2600,
+	0xa319, 0xa4a1, 0x0000, 0xa5a9, 0x0000, 0x0078, 0x1d29, 0x8107,
+	0x8004, 0x8004, 0xa210, 0xa399, 0x0000, 0xa4a1, 0x0000, 0xa5a9,
+	0x0000, 0x2009, 0x0020, 0x1078, 0x1929, 0x2091, 0x8001, 0x0040,
+	0x1d48, 0x1078, 0x1948, 0x78a8, 0x8000, 0x78aa, 0xa086, 0x0002,
+	0x00c0, 0x1d51, 0x2091, 0x8000, 0x78e3, 0x0002, 0x78ab, 0x0000,
+	0x78cc, 0xa085, 0x0003, 0x78ce, 0x2091, 0x8001, 0x0078, 0x1d51,
+	0x78ab, 0x0000, 0x1078, 0x20ac, 0x6004, 0xa084, 0x000f, 0x0079,
+	0x1d56, 0x2071, 0x0010, 0x2091, 0x8001, 0x007c, 0x1d66, 0x1d88,
+	0x1dae, 0x1d66, 0x1dcb, 0x1d75, 0x1f2c, 0x1f47, 0x1d66, 0x1d82,
+	0x1da8, 0x1e13, 0x1e82, 0x1ed2, 0x1ee4, 0x1f43, 0x2039, 0x0400,
+	0x78dc, 0xa705, 0x78de, 0x6008, 0xa705, 0x600a, 0x1078, 0x1fc7,
+	0x609c, 0x78da, 0x1078, 0x2094, 0x007c, 0x78dc, 0xa084, 0x0100,
+	0x0040, 0x1d7c, 0x0078, 0x1d66, 0x601c, 0xa085, 0x0080, 0x601e,
+	0x0078, 0x1d8f, 0x1078, 0x1b53, 0x00c0, 0x1d66, 0x1078, 0x20c6,
+	0x78dc, 0xa084, 0x0100, 0x0040, 0x1d8f, 0x0078, 0x1d66, 0x78df,
+	0x0000, 0x6004, 0x8007, 0xa084, 0x00ff, 0x78d2, 0x8001, 0x609f,
+	0x0000, 0x0040, 0x1da5, 0x1078, 0x1fc7, 0x0040, 0x1da5, 0x78dc,
+	0xa085, 0x0100, 0x78de, 0x0078, 0x1da7, 0x1078, 0x1feb, 0x007c,
+	0x1078, 0x1b53, 0x00c0, 0x1d66, 0x1078, 0x20c2, 0x78dc, 0xa08c,
+	0x0e00, 0x00c0, 0x1db7, 0xa084, 0x0100, 0x00c0, 0x1db9, 0x0078,
+	0x1d66, 0x1078, 0x1fc7, 0x00c0, 0x1dca, 0x6104, 0xa18c, 0x00ff,
+	0xa186, 0x0007, 0x0040, 0x1f84, 0xa186, 0x000f, 0x0040, 0x1f84,
+	0x1078, 0x1feb, 0x007c, 0x78dc, 0xa084, 0x0100, 0x0040, 0x1dd2,
+	0x0078, 0x1d66, 0x78df, 0x0000, 0x6714, 0x2011, 0x0001, 0x20a9,
+	0x0001, 0x6018, 0xa084, 0x00ff, 0xa005, 0x0040, 0x1df5, 0x2011,
+	0x0001, 0xa7bc, 0xff00, 0x20a9, 0x0020, 0xa08e, 0x0001, 0x0040,
+	0x1df5, 0x2039, 0x0000, 0x2011, 0x0002, 0x20a9, 0x0100, 0xa08e,
+	0x0002, 0x0040, 0x1df5, 0x0078, 0x1e10, 0x1078, 0x1973, 0x2091,
+	0x8000, 0x682b, 0x0000, 0x682f, 0x0000, 0x6808, 0xa084, 0xffde,
+	0x680a, 0xade8, 0x0010, 0x2091, 0x8001, 0x0070, 0x1e09, 0x0078,
+	0x1df7, 0x8211, 0x0040, 0x1e10, 0x20a9, 0x0100, 0x0078, 0x1df7,
+	0x1078, 0x1948, 0x007c, 0x2001, 0x5167, 0x2004, 0xa084, 0x8000,
+	0x0040, 0x1fac, 0x6114, 0x1078, 0x20e3, 0x6900, 0xa184, 0x0001,
+	0x0040, 0x1e34, 0x6028, 0xa084, 0x00ff, 0x00c0, 0x1fa4, 0x6800,
+	0xa084, 0x0001, 0x0040, 0x1fac, 0x6803, 0x0000, 0x680b, 0x0000,
+	0x6807, 0x0000, 0x0078, 0x1fb4, 0x2011, 0x0001, 0x6020, 0xd0f4,
+	0x0040, 0x1e3c, 0xa295, 0x0002, 0xd0c4, 0x0040, 0x1e41, 0xa295,
+	0x0008, 0xd0cc, 0x0040, 0x1e46, 0xa295, 0x0400, 0x601c, 0xa084,
+	0x0002, 0x0040, 0x1e4d, 0xa295, 0x0004, 0x602c, 0xa08c, 0x00ff,
+	0xa182, 0x0002, 0x0048, 0x1fb0, 0xa182, 0x001b, 0x00c8, 0x1fb0,
+	0x0040, 0x1fb0, 0x690e, 0x602c, 0x8007, 0xa08c, 0x00ff, 0xa182,
+	0x0002, 0x0048, 0x1fb0, 0xa182, 0x001b, 0x00c8, 0x1fb0, 0x0040,
+	0x1fb0, 0x6912, 0x6030, 0xa005, 0x00c0, 0x1e70, 0x2001, 0x001e,
+	0x8000, 0x6816, 0x6028, 0xa084, 0x00ff, 0x0040, 0x1fac, 0x6806,
+	0x6028, 0x8007, 0xa084, 0x00ff, 0x0040, 0x1fac, 0x680a, 0x6a02,
+	0x0078, 0x1fb4, 0x2001, 0x5167, 0x2004, 0xa084, 0x8000, 0x0040,
+	0x1fac, 0x6114, 0x1078, 0x20e3, 0x2091, 0x8000, 0x6a04, 0x6b08,
+	0x6418, 0xa484, 0x0003, 0x0040, 0x1ea8, 0x6128, 0xa18c, 0x00ff,
+	0x8001, 0x00c0, 0x1ea1, 0x2100, 0xa210, 0x0048, 0x1ece, 0x0078,
+	0x1ea8, 0x8001, 0x00c0, 0x1ece, 0x2100, 0xa212, 0x0048, 0x1ece,
+	0xa484, 0x000c, 0x0040, 0x1ec2, 0x6128, 0x810f, 0xa18c, 0x00ff,
+	0xa082, 0x0004, 0x00c0, 0x1eba, 0x2100, 0xa318, 0x0048, 0x1ece,
+	0x0078, 0x1ec2, 0xa082, 0x0004, 0x00c0, 0x1ece, 0x2100, 0xa31a,
+	0x0048, 0x1ece, 0x6030, 0xa005, 0x0040, 0x1ec8, 0x8000, 0x6816,
+	0x6a06, 0x6b0a, 0x2091, 0x8001, 0x0078, 0x1fb4, 0x2091, 0x8001,
+	0x0078, 0x1fb0, 0x6114, 0x1078, 0x20e3, 0x2091, 0x8000, 0x6b08,
+	0x8318, 0x0048, 0x1ee0, 0x6b0a, 0x2091, 0x8001, 0x0078, 0x1fc3,
+	0x2091, 0x8001, 0x0078, 0x1fb0, 0x6024, 0x8007, 0xa084, 0x00ff,
+	0x0040, 0x1f02, 0xa086, 0x0080, 0x00c0, 0x1f2a, 0x20a9, 0x0008,
+	0x2069, 0x7510, 0x2091, 0x8000, 0x6800, 0xa084, 0xfcff, 0x6802,
+	0xade8, 0x0008, 0x0070, 0x1efe, 0x0078, 0x1ef4, 0x2091, 0x8001,
+	0x0078, 0x1fb4, 0x6028, 0xa015, 0x0040, 0x1f2a, 0x6114, 0x1078,
+	0x20e3, 0x0d7e, 0xade8, 0x0007, 0x2091, 0x8000, 0x6800, 0xa00d,
+	0x0040, 0x1f27, 0xa206, 0x0040, 0x1f18, 0x2168, 0x0078, 0x1f0e,
+	0x0c7e, 0x2160, 0x6000, 0x6802, 0x1078, 0x1948, 0x0c7f, 0x0d7f,
+	0x6808, 0x8000, 0x680a, 0x2091, 0x8001, 0x0078, 0x1fc3, 0x2091,
+	0x8001, 0x0d7f, 0x0078, 0x1fac, 0x6114, 0x1078, 0x20e3, 0x6800,
+	0xa084, 0x0001, 0x0040, 0x1f9c, 0x2091, 0x8000, 0x6a04, 0x8210,
+	0x0048, 0x1f3f, 0x6a06, 0x2091, 0x8001, 0x0078, 0x1fc3, 0x2091,
+	0x8001, 0x0078, 0x1fb0, 0x1078, 0x1b53, 0x00c0, 0x1d66, 0x6114,
+	0x1078, 0x20e3, 0x60be, 0x60bb, 0x0000, 0x6900, 0xa184, 0x0008,
+	0x0040, 0x1f56, 0x6020, 0xa085, 0x0100, 0x6022, 0xa184, 0x0001,
+	0x0040, 0x1fac, 0xa184, 0x0100, 0x00c0, 0x1f98, 0xa184, 0x0200,
+	0x00c0, 0x1f94, 0x681c, 0xa005, 0x00c0, 0x1fa0, 0x6004, 0xa084,
+	0x00ff, 0xa086, 0x000f, 0x00c0, 0x1f6f, 0x1078, 0x20c6, 0x78df,
+	0x0000, 0x6004, 0x8007, 0xa084, 0x00ff, 0x78d2, 0x8001, 0x609f,
+	0x0000, 0x0040, 0x1f84, 0x1078, 0x1fc7, 0x0040, 0x1f84, 0x78dc,
+	0xa085, 0x0100, 0x78de, 0x007c, 0x78d7, 0x0000, 0x78db, 0x0000,
+	0x6024, 0xa084, 0xff00, 0x6026, 0x1078, 0x39de, 0x0040, 0x1ce3,
+	0x1078, 0x1b78, 0x0078, 0x1ce3, 0x2009, 0x0017, 0x0078, 0x1fb6,
+	0x2009, 0x000e, 0x0078, 0x1fb6, 0x2009, 0x0007, 0x0078, 0x1fb6,
+	0x2009, 0x0035, 0x0078, 0x1fb6, 0x2009, 0x003e, 0x0078, 0x1fb6,
+	0x2009, 0x0004, 0x0078, 0x1fb6, 0x2009, 0x0006, 0x0078, 0x1fb6,
+	0x2009, 0x0016, 0x0078, 0x1fb6, 0x2009, 0x0001, 0x6024, 0xa084,
+	0xff00, 0xa105, 0x6026, 0x2091, 0x8000, 0x1078, 0x1c5f, 0x2091,
+	0x8001, 0x0078, 0x1ce3, 0x1078, 0x1948, 0x0078, 0x1ce3, 0x78d4,
+	0xa06d, 0x00c0, 0x1fd2, 0x2c00, 0x78d6, 0x78da, 0x609f, 0x0000,
+	0x0078, 0x1fde, 0x2c00, 0x689e, 0x609f, 0x0000, 0x78d6, 0x2d00,
+	0x6002, 0x78d8, 0xad06, 0x00c0, 0x1fde, 0x6002, 0x78d0, 0x8001,
+	0x78d2, 0x00c0, 0x1fea, 0x78dc, 0xa084, 0xfeff, 0x78de, 0x78d8,
+	0x2060, 0xa006, 0x007c, 0xa02e, 0x2530, 0x611c, 0x61a2, 0xa184,
+	0xe1ff, 0x601e, 0xa184, 0x0060, 0x0040, 0x1ffa, 0x0e7e, 0x1078,
+	0x47c2, 0x0e7f, 0x6596, 0x65a6, 0x669a, 0x66aa, 0x60af, 0x0000,
+	0x60b3, 0x0000, 0x6714, 0x1078, 0x1973, 0x2091, 0x8000, 0x60a0,
+	0xa084, 0x8000, 0x00c0, 0x2021, 0x6808, 0xa084, 0x0001, 0x0040,
+	0x2021, 0x2091, 0x8001, 0x1078, 0x19c0, 0x2091, 0x8000, 0x1078,
+	0x1c5f, 0x2091, 0x8001, 0x78d7, 0x0000, 0x78db, 0x0000, 0x0078,
+	0x2093, 0x6024, 0xa096, 0x0001, 0x00c0, 0x2028, 0x8000, 0x6026,
+	0x6a10, 0x6814, 0x2091, 0x8001, 0xa202, 0x0048, 0x2037, 0x0040,
+	0x2037, 0x2039, 0x0200, 0x1078, 0x2094, 0x0078, 0x2093, 0x2c08,
+	0x2091, 0x8000, 0x60a0, 0xa084, 0x8000, 0x0040, 0x2064, 0x6800,
+	0xa065, 0x0040, 0x2069, 0x6a04, 0x0e7e, 0x2071, 0x5140, 0x7000,
+	0xa084, 0x0001, 0x0040, 0x205e, 0x7048, 0xa206, 0x00c0, 0x205e,
+	0x6b04, 0x231c, 0x2160, 0x6302, 0x2300, 0xa005, 0x00c0, 0x2059,
+	0x6902, 0x2260, 0x6102, 0x0e7f, 0x0078, 0x2070, 0x2160, 0x6202,
+	0x6906, 0x0e7f, 0x0078, 0x2070, 0x6800, 0xa065, 0x0040, 0x2069,
+	0x6102, 0x6902, 0x00c0, 0x206d, 0x6906, 0x2160, 0x6003, 0x0000,
+	0x2160, 0x60a0, 0xa084, 0x8000, 0x0040, 0x207a, 0x6808, 0xa084,
+	0xfffc, 0x680a, 0x6810, 0x8000, 0x6812, 0x2091, 0x8001, 0x6808,
+	0xa08c, 0x0040, 0x0040, 0x2089, 0xa086, 0x0040, 0x680a, 0x1078,
+	0x19d1, 0x2091, 0x8000, 0x1078, 0x21d2, 0x2091, 0x8001, 0x78db,
+	0x0000, 0x78d7, 0x0000, 0x007c, 0x6008, 0xa705, 0x600a, 0x2091,
+	0x8000, 0x1078, 0x1c5f, 0x2091, 0x8001, 0x78d8, 0xa065, 0x0040,
+	0x20a7, 0x609c, 0x78da, 0x609f, 0x0000, 0x0078, 0x2097, 0x78d7,
+	0x0000, 0x78db, 0x0000, 0x007c, 0x7990, 0x7894, 0x8000, 0xa10a,
+	0x00c8, 0x20b3, 0xa006, 0x7896, 0x70d2, 0x7804, 0xa005, 0x0040,
+	0x20c1, 0x8001, 0x7806, 0x00c0, 0x20c1, 0x0068, 0x20c1, 0x2091,
+	0x4080, 0x007c, 0x2039, 0x20da, 0x0078, 0x20c8, 0x2039, 0x20e0,
+	0x2704, 0xa005, 0x0040, 0x20d9, 0xac00, 0x2068, 0x6b08, 0x6c0c,
+	0x6910, 0x6a14, 0x690a, 0x6a0e, 0x6b12, 0x6c16, 0x8738, 0x0078,
+	0x20c8, 0x007c, 0x0003, 0x0009, 0x000f, 0x0015, 0x001b, 0x0000,
+	0x0015, 0x001b, 0x0000, 0x0c7e, 0x1078, 0x3b69, 0x2c68, 0x0c7f,
+	0x007c, 0x0010, 0x215a, 0x0068, 0x215a, 0x2029, 0x0000, 0x78cb,
+	0x0000, 0x788c, 0xa065, 0x0040, 0x2153, 0x2009, 0x5174, 0x2104,
+	0xa084, 0x0001, 0x0040, 0x2121, 0x6004, 0xa086, 0x0103, 0x00c0,
+	0x2121, 0x6018, 0xa005, 0x00c0, 0x2121, 0x6014, 0xa005, 0x00c0,
+	0x2121, 0x0d7e, 0x2069, 0x0000, 0x6818, 0xa084, 0x0001, 0x00c0,
+	0x2120, 0x600c, 0x70c6, 0x6010, 0x70ca, 0x70c3, 0x8020, 0x681b,
+	0x0001, 0x2091, 0x4080, 0x0d7f, 0x1078, 0x1c86, 0x0078, 0x2158,
+	0x0d7f, 0x1078, 0x215b, 0x0040, 0x2153, 0x6204, 0xa294, 0x00ff,
+	0xa296, 0x0003, 0x0040, 0x2133, 0x6204, 0xa296, 0x0110, 0x00c0,
+	0x2141, 0x78cb, 0x0001, 0x6204, 0xa294, 0xff00, 0x8217, 0x8211,
+	0x0040, 0x2141, 0x85ff, 0x00c0, 0x2153, 0x8210, 0xa202, 0x00c8,
+	0x2153, 0x057e, 0x1078, 0x216a, 0x057f, 0x0040, 0x214e, 0x78e0,
+	0xa086, 0x0003, 0x0040, 0x2153, 0x0078, 0x2141, 0x8528, 0x78c8,
+	0xa005, 0x0040, 0x20f1, 0x85ff, 0x0040, 0x215a, 0x2091, 0x4080,
+	0x78b0, 0x70d6, 0x007c, 0x7bac, 0x79b0, 0x70d4, 0xa102, 0x00c0,
+	0x2164, 0x2300, 0xa005, 0x007c, 0x0048, 0x2168, 0xa302, 0x007c,
+	0x8002, 0x007c, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005, 0x00c8,
+	0x2184, 0x2091, 0x8000, 0x2071, 0x0020, 0x7004, 0xa005, 0x00c0,
+	0x21b9, 0x7008, 0x7208, 0xa206, 0x00c0, 0x21b9, 0xa286, 0x0008,
+	0x00c0, 0x21b9, 0x2071, 0x0010, 0x1078, 0x21be, 0x2009, 0x0020,
+	0x6004, 0xa086, 0x0103, 0x00c0, 0x2193, 0x6028, 0xa005, 0x00c0,
+	0x2193, 0x2009, 0x000c, 0x1078, 0x1924, 0x0040, 0x21ac, 0x78c4,
+	0x8000, 0x78c6, 0xa086, 0x0002, 0x00c0, 0x21b9, 0x2091, 0x8000,
+	0x78e3, 0x0003, 0x78c7, 0x0000, 0x78cc, 0xa085, 0x0300, 0x78ce,
+	0x2091, 0x8001, 0x0078, 0x21b9, 0x78c7, 0x0000, 0x1078, 0x1c86,
+	0x79ac, 0x78b0, 0x8000, 0xa10a, 0x00c8, 0x21b7, 0xa006, 0x78b2,
+	0xa006, 0x2071, 0x0010, 0x2091, 0x8001, 0x007c, 0x8107, 0x8004,
+	0x8004, 0x7ab8, 0x7bb4, 0x7cc0, 0x7dbc, 0xa210, 0xa399, 0x0000,
+	0xa4a1, 0x0000, 0xa5a9, 0x0000, 0x007c, 0x2009, 0x515b, 0x2091,
+	0x8000, 0x200a, 0x0f7e, 0x0e7e, 0x2071, 0x5140, 0x7000, 0xa086,
+	0x0000, 0x00c0, 0x21ec, 0x2009, 0x5112, 0x2104, 0xa005, 0x00c0,
+	0x21ec, 0x2079, 0x0100, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x21ec,
+	0x0018, 0x21ec, 0x781b, 0x004b, 0x0e7f, 0x0f7f, 0x007c, 0x0f7e,
+	0x0e7e, 0x2071, 0x5140, 0x2091, 0x8000, 0x7000, 0xa086, 0x0000,
+	0x00c0, 0x2205, 0x2079, 0x0100, 0x7830, 0xa084, 0x00c0, 0x00c0,
+	0x2205, 0x0018, 0x2205, 0x781b, 0x004d, 0x2091, 0x8001, 0x0e7f,
+	0x0f7f, 0x007c, 0x127e, 0x2091, 0x2300, 0x2071, 0x5140, 0x2079,
+	0x0100, 0x784b, 0x000f, 0x0098, 0x2218, 0x7838, 0x0078, 0x2211,
+	0x20a9, 0x0040, 0x7800, 0xa082, 0x0004, 0x0048, 0x2221, 0x20a9,
+	0x0060, 0x789b, 0x0000, 0x78af, 0x0000, 0x78af, 0x0000, 0x0070,
+	0x222b, 0x0078, 0x2223, 0x7800, 0xa082, 0x0004, 0x0048, 0x223a,
+	0x70b7, 0x0096, 0x2019, 0x4ee7, 0x1078, 0x2276, 0x702f, 0x8001,
+	0x0078, 0x2246, 0x70b7, 0x0000, 0x2019, 0x4d5f, 0x1078, 0x2276,
+	0x2019, 0x4d9e, 0x1078, 0x2276, 0x702f, 0x8000, 0x7003, 0x0000,
+	0x1078, 0x237f, 0x7004, 0xa084, 0x000f, 0x017e, 0x2009, 0x04fd,
+	0x210c, 0xa18a, 0x0005, 0x0048, 0x225b, 0x0038, 0x2261, 0xa085,
+	0x6280, 0x0078, 0x2263, 0x0028, 0x2261, 0xa085, 0x6280, 0x0078,
+	0x2263, 0xa085, 0x62c0, 0x017f, 0x7806, 0x780f, 0xb204, 0x7843,
+	0x00d8, 0x7853, 0x0080, 0x780b, 0x0008, 0x7047, 0x0008, 0x7053,
+	0x517f, 0x704f, 0x0000, 0x127f, 0x2000, 0x007c, 0x137e, 0x147e,
+	0x157e, 0x047e, 0x20a1, 0x012b, 0x2304, 0xa005, 0x789a, 0x0040,
+	0x2296, 0x8318, 0x2324, 0x8318, 0x2398, 0x24a8, 0xa484, 0xff00,
+	0x0040, 0x228e, 0xa482, 0x0100, 0x20a9, 0x0100, 0x2020, 0x53a6,
+	0xa005, 0x00c0, 0x2285, 0x3318, 0x0078, 0x227c, 0x047f, 0x157f,
+	0x147f, 0x137f, 0x007c, 0xa18c, 0x000f, 0x2011, 0x0101, 0x2204,
+	0xa084, 0xfff0, 0xa105, 0x2012, 0x1078, 0x237f, 0x007c, 0x2011,
+	0x0101, 0x20a9, 0x0009, 0x810b, 0x0070, 0x22b0, 0x0078, 0x22ab,
+	0xa18c, 0x0e00, 0x2204, 0xa084, 0xf1ff, 0xa105, 0x2012, 0x007c,
+	0x2009, 0x0101, 0x20a9, 0x0005, 0x8213, 0x0070, 0x22c1, 0x0078,
+	0x22bc, 0xa294, 0x00e0, 0x2104, 0xa084, 0xff1f, 0xa205, 0x200a,
+	0x007c, 0x2011, 0x0101, 0x20a9, 0x000c, 0x810b, 0x0070, 0x22d2,
+	0x0078, 0x22cd, 0xa18c, 0xf000, 0x2204, 0xa084, 0x0fff, 0xa105,
+	0x2012, 0x007c, 0x2011, 0x0102, 0x2204, 0xa084, 0xffcf, 0xa105,
+	0x2012, 0x007c, 0x8103, 0x8003, 0xa080, 0x0020, 0x0c7e, 0x2061,
+	0x0100, 0x609a, 0x62ac, 0x63ac, 0x0c7f, 0x007c, 0x8103, 0x8003,
+	0xa080, 0x0022, 0x0c7e, 0x2061, 0x0100, 0x609a, 0x60a4, 0xa084,
+	0xffdf, 0x60ae, 0x0c7f, 0x007c, 0x8103, 0x8003, 0xa080, 0x0022,
+	0x0c7e, 0x2061, 0x0100, 0x609a, 0x60a4, 0xa085, 0x0020, 0x60ae,
+	0x0c7f, 0x007c, 0x8103, 0x8003, 0xa080, 0x0020, 0x0c7e, 0x2061,
+	0x0100, 0x609a, 0x60a4, 0x62ae, 0x2010, 0x60a4, 0x63ae, 0x2018,
+	0x0c7f, 0x007c, 0x2091, 0x8000, 0x0c7e, 0x0e7e, 0x6818, 0xa005,
+	0x0040, 0x235d, 0x2061, 0x7500, 0x1078, 0x2365, 0x0040, 0x2349,
+	0x20a9, 0x0000, 0x2061, 0x7400, 0x0c7e, 0x1078, 0x2365, 0x0040,
+	0x2339, 0x0c7f, 0x8c60, 0x0070, 0x2337, 0x0078, 0x232c, 0x0078,
+	0x235d, 0x007f, 0xa082, 0x7400, 0x2071, 0x5140, 0x7086, 0x7182,
+	0x2001, 0x0004, 0x706e, 0x7093, 0x000f, 0x1078, 0x21cd, 0x0078,
+	0x2359, 0x60c0, 0xa005, 0x00c0, 0x235d, 0x2071, 0x5140, 0x7182,
+	0x2c00, 0x708a, 0x2001, 0x0006, 0x706e, 0x7093, 0x000f, 0x1078,
+	0x21cd, 0x2001, 0x0000, 0x0078, 0x235f, 0x2001, 0x0001, 0x2091,
+	0x8001, 0xa005, 0x0e7f, 0x0c7f, 0x007c, 0x2c04, 0xa005, 0x0040,
+	0x237c, 0x2060, 0x600c, 0xa306, 0x00c0, 0x2379, 0x6010, 0xa206,
+	0x00c0, 0x2379, 0x6014, 0xa106, 0x00c0, 0x2379, 0xa006, 0x0078,
+	0x237e, 0x6000, 0x0078, 0x2366, 0xa085, 0x0001, 0x007c, 0x2011,
+	0x5141, 0x220c, 0xa18c, 0x000f, 0x2011, 0x013b, 0x2204, 0xa084,
+	0x0100, 0x0040, 0x2395, 0x2021, 0xff04, 0x2122, 0x810b, 0x810b,
+	0x810b, 0x810b, 0xa18d, 0x0f00, 0x2104, 0x007c, 0x0e7e, 0x68e4,
+	0xa08c, 0x0020, 0x0040, 0x23e9, 0xa084, 0x0006, 0x00c0, 0x23e9,
+	0x6014, 0x8007, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0f0,
+	0x5380, 0x7004, 0xa084, 0x000a, 0x00c0, 0x23e9, 0x7108, 0xa194,
+	0xff00, 0x0040, 0x23e9, 0xa18c, 0x00ff, 0x2001, 0x000c, 0xa106,
+	0x0040, 0x23d0, 0x2001, 0x0012, 0xa106, 0x0040, 0x23d4, 0x2001,
+	0x0014, 0xa106, 0x0040, 0x23d8, 0x2001, 0x0019, 0xa106, 0x0040,
+	0x23dc, 0x2001, 0x0032, 0xa106, 0x0040, 0x23e0, 0x0078, 0x23e4,
+	0x2009, 0x0012, 0x0078, 0x23e6, 0x2009, 0x0014, 0x0078, 0x23e6,
+	0x2009, 0x0019, 0x0078, 0x23e6, 0x2009, 0x0020, 0x0078, 0x23e6,
+	0x2009, 0x003f, 0x0078, 0x23e6, 0x2011, 0x0000, 0x2100, 0xa205,
+	0x700a, 0x0e7f, 0x007c, 0x0068, 0x23eb, 0x2091, 0x8000, 0x2071,
+	0x0000, 0x007e, 0x7018, 0xa084, 0x0001, 0x00c0, 0x23f2, 0x007f,
+	0x2071, 0x0010, 0x70ca, 0x007f, 0x70c6, 0x70c3, 0x8002, 0x70db,
+	0x0741, 0x70df, 0x0000, 0x2071, 0x0000, 0x701b, 0x0001, 0x2091,
+	0x4080, 0x0078, 0x2409, 0x107e, 0x007e, 0x127e, 0x2091, 0x2300,
+	0x7f3c, 0x7e58, 0x7c30, 0x7d38, 0x77c2, 0x74c6, 0x76ca, 0x75ce,
+	0xa594, 0x003f, 0xa49c, 0x0003, 0xa484, 0x000f, 0x0079, 0x2420,
+	0x2432, 0x2432, 0x2432, 0x276c, 0x393b, 0x2430, 0x2461, 0x246b,
+	0x2430, 0x2430, 0x2430, 0x2430, 0x2430, 0x2430, 0x2430, 0x2430,
+	0x1078, 0x23eb, 0x8507, 0xa084, 0x001f, 0x0079, 0x2437, 0x2475,
+	0x276c, 0x2926, 0x2a23, 0x2a4b, 0x2ced, 0x2f98, 0x2fdb, 0x3026,
+	0x30ab, 0x3163, 0x320c, 0x2461, 0x2848, 0x2f6d, 0x2457, 0x3cc8,
+	0x3ce8, 0x3eae, 0x3eba, 0x3f8f, 0x2457, 0x2457, 0x4062, 0x4066,
+	0x3cc6, 0x2457, 0x3e19, 0x2457, 0x3b8c, 0x246b, 0x2457, 0x1078,
+	0x23eb, 0x0018, 0x2410, 0x127f, 0x2091, 0x8001, 0x007f, 0x107f,
+	0x007c, 0x2019, 0x4e3b, 0x1078, 0x2276, 0x702f, 0x0001, 0x781b,
+	0x004f, 0x0078, 0x2459, 0x2019, 0x4d9e, 0x1078, 0x2276, 0x702f,
+	0x8000, 0x781b, 0x00d0, 0x0078, 0x2459, 0x7242, 0x2009, 0x510f,
+	0x200b, 0x0000, 0xa584, 0x0001, 0x00c0, 0x3ba0, 0x0040, 0x2492,
+	0x1078, 0x23eb, 0x7003, 0x0000, 0x704b, 0x0000, 0x7043, 0x0000,
+	0x7037, 0x0000, 0x1078, 0x3912, 0x0018, 0x2410, 0x2009, 0x510f,
+	0x200b, 0x0000, 0x7068, 0xa005, 0x00c0, 0x255d, 0x706c, 0xa084,
+	0x0007, 0x0079, 0x249b, 0x2594, 0x24a3, 0x24af, 0x24cc, 0x24ee,
+	0x253b, 0x2514, 0x24a3, 0x1078, 0x38fa, 0x2009, 0x0048, 0x1078,
+	0x2e39, 0x00c0, 0x24ad, 0x7003, 0x0004, 0x0078, 0x2459, 0x1078,
+	0x38fa, 0x00c0, 0x24ca, 0x7080, 0x8007, 0x7882, 0x789b, 0x0010,
+	0x78ab, 0x000c, 0x789b, 0x0060, 0x78ab, 0x0001, 0x785b, 0x0004,
+	0x2009, 0x00e0, 0x1078, 0x2e2d, 0x00c0, 0x24ca, 0x7003, 0x0004,
+	0x7093, 0x000f, 0x0078, 0x2459, 0x1078, 0x38fa, 0x00c0, 0x24ec,
+	0x7180, 0x8107, 0x7882, 0x789b, 0x0010, 0xa18c, 0x001f, 0xa18d,
+	0x00c0, 0x79aa, 0x78ab, 0x0006, 0x789b, 0x0060, 0x78ab, 0x0002,
+	0x785b, 0x0004, 0x2009, 0x00e0, 0x1078, 0x2e2d, 0x00c0, 0x24ec,
+	0x7003, 0x0004, 0x7093, 0x000f, 0x0078, 0x2459, 0x1078, 0x38fa,
+	0x00c0, 0x2512, 0x7180, 0x8107, 0x7882, 0x789b, 0x0010, 0xa18c,
+	0x001f, 0xa18d, 0x00c0, 0x79aa, 0x78ab, 0x0020, 0x7184, 0x79aa,
+	0x78ab, 0x000d, 0x789b, 0x0060, 0x78ab, 0x0004, 0x785b, 0x0004,
+	0x2009, 0x00e0, 0x1078, 0x2e2d, 0x00c0, 0x2512, 0x7003, 0x0004,
+	0x7093, 0x000f, 0x0078, 0x2459, 0x1078, 0x38fa, 0x00c0, 0x2539,
+	0x7180, 0x8107, 0x7882, 0x789b, 0x0010, 0xa18c, 0x001f, 0xa18d,
+	0x00c0, 0x79aa, 0x78ab, 0x0006, 0x789b, 0x0060, 0x78ab, 0x0002,
+	0x785b, 0x0004, 0x2009, 0x00e0, 0x1078, 0x2e2d, 0x00c0, 0x2539,
+	0x7088, 0x708b, 0x0000, 0x2068, 0x704a, 0x7003, 0x0002, 0x7093,
+	0x000f, 0x0078, 0x2459, 0x1078, 0x38fa, 0x00c0, 0x2459, 0x7088,
+	0x2068, 0x6f14, 0x1078, 0x37ef, 0x2c50, 0x1078, 0x39ac, 0x789b,
+	0x0010, 0x6814, 0xa084, 0x001f, 0xa085, 0x0080, 0x78aa, 0x6e1c,
+	0x2041, 0x0001, 0x708c, 0xa084, 0x0400, 0x2001, 0x0004, 0x0040,
+	0x255b, 0x2001, 0x0006, 0x0078, 0x267c, 0x1078, 0x38fa, 0x00c0,
+	0x2459, 0x789b, 0x0010, 0x7068, 0x2068, 0x6f14, 0x1078, 0x37ef,
+	0x2c50, 0x1078, 0x39ac, 0x6008, 0xa085, 0x0010, 0x600a, 0x6824,
+	0xa005, 0x0040, 0x257b, 0xa082, 0x0006, 0x0048, 0x2579, 0x0078,
+	0x257b, 0x6827, 0x0005, 0x6b14, 0xa39c, 0x001f, 0xa39d, 0x00c0,
+	0x7058, 0xa084, 0x8000, 0x0040, 0x2589, 0xa684, 0x0001, 0x0040,
+	0x258b, 0xa39c, 0xffbf, 0x7baa, 0x2031, 0x0020, 0x2041, 0x0001,
+	0x2001, 0x0003, 0x0078, 0x267c, 0x0018, 0x2410, 0x744c, 0xa485,
+	0x0000, 0x0040, 0x25ae, 0xa080, 0x5180, 0x2030, 0x7150, 0x8108,
+	0xa12a, 0x0048, 0x25a5, 0x2009, 0x5180, 0x2164, 0x6504, 0x85ff,
+	0x00c0, 0x25bf, 0x8421, 0x00c0, 0x259f, 0x7152, 0x7003, 0x0000,
+	0x704b, 0x0000, 0x7040, 0xa005, 0x0040, 0x3ba0, 0x0078, 0x2459,
+	0x764c, 0xa6b0, 0x5180, 0x7150, 0x2600, 0x0078, 0x25aa, 0x7152,
+	0x2568, 0x2558, 0x754a, 0x2c50, 0x6034, 0xa085, 0x0000, 0x00c0,
+	0x25bc, 0x6708, 0x773a, 0xa784, 0x033f, 0x0040, 0x25f5, 0xa784,
+	0x0021, 0x00c0, 0x25bc, 0xa784, 0x0002, 0x0040, 0x25de, 0xa784,
+	0x0004, 0x0040, 0x25bc, 0xa7bc, 0xfffb, 0x670a, 0xa784, 0x0008,
+	0x00c0, 0x25bc, 0xa784, 0x0010, 0x00c0, 0x25bc, 0xa784, 0x0200,
+	0x00c0, 0x25bc, 0xa784, 0x0100, 0x0040, 0x25f5, 0x6018, 0xa005,
+	0x00c0, 0x25bc, 0xa7bc, 0xfeff, 0x670a, 0x6823, 0x0000, 0x6e1c,
+	0xa684, 0x000e, 0x6118, 0x0040, 0x2605, 0x601c, 0xa102, 0x0048,
+	0x2608, 0x0040, 0x2608, 0x0078, 0x25b8, 0x81ff, 0x00c0, 0x25b8,
+	0x68c3, 0x0000, 0xa784, 0x0080, 0x00c0, 0x2610, 0x700c, 0x6022,
+	0xa7bc, 0xff7f, 0x670a, 0x1078, 0x39ac, 0x0018, 0x2410, 0x789b,
+	0x0010, 0xa046, 0x1078, 0x38fa, 0x00c0, 0x2459, 0x6b14, 0xa39c,
+	0x001f, 0xa39d, 0x00c0, 0x7058, 0xa084, 0x8000, 0x0040, 0x262c,
+	0xa684, 0x0001, 0x0040, 0x262e, 0xa39c, 0xffbf, 0xa684, 0x0010,
+	0x0040, 0x2634, 0xa39d, 0x0020, 0x7baa, 0x8840, 0xa684, 0x000e,
+	0x00c0, 0x263f, 0xa7bd, 0x0010, 0x670a, 0x0078, 0x267a, 0x7158,
+	0xa18c, 0x0800, 0x0040, 0x3401, 0x2011, 0x0020, 0xa684, 0x0008,
+	0x00c0, 0x2650, 0x8210, 0xa684, 0x0002, 0x00c0, 0x2650, 0x8210,
+	0x7aaa, 0x8840, 0x1078, 0x3912, 0x6a14, 0x610c, 0x8108, 0xa18c,
+	0x00ff, 0xa1e0, 0x7400, 0x2c64, 0x8cff, 0x0040, 0x2671, 0x6014,
+	0xa206, 0x00c0, 0x265b, 0x60b8, 0x8001, 0x60ba, 0x00c0, 0x2656,
+	0x0c7e, 0x2a60, 0x6008, 0xa085, 0x0100, 0x600a, 0x0c7f, 0x0078,
+	0x2594, 0x1078, 0x38fa, 0x00c0, 0x2459, 0x2a60, 0x610e, 0x79aa,
+	0x8840, 0x7132, 0x2001, 0x0001, 0x007e, 0x715c, 0xa184, 0x0018,
+	0x0040, 0x2697, 0xa184, 0x0010, 0x0040, 0x268a, 0x1078, 0x3604,
+	0x00c0, 0x26ba, 0xa184, 0x0008, 0x0040, 0x2697, 0x69a0, 0xa184,
+	0x0600, 0x00c0, 0x2697, 0x1078, 0x34f1, 0x0078, 0x26ba, 0x69a0,
+	0xa184, 0x0800, 0x0040, 0x26ae, 0x0c7e, 0x027e, 0x2960, 0x6000,
+	0xa085, 0x2000, 0x6002, 0x6104, 0xa18d, 0x0010, 0x6106, 0x027f,
+	0x0c7f, 0x1078, 0x3604, 0x00c0, 0x26ba, 0x69a0, 0xa184, 0x0200,
+	0x0040, 0x26b6, 0x1078, 0x3540, 0x0078, 0x26ba, 0xa184, 0x0400,
+	0x00c0, 0x2693, 0x69a0, 0xa184, 0x1000, 0x0040, 0x26c5, 0x6914,
+	0xa18c, 0xff00, 0x810f, 0x1078, 0x22ee, 0x007f, 0x7002, 0xa68c,
+	0x00e0, 0xa684, 0x0060, 0x0040, 0x26d3, 0xa086, 0x0060, 0x00c0,
+	0x26d3, 0xa18d, 0x4000, 0x88ff, 0x0040, 0x26d8, 0xa18d, 0x0004,
+	0x795a, 0x69b6, 0x789b, 0x0060, 0x2800, 0x78aa, 0x789b, 0x0061,
+	0x6818, 0xa08d, 0x8000, 0xa084, 0x7fff, 0x691a, 0xa68c, 0x0080,
+	0x0040, 0x26f7, 0x7097, 0x0000, 0xa08a, 0x000d, 0x0050, 0x26f5,
+	0xa08a, 0x000c, 0x7196, 0x2001, 0x000c, 0x800c, 0x719a, 0x78aa,
+	0x8008, 0x810c, 0x0040, 0x3407, 0xa18c, 0x00f8, 0x00c0, 0x3407,
+	0x157e, 0x137e, 0x147e, 0x20a1, 0x012b, 0x789b, 0x0000, 0x8000,
+	0x80ac, 0xad80, 0x000b, 0x2098, 0x53a6, 0x147f, 0x137f, 0x157f,
+	0x6814, 0x8007, 0x7882, 0x6d94, 0x7dd6, 0x7dde, 0x6e98, 0x7ed2,
+	0x7eda, 0x1078, 0x38fa, 0x00c0, 0x272e, 0x702c, 0x8003, 0x0048,
+	0x2727, 0x2019, 0x4d9e, 0x1078, 0x2276, 0x702f, 0x8000, 0x7830,
+	0xa084, 0x00c0, 0x00c0, 0x272e, 0x0098, 0x2736, 0x6008, 0xa084,
+	0xffef, 0x600a, 0x1078, 0x3912, 0x0078, 0x2482, 0x7200, 0xa284,
+	0x0007, 0xa086, 0x0001, 0x00c0, 0x2743, 0x781b, 0x004f, 0x1078,
+	0x3912, 0x0078, 0x2754, 0x6ab4, 0xa295, 0x2000, 0x7a5a, 0x781b,
+	0x004f, 0x1078, 0x3912, 0x7200, 0x2500, 0xa605, 0x0040, 0x2754,
+	0xa284, 0x0007, 0x1079, 0x2762, 0xad80, 0x0009, 0x7036, 0xa284,
+	0x0007, 0xa086, 0x0001, 0x00c0, 0x2459, 0x6018, 0x8000, 0x601a,
+	0x0078, 0x2459, 0x276a, 0x4a3a, 0x4a3a, 0x4a29, 0x4a3a, 0x276a,
+	0x4a29, 0x276a, 0x1078, 0x23eb, 0x1078, 0x38fa, 0x0f7e, 0x2079,
+	0x5100, 0x78cc, 0x0f7f, 0xa084, 0x0001, 0x0040, 0x2790, 0x706c,
+	0xa086, 0x0001, 0x00c0, 0x277f, 0x706e, 0x0078, 0x2823, 0x706c,
+	0xa086, 0x0005, 0x00c0, 0x278e, 0x7088, 0x2068, 0x681b, 0x0004,
+	0x6817, 0x0000, 0x6820, 0xa085, 0x0008, 0x6822, 0x706f, 0x0000,
+	0x2011, 0x0004, 0x716c, 0xa186, 0x0001, 0x0040, 0x27b1, 0xa186,
+	0x0007, 0x00c0, 0x27a1, 0x2009, 0x5138, 0x200b, 0x0005, 0x0078,
+	0x27b1, 0x2009, 0x5113, 0x2104, 0x2009, 0x5112, 0x200a, 0x2009,
+	0x5138, 0x200b, 0x0001, 0x706f, 0x0000, 0x7073, 0x0001, 0x0078,
+	0x27b3, 0x706f, 0x0000, 0x1078, 0x4776, 0x157e, 0x20a9, 0x0010,
+	0x2039, 0x0000, 0x1078, 0x36e2, 0xa7b8, 0x0100, 0x0070, 0x27c2,
+	0x0078, 0x27ba, 0x157f, 0x7000, 0x0079, 0x27c6, 0x27f4, 0x27db,
+	0x27db, 0x27ce, 0x27f4, 0x27f4, 0x27f4, 0x27f4, 0x2021, 0x515a,
+	0x2404, 0xa005, 0x0040, 0x27f4, 0xad06, 0x00c0, 0x27db, 0x6800,
+	0x2022, 0x0078, 0x27eb, 0x6820, 0xa084, 0x0001, 0x00c0, 0x27e7,
+	0x6f14, 0x1078, 0x37ef, 0x1078, 0x33d8, 0x0078, 0x27eb, 0x7060,
+	0x2060, 0x6800, 0x6002, 0x6a1a, 0x6817, 0x0000, 0x6820, 0xa085,
+	0x0008, 0x6822, 0x1078, 0x1c70, 0x2021, 0x7500, 0x1078, 0x2830,
+	0x2021, 0x515a, 0x1078, 0x2830, 0x157e, 0x20a9, 0x0000, 0x2021,
+	0x7400, 0x1078, 0x2830, 0x8420, 0x0070, 0x2808, 0x0078, 0x2801,
+	0x2061, 0x5400, 0x2021, 0x0002, 0x20a9, 0x0100, 0x6018, 0x6110,
+	0x81ff, 0x0040, 0x2817, 0xa102, 0x0050, 0x2817, 0x6012, 0x601b,
+	0x0000, 0xace0, 0x0010, 0x0070, 0x281f, 0x0078, 0x280e, 0x8421,
+	0x00c0, 0x280c, 0x157f, 0x709c, 0xa084, 0x8000, 0x0040, 0x282a,
+	0x1078, 0x3a00, 0x7003, 0x0000, 0x704b, 0x0000, 0x0078, 0x2459,
+	0x047e, 0x2404, 0xa005, 0x0040, 0x2844, 0x2068, 0x6800, 0x007e,
+	0x6a1a, 0x6817, 0x0000, 0x6820, 0xa085, 0x0008, 0x6822, 0x1078,
+	0x1c70, 0x007f, 0x0078, 0x2832, 0x047f, 0x2023, 0x0000, 0x007c,
+	0xa282, 0x0003, 0x0050, 0x284e, 0x1078, 0x23eb, 0x2300, 0x0079,
+	0x2851, 0x2854, 0x28c7, 0x28e4, 0xa282, 0x0002, 0x0040, 0x285a,
+	0x1078, 0x23eb, 0x706c, 0x706f, 0x0000, 0x7093, 0x0000, 0x0079,
+	0x2861, 0x2869, 0x2869, 0x286b, 0x289f, 0x340d, 0x2869, 0x289f,
+	0x2869, 0x1078, 0x23eb, 0x7780, 0x1078, 0x36e2, 0x7780, 0xa7bc,
+	0x0f00, 0x1078, 0x37ef, 0x6018, 0xa005, 0x0040, 0x2896, 0x2021,
+	0x7500, 0x2009, 0x0004, 0x2011, 0x0010, 0x1078, 0x28ff, 0x0040,
+	0x2896, 0x157e, 0x20a9, 0x0000, 0x2021, 0x7400, 0x047e, 0x2009,
+	0x0004, 0x2011, 0x0010, 0x1078, 0x28ff, 0x047f, 0x0040, 0x2895,
+	0x8420, 0x0070, 0x2895, 0x0078, 0x2886, 0x157f, 0x8738, 0xa784,
+	0x001f, 0x00c0, 0x2871, 0x0078, 0x2482, 0x0078, 0x2482, 0x7780,
+	0x1078, 0x37ef, 0x6018, 0xa005, 0x0040, 0x28c5, 0x2021, 0x7500,
+	0x2009, 0x0005, 0x2011, 0x0020, 0x1078, 0x28ff, 0x0040, 0x28c5,
+	0x157e, 0x20a9, 0x0000, 0x2021, 0x7400, 0x047e, 0x2009, 0x0005,
+	0x2011, 0x0020, 0x1078, 0x28ff, 0x047f, 0x0040, 0x28c4, 0x8420,
+	0x0070, 0x28c4, 0x0078, 0x28b5, 0x157f, 0x0078, 0x2482, 0x2200,
+	0x0079, 0x28ca, 0x28cd, 0x28cf, 0x28cf, 0x1078, 0x23eb, 0x2009,
+	0x0012, 0x706c, 0xa086, 0x0002, 0x0040, 0x28d8, 0x2009, 0x000e,
+	0x6818, 0xa084, 0x8000, 0x0040, 0x28de, 0x691a, 0x706f, 0x0000,
+	0x7073, 0x0001, 0x0078, 0x3888, 0x2200, 0x0079, 0x28e7, 0x28ec,
+	0x28cf, 0x28ea, 0x1078, 0x23eb, 0x1078, 0x4776, 0x7000, 0xa086,
+	0x0001, 0x00c0, 0x339d, 0x1078, 0x33ee, 0x6008, 0xa084, 0xffef,
+	0x600a, 0x1078, 0x3390, 0x0040, 0x339d, 0x0078, 0x2594, 0x2404,
+	0xa005, 0x0040, 0x2922, 0x2068, 0x2d04, 0x007e, 0x6814, 0xa706,
+	0x0040, 0x290e, 0x2d20, 0x007f, 0x0078, 0x2900, 0x007f, 0x2022,
+	0x691a, 0x6817, 0x0000, 0x6820, 0xa205, 0x6822, 0x1078, 0x1c70,
+	0x6010, 0x8001, 0x6012, 0x6008, 0xa084, 0xffef, 0x600a, 0x1078,
+	0x33ee, 0x007c, 0xa085, 0x0001, 0x0078, 0x2921, 0x2300, 0x0079,
+	0x2929, 0x292e, 0x292c, 0x29c7, 0x1078, 0x23eb, 0x78ec, 0xa084,
+	0x0001, 0x00c0, 0x2942, 0x7000, 0xa086, 0x0004, 0x00c0, 0x293a,
+	0x0078, 0x2965, 0x1078, 0x33ee, 0x6008, 0xa084, 0xffef, 0x600a,
+	0x0078, 0x339d, 0x78e4, 0xa005, 0x00d0, 0x2965, 0x0018, 0x2459,
+	0x2008, 0xa084, 0x0030, 0x00c0, 0x2951, 0x781b, 0x004f, 0x0078,
+	0x2459, 0x78ec, 0xa084, 0x0003, 0x0040, 0x294d, 0x2100, 0xa084,
+	0x0007, 0x0079, 0x295b, 0x299e, 0x29a9, 0x298f, 0x2963, 0x38ed,
+	0x38ed, 0x2963, 0x29b8, 0x1078, 0x23eb, 0x7000, 0xa086, 0x0004,
+	0x00c0, 0x297f, 0x706c, 0xa086, 0x0002, 0x00c0, 0x2975, 0x2011,
+	0x0002, 0x2019, 0x0000, 0x0078, 0x2848, 0x706c, 0xa086, 0x0006,
+	0x0040, 0x296f, 0x706c, 0xa086, 0x0004, 0x0040, 0x296f, 0x79e4,
+	0xa184, 0x0030, 0x0040, 0x2989, 0x78ec, 0xa084, 0x0003, 0x00c0,
+	0x298b, 0x0078, 0x2f6d, 0x2001, 0x0003, 0x0078, 0x2d01, 0x6818,
+	0xa084, 0x8000, 0x0040, 0x2996, 0x681b, 0x001d, 0x1078, 0x36c1,
+	0x782b, 0x3008, 0x781b, 0x0056, 0x0078, 0x2459, 0x6818, 0xa084,
+	0x8000, 0x0040, 0x29a5, 0x681b, 0x001d, 0x1078, 0x36c1, 0x0078,
+	0x38b8, 0x6818, 0xa084, 0x8000, 0x0040, 0x29b0, 0x681b, 0x001d,
+	0x1078, 0x36c1, 0x782b, 0x3008, 0x781b, 0x00cd, 0x0078, 0x2459,
+	0x6818, 0xa084, 0x8000, 0x0040, 0x29bf, 0x681b, 0x001d, 0x1078,
+	0x36c1, 0x782b, 0x3008, 0x781b, 0x008e, 0x0078, 0x2459, 0xa584,
+	0x000f, 0x00c0, 0x29e4, 0x7000, 0x0079, 0x29ce, 0x2482, 0x29d8,
+	0x29d6, 0x339d, 0x339d, 0x339d, 0x339d, 0x29d6, 0x1078, 0x23eb,
+	0x1078, 0x33ee, 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x3390,
+	0x0040, 0x339d, 0x0078, 0x2594, 0x78e4, 0xa005, 0x00d0, 0x2965,
+	0x0018, 0x2965, 0x2008, 0xa084, 0x0030, 0x00c0, 0x29f3, 0x781b,
+	0x004f, 0x0078, 0x2459, 0x78ec, 0xa084, 0x0003, 0x0040, 0x29ef,
+	0x2100, 0xa184, 0x0007, 0x0079, 0x29fd, 0x2a0f, 0x2a13, 0x2a07,
+	0x2a05, 0x38ed, 0x38ed, 0x2a05, 0x38e3, 0x1078, 0x23eb, 0x1078,
+	0x36c9, 0x782b, 0x3008, 0x781b, 0x0056, 0x0078, 0x2459, 0x1078,
+	0x36c9, 0x0078, 0x38b8, 0x1078, 0x36c9, 0x782b, 0x3008, 0x781b,
+	0x00cd, 0x0078, 0x2459, 0x1078, 0x36c9, 0x782b, 0x3008, 0x781b,
+	0x008e, 0x0078, 0x2459, 0x2300, 0x0079, 0x2a26, 0x2a2b, 0x2a29,
+	0x2a2d, 0x1078, 0x23eb, 0x0078, 0x30ab, 0x681b, 0x0008, 0x78a3,
+	0x0000, 0x79e4, 0xa184, 0x0030, 0x0040, 0x30ab, 0x78ec, 0xa084,
+	0x0003, 0x0040, 0x30ab, 0xa184, 0x0007, 0x0079, 0x2a3f, 0x2a47,
+	0x2a13, 0x298f, 0x3888, 0x38ed, 0x38ed, 0x2a47, 0x38e3, 0x1078,
+	0x389c, 0x0078, 0x2459, 0xa282, 0x0005, 0x0050, 0x2a51, 0x1078,
+	0x23eb, 0x2300, 0x0079, 0x2a54, 0x2a57, 0x2cae, 0x2cbc, 0x2200,
+	0x0079, 0x2a5a, 0x2a74, 0x2a61, 0x2a74, 0x2a5f, 0x2c93, 0x1078,
+	0x23eb, 0x789b, 0x0018, 0x78a8, 0xa084, 0x00ff, 0xa082, 0x0020,
+	0x0048, 0x369d, 0xa08a, 0x0004, 0x00c8, 0x369d, 0x0079, 0x2a70,
+	0x369d, 0x369d, 0x369d, 0x364b, 0x789b, 0x0018, 0x79a8, 0xa184,
+	0x0080, 0x0040, 0x2a85, 0x0078, 0x369d, 0x7000, 0xa005, 0x00c0,
+	0x2a7b, 0x2011, 0x0004, 0x0078, 0x321f, 0xa184, 0x00ff, 0xa08a,
+	0x0010, 0x00c8, 0x369d, 0x0079, 0x2a8d, 0x2a9f, 0x2a9d, 0x2ab7,
+	0x2abb, 0x2b78, 0x369d, 0x369d, 0x2b7a, 0x369d, 0x369d, 0x2c8f,
+	0x2c8f, 0x369d, 0x369d, 0x369d, 0x2c91, 0x1078, 0x23eb, 0xa684,
+	0x1000, 0x0040, 0x2aac, 0x2001, 0x0500, 0x8000, 0x8000, 0x783a,
+	0x781b, 0x008c, 0x0078, 0x2459, 0x6818, 0xa084, 0x8000, 0x0040,
+	0x2ab5, 0x681b, 0x001d, 0x0078, 0x2aa3, 0x0078, 0x3888, 0x681b,
+	0x001d, 0x0078, 0x36ad, 0x6920, 0x6922, 0xa684, 0x1800, 0x00c0,
+	0x2afc, 0x6820, 0xa084, 0x0001, 0x00c0, 0x2b04, 0x6818, 0xa086,
+	0x0008, 0x00c0, 0x2acd, 0x681b, 0x0000, 0xa684, 0x0400, 0x0040,
+	0x2b74, 0xa684, 0x0080, 0x0040, 0x2af8, 0x7097, 0x0000, 0x6818,
+	0xa084, 0x003f, 0xa08a, 0x000d, 0x0050, 0x2af8, 0xa08a, 0x000c,
+	0x7196, 0x2001, 0x000c, 0x800c, 0x719a, 0x789b, 0x0061, 0x78aa,
+	0x157e, 0x137e, 0x147e, 0x20a1, 0x012b, 0x789b, 0x0000, 0x8000,
+	0x80ac, 0xad80, 0x000b, 0x2098, 0x53a6, 0x147f, 0x137f, 0x157f,
+	0x781b, 0x0058, 0x0078, 0x2459, 0xa684, 0x1000, 0x0040, 0x2b04,
+	0x781b, 0x0065, 0x0078, 0x2459, 0xa684, 0x0060, 0x0040, 0x2b70,
+	0xa684, 0x0800, 0x0040, 0x2b70, 0xa684, 0x8000, 0x00c0, 0x2b12,
+	0x0078, 0x2b2c, 0xa6b4, 0x7fff, 0x7e5a, 0x6eb6, 0x789b, 0x0076,
+	0x7aac, 0x79ac, 0x78ac, 0x801b, 0x00c8, 0x2b1f, 0x8000, 0xa084,
+	0x003f, 0xa108, 0xa291, 0x0000, 0x6b98, 0x2100, 0xa302, 0x68b2,
+	0x6b94, 0x2200, 0xa303, 0x68ae, 0xa684, 0x4000, 0x0040, 0x2b34,
+	0xa6b4, 0xbfff, 0x7e5a, 0x6eb6, 0x7000, 0xa086, 0x0003, 0x00c0,
+	0x2b41, 0x1078, 0x482c, 0x1078, 0x4a29, 0x781b, 0x0064, 0x0078,
+	0x2459, 0xa006, 0x1078, 0x4b30, 0x6ab0, 0x69ac, 0x6c98, 0x6b94,
+	0x2200, 0xa105, 0x0040, 0x2b50, 0x2200, 0xa422, 0x2100, 0xa31b,
+	0x6caa, 0x7cd2, 0x7cda, 0x6ba6, 0x7bd6, 0x7bde, 0x2300, 0xa405,
+	0x00c0, 0x2b62, 0xa6b5, 0x4000, 0x7e5a, 0x6eb6, 0x781b, 0x0064,
+	0x0078, 0x2459, 0x781b, 0x0064, 0x2200, 0xa115, 0x00c0, 0x2b6c,
+	0x1078, 0x4a3a, 0x0078, 0x2459, 0x1078, 0x4a85, 0x0078, 0x2459,
+	0x781b, 0x0065, 0x0078, 0x2459, 0x781b, 0x0058, 0x0078, 0x2459,
+	0x1078, 0x23eb, 0x0078, 0x2bdb, 0x6920, 0xa184, 0x0100, 0x0040,
+	0x2b92, 0xa18c, 0xfeff, 0x6922, 0x0c7e, 0x7054, 0x2060, 0x6000,
+	0xa084, 0xefff, 0x6002, 0x6004, 0xa084, 0xfff5, 0x6006, 0x0c7f,
+	0x0078, 0x2bca, 0xa184, 0x0200, 0x0040, 0x2bca, 0xa18c, 0xfdff,
+	0x6922, 0x0c7e, 0x7054, 0x2060, 0x6000, 0xa084, 0xdfff, 0x6002,
+	0x6004, 0xa084, 0xffef, 0x6006, 0x2008, 0x2c48, 0x0c7f, 0xa184,
+	0x0008, 0x0040, 0x2bca, 0x1078, 0x37eb, 0x1078, 0x34f1, 0x88ff,
+	0x0040, 0x2bca, 0x789b, 0x0060, 0x2800, 0x78aa, 0x7e58, 0xa6b5,
+	0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x2bc4, 0x782b, 0x3008,
+	0x781b, 0x0056, 0x0078, 0x2459, 0x782b, 0x3008, 0x781b, 0x0065,
+	0x0078, 0x2459, 0x7e58, 0xa684, 0x0400, 0x00c0, 0x2bd3, 0x781b,
+	0x0058, 0x0078, 0x2459, 0x781b, 0x0065, 0x0078, 0x2459, 0x0078,
+	0x36a5, 0x0078, 0x36a5, 0x2019, 0x0000, 0x7990, 0xa18c, 0x0007,
+	0x00c0, 0x2be9, 0x6820, 0xa084, 0x0100, 0x0040, 0x2bd9, 0x2009,
+	0x0008, 0x789b, 0x0010, 0x78a8, 0xa094, 0x00ff, 0xa286, 0x0001,
+	0x00c0, 0x2c20, 0x2300, 0x7ca8, 0xa400, 0x2018, 0xa102, 0x0040,
+	0x2c18, 0x0048, 0x2bfd, 0x0078, 0x2c1a, 0xa380, 0x0002, 0xa102,
+	0x00c8, 0x2c18, 0x6920, 0xa18c, 0xfcff, 0x6922, 0x0c7e, 0x7054,
+	0x2060, 0x6000, 0xa084, 0xefef, 0x6002, 0x6004, 0xa084, 0xffe5,
+	0x6006, 0x0c7f, 0x7e58, 0xa6b4, 0xfffb, 0x7e5a, 0x0078, 0x2bcb,
+	0x0078, 0x2b7c, 0x24a8, 0x7aa8, 0x00f0, 0x2c1a, 0x0078, 0x2beb,
+	0xa284, 0x00f0, 0xa086, 0x0020, 0x00c0, 0x2c80, 0x8318, 0x8318,
+	0x2300, 0xa102, 0x0040, 0x2c30, 0x0048, 0x2c30, 0x0078, 0x2c7d,
+	0xa286, 0x0023, 0x0040, 0x2bd9, 0x681c, 0xa084, 0xfff1, 0x681e,
+	0x7e58, 0xa684, 0xfff1, 0xa085, 0x0010, 0x2030, 0x7e5a, 0x6008,
+	0xa085, 0x0010, 0x600a, 0x0c7e, 0x7054, 0x2060, 0x6004, 0x2008,
+	0x2c48, 0x0c7f, 0xa184, 0x0010, 0x0040, 0x2c54, 0x1078, 0x37eb,
+	0x1078, 0x3604, 0x0078, 0x2c63, 0x0c7e, 0x7054, 0x2060, 0x6004,
+	0x2008, 0x2c48, 0x0c7f, 0xa184, 0x0008, 0x0040, 0x2bca, 0x1078,
+	0x37eb, 0x1078, 0x34f1, 0x88ff, 0x0040, 0x2bca, 0x789b, 0x0060,
+	0x2800, 0x78aa, 0xa6b5, 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0,
+	0x2c77, 0x782b, 0x3008, 0x781b, 0x0056, 0x0078, 0x2459, 0x782b,
+	0x3008, 0x781b, 0x0065, 0x0078, 0x2459, 0x7aa8, 0x0078, 0x2beb,
+	0x8318, 0x2300, 0xa102, 0x0040, 0x2c89, 0x0048, 0x2c89, 0x0078,
+	0x2beb, 0xa284, 0x0080, 0x00c0, 0x36ad, 0x0078, 0x36a5, 0x0078,
+	0x36ad, 0x0078, 0x369d, 0x789b, 0x0018, 0x78a8, 0xa084, 0x00ff,
+	0xa08e, 0x0001, 0x0040, 0x2c9e, 0x1078, 0x23eb, 0x7aa8, 0xa294,
+	0x00ff, 0x78a8, 0xa084, 0x00ff, 0xa08a, 0x0004, 0x00c8, 0x369d,
+	0x0079, 0x2caa, 0x369d, 0x343e, 0x369d, 0x3599, 0xa282, 0x0000,
+	0x00c0, 0x2cb4, 0x1078, 0x23eb, 0x1078, 0x36c1, 0x782b, 0x3008,
+	0x781b, 0x0065, 0x0078, 0x2459, 0xa282, 0x0003, 0x00c0, 0x2cc2,
+	0x1078, 0x23eb, 0xa484, 0x8000, 0x00c0, 0x2ce5, 0x706c, 0xa005,
+	0x0040, 0x2ccc, 0x1078, 0x23eb, 0x6f14, 0x7782, 0xa7bc, 0x0f00,
+	0x1078, 0x37ef, 0x6008, 0xa085, 0x0021, 0x600a, 0x8738, 0xa784,
+	0x001f, 0x00c0, 0x2cd0, 0x1078, 0x36c5, 0x706f, 0x0002, 0x2009,
+	0x5138, 0x200b, 0x0009, 0x0078, 0x2ce7, 0x1078, 0x36d1, 0x782b,
+	0x3008, 0x781b, 0x0065, 0x0078, 0x2459, 0xa282, 0x0004, 0x0050,
+	0x2cf3, 0x1078, 0x23eb, 0x2300, 0x0079, 0x2cf6, 0x2cf9, 0x2de2,
+	0x2e15, 0xa286, 0x0003, 0x0040, 0x2cff, 0x1078, 0x23eb, 0x2001,
+	0x0000, 0x007e, 0x68c0, 0xa005, 0x0040, 0x2d08, 0x7003, 0x0003,
+	0x68a0, 0xa084, 0x2000, 0x0040, 0x2d11, 0x6008, 0xa085, 0x0002,
+	0x600a, 0x007f, 0x703e, 0x7000, 0xa084, 0x0007, 0x0079, 0x2d18,
+	0x2482, 0x2d22, 0x2d22, 0x2f17, 0x2f53, 0x2482, 0x2f53, 0x2d20,
+	0x1078, 0x23eb, 0xa684, 0x1000, 0x00c0, 0x2d2a, 0x1078, 0x4776,
+	0x0040, 0x2dbc, 0x7868, 0xa08c, 0x00ff, 0x0040, 0x2d72, 0xa186,
+	0x0008, 0x00c0, 0x2d41, 0x1078, 0x33ee, 0x6008, 0xa084, 0xffef,
+	0x600a, 0x1078, 0x3390, 0x0040, 0x2d72, 0x1078, 0x4776, 0x0078,
+	0x2d59, 0xa186, 0x0028, 0x00c0, 0x2d72, 0x1078, 0x4776, 0x6008,
+	0xa084, 0xffef, 0x600a, 0x6018, 0xa005, 0x0040, 0x2d59, 0x8001,
+	0x601a, 0xa005, 0x0040, 0x2d59, 0x8001, 0xa005, 0x0040, 0x2d59,
+	0x601e, 0x6820, 0xa084, 0x0001, 0x0040, 0x2482, 0x6820, 0xa084,
+	0xfffe, 0x6822, 0x7060, 0x0c7e, 0x2060, 0x6800, 0x6002, 0x0c7f,
+	0x6004, 0x6802, 0xa005, 0x2d00, 0x00c0, 0x2d6f, 0x6002, 0x6006,
+	0x0078, 0x2482, 0x017e, 0x1078, 0x2e46, 0x017f, 0xa684, 0xdf00,
+	0x681e, 0x682b, 0x0000, 0x6f14, 0x81ff, 0x0040, 0x2dbc, 0xa186,
+	0x0002, 0x00c0, 0x2dbc, 0xa684, 0x0800, 0x00c0, 0x2d8f, 0xa684,
+	0x0060, 0x0040, 0x2d8f, 0x78d8, 0x7adc, 0x682e, 0x6a32, 0x6820,
+	0xa084, 0x0800, 0x00c0, 0x2dbc, 0x8717, 0xa294, 0x000f, 0x8213,
+	0x8213, 0x8213, 0xa290, 0x5380, 0xa290, 0x0000, 0x221c, 0xa384,
+	0x0100, 0x00c0, 0x2da5, 0x0078, 0x2dab, 0x8210, 0x2204, 0xa085,
+	0x0018, 0x2012, 0x8211, 0xa384, 0x0400, 0x0040, 0x2db8, 0x68a0,
+	0xa084, 0x0100, 0x00c0, 0x2db8, 0x1078, 0x2eca, 0x0078, 0x2482,
+	0x6008, 0xa085, 0x0002, 0x600a, 0x6916, 0x6818, 0xa084, 0x8000,
+	0x0040, 0x2dc4, 0x703c, 0x681a, 0xa68c, 0xdf00, 0x691e, 0x1078,
+	0x33df, 0x1078, 0x33ee, 0x00c0, 0x2dd1, 0x6008, 0xa084, 0xffef,
+	0x600a, 0x6820, 0xa084, 0x0001, 0x00c0, 0x2dda, 0x1078, 0x33d8,
+	0x0078, 0x2dde, 0x7060, 0x2060, 0x6800, 0x6002, 0x1078, 0x1c70,
+	0x0078, 0x2482, 0xa282, 0x0004, 0x0048, 0x2de8, 0x1078, 0x23eb,
+	0x2200, 0x0079, 0x2deb, 0x2de6, 0x2def, 0x2dfc, 0x2def, 0x7000,
+	0xa086, 0x0005, 0x0040, 0x2df8, 0x1078, 0x36c1, 0x782b, 0x3008,
+	0x781b, 0x0065, 0x0078, 0x2459, 0x7890, 0x8007, 0x8001, 0xa084,
+	0x0007, 0xa080, 0x0018, 0x789a, 0x79a8, 0xa18c, 0x00ff, 0xa186,
+	0x0003, 0x0040, 0x2e11, 0xa186, 0x0000, 0x0040, 0x2e11, 0x0078,
+	0x369d, 0x781b, 0x0065, 0x0078, 0x2459, 0x6820, 0xa085, 0x0004,
+	0x6822, 0x82ff, 0x00c0, 0x2e20, 0x1078, 0x36c1, 0x0078, 0x2e27,
+	0x8211, 0x0040, 0x2e25, 0x1078, 0x23eb, 0x1078, 0x36d1, 0x782b,
+	0x3008, 0x781b, 0x0065, 0x0078, 0x2459, 0x702c, 0x8003, 0x0048,
+	0x2e37, 0x2019, 0x4d9e, 0x1078, 0x2276, 0x702f, 0x8000, 0x1078,
+	0x3912, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x2e43, 0x0018, 0x2e43,
+	0x791a, 0xa006, 0x007c, 0xa085, 0x0001, 0x007c, 0xa684, 0x0060,
+	0x00c0, 0x2e50, 0x682f, 0x0000, 0x6833, 0x0000, 0x0078, 0x2ec9,
+	0xa684, 0x0800, 0x00c0, 0x2e72, 0x68b4, 0xa084, 0x4800, 0xa635,
+	0xa684, 0x0800, 0x00c0, 0x2e72, 0x6998, 0x6a94, 0x692e, 0x6a32,
+	0x703c, 0xa005, 0x00c0, 0x2e6a, 0x2200, 0xa105, 0x0040, 0x2e71,
+	0x703f, 0x0015, 0x7000, 0xa086, 0x0006, 0x0040, 0x2e71, 0x1078,
+	0x4776, 0x007c, 0xa684, 0x0020, 0x0040, 0x2e94, 0xa684, 0x4000,
+	0x0040, 0x2e80, 0x682f, 0x0000, 0x6833, 0x0000, 0x0078, 0x2e6a,
+	0x68b4, 0xa084, 0x4800, 0xa635, 0xa684, 0x4000, 0x00c0, 0x2e7a,
+	0x703c, 0xa005, 0x00c0, 0x2e8e, 0x703f, 0x0015, 0x79d8, 0x7adc,
+	0x692e, 0x6a32, 0x0078, 0x2e6a, 0xa684, 0x4000, 0x0040, 0x2e9e,
+	0x682f, 0x0000, 0x6833, 0x0000, 0x0078, 0x2e6a, 0x68b4, 0xa084,
+	0x4800, 0xa635, 0xa684, 0x4000, 0x00c0, 0x2e98, 0x703c, 0xa005,
+	0x00c0, 0x2eac, 0x703f, 0x0015, 0x79d8, 0x7adc, 0x78d0, 0x80fb,
+	0x00c8, 0x2eb3, 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, 0x0000,
+	0x692e, 0x6a32, 0x2100, 0xa205, 0x00c0, 0x2ec0, 0x0078, 0x2e6a,
+	0x7000, 0xa086, 0x0006, 0x0040, 0x2ec9, 0x1078, 0x4b30, 0x0078,
+	0x2e6a, 0x007c, 0x6008, 0xa085, 0x0200, 0x600a, 0xa384, 0x0200,
+	0x0040, 0x2ed6, 0x6008, 0xa085, 0x0002, 0x600a, 0x681b, 0x0006,
+	0x688f, 0x0000, 0x6893, 0x0000, 0x6a30, 0x692c, 0x6a3e, 0x6942,
+	0x682f, 0x0003, 0x6833, 0x0000, 0x6837, 0x0020, 0x6897, 0x0000,
+	0x689b, 0x0020, 0x68b3, 0x0000, 0x68af, 0x0000, 0x7000, 0x0079,
+	0x2ef1, 0x2482, 0x2efb, 0x2f04, 0x2ef9, 0x2ef9, 0x2ef9, 0x2ef9,
+	0x2ef9, 0x1078, 0x23eb, 0x6820, 0xa084, 0x0001, 0x00c0, 0x2f04,
+	0x1078, 0x33d8, 0x0078, 0x2f0a, 0x7060, 0x2c50, 0x2060, 0x6800,
+	0x6002, 0x2a60, 0x2021, 0x515a, 0x2404, 0xa005, 0x0040, 0x2f13,
+	0x2020, 0x0078, 0x2f0c, 0x2d22, 0x206b, 0x0000, 0x007c, 0x1078,
+	0x33df, 0x1078, 0x33ee, 0x6008, 0xa084, 0xfdff, 0x600a, 0x682b,
+	0x0000, 0x789b, 0x000e, 0x6f14, 0x6817, 0x0002, 0x1078, 0x4b78,
+	0xa684, 0x0800, 0x0040, 0x2f30, 0x691c, 0xa18d, 0x2000, 0x691e,
+	0x6818, 0xa084, 0x8000, 0x0040, 0x2f40, 0x7868, 0xa08c, 0x00ff,
+	0x0040, 0x2f3e, 0x681b, 0x001e, 0x0078, 0x2f40, 0x681b, 0x0000,
+	0x2021, 0x515a, 0x2404, 0xad06, 0x0040, 0x2f47, 0x7460, 0x6800,
+	0x2022, 0x68c3, 0x0000, 0x6a3c, 0x6940, 0x6a32, 0x692e, 0x1078,
+	0x1c70, 0x0078, 0x2482, 0x1078, 0x2e46, 0x682b, 0x0000, 0x2001,
+	0x000e, 0x6f14, 0x1078, 0x3918, 0xa08c, 0x00ff, 0x6916, 0x6818,
+	0xa084, 0x8000, 0x0040, 0x2f66, 0x703c, 0x681a, 0xa68c, 0xdf00,
+	0x691e, 0x706f, 0x0000, 0x0078, 0x2482, 0x7000, 0xa005, 0x00c0,
+	0x2f73, 0x0078, 0x2482, 0xa006, 0x1078, 0x4776, 0x6817, 0x0000,
+	0x681b, 0x0014, 0xa68c, 0xdf00, 0x691e, 0x682b, 0x0000, 0x6820,
+	0xa085, 0x00ff, 0x6822, 0x7000, 0x0079, 0x2f86, 0x2482, 0x2f90,
+	0x2f90, 0x2f92, 0x2f92, 0x2f92, 0x2f92, 0x2f8e, 0x1078, 0x23eb,
+	0x1078, 0x33ee, 0x6008, 0xa084, 0xffef, 0x600a, 0x0078, 0x33a8,
+	0x2300, 0x0079, 0x2f9b, 0x2f9e, 0x2fa0, 0x2fd9, 0x1078, 0x23eb,
+	0x7000, 0x0079, 0x2fa3, 0x2482, 0x2fad, 0x2fad, 0x2fc8, 0x2fad,
+	0x2fd5, 0x2fc8, 0x2fab, 0x1078, 0x23eb, 0xa684, 0x0060, 0xa086,
+	0x0060, 0x00c0, 0x2fc4, 0xa6b4, 0xffdf, 0xa6b4, 0xbfff, 0xa6b5,
+	0x2000, 0x7e5a, 0x681c, 0xa084, 0xffdf, 0x681e, 0x1078, 0x4776,
+	0x1078, 0x4a3a, 0x0078, 0x3888, 0xa684, 0x2000, 0x0040, 0x2fb7,
+	0x6818, 0xa084, 0x8000, 0x0040, 0x2fd5, 0x681b, 0x0015, 0xa684,
+	0x4000, 0x0040, 0x2fd5, 0x681b, 0x0007, 0x1078, 0x389c, 0x0078,
+	0x2459, 0x1078, 0x23eb, 0x2300, 0x0079, 0x2fde, 0x2fe1, 0x2fe3,
+	0x3016, 0x1078, 0x23eb, 0x7000, 0x0079, 0x2fe6, 0x2482, 0x2ff0,
+	0x2ff0, 0x300b, 0x2ff0, 0x3012, 0x300b, 0x2fee, 0x1078, 0x23eb,
+	0xa684, 0x0060, 0xa086, 0x0060, 0x00c0, 0x3007, 0xa6b4, 0xffbf,
+	0xa6b4, 0xbfff, 0xa6b5, 0x2000, 0x7e5a, 0x681c, 0xa084, 0xffbf,
+	0x681e, 0x1078, 0x4776, 0x1078, 0x4a3a, 0x0078, 0x3888, 0xa684,
+	0x2000, 0x0040, 0x2ffa, 0x6818, 0xa084, 0x8000, 0x0040, 0x3012,
+	0x681b, 0x0007, 0x781b, 0x00cd, 0x0078, 0x2459, 0x6820, 0xa085,
+	0x0004, 0x6822, 0x1078, 0x3853, 0xa6b5, 0x0800, 0x1078, 0x36c1,
+	0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2459, 0x2300, 0x0079,
+	0x3029, 0x302c, 0x302e, 0x3030, 0x1078, 0x23eb, 0x0078, 0x36ad,
+	0xa684, 0x0400, 0x00c0, 0x3059, 0x79e4, 0xa184, 0x0020, 0x0040,
+	0x3040, 0x78ec, 0xa084, 0x0003, 0x0040, 0x3040, 0x782b, 0x3009,
+	0x789b, 0x0060, 0x78ab, 0x0000, 0xa684, 0xfffb, 0x785a, 0x79e4,
+	0xa184, 0x0020, 0x0040, 0x3051, 0x78ec, 0xa084, 0x0003, 0x00c0,
+	0x3055, 0x2001, 0x0014, 0x0078, 0x2d01, 0xa184, 0x0007, 0x0079,
+	0x3091, 0x7a90, 0xa294, 0x0007, 0x789b, 0x0060, 0x79a8, 0x81ff,
+	0x0040, 0x308f, 0x789b, 0x0010, 0x7ba8, 0xa384, 0x0001, 0x00c0,
+	0x3080, 0x7ba8, 0x7ba8, 0xa386, 0x0001, 0x00c0, 0x3073, 0x2009,
+	0xfff7, 0x0078, 0x3079, 0xa386, 0x0003, 0x00c0, 0x3080, 0x2009,
+	0xffef, 0x0c7e, 0x7054, 0x2060, 0x6004, 0xa104, 0x6006, 0x0c7f,
+	0x789b, 0x0060, 0x78ab, 0x0000, 0xa684, 0xfffb, 0x785a, 0x782b,
+	0x3009, 0x6920, 0xa18c, 0xfdff, 0xa18c, 0xfeff, 0x6922, 0x0078,
+	0x3888, 0x299e, 0x29a9, 0x309b, 0x30a3, 0x3099, 0x3099, 0x3888,
+	0x3888, 0x1078, 0x23eb, 0x6920, 0xa18c, 0xfdff, 0xa18c, 0xfeff,
+	0x6922, 0x0078, 0x3892, 0x6920, 0xa18c, 0xfdff, 0xa18c, 0xfeff,
+	0x6922, 0x0078, 0x3888, 0x79e4, 0xa184, 0x0030, 0x0040, 0x30b5,
+	0x78ec, 0xa084, 0x0003, 0x00c0, 0x30dc, 0x7000, 0xa086, 0x0004,
+	0x00c0, 0x30cf, 0x706c, 0xa086, 0x0002, 0x00c0, 0x30c5, 0x2011,
+	0x0002, 0x2019, 0x0000, 0x0078, 0x2848, 0x706c, 0xa086, 0x0006,
+	0x0040, 0x30bf, 0x706c, 0xa086, 0x0004, 0x0040, 0x30bf, 0x7000,
+	0xa086, 0x0000, 0x0040, 0x2459, 0x6818, 0xa085, 0x8000, 0x681a,
+	0x2001, 0x0014, 0x0078, 0x2d01, 0xa184, 0x0007, 0x0079, 0x30e0,
+	0x3888, 0x3888, 0x30e8, 0x3888, 0x38ed, 0x38ed, 0x3888, 0x3888,
+	0xa684, 0x0080, 0x0040, 0x3117, 0x7194, 0x81ff, 0x0040, 0x3117,
+	0xa182, 0x000d, 0x00d0, 0x30f8, 0x7097, 0x0000, 0x0078, 0x30fd,
+	0xa182, 0x000c, 0x7096, 0x2009, 0x000c, 0x789b, 0x0061, 0x79aa,
+	0x157e, 0x137e, 0x147e, 0x7098, 0x8114, 0xa210, 0x729a, 0xa080,
+	0x000b, 0xad00, 0x2098, 0x20a1, 0x012b, 0x789b, 0x0000, 0x8108,
+	0x81ac, 0x53a6, 0x147f, 0x137f, 0x157f, 0x0078, 0x3892, 0xa684,
+	0x0400, 0x00c0, 0x3158, 0x6820, 0xa084, 0x0001, 0x0040, 0x3892,
+	0xa68c, 0x0060, 0xa684, 0x0060, 0x0040, 0x312c, 0xa086, 0x0060,
+	0x00c0, 0x312c, 0xa18d, 0x4000, 0xa18c, 0xfffb, 0x795a, 0x69b6,
+	0x789b, 0x0060, 0x78ab, 0x0000, 0x789b, 0x0061, 0x6818, 0xa085,
+	0x8000, 0x681a, 0x78aa, 0x8008, 0x810c, 0x0040, 0x3407, 0xa18c,
+	0x00f8, 0x00c0, 0x3407, 0x157e, 0x137e, 0x147e, 0x20a1, 0x012b,
+	0x789b, 0x0000, 0x8000, 0x80ac, 0xad80, 0x000b, 0x2098, 0x53a6,
+	0x147f, 0x137f, 0x157f, 0x6814, 0x8007, 0x7882, 0x0078, 0x3892,
+	0x6818, 0xa084, 0x8000, 0x0040, 0x315f, 0x681b, 0x0008, 0x781b,
+	0x00c3, 0x0078, 0x2459, 0x2300, 0x0079, 0x3166, 0x316b, 0x320a,
+	0x3169, 0x1078, 0x23eb, 0x7000, 0xa084, 0x0007, 0x0079, 0x3170,
+	0x2482, 0x317a, 0x31af, 0x3185, 0x3178, 0x2482, 0x3178, 0x3178,
+	0x1078, 0x23eb, 0x681c, 0xa084, 0x2000, 0x0040, 0x3193, 0x6008,
+	0xa085, 0x0002, 0x600a, 0x0078, 0x3193, 0x68c0, 0xa005, 0x00c0,
+	0x31af, 0x6920, 0xa18d, 0x0001, 0x6922, 0x68c3, 0x0001, 0x6800,
+	0x706a, 0x0078, 0x31a9, 0x6920, 0xa18d, 0x0001, 0x6922, 0x6800,
+	0x6006, 0xa005, 0x00c0, 0x319d, 0x6002, 0x681c, 0xa084, 0x000e,
+	0x0040, 0x31a9, 0x7014, 0x68ba, 0x7130, 0xa188, 0x7400, 0x0078,
+	0x31ab, 0x2009, 0x7500, 0x2104, 0x6802, 0x2d0a, 0x7162, 0x6eb6,
+	0xa684, 0x0060, 0x0040, 0x3208, 0xa684, 0x0800, 0x00c0, 0x31c3,
+	0xa684, 0x7fff, 0x68b6, 0x6894, 0x68a6, 0x6898, 0x68aa, 0x1078,
+	0x4776, 0x0078, 0x3208, 0xa684, 0x0020, 0x0040, 0x31d8, 0x68c0,
+	0xa005, 0x0040, 0x31cf, 0x1078, 0x4b78, 0x0078, 0x31d2, 0xa006,
+	0x1078, 0x4b30, 0x79d8, 0x7adc, 0x69aa, 0x6aa6, 0x0078, 0x31de,
+	0x1078, 0x37fc, 0x69aa, 0x6aa6, 0x1078, 0x4b30, 0xa684, 0x8000,
+	0x0040, 0x3208, 0xa684, 0x7fff, 0x68b6, 0x2001, 0x0076, 0x1078,
+	0x3918, 0x2010, 0x2001, 0x0078, 0x1078, 0x3918, 0x2008, 0xa684,
+	0x0020, 0x00c0, 0x3200, 0x2001, 0x007a, 0x1078, 0x3918, 0x801b,
+	0x00c8, 0x31fb, 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, 0x0000,
+	0x6b98, 0x2100, 0xa302, 0x68b2, 0x6b94, 0x2200, 0xa303, 0x68ae,
+	0x0078, 0x2482, 0x0078, 0x36ad, 0x7037, 0x0000, 0xa282, 0x0006,
+	0x0050, 0x3214, 0x1078, 0x23eb, 0x7000, 0xa084, 0x0007, 0x10c0,
+	0x39be, 0x2300, 0x0079, 0x321c, 0x321f, 0x3248, 0x325c, 0x2200,
+	0x0079, 0x3222, 0x3246, 0x36ad, 0x3228, 0x3246, 0x3278, 0x32ba,
+	0x7003, 0x0005, 0x2001, 0x7610, 0x2068, 0x704a, 0x157e, 0x20a9,
+	0x0031, 0x2003, 0x0000, 0x8000, 0x0070, 0x3238, 0x0078, 0x3231,
+	0x157f, 0xad80, 0x0009, 0x7036, 0x6817, 0x0000, 0x68b7, 0x0700,
+	0x6823, 0x0800, 0x6827, 0x0003, 0x0078, 0x369d, 0x1078, 0x23eb,
+	0x7003, 0x0005, 0x2001, 0x7610, 0x2068, 0x704a, 0xad80, 0x0009,
+	0x7036, 0x2200, 0x0079, 0x3254, 0x36ad, 0x325a, 0x325a, 0x3278,
+	0x325a, 0x36ad, 0x1078, 0x23eb, 0x7003, 0x0005, 0x2001, 0x7610,
+	0x2068, 0x704a, 0xad80, 0x0009, 0x7036, 0x2200, 0x0079, 0x3268,
+	0x3270, 0x326e, 0x326e, 0x3270, 0x326e, 0x3270, 0x1078, 0x23eb,
+	0x1078, 0x36d1, 0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2459,
+	0x7003, 0x0002, 0x7a80, 0xa294, 0x0f00, 0x789b, 0x0018, 0x7ca8,
+	0xa484, 0x001f, 0xa215, 0x2069, 0x7500, 0x2d04, 0x2d08, 0x7162,
+	0x2068, 0xa005, 0x0040, 0x3293, 0x6814, 0xa206, 0x0040, 0x32af,
+	0x6800, 0x0078, 0x3286, 0x7003, 0x0005, 0x2001, 0x7610, 0x2068,
+	0x704a, 0x7036, 0x157e, 0x20a9, 0x0031, 0x2003, 0x0000, 0x8000,
+	0x0070, 0x32a4, 0x0078, 0x329d, 0x157f, 0xad80, 0x0009, 0x7036,
+	0x6a16, 0x68b7, 0x0700, 0x6823, 0x0800, 0x6827, 0x0003, 0x6eb4,
+	0x7e5a, 0x6820, 0xa084, 0x0c00, 0x0040, 0x3309, 0x1078, 0x36c9,
+	0x0078, 0x3309, 0x7003, 0x0002, 0x7a80, 0xa294, 0x0f00, 0x789b,
+	0x0018, 0x7ca8, 0xa484, 0x001f, 0xa215, 0x79a8, 0x79a8, 0xa18c,
+	0x00ff, 0xa1e8, 0x7400, 0x2d04, 0x2d08, 0x7162, 0x2068, 0xa005,
+	0x0040, 0x32d9, 0x6814, 0xa206, 0x0040, 0x32f4, 0x6800, 0x0078,
+	0x32cc, 0x7003, 0x0005, 0x2001, 0x7610, 0x2068, 0x704a, 0x157e,
+	0x20a9, 0x0031, 0x2003, 0x0000, 0x8000, 0x0070, 0x32e9, 0x0078,
+	0x32e2, 0x157f, 0xad80, 0x0009, 0x7036, 0x6a16, 0x68b7, 0x0700,
+	0x6823, 0x0800, 0x6827, 0x0003, 0x6eb4, 0x7e5a, 0x6820, 0xa084,
+	0x0c00, 0x0040, 0x3309, 0xa084, 0x0800, 0x0040, 0x3303, 0x1078,
+	0x36cd, 0x0078, 0x3309, 0x1078, 0x36c9, 0x708b, 0x0000, 0x0078,
+	0x3309, 0x027e, 0x8207, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003,
+	0xa080, 0x5380, 0x2060, 0x7056, 0x6000, 0x705a, 0x6004, 0x705e,
+	0xa684, 0x0060, 0x0040, 0x3361, 0x6b98, 0x6c94, 0x69ac, 0x68b0,
+	0xa105, 0x00c0, 0x3343, 0x7bd2, 0x7bda, 0x7cd6, 0x7cde, 0xa6b4,
+	0xb7ff, 0x7e5a, 0xa684, 0x0060, 0xa086, 0x0060, 0x0040, 0x3361,
+	0x68c0, 0xa005, 0x0040, 0x333c, 0x7003, 0x0003, 0x682b, 0x0000,
+	0x1078, 0x4a29, 0x0078, 0x333e, 0x1078, 0x4a3a, 0xa6b5, 0x2000,
+	0x7e5a, 0x0078, 0x3361, 0x68b0, 0xa31a, 0x2100, 0xa423, 0x2400,
+	0xa305, 0x0040, 0x3361, 0x7bd2, 0x7bda, 0x7cd6, 0x7cde, 0x68b0,
+	0xa6b4, 0xbfff, 0x7e5a, 0x007e, 0x68c0, 0xa005, 0x007f, 0x0040,
+	0x335f, 0x7003, 0x0003, 0x1078, 0x4a29, 0x0078, 0x3361, 0x1078,
+	0x4a85, 0x077f, 0x1078, 0x37ef, 0x2009, 0x0065, 0xa684, 0x0004,
+	0x0040, 0x3382, 0x78e4, 0xa084, 0x0030, 0x0040, 0x337a, 0x78ec,
+	0xa084, 0x0003, 0x0040, 0x337a, 0x782b, 0x3008, 0x2009, 0x0065,
+	0x0078, 0x3382, 0x0f7e, 0x2079, 0x5100, 0x1078, 0x4776, 0x0f7f,
+	0x0040, 0x2482, 0x791a, 0x2d00, 0x704a, 0x8207, 0xa084, 0x000f,
+	0x8003, 0x8003, 0x8003, 0xa080, 0x5380, 0x2048, 0x0078, 0x2459,
+	0x6020, 0xa005, 0x0040, 0x339c, 0x8001, 0x6022, 0x6008, 0xa085,
+	0x0008, 0x600a, 0x7010, 0x6026, 0x007c, 0xa006, 0x1078, 0x4776,
+	0x6817, 0x0000, 0x681b, 0x0001, 0x6823, 0x0040, 0x681f, 0x0100,
+	0x7000, 0xa084, 0x0007, 0x0079, 0x33ad, 0x2482, 0x33b7, 0x33b7,
+	0x33d4, 0x33bf, 0x33bd, 0x33bf, 0x33b5, 0x1078, 0x23eb, 0x1078,
+	0x33df, 0x1078, 0x33d8, 0x1078, 0x1c70, 0x0078, 0x2482, 0x706c,
+	0x706f, 0x0000, 0x7093, 0x0000, 0x0079, 0x33c6, 0x33d0, 0x33d0,
+	0x33ce, 0x33ce, 0x33ce, 0x33d0, 0x33ce, 0x33d0, 0x0079, 0x2861,
+	0x706f, 0x0000, 0x0078, 0x2482, 0x681b, 0x0000, 0x0078, 0x2f17,
+	0x6800, 0xa005, 0x00c0, 0x33dd, 0x6002, 0x6006, 0x007c, 0x6010,
+	0xa005, 0x0040, 0x33e8, 0x8001, 0x00d0, 0x33e8, 0x1078, 0x23eb,
+	0x6012, 0x6008, 0xa084, 0xffef, 0x600a, 0x007c, 0x6018, 0xa005,
+	0x0040, 0x33f4, 0x8001, 0x601a, 0x007c, 0x1078, 0x3912, 0x681b,
+	0x0018, 0x0078, 0x342b, 0x1078, 0x3912, 0x681b, 0x0019, 0x0078,
+	0x342b, 0x1078, 0x3912, 0x681b, 0x001a, 0x0078, 0x342b, 0x1078,
+	0x3912, 0x681b, 0x0003, 0x0078, 0x342b, 0x7780, 0x1078, 0x37ef,
+	0x7184, 0xa18c, 0x00ff, 0xa1e8, 0x7400, 0x2d04, 0x2d08, 0x2068,
+	0xa005, 0x00c0, 0x341d, 0x0078, 0x2482, 0x6814, 0x7280, 0xa206,
+	0x0040, 0x3425, 0x6800, 0x0078, 0x3416, 0x6800, 0x200a, 0x681b,
+	0x0005, 0x708b, 0x0000, 0x1078, 0x33df, 0x6820, 0xa084, 0x0001,
+	0x00c0, 0x3434, 0x1078, 0x33d8, 0x1078, 0x33ee, 0x681f, 0x0000,
+	0x6823, 0x0020, 0x1078, 0x1c70, 0x0078, 0x2482, 0xa282, 0x0003,
+	0x00c0, 0x369d, 0x7da8, 0xa5ac, 0x00ff, 0x7ca8, 0xa4a4, 0x00ff,
+	0x6920, 0xa18d, 0x0080, 0x6922, 0xa184, 0x0100, 0x0040, 0x34a2,
+	0xa18c, 0xfeff, 0x6922, 0xa4a4, 0x00ff, 0x0040, 0x348c, 0xa482,
+	0x000c, 0x0048, 0x345f, 0x0040, 0x345f, 0x2021, 0x000c, 0x852b,
+	0x852b, 0x1078, 0x3760, 0x0040, 0x3469, 0x1078, 0x355b, 0x0078,
+	0x3495, 0x1078, 0x371b, 0x0c7e, 0x2960, 0x6004, 0xa084, 0xfff5,
+	0x6006, 0x1078, 0x3586, 0x0c7f, 0x6920, 0xa18d, 0x0100, 0x6922,
+	0x7e58, 0xa6b5, 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x3486,
+	0x782b, 0x3008, 0x781b, 0x0056, 0x0078, 0x2459, 0x782b, 0x3008,
+	0x781b, 0x0065, 0x0078, 0x2459, 0x0c7e, 0x2960, 0x6004, 0xa084,
+	0xfff5, 0x6006, 0x1078, 0x3586, 0x0c7f, 0x7e58, 0xa684, 0x0400,
+	0x00c0, 0x349e, 0x781b, 0x0058, 0x0078, 0x2459, 0x781b, 0x0065,
+	0x0078, 0x2459, 0x0c7e, 0x7054, 0x2060, 0x6100, 0xa18c, 0x1000,
+	0x0040, 0x34e2, 0x6208, 0x8217, 0xa294, 0x00ff, 0xa282, 0x000c,
+	0x0048, 0x34b6, 0x0040, 0x34b6, 0x2011, 0x000c, 0x2400, 0xa202,
+	0x00c8, 0x34bb, 0x2220, 0x6208, 0xa294, 0x00ff, 0x7018, 0xa086,
+	0x0028, 0x00c0, 0x34cb, 0xa282, 0x0019, 0x00c8, 0x34d1, 0x2011,
+	0x0019, 0x0078, 0x34d1, 0xa282, 0x000c, 0x00c8, 0x34d1, 0x2011,
+	0x000c, 0x2200, 0xa502, 0x00c8, 0x34d6, 0x2228, 0x1078, 0x371f,
+	0x852b, 0x852b, 0x1078, 0x3760, 0x0040, 0x34e2, 0x1078, 0x355b,
+	0x0078, 0x34e6, 0x1078, 0x371b, 0x1078, 0x3586, 0x7858, 0xa085,
+	0x0004, 0x785a, 0x0c7f, 0x782b, 0x3008, 0x781b, 0x0065, 0x0078,
+	0x2459, 0x0c7e, 0x2960, 0x6000, 0xa084, 0x1000, 0x00c0, 0x3509,
+	0x6010, 0xa084, 0x000f, 0x00c0, 0x3503, 0x6104, 0xa18c, 0xfff5,
+	0x6106, 0x0c7f, 0x007c, 0x2011, 0x0032, 0x2019, 0x0000, 0x0078,
+	0x3530, 0x68a0, 0xa084, 0x0200, 0x00c0, 0x3503, 0x6208, 0xa294,
+	0x00ff, 0x7018, 0xa086, 0x0028, 0x00c0, 0x351e, 0xa282, 0x0019,
+	0x00c8, 0x3524, 0x2011, 0x0019, 0x0078, 0x3524, 0xa282, 0x000c,
+	0x00c8, 0x3524, 0x2011, 0x000c, 0x6308, 0x831f, 0xa39c, 0x00ff,
+	0xa382, 0x000c, 0x0048, 0x3530, 0x0040, 0x3530, 0x2019, 0x000c,
+	0x78ab, 0x0001, 0x78ab, 0x0003, 0x78ab, 0x0001, 0x7aaa, 0x7baa,
+	0xa8c0, 0x0005, 0x6820, 0xa085, 0x0100, 0x6822, 0x0c7f, 0x007c,
+	0x0c7e, 0x2960, 0xa18c, 0xfff5, 0x6106, 0x2011, 0x0032, 0x2019,
+	0x0000, 0x0078, 0x354b, 0x78ab, 0x0001, 0x78ab, 0x0003, 0x78ab,
+	0x0001, 0x7aaa, 0x7baa, 0xa8c0, 0x0005, 0x6820, 0xa085, 0x0100,
+	0x6822, 0x0c7f, 0x007c, 0x0c7e, 0x7154, 0x2160, 0x1078, 0x3562,
+	0x0c7f, 0x007c, 0x2008, 0xa084, 0xfff0, 0xa425, 0x7c86, 0x6018,
+	0x789a, 0x7cae, 0x6412, 0x78a4, 0xa084, 0xfff8, 0xa18c, 0x0007,
+	0xa105, 0x78a6, 0x6016, 0x788a, 0xa4a4, 0x000f, 0x8427, 0x8204,
+	0x8004, 0xa084, 0x00ff, 0xa405, 0x600e, 0x78ec, 0xd08c, 0x00c0,
+	0x3585, 0x6004, 0xa084, 0xfff5, 0x6006, 0x007c, 0x0c7e, 0x7054,
+	0x2060, 0x1078, 0x358d, 0x0c7f, 0x007c, 0x6018, 0x789a, 0x78a4,
+	0xa084, 0xfff0, 0x78a6, 0x6012, 0x7884, 0xa084, 0xfff0, 0x7886,
+	0x007c, 0xa282, 0x0002, 0x00c0, 0x369d, 0x7aa8, 0x6920, 0xa18d,
+	0x0080, 0x6922, 0xa184, 0x0200, 0x0040, 0x35e2, 0xa18c, 0xfdff,
+	0x6922, 0xa294, 0x00ff, 0xa282, 0x0002, 0x00c8, 0x369d, 0x1078,
+	0x362b, 0x1078, 0x3586, 0xa980, 0x0001, 0x200c, 0x1078, 0x37eb,
+	0x1078, 0x34f1, 0x88ff, 0x0040, 0x35d5, 0x789b, 0x0060, 0x2800,
+	0x78aa, 0x7e58, 0xa6b5, 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0,
+	0x35cf, 0x782b, 0x3008, 0x781b, 0x0056, 0x0078, 0x2459, 0x782b,
+	0x3008, 0x781b, 0x0065, 0x0078, 0x2459, 0x7e58, 0xa684, 0x0400,
+	0x00c0, 0x35de, 0x781b, 0x0058, 0x0078, 0x2459, 0x781b, 0x0065,
+	0x0078, 0x2459, 0xa282, 0x0002, 0x00c8, 0x35ea, 0xa284, 0x0001,
+	0x0040, 0x35f4, 0x7154, 0xa188, 0x0000, 0x210c, 0xa18c, 0x2000,
+	0x00c0, 0x35f4, 0x2011, 0x0000, 0x1078, 0x370d, 0x1078, 0x362b,
+	0x1078, 0x3586, 0x7858, 0xa085, 0x0004, 0x785a, 0x782b, 0x3008,
+	0x781b, 0x0065, 0x0078, 0x2459, 0x0c7e, 0x027e, 0x2960, 0x6000,
+	0x2011, 0x0001, 0xa084, 0x2000, 0x00c0, 0x361b, 0x6014, 0xa084,
+	0x0040, 0x00c0, 0x3619, 0xa18c, 0xffef, 0x6106, 0xa006, 0x0078,
+	0x3628, 0x2011, 0x0000, 0x78ab, 0x0001, 0x78ab, 0x0002, 0x78ab,
+	0x0003, 0x7aaa, 0xa8c0, 0x0004, 0x6820, 0xa085, 0x0200, 0x6822,
+	0x027f, 0x0c7f, 0x007c, 0x0c7e, 0x7054, 0x2060, 0x1078, 0x3632,
+	0x0c7f, 0x007c, 0x82ff, 0x0040, 0x3637, 0x2011, 0x0040, 0x6018,
+	0xa080, 0x0002, 0x789a, 0x78a4, 0xa084, 0xffbf, 0xa205, 0x78a6,
+	0x788a, 0x6016, 0x78ec, 0xd08c, 0x00c0, 0x364a, 0x6004, 0xa084,
+	0xffef, 0x6006, 0x007c, 0x007e, 0x7000, 0xa086, 0x0003, 0x0040,
+	0x3654, 0x007f, 0x0078, 0x3657, 0x007f, 0x0078, 0x3699, 0xa684,
+	0x0020, 0x0040, 0x3699, 0x7888, 0xa084, 0x0040, 0x0040, 0x3699,
+	0x7bb8, 0xa384, 0x003f, 0x831b, 0x00c8, 0x3667, 0x8000, 0xa005,
+	0x0040, 0x367d, 0x831b, 0x00c8, 0x3670, 0x8001, 0x0040, 0x3695,
+	0xa684, 0x4000, 0x0040, 0x367d, 0x78b8, 0x801b, 0x00c8, 0x3679,
+	0x8000, 0xa084, 0x003f, 0x00c0, 0x3695, 0xa6b4, 0xbfff, 0x7e5a,
+	0x79d8, 0x7adc, 0x2001, 0x0001, 0xa108, 0x00c8, 0x3689, 0xa291,
+	0x0000, 0x79d2, 0x79da, 0x7ad6, 0x7ade, 0x1078, 0x4b30, 0x781b,
+	0x0064, 0x1078, 0x49b5, 0x0078, 0x2459, 0x781b, 0x0064, 0x0078,
+	0x2459, 0x781b, 0x0065, 0x0078, 0x2459, 0x1078, 0x36d5, 0x782b,
+	0x3008, 0x781b, 0x0065, 0x0078, 0x2459, 0x1078, 0x36c1, 0x782b,
+	0x3008, 0x781b, 0x0065, 0x0078, 0x2459, 0x6827, 0x0002, 0x1078,
+	0x36c9, 0x78e4, 0xa084, 0x0030, 0x0040, 0x2482, 0x78ec, 0xa084,
+	0x0003, 0x0040, 0x2482, 0x782b, 0x3008, 0x781b, 0x0065, 0x0078,
+	0x2459, 0x2001, 0x0005, 0x0078, 0x36d7, 0x2001, 0x000c, 0x0078,
+	0x36d7, 0x2001, 0x0006, 0x0078, 0x36d7, 0x2001, 0x000d, 0x0078,
+	0x36d7, 0x2001, 0x0009, 0x0078, 0x36d7, 0x2001, 0x0007, 0x789b,
+	0x0010, 0x78aa, 0x789b, 0x0060, 0x78ab, 0x0001, 0xa6b5, 0x0004,
+	0x7e5a, 0x007c, 0x077e, 0x873f, 0xa7bc, 0x000f, 0x873b, 0x873b,
+	0x8703, 0xa0e0, 0x5380, 0xa7b8, 0x0020, 0x7f9a, 0x79a4, 0xa184,
+	0x000f, 0x0040, 0x36fb, 0xa184, 0xfff0, 0x78a6, 0x6012, 0x6004,
+	0xa085, 0x0008, 0x6006, 0x8738, 0x8738, 0x7f9a, 0x79a4, 0xa184,
+	0x0040, 0x0040, 0x370b, 0xa184, 0xffbf, 0x78a6, 0x6016, 0x6004,
+	0xa085, 0x0010, 0x6006, 0x077f, 0x007c, 0x789b, 0x0010, 0x78ab,
+	0x0001, 0x78ab, 0x0002, 0x78ab, 0x0003, 0x7aaa, 0x789b, 0x0060,
+	0x78ab, 0x0004, 0x007c, 0x2021, 0x0000, 0x2029, 0x0032, 0x789b,
+	0x0010, 0x78ab, 0x0001, 0x78ab, 0x0003, 0x78ab, 0x0001, 0x7daa,
+	0x7caa, 0x789b, 0x0060, 0x78ab, 0x0005, 0x007c, 0x157e, 0x8007,
+	0xa084, 0x00ff, 0x8003, 0x8003, 0xa080, 0x0020, 0x789a, 0x79a4,
+	0xa18c, 0xfff0, 0x2001, 0x5146, 0x2004, 0xa082, 0x0028, 0x0040,
+	0x3749, 0x2021, 0x37d2, 0x2019, 0x0014, 0x20a9, 0x000c, 0x0078,
+	0x374f, 0x2021, 0x37de, 0x2019, 0x0019, 0x20a9, 0x000d, 0x2011,
+	0x0064, 0x2404, 0xa084, 0xfff0, 0xa106, 0x0040, 0x375e, 0x8420,
+	0x2300, 0xa210, 0x0070, 0x375e, 0x0078, 0x3751, 0x157f, 0x007c,
+	0x157e, 0x2009, 0x5146, 0x210c, 0xa182, 0x0032, 0x0048, 0x3774,
+	0x0040, 0x3778, 0x2009, 0x37c4, 0x2019, 0x0011, 0x20a9, 0x000e,
+	0x2011, 0x0032, 0x0078, 0x378a, 0xa182, 0x0028, 0x0040, 0x3782,
+	0x2009, 0x37d2, 0x2019, 0x0014, 0x20a9, 0x000c, 0x2011, 0x0064,
+	0x0078, 0x378a, 0x2009, 0x37de, 0x2019, 0x0019, 0x20a9, 0x000d,
+	0x2011, 0x0064, 0x2200, 0xa502, 0x0040, 0x379a, 0x0048, 0x379a,
+	0x8108, 0x2300, 0xa210, 0x0070, 0x3797, 0x0078, 0x378a, 0x157f,
+	0xa006, 0x007c, 0x157f, 0xa582, 0x0064, 0x00c8, 0x37a9, 0x7808,
+	0xa085, 0x0070, 0x780a, 0x7044, 0xa085, 0x0070, 0x7046, 0x0078,
+	0x37a9, 0x78ec, 0xa084, 0x0300, 0x0040, 0x37b1, 0x2104, 0x0078,
+	0x37c2, 0x2104, 0xa09e, 0x1102, 0x00c0, 0x37c2, 0x2001, 0x04fd,
+	0x2004, 0xa082, 0x0005, 0x0048, 0x37c1, 0x2001, 0x1201, 0x0078,
+	0x37c2, 0x2104, 0xa005, 0x007c, 0x1102, 0x3002, 0x3202, 0x4203,
+	0x4403, 0x5404, 0x5604, 0x6605, 0x6805, 0x7806, 0x7a06, 0x0c07,
+	0x0c07, 0x0e07, 0x3202, 0x4202, 0x5202, 0x6202, 0x7202, 0x6605,
+	0x7605, 0x7805, 0x7a05, 0x7c05, 0x7e05, 0x7f05, 0x2202, 0x3202,
+	0x4202, 0x5202, 0x5404, 0x6404, 0x7404, 0x7604, 0x7804, 0x7a04,
+	0x7c04, 0x7e04, 0x7f04, 0x789b, 0x0010, 0xa046, 0x007c, 0xa784,
+	0x0f00, 0x800b, 0xa784, 0x001f, 0x8003, 0x8003, 0x8003, 0x8003,
+	0xa105, 0xa0e0, 0x5400, 0x007c, 0x79d8, 0x7adc, 0x78d0, 0x801b,
+	0x00c8, 0x3803, 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, 0x0000,
+	0x007c, 0x0f7e, 0x2079, 0x0100, 0x2009, 0x5140, 0x2091, 0x8000,
+	0x2104, 0x0079, 0x3813, 0x3849, 0x381d, 0x381d, 0x381d, 0x381d,
+	0x381d, 0x381d, 0x384d, 0x1078, 0x23eb, 0x784b, 0x0004, 0x7848,
+	0xa084, 0x0004, 0x00c0, 0x381f, 0x784b, 0x0008, 0x7848, 0xa084,
+	0x0008, 0x00c0, 0x3826, 0x68b4, 0xa085, 0x4000, 0x68b6, 0x7858,
+	0xa085, 0x4000, 0x785a, 0x7830, 0xa084, 0x0080, 0x00c0, 0x3849,
+	0x0018, 0x3849, 0x681c, 0xa084, 0x0020, 0x00c0, 0x3847, 0x0e7e,
+	0x2071, 0x5140, 0x1078, 0x389c, 0x0e7f, 0x0078, 0x3849, 0x781b,
+	0x00cd, 0x2091, 0x8001, 0x0f7f, 0x007c, 0x70b3, 0x0000, 0x1078,
+	0x3a76, 0x0078, 0x3849, 0x0c7e, 0x6814, 0x8007, 0xa084, 0x000f,
+	0x8003, 0x8003, 0x8003, 0xa0e0, 0x5380, 0x6004, 0xa084, 0x000a,
+	0x00c0, 0x3886, 0x6108, 0xa194, 0xff00, 0x0040, 0x3886, 0xa18c,
+	0x00ff, 0x2001, 0x0019, 0xa106, 0x0040, 0x3875, 0x2001, 0x0032,
+	0xa106, 0x0040, 0x3879, 0x0078, 0x387d, 0x2009, 0x0020, 0x0078,
+	0x387f, 0x2009, 0x003f, 0x0078, 0x387f, 0x2011, 0x0000, 0x2100,
+	0xa205, 0x600a, 0x6004, 0xa085, 0x0002, 0x6006, 0x0c7f, 0x007c,
+	0x781b, 0x0065, 0x0078, 0x2459, 0x782b, 0x3008, 0x781b, 0x0065,
+	0x0078, 0x2459, 0x781b, 0x0058, 0x0078, 0x2459, 0x782b, 0x3008,
+	0x781b, 0x0056, 0x0078, 0x2459, 0x2009, 0x5120, 0x210c, 0xa186,
+	0x0000, 0x0040, 0x38b0, 0xa186, 0x0001, 0x0040, 0x38b3, 0x2009,
+	0x5138, 0x200b, 0x000b, 0x706f, 0x0001, 0x781b, 0x0048, 0x007c,
+	0x781b, 0x00c7, 0x007c, 0x2009, 0x5138, 0x200b, 0x000a, 0x007c,
+	0x2009, 0x5120, 0x210c, 0xa186, 0x0000, 0x0040, 0x38d3, 0xa186,
+	0x0001, 0x0040, 0x38cd, 0x2009, 0x5138, 0x200b, 0x000b, 0x706f,
+	0x0001, 0x781b, 0x0048, 0x0078, 0x2459, 0x2009, 0x5138, 0x200b,
+	0x000a, 0x0078, 0x2459, 0x782b, 0x3008, 0x781b, 0x00c7, 0x0078,
+	0x2459, 0x781b, 0x00cd, 0x0078, 0x2459, 0x782b, 0x3008, 0x781b,
+	0x00cd, 0x0078, 0x2459, 0x781b, 0x008e, 0x0078, 0x2459, 0x782b,
+	0x3008, 0x781b, 0x008e, 0x0078, 0x2459, 0x6818, 0xa084, 0x8000,
+	0x0040, 0x38f4, 0x681b, 0x001d, 0x706f, 0x0001, 0x781b, 0x0048,
+	0x0078, 0x2459, 0x007e, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x3910,
+	0x7808, 0xa084, 0xfffc, 0x780a, 0x0005, 0x0005, 0x0005, 0x0005,
+	0x78ec, 0xa084, 0x0021, 0x0040, 0x3910, 0x7044, 0x780a, 0xa005,
+	0x007f, 0x007c, 0x7044, 0xa085, 0x0002, 0x7046, 0x780a, 0x007c,
+	0x007e, 0x7830, 0xa084, 0x0040, 0x00c0, 0x3919, 0x0098, 0x3924,
+	0x007f, 0x789a, 0x78ac, 0x007c, 0x7808, 0xa084, 0xfffd, 0x780a,
+	0x0005, 0x0005, 0x0005, 0x0005, 0x78ec, 0xa084, 0x0021, 0x0040,
+	0x3933, 0x0098, 0x3931, 0x007f, 0x789a, 0x78ac, 0x007e, 0x7044,
+	0x780a, 0x007f, 0x007c, 0x78ec, 0xa084, 0x0002, 0x00c0, 0x4760,
+	0xa784, 0x007d, 0x00c0, 0x3947, 0x2700, 0x1078, 0x23eb, 0xa784,
+	0x0001, 0x00c0, 0x2f6d, 0xa784, 0x0070, 0x0040, 0x3957, 0x0c7e,
+	0x2d60, 0x2f68, 0x1078, 0x2396, 0x2d78, 0x2c68, 0x0c7f, 0xa784,
+	0x0008, 0x0040, 0x3964, 0x784b, 0x0008, 0x78ec, 0xa084, 0x0003,
+	0x0040, 0x2482, 0x0078, 0x3888, 0xa784, 0x0004, 0x0040, 0x3997,
+	0x78b8, 0xa084, 0x4001, 0x0040, 0x3997, 0x784b, 0x0008, 0x78ec,
+	0xa084, 0x0003, 0x0040, 0x2482, 0x78e4, 0xa084, 0x0007, 0xa086,
+	0x0001, 0x00c0, 0x3997, 0x78c0, 0xa085, 0x4800, 0x2030, 0x7e5a,
+	0x781b, 0x00cd, 0x0078, 0x2459, 0x784b, 0x0008, 0x6818, 0xa084,
+	0x8000, 0x0040, 0x3993, 0x681b, 0x0015, 0xa684, 0x4000, 0x0040,
+	0x3993, 0x681b, 0x0007, 0x1078, 0x389c, 0x0078, 0x2459, 0x681b,
+	0x0003, 0x7858, 0xa084, 0x3f00, 0x681e, 0x682f, 0x0000, 0x6833,
+	0x0000, 0x784b, 0x0008, 0x78ec, 0xa084, 0x0003, 0x0040, 0x2965,
+	0x0018, 0x2459, 0x0078, 0x36a5, 0x6b14, 0x8307, 0xa084, 0x000f,
+	0x8003, 0x8003, 0x8003, 0xa080, 0x5380, 0x2060, 0x2048, 0x7056,
+	0x6000, 0x705a, 0x6004, 0x705e, 0x2a60, 0x007c, 0x0079, 0x39c0,
+	0x39c8, 0x39c9, 0x39c8, 0x39cb, 0x39c8, 0x39c8, 0x39c8, 0x39d0,
+	0x007c, 0x1078, 0x33ee, 0x1078, 0x4776, 0x7038, 0x600a, 0x007c,
+	0x70a0, 0xa005, 0x0040, 0x39dd, 0x2068, 0x1078, 0x1b62, 0x1078,
+	0x46f8, 0x1078, 0x46ff, 0x70a3, 0x0000, 0x007c, 0x0e7e, 0x2091,
+	0x8000, 0x2071, 0x5140, 0x7000, 0xa086, 0x0007, 0x00c0, 0x39f4,
+	0x6110, 0x70bc, 0xa106, 0x00c0, 0x39f4, 0x0e7f, 0x1078, 0x1b6f,
+	0x1078, 0x39fa, 0xa006, 0x007c, 0x2091, 0x8001, 0x0e7f, 0xa085,
+	0x0001, 0x007c, 0x0f7e, 0x0e7e, 0x2071, 0x5140, 0x0078, 0x21fa,
+	0x785b, 0x0000, 0x70af, 0x000e, 0x2009, 0x0100, 0x017e, 0x70a0,
+	0xa06d, 0x0040, 0x3a0f, 0x70a3, 0x0000, 0x0078, 0x3a15, 0x70b3,
+	0x0000, 0x1078, 0x1b8b, 0x0040, 0x3a1b, 0x70ac, 0x6826, 0x1078,
+	0x3af8, 0x0078, 0x3a0f, 0x017f, 0x157e, 0x0c7e, 0x0d7e, 0x20a9,
+	0x0008, 0x2061, 0x7510, 0x6000, 0xa105, 0x6002, 0x601c, 0xa06d,
+	0x0040, 0x3a33, 0x6800, 0x601e, 0x1078, 0x195a, 0x6008, 0x8000,
+	0x600a, 0x0078, 0x3a26, 0x6018, 0xa06d, 0x0040, 0x3a3d, 0x6800,
+	0x601a, 0x1078, 0x195a, 0x0078, 0x3a33, 0xace0, 0x0008, 0x0070,
+	0x3a43, 0x0078, 0x3a23, 0x709c, 0xa084, 0x8000, 0x0040, 0x3a4a,
+	0x1078, 0x3b72, 0x0d7f, 0x0c7f, 0x157f, 0x007c, 0x127e, 0x2091,
+	0x2300, 0x6804, 0xa084, 0x000f, 0x0079, 0x3a56, 0x3a66, 0x3a66,
+	0x3a66, 0x3a66, 0x3a66, 0x3a66, 0x3a68, 0x3a6e, 0x3a66, 0x3a66,
+	0x3a66, 0x3a66, 0x3a66, 0x3a70, 0x3a66, 0x3a68, 0x1078, 0x23eb,
+	0x1078, 0x44d0, 0x1078, 0x195a, 0x0078, 0x3a74, 0x6827, 0x000b,
+	0x1078, 0x44d0, 0x1078, 0x3af8, 0x127f, 0x007c, 0x127e, 0x2091,
+	0x2300, 0x0098, 0x3a92, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x3a92,
+	0x0d7e, 0x1078, 0x4708, 0x2d00, 0x682e, 0x2009, 0x0004, 0x2001,
+	0x0000, 0x6827, 0x0084, 0x1078, 0x46c1, 0x1078, 0x3af8, 0x0d7f,
+	0x0078, 0x3ac6, 0x7948, 0xa185, 0x4000, 0x784a, 0x0098, 0x3a9b,
+	0x794a, 0x0078, 0x3a80, 0x7828, 0xa086, 0x1834, 0x00c0, 0x3aa4,
+	0xa185, 0x0004, 0x0078, 0x3aab, 0x7828, 0xa086, 0x1814, 0x00c0,
+	0x3a98, 0xa185, 0x000c, 0x784a, 0x789b, 0x000e, 0x78ab, 0x0002,
+	0x7858, 0xa084, 0x00ff, 0xa085, 0x0400, 0x785a, 0x70b4, 0xa080,
+	0x0091, 0x781a, 0x6827, 0x0284, 0x682c, 0x6836, 0x6830, 0x683a,
+	0x2009, 0x0004, 0x2001, 0x0000, 0x1078, 0x46c1, 0x127f, 0x007c,
+	0x0d7e, 0x6b14, 0x1078, 0x1bfd, 0x0040, 0x3ad5, 0x2068, 0x6827,
+	0x0002, 0x1078, 0x3af8, 0x0078, 0x3aca, 0x0d7f, 0x007c, 0x0d7e,
+	0x6b14, 0x6c28, 0xa4a4, 0x00ff, 0x1078, 0x1b9b, 0x0040, 0x3ae5,
+	0x2068, 0x6827, 0x0002, 0x1078, 0x3af8, 0x0d7f, 0x007c, 0x0d7e,
+	0x6b14, 0xa39c, 0x00ff, 0x1078, 0x1bce, 0x0040, 0x3af6, 0x2068,
+	0x6827, 0x0002, 0x1078, 0x3af8, 0x0078, 0x3aeb, 0x0d7f, 0x007c,
+	0x0c7e, 0x6914, 0x1078, 0x3b69, 0x6904, 0xa18c, 0x00ff, 0xa186,
+	0x0006, 0x0040, 0x3b13, 0xa186, 0x000d, 0x0040, 0x3b32, 0xa186,
+	0x0017, 0x00c0, 0x3b0f, 0x1078, 0x195a, 0x0078, 0x3b11, 0x1078,
+	0x1c72, 0x0c7f, 0x007c, 0x6004, 0x8001, 0x0048, 0x3b30, 0x6006,
+	0x2009, 0x0000, 0xa684, 0x0001, 0x00c0, 0x3b20, 0xa18d, 0x8000,
+	0xa684, 0x0004, 0x0040, 0x3b26, 0xa18d, 0x0002, 0x691e, 0x6823,
+	0x0000, 0x7104, 0x810f, 0x6818, 0xa105, 0x681a, 0x0078, 0x3b0f,
+	0x1078, 0x23eb, 0x6018, 0xa005, 0x00c0, 0x3b41, 0x6008, 0x8001,
+	0x0048, 0x3b41, 0x600a, 0x601c, 0x6802, 0x2d00, 0x601e, 0x0078,
+	0x3b57, 0xac88, 0x0006, 0x2104, 0xa005, 0x0040, 0x3b4a, 0x2008,
+	0x0078, 0x3b43, 0x6802, 0x2d0a, 0x6008, 0x8001, 0x0048, 0x3b11,
+	0x600a, 0x6018, 0x2068, 0x6800, 0x601a, 0x0078, 0x3b3b, 0x157e,
+	0x137e, 0x147e, 0x0c7e, 0x0d7e, 0x1078, 0x1937, 0x2da0, 0x137f,
+	0x20a9, 0x0031, 0x53a3, 0x0c7f, 0x147f, 0x137f, 0x157f, 0x0078,
+	0x3b0f, 0xa184, 0x001f, 0x8003, 0x8003, 0x8003, 0xa080, 0x7510,
+	0x2060, 0x007c, 0x2019, 0x5151, 0x2304, 0xa085, 0x0001, 0x201a,
+	0x2019, 0x0102, 0x2304, 0xa085, 0x0001, 0x201a, 0x007c, 0x2019,
+	0x5151, 0x2304, 0xa084, 0xfffe, 0x201a, 0x2019, 0x0102, 0x2304,
+	0xa084, 0xfffe, 0x201a, 0x007c, 0x7990, 0xa18c, 0xfff8, 0x7992,
+	0x70b4, 0xa080, 0x00dd, 0x781a, 0x0078, 0x2459, 0x70a3, 0x0000,
+	0x7003, 0x0000, 0x7043, 0x0001, 0x7037, 0x0000, 0x0018, 0x2410,
+	0x1078, 0x1b8b, 0x0040, 0x3bc7, 0x2009, 0x510f, 0x200b, 0x0000,
+	0x68bc, 0x2060, 0x6100, 0xa184, 0x0300, 0x0040, 0x3bbb, 0x6827,
+	0x000e, 0xa084, 0x0200, 0x0040, 0x3bb7, 0x6827, 0x0017, 0x1078,
+	0x3af8, 0x0078, 0x3b96, 0x7000, 0xa086, 0x0007, 0x00c0, 0x3c29,
+	0x2d00, 0x70a2, 0xad80, 0x000f, 0x7036, 0x0078, 0x3bce, 0x7040,
+	0xa086, 0x0001, 0x0040, 0x2492, 0x0078, 0x2459, 0x2031, 0x0000,
+	0x691c, 0xa184, 0x0002, 0x0040, 0x3bd7, 0xa6b5, 0x0004, 0xa184,
+	0x00c0, 0x8003, 0x8003, 0x8007, 0xa080, 0x3cc2, 0x2004, 0xa635,
+	0x6820, 0xa084, 0x0400, 0x0040, 0x3bef, 0x789b, 0x0018, 0x78ab,
+	0x0003, 0x789b, 0x0081, 0x78ab, 0x0001, 0xa6b5, 0x1000, 0x6820,
+	0xa084, 0x8000, 0x00c0, 0x3bfd, 0x681c, 0xa084, 0x8000, 0x00c0,
+	0x3c04, 0xa6b5, 0x0800, 0x0078, 0x3c04, 0xa6b5, 0x0400, 0x789b,
+	0x000e, 0x6824, 0x8007, 0x78aa, 0x6820, 0xa084, 0x0100, 0x0040,
+	0x3c0b, 0xa6b5, 0x4000, 0xa684, 0x0200, 0x0040, 0x3c25, 0x682c,
+	0x78d2, 0x6830, 0x78d6, 0xa684, 0x0100, 0x0040, 0x3c23, 0x682c,
+	0xa084, 0x0001, 0x0040, 0x3c23, 0x7888, 0xa084, 0x0040, 0x0040,
+	0x3c23, 0xa6b5, 0x8000, 0x1078, 0x46f0, 0x7e5a, 0x6eb6, 0x0078,
+	0x4727, 0x1078, 0x38fa, 0x00c0, 0x3cbc, 0x702c, 0x8004, 0x0048,
+	0x3c37, 0x2019, 0x4e3b, 0x1078, 0x2276, 0x702f, 0x0001, 0x2041,
+	0x0001, 0x2031, 0x1000, 0x789b, 0x0018, 0x6814, 0xa084, 0x001f,
+	0xa085, 0x0080, 0x78aa, 0x691c, 0xa184, 0x0002, 0x0040, 0x3c50,
+	0xa6b5, 0x0004, 0x78ab, 0x0020, 0x6828, 0x78aa, 0xa8c0, 0x0002,
+	0x681c, 0xd0f4, 0x0040, 0x3c59, 0x2c50, 0x1078, 0x39ac, 0x1078,
+	0x45ff, 0x6820, 0xa084, 0x8000, 0x0040, 0x3c67, 0xa6b5, 0x0400,
+	0x789b, 0x000e, 0x6824, 0x8007, 0x78aa, 0x0078, 0x3c6e, 0x681c,
+	0xa084, 0x8000, 0x00c0, 0x3c6e, 0xa6b5, 0x0800, 0x6820, 0xa084,
+	0x0100, 0x0040, 0x3c75, 0xa6b5, 0x4000, 0x681c, 0xa084, 0x00c0,
+	0x8003, 0x8003, 0x8007, 0xa080, 0x3cc2, 0x2004, 0xa635, 0xa684,
+	0x0100, 0x0040, 0x3c8f, 0x682c, 0xa084, 0x0001, 0x0040, 0x3c8f,
+	0x7888, 0xa084, 0x0040, 0x0040, 0x3c8f, 0xa6b5, 0x8000, 0x789b,
+	0x007e, 0x7eae, 0x6eb6, 0x6814, 0x8007, 0x78aa, 0x7882, 0x2810,
+	0x7aaa, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x3cbc, 0x0018, 0x3cbc,
+	0x70b4, 0xa080, 0x00e2, 0x781a, 0x1078, 0x3912, 0xa684, 0x0200,
+	0x0040, 0x3cb0, 0x682c, 0x78d2, 0x6830, 0x78d6, 0x1078, 0x46f0,
+	0x2d00, 0x70a2, 0x704a, 0x6810, 0x70be, 0x7003, 0x0007, 0xad80,
+	0x000f, 0x7036, 0x0078, 0x2459, 0x1078, 0x1b62, 0x1078, 0x3912,
+	0x0078, 0x2459, 0x0000, 0x0300, 0x0200, 0x0000, 0x1078, 0x23eb,
+	0x2300, 0x0079, 0x3ccb, 0x3cce, 0x3cce, 0x3cd0, 0x1078, 0x23eb,
+	0x1078, 0x46ff, 0x6924, 0xa184, 0x00ff, 0xa086, 0x000a, 0x0040,
+	0x3ce2, 0xa184, 0xff00, 0xa085, 0x000a, 0x6826, 0x1078, 0x1b62,
+	0x0078, 0x3b96, 0x2001, 0x000a, 0x1078, 0x4691, 0x0078, 0x3b96,
+	0xa282, 0x0005, 0x0050, 0x3cee, 0x1078, 0x23eb, 0x7000, 0xa084,
+	0x0007, 0x10c0, 0x39be, 0x1078, 0x1937, 0x00c0, 0x3d0d, 0xa684,
+	0x0004, 0x0040, 0x3cff, 0x2001, 0x2800, 0x0078, 0x3d01, 0x2001,
+	0x0800, 0x71b4, 0xa188, 0x0091, 0x789b, 0x000e, 0x78aa, 0x2031,
+	0x0400, 0x7e5a, 0x791a, 0x0078, 0x2459, 0x6807, 0x0106, 0x680b,
+	0x0000, 0x689f, 0x0000, 0x6827, 0x0000, 0xa386, 0x0002, 0x00c0,
+	0x3d2e, 0xa286, 0x0002, 0x00c0, 0x3d2e, 0x78a0, 0xa005, 0x00c0,
+	0x3d2e, 0xa484, 0x8000, 0x00c0, 0x3d2e, 0x78e4, 0xa084, 0x0008,
+	0x0040, 0x3d2e, 0xa6b5, 0x0008, 0x2019, 0x0000, 0x1078, 0x411e,
+	0x2d00, 0x70a2, 0x704a, 0x7003, 0x0007, 0x7037, 0x0000, 0x6824,
+	0xa084, 0x0080, 0x0040, 0x3d40, 0x1078, 0x41d0, 0x0078, 0x2459,
+	0x2300, 0x0079, 0x3d43, 0x3d46, 0x3dc7, 0x3de6, 0x2200, 0x0079,
+	0x3d49, 0x3d4e, 0x3d5e, 0x3d84, 0x3d90, 0x3db3, 0x2029, 0x0001,
+	0xa026, 0x2011, 0x0000, 0x1078, 0x42f1, 0x0079, 0x3d57, 0x3d5c,
+	0x2459, 0x3b96, 0x3d5c, 0x3d5c, 0x1078, 0x23eb, 0x7990, 0xa18c,
+	0x0007, 0x00c0, 0x3d65, 0x2009, 0x0008, 0x2011, 0x0001, 0xa684,
+	0x0004, 0x0040, 0x3d6d, 0x2011, 0x0003, 0x2220, 0xa12a, 0x2011,
+	0x0001, 0x1078, 0x42f1, 0x0079, 0x3d75, 0x3d7a, 0x2459, 0x3b96,
+	0x3d82, 0x3d7c, 0x0078, 0x472d, 0x70ab, 0x3d80, 0x0078, 0x2459,
+	0x0078, 0x3d7a, 0x1078, 0x23eb, 0xa684, 0x0010, 0x0040, 0x3d8e,
+	0x1078, 0x419f, 0x0040, 0x3d8e, 0x0078, 0x2459, 0x0078, 0x420c,
+	0x6000, 0xa084, 0x0002, 0x0040, 0x3dad, 0x70b4, 0xa080, 0x00d2,
+	0x781a, 0x0d7e, 0x1078, 0x4708, 0x2d00, 0x682e, 0x6827, 0x0000,
+	0x1078, 0x3af8, 0x0d7f, 0x1078, 0x195a, 0x7003, 0x0000, 0x7037,
+	0x0000, 0x704b, 0x0000, 0x0078, 0x3b96, 0xa684, 0x0004, 0x00c0,
+	0x3db3, 0x0078, 0x472d, 0x6000, 0xa084, 0x0004, 0x00c0, 0x3dc5,
+	0x6000, 0xa084, 0x0001, 0x0040, 0x3dc5, 0x70ab, 0x3dc5, 0x2001,
+	0x0007, 0x1078, 0x4689, 0x0078, 0x4733, 0x0078, 0x472d, 0x2200,
+	0x0079, 0x3dca, 0x3dcf, 0x3dcf, 0x3dcf, 0x3dd1, 0x3dcf, 0x1078,
+	0x23eb, 0x70a7, 0x3dd5, 0x0078, 0x4739, 0x2011, 0x0018, 0x1078,
+	0x42eb, 0x0079, 0x3ddb, 0x3de0, 0x2459, 0x3b96, 0x3de2, 0x3de4,
+	0x1078, 0x23eb, 0x1078, 0x23eb, 0x1078, 0x23eb, 0x2200, 0x0079,
+	0x3de9, 0x3dee, 0x3df0, 0x3df0, 0x3dee, 0x3dee, 0x1078, 0x23eb,
+	0x78e4, 0xa084, 0x0008, 0x0040, 0x3e05, 0x70a7, 0x3df9, 0x0078,
+	0x4739, 0x2011, 0x0004, 0x1078, 0x42eb, 0x0079, 0x3dff, 0x3e05,
+	0x2459, 0x3b96, 0x3e05, 0x3e0f, 0x3e13, 0x70ab, 0x3e0d, 0x2001,
+	0x0003, 0x1078, 0x4689, 0x0078, 0x4733, 0x0078, 0x472d, 0x70ab,
+	0x3e05, 0x0078, 0x2459, 0x70ab, 0x3e17, 0x0078, 0x2459, 0x0078,
+	0x3e0d, 0xa282, 0x0003, 0x0050, 0x3e1f, 0x1078, 0x23eb, 0xa386,
+	0x0002, 0x00c0, 0x3e38, 0xa286, 0x0002, 0x00c0, 0x3e3e, 0x78a0,
+	0xa005, 0x00c0, 0x3e3e, 0xa484, 0x8000, 0x00c0, 0x3e3e, 0x78e4,
+	0xa084, 0x0008, 0x0040, 0x3e38, 0xa6b5, 0x0008, 0x2019, 0x0000,
+	0xa684, 0x0008, 0x0040, 0x3e3e, 0x1078, 0x417c, 0x6810, 0x70be,
+	0x7003, 0x0007, 0x2300, 0x0079, 0x3e45, 0x3e48, 0x3e75, 0x3e7d,
+	0x2200, 0x0079, 0x3e4b, 0x3e50, 0x3e4e, 0x3e69, 0x1078, 0x23eb,
+	0x7990, 0xa1ac, 0x0007, 0xa026, 0x2011, 0x0001, 0x1078, 0x42f1,
+	0x0079, 0x3e5a, 0x3e5f, 0x2459, 0x3b96, 0x3e67, 0x3e61, 0x0078,
+	0x472d, 0x70ab, 0x3e65, 0x0078, 0x2459, 0x0078, 0x3e5f, 0x1078,
+	0x23eb, 0xa684, 0x0010, 0x0040, 0x3e73, 0x1078, 0x419f, 0x0040,
+	0x3e73, 0x0078, 0x2459, 0x0078, 0x420c, 0x2200, 0x0079, 0x3e78,
+	0x3e7b, 0x3e7b, 0x3e7b, 0x1078, 0x23eb, 0x2200, 0x0079, 0x3e80,
+	0x3e83, 0x3e85, 0x3e85, 0x1078, 0x23eb, 0x78e4, 0xa084, 0x0008,
+	0x0040, 0x3e9a, 0x70a7, 0x3e8e, 0x0078, 0x4739, 0x2011, 0x0004,
+	0x1078, 0x42eb, 0x0079, 0x3e94, 0x3e9a, 0x2459, 0x3b96, 0x3e9a,
+	0x3ea4, 0x3ea8, 0x70ab, 0x3ea2, 0x2001, 0x0003, 0x1078, 0x4689,
+	0x0078, 0x4733, 0x0078, 0x472d, 0x70ab, 0x3e9a, 0x0078, 0x2459,
+	0x70ab, 0x3eac, 0x0078, 0x2459, 0x0078, 0x3ea2, 0x2300, 0x0079,
+	0x3eb1, 0x3eb6, 0x3eb8, 0x3eb4, 0x1078, 0x23eb, 0x70a4, 0x007a,
+	0x70a4, 0x007a, 0xa282, 0x0002, 0x0050, 0x3ec0, 0x1078, 0x23eb,
+	0xa684, 0x0200, 0x0040, 0x3eca, 0x1078, 0x46f8, 0x1078, 0x42d3,
+	0x1078, 0x46ff, 0x2300, 0x0079, 0x3ecd, 0x3ed0, 0x3ef4, 0x3f5a,
+	0xa286, 0x0001, 0x0040, 0x3ed6, 0x1078, 0x23eb, 0xa684, 0x0200,
+	0x0040, 0x3ede, 0x1078, 0x46f8, 0x1078, 0x46ff, 0x2001, 0x0001,
+	0x1078, 0x4691, 0x78b8, 0xa084, 0xc001, 0x0040, 0x3ef0, 0x7848,
+	0xa085, 0x0008, 0x784a, 0x7848, 0xa084, 0x0008, 0x00c0, 0x3eeb,
+	0x7003, 0x0000, 0x0078, 0x3b96, 0x2200, 0x0079, 0x3ef7, 0x3ef9,
+	0x3f2a, 0x70a7, 0x3efd, 0x0078, 0x4739, 0x2011, 0x000d, 0x1078,
+	0x42eb, 0x0079, 0x3f03, 0x3f0a, 0x2459, 0x3b96, 0x3f12, 0x3f1a,
+	0x3f20, 0x3f22, 0xa6b4, 0x00ff, 0xa6b5, 0x0400, 0x6eb6, 0x7e5a,
+	0x0078, 0x4727, 0xa6b4, 0x00ff, 0xa6b5, 0x0400, 0x6eb6, 0x7e5a,
+	0x0078, 0x4727, 0x70ab, 0x3f1e, 0x0078, 0x2459, 0x0078, 0x3f0a,
+	0x1078, 0x23eb, 0x70ab, 0x3f26, 0x0078, 0x2459, 0x1078, 0x473f,
+	0x0078, 0x2459, 0x70a7, 0x3f2e, 0x0078, 0x4739, 0x2011, 0x0012,
+	0x1078, 0x42eb, 0x0079, 0x3f34, 0x3f3a, 0x2459, 0x3b96, 0x3f46,
+	0x3f4e, 0x3f54, 0xa6b4, 0x00ff, 0xa6b5, 0x0400, 0x6eb6, 0x7e5a,
+	0x70b4, 0xa080, 0x00a6, 0x781a, 0x0078, 0x2459, 0xa6b4, 0x00ff,
+	0xa6b5, 0x0400, 0x6eb6, 0x7e5a, 0x0078, 0x4727, 0x70ab, 0x3f52,
+	0x0078, 0x2459, 0x0078, 0x3f3a, 0x70ab, 0x3f58, 0x0078, 0x2459,
+	0x0078, 0x3f46, 0xa286, 0x0001, 0x0040, 0x3f60, 0x1078, 0x23eb,
+	0x70a7, 0x3f64, 0x0078, 0x4739, 0x2011, 0x0015, 0x1078, 0x42eb,
+	0x0079, 0x3f6a, 0x3f6f, 0x2459, 0x3b96, 0x3f7d, 0x3f89, 0xa6b4,
+	0x00ff, 0xa6b5, 0x0400, 0x6eb6, 0x7e5a, 0x783b, 0x1301, 0x70b4,
+	0xa080, 0x00b4, 0x781a, 0x0078, 0x2459, 0xa6b4, 0x00ff, 0xa6b5,
+	0x0400, 0x6eb6, 0x7e5a, 0x70b4, 0xa080, 0x00a6, 0x781a, 0x0078,
+	0x2459, 0x70ab, 0x3f8d, 0x0078, 0x2459, 0x0078, 0x3f6f, 0xa282,
+	0x0003, 0x0050, 0x3f95, 0x1078, 0x23eb, 0x2300, 0x0079, 0x3f98,
+	0x3f9b, 0x3fd2, 0x402d, 0xa286, 0x0001, 0x0040, 0x3fa1, 0x1078,
+	0x23eb, 0x6804, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0, 0x3fae,
+	0x1078, 0x3af8, 0x7003, 0x0000, 0x0078, 0x3b96, 0x683b, 0x0000,
+	0x6837, 0x0000, 0xa684, 0x0200, 0x0040, 0x3fbc, 0x1078, 0x46f8,
+	0x1078, 0x42d3, 0x1078, 0x46ff, 0x2001, 0x0001, 0x1078, 0x4691,
+	0x78b8, 0xa084, 0xc001, 0x0040, 0x3fce, 0x7848, 0xa085, 0x0008,
+	0x784a, 0x7848, 0xa084, 0x0008, 0x00c0, 0x3fc9, 0x7003, 0x0000,
+	0x0078, 0x3b96, 0x2200, 0x0079, 0x3fd5, 0x3fd7, 0x4008, 0x70a7,
+	0x3fdb, 0x0078, 0x4739, 0x2011, 0x000d, 0x1078, 0x42eb, 0x0079,
+	0x3fe1, 0x3fe8, 0x2459, 0x3b96, 0x3ff0, 0x3ff8, 0x3ffe, 0x4000,
+	0xa6b4, 0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x4727,
+	0xa6b4, 0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x4727,
+	0x70ab, 0x3ffc, 0x0078, 0x2459, 0x0078, 0x3fe8, 0x1078, 0x23eb,
+	0x70ab, 0x4004, 0x0078, 0x2459, 0x1078, 0x473f, 0x0078, 0x2459,
+	0x70a7, 0x400c, 0x0078, 0x4739, 0x2011, 0x0005, 0x1078, 0x42eb,
+	0x0079, 0x4012, 0x4017, 0x2459, 0x3b96, 0x401f, 0x4027, 0xa6b4,
+	0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x4727, 0xa6b4,
+	0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x4727, 0x70ab,
+	0x402b, 0x0078, 0x2459, 0x0078, 0x4017, 0xa286, 0x0001, 0x0040,
+	0x4033, 0x1078, 0x23eb, 0x70a7, 0x4037, 0x0078, 0x4739, 0x2011,
+	0x0006, 0x1078, 0x42eb, 0x0079, 0x403d, 0x4042, 0x2459, 0x3b96,
+	0x4048, 0x4052, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x4727,
+	0xa6b4, 0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0xa6b5, 0x4000, 0x7e5a,
+	0x0078, 0x4727, 0x70ab, 0x4056, 0x0078, 0x2459, 0x0078, 0x4042,
+	0x2300, 0x0079, 0x405b, 0x4060, 0x405e, 0x405e, 0x1078, 0x23eb,
+	0x1078, 0x23eb, 0x2300, 0x71a8, 0xa005, 0x017a, 0x6810, 0x70be,
+	0xa282, 0x0003, 0x0050, 0x406e, 0x1078, 0x23eb, 0x2300, 0x0079,
+	0x4071, 0x4074, 0x4082, 0x40a4, 0xa684, 0x0200, 0x0040, 0x407c,
+	0x1078, 0x46f8, 0x1078, 0x46ff, 0x2001, 0x0001, 0x1078, 0x4691,
+	0x0078, 0x2459, 0xa296, 0x0002, 0x0040, 0x408b, 0x82ff, 0x0040,
+	0x408b, 0x1078, 0x23eb, 0x70a7, 0x408f, 0x0078, 0x4739, 0x2011,
+	0x0018, 0x1078, 0x42eb, 0x0079, 0x4095, 0x409a, 0x2459, 0x3b96,
+	0x409c, 0x409e, 0x0078, 0x4727, 0x0078, 0x4727, 0x70ab, 0x40a2,
+	0x0078, 0x2459, 0x0078, 0x409a, 0x2200, 0x0079, 0x40a7, 0x40a9,
+	0x40c2, 0x70a7, 0x40ad, 0x0078, 0x4739, 0x2011, 0x0017, 0x1078,
+	0x42eb, 0x0079, 0x40b3, 0x40b8, 0x2459, 0x3b96, 0x40ba, 0x40bc,
+	0x0078, 0x4727, 0x0078, 0x4727, 0x70ab, 0x40c0, 0x0078, 0x2459,
+	0x0078, 0x40b8, 0xa484, 0x8000, 0x00c0, 0x410c, 0xa684, 0x0100,
+	0x0040, 0x40d6, 0x1078, 0x46f8, 0x1078, 0x42d3, 0x1078, 0x46ff,
+	0x7848, 0xa085, 0x000c, 0x784a, 0x0078, 0x40da, 0x78d8, 0x78d2,
+	0x78dc, 0x78d6, 0xa6b4, 0xefff, 0x7e5a, 0x70a7, 0x40e1, 0x0078,
+	0x4739, 0x2011, 0x000d, 0x1078, 0x42eb, 0x0079, 0x40e7, 0x40ee,
+	0x2459, 0x3b96, 0x40ee, 0x40fc, 0x4102, 0x4104, 0xa684, 0x0100,
+	0x0040, 0x40fa, 0x1078, 0x46b6, 0x682c, 0x78d2, 0x6830, 0x78d6,
+	0x1078, 0x46f0, 0x0078, 0x4727, 0x70ab, 0x4100, 0x0078, 0x2459,
+	0x0078, 0x40ee, 0x1078, 0x23eb, 0x70ab, 0x4108, 0x0078, 0x2459,
+	0x1078, 0x473f, 0x0078, 0x2459, 0x1078, 0x46ff, 0x70ab, 0x4116,
+	0x2001, 0x0003, 0x1078, 0x4689, 0x0078, 0x4733, 0x1078, 0x46f0,
+	0x682c, 0x78d2, 0x6830, 0x78d6, 0x0078, 0x4727, 0x70b8, 0x6812,
+	0x70be, 0x8000, 0x70ba, 0x681b, 0x0000, 0xa684, 0x0008, 0x0040,
+	0x4141, 0x157e, 0x137e, 0x147e, 0x7890, 0x8004, 0x8004, 0x8004,
+	0x8004, 0xa084, 0x000f, 0x681a, 0x80ac, 0x789b, 0x0000, 0xaf80,
+	0x002b, 0x2098, 0xad80, 0x000b, 0x20a0, 0x53a5, 0x147f, 0x137f,
+	0x157f, 0xa6c4, 0x0f00, 0xa684, 0x0002, 0x00c0, 0x4150, 0x692c,
+	0x810d, 0x810d, 0x810d, 0xa184, 0x0007, 0x2008, 0x0078, 0x415f,
+	0x789b, 0x0010, 0x79ac, 0xa184, 0x0020, 0x0040, 0x415f, 0x017e,
+	0x2009, 0x0005, 0x2001, 0x3d00, 0x1078, 0x46c1, 0x017f, 0xa184,
+	0x001f, 0xa805, 0x6816, 0x1078, 0x3b69, 0x68be, 0xa684, 0x0004,
+	0x0040, 0x4170, 0xa18c, 0xff00, 0x78a8, 0xa084, 0x00ff, 0xa105,
+	0x682a, 0xa6b4, 0x00ff, 0x6000, 0xa084, 0x0008, 0x0040, 0x417a,
+	0xa6b5, 0x4000, 0x6eb6, 0x007c, 0x157e, 0x137e, 0x147e, 0x6918,
+	0x7890, 0x8004, 0x8004, 0x8004, 0x8004, 0xa084, 0x000f, 0x007e,
+	0xa100, 0x681a, 0x007f, 0x8000, 0x8004, 0x0040, 0x419b, 0x20a8,
+	0x8104, 0xa080, 0x000b, 0xad00, 0x20a0, 0x789b, 0x0000, 0xaf80,
+	0x002b, 0x2098, 0x53a5, 0x147f, 0x137f, 0x157f, 0x007c, 0x682c,
+	0xa084, 0x0020, 0x00c0, 0x41a7, 0x620c, 0x0078, 0x41a8, 0x6210,
+	0x6b18, 0x2300, 0xa202, 0x0040, 0x41c8, 0x2018, 0xa382, 0x000e,
+	0x0048, 0x41b8, 0x0040, 0x41b8, 0x2019, 0x000e, 0x0078, 0x41bc,
+	0x7858, 0xa084, 0xffef, 0x785a, 0x783b, 0x1b01, 0x7893, 0x0000,
+	0x7ba2, 0x70b4, 0xa080, 0x008e, 0x781a, 0xa085, 0x0001, 0x007c,
+	0x7858, 0xa084, 0xffef, 0x785a, 0x7893, 0x0000, 0xa006, 0x007c,
+	0x6904, 0xa18c, 0x00ff, 0xa196, 0x0007, 0x0040, 0x41dd, 0xa196,
+	0x000f, 0x0040, 0x41dd, 0x6807, 0x0117, 0x6914, 0x1078, 0x3b69,
+	0x6100, 0x8104, 0x00c8, 0x41f8, 0x601c, 0xa005, 0x0040, 0x41ec,
+	0x2001, 0x0800, 0x0078, 0x41fa, 0x0d7e, 0x6824, 0x007e, 0x1078,
+	0x4708, 0x007f, 0x6826, 0x2d00, 0x682e, 0x1078, 0x3af8, 0x0d7f,
+	0x2001, 0x0200, 0x6826, 0x8007, 0x789b, 0x000e, 0x78aa, 0x6820,
+	0xa085, 0x8000, 0x6822, 0x2031, 0x0400, 0x6eb6, 0x7e5a, 0x71b4,
+	0xa188, 0x0091, 0x791a, 0x007c, 0xa6c4, 0x0f00, 0xa684, 0x0002,
+	0x00c0, 0x4220, 0x692c, 0x810d, 0x810d, 0x810d, 0xa184, 0x0007,
+	0x2008, 0xa805, 0x6816, 0x1078, 0x3b69, 0x68be, 0x0078, 0x4223,
+	0x6914, 0x1078, 0x3b69, 0x6100, 0x8104, 0x00c8, 0x4280, 0xa184,
+	0x0300, 0x0040, 0x422f, 0x6807, 0x0117, 0x0078, 0x424d, 0x6004,
+	0xa005, 0x00c0, 0x4256, 0x6807, 0x0117, 0x601c, 0xa005, 0x00c0,
+	0x4243, 0x0d7e, 0x1078, 0x4708, 0x6827, 0x0034, 0x2d00, 0x682e,
+	0x1078, 0x3af8, 0x0d7f, 0xa684, 0x0004, 0x0040, 0x424d, 0x2031,
+	0x0400, 0x2001, 0x2800, 0x0078, 0x4251, 0x2031, 0x0400, 0x2001,
+	0x0800, 0x71b4, 0xa188, 0x0091, 0x0078, 0x42ae, 0x6018, 0xa005,
+	0x00c0, 0x4243, 0x601c, 0xa005, 0x00c0, 0x4243, 0x689f, 0x0000,
+	0x6827, 0x003d, 0xa684, 0x0001, 0x0040, 0x42bc, 0xd694, 0x00c0,
+	0x4279, 0x6100, 0xd1d4, 0x0040, 0x4279, 0x692c, 0x81ff, 0x0040,
+	0x42bc, 0xa186, 0x0003, 0x0040, 0x42bc, 0xa186, 0x0012, 0x0040,
+	0x42bc, 0xa6b5, 0x0800, 0x71b4, 0xa188, 0x00af, 0x0078, 0x42b7,
+	0x6807, 0x0117, 0x2031, 0x0400, 0x692c, 0xa18c, 0x00ff, 0xa186,
+	0x0012, 0x00c0, 0x4291, 0x2001, 0x42c9, 0x2009, 0x0001, 0x0078,
+	0x42a2, 0xa186, 0x0003, 0x00c0, 0x429b, 0x2001, 0x42ca, 0x2009,
+	0x0012, 0x0078, 0x42a2, 0x2001, 0x0200, 0x71b4, 0xa188, 0x0091,
+	0x0078, 0x42ae, 0x1078, 0x46db, 0x78a3, 0x0000, 0x681c, 0xa085,
+	0x0040, 0x681e, 0x71b4, 0xa188, 0x00df, 0xa006, 0x6826, 0x8007,
+	0x789b, 0x000e, 0x78aa, 0x6820, 0xa085, 0x8000, 0x6822, 0x6eb6,
+	0x7e5a, 0x791a, 0x0078, 0x2459, 0x6eb6, 0x1078, 0x3af8, 0x6810,
+	0x70be, 0x7003, 0x0007, 0x70a3, 0x0000, 0x704b, 0x0000, 0x0078,
+	0x2459, 0x0023, 0x0070, 0x0005, 0x0000, 0x0a00, 0x0000, 0x0000,
+	0x0025, 0x0000, 0x0000, 0x683b, 0x0000, 0x6837, 0x0000, 0xa684,
+	0x0200, 0x0040, 0x42ea, 0x78b8, 0xa08c, 0x001f, 0xa084, 0x8000,
+	0x0040, 0x42e3, 0x8108, 0x78d8, 0xa100, 0x6836, 0x78dc, 0xa081,
+	0x0000, 0x683a, 0x007c, 0x7990, 0x810f, 0xa5ac, 0x0007, 0x2021,
+	0x0000, 0xa480, 0x0010, 0x789a, 0x79a8, 0xa18c, 0x00ff, 0xa184,
+	0x0080, 0x00c0, 0x4319, 0xa182, 0x0020, 0x00c8, 0x4337, 0xa182,
+	0x0012, 0x00c8, 0x467b, 0x2100, 0x1079, 0x4307, 0x007c, 0x467b,
+	0x44e8, 0x467b, 0x467b, 0x4344, 0x4347, 0x4381, 0x43b7, 0x43eb,
+	0x43ee, 0x467b, 0x467b, 0x43a2, 0x4412, 0x444c, 0x467b, 0x467b,
+	0x4473, 0xa184, 0x0020, 0x00c0, 0x44a7, 0xa18c, 0x001f, 0x6814,
+	0xa084, 0x001f, 0xa106, 0x0040, 0x4334, 0x70b4, 0xa080, 0x00d2,
+	0x781a, 0x2001, 0x0014, 0x1078, 0x4691, 0x1078, 0x46ff, 0x7003,
+	0x0000, 0x2001, 0x0002, 0x007c, 0x2001, 0x0000, 0x007c, 0xa182,
+	0x0024, 0x00c8, 0x467b, 0xa184, 0x0003, 0x1079, 0x4307, 0x007c,
+	0x467b, 0x467b, 0x467b, 0x467b, 0x1078, 0x467b, 0x007c, 0x2200,
+	0x0079, 0x434a, 0x4476, 0x4476, 0x436e, 0x436e, 0x436e, 0x436e,
+	0x436e, 0x436e, 0x436e, 0x436e, 0x436c, 0x436e, 0x4363, 0x436e,
+	0x436e, 0x436e, 0x436e, 0x436e, 0x4376, 0x4379, 0x4476, 0x4379,
+	0x436e, 0x436e, 0x436e, 0x0c7e, 0x077e, 0x6f14, 0x1078, 0x36e2,
+	0x077f, 0x0c7f, 0x0078, 0x436e, 0x1078, 0x458b, 0x6827, 0x02b3,
+	0x2009, 0x000b, 0x2001, 0x4800, 0x0078, 0x44aa, 0x1078, 0x4670,
+	0x007c, 0x6827, 0x0093, 0x2009, 0x000b, 0x2001, 0x4800, 0x0078,
+	0x4492, 0x2d58, 0x6804, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0,
+	0x438b, 0x6807, 0x0117, 0x6827, 0x0002, 0x1078, 0x4708, 0x6827,
+	0x0036, 0x6932, 0x2d00, 0x682e, 0x0d7e, 0x1078, 0x3ac8, 0x1078,
+	0x44d0, 0x2b68, 0x1078, 0x3af8, 0x0d7f, 0x1078, 0x3af8, 0x2001,
+	0x0002, 0x007c, 0x1078, 0x44d0, 0x2001, 0x0017, 0x1078, 0x4691,
+	0x70a3, 0x0000, 0x2009, 0x5138, 0x200b, 0x0006, 0x70af, 0x0017,
+	0x2009, 0x0200, 0x1078, 0x3a06, 0x2001, 0x0001, 0x007c, 0x2200,
+	0x0079, 0x43ba, 0x4476, 0x44a7, 0x44a7, 0x44a7, 0x43db, 0x44b7,
+	0x43e3, 0x44b7, 0x44b7, 0x44ba, 0x44ba, 0x44bf, 0x44bf, 0x43d3,
+	0x43d3, 0x44a7, 0x44a7, 0x44b7, 0x44a7, 0x43e3, 0x4476, 0x43e3,
+	0x43e3, 0x43e3, 0x43e3, 0x6827, 0x0084, 0x2009, 0x000b, 0x2001,
+	0x4300, 0x0078, 0x44c9, 0x6827, 0x000d, 0x2009, 0x000b, 0x2001,
+	0x4300, 0x0078, 0x44aa, 0x6827, 0x0093, 0x2009, 0x000b, 0x2001,
+	0x4300, 0x0078, 0x4492, 0x2001, 0x0000, 0x007c, 0x2200, 0x0079,
+	0x43f1, 0x4476, 0x440a, 0x440a, 0x440a, 0x440a, 0x44b7, 0x44b7,
+	0x44b7, 0x44b7, 0x44b7, 0x44b7, 0x44b7, 0x44b7, 0x440a, 0x440a,
+	0x440a, 0x440a, 0x44b7, 0x440a, 0x440a, 0x44b7, 0x44b7, 0x44b7,
+	0x44b7, 0x4476, 0x6827, 0x0093, 0x2009, 0x000b, 0x2001, 0x4300,
+	0x0078, 0x4492, 0xa684, 0x0004, 0x00c0, 0x4426, 0x6804, 0xa084,
+	0x00ff, 0xa086, 0x0006, 0x00c0, 0x467b, 0x1078, 0x44d0, 0x6807,
+	0x0117, 0x1078, 0x3af8, 0x2001, 0x0002, 0x007c, 0x6000, 0xa084,
+	0x0004, 0x0040, 0x467b, 0x2d58, 0x6804, 0xa084, 0x00ff, 0xa086,
+	0x0006, 0x00c0, 0x4435, 0x6807, 0x0117, 0x6827, 0x0002, 0x1078,
+	0x4708, 0x6827, 0x0036, 0x6932, 0x2d00, 0x682e, 0x0d7e, 0x1078,
+	0x3ad7, 0x1078, 0x44d0, 0x2b68, 0x1078, 0x3af8, 0x0d7f, 0x1078,
+	0x3af8, 0x2001, 0x0002, 0x007c, 0x6000, 0xa084, 0x0004, 0x0040,
+	0x467b, 0x2d58, 0x6a04, 0xa294, 0x00ff, 0xa286, 0x0006, 0x00c0,
+	0x445b, 0x6807, 0x0117, 0x6827, 0x0002, 0x2d58, 0x1078, 0x4708,
+	0x6827, 0x0036, 0x6932, 0x2d00, 0x682e, 0x0d7e, 0x1078, 0x3ae7,
+	0x1078, 0x44d0, 0x2b68, 0x1078, 0x3af8, 0x0d7f, 0x1078, 0x3af8,
+	0x2001, 0x0002, 0x007c, 0x1078, 0x467b, 0x007c, 0x70b4, 0xa080,
+	0x00d2, 0x781a, 0x2001, 0x0001, 0x1078, 0x4691, 0x1078, 0x46ff,
+	0x7003, 0x0000, 0x2001, 0x0002, 0x007c, 0x1078, 0x46c1, 0x1078,
+	0x46f8, 0x1078, 0x42d3, 0x1078, 0x41d0, 0x1078, 0x46ff, 0x2001,
+	0x0001, 0x007c, 0x1078, 0x46c1, 0x1078, 0x46f8, 0x1078, 0x42d3,
+	0x70b4, 0xa080, 0x00d2, 0x781a, 0x2001, 0x0013, 0x1078, 0x4691,
+	0x1078, 0x46ff, 0x7003, 0x0000, 0x2001, 0x0002, 0x007c, 0x1078,
+	0x467b, 0x007c, 0x1078, 0x46c1, 0x1078, 0x46f8, 0x1078, 0x42d3,
+	0x1078, 0x41d0, 0x1078, 0x46ff, 0x2001, 0x0001, 0x007c, 0x2001,
+	0x0003, 0x007c, 0x1078, 0x458b, 0x2001, 0x0000, 0x007c, 0x0c7e,
+	0x077e, 0x6f14, 0x1078, 0x36e2, 0x077f, 0x0c7f, 0x2001, 0x0000,
+	0x007c, 0x1078, 0x46c1, 0x1078, 0x467b, 0x2001, 0x0006, 0x007c,
+	0x6904, 0xa18c, 0x00ff, 0xa186, 0x0007, 0x0040, 0x44db, 0xa186,
+	0x000f, 0x00c0, 0x44df, 0x1078, 0x46f8, 0x1078, 0x42d3, 0x70b4,
+	0xa080, 0x00d2, 0x781a, 0x1078, 0x46ff, 0x7003, 0x0000, 0x007c,
+	0x7aa8, 0xa294, 0x00ff, 0x78a8, 0xa084, 0x00ff, 0xa08a, 0x0004,
+	0x00c8, 0x467b, 0x1079, 0x44f5, 0x007c, 0x467b, 0x44f9, 0x467b,
+	0x4592, 0xa282, 0x0003, 0x0040, 0x4500, 0x1078, 0x467b, 0x007c,
+	0x7da8, 0xa5ac, 0x00ff, 0x7ca8, 0xa4a4, 0x00ff, 0x69b8, 0xa184,
+	0x0100, 0x0040, 0x453f, 0xa18c, 0xfeff, 0x69ba, 0x78a0, 0xa005,
+	0x00c0, 0x453f, 0xa4a4, 0x00ff, 0x0040, 0x4533, 0xa482, 0x000c,
+	0x0040, 0x451c, 0x00c8, 0x4526, 0x852b, 0x852b, 0x1078, 0x3760,
+	0x0040, 0x4526, 0x1078, 0x355b, 0x0078, 0x4535, 0x1078, 0x465d,
+	0x1078, 0x3586, 0x69b8, 0xa18d, 0x0100, 0x69ba, 0xa6b5, 0x1000,
+	0x7e5a, 0x0078, 0x4538, 0x1078, 0x3586, 0xa6b4, 0xefff, 0x7e5a,
+	0x70b4, 0xa080, 0x0091, 0x781a, 0x2001, 0x0001, 0x007c, 0x0c7e,
+	0x1078, 0x457f, 0x6200, 0xd2e4, 0x0040, 0x4570, 0x6208, 0x8217,
+	0xa294, 0x00ff, 0xa282, 0x000c, 0x0048, 0x4552, 0x0040, 0x4552,
+	0x2011, 0x000c, 0x2400, 0xa202, 0x00c8, 0x4557, 0x2220, 0x6208,
+	0xa294, 0x00ff, 0x701c, 0xa202, 0x00c8, 0x455f, 0x721c, 0x2200,
+	0xa502, 0x00c8, 0x4564, 0x2228, 0x1078, 0x4661, 0x852b, 0x852b,
+	0x1078, 0x3760, 0x0040, 0x4570, 0x1078, 0x3562, 0x0078, 0x4574,
+	0x1078, 0x465d, 0x1078, 0x358d, 0xa6b5, 0x1000, 0x7e5a, 0x70b4,
+	0xa080, 0x00be, 0x781a, 0x2001, 0x0004, 0x0c7f, 0x007c, 0x007e,
+	0x6814, 0x8007, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e0,
+	0x5380, 0x007f, 0x007c, 0x0c7e, 0x1078, 0x457f, 0x1078, 0x358d,
+	0x0c7f, 0x007c, 0xa282, 0x0002, 0x00c0, 0x467b, 0x7aa8, 0xa294,
+	0x00ff, 0x69b8, 0xa184, 0x0200, 0x0040, 0x45c9, 0xa18c, 0xfdff,
+	0x69ba, 0x78a0, 0xa005, 0x00c0, 0x45c9, 0xa282, 0x0002, 0x00c8,
+	0x369d, 0x1078, 0x4627, 0x1078, 0x362b, 0x1078, 0x3586, 0xa684,
+	0x0100, 0x0040, 0x45bf, 0x682c, 0xa084, 0x0001, 0x0040, 0x45bf,
+	0xc6fc, 0x7888, 0xa084, 0x0040, 0x0040, 0x45bf, 0xc6fd, 0xa6b5,
+	0x1000, 0x7e5a, 0x70b4, 0xa080, 0x0091, 0x781a, 0x2001, 0x0001,
+	0x007c, 0x0c7e, 0x1078, 0x457f, 0xa284, 0xfffe, 0x0040, 0x45d4,
+	0x2011, 0x0001, 0x0078, 0x45d8, 0xa284, 0x0001, 0x0040, 0x45de,
+	0x6100, 0xd1ec, 0x00c0, 0x45de, 0x2011, 0x0000, 0x1078, 0x4619,
+	0x1078, 0x3632, 0x1078, 0x358d, 0xa684, 0x0100, 0x0040, 0x45f4,
+	0x682c, 0xa084, 0x0001, 0x0040, 0x45f4, 0xc6fc, 0x7888, 0xa084,
+	0x0040, 0x0040, 0x45f4, 0xc6fd, 0xa6b5, 0x1000, 0x7e5a, 0x70b4,
+	0xa080, 0x00be, 0x781a, 0x2001, 0x0004, 0x0c7f, 0x007c, 0x0c7e,
+	0x2960, 0x6000, 0x2011, 0x0001, 0xa084, 0x2000, 0x00c0, 0x460a,
+	0x2011, 0x0000, 0x78ab, 0x0001, 0x78ab, 0x0002, 0x78ab, 0x0003,
+	0x7aaa, 0xa8c0, 0x0004, 0x68b8, 0xa085, 0x0200, 0x68ba, 0x0c7f,
+	0x007c, 0x789b, 0x0018, 0x78ab, 0x0001, 0x78ab, 0x0002, 0x78ab,
+	0x0003, 0x7aaa, 0x789b, 0x0081, 0x78ab, 0x0004, 0x007c, 0x0c7e,
+	0x7054, 0x2060, 0x6000, 0xa084, 0x1000, 0x00c0, 0x4635, 0x2029,
+	0x0032, 0x2021, 0x0000, 0x0078, 0x4655, 0x6508, 0xa5ac, 0x00ff,
+	0x7018, 0xa086, 0x0028, 0x00c0, 0x4645, 0xa582, 0x0019, 0x00c8,
+	0x464b, 0x2029, 0x0019, 0x0078, 0x464b, 0xa582, 0x000c, 0x00c8,
+	0x464b, 0x2029, 0x000c, 0x6408, 0x8427, 0xa4a4, 0x00ff, 0xa482,
+	0x000c, 0x0048, 0x4655, 0x2021, 0x000c, 0x1078, 0x4661, 0x68b8,
+	0xa085, 0x0100, 0x68ba, 0x0c7f, 0x007c, 0x2021, 0x0000, 0x2029,
+	0x0032, 0x789b, 0x0018, 0x78ab, 0x0001, 0x78ab, 0x0003, 0x78ab,
+	0x0001, 0x7daa, 0x7caa, 0x789b, 0x0081, 0x78ab, 0x0005, 0x007c,
+	0x2001, 0x0003, 0x1078, 0x4689, 0x70b4, 0xa080, 0x00be, 0x781a,
+	0x2001, 0x0005, 0x007c, 0x2001, 0x0007, 0x1078, 0x4689, 0xa6b5,
+	0x1000, 0x7e5a, 0x70b4, 0xa080, 0x00be, 0x781a, 0x2001, 0x0004,
+	0x007c, 0x789b, 0x0018, 0x78aa, 0x789b, 0x0081, 0x78ab, 0x0001,
+	0x007c, 0x6904, 0xa18c, 0x00ff, 0xa196, 0x0007, 0x0040, 0x469f,
+	0xa196, 0x000f, 0x0040, 0x469f, 0x1078, 0x195a, 0x007c, 0x6924,
+	0xa194, 0x003f, 0x00c0, 0x46a8, 0xa18c, 0xffc0, 0xa105, 0x6826,
+	0x1078, 0x3af8, 0x691c, 0xa184, 0x0100, 0x0040, 0x46b5, 0x6914,
+	0x1078, 0x3b69, 0x6204, 0x8210, 0x6206, 0x007c, 0x692c, 0x6834,
+	0x682e, 0xa112, 0x6930, 0x6838, 0x6832, 0xa11b, 0xa200, 0xa301,
+	0x007c, 0x0c7e, 0xade0, 0x0018, 0x6003, 0x0070, 0x6106, 0x600b,
+	0x0000, 0x600f, 0x0a00, 0x6013, 0x0000, 0x6017, 0x0000, 0x8007,
+	0x601a, 0x601f, 0x0000, 0x6023, 0x0000, 0x0c7f, 0x6824, 0xa085,
+	0x0080, 0x6826, 0x007c, 0x157e, 0x137e, 0x147e, 0x2098, 0xaf80,
+	0x002d, 0x20a0, 0x81ac, 0x0040, 0x46e6, 0x53a6, 0xa184, 0x0001,
+	0x0040, 0x46ec, 0x3304, 0x78be, 0x147f, 0x137f, 0x157f, 0x007c,
+	0x70b0, 0xa005, 0x10c0, 0x23eb, 0x70b3, 0x8000, 0x0078, 0x4a3a,
+	0x71b0, 0x81ff, 0x0040, 0x46fe, 0x1078, 0x4b30, 0x007c, 0x71b0,
+	0x81ff, 0x0040, 0x4707, 0x70b3, 0x0000, 0x1078, 0x4776, 0x007c,
+	0x0c7e, 0x0d7e, 0x1078, 0x1937, 0x0c7f, 0x157e, 0x137e, 0x147e,
+	0x2da0, 0x2c98, 0x20a9, 0x0031, 0x53a3, 0x147f, 0x137f, 0x157f,
+	0x6807, 0x010d, 0x680b, 0x0000, 0x7004, 0x8007, 0x681a, 0x6823,
+	0x0000, 0x681f, 0x0000, 0x689f, 0x0000, 0x0c7f, 0x007c, 0x70b4,
+	0xa080, 0x0091, 0x781a, 0x0078, 0x2459, 0x70b4, 0xa080, 0x0081,
+	0x781a, 0x0078, 0x2459, 0x70b4, 0xa080, 0x00be, 0x781a, 0x0078,
+	0x2459, 0x70b4, 0xa080, 0x00c8, 0x781a, 0x0078, 0x2459, 0x6904,
+	0xa18c, 0x00ff, 0xa196, 0x0007, 0x0040, 0x474c, 0xa196, 0x000f,
+	0x0040, 0x474c, 0x6807, 0x0117, 0x2001, 0x0200, 0x6826, 0x8007,
+	0x789b, 0x000e, 0x78aa, 0x6820, 0xa085, 0x8000, 0x6822, 0x2031,
+	0x0400, 0x6eb6, 0x7e5a, 0x71b4, 0xa188, 0x0091, 0x791a, 0x007c,
+	0x1078, 0x46ff, 0x7848, 0xa085, 0x000c, 0x784a, 0x70b4, 0xa080,
+	0x00d2, 0x781a, 0x2009, 0x000b, 0x2001, 0x4400, 0x1078, 0x46c1,
+	0x2001, 0x0013, 0x1078, 0x4691, 0x0078, 0x3b96, 0x127e, 0x2091,
+	0x2200, 0x2049, 0x4776, 0x7000, 0x7204, 0xa205, 0x720c, 0xa215,
+	0x7008, 0xa084, 0xfff7, 0xa205, 0x0040, 0x4788, 0x0078, 0x478d,
+	0x7003, 0x0000, 0x127f, 0x2000, 0x007c, 0x7000, 0xa084, 0x0001,
+	0x00c0, 0x47bb, 0x7108, 0x8103, 0x00c8, 0x479a, 0x1078, 0x48bd,
+	0x0078, 0x4792, 0x700c, 0xa08c, 0x00ff, 0x0040, 0x47bb, 0x7004,
+	0x8004, 0x00c8, 0x47b2, 0x7014, 0xa005, 0x00c0, 0x47ae, 0x7010,
+	0xa005, 0x0040, 0x47b2, 0xa102, 0x00c8, 0x4792, 0x7007, 0x0010,
+	0x0078, 0x47bb, 0x8aff, 0x0040, 0x47bb, 0x1078, 0x4b07, 0x00c0,
+	0x47b5, 0x0040, 0x4792, 0x1078, 0x4846, 0x7003, 0x0000, 0x127f,
+	0x2000, 0x007c, 0x017e, 0x6104, 0xa18c, 0x00ff, 0xa186, 0x0007,
+	0x0040, 0x47ce, 0xa18e, 0x000f, 0x00c0, 0x47d1, 0x6040, 0x0078,
+	0x47d2, 0x6428, 0x017f, 0x84ff, 0x0040, 0x47fc, 0x2c70, 0x7004,
+	0xa0bc, 0x000f, 0xa7b8, 0x480c, 0x273c, 0x87fb, 0x00c0, 0x47ea,
+	0x0048, 0x47e4, 0x1078, 0x23eb, 0x609c, 0xa075, 0x0040, 0x47fc,
+	0x0078, 0x47d7, 0x2704, 0xae68, 0x6808, 0xa630, 0x680c, 0xa529,
+	0x8421, 0x0040, 0x47fc, 0x8738, 0x2704, 0xa005, 0x00c0, 0x47eb,
+	0x709c, 0xa075, 0x00c0, 0x47d7, 0x007c, 0x0000, 0x0005, 0x0009,
+	0x000d, 0x0011, 0x0015, 0x0019, 0x001d, 0x0000, 0x0003, 0x0009,
+	0x000f, 0x0015, 0x001b, 0x0000, 0x0000, 0x4801, 0x47fe, 0x0000,
+	0x0000, 0x8000, 0x0000, 0x4801, 0x0000, 0x4809, 0x4806, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x4809, 0x0000, 0x4804, 0x4804, 0x0000,
+	0x0000, 0x8000, 0x0000, 0x4804, 0x0000, 0x480a, 0x480a, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x480a, 0x127e, 0x2091, 0x2200, 0x2079,
+	0x5100, 0x2071, 0x0010, 0x7007, 0x000a, 0x7007, 0x0002, 0x7003,
+	0x0000, 0x2071, 0x0020, 0x7007, 0x000a, 0x7007, 0x0002, 0x7003,
+	0x0000, 0x2049, 0x0000, 0x127f, 0x2000, 0x007c, 0x2049, 0x4846,
+	0x2019, 0x0000, 0x7004, 0x8004, 0x00c8, 0x4899, 0x7007, 0x0012,
+	0x7108, 0x7008, 0xa106, 0x00c0, 0x4850, 0xa184, 0x01e0, 0x0040,
+	0x485b, 0x1078, 0x23eb, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005,
+	0x00c8, 0x4866, 0xa184, 0x4000, 0x00c0, 0x4850, 0xa19c, 0x300c,
+	0xa386, 0x2004, 0x0040, 0x4874, 0xa386, 0x0008, 0x0040, 0x487f,
+	0xa386, 0x200c, 0x00c0, 0x4850, 0x7200, 0x8204, 0x0048, 0x487f,
+	0x730c, 0xa384, 0x00ff, 0x0040, 0x487f, 0x1078, 0x23eb, 0x7007,
+	0x0012, 0x7000, 0xa084, 0x0001, 0x00c0, 0x4899, 0x7008, 0xa084,
+	0x01e0, 0x00c0, 0x4899, 0x7310, 0x7014, 0xa305, 0x0040, 0x4899,
+	0x710c, 0xa184, 0x0300, 0x00c0, 0x4899, 0xa184, 0x00ff, 0x00c0,
+	0x4846, 0x7007, 0x0012, 0x7007, 0x0008, 0x7004, 0xa084, 0x0008,
+	0x00c0, 0x489d, 0x7007, 0x0012, 0x7108, 0x8103, 0x0048, 0x48a2,
+	0x7003, 0x0000, 0x2049, 0x0000, 0x007c, 0x107e, 0x007e, 0x127e,
+	0x157e, 0x2091, 0x2200, 0x7108, 0x1078, 0x48bd, 0x157f, 0x127f,
+	0x2091, 0x8001, 0x007f, 0x107f, 0x007c, 0x7204, 0x7500, 0x730c,
+	0xa384, 0x0300, 0x00c0, 0x48e4, 0xa184, 0x01e0, 0x00c0, 0x4908,
+	0x7108, 0xa184, 0x01e0, 0x00c0, 0x4908, 0x2001, 0x04fd, 0x2004,
+	0xa082, 0x0005, 0x00c8, 0x48d8, 0xa184, 0x4000, 0x00c0, 0x48c8,
+	0xa184, 0x0007, 0x0079, 0x48dc, 0x48e6, 0x48f8, 0x48e4, 0x48f8,
+	0x48e4, 0x4944, 0x48e4, 0x4942, 0x1078, 0x23eb, 0x7004, 0xa084,
+	0x0010, 0xa085, 0x0002, 0x7006, 0x8aff, 0x00c0, 0x48f3, 0x2049,
+	0x0000, 0x0078, 0x48f7, 0x1078, 0x4b07, 0x00c0, 0x48f3, 0x007c,
+	0x7004, 0xa084, 0x0010, 0xa085, 0x0002, 0x7006, 0x8aff, 0x00c0,
+	0x4903, 0x0078, 0x4907, 0x1078, 0x4b07, 0x00c0, 0x4903, 0x007c,
+	0x7007, 0x0012, 0x7108, 0x00e0, 0x490b, 0x2091, 0x6000, 0x00e0,
+	0x490f, 0x2091, 0x6000, 0x7007, 0x0012, 0x7007, 0x0008, 0x7004,
+	0xa084, 0x0008, 0x00c0, 0x4917, 0x7007, 0x0012, 0x7108, 0x8103,
+	0x0048, 0x491c, 0x7003, 0x0000, 0x7000, 0xa005, 0x00c0, 0x4930,
+	0x7004, 0xa005, 0x00c0, 0x4930, 0x700c, 0xa005, 0x0040, 0x4932,
+	0x0078, 0x4913, 0x2049, 0x0000, 0x1078, 0x3809, 0x6818, 0xa084,
+	0x8000, 0x0040, 0x493d, 0x681b, 0x0002, 0x007c, 0x1078, 0x23eb,
+	0x1078, 0x23eb, 0x1078, 0x49a0, 0x7210, 0x7114, 0x700c, 0xa09c,
+	0x00ff, 0x2800, 0xa300, 0xa211, 0xa189, 0x0000, 0x1078, 0x49a0,
+	0x2704, 0x2c58, 0xac60, 0x6308, 0x2200, 0xa322, 0x630c, 0x2100,
+	0xa31b, 0x2400, 0xa305, 0x0040, 0x4967, 0x00c8, 0x4967, 0x8412,
+	0x8210, 0x830a, 0xa189, 0x0000, 0x2b60, 0x0078, 0x494e, 0x2b60,
+	0x8a07, 0x007e, 0x6004, 0xa084, 0x0008, 0x0040, 0x4973, 0xa7ba,
+	0x4806, 0x0078, 0x4975, 0xa7ba, 0x47fe, 0x007f, 0xa73d, 0x2c00,
+	0x6886, 0x6f8a, 0x6c92, 0x6b8e, 0x7007, 0x0012, 0x1078, 0x4846,
+	0x007c, 0x8738, 0x2704, 0xa005, 0x00c0, 0x4994, 0x609c, 0xa005,
+	0x0040, 0x499d, 0x2060, 0x6004, 0xa084, 0x000f, 0xa080, 0x480c,
+	0x203c, 0x87fb, 0x1040, 0x23eb, 0x8a51, 0x0040, 0x499c, 0x7008,
+	0xa084, 0x0003, 0xa086, 0x0003, 0x007c, 0x2051, 0x0000, 0x007c,
+	0x8a50, 0x8739, 0x2704, 0xa004, 0x00c0, 0x49b4, 0x6000, 0xa064,
+	0x00c0, 0x49ab, 0x2d60, 0x6004, 0xa084, 0x000f, 0xa080, 0x481c,
+	0x203c, 0x87fb, 0x1040, 0x23eb, 0x007c, 0x127e, 0x0d7e, 0x2091,
+	0x2200, 0x0d7f, 0x6884, 0x2060, 0x6888, 0x6b8c, 0x6c90, 0x8057,
+	0xaad4, 0x00ff, 0xa084, 0x00ff, 0x007e, 0x6804, 0xa084, 0x0008,
+	0x007f, 0x0040, 0x49cf, 0xa0b8, 0x4806, 0x0078, 0x49d1, 0xa0b8,
+	0x47fe, 0x7e08, 0xa6b5, 0x000c, 0x6904, 0xa18c, 0x00ff, 0xa186,
+	0x0007, 0x0040, 0x49df, 0xa18e, 0x000f, 0x00c0, 0x49e8, 0x681c,
+	0xa084, 0x0040, 0x0040, 0x49ef, 0xa6b5, 0x0001, 0x0078, 0x49ef,
+	0x681c, 0xa084, 0x0040, 0x0040, 0x49ef, 0xa6b5, 0x0001, 0x7007,
+	0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, 0x49f1, 0x2400, 0xa305,
+	0x00c0, 0x49fc, 0x0078, 0x4a22, 0x2c58, 0x2704, 0x6104, 0xac60,
+	0x6000, 0xa400, 0x701a, 0x6004, 0xa301, 0x701e, 0xa184, 0x0008,
+	0x0040, 0x4a12, 0x6010, 0xa081, 0x0000, 0x7022, 0x6014, 0xa081,
+	0x0000, 0x7026, 0x6208, 0x2400, 0xa202, 0x7012, 0x620c, 0x2300,
+	0xa203, 0x7016, 0x7602, 0x7007, 0x0001, 0x2b60, 0x1078, 0x4981,
+	0x0078, 0x4a24, 0x1078, 0x4b07, 0x00c0, 0x4a22, 0x127f, 0x2000,
+	0x007c, 0x127e, 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x7007, 0x0004,
+	0x7004, 0xa084, 0x0004, 0x00c0, 0x4a30, 0x7003, 0x0008, 0x127f,
+	0x2000, 0x007c, 0x127e, 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x2049,
+	0x4a3a, 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, 0x4a43,
+	0x7e08, 0xa6b5, 0x000c, 0x6904, 0xa18c, 0x00ff, 0xa186, 0x0007,
+	0x0040, 0x4a56, 0xa18e, 0x000f, 0x00c0, 0x4a61, 0x681c, 0xa084,
+	0x0040, 0x0040, 0x4a5d, 0xa6b5, 0x0001, 0x6840, 0x2050, 0x0078,
+	0x4a6a, 0x681c, 0xa084, 0x0020, 0x00c0, 0x4a68, 0xa6b5, 0x0001,
+	0x6828, 0x2050, 0x2d60, 0x6004, 0xa0bc, 0x000f, 0xa7b8, 0x480c,
+	0x273c, 0x87fb, 0x00c0, 0x4a7e, 0x0048, 0x4a78, 0x1078, 0x23eb,
+	0x689c, 0xa065, 0x0040, 0x4a82, 0x0078, 0x4a6b, 0x1078, 0x4b07,
+	0x00c0, 0x4a7e, 0x127f, 0x2000, 0x007c, 0x127e, 0x007e, 0x017e,
+	0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x037f, 0x047f, 0x7e08, 0xa6b5,
+	0x000c, 0x6904, 0xa18c, 0x00ff, 0xa186, 0x0007, 0x0040, 0x4a9c,
+	0xa18e, 0x000f, 0x00c0, 0x4aa5, 0x681c, 0xa084, 0x0040, 0x0040,
+	0x4aac, 0xa6b5, 0x0001, 0x0078, 0x4aac, 0x681c, 0xa084, 0x0040,
+	0x0040, 0x4aac, 0xa6b5, 0x0001, 0x2049, 0x4a85, 0x017e, 0x6904,
+	0xa18c, 0x00ff, 0xa186, 0x0007, 0x0040, 0x4aba, 0xa18e, 0x000f,
+	0x00c0, 0x4abd, 0x6840, 0x0078, 0x4abe, 0x6828, 0x017f, 0xa055,
+	0x0040, 0x4b04, 0x2d70, 0x2e60, 0x7004, 0xa0bc, 0x000f, 0xa7b8,
+	0x480c, 0x273c, 0x87fb, 0x00c0, 0x4ad8, 0x0048, 0x4ad1, 0x1078,
+	0x23eb, 0x709c, 0xa075, 0x2060, 0x0040, 0x4b04, 0x0078, 0x4ac4,
+	0x2704, 0xae68, 0x6808, 0xa422, 0x680c, 0xa31b, 0x0048, 0x4af1,
+	0x8a51, 0x00c0, 0x4ae5, 0x1078, 0x23eb, 0x8738, 0x2704, 0xa005,
+	0x00c0, 0x4ad9, 0x709c, 0xa075, 0x2060, 0x0040, 0x4b04, 0x0078,
+	0x4ac4, 0x8422, 0x8420, 0x831a, 0xa399, 0x0000, 0x6908, 0x2400,
+	0xa122, 0x690c, 0x2300, 0xa11b, 0x00c8, 0x4b00, 0x1078, 0x23eb,
+	0x2071, 0x0020, 0x0078, 0x49ef, 0x127f, 0x2000, 0x007c, 0x7008,
+	0xa084, 0x0003, 0xa086, 0x0003, 0x0040, 0x4b2f, 0x2704, 0xac08,
+	0x2104, 0x701a, 0x8108, 0x2104, 0x701e, 0x8108, 0x2104, 0x7012,
+	0x8108, 0x2104, 0x7016, 0x6004, 0xa084, 0x0008, 0x0040, 0x4b26,
+	0x8108, 0x2104, 0x7022, 0x8108, 0x2104, 0x7026, 0x7602, 0x7004,
+	0xa084, 0x0010, 0xa085, 0x0001, 0x7006, 0x1078, 0x4981, 0x007c,
+	0x127e, 0x007e, 0x0d7e, 0x2091, 0x2200, 0x2049, 0x4b30, 0x0d7f,
+	0x087f, 0x7108, 0xa184, 0x0003, 0x00c0, 0x4b5a, 0x017e, 0x6904,
+	0xa18c, 0x00ff, 0xa186, 0x0007, 0x0040, 0x4b4a, 0xa18e, 0x000f,
+	0x00c0, 0x4b4d, 0x6840, 0x0078, 0x4b4e, 0x6828, 0x017f, 0xa005,
+	0x0040, 0x4b68, 0x0078, 0x478d, 0x0020, 0x4b5a, 0x1078, 0x4944,
+	0x0078, 0x4b68, 0x00a0, 0x4b61, 0x7108, 0x1078, 0x48bd, 0x0078,
+	0x4b39, 0x7007, 0x0010, 0x00a0, 0x4b63, 0x7108, 0x1078, 0x48bd,
+	0x7008, 0xa086, 0x0008, 0x00c0, 0x4b39, 0x7000, 0xa005, 0x00c0,
+	0x4b39, 0x7003, 0x0000, 0x2049, 0x0000, 0x127f, 0x2000, 0x007c,
+	0x127e, 0x147e, 0x137e, 0x157e, 0x0c7e, 0x0d7e, 0x2091, 0x2200,
+	0x0d7f, 0x2049, 0x4b78, 0xad80, 0x0011, 0x20a0, 0x2099, 0x0031,
+	0x700c, 0xa084, 0x00ff, 0x682a, 0x7007, 0x0008, 0x7007, 0x0002,
+	0x7003, 0x0001, 0x0040, 0x4b97, 0x8000, 0x80ac, 0x53a5, 0x7007,
+	0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, 0x4b99, 0x0c7f, 0x2049,
+	0x0000, 0x7003, 0x0000, 0x157f, 0x137f, 0x147f, 0x127f, 0x2000,
+	0x007c, 0x2091, 0x6000, 0x2091, 0x8000, 0x78cc, 0xa005, 0x0040,
+	0x4bc0, 0x7994, 0x70d0, 0xa106, 0x00c0, 0x4bc0, 0x7804, 0xa005,
+	0x0040, 0x4bc0, 0x7807, 0x0000, 0x0068, 0x4bc0, 0x2091, 0x4080,
+	0x7820, 0x8001, 0x7822, 0x00c0, 0x4c1b, 0x7824, 0x7822, 0x2069,
+	0x5140, 0x6800, 0xa084, 0x0007, 0x0040, 0x4bde, 0xa086, 0x0002,
+	0x0040, 0x4bde, 0x6834, 0xa00d, 0x0040, 0x4bde, 0x2104, 0xa005,
+	0x0040, 0x4bde, 0x8001, 0x200a, 0x0040, 0x4cc3, 0x7848, 0xa005,
+	0x0040, 0x4bec, 0x8001, 0x784a, 0x00c0, 0x4bec, 0x2009, 0x0102,
+	0x6844, 0x200a, 0x1078, 0x21d2, 0x6890, 0xa005, 0x0040, 0x4bf8,
+	0x8001, 0x6892, 0x00c0, 0x4bf8, 0x686f, 0x0000, 0x6873, 0x0001,
+	0x2061, 0x5400, 0x20a9, 0x0100, 0x2009, 0x0002, 0x6034, 0xa005,
+	0x0040, 0x4c0e, 0x8001, 0x6036, 0x00c0, 0x4c0e, 0x6010, 0xa005,
+	0x0040, 0x4c0e, 0x017e, 0x1078, 0x21d2, 0x017f, 0xace0, 0x0010,
+	0x0070, 0x4c14, 0x0078, 0x4bfe, 0x8109, 0x0040, 0x4c1b, 0x20a9,
+	0x0100, 0x0078, 0x4bfe, 0x1078, 0x4c28, 0x1078, 0x4c4d, 0x2009,
+	0x5151, 0x2104, 0x2009, 0x0102, 0x200a, 0x2091, 0x8001, 0x007c,
+	0x7834, 0x8001, 0x7836, 0x00c0, 0x4c4c, 0x7838, 0x7836, 0x2091,
+	0x8000, 0x7844, 0xa005, 0x00c0, 0x4c37, 0x2001, 0x0101, 0x8001,
+	0x7846, 0xa080, 0x7400, 0x2040, 0x2004, 0xa065, 0x0040, 0x4c4c,
+	0x6024, 0xa005, 0x0040, 0x4c48, 0x8001, 0x6026, 0x0040, 0x4c7c,
+	0x6000, 0x2c40, 0x0078, 0x4c3d, 0x007c, 0x7828, 0x8001, 0x782a,
+	0x00c0, 0x4c7b, 0x782c, 0x782a, 0x7830, 0xa005, 0x00c0, 0x4c5a,
+	0x2001, 0x0200, 0x8001, 0x7832, 0x8003, 0x8003, 0x8003, 0x8003,
+	0xa090, 0x5400, 0xa298, 0x0002, 0x2304, 0xa084, 0x0008, 0x0040,
+	0x4c7b, 0xa290, 0x0009, 0x2204, 0xa005, 0x0040, 0x4c73, 0x8001,
+	0x2012, 0x00c0, 0x4c7b, 0x2304, 0xa084, 0xfff7, 0xa085, 0x0080,
+	0x201a, 0x1078, 0x21d2, 0x007c, 0x2069, 0x5140, 0x6800, 0xa005,
+	0x0040, 0x4c86, 0x6848, 0xac06, 0x0040, 0x4cc3, 0x601b, 0x0006,
+	0x60b4, 0xa084, 0x3f00, 0x601e, 0x6020, 0xa084, 0x00ff, 0xa085,
+	0x0060, 0x6022, 0x6000, 0x2042, 0x6714, 0x6f82, 0x1078, 0x1973,
+	0x6818, 0xa005, 0x0040, 0x4c9e, 0x8001, 0x681a, 0x6808, 0xa084,
+	0xffef, 0x680a, 0x6810, 0x8001, 0x00d0, 0x4ca8, 0x1078, 0x23eb,
+	0x6812, 0x602f, 0x0000, 0x6033, 0x0000, 0x2c68, 0x1078, 0x1c70,
+	0x2069, 0x5140, 0x7944, 0xa184, 0x0100, 0x2001, 0x0006, 0x686e,
+	0x00c0, 0x4cbe, 0x6986, 0x2001, 0x0004, 0x686e, 0x1078, 0x21cd,
+	0x2091, 0x8001, 0x007c, 0x2069, 0x0100, 0x2009, 0x5140, 0x2104,
+	0xa084, 0x0007, 0x0040, 0x4d1f, 0xa086, 0x0007, 0x00c0, 0x4cd9,
+	0x0d7e, 0x2009, 0x5152, 0x216c, 0x1078, 0x3a4e, 0x0d7f, 0x0078,
+	0x4d1f, 0x2009, 0x5152, 0x2164, 0x1078, 0x2396, 0x601b, 0x0006,
+	0x6858, 0xa084, 0x3f00, 0x601e, 0x6020, 0xa084, 0x00ff, 0xa085,
+	0x0048, 0x6022, 0x602f, 0x0000, 0x6033, 0x0000, 0x6830, 0xa084,
+	0x0040, 0x0040, 0x4d13, 0x684b, 0x0004, 0x20a9, 0x0014, 0x6848,
+	0xa084, 0x0004, 0x0040, 0x4d00, 0x0070, 0x4d00, 0x0078, 0x4cf7,
+	0x684b, 0x0009, 0x20a9, 0x0014, 0x6848, 0xa084, 0x0001, 0x0040,
+	0x4d0d, 0x0070, 0x4d0d, 0x0078, 0x4d04, 0x20a9, 0x00fa, 0x0070,
+	0x4d13, 0x0078, 0x4d0f, 0x6808, 0xa084, 0xfffd, 0x680a, 0x681b,
+	0x0048, 0x2009, 0x515b, 0x200b, 0x0007, 0x784c, 0x784a, 0x2091,
+	0x8001, 0x007c, 0x2079, 0x5100, 0x1078, 0x4d4d, 0x1078, 0x4d31,
+	0x1078, 0x4d3f, 0x7833, 0x0000, 0x7847, 0x0000, 0x784b, 0x0000,
+	0x007c, 0x2019, 0x0003, 0x2011, 0x5146, 0x2204, 0xa086, 0x003c,
+	0x0040, 0x4d3c, 0x2019, 0x0002, 0x7b2a, 0x7b2e, 0x007c, 0x2019,
+	0x0039, 0x2011, 0x5146, 0x2204, 0xa086, 0x003c, 0x0040, 0x4d4a,
+	0x2019, 0x0027, 0x7b36, 0x7b3a, 0x007c, 0x2019, 0x3971, 0x2011,
+	0x5146, 0x2204, 0xa086, 0x003c, 0x0040, 0x4d58, 0x2019, 0x2626,
+	0x7b22, 0x7b26, 0x783f, 0x0000, 0x7843, 0x000a, 0x007c, 0x0020,
+	0x002b, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000,
+	0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000,
+	0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000,
+	0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000,
+	0x0020, 0x0000, 0x0014, 0x0014, 0x9849, 0x0014, 0x0014, 0x0014,
+	0x0014, 0x0014, 0x0014, 0x0014, 0x0080, 0x000f, 0x0000, 0x0201,
+	0x0604, 0x0c08, 0x2120, 0x4022, 0xf880, 0x0018, 0x300b, 0xa201,
+	0x0014, 0xa200, 0x0014, 0xa200, 0x0214, 0x0000, 0x006c, 0x0002,
+	0x0014, 0x98d0, 0x009e, 0x0096, 0xa202, 0x8838, 0x3806, 0x8839,
+	0x20c3, 0x0864, 0x9884, 0x28c1, 0x9cb1, 0xa203, 0x300c, 0x2846,
+	0x8161, 0x846a, 0x8300, 0x1856, 0x883a, 0x9865, 0x28f2, 0x9c90,
+	0x9858, 0x300c, 0x28e1, 0x9c90, 0x2802, 0xa206, 0x64c3, 0x282d,
+	0xa207, 0x64a0, 0x67a0, 0x6fc0, 0x1814, 0x883b, 0x7824, 0x68c1,
+	0x7864, 0x883e, 0x9878, 0x8576, 0x8677, 0x206b, 0x28c1, 0x9cb1,
+	0x2044, 0x2103, 0x20a2, 0x2081, 0x9865, 0xa209, 0x2901, 0x988c,
+	0x0014, 0xa205, 0xa300, 0x1872, 0x879a, 0x883c, 0x1fe2, 0xc601,
+	0xa20a, 0x856e, 0x0704, 0x9c90, 0x0014, 0xa204, 0xa300, 0x3009,
+	0x19e2, 0xf868, 0x8176, 0x86eb, 0x85eb, 0x872e, 0x87a9, 0x883f,
+	0x08e6, 0x9890, 0xf881, 0x988b, 0xc801, 0x0014, 0xf8c1, 0x0016,
+	0x85b2, 0x80f0, 0x9532, 0xfb02, 0x1de2, 0x0014, 0x8532, 0xf241,
+	0x0014, 0x1de2, 0x84a8, 0xd7a0, 0x1fe6, 0x0014, 0xa208, 0x6043,
+	0x8008, 0x1dc1, 0x0016, 0x8300, 0x8160, 0x842a, 0xf041, 0x3008,
+	0x84a8, 0x11d6, 0x7042, 0x20dd, 0x0011, 0x20d5, 0x8822, 0x0016,
+	0x8000, 0x2847, 0x1011, 0x98c3, 0x8000, 0xa000, 0x2802, 0x1011,
+	0x98c9, 0x9865, 0x283e, 0x1011, 0x98cd, 0xa20b, 0x0017, 0x300c,
+	0xa300, 0x1de2, 0xdb81, 0x0014, 0x0210, 0x98da, 0x0014, 0x26e0,
+	0x873a, 0xfb02, 0x19f2, 0x1fe2, 0x0014, 0xa20d, 0x3806, 0x0210,
+	0x9cb6, 0x0704, 0x0000, 0x006c, 0x0002, 0x984f, 0x0014, 0x009e,
+	0x00a5, 0x0017, 0x60ff, 0x300c, 0x8720, 0xa211, 0x9cd5, 0x8772,
+	0x8837, 0x2101, 0x987a, 0x10d2, 0x78e2, 0x9cd8, 0x9859, 0xd984,
+	0xf0e2, 0xf0a1, 0x98d2, 0x0014, 0x8831, 0xd166, 0x8830, 0x800f,
+	0x9401, 0xb520, 0xc802, 0x8820, 0x987a, 0x2301, 0x987a, 0x10d2,
+	0x78e4, 0x9cd8, 0x8821, 0x8820, 0x9859, 0xf123, 0xf142, 0xf101,
+	0x98cb, 0x10d2, 0x70f6, 0x8832, 0x8203, 0x870c, 0xd99e, 0x6001,
+	0x0014, 0x6845, 0x0214, 0xa21b, 0x9cd5, 0x2001, 0x98ca, 0x8201,
+	0x1852, 0xd184, 0xd163, 0x8834, 0x8001, 0x988d, 0x3027, 0x84a8,
+	0x1a56, 0x8833, 0x0014, 0xa218, 0x6981, 0x9cc1, 0x692a, 0x6902,
+	0x1834, 0x989d, 0x1a14, 0x8010, 0x8592, 0x8026, 0x84b9, 0x7021,
+	0x0014, 0xa300, 0x69e1, 0x9caa, 0x694c, 0xa213, 0x9cba, 0x1462,
+	0xa213, 0x8000, 0x16e1, 0x98b4, 0x8023, 0x16e1, 0x8001, 0x10f1,
+	0x0016, 0x6968, 0xa214, 0x9cba, 0x8004, 0x16e1, 0x0101, 0x300a,
+	0x8827, 0x0014, 0x9cba, 0x0014, 0x61c2, 0x8002, 0x14e1, 0x0016,
+	0xa217, 0x9cc1, 0x0014, 0xa300, 0x8181, 0x842a, 0x84a8, 0x1ce6,
+	0x882c, 0x0016, 0xa212, 0x9cd5, 0x10d2, 0x70e4, 0x0004, 0x8007,
+	0x9424, 0xcc1a, 0x9cd8, 0x98ca, 0x8827, 0x300a, 0x0013, 0x8000,
+	0x84a4, 0x0016, 0x11c2, 0x211e, 0x870e, 0xa21d, 0x0014, 0x878e,
+	0x0016, 0xa21c, 0x1035, 0x9891, 0xa210, 0xa000, 0x8010, 0x8592,
+	0x853b, 0xd044, 0x8022, 0x3807, 0x84bb, 0x98ef, 0x8021, 0x3807,
+	0x84b9, 0x300c, 0x817e, 0x872b, 0x8772, 0x9891, 0x0000, 0x0020,
+	0x002b, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000,
+	0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000,
+	0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000,
+	0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000,
+	0x0020, 0x0000, 0x0014, 0x0014, 0x9849, 0x0014, 0x0014, 0x98e5,
+	0x98d0, 0x0014, 0x0014, 0x0014, 0x0080, 0x013f, 0x0000, 0x0201,
+	0x0604, 0x0c08, 0x2120, 0x4022, 0xf880, 0x0018, 0x300b, 0xa201,
+	0x0014, 0xa200, 0x0014, 0xa200, 0x0214, 0xa202, 0x8838, 0x3806,
+	0x8839, 0x20c3, 0x0864, 0xa82e, 0x28c1, 0x9cb1, 0xa203, 0x300c,
+	0x2846, 0x8161, 0x846a, 0x8300, 0x1856, 0x883a, 0xa804, 0x28f2,
+	0x9c90, 0xa8f4, 0x300c, 0x28e1, 0x9c90, 0x2802, 0xa206, 0x64c3,
+	0x282d, 0xa207, 0x64a0, 0x67a0, 0x6fc0, 0x1814, 0x883b, 0x7824,
+	0x68c1, 0x7864, 0x883e, 0xa802, 0x8576, 0x8677, 0x206b, 0x28c1,
+	0x9cb1, 0x2044, 0x2103, 0x20a2, 0x2081, 0xa8e5, 0xa209, 0x2901,
+	0xa809, 0x0014, 0xa205, 0xa300, 0x1872, 0x879a, 0x883c, 0x1fe2,
+	0xc601, 0xa20a, 0x856e, 0x0704, 0x9c90, 0x0014, 0xa204, 0xa300,
+	0x3009, 0x19e2, 0xf868, 0x8176, 0x86eb, 0x85eb, 0x872e, 0x87a9,
+	0x883f, 0x08e6, 0xa8f3, 0xf881, 0xa8ec, 0xc801, 0x0014, 0xf8c1,
+	0x0016, 0x85b2, 0x80f0, 0x9532, 0xfb02, 0x1de2, 0x0014, 0x8532,
+	0xf241, 0x0014, 0x1de2, 0x84a8, 0xd7a0, 0x1fe6, 0x0014, 0xa208,
+	0x6043, 0x8008, 0x1dc1, 0x0016, 0x8300, 0x8160, 0x842a, 0xf041,
+	0x3008, 0x84a8, 0x11d6, 0x7042, 0x20dd, 0x0011, 0x20d5, 0x8822,
+	0x0016, 0x8000, 0x2847, 0x1011, 0xa8fc, 0x8000, 0xa000, 0x2802,
+	0x1011, 0xa8fd, 0xa898, 0x283e, 0x1011, 0xa8fd, 0xa20b, 0x0017,
+	0x300c, 0xa300, 0x1de2, 0xdb81, 0x0014, 0x0210, 0xa801, 0x0014,
+	0x26e0, 0x873a, 0xfb02, 0x19f2, 0x1fe2, 0x0014, 0xa20d, 0x3806,
+	0x0210, 0x9cb6, 0x0704, 0x0017, 0x60ff, 0x300c, 0x8720, 0xa211,
+	0x9d6b, 0x8772, 0x8837, 0x2101, 0xa821, 0x10d2, 0x78e2, 0x9d6e,
+	0xa8fc, 0xd984, 0xf0e2, 0xf0a1, 0xa871, 0x0014, 0x8831, 0xd166,
+	0x8830, 0x800f, 0x9401, 0xb520, 0xc802, 0x8820, 0xa80f, 0x2301,
+	0xa80d, 0x10d2, 0x78e4, 0x9d6e, 0x8821, 0x8820, 0xa8e6, 0xf123,
+	0xf142, 0xf101, 0xa854, 0x10d2, 0x70f6, 0x8832, 0x8203, 0x870c,
+	0xd99e, 0x6001, 0x0014, 0x6845, 0x0214, 0xa21b, 0x9d6b, 0x2001,
+	0xa845, 0x8201, 0x1852, 0xd184, 0xd163, 0x8834, 0x8001, 0xa801,
+	0x3027, 0x84a8, 0x1a56, 0x8833, 0x0014, 0xa218, 0x6981, 0x9d57,
+	0x692a, 0x6902, 0x1834, 0xa805, 0x1a14, 0x8010, 0x8592, 0x8026,
+	0x84b9, 0x7021, 0x0014, 0xa300, 0x69e1, 0x9d40, 0x694c, 0xa213,
+	0x9d50, 0x1462, 0xa213, 0x8000, 0x16e1, 0xa80a, 0x8023, 0x16e1,
+	0x8001, 0x10f1, 0x0016, 0x6968, 0xa214, 0x9d50, 0x8004, 0x16e1,
+	0x0101, 0x300a, 0x8827, 0x0014, 0x9d50, 0x0014, 0x61c2, 0x8002,
+	0x14e1, 0x0016, 0xa217, 0x9d57, 0x0014, 0xa300, 0x8181, 0x842a,
+	0x84a8, 0x1ce6, 0x882c, 0x0016, 0xa212, 0x9d6b, 0x10d2, 0x70e4,
+	0x0004, 0x8007, 0x9424, 0xcc1a, 0x9d6e, 0xa8f8, 0x8827, 0x300a,
+	0x0013, 0x8000, 0x84a4, 0x0016, 0x11c2, 0x211e, 0x870e, 0xa21d,
+	0x0014, 0x878e, 0x0016, 0xa21c, 0x1035, 0xa8af, 0xa210, 0x3807,
+	0x300c, 0x817e, 0x872b, 0x8772, 0xa8a8, 0x0000, 0xdf21
+};
+static unsigned short   risc_code_length01 = 0x4057;
+
diff -Nru a/drivers/scsi/ql12160_fw.h b/drivers/scsi/ql12160_fw.h
--- a/drivers/scsi/ql12160_fw.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/ql12160_fw.h	2004-12-24 13:36:48 -08:00
@@ -26,15 +26,9 @@
  */
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw12160i_version = 10*1024+4;
+static unsigned char fw12160i_version_str[] = {10,4,32};
 #else
-unsigned short risc_code_version = 10*1024+4;
-#endif
-
-#ifdef UNIQUE_FW_NAME
-unsigned char fw12160i_version_str[] = {10,4,32};
-#else
-unsigned char firmware_version[] = {10,4,32};
+static unsigned char firmware_version[] = {10,4,32};
 #endif
 
 #ifdef UNIQUE_FW_NAME
@@ -44,15 +38,15 @@
 #endif
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw12160i_addr01 = 0x1000;
+static unsigned short fw12160i_addr01 = 0x1000;
 #else
-unsigned short risc_code_addr01 = 0x1000;
+static unsigned short risc_code_addr01 = 0x1000;
 #endif
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw12160i_code01[] = {
+static unsigned short fw12160i_code01[] = {
 #else
-unsigned short risc_code01[] = {
+static unsigned short risc_code01[] = {
 #endif
 	0x0804, 0x1041, 0x0000, 0x35e6, 0x0000, 0x2043, 0x4f50, 0x5952,
 	0x4947, 0x4854, 0x2031, 0x3939, 0x312c, 0x3139, 0x3932, 0x2c31,
@@ -1781,7 +1775,7 @@
 	0x681f, 0x000c, 0x70a0, 0x70a2, 0x0005, 0x7c12
 };
 #ifdef UNIQUE_FW_NAME
-unsigned short   fw12160i_length01 = 0x35e6;
+static unsigned short   fw12160i_length01 = 0x35e6;
 #else
-unsigned short   risc_code_length01 = 0x35e6;
+static unsigned short   risc_code_length01 = 0x35e6;
 #endif
diff -Nru a/drivers/scsi/ql1280_fw.h b/drivers/scsi/ql1280_fw.h
--- a/drivers/scsi/ql1280_fw.h	2004-12-24 13:37:02 -08:00
+++ b/drivers/scsi/ql1280_fw.h	2004-12-24 13:37:02 -08:00
@@ -27,15 +27,9 @@
  */
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw1280ei_version = 8*1024+15;
+static unsigned char fw1280ei_version_str[] = {8,15,0};
 #else
-unsigned short risc_code_version = 8*1024+15;
-#endif
-
-#ifdef UNIQUE_FW_NAME
-unsigned char fw1280ei_version_str[] = {8,15,0};
-#else
-unsigned char firmware_version[] = {8,15,0};
+static unsigned char firmware_version[] = {8,15,0};
 #endif
 
 #ifdef UNIQUE_FW_NAME
@@ -45,15 +39,15 @@
 #endif
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw1280ei_addr01 = 0x1000;
+static unsigned short fw1280ei_addr01 = 0x1000;
 #else
-unsigned short risc_code_addr01 = 0x1000;
+static unsigned short risc_code_addr01 = 0x1000;
 #endif
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw1280ei_code01[] = {
+static unsigned short fw1280ei_code01[] = {
 #else
-unsigned short risc_code01[] = {
+static unsigned short risc_code01[] = {
 #endif
 	0x0078, 0x1041, 0x0000, 0x3d3b, 0x0000, 0x2043, 0x4f50, 0x5952,
 	0x4947, 0x4854, 0x2031, 0x3939, 0x312c, 0x3139, 0x3932, 0x2c31,
@@ -2017,7 +2011,7 @@
 	0x70a2, 0x007c, 0x205b
 };
 #ifdef UNIQUE_FW_NAME
-unsigned short   fw1280ei_length01 = 0x3d3b;
+static unsigned short   fw1280ei_length01 = 0x3d3b;
 #else
-unsigned short   risc_code_length01 = 0x3d3b;
+static unsigned short   risc_code_length01 = 0x3d3b;
 #endif
diff -Nru a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
--- a/drivers/scsi/qla1280.c	2004-12-24 13:37:32 -08:00
+++ b/drivers/scsi/qla1280.c	2004-12-24 13:37:32 -08:00
@@ -17,9 +17,12 @@
 * General Public License for more details.
 *
 ******************************************************************************/
-#define QLA1280_VERSION      "3.24.4"
+#define QLA1280_VERSION      "3.25"
 /*****************************************************************************
     Revision History:
+    Rev  3.25, September 28, 2004, Christoph Hellwig
+	- add support for ISP1020/1040
+	- don't include "scsi.h" anymore for 2.6.x
     Rev  3.24.4 June 7, 2004 Christoph Hellwig
 	- restructure firmware loading, cleanup initialization code
 	- prepare support for ISP1020/1040 chips
@@ -356,7 +359,6 @@
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_tcq.h>
-#include "scsi.h"
 #else
 #include <linux/blk.h>
 #include "scsi.h"
@@ -364,6 +366,10 @@
 #include "sd.h"
 #endif
 
+#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
+#include <asm/sn/io.h>
+#endif
+
 #if LINUX_VERSION_CODE < 0x020407
 #error "Kernels older than 2.4.7 are no longer supported"
 #endif
@@ -390,6 +396,7 @@
 #include "qla1280.h"
 #include "ql12160_fw.h"		/* ISP RISC codes */
 #include "ql1280_fw.h"
+#include "ql1040_fw.h"
 
 
 /*
@@ -422,13 +429,6 @@
 #define QLA_64BIT_PTR	1
 #endif
 
-#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
-#include <asm/sn/pci/pciio.h>
-/* Ugly hack needed for the virtual channel fix on SN2 */
-extern int snia_pcibr_rrb_alloc(struct pci_dev *pci_dev,
-				int *count_vchan0, int *count_vchan1);
-#endif
-
 #ifdef QLA_64BIT_PTR
 #define pci_dma_hi32(a)			((a >> 16) >> 16)
 #else
@@ -540,7 +540,7 @@
 				struct list_head *);
 static uint16_t qla1280_get_nvram_word(struct scsi_qla_host *, uint32_t);
 static uint16_t qla1280_nvram_request(struct scsi_qla_host *, uint32_t);
-static uint16_t qla1280_debounce_register(volatile uint16_t *);
+static uint16_t qla1280_debounce_register(volatile uint16_t __iomem *);
 static request_t *qla1280_req_pkt(struct scsi_qla_host *);
 static int qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *,
 					   unsigned int);
@@ -549,7 +549,7 @@
 static int qla1280_set_target_parameters(struct scsi_qla_host *, int, int);
 
 
-static struct qla_driver_setup driver_setup __initdata;
+static struct qla_driver_setup driver_setup;
 
 /*
  * convert scsi data direction to request_t control flags
@@ -588,7 +588,7 @@
 static char *qla1280;
 
 /* insmod qla1280 options=verbose" */
-MODULE_PARM(qla1280, "s");
+module_param(qla1280, charp, 0);
 #else
 __setup("qla1280=", qla1280_setup);
 #endif
@@ -632,18 +632,22 @@
 	unsigned char *fwver;	/* Ptr to F/W version array    */
 };
 
-/* NOTE: qla1280_pci_tbl and ql1280_board_tbl must be in the same order */
+/* NOTE: the last argument in each entry is used to index ql1280_board_tbl */
 static struct pci_device_id qla1280_pci_tbl[] = {
 	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP12160,
 		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1080,
+#ifdef CONFIG_SCSI_QLOGIC_1280_1040
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020,
 		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
-	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1240,
+#endif
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1080,
 		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
-	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1280,
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1240,
 		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
-	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP10160,
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1280,
 		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP10160,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5},
 	{0,}
 };
 MODULE_DEVICE_TABLE(pci, qla1280_pci_tbl);
@@ -652,6 +656,8 @@
 	/* Name ,  Number of ports, FW details */
 	{"QLA12160", 2, &fw12160i_code01[0], &fw12160i_length01,
 	 &fw12160i_addr01, &fw12160i_version_str[0]},
+	{"QLA1040", 1, &risc_code01[0], &risc_code_length01,
+	 &risc_code_addr01, &firmware_version[0]},
 	{"QLA1080", 1, &fw1280ei_code01[0], &fw1280ei_length01,
 	 &fw1280ei_addr01, &fw1280ei_version_str[0]},
 	{"QLA1240", 2, &fw1280ei_code01[0], &fw1280ei_length01,
@@ -943,7 +949,7 @@
 static void qla1280_mailbox_timeout(unsigned long __data)
 {
 	struct scsi_qla_host *ha = (struct scsi_qla_host *)__data;
-	struct device_reg *reg;
+	struct device_reg __iomem *reg;
 	reg = ha->iobase;
 
 	ha->mailbox_out[0] = RD_REG_WORD(&reg->mailbox0);
@@ -1354,7 +1360,7 @@
 qla1280_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct scsi_qla_host *ha;
-	struct device_reg *reg;
+	struct device_reg __iomem *reg;
 	u16 data;
 	int handled = 0;
 
@@ -1710,7 +1716,7 @@
 static inline void
 qla1280_enable_intrs(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg;
+	struct device_reg __iomem *reg;
 
 	reg = ha->iobase;
 	/* enable risc and host interrupts */
@@ -1722,7 +1728,7 @@
 static inline void
 qla1280_disable_intrs(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg;
+	struct device_reg __iomem *reg;
 
 	reg = ha->iobase;
 	/* disable risc and host interrupts */
@@ -1744,7 +1750,7 @@
 static int __devinit
 qla1280_initialize_adapter(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg;
+	struct device_reg __iomem *reg;
 	int status;
 	int bus;
 #if LINUX_VERSION_CODE > 0x020500
@@ -1762,23 +1768,17 @@
 	ha->flags.ints_enabled = 0;
 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
 	if (ia64_platform_is("sn2")) {
-		int count1, count2;
-		int c;
-
-		count1 = 3;
-		count2 = 3;
 		printk(KERN_INFO "scsi(%li): Enabling SN2 PCI DMA "
 		       "dual channel lockup workaround\n", ha->host_no);
-		if ((c = snia_pcibr_rrb_alloc(ha->pdev, &count1, &count2)) < 0)
-			printk(KERN_ERR "scsi(%li): Unable to allocate SN2 "
-			       "virtual DMA channels\n", ha->host_no);
-		else
-			ha->flags.use_pci_vchannel = 1;
-
+		ha->flags.use_pci_vchannel = 1;
 		driver_setup.no_nvram = 1;
 	}
 #endif
 
+	/* TODO: implement support for the 1040 nvram format */
+	if (IS_ISP1040(ha))
+		driver_setup.no_nvram = 1;
+
 	dprintk(1, "Configure PCI space for adapter...\n");
 
 	reg = ha->iobase;
@@ -1921,7 +1921,7 @@
 qla1280_chip_diag(struct scsi_qla_host *ha)
 {
 	uint16_t mb[MAILBOX_REGISTER_COUNT];
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	int status = 0;
 	int cnt;
 	uint16_t data;
@@ -2339,9 +2339,7 @@
 #if 1	/* Some SCSI Processors do not seem to like this */
 	nv->bus[bus].target[target].parameter.f.enable_wide = 1;
 #endif
-	if (!IS_ISP1040(ha))
-		nv->bus[bus].target[target].parameter.f.parity_checking = 1;
-
+	nv->bus[bus].target[target].parameter.f.parity_checking = 1;
 	nv->bus[bus].target[target].parameter.f.disconnect_allowed = 1;
 	nv->bus[bus].target[target].execution_throttle =
 		nv->bus[bus].max_queue_depth - 1;
@@ -2515,7 +2513,7 @@
 static int
 qla1280_nvram_config(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	struct nvram *nv = &ha->nvram;
 	int bus, target, status = 0;
 	uint16_t mb[MAILBOX_REGISTER_COUNT];
@@ -2701,7 +2699,7 @@
 static uint16_t
 qla1280_nvram_request(struct scsi_qla_host *ha, uint32_t nv_cmd)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	int cnt;
 	uint16_t data = 0;
 	uint16_t reg_data;
@@ -2744,7 +2742,7 @@
 static void
 qla1280_nv_write(struct scsi_qla_host *ha, uint16_t data)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 
 	WRT_REG_WORD(&reg->nvram, data | NV_SELECT);
 	RD_REG_WORD(&reg->id_l);	/* Flush PCI write */
@@ -2775,13 +2773,14 @@
 static int
 qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 #if 0
 	LIST_HEAD(done_q);
 #endif
 	int status = 0;
 	int cnt;
 	uint16_t *optr, *iptr;
+	uint16_t __iomem *mptr;
 	uint16_t data;
 	DECLARE_COMPLETION(wait);
 	struct timer_list timer;
@@ -2798,15 +2797,15 @@
 	 * available before starting sending the command data
 	 */
 	/* Load mailbox registers. */
-	optr = (uint16_t *) &reg->mailbox0;
+	mptr = (uint16_t __iomem *) &reg->mailbox0;
 	iptr = mb;
 	for (cnt = 0; cnt < MAILBOX_REGISTER_COUNT; cnt++) {
 		if (mr & BIT_0) {
-			WRT_REG_WORD(optr, (*iptr));
+			WRT_REG_WORD(mptr, (*iptr));
 		}
 
 		mr >>= 1;
-		optr++;
+		mptr++;
 		iptr++;
 	}
 
@@ -2882,7 +2881,7 @@
 static void
 qla1280_poll(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	uint16_t data;
 	LIST_HEAD(done_q);
 
@@ -3085,7 +3084,7 @@
 static void
 qla1280_reset_adapter(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 
 	ENTER("qla1280_reset_adapter");
 
@@ -3149,7 +3148,7 @@
 static int
 qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	struct scsi_cmnd *cmd = sp->cmd;
 	cmd_a64_entry_t *pkt;
 	struct scatterlist *sg = NULL;
@@ -3272,7 +3271,8 @@
 				dma_handle = sg_dma_address(sg);
 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
 				if (ha->flags.use_pci_vchannel)
-					sn_pci_set_vchan(ha->pdev, &dma_handle,
+					sn_pci_set_vchan(ha->pdev,
+							(unsigned long *)&dma_handle,
 							 SCSI_BUS_32(cmd));
 #endif
 				*dword_ptr++ =
@@ -3330,7 +3330,8 @@
 					dma_handle = sg_dma_address(sg);
 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
 				if (ha->flags.use_pci_vchannel)
-					sn_pci_set_vchan(ha->pdev, &dma_handle,
+					sn_pci_set_vchan(ha->pdev, 
+							(unsigned long *)&dma_handle,
 							 SCSI_BUS_32(cmd));
 #endif
 					*dword_ptr++ =
@@ -3364,7 +3365,8 @@
 			sp->saved_dma_handle = dma_handle;
 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
 			if (ha->flags.use_pci_vchannel)
-				sn_pci_set_vchan(ha->pdev, &dma_handle,
+				sn_pci_set_vchan(ha->pdev, 
+						(unsigned long *)&dma_handle,
 						 SCSI_BUS_32(cmd));
 #endif
 			*dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_handle));
@@ -3432,7 +3434,7 @@
 static int
 qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	struct scsi_cmnd *cmd = sp->cmd;
 	struct cmd_entry *pkt;
 	struct scatterlist *sg = NULL;
@@ -3692,7 +3694,7 @@
 static request_t *
 qla1280_req_pkt(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	request_t *pkt = NULL;
 	int cnt;
 	uint32_t timer;
@@ -3760,7 +3762,7 @@
 static void
 qla1280_isp_cmd(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 
 	ENTER("qla1280_isp_cmd");
 
@@ -3798,7 +3800,7 @@
 static void
 qla1280_isr(struct scsi_qla_host *ha, struct list_head *done_q)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	struct response *pkt;
 	struct srb *sp = NULL;
 	uint16_t mailbox[MAILBOX_REGISTER_COUNT];
@@ -4257,7 +4259,7 @@
 static int
 qla1280_abort_isp(struct scsi_qla_host *ha)
 {
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 	struct srb *sp;
 	int status = 0;
 	int cnt;
@@ -4335,7 +4337,7 @@
  *      register value.
  */
 static u16
-qla1280_debounce_register(volatile u16 * addr)
+qla1280_debounce_register(volatile u16 __iomem * addr)
 {
 	volatile u16 ret;
 	volatile u16 ret2;
@@ -4367,7 +4369,7 @@
 qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *ha, unsigned int bus)
 {
 	uint16_t config_reg, scsi_control;
-	struct device_reg *reg = ha->iobase;
+	struct device_reg __iomem *reg = ha->iobase;
 
 	if (ha->bus_settings[bus].scsi_bus_dead) {
 		WRT_REG_WORD(&reg->host_cmd, HC_PAUSE_RISC);
@@ -4641,6 +4643,7 @@
 
 #if LINUX_VERSION_CODE >= 0x020600
 static struct scsi_host_template qla1280_driver_template = {
+	.module			= THIS_MODULE,
 	.proc_name		= "qla1280",
 	.name			= "Qlogic ISP 1280/12160",
 	.info			= qla1280_info,
@@ -4785,7 +4788,7 @@
 	}
 
 	host->base = (unsigned long)ha->mmpbase;
-	ha->iobase = (struct device_reg *)ha->mmpbase;
+	ha->iobase = (struct device_reg __iomem *)ha->mmpbase;
 #else
 	host->io_port = pci_resource_start(ha->pdev, 0);
 	if (!request_region(host->io_port, 0xff, "qla1280")) {
diff -Nru a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h
--- a/drivers/scsi/qla1280.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/scsi/qla1280.h	2004-12-24 13:37:31 -08:00
@@ -1038,9 +1038,9 @@
 	/* Linux adapter configuration data */
 	struct Scsi_Host *host;	/* pointer to host data */
 	struct scsi_qla_host *next;
-	struct device_reg *iobase;	/* Base Memory-mapped I/O address */
+	struct device_reg __iomem *iobase;	/* Base Memory-mapped I/O address */
 
-	unsigned char *mmpbase;	/* memory mapped address */
+	unsigned char __iomem *mmpbase;	/* memory mapped address */
 	unsigned long host_no;
 	struct pci_dev *pdev;
 	uint8_t devnum;
diff -Nru a/drivers/scsi/qla2xxx/ql2300_fw.c b/drivers/scsi/qla2xxx/ql2300_fw.c
--- a/drivers/scsi/qla2xxx/ql2300_fw.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/qla2xxx/ql2300_fw.c	2004-12-24 13:36:48 -08:00
@@ -18,25 +18,25 @@
  *************************************************************************/
 
 /*
- *	Firmware Version 3.02.30 (07:51 Jun 16, 2004)
+ *	Firmware Version 3.03.02 (16:50 Aug 10, 2004)
  */
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw2300ipx_version = 3*1024+2;
+unsigned short fw2300ipx_version = 3*1024+3;
 #else
-unsigned short risc_code_version = 3*1024+2;
+unsigned short risc_code_version = 3*1024+3;
 #endif
 
 #ifdef UNIQUE_FW_NAME
-unsigned char fw2300ipx_version_str[] = {3, 2,30};
+unsigned char fw2300ipx_version_str[] = {3, 3, 2};
 #else
-unsigned char firmware_version[] = {3, 2,30};
+unsigned char firmware_version[] = {3, 3, 2};
 #endif
 
 #ifdef UNIQUE_FW_NAME
-#define fw2300ipx_VERSION_STRING "3.02.30"
+#define fw2300ipx_VERSION_STRING "3.03.02"
 #else
-#define FW_VERSION_STRING "3.02.30"
+#define FW_VERSION_STRING "3.03.02"
 #endif
 
 #ifdef UNIQUE_FW_NAME
@@ -50,12 +50,12 @@
 #else
 unsigned short risc_code01[] = { 
 #endif
-	0x0470, 0x0000, 0x0000, 0xe9e8, 0x0000, 0x0003, 0x0002, 0x001e,
+	0x0470, 0x0000, 0x0000, 0xea02, 0x0000, 0x0003, 0x0003, 0x0002,
 	0x0137, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2032, 0x3030,
 	0x3120, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
 	0x5449, 0x4f4e, 0x2049, 0x5350, 0x3233, 0x3030, 0x2046, 0x6972,
 	0x6d77, 0x6172, 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030,
-	0x332e, 0x3032, 0x2e33, 0x3020, 0x2020, 0x2020, 0x2400, 0x20a9,
+	0x332e, 0x3033, 0x2e30, 0x3220, 0x2020, 0x2020, 0x2400, 0x20a9,
 	0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2200, 0x20a9, 0x000f,
 	0x2001, 0x0000, 0x400f, 0x2091, 0x2400, 0x20a9, 0x000f, 0x2001,
 	0x0000, 0x400f, 0x2091, 0x2600, 0x20a9, 0x000f, 0x2001, 0x0000,
@@ -64,7 +64,7 @@
 	0x2c00, 0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2e00,
 	0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2000, 0x2001,
 	0x0000, 0x20c1, 0x0004, 0x20c9, 0x1bff, 0x2059, 0x0000, 0x2b78,
-	0x7883, 0x0004, 0x2089, 0x2d2b, 0x2051, 0x1800, 0x2a70, 0x20e1,
+	0x7883, 0x0004, 0x2089, 0x2d36, 0x2051, 0x1800, 0x2a70, 0x20e1,
 	0x0001, 0x20e9, 0x0001, 0x2009, 0x0000, 0x080c, 0x0e51, 0x2029,
 	0x4d00, 0x2031, 0xffff, 0x2039, 0x4cd0, 0x2021, 0x0200, 0x20e9,
 	0x0001, 0x20a1, 0x0000, 0x20a9, 0x0800, 0x900e, 0x4104, 0x20e9,
@@ -78,161 +78,161 @@
 	0x1800, 0x810d, 0x810d, 0x810d, 0x810d, 0x810d, 0x918c, 0x001f,
 	0x2001, 0x0001, 0x9112, 0x20e9, 0x0001, 0x20a1, 0x0800, 0x900e,
 	0x20a9, 0x0800, 0x4104, 0x8211, 0x1dd8, 0x080c, 0x0f17, 0x080c,
-	0x6031, 0x080c, 0xae07, 0x080c, 0x10ce, 0x080c, 0x12ed, 0x080c,
-	0x1ba6, 0x080c, 0x0d69, 0x080c, 0x1053, 0x080c, 0x3427, 0x080c,
-	0x76a1, 0x080c, 0x699f, 0x080c, 0x86df, 0x080c, 0x8413, 0x080c,
-	0x247a, 0x080c, 0x8f81, 0x080c, 0x7d6b, 0x080c, 0x22b3, 0x080c,
-	0x23e7, 0x080c, 0x246f, 0x2091, 0x3009, 0x7883, 0x0000, 0x1004,
+	0x603b, 0x080c, 0xadf5, 0x080c, 0x10ce, 0x080c, 0x12ed, 0x080c,
+	0x1bb1, 0x080c, 0x0d69, 0x080c, 0x1053, 0x080c, 0x3432, 0x080c,
+	0x76ad, 0x080c, 0x69ad, 0x080c, 0x86fc, 0x080c, 0x8430, 0x080c,
+	0x2485, 0x080c, 0x8fa0, 0x080c, 0x7d78, 0x080c, 0x22be, 0x080c,
+	0x23f2, 0x080c, 0x247a, 0x2091, 0x3009, 0x7883, 0x0000, 0x1004,
 	0x091f, 0x7880, 0x9086, 0x0002, 0x1190, 0x7883, 0x4000, 0x7837,
 	0x4000, 0x7833, 0x0010, 0x0e04, 0x0913, 0x2091, 0x5000, 0x2091,
 	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b, 0x2071,
 	0x1800, 0x7003, 0x0000, 0x2071, 0x1800, 0x7000, 0x908e, 0x0003,
-	0x1178, 0x080c, 0x4bd9, 0x080c, 0x344e, 0x080c, 0x7712, 0x080c,
-	0x6ed0, 0x080c, 0x87bd, 0x080c, 0x843c, 0x080c, 0x2c95, 0x0c58,
+	0x1178, 0x080c, 0x4be3, 0x080c, 0x3459, 0x080c, 0x771e, 0x080c,
+	0x6ede, 0x080c, 0x87da, 0x080c, 0x8459, 0x080c, 0x2ca0, 0x0c58,
 	0x000b, 0x0c78, 0x0944, 0x0945, 0x0ae7, 0x0942, 0x0bae, 0x0d68,
 	0x0d68, 0x0d68, 0x080c, 0x0dd5, 0x0005, 0x0126, 0x00f6, 0x2091,
-	0x8000, 0x7000, 0x9086, 0x0001, 0x1904, 0x0aba, 0x080c, 0x56e7,
+	0x8000, 0x7000, 0x9086, 0x0001, 0x1904, 0x0aba, 0x080c, 0x56f1,
 	0x1130, 0x0026, 0x2011, 0x0080, 0x080c, 0x0edf, 0x002e, 0x080c,
-	0x73a5, 0x0150, 0x080c, 0x73c8, 0x15a0, 0x2079, 0x0100, 0x7828,
-	0x9085, 0x1800, 0x782a, 0x0468, 0x080c, 0x72d7, 0x7000, 0x9086,
+	0x73b3, 0x0150, 0x080c, 0x73d6, 0x15a0, 0x2079, 0x0100, 0x7828,
+	0x9085, 0x1800, 0x782a, 0x0468, 0x080c, 0x72e5, 0x7000, 0x9086,
 	0x0001, 0x1904, 0x0aba, 0x7098, 0x9086, 0x0028, 0x1904, 0x0aba,
-	0x080c, 0x840b, 0x080c, 0x83fd, 0x2001, 0x0161, 0x2003, 0x0001,
+	0x080c, 0x8428, 0x080c, 0x841a, 0x2001, 0x0161, 0x2003, 0x0001,
 	0x2079, 0x0100, 0x7827, 0xffff, 0x7a28, 0x9295, 0x5e2f, 0x7a2a,
-	0x2011, 0x723b, 0x080c, 0x84dc, 0x2011, 0x722e, 0x080c, 0x85b6,
-	0x2011, 0x5e8c, 0x080c, 0x84dc, 0x2011, 0x8030, 0x901e, 0x7396,
-	0x04d0, 0x080c, 0x5739, 0x2079, 0x0100, 0x7844, 0x9005, 0x1904,
-	0x0aba, 0x2011, 0x5e8c, 0x080c, 0x84dc, 0x2011, 0x723b, 0x080c,
-	0x84dc, 0x2011, 0x722e, 0x080c, 0x85b6, 0x2001, 0x0265, 0x2001,
+	0x2011, 0x7249, 0x080c, 0x84f9, 0x2011, 0x723c, 0x080c, 0x85d3,
+	0x2011, 0x5e96, 0x080c, 0x84f9, 0x2011, 0x8030, 0x901e, 0x7396,
+	0x04d0, 0x080c, 0x5743, 0x2079, 0x0100, 0x7844, 0x9005, 0x1904,
+	0x0aba, 0x2011, 0x5e96, 0x080c, 0x84f9, 0x2011, 0x7249, 0x080c,
+	0x84f9, 0x2011, 0x723c, 0x080c, 0x85d3, 0x2001, 0x0265, 0x2001,
 	0x0205, 0x2003, 0x0000, 0x7840, 0x9084, 0xfffb, 0x7842, 0x2001,
 	0x19a5, 0x2004, 0x9005, 0x1140, 0x00c6, 0x2061, 0x0100, 0x080c,
-	0x5fd9, 0x00ce, 0x0804, 0x0aba, 0x780f, 0x006b, 0x7a28, 0x080c,
-	0x73ad, 0x0118, 0x9295, 0x5e2f, 0x0010, 0x9295, 0x402f, 0x7a2a,
+	0x5fe3, 0x00ce, 0x0804, 0x0aba, 0x780f, 0x006b, 0x7a28, 0x080c,
+	0x73bb, 0x0118, 0x9295, 0x5e2f, 0x0010, 0x9295, 0x402f, 0x7a2a,
 	0x2011, 0x8010, 0x73d8, 0x2001, 0x19a6, 0x2003, 0x0001, 0x080c,
-	0x2b5b, 0x080c, 0x4b14, 0x7248, 0xc284, 0x724a, 0x2001, 0x180c,
-	0x200c, 0xc1ac, 0xc1cc, 0x2102, 0x080c, 0xa51e, 0x2011, 0x0004,
-	0x080c, 0xcb5a, 0x080c, 0x682b, 0x080c, 0x73a5, 0x1120, 0x080c,
-	0x2b9f, 0x02e0, 0x0400, 0x080c, 0x5fe0, 0x0140, 0x7097, 0x0001,
-	0x70d3, 0x0000, 0x080c, 0x5906, 0x0804, 0x0aba, 0x080c, 0x56d8,
+	0x2b66, 0x080c, 0x4b1e, 0x7248, 0xc284, 0x724a, 0x2001, 0x180c,
+	0x200c, 0xc1ac, 0xc1cc, 0x2102, 0x080c, 0xa52f, 0x2011, 0x0004,
+	0x080c, 0xcb6a, 0x080c, 0x6839, 0x080c, 0x73b3, 0x1120, 0x080c,
+	0x2baa, 0x02e0, 0x0400, 0x080c, 0x5fea, 0x0140, 0x7097, 0x0001,
+	0x70d3, 0x0000, 0x080c, 0x5910, 0x0804, 0x0aba, 0x080c, 0x56e2,
 	0xd094, 0x0188, 0x2011, 0x180c, 0x2204, 0xc0cd, 0x2012, 0x080c,
-	0x56dc, 0xd0d4, 0x1118, 0x080c, 0x2b9f, 0x1270, 0x2011, 0x180c,
-	0x2204, 0xc0bc, 0x00a8, 0x080c, 0x56dc, 0xd0d4, 0x1db8, 0x2011,
+	0x56e6, 0xd0d4, 0x1118, 0x080c, 0x2baa, 0x1270, 0x2011, 0x180c,
+	0x2204, 0xc0bc, 0x00a8, 0x080c, 0x56e6, 0xd0d4, 0x1db8, 0x2011,
 	0x180c, 0x2204, 0xc0bd, 0x0060, 0x2011, 0x180c, 0x2204, 0xc0bd,
-	0x2012, 0x080c, 0x6973, 0x1128, 0xd0a4, 0x0118, 0x2204, 0xc0fd,
-	0x2012, 0x080c, 0x6939, 0x0120, 0x7a0c, 0xc2b4, 0x7a0e, 0x00a8,
-	0x707f, 0x0000, 0x080c, 0x73a5, 0x1130, 0x70b0, 0x9005, 0x1168,
-	0x080c, 0xcf9b, 0x0050, 0x080c, 0xcf9b, 0x70dc, 0xd09c, 0x1128,
-	0x70b0, 0x9005, 0x0110, 0x080c, 0x5fb6, 0x70e7, 0x0000, 0x70e3,
-	0x0000, 0x70a7, 0x0000, 0x080c, 0x2ba7, 0x0228, 0x2011, 0x0101,
-	0x2204, 0xc0c4, 0x2012, 0x72dc, 0x080c, 0x73a5, 0x1178, 0x9016,
-	0x0016, 0x080c, 0x2958, 0x2019, 0x196c, 0x211a, 0x001e, 0x705f,
+	0x2012, 0x080c, 0x6981, 0x1128, 0xd0a4, 0x0118, 0x2204, 0xc0fd,
+	0x2012, 0x080c, 0x6947, 0x0120, 0x7a0c, 0xc2b4, 0x7a0e, 0x00a8,
+	0x707f, 0x0000, 0x080c, 0x73b3, 0x1130, 0x70b0, 0x9005, 0x1168,
+	0x080c, 0xcfab, 0x0050, 0x080c, 0xcfab, 0x70dc, 0xd09c, 0x1128,
+	0x70b0, 0x9005, 0x0110, 0x080c, 0x5fc0, 0x70e7, 0x0000, 0x70e3,
+	0x0000, 0x70a7, 0x0000, 0x080c, 0x2bb2, 0x0228, 0x2011, 0x0101,
+	0x2204, 0xc0c4, 0x2012, 0x72dc, 0x080c, 0x73b3, 0x1178, 0x9016,
+	0x0016, 0x080c, 0x2963, 0x2019, 0x196c, 0x211a, 0x001e, 0x705f,
 	0xffff, 0x7063, 0x00ef, 0x7083, 0x0000, 0x0020, 0x2019, 0x196c,
 	0x201b, 0x0000, 0x2079, 0x1847, 0x7804, 0xd0ac, 0x0108, 0xc295,
-	0x72de, 0x080c, 0x73a5, 0x0118, 0x9296, 0x0004, 0x0548, 0x2011,
-	0x0001, 0x080c, 0xcb5a, 0x70ab, 0x0000, 0x70af, 0xffff, 0x7003,
+	0x72de, 0x080c, 0x73b3, 0x0118, 0x9296, 0x0004, 0x0548, 0x2011,
+	0x0001, 0x080c, 0xcb6a, 0x70ab, 0x0000, 0x70af, 0xffff, 0x7003,
 	0x0002, 0x2079, 0x0100, 0x7827, 0x0003, 0x7828, 0x9085, 0x0003,
-	0x782a, 0x00fe, 0x080c, 0x2f98, 0x2011, 0x0005, 0x080c, 0xa654,
-	0x080c, 0x9687, 0x080c, 0x73a5, 0x0148, 0x00c6, 0x2061, 0x0100,
-	0x0016, 0x080c, 0x2958, 0x61e2, 0x001e, 0x00ce, 0x012e, 0x0420,
+	0x782a, 0x00fe, 0x080c, 0x2fa3, 0x2011, 0x0005, 0x080c, 0xa63e,
+	0x080c, 0x96a6, 0x080c, 0x73b3, 0x0148, 0x00c6, 0x2061, 0x0100,
+	0x0016, 0x080c, 0x2963, 0x61e2, 0x001e, 0x00ce, 0x012e, 0x0420,
 	0x70ab, 0x0000, 0x70af, 0xffff, 0x7003, 0x0002, 0x00f6, 0x2079,
 	0x0100, 0x7827, 0x0003, 0x7828, 0x9085, 0x0003, 0x782a, 0x00fe,
-	0x2011, 0x0005, 0x080c, 0xa654, 0x080c, 0x9687, 0x080c, 0x73a5,
-	0x0148, 0x00c6, 0x2061, 0x0100, 0x0016, 0x080c, 0x2958, 0x61e2,
+	0x2011, 0x0005, 0x080c, 0xa63e, 0x080c, 0x96a6, 0x080c, 0x73b3,
+	0x0148, 0x00c6, 0x2061, 0x0100, 0x0016, 0x080c, 0x2963, 0x61e2,
 	0x001e, 0x00ce, 0x00fe, 0x012e, 0x0005, 0x00c6, 0x00b6, 0x080c,
-	0x73a5, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782, 0x080c,
-	0x73a5, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e, 0x86ff, 0x0138,
+	0x73b3, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782, 0x080c,
+	0x73b3, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e, 0x86ff, 0x0138,
 	0x9180, 0x1000, 0x2004, 0x905d, 0x0110, 0xb800, 0xd0bc, 0x090c,
-	0x32bd, 0x8108, 0x1f04, 0x0ace, 0x707f, 0x0000, 0x7080, 0x9084,
+	0x32c8, 0x8108, 0x1f04, 0x0ace, 0x707f, 0x0000, 0x7080, 0x9084,
 	0x00ff, 0x7082, 0x70b3, 0x0000, 0x00be, 0x00ce, 0x0005, 0x00b6,
 	0x0126, 0x2091, 0x8000, 0x7000, 0x9086, 0x0002, 0x1904, 0x0bab,
-	0x70ac, 0x9086, 0xffff, 0x0130, 0x080c, 0x2f98, 0x080c, 0x9687,
+	0x70ac, 0x9086, 0xffff, 0x0130, 0x080c, 0x2fa3, 0x080c, 0x96a6,
 	0x0804, 0x0bab, 0x70dc, 0xd0ac, 0x1110, 0xd09c, 0x0558, 0xd084,
 	0x0548, 0x0006, 0x2001, 0x0103, 0x2003, 0x002b, 0x000e, 0xd08c,
-	0x0508, 0x080c, 0x3320, 0x11d0, 0x70e0, 0x9086, 0xffff, 0x01b0,
-	0x080c, 0x312d, 0x080c, 0x9687, 0x70dc, 0xd094, 0x1904, 0x0bab,
-	0x2011, 0x0001, 0x080c, 0xd24a, 0x0110, 0x2011, 0x0003, 0x901e,
-	0x080c, 0x3167, 0x080c, 0x9687, 0x0804, 0x0bab, 0x70e4, 0x9005,
+	0x0508, 0x080c, 0x332b, 0x11d0, 0x70e0, 0x9086, 0xffff, 0x01b0,
+	0x080c, 0x3138, 0x080c, 0x96a6, 0x70dc, 0xd094, 0x1904, 0x0bab,
+	0x2011, 0x0001, 0x080c, 0xd25a, 0x0110, 0x2011, 0x0003, 0x901e,
+	0x080c, 0x3172, 0x080c, 0x96a6, 0x0804, 0x0bab, 0x70e4, 0x9005,
 	0x1904, 0x0bab, 0x70a8, 0x9005, 0x1904, 0x0bab, 0x70dc, 0xd0a4,
-	0x0118, 0xd0b4, 0x0904, 0x0bab, 0x080c, 0x6939, 0x1904, 0x0bab,
-	0x080c, 0x698c, 0x1904, 0x0bab, 0x080c, 0x6973, 0x01c0, 0x0156,
-	0x00c6, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6608, 0x1118,
+	0x0118, 0xd0b4, 0x0904, 0x0bab, 0x080c, 0x6947, 0x1904, 0x0bab,
+	0x080c, 0x699a, 0x1904, 0x0bab, 0x080c, 0x6981, 0x01c0, 0x0156,
+	0x00c6, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6616, 0x1118,
 	0xb800, 0xd0ec, 0x1138, 0x001e, 0x8108, 0x1f04, 0x0b44, 0x00ce,
 	0x015e, 0x0028, 0x001e, 0x00ce, 0x015e, 0x0804, 0x0bab, 0x0006,
 	0x2001, 0x0103, 0x2003, 0x002b, 0x000e, 0x2011, 0x19b2, 0x080c,
 	0x0f87, 0x2011, 0x19cc, 0x080c, 0x0f87, 0x7030, 0xc08c, 0x7032,
-	0x7003, 0x0003, 0x70af, 0xffff, 0x080c, 0x56e7, 0x1130, 0x0026,
-	0x2011, 0x0040, 0x080c, 0x0edf, 0x002e, 0x9006, 0x080c, 0x27ec,
-	0x080c, 0x3320, 0x0118, 0x080c, 0x4cb1, 0x0050, 0x0036, 0x0046,
-	0x2019, 0xffff, 0x2021, 0x0006, 0x080c, 0x4ccb, 0x004e, 0x003e,
-	0x00f6, 0x2079, 0x0100, 0x080c, 0x73c8, 0x0150, 0x080c, 0x73a5,
+	0x7003, 0x0003, 0x70af, 0xffff, 0x080c, 0x56f1, 0x1130, 0x0026,
+	0x2011, 0x0040, 0x080c, 0x0edf, 0x002e, 0x9006, 0x080c, 0x27f7,
+	0x080c, 0x332b, 0x0118, 0x080c, 0x4cbb, 0x0050, 0x0036, 0x0046,
+	0x2019, 0xffff, 0x2021, 0x0006, 0x080c, 0x4cd5, 0x004e, 0x003e,
+	0x00f6, 0x2079, 0x0100, 0x080c, 0x73d6, 0x0150, 0x080c, 0x73b3,
 	0x7828, 0x0118, 0x9084, 0xe1ff, 0x0010, 0x9084, 0xffdf, 0x782a,
 	0x00fe, 0x2001, 0x19e7, 0x2004, 0x9086, 0x0005, 0x1120, 0x2011,
-	0x0000, 0x080c, 0xa654, 0x2011, 0x0000, 0x080c, 0xa65e, 0x080c,
-	0x9687, 0x080c, 0x97b5, 0x012e, 0x00be, 0x0005, 0x0016, 0x0046,
+	0x0000, 0x080c, 0xa63e, 0x2011, 0x0000, 0x080c, 0xa648, 0x080c,
+	0x96a6, 0x080c, 0x97d4, 0x012e, 0x00be, 0x0005, 0x0016, 0x0046,
 	0x00f6, 0x0126, 0x2091, 0x8000, 0x2079, 0x0100, 0x7904, 0x918c,
-	0xfffd, 0x7906, 0x2009, 0x00f7, 0x080c, 0x5f9f, 0x7940, 0x918c,
+	0xfffd, 0x7906, 0x2009, 0x00f7, 0x080c, 0x5fa9, 0x7940, 0x918c,
 	0x0010, 0x7942, 0x7924, 0xd1b4, 0x0110, 0x7827, 0x0040, 0xd19c,
 	0x0110, 0x7827, 0x0008, 0x0006, 0x0036, 0x0156, 0x7954, 0xd1ac,
 	0x1904, 0x0c3b, 0x2001, 0x19a6, 0x2004, 0x9005, 0x1518, 0x080c,
-	0x2c22, 0x1148, 0x2001, 0x0001, 0x080c, 0x2b8a, 0x2001, 0x0001,
-	0x080c, 0x2b6d, 0x00b8, 0x080c, 0x2c2a, 0x1138, 0x9006, 0x080c,
-	0x2b8a, 0x9006, 0x080c, 0x2b6d, 0x0068, 0x080c, 0x2c32, 0x1d50,
-	0x2001, 0x1997, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c, 0x2984,
-	0x0804, 0x0d1a, 0x080c, 0x73b6, 0x0148, 0x080c, 0x73c8, 0x1118,
-	0x080c, 0x769c, 0x0050, 0x080c, 0x73ad, 0x0dd0, 0x080c, 0x7697,
-	0x080c, 0x768d, 0x080c, 0x72d7, 0x0058, 0x080c, 0x73a5, 0x0140,
-	0x2009, 0x00f8, 0x080c, 0x5f9f, 0x7843, 0x0090, 0x7843, 0x0010,
-	0x20a9, 0x09c4, 0x7820, 0xd09c, 0x1138, 0x080c, 0x73a5, 0x0138,
+	0x2c2d, 0x1148, 0x2001, 0x0001, 0x080c, 0x2b95, 0x2001, 0x0001,
+	0x080c, 0x2b78, 0x00b8, 0x080c, 0x2c35, 0x1138, 0x9006, 0x080c,
+	0x2b95, 0x9006, 0x080c, 0x2b78, 0x0068, 0x080c, 0x2c3d, 0x1d50,
+	0x2001, 0x1997, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c, 0x298f,
+	0x0804, 0x0d1a, 0x080c, 0x73c4, 0x0148, 0x080c, 0x73d6, 0x1118,
+	0x080c, 0x76a8, 0x0050, 0x080c, 0x73bb, 0x0dd0, 0x080c, 0x76a3,
+	0x080c, 0x7699, 0x080c, 0x72e5, 0x0058, 0x080c, 0x73b3, 0x0140,
+	0x2009, 0x00f8, 0x080c, 0x5fa9, 0x7843, 0x0090, 0x7843, 0x0010,
+	0x20a9, 0x09c4, 0x7820, 0xd09c, 0x1138, 0x080c, 0x73b3, 0x0138,
 	0x7824, 0xd0ac, 0x1904, 0x0d1f, 0x1f04, 0x0c1a, 0x0070, 0x7824,
-	0x080c, 0x73bf, 0x0118, 0xd0ac, 0x1904, 0x0d1f, 0x9084, 0x1800,
+	0x080c, 0x73cd, 0x0118, 0xd0ac, 0x1904, 0x0d1f, 0x9084, 0x1800,
 	0x0d98, 0x7003, 0x0001, 0x0804, 0x0d1f, 0x2001, 0x0001, 0x080c,
-	0x27ec, 0x0804, 0x0d32, 0x2001, 0x19a6, 0x2004, 0x9005, 0x1518,
-	0x080c, 0x2c22, 0x1148, 0x2001, 0x0001, 0x080c, 0x2b8a, 0x2001,
-	0x0001, 0x080c, 0x2b6d, 0x00b8, 0x080c, 0x2c2a, 0x1138, 0x9006,
-	0x080c, 0x2b8a, 0x9006, 0x080c, 0x2b6d, 0x0068, 0x080c, 0x2c32,
+	0x27f7, 0x0804, 0x0d32, 0x2001, 0x19a6, 0x2004, 0x9005, 0x1518,
+	0x080c, 0x2c2d, 0x1148, 0x2001, 0x0001, 0x080c, 0x2b95, 0x2001,
+	0x0001, 0x080c, 0x2b78, 0x00b8, 0x080c, 0x2c35, 0x1138, 0x9006,
+	0x080c, 0x2b95, 0x9006, 0x080c, 0x2b78, 0x0068, 0x080c, 0x2c3d,
 	0x1d50, 0x2001, 0x1997, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c,
-	0x2984, 0x0804, 0x0d1a, 0x7850, 0x9085, 0x0040, 0x7852, 0x7938,
-	0x7850, 0x9084, 0xfbcf, 0x7852, 0x080c, 0x2c3a, 0x9085, 0x2000,
-	0x7852, 0x793a, 0x20a9, 0x0046, 0x1d04, 0x0c74, 0x080c, 0x8596,
+	0x298f, 0x0804, 0x0d1a, 0x7850, 0x9085, 0x0040, 0x7852, 0x7938,
+	0x7850, 0x9084, 0xfbcf, 0x7852, 0x080c, 0x2c45, 0x9085, 0x2000,
+	0x7852, 0x793a, 0x20a9, 0x0046, 0x1d04, 0x0c74, 0x080c, 0x85b3,
 	0x1f04, 0x0c74, 0x7850, 0x9085, 0x0400, 0x9084, 0xdfbf, 0x7852,
-	0x793a, 0x080c, 0x73b6, 0x0148, 0x080c, 0x73c8, 0x1118, 0x080c,
-	0x769c, 0x0050, 0x080c, 0x73ad, 0x0dd0, 0x080c, 0x7697, 0x080c,
-	0x768d, 0x080c, 0x72d7, 0x0020, 0x2009, 0x00f8, 0x080c, 0x5f9f,
+	0x793a, 0x080c, 0x73c4, 0x0148, 0x080c, 0x73d6, 0x1118, 0x080c,
+	0x76a8, 0x0050, 0x080c, 0x73bb, 0x0dd0, 0x080c, 0x76a3, 0x080c,
+	0x7699, 0x080c, 0x72e5, 0x0020, 0x2009, 0x00f8, 0x080c, 0x5fa9,
 	0x20a9, 0x0028, 0xa001, 0x1f04, 0x0c9a, 0x7850, 0x9085, 0x1400,
-	0x7852, 0x080c, 0x73a5, 0x0120, 0x7843, 0x0090, 0x7843, 0x0010,
-	0x2021, 0xe678, 0x2019, 0xea60, 0x0d0c, 0x8596, 0x7820, 0xd09c,
-	0x1580, 0x080c, 0x73a5, 0x0904, 0x0cff, 0x7824, 0xd0ac, 0x1904,
-	0x0d1f, 0x080c, 0x73c8, 0x1528, 0x0046, 0x2021, 0x0320, 0x8421,
-	0x1df0, 0x004e, 0x7827, 0x1800, 0x080c, 0x2c3a, 0x7824, 0x9084,
+	0x7852, 0x080c, 0x73b3, 0x0120, 0x7843, 0x0090, 0x7843, 0x0010,
+	0x2021, 0xe678, 0x2019, 0xea60, 0x0d0c, 0x85b3, 0x7820, 0xd09c,
+	0x1580, 0x080c, 0x73b3, 0x0904, 0x0cff, 0x7824, 0xd0ac, 0x1904,
+	0x0d1f, 0x080c, 0x73d6, 0x1528, 0x0046, 0x2021, 0x0320, 0x8421,
+	0x1df0, 0x004e, 0x7827, 0x1800, 0x080c, 0x2c45, 0x7824, 0x9084,
 	0x1800, 0x1160, 0x9484, 0x0fff, 0x1138, 0x2001, 0x1810, 0x2004,
 	0xd0fc, 0x0110, 0x080c, 0x0d45, 0x8421, 0x1158, 0x1d04, 0x0cda,
-	0x080c, 0x8596, 0x080c, 0x7697, 0x080c, 0x768d, 0x7003, 0x0001,
-	0x04f0, 0x8319, 0x1948, 0x1d04, 0x0ce7, 0x080c, 0x8596, 0x2009,
+	0x080c, 0x85b3, 0x080c, 0x76a3, 0x080c, 0x7699, 0x7003, 0x0001,
+	0x04f0, 0x8319, 0x1948, 0x1d04, 0x0ce7, 0x080c, 0x85b3, 0x2009,
 	0x199a, 0x2104, 0x9005, 0x0118, 0x8001, 0x200a, 0x1178, 0x200b,
-	0x000a, 0x7827, 0x0048, 0x20a9, 0x0002, 0x080c, 0x2c1b, 0x7924,
-	0x080c, 0x2c3a, 0xd19c, 0x0110, 0x080c, 0x2b5b, 0x00d8, 0x080c,
-	0x73b6, 0x1140, 0x94a2, 0x03e8, 0x1128, 0x080c, 0x737d, 0x7003,
-	0x0001, 0x00a8, 0x7827, 0x1800, 0x080c, 0x2c3a, 0x7824, 0x080c,
-	0x73bf, 0x0110, 0xd0ac, 0x1158, 0x9084, 0x1800, 0x0950, 0x7003,
-	0x0001, 0x0028, 0x2001, 0x0001, 0x080c, 0x27ec, 0x0078, 0x2009,
+	0x000a, 0x7827, 0x0048, 0x20a9, 0x0002, 0x080c, 0x2c26, 0x7924,
+	0x080c, 0x2c45, 0xd19c, 0x0110, 0x080c, 0x2b66, 0x00d8, 0x080c,
+	0x73c4, 0x1140, 0x94a2, 0x03e8, 0x1128, 0x080c, 0x738b, 0x7003,
+	0x0001, 0x00a8, 0x7827, 0x1800, 0x080c, 0x2c45, 0x7824, 0x080c,
+	0x73cd, 0x0110, 0xd0ac, 0x1158, 0x9084, 0x1800, 0x0950, 0x7003,
+	0x0001, 0x0028, 0x2001, 0x0001, 0x080c, 0x27f7, 0x0078, 0x2009,
 	0x180c, 0x210c, 0xd19c, 0x1120, 0x7904, 0x918d, 0x0002, 0x7906,
 	0x7827, 0x0048, 0x7828, 0x9085, 0x0028, 0x782a, 0x7850, 0x9085,
 	0x0400, 0x7852, 0x2001, 0x19a6, 0x2003, 0x0000, 0x9006, 0x78f2,
-	0x015e, 0x003e, 0x000e, 0x080c, 0x56e7, 0x1110, 0x080c, 0x0e62,
+	0x015e, 0x003e, 0x000e, 0x080c, 0x56f1, 0x1110, 0x080c, 0x0e62,
 	0x012e, 0x00fe, 0x004e, 0x001e, 0x0005, 0x0006, 0x0016, 0x0036,
 	0x0046, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0156, 0x0069,
-	0x0d0c, 0x8596, 0x015e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be,
+	0x0d0c, 0x85b3, 0x015e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be,
 	0x004e, 0x003e, 0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0x189e,
-	0x7004, 0x9086, 0x0001, 0x1110, 0x080c, 0x344e, 0x00ee, 0x0005,
-	0x0005, 0x2a70, 0x2061, 0x19aa, 0x2063, 0x0003, 0x6007, 0x0002,
-	0x600b, 0x001e, 0x600f, 0x0137, 0x2001, 0x197b, 0x900e, 0x2102,
+	0x7004, 0x9086, 0x0001, 0x1110, 0x080c, 0x3459, 0x00ee, 0x0005,
+	0x0005, 0x2a70, 0x2061, 0x19aa, 0x2063, 0x0003, 0x6007, 0x0003,
+	0x600b, 0x0002, 0x600f, 0x0137, 0x2001, 0x197b, 0x900e, 0x2102,
 	0x7196, 0x2001, 0x0100, 0x2004, 0x9082, 0x0002, 0x0218, 0x705f,
 	0xffff, 0x0008, 0x715e, 0x7067, 0xffff, 0x717e, 0x7182, 0x080c,
-	0xcf9b, 0x2061, 0x196b, 0x6003, 0x0909, 0x6106, 0x600b, 0x8800,
+	0xcfab, 0x2061, 0x196b, 0x6003, 0x0909, 0x6106, 0x600b, 0x8800,
 	0x600f, 0x0200, 0x6013, 0x00ff, 0x6017, 0x001f, 0x611a, 0x601f,
 	0x07d0, 0x2061, 0x1973, 0x6003, 0x8000, 0x6106, 0x610a, 0x600f,
 	0x0200, 0x6013, 0x00ff, 0x6116, 0x601b, 0x0001, 0x611e, 0x2061,
 	0x1988, 0x6003, 0x514c, 0x6007, 0x4f47, 0x600b, 0x4943, 0x600f,
-	0x2020, 0x2001, 0x182c, 0x2102, 0x0005, 0x9016, 0x080c, 0x6608,
+	0x2020, 0x2001, 0x182c, 0x2102, 0x0005, 0x9016, 0x080c, 0x6616,
 	0x1178, 0xb804, 0x90c4, 0x00ff, 0x98c6, 0x0006, 0x0128, 0x90c4,
 	0xff00, 0x98c6, 0x0600, 0x1120, 0x9186, 0x0080, 0x0108, 0x8210,
 	0x8108, 0x9186, 0x0800, 0x1d50, 0x2208, 0x0005, 0x2091, 0x8000,
@@ -251,11 +251,11 @@
 	0x1800, 0x7803, 0x0005, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
 	0xd084, 0x0180, 0x2001, 0x1a18, 0x2004, 0x9005, 0x0128, 0x2001,
 	0x008b, 0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002,
-	0x2003, 0x1001, 0x080c, 0x56e7, 0x1110, 0x080c, 0x0e99, 0x0cd0,
+	0x2003, 0x1001, 0x080c, 0x56f1, 0x1110, 0x080c, 0x0e99, 0x0cd0,
 	0x0005, 0x918c, 0x03ff, 0x2001, 0x0003, 0x2004, 0x9084, 0x0600,
 	0x1118, 0x918d, 0x2800, 0x0010, 0x918d, 0x2000, 0x2001, 0x017f,
 	0x2102, 0x0005, 0x00f6, 0x0006, 0x2079, 0x1827, 0x2f04, 0x8000,
-	0x207a, 0x080c, 0x2c32, 0x1150, 0x0006, 0x2001, 0x1997, 0x2004,
+	0x207a, 0x080c, 0x2c3d, 0x1150, 0x0006, 0x2001, 0x1997, 0x2004,
 	0xd0fc, 0x000e, 0x1118, 0x9082, 0x7530, 0x0010, 0x9082, 0x000f,
 	0x0258, 0x9006, 0x207a, 0x2079, 0x182a, 0x2f04, 0x9084, 0x0001,
 	0x9086, 0x0001, 0x207a, 0x0090, 0x2079, 0x182a, 0x2f7c, 0x8fff,
@@ -266,8 +266,8 @@
 	0x080c, 0x0f00, 0x0c80, 0x7038, 0xd0b4, 0x1128, 0x0026, 0x2011,
 	0x0040, 0x0469, 0x002e, 0x0005, 0x7038, 0xd0b4, 0x1128, 0x0026,
 	0x2011, 0x0080, 0x0421, 0x002e, 0x0005, 0x0026, 0x70ef, 0x0000,
-	0x0459, 0x1148, 0x080c, 0x2c32, 0x1118, 0x2011, 0x8484, 0x0058,
-	0x2011, 0x8282, 0x0040, 0x080c, 0x2c32, 0x1118, 0x2011, 0xcdc5,
+	0x0459, 0x1148, 0x080c, 0x2c3d, 0x1118, 0x2011, 0x8484, 0x0058,
+	0x2011, 0x8282, 0x0040, 0x080c, 0x2c3d, 0x1118, 0x2011, 0xcdc5,
 	0x0010, 0x2011, 0xcac2, 0x00e9, 0x002e, 0x0005, 0xd0b4, 0x0130,
 	0x0006, 0x3b00, 0x9084, 0xff3f, 0x20d8, 0x000e, 0x0005, 0x0016,
 	0x3b08, 0x3a00, 0x9104, 0x918d, 0x00c0, 0x21d8, 0x9084, 0xff3f,
@@ -315,7 +315,7 @@
 	0x0cd8, 0x00e6, 0x0126, 0x2091, 0x8000, 0x0016, 0x890e, 0x810e,
 	0x810f, 0x9184, 0x003f, 0xa862, 0x9184, 0xffc0, 0xa85e, 0x001e,
 	0x0020, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x702c,
-	0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x83fd,
+	0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x841a,
 	0x012e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9026, 0x2009, 0x0000,
 	0x2049, 0x0400, 0x2900, 0x702e, 0x8940, 0x2800, 0xa802, 0xa95e,
 	0xa863, 0x0001, 0x8420, 0x9886, 0x0440, 0x0120, 0x2848, 0x9188,
@@ -380,15 +380,15 @@
 	0x080c, 0x1108, 0x0005, 0x00de, 0x009e, 0x080c, 0x1108, 0x0005,
 	0xa8a8, 0xd08c, 0x0005, 0x0096, 0xa0a0, 0x904d, 0x090c, 0x0dd5,
 	0xa06c, 0x908e, 0x0100, 0x0130, 0xa87b, 0x0030, 0xa883, 0x0000,
-	0xa897, 0x4002, 0x080c, 0x6c7a, 0xa09f, 0x0000, 0xa0a3, 0x0000,
+	0xa897, 0x4002, 0x080c, 0x6c88, 0xa09f, 0x0000, 0xa0a3, 0x0000,
 	0x2848, 0x080c, 0x1031, 0x009e, 0x0005, 0x00a6, 0xa0a0, 0x904d,
 	0x090c, 0x0dd5, 0xa06c, 0x908e, 0x0100, 0x0128, 0xa87b, 0x0001,
 	0xa883, 0x0000, 0x00c0, 0xa80c, 0x2050, 0xb004, 0x9005, 0x0198,
 	0xa80e, 0x2050, 0x8006, 0x8006, 0x8007, 0x908c, 0x003f, 0x9084,
 	0xffc0, 0x9080, 0x0002, 0xa076, 0xa172, 0xb000, 0xa07a, 0x2810,
 	0x080c, 0x10e9, 0x00e8, 0xa97c, 0xa894, 0x0016, 0x0006, 0x080c,
-	0x6c7a, 0x000e, 0x001e, 0xd1fc, 0x1138, 0xd1f4, 0x0128, 0x00c6,
-	0x2060, 0x080c, 0xae71, 0x00ce, 0x7008, 0x2048, 0xa89f, 0x0000,
+	0x6c88, 0x000e, 0x001e, 0xd1fc, 0x1138, 0xd1f4, 0x0128, 0x00c6,
+	0x2060, 0x080c, 0xae5f, 0x00ce, 0x7008, 0x2048, 0xa89f, 0x0000,
 	0xa8a3, 0x0000, 0x080c, 0x1031, 0x7007, 0x0000, 0x080c, 0x1108,
 	0x00ae, 0x0005, 0x0126, 0x2091, 0x8000, 0x782b, 0x1001, 0x7007,
 	0x0005, 0x7000, 0xc094, 0x7002, 0x012e, 0x0005, 0x0096, 0x2001,
@@ -397,12 +397,12 @@
 	0x8000, 0x782b, 0x0041, 0x7007, 0x0003, 0x7000, 0xc084, 0x7002,
 	0x2900, 0x700a, 0x012e, 0x009e, 0x0005, 0x20e1, 0x0000, 0x2099,
 	0x0088, 0x782b, 0x0040, 0x0096, 0x2001, 0x192e, 0x204c, 0xaa7c,
-	0x009e, 0x080c, 0x89f5, 0x2009, 0x188c, 0x2104, 0x9084, 0xfffc,
-	0x200a, 0x080c, 0x8868, 0x7007, 0x0000, 0x080c, 0x1119, 0x0005,
+	0x009e, 0x080c, 0x8a12, 0x2009, 0x188c, 0x2104, 0x9084, 0xfffc,
+	0x200a, 0x080c, 0x8885, 0x7007, 0x0000, 0x080c, 0x1119, 0x0005,
 	0x7007, 0x0000, 0x080c, 0x1119, 0x0005, 0x0126, 0x2091, 0x2200,
 	0x2079, 0x0300, 0x2071, 0x1a61, 0x7003, 0x0000, 0x78bf, 0x00f6,
 	0x781b, 0x4800, 0x00c1, 0x7803, 0x0003, 0x780f, 0x0000, 0x20a9,
-	0x03d0, 0x2061, 0xea39, 0x2c0d, 0x7912, 0xe104, 0x9ce0, 0x0002,
+	0x03d0, 0x2061, 0xea53, 0x2c0d, 0x7912, 0xe104, 0x9ce0, 0x0002,
 	0x7916, 0x1f04, 0x1303, 0x7807, 0x0007, 0x7803, 0x0000, 0x7803,
 	0x0001, 0x012e, 0x0005, 0x00c6, 0x7803, 0x0000, 0x7808, 0xd09c,
 	0x0120, 0x7820, 0x080c, 0x1362, 0x0cc8, 0x2001, 0x1a62, 0x2003,
@@ -411,13 +411,13 @@
 	0x782b, 0x1a81, 0x781f, 0xff00, 0x781b, 0xb700, 0x2001, 0x0200,
 	0x2004, 0xd0dc, 0x0110, 0x781f, 0x0303, 0x2061, 0x1a81, 0x602f,
 	0x1cd0, 0x2001, 0x181a, 0x2004, 0x9082, 0x1cd0, 0x6032, 0x603b,
-	0x2092, 0x2001, 0x3327, 0xd0fc, 0x190c, 0x0dd5, 0x2001, 0x0003,
-	0x2004, 0xd0d4, 0x1118, 0x783f, 0x3327, 0x0020, 0x9084, 0xc000,
-	0x783f, 0xb327, 0x604f, 0x193c, 0x2001, 0x1927, 0x2004, 0x6042,
+	0x209d, 0x2001, 0x3332, 0xd0fc, 0x190c, 0x0dd5, 0x2001, 0x0003,
+	0x2004, 0xd0d4, 0x1118, 0x783f, 0x3332, 0x0020, 0x9084, 0xc000,
+	0x783f, 0xb332, 0x604f, 0x193c, 0x2001, 0x1927, 0x2004, 0x6042,
 	0x00ce, 0x0005, 0x9086, 0x000d, 0x11d0, 0x7808, 0xd09c, 0x01b8,
-	0x7820, 0x0026, 0x2010, 0x080c, 0xcb38, 0x0180, 0x2260, 0x6000,
+	0x7820, 0x0026, 0x2010, 0x080c, 0xcb48, 0x0180, 0x2260, 0x6000,
 	0x9086, 0x0004, 0x1158, 0x0016, 0x6120, 0x9186, 0x0009, 0x0108,
-	0x0020, 0x2009, 0x004c, 0x080c, 0xaeec, 0x001e, 0x002e, 0x0005,
+	0x0020, 0x2009, 0x004c, 0x080c, 0xaeda, 0x001e, 0x002e, 0x0005,
 	0x0126, 0x2091, 0x2200, 0x7908, 0x9184, 0x0070, 0x190c, 0x0dce,
 	0xd19c, 0x0158, 0x7820, 0x908c, 0xf000, 0x15e8, 0x908a, 0x0024,
 	0x1a0c, 0x0dd5, 0x0023, 0x012e, 0x0005, 0x012e, 0x0005, 0x13bb,
@@ -426,18 +426,18 @@
 	0x155d, 0x1568, 0x156f, 0x13bb, 0x13bb, 0x13bb, 0x13bb, 0x13bb,
 	0x13bb, 0x13bb, 0x13e2, 0x13bb, 0x13bb, 0x13bb, 0x13bb, 0x13bb,
 	0x13bb, 0x13bf, 0x13bd, 0x080c, 0x0dd5, 0x080c, 0x0dce, 0x080c,
-	0x157a, 0x2009, 0x1a7a, 0x2104, 0x8000, 0x200a, 0x080c, 0x7e3f,
-	0x080c, 0x1aab, 0x0005, 0x2009, 0x0048, 0x2060, 0x080c, 0xaeec,
+	0x157a, 0x2009, 0x1a7a, 0x2104, 0x8000, 0x200a, 0x080c, 0x7e4c,
+	0x080c, 0x1abb, 0x0005, 0x2009, 0x0048, 0x2060, 0x080c, 0xaeda,
 	0x012e, 0x0005, 0x7004, 0xc085, 0xc0b5, 0x7006, 0x0005, 0x7004,
 	0xc085, 0x7006, 0x0005, 0x080c, 0x157a, 0x080c, 0x16bd, 0x0005,
 	0x080c, 0x0dd5, 0x080c, 0x157a, 0x2060, 0x6014, 0x0096, 0x2048,
-	0xa83b, 0xffff, 0x009e, 0x2009, 0x0048, 0x080c, 0xaeec, 0x2001,
+	0xa83b, 0xffff, 0x009e, 0x2009, 0x0048, 0x080c, 0xaeda, 0x2001,
 	0x015d, 0x2003, 0x0000, 0x2009, 0x03e8, 0x8109, 0x0160, 0x2001,
 	0x0201, 0x2004, 0x9005, 0x0dc8, 0x2001, 0x0218, 0x2004, 0xd0ec,
 	0x1110, 0x080c, 0x157f, 0x2001, 0x0307, 0x2003, 0x8000, 0x0005,
 	0x7004, 0xc095, 0x7006, 0x0005, 0x080c, 0x157a, 0x2060, 0x6014,
 	0x0096, 0x2048, 0xa83b, 0xffff, 0x009e, 0x2009, 0x0048, 0x080c,
-	0xaeec, 0x0005, 0x080c, 0x157a, 0x080c, 0x0dd5, 0x080c, 0x157a,
+	0xaeda, 0x0005, 0x080c, 0x157a, 0x080c, 0x0dd5, 0x080c, 0x157a,
 	0x080c, 0x14d6, 0x7827, 0x0018, 0x79ac, 0xd1dc, 0x0904, 0x1487,
 	0x7827, 0x0015, 0x7828, 0x782b, 0x0000, 0x9065, 0x0140, 0x2001,
 	0x020d, 0x2003, 0x0050, 0x2003, 0x0020, 0x0804, 0x148d, 0x7004,
@@ -446,20 +446,20 @@
 	0x2003, 0x0020, 0x0804, 0x14bb, 0x78ab, 0x0004, 0x7803, 0x0001,
 	0x080c, 0x14ef, 0x0005, 0x7827, 0x0018, 0xa001, 0x7828, 0x7827,
 	0x0011, 0xa001, 0x7928, 0x9106, 0x0110, 0x79ac, 0x08e0, 0x00e6,
-	0x2071, 0x0200, 0x702c, 0xd0c4, 0x0140, 0x00ee, 0x080c, 0x1aab,
+	0x2071, 0x0200, 0x702c, 0xd0c4, 0x0140, 0x00ee, 0x080c, 0x1abb,
 	0x080c, 0x1313, 0x7803, 0x0001, 0x0005, 0x7037, 0x0001, 0xa001,
 	0x7150, 0x00ee, 0x918c, 0xff00, 0x9186, 0x0500, 0x0110, 0x79ac,
 	0x0810, 0x7004, 0xc09d, 0x7006, 0x78ab, 0x0004, 0x7803, 0x0001,
 	0x080c, 0x14ef, 0x2001, 0x020d, 0x2003, 0x0020, 0x0005, 0x7828,
 	0x782b, 0x0000, 0x9065, 0x090c, 0x0dd5, 0x6014, 0x2048, 0x78ab,
-	0x0004, 0x918c, 0x0700, 0x01a8, 0x080c, 0x7e3f, 0x080c, 0x1aab,
-	0x080c, 0xcb4a, 0x0158, 0xa9ac, 0xa936, 0xa9b0, 0xa93a, 0xa83f,
+	0x0004, 0x918c, 0x0700, 0x01a8, 0x080c, 0x7e4c, 0x080c, 0x1abb,
+	0x080c, 0xcb5a, 0x0158, 0xa9ac, 0xa936, 0xa9b0, 0xa93a, 0xa83f,
 	0xffff, 0xa843, 0xffff, 0xa880, 0xc0bd, 0xa882, 0x080c, 0xc77b,
 	0x0005, 0x6020, 0x9086, 0x0009, 0x1128, 0x2009, 0x004c, 0x080c,
-	0xaeec, 0x0048, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
-	0x6024, 0x190c, 0xcf34, 0x2029, 0x00c8, 0x8529, 0x0128, 0x2001,
-	0x0201, 0x2004, 0x9005, 0x0dc8, 0x7dbc, 0x080c, 0xe9e2, 0xd5a4,
-	0x1118, 0x080c, 0x157f, 0x0005, 0x080c, 0x7e3f, 0x080c, 0x1aab,
+	0xaeda, 0x0048, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
+	0x6024, 0x190c, 0xcf44, 0x2029, 0x00c8, 0x8529, 0x0128, 0x2001,
+	0x0201, 0x2004, 0x9005, 0x0dc8, 0x7dbc, 0x080c, 0xe9fc, 0xd5a4,
+	0x1118, 0x080c, 0x157f, 0x0005, 0x080c, 0x7e4c, 0x080c, 0x1abb,
 	0x0005, 0x781f, 0x0300, 0x7803, 0x0001, 0x0005, 0x0016, 0x0066,
 	0x0076, 0x00f6, 0x2079, 0x0300, 0x7908, 0x918c, 0x0007, 0x9186,
 	0x0003, 0x0120, 0x2001, 0x0016, 0x080c, 0x15f0, 0x00fe, 0x007e,
@@ -477,9 +477,9 @@
 	0x0040, 0x2001, 0x020d, 0x2003, 0x0020, 0x080c, 0x1313, 0x7803,
 	0x0001, 0x00ee, 0x001e, 0x0005, 0x2001, 0x020d, 0x2003, 0x0050,
 	0x2003, 0x0020, 0x0461, 0x0ca8, 0x0429, 0x2060, 0x2009, 0x0053,
-	0x080c, 0xaeec, 0x0005, 0x0005, 0x0005, 0x00e1, 0x2008, 0x00d1,
-	0x0006, 0x7004, 0xc09d, 0x7006, 0x000e, 0x080c, 0x8d52, 0x0005,
-	0x0089, 0x9005, 0x0118, 0x080c, 0x8955, 0x0cd0, 0x0005, 0x2001,
+	0x080c, 0xaeda, 0x0005, 0x0005, 0x0005, 0x00e1, 0x2008, 0x00d1,
+	0x0006, 0x7004, 0xc09d, 0x7006, 0x000e, 0x080c, 0x8d71, 0x0005,
+	0x0089, 0x9005, 0x0118, 0x080c, 0x8972, 0x0cd0, 0x0005, 0x2001,
 	0x0036, 0x2009, 0x1820, 0x210c, 0x2011, 0x181f, 0x2214, 0x080c,
 	0x15f0, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820, 0x0005, 0x080c,
 	0x14d6, 0x00d6, 0x2069, 0x0200, 0x2009, 0x01f4, 0x8109, 0x0510,
@@ -489,7 +489,7 @@
 	0x080c, 0x15e2, 0x6827, 0x0001, 0x8109, 0x1dd0, 0x04d9, 0x6827,
 	0x0002, 0x04c1, 0x6804, 0x9005, 0x1130, 0x682c, 0xd0e4, 0x1500,
 	0x6804, 0x9005, 0x0de8, 0x79b8, 0xd1ec, 0x1130, 0x08c0, 0x080c,
-	0x7e3f, 0x080c, 0x1aab, 0x0090, 0x7827, 0x0015, 0x782b, 0x0000,
+	0x7e4c, 0x080c, 0x1abb, 0x0090, 0x7827, 0x0015, 0x782b, 0x0000,
 	0x7827, 0x0018, 0x782b, 0x0000, 0x2001, 0x020d, 0x2003, 0x0020,
 	0x2001, 0x0307, 0x2003, 0x0300, 0x7803, 0x0001, 0x00de, 0x0005,
 	0x682c, 0x9084, 0x5400, 0x9086, 0x5400, 0x0d30, 0x7827, 0x0015,
@@ -505,17 +505,17 @@
 	0x1669, 0x9284, 0x0048, 0x9086, 0x0008, 0x1904, 0x1669, 0x2001,
 	0x0109, 0x2004, 0xd08c, 0x01f0, 0x0006, 0x01c6, 0x01d6, 0x0136,
 	0x0146, 0x0156, 0x0126, 0x2091, 0x2800, 0x00f6, 0x0026, 0x0016,
-	0x2009, 0x1a7c, 0x2104, 0x8000, 0x0208, 0x200a, 0x080c, 0x908b,
+	0x2009, 0x1a7c, 0x2104, 0x8000, 0x0208, 0x200a, 0x080c, 0x90aa,
 	0x001e, 0x002e, 0x00fe, 0x012e, 0x015e, 0x014e, 0x013e, 0x01de,
 	0x01ce, 0x000e, 0x2001, 0x009b, 0x2004, 0xd0fc, 0x01d0, 0x0006,
 	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x00f6, 0x0016,
-	0x2009, 0x1a7d, 0x2104, 0x8000, 0x0208, 0x200a, 0x080c, 0x1eb6,
+	0x2009, 0x1a7d, 0x2104, 0x8000, 0x0208, 0x200a, 0x080c, 0x1ec1,
 	0x001e, 0x00fe, 0x015e, 0x014e, 0x013e, 0x01de, 0x01ce, 0x012e,
 	0x000e, 0x7818, 0xd0bc, 0x1904, 0x1619, 0x0005, 0x2001, 0x180c,
 	0x2004, 0xd0f4, 0x1528, 0x7a18, 0x9284, 0x0030, 0x0508, 0x9284,
 	0x0048, 0x9086, 0x0008, 0x11e0, 0x2001, 0x19f5, 0x2004, 0x9005,
 	0x01b8, 0x2001, 0x1a65, 0x2004, 0x9086, 0x0000, 0x0188, 0x2009,
-	0x1a7b, 0x2104, 0x8000, 0x0208, 0x200a, 0x080c, 0xa2f8, 0x2009,
+	0x1a7b, 0x2104, 0x8000, 0x0208, 0x200a, 0x080c, 0xa30d, 0x2009,
 	0x180c, 0x2104, 0xc0f5, 0x200a, 0x2009, 0xff00, 0x0804, 0x1619,
 	0x9085, 0x0001, 0x0005, 0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080,
 	0x080c, 0x1612, 0x1108, 0x0005, 0x792c, 0x3900, 0x8000, 0x2004,
@@ -526,32 +526,32 @@
 	0x171c, 0x7017, 0x0000, 0x2001, 0x0264, 0x2004, 0xd0bc, 0x0904,
 	0x171c, 0x2001, 0x0268, 0x00c6, 0x2064, 0x6104, 0x6038, 0x00ce,
 	0x918e, 0x0039, 0x1904, 0x171c, 0x9c06, 0x15f0, 0x0126, 0x2091,
-	0x2600, 0x080c, 0x7d86, 0x012e, 0x7358, 0x745c, 0x6014, 0x905d,
+	0x2600, 0x080c, 0x7d93, 0x012e, 0x7358, 0x745c, 0x6014, 0x905d,
 	0x0598, 0x2b48, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
-	0x190c, 0xcf0f, 0xab42, 0xac3e, 0x2001, 0x1869, 0x2004, 0xd0b4,
+	0x190c, 0xcf1f, 0xab42, 0xac3e, 0x2001, 0x1869, 0x2004, 0xd0b4,
 	0x1170, 0x601c, 0xd0e4, 0x1158, 0x6010, 0x00b6, 0x2058, 0xb800,
 	0x00be, 0xd0bc, 0x1120, 0xa83b, 0x7fff, 0xa837, 0xffff, 0x080c,
-	0x20b2, 0x1190, 0x080c, 0x1909, 0x2a00, 0xa816, 0x0130, 0x2800,
+	0x20bd, 0x1190, 0x080c, 0x1909, 0x2a00, 0xa816, 0x0130, 0x2800,
 	0xa80e, 0x2c05, 0xa80a, 0x2c00, 0xa812, 0x7037, 0x0020, 0x781f,
 	0x0300, 0x001e, 0x00ee, 0x0005, 0x7037, 0x0050, 0x7037, 0x0020,
 	0x001e, 0x00ee, 0x080c, 0x157f, 0x0005, 0x080c, 0x0dd5, 0x2ff0,
 	0x0126, 0x2091, 0x2200, 0x00c6, 0x3e60, 0x6014, 0x2048, 0x2940,
 	0x903e, 0x2730, 0xa864, 0x2068, 0xa81a, 0x9d84, 0x000f, 0x9088,
-	0x2092, 0x2165, 0x0002, 0x1752, 0x17c0, 0x1752, 0x1752, 0x1756,
+	0x209d, 0x2165, 0x0002, 0x1752, 0x17c0, 0x1752, 0x1752, 0x1756,
 	0x17a1, 0x1752, 0x1776, 0x174b, 0x17b7, 0x1752, 0x1752, 0x175b,
 	0x18ac, 0x178a, 0x1780, 0xa964, 0x918c, 0x00ff, 0x918e, 0x0048,
 	0x0904, 0x17b7, 0x9085, 0x0001, 0x0804, 0x18a3, 0xa87c, 0xd0ac,
 	0x0dc8, 0x0804, 0x17c7, 0xa87c, 0xd0ac, 0x0da0, 0x0804, 0x1832,
 	0xa898, 0x901d, 0x1108, 0xab9c, 0x9016, 0xaab2, 0xaa3e, 0xaa42,
-	0x3e00, 0x9080, 0x0008, 0x2004, 0x9080, 0x8f19, 0x2005, 0x9005,
+	0x3e00, 0x9080, 0x0008, 0x2004, 0x9080, 0x8f38, 0x2005, 0x9005,
 	0x090c, 0x0dd5, 0x2004, 0xa8ae, 0x0804, 0x188b, 0xa87c, 0xd0bc,
 	0x09c8, 0xa890, 0xa842, 0xa88c, 0xa83e, 0xa888, 0x0804, 0x17c7,
 	0xa87c, 0xd0bc, 0x0978, 0xa890, 0xa842, 0xa88c, 0xa83e, 0xa888,
 	0x0804, 0x1832, 0xa87c, 0xd0bc, 0x0928, 0xa890, 0xa842, 0xa88c,
 	0xa83e, 0xa804, 0x9045, 0x090c, 0x0dd5, 0xa164, 0xa91a, 0x91ec,
-	0x000f, 0x9d80, 0x2092, 0x2065, 0xa888, 0xd19c, 0x1904, 0x1832,
+	0x000f, 0x9d80, 0x209d, 0x2065, 0xa888, 0xd19c, 0x1904, 0x1832,
 	0x0430, 0xa87c, 0xd0ac, 0x0904, 0x1752, 0xa804, 0x9045, 0x090c,
-	0x0dd5, 0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80, 0x2092, 0x2065,
+	0x0dd5, 0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80, 0x209d, 0x2065,
 	0x9006, 0xa842, 0xa83e, 0xd19c, 0x1904, 0x1832, 0x0080, 0xa87c,
 	0xd0ac, 0x0904, 0x1752, 0x9006, 0xa842, 0xa83e, 0x0804, 0x1832,
 	0xa87c, 0xd0ac, 0x0904, 0x1752, 0x9006, 0xa842, 0xa83e, 0x2c05,
@@ -585,7 +585,7 @@
 	0xc0dd, 0xa87e, 0x9006, 0x00ce, 0x012e, 0x0005, 0x2800, 0xa80e,
 	0xab0a, 0x2c00, 0xa812, 0x0c78, 0x0804, 0x1752, 0x2ff0, 0x0126,
 	0x2091, 0x2200, 0x00c6, 0x3e60, 0x6014, 0x2048, 0x2940, 0xa80e,
-	0x2061, 0x208d, 0xa813, 0x208d, 0x2c05, 0xa80a, 0xa964, 0xa91a,
+	0x2061, 0x2098, 0xa813, 0x2098, 0x2c05, 0xa80a, 0xa964, 0xa91a,
 	0xa87c, 0xd0ac, 0x090c, 0x0dd5, 0x9006, 0xa842, 0xa83e, 0x2c05,
 	0x908a, 0x0034, 0x1a0c, 0x0dd5, 0xadcc, 0xacd0, 0xafd4, 0xaed8,
 	0xabdc, 0xaae0, 0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a,
@@ -594,7 +594,7 @@
 	0x0002, 0xa916, 0x1158, 0x3e60, 0x601c, 0xc085, 0x601e, 0xa87c,
 	0xc0dd, 0xa87e, 0x9006, 0x00ce, 0x012e, 0x0005, 0xa804, 0x9045,
 	0x090c, 0x0dd5, 0xa80e, 0xa064, 0xa81a, 0x9084, 0x000f, 0x9080,
-	0x2092, 0x2015, 0x82ff, 0x090c, 0x0dd5, 0xaa12, 0x2205, 0xa80a,
+	0x209d, 0x2015, 0x82ff, 0x090c, 0x0dd5, 0xaa12, 0x2205, 0xa80a,
 	0x0c10, 0x903e, 0x2730, 0xa880, 0xd0fc, 0x1190, 0x2d00, 0x0002,
 	0x1a33, 0x1960, 0x1960, 0x1a33, 0x1960, 0x1a2d, 0x1a33, 0x1960,
 	0x19d0, 0x19d0, 0x19d0, 0x1a33, 0x19d0, 0x1a33, 0x1a2a, 0x19d0,
@@ -631,5534 +631,5534 @@
 	0x9d86, 0x000c, 0x0510, 0xa3ac, 0xa2b0, 0x00f8, 0xa5b4, 0xa4b8,
 	0xa7bc, 0xa6c0, 0x9d86, 0x000c, 0x01c0, 0xa3c4, 0xa2c8, 0x00a8,
 	0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8, 0x9d86, 0x000c, 0x0170, 0xa3dc,
-	0xa2e0, 0x0058, 0x9d86, 0x000e, 0x1130, 0x080c, 0x204a, 0x1904,
+	0xa2e0, 0x0058, 0x9d86, 0x000e, 0x1130, 0x080c, 0x2055, 0x1904,
 	0x1909, 0x900e, 0x0050, 0x080c, 0x0dd5, 0xab2e, 0xaa32, 0xad1e,
-	0xac22, 0xaf26, 0xae2a, 0x080c, 0x204a, 0x0005, 0x6014, 0x2048,
+	0xac22, 0xaf26, 0xae2a, 0x080c, 0x2055, 0x0005, 0x6014, 0x2048,
 	0x6118, 0x810c, 0x810c, 0x810c, 0x81ff, 0x1118, 0xa887, 0x0001,
-	0x0008, 0xa986, 0x601b, 0x0002, 0xa974, 0xd1dc, 0x1108, 0x0005,
+	0x0008, 0xa986, 0x601b, 0x0002, 0xa874, 0x9084, 0x00ff, 0x9084,
+	0x0008, 0x0150, 0x00e9, 0x6000, 0x9086, 0x0004, 0x1120, 0x2009,
+	0x0048, 0x080c, 0xaeda, 0x0005, 0xa974, 0xd1dc, 0x1108, 0x0005,
 	0xa934, 0xa88c, 0x9106, 0x1158, 0xa938, 0xa890, 0x9106, 0x1138,
-	0x601c, 0xc084, 0x601e, 0x2009, 0x0048, 0x0804, 0xaeec, 0x0005,
+	0x601c, 0xc084, 0x601e, 0x2009, 0x0048, 0x0804, 0xaeda, 0x0005,
 	0x0126, 0x00c6, 0x2091, 0x2200, 0x00ce, 0x7908, 0x918c, 0x0007,
 	0x9186, 0x0000, 0x05b0, 0x9186, 0x0003, 0x0598, 0x6020, 0x6023,
 	0x0000, 0x0006, 0x2031, 0x0008, 0x00c6, 0x781f, 0x0808, 0x7808,
 	0xd09c, 0x0120, 0x080c, 0x1380, 0x8631, 0x1db8, 0x00ce, 0x781f,
 	0x0800, 0x2031, 0x0168, 0x00c6, 0x7808, 0xd09c, 0x190c, 0x1380,
-	0x00ce, 0x2001, 0x0038, 0x080c, 0x1b38, 0x7930, 0x9186, 0x0040,
+	0x00ce, 0x2001, 0x0038, 0x080c, 0x1b43, 0x7930, 0x9186, 0x0040,
 	0x0160, 0x9186, 0x0042, 0x190c, 0x0dd5, 0x2001, 0x001e, 0x8001,
-	0x1df0, 0x8631, 0x1d40, 0x080c, 0x1b47, 0x000e, 0x6022, 0x012e,
-	0x0005, 0x080c, 0x1b34, 0x7827, 0x0015, 0x7828, 0x9c06, 0x1db8,
+	0x1df0, 0x8631, 0x1d40, 0x080c, 0x1b52, 0x000e, 0x6022, 0x012e,
+	0x0005, 0x080c, 0x1b3f, 0x7827, 0x0015, 0x7828, 0x9c06, 0x1db8,
 	0x782b, 0x0000, 0x0ca0, 0x00f6, 0x2079, 0x0300, 0x7803, 0x0000,
-	0x78ab, 0x0004, 0x00fe, 0x080c, 0x73a5, 0x11b0, 0x2001, 0x0138,
+	0x78ab, 0x0004, 0x00fe, 0x080c, 0x73b3, 0x1188, 0x2001, 0x0138,
 	0x2003, 0x0000, 0x2001, 0x0160, 0x2003, 0x0000, 0x2011, 0x012c,
-	0xa001, 0xa001, 0x8211, 0x1de0, 0x0081, 0x0066, 0x2031, 0x0000,
-	0x080c, 0x7455, 0x006e, 0x0005, 0x0479, 0x0039, 0x2001, 0x0160,
-	0x2502, 0x2001, 0x0138, 0x2202, 0x0005, 0x00e6, 0x2071, 0x0200,
-	0x080c, 0x2c46, 0x2009, 0x003c, 0x080c, 0x23d4, 0x2001, 0x015d,
-	0x2003, 0x0000, 0x7000, 0x9084, 0x003c, 0x1de0, 0x080c, 0x83fd,
-	0x70a0, 0x70a2, 0x7098, 0x709a, 0x709c, 0x709e, 0x2001, 0x020d,
-	0x2003, 0x0020, 0x00f6, 0x2079, 0x0300, 0x080c, 0x1313, 0x7803,
-	0x0001, 0x00fe, 0x00ee, 0x0005, 0x2001, 0x0138, 0x2014, 0x2003,
-	0x0000, 0x2001, 0x0160, 0x202c, 0x2003, 0x0000, 0x080c, 0x73a5,
-	0x1108, 0x0005, 0x2021, 0x0260, 0x2001, 0x0141, 0x201c, 0xd3dc,
-	0x1168, 0x2001, 0x0109, 0x201c, 0x939c, 0x0048, 0x1160, 0x2001,
-	0x0111, 0x201c, 0x83ff, 0x1110, 0x8421, 0x1d70, 0x2001, 0x015d,
-	0x2003, 0x0000, 0x0005, 0x0046, 0x2021, 0x0019, 0x2003, 0x0048,
-	0xa001, 0xa001, 0x201c, 0x939c, 0x0048, 0x0120, 0x8421, 0x1db0,
-	0x004e, 0x0c60, 0x004e, 0x0c40, 0x601c, 0xc084, 0x601e, 0x0005,
-	0x2c08, 0x621c, 0x080c, 0x15f0, 0x7930, 0x0005, 0x2c08, 0x621c,
-	0x080c, 0x169b, 0x7930, 0x0005, 0x8001, 0x1df0, 0x0005, 0x2031,
-	0x0005, 0x781c, 0x9084, 0x0007, 0x0170, 0x2001, 0x0038, 0x0c41,
-	0x9186, 0x0040, 0x0904, 0x1ba5, 0x2001, 0x001e, 0x0c69, 0x8631,
-	0x1d80, 0x080c, 0x0dd5, 0x781f, 0x0202, 0x2001, 0x015d, 0x2003,
-	0x0000, 0x2001, 0x0b10, 0x0c01, 0x781c, 0xd084, 0x0110, 0x0861,
-	0x04e0, 0x2001, 0x0030, 0x0891, 0x9186, 0x0040, 0x0568, 0x781c,
-	0xd084, 0x1da8, 0x781f, 0x0101, 0x2001, 0x0014, 0x0869, 0x2001,
-	0x0037, 0x0821, 0x9186, 0x0040, 0x0140, 0x2001, 0x0030, 0x080c,
-	0x1b3e, 0x9186, 0x0040, 0x190c, 0x0dd5, 0x00d6, 0x2069, 0x0200,
-	0x692c, 0xd1f4, 0x1170, 0xd1c4, 0x0160, 0xd19c, 0x0130, 0x6800,
-	0x9085, 0x1800, 0x6802, 0x00de, 0x0080, 0x6908, 0x9184, 0x0007,
-	0x1db0, 0x00de, 0x781f, 0x0100, 0x791c, 0x9184, 0x0007, 0x090c,
-	0x0dd5, 0xa001, 0xa001, 0x781f, 0x0200, 0x0005, 0x0126, 0x2091,
-	0x2400, 0x2071, 0x1a65, 0x2079, 0x0090, 0x012e, 0x0005, 0x9280,
-	0x0005, 0x2004, 0x2048, 0xa97c, 0xd1dc, 0x1904, 0x1c47, 0xa964,
-	0x9184, 0x0007, 0x0002, 0x1bc3, 0x1c32, 0x1bda, 0x1bdc, 0x1bda,
-	0x1c1a, 0x1bfa, 0x1be9, 0x918c, 0x00ff, 0x9186, 0x0008, 0x1170,
-	0xa87c, 0xd0b4, 0x0904, 0x1e71, 0x9006, 0xa842, 0xa83e, 0xa988,
-	0x2900, 0xa85a, 0xa813, 0x208d, 0x0804, 0x1c43, 0x9186, 0x0048,
-	0x0904, 0x1c32, 0x080c, 0x0dd5, 0x9184, 0x00ff, 0x9086, 0x0013,
-	0x0904, 0x1c32, 0x9184, 0x00ff, 0x9086, 0x001b, 0x0904, 0x1c32,
-	0x0c88, 0xa87c, 0xd0b4, 0x0904, 0x1e71, 0xa890, 0xa842, 0xa83a,
-	0xa88c, 0xa83e, 0xa836, 0xa8ac, 0xa846, 0xa8b0, 0xa84a, 0xa988,
-	0x0804, 0x1c3a, 0xa864, 0x9084, 0x00ff, 0x9086, 0x001e, 0x19d0,
-	0xa87c, 0xd0b4, 0x0904, 0x1e71, 0xa890, 0xa842, 0xa83a, 0xa88c,
-	0xa83e, 0xa836, 0xa8ac, 0xa846, 0xa8b0, 0xa84a, 0xa804, 0xa85a,
-	0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x2092, 0x2005, 0xa812,
-	0xa988, 0x0448, 0x918c, 0x00ff, 0x9186, 0x0015, 0x1540, 0xa87c,
-	0xd0b4, 0x0904, 0x1e71, 0xa804, 0xa85a, 0x2040, 0xa064, 0x9084,
-	0x000f, 0x9080, 0x2092, 0x2005, 0xa812, 0xa988, 0x9006, 0xa842,
-	0xa83e, 0x0088, 0xa87c, 0xd0b4, 0x0904, 0x1e71, 0xa988, 0x9006,
-	0xa842, 0xa83e, 0x2900, 0xa85a, 0xa864, 0x9084, 0x000f, 0x9080,
-	0x2092, 0x2005, 0xa812, 0xa916, 0xa87c, 0xc0dd, 0xa87e, 0x0005,
-	0x00f6, 0x2079, 0x0090, 0x782c, 0xd0fc, 0x190c, 0x1eb6, 0x00e6,
-	0x2071, 0x1a65, 0x7000, 0x9005, 0x1904, 0x1cb0, 0x7206, 0x9280,
-	0x0005, 0x204c, 0x9280, 0x0004, 0x2004, 0x782b, 0x0004, 0x00f6,
-	0x2079, 0x0200, 0x7803, 0x0040, 0x00fe, 0x00b6, 0x2058, 0xb86c,
-	0x7836, 0xb890, 0x00be, 0x00f6, 0x2079, 0x0200, 0x7803, 0x0040,
-	0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x781a, 0x2079,
-	0x0100, 0x8004, 0x78d6, 0x00fe, 0xa814, 0x2050, 0xa858, 0x2040,
-	0xa810, 0x2060, 0xa064, 0x90ec, 0x000f, 0xa944, 0x791a, 0x7116,
-	0xa848, 0x781e, 0x701a, 0x9006, 0x700e, 0x7012, 0x7004, 0xa940,
-	0xa838, 0x9106, 0x1500, 0xa93c, 0xa834, 0x9106, 0x11e0, 0x0006,
-	0x0016, 0xa938, 0xa834, 0x9105, 0x0118, 0x001e, 0x000e, 0x0098,
-	0x001e, 0x000e, 0x8aff, 0x01c8, 0x0126, 0x2091, 0x8000, 0x2009,
-	0x0306, 0x200b, 0x0808, 0x00d9, 0x0108, 0x00c9, 0x012e, 0x9006,
-	0x00ee, 0x00fe, 0x0005, 0x0036, 0x0046, 0xab38, 0xac34, 0x080c,
-	0x20b2, 0x004e, 0x003e, 0x0d30, 0x0c98, 0x9085, 0x0001, 0x0c80,
-	0x2009, 0x0306, 0x200b, 0x4800, 0x7027, 0x0000, 0x0005, 0x0076,
-	0x0066, 0x0056, 0x0046, 0x0036, 0x0026, 0x8aff, 0x0904, 0x1e6a,
-	0x700c, 0x7214, 0x923a, 0x7010, 0x7218, 0x9203, 0x0a04, 0x1e69,
-	0x9705, 0x0904, 0x1e69, 0x903e, 0x2730, 0xa880, 0xd0fc, 0x1190,
-	0x2d00, 0x0002, 0x1df3, 0x1d32, 0x1d32, 0x1df3, 0x1df3, 0x1dd0,
-	0x1df3, 0x1d32, 0x1dd7, 0x1d81, 0x1d81, 0x1df3, 0x1df3, 0x1df3,
-	0x1dca, 0x1d81, 0xc0fc, 0xa882, 0xab2c, 0xaa30, 0xad1c, 0xac20,
-	0xdd9c, 0x0904, 0x1e00, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0dd5,
-	0x9082, 0x001b, 0x0002, 0x1d1e, 0x1d1c, 0x1d1c, 0x1d1c, 0x1d1c,
-	0x1d1c, 0x1d22, 0x1d1c, 0x1d1c, 0x1d1c, 0x1d1c, 0x1d1c, 0x1d26,
-	0x1d1c, 0x1d1c, 0x1d1c, 0x1d1c, 0x1d1c, 0x1d2a, 0x1d1c, 0x1d1c,
-	0x1d1c, 0x1d1c, 0x1d1c, 0x1d2e, 0x080c, 0x0dd5, 0xa774, 0xa678,
-	0x0804, 0x1e00, 0xa78c, 0xa690, 0x0804, 0x1e00, 0xa7a4, 0xa6a8,
-	0x0804, 0x1e00, 0xa7bc, 0xa6c0, 0x0804, 0x1e00, 0xa7d4, 0xa6d8,
-	0x0804, 0x1e00, 0x2c05, 0x908a, 0x0036, 0x1a0c, 0x0dd5, 0x9082,
-	0x001b, 0x0002, 0x1d55, 0x1d55, 0x1d57, 0x1d55, 0x1d55, 0x1d55,
-	0x1d5d, 0x1d55, 0x1d55, 0x1d55, 0x1d63, 0x1d55, 0x1d55, 0x1d55,
-	0x1d69, 0x1d55, 0x1d55, 0x1d55, 0x1d6f, 0x1d55, 0x1d55, 0x1d55,
-	0x1d75, 0x1d55, 0x1d55, 0x1d55, 0x1d7b, 0x080c, 0x0dd5, 0xa574,
-	0xa478, 0xa37c, 0xa280, 0x0804, 0x1e00, 0xa584, 0xa488, 0xa38c,
-	0xa290, 0x0804, 0x1e00, 0xa594, 0xa498, 0xa39c, 0xa2a0, 0x0804,
-	0x1e00, 0xa5a4, 0xa4a8, 0xa3ac, 0xa2b0, 0x0804, 0x1e00, 0xa5b4,
-	0xa4b8, 0xa3bc, 0xa2c0, 0x0804, 0x1e00, 0xa5c4, 0xa4c8, 0xa3cc,
-	0xa2d0, 0x0804, 0x1e00, 0xa5d4, 0xa4d8, 0xa3dc, 0xa2e0, 0x0804,
-	0x1e00, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0dd5, 0x9082, 0x001b,
-	0x0002, 0x1da4, 0x1da2, 0x1da2, 0x1da2, 0x1da2, 0x1da2, 0x1dac,
-	0x1da2, 0x1da2, 0x1da2, 0x1da2, 0x1da2, 0x1db4, 0x1da2, 0x1da2,
-	0x1da2, 0x1da2, 0x1da2, 0x1dbc, 0x1da2, 0x1da2, 0x1da2, 0x1da2,
-	0x1da2, 0x1dc3, 0x080c, 0x0dd5, 0xa56c, 0xa470, 0xa774, 0xa678,
-	0xa37c, 0xa280, 0x0804, 0x1e00, 0xa584, 0xa488, 0xa78c, 0xa690,
-	0xa394, 0xa298, 0x0804, 0x1e00, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8,
-	0xa3ac, 0xa2b0, 0x0804, 0x1e00, 0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0,
-	0xa3c4, 0xa2c8, 0x04e8, 0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8, 0xa3dc,
-	0xa2e0, 0x04b0, 0xa864, 0x9084, 0x00ff, 0x9086, 0x001e, 0x1518,
-	0x080c, 0x204a, 0x1904, 0x1ccd, 0x900e, 0x0804, 0x1e6a, 0xab64,
-	0x939c, 0x00ff, 0x9386, 0x0048, 0x1180, 0x00c6, 0x7004, 0x2060,
-	0x6004, 0x9086, 0x0043, 0x00ce, 0x0904, 0x1d81, 0xab9c, 0x9016,
-	0xad8c, 0xac90, 0xaf94, 0xae98, 0x0098, 0x9386, 0x0008, 0x0904,
-	0x1d81, 0x080c, 0x0dd5, 0xa964, 0x918c, 0x00ff, 0x9186, 0x0013,
-	0x0904, 0x1d32, 0x9186, 0x001b, 0x0904, 0x1d81, 0x080c, 0x0dd5,
-	0x2009, 0x030f, 0x2104, 0xd0fc, 0x0530, 0x0066, 0x2009, 0x0306,
-	0x2104, 0x9084, 0x0030, 0x15c8, 0x2031, 0x1000, 0x200b, 0x4000,
-	0x2600, 0x9302, 0x928b, 0x0000, 0xa82e, 0xa932, 0x0278, 0x9105,
-	0x0168, 0x2011, 0x0000, 0x2618, 0x2600, 0x9500, 0xa81e, 0x9481,
-	0x0000, 0xa822, 0xa880, 0xc0fd, 0xa882, 0x0020, 0xa82f, 0x0000,
-	0xa833, 0x0000, 0x006e, 0x7b12, 0x7a16, 0x7d02, 0x7c06, 0x7f0a,
-	0x7e0e, 0x782b, 0x0001, 0x7000, 0x8000, 0x7002, 0xa83c, 0x9300,
-	0xa83e, 0xa840, 0x9201, 0xa842, 0x700c, 0x9300, 0x700e, 0x7010,
-	0x9201, 0x7012, 0x080c, 0x204a, 0x0428, 0x2031, 0x0080, 0x9584,
-	0x007f, 0x0108, 0x9632, 0x7124, 0x7000, 0x9086, 0x0000, 0x1198,
-	0xc185, 0x7126, 0x2009, 0x0306, 0x2104, 0xd0b4, 0x1904, 0x1e10,
-	0x200b, 0x4040, 0x2009, 0x1a7e, 0x2104, 0x8000, 0x0a04, 0x1e10,
-	0x200a, 0x0804, 0x1e10, 0xc18d, 0x7126, 0xd184, 0x1d58, 0x0804,
-	0x1e10, 0x9006, 0x002e, 0x003e, 0x004e, 0x005e, 0x006e, 0x007e,
-	0x0005, 0x080c, 0x0dd5, 0x0026, 0x2001, 0x0105, 0x2003, 0x0010,
-	0x782b, 0x0004, 0x7003, 0x0000, 0x7004, 0x0016, 0x080c, 0x1cc0,
-	0x001e, 0x2060, 0x6014, 0x2048, 0x080c, 0xcb4a, 0x0118, 0xa880,
-	0xc0bd, 0xa882, 0x6020, 0x9086, 0x0006, 0x1180, 0x2061, 0x0100,
-	0x62c8, 0x2001, 0x00fa, 0x8001, 0x1df0, 0x60c8, 0x9206, 0x1dc0,
-	0x60c4, 0xa89a, 0x60c8, 0xa896, 0x7004, 0x2060, 0x00c6, 0x080c,
-	0xc77b, 0x00ce, 0x2001, 0x19f5, 0x2004, 0x9c06, 0x1160, 0x2009,
-	0x0040, 0x080c, 0x23d4, 0x080c, 0xa7cd, 0x2011, 0x0000, 0x080c,
-	0xa65e, 0x080c, 0x97b5, 0x002e, 0x0804, 0x1ffa, 0x0126, 0x2091,
-	0x2400, 0xa858, 0x2040, 0x792c, 0x782b, 0x0002, 0x9184, 0x0700,
-	0x1904, 0x1e73, 0x7000, 0x0002, 0x1ffa, 0x1ec8, 0x1f48, 0x1ff8,
-	0x8001, 0x7002, 0x7027, 0x0000, 0xd19c, 0x1158, 0x8aff, 0x0904,
-	0x1f15, 0x080c, 0x1cc7, 0x0904, 0x1ffa, 0x080c, 0x1cc7, 0x0804,
-	0x1ffa, 0x782b, 0x0004, 0xd194, 0x0148, 0xa880, 0xc0fc, 0xa882,
-	0x8aff, 0x1518, 0xa87c, 0xc0f5, 0xa87e, 0x00f8, 0x0026, 0x0036,
-	0xab3c, 0xaa40, 0x0016, 0x7910, 0xa82c, 0x9100, 0xa82e, 0x7914,
-	0xa830, 0x9101, 0xa832, 0x001e, 0x7810, 0x931a, 0x7814, 0x9213,
-	0x7800, 0xa81e, 0x7804, 0xa822, 0xab3e, 0xaa42, 0x003e, 0x002e,
-	0x080c, 0x2065, 0xa880, 0xc0fd, 0xa882, 0x2a00, 0xa816, 0x2800,
-	0xa85a, 0x2c00, 0xa812, 0x7003, 0x0000, 0x2009, 0x0306, 0x200b,
-	0x4800, 0x7027, 0x0000, 0x0804, 0x1ffa, 0x00f6, 0x0026, 0x781c,
-	0x0006, 0x7818, 0x0006, 0x2079, 0x0100, 0x7a14, 0x9284, 0x1984,
-	0x9085, 0x0012, 0x7816, 0x0036, 0x2019, 0x1000, 0x8319, 0x090c,
-	0x0dd5, 0x7820, 0xd0bc, 0x1dd0, 0x003e, 0x79c8, 0x000e, 0x9102,
-	0x001e, 0x0006, 0x0016, 0x79c4, 0x000e, 0x9103, 0x78c6, 0x000e,
-	0x78ca, 0x9284, 0x1984, 0x9085, 0x0012, 0x7816, 0x002e, 0x00fe,
-	0x782b, 0x0008, 0x7003, 0x0000, 0x080c, 0x1cc0, 0x0804, 0x1ffa,
-	0x8001, 0x7002, 0x7024, 0x8004, 0x7026, 0xd194, 0x0170, 0x782c,
-	0xd0fc, 0x1904, 0x1ebb, 0xd19c, 0x1904, 0x1ff6, 0x8aff, 0x0904,
-	0x1ffa, 0x080c, 0x1cc7, 0x0804, 0x1ffa, 0x0026, 0x0036, 0xab3c,
-	0xaa40, 0x080c, 0x2065, 0xdd9c, 0x1904, 0x1fb5, 0x2c05, 0x908a,
-	0x0036, 0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002, 0x1f89, 0x1f89,
-	0x1f8b, 0x1f89, 0x1f89, 0x1f89, 0x1f91, 0x1f89, 0x1f89, 0x1f89,
-	0x1f97, 0x1f89, 0x1f89, 0x1f89, 0x1f9d, 0x1f89, 0x1f89, 0x1f89,
-	0x1fa3, 0x1f89, 0x1f89, 0x1f89, 0x1fa9, 0x1f89, 0x1f89, 0x1f89,
-	0x1faf, 0x080c, 0x0dd5, 0xa07c, 0x931a, 0xa080, 0x9213, 0x0804,
-	0x1eea, 0xa08c, 0x931a, 0xa090, 0x9213, 0x0804, 0x1eea, 0xa09c,
-	0x931a, 0xa0a0, 0x9213, 0x0804, 0x1eea, 0xa0ac, 0x931a, 0xa0b0,
-	0x9213, 0x0804, 0x1eea, 0xa0bc, 0x931a, 0xa0c0, 0x9213, 0x0804,
-	0x1eea, 0xa0cc, 0x931a, 0xa0d0, 0x9213, 0x0804, 0x1eea, 0xa0dc,
-	0x931a, 0xa0e0, 0x9213, 0x0804, 0x1eea, 0x2c05, 0x908a, 0x0034,
-	0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002, 0x1fd8, 0x1fd6, 0x1fd6,
-	0x1fd6, 0x1fd6, 0x1fd6, 0x1fde, 0x1fd6, 0x1fd6, 0x1fd6, 0x1fd6,
-	0x1fd6, 0x1fe4, 0x1fd6, 0x1fd6, 0x1fd6, 0x1fd6, 0x1fd6, 0x1fea,
-	0x1fd6, 0x1fd6, 0x1fd6, 0x1fd6, 0x1fd6, 0x1ff0, 0x080c, 0x0dd5,
-	0xa07c, 0x931a, 0xa080, 0x9213, 0x0804, 0x1eea, 0xa094, 0x931a,
-	0xa098, 0x9213, 0x0804, 0x1eea, 0xa0ac, 0x931a, 0xa0b0, 0x9213,
-	0x0804, 0x1eea, 0xa0c4, 0x931a, 0xa0c8, 0x9213, 0x0804, 0x1eea,
-	0xa0dc, 0x931a, 0xa0e0, 0x9213, 0x0804, 0x1eea, 0x0804, 0x1ee6,
-	0x080c, 0x0dd5, 0x012e, 0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a65,
-	0x7000, 0x9086, 0x0000, 0x0904, 0x2045, 0x2079, 0x0090, 0x2009,
-	0x0207, 0x210c, 0xd194, 0x01b8, 0x2009, 0x020c, 0x210c, 0x9184,
-	0x0003, 0x0188, 0x080c, 0xea2b, 0x2001, 0x0133, 0x2004, 0x9005,
-	0x090c, 0x0dd5, 0x0016, 0x2009, 0x0040, 0x080c, 0x23d4, 0x001e,
-	0x2001, 0x020c, 0x2102, 0x2009, 0x0206, 0x2104, 0x2009, 0x0203,
-	0x210c, 0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x23d4, 0x782c,
-	0xd0fc, 0x09a8, 0x080c, 0x1eb6, 0x7000, 0x9086, 0x0000, 0x1978,
-	0x782b, 0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c,
-	0x23d4, 0x782b, 0x0002, 0x7003, 0x0000, 0x080c, 0x1cc0, 0x00ee,
-	0x00fe, 0x0005, 0xa880, 0xd0fc, 0x11a8, 0x8c60, 0x2c05, 0x9005,
-	0x0110, 0x8a51, 0x0005, 0xa004, 0x9005, 0x0168, 0xa85a, 0x2040,
-	0xa064, 0x9084, 0x000f, 0x9080, 0x2092, 0x2065, 0x8cff, 0x090c,
-	0x0dd5, 0x8a51, 0x0005, 0x2050, 0x0005, 0xa880, 0xd0fc, 0x11b8,
-	0x8a50, 0x8c61, 0x2c05, 0x9005, 0x1190, 0x2800, 0x9906, 0x0120,
-	0xa000, 0x9005, 0x1108, 0x2900, 0x2040, 0xa85a, 0xa064, 0x9084,
-	0x000f, 0x9080, 0x20a2, 0x2065, 0x8cff, 0x090c, 0x0dd5, 0x0005,
-	0x0000, 0x001d, 0x0021, 0x0025, 0x0029, 0x002d, 0x0031, 0x0035,
-	0x0000, 0x001b, 0x0021, 0x0027, 0x002d, 0x0033, 0x0000, 0x0000,
-	0x0023, 0x0000, 0x0000, 0x2085, 0x2081, 0x2085, 0x2085, 0x208f,
-	0x0000, 0x2085, 0x208c, 0x208c, 0x2089, 0x208c, 0x208c, 0x0000,
-	0x208f, 0x208c, 0x0000, 0x2087, 0x2087, 0x0000, 0x2087, 0x208f,
-	0x0000, 0x2087, 0x208d, 0x208d, 0x208d, 0x0000, 0x208d, 0x0000,
-	0x208f, 0x208d, 0x00c6, 0x00d6, 0x0086, 0xab42, 0xac3e, 0xa888,
-	0x9055, 0x0904, 0x2291, 0x2940, 0xa064, 0x90ec, 0x000f, 0x9084,
-	0x00ff, 0x9086, 0x0008, 0x1118, 0x2061, 0x208d, 0x00d0, 0x9de0,
-	0x2092, 0x9d86, 0x0007, 0x0130, 0x9d86, 0x000e, 0x0118, 0x9d86,
-	0x000f, 0x1120, 0xa08c, 0x9422, 0xa090, 0x931b, 0x2c05, 0x9065,
-	0x1140, 0x0310, 0x0804, 0x2291, 0xa004, 0x9045, 0x0904, 0x2291,
-	0x08d8, 0x2c05, 0x9005, 0x0904, 0x2179, 0xdd9c, 0x1904, 0x2135,
-	0x908a, 0x0036, 0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002, 0x210a,
-	0x210a, 0x210c, 0x210a, 0x210a, 0x210a, 0x2112, 0x210a, 0x210a,
-	0x210a, 0x2118, 0x210a, 0x210a, 0x210a, 0x211e, 0x210a, 0x210a,
-	0x210a, 0x2124, 0x210a, 0x210a, 0x210a, 0x212a, 0x210a, 0x210a,
-	0x210a, 0x2130, 0x080c, 0x0dd5, 0xa07c, 0x9422, 0xa080, 0x931b,
-	0x0804, 0x216f, 0xa08c, 0x9422, 0xa090, 0x931b, 0x0804, 0x216f,
-	0xa09c, 0x9422, 0xa0a0, 0x931b, 0x0804, 0x216f, 0xa0ac, 0x9422,
-	0xa0b0, 0x931b, 0x0804, 0x216f, 0xa0bc, 0x9422, 0xa0c0, 0x931b,
-	0x0804, 0x216f, 0xa0cc, 0x9422, 0xa0d0, 0x931b, 0x0804, 0x216f,
-	0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x04d0, 0x908a, 0x0034, 0x1a0c,
-	0x0dd5, 0x9082, 0x001b, 0x0002, 0x2157, 0x2155, 0x2155, 0x2155,
-	0x2155, 0x2155, 0x215c, 0x2155, 0x2155, 0x2155, 0x2155, 0x2155,
-	0x2161, 0x2155, 0x2155, 0x2155, 0x2155, 0x2155, 0x2166, 0x2155,
-	0x2155, 0x2155, 0x2155, 0x2155, 0x216b, 0x080c, 0x0dd5, 0xa07c,
-	0x9422, 0xa080, 0x931b, 0x0098, 0xa094, 0x9422, 0xa098, 0x931b,
-	0x0070, 0xa0ac, 0x9422, 0xa0b0, 0x931b, 0x0048, 0xa0c4, 0x9422,
-	0xa0c8, 0x931b, 0x0020, 0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x0630,
-	0x2300, 0x9405, 0x0160, 0x8a51, 0x0904, 0x2291, 0x8c60, 0x0804,
-	0x20e1, 0xa004, 0x9045, 0x0904, 0x2291, 0x0804, 0x20bc, 0x8a51,
-	0x0904, 0x2291, 0x8c60, 0x2c05, 0x9005, 0x1158, 0xa004, 0x9045,
-	0x0904, 0x2291, 0xa064, 0x90ec, 0x000f, 0x9de0, 0x2092, 0x2c05,
-	0x2060, 0xa880, 0xc0fc, 0xa882, 0x0804, 0x2286, 0x2c05, 0x8422,
-	0x8420, 0x831a, 0x9399, 0x0000, 0xac2e, 0xab32, 0xdd9c, 0x1904,
-	0x2223, 0x9082, 0x001b, 0x0002, 0x21bf, 0x21bf, 0x21c1, 0x21bf,
-	0x21bf, 0x21bf, 0x21cf, 0x21bf, 0x21bf, 0x21bf, 0x21dd, 0x21bf,
-	0x21bf, 0x21bf, 0x21eb, 0x21bf, 0x21bf, 0x21bf, 0x21f9, 0x21bf,
-	0x21bf, 0x21bf, 0x2207, 0x21bf, 0x21bf, 0x21bf, 0x2215, 0x080c,
-	0x0dd5, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300, 0x911b, 0x0a0c,
-	0x0dd5, 0xa074, 0x9420, 0xa078, 0x9319, 0x0804, 0x2281, 0xa18c,
-	0x2400, 0x9122, 0xa190, 0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa084,
-	0x9420, 0xa088, 0x9319, 0x0804, 0x2281, 0xa19c, 0x2400, 0x9122,
-	0xa1a0, 0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa094, 0x9420, 0xa098,
-	0x9319, 0x0804, 0x2281, 0xa1ac, 0x2400, 0x9122, 0xa1b0, 0x2300,
-	0x911b, 0x0a0c, 0x0dd5, 0xa0a4, 0x9420, 0xa0a8, 0x9319, 0x0804,
-	0x2281, 0xa1bc, 0x2400, 0x9122, 0xa1c0, 0x2300, 0x911b, 0x0a0c,
-	0x0dd5, 0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0804, 0x2281, 0xa1cc,
-	0x2400, 0x9122, 0xa1d0, 0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa0c4,
-	0x9420, 0xa0c8, 0x9319, 0x0804, 0x2281, 0xa1dc, 0x2400, 0x9122,
-	0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa0d4, 0x9420, 0xa0d8,
-	0x9319, 0x0804, 0x2281, 0x9082, 0x001b, 0x0002, 0x2241, 0x223f,
-	0x223f, 0x223f, 0x223f, 0x223f, 0x224e, 0x223f, 0x223f, 0x223f,
-	0x223f, 0x223f, 0x225b, 0x223f, 0x223f, 0x223f, 0x223f, 0x223f,
-	0x2268, 0x223f, 0x223f, 0x223f, 0x223f, 0x223f, 0x2275, 0x080c,
-	0x0dd5, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300, 0x911b, 0x0a0c,
-	0x0dd5, 0xa06c, 0x9420, 0xa070, 0x9319, 0x0498, 0xa194, 0x2400,
-	0x9122, 0xa198, 0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa084, 0x9420,
-	0xa088, 0x9319, 0x0430, 0xa1ac, 0x2400, 0x9122, 0xa1b0, 0x2300,
-	0x911b, 0x0a0c, 0x0dd5, 0xa09c, 0x9420, 0xa0a0, 0x9319, 0x00c8,
-	0xa1c4, 0x2400, 0x9122, 0xa1c8, 0x2300, 0x911b, 0x0a0c, 0x0dd5,
-	0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0060, 0xa1dc, 0x2400, 0x9122,
-	0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa0cc, 0x9420, 0xa0d0,
-	0x9319, 0xac1e, 0xab22, 0xa880, 0xc0fd, 0xa882, 0x2800, 0xa85a,
-	0x2c00, 0xa812, 0x2a00, 0xa816, 0x000e, 0x000e, 0x000e, 0x9006,
-	0x0028, 0x008e, 0x00de, 0x00ce, 0x9085, 0x0001, 0x0005, 0x2001,
-	0x0005, 0x2004, 0xd0bc, 0x190c, 0x0dce, 0x9084, 0x0007, 0x0002,
-	0x22b2, 0x1eb6, 0x22b2, 0x22a8, 0x22ab, 0x22ae, 0x22ab, 0x22ae,
-	0x080c, 0x1eb6, 0x0005, 0x080c, 0x11a3, 0x0005, 0x080c, 0x1eb6,
-	0x080c, 0x11a3, 0x0005, 0x0126, 0x2091, 0x2600, 0x2079, 0x0200,
-	0x2071, 0x0260, 0x2069, 0x1800, 0x7817, 0x0000, 0x789b, 0x0814,
-	0x78a3, 0x0406, 0x789f, 0x0410, 0x2009, 0x013b, 0x200b, 0x0400,
-	0x781b, 0x0002, 0x783b, 0x001f, 0x7837, 0x0020, 0x7803, 0x1600,
-	0x012e, 0x0005, 0x2091, 0x2600, 0x781c, 0xd0a4, 0x190c, 0x23d1,
-	0x7900, 0xd1dc, 0x1118, 0x9084, 0x0006, 0x001a, 0x9084, 0x000e,
-	0x0002, 0x22f9, 0x22f1, 0x7d86, 0x22f1, 0x22f3, 0x22f3, 0x22f3,
-	0x22f3, 0x7d6c, 0x22f1, 0x22f5, 0x22f1, 0x22f3, 0x22f1, 0x22f3,
-	0x22f1, 0x080c, 0x0dd5, 0x0031, 0x0020, 0x080c, 0x7d6c, 0x080c,
-	0x7d86, 0x0005, 0x0006, 0x0016, 0x0026, 0x080c, 0xea2b, 0x7930,
-	0x9184, 0x0003, 0x01c0, 0x2001, 0x19f5, 0x2004, 0x9005, 0x0170,
-	0x2001, 0x0133, 0x2004, 0x9005, 0x090c, 0x0dd5, 0x00c6, 0x2001,
-	0x19f5, 0x2064, 0x080c, 0xc77b, 0x00ce, 0x00f8, 0x2009, 0x0040,
-	0x080c, 0x23d4, 0x00d0, 0x9184, 0x0014, 0x01a0, 0x6a00, 0x9286,
-	0x0003, 0x0160, 0x080c, 0x73a5, 0x1138, 0x080c, 0x768d, 0x080c,
-	0x6023, 0x080c, 0x72d7, 0x0010, 0x080c, 0x5ee2, 0x080c, 0x7e35,
-	0x0041, 0x0018, 0x9184, 0x9540, 0x1dc8, 0x002e, 0x001e, 0x000e,
-	0x0005, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a61, 0x080c,
-	0x1aab, 0x005e, 0x004e, 0x003e, 0x00ee, 0x0005, 0x0126, 0x2091,
-	0x2e00, 0x2071, 0x1800, 0x7128, 0x2001, 0x196e, 0x2102, 0x2001,
-	0x1976, 0x2102, 0x2001, 0x013b, 0x2102, 0x2079, 0x0200, 0x2001,
-	0x0201, 0x789e, 0x78a3, 0x0200, 0x9198, 0x0007, 0x831c, 0x831c,
-	0x831c, 0x9398, 0x0005, 0x2320, 0x9182, 0x0204, 0x1230, 0x2011,
-	0x0008, 0x8423, 0x8423, 0x8423, 0x0488, 0x9182, 0x024c, 0x1240,
-	0x2011, 0x0007, 0x8403, 0x8003, 0x9400, 0x9400, 0x9420, 0x0430,
-	0x9182, 0x02bc, 0x1238, 0x2011, 0x0006, 0x8403, 0x8003, 0x9400,
-	0x9420, 0x00e0, 0x9182, 0x034c, 0x1230, 0x2011, 0x0005, 0x8403,
-	0x8003, 0x9420, 0x0098, 0x9182, 0x042c, 0x1228, 0x2011, 0x0004,
-	0x8423, 0x8423, 0x0058, 0x9182, 0x059c, 0x1228, 0x2011, 0x0003,
-	0x8403, 0x9420, 0x0018, 0x2011, 0x0002, 0x8423, 0x9482, 0x0228,
-	0x8002, 0x8020, 0x8301, 0x9402, 0x0110, 0x0208, 0x8321, 0x8217,
-	0x8203, 0x9405, 0x789a, 0x012e, 0x0005, 0x0006, 0x00d6, 0x2069,
-	0x0200, 0x6814, 0x9084, 0xffc0, 0x910d, 0x6916, 0x00de, 0x000e,
-	0x0005, 0x00d6, 0x2069, 0x0200, 0x9005, 0x6810, 0x0110, 0xc0a5,
-	0x0008, 0xc0a4, 0x6812, 0x00de, 0x0005, 0x0006, 0x00d6, 0x2069,
-	0x0200, 0x6810, 0x9084, 0xfff8, 0x910d, 0x6912, 0x00de, 0x000e,
-	0x0005, 0x7938, 0x080c, 0x0dce, 0x00f6, 0x2079, 0x0200, 0x7902,
-	0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x7902, 0xa001,
-	0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x00fe, 0x0005, 0x0126,
-	0x2091, 0x2800, 0x2061, 0x0100, 0x2071, 0x1800, 0x2009, 0x0000,
-	0x080c, 0x2c40, 0x080c, 0x2b5b, 0x6054, 0x8004, 0x8004, 0x8004,
-	0x8004, 0x9084, 0x000c, 0x6150, 0x918c, 0xfff3, 0x9105, 0x6052,
-	0x6050, 0x9084, 0xb17f, 0x9085, 0x2000, 0x6052, 0x2009, 0x199c,
-	0x2011, 0x199d, 0x6358, 0x939c, 0x38f0, 0x2320, 0x080c, 0x2b9f,
-	0x1238, 0x939d, 0x4003, 0x94a5, 0x8603, 0x230a, 0x2412, 0x0030,
-	0x939d, 0x0203, 0x94a5, 0x8603, 0x230a, 0x2412, 0x9006, 0x080c,
-	0x2b8a, 0x9006, 0x080c, 0x2b6d, 0x20a9, 0x0012, 0x1d04, 0x2426,
-	0x2091, 0x6000, 0x1f04, 0x2426, 0x602f, 0x0100, 0x602f, 0x0000,
-	0x6050, 0x9085, 0x0400, 0x9084, 0xdfff, 0x6052, 0x6024, 0x6026,
-	0x080c, 0x2879, 0x2009, 0x00ef, 0x6132, 0x6136, 0x080c, 0x2889,
-	0x60e7, 0x0000, 0x61ea, 0x60e3, 0x0008, 0x604b, 0xf7f7, 0x6043,
-	0x0000, 0x602f, 0x0080, 0x602f, 0x0000, 0x6007, 0x349f, 0x60bb,
-	0x0000, 0x20a9, 0x0018, 0x60bf, 0x0000, 0x1f04, 0x2453, 0x60bb,
-	0x0000, 0x60bf, 0x0108, 0x60bf, 0x0012, 0x60bf, 0x0405, 0x60bf,
-	0x0014, 0x60bf, 0x0320, 0x60bf, 0x0018, 0x601b, 0x00f0, 0x601f,
-	0x001e, 0x600f, 0x006b, 0x602b, 0x402f, 0x012e, 0x0005, 0x00f6,
-	0x2079, 0x0140, 0x78c3, 0x0080, 0x78c3, 0x0083, 0x78c3, 0x0000,
-	0x00fe, 0x0005, 0x2001, 0x1835, 0x2003, 0x0000, 0x2001, 0x1834,
-	0x2003, 0x0001, 0x0005, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016,
-	0x0026, 0x6124, 0x0066, 0x2031, 0x1837, 0x2634, 0x96b4, 0x0028,
-	0x006e, 0x1138, 0x6020, 0xd1bc, 0x0120, 0xd0bc, 0x1168, 0xd0b4,
-	0x1198, 0x9184, 0x5e2c, 0x1118, 0x9184, 0x0007, 0x00aa, 0x9195,
-	0x0004, 0x9284, 0x0007, 0x0082, 0x0016, 0x2001, 0x188b, 0x200c,
-	0xd184, 0x001e, 0x0d70, 0x0c98, 0x0016, 0x2001, 0x188b, 0x200c,
-	0xd194, 0x001e, 0x0d30, 0x0c58, 0x24d6, 0x24bc, 0x24bf, 0x24c2,
-	0x24c7, 0x24c9, 0x24cd, 0x24d1, 0x080c, 0x8fbe, 0x00b8, 0x080c,
-	0x908b, 0x00a0, 0x080c, 0x908b, 0x080c, 0x8fbe, 0x0078, 0x0099,
-	0x0068, 0x080c, 0x8fbe, 0x0079, 0x0048, 0x080c, 0x908b, 0x0059,
-	0x0028, 0x080c, 0x908b, 0x080c, 0x8fbe, 0x0029, 0x002e, 0x001e,
-	0x000e, 0x012e, 0x0005, 0x00a6, 0x6124, 0x6028, 0xd09c, 0x0118,
-	0xd19c, 0x1904, 0x273e, 0xd1f4, 0x190c, 0x0dce, 0x080c, 0x73a5,
-	0x0904, 0x2531, 0x080c, 0xd24a, 0x1120, 0x7000, 0x9086, 0x0003,
-	0x0570, 0x6024, 0x9084, 0x1800, 0x0550, 0x080c, 0x73c8, 0x0118,
-	0x080c, 0x73b6, 0x1520, 0x6027, 0x0020, 0x6043, 0x0000, 0x080c,
-	0xd24a, 0x0168, 0x080c, 0x73c8, 0x1150, 0x2001, 0x19a6, 0x2003,
-	0x0001, 0x6027, 0x1800, 0x080c, 0x723b, 0x0804, 0x2741, 0x70a4,
-	0x9005, 0x1150, 0x70a7, 0x0001, 0x00d6, 0x2069, 0x0140, 0x080c,
-	0x73fc, 0x00de, 0x1904, 0x2741, 0x080c, 0x7697, 0x0428, 0x080c,
-	0x73c8, 0x1590, 0x6024, 0x9084, 0x1800, 0x1108, 0x0468, 0x080c,
-	0x7697, 0x080c, 0x768d, 0x080c, 0x6023, 0x080c, 0x72d7, 0x0804,
-	0x273e, 0xd1ac, 0x1508, 0x6024, 0xd0dc, 0x1170, 0xd0e4, 0x1178,
-	0xd0d4, 0x1190, 0xd0cc, 0x0130, 0x7098, 0x9086, 0x0028, 0x1110,
-	0x080c, 0x757a, 0x0804, 0x273e, 0x080c, 0x7692, 0x0048, 0x2001,
-	0x197c, 0x2003, 0x0002, 0x0020, 0x080c, 0x74df, 0x0804, 0x273e,
-	0x080c, 0x7615, 0x0804, 0x273e, 0x6220, 0xd1bc, 0x0138, 0xd2bc,
-	0x1904, 0x27b1, 0xd2b4, 0x1904, 0x27c4, 0x0000, 0xd1ac, 0x0904,
-	0x2653, 0x0036, 0x6328, 0xc3bc, 0x632a, 0x003e, 0x080c, 0x73a5,
-	0x11c0, 0x6027, 0x0020, 0x0006, 0x0026, 0x0036, 0x080c, 0x73bf,
-	0x1158, 0x080c, 0x768d, 0x080c, 0x6023, 0x080c, 0x72d7, 0x003e,
-	0x002e, 0x000e, 0x00ae, 0x0005, 0x003e, 0x002e, 0x000e, 0x080c,
-	0x737d, 0x0016, 0x0046, 0x00c6, 0x644c, 0x9486, 0xf0f0, 0x1138,
-	0x2061, 0x0100, 0x644a, 0x6043, 0x0090, 0x6043, 0x0010, 0x74da,
-	0x948c, 0xff00, 0x7038, 0xd084, 0x0178, 0x9186, 0xf800, 0x1160,
-	0x7048, 0xd084, 0x1148, 0xc085, 0x704a, 0x0036, 0x2418, 0x2011,
-	0x8016, 0x080c, 0x4b14, 0x003e, 0x080c, 0xd243, 0x1904, 0x2630,
-	0x9196, 0xff00, 0x05a8, 0x7060, 0x9084, 0x00ff, 0x810f, 0x81ff,
-	0x0110, 0x9116, 0x0568, 0x7130, 0xd184, 0x1550, 0x080c, 0x331b,
-	0x0128, 0xc18d, 0x7132, 0x080c, 0x6973, 0x1510, 0x6240, 0x9294,
-	0x0010, 0x0130, 0x6248, 0x9294, 0xff00, 0x9296, 0xff00, 0x01c0,
-	0x7030, 0xd08c, 0x0904, 0x2630, 0x7038, 0xd08c, 0x1140, 0x2001,
-	0x180c, 0x200c, 0xd1ac, 0x1904, 0x2630, 0xc1ad, 0x2102, 0x0036,
-	0x73d8, 0x2011, 0x8013, 0x080c, 0x4b14, 0x003e, 0x0804, 0x2630,
-	0x7038, 0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904,
-	0x2630, 0xc1ad, 0x2102, 0x0036, 0x73d8, 0x2011, 0x8013, 0x080c,
-	0x4b14, 0x003e, 0x7130, 0xc185, 0x7132, 0x2011, 0x1848, 0x220c,
-	0xd1a4, 0x01f0, 0x0016, 0x2009, 0x0001, 0x2011, 0x0100, 0x080c,
-	0x86c6, 0x2019, 0x000e, 0x00c6, 0x2061, 0x0000, 0x080c, 0xe543,
-	0x00ce, 0x9484, 0x00ff, 0x9080, 0x3327, 0x200d, 0x918c, 0xff00,
-	0x810f, 0x2120, 0x9006, 0x2009, 0x000e, 0x080c, 0xe5cf, 0x001e,
-	0x0016, 0x2009, 0x0002, 0x2019, 0x0004, 0x080c, 0x318c, 0x001e,
-	0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x6608,
-	0x1110, 0x080c, 0x603d, 0x8108, 0x1f04, 0x2626, 0x00be, 0x015e,
-	0x00ce, 0x004e, 0x080c, 0xade2, 0x60e3, 0x0000, 0x001e, 0x2001,
-	0x1800, 0x2014, 0x9296, 0x0004, 0x1170, 0xd19c, 0x11a0, 0x2011,
-	0x180c, 0x2214, 0xd29c, 0x1120, 0x6204, 0x9295, 0x0002, 0x6206,
-	0x6228, 0xc29d, 0x622a, 0x2003, 0x0001, 0x2001, 0x1826, 0x2003,
-	0x0000, 0x6027, 0x0020, 0xd194, 0x0904, 0x273e, 0x0016, 0x6220,
-	0xd2b4, 0x0904, 0x26db, 0x080c, 0x8562, 0x080c, 0xa274, 0x6027,
-	0x0004, 0x00f6, 0x2019, 0x19ef, 0x2304, 0x907d, 0x0904, 0x26aa,
-	0x7804, 0x9086, 0x0032, 0x15f0, 0x00d6, 0x00c6, 0x00e6, 0x0096,
-	0x2069, 0x0140, 0x782c, 0x685e, 0x7808, 0x685a, 0x6043, 0x0002,
-	0x2001, 0x0003, 0x8001, 0x1df0, 0x6043, 0x0000, 0x2001, 0x003c,
-	0x8001, 0x1df0, 0x080c, 0x2d01, 0x2001, 0x001e, 0x8001, 0x0240,
-	0x20a9, 0x0009, 0x080c, 0x2c1b, 0x6904, 0xd1dc, 0x1140, 0x0cb0,
-	0x2001, 0x0100, 0x080c, 0x2cf1, 0x9006, 0x080c, 0x2cf1, 0x080c,
-	0x957b, 0x080c, 0x9687, 0x7814, 0x2048, 0xa867, 0x0103, 0x2f60,
-	0x080c, 0xae71, 0x009e, 0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e,
-	0x00ae, 0x0005, 0x00fe, 0x00d6, 0x2069, 0x0140, 0x6804, 0x9084,
-	0x4000, 0x0110, 0x080c, 0x2d01, 0x00de, 0x00c6, 0x2061, 0x19e6,
-	0x6028, 0x080c, 0xd24a, 0x0120, 0x909a, 0x0003, 0x1258, 0x0018,
-	0x909a, 0x00c8, 0x1238, 0x8000, 0x602a, 0x00ce, 0x080c, 0xa250,
-	0x0804, 0x273d, 0x2061, 0x0100, 0x62c0, 0x080c, 0xac68, 0x2019,
-	0x19ef, 0x2304, 0x9065, 0x0120, 0x2009, 0x0027, 0x080c, 0xaeec,
-	0x00ce, 0x0804, 0x273d, 0xd2bc, 0x0904, 0x2724, 0x080c, 0x856f,
-	0x6014, 0x9084, 0x1984, 0x9085, 0x0010, 0x6016, 0x6027, 0x0004,
-	0x00d6, 0x2069, 0x0140, 0x6804, 0x9084, 0x4000, 0x0110, 0x080c,
-	0x2d01, 0x00de, 0x00c6, 0x2061, 0x19e6, 0x6044, 0x080c, 0xd24a,
-	0x0120, 0x909a, 0x0003, 0x1658, 0x0018, 0x909a, 0x00c8, 0x1638,
-	0x8000, 0x6046, 0x603c, 0x00ce, 0x9005, 0x05b8, 0x2009, 0x07d0,
-	0x080c, 0x8567, 0x9080, 0x0008, 0x2004, 0x9086, 0x0006, 0x1138,
-	0x6114, 0x918c, 0x1984, 0x918d, 0x0012, 0x6116, 0x0430, 0x9080,
-	0x0008, 0x2004, 0x9086, 0x0009, 0x0d98, 0x6114, 0x918c, 0x1984,
-	0x918d, 0x0016, 0x6116, 0x00c8, 0x6027, 0x0004, 0x00b0, 0x0036,
-	0x2019, 0x0001, 0x080c, 0xa5b7, 0x003e, 0x2019, 0x19f5, 0x2304,
-	0x9065, 0x0150, 0x2009, 0x004f, 0x6020, 0x9086, 0x0009, 0x1110,
-	0x2009, 0x004f, 0x080c, 0xaeec, 0x00ce, 0x001e, 0xd19c, 0x0904,
-	0x27ac, 0x7038, 0xd0ac, 0x1904, 0x2785, 0x0016, 0x0156, 0x6027,
-	0x0008, 0x6050, 0x9085, 0x0040, 0x6052, 0x6050, 0x9084, 0xfbcf,
-	0x6052, 0x080c, 0x2c3a, 0x9085, 0x2000, 0x6052, 0x20a9, 0x0012,
-	0x1d04, 0x2758, 0x080c, 0x8596, 0x1f04, 0x2758, 0x6050, 0x9085,
-	0x0400, 0x9084, 0xdfbf, 0x6052, 0x20a9, 0x0028, 0xa001, 0x1f04,
-	0x2766, 0x6150, 0x9185, 0x1400, 0x6052, 0x20a9, 0x0366, 0x1d04,
-	0x276f, 0x080c, 0x8596, 0x6020, 0xd09c, 0x1130, 0x015e, 0x6152,
-	0x001e, 0x6027, 0x0008, 0x0480, 0x080c, 0x2c02, 0x1f04, 0x276f,
-	0x015e, 0x6152, 0x001e, 0x6027, 0x0008, 0x0016, 0x6028, 0xc09c,
-	0x602a, 0x080c, 0xade2, 0x60e3, 0x0000, 0x080c, 0xea0a, 0x080c,
-	0xea25, 0x080c, 0x56dc, 0xd0fc, 0x1138, 0x080c, 0xd243, 0x1120,
-	0x9085, 0x0001, 0x080c, 0x73ec, 0x9006, 0x080c, 0x2cf1, 0x2009,
-	0x0002, 0x080c, 0x2c40, 0x2001, 0x1800, 0x2003, 0x0004, 0x6027,
-	0x0008, 0x080c, 0x0bae, 0x001e, 0x918c, 0xffd0, 0x6126, 0x00ae,
-	0x0005, 0x0016, 0x2001, 0x188b, 0x200c, 0xd184, 0x001e, 0x0904,
-	0x255e, 0x0016, 0x2009, 0x27bd, 0x00d0, 0x2001, 0x188b, 0x200c,
-	0xc184, 0x2102, 0x001e, 0x0c40, 0x0016, 0x2001, 0x188b, 0x200c,
-	0xd194, 0x001e, 0x0904, 0x255e, 0x0016, 0x2009, 0x27d0, 0x0038,
-	0x2001, 0x188b, 0x200c, 0xc194, 0x2102, 0x001e, 0x08a8, 0x6028,
-	0xc0bc, 0x602a, 0x2001, 0x0156, 0x2003, 0xbc91, 0x8000, 0x2003,
-	0xffff, 0x6043, 0x0001, 0x080c, 0x2c3a, 0x6027, 0x0080, 0x6017,
-	0x0000, 0x6043, 0x0000, 0x0817, 0x0006, 0x0016, 0x0026, 0x0036,
-	0x00e6, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x71d0,
-	0x70d2, 0x9116, 0x05e8, 0x81ff, 0x01a0, 0x2009, 0x0000, 0x080c,
-	0x2c40, 0x2011, 0x8011, 0x2019, 0x010e, 0x231c, 0x939e, 0x0007,
-	0x1118, 0x2019, 0x0001, 0x0010, 0x2019, 0x0000, 0x080c, 0x4b14,
-	0x0438, 0x2001, 0x19a7, 0x200c, 0x81ff, 0x1140, 0x2001, 0x0109,
-	0x2004, 0xd0b4, 0x0118, 0x2019, 0x0003, 0x0008, 0x2118, 0x2011,
-	0x8012, 0x080c, 0x4b14, 0x080c, 0x56dc, 0xd0fc, 0x1188, 0x080c,
-	0xd243, 0x1170, 0x00c6, 0x080c, 0x28d4, 0x080c, 0xa51e, 0x2061,
-	0x0100, 0x2019, 0x0028, 0x2009, 0x0002, 0x080c, 0x318c, 0x00ce,
-	0x012e, 0x00fe, 0x00ee, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005,
-	0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00, 0x11f0, 0x2011,
-	0x1837, 0x2214, 0xd2ac, 0x11c8, 0x81ff, 0x01e8, 0x2011, 0x181f,
-	0x2204, 0x9106, 0x1190, 0x2011, 0x1820, 0x2214, 0x9294, 0xff00,
-	0x9584, 0xff00, 0x9206, 0x1148, 0x2011, 0x1820, 0x2214, 0x9294,
-	0x00ff, 0x9584, 0x00ff, 0x9206, 0x1120, 0x2500, 0x080c, 0x80a7,
-	0x0048, 0x9584, 0x00ff, 0x9080, 0x3327, 0x200d, 0x918c, 0xff00,
-	0x810f, 0x9006, 0x0005, 0x9080, 0x3327, 0x200d, 0x918c, 0x00ff,
-	0x0005, 0x00d6, 0x2069, 0x0140, 0x2001, 0x1818, 0x2003, 0x00ef,
-	0x20a9, 0x0010, 0x9006, 0x6852, 0x6856, 0x1f04, 0x2884, 0x00de,
-	0x0005, 0x0006, 0x00d6, 0x0026, 0x2069, 0x0140, 0x2001, 0x1818,
-	0x2102, 0x8114, 0x8214, 0x8214, 0x8214, 0x20a9, 0x0010, 0x6853,
-	0x0000, 0x9006, 0x82ff, 0x1128, 0x9184, 0x000f, 0x9080, 0xf1d7,
-	0x2005, 0x6856, 0x8211, 0x1f04, 0x2899, 0x002e, 0x00de, 0x000e,
-	0x0005, 0x00c6, 0x2061, 0x1800, 0x6030, 0x0110, 0xc09d, 0x0008,
-	0xc09c, 0x6032, 0x00ce, 0x0005, 0x0156, 0x00d6, 0x0026, 0x0016,
-	0x0006, 0x2069, 0x0140, 0x6980, 0x9116, 0x0180, 0x9112, 0x1230,
-	0x8212, 0x8210, 0x22a8, 0x2001, 0x0402, 0x0018, 0x22a8, 0x2001,
-	0x0404, 0x680e, 0x1f04, 0x28c9, 0x680f, 0x0000, 0x000e, 0x001e,
-	0x002e, 0x00de, 0x015e, 0x0005, 0x080c, 0x56d8, 0xd0c4, 0x0150,
-	0xd0a4, 0x0140, 0x9006, 0x0046, 0x2020, 0x2009, 0x002e, 0x080c,
-	0xe5cf, 0x004e, 0x0005, 0x00f6, 0x0016, 0x0026, 0x2079, 0x0140,
-	0x78c4, 0xd0dc, 0x0904, 0x2940, 0x080c, 0x2b9f, 0x0660, 0x9084,
-	0x0700, 0x908e, 0x0600, 0x1120, 0x2011, 0x4000, 0x900e, 0x0458,
-	0x908e, 0x0500, 0x1120, 0x2011, 0x8000, 0x900e, 0x0420, 0x908e,
-	0x0400, 0x1120, 0x9016, 0x2009, 0x0001, 0x00e8, 0x908e, 0x0300,
-	0x1120, 0x9016, 0x2009, 0x0002, 0x00b0, 0x908e, 0x0200, 0x1120,
-	0x9016, 0x2009, 0x0004, 0x0078, 0x908e, 0x0100, 0x1548, 0x9016,
-	0x2009, 0x0008, 0x0040, 0x9084, 0x0700, 0x908e, 0x0300, 0x1500,
-	0x2011, 0x0030, 0x0058, 0x2300, 0x9080, 0x0020, 0x2018, 0x080c,
-	0x8f51, 0x928c, 0xff00, 0x0110, 0x2011, 0x00ff, 0x2200, 0x8007,
-	0x9085, 0x004c, 0x78c2, 0x2009, 0x0138, 0x220a, 0x080c, 0x73a5,
-	0x1118, 0x2009, 0x196c, 0x220a, 0x002e, 0x001e, 0x00fe, 0x0005,
-	0x78c3, 0x0000, 0x0cc8, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016,
-	0x0026, 0x2001, 0x0170, 0x200c, 0x8000, 0x2014, 0x9184, 0x0003,
-	0x0110, 0x080c, 0x0dce, 0x002e, 0x001e, 0x000e, 0x012e, 0x0005,
-	0x2001, 0x0171, 0x2004, 0xd0dc, 0x0168, 0x2001, 0x0170, 0x200c,
-	0x918c, 0x00ff, 0x918e, 0x004c, 0x1128, 0x200c, 0x918c, 0xff00,
-	0x810f, 0x0005, 0x900e, 0x2001, 0x0227, 0x2004, 0x8007, 0x9084,
-	0x00ff, 0x8004, 0x9108, 0x2001, 0x0226, 0x2004, 0x8007, 0x9084,
-	0x00ff, 0x8004, 0x9108, 0x0005, 0x0018, 0x000c, 0x0018, 0x0020,
-	0x1000, 0x0800, 0x1000, 0x1800, 0x0156, 0x0006, 0x0016, 0x0026,
-	0x00e6, 0x2001, 0x198f, 0x2004, 0x908a, 0x0007, 0x1a0c, 0x0dd5,
-	0x0033, 0x00ee, 0x002e, 0x001e, 0x000e, 0x015e, 0x0005, 0x299e,
-	0x29bc, 0x29e0, 0x29e2, 0x2a0b, 0x2a0d, 0x2a0f, 0x2001, 0x0001,
-	0x080c, 0x27ec, 0x080c, 0x2bfd, 0x2001, 0x1991, 0x2003, 0x0000,
-	0x7828, 0x9084, 0xe1d7, 0x782a, 0x9006, 0x20a9, 0x0009, 0x080c,
-	0x2bbb, 0x2001, 0x198f, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011,
-	0x2a10, 0x080c, 0x8574, 0x0005, 0x2009, 0x1994, 0x200b, 0x0000,
-	0x2001, 0x1999, 0x2003, 0x0036, 0x2001, 0x1998, 0x2003, 0x002a,
-	0x2001, 0x1991, 0x2003, 0x0001, 0x9006, 0x080c, 0x2b6d, 0x2001,
-	0xffff, 0x20a9, 0x0009, 0x080c, 0x2bbb, 0x2001, 0x198f, 0x2003,
-	0x0006, 0x2009, 0x001e, 0x2011, 0x2a10, 0x080c, 0x8574, 0x0005,
-	0x080c, 0x0dd5, 0x2001, 0x1999, 0x2003, 0x0036, 0x2001, 0x1991,
-	0x2003, 0x0003, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0004, 0x0110,
-	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x2b6d, 0x2001, 0x1995,
-	0x2003, 0x0000, 0x2001, 0xffff, 0x20a9, 0x0009, 0x080c, 0x2bbb,
-	0x2001, 0x198f, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x2a10,
-	0x080c, 0x8574, 0x0005, 0x080c, 0x0dd5, 0x080c, 0x0dd5, 0x0005,
-	0x0006, 0x0016, 0x0026, 0x00e6, 0x00f6, 0x0156, 0x0126, 0x2091,
-	0x8000, 0x2079, 0x0100, 0x2001, 0x1991, 0x2004, 0x908a, 0x0007,
-	0x1a0c, 0x0dd5, 0x0043, 0x012e, 0x015e, 0x00fe, 0x00ee, 0x002e,
-	0x001e, 0x000e, 0x0005, 0x2a32, 0x2a52, 0x2a92, 0x2ac2, 0x2ae6,
-	0x2af6, 0x2af8, 0x080c, 0x2baf, 0x11b0, 0x7850, 0x9084, 0xefff,
-	0x7852, 0x2009, 0x1997, 0x2104, 0x7a38, 0x9294, 0x0005, 0x9296,
-	0x0004, 0x0110, 0xc08d, 0x0008, 0xc085, 0x200a, 0x2001, 0x198f,
-	0x2003, 0x0001, 0x0030, 0x080c, 0x2b1c, 0x2001, 0xffff, 0x080c,
-	0x29ad, 0x0005, 0x080c, 0x2afa, 0x05e0, 0x2009, 0x1998, 0x2104,
-	0x8001, 0x200a, 0x080c, 0x2baf, 0x1178, 0x7850, 0x9084, 0xefff,
-	0x7852, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0518, 0x2009,
-	0x1997, 0x2104, 0xc085, 0x200a, 0x2009, 0x1994, 0x2104, 0x8000,
-	0x200a, 0x9086, 0x0005, 0x0118, 0x080c, 0x2b02, 0x00c0, 0x200b,
-	0x0000, 0x7a38, 0x9294, 0x0006, 0x9296, 0x0004, 0x0110, 0x9006,
-	0x0010, 0x2001, 0x0001, 0x080c, 0x2b8a, 0x2001, 0x1991, 0x2003,
-	0x0002, 0x0028, 0x2001, 0x198f, 0x2003, 0x0003, 0x0010, 0x080c,
-	0x29cf, 0x0005, 0x080c, 0x2afa, 0x0560, 0x2009, 0x1998, 0x2104,
-	0x8001, 0x200a, 0x080c, 0x2baf, 0x1168, 0x7850, 0x9084, 0xefff,
-	0x7852, 0x2001, 0x198f, 0x2003, 0x0003, 0x2001, 0x1990, 0x2003,
-	0x0000, 0x00b8, 0x2009, 0x1998, 0x2104, 0x9005, 0x1118, 0x080c,
-	0x2b3f, 0x0010, 0x080c, 0x2b0f, 0x080c, 0x2b02, 0x2009, 0x1994,
-	0x200b, 0x0000, 0x2001, 0x1991, 0x2003, 0x0001, 0x080c, 0x29cf,
-	0x0000, 0x0005, 0x04b9, 0x0508, 0x080c, 0x2baf, 0x11b8, 0x7850,
-	0x9084, 0xefff, 0x7852, 0x2009, 0x1995, 0x2104, 0x8000, 0x200a,
-	0x9086, 0x0007, 0x0108, 0x0078, 0x2001, 0x199a, 0x2003, 0x000a,
-	0x2009, 0x1997, 0x2104, 0xc0fd, 0x200a, 0x0038, 0x0419, 0x2001,
-	0x1991, 0x2003, 0x0004, 0x080c, 0x29fa, 0x0005, 0x0099, 0x0168,
-	0x080c, 0x2baf, 0x1138, 0x7850, 0x9084, 0xefff, 0x7852, 0x080c,
-	0x29e6, 0x0018, 0x0079, 0x080c, 0x29fa, 0x0005, 0x080c, 0x0dd5,
-	0x080c, 0x0dd5, 0x2009, 0x1999, 0x2104, 0x8001, 0x200a, 0x090c,
-	0x2b5b, 0x0005, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0110,
-	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x2b8a, 0x0005, 0x7a38,
-	0x9294, 0x0006, 0x9296, 0x0006, 0x0110, 0x9006, 0x0010, 0x2001,
-	0x0001, 0x080c, 0x2b6d, 0x0005, 0x2009, 0x1994, 0x2104, 0x8000,
-	0x200a, 0x9086, 0x0005, 0x0108, 0x0068, 0x200b, 0x0000, 0x7a38,
-	0x9294, 0x0006, 0x9296, 0x0006, 0x0110, 0x9006, 0x0010, 0x2001,
-	0x0001, 0x04d9, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0110,
-	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x2b8a, 0x0005, 0x0086,
-	0x2001, 0x1997, 0x2004, 0x9084, 0x7fff, 0x090c, 0x0dd5, 0x2009,
-	0x1996, 0x2144, 0x8846, 0x280a, 0x9844, 0x0dd8, 0xd08c, 0x1120,
-	0xd084, 0x1120, 0x080c, 0x0dd5, 0x9006, 0x0010, 0x2001, 0x0001,
-	0x00a1, 0x008e, 0x0005, 0x0006, 0x0156, 0x2001, 0x198f, 0x20a9,
-	0x0009, 0x2003, 0x0000, 0x8000, 0x1f04, 0x2b61, 0x2001, 0x1996,
-	0x2003, 0x8000, 0x015e, 0x000e, 0x0005, 0x00f6, 0x2079, 0x0100,
-	0x9085, 0x0000, 0x0158, 0x7838, 0x9084, 0xfff9, 0x9085, 0x0004,
-	0x783a, 0x2009, 0x199c, 0x210c, 0x795a, 0x0050, 0x7838, 0x9084,
-	0xfffb, 0x9085, 0x0006, 0x783a, 0x2009, 0x199d, 0x210c, 0x795a,
-	0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100, 0x9085, 0x0000, 0x0138,
-	0x7838, 0x9084, 0xfffa, 0x9085, 0x0004, 0x783a, 0x0030, 0x7838,
-	0x9084, 0xfffb, 0x9085, 0x0005, 0x783a, 0x00fe, 0x0005, 0x0006,
-	0x2001, 0x0100, 0x2004, 0x9082, 0x0007, 0x000e, 0x0005, 0x0006,
-	0x2001, 0x0100, 0x2004, 0x9082, 0x0009, 0x000e, 0x0005, 0x0156,
-	0x20a9, 0x0064, 0x7820, 0x080c, 0x2c3a, 0xd09c, 0x1110, 0x1f04,
-	0x2bb2, 0x015e, 0x0005, 0x0126, 0x0016, 0x0006, 0x2091, 0x8000,
-	0x7850, 0x9085, 0x0040, 0x7852, 0x7850, 0x9084, 0xfbcf, 0x7852,
-	0x080c, 0x2c3a, 0x9085, 0x2000, 0x7852, 0x000e, 0x2008, 0x9186,
-	0x0000, 0x1118, 0x783b, 0x0007, 0x0090, 0x9186, 0x0001, 0x1118,
-	0x783b, 0x0006, 0x0060, 0x9186, 0x0002, 0x1118, 0x783b, 0x0005,
-	0x0030, 0x9186, 0x0003, 0x1118, 0x783b, 0x0004, 0x0000, 0x0006,
-	0x1d04, 0x2be8, 0x080c, 0x8596, 0x1f04, 0x2be8, 0x7850, 0x9085,
-	0x0400, 0x9084, 0xdfbf, 0x7852, 0x080c, 0x2c3a, 0x9085, 0x1000,
-	0x7852, 0x000e, 0x001e, 0x012e, 0x0005, 0x7850, 0x9084, 0xffcf,
-	0x7852, 0x0005, 0x0006, 0x0156, 0x00f6, 0x2079, 0x0100, 0x20a9,
-	0x000a, 0x7854, 0xd0ac, 0x1130, 0x7820, 0xd0e4, 0x1140, 0x1f04,
-	0x2c0c, 0x0028, 0x7854, 0xd08c, 0x1110, 0x1f04, 0x2c12, 0x00fe,
-	0x015e, 0x000e, 0x0005, 0x1d04, 0x2c1b, 0x080c, 0x8596, 0x1f04,
-	0x2c1b, 0x0005, 0x0006, 0x2001, 0x199b, 0x2004, 0x9086, 0x0000,
-	0x000e, 0x0005, 0x0006, 0x2001, 0x199b, 0x2004, 0x9086, 0x0001,
-	0x000e, 0x0005, 0x0006, 0x2001, 0x199b, 0x2004, 0x9086, 0x0002,
-	0x000e, 0x0005, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x0005,
-	0x0006, 0x2001, 0x19a7, 0x2102, 0x000e, 0x0005, 0x2009, 0x0171,
-	0x2104, 0xd0dc, 0x0140, 0x2009, 0x0170, 0x2104, 0x200b, 0x0080,
-	0xa001, 0xa001, 0x200a, 0x0005, 0x0036, 0x0046, 0x2001, 0x0141,
-	0x200c, 0x918c, 0xff00, 0x9186, 0x2000, 0x0118, 0x9186, 0x0100,
-	0x1588, 0x2009, 0x00a2, 0x080c, 0x0e51, 0x2019, 0x0160, 0x2324,
-	0x2011, 0x0003, 0x2009, 0x0169, 0x2104, 0x9084, 0x0007, 0x210c,
-	0x918c, 0x0007, 0x910e, 0x1db0, 0x9086, 0x0003, 0x11b8, 0x2304,
-	0x9402, 0x02a0, 0x1d60, 0x8211, 0x1d68, 0x84ff, 0x0170, 0x2001,
-	0x0141, 0x200c, 0x918c, 0xff00, 0x9186, 0x0100, 0x0130, 0x2009,
-	0x180c, 0x2104, 0xc0dd, 0x200a, 0x0008, 0x0419, 0x2009, 0x0000,
-	0x080c, 0x0e51, 0x004e, 0x003e, 0x0005, 0x2001, 0x180c, 0x2004,
-	0xd0dc, 0x01b0, 0x2001, 0x0160, 0x2004, 0x9005, 0x0140, 0x2001,
-	0x0141, 0x2004, 0x9084, 0xff00, 0x9086, 0x0100, 0x1148, 0x0126,
-	0x2091, 0x8000, 0x0016, 0x0026, 0x0021, 0x002e, 0x001e, 0x012e,
-	0x0005, 0x00c6, 0x2061, 0x0100, 0x6014, 0x0006, 0x2001, 0x0161,
-	0x2003, 0x0000, 0x6017, 0x0018, 0xa001, 0xa001, 0x602f, 0x0008,
-	0x6104, 0x918e, 0x0010, 0x6106, 0x918e, 0x0010, 0x6106, 0x6017,
-	0x0040, 0x04b9, 0x001e, 0x9184, 0x0003, 0x01e0, 0x0036, 0x0016,
-	0x2019, 0x0141, 0x6124, 0x918c, 0x0028, 0x1120, 0x2304, 0x9084,
-	0x2800, 0x0dc0, 0x001e, 0x919c, 0xffe4, 0x9184, 0x0001, 0x0118,
-	0x9385, 0x0009, 0x6016, 0x9184, 0x0002, 0x0118, 0x9385, 0x0012,
-	0x6016, 0x003e, 0x2001, 0x180c, 0x200c, 0xc1dc, 0x2102, 0x00ce,
-	0x0005, 0x0016, 0x0026, 0x080c, 0x73bf, 0x0108, 0xc0bc, 0x2009,
-	0x0140, 0x2114, 0x9294, 0x0001, 0x9215, 0x220a, 0x002e, 0x001e,
-	0x0005, 0x0016, 0x0026, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001,
-	0x9285, 0x1000, 0x200a, 0x220a, 0x002e, 0x001e, 0x0005, 0x0016,
-	0x0026, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001, 0x9215, 0x220a,
-	0x002e, 0x001e, 0x0005, 0x0006, 0x0016, 0x2009, 0x0140, 0x2104,
-	0x1128, 0x080c, 0x73bf, 0x0110, 0xc0bc, 0x0008, 0xc0bd, 0x200a,
-	0x001e, 0x000e, 0x0005, 0x2f97, 0x2f97, 0x2dbb, 0x2dbb, 0x2dc7,
-	0x2dc7, 0x2dd3, 0x2dd3, 0x2de1, 0x2de1, 0x2ded, 0x2ded, 0x2dfb,
-	0x2dfb, 0x2e09, 0x2e09, 0x2e1b, 0x2e1b, 0x2e27, 0x2e27, 0x2e35,
-	0x2e35, 0x2e53, 0x2e53, 0x2e73, 0x2e73, 0x2e43, 0x2e43, 0x2e63,
-	0x2e63, 0x2e81, 0x2e81, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e93, 0x2e93, 0x2e9f, 0x2e9f, 0x2ead,
-	0x2ead, 0x2ebb, 0x2ebb, 0x2ecb, 0x2ecb, 0x2ed9, 0x2ed9, 0x2ee9,
-	0x2ee9, 0x2ef9, 0x2ef9, 0x2f0b, 0x2f0b, 0x2f19, 0x2f19, 0x2f29,
-	0x2f29, 0x2f4b, 0x2f4b, 0x2f6d, 0x2f6d, 0x2f39, 0x2f39, 0x2f5c,
-	0x2f5c, 0x2f7c, 0x2f7c, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19, 0x2e19,
-	0x2e19, 0x2e19, 0x2e19, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2483, 0x0804, 0x2f8f, 0x0106,
-	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2297, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2297, 0x080c, 0x2483, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x22d2, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2483, 0x080c,
-	0x22d2, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2297, 0x080c, 0x22d2, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2297, 0x080c, 0x2483, 0x080c, 0x22d2, 0x0804,
-	0x2f8f, 0xa001, 0x0cf0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x1380, 0x0804, 0x2f8f, 0x0106,
+	0xa001, 0xa001, 0x8211, 0x1de0, 0x0059, 0x0804, 0x7463, 0x0479,
+	0x0039, 0x2001, 0x0160, 0x2502, 0x2001, 0x0138, 0x2202, 0x0005,
+	0x00e6, 0x2071, 0x0200, 0x080c, 0x2c51, 0x2009, 0x003c, 0x080c,
+	0x23df, 0x2001, 0x015d, 0x2003, 0x0000, 0x7000, 0x9084, 0x003c,
+	0x1de0, 0x080c, 0x841a, 0x70a0, 0x70a2, 0x7098, 0x709a, 0x709c,
+	0x709e, 0x2001, 0x020d, 0x2003, 0x0020, 0x00f6, 0x2079, 0x0300,
+	0x080c, 0x1313, 0x7803, 0x0001, 0x00fe, 0x00ee, 0x0005, 0x2001,
+	0x0138, 0x2014, 0x2003, 0x0000, 0x2001, 0x0160, 0x202c, 0x2003,
+	0x0000, 0x080c, 0x73b3, 0x1108, 0x0005, 0x2021, 0x0260, 0x2001,
+	0x0141, 0x201c, 0xd3dc, 0x1168, 0x2001, 0x0109, 0x201c, 0x939c,
+	0x0048, 0x1160, 0x2001, 0x0111, 0x201c, 0x83ff, 0x1110, 0x8421,
+	0x1d70, 0x2001, 0x015d, 0x2003, 0x0000, 0x0005, 0x0046, 0x2021,
+	0x0019, 0x2003, 0x0048, 0xa001, 0xa001, 0x201c, 0x939c, 0x0048,
+	0x0120, 0x8421, 0x1db0, 0x004e, 0x0c60, 0x004e, 0x0c40, 0x601c,
+	0xc084, 0x601e, 0x0005, 0x2c08, 0x621c, 0x080c, 0x15f0, 0x7930,
+	0x0005, 0x2c08, 0x621c, 0x080c, 0x169b, 0x7930, 0x0005, 0x8001,
+	0x1df0, 0x0005, 0x2031, 0x0005, 0x781c, 0x9084, 0x0007, 0x0170,
+	0x2001, 0x0038, 0x0c41, 0x9186, 0x0040, 0x0904, 0x1bb0, 0x2001,
+	0x001e, 0x0c69, 0x8631, 0x1d80, 0x080c, 0x0dd5, 0x781f, 0x0202,
+	0x2001, 0x015d, 0x2003, 0x0000, 0x2001, 0x0b10, 0x0c01, 0x781c,
+	0xd084, 0x0110, 0x0861, 0x04e0, 0x2001, 0x0030, 0x0891, 0x9186,
+	0x0040, 0x0568, 0x781c, 0xd084, 0x1da8, 0x781f, 0x0101, 0x2001,
+	0x0014, 0x0869, 0x2001, 0x0037, 0x0821, 0x9186, 0x0040, 0x0140,
+	0x2001, 0x0030, 0x080c, 0x1b49, 0x9186, 0x0040, 0x190c, 0x0dd5,
+	0x00d6, 0x2069, 0x0200, 0x692c, 0xd1f4, 0x1170, 0xd1c4, 0x0160,
+	0xd19c, 0x0130, 0x6800, 0x9085, 0x1800, 0x6802, 0x00de, 0x0080,
+	0x6908, 0x9184, 0x0007, 0x1db0, 0x00de, 0x781f, 0x0100, 0x791c,
+	0x9184, 0x0007, 0x090c, 0x0dd5, 0xa001, 0xa001, 0x781f, 0x0200,
+	0x0005, 0x0126, 0x2091, 0x2400, 0x2071, 0x1a65, 0x2079, 0x0090,
+	0x012e, 0x0005, 0x9280, 0x0005, 0x2004, 0x2048, 0xa97c, 0xd1dc,
+	0x1904, 0x1c52, 0xa964, 0x9184, 0x0007, 0x0002, 0x1bce, 0x1c3d,
+	0x1be5, 0x1be7, 0x1be5, 0x1c25, 0x1c05, 0x1bf4, 0x918c, 0x00ff,
+	0x9186, 0x0008, 0x1170, 0xa87c, 0xd0b4, 0x0904, 0x1e7c, 0x9006,
+	0xa842, 0xa83e, 0xa988, 0x2900, 0xa85a, 0xa813, 0x2098, 0x0804,
+	0x1c4e, 0x9186, 0x0048, 0x0904, 0x1c3d, 0x080c, 0x0dd5, 0x9184,
+	0x00ff, 0x9086, 0x0013, 0x0904, 0x1c3d, 0x9184, 0x00ff, 0x9086,
+	0x001b, 0x0904, 0x1c3d, 0x0c88, 0xa87c, 0xd0b4, 0x0904, 0x1e7c,
+	0xa890, 0xa842, 0xa83a, 0xa88c, 0xa83e, 0xa836, 0xa8ac, 0xa846,
+	0xa8b0, 0xa84a, 0xa988, 0x0804, 0x1c45, 0xa864, 0x9084, 0x00ff,
+	0x9086, 0x001e, 0x19d0, 0xa87c, 0xd0b4, 0x0904, 0x1e7c, 0xa890,
+	0xa842, 0xa83a, 0xa88c, 0xa83e, 0xa836, 0xa8ac, 0xa846, 0xa8b0,
+	0xa84a, 0xa804, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f, 0x9080,
+	0x209d, 0x2005, 0xa812, 0xa988, 0x0448, 0x918c, 0x00ff, 0x9186,
+	0x0015, 0x1540, 0xa87c, 0xd0b4, 0x0904, 0x1e7c, 0xa804, 0xa85a,
+	0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x209d, 0x2005, 0xa812,
+	0xa988, 0x9006, 0xa842, 0xa83e, 0x0088, 0xa87c, 0xd0b4, 0x0904,
+	0x1e7c, 0xa988, 0x9006, 0xa842, 0xa83e, 0x2900, 0xa85a, 0xa864,
+	0x9084, 0x000f, 0x9080, 0x209d, 0x2005, 0xa812, 0xa916, 0xa87c,
+	0xc0dd, 0xa87e, 0x0005, 0x00f6, 0x2079, 0x0090, 0x782c, 0xd0fc,
+	0x190c, 0x1ec1, 0x00e6, 0x2071, 0x1a65, 0x7000, 0x9005, 0x1904,
+	0x1cbb, 0x7206, 0x9280, 0x0005, 0x204c, 0x9280, 0x0004, 0x2004,
+	0x782b, 0x0004, 0x00f6, 0x2079, 0x0200, 0x7803, 0x0040, 0x00fe,
+	0x00b6, 0x2058, 0xb86c, 0x7836, 0xb890, 0x00be, 0x00f6, 0x2079,
+	0x0200, 0x7803, 0x0040, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001,
+	0xa001, 0x781a, 0x2079, 0x0100, 0x8004, 0x78d6, 0x00fe, 0xa814,
+	0x2050, 0xa858, 0x2040, 0xa810, 0x2060, 0xa064, 0x90ec, 0x000f,
+	0xa944, 0x791a, 0x7116, 0xa848, 0x781e, 0x701a, 0x9006, 0x700e,
+	0x7012, 0x7004, 0xa940, 0xa838, 0x9106, 0x1500, 0xa93c, 0xa834,
+	0x9106, 0x11e0, 0x0006, 0x0016, 0xa938, 0xa834, 0x9105, 0x0118,
+	0x001e, 0x000e, 0x0098, 0x001e, 0x000e, 0x8aff, 0x01c8, 0x0126,
+	0x2091, 0x8000, 0x2009, 0x0306, 0x200b, 0x0808, 0x00d9, 0x0108,
+	0x00c9, 0x012e, 0x9006, 0x00ee, 0x00fe, 0x0005, 0x0036, 0x0046,
+	0xab38, 0xac34, 0x080c, 0x20bd, 0x004e, 0x003e, 0x0d30, 0x0c98,
+	0x9085, 0x0001, 0x0c80, 0x2009, 0x0306, 0x200b, 0x4800, 0x7027,
+	0x0000, 0x0005, 0x0076, 0x0066, 0x0056, 0x0046, 0x0036, 0x0026,
+	0x8aff, 0x0904, 0x1e75, 0x700c, 0x7214, 0x923a, 0x7010, 0x7218,
+	0x9203, 0x0a04, 0x1e74, 0x9705, 0x0904, 0x1e74, 0x903e, 0x2730,
+	0xa880, 0xd0fc, 0x1190, 0x2d00, 0x0002, 0x1dfe, 0x1d3d, 0x1d3d,
+	0x1dfe, 0x1dfe, 0x1ddb, 0x1dfe, 0x1d3d, 0x1de2, 0x1d8c, 0x1d8c,
+	0x1dfe, 0x1dfe, 0x1dfe, 0x1dd5, 0x1d8c, 0xc0fc, 0xa882, 0xab2c,
+	0xaa30, 0xad1c, 0xac20, 0xdd9c, 0x0904, 0x1e0b, 0x2c05, 0x908a,
+	0x0034, 0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002, 0x1d29, 0x1d27,
+	0x1d27, 0x1d27, 0x1d27, 0x1d27, 0x1d2d, 0x1d27, 0x1d27, 0x1d27,
+	0x1d27, 0x1d27, 0x1d31, 0x1d27, 0x1d27, 0x1d27, 0x1d27, 0x1d27,
+	0x1d35, 0x1d27, 0x1d27, 0x1d27, 0x1d27, 0x1d27, 0x1d39, 0x080c,
+	0x0dd5, 0xa774, 0xa678, 0x0804, 0x1e0b, 0xa78c, 0xa690, 0x0804,
+	0x1e0b, 0xa7a4, 0xa6a8, 0x0804, 0x1e0b, 0xa7bc, 0xa6c0, 0x0804,
+	0x1e0b, 0xa7d4, 0xa6d8, 0x0804, 0x1e0b, 0x2c05, 0x908a, 0x0036,
+	0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002, 0x1d60, 0x1d60, 0x1d62,
+	0x1d60, 0x1d60, 0x1d60, 0x1d68, 0x1d60, 0x1d60, 0x1d60, 0x1d6e,
+	0x1d60, 0x1d60, 0x1d60, 0x1d74, 0x1d60, 0x1d60, 0x1d60, 0x1d7a,
+	0x1d60, 0x1d60, 0x1d60, 0x1d80, 0x1d60, 0x1d60, 0x1d60, 0x1d86,
+	0x080c, 0x0dd5, 0xa574, 0xa478, 0xa37c, 0xa280, 0x0804, 0x1e0b,
+	0xa584, 0xa488, 0xa38c, 0xa290, 0x0804, 0x1e0b, 0xa594, 0xa498,
+	0xa39c, 0xa2a0, 0x0804, 0x1e0b, 0xa5a4, 0xa4a8, 0xa3ac, 0xa2b0,
+	0x0804, 0x1e0b, 0xa5b4, 0xa4b8, 0xa3bc, 0xa2c0, 0x0804, 0x1e0b,
+	0xa5c4, 0xa4c8, 0xa3cc, 0xa2d0, 0x0804, 0x1e0b, 0xa5d4, 0xa4d8,
+	0xa3dc, 0xa2e0, 0x0804, 0x1e0b, 0x2c05, 0x908a, 0x0034, 0x1a0c,
+	0x0dd5, 0x9082, 0x001b, 0x0002, 0x1daf, 0x1dad, 0x1dad, 0x1dad,
+	0x1dad, 0x1dad, 0x1db7, 0x1dad, 0x1dad, 0x1dad, 0x1dad, 0x1dad,
+	0x1dbf, 0x1dad, 0x1dad, 0x1dad, 0x1dad, 0x1dad, 0x1dc7, 0x1dad,
+	0x1dad, 0x1dad, 0x1dad, 0x1dad, 0x1dce, 0x080c, 0x0dd5, 0xa56c,
+	0xa470, 0xa774, 0xa678, 0xa37c, 0xa280, 0x0804, 0x1e0b, 0xa584,
+	0xa488, 0xa78c, 0xa690, 0xa394, 0xa298, 0x0804, 0x1e0b, 0xa59c,
+	0xa4a0, 0xa7a4, 0xa6a8, 0xa3ac, 0xa2b0, 0x0804, 0x1e0b, 0xa5b4,
+	0xa4b8, 0xa7bc, 0xa6c0, 0xa3c4, 0xa2c8, 0x04e8, 0xa5cc, 0xa4d0,
+	0xa7d4, 0xa6d8, 0xa3dc, 0xa2e0, 0x04b0, 0xa864, 0x9084, 0x00ff,
+	0x9086, 0x001e, 0x1518, 0x080c, 0x2055, 0x1904, 0x1cd8, 0x900e,
+	0x0804, 0x1e75, 0xab64, 0x939c, 0x00ff, 0x9386, 0x0048, 0x1180,
+	0x00c6, 0x7004, 0x2060, 0x6004, 0x9086, 0x0043, 0x00ce, 0x0904,
+	0x1d8c, 0xab9c, 0x9016, 0xad8c, 0xac90, 0xaf94, 0xae98, 0x0098,
+	0x9386, 0x0008, 0x0904, 0x1d8c, 0x080c, 0x0dd5, 0xa964, 0x918c,
+	0x00ff, 0x9186, 0x0013, 0x0904, 0x1d3d, 0x9186, 0x001b, 0x0904,
+	0x1d8c, 0x080c, 0x0dd5, 0x2009, 0x030f, 0x2104, 0xd0fc, 0x0530,
+	0x0066, 0x2009, 0x0306, 0x2104, 0x9084, 0x0030, 0x15c8, 0x2031,
+	0x1000, 0x200b, 0x4000, 0x2600, 0x9302, 0x928b, 0x0000, 0xa82e,
+	0xa932, 0x0278, 0x9105, 0x0168, 0x2011, 0x0000, 0x2618, 0x2600,
+	0x9500, 0xa81e, 0x9481, 0x0000, 0xa822, 0xa880, 0xc0fd, 0xa882,
+	0x0020, 0xa82f, 0x0000, 0xa833, 0x0000, 0x006e, 0x7b12, 0x7a16,
+	0x7d02, 0x7c06, 0x7f0a, 0x7e0e, 0x782b, 0x0001, 0x7000, 0x8000,
+	0x7002, 0xa83c, 0x9300, 0xa83e, 0xa840, 0x9201, 0xa842, 0x700c,
+	0x9300, 0x700e, 0x7010, 0x9201, 0x7012, 0x080c, 0x2055, 0x0428,
+	0x2031, 0x0080, 0x9584, 0x007f, 0x0108, 0x9632, 0x7124, 0x7000,
+	0x9086, 0x0000, 0x1198, 0xc185, 0x7126, 0x2009, 0x0306, 0x2104,
+	0xd0b4, 0x1904, 0x1e1b, 0x200b, 0x4040, 0x2009, 0x1a7e, 0x2104,
+	0x8000, 0x0a04, 0x1e1b, 0x200a, 0x0804, 0x1e1b, 0xc18d, 0x7126,
+	0xd184, 0x1d58, 0x0804, 0x1e1b, 0x9006, 0x002e, 0x003e, 0x004e,
+	0x005e, 0x006e, 0x007e, 0x0005, 0x080c, 0x0dd5, 0x0026, 0x2001,
+	0x0105, 0x2003, 0x0010, 0x782b, 0x0004, 0x7003, 0x0000, 0x7004,
+	0x0016, 0x080c, 0x1ccb, 0x001e, 0x2060, 0x6014, 0x2048, 0x080c,
+	0xcb5a, 0x0118, 0xa880, 0xc0bd, 0xa882, 0x6020, 0x9086, 0x0006,
+	0x1180, 0x2061, 0x0100, 0x62c8, 0x2001, 0x00fa, 0x8001, 0x1df0,
+	0x60c8, 0x9206, 0x1dc0, 0x60c4, 0xa89a, 0x60c8, 0xa896, 0x7004,
+	0x2060, 0x00c6, 0x080c, 0xc77b, 0x00ce, 0x2001, 0x19f5, 0x2004,
+	0x9c06, 0x1160, 0x2009, 0x0040, 0x080c, 0x23df, 0x080c, 0xa7b7,
+	0x2011, 0x0000, 0x080c, 0xa648, 0x080c, 0x97d4, 0x002e, 0x0804,
+	0x2005, 0x0126, 0x2091, 0x2400, 0xa858, 0x2040, 0x792c, 0x782b,
+	0x0002, 0x9184, 0x0700, 0x1904, 0x1e7e, 0x7000, 0x0002, 0x2005,
+	0x1ed3, 0x1f53, 0x2003, 0x8001, 0x7002, 0x7027, 0x0000, 0xd19c,
+	0x1158, 0x8aff, 0x0904, 0x1f20, 0x080c, 0x1cd2, 0x0904, 0x2005,
+	0x080c, 0x1cd2, 0x0804, 0x2005, 0x782b, 0x0004, 0xd194, 0x0148,
+	0xa880, 0xc0fc, 0xa882, 0x8aff, 0x1518, 0xa87c, 0xc0f5, 0xa87e,
+	0x00f8, 0x0026, 0x0036, 0xab3c, 0xaa40, 0x0016, 0x7910, 0xa82c,
+	0x9100, 0xa82e, 0x7914, 0xa830, 0x9101, 0xa832, 0x001e, 0x7810,
+	0x931a, 0x7814, 0x9213, 0x7800, 0xa81e, 0x7804, 0xa822, 0xab3e,
+	0xaa42, 0x003e, 0x002e, 0x080c, 0x2070, 0xa880, 0xc0fd, 0xa882,
+	0x2a00, 0xa816, 0x2800, 0xa85a, 0x2c00, 0xa812, 0x7003, 0x0000,
+	0x2009, 0x0306, 0x200b, 0x4800, 0x7027, 0x0000, 0x0804, 0x2005,
+	0x00f6, 0x0026, 0x781c, 0x0006, 0x7818, 0x0006, 0x2079, 0x0100,
+	0x7a14, 0x9284, 0x1984, 0x9085, 0x0012, 0x7816, 0x0036, 0x2019,
+	0x1000, 0x8319, 0x090c, 0x0dd5, 0x7820, 0xd0bc, 0x1dd0, 0x003e,
+	0x79c8, 0x000e, 0x9102, 0x001e, 0x0006, 0x0016, 0x79c4, 0x000e,
+	0x9103, 0x78c6, 0x000e, 0x78ca, 0x9284, 0x1984, 0x9085, 0x0012,
+	0x7816, 0x002e, 0x00fe, 0x782b, 0x0008, 0x7003, 0x0000, 0x080c,
+	0x1ccb, 0x0804, 0x2005, 0x8001, 0x7002, 0x7024, 0x8004, 0x7026,
+	0xd194, 0x0170, 0x782c, 0xd0fc, 0x1904, 0x1ec6, 0xd19c, 0x1904,
+	0x2001, 0x8aff, 0x0904, 0x2005, 0x080c, 0x1cd2, 0x0804, 0x2005,
+	0x0026, 0x0036, 0xab3c, 0xaa40, 0x080c, 0x2070, 0xdd9c, 0x1904,
+	0x1fc0, 0x2c05, 0x908a, 0x0036, 0x1a0c, 0x0dd5, 0x9082, 0x001b,
+	0x0002, 0x1f94, 0x1f94, 0x1f96, 0x1f94, 0x1f94, 0x1f94, 0x1f9c,
+	0x1f94, 0x1f94, 0x1f94, 0x1fa2, 0x1f94, 0x1f94, 0x1f94, 0x1fa8,
+	0x1f94, 0x1f94, 0x1f94, 0x1fae, 0x1f94, 0x1f94, 0x1f94, 0x1fb4,
+	0x1f94, 0x1f94, 0x1f94, 0x1fba, 0x080c, 0x0dd5, 0xa07c, 0x931a,
+	0xa080, 0x9213, 0x0804, 0x1ef5, 0xa08c, 0x931a, 0xa090, 0x9213,
+	0x0804, 0x1ef5, 0xa09c, 0x931a, 0xa0a0, 0x9213, 0x0804, 0x1ef5,
+	0xa0ac, 0x931a, 0xa0b0, 0x9213, 0x0804, 0x1ef5, 0xa0bc, 0x931a,
+	0xa0c0, 0x9213, 0x0804, 0x1ef5, 0xa0cc, 0x931a, 0xa0d0, 0x9213,
+	0x0804, 0x1ef5, 0xa0dc, 0x931a, 0xa0e0, 0x9213, 0x0804, 0x1ef5,
+	0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002,
+	0x1fe3, 0x1fe1, 0x1fe1, 0x1fe1, 0x1fe1, 0x1fe1, 0x1fe9, 0x1fe1,
+	0x1fe1, 0x1fe1, 0x1fe1, 0x1fe1, 0x1fef, 0x1fe1, 0x1fe1, 0x1fe1,
+	0x1fe1, 0x1fe1, 0x1ff5, 0x1fe1, 0x1fe1, 0x1fe1, 0x1fe1, 0x1fe1,
+	0x1ffb, 0x080c, 0x0dd5, 0xa07c, 0x931a, 0xa080, 0x9213, 0x0804,
+	0x1ef5, 0xa094, 0x931a, 0xa098, 0x9213, 0x0804, 0x1ef5, 0xa0ac,
+	0x931a, 0xa0b0, 0x9213, 0x0804, 0x1ef5, 0xa0c4, 0x931a, 0xa0c8,
+	0x9213, 0x0804, 0x1ef5, 0xa0dc, 0x931a, 0xa0e0, 0x9213, 0x0804,
+	0x1ef5, 0x0804, 0x1ef1, 0x080c, 0x0dd5, 0x012e, 0x0005, 0x00f6,
+	0x00e6, 0x2071, 0x1a65, 0x7000, 0x9086, 0x0000, 0x0904, 0x2050,
+	0x2079, 0x0090, 0x2009, 0x0207, 0x210c, 0xd194, 0x01b8, 0x2009,
+	0x020c, 0x210c, 0x9184, 0x0003, 0x0188, 0x080c, 0xea45, 0x2001,
+	0x0133, 0x2004, 0x9005, 0x090c, 0x0dd5, 0x0016, 0x2009, 0x0040,
+	0x080c, 0x23df, 0x001e, 0x2001, 0x020c, 0x2102, 0x2009, 0x0206,
+	0x2104, 0x2009, 0x0203, 0x210c, 0x9106, 0x1120, 0x2009, 0x0040,
+	0x080c, 0x23df, 0x782c, 0xd0fc, 0x09a8, 0x080c, 0x1ec1, 0x7000,
+	0x9086, 0x0000, 0x1978, 0x782b, 0x0004, 0x782c, 0xd0ac, 0x1de8,
+	0x2009, 0x0040, 0x080c, 0x23df, 0x782b, 0x0002, 0x7003, 0x0000,
+	0x080c, 0x1ccb, 0x00ee, 0x00fe, 0x0005, 0xa880, 0xd0fc, 0x11a8,
+	0x8c60, 0x2c05, 0x9005, 0x0110, 0x8a51, 0x0005, 0xa004, 0x9005,
+	0x0168, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x209d,
+	0x2065, 0x8cff, 0x090c, 0x0dd5, 0x8a51, 0x0005, 0x2050, 0x0005,
+	0xa880, 0xd0fc, 0x11b8, 0x8a50, 0x8c61, 0x2c05, 0x9005, 0x1190,
+	0x2800, 0x9906, 0x0120, 0xa000, 0x9005, 0x1108, 0x2900, 0x2040,
+	0xa85a, 0xa064, 0x9084, 0x000f, 0x9080, 0x20ad, 0x2065, 0x8cff,
+	0x090c, 0x0dd5, 0x0005, 0x0000, 0x001d, 0x0021, 0x0025, 0x0029,
+	0x002d, 0x0031, 0x0035, 0x0000, 0x001b, 0x0021, 0x0027, 0x002d,
+	0x0033, 0x0000, 0x0000, 0x0023, 0x0000, 0x0000, 0x2090, 0x208c,
+	0x2090, 0x2090, 0x209a, 0x0000, 0x2090, 0x2097, 0x2097, 0x2094,
+	0x2097, 0x2097, 0x0000, 0x209a, 0x2097, 0x0000, 0x2092, 0x2092,
+	0x0000, 0x2092, 0x209a, 0x0000, 0x2092, 0x2098, 0x2098, 0x2098,
+	0x0000, 0x2098, 0x0000, 0x209a, 0x2098, 0x00c6, 0x00d6, 0x0086,
+	0xab42, 0xac3e, 0xa888, 0x9055, 0x0904, 0x229c, 0x2940, 0xa064,
+	0x90ec, 0x000f, 0x9084, 0x00ff, 0x9086, 0x0008, 0x1118, 0x2061,
+	0x2098, 0x00d0, 0x9de0, 0x209d, 0x9d86, 0x0007, 0x0130, 0x9d86,
+	0x000e, 0x0118, 0x9d86, 0x000f, 0x1120, 0xa08c, 0x9422, 0xa090,
+	0x931b, 0x2c05, 0x9065, 0x1140, 0x0310, 0x0804, 0x229c, 0xa004,
+	0x9045, 0x0904, 0x229c, 0x08d8, 0x2c05, 0x9005, 0x0904, 0x2184,
+	0xdd9c, 0x1904, 0x2140, 0x908a, 0x0036, 0x1a0c, 0x0dd5, 0x9082,
+	0x001b, 0x0002, 0x2115, 0x2115, 0x2117, 0x2115, 0x2115, 0x2115,
+	0x211d, 0x2115, 0x2115, 0x2115, 0x2123, 0x2115, 0x2115, 0x2115,
+	0x2129, 0x2115, 0x2115, 0x2115, 0x212f, 0x2115, 0x2115, 0x2115,
+	0x2135, 0x2115, 0x2115, 0x2115, 0x213b, 0x080c, 0x0dd5, 0xa07c,
+	0x9422, 0xa080, 0x931b, 0x0804, 0x217a, 0xa08c, 0x9422, 0xa090,
+	0x931b, 0x0804, 0x217a, 0xa09c, 0x9422, 0xa0a0, 0x931b, 0x0804,
+	0x217a, 0xa0ac, 0x9422, 0xa0b0, 0x931b, 0x0804, 0x217a, 0xa0bc,
+	0x9422, 0xa0c0, 0x931b, 0x0804, 0x217a, 0xa0cc, 0x9422, 0xa0d0,
+	0x931b, 0x0804, 0x217a, 0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x04d0,
+	0x908a, 0x0034, 0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002, 0x2162,
+	0x2160, 0x2160, 0x2160, 0x2160, 0x2160, 0x2167, 0x2160, 0x2160,
+	0x2160, 0x2160, 0x2160, 0x216c, 0x2160, 0x2160, 0x2160, 0x2160,
+	0x2160, 0x2171, 0x2160, 0x2160, 0x2160, 0x2160, 0x2160, 0x2176,
+	0x080c, 0x0dd5, 0xa07c, 0x9422, 0xa080, 0x931b, 0x0098, 0xa094,
+	0x9422, 0xa098, 0x931b, 0x0070, 0xa0ac, 0x9422, 0xa0b0, 0x931b,
+	0x0048, 0xa0c4, 0x9422, 0xa0c8, 0x931b, 0x0020, 0xa0dc, 0x9422,
+	0xa0e0, 0x931b, 0x0630, 0x2300, 0x9405, 0x0160, 0x8a51, 0x0904,
+	0x229c, 0x8c60, 0x0804, 0x20ec, 0xa004, 0x9045, 0x0904, 0x229c,
+	0x0804, 0x20c7, 0x8a51, 0x0904, 0x229c, 0x8c60, 0x2c05, 0x9005,
+	0x1158, 0xa004, 0x9045, 0x0904, 0x229c, 0xa064, 0x90ec, 0x000f,
+	0x9de0, 0x209d, 0x2c05, 0x2060, 0xa880, 0xc0fc, 0xa882, 0x0804,
+	0x2291, 0x2c05, 0x8422, 0x8420, 0x831a, 0x9399, 0x0000, 0xac2e,
+	0xab32, 0xdd9c, 0x1904, 0x222e, 0x9082, 0x001b, 0x0002, 0x21ca,
+	0x21ca, 0x21cc, 0x21ca, 0x21ca, 0x21ca, 0x21da, 0x21ca, 0x21ca,
+	0x21ca, 0x21e8, 0x21ca, 0x21ca, 0x21ca, 0x21f6, 0x21ca, 0x21ca,
+	0x21ca, 0x2204, 0x21ca, 0x21ca, 0x21ca, 0x2212, 0x21ca, 0x21ca,
+	0x21ca, 0x2220, 0x080c, 0x0dd5, 0xa17c, 0x2400, 0x9122, 0xa180,
+	0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa074, 0x9420, 0xa078, 0x9319,
+	0x0804, 0x228c, 0xa18c, 0x2400, 0x9122, 0xa190, 0x2300, 0x911b,
+	0x0a0c, 0x0dd5, 0xa084, 0x9420, 0xa088, 0x9319, 0x0804, 0x228c,
+	0xa19c, 0x2400, 0x9122, 0xa1a0, 0x2300, 0x911b, 0x0a0c, 0x0dd5,
+	0xa094, 0x9420, 0xa098, 0x9319, 0x0804, 0x228c, 0xa1ac, 0x2400,
+	0x9122, 0xa1b0, 0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa0a4, 0x9420,
+	0xa0a8, 0x9319, 0x0804, 0x228c, 0xa1bc, 0x2400, 0x9122, 0xa1c0,
+	0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa0b4, 0x9420, 0xa0b8, 0x9319,
+	0x0804, 0x228c, 0xa1cc, 0x2400, 0x9122, 0xa1d0, 0x2300, 0x911b,
+	0x0a0c, 0x0dd5, 0xa0c4, 0x9420, 0xa0c8, 0x9319, 0x0804, 0x228c,
+	0xa1dc, 0x2400, 0x9122, 0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0dd5,
+	0xa0d4, 0x9420, 0xa0d8, 0x9319, 0x0804, 0x228c, 0x9082, 0x001b,
+	0x0002, 0x224c, 0x224a, 0x224a, 0x224a, 0x224a, 0x224a, 0x2259,
+	0x224a, 0x224a, 0x224a, 0x224a, 0x224a, 0x2266, 0x224a, 0x224a,
+	0x224a, 0x224a, 0x224a, 0x2273, 0x224a, 0x224a, 0x224a, 0x224a,
+	0x224a, 0x2280, 0x080c, 0x0dd5, 0xa17c, 0x2400, 0x9122, 0xa180,
+	0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa06c, 0x9420, 0xa070, 0x9319,
+	0x0498, 0xa194, 0x2400, 0x9122, 0xa198, 0x2300, 0x911b, 0x0a0c,
+	0x0dd5, 0xa084, 0x9420, 0xa088, 0x9319, 0x0430, 0xa1ac, 0x2400,
+	0x9122, 0xa1b0, 0x2300, 0x911b, 0x0a0c, 0x0dd5, 0xa09c, 0x9420,
+	0xa0a0, 0x9319, 0x00c8, 0xa1c4, 0x2400, 0x9122, 0xa1c8, 0x2300,
+	0x911b, 0x0a0c, 0x0dd5, 0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0060,
+	0xa1dc, 0x2400, 0x9122, 0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0dd5,
+	0xa0cc, 0x9420, 0xa0d0, 0x9319, 0xac1e, 0xab22, 0xa880, 0xc0fd,
+	0xa882, 0x2800, 0xa85a, 0x2c00, 0xa812, 0x2a00, 0xa816, 0x000e,
+	0x000e, 0x000e, 0x9006, 0x0028, 0x008e, 0x00de, 0x00ce, 0x9085,
+	0x0001, 0x0005, 0x2001, 0x0005, 0x2004, 0xd0bc, 0x190c, 0x0dce,
+	0x9084, 0x0007, 0x0002, 0x22bd, 0x1ec1, 0x22bd, 0x22b3, 0x22b6,
+	0x22b9, 0x22b6, 0x22b9, 0x080c, 0x1ec1, 0x0005, 0x080c, 0x11a3,
+	0x0005, 0x080c, 0x1ec1, 0x080c, 0x11a3, 0x0005, 0x0126, 0x2091,
+	0x2600, 0x2079, 0x0200, 0x2071, 0x0260, 0x2069, 0x1800, 0x7817,
+	0x0000, 0x789b, 0x0814, 0x78a3, 0x0406, 0x789f, 0x0410, 0x2009,
+	0x013b, 0x200b, 0x0400, 0x781b, 0x0002, 0x783b, 0x001f, 0x7837,
+	0x0020, 0x7803, 0x1600, 0x012e, 0x0005, 0x2091, 0x2600, 0x781c,
+	0xd0a4, 0x190c, 0x23dc, 0x7900, 0xd1dc, 0x1118, 0x9084, 0x0006,
+	0x001a, 0x9084, 0x000e, 0x0002, 0x2304, 0x22fc, 0x7d93, 0x22fc,
+	0x22fe, 0x22fe, 0x22fe, 0x22fe, 0x7d79, 0x22fc, 0x2300, 0x22fc,
+	0x22fe, 0x22fc, 0x22fe, 0x22fc, 0x080c, 0x0dd5, 0x0031, 0x0020,
+	0x080c, 0x7d79, 0x080c, 0x7d93, 0x0005, 0x0006, 0x0016, 0x0026,
+	0x080c, 0xea45, 0x7930, 0x9184, 0x0003, 0x01c0, 0x2001, 0x19f5,
+	0x2004, 0x9005, 0x0170, 0x2001, 0x0133, 0x2004, 0x9005, 0x090c,
+	0x0dd5, 0x00c6, 0x2001, 0x19f5, 0x2064, 0x080c, 0xc77b, 0x00ce,
+	0x00f8, 0x2009, 0x0040, 0x080c, 0x23df, 0x00d0, 0x9184, 0x0014,
+	0x01a0, 0x6a00, 0x9286, 0x0003, 0x0160, 0x080c, 0x73b3, 0x1138,
+	0x080c, 0x7699, 0x080c, 0x602d, 0x080c, 0x72e5, 0x0010, 0x080c,
+	0x5eec, 0x080c, 0x7e42, 0x0041, 0x0018, 0x9184, 0x9540, 0x1dc8,
+	0x002e, 0x001e, 0x000e, 0x0005, 0x00e6, 0x0036, 0x0046, 0x0056,
+	0x2071, 0x1a61, 0x080c, 0x1abb, 0x005e, 0x004e, 0x003e, 0x00ee,
+	0x0005, 0x0126, 0x2091, 0x2e00, 0x2071, 0x1800, 0x7128, 0x2001,
+	0x196e, 0x2102, 0x2001, 0x1976, 0x2102, 0x2001, 0x013b, 0x2102,
+	0x2079, 0x0200, 0x2001, 0x0201, 0x789e, 0x78a3, 0x0200, 0x9198,
+	0x0007, 0x831c, 0x831c, 0x831c, 0x9398, 0x0005, 0x2320, 0x9182,
+	0x0204, 0x1230, 0x2011, 0x0008, 0x8423, 0x8423, 0x8423, 0x0488,
+	0x9182, 0x024c, 0x1240, 0x2011, 0x0007, 0x8403, 0x8003, 0x9400,
+	0x9400, 0x9420, 0x0430, 0x9182, 0x02bc, 0x1238, 0x2011, 0x0006,
+	0x8403, 0x8003, 0x9400, 0x9420, 0x00e0, 0x9182, 0x034c, 0x1230,
+	0x2011, 0x0005, 0x8403, 0x8003, 0x9420, 0x0098, 0x9182, 0x042c,
+	0x1228, 0x2011, 0x0004, 0x8423, 0x8423, 0x0058, 0x9182, 0x059c,
+	0x1228, 0x2011, 0x0003, 0x8403, 0x9420, 0x0018, 0x2011, 0x0002,
+	0x8423, 0x9482, 0x0228, 0x8002, 0x8020, 0x8301, 0x9402, 0x0110,
+	0x0208, 0x8321, 0x8217, 0x8203, 0x9405, 0x789a, 0x012e, 0x0005,
+	0x0006, 0x00d6, 0x2069, 0x0200, 0x6814, 0x9084, 0xffc0, 0x910d,
+	0x6916, 0x00de, 0x000e, 0x0005, 0x00d6, 0x2069, 0x0200, 0x9005,
+	0x6810, 0x0110, 0xc0a5, 0x0008, 0xc0a4, 0x6812, 0x00de, 0x0005,
+	0x0006, 0x00d6, 0x2069, 0x0200, 0x6810, 0x9084, 0xfff8, 0x910d,
+	0x6912, 0x00de, 0x000e, 0x0005, 0x7938, 0x080c, 0x0dce, 0x00f6,
+	0x2079, 0x0200, 0x7902, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001,
+	0xa001, 0x7902, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001,
+	0x00fe, 0x0005, 0x0126, 0x2091, 0x2800, 0x2061, 0x0100, 0x2071,
+	0x1800, 0x2009, 0x0000, 0x080c, 0x2c4b, 0x080c, 0x2b66, 0x6054,
+	0x8004, 0x8004, 0x8004, 0x8004, 0x9084, 0x000c, 0x6150, 0x918c,
+	0xfff3, 0x9105, 0x6052, 0x6050, 0x9084, 0xb17f, 0x9085, 0x2000,
+	0x6052, 0x2009, 0x199c, 0x2011, 0x199d, 0x6358, 0x939c, 0x38f0,
+	0x2320, 0x080c, 0x2baa, 0x1238, 0x939d, 0x4003, 0x94a5, 0x8603,
+	0x230a, 0x2412, 0x0030, 0x939d, 0x0203, 0x94a5, 0x8603, 0x230a,
+	0x2412, 0x9006, 0x080c, 0x2b95, 0x9006, 0x080c, 0x2b78, 0x20a9,
+	0x0012, 0x1d04, 0x2431, 0x2091, 0x6000, 0x1f04, 0x2431, 0x602f,
+	0x0100, 0x602f, 0x0000, 0x6050, 0x9085, 0x0400, 0x9084, 0xdfff,
+	0x6052, 0x6024, 0x6026, 0x080c, 0x2884, 0x2009, 0x00ef, 0x6132,
+	0x6136, 0x080c, 0x2894, 0x60e7, 0x0000, 0x61ea, 0x60e3, 0x0008,
+	0x604b, 0xf7f7, 0x6043, 0x0000, 0x602f, 0x0080, 0x602f, 0x0000,
+	0x6007, 0x349f, 0x60bb, 0x0000, 0x20a9, 0x0018, 0x60bf, 0x0000,
+	0x1f04, 0x245e, 0x60bb, 0x0000, 0x60bf, 0x0108, 0x60bf, 0x0012,
+	0x60bf, 0x0405, 0x60bf, 0x0014, 0x60bf, 0x0320, 0x60bf, 0x0018,
+	0x601b, 0x00f0, 0x601f, 0x001e, 0x600f, 0x006b, 0x602b, 0x402f,
+	0x012e, 0x0005, 0x00f6, 0x2079, 0x0140, 0x78c3, 0x0080, 0x78c3,
+	0x0083, 0x78c3, 0x0000, 0x00fe, 0x0005, 0x2001, 0x1835, 0x2003,
+	0x0000, 0x2001, 0x1834, 0x2003, 0x0001, 0x0005, 0x0126, 0x2091,
+	0x2800, 0x0006, 0x0016, 0x0026, 0x6124, 0x0066, 0x2031, 0x1837,
+	0x2634, 0x96b4, 0x0028, 0x006e, 0x1138, 0x6020, 0xd1bc, 0x0120,
+	0xd0bc, 0x1168, 0xd0b4, 0x1198, 0x9184, 0x5e2c, 0x1118, 0x9184,
+	0x0007, 0x00aa, 0x9195, 0x0004, 0x9284, 0x0007, 0x0082, 0x0016,
+	0x2001, 0x188b, 0x200c, 0xd184, 0x001e, 0x0d70, 0x0c98, 0x0016,
+	0x2001, 0x188b, 0x200c, 0xd194, 0x001e, 0x0d30, 0x0c58, 0x24e1,
+	0x24c7, 0x24ca, 0x24cd, 0x24d2, 0x24d4, 0x24d8, 0x24dc, 0x080c,
+	0x8fdd, 0x00b8, 0x080c, 0x90aa, 0x00a0, 0x080c, 0x90aa, 0x080c,
+	0x8fdd, 0x0078, 0x0099, 0x0068, 0x080c, 0x8fdd, 0x0079, 0x0048,
+	0x080c, 0x90aa, 0x0059, 0x0028, 0x080c, 0x90aa, 0x080c, 0x8fdd,
+	0x0029, 0x002e, 0x001e, 0x000e, 0x012e, 0x0005, 0x00a6, 0x6124,
+	0x6028, 0xd09c, 0x0118, 0xd19c, 0x1904, 0x2749, 0xd1f4, 0x190c,
+	0x0dce, 0x080c, 0x73b3, 0x0904, 0x253c, 0x080c, 0xd25a, 0x1120,
+	0x7000, 0x9086, 0x0003, 0x0570, 0x6024, 0x9084, 0x1800, 0x0550,
+	0x080c, 0x73d6, 0x0118, 0x080c, 0x73c4, 0x1520, 0x6027, 0x0020,
+	0x6043, 0x0000, 0x080c, 0xd25a, 0x0168, 0x080c, 0x73d6, 0x1150,
+	0x2001, 0x19a6, 0x2003, 0x0001, 0x6027, 0x1800, 0x080c, 0x7249,
+	0x0804, 0x274c, 0x70a4, 0x9005, 0x1150, 0x70a7, 0x0001, 0x00d6,
+	0x2069, 0x0140, 0x080c, 0x740a, 0x00de, 0x1904, 0x274c, 0x080c,
+	0x76a3, 0x0428, 0x080c, 0x73d6, 0x1590, 0x6024, 0x9084, 0x1800,
+	0x1108, 0x0468, 0x080c, 0x76a3, 0x080c, 0x7699, 0x080c, 0x602d,
+	0x080c, 0x72e5, 0x0804, 0x2749, 0xd1ac, 0x1508, 0x6024, 0xd0dc,
+	0x1170, 0xd0e4, 0x1178, 0xd0d4, 0x1190, 0xd0cc, 0x0130, 0x7098,
+	0x9086, 0x0028, 0x1110, 0x080c, 0x7586, 0x0804, 0x2749, 0x080c,
+	0x769e, 0x0048, 0x2001, 0x197c, 0x2003, 0x0002, 0x0020, 0x080c,
+	0x74eb, 0x0804, 0x2749, 0x080c, 0x7621, 0x0804, 0x2749, 0x6220,
+	0xd1bc, 0x0138, 0xd2bc, 0x1904, 0x27bc, 0xd2b4, 0x1904, 0x27cf,
+	0x0000, 0xd1ac, 0x0904, 0x265e, 0x0036, 0x6328, 0xc3bc, 0x632a,
+	0x003e, 0x080c, 0x73b3, 0x11c0, 0x6027, 0x0020, 0x0006, 0x0026,
+	0x0036, 0x080c, 0x73cd, 0x1158, 0x080c, 0x7699, 0x080c, 0x602d,
+	0x080c, 0x72e5, 0x003e, 0x002e, 0x000e, 0x00ae, 0x0005, 0x003e,
+	0x002e, 0x000e, 0x080c, 0x738b, 0x0016, 0x0046, 0x00c6, 0x644c,
+	0x9486, 0xf0f0, 0x1138, 0x2061, 0x0100, 0x644a, 0x6043, 0x0090,
+	0x6043, 0x0010, 0x74da, 0x948c, 0xff00, 0x7038, 0xd084, 0x0178,
+	0x9186, 0xf800, 0x1160, 0x7048, 0xd084, 0x1148, 0xc085, 0x704a,
+	0x0036, 0x2418, 0x2011, 0x8016, 0x080c, 0x4b1e, 0x003e, 0x080c,
+	0xd253, 0x1904, 0x263b, 0x9196, 0xff00, 0x05a8, 0x7060, 0x9084,
+	0x00ff, 0x810f, 0x81ff, 0x0110, 0x9116, 0x0568, 0x7130, 0xd184,
+	0x1550, 0x080c, 0x3326, 0x0128, 0xc18d, 0x7132, 0x080c, 0x6981,
+	0x1510, 0x6240, 0x9294, 0x0010, 0x0130, 0x6248, 0x9294, 0xff00,
+	0x9296, 0xff00, 0x01c0, 0x7030, 0xd08c, 0x0904, 0x263b, 0x7038,
+	0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904, 0x263b,
+	0xc1ad, 0x2102, 0x0036, 0x73d8, 0x2011, 0x8013, 0x080c, 0x4b1e,
+	0x003e, 0x0804, 0x263b, 0x7038, 0xd08c, 0x1140, 0x2001, 0x180c,
+	0x200c, 0xd1ac, 0x1904, 0x263b, 0xc1ad, 0x2102, 0x0036, 0x73d8,
+	0x2011, 0x8013, 0x080c, 0x4b1e, 0x003e, 0x7130, 0xc185, 0x7132,
+	0x2011, 0x1848, 0x220c, 0xd1a4, 0x01f0, 0x0016, 0x2009, 0x0001,
+	0x2011, 0x0100, 0x080c, 0x86e3, 0x2019, 0x000e, 0x00c6, 0x2061,
+	0x0000, 0x080c, 0xe55d, 0x00ce, 0x9484, 0x00ff, 0x9080, 0x3332,
+	0x200d, 0x918c, 0xff00, 0x810f, 0x2120, 0x9006, 0x2009, 0x000e,
+	0x080c, 0xe5e9, 0x001e, 0x0016, 0x2009, 0x0002, 0x2019, 0x0004,
+	0x080c, 0x3197, 0x001e, 0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f,
+	0x900e, 0x080c, 0x6616, 0x1110, 0x080c, 0x6047, 0x8108, 0x1f04,
+	0x2631, 0x00be, 0x015e, 0x00ce, 0x004e, 0x080c, 0xadd0, 0x60e3,
+	0x0000, 0x001e, 0x2001, 0x1800, 0x2014, 0x9296, 0x0004, 0x1170,
+	0xd19c, 0x11a0, 0x2011, 0x180c, 0x2214, 0xd29c, 0x1120, 0x6204,
+	0x9295, 0x0002, 0x6206, 0x6228, 0xc29d, 0x622a, 0x2003, 0x0001,
+	0x2001, 0x1826, 0x2003, 0x0000, 0x6027, 0x0020, 0xd194, 0x0904,
+	0x2749, 0x0016, 0x6220, 0xd2b4, 0x0904, 0x26e6, 0x080c, 0x857f,
+	0x080c, 0xa28f, 0x6027, 0x0004, 0x00f6, 0x2019, 0x19ef, 0x2304,
+	0x907d, 0x0904, 0x26b5, 0x7804, 0x9086, 0x0032, 0x15f0, 0x00d6,
+	0x00c6, 0x00e6, 0x0096, 0x2069, 0x0140, 0x782c, 0x685e, 0x7808,
+	0x685a, 0x6043, 0x0002, 0x2001, 0x0003, 0x8001, 0x1df0, 0x6043,
+	0x0000, 0x2001, 0x003c, 0x8001, 0x1df0, 0x080c, 0x2d0c, 0x2001,
+	0x001e, 0x8001, 0x0240, 0x20a9, 0x0009, 0x080c, 0x2c26, 0x6904,
+	0xd1dc, 0x1140, 0x0cb0, 0x2001, 0x0100, 0x080c, 0x2cfc, 0x9006,
+	0x080c, 0x2cfc, 0x080c, 0x959a, 0x080c, 0x96a6, 0x7814, 0x2048,
+	0xa867, 0x0103, 0x2f60, 0x080c, 0xae5f, 0x009e, 0x00ee, 0x00ce,
+	0x00de, 0x00fe, 0x001e, 0x00ae, 0x0005, 0x00fe, 0x00d6, 0x2069,
+	0x0140, 0x6804, 0x9084, 0x4000, 0x0110, 0x080c, 0x2d0c, 0x00de,
+	0x00c6, 0x2061, 0x19e6, 0x6028, 0x080c, 0xd25a, 0x0120, 0x909a,
+	0x0003, 0x1258, 0x0018, 0x909a, 0x00c8, 0x1238, 0x8000, 0x602a,
+	0x00ce, 0x080c, 0xa26b, 0x0804, 0x2748, 0x2061, 0x0100, 0x62c0,
+	0x080c, 0xac56, 0x2019, 0x19ef, 0x2304, 0x9065, 0x0120, 0x2009,
+	0x0027, 0x080c, 0xaeda, 0x00ce, 0x0804, 0x2748, 0xd2bc, 0x0904,
+	0x272f, 0x080c, 0x858c, 0x6014, 0x9084, 0x1984, 0x9085, 0x0010,
+	0x6016, 0x6027, 0x0004, 0x00d6, 0x2069, 0x0140, 0x6804, 0x9084,
+	0x4000, 0x0110, 0x080c, 0x2d0c, 0x00de, 0x00c6, 0x2061, 0x19e6,
+	0x6044, 0x080c, 0xd25a, 0x0120, 0x909a, 0x0003, 0x1658, 0x0018,
+	0x909a, 0x00c8, 0x1638, 0x8000, 0x6046, 0x603c, 0x00ce, 0x9005,
+	0x05b8, 0x2009, 0x07d0, 0x080c, 0x8584, 0x9080, 0x0008, 0x2004,
+	0x9086, 0x0006, 0x1138, 0x6114, 0x918c, 0x1984, 0x918d, 0x0012,
+	0x6116, 0x0430, 0x9080, 0x0008, 0x2004, 0x9086, 0x0009, 0x0d98,
+	0x6114, 0x918c, 0x1984, 0x918d, 0x0016, 0x6116, 0x00c8, 0x6027,
+	0x0004, 0x00b0, 0x0036, 0x2019, 0x0001, 0x080c, 0xa5c8, 0x003e,
+	0x2019, 0x19f5, 0x2304, 0x9065, 0x0150, 0x2009, 0x004f, 0x6020,
+	0x9086, 0x0009, 0x1110, 0x2009, 0x004f, 0x080c, 0xaeda, 0x00ce,
+	0x001e, 0xd19c, 0x0904, 0x27b7, 0x7038, 0xd0ac, 0x1904, 0x2790,
+	0x0016, 0x0156, 0x6027, 0x0008, 0x6050, 0x9085, 0x0040, 0x6052,
+	0x6050, 0x9084, 0xfbcf, 0x6052, 0x080c, 0x2c45, 0x9085, 0x2000,
+	0x6052, 0x20a9, 0x0012, 0x1d04, 0x2763, 0x080c, 0x85b3, 0x1f04,
+	0x2763, 0x6050, 0x9085, 0x0400, 0x9084, 0xdfbf, 0x6052, 0x20a9,
+	0x0028, 0xa001, 0x1f04, 0x2771, 0x6150, 0x9185, 0x1400, 0x6052,
+	0x20a9, 0x0366, 0x1d04, 0x277a, 0x080c, 0x85b3, 0x6020, 0xd09c,
+	0x1130, 0x015e, 0x6152, 0x001e, 0x6027, 0x0008, 0x0480, 0x080c,
+	0x2c0d, 0x1f04, 0x277a, 0x015e, 0x6152, 0x001e, 0x6027, 0x0008,
+	0x0016, 0x6028, 0xc09c, 0x602a, 0x080c, 0xadd0, 0x60e3, 0x0000,
+	0x080c, 0xea24, 0x080c, 0xea3f, 0x080c, 0x56e6, 0xd0fc, 0x1138,
+	0x080c, 0xd253, 0x1120, 0x9085, 0x0001, 0x080c, 0x73fa, 0x9006,
+	0x080c, 0x2cfc, 0x2009, 0x0002, 0x080c, 0x2c4b, 0x2001, 0x1800,
+	0x2003, 0x0004, 0x6027, 0x0008, 0x080c, 0x0bae, 0x001e, 0x918c,
+	0xffd0, 0x6126, 0x00ae, 0x0005, 0x0016, 0x2001, 0x188b, 0x200c,
+	0xd184, 0x001e, 0x0904, 0x2569, 0x0016, 0x2009, 0x27c8, 0x00d0,
+	0x2001, 0x188b, 0x200c, 0xc184, 0x2102, 0x001e, 0x0c40, 0x0016,
+	0x2001, 0x188b, 0x200c, 0xd194, 0x001e, 0x0904, 0x2569, 0x0016,
+	0x2009, 0x27db, 0x0038, 0x2001, 0x188b, 0x200c, 0xc194, 0x2102,
+	0x001e, 0x08a8, 0x6028, 0xc0bc, 0x602a, 0x2001, 0x0156, 0x2003,
+	0xbc91, 0x8000, 0x2003, 0xffff, 0x6043, 0x0001, 0x080c, 0x2c45,
+	0x6027, 0x0080, 0x6017, 0x0000, 0x6043, 0x0000, 0x0817, 0x0006,
+	0x0016, 0x0026, 0x0036, 0x00e6, 0x00f6, 0x0126, 0x2091, 0x8000,
+	0x2071, 0x1800, 0x71d0, 0x70d2, 0x9116, 0x05e8, 0x81ff, 0x01a0,
+	0x2009, 0x0000, 0x080c, 0x2c4b, 0x2011, 0x8011, 0x2019, 0x010e,
+	0x231c, 0x939e, 0x0007, 0x1118, 0x2019, 0x0001, 0x0010, 0x2019,
+	0x0000, 0x080c, 0x4b1e, 0x0438, 0x2001, 0x19a7, 0x200c, 0x81ff,
+	0x1140, 0x2001, 0x0109, 0x2004, 0xd0b4, 0x0118, 0x2019, 0x0003,
+	0x0008, 0x2118, 0x2011, 0x8012, 0x080c, 0x4b1e, 0x080c, 0x56e6,
+	0xd0fc, 0x1188, 0x080c, 0xd253, 0x1170, 0x00c6, 0x080c, 0x28df,
+	0x080c, 0xa52f, 0x2061, 0x0100, 0x2019, 0x0028, 0x2009, 0x0002,
+	0x080c, 0x3197, 0x00ce, 0x012e, 0x00fe, 0x00ee, 0x003e, 0x002e,
+	0x001e, 0x000e, 0x0005, 0x2028, 0x918c, 0x00ff, 0x2130, 0x9094,
+	0xff00, 0x11f0, 0x2011, 0x1837, 0x2214, 0xd2ac, 0x11c8, 0x81ff,
+	0x01e8, 0x2011, 0x181f, 0x2204, 0x9106, 0x1190, 0x2011, 0x1820,
+	0x2214, 0x9294, 0xff00, 0x9584, 0xff00, 0x9206, 0x1148, 0x2011,
+	0x1820, 0x2214, 0x9294, 0x00ff, 0x9584, 0x00ff, 0x9206, 0x1120,
+	0x2500, 0x080c, 0x80b4, 0x0048, 0x9584, 0x00ff, 0x9080, 0x3332,
+	0x200d, 0x918c, 0xff00, 0x810f, 0x9006, 0x0005, 0x9080, 0x3332,
+	0x200d, 0x918c, 0x00ff, 0x0005, 0x00d6, 0x2069, 0x0140, 0x2001,
+	0x1818, 0x2003, 0x00ef, 0x20a9, 0x0010, 0x9006, 0x6852, 0x6856,
+	0x1f04, 0x288f, 0x00de, 0x0005, 0x0006, 0x00d6, 0x0026, 0x2069,
+	0x0140, 0x2001, 0x1818, 0x2102, 0x8114, 0x8214, 0x8214, 0x8214,
+	0x20a9, 0x0010, 0x6853, 0x0000, 0x9006, 0x82ff, 0x1128, 0x9184,
+	0x000f, 0x9080, 0xf1f1, 0x2005, 0x6856, 0x8211, 0x1f04, 0x28a4,
+	0x002e, 0x00de, 0x000e, 0x0005, 0x00c6, 0x2061, 0x1800, 0x6030,
+	0x0110, 0xc09d, 0x0008, 0xc09c, 0x6032, 0x00ce, 0x0005, 0x0156,
+	0x00d6, 0x0026, 0x0016, 0x0006, 0x2069, 0x0140, 0x6980, 0x9116,
+	0x0180, 0x9112, 0x1230, 0x8212, 0x8210, 0x22a8, 0x2001, 0x0402,
+	0x0018, 0x22a8, 0x2001, 0x0404, 0x680e, 0x1f04, 0x28d4, 0x680f,
+	0x0000, 0x000e, 0x001e, 0x002e, 0x00de, 0x015e, 0x0005, 0x080c,
+	0x56e2, 0xd0c4, 0x0150, 0xd0a4, 0x0140, 0x9006, 0x0046, 0x2020,
+	0x2009, 0x002e, 0x080c, 0xe5e9, 0x004e, 0x0005, 0x00f6, 0x0016,
+	0x0026, 0x2079, 0x0140, 0x78c4, 0xd0dc, 0x0904, 0x294b, 0x080c,
+	0x2baa, 0x0660, 0x9084, 0x0700, 0x908e, 0x0600, 0x1120, 0x2011,
+	0x4000, 0x900e, 0x0458, 0x908e, 0x0500, 0x1120, 0x2011, 0x8000,
+	0x900e, 0x0420, 0x908e, 0x0400, 0x1120, 0x9016, 0x2009, 0x0001,
+	0x00e8, 0x908e, 0x0300, 0x1120, 0x9016, 0x2009, 0x0002, 0x00b0,
+	0x908e, 0x0200, 0x1120, 0x9016, 0x2009, 0x0004, 0x0078, 0x908e,
+	0x0100, 0x1548, 0x9016, 0x2009, 0x0008, 0x0040, 0x9084, 0x0700,
+	0x908e, 0x0300, 0x1500, 0x2011, 0x0030, 0x0058, 0x2300, 0x9080,
+	0x0020, 0x2018, 0x080c, 0x8f70, 0x928c, 0xff00, 0x0110, 0x2011,
+	0x00ff, 0x2200, 0x8007, 0x9085, 0x004c, 0x78c2, 0x2009, 0x0138,
+	0x220a, 0x080c, 0x73b3, 0x1118, 0x2009, 0x196c, 0x220a, 0x002e,
+	0x001e, 0x00fe, 0x0005, 0x78c3, 0x0000, 0x0cc8, 0x0126, 0x2091,
+	0x2800, 0x0006, 0x0016, 0x0026, 0x2001, 0x0170, 0x200c, 0x8000,
+	0x2014, 0x9184, 0x0003, 0x0110, 0x080c, 0x0dce, 0x002e, 0x001e,
+	0x000e, 0x012e, 0x0005, 0x2001, 0x0171, 0x2004, 0xd0dc, 0x0168,
+	0x2001, 0x0170, 0x200c, 0x918c, 0x00ff, 0x918e, 0x004c, 0x1128,
+	0x200c, 0x918c, 0xff00, 0x810f, 0x0005, 0x900e, 0x2001, 0x0227,
+	0x2004, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9108, 0x2001, 0x0226,
+	0x2004, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9108, 0x0005, 0x0018,
+	0x000c, 0x0018, 0x0020, 0x1000, 0x0800, 0x1000, 0x1800, 0x0156,
+	0x0006, 0x0016, 0x0026, 0x00e6, 0x2001, 0x198f, 0x2004, 0x908a,
+	0x0007, 0x1a0c, 0x0dd5, 0x0033, 0x00ee, 0x002e, 0x001e, 0x000e,
+	0x015e, 0x0005, 0x29a9, 0x29c7, 0x29eb, 0x29ed, 0x2a16, 0x2a18,
+	0x2a1a, 0x2001, 0x0001, 0x080c, 0x27f7, 0x080c, 0x2c08, 0x2001,
+	0x1991, 0x2003, 0x0000, 0x7828, 0x9084, 0xe1d7, 0x782a, 0x9006,
+	0x20a9, 0x0009, 0x080c, 0x2bc6, 0x2001, 0x198f, 0x2003, 0x0006,
+	0x2009, 0x001e, 0x2011, 0x2a1b, 0x080c, 0x8591, 0x0005, 0x2009,
+	0x1994, 0x200b, 0x0000, 0x2001, 0x1999, 0x2003, 0x0036, 0x2001,
+	0x1998, 0x2003, 0x002a, 0x2001, 0x1991, 0x2003, 0x0001, 0x9006,
+	0x080c, 0x2b78, 0x2001, 0xffff, 0x20a9, 0x0009, 0x080c, 0x2bc6,
+	0x2001, 0x198f, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x2a1b,
+	0x080c, 0x8591, 0x0005, 0x080c, 0x0dd5, 0x2001, 0x1999, 0x2003,
+	0x0036, 0x2001, 0x1991, 0x2003, 0x0003, 0x7a38, 0x9294, 0x0005,
+	0x9296, 0x0004, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c,
+	0x2b78, 0x2001, 0x1995, 0x2003, 0x0000, 0x2001, 0xffff, 0x20a9,
+	0x0009, 0x080c, 0x2bc6, 0x2001, 0x198f, 0x2003, 0x0006, 0x2009,
+	0x001e, 0x2011, 0x2a1b, 0x080c, 0x8591, 0x0005, 0x080c, 0x0dd5,
+	0x080c, 0x0dd5, 0x0005, 0x0006, 0x0016, 0x0026, 0x00e6, 0x00f6,
+	0x0156, 0x0126, 0x2091, 0x8000, 0x2079, 0x0100, 0x2001, 0x1991,
+	0x2004, 0x908a, 0x0007, 0x1a0c, 0x0dd5, 0x0043, 0x012e, 0x015e,
+	0x00fe, 0x00ee, 0x002e, 0x001e, 0x000e, 0x0005, 0x2a3d, 0x2a5d,
+	0x2a9d, 0x2acd, 0x2af1, 0x2b01, 0x2b03, 0x080c, 0x2bba, 0x11b0,
+	0x7850, 0x9084, 0xefff, 0x7852, 0x2009, 0x1997, 0x2104, 0x7a38,
+	0x9294, 0x0005, 0x9296, 0x0004, 0x0110, 0xc08d, 0x0008, 0xc085,
+	0x200a, 0x2001, 0x198f, 0x2003, 0x0001, 0x0030, 0x080c, 0x2b27,
+	0x2001, 0xffff, 0x080c, 0x29b8, 0x0005, 0x080c, 0x2b05, 0x05e0,
+	0x2009, 0x1998, 0x2104, 0x8001, 0x200a, 0x080c, 0x2bba, 0x1178,
+	0x7850, 0x9084, 0xefff, 0x7852, 0x7a38, 0x9294, 0x0005, 0x9296,
+	0x0005, 0x0518, 0x2009, 0x1997, 0x2104, 0xc085, 0x200a, 0x2009,
+	0x1994, 0x2104, 0x8000, 0x200a, 0x9086, 0x0005, 0x0118, 0x080c,
+	0x2b0d, 0x00c0, 0x200b, 0x0000, 0x7a38, 0x9294, 0x0006, 0x9296,
+	0x0004, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x2b95,
+	0x2001, 0x1991, 0x2003, 0x0002, 0x0028, 0x2001, 0x198f, 0x2003,
+	0x0003, 0x0010, 0x080c, 0x29da, 0x0005, 0x080c, 0x2b05, 0x0560,
+	0x2009, 0x1998, 0x2104, 0x8001, 0x200a, 0x080c, 0x2bba, 0x1168,
+	0x7850, 0x9084, 0xefff, 0x7852, 0x2001, 0x198f, 0x2003, 0x0003,
+	0x2001, 0x1990, 0x2003, 0x0000, 0x00b8, 0x2009, 0x1998, 0x2104,
+	0x9005, 0x1118, 0x080c, 0x2b4a, 0x0010, 0x080c, 0x2b1a, 0x080c,
+	0x2b0d, 0x2009, 0x1994, 0x200b, 0x0000, 0x2001, 0x1991, 0x2003,
+	0x0001, 0x080c, 0x29da, 0x0000, 0x0005, 0x04b9, 0x0508, 0x080c,
+	0x2bba, 0x11b8, 0x7850, 0x9084, 0xefff, 0x7852, 0x2009, 0x1995,
+	0x2104, 0x8000, 0x200a, 0x9086, 0x0007, 0x0108, 0x0078, 0x2001,
+	0x199a, 0x2003, 0x000a, 0x2009, 0x1997, 0x2104, 0xc0fd, 0x200a,
+	0x0038, 0x0419, 0x2001, 0x1991, 0x2003, 0x0004, 0x080c, 0x2a05,
+	0x0005, 0x0099, 0x0168, 0x080c, 0x2bba, 0x1138, 0x7850, 0x9084,
+	0xefff, 0x7852, 0x080c, 0x29f1, 0x0018, 0x0079, 0x080c, 0x2a05,
+	0x0005, 0x080c, 0x0dd5, 0x080c, 0x0dd5, 0x2009, 0x1999, 0x2104,
+	0x8001, 0x200a, 0x090c, 0x2b66, 0x0005, 0x7a38, 0x9294, 0x0005,
+	0x9296, 0x0005, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c,
+	0x2b95, 0x0005, 0x7a38, 0x9294, 0x0006, 0x9296, 0x0006, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x2b78, 0x0005, 0x2009,
+	0x1994, 0x2104, 0x8000, 0x200a, 0x9086, 0x0005, 0x0108, 0x0068,
+	0x200b, 0x0000, 0x7a38, 0x9294, 0x0006, 0x9296, 0x0006, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x04d9, 0x7a38, 0x9294, 0x0005,
+	0x9296, 0x0005, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c,
+	0x2b95, 0x0005, 0x0086, 0x2001, 0x1997, 0x2004, 0x9084, 0x7fff,
+	0x090c, 0x0dd5, 0x2009, 0x1996, 0x2144, 0x8846, 0x280a, 0x9844,
+	0x0dd8, 0xd08c, 0x1120, 0xd084, 0x1120, 0x080c, 0x0dd5, 0x9006,
+	0x0010, 0x2001, 0x0001, 0x00a1, 0x008e, 0x0005, 0x0006, 0x0156,
+	0x2001, 0x198f, 0x20a9, 0x0009, 0x2003, 0x0000, 0x8000, 0x1f04,
+	0x2b6c, 0x2001, 0x1996, 0x2003, 0x8000, 0x015e, 0x000e, 0x0005,
+	0x00f6, 0x2079, 0x0100, 0x9085, 0x0000, 0x0158, 0x7838, 0x9084,
+	0xfff9, 0x9085, 0x0004, 0x783a, 0x2009, 0x199c, 0x210c, 0x795a,
+	0x0050, 0x7838, 0x9084, 0xfffb, 0x9085, 0x0006, 0x783a, 0x2009,
+	0x199d, 0x210c, 0x795a, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100,
+	0x9085, 0x0000, 0x0138, 0x7838, 0x9084, 0xfffa, 0x9085, 0x0004,
+	0x783a, 0x0030, 0x7838, 0x9084, 0xfffb, 0x9085, 0x0005, 0x783a,
+	0x00fe, 0x0005, 0x0006, 0x2001, 0x0100, 0x2004, 0x9082, 0x0007,
+	0x000e, 0x0005, 0x0006, 0x2001, 0x0100, 0x2004, 0x9082, 0x0009,
+	0x000e, 0x0005, 0x0156, 0x20a9, 0x0064, 0x7820, 0x080c, 0x2c45,
+	0xd09c, 0x1110, 0x1f04, 0x2bbd, 0x015e, 0x0005, 0x0126, 0x0016,
+	0x0006, 0x2091, 0x8000, 0x7850, 0x9085, 0x0040, 0x7852, 0x7850,
+	0x9084, 0xfbcf, 0x7852, 0x080c, 0x2c45, 0x9085, 0x2000, 0x7852,
+	0x000e, 0x2008, 0x9186, 0x0000, 0x1118, 0x783b, 0x0007, 0x0090,
+	0x9186, 0x0001, 0x1118, 0x783b, 0x0006, 0x0060, 0x9186, 0x0002,
+	0x1118, 0x783b, 0x0005, 0x0030, 0x9186, 0x0003, 0x1118, 0x783b,
+	0x0004, 0x0000, 0x0006, 0x1d04, 0x2bf3, 0x080c, 0x85b3, 0x1f04,
+	0x2bf3, 0x7850, 0x9085, 0x0400, 0x9084, 0xdfbf, 0x7852, 0x080c,
+	0x2c45, 0x9085, 0x1000, 0x7852, 0x000e, 0x001e, 0x012e, 0x0005,
+	0x7850, 0x9084, 0xffcf, 0x7852, 0x0005, 0x0006, 0x0156, 0x00f6,
+	0x2079, 0x0100, 0x20a9, 0x000a, 0x7854, 0xd0ac, 0x1130, 0x7820,
+	0xd0e4, 0x1140, 0x1f04, 0x2c17, 0x0028, 0x7854, 0xd08c, 0x1110,
+	0x1f04, 0x2c1d, 0x00fe, 0x015e, 0x000e, 0x0005, 0x1d04, 0x2c26,
+	0x080c, 0x85b3, 0x1f04, 0x2c26, 0x0005, 0x0006, 0x2001, 0x199b,
+	0x2004, 0x9086, 0x0000, 0x000e, 0x0005, 0x0006, 0x2001, 0x199b,
+	0x2004, 0x9086, 0x0001, 0x000e, 0x0005, 0x0006, 0x2001, 0x199b,
+	0x2004, 0x9086, 0x0002, 0x000e, 0x0005, 0xa001, 0xa001, 0xa001,
+	0xa001, 0xa001, 0x0005, 0x0006, 0x2001, 0x19a7, 0x2102, 0x000e,
+	0x0005, 0x2009, 0x0171, 0x2104, 0xd0dc, 0x0140, 0x2009, 0x0170,
+	0x2104, 0x200b, 0x0080, 0xa001, 0xa001, 0x200a, 0x0005, 0x0036,
+	0x0046, 0x2001, 0x0141, 0x200c, 0x918c, 0xff00, 0x9186, 0x2000,
+	0x0118, 0x9186, 0x0100, 0x1588, 0x2009, 0x00a2, 0x080c, 0x0e51,
+	0x2019, 0x0160, 0x2324, 0x2011, 0x0003, 0x2009, 0x0169, 0x2104,
+	0x9084, 0x0007, 0x210c, 0x918c, 0x0007, 0x910e, 0x1db0, 0x9086,
+	0x0003, 0x11b8, 0x2304, 0x9402, 0x02a0, 0x1d60, 0x8211, 0x1d68,
+	0x84ff, 0x0170, 0x2001, 0x0141, 0x200c, 0x918c, 0xff00, 0x9186,
+	0x0100, 0x0130, 0x2009, 0x180c, 0x2104, 0xc0dd, 0x200a, 0x0008,
+	0x0419, 0x2009, 0x0000, 0x080c, 0x0e51, 0x004e, 0x003e, 0x0005,
+	0x2001, 0x180c, 0x2004, 0xd0dc, 0x01b0, 0x2001, 0x0160, 0x2004,
+	0x9005, 0x0140, 0x2001, 0x0141, 0x2004, 0x9084, 0xff00, 0x9086,
+	0x0100, 0x1148, 0x0126, 0x2091, 0x8000, 0x0016, 0x0026, 0x0021,
+	0x002e, 0x001e, 0x012e, 0x0005, 0x00c6, 0x2061, 0x0100, 0x6014,
+	0x0006, 0x2001, 0x0161, 0x2003, 0x0000, 0x6017, 0x0018, 0xa001,
+	0xa001, 0x602f, 0x0008, 0x6104, 0x918e, 0x0010, 0x6106, 0x918e,
+	0x0010, 0x6106, 0x6017, 0x0040, 0x04b9, 0x001e, 0x9184, 0x0003,
+	0x01e0, 0x0036, 0x0016, 0x2019, 0x0141, 0x6124, 0x918c, 0x0028,
+	0x1120, 0x2304, 0x9084, 0x2800, 0x0dc0, 0x001e, 0x919c, 0xffe4,
+	0x9184, 0x0001, 0x0118, 0x9385, 0x0009, 0x6016, 0x9184, 0x0002,
+	0x0118, 0x9385, 0x0012, 0x6016, 0x003e, 0x2001, 0x180c, 0x200c,
+	0xc1dc, 0x2102, 0x00ce, 0x0005, 0x0016, 0x0026, 0x080c, 0x73cd,
+	0x0108, 0xc0bc, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001, 0x9215,
+	0x220a, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026, 0x2009, 0x0140,
+	0x2114, 0x9294, 0x0001, 0x9285, 0x1000, 0x200a, 0x220a, 0x002e,
+	0x001e, 0x0005, 0x0016, 0x0026, 0x2009, 0x0140, 0x2114, 0x9294,
+	0x0001, 0x9215, 0x220a, 0x002e, 0x001e, 0x0005, 0x0006, 0x0016,
+	0x2009, 0x0140, 0x2104, 0x1128, 0x080c, 0x73cd, 0x0110, 0xc0bc,
+	0x0008, 0xc0bd, 0x200a, 0x001e, 0x000e, 0x0005, 0x2fa2, 0x2fa2,
+	0x2dc6, 0x2dc6, 0x2dd2, 0x2dd2, 0x2dde, 0x2dde, 0x2dec, 0x2dec,
+	0x2df8, 0x2df8, 0x2e06, 0x2e06, 0x2e14, 0x2e14, 0x2e26, 0x2e26,
+	0x2e32, 0x2e32, 0x2e40, 0x2e40, 0x2e5e, 0x2e5e, 0x2e7e, 0x2e7e,
+	0x2e4e, 0x2e4e, 0x2e6e, 0x2e6e, 0x2e8c, 0x2e8c, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e9e, 0x2e9e,
+	0x2eaa, 0x2eaa, 0x2eb8, 0x2eb8, 0x2ec6, 0x2ec6, 0x2ed6, 0x2ed6,
+	0x2ee4, 0x2ee4, 0x2ef4, 0x2ef4, 0x2f04, 0x2f04, 0x2f16, 0x2f16,
+	0x2f24, 0x2f24, 0x2f34, 0x2f34, 0x2f56, 0x2f56, 0x2f78, 0x2f78,
+	0x2f44, 0x2f44, 0x2f67, 0x2f67, 0x2f87, 0x2f87, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24,
+	0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x2e24, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x248e,
+	0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x22a2, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x22a2,
+	0x080c, 0x248e, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x22dd, 0x0804, 0x2f9a,
+	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
+	0x080c, 0x248e, 0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x22a2,
+	0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x22a2, 0x080c, 0x248e,
+	0x080c, 0x22dd, 0x0804, 0x2f9a, 0xa001, 0x0cf0, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1380,
+	0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x248e, 0x080c, 0x1380, 0x0804, 0x2f9a,
+	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
+	0x080c, 0x22a2, 0x080c, 0x1380, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x248e,
+	0x080c, 0x1380, 0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x22a2,
+	0x080c, 0x248e, 0x080c, 0x1380, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x22a2,
+	0x080c, 0x1380, 0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1380,
+	0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x22a2, 0x080c, 0x248e,
+	0x080c, 0x1380, 0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e,
+	0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x294e, 0x080c, 0x248e, 0x0804, 0x2f9a,
+	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
+	0x080c, 0x294e, 0x080c, 0x22a2, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e,
+	0x080c, 0x22a2, 0x080c, 0x248e, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e,
+	0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e, 0x080c, 0x248e,
+	0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e, 0x080c, 0x22a2,
+	0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e, 0x080c, 0x22a2,
+	0x080c, 0x248e, 0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e,
+	0x080c, 0x1380, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e, 0x080c, 0x248e,
+	0x080c, 0x1380, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e, 0x080c, 0x22a2,
+	0x080c, 0x1380, 0x0804, 0x2f9a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e, 0x080c, 0x248e,
+	0x080c, 0x1380, 0x080c, 0x22dd, 0x0804, 0x2f9a, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x294e,
+	0x080c, 0x22a2, 0x080c, 0x248e, 0x080c, 0x1380, 0x0498, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2483, 0x080c, 0x1380, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2297, 0x080c,
-	0x1380, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2483, 0x080c, 0x1380, 0x080c,
-	0x22d2, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2297, 0x080c, 0x2483, 0x080c,
-	0x1380, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2297, 0x080c, 0x1380, 0x080c,
-	0x22d2, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x1380, 0x080c, 0x22d2, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2297, 0x080c, 0x2483, 0x080c, 0x1380, 0x080c,
-	0x22d2, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x0804, 0x2f8f, 0x0106,
+	0x294e, 0x080c, 0x22a2, 0x080c, 0x1380, 0x080c, 0x22dd, 0x0410,
+	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
+	0x080c, 0x294e, 0x080c, 0x1380, 0x080c, 0x22dd, 0x0098, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2943, 0x080c, 0x2483, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x080c,
-	0x2297, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x080c, 0x2297, 0x080c,
-	0x2483, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x080c, 0x22d2, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2943, 0x080c, 0x2483, 0x080c, 0x22d2, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2943, 0x080c, 0x2297, 0x080c, 0x22d2, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2943, 0x080c, 0x2297, 0x080c, 0x2483, 0x080c,
-	0x22d2, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x080c, 0x1380, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2943, 0x080c, 0x2483, 0x080c, 0x1380, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2943, 0x080c, 0x2297, 0x080c, 0x1380, 0x0804,
-	0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2943, 0x080c, 0x2483, 0x080c, 0x1380, 0x080c,
-	0x22d2, 0x0804, 0x2f8f, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x080c, 0x2297, 0x080c,
-	0x2483, 0x080c, 0x1380, 0x0498, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x080c, 0x2297,
-	0x080c, 0x1380, 0x080c, 0x22d2, 0x0410, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x080c,
-	0x1380, 0x080c, 0x22d2, 0x0098, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2943, 0x080c, 0x2297,
-	0x080c, 0x2483, 0x080c, 0x1380, 0x080c, 0x22d2, 0x0000, 0x015e,
-	0x014e, 0x013e, 0x01de, 0x01ce, 0x012e, 0x000e, 0x010e, 0x000d,
-	0x00b6, 0x00c6, 0x0026, 0x0046, 0x9026, 0x080c, 0x6939, 0x1904,
-	0x30a8, 0x72dc, 0x2001, 0x197b, 0x2004, 0x9005, 0x1110, 0xd29c,
-	0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904, 0x30a8, 0x080c, 0x30ad,
-	0x0804, 0x30a8, 0xd2cc, 0x1904, 0x30a8, 0x080c, 0x73a5, 0x1120,
-	0x70af, 0xffff, 0x0804, 0x30a8, 0xd294, 0x0120, 0x70af, 0xffff,
-	0x0804, 0x30a8, 0x080c, 0x3316, 0x0160, 0x080c, 0xd24a, 0x0128,
-	0x2001, 0x1818, 0x203c, 0x0804, 0x3035, 0x70af, 0xffff, 0x0804,
-	0x30a8, 0x2001, 0x1818, 0x203c, 0x7294, 0xd284, 0x0904, 0x3035,
-	0xd28c, 0x1904, 0x3035, 0x0036, 0x73ac, 0x938e, 0xffff, 0x1110,
-	0x2019, 0x0001, 0x8314, 0x92e0, 0x1c80, 0x2c04, 0x938c, 0x0001,
-	0x0120, 0x9084, 0xff00, 0x8007, 0x0010, 0x9084, 0x00ff, 0x970e,
-	0x05d0, 0x908e, 0x0000, 0x05b8, 0x908e, 0x00ff, 0x1150, 0x7230,
-	0xd284, 0x15b0, 0x7294, 0xc28d, 0x7296, 0x70af, 0xffff, 0x003e,
-	0x04a0, 0x900e, 0x080c, 0x2840, 0x080c, 0x65a7, 0x1538, 0x9006,
-	0xb8bb, 0x0520, 0xb8ac, 0x9005, 0x0148, 0x00c6, 0x2060, 0x080c,
-	0x896a, 0x00ce, 0x090c, 0x8d0e, 0xb8af, 0x0000, 0x080c, 0x697b,
-	0x1168, 0x7030, 0xd08c, 0x0130, 0xb800, 0xd0bc, 0x0138, 0x080c,
-	0x6828, 0x0120, 0x080c, 0x30c6, 0x0148, 0x0028, 0x080c, 0x3206,
-	0x080c, 0x30f2, 0x0118, 0x8318, 0x0804, 0x2fe2, 0x73ae, 0x0010,
-	0x70af, 0xffff, 0x003e, 0x0804, 0x30a8, 0x9780, 0x3327, 0x203d,
-	0x97bc, 0xff00, 0x873f, 0x2041, 0x007e, 0x70ac, 0x9096, 0xffff,
-	0x1118, 0x900e, 0x28a8, 0x0050, 0x9812, 0x0220, 0x2008, 0x9802,
-	0x20a8, 0x0020, 0x70af, 0xffff, 0x0804, 0x30a8, 0x2700, 0x0156,
-	0x0016, 0x9106, 0x0904, 0x309d, 0xc484, 0x080c, 0x6608, 0x0148,
-	0x080c, 0xd24a, 0x1904, 0x309d, 0x080c, 0x65a7, 0x1904, 0x30a5,
-	0x0008, 0xc485, 0xb8bb, 0x0520, 0xb8ac, 0x9005, 0x0148, 0x00c6,
-	0x2060, 0x080c, 0x896a, 0x00ce, 0x090c, 0x8d0e, 0xb8af, 0x0000,
-	0x080c, 0x697b, 0x1130, 0x7030, 0xd08c, 0x01f8, 0xb800, 0xd0bc,
-	0x11e0, 0x7294, 0xd28c, 0x0180, 0x080c, 0x697b, 0x9082, 0x0006,
-	0x02e0, 0xd484, 0x1118, 0x080c, 0x65cc, 0x0028, 0x080c, 0x3292,
-	0x01a0, 0x080c, 0x32bd, 0x0088, 0x080c, 0x3206, 0x080c, 0xd24a,
-	0x1160, 0x080c, 0x30f2, 0x0188, 0x0040, 0x080c, 0xd24a, 0x1118,
-	0x080c, 0x3292, 0x0110, 0x0451, 0x0140, 0x001e, 0x8108, 0x015e,
-	0x1f04, 0x304e, 0x70af, 0xffff, 0x0018, 0x001e, 0x015e, 0x71ae,
-	0x004e, 0x002e, 0x00ce, 0x00be, 0x0005, 0x00c6, 0x0016, 0x70af,
-	0x0001, 0x2009, 0x007e, 0x080c, 0x65a7, 0x1168, 0xb813, 0x00ff,
-	0xb817, 0xfffe, 0x080c, 0x3206, 0x04a9, 0x0128, 0x70dc, 0xc0bd,
-	0x70de, 0x080c, 0xcf9b, 0x001e, 0x00ce, 0x0005, 0x0016, 0x0076,
-	0x00d6, 0x00c6, 0x2001, 0x184c, 0x2004, 0x9084, 0x00ff, 0xb842,
-	0x080c, 0xaebf, 0x01d0, 0x2b00, 0x6012, 0x080c, 0xcfc4, 0x6023,
-	0x0001, 0x9006, 0x080c, 0x6544, 0x2001, 0x0000, 0x080c, 0x6558,
-	0x0126, 0x2091, 0x8000, 0x70a8, 0x8000, 0x70aa, 0x012e, 0x2009,
-	0x0004, 0x080c, 0xaeec, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e,
-	0x001e, 0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x2001, 0x184c,
-	0x2004, 0x9084, 0x00ff, 0xb842, 0x080c, 0xaebf, 0x0548, 0x2b00,
-	0x6012, 0xb800, 0xc0c4, 0xb802, 0xb8a0, 0x9086, 0x007e, 0x0140,
-	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x1110, 0x080c, 0x31c1,
-	0x080c, 0xcfc4, 0x6023, 0x0001, 0x9006, 0x080c, 0x6544, 0x2001,
-	0x0002, 0x080c, 0x6558, 0x0126, 0x2091, 0x8000, 0x70a8, 0x8000,
-	0x70aa, 0x012e, 0x2009, 0x0002, 0x080c, 0xaeec, 0x9085, 0x0001,
-	0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00b6, 0x00c6, 0x0026,
-	0x2009, 0x0080, 0x080c, 0x65a7, 0x1140, 0xb813, 0x00ff, 0xb817,
-	0xfffc, 0x0039, 0x0110, 0x70e3, 0xffff, 0x002e, 0x00ce, 0x00be,
-	0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x080c, 0xae1b, 0x01d0,
-	0x2b00, 0x6012, 0x080c, 0xcfc4, 0x6023, 0x0001, 0x9006, 0x080c,
-	0x6544, 0x2001, 0x0002, 0x080c, 0x6558, 0x0126, 0x2091, 0x8000,
-	0x70e4, 0x8000, 0x70e6, 0x012e, 0x2009, 0x0002, 0x080c, 0xaeec,
-	0x9085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00c6,
-	0x00d6, 0x0126, 0x2091, 0x8000, 0x2009, 0x007f, 0x080c, 0x65a7,
-	0x11b8, 0xb813, 0x00ff, 0xb817, 0xfffd, 0xb8cf, 0x0004, 0x080c,
-	0xae1b, 0x0170, 0x2b00, 0x6012, 0x6316, 0x6023, 0x0001, 0x620a,
-	0x080c, 0xcfc4, 0x2009, 0x0022, 0x080c, 0xaeec, 0x9085, 0x0001,
-	0x012e, 0x00de, 0x00ce, 0x0005, 0x00e6, 0x00c6, 0x0066, 0x0036,
-	0x0026, 0x00b6, 0x21f0, 0x080c, 0x9289, 0x080c, 0x9209, 0x080c,
-	0xacaf, 0x080c, 0xbd8a, 0x3e08, 0x2130, 0x81ff, 0x0120, 0x20a9,
-	0x007e, 0x900e, 0x0018, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c,
-	0x6608, 0x1140, 0x9686, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x1110,
-	0x080c, 0x603d, 0x001e, 0x8108, 0x1f04, 0x31a6, 0x9686, 0x0001,
-	0x190c, 0x32ea, 0x00be, 0x002e, 0x003e, 0x006e, 0x00ce, 0x00ee,
-	0x0005, 0x00e6, 0x00c6, 0x0046, 0x0036, 0x0026, 0x0016, 0x00b6,
-	0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c, 0x927e,
-	0x0076, 0x2039, 0x0000, 0x080c, 0x9151, 0x2c08, 0x080c, 0xe30c,
-	0x007e, 0x001e, 0xba10, 0xbb14, 0xbcc0, 0x080c, 0x603d, 0xba12,
-	0xbb16, 0xbcc2, 0x00be, 0x001e, 0x002e, 0x003e, 0x004e, 0x00ce,
-	0x00ee, 0x0005, 0x00e6, 0x0006, 0x00b6, 0x6010, 0x2058, 0xb8a0,
-	0x00be, 0x9086, 0x0080, 0x0150, 0x2071, 0x1800, 0x70a8, 0x9005,
-	0x0110, 0x8001, 0x70aa, 0x000e, 0x00ee, 0x0005, 0x2071, 0x1800,
-	0x70e4, 0x9005, 0x0dc0, 0x8001, 0x70e6, 0x0ca8, 0xb800, 0xc08c,
-	0xb802, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x00b6, 0x0046, 0x0036,
-	0x0026, 0x0016, 0x0156, 0x2178, 0x81ff, 0x1118, 0x20a9, 0x0001,
-	0x0078, 0x080c, 0x56d8, 0xd0c4, 0x0140, 0xd0a4, 0x0130, 0x9006,
-	0x2020, 0x2009, 0x002d, 0x080c, 0xe5cf, 0x20a9, 0x0800, 0x9016,
-	0x0026, 0x928e, 0x007e, 0x0904, 0x3271, 0x928e, 0x007f, 0x0904,
-	0x3271, 0x928e, 0x0080, 0x05e8, 0x9288, 0x1000, 0x210c, 0x81ff,
-	0x05c0, 0x8fff, 0x1148, 0x2001, 0x198d, 0x0006, 0x2003, 0x0001,
-	0x04f1, 0x000e, 0x2003, 0x0000, 0x00b6, 0x00c6, 0x2158, 0x2001,
-	0x0001, 0x080c, 0x6945, 0x00ce, 0x00be, 0x2019, 0x0029, 0x080c,
-	0x927e, 0x0076, 0x2039, 0x0000, 0x080c, 0x9151, 0x00b6, 0x00c6,
-	0x0026, 0x2158, 0xba04, 0x9294, 0x00ff, 0x9286, 0x0006, 0x1118,
-	0xb807, 0x0404, 0x0028, 0x2001, 0x0004, 0x8007, 0x9215, 0xba06,
-	0x002e, 0x00ce, 0x00be, 0x0016, 0x2c08, 0x080c, 0xe30c, 0x001e,
-	0x007e, 0x002e, 0x8210, 0x1f04, 0x3228, 0x015e, 0x001e, 0x002e,
-	0x003e, 0x004e, 0x00be, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0046,
-	0x0026, 0x0016, 0x080c, 0x56d8, 0xd0c4, 0x0140, 0xd0a4, 0x0130,
-	0x9006, 0x2220, 0x2009, 0x0029, 0x080c, 0xe5cf, 0x001e, 0x002e,
-	0x004e, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x7294, 0x82ff,
-	0x01e8, 0x080c, 0x6973, 0x11d0, 0x2100, 0x080c, 0x2873, 0x81ff,
-	0x01b8, 0x2019, 0x0001, 0x8314, 0x92e0, 0x1c80, 0x2c04, 0xd384,
-	0x0120, 0x9084, 0xff00, 0x8007, 0x0010, 0x9084, 0x00ff, 0x9116,
-	0x0138, 0x9096, 0x00ff, 0x0110, 0x8318, 0x0c68, 0x9085, 0x0001,
-	0x00ce, 0x003e, 0x002e, 0x001e, 0x0005, 0x0016, 0x00c6, 0x0126,
-	0x2091, 0x8000, 0x0036, 0x2019, 0x0029, 0x00a9, 0x003e, 0x9180,
-	0x1000, 0x2004, 0x9065, 0x0158, 0x0016, 0x00c6, 0x2061, 0x1aaf,
-	0x001e, 0x6112, 0x080c, 0x31c1, 0x001e, 0x080c, 0x65cc, 0x012e,
-	0x00ce, 0x001e, 0x0005, 0x0016, 0x0026, 0x2110, 0x080c, 0xa80e,
-	0x080c, 0xe938, 0x002e, 0x001e, 0x0005, 0x2001, 0x1837, 0x2004,
-	0xd0cc, 0x0005, 0x00c6, 0x00b6, 0x080c, 0x73a5, 0x1118, 0x20a9,
-	0x0800, 0x0010, 0x20a9, 0x0782, 0x080c, 0x73a5, 0x1110, 0x900e,
-	0x0010, 0x2009, 0x007e, 0x9180, 0x1000, 0x2004, 0x905d, 0x0130,
-	0x86ff, 0x0110, 0xb800, 0xd0bc, 0x090c, 0x65cc, 0x8108, 0x1f04,
-	0x32fb, 0x2061, 0x1800, 0x607f, 0x0000, 0x6080, 0x9084, 0x00ff,
-	0x6082, 0x60b3, 0x0000, 0x00be, 0x00ce, 0x0005, 0x2001, 0x1869,
-	0x2004, 0xd0bc, 0x0005, 0x2011, 0x1848, 0x2214, 0xd2ec, 0x0005,
-	0x0026, 0x2011, 0x1867, 0x2214, 0xd2dc, 0x002e, 0x0005, 0x7eef,
-	0x7de8, 0x7ce4, 0x80e2, 0x7be1, 0x80e0, 0x80dc, 0x80da, 0x7ad9,
-	0x80d6, 0x80d5, 0x80d4, 0x80d3, 0x80d2, 0x80d1, 0x79ce, 0x78cd,
-	0x80cc, 0x80cb, 0x80ca, 0x80c9, 0x80c7, 0x80c6, 0x77c5, 0x76c3,
-	0x80bc, 0x80ba, 0x75b9, 0x80b6, 0x74b5, 0x73b4, 0x72b3, 0x80b2,
-	0x80b1, 0x80ae, 0x71ad, 0x80ac, 0x70ab, 0x6faa, 0x6ea9, 0x80a7,
-	0x6da6, 0x6ca5, 0x6ba3, 0x6a9f, 0x699e, 0x689d, 0x809b, 0x8098,
-	0x6797, 0x6690, 0x658f, 0x6488, 0x6384, 0x6282, 0x8081, 0x8080,
-	0x617c, 0x607a, 0x8079, 0x5f76, 0x8075, 0x8074, 0x8073, 0x8072,
-	0x8071, 0x806e, 0x5e6d, 0x806c, 0x5d6b, 0x5c6a, 0x5b69, 0x8067,
-	0x5a66, 0x5965, 0x5863, 0x575c, 0x565a, 0x5559, 0x8056, 0x8055,
-	0x5454, 0x5353, 0x5252, 0x5151, 0x504e, 0x4f4d, 0x804c, 0x804b,
-	0x4e4a, 0x4d49, 0x8047, 0x4c46, 0x8045, 0x8043, 0x803c, 0x803a,
-	0x8039, 0x8036, 0x4b35, 0x8034, 0x4a33, 0x4932, 0x4831, 0x802e,
-	0x472d, 0x462c, 0x452b, 0x442a, 0x4329, 0x4227, 0x8026, 0x8025,
-	0x4123, 0x401f, 0x3f1e, 0x3e1d, 0x3d1b, 0x3c18, 0x8017, 0x8010,
-	0x3b0f, 0x3a08, 0x8004, 0x3902, 0x8001, 0x8000, 0x8000, 0x3800,
-	0x3700, 0x3600, 0x8000, 0x3500, 0x8000, 0x8000, 0x8000, 0x3400,
-	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x3300, 0x3200,
-	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x3100, 0x3000,
-	0x8000, 0x8000, 0x2f00, 0x8000, 0x2e00, 0x2d00, 0x2c00, 0x8000,
-	0x8000, 0x8000, 0x2b00, 0x8000, 0x2a00, 0x2900, 0x2800, 0x8000,
-	0x2700, 0x2600, 0x2500, 0x2400, 0x2300, 0x2200, 0x8000, 0x8000,
-	0x2100, 0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x8000, 0x8000,
-	0x1b00, 0x1a00, 0x8000, 0x1900, 0x8000, 0x8000, 0x8000, 0x8000,
-	0x8000, 0x8000, 0x1800, 0x8000, 0x1700, 0x1600, 0x1500, 0x8000,
-	0x1400, 0x1300, 0x1200, 0x1100, 0x1000, 0x0f00, 0x8000, 0x8000,
-	0x0e00, 0x0d00, 0x0c00, 0x0b00, 0x0a00, 0x0900, 0x8000, 0x8000,
-	0x0800, 0x0700, 0x8000, 0x0600, 0x8000, 0x8000, 0x8000, 0x0500,
-	0x0400, 0x0300, 0x8000, 0x0200, 0x8000, 0x8000, 0x8000, 0x0100,
-	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x8000,
+	0x294e, 0x080c, 0x22a2, 0x080c, 0x248e, 0x080c, 0x1380, 0x080c,
+	0x22dd, 0x0000, 0x015e, 0x014e, 0x013e, 0x01de, 0x01ce, 0x012e,
+	0x000e, 0x010e, 0x000d, 0x00b6, 0x00c6, 0x0026, 0x0046, 0x9026,
+	0x080c, 0x6947, 0x1904, 0x30b3, 0x72dc, 0x2001, 0x197b, 0x2004,
+	0x9005, 0x1110, 0xd29c, 0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904,
+	0x30b3, 0x080c, 0x30b8, 0x0804, 0x30b3, 0xd2cc, 0x1904, 0x30b3,
+	0x080c, 0x73b3, 0x1120, 0x70af, 0xffff, 0x0804, 0x30b3, 0xd294,
+	0x0120, 0x70af, 0xffff, 0x0804, 0x30b3, 0x080c, 0x3321, 0x0160,
+	0x080c, 0xd25a, 0x0128, 0x2001, 0x1818, 0x203c, 0x0804, 0x3040,
+	0x70af, 0xffff, 0x0804, 0x30b3, 0x2001, 0x1818, 0x203c, 0x7294,
+	0xd284, 0x0904, 0x3040, 0xd28c, 0x1904, 0x3040, 0x0036, 0x73ac,
+	0x938e, 0xffff, 0x1110, 0x2019, 0x0001, 0x8314, 0x92e0, 0x1c80,
+	0x2c04, 0x938c, 0x0001, 0x0120, 0x9084, 0xff00, 0x8007, 0x0010,
+	0x9084, 0x00ff, 0x970e, 0x05d0, 0x908e, 0x0000, 0x05b8, 0x908e,
+	0x00ff, 0x1150, 0x7230, 0xd284, 0x15b0, 0x7294, 0xc28d, 0x7296,
+	0x70af, 0xffff, 0x003e, 0x04a0, 0x900e, 0x080c, 0x284b, 0x080c,
+	0x65b5, 0x1538, 0x9006, 0xb8bb, 0x0520, 0xb8ac, 0x9005, 0x0148,
+	0x00c6, 0x2060, 0x080c, 0x8987, 0x00ce, 0x090c, 0x8d2d, 0xb8af,
+	0x0000, 0x080c, 0x6989, 0x1168, 0x7030, 0xd08c, 0x0130, 0xb800,
+	0xd0bc, 0x0138, 0x080c, 0x6836, 0x0120, 0x080c, 0x30d1, 0x0148,
+	0x0028, 0x080c, 0x3211, 0x080c, 0x30fd, 0x0118, 0x8318, 0x0804,
+	0x2fed, 0x73ae, 0x0010, 0x70af, 0xffff, 0x003e, 0x0804, 0x30b3,
+	0x9780, 0x3332, 0x203d, 0x97bc, 0xff00, 0x873f, 0x2041, 0x007e,
+	0x70ac, 0x9096, 0xffff, 0x1118, 0x900e, 0x28a8, 0x0050, 0x9812,
+	0x0220, 0x2008, 0x9802, 0x20a8, 0x0020, 0x70af, 0xffff, 0x0804,
+	0x30b3, 0x2700, 0x0156, 0x0016, 0x9106, 0x0904, 0x30a8, 0xc484,
+	0x080c, 0x6616, 0x0148, 0x080c, 0xd25a, 0x1904, 0x30a8, 0x080c,
+	0x65b5, 0x1904, 0x30b0, 0x0008, 0xc485, 0xb8bb, 0x0520, 0xb8ac,
+	0x9005, 0x0148, 0x00c6, 0x2060, 0x080c, 0x8987, 0x00ce, 0x090c,
+	0x8d2d, 0xb8af, 0x0000, 0x080c, 0x6989, 0x1130, 0x7030, 0xd08c,
+	0x01f8, 0xb800, 0xd0bc, 0x11e0, 0x7294, 0xd28c, 0x0180, 0x080c,
+	0x6989, 0x9082, 0x0006, 0x02e0, 0xd484, 0x1118, 0x080c, 0x65da,
+	0x0028, 0x080c, 0x329d, 0x01a0, 0x080c, 0x32c8, 0x0088, 0x080c,
+	0x3211, 0x080c, 0xd25a, 0x1160, 0x080c, 0x30fd, 0x0188, 0x0040,
+	0x080c, 0xd25a, 0x1118, 0x080c, 0x329d, 0x0110, 0x0451, 0x0140,
+	0x001e, 0x8108, 0x015e, 0x1f04, 0x3059, 0x70af, 0xffff, 0x0018,
+	0x001e, 0x015e, 0x71ae, 0x004e, 0x002e, 0x00ce, 0x00be, 0x0005,
+	0x00c6, 0x0016, 0x70af, 0x0001, 0x2009, 0x007e, 0x080c, 0x65b5,
+	0x1168, 0xb813, 0x00ff, 0xb817, 0xfffe, 0x080c, 0x3211, 0x04a9,
+	0x0128, 0x70dc, 0xc0bd, 0x70de, 0x080c, 0xcfab, 0x001e, 0x00ce,
+	0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x2001, 0x184c, 0x2004,
+	0x9084, 0x00ff, 0xb842, 0x080c, 0xaead, 0x01d0, 0x2b00, 0x6012,
+	0x080c, 0xcfd4, 0x6023, 0x0001, 0x9006, 0x080c, 0x6552, 0x2001,
+	0x0000, 0x080c, 0x6566, 0x0126, 0x2091, 0x8000, 0x70a8, 0x8000,
+	0x70aa, 0x012e, 0x2009, 0x0004, 0x080c, 0xaeda, 0x9085, 0x0001,
+	0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x0016, 0x0076, 0x00d6,
+	0x00c6, 0x2001, 0x184c, 0x2004, 0x9084, 0x00ff, 0xb842, 0x080c,
+	0xaead, 0x0548, 0x2b00, 0x6012, 0xb800, 0xc0c4, 0xb802, 0xb8a0,
+	0x9086, 0x007e, 0x0140, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
+	0x1110, 0x080c, 0x31cc, 0x080c, 0xcfd4, 0x6023, 0x0001, 0x9006,
+	0x080c, 0x6552, 0x2001, 0x0002, 0x080c, 0x6566, 0x0126, 0x2091,
+	0x8000, 0x70a8, 0x8000, 0x70aa, 0x012e, 0x2009, 0x0002, 0x080c,
+	0xaeda, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005,
+	0x00b6, 0x00c6, 0x0026, 0x2009, 0x0080, 0x080c, 0x65b5, 0x1140,
+	0xb813, 0x00ff, 0xb817, 0xfffc, 0x0039, 0x0110, 0x70e3, 0xffff,
+	0x002e, 0x00ce, 0x00be, 0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6,
+	0x080c, 0xae09, 0x01d0, 0x2b00, 0x6012, 0x080c, 0xcfd4, 0x6023,
+	0x0001, 0x9006, 0x080c, 0x6552, 0x2001, 0x0002, 0x080c, 0x6566,
+	0x0126, 0x2091, 0x8000, 0x70e4, 0x8000, 0x70e6, 0x012e, 0x2009,
+	0x0002, 0x080c, 0xaeda, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e,
+	0x001e, 0x0005, 0x00c6, 0x00d6, 0x0126, 0x2091, 0x8000, 0x2009,
+	0x007f, 0x080c, 0x65b5, 0x11b8, 0xb813, 0x00ff, 0xb817, 0xfffd,
+	0xb8cf, 0x0004, 0x080c, 0xae09, 0x0170, 0x2b00, 0x6012, 0x6316,
+	0x6023, 0x0001, 0x620a, 0x080c, 0xcfd4, 0x2009, 0x0022, 0x080c,
+	0xaeda, 0x9085, 0x0001, 0x012e, 0x00de, 0x00ce, 0x0005, 0x00e6,
+	0x00c6, 0x0066, 0x0036, 0x0026, 0x00b6, 0x21f0, 0x080c, 0x92a8,
+	0x080c, 0x9228, 0x080c, 0xac9d, 0x080c, 0xbd87, 0x3e08, 0x2130,
+	0x81ff, 0x0120, 0x20a9, 0x007e, 0x900e, 0x0018, 0x20a9, 0x007f,
+	0x900e, 0x0016, 0x080c, 0x6616, 0x1140, 0x9686, 0x0002, 0x1118,
+	0xb800, 0xd0bc, 0x1110, 0x080c, 0x6047, 0x001e, 0x8108, 0x1f04,
+	0x31b1, 0x9686, 0x0001, 0x190c, 0x32f5, 0x00be, 0x002e, 0x003e,
+	0x006e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x00c6, 0x0046, 0x0036,
+	0x0026, 0x0016, 0x00b6, 0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019,
+	0x0029, 0x080c, 0x929d, 0x0076, 0x2039, 0x0000, 0x080c, 0x9170,
+	0x2c08, 0x080c, 0xe326, 0x007e, 0x001e, 0xba10, 0xbb14, 0xbcc0,
+	0x080c, 0x6047, 0xba12, 0xbb16, 0xbcc2, 0x00be, 0x001e, 0x002e,
+	0x003e, 0x004e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x00b6,
+	0x6010, 0x2058, 0xb8a0, 0x00be, 0x9086, 0x0080, 0x0150, 0x2071,
+	0x1800, 0x70a8, 0x9005, 0x0110, 0x8001, 0x70aa, 0x000e, 0x00ee,
+	0x0005, 0x2071, 0x1800, 0x70e4, 0x9005, 0x0dc0, 0x8001, 0x70e6,
+	0x0ca8, 0xb800, 0xc08c, 0xb802, 0x0005, 0x00f6, 0x00e6, 0x00c6,
+	0x00b6, 0x0046, 0x0036, 0x0026, 0x0016, 0x0156, 0x2178, 0x81ff,
+	0x1118, 0x20a9, 0x0001, 0x0078, 0x080c, 0x56e2, 0xd0c4, 0x0140,
+	0xd0a4, 0x0130, 0x9006, 0x2020, 0x2009, 0x002d, 0x080c, 0xe5e9,
+	0x20a9, 0x0800, 0x9016, 0x0026, 0x928e, 0x007e, 0x0904, 0x327c,
+	0x928e, 0x007f, 0x0904, 0x327c, 0x928e, 0x0080, 0x05e8, 0x9288,
+	0x1000, 0x210c, 0x81ff, 0x05c0, 0x8fff, 0x1148, 0x2001, 0x198d,
+	0x0006, 0x2003, 0x0001, 0x04f1, 0x000e, 0x2003, 0x0000, 0x00b6,
+	0x00c6, 0x2158, 0x2001, 0x0001, 0x080c, 0x6953, 0x00ce, 0x00be,
+	0x2019, 0x0029, 0x080c, 0x929d, 0x0076, 0x2039, 0x0000, 0x080c,
+	0x9170, 0x00b6, 0x00c6, 0x0026, 0x2158, 0xba04, 0x9294, 0x00ff,
+	0x9286, 0x0006, 0x1118, 0xb807, 0x0404, 0x0028, 0x2001, 0x0004,
+	0x8007, 0x9215, 0xba06, 0x002e, 0x00ce, 0x00be, 0x0016, 0x2c08,
+	0x080c, 0xe326, 0x001e, 0x007e, 0x002e, 0x8210, 0x1f04, 0x3233,
+	0x015e, 0x001e, 0x002e, 0x003e, 0x004e, 0x00be, 0x00ce, 0x00ee,
+	0x00fe, 0x0005, 0x0046, 0x0026, 0x0016, 0x080c, 0x56e2, 0xd0c4,
+	0x0140, 0xd0a4, 0x0130, 0x9006, 0x2220, 0x2009, 0x0029, 0x080c,
+	0xe5e9, 0x001e, 0x002e, 0x004e, 0x0005, 0x0016, 0x0026, 0x0036,
+	0x00c6, 0x7294, 0x82ff, 0x01e8, 0x080c, 0x6981, 0x11d0, 0x2100,
+	0x080c, 0x287e, 0x81ff, 0x01b8, 0x2019, 0x0001, 0x8314, 0x92e0,
+	0x1c80, 0x2c04, 0xd384, 0x0120, 0x9084, 0xff00, 0x8007, 0x0010,
+	0x9084, 0x00ff, 0x9116, 0x0138, 0x9096, 0x00ff, 0x0110, 0x8318,
+	0x0c68, 0x9085, 0x0001, 0x00ce, 0x003e, 0x002e, 0x001e, 0x0005,
+	0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x0036, 0x2019, 0x0029,
+	0x00a9, 0x003e, 0x9180, 0x1000, 0x2004, 0x9065, 0x0158, 0x0016,
+	0x00c6, 0x2061, 0x1aaf, 0x001e, 0x6112, 0x080c, 0x31cc, 0x001e,
+	0x080c, 0x65da, 0x012e, 0x00ce, 0x001e, 0x0005, 0x0016, 0x0026,
+	0x2110, 0x080c, 0xa7f8, 0x080c, 0xe952, 0x002e, 0x001e, 0x0005,
+	0x2001, 0x1837, 0x2004, 0xd0cc, 0x0005, 0x00c6, 0x00b6, 0x080c,
+	0x73b3, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782, 0x080c,
+	0x73b3, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e, 0x9180, 0x1000,
+	0x2004, 0x905d, 0x0130, 0x86ff, 0x0110, 0xb800, 0xd0bc, 0x090c,
+	0x65da, 0x8108, 0x1f04, 0x3306, 0x2061, 0x1800, 0x607f, 0x0000,
+	0x6080, 0x9084, 0x00ff, 0x6082, 0x60b3, 0x0000, 0x00be, 0x00ce,
+	0x0005, 0x2001, 0x1869, 0x2004, 0xd0bc, 0x0005, 0x2011, 0x1848,
+	0x2214, 0xd2ec, 0x0005, 0x0026, 0x2011, 0x1867, 0x2214, 0xd2dc,
+	0x002e, 0x0005, 0x7eef, 0x7de8, 0x7ce4, 0x80e2, 0x7be1, 0x80e0,
+	0x80dc, 0x80da, 0x7ad9, 0x80d6, 0x80d5, 0x80d4, 0x80d3, 0x80d2,
+	0x80d1, 0x79ce, 0x78cd, 0x80cc, 0x80cb, 0x80ca, 0x80c9, 0x80c7,
+	0x80c6, 0x77c5, 0x76c3, 0x80bc, 0x80ba, 0x75b9, 0x80b6, 0x74b5,
+	0x73b4, 0x72b3, 0x80b2, 0x80b1, 0x80ae, 0x71ad, 0x80ac, 0x70ab,
+	0x6faa, 0x6ea9, 0x80a7, 0x6da6, 0x6ca5, 0x6ba3, 0x6a9f, 0x699e,
+	0x689d, 0x809b, 0x8098, 0x6797, 0x6690, 0x658f, 0x6488, 0x6384,
+	0x6282, 0x8081, 0x8080, 0x617c, 0x607a, 0x8079, 0x5f76, 0x8075,
+	0x8074, 0x8073, 0x8072, 0x8071, 0x806e, 0x5e6d, 0x806c, 0x5d6b,
+	0x5c6a, 0x5b69, 0x8067, 0x5a66, 0x5965, 0x5863, 0x575c, 0x565a,
+	0x5559, 0x8056, 0x8055, 0x5454, 0x5353, 0x5252, 0x5151, 0x504e,
+	0x4f4d, 0x804c, 0x804b, 0x4e4a, 0x4d49, 0x8047, 0x4c46, 0x8045,
+	0x8043, 0x803c, 0x803a, 0x8039, 0x8036, 0x4b35, 0x8034, 0x4a33,
+	0x4932, 0x4831, 0x802e, 0x472d, 0x462c, 0x452b, 0x442a, 0x4329,
+	0x4227, 0x8026, 0x8025, 0x4123, 0x401f, 0x3f1e, 0x3e1d, 0x3d1b,
+	0x3c18, 0x8017, 0x8010, 0x3b0f, 0x3a08, 0x8004, 0x3902, 0x8001,
+	0x8000, 0x8000, 0x3800, 0x3700, 0x3600, 0x8000, 0x3500, 0x8000,
+	0x8000, 0x8000, 0x3400, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x3300, 0x3200, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x3100, 0x3000, 0x8000, 0x8000, 0x2f00, 0x8000, 0x2e00,
+	0x2d00, 0x2c00, 0x8000, 0x8000, 0x8000, 0x2b00, 0x8000, 0x2a00,
+	0x2900, 0x2800, 0x8000, 0x2700, 0x2600, 0x2500, 0x2400, 0x2300,
+	0x2200, 0x8000, 0x8000, 0x2100, 0x2000, 0x1f00, 0x1e00, 0x1d00,
+	0x1c00, 0x8000, 0x8000, 0x1b00, 0x1a00, 0x8000, 0x1900, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x1800, 0x8000, 0x1700,
+	0x1600, 0x1500, 0x8000, 0x1400, 0x1300, 0x1200, 0x1100, 0x1000,
+	0x0f00, 0x8000, 0x8000, 0x0e00, 0x0d00, 0x0c00, 0x0b00, 0x0a00,
+	0x0900, 0x8000, 0x8000, 0x0800, 0x0700, 0x8000, 0x0600, 0x8000,
+	0x8000, 0x8000, 0x0500, 0x0400, 0x0300, 0x8000, 0x0200, 0x8000,
+	0x8000, 0x8000, 0x0100, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
 	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x2071,
-	0x189e, 0x7003, 0x0002, 0x9006, 0x7016, 0x701a, 0x704a, 0x704e,
-	0x700e, 0x7042, 0x7046, 0x703b, 0x18ba, 0x703f, 0x18ba, 0x7007,
-	0x0001, 0x080c, 0x1018, 0x090c, 0x0dd5, 0x2900, 0x706a, 0xa867,
-	0x0002, 0xa8ab, 0xdcb0, 0x080c, 0x1018, 0x090c, 0x0dd5, 0x2900,
-	0x706e, 0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x189e,
-	0x7004, 0x0002, 0x3456, 0x3457, 0x346a, 0x347e, 0x0005, 0x1004,
-	0x3467, 0x0e04, 0x3467, 0x2079, 0x0000, 0x0126, 0x2091, 0x8000,
-	0x700c, 0x9005, 0x1128, 0x700f, 0x0001, 0x012e, 0x0468, 0x0005,
-	0x012e, 0x0ce8, 0x2079, 0x0000, 0x2061, 0x18b8, 0x2c4c, 0xa86c,
-	0x908e, 0x0100, 0x0128, 0x9086, 0x0200, 0x0904, 0x3552, 0x0005,
-	0x7018, 0x2048, 0x2061, 0x1800, 0x701c, 0x0807, 0x7014, 0x2048,
-	0xa864, 0x9094, 0x00ff, 0x9296, 0x0029, 0x1120, 0xaa78, 0xd2fc,
-	0x0128, 0x0005, 0x9086, 0x0103, 0x0108, 0x0005, 0x2079, 0x0000,
-	0x2061, 0x1800, 0x701c, 0x0807, 0x2061, 0x1800, 0x7880, 0x908a,
-	0x0040, 0x1210, 0x61d0, 0x0042, 0x2100, 0x908a, 0x003f, 0x1a04,
-	0x354f, 0x61d0, 0x0804, 0x34e4, 0x3526, 0x355e, 0x354f, 0x3568,
-	0x3572, 0x3578, 0x357c, 0x358c, 0x3590, 0x35a6, 0x35ac, 0x35b2,
-	0x35bd, 0x35c8, 0x35d7, 0x35e6, 0x35f4, 0x360b, 0x3626, 0x354f,
-	0x36cf, 0x370d, 0x37b3, 0x37c4, 0x37e7, 0x354f, 0x354f, 0x354f,
-	0x381f, 0x383b, 0x3844, 0x3873, 0x3879, 0x354f, 0x38bf, 0x354f,
-	0x354f, 0x354f, 0x354f, 0x354f, 0x38ca, 0x38d3, 0x38db, 0x38dd,
-	0x354f, 0x354f, 0x354f, 0x354f, 0x354f, 0x354f, 0x3909, 0x354f,
-	0x354f, 0x354f, 0x354f, 0x354f, 0x3926, 0x3987, 0x354f, 0x354f,
-	0x354f, 0x354f, 0x354f, 0x354f, 0x0002, 0x39b1, 0x39b4, 0x3a13,
-	0x3a2c, 0x3a5c, 0x3cfa, 0x354f, 0x52b1, 0x354f, 0x354f, 0x354f,
-	0x354f, 0x354f, 0x354f, 0x354f, 0x354f, 0x35a6, 0x35ac, 0x421b,
-	0x56fc, 0x4239, 0x5340, 0x5391, 0x5494, 0x354f, 0x54f6, 0x5532,
-	0x5563, 0x5667, 0x5590, 0x55e7, 0x354f, 0x423d, 0x43fe, 0x4414,
-	0x4439, 0x449e, 0x4512, 0x4532, 0x45a9, 0x4605, 0x4661, 0x4664,
-	0x4689, 0x4726, 0x478c, 0x4794, 0x48c6, 0x4a3e, 0x4a72, 0x4cd6,
-	0x354f, 0x4cf4, 0x4d99, 0x4e7b, 0x4ed5, 0x354f, 0x4f8a, 0x354f,
-	0x4ff0, 0x500b, 0x4794, 0x5251, 0x714c, 0x0000, 0x2021, 0x4000,
-	0x080c, 0x4af0, 0x0126, 0x2091, 0x8000, 0x0e04, 0x3530, 0x0010,
-	0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000, 0x0118, 0x7833, 0x0011,
-	0x0010, 0x7833, 0x0010, 0x7c82, 0x7986, 0x7a8a, 0x7b8e, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b, 0x7007,
-	0x0001, 0x2091, 0x5000, 0x700f, 0x0000, 0x012e, 0x0005, 0x2021,
-	0x4001, 0x08b0, 0x2021, 0x4002, 0x0898, 0x2021, 0x4003, 0x0880,
-	0x2021, 0x4005, 0x0868, 0x2021, 0x4006, 0x0850, 0x2039, 0x0001,
-	0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884, 0x7990, 0x0804, 0x4afd,
-	0x2039, 0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884, 0x7990,
-	0x0804, 0x4b00, 0x7984, 0x7888, 0x2114, 0x200a, 0x0804, 0x3526,
-	0x7984, 0x2114, 0x0804, 0x3526, 0x20e1, 0x0000, 0x2099, 0x0021,
-	0x20e9, 0x0000, 0x20a1, 0x0021, 0x20a9, 0x001f, 0x4003, 0x7984,
-	0x7a88, 0x7b8c, 0x0804, 0x3526, 0x7884, 0x2060, 0x0804, 0x35d9,
-	0x2009, 0x0003, 0x2011, 0x0002, 0x2019, 0x001e, 0x789b, 0x0137,
-	0x7893, 0xffff, 0x2001, 0x188f, 0x2004, 0x9005, 0x0118, 0x7896,
-	0x0804, 0x3526, 0x7897, 0x0001, 0x0804, 0x3526, 0x2039, 0x0001,
-	0x7d98, 0x7c9c, 0x0804, 0x3562, 0x2039, 0x0001, 0x7d98, 0x7c9c,
-	0x0804, 0x356c, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x355b,
-	0x2138, 0x7d98, 0x7c9c, 0x0804, 0x3562, 0x79a0, 0x9182, 0x0040,
-	0x0210, 0x0804, 0x355b, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x356c,
-	0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x355b, 0x21e8, 0x7984,
-	0x7888, 0x20a9, 0x0001, 0x21a0, 0x4004, 0x0804, 0x3526, 0x2061,
-	0x0800, 0xe10c, 0x9006, 0x2c15, 0x9200, 0x8c60, 0x8109, 0x1dd8,
-	0x2010, 0x9005, 0x0904, 0x3526, 0x0804, 0x3555, 0x79a0, 0x9182,
-	0x0040, 0x0210, 0x0804, 0x355b, 0x21e0, 0x20a9, 0x0001, 0x7984,
-	0x2198, 0x4012, 0x0804, 0x3526, 0x2069, 0x1847, 0x7884, 0x7990,
-	0x911a, 0x1a04, 0x355b, 0x8019, 0x0904, 0x355b, 0x684a, 0x6942,
-	0x788c, 0x6852, 0x7888, 0x6856, 0x9006, 0x685a, 0x685e, 0x080c,
-	0x76be, 0x0804, 0x3526, 0x2069, 0x1847, 0x7884, 0x7994, 0x911a,
-	0x1a04, 0x355b, 0x8019, 0x0904, 0x355b, 0x684e, 0x6946, 0x788c,
-	0x6862, 0x7888, 0x6866, 0x9006, 0x686a, 0x686e, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x69e1, 0x012e, 0x0804, 0x3526, 0x902e, 0x2520,
-	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3558, 0x7984, 0x7b88,
-	0x7a8c, 0x20a9, 0x0005, 0x20e9, 0x0001, 0x20a1, 0x18a6, 0x4101,
-	0x080c, 0x4ab4, 0x1120, 0x2009, 0x0002, 0x0804, 0x3558, 0x2009,
-	0x0020, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x4afd, 0x701f,
-	0x364a, 0x0005, 0xa864, 0x2008, 0x9084, 0x00ff, 0x9096, 0x0011,
-	0x0168, 0x9096, 0x0019, 0x0150, 0x9096, 0x0015, 0x0138, 0x9096,
-	0x0048, 0x0120, 0x9096, 0x0029, 0x1904, 0x3558, 0x810f, 0x918c,
-	0x00ff, 0x0904, 0x3558, 0x7112, 0x7010, 0x8001, 0x0560, 0x7012,
-	0x080c, 0x4ab4, 0x1120, 0x2009, 0x0002, 0x0804, 0x3558, 0x2009,
-	0x0020, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494, 0xa598, 0x9290,
-	0x0040, 0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c,
-	0x9080, 0x0019, 0xaf60, 0x080c, 0x4afd, 0x701f, 0x3688, 0x0005,
-	0xa864, 0x9084, 0x00ff, 0x9096, 0x0002, 0x0120, 0x9096, 0x000a,
-	0x1904, 0x3558, 0x0888, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a,
-	0xa864, 0x9084, 0x00ff, 0x9096, 0x0029, 0x1160, 0xc2fd, 0xaa7a,
-	0x080c, 0x6194, 0x0150, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982,
-	0x012e, 0x0050, 0x080c, 0x64bd, 0x1128, 0x7007, 0x0003, 0x701f,
-	0x36b4, 0x0005, 0x080c, 0x6eb9, 0x0126, 0x2091, 0x8000, 0x20a9,
-	0x0005, 0x20e1, 0x0001, 0x2099, 0x18a6, 0x400a, 0x2100, 0x9210,
-	0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c, 0x9080,
-	0x0019, 0x2009, 0x0020, 0x012e, 0xaf60, 0x0804, 0x4b00, 0x2091,
-	0x8000, 0x7837, 0x4000, 0x7833, 0x0010, 0x7883, 0x4000, 0x7887,
-	0x4953, 0x788b, 0x5020, 0x788f, 0x2020, 0x2009, 0x017f, 0x2104,
-	0x7892, 0x3f00, 0x7896, 0x2061, 0x0100, 0x6200, 0x2061, 0x0200,
-	0x603c, 0x8007, 0x9205, 0x789a, 0x2009, 0x04fd, 0x2104, 0x789e,
-	0x2091, 0x5000, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x0180, 0x2001, 0x1a18, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b,
-	0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002, 0x2003,
-	0x1001, 0x2071, 0x0080, 0x0804, 0x0427, 0x81ff, 0x1904, 0x3558,
-	0x7984, 0x080c, 0x6608, 0x1904, 0x355b, 0x7e98, 0x9684, 0x3fff,
-	0x9082, 0x4000, 0x1a04, 0x355b, 0x7c88, 0x7d8c, 0x080c, 0x676b,
-	0x080c, 0x673a, 0x0000, 0x1518, 0x2061, 0x1cd0, 0x0126, 0x2091,
-	0x8000, 0x6000, 0x9086, 0x0000, 0x0148, 0x6014, 0x904d, 0x0130,
-	0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0150, 0x012e, 0x9ce0,
-	0x0018, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1a04, 0x3558, 0x0c30,
-	0x080c, 0xc77b, 0x012e, 0x0904, 0x3558, 0x0804, 0x3526, 0x900e,
-	0x2001, 0x0005, 0x080c, 0x6eb9, 0x0126, 0x2091, 0x8000, 0x080c,
-	0xce44, 0x080c, 0x6c86, 0x012e, 0x0804, 0x3526, 0x00a6, 0x2950,
-	0xb198, 0x080c, 0x6608, 0x1904, 0x37a0, 0xb6a4, 0x9684, 0x3fff,
-	0x9082, 0x4000, 0x16e8, 0xb49c, 0xb5a0, 0x080c, 0x676b, 0x080c,
-	0x673a, 0x1520, 0x2061, 0x1cd0, 0x0126, 0x2091, 0x8000, 0x6000,
-	0x9086, 0x0000, 0x0148, 0x6014, 0x904d, 0x0130, 0xa86c, 0x9406,
-	0x1118, 0xa870, 0x9506, 0x0158, 0x012e, 0x9ce0, 0x0018, 0x2001,
-	0x181a, 0x2004, 0x9c02, 0x2009, 0x000d, 0x12b0, 0x0c28, 0x080c,
-	0xc77b, 0x012e, 0x2009, 0x0003, 0x0178, 0x00e0, 0x900e, 0x2001,
-	0x0005, 0x080c, 0x6eb9, 0x0126, 0x2091, 0x8000, 0x080c, 0xce44,
-	0x080c, 0x6c7a, 0x012e, 0x0070, 0xb097, 0x4005, 0xb19a, 0x0010,
-	0xb097, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x2a48,
-	0x00ae, 0x0005, 0xb097, 0x4000, 0x9006, 0x918d, 0x0001, 0x2008,
-	0x2a48, 0x00ae, 0x0005, 0x81ff, 0x1904, 0x3558, 0x080c, 0x4acb,
-	0x0904, 0x355b, 0x080c, 0x66cf, 0x0904, 0x3558, 0x080c, 0x6771,
-	0x0904, 0x3558, 0x0804, 0x4529, 0x81ff, 0x1904, 0x3558, 0x080c,
-	0x4ae7, 0x0904, 0x355b, 0x080c, 0x67ff, 0x0904, 0x3558, 0x2019,
-	0x0005, 0x79a8, 0x080c, 0x678c, 0x0904, 0x3558, 0x7888, 0x908a,
-	0x1000, 0x1a04, 0x355b, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c,
-	0x84ea, 0x7984, 0xd184, 0x1904, 0x3526, 0x0804, 0x4529, 0x0126,
-	0x2091, 0x8000, 0x81ff, 0x0118, 0x2009, 0x0001, 0x0450, 0x2029,
-	0x07ff, 0x645c, 0x2400, 0x9506, 0x01f8, 0x2508, 0x080c, 0x6608,
-	0x11d8, 0x080c, 0x67ff, 0x1128, 0x2009, 0x0002, 0x62c0, 0x2518,
-	0x00c0, 0x2019, 0x0004, 0x900e, 0x080c, 0x678c, 0x1118, 0x2009,
-	0x0006, 0x0078, 0x7884, 0x908a, 0x1000, 0x1270, 0x8003, 0x800b,
-	0x810b, 0x9108, 0x080c, 0x84ea, 0x8529, 0x1ae0, 0x012e, 0x0804,
-	0x3526, 0x012e, 0x0804, 0x3558, 0x012e, 0x0804, 0x355b, 0x080c,
-	0x4acb, 0x0904, 0x355b, 0x080c, 0x66cf, 0x0904, 0x3558, 0xbaa0,
-	0x2019, 0x0005, 0x00c6, 0x9066, 0x080c, 0x927e, 0x0076, 0x903e,
-	0x080c, 0x9151, 0x900e, 0x080c, 0xe30c, 0x007e, 0x00ce, 0x080c,
-	0x676b, 0x0804, 0x3526, 0x080c, 0x4acb, 0x0904, 0x355b, 0x080c,
-	0x676b, 0x2208, 0x0804, 0x3526, 0x0156, 0x00d6, 0x00e6, 0x2069,
-	0x1910, 0x6810, 0x6914, 0x910a, 0x1208, 0x900e, 0x6816, 0x9016,
-	0x901e, 0x20a9, 0x007e, 0x2069, 0x1000, 0x2d04, 0x905d, 0x0118,
-	0xb84c, 0x0059, 0x9210, 0x8d68, 0x1f04, 0x3855, 0x2300, 0x9218,
-	0x00ee, 0x00de, 0x015e, 0x0804, 0x3526, 0x00f6, 0x0016, 0x907d,
-	0x0138, 0x9006, 0x8000, 0x2f0c, 0x81ff, 0x0110, 0x2178, 0x0cd0,
-	0x001e, 0x00fe, 0x0005, 0x2069, 0x1910, 0x6910, 0x62bc, 0x0804,
-	0x3526, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3558, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x56ec, 0x0128, 0x2009, 0x0007, 0x012e,
-	0x0804, 0x3558, 0x012e, 0x615c, 0x9190, 0x3327, 0x2215, 0x9294,
-	0x00ff, 0x637c, 0x83ff, 0x0108, 0x6280, 0x67dc, 0x97c4, 0x000a,
-	0x98c6, 0x000a, 0x1118, 0x2031, 0x0001, 0x00e8, 0x97c4, 0x0022,
-	0x98c6, 0x0022, 0x1118, 0x2031, 0x0003, 0x00a8, 0x97c4, 0x0012,
-	0x98c6, 0x0012, 0x1118, 0x2031, 0x0002, 0x0068, 0x080c, 0x73a5,
-	0x1118, 0x2031, 0x0004, 0x0038, 0xd79c, 0x0120, 0x2009, 0x0005,
-	0x0804, 0x3558, 0x9036, 0x7e9a, 0x7f9e, 0x0804, 0x3526, 0x614c,
-	0x6250, 0x2019, 0x1985, 0x231c, 0x2001, 0x1986, 0x2004, 0x789a,
-	0x0804, 0x3526, 0x0126, 0x2091, 0x8000, 0x6138, 0x623c, 0x6340,
-	0x012e, 0x0804, 0x3526, 0x080c, 0x4ae7, 0x0904, 0x355b, 0xba44,
-	0xbb38, 0x0804, 0x3526, 0x080c, 0x0dd5, 0x080c, 0x4ae7, 0x2110,
-	0x0904, 0x355b, 0xb804, 0x908c, 0x00ff, 0x918e, 0x0006, 0x0140,
-	0x9084, 0xff00, 0x9086, 0x0600, 0x2009, 0x0009, 0x1904, 0x3558,
-	0x0126, 0x2091, 0x8000, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c,
-	0xa80e, 0x080c, 0x927e, 0x0076, 0x903e, 0x080c, 0x9151, 0x900e,
-	0x080c, 0xe30c, 0x007e, 0x00ce, 0xb807, 0x0407, 0x012e, 0x0804,
-	0x3526, 0x614c, 0x6250, 0x7884, 0x604e, 0x7b88, 0x6352, 0x2069,
-	0x1847, 0x831f, 0x9305, 0x6816, 0x788c, 0x2069, 0x1985, 0x2d1c,
-	0x206a, 0x7e98, 0x9682, 0x0014, 0x1210, 0x2031, 0x07d0, 0x2069,
-	0x1986, 0x2d04, 0x266a, 0x789a, 0x0804, 0x3526, 0x0126, 0x2091,
-	0x8000, 0x7884, 0x603a, 0xd0c4, 0x01a8, 0x00d6, 0x78a8, 0x2009,
-	0x199c, 0x200a, 0x78ac, 0x2011, 0x199d, 0x2012, 0x2069, 0x0100,
-	0x6838, 0x9086, 0x0007, 0x1118, 0x2214, 0x6a5a, 0x0010, 0x210c,
-	0x695a, 0x00de, 0x7884, 0xd0b4, 0x0120, 0x3b00, 0x9084, 0xff3f,
-	0x20d8, 0x7888, 0x603e, 0x2011, 0x0114, 0x220c, 0x7888, 0xd08c,
-	0x0118, 0x918d, 0x0080, 0x0010, 0x918c, 0xff7f, 0x2112, 0x788c,
-	0x6042, 0x9084, 0x0020, 0x0130, 0x78b4, 0x6046, 0x9084, 0x0001,
-	0x090c, 0x421b, 0x6040, 0xd0cc, 0x0120, 0x78b0, 0x2011, 0x0114,
-	0x2012, 0x012e, 0x0804, 0x3526, 0x00f6, 0x2079, 0x1800, 0x7a38,
-	0xa898, 0x9084, 0xfebf, 0x9215, 0xa89c, 0x9084, 0xfebf, 0x8002,
-	0x9214, 0x7838, 0x9084, 0x0140, 0x9215, 0x7a3a, 0xa897, 0x4000,
-	0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x00fe, 0x0005, 0x7898,
-	0x9005, 0x01a8, 0x7888, 0x9025, 0x0904, 0x355b, 0x788c, 0x902d,
-	0x0904, 0x355b, 0x900e, 0x080c, 0x6608, 0x1120, 0xba44, 0xbb38,
-	0xbc46, 0xbd3a, 0x9186, 0x07ff, 0x0190, 0x8108, 0x0ca0, 0x080c,
-	0x4ae7, 0x0904, 0x355b, 0x7888, 0x900d, 0x0904, 0x355b, 0x788c,
-	0x9005, 0x0904, 0x355b, 0xba44, 0xb946, 0xbb38, 0xb83a, 0x0804,
-	0x3526, 0x2011, 0xbc09, 0x0010, 0x2011, 0xbc05, 0x080c, 0x56ec,
-	0x1904, 0x3558, 0x00c6, 0x2061, 0x0100, 0x7984, 0x9186, 0x00ff,
-	0x1130, 0x2001, 0x1818, 0x2004, 0x9085, 0xff00, 0x0088, 0x9182,
-	0x007f, 0x16e0, 0x9188, 0x3327, 0x210d, 0x918c, 0x00ff, 0x2001,
-	0x1818, 0x2004, 0x0026, 0x9116, 0x002e, 0x0580, 0x810f, 0x9105,
-	0x0126, 0x2091, 0x8000, 0x0006, 0x080c, 0xae1b, 0x000e, 0x0510,
-	0x602e, 0x620a, 0x7984, 0x00b6, 0x080c, 0x65ad, 0x2b08, 0x00be,
-	0x1500, 0x6112, 0x6023, 0x0001, 0x080c, 0x4ab4, 0x01d0, 0x9006,
-	0xa866, 0x7007, 0x0003, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x701f,
-	0x3a0c, 0x2900, 0x6016, 0x2009, 0x0032, 0x080c, 0xaeec, 0x012e,
-	0x00ce, 0x0005, 0x012e, 0x00ce, 0x0804, 0x3558, 0x00ce, 0x0804,
-	0x355b, 0x080c, 0xae71, 0x0cb0, 0xa830, 0x9086, 0x0100, 0x0904,
-	0x3558, 0x0804, 0x3526, 0x2061, 0x1a70, 0x0126, 0x2091, 0x8000,
-	0x6000, 0xd084, 0x0170, 0x6104, 0x6208, 0x2061, 0x1800, 0x6354,
-	0x6074, 0x789a, 0x60c0, 0x789e, 0x60bc, 0x78aa, 0x012e, 0x0804,
-	0x3526, 0x900e, 0x2110, 0x0c88, 0x81ff, 0x1904, 0x3558, 0x080c,
-	0x73a5, 0x0904, 0x3558, 0x0126, 0x2091, 0x8000, 0x6254, 0x6074,
-	0x9202, 0x0248, 0x9085, 0x0001, 0x080c, 0x28a9, 0x080c, 0x5906,
-	0x012e, 0x0804, 0x3526, 0x012e, 0x0804, 0x355b, 0x0006, 0x0016,
-	0x00c6, 0x00e6, 0x2001, 0x19a8, 0x2070, 0x2061, 0x1847, 0x6008,
-	0x2072, 0x900e, 0x2011, 0x1400, 0x080c, 0x8f51, 0x7206, 0x00ee,
-	0x00ce, 0x001e, 0x000e, 0x0005, 0x0126, 0x2091, 0x8000, 0x81ff,
-	0x0128, 0x012e, 0x2021, 0x400b, 0x0804, 0x3528, 0x7884, 0xd0fc,
-	0x0148, 0x2001, 0x002a, 0x2004, 0x9082, 0x00e1, 0x0288, 0x012e,
-	0x0804, 0x355b, 0x2001, 0x002a, 0x2004, 0x2069, 0x1847, 0x6908,
-	0x9102, 0x1230, 0x012e, 0x0804, 0x355b, 0x012e, 0x0804, 0x3558,
-	0x080c, 0xaddb, 0x0dd0, 0x7884, 0xd0fc, 0x0904, 0x3ad7, 0x00c6,
-	0x080c, 0x4ab4, 0x00ce, 0x0d88, 0xa867, 0x0000, 0x7884, 0xa80a,
-	0x7898, 0xa80e, 0x789c, 0xa812, 0x2001, 0x002e, 0x2004, 0xa81a,
-	0x2001, 0x002f, 0x2004, 0xa81e, 0x2001, 0x0030, 0x2004, 0xa822,
-	0x2001, 0x0031, 0x2004, 0xa826, 0x2001, 0x0034, 0x2004, 0xa82a,
-	0x2001, 0x0035, 0x2004, 0xa82e, 0x2001, 0x002a, 0x2004, 0x9080,
-	0x0003, 0x9084, 0x00fc, 0x8004, 0xa816, 0x080c, 0x3c5d, 0x0928,
-	0x7014, 0x2048, 0xad2c, 0xac28, 0xab1c, 0xaa18, 0xa930, 0xa808,
-	0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021, 0x0000, 0x8906, 0x8006,
-	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x080c,
-	0x4afd, 0x701f, 0x3b9a, 0x7023, 0x0001, 0x012e, 0x0005, 0x0046,
-	0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
-	0x080c, 0x3a46, 0x2001, 0x199e, 0x2003, 0x0000, 0x2021, 0x000a,
-	0x2061, 0x0100, 0x6104, 0x0016, 0x60bb, 0x0000, 0x60bf, 0x32e1,
-	0x60bf, 0x0012, 0x080c, 0x3ccc, 0x080c, 0x3c8b, 0x00f6, 0x00e6,
-	0x0086, 0x2940, 0x2071, 0x1a65, 0x2079, 0x0090, 0x00d6, 0x2069,
-	0x0000, 0x6884, 0xd0b4, 0x0140, 0x2001, 0x0035, 0x2004, 0x780e,
-	0x2001, 0x0034, 0x2004, 0x780a, 0x00de, 0x2011, 0x0001, 0x080c,
-	0x405f, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3f8c, 0x080c, 0x3e91,
-	0x05b8, 0x2001, 0x020b, 0x2004, 0x9084, 0x0140, 0x1db8, 0x080c,
-	0x40d3, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe, 0x908c, 0x0070,
-	0x1560, 0x2071, 0x0200, 0x7037, 0x0000, 0x7050, 0x9084, 0xff00,
-	0x9086, 0x3200, 0x1510, 0x7037, 0x0001, 0x7050, 0x9084, 0xff00,
-	0x9086, 0xe100, 0x11d0, 0x7037, 0x0000, 0x7054, 0x7037, 0x0000,
-	0x715c, 0x9106, 0x1190, 0x2001, 0x1820, 0x2004, 0x9106, 0x1168,
-	0x00c6, 0x2061, 0x0100, 0x6024, 0x9084, 0x1e00, 0x00ce, 0x0138,
-	0x080c, 0x3e9b, 0x080c, 0x3c86, 0x0058, 0x080c, 0x3c86, 0x080c,
-	0x3ff7, 0x080c, 0x3f82, 0x2001, 0x020b, 0x2004, 0xd0e4, 0x0dd8,
-	0x2001, 0x032a, 0x2003, 0x0004, 0x2061, 0x0100, 0x6027, 0x0002,
-	0x001e, 0x6106, 0x2011, 0x020d, 0x2013, 0x0020, 0x60bb, 0x0000,
-	0x60bf, 0x0108, 0x60bf, 0x0012, 0x2001, 0x0004, 0x200c, 0x918c,
-	0xfffd, 0x2102, 0x080c, 0x12ed, 0x2009, 0x0028, 0x080c, 0x23d4,
-	0x2001, 0x0227, 0x200c, 0x2102, 0x00fe, 0x00ee, 0x00de, 0x00ce,
-	0x00be, 0x00ae, 0x009e, 0x008e, 0x004e, 0x2001, 0x199e, 0x2004,
-	0x9005, 0x1118, 0x012e, 0x0804, 0x3526, 0x012e, 0x2021, 0x400c,
-	0x0804, 0x3528, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0076,
-	0x0086, 0x0096, 0x00d6, 0x0156, 0x7014, 0x2048, 0x7020, 0x20a8,
-	0x8000, 0x7022, 0xa804, 0x9005, 0x0904, 0x3bf6, 0x2048, 0x1f04,
-	0x3baa, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494, 0xa598, 0xa930,
-	0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021, 0x0000, 0x0096,
-	0x7014, 0x2048, 0xa864, 0x009e, 0x9086, 0x0103, 0x0170, 0x8906,
-	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b,
-	0x080c, 0x4afd, 0x701f, 0x3b9a, 0x00b0, 0x8906, 0x8006, 0x8007,
-	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x21a8, 0x27e0,
-	0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c, 0x0f7c, 0x000e, 0x080c,
-	0x4b00, 0x701f, 0x3b9a, 0x015e, 0x00de, 0x009e, 0x008e, 0x007e,
-	0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005, 0x7014, 0x2048,
-	0xa864, 0x9086, 0x0103, 0x1118, 0x701f, 0x3c5b, 0x0450, 0x7014,
-	0x2048, 0xa868, 0xc0fd, 0xa86a, 0x2009, 0x007f, 0x080c, 0x65a7,
-	0x0110, 0x9006, 0x0030, 0xb813, 0x00ff, 0xb817, 0xfffd, 0x080c,
-	0xd013, 0x015e, 0x00de, 0x009e, 0x008e, 0x007e, 0x005e, 0x004e,
-	0x003e, 0x002e, 0x001e, 0x0904, 0x3558, 0x0016, 0x0026, 0x0036,
-	0x0046, 0x0056, 0x0076, 0x0086, 0x0096, 0x00d6, 0x0156, 0x701f,
-	0x3c2d, 0x7007, 0x0003, 0x0804, 0x3beb, 0xa830, 0x9086, 0x0100,
-	0x2021, 0x400c, 0x0904, 0x3528, 0x0076, 0xad10, 0xac0c, 0xab24,
-	0xaa20, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021,
+	0x8000, 0x8000, 0x2071, 0x189e, 0x7003, 0x0002, 0x9006, 0x7016,
+	0x701a, 0x704a, 0x704e, 0x700e, 0x7042, 0x7046, 0x703b, 0x18ba,
+	0x703f, 0x18ba, 0x7007, 0x0001, 0x080c, 0x1018, 0x090c, 0x0dd5,
+	0x2900, 0x706a, 0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x080c, 0x1018,
+	0x090c, 0x0dd5, 0x2900, 0x706e, 0xa867, 0x0002, 0xa8ab, 0xdcb0,
+	0x0005, 0x2071, 0x189e, 0x7004, 0x0002, 0x3461, 0x3462, 0x3475,
+	0x3489, 0x0005, 0x1004, 0x3472, 0x0e04, 0x3472, 0x2079, 0x0000,
+	0x0126, 0x2091, 0x8000, 0x700c, 0x9005, 0x1128, 0x700f, 0x0001,
+	0x012e, 0x0468, 0x0005, 0x012e, 0x0ce8, 0x2079, 0x0000, 0x2061,
+	0x18b8, 0x2c4c, 0xa86c, 0x908e, 0x0100, 0x0128, 0x9086, 0x0200,
+	0x0904, 0x355d, 0x0005, 0x7018, 0x2048, 0x2061, 0x1800, 0x701c,
+	0x0807, 0x7014, 0x2048, 0xa864, 0x9094, 0x00ff, 0x9296, 0x0029,
+	0x1120, 0xaa78, 0xd2fc, 0x0128, 0x0005, 0x9086, 0x0103, 0x0108,
+	0x0005, 0x2079, 0x0000, 0x2061, 0x1800, 0x701c, 0x0807, 0x2061,
+	0x1800, 0x7880, 0x908a, 0x0040, 0x1210, 0x61d0, 0x0042, 0x2100,
+	0x908a, 0x003f, 0x1a04, 0x355a, 0x61d0, 0x0804, 0x34ef, 0x3531,
+	0x3569, 0x355a, 0x3573, 0x357d, 0x3583, 0x3587, 0x3597, 0x359b,
+	0x35b1, 0x35b7, 0x35bd, 0x35c8, 0x35d3, 0x35e2, 0x35f1, 0x35ff,
+	0x3616, 0x3631, 0x355a, 0x36da, 0x3718, 0x37be, 0x37cf, 0x37f2,
+	0x355a, 0x355a, 0x355a, 0x382a, 0x3846, 0x384f, 0x387e, 0x3884,
+	0x355a, 0x38ca, 0x355a, 0x355a, 0x355a, 0x355a, 0x355a, 0x38d5,
+	0x38de, 0x38e6, 0x38e8, 0x355a, 0x355a, 0x355a, 0x355a, 0x355a,
+	0x355a, 0x3914, 0x355a, 0x355a, 0x355a, 0x355a, 0x355a, 0x3931,
+	0x3992, 0x355a, 0x355a, 0x355a, 0x355a, 0x355a, 0x355a, 0x0002,
+	0x39bc, 0x39bf, 0x3a1e, 0x3a37, 0x3a67, 0x3d05, 0x355a, 0x52bb,
+	0x355a, 0x355a, 0x355a, 0x355a, 0x355a, 0x355a, 0x355a, 0x355a,
+	0x35b1, 0x35b7, 0x4226, 0x5706, 0x4244, 0x534a, 0x539b, 0x549e,
+	0x355a, 0x5500, 0x553c, 0x556d, 0x5671, 0x559a, 0x55f1, 0x355a,
+	0x4248, 0x4409, 0x441f, 0x4444, 0x44a9, 0x451d, 0x453d, 0x45b4,
+	0x4610, 0x466c, 0x466f, 0x4694, 0x4730, 0x4796, 0x479e, 0x48d0,
+	0x4a48, 0x4a7c, 0x4ce0, 0x355a, 0x4cfe, 0x4da3, 0x4e85, 0x4edf,
+	0x355a, 0x4f94, 0x355a, 0x4ffa, 0x5015, 0x479e, 0x525b, 0x714c,
+	0x0000, 0x2021, 0x4000, 0x080c, 0x4afa, 0x0126, 0x2091, 0x8000,
+	0x0e04, 0x353b, 0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000,
+	0x0118, 0x7833, 0x0011, 0x0010, 0x7833, 0x0010, 0x7c82, 0x7986,
+	0x7a8a, 0x7b8e, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x119b, 0x7007, 0x0001, 0x2091, 0x5000, 0x700f, 0x0000,
+	0x012e, 0x0005, 0x2021, 0x4001, 0x08b0, 0x2021, 0x4002, 0x0898,
+	0x2021, 0x4003, 0x0880, 0x2021, 0x4005, 0x0868, 0x2021, 0x4006,
+	0x0850, 0x2039, 0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884,
+	0x7990, 0x0804, 0x4b07, 0x2039, 0x0001, 0x902e, 0x2520, 0x7b88,
+	0x7a8c, 0x7884, 0x7990, 0x0804, 0x4b0a, 0x7984, 0x7888, 0x2114,
+	0x200a, 0x0804, 0x3531, 0x7984, 0x2114, 0x0804, 0x3531, 0x20e1,
+	0x0000, 0x2099, 0x0021, 0x20e9, 0x0000, 0x20a1, 0x0021, 0x20a9,
+	0x001f, 0x4003, 0x7984, 0x7a88, 0x7b8c, 0x0804, 0x3531, 0x7884,
+	0x2060, 0x0804, 0x35e4, 0x2009, 0x0003, 0x2011, 0x0003, 0x2019,
+	0x0002, 0x789b, 0x0137, 0x7893, 0xffff, 0x2001, 0x188f, 0x2004,
+	0x9005, 0x0118, 0x7896, 0x0804, 0x3531, 0x7897, 0x0001, 0x0804,
+	0x3531, 0x2039, 0x0001, 0x7d98, 0x7c9c, 0x0804, 0x356d, 0x2039,
+	0x0001, 0x7d98, 0x7c9c, 0x0804, 0x3577, 0x79a0, 0x9182, 0x0040,
+	0x0210, 0x0804, 0x3566, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x356d,
+	0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x3566, 0x2138, 0x7d98,
+	0x7c9c, 0x0804, 0x3577, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804,
+	0x3566, 0x21e8, 0x7984, 0x7888, 0x20a9, 0x0001, 0x21a0, 0x4004,
+	0x0804, 0x3531, 0x2061, 0x0800, 0xe10c, 0x9006, 0x2c15, 0x9200,
+	0x8c60, 0x8109, 0x1dd8, 0x2010, 0x9005, 0x0904, 0x3531, 0x0804,
+	0x3560, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x3566, 0x21e0,
+	0x20a9, 0x0001, 0x7984, 0x2198, 0x4012, 0x0804, 0x3531, 0x2069,
+	0x1847, 0x7884, 0x7990, 0x911a, 0x1a04, 0x3566, 0x8019, 0x0904,
+	0x3566, 0x684a, 0x6942, 0x788c, 0x6852, 0x7888, 0x6856, 0x9006,
+	0x685a, 0x685e, 0x080c, 0x76ca, 0x0804, 0x3531, 0x2069, 0x1847,
+	0x7884, 0x7994, 0x911a, 0x1a04, 0x3566, 0x8019, 0x0904, 0x3566,
+	0x684e, 0x6946, 0x788c, 0x6862, 0x7888, 0x6866, 0x9006, 0x686a,
+	0x686e, 0x0126, 0x2091, 0x8000, 0x080c, 0x69ef, 0x012e, 0x0804,
+	0x3531, 0x902e, 0x2520, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804,
+	0x3563, 0x7984, 0x7b88, 0x7a8c, 0x20a9, 0x0005, 0x20e9, 0x0001,
+	0x20a1, 0x18a6, 0x4101, 0x080c, 0x4abe, 0x1120, 0x2009, 0x0002,
+	0x0804, 0x3563, 0x2009, 0x0020, 0xa85c, 0x9080, 0x0019, 0xaf60,
+	0x080c, 0x4b07, 0x701f, 0x3655, 0x0005, 0xa864, 0x2008, 0x9084,
+	0x00ff, 0x9096, 0x0011, 0x0168, 0x9096, 0x0019, 0x0150, 0x9096,
+	0x0015, 0x0138, 0x9096, 0x0048, 0x0120, 0x9096, 0x0029, 0x1904,
+	0x3563, 0x810f, 0x918c, 0x00ff, 0x0904, 0x3563, 0x7112, 0x7010,
+	0x8001, 0x0560, 0x7012, 0x080c, 0x4abe, 0x1120, 0x2009, 0x0002,
+	0x0804, 0x3563, 0x2009, 0x0020, 0x7068, 0x2040, 0xa28c, 0xa390,
+	0xa494, 0xa598, 0x9290, 0x0040, 0x9399, 0x0000, 0x94a1, 0x0000,
+	0x95a9, 0x0000, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x4b07,
+	0x701f, 0x3693, 0x0005, 0xa864, 0x9084, 0x00ff, 0x9096, 0x0002,
+	0x0120, 0x9096, 0x000a, 0x1904, 0x3563, 0x0888, 0x7014, 0x2048,
+	0xa868, 0xc0fd, 0xa86a, 0xa864, 0x9084, 0x00ff, 0x9096, 0x0029,
+	0x1160, 0xc2fd, 0xaa7a, 0x080c, 0x619e, 0x0150, 0x0126, 0x2091,
+	0x8000, 0xa87a, 0xa982, 0x012e, 0x0050, 0x080c, 0x64cb, 0x1128,
+	0x7007, 0x0003, 0x701f, 0x36bf, 0x0005, 0x080c, 0x6ec7, 0x0126,
+	0x2091, 0x8000, 0x20a9, 0x0005, 0x20e1, 0x0001, 0x2099, 0x18a6,
+	0x400a, 0x2100, 0x9210, 0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9,
+	0x0000, 0xa85c, 0x9080, 0x0019, 0x2009, 0x0020, 0x012e, 0xaf60,
+	0x0804, 0x4b0a, 0x2091, 0x8000, 0x7837, 0x4000, 0x7833, 0x0010,
+	0x7883, 0x4000, 0x7887, 0x4953, 0x788b, 0x5020, 0x788f, 0x2020,
+	0x2009, 0x017f, 0x2104, 0x7892, 0x3f00, 0x7896, 0x2061, 0x0100,
+	0x6200, 0x2061, 0x0200, 0x603c, 0x8007, 0x9205, 0x789a, 0x2009,
+	0x04fd, 0x2104, 0x789e, 0x2091, 0x5000, 0x2091, 0x4080, 0x2001,
+	0x0089, 0x2004, 0xd084, 0x0180, 0x2001, 0x1a18, 0x2004, 0x9005,
+	0x0128, 0x2001, 0x008b, 0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a,
+	0x2003, 0x0002, 0x2003, 0x1001, 0x2071, 0x0080, 0x0804, 0x0427,
+	0x81ff, 0x1904, 0x3563, 0x7984, 0x080c, 0x6616, 0x1904, 0x3566,
+	0x7e98, 0x9684, 0x3fff, 0x9082, 0x4000, 0x1a04, 0x3566, 0x7c88,
+	0x7d8c, 0x080c, 0x6779, 0x080c, 0x6748, 0x0000, 0x1518, 0x2061,
+	0x1cd0, 0x0126, 0x2091, 0x8000, 0x6000, 0x9086, 0x0000, 0x0148,
+	0x6014, 0x904d, 0x0130, 0xa86c, 0x9406, 0x1118, 0xa870, 0x9506,
+	0x0150, 0x012e, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004, 0x9c02,
+	0x1a04, 0x3563, 0x0c30, 0x080c, 0xc77b, 0x012e, 0x0904, 0x3563,
+	0x0804, 0x3531, 0x900e, 0x2001, 0x0005, 0x080c, 0x6ec7, 0x0126,
+	0x2091, 0x8000, 0x080c, 0xce54, 0x080c, 0x6c94, 0x012e, 0x0804,
+	0x3531, 0x00a6, 0x2950, 0xb198, 0x080c, 0x6616, 0x1904, 0x37ab,
+	0xb6a4, 0x9684, 0x3fff, 0x9082, 0x4000, 0x16e8, 0xb49c, 0xb5a0,
+	0x080c, 0x6779, 0x080c, 0x6748, 0x1520, 0x2061, 0x1cd0, 0x0126,
+	0x2091, 0x8000, 0x6000, 0x9086, 0x0000, 0x0148, 0x6014, 0x904d,
+	0x0130, 0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0158, 0x012e,
+	0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004, 0x9c02, 0x2009, 0x000d,
+	0x12b0, 0x0c28, 0x080c, 0xc77b, 0x012e, 0x2009, 0x0003, 0x0178,
+	0x00e0, 0x900e, 0x2001, 0x0005, 0x080c, 0x6ec7, 0x0126, 0x2091,
+	0x8000, 0x080c, 0xce54, 0x080c, 0x6c88, 0x012e, 0x0070, 0xb097,
+	0x4005, 0xb19a, 0x0010, 0xb097, 0x4006, 0x900e, 0x9085, 0x0001,
+	0x2001, 0x0030, 0x2a48, 0x00ae, 0x0005, 0xb097, 0x4000, 0x9006,
+	0x918d, 0x0001, 0x2008, 0x2a48, 0x00ae, 0x0005, 0x81ff, 0x1904,
+	0x3563, 0x080c, 0x4ad5, 0x0904, 0x3566, 0x080c, 0x66dd, 0x0904,
+	0x3563, 0x080c, 0x677f, 0x0904, 0x3563, 0x0804, 0x4534, 0x81ff,
+	0x1904, 0x3563, 0x080c, 0x4af1, 0x0904, 0x3566, 0x080c, 0x680d,
+	0x0904, 0x3563, 0x2019, 0x0005, 0x79a8, 0x080c, 0x679a, 0x0904,
+	0x3563, 0x7888, 0x908a, 0x1000, 0x1a04, 0x3566, 0x8003, 0x800b,
+	0x810b, 0x9108, 0x080c, 0x8507, 0x7984, 0xd184, 0x1904, 0x3531,
+	0x0804, 0x4534, 0x0126, 0x2091, 0x8000, 0x81ff, 0x0118, 0x2009,
+	0x0001, 0x0450, 0x2029, 0x07ff, 0x645c, 0x2400, 0x9506, 0x01f8,
+	0x2508, 0x080c, 0x6616, 0x11d8, 0x080c, 0x680d, 0x1128, 0x2009,
+	0x0002, 0x62c0, 0x2518, 0x00c0, 0x2019, 0x0004, 0x900e, 0x080c,
+	0x679a, 0x1118, 0x2009, 0x0006, 0x0078, 0x7884, 0x908a, 0x1000,
+	0x1270, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x8507, 0x8529,
+	0x1ae0, 0x012e, 0x0804, 0x3531, 0x012e, 0x0804, 0x3563, 0x012e,
+	0x0804, 0x3566, 0x080c, 0x4ad5, 0x0904, 0x3566, 0x080c, 0x66dd,
+	0x0904, 0x3563, 0xbaa0, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c,
+	0x929d, 0x0076, 0x903e, 0x080c, 0x9170, 0x900e, 0x080c, 0xe326,
+	0x007e, 0x00ce, 0x080c, 0x6779, 0x0804, 0x3531, 0x080c, 0x4ad5,
+	0x0904, 0x3566, 0x080c, 0x6779, 0x2208, 0x0804, 0x3531, 0x0156,
+	0x00d6, 0x00e6, 0x2069, 0x1910, 0x6810, 0x6914, 0x910a, 0x1208,
+	0x900e, 0x6816, 0x9016, 0x901e, 0x20a9, 0x007e, 0x2069, 0x1000,
+	0x2d04, 0x905d, 0x0118, 0xb84c, 0x0059, 0x9210, 0x8d68, 0x1f04,
+	0x3860, 0x2300, 0x9218, 0x00ee, 0x00de, 0x015e, 0x0804, 0x3531,
+	0x00f6, 0x0016, 0x907d, 0x0138, 0x9006, 0x8000, 0x2f0c, 0x81ff,
+	0x0110, 0x2178, 0x0cd0, 0x001e, 0x00fe, 0x0005, 0x2069, 0x1910,
+	0x6910, 0x62bc, 0x0804, 0x3531, 0x81ff, 0x0120, 0x2009, 0x0001,
+	0x0804, 0x3563, 0x0126, 0x2091, 0x8000, 0x080c, 0x56f6, 0x0128,
+	0x2009, 0x0007, 0x012e, 0x0804, 0x3563, 0x012e, 0x615c, 0x9190,
+	0x3332, 0x2215, 0x9294, 0x00ff, 0x637c, 0x83ff, 0x0108, 0x6280,
+	0x67dc, 0x97c4, 0x000a, 0x98c6, 0x000a, 0x1118, 0x2031, 0x0001,
+	0x00e8, 0x97c4, 0x0022, 0x98c6, 0x0022, 0x1118, 0x2031, 0x0003,
+	0x00a8, 0x97c4, 0x0012, 0x98c6, 0x0012, 0x1118, 0x2031, 0x0002,
+	0x0068, 0x080c, 0x73b3, 0x1118, 0x2031, 0x0004, 0x0038, 0xd79c,
+	0x0120, 0x2009, 0x0005, 0x0804, 0x3563, 0x9036, 0x7e9a, 0x7f9e,
+	0x0804, 0x3531, 0x614c, 0x6250, 0x2019, 0x1985, 0x231c, 0x2001,
+	0x1986, 0x2004, 0x789a, 0x0804, 0x3531, 0x0126, 0x2091, 0x8000,
+	0x6138, 0x623c, 0x6340, 0x012e, 0x0804, 0x3531, 0x080c, 0x4af1,
+	0x0904, 0x3566, 0xba44, 0xbb38, 0x0804, 0x3531, 0x080c, 0x0dd5,
+	0x080c, 0x4af1, 0x2110, 0x0904, 0x3566, 0xb804, 0x908c, 0x00ff,
+	0x918e, 0x0006, 0x0140, 0x9084, 0xff00, 0x9086, 0x0600, 0x2009,
+	0x0009, 0x1904, 0x3563, 0x0126, 0x2091, 0x8000, 0x2019, 0x0005,
+	0x00c6, 0x9066, 0x080c, 0xa7f8, 0x080c, 0x929d, 0x0076, 0x903e,
+	0x080c, 0x9170, 0x900e, 0x080c, 0xe326, 0x007e, 0x00ce, 0xb807,
+	0x0407, 0x012e, 0x0804, 0x3531, 0x614c, 0x6250, 0x7884, 0x604e,
+	0x7b88, 0x6352, 0x2069, 0x1847, 0x831f, 0x9305, 0x6816, 0x788c,
+	0x2069, 0x1985, 0x2d1c, 0x206a, 0x7e98, 0x9682, 0x0014, 0x1210,
+	0x2031, 0x07d0, 0x2069, 0x1986, 0x2d04, 0x266a, 0x789a, 0x0804,
+	0x3531, 0x0126, 0x2091, 0x8000, 0x7884, 0x603a, 0xd0c4, 0x01a8,
+	0x00d6, 0x78a8, 0x2009, 0x199c, 0x200a, 0x78ac, 0x2011, 0x199d,
+	0x2012, 0x2069, 0x0100, 0x6838, 0x9086, 0x0007, 0x1118, 0x2214,
+	0x6a5a, 0x0010, 0x210c, 0x695a, 0x00de, 0x7884, 0xd0b4, 0x0120,
+	0x3b00, 0x9084, 0xff3f, 0x20d8, 0x7888, 0x603e, 0x2011, 0x0114,
+	0x220c, 0x7888, 0xd08c, 0x0118, 0x918d, 0x0080, 0x0010, 0x918c,
+	0xff7f, 0x2112, 0x788c, 0x6042, 0x9084, 0x0020, 0x0130, 0x78b4,
+	0x6046, 0x9084, 0x0001, 0x090c, 0x4226, 0x6040, 0xd0cc, 0x0120,
+	0x78b0, 0x2011, 0x0114, 0x2012, 0x012e, 0x0804, 0x3531, 0x00f6,
+	0x2079, 0x1800, 0x7a38, 0xa898, 0x9084, 0xfebf, 0x9215, 0xa89c,
+	0x9084, 0xfebf, 0x8002, 0x9214, 0x7838, 0x9084, 0x0140, 0x9215,
+	0x7a3a, 0xa897, 0x4000, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000,
+	0x00fe, 0x0005, 0x7898, 0x9005, 0x01a8, 0x7888, 0x9025, 0x0904,
+	0x3566, 0x788c, 0x902d, 0x0904, 0x3566, 0x900e, 0x080c, 0x6616,
+	0x1120, 0xba44, 0xbb38, 0xbc46, 0xbd3a, 0x9186, 0x07ff, 0x0190,
+	0x8108, 0x0ca0, 0x080c, 0x4af1, 0x0904, 0x3566, 0x7888, 0x900d,
+	0x0904, 0x3566, 0x788c, 0x9005, 0x0904, 0x3566, 0xba44, 0xb946,
+	0xbb38, 0xb83a, 0x0804, 0x3531, 0x2011, 0xbc09, 0x0010, 0x2011,
+	0xbc05, 0x080c, 0x56f6, 0x1904, 0x3563, 0x00c6, 0x2061, 0x0100,
+	0x7984, 0x9186, 0x00ff, 0x1130, 0x2001, 0x1818, 0x2004, 0x9085,
+	0xff00, 0x0088, 0x9182, 0x007f, 0x16e0, 0x9188, 0x3332, 0x210d,
+	0x918c, 0x00ff, 0x2001, 0x1818, 0x2004, 0x0026, 0x9116, 0x002e,
+	0x0580, 0x810f, 0x9105, 0x0126, 0x2091, 0x8000, 0x0006, 0x080c,
+	0xae09, 0x000e, 0x0510, 0x602e, 0x620a, 0x7984, 0x00b6, 0x080c,
+	0x65bb, 0x2b08, 0x00be, 0x1500, 0x6112, 0x6023, 0x0001, 0x080c,
+	0x4abe, 0x01d0, 0x9006, 0xa866, 0x7007, 0x0003, 0xa832, 0xa868,
+	0xc0fd, 0xa86a, 0x701f, 0x3a17, 0x2900, 0x6016, 0x2009, 0x0032,
+	0x080c, 0xaeda, 0x012e, 0x00ce, 0x0005, 0x012e, 0x00ce, 0x0804,
+	0x3563, 0x00ce, 0x0804, 0x3566, 0x080c, 0xae5f, 0x0cb0, 0xa830,
+	0x9086, 0x0100, 0x0904, 0x3563, 0x0804, 0x3531, 0x2061, 0x1a70,
+	0x0126, 0x2091, 0x8000, 0x6000, 0xd084, 0x0170, 0x6104, 0x6208,
+	0x2061, 0x1800, 0x6354, 0x6074, 0x789a, 0x60c0, 0x789e, 0x60bc,
+	0x78aa, 0x012e, 0x0804, 0x3531, 0x900e, 0x2110, 0x0c88, 0x81ff,
+	0x1904, 0x3563, 0x080c, 0x73b3, 0x0904, 0x3563, 0x0126, 0x2091,
+	0x8000, 0x6254, 0x6074, 0x9202, 0x0248, 0x9085, 0x0001, 0x080c,
+	0x28b4, 0x080c, 0x5910, 0x012e, 0x0804, 0x3531, 0x012e, 0x0804,
+	0x3566, 0x0006, 0x0016, 0x00c6, 0x00e6, 0x2001, 0x19a8, 0x2070,
+	0x2061, 0x1847, 0x6008, 0x2072, 0x900e, 0x2011, 0x1400, 0x080c,
+	0x8f70, 0x7206, 0x00ee, 0x00ce, 0x001e, 0x000e, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x81ff, 0x0128, 0x012e, 0x2021, 0x400b, 0x0804,
+	0x3533, 0x7884, 0xd0fc, 0x0148, 0x2001, 0x002a, 0x2004, 0x9082,
+	0x00e1, 0x0288, 0x012e, 0x0804, 0x3566, 0x2001, 0x002a, 0x2004,
+	0x2069, 0x1847, 0x6908, 0x9102, 0x1230, 0x012e, 0x0804, 0x3566,
+	0x012e, 0x0804, 0x3563, 0x080c, 0xadc9, 0x0dd0, 0x7884, 0xd0fc,
+	0x0904, 0x3ae2, 0x00c6, 0x080c, 0x4abe, 0x00ce, 0x0d88, 0xa867,
+	0x0000, 0x7884, 0xa80a, 0x7898, 0xa80e, 0x789c, 0xa812, 0x2001,
+	0x002e, 0x2004, 0xa81a, 0x2001, 0x002f, 0x2004, 0xa81e, 0x2001,
+	0x0030, 0x2004, 0xa822, 0x2001, 0x0031, 0x2004, 0xa826, 0x2001,
+	0x0034, 0x2004, 0xa82a, 0x2001, 0x0035, 0x2004, 0xa82e, 0x2001,
+	0x002a, 0x2004, 0x9080, 0x0003, 0x9084, 0x00fc, 0x8004, 0xa816,
+	0x080c, 0x3c68, 0x0928, 0x7014, 0x2048, 0xad2c, 0xac28, 0xab1c,
+	0xaa18, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021,
 	0x0000, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
-	0x9080, 0x001b, 0x21a8, 0x27e0, 0x2098, 0x27e8, 0x20a0, 0x0006,
-	0x080c, 0x0f7c, 0x000e, 0x080c, 0x4b00, 0x007e, 0x701f, 0x3b9a,
-	0x7023, 0x0001, 0x0005, 0x0804, 0x3526, 0x0156, 0x00c6, 0xa814,
-	0x908a, 0x001e, 0x0218, 0xa833, 0x001e, 0x0010, 0xa832, 0x0078,
-	0x81ff, 0x0168, 0x0016, 0x080c, 0x4ab4, 0x001e, 0x0130, 0xa800,
-	0x2040, 0xa008, 0xa80a, 0x2100, 0x0c58, 0x9006, 0x0010, 0x9085,
-	0x0001, 0x00ce, 0x015e, 0x0005, 0x0006, 0x00f6, 0x2079, 0x0000,
-	0x7880, 0x9086, 0x0044, 0x00fe, 0x000e, 0x0005, 0x2001, 0x199e,
-	0x2003, 0x0001, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x2061, 0x0200,
-	0x2001, 0x19a9, 0x2004, 0x601a, 0x2061, 0x0100, 0x2001, 0x19a8,
-	0x2004, 0x60ce, 0x6104, 0xc1ac, 0x6106, 0x080c, 0x4ab4, 0xa813,
-	0x0019, 0xa817, 0x0001, 0x2900, 0xa85a, 0x2001, 0x002e, 0x2004,
-	0xa866, 0x2001, 0x002f, 0x2004, 0xa86a, 0x2061, 0x0090, 0x2079,
-	0x0100, 0x2001, 0x19a8, 0x2004, 0x6036, 0x2009, 0x0040, 0x080c,
-	0x23d4, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e, 0x601a,
-	0xa873, 0x0000, 0x601f, 0x0000, 0x78ca, 0x9006, 0x600a, 0x600e,
-	0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00e6, 0x080c, 0x4ab4, 0x2940,
-	0xa013, 0x0019, 0xa017, 0x0001, 0x2800, 0xa05a, 0x2001, 0x0030,
-	0x2004, 0xa866, 0x2001, 0x0031, 0x2004, 0xa86a, 0x2001, 0x002a,
-	0x2004, 0x9084, 0xfff8, 0xa86e, 0xa873, 0x0000, 0x2001, 0x032a,
-	0x2003, 0x0004, 0x2001, 0x0300, 0x2003, 0x0000, 0x2001, 0x020d,
-	0x2003, 0x0000, 0x2001, 0x0004, 0x200c, 0x918d, 0x0002, 0x2102,
-	0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x81ff, 0x0148, 0x080c,
-	0x2c32, 0x1130, 0x9006, 0x080c, 0x2b8a, 0x9006, 0x080c, 0x2b6d,
-	0x7884, 0x9084, 0x0007, 0x0002, 0x3d17, 0x3d20, 0x3d29, 0x3d14,
-	0x3d14, 0x3d14, 0x3d14, 0x3d14, 0x012e, 0x0804, 0x355b, 0x2009,
-	0x0114, 0x2104, 0x9085, 0x0800, 0x200a, 0x080c, 0x3ee5, 0x00c0,
-	0x2009, 0x0114, 0x2104, 0x9085, 0x4000, 0x200a, 0x080c, 0x3ee5,
-	0x0078, 0x080c, 0x73a5, 0x1128, 0x012e, 0x2009, 0x0016, 0x0804,
-	0x3558, 0x81ff, 0x0128, 0x012e, 0x2021, 0x400b, 0x0804, 0x3528,
-	0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
-	0x080c, 0x3a46, 0x2009, 0x0101, 0x210c, 0x0016, 0x7ec8, 0x7dcc,
-	0x9006, 0x2068, 0x2060, 0x2058, 0x080c, 0x41ae, 0x080c, 0x40fe,
-	0x903e, 0x2720, 0x00f6, 0x00e6, 0x0086, 0x2940, 0x2071, 0x1a65,
-	0x2079, 0x0090, 0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120,
-	0x68d4, 0x780e, 0x68d0, 0x780a, 0x00de, 0x2011, 0x0001, 0x080c,
-	0x405f, 0x080c, 0x2c3a, 0x080c, 0x2c3a, 0x080c, 0x2c3a, 0x080c,
-	0x2c3a, 0x080c, 0x405f, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3f8c,
-	0x2009, 0x9c40, 0x8109, 0x11b0, 0x080c, 0x3e9b, 0x2001, 0x0004,
-	0x200c, 0x918c, 0xfffd, 0x2102, 0x001e, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e, 0x2009, 0x0017, 0x080c,
-	0x3558, 0x0cf8, 0x2001, 0x020b, 0x2004, 0x9084, 0x0140, 0x1d10,
-	0x00f6, 0x2079, 0x0000, 0x7884, 0x00fe, 0xd0bc, 0x0178, 0x2001,
-	0x0201, 0x200c, 0x81ff, 0x0150, 0x080c, 0x3f6a, 0x2d00, 0x9c05,
-	0x9b05, 0x0120, 0x080c, 0x3e9b, 0x0804, 0x3e48, 0x080c, 0x40d3,
-	0x080c, 0x3ff7, 0x080c, 0x3f4d, 0x080c, 0x3f82, 0x00f6, 0x2079,
-	0x0100, 0x7824, 0xd0ac, 0x0130, 0x8b58, 0x080c, 0x3e9b, 0x00fe,
-	0x0804, 0x3e48, 0x00fe, 0x080c, 0x3e91, 0x1150, 0x8d68, 0x2001,
-	0x0032, 0x2602, 0x2001, 0x0033, 0x2502, 0x080c, 0x3e9b, 0x0080,
-	0x87ff, 0x0138, 0x2001, 0x0201, 0x2004, 0x9005, 0x1908, 0x8739,
-	0x0038, 0x2001, 0x1a61, 0x2004, 0x9086, 0x0000, 0x1904, 0x3d98,
-	0x2001, 0x032f, 0x2003, 0x00f6, 0x8631, 0x1208, 0x8529, 0x2500,
-	0x9605, 0x0904, 0x3e48, 0x7884, 0xd0bc, 0x0128, 0x2d00, 0x9c05,
-	0x9b05, 0x1904, 0x3e48, 0xa013, 0x0019, 0x2001, 0x032a, 0x2003,
-	0x0004, 0x7884, 0xd0ac, 0x1148, 0x2001, 0x1a61, 0x2003, 0x0003,
-	0x2001, 0x032a, 0x2003, 0x0009, 0x0030, 0xa017, 0x0001, 0x78b4,
-	0x9005, 0x0108, 0xa016, 0x2800, 0xa05a, 0x2009, 0x0040, 0x080c,
-	0x23d4, 0x2900, 0xa85a, 0xa813, 0x0019, 0x7884, 0xd0a4, 0x1180,
-	0xa817, 0x0000, 0x00c6, 0x20a9, 0x0004, 0x2061, 0x0090, 0x602b,
-	0x0008, 0x2001, 0x0203, 0x2004, 0x1f04, 0x3e1f, 0x00ce, 0x0030,
-	0xa817, 0x0001, 0x78b0, 0x9005, 0x0108, 0xa816, 0x00f6, 0x00c6,
-	0x2079, 0x0100, 0x2061, 0x0090, 0x7827, 0x0002, 0x2001, 0x002a,
-	0x2004, 0x9084, 0xfff8, 0x601a, 0x0006, 0x2001, 0x002b, 0x2004,
-	0x601e, 0x78c6, 0x000e, 0x78ca, 0x00ce, 0x00fe, 0x0804, 0x3d52,
-	0x001e, 0x00c6, 0x2001, 0x032a, 0x2003, 0x0004, 0x2061, 0x0100,
-	0x6027, 0x0002, 0x6106, 0x2011, 0x020d, 0x2013, 0x0020, 0x2001,
-	0x0004, 0x200c, 0x918c, 0xfffd, 0x2102, 0x080c, 0x12ed, 0x7884,
-	0x9084, 0x0003, 0x9086, 0x0002, 0x01a0, 0x2009, 0x0028, 0x080c,
-	0x23d4, 0x2001, 0x0227, 0x200c, 0x2102, 0x6050, 0x9084, 0xb7ef,
-	0x6052, 0x602f, 0x0000, 0x604b, 0xf7f7, 0x6043, 0x0090, 0x6043,
-	0x0010, 0x00ce, 0x2d08, 0x2c10, 0x2b18, 0x2b00, 0x9c05, 0x9d05,
+	0x9080, 0x001b, 0x080c, 0x4b07, 0x701f, 0x3ba5, 0x7023, 0x0001,
+	0x012e, 0x0005, 0x0046, 0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6,
+	0x00d6, 0x00e6, 0x00f6, 0x080c, 0x3a51, 0x2001, 0x199e, 0x2003,
+	0x0000, 0x2021, 0x000a, 0x2061, 0x0100, 0x6104, 0x0016, 0x60bb,
+	0x0000, 0x60bf, 0x32e1, 0x60bf, 0x0012, 0x080c, 0x3cd7, 0x080c,
+	0x3c96, 0x00f6, 0x00e6, 0x0086, 0x2940, 0x2071, 0x1a65, 0x2079,
+	0x0090, 0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0140, 0x2001,
+	0x0035, 0x2004, 0x780e, 0x2001, 0x0034, 0x2004, 0x780a, 0x00de,
+	0x2011, 0x0001, 0x080c, 0x406a, 0x008e, 0x00ee, 0x00fe, 0x080c,
+	0x3f97, 0x080c, 0x3e9c, 0x05b8, 0x2001, 0x020b, 0x2004, 0x9084,
+	0x0140, 0x1db8, 0x080c, 0x40de, 0x00f6, 0x2079, 0x0300, 0x78bc,
+	0x00fe, 0x908c, 0x0070, 0x1560, 0x2071, 0x0200, 0x7037, 0x0000,
+	0x7050, 0x9084, 0xff00, 0x9086, 0x3200, 0x1510, 0x7037, 0x0001,
+	0x7050, 0x9084, 0xff00, 0x9086, 0xe100, 0x11d0, 0x7037, 0x0000,
+	0x7054, 0x7037, 0x0000, 0x715c, 0x9106, 0x1190, 0x2001, 0x1820,
+	0x2004, 0x9106, 0x1168, 0x00c6, 0x2061, 0x0100, 0x6024, 0x9084,
+	0x1e00, 0x00ce, 0x0138, 0x080c, 0x3ea6, 0x080c, 0x3c91, 0x0058,
+	0x080c, 0x3c91, 0x080c, 0x4002, 0x080c, 0x3f8d, 0x2001, 0x020b,
+	0x2004, 0xd0e4, 0x0dd8, 0x2001, 0x032a, 0x2003, 0x0004, 0x2061,
+	0x0100, 0x6027, 0x0002, 0x001e, 0x6106, 0x2011, 0x020d, 0x2013,
+	0x0020, 0x60bb, 0x0000, 0x60bf, 0x0108, 0x60bf, 0x0012, 0x2001,
+	0x0004, 0x200c, 0x918c, 0xfffd, 0x2102, 0x080c, 0x12ed, 0x2009,
+	0x0028, 0x080c, 0x23df, 0x2001, 0x0227, 0x200c, 0x2102, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e, 0x004e,
+	0x2001, 0x199e, 0x2004, 0x9005, 0x1118, 0x012e, 0x0804, 0x3531,
+	0x012e, 0x2021, 0x400c, 0x0804, 0x3533, 0x0016, 0x0026, 0x0036,
+	0x0046, 0x0056, 0x0076, 0x0086, 0x0096, 0x00d6, 0x0156, 0x7014,
+	0x2048, 0x7020, 0x20a8, 0x8000, 0x7022, 0xa804, 0x9005, 0x0904,
+	0x3c01, 0x2048, 0x1f04, 0x3bb5, 0x7068, 0x2040, 0xa28c, 0xa390,
+	0xa494, 0xa598, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000,
+	0x2021, 0x0000, 0x0096, 0x7014, 0x2048, 0xa864, 0x009e, 0x9086,
+	0x0103, 0x0170, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
+	0xffc0, 0x9080, 0x001b, 0x080c, 0x4b07, 0x701f, 0x3ba5, 0x00b0,
+	0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
+	0x001b, 0x21a8, 0x27e0, 0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c,
+	0x0f7c, 0x000e, 0x080c, 0x4b0a, 0x701f, 0x3ba5, 0x015e, 0x00de,
+	0x009e, 0x008e, 0x007e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e,
+	0x0005, 0x7014, 0x2048, 0xa864, 0x9086, 0x0103, 0x1118, 0x701f,
+	0x3c66, 0x0450, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a, 0x2009,
+	0x007f, 0x080c, 0x65b5, 0x0110, 0x9006, 0x0030, 0xb813, 0x00ff,
+	0xb817, 0xfffd, 0x080c, 0xd023, 0x015e, 0x00de, 0x009e, 0x008e,
+	0x007e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0904, 0x3563,
+	0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0076, 0x0086, 0x0096,
+	0x00d6, 0x0156, 0x701f, 0x3c38, 0x7007, 0x0003, 0x0804, 0x3bf6,
+	0xa830, 0x9086, 0x0100, 0x2021, 0x400c, 0x0904, 0x3533, 0x0076,
+	0xad10, 0xac0c, 0xab24, 0xaa20, 0xa930, 0xa808, 0xd0b4, 0x1120,
+	0x2029, 0x0000, 0x2021, 0x0000, 0x8906, 0x8006, 0x8007, 0x90bc,
+	0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x21a8, 0x27e0, 0x2098,
+	0x27e8, 0x20a0, 0x0006, 0x080c, 0x0f7c, 0x000e, 0x080c, 0x4b0a,
+	0x007e, 0x701f, 0x3ba5, 0x7023, 0x0001, 0x0005, 0x0804, 0x3531,
+	0x0156, 0x00c6, 0xa814, 0x908a, 0x001e, 0x0218, 0xa833, 0x001e,
+	0x0010, 0xa832, 0x0078, 0x81ff, 0x0168, 0x0016, 0x080c, 0x4abe,
+	0x001e, 0x0130, 0xa800, 0x2040, 0xa008, 0xa80a, 0x2100, 0x0c58,
+	0x9006, 0x0010, 0x9085, 0x0001, 0x00ce, 0x015e, 0x0005, 0x0006,
+	0x00f6, 0x2079, 0x0000, 0x7880, 0x9086, 0x0044, 0x00fe, 0x000e,
+	0x0005, 0x2001, 0x199e, 0x2003, 0x0001, 0x0005, 0x00f6, 0x00e6,
+	0x00c6, 0x2061, 0x0200, 0x2001, 0x19a9, 0x2004, 0x601a, 0x2061,
+	0x0100, 0x2001, 0x19a8, 0x2004, 0x60ce, 0x6104, 0xc1ac, 0x6106,
+	0x080c, 0x4abe, 0xa813, 0x0019, 0xa817, 0x0001, 0x2900, 0xa85a,
+	0x2001, 0x002e, 0x2004, 0xa866, 0x2001, 0x002f, 0x2004, 0xa86a,
+	0x2061, 0x0090, 0x2079, 0x0100, 0x2001, 0x19a8, 0x2004, 0x6036,
+	0x2009, 0x0040, 0x080c, 0x23df, 0x2001, 0x002a, 0x2004, 0x9084,
+	0xfff8, 0xa86e, 0x601a, 0xa873, 0x0000, 0x601f, 0x0000, 0x78ca,
+	0x9006, 0x600a, 0x600e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00e6,
+	0x080c, 0x4abe, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001, 0x2800,
+	0xa05a, 0x2001, 0x0030, 0x2004, 0xa866, 0x2001, 0x0031, 0x2004,
+	0xa86a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e, 0xa873,
+	0x0000, 0x2001, 0x032a, 0x2003, 0x0004, 0x2001, 0x0300, 0x2003,
+	0x0000, 0x2001, 0x020d, 0x2003, 0x0000, 0x2001, 0x0004, 0x200c,
+	0x918d, 0x0002, 0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x81ff, 0x0148, 0x080c, 0x2c3d, 0x1130, 0x9006, 0x080c, 0x2b95,
+	0x9006, 0x080c, 0x2b78, 0x7884, 0x9084, 0x0007, 0x0002, 0x3d22,
+	0x3d2b, 0x3d34, 0x3d1f, 0x3d1f, 0x3d1f, 0x3d1f, 0x3d1f, 0x012e,
+	0x0804, 0x3566, 0x2009, 0x0114, 0x2104, 0x9085, 0x0800, 0x200a,
+	0x080c, 0x3ef0, 0x00c0, 0x2009, 0x0114, 0x2104, 0x9085, 0x4000,
+	0x200a, 0x080c, 0x3ef0, 0x0078, 0x080c, 0x73b3, 0x1128, 0x012e,
+	0x2009, 0x0016, 0x0804, 0x3563, 0x81ff, 0x0128, 0x012e, 0x2021,
+	0x400b, 0x0804, 0x3533, 0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6,
+	0x00d6, 0x00e6, 0x00f6, 0x080c, 0x3a51, 0x2009, 0x0101, 0x210c,
+	0x0016, 0x7ec8, 0x7dcc, 0x9006, 0x2068, 0x2060, 0x2058, 0x080c,
+	0x41b9, 0x080c, 0x4109, 0x903e, 0x2720, 0x00f6, 0x00e6, 0x0086,
+	0x2940, 0x2071, 0x1a65, 0x2079, 0x0090, 0x00d6, 0x2069, 0x0000,
+	0x6884, 0xd0b4, 0x0120, 0x68d4, 0x780e, 0x68d0, 0x780a, 0x00de,
+	0x2011, 0x0001, 0x080c, 0x406a, 0x080c, 0x2c45, 0x080c, 0x2c45,
+	0x080c, 0x2c45, 0x080c, 0x2c45, 0x080c, 0x406a, 0x008e, 0x00ee,
+	0x00fe, 0x080c, 0x3f97, 0x2009, 0x9c40, 0x8109, 0x11b0, 0x080c,
+	0x3ea6, 0x2001, 0x0004, 0x200c, 0x918c, 0xfffd, 0x2102, 0x001e,
 	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e,
-	0x1118, 0x012e, 0x0804, 0x3526, 0x012e, 0x2021, 0x400c, 0x0804,
-	0x3528, 0x9085, 0x0001, 0x1d04, 0x3e9a, 0x2091, 0x6000, 0x8420,
-	0x9486, 0x0064, 0x0005, 0x2001, 0x0105, 0x2003, 0x0010, 0x2001,
-	0x032a, 0x2003, 0x0004, 0x2001, 0x1a61, 0x2003, 0x0000, 0x0071,
-	0x2009, 0x0048, 0x080c, 0x23d4, 0x2001, 0x0227, 0x2024, 0x2402,
-	0x2001, 0x0109, 0x2003, 0x4000, 0x9026, 0x0005, 0x00f6, 0x00e6,
-	0x2071, 0x1a65, 0x7000, 0x9086, 0x0000, 0x0520, 0x2079, 0x0090,
-	0x2009, 0x0206, 0x2104, 0x2009, 0x0203, 0x210c, 0x9106, 0x1120,
-	0x2009, 0x0040, 0x080c, 0x23d4, 0x782c, 0xd0fc, 0x0d88, 0x080c,
-	0x40d3, 0x7000, 0x9086, 0x0000, 0x1d58, 0x782b, 0x0004, 0x782c,
-	0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x23d4, 0x782b, 0x0002,
-	0x7003, 0x0000, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100,
-	0x2001, 0x1818, 0x200c, 0x7932, 0x7936, 0x080c, 0x2889, 0x7850,
-	0x9084, 0xfbff, 0x9085, 0x0030, 0x7852, 0x2019, 0x01f4, 0x8319,
-	0x1df0, 0x9084, 0xffcf, 0x9085, 0x2000, 0x7852, 0x20a9, 0x0046,
-	0x1d04, 0x3f00, 0x2091, 0x6000, 0x1f04, 0x3f00, 0x7850, 0x9085,
-	0x0400, 0x9084, 0xdfff, 0x7852, 0x2001, 0x0021, 0x2004, 0x9084,
-	0x0003, 0x9086, 0x0001, 0x1120, 0x7850, 0x9084, 0xdfff, 0x7852,
-	0x784b, 0xf7f7, 0x7843, 0x0090, 0x7843, 0x0010, 0x20a9, 0x0028,
-	0xa001, 0x1f04, 0x3f20, 0x7850, 0x9085, 0x1400, 0x7852, 0x2019,
-	0x61a8, 0x7854, 0xa001, 0xa001, 0xd08c, 0x1110, 0x8319, 0x1dc8,
-	0x7827, 0x0048, 0x7850, 0x9085, 0x0400, 0x7852, 0x7843, 0x0040,
-	0x2019, 0x01f4, 0xa001, 0xa001, 0x8319, 0x1de0, 0x2001, 0x0100,
-	0x080c, 0x2cf1, 0x7827, 0x0020, 0x7843, 0x0000, 0x9006, 0x080c,
-	0x2cf1, 0x7827, 0x0048, 0x00fe, 0x0005, 0x7884, 0xd0ac, 0x11c8,
-	0x00f6, 0x00e6, 0x2071, 0x1a61, 0x2079, 0x0320, 0x2001, 0x0201,
-	0x2004, 0x9005, 0x0160, 0x7000, 0x9086, 0x0000, 0x1140, 0x0051,
-	0xd0bc, 0x0108, 0x8738, 0x7003, 0x0003, 0x782b, 0x0019, 0x00ee,
-	0x00fe, 0x0005, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe, 0x908c,
-	0x0070, 0x0178, 0x2009, 0x0032, 0x260a, 0x2009, 0x0033, 0x250a,
-	0xd0b4, 0x0108, 0x8c60, 0xd0ac, 0x0108, 0x8d68, 0xd0a4, 0x0108,
-	0x8b58, 0x0005, 0x00f6, 0x2079, 0x0200, 0x781c, 0xd084, 0x0110,
-	0x7837, 0x0050, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x0100, 0x2001,
-	0x19a9, 0x2004, 0x70e2, 0x080c, 0x3c7c, 0x1188, 0x2001, 0x1820,
-	0x2004, 0x2009, 0x181f, 0x210c, 0x918c, 0x00ff, 0x706e, 0x716a,
-	0x7066, 0x918d, 0x3200, 0x7162, 0x7073, 0xe109, 0x0080, 0x702c,
-	0x9085, 0x0002, 0x702e, 0x2009, 0x1818, 0x210c, 0x716e, 0x7063,
-	0x0100, 0x7166, 0x719e, 0x706b, 0x0000, 0x7073, 0x0809, 0x7077,
-	0x0008, 0x7078, 0x9080, 0x0100, 0x707a, 0x7080, 0x8000, 0x7082,
-	0x7087, 0xaaaa, 0x9006, 0x708a, 0x708e, 0x707e, 0x70d6, 0x70ab,
-	0x0036, 0x70af, 0x95d5, 0x7014, 0x9084, 0x1984, 0x9085, 0x0092,
-	0x7016, 0x080c, 0x40d3, 0x00f6, 0x2071, 0x1a61, 0x2079, 0x0320,
-	0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120, 0x689c, 0x780e,
-	0x6898, 0x780a, 0x00de, 0x2009, 0x03e8, 0x8109, 0x1df0, 0x792c,
-	0xd1fc, 0x0110, 0x782b, 0x0004, 0x2011, 0x0011, 0x080c, 0x405f,
-	0x2011, 0x0001, 0x080c, 0x405f, 0x00fe, 0x00ee, 0x0005, 0x00f6,
-	0x00e6, 0x2071, 0x1a61, 0x2079, 0x0320, 0x792c, 0xd1fc, 0x0904,
-	0x405c, 0x782b, 0x0002, 0x9026, 0xd19c, 0x1904, 0x4058, 0x7000,
-	0x0002, 0x405c, 0x400d, 0x403d, 0x4058, 0xd1bc, 0x1170, 0xd1dc,
-	0x1190, 0x8001, 0x7002, 0x2011, 0x0001, 0x080c, 0x405f, 0x0904,
-	0x405c, 0x080c, 0x405f, 0x0804, 0x405c, 0x00f6, 0x2079, 0x0300,
-	0x78bf, 0x0000, 0x00fe, 0x7810, 0x7914, 0x782b, 0x0004, 0x7812,
-	0x7916, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0de8, 0x080c, 0x3f6a,
-	0x2009, 0x0001, 0x00f6, 0x2079, 0x0300, 0x78b8, 0x00fe, 0xd0ec,
-	0x0110, 0x2009, 0x0011, 0x792a, 0x00f8, 0x8001, 0x7002, 0x9184,
-	0x0880, 0x1140, 0x782c, 0xd0fc, 0x1904, 0x4001, 0x2011, 0x0001,
-	0x00b1, 0x0090, 0xa010, 0x9092, 0x0004, 0x9086, 0x0015, 0x1120,
-	0xa000, 0xa05a, 0x2011, 0x0031, 0xa212, 0xd1dc, 0x1960, 0x0828,
-	0x782b, 0x0004, 0x7003, 0x0000, 0x00ee, 0x00fe, 0x0005, 0xa014,
-	0x9005, 0x0550, 0x8001, 0x0036, 0x0096, 0xa016, 0xa058, 0x2048,
-	0xa010, 0x2009, 0x0031, 0x911a, 0x831c, 0x831c, 0x938a, 0x0007,
-	0x1a0c, 0x0dd5, 0x9398, 0x408d, 0x231d, 0x083f, 0x9080, 0x0004,
-	0x7a2a, 0x7100, 0x8108, 0x7102, 0x009e, 0x003e, 0x908a, 0x0035,
-	0x1140, 0x0096, 0xa058, 0x2048, 0xa804, 0xa05a, 0x2001, 0x0019,
-	0x009e, 0xa012, 0x9085, 0x0001, 0x0005, 0x40ca, 0x40c1, 0x40b8,
-	0x40af, 0x40a6, 0x409d, 0x4094, 0xa964, 0x7902, 0xa968, 0x7906,
-	0xa96c, 0x7912, 0xa970, 0x7916, 0x0005, 0xa974, 0x7902, 0xa978,
-	0x7906, 0xa97c, 0x7912, 0xa980, 0x7916, 0x0005, 0xa984, 0x7902,
-	0xa988, 0x7906, 0xa98c, 0x7912, 0xa990, 0x7916, 0x0005, 0xa994,
-	0x7902, 0xa998, 0x7906, 0xa99c, 0x7912, 0xa9a0, 0x7916, 0x0005,
-	0xa9a4, 0x7902, 0xa9a8, 0x7906, 0xa9ac, 0x7912, 0xa9b0, 0x7916,
-	0x0005, 0xa9b4, 0x7902, 0xa9b8, 0x7906, 0xa9bc, 0x7912, 0xa9c0,
-	0x7916, 0x0005, 0xa9c4, 0x7902, 0xa9c8, 0x7906, 0xa9cc, 0x7912,
-	0xa9d0, 0x7916, 0x0005, 0x00f6, 0x00e6, 0x0086, 0x2071, 0x1a65,
-	0x2079, 0x0090, 0x792c, 0xd1fc, 0x01e8, 0x782b, 0x0002, 0x2940,
-	0x9026, 0x7000, 0x0002, 0x40fa, 0x40e6, 0x40f1, 0x8001, 0x7002,
-	0xd19c, 0x1180, 0x2011, 0x0001, 0x080c, 0x405f, 0x190c, 0x405f,
-	0x0048, 0x8001, 0x7002, 0x782c, 0xd0fc, 0x1d38, 0x2011, 0x0001,
-	0x080c, 0x405f, 0x008e, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x00e6,
-	0x00c6, 0x0086, 0x2061, 0x0200, 0x2001, 0x19a9, 0x2004, 0x601a,
-	0x2061, 0x0100, 0x2001, 0x19a8, 0x2004, 0x60ce, 0x6104, 0xc1ac,
-	0x6106, 0x2001, 0x002c, 0x2004, 0x9005, 0x0520, 0x2038, 0x2001,
-	0x002e, 0x2024, 0x2001, 0x002f, 0x201c, 0x080c, 0x4ab4, 0xa813,
-	0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007, 0x0220, 0x2138,
-	0x2009, 0x0007, 0x0010, 0x2708, 0x903e, 0x0096, 0xa858, 0x2048,
-	0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x4176, 0x1d68, 0x2900,
-	0xa85a, 0x00d0, 0x080c, 0x4ab4, 0xa813, 0x0019, 0xa817, 0x0001,
-	0x2900, 0xa85a, 0x2001, 0x002e, 0x2004, 0xa866, 0x2001, 0x002f,
-	0x2004, 0xa86a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e,
-	0x2001, 0x002b, 0x2004, 0xa872, 0x2061, 0x0090, 0x2079, 0x0100,
-	0x2001, 0x19a8, 0x2004, 0x6036, 0x2009, 0x0040, 0x080c, 0x23d4,
-	0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a, 0x0006, 0x2001,
-	0x002b, 0x2004, 0x601e, 0x78c6, 0x000e, 0x78ca, 0x9006, 0x600a,
-	0x600e, 0x008e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00e6, 0x2071,
-	0x0080, 0xaa60, 0x22e8, 0x20a0, 0x20e1, 0x0000, 0x2099, 0x0088,
-	0x702b, 0x0026, 0x7402, 0x7306, 0x9006, 0x700a, 0x700e, 0x810b,
-	0x810b, 0x21a8, 0x810b, 0x7112, 0x702b, 0x0041, 0x702c, 0xd0fc,
-	0x0de8, 0x702b, 0x0002, 0x702b, 0x0040, 0x4005, 0x7400, 0x7304,
-	0x87ff, 0x0190, 0x0086, 0x0096, 0x2940, 0x0086, 0x080c, 0x4ab4,
-	0x008e, 0xa058, 0x00a6, 0x2050, 0x2900, 0xb006, 0xa05a, 0x00ae,
-	0x009e, 0x008e, 0x9085, 0x0001, 0x00ee, 0x0005, 0x00e6, 0x2001,
-	0x002d, 0x2004, 0x9005, 0x0528, 0x2038, 0x2001, 0x0030, 0x2024,
-	0x2001, 0x0031, 0x201c, 0x080c, 0x4ab4, 0x2940, 0xa813, 0x0019,
-	0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007, 0x0220, 0x2138, 0x2009,
-	0x0007, 0x0010, 0x2708, 0x903e, 0x0096, 0xa858, 0x2048, 0xa85c,
-	0x9080, 0x0019, 0x009e, 0x080c, 0x4176, 0x1d68, 0x2900, 0xa85a,
-	0x00d8, 0x080c, 0x4ab4, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001,
-	0x2800, 0xa05a, 0x2001, 0x0030, 0x2004, 0xa066, 0x2001, 0x0031,
-	0x2004, 0xa06a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa06e,
-	0x2001, 0x002b, 0x2004, 0xa072, 0x2001, 0x032a, 0x2003, 0x0004,
-	0x7884, 0xd0ac, 0x1180, 0x2001, 0x0101, 0x200c, 0x918d, 0x0200,
-	0x2102, 0xa017, 0x0000, 0x2001, 0x1a61, 0x2003, 0x0003, 0x2001,
-	0x032a, 0x2003, 0x0009, 0x2001, 0x0300, 0x2003, 0x0000, 0x2001,
-	0x020d, 0x2003, 0x0000, 0x2001, 0x0004, 0x200c, 0x918d, 0x0002,
-	0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x20a9, 0x0007,
-	0x20a1, 0x1840, 0x20e9, 0x0001, 0x9006, 0x4004, 0x20a9, 0x000c,
-	0x20a1, 0xfff4, 0x20e9, 0x0000, 0x9006, 0x4004, 0x2009, 0x013c,
-	0x200a, 0x012e, 0x7880, 0x9086, 0x0052, 0x0108, 0x0005, 0x0804,
-	0x3526, 0x7d98, 0x7c9c, 0x0804, 0x3628, 0x080c, 0x73a5, 0x190c,
-	0x5fe8, 0x6040, 0x9084, 0x0020, 0x09b1, 0x2069, 0x1847, 0x2d00,
-	0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0001,
-	0x080c, 0x4afd, 0x701f, 0x4255, 0x0005, 0x080c, 0x56e7, 0x1130,
-	0x3b00, 0x3a08, 0xc194, 0xc095, 0x20d8, 0x21d0, 0x2069, 0x1847,
-	0x6800, 0x9005, 0x0904, 0x355b, 0x6804, 0xd0ac, 0x0118, 0xd0a4,
-	0x0904, 0x355b, 0xd094, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0138,
-	0x6200, 0x9292, 0x0005, 0x0218, 0x918c, 0xffdf, 0x0010, 0x918d,
-	0x0020, 0x6106, 0x00ce, 0xd08c, 0x00c6, 0x2061, 0x0100, 0x6104,
-	0x0118, 0x918d, 0x0010, 0x0010, 0x918c, 0xffef, 0x6106, 0x00ce,
-	0xd084, 0x0158, 0x6a28, 0x928a, 0x007f, 0x1a04, 0x355b, 0x9288,
-	0x3327, 0x210d, 0x918c, 0x00ff, 0x6166, 0xd0dc, 0x0130, 0x6828,
-	0x908a, 0x007f, 0x1a04, 0x355b, 0x605e, 0x6888, 0x9084, 0x0030,
-	0x8004, 0x8004, 0x8004, 0x8004, 0x0006, 0x2009, 0x19b0, 0x9080,
-	0x297c, 0x2005, 0x200a, 0x000e, 0x2009, 0x19b1, 0x9080, 0x2980,
-	0x2005, 0x200a, 0x6808, 0x908a, 0x0100, 0x0a04, 0x355b, 0x908a,
-	0x0841, 0x1a04, 0x355b, 0x9084, 0x0007, 0x1904, 0x355b, 0x680c,
-	0x9005, 0x0904, 0x355b, 0x6810, 0x9005, 0x0904, 0x355b, 0x6848,
-	0x6940, 0x910a, 0x1a04, 0x355b, 0x8001, 0x0904, 0x355b, 0x684c,
-	0x6944, 0x910a, 0x1a04, 0x355b, 0x8001, 0x0904, 0x355b, 0x2009,
-	0x1980, 0x200b, 0x0000, 0x2001, 0x1869, 0x2004, 0xd0c4, 0x0140,
-	0x7884, 0x200a, 0x2009, 0x017f, 0x200a, 0x3b00, 0xc085, 0x20d8,
-	0x6814, 0x908c, 0x00ff, 0x614e, 0x8007, 0x9084, 0x00ff, 0x6052,
-	0x080c, 0x76be, 0x080c, 0x69ad, 0x080c, 0x69e1, 0x6808, 0x602a,
-	0x080c, 0x2346, 0x2009, 0x0170, 0x200b, 0x0080, 0xa001, 0xa001,
-	0x200b, 0x0000, 0x0036, 0x6b08, 0x080c, 0x28e3, 0x003e, 0x6000,
-	0x9086, 0x0000, 0x1904, 0x43ec, 0x6818, 0x691c, 0x6a20, 0x6b24,
-	0x8007, 0x810f, 0x8217, 0x831f, 0x6016, 0x611a, 0x621e, 0x6322,
-	0x6c04, 0xd4f4, 0x0148, 0x6830, 0x6934, 0x6a38, 0x6b3c, 0x8007,
-	0x810f, 0x8217, 0x831f, 0x0010, 0x9084, 0xf0ff, 0x6006, 0x610a,
-	0x620e, 0x6312, 0x8007, 0x810f, 0x8217, 0x831f, 0x20a9, 0x0004,
-	0x20a1, 0x19b2, 0x20e9, 0x0001, 0x4001, 0x20a9, 0x0004, 0x20a1,
-	0x19cc, 0x20e9, 0x0001, 0x4001, 0x080c, 0x85d8, 0x00c6, 0x900e,
-	0x20a9, 0x0001, 0x6b70, 0xd384, 0x0510, 0x0068, 0x2009, 0x0100,
-	0x210c, 0x918e, 0x0008, 0x1110, 0x839d, 0x0010, 0x83f5, 0x3e18,
-	0x12b0, 0x3508, 0x8109, 0x080c, 0x7c74, 0x6878, 0x6016, 0x6874,
-	0x2008, 0x9084, 0xff00, 0x8007, 0x600a, 0x9184, 0x00ff, 0x6006,
-	0x8108, 0x1118, 0x6003, 0x0003, 0x0010, 0x6003, 0x0001, 0x1f04,
-	0x4346, 0x00ce, 0x00c6, 0x2061, 0x199b, 0x6a88, 0x9284, 0xc000,
-	0x2010, 0x9286, 0x0000, 0x1158, 0x2063, 0x0000, 0x2001, 0x0001,
-	0x080c, 0x2b8a, 0x2001, 0x0001, 0x080c, 0x2b6d, 0x0088, 0x9286,
-	0x4000, 0x1148, 0x2063, 0x0001, 0x9006, 0x080c, 0x2b8a, 0x9006,
-	0x080c, 0x2b6d, 0x0028, 0x9286, 0x8000, 0x1d30, 0x2063, 0x0002,
-	0x00ce, 0x6888, 0xd0ec, 0x0130, 0x2011, 0x0114, 0x2204, 0x9085,
-	0x0100, 0x2012, 0x6a80, 0x9284, 0x0030, 0x9086, 0x0030, 0x1128,
-	0x9294, 0xffcf, 0x9295, 0x0020, 0x6a82, 0x2001, 0x197b, 0x6a80,
-	0x9294, 0x0030, 0x928e, 0x0000, 0x0170, 0x928e, 0x0010, 0x0118,
-	0x928e, 0x0020, 0x0140, 0x2003, 0xaaaa, 0x080c, 0x2958, 0x2001,
-	0x196c, 0x2102, 0x0008, 0x2102, 0x00c6, 0x2061, 0x0100, 0x602f,
-	0x0040, 0x602f, 0x0000, 0x00ce, 0x080c, 0x73a5, 0x0128, 0x080c,
-	0x4fe4, 0x0110, 0x080c, 0x28a9, 0x60d4, 0x9005, 0x01c0, 0x6003,
-	0x0001, 0x2009, 0x43d4, 0x00e0, 0x080c, 0x73a5, 0x1168, 0x2011,
-	0x723b, 0x080c, 0x84dc, 0x2011, 0x722e, 0x080c, 0x85b6, 0x080c,
-	0x7692, 0x080c, 0x72d7, 0x0040, 0x080c, 0x5ee2, 0x0028, 0x6003,
-	0x0004, 0x2009, 0x43ec, 0x0020, 0x080c, 0x68dd, 0x0804, 0x3526,
-	0x2001, 0x0170, 0x2004, 0x9084, 0x00ff, 0x9086, 0x004c, 0x1118,
-	0x2091, 0x30bd, 0x0817, 0x2091, 0x303d, 0x0817, 0x6000, 0x9086,
-	0x0000, 0x0904, 0x3558, 0x2069, 0x1847, 0x7890, 0x6842, 0x7894,
-	0x6846, 0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
-	0x2039, 0x0001, 0x0804, 0x4b00, 0x9006, 0x080c, 0x28a9, 0x81ff,
-	0x1904, 0x3558, 0x080c, 0x73a5, 0x11b0, 0x080c, 0x768d, 0x080c,
-	0x6023, 0x080c, 0x331b, 0x0118, 0x6130, 0xc18d, 0x6132, 0x080c,
-	0xd24a, 0x0130, 0x080c, 0x73c8, 0x1118, 0x080c, 0x737d, 0x0038,
-	0x080c, 0x72d7, 0x0020, 0x080c, 0x5fe8, 0x080c, 0x5ee2, 0x0804,
-	0x3526, 0x81ff, 0x1904, 0x3558, 0x080c, 0x73a5, 0x1110, 0x0804,
-	0x3558, 0x6194, 0x81ff, 0x01a8, 0x704f, 0x0000, 0x2001, 0x1c80,
-	0x2009, 0x0040, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0126, 0x2091,
-	0x8000, 0x2039, 0x0001, 0x080c, 0x4b00, 0x701f, 0x3524, 0x012e,
-	0x0005, 0x704f, 0x0001, 0x00d6, 0x2069, 0x1c80, 0x20a9, 0x0040,
-	0x20e9, 0x0001, 0x20a1, 0x1c80, 0x2019, 0xffff, 0x4304, 0x655c,
-	0x9588, 0x3327, 0x210d, 0x918c, 0x00ff, 0x216a, 0x900e, 0x2011,
-	0x0002, 0x2100, 0x9506, 0x01a8, 0x080c, 0x6608, 0x1190, 0xb814,
-	0x821c, 0x0238, 0x9398, 0x1c80, 0x9085, 0xff00, 0x8007, 0x201a,
-	0x0038, 0x9398, 0x1c80, 0x2324, 0x94a4, 0xff00, 0x9405, 0x201a,
-	0x8210, 0x8108, 0x9182, 0x0080, 0x1208, 0x0c18, 0x8201, 0x8007,
-	0x2d0c, 0x9105, 0x206a, 0x00de, 0x20a9, 0x0040, 0x20a1, 0x1c80,
-	0x2099, 0x1c80, 0x080c, 0x5f73, 0x0804, 0x4446, 0x080c, 0x4ae7,
-	0x0904, 0x355b, 0x080c, 0x4ab4, 0x1120, 0x2009, 0x0002, 0x0804,
-	0x3558, 0x080c, 0x56d8, 0xd0b4, 0x0558, 0x7884, 0x908e, 0x007e,
-	0x0538, 0x908e, 0x007f, 0x0520, 0x908e, 0x0080, 0x0508, 0x080c,
-	0x3316, 0x1148, 0xb800, 0xd08c, 0x11d8, 0xb804, 0x9084, 0x00ff,
-	0x9086, 0x0006, 0x11a8, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a,
-	0x080c, 0xcd13, 0x1120, 0x2009, 0x0003, 0x0804, 0x3558, 0x7007,
-	0x0003, 0x701f, 0x44d4, 0x0005, 0x080c, 0x4ae7, 0x0904, 0x355b,
-	0x20a9, 0x002b, 0xb8c4, 0x20e0, 0xb8c8, 0x2098, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080,
-	0x0006, 0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098,
-	0x080c, 0x0f7c, 0x0070, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x000a,
-	0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x000a, 0x2098, 0x080c,
-	0x0f7c, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
-	0x9080, 0x0002, 0x2009, 0x002b, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
-	0x0804, 0x4b00, 0x81ff, 0x1904, 0x3558, 0x080c, 0x4acb, 0x0904,
-	0x355b, 0x080c, 0x677a, 0x0904, 0x3558, 0x0058, 0xa878, 0x9005,
-	0x0120, 0x2009, 0x0004, 0x0804, 0x3558, 0xa974, 0xaa94, 0x0804,
-	0x3526, 0x080c, 0x56e0, 0x0904, 0x3526, 0x701f, 0x451e, 0x7007,
-	0x0003, 0x0005, 0x81ff, 0x1904, 0x3558, 0x7888, 0x908a, 0x1000,
-	0x1a04, 0x355b, 0x080c, 0x4ae7, 0x0904, 0x355b, 0x080c, 0x697b,
-	0x0120, 0x080c, 0x6983, 0x1904, 0x355b, 0x080c, 0x67ff, 0x0904,
-	0x3558, 0x2019, 0x0004, 0x900e, 0x080c, 0x678c, 0x0904, 0x3558,
-	0x7984, 0x7a88, 0x04c9, 0x08a8, 0xa89c, 0x908a, 0x1000, 0x12f8,
-	0x080c, 0x4ae5, 0x01e0, 0x080c, 0x697b, 0x0118, 0x080c, 0x6983,
-	0x11b0, 0x080c, 0x67ff, 0x2009, 0x0002, 0x0168, 0x2009, 0x0002,
-	0x2019, 0x0004, 0x080c, 0x678c, 0x2009, 0x0003, 0x0120, 0xa998,
-	0xaa9c, 0x00d1, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
-	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
-	0x4000, 0x080c, 0x56e0, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085,
-	0x0001, 0x2001, 0x0000, 0x0005, 0x9186, 0x00ff, 0x0110, 0x0071,
-	0x0060, 0x2029, 0x007e, 0x2061, 0x1800, 0x645c, 0x2400, 0x9506,
-	0x0110, 0x2508, 0x0019, 0x8529, 0x1ec8, 0x0005, 0x080c, 0x6608,
-	0x1138, 0x2200, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x84ea,
-	0x0005, 0x81ff, 0x1904, 0x3558, 0x798c, 0x2001, 0x197f, 0x918c,
-	0x8000, 0x2102, 0x080c, 0x4acb, 0x0904, 0x355b, 0x080c, 0x697b,
-	0x0120, 0x080c, 0x6983, 0x1904, 0x355b, 0x080c, 0x66cf, 0x0904,
-	0x3558, 0x080c, 0x6783, 0x0904, 0x3558, 0x2001, 0x197f, 0x2004,
-	0xd0fc, 0x1904, 0x3526, 0x0804, 0x4529, 0xa9a0, 0x2001, 0x197f,
-	0x918c, 0x8000, 0xc18d, 0x2102, 0x080c, 0x4ad8, 0x01a0, 0x080c,
-	0x697b, 0x0118, 0x080c, 0x6983, 0x1170, 0x080c, 0x66cf, 0x2009,
-	0x0002, 0x0128, 0x080c, 0x6783, 0x1170, 0x2009, 0x0003, 0xa897,
+	0x2009, 0x0017, 0x080c, 0x3563, 0x0cf8, 0x2001, 0x020b, 0x2004,
+	0x9084, 0x0140, 0x1d10, 0x00f6, 0x2079, 0x0000, 0x7884, 0x00fe,
+	0xd0bc, 0x0178, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0150, 0x080c,
+	0x3f75, 0x2d00, 0x9c05, 0x9b05, 0x0120, 0x080c, 0x3ea6, 0x0804,
+	0x3e53, 0x080c, 0x40de, 0x080c, 0x4002, 0x080c, 0x3f58, 0x080c,
+	0x3f8d, 0x00f6, 0x2079, 0x0100, 0x7824, 0xd0ac, 0x0130, 0x8b58,
+	0x080c, 0x3ea6, 0x00fe, 0x0804, 0x3e53, 0x00fe, 0x080c, 0x3e9c,
+	0x1150, 0x8d68, 0x2001, 0x0032, 0x2602, 0x2001, 0x0033, 0x2502,
+	0x080c, 0x3ea6, 0x0080, 0x87ff, 0x0138, 0x2001, 0x0201, 0x2004,
+	0x9005, 0x1908, 0x8739, 0x0038, 0x2001, 0x1a61, 0x2004, 0x9086,
+	0x0000, 0x1904, 0x3da3, 0x2001, 0x032f, 0x2003, 0x00f6, 0x8631,
+	0x1208, 0x8529, 0x2500, 0x9605, 0x0904, 0x3e53, 0x7884, 0xd0bc,
+	0x0128, 0x2d00, 0x9c05, 0x9b05, 0x1904, 0x3e53, 0xa013, 0x0019,
+	0x2001, 0x032a, 0x2003, 0x0004, 0x7884, 0xd0ac, 0x1148, 0x2001,
+	0x1a61, 0x2003, 0x0003, 0x2001, 0x032a, 0x2003, 0x0009, 0x0030,
+	0xa017, 0x0001, 0x78b4, 0x9005, 0x0108, 0xa016, 0x2800, 0xa05a,
+	0x2009, 0x0040, 0x080c, 0x23df, 0x2900, 0xa85a, 0xa813, 0x0019,
+	0x7884, 0xd0a4, 0x1180, 0xa817, 0x0000, 0x00c6, 0x20a9, 0x0004,
+	0x2061, 0x0090, 0x602b, 0x0008, 0x2001, 0x0203, 0x2004, 0x1f04,
+	0x3e2a, 0x00ce, 0x0030, 0xa817, 0x0001, 0x78b0, 0x9005, 0x0108,
+	0xa816, 0x00f6, 0x00c6, 0x2079, 0x0100, 0x2061, 0x0090, 0x7827,
+	0x0002, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a, 0x0006,
+	0x2001, 0x002b, 0x2004, 0x601e, 0x78c6, 0x000e, 0x78ca, 0x00ce,
+	0x00fe, 0x0804, 0x3d5d, 0x001e, 0x00c6, 0x2001, 0x032a, 0x2003,
+	0x0004, 0x2061, 0x0100, 0x6027, 0x0002, 0x6106, 0x2011, 0x020d,
+	0x2013, 0x0020, 0x2001, 0x0004, 0x200c, 0x918c, 0xfffd, 0x2102,
+	0x080c, 0x12ed, 0x7884, 0x9084, 0x0003, 0x9086, 0x0002, 0x01a0,
+	0x2009, 0x0028, 0x080c, 0x23df, 0x2001, 0x0227, 0x200c, 0x2102,
+	0x6050, 0x9084, 0xb7ef, 0x6052, 0x602f, 0x0000, 0x604b, 0xf7f7,
+	0x6043, 0x0090, 0x6043, 0x0010, 0x00ce, 0x2d08, 0x2c10, 0x2b18,
+	0x2b00, 0x9c05, 0x9d05, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be,
+	0x00ae, 0x009e, 0x008e, 0x1118, 0x012e, 0x0804, 0x3531, 0x012e,
+	0x2021, 0x400c, 0x0804, 0x3533, 0x9085, 0x0001, 0x1d04, 0x3ea5,
+	0x2091, 0x6000, 0x8420, 0x9486, 0x0064, 0x0005, 0x2001, 0x0105,
+	0x2003, 0x0010, 0x2001, 0x032a, 0x2003, 0x0004, 0x2001, 0x1a61,
+	0x2003, 0x0000, 0x0071, 0x2009, 0x0048, 0x080c, 0x23df, 0x2001,
+	0x0227, 0x2024, 0x2402, 0x2001, 0x0109, 0x2003, 0x4000, 0x9026,
+	0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a65, 0x7000, 0x9086, 0x0000,
+	0x0520, 0x2079, 0x0090, 0x2009, 0x0206, 0x2104, 0x2009, 0x0203,
+	0x210c, 0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x23df, 0x782c,
+	0xd0fc, 0x0d88, 0x080c, 0x40de, 0x7000, 0x9086, 0x0000, 0x1d58,
+	0x782b, 0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c,
+	0x23df, 0x782b, 0x0002, 0x7003, 0x0000, 0x00ee, 0x00fe, 0x0005,
+	0x00f6, 0x2079, 0x0100, 0x2001, 0x1818, 0x200c, 0x7932, 0x7936,
+	0x080c, 0x2894, 0x7850, 0x9084, 0xfbff, 0x9085, 0x0030, 0x7852,
+	0x2019, 0x01f4, 0x8319, 0x1df0, 0x9084, 0xffcf, 0x9085, 0x2000,
+	0x7852, 0x20a9, 0x0046, 0x1d04, 0x3f0b, 0x2091, 0x6000, 0x1f04,
+	0x3f0b, 0x7850, 0x9085, 0x0400, 0x9084, 0xdfff, 0x7852, 0x2001,
+	0x0021, 0x2004, 0x9084, 0x0003, 0x9086, 0x0001, 0x1120, 0x7850,
+	0x9084, 0xdfff, 0x7852, 0x784b, 0xf7f7, 0x7843, 0x0090, 0x7843,
+	0x0010, 0x20a9, 0x0028, 0xa001, 0x1f04, 0x3f2b, 0x7850, 0x9085,
+	0x1400, 0x7852, 0x2019, 0x61a8, 0x7854, 0xa001, 0xa001, 0xd08c,
+	0x1110, 0x8319, 0x1dc8, 0x7827, 0x0048, 0x7850, 0x9085, 0x0400,
+	0x7852, 0x7843, 0x0040, 0x2019, 0x01f4, 0xa001, 0xa001, 0x8319,
+	0x1de0, 0x2001, 0x0100, 0x080c, 0x2cfc, 0x7827, 0x0020, 0x7843,
+	0x0000, 0x9006, 0x080c, 0x2cfc, 0x7827, 0x0048, 0x00fe, 0x0005,
+	0x7884, 0xd0ac, 0x11c8, 0x00f6, 0x00e6, 0x2071, 0x1a61, 0x2079,
+	0x0320, 0x2001, 0x0201, 0x2004, 0x9005, 0x0160, 0x7000, 0x9086,
+	0x0000, 0x1140, 0x0051, 0xd0bc, 0x0108, 0x8738, 0x7003, 0x0003,
+	0x782b, 0x0019, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0300,
+	0x78bc, 0x00fe, 0x908c, 0x0070, 0x0178, 0x2009, 0x0032, 0x260a,
+	0x2009, 0x0033, 0x250a, 0xd0b4, 0x0108, 0x8c60, 0xd0ac, 0x0108,
+	0x8d68, 0xd0a4, 0x0108, 0x8b58, 0x0005, 0x00f6, 0x2079, 0x0200,
+	0x781c, 0xd084, 0x0110, 0x7837, 0x0050, 0x00fe, 0x0005, 0x00e6,
+	0x2071, 0x0100, 0x2001, 0x19a9, 0x2004, 0x70e2, 0x080c, 0x3c87,
+	0x1188, 0x2001, 0x1820, 0x2004, 0x2009, 0x181f, 0x210c, 0x918c,
+	0x00ff, 0x706e, 0x716a, 0x7066, 0x918d, 0x3200, 0x7162, 0x7073,
+	0xe109, 0x0080, 0x702c, 0x9085, 0x0002, 0x702e, 0x2009, 0x1818,
+	0x210c, 0x716e, 0x7063, 0x0100, 0x7166, 0x719e, 0x706b, 0x0000,
+	0x7073, 0x0809, 0x7077, 0x0008, 0x7078, 0x9080, 0x0100, 0x707a,
+	0x7080, 0x8000, 0x7082, 0x7087, 0xaaaa, 0x9006, 0x708a, 0x708e,
+	0x707e, 0x70d6, 0x70ab, 0x0036, 0x70af, 0x95d5, 0x7014, 0x9084,
+	0x1984, 0x9085, 0x0092, 0x7016, 0x080c, 0x40de, 0x00f6, 0x2071,
+	0x1a61, 0x2079, 0x0320, 0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4,
+	0x0120, 0x689c, 0x780e, 0x6898, 0x780a, 0x00de, 0x2009, 0x03e8,
+	0x8109, 0x1df0, 0x792c, 0xd1fc, 0x0110, 0x782b, 0x0004, 0x2011,
+	0x0011, 0x080c, 0x406a, 0x2011, 0x0001, 0x080c, 0x406a, 0x00fe,
+	0x00ee, 0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a61, 0x2079, 0x0320,
+	0x792c, 0xd1fc, 0x0904, 0x4067, 0x782b, 0x0002, 0x9026, 0xd19c,
+	0x1904, 0x4063, 0x7000, 0x0002, 0x4067, 0x4018, 0x4048, 0x4063,
+	0xd1bc, 0x1170, 0xd1dc, 0x1190, 0x8001, 0x7002, 0x2011, 0x0001,
+	0x080c, 0x406a, 0x0904, 0x4067, 0x080c, 0x406a, 0x0804, 0x4067,
+	0x00f6, 0x2079, 0x0300, 0x78bf, 0x0000, 0x00fe, 0x7810, 0x7914,
+	0x782b, 0x0004, 0x7812, 0x7916, 0x2001, 0x0201, 0x200c, 0x81ff,
+	0x0de8, 0x080c, 0x3f75, 0x2009, 0x0001, 0x00f6, 0x2079, 0x0300,
+	0x78b8, 0x00fe, 0xd0ec, 0x0110, 0x2009, 0x0011, 0x792a, 0x00f8,
+	0x8001, 0x7002, 0x9184, 0x0880, 0x1140, 0x782c, 0xd0fc, 0x1904,
+	0x400c, 0x2011, 0x0001, 0x00b1, 0x0090, 0xa010, 0x9092, 0x0004,
+	0x9086, 0x0015, 0x1120, 0xa000, 0xa05a, 0x2011, 0x0031, 0xa212,
+	0xd1dc, 0x1960, 0x0828, 0x782b, 0x0004, 0x7003, 0x0000, 0x00ee,
+	0x00fe, 0x0005, 0xa014, 0x9005, 0x0550, 0x8001, 0x0036, 0x0096,
+	0xa016, 0xa058, 0x2048, 0xa010, 0x2009, 0x0031, 0x911a, 0x831c,
+	0x831c, 0x938a, 0x0007, 0x1a0c, 0x0dd5, 0x9398, 0x4098, 0x231d,
+	0x083f, 0x9080, 0x0004, 0x7a2a, 0x7100, 0x8108, 0x7102, 0x009e,
+	0x003e, 0x908a, 0x0035, 0x1140, 0x0096, 0xa058, 0x2048, 0xa804,
+	0xa05a, 0x2001, 0x0019, 0x009e, 0xa012, 0x9085, 0x0001, 0x0005,
+	0x40d5, 0x40cc, 0x40c3, 0x40ba, 0x40b1, 0x40a8, 0x409f, 0xa964,
+	0x7902, 0xa968, 0x7906, 0xa96c, 0x7912, 0xa970, 0x7916, 0x0005,
+	0xa974, 0x7902, 0xa978, 0x7906, 0xa97c, 0x7912, 0xa980, 0x7916,
+	0x0005, 0xa984, 0x7902, 0xa988, 0x7906, 0xa98c, 0x7912, 0xa990,
+	0x7916, 0x0005, 0xa994, 0x7902, 0xa998, 0x7906, 0xa99c, 0x7912,
+	0xa9a0, 0x7916, 0x0005, 0xa9a4, 0x7902, 0xa9a8, 0x7906, 0xa9ac,
+	0x7912, 0xa9b0, 0x7916, 0x0005, 0xa9b4, 0x7902, 0xa9b8, 0x7906,
+	0xa9bc, 0x7912, 0xa9c0, 0x7916, 0x0005, 0xa9c4, 0x7902, 0xa9c8,
+	0x7906, 0xa9cc, 0x7912, 0xa9d0, 0x7916, 0x0005, 0x00f6, 0x00e6,
+	0x0086, 0x2071, 0x1a65, 0x2079, 0x0090, 0x792c, 0xd1fc, 0x01e8,
+	0x782b, 0x0002, 0x2940, 0x9026, 0x7000, 0x0002, 0x4105, 0x40f1,
+	0x40fc, 0x8001, 0x7002, 0xd19c, 0x1180, 0x2011, 0x0001, 0x080c,
+	0x406a, 0x190c, 0x406a, 0x0048, 0x8001, 0x7002, 0x782c, 0xd0fc,
+	0x1d38, 0x2011, 0x0001, 0x080c, 0x406a, 0x008e, 0x00ee, 0x00fe,
+	0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0086, 0x2061, 0x0200, 0x2001,
+	0x19a9, 0x2004, 0x601a, 0x2061, 0x0100, 0x2001, 0x19a8, 0x2004,
+	0x60ce, 0x6104, 0xc1ac, 0x6106, 0x2001, 0x002c, 0x2004, 0x9005,
+	0x0520, 0x2038, 0x2001, 0x002e, 0x2024, 0x2001, 0x002f, 0x201c,
+	0x080c, 0x4abe, 0xa813, 0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a,
+	0x0007, 0x0220, 0x2138, 0x2009, 0x0007, 0x0010, 0x2708, 0x903e,
+	0x0096, 0xa858, 0x2048, 0xa85c, 0x9080, 0x0019, 0x009e, 0x080c,
+	0x4181, 0x1d68, 0x2900, 0xa85a, 0x00d0, 0x080c, 0x4abe, 0xa813,
+	0x0019, 0xa817, 0x0001, 0x2900, 0xa85a, 0x2001, 0x002e, 0x2004,
+	0xa866, 0x2001, 0x002f, 0x2004, 0xa86a, 0x2001, 0x002a, 0x2004,
+	0x9084, 0xfff8, 0xa86e, 0x2001, 0x002b, 0x2004, 0xa872, 0x2061,
+	0x0090, 0x2079, 0x0100, 0x2001, 0x19a8, 0x2004, 0x6036, 0x2009,
+	0x0040, 0x080c, 0x23df, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8,
+	0x601a, 0x0006, 0x2001, 0x002b, 0x2004, 0x601e, 0x78c6, 0x000e,
+	0x78ca, 0x9006, 0x600a, 0x600e, 0x008e, 0x00ce, 0x00ee, 0x00fe,
+	0x0005, 0x00e6, 0x2071, 0x0080, 0xaa60, 0x22e8, 0x20a0, 0x20e1,
+	0x0000, 0x2099, 0x0088, 0x702b, 0x0026, 0x7402, 0x7306, 0x9006,
+	0x700a, 0x700e, 0x810b, 0x810b, 0x21a8, 0x810b, 0x7112, 0x702b,
+	0x0041, 0x702c, 0xd0fc, 0x0de8, 0x702b, 0x0002, 0x702b, 0x0040,
+	0x4005, 0x7400, 0x7304, 0x87ff, 0x0190, 0x0086, 0x0096, 0x2940,
+	0x0086, 0x080c, 0x4abe, 0x008e, 0xa058, 0x00a6, 0x2050, 0x2900,
+	0xb006, 0xa05a, 0x00ae, 0x009e, 0x008e, 0x9085, 0x0001, 0x00ee,
+	0x0005, 0x00e6, 0x2001, 0x002d, 0x2004, 0x9005, 0x0528, 0x2038,
+	0x2001, 0x0030, 0x2024, 0x2001, 0x0031, 0x201c, 0x080c, 0x4abe,
+	0x2940, 0xa813, 0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007,
+	0x0220, 0x2138, 0x2009, 0x0007, 0x0010, 0x2708, 0x903e, 0x0096,
+	0xa858, 0x2048, 0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x4181,
+	0x1d68, 0x2900, 0xa85a, 0x00d8, 0x080c, 0x4abe, 0x2940, 0xa013,
+	0x0019, 0xa017, 0x0001, 0x2800, 0xa05a, 0x2001, 0x0030, 0x2004,
+	0xa066, 0x2001, 0x0031, 0x2004, 0xa06a, 0x2001, 0x002a, 0x2004,
+	0x9084, 0xfff8, 0xa06e, 0x2001, 0x002b, 0x2004, 0xa072, 0x2001,
+	0x032a, 0x2003, 0x0004, 0x7884, 0xd0ac, 0x1180, 0x2001, 0x0101,
+	0x200c, 0x918d, 0x0200, 0x2102, 0xa017, 0x0000, 0x2001, 0x1a61,
+	0x2003, 0x0003, 0x2001, 0x032a, 0x2003, 0x0009, 0x2001, 0x0300,
+	0x2003, 0x0000, 0x2001, 0x020d, 0x2003, 0x0000, 0x2001, 0x0004,
+	0x200c, 0x918d, 0x0002, 0x2102, 0x00ee, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x20a9, 0x0007, 0x20a1, 0x1840, 0x20e9, 0x0001, 0x9006,
+	0x4004, 0x20a9, 0x0014, 0x20a1, 0xffec, 0x20e9, 0x0000, 0x9006,
+	0x4004, 0x2009, 0x013c, 0x200a, 0x012e, 0x7880, 0x9086, 0x0052,
+	0x0108, 0x0005, 0x0804, 0x3531, 0x7d98, 0x7c9c, 0x0804, 0x3633,
+	0x080c, 0x73b3, 0x190c, 0x5ff2, 0x6040, 0x9084, 0x0020, 0x09b1,
+	0x2069, 0x1847, 0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c,
+	0x7d98, 0x2039, 0x0001, 0x080c, 0x4b07, 0x701f, 0x4260, 0x0005,
+	0x080c, 0x56f1, 0x1130, 0x3b00, 0x3a08, 0xc194, 0xc095, 0x20d8,
+	0x21d0, 0x2069, 0x1847, 0x6800, 0x9005, 0x0904, 0x3566, 0x6804,
+	0xd0ac, 0x0118, 0xd0a4, 0x0904, 0x3566, 0xd094, 0x00c6, 0x2061,
+	0x0100, 0x6104, 0x0138, 0x6200, 0x9292, 0x0005, 0x0218, 0x918c,
+	0xffdf, 0x0010, 0x918d, 0x0020, 0x6106, 0x00ce, 0xd08c, 0x00c6,
+	0x2061, 0x0100, 0x6104, 0x0118, 0x918d, 0x0010, 0x0010, 0x918c,
+	0xffef, 0x6106, 0x00ce, 0xd084, 0x0158, 0x6a28, 0x928a, 0x007f,
+	0x1a04, 0x3566, 0x9288, 0x3332, 0x210d, 0x918c, 0x00ff, 0x6166,
+	0xd0dc, 0x0130, 0x6828, 0x908a, 0x007f, 0x1a04, 0x3566, 0x605e,
+	0x6888, 0x9084, 0x0030, 0x8004, 0x8004, 0x8004, 0x8004, 0x0006,
+	0x2009, 0x19b0, 0x9080, 0x2987, 0x2005, 0x200a, 0x000e, 0x2009,
+	0x19b1, 0x9080, 0x298b, 0x2005, 0x200a, 0x6808, 0x908a, 0x0100,
+	0x0a04, 0x3566, 0x908a, 0x0841, 0x1a04, 0x3566, 0x9084, 0x0007,
+	0x1904, 0x3566, 0x680c, 0x9005, 0x0904, 0x3566, 0x6810, 0x9005,
+	0x0904, 0x3566, 0x6848, 0x6940, 0x910a, 0x1a04, 0x3566, 0x8001,
+	0x0904, 0x3566, 0x684c, 0x6944, 0x910a, 0x1a04, 0x3566, 0x8001,
+	0x0904, 0x3566, 0x2009, 0x1980, 0x200b, 0x0000, 0x2001, 0x1869,
+	0x2004, 0xd0c4, 0x0140, 0x7884, 0x200a, 0x2009, 0x017f, 0x200a,
+	0x3b00, 0xc085, 0x20d8, 0x6814, 0x908c, 0x00ff, 0x614e, 0x8007,
+	0x9084, 0x00ff, 0x6052, 0x080c, 0x76ca, 0x080c, 0x69bb, 0x080c,
+	0x69ef, 0x6808, 0x602a, 0x080c, 0x2351, 0x2009, 0x0170, 0x200b,
+	0x0080, 0xa001, 0xa001, 0x200b, 0x0000, 0x0036, 0x6b08, 0x080c,
+	0x28ee, 0x003e, 0x6000, 0x9086, 0x0000, 0x1904, 0x43f7, 0x6818,
+	0x691c, 0x6a20, 0x6b24, 0x8007, 0x810f, 0x8217, 0x831f, 0x6016,
+	0x611a, 0x621e, 0x6322, 0x6c04, 0xd4f4, 0x0148, 0x6830, 0x6934,
+	0x6a38, 0x6b3c, 0x8007, 0x810f, 0x8217, 0x831f, 0x0010, 0x9084,
+	0xf0ff, 0x6006, 0x610a, 0x620e, 0x6312, 0x8007, 0x810f, 0x8217,
+	0x831f, 0x20a9, 0x0004, 0x20a1, 0x19b2, 0x20e9, 0x0001, 0x4001,
+	0x20a9, 0x0004, 0x20a1, 0x19cc, 0x20e9, 0x0001, 0x4001, 0x080c,
+	0x85f5, 0x00c6, 0x900e, 0x20a9, 0x0001, 0x6b70, 0xd384, 0x0510,
+	0x0068, 0x2009, 0x0100, 0x210c, 0x918e, 0x0008, 0x1110, 0x839d,
+	0x0010, 0x83f5, 0x3e18, 0x12b0, 0x3508, 0x8109, 0x080c, 0x7c81,
+	0x6878, 0x6016, 0x6874, 0x2008, 0x9084, 0xff00, 0x8007, 0x600a,
+	0x9184, 0x00ff, 0x6006, 0x8108, 0x1118, 0x6003, 0x0003, 0x0010,
+	0x6003, 0x0001, 0x1f04, 0x4351, 0x00ce, 0x00c6, 0x2061, 0x199b,
+	0x6a88, 0x9284, 0xc000, 0x2010, 0x9286, 0x0000, 0x1158, 0x2063,
+	0x0000, 0x2001, 0x0001, 0x080c, 0x2b95, 0x2001, 0x0001, 0x080c,
+	0x2b78, 0x0088, 0x9286, 0x4000, 0x1148, 0x2063, 0x0001, 0x9006,
+	0x080c, 0x2b95, 0x9006, 0x080c, 0x2b78, 0x0028, 0x9286, 0x8000,
+	0x1d30, 0x2063, 0x0002, 0x00ce, 0x6888, 0xd0ec, 0x0130, 0x2011,
+	0x0114, 0x2204, 0x9085, 0x0100, 0x2012, 0x6a80, 0x9284, 0x0030,
+	0x9086, 0x0030, 0x1128, 0x9294, 0xffcf, 0x9295, 0x0020, 0x6a82,
+	0x2001, 0x197b, 0x6a80, 0x9294, 0x0030, 0x928e, 0x0000, 0x0170,
+	0x928e, 0x0010, 0x0118, 0x928e, 0x0020, 0x0140, 0x2003, 0xaaaa,
+	0x080c, 0x2963, 0x2001, 0x196c, 0x2102, 0x0008, 0x2102, 0x00c6,
+	0x2061, 0x0100, 0x602f, 0x0040, 0x602f, 0x0000, 0x00ce, 0x080c,
+	0x73b3, 0x0128, 0x080c, 0x4fee, 0x0110, 0x080c, 0x28b4, 0x60d4,
+	0x9005, 0x01c0, 0x6003, 0x0001, 0x2009, 0x43df, 0x00e0, 0x080c,
+	0x73b3, 0x1168, 0x2011, 0x7249, 0x080c, 0x84f9, 0x2011, 0x723c,
+	0x080c, 0x85d3, 0x080c, 0x769e, 0x080c, 0x72e5, 0x0040, 0x080c,
+	0x5eec, 0x0028, 0x6003, 0x0004, 0x2009, 0x43f7, 0x0020, 0x080c,
+	0x68eb, 0x0804, 0x3531, 0x2001, 0x0170, 0x2004, 0x9084, 0x00ff,
+	0x9086, 0x004c, 0x1118, 0x2091, 0x30bd, 0x0817, 0x2091, 0x303d,
+	0x0817, 0x6000, 0x9086, 0x0000, 0x0904, 0x3563, 0x2069, 0x1847,
+	0x7890, 0x6842, 0x7894, 0x6846, 0x2d00, 0x2009, 0x0030, 0x7a8c,
+	0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0001, 0x0804, 0x4b0a, 0x9006,
+	0x080c, 0x28b4, 0x81ff, 0x1904, 0x3563, 0x080c, 0x73b3, 0x11b0,
+	0x080c, 0x7699, 0x080c, 0x602d, 0x080c, 0x3326, 0x0118, 0x6130,
+	0xc18d, 0x6132, 0x080c, 0xd25a, 0x0130, 0x080c, 0x73d6, 0x1118,
+	0x080c, 0x738b, 0x0038, 0x080c, 0x72e5, 0x0020, 0x080c, 0x5ff2,
+	0x080c, 0x5eec, 0x0804, 0x3531, 0x81ff, 0x1904, 0x3563, 0x080c,
+	0x73b3, 0x1110, 0x0804, 0x3563, 0x6194, 0x81ff, 0x01a8, 0x704f,
+	0x0000, 0x2001, 0x1c80, 0x2009, 0x0040, 0x7a8c, 0x7b88, 0x7c9c,
+	0x7d98, 0x0126, 0x2091, 0x8000, 0x2039, 0x0001, 0x080c, 0x4b0a,
+	0x701f, 0x352f, 0x012e, 0x0005, 0x704f, 0x0001, 0x00d6, 0x2069,
+	0x1c80, 0x20a9, 0x0040, 0x20e9, 0x0001, 0x20a1, 0x1c80, 0x2019,
+	0xffff, 0x4304, 0x655c, 0x9588, 0x3332, 0x210d, 0x918c, 0x00ff,
+	0x216a, 0x900e, 0x2011, 0x0002, 0x2100, 0x9506, 0x01a8, 0x080c,
+	0x6616, 0x1190, 0xb814, 0x821c, 0x0238, 0x9398, 0x1c80, 0x9085,
+	0xff00, 0x8007, 0x201a, 0x0038, 0x9398, 0x1c80, 0x2324, 0x94a4,
+	0xff00, 0x9405, 0x201a, 0x8210, 0x8108, 0x9182, 0x0080, 0x1208,
+	0x0c18, 0x8201, 0x8007, 0x2d0c, 0x9105, 0x206a, 0x00de, 0x20a9,
+	0x0040, 0x20a1, 0x1c80, 0x2099, 0x1c80, 0x080c, 0x5f7d, 0x0804,
+	0x4451, 0x080c, 0x4af1, 0x0904, 0x3566, 0x080c, 0x4abe, 0x1120,
+	0x2009, 0x0002, 0x0804, 0x3563, 0x080c, 0x56e2, 0xd0b4, 0x0558,
+	0x7884, 0x908e, 0x007e, 0x0538, 0x908e, 0x007f, 0x0520, 0x908e,
+	0x0080, 0x0508, 0x080c, 0x3321, 0x1148, 0xb800, 0xd08c, 0x11d8,
+	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x11a8, 0xa867, 0x0000,
+	0xa868, 0xc0fd, 0xa86a, 0x080c, 0xcd23, 0x1120, 0x2009, 0x0003,
+	0x0804, 0x3563, 0x7007, 0x0003, 0x701f, 0x44df, 0x0005, 0x080c,
+	0x4af1, 0x0904, 0x3566, 0x20a9, 0x002b, 0xb8c4, 0x20e0, 0xb8c8,
+	0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003,
+	0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0, 0xb8c4, 0x20e0, 0xb8c8,
+	0x9080, 0x0006, 0x2098, 0x080c, 0x0f7c, 0x0070, 0x20a9, 0x0004,
+	0xa85c, 0x9080, 0x000a, 0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080,
+	0x000a, 0x2098, 0x080c, 0x0f7c, 0x8906, 0x8006, 0x8007, 0x90bc,
+	0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009, 0x002b, 0x7a8c,
+	0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4b0a, 0x81ff, 0x1904, 0x3563,
+	0x080c, 0x4ad5, 0x0904, 0x3566, 0x080c, 0x6788, 0x0904, 0x3563,
+	0x0058, 0xa878, 0x9005, 0x0120, 0x2009, 0x0004, 0x0804, 0x3563,
+	0xa974, 0xaa94, 0x0804, 0x3531, 0x080c, 0x56ea, 0x0904, 0x3531,
+	0x701f, 0x4529, 0x7007, 0x0003, 0x0005, 0x81ff, 0x1904, 0x3563,
+	0x7888, 0x908a, 0x1000, 0x1a04, 0x3566, 0x080c, 0x4af1, 0x0904,
+	0x3566, 0x080c, 0x6989, 0x0120, 0x080c, 0x6991, 0x1904, 0x3566,
+	0x080c, 0x680d, 0x0904, 0x3563, 0x2019, 0x0004, 0x900e, 0x080c,
+	0x679a, 0x0904, 0x3563, 0x7984, 0x7a88, 0x04c9, 0x08a8, 0xa89c,
+	0x908a, 0x1000, 0x12f8, 0x080c, 0x4aef, 0x01e0, 0x080c, 0x6989,
+	0x0118, 0x080c, 0x6991, 0x11b0, 0x080c, 0x680d, 0x2009, 0x0002,
+	0x0168, 0x2009, 0x0002, 0x2019, 0x0004, 0x080c, 0x679a, 0x2009,
+	0x0003, 0x0120, 0xa998, 0xaa9c, 0x00d1, 0x0060, 0xa897, 0x4005,
+	0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001,
+	0x0030, 0x0005, 0xa897, 0x4000, 0x080c, 0x56ea, 0x0110, 0x9006,
+	0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x9186,
+	0x00ff, 0x0110, 0x0071, 0x0060, 0x2029, 0x007e, 0x2061, 0x1800,
+	0x645c, 0x2400, 0x9506, 0x0110, 0x2508, 0x0019, 0x8529, 0x1ec8,
+	0x0005, 0x080c, 0x6616, 0x1138, 0x2200, 0x8003, 0x800b, 0x810b,
+	0x9108, 0x080c, 0x8507, 0x0005, 0x81ff, 0x1904, 0x3563, 0x798c,
+	0x2001, 0x197f, 0x918c, 0x8000, 0x2102, 0x080c, 0x4ad5, 0x0904,
+	0x3566, 0x080c, 0x6989, 0x0120, 0x080c, 0x6991, 0x1904, 0x3566,
+	0x080c, 0x66dd, 0x0904, 0x3563, 0x080c, 0x6791, 0x0904, 0x3563,
+	0x2001, 0x197f, 0x2004, 0xd0fc, 0x1904, 0x3531, 0x0804, 0x4534,
+	0xa9a0, 0x2001, 0x197f, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c,
+	0x4ae2, 0x01a0, 0x080c, 0x6989, 0x0118, 0x080c, 0x6991, 0x1170,
+	0x080c, 0x66dd, 0x2009, 0x0002, 0x0128, 0x080c, 0x6791, 0x1170,
+	0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
+	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000,
+	0x2001, 0x197f, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x56ea, 0x0110,
+	0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005,
+	0x81ff, 0x1904, 0x3563, 0x798c, 0x2001, 0x197e, 0x918c, 0x8000,
+	0x2102, 0x080c, 0x4ad5, 0x0904, 0x3566, 0x080c, 0x6989, 0x0120,
+	0x080c, 0x6991, 0x1904, 0x3566, 0x080c, 0x66dd, 0x0904, 0x3563,
+	0x080c, 0x677f, 0x0904, 0x3563, 0x2001, 0x197e, 0x2004, 0xd0fc,
+	0x1904, 0x3531, 0x0804, 0x4534, 0xa9a0, 0x2001, 0x197e, 0x918c,
+	0x8000, 0xc18d, 0x2102, 0x080c, 0x4ae2, 0x01a0, 0x080c, 0x6989,
+	0x0118, 0x080c, 0x6991, 0x1170, 0x080c, 0x66dd, 0x2009, 0x0002,
+	0x0128, 0x080c, 0x677f, 0x1170, 0x2009, 0x0003, 0xa897, 0x4005,
+	0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001,
+	0x0030, 0x0005, 0xa897, 0x4000, 0x2001, 0x197e, 0x2004, 0xd0fc,
+	0x1128, 0x080c, 0x56ea, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085,
+	0x0001, 0x2001, 0x0000, 0x0005, 0x6100, 0x0804, 0x3531, 0x080c,
+	0x4af1, 0x0904, 0x3566, 0x080c, 0x56f6, 0x1904, 0x3563, 0x79a8,
+	0xd184, 0x1158, 0xb834, 0x8007, 0x789e, 0xb830, 0x8007, 0x789a,
+	0xbb2c, 0x831f, 0xba28, 0x8217, 0x0050, 0xb824, 0x8007, 0x789e,
+	0xb820, 0x8007, 0x789a, 0xbb1c, 0x831f, 0xba18, 0x8217, 0xb900,
+	0x918c, 0x0200, 0x0804, 0x3531, 0x78a8, 0x909c, 0x0003, 0xd0ac,
+	0x1150, 0xd0b4, 0x1140, 0x939a, 0x0003, 0x1a04, 0x3563, 0x625c,
+	0x7884, 0x9206, 0x15e8, 0x080c, 0x85df, 0x2001, 0xffec, 0x7a8c,
+	0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0000, 0x0006, 0x78a8, 0x9084,
+	0x0080, 0x11c8, 0x0006, 0x0036, 0x2001, 0x1a7e, 0x201c, 0x7b9a,
+	0x2003, 0x0000, 0x2001, 0x1a7f, 0x201c, 0x7b9e, 0x2003, 0x0000,
+	0x2001, 0x1a80, 0x201c, 0x7ba2, 0x2003, 0x0000, 0x003e, 0x000e,
+	0x000e, 0x0804, 0x4b0a, 0x000e, 0x2031, 0x0000, 0x2061, 0x18b8,
+	0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e, 0xa392, 0xa496,
+	0xa59a, 0x080c, 0x10e9, 0x7007, 0x0002, 0x701f, 0x4700, 0x0005,
+	0x81ff, 0x1904, 0x3563, 0x080c, 0x4af1, 0x0904, 0x3566, 0x080c,
+	0x6989, 0x1904, 0x3563, 0x00c6, 0x080c, 0x4abe, 0x00ce, 0x0904,
+	0x3563, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7ea8, 0x080c,
+	0xccc9, 0x0904, 0x3563, 0x7007, 0x0003, 0x701f, 0x471a, 0x0005,
+	0x080c, 0x4226, 0x0006, 0x0036, 0x2001, 0x1a7e, 0x201c, 0x7b9a,
+	0x2003, 0x0000, 0x2001, 0x1a7f, 0x201c, 0x7b9e, 0x2003, 0x0000,
+	0x2001, 0x1a80, 0x201c, 0x7ba2, 0x2003, 0x0000, 0x003e, 0x000e,
+	0x0804, 0x3531, 0xa830, 0x9086, 0x0100, 0x0904, 0x3563, 0x8906,
+	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b,
+	0x2009, 0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4b0a,
+	0x9006, 0x080c, 0x28b4, 0x78a8, 0x9084, 0x00ff, 0x9086, 0x00ff,
+	0x0118, 0x81ff, 0x1904, 0x3563, 0x080c, 0x73b3, 0x0110, 0x080c,
+	0x5ff2, 0x7888, 0x908a, 0x1000, 0x1a04, 0x3566, 0x7984, 0x9186,
+	0x00ff, 0x0138, 0x9182, 0x007f, 0x1a04, 0x3566, 0x2100, 0x080c,
+	0x287e, 0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x2061, 0x19f9,
+	0x601b, 0x0000, 0x601f, 0x0000, 0x6073, 0x0000, 0x6077, 0x0000,
+	0x080c, 0x73b3, 0x1158, 0x080c, 0x7699, 0x080c, 0x602d, 0x9085,
+	0x0001, 0x080c, 0x73fa, 0x080c, 0x72e5, 0x00d0, 0x080c, 0xadd0,
+	0x2061, 0x0100, 0x2001, 0x1818, 0x2004, 0x9084, 0x00ff, 0x810f,
+	0x9105, 0x604a, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x1998,
+	0x200b, 0x0000, 0x2009, 0x002d, 0x2011, 0x5f18, 0x080c, 0x8591,
+	0x7984, 0x080c, 0x73b3, 0x1110, 0x2009, 0x00ff, 0x7a88, 0x080c,
+	0x4597, 0x012e, 0x00ce, 0x002e, 0x0804, 0x3531, 0x7984, 0x080c,
+	0x65b5, 0x2b08, 0x1904, 0x3566, 0x0804, 0x3531, 0x81ff, 0x0120,
+	0x2009, 0x0001, 0x0804, 0x3563, 0x60dc, 0xd0ac, 0x1130, 0xd09c,
+	0x1120, 0x2009, 0x0005, 0x0804, 0x3563, 0x080c, 0x4abe, 0x1120,
+	0x2009, 0x0002, 0x0804, 0x3563, 0x7984, 0x9192, 0x0021, 0x1a04,
+	0x3566, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019,
+	0x702a, 0xaf60, 0x7736, 0x080c, 0x4b07, 0x701f, 0x47ce, 0x7880,
+	0x9086, 0x006e, 0x0110, 0x701f, 0x51a0, 0x0005, 0x2009, 0x0080,
+	0x080c, 0x6616, 0x1118, 0x080c, 0x6989, 0x0120, 0x2021, 0x400a,
+	0x0804, 0x3533, 0x00d6, 0x0096, 0xa964, 0xaa6c, 0xab70, 0xac74,
+	0xad78, 0xae7c, 0xa884, 0x90be, 0x0100, 0x0904, 0x4867, 0x90be,
+	0x0112, 0x0904, 0x4867, 0x90be, 0x0113, 0x0904, 0x4867, 0x90be,
+	0x0114, 0x0904, 0x4867, 0x90be, 0x0117, 0x0904, 0x4867, 0x90be,
+	0x011a, 0x0904, 0x4867, 0x90be, 0x011c, 0x0904, 0x4867, 0x90be,
+	0x0121, 0x0904, 0x484e, 0x90be, 0x0131, 0x0904, 0x484e, 0x90be,
+	0x0171, 0x0904, 0x4867, 0x90be, 0x0173, 0x0904, 0x4867, 0x90be,
+	0x01a1, 0x1128, 0xa894, 0x8007, 0xa896, 0x0804, 0x4872, 0x90be,
+	0x0212, 0x0904, 0x485b, 0x90be, 0x0213, 0x05e8, 0x90be, 0x0214,
+	0x0500, 0x90be, 0x0217, 0x0188, 0x90be, 0x021a, 0x1120, 0xa89c,
+	0x8007, 0xa89e, 0x04e0, 0x90be, 0x021f, 0x05c8, 0x90be, 0x0300,
+	0x05b0, 0x009e, 0x00de, 0x0804, 0x3566, 0x7028, 0x9080, 0x0010,
+	0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0007, 0x080c,
+	0x48b0, 0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034, 0x20e0,
+	0x20e8, 0x20a9, 0x0001, 0x080c, 0x48b0, 0x00c8, 0x7028, 0x9080,
+	0x000c, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001,
+	0x080c, 0x48bd, 0x00b8, 0x7028, 0x9080, 0x000e, 0x2098, 0x20a0,
+	0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x48bd, 0x7028,
+	0x9080, 0x000c, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9,
+	0x0001, 0x04f1, 0x00c6, 0x080c, 0x4abe, 0x0550, 0xa868, 0xc0fd,
+	0xa86a, 0xa867, 0x0119, 0x9006, 0xa882, 0xa87f, 0x0020, 0xa88b,
+	0x0001, 0x810b, 0xa9ae, 0xa8b2, 0xaab6, 0xabba, 0xacbe, 0xadc2,
+	0xa9c6, 0xa8ca, 0x00ce, 0x009e, 0x00de, 0xa866, 0xa822, 0xa868,
+	0xc0fd, 0xa86a, 0xa804, 0x2048, 0x080c, 0xcce4, 0x1120, 0x2009,
+	0x0003, 0x0804, 0x3563, 0x7007, 0x0003, 0x701f, 0x48a7, 0x0005,
+	0x00ce, 0x009e, 0x00de, 0x2009, 0x0002, 0x0804, 0x3563, 0xa820,
+	0x9086, 0x8001, 0x1904, 0x3531, 0x2009, 0x0004, 0x0804, 0x3563,
+	0x0016, 0x0026, 0x3510, 0x20a9, 0x0002, 0x4002, 0x4104, 0x4004,
+	0x8211, 0x1dc8, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026, 0x0036,
+	0x0046, 0x3520, 0x20a9, 0x0004, 0x4002, 0x4304, 0x4204, 0x4104,
+	0x4004, 0x8421, 0x1db8, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005,
+	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3563, 0x60dc, 0xd0ac,
+	0x1130, 0xd09c, 0x1120, 0x2009, 0x0005, 0x0804, 0x3563, 0x7984,
+	0x78a8, 0x2040, 0x080c, 0xadc9, 0x1120, 0x9182, 0x007f, 0x0a04,
+	0x3566, 0x9186, 0x00ff, 0x0904, 0x3566, 0x9182, 0x0800, 0x1a04,
+	0x3566, 0x7a8c, 0x7b88, 0x607c, 0x9306, 0x1158, 0x6080, 0x924e,
+	0x0904, 0x3566, 0x080c, 0xadc9, 0x1120, 0x99cc, 0xff00, 0x0904,
+	0x3566, 0x0126, 0x2091, 0x8000, 0x080c, 0x49d1, 0x0904, 0x4951,
+	0x0086, 0x90c6, 0x4000, 0x008e, 0x1538, 0x00c6, 0x0006, 0x0036,
+	0xb818, 0xbb1c, 0x9305, 0xbb20, 0x9305, 0xbb24, 0x9305, 0xbb28,
+	0x9305, 0xbb2c, 0x9305, 0xbb30, 0x9305, 0xbb34, 0x9305, 0x003e,
+	0x0570, 0xd88c, 0x1128, 0x080c, 0x6989, 0x0110, 0xc89d, 0x0438,
+	0x900e, 0x080c, 0x6836, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
+	0xc18d, 0x000e, 0x00ce, 0x00b8, 0x90c6, 0x4007, 0x1110, 0x2408,
+	0x0090, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0060, 0x90c6,
+	0x4009, 0x1108, 0x0040, 0x90c6, 0x4006, 0x1108, 0x0020, 0x2001,
+	0x4005, 0x2009, 0x000a, 0x2020, 0x012e, 0x0804, 0x3533, 0x000e,
+	0x00ce, 0x2b00, 0x7026, 0x0016, 0x00b6, 0x00c6, 0x00e6, 0x2c70,
+	0x080c, 0xaead, 0x0904, 0x49a6, 0x2b00, 0x6012, 0x080c, 0xcfd4,
+	0x2e58, 0x00ee, 0x00e6, 0x00c6, 0x080c, 0x4abe, 0x00ce, 0x2b70,
+	0x1158, 0x080c, 0xae5f, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e,
+	0x2009, 0x0002, 0x0804, 0x3563, 0x900e, 0xa966, 0xa96a, 0x2900,
+	0x6016, 0xa932, 0xa868, 0xc0fd, 0xd88c, 0x0108, 0xc0f5, 0xa86a,
+	0xd89c, 0x1110, 0x080c, 0x31cc, 0x6023, 0x0001, 0x9006, 0x080c,
+	0x6552, 0xd89c, 0x0138, 0x2001, 0x0004, 0x080c, 0x6566, 0x2009,
+	0x0003, 0x0030, 0x2001, 0x0002, 0x080c, 0x6566, 0x2009, 0x0002,
+	0x080c, 0xaeda, 0x78a8, 0xd094, 0x0138, 0x00ee, 0x7024, 0x00e6,
+	0x2058, 0xb8cc, 0xc08d, 0xb8ce, 0x9085, 0x0001, 0x00ee, 0x00ce,
+	0x00be, 0x001e, 0x012e, 0x1120, 0x2009, 0x0003, 0x0804, 0x3563,
+	0x7007, 0x0003, 0x701f, 0x49b5, 0x0005, 0xa830, 0x9086, 0x0100,
+	0x7024, 0x2058, 0x1138, 0x2009, 0x0004, 0xba04, 0x9294, 0x00ff,
+	0x0804, 0x563f, 0x900e, 0xa868, 0xd0f4, 0x1904, 0x3531, 0x080c,
+	0x6836, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804,
+	0x3531, 0x00e6, 0x00d6, 0x0096, 0x83ff, 0x0904, 0x4a20, 0x902e,
+	0x080c, 0xadc9, 0x0130, 0x9026, 0x20a9, 0x0800, 0x2071, 0x1000,
+	0x0030, 0x2021, 0x007f, 0x20a9, 0x0781, 0x2071, 0x107f, 0x2e04,
+	0x9005, 0x11b8, 0x2100, 0x9406, 0x1904, 0x4a31, 0x2428, 0x94ce,
+	0x007f, 0x1120, 0x92ce, 0xfffd, 0x1558, 0x0030, 0x94ce, 0x0080,
+	0x1130, 0x92ce, 0xfffc, 0x1520, 0x93ce, 0x00ff, 0x1508, 0xc5fd,
+	0x0480, 0x2058, 0xbf10, 0x2700, 0x9306, 0x11e8, 0xbe14, 0x2600,
+	0x9206, 0x11c8, 0x2400, 0x9106, 0x1180, 0xd884, 0x0598, 0xd894,
+	0x1588, 0x080c, 0x6929, 0x1570, 0x2001, 0x4000, 0x0460, 0x080c,
+	0x6989, 0x1540, 0x2001, 0x4000, 0x0430, 0x2001, 0x4007, 0x0418,
+	0x2001, 0x4006, 0x0400, 0x2400, 0x9106, 0x1158, 0xbe14, 0x87ff,
+	0x1128, 0x86ff, 0x0918, 0x080c, 0xadc9, 0x1900, 0x2001, 0x4008,
+	0x0090, 0x8420, 0x8e70, 0x1f04, 0x49e7, 0x85ff, 0x1130, 0x2001,
+	0x4009, 0x0048, 0x2001, 0x0001, 0x0030, 0x080c, 0x65b5, 0x1dd0,
+	0xbb12, 0xba16, 0x9006, 0x9005, 0x009e, 0x00de, 0x00ee, 0x0005,
+	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3563, 0x080c, 0x4abe,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x3563, 0xa867, 0x0000, 0xa868,
+	0xc0fd, 0xa86a, 0x7884, 0x9005, 0x0904, 0x3566, 0x9096, 0x00ff,
+	0x0120, 0x9092, 0x0004, 0x1a04, 0x3566, 0x2010, 0x2918, 0x080c,
+	0x3172, 0x1120, 0x2009, 0x0003, 0x0804, 0x3563, 0x7007, 0x0003,
+	0x701f, 0x4a73, 0x0005, 0xa830, 0x9086, 0x0100, 0x1904, 0x3531,
+	0x2009, 0x0004, 0x0804, 0x3563, 0x7984, 0x080c, 0xadc9, 0x1120,
+	0x9182, 0x007f, 0x0a04, 0x3566, 0x9186, 0x00ff, 0x0904, 0x3566,
+	0x9182, 0x0800, 0x1a04, 0x3566, 0x2001, 0x9000, 0x080c, 0x569a,
+	0x1904, 0x3563, 0x0804, 0x3531, 0xa998, 0x080c, 0xadc9, 0x1118,
+	0x9182, 0x007f, 0x0280, 0x9186, 0x00ff, 0x0168, 0x9182, 0x0800,
+	0x1250, 0x2001, 0x9000, 0x080c, 0x569a, 0x11a8, 0x0060, 0xa897,
 	0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001,
-	0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0x2001, 0x197f, 0x2004,
-	0xd0fc, 0x1128, 0x080c, 0x56e0, 0x0110, 0x9006, 0x0018, 0x900e,
-	0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x81ff, 0x1904, 0x3558,
-	0x798c, 0x2001, 0x197e, 0x918c, 0x8000, 0x2102, 0x080c, 0x4acb,
-	0x0904, 0x355b, 0x080c, 0x697b, 0x0120, 0x080c, 0x6983, 0x1904,
-	0x355b, 0x080c, 0x66cf, 0x0904, 0x3558, 0x080c, 0x6771, 0x0904,
-	0x3558, 0x2001, 0x197e, 0x2004, 0xd0fc, 0x1904, 0x3526, 0x0804,
-	0x4529, 0xa9a0, 0x2001, 0x197e, 0x918c, 0x8000, 0xc18d, 0x2102,
-	0x080c, 0x4ad8, 0x01a0, 0x080c, 0x697b, 0x0118, 0x080c, 0x6983,
-	0x1170, 0x080c, 0x66cf, 0x2009, 0x0002, 0x0128, 0x080c, 0x6771,
-	0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
-	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
-	0x4000, 0x2001, 0x197e, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x56e0,
-	0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000,
-	0x0005, 0x6100, 0x0804, 0x3526, 0x080c, 0x4ae7, 0x0904, 0x355b,
-	0x080c, 0x56ec, 0x1904, 0x3558, 0x79a8, 0xd184, 0x1158, 0xb834,
-	0x8007, 0x789e, 0xb830, 0x8007, 0x789a, 0xbb2c, 0x831f, 0xba28,
-	0x8217, 0x0050, 0xb824, 0x8007, 0x789e, 0xb820, 0x8007, 0x789a,
-	0xbb1c, 0x831f, 0xba18, 0x8217, 0xb900, 0x918c, 0x0200, 0x0804,
-	0x3526, 0x78a8, 0x909c, 0x0003, 0xd0b4, 0x1148, 0x939a, 0x0003,
-	0x1a04, 0x3558, 0x625c, 0x7884, 0x9206, 0x1904, 0x46d6, 0x080c,
-	0x85c2, 0x2001, 0xfff4, 0x2009, 0x000c, 0x7a8c, 0x7b88, 0x7c9c,
-	0x7d98, 0x2039, 0x0000, 0x0006, 0x78a8, 0x9084, 0x0080, 0x11c8,
-	0x0006, 0x0036, 0x2001, 0x1a7e, 0x201c, 0x7b9a, 0x2003, 0x0000,
-	0x2001, 0x1a7f, 0x201c, 0x7b9e, 0x2003, 0x0000, 0x2001, 0x1a80,
-	0x201c, 0x7ba2, 0x2003, 0x0000, 0x003e, 0x000e, 0x000e, 0x0804,
-	0x4b00, 0x000e, 0x2031, 0x0000, 0x2061, 0x18b8, 0x2c44, 0xa66a,
+	0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0x900e, 0x9085, 0x0001,
+	0x2001, 0x0000, 0x0005, 0x2009, 0x000a, 0x0c48, 0x080c, 0x0fff,
+	0x0198, 0x9006, 0xa802, 0x7014, 0x9005, 0x1120, 0x2900, 0x7016,
+	0x701a, 0x0040, 0x7018, 0xa802, 0x0086, 0x2040, 0x2900, 0xa006,
+	0x701a, 0x008e, 0x9085, 0x0001, 0x0005, 0x7984, 0x080c, 0x6616,
+	0x1130, 0x7e88, 0x9684, 0x3fff, 0x9082, 0x4000, 0x0208, 0x905e,
+	0x8bff, 0x0005, 0xa998, 0x080c, 0x6616, 0x1130, 0xae9c, 0x9684,
+	0x3fff, 0x9082, 0x4000, 0x0208, 0x905e, 0x8bff, 0x0005, 0xae98,
+	0x0008, 0x7e84, 0x2608, 0x080c, 0x6616, 0x1108, 0x0008, 0x905e,
+	0x8bff, 0x0005, 0x0016, 0x7114, 0x81ff, 0x0128, 0x2148, 0xa904,
+	0x080c, 0x1031, 0x0cc8, 0x7116, 0x711a, 0x001e, 0x0005, 0x2031,
+	0x0001, 0x0010, 0x2031, 0x0000, 0x2061, 0x18b8, 0x2c44, 0xa66a,
 	0xa17a, 0xa772, 0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c,
-	0x10e9, 0x7007, 0x0002, 0x701f, 0x46f6, 0x0005, 0x81ff, 0x1904,
-	0x3558, 0x080c, 0x4ae7, 0x0904, 0x355b, 0x080c, 0x697b, 0x1904,
-	0x3558, 0x00c6, 0x080c, 0x4ab4, 0x00ce, 0x0904, 0x3558, 0xa867,
-	0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7ea8, 0x080c, 0xccb9, 0x0904,
-	0x3558, 0x7007, 0x0003, 0x701f, 0x4710, 0x0005, 0x080c, 0x421b,
-	0x0006, 0x0036, 0x2001, 0x1a7e, 0x201c, 0x7b9a, 0x2003, 0x0000,
-	0x2001, 0x1a7f, 0x201c, 0x7b9e, 0x2003, 0x0000, 0x2001, 0x1a80,
-	0x201c, 0x7ba2, 0x2003, 0x0000, 0x003e, 0x000e, 0x0804, 0x3526,
-	0xa830, 0x9086, 0x0100, 0x0904, 0x3558, 0x8906, 0x8006, 0x8007,
-	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x2009, 0x000c,
-	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4b00, 0x9006, 0x080c,
-	0x28a9, 0x78a8, 0x9084, 0x00ff, 0x9086, 0x00ff, 0x0118, 0x81ff,
-	0x1904, 0x3558, 0x080c, 0x73a5, 0x0110, 0x080c, 0x5fe8, 0x7888,
-	0x908a, 0x1000, 0x1a04, 0x355b, 0x7984, 0x9186, 0x00ff, 0x0138,
-	0x9182, 0x007f, 0x1a04, 0x355b, 0x2100, 0x080c, 0x2873, 0x0026,
-	0x00c6, 0x0126, 0x2091, 0x8000, 0x2061, 0x19f9, 0x601b, 0x0000,
-	0x601f, 0x0000, 0x6073, 0x0000, 0x6077, 0x0000, 0x080c, 0x73a5,
-	0x1158, 0x080c, 0x768d, 0x080c, 0x6023, 0x9085, 0x0001, 0x080c,
-	0x73ec, 0x080c, 0x72d7, 0x00d0, 0x080c, 0xade2, 0x2061, 0x0100,
-	0x2001, 0x1818, 0x2004, 0x9084, 0x00ff, 0x810f, 0x9105, 0x604a,
-	0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x1998, 0x200b, 0x0000,
-	0x2009, 0x002d, 0x2011, 0x5f0e, 0x080c, 0x8574, 0x7984, 0x080c,
-	0x73a5, 0x1110, 0x2009, 0x00ff, 0x7a88, 0x080c, 0x458c, 0x012e,
-	0x00ce, 0x002e, 0x0804, 0x3526, 0x7984, 0x080c, 0x65a7, 0x2b08,
-	0x1904, 0x355b, 0x0804, 0x3526, 0x81ff, 0x0120, 0x2009, 0x0001,
-	0x0804, 0x3558, 0x60dc, 0xd0ac, 0x1130, 0xd09c, 0x1120, 0x2009,
-	0x0005, 0x0804, 0x3558, 0x080c, 0x4ab4, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x3558, 0x7984, 0x9192, 0x0021, 0x1a04, 0x355b, 0x7a8c,
-	0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0x702a, 0xaf60,
-	0x7736, 0x080c, 0x4afd, 0x701f, 0x47c4, 0x7880, 0x9086, 0x006e,
-	0x0110, 0x701f, 0x5196, 0x0005, 0x2009, 0x0080, 0x080c, 0x6608,
-	0x1118, 0x080c, 0x697b, 0x0120, 0x2021, 0x400a, 0x0804, 0x3528,
-	0x00d6, 0x0096, 0xa964, 0xaa6c, 0xab70, 0xac74, 0xad78, 0xae7c,
-	0xa884, 0x90be, 0x0100, 0x0904, 0x485d, 0x90be, 0x0112, 0x0904,
-	0x485d, 0x90be, 0x0113, 0x0904, 0x485d, 0x90be, 0x0114, 0x0904,
-	0x485d, 0x90be, 0x0117, 0x0904, 0x485d, 0x90be, 0x011a, 0x0904,
-	0x485d, 0x90be, 0x011c, 0x0904, 0x485d, 0x90be, 0x0121, 0x0904,
-	0x4844, 0x90be, 0x0131, 0x0904, 0x4844, 0x90be, 0x0171, 0x0904,
-	0x485d, 0x90be, 0x0173, 0x0904, 0x485d, 0x90be, 0x01a1, 0x1128,
-	0xa894, 0x8007, 0xa896, 0x0804, 0x4868, 0x90be, 0x0212, 0x0904,
-	0x4851, 0x90be, 0x0213, 0x05e8, 0x90be, 0x0214, 0x0500, 0x90be,
-	0x0217, 0x0188, 0x90be, 0x021a, 0x1120, 0xa89c, 0x8007, 0xa89e,
-	0x04e0, 0x90be, 0x021f, 0x05c8, 0x90be, 0x0300, 0x05b0, 0x009e,
-	0x00de, 0x0804, 0x355b, 0x7028, 0x9080, 0x0010, 0x2098, 0x20a0,
-	0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0007, 0x080c, 0x48a6, 0x7028,
-	0x9080, 0x000e, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9,
-	0x0001, 0x080c, 0x48a6, 0x00c8, 0x7028, 0x9080, 0x000c, 0x2098,
-	0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x48b3,
-	0x00b8, 0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034, 0x20e0,
-	0x20e8, 0x20a9, 0x0001, 0x080c, 0x48b3, 0x7028, 0x9080, 0x000c,
-	0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x04f1,
-	0x00c6, 0x080c, 0x4ab4, 0x0550, 0xa868, 0xc0fd, 0xa86a, 0xa867,
-	0x0119, 0x9006, 0xa882, 0xa87f, 0x0020, 0xa88b, 0x0001, 0x810b,
-	0xa9ae, 0xa8b2, 0xaab6, 0xabba, 0xacbe, 0xadc2, 0xa9c6, 0xa8ca,
-	0x00ce, 0x009e, 0x00de, 0xa866, 0xa822, 0xa868, 0xc0fd, 0xa86a,
-	0xa804, 0x2048, 0x080c, 0xccd4, 0x1120, 0x2009, 0x0003, 0x0804,
-	0x3558, 0x7007, 0x0003, 0x701f, 0x489d, 0x0005, 0x00ce, 0x009e,
-	0x00de, 0x2009, 0x0002, 0x0804, 0x3558, 0xa820, 0x9086, 0x8001,
-	0x1904, 0x3526, 0x2009, 0x0004, 0x0804, 0x3558, 0x0016, 0x0026,
-	0x3510, 0x20a9, 0x0002, 0x4002, 0x4104, 0x4004, 0x8211, 0x1dc8,
-	0x002e, 0x001e, 0x0005, 0x0016, 0x0026, 0x0036, 0x0046, 0x3520,
-	0x20a9, 0x0004, 0x4002, 0x4304, 0x4204, 0x4104, 0x4004, 0x8421,
-	0x1db8, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005, 0x81ff, 0x0120,
-	0x2009, 0x0001, 0x0804, 0x3558, 0x60dc, 0xd0ac, 0x1130, 0xd09c,
-	0x1120, 0x2009, 0x0005, 0x0804, 0x3558, 0x7984, 0x78a8, 0x2040,
-	0x080c, 0xaddb, 0x1120, 0x9182, 0x007f, 0x0a04, 0x355b, 0x9186,
-	0x00ff, 0x0904, 0x355b, 0x9182, 0x0800, 0x1a04, 0x355b, 0x7a8c,
-	0x7b88, 0x607c, 0x9306, 0x1158, 0x6080, 0x924e, 0x0904, 0x355b,
-	0x080c, 0xaddb, 0x1120, 0x99cc, 0xff00, 0x0904, 0x355b, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x49c7, 0x0904, 0x4947, 0x0086, 0x90c6,
-	0x4000, 0x008e, 0x1538, 0x00c6, 0x0006, 0x0036, 0xb818, 0xbb1c,
-	0x9305, 0xbb20, 0x9305, 0xbb24, 0x9305, 0xbb28, 0x9305, 0xbb2c,
-	0x9305, 0xbb30, 0x9305, 0xbb34, 0x9305, 0x003e, 0x0570, 0xd88c,
-	0x1128, 0x080c, 0x697b, 0x0110, 0xc89d, 0x0438, 0x900e, 0x080c,
-	0x6828, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x000e,
-	0x00ce, 0x00b8, 0x90c6, 0x4007, 0x1110, 0x2408, 0x0090, 0x90c6,
-	0x4008, 0x1118, 0x2708, 0x2610, 0x0060, 0x90c6, 0x4009, 0x1108,
-	0x0040, 0x90c6, 0x4006, 0x1108, 0x0020, 0x2001, 0x4005, 0x2009,
-	0x000a, 0x2020, 0x012e, 0x0804, 0x3528, 0x000e, 0x00ce, 0x2b00,
-	0x7026, 0x0016, 0x00b6, 0x00c6, 0x00e6, 0x2c70, 0x080c, 0xaebf,
-	0x0904, 0x499c, 0x2b00, 0x6012, 0x080c, 0xcfc4, 0x2e58, 0x00ee,
-	0x00e6, 0x00c6, 0x080c, 0x4ab4, 0x00ce, 0x2b70, 0x1158, 0x080c,
-	0xae71, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x2009, 0x0002,
-	0x0804, 0x3558, 0x900e, 0xa966, 0xa96a, 0x2900, 0x6016, 0xa932,
-	0xa868, 0xc0fd, 0xd88c, 0x0108, 0xc0f5, 0xa86a, 0xd89c, 0x1110,
-	0x080c, 0x31c1, 0x6023, 0x0001, 0x9006, 0x080c, 0x6544, 0xd89c,
-	0x0138, 0x2001, 0x0004, 0x080c, 0x6558, 0x2009, 0x0003, 0x0030,
-	0x2001, 0x0002, 0x080c, 0x6558, 0x2009, 0x0002, 0x080c, 0xaeec,
-	0x78a8, 0xd094, 0x0138, 0x00ee, 0x7024, 0x00e6, 0x2058, 0xb8cc,
-	0xc08d, 0xb8ce, 0x9085, 0x0001, 0x00ee, 0x00ce, 0x00be, 0x001e,
-	0x012e, 0x1120, 0x2009, 0x0003, 0x0804, 0x3558, 0x7007, 0x0003,
-	0x701f, 0x49ab, 0x0005, 0xa830, 0x9086, 0x0100, 0x7024, 0x2058,
-	0x1138, 0x2009, 0x0004, 0xba04, 0x9294, 0x00ff, 0x0804, 0x5635,
-	0x900e, 0xa868, 0xd0f4, 0x1904, 0x3526, 0x080c, 0x6828, 0x1108,
-	0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3526, 0x00e6,
-	0x00d6, 0x0096, 0x83ff, 0x0904, 0x4a16, 0x902e, 0x080c, 0xaddb,
-	0x0130, 0x9026, 0x20a9, 0x0800, 0x2071, 0x1000, 0x0030, 0x2021,
-	0x007f, 0x20a9, 0x0781, 0x2071, 0x107f, 0x2e04, 0x9005, 0x11b8,
-	0x2100, 0x9406, 0x1904, 0x4a27, 0x2428, 0x94ce, 0x007f, 0x1120,
-	0x92ce, 0xfffd, 0x1558, 0x0030, 0x94ce, 0x0080, 0x1130, 0x92ce,
-	0xfffc, 0x1520, 0x93ce, 0x00ff, 0x1508, 0xc5fd, 0x0480, 0x2058,
-	0xbf10, 0x2700, 0x9306, 0x11e8, 0xbe14, 0x2600, 0x9206, 0x11c8,
-	0x2400, 0x9106, 0x1180, 0xd884, 0x0598, 0xd894, 0x1588, 0x080c,
-	0x691b, 0x1570, 0x2001, 0x4000, 0x0460, 0x080c, 0x697b, 0x1540,
-	0x2001, 0x4000, 0x0430, 0x2001, 0x4007, 0x0418, 0x2001, 0x4006,
-	0x0400, 0x2400, 0x9106, 0x1158, 0xbe14, 0x87ff, 0x1128, 0x86ff,
-	0x0918, 0x080c, 0xaddb, 0x1900, 0x2001, 0x4008, 0x0090, 0x8420,
-	0x8e70, 0x1f04, 0x49dd, 0x85ff, 0x1130, 0x2001, 0x4009, 0x0048,
-	0x2001, 0x0001, 0x0030, 0x080c, 0x65a7, 0x1dd0, 0xbb12, 0xba16,
-	0x9006, 0x9005, 0x009e, 0x00de, 0x00ee, 0x0005, 0x81ff, 0x0120,
-	0x2009, 0x0001, 0x0804, 0x3558, 0x080c, 0x4ab4, 0x1120, 0x2009,
-	0x0002, 0x0804, 0x3558, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a,
-	0x7884, 0x9005, 0x0904, 0x355b, 0x9096, 0x00ff, 0x0120, 0x9092,
-	0x0004, 0x1a04, 0x355b, 0x2010, 0x2918, 0x080c, 0x3167, 0x1120,
-	0x2009, 0x0003, 0x0804, 0x3558, 0x7007, 0x0003, 0x701f, 0x4a69,
-	0x0005, 0xa830, 0x9086, 0x0100, 0x1904, 0x3526, 0x2009, 0x0004,
-	0x0804, 0x3558, 0x7984, 0x080c, 0xaddb, 0x1120, 0x9182, 0x007f,
-	0x0a04, 0x355b, 0x9186, 0x00ff, 0x0904, 0x355b, 0x9182, 0x0800,
-	0x1a04, 0x355b, 0x2001, 0x9000, 0x080c, 0x5690, 0x1904, 0x3558,
-	0x0804, 0x3526, 0xa998, 0x080c, 0xaddb, 0x1118, 0x9182, 0x007f,
-	0x0280, 0x9186, 0x00ff, 0x0168, 0x9182, 0x0800, 0x1250, 0x2001,
-	0x9000, 0x080c, 0x5690, 0x11a8, 0x0060, 0xa897, 0x4005, 0xa99a,
-	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
-	0x0005, 0xa897, 0x4000, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000,
-	0x0005, 0x2009, 0x000a, 0x0c48, 0x080c, 0x0fff, 0x0198, 0x9006,
-	0xa802, 0x7014, 0x9005, 0x1120, 0x2900, 0x7016, 0x701a, 0x0040,
-	0x7018, 0xa802, 0x0086, 0x2040, 0x2900, 0xa006, 0x701a, 0x008e,
-	0x9085, 0x0001, 0x0005, 0x7984, 0x080c, 0x6608, 0x1130, 0x7e88,
-	0x9684, 0x3fff, 0x9082, 0x4000, 0x0208, 0x905e, 0x8bff, 0x0005,
-	0xa998, 0x080c, 0x6608, 0x1130, 0xae9c, 0x9684, 0x3fff, 0x9082,
-	0x4000, 0x0208, 0x905e, 0x8bff, 0x0005, 0xae98, 0x0008, 0x7e84,
-	0x2608, 0x080c, 0x6608, 0x1108, 0x0008, 0x905e, 0x8bff, 0x0005,
-	0x0016, 0x7114, 0x81ff, 0x0128, 0x2148, 0xa904, 0x080c, 0x1031,
-	0x0cc8, 0x7116, 0x711a, 0x001e, 0x0005, 0x2031, 0x0001, 0x0010,
-	0x2031, 0x0000, 0x2061, 0x18b8, 0x2c44, 0xa66a, 0xa17a, 0xa772,
-	0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10e9, 0x7007,
-	0x0002, 0x701f, 0x3526, 0x0005, 0x00f6, 0x0126, 0x2091, 0x8000,
-	0x2079, 0x0000, 0x2001, 0x18b0, 0x2004, 0x9005, 0x1190, 0x0e04,
-	0x4b31, 0x7a36, 0x7833, 0x0012, 0x7a82, 0x7b86, 0x7c8a, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b, 0x0804,
-	0x4b97, 0x0016, 0x0086, 0x0096, 0x00c6, 0x00e6, 0x2071, 0x189e,
-	0x7044, 0x9005, 0x1540, 0x7148, 0x9182, 0x0010, 0x0288, 0x7038,
-	0x2060, 0x080c, 0x0fff, 0x0904, 0x4b8f, 0xa84b, 0x0000, 0x2900,
-	0x7046, 0x2001, 0x0002, 0x9080, 0x2092, 0x2005, 0xa846, 0x0098,
-	0x7038, 0x90e0, 0x0004, 0x2001, 0x18ba, 0x9c82, 0x18fa, 0x0210,
-	0x2061, 0x18ba, 0x2c00, 0x703a, 0x7148, 0x81ff, 0x1108, 0x703e,
-	0x8108, 0x714a, 0x0460, 0x7148, 0x8108, 0x714a, 0x7044, 0x2040,
-	0xa144, 0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c, 0x0dd5, 0x2060,
-	0x001e, 0x8108, 0x2105, 0x9005, 0xa146, 0x1520, 0x080c, 0x0fff,
-	0x1130, 0x8109, 0xa946, 0x7148, 0x8109, 0x714a, 0x00d8, 0x9006,
-	0xa806, 0xa84a, 0xa046, 0x2800, 0xa802, 0x2900, 0xa006, 0x7046,
-	0x2001, 0x0002, 0x9080, 0x2092, 0x2005, 0xa846, 0x0058, 0x2262,
-	0x6306, 0x640a, 0x00ee, 0x00ce, 0x009e, 0x008e, 0x001e, 0x012e,
-	0x00fe, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002, 0x4bb9, 0x4bb9,
-	0x4bbb, 0x4bb9, 0x4bb9, 0x4bb9, 0x4bbf, 0x4bb9, 0x4bb9, 0x4bb9,
-	0x4bc3, 0x4bb9, 0x4bb9, 0x4bb9, 0x4bc7, 0x4bb9, 0x4bb9, 0x4bb9,
-	0x4bcb, 0x4bb9, 0x4bb9, 0x4bb9, 0x4bcf, 0x4bb9, 0x4bb9, 0x4bb9,
-	0x4bd4, 0x080c, 0x0dd5, 0xa276, 0xa37a, 0xa47e, 0x0898, 0xa286,
-	0xa38a, 0xa48e, 0x0878, 0xa296, 0xa39a, 0xa49e, 0x0858, 0xa2a6,
-	0xa3aa, 0xa4ae, 0x0838, 0xa2b6, 0xa3ba, 0xa4be, 0x0818, 0xa2c6,
-	0xa3ca, 0xa4ce, 0x0804, 0x4b92, 0xa2d6, 0xa3da, 0xa4de, 0x0804,
-	0x4b92, 0x00e6, 0x2071, 0x189e, 0x7048, 0x9005, 0x0904, 0x4c6b,
-	0x0126, 0x2091, 0x8000, 0x0e04, 0x4c6a, 0x00f6, 0x2079, 0x0000,
-	0x00c6, 0x0096, 0x0086, 0x0076, 0x9006, 0x2038, 0x7040, 0x2048,
-	0x9005, 0x0500, 0xa948, 0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c,
-	0x0dd5, 0x2060, 0x001e, 0x8108, 0x2105, 0x9005, 0xa94a, 0x1904,
-	0x4c6d, 0xa804, 0x9005, 0x090c, 0x0dd5, 0x7042, 0x2938, 0x2040,
-	0xa003, 0x0000, 0x2001, 0x0002, 0x9080, 0x2092, 0x2005, 0xa04a,
-	0x0804, 0x4c6d, 0x703c, 0x2060, 0x2c14, 0x6304, 0x6408, 0x650c,
-	0x2200, 0x7836, 0x7833, 0x0012, 0x7882, 0x2300, 0x7886, 0x2400,
-	0x788a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
-	0x119b, 0x87ff, 0x0118, 0x2748, 0x080c, 0x1031, 0x7048, 0x8001,
-	0x704a, 0x9005, 0x1170, 0x7040, 0x2048, 0x9005, 0x0128, 0x080c,
-	0x1031, 0x9006, 0x7042, 0x7046, 0x703b, 0x18ba, 0x703f, 0x18ba,
-	0x0420, 0x7040, 0x9005, 0x1508, 0x7238, 0x2c00, 0x9206, 0x0148,
-	0x9c80, 0x0004, 0x90fa, 0x18fa, 0x0210, 0x2001, 0x18ba, 0x703e,
-	0x00a0, 0x9006, 0x703e, 0x703a, 0x7044, 0x9005, 0x090c, 0x0dd5,
-	0x2048, 0xa800, 0x9005, 0x1de0, 0x2900, 0x7042, 0x2001, 0x0002,
-	0x9080, 0x2092, 0x2005, 0xa84a, 0x0000, 0x007e, 0x008e, 0x009e,
-	0x00ce, 0x00fe, 0x012e, 0x00ee, 0x0005, 0x2c00, 0x9082, 0x001b,
-	0x0002, 0x4c8c, 0x4c8c, 0x4c8e, 0x4c8c, 0x4c8c, 0x4c8c, 0x4c93,
-	0x4c8c, 0x4c8c, 0x4c8c, 0x4c98, 0x4c8c, 0x4c8c, 0x4c8c, 0x4c9d,
-	0x4c8c, 0x4c8c, 0x4c8c, 0x4ca2, 0x4c8c, 0x4c8c, 0x4c8c, 0x4ca7,
-	0x4c8c, 0x4c8c, 0x4c8c, 0x4cac, 0x080c, 0x0dd5, 0xaa74, 0xab78,
-	0xac7c, 0x0804, 0x4c18, 0xaa84, 0xab88, 0xac8c, 0x0804, 0x4c18,
-	0xaa94, 0xab98, 0xac9c, 0x0804, 0x4c18, 0xaaa4, 0xaba8, 0xacac,
-	0x0804, 0x4c18, 0xaab4, 0xabb8, 0xacbc, 0x0804, 0x4c18, 0xaac4,
-	0xabc8, 0xaccc, 0x0804, 0x4c18, 0xaad4, 0xabd8, 0xacdc, 0x0804,
-	0x4c18, 0x0016, 0x0026, 0x0036, 0x00b6, 0x00c6, 0x2009, 0x007e,
-	0x080c, 0x6608, 0x2019, 0x0001, 0xb85c, 0xd0ac, 0x0110, 0x2019,
-	0x0000, 0x2011, 0x801b, 0x080c, 0x4b14, 0x00ce, 0x00be, 0x003e,
-	0x002e, 0x001e, 0x0005, 0x0026, 0x080c, 0x56d8, 0xd0c4, 0x0120,
-	0x2011, 0x8014, 0x080c, 0x4b14, 0x002e, 0x0005, 0x81ff, 0x1904,
-	0x3558, 0x0126, 0x2091, 0x8000, 0x6030, 0xc08d, 0xc085, 0xc0ac,
-	0x6032, 0x080c, 0x73a5, 0x1158, 0x080c, 0x768d, 0x080c, 0x6023,
-	0x9085, 0x0001, 0x080c, 0x73ec, 0x080c, 0x72d7, 0x0010, 0x080c,
-	0x5ee2, 0x012e, 0x0804, 0x3526, 0x81ff, 0x0120, 0x2009, 0x0001,
-	0x0804, 0x3558, 0x080c, 0x56ec, 0x0120, 0x2009, 0x0007, 0x0804,
-	0x3558, 0x080c, 0x6973, 0x0120, 0x2009, 0x0008, 0x0804, 0x3558,
-	0x7984, 0x080c, 0x65a7, 0x1904, 0x355b, 0x2b00, 0x7026, 0x080c,
-	0x697b, 0x7888, 0x1170, 0x9084, 0x0005, 0x1158, 0x900e, 0x080c,
-	0x6828, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804,
-	0x3526, 0x080c, 0x4ab4, 0x0904, 0x3558, 0x9006, 0xa866, 0xa832,
-	0xa868, 0xc0fd, 0xa86a, 0x080c, 0xcd72, 0x0904, 0x3558, 0x7888,
-	0xd094, 0x0118, 0xb8cc, 0xc08d, 0xb8ce, 0x7007, 0x0003, 0x701f,
-	0x4d86, 0x0005, 0x2061, 0x1800, 0x080c, 0x56ec, 0x2009, 0x0007,
-	0x1578, 0x080c, 0x6973, 0x0118, 0x2009, 0x0008, 0x0448, 0x080c,
-	0x3316, 0x0120, 0xa998, 0x080c, 0x65a7, 0x1530, 0x080c, 0x4ae5,
-	0x0518, 0x080c, 0x697b, 0xa89c, 0x1168, 0x9084, 0x0005, 0x1150,
-	0x900e, 0x080c, 0x6828, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
-	0xc18d, 0x00d0, 0xa868, 0xc0fc, 0xa86a, 0x080c, 0xcd72, 0x11e0,
-	0xa89c, 0xd094, 0x0118, 0xb8cc, 0xc08d, 0xb8ce, 0x2009, 0x0003,
-	0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085,
-	0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0xa99a, 0x9006,
-	0x918d, 0x0001, 0x2008, 0x0005, 0x9006, 0x0005, 0xa830, 0x9086,
-	0x0100, 0x7024, 0x2058, 0x1110, 0x0804, 0x5635, 0x900e, 0x080c,
-	0x6828, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804,
-	0x3526, 0x080c, 0x56ec, 0x0120, 0x2009, 0x0007, 0x0804, 0x3558,
-	0x7f84, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c, 0x4ab4, 0x1120,
-	0x2009, 0x0002, 0x0804, 0x3558, 0x900e, 0x2130, 0x7126, 0x7132,
-	0xa860, 0x20e8, 0x7036, 0xa85c, 0x9080, 0x0005, 0x702a, 0x20a0,
-	0x080c, 0x6608, 0x1904, 0x4e28, 0x080c, 0x697b, 0x0138, 0x080c,
-	0x6983, 0x0120, 0x080c, 0x691b, 0x1904, 0x4e28, 0xd794, 0x1110,
-	0xd784, 0x01a8, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098,
-	0x3400, 0xd794, 0x0160, 0x20a9, 0x0008, 0x4003, 0x2098, 0x20a0,
-	0x3d00, 0x20e0, 0x20a9, 0x0002, 0x080c, 0x48b3, 0x0048, 0x20a9,
-	0x0004, 0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x080c, 0x48b3,
-	0x9186, 0x007e, 0x0170, 0x9186, 0x0080, 0x0158, 0x080c, 0x697b,
-	0x90c2, 0x0006, 0x1210, 0xc1fd, 0x0020, 0x080c, 0x6828, 0x1108,
-	0xc1fd, 0x4104, 0xc1fc, 0xd794, 0x0528, 0xb8c4, 0x20e0, 0xb8c8,
-	0x2060, 0x9c80, 0x0000, 0x2098, 0x20a9, 0x0002, 0x4003, 0x9c80,
-	0x0003, 0x2098, 0x20a9, 0x0001, 0x4005, 0x9c80, 0x0004, 0x2098,
-	0x3400, 0x20a9, 0x0002, 0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0,
-	0x080c, 0x48a6, 0x9c80, 0x0026, 0x2098, 0xb8c4, 0x20e0, 0x20a9,
-	0x0002, 0x4003, 0xd794, 0x0110, 0x96b0, 0x000b, 0x96b0, 0x0005,
-	0x8108, 0x080c, 0xaddb, 0x0118, 0x9186, 0x0800, 0x0040, 0xd78c,
-	0x0120, 0x9186, 0x0800, 0x0170, 0x0018, 0x9186, 0x007e, 0x0150,
-	0xd794, 0x0118, 0x9686, 0x0020, 0x0010, 0x9686, 0x0028, 0x0150,
-	0x0804, 0x4db8, 0x86ff, 0x1120, 0x7124, 0x810b, 0x0804, 0x3526,
-	0x7033, 0x0001, 0x7122, 0x7024, 0x9600, 0x7026, 0x772e, 0x2061,
-	0x18b8, 0x2c44, 0xa06b, 0x0000, 0xa67a, 0x7034, 0xa072, 0x7028,
-	0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10e9, 0x7007,
-	0x0002, 0x701f, 0x4e64, 0x0005, 0x7030, 0x9005, 0x1180, 0x7120,
-	0x7028, 0x20a0, 0x772c, 0x9036, 0x7034, 0x20e8, 0x2061, 0x18b8,
-	0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x0804, 0x4db8, 0x7124,
-	0x810b, 0x0804, 0x3526, 0x2029, 0x007e, 0x7984, 0x7a88, 0x7b8c,
-	0x7c98, 0x9184, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x355b,
-	0x9502, 0x0a04, 0x355b, 0x9184, 0x00ff, 0x90e2, 0x0020, 0x0a04,
-	0x355b, 0x9502, 0x0a04, 0x355b, 0x9284, 0xff00, 0x8007, 0x90e2,
-	0x0020, 0x0a04, 0x355b, 0x9502, 0x0a04, 0x355b, 0x9284, 0x00ff,
-	0x90e2, 0x0020, 0x0a04, 0x355b, 0x9502, 0x0a04, 0x355b, 0x9384,
-	0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x355b, 0x9502, 0x0a04,
-	0x355b, 0x9384, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x355b, 0x9502,
-	0x0a04, 0x355b, 0x9484, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04,
-	0x355b, 0x9502, 0x0a04, 0x355b, 0x9484, 0x00ff, 0x90e2, 0x0020,
-	0x0a04, 0x355b, 0x9502, 0x0a04, 0x355b, 0x2061, 0x1988, 0x6102,
-	0x6206, 0x630a, 0x640e, 0x0804, 0x3526, 0x080c, 0x4ab4, 0x0904,
-	0x3558, 0x2009, 0x0016, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c,
-	0x9080, 0x0019, 0xaf60, 0x080c, 0x4afd, 0x701f, 0x4ee8, 0x0005,
-	0x2001, 0x0138, 0x2003, 0x0000, 0x00e6, 0x2071, 0x0300, 0x701c,
-	0xd0a4, 0x1de8, 0x00ee, 0x20a9, 0x0016, 0x896e, 0x8d6e, 0x8d6f,
-	0x9d84, 0xffc0, 0x9080, 0x0019, 0x2098, 0x9d84, 0x003f, 0x20e0,
-	0x2069, 0x1877, 0x20e9, 0x0001, 0x2da0, 0x4003, 0x6800, 0x9005,
-	0x0904, 0x4f69, 0x6804, 0x2008, 0x918c, 0xfff8, 0x1904, 0x4f69,
-	0x680c, 0x9005, 0x0904, 0x4f69, 0x9082, 0xff01, 0x1a04, 0x4f69,
-	0x6810, 0x9082, 0x005c, 0x0a04, 0x4f69, 0x6824, 0x2008, 0x9082,
-	0x0008, 0x0a04, 0x4f69, 0x9182, 0x0400, 0x1a04, 0x4f69, 0x0056,
-	0x2029, 0x0000, 0x080c, 0x8ae4, 0x005e, 0x6944, 0x6820, 0x9102,
-	0x06c0, 0x6820, 0x9082, 0x0019, 0x16a0, 0x6828, 0x6944, 0x810c,
-	0x9102, 0x0678, 0x6840, 0x9082, 0x000f, 0x1658, 0x080c, 0x1018,
-	0x2900, 0x0904, 0x4f83, 0x684e, 0x00e6, 0x2071, 0x1930, 0x00b6,
-	0x2059, 0x0000, 0x080c, 0x89a0, 0x00be, 0x00ee, 0x0558, 0x080c,
-	0x86fa, 0x080c, 0x8740, 0x11e0, 0x6857, 0x0000, 0x00c6, 0x2061,
-	0x0100, 0x6104, 0x918d, 0x2000, 0x6106, 0x6b10, 0x2061, 0x1a61,
-	0x630a, 0x00ce, 0x080c, 0x2958, 0x2001, 0x0138, 0x2102, 0x0804,
-	0x3526, 0x080c, 0x2958, 0x2001, 0x0138, 0x2102, 0x0804, 0x355b,
-	0x00e6, 0x2071, 0x1930, 0x080c, 0x8b75, 0x080c, 0x8b84, 0x080c,
-	0x898f, 0x00ee, 0x2001, 0x188a, 0x204c, 0x080c, 0x1031, 0x2001,
-	0x188a, 0x2003, 0x0000, 0x080c, 0x2958, 0x2001, 0x0138, 0x2102,
-	0x0804, 0x3558, 0x2001, 0x1924, 0x200c, 0x918e, 0x0000, 0x0904,
-	0x4fe2, 0x080c, 0x898a, 0x0904, 0x4fe2, 0x2001, 0x0101, 0x200c,
-	0x918c, 0xdfff, 0x2102, 0x2001, 0x0138, 0x2003, 0x0000, 0x00e6,
-	0x2071, 0x0300, 0x701c, 0xd0a4, 0x1de8, 0x00ee, 0x080c, 0x898f,
-	0x2001, 0x0035, 0x080c, 0x15f0, 0x00c6, 0x2061, 0x193c, 0x6004,
-	0x6100, 0x9106, 0x1de0, 0x00ce, 0x080c, 0x2958, 0x2001, 0x0138,
-	0x2102, 0x00e6, 0x00f6, 0x2071, 0x1923, 0x080c, 0x88cb, 0x0120,
-	0x2f00, 0x080c, 0x8955, 0x0cc8, 0x00fe, 0x00ee, 0x0126, 0x2091,
-	0x8000, 0x2001, 0x188a, 0x200c, 0x81ff, 0x0138, 0x2148, 0x080c,
-	0x1031, 0x2001, 0x188a, 0x2003, 0x0000, 0x2001, 0x183c, 0x2003,
-	0x0020, 0x00e6, 0x2071, 0x1930, 0x080c, 0x8b75, 0x080c, 0x8b84,
-	0x00ee, 0x012e, 0x0804, 0x3526, 0x0006, 0x080c, 0x56d8, 0xd0cc,
-	0x000e, 0x0005, 0x0006, 0x080c, 0x56dc, 0xd0bc, 0x000e, 0x0005,
-	0x6174, 0x7a84, 0x6300, 0x82ff, 0x1118, 0x7986, 0x0804, 0x3526,
-	0x83ff, 0x1904, 0x355b, 0x2001, 0xfff0, 0x9200, 0x1a04, 0x355b,
-	0x2019, 0xffff, 0x6078, 0x9302, 0x9200, 0x0a04, 0x355b, 0x7986,
-	0x6276, 0x0804, 0x3526, 0x080c, 0x56ec, 0x1904, 0x3558, 0x7c88,
-	0x7d84, 0x7e98, 0x7f8c, 0x080c, 0x4ab4, 0x0904, 0x3558, 0x900e,
-	0x901e, 0x7326, 0x7332, 0xa860, 0x20e8, 0x7036, 0xa85c, 0x9080,
-	0x0003, 0x702a, 0x20a0, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178,
-	0x080c, 0x697b, 0x0118, 0x080c, 0x6983, 0x1148, 0x20a9, 0x0001,
-	0xb814, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003, 0x8108,
-	0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x0170, 0x0c20, 0x83ff,
-	0x1148, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c, 0x8f51, 0x2208,
-	0x0804, 0x3526, 0x7033, 0x0001, 0x7122, 0x7024, 0x9300, 0x7026,
-	0x2061, 0x18b8, 0x2c44, 0xa06b, 0x0000, 0xa37a, 0x7028, 0xa076,
-	0x7034, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a, 0x080c, 0x10e9,
-	0x7007, 0x0002, 0x701f, 0x5065, 0x0005, 0x7030, 0x9005, 0x1178,
-	0x7120, 0x7028, 0x20a0, 0x901e, 0x7034, 0x20e8, 0x2061, 0x18b8,
-	0x2c44, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0804, 0x5023, 0x7224,
-	0x900e, 0x2001, 0x0003, 0x080c, 0x8f51, 0x2208, 0x0804, 0x3526,
-	0x00f6, 0x00e6, 0x080c, 0x56ec, 0x2009, 0x0007, 0x1904, 0x50f8,
-	0x2071, 0x189e, 0x745c, 0x84ff, 0x2009, 0x000e, 0x1904, 0x50f8,
-	0xac9c, 0xad98, 0xaea4, 0xafa0, 0x0096, 0x080c, 0x1018, 0x2009,
-	0x0002, 0x0904, 0x50f8, 0x2900, 0x705e, 0x900e, 0x901e, 0x7356,
-	0x7362, 0xa860, 0x7066, 0xa85c, 0x9080, 0x0003, 0x705a, 0x20a0,
-	0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x697b, 0x0118,
-	0x080c, 0x6983, 0x1148, 0xb814, 0x20a9, 0x0001, 0x4004, 0xb810,
-	0x4004, 0x4104, 0x9398, 0x0003, 0x8108, 0x9182, 0x0800, 0x0120,
-	0x9386, 0x003c, 0x01e8, 0x0c20, 0x83ff, 0x11c0, 0x7254, 0x900e,
-	0x2001, 0x0003, 0x080c, 0x8f51, 0x2208, 0x009e, 0xa897, 0x4000,
-	0xa99a, 0x715c, 0x81ff, 0x090c, 0x0dd5, 0x2148, 0x080c, 0x1031,
-	0x9006, 0x705e, 0x918d, 0x0001, 0x2008, 0x0418, 0x7063, 0x0001,
-	0x7152, 0x7054, 0x9300, 0x7056, 0x2061, 0x18b9, 0x2c44, 0xa37a,
-	0x7058, 0xa076, 0x7064, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a,
-	0xa09f, 0x5104, 0x000e, 0xa0a2, 0x080c, 0x10e9, 0x9006, 0x0048,
-	0x009e, 0xa897, 0x4005, 0xa99a, 0x900e, 0x9085, 0x0001, 0x2001,
-	0x0030, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0xa0a0, 0x904d, 0x090c,
-	0x0dd5, 0x00e6, 0x2071, 0x189e, 0xa06c, 0x908e, 0x0100, 0x0138,
-	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002, 0x00d8, 0x7060,
-	0x9005, 0x1158, 0x7150, 0x7058, 0x20a0, 0x901e, 0x7064, 0x20e8,
-	0xa48c, 0xa590, 0xa694, 0xa798, 0x0428, 0xa87b, 0x0000, 0xa883,
-	0x0000, 0xa897, 0x4000, 0x7254, 0x900e, 0x2001, 0x0003, 0x080c,
-	0x8f51, 0xaa9a, 0x715c, 0x81ff, 0x090c, 0x0dd5, 0x2148, 0x080c,
-	0x1031, 0x705f, 0x0000, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x6c86, 0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x00ee,
-	0x00fe, 0x0005, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c,
-	0x697b, 0x0118, 0x080c, 0x6983, 0x1148, 0xb814, 0x20a9, 0x0001,
+	0x10e9, 0x7007, 0x0002, 0x701f, 0x3531, 0x0005, 0x00f6, 0x0126,
+	0x2091, 0x8000, 0x2079, 0x0000, 0x2001, 0x18b0, 0x2004, 0x9005,
+	0x1190, 0x0e04, 0x4b3b, 0x7a36, 0x7833, 0x0012, 0x7a82, 0x7b86,
+	0x7c8a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x119b, 0x0804, 0x4ba1, 0x0016, 0x0086, 0x0096, 0x00c6, 0x00e6,
+	0x2071, 0x189e, 0x7044, 0x9005, 0x1540, 0x7148, 0x9182, 0x0010,
+	0x0288, 0x7038, 0x2060, 0x080c, 0x0fff, 0x0904, 0x4b99, 0xa84b,
+	0x0000, 0x2900, 0x7046, 0x2001, 0x0002, 0x9080, 0x209d, 0x2005,
+	0xa846, 0x0098, 0x7038, 0x90e0, 0x0004, 0x2001, 0x18ba, 0x9c82,
+	0x18fa, 0x0210, 0x2061, 0x18ba, 0x2c00, 0x703a, 0x7148, 0x81ff,
+	0x1108, 0x703e, 0x8108, 0x714a, 0x0460, 0x7148, 0x8108, 0x714a,
+	0x7044, 0x2040, 0xa144, 0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c,
+	0x0dd5, 0x2060, 0x001e, 0x8108, 0x2105, 0x9005, 0xa146, 0x1520,
+	0x080c, 0x0fff, 0x1130, 0x8109, 0xa946, 0x7148, 0x8109, 0x714a,
+	0x00d8, 0x9006, 0xa806, 0xa84a, 0xa046, 0x2800, 0xa802, 0x2900,
+	0xa006, 0x7046, 0x2001, 0x0002, 0x9080, 0x209d, 0x2005, 0xa846,
+	0x0058, 0x2262, 0x6306, 0x640a, 0x00ee, 0x00ce, 0x009e, 0x008e,
+	0x001e, 0x012e, 0x00fe, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002,
+	0x4bc3, 0x4bc3, 0x4bc5, 0x4bc3, 0x4bc3, 0x4bc3, 0x4bc9, 0x4bc3,
+	0x4bc3, 0x4bc3, 0x4bcd, 0x4bc3, 0x4bc3, 0x4bc3, 0x4bd1, 0x4bc3,
+	0x4bc3, 0x4bc3, 0x4bd5, 0x4bc3, 0x4bc3, 0x4bc3, 0x4bd9, 0x4bc3,
+	0x4bc3, 0x4bc3, 0x4bde, 0x080c, 0x0dd5, 0xa276, 0xa37a, 0xa47e,
+	0x0898, 0xa286, 0xa38a, 0xa48e, 0x0878, 0xa296, 0xa39a, 0xa49e,
+	0x0858, 0xa2a6, 0xa3aa, 0xa4ae, 0x0838, 0xa2b6, 0xa3ba, 0xa4be,
+	0x0818, 0xa2c6, 0xa3ca, 0xa4ce, 0x0804, 0x4b9c, 0xa2d6, 0xa3da,
+	0xa4de, 0x0804, 0x4b9c, 0x00e6, 0x2071, 0x189e, 0x7048, 0x9005,
+	0x0904, 0x4c75, 0x0126, 0x2091, 0x8000, 0x0e04, 0x4c74, 0x00f6,
+	0x2079, 0x0000, 0x00c6, 0x0096, 0x0086, 0x0076, 0x9006, 0x2038,
+	0x7040, 0x2048, 0x9005, 0x0500, 0xa948, 0x2105, 0x0016, 0x908a,
+	0x0036, 0x1a0c, 0x0dd5, 0x2060, 0x001e, 0x8108, 0x2105, 0x9005,
+	0xa94a, 0x1904, 0x4c77, 0xa804, 0x9005, 0x090c, 0x0dd5, 0x7042,
+	0x2938, 0x2040, 0xa003, 0x0000, 0x2001, 0x0002, 0x9080, 0x209d,
+	0x2005, 0xa04a, 0x0804, 0x4c77, 0x703c, 0x2060, 0x2c14, 0x6304,
+	0x6408, 0x650c, 0x2200, 0x7836, 0x7833, 0x0012, 0x7882, 0x2300,
+	0x7886, 0x2400, 0x788a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
+	0xd084, 0x190c, 0x119b, 0x87ff, 0x0118, 0x2748, 0x080c, 0x1031,
+	0x7048, 0x8001, 0x704a, 0x9005, 0x1170, 0x7040, 0x2048, 0x9005,
+	0x0128, 0x080c, 0x1031, 0x9006, 0x7042, 0x7046, 0x703b, 0x18ba,
+	0x703f, 0x18ba, 0x0420, 0x7040, 0x9005, 0x1508, 0x7238, 0x2c00,
+	0x9206, 0x0148, 0x9c80, 0x0004, 0x90fa, 0x18fa, 0x0210, 0x2001,
+	0x18ba, 0x703e, 0x00a0, 0x9006, 0x703e, 0x703a, 0x7044, 0x9005,
+	0x090c, 0x0dd5, 0x2048, 0xa800, 0x9005, 0x1de0, 0x2900, 0x7042,
+	0x2001, 0x0002, 0x9080, 0x209d, 0x2005, 0xa84a, 0x0000, 0x007e,
+	0x008e, 0x009e, 0x00ce, 0x00fe, 0x012e, 0x00ee, 0x0005, 0x2c00,
+	0x9082, 0x001b, 0x0002, 0x4c96, 0x4c96, 0x4c98, 0x4c96, 0x4c96,
+	0x4c96, 0x4c9d, 0x4c96, 0x4c96, 0x4c96, 0x4ca2, 0x4c96, 0x4c96,
+	0x4c96, 0x4ca7, 0x4c96, 0x4c96, 0x4c96, 0x4cac, 0x4c96, 0x4c96,
+	0x4c96, 0x4cb1, 0x4c96, 0x4c96, 0x4c96, 0x4cb6, 0x080c, 0x0dd5,
+	0xaa74, 0xab78, 0xac7c, 0x0804, 0x4c22, 0xaa84, 0xab88, 0xac8c,
+	0x0804, 0x4c22, 0xaa94, 0xab98, 0xac9c, 0x0804, 0x4c22, 0xaaa4,
+	0xaba8, 0xacac, 0x0804, 0x4c22, 0xaab4, 0xabb8, 0xacbc, 0x0804,
+	0x4c22, 0xaac4, 0xabc8, 0xaccc, 0x0804, 0x4c22, 0xaad4, 0xabd8,
+	0xacdc, 0x0804, 0x4c22, 0x0016, 0x0026, 0x0036, 0x00b6, 0x00c6,
+	0x2009, 0x007e, 0x080c, 0x6616, 0x2019, 0x0001, 0xb85c, 0xd0ac,
+	0x0110, 0x2019, 0x0000, 0x2011, 0x801b, 0x080c, 0x4b1e, 0x00ce,
+	0x00be, 0x003e, 0x002e, 0x001e, 0x0005, 0x0026, 0x080c, 0x56e2,
+	0xd0c4, 0x0120, 0x2011, 0x8014, 0x080c, 0x4b1e, 0x002e, 0x0005,
+	0x81ff, 0x1904, 0x3563, 0x0126, 0x2091, 0x8000, 0x6030, 0xc08d,
+	0xc085, 0xc0ac, 0x6032, 0x080c, 0x73b3, 0x1158, 0x080c, 0x7699,
+	0x080c, 0x602d, 0x9085, 0x0001, 0x080c, 0x73fa, 0x080c, 0x72e5,
+	0x0010, 0x080c, 0x5eec, 0x012e, 0x0804, 0x3531, 0x81ff, 0x0120,
+	0x2009, 0x0001, 0x0804, 0x3563, 0x080c, 0x56f6, 0x0120, 0x2009,
+	0x0007, 0x0804, 0x3563, 0x080c, 0x6981, 0x0120, 0x2009, 0x0008,
+	0x0804, 0x3563, 0x7984, 0x080c, 0x65b5, 0x1904, 0x3566, 0x2b00,
+	0x7026, 0x080c, 0x6989, 0x7888, 0x1170, 0x9084, 0x0005, 0x1158,
+	0x900e, 0x080c, 0x6836, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
+	0xc18d, 0x0804, 0x3531, 0x080c, 0x4abe, 0x0904, 0x3563, 0x9006,
+	0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xcd82, 0x0904,
+	0x3563, 0x7888, 0xd094, 0x0118, 0xb8cc, 0xc08d, 0xb8ce, 0x7007,
+	0x0003, 0x701f, 0x4d90, 0x0005, 0x2061, 0x1800, 0x080c, 0x56f6,
+	0x2009, 0x0007, 0x1578, 0x080c, 0x6981, 0x0118, 0x2009, 0x0008,
+	0x0448, 0x080c, 0x3321, 0x0120, 0xa998, 0x080c, 0x65b5, 0x1530,
+	0x080c, 0x4aef, 0x0518, 0x080c, 0x6989, 0xa89c, 0x1168, 0x9084,
+	0x0005, 0x1150, 0x900e, 0x080c, 0x6836, 0x1108, 0xc185, 0xb800,
+	0xd0bc, 0x0108, 0xc18d, 0x00d0, 0xa868, 0xc0fc, 0xa86a, 0x080c,
+	0xcd82, 0x11e0, 0xa89c, 0xd094, 0x0118, 0xb8cc, 0xc08d, 0xb8ce,
+	0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
+	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000,
+	0xa99a, 0x9006, 0x918d, 0x0001, 0x2008, 0x0005, 0x9006, 0x0005,
+	0xa830, 0x9086, 0x0100, 0x7024, 0x2058, 0x1110, 0x0804, 0x563f,
+	0x900e, 0x080c, 0x6836, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
+	0xc18d, 0x0804, 0x3531, 0x080c, 0x56f6, 0x0120, 0x2009, 0x0007,
+	0x0804, 0x3563, 0x7f84, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c,
+	0x4abe, 0x1120, 0x2009, 0x0002, 0x0804, 0x3563, 0x900e, 0x2130,
+	0x7126, 0x7132, 0xa860, 0x20e8, 0x7036, 0xa85c, 0x9080, 0x0005,
+	0x702a, 0x20a0, 0x080c, 0x6616, 0x1904, 0x4e32, 0x080c, 0x6989,
+	0x0138, 0x080c, 0x6991, 0x0120, 0x080c, 0x6929, 0x1904, 0x4e32,
+	0xd794, 0x1110, 0xd784, 0x01a8, 0xb8c4, 0x20e0, 0xb8c8, 0x9080,
+	0x0006, 0x2098, 0x3400, 0xd794, 0x0160, 0x20a9, 0x0008, 0x4003,
+	0x2098, 0x20a0, 0x3d00, 0x20e0, 0x20a9, 0x0002, 0x080c, 0x48bd,
+	0x0048, 0x20a9, 0x0004, 0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0,
+	0x080c, 0x48bd, 0x9186, 0x007e, 0x0170, 0x9186, 0x0080, 0x0158,
+	0x080c, 0x6989, 0x90c2, 0x0006, 0x1210, 0xc1fd, 0x0020, 0x080c,
+	0x6836, 0x1108, 0xc1fd, 0x4104, 0xc1fc, 0xd794, 0x0528, 0xb8c4,
+	0x20e0, 0xb8c8, 0x2060, 0x9c80, 0x0000, 0x2098, 0x20a9, 0x0002,
+	0x4003, 0x9c80, 0x0003, 0x2098, 0x20a9, 0x0001, 0x4005, 0x9c80,
+	0x0004, 0x2098, 0x3400, 0x20a9, 0x0002, 0x4003, 0x2098, 0x20a0,
+	0x3d00, 0x20e0, 0x080c, 0x48b0, 0x9c80, 0x0026, 0x2098, 0xb8c4,
+	0x20e0, 0x20a9, 0x0002, 0x4003, 0xd794, 0x0110, 0x96b0, 0x000b,
+	0x96b0, 0x0005, 0x8108, 0x080c, 0xadc9, 0x0118, 0x9186, 0x0800,
+	0x0040, 0xd78c, 0x0120, 0x9186, 0x0800, 0x0170, 0x0018, 0x9186,
+	0x007e, 0x0150, 0xd794, 0x0118, 0x9686, 0x0020, 0x0010, 0x9686,
+	0x0028, 0x0150, 0x0804, 0x4dc2, 0x86ff, 0x1120, 0x7124, 0x810b,
+	0x0804, 0x3531, 0x7033, 0x0001, 0x7122, 0x7024, 0x9600, 0x7026,
+	0x772e, 0x2061, 0x18b8, 0x2c44, 0xa06b, 0x0000, 0xa67a, 0x7034,
+	0xa072, 0x7028, 0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c,
+	0x10e9, 0x7007, 0x0002, 0x701f, 0x4e6e, 0x0005, 0x7030, 0x9005,
+	0x1180, 0x7120, 0x7028, 0x20a0, 0x772c, 0x9036, 0x7034, 0x20e8,
+	0x2061, 0x18b8, 0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x0804,
+	0x4dc2, 0x7124, 0x810b, 0x0804, 0x3531, 0x2029, 0x007e, 0x7984,
+	0x7a88, 0x7b8c, 0x7c98, 0x9184, 0xff00, 0x8007, 0x90e2, 0x0020,
+	0x0a04, 0x3566, 0x9502, 0x0a04, 0x3566, 0x9184, 0x00ff, 0x90e2,
+	0x0020, 0x0a04, 0x3566, 0x9502, 0x0a04, 0x3566, 0x9284, 0xff00,
+	0x8007, 0x90e2, 0x0020, 0x0a04, 0x3566, 0x9502, 0x0a04, 0x3566,
+	0x9284, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x3566, 0x9502, 0x0a04,
+	0x3566, 0x9384, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x3566,
+	0x9502, 0x0a04, 0x3566, 0x9384, 0x00ff, 0x90e2, 0x0020, 0x0a04,
+	0x3566, 0x9502, 0x0a04, 0x3566, 0x9484, 0xff00, 0x8007, 0x90e2,
+	0x0020, 0x0a04, 0x3566, 0x9502, 0x0a04, 0x3566, 0x9484, 0x00ff,
+	0x90e2, 0x0020, 0x0a04, 0x3566, 0x9502, 0x0a04, 0x3566, 0x2061,
+	0x1988, 0x6102, 0x6206, 0x630a, 0x640e, 0x0804, 0x3531, 0x080c,
+	0x4abe, 0x0904, 0x3563, 0x2009, 0x0016, 0x7a8c, 0x7b88, 0x7c9c,
+	0x7d98, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x4b07, 0x701f,
+	0x4ef2, 0x0005, 0x2001, 0x0138, 0x2003, 0x0000, 0x00e6, 0x2071,
+	0x0300, 0x701c, 0xd0a4, 0x1de8, 0x00ee, 0x20a9, 0x0016, 0x896e,
+	0x8d6e, 0x8d6f, 0x9d84, 0xffc0, 0x9080, 0x0019, 0x2098, 0x9d84,
+	0x003f, 0x20e0, 0x2069, 0x1877, 0x20e9, 0x0001, 0x2da0, 0x4003,
+	0x6800, 0x9005, 0x0904, 0x4f73, 0x6804, 0x2008, 0x918c, 0xfff8,
+	0x1904, 0x4f73, 0x680c, 0x9005, 0x0904, 0x4f73, 0x9082, 0xff01,
+	0x1a04, 0x4f73, 0x6810, 0x9082, 0x005c, 0x0a04, 0x4f73, 0x6824,
+	0x2008, 0x9082, 0x0008, 0x0a04, 0x4f73, 0x9182, 0x0400, 0x1a04,
+	0x4f73, 0x0056, 0x2029, 0x0000, 0x080c, 0x8b01, 0x005e, 0x6944,
+	0x6820, 0x9102, 0x06c0, 0x6820, 0x9082, 0x0019, 0x16a0, 0x6828,
+	0x6944, 0x810c, 0x9102, 0x0678, 0x6840, 0x9082, 0x000f, 0x1658,
+	0x080c, 0x1018, 0x2900, 0x0904, 0x4f8d, 0x684e, 0x00e6, 0x2071,
+	0x1930, 0x00b6, 0x2059, 0x0000, 0x080c, 0x89bd, 0x00be, 0x00ee,
+	0x0558, 0x080c, 0x8717, 0x080c, 0x875d, 0x11e0, 0x6857, 0x0000,
+	0x00c6, 0x2061, 0x0100, 0x6104, 0x918d, 0x2000, 0x6106, 0x6b10,
+	0x2061, 0x1a61, 0x630a, 0x00ce, 0x080c, 0x2963, 0x2001, 0x0138,
+	0x2102, 0x0804, 0x3531, 0x080c, 0x2963, 0x2001, 0x0138, 0x2102,
+	0x0804, 0x3566, 0x00e6, 0x2071, 0x1930, 0x080c, 0x8b92, 0x080c,
+	0x8ba1, 0x080c, 0x89ac, 0x00ee, 0x2001, 0x188a, 0x204c, 0x080c,
+	0x1031, 0x2001, 0x188a, 0x2003, 0x0000, 0x080c, 0x2963, 0x2001,
+	0x0138, 0x2102, 0x0804, 0x3563, 0x2001, 0x1924, 0x200c, 0x918e,
+	0x0000, 0x0904, 0x4fec, 0x080c, 0x89a7, 0x0904, 0x4fec, 0x2001,
+	0x0101, 0x200c, 0x918c, 0xdfff, 0x2102, 0x2001, 0x0138, 0x2003,
+	0x0000, 0x00e6, 0x2071, 0x0300, 0x701c, 0xd0a4, 0x1de8, 0x00ee,
+	0x080c, 0x89ac, 0x2001, 0x0035, 0x080c, 0x15f0, 0x00c6, 0x2061,
+	0x193c, 0x6004, 0x6100, 0x9106, 0x1de0, 0x00ce, 0x080c, 0x2963,
+	0x2001, 0x0138, 0x2102, 0x00e6, 0x00f6, 0x2071, 0x1923, 0x080c,
+	0x88e8, 0x0120, 0x2f00, 0x080c, 0x8972, 0x0cc8, 0x00fe, 0x00ee,
+	0x0126, 0x2091, 0x8000, 0x2001, 0x188a, 0x200c, 0x81ff, 0x0138,
+	0x2148, 0x080c, 0x1031, 0x2001, 0x188a, 0x2003, 0x0000, 0x2001,
+	0x183c, 0x2003, 0x0020, 0x00e6, 0x2071, 0x1930, 0x080c, 0x8b92,
+	0x080c, 0x8ba1, 0x00ee, 0x012e, 0x0804, 0x3531, 0x0006, 0x080c,
+	0x56e2, 0xd0cc, 0x000e, 0x0005, 0x0006, 0x080c, 0x56e6, 0xd0bc,
+	0x000e, 0x0005, 0x6174, 0x7a84, 0x6300, 0x82ff, 0x1118, 0x7986,
+	0x0804, 0x3531, 0x83ff, 0x1904, 0x3566, 0x2001, 0xfff0, 0x9200,
+	0x1a04, 0x3566, 0x2019, 0xffff, 0x6078, 0x9302, 0x9200, 0x0a04,
+	0x3566, 0x7986, 0x6276, 0x0804, 0x3531, 0x080c, 0x56f6, 0x1904,
+	0x3563, 0x7c88, 0x7d84, 0x7e98, 0x7f8c, 0x080c, 0x4abe, 0x0904,
+	0x3563, 0x900e, 0x901e, 0x7326, 0x7332, 0xa860, 0x20e8, 0x7036,
+	0xa85c, 0x9080, 0x0003, 0x702a, 0x20a0, 0x91d8, 0x1000, 0x2b5c,
+	0x8bff, 0x0178, 0x080c, 0x6989, 0x0118, 0x080c, 0x6991, 0x1148,
+	0x20a9, 0x0001, 0xb814, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398,
+	0x0003, 0x8108, 0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x0170,
+	0x0c20, 0x83ff, 0x1148, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c,
+	0x8f70, 0x2208, 0x0804, 0x3531, 0x7033, 0x0001, 0x7122, 0x7024,
+	0x9300, 0x7026, 0x2061, 0x18b8, 0x2c44, 0xa06b, 0x0000, 0xa37a,
+	0x7028, 0xa076, 0x7034, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a,
+	0x080c, 0x10e9, 0x7007, 0x0002, 0x701f, 0x506f, 0x0005, 0x7030,
+	0x9005, 0x1178, 0x7120, 0x7028, 0x20a0, 0x901e, 0x7034, 0x20e8,
+	0x2061, 0x18b8, 0x2c44, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0804,
+	0x502d, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c, 0x8f70, 0x2208,
+	0x0804, 0x3531, 0x00f6, 0x00e6, 0x080c, 0x56f6, 0x2009, 0x0007,
+	0x1904, 0x5102, 0x2071, 0x189e, 0x745c, 0x84ff, 0x2009, 0x000e,
+	0x1904, 0x5102, 0xac9c, 0xad98, 0xaea4, 0xafa0, 0x0096, 0x080c,
+	0x1018, 0x2009, 0x0002, 0x0904, 0x5102, 0x2900, 0x705e, 0x900e,
+	0x901e, 0x7356, 0x7362, 0xa860, 0x7066, 0xa85c, 0x9080, 0x0003,
+	0x705a, 0x20a0, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c,
+	0x6989, 0x0118, 0x080c, 0x6991, 0x1148, 0xb814, 0x20a9, 0x0001,
 	0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003, 0x8108, 0x9182,
-	0x0800, 0x0120, 0x9386, 0x003c, 0x0518, 0x0c20, 0x83ff, 0x11f0,
-	0x7154, 0x810c, 0xa99a, 0xa897, 0x4000, 0x715c, 0x81ff, 0x090c,
-	0x0dd5, 0x2148, 0x080c, 0x1031, 0x9006, 0x705e, 0x918d, 0x0001,
-	0x2008, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000, 0x080c, 0x6c86,
-	0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x0070, 0x7063, 0x0001,
-	0x7152, 0x7054, 0x9300, 0x7056, 0xa37a, 0xa48e, 0xa592, 0xa696,
-	0xa79a, 0x080c, 0x10e9, 0x9006, 0x00ee, 0x0005, 0x0096, 0xa88c,
-	0x90be, 0x7000, 0x0148, 0x90be, 0x7100, 0x0130, 0x90be, 0x7200,
-	0x0118, 0x009e, 0x0804, 0x355b, 0xa884, 0xa988, 0x080c, 0x2840,
-	0x1518, 0x080c, 0x65a7, 0x1500, 0x7126, 0xbe12, 0xbd16, 0xae7c,
-	0x080c, 0x4ab4, 0x01c8, 0x080c, 0x4ab4, 0x01b0, 0x009e, 0xa867,
-	0x0000, 0xa868, 0xc0fd, 0xa86a, 0xa823, 0x0000, 0xa804, 0x2048,
-	0x080c, 0xccf4, 0x1120, 0x2009, 0x0003, 0x0804, 0x3558, 0x7007,
-	0x0003, 0x701f, 0x51d1, 0x0005, 0x009e, 0x2009, 0x0002, 0x0804,
-	0x3558, 0x7124, 0x080c, 0x32bd, 0xa820, 0x9086, 0x8001, 0x1120,
-	0x2009, 0x0004, 0x0804, 0x3558, 0x2900, 0x7022, 0xa804, 0x0096,
-	0x2048, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
-	0x009e, 0x9080, 0x0002, 0x0076, 0x0006, 0x2098, 0x20a0, 0x27e0,
-	0x27e8, 0x20a9, 0x002a, 0x080c, 0x0f7c, 0xaa6c, 0xab70, 0xac74,
-	0xad78, 0x2061, 0x18b8, 0x2c44, 0xa06b, 0x0000, 0xae64, 0xaf8c,
-	0x97c6, 0x7000, 0x0118, 0x97c6, 0x7100, 0x1148, 0x96c2, 0x0004,
-	0x0600, 0x2009, 0x0004, 0x000e, 0x007e, 0x0804, 0x4b00, 0x97c6,
-	0x7200, 0x11b8, 0x96c2, 0x0054, 0x02a0, 0x000e, 0x007e, 0x2061,
-	0x18b8, 0x2c44, 0xa076, 0xa772, 0xa07b, 0x002a, 0xa28e, 0xa392,
-	0xa496, 0xa59a, 0x080c, 0x10e9, 0x7007, 0x0002, 0x701f, 0x522d,
-	0x0005, 0x000e, 0x007e, 0x0804, 0x355b, 0x7020, 0x2048, 0xa804,
-	0x2048, 0xa804, 0x2048, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
-	0x9084, 0xffc0, 0x9080, 0x0002, 0x2098, 0x20a0, 0x27e0, 0x27e8,
-	0x20a9, 0x002a, 0x080c, 0x0f7c, 0x2100, 0x2238, 0x2061, 0x18b8,
-	0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x2009, 0x002a, 0x0804,
-	0x4b00, 0x81ff, 0x1904, 0x3558, 0x798c, 0x2001, 0x197d, 0x918c,
-	0x8000, 0x2102, 0x080c, 0x4acb, 0x0904, 0x355b, 0x080c, 0x697b,
-	0x0120, 0x080c, 0x6983, 0x1904, 0x355b, 0x080c, 0x66cf, 0x0904,
-	0x3558, 0x0126, 0x2091, 0x8000, 0x080c, 0x6795, 0x012e, 0x0904,
-	0x3558, 0x2001, 0x197d, 0x2004, 0xd0fc, 0x1904, 0x3526, 0x0804,
-	0x4529, 0xa9a0, 0x2001, 0x197d, 0x918c, 0x8000, 0xc18d, 0x2102,
-	0x080c, 0x4ad8, 0x01a0, 0x080c, 0x697b, 0x0118, 0x080c, 0x6983,
-	0x1170, 0x080c, 0x66cf, 0x2009, 0x0002, 0x0128, 0x080c, 0x6795,
-	0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
-	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
-	0x4000, 0x2001, 0x197d, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x56e0,
-	0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000,
-	0x0005, 0x78a8, 0xd08c, 0x1118, 0xd084, 0x0904, 0x449e, 0x080c,
-	0x4ae7, 0x0904, 0x355b, 0x080c, 0x4ab4, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x3558, 0x080c, 0x697b, 0x0130, 0x908e, 0x0004, 0x0118,
-	0x908e, 0x0005, 0x15a0, 0x78a8, 0xd08c, 0x0120, 0xb800, 0xc08c,
-	0xb802, 0x0028, 0x080c, 0x56d8, 0xd0b4, 0x0904, 0x44d8, 0x7884,
-	0x908e, 0x007e, 0x0904, 0x44d8, 0x908e, 0x007f, 0x0904, 0x44d8,
-	0x908e, 0x0080, 0x0904, 0x44d8, 0xb800, 0xd08c, 0x1904, 0x44d8,
-	0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xcd13, 0x1120,
-	0x2009, 0x0003, 0x0804, 0x3558, 0x7007, 0x0003, 0x701f, 0x52f9,
-	0x0005, 0x080c, 0x4ae7, 0x0904, 0x355b, 0x0804, 0x44d8, 0x080c,
-	0x3316, 0x0108, 0x0005, 0x2009, 0x1834, 0x210c, 0x81ff, 0x0120,
-	0x2009, 0x0001, 0x0804, 0x3558, 0x080c, 0x56ec, 0x0120, 0x2009,
-	0x0007, 0x0804, 0x3558, 0x080c, 0x6973, 0x0120, 0x2009, 0x0008,
-	0x0804, 0x3558, 0xb89c, 0xd0a4, 0x1118, 0xd0ac, 0x1904, 0x44d8,
-	0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xcd72,
-	0x1120, 0x2009, 0x0003, 0x0804, 0x3558, 0x7007, 0x0003, 0x701f,
-	0x5332, 0x0005, 0xa830, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004,
-	0x0804, 0x5635, 0x080c, 0x4ae7, 0x0904, 0x355b, 0x0804, 0x52cb,
-	0x81ff, 0x2009, 0x0001, 0x1904, 0x3558, 0x080c, 0x56ec, 0x2009,
-	0x0007, 0x1904, 0x3558, 0x080c, 0x6973, 0x0120, 0x2009, 0x0008,
-	0x0804, 0x3558, 0x080c, 0x4ae7, 0x0904, 0x355b, 0x080c, 0x697b,
-	0x2009, 0x0009, 0x1904, 0x3558, 0x080c, 0x4ab4, 0x2009, 0x0002,
-	0x0904, 0x3558, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
-	0x7988, 0x9194, 0xff00, 0x918c, 0x00ff, 0x9006, 0x82ff, 0x1128,
-	0xc0ed, 0xa952, 0x798c, 0xa956, 0x0038, 0x928e, 0x0100, 0x1904,
-	0x355b, 0xc0e5, 0xa952, 0xa956, 0xa83e, 0x080c, 0xcfc5, 0x2009,
-	0x0003, 0x0904, 0x3558, 0x7007, 0x0003, 0x701f, 0x5388, 0x0005,
-	0xa830, 0x9086, 0x0100, 0x2009, 0x0004, 0x0904, 0x3558, 0x0804,
-	0x3526, 0x7aa8, 0x9284, 0xc000, 0x0148, 0xd2ec, 0x01a0, 0x080c,
-	0x56ec, 0x1188, 0x2009, 0x0014, 0x0804, 0x3558, 0xd2dc, 0x1568,
-	0x81ff, 0x2009, 0x0001, 0x1904, 0x3558, 0x080c, 0x56ec, 0x2009,
-	0x0007, 0x1904, 0x3558, 0xd2f4, 0x0130, 0x9284, 0x5000, 0x080c,
-	0x56b3, 0x0804, 0x3526, 0xd2fc, 0x0158, 0x080c, 0x4ae7, 0x0904,
-	0x355b, 0x7984, 0x9284, 0x9000, 0x080c, 0x5690, 0x0804, 0x3526,
-	0x080c, 0x4ae7, 0x0904, 0x355b, 0xb804, 0x9084, 0x00ff, 0x9086,
-	0x0006, 0x2009, 0x0009, 0x1904, 0x5471, 0x080c, 0x4ab4, 0x2009,
-	0x0002, 0x0904, 0x5471, 0xa85c, 0x9080, 0x001b, 0xaf60, 0x2009,
-	0x0008, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c, 0x4afd, 0x701f,
-	0x53e2, 0x0005, 0xa86c, 0x9086, 0x0500, 0x1138, 0xa870, 0x9005,
-	0x1120, 0xa874, 0x9084, 0xff00, 0x0110, 0x1904, 0x355b, 0xa866,
-	0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0x4ae7, 0x1110, 0x0804,
-	0x355b, 0x2009, 0x0043, 0x080c, 0xd02d, 0x2009, 0x0003, 0x0904,
-	0x5471, 0x7007, 0x0003, 0x701f, 0x5406, 0x0005, 0xa830, 0x9086,
-	0x0100, 0x2009, 0x0004, 0x0904, 0x5471, 0x7984, 0x7aa8, 0x9284,
-	0x1000, 0x080c, 0x5690, 0x0804, 0x3526, 0x00c6, 0xaab0, 0x9284,
-	0xc000, 0x0140, 0xd2ec, 0x0168, 0x080c, 0x56ec, 0x1150, 0x2009,
-	0x0014, 0x04f0, 0x2061, 0x1800, 0x080c, 0x56ec, 0x2009, 0x0007,
-	0x15b8, 0xd2f4, 0x0128, 0x9284, 0x5000, 0x080c, 0x56b3, 0x0050,
-	0xd2fc, 0x0178, 0x080c, 0x4ae5, 0x0588, 0xa998, 0x9284, 0x9000,
-	0x080c, 0x5690, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000,
-	0x0438, 0x080c, 0x4ae5, 0x0510, 0x080c, 0x697b, 0x2009, 0x0009,
-	0x11b8, 0xa8c4, 0x9086, 0x0500, 0x11c8, 0xa8c8, 0x9005, 0x11b0,
-	0xa8cc, 0x9084, 0xff00, 0x1190, 0x080c, 0x4ae5, 0x1108, 0x0070,
-	0x2009, 0x004b, 0x080c, 0xd02d, 0x2009, 0x0003, 0x0108, 0x0078,
-	0x0429, 0x19c0, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
-	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x00ce, 0x0005, 0x9006,
-	0x0ce0, 0x7aa8, 0xd2dc, 0x0904, 0x3558, 0x0016, 0x7984, 0x9284,
-	0x1000, 0xc0fd, 0x080c, 0x5690, 0x001e, 0x1904, 0x3558, 0x0804,
-	0x3526, 0x00f6, 0x2d78, 0x0011, 0x00fe, 0x0005, 0xaab0, 0xd2dc,
-	0x0150, 0x0016, 0xa998, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x5690,
-	0x001e, 0x9085, 0x0001, 0x0005, 0x81ff, 0x0120, 0x2009, 0x0001,
-	0x0804, 0x3558, 0x080c, 0x56ec, 0x0120, 0x2009, 0x0007, 0x0804,
-	0x3558, 0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c, 0x6608, 0x1904,
-	0x355b, 0x9186, 0x007f, 0x0138, 0x080c, 0x697b, 0x0120, 0x2009,
-	0x0009, 0x0804, 0x3558, 0x080c, 0x4ab4, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x3558, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x2001,
-	0x0100, 0x8007, 0xa80a, 0x080c, 0xcd2d, 0x1120, 0x2009, 0x0003,
-	0x0804, 0x3558, 0x7007, 0x0003, 0x701f, 0x54cf, 0x0005, 0xa808,
-	0x8007, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x3558,
-	0xa8e0, 0xa866, 0xa810, 0x8007, 0x9084, 0x00ff, 0x800c, 0xa814,
-	0x8007, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0002, 0x9108, 0x8906,
-	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0004,
-	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4b00, 0x080c, 0x4ab4,
-	0x1120, 0x2009, 0x0002, 0x0804, 0x3558, 0x7984, 0x9194, 0xff00,
-	0x918c, 0x00ff, 0x8217, 0x82ff, 0x1118, 0x7023, 0x19b2, 0x0040,
-	0x92c6, 0x0001, 0x1118, 0x7023, 0x19cc, 0x0010, 0x0804, 0x355b,
-	0x2009, 0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080,
-	0x0019, 0xaf60, 0x080c, 0x4afd, 0x701f, 0x551f, 0x0005, 0x2001,
-	0x182e, 0x2003, 0x0001, 0xa85c, 0x9080, 0x0019, 0x2098, 0xa860,
-	0x20e0, 0x20a9, 0x001a, 0x7020, 0x20a0, 0x20e9, 0x0001, 0x4003,
-	0x0804, 0x3526, 0x080c, 0x4ab4, 0x1120, 0x2009, 0x0002, 0x0804,
-	0x3558, 0x7984, 0x9194, 0xff00, 0x918c, 0x00ff, 0x8217, 0x82ff,
-	0x1118, 0x2099, 0x19b2, 0x0040, 0x92c6, 0x0001, 0x1118, 0x2099,
-	0x19cc, 0x0010, 0x0804, 0x355b, 0xa85c, 0x9080, 0x0019, 0x20a0,
-	0xa860, 0x20e8, 0x20a9, 0x001a, 0x20e1, 0x0001, 0x4003, 0x2009,
-	0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019,
-	0xaf60, 0x0804, 0x4b00, 0x7884, 0x908a, 0x1000, 0x1a04, 0x355b,
-	0x0126, 0x2091, 0x8000, 0x8003, 0x800b, 0x810b, 0x9108, 0x00c6,
-	0x2061, 0x19f9, 0x6142, 0x00ce, 0x012e, 0x0804, 0x3526, 0x00c6,
-	0x080c, 0x73a5, 0x1160, 0x080c, 0x768d, 0x080c, 0x6023, 0x9085,
-	0x0001, 0x080c, 0x73ec, 0x080c, 0x72d7, 0x080c, 0x0dd5, 0x2061,
-	0x1800, 0x6030, 0xc09d, 0x6032, 0x080c, 0x5ee2, 0x00ce, 0x0005,
-	0x00c6, 0x2001, 0x1800, 0x2004, 0x908e, 0x0000, 0x0904, 0x3558,
-	0x7884, 0x9005, 0x0188, 0x7888, 0x2061, 0x199b, 0x2c0c, 0x2062,
-	0x080c, 0x2c22, 0x01a0, 0x080c, 0x2c2a, 0x0188, 0x080c, 0x2c32,
-	0x0170, 0x2162, 0x0804, 0x355b, 0x2061, 0x0100, 0x6038, 0x9086,
-	0x0007, 0x1118, 0x2009, 0x0001, 0x0010, 0x2009, 0x0000, 0x7884,
-	0x9086, 0x0002, 0x1548, 0x2061, 0x0100, 0x6028, 0xc09c, 0x602a,
-	0x0026, 0x2011, 0x0003, 0x080c, 0xa654, 0x2011, 0x0002, 0x080c,
-	0xa65e, 0x002e, 0x080c, 0xa541, 0x0036, 0x901e, 0x080c, 0xa5b7,
-	0x003e, 0x60e3, 0x0000, 0x080c, 0xea0a, 0x080c, 0xea25, 0x9085,
-	0x0001, 0x080c, 0x73ec, 0x9006, 0x080c, 0x2cf1, 0x2001, 0x1800,
-	0x2003, 0x0004, 0x6027, 0x0008, 0x00ce, 0x0804, 0x3526, 0x81ff,
-	0x0120, 0x2009, 0x0001, 0x0804, 0x3558, 0x080c, 0x56ec, 0x0120,
-	0x2009, 0x0007, 0x0804, 0x3558, 0x7984, 0x7ea8, 0x96b4, 0x00ff,
-	0x080c, 0x6608, 0x1904, 0x355b, 0x9186, 0x007f, 0x0138, 0x080c,
-	0x697b, 0x0120, 0x2009, 0x0009, 0x0804, 0x3558, 0x080c, 0x4ab4,
-	0x1120, 0x2009, 0x0002, 0x0804, 0x3558, 0xa867, 0x0000, 0xa868,
-	0xc0fd, 0xa86a, 0x080c, 0xcd30, 0x1120, 0x2009, 0x0003, 0x0804,
-	0x3558, 0x7007, 0x0003, 0x701f, 0x561e, 0x0005, 0xa830, 0x9086,
-	0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x3558, 0xa8e0, 0xa866,
-	0xa834, 0x8007, 0x800c, 0xa85c, 0x9080, 0x000c, 0x7a8c, 0x7b88,
-	0x7c9c, 0x7d98, 0xaf60, 0x0804, 0x4b00, 0xa898, 0x9086, 0x000d,
-	0x1904, 0x3558, 0x2021, 0x4005, 0x0126, 0x2091, 0x8000, 0x0e04,
-	0x5642, 0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000, 0x0118,
-	0x7833, 0x0011, 0x0010, 0x7833, 0x0010, 0x7883, 0x4005, 0xa998,
-	0x7986, 0xa9a4, 0x799a, 0xa9a8, 0x799e, 0x080c, 0x4af0, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b, 0x7007,
-	0x0001, 0x2091, 0x5000, 0x700f, 0x0000, 0x012e, 0x0005, 0x0126,
-	0x2091, 0x8000, 0x00c6, 0x2061, 0x19f9, 0x7984, 0x6152, 0x614e,
-	0x6057, 0x0000, 0x604b, 0x0009, 0x7898, 0x606a, 0x789c, 0x6066,
-	0x7888, 0x6062, 0x788c, 0x605e, 0x2001, 0x1a07, 0x2044, 0x2001,
-	0x1a0e, 0xa076, 0xa060, 0xa072, 0xa07b, 0x0001, 0xa07f, 0x0002,
-	0xa06b, 0x0000, 0xa09f, 0x0000, 0x00ce, 0x012e, 0x0804, 0x3526,
-	0x0126, 0x2091, 0x8000, 0x00b6, 0x00c6, 0x90e4, 0xc000, 0x0128,
-	0x0006, 0x080c, 0xcb97, 0x000e, 0x1198, 0xd0e4, 0x0160, 0x9180,
-	0x1000, 0x2004, 0x905d, 0x0160, 0x080c, 0x603d, 0x080c, 0xaddb,
-	0x0110, 0xb817, 0x0000, 0x9006, 0x00ce, 0x00be, 0x012e, 0x0005,
-	0x9085, 0x0001, 0x0cc8, 0x0126, 0x2091, 0x8000, 0x0156, 0x2010,
-	0x900e, 0x20a9, 0x0800, 0x0016, 0x9180, 0x1000, 0x2004, 0x9005,
-	0x0180, 0x9186, 0x007e, 0x0168, 0x9186, 0x007f, 0x0150, 0x9186,
-	0x0080, 0x0138, 0x9186, 0x00ff, 0x0120, 0x0026, 0x2200, 0x0801,
-	0x002e, 0x001e, 0x8108, 0x1f04, 0x56bb, 0x015e, 0x012e, 0x0005,
-	0x2001, 0x1848, 0x2004, 0x0005, 0x2001, 0x1867, 0x2004, 0x0005,
-	0x0006, 0x2001, 0x1810, 0x2004, 0xd0d4, 0x000e, 0x0005, 0x2001,
-	0x180e, 0x2004, 0xd0b4, 0x0005, 0x2001, 0x1800, 0x2004, 0x9086,
-	0x0003, 0x0005, 0x0016, 0x00e6, 0x2071, 0x189e, 0x7108, 0x910d,
-	0x710a, 0x00ee, 0x001e, 0x0005, 0x79a4, 0x9182, 0x0081, 0x1a04,
-	0x355b, 0x810c, 0x0016, 0x080c, 0x4ab4, 0x080c, 0x0f07, 0x2100,
-	0x2238, 0x7d84, 0x7c88, 0x7b8c, 0x7a90, 0x001e, 0x080c, 0x4afd,
-	0x701f, 0x5713, 0x0005, 0x2079, 0x0000, 0x7d94, 0x7c98, 0x7ba8,
-	0x7aac, 0x79a4, 0x810c, 0x2061, 0x18b8, 0x2c44, 0xa770, 0xa074,
-	0x2071, 0x189e, 0x080c, 0x4b00, 0x701f, 0x5727, 0x0005, 0x2061,
-	0x18b8, 0x2c44, 0x0016, 0x0026, 0xa270, 0xa174, 0x080c, 0x0f0f,
-	0x002e, 0x001e, 0x080c, 0x0fbc, 0x9006, 0xa802, 0xa806, 0x0804,
-	0x3526, 0x0126, 0x0156, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6,
-	0x00d6, 0x00e6, 0x00f6, 0x2061, 0x0100, 0x2069, 0x0200, 0x2071,
-	0x1800, 0x6044, 0xd0a4, 0x11e8, 0xd084, 0x0118, 0x080c, 0x58e2,
-	0x0068, 0xd08c, 0x0118, 0x080c, 0x57eb, 0x0040, 0xd094, 0x0118,
-	0x080c, 0x57bb, 0x0018, 0xd09c, 0x0108, 0x0099, 0x00fe, 0x00ee,
-	0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x012e,
-	0x0005, 0x0016, 0x6128, 0xd19c, 0x1110, 0xc19d, 0x612a, 0x001e,
-	0x0c68, 0x0006, 0x7098, 0x9005, 0x000e, 0x0120, 0x709b, 0x0000,
-	0x7093, 0x0000, 0x624c, 0x9286, 0xf0f0, 0x1150, 0x6048, 0x9086,
-	0xf0f0, 0x0130, 0x624a, 0x6043, 0x0090, 0x6043, 0x0010, 0x0490,
-	0x9294, 0xff00, 0x9296, 0xf700, 0x0178, 0x7138, 0xd1a4, 0x1160,
-	0x6240, 0x9295, 0x0100, 0x6242, 0x9294, 0x0010, 0x0128, 0x2009,
-	0x00f7, 0x080c, 0x5f9f, 0x00f0, 0x6040, 0x9084, 0x0010, 0x9085,
-	0x0140, 0x6042, 0x6043, 0x0000, 0x7087, 0x0000, 0x70a3, 0x0001,
-	0x70c7, 0x0000, 0x70df, 0x0000, 0x2009, 0x1c80, 0x200b, 0x0000,
-	0x7097, 0x0000, 0x708b, 0x000f, 0x2009, 0x000f, 0x2011, 0x5e85,
-	0x080c, 0x8574, 0x0005, 0x2001, 0x1869, 0x2004, 0xd08c, 0x0110,
-	0x705f, 0xffff, 0x7088, 0x9005, 0x1528, 0x2011, 0x5e85, 0x080c,
-	0x84dc, 0x6040, 0x9094, 0x0010, 0x9285, 0x0020, 0x6042, 0x20a9,
-	0x00c8, 0x6044, 0xd08c, 0x1168, 0x1f04, 0x57d1, 0x6242, 0x709b,
-	0x0000, 0x6040, 0x9094, 0x0010, 0x9285, 0x0080, 0x6042, 0x6242,
-	0x0048, 0x6242, 0x709b, 0x0000, 0x708f, 0x0000, 0x9006, 0x080c,
-	0x6028, 0x0000, 0x0005, 0x708c, 0x908a, 0x0003, 0x1a0c, 0x0dd5,
-	0x000b, 0x0005, 0x57f5, 0x5846, 0x58e1, 0x00f6, 0x0016, 0x6900,
-	0x918c, 0x0800, 0x708f, 0x0001, 0x2001, 0x015d, 0x2003, 0x0000,
-	0x6803, 0x00fc, 0x20a9, 0x0004, 0x6800, 0x9084, 0x00fc, 0x0120,
-	0x1f04, 0x5804, 0x080c, 0x0dd5, 0x68a0, 0x68a2, 0x689c, 0x689e,
-	0x6898, 0x689a, 0xa001, 0x918d, 0x1600, 0x6902, 0x001e, 0x6837,
-	0x0020, 0x080c, 0x6004, 0x2079, 0x1c00, 0x7833, 0x1101, 0x7837,
-	0x0000, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0001, 0x20a1,
-	0x1c0e, 0x20a9, 0x0004, 0x4003, 0x080c, 0xab2c, 0x20e1, 0x0001,
-	0x2099, 0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x0014,
-	0x4003, 0x60c3, 0x000c, 0x600f, 0x0000, 0x080c, 0x5eb6, 0x00fe,
-	0x9006, 0x7092, 0x6043, 0x0008, 0x6042, 0x0005, 0x00f6, 0x7090,
-	0x7093, 0x0000, 0x9025, 0x0904, 0x58be, 0x6020, 0xd0b4, 0x1904,
-	0x58bc, 0x71a0, 0x81ff, 0x0904, 0x58aa, 0x9486, 0x000c, 0x1904,
-	0x58b7, 0x9480, 0x0018, 0x8004, 0x20a8, 0x080c, 0x5ffd, 0x2011,
-	0x0260, 0x2019, 0x1c00, 0x220c, 0x2304, 0x9106, 0x11e8, 0x8210,
-	0x8318, 0x1f04, 0x5863, 0x6043, 0x0004, 0x2061, 0x0140, 0x605b,
-	0xbc94, 0x605f, 0xf0f0, 0x2061, 0x0100, 0x6043, 0x0006, 0x708f,
-	0x0002, 0x709b, 0x0002, 0x2009, 0x07d0, 0x2011, 0x5e8c, 0x080c,
-	0x8574, 0x080c, 0x6004, 0x04c0, 0x080c, 0x5ffd, 0x2079, 0x0260,
-	0x7930, 0x918e, 0x1101, 0x1558, 0x7834, 0x9005, 0x1540, 0x7900,
-	0x918c, 0x00ff, 0x1118, 0x7804, 0x9005, 0x0190, 0x080c, 0x5ffd,
-	0x2011, 0x026e, 0x2019, 0x1805, 0x20a9, 0x0004, 0x220c, 0x2304,
-	0x9102, 0x0230, 0x11a0, 0x8210, 0x8318, 0x1f04, 0x589e, 0x0078,
-	0x70a3, 0x0000, 0x080c, 0x5ffd, 0x20e1, 0x0000, 0x2099, 0x0260,
-	0x20e9, 0x0001, 0x20a1, 0x1c00, 0x20a9, 0x0014, 0x4003, 0x6043,
-	0x0008, 0x6043, 0x0000, 0x0010, 0x00fe, 0x0005, 0x6040, 0x9085,
-	0x0100, 0x6042, 0x6020, 0xd0b4, 0x1db8, 0x080c, 0xab2c, 0x20e1,
-	0x0001, 0x2099, 0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9,
-	0x0014, 0x4003, 0x60c3, 0x000c, 0x2011, 0x19f0, 0x2013, 0x0000,
-	0x7093, 0x0000, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0xa26b,
-	0x08d8, 0x0005, 0x7098, 0x908a, 0x001d, 0x1a0c, 0x0dd5, 0x000b,
-	0x0005, 0x5913, 0x5926, 0x594f, 0x596f, 0x5995, 0x59c4, 0x59ea,
-	0x5a22, 0x5a48, 0x5a76, 0x5ab1, 0x5ae9, 0x5b07, 0x5b32, 0x5b54,
-	0x5b6f, 0x5b79, 0x5bad, 0x5bd3, 0x5c02, 0x5c28, 0x5c60, 0x5ca4,
-	0x5ce1, 0x5d02, 0x5d5b, 0x5d7d, 0x5dab, 0x5dab, 0x00c6, 0x2061,
-	0x1800, 0x6003, 0x0007, 0x2061, 0x0100, 0x6004, 0x9084, 0xfff9,
-	0x6006, 0x00ce, 0x0005, 0x2061, 0x0140, 0x605b, 0xbc94, 0x605f,
-	0xf0f0, 0x2061, 0x0100, 0x6043, 0x0002, 0x709b, 0x0001, 0x2009,
-	0x07d0, 0x2011, 0x5e8c, 0x080c, 0x8574, 0x0005, 0x00f6, 0x7090,
-	0x9086, 0x0014, 0x1510, 0x6042, 0x6020, 0xd0b4, 0x11f0, 0x080c,
-	0x5ffd, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102, 0x11a0, 0x7834,
-	0x9005, 0x1188, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110,
-	0x70c7, 0x0001, 0x2011, 0x5e8c, 0x080c, 0x84dc, 0x709b, 0x0010,
-	0x080c, 0x5b79, 0x0010, 0x7093, 0x0000, 0x00fe, 0x0005, 0x00f6,
-	0x709b, 0x0003, 0x6043, 0x0004, 0x2011, 0x5e8c, 0x080c, 0x84dc,
-	0x080c, 0x5f81, 0x2079, 0x0240, 0x7833, 0x1102, 0x7837, 0x0000,
-	0x20a9, 0x0008, 0x9f88, 0x000e, 0x200b, 0x0000, 0x8108, 0x1f04,
-	0x5964, 0x60c3, 0x0014, 0x080c, 0x5eb6, 0x00fe, 0x0005, 0x00f6,
-	0x7090, 0x9005, 0x0500, 0x2011, 0x5e8c, 0x080c, 0x84dc, 0x9086,
-	0x0014, 0x11b8, 0x080c, 0x5ffd, 0x2079, 0x0260, 0x7a30, 0x9296,
-	0x1102, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128,
-	0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x709b, 0x0004, 0x0029,
-	0x0010, 0x080c, 0x5fd9, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0005,
-	0x080c, 0x5f81, 0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000,
-	0x080c, 0x5ffd, 0x080c, 0x5fe0, 0x1170, 0x7084, 0x9005, 0x1158,
-	0x715c, 0x9186, 0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5e39,
-	0x0168, 0x080c, 0x5fb6, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099,
+	0x0800, 0x0120, 0x9386, 0x003c, 0x01e8, 0x0c20, 0x83ff, 0x11c0,
+	0x7254, 0x900e, 0x2001, 0x0003, 0x080c, 0x8f70, 0x2208, 0x009e,
+	0xa897, 0x4000, 0xa99a, 0x715c, 0x81ff, 0x090c, 0x0dd5, 0x2148,
+	0x080c, 0x1031, 0x9006, 0x705e, 0x918d, 0x0001, 0x2008, 0x0418,
+	0x7063, 0x0001, 0x7152, 0x7054, 0x9300, 0x7056, 0x2061, 0x18b9,
+	0x2c44, 0xa37a, 0x7058, 0xa076, 0x7064, 0xa072, 0xa48e, 0xa592,
+	0xa696, 0xa79a, 0xa09f, 0x510e, 0x000e, 0xa0a2, 0x080c, 0x10e9,
+	0x9006, 0x0048, 0x009e, 0xa897, 0x4005, 0xa99a, 0x900e, 0x9085,
+	0x0001, 0x2001, 0x0030, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0xa0a0,
+	0x904d, 0x090c, 0x0dd5, 0x00e6, 0x2071, 0x189e, 0xa06c, 0x908e,
+	0x0100, 0x0138, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002,
+	0x00d8, 0x7060, 0x9005, 0x1158, 0x7150, 0x7058, 0x20a0, 0x901e,
+	0x7064, 0x20e8, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0428, 0xa87b,
+	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x7254, 0x900e, 0x2001,
+	0x0003, 0x080c, 0x8f70, 0xaa9a, 0x715c, 0x81ff, 0x090c, 0x0dd5,
+	0x2148, 0x080c, 0x1031, 0x705f, 0x0000, 0xa0a0, 0x2048, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x6c94, 0x012e, 0xa09f, 0x0000, 0xa0a3,
+	0x0000, 0x00ee, 0x00fe, 0x0005, 0x91d8, 0x1000, 0x2b5c, 0x8bff,
+	0x0178, 0x080c, 0x6989, 0x0118, 0x080c, 0x6991, 0x1148, 0xb814,
+	0x20a9, 0x0001, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003,
+	0x8108, 0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x0518, 0x0c20,
+	0x83ff, 0x11f0, 0x7154, 0x810c, 0xa99a, 0xa897, 0x4000, 0x715c,
+	0x81ff, 0x090c, 0x0dd5, 0x2148, 0x080c, 0x1031, 0x9006, 0x705e,
+	0x918d, 0x0001, 0x2008, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x6c94, 0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x0070,
+	0x7063, 0x0001, 0x7152, 0x7054, 0x9300, 0x7056, 0xa37a, 0xa48e,
+	0xa592, 0xa696, 0xa79a, 0x080c, 0x10e9, 0x9006, 0x00ee, 0x0005,
+	0x0096, 0xa88c, 0x90be, 0x7000, 0x0148, 0x90be, 0x7100, 0x0130,
+	0x90be, 0x7200, 0x0118, 0x009e, 0x0804, 0x3566, 0xa884, 0xa988,
+	0x080c, 0x284b, 0x1518, 0x080c, 0x65b5, 0x1500, 0x7126, 0xbe12,
+	0xbd16, 0xae7c, 0x080c, 0x4abe, 0x01c8, 0x080c, 0x4abe, 0x01b0,
+	0x009e, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0xa823, 0x0000,
+	0xa804, 0x2048, 0x080c, 0xcd04, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x3563, 0x7007, 0x0003, 0x701f, 0x51db, 0x0005, 0x009e, 0x2009,
+	0x0002, 0x0804, 0x3563, 0x7124, 0x080c, 0x32c8, 0xa820, 0x9086,
+	0x8001, 0x1120, 0x2009, 0x0004, 0x0804, 0x3563, 0x2900, 0x7022,
+	0xa804, 0x0096, 0x2048, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
+	0x9084, 0xffc0, 0x009e, 0x9080, 0x0002, 0x0076, 0x0006, 0x2098,
+	0x20a0, 0x27e0, 0x27e8, 0x20a9, 0x002a, 0x080c, 0x0f7c, 0xaa6c,
+	0xab70, 0xac74, 0xad78, 0x2061, 0x18b8, 0x2c44, 0xa06b, 0x0000,
+	0xae64, 0xaf8c, 0x97c6, 0x7000, 0x0118, 0x97c6, 0x7100, 0x1148,
+	0x96c2, 0x0004, 0x0600, 0x2009, 0x0004, 0x000e, 0x007e, 0x0804,
+	0x4b0a, 0x97c6, 0x7200, 0x11b8, 0x96c2, 0x0054, 0x02a0, 0x000e,
+	0x007e, 0x2061, 0x18b8, 0x2c44, 0xa076, 0xa772, 0xa07b, 0x002a,
+	0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10e9, 0x7007, 0x0002,
+	0x701f, 0x5237, 0x0005, 0x000e, 0x007e, 0x0804, 0x3566, 0x7020,
+	0x2048, 0xa804, 0x2048, 0xa804, 0x2048, 0x8906, 0x8006, 0x8007,
+	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2098, 0x20a0,
+	0x27e0, 0x27e8, 0x20a9, 0x002a, 0x080c, 0x0f7c, 0x2100, 0x2238,
+	0x2061, 0x18b8, 0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x2009,
+	0x002a, 0x0804, 0x4b0a, 0x81ff, 0x1904, 0x3563, 0x798c, 0x2001,
+	0x197d, 0x918c, 0x8000, 0x2102, 0x080c, 0x4ad5, 0x0904, 0x3566,
+	0x080c, 0x6989, 0x0120, 0x080c, 0x6991, 0x1904, 0x3566, 0x080c,
+	0x66dd, 0x0904, 0x3563, 0x0126, 0x2091, 0x8000, 0x080c, 0x67a3,
+	0x012e, 0x0904, 0x3563, 0x2001, 0x197d, 0x2004, 0xd0fc, 0x1904,
+	0x3531, 0x0804, 0x4534, 0xa9a0, 0x2001, 0x197d, 0x918c, 0x8000,
+	0xc18d, 0x2102, 0x080c, 0x4ae2, 0x01a0, 0x080c, 0x6989, 0x0118,
+	0x080c, 0x6991, 0x1170, 0x080c, 0x66dd, 0x2009, 0x0002, 0x0128,
+	0x080c, 0x67a3, 0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a,
+	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
+	0x0005, 0xa897, 0x4000, 0x2001, 0x197d, 0x2004, 0xd0fc, 0x1128,
+	0x080c, 0x56ea, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001,
+	0x2001, 0x0000, 0x0005, 0x78a8, 0xd08c, 0x1118, 0xd084, 0x0904,
+	0x44a9, 0x080c, 0x4af1, 0x0904, 0x3566, 0x080c, 0x4abe, 0x1120,
+	0x2009, 0x0002, 0x0804, 0x3563, 0x080c, 0x6989, 0x0130, 0x908e,
+	0x0004, 0x0118, 0x908e, 0x0005, 0x15a0, 0x78a8, 0xd08c, 0x0120,
+	0xb800, 0xc08c, 0xb802, 0x0028, 0x080c, 0x56e2, 0xd0b4, 0x0904,
+	0x44e3, 0x7884, 0x908e, 0x007e, 0x0904, 0x44e3, 0x908e, 0x007f,
+	0x0904, 0x44e3, 0x908e, 0x0080, 0x0904, 0x44e3, 0xb800, 0xd08c,
+	0x1904, 0x44e3, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c,
+	0xcd23, 0x1120, 0x2009, 0x0003, 0x0804, 0x3563, 0x7007, 0x0003,
+	0x701f, 0x5303, 0x0005, 0x080c, 0x4af1, 0x0904, 0x3566, 0x0804,
+	0x44e3, 0x080c, 0x3321, 0x0108, 0x0005, 0x2009, 0x1834, 0x210c,
+	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3563, 0x080c, 0x56f6,
+	0x0120, 0x2009, 0x0007, 0x0804, 0x3563, 0x080c, 0x6981, 0x0120,
+	0x2009, 0x0008, 0x0804, 0x3563, 0xb89c, 0xd0a4, 0x1118, 0xd0ac,
+	0x1904, 0x44e3, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
+	0x080c, 0xcd82, 0x1120, 0x2009, 0x0003, 0x0804, 0x3563, 0x7007,
+	0x0003, 0x701f, 0x533c, 0x0005, 0xa830, 0x9086, 0x0100, 0x1120,
+	0x2009, 0x0004, 0x0804, 0x563f, 0x080c, 0x4af1, 0x0904, 0x3566,
+	0x0804, 0x52d5, 0x81ff, 0x2009, 0x0001, 0x1904, 0x3563, 0x080c,
+	0x56f6, 0x2009, 0x0007, 0x1904, 0x3563, 0x080c, 0x6981, 0x0120,
+	0x2009, 0x0008, 0x0804, 0x3563, 0x080c, 0x4af1, 0x0904, 0x3566,
+	0x080c, 0x6989, 0x2009, 0x0009, 0x1904, 0x3563, 0x080c, 0x4abe,
+	0x2009, 0x0002, 0x0904, 0x3563, 0x9006, 0xa866, 0xa832, 0xa868,
+	0xc0fd, 0xa86a, 0x7988, 0x9194, 0xff00, 0x918c, 0x00ff, 0x9006,
+	0x82ff, 0x1128, 0xc0ed, 0xa952, 0x798c, 0xa956, 0x0038, 0x928e,
+	0x0100, 0x1904, 0x3566, 0xc0e5, 0xa952, 0xa956, 0xa83e, 0x080c,
+	0xcfd5, 0x2009, 0x0003, 0x0904, 0x3563, 0x7007, 0x0003, 0x701f,
+	0x5392, 0x0005, 0xa830, 0x9086, 0x0100, 0x2009, 0x0004, 0x0904,
+	0x3563, 0x0804, 0x3531, 0x7aa8, 0x9284, 0xc000, 0x0148, 0xd2ec,
+	0x01a0, 0x080c, 0x56f6, 0x1188, 0x2009, 0x0014, 0x0804, 0x3563,
+	0xd2dc, 0x1568, 0x81ff, 0x2009, 0x0001, 0x1904, 0x3563, 0x080c,
+	0x56f6, 0x2009, 0x0007, 0x1904, 0x3563, 0xd2f4, 0x0130, 0x9284,
+	0x5000, 0x080c, 0x56bd, 0x0804, 0x3531, 0xd2fc, 0x0158, 0x080c,
+	0x4af1, 0x0904, 0x3566, 0x7984, 0x9284, 0x9000, 0x080c, 0x569a,
+	0x0804, 0x3531, 0x080c, 0x4af1, 0x0904, 0x3566, 0xb804, 0x9084,
+	0x00ff, 0x9086, 0x0006, 0x2009, 0x0009, 0x1904, 0x547b, 0x080c,
+	0x4abe, 0x2009, 0x0002, 0x0904, 0x547b, 0xa85c, 0x9080, 0x001b,
+	0xaf60, 0x2009, 0x0008, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c,
+	0x4b07, 0x701f, 0x53ec, 0x0005, 0xa86c, 0x9086, 0x0500, 0x1138,
+	0xa870, 0x9005, 0x1120, 0xa874, 0x9084, 0xff00, 0x0110, 0x1904,
+	0x3566, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0x4af1,
+	0x1110, 0x0804, 0x3566, 0x2009, 0x0043, 0x080c, 0xd03d, 0x2009,
+	0x0003, 0x0904, 0x547b, 0x7007, 0x0003, 0x701f, 0x5410, 0x0005,
+	0xa830, 0x9086, 0x0100, 0x2009, 0x0004, 0x0904, 0x547b, 0x7984,
+	0x7aa8, 0x9284, 0x1000, 0x080c, 0x569a, 0x0804, 0x3531, 0x00c6,
+	0xaab0, 0x9284, 0xc000, 0x0140, 0xd2ec, 0x0168, 0x080c, 0x56f6,
+	0x1150, 0x2009, 0x0014, 0x04f0, 0x2061, 0x1800, 0x080c, 0x56f6,
+	0x2009, 0x0007, 0x15b8, 0xd2f4, 0x0128, 0x9284, 0x5000, 0x080c,
+	0x56bd, 0x0050, 0xd2fc, 0x0178, 0x080c, 0x4aef, 0x0588, 0xa998,
+	0x9284, 0x9000, 0x080c, 0x569a, 0xa87b, 0x0000, 0xa883, 0x0000,
+	0xa897, 0x4000, 0x0438, 0x080c, 0x4aef, 0x0510, 0x080c, 0x6989,
+	0x2009, 0x0009, 0x11b8, 0xa8c4, 0x9086, 0x0500, 0x11c8, 0xa8c8,
+	0x9005, 0x11b0, 0xa8cc, 0x9084, 0xff00, 0x1190, 0x080c, 0x4aef,
+	0x1108, 0x0070, 0x2009, 0x004b, 0x080c, 0xd03d, 0x2009, 0x0003,
+	0x0108, 0x0078, 0x0429, 0x19c0, 0xa897, 0x4005, 0xa99a, 0x0010,
+	0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x00ce,
+	0x0005, 0x9006, 0x0ce0, 0x7aa8, 0xd2dc, 0x0904, 0x3563, 0x0016,
+	0x7984, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x569a, 0x001e, 0x1904,
+	0x3563, 0x0804, 0x3531, 0x00f6, 0x2d78, 0x0011, 0x00fe, 0x0005,
+	0xaab0, 0xd2dc, 0x0150, 0x0016, 0xa998, 0x9284, 0x1000, 0xc0fd,
+	0x080c, 0x569a, 0x001e, 0x9085, 0x0001, 0x0005, 0x81ff, 0x0120,
+	0x2009, 0x0001, 0x0804, 0x3563, 0x080c, 0x56f6, 0x0120, 0x2009,
+	0x0007, 0x0804, 0x3563, 0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c,
+	0x6616, 0x1904, 0x3566, 0x9186, 0x007f, 0x0138, 0x080c, 0x6989,
+	0x0120, 0x2009, 0x0009, 0x0804, 0x3563, 0x080c, 0x4abe, 0x1120,
+	0x2009, 0x0002, 0x0804, 0x3563, 0xa867, 0x0000, 0xa868, 0xc0fd,
+	0xa86a, 0x2001, 0x0100, 0x8007, 0xa80a, 0x080c, 0xcd3d, 0x1120,
+	0x2009, 0x0003, 0x0804, 0x3563, 0x7007, 0x0003, 0x701f, 0x54d9,
+	0x0005, 0xa808, 0x8007, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004,
+	0x0804, 0x3563, 0xa8e0, 0xa866, 0xa810, 0x8007, 0x9084, 0x00ff,
+	0x800c, 0xa814, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0002,
+	0x9108, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
+	0x9080, 0x0004, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4b0a,
+	0x080c, 0x4abe, 0x1120, 0x2009, 0x0002, 0x0804, 0x3563, 0x7984,
+	0x9194, 0xff00, 0x918c, 0x00ff, 0x8217, 0x82ff, 0x1118, 0x7023,
+	0x19b2, 0x0040, 0x92c6, 0x0001, 0x1118, 0x7023, 0x19cc, 0x0010,
+	0x0804, 0x3566, 0x2009, 0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
+	0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x4b07, 0x701f, 0x5529,
+	0x0005, 0x2001, 0x182e, 0x2003, 0x0001, 0xa85c, 0x9080, 0x0019,
+	0x2098, 0xa860, 0x20e0, 0x20a9, 0x001a, 0x7020, 0x20a0, 0x20e9,
+	0x0001, 0x4003, 0x0804, 0x3531, 0x080c, 0x4abe, 0x1120, 0x2009,
+	0x0002, 0x0804, 0x3563, 0x7984, 0x9194, 0xff00, 0x918c, 0x00ff,
+	0x8217, 0x82ff, 0x1118, 0x2099, 0x19b2, 0x0040, 0x92c6, 0x0001,
+	0x1118, 0x2099, 0x19cc, 0x0010, 0x0804, 0x3566, 0xa85c, 0x9080,
+	0x0019, 0x20a0, 0xa860, 0x20e8, 0x20a9, 0x001a, 0x20e1, 0x0001,
+	0x4003, 0x2009, 0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c,
+	0x9080, 0x0019, 0xaf60, 0x0804, 0x4b0a, 0x7884, 0x908a, 0x1000,
+	0x1a04, 0x3566, 0x0126, 0x2091, 0x8000, 0x8003, 0x800b, 0x810b,
+	0x9108, 0x00c6, 0x2061, 0x19f9, 0x6142, 0x00ce, 0x012e, 0x0804,
+	0x3531, 0x00c6, 0x080c, 0x73b3, 0x1160, 0x080c, 0x7699, 0x080c,
+	0x602d, 0x9085, 0x0001, 0x080c, 0x73fa, 0x080c, 0x72e5, 0x080c,
+	0x0dd5, 0x2061, 0x1800, 0x6030, 0xc09d, 0x6032, 0x080c, 0x5eec,
+	0x00ce, 0x0005, 0x00c6, 0x2001, 0x1800, 0x2004, 0x908e, 0x0000,
+	0x0904, 0x3563, 0x7884, 0x9005, 0x0188, 0x7888, 0x2061, 0x199b,
+	0x2c0c, 0x2062, 0x080c, 0x2c2d, 0x01a0, 0x080c, 0x2c35, 0x0188,
+	0x080c, 0x2c3d, 0x0170, 0x2162, 0x0804, 0x3566, 0x2061, 0x0100,
+	0x6038, 0x9086, 0x0007, 0x1118, 0x2009, 0x0001, 0x0010, 0x2009,
+	0x0000, 0x7884, 0x9086, 0x0002, 0x1548, 0x2061, 0x0100, 0x6028,
+	0xc09c, 0x602a, 0x0026, 0x2011, 0x0003, 0x080c, 0xa63e, 0x2011,
+	0x0002, 0x080c, 0xa648, 0x002e, 0x080c, 0xa552, 0x0036, 0x901e,
+	0x080c, 0xa5c8, 0x003e, 0x60e3, 0x0000, 0x080c, 0xea24, 0x080c,
+	0xea3f, 0x9085, 0x0001, 0x080c, 0x73fa, 0x9006, 0x080c, 0x2cfc,
+	0x2001, 0x1800, 0x2003, 0x0004, 0x6027, 0x0008, 0x00ce, 0x0804,
+	0x3531, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3563, 0x080c,
+	0x56f6, 0x0120, 0x2009, 0x0007, 0x0804, 0x3563, 0x7984, 0x7ea8,
+	0x96b4, 0x00ff, 0x080c, 0x6616, 0x1904, 0x3566, 0x9186, 0x007f,
+	0x0138, 0x080c, 0x6989, 0x0120, 0x2009, 0x0009, 0x0804, 0x3563,
+	0x080c, 0x4abe, 0x1120, 0x2009, 0x0002, 0x0804, 0x3563, 0xa867,
+	0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xcd40, 0x1120, 0x2009,
+	0x0003, 0x0804, 0x3563, 0x7007, 0x0003, 0x701f, 0x5628, 0x0005,
+	0xa830, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x3563,
+	0xa8e0, 0xa866, 0xa834, 0x8007, 0x800c, 0xa85c, 0x9080, 0x000c,
+	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xaf60, 0x0804, 0x4b0a, 0xa898,
+	0x9086, 0x000d, 0x1904, 0x3563, 0x2021, 0x4005, 0x0126, 0x2091,
+	0x8000, 0x0e04, 0x564c, 0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486,
+	0x4000, 0x0118, 0x7833, 0x0011, 0x0010, 0x7833, 0x0010, 0x7883,
+	0x4005, 0xa998, 0x7986, 0xa9a4, 0x799a, 0xa9a8, 0x799e, 0x080c,
+	0x4afa, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x119b, 0x7007, 0x0001, 0x2091, 0x5000, 0x700f, 0x0000, 0x012e,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x00c6, 0x2061, 0x19f9, 0x7984,
+	0x6152, 0x614e, 0x6057, 0x0000, 0x604b, 0x0009, 0x7898, 0x606a,
+	0x789c, 0x6066, 0x7888, 0x6062, 0x788c, 0x605e, 0x2001, 0x1a07,
+	0x2044, 0x2001, 0x1a0e, 0xa076, 0xa060, 0xa072, 0xa07b, 0x0001,
+	0xa07f, 0x0002, 0xa06b, 0x0000, 0xa09f, 0x0000, 0x00ce, 0x012e,
+	0x0804, 0x3531, 0x0126, 0x2091, 0x8000, 0x00b6, 0x00c6, 0x90e4,
+	0xc000, 0x0128, 0x0006, 0x080c, 0xcba7, 0x000e, 0x1198, 0xd0e4,
+	0x0160, 0x9180, 0x1000, 0x2004, 0x905d, 0x0160, 0x080c, 0x6047,
+	0x080c, 0xadc9, 0x0110, 0xb817, 0x0000, 0x9006, 0x00ce, 0x00be,
+	0x012e, 0x0005, 0x9085, 0x0001, 0x0cc8, 0x0126, 0x2091, 0x8000,
+	0x0156, 0x2010, 0x900e, 0x20a9, 0x0800, 0x0016, 0x9180, 0x1000,
+	0x2004, 0x9005, 0x0180, 0x9186, 0x007e, 0x0168, 0x9186, 0x007f,
+	0x0150, 0x9186, 0x0080, 0x0138, 0x9186, 0x00ff, 0x0120, 0x0026,
+	0x2200, 0x0801, 0x002e, 0x001e, 0x8108, 0x1f04, 0x56c5, 0x015e,
+	0x012e, 0x0005, 0x2001, 0x1848, 0x2004, 0x0005, 0x2001, 0x1867,
+	0x2004, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0d4, 0x000e,
+	0x0005, 0x2001, 0x180e, 0x2004, 0xd0b4, 0x0005, 0x2001, 0x1800,
+	0x2004, 0x9086, 0x0003, 0x0005, 0x0016, 0x00e6, 0x2071, 0x189e,
+	0x7108, 0x910d, 0x710a, 0x00ee, 0x001e, 0x0005, 0x79a4, 0x9182,
+	0x0081, 0x1a04, 0x3566, 0x810c, 0x0016, 0x080c, 0x4abe, 0x080c,
+	0x0f07, 0x2100, 0x2238, 0x7d84, 0x7c88, 0x7b8c, 0x7a90, 0x001e,
+	0x080c, 0x4b07, 0x701f, 0x571d, 0x0005, 0x2079, 0x0000, 0x7d94,
+	0x7c98, 0x7ba8, 0x7aac, 0x79a4, 0x810c, 0x2061, 0x18b8, 0x2c44,
+	0xa770, 0xa074, 0x2071, 0x189e, 0x080c, 0x4b0a, 0x701f, 0x5731,
+	0x0005, 0x2061, 0x18b8, 0x2c44, 0x0016, 0x0026, 0xa270, 0xa174,
+	0x080c, 0x0f0f, 0x002e, 0x001e, 0x080c, 0x0fbc, 0x9006, 0xa802,
+	0xa806, 0x0804, 0x3531, 0x0126, 0x0156, 0x0136, 0x0146, 0x01c6,
+	0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2061, 0x0100, 0x2069,
+	0x0200, 0x2071, 0x1800, 0x6044, 0xd0a4, 0x11e8, 0xd084, 0x0118,
+	0x080c, 0x58ec, 0x0068, 0xd08c, 0x0118, 0x080c, 0x57f5, 0x0040,
+	0xd094, 0x0118, 0x080c, 0x57c5, 0x0018, 0xd09c, 0x0108, 0x0099,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e,
+	0x015e, 0x012e, 0x0005, 0x0016, 0x6128, 0xd19c, 0x1110, 0xc19d,
+	0x612a, 0x001e, 0x0c68, 0x0006, 0x7098, 0x9005, 0x000e, 0x0120,
+	0x709b, 0x0000, 0x7093, 0x0000, 0x624c, 0x9286, 0xf0f0, 0x1150,
+	0x6048, 0x9086, 0xf0f0, 0x0130, 0x624a, 0x6043, 0x0090, 0x6043,
+	0x0010, 0x0490, 0x9294, 0xff00, 0x9296, 0xf700, 0x0178, 0x7138,
+	0xd1a4, 0x1160, 0x6240, 0x9295, 0x0100, 0x6242, 0x9294, 0x0010,
+	0x0128, 0x2009, 0x00f7, 0x080c, 0x5fa9, 0x00f0, 0x6040, 0x9084,
+	0x0010, 0x9085, 0x0140, 0x6042, 0x6043, 0x0000, 0x7087, 0x0000,
+	0x70a3, 0x0001, 0x70c7, 0x0000, 0x70df, 0x0000, 0x2009, 0x1c80,
+	0x200b, 0x0000, 0x7097, 0x0000, 0x708b, 0x000f, 0x2009, 0x000f,
+	0x2011, 0x5e8f, 0x080c, 0x8591, 0x0005, 0x2001, 0x1869, 0x2004,
+	0xd08c, 0x0110, 0x705f, 0xffff, 0x7088, 0x9005, 0x1528, 0x2011,
+	0x5e8f, 0x080c, 0x84f9, 0x6040, 0x9094, 0x0010, 0x9285, 0x0020,
+	0x6042, 0x20a9, 0x00c8, 0x6044, 0xd08c, 0x1168, 0x1f04, 0x57db,
+	0x6242, 0x709b, 0x0000, 0x6040, 0x9094, 0x0010, 0x9285, 0x0080,
+	0x6042, 0x6242, 0x0048, 0x6242, 0x709b, 0x0000, 0x708f, 0x0000,
+	0x9006, 0x080c, 0x6032, 0x0000, 0x0005, 0x708c, 0x908a, 0x0003,
+	0x1a0c, 0x0dd5, 0x000b, 0x0005, 0x57ff, 0x5850, 0x58eb, 0x00f6,
+	0x0016, 0x6900, 0x918c, 0x0800, 0x708f, 0x0001, 0x2001, 0x015d,
+	0x2003, 0x0000, 0x6803, 0x00fc, 0x20a9, 0x0004, 0x6800, 0x9084,
+	0x00fc, 0x0120, 0x1f04, 0x580e, 0x080c, 0x0dd5, 0x68a0, 0x68a2,
+	0x689c, 0x689e, 0x6898, 0x689a, 0xa001, 0x918d, 0x1600, 0x6902,
+	0x001e, 0x6837, 0x0020, 0x080c, 0x600e, 0x2079, 0x1c00, 0x7833,
+	0x1101, 0x7837, 0x0000, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9,
+	0x0001, 0x20a1, 0x1c0e, 0x20a9, 0x0004, 0x4003, 0x080c, 0xab1a,
+	0x20e1, 0x0001, 0x2099, 0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240,
+	0x20a9, 0x0014, 0x4003, 0x60c3, 0x000c, 0x600f, 0x0000, 0x080c,
+	0x5ec0, 0x00fe, 0x9006, 0x7092, 0x6043, 0x0008, 0x6042, 0x0005,
+	0x00f6, 0x7090, 0x7093, 0x0000, 0x9025, 0x0904, 0x58c8, 0x6020,
+	0xd0b4, 0x1904, 0x58c6, 0x71a0, 0x81ff, 0x0904, 0x58b4, 0x9486,
+	0x000c, 0x1904, 0x58c1, 0x9480, 0x0018, 0x8004, 0x20a8, 0x080c,
+	0x6007, 0x2011, 0x0260, 0x2019, 0x1c00, 0x220c, 0x2304, 0x9106,
+	0x11e8, 0x8210, 0x8318, 0x1f04, 0x586d, 0x6043, 0x0004, 0x2061,
+	0x0140, 0x605b, 0xbc94, 0x605f, 0xf0f0, 0x2061, 0x0100, 0x6043,
+	0x0006, 0x708f, 0x0002, 0x709b, 0x0002, 0x2009, 0x07d0, 0x2011,
+	0x5e96, 0x080c, 0x8591, 0x080c, 0x600e, 0x04c0, 0x080c, 0x6007,
+	0x2079, 0x0260, 0x7930, 0x918e, 0x1101, 0x1558, 0x7834, 0x9005,
+	0x1540, 0x7900, 0x918c, 0x00ff, 0x1118, 0x7804, 0x9005, 0x0190,
+	0x080c, 0x6007, 0x2011, 0x026e, 0x2019, 0x1805, 0x20a9, 0x0004,
+	0x220c, 0x2304, 0x9102, 0x0230, 0x11a0, 0x8210, 0x8318, 0x1f04,
+	0x58a8, 0x0078, 0x70a3, 0x0000, 0x080c, 0x6007, 0x20e1, 0x0000,
+	0x2099, 0x0260, 0x20e9, 0x0001, 0x20a1, 0x1c00, 0x20a9, 0x0014,
+	0x4003, 0x6043, 0x0008, 0x6043, 0x0000, 0x0010, 0x00fe, 0x0005,
+	0x6040, 0x9085, 0x0100, 0x6042, 0x6020, 0xd0b4, 0x1db8, 0x080c,
+	0xab1a, 0x20e1, 0x0001, 0x2099, 0x1c00, 0x20e9, 0x0000, 0x20a1,
+	0x0240, 0x20a9, 0x0014, 0x4003, 0x60c3, 0x000c, 0x2011, 0x19f0,
+	0x2013, 0x0000, 0x7093, 0x0000, 0x60a3, 0x0056, 0x60a7, 0x9575,
+	0x080c, 0xa286, 0x08d8, 0x0005, 0x7098, 0x908a, 0x001d, 0x1a0c,
+	0x0dd5, 0x000b, 0x0005, 0x591d, 0x5930, 0x5959, 0x5979, 0x599f,
+	0x59ce, 0x59f4, 0x5a2c, 0x5a52, 0x5a80, 0x5abb, 0x5af3, 0x5b11,
+	0x5b3c, 0x5b5e, 0x5b79, 0x5b83, 0x5bb7, 0x5bdd, 0x5c0c, 0x5c32,
+	0x5c6a, 0x5cae, 0x5ceb, 0x5d0c, 0x5d65, 0x5d87, 0x5db5, 0x5db5,
+	0x00c6, 0x2061, 0x1800, 0x6003, 0x0007, 0x2061, 0x0100, 0x6004,
+	0x9084, 0xfff9, 0x6006, 0x00ce, 0x0005, 0x2061, 0x0140, 0x605b,
+	0xbc94, 0x605f, 0xf0f0, 0x2061, 0x0100, 0x6043, 0x0002, 0x709b,
+	0x0001, 0x2009, 0x07d0, 0x2011, 0x5e96, 0x080c, 0x8591, 0x0005,
+	0x00f6, 0x7090, 0x9086, 0x0014, 0x1510, 0x6042, 0x6020, 0xd0b4,
+	0x11f0, 0x080c, 0x6007, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102,
+	0x11a0, 0x7834, 0x9005, 0x1188, 0x7a38, 0xd2fc, 0x0128, 0x70c4,
+	0x9005, 0x1110, 0x70c7, 0x0001, 0x2011, 0x5e96, 0x080c, 0x84f9,
+	0x709b, 0x0010, 0x080c, 0x5b83, 0x0010, 0x7093, 0x0000, 0x00fe,
+	0x0005, 0x00f6, 0x709b, 0x0003, 0x6043, 0x0004, 0x2011, 0x5e96,
+	0x080c, 0x84f9, 0x080c, 0x5f8b, 0x2079, 0x0240, 0x7833, 0x1102,
+	0x7837, 0x0000, 0x20a9, 0x0008, 0x9f88, 0x000e, 0x200b, 0x0000,
+	0x8108, 0x1f04, 0x596e, 0x60c3, 0x0014, 0x080c, 0x5ec0, 0x00fe,
+	0x0005, 0x00f6, 0x7090, 0x9005, 0x0500, 0x2011, 0x5e96, 0x080c,
+	0x84f9, 0x9086, 0x0014, 0x11b8, 0x080c, 0x6007, 0x2079, 0x0260,
+	0x7a30, 0x9296, 0x1102, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38,
+	0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x709b,
+	0x0004, 0x0029, 0x0010, 0x080c, 0x5fe3, 0x00fe, 0x0005, 0x00f6,
+	0x709b, 0x0005, 0x080c, 0x5f8b, 0x2079, 0x0240, 0x7833, 0x1103,
+	0x7837, 0x0000, 0x080c, 0x6007, 0x080c, 0x5fea, 0x1170, 0x7084,
+	0x9005, 0x1158, 0x715c, 0x9186, 0xffff, 0x0138, 0x2011, 0x0008,
+	0x080c, 0x5e43, 0x0168, 0x080c, 0x5fc0, 0x20a9, 0x0008, 0x20e1,
+	0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003,
+	0x60c3, 0x0014, 0x080c, 0x5ec0, 0x00fe, 0x0005, 0x00f6, 0x7090,
+	0x9005, 0x0500, 0x2011, 0x5e96, 0x080c, 0x84f9, 0x9086, 0x0014,
+	0x11b8, 0x080c, 0x6007, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103,
+	0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c4,
+	0x9005, 0x1110, 0x70c7, 0x0001, 0x709b, 0x0006, 0x0029, 0x0010,
+	0x080c, 0x5fe3, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0007, 0x080c,
+	0x5f8b, 0x2079, 0x0240, 0x7833, 0x1104, 0x7837, 0x0000, 0x080c,
+	0x6007, 0x080c, 0x5fea, 0x11b8, 0x7084, 0x9005, 0x11a0, 0x7164,
+	0x9186, 0xffff, 0x0180, 0x9180, 0x3332, 0x200d, 0x918c, 0xff00,
+	0x810f, 0x2011, 0x0008, 0x080c, 0x5e43, 0x0180, 0x080c, 0x4ff4,
+	0x0110, 0x080c, 0x28b4, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099,
 	0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014,
-	0x080c, 0x5eb6, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500,
-	0x2011, 0x5e8c, 0x080c, 0x84dc, 0x9086, 0x0014, 0x11b8, 0x080c,
-	0x5ffd, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178, 0x7834,
+	0x080c, 0x5ec0, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500,
+	0x2011, 0x5e96, 0x080c, 0x84f9, 0x9086, 0x0014, 0x11b8, 0x080c,
+	0x6007, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1104, 0x1178, 0x7834,
 	0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110,
-	0x70c7, 0x0001, 0x709b, 0x0006, 0x0029, 0x0010, 0x080c, 0x5fd9,
-	0x00fe, 0x0005, 0x00f6, 0x709b, 0x0007, 0x080c, 0x5f81, 0x2079,
-	0x0240, 0x7833, 0x1104, 0x7837, 0x0000, 0x080c, 0x5ffd, 0x080c,
-	0x5fe0, 0x11b8, 0x7084, 0x9005, 0x11a0, 0x7164, 0x9186, 0xffff,
-	0x0180, 0x9180, 0x3327, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011,
-	0x0008, 0x080c, 0x5e39, 0x0180, 0x080c, 0x4fea, 0x0110, 0x080c,
-	0x28a9, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
-	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5eb6,
-	0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500, 0x2011, 0x5e8c,
-	0x080c, 0x84dc, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5ffd, 0x2079,
-	0x0260, 0x7a30, 0x9296, 0x1104, 0x1178, 0x7834, 0x9005, 0x1160,
-	0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001,
-	0x709b, 0x0008, 0x0029, 0x0010, 0x080c, 0x5fd9, 0x00fe, 0x0005,
-	0x00f6, 0x709b, 0x0009, 0x080c, 0x5f81, 0x2079, 0x0240, 0x7833,
-	0x1105, 0x7837, 0x0100, 0x080c, 0x5fe0, 0x1150, 0x7084, 0x9005,
-	0x1138, 0x080c, 0x5dac, 0x1188, 0x9085, 0x0001, 0x080c, 0x28a9,
-	0x20a9, 0x0008, 0x080c, 0x5ffd, 0x20e1, 0x0000, 0x2099, 0x026e,
-	0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c,
-	0x5eb6, 0x0010, 0x080c, 0x5906, 0x00fe, 0x0005, 0x00f6, 0x7090,
-	0x9005, 0x05a8, 0x2011, 0x5e8c, 0x080c, 0x84dc, 0x9086, 0x0014,
-	0x1560, 0x080c, 0x5ffd, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1105,
-	0x1520, 0x7834, 0x9084, 0x0100, 0x2011, 0x0100, 0x921e, 0x1160,
-	0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001,
-	0x709b, 0x000a, 0x00b1, 0x0098, 0x9005, 0x1178, 0x7a38, 0xd2fc,
-	0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x7097, 0x0000,
-	0x709b, 0x000e, 0x080c, 0x5b54, 0x0010, 0x080c, 0x5fd9, 0x00fe,
-	0x0005, 0x00f6, 0x709b, 0x000b, 0x2011, 0x1c0e, 0x20e9, 0x0001,
-	0x22a0, 0x20a9, 0x0040, 0x2019, 0xffff, 0x4304, 0x080c, 0x5f81,
-	0x2079, 0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x5fe0,
-	0x0118, 0x2013, 0x0000, 0x0020, 0x7060, 0x9085, 0x0100, 0x2012,
-	0x20a9, 0x0040, 0x2009, 0x024e, 0x2011, 0x1c0e, 0x220e, 0x8210,
-	0x8108, 0x9186, 0x0260, 0x1128, 0x6810, 0x8000, 0x6812, 0x2009,
-	0x0240, 0x1f04, 0x5ad6, 0x60c3, 0x0084, 0x080c, 0x5eb6, 0x00fe,
-	0x0005, 0x00f6, 0x7090, 0x9005, 0x01c0, 0x2011, 0x5e8c, 0x080c,
-	0x84dc, 0x9086, 0x0084, 0x1178, 0x080c, 0x5ffd, 0x2079, 0x0260,
-	0x7a30, 0x9296, 0x1106, 0x1138, 0x7834, 0x9005, 0x1120, 0x709b,
-	0x000c, 0x0029, 0x0010, 0x080c, 0x5fd9, 0x00fe, 0x0005, 0x00f6,
-	0x709b, 0x000d, 0x080c, 0x5f81, 0x2079, 0x0240, 0x7833, 0x1107,
-	0x7837, 0x0000, 0x080c, 0x5ffd, 0x20a9, 0x0040, 0x2011, 0x026e,
-	0x2009, 0x024e, 0x220e, 0x8210, 0x8108, 0x9186, 0x0260, 0x1150,
-	0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x6814, 0x8000, 0x6816,
-	0x2011, 0x0260, 0x1f04, 0x5b1a, 0x60c3, 0x0084, 0x080c, 0x5eb6,
-	0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x01e0, 0x2011, 0x5e8c,
-	0x080c, 0x84dc, 0x9086, 0x0084, 0x1198, 0x080c, 0x5ffd, 0x2079,
-	0x0260, 0x7a30, 0x9296, 0x1107, 0x1158, 0x7834, 0x9005, 0x1140,
-	0x7097, 0x0001, 0x080c, 0x5f53, 0x709b, 0x000e, 0x0029, 0x0010,
-	0x080c, 0x5fd9, 0x00fe, 0x0005, 0x918d, 0x0001, 0x080c, 0x6028,
-	0x709b, 0x000f, 0x7093, 0x0000, 0x2061, 0x0140, 0x605b, 0xbc85,
-	0x605f, 0xb5b5, 0x2061, 0x0100, 0x6043, 0x0005, 0x6043, 0x0004,
-	0x2009, 0x07d0, 0x2011, 0x5e8c, 0x080c, 0x84d0, 0x0005, 0x7090,
-	0x9005, 0x0130, 0x2011, 0x5e8c, 0x080c, 0x84dc, 0x709b, 0x0000,
-	0x0005, 0x709b, 0x0011, 0x080c, 0xab2c, 0x080c, 0x5ffd, 0x20e1,
-	0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x7490,
-	0x9480, 0x0018, 0x9080, 0x0007, 0x9084, 0x03f8, 0x8004, 0x20a8,
-	0x4003, 0x080c, 0x5fe0, 0x11a0, 0x717c, 0x81ff, 0x0188, 0x900e,
-	0x7080, 0x9084, 0x00ff, 0x0160, 0x080c, 0x2840, 0x9186, 0x007e,
-	0x0138, 0x9186, 0x0080, 0x0120, 0x2011, 0x0008, 0x080c, 0x5e39,
-	0x60c3, 0x0014, 0x080c, 0x5eb6, 0x0005, 0x00f6, 0x7090, 0x9005,
-	0x0500, 0x2011, 0x5e8c, 0x080c, 0x84dc, 0x9086, 0x0014, 0x11b8,
-	0x080c, 0x5ffd, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178,
-	0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005,
-	0x1110, 0x70c7, 0x0001, 0x709b, 0x0012, 0x0029, 0x0010, 0x7093,
-	0x0000, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0013, 0x080c, 0x5f8f,
-	0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000, 0x080c, 0x5ffd,
-	0x080c, 0x5fe0, 0x1170, 0x7084, 0x9005, 0x1158, 0x715c, 0x9186,
-	0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5e39, 0x0168, 0x080c,
-	0x5fb6, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
-	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5eb6,
-	0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500, 0x2011, 0x5e8c,
-	0x080c, 0x84dc, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5ffd, 0x2079,
-	0x0260, 0x7a30, 0x9296, 0x1104, 0x1178, 0x7834, 0x9005, 0x1160,
+	0x70c7, 0x0001, 0x709b, 0x0008, 0x0029, 0x0010, 0x080c, 0x5fe3,
+	0x00fe, 0x0005, 0x00f6, 0x709b, 0x0009, 0x080c, 0x5f8b, 0x2079,
+	0x0240, 0x7833, 0x1105, 0x7837, 0x0100, 0x080c, 0x5fea, 0x1150,
+	0x7084, 0x9005, 0x1138, 0x080c, 0x5db6, 0x1188, 0x9085, 0x0001,
+	0x080c, 0x28b4, 0x20a9, 0x0008, 0x080c, 0x6007, 0x20e1, 0x0000,
+	0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3,
+	0x0014, 0x080c, 0x5ec0, 0x0010, 0x080c, 0x5910, 0x00fe, 0x0005,
+	0x00f6, 0x7090, 0x9005, 0x05a8, 0x2011, 0x5e96, 0x080c, 0x84f9,
+	0x9086, 0x0014, 0x1560, 0x080c, 0x6007, 0x2079, 0x0260, 0x7a30,
+	0x9296, 0x1105, 0x1520, 0x7834, 0x9084, 0x0100, 0x2011, 0x0100,
+	0x921e, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110,
+	0x70c7, 0x0001, 0x709b, 0x000a, 0x00b1, 0x0098, 0x9005, 0x1178,
 	0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001,
-	0x709b, 0x0014, 0x0029, 0x0010, 0x7093, 0x0000, 0x00fe, 0x0005,
-	0x00f6, 0x709b, 0x0015, 0x080c, 0x5f8f, 0x2079, 0x0240, 0x7833,
-	0x1104, 0x7837, 0x0000, 0x080c, 0x5ffd, 0x080c, 0x5fe0, 0x11b8,
-	0x7084, 0x9005, 0x11a0, 0x7164, 0x9186, 0xffff, 0x0180, 0x9180,
-	0x3327, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011, 0x0008, 0x080c,
-	0x5e39, 0x0180, 0x080c, 0x4fea, 0x0110, 0x080c, 0x28a9, 0x20a9,
-	0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1,
-	0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5eb6, 0x00fe, 0x0005,
-	0x00f6, 0x7090, 0x9005, 0x05f0, 0x2011, 0x5e8c, 0x080c, 0x84dc,
-	0x9086, 0x0014, 0x15a8, 0x080c, 0x5ffd, 0x2079, 0x0260, 0x7a30,
-	0x9296, 0x1105, 0x1568, 0x7834, 0x9084, 0x0100, 0x2011, 0x0100,
-	0x921e, 0x1168, 0x9085, 0x0001, 0x080c, 0x6028, 0x7a38, 0xd2fc,
-	0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x0080, 0x9005,
-	0x11b8, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7,
-	0x0001, 0x9085, 0x0001, 0x080c, 0x6028, 0x7097, 0x0000, 0x7a38,
-	0xd2f4, 0x0110, 0x70df, 0x0008, 0x709b, 0x0016, 0x0029, 0x0010,
-	0x7093, 0x0000, 0x00fe, 0x0005, 0x080c, 0xab2c, 0x080c, 0x5ffd,
-	0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240,
-	0x20a9, 0x000e, 0x4003, 0x2011, 0x026d, 0x2204, 0x9084, 0x0100,
-	0x2011, 0x024d, 0x2012, 0x2011, 0x026e, 0x709b, 0x0017, 0x080c,
-	0x5fe0, 0x1150, 0x7084, 0x9005, 0x1138, 0x080c, 0x5dac, 0x1188,
-	0x9085, 0x0001, 0x080c, 0x28a9, 0x20a9, 0x0008, 0x080c, 0x5ffd,
-	0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e,
-	0x4003, 0x60c3, 0x0014, 0x080c, 0x5eb6, 0x0010, 0x080c, 0x5906,
-	0x0005, 0x00f6, 0x7090, 0x9005, 0x01d8, 0x2011, 0x5e8c, 0x080c,
-	0x84dc, 0x9086, 0x0084, 0x1190, 0x080c, 0x5ffd, 0x2079, 0x0260,
-	0x7a30, 0x9296, 0x1106, 0x1150, 0x7834, 0x9005, 0x1138, 0x9006,
-	0x080c, 0x6028, 0x709b, 0x0018, 0x0029, 0x0010, 0x7093, 0x0000,
-	0x00fe, 0x0005, 0x00f6, 0x709b, 0x0019, 0x080c, 0x5f8f, 0x2079,
-	0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x5ffd, 0x2009,
-	0x026e, 0x2039, 0x1c0e, 0x20a9, 0x0040, 0x213e, 0x8738, 0x8108,
-	0x9186, 0x0280, 0x1128, 0x6814, 0x8000, 0x6816, 0x2009, 0x0260,
-	0x1f04, 0x5d15, 0x2039, 0x1c0e, 0x080c, 0x5fe0, 0x11e8, 0x2728,
-	0x2514, 0x8207, 0x9084, 0x00ff, 0x8000, 0x2018, 0x9294, 0x00ff,
-	0x8007, 0x9205, 0x202a, 0x7060, 0x2310, 0x8214, 0x92a0, 0x1c0e,
-	0x2414, 0x938c, 0x0001, 0x0118, 0x9294, 0xff00, 0x0018, 0x9294,
-	0x00ff, 0x8007, 0x9215, 0x2222, 0x20a9, 0x0040, 0x2009, 0x024e,
-	0x270e, 0x8738, 0x8108, 0x9186, 0x0260, 0x1128, 0x6810, 0x8000,
-	0x6812, 0x2009, 0x0240, 0x1f04, 0x5d48, 0x60c3, 0x0084, 0x080c,
-	0x5eb6, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x01e0, 0x2011,
-	0x5e8c, 0x080c, 0x84dc, 0x9086, 0x0084, 0x1198, 0x080c, 0x5ffd,
-	0x2079, 0x0260, 0x7a30, 0x9296, 0x1107, 0x1158, 0x7834, 0x9005,
-	0x1140, 0x7097, 0x0001, 0x080c, 0x5f53, 0x709b, 0x001a, 0x0029,
-	0x0010, 0x7093, 0x0000, 0x00fe, 0x0005, 0x9085, 0x0001, 0x080c,
-	0x6028, 0x709b, 0x001b, 0x080c, 0xab2c, 0x080c, 0x5ffd, 0x2011,
-	0x0260, 0x2009, 0x0240, 0x7490, 0x9480, 0x0018, 0x9080, 0x0007,
-	0x9084, 0x03f8, 0x8004, 0x20a8, 0x220e, 0x8210, 0x8108, 0x9186,
+	0x7097, 0x0000, 0x709b, 0x000e, 0x080c, 0x5b5e, 0x0010, 0x080c,
+	0x5fe3, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x000b, 0x2011, 0x1c0e,
+	0x20e9, 0x0001, 0x22a0, 0x20a9, 0x0040, 0x2019, 0xffff, 0x4304,
+	0x080c, 0x5f8b, 0x2079, 0x0240, 0x7833, 0x1106, 0x7837, 0x0000,
+	0x080c, 0x5fea, 0x0118, 0x2013, 0x0000, 0x0020, 0x7060, 0x9085,
+	0x0100, 0x2012, 0x20a9, 0x0040, 0x2009, 0x024e, 0x2011, 0x1c0e,
+	0x220e, 0x8210, 0x8108, 0x9186, 0x0260, 0x1128, 0x6810, 0x8000,
+	0x6812, 0x2009, 0x0240, 0x1f04, 0x5ae0, 0x60c3, 0x0084, 0x080c,
+	0x5ec0, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x01c0, 0x2011,
+	0x5e96, 0x080c, 0x84f9, 0x9086, 0x0084, 0x1178, 0x080c, 0x6007,
+	0x2079, 0x0260, 0x7a30, 0x9296, 0x1106, 0x1138, 0x7834, 0x9005,
+	0x1120, 0x709b, 0x000c, 0x0029, 0x0010, 0x080c, 0x5fe3, 0x00fe,
+	0x0005, 0x00f6, 0x709b, 0x000d, 0x080c, 0x5f8b, 0x2079, 0x0240,
+	0x7833, 0x1107, 0x7837, 0x0000, 0x080c, 0x6007, 0x20a9, 0x0040,
+	0x2011, 0x026e, 0x2009, 0x024e, 0x220e, 0x8210, 0x8108, 0x9186,
 	0x0260, 0x1150, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x6814,
-	0x8000, 0x6816, 0x2011, 0x0260, 0x1f04, 0x5d94, 0x60c3, 0x0084,
-	0x080c, 0x5eb6, 0x0005, 0x0005, 0x0086, 0x0096, 0x2029, 0x1848,
-	0x252c, 0x20a9, 0x0008, 0x2041, 0x1c0e, 0x20e9, 0x0001, 0x28a0,
-	0x080c, 0x5ffd, 0x20e1, 0x0000, 0x2099, 0x026e, 0x4003, 0x20a9,
-	0x0008, 0x2011, 0x0007, 0xd5d4, 0x0108, 0x9016, 0x2800, 0x9200,
-	0x200c, 0x91a6, 0xffff, 0x1148, 0xd5d4, 0x0110, 0x8210, 0x0008,
-	0x8211, 0x1f04, 0x5dc6, 0x0804, 0x5e35, 0x82ff, 0x1160, 0xd5d4,
-	0x0120, 0x91a6, 0x3fff, 0x0d90, 0x0020, 0x91a6, 0x3fff, 0x0904,
-	0x5e35, 0x918d, 0xc000, 0x20a9, 0x0010, 0x2019, 0x0001, 0xd5d4,
-	0x0110, 0x2019, 0x0010, 0x2120, 0xd5d4, 0x0110, 0x8423, 0x0008,
-	0x8424, 0x1240, 0xd5d4, 0x0110, 0x8319, 0x0008, 0x8318, 0x1f04,
-	0x5dec, 0x04d8, 0x23a8, 0x2021, 0x0001, 0x8426, 0x8425, 0x1f04,
-	0x5dfe, 0x2328, 0x8529, 0x92be, 0x0007, 0x0158, 0x0006, 0x2039,
-	0x0007, 0x2200, 0x973a, 0x000e, 0x27a8, 0x95a8, 0x0010, 0x1f04,
-	0x5e0d, 0x755e, 0x95c8, 0x3327, 0x292d, 0x95ac, 0x00ff, 0x7582,
-	0x6532, 0x6536, 0x0016, 0x2508, 0x080c, 0x2889, 0x001e, 0x60e7,
-	0x0000, 0x65ea, 0x2018, 0x2304, 0x9405, 0x201a, 0x7087, 0x0001,
-	0x20e9, 0x0000, 0x20a1, 0x024e, 0x20e1, 0x0001, 0x2898, 0x20a9,
-	0x0008, 0x4003, 0x9085, 0x0001, 0x0008, 0x9006, 0x009e, 0x008e,
-	0x0005, 0x0156, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x22a8, 0x20e1,
-	0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x2011, 0x024e, 0x22a0,
-	0x4003, 0x014e, 0x013e, 0x01de, 0x01ce, 0x015e, 0x2118, 0x9026,
-	0x2001, 0x0007, 0x939a, 0x0010, 0x0218, 0x8420, 0x8001, 0x0cd0,
-	0x2118, 0x84ff, 0x0120, 0x939a, 0x0010, 0x8421, 0x1de0, 0x2021,
-	0x0001, 0x83ff, 0x0118, 0x8423, 0x8319, 0x1de8, 0x9238, 0x2029,
-	0x026e, 0x9528, 0x2504, 0x942c, 0x11b8, 0x9405, 0x203a, 0x715e,
-	0x91a0, 0x3327, 0x242d, 0x95ac, 0x00ff, 0x7582, 0x6532, 0x6536,
-	0x0016, 0x2508, 0x080c, 0x2889, 0x001e, 0x60e7, 0x0000, 0x65ea,
-	0x7087, 0x0001, 0x9084, 0x0000, 0x0005, 0x00e6, 0x2071, 0x1800,
-	0x708b, 0x0000, 0x00ee, 0x0005, 0x00e6, 0x00f6, 0x2079, 0x0100,
-	0x2071, 0x0140, 0x080c, 0x5f42, 0x080c, 0xa274, 0x7004, 0x9084,
-	0x4000, 0x0110, 0x080c, 0x2d01, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x1826, 0x2073, 0x0000, 0x7840, 0x0026, 0x0016, 0x2009, 0x00f7,
-	0x080c, 0x5f9f, 0x001e, 0x9094, 0x0010, 0x9285, 0x0080, 0x7842,
-	0x7a42, 0x002e, 0x012e, 0x00fe, 0x00ee, 0x0005, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x2ba7, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5,
-	0x2012, 0x2011, 0x19f0, 0x2013, 0x0000, 0x7093, 0x0000, 0x012e,
-	0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0xa26b, 0x6144, 0xd184,
-	0x0120, 0x7198, 0x918d, 0x2000, 0x0018, 0x718c, 0x918d, 0x1000,
-	0x2011, 0x1998, 0x2112, 0x2009, 0x07d0, 0x2011, 0x5e8c, 0x080c,
-	0x8574, 0x0005, 0x0016, 0x0026, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0xade2, 0x2009, 0x00f7, 0x080c, 0x5f9f, 0x2061, 0x19f9,
-	0x900e, 0x611a, 0x611e, 0x6172, 0x6176, 0x2061, 0x1800, 0x6003,
-	0x0001, 0x2061, 0x0100, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009,
-	0x1998, 0x200b, 0x0000, 0x2009, 0x002d, 0x2011, 0x5f0e, 0x080c,
-	0x84d0, 0x012e, 0x00ce, 0x002e, 0x001e, 0x0005, 0x00e6, 0x0006,
-	0x0126, 0x2091, 0x8000, 0x0471, 0x2071, 0x0100, 0x080c, 0xa274,
-	0x2071, 0x0140, 0x7004, 0x9084, 0x4000, 0x0110, 0x080c, 0x2d01,
-	0x080c, 0x73ad, 0x0188, 0x080c, 0x73c8, 0x1170, 0x080c, 0x7697,
-	0x0016, 0x080c, 0x2958, 0x2001, 0x196c, 0x2102, 0x001e, 0x080c,
-	0x7692, 0x080c, 0x72d7, 0x0050, 0x2009, 0x0001, 0x080c, 0x2c40,
-	0x2001, 0x0001, 0x080c, 0x27ec, 0x080c, 0x5ee2, 0x012e, 0x000e,
-	0x00ee, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0bc, 0x0158, 0x0026,
-	0x0036, 0x2011, 0x8017, 0x2001, 0x1998, 0x201c, 0x080c, 0x4b14,
-	0x003e, 0x002e, 0x0005, 0x20a9, 0x0012, 0x20e9, 0x0001, 0x20a1,
-	0x1c80, 0x080c, 0x5ffd, 0x20e9, 0x0000, 0x2099, 0x026e, 0x0099,
-	0x20a9, 0x0020, 0x080c, 0x5ff7, 0x2099, 0x0260, 0x20a1, 0x1c92,
-	0x0051, 0x20a9, 0x000e, 0x080c, 0x5ffa, 0x2099, 0x0260, 0x20a1,
-	0x1cb2, 0x0009, 0x0005, 0x0016, 0x0026, 0x3410, 0x3308, 0x2104,
-	0x8007, 0x2012, 0x8108, 0x8210, 0x1f04, 0x5f77, 0x002e, 0x001e,
-	0x0005, 0x080c, 0xab2c, 0x20e1, 0x0001, 0x2099, 0x1c00, 0x20e9,
-	0x0000, 0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003, 0x0005, 0x080c,
-	0xab2c, 0x080c, 0x5ffd, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9,
-	0x0000, 0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003, 0x0005, 0x00c6,
-	0x0006, 0x2061, 0x0100, 0x810f, 0x2001, 0x1834, 0x2004, 0x9005,
-	0x1138, 0x2001, 0x1818, 0x2004, 0x9084, 0x00ff, 0x9105, 0x0010,
-	0x9185, 0x00f7, 0x604a, 0x000e, 0x00ce, 0x0005, 0x0016, 0x0046,
-	0x080c, 0x6977, 0x0158, 0x9006, 0x2020, 0x2009, 0x002a, 0x080c,
-	0xe5cf, 0x2001, 0x180c, 0x200c, 0xc195, 0x2102, 0x2019, 0x002a,
-	0x900e, 0x080c, 0x318c, 0x080c, 0xd24a, 0x0140, 0x0036, 0x2019,
-	0xffff, 0x2021, 0x0007, 0x080c, 0x4ccb, 0x003e, 0x004e, 0x001e,
-	0x0005, 0x080c, 0x5ee2, 0x709b, 0x0000, 0x7093, 0x0000, 0x0005,
-	0x0006, 0x2001, 0x180c, 0x2004, 0xd09c, 0x0100, 0x000e, 0x0005,
-	0x0006, 0x0016, 0x0126, 0x2091, 0x8000, 0x2001, 0x0101, 0x200c,
-	0x918d, 0x0006, 0x2102, 0x012e, 0x001e, 0x000e, 0x0005, 0x2009,
-	0x0001, 0x0020, 0x2009, 0x0002, 0x0008, 0x900e, 0x6814, 0x9084,
-	0xffc0, 0x910d, 0x6916, 0x0005, 0x00f6, 0x0156, 0x0146, 0x01d6,
-	0x9006, 0x20a9, 0x0080, 0x20e9, 0x0001, 0x20a1, 0x1c00, 0x4004,
-	0x2079, 0x1c00, 0x7803, 0x2200, 0x7807, 0x00ef, 0x780f, 0x00ef,
-	0x7813, 0x0138, 0x7823, 0xffff, 0x7827, 0xffff, 0x01de, 0x014e,
-	0x015e, 0x00fe, 0x0005, 0x2001, 0x1800, 0x2003, 0x0001, 0x0005,
-	0x2001, 0x19a5, 0x0118, 0x2003, 0x0001, 0x0010, 0x2003, 0x0000,
-	0x0005, 0x0156, 0x20a9, 0x0800, 0x2009, 0x1000, 0x9006, 0x200a,
-	0x8108, 0x1f04, 0x6037, 0x015e, 0x0005, 0x00d6, 0x0036, 0x0156,
-	0x0136, 0x0146, 0x2069, 0x1847, 0x9006, 0xb802, 0xb8ce, 0xb807,
-	0x0707, 0xb80a, 0xb80e, 0xb812, 0x9198, 0x3327, 0x231d, 0x939c,
-	0x00ff, 0xbb16, 0x0016, 0x0026, 0xb8c2, 0x080c, 0xaddb, 0x1120,
-	0x9192, 0x007e, 0x1208, 0xbbc2, 0x20a9, 0x0004, 0xb8c4, 0x20e8,
-	0xb9c8, 0x9198, 0x0006, 0x9006, 0x23a0, 0x4004, 0x20a9, 0x0004,
-	0x9198, 0x000a, 0x23a0, 0x4004, 0x002e, 0x001e, 0xb83e, 0xb842,
-	0xb84e, 0xb852, 0xb856, 0xb85a, 0xb85e, 0xb862, 0xb866, 0xb86a,
-	0xb86f, 0x0100, 0xb872, 0xb876, 0xb87a, 0xb88a, 0xb88e, 0xb893,
-	0x0008, 0xb896, 0xb89a, 0xb89e, 0xb8be, 0xb9a2, 0x0096, 0xb8a4,
-	0x904d, 0x0110, 0x080c, 0x1031, 0xb8a7, 0x0000, 0x009e, 0x9006,
-	0xb84a, 0x6810, 0xb83a, 0x680c, 0xb846, 0xb8bb, 0x0520, 0xb8ac,
-	0x9005, 0x0198, 0x00c6, 0x2060, 0x9c82, 0x1cd0, 0x0a0c, 0x0dd5,
-	0x2001, 0x181a, 0x2004, 0x9c02, 0x1a0c, 0x0dd5, 0x080c, 0x896a,
-	0x00ce, 0x090c, 0x8d0e, 0xb8af, 0x0000, 0x6814, 0x9084, 0x00ff,
-	0xb842, 0x014e, 0x013e, 0x015e, 0x003e, 0x00de, 0x0005, 0x0126,
-	0x2091, 0x8000, 0xa974, 0xae78, 0x9684, 0x3fff, 0x9082, 0x4000,
-	0x1a04, 0x6125, 0x9182, 0x0800, 0x1a04, 0x6129, 0x2001, 0x180c,
-	0x2004, 0x9084, 0x0003, 0x1904, 0x612f, 0x9188, 0x1000, 0x2104,
-	0x905d, 0x0518, 0xb804, 0x9084, 0x00ff, 0x908e, 0x0006, 0x1508,
-	0xb8a4, 0x900d, 0x1904, 0x6141, 0xb850, 0x900d, 0x1148, 0xa802,
-	0x2900, 0xb852, 0xb84e, 0x080c, 0x90f6, 0x9006, 0x012e, 0x0005,
-	0x00a6, 0x2150, 0x2900, 0xb002, 0xa803, 0x0000, 0x00ae, 0xb852,
-	0x0c90, 0x2001, 0x0005, 0x900e, 0x04b8, 0x2001, 0x0028, 0x900e,
-	0x0498, 0x9082, 0x0006, 0x1290, 0x080c, 0xaddb, 0x1160, 0xb8a0,
-	0x9084, 0xff80, 0x1140, 0xb900, 0xd1fc, 0x0990, 0x2001, 0x0029,
-	0x2009, 0x1000, 0x0408, 0x2001, 0x0028, 0x00a8, 0x2009, 0x180c,
-	0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0068, 0xd184, 0x0118,
-	0x2001, 0x0004, 0x0040, 0x2001, 0x0029, 0xb900, 0xd1fc, 0x0118,
-	0x2009, 0x1000, 0x0048, 0x900e, 0x0038, 0x2001, 0x0029, 0x900e,
-	0x0018, 0x2001, 0x0029, 0x900e, 0x9005, 0x012e, 0x0005, 0x2001,
-	0x180c, 0x2004, 0xd084, 0x19d0, 0x9188, 0x1000, 0x2104, 0x905d,
-	0x09a8, 0x080c, 0x697b, 0x1990, 0xb800, 0xd0bc, 0x0978, 0x0804,
-	0x60d8, 0x080c, 0x67a4, 0x0904, 0x60f1, 0x0804, 0x60dc, 0x00b6,
-	0x00e6, 0x0126, 0x2091, 0x8000, 0xa874, 0x908e, 0x00ff, 0x1120,
-	0x2001, 0x196a, 0x205c, 0x0060, 0xa974, 0x9182, 0x0800, 0x1690,
-	0x9188, 0x1000, 0x2104, 0x905d, 0x01d0, 0x080c, 0x691b, 0x11d0,
-	0x080c, 0xae1b, 0x0570, 0x2b00, 0x6012, 0x2900, 0x6016, 0x6023,
-	0x0009, 0x600b, 0x0000, 0xa874, 0x908e, 0x00ff, 0x1110, 0x600b,
-	0x8000, 0x2009, 0x0043, 0x080c, 0xaeec, 0x9006, 0x00b0, 0x2001,
-	0x0028, 0x0090, 0x2009, 0x180c, 0x210c, 0xd18c, 0x0118, 0x2001,
-	0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004, 0x0010, 0x2001,
-	0x0029, 0x0010, 0x2001, 0x0029, 0x9005, 0x012e, 0x00ee, 0x00be,
-	0x0005, 0x2001, 0x002c, 0x0cc0, 0x00b6, 0x00e6, 0x0126, 0x2091,
-	0x8000, 0xa974, 0x9182, 0x0800, 0x1a04, 0x620f, 0x9188, 0x1000,
-	0x2104, 0x905d, 0x0904, 0x61e7, 0xb8a0, 0x9086, 0x007f, 0x0178,
-	0x080c, 0x6983, 0x0160, 0xa994, 0x81ff, 0x0130, 0x908e, 0x0004,
-	0x0130, 0x908e, 0x0005, 0x0118, 0x080c, 0x697b, 0x1598, 0xa87c,
-	0xd0fc, 0x01e0, 0xa894, 0x9005, 0x01c8, 0x2060, 0x0026, 0x2010,
-	0x080c, 0xcb38, 0x002e, 0x1120, 0x2001, 0x0008, 0x0804, 0x6211,
-	0x6020, 0x9086, 0x000a, 0x0120, 0x2001, 0x0008, 0x0804, 0x6211,
-	0x601a, 0x6003, 0x0008, 0x2900, 0x6016, 0x0058, 0x080c, 0xae1b,
-	0x05e8, 0x2b00, 0x6012, 0x2900, 0x6016, 0x600b, 0xffff, 0x6023,
-	0x000a, 0x2009, 0x0003, 0x080c, 0xaeec, 0x9006, 0x0458, 0x2001,
-	0x0028, 0x0438, 0x9082, 0x0006, 0x1290, 0x080c, 0xaddb, 0x1160,
-	0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900, 0xd1fc, 0x0900, 0x2001,
-	0x0029, 0x2009, 0x1000, 0x00a8, 0x2001, 0x0028, 0x0090, 0x2009,
-	0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0050, 0xd184,
-	0x0118, 0x2001, 0x0004, 0x0028, 0x2001, 0x0029, 0x0010, 0x2001,
-	0x0029, 0x9005, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2001, 0x002c,
-	0x0cc0, 0x00f6, 0x00b6, 0x0126, 0x2091, 0x8000, 0xa8e0, 0x9005,
-	0x1550, 0xa8dc, 0x9082, 0x0101, 0x1630, 0xa8c8, 0x9005, 0x1518,
-	0xa8c4, 0x9082, 0x0101, 0x12f8, 0xa974, 0x2079, 0x1800, 0x9182,
-	0x0800, 0x12e8, 0x7830, 0x9084, 0x0003, 0x1130, 0xaa98, 0xab94,
-	0xa878, 0x9084, 0x0007, 0x00ea, 0x7930, 0xd18c, 0x0118, 0x2001,
-	0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004, 0x0010, 0x2001,
-	0x0029, 0x900e, 0x0038, 0x2001, 0x002c, 0x900e, 0x0018, 0x2001,
-	0x0029, 0x900e, 0x9006, 0x0008, 0x9005, 0x012e, 0x00be, 0x00fe,
-	0x0005, 0x62a6, 0x6261, 0x6278, 0x62a6, 0x62a6, 0x62a6, 0x62a6,
-	0x62a6, 0x2100, 0x9082, 0x007e, 0x1278, 0x080c, 0x65a7, 0x0148,
-	0x9046, 0xb810, 0x9306, 0x1904, 0x62ae, 0xb814, 0x9206, 0x15f0,
-	0x0028, 0xbb12, 0xba16, 0x0010, 0x080c, 0x49c7, 0x0150, 0x04b0,
-	0x080c, 0x6608, 0x1598, 0xb810, 0x9306, 0x1580, 0xb814, 0x9206,
-	0x1568, 0x080c, 0xae1b, 0x0530, 0x2b00, 0x6012, 0x080c, 0xcfc4,
-	0x2900, 0x6016, 0x600b, 0xffff, 0x6023, 0x000a, 0xa878, 0x9086,
-	0x0001, 0x1170, 0x080c, 0x31c1, 0x9006, 0x080c, 0x6544, 0x2001,
-	0x0002, 0x080c, 0x6558, 0x2001, 0x0200, 0xb86e, 0xb893, 0x0002,
-	0x2009, 0x0003, 0x080c, 0xaeec, 0x9006, 0x0068, 0x2001, 0x0001,
-	0x900e, 0x0038, 0x2001, 0x002c, 0x900e, 0x0018, 0x2001, 0x0028,
-	0x900e, 0x9005, 0x0000, 0x012e, 0x00be, 0x00fe, 0x0005, 0x00b6,
-	0x00f6, 0x00e6, 0x0126, 0x2091, 0x8000, 0xa894, 0x90c6, 0x0015,
-	0x0904, 0x6495, 0x90c6, 0x0056, 0x0904, 0x6499, 0x90c6, 0x0066,
-	0x0904, 0x649d, 0x90c6, 0x0067, 0x0904, 0x64a1, 0x90c6, 0x0068,
-	0x0904, 0x64a5, 0x90c6, 0x0071, 0x0904, 0x64a9, 0x90c6, 0x0074,
-	0x0904, 0x64ad, 0x90c6, 0x007c, 0x0904, 0x64b1, 0x90c6, 0x007e,
-	0x0904, 0x64b5, 0x90c6, 0x0037, 0x0904, 0x64b9, 0x9016, 0x2079,
-	0x1800, 0xa974, 0x9186, 0x00ff, 0x0904, 0x6490, 0x9182, 0x0800,
-	0x1a04, 0x6490, 0x080c, 0x6608, 0x1198, 0xb804, 0x9084, 0x00ff,
-	0x9082, 0x0006, 0x1268, 0xa894, 0x90c6, 0x006f, 0x0148, 0x080c,
-	0xaddb, 0x1904, 0x6479, 0xb8a0, 0x9084, 0xff80, 0x1904, 0x6479,
-	0xa894, 0x90c6, 0x006f, 0x0158, 0x90c6, 0x005e, 0x0904, 0x63d9,
-	0x90c6, 0x0064, 0x0904, 0x6402, 0x2008, 0x0804, 0x639b, 0xa998,
-	0xa8b0, 0x2040, 0x080c, 0xaddb, 0x1120, 0x9182, 0x007f, 0x0a04,
-	0x639b, 0x9186, 0x00ff, 0x0904, 0x639b, 0x9182, 0x0800, 0x1a04,
-	0x639b, 0xaaa0, 0xab9c, 0x787c, 0x9306, 0x1188, 0x7880, 0x0096,
-	0x924e, 0x1128, 0x2208, 0x2310, 0x009e, 0x0804, 0x639b, 0x99cc,
-	0xff00, 0x009e, 0x1120, 0x2208, 0x2310, 0x0804, 0x639b, 0x080c,
-	0x49c7, 0x0904, 0x63a5, 0x900e, 0x9016, 0x90c6, 0x4000, 0x15e0,
-	0x0006, 0x080c, 0x6828, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
-	0xc18d, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031,
-	0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098, 0x080c,
-	0x0f7c, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0035,
-	0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x000a, 0x2098, 0x080c,
-	0x0f7c, 0xa8c4, 0xabc8, 0x9305, 0xabcc, 0x9305, 0xabd0, 0x9305,
-	0xabd4, 0x9305, 0xabd8, 0x9305, 0xabdc, 0x9305, 0xabe0, 0x9305,
-	0x9005, 0x0510, 0x000e, 0x00c8, 0x90c6, 0x4007, 0x1110, 0x2408,
-	0x00a0, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0070, 0x90c6,
-	0x4009, 0x1108, 0x0050, 0x90c6, 0x4006, 0x0138, 0x2001, 0x4005,
-	0x2009, 0x000a, 0x0010, 0x2001, 0x4006, 0xa896, 0xa99a, 0xaa9e,
-	0x2001, 0x0030, 0x900e, 0x0478, 0x000e, 0x080c, 0xae1b, 0x1130,
-	0x2001, 0x4005, 0x2009, 0x0003, 0x9016, 0x0c78, 0x2b00, 0x6012,
-	0x080c, 0xcfc4, 0x2900, 0x6016, 0x6023, 0x0001, 0xa868, 0xd88c,
-	0x0108, 0xc0f5, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c, 0x31c1,
-	0x012e, 0x9006, 0x080c, 0x6544, 0x2001, 0x0002, 0x080c, 0x6558,
-	0x2009, 0x0002, 0x080c, 0xaeec, 0xa8b0, 0xd094, 0x0118, 0xb8cc,
-	0xc08d, 0xb8ce, 0x9006, 0x9005, 0x012e, 0x00ee, 0x00fe, 0x00be,
-	0x0005, 0x080c, 0x56ec, 0x0118, 0x2009, 0x0007, 0x00f8, 0xa998,
-	0xaeb0, 0x080c, 0x6608, 0x1904, 0x6396, 0x9186, 0x007f, 0x0130,
-	0x080c, 0x697b, 0x0118, 0x2009, 0x0009, 0x0080, 0x0096, 0x080c,
-	0x0fff, 0x1120, 0x009e, 0x2009, 0x0002, 0x0040, 0x2900, 0x009e,
-	0xa806, 0x080c, 0xcd30, 0x19b0, 0x2009, 0x0003, 0x2001, 0x4005,
-	0x0804, 0x639d, 0xa998, 0xaeb0, 0x080c, 0x6608, 0x1904, 0x6396,
-	0x0096, 0x080c, 0x0fff, 0x1128, 0x009e, 0x2009, 0x0002, 0x0804,
-	0x6456, 0x2900, 0x009e, 0xa806, 0x0096, 0x2048, 0x20a9, 0x002b,
-	0xb8c4, 0x20e0, 0xb8c8, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080,
-	0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0,
-	0xbbc8, 0x9398, 0x0006, 0x2398, 0x080c, 0x0f7c, 0x009e, 0xa87b,
-	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xd684, 0x1168, 0x080c,
-	0x56d8, 0xd0b4, 0x1118, 0xa89b, 0x000b, 0x00e0, 0xb800, 0xd08c,
-	0x0118, 0xa89b, 0x000c, 0x00b0, 0x080c, 0x697b, 0x0118, 0xa89b,
-	0x0009, 0x0080, 0x080c, 0x56ec, 0x0118, 0xa89b, 0x0007, 0x0050,
-	0x080c, 0xcd13, 0x1904, 0x63d2, 0x2009, 0x0003, 0x2001, 0x4005,
-	0x0804, 0x639d, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa804, 0x8006,
-	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002,
-	0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000,
-	0x2041, 0x1243, 0x080c, 0xb38b, 0x1904, 0x63d2, 0x2009, 0x0002,
-	0x08e8, 0x2001, 0x0028, 0x900e, 0x0804, 0x63d3, 0x2009, 0x180c,
-	0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118,
-	0x2001, 0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0804, 0x63d3,
-	0x2001, 0x0029, 0x900e, 0x0804, 0x63d3, 0x080c, 0x3756, 0x0804,
-	0x63d4, 0x080c, 0x5415, 0x0804, 0x63d4, 0x080c, 0x4554, 0x0804,
-	0x63d4, 0x080c, 0x45cd, 0x0804, 0x63d4, 0x080c, 0x4629, 0x0804,
-	0x63d4, 0x080c, 0x4a8a, 0x0804, 0x63d4, 0x080c, 0x4d3a, 0x0804,
-	0x63d4, 0x080c, 0x5080, 0x0804, 0x63d4, 0x080c, 0x5279, 0x0804,
-	0x63d4, 0x080c, 0x396c, 0x0804, 0x63d4, 0x00b6, 0xa974, 0xae78,
-	0x9684, 0x3fff, 0x9082, 0x4000, 0x1618, 0x9182, 0x0800, 0x1268,
-	0x9188, 0x1000, 0x2104, 0x905d, 0x0140, 0x080c, 0x697b, 0x1148,
-	0x00e9, 0x080c, 0x6733, 0x9006, 0x00b0, 0x2001, 0x0028, 0x900e,
-	0x0090, 0x9082, 0x0006, 0x1240, 0xb900, 0xd1fc, 0x0d88, 0x2001,
-	0x0029, 0x2009, 0x1000, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018,
-	0x2001, 0x0029, 0x900e, 0x9005, 0x00be, 0x0005, 0x0126, 0x2091,
-	0x8000, 0xb850, 0x900d, 0x0150, 0x2900, 0x0096, 0x2148, 0xa802,
-	0x009e, 0xa803, 0x0000, 0xb852, 0x012e, 0x0005, 0x2900, 0xb852,
-	0xb84e, 0xa803, 0x0000, 0x0cc0, 0x0126, 0x2091, 0x8000, 0xb84c,
-	0x9005, 0x0170, 0x00e6, 0x2071, 0x19e6, 0x7004, 0x9086, 0x0002,
-	0x0168, 0x00ee, 0xb84c, 0xa802, 0x2900, 0xb84e, 0x012e, 0x0005,
-	0x2900, 0xb852, 0xb84e, 0xa803, 0x0000, 0x0cc0, 0x701c, 0x9b06,
-	0x1d80, 0xb84c, 0x00a6, 0x2050, 0xb000, 0xa802, 0x2900, 0xb002,
-	0x00ae, 0x00ee, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0xb84c,
-	0x904d, 0x0130, 0xa800, 0x9005, 0x1108, 0xb852, 0xb84e, 0x9905,
-	0x012e, 0x0005, 0xb84c, 0x904d, 0x0130, 0xa800, 0x9005, 0x1108,
-	0xb852, 0xb84e, 0x9905, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x0026,
-	0x2091, 0x8000, 0x6210, 0x2258, 0xba00, 0x9005, 0x0110, 0xc285,
-	0x0008, 0xc284, 0xba02, 0x002e, 0x00ce, 0x012e, 0x00be, 0x0005,
-	0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x6210, 0x2258, 0xba04,
-	0x0006, 0x9086, 0x0006, 0x1170, 0xb89c, 0xd0ac, 0x0158, 0x080c,
-	0x6977, 0x0140, 0x9284, 0xff00, 0x8007, 0x9086, 0x0007, 0x1110,
-	0x2011, 0x0600, 0x000e, 0x9294, 0xff00, 0x9215, 0xba06, 0x0006,
-	0x9086, 0x0006, 0x1120, 0xba90, 0x82ff, 0x090c, 0x0dd5, 0x000e,
-	0x00ce, 0x012e, 0x00be, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x2091,
-	0x8000, 0x6210, 0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1168,
-	0xb89c, 0xd0a4, 0x0150, 0x080c, 0x6973, 0x1138, 0x9284, 0x00ff,
-	0x9086, 0x0007, 0x1110, 0x2011, 0x0006, 0x000e, 0x9294, 0x00ff,
-	0x8007, 0x9215, 0xba06, 0x00ce, 0x012e, 0x00be, 0x0005, 0x9182,
-	0x0800, 0x0218, 0x9085, 0x0001, 0x0005, 0x00d6, 0x0026, 0x9190,
-	0x1000, 0x2204, 0x905d, 0x1188, 0x0096, 0x080c, 0x0fff, 0x2958,
-	0x009e, 0x0168, 0x2b00, 0x2012, 0xb85c, 0xb8ca, 0xb860, 0xb8c6,
-	0x9006, 0xb8a6, 0xb8ae, 0x080c, 0x603d, 0x9006, 0x0010, 0x9085,
-	0x0001, 0x002e, 0x00de, 0x0005, 0x00b6, 0x0096, 0x0126, 0x2091,
-	0x8000, 0x0026, 0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0458,
-	0x00d6, 0x9190, 0x1000, 0x2204, 0x905d, 0x0518, 0x2013, 0x0000,
-	0xb8a4, 0x904d, 0x0110, 0x080c, 0x1031, 0x00d6, 0x00c6, 0xb8bc,
-	0x2060, 0x8cff, 0x0168, 0x600c, 0x0006, 0x6014, 0x2048, 0x080c,
-	0xcb4a, 0x0110, 0x080c, 0x0fb1, 0x080c, 0xae71, 0x00ce, 0x0c88,
-	0x00ce, 0x00de, 0x2b48, 0xb8c8, 0xb85e, 0xb8c4, 0xb862, 0x080c,
-	0x1041, 0x00de, 0x9006, 0x002e, 0x012e, 0x009e, 0x00be, 0x0005,
-	0x0016, 0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0030, 0x9188,
-	0x1000, 0x2104, 0x905d, 0x0dc0, 0x9006, 0x001e, 0x0005, 0x00d6,
-	0x0156, 0x0136, 0x0146, 0x9006, 0xb80a, 0xb80e, 0xb800, 0xc08c,
-	0xb802, 0x080c, 0x73a5, 0x1510, 0xb8a0, 0x9086, 0x007e, 0x0120,
-	0x080c, 0xaddb, 0x11d8, 0x0078, 0x7040, 0xd0e4, 0x01b8, 0x00c6,
-	0x2061, 0x1981, 0x7048, 0x2062, 0x704c, 0x6006, 0x7050, 0x600a,
-	0x7054, 0x600e, 0x00ce, 0x703c, 0x2069, 0x0140, 0x9005, 0x1110,
-	0x2001, 0x0001, 0x6886, 0x2069, 0x1800, 0x68b6, 0x7040, 0xb85e,
-	0x7048, 0xb862, 0x704c, 0xb866, 0x20e1, 0x0000, 0x2099, 0x0276,
-	0xb8c4, 0x20e8, 0xb8c8, 0x9088, 0x000a, 0x21a0, 0x20a9, 0x0004,
-	0x4003, 0x2099, 0x027a, 0x9088, 0x0006, 0x21a0, 0x20a9, 0x0004,
-	0x4003, 0x2069, 0x0200, 0x6817, 0x0001, 0x7040, 0xb86a, 0x7144,
-	0xb96e, 0x7048, 0xb872, 0x7050, 0xb876, 0x2069, 0x0200, 0x6817,
-	0x0000, 0xb8a0, 0x9086, 0x007e, 0x1110, 0x7144, 0xb96e, 0x9182,
-	0x0211, 0x1218, 0x2009, 0x0008, 0x0400, 0x9182, 0x0259, 0x1218,
-	0x2009, 0x0007, 0x00d0, 0x9182, 0x02c1, 0x1218, 0x2009, 0x0006,
-	0x00a0, 0x9182, 0x0349, 0x1218, 0x2009, 0x0005, 0x0070, 0x9182,
-	0x0421, 0x1218, 0x2009, 0x0004, 0x0040, 0x9182, 0x0581, 0x1218,
-	0x2009, 0x0003, 0x0010, 0x2009, 0x0002, 0xb992, 0x014e, 0x013e,
-	0x015e, 0x00de, 0x0005, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260,
-	0x7034, 0xb896, 0x703c, 0xb89a, 0x7054, 0xb89e, 0x0036, 0xbbcc,
-	0xc384, 0xba00, 0x2009, 0x1867, 0x210c, 0xd0bc, 0x0120, 0xd1ec,
-	0x0110, 0xc2ad, 0x0008, 0xc2ac, 0xd0c4, 0x0148, 0xd1e4, 0x0138,
-	0xc2bd, 0xd0cc, 0x0128, 0xd38c, 0x1108, 0xc385, 0x0008, 0xc2bc,
-	0xba02, 0xbbce, 0x003e, 0x00ee, 0x002e, 0x001e, 0x0005, 0x0096,
-	0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d, 0x0578, 0xa900, 0x81ff,
-	0x15c0, 0xaa04, 0x9282, 0x0010, 0x16c8, 0x0136, 0x0146, 0x01c6,
-	0x01d6, 0x8906, 0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084,
-	0xffc0, 0x9080, 0x0004, 0x2098, 0x2009, 0x0010, 0x20a9, 0x0001,
-	0x4002, 0x9086, 0xffff, 0x0120, 0x8109, 0x1dd0, 0x080c, 0x0dd5,
-	0x3c00, 0x20e8, 0x3300, 0x8001, 0x20a0, 0x4604, 0x8210, 0xaa06,
-	0x01de, 0x01ce, 0x014e, 0x013e, 0x0060, 0x080c, 0x0fff, 0x0170,
-	0x2900, 0xb8a6, 0xa803, 0x0000, 0x080c, 0x67c4, 0xa807, 0x0001,
-	0xae12, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8,
-	0x0126, 0x2091, 0x8000, 0x0096, 0xb8a4, 0x904d, 0x0188, 0xa800,
-	0x9005, 0x1150, 0x080c, 0x67d3, 0x1158, 0xa804, 0x908a, 0x0002,
-	0x0218, 0x8001, 0xa806, 0x0020, 0x080c, 0x1031, 0xb8a7, 0x0000,
-	0x009e, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x90f6,
-	0x012e, 0x0005, 0x901e, 0x0010, 0x2019, 0x0001, 0x900e, 0x0126,
-	0x2091, 0x8000, 0xb84c, 0x2048, 0xb800, 0xd0dc, 0x1170, 0x89ff,
-	0x0500, 0x83ff, 0x0120, 0xa878, 0x9606, 0x0158, 0x0030, 0xa86c,
-	0x9406, 0x1118, 0xa870, 0x9506, 0x0120, 0x2908, 0xa800, 0x2048,
-	0x0c70, 0x080c, 0xa693, 0xaa00, 0xb84c, 0x9906, 0x1110, 0xba4e,
-	0x0020, 0x00a6, 0x2150, 0xb202, 0x00ae, 0x82ff, 0x1110, 0xb952,
-	0x89ff, 0x012e, 0x0005, 0x9016, 0x0489, 0x1110, 0x2011, 0x0001,
-	0x0005, 0x080c, 0x6828, 0x0128, 0x080c, 0xcc07, 0x0010, 0x9085,
-	0x0001, 0x0005, 0x080c, 0x6828, 0x0128, 0x080c, 0xcbac, 0x0010,
-	0x9085, 0x0001, 0x0005, 0x080c, 0x6828, 0x0128, 0x080c, 0xcc04,
-	0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6828, 0x0128, 0x080c,
-	0xcbcb, 0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6828, 0x0128,
-	0x080c, 0xcc48, 0x0010, 0x9085, 0x0001, 0x0005, 0xb8a4, 0x900d,
-	0x1118, 0x9085, 0x0001, 0x0005, 0x0136, 0x01c6, 0xa800, 0x9005,
-	0x11b8, 0x890e, 0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184,
-	0xffc0, 0x9080, 0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010,
-	0x4002, 0x9606, 0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0008,
-	0x9006, 0x01ce, 0x013e, 0x0005, 0x0146, 0x01d6, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0004, 0x20a0, 0x20a9, 0x0010, 0x2009, 0xffff,
-	0x4104, 0x01de, 0x014e, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8,
-	0x890e, 0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0,
-	0x9080, 0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002,
-	0x9606, 0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0068, 0x0146,
-	0x01d6, 0x3300, 0x8001, 0x20a0, 0x3c00, 0x20e8, 0x2001, 0xffff,
-	0x4004, 0x01de, 0x014e, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0096,
-	0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d, 0x1128, 0x080c, 0x0fff,
-	0x0168, 0x2900, 0xb8a6, 0x080c, 0x67c4, 0xa803, 0x0001, 0xa807,
-	0x0000, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8,
-	0x0096, 0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d, 0x0130, 0xb8a7,
-	0x0000, 0x080c, 0x1031, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005,
-	0xb89c, 0xd0a4, 0x0005, 0x00b6, 0x00f6, 0x080c, 0x73a5, 0x01b0,
-	0x71c4, 0x81ff, 0x1198, 0x71dc, 0xd19c, 0x0180, 0x2001, 0x007e,
-	0x9080, 0x1000, 0x2004, 0x905d, 0x0148, 0xb804, 0x9084, 0x00ff,
-	0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x2079, 0x1847,
-	0x7804, 0xd0a4, 0x01d0, 0x0156, 0x20a9, 0x007f, 0x900e, 0x0016,
-	0x080c, 0x6608, 0x1168, 0xb804, 0x9084, 0xff00, 0x8007, 0x9096,
-	0x0004, 0x0118, 0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802,
-	0x001e, 0x8108, 0x1f04, 0x684f, 0x015e, 0x080c, 0x6939, 0x0120,
-	0x2001, 0x1984, 0x200c, 0x0038, 0x2079, 0x1847, 0x7804, 0xd0a4,
-	0x0130, 0x2009, 0x07d0, 0x2011, 0x687a, 0x080c, 0x8574, 0x00fe,
-	0x00be, 0x0005, 0x00b6, 0x2011, 0x687a, 0x080c, 0x84dc, 0x080c,
-	0x6939, 0x01d8, 0x2001, 0x107e, 0x2004, 0x2058, 0xb900, 0xc1ec,
-	0xb902, 0x080c, 0x6977, 0x0130, 0x2009, 0x07d0, 0x2011, 0x687a,
-	0x080c, 0x8574, 0x00e6, 0x2071, 0x1800, 0x9006, 0x707e, 0x7060,
-	0x7082, 0x080c, 0x2f98, 0x00ee, 0x04b0, 0x0156, 0x00c6, 0x20a9,
-	0x007f, 0x900e, 0x0016, 0x080c, 0x6608, 0x1538, 0xb800, 0xd0ec,
-	0x0520, 0x0046, 0xbaa0, 0x2220, 0x9006, 0x2009, 0x0029, 0x080c,
-	0xe5cf, 0xb800, 0xc0e5, 0xc0ec, 0xb802, 0x080c, 0x6973, 0x2001,
-	0x0707, 0x1128, 0xb804, 0x9084, 0x00ff, 0x9085, 0x0700, 0xb806,
-	0x2019, 0x0029, 0x080c, 0x927e, 0x0076, 0x903e, 0x080c, 0x9151,
-	0x900e, 0x080c, 0xe30c, 0x007e, 0x004e, 0x001e, 0x8108, 0x1f04,
-	0x68a2, 0x00ce, 0x015e, 0x00be, 0x0005, 0x00b6, 0x6010, 0x2058,
-	0xb800, 0xc0ec, 0xb802, 0x00be, 0x0005, 0x00b6, 0x00c6, 0x0096,
-	0x080c, 0x1018, 0x090c, 0x0dd5, 0x2958, 0x009e, 0x2001, 0x196a,
-	0x2b02, 0x8b07, 0x8006, 0x8006, 0x908c, 0x003f, 0xb9c6, 0x908c,
-	0xffc0, 0xb9ca, 0xb8af, 0x0000, 0x2009, 0x00ff, 0x080c, 0x603d,
-	0xb807, 0x0006, 0xb813, 0x00ff, 0xb817, 0xffff, 0xb86f, 0x0200,
-	0xb86c, 0xb893, 0x0002, 0xb8bb, 0x0520, 0xb8a3, 0x00ff, 0xb8af,
-	0x0000, 0x00ce, 0x00be, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0ac, 0x0005, 0x6010, 0x00b6, 0x905d, 0x0108, 0xb800,
-	0x00be, 0xd0bc, 0x0005, 0x0006, 0x0016, 0x0026, 0xb804, 0x908c,
-	0x00ff, 0x9196, 0x0006, 0x0188, 0x9196, 0x0004, 0x0170, 0x9196,
-	0x0005, 0x0158, 0x908c, 0xff00, 0x810f, 0x9196, 0x0006, 0x0128,
-	0x9196, 0x0004, 0x0110, 0x9196, 0x0005, 0x002e, 0x001e, 0x000e,
-	0x0005, 0x00b6, 0x00f6, 0x2001, 0x107e, 0x2004, 0x905d, 0x0110,
-	0xb800, 0xd0ec, 0x00fe, 0x00be, 0x0005, 0x0126, 0x0026, 0x2091,
-	0x8000, 0x0006, 0xbaa0, 0x9290, 0x1000, 0x2204, 0x9b06, 0x190c,
-	0x0dd5, 0x000e, 0xba00, 0x9005, 0x0110, 0xc2fd, 0x0008, 0xc2fc,
-	0xba02, 0x002e, 0x012e, 0x0005, 0x2011, 0x1837, 0x2204, 0xd0cc,
-	0x0138, 0x2001, 0x1982, 0x200c, 0x2011, 0x6969, 0x080c, 0x8574,
-	0x0005, 0x2011, 0x6969, 0x080c, 0x84dc, 0x2011, 0x1837, 0x2204,
-	0xc0cc, 0x2012, 0x0005, 0x080c, 0x56d8, 0xd0ac, 0x0005, 0x080c,
-	0x56d8, 0xd0a4, 0x0005, 0x0016, 0xb904, 0x9184, 0x00ff, 0x908e,
-	0x0006, 0x001e, 0x0005, 0x0016, 0xb904, 0x9184, 0xff00, 0x8007,
-	0x908e, 0x0006, 0x001e, 0x0005, 0x00b6, 0x00f6, 0x080c, 0xd24a,
-	0x0158, 0x70dc, 0x9084, 0x0028, 0x0138, 0x2001, 0x107f, 0x2004,
-	0x905d, 0x0110, 0xb8cc, 0xd094, 0x00fe, 0x00be, 0x0005, 0x2071,
-	0x1910, 0x7003, 0x0001, 0x7007, 0x0000, 0x9006, 0x7012, 0x7016,
-	0x701a, 0x701e, 0x700a, 0x7046, 0x0005, 0x0016, 0x00e6, 0x2071,
-	0x1947, 0x900e, 0x710a, 0x080c, 0x56d8, 0xd0fc, 0x1140, 0x080c,
-	0x56d8, 0x900e, 0xd09c, 0x0108, 0x8108, 0x7102, 0x00f8, 0x2001,
-	0x1867, 0x200c, 0x9184, 0x0007, 0x0002, 0x69b7, 0x69b7, 0x69b7,
-	0x69b7, 0x69b7, 0x69cd, 0x69db, 0x69b7, 0x7003, 0x0003, 0x2009,
-	0x1868, 0x210c, 0x9184, 0xff00, 0x8007, 0x9005, 0x1110, 0x2001,
-	0x0002, 0x7006, 0x0018, 0x7003, 0x0005, 0x0c88, 0x00ee, 0x001e,
-	0x0005, 0x00e6, 0x2071, 0x0050, 0x684c, 0x9005, 0x1150, 0x00e6,
-	0x2071, 0x1910, 0x7028, 0xc085, 0x702a, 0x00ee, 0x9085, 0x0001,
-	0x0488, 0x6844, 0x9005, 0x0158, 0x080c, 0x76ff, 0x6a60, 0x9200,
-	0x7002, 0x6864, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6860,
-	0x7002, 0x6864, 0x7006, 0x6868, 0x700a, 0x686c, 0x700e, 0x6844,
-	0x9005, 0x1110, 0x7012, 0x7016, 0x684c, 0x701a, 0x701c, 0x9085,
-	0x0040, 0x701e, 0x7037, 0x0019, 0x702b, 0x0001, 0x00e6, 0x2071,
-	0x1910, 0x7028, 0xc084, 0x702a, 0x7007, 0x0001, 0x700b, 0x0000,
-	0x00ee, 0x9006, 0x00ee, 0x0005, 0x00e6, 0x0026, 0x2071, 0x1947,
-	0x7000, 0x9015, 0x0904, 0x6c8b, 0x9286, 0x0003, 0x0904, 0x6b21,
-	0x9286, 0x0005, 0x0904, 0x6b21, 0x2071, 0x1877, 0xa87c, 0x9005,
-	0x0904, 0x6a82, 0x7140, 0xa868, 0x9102, 0x0a04, 0x6c8b, 0xa878,
-	0xd084, 0x15d8, 0xa853, 0x0019, 0x2001, 0x8023, 0xa84e, 0x2071,
-	0x1910, 0x701c, 0x9005, 0x1904, 0x6e21, 0x0e04, 0x6e8f, 0x2071,
-	0x0000, 0xa850, 0x7032, 0xa84c, 0x7082, 0xa870, 0x7086, 0xa86c,
-	0x708a, 0xa880, 0x708e, 0x7036, 0x0146, 0x01d6, 0x0136, 0x01c6,
-	0x0156, 0x20e9, 0x0000, 0x20a1, 0x002a, 0xa868, 0x20a8, 0xa860,
-	0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098, 0x4003, 0x015e, 0x01ce,
-	0x013e, 0x01de, 0x014e, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
-	0xd084, 0x190c, 0x119b, 0x0804, 0x6b04, 0xa853, 0x001b, 0x2001,
-	0x8027, 0x0820, 0x7004, 0xd08c, 0x1904, 0x6c8b, 0xa853, 0x001a,
-	0x2001, 0x8024, 0x0804, 0x6a46, 0x00e6, 0x0026, 0x2071, 0x1947,
-	0x7000, 0x9015, 0x0904, 0x6c8b, 0x9286, 0x0003, 0x0904, 0x6b21,
-	0x9286, 0x0005, 0x0904, 0x6b21, 0xa84f, 0x8022, 0xa853, 0x0018,
-	0x0804, 0x6ae9, 0xa868, 0xd0fc, 0x11d8, 0x00e6, 0x0026, 0x2001,
-	0x1947, 0x2004, 0x9005, 0x0904, 0x6c8b, 0xa87c, 0xd0bc, 0x1904,
-	0x6c8b, 0xa978, 0xa874, 0x9105, 0x1904, 0x6c8b, 0x2001, 0x1947,
-	0x2004, 0x0002, 0x6c8b, 0x6ae5, 0x6b21, 0x6b21, 0x6c8b, 0x6b21,
-	0x0005, 0xa868, 0xd0fc, 0x1500, 0x00e6, 0x0026, 0x2009, 0x1947,
-	0x210c, 0x81ff, 0x0904, 0x6c8b, 0xa87c, 0xd0cc, 0x0904, 0x6c8b,
-	0xa880, 0x9084, 0x00ff, 0x9086, 0x0001, 0x1904, 0x6c8b, 0x9186,
-	0x0003, 0x0904, 0x6b21, 0x9186, 0x0005, 0x0904, 0x6b21, 0xa84f,
-	0x8021, 0xa853, 0x0017, 0x0028, 0x0005, 0xa84f, 0x8020, 0xa853,
-	0x0016, 0x2071, 0x1910, 0x701c, 0x9005, 0x1904, 0x6e21, 0x0e04,
-	0x6e8f, 0x2071, 0x0000, 0xa84c, 0x7082, 0xa850, 0x7032, 0xa86c,
-	0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x190c, 0x119b, 0x2071, 0x1800, 0x2011, 0x0001,
-	0xa804, 0x900d, 0x702c, 0x1158, 0xa802, 0x2900, 0x702e, 0x70c0,
-	0x9200, 0x70c2, 0x080c, 0x83fd, 0x002e, 0x00ee, 0x0005, 0x0096,
-	0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x009e,
-	0x0c58, 0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050, 0x2071, 0x1910,
-	0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x6c10, 0x782c, 0x908c,
-	0x0780, 0x190c, 0x6fdb, 0x8004, 0x8004, 0x8004, 0x9084, 0x0003,
-	0x0002, 0x6b3f, 0x6c10, 0x6b64, 0x6bab, 0x080c, 0x0dd5, 0x2071,
-	0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1170, 0x2071, 0x19f9,
-	0x703c, 0x9005, 0x1328, 0x2001, 0x1948, 0x2004, 0x8005, 0x703e,
-	0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904,
-	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200,
-	0x70c2, 0x080c, 0x83fd, 0x0c10, 0x2071, 0x1800, 0x2900, 0x7822,
-	0xa804, 0x900d, 0x1580, 0x7824, 0x00e6, 0x2071, 0x0040, 0x712c,
-	0xd19c, 0x1148, 0x2009, 0x1830, 0x210c, 0x918a, 0x0020, 0x0218,
-	0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900,
-	0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x83fd, 0x782c, 0x9094,
-	0x0780, 0x190c, 0x6fdb, 0xd0a4, 0x19f0, 0x2071, 0x19f9, 0x703c,
+	0x8000, 0x6816, 0x2011, 0x0260, 0x1f04, 0x5b24, 0x60c3, 0x0084,
+	0x080c, 0x5ec0, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x01e0,
+	0x2011, 0x5e96, 0x080c, 0x84f9, 0x9086, 0x0084, 0x1198, 0x080c,
+	0x6007, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1107, 0x1158, 0x7834,
+	0x9005, 0x1140, 0x7097, 0x0001, 0x080c, 0x5f5d, 0x709b, 0x000e,
+	0x0029, 0x0010, 0x080c, 0x5fe3, 0x00fe, 0x0005, 0x918d, 0x0001,
+	0x080c, 0x6032, 0x709b, 0x000f, 0x7093, 0x0000, 0x2061, 0x0140,
+	0x605b, 0xbc85, 0x605f, 0xb5b5, 0x2061, 0x0100, 0x6043, 0x0005,
+	0x6043, 0x0004, 0x2009, 0x07d0, 0x2011, 0x5e96, 0x080c, 0x84ed,
+	0x0005, 0x7090, 0x9005, 0x0130, 0x2011, 0x5e96, 0x080c, 0x84f9,
+	0x709b, 0x0000, 0x0005, 0x709b, 0x0011, 0x080c, 0xab1a, 0x080c,
+	0x6007, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1,
+	0x0240, 0x7490, 0x9480, 0x0018, 0x9080, 0x0007, 0x9084, 0x03f8,
+	0x8004, 0x20a8, 0x4003, 0x080c, 0x5fea, 0x11a0, 0x717c, 0x81ff,
+	0x0188, 0x900e, 0x7080, 0x9084, 0x00ff, 0x0160, 0x080c, 0x284b,
+	0x9186, 0x007e, 0x0138, 0x9186, 0x0080, 0x0120, 0x2011, 0x0008,
+	0x080c, 0x5e43, 0x60c3, 0x0014, 0x080c, 0x5ec0, 0x0005, 0x00f6,
+	0x7090, 0x9005, 0x0500, 0x2011, 0x5e96, 0x080c, 0x84f9, 0x9086,
+	0x0014, 0x11b8, 0x080c, 0x6007, 0x2079, 0x0260, 0x7a30, 0x9296,
+	0x1103, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128,
+	0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x709b, 0x0012, 0x0029,
+	0x0010, 0x7093, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0013,
+	0x080c, 0x5f99, 0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000,
+	0x080c, 0x6007, 0x080c, 0x5fea, 0x1170, 0x7084, 0x9005, 0x1158,
+	0x715c, 0x9186, 0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5e43,
+	0x0168, 0x080c, 0x5fc0, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099,
+	0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014,
+	0x080c, 0x5ec0, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500,
+	0x2011, 0x5e96, 0x080c, 0x84f9, 0x9086, 0x0014, 0x11b8, 0x080c,
+	0x6007, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1104, 0x1178, 0x7834,
+	0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110,
+	0x70c7, 0x0001, 0x709b, 0x0014, 0x0029, 0x0010, 0x7093, 0x0000,
+	0x00fe, 0x0005, 0x00f6, 0x709b, 0x0015, 0x080c, 0x5f99, 0x2079,
+	0x0240, 0x7833, 0x1104, 0x7837, 0x0000, 0x080c, 0x6007, 0x080c,
+	0x5fea, 0x11b8, 0x7084, 0x9005, 0x11a0, 0x7164, 0x9186, 0xffff,
+	0x0180, 0x9180, 0x3332, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011,
+	0x0008, 0x080c, 0x5e43, 0x0180, 0x080c, 0x4ff4, 0x0110, 0x080c,
+	0x28b4, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
+	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5ec0,
+	0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x05f0, 0x2011, 0x5e96,
+	0x080c, 0x84f9, 0x9086, 0x0014, 0x15a8, 0x080c, 0x6007, 0x2079,
+	0x0260, 0x7a30, 0x9296, 0x1105, 0x1568, 0x7834, 0x9084, 0x0100,
+	0x2011, 0x0100, 0x921e, 0x1168, 0x9085, 0x0001, 0x080c, 0x6032,
+	0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001,
+	0x0080, 0x9005, 0x11b8, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005,
+	0x1110, 0x70c7, 0x0001, 0x9085, 0x0001, 0x080c, 0x6032, 0x7097,
+	0x0000, 0x7a38, 0xd2f4, 0x0110, 0x70df, 0x0008, 0x709b, 0x0016,
+	0x0029, 0x0010, 0x7093, 0x0000, 0x00fe, 0x0005, 0x080c, 0xab1a,
+	0x080c, 0x6007, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0000,
+	0x20a1, 0x0240, 0x20a9, 0x000e, 0x4003, 0x2011, 0x026d, 0x2204,
+	0x9084, 0x0100, 0x2011, 0x024d, 0x2012, 0x2011, 0x026e, 0x709b,
+	0x0017, 0x080c, 0x5fea, 0x1150, 0x7084, 0x9005, 0x1138, 0x080c,
+	0x5db6, 0x1188, 0x9085, 0x0001, 0x080c, 0x28b4, 0x20a9, 0x0008,
+	0x080c, 0x6007, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000,
+	0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5ec0, 0x0010,
+	0x080c, 0x5910, 0x0005, 0x00f6, 0x7090, 0x9005, 0x01d8, 0x2011,
+	0x5e96, 0x080c, 0x84f9, 0x9086, 0x0084, 0x1190, 0x080c, 0x6007,
+	0x2079, 0x0260, 0x7a30, 0x9296, 0x1106, 0x1150, 0x7834, 0x9005,
+	0x1138, 0x9006, 0x080c, 0x6032, 0x709b, 0x0018, 0x0029, 0x0010,
+	0x7093, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0019, 0x080c,
+	0x5f99, 0x2079, 0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c,
+	0x6007, 0x2009, 0x026e, 0x2039, 0x1c0e, 0x20a9, 0x0040, 0x213e,
+	0x8738, 0x8108, 0x9186, 0x0280, 0x1128, 0x6814, 0x8000, 0x6816,
+	0x2009, 0x0260, 0x1f04, 0x5d1f, 0x2039, 0x1c0e, 0x080c, 0x5fea,
+	0x11e8, 0x2728, 0x2514, 0x8207, 0x9084, 0x00ff, 0x8000, 0x2018,
+	0x9294, 0x00ff, 0x8007, 0x9205, 0x202a, 0x7060, 0x2310, 0x8214,
+	0x92a0, 0x1c0e, 0x2414, 0x938c, 0x0001, 0x0118, 0x9294, 0xff00,
+	0x0018, 0x9294, 0x00ff, 0x8007, 0x9215, 0x2222, 0x20a9, 0x0040,
+	0x2009, 0x024e, 0x270e, 0x8738, 0x8108, 0x9186, 0x0260, 0x1128,
+	0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x1f04, 0x5d52, 0x60c3,
+	0x0084, 0x080c, 0x5ec0, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005,
+	0x01e0, 0x2011, 0x5e96, 0x080c, 0x84f9, 0x9086, 0x0084, 0x1198,
+	0x080c, 0x6007, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1107, 0x1158,
+	0x7834, 0x9005, 0x1140, 0x7097, 0x0001, 0x080c, 0x5f5d, 0x709b,
+	0x001a, 0x0029, 0x0010, 0x7093, 0x0000, 0x00fe, 0x0005, 0x9085,
+	0x0001, 0x080c, 0x6032, 0x709b, 0x001b, 0x080c, 0xab1a, 0x080c,
+	0x6007, 0x2011, 0x0260, 0x2009, 0x0240, 0x7490, 0x9480, 0x0018,
+	0x9080, 0x0007, 0x9084, 0x03f8, 0x8004, 0x20a8, 0x220e, 0x8210,
+	0x8108, 0x9186, 0x0260, 0x1150, 0x6810, 0x8000, 0x6812, 0x2009,
+	0x0240, 0x6814, 0x8000, 0x6816, 0x2011, 0x0260, 0x1f04, 0x5d9e,
+	0x60c3, 0x0084, 0x080c, 0x5ec0, 0x0005, 0x0005, 0x0086, 0x0096,
+	0x2029, 0x1848, 0x252c, 0x20a9, 0x0008, 0x2041, 0x1c0e, 0x20e9,
+	0x0001, 0x28a0, 0x080c, 0x6007, 0x20e1, 0x0000, 0x2099, 0x026e,
+	0x4003, 0x20a9, 0x0008, 0x2011, 0x0007, 0xd5d4, 0x0108, 0x9016,
+	0x2800, 0x9200, 0x200c, 0x91a6, 0xffff, 0x1148, 0xd5d4, 0x0110,
+	0x8210, 0x0008, 0x8211, 0x1f04, 0x5dd0, 0x0804, 0x5e3f, 0x82ff,
+	0x1160, 0xd5d4, 0x0120, 0x91a6, 0x3fff, 0x0d90, 0x0020, 0x91a6,
+	0x3fff, 0x0904, 0x5e3f, 0x918d, 0xc000, 0x20a9, 0x0010, 0x2019,
+	0x0001, 0xd5d4, 0x0110, 0x2019, 0x0010, 0x2120, 0xd5d4, 0x0110,
+	0x8423, 0x0008, 0x8424, 0x1240, 0xd5d4, 0x0110, 0x8319, 0x0008,
+	0x8318, 0x1f04, 0x5df6, 0x04d8, 0x23a8, 0x2021, 0x0001, 0x8426,
+	0x8425, 0x1f04, 0x5e08, 0x2328, 0x8529, 0x92be, 0x0007, 0x0158,
+	0x0006, 0x2039, 0x0007, 0x2200, 0x973a, 0x000e, 0x27a8, 0x95a8,
+	0x0010, 0x1f04, 0x5e17, 0x755e, 0x95c8, 0x3332, 0x292d, 0x95ac,
+	0x00ff, 0x7582, 0x6532, 0x6536, 0x0016, 0x2508, 0x080c, 0x2894,
+	0x001e, 0x60e7, 0x0000, 0x65ea, 0x2018, 0x2304, 0x9405, 0x201a,
+	0x7087, 0x0001, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x20e1, 0x0001,
+	0x2898, 0x20a9, 0x0008, 0x4003, 0x9085, 0x0001, 0x0008, 0x9006,
+	0x009e, 0x008e, 0x0005, 0x0156, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x22a8, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x2011,
+	0x024e, 0x22a0, 0x4003, 0x014e, 0x013e, 0x01de, 0x01ce, 0x015e,
+	0x2118, 0x9026, 0x2001, 0x0007, 0x939a, 0x0010, 0x0218, 0x8420,
+	0x8001, 0x0cd0, 0x2118, 0x84ff, 0x0120, 0x939a, 0x0010, 0x8421,
+	0x1de0, 0x2021, 0x0001, 0x83ff, 0x0118, 0x8423, 0x8319, 0x1de8,
+	0x9238, 0x2029, 0x026e, 0x9528, 0x2504, 0x942c, 0x11b8, 0x9405,
+	0x203a, 0x715e, 0x91a0, 0x3332, 0x242d, 0x95ac, 0x00ff, 0x7582,
+	0x6532, 0x6536, 0x0016, 0x2508, 0x080c, 0x2894, 0x001e, 0x60e7,
+	0x0000, 0x65ea, 0x7087, 0x0001, 0x9084, 0x0000, 0x0005, 0x00e6,
+	0x2071, 0x1800, 0x708b, 0x0000, 0x00ee, 0x0005, 0x00e6, 0x00f6,
+	0x2079, 0x0100, 0x2071, 0x0140, 0x080c, 0x5f4c, 0x080c, 0xa28f,
+	0x7004, 0x9084, 0x4000, 0x0110, 0x080c, 0x2d0c, 0x0126, 0x2091,
+	0x8000, 0x2071, 0x1826, 0x2073, 0x0000, 0x7840, 0x0026, 0x0016,
+	0x2009, 0x00f7, 0x080c, 0x5fa9, 0x001e, 0x9094, 0x0010, 0x9285,
+	0x0080, 0x7842, 0x7a42, 0x002e, 0x012e, 0x00fe, 0x00ee, 0x0005,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x2bb2, 0x0228, 0x2011, 0x0101,
+	0x2204, 0xc0c5, 0x2012, 0x2011, 0x19f0, 0x2013, 0x0000, 0x7093,
+	0x0000, 0x012e, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0xa286,
+	0x6144, 0xd184, 0x0120, 0x7198, 0x918d, 0x2000, 0x0018, 0x718c,
+	0x918d, 0x1000, 0x2011, 0x1998, 0x2112, 0x2009, 0x07d0, 0x2011,
+	0x5e96, 0x080c, 0x8591, 0x0005, 0x0016, 0x0026, 0x00c6, 0x0126,
+	0x2091, 0x8000, 0x080c, 0xadd0, 0x2009, 0x00f7, 0x080c, 0x5fa9,
+	0x2061, 0x19f9, 0x900e, 0x611a, 0x611e, 0x6172, 0x6176, 0x2061,
+	0x1800, 0x6003, 0x0001, 0x2061, 0x0100, 0x6043, 0x0090, 0x6043,
+	0x0010, 0x2009, 0x1998, 0x200b, 0x0000, 0x2009, 0x002d, 0x2011,
+	0x5f18, 0x080c, 0x84ed, 0x012e, 0x00ce, 0x002e, 0x001e, 0x0005,
+	0x00e6, 0x0006, 0x0126, 0x2091, 0x8000, 0x0471, 0x2071, 0x0100,
+	0x080c, 0xa28f, 0x2071, 0x0140, 0x7004, 0x9084, 0x4000, 0x0110,
+	0x080c, 0x2d0c, 0x080c, 0x73bb, 0x0188, 0x080c, 0x73d6, 0x1170,
+	0x080c, 0x76a3, 0x0016, 0x080c, 0x2963, 0x2001, 0x196c, 0x2102,
+	0x001e, 0x080c, 0x769e, 0x080c, 0x72e5, 0x0050, 0x2009, 0x0001,
+	0x080c, 0x2c4b, 0x2001, 0x0001, 0x080c, 0x27f7, 0x080c, 0x5eec,
+	0x012e, 0x000e, 0x00ee, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0bc,
+	0x0158, 0x0026, 0x0036, 0x2011, 0x8017, 0x2001, 0x1998, 0x201c,
+	0x080c, 0x4b1e, 0x003e, 0x002e, 0x0005, 0x20a9, 0x0012, 0x20e9,
+	0x0001, 0x20a1, 0x1c80, 0x080c, 0x6007, 0x20e9, 0x0000, 0x2099,
+	0x026e, 0x0099, 0x20a9, 0x0020, 0x080c, 0x6001, 0x2099, 0x0260,
+	0x20a1, 0x1c92, 0x0051, 0x20a9, 0x000e, 0x080c, 0x6004, 0x2099,
+	0x0260, 0x20a1, 0x1cb2, 0x0009, 0x0005, 0x0016, 0x0026, 0x3410,
+	0x3308, 0x2104, 0x8007, 0x2012, 0x8108, 0x8210, 0x1f04, 0x5f81,
+	0x002e, 0x001e, 0x0005, 0x080c, 0xab1a, 0x20e1, 0x0001, 0x2099,
+	0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003,
+	0x0005, 0x080c, 0xab1a, 0x080c, 0x6007, 0x20e1, 0x0000, 0x2099,
+	0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003,
+	0x0005, 0x00c6, 0x0006, 0x2061, 0x0100, 0x810f, 0x2001, 0x1834,
+	0x2004, 0x9005, 0x1138, 0x2001, 0x1818, 0x2004, 0x9084, 0x00ff,
+	0x9105, 0x0010, 0x9185, 0x00f7, 0x604a, 0x000e, 0x00ce, 0x0005,
+	0x0016, 0x0046, 0x080c, 0x6985, 0x0158, 0x9006, 0x2020, 0x2009,
+	0x002a, 0x080c, 0xe5e9, 0x2001, 0x180c, 0x200c, 0xc195, 0x2102,
+	0x2019, 0x002a, 0x900e, 0x080c, 0x3197, 0x080c, 0xd25a, 0x0140,
+	0x0036, 0x2019, 0xffff, 0x2021, 0x0007, 0x080c, 0x4cd5, 0x003e,
+	0x004e, 0x001e, 0x0005, 0x080c, 0x5eec, 0x709b, 0x0000, 0x7093,
+	0x0000, 0x0005, 0x0006, 0x2001, 0x180c, 0x2004, 0xd09c, 0x0100,
+	0x000e, 0x0005, 0x0006, 0x0016, 0x0126, 0x2091, 0x8000, 0x2001,
+	0x0101, 0x200c, 0x918d, 0x0006, 0x2102, 0x012e, 0x001e, 0x000e,
+	0x0005, 0x2009, 0x0001, 0x0020, 0x2009, 0x0002, 0x0008, 0x900e,
+	0x6814, 0x9084, 0xffc0, 0x910d, 0x6916, 0x0005, 0x00f6, 0x0156,
+	0x0146, 0x01d6, 0x9006, 0x20a9, 0x0080, 0x20e9, 0x0001, 0x20a1,
+	0x1c00, 0x4004, 0x2079, 0x1c00, 0x7803, 0x2200, 0x7807, 0x00ef,
+	0x780f, 0x00ef, 0x7813, 0x0138, 0x7823, 0xffff, 0x7827, 0xffff,
+	0x01de, 0x014e, 0x015e, 0x00fe, 0x0005, 0x2001, 0x1800, 0x2003,
+	0x0001, 0x0005, 0x2001, 0x19a5, 0x0118, 0x2003, 0x0001, 0x0010,
+	0x2003, 0x0000, 0x0005, 0x0156, 0x20a9, 0x0800, 0x2009, 0x1000,
+	0x9006, 0x200a, 0x8108, 0x1f04, 0x6041, 0x015e, 0x0005, 0x00d6,
+	0x0036, 0x0156, 0x0136, 0x0146, 0x2069, 0x1847, 0x9006, 0xb802,
+	0xb8ce, 0xb807, 0x0707, 0xb80a, 0xb80e, 0xb812, 0x9198, 0x3332,
+	0x231d, 0x939c, 0x00ff, 0xbb16, 0x0016, 0x0026, 0xb8c2, 0x080c,
+	0xadc9, 0x1120, 0x9192, 0x007e, 0x1208, 0xbbc2, 0x20a9, 0x0004,
+	0xb8c4, 0x20e8, 0xb9c8, 0x9198, 0x0006, 0x9006, 0x23a0, 0x4004,
+	0x20a9, 0x0004, 0x9198, 0x000a, 0x23a0, 0x4004, 0x002e, 0x001e,
+	0xb83e, 0xb842, 0xb84e, 0xb852, 0xb856, 0xb85a, 0xb85e, 0xb862,
+	0xb866, 0xb86a, 0xb86f, 0x0100, 0xb872, 0xb876, 0xb87a, 0xb88a,
+	0xb88e, 0xb893, 0x0008, 0xb896, 0xb89a, 0xb89e, 0xb8be, 0xb9a2,
+	0x0096, 0xb8a4, 0x904d, 0x0110, 0x080c, 0x1031, 0xb8a7, 0x0000,
+	0x009e, 0x9006, 0xb84a, 0x6810, 0xb83a, 0x680c, 0xb846, 0xb8bb,
+	0x0520, 0xb8ac, 0x9005, 0x0198, 0x00c6, 0x2060, 0x9c82, 0x1cd0,
+	0x0a0c, 0x0dd5, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1a0c, 0x0dd5,
+	0x080c, 0x8987, 0x00ce, 0x090c, 0x8d2d, 0xb8af, 0x0000, 0x6814,
+	0x9084, 0x00ff, 0xb842, 0x014e, 0x013e, 0x015e, 0x003e, 0x00de,
+	0x0005, 0x0126, 0x2091, 0x8000, 0xa974, 0xae78, 0x9684, 0x3fff,
+	0x9082, 0x4000, 0x1a04, 0x612f, 0x9182, 0x0800, 0x1a04, 0x6133,
+	0x2001, 0x180c, 0x2004, 0x9084, 0x0003, 0x1904, 0x6139, 0x9188,
+	0x1000, 0x2104, 0x905d, 0x0518, 0xb804, 0x9084, 0x00ff, 0x908e,
+	0x0006, 0x1508, 0xb8a4, 0x900d, 0x1904, 0x614b, 0xb850, 0x900d,
+	0x1148, 0xa802, 0x2900, 0xb852, 0xb84e, 0x080c, 0x9115, 0x9006,
+	0x012e, 0x0005, 0x00a6, 0x2150, 0x2900, 0xb002, 0xa803, 0x0000,
+	0x00ae, 0xb852, 0x0c90, 0x2001, 0x0005, 0x900e, 0x04b8, 0x2001,
+	0x0028, 0x900e, 0x0498, 0x9082, 0x0006, 0x1290, 0x080c, 0xadc9,
+	0x1160, 0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900, 0xd1fc, 0x0990,
+	0x2001, 0x0029, 0x2009, 0x1000, 0x0408, 0x2001, 0x0028, 0x00a8,
+	0x2009, 0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0068,
+	0xd184, 0x0118, 0x2001, 0x0004, 0x0040, 0x2001, 0x0029, 0xb900,
+	0xd1fc, 0x0118, 0x2009, 0x1000, 0x0048, 0x900e, 0x0038, 0x2001,
+	0x0029, 0x900e, 0x0018, 0x2001, 0x0029, 0x900e, 0x9005, 0x012e,
+	0x0005, 0x2001, 0x180c, 0x2004, 0xd084, 0x19d0, 0x9188, 0x1000,
+	0x2104, 0x905d, 0x09a8, 0x080c, 0x6989, 0x1990, 0xb800, 0xd0bc,
+	0x0978, 0x0804, 0x60e2, 0x080c, 0x67b2, 0x0904, 0x60fb, 0x0804,
+	0x60e6, 0x00b6, 0x00e6, 0x0126, 0x2091, 0x8000, 0xa874, 0x908e,
+	0x00ff, 0x1120, 0x2001, 0x196a, 0x205c, 0x0060, 0xa974, 0x9182,
+	0x0800, 0x1690, 0x9188, 0x1000, 0x2104, 0x905d, 0x01d0, 0x080c,
+	0x6929, 0x11d0, 0x080c, 0xae09, 0x0570, 0x2b00, 0x6012, 0x2900,
+	0x6016, 0x6023, 0x0009, 0x600b, 0x0000, 0xa874, 0x908e, 0x00ff,
+	0x1110, 0x600b, 0x8000, 0x2009, 0x0043, 0x080c, 0xaeda, 0x9006,
+	0x00b0, 0x2001, 0x0028, 0x0090, 0x2009, 0x180c, 0x210c, 0xd18c,
+	0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004,
+	0x0010, 0x2001, 0x0029, 0x0010, 0x2001, 0x0029, 0x9005, 0x012e,
+	0x00ee, 0x00be, 0x0005, 0x2001, 0x002c, 0x0cc0, 0x00b6, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0xa974, 0x9182, 0x0800, 0x1a04, 0x6219,
+	0x9188, 0x1000, 0x2104, 0x905d, 0x0904, 0x61f1, 0xb8a0, 0x9086,
+	0x007f, 0x0178, 0x080c, 0x6991, 0x0160, 0xa994, 0x81ff, 0x0130,
+	0x908e, 0x0004, 0x0130, 0x908e, 0x0005, 0x0118, 0x080c, 0x6989,
+	0x1598, 0xa87c, 0xd0fc, 0x01e0, 0xa894, 0x9005, 0x01c8, 0x2060,
+	0x0026, 0x2010, 0x080c, 0xcb48, 0x002e, 0x1120, 0x2001, 0x0008,
+	0x0804, 0x621b, 0x6020, 0x9086, 0x000a, 0x0120, 0x2001, 0x0008,
+	0x0804, 0x621b, 0x601a, 0x6003, 0x0008, 0x2900, 0x6016, 0x0058,
+	0x080c, 0xae09, 0x05e8, 0x2b00, 0x6012, 0x2900, 0x6016, 0x600b,
+	0xffff, 0x6023, 0x000a, 0x2009, 0x0003, 0x080c, 0xaeda, 0x9006,
+	0x0458, 0x2001, 0x0028, 0x0438, 0x9082, 0x0006, 0x1290, 0x080c,
+	0xadc9, 0x1160, 0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900, 0xd1fc,
+	0x0900, 0x2001, 0x0029, 0x2009, 0x1000, 0x00a8, 0x2001, 0x0028,
+	0x0090, 0x2009, 0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004,
+	0x0050, 0xd184, 0x0118, 0x2001, 0x0004, 0x0028, 0x2001, 0x0029,
+	0x0010, 0x2001, 0x0029, 0x9005, 0x012e, 0x00ee, 0x00be, 0x0005,
+	0x2001, 0x002c, 0x0cc0, 0x00f6, 0x00b6, 0x0126, 0x2091, 0x8000,
+	0xa8e0, 0x9005, 0x1550, 0xa8dc, 0x9082, 0x0101, 0x1630, 0xa8c8,
+	0x9005, 0x1518, 0xa8c4, 0x9082, 0x0101, 0x12f8, 0xa974, 0x2079,
+	0x1800, 0x9182, 0x0800, 0x12e8, 0x7830, 0x9084, 0x0003, 0x1130,
+	0xaa98, 0xab94, 0xa878, 0x9084, 0x0007, 0x00ea, 0x7930, 0xd18c,
+	0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004,
+	0x0010, 0x2001, 0x0029, 0x900e, 0x0038, 0x2001, 0x002c, 0x900e,
+	0x0018, 0x2001, 0x0029, 0x900e, 0x9006, 0x0008, 0x9005, 0x012e,
+	0x00be, 0x00fe, 0x0005, 0x62b0, 0x626b, 0x6282, 0x62b0, 0x62b0,
+	0x62b0, 0x62b0, 0x62b0, 0x2100, 0x9082, 0x007e, 0x1278, 0x080c,
+	0x65b5, 0x0148, 0x9046, 0xb810, 0x9306, 0x1904, 0x62b8, 0xb814,
+	0x9206, 0x15f0, 0x0028, 0xbb12, 0xba16, 0x0010, 0x080c, 0x49d1,
+	0x0150, 0x04b0, 0x080c, 0x6616, 0x1598, 0xb810, 0x9306, 0x1580,
+	0xb814, 0x9206, 0x1568, 0x080c, 0xae09, 0x0530, 0x2b00, 0x6012,
+	0x080c, 0xcfd4, 0x2900, 0x6016, 0x600b, 0xffff, 0x6023, 0x000a,
+	0xa878, 0x9086, 0x0001, 0x1170, 0x080c, 0x31cc, 0x9006, 0x080c,
+	0x6552, 0x2001, 0x0002, 0x080c, 0x6566, 0x2001, 0x0200, 0xb86e,
+	0xb893, 0x0002, 0x2009, 0x0003, 0x080c, 0xaeda, 0x9006, 0x0068,
+	0x2001, 0x0001, 0x900e, 0x0038, 0x2001, 0x002c, 0x900e, 0x0018,
+	0x2001, 0x0028, 0x900e, 0x9005, 0x0000, 0x012e, 0x00be, 0x00fe,
+	0x0005, 0x00b6, 0x00f6, 0x00e6, 0x0126, 0x2091, 0x8000, 0xa894,
+	0x90c6, 0x0015, 0x0904, 0x64a3, 0x90c6, 0x0056, 0x0904, 0x64a7,
+	0x90c6, 0x0066, 0x0904, 0x64ab, 0x90c6, 0x0067, 0x0904, 0x64af,
+	0x90c6, 0x0068, 0x0904, 0x64b3, 0x90c6, 0x0071, 0x0904, 0x64b7,
+	0x90c6, 0x0074, 0x0904, 0x64bb, 0x90c6, 0x007c, 0x0904, 0x64bf,
+	0x90c6, 0x007e, 0x0904, 0x64c3, 0x90c6, 0x0037, 0x0904, 0x64c7,
+	0x9016, 0x2079, 0x1800, 0xa974, 0x9186, 0x00ff, 0x0904, 0x649e,
+	0x9182, 0x0800, 0x1a04, 0x649e, 0x080c, 0x6616, 0x1198, 0xb804,
+	0x9084, 0x00ff, 0x9082, 0x0006, 0x1268, 0xa894, 0x90c6, 0x006f,
+	0x0148, 0x080c, 0xadc9, 0x1904, 0x6487, 0xb8a0, 0x9084, 0xff80,
+	0x1904, 0x6487, 0xa894, 0x90c6, 0x006f, 0x0158, 0x90c6, 0x005e,
+	0x0904, 0x63e7, 0x90c6, 0x0064, 0x0904, 0x6410, 0x2008, 0x0804,
+	0x63a9, 0xa998, 0xa8b0, 0x2040, 0x080c, 0xadc9, 0x1120, 0x9182,
+	0x007f, 0x0a04, 0x63a9, 0x9186, 0x00ff, 0x0904, 0x63a9, 0x9182,
+	0x0800, 0x1a04, 0x63a9, 0xaaa0, 0xab9c, 0x787c, 0x9306, 0x11a8,
+	0x7880, 0x0096, 0x924e, 0x1128, 0x2208, 0x2310, 0x009e, 0x0804,
+	0x63a9, 0x080c, 0xadc9, 0x1140, 0x99cc, 0xff00, 0x009e, 0x1128,
+	0x2208, 0x2310, 0x0804, 0x63a9, 0x009e, 0x080c, 0x49d1, 0x0904,
+	0x63b3, 0x900e, 0x9016, 0x90c6, 0x4000, 0x15e0, 0x0006, 0x080c,
+	0x6836, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x20a9,
+	0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031, 0x20a0, 0xb8c4,
+	0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098, 0x080c, 0x0f7c, 0x20a9,
+	0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0035, 0x20a0, 0xb8c4,
+	0x20e0, 0xb8c8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0f7c, 0xa8c4,
+	0xabc8, 0x9305, 0xabcc, 0x9305, 0xabd0, 0x9305, 0xabd4, 0x9305,
+	0xabd8, 0x9305, 0xabdc, 0x9305, 0xabe0, 0x9305, 0x9005, 0x0510,
+	0x000e, 0x00c8, 0x90c6, 0x4007, 0x1110, 0x2408, 0x00a0, 0x90c6,
+	0x4008, 0x1118, 0x2708, 0x2610, 0x0070, 0x90c6, 0x4009, 0x1108,
+	0x0050, 0x90c6, 0x4006, 0x0138, 0x2001, 0x4005, 0x2009, 0x000a,
+	0x0010, 0x2001, 0x4006, 0xa896, 0xa99a, 0xaa9e, 0x2001, 0x0030,
+	0x900e, 0x0478, 0x000e, 0x080c, 0xae09, 0x1130, 0x2001, 0x4005,
+	0x2009, 0x0003, 0x9016, 0x0c78, 0x2b00, 0x6012, 0x080c, 0xcfd4,
+	0x2900, 0x6016, 0x6023, 0x0001, 0xa868, 0xd88c, 0x0108, 0xc0f5,
+	0xa86a, 0x0126, 0x2091, 0x8000, 0x080c, 0x31cc, 0x012e, 0x9006,
+	0x080c, 0x6552, 0x2001, 0x0002, 0x080c, 0x6566, 0x2009, 0x0002,
+	0x080c, 0xaeda, 0xa8b0, 0xd094, 0x0118, 0xb8cc, 0xc08d, 0xb8ce,
+	0x9006, 0x9005, 0x012e, 0x00ee, 0x00fe, 0x00be, 0x0005, 0x080c,
+	0x56f6, 0x0118, 0x2009, 0x0007, 0x00f8, 0xa998, 0xaeb0, 0x080c,
+	0x6616, 0x1904, 0x63a4, 0x9186, 0x007f, 0x0130, 0x080c, 0x6989,
+	0x0118, 0x2009, 0x0009, 0x0080, 0x0096, 0x080c, 0x0fff, 0x1120,
+	0x009e, 0x2009, 0x0002, 0x0040, 0x2900, 0x009e, 0xa806, 0x080c,
+	0xcd40, 0x19b0, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804, 0x63ab,
+	0xa998, 0xaeb0, 0x080c, 0x6616, 0x1904, 0x63a4, 0x0096, 0x080c,
+	0x0fff, 0x1128, 0x009e, 0x2009, 0x0002, 0x0804, 0x6464, 0x2900,
+	0x009e, 0xa806, 0x0096, 0x2048, 0x20a9, 0x002b, 0xb8c4, 0x20e0,
+	0xb8c8, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0,
+	0x4003, 0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0, 0xbbc8, 0x9398,
+	0x0006, 0x2398, 0x080c, 0x0f7c, 0x009e, 0xa87b, 0x0000, 0xa883,
+	0x0000, 0xa897, 0x4000, 0xd684, 0x1168, 0x080c, 0x56e2, 0xd0b4,
+	0x1118, 0xa89b, 0x000b, 0x00e0, 0xb800, 0xd08c, 0x0118, 0xa89b,
+	0x000c, 0x00b0, 0x080c, 0x6989, 0x0118, 0xa89b, 0x0009, 0x0080,
+	0x080c, 0x56f6, 0x0118, 0xa89b, 0x0007, 0x0050, 0x080c, 0xcd23,
+	0x1904, 0x63e0, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804, 0x63ab,
+	0xa87b, 0x0030, 0xa897, 0x4005, 0xa804, 0x8006, 0x8006, 0x8007,
+	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009, 0x002b,
+	0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x1243,
+	0x080c, 0xb379, 0x1904, 0x63e0, 0x2009, 0x0002, 0x08e8, 0x2001,
+	0x0028, 0x900e, 0x0804, 0x63e1, 0x2009, 0x180c, 0x210c, 0xd18c,
+	0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004,
+	0x0010, 0x2001, 0x0029, 0x900e, 0x0804, 0x63e1, 0x2001, 0x0029,
+	0x900e, 0x0804, 0x63e1, 0x080c, 0x3761, 0x0804, 0x63e2, 0x080c,
+	0x541f, 0x0804, 0x63e2, 0x080c, 0x455f, 0x0804, 0x63e2, 0x080c,
+	0x45d8, 0x0804, 0x63e2, 0x080c, 0x4634, 0x0804, 0x63e2, 0x080c,
+	0x4a94, 0x0804, 0x63e2, 0x080c, 0x4d44, 0x0804, 0x63e2, 0x080c,
+	0x508a, 0x0804, 0x63e2, 0x080c, 0x5283, 0x0804, 0x63e2, 0x080c,
+	0x3977, 0x0804, 0x63e2, 0x00b6, 0xa974, 0xae78, 0x9684, 0x3fff,
+	0x9082, 0x4000, 0x1618, 0x9182, 0x0800, 0x1268, 0x9188, 0x1000,
+	0x2104, 0x905d, 0x0140, 0x080c, 0x6989, 0x1148, 0x00e9, 0x080c,
+	0x6741, 0x9006, 0x00b0, 0x2001, 0x0028, 0x900e, 0x0090, 0x9082,
+	0x0006, 0x1240, 0xb900, 0xd1fc, 0x0d88, 0x2001, 0x0029, 0x2009,
+	0x1000, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018, 0x2001, 0x0029,
+	0x900e, 0x9005, 0x00be, 0x0005, 0x0126, 0x2091, 0x8000, 0xb850,
+	0x900d, 0x0150, 0x2900, 0x0096, 0x2148, 0xa802, 0x009e, 0xa803,
+	0x0000, 0xb852, 0x012e, 0x0005, 0x2900, 0xb852, 0xb84e, 0xa803,
+	0x0000, 0x0cc0, 0x0126, 0x2091, 0x8000, 0xb84c, 0x9005, 0x0170,
+	0x00e6, 0x2071, 0x19e6, 0x7004, 0x9086, 0x0002, 0x0168, 0x00ee,
+	0xb84c, 0xa802, 0x2900, 0xb84e, 0x012e, 0x0005, 0x2900, 0xb852,
+	0xb84e, 0xa803, 0x0000, 0x0cc0, 0x701c, 0x9b06, 0x1d80, 0xb84c,
+	0x00a6, 0x2050, 0xb000, 0xa802, 0x2900, 0xb002, 0x00ae, 0x00ee,
+	0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0xb84c, 0x904d, 0x0130,
+	0xa800, 0x9005, 0x1108, 0xb852, 0xb84e, 0x9905, 0x012e, 0x0005,
+	0xb84c, 0x904d, 0x0130, 0xa800, 0x9005, 0x1108, 0xb852, 0xb84e,
+	0x9905, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x0026, 0x2091, 0x8000,
+	0x6210, 0x2258, 0xba00, 0x9005, 0x0110, 0xc285, 0x0008, 0xc284,
+	0xba02, 0x002e, 0x00ce, 0x012e, 0x00be, 0x0005, 0x00b6, 0x0126,
+	0x00c6, 0x2091, 0x8000, 0x6210, 0x2258, 0xba04, 0x0006, 0x9086,
+	0x0006, 0x1170, 0xb89c, 0xd0ac, 0x0158, 0x080c, 0x6985, 0x0140,
+	0x9284, 0xff00, 0x8007, 0x9086, 0x0007, 0x1110, 0x2011, 0x0600,
+	0x000e, 0x9294, 0xff00, 0x9215, 0xba06, 0x0006, 0x9086, 0x0006,
+	0x1120, 0xba90, 0x82ff, 0x090c, 0x0dd5, 0x000e, 0x00ce, 0x012e,
+	0x00be, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x6210,
+	0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1168, 0xb89c, 0xd0a4,
+	0x0150, 0x080c, 0x6981, 0x1138, 0x9284, 0x00ff, 0x9086, 0x0007,
+	0x1110, 0x2011, 0x0006, 0x000e, 0x9294, 0x00ff, 0x8007, 0x9215,
+	0xba06, 0x00ce, 0x012e, 0x00be, 0x0005, 0x9182, 0x0800, 0x0218,
+	0x9085, 0x0001, 0x0005, 0x00d6, 0x0026, 0x9190, 0x1000, 0x2204,
+	0x905d, 0x1188, 0x0096, 0x080c, 0x0fff, 0x2958, 0x009e, 0x0168,
+	0x2b00, 0x2012, 0xb85c, 0xb8ca, 0xb860, 0xb8c6, 0x9006, 0xb8a6,
+	0xb8ae, 0x080c, 0x6047, 0x9006, 0x0010, 0x9085, 0x0001, 0x002e,
+	0x00de, 0x0005, 0x00b6, 0x0096, 0x0126, 0x2091, 0x8000, 0x0026,
+	0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0458, 0x00d6, 0x9190,
+	0x1000, 0x2204, 0x905d, 0x0518, 0x2013, 0x0000, 0xb8a4, 0x904d,
+	0x0110, 0x080c, 0x1031, 0x00d6, 0x00c6, 0xb8bc, 0x2060, 0x8cff,
+	0x0168, 0x600c, 0x0006, 0x6014, 0x2048, 0x080c, 0xcb5a, 0x0110,
+	0x080c, 0x0fb1, 0x080c, 0xae5f, 0x00ce, 0x0c88, 0x00ce, 0x00de,
+	0x2b48, 0xb8c8, 0xb85e, 0xb8c4, 0xb862, 0x080c, 0x1041, 0x00de,
+	0x9006, 0x002e, 0x012e, 0x009e, 0x00be, 0x0005, 0x0016, 0x9182,
+	0x0800, 0x0218, 0x9085, 0x0001, 0x0030, 0x9188, 0x1000, 0x2104,
+	0x905d, 0x0dc0, 0x9006, 0x001e, 0x0005, 0x00d6, 0x0156, 0x0136,
+	0x0146, 0x9006, 0xb80a, 0xb80e, 0xb800, 0xc08c, 0xb802, 0x080c,
+	0x73b3, 0x1510, 0xb8a0, 0x9086, 0x007e, 0x0120, 0x080c, 0xadc9,
+	0x11d8, 0x0078, 0x7040, 0xd0e4, 0x01b8, 0x00c6, 0x2061, 0x1981,
+	0x7048, 0x2062, 0x704c, 0x6006, 0x7050, 0x600a, 0x7054, 0x600e,
+	0x00ce, 0x703c, 0x2069, 0x0140, 0x9005, 0x1110, 0x2001, 0x0001,
+	0x6886, 0x2069, 0x1800, 0x68b6, 0x7040, 0xb85e, 0x7048, 0xb862,
+	0x704c, 0xb866, 0x20e1, 0x0000, 0x2099, 0x0276, 0xb8c4, 0x20e8,
+	0xb8c8, 0x9088, 0x000a, 0x21a0, 0x20a9, 0x0004, 0x4003, 0x2099,
+	0x027a, 0x9088, 0x0006, 0x21a0, 0x20a9, 0x0004, 0x4003, 0x2069,
+	0x0200, 0x6817, 0x0001, 0x7040, 0xb86a, 0x7144, 0xb96e, 0x7048,
+	0xb872, 0x7050, 0xb876, 0x2069, 0x0200, 0x6817, 0x0000, 0xb8a0,
+	0x9086, 0x007e, 0x1110, 0x7144, 0xb96e, 0x9182, 0x0211, 0x1218,
+	0x2009, 0x0008, 0x0400, 0x9182, 0x0259, 0x1218, 0x2009, 0x0007,
+	0x00d0, 0x9182, 0x02c1, 0x1218, 0x2009, 0x0006, 0x00a0, 0x9182,
+	0x0349, 0x1218, 0x2009, 0x0005, 0x0070, 0x9182, 0x0421, 0x1218,
+	0x2009, 0x0004, 0x0040, 0x9182, 0x0581, 0x1218, 0x2009, 0x0003,
+	0x0010, 0x2009, 0x0002, 0xb992, 0x014e, 0x013e, 0x015e, 0x00de,
+	0x0005, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260, 0x7034, 0xb896,
+	0x703c, 0xb89a, 0x7054, 0xb89e, 0x0036, 0xbbcc, 0xc384, 0xba00,
+	0x2009, 0x1867, 0x210c, 0xd0bc, 0x0120, 0xd1ec, 0x0110, 0xc2ad,
+	0x0008, 0xc2ac, 0xd0c4, 0x0148, 0xd1e4, 0x0138, 0xc2bd, 0xd0cc,
+	0x0128, 0xd38c, 0x1108, 0xc385, 0x0008, 0xc2bc, 0xba02, 0xbbce,
+	0x003e, 0x00ee, 0x002e, 0x001e, 0x0005, 0x0096, 0x0126, 0x2091,
+	0x8000, 0xb8a4, 0x904d, 0x0578, 0xa900, 0x81ff, 0x15c0, 0xaa04,
+	0x9282, 0x0010, 0x16c8, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x8906,
+	0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0, 0x9080,
+	0x0004, 0x2098, 0x2009, 0x0010, 0x20a9, 0x0001, 0x4002, 0x9086,
+	0xffff, 0x0120, 0x8109, 0x1dd0, 0x080c, 0x0dd5, 0x3c00, 0x20e8,
+	0x3300, 0x8001, 0x20a0, 0x4604, 0x8210, 0xaa06, 0x01de, 0x01ce,
+	0x014e, 0x013e, 0x0060, 0x080c, 0x0fff, 0x0170, 0x2900, 0xb8a6,
+	0xa803, 0x0000, 0x080c, 0x67d2, 0xa807, 0x0001, 0xae12, 0x9085,
+	0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0126, 0x2091,
+	0x8000, 0x0096, 0xb8a4, 0x904d, 0x0188, 0xa800, 0x9005, 0x1150,
+	0x080c, 0x67e1, 0x1158, 0xa804, 0x908a, 0x0002, 0x0218, 0x8001,
+	0xa806, 0x0020, 0x080c, 0x1031, 0xb8a7, 0x0000, 0x009e, 0x012e,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x9115, 0x012e, 0x0005,
+	0x901e, 0x0010, 0x2019, 0x0001, 0x900e, 0x0126, 0x2091, 0x8000,
+	0xb84c, 0x2048, 0xb800, 0xd0dc, 0x1170, 0x89ff, 0x0500, 0x83ff,
+	0x0120, 0xa878, 0x9606, 0x0158, 0x0030, 0xa86c, 0x9406, 0x1118,
+	0xa870, 0x9506, 0x0120, 0x2908, 0xa800, 0x2048, 0x0c70, 0x080c,
+	0xa67d, 0xaa00, 0xb84c, 0x9906, 0x1110, 0xba4e, 0x0020, 0x00a6,
+	0x2150, 0xb202, 0x00ae, 0x82ff, 0x1110, 0xb952, 0x89ff, 0x012e,
+	0x0005, 0x9016, 0x0489, 0x1110, 0x2011, 0x0001, 0x0005, 0x080c,
+	0x6836, 0x0128, 0x080c, 0xcc17, 0x0010, 0x9085, 0x0001, 0x0005,
+	0x080c, 0x6836, 0x0128, 0x080c, 0xcbbc, 0x0010, 0x9085, 0x0001,
+	0x0005, 0x080c, 0x6836, 0x0128, 0x080c, 0xcc14, 0x0010, 0x9085,
+	0x0001, 0x0005, 0x080c, 0x6836, 0x0128, 0x080c, 0xcbdb, 0x0010,
+	0x9085, 0x0001, 0x0005, 0x080c, 0x6836, 0x0128, 0x080c, 0xcc58,
+	0x0010, 0x9085, 0x0001, 0x0005, 0xb8a4, 0x900d, 0x1118, 0x9085,
+	0x0001, 0x0005, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e,
+	0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080,
+	0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606,
+	0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0008, 0x9006, 0x01ce,
+	0x013e, 0x0005, 0x0146, 0x01d6, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0004, 0x20a0, 0x20a9, 0x0010, 0x2009, 0xffff, 0x4104, 0x01de,
+	0x014e, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e, 0x810e,
+	0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080, 0x0004,
+	0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606, 0x0128,
+	0x8109, 0x1dd8, 0x9085, 0x0001, 0x0068, 0x0146, 0x01d6, 0x3300,
+	0x8001, 0x20a0, 0x3c00, 0x20e8, 0x2001, 0xffff, 0x4004, 0x01de,
+	0x014e, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0096, 0x0126, 0x2091,
+	0x8000, 0xb8a4, 0x904d, 0x1128, 0x080c, 0x0fff, 0x0168, 0x2900,
+	0xb8a6, 0x080c, 0x67d2, 0xa803, 0x0001, 0xa807, 0x0000, 0x9085,
+	0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0096, 0x0126,
+	0x2091, 0x8000, 0xb8a4, 0x904d, 0x0130, 0xb8a7, 0x0000, 0x080c,
+	0x1031, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0xb89c, 0xd0a4,
+	0x0005, 0x00b6, 0x00f6, 0x080c, 0x73b3, 0x01b0, 0x71c4, 0x81ff,
+	0x1198, 0x71dc, 0xd19c, 0x0180, 0x2001, 0x007e, 0x9080, 0x1000,
+	0x2004, 0x905d, 0x0148, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
+	0x1118, 0xb800, 0xc0ed, 0xb802, 0x2079, 0x1847, 0x7804, 0xd0a4,
+	0x01d0, 0x0156, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6616,
+	0x1168, 0xb804, 0x9084, 0xff00, 0x8007, 0x9096, 0x0004, 0x0118,
+	0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x001e, 0x8108,
+	0x1f04, 0x685d, 0x015e, 0x080c, 0x6947, 0x0120, 0x2001, 0x1984,
+	0x200c, 0x0038, 0x2079, 0x1847, 0x7804, 0xd0a4, 0x0130, 0x2009,
+	0x07d0, 0x2011, 0x6888, 0x080c, 0x8591, 0x00fe, 0x00be, 0x0005,
+	0x00b6, 0x2011, 0x6888, 0x080c, 0x84f9, 0x080c, 0x6947, 0x01d8,
+	0x2001, 0x107e, 0x2004, 0x2058, 0xb900, 0xc1ec, 0xb902, 0x080c,
+	0x6985, 0x0130, 0x2009, 0x07d0, 0x2011, 0x6888, 0x080c, 0x8591,
+	0x00e6, 0x2071, 0x1800, 0x9006, 0x707e, 0x7060, 0x7082, 0x080c,
+	0x2fa3, 0x00ee, 0x04b0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e,
+	0x0016, 0x080c, 0x6616, 0x1538, 0xb800, 0xd0ec, 0x0520, 0x0046,
+	0xbaa0, 0x2220, 0x9006, 0x2009, 0x0029, 0x080c, 0xe5e9, 0xb800,
+	0xc0e5, 0xc0ec, 0xb802, 0x080c, 0x6981, 0x2001, 0x0707, 0x1128,
+	0xb804, 0x9084, 0x00ff, 0x9085, 0x0700, 0xb806, 0x2019, 0x0029,
+	0x080c, 0x929d, 0x0076, 0x903e, 0x080c, 0x9170, 0x900e, 0x080c,
+	0xe326, 0x007e, 0x004e, 0x001e, 0x8108, 0x1f04, 0x68b0, 0x00ce,
+	0x015e, 0x00be, 0x0005, 0x00b6, 0x6010, 0x2058, 0xb800, 0xc0ec,
+	0xb802, 0x00be, 0x0005, 0x00b6, 0x00c6, 0x0096, 0x080c, 0x1018,
+	0x090c, 0x0dd5, 0x2958, 0x009e, 0x2001, 0x196a, 0x2b02, 0x8b07,
+	0x8006, 0x8006, 0x908c, 0x003f, 0xb9c6, 0x908c, 0xffc0, 0xb9ca,
+	0xb8af, 0x0000, 0x2009, 0x00ff, 0x080c, 0x6047, 0xb807, 0x0006,
+	0xb813, 0x00ff, 0xb817, 0xffff, 0xb86f, 0x0200, 0xb86c, 0xb893,
+	0x0002, 0xb8bb, 0x0520, 0xb8a3, 0x00ff, 0xb8af, 0x0000, 0x00ce,
+	0x00be, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ac,
+	0x0005, 0x6010, 0x00b6, 0x905d, 0x0108, 0xb800, 0x00be, 0xd0bc,
+	0x0005, 0x0006, 0x0016, 0x0026, 0xb804, 0x908c, 0x00ff, 0x9196,
+	0x0006, 0x0188, 0x9196, 0x0004, 0x0170, 0x9196, 0x0005, 0x0158,
+	0x908c, 0xff00, 0x810f, 0x9196, 0x0006, 0x0128, 0x9196, 0x0004,
+	0x0110, 0x9196, 0x0005, 0x002e, 0x001e, 0x000e, 0x0005, 0x00b6,
+	0x00f6, 0x2001, 0x107e, 0x2004, 0x905d, 0x0110, 0xb800, 0xd0ec,
+	0x00fe, 0x00be, 0x0005, 0x0126, 0x0026, 0x2091, 0x8000, 0x0006,
+	0xbaa0, 0x9290, 0x1000, 0x2204, 0x9b06, 0x190c, 0x0dd5, 0x000e,
+	0xba00, 0x9005, 0x0110, 0xc2fd, 0x0008, 0xc2fc, 0xba02, 0x002e,
+	0x012e, 0x0005, 0x2011, 0x1837, 0x2204, 0xd0cc, 0x0138, 0x2001,
+	0x1982, 0x200c, 0x2011, 0x6977, 0x080c, 0x8591, 0x0005, 0x2011,
+	0x6977, 0x080c, 0x84f9, 0x2011, 0x1837, 0x2204, 0xc0cc, 0x2012,
+	0x0005, 0x080c, 0x56e2, 0xd0ac, 0x0005, 0x080c, 0x56e2, 0xd0a4,
+	0x0005, 0x0016, 0xb904, 0x9184, 0x00ff, 0x908e, 0x0006, 0x001e,
+	0x0005, 0x0016, 0xb904, 0x9184, 0xff00, 0x8007, 0x908e, 0x0006,
+	0x001e, 0x0005, 0x00b6, 0x00f6, 0x080c, 0xd25a, 0x0158, 0x70dc,
+	0x9084, 0x0028, 0x0138, 0x2001, 0x107f, 0x2004, 0x905d, 0x0110,
+	0xb8cc, 0xd094, 0x00fe, 0x00be, 0x0005, 0x2071, 0x1910, 0x7003,
+	0x0001, 0x7007, 0x0000, 0x9006, 0x7012, 0x7016, 0x701a, 0x701e,
+	0x700a, 0x7046, 0x0005, 0x0016, 0x00e6, 0x2071, 0x1947, 0x900e,
+	0x710a, 0x080c, 0x56e2, 0xd0fc, 0x1140, 0x080c, 0x56e2, 0x900e,
+	0xd09c, 0x0108, 0x8108, 0x7102, 0x00f8, 0x2001, 0x1867, 0x200c,
+	0x9184, 0x0007, 0x0002, 0x69c5, 0x69c5, 0x69c5, 0x69c5, 0x69c5,
+	0x69db, 0x69e9, 0x69c5, 0x7003, 0x0003, 0x2009, 0x1868, 0x210c,
+	0x9184, 0xff00, 0x8007, 0x9005, 0x1110, 0x2001, 0x0002, 0x7006,
+	0x0018, 0x7003, 0x0005, 0x0c88, 0x00ee, 0x001e, 0x0005, 0x00e6,
+	0x2071, 0x0050, 0x684c, 0x9005, 0x1150, 0x00e6, 0x2071, 0x1910,
+	0x7028, 0xc085, 0x702a, 0x00ee, 0x9085, 0x0001, 0x0488, 0x6844,
+	0x9005, 0x0158, 0x080c, 0x770b, 0x6a60, 0x9200, 0x7002, 0x6864,
+	0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6860, 0x7002, 0x6864,
+	0x7006, 0x6868, 0x700a, 0x686c, 0x700e, 0x6844, 0x9005, 0x1110,
+	0x7012, 0x7016, 0x684c, 0x701a, 0x701c, 0x9085, 0x0040, 0x701e,
+	0x7037, 0x0019, 0x702b, 0x0001, 0x00e6, 0x2071, 0x1910, 0x7028,
+	0xc084, 0x702a, 0x7007, 0x0001, 0x700b, 0x0000, 0x00ee, 0x9006,
+	0x00ee, 0x0005, 0x00e6, 0x0026, 0x2071, 0x1947, 0x7000, 0x9015,
+	0x0904, 0x6c99, 0x9286, 0x0003, 0x0904, 0x6b2f, 0x9286, 0x0005,
+	0x0904, 0x6b2f, 0x2071, 0x1877, 0xa87c, 0x9005, 0x0904, 0x6a90,
+	0x7140, 0xa868, 0x9102, 0x0a04, 0x6c99, 0xa878, 0xd084, 0x15d8,
+	0xa853, 0x0019, 0x2001, 0x8023, 0xa84e, 0x2071, 0x1910, 0x701c,
+	0x9005, 0x1904, 0x6e2f, 0x0e04, 0x6e9d, 0x2071, 0x0000, 0xa850,
+	0x7032, 0xa84c, 0x7082, 0xa870, 0x7086, 0xa86c, 0x708a, 0xa880,
+	0x708e, 0x7036, 0x0146, 0x01d6, 0x0136, 0x01c6, 0x0156, 0x20e9,
+	0x0000, 0x20a1, 0x002a, 0xa868, 0x20a8, 0xa860, 0x20e0, 0xa85c,
+	0x9080, 0x0021, 0x2098, 0x4003, 0x015e, 0x01ce, 0x013e, 0x01de,
+	0x014e, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x119b, 0x0804, 0x6b12, 0xa853, 0x001b, 0x2001, 0x8027, 0x0820,
+	0x7004, 0xd08c, 0x1904, 0x6c99, 0xa853, 0x001a, 0x2001, 0x8024,
+	0x0804, 0x6a54, 0x00e6, 0x0026, 0x2071, 0x1947, 0x7000, 0x9015,
+	0x0904, 0x6c99, 0x9286, 0x0003, 0x0904, 0x6b2f, 0x9286, 0x0005,
+	0x0904, 0x6b2f, 0xa84f, 0x8022, 0xa853, 0x0018, 0x0804, 0x6af7,
+	0xa868, 0xd0fc, 0x11d8, 0x00e6, 0x0026, 0x2001, 0x1947, 0x2004,
+	0x9005, 0x0904, 0x6c99, 0xa87c, 0xd0bc, 0x1904, 0x6c99, 0xa978,
+	0xa874, 0x9105, 0x1904, 0x6c99, 0x2001, 0x1947, 0x2004, 0x0002,
+	0x6c99, 0x6af3, 0x6b2f, 0x6b2f, 0x6c99, 0x6b2f, 0x0005, 0xa868,
+	0xd0fc, 0x1500, 0x00e6, 0x0026, 0x2009, 0x1947, 0x210c, 0x81ff,
+	0x0904, 0x6c99, 0xa87c, 0xd0cc, 0x0904, 0x6c99, 0xa880, 0x9084,
+	0x00ff, 0x9086, 0x0001, 0x1904, 0x6c99, 0x9186, 0x0003, 0x0904,
+	0x6b2f, 0x9186, 0x0005, 0x0904, 0x6b2f, 0xa84f, 0x8021, 0xa853,
+	0x0017, 0x0028, 0x0005, 0xa84f, 0x8020, 0xa853, 0x0016, 0x2071,
+	0x1910, 0x701c, 0x9005, 0x1904, 0x6e2f, 0x0e04, 0x6e9d, 0x2071,
+	0x0000, 0xa84c, 0x7082, 0xa850, 0x7032, 0xa86c, 0x7086, 0x7036,
+	0xa870, 0x708a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x119b, 0x2071, 0x1800, 0x2011, 0x0001, 0xa804, 0x900d,
+	0x702c, 0x1158, 0xa802, 0x2900, 0x702e, 0x70c0, 0x9200, 0x70c2,
+	0x080c, 0x841a, 0x002e, 0x00ee, 0x0005, 0x0096, 0x2148, 0xa904,
+	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x009e, 0x0c58, 0xa84f,
+	0x0000, 0x00f6, 0x2079, 0x0050, 0x2071, 0x1910, 0xa803, 0x0000,
+	0x7010, 0x9005, 0x1904, 0x6c1e, 0x782c, 0x908c, 0x0780, 0x190c,
+	0x6fe9, 0x8004, 0x8004, 0x8004, 0x9084, 0x0003, 0x0002, 0x6b4d,
+	0x6c1e, 0x6b72, 0x6bb9, 0x080c, 0x0dd5, 0x2071, 0x1800, 0x2900,
+	0x7822, 0xa804, 0x900d, 0x1170, 0x2071, 0x19f9, 0x703c, 0x9005,
+	0x1328, 0x2001, 0x1948, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
+	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c,
+	0x841a, 0x0c10, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d,
+	0x1580, 0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1148,
+	0x2009, 0x1830, 0x210c, 0x918a, 0x0020, 0x0218, 0x7022, 0x00ee,
+	0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0,
+	0x8000, 0x70c2, 0x080c, 0x841a, 0x782c, 0x9094, 0x0780, 0x190c,
+	0x6fe9, 0xd0a4, 0x19f0, 0x2071, 0x19f9, 0x703c, 0x9005, 0x1328,
+	0x2001, 0x1948, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee,
+	0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x841a,
+	0x0800, 0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c,
+	0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x841a,
+	0x782c, 0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4, 0x1d60, 0x00ee,
+	0x782c, 0x9094, 0x0780, 0x190c, 0x6fe9, 0xd09c, 0x11a0, 0x009e,
+	0x2900, 0x7822, 0xa804, 0x900d, 0x1560, 0x2071, 0x19f9, 0x703c,
 	0x9005, 0x1328, 0x2001, 0x1948, 0x2004, 0x8005, 0x703e, 0x00fe,
-	0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
+	0x002e, 0x00ee, 0x0005, 0x009e, 0x2908, 0x7010, 0x8000, 0x7012,
+	0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148,
+	0xa804, 0x900d, 0x1170, 0x2071, 0x19f9, 0x703c, 0x9005, 0x1328,
+	0x2001, 0x1948, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee,
+	0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
 	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2,
-	0x080c, 0x83fd, 0x0800, 0x0096, 0x00e6, 0x7824, 0x2048, 0x2071,
-	0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2,
-	0x080c, 0x83fd, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd0a4,
-	0x1d60, 0x00ee, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd09c,
-	0x11a0, 0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x1560, 0x2071,
-	0x19f9, 0x703c, 0x9005, 0x1328, 0x2001, 0x1948, 0x2004, 0x8005,
-	0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x009e, 0x2908, 0x7010,
+	0x080c, 0x841a, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908, 0x7010,
 	0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008,
-	0x711e, 0x2148, 0xa804, 0x900d, 0x1170, 0x2071, 0x19f9, 0x703c,
+	0x711e, 0x2148, 0xa804, 0x900d, 0x1904, 0x6c73, 0x782c, 0x9094,
+	0x0780, 0x190c, 0x6fe9, 0xd09c, 0x1198, 0x701c, 0x904d, 0x0180,
+	0x7010, 0x8001, 0x7012, 0x1108, 0x701a, 0xa800, 0x701e, 0x2900,
+	0x7822, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fe9, 0xd09c, 0x0d68,
+	0x782c, 0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4, 0x01b0, 0x00e6,
+	0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e,
+	0x70c0, 0x8000, 0x70c2, 0x080c, 0x841a, 0x782c, 0x9094, 0x0780,
+	0x190c, 0x6fe9, 0xd0a4, 0x1d60, 0x00ee, 0x2071, 0x19f9, 0x703c,
 	0x9005, 0x1328, 0x2001, 0x1948, 0x2004, 0x8005, 0x703e, 0x00fe,
-	0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
-	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0,
-	0x9200, 0x70c2, 0x080c, 0x83fd, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110,
-	0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904, 0x6c65,
-	0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd09c, 0x1198, 0x701c,
-	0x904d, 0x0180, 0x7010, 0x8001, 0x7012, 0x1108, 0x701a, 0xa800,
-	0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb,
-	0xd09c, 0x0d68, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd0a4,
-	0x01b0, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802,
-	0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x83fd, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x6fdb, 0xd0a4, 0x1d60, 0x00ee, 0x2071,
-	0x19f9, 0x703c, 0x9005, 0x1328, 0x2001, 0x1948, 0x2004, 0x8005,
-	0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800,
-	0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff,
-	0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x83fd, 0x00ee,
-	0x0804, 0x6c20, 0xa868, 0xd0fc, 0x1560, 0x0096, 0xa804, 0xa807,
-	0x0000, 0x904d, 0x190c, 0x0fb1, 0x009e, 0x0018, 0xa868, 0xd0fc,
-	0x1500, 0x00e6, 0x0026, 0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050,
-	0x2071, 0x1910, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x6d9f,
-	0x782c, 0x908c, 0x0780, 0x190c, 0x6fdb, 0x8004, 0x8004, 0x8004,
-	0x9084, 0x0003, 0x0002, 0x6caa, 0x6d9f, 0x6cc5, 0x6d32, 0x080c,
-	0x0dd5, 0x0005, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d,
-	0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148,
-	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0,
-	0x9200, 0x70c2, 0x080c, 0x83fd, 0x0c60, 0x2071, 0x1800, 0x2900,
-	0x7822, 0xa804, 0x900d, 0x1904, 0x6d21, 0x7830, 0x8007, 0x9084,
-	0x001f, 0x9082, 0x0001, 0x1220, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1148, 0x2009,
-	0x1830, 0x210c, 0x918a, 0x0020, 0x0218, 0x7022, 0x00ee, 0x0058,
-	0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000,
-	0x70c2, 0x080c, 0x83fd, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb,
-	0xd0a4, 0x19f0, 0x0e04, 0x6d18, 0x7838, 0x7938, 0x910e, 0x1de0,
-	0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2001,
-	0x1921, 0x200c, 0xc184, 0x2102, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x190c, 0x119b, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x2001, 0x1921, 0x200c, 0xc185, 0x2102, 0x00fe, 0x002e, 0x00ee,
-	0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
-	0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x83fd,
-	0x0804, 0x6cd8, 0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
-	0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c,
-	0x83fd, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd0a4, 0x1d60,
-	0x00ee, 0x0e04, 0x6d72, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6,
-	0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084,
-	0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
-	0x119b, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd09c, 0x1170,
-	0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x11e0, 0x00fe, 0x002e,
-	0x00ee, 0x0005, 0x7044, 0xc085, 0x7046, 0x0c58, 0x009e, 0x2908,
-	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
-	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1120, 0x00fe, 0x002e,
-	0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904,
-	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200,
-	0x70c2, 0x080c, 0x83fd, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908,
-	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
-	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904, 0x6e0c, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x6fdb, 0xd09c, 0x11b0, 0x701c, 0x904d,
-	0x0198, 0xa84c, 0x9005, 0x1180, 0x7010, 0x8001, 0x7012, 0x1108,
-	0x701a, 0xa800, 0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6fdb, 0xd09c, 0x0d50, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x6fdb, 0xd0a4, 0x05a8, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
+	0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016, 0x702c,
+	0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e,
+	0x70c0, 0x9200, 0x70c2, 0x080c, 0x841a, 0x00ee, 0x0804, 0x6c2e,
+	0xa868, 0xd0fc, 0x1560, 0x0096, 0xa804, 0xa807, 0x0000, 0x904d,
+	0x190c, 0x0fb1, 0x009e, 0x0018, 0xa868, 0xd0fc, 0x1500, 0x00e6,
+	0x0026, 0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050, 0x2071, 0x1910,
+	0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x6dad, 0x782c, 0x908c,
+	0x0780, 0x190c, 0x6fe9, 0x8004, 0x8004, 0x8004, 0x9084, 0x0003,
+	0x0002, 0x6cb8, 0x6dad, 0x6cd3, 0x6d40, 0x080c, 0x0dd5, 0x0005,
+	0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1120, 0x00fe,
+	0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
+	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2,
+	0x080c, 0x841a, 0x0c60, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804,
+	0x900d, 0x1904, 0x6d2f, 0x7830, 0x8007, 0x9084, 0x001f, 0x9082,
+	0x0001, 0x1220, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7824, 0x00e6,
+	0x2071, 0x0040, 0x712c, 0xd19c, 0x1148, 0x2009, 0x1830, 0x210c,
+	0x918a, 0x0020, 0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048,
 	0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c,
-	0x83fd, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd0a4, 0x1d60,
-	0x00ee, 0x0e04, 0x6e05, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6,
-	0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084,
-	0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
-	0x119b, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7044, 0xc085, 0x7046,
-	0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016,
+	0x841a, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4, 0x19f0,
+	0x0e04, 0x6d26, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069,
+	0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2001, 0x1921, 0x200c,
+	0xc184, 0x2102, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x119b, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2001, 0x1921,
+	0x200c, 0xc185, 0x2102, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016,
 	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
-	0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x83fd, 0x00ee, 0x0804,
-	0x6daf, 0x2071, 0x1910, 0xa803, 0x0000, 0x2908, 0x7010, 0x8000,
+	0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x841a, 0x0804, 0x6ce6,
+	0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802,
+	0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x841a, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4, 0x1d60, 0x00ee, 0x0e04,
+	0x6d80, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
+	0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084, 0x7046, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6fe9, 0xd09c, 0x1170, 0x009e, 0x2900,
+	0x7822, 0xa804, 0x900d, 0x11e0, 0x00fe, 0x002e, 0x00ee, 0x0005,
+	0x7044, 0xc085, 0x7046, 0x0c58, 0x009e, 0x2908, 0x7010, 0x8000,
 	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
-	0x2148, 0xa804, 0x900d, 0x1128, 0x1e04, 0x6e4c, 0x002e, 0x00ee,
-	0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
-	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2,
-	0x080c, 0x83fd, 0x0e04, 0x6e36, 0x2071, 0x1910, 0x701c, 0x2048,
-	0xa84c, 0x900d, 0x0d18, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032,
-	0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0xa850, 0x9082, 0x0019,
-	0x1278, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
-	0x119b, 0x2071, 0x1910, 0x080c, 0x6fc7, 0x002e, 0x00ee, 0x0005,
-	0xa850, 0x9082, 0x001c, 0x1e68, 0xa880, 0x708e, 0x7036, 0x0146,
-	0x01d6, 0x0136, 0x01c6, 0x0156, 0x20e9, 0x0000, 0x20a1, 0x002a,
-	0xa868, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098,
-	0x4003, 0x015e, 0x01ce, 0x013e, 0x01de, 0x014e, 0x0890, 0x2071,
+	0x2148, 0xa804, 0x900d, 0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005,
+	0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
+	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c,
+	0x841a, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908, 0x7010, 0x8000,
+	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
+	0x2148, 0xa804, 0x900d, 0x1904, 0x6e1a, 0x782c, 0x9094, 0x0780,
+	0x190c, 0x6fe9, 0xd09c, 0x11b0, 0x701c, 0x904d, 0x0198, 0xa84c,
+	0x9005, 0x1180, 0x7010, 0x8001, 0x7012, 0x1108, 0x701a, 0xa800,
+	0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fe9,
+	0xd09c, 0x0d50, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4,
+	0x05a8, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802,
+	0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x841a, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4, 0x1d60, 0x00ee, 0x0e04,
+	0x6e13, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
+	0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084, 0x7046, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b, 0x00fe,
+	0x002e, 0x00ee, 0x0005, 0x7044, 0xc085, 0x7046, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
+	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0,
+	0x9200, 0x70c2, 0x080c, 0x841a, 0x00ee, 0x0804, 0x6dbd, 0x2071,
 	0x1910, 0xa803, 0x0000, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018,
 	0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804,
-	0x900d, 0x1118, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016,
-	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
-	0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x83fd, 0x002e, 0x00ee,
-	0x0005, 0x0006, 0xa87c, 0x0006, 0xa867, 0x0103, 0x20a9, 0x001c,
-	0xa860, 0x20e8, 0xa85c, 0x9080, 0x001d, 0x20a0, 0x9006, 0x4004,
-	0x000e, 0x9084, 0x00ff, 0xa87e, 0x000e, 0xa87a, 0xa982, 0x0005,
-	0x2071, 0x1910, 0x7004, 0x0002, 0x6eda, 0x6edb, 0x6fc6, 0x6edb,
-	0x0dd5, 0x6fc6, 0x0005, 0x2001, 0x1947, 0x2004, 0x0002, 0x6ee5,
-	0x6ee5, 0x6f5f, 0x6f60, 0x6ee5, 0x6f60, 0x0126, 0x2091, 0x8000,
-	0x1e0c, 0x6fe6, 0x701c, 0x904d, 0x0508, 0xa84c, 0x9005, 0x0904,
-	0x6f30, 0x0e04, 0x6f0e, 0xa94c, 0x2071, 0x0000, 0x7182, 0xa850,
-	0x7032, 0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0xa850, 0x9082,
-	0x0019, 0x1278, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x119b, 0x2071, 0x1910, 0x080c, 0x6fc7, 0x012e, 0x0804,
-	0x6f5e, 0xa850, 0x9082, 0x001c, 0x1e68, 0xa880, 0x708e, 0x7036,
-	0x0146, 0x01d6, 0x0136, 0x01c6, 0x0156, 0x20e9, 0x0000, 0x20a1,
-	0x002a, 0xa868, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021,
-	0x2098, 0x4003, 0x015e, 0x01ce, 0x013e, 0x01de, 0x014e, 0x0890,
-	0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd09c,
-	0x2071, 0x1910, 0x1510, 0x2071, 0x1910, 0x700f, 0x0001, 0xa964,
-	0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f, 0x918c, 0x00ff,
-	0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069, 0x0050, 0x6822,
-	0x00de, 0x2071, 0x1910, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012,
-	0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005,
-	0x00d6, 0x2008, 0x2069, 0x19f9, 0x683c, 0x9005, 0x0760, 0x0158,
-	0x9186, 0x0003, 0x0540, 0x2001, 0x1815, 0x2004, 0x2009, 0x1ac7,
-	0x210c, 0x9102, 0x1500, 0x0126, 0x2091, 0x8000, 0x2069, 0x0050,
-	0x693c, 0x6838, 0x9106, 0x0190, 0x0e04, 0x6f92, 0x2069, 0x0000,
-	0x6837, 0x8040, 0x6833, 0x0012, 0x6883, 0x8040, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b, 0x2069, 0x19f9,
-	0x683f, 0xffff, 0x012e, 0x00de, 0x0126, 0x2091, 0x8000, 0x1e0c,
-	0x7047, 0x701c, 0x904d, 0x0540, 0x2001, 0x005b, 0x2004, 0x9094,
-	0x0780, 0x15c9, 0xd09c, 0x1500, 0x2071, 0x1910, 0x700f, 0x0001,
-	0xa964, 0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f, 0x918c,
-	0x00ff, 0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069, 0x0050,
-	0x6822, 0x00de, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012, 0xa800,
-	0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005, 0x0126,
-	0x2091, 0x8000, 0x701c, 0x904d, 0x0160, 0x7010, 0x8001, 0x7012,
-	0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x080c, 0x1031,
-	0x0005, 0x012e, 0x0005, 0x2091, 0x8000, 0x0e04, 0x6fdd, 0x0006,
-	0x0016, 0x2001, 0x8004, 0x0006, 0x0804, 0x0dde, 0x0096, 0x00f6,
-	0x2079, 0x0050, 0x7044, 0xd084, 0x01c0, 0xc084, 0x7046, 0x7838,
-	0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833,
-	0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x119b, 0x00fe, 0x009e, 0x0005, 0x782c, 0x9094, 0x0780,
-	0x1991, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x00e6,
-	0x2071, 0x0040, 0x712c, 0xd19c, 0x1148, 0x2009, 0x1830, 0x210c,
-	0x918a, 0x0020, 0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048,
-	0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c,
-	0x83fd, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd0a4, 0x19f0,
-	0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836,
-	0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
-	0xd084, 0x190c, 0x119b, 0x00ee, 0x00fe, 0x009e, 0x0005, 0x00f6,
-	0x2079, 0x0050, 0x7044, 0xd084, 0x01b8, 0xc084, 0x7046, 0x7838,
-	0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833,
-	0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x119b, 0x00fe, 0x0005, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x6fdb, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x2048,
-	0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c,
-	0x83fd, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fdb, 0xd0a4, 0x1d70,
-	0x00d6, 0x2069, 0x0050, 0x693c, 0x2069, 0x1947, 0x6808, 0x690a,
-	0x2069, 0x19f9, 0x9102, 0x1118, 0x683c, 0x9005, 0x1328, 0x2001,
-	0x1948, 0x200c, 0x810d, 0x693e, 0x00de, 0x00ee, 0x00fe, 0x0005,
-	0x7098, 0x908a, 0x0029, 0x1a0c, 0x0dd5, 0x9082, 0x001d, 0x001b,
-	0x6027, 0x1e00, 0x0005, 0x716f, 0x70f5, 0x7111, 0x713b, 0x715e,
-	0x719e, 0x71b0, 0x7111, 0x7186, 0x70b0, 0x70de, 0x70af, 0x0005,
-	0x00d6, 0x2069, 0x0200, 0x6804, 0x9005, 0x1180, 0x6808, 0x9005,
-	0x1518, 0x709b, 0x0028, 0x2069, 0x198e, 0x2d04, 0x7002, 0x080c,
-	0x74df, 0x6028, 0x9085, 0x0600, 0x602a, 0x00b0, 0x709b, 0x0028,
-	0x2069, 0x198e, 0x2d04, 0x7002, 0x6028, 0x9085, 0x0600, 0x602a,
-	0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a61, 0x080c, 0x1aab,
-	0x005e, 0x004e, 0x003e, 0x00ee, 0x00de, 0x0005, 0x00d6, 0x2069,
-	0x0200, 0x6804, 0x9005, 0x1178, 0x6808, 0x9005, 0x1160, 0x709b,
-	0x0028, 0x2069, 0x198e, 0x2d04, 0x7002, 0x080c, 0x757a, 0x6028,
-	0x9085, 0x0600, 0x602a, 0x00de, 0x0005, 0x0006, 0x2001, 0x0090,
-	0x080c, 0x2cf1, 0x000e, 0x6124, 0xd1e4, 0x1190, 0x080c, 0x721d,
-	0xd1d4, 0x1160, 0xd1dc, 0x1138, 0xd1cc, 0x0150, 0x709b, 0x0020,
-	0x080c, 0x721d, 0x0028, 0x709b, 0x001d, 0x0010, 0x709b, 0x001f,
-	0x0005, 0x2001, 0x0088, 0x080c, 0x2cf1, 0x6124, 0xd1cc, 0x11e8,
-	0xd1dc, 0x11c0, 0xd1e4, 0x1198, 0x9184, 0x1e00, 0x11d8, 0x080c,
-	0x1ad5, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c, 0x73d1,
-	0x2001, 0x0080, 0x080c, 0x2cf1, 0x709b, 0x0028, 0x0058, 0x709b,
-	0x001e, 0x0040, 0x709b, 0x001d, 0x0028, 0x709b, 0x0020, 0x0010,
-	0x709b, 0x001f, 0x0005, 0x080c, 0x1ad5, 0x60e3, 0x0001, 0x600c,
-	0xc0b4, 0x600e, 0x080c, 0x73d1, 0x2001, 0x0080, 0x080c, 0x2cf1,
-	0x6124, 0xd1d4, 0x1180, 0xd1dc, 0x1158, 0xd1e4, 0x1130, 0x9184,
-	0x1e00, 0x1158, 0x709b, 0x0028, 0x0040, 0x709b, 0x001e, 0x0028,
-	0x709b, 0x001d, 0x0010, 0x709b, 0x001f, 0x0005, 0x2001, 0x00a0,
-	0x080c, 0x2cf1, 0x6124, 0xd1dc, 0x1138, 0xd1e4, 0x0138, 0x080c,
-	0x1ad5, 0x709b, 0x001e, 0x0010, 0x709b, 0x001d, 0x0005, 0x080c,
-	0x72a0, 0x6124, 0xd1dc, 0x1188, 0x080c, 0x721d, 0x0016, 0x080c,
-	0x1ad5, 0x001e, 0xd1d4, 0x1128, 0xd1e4, 0x0138, 0x709b, 0x001e,
-	0x0020, 0x709b, 0x001f, 0x080c, 0x721d, 0x0005, 0x0006, 0x2001,
-	0x00a0, 0x080c, 0x2cf1, 0x000e, 0x6124, 0xd1d4, 0x1160, 0xd1cc,
+	0x900d, 0x1128, 0x1e04, 0x6e5a, 0x002e, 0x00ee, 0x0005, 0x2071,
+	0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x841a,
+	0x0e04, 0x6e44, 0x2071, 0x1910, 0x701c, 0x2048, 0xa84c, 0x900d,
+	0x0d18, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032, 0xa86c, 0x7086,
+	0x7036, 0xa870, 0x708a, 0xa850, 0x9082, 0x0019, 0x1278, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b, 0x2071,
+	0x1910, 0x080c, 0x6fd5, 0x002e, 0x00ee, 0x0005, 0xa850, 0x9082,
+	0x001c, 0x1e68, 0xa880, 0x708e, 0x7036, 0x0146, 0x01d6, 0x0136,
+	0x01c6, 0x0156, 0x20e9, 0x0000, 0x20a1, 0x002a, 0xa868, 0x20a8,
+	0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098, 0x4003, 0x015e,
+	0x01ce, 0x013e, 0x01de, 0x014e, 0x0890, 0x2071, 0x1910, 0xa803,
+	0x0000, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
+	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1118,
+	0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
+	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0,
+	0x9200, 0x70c2, 0x080c, 0x841a, 0x002e, 0x00ee, 0x0005, 0x0006,
+	0xa87c, 0x0006, 0xa867, 0x0103, 0x20a9, 0x001c, 0xa860, 0x20e8,
+	0xa85c, 0x9080, 0x001d, 0x20a0, 0x9006, 0x4004, 0x000e, 0x9084,
+	0x00ff, 0xa87e, 0x000e, 0xa87a, 0xa982, 0x0005, 0x2071, 0x1910,
+	0x7004, 0x0002, 0x6ee8, 0x6ee9, 0x6fd4, 0x6ee9, 0x0dd5, 0x6fd4,
+	0x0005, 0x2001, 0x1947, 0x2004, 0x0002, 0x6ef3, 0x6ef3, 0x6f6d,
+	0x6f6e, 0x6ef3, 0x6f6e, 0x0126, 0x2091, 0x8000, 0x1e0c, 0x6ff4,
+	0x701c, 0x904d, 0x0508, 0xa84c, 0x9005, 0x0904, 0x6f3e, 0x0e04,
+	0x6f1c, 0xa94c, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032, 0xa86c,
+	0x7086, 0x7036, 0xa870, 0x708a, 0xa850, 0x9082, 0x0019, 0x1278,
+	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b,
+	0x2071, 0x1910, 0x080c, 0x6fd5, 0x012e, 0x0804, 0x6f6c, 0xa850,
+	0x9082, 0x001c, 0x1e68, 0xa880, 0x708e, 0x7036, 0x0146, 0x01d6,
+	0x0136, 0x01c6, 0x0156, 0x20e9, 0x0000, 0x20a1, 0x002a, 0xa868,
+	0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098, 0x4003,
+	0x015e, 0x01ce, 0x013e, 0x01de, 0x014e, 0x0890, 0x2001, 0x005b,
+	0x2004, 0x9094, 0x0780, 0x190c, 0x6fe9, 0xd09c, 0x2071, 0x1910,
+	0x1510, 0x2071, 0x1910, 0x700f, 0x0001, 0xa964, 0x9184, 0x00ff,
+	0x9086, 0x0003, 0x1130, 0x810f, 0x918c, 0x00ff, 0x8101, 0x0108,
+	0x710e, 0x2900, 0x00d6, 0x2069, 0x0050, 0x6822, 0x00de, 0x2071,
+	0x1910, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012, 0xa800, 0x701e,
+	0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005, 0x00d6, 0x2008,
+	0x2069, 0x19f9, 0x683c, 0x9005, 0x0760, 0x0158, 0x9186, 0x0003,
+	0x0540, 0x2001, 0x1815, 0x2004, 0x2009, 0x1ac7, 0x210c, 0x9102,
+	0x1500, 0x0126, 0x2091, 0x8000, 0x2069, 0x0050, 0x693c, 0x6838,
+	0x9106, 0x0190, 0x0e04, 0x6fa0, 0x2069, 0x0000, 0x6837, 0x8040,
+	0x6833, 0x0012, 0x6883, 0x8040, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x119b, 0x2069, 0x19f9, 0x683f, 0xffff,
+	0x012e, 0x00de, 0x0126, 0x2091, 0x8000, 0x1e0c, 0x7055, 0x701c,
+	0x904d, 0x0540, 0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x15c9,
+	0xd09c, 0x1500, 0x2071, 0x1910, 0x700f, 0x0001, 0xa964, 0x9184,
+	0x00ff, 0x9086, 0x0003, 0x1130, 0x810f, 0x918c, 0x00ff, 0x8101,
+	0x0108, 0x710e, 0x2900, 0x00d6, 0x2069, 0x0050, 0x6822, 0x00de,
+	0x701c, 0x2048, 0x7010, 0x8001, 0x7012, 0xa800, 0x701e, 0x9005,
+	0x1108, 0x701a, 0x012e, 0x0005, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x701c, 0x904d, 0x0160, 0x7010, 0x8001, 0x7012, 0xa800, 0x701e,
+	0x9005, 0x1108, 0x701a, 0x012e, 0x080c, 0x1031, 0x0005, 0x012e,
+	0x0005, 0x2091, 0x8000, 0x0e04, 0x6feb, 0x0006, 0x0016, 0x2001,
+	0x8004, 0x0006, 0x0804, 0x0dde, 0x0096, 0x00f6, 0x2079, 0x0050,
+	0x7044, 0xd084, 0x01c0, 0xc084, 0x7046, 0x7838, 0x7938, 0x910e,
+	0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de,
+	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b,
+	0x00fe, 0x009e, 0x0005, 0x782c, 0x9094, 0x0780, 0x1991, 0xd0a4,
+	0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x00e6, 0x2071, 0x0040,
+	0x712c, 0xd19c, 0x1148, 0x2009, 0x1830, 0x210c, 0x918a, 0x0020,
+	0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802,
+	0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x841a, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4, 0x19f0, 0x7838, 0x7938,
+	0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013,
+	0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x119b, 0x00ee, 0x00fe, 0x009e, 0x0005, 0x00f6, 0x2079, 0x0050,
+	0x7044, 0xd084, 0x01b8, 0xc084, 0x7046, 0x7838, 0x7938, 0x910e,
+	0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de,
+	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x119b,
+	0x00fe, 0x0005, 0x782c, 0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4,
+	0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x2048, 0x702c, 0xa802,
+	0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x841a, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6fe9, 0xd0a4, 0x1d70, 0x00d6, 0x2069,
+	0x0050, 0x693c, 0x2069, 0x1947, 0x6808, 0x690a, 0x2069, 0x19f9,
+	0x9102, 0x1118, 0x683c, 0x9005, 0x1328, 0x2001, 0x1948, 0x200c,
+	0x810d, 0x693e, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x7098, 0x908a,
+	0x0029, 0x1a0c, 0x0dd5, 0x9082, 0x001d, 0x001b, 0x6027, 0x1e00,
+	0x0005, 0x717d, 0x7103, 0x711f, 0x7149, 0x716c, 0x71ac, 0x71be,
+	0x711f, 0x7194, 0x70be, 0x70ec, 0x70bd, 0x0005, 0x00d6, 0x2069,
+	0x0200, 0x6804, 0x9005, 0x1180, 0x6808, 0x9005, 0x1518, 0x709b,
+	0x0028, 0x2069, 0x198e, 0x2d04, 0x7002, 0x080c, 0x74eb, 0x6028,
+	0x9085, 0x0600, 0x602a, 0x00b0, 0x709b, 0x0028, 0x2069, 0x198e,
+	0x2d04, 0x7002, 0x6028, 0x9085, 0x0600, 0x602a, 0x00e6, 0x0036,
+	0x0046, 0x0056, 0x2071, 0x1a61, 0x080c, 0x1abb, 0x005e, 0x004e,
+	0x003e, 0x00ee, 0x00de, 0x0005, 0x00d6, 0x2069, 0x0200, 0x6804,
+	0x9005, 0x1178, 0x6808, 0x9005, 0x1160, 0x709b, 0x0028, 0x2069,
+	0x198e, 0x2d04, 0x7002, 0x080c, 0x7586, 0x6028, 0x9085, 0x0600,
+	0x602a, 0x00de, 0x0005, 0x0006, 0x2001, 0x0090, 0x080c, 0x2cfc,
+	0x000e, 0x6124, 0xd1e4, 0x1190, 0x080c, 0x722b, 0xd1d4, 0x1160,
+	0xd1dc, 0x1138, 0xd1cc, 0x0150, 0x709b, 0x0020, 0x080c, 0x722b,
+	0x0028, 0x709b, 0x001d, 0x0010, 0x709b, 0x001f, 0x0005, 0x2001,
+	0x0088, 0x080c, 0x2cfc, 0x6124, 0xd1cc, 0x11e8, 0xd1dc, 0x11c0,
+	0xd1e4, 0x1198, 0x9184, 0x1e00, 0x11d8, 0x080c, 0x1ae0, 0x60e3,
+	0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c, 0x73df, 0x2001, 0x0080,
+	0x080c, 0x2cfc, 0x709b, 0x0028, 0x0058, 0x709b, 0x001e, 0x0040,
+	0x709b, 0x001d, 0x0028, 0x709b, 0x0020, 0x0010, 0x709b, 0x001f,
+	0x0005, 0x080c, 0x1ae0, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e,
+	0x080c, 0x73df, 0x2001, 0x0080, 0x080c, 0x2cfc, 0x6124, 0xd1d4,
+	0x1180, 0xd1dc, 0x1158, 0xd1e4, 0x1130, 0x9184, 0x1e00, 0x1158,
+	0x709b, 0x0028, 0x0040, 0x709b, 0x001e, 0x0028, 0x709b, 0x001d,
+	0x0010, 0x709b, 0x001f, 0x0005, 0x2001, 0x00a0, 0x080c, 0x2cfc,
+	0x6124, 0xd1dc, 0x1138, 0xd1e4, 0x0138, 0x080c, 0x1ae0, 0x709b,
+	0x001e, 0x0010, 0x709b, 0x001d, 0x0005, 0x080c, 0x72ae, 0x6124,
+	0xd1dc, 0x1188, 0x080c, 0x722b, 0x0016, 0x080c, 0x1ae0, 0x001e,
+	0xd1d4, 0x1128, 0xd1e4, 0x0138, 0x709b, 0x001e, 0x0020, 0x709b,
+	0x001f, 0x080c, 0x722b, 0x0005, 0x0006, 0x2001, 0x00a0, 0x080c,
+	0x2cfc, 0x000e, 0x6124, 0xd1d4, 0x1160, 0xd1cc, 0x1150, 0xd1dc,
+	0x1128, 0xd1e4, 0x0140, 0x709b, 0x001e, 0x0028, 0x709b, 0x001d,
+	0x0010, 0x709b, 0x0021, 0x0005, 0x080c, 0x72ae, 0x6124, 0xd1d4,
 	0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x709b, 0x001e, 0x0028,
-	0x709b, 0x001d, 0x0010, 0x709b, 0x0021, 0x0005, 0x080c, 0x72a0,
-	0x6124, 0xd1d4, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x709b,
-	0x001e, 0x0028, 0x709b, 0x001d, 0x0010, 0x709b, 0x001f, 0x0005,
-	0x0006, 0x2001, 0x0090, 0x080c, 0x2cf1, 0x000e, 0x6124, 0xd1d4,
-	0x1178, 0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0158, 0x709b,
-	0x001e, 0x0040, 0x709b, 0x001d, 0x0028, 0x709b, 0x0020, 0x0010,
-	0x709b, 0x001f, 0x0005, 0x0016, 0x00c6, 0x00d6, 0x00e6, 0x0126,
-	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2091, 0x8000,
-	0x080c, 0x73a5, 0x11d8, 0x2001, 0x180c, 0x200c, 0xd1b4, 0x01b0,
-	0xc1b4, 0x2102, 0x6027, 0x0200, 0x080c, 0x2c3a, 0x6024, 0xd0cc,
-	0x0148, 0x2001, 0x00a0, 0x080c, 0x2cf1, 0x080c, 0x768d, 0x080c,
-	0x6023, 0x0428, 0x6028, 0xc0cd, 0x602a, 0x0408, 0x080c, 0x73bf,
-	0x0150, 0x080c, 0x73b6, 0x1138, 0x2001, 0x0001, 0x080c, 0x27ec,
-	0x080c, 0x737d, 0x00a0, 0x080c, 0x729d, 0x0178, 0x2001, 0x0001,
-	0x080c, 0x27ec, 0x7098, 0x9086, 0x001e, 0x0120, 0x7098, 0x9086,
-	0x0022, 0x1118, 0x709b, 0x0025, 0x0010, 0x709b, 0x0021, 0x012e,
-	0x00ee, 0x00de, 0x00ce, 0x001e, 0x0005, 0x0026, 0x2011, 0x722e,
-	0x080c, 0x85b6, 0x002e, 0x0016, 0x0026, 0x2009, 0x0064, 0x2011,
-	0x722e, 0x080c, 0x85ad, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00f6,
-	0x0016, 0x080c, 0xa274, 0x2071, 0x1800, 0x080c, 0x71cb, 0x001e,
-	0x00fe, 0x00ee, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6,
-	0x00e6, 0x00f6, 0x0126, 0x080c, 0xa274, 0x2061, 0x0100, 0x2069,
-	0x0140, 0x2071, 0x1800, 0x2091, 0x8000, 0x6028, 0xc09c, 0x602a,
-	0x2011, 0x0003, 0x080c, 0xa654, 0x2011, 0x0002, 0x080c, 0xa65e,
-	0x080c, 0xa541, 0x080c, 0x8562, 0x0036, 0x901e, 0x080c, 0xa5b7,
-	0x003e, 0x60e3, 0x0000, 0x080c, 0xea0a, 0x080c, 0xea25, 0x2009,
-	0x0004, 0x080c, 0x2c40, 0x080c, 0x2b5b, 0x2001, 0x1800, 0x2003,
-	0x0004, 0x6027, 0x0008, 0x2011, 0x722e, 0x080c, 0x85b6, 0x080c,
-	0x73bf, 0x0118, 0x9006, 0x080c, 0x2cf1, 0x080c, 0x0bae, 0x2001,
-	0x0001, 0x080c, 0x27ec, 0x012e, 0x00fe, 0x00ee, 0x00de, 0x00ce,
-	0x003e, 0x002e, 0x001e, 0x0005, 0x0026, 0x00e6, 0x2011, 0x723b,
-	0x2071, 0x19f9, 0x701c, 0x9206, 0x1118, 0x7018, 0x9005, 0x0110,
-	0x9085, 0x0001, 0x00ee, 0x002e, 0x0005, 0x6020, 0xd09c, 0x0005,
-	0x6800, 0x9084, 0xfffe, 0x9086, 0x00c0, 0x0170, 0x2001, 0x00c0,
-	0x080c, 0x2cf1, 0x0156, 0x20a9, 0x002d, 0x1d04, 0x72ad, 0x2091,
-	0x6000, 0x1f04, 0x72ad, 0x015e, 0x0005, 0x00c6, 0x00d6, 0x00e6,
-	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x769c,
-	0x2001, 0x196c, 0x2003, 0x0000, 0x9006, 0x709a, 0x60e2, 0x6886,
-	0x080c, 0x28b4, 0x9006, 0x080c, 0x2cf1, 0x080c, 0x5ee2, 0x6027,
-	0xffff, 0x602b, 0x182f, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6,
+	0x709b, 0x001d, 0x0010, 0x709b, 0x001f, 0x0005, 0x0006, 0x2001,
+	0x0090, 0x080c, 0x2cfc, 0x000e, 0x6124, 0xd1d4, 0x1178, 0xd1cc,
+	0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0158, 0x709b, 0x001e, 0x0040,
+	0x709b, 0x001d, 0x0028, 0x709b, 0x0020, 0x0010, 0x709b, 0x001f,
+	0x0005, 0x0016, 0x00c6, 0x00d6, 0x00e6, 0x0126, 0x2061, 0x0100,
+	0x2069, 0x0140, 0x2071, 0x1800, 0x2091, 0x8000, 0x080c, 0x73b3,
+	0x11d8, 0x2001, 0x180c, 0x200c, 0xd1b4, 0x01b0, 0xc1b4, 0x2102,
+	0x6027, 0x0200, 0x080c, 0x2c45, 0x6024, 0xd0cc, 0x0148, 0x2001,
+	0x00a0, 0x080c, 0x2cfc, 0x080c, 0x7699, 0x080c, 0x602d, 0x0428,
+	0x6028, 0xc0cd, 0x602a, 0x0408, 0x080c, 0x73cd, 0x0150, 0x080c,
+	0x73c4, 0x1138, 0x2001, 0x0001, 0x080c, 0x27f7, 0x080c, 0x738b,
+	0x00a0, 0x080c, 0x72ab, 0x0178, 0x2001, 0x0001, 0x080c, 0x27f7,
+	0x7098, 0x9086, 0x001e, 0x0120, 0x7098, 0x9086, 0x0022, 0x1118,
+	0x709b, 0x0025, 0x0010, 0x709b, 0x0021, 0x012e, 0x00ee, 0x00de,
+	0x00ce, 0x001e, 0x0005, 0x0026, 0x2011, 0x723c, 0x080c, 0x85d3,
+	0x002e, 0x0016, 0x0026, 0x2009, 0x0064, 0x2011, 0x723c, 0x080c,
+	0x85ca, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00f6, 0x0016, 0x080c,
+	0xa28f, 0x2071, 0x1800, 0x080c, 0x71d9, 0x001e, 0x00fe, 0x00ee,
+	0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x0126, 0x080c, 0xa28f, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071,
+	0x1800, 0x2091, 0x8000, 0x6028, 0xc09c, 0x602a, 0x2011, 0x0003,
+	0x080c, 0xa63e, 0x2011, 0x0002, 0x080c, 0xa648, 0x080c, 0xa552,
+	0x080c, 0x857f, 0x0036, 0x901e, 0x080c, 0xa5c8, 0x003e, 0x60e3,
+	0x0000, 0x080c, 0xea24, 0x080c, 0xea3f, 0x2009, 0x0004, 0x080c,
+	0x2c4b, 0x080c, 0x2b66, 0x2001, 0x1800, 0x2003, 0x0004, 0x6027,
+	0x0008, 0x2011, 0x723c, 0x080c, 0x85d3, 0x080c, 0x73cd, 0x0118,
+	0x9006, 0x080c, 0x2cfc, 0x080c, 0x0bae, 0x2001, 0x0001, 0x080c,
+	0x27f7, 0x012e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e,
+	0x001e, 0x0005, 0x0026, 0x00e6, 0x2011, 0x7249, 0x2071, 0x19f9,
+	0x701c, 0x9206, 0x1118, 0x7018, 0x9005, 0x0110, 0x9085, 0x0001,
+	0x00ee, 0x002e, 0x0005, 0x6020, 0xd09c, 0x0005, 0x6800, 0x9084,
+	0xfffe, 0x9086, 0x00c0, 0x0170, 0x2001, 0x00c0, 0x080c, 0x2cfc,
+	0x0156, 0x20a9, 0x002d, 0x1d04, 0x72bb, 0x2091, 0x6000, 0x1f04,
+	0x72bb, 0x015e, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
+	0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x76a8, 0x2001, 0x196c,
+	0x2003, 0x0000, 0x9006, 0x709a, 0x60e2, 0x6886, 0x080c, 0x28bf,
+	0x9006, 0x080c, 0x2cfc, 0x080c, 0x5eec, 0x6027, 0xffff, 0x602b,
+	0x182f, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2001, 0x197c,
+	0x200c, 0x9186, 0x0000, 0x0158, 0x9186, 0x0001, 0x0158, 0x9186,
+	0x0002, 0x0158, 0x9186, 0x0003, 0x0158, 0x0804, 0x737b, 0x709b,
+	0x0022, 0x0040, 0x709b, 0x0021, 0x0028, 0x709b, 0x0023, 0x0010,
+	0x709b, 0x0024, 0x60e3, 0x0000, 0x6887, 0x0001, 0x2001, 0x0001,
+	0x080c, 0x28bf, 0x0026, 0x080c, 0xadd0, 0x002e, 0x7000, 0x908e,
+	0x0004, 0x0118, 0x602b, 0x0028, 0x0010, 0x602b, 0x0020, 0x0156,
+	0x0126, 0x2091, 0x8000, 0x20a9, 0x0005, 0x6024, 0xd0ac, 0x0150,
+	0x012e, 0x015e, 0x080c, 0xd25a, 0x0118, 0x9006, 0x080c, 0x2d26,
+	0x0804, 0x7387, 0x6800, 0x9084, 0x00a1, 0xc0bd, 0x6802, 0x080c,
+	0x2c45, 0x6904, 0xd1d4, 0x1140, 0x2001, 0x0100, 0x080c, 0x2cfc,
+	0x1f04, 0x7325, 0x080c, 0x740a, 0x012e, 0x015e, 0x080c, 0x73c4,
+	0x01a8, 0x6044, 0x9005, 0x0168, 0x6050, 0x0006, 0x9085, 0x0020,
+	0x6052, 0x080c, 0x740a, 0x9006, 0x8001, 0x1df0, 0x000e, 0x6052,
+	0x0028, 0x6804, 0xd0d4, 0x1110, 0x080c, 0x740a, 0x080c, 0xd25a,
+	0x0118, 0x9006, 0x080c, 0x2d26, 0x0016, 0x0026, 0x7000, 0x908e,
+	0x0004, 0x0130, 0x2009, 0x00c8, 0x2011, 0x7249, 0x080c, 0x8591,
+	0x002e, 0x001e, 0x080c, 0x8411, 0x7034, 0xc085, 0x7036, 0x2001,
+	0x197c, 0x2003, 0x0004, 0x080c, 0x70a6, 0x080c, 0x73c4, 0x0138,
+	0x6804, 0xd0d4, 0x1120, 0xd0dc, 0x1100, 0x080c, 0x769e, 0x00ee,
+	0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
+	0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x8428, 0x080c, 0x841a,
+	0x080c, 0x76a8, 0x2001, 0x196c, 0x2003, 0x0000, 0x9006, 0x709a,
+	0x60e2, 0x6886, 0x080c, 0x28bf, 0x9006, 0x080c, 0x2cfc, 0x6043,
+	0x0090, 0x6043, 0x0010, 0x6027, 0xffff, 0x602b, 0x182f, 0x00ee,
+	0x00de, 0x00ce, 0x0005, 0x0006, 0x2001, 0x197b, 0x2004, 0x9086,
+	0xaaaa, 0x000e, 0x0005, 0x0006, 0x080c, 0x56e6, 0x9084, 0x0030,
+	0x9086, 0x0000, 0x000e, 0x0005, 0x0006, 0x080c, 0x56e6, 0x9084,
+	0x0030, 0x9086, 0x0030, 0x000e, 0x0005, 0x0006, 0x080c, 0x56e6,
+	0x9084, 0x0030, 0x9086, 0x0010, 0x000e, 0x0005, 0x0006, 0x080c,
+	0x56e6, 0x9084, 0x0030, 0x9086, 0x0020, 0x000e, 0x0005, 0x0036,
+	0x0016, 0x2001, 0x180c, 0x2004, 0x908c, 0x0013, 0x0180, 0x0020,
+	0x080c, 0x28df, 0x900e, 0x0028, 0x080c, 0x6981, 0x1dc8, 0x2009,
+	0x0002, 0x2019, 0x0028, 0x080c, 0x3197, 0x9006, 0x0019, 0x001e,
+	0x003e, 0x0005, 0x00e6, 0x2071, 0x180c, 0x2e04, 0x0130, 0x080c,
+	0xd253, 0x1128, 0x9085, 0x0010, 0x0010, 0x9084, 0xffef, 0x2072,
+	0x00ee, 0x0005, 0x6050, 0x0006, 0x60ec, 0x0006, 0x600c, 0x0006,
+	0x6004, 0x0006, 0x6028, 0x0006, 0x0016, 0x6138, 0x6050, 0x9084,
+	0xfbff, 0x9085, 0x2000, 0x6052, 0x613a, 0x20a9, 0x0012, 0x1d04,
+	0x741f, 0x2091, 0x6000, 0x1f04, 0x741f, 0x602f, 0x0100, 0x602f,
+	0x0000, 0x6050, 0x9085, 0x0400, 0x9084, 0xdfff, 0x6052, 0x613a,
+	0x001e, 0x602f, 0x0040, 0x602f, 0x0000, 0x000e, 0x602a, 0x000e,
+	0x6006, 0x000e, 0x600e, 0x000e, 0x60ee, 0x60e3, 0x0000, 0x6887,
+	0x0001, 0x2001, 0x0001, 0x080c, 0x28bf, 0x2001, 0x00a0, 0x0006,
+	0x080c, 0xd25a, 0x000e, 0x0130, 0x080c, 0x2d1a, 0x9006, 0x080c,
+	0x2d26, 0x0010, 0x080c, 0x2cfc, 0x000e, 0x6052, 0x6050, 0x0006,
+	0xc0e5, 0x6052, 0x00f6, 0x2079, 0x0100, 0x080c, 0x2bba, 0x00fe,
+	0x000e, 0x6052, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6,
 	0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800,
-	0x2001, 0x197c, 0x200c, 0x9186, 0x0000, 0x0158, 0x9186, 0x0001,
-	0x0158, 0x9186, 0x0002, 0x0158, 0x9186, 0x0003, 0x0158, 0x0804,
-	0x736d, 0x709b, 0x0022, 0x0040, 0x709b, 0x0021, 0x0028, 0x709b,
-	0x0023, 0x0010, 0x709b, 0x0024, 0x60e3, 0x0000, 0x6887, 0x0001,
-	0x2001, 0x0001, 0x080c, 0x28b4, 0x0026, 0x080c, 0xade2, 0x002e,
-	0x7000, 0x908e, 0x0004, 0x0118, 0x602b, 0x0028, 0x0010, 0x602b,
-	0x0020, 0x0156, 0x0126, 0x2091, 0x8000, 0x20a9, 0x0005, 0x6024,
-	0xd0ac, 0x0150, 0x012e, 0x015e, 0x080c, 0xd24a, 0x0118, 0x9006,
-	0x080c, 0x2d1b, 0x0804, 0x7379, 0x6800, 0x9084, 0x00a1, 0xc0bd,
-	0x6802, 0x080c, 0x2c3a, 0x6904, 0xd1d4, 0x1140, 0x2001, 0x0100,
-	0x080c, 0x2cf1, 0x1f04, 0x7317, 0x080c, 0x73fc, 0x012e, 0x015e,
-	0x080c, 0x73b6, 0x01a8, 0x6044, 0x9005, 0x0168, 0x6050, 0x0006,
-	0x9085, 0x0020, 0x6052, 0x080c, 0x73fc, 0x9006, 0x8001, 0x1df0,
-	0x000e, 0x6052, 0x0028, 0x6804, 0xd0d4, 0x1110, 0x080c, 0x73fc,
-	0x080c, 0xd24a, 0x0118, 0x9006, 0x080c, 0x2d1b, 0x0016, 0x0026,
-	0x7000, 0x908e, 0x0004, 0x0130, 0x2009, 0x00c8, 0x2011, 0x723b,
-	0x080c, 0x8574, 0x002e, 0x001e, 0x080c, 0x83f4, 0x7034, 0xc085,
-	0x7036, 0x2001, 0x197c, 0x2003, 0x0004, 0x080c, 0x7098, 0x080c,
-	0x73b6, 0x0138, 0x6804, 0xd0d4, 0x1120, 0xd0dc, 0x1100, 0x080c,
-	0x7692, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6,
-	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x840b,
-	0x080c, 0x83fd, 0x080c, 0x769c, 0x2001, 0x196c, 0x2003, 0x0000,
-	0x9006, 0x709a, 0x60e2, 0x6886, 0x080c, 0x28b4, 0x9006, 0x080c,
-	0x2cf1, 0x6043, 0x0090, 0x6043, 0x0010, 0x6027, 0xffff, 0x602b,
-	0x182f, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x0006, 0x2001, 0x197b,
-	0x2004, 0x9086, 0xaaaa, 0x000e, 0x0005, 0x0006, 0x080c, 0x56dc,
-	0x9084, 0x0030, 0x9086, 0x0000, 0x000e, 0x0005, 0x0006, 0x080c,
-	0x56dc, 0x9084, 0x0030, 0x9086, 0x0030, 0x000e, 0x0005, 0x0006,
-	0x080c, 0x56dc, 0x9084, 0x0030, 0x9086, 0x0010, 0x000e, 0x0005,
-	0x0006, 0x080c, 0x56dc, 0x9084, 0x0030, 0x9086, 0x0020, 0x000e,
-	0x0005, 0x0036, 0x0016, 0x2001, 0x180c, 0x2004, 0x908c, 0x0013,
-	0x0180, 0x0020, 0x080c, 0x28d4, 0x900e, 0x0028, 0x080c, 0x6973,
-	0x1dc8, 0x2009, 0x0002, 0x2019, 0x0028, 0x080c, 0x318c, 0x9006,
-	0x0019, 0x001e, 0x003e, 0x0005, 0x00e6, 0x2071, 0x180c, 0x2e04,
-	0x0130, 0x080c, 0xd243, 0x1128, 0x9085, 0x0010, 0x0010, 0x9084,
-	0xffef, 0x2072, 0x00ee, 0x0005, 0x6050, 0x0006, 0x60ec, 0x0006,
-	0x600c, 0x0006, 0x6004, 0x0006, 0x6028, 0x0006, 0x0016, 0x6138,
-	0x6050, 0x9084, 0xfbff, 0x9085, 0x2000, 0x6052, 0x613a, 0x20a9,
-	0x0012, 0x1d04, 0x7411, 0x2091, 0x6000, 0x1f04, 0x7411, 0x602f,
-	0x0100, 0x602f, 0x0000, 0x6050, 0x9085, 0x0400, 0x9084, 0xdfff,
-	0x6052, 0x613a, 0x001e, 0x602f, 0x0040, 0x602f, 0x0000, 0x000e,
-	0x602a, 0x000e, 0x6006, 0x000e, 0x600e, 0x000e, 0x60ee, 0x60e3,
-	0x0000, 0x6887, 0x0001, 0x2001, 0x0001, 0x080c, 0x28b4, 0x2001,
-	0x00a0, 0x0006, 0x080c, 0xd24a, 0x000e, 0x0130, 0x080c, 0x2d0f,
-	0x9006, 0x080c, 0x2d1b, 0x0010, 0x080c, 0x2cf1, 0x000e, 0x6052,
-	0x6050, 0x0006, 0xc0e5, 0x6052, 0x00f6, 0x2079, 0x0100, 0x080c,
-	0x2baf, 0x00fe, 0x000e, 0x6052, 0x0005, 0x0156, 0x0016, 0x0026,
-	0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140,
-	0x2071, 0x1800, 0x6020, 0x9084, 0x0080, 0x0138, 0x2001, 0x180c,
-	0x200c, 0xc1c5, 0x2102, 0x0804, 0x74d1, 0x2001, 0x180c, 0x200c,
-	0xc1c4, 0x2102, 0x6028, 0x9084, 0xe1ff, 0x602a, 0x6027, 0x0200,
-	0x2001, 0x0090, 0x080c, 0x2cf1, 0x20a9, 0x0366, 0x6024, 0xd0cc,
-	0x1518, 0x1d04, 0x747e, 0x2091, 0x6000, 0x1f04, 0x747e, 0x2011,
-	0x0003, 0x080c, 0xa654, 0x2011, 0x0002, 0x080c, 0xa65e, 0x080c,
-	0xa541, 0x901e, 0x080c, 0xa5b7, 0x2001, 0x00a0, 0x080c, 0x2cf1,
-	0x080c, 0x768d, 0x080c, 0x6023, 0x080c, 0xd24a, 0x0110, 0x080c,
-	0x0d45, 0x9085, 0x0001, 0x0498, 0x86ff, 0x1110, 0x080c, 0x1ad5,
-	0x60e3, 0x0000, 0x2001, 0x196c, 0x2004, 0x080c, 0x28b4, 0x60e2,
-	0x2001, 0x0080, 0x080c, 0x2cf1, 0x20a9, 0x0366, 0x6027, 0x1e00,
-	0x2009, 0x1e00, 0x080c, 0x2c3a, 0x6024, 0x910c, 0x0138, 0x1d04,
-	0x74b6, 0x2091, 0x6000, 0x1f04, 0x74b6, 0x0808, 0x6028, 0x9085,
-	0x1e00, 0x602a, 0x70b4, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008,
-	0x6886, 0x080c, 0xd24a, 0x0110, 0x080c, 0x0d45, 0x9006, 0x00ee,
-	0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156,
-	0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
-	0x2071, 0x1800, 0x7000, 0x9086, 0x0003, 0x1168, 0x2001, 0x020b,
-	0x2004, 0x9084, 0x5540, 0x9086, 0x5540, 0x1128, 0x2069, 0x1a78,
-	0x2d04, 0x8000, 0x206a, 0x2069, 0x0140, 0x6020, 0x9084, 0x00c0,
-	0x0120, 0x6884, 0x9005, 0x1904, 0x7544, 0x2001, 0x0088, 0x080c,
-	0x2cf1, 0x9006, 0x60e2, 0x6886, 0x080c, 0x28b4, 0x2069, 0x0200,
-	0x6804, 0x9005, 0x1118, 0x6808, 0x9005, 0x01c0, 0x6028, 0x9084,
-	0xfbff, 0x602a, 0x6027, 0x0400, 0x2069, 0x198e, 0x7000, 0x206a,
-	0x709b, 0x0026, 0x7003, 0x0001, 0x20a9, 0x0002, 0x1d04, 0x7526,
-	0x2091, 0x6000, 0x1f04, 0x7526, 0x0804, 0x7572, 0x2069, 0x0140,
-	0x20a9, 0x0384, 0x6027, 0x1e00, 0x2009, 0x1e00, 0x080c, 0x2c3a,
-	0x6024, 0x910c, 0x0508, 0x9084, 0x1a00, 0x11f0, 0x1d04, 0x7532,
-	0x2091, 0x6000, 0x1f04, 0x7532, 0x2011, 0x0003, 0x080c, 0xa654,
-	0x2011, 0x0002, 0x080c, 0xa65e, 0x080c, 0xa541, 0x901e, 0x080c,
-	0xa5b7, 0x2001, 0x00a0, 0x080c, 0x2cf1, 0x080c, 0x768d, 0x080c,
-	0x6023, 0x9085, 0x0001, 0x00b0, 0x2001, 0x0080, 0x080c, 0x2cf1,
-	0x2069, 0x0140, 0x60e3, 0x0000, 0x70b4, 0x9005, 0x1118, 0x6887,
-	0x0001, 0x0008, 0x6886, 0x2001, 0x196c, 0x2004, 0x080c, 0x28b4,
-	0x60e2, 0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e,
-	0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6,
-	0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x6020, 0x9084, 0x00c0,
-	0x01c8, 0x2011, 0x0003, 0x080c, 0xa654, 0x2011, 0x0002, 0x080c,
-	0xa65e, 0x080c, 0xa541, 0x901e, 0x080c, 0xa5b7, 0x2069, 0x0140,
-	0x2001, 0x00a0, 0x080c, 0x2cf1, 0x080c, 0x768d, 0x080c, 0x6023,
-	0x0804, 0x760d, 0x2001, 0x180c, 0x200c, 0xd1b4, 0x1160, 0xc1b5,
-	0x2102, 0x080c, 0x7223, 0x2069, 0x0140, 0x2001, 0x0080, 0x080c,
-	0x2cf1, 0x60e3, 0x0000, 0x2069, 0x0200, 0x6804, 0x9005, 0x1118,
-	0x6808, 0x9005, 0x0180, 0x6028, 0x9084, 0xfdff, 0x602a, 0x6027,
-	0x0200, 0x2069, 0x198e, 0x7000, 0x206a, 0x709b, 0x0027, 0x7003,
-	0x0001, 0x0804, 0x760d, 0x6027, 0x1e00, 0x2009, 0x1e00, 0x080c,
-	0x2c3a, 0x6024, 0x910c, 0x01c8, 0x9084, 0x1c00, 0x11b0, 0x1d04,
-	0x75cb, 0x0006, 0x0016, 0x00c6, 0x00d6, 0x00e6, 0x080c, 0x843c,
-	0x00ee, 0x00de, 0x00ce, 0x001e, 0x000e, 0x00e6, 0x2071, 0x19f9,
-	0x7018, 0x00ee, 0x9005, 0x19f8, 0x0500, 0x0026, 0x2011, 0x723b,
-	0x080c, 0x84dc, 0x2011, 0x722e, 0x080c, 0x85b6, 0x002e, 0x2069,
-	0x0140, 0x60e3, 0x0000, 0x70b4, 0x9005, 0x1118, 0x6887, 0x0001,
-	0x0008, 0x6886, 0x2001, 0x196c, 0x2004, 0x080c, 0x28b4, 0x60e2,
-	0x2001, 0x180c, 0x200c, 0xc1b4, 0x2102, 0x00ee, 0x00de, 0x00ce,
-	0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026,
-	0x0036, 0x0046, 0x00c6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800,
-	0x080c, 0xd243, 0x1904, 0x767b, 0x7130, 0xd184, 0x1170, 0x080c,
-	0x331b, 0x0138, 0xc18d, 0x7132, 0x2011, 0x1848, 0x2214, 0xd2ac,
-	0x1120, 0x7030, 0xd08c, 0x0904, 0x767b, 0x2011, 0x1848, 0x220c,
-	0xd1a4, 0x0538, 0x0016, 0x2019, 0x000e, 0x080c, 0xe543, 0x0156,
-	0x00b6, 0x20a9, 0x007f, 0x900e, 0x9186, 0x007e, 0x01a0, 0x9186,
-	0x0080, 0x0188, 0x080c, 0x6608, 0x1170, 0x2120, 0x9006, 0x0016,
-	0x2009, 0x000e, 0x080c, 0xe5cf, 0x2009, 0x0001, 0x2011, 0x0100,
-	0x080c, 0x86c6, 0x001e, 0x8108, 0x1f04, 0x7644, 0x00be, 0x015e,
-	0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009, 0x0002, 0x2019, 0x0004,
-	0x080c, 0x318c, 0x001e, 0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f,
-	0x900e, 0x080c, 0x6608, 0x1110, 0x080c, 0x603d, 0x8108, 0x1f04,
-	0x7671, 0x00be, 0x015e, 0x080c, 0x1ad5, 0x080c, 0xade2, 0x60e3,
-	0x0000, 0x080c, 0x6023, 0x080c, 0x72d7, 0x00ee, 0x00ce, 0x004e,
-	0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x2001, 0x197c, 0x2003,
-	0x0001, 0x0005, 0x2001, 0x197c, 0x2003, 0x0000, 0x0005, 0x2001,
-	0x197b, 0x2003, 0xaaaa, 0x0005, 0x2001, 0x197b, 0x2003, 0x0000,
-	0x0005, 0x2071, 0x18fa, 0x7003, 0x0000, 0x7007, 0x0000, 0x080c,
-	0x1018, 0x090c, 0x0dd5, 0xa8ab, 0xdcb0, 0x2900, 0x704e, 0x080c,
-	0x1018, 0x090c, 0x0dd5, 0xa8ab, 0xdcb0, 0x2900, 0x7052, 0xa867,
-	0x0000, 0xa86b, 0x0001, 0xa89f, 0x0000, 0x0005, 0x00e6, 0x2071,
-	0x0040, 0x6848, 0x9005, 0x1118, 0x9085, 0x0001, 0x04b0, 0x6840,
-	0x9005, 0x0150, 0x04a1, 0x6a50, 0x9200, 0x7002, 0x6854, 0x9101,
-	0x7006, 0x9006, 0x7012, 0x7016, 0x6850, 0x7002, 0x6854, 0x7006,
-	0x6858, 0x700a, 0x685c, 0x700e, 0x6840, 0x9005, 0x1110, 0x7012,
-	0x7016, 0x6848, 0x701a, 0x701c, 0x9085, 0x0040, 0x701e, 0x2001,
-	0x0019, 0x7036, 0x702b, 0x0001, 0x2001, 0x0004, 0x200c, 0x918c,
-	0xfff7, 0x918d, 0x8000, 0x2102, 0x00d6, 0x2069, 0x18fa, 0x6807,
-	0x0001, 0x00de, 0x080c, 0x7c79, 0x9006, 0x00ee, 0x0005, 0x900e,
-	0x0156, 0x20a9, 0x0006, 0x8003, 0x2011, 0x0100, 0x2214, 0x9296,
-	0x0008, 0x1110, 0x818d, 0x0010, 0x81f5, 0x3e08, 0x1f04, 0x7703,
-	0x015e, 0x0005, 0x2079, 0x0040, 0x2071, 0x18fa, 0x7004, 0x0002,
-	0x7722, 0x7723, 0x775a, 0x77b5, 0x78c5, 0x7720, 0x7720, 0x78ef,
-	0x080c, 0x0dd5, 0x0005, 0x2079, 0x0040, 0x782c, 0x908c, 0x0780,
-	0x190c, 0x7d5b, 0xd0a4, 0x01f0, 0x7824, 0x2048, 0x9006, 0xa802,
-	0xa806, 0xa864, 0x9084, 0x00ff, 0x908a, 0x0040, 0x0608, 0x00b8,
-	0x2001, 0x1800, 0x200c, 0x9186, 0x0003, 0x1160, 0x7104, 0x9186,
-	0x0004, 0x0140, 0x9186, 0x0007, 0x0128, 0x9186, 0x0003, 0x19e8,
-	0x080c, 0x77b5, 0x782c, 0xd09c, 0x090c, 0x7c79, 0x0005, 0x9082,
-	0x005a, 0x1218, 0x2100, 0x003b, 0x0c18, 0x080c, 0x77eb, 0x0c90,
-	0x00e3, 0x08f0, 0x0005, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb,
-	0x77eb, 0x77eb, 0x77eb, 0x780d, 0x77eb, 0x77eb, 0x77eb, 0x77eb,
-	0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb,
-	0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77f7,
-	0x77eb, 0x79e0, 0x77eb, 0x77eb, 0x77eb, 0x780d, 0x77eb, 0x77f7,
-	0x7a21, 0x7a62, 0x7aa9, 0x7abd, 0x77eb, 0x77eb, 0x780d, 0x77f7,
-	0x7821, 0x77eb, 0x7899, 0x7b68, 0x7b83, 0x77eb, 0x780d, 0x77eb,
-	0x7821, 0x77eb, 0x77eb, 0x788f, 0x7b83, 0x77eb, 0x77eb, 0x77eb,
-	0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x7835, 0x77eb,
-	0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb,
-	0x7cff, 0x77eb, 0x7ca9, 0x77eb, 0x7ca9, 0x77eb, 0x784a, 0x77eb,
-	0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x77eb, 0x2079, 0x0040, 0x7004,
-	0x9086, 0x0003, 0x1198, 0x782c, 0x080c, 0x7ca2, 0xd0a4, 0x0170,
+	0x6020, 0x9084, 0x0080, 0x0138, 0x2001, 0x180c, 0x200c, 0xc1c5,
+	0x2102, 0x0804, 0x74dd, 0x2001, 0x180c, 0x200c, 0xc1c4, 0x2102,
+	0x6028, 0x9084, 0xe1ff, 0x602a, 0x6027, 0x0200, 0x2001, 0x0090,
+	0x080c, 0x2cfc, 0x20a9, 0x0366, 0x6024, 0xd0cc, 0x1518, 0x1d04,
+	0x748c, 0x2091, 0x6000, 0x1f04, 0x748c, 0x2011, 0x0003, 0x080c,
+	0xa63e, 0x2011, 0x0002, 0x080c, 0xa648, 0x080c, 0xa552, 0x901e,
+	0x080c, 0xa5c8, 0x2001, 0x00a0, 0x080c, 0x2cfc, 0x080c, 0x7699,
+	0x080c, 0x602d, 0x080c, 0xd25a, 0x0110, 0x080c, 0x0d45, 0x9085,
+	0x0001, 0x0488, 0x080c, 0x1ae0, 0x60e3, 0x0000, 0x2001, 0x196c,
+	0x2004, 0x080c, 0x28bf, 0x60e2, 0x2001, 0x0080, 0x080c, 0x2cfc,
+	0x20a9, 0x0366, 0x6027, 0x1e00, 0x2009, 0x1e00, 0x080c, 0x2c45,
+	0x6024, 0x910c, 0x0138, 0x1d04, 0x74c2, 0x2091, 0x6000, 0x1f04,
+	0x74c2, 0x0818, 0x6028, 0x9085, 0x1e00, 0x602a, 0x70b4, 0x9005,
+	0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x080c, 0xd25a, 0x0110,
+	0x080c, 0x0d45, 0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e,
+	0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6,
+	0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x7000, 0x9086,
+	0x0003, 0x1168, 0x2001, 0x020b, 0x2004, 0x9084, 0x5540, 0x9086,
+	0x5540, 0x1128, 0x2069, 0x1a78, 0x2d04, 0x8000, 0x206a, 0x2069,
+	0x0140, 0x6020, 0x9084, 0x00c0, 0x0120, 0x6884, 0x9005, 0x1904,
+	0x7550, 0x2001, 0x0088, 0x080c, 0x2cfc, 0x9006, 0x60e2, 0x6886,
+	0x080c, 0x28bf, 0x2069, 0x0200, 0x6804, 0x9005, 0x1118, 0x6808,
+	0x9005, 0x01c0, 0x6028, 0x9084, 0xfbff, 0x602a, 0x6027, 0x0400,
+	0x2069, 0x198e, 0x7000, 0x206a, 0x709b, 0x0026, 0x7003, 0x0001,
+	0x20a9, 0x0002, 0x1d04, 0x7532, 0x2091, 0x6000, 0x1f04, 0x7532,
+	0x0804, 0x757e, 0x2069, 0x0140, 0x20a9, 0x0384, 0x6027, 0x1e00,
+	0x2009, 0x1e00, 0x080c, 0x2c45, 0x6024, 0x910c, 0x0508, 0x9084,
+	0x1a00, 0x11f0, 0x1d04, 0x753e, 0x2091, 0x6000, 0x1f04, 0x753e,
+	0x2011, 0x0003, 0x080c, 0xa63e, 0x2011, 0x0002, 0x080c, 0xa648,
+	0x080c, 0xa552, 0x901e, 0x080c, 0xa5c8, 0x2001, 0x00a0, 0x080c,
+	0x2cfc, 0x080c, 0x7699, 0x080c, 0x602d, 0x9085, 0x0001, 0x00b0,
+	0x2001, 0x0080, 0x080c, 0x2cfc, 0x2069, 0x0140, 0x60e3, 0x0000,
+	0x70b4, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001,
+	0x196c, 0x2004, 0x080c, 0x28bf, 0x60e2, 0x9006, 0x00ee, 0x00de,
+	0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016,
+	0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071,
+	0x1800, 0x6020, 0x9084, 0x00c0, 0x01c8, 0x2011, 0x0003, 0x080c,
+	0xa63e, 0x2011, 0x0002, 0x080c, 0xa648, 0x080c, 0xa552, 0x901e,
+	0x080c, 0xa5c8, 0x2069, 0x0140, 0x2001, 0x00a0, 0x080c, 0x2cfc,
+	0x080c, 0x7699, 0x080c, 0x602d, 0x0804, 0x7619, 0x2001, 0x180c,
+	0x200c, 0xd1b4, 0x1160, 0xc1b5, 0x2102, 0x080c, 0x7231, 0x2069,
+	0x0140, 0x2001, 0x0080, 0x080c, 0x2cfc, 0x60e3, 0x0000, 0x2069,
+	0x0200, 0x6804, 0x9005, 0x1118, 0x6808, 0x9005, 0x0180, 0x6028,
+	0x9084, 0xfdff, 0x602a, 0x6027, 0x0200, 0x2069, 0x198e, 0x7000,
+	0x206a, 0x709b, 0x0027, 0x7003, 0x0001, 0x0804, 0x7619, 0x6027,
+	0x1e00, 0x2009, 0x1e00, 0x080c, 0x2c45, 0x6024, 0x910c, 0x01c8,
+	0x9084, 0x1c00, 0x11b0, 0x1d04, 0x75d7, 0x0006, 0x0016, 0x00c6,
+	0x00d6, 0x00e6, 0x080c, 0x8459, 0x00ee, 0x00de, 0x00ce, 0x001e,
+	0x000e, 0x00e6, 0x2071, 0x19f9, 0x7070, 0x00ee, 0x9005, 0x19f8,
+	0x0400, 0x0026, 0x2011, 0x7249, 0x080c, 0x84f9, 0x2011, 0x723c,
+	0x080c, 0x85d3, 0x002e, 0x2069, 0x0140, 0x60e3, 0x0000, 0x70b4,
+	0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001, 0x196c,
+	0x2004, 0x080c, 0x28bf, 0x60e2, 0x2001, 0x180c, 0x200c, 0xc1b4,
+	0x2102, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x0046, 0x00c6, 0x00e6,
+	0x2061, 0x0100, 0x2071, 0x1800, 0x080c, 0xd253, 0x1904, 0x7687,
+	0x7130, 0xd184, 0x1170, 0x080c, 0x3326, 0x0138, 0xc18d, 0x7132,
+	0x2011, 0x1848, 0x2214, 0xd2ac, 0x1120, 0x7030, 0xd08c, 0x0904,
+	0x7687, 0x2011, 0x1848, 0x220c, 0xd1a4, 0x0538, 0x0016, 0x2019,
+	0x000e, 0x080c, 0xe55d, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e,
+	0x9186, 0x007e, 0x01a0, 0x9186, 0x0080, 0x0188, 0x080c, 0x6616,
+	0x1170, 0x2120, 0x9006, 0x0016, 0x2009, 0x000e, 0x080c, 0xe5e9,
+	0x2009, 0x0001, 0x2011, 0x0100, 0x080c, 0x86e3, 0x001e, 0x8108,
+	0x1f04, 0x7650, 0x00be, 0x015e, 0x001e, 0xd1ac, 0x1148, 0x0016,
+	0x2009, 0x0002, 0x2019, 0x0004, 0x080c, 0x3197, 0x001e, 0x0078,
+	0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x6616, 0x1110,
+	0x080c, 0x6047, 0x8108, 0x1f04, 0x767d, 0x00be, 0x015e, 0x080c,
+	0x1ae0, 0x080c, 0xadd0, 0x60e3, 0x0000, 0x080c, 0x602d, 0x080c,
+	0x72e5, 0x00ee, 0x00ce, 0x004e, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x0005, 0x2001, 0x197c, 0x2003, 0x0001, 0x0005, 0x2001, 0x197c,
+	0x2003, 0x0000, 0x0005, 0x2001, 0x197b, 0x2003, 0xaaaa, 0x0005,
+	0x2001, 0x197b, 0x2003, 0x0000, 0x0005, 0x2071, 0x18fa, 0x7003,
+	0x0000, 0x7007, 0x0000, 0x080c, 0x1018, 0x090c, 0x0dd5, 0xa8ab,
+	0xdcb0, 0x2900, 0x704e, 0x080c, 0x1018, 0x090c, 0x0dd5, 0xa8ab,
+	0xdcb0, 0x2900, 0x7052, 0xa867, 0x0000, 0xa86b, 0x0001, 0xa89f,
+	0x0000, 0x0005, 0x00e6, 0x2071, 0x0040, 0x6848, 0x9005, 0x1118,
+	0x9085, 0x0001, 0x04b0, 0x6840, 0x9005, 0x0150, 0x04a1, 0x6a50,
+	0x9200, 0x7002, 0x6854, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016,
+	0x6850, 0x7002, 0x6854, 0x7006, 0x6858, 0x700a, 0x685c, 0x700e,
+	0x6840, 0x9005, 0x1110, 0x7012, 0x7016, 0x6848, 0x701a, 0x701c,
+	0x9085, 0x0040, 0x701e, 0x2001, 0x0019, 0x7036, 0x702b, 0x0001,
+	0x2001, 0x0004, 0x200c, 0x918c, 0xfff7, 0x918d, 0x8000, 0x2102,
+	0x00d6, 0x2069, 0x18fa, 0x6807, 0x0001, 0x00de, 0x080c, 0x7c86,
+	0x9006, 0x00ee, 0x0005, 0x900e, 0x0156, 0x20a9, 0x0006, 0x8003,
+	0x2011, 0x0100, 0x2214, 0x9296, 0x0008, 0x1110, 0x818d, 0x0010,
+	0x81f5, 0x3e08, 0x1f04, 0x770f, 0x015e, 0x0005, 0x2079, 0x0040,
+	0x2071, 0x18fa, 0x7004, 0x0002, 0x772e, 0x772f, 0x7767, 0x77c2,
+	0x78d2, 0x772c, 0x772c, 0x78fc, 0x080c, 0x0dd5, 0x0005, 0x2079,
+	0x0040, 0x782c, 0x908c, 0x0780, 0x190c, 0x7d68, 0xd0a4, 0x01f8,
 	0x7824, 0x2048, 0x9006, 0xa802, 0xa806, 0xa864, 0x9084, 0x00ff,
-	0x908a, 0x001a, 0x1210, 0x002b, 0x0c50, 0x00e9, 0x080c, 0x7c79,
-	0x0005, 0x77eb, 0x77f7, 0x79cc, 0x77eb, 0x77f7, 0x77eb, 0x77f7,
-	0x77f7, 0x77eb, 0x77f7, 0x79cc, 0x77f7, 0x77f7, 0x77f7, 0x77f7,
-	0x77f7, 0x77eb, 0x77f7, 0x79cc, 0x77eb, 0x77eb, 0x77f7, 0x77eb,
-	0x77eb, 0x77eb, 0x77f7, 0x00e6, 0x2071, 0x18fa, 0x2009, 0x0400,
-	0x0071, 0x00ee, 0x0005, 0x2009, 0x1000, 0x0049, 0x0005, 0x2009,
-	0x2000, 0x0029, 0x0005, 0x2009, 0x0800, 0x0009, 0x0005, 0x7007,
-	0x0001, 0xa868, 0x9084, 0x00ff, 0x9105, 0xa86a, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x6c86, 0x012e, 0x0005, 0xa864, 0x8007, 0x9084,
-	0x00ff, 0x0d08, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x796e,
-	0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x796e,
-	0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0968, 0x8001, 0x1120,
-	0x7007, 0x0001, 0x0804, 0x7989, 0x7007, 0x0003, 0x7012, 0x2900,
-	0x7016, 0x701a, 0x704b, 0x7989, 0x0005, 0xa864, 0x8007, 0x9084,
-	0x00ff, 0x0904, 0x77f3, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804,
-	0x79a5, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b,
-	0x79a5, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x9086, 0x0001,
-	0x1904, 0x77f3, 0x7007, 0x0001, 0x2009, 0x1834, 0x210c, 0x81ff,
-	0x11a8, 0xa868, 0x9084, 0x00ff, 0xa86a, 0xa883, 0x0000, 0x080c,
-	0x62b7, 0x1108, 0x0005, 0x0126, 0x2091, 0x8000, 0xa867, 0x0139,
-	0xa87a, 0xa982, 0x080c, 0x6c86, 0x012e, 0x0ca0, 0xa994, 0x9186,
-	0x0071, 0x0d38, 0x9186, 0x0064, 0x0d20, 0x9186, 0x007c, 0x0d08,
-	0x9186, 0x0028, 0x09f0, 0x9186, 0x0038, 0x09d8, 0x9186, 0x0078,
-	0x09c0, 0x9186, 0x005f, 0x09a8, 0x9186, 0x0056, 0x0990, 0xa897,
-	0x4005, 0xa89b, 0x0001, 0x2001, 0x0030, 0x900e, 0x08a0, 0xa87c,
-	0x9084, 0x00c0, 0x9086, 0x00c0, 0x1120, 0x7007, 0x0001, 0x0804,
-	0x7b9a, 0x2900, 0x7016, 0x701a, 0x20a9, 0x0004, 0xa860, 0x20e0,
-	0xa85c, 0x9080, 0x0030, 0x2098, 0x7050, 0x2040, 0xa060, 0x20e8,
-	0xa05c, 0x9080, 0x0023, 0x20a0, 0x4003, 0xa888, 0x7012, 0x9082,
-	0x0401, 0x1a04, 0x77fb, 0xaab4, 0x928a, 0x0002, 0x1a04, 0x77fb,
-	0x82ff, 0x1138, 0xa8b8, 0xa9bc, 0x9105, 0x0118, 0x2001, 0x792c,
-	0x0018, 0x9280, 0x7922, 0x2005, 0x7056, 0x7010, 0x9015, 0x0904,
-	0x790d, 0x080c, 0x1018, 0x1118, 0x7007, 0x0004, 0x0005, 0x2900,
-	0x7022, 0x7054, 0x2060, 0xe000, 0xa866, 0x7050, 0x2040, 0xa95c,
-	0xe004, 0x9100, 0xa076, 0xa860, 0xa072, 0xe008, 0x920a, 0x1210,
-	0x900e, 0x2200, 0x7112, 0xe20c, 0x8003, 0x800b, 0x9296, 0x0004,
-	0x0108, 0x9108, 0xa17a, 0x810b, 0xa17e, 0x080c, 0x10e9, 0xa06c,
-	0x908e, 0x0100, 0x0170, 0x9086, 0x0200, 0x0118, 0x7007, 0x0007,
-	0x0005, 0x7020, 0x2048, 0x080c, 0x1031, 0x7014, 0x2048, 0x0804,
-	0x77fb, 0x7020, 0x2048, 0x7018, 0xa802, 0xa807, 0x0000, 0x2908,
-	0x2048, 0xa906, 0x711a, 0x0804, 0x78c5, 0x7014, 0x2048, 0x7007,
-	0x0001, 0xa8b4, 0x9005, 0x1128, 0xa8b8, 0xa9bc, 0x9105, 0x0108,
-	0x00b9, 0xa864, 0x9084, 0x00ff, 0x9086, 0x001e, 0x0904, 0x7b9a,
-	0x0804, 0x796e, 0x7924, 0x7928, 0x0002, 0x001d, 0x0007, 0x0004,
-	0x000a, 0x001b, 0x0005, 0x0006, 0x000a, 0x001d, 0x0005, 0x0004,
-	0x0076, 0x0066, 0xafb8, 0xaebc, 0xa804, 0x2050, 0xb0c0, 0xb0e2,
-	0xb0bc, 0xb0de, 0xb0b8, 0xb0d2, 0xb0b4, 0xb0ce, 0xb6da, 0xb7d6,
-	0xb0b0, 0xb0ca, 0xb0ac, 0xb0c6, 0xb0a8, 0xb0ba, 0xb0a4, 0xb0b6,
-	0xb6c2, 0xb7be, 0xb0a0, 0xb0b2, 0xb09c, 0xb0ae, 0xb098, 0xb0a2,
-	0xb094, 0xb09e, 0xb6aa, 0xb7a6, 0xb090, 0xb09a, 0xb08c, 0xb096,
-	0xb088, 0xb08a, 0xb084, 0xb086, 0xb692, 0xb78e, 0xb080, 0xb082,
-	0xb07c, 0xb07e, 0xb078, 0xb072, 0xb074, 0xb06e, 0xb67a, 0xb776,
-	0xb004, 0x9055, 0x1958, 0x006e, 0x007e, 0x0005, 0x2009, 0x1834,
-	0x210c, 0x81ff, 0x1178, 0x080c, 0x60b7, 0x1108, 0x0005, 0x080c,
-	0x6eb9, 0x0126, 0x2091, 0x8000, 0x080c, 0xce3e, 0x080c, 0x6c86,
-	0x012e, 0x0ca0, 0x080c, 0xd243, 0x1d70, 0x2001, 0x0028, 0x900e,
-	0x0c70, 0x2009, 0x1834, 0x210c, 0x81ff, 0x1188, 0xa888, 0x9005,
-	0x0188, 0xa883, 0x0000, 0x080c, 0x6147, 0x1108, 0x0005, 0xa87a,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6c86, 0x012e, 0x0cb8, 0x2001,
-	0x0028, 0x0ca8, 0x2001, 0x0000, 0x0c90, 0x2009, 0x1834, 0x210c,
-	0x81ff, 0x11d8, 0xa888, 0x9005, 0x01e0, 0xa883, 0x0000, 0xa87c,
-	0xd0f4, 0x0120, 0x080c, 0x6219, 0x1138, 0x0005, 0x9006, 0xa87a,
-	0x080c, 0x6194, 0x1108, 0x0005, 0x0126, 0x2091, 0x8000, 0xa87a,
-	0xa982, 0x080c, 0x6c86, 0x012e, 0x0cb0, 0x2001, 0x0028, 0x900e,
-	0x0c98, 0x2001, 0x0000, 0x0c80, 0x7018, 0xa802, 0x2908, 0x2048,
-	0xa906, 0x711a, 0x7010, 0x8001, 0x7012, 0x0118, 0x7007, 0x0003,
-	0x0030, 0x7014, 0x2048, 0x7007, 0x0001, 0x7048, 0x080f, 0x0005,
-	0x00b6, 0x7007, 0x0001, 0xa974, 0xa878, 0x9084, 0x00ff, 0x9096,
-	0x0004, 0x0540, 0x20a9, 0x0001, 0x9096, 0x0001, 0x0190, 0x900e,
-	0x20a9, 0x0800, 0x9096, 0x0002, 0x0160, 0x9005, 0x11d8, 0xa974,
-	0x080c, 0x6608, 0x11b8, 0x0066, 0xae80, 0x080c, 0x6718, 0x006e,
-	0x0088, 0x0046, 0x2011, 0x180c, 0x2224, 0xc484, 0x2412, 0x004e,
-	0x00c6, 0x080c, 0x6608, 0x1110, 0x080c, 0x6818, 0x8108, 0x1f04,
-	0x7a09, 0x00ce, 0xa87c, 0xd084, 0x1120, 0x080c, 0x1031, 0x00be,
-	0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x6c86, 0x012e, 0x00be,
-	0x0005, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x080c, 0x6977,
-	0x0580, 0x2061, 0x1a70, 0x6100, 0xd184, 0x0178, 0xa888, 0x9084,
-	0x00ff, 0x1550, 0x6000, 0xd084, 0x0520, 0x6004, 0x9005, 0x1538,
-	0x6003, 0x0000, 0x600b, 0x0000, 0x00c8, 0x2011, 0x0001, 0xa890,
-	0x9005, 0x1110, 0x2001, 0x001e, 0x8000, 0x6016, 0xa888, 0x9084,
-	0x00ff, 0x0178, 0x6006, 0xa888, 0x8007, 0x9084, 0x00ff, 0x0148,
-	0x600a, 0xa888, 0x8000, 0x1108, 0xc28d, 0x6202, 0x012e, 0x0804,
-	0x7c63, 0x012e, 0x0804, 0x7c5d, 0x012e, 0x0804, 0x7c57, 0x012e,
-	0x0804, 0x7c5a, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x080c,
-	0x6977, 0x05e0, 0x2061, 0x1a70, 0x6000, 0xd084, 0x05b8, 0x6204,
-	0x6308, 0xd08c, 0x1530, 0xac78, 0x9484, 0x0003, 0x0170, 0xa988,
-	0x918c, 0x00ff, 0x8001, 0x1120, 0x2100, 0x9210, 0x0620, 0x0028,
-	0x8001, 0x1508, 0x2100, 0x9212, 0x02f0, 0x9484, 0x000c, 0x0188,
-	0xa988, 0x810f, 0x918c, 0x00ff, 0x9082, 0x0004, 0x1120, 0x2100,
-	0x9318, 0x0288, 0x0030, 0x9082, 0x0004, 0x1168, 0x2100, 0x931a,
-	0x0250, 0xa890, 0x9005, 0x0110, 0x8000, 0x6016, 0x6206, 0x630a,
-	0x012e, 0x0804, 0x7c63, 0x012e, 0x0804, 0x7c60, 0x012e, 0x0804,
-	0x7c5d, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x2061, 0x1a70,
-	0x6300, 0xd38c, 0x1120, 0x6308, 0x8318, 0x0220, 0x630a, 0x012e,
-	0x0804, 0x7c71, 0x012e, 0x0804, 0x7c60, 0x00b6, 0x0126, 0x00c6,
-	0x2091, 0x8000, 0x7007, 0x0001, 0xa87c, 0xd0ac, 0x0148, 0x00c6,
-	0x2061, 0x1a70, 0x6000, 0x9084, 0xfcff, 0x6002, 0x00ce, 0x0440,
-	0xa888, 0x9005, 0x05d8, 0xa88c, 0x9065, 0x0598, 0x2001, 0x1834,
-	0x2004, 0x9005, 0x0118, 0x080c, 0xaea2, 0x0068, 0x6017, 0xf400,
-	0x605b, 0x0000, 0xa97c, 0xd1a4, 0x0110, 0xa980, 0x615a, 0x2009,
-	0x0041, 0x080c, 0xaeec, 0xa988, 0x918c, 0xff00, 0x9186, 0x2000,
-	0x1138, 0x0026, 0x900e, 0x2011, 0xfdff, 0x080c, 0x86c6, 0x002e,
-	0xa87c, 0xd0c4, 0x0148, 0x2061, 0x1a70, 0x6000, 0xd08c, 0x1120,
-	0x6008, 0x8000, 0x0208, 0x600a, 0x00ce, 0x012e, 0x00be, 0x0804,
-	0x7c63, 0x00ce, 0x012e, 0x00be, 0x0804, 0x7c5d, 0xa984, 0x9186,
-	0x002e, 0x0d30, 0x9186, 0x002d, 0x0d18, 0x9186, 0x0045, 0x0510,
-	0x9186, 0x002a, 0x1130, 0x2001, 0x180c, 0x200c, 0xc194, 0x2102,
-	0x08b8, 0x9186, 0x0020, 0x0158, 0x9186, 0x0029, 0x1d10, 0xa974,
-	0x080c, 0x6608, 0x1968, 0xb800, 0xc0e4, 0xb802, 0x0848, 0xa88c,
-	0x9065, 0x09b8, 0x6007, 0x0024, 0x2001, 0x1985, 0x2004, 0x601a,
-	0x0804, 0x7af8, 0xa88c, 0x9065, 0x0960, 0x00e6, 0xa890, 0x9075,
-	0x2001, 0x1834, 0x2004, 0x9005, 0x0150, 0x080c, 0xaea2, 0x8eff,
-	0x0118, 0x2e60, 0x080c, 0xaea2, 0x00ee, 0x0804, 0x7af8, 0x6024,
-	0xc0dc, 0xc0d5, 0x6026, 0x2e60, 0x6007, 0x003a, 0xa8a0, 0x9005,
-	0x0130, 0x6007, 0x003b, 0xa8a4, 0x602e, 0xa8a8, 0x6016, 0x6003,
-	0x0001, 0x080c, 0x90d9, 0x080c, 0x9687, 0x00ee, 0x0804, 0x7af8,
-	0x2061, 0x1a70, 0x6000, 0xd084, 0x0190, 0xd08c, 0x1904, 0x7c71,
-	0x0126, 0x2091, 0x8000, 0x6204, 0x8210, 0x0220, 0x6206, 0x012e,
-	0x0804, 0x7c71, 0x012e, 0xa883, 0x0016, 0x0804, 0x7c6a, 0xa883,
-	0x0007, 0x0804, 0x7c6a, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0130,
-	0x8001, 0x1138, 0x7007, 0x0001, 0x0069, 0x0005, 0x080c, 0x77f3,
-	0x0040, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b,
-	0x7b9a, 0x0005, 0x00b6, 0x00e6, 0x0126, 0x2091, 0x8000, 0x903e,
-	0x2061, 0x1800, 0x61d0, 0x81ff, 0x1904, 0x7c1c, 0x6130, 0xd194,
-	0x1904, 0x7c46, 0xa878, 0x2070, 0x9e82, 0x1cd0, 0x0a04, 0x7c10,
-	0x6068, 0x9e02, 0x1a04, 0x7c10, 0x7120, 0x9186, 0x0006, 0x1904,
-	0x7c02, 0x7010, 0x905d, 0x0904, 0x7c1c, 0xb800, 0xd0e4, 0x1904,
-	0x7c40, 0x2061, 0x1a70, 0x6100, 0x9184, 0x0301, 0x9086, 0x0001,
-	0x15a0, 0x7024, 0xd0dc, 0x1904, 0x7c49, 0xa883, 0x0000, 0xa803,
-	0x0000, 0x2908, 0x7014, 0x9005, 0x1198, 0x7116, 0xa87c, 0xd0f4,
-	0x1904, 0x7c4c, 0x080c, 0x56d8, 0xd09c, 0x1118, 0xa87c, 0xc0cc,
-	0xa87e, 0x2e60, 0x080c, 0x85e6, 0x012e, 0x00ee, 0x00be, 0x0005,
-	0x2048, 0xa800, 0x9005, 0x1de0, 0xa902, 0x2148, 0xa87c, 0xd0f4,
-	0x1904, 0x7c4c, 0x012e, 0x00ee, 0x00be, 0x0005, 0x012e, 0x00ee,
-	0xa883, 0x0006, 0x00be, 0x0804, 0x7c6a, 0xd184, 0x0db8, 0xd1c4,
-	0x1190, 0x00a0, 0xa974, 0x080c, 0x6608, 0x15d0, 0xb800, 0xd0e4,
-	0x15b8, 0x7120, 0x9186, 0x0007, 0x1118, 0xa883, 0x0002, 0x0490,
-	0xa883, 0x0008, 0x0478, 0xa883, 0x000e, 0x0460, 0xa883, 0x0017,
-	0x0448, 0xa883, 0x0035, 0x0430, 0x080c, 0x56dc, 0xd0fc, 0x01e8,
-	0xa878, 0x2070, 0x9e82, 0x1cd0, 0x02c0, 0x6068, 0x9e02, 0x12a8,
-	0x7120, 0x9186, 0x0006, 0x1188, 0x7010, 0x905d, 0x0170, 0xb800,
-	0xd0bc, 0x0158, 0x2039, 0x0001, 0x7000, 0x9086, 0x0007, 0x1904,
-	0x7ba6, 0x7003, 0x0002, 0x0804, 0x7ba6, 0xa883, 0x0028, 0x0010,
-	0xa883, 0x0029, 0x012e, 0x00ee, 0x00be, 0x0420, 0xa883, 0x002a,
-	0x0cc8, 0xa883, 0x0045, 0x0cb0, 0x2e60, 0x2019, 0x0002, 0x601b,
-	0x0014, 0x080c, 0xe155, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2009,
-	0x003e, 0x0058, 0x2009, 0x0004, 0x0040, 0x2009, 0x0006, 0x0028,
-	0x2009, 0x0016, 0x0010, 0x2009, 0x0001, 0xa884, 0x9084, 0xff00,
-	0x9105, 0xa886, 0x0126, 0x2091, 0x8000, 0x080c, 0x6c86, 0x012e,
-	0x0005, 0x080c, 0x1031, 0x0005, 0x00d6, 0x080c, 0x85dd, 0x00de,
-	0x0005, 0x00d6, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x0040,
-	0x702c, 0xd084, 0x01d8, 0x908c, 0x0780, 0x190c, 0x7d5b, 0xd09c,
-	0x11a8, 0x2071, 0x1800, 0x70c0, 0x90ea, 0x0020, 0x0278, 0x8001,
-	0x70c2, 0x702c, 0x2048, 0xa800, 0x702e, 0x9006, 0xa802, 0xa806,
-	0x2071, 0x0040, 0x2900, 0x7022, 0x702c, 0x0c28, 0x012e, 0x00ee,
-	0x00de, 0x0005, 0x0006, 0x9084, 0x0780, 0x190c, 0x7d5b, 0x000e,
-	0x0005, 0xa898, 0x9084, 0x0003, 0x05a8, 0x080c, 0xae1b, 0x05d8,
-	0x2900, 0x6016, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0035, 0x1138,
-	0x6008, 0xc0fd, 0x600a, 0x2001, 0x196a, 0x2004, 0x0098, 0xa8a0,
-	0x9084, 0x00ff, 0xa99c, 0x918c, 0xff00, 0x9105, 0xa99c, 0x918c,
-	0x00ff, 0x080c, 0x2840, 0x1540, 0x00b6, 0x080c, 0x6608, 0x2b00,
-	0x00be, 0x1510, 0x6012, 0x6023, 0x0001, 0x2009, 0x0040, 0xa864,
-	0x9084, 0x00ff, 0x9086, 0x0035, 0x0110, 0x2009, 0x0041, 0x080c,
-	0xaeec, 0x0005, 0xa87b, 0x0101, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x6c86, 0x012e, 0x0005, 0xa87b, 0x002c, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x6c86, 0x012e, 0x0005, 0xa87b, 0x0028, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x6c86, 0x012e, 0x080c, 0xae71, 0x0005, 0x00d6,
-	0x00c6, 0x0036, 0x0026, 0x0016, 0x00b6, 0x7007, 0x0001, 0xaa74,
-	0x9282, 0x0004, 0x1a04, 0x7d4c, 0xa97c, 0x9188, 0x1000, 0x2104,
-	0x905d, 0xb804, 0xd284, 0x0140, 0x05e8, 0x8007, 0x9084, 0x00ff,
-	0x9084, 0x0006, 0x1108, 0x04b0, 0x2b10, 0x080c, 0xae1b, 0x1118,
-	0x080c, 0xaebf, 0x05a8, 0x6212, 0xa874, 0x0002, 0x7d2a, 0x7d2f,
-	0x7d32, 0x7d38, 0x2019, 0x0002, 0x080c, 0xe543, 0x0060, 0x080c,
-	0xe4df, 0x0048, 0x2019, 0x0002, 0xa980, 0x080c, 0xe4fa, 0x0018,
-	0xa980, 0x080c, 0xe4df, 0x080c, 0xae71, 0xa887, 0x0000, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x6c86, 0x012e, 0x00be, 0x001e, 0x002e,
-	0x003e, 0x00ce, 0x00de, 0x0005, 0xa887, 0x0006, 0x0c80, 0xa887,
-	0x0002, 0x0c68, 0xa887, 0x0005, 0x0c50, 0xa887, 0x0004, 0x0c38,
-	0xa887, 0x0007, 0x0c20, 0x2091, 0x8000, 0x0e04, 0x7d5d, 0x0006,
-	0x0016, 0x2001, 0x8003, 0x0006, 0x0804, 0x0dde, 0x2001, 0x1834,
-	0x2004, 0x9005, 0x0005, 0x0005, 0x00f6, 0x2079, 0x0300, 0x2001,
-	0x0200, 0x200c, 0xc1e5, 0xc1dc, 0x2102, 0x2009, 0x0218, 0x210c,
-	0xd1ec, 0x1120, 0x080c, 0x157f, 0x00fe, 0x0005, 0x2001, 0x020d,
-	0x2003, 0x0020, 0x781f, 0x0300, 0x00fe, 0x0005, 0x781c, 0xd08c,
-	0x0904, 0x7ddd, 0x68c0, 0x90aa, 0x0005, 0x0a04, 0x83f4, 0x7d44,
-	0x7c40, 0x9584, 0x00f6, 0x1510, 0x9484, 0x7000, 0x0140, 0x908a,
-	0x2000, 0x1260, 0x9584, 0x0700, 0x8007, 0x0804, 0x7de4, 0x7000,
-	0x9084, 0xff00, 0x9086, 0x8100, 0x0da8, 0x00b0, 0x9484, 0x0fff,
-	0x1130, 0x7000, 0x9084, 0xff00, 0x9086, 0x8100, 0x11c0, 0x080c,
-	0xe9e2, 0x080c, 0x82e9, 0x7817, 0x0140, 0x00a8, 0x9584, 0x0076,
-	0x1118, 0x080c, 0x8347, 0x19c0, 0xd5a4, 0x0148, 0x0046, 0x0056,
-	0x080c, 0x7e3f, 0x080c, 0x2339, 0x005e, 0x004e, 0x0020, 0x080c,
-	0xe9e2, 0x7817, 0x0140, 0x080c, 0x73a5, 0x0168, 0x2001, 0x0111,
-	0x2004, 0xd08c, 0x0140, 0x6893, 0x0000, 0x2001, 0x0110, 0x2003,
-	0x0008, 0x2003, 0x0000, 0x080c, 0x7e20, 0x2001, 0x19ef, 0x2004,
-	0x9005, 0x090c, 0x9687, 0x0005, 0x0002, 0x7df6, 0x810b, 0x7ded,
-	0x7ded, 0x7ded, 0x7ded, 0x7ded, 0x7ded, 0x7817, 0x0140, 0x2001,
-	0x19ef, 0x2004, 0x9005, 0x090c, 0x9687, 0x0005, 0x7000, 0x908c,
-	0xff00, 0x9194, 0xf000, 0x810f, 0x9484, 0x0fff, 0x6892, 0x9286,
-	0x2000, 0x1150, 0x6800, 0x9086, 0x0001, 0x1118, 0x080c, 0x5739,
-	0x0070, 0x080c, 0x7e5f, 0x0058, 0x9286, 0x3000, 0x1118, 0x080c,
-	0x8046, 0x0028, 0x9286, 0x8000, 0x1110, 0x080c, 0x8219, 0x7817,
-	0x0140, 0x2001, 0x19ef, 0x2004, 0x9005, 0x090c, 0x9687, 0x0005,
-	0x2001, 0x1810, 0x2004, 0xd08c, 0x0178, 0x2001, 0x1800, 0x2004,
-	0x9086, 0x0003, 0x1148, 0x0026, 0x0036, 0x2011, 0x8048, 0x2518,
-	0x080c, 0x4b14, 0x003e, 0x002e, 0x0005, 0x0036, 0x0046, 0x0056,
-	0x00f6, 0x2079, 0x0200, 0x2019, 0xfffe, 0x7c30, 0x0050, 0x0036,
-	0x0046, 0x0056, 0x00f6, 0x2079, 0x0200, 0x7d44, 0x7c40, 0x2019,
-	0xffff, 0x2001, 0x1810, 0x2004, 0xd08c, 0x0160, 0x2001, 0x1800,
-	0x2004, 0x9086, 0x0003, 0x1130, 0x0026, 0x2011, 0x8048, 0x080c,
-	0x4b14, 0x002e, 0x00fe, 0x005e, 0x004e, 0x003e, 0x0005, 0x00b6,
-	0x00c6, 0x7010, 0x9084, 0xff00, 0x8007, 0x9096, 0x0001, 0x0120,
-	0x9096, 0x0023, 0x1904, 0x8017, 0x9186, 0x0023, 0x15c0, 0x080c,
-	0x82ae, 0x0904, 0x8017, 0x6120, 0x9186, 0x0001, 0x0150, 0x9186,
-	0x0004, 0x0138, 0x9186, 0x0008, 0x0120, 0x9186, 0x000a, 0x1904,
-	0x8017, 0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1130, 0x2009,
-	0x0015, 0x080c, 0xaeec, 0x0804, 0x8017, 0x908e, 0x0214, 0x0118,
-	0x908e, 0x0210, 0x1130, 0x2009, 0x0015, 0x080c, 0xaeec, 0x0804,
-	0x8017, 0x908e, 0x0100, 0x1904, 0x8017, 0x7034, 0x9005, 0x1904,
-	0x8017, 0x2009, 0x0016, 0x080c, 0xaeec, 0x0804, 0x8017, 0x9186,
-	0x0022, 0x1904, 0x8017, 0x7030, 0x908e, 0x0300, 0x1580, 0x68dc,
-	0xd0a4, 0x0528, 0xc0b5, 0x68de, 0x7100, 0x918c, 0x00ff, 0x697e,
-	0x7004, 0x6882, 0x00f6, 0x2079, 0x0100, 0x79e6, 0x78ea, 0x0006,
-	0x9084, 0x00ff, 0x0016, 0x2008, 0x080c, 0x2889, 0x7932, 0x7936,
-	0x001e, 0x000e, 0x00fe, 0x080c, 0x2840, 0x695e, 0x703c, 0x00e6,
-	0x2071, 0x0140, 0x7086, 0x2071, 0x1800, 0x70b6, 0x00ee, 0x7034,
-	0x9005, 0x1904, 0x8017, 0x2009, 0x0017, 0x0804, 0x7fc7, 0x908e,
-	0x0400, 0x1190, 0x7034, 0x9005, 0x1904, 0x8017, 0x080c, 0x73a5,
-	0x0120, 0x2009, 0x001d, 0x0804, 0x7fc7, 0x68dc, 0xc0a5, 0x68de,
-	0x2009, 0x0030, 0x0804, 0x7fc7, 0x908e, 0x0500, 0x1140, 0x7034,
-	0x9005, 0x1904, 0x8017, 0x2009, 0x0018, 0x0804, 0x7fc7, 0x908e,
-	0x2010, 0x1120, 0x2009, 0x0019, 0x0804, 0x7fc7, 0x908e, 0x2110,
-	0x1120, 0x2009, 0x001a, 0x0804, 0x7fc7, 0x908e, 0x5200, 0x1140,
-	0x7034, 0x9005, 0x1904, 0x8017, 0x2009, 0x001b, 0x0804, 0x7fc7,
-	0x908e, 0x5000, 0x1140, 0x7034, 0x9005, 0x1904, 0x8017, 0x2009,
-	0x001c, 0x0804, 0x7fc7, 0x908e, 0x1300, 0x1120, 0x2009, 0x0034,
-	0x0804, 0x7fc7, 0x908e, 0x1200, 0x1140, 0x7034, 0x9005, 0x1904,
-	0x8017, 0x2009, 0x0024, 0x0804, 0x7fc7, 0x908c, 0xff00, 0x918e,
-	0x2400, 0x1170, 0x2009, 0x002d, 0x2001, 0x1810, 0x2004, 0xd09c,
-	0x0904, 0x7fc7, 0x080c, 0xd924, 0x1904, 0x8017, 0x0804, 0x7fc5,
-	0x908c, 0xff00, 0x918e, 0x5300, 0x1120, 0x2009, 0x002a, 0x0804,
-	0x7fc7, 0x908e, 0x0f00, 0x1120, 0x2009, 0x0020, 0x0804, 0x7fc7,
-	0x908e, 0x6104, 0x1530, 0x2029, 0x0205, 0x2011, 0x026d, 0x8208,
-	0x2204, 0x9082, 0x0004, 0x8004, 0x8004, 0x20a8, 0x2011, 0x8015,
-	0x211c, 0x8108, 0x0046, 0x2124, 0x080c, 0x4b14, 0x004e, 0x8108,
-	0x0f04, 0x7f7b, 0x9186, 0x0280, 0x1d88, 0x2504, 0x8000, 0x202a,
-	0x2009, 0x0260, 0x0c58, 0x202b, 0x0000, 0x2009, 0x0023, 0x0804,
-	0x7fc7, 0x908e, 0x6000, 0x1120, 0x2009, 0x003f, 0x0804, 0x7fc7,
-	0x908e, 0x5400, 0x1138, 0x080c, 0x83a4, 0x1904, 0x8017, 0x2009,
-	0x0046, 0x04a8, 0x908e, 0x5500, 0x1148, 0x080c, 0x83cc, 0x1118,
-	0x2009, 0x0041, 0x0460, 0x2009, 0x0042, 0x0448, 0x908e, 0x7800,
-	0x1118, 0x2009, 0x0045, 0x0418, 0x908e, 0x1000, 0x1118, 0x2009,
-	0x004e, 0x00e8, 0x908e, 0x6300, 0x1118, 0x2009, 0x004a, 0x00b8,
-	0x908c, 0xff00, 0x918e, 0x5600, 0x1118, 0x2009, 0x004f, 0x0078,
-	0x908c, 0xff00, 0x918e, 0x5700, 0x1118, 0x2009, 0x0050, 0x0038,
-	0x2009, 0x001d, 0x6838, 0xd0d4, 0x0110, 0x2009, 0x004c, 0x0016,
-	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2840, 0x1904,
-	0x801a, 0x080c, 0x65a7, 0x1904, 0x801a, 0xbe12, 0xbd16, 0x001e,
-	0x0016, 0x080c, 0x73a5, 0x01c0, 0x68dc, 0xd08c, 0x1148, 0x7000,
-	0x9084, 0x00ff, 0x1188, 0x7004, 0x9084, 0xff00, 0x1168, 0x0040,
-	0x687c, 0x9606, 0x1148, 0x6880, 0x9506, 0x9084, 0xff00, 0x1120,
-	0x9584, 0x00ff, 0xb8c2, 0x0080, 0xb8c0, 0x9005, 0x1168, 0x9186,
-	0x0046, 0x1150, 0x687c, 0x9606, 0x1138, 0x6880, 0x9506, 0x9084,
-	0xff00, 0x1110, 0x001e, 0x0098, 0x080c, 0xae1b, 0x01a8, 0x2b08,
-	0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x9186, 0x004c,
-	0x1110, 0x6023, 0x000a, 0x0016, 0x001e, 0x080c, 0xaeec, 0x00ce,
-	0x00be, 0x0005, 0x001e, 0x0cd8, 0x2001, 0x180e, 0x2004, 0xd0ec,
-	0x0120, 0x2011, 0x8049, 0x080c, 0x4b14, 0x080c, 0xaebf, 0x0d90,
-	0x2b08, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x0016,
-	0x9186, 0x0017, 0x0118, 0x9186, 0x0030, 0x1128, 0x6007, 0x0009,
-	0x6017, 0x2900, 0x0020, 0x6007, 0x0051, 0x6017, 0x0000, 0x602f,
-	0x0009, 0x6003, 0x0001, 0x080c, 0x9121, 0x08a0, 0x080c, 0x32e5,
-	0x1140, 0x7010, 0x9084, 0xff00, 0x8007, 0x908e, 0x0008, 0x1108,
-	0x0009, 0x0005, 0x00b6, 0x00c6, 0x0046, 0x7000, 0x908c, 0xff00,
-	0x810f, 0x9186, 0x0033, 0x11e8, 0x080c, 0x82ae, 0x0904, 0x80a3,
-	0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1140, 0x7034, 0x9005,
-	0x15d0, 0x2009, 0x0015, 0x080c, 0xaeec, 0x04a8, 0x908e, 0x0100,
-	0x1590, 0x7034, 0x9005, 0x1578, 0x2009, 0x0016, 0x080c, 0xaeec,
-	0x0450, 0x9186, 0x0032, 0x1538, 0x7030, 0x908e, 0x1400, 0x1518,
-	0x2009, 0x0038, 0x0016, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c,
-	0x080c, 0x2840, 0x11b8, 0x080c, 0x65a7, 0x11a0, 0xbe12, 0xbd16,
-	0x080c, 0xae1b, 0x0178, 0x2b08, 0x6112, 0x080c, 0xcfc4, 0x6023,
-	0x0004, 0x7120, 0x610a, 0x001e, 0x080c, 0xaeec, 0x080c, 0x9687,
-	0x0010, 0x00ce, 0x001e, 0x004e, 0x00ce, 0x00be, 0x0005, 0x00b6,
-	0x0046, 0x00e6, 0x00d6, 0x2028, 0x2130, 0x9696, 0x00ff, 0x11b8,
-	0x9592, 0xfffc, 0x02a0, 0x9596, 0xfffd, 0x1120, 0x2009, 0x007f,
-	0x0804, 0x8105, 0x9596, 0xfffe, 0x1120, 0x2009, 0x007e, 0x0804,
-	0x8105, 0x9596, 0xfffc, 0x1118, 0x2009, 0x0080, 0x04f0, 0x2011,
-	0x0000, 0x2019, 0x1837, 0x231c, 0xd3ac, 0x0130, 0x9026, 0x20a9,
-	0x0800, 0x2071, 0x1000, 0x0030, 0x2021, 0x0081, 0x20a9, 0x077f,
-	0x2071, 0x1081, 0x2e1c, 0x93dd, 0x0000, 0x1140, 0x82ff, 0x11d0,
-	0x9496, 0x00ff, 0x01b8, 0x2410, 0xc2fd, 0x00a0, 0xbf10, 0x2600,
-	0x9706, 0xb814, 0x1120, 0x9546, 0x1110, 0x2408, 0x00b0, 0x9745,
-	0x1148, 0x94c6, 0x007e, 0x0130, 0x94c6, 0x007f, 0x0118, 0x94c6,
-	0x0080, 0x1d20, 0x8420, 0x8e70, 0x1f04, 0x80da, 0x82ff, 0x1118,
-	0x9085, 0x0001, 0x0018, 0xc2fc, 0x2208, 0x9006, 0x00de, 0x00ee,
-	0x004e, 0x00be, 0x0005, 0x7000, 0x908c, 0xff00, 0x810f, 0x9184,
-	0x000f, 0x0002, 0x8122, 0x8122, 0x8122, 0x82c0, 0x8122, 0x812b,
-	0x8156, 0x81e4, 0x8122, 0x8122, 0x8122, 0x8122, 0x8122, 0x8122,
-	0x8122, 0x8122, 0x7817, 0x0140, 0x2001, 0x19ef, 0x2004, 0x9005,
-	0x090c, 0x9687, 0x0005, 0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7120,
-	0x2160, 0x9c8c, 0x0007, 0x11c0, 0x9c8a, 0x1cd0, 0x02a8, 0x6868,
-	0x9c02, 0x1290, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910,
-	0x9106, 0x1150, 0x700c, 0xb914, 0x9106, 0x1130, 0x7124, 0x610a,
-	0x2009, 0x0046, 0x080c, 0xaeec, 0x7817, 0x0140, 0x2001, 0x19ef,
-	0x2004, 0x9005, 0x090c, 0x9687, 0x00be, 0x0005, 0x00b6, 0x00c6,
-	0x9484, 0x0fff, 0x0904, 0x81ba, 0x7110, 0xd1bc, 0x1904, 0x81ba,
-	0x7108, 0x700c, 0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00,
-	0x15b0, 0x81ff, 0x15a0, 0x9080, 0x3327, 0x200d, 0x918c, 0xff00,
-	0x810f, 0x2001, 0x0080, 0x9106, 0x0904, 0x81ba, 0x080c, 0x65a7,
-	0x1904, 0x81ba, 0xbe12, 0xbd16, 0xb800, 0xd0ec, 0x15d8, 0xba04,
-	0x9294, 0xff00, 0x9286, 0x0600, 0x11a0, 0x080c, 0xae1b, 0x05e8,
-	0x2b08, 0x7028, 0x604a, 0x702c, 0x6046, 0x6112, 0x6023, 0x0006,
-	0x7120, 0x610a, 0x7130, 0x6156, 0x2009, 0x0044, 0x080c, 0xdb84,
-	0x0408, 0x080c, 0x697b, 0x1138, 0xb807, 0x0606, 0x0c30, 0x190c,
-	0x80a7, 0x11c0, 0x0898, 0x080c, 0xae1b, 0x2b08, 0x0198, 0x6112,
-	0x6023, 0x0004, 0x7120, 0x610a, 0x9286, 0x0400, 0x1118, 0x6007,
-	0x0005, 0x0010, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x9121,
-	0x080c, 0x9687, 0x7817, 0x0140, 0x2001, 0x19ef, 0x2004, 0x9005,
-	0x090c, 0x9687, 0x00ce, 0x00be, 0x0005, 0x2001, 0x180e, 0x2004,
-	0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x4b14, 0x080c, 0xaebf,
-	0x0d48, 0x2b08, 0x6112, 0x6023, 0x0006, 0x7120, 0x610a, 0x7130,
-	0x6156, 0x6017, 0xf300, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c,
-	0x90d9, 0x080c, 0x9687, 0x08b0, 0x00b6, 0x7110, 0xd1bc, 0x01e8,
-	0x7020, 0x2060, 0x9c84, 0x0007, 0x11c0, 0x9c82, 0x1cd0, 0x02a8,
-	0x6868, 0x9c02, 0x1290, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158,
-	0xb910, 0x9106, 0x1150, 0x700c, 0xb914, 0x9106, 0x1130, 0x7124,
-	0x610a, 0x2009, 0x0045, 0x080c, 0xaeec, 0x7817, 0x0140, 0x2001,
-	0x19ef, 0x2004, 0x9005, 0x090c, 0x9687, 0x00be, 0x0005, 0x6120,
-	0x9186, 0x0002, 0x0128, 0x9186, 0x0005, 0x0110, 0x9085, 0x0001,
-	0x0005, 0x080c, 0x32e5, 0x1168, 0x7010, 0x9084, 0xff00, 0x8007,
-	0x9086, 0x0000, 0x1130, 0x9184, 0x000f, 0x908a, 0x0006, 0x1208,
-	0x000b, 0x0005, 0x8230, 0x8231, 0x8230, 0x8230, 0x8290, 0x829f,
-	0x0005, 0x00b6, 0x7110, 0xd1bc, 0x0120, 0x702c, 0xd084, 0x0904,
-	0x828e, 0x700c, 0x7108, 0x080c, 0x2840, 0x1904, 0x828e, 0x080c,
-	0x65a7, 0x1904, 0x828e, 0xbe12, 0xbd16, 0x7110, 0xd1bc, 0x01d8,
-	0x080c, 0x697b, 0x0118, 0x9086, 0x0004, 0x1588, 0x00c6, 0x080c,
-	0x82ae, 0x00ce, 0x05d8, 0x080c, 0xae1b, 0x2b08, 0x05b8, 0x6112,
-	0x080c, 0xcfc4, 0x6023, 0x0002, 0x7120, 0x610a, 0x2009, 0x0088,
-	0x080c, 0xaeec, 0x0458, 0x080c, 0x697b, 0x0148, 0x9086, 0x0004,
-	0x0130, 0x080c, 0x6983, 0x0118, 0x9086, 0x0004, 0x1180, 0x080c,
-	0xae1b, 0x2b08, 0x01d8, 0x6112, 0x080c, 0xcfc4, 0x6023, 0x0005,
-	0x7120, 0x610a, 0x2009, 0x0088, 0x080c, 0xaeec, 0x0078, 0x080c,
-	0xae1b, 0x2b08, 0x0158, 0x6112, 0x080c, 0xcfc4, 0x6023, 0x0004,
-	0x7120, 0x610a, 0x2009, 0x0001, 0x080c, 0xaeec, 0x00be, 0x0005,
-	0x7110, 0xd1bc, 0x0158, 0x00d1, 0x0148, 0x080c, 0x820f, 0x1130,
-	0x7124, 0x610a, 0x2009, 0x0089, 0x080c, 0xaeec, 0x0005, 0x7110,
-	0xd1bc, 0x0158, 0x0059, 0x0148, 0x080c, 0x820f, 0x1130, 0x7124,
-	0x610a, 0x2009, 0x008a, 0x080c, 0xaeec, 0x0005, 0x7020, 0x2060,
-	0x9c84, 0x0007, 0x1158, 0x9c82, 0x1cd0, 0x0240, 0x2001, 0x181a,
-	0x2004, 0x9c02, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8,
-	0x00b6, 0x7110, 0xd1bc, 0x11d8, 0x7024, 0x2060, 0x9c84, 0x0007,
-	0x11b0, 0x9c82, 0x1cd0, 0x0298, 0x6868, 0x9c02, 0x1280, 0x7008,
-	0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1140, 0x700c,
-	0xb914, 0x9106, 0x1120, 0x2009, 0x0051, 0x080c, 0xaeec, 0x7817,
-	0x0140, 0x2001, 0x19ef, 0x2004, 0x9005, 0x090c, 0x9687, 0x00be,
-	0x0005, 0x2031, 0x0105, 0x0069, 0x0005, 0x2031, 0x0206, 0x0049,
-	0x0005, 0x2031, 0x0207, 0x0029, 0x0005, 0x2031, 0x0213, 0x0009,
-	0x0005, 0x00c6, 0x0096, 0x00f6, 0x7000, 0x9084, 0xf000, 0x9086,
-	0xc000, 0x05d0, 0x080c, 0xae1b, 0x05b8, 0x0066, 0x00c6, 0x0046,
-	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2840, 0x15a0,
-	0x080c, 0x65a7, 0x1588, 0xbe12, 0xbd16, 0x2b00, 0x004e, 0x00ce,
-	0x6012, 0x080c, 0xcfc4, 0x080c, 0x0fff, 0x0510, 0x2900, 0x605a,
-	0x9006, 0xa802, 0xa866, 0xac6a, 0xa85c, 0x90f8, 0x001b, 0x20a9,
-	0x000e, 0xa860, 0x20e8, 0x20e1, 0x0000, 0x2fa0, 0x2e98, 0x4003,
-	0x006e, 0x6616, 0x6007, 0x003e, 0x6023, 0x0001, 0x6003, 0x0001,
-	0x080c, 0x9121, 0x080c, 0x9687, 0x00fe, 0x009e, 0x00ce, 0x0005,
-	0x080c, 0xae71, 0x006e, 0x0cc0, 0x004e, 0x00ce, 0x0cc8, 0x00c6,
-	0x7000, 0x908c, 0xff00, 0x9184, 0xf000, 0x810f, 0x9086, 0x2000,
-	0x1904, 0x839e, 0x9186, 0x0022, 0x15f0, 0x2001, 0x0111, 0x2004,
-	0x9005, 0x1904, 0x83a0, 0x7030, 0x908e, 0x0400, 0x0904, 0x83a0,
-	0x908e, 0x6000, 0x05e8, 0x908e, 0x5400, 0x05d0, 0x908e, 0x0300,
-	0x11d8, 0x2009, 0x1837, 0x210c, 0xd18c, 0x1590, 0xd1a4, 0x1580,
-	0x080c, 0x6939, 0x0558, 0x68b0, 0x9084, 0x00ff, 0x7100, 0x918c,
-	0x00ff, 0x9106, 0x1518, 0x6880, 0x69b0, 0x918c, 0xff00, 0x9105,
-	0x7104, 0x9106, 0x11d8, 0x00e0, 0x2009, 0x0103, 0x210c, 0xd1b4,
-	0x11a8, 0x908e, 0x5200, 0x09e8, 0x908e, 0x0500, 0x09d0, 0x908e,
-	0x5000, 0x09b8, 0x0058, 0x9186, 0x0023, 0x1140, 0x080c, 0x82ae,
-	0x0128, 0x6004, 0x9086, 0x0002, 0x0118, 0x0000, 0x9006, 0x0010,
-	0x9085, 0x0001, 0x00ce, 0x0005, 0x0156, 0x0046, 0x0016, 0x0036,
-	0x7038, 0x2020, 0x8427, 0x94a4, 0x0007, 0xd484, 0x0148, 0x20a9,
-	0x0004, 0x2019, 0x1805, 0x2011, 0x027a, 0x080c, 0xbe1c, 0x1178,
-	0xd48c, 0x0148, 0x20a9, 0x0004, 0x2019, 0x1801, 0x2011, 0x027e,
-	0x080c, 0xbe1c, 0x1120, 0xd494, 0x0110, 0x9085, 0x0001, 0x003e,
-	0x001e, 0x004e, 0x015e, 0x0005, 0x0156, 0x0046, 0x0016, 0x0036,
-	0x7038, 0x2020, 0x8427, 0x94a4, 0x0007, 0xd484, 0x0148, 0x20a9,
-	0x0004, 0x2019, 0x1805, 0x2011, 0x0272, 0x080c, 0xbe1c, 0x1178,
-	0xd48c, 0x0148, 0x20a9, 0x0004, 0x2019, 0x1801, 0x2011, 0x0276,
-	0x080c, 0xbe1c, 0x1120, 0xd494, 0x0110, 0x9085, 0x0001, 0x003e,
-	0x001e, 0x004e, 0x015e, 0x0005, 0x00f6, 0x2079, 0x0200, 0x7800,
-	0xc0e5, 0xc0cc, 0x7802, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x1800,
-	0x7834, 0xd084, 0x1130, 0x2079, 0x0200, 0x7800, 0x9085, 0x1200,
-	0x7802, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x1800, 0x7034, 0xc084,
-	0x7036, 0x00ee, 0x0005, 0x2071, 0x19f9, 0x7003, 0x0003, 0x700f,
-	0x0361, 0x9006, 0x701a, 0x7072, 0x7012, 0x7017, 0x1cd0, 0x7007,
-	0x0000, 0x7026, 0x702b, 0xa28a, 0x7032, 0x7037, 0xa2f8, 0x703f,
-	0xffff, 0x7042, 0x7047, 0x5577, 0x704a, 0x705b, 0x857d, 0x080c,
-	0x1018, 0x090c, 0x0dd5, 0x2900, 0x703a, 0xa867, 0x0003, 0xa86f,
-	0x0100, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x19f9, 0x1d04, 0x84cb,
-	0x2091, 0x6000, 0x700c, 0x8001, 0x700e, 0x1530, 0x2001, 0x013c,
-	0x2004, 0x9005, 0x190c, 0x85c2, 0x2001, 0x1869, 0x2004, 0xd0c4,
-	0x0158, 0x3a00, 0xd08c, 0x1140, 0x20d1, 0x0000, 0x20d1, 0x0001,
-	0x20d1, 0x0000, 0x080c, 0x0dd5, 0x700f, 0x0361, 0x7007, 0x0001,
-	0x0126, 0x2091, 0x8000, 0x7040, 0x900d, 0x0148, 0x8109, 0x7142,
-	0x1130, 0x7044, 0x080f, 0x0018, 0x0126, 0x2091, 0x8000, 0x7024,
-	0x900d, 0x0188, 0x7020, 0x8001, 0x7022, 0x1168, 0x7023, 0x0009,
-	0x8109, 0x7126, 0x9186, 0x03e8, 0x1110, 0x7028, 0x080f, 0x81ff,
-	0x1110, 0x7028, 0x080f, 0x7030, 0x900d, 0x0180, 0x702c, 0x8001,
-	0x702e, 0x1160, 0x702f, 0x0009, 0x8109, 0x7132, 0x0128, 0x9184,
-	0x007f, 0x090c, 0xa419, 0x0010, 0x7034, 0x080f, 0x703c, 0x9005,
-	0x0118, 0x0310, 0x8001, 0x703e, 0x704c, 0x900d, 0x0168, 0x7048,
-	0x8001, 0x704a, 0x1148, 0x704b, 0x0009, 0x8109, 0x714e, 0x1120,
-	0x7150, 0x714e, 0x7058, 0x080f, 0x7018, 0x900d, 0x01d8, 0x0016,
-	0x7070, 0x900d, 0x0158, 0x706c, 0x8001, 0x706e, 0x1138, 0x706f,
-	0x0009, 0x8109, 0x7172, 0x1110, 0x7074, 0x080f, 0x001e, 0x7008,
-	0x8001, 0x700a, 0x1138, 0x700b, 0x0009, 0x8109, 0x711a, 0x1110,
-	0x701c, 0x080f, 0x012e, 0x7004, 0x0002, 0x84f3, 0x84f4, 0x8510,
-	0x00e6, 0x2071, 0x19f9, 0x7018, 0x9005, 0x1120, 0x711a, 0x721e,
-	0x700b, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0x19f9,
-	0x701c, 0x9206, 0x1120, 0x701a, 0x701e, 0x7072, 0x7076, 0x000e,
-	0x00ee, 0x0005, 0x00e6, 0x2071, 0x19f9, 0xb888, 0x9102, 0x0208,
-	0xb98a, 0x00ee, 0x0005, 0x0005, 0x00b6, 0x7110, 0x080c, 0x6608,
-	0x1168, 0xb888, 0x8001, 0x0250, 0xb88a, 0x1140, 0x0126, 0x2091,
-	0x8000, 0x0016, 0x080c, 0x9687, 0x001e, 0x012e, 0x8108, 0x9182,
-	0x0800, 0x0218, 0x900e, 0x7007, 0x0002, 0x7112, 0x00be, 0x0005,
-	0x7014, 0x2060, 0x0126, 0x2091, 0x8000, 0x6040, 0x9005, 0x0128,
-	0x8001, 0x6042, 0x1110, 0x080c, 0xce55, 0x6018, 0x9005, 0x0558,
-	0x8001, 0x601a, 0x1540, 0x6120, 0x9186, 0x0003, 0x0148, 0x9186,
-	0x0006, 0x0130, 0x9186, 0x0009, 0x11e0, 0x611c, 0xd1c4, 0x1100,
-	0x080c, 0xcb4a, 0x01b0, 0x6014, 0x2048, 0xa884, 0x908a, 0x199a,
-	0x0280, 0x9082, 0x1999, 0xa886, 0x908a, 0x199a, 0x0210, 0x2001,
-	0x1999, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0xa87c, 0xd0e4,
-	0x0110, 0x080c, 0xc846, 0x012e, 0x9c88, 0x0018, 0x7116, 0x2001,
-	0x181a, 0x2004, 0x9102, 0x0220, 0x7017, 0x1cd0, 0x7007, 0x0000,
-	0x0005, 0x00e6, 0x2071, 0x19f9, 0x7027, 0x07d0, 0x7023, 0x0009,
-	0x00ee, 0x0005, 0x2001, 0x1a02, 0x2003, 0x0000, 0x0005, 0x00e6,
-	0x2071, 0x19f9, 0x7132, 0x702f, 0x0009, 0x00ee, 0x0005, 0x2011,
-	0x1a05, 0x2013, 0x0000, 0x0005, 0x00e6, 0x2071, 0x19f9, 0x711a,
-	0x721e, 0x700b, 0x0009, 0x00ee, 0x0005, 0x0086, 0x0026, 0x7054,
-	0x8000, 0x7056, 0x2001, 0x1a07, 0x2044, 0xa06c, 0x9086, 0x0000,
-	0x0150, 0x7068, 0xa09a, 0x7064, 0xa096, 0x7060, 0xa092, 0x705c,
-	0xa08e, 0x080c, 0x10e9, 0x002e, 0x008e, 0x0005, 0x0006, 0x0016,
-	0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0156,
-	0x080c, 0x843c, 0x015e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be,
-	0x00ae, 0x009e, 0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0x19f9,
-	0x7172, 0x7276, 0x706f, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006,
-	0x2071, 0x19f9, 0x7074, 0x9206, 0x1110, 0x7072, 0x7076, 0x000e,
-	0x00ee, 0x0005, 0x0016, 0x00c6, 0x2009, 0xfffc, 0x210d, 0x2061,
-	0x0100, 0x60f0, 0x9100, 0x60f3, 0x0000, 0x2009, 0xfffc, 0x200f,
-	0x1220, 0x8108, 0x2105, 0x8000, 0x200f, 0x00ce, 0x001e, 0x0005,
-	0x00c6, 0x2061, 0x1a70, 0x00ce, 0x0005, 0x9184, 0x000f, 0x8003,
-	0x8003, 0x8003, 0x9080, 0x1a70, 0x2060, 0x0005, 0xa884, 0x908a,
-	0x199a, 0x1638, 0x9005, 0x1150, 0x00c6, 0x2061, 0x1a70, 0x6014,
-	0x00ce, 0x9005, 0x1130, 0x2001, 0x001e, 0x0018, 0x908e, 0xffff,
-	0x01b0, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0xa87c, 0x908c,
-	0x00c0, 0x918e, 0x00c0, 0x0904, 0x8670, 0xd0b4, 0x1168, 0xd0bc,
-	0x1904, 0x8649, 0x2009, 0x0006, 0x080c, 0x869d, 0x0005, 0x900e,
-	0x0c60, 0x2001, 0x1999, 0x08b0, 0xd0fc, 0x0160, 0x908c, 0x0003,
-	0x0120, 0x918e, 0x0003, 0x1904, 0x8697, 0x908c, 0x2020, 0x918e,
-	0x2020, 0x01a8, 0x6024, 0xd0d4, 0x11e8, 0x2009, 0x1869, 0x2104,
-	0xd084, 0x1138, 0x87ff, 0x1120, 0x2009, 0x0043, 0x0804, 0xaeec,
-	0x0005, 0x87ff, 0x1de8, 0x2009, 0x0042, 0x0804, 0xaeec, 0x6110,
-	0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20, 0x6024, 0xc0cd,
-	0x6026, 0x0c00, 0xc0d4, 0x6026, 0xa890, 0x602e, 0xa88c, 0x6032,
-	0x08e0, 0xd0fc, 0x0160, 0x908c, 0x0003, 0x0120, 0x918e, 0x0003,
-	0x1904, 0x8697, 0x908c, 0x2020, 0x918e, 0x2020, 0x0170, 0x0076,
-	0x00f6, 0x2c78, 0x080c, 0x1727, 0x00fe, 0x007e, 0x87ff, 0x1120,
-	0x2009, 0x0042, 0x080c, 0xaeec, 0x0005, 0x6110, 0x00b6, 0x2158,
-	0xb900, 0x00be, 0xd1ac, 0x0d58, 0x6124, 0xc1cd, 0x6126, 0x0c38,
-	0xd0fc, 0x0188, 0x908c, 0x2020, 0x918e, 0x2020, 0x01a8, 0x9084,
-	0x0003, 0x908e, 0x0002, 0x0148, 0x87ff, 0x1120, 0x2009, 0x0041,
-	0x080c, 0xaeec, 0x0005, 0x00b9, 0x0ce8, 0x87ff, 0x1dd8, 0x2009,
-	0x0043, 0x080c, 0xaeec, 0x0cb0, 0x6110, 0x00b6, 0x2158, 0xb900,
-	0x00be, 0xd1ac, 0x0d20, 0x6124, 0xc1cd, 0x6126, 0x0c00, 0x2009,
-	0x0004, 0x0019, 0x0005, 0x2009, 0x0001, 0x0096, 0x080c, 0xcb4a,
-	0x0518, 0x6014, 0x2048, 0xa982, 0xa800, 0x6016, 0x9186, 0x0001,
-	0x1188, 0xa97c, 0x918c, 0x8100, 0x918e, 0x8100, 0x1158, 0x00c6,
-	0x2061, 0x1a70, 0x6200, 0xd28c, 0x1120, 0x6204, 0x8210, 0x0208,
-	0x6206, 0x00ce, 0x080c, 0x6ac1, 0x6014, 0x904d, 0x0076, 0x2039,
-	0x0000, 0x190c, 0x85e6, 0x007e, 0x009e, 0x0005, 0x0156, 0x00c6,
-	0x2061, 0x1a70, 0x6000, 0x81ff, 0x0110, 0x9205, 0x0008, 0x9204,
-	0x6002, 0x00ce, 0x015e, 0x0005, 0x6800, 0xd08c, 0x1138, 0x6808,
-	0x9005, 0x0120, 0x8001, 0x680a, 0x9085, 0x0001, 0x0005, 0x2071,
-	0x1923, 0x7003, 0x0006, 0x7007, 0x0000, 0x700f, 0x0000, 0x7013,
-	0x0001, 0x080c, 0x1018, 0x090c, 0x0dd5, 0xa867, 0x0006, 0xa86b,
-	0x0001, 0xa8ab, 0xdcb0, 0xa89f, 0x0000, 0x2900, 0x702e, 0x7033,
-	0x0000, 0x0005, 0x0096, 0x00e6, 0x2071, 0x1923, 0x702c, 0x2048,
-	0x6a2c, 0x721e, 0x6b30, 0x7322, 0x6834, 0x7026, 0xa896, 0x6838,
-	0x702a, 0xa89a, 0x6824, 0x7016, 0x683c, 0x701a, 0x2009, 0x0028,
-	0x200a, 0x9005, 0x0148, 0x900e, 0x9188, 0x000c, 0x8001, 0x1de0,
-	0x2100, 0x9210, 0x1208, 0x8318, 0xaa8e, 0xab92, 0x7010, 0xd084,
-	0x0178, 0xc084, 0x7007, 0x0001, 0x700f, 0x0000, 0x0006, 0x2009,
-	0x181d, 0x2104, 0x9082, 0x0007, 0x2009, 0x1ac7, 0x200a, 0x000e,
-	0xc095, 0x7012, 0x2008, 0x2001, 0x003b, 0x080c, 0x15f0, 0x9006,
-	0x2071, 0x193c, 0x7002, 0x7006, 0x702a, 0x00ee, 0x009e, 0x0005,
-	0x00e6, 0x0126, 0x0156, 0x2091, 0x8000, 0x2071, 0x1800, 0x7154,
-	0x2001, 0x0008, 0x910a, 0x0638, 0x2001, 0x187d, 0x20ac, 0x9006,
-	0x9080, 0x0008, 0x1f04, 0x8750, 0x71c0, 0x9102, 0x02e0, 0x2071,
-	0x1877, 0x20a9, 0x0007, 0x00c6, 0x080c, 0xae1b, 0x6023, 0x0009,
-	0x6003, 0x0004, 0x601f, 0x0101, 0x0089, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x88d6, 0x012e, 0x1f04, 0x875c, 0x9006, 0x00ce, 0x015e,
-	0x012e, 0x00ee, 0x0005, 0x9085, 0x0001, 0x0cc8, 0x00e6, 0x00b6,
-	0x0096, 0x0086, 0x0056, 0x0046, 0x0026, 0x7118, 0x720c, 0x7620,
-	0x7004, 0xd084, 0x1128, 0x2021, 0x0024, 0x2029, 0x0002, 0x0020,
-	0x2021, 0x002c, 0x2029, 0x000a, 0x080c, 0x0fff, 0x090c, 0x0dd5,
-	0x2900, 0x6016, 0x2058, 0xac66, 0x9006, 0xa802, 0xa806, 0xa86a,
-	0xa87a, 0xa8aa, 0xa887, 0x0005, 0xa87f, 0x0020, 0x7008, 0xa89a,
-	0x7010, 0xa89e, 0xae8a, 0xa8af, 0xffff, 0xa8b3, 0x0000, 0x8109,
-	0x0160, 0x080c, 0x0fff, 0x090c, 0x0dd5, 0xad66, 0x2b00, 0xa802,
-	0x2900, 0xb806, 0x2058, 0x8109, 0x1da0, 0x002e, 0x004e, 0x005e,
-	0x008e, 0x009e, 0x00be, 0x00ee, 0x0005, 0x2079, 0x0000, 0x2071,
-	0x1923, 0x7004, 0x004b, 0x700c, 0x0002, 0x87c8, 0x87c1, 0x87c1,
-	0x0005, 0x87d2, 0x8833, 0x8833, 0x8833, 0x8834, 0x8845, 0x8845,
-	0x700c, 0x0cba, 0x0126, 0x2091, 0x8000, 0x78a0, 0x79a0, 0x9106,
-	0x0128, 0x78a0, 0x79a0, 0x9106, 0x1904, 0x8826, 0x2001, 0x0005,
-	0x2004, 0xd0bc, 0x0130, 0x2011, 0x0004, 0x2204, 0xc0c5, 0x2012,
-	0x0ca8, 0x012e, 0x7018, 0x910a, 0x1130, 0x7030, 0x9005, 0x05a8,
-	0x080c, 0x8874, 0x0490, 0x1210, 0x7114, 0x910a, 0x9192, 0x000a,
-	0x0210, 0x2009, 0x000a, 0x2001, 0x1888, 0x2014, 0x2001, 0x1935,
-	0x2004, 0x9100, 0x9202, 0x0e48, 0x080c, 0x89c0, 0x2200, 0x9102,
-	0x0208, 0x2208, 0x0096, 0x702c, 0x2048, 0xa873, 0x0001, 0xa976,
-	0x080c, 0x8ac9, 0x2100, 0xa87e, 0xa86f, 0x0000, 0x009e, 0x0126,
-	0x2091, 0x8000, 0x2009, 0x1a17, 0x2104, 0xc085, 0x200a, 0x700f,
-	0x0002, 0x012e, 0x080c, 0x1108, 0x1de8, 0x0005, 0x2001, 0x0005,
-	0x2004, 0xd0bc, 0x0130, 0x2011, 0x0004, 0x2204, 0xc0c5, 0x2012,
-	0x0ca8, 0x012e, 0x0005, 0x0005, 0x700c, 0x0002, 0x8839, 0x883c,
-	0x883b, 0x080c, 0x87d0, 0x0005, 0x8001, 0x700e, 0x0096, 0x702c,
-	0x2048, 0xa974, 0x009e, 0x0011, 0x0ca0, 0x0005, 0x0096, 0x702c,
-	0x2048, 0x7018, 0x9100, 0x7214, 0x921a, 0x1130, 0x701c, 0xa88e,
-	0x7020, 0xa892, 0x9006, 0x0068, 0x0006, 0x080c, 0x8ac9, 0x2100,
-	0xaa8c, 0x9210, 0xaa8e, 0x1220, 0xa890, 0x9081, 0x0000, 0xa892,
-	0x000e, 0x009e, 0x2f08, 0x9188, 0x0028, 0x200a, 0x701a, 0x0005,
-	0x00e6, 0x2071, 0x1923, 0x700c, 0x0002, 0x8872, 0x8872, 0x8870,
-	0x700f, 0x0001, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x7030,
-	0x9005, 0x0508, 0x2078, 0x7814, 0x2048, 0xae88, 0x00b6, 0x2059,
-	0x0000, 0x080c, 0x88df, 0x00be, 0x01b0, 0x00e6, 0x2071, 0x193c,
-	0x080c, 0x8926, 0x00ee, 0x0178, 0x0096, 0x080c, 0x1018, 0x2900,
-	0x009e, 0x0148, 0xa8aa, 0x04b9, 0x0041, 0x2001, 0x1946, 0x2003,
-	0x0000, 0x012e, 0x08c8, 0x012e, 0x0005, 0x00d6, 0x00c6, 0x0086,
-	0x00a6, 0x2940, 0x2650, 0x2600, 0x9005, 0x0180, 0xa864, 0x9084,
-	0x000f, 0x2068, 0x9d88, 0x2092, 0x2165, 0x0056, 0x2029, 0x0000,
-	0x080c, 0x8a4e, 0x080c, 0x204a, 0x1dd8, 0x005e, 0x00ae, 0x2001,
-	0x187f, 0x2004, 0xa88a, 0x080c, 0x1727, 0x781f, 0x0101, 0x7813,
-	0x0000, 0x0126, 0x2091, 0x8000, 0x080c, 0x8935, 0x012e, 0x008e,
-	0x00ce, 0x00de, 0x0005, 0x7030, 0x9005, 0x0138, 0x2078, 0x780c,
-	0x7032, 0x2001, 0x1946, 0x2003, 0x0001, 0x0005, 0x00e6, 0x2071,
-	0x1923, 0x7030, 0x600e, 0x2c00, 0x7032, 0x00ee, 0x0005, 0x00d6,
-	0x00c6, 0x0026, 0x9b80, 0x8ba8, 0x2005, 0x906d, 0x090c, 0x0dd5,
-	0x9b80, 0x8ba0, 0x2005, 0x9065, 0x090c, 0x0dd5, 0x6114, 0x2600,
-	0x9102, 0x0248, 0x6828, 0x9102, 0x02f0, 0x9085, 0x0001, 0x002e,
-	0x00ce, 0x00de, 0x0005, 0x6804, 0xd094, 0x0148, 0x6854, 0xd084,
-	0x1178, 0xc085, 0x6856, 0x2011, 0x8026, 0x080c, 0x4b14, 0x684c,
-	0x0096, 0x904d, 0x090c, 0x0dd5, 0xa804, 0x8000, 0xa806, 0x009e,
-	0x9006, 0x2030, 0x0c20, 0x6854, 0xd08c, 0x1d08, 0xc08d, 0x6856,
-	0x2011, 0x8025, 0x080c, 0x4b14, 0x684c, 0x0096, 0x904d, 0x090c,
-	0x0dd5, 0xa800, 0x8000, 0xa802, 0x009e, 0x0888, 0x7000, 0x2019,
-	0x0008, 0x8319, 0x7104, 0x9102, 0x1118, 0x2300, 0x9005, 0x0020,
-	0x0210, 0x9302, 0x0008, 0x8002, 0x0005, 0x00d6, 0x7814, 0x9005,
-	0x090c, 0x0dd5, 0x781c, 0x9084, 0x0101, 0x9086, 0x0101, 0x190c,
-	0x0dd5, 0x2069, 0x193c, 0x6804, 0x9080, 0x193e, 0x2f08, 0x2102,
-	0x6904, 0x8108, 0x9182, 0x0008, 0x0208, 0x900e, 0x6906, 0x9180,
-	0x193e, 0x2003, 0x0000, 0x00de, 0x0005, 0x0096, 0x00c6, 0x2060,
-	0x6014, 0x2048, 0xa8a8, 0x0096, 0x2048, 0x9005, 0x190c, 0x1031,
-	0x009e, 0xa8ab, 0x0000, 0x080c, 0x0fb1, 0x080c, 0xae71, 0x00ce,
-	0x009e, 0x0005, 0x6020, 0x9086, 0x0009, 0x1128, 0x601c, 0xd0c4,
-	0x0110, 0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x6000, 0x9086,
-	0x0000, 0x0178, 0x6010, 0x9005, 0x0150, 0x00b6, 0x2058, 0x080c,
-	0x8cdb, 0x00be, 0x6013, 0x0000, 0x601b, 0x0000, 0x0010, 0x2c00,
-	0x0861, 0x0005, 0x2009, 0x1927, 0x210c, 0xd194, 0x0005, 0x00e6,
-	0x2071, 0x1923, 0x7110, 0xc194, 0xd19c, 0x1118, 0xc185, 0x7007,
-	0x0000, 0x7112, 0x2001, 0x003b, 0x080c, 0x15f0, 0x00ee, 0x0005,
-	0x0096, 0x00d6, 0x9006, 0x7006, 0x700e, 0x701a, 0x701e, 0x7022,
-	0x7016, 0x702a, 0x7026, 0x702f, 0x0000, 0x080c, 0x8b28, 0x0170,
-	0x080c, 0x8b5d, 0x0158, 0x2900, 0x7002, 0x700a, 0x701a, 0x7013,
-	0x0001, 0x701f, 0x000a, 0x00de, 0x009e, 0x0005, 0x900e, 0x0cd8,
-	0x00e6, 0x0096, 0x0086, 0x00d6, 0x00c6, 0x2071, 0x1930, 0x721c,
-	0x2100, 0x9202, 0x1618, 0x080c, 0x8b5d, 0x090c, 0x0dd5, 0x7018,
-	0x9005, 0x1160, 0x2900, 0x7002, 0x700a, 0x701a, 0x9006, 0x7006,
-	0x700e, 0xa806, 0xa802, 0x7012, 0x701e, 0x0038, 0x2040, 0xa806,
-	0x2900, 0xa002, 0x701a, 0xa803, 0x0000, 0x7010, 0x8000, 0x7012,
-	0x701c, 0x9080, 0x000a, 0x701e, 0x721c, 0x08d0, 0x721c, 0x00ce,
-	0x00de, 0x008e, 0x009e, 0x00ee, 0x0005, 0x0096, 0x0156, 0x0136,
-	0x0146, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1930, 0x7300,
-	0x831f, 0x831e, 0x831e, 0x9384, 0x003f, 0x20e8, 0x939c, 0xffc0,
-	0x9398, 0x0003, 0x7104, 0x080c, 0x8ac9, 0x810c, 0x2100, 0x9318,
-	0x8003, 0x2228, 0x2021, 0x0078, 0x9402, 0x9532, 0x0208, 0x2028,
-	0x2500, 0x8004, 0x20a8, 0x23a0, 0xa001, 0xa001, 0x4005, 0x2508,
-	0x080c, 0x8ad2, 0x2130, 0x7014, 0x9600, 0x7016, 0x2600, 0x711c,
-	0x9102, 0x701e, 0x7004, 0x9600, 0x2008, 0x9082, 0x000a, 0x1190,
-	0x7000, 0x2048, 0xa800, 0x9005, 0x1148, 0x2009, 0x0001, 0x0026,
-	0x080c, 0x89c0, 0x002e, 0x7000, 0x2048, 0xa800, 0x7002, 0x7007,
-	0x0000, 0x0008, 0x7106, 0x2500, 0x9212, 0x1904, 0x89ff, 0x012e,
-	0x00ee, 0x014e, 0x013e, 0x015e, 0x009e, 0x0005, 0x0016, 0x0026,
-	0x00e6, 0x0126, 0x2091, 0x8000, 0x9580, 0x8ba0, 0x2005, 0x9075,
-	0x090c, 0x0dd5, 0x080c, 0x8aa4, 0x012e, 0x9580, 0x8b9c, 0x2005,
-	0x9075, 0x090c, 0x0dd5, 0x0156, 0x0136, 0x01c6, 0x0146, 0x01d6,
-	0x831f, 0x831e, 0x831e, 0x9384, 0x003f, 0x20e0, 0x9384, 0xffc0,
-	0x9100, 0x2098, 0xa860, 0x20e8, 0xa95c, 0x2c05, 0x9100, 0x20a0,
-	0x20a9, 0x0002, 0x4003, 0x2e0c, 0x2d00, 0x0002, 0x8a8e, 0x8a8e,
-	0x8a90, 0x8a8e, 0x8a90, 0x8a8e, 0x8a8e, 0x8a8e, 0x8a8e, 0x8a8e,
-	0x8a96, 0x8a8e, 0x8a96, 0x8a8e, 0x8a8e, 0x8a8e, 0x080c, 0x0dd5,
-	0x4104, 0x20a9, 0x0002, 0x4002, 0x4003, 0x0028, 0x20a9, 0x0002,
-	0x4003, 0x4104, 0x4003, 0x01de, 0x014e, 0x01ce, 0x013e, 0x015e,
-	0x00ee, 0x002e, 0x001e, 0x0005, 0x0096, 0x7014, 0x8001, 0x7016,
-	0x710c, 0x2110, 0x00f1, 0x810c, 0x9188, 0x0003, 0x7308, 0x8210,
-	0x9282, 0x000a, 0x1198, 0x7008, 0x2048, 0xa800, 0x9005, 0x0158,
-	0x0006, 0x080c, 0x8b6c, 0x009e, 0xa807, 0x0000, 0x2900, 0x700a,
-	0x7010, 0x8001, 0x7012, 0x700f, 0x0000, 0x0008, 0x720e, 0x009e,
-	0x0005, 0x0006, 0x810b, 0x810b, 0x2100, 0x810b, 0x9100, 0x2008,
-	0x000e, 0x0005, 0x0006, 0x0026, 0x2100, 0x9005, 0x0158, 0x9092,
-	0x000c, 0x0240, 0x900e, 0x8108, 0x9082, 0x000c, 0x1de0, 0x002e,
-	0x000e, 0x0005, 0x900e, 0x0cd8, 0x2d00, 0x90b8, 0x0008, 0x690c,
-	0x6810, 0x2019, 0x0001, 0x2031, 0x8b12, 0x9112, 0x0220, 0x0118,
-	0x8318, 0x2208, 0x0cd0, 0x6808, 0x9005, 0x0108, 0x8318, 0x233a,
-	0x6804, 0xd084, 0x2300, 0x2021, 0x0001, 0x1150, 0x9082, 0x0003,
-	0x0967, 0x0a67, 0x8420, 0x9082, 0x0007, 0x0967, 0x0a67, 0x0cd0,
-	0x9082, 0x0002, 0x0967, 0x0a67, 0x8420, 0x9082, 0x0005, 0x0967,
-	0x0a67, 0x0cd0, 0x6c1a, 0x2d00, 0x90b8, 0x0007, 0x00e6, 0x2071,
-	0x1800, 0x7128, 0x6810, 0x2019, 0x0001, 0x910a, 0x0118, 0x0210,
-	0x8318, 0x0cd8, 0x2031, 0x8b25, 0x0870, 0x6c16, 0x00ee, 0x0005,
-	0x0096, 0x0046, 0x0126, 0x2091, 0x8000, 0x2b00, 0x9080, 0x8ba4,
-	0x2005, 0x9005, 0x090c, 0x0dd5, 0x2004, 0x90a0, 0x000a, 0x080c,
-	0x1018, 0x01d0, 0x2900, 0x7026, 0xa803, 0x0000, 0xa807, 0x0000,
-	0x080c, 0x1018, 0x0188, 0x7024, 0xa802, 0xa807, 0x0000, 0x2900,
-	0x7026, 0x94a2, 0x000a, 0x0110, 0x0208, 0x0c90, 0x9085, 0x0001,
-	0x012e, 0x004e, 0x009e, 0x0005, 0x7024, 0x9005, 0x0dc8, 0x2048,
-	0xac00, 0x080c, 0x1031, 0x2400, 0x0cc0, 0x0126, 0x2091, 0x8000,
-	0x7024, 0x2048, 0x9005, 0x0130, 0xa800, 0x7026, 0xa803, 0x0000,
-	0xa807, 0x0000, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x7024,
-	0xa802, 0x2900, 0x7026, 0x012e, 0x0005, 0x0096, 0x9e80, 0x0009,
-	0x2004, 0x9005, 0x0138, 0x2048, 0xa800, 0x0006, 0x080c, 0x1031,
-	0x000e, 0x0cb8, 0x009e, 0x0005, 0x0096, 0x7008, 0x9005, 0x0138,
-	0x2048, 0xa800, 0x0006, 0x080c, 0x1031, 0x000e, 0x0cb8, 0x9006,
-	0x7002, 0x700a, 0x7006, 0x700e, 0x701a, 0x701e, 0x7022, 0x702a,
-	0x7026, 0x702e, 0x009e, 0x0005, 0x1a63, 0x0000, 0x0000, 0x0000,
-	0x1930, 0x0000, 0x0000, 0x0000, 0x1888, 0x0000, 0x0000, 0x0000,
-	0x1877, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00c6, 0x00b6, 0x00a6,
-	0xa8a8, 0x2040, 0x2071, 0x1877, 0x080c, 0x8cc6, 0xa067, 0x0023,
-	0x6010, 0x905d, 0x0904, 0x8c9b, 0xb814, 0xa06e, 0xb910, 0xa172,
-	0xb9a0, 0xa176, 0x2001, 0x0003, 0xa07e, 0xa834, 0xa082, 0xa07b,
-	0x0000, 0xa898, 0x9005, 0x0118, 0xa078, 0xc085, 0xa07a, 0x2858,
-	0x2031, 0x0018, 0xa068, 0x908a, 0x0019, 0x1a0c, 0x0dd5, 0x2020,
-	0x2050, 0x2940, 0xa864, 0x90bc, 0x00ff, 0x908c, 0x000f, 0x91e0,
-	0x2092, 0x2c65, 0x9786, 0x0024, 0x2c05, 0x1590, 0x908a, 0x0036,
-	0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002, 0x8c08, 0x8c08, 0x8c0a,
-	0x8c08, 0x8c08, 0x8c08, 0x8c0c, 0x8c08, 0x8c08, 0x8c08, 0x8c0e,
-	0x8c08, 0x8c08, 0x8c08, 0x8c10, 0x8c08, 0x8c08, 0x8c08, 0x8c12,
-	0x8c08, 0x8c08, 0x8c08, 0x8c14, 0x8c08, 0x8c08, 0x8c08, 0x8c16,
-	0x080c, 0x0dd5, 0xa180, 0x04b8, 0xa190, 0x04a8, 0xa1a0, 0x0498,
-	0xa1b0, 0x0488, 0xa1c0, 0x0478, 0xa1d0, 0x0468, 0xa1e0, 0x0458,
-	0x908a, 0x0034, 0x1a0c, 0x0dd5, 0x9082, 0x001b, 0x0002, 0x8c3a,
-	0x8c38, 0x8c38, 0x8c38, 0x8c38, 0x8c38, 0x8c3c, 0x8c38, 0x8c38,
-	0x8c38, 0x8c38, 0x8c38, 0x8c3e, 0x8c38, 0x8c38, 0x8c38, 0x8c38,
-	0x8c38, 0x8c40, 0x8c38, 0x8c38, 0x8c38, 0x8c38, 0x8c38, 0x8c42,
-	0x080c, 0x0dd5, 0xa180, 0x0038, 0xa198, 0x0028, 0xa1b0, 0x0018,
-	0xa1c8, 0x0008, 0xa1e0, 0x2600, 0x0002, 0x8c5e, 0x8c60, 0x8c62,
-	0x8c64, 0x8c66, 0x8c68, 0x8c6a, 0x8c6c, 0x8c6e, 0x8c70, 0x8c72,
-	0x8c74, 0x8c76, 0x8c78, 0x8c7a, 0x8c7c, 0x8c7e, 0x8c80, 0x8c82,
-	0x8c84, 0x8c86, 0x8c88, 0x8c8a, 0x8c8c, 0x8c8e, 0x080c, 0x0dd5,
-	0xb9e2, 0x0468, 0xb9de, 0x0458, 0xb9da, 0x0448, 0xb9d6, 0x0438,
-	0xb9d2, 0x0428, 0xb9ce, 0x0418, 0xb9ca, 0x0408, 0xb9c6, 0x00f8,
-	0xb9c2, 0x00e8, 0xb9be, 0x00d8, 0xb9ba, 0x00c8, 0xb9b6, 0x00b8,
-	0xb9b2, 0x00a8, 0xb9ae, 0x0098, 0xb9aa, 0x0088, 0xb9a6, 0x0078,
-	0xb9a2, 0x0068, 0xb99e, 0x0058, 0xb99a, 0x0048, 0xb996, 0x0038,
-	0xb992, 0x0028, 0xb98e, 0x0018, 0xb98a, 0x0008, 0xb986, 0x8631,
-	0x8421, 0x0120, 0x080c, 0x204a, 0x0804, 0x8be2, 0x00ae, 0x00be,
-	0x00ce, 0x00ee, 0x0005, 0xa86c, 0xa06e, 0xa870, 0xa072, 0xa077,
-	0x00ff, 0x9006, 0x0804, 0x8bc4, 0x0006, 0x0016, 0x00b6, 0x6010,
-	0x2058, 0xb810, 0x9005, 0x01b0, 0x2001, 0x1924, 0x2004, 0x9005,
-	0x0188, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x1158, 0x0036,
-	0x0046, 0xbba0, 0x2021, 0x0004, 0x2011, 0x8014, 0x080c, 0x4b14,
-	0x004e, 0x003e, 0x00be, 0x001e, 0x000e, 0x0005, 0x9016, 0x710c,
-	0xa834, 0x910a, 0xa936, 0x7008, 0x9005, 0x0120, 0x8210, 0x910a,
-	0x0238, 0x0130, 0x7010, 0x8210, 0x910a, 0x0210, 0x0108, 0x0cd8,
-	0xaa8a, 0xa26a, 0x0005, 0x00f6, 0x00d6, 0x0036, 0x2079, 0x0300,
-	0x781b, 0x0200, 0x7818, 0xd094, 0x1dd8, 0x781b, 0x0202, 0xa001,
-	0xa001, 0x7818, 0xd094, 0x1da0, 0xb8ac, 0x9005, 0x01b8, 0x2068,
-	0x2079, 0x0000, 0x2c08, 0x911e, 0x1118, 0x680c, 0xb8ae, 0x0060,
-	0x9106, 0x0140, 0x2d00, 0x2078, 0x680c, 0x9005, 0x090c, 0x0dd5,
-	0x2068, 0x0cb0, 0x6b0c, 0x7b0e, 0x600f, 0x0000, 0x2079, 0x0300,
-	0x781b, 0x0200, 0x003e, 0x00de, 0x00fe, 0x0005, 0x00e6, 0x00d6,
-	0x0096, 0x00c6, 0x0036, 0x0126, 0x2091, 0x8000, 0x0156, 0x20a9,
-	0x01ff, 0x2071, 0x0300, 0x701b, 0x0200, 0x7018, 0xd094, 0x0110,
-	0x1f04, 0x8d1b, 0x701b, 0x0202, 0xa001, 0xa001, 0x7018, 0xd094,
-	0x1d90, 0xb8ac, 0x9005, 0x01d0, 0x2060, 0x600c, 0xb8ae, 0x6003,
-	0x0004, 0x601b, 0x0000, 0x6013, 0x0000, 0x601f, 0x0101, 0x6014,
-	0x2048, 0xa88b, 0x0000, 0xa8a8, 0xa8ab, 0x0000, 0x904d, 0x090c,
-	0x0dd5, 0x080c, 0x1031, 0x080c, 0x88d6, 0x0c18, 0x2071, 0x0300,
-	0x701b, 0x0200, 0x015e, 0x012e, 0x003e, 0x00ce, 0x009e, 0x00de,
-	0x00ee, 0x0005, 0x00c6, 0x00b6, 0x0016, 0x0006, 0x0156, 0x080c,
-	0x2840, 0x015e, 0x11b0, 0x080c, 0x65a7, 0x190c, 0x0dd5, 0x000e,
-	0x001e, 0xb912, 0xb816, 0x080c, 0xae1b, 0x0140, 0x2b00, 0x6012,
-	0x6023, 0x0001, 0x2009, 0x0001, 0x080c, 0xaeec, 0x00be, 0x00ce,
-	0x0005, 0x000e, 0x001e, 0x0cd0, 0x0066, 0x6000, 0x90b2, 0x0016,
-	0x1a0c, 0x0dd5, 0x0013, 0x006e, 0x0005, 0x8d8d, 0x8d8d, 0x8d8d,
-	0x8d8f, 0x8de0, 0x8d8d, 0x8d8d, 0x8d8d, 0x8e43, 0x8d8d, 0x8e80,
-	0x8d8d, 0x8d8d, 0x8d8d, 0x8d8d, 0x8d8d, 0x080c, 0x0dd5, 0x9182,
-	0x0040, 0x0002, 0x8da2, 0x8da2, 0x8da2, 0x8da2, 0x8da2, 0x8da2,
-	0x8da2, 0x8da2, 0x8da2, 0x8da4, 0x8db9, 0x8da2, 0x8da2, 0x8da2,
-	0x8da2, 0x8dcc, 0x080c, 0x0dd5, 0x0096, 0x080c, 0x9637, 0x080c,
-	0x97b5, 0x6114, 0x2148, 0xa87b, 0x0000, 0x6010, 0x00b6, 0x2058,
-	0xb8bb, 0x0500, 0x00be, 0x080c, 0x6a8c, 0x080c, 0xae71, 0x009e,
-	0x0005, 0x080c, 0x9637, 0x00d6, 0x6114, 0x080c, 0xcb4a, 0x0130,
-	0x0096, 0x6114, 0x2148, 0x080c, 0x6c86, 0x009e, 0x00de, 0x080c,
-	0xae71, 0x080c, 0x97b5, 0x0005, 0x080c, 0x9637, 0x080c, 0x31c1,
-	0x6114, 0x0096, 0x2148, 0x080c, 0xcb4a, 0x0120, 0xa87b, 0x0029,
-	0x080c, 0x6c86, 0x009e, 0x080c, 0xae71, 0x080c, 0x97b5, 0x0005,
-	0x601b, 0x0000, 0x9182, 0x0040, 0x0096, 0x0002, 0x8dfb, 0x8dfb,
-	0x8dfb, 0x8dfb, 0x8dfb, 0x8dfb, 0x8dfb, 0x8dfb, 0x8dfd, 0x8dfb,
-	0x8dfb, 0x8dfb, 0x8e3f, 0x8dfb, 0x8dfb, 0x8dfb, 0x8dfb, 0x8dfb,
-	0x8dfb, 0x8e03, 0x8dfb, 0x080c, 0x0dd5, 0x6114, 0x2148, 0xa938,
-	0x918e, 0xffff, 0x05e0, 0x00e6, 0x6114, 0x2148, 0x080c, 0x8bac,
-	0x0096, 0xa8a8, 0x2048, 0x080c, 0x6a24, 0x009e, 0xa8ab, 0x0000,
-	0x6010, 0x9005, 0x0128, 0x00b6, 0x2058, 0x080c, 0x8cdb, 0x00be,
-	0xae88, 0x00b6, 0x2059, 0x0000, 0x080c, 0x88df, 0x00be, 0x01e0,
-	0x2071, 0x193c, 0x080c, 0x8926, 0x01b8, 0x9086, 0x0001, 0x1128,
-	0x2001, 0x1946, 0x2004, 0x9005, 0x1178, 0x0096, 0x080c, 0x0fff,
-	0x2900, 0x009e, 0x0148, 0xa8aa, 0x00f6, 0x2c78, 0x080c, 0x889d,
-	0x00fe, 0x00ee, 0x009e, 0x0005, 0x080c, 0x88d6, 0x0cd0, 0x080c,
-	0x8eed, 0x009e, 0x0005, 0x9182, 0x0040, 0x0096, 0x0002, 0x8e57,
-	0x8e57, 0x8e57, 0x8e59, 0x8e57, 0x8e57, 0x8e57, 0x8e7e, 0x8e57,
-	0x8e57, 0x8e57, 0x8e57, 0x8e57, 0x8e57, 0x8e57, 0x8e57, 0x080c,
-	0x0dd5, 0x6003, 0x0003, 0x6106, 0x6014, 0x2048, 0xa8ac, 0xa846,
-	0xa8b0, 0xa84a, 0xa837, 0x0000, 0xa83b, 0x0000, 0xa884, 0x9092,
-	0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x8013, 0x8213, 0x9210,
-	0x621a, 0x2c10, 0x080c, 0x1baf, 0x080c, 0x913e, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x97b5, 0x012e, 0x009e, 0x0005, 0x080c, 0x0dd5,
-	0x080c, 0x9637, 0x080c, 0x97b5, 0x6114, 0x2148, 0xa87b, 0x0000,
-	0x6010, 0x00b6, 0x2058, 0xb8bb, 0x0500, 0x00be, 0x080c, 0x6c86,
-	0x080c, 0xae71, 0x009e, 0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c,
-	0x0dd5, 0x0096, 0x0013, 0x009e, 0x0005, 0x8ead, 0x8ead, 0x8ead,
-	0x8eaf, 0x8ec0, 0x8ead, 0x8ead, 0x8ead, 0x8ead, 0x8ead, 0x8ead,
-	0x8ead, 0x8ead, 0x8ead, 0x8ead, 0x8ead, 0x080c, 0x0dd5, 0x080c,
-	0xa7cd, 0x6114, 0x2148, 0xa87b, 0x0006, 0x6010, 0x00b6, 0x2058,
-	0xb8bb, 0x0500, 0x00be, 0x080c, 0x6c86, 0x080c, 0xae71, 0x0005,
-	0x0461, 0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0dd5, 0x0096,
-	0x0013, 0x009e, 0x0005, 0x8edb, 0x8edb, 0x8edb, 0x8edd, 0x8eed,
-	0x8edb, 0x8edb, 0x8edb, 0x8edb, 0x8edb, 0x8edb, 0x8edb, 0x8edb,
-	0x8edb, 0x8edb, 0x8edb, 0x080c, 0x0dd5, 0x0036, 0x00e6, 0x2071,
-	0x19e6, 0x703c, 0x9c06, 0x1120, 0x2019, 0x0000, 0x080c, 0xa5b7,
-	0x080c, 0xa7cd, 0x00ee, 0x003e, 0x0005, 0x00f6, 0x00e6, 0x601b,
-	0x0000, 0x6014, 0x2048, 0x6010, 0x9005, 0x0128, 0x00b6, 0x2058,
-	0x080c, 0x8cdb, 0x00be, 0x2071, 0x193c, 0x080c, 0x8926, 0x0160,
-	0x2001, 0x187f, 0x2004, 0xa88a, 0x2031, 0x0000, 0x2c78, 0x080c,
-	0x889d, 0x00ee, 0x00fe, 0x0005, 0x0096, 0xa88b, 0x0000, 0xa8a8,
-	0x2048, 0x080c, 0x1031, 0x009e, 0xa8ab, 0x0000, 0x080c, 0x88d6,
-	0x0c80, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x187a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0126, 0x2091, 0x8000, 0x0036, 0x0046, 0x20a9, 0x0010,
-	0x9006, 0x8004, 0x2019, 0x0100, 0x231c, 0x93a6, 0x0008, 0x1118,
-	0x8086, 0x818e, 0x0020, 0x80f6, 0x3e00, 0x81f6, 0x3e08, 0x1208,
-	0x9200, 0x1f04, 0x8f32, 0x93a6, 0x0008, 0x1118, 0x8086, 0x818e,
-	0x0020, 0x80f6, 0x3e00, 0x81f6, 0x3e08, 0x004e, 0x003e, 0x012e,
-	0x0005, 0x0126, 0x2091, 0x8000, 0x0076, 0x0156, 0x20a9, 0x0010,
-	0x9005, 0x0510, 0x911a, 0x1600, 0x8213, 0x2039, 0x0100, 0x273c,
-	0x97be, 0x0008, 0x1110, 0x818d, 0x0010, 0x81f5, 0x3e08, 0x0228,
-	0x911a, 0x1220, 0x1f04, 0x8f5c, 0x0028, 0x911a, 0x2308, 0x8210,
-	0x1f04, 0x8f5c, 0x0006, 0x3200, 0x9084, 0xefff, 0x2080, 0x000e,
-	0x015e, 0x007e, 0x012e, 0x0005, 0x0006, 0x3200, 0x9085, 0x1000,
-	0x0ca8, 0x0126, 0x2091, 0x2800, 0x2079, 0x19e6, 0x012e, 0x00d6,
-	0x2069, 0x19e6, 0x6803, 0x0005, 0x0156, 0x0146, 0x01d6, 0x20e9,
-	0x0000, 0x2069, 0x0200, 0x080c, 0xab2c, 0x0401, 0x080c, 0xab17,
-	0x00e9, 0x080c, 0xab1a, 0x00d1, 0x080c, 0xab1d, 0x00b9, 0x080c,
-	0xab20, 0x00a1, 0x080c, 0xab23, 0x0089, 0x080c, 0xab26, 0x0071,
-	0x080c, 0xab29, 0x0059, 0x01de, 0x014e, 0x015e, 0x2069, 0x0004,
-	0x2d04, 0x9085, 0x8001, 0x206a, 0x00de, 0x0005, 0x20a9, 0x0020,
-	0x20a1, 0x0240, 0x2001, 0x0000, 0x4004, 0x0005, 0x00c6, 0x6027,
-	0x0001, 0x7804, 0x9084, 0x0007, 0x0002, 0x8fcf, 0x8ff3, 0x9032,
-	0x8fd5, 0x8ff3, 0x8fcf, 0x8fcd, 0x8fcd, 0x080c, 0x0dd5, 0x080c,
-	0x8562, 0x080c, 0x9687, 0x00ce, 0x0005, 0x62c0, 0x82ff, 0x1110,
-	0x00ce, 0x0005, 0x2011, 0x5e8c, 0x080c, 0x84dc, 0x7828, 0x9092,
-	0x00c8, 0x1228, 0x8000, 0x782a, 0x080c, 0x5ecc, 0x0c88, 0x62c0,
-	0x080c, 0xac68, 0x080c, 0x5e8c, 0x7807, 0x0003, 0x7827, 0x0000,
-	0x782b, 0x0000, 0x0c28, 0x080c, 0x8562, 0x6220, 0xd2a4, 0x0160,
+	0x908a, 0x0040, 0x0610, 0x00c0, 0x2001, 0x1800, 0x200c, 0x9186,
+	0x0003, 0x1168, 0x7004, 0x0002, 0x7757, 0x7731, 0x7757, 0x7755,
+	0x7757, 0x7757, 0x7757, 0x7757, 0x7757, 0x080c, 0x77c2, 0x782c,
+	0xd09c, 0x090c, 0x7c86, 0x0005, 0x9082, 0x005a, 0x1218, 0x2100,
+	0x003b, 0x0c10, 0x080c, 0x77f8, 0x0c90, 0x00e3, 0x08e8, 0x0005,
+	0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8,
+	0x781a, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8,
+	0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8,
+	0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x7804, 0x77f8, 0x79ed, 0x77f8,
+	0x77f8, 0x77f8, 0x781a, 0x77f8, 0x7804, 0x7a2e, 0x7a6f, 0x7ab6,
+	0x7aca, 0x77f8, 0x77f8, 0x781a, 0x7804, 0x782e, 0x77f8, 0x78a6,
+	0x7b75, 0x7b90, 0x77f8, 0x781a, 0x77f8, 0x782e, 0x77f8, 0x77f8,
+	0x789c, 0x7b90, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8,
+	0x77f8, 0x77f8, 0x77f8, 0x7842, 0x77f8, 0x77f8, 0x77f8, 0x77f8,
+	0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x77f8, 0x7d0c, 0x77f8, 0x7cb6,
+	0x77f8, 0x7cb6, 0x77f8, 0x7857, 0x77f8, 0x77f8, 0x77f8, 0x77f8,
+	0x77f8, 0x77f8, 0x2079, 0x0040, 0x7004, 0x9086, 0x0003, 0x1198,
+	0x782c, 0x080c, 0x7caf, 0xd0a4, 0x0170, 0x7824, 0x2048, 0x9006,
+	0xa802, 0xa806, 0xa864, 0x9084, 0x00ff, 0x908a, 0x001a, 0x1210,
+	0x002b, 0x0c50, 0x00e9, 0x080c, 0x7c86, 0x0005, 0x77f8, 0x7804,
+	0x79d9, 0x77f8, 0x7804, 0x77f8, 0x7804, 0x7804, 0x77f8, 0x7804,
+	0x79d9, 0x7804, 0x7804, 0x7804, 0x7804, 0x7804, 0x77f8, 0x7804,
+	0x79d9, 0x77f8, 0x77f8, 0x7804, 0x77f8, 0x77f8, 0x77f8, 0x7804,
+	0x00e6, 0x2071, 0x18fa, 0x2009, 0x0400, 0x0071, 0x00ee, 0x0005,
+	0x2009, 0x1000, 0x0049, 0x0005, 0x2009, 0x2000, 0x0029, 0x0005,
+	0x2009, 0x0800, 0x0009, 0x0005, 0x7007, 0x0001, 0xa868, 0x9084,
+	0x00ff, 0x9105, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c, 0x6c94,
+	0x012e, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0d08, 0x8001,
+	0x1120, 0x7007, 0x0001, 0x0804, 0x797b, 0x7007, 0x0003, 0x7012,
+	0x2900, 0x7016, 0x701a, 0x704b, 0x797b, 0x0005, 0xa864, 0x8007,
+	0x9084, 0x00ff, 0x0968, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804,
+	0x7996, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b,
+	0x7996, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0904, 0x7800,
+	0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x79b2, 0x7007, 0x0003,
+	0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x79b2, 0x0005, 0xa864,
+	0x8007, 0x9084, 0x00ff, 0x9086, 0x0001, 0x1904, 0x7800, 0x7007,
+	0x0001, 0x2009, 0x1834, 0x210c, 0x81ff, 0x11a8, 0xa868, 0x9084,
+	0x00ff, 0xa86a, 0xa883, 0x0000, 0x080c, 0x62c1, 0x1108, 0x0005,
+	0x0126, 0x2091, 0x8000, 0xa867, 0x0139, 0xa87a, 0xa982, 0x080c,
+	0x6c94, 0x012e, 0x0ca0, 0xa994, 0x9186, 0x0071, 0x0d38, 0x9186,
+	0x0064, 0x0d20, 0x9186, 0x007c, 0x0d08, 0x9186, 0x0028, 0x09f0,
+	0x9186, 0x0038, 0x09d8, 0x9186, 0x0078, 0x09c0, 0x9186, 0x005f,
+	0x09a8, 0x9186, 0x0056, 0x0990, 0xa897, 0x4005, 0xa89b, 0x0001,
+	0x2001, 0x0030, 0x900e, 0x08a0, 0xa87c, 0x9084, 0x00c0, 0x9086,
+	0x00c0, 0x1120, 0x7007, 0x0001, 0x0804, 0x7ba7, 0x2900, 0x7016,
+	0x701a, 0x20a9, 0x0004, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0030,
+	0x2098, 0x7050, 0x2040, 0xa060, 0x20e8, 0xa05c, 0x9080, 0x0023,
+	0x20a0, 0x4003, 0xa888, 0x7012, 0x9082, 0x0401, 0x1a04, 0x7808,
+	0xaab4, 0x928a, 0x0002, 0x1a04, 0x7808, 0x82ff, 0x1138, 0xa8b8,
+	0xa9bc, 0x9105, 0x0118, 0x2001, 0x7939, 0x0018, 0x9280, 0x792f,
+	0x2005, 0x7056, 0x7010, 0x9015, 0x0904, 0x791a, 0x080c, 0x1018,
+	0x1118, 0x7007, 0x0004, 0x0005, 0x2900, 0x7022, 0x7054, 0x2060,
+	0xe000, 0xa866, 0x7050, 0x2040, 0xa95c, 0xe004, 0x9100, 0xa076,
+	0xa860, 0xa072, 0xe008, 0x920a, 0x1210, 0x900e, 0x2200, 0x7112,
+	0xe20c, 0x8003, 0x800b, 0x9296, 0x0004, 0x0108, 0x9108, 0xa17a,
+	0x810b, 0xa17e, 0x080c, 0x10e9, 0xa06c, 0x908e, 0x0100, 0x0170,
+	0x9086, 0x0200, 0x0118, 0x7007, 0x0007, 0x0005, 0x7020, 0x2048,
+	0x080c, 0x1031, 0x7014, 0x2048, 0x0804, 0x7808, 0x7020, 0x2048,
+	0x7018, 0xa802, 0xa807, 0x0000, 0x2908, 0x2048, 0xa906, 0x711a,
+	0x0804, 0x78d2, 0x7014, 0x2048, 0x7007, 0x0001, 0xa8b4, 0x9005,
+	0x1128, 0xa8b8, 0xa9bc, 0x9105, 0x0108, 0x00b9, 0xa864, 0x9084,
+	0x00ff, 0x9086, 0x001e, 0x0904, 0x7ba7, 0x0804, 0x797b, 0x7931,
+	0x7935, 0x0002, 0x001d, 0x0007, 0x0004, 0x000a, 0x001b, 0x0005,
+	0x0006, 0x000a, 0x001d, 0x0005, 0x0004, 0x0076, 0x0066, 0xafb8,
+	0xaebc, 0xa804, 0x2050, 0xb0c0, 0xb0e2, 0xb0bc, 0xb0de, 0xb0b8,
+	0xb0d2, 0xb0b4, 0xb0ce, 0xb6da, 0xb7d6, 0xb0b0, 0xb0ca, 0xb0ac,
+	0xb0c6, 0xb0a8, 0xb0ba, 0xb0a4, 0xb0b6, 0xb6c2, 0xb7be, 0xb0a0,
+	0xb0b2, 0xb09c, 0xb0ae, 0xb098, 0xb0a2, 0xb094, 0xb09e, 0xb6aa,
+	0xb7a6, 0xb090, 0xb09a, 0xb08c, 0xb096, 0xb088, 0xb08a, 0xb084,
+	0xb086, 0xb692, 0xb78e, 0xb080, 0xb082, 0xb07c, 0xb07e, 0xb078,
+	0xb072, 0xb074, 0xb06e, 0xb67a, 0xb776, 0xb004, 0x9055, 0x1958,
+	0x006e, 0x007e, 0x0005, 0x2009, 0x1834, 0x210c, 0x81ff, 0x1178,
+	0x080c, 0x60c1, 0x1108, 0x0005, 0x080c, 0x6ec7, 0x0126, 0x2091,
+	0x8000, 0x080c, 0xce4e, 0x080c, 0x6c94, 0x012e, 0x0ca0, 0x080c,
+	0xd253, 0x1d70, 0x2001, 0x0028, 0x900e, 0x0c70, 0x2009, 0x1834,
+	0x210c, 0x81ff, 0x1188, 0xa888, 0x9005, 0x0188, 0xa883, 0x0000,
+	0x080c, 0x6151, 0x1108, 0x0005, 0xa87a, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x6c94, 0x012e, 0x0cb8, 0x2001, 0x0028, 0x0ca8, 0x2001,
+	0x0000, 0x0c90, 0x2009, 0x1834, 0x210c, 0x81ff, 0x11d8, 0xa888,
+	0x9005, 0x01e0, 0xa883, 0x0000, 0xa87c, 0xd0f4, 0x0120, 0x080c,
+	0x6223, 0x1138, 0x0005, 0x9006, 0xa87a, 0x080c, 0x619e, 0x1108,
+	0x0005, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982, 0x080c, 0x6c94,
+	0x012e, 0x0cb0, 0x2001, 0x0028, 0x900e, 0x0c98, 0x2001, 0x0000,
+	0x0c80, 0x7018, 0xa802, 0x2908, 0x2048, 0xa906, 0x711a, 0x7010,
+	0x8001, 0x7012, 0x0118, 0x7007, 0x0003, 0x0030, 0x7014, 0x2048,
+	0x7007, 0x0001, 0x7048, 0x080f, 0x0005, 0x00b6, 0x7007, 0x0001,
+	0xa974, 0xa878, 0x9084, 0x00ff, 0x9096, 0x0004, 0x0540, 0x20a9,
+	0x0001, 0x9096, 0x0001, 0x0190, 0x900e, 0x20a9, 0x0800, 0x9096,
+	0x0002, 0x0160, 0x9005, 0x11d8, 0xa974, 0x080c, 0x6616, 0x11b8,
+	0x0066, 0xae80, 0x080c, 0x6726, 0x006e, 0x0088, 0x0046, 0x2011,
+	0x180c, 0x2224, 0xc484, 0x2412, 0x004e, 0x00c6, 0x080c, 0x6616,
+	0x1110, 0x080c, 0x6826, 0x8108, 0x1f04, 0x7a16, 0x00ce, 0xa87c,
+	0xd084, 0x1120, 0x080c, 0x1031, 0x00be, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x6c94, 0x012e, 0x00be, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x7007, 0x0001, 0x080c, 0x6985, 0x0580, 0x2061, 0x1a70,
+	0x6100, 0xd184, 0x0178, 0xa888, 0x9084, 0x00ff, 0x1550, 0x6000,
+	0xd084, 0x0520, 0x6004, 0x9005, 0x1538, 0x6003, 0x0000, 0x600b,
+	0x0000, 0x00c8, 0x2011, 0x0001, 0xa890, 0x9005, 0x1110, 0x2001,
+	0x001e, 0x8000, 0x6016, 0xa888, 0x9084, 0x00ff, 0x0178, 0x6006,
+	0xa888, 0x8007, 0x9084, 0x00ff, 0x0148, 0x600a, 0xa888, 0x8000,
+	0x1108, 0xc28d, 0x6202, 0x012e, 0x0804, 0x7c70, 0x012e, 0x0804,
+	0x7c6a, 0x012e, 0x0804, 0x7c64, 0x012e, 0x0804, 0x7c67, 0x0126,
+	0x2091, 0x8000, 0x7007, 0x0001, 0x080c, 0x6985, 0x05e0, 0x2061,
+	0x1a70, 0x6000, 0xd084, 0x05b8, 0x6204, 0x6308, 0xd08c, 0x1530,
+	0xac78, 0x9484, 0x0003, 0x0170, 0xa988, 0x918c, 0x00ff, 0x8001,
+	0x1120, 0x2100, 0x9210, 0x0620, 0x0028, 0x8001, 0x1508, 0x2100,
+	0x9212, 0x02f0, 0x9484, 0x000c, 0x0188, 0xa988, 0x810f, 0x918c,
+	0x00ff, 0x9082, 0x0004, 0x1120, 0x2100, 0x9318, 0x0288, 0x0030,
+	0x9082, 0x0004, 0x1168, 0x2100, 0x931a, 0x0250, 0xa890, 0x9005,
+	0x0110, 0x8000, 0x6016, 0x6206, 0x630a, 0x012e, 0x0804, 0x7c70,
+	0x012e, 0x0804, 0x7c6d, 0x012e, 0x0804, 0x7c6a, 0x0126, 0x2091,
+	0x8000, 0x7007, 0x0001, 0x2061, 0x1a70, 0x6300, 0xd38c, 0x1120,
+	0x6308, 0x8318, 0x0220, 0x630a, 0x012e, 0x0804, 0x7c7e, 0x012e,
+	0x0804, 0x7c6d, 0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x7007,
+	0x0001, 0xa87c, 0xd0ac, 0x0148, 0x00c6, 0x2061, 0x1a70, 0x6000,
+	0x9084, 0xfcff, 0x6002, 0x00ce, 0x0440, 0xa888, 0x9005, 0x05d8,
+	0xa88c, 0x9065, 0x0598, 0x2001, 0x1834, 0x2004, 0x9005, 0x0118,
+	0x080c, 0xae90, 0x0068, 0x6017, 0xf400, 0x605b, 0x0000, 0xa97c,
+	0xd1a4, 0x0110, 0xa980, 0x615a, 0x2009, 0x0041, 0x080c, 0xaeda,
+	0xa988, 0x918c, 0xff00, 0x9186, 0x2000, 0x1138, 0x0026, 0x900e,
+	0x2011, 0xfdff, 0x080c, 0x86e3, 0x002e, 0xa87c, 0xd0c4, 0x0148,
+	0x2061, 0x1a70, 0x6000, 0xd08c, 0x1120, 0x6008, 0x8000, 0x0208,
+	0x600a, 0x00ce, 0x012e, 0x00be, 0x0804, 0x7c70, 0x00ce, 0x012e,
+	0x00be, 0x0804, 0x7c6a, 0xa984, 0x9186, 0x002e, 0x0d30, 0x9186,
+	0x002d, 0x0d18, 0x9186, 0x0045, 0x0510, 0x9186, 0x002a, 0x1130,
+	0x2001, 0x180c, 0x200c, 0xc194, 0x2102, 0x08b8, 0x9186, 0x0020,
+	0x0158, 0x9186, 0x0029, 0x1d10, 0xa974, 0x080c, 0x6616, 0x1968,
+	0xb800, 0xc0e4, 0xb802, 0x0848, 0xa88c, 0x9065, 0x09b8, 0x6007,
+	0x0024, 0x2001, 0x1985, 0x2004, 0x601a, 0x0804, 0x7b05, 0xa88c,
+	0x9065, 0x0960, 0x00e6, 0xa890, 0x9075, 0x2001, 0x1834, 0x2004,
+	0x9005, 0x0150, 0x080c, 0xae90, 0x8eff, 0x0118, 0x2e60, 0x080c,
+	0xae90, 0x00ee, 0x0804, 0x7b05, 0x6024, 0xc0dc, 0xc0d5, 0x6026,
+	0x2e60, 0x6007, 0x003a, 0xa8a0, 0x9005, 0x0130, 0x6007, 0x003b,
+	0xa8a4, 0x602e, 0xa8a8, 0x6016, 0x6003, 0x0001, 0x080c, 0x90f8,
+	0x080c, 0x96a6, 0x00ee, 0x0804, 0x7b05, 0x2061, 0x1a70, 0x6000,
+	0xd084, 0x0190, 0xd08c, 0x1904, 0x7c7e, 0x0126, 0x2091, 0x8000,
+	0x6204, 0x8210, 0x0220, 0x6206, 0x012e, 0x0804, 0x7c7e, 0x012e,
+	0xa883, 0x0016, 0x0804, 0x7c77, 0xa883, 0x0007, 0x0804, 0x7c77,
+	0xa864, 0x8007, 0x9084, 0x00ff, 0x0130, 0x8001, 0x1138, 0x7007,
+	0x0001, 0x0069, 0x0005, 0x080c, 0x7800, 0x0040, 0x7007, 0x0003,
+	0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x7ba7, 0x0005, 0x00b6,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x903e, 0x2061, 0x1800, 0x61d0,
+	0x81ff, 0x1904, 0x7c29, 0x6130, 0xd194, 0x1904, 0x7c53, 0xa878,
+	0x2070, 0x9e82, 0x1cd0, 0x0a04, 0x7c1d, 0x6068, 0x9e02, 0x1a04,
+	0x7c1d, 0x7120, 0x9186, 0x0006, 0x1904, 0x7c0f, 0x7010, 0x905d,
+	0x0904, 0x7c29, 0xb800, 0xd0e4, 0x1904, 0x7c4d, 0x2061, 0x1a70,
+	0x6100, 0x9184, 0x0301, 0x9086, 0x0001, 0x15a0, 0x7024, 0xd0dc,
+	0x1904, 0x7c56, 0xa883, 0x0000, 0xa803, 0x0000, 0x2908, 0x7014,
+	0x9005, 0x1198, 0x7116, 0xa87c, 0xd0f4, 0x1904, 0x7c59, 0x080c,
+	0x56e2, 0xd09c, 0x1118, 0xa87c, 0xc0cc, 0xa87e, 0x2e60, 0x080c,
+	0x8603, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2048, 0xa800, 0x9005,
+	0x1de0, 0xa902, 0x2148, 0xa87c, 0xd0f4, 0x1904, 0x7c59, 0x012e,
+	0x00ee, 0x00be, 0x0005, 0x012e, 0x00ee, 0xa883, 0x0006, 0x00be,
+	0x0804, 0x7c77, 0xd184, 0x0db8, 0xd1c4, 0x1190, 0x00a0, 0xa974,
+	0x080c, 0x6616, 0x15d0, 0xb800, 0xd0e4, 0x15b8, 0x7120, 0x9186,
+	0x0007, 0x1118, 0xa883, 0x0002, 0x0490, 0xa883, 0x0008, 0x0478,
+	0xa883, 0x000e, 0x0460, 0xa883, 0x0017, 0x0448, 0xa883, 0x0035,
+	0x0430, 0x080c, 0x56e6, 0xd0fc, 0x01e8, 0xa878, 0x2070, 0x9e82,
+	0x1cd0, 0x02c0, 0x6068, 0x9e02, 0x12a8, 0x7120, 0x9186, 0x0006,
+	0x1188, 0x7010, 0x905d, 0x0170, 0xb800, 0xd0bc, 0x0158, 0x2039,
+	0x0001, 0x7000, 0x9086, 0x0007, 0x1904, 0x7bb3, 0x7003, 0x0002,
+	0x0804, 0x7bb3, 0xa883, 0x0028, 0x0010, 0xa883, 0x0029, 0x012e,
+	0x00ee, 0x00be, 0x0420, 0xa883, 0x002a, 0x0cc8, 0xa883, 0x0045,
+	0x0cb0, 0x2e60, 0x2019, 0x0002, 0x601b, 0x0014, 0x080c, 0xe16f,
+	0x012e, 0x00ee, 0x00be, 0x0005, 0x2009, 0x003e, 0x0058, 0x2009,
+	0x0004, 0x0040, 0x2009, 0x0006, 0x0028, 0x2009, 0x0016, 0x0010,
+	0x2009, 0x0001, 0xa884, 0x9084, 0xff00, 0x9105, 0xa886, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x6c94, 0x012e, 0x0005, 0x080c, 0x1031,
+	0x0005, 0x00d6, 0x080c, 0x85fa, 0x00de, 0x0005, 0x00d6, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x0040, 0x702c, 0xd084, 0x01d8,
+	0x908c, 0x0780, 0x190c, 0x7d68, 0xd09c, 0x11a8, 0x2071, 0x1800,
+	0x70c0, 0x90ea, 0x0020, 0x0278, 0x8001, 0x70c2, 0x702c, 0x2048,
+	0xa800, 0x702e, 0x9006, 0xa802, 0xa806, 0x2071, 0x0040, 0x2900,
+	0x7022, 0x702c, 0x0c28, 0x012e, 0x00ee, 0x00de, 0x0005, 0x0006,
+	0x9084, 0x0780, 0x190c, 0x7d68, 0x000e, 0x0005, 0xa898, 0x9084,
+	0x0003, 0x05a8, 0x080c, 0xae09, 0x05d8, 0x2900, 0x6016, 0xa864,
+	0x9084, 0x00ff, 0x9086, 0x0035, 0x1138, 0x6008, 0xc0fd, 0x600a,
+	0x2001, 0x196a, 0x2004, 0x0098, 0xa8a0, 0x9084, 0x00ff, 0xa99c,
+	0x918c, 0xff00, 0x9105, 0xa99c, 0x918c, 0x00ff, 0x080c, 0x284b,
+	0x1540, 0x00b6, 0x080c, 0x6616, 0x2b00, 0x00be, 0x1510, 0x6012,
+	0x6023, 0x0001, 0x2009, 0x0040, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x0035, 0x0110, 0x2009, 0x0041, 0x080c, 0xaeda, 0x0005, 0xa87b,
+	0x0101, 0x0126, 0x2091, 0x8000, 0x080c, 0x6c94, 0x012e, 0x0005,
+	0xa87b, 0x002c, 0x0126, 0x2091, 0x8000, 0x080c, 0x6c94, 0x012e,
+	0x0005, 0xa87b, 0x0028, 0x0126, 0x2091, 0x8000, 0x080c, 0x6c94,
+	0x012e, 0x080c, 0xae5f, 0x0005, 0x00d6, 0x00c6, 0x0036, 0x0026,
+	0x0016, 0x00b6, 0x7007, 0x0001, 0xaa74, 0x9282, 0x0004, 0x1a04,
+	0x7d59, 0xa97c, 0x9188, 0x1000, 0x2104, 0x905d, 0xb804, 0xd284,
+	0x0140, 0x05e8, 0x8007, 0x9084, 0x00ff, 0x9084, 0x0006, 0x1108,
+	0x04b0, 0x2b10, 0x080c, 0xae09, 0x1118, 0x080c, 0xaead, 0x05a8,
+	0x6212, 0xa874, 0x0002, 0x7d37, 0x7d3c, 0x7d3f, 0x7d45, 0x2019,
+	0x0002, 0x080c, 0xe55d, 0x0060, 0x080c, 0xe4f9, 0x0048, 0x2019,
+	0x0002, 0xa980, 0x080c, 0xe514, 0x0018, 0xa980, 0x080c, 0xe4f9,
+	0x080c, 0xae5f, 0xa887, 0x0000, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x6c94, 0x012e, 0x00be, 0x001e, 0x002e, 0x003e, 0x00ce, 0x00de,
+	0x0005, 0xa887, 0x0006, 0x0c80, 0xa887, 0x0002, 0x0c68, 0xa887,
+	0x0005, 0x0c50, 0xa887, 0x0004, 0x0c38, 0xa887, 0x0007, 0x0c20,
+	0x2091, 0x8000, 0x0e04, 0x7d6a, 0x0006, 0x0016, 0x2001, 0x8003,
+	0x0006, 0x0804, 0x0dde, 0x2001, 0x1834, 0x2004, 0x9005, 0x0005,
+	0x0005, 0x00f6, 0x2079, 0x0300, 0x2001, 0x0200, 0x200c, 0xc1e5,
+	0xc1dc, 0x2102, 0x2009, 0x0218, 0x210c, 0xd1ec, 0x1120, 0x080c,
+	0x157f, 0x00fe, 0x0005, 0x2001, 0x020d, 0x2003, 0x0020, 0x781f,
+	0x0300, 0x00fe, 0x0005, 0x781c, 0xd08c, 0x0904, 0x7dea, 0x68c0,
+	0x90aa, 0x0005, 0x0a04, 0x8411, 0x7d44, 0x7c40, 0x9584, 0x00f6,
+	0x1510, 0x9484, 0x7000, 0x0140, 0x908a, 0x2000, 0x1260, 0x9584,
+	0x0700, 0x8007, 0x0804, 0x7df1, 0x7000, 0x9084, 0xff00, 0x9086,
+	0x8100, 0x0da8, 0x00b0, 0x9484, 0x0fff, 0x1130, 0x7000, 0x9084,
+	0xff00, 0x9086, 0x8100, 0x11c0, 0x080c, 0xe9fc, 0x080c, 0x82f6,
+	0x7817, 0x0140, 0x00a8, 0x9584, 0x0076, 0x1118, 0x080c, 0x8354,
+	0x19c0, 0xd5a4, 0x0148, 0x0046, 0x0056, 0x080c, 0x7e4c, 0x080c,
+	0x2344, 0x005e, 0x004e, 0x0020, 0x080c, 0xe9fc, 0x7817, 0x0140,
+	0x080c, 0x73b3, 0x0168, 0x2001, 0x0111, 0x2004, 0xd08c, 0x0140,
+	0x6893, 0x0000, 0x2001, 0x0110, 0x2003, 0x0008, 0x2003, 0x0000,
+	0x080c, 0x7e2d, 0x2001, 0x19ef, 0x2004, 0x9005, 0x090c, 0x96a6,
+	0x0005, 0x0002, 0x7e03, 0x8118, 0x7dfa, 0x7dfa, 0x7dfa, 0x7dfa,
+	0x7dfa, 0x7dfa, 0x7817, 0x0140, 0x2001, 0x19ef, 0x2004, 0x9005,
+	0x090c, 0x96a6, 0x0005, 0x7000, 0x908c, 0xff00, 0x9194, 0xf000,
+	0x810f, 0x9484, 0x0fff, 0x6892, 0x9286, 0x2000, 0x1150, 0x6800,
+	0x9086, 0x0001, 0x1118, 0x080c, 0x5743, 0x0070, 0x080c, 0x7e6c,
+	0x0058, 0x9286, 0x3000, 0x1118, 0x080c, 0x8053, 0x0028, 0x9286,
+	0x8000, 0x1110, 0x080c, 0x8226, 0x7817, 0x0140, 0x2001, 0x19ef,
+	0x2004, 0x9005, 0x090c, 0x96a6, 0x0005, 0x2001, 0x1810, 0x2004,
+	0xd08c, 0x0178, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x1148,
+	0x0026, 0x0036, 0x2011, 0x8048, 0x2518, 0x080c, 0x4b1e, 0x003e,
+	0x002e, 0x0005, 0x0036, 0x0046, 0x0056, 0x00f6, 0x2079, 0x0200,
+	0x2019, 0xfffe, 0x7c30, 0x0050, 0x0036, 0x0046, 0x0056, 0x00f6,
+	0x2079, 0x0200, 0x7d44, 0x7c40, 0x2019, 0xffff, 0x2001, 0x1810,
+	0x2004, 0xd08c, 0x0160, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003,
+	0x1130, 0x0026, 0x2011, 0x8048, 0x080c, 0x4b1e, 0x002e, 0x00fe,
+	0x005e, 0x004e, 0x003e, 0x0005, 0x00b6, 0x00c6, 0x7010, 0x9084,
+	0xff00, 0x8007, 0x9096, 0x0001, 0x0120, 0x9096, 0x0023, 0x1904,
+	0x8024, 0x9186, 0x0023, 0x15c0, 0x080c, 0x82bb, 0x0904, 0x8024,
+	0x6120, 0x9186, 0x0001, 0x0150, 0x9186, 0x0004, 0x0138, 0x9186,
+	0x0008, 0x0120, 0x9186, 0x000a, 0x1904, 0x8024, 0x7124, 0x610a,
+	0x7030, 0x908e, 0x0200, 0x1130, 0x2009, 0x0015, 0x080c, 0xaeda,
+	0x0804, 0x8024, 0x908e, 0x0214, 0x0118, 0x908e, 0x0210, 0x1130,
+	0x2009, 0x0015, 0x080c, 0xaeda, 0x0804, 0x8024, 0x908e, 0x0100,
+	0x1904, 0x8024, 0x7034, 0x9005, 0x1904, 0x8024, 0x2009, 0x0016,
+	0x080c, 0xaeda, 0x0804, 0x8024, 0x9186, 0x0022, 0x1904, 0x8024,
+	0x7030, 0x908e, 0x0300, 0x1580, 0x68dc, 0xd0a4, 0x0528, 0xc0b5,
+	0x68de, 0x7100, 0x918c, 0x00ff, 0x697e, 0x7004, 0x6882, 0x00f6,
+	0x2079, 0x0100, 0x79e6, 0x78ea, 0x0006, 0x9084, 0x00ff, 0x0016,
+	0x2008, 0x080c, 0x2894, 0x7932, 0x7936, 0x001e, 0x000e, 0x00fe,
+	0x080c, 0x284b, 0x695e, 0x703c, 0x00e6, 0x2071, 0x0140, 0x7086,
+	0x2071, 0x1800, 0x70b6, 0x00ee, 0x7034, 0x9005, 0x1904, 0x8024,
+	0x2009, 0x0017, 0x0804, 0x7fd4, 0x908e, 0x0400, 0x1190, 0x7034,
+	0x9005, 0x1904, 0x8024, 0x080c, 0x73b3, 0x0120, 0x2009, 0x001d,
+	0x0804, 0x7fd4, 0x68dc, 0xc0a5, 0x68de, 0x2009, 0x0030, 0x0804,
+	0x7fd4, 0x908e, 0x0500, 0x1140, 0x7034, 0x9005, 0x1904, 0x8024,
+	0x2009, 0x0018, 0x0804, 0x7fd4, 0x908e, 0x2010, 0x1120, 0x2009,
+	0x0019, 0x0804, 0x7fd4, 0x908e, 0x2110, 0x1120, 0x2009, 0x001a,
+	0x0804, 0x7fd4, 0x908e, 0x5200, 0x1140, 0x7034, 0x9005, 0x1904,
+	0x8024, 0x2009, 0x001b, 0x0804, 0x7fd4, 0x908e, 0x5000, 0x1140,
+	0x7034, 0x9005, 0x1904, 0x8024, 0x2009, 0x001c, 0x0804, 0x7fd4,
+	0x908e, 0x1300, 0x1120, 0x2009, 0x0034, 0x0804, 0x7fd4, 0x908e,
+	0x1200, 0x1140, 0x7034, 0x9005, 0x1904, 0x8024, 0x2009, 0x0024,
+	0x0804, 0x7fd4, 0x908c, 0xff00, 0x918e, 0x2400, 0x1170, 0x2009,
+	0x002d, 0x2001, 0x1810, 0x2004, 0xd09c, 0x0904, 0x7fd4, 0x080c,
+	0xd934, 0x1904, 0x8024, 0x0804, 0x7fd2, 0x908c, 0xff00, 0x918e,
+	0x5300, 0x1120, 0x2009, 0x002a, 0x0804, 0x7fd4, 0x908e, 0x0f00,
+	0x1120, 0x2009, 0x0020, 0x0804, 0x7fd4, 0x908e, 0x6104, 0x1530,
+	0x2029, 0x0205, 0x2011, 0x026d, 0x8208, 0x2204, 0x9082, 0x0004,
+	0x8004, 0x8004, 0x20a8, 0x2011, 0x8015, 0x211c, 0x8108, 0x0046,
+	0x2124, 0x080c, 0x4b1e, 0x004e, 0x8108, 0x0f04, 0x7f88, 0x9186,
+	0x0280, 0x1d88, 0x2504, 0x8000, 0x202a, 0x2009, 0x0260, 0x0c58,
+	0x202b, 0x0000, 0x2009, 0x0023, 0x0804, 0x7fd4, 0x908e, 0x6000,
+	0x1120, 0x2009, 0x003f, 0x0804, 0x7fd4, 0x908e, 0x5400, 0x1138,
+	0x080c, 0x83c1, 0x1904, 0x8024, 0x2009, 0x0046, 0x04a8, 0x908e,
+	0x5500, 0x1148, 0x080c, 0x83e9, 0x1118, 0x2009, 0x0041, 0x0460,
+	0x2009, 0x0042, 0x0448, 0x908e, 0x7800, 0x1118, 0x2009, 0x0045,
+	0x0418, 0x908e, 0x1000, 0x1118, 0x2009, 0x004e, 0x00e8, 0x908e,
+	0x6300, 0x1118, 0x2009, 0x004a, 0x00b8, 0x908c, 0xff00, 0x918e,
+	0x5600, 0x1118, 0x2009, 0x004f, 0x0078, 0x908c, 0xff00, 0x918e,
+	0x5700, 0x1118, 0x2009, 0x0050, 0x0038, 0x2009, 0x001d, 0x6838,
+	0xd0d4, 0x0110, 0x2009, 0x004c, 0x0016, 0x2011, 0x0263, 0x2204,
+	0x8211, 0x220c, 0x080c, 0x284b, 0x1904, 0x8027, 0x080c, 0x65b5,
+	0x1904, 0x8027, 0xbe12, 0xbd16, 0x001e, 0x0016, 0x080c, 0x73b3,
+	0x01c0, 0x68dc, 0xd08c, 0x1148, 0x7000, 0x9084, 0x00ff, 0x1188,
+	0x7004, 0x9084, 0xff00, 0x1168, 0x0040, 0x687c, 0x9606, 0x1148,
+	0x6880, 0x9506, 0x9084, 0xff00, 0x1120, 0x9584, 0x00ff, 0xb8c2,
+	0x0080, 0xb8c0, 0x9005, 0x1168, 0x9186, 0x0046, 0x1150, 0x687c,
+	0x9606, 0x1138, 0x6880, 0x9506, 0x9084, 0xff00, 0x1110, 0x001e,
+	0x0098, 0x080c, 0xae09, 0x01a8, 0x2b08, 0x6112, 0x6023, 0x0004,
+	0x7120, 0x610a, 0x001e, 0x9186, 0x004c, 0x1110, 0x6023, 0x000a,
+	0x0016, 0x001e, 0x080c, 0xaeda, 0x00ce, 0x00be, 0x0005, 0x001e,
+	0x0cd8, 0x2001, 0x180e, 0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049,
+	0x080c, 0x4b1e, 0x080c, 0xaead, 0x0d90, 0x2b08, 0x6112, 0x6023,
+	0x0004, 0x7120, 0x610a, 0x001e, 0x0016, 0x9186, 0x0017, 0x0118,
+	0x9186, 0x0030, 0x1128, 0x6007, 0x0009, 0x6017, 0x2900, 0x0020,
+	0x6007, 0x0051, 0x6017, 0x0000, 0x602f, 0x0009, 0x6003, 0x0001,
+	0x080c, 0x9140, 0x08a0, 0x080c, 0x32f0, 0x1140, 0x7010, 0x9084,
+	0xff00, 0x8007, 0x908e, 0x0008, 0x1108, 0x0009, 0x0005, 0x00b6,
+	0x00c6, 0x0046, 0x7000, 0x908c, 0xff00, 0x810f, 0x9186, 0x0033,
+	0x11e8, 0x080c, 0x82bb, 0x0904, 0x80b0, 0x7124, 0x610a, 0x7030,
+	0x908e, 0x0200, 0x1140, 0x7034, 0x9005, 0x15d0, 0x2009, 0x0015,
+	0x080c, 0xaeda, 0x04a8, 0x908e, 0x0100, 0x1590, 0x7034, 0x9005,
+	0x1578, 0x2009, 0x0016, 0x080c, 0xaeda, 0x0450, 0x9186, 0x0032,
+	0x1538, 0x7030, 0x908e, 0x1400, 0x1518, 0x2009, 0x0038, 0x0016,
+	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x284b, 0x11b8,
+	0x080c, 0x65b5, 0x11a0, 0xbe12, 0xbd16, 0x080c, 0xae09, 0x0178,
+	0x2b08, 0x6112, 0x080c, 0xcfd4, 0x6023, 0x0004, 0x7120, 0x610a,
+	0x001e, 0x080c, 0xaeda, 0x080c, 0x96a6, 0x0010, 0x00ce, 0x001e,
+	0x004e, 0x00ce, 0x00be, 0x0005, 0x00b6, 0x0046, 0x00e6, 0x00d6,
+	0x2028, 0x2130, 0x9696, 0x00ff, 0x11b8, 0x9592, 0xfffc, 0x02a0,
+	0x9596, 0xfffd, 0x1120, 0x2009, 0x007f, 0x0804, 0x8112, 0x9596,
+	0xfffe, 0x1120, 0x2009, 0x007e, 0x0804, 0x8112, 0x9596, 0xfffc,
+	0x1118, 0x2009, 0x0080, 0x04f0, 0x2011, 0x0000, 0x2019, 0x1837,
+	0x231c, 0xd3ac, 0x0130, 0x9026, 0x20a9, 0x0800, 0x2071, 0x1000,
+	0x0030, 0x2021, 0x0081, 0x20a9, 0x077f, 0x2071, 0x1081, 0x2e1c,
+	0x93dd, 0x0000, 0x1140, 0x82ff, 0x11d0, 0x9496, 0x00ff, 0x01b8,
+	0x2410, 0xc2fd, 0x00a0, 0xbf10, 0x2600, 0x9706, 0xb814, 0x1120,
+	0x9546, 0x1110, 0x2408, 0x00b0, 0x9745, 0x1148, 0x94c6, 0x007e,
+	0x0130, 0x94c6, 0x007f, 0x0118, 0x94c6, 0x0080, 0x1d20, 0x8420,
+	0x8e70, 0x1f04, 0x80e7, 0x82ff, 0x1118, 0x9085, 0x0001, 0x0018,
+	0xc2fc, 0x2208, 0x9006, 0x00de, 0x00ee, 0x004e, 0x00be, 0x0005,
+	0x7000, 0x908c, 0xff00, 0x810f, 0x9184, 0x000f, 0x0002, 0x812f,
+	0x812f, 0x812f, 0x82cd, 0x812f, 0x8138, 0x8163, 0x81f1, 0x812f,
+	0x812f, 0x812f, 0x812f, 0x812f, 0x812f, 0x812f, 0x812f, 0x7817,
+	0x0140, 0x2001, 0x19ef, 0x2004, 0x9005, 0x090c, 0x96a6, 0x0005,
+	0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7120, 0x2160, 0x9c8c, 0x0007,
+	0x11c0, 0x9c8a, 0x1cd0, 0x02a8, 0x6868, 0x9c02, 0x1290, 0x7008,
+	0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1150, 0x700c,
+	0xb914, 0x9106, 0x1130, 0x7124, 0x610a, 0x2009, 0x0046, 0x080c,
+	0xaeda, 0x7817, 0x0140, 0x2001, 0x19ef, 0x2004, 0x9005, 0x090c,
+	0x96a6, 0x00be, 0x0005, 0x00b6, 0x00c6, 0x9484, 0x0fff, 0x0904,
+	0x81c7, 0x7110, 0xd1bc, 0x1904, 0x81c7, 0x7108, 0x700c, 0x2028,
+	0x918c, 0x00ff, 0x2130, 0x9094, 0xff00, 0x15b0, 0x81ff, 0x15a0,
+	0x9080, 0x3332, 0x200d, 0x918c, 0xff00, 0x810f, 0x2001, 0x0080,
+	0x9106, 0x0904, 0x81c7, 0x080c, 0x65b5, 0x1904, 0x81c7, 0xbe12,
+	0xbd16, 0xb800, 0xd0ec, 0x15d8, 0xba04, 0x9294, 0xff00, 0x9286,
+	0x0600, 0x11a0, 0x080c, 0xae09, 0x05e8, 0x2b08, 0x7028, 0x604a,
+	0x702c, 0x6046, 0x6112, 0x6023, 0x0006, 0x7120, 0x610a, 0x7130,
+	0x6156, 0x2009, 0x0044, 0x080c, 0xdb94, 0x0408, 0x080c, 0x6989,
+	0x1138, 0xb807, 0x0606, 0x0c30, 0x190c, 0x80b4, 0x11c0, 0x0898,
+	0x080c, 0xae09, 0x2b08, 0x0198, 0x6112, 0x6023, 0x0004, 0x7120,
+	0x610a, 0x9286, 0x0400, 0x1118, 0x6007, 0x0005, 0x0010, 0x6007,
+	0x0001, 0x6003, 0x0001, 0x080c, 0x9140, 0x080c, 0x96a6, 0x7817,
+	0x0140, 0x2001, 0x19ef, 0x2004, 0x9005, 0x090c, 0x96a6, 0x00ce,
+	0x00be, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0ec, 0x0120, 0x2011,
+	0x8049, 0x080c, 0x4b1e, 0x080c, 0xaead, 0x0d48, 0x2b08, 0x6112,
+	0x6023, 0x0006, 0x7120, 0x610a, 0x7130, 0x6156, 0x6017, 0xf300,
+	0x6003, 0x0001, 0x6007, 0x0041, 0x080c, 0x90f8, 0x080c, 0x96a6,
+	0x08b0, 0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7020, 0x2060, 0x9c84,
+	0x0007, 0x11c0, 0x9c82, 0x1cd0, 0x02a8, 0x6868, 0x9c02, 0x1290,
+	0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1150,
+	0x700c, 0xb914, 0x9106, 0x1130, 0x7124, 0x610a, 0x2009, 0x0045,
+	0x080c, 0xaeda, 0x7817, 0x0140, 0x2001, 0x19ef, 0x2004, 0x9005,
+	0x090c, 0x96a6, 0x00be, 0x0005, 0x6120, 0x9186, 0x0002, 0x0128,
+	0x9186, 0x0005, 0x0110, 0x9085, 0x0001, 0x0005, 0x080c, 0x32f0,
+	0x1168, 0x7010, 0x9084, 0xff00, 0x8007, 0x9086, 0x0000, 0x1130,
+	0x9184, 0x000f, 0x908a, 0x0006, 0x1208, 0x000b, 0x0005, 0x823d,
+	0x823e, 0x823d, 0x823d, 0x829d, 0x82ac, 0x0005, 0x00b6, 0x7110,
+	0xd1bc, 0x0120, 0x702c, 0xd084, 0x0904, 0x829b, 0x700c, 0x7108,
+	0x080c, 0x284b, 0x1904, 0x829b, 0x080c, 0x65b5, 0x1904, 0x829b,
+	0xbe12, 0xbd16, 0x7110, 0xd1bc, 0x01d8, 0x080c, 0x6989, 0x0118,
+	0x9086, 0x0004, 0x1588, 0x00c6, 0x080c, 0x82bb, 0x00ce, 0x05d8,
+	0x080c, 0xae09, 0x2b08, 0x05b8, 0x6112, 0x080c, 0xcfd4, 0x6023,
+	0x0002, 0x7120, 0x610a, 0x2009, 0x0088, 0x080c, 0xaeda, 0x0458,
+	0x080c, 0x6989, 0x0148, 0x9086, 0x0004, 0x0130, 0x080c, 0x6991,
+	0x0118, 0x9086, 0x0004, 0x1180, 0x080c, 0xae09, 0x2b08, 0x01d8,
+	0x6112, 0x080c, 0xcfd4, 0x6023, 0x0005, 0x7120, 0x610a, 0x2009,
+	0x0088, 0x080c, 0xaeda, 0x0078, 0x080c, 0xae09, 0x2b08, 0x0158,
+	0x6112, 0x080c, 0xcfd4, 0x6023, 0x0004, 0x7120, 0x610a, 0x2009,
+	0x0001, 0x080c, 0xaeda, 0x00be, 0x0005, 0x7110, 0xd1bc, 0x0158,
+	0x00d1, 0x0148, 0x080c, 0x821c, 0x1130, 0x7124, 0x610a, 0x2009,
+	0x0089, 0x080c, 0xaeda, 0x0005, 0x7110, 0xd1bc, 0x0158, 0x0059,
+	0x0148, 0x080c, 0x821c, 0x1130, 0x7124, 0x610a, 0x2009, 0x008a,
+	0x080c, 0xaeda, 0x0005, 0x7020, 0x2060, 0x9c84, 0x0007, 0x1158,
+	0x9c82, 0x1cd0, 0x0240, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1218,
+	0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8, 0x00b6, 0x7110, 0xd1bc,
+	0x11d8, 0x7024, 0x2060, 0x9c84, 0x0007, 0x11b0, 0x9c82, 0x1cd0,
+	0x0298, 0x6868, 0x9c02, 0x1280, 0x7008, 0x9084, 0x00ff, 0x6110,
+	0x2158, 0xb910, 0x9106, 0x1140, 0x700c, 0xb914, 0x9106, 0x1120,
+	0x2009, 0x0051, 0x080c, 0xaeda, 0x7817, 0x0140, 0x2001, 0x19ef,
+	0x2004, 0x9005, 0x090c, 0x96a6, 0x00be, 0x0005, 0x2031, 0x0105,
+	0x0069, 0x0005, 0x2031, 0x0206, 0x0049, 0x0005, 0x2031, 0x0207,
+	0x0029, 0x0005, 0x2031, 0x0213, 0x0009, 0x0005, 0x00c6, 0x0096,
+	0x00f6, 0x7000, 0x9084, 0xf000, 0x9086, 0xc000, 0x05d0, 0x080c,
+	0xae09, 0x05b8, 0x0066, 0x00c6, 0x0046, 0x2011, 0x0263, 0x2204,
+	0x8211, 0x220c, 0x080c, 0x284b, 0x15a0, 0x080c, 0x65b5, 0x1588,
+	0xbe12, 0xbd16, 0x2b00, 0x004e, 0x00ce, 0x6012, 0x080c, 0xcfd4,
+	0x080c, 0x0fff, 0x0510, 0x2900, 0x605a, 0x9006, 0xa802, 0xa866,
+	0xac6a, 0xa85c, 0x90f8, 0x001b, 0x20a9, 0x000e, 0xa860, 0x20e8,
+	0x20e1, 0x0000, 0x2fa0, 0x2e98, 0x4003, 0x006e, 0x6616, 0x6007,
+	0x003e, 0x6023, 0x0001, 0x6003, 0x0001, 0x080c, 0x9140, 0x080c,
+	0x96a6, 0x00fe, 0x009e, 0x00ce, 0x0005, 0x080c, 0xae5f, 0x006e,
+	0x0cc0, 0x004e, 0x00ce, 0x0cc8, 0x00c6, 0x7000, 0x908c, 0xff00,
+	0x9184, 0xf000, 0x810f, 0x9086, 0x2000, 0x1904, 0x83ab, 0x9186,
+	0x0022, 0x15f0, 0x2001, 0x0111, 0x2004, 0x9005, 0x1904, 0x83ad,
+	0x7030, 0x908e, 0x0400, 0x0904, 0x83ad, 0x908e, 0x6000, 0x05e8,
+	0x908e, 0x5400, 0x05d0, 0x908e, 0x0300, 0x11d8, 0x2009, 0x1837,
+	0x210c, 0xd18c, 0x1590, 0xd1a4, 0x1580, 0x080c, 0x6947, 0x0588,
+	0x68b0, 0x9084, 0x00ff, 0x7100, 0x918c, 0x00ff, 0x9106, 0x1518,
+	0x6880, 0x69b0, 0x918c, 0xff00, 0x9105, 0x7104, 0x9106, 0x11d8,
+	0x00e0, 0x2009, 0x0103, 0x210c, 0xd1b4, 0x11a8, 0x908e, 0x5200,
+	0x09e8, 0x908e, 0x0500, 0x09d0, 0x908e, 0x5000, 0x09b8, 0x0058,
+	0x9186, 0x0023, 0x1140, 0x080c, 0x82bb, 0x0128, 0x6004, 0x9086,
+	0x0002, 0x0118, 0x0000, 0x9006, 0x0010, 0x9085, 0x0001, 0x00ce,
+	0x0005, 0x7030, 0x908e, 0x0300, 0x0118, 0x908e, 0x5200, 0x1d98,
+	0x2001, 0x1837, 0x2004, 0x9084, 0x0009, 0x9086, 0x0008, 0x0d68,
+	0x0c50, 0x0156, 0x0046, 0x0016, 0x0036, 0x7038, 0x2020, 0x8427,
+	0x94a4, 0x0007, 0xd484, 0x0148, 0x20a9, 0x0004, 0x2019, 0x1805,
+	0x2011, 0x027a, 0x080c, 0xbe19, 0x1178, 0xd48c, 0x0148, 0x20a9,
+	0x0004, 0x2019, 0x1801, 0x2011, 0x027e, 0x080c, 0xbe19, 0x1120,
+	0xd494, 0x0110, 0x9085, 0x0001, 0x003e, 0x001e, 0x004e, 0x015e,
+	0x0005, 0x0156, 0x0046, 0x0016, 0x0036, 0x7038, 0x2020, 0x8427,
+	0x94a4, 0x0007, 0xd484, 0x0148, 0x20a9, 0x0004, 0x2019, 0x1805,
+	0x2011, 0x0272, 0x080c, 0xbe19, 0x1178, 0xd48c, 0x0148, 0x20a9,
+	0x0004, 0x2019, 0x1801, 0x2011, 0x0276, 0x080c, 0xbe19, 0x1120,
+	0xd494, 0x0110, 0x9085, 0x0001, 0x003e, 0x001e, 0x004e, 0x015e,
+	0x0005, 0x00f6, 0x2079, 0x0200, 0x7800, 0xc0e5, 0xc0cc, 0x7802,
+	0x00fe, 0x0005, 0x00f6, 0x2079, 0x1800, 0x7834, 0xd084, 0x1130,
+	0x2079, 0x0200, 0x7800, 0x9085, 0x1200, 0x7802, 0x00fe, 0x0005,
+	0x00e6, 0x2071, 0x1800, 0x7034, 0xc084, 0x7036, 0x00ee, 0x0005,
+	0x2071, 0x19f9, 0x7003, 0x0003, 0x700f, 0x0361, 0x9006, 0x701a,
+	0x7072, 0x7012, 0x7017, 0x1cd0, 0x7007, 0x0000, 0x7026, 0x702b,
+	0xa2a5, 0x7032, 0x7037, 0xa30d, 0x703f, 0xffff, 0x7042, 0x7047,
+	0x5581, 0x704a, 0x705b, 0x859a, 0x080c, 0x1018, 0x090c, 0x0dd5,
+	0x2900, 0x703a, 0xa867, 0x0003, 0xa86f, 0x0100, 0xa8ab, 0xdcb0,
+	0x0005, 0x2071, 0x19f9, 0x1d04, 0x84e8, 0x2091, 0x6000, 0x700c,
+	0x8001, 0x700e, 0x1530, 0x2001, 0x013c, 0x2004, 0x9005, 0x190c,
+	0x85df, 0x2001, 0x1869, 0x2004, 0xd0c4, 0x0158, 0x3a00, 0xd08c,
+	0x1140, 0x20d1, 0x0000, 0x20d1, 0x0001, 0x20d1, 0x0000, 0x080c,
+	0x0dd5, 0x700f, 0x0361, 0x7007, 0x0001, 0x0126, 0x2091, 0x8000,
+	0x7040, 0x900d, 0x0148, 0x8109, 0x7142, 0x1130, 0x7044, 0x080f,
+	0x0018, 0x0126, 0x2091, 0x8000, 0x7024, 0x900d, 0x0188, 0x7020,
+	0x8001, 0x7022, 0x1168, 0x7023, 0x0009, 0x8109, 0x7126, 0x9186,
+	0x03e8, 0x1110, 0x7028, 0x080f, 0x81ff, 0x1110, 0x7028, 0x080f,
+	0x7030, 0x900d, 0x0180, 0x702c, 0x8001, 0x702e, 0x1160, 0x702f,
+	0x0009, 0x8109, 0x7132, 0x0128, 0x9184, 0x007f, 0x090c, 0xa42a,
+	0x0010, 0x7034, 0x080f, 0x703c, 0x9005, 0x0118, 0x0310, 0x8001,
+	0x703e, 0x704c, 0x900d, 0x0168, 0x7048, 0x8001, 0x704a, 0x1148,
+	0x704b, 0x0009, 0x8109, 0x714e, 0x1120, 0x7150, 0x714e, 0x7058,
+	0x080f, 0x7018, 0x900d, 0x01d8, 0x0016, 0x7070, 0x900d, 0x0158,
+	0x706c, 0x8001, 0x706e, 0x1138, 0x706f, 0x0009, 0x8109, 0x7172,
+	0x1110, 0x7074, 0x080f, 0x001e, 0x7008, 0x8001, 0x700a, 0x1138,
+	0x700b, 0x0009, 0x8109, 0x711a, 0x1110, 0x701c, 0x080f, 0x012e,
+	0x7004, 0x0002, 0x8510, 0x8511, 0x852d, 0x00e6, 0x2071, 0x19f9,
+	0x7018, 0x9005, 0x1120, 0x711a, 0x721e, 0x700b, 0x0009, 0x00ee,
+	0x0005, 0x00e6, 0x0006, 0x2071, 0x19f9, 0x701c, 0x9206, 0x1120,
+	0x701a, 0x701e, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x00e6,
+	0x2071, 0x19f9, 0xb888, 0x9102, 0x0208, 0xb98a, 0x00ee, 0x0005,
+	0x0005, 0x00b6, 0x7110, 0x080c, 0x6616, 0x1168, 0xb888, 0x8001,
+	0x0250, 0xb88a, 0x1140, 0x0126, 0x2091, 0x8000, 0x0016, 0x080c,
+	0x96a6, 0x001e, 0x012e, 0x8108, 0x9182, 0x0800, 0x0218, 0x900e,
+	0x7007, 0x0002, 0x7112, 0x00be, 0x0005, 0x7014, 0x2060, 0x0126,
+	0x2091, 0x8000, 0x6040, 0x9005, 0x0128, 0x8001, 0x6042, 0x1110,
+	0x080c, 0xce65, 0x6018, 0x9005, 0x0558, 0x8001, 0x601a, 0x1540,
+	0x6120, 0x9186, 0x0003, 0x0148, 0x9186, 0x0006, 0x0130, 0x9186,
+	0x0009, 0x11e0, 0x611c, 0xd1c4, 0x1100, 0x080c, 0xcb5a, 0x01b0,
+	0x6014, 0x2048, 0xa884, 0x908a, 0x199a, 0x0280, 0x9082, 0x1999,
+	0xa886, 0x908a, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x800b,
+	0x810b, 0x9108, 0x611a, 0xa87c, 0xd0e4, 0x0110, 0x080c, 0xc846,
+	0x012e, 0x9c88, 0x0018, 0x7116, 0x2001, 0x181a, 0x2004, 0x9102,
+	0x0220, 0x7017, 0x1cd0, 0x7007, 0x0000, 0x0005, 0x00e6, 0x2071,
+	0x19f9, 0x7027, 0x07d0, 0x7023, 0x0009, 0x00ee, 0x0005, 0x2001,
+	0x1a02, 0x2003, 0x0000, 0x0005, 0x00e6, 0x2071, 0x19f9, 0x7132,
+	0x702f, 0x0009, 0x00ee, 0x0005, 0x2011, 0x1a05, 0x2013, 0x0000,
+	0x0005, 0x00e6, 0x2071, 0x19f9, 0x711a, 0x721e, 0x700b, 0x0009,
+	0x00ee, 0x0005, 0x0086, 0x0026, 0x7054, 0x8000, 0x7056, 0x2001,
+	0x1a07, 0x2044, 0xa06c, 0x9086, 0x0000, 0x0150, 0x7068, 0xa09a,
+	0x7064, 0xa096, 0x7060, 0xa092, 0x705c, 0xa08e, 0x080c, 0x10e9,
+	0x002e, 0x008e, 0x0005, 0x0006, 0x0016, 0x0096, 0x00a6, 0x00b6,
+	0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0156, 0x080c, 0x8459, 0x015e,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x001e,
+	0x000e, 0x0005, 0x00e6, 0x2071, 0x19f9, 0x7172, 0x7276, 0x706f,
+	0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0x19f9, 0x7074,
+	0x9206, 0x1110, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x0016,
+	0x00c6, 0x2009, 0xfff4, 0x210d, 0x2061, 0x0100, 0x60f0, 0x9100,
+	0x60f3, 0x0000, 0x2009, 0xfff4, 0x200f, 0x1220, 0x8108, 0x2105,
+	0x8000, 0x200f, 0x00ce, 0x001e, 0x0005, 0x00c6, 0x2061, 0x1a70,
+	0x00ce, 0x0005, 0x9184, 0x000f, 0x8003, 0x8003, 0x8003, 0x9080,
+	0x1a70, 0x2060, 0x0005, 0xa884, 0x908a, 0x199a, 0x1638, 0x9005,
+	0x1150, 0x00c6, 0x2061, 0x1a70, 0x6014, 0x00ce, 0x9005, 0x1130,
+	0x2001, 0x001e, 0x0018, 0x908e, 0xffff, 0x01b0, 0x8003, 0x800b,
+	0x810b, 0x9108, 0x611a, 0xa87c, 0x908c, 0x00c0, 0x918e, 0x00c0,
+	0x0904, 0x868d, 0xd0b4, 0x1168, 0xd0bc, 0x1904, 0x8666, 0x2009,
+	0x0006, 0x080c, 0x86ba, 0x0005, 0x900e, 0x0c60, 0x2001, 0x1999,
+	0x08b0, 0xd0fc, 0x0160, 0x908c, 0x0003, 0x0120, 0x918e, 0x0003,
+	0x1904, 0x86b4, 0x908c, 0x2020, 0x918e, 0x2020, 0x01a8, 0x6024,
+	0xd0d4, 0x11e8, 0x2009, 0x1869, 0x2104, 0xd084, 0x1138, 0x87ff,
+	0x1120, 0x2009, 0x0043, 0x0804, 0xaeda, 0x0005, 0x87ff, 0x1de8,
+	0x2009, 0x0042, 0x0804, 0xaeda, 0x6110, 0x00b6, 0x2158, 0xb900,
+	0x00be, 0xd1ac, 0x0d20, 0x6024, 0xc0cd, 0x6026, 0x0c00, 0xc0d4,
+	0x6026, 0xa890, 0x602e, 0xa88c, 0x6032, 0x08e0, 0xd0fc, 0x0160,
+	0x908c, 0x0003, 0x0120, 0x918e, 0x0003, 0x1904, 0x86b4, 0x908c,
+	0x2020, 0x918e, 0x2020, 0x0170, 0x0076, 0x00f6, 0x2c78, 0x080c,
+	0x1727, 0x00fe, 0x007e, 0x87ff, 0x1120, 0x2009, 0x0042, 0x080c,
+	0xaeda, 0x0005, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac,
+	0x0d58, 0x6124, 0xc1cd, 0x6126, 0x0c38, 0xd0fc, 0x0188, 0x908c,
+	0x2020, 0x918e, 0x2020, 0x01a8, 0x9084, 0x0003, 0x908e, 0x0002,
+	0x0148, 0x87ff, 0x1120, 0x2009, 0x0041, 0x080c, 0xaeda, 0x0005,
+	0x00b9, 0x0ce8, 0x87ff, 0x1dd8, 0x2009, 0x0043, 0x080c, 0xaeda,
+	0x0cb0, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20,
+	0x6124, 0xc1cd, 0x6126, 0x0c00, 0x2009, 0x0004, 0x0019, 0x0005,
+	0x2009, 0x0001, 0x0096, 0x080c, 0xcb5a, 0x0518, 0x6014, 0x2048,
+	0xa982, 0xa800, 0x6016, 0x9186, 0x0001, 0x1188, 0xa97c, 0x918c,
+	0x8100, 0x918e, 0x8100, 0x1158, 0x00c6, 0x2061, 0x1a70, 0x6200,
+	0xd28c, 0x1120, 0x6204, 0x8210, 0x0208, 0x6206, 0x00ce, 0x080c,
+	0x6acf, 0x6014, 0x904d, 0x0076, 0x2039, 0x0000, 0x190c, 0x8603,
+	0x007e, 0x009e, 0x0005, 0x0156, 0x00c6, 0x2061, 0x1a70, 0x6000,
+	0x81ff, 0x0110, 0x9205, 0x0008, 0x9204, 0x6002, 0x00ce, 0x015e,
+	0x0005, 0x6800, 0xd08c, 0x1138, 0x6808, 0x9005, 0x0120, 0x8001,
+	0x680a, 0x9085, 0x0001, 0x0005, 0x2071, 0x1923, 0x7003, 0x0006,
+	0x7007, 0x0000, 0x700f, 0x0000, 0x7013, 0x0001, 0x080c, 0x1018,
+	0x090c, 0x0dd5, 0xa867, 0x0006, 0xa86b, 0x0001, 0xa8ab, 0xdcb0,
+	0xa89f, 0x0000, 0x2900, 0x702e, 0x7033, 0x0000, 0x0005, 0x0096,
+	0x00e6, 0x2071, 0x1923, 0x702c, 0x2048, 0x6a2c, 0x721e, 0x6b30,
+	0x7322, 0x6834, 0x7026, 0xa896, 0x6838, 0x702a, 0xa89a, 0x6824,
+	0x7016, 0x683c, 0x701a, 0x2009, 0x0028, 0x200a, 0x9005, 0x0148,
+	0x900e, 0x9188, 0x000c, 0x8001, 0x1de0, 0x2100, 0x9210, 0x1208,
+	0x8318, 0xaa8e, 0xab92, 0x7010, 0xd084, 0x0178, 0xc084, 0x7007,
+	0x0001, 0x700f, 0x0000, 0x0006, 0x2009, 0x181d, 0x2104, 0x9082,
+	0x0007, 0x2009, 0x1ac7, 0x200a, 0x000e, 0xc095, 0x7012, 0x2008,
+	0x2001, 0x003b, 0x080c, 0x15f0, 0x9006, 0x2071, 0x193c, 0x7002,
+	0x7006, 0x702a, 0x00ee, 0x009e, 0x0005, 0x00e6, 0x0126, 0x0156,
+	0x2091, 0x8000, 0x2071, 0x1800, 0x7154, 0x2001, 0x0008, 0x910a,
+	0x0638, 0x2001, 0x187d, 0x20ac, 0x9006, 0x9080, 0x0008, 0x1f04,
+	0x876d, 0x71c0, 0x9102, 0x02e0, 0x2071, 0x1877, 0x20a9, 0x0007,
+	0x00c6, 0x080c, 0xae09, 0x6023, 0x0009, 0x6003, 0x0004, 0x601f,
+	0x0101, 0x0089, 0x0126, 0x2091, 0x8000, 0x080c, 0x88f3, 0x012e,
+	0x1f04, 0x8779, 0x9006, 0x00ce, 0x015e, 0x012e, 0x00ee, 0x0005,
+	0x9085, 0x0001, 0x0cc8, 0x00e6, 0x00b6, 0x0096, 0x0086, 0x0056,
+	0x0046, 0x0026, 0x7118, 0x720c, 0x7620, 0x7004, 0xd084, 0x1128,
+	0x2021, 0x0024, 0x2029, 0x0002, 0x0020, 0x2021, 0x002c, 0x2029,
+	0x000a, 0x080c, 0x0fff, 0x090c, 0x0dd5, 0x2900, 0x6016, 0x2058,
+	0xac66, 0x9006, 0xa802, 0xa806, 0xa86a, 0xa87a, 0xa8aa, 0xa887,
+	0x0005, 0xa87f, 0x0020, 0x7008, 0xa89a, 0x7010, 0xa89e, 0xae8a,
+	0xa8af, 0xffff, 0xa8b3, 0x0000, 0x8109, 0x0160, 0x080c, 0x0fff,
+	0x090c, 0x0dd5, 0xad66, 0x2b00, 0xa802, 0x2900, 0xb806, 0x2058,
+	0x8109, 0x1da0, 0x002e, 0x004e, 0x005e, 0x008e, 0x009e, 0x00be,
+	0x00ee, 0x0005, 0x2079, 0x0000, 0x2071, 0x1923, 0x7004, 0x004b,
+	0x700c, 0x0002, 0x87e5, 0x87de, 0x87de, 0x0005, 0x87ef, 0x8850,
+	0x8850, 0x8850, 0x8851, 0x8862, 0x8862, 0x700c, 0x0cba, 0x0126,
+	0x2091, 0x8000, 0x78a0, 0x79a0, 0x9106, 0x0128, 0x78a0, 0x79a0,
+	0x9106, 0x1904, 0x8843, 0x2001, 0x0005, 0x2004, 0xd0bc, 0x0130,
+	0x2011, 0x0004, 0x2204, 0xc0c5, 0x2012, 0x0ca8, 0x012e, 0x7018,
+	0x910a, 0x1130, 0x7030, 0x9005, 0x05a8, 0x080c, 0x8891, 0x0490,
+	0x1210, 0x7114, 0x910a, 0x9192, 0x000a, 0x0210, 0x2009, 0x000a,
+	0x2001, 0x1888, 0x2014, 0x2001, 0x1935, 0x2004, 0x9100, 0x9202,
+	0x0e48, 0x080c, 0x89dd, 0x2200, 0x9102, 0x0208, 0x2208, 0x0096,
+	0x702c, 0x2048, 0xa873, 0x0001, 0xa976, 0x080c, 0x8ae6, 0x2100,
+	0xa87e, 0xa86f, 0x0000, 0x009e, 0x0126, 0x2091, 0x8000, 0x2009,
+	0x1a17, 0x2104, 0xc085, 0x200a, 0x700f, 0x0002, 0x012e, 0x080c,
+	0x1108, 0x1de8, 0x0005, 0x2001, 0x0005, 0x2004, 0xd0bc, 0x0130,
+	0x2011, 0x0004, 0x2204, 0xc0c5, 0x2012, 0x0ca8, 0x012e, 0x0005,
+	0x0005, 0x700c, 0x0002, 0x8856, 0x8859, 0x8858, 0x080c, 0x87ed,
+	0x0005, 0x8001, 0x700e, 0x0096, 0x702c, 0x2048, 0xa974, 0x009e,
+	0x0011, 0x0ca0, 0x0005, 0x0096, 0x702c, 0x2048, 0x7018, 0x9100,
+	0x7214, 0x921a, 0x1130, 0x701c, 0xa88e, 0x7020, 0xa892, 0x9006,
+	0x0068, 0x0006, 0x080c, 0x8ae6, 0x2100, 0xaa8c, 0x9210, 0xaa8e,
+	0x1220, 0xa890, 0x9081, 0x0000, 0xa892, 0x000e, 0x009e, 0x2f08,
+	0x9188, 0x0028, 0x200a, 0x701a, 0x0005, 0x00e6, 0x2071, 0x1923,
+	0x700c, 0x0002, 0x888f, 0x888f, 0x888d, 0x700f, 0x0001, 0x00ee,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x7030, 0x9005, 0x0508, 0x2078,
+	0x7814, 0x2048, 0xae88, 0x00b6, 0x2059, 0x0000, 0x080c, 0x88fc,
+	0x00be, 0x01b0, 0x00e6, 0x2071, 0x193c, 0x080c, 0x8943, 0x00ee,
+	0x0178, 0x0096, 0x080c, 0x1018, 0x2900, 0x009e, 0x0148, 0xa8aa,
+	0x04b9, 0x0041, 0x2001, 0x1946, 0x2003, 0x0000, 0x012e, 0x08c8,
+	0x012e, 0x0005, 0x00d6, 0x00c6, 0x0086, 0x00a6, 0x2940, 0x2650,
+	0x2600, 0x9005, 0x0180, 0xa864, 0x9084, 0x000f, 0x2068, 0x9d88,
+	0x209d, 0x2165, 0x0056, 0x2029, 0x0000, 0x080c, 0x8a6b, 0x080c,
+	0x2055, 0x1dd8, 0x005e, 0x00ae, 0x2001, 0x187f, 0x2004, 0xa88a,
+	0x080c, 0x1727, 0x781f, 0x0101, 0x7813, 0x0000, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x8952, 0x012e, 0x008e, 0x00ce, 0x00de, 0x0005,
+	0x7030, 0x9005, 0x0138, 0x2078, 0x780c, 0x7032, 0x2001, 0x1946,
+	0x2003, 0x0001, 0x0005, 0x00e6, 0x2071, 0x1923, 0x7030, 0x600e,
+	0x2c00, 0x7032, 0x00ee, 0x0005, 0x00d6, 0x00c6, 0x0026, 0x9b80,
+	0x8bc5, 0x2005, 0x906d, 0x090c, 0x0dd5, 0x9b80, 0x8bbd, 0x2005,
+	0x9065, 0x090c, 0x0dd5, 0x6114, 0x2600, 0x9102, 0x0248, 0x6828,
+	0x9102, 0x02f0, 0x9085, 0x0001, 0x002e, 0x00ce, 0x00de, 0x0005,
+	0x6804, 0xd094, 0x0148, 0x6854, 0xd084, 0x1178, 0xc085, 0x6856,
+	0x2011, 0x8026, 0x080c, 0x4b1e, 0x684c, 0x0096, 0x904d, 0x090c,
+	0x0dd5, 0xa804, 0x8000, 0xa806, 0x009e, 0x9006, 0x2030, 0x0c20,
+	0x6854, 0xd08c, 0x1d08, 0xc08d, 0x6856, 0x2011, 0x8025, 0x080c,
+	0x4b1e, 0x684c, 0x0096, 0x904d, 0x090c, 0x0dd5, 0xa800, 0x8000,
+	0xa802, 0x009e, 0x0888, 0x7000, 0x2019, 0x0008, 0x8319, 0x7104,
+	0x9102, 0x1118, 0x2300, 0x9005, 0x0020, 0x0210, 0x9302, 0x0008,
+	0x8002, 0x0005, 0x00d6, 0x7814, 0x9005, 0x090c, 0x0dd5, 0x781c,
+	0x9084, 0x0101, 0x9086, 0x0101, 0x190c, 0x0dd5, 0x2069, 0x193c,
+	0x6804, 0x9080, 0x193e, 0x2f08, 0x2102, 0x6904, 0x8108, 0x9182,
+	0x0008, 0x0208, 0x900e, 0x6906, 0x9180, 0x193e, 0x2003, 0x0000,
+	0x00de, 0x0005, 0x0096, 0x00c6, 0x2060, 0x6014, 0x2048, 0xa8a8,
+	0x0096, 0x2048, 0x9005, 0x190c, 0x1031, 0x009e, 0xa8ab, 0x0000,
+	0x080c, 0x0fb1, 0x080c, 0xae5f, 0x00ce, 0x009e, 0x0005, 0x6020,
+	0x9086, 0x0009, 0x1128, 0x601c, 0xd0c4, 0x0110, 0x9006, 0x0005,
+	0x9085, 0x0001, 0x0005, 0x6000, 0x9086, 0x0000, 0x0178, 0x6010,
+	0x9005, 0x0150, 0x00b6, 0x2058, 0x080c, 0x8cfa, 0x00be, 0x6013,
+	0x0000, 0x601b, 0x0000, 0x0010, 0x2c00, 0x0861, 0x0005, 0x2009,
+	0x1927, 0x210c, 0xd194, 0x0005, 0x00e6, 0x2071, 0x1923, 0x7110,
+	0xc194, 0xd19c, 0x1118, 0xc185, 0x7007, 0x0000, 0x7112, 0x2001,
+	0x003b, 0x080c, 0x15f0, 0x00ee, 0x0005, 0x0096, 0x00d6, 0x9006,
+	0x7006, 0x700e, 0x701a, 0x701e, 0x7022, 0x7016, 0x702a, 0x7026,
+	0x702f, 0x0000, 0x080c, 0x8b45, 0x0170, 0x080c, 0x8b7a, 0x0158,
+	0x2900, 0x7002, 0x700a, 0x701a, 0x7013, 0x0001, 0x701f, 0x000a,
+	0x00de, 0x009e, 0x0005, 0x900e, 0x0cd8, 0x00e6, 0x0096, 0x0086,
+	0x00d6, 0x00c6, 0x2071, 0x1930, 0x721c, 0x2100, 0x9202, 0x1618,
+	0x080c, 0x8b7a, 0x090c, 0x0dd5, 0x7018, 0x9005, 0x1160, 0x2900,
+	0x7002, 0x700a, 0x701a, 0x9006, 0x7006, 0x700e, 0xa806, 0xa802,
+	0x7012, 0x701e, 0x0038, 0x2040, 0xa806, 0x2900, 0xa002, 0x701a,
+	0xa803, 0x0000, 0x7010, 0x8000, 0x7012, 0x701c, 0x9080, 0x000a,
+	0x701e, 0x721c, 0x08d0, 0x721c, 0x00ce, 0x00de, 0x008e, 0x009e,
+	0x00ee, 0x0005, 0x0096, 0x0156, 0x0136, 0x0146, 0x00e6, 0x0126,
+	0x2091, 0x8000, 0x2071, 0x1930, 0x7300, 0x831f, 0x831e, 0x831e,
+	0x9384, 0x003f, 0x20e8, 0x939c, 0xffc0, 0x9398, 0x0003, 0x7104,
+	0x080c, 0x8ae6, 0x810c, 0x2100, 0x9318, 0x8003, 0x2228, 0x2021,
+	0x0078, 0x9402, 0x9532, 0x0208, 0x2028, 0x2500, 0x8004, 0x20a8,
+	0x23a0, 0xa001, 0xa001, 0x4005, 0x2508, 0x080c, 0x8aef, 0x2130,
+	0x7014, 0x9600, 0x7016, 0x2600, 0x711c, 0x9102, 0x701e, 0x7004,
+	0x9600, 0x2008, 0x9082, 0x000a, 0x1190, 0x7000, 0x2048, 0xa800,
+	0x9005, 0x1148, 0x2009, 0x0001, 0x0026, 0x080c, 0x89dd, 0x002e,
+	0x7000, 0x2048, 0xa800, 0x7002, 0x7007, 0x0000, 0x0008, 0x7106,
+	0x2500, 0x9212, 0x1904, 0x8a1c, 0x012e, 0x00ee, 0x014e, 0x013e,
+	0x015e, 0x009e, 0x0005, 0x0016, 0x0026, 0x00e6, 0x0126, 0x2091,
+	0x8000, 0x9580, 0x8bbd, 0x2005, 0x9075, 0x090c, 0x0dd5, 0x080c,
+	0x8ac1, 0x012e, 0x9580, 0x8bb9, 0x2005, 0x9075, 0x090c, 0x0dd5,
+	0x0156, 0x0136, 0x01c6, 0x0146, 0x01d6, 0x831f, 0x831e, 0x831e,
+	0x9384, 0x003f, 0x20e0, 0x9384, 0xffc0, 0x9100, 0x2098, 0xa860,
+	0x20e8, 0xa95c, 0x2c05, 0x9100, 0x20a0, 0x20a9, 0x0002, 0x4003,
+	0x2e0c, 0x2d00, 0x0002, 0x8aab, 0x8aab, 0x8aad, 0x8aab, 0x8aad,
+	0x8aab, 0x8aab, 0x8aab, 0x8aab, 0x8aab, 0x8ab3, 0x8aab, 0x8ab3,
+	0x8aab, 0x8aab, 0x8aab, 0x080c, 0x0dd5, 0x4104, 0x20a9, 0x0002,
+	0x4002, 0x4003, 0x0028, 0x20a9, 0x0002, 0x4003, 0x4104, 0x4003,
+	0x01de, 0x014e, 0x01ce, 0x013e, 0x015e, 0x00ee, 0x002e, 0x001e,
+	0x0005, 0x0096, 0x7014, 0x8001, 0x7016, 0x710c, 0x2110, 0x00f1,
+	0x810c, 0x9188, 0x0003, 0x7308, 0x8210, 0x9282, 0x000a, 0x1198,
+	0x7008, 0x2048, 0xa800, 0x9005, 0x0158, 0x0006, 0x080c, 0x8b89,
+	0x009e, 0xa807, 0x0000, 0x2900, 0x700a, 0x7010, 0x8001, 0x7012,
+	0x700f, 0x0000, 0x0008, 0x720e, 0x009e, 0x0005, 0x0006, 0x810b,
+	0x810b, 0x2100, 0x810b, 0x9100, 0x2008, 0x000e, 0x0005, 0x0006,
+	0x0026, 0x2100, 0x9005, 0x0158, 0x9092, 0x000c, 0x0240, 0x900e,
+	0x8108, 0x9082, 0x000c, 0x1de0, 0x002e, 0x000e, 0x0005, 0x900e,
+	0x0cd8, 0x2d00, 0x90b8, 0x0008, 0x690c, 0x6810, 0x2019, 0x0001,
+	0x2031, 0x8b2f, 0x9112, 0x0220, 0x0118, 0x8318, 0x2208, 0x0cd0,
+	0x6808, 0x9005, 0x0108, 0x8318, 0x233a, 0x6804, 0xd084, 0x2300,
+	0x2021, 0x0001, 0x1150, 0x9082, 0x0003, 0x0967, 0x0a67, 0x8420,
+	0x9082, 0x0007, 0x0967, 0x0a67, 0x0cd0, 0x9082, 0x0002, 0x0967,
+	0x0a67, 0x8420, 0x9082, 0x0005, 0x0967, 0x0a67, 0x0cd0, 0x6c1a,
+	0x2d00, 0x90b8, 0x0007, 0x00e6, 0x2071, 0x1800, 0x7128, 0x6810,
+	0x2019, 0x0001, 0x910a, 0x0118, 0x0210, 0x8318, 0x0cd8, 0x2031,
+	0x8b42, 0x0870, 0x6c16, 0x00ee, 0x0005, 0x0096, 0x0046, 0x0126,
+	0x2091, 0x8000, 0x2b00, 0x9080, 0x8bc1, 0x2005, 0x9005, 0x090c,
+	0x0dd5, 0x2004, 0x90a0, 0x000a, 0x080c, 0x1018, 0x01d0, 0x2900,
+	0x7026, 0xa803, 0x0000, 0xa807, 0x0000, 0x080c, 0x1018, 0x0188,
+	0x7024, 0xa802, 0xa807, 0x0000, 0x2900, 0x7026, 0x94a2, 0x000a,
+	0x0110, 0x0208, 0x0c90, 0x9085, 0x0001, 0x012e, 0x004e, 0x009e,
+	0x0005, 0x7024, 0x9005, 0x0dc8, 0x2048, 0xac00, 0x080c, 0x1031,
+	0x2400, 0x0cc0, 0x0126, 0x2091, 0x8000, 0x7024, 0x2048, 0x9005,
+	0x0130, 0xa800, 0x7026, 0xa803, 0x0000, 0xa807, 0x0000, 0x012e,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x7024, 0xa802, 0x2900, 0x7026,
+	0x012e, 0x0005, 0x0096, 0x9e80, 0x0009, 0x2004, 0x9005, 0x0138,
+	0x2048, 0xa800, 0x0006, 0x080c, 0x1031, 0x000e, 0x0cb8, 0x009e,
+	0x0005, 0x0096, 0x7008, 0x9005, 0x0138, 0x2048, 0xa800, 0x0006,
+	0x080c, 0x1031, 0x000e, 0x0cb8, 0x9006, 0x7002, 0x700a, 0x7006,
+	0x700e, 0x701a, 0x701e, 0x7022, 0x702a, 0x7026, 0x702e, 0x009e,
+	0x0005, 0x1a63, 0x0000, 0x0000, 0x0000, 0x1930, 0x0000, 0x0000,
+	0x0000, 0x1888, 0x0000, 0x0000, 0x0000, 0x1877, 0x0000, 0x0000,
+	0x0000, 0x00e6, 0x00c6, 0x00b6, 0x00a6, 0xa8a8, 0x2040, 0x2071,
+	0x1877, 0x080c, 0x8ce5, 0xa067, 0x0023, 0x6010, 0x905d, 0x0904,
+	0x8cba, 0xb814, 0xa06e, 0xb910, 0xa172, 0xb9a0, 0xa176, 0x2001,
+	0x0003, 0xa07e, 0xa834, 0xa082, 0xa07b, 0x0000, 0xa898, 0x9005,
+	0x0118, 0xa078, 0xc085, 0xa07a, 0x2858, 0x2031, 0x0018, 0xa068,
+	0x908a, 0x0019, 0x1a0c, 0x0dd5, 0x2020, 0x2050, 0x2940, 0xa864,
+	0x90bc, 0x00ff, 0x908c, 0x000f, 0x91e0, 0x209d, 0x2c65, 0x9786,
+	0x0024, 0x2c05, 0x1590, 0x908a, 0x0036, 0x1a0c, 0x0dd5, 0x9082,
+	0x001b, 0x0002, 0x8c25, 0x8c25, 0x8c27, 0x8c25, 0x8c25, 0x8c25,
+	0x8c29, 0x8c25, 0x8c25, 0x8c25, 0x8c2b, 0x8c25, 0x8c25, 0x8c25,
+	0x8c2d, 0x8c25, 0x8c25, 0x8c25, 0x8c2f, 0x8c25, 0x8c25, 0x8c25,
+	0x8c31, 0x8c25, 0x8c25, 0x8c25, 0x8c33, 0x080c, 0x0dd5, 0xa180,
+	0x04b8, 0xa190, 0x04a8, 0xa1a0, 0x0498, 0xa1b0, 0x0488, 0xa1c0,
+	0x0478, 0xa1d0, 0x0468, 0xa1e0, 0x0458, 0x908a, 0x0034, 0x1a0c,
+	0x0dd5, 0x9082, 0x001b, 0x0002, 0x8c57, 0x8c55, 0x8c55, 0x8c55,
+	0x8c55, 0x8c55, 0x8c59, 0x8c55, 0x8c55, 0x8c55, 0x8c55, 0x8c55,
+	0x8c5b, 0x8c55, 0x8c55, 0x8c55, 0x8c55, 0x8c55, 0x8c5d, 0x8c55,
+	0x8c55, 0x8c55, 0x8c55, 0x8c55, 0x8c5f, 0x080c, 0x0dd5, 0xa180,
+	0x0038, 0xa198, 0x0028, 0xa1b0, 0x0018, 0xa1c8, 0x0008, 0xa1e0,
+	0x2600, 0x0002, 0x8c7b, 0x8c7d, 0x8c7f, 0x8c81, 0x8c83, 0x8c85,
+	0x8c87, 0x8c89, 0x8c8b, 0x8c8d, 0x8c8f, 0x8c91, 0x8c93, 0x8c95,
+	0x8c97, 0x8c99, 0x8c9b, 0x8c9d, 0x8c9f, 0x8ca1, 0x8ca3, 0x8ca5,
+	0x8ca7, 0x8ca9, 0x8cab, 0x080c, 0x0dd5, 0xb9e2, 0x0468, 0xb9de,
+	0x0458, 0xb9da, 0x0448, 0xb9d6, 0x0438, 0xb9d2, 0x0428, 0xb9ce,
+	0x0418, 0xb9ca, 0x0408, 0xb9c6, 0x00f8, 0xb9c2, 0x00e8, 0xb9be,
+	0x00d8, 0xb9ba, 0x00c8, 0xb9b6, 0x00b8, 0xb9b2, 0x00a8, 0xb9ae,
+	0x0098, 0xb9aa, 0x0088, 0xb9a6, 0x0078, 0xb9a2, 0x0068, 0xb99e,
+	0x0058, 0xb99a, 0x0048, 0xb996, 0x0038, 0xb992, 0x0028, 0xb98e,
+	0x0018, 0xb98a, 0x0008, 0xb986, 0x8631, 0x8421, 0x0130, 0x080c,
+	0x2055, 0x090c, 0x0dd5, 0x0804, 0x8bff, 0x00ae, 0x00be, 0x00ce,
+	0x00ee, 0x0005, 0xa86c, 0xa06e, 0xa870, 0xa072, 0xa077, 0x00ff,
+	0x9006, 0x0804, 0x8be1, 0x0006, 0x0016, 0x00b6, 0x6010, 0x2058,
+	0xb810, 0x9005, 0x01b0, 0x2001, 0x1924, 0x2004, 0x9005, 0x0188,
+	0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x1158, 0x0036, 0x0046,
+	0xbba0, 0x2021, 0x0004, 0x2011, 0x8014, 0x080c, 0x4b1e, 0x004e,
+	0x003e, 0x00be, 0x001e, 0x000e, 0x0005, 0x9016, 0x710c, 0xa834,
+	0x910a, 0xa936, 0x7008, 0x9005, 0x0120, 0x8210, 0x910a, 0x0238,
+	0x0130, 0x7010, 0x8210, 0x910a, 0x0210, 0x0108, 0x0cd8, 0xaa8a,
+	0xa26a, 0x0005, 0x00f6, 0x00d6, 0x0036, 0x2079, 0x0300, 0x781b,
+	0x0200, 0x7818, 0xd094, 0x1dd8, 0x781b, 0x0202, 0xa001, 0xa001,
+	0x7818, 0xd094, 0x1da0, 0xb8ac, 0x9005, 0x01b8, 0x2068, 0x2079,
+	0x0000, 0x2c08, 0x911e, 0x1118, 0x680c, 0xb8ae, 0x0060, 0x9106,
+	0x0140, 0x2d00, 0x2078, 0x680c, 0x9005, 0x090c, 0x0dd5, 0x2068,
+	0x0cb0, 0x6b0c, 0x7b0e, 0x600f, 0x0000, 0x2079, 0x0300, 0x781b,
+	0x0200, 0x003e, 0x00de, 0x00fe, 0x0005, 0x00e6, 0x00d6, 0x0096,
+	0x00c6, 0x0036, 0x0126, 0x2091, 0x8000, 0x0156, 0x20a9, 0x01ff,
+	0x2071, 0x0300, 0x701b, 0x0200, 0x7018, 0xd094, 0x0110, 0x1f04,
+	0x8d3a, 0x701b, 0x0202, 0xa001, 0xa001, 0x7018, 0xd094, 0x1d90,
+	0xb8ac, 0x9005, 0x01d0, 0x2060, 0x600c, 0xb8ae, 0x6003, 0x0004,
+	0x601b, 0x0000, 0x6013, 0x0000, 0x601f, 0x0101, 0x6014, 0x2048,
+	0xa88b, 0x0000, 0xa8a8, 0xa8ab, 0x0000, 0x904d, 0x090c, 0x0dd5,
+	0x080c, 0x1031, 0x080c, 0x88f3, 0x0c18, 0x2071, 0x0300, 0x701b,
+	0x0200, 0x015e, 0x012e, 0x003e, 0x00ce, 0x009e, 0x00de, 0x00ee,
+	0x0005, 0x00c6, 0x00b6, 0x0016, 0x0006, 0x0156, 0x080c, 0x284b,
+	0x015e, 0x11b0, 0x080c, 0x65b5, 0x190c, 0x0dd5, 0x000e, 0x001e,
+	0xb912, 0xb816, 0x080c, 0xae09, 0x0140, 0x2b00, 0x6012, 0x6023,
+	0x0001, 0x2009, 0x0001, 0x080c, 0xaeda, 0x00be, 0x00ce, 0x0005,
+	0x000e, 0x001e, 0x0cd0, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c,
+	0x0dd5, 0x0013, 0x006e, 0x0005, 0x8dac, 0x8dac, 0x8dac, 0x8dae,
+	0x8dff, 0x8dac, 0x8dac, 0x8dac, 0x8e62, 0x8dac, 0x8e9f, 0x8dac,
+	0x8dac, 0x8dac, 0x8dac, 0x8dac, 0x080c, 0x0dd5, 0x9182, 0x0040,
+	0x0002, 0x8dc1, 0x8dc1, 0x8dc1, 0x8dc1, 0x8dc1, 0x8dc1, 0x8dc1,
+	0x8dc1, 0x8dc1, 0x8dc3, 0x8dd8, 0x8dc1, 0x8dc1, 0x8dc1, 0x8dc1,
+	0x8deb, 0x080c, 0x0dd5, 0x0096, 0x080c, 0x9656, 0x080c, 0x97d4,
+	0x6114, 0x2148, 0xa87b, 0x0000, 0x6010, 0x00b6, 0x2058, 0xb8bb,
+	0x0500, 0x00be, 0x080c, 0x6a9a, 0x080c, 0xae5f, 0x009e, 0x0005,
+	0x080c, 0x9656, 0x00d6, 0x6114, 0x080c, 0xcb5a, 0x0130, 0x0096,
+	0x6114, 0x2148, 0x080c, 0x6c94, 0x009e, 0x00de, 0x080c, 0xae5f,
+	0x080c, 0x97d4, 0x0005, 0x080c, 0x9656, 0x080c, 0x31cc, 0x6114,
+	0x0096, 0x2148, 0x080c, 0xcb5a, 0x0120, 0xa87b, 0x0029, 0x080c,
+	0x6c94, 0x009e, 0x080c, 0xae5f, 0x080c, 0x97d4, 0x0005, 0x601b,
+	0x0000, 0x9182, 0x0040, 0x0096, 0x0002, 0x8e1a, 0x8e1a, 0x8e1a,
+	0x8e1a, 0x8e1a, 0x8e1a, 0x8e1a, 0x8e1a, 0x8e1c, 0x8e1a, 0x8e1a,
+	0x8e1a, 0x8e5e, 0x8e1a, 0x8e1a, 0x8e1a, 0x8e1a, 0x8e1a, 0x8e1a,
+	0x8e22, 0x8e1a, 0x080c, 0x0dd5, 0x6114, 0x2148, 0xa938, 0x918e,
+	0xffff, 0x05e0, 0x00e6, 0x6114, 0x2148, 0x080c, 0x8bc9, 0x0096,
+	0xa8a8, 0x2048, 0x080c, 0x6a32, 0x009e, 0xa8ab, 0x0000, 0x6010,
+	0x9005, 0x0128, 0x00b6, 0x2058, 0x080c, 0x8cfa, 0x00be, 0xae88,
+	0x00b6, 0x2059, 0x0000, 0x080c, 0x88fc, 0x00be, 0x01e0, 0x2071,
+	0x193c, 0x080c, 0x8943, 0x01b8, 0x9086, 0x0001, 0x1128, 0x2001,
+	0x1946, 0x2004, 0x9005, 0x1178, 0x0096, 0x080c, 0x0fff, 0x2900,
+	0x009e, 0x0148, 0xa8aa, 0x00f6, 0x2c78, 0x080c, 0x88ba, 0x00fe,
+	0x00ee, 0x009e, 0x0005, 0x080c, 0x88f3, 0x0cd0, 0x080c, 0x8f0c,
+	0x009e, 0x0005, 0x9182, 0x0040, 0x0096, 0x0002, 0x8e76, 0x8e76,
+	0x8e76, 0x8e78, 0x8e76, 0x8e76, 0x8e76, 0x8e9d, 0x8e76, 0x8e76,
+	0x8e76, 0x8e76, 0x8e76, 0x8e76, 0x8e76, 0x8e76, 0x080c, 0x0dd5,
+	0x6003, 0x0003, 0x6106, 0x6014, 0x2048, 0xa8ac, 0xa846, 0xa8b0,
+	0xa84a, 0xa837, 0x0000, 0xa83b, 0x0000, 0xa884, 0x9092, 0x199a,
+	0x0210, 0x2001, 0x1999, 0x8003, 0x8013, 0x8213, 0x9210, 0x621a,
+	0x2c10, 0x080c, 0x1bba, 0x080c, 0x915d, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x97d4, 0x012e, 0x009e, 0x0005, 0x080c, 0x0dd5, 0x080c,
+	0x9656, 0x080c, 0x97d4, 0x6114, 0x2148, 0xa87b, 0x0000, 0x6010,
+	0x00b6, 0x2058, 0xb8bb, 0x0500, 0x00be, 0x080c, 0x6c94, 0x080c,
+	0xae5f, 0x009e, 0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0dd5,
+	0x0096, 0x0013, 0x009e, 0x0005, 0x8ecc, 0x8ecc, 0x8ecc, 0x8ece,
+	0x8edf, 0x8ecc, 0x8ecc, 0x8ecc, 0x8ecc, 0x8ecc, 0x8ecc, 0x8ecc,
+	0x8ecc, 0x8ecc, 0x8ecc, 0x8ecc, 0x080c, 0x0dd5, 0x080c, 0xa7b7,
+	0x6114, 0x2148, 0xa87b, 0x0006, 0x6010, 0x00b6, 0x2058, 0xb8bb,
+	0x0500, 0x00be, 0x080c, 0x6c94, 0x080c, 0xae5f, 0x0005, 0x0461,
+	0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0dd5, 0x0096, 0x0013,
+	0x009e, 0x0005, 0x8efa, 0x8efa, 0x8efa, 0x8efc, 0x8f0c, 0x8efa,
+	0x8efa, 0x8efa, 0x8efa, 0x8efa, 0x8efa, 0x8efa, 0x8efa, 0x8efa,
+	0x8efa, 0x8efa, 0x080c, 0x0dd5, 0x0036, 0x00e6, 0x2071, 0x19e6,
+	0x703c, 0x9c06, 0x1120, 0x2019, 0x0000, 0x080c, 0xa5c8, 0x080c,
+	0xa7b7, 0x00ee, 0x003e, 0x0005, 0x00f6, 0x00e6, 0x601b, 0x0000,
+	0x6014, 0x2048, 0x6010, 0x9005, 0x0128, 0x00b6, 0x2058, 0x080c,
+	0x8cfa, 0x00be, 0x2071, 0x193c, 0x080c, 0x8943, 0x0160, 0x2001,
+	0x187f, 0x2004, 0xa88a, 0x2031, 0x0000, 0x2c78, 0x080c, 0x88ba,
+	0x00ee, 0x00fe, 0x0005, 0x0096, 0xa88b, 0x0000, 0xa8a8, 0x2048,
+	0x080c, 0x1031, 0x009e, 0xa8ab, 0x0000, 0x080c, 0x88f3, 0x0c80,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x187a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0126, 0x2091, 0x8000, 0x0036, 0x0046, 0x20a9, 0x0010, 0x9006,
+	0x8004, 0x2019, 0x0100, 0x231c, 0x93a6, 0x0008, 0x1118, 0x8086,
+	0x818e, 0x0020, 0x80f6, 0x3e00, 0x81f6, 0x3e08, 0x1208, 0x9200,
+	0x1f04, 0x8f51, 0x93a6, 0x0008, 0x1118, 0x8086, 0x818e, 0x0020,
+	0x80f6, 0x3e00, 0x81f6, 0x3e08, 0x004e, 0x003e, 0x012e, 0x0005,
+	0x0126, 0x2091, 0x8000, 0x0076, 0x0156, 0x20a9, 0x0010, 0x9005,
+	0x0510, 0x911a, 0x1600, 0x8213, 0x2039, 0x0100, 0x273c, 0x97be,
+	0x0008, 0x1110, 0x818d, 0x0010, 0x81f5, 0x3e08, 0x0228, 0x911a,
+	0x1220, 0x1f04, 0x8f7b, 0x0028, 0x911a, 0x2308, 0x8210, 0x1f04,
+	0x8f7b, 0x0006, 0x3200, 0x9084, 0xefff, 0x2080, 0x000e, 0x015e,
+	0x007e, 0x012e, 0x0005, 0x0006, 0x3200, 0x9085, 0x1000, 0x0ca8,
+	0x0126, 0x2091, 0x2800, 0x2079, 0x19e6, 0x012e, 0x00d6, 0x2069,
+	0x19e6, 0x6803, 0x0005, 0x0156, 0x0146, 0x01d6, 0x20e9, 0x0000,
+	0x2069, 0x0200, 0x080c, 0xab1a, 0x0401, 0x080c, 0xab05, 0x00e9,
+	0x080c, 0xab08, 0x00d1, 0x080c, 0xab0b, 0x00b9, 0x080c, 0xab0e,
+	0x00a1, 0x080c, 0xab11, 0x0089, 0x080c, 0xab14, 0x0071, 0x080c,
+	0xab17, 0x0059, 0x01de, 0x014e, 0x015e, 0x2069, 0x0004, 0x2d04,
+	0x9085, 0x8001, 0x206a, 0x00de, 0x0005, 0x20a9, 0x0020, 0x20a1,
+	0x0240, 0x2001, 0x0000, 0x4004, 0x0005, 0x00c6, 0x6027, 0x0001,
+	0x7804, 0x9084, 0x0007, 0x0002, 0x8fee, 0x9012, 0x9051, 0x8ff4,
+	0x9012, 0x8fee, 0x8fec, 0x8fec, 0x080c, 0x0dd5, 0x080c, 0x857f,
+	0x080c, 0x96a6, 0x00ce, 0x0005, 0x62c0, 0x82ff, 0x1110, 0x00ce,
+	0x0005, 0x2011, 0x5e96, 0x080c, 0x84f9, 0x7828, 0x9092, 0x00c8,
+	0x1228, 0x8000, 0x782a, 0x080c, 0x5ed6, 0x0c88, 0x62c0, 0x080c,
+	0xac56, 0x080c, 0x5e96, 0x7807, 0x0003, 0x7827, 0x0000, 0x782b,
+	0x0000, 0x0c28, 0x080c, 0x857f, 0x6220, 0xd2a4, 0x0160, 0x782b,
+	0x0000, 0x7824, 0x9065, 0x090c, 0x0dd5, 0x2009, 0x0013, 0x080c,
+	0xaeda, 0x00ce, 0x0005, 0x00c6, 0x7824, 0x9065, 0x090c, 0x0dd5,
+	0x7828, 0x9092, 0xc350, 0x12c0, 0x8000, 0x782a, 0x00ce, 0x080c,
+	0x2bb2, 0x0278, 0x00c6, 0x7924, 0x2160, 0x6010, 0x906d, 0x090c,
+	0x0dd5, 0x7807, 0x0000, 0x7827, 0x0000, 0x00ce, 0x080c, 0x96a6,
+	0x0c00, 0x080c, 0xa26b, 0x08e8, 0x2011, 0x0130, 0x2214, 0x080c,
+	0xac56, 0x080c, 0xea39, 0x2009, 0x0014, 0x080c, 0xaeda, 0x00ce,
+	0x0880, 0x2001, 0x1a02, 0x2003, 0x0000, 0x62c0, 0x82ff, 0x1160,
 	0x782b, 0x0000, 0x7824, 0x9065, 0x090c, 0x0dd5, 0x2009, 0x0013,
-	0x080c, 0xaeec, 0x00ce, 0x0005, 0x00c6, 0x7824, 0x9065, 0x090c,
-	0x0dd5, 0x7828, 0x9092, 0xc350, 0x12c0, 0x8000, 0x782a, 0x00ce,
-	0x080c, 0x2ba7, 0x0278, 0x00c6, 0x7924, 0x2160, 0x6010, 0x906d,
-	0x090c, 0x0dd5, 0x7807, 0x0000, 0x7827, 0x0000, 0x00ce, 0x080c,
-	0x9687, 0x0c00, 0x080c, 0xa250, 0x08e8, 0x2011, 0x0130, 0x2214,
-	0x080c, 0xac68, 0x080c, 0xea1f, 0x2009, 0x0014, 0x080c, 0xaeec,
-	0x00ce, 0x0880, 0x2001, 0x1a02, 0x2003, 0x0000, 0x62c0, 0x82ff,
-	0x1160, 0x782b, 0x0000, 0x7824, 0x9065, 0x090c, 0x0dd5, 0x2009,
-	0x0013, 0x080c, 0xaf3e, 0x00ce, 0x0005, 0x00b6, 0x00c6, 0x00d6,
-	0x7824, 0x9005, 0x090c, 0x0dd5, 0x7828, 0x9092, 0xc350, 0x1648,
-	0x8000, 0x782a, 0x00de, 0x00ce, 0x00be, 0x080c, 0x2ba7, 0x02f0,
-	0x00b6, 0x00c6, 0x00d6, 0x781c, 0x905d, 0x090c, 0x0dd5, 0xb800,
-	0xc0dc, 0xb802, 0x7924, 0x2160, 0x080c, 0xae71, 0xb93c, 0x81ff,
-	0x090c, 0x0dd5, 0x8109, 0xb93e, 0x7807, 0x0000, 0x7827, 0x0000,
-	0x00de, 0x00ce, 0x00be, 0x080c, 0x9687, 0x0868, 0x080c, 0xa250,
-	0x0850, 0x2011, 0x0130, 0x2214, 0x080c, 0xac68, 0x080c, 0xea1f,
-	0x7824, 0x9065, 0x2009, 0x0014, 0x080c, 0xaeec, 0x00de, 0x00ce,
-	0x00be, 0x0804, 0x9043, 0x00c6, 0x2001, 0x009b, 0x2004, 0xd0fc,
-	0x190c, 0x1eb6, 0x6024, 0x6027, 0x0002, 0xd0f4, 0x15b8, 0x62c8,
-	0x60c4, 0x9205, 0x1170, 0x783c, 0x9065, 0x0130, 0x2009, 0x0049,
-	0x080c, 0xaeec, 0x00ce, 0x0005, 0x2011, 0x1a05, 0x2013, 0x0000,
-	0x0cc8, 0x793c, 0x81ff, 0x0dc0, 0x7944, 0x9192, 0x7530, 0x1628,
-	0x8108, 0x7946, 0x793c, 0x9188, 0x0008, 0x210c, 0x918e, 0x0006,
-	0x1138, 0x6014, 0x9084, 0x1984, 0x9085, 0x0012, 0x6016, 0x0c10,
-	0x793c, 0x9188, 0x0008, 0x210c, 0x918e, 0x0009, 0x0d90, 0x6014,
-	0x9084, 0x1984, 0x9085, 0x0016, 0x6016, 0x08a0, 0x793c, 0x2160,
-	0x2009, 0x004a, 0x080c, 0xaeec, 0x0868, 0x7848, 0xc085, 0x784a,
-	0x0848, 0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x600f,
-	0x0000, 0x2c08, 0x2061, 0x19e6, 0x6020, 0x8000, 0x6022, 0x6010,
-	0x9005, 0x0148, 0x9080, 0x0003, 0x2102, 0x6112, 0x012e, 0x00ce,
-	0x001e, 0x000e, 0x0005, 0x6116, 0x6112, 0x0cc0, 0x00d6, 0x2069,
-	0x19e6, 0xb800, 0xd0d4, 0x0168, 0x6820, 0x8000, 0x6822, 0x9086,
-	0x0001, 0x1110, 0x2b00, 0x681e, 0x00de, 0x0804, 0x9687, 0x00de,
-	0x0005, 0xc0d5, 0xb802, 0x6818, 0x9005, 0x0168, 0xb856, 0xb85b,
-	0x0000, 0x0086, 0x0006, 0x2b00, 0x681a, 0x008e, 0xa05a, 0x008e,
-	0x2069, 0x19e6, 0x0c08, 0xb856, 0xb85a, 0x2b00, 0x681a, 0x681e,
-	0x08d8, 0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x600f,
-	0x0000, 0x2c08, 0x2061, 0x19e6, 0x6020, 0x8000, 0x6022, 0x6008,
-	0x9005, 0x0148, 0x9080, 0x0003, 0x2102, 0x610a, 0x012e, 0x00ce,
-	0x001e, 0x000e, 0x0005, 0x610e, 0x610a, 0x0cc0, 0x00c6, 0x600f,
-	0x0000, 0x2c08, 0x2061, 0x19e6, 0x6034, 0x9005, 0x0130, 0x9080,
-	0x0003, 0x2102, 0x6136, 0x00ce, 0x0005, 0x613a, 0x6136, 0x00ce,
-	0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00b6, 0x0096, 0x0076,
-	0x0066, 0x0056, 0x0036, 0x0026, 0x0016, 0x0006, 0x0126, 0x902e,
-	0x2071, 0x19e6, 0x7638, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff,
-	0x0904, 0x91cd, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x91c8,
-	0x87ff, 0x0120, 0x6054, 0x9106, 0x1904, 0x91c8, 0x703c, 0x9c06,
-	0x1178, 0x0036, 0x2019, 0x0001, 0x080c, 0xa5b7, 0x7033, 0x0000,
-	0x9006, 0x703e, 0x7042, 0x7046, 0x704a, 0x003e, 0x2029, 0x0001,
-	0x7038, 0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36, 0x1140,
-	0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000,
-	0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678,
-	0x600f, 0x0000, 0x080c, 0xcb4a, 0x01f0, 0x6014, 0x2048, 0x6020,
-	0x9086, 0x0003, 0x15b8, 0x6004, 0x9086, 0x0040, 0x090c, 0xa7bd,
-	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036, 0x0076,
-	0x080c, 0xce3e, 0x080c, 0xe929, 0x080c, 0x6c86, 0x007e, 0x003e,
-	0x001e, 0x080c, 0xcd33, 0x080c, 0xaea2, 0x00ce, 0x0804, 0x9167,
-	0x2c78, 0x600c, 0x2060, 0x0804, 0x9167, 0x85ff, 0x0120, 0x0036,
-	0x080c, 0x97b5, 0x003e, 0x012e, 0x000e, 0x001e, 0x002e, 0x003e,
-	0x005e, 0x006e, 0x007e, 0x009e, 0x00be, 0x00ce, 0x00de, 0x00ee,
-	0x00fe, 0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016, 0x0036,
-	0x0076, 0x080c, 0xe929, 0x080c, 0xe572, 0x007e, 0x003e, 0x001e,
-	0x0890, 0x6020, 0x9086, 0x0009, 0x1168, 0xa87b, 0x0006, 0x0016,
-	0x0036, 0x0076, 0x080c, 0x6c86, 0x080c, 0xae71, 0x007e, 0x003e,
-	0x001e, 0x0818, 0x6020, 0x9086, 0x000a, 0x0904, 0x91b2, 0x0804,
-	0x91ab, 0x0006, 0x0066, 0x0096, 0x00c6, 0x00d6, 0x00f6, 0x9036,
-	0x0126, 0x2091, 0x8000, 0x2079, 0x19e6, 0x7838, 0x9065, 0x0904,
-	0x925e, 0x600c, 0x0006, 0x600f, 0x0000, 0x783c, 0x9c06, 0x1168,
-	0x0036, 0x2019, 0x0001, 0x080c, 0xa5b7, 0x7833, 0x0000, 0x901e,
-	0x7b3e, 0x7b42, 0x7b46, 0x7b4a, 0x003e, 0x080c, 0xcb4a, 0x0548,
-	0x6014, 0x2048, 0x6020, 0x9086, 0x0003, 0x1590, 0x3e08, 0x918e,
-	0x0002, 0x1188, 0x6010, 0x9005, 0x0170, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x0140, 0x6040, 0x9005, 0x11a8, 0x2001, 0x1987,
-	0x2004, 0x6042, 0x0080, 0x6004, 0x9086, 0x0040, 0x090c, 0xa7bd,
-	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6c7a, 0x080c,
-	0xcd33, 0x080c, 0xaea2, 0x000e, 0x0804, 0x9216, 0x7e3a, 0x7e36,
-	0x012e, 0x00fe, 0x00de, 0x00ce, 0x009e, 0x006e, 0x000e, 0x0005,
-	0x6020, 0x9086, 0x0006, 0x1118, 0x080c, 0xe572, 0x0c50, 0x6020,
-	0x9086, 0x0009, 0x1130, 0xab7a, 0x080c, 0x6c86, 0x080c, 0xae71,
-	0x0c10, 0x6020, 0x9086, 0x000a, 0x09a8, 0x0868, 0x0016, 0x0026,
-	0x0086, 0x9046, 0x0099, 0x080c, 0x9367, 0x008e, 0x002e, 0x001e,
-	0x0005, 0x00f6, 0x0126, 0x2079, 0x19e6, 0x2091, 0x8000, 0x080c,
-	0x93fe, 0x080c, 0x948c, 0x012e, 0x00fe, 0x0005, 0x00b6, 0x0096,
-	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0016, 0x0006, 0x0126,
-	0x2091, 0x8000, 0x2071, 0x19e6, 0x7614, 0x2660, 0x2678, 0x8cff,
-	0x0904, 0x932c, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x9327,
-	0x88ff, 0x0120, 0x6054, 0x9106, 0x1904, 0x9327, 0x7024, 0x9c06,
-	0x1558, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508, 0x080c, 0x8562,
-	0x080c, 0xa274, 0x68c3, 0x0000, 0x080c, 0xa7bd, 0x7027, 0x0000,
-	0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2cf1, 0x9006, 0x080c, 0x2cf1, 0x2069, 0x0100,
-	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x0028, 0x6003,
-	0x0009, 0x630a, 0x0804, 0x9327, 0x7014, 0x9c36, 0x1110, 0x660c,
-	0x7616, 0x7010, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00,
-	0x7012, 0x0010, 0x7013, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06,
-	0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x6014, 0x2048,
-	0x080c, 0xcb4a, 0x01e8, 0x6020, 0x9086, 0x0003, 0x1580, 0x080c,
-	0xcd50, 0x1118, 0x080c, 0xb824, 0x0098, 0xa867, 0x0103, 0xab7a,
-	0xa877, 0x0000, 0x0016, 0x0036, 0x0086, 0x080c, 0xce3e, 0x080c,
-	0xe929, 0x080c, 0x6c86, 0x008e, 0x003e, 0x001e, 0x080c, 0xcd33,
-	0x080c, 0xaea2, 0x080c, 0xa693, 0x00ce, 0x0804, 0x92a7, 0x2c78,
-	0x600c, 0x2060, 0x0804, 0x92a7, 0x012e, 0x000e, 0x001e, 0x006e,
-	0x00ce, 0x00de, 0x00ee, 0x00fe, 0x009e, 0x00be, 0x0005, 0x6020,
-	0x9086, 0x0006, 0x1158, 0x0016, 0x0036, 0x0086, 0x080c, 0xe929,
-	0x080c, 0xe572, 0x008e, 0x003e, 0x001e, 0x08d0, 0x080c, 0xb824,
-	0x6020, 0x9086, 0x0002, 0x1160, 0x6004, 0x0006, 0x9086, 0x0085,
-	0x000e, 0x0904, 0x930d, 0x9086, 0x008b, 0x0904, 0x930d, 0x0840,
-	0x6020, 0x9086, 0x0005, 0x1920, 0x6004, 0x0006, 0x9086, 0x0085,
-	0x000e, 0x09c8, 0x9086, 0x008b, 0x09b0, 0x0804, 0x9320, 0x00b6,
-	0x00a6, 0x0096, 0x00c6, 0x0006, 0x0126, 0x2091, 0x8000, 0x9280,
-	0x1000, 0x2004, 0x905d, 0x0904, 0x93f7, 0x00f6, 0x00e6, 0x00d6,
-	0x0066, 0x2071, 0x19e6, 0xbe54, 0x7018, 0x9b06, 0x1108, 0x761a,
-	0x701c, 0x9b06, 0x1130, 0x86ff, 0x1118, 0x7018, 0x701e, 0x0008,
-	0x761e, 0xb858, 0x904d, 0x0108, 0xae56, 0x96d5, 0x0000, 0x0110,
-	0x2900, 0xb05a, 0xb857, 0x0000, 0xb85b, 0x0000, 0xb800, 0xc0d4,
-	0xc0dc, 0xb802, 0x080c, 0x653a, 0x0904, 0x93f3, 0x7624, 0x86ff,
-	0x0904, 0x93e2, 0x9680, 0x0005, 0x2004, 0x9906, 0x15d8, 0x00d6,
-	0x2069, 0x0100, 0x68c0, 0x9005, 0x0560, 0x080c, 0x8562, 0x080c,
-	0xa274, 0x68c3, 0x0000, 0x080c, 0xa7bd, 0x7027, 0x0000, 0x0036,
+	0x080c, 0xaf2c, 0x00ce, 0x0005, 0x00b6, 0x00c6, 0x00d6, 0x7824,
+	0x9005, 0x090c, 0x0dd5, 0x7828, 0x9092, 0xc350, 0x1648, 0x8000,
+	0x782a, 0x00de, 0x00ce, 0x00be, 0x080c, 0x2bb2, 0x02f0, 0x00b6,
+	0x00c6, 0x00d6, 0x781c, 0x905d, 0x090c, 0x0dd5, 0xb800, 0xc0dc,
+	0xb802, 0x7924, 0x2160, 0x080c, 0xae5f, 0xb93c, 0x81ff, 0x090c,
+	0x0dd5, 0x8109, 0xb93e, 0x7807, 0x0000, 0x7827, 0x0000, 0x00de,
+	0x00ce, 0x00be, 0x080c, 0x96a6, 0x0868, 0x080c, 0xa26b, 0x0850,
+	0x2011, 0x0130, 0x2214, 0x080c, 0xac56, 0x080c, 0xea39, 0x7824,
+	0x9065, 0x2009, 0x0014, 0x080c, 0xaeda, 0x00de, 0x00ce, 0x00be,
+	0x0804, 0x9062, 0x00c6, 0x2001, 0x009b, 0x2004, 0xd0fc, 0x190c,
+	0x1ec1, 0x6024, 0x6027, 0x0002, 0xd0f4, 0x15b8, 0x62c8, 0x60c4,
+	0x9205, 0x1170, 0x783c, 0x9065, 0x0130, 0x2009, 0x0049, 0x080c,
+	0xaeda, 0x00ce, 0x0005, 0x2011, 0x1a05, 0x2013, 0x0000, 0x0cc8,
+	0x793c, 0x81ff, 0x0dc0, 0x7944, 0x9192, 0x7530, 0x1628, 0x8108,
+	0x7946, 0x793c, 0x9188, 0x0008, 0x210c, 0x918e, 0x0006, 0x1138,
+	0x6014, 0x9084, 0x1984, 0x9085, 0x0012, 0x6016, 0x0c10, 0x793c,
+	0x9188, 0x0008, 0x210c, 0x918e, 0x0009, 0x0d90, 0x6014, 0x9084,
+	0x1984, 0x9085, 0x0016, 0x6016, 0x08a0, 0x793c, 0x2160, 0x2009,
+	0x004a, 0x080c, 0xaeda, 0x0868, 0x7848, 0xc085, 0x784a, 0x0848,
+	0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19e6, 0x6020, 0x8000, 0x6022, 0x6010, 0x9005,
+	0x0148, 0x9080, 0x0003, 0x2102, 0x6112, 0x012e, 0x00ce, 0x001e,
+	0x000e, 0x0005, 0x6116, 0x6112, 0x0cc0, 0x00d6, 0x2069, 0x19e6,
+	0xb800, 0xd0d4, 0x0168, 0x6820, 0x8000, 0x6822, 0x9086, 0x0001,
+	0x1110, 0x2b00, 0x681e, 0x00de, 0x0804, 0x96a6, 0x00de, 0x0005,
+	0xc0d5, 0xb802, 0x6818, 0x9005, 0x0168, 0xb856, 0xb85b, 0x0000,
+	0x0086, 0x0006, 0x2b00, 0x681a, 0x008e, 0xa05a, 0x008e, 0x2069,
+	0x19e6, 0x0c08, 0xb856, 0xb85a, 0x2b00, 0x681a, 0x681e, 0x08d8,
+	0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19e6, 0x6020, 0x8000, 0x6022, 0x6008, 0x9005,
+	0x0148, 0x9080, 0x0003, 0x2102, 0x610a, 0x012e, 0x00ce, 0x001e,
+	0x000e, 0x0005, 0x610e, 0x610a, 0x0cc0, 0x00c6, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19e6, 0x6034, 0x9005, 0x0130, 0x9080, 0x0003,
+	0x2102, 0x6136, 0x00ce, 0x0005, 0x613a, 0x6136, 0x00ce, 0x0005,
+	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00b6, 0x0096, 0x0076, 0x0066,
+	0x0056, 0x0036, 0x0026, 0x0016, 0x0006, 0x0126, 0x902e, 0x2071,
+	0x19e6, 0x7638, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff, 0x0904,
+	0x91ec, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x91e7, 0x87ff,
+	0x0120, 0x6054, 0x9106, 0x1904, 0x91e7, 0x703c, 0x9c06, 0x1178,
+	0x0036, 0x2019, 0x0001, 0x080c, 0xa5c8, 0x7033, 0x0000, 0x9006,
+	0x703e, 0x7042, 0x7046, 0x704a, 0x003e, 0x2029, 0x0001, 0x7038,
+	0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36, 0x1140, 0x2c00,
+	0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
+	0x0000, 0x080c, 0xcb5a, 0x01f0, 0x6014, 0x2048, 0x6020, 0x9086,
+	0x0003, 0x15b8, 0x6004, 0x9086, 0x0040, 0x090c, 0xa7a7, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036, 0x0076, 0x080c,
+	0xce4e, 0x080c, 0xe943, 0x080c, 0x6c94, 0x007e, 0x003e, 0x001e,
+	0x080c, 0xcd43, 0x080c, 0xae90, 0x00ce, 0x0804, 0x9186, 0x2c78,
+	0x600c, 0x2060, 0x0804, 0x9186, 0x85ff, 0x0120, 0x0036, 0x080c,
+	0x97d4, 0x003e, 0x012e, 0x000e, 0x001e, 0x002e, 0x003e, 0x005e,
+	0x006e, 0x007e, 0x009e, 0x00be, 0x00ce, 0x00de, 0x00ee, 0x00fe,
+	0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016, 0x0036, 0x0076,
+	0x080c, 0xe943, 0x080c, 0xe58c, 0x007e, 0x003e, 0x001e, 0x0890,
+	0x6020, 0x9086, 0x0009, 0x1168, 0xa87b, 0x0006, 0x0016, 0x0036,
+	0x0076, 0x080c, 0x6c94, 0x080c, 0xae5f, 0x007e, 0x003e, 0x001e,
+	0x0818, 0x6020, 0x9086, 0x000a, 0x0904, 0x91d1, 0x0804, 0x91ca,
+	0x0006, 0x0066, 0x0096, 0x00c6, 0x00d6, 0x00f6, 0x9036, 0x0126,
+	0x2091, 0x8000, 0x2079, 0x19e6, 0x7838, 0x9065, 0x0904, 0x927d,
+	0x600c, 0x0006, 0x600f, 0x0000, 0x783c, 0x9c06, 0x1168, 0x0036,
+	0x2019, 0x0001, 0x080c, 0xa5c8, 0x7833, 0x0000, 0x901e, 0x7b3e,
+	0x7b42, 0x7b46, 0x7b4a, 0x003e, 0x080c, 0xcb5a, 0x0548, 0x6014,
+	0x2048, 0x6020, 0x9086, 0x0003, 0x1590, 0x3e08, 0x918e, 0x0002,
+	0x1188, 0x6010, 0x9005, 0x0170, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x0140, 0x6040, 0x9005, 0x11a8, 0x2001, 0x1987, 0x2004,
+	0x6042, 0x0080, 0x6004, 0x9086, 0x0040, 0x090c, 0xa7a7, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6c88, 0x080c, 0xcd43,
+	0x080c, 0xae90, 0x000e, 0x0804, 0x9235, 0x7e3a, 0x7e36, 0x012e,
+	0x00fe, 0x00de, 0x00ce, 0x009e, 0x006e, 0x000e, 0x0005, 0x6020,
+	0x9086, 0x0006, 0x1118, 0x080c, 0xe58c, 0x0c50, 0x6020, 0x9086,
+	0x0009, 0x1130, 0xab7a, 0x080c, 0x6c94, 0x080c, 0xae5f, 0x0c10,
+	0x6020, 0x9086, 0x000a, 0x09a8, 0x0868, 0x0016, 0x0026, 0x0086,
+	0x9046, 0x0099, 0x080c, 0x9386, 0x008e, 0x002e, 0x001e, 0x0005,
+	0x00f6, 0x0126, 0x2079, 0x19e6, 0x2091, 0x8000, 0x080c, 0x941d,
+	0x080c, 0x94ab, 0x012e, 0x00fe, 0x0005, 0x00b6, 0x0096, 0x00f6,
+	0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0016, 0x0006, 0x0126, 0x2091,
+	0x8000, 0x2071, 0x19e6, 0x7614, 0x2660, 0x2678, 0x8cff, 0x0904,
+	0x934b, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x9346, 0x88ff,
+	0x0120, 0x6054, 0x9106, 0x1904, 0x9346, 0x7024, 0x9c06, 0x1558,
+	0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508, 0x080c, 0x857f, 0x080c,
+	0xa28f, 0x68c3, 0x0000, 0x080c, 0xa7a7, 0x7027, 0x0000, 0x0036,
 	0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100,
-	0x080c, 0x2cf1, 0x9006, 0x080c, 0x2cf1, 0x2069, 0x0100, 0x6824,
-	0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x00de, 0x00c6, 0xb83c,
-	0x9005, 0x0110, 0x8001, 0xb83e, 0x2660, 0x080c, 0xaea2, 0x00ce,
-	0x0048, 0x00de, 0x00c6, 0x2660, 0x6003, 0x0009, 0x630a, 0x00ce,
-	0x0804, 0x939a, 0x89ff, 0x0158, 0xa867, 0x0103, 0xab7a, 0xa877,
-	0x0000, 0x080c, 0xce3e, 0x080c, 0xe929, 0x080c, 0x6c86, 0x080c,
-	0xa693, 0x0804, 0x939a, 0x006e, 0x00de, 0x00ee, 0x00fe, 0x012e,
-	0x000e, 0x00ce, 0x009e, 0x00ae, 0x00be, 0x0005, 0x0096, 0x0006,
-	0x0066, 0x00c6, 0x00d6, 0x9036, 0x7814, 0x9065, 0x0904, 0x945f,
-	0x600c, 0x0006, 0x600f, 0x0000, 0x7824, 0x9c06, 0x1570, 0x2069,
-	0x0100, 0x6820, 0xd0a4, 0x1508, 0x080c, 0x8562, 0x080c, 0xa274,
-	0x68c3, 0x0000, 0x080c, 0xa7bd, 0x7827, 0x0000, 0x0036, 0x2069,
+	0x080c, 0x2cfc, 0x9006, 0x080c, 0x2cfc, 0x2069, 0x0100, 0x6824,
+	0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x0028, 0x6003, 0x0009,
+	0x630a, 0x0804, 0x9346, 0x7014, 0x9c36, 0x1110, 0x660c, 0x7616,
+	0x7010, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7012,
+	0x0010, 0x7013, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110,
+	0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x6014, 0x2048, 0x080c,
+	0xcb5a, 0x01e8, 0x6020, 0x9086, 0x0003, 0x1580, 0x080c, 0xcd60,
+	0x1118, 0x080c, 0xb821, 0x0098, 0xa867, 0x0103, 0xab7a, 0xa877,
+	0x0000, 0x0016, 0x0036, 0x0086, 0x080c, 0xce4e, 0x080c, 0xe943,
+	0x080c, 0x6c94, 0x008e, 0x003e, 0x001e, 0x080c, 0xcd43, 0x080c,
+	0xae90, 0x080c, 0xa67d, 0x00ce, 0x0804, 0x92c6, 0x2c78, 0x600c,
+	0x2060, 0x0804, 0x92c6, 0x012e, 0x000e, 0x001e, 0x006e, 0x00ce,
+	0x00de, 0x00ee, 0x00fe, 0x009e, 0x00be, 0x0005, 0x6020, 0x9086,
+	0x0006, 0x1158, 0x0016, 0x0036, 0x0086, 0x080c, 0xe943, 0x080c,
+	0xe58c, 0x008e, 0x003e, 0x001e, 0x08d0, 0x080c, 0xb821, 0x6020,
+	0x9086, 0x0002, 0x1160, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e,
+	0x0904, 0x932c, 0x9086, 0x008b, 0x0904, 0x932c, 0x0840, 0x6020,
+	0x9086, 0x0005, 0x1920, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e,
+	0x09c8, 0x9086, 0x008b, 0x09b0, 0x0804, 0x933f, 0x00b6, 0x00a6,
+	0x0096, 0x00c6, 0x0006, 0x0126, 0x2091, 0x8000, 0x9280, 0x1000,
+	0x2004, 0x905d, 0x0904, 0x9416, 0x00f6, 0x00e6, 0x00d6, 0x0066,
+	0x2071, 0x19e6, 0xbe54, 0x7018, 0x9b06, 0x1108, 0x761a, 0x701c,
+	0x9b06, 0x1130, 0x86ff, 0x1118, 0x7018, 0x701e, 0x0008, 0x761e,
+	0xb858, 0x904d, 0x0108, 0xae56, 0x96d5, 0x0000, 0x0110, 0x2900,
+	0xb05a, 0xb857, 0x0000, 0xb85b, 0x0000, 0xb800, 0xc0d4, 0xc0dc,
+	0xb802, 0x080c, 0x6548, 0x0904, 0x9412, 0x7624, 0x86ff, 0x0904,
+	0x9401, 0x9680, 0x0005, 0x2004, 0x9906, 0x15d8, 0x00d6, 0x2069,
+	0x0100, 0x68c0, 0x9005, 0x0560, 0x080c, 0x857f, 0x080c, 0xa28f,
+	0x68c3, 0x0000, 0x080c, 0xa7a7, 0x7027, 0x0000, 0x0036, 0x2069,
 	0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c,
-	0x2cf1, 0x9006, 0x080c, 0x2cf1, 0x2069, 0x0100, 0x6824, 0xd084,
-	0x0110, 0x6827, 0x0001, 0x003e, 0x0040, 0x080c, 0x6913, 0x1520,
-	0x6003, 0x0009, 0x630a, 0x2c30, 0x00f8, 0x6014, 0x2048, 0x080c,
-	0xcb48, 0x01b0, 0x6020, 0x9086, 0x0003, 0x1508, 0x080c, 0xcd50,
-	0x1118, 0x080c, 0xb824, 0x0060, 0x080c, 0x6913, 0x1168, 0xa867,
-	0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6c86, 0x080c, 0xcd33,
-	0x080c, 0xaea2, 0x080c, 0xa693, 0x000e, 0x0804, 0x9405, 0x7e16,
-	0x7e12, 0x00de, 0x00ce, 0x006e, 0x000e, 0x009e, 0x0005, 0x6020,
-	0x9086, 0x0006, 0x1118, 0x080c, 0xe572, 0x0c50, 0x080c, 0xb824,
-	0x6020, 0x9086, 0x0002, 0x1150, 0x6004, 0x0006, 0x9086, 0x0085,
-	0x000e, 0x0990, 0x9086, 0x008b, 0x0978, 0x08d0, 0x6020, 0x9086,
-	0x0005, 0x19b0, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0d18,
-	0x9086, 0x008b, 0x0d00, 0x0860, 0x0006, 0x0066, 0x0096, 0x00b6,
-	0x00c6, 0x00d6, 0x7818, 0x905d, 0x0904, 0x950c, 0xb854, 0x0006,
-	0x9006, 0xb856, 0xb85a, 0xb800, 0xc0d4, 0xc0dc, 0xb802, 0x080c,
-	0x653a, 0x0904, 0x9509, 0x7e24, 0x86ff, 0x0904, 0x94fc, 0x9680,
-	0x0005, 0x2004, 0x9906, 0x1904, 0x94fc, 0x00d6, 0x2069, 0x0100,
-	0x68c0, 0x9005, 0x0904, 0x94f3, 0x080c, 0x8562, 0x080c, 0xa274,
-	0x68c3, 0x0000, 0x080c, 0xa7bd, 0x7827, 0x0000, 0x0036, 0x2069,
-	0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c,
-	0x2cf1, 0x9006, 0x080c, 0x2cf1, 0x2069, 0x0100, 0x6824, 0xd084,
-	0x0110, 0x6827, 0x0001, 0x003e, 0x00de, 0x00c6, 0x3e08, 0x918e,
-	0x0002, 0x1168, 0xb800, 0xd0bc, 0x0150, 0x9680, 0x0010, 0x200c,
-	0x81ff, 0x1518, 0x2009, 0x1987, 0x210c, 0x2102, 0x00f0, 0xb83c,
-	0x9005, 0x0110, 0x8001, 0xb83e, 0x2660, 0x600f, 0x0000, 0x080c,
-	0xaea2, 0x00ce, 0x0048, 0x00de, 0x00c6, 0x2660, 0x6003, 0x0009,
-	0x630a, 0x00ce, 0x0804, 0x949f, 0x89ff, 0x0138, 0xa867, 0x0103,
-	0xab7a, 0xa877, 0x0000, 0x080c, 0x6c86, 0x080c, 0xa693, 0x0804,
-	0x949f, 0x000e, 0x0804, 0x9493, 0x781e, 0x781a, 0x00de, 0x00ce,
-	0x00be, 0x009e, 0x006e, 0x000e, 0x0005, 0x00e6, 0x00d6, 0x0096,
-	0x0066, 0xb800, 0xd0dc, 0x01a0, 0xb84c, 0x904d, 0x0188, 0xa878,
-	0x9606, 0x1170, 0x2071, 0x19e6, 0x7024, 0x9035, 0x0148, 0x9080,
-	0x0005, 0x2004, 0x9906, 0x1120, 0xb800, 0xc0dc, 0xb802, 0x0029,
-	0x006e, 0x009e, 0x00de, 0x00ee, 0x0005, 0x00f6, 0x2079, 0x0100,
-	0x78c0, 0x9005, 0x1138, 0x00c6, 0x2660, 0x6003, 0x0009, 0x630a,
-	0x00ce, 0x04b8, 0x080c, 0xa274, 0x78c3, 0x0000, 0x080c, 0xa7bd,
-	0x7027, 0x0000, 0x0036, 0x2079, 0x0140, 0x7b04, 0x9384, 0x1000,
-	0x0138, 0x2001, 0x0100, 0x080c, 0x2cf1, 0x9006, 0x080c, 0x2cf1,
-	0x2079, 0x0100, 0x7824, 0xd084, 0x0110, 0x7827, 0x0001, 0x080c,
-	0xa7bd, 0x003e, 0x080c, 0x653a, 0x00c6, 0xb83c, 0x9005, 0x0110,
-	0x8001, 0xb83e, 0x2660, 0x080c, 0xae71, 0x00ce, 0xa867, 0x0103,
-	0xab7a, 0xa877, 0x0000, 0x080c, 0xce3e, 0x080c, 0x6c86, 0x080c,
-	0xa693, 0x00fe, 0x0005, 0x00b6, 0x00e6, 0x00c6, 0x2011, 0x0101,
-	0x2204, 0xc0c4, 0x2012, 0x2001, 0x180c, 0x2014, 0xc2e4, 0x2202,
-	0x2071, 0x19e6, 0x7004, 0x9084, 0x0007, 0x0002, 0x9598, 0x959c,
-	0x95ba, 0x95e3, 0x9621, 0x9598, 0x95b3, 0x9596, 0x080c, 0x0dd5,
-	0x00ce, 0x00ee, 0x00be, 0x0005, 0x7024, 0x9065, 0x0148, 0x7020,
-	0x8001, 0x7022, 0x600c, 0x9015, 0x0158, 0x7216, 0x600f, 0x0000,
-	0x7007, 0x0000, 0x7027, 0x0000, 0x00ce, 0x00ee, 0x00be, 0x0005,
-	0x7216, 0x7212, 0x0ca8, 0x7007, 0x0000, 0x7027, 0x0000, 0x7020,
-	0x9005, 0x0070, 0x6010, 0x2058, 0x080c, 0x653a, 0xb800, 0xc0dc,
-	0xb802, 0x7007, 0x0000, 0x7027, 0x0000, 0x7020, 0x8001, 0x7022,
-	0x1148, 0x2001, 0x180c, 0x2014, 0xd2ec, 0x1180, 0x00ce, 0x00ee,
-	0x00be, 0x0005, 0xb854, 0x9015, 0x0120, 0x721e, 0x080c, 0x9687,
-	0x0ca8, 0x7218, 0x721e, 0x080c, 0x9687, 0x0c80, 0xc2ec, 0x2202,
-	0x080c, 0x97b5, 0x0c58, 0x7024, 0x9065, 0x05b8, 0x700c, 0x9c06,
-	0x1160, 0x080c, 0xa693, 0x600c, 0x9015, 0x0120, 0x720e, 0x600f,
-	0x0000, 0x0448, 0x720e, 0x720a, 0x0430, 0x7014, 0x9c06, 0x1160,
-	0x080c, 0xa693, 0x600c, 0x9015, 0x0120, 0x7216, 0x600f, 0x0000,
-	0x00d0, 0x7216, 0x7212, 0x00b8, 0x6020, 0x9086, 0x0003, 0x1198,
-	0x6010, 0x2058, 0x080c, 0x653a, 0xb800, 0xc0dc, 0xb802, 0x080c,
-	0xa693, 0x701c, 0x9065, 0x0138, 0xb854, 0x9015, 0x0110, 0x721e,
-	0x0010, 0x7218, 0x721e, 0x7027, 0x0000, 0x00ce, 0x00ee, 0x00be,
-	0x0005, 0x7024, 0x9065, 0x0140, 0x080c, 0xa693, 0x600c, 0x9015,
-	0x0158, 0x720e, 0x600f, 0x0000, 0x080c, 0xa7bd, 0x7027, 0x0000,
-	0x00ce, 0x00ee, 0x00be, 0x0005, 0x720e, 0x720a, 0x0ca8, 0x00d6,
-	0x2069, 0x19e6, 0x6830, 0x9084, 0x0003, 0x0002, 0x9644, 0x9646,
-	0x966a, 0x9642, 0x080c, 0x0dd5, 0x00de, 0x0005, 0x00c6, 0x6840,
-	0x9086, 0x0001, 0x01b8, 0x683c, 0x9065, 0x0130, 0x600c, 0x9015,
-	0x0170, 0x6a3a, 0x600f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000,
-	0x2011, 0x1a05, 0x2013, 0x0000, 0x00ce, 0x00de, 0x0005, 0x683a,
-	0x6836, 0x0c90, 0x6843, 0x0000, 0x6838, 0x9065, 0x0d68, 0x6003,
-	0x0003, 0x0c50, 0x00c6, 0x9006, 0x6842, 0x6846, 0x684a, 0x683c,
-	0x9065, 0x0160, 0x600c, 0x9015, 0x0130, 0x6a3a, 0x600f, 0x0000,
-	0x683f, 0x0000, 0x0018, 0x683e, 0x683a, 0x6836, 0x00ce, 0x00de,
-	0x0005, 0x2001, 0x180c, 0x200c, 0xc1e5, 0x2102, 0x0005, 0x2001,
-	0x180c, 0x200c, 0xd1ec, 0x0120, 0xc1ec, 0x2102, 0x080c, 0x97b5,
-	0x2001, 0x19f2, 0x2004, 0x9086, 0x0001, 0x0d58, 0x00d6, 0x2069,
-	0x19e6, 0x6804, 0x9084, 0x0007, 0x0006, 0x9005, 0x11c8, 0x2001,
-	0x1837, 0x2004, 0x9084, 0x0028, 0x1198, 0x2001, 0x197b, 0x2004,
-	0x9086, 0xaaaa, 0x0168, 0x2001, 0x188b, 0x2004, 0xd08c, 0x1118,
-	0xd084, 0x1118, 0x0028, 0x080c, 0x97b5, 0x000e, 0x00de, 0x0005,
-	0x000e, 0x0002, 0x96c4, 0x9783, 0x9783, 0x9783, 0x9783, 0x9785,
-	0x9783, 0x96c2, 0x080c, 0x0dd5, 0x6820, 0x9005, 0x1110, 0x00de,
-	0x0005, 0x00c6, 0x680c, 0x9065, 0x0520, 0x6114, 0x0096, 0x2148,
-	0xa964, 0x009e, 0x918c, 0x00ff, 0x918e, 0x0035, 0x1180, 0x2009,
-	0x1837, 0x210c, 0x918c, 0x0028, 0x1150, 0x080c, 0x73a5, 0x0138,
-	0x0006, 0x2009, 0x188b, 0x2104, 0xc095, 0x200a, 0x000e, 0x6807,
-	0x0004, 0x6826, 0x682b, 0x0000, 0x080c, 0x9862, 0x00ce, 0x00de,
-	0x0005, 0x6814, 0x9065, 0x0150, 0x6807, 0x0001, 0x6826, 0x682b,
-	0x0000, 0x080c, 0x9862, 0x00ce, 0x00de, 0x0005, 0x00b6, 0x00e6,
-	0x6a1c, 0x92dd, 0x0000, 0x0904, 0x976d, 0xb84c, 0x900d, 0x0118,
-	0xb888, 0x9005, 0x01a0, 0xb854, 0x905d, 0x0120, 0x920e, 0x0904,
-	0x976d, 0x0028, 0x6818, 0x920e, 0x0904, 0x976d, 0x2058, 0xb84c,
-	0x900d, 0x0d88, 0xb888, 0x9005, 0x1d70, 0x2b00, 0x681e, 0xbb3c,
-	0xb838, 0x9302, 0x1e40, 0x080c, 0xae48, 0x0904, 0x976d, 0x8318,
-	0xbb3e, 0x6116, 0x2b10, 0x6212, 0x0096, 0x2148, 0xa880, 0x9084,
-	0x00ff, 0x605e, 0xa883, 0x0000, 0xa884, 0x009e, 0x908a, 0x199a,
-	0x0210, 0x2001, 0x1999, 0x8003, 0x801b, 0x831b, 0x9318, 0x631a,
+	0x2cfc, 0x9006, 0x080c, 0x2cfc, 0x2069, 0x0100, 0x6824, 0xd084,
+	0x0110, 0x6827, 0x0001, 0x003e, 0x00de, 0x00c6, 0xb83c, 0x9005,
+	0x0110, 0x8001, 0xb83e, 0x2660, 0x080c, 0xae90, 0x00ce, 0x0048,
+	0x00de, 0x00c6, 0x2660, 0x6003, 0x0009, 0x630a, 0x00ce, 0x0804,
+	0x93b9, 0x89ff, 0x0158, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000,
+	0x080c, 0xce4e, 0x080c, 0xe943, 0x080c, 0x6c94, 0x080c, 0xa67d,
+	0x0804, 0x93b9, 0x006e, 0x00de, 0x00ee, 0x00fe, 0x012e, 0x000e,
+	0x00ce, 0x009e, 0x00ae, 0x00be, 0x0005, 0x0096, 0x0006, 0x0066,
+	0x00c6, 0x00d6, 0x9036, 0x7814, 0x9065, 0x0904, 0x947e, 0x600c,
+	0x0006, 0x600f, 0x0000, 0x7824, 0x9c06, 0x1570, 0x2069, 0x0100,
+	0x6820, 0xd0a4, 0x1508, 0x080c, 0x857f, 0x080c, 0xa28f, 0x68c3,
+	0x0000, 0x080c, 0xa7a7, 0x7827, 0x0000, 0x0036, 0x2069, 0x0140,
+	0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2cfc,
+	0x9006, 0x080c, 0x2cfc, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
+	0x6827, 0x0001, 0x003e, 0x0040, 0x080c, 0x6921, 0x1520, 0x6003,
+	0x0009, 0x630a, 0x2c30, 0x00f8, 0x6014, 0x2048, 0x080c, 0xcb58,
+	0x01b0, 0x6020, 0x9086, 0x0003, 0x1508, 0x080c, 0xcd60, 0x1118,
+	0x080c, 0xb821, 0x0060, 0x080c, 0x6921, 0x1168, 0xa867, 0x0103,
+	0xab7a, 0xa877, 0x0000, 0x080c, 0x6c94, 0x080c, 0xcd43, 0x080c,
+	0xae90, 0x080c, 0xa67d, 0x000e, 0x0804, 0x9424, 0x7e16, 0x7e12,
+	0x00de, 0x00ce, 0x006e, 0x000e, 0x009e, 0x0005, 0x6020, 0x9086,
+	0x0006, 0x1118, 0x080c, 0xe58c, 0x0c50, 0x080c, 0xb821, 0x6020,
+	0x9086, 0x0002, 0x1150, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e,
+	0x0990, 0x9086, 0x008b, 0x0978, 0x08d0, 0x6020, 0x9086, 0x0005,
+	0x19b0, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0d18, 0x9086,
+	0x008b, 0x0d00, 0x0860, 0x0006, 0x0066, 0x0096, 0x00b6, 0x00c6,
+	0x00d6, 0x7818, 0x905d, 0x0904, 0x952b, 0xb854, 0x0006, 0x9006,
+	0xb856, 0xb85a, 0xb800, 0xc0d4, 0xc0dc, 0xb802, 0x080c, 0x6548,
+	0x0904, 0x9528, 0x7e24, 0x86ff, 0x0904, 0x951b, 0x9680, 0x0005,
+	0x2004, 0x9906, 0x1904, 0x951b, 0x00d6, 0x2069, 0x0100, 0x68c0,
+	0x9005, 0x0904, 0x9512, 0x080c, 0x857f, 0x080c, 0xa28f, 0x68c3,
+	0x0000, 0x080c, 0xa7a7, 0x7827, 0x0000, 0x0036, 0x2069, 0x0140,
+	0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2cfc,
+	0x9006, 0x080c, 0x2cfc, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
+	0x6827, 0x0001, 0x003e, 0x00de, 0x00c6, 0x3e08, 0x918e, 0x0002,
+	0x1168, 0xb800, 0xd0bc, 0x0150, 0x9680, 0x0010, 0x200c, 0x81ff,
+	0x1518, 0x2009, 0x1987, 0x210c, 0x2102, 0x00f0, 0xb83c, 0x9005,
+	0x0110, 0x8001, 0xb83e, 0x2660, 0x600f, 0x0000, 0x080c, 0xae90,
+	0x00ce, 0x0048, 0x00de, 0x00c6, 0x2660, 0x6003, 0x0009, 0x630a,
+	0x00ce, 0x0804, 0x94be, 0x89ff, 0x0138, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x080c, 0x6c94, 0x080c, 0xa67d, 0x0804, 0x94be,
+	0x000e, 0x0804, 0x94b2, 0x781e, 0x781a, 0x00de, 0x00ce, 0x00be,
+	0x009e, 0x006e, 0x000e, 0x0005, 0x00e6, 0x00d6, 0x0096, 0x0066,
+	0xb800, 0xd0dc, 0x01a0, 0xb84c, 0x904d, 0x0188, 0xa878, 0x9606,
+	0x1170, 0x2071, 0x19e6, 0x7024, 0x9035, 0x0148, 0x9080, 0x0005,
+	0x2004, 0x9906, 0x1120, 0xb800, 0xc0dc, 0xb802, 0x0029, 0x006e,
+	0x009e, 0x00de, 0x00ee, 0x0005, 0x00f6, 0x2079, 0x0100, 0x78c0,
+	0x9005, 0x1138, 0x00c6, 0x2660, 0x6003, 0x0009, 0x630a, 0x00ce,
+	0x04b8, 0x080c, 0xa28f, 0x78c3, 0x0000, 0x080c, 0xa7a7, 0x7027,
+	0x0000, 0x0036, 0x2079, 0x0140, 0x7b04, 0x9384, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2cfc, 0x9006, 0x080c, 0x2cfc, 0x2079,
+	0x0100, 0x7824, 0xd084, 0x0110, 0x7827, 0x0001, 0x080c, 0xa7a7,
+	0x003e, 0x080c, 0x6548, 0x00c6, 0xb83c, 0x9005, 0x0110, 0x8001,
+	0xb83e, 0x2660, 0x080c, 0xae5f, 0x00ce, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x080c, 0xce4e, 0x080c, 0x6c94, 0x080c, 0xa67d,
+	0x00fe, 0x0005, 0x00b6, 0x00e6, 0x00c6, 0x2011, 0x0101, 0x2204,
+	0xc0c4, 0x2012, 0x2001, 0x180c, 0x2014, 0xc2e4, 0x2202, 0x2071,
+	0x19e6, 0x7004, 0x9084, 0x0007, 0x0002, 0x95b7, 0x95bb, 0x95d9,
+	0x9602, 0x9640, 0x95b7, 0x95d2, 0x95b5, 0x080c, 0x0dd5, 0x00ce,
+	0x00ee, 0x00be, 0x0005, 0x7024, 0x9065, 0x0148, 0x7020, 0x8001,
+	0x7022, 0x600c, 0x9015, 0x0158, 0x7216, 0x600f, 0x0000, 0x7007,
+	0x0000, 0x7027, 0x0000, 0x00ce, 0x00ee, 0x00be, 0x0005, 0x7216,
+	0x7212, 0x0ca8, 0x7007, 0x0000, 0x7027, 0x0000, 0x7020, 0x9005,
+	0x0070, 0x6010, 0x2058, 0x080c, 0x6548, 0xb800, 0xc0dc, 0xb802,
+	0x7007, 0x0000, 0x7027, 0x0000, 0x7020, 0x8001, 0x7022, 0x1148,
+	0x2001, 0x180c, 0x2014, 0xd2ec, 0x1180, 0x00ce, 0x00ee, 0x00be,
+	0x0005, 0xb854, 0x9015, 0x0120, 0x721e, 0x080c, 0x96a6, 0x0ca8,
+	0x7218, 0x721e, 0x080c, 0x96a6, 0x0c80, 0xc2ec, 0x2202, 0x080c,
+	0x97d4, 0x0c58, 0x7024, 0x9065, 0x05b8, 0x700c, 0x9c06, 0x1160,
+	0x080c, 0xa67d, 0x600c, 0x9015, 0x0120, 0x720e, 0x600f, 0x0000,
+	0x0448, 0x720e, 0x720a, 0x0430, 0x7014, 0x9c06, 0x1160, 0x080c,
+	0xa67d, 0x600c, 0x9015, 0x0120, 0x7216, 0x600f, 0x0000, 0x00d0,
+	0x7216, 0x7212, 0x00b8, 0x6020, 0x9086, 0x0003, 0x1198, 0x6010,
+	0x2058, 0x080c, 0x6548, 0xb800, 0xc0dc, 0xb802, 0x080c, 0xa67d,
+	0x701c, 0x9065, 0x0138, 0xb854, 0x9015, 0x0110, 0x721e, 0x0010,
+	0x7218, 0x721e, 0x7027, 0x0000, 0x00ce, 0x00ee, 0x00be, 0x0005,
+	0x7024, 0x9065, 0x0140, 0x080c, 0xa67d, 0x600c, 0x9015, 0x0158,
+	0x720e, 0x600f, 0x0000, 0x080c, 0xa7a7, 0x7027, 0x0000, 0x00ce,
+	0x00ee, 0x00be, 0x0005, 0x720e, 0x720a, 0x0ca8, 0x00d6, 0x2069,
+	0x19e6, 0x6830, 0x9084, 0x0003, 0x0002, 0x9663, 0x9665, 0x9689,
+	0x9661, 0x080c, 0x0dd5, 0x00de, 0x0005, 0x00c6, 0x6840, 0x9086,
+	0x0001, 0x01b8, 0x683c, 0x9065, 0x0130, 0x600c, 0x9015, 0x0170,
+	0x6a3a, 0x600f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000, 0x2011,
+	0x1a05, 0x2013, 0x0000, 0x00ce, 0x00de, 0x0005, 0x683a, 0x6836,
+	0x0c90, 0x6843, 0x0000, 0x6838, 0x9065, 0x0d68, 0x6003, 0x0003,
+	0x0c50, 0x00c6, 0x9006, 0x6842, 0x6846, 0x684a, 0x683c, 0x9065,
+	0x0160, 0x600c, 0x9015, 0x0130, 0x6a3a, 0x600f, 0x0000, 0x683f,
+	0x0000, 0x0018, 0x683e, 0x683a, 0x6836, 0x00ce, 0x00de, 0x0005,
+	0x2001, 0x180c, 0x200c, 0xc1e5, 0x2102, 0x0005, 0x2001, 0x180c,
+	0x200c, 0xd1ec, 0x0120, 0xc1ec, 0x2102, 0x080c, 0x97d4, 0x2001,
+	0x19f2, 0x2004, 0x9086, 0x0001, 0x0d58, 0x00d6, 0x2069, 0x19e6,
+	0x6804, 0x9084, 0x0007, 0x0006, 0x9005, 0x11c8, 0x2001, 0x1837,
+	0x2004, 0x9084, 0x0028, 0x1198, 0x2001, 0x197b, 0x2004, 0x9086,
+	0xaaaa, 0x0168, 0x2001, 0x188b, 0x2004, 0xd08c, 0x1118, 0xd084,
+	0x1118, 0x0028, 0x080c, 0x97d4, 0x000e, 0x00de, 0x0005, 0x000e,
+	0x0002, 0x96e3, 0x97a2, 0x97a2, 0x97a2, 0x97a2, 0x97a4, 0x97a2,
+	0x96e1, 0x080c, 0x0dd5, 0x6820, 0x9005, 0x1110, 0x00de, 0x0005,
+	0x00c6, 0x680c, 0x9065, 0x0520, 0x6114, 0x0096, 0x2148, 0xa964,
+	0x009e, 0x918c, 0x00ff, 0x918e, 0x0035, 0x1180, 0x2009, 0x1837,
+	0x210c, 0x918c, 0x0028, 0x1150, 0x080c, 0x73b3, 0x0138, 0x0006,
+	0x2009, 0x188b, 0x2104, 0xc095, 0x200a, 0x000e, 0x6807, 0x0004,
+	0x6826, 0x682b, 0x0000, 0x080c, 0x987d, 0x00ce, 0x00de, 0x0005,
+	0x6814, 0x9065, 0x0150, 0x6807, 0x0001, 0x6826, 0x682b, 0x0000,
+	0x080c, 0x987d, 0x00ce, 0x00de, 0x0005, 0x00b6, 0x00e6, 0x6a1c,
+	0x92dd, 0x0000, 0x0904, 0x978c, 0xb84c, 0x900d, 0x0118, 0xb888,
+	0x9005, 0x01a0, 0xb854, 0x905d, 0x0120, 0x920e, 0x0904, 0x978c,
+	0x0028, 0x6818, 0x920e, 0x0904, 0x978c, 0x2058, 0xb84c, 0x900d,
+	0x0d88, 0xb888, 0x9005, 0x1d70, 0x2b00, 0x681e, 0xbb3c, 0xb838,
+	0x9302, 0x1e40, 0x080c, 0xae36, 0x0904, 0x978c, 0x8318, 0xbb3e,
+	0x6116, 0x2b10, 0x6212, 0x0096, 0x2148, 0xa880, 0x9084, 0x00ff,
+	0x605e, 0xa883, 0x0000, 0xa884, 0x009e, 0x908a, 0x199a, 0x0210,
+	0x2001, 0x1999, 0x8003, 0x801b, 0x831b, 0x9318, 0x631a, 0x6114,
+	0x0096, 0x2148, 0xa964, 0x009e, 0x918c, 0x00ff, 0x918e, 0x0048,
+	0x0538, 0x00f6, 0x2c78, 0x2061, 0x0100, 0xbac0, 0x629a, 0x2069,
+	0x0200, 0x2071, 0x0240, 0x080c, 0x9dca, 0x2069, 0x19e6, 0xbb00,
+	0xc3dd, 0xbb02, 0x6807, 0x0002, 0x2f18, 0x6b26, 0x682b, 0x0000,
+	0x7823, 0x0003, 0x7803, 0x0001, 0x7807, 0x0040, 0x00fe, 0x00ee,
+	0x00be, 0x00ce, 0x00de, 0x0005, 0x00ee, 0x00be, 0x00ce, 0x0cd0,
+	0x6807, 0x0006, 0x2c18, 0x6b26, 0x6820, 0x8001, 0x6822, 0x682b,
+	0x0000, 0x080c, 0x6548, 0x080c, 0xac76, 0x00ee, 0x00be, 0x00ce,
+	0x00de, 0x0005, 0x00de, 0x0005, 0x00c6, 0x680c, 0x9065, 0x0508,
 	0x6114, 0x0096, 0x2148, 0xa964, 0x009e, 0x918c, 0x00ff, 0x918e,
-	0x0048, 0x0538, 0x00f6, 0x2c78, 0x2061, 0x0100, 0xbac0, 0x629a,
-	0x2069, 0x0200, 0x2071, 0x0240, 0x080c, 0x9daf, 0x2069, 0x19e6,
-	0xbb00, 0xc3dd, 0xbb02, 0x6807, 0x0002, 0x2f18, 0x6b26, 0x682b,
-	0x0000, 0x7823, 0x0003, 0x7803, 0x0001, 0x7807, 0x0040, 0x00fe,
-	0x00ee, 0x00be, 0x00ce, 0x00de, 0x0005, 0x00ee, 0x00be, 0x00ce,
-	0x0cd0, 0x6807, 0x0006, 0x2c18, 0x6b26, 0x6820, 0x8001, 0x6822,
-	0x682b, 0x0000, 0x080c, 0x653a, 0x080c, 0xac88, 0x00ee, 0x00be,
-	0x00ce, 0x00de, 0x0005, 0x00de, 0x0005, 0x00c6, 0x680c, 0x9065,
-	0x0508, 0x6114, 0x0096, 0x2148, 0xa964, 0x009e, 0x918c, 0x00ff,
-	0x918e, 0x0035, 0x1180, 0x2009, 0x1837, 0x210c, 0x918c, 0x0028,
-	0x1150, 0x080c, 0x73a5, 0x0138, 0x0006, 0x2009, 0x188b, 0x2104,
-	0xc095, 0x200a, 0x000e, 0x6807, 0x0004, 0x6826, 0x682b, 0x0000,
-	0x080c, 0x9862, 0x00ce, 0x00de, 0x0005, 0x2001, 0x180c, 0x2014,
-	0xc2ed, 0x2202, 0x00de, 0x00fe, 0x0005, 0x00f6, 0x00d6, 0x2069,
-	0x19e6, 0x6830, 0x9086, 0x0000, 0x1570, 0x2001, 0x180c, 0x2014,
-	0xd2e4, 0x0130, 0xc2e4, 0x2202, 0x080c, 0x9696, 0x2069, 0x19e6,
-	0x2001, 0x180c, 0x200c, 0xd1c4, 0x1508, 0x6838, 0x907d, 0x01d8,
-	0x6a04, 0x9296, 0x0000, 0x1904, 0x9856, 0x7920, 0x918e, 0x0009,
-	0x0588, 0x6833, 0x0001, 0x683e, 0x6847, 0x0000, 0x684b, 0x0000,
-	0x0126, 0x00f6, 0x2091, 0x2400, 0x002e, 0x080c, 0x1c48, 0x1178,
-	0x012e, 0x080c, 0xa0d1, 0x00de, 0x00fe, 0x0005, 0xc1c4, 0x2102,
-	0x0066, 0x2031, 0x0001, 0x080c, 0x7455, 0x006e, 0x08b0, 0x012e,
-	0x6843, 0x0000, 0x7803, 0x0002, 0x780c, 0x9015, 0x0140, 0x6a3a,
-	0x780f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000, 0x0c20, 0x683a,
-	0x6836, 0x0cc0, 0x7908, 0xd1fc, 0x1198, 0x6833, 0x0001, 0x683e,
-	0x6847, 0x0000, 0x684b, 0x0000, 0x0126, 0x00f6, 0x2091, 0x2400,
-	0x002e, 0x080c, 0x1c48, 0x19d8, 0x012e, 0x080c, 0xa052, 0x0858,
-	0x2001, 0x1837, 0x2004, 0x9084, 0x0028, 0x1188, 0x2001, 0x197b,
-	0x2004, 0x9086, 0xaaaa, 0x0158, 0x2001, 0x19e7, 0x2004, 0x9005,
-	0x11f0, 0x2001, 0x188b, 0x200c, 0xc185, 0xc18c, 0x2102, 0x2f00,
+	0x0035, 0x1180, 0x2009, 0x1837, 0x210c, 0x918c, 0x0028, 0x1150,
+	0x080c, 0x73b3, 0x0138, 0x0006, 0x2009, 0x188b, 0x2104, 0xc095,
+	0x200a, 0x000e, 0x6807, 0x0004, 0x6826, 0x682b, 0x0000, 0x080c,
+	0x987d, 0x00ce, 0x00de, 0x0005, 0x2001, 0x180c, 0x2014, 0xc2ed,
+	0x2202, 0x00de, 0x00fe, 0x0005, 0x00f6, 0x00d6, 0x2069, 0x19e6,
+	0x6830, 0x9086, 0x0000, 0x1570, 0x2001, 0x180c, 0x2014, 0xd2e4,
+	0x0130, 0xc2e4, 0x2202, 0x080c, 0x96b5, 0x2069, 0x19e6, 0x2001,
+	0x180c, 0x200c, 0xd1c4, 0x1508, 0x6838, 0x907d, 0x01d8, 0x6a04,
+	0x9296, 0x0000, 0x1904, 0x9871, 0x7920, 0x918e, 0x0009, 0x0568,
+	0x6833, 0x0001, 0x683e, 0x6847, 0x0000, 0x684b, 0x0000, 0x0126,
+	0x00f6, 0x2091, 0x2400, 0x002e, 0x080c, 0x1c53, 0x1158, 0x012e,
+	0x080c, 0xa0ec, 0x00de, 0x00fe, 0x0005, 0xc1c4, 0x2102, 0x080c,
+	0x7463, 0x08d0, 0x012e, 0x6843, 0x0000, 0x7803, 0x0002, 0x780c,
+	0x9015, 0x0140, 0x6a3a, 0x780f, 0x0000, 0x6833, 0x0000, 0x683f,
+	0x0000, 0x0c40, 0x683a, 0x6836, 0x0cc0, 0x7908, 0xd1fc, 0x1198,
 	0x6833, 0x0001, 0x683e, 0x6847, 0x0000, 0x684b, 0x0000, 0x0126,
-	0x00f6, 0x2091, 0x2400, 0x002e, 0x080c, 0x1c48, 0x1904, 0x97f7,
-	0x012e, 0x6a3c, 0x2278, 0x080c, 0x9fdc, 0x0804, 0x97eb, 0x2011,
-	0x188b, 0x2204, 0xc08d, 0x2012, 0x0804, 0x97eb, 0x6a04, 0x9296,
-	0x0006, 0x1904, 0x97ad, 0x6a30, 0x9296, 0x0000, 0x0904, 0x97d5,
-	0x0804, 0x97ad, 0x6020, 0x9084, 0x000f, 0x000b, 0x0005, 0x9876,
-	0x987b, 0x9ce9, 0x9d78, 0x987b, 0x9ce9, 0x9d78, 0x9876, 0x987b,
-	0x9876, 0x9876, 0x9876, 0x9876, 0x9876, 0x9876, 0x080c, 0x957b,
-	0x080c, 0x9687, 0x0005, 0x00b6, 0x0156, 0x0136, 0x0146, 0x01c6,
-	0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2069, 0x0200, 0x2071,
-	0x0240, 0x6004, 0x908a, 0x0053, 0x1a0c, 0x0dd5, 0x6110, 0x2158,
-	0xb9c0, 0x2c78, 0x2061, 0x0100, 0x619a, 0x908a, 0x0040, 0x1a04,
-	0x98e7, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de, 0x01ce,
-	0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0x9a6c, 0x9aa7, 0x9ad0,
-	0x9b78, 0x9b9a, 0x9ba0, 0x9bad, 0x9bb5, 0x9bc1, 0x9bc7, 0x9bd8,
-	0x9bc7, 0x9c30, 0x9bb5, 0x9c3c, 0x9c42, 0x9bc1, 0x9c42, 0x9c4e,
-	0x98e5, 0x98e5, 0x98e5, 0x98e5, 0x98e5, 0x98e5, 0x98e5, 0x98e5,
-	0x98e5, 0x98e5, 0x98e5, 0xa46e, 0xa491, 0xa4a2, 0xa4c2, 0xa4f4,
-	0x9bad, 0x98e5, 0x9bad, 0x9bc7, 0x98e5, 0x9ad0, 0x9b78, 0x98e5,
-	0xa8b4, 0x9bc7, 0x98e5, 0xa8d0, 0x9bc7, 0x98e5, 0x9bc1, 0x9a66,
-	0x9908, 0x98e5, 0xa8ec, 0xa959, 0xaa30, 0x98e5, 0xaa3d, 0x9baa,
-	0xaa68, 0x98e5, 0xa4fe, 0xaa95, 0x98e5, 0x080c, 0x0dd5, 0x2100,
-	0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e,
-	0x013e, 0x015e, 0x00be, 0x0005, 0xab30, 0xabe2, 0x9906, 0x992f,
-	0x99db, 0x99e6, 0x9906, 0x9bad, 0x9906, 0x9a2d, 0x9a39, 0x994a,
-	0x9906, 0x9965, 0x9999, 0xad4f, 0xad94, 0x9bc7, 0x080c, 0x0dd5,
-	0x00d6, 0x0096, 0x080c, 0x9c61, 0x7003, 0x2414, 0x7007, 0x0018,
-	0x700b, 0x0800, 0x7814, 0x2048, 0xa83c, 0x700e, 0xa850, 0x7022,
-	0xa854, 0x7026, 0x60c3, 0x0018, 0x080c, 0xa248, 0x009e, 0x00de,
-	0x0005, 0x7810, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x080c, 0xaddb,
-	0x1118, 0x9084, 0xff80, 0x0110, 0x9085, 0x0001, 0x0005, 0x00d6,
-	0x0096, 0x080c, 0x9c61, 0x7003, 0x0500, 0x7814, 0x2048, 0xa874,
-	0x700a, 0xa878, 0x700e, 0xa87c, 0x7012, 0xa880, 0x7016, 0xa884,
-	0x701a, 0xa888, 0x701e, 0x60c3, 0x0010, 0x080c, 0xa248, 0x009e,
-	0x00de, 0x0005, 0x00d6, 0x0096, 0x080c, 0x9c61, 0x7003, 0x0500,
-	0x7814, 0x2048, 0xa8cc, 0x700a, 0xa8d0, 0x700e, 0xa8d4, 0x7012,
-	0xa8d8, 0x7016, 0xa8dc, 0x701a, 0xa8e0, 0x701e, 0x60c3, 0x0010,
-	0x080c, 0xa248, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x9c61, 0x20e9, 0x0000, 0x2001, 0x19a2,
-	0x2003, 0x0000, 0x7814, 0x2048, 0xa814, 0x8003, 0x60c2, 0xa830,
-	0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098, 0x2001,
-	0x19a2, 0x0016, 0x200c, 0x2001, 0x0001, 0x080c, 0x23b9, 0x080c,
-	0xd886, 0x9006, 0x080c, 0x23b9, 0x001e, 0xa804, 0x9005, 0x0110,
-	0x2048, 0x0c28, 0x04d9, 0x080c, 0xa248, 0x012e, 0x009e, 0x00de,
-	0x0005, 0x00d6, 0x0096, 0x0126, 0x2091, 0x8000, 0x080c, 0x9cac,
-	0x20e9, 0x0000, 0x2001, 0x19a2, 0x2003, 0x0000, 0x7814, 0x2048,
-	0xa86f, 0x0200, 0xa873, 0x0000, 0xa814, 0x8003, 0x60c2, 0xa830,
-	0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098, 0x2001,
-	0x19a2, 0x0016, 0x200c, 0x080c, 0xd886, 0x001e, 0xa804, 0x9005,
-	0x0110, 0x2048, 0x0c60, 0x0051, 0x7814, 0x2048, 0x080c, 0x0fb1,
-	0x080c, 0xa248, 0x012e, 0x009e, 0x00de, 0x0005, 0x60c0, 0x8004,
-	0x9084, 0x0003, 0x9005, 0x0130, 0x9082, 0x0004, 0x20a3, 0x0000,
-	0x8000, 0x1de0, 0x0005, 0x080c, 0x9c61, 0x7003, 0x7800, 0x7808,
-	0x8007, 0x700a, 0x60c3, 0x0008, 0x0804, 0xa248, 0x00d6, 0x00e6,
-	0x080c, 0x9cac, 0x7814, 0x9084, 0xff00, 0x2073, 0x0200, 0x8e70,
-	0x8e70, 0x9095, 0x0010, 0x2272, 0x8e70, 0x2073, 0x0034, 0x8e70,
-	0x2069, 0x1805, 0x20a9, 0x0004, 0x2d76, 0x8d68, 0x8e70, 0x1f04,
-	0x99fc, 0x2069, 0x1801, 0x20a9, 0x0004, 0x2d76, 0x8d68, 0x8e70,
-	0x1f04, 0x9a05, 0x2069, 0x19b2, 0x9086, 0xdf00, 0x0110, 0x2069,
-	0x19cc, 0x20a9, 0x001a, 0x9e86, 0x0260, 0x1148, 0x00c6, 0x2061,
-	0x0200, 0x6010, 0x8000, 0x6012, 0x00ce, 0x2071, 0x0240, 0x2d04,
-	0x8007, 0x2072, 0x8d68, 0x8e70, 0x1f04, 0x9a13, 0x60c3, 0x004c,
-	0x080c, 0xa248, 0x00ee, 0x00de, 0x0005, 0x080c, 0x9c61, 0x7003,
-	0x6300, 0x7007, 0x0028, 0x7808, 0x700e, 0x60c3, 0x0008, 0x0804,
-	0xa248, 0x00d6, 0x0026, 0x0016, 0x080c, 0x9cac, 0x7003, 0x0200,
-	0x7814, 0x700e, 0x00e6, 0x9ef0, 0x0004, 0x2009, 0x0001, 0x2011,
-	0x000c, 0x2069, 0x1923, 0x6810, 0xd084, 0x1148, 0x2073, 0x0500,
-	0x8e70, 0x2073, 0x0000, 0x8e70, 0x8108, 0x9290, 0x0004, 0x2073,
-	0x0800, 0x8e70, 0x2073, 0x0000, 0x00ee, 0x7206, 0x710a, 0x62c2,
-	0x080c, 0xa248, 0x001e, 0x002e, 0x00de, 0x0005, 0x2001, 0x1818,
-	0x2004, 0x609a, 0x0804, 0xa248, 0x080c, 0x9c61, 0x7003, 0x5200,
-	0x2069, 0x1847, 0x6804, 0xd084, 0x0130, 0x6828, 0x0016, 0x080c,
-	0x2873, 0x710e, 0x001e, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099,
-	0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003, 0x20a9, 0x0004,
-	0x2099, 0x1801, 0x20a1, 0x0254, 0x4003, 0x080c, 0xaddb, 0x1120,
-	0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181f, 0x2004, 0x7032,
-	0x2001, 0x1820, 0x2004, 0x7036, 0x0030, 0x2001, 0x1818, 0x2004,
-	0x9084, 0x00ff, 0x7036, 0x60c3, 0x001c, 0x0804, 0xa248, 0x080c,
-	0x9c61, 0x7003, 0x0500, 0x080c, 0xaddb, 0x1120, 0xb8a0, 0x9082,
-	0x007f, 0x0248, 0x2001, 0x181f, 0x2004, 0x700a, 0x2001, 0x1820,
-	0x2004, 0x700e, 0x0030, 0x2001, 0x1818, 0x2004, 0x9084, 0x00ff,
-	0x700e, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9,
-	0x0000, 0x20a1, 0x0250, 0x4003, 0x60c3, 0x0010, 0x0804, 0xa248,
-	0x080c, 0x9c61, 0x9006, 0x080c, 0x6945, 0xb8a0, 0x9086, 0x007e,
-	0x1130, 0x7003, 0x0400, 0x620c, 0xc2b4, 0x620e, 0x0058, 0x7814,
-	0x0096, 0x904d, 0x0120, 0x9006, 0xa89a, 0xa8a6, 0xa8aa, 0x009e,
-	0x7003, 0x0300, 0xb8a0, 0x9086, 0x007e, 0x1904, 0x9b3f, 0x00d6,
-	0x2069, 0x196b, 0x2001, 0x1837, 0x2004, 0xd0a4, 0x0188, 0x6800,
-	0x700a, 0x6808, 0x9084, 0x2000, 0x7012, 0x080c, 0xadf2, 0x680c,
-	0x7016, 0x701f, 0x2710, 0x6818, 0x7022, 0x681c, 0x7026, 0x0090,
-	0x6800, 0x700a, 0x6804, 0x700e, 0x6808, 0x080c, 0x73a5, 0x1118,
-	0x9084, 0x37ff, 0x0010, 0x9084, 0x3fff, 0x7012, 0x080c, 0xadf2,
-	0x680c, 0x7016, 0x00de, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099,
-	0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256, 0x4003, 0x20a9, 0x0004,
-	0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x00d6, 0x080c, 0xab17,
-	0x2069, 0x1973, 0x2071, 0x024e, 0x6800, 0xc0dd, 0x7002, 0x080c,
-	0x56dc, 0xd0e4, 0x0110, 0x680c, 0x700e, 0x00de, 0x04a8, 0x2001,
-	0x1837, 0x2004, 0xd0a4, 0x0170, 0x0016, 0x2001, 0x196c, 0x200c,
-	0x60e0, 0x9106, 0x0130, 0x2100, 0x60e3, 0x0000, 0x080c, 0x28b4,
-	0x61e2, 0x001e, 0x20e1, 0x0001, 0x2099, 0x196b, 0x20e9, 0x0000,
-	0x20a1, 0x024e, 0x20a9, 0x0008, 0x4003, 0x20a9, 0x0004, 0x2099,
-	0x1805, 0x20a1, 0x0256, 0x4003, 0x20a9, 0x0004, 0x2099, 0x1801,
-	0x20a1, 0x025a, 0x4003, 0x080c, 0xab17, 0x20a1, 0x024e, 0x20a9,
-	0x0008, 0x2099, 0x1973, 0x4003, 0x60c3, 0x0074, 0x0804, 0xa248,
-	0x080c, 0x9c61, 0x7003, 0x2010, 0x7007, 0x0014, 0x700b, 0x0800,
-	0x700f, 0x2000, 0x9006, 0x00f6, 0x2079, 0x1847, 0x7904, 0x00fe,
-	0xd1ac, 0x1110, 0x9085, 0x0020, 0xd1a4, 0x0110, 0x9085, 0x0010,
-	0x9085, 0x0002, 0x00d6, 0x0804, 0x9c11, 0x7026, 0x60c3, 0x0014,
-	0x0804, 0xa248, 0x080c, 0x9c61, 0x7003, 0x5000, 0x0804, 0x9aea,
-	0x080c, 0x9c61, 0x7003, 0x2110, 0x7007, 0x0014, 0x60c3, 0x0014,
-	0x0804, 0xa248, 0x080c, 0x9ca3, 0x0010, 0x080c, 0x9cac, 0x7003,
-	0x0200, 0x60c3, 0x0004, 0x0804, 0xa248, 0x080c, 0x9cac, 0x7003,
+	0x00f6, 0x2091, 0x2400, 0x002e, 0x080c, 0x1c53, 0x19d8, 0x012e,
+	0x080c, 0xa06d, 0x0878, 0x2001, 0x1837, 0x2004, 0x9084, 0x0028,
+	0x1188, 0x2001, 0x197b, 0x2004, 0x9086, 0xaaaa, 0x0158, 0x2001,
+	0x19e7, 0x2004, 0x9005, 0x11f0, 0x2001, 0x188b, 0x200c, 0xc185,
+	0xc18c, 0x2102, 0x2f00, 0x6833, 0x0001, 0x683e, 0x6847, 0x0000,
+	0x684b, 0x0000, 0x0126, 0x00f6, 0x2091, 0x2400, 0x002e, 0x080c,
+	0x1c53, 0x1904, 0x9812, 0x012e, 0x6a3c, 0x2278, 0x080c, 0x9ff7,
+	0x0804, 0x980a, 0x2011, 0x188b, 0x2204, 0xc08d, 0x2012, 0x0804,
+	0x980a, 0x6a04, 0x9296, 0x0006, 0x1904, 0x97cc, 0x6a30, 0x9296,
+	0x0000, 0x0904, 0x97f4, 0x0804, 0x97cc, 0x6020, 0x9084, 0x000f,
+	0x000b, 0x0005, 0x9891, 0x9896, 0x9d04, 0x9d93, 0x9896, 0x9d04,
+	0x9d93, 0x9891, 0x9896, 0x9891, 0x9891, 0x9891, 0x9891, 0x9891,
+	0x9891, 0x080c, 0x959a, 0x080c, 0x96a6, 0x0005, 0x00b6, 0x0156,
+	0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a, 0x0053, 0x1a0c,
+	0x0dd5, 0x6110, 0x2158, 0xb9c0, 0x2c78, 0x2061, 0x0100, 0x619a,
+	0x908a, 0x0040, 0x1a04, 0x9902, 0x005b, 0x00fe, 0x00ee, 0x00de,
+	0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005,
+	0x9a87, 0x9ac2, 0x9aeb, 0x9b93, 0x9bb5, 0x9bbb, 0x9bc8, 0x9bd0,
+	0x9bdc, 0x9be2, 0x9bf3, 0x9be2, 0x9c4b, 0x9bd0, 0x9c57, 0x9c5d,
+	0x9bdc, 0x9c5d, 0x9c69, 0x9900, 0x9900, 0x9900, 0x9900, 0x9900,
+	0x9900, 0x9900, 0x9900, 0x9900, 0x9900, 0x9900, 0xa47f, 0xa4a2,
+	0xa4b3, 0xa4d3, 0xa505, 0x9bc8, 0x9900, 0x9bc8, 0x9be2, 0x9900,
+	0x9aeb, 0x9b93, 0x9900, 0xa89e, 0x9be2, 0x9900, 0xa8ba, 0x9be2,
+	0x9900, 0x9bdc, 0x9a81, 0x9923, 0x9900, 0xa8d6, 0xa943, 0xaa1e,
+	0x9900, 0xaa2b, 0x9bc5, 0xaa56, 0x9900, 0xa50f, 0xaa83, 0x9900,
+	0x080c, 0x0dd5, 0x2100, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0xab1e,
+	0xabd0, 0x9921, 0x994a, 0x99f6, 0x9a01, 0x9921, 0x9bc8, 0x9921,
+	0x9a48, 0x9a54, 0x9965, 0x9921, 0x9980, 0x99b4, 0xad3d, 0xad82,
+	0x9be2, 0x080c, 0x0dd5, 0x00d6, 0x0096, 0x080c, 0x9c7c, 0x7003,
+	0x2414, 0x7007, 0x0018, 0x700b, 0x0800, 0x7814, 0x2048, 0xa83c,
+	0x700e, 0xa850, 0x7022, 0xa854, 0x7026, 0x60c3, 0x0018, 0x080c,
+	0xa263, 0x009e, 0x00de, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb8a0,
+	0x00be, 0x080c, 0xadc9, 0x1118, 0x9084, 0xff80, 0x0110, 0x9085,
+	0x0001, 0x0005, 0x00d6, 0x0096, 0x080c, 0x9c7c, 0x7003, 0x0500,
+	0x7814, 0x2048, 0xa874, 0x700a, 0xa878, 0x700e, 0xa87c, 0x7012,
+	0xa880, 0x7016, 0xa884, 0x701a, 0xa888, 0x701e, 0x60c3, 0x0010,
+	0x080c, 0xa263, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x080c,
+	0x9c7c, 0x7003, 0x0500, 0x7814, 0x2048, 0xa8cc, 0x700a, 0xa8d0,
+	0x700e, 0xa8d4, 0x7012, 0xa8d8, 0x7016, 0xa8dc, 0x701a, 0xa8e0,
+	0x701e, 0x60c3, 0x0010, 0x080c, 0xa263, 0x009e, 0x00de, 0x0005,
+	0x00d6, 0x0096, 0x0126, 0x2091, 0x8000, 0x080c, 0x9c7c, 0x20e9,
+	0x0000, 0x2001, 0x19a2, 0x2003, 0x0000, 0x7814, 0x2048, 0xa814,
+	0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x001b, 0x2098, 0x2001, 0x19a2, 0x0016, 0x200c, 0x2001, 0x0001,
+	0x080c, 0x23c4, 0x080c, 0xd896, 0x9006, 0x080c, 0x23c4, 0x001e,
+	0xa804, 0x9005, 0x0110, 0x2048, 0x0c28, 0x04d9, 0x080c, 0xa263,
+	0x012e, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x9cc7, 0x20e9, 0x0000, 0x2001, 0x19a2, 0x2003,
+	0x0000, 0x7814, 0x2048, 0xa86f, 0x0200, 0xa873, 0x0000, 0xa814,
+	0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x001b, 0x2098, 0x2001, 0x19a2, 0x0016, 0x200c, 0x080c, 0xd896,
+	0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c60, 0x0051, 0x7814,
+	0x2048, 0x080c, 0x0fb1, 0x080c, 0xa263, 0x012e, 0x009e, 0x00de,
+	0x0005, 0x60c0, 0x8004, 0x9084, 0x0003, 0x9005, 0x0130, 0x9082,
+	0x0004, 0x20a3, 0x0000, 0x8000, 0x1de0, 0x0005, 0x080c, 0x9c7c,
+	0x7003, 0x7800, 0x7808, 0x8007, 0x700a, 0x60c3, 0x0008, 0x0804,
+	0xa263, 0x00d6, 0x00e6, 0x080c, 0x9cc7, 0x7814, 0x9084, 0xff00,
+	0x2073, 0x0200, 0x8e70, 0x8e70, 0x9095, 0x0010, 0x2272, 0x8e70,
+	0x2073, 0x0034, 0x8e70, 0x2069, 0x1805, 0x20a9, 0x0004, 0x2d76,
+	0x8d68, 0x8e70, 0x1f04, 0x9a17, 0x2069, 0x1801, 0x20a9, 0x0004,
+	0x2d76, 0x8d68, 0x8e70, 0x1f04, 0x9a20, 0x2069, 0x19b2, 0x9086,
+	0xdf00, 0x0110, 0x2069, 0x19cc, 0x20a9, 0x001a, 0x9e86, 0x0260,
+	0x1148, 0x00c6, 0x2061, 0x0200, 0x6010, 0x8000, 0x6012, 0x00ce,
+	0x2071, 0x0240, 0x2d04, 0x8007, 0x2072, 0x8d68, 0x8e70, 0x1f04,
+	0x9a2e, 0x60c3, 0x004c, 0x080c, 0xa263, 0x00ee, 0x00de, 0x0005,
+	0x080c, 0x9c7c, 0x7003, 0x6300, 0x7007, 0x0028, 0x7808, 0x700e,
+	0x60c3, 0x0008, 0x0804, 0xa263, 0x00d6, 0x0026, 0x0016, 0x080c,
+	0x9cc7, 0x7003, 0x0200, 0x7814, 0x700e, 0x00e6, 0x9ef0, 0x0004,
+	0x2009, 0x0001, 0x2011, 0x000c, 0x2069, 0x1923, 0x6810, 0xd084,
+	0x1148, 0x2073, 0x0500, 0x8e70, 0x2073, 0x0000, 0x8e70, 0x8108,
+	0x9290, 0x0004, 0x2073, 0x0800, 0x8e70, 0x2073, 0x0000, 0x00ee,
+	0x7206, 0x710a, 0x62c2, 0x080c, 0xa263, 0x001e, 0x002e, 0x00de,
+	0x0005, 0x2001, 0x1818, 0x2004, 0x609a, 0x0804, 0xa263, 0x080c,
+	0x9c7c, 0x7003, 0x5200, 0x2069, 0x1847, 0x6804, 0xd084, 0x0130,
+	0x6828, 0x0016, 0x080c, 0x287e, 0x710e, 0x001e, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250,
+	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x0254, 0x4003,
+	0x080c, 0xadc9, 0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001,
+	0x181f, 0x2004, 0x7032, 0x2001, 0x1820, 0x2004, 0x7036, 0x0030,
+	0x2001, 0x1818, 0x2004, 0x9084, 0x00ff, 0x7036, 0x60c3, 0x001c,
+	0x0804, 0xa263, 0x080c, 0x9c7c, 0x7003, 0x0500, 0x080c, 0xadc9,
+	0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181f, 0x2004,
+	0x700a, 0x2001, 0x1820, 0x2004, 0x700e, 0x0030, 0x2001, 0x1818,
+	0x2004, 0x9084, 0x00ff, 0x700e, 0x20a9, 0x0004, 0x20e1, 0x0001,
+	0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003, 0x60c3,
+	0x0010, 0x0804, 0xa263, 0x080c, 0x9c7c, 0x9006, 0x080c, 0x6953,
+	0xb8a0, 0x9086, 0x007e, 0x1130, 0x7003, 0x0400, 0x620c, 0xc2b4,
+	0x620e, 0x0058, 0x7814, 0x0096, 0x904d, 0x0120, 0x9006, 0xa89a,
+	0xa8a6, 0xa8aa, 0x009e, 0x7003, 0x0300, 0xb8a0, 0x9086, 0x007e,
+	0x1904, 0x9b5a, 0x00d6, 0x2069, 0x196b, 0x2001, 0x1837, 0x2004,
+	0xd0a4, 0x0188, 0x6800, 0x700a, 0x6808, 0x9084, 0x2000, 0x7012,
+	0x080c, 0xade0, 0x680c, 0x7016, 0x701f, 0x2710, 0x6818, 0x7022,
+	0x681c, 0x7026, 0x0090, 0x6800, 0x700a, 0x6804, 0x700e, 0x6808,
+	0x080c, 0x73b3, 0x1118, 0x9084, 0x37ff, 0x0010, 0x9084, 0x3fff,
+	0x7012, 0x080c, 0xade0, 0x680c, 0x7016, 0x00de, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256,
+	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003,
+	0x00d6, 0x080c, 0xab05, 0x2069, 0x1973, 0x2071, 0x024e, 0x6800,
+	0xc0dd, 0x7002, 0x080c, 0x56e6, 0xd0e4, 0x0110, 0x680c, 0x700e,
+	0x00de, 0x04a8, 0x2001, 0x1837, 0x2004, 0xd0a4, 0x0170, 0x0016,
+	0x2001, 0x196c, 0x200c, 0x60e0, 0x9106, 0x0130, 0x2100, 0x60e3,
+	0x0000, 0x080c, 0x28bf, 0x61e2, 0x001e, 0x20e1, 0x0001, 0x2099,
+	0x196b, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x20a9, 0x0008, 0x4003,
+	0x20a9, 0x0004, 0x2099, 0x1805, 0x20a1, 0x0256, 0x4003, 0x20a9,
+	0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x080c, 0xab05,
+	0x20a1, 0x024e, 0x20a9, 0x0008, 0x2099, 0x1973, 0x4003, 0x60c3,
+	0x0074, 0x0804, 0xa263, 0x080c, 0x9c7c, 0x7003, 0x2010, 0x7007,
+	0x0014, 0x700b, 0x0800, 0x700f, 0x2000, 0x9006, 0x00f6, 0x2079,
+	0x1847, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0xd1a4,
+	0x0110, 0x9085, 0x0010, 0x9085, 0x0002, 0x00d6, 0x0804, 0x9c2c,
+	0x7026, 0x60c3, 0x0014, 0x0804, 0xa263, 0x080c, 0x9c7c, 0x7003,
+	0x5000, 0x0804, 0x9b05, 0x080c, 0x9c7c, 0x7003, 0x2110, 0x7007,
+	0x0014, 0x60c3, 0x0014, 0x0804, 0xa263, 0x080c, 0x9cbe, 0x0010,
+	0x080c, 0x9cc7, 0x7003, 0x0200, 0x60c3, 0x0004, 0x0804, 0xa263,
+	0x080c, 0x9cc7, 0x7003, 0x0100, 0x700b, 0x0003, 0x700f, 0x2a00,
+	0x60c3, 0x0008, 0x0804, 0xa263, 0x080c, 0x9cc7, 0x7003, 0x0200,
+	0x0804, 0x9b05, 0x080c, 0x9cc7, 0x7003, 0x0100, 0x782c, 0x9005,
+	0x0110, 0x700a, 0x0010, 0x700b, 0x0003, 0x7814, 0x700e, 0x60c3,
+	0x0008, 0x0804, 0xa263, 0x00d6, 0x080c, 0x9cc7, 0x7003, 0x0210,
+	0x7007, 0x0014, 0x700b, 0x0800, 0xb894, 0x9086, 0x0014, 0x1198,
+	0xb99c, 0x9184, 0x0030, 0x0190, 0xb998, 0x9184, 0xc000, 0x1140,
+	0xd1ec, 0x0118, 0x700f, 0x2100, 0x0058, 0x700f, 0x0100, 0x0040,
+	0x700f, 0x0400, 0x0028, 0x700f, 0x0700, 0x0010, 0x700f, 0x0800,
+	0x00f6, 0x2079, 0x1847, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085,
+	0x0020, 0xd1a4, 0x0110, 0x9085, 0x0010, 0x2009, 0x1869, 0x210c,
+	0xd184, 0x1110, 0x9085, 0x0002, 0x0026, 0x2009, 0x1867, 0x210c,
+	0xd1e4, 0x0150, 0xc0c5, 0xbacc, 0xd28c, 0x1108, 0xc0cd, 0x9094,
+	0x0030, 0x9296, 0x0010, 0x0140, 0xd1ec, 0x0130, 0x9094, 0x0030,
+	0x9296, 0x0010, 0x0108, 0xc0bd, 0x002e, 0x7026, 0x60c3, 0x0014,
+	0x00de, 0x0804, 0xa263, 0x080c, 0x9cc7, 0x7003, 0x0210, 0x7007,
+	0x0014, 0x700f, 0x0100, 0x60c3, 0x0014, 0x0804, 0xa263, 0x080c,
+	0x9cc7, 0x7003, 0x0200, 0x0804, 0x9a8b, 0x080c, 0x9cc7, 0x7003,
 	0x0100, 0x700b, 0x0003, 0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804,
-	0xa248, 0x080c, 0x9cac, 0x7003, 0x0200, 0x0804, 0x9aea, 0x080c,
-	0x9cac, 0x7003, 0x0100, 0x782c, 0x9005, 0x0110, 0x700a, 0x0010,
-	0x700b, 0x0003, 0x7814, 0x700e, 0x60c3, 0x0008, 0x0804, 0xa248,
-	0x00d6, 0x080c, 0x9cac, 0x7003, 0x0210, 0x7007, 0x0014, 0x700b,
-	0x0800, 0xb894, 0x9086, 0x0014, 0x1198, 0xb99c, 0x9184, 0x0030,
-	0x0190, 0xb998, 0x9184, 0xc000, 0x1140, 0xd1ec, 0x0118, 0x700f,
-	0x2100, 0x0058, 0x700f, 0x0100, 0x0040, 0x700f, 0x0400, 0x0028,
-	0x700f, 0x0700, 0x0010, 0x700f, 0x0800, 0x00f6, 0x2079, 0x1847,
-	0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0xd1a4, 0x0110,
-	0x9085, 0x0010, 0x2009, 0x1869, 0x210c, 0xd184, 0x1110, 0x9085,
-	0x0002, 0x0026, 0x2009, 0x1867, 0x210c, 0xd1e4, 0x0150, 0xc0c5,
-	0xbacc, 0xd28c, 0x1108, 0xc0cd, 0x9094, 0x0030, 0x9296, 0x0010,
-	0x0140, 0xd1ec, 0x0130, 0x9094, 0x0030, 0x9296, 0x0010, 0x0108,
-	0xc0bd, 0x002e, 0x7026, 0x60c3, 0x0014, 0x00de, 0x0804, 0xa248,
-	0x080c, 0x9cac, 0x7003, 0x0210, 0x7007, 0x0014, 0x700f, 0x0100,
-	0x60c3, 0x0014, 0x0804, 0xa248, 0x080c, 0x9cac, 0x7003, 0x0200,
-	0x0804, 0x9a70, 0x080c, 0x9cac, 0x7003, 0x0100, 0x700b, 0x0003,
-	0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804, 0xa248, 0x080c, 0x9cac,
-	0x7003, 0x0100, 0x700b, 0x000b, 0x60c3, 0x0008, 0x0804, 0xa248,
-	0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x3200, 0x2021, 0x0800,
-	0x0040, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x2200, 0x2021,
-	0x0100, 0x080c, 0xab2c, 0xb810, 0x9305, 0x7002, 0xb814, 0x7006,
-	0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x9485, 0x0029,
-	0x7012, 0x004e, 0x003e, 0x00de, 0x080c, 0xa236, 0x721a, 0x9f95,
-	0x0000, 0x7222, 0x7027, 0xffff, 0x2071, 0x024c, 0x002e, 0x0005,
-	0x0026, 0x080c, 0xab2c, 0x7003, 0x02ff, 0x7007, 0xfffc, 0x00d6,
-	0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x00de, 0x7013,
-	0x2029, 0x0c10, 0x7003, 0x0100, 0x7007, 0x0000, 0x700b, 0xfc02,
-	0x700f, 0x0000, 0x0005, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019,
-	0x3300, 0x2021, 0x0800, 0x0040, 0x0026, 0x00d6, 0x0036, 0x0046,
-	0x2019, 0x2300, 0x2021, 0x0100, 0x080c, 0xab2c, 0xb810, 0x9305,
-	0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0xb810, 0x9005, 0x1140,
-	0xb814, 0x9005, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffe, 0x0020,
-	0x687c, 0x700a, 0x6880, 0x700e, 0x0000, 0x9485, 0x0098, 0x7012,
-	0x004e, 0x003e, 0x00de, 0x080c, 0xa236, 0x721a, 0x7a08, 0x7222,
-	0x2f10, 0x7226, 0x2071, 0x024c, 0x002e, 0x0005, 0x080c, 0xa236,
-	0x721a, 0x7a08, 0x7222, 0x7814, 0x7026, 0x2071, 0x024c, 0x002e,
-	0x0005, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2069, 0x0200,
-	0x2071, 0x0240, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0dd5, 0x908a,
-	0x0092, 0x1a0c, 0x0dd5, 0x6110, 0x2158, 0xb9c0, 0x2c78, 0x2061,
-	0x0100, 0x619a, 0x9082, 0x0085, 0x0033, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x00be, 0x0005, 0x9d1a, 0x9d29, 0x9d34, 0x9d18, 0x9d18,
-	0x9d18, 0x9d1a, 0x9d18, 0x9d18, 0x9d18, 0x9d18, 0x9d18, 0x9d18,
-	0x080c, 0x0dd5, 0x0411, 0x60c3, 0x0000, 0x0026, 0x080c, 0x2ba7,
-	0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012, 0x002e, 0x0804,
-	0xa248, 0x0431, 0x7808, 0x700a, 0x7814, 0x700e, 0x7017, 0xffff,
-	0x60c3, 0x000c, 0x0804, 0xa248, 0x0479, 0x7003, 0x0003, 0x7007,
-	0x0300, 0x60c3, 0x0004, 0x0804, 0xa248, 0x0026, 0x080c, 0xab2c,
-	0xb810, 0x9085, 0x8100, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800,
-	0x687c, 0x700a, 0x6880, 0x700e, 0x7013, 0x0009, 0x0804, 0x9c7c,
-	0x0026, 0x080c, 0xab2c, 0xb810, 0x9085, 0x8400, 0x7002, 0xb814,
-	0x7006, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x2001,
-	0x0099, 0x7012, 0x0804, 0x9cde, 0x0026, 0x080c, 0xab2c, 0xb810,
-	0x9085, 0x8500, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x687c,
-	0x700a, 0x6880, 0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x9cde,
-	0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2c78, 0x2069, 0x0200,
-	0x2071, 0x0240, 0x7804, 0x908a, 0x0040, 0x0a0c, 0x0dd5, 0x908a,
-	0x0054, 0x1a0c, 0x0dd5, 0x7910, 0x2158, 0xb9c0, 0x2061, 0x0100,
-	0x619a, 0x9082, 0x0040, 0x0033, 0x00fe, 0x00ee, 0x00de, 0x00ce,
-	0x00be, 0x0005, 0x9daf, 0x9e6b, 0x9e3e, 0x9f8d, 0x9dad, 0x9dad,
-	0x9dad, 0x9dad, 0x9dad, 0x9dad, 0x9dad, 0xa670, 0xa678, 0xa680,
-	0xa688, 0x9dad, 0xaa74, 0x9dad, 0xa668, 0x080c, 0x0dd5, 0x0096,
-	0x780b, 0xffff, 0x080c, 0x9e1a, 0x7914, 0x2148, 0xa978, 0x7956,
-	0xae64, 0x96b4, 0x00ff, 0x9686, 0x0008, 0x1148, 0xa8b4, 0x7032,
-	0xa8b8, 0x7036, 0xa8bc, 0x703a, 0xa8c0, 0x703e, 0x0008, 0x7132,
-	0xa97c, 0x9184, 0x000f, 0x1118, 0x2001, 0x0005, 0x0040, 0xd184,
-	0x0118, 0x2001, 0x0004, 0x0018, 0x9084, 0x0006, 0x8004, 0x2010,
-	0x785c, 0x9084, 0x00ff, 0x8007, 0x9205, 0x7042, 0xd1ac, 0x0158,
-	0x7047, 0x0002, 0x9686, 0x0008, 0x1118, 0x080c, 0x18ae, 0x0010,
-	0x080c, 0x1727, 0x0050, 0xd1b4, 0x0118, 0x7047, 0x0001, 0x0028,
-	0x7047, 0x0000, 0x9016, 0x2230, 0x0010, 0xaab0, 0xaeac, 0x726a,
-	0x766e, 0x20a9, 0x0008, 0x20e9, 0x0000, 0xa860, 0x20e0, 0xa85c,
-	0x9080, 0x0023, 0x2098, 0x20a1, 0x0252, 0x2069, 0x0200, 0x6813,
-	0x0018, 0x4003, 0x6813, 0x0008, 0x60c3, 0x0020, 0x6017, 0x0009,
-	0x2001, 0x1a02, 0x2003, 0x07d0, 0x2001, 0x1a01, 0x2003, 0x0009,
-	0x009e, 0x0005, 0x6813, 0x0008, 0xba8c, 0x8210, 0xb8cc, 0xd084,
-	0x0128, 0x7a46, 0x7b14, 0x7b4a, 0x722e, 0x732a, 0x9294, 0x00ff,
-	0xba8e, 0x8217, 0x721a, 0xba10, 0x9295, 0x0600, 0x7202, 0xba14,
-	0x7206, 0x2069, 0x1800, 0x6a7c, 0x720a, 0x6a80, 0x720e, 0x7013,
-	0x0829, 0x2f10, 0x7222, 0x7027, 0xffff, 0x0005, 0x00d6, 0x0096,
-	0x0081, 0x7814, 0x2048, 0xa890, 0x7002, 0xa88c, 0x7006, 0xa8b0,
-	0x700a, 0xa8ac, 0x700e, 0x60c3, 0x000c, 0x009e, 0x00de, 0x0804,
-	0xa248, 0x6813, 0x0008, 0xb810, 0x9085, 0x0500, 0x7002, 0xb814,
+	0xa263, 0x080c, 0x9cc7, 0x7003, 0x0100, 0x700b, 0x000b, 0x60c3,
+	0x0008, 0x0804, 0xa263, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019,
+	0x3200, 0x2021, 0x0800, 0x0040, 0x0026, 0x00d6, 0x0036, 0x0046,
+	0x2019, 0x2200, 0x2021, 0x0100, 0x080c, 0xab1a, 0xb810, 0x9305,
+	0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880,
+	0x700e, 0x9485, 0x0029, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c,
+	0xa251, 0x721a, 0x9f95, 0x0000, 0x7222, 0x7027, 0xffff, 0x2071,
+	0x024c, 0x002e, 0x0005, 0x0026, 0x080c, 0xab1a, 0x7003, 0x02ff,
+	0x7007, 0xfffc, 0x00d6, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880,
+	0x700e, 0x00de, 0x7013, 0x2029, 0x0c10, 0x7003, 0x0100, 0x7007,
+	0x0000, 0x700b, 0xfc02, 0x700f, 0x0000, 0x0005, 0x0026, 0x00d6,
+	0x0036, 0x0046, 0x2019, 0x3300, 0x2021, 0x0800, 0x0040, 0x0026,
+	0x00d6, 0x0036, 0x0046, 0x2019, 0x2300, 0x2021, 0x0100, 0x080c,
+	0xab1a, 0xb810, 0x9305, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800,
+	0xb810, 0x9005, 0x1140, 0xb814, 0x9005, 0x1128, 0x700b, 0x00ff,
+	0x700f, 0xfffe, 0x0020, 0x687c, 0x700a, 0x6880, 0x700e, 0x0000,
+	0x9485, 0x0098, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c, 0xa251,
+	0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c, 0x002e,
+	0x0005, 0x080c, 0xa251, 0x721a, 0x7a08, 0x7222, 0x7814, 0x7026,
+	0x2071, 0x024c, 0x002e, 0x0005, 0x00b6, 0x00c6, 0x00d6, 0x00e6,
+	0x00f6, 0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a, 0x0085,
+	0x0a0c, 0x0dd5, 0x908a, 0x0092, 0x1a0c, 0x0dd5, 0x6110, 0x2158,
+	0xb9c0, 0x2c78, 0x2061, 0x0100, 0x619a, 0x9082, 0x0085, 0x0033,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x9d35, 0x9d44,
+	0x9d4f, 0x9d33, 0x9d33, 0x9d33, 0x9d35, 0x9d33, 0x9d33, 0x9d33,
+	0x9d33, 0x9d33, 0x9d33, 0x080c, 0x0dd5, 0x0411, 0x60c3, 0x0000,
+	0x0026, 0x080c, 0x2bb2, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5,
+	0x2012, 0x002e, 0x0804, 0xa263, 0x0431, 0x7808, 0x700a, 0x7814,
+	0x700e, 0x7017, 0xffff, 0x60c3, 0x000c, 0x0804, 0xa263, 0x0479,
+	0x7003, 0x0003, 0x7007, 0x0300, 0x60c3, 0x0004, 0x0804, 0xa263,
+	0x0026, 0x080c, 0xab1a, 0xb810, 0x9085, 0x8100, 0x7002, 0xb814,
 	0x7006, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x7013,
-	0x0889, 0x080c, 0xa236, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226,
-	0x2071, 0x024c, 0x0005, 0x00d6, 0x0096, 0x080c, 0x9f6b, 0x7814,
-	0x2048, 0x080c, 0xcb48, 0x1130, 0x7814, 0x9084, 0x0700, 0x8007,
-	0x0033, 0x0010, 0x9006, 0x001b, 0x009e, 0x00de, 0x0005, 0x9e89,
-	0x9ef2, 0x9f02, 0x9f28, 0x9f34, 0x9f45, 0x9f4d, 0x9e87, 0x080c,
-	0x0dd5, 0x0016, 0x0036, 0xa97c, 0x918c, 0x0003, 0x0118, 0x9186,
-	0x0003, 0x1198, 0xaba8, 0x7824, 0xd0cc, 0x1168, 0x7316, 0xa898,
-	0x701a, 0xa894, 0x701e, 0x003e, 0x001e, 0x2001, 0x19b0, 0x2004,
-	0x60c2, 0x0804, 0xa248, 0xc3e5, 0x0c88, 0x9186, 0x0001, 0x190c,
-	0x0dd5, 0xaba8, 0x7824, 0xd0cc, 0x1904, 0x9eef, 0x7316, 0xa898,
-	0x701a, 0xa894, 0x701e, 0xa8a4, 0x7026, 0xa8ac, 0x702e, 0x2009,
-	0x0018, 0x9384, 0x0300, 0x0570, 0xd3c4, 0x0110, 0xa8ac, 0x9108,
-	0xd3cc, 0x0110, 0xa8a4, 0x9108, 0x6810, 0x9085, 0x0010, 0x6812,
-	0x2011, 0x0258, 0x20e9, 0x0000, 0x22a0, 0x0156, 0x20a9, 0x0008,
-	0xa860, 0x20e0, 0xa85c, 0x9080, 0x002c, 0x2098, 0x4003, 0x6810,
-	0x8000, 0x6812, 0x2011, 0x0240, 0x22a0, 0x20a9, 0x0005, 0x4003,
-	0x6810, 0xc084, 0x6812, 0x015e, 0x9184, 0x0003, 0x0118, 0x2019,
-	0x0245, 0x201a, 0x61c2, 0x003e, 0x001e, 0x0804, 0xa248, 0xc3e5,
-	0x0804, 0x9eae, 0x2011, 0x0008, 0x2001, 0x180f, 0x2004, 0xd0a4,
-	0x0110, 0x2011, 0x0028, 0x7824, 0xd0cc, 0x1110, 0x7216, 0x0470,
-	0x0ce8, 0xc2e5, 0x2011, 0x0302, 0x0016, 0x782c, 0x701a, 0x7930,
-	0x711e, 0x9105, 0x0108, 0xc2dd, 0x001e, 0x7824, 0xd0cc, 0x0108,
-	0xc2e5, 0x7216, 0x7027, 0x0012, 0x702f, 0x0008, 0x7043, 0x7000,
-	0x7047, 0x0500, 0x704f, 0x000a, 0x2069, 0x0200, 0x6813, 0x0009,
-	0x2071, 0x0240, 0x700b, 0x2500, 0x60c3, 0x0032, 0x0804, 0xa248,
-	0x2011, 0x0028, 0x7824, 0xd0cc, 0x1128, 0x7216, 0x60c3, 0x0018,
-	0x0804, 0xa248, 0x0cd0, 0xc2e5, 0x2011, 0x0100, 0x7824, 0xd0cc,
-	0x0108, 0xc2e5, 0x7216, 0x702f, 0x0008, 0x7858, 0x9084, 0x00ff,
-	0x7036, 0x60c3, 0x0020, 0x0804, 0xa248, 0x2011, 0x0008, 0x7824,
-	0xd0cc, 0x0108, 0xc2e5, 0x7216, 0x0c08, 0x0036, 0x7b14, 0x9384,
-	0xff00, 0x7816, 0x9384, 0x00ff, 0x8001, 0x1138, 0x7824, 0xd0cc,
-	0x0108, 0xc2e5, 0x7216, 0x003e, 0x0888, 0x0046, 0x2021, 0x0800,
-	0x0006, 0x7824, 0xd0cc, 0x000e, 0x0108, 0xc4e5, 0x7416, 0x004e,
-	0x701e, 0x003e, 0x0818, 0x00d6, 0x6813, 0x0008, 0xb810, 0x9085,
-	0x0700, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x687c, 0x700a,
-	0x6880, 0x700e, 0x7824, 0xd0cc, 0x1168, 0x7013, 0x0898, 0x080c,
-	0xa236, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c,
-	0x00de, 0x0005, 0x7013, 0x0889, 0x0c90, 0x0016, 0x7814, 0x9084,
-	0x0700, 0x8007, 0x0013, 0x001e, 0x0005, 0x9f9d, 0x9f9d, 0x9f9f,
-	0x9f9d, 0x9f9d, 0x9f9d, 0x9fb9, 0x9f9d, 0x080c, 0x0dd5, 0x7914,
-	0x918c, 0x08ff, 0x918d, 0xf600, 0x7916, 0x2009, 0x0003, 0x00b9,
-	0x2069, 0x1847, 0x6804, 0xd0bc, 0x0130, 0x682c, 0x9084, 0x00ff,
-	0x8007, 0x7032, 0x0010, 0x7033, 0x3f00, 0x60c3, 0x0001, 0x0804,
-	0xa248, 0x2009, 0x0003, 0x0019, 0x7033, 0x7f00, 0x0cb0, 0x0016,
-	0x080c, 0xab2c, 0x001e, 0xb810, 0x9085, 0x0100, 0x7002, 0xb814,
-	0x7006, 0x2069, 0x1800, 0x6a7c, 0x720a, 0x6a80, 0x720e, 0x7013,
-	0x0888, 0x918d, 0x0008, 0x7116, 0x080c, 0xa236, 0x721a, 0x7a08,
-	0x7222, 0x2f10, 0x7226, 0x0005, 0x00b6, 0x00e6, 0x00d6, 0x00c6,
-	0x0066, 0x0056, 0x0046, 0x0036, 0x2061, 0x0100, 0x2071, 0x1800,
-	0x7160, 0x7810, 0x2058, 0x76dc, 0x96b4, 0x0028, 0x0110, 0x737c,
-	0x7480, 0x2500, 0x76dc, 0x96b4, 0x0028, 0x0140, 0x2001, 0x04ff,
-	0x6062, 0x6067, 0xffff, 0x636a, 0x646e, 0x0050, 0x2001, 0x00ff,
-	0x9085, 0x0400, 0x6062, 0x6067, 0xffff, 0x606b, 0x0000, 0x616e,
-	0xb8b8, 0x6073, 0x0530, 0x6077, 0x0008, 0xb88c, 0x8000, 0x9084,
-	0x00ff, 0xb88e, 0x8007, 0x9085, 0x0020, 0x607a, 0x607f, 0x0000,
-	0x2b00, 0x6082, 0x6087, 0xffff, 0x7814, 0x0096, 0x2048, 0xa838,
-	0x608a, 0xa834, 0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca, 0x009e,
-	0xb86c, 0x60ce, 0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7, 0x0000,
-	0x2001, 0x1837, 0x2004, 0x9084, 0x0028, 0x0128, 0x609f, 0x0000,
-	0x2001, 0x0092, 0x0048, 0x6028, 0xc0bd, 0x602a, 0x609f, 0x00ff,
-	0x6027, 0xffff, 0x2001, 0x00b2, 0x6016, 0x2009, 0x07d0, 0x080c,
-	0x8567, 0x003e, 0x004e, 0x005e, 0x006e, 0x00ce, 0x00de, 0x00ee,
-	0x00be, 0x0005, 0x00b6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0056,
-	0x0046, 0x0036, 0x2061, 0x0100, 0x2071, 0x1800, 0x7160, 0x7810,
-	0x2058, 0xb8a0, 0x2028, 0x76dc, 0xd6ac, 0x1168, 0x9582, 0x007e,
-	0x1250, 0x2500, 0x9094, 0xff80, 0x1130, 0x9080, 0x3327, 0x2015,
-	0x9294, 0x00ff, 0x0020, 0xb910, 0xba14, 0x737c, 0x7480, 0x70dc,
-	0xd0ac, 0x1130, 0x9582, 0x007e, 0x1218, 0x9584, 0xff80, 0x0138,
-	0x9185, 0x0400, 0x6062, 0x6266, 0x636a, 0x646e, 0x0030, 0x6063,
-	0x0400, 0x6266, 0x606b, 0x0000, 0x616e, 0xb8b8, 0x6072, 0x6077,
-	0x0000, 0xb864, 0xd0a4, 0x0110, 0x6077, 0x0008, 0xb88c, 0x8000,
-	0x9084, 0x00ff, 0xb88e, 0x8007, 0x9085, 0x0020, 0x607a, 0x607f,
-	0x0000, 0x2b00, 0x6082, 0x6087, 0xffff, 0x7814, 0x0096, 0x2048,
+	0x0009, 0x0804, 0x9c97, 0x0026, 0x080c, 0xab1a, 0xb810, 0x9085,
+	0x8400, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x687c, 0x700a,
+	0x6880, 0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x9cf9, 0x0026,
+	0x080c, 0xab1a, 0xb810, 0x9085, 0x8500, 0x7002, 0xb814, 0x7006,
+	0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x2001, 0x0099,
+	0x7012, 0x0804, 0x9cf9, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x2c78, 0x2069, 0x0200, 0x2071, 0x0240, 0x7804, 0x908a, 0x0040,
+	0x0a0c, 0x0dd5, 0x908a, 0x0054, 0x1a0c, 0x0dd5, 0x7910, 0x2158,
+	0xb9c0, 0x2061, 0x0100, 0x619a, 0x9082, 0x0040, 0x0033, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x9dca, 0x9e86, 0x9e59,
+	0x9fa8, 0x9dc8, 0x9dc8, 0x9dc8, 0x9dc8, 0x9dc8, 0x9dc8, 0x9dc8,
+	0xa65a, 0xa662, 0xa66a, 0xa672, 0x9dc8, 0xaa62, 0x9dc8, 0xa652,
+	0x080c, 0x0dd5, 0x0096, 0x780b, 0xffff, 0x080c, 0x9e35, 0x7914,
+	0x2148, 0xa978, 0x7956, 0xae64, 0x96b4, 0x00ff, 0x9686, 0x0008,
+	0x1148, 0xa8b4, 0x7032, 0xa8b8, 0x7036, 0xa8bc, 0x703a, 0xa8c0,
+	0x703e, 0x0008, 0x7132, 0xa97c, 0x9184, 0x000f, 0x1118, 0x2001,
+	0x0005, 0x0040, 0xd184, 0x0118, 0x2001, 0x0004, 0x0018, 0x9084,
+	0x0006, 0x8004, 0x2010, 0x785c, 0x9084, 0x00ff, 0x8007, 0x9205,
+	0x7042, 0xd1ac, 0x0158, 0x7047, 0x0002, 0x9686, 0x0008, 0x1118,
+	0x080c, 0x18ae, 0x0010, 0x080c, 0x1727, 0x0050, 0xd1b4, 0x0118,
+	0x7047, 0x0001, 0x0028, 0x7047, 0x0000, 0x9016, 0x2230, 0x0010,
+	0xaab0, 0xaeac, 0x726a, 0x766e, 0x20a9, 0x0008, 0x20e9, 0x0000,
+	0xa860, 0x20e0, 0xa85c, 0x9080, 0x0023, 0x2098, 0x20a1, 0x0252,
+	0x2069, 0x0200, 0x6813, 0x0018, 0x4003, 0x6813, 0x0008, 0x60c3,
+	0x0020, 0x6017, 0x0009, 0x2001, 0x1a02, 0x2003, 0x07d0, 0x2001,
+	0x1a01, 0x2003, 0x0009, 0x009e, 0x0005, 0x6813, 0x0008, 0xba8c,
+	0x8210, 0xb8cc, 0xd084, 0x0128, 0x7a46, 0x7b14, 0x7b4a, 0x722e,
+	0x732a, 0x9294, 0x00ff, 0xba8e, 0x8217, 0x721a, 0xba10, 0x9295,
+	0x0600, 0x7202, 0xba14, 0x7206, 0x2069, 0x1800, 0x6a7c, 0x720a,
+	0x6a80, 0x720e, 0x7013, 0x0829, 0x2f10, 0x7222, 0x7027, 0xffff,
+	0x0005, 0x00d6, 0x0096, 0x0081, 0x7814, 0x2048, 0xa890, 0x7002,
+	0xa88c, 0x7006, 0xa8b0, 0x700a, 0xa8ac, 0x700e, 0x60c3, 0x000c,
+	0x009e, 0x00de, 0x0804, 0xa263, 0x6813, 0x0008, 0xb810, 0x9085,
+	0x0500, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x687c, 0x700a,
+	0x6880, 0x700e, 0x7013, 0x0889, 0x080c, 0xa251, 0x721a, 0x7a08,
+	0x7222, 0x2f10, 0x7226, 0x2071, 0x024c, 0x0005, 0x00d6, 0x0096,
+	0x080c, 0x9f86, 0x7814, 0x2048, 0x080c, 0xcb58, 0x1130, 0x7814,
+	0x9084, 0x0700, 0x8007, 0x0033, 0x0010, 0x9006, 0x001b, 0x009e,
+	0x00de, 0x0005, 0x9ea4, 0x9f0d, 0x9f1d, 0x9f43, 0x9f4f, 0x9f60,
+	0x9f68, 0x9ea2, 0x080c, 0x0dd5, 0x0016, 0x0036, 0xa97c, 0x918c,
+	0x0003, 0x0118, 0x9186, 0x0003, 0x1198, 0xaba8, 0x7824, 0xd0cc,
+	0x1168, 0x7316, 0xa898, 0x701a, 0xa894, 0x701e, 0x003e, 0x001e,
+	0x2001, 0x19b0, 0x2004, 0x60c2, 0x0804, 0xa263, 0xc3e5, 0x0c88,
+	0x9186, 0x0001, 0x190c, 0x0dd5, 0xaba8, 0x7824, 0xd0cc, 0x1904,
+	0x9f0a, 0x7316, 0xa898, 0x701a, 0xa894, 0x701e, 0xa8a4, 0x7026,
+	0xa8ac, 0x702e, 0x2009, 0x0018, 0x9384, 0x0300, 0x0570, 0xd3c4,
+	0x0110, 0xa8ac, 0x9108, 0xd3cc, 0x0110, 0xa8a4, 0x9108, 0x6810,
+	0x9085, 0x0010, 0x6812, 0x2011, 0x0258, 0x20e9, 0x0000, 0x22a0,
+	0x0156, 0x20a9, 0x0008, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x002c,
+	0x2098, 0x4003, 0x6810, 0x8000, 0x6812, 0x2011, 0x0240, 0x22a0,
+	0x20a9, 0x0005, 0x4003, 0x6810, 0xc084, 0x6812, 0x015e, 0x9184,
+	0x0003, 0x0118, 0x2019, 0x0245, 0x201a, 0x61c2, 0x003e, 0x001e,
+	0x0804, 0xa263, 0xc3e5, 0x0804, 0x9ec9, 0x2011, 0x0008, 0x2001,
+	0x180f, 0x2004, 0xd0a4, 0x0110, 0x2011, 0x0028, 0x7824, 0xd0cc,
+	0x1110, 0x7216, 0x0470, 0x0ce8, 0xc2e5, 0x2011, 0x0302, 0x0016,
+	0x782c, 0x701a, 0x7930, 0x711e, 0x9105, 0x0108, 0xc2dd, 0x001e,
+	0x7824, 0xd0cc, 0x0108, 0xc2e5, 0x7216, 0x7027, 0x0012, 0x702f,
+	0x0008, 0x7043, 0x7000, 0x7047, 0x0500, 0x704f, 0x000a, 0x2069,
+	0x0200, 0x6813, 0x0009, 0x2071, 0x0240, 0x700b, 0x2500, 0x60c3,
+	0x0032, 0x0804, 0xa263, 0x2011, 0x0028, 0x7824, 0xd0cc, 0x1128,
+	0x7216, 0x60c3, 0x0018, 0x0804, 0xa263, 0x0cd0, 0xc2e5, 0x2011,
+	0x0100, 0x7824, 0xd0cc, 0x0108, 0xc2e5, 0x7216, 0x702f, 0x0008,
+	0x7858, 0x9084, 0x00ff, 0x7036, 0x60c3, 0x0020, 0x0804, 0xa263,
+	0x2011, 0x0008, 0x7824, 0xd0cc, 0x0108, 0xc2e5, 0x7216, 0x0c08,
+	0x0036, 0x7b14, 0x9384, 0xff00, 0x7816, 0x9384, 0x00ff, 0x8001,
+	0x1138, 0x7824, 0xd0cc, 0x0108, 0xc2e5, 0x7216, 0x003e, 0x0888,
+	0x0046, 0x2021, 0x0800, 0x0006, 0x7824, 0xd0cc, 0x000e, 0x0108,
+	0xc4e5, 0x7416, 0x004e, 0x701e, 0x003e, 0x0818, 0x00d6, 0x6813,
+	0x0008, 0xb810, 0x9085, 0x0700, 0x7002, 0xb814, 0x7006, 0x2069,
+	0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x7824, 0xd0cc, 0x1168,
+	0x7013, 0x0898, 0x080c, 0xa251, 0x721a, 0x7a08, 0x7222, 0x2f10,
+	0x7226, 0x2071, 0x024c, 0x00de, 0x0005, 0x7013, 0x0889, 0x0c90,
+	0x0016, 0x7814, 0x9084, 0x0700, 0x8007, 0x0013, 0x001e, 0x0005,
+	0x9fb8, 0x9fb8, 0x9fba, 0x9fb8, 0x9fb8, 0x9fb8, 0x9fd4, 0x9fb8,
+	0x080c, 0x0dd5, 0x7914, 0x918c, 0x08ff, 0x918d, 0xf600, 0x7916,
+	0x2009, 0x0003, 0x00b9, 0x2069, 0x1847, 0x6804, 0xd0bc, 0x0130,
+	0x682c, 0x9084, 0x00ff, 0x8007, 0x7032, 0x0010, 0x7033, 0x3f00,
+	0x60c3, 0x0001, 0x0804, 0xa263, 0x2009, 0x0003, 0x0019, 0x7033,
+	0x7f00, 0x0cb0, 0x0016, 0x080c, 0xab1a, 0x001e, 0xb810, 0x9085,
+	0x0100, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6a7c, 0x720a,
+	0x6a80, 0x720e, 0x7013, 0x0888, 0x918d, 0x0008, 0x7116, 0x080c,
+	0xa251, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x0005, 0x00b6,
+	0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0056, 0x0046, 0x0036, 0x2061,
+	0x0100, 0x2071, 0x1800, 0x7160, 0x7810, 0x2058, 0x76dc, 0x96b4,
+	0x0028, 0x0110, 0x737c, 0x7480, 0x2500, 0x76dc, 0x96b4, 0x0028,
+	0x0140, 0x2001, 0x04ff, 0x6062, 0x6067, 0xffff, 0x636a, 0x646e,
+	0x0050, 0x2001, 0x00ff, 0x9085, 0x0400, 0x6062, 0x6067, 0xffff,
+	0x606b, 0x0000, 0x616e, 0xb8b8, 0x6073, 0x0530, 0x6077, 0x0008,
+	0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x9085, 0x0020,
+	0x607a, 0x607f, 0x0000, 0x2b00, 0x6082, 0x6087, 0xffff, 0x7814,
+	0x0096, 0x2048, 0xa838, 0x608a, 0xa834, 0x608e, 0xa848, 0x60c6,
+	0xa844, 0x60ca, 0x009e, 0xb86c, 0x60ce, 0x60ab, 0x0036, 0x60af,
+	0x95d5, 0x60d7, 0x0000, 0x2001, 0x1837, 0x2004, 0x9084, 0x0028,
+	0x0128, 0x609f, 0x0000, 0x2001, 0x0092, 0x0048, 0x6028, 0xc0bd,
+	0x602a, 0x609f, 0x00ff, 0x6027, 0xffff, 0x2001, 0x00b2, 0x6016,
+	0x2009, 0x07d0, 0x080c, 0x8584, 0x003e, 0x004e, 0x005e, 0x006e,
+	0x00ce, 0x00de, 0x00ee, 0x00be, 0x0005, 0x00b6, 0x00e6, 0x00d6,
+	0x00c6, 0x0066, 0x0056, 0x0046, 0x0036, 0x2061, 0x0100, 0x2071,
+	0x1800, 0x7160, 0x7810, 0x2058, 0xb8a0, 0x2028, 0x76dc, 0xd6ac,
+	0x1168, 0x9582, 0x007e, 0x1250, 0x2500, 0x9094, 0xff80, 0x1130,
+	0x9080, 0x3332, 0x2015, 0x9294, 0x00ff, 0x0020, 0xb910, 0xba14,
+	0x737c, 0x7480, 0x70dc, 0xd0ac, 0x1130, 0x9582, 0x007e, 0x1218,
+	0x9584, 0xff80, 0x0138, 0x9185, 0x0400, 0x6062, 0x6266, 0x636a,
+	0x646e, 0x0030, 0x6063, 0x0400, 0x6266, 0x606b, 0x0000, 0x616e,
+	0xb8b8, 0x6072, 0x6077, 0x0000, 0xb864, 0xd0a4, 0x0110, 0x6077,
+	0x0008, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x9085,
+	0x0020, 0x607a, 0x607f, 0x0000, 0x2b00, 0x6082, 0x6087, 0xffff,
+	0x7814, 0x0096, 0x2048, 0xa838, 0x608a, 0xa834, 0x608e, 0xa848,
+	0x60c6, 0xa844, 0x60ca, 0x009e, 0xb86c, 0x60ce, 0x60ab, 0x0036,
+	0x60af, 0x95d5, 0x60d7, 0x0000, 0xbac0, 0x629e, 0x00f6, 0x2079,
+	0x0140, 0x7803, 0x0000, 0x00fe, 0x2009, 0x0092, 0x6116, 0x2009,
+	0x07d0, 0x080c, 0x8584, 0x003e, 0x004e, 0x005e, 0x006e, 0x00ce,
+	0x00de, 0x00ee, 0x00be, 0x0005, 0x00b6, 0x0096, 0x00e6, 0x00d6,
+	0x00c6, 0x0056, 0x0046, 0x0036, 0x2061, 0x0100, 0x2071, 0x1800,
+	0x7810, 0x2058, 0xb8a0, 0x2028, 0xb910, 0xba14, 0x737c, 0x7480,
+	0x7820, 0x90be, 0x0006, 0x0904, 0xa1c0, 0x90be, 0x000a, 0x1904,
+	0xa17c, 0xb8c0, 0x609e, 0x7814, 0x2048, 0xa87c, 0xd0fc, 0x0558,
+	0xaf90, 0x9784, 0xff00, 0x9105, 0x6062, 0x873f, 0x9784, 0xff00,
+	0x0006, 0x7814, 0x2048, 0xa878, 0xc0fc, 0x9005, 0x000e, 0x1160,
+	0xaf94, 0x87ff, 0x0198, 0x2039, 0x0098, 0x9705, 0x6072, 0x7808,
+	0x6082, 0x2f00, 0x6086, 0x0038, 0x9185, 0x2200, 0x6062, 0x6073,
+	0x0129, 0x6077, 0x0000, 0xb8c0, 0x609e, 0x0050, 0x2039, 0x0029,
+	0x9705, 0x6072, 0x0cc0, 0x9185, 0x0200, 0x6062, 0x6073, 0x2029,
+	0xa87c, 0xd0fc, 0x0118, 0xaf94, 0x87ff, 0x1120, 0x2f00, 0x6082,
+	0x7808, 0x6086, 0x6266, 0x636a, 0x646e, 0x6077, 0x0000, 0xb88c,
+	0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000,
 	0xa838, 0x608a, 0xa834, 0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca,
-	0x009e, 0xb86c, 0x60ce, 0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7,
-	0x0000, 0xbac0, 0x629e, 0x00f6, 0x2079, 0x0140, 0x7803, 0x0000,
-	0x00fe, 0x2009, 0x0092, 0x6116, 0x2009, 0x07d0, 0x080c, 0x8567,
-	0x003e, 0x004e, 0x005e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00be,
-	0x0005, 0x00b6, 0x0096, 0x00e6, 0x00d6, 0x00c6, 0x0056, 0x0046,
-	0x0036, 0x2061, 0x0100, 0x2071, 0x1800, 0x7810, 0x2058, 0xb8a0,
-	0x2028, 0xb910, 0xba14, 0x737c, 0x7480, 0x7820, 0x90be, 0x0006,
-	0x0904, 0xa1a5, 0x90be, 0x000a, 0x1904, 0xa161, 0xb8c0, 0x609e,
-	0x7814, 0x2048, 0xa87c, 0xd0fc, 0x0558, 0xaf90, 0x9784, 0xff00,
-	0x9105, 0x6062, 0x873f, 0x9784, 0xff00, 0x0006, 0x7814, 0x2048,
-	0xa878, 0xc0fc, 0x9005, 0x000e, 0x1160, 0xaf94, 0x87ff, 0x0198,
-	0x2039, 0x0098, 0x9705, 0x6072, 0x7808, 0x6082, 0x2f00, 0x6086,
-	0x0038, 0x9185, 0x2200, 0x6062, 0x6073, 0x0129, 0x6077, 0x0000,
-	0xb8c0, 0x609e, 0x0050, 0x2039, 0x0029, 0x9705, 0x6072, 0x0cc0,
-	0x9185, 0x0200, 0x6062, 0x6073, 0x2029, 0xa87c, 0xd0fc, 0x0118,
-	0xaf94, 0x87ff, 0x1120, 0x2f00, 0x6082, 0x7808, 0x6086, 0x6266,
-	0x636a, 0x646e, 0x6077, 0x0000, 0xb88c, 0x8000, 0x9084, 0x00ff,
-	0xb88e, 0x8007, 0x607a, 0x607f, 0x0000, 0xa838, 0x608a, 0xa834,
-	0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce, 0x60af,
-	0x95d5, 0x60d7, 0x0000, 0x080c, 0xab11, 0x2009, 0x07d0, 0x60c4,
-	0x9084, 0xfff0, 0x9005, 0x0110, 0x2009, 0x1b58, 0x080c, 0x8567,
-	0x003e, 0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x009e, 0x00be,
-	0x0005, 0x7804, 0x9086, 0x0040, 0x0904, 0xa1e1, 0x9185, 0x0100,
-	0x6062, 0x6266, 0x636a, 0x646e, 0x6073, 0x0809, 0x6077, 0x0008,
-	0x60af, 0x95d5, 0x60d7, 0x0000, 0xb88c, 0x8000, 0x9084, 0x00ff,
-	0xb88e, 0x8007, 0x607a, 0x607f, 0x0000, 0x2f00, 0x6082, 0x7808,
-	0x6086, 0x7814, 0x2048, 0xa838, 0x608a, 0xa834, 0x608e, 0xa848,
-	0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce, 0xbac0, 0x629e, 0x080c,
-	0xab11, 0x2009, 0x07d0, 0x60c4, 0x9084, 0xfff0, 0x9005, 0x0110,
-	0x2009, 0x1b58, 0x080c, 0x8567, 0x003e, 0x004e, 0x005e, 0x00ce,
-	0x00de, 0x00ee, 0x009e, 0x00be, 0x0005, 0x7814, 0x2048, 0xa87c,
-	0x9084, 0x0003, 0x9086, 0x0002, 0x0904, 0xa1fd, 0x9185, 0x0100,
-	0x6062, 0x6266, 0x636a, 0x646e, 0x6073, 0x0880, 0x6077, 0x0008,
-	0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x7838,
-	0x607e, 0x2f00, 0x6086, 0x7808, 0x6082, 0xa890, 0x608a, 0xa88c,
-	0x608e, 0xa8b0, 0x60c6, 0xa8ac, 0x60ca, 0xa8ac, 0x7930, 0x9108,
-	0x7932, 0xa8b0, 0x792c, 0x9109, 0x792e, 0xb86c, 0x60ce, 0x60af,
-	0x95d5, 0x60d7, 0x0000, 0xbac0, 0x629e, 0x080c, 0xaaee, 0x0804,
-	0xa191, 0xb8cc, 0xd084, 0x0148, 0xb88c, 0x7814, 0x2048, 0xb88c,
-	0x7846, 0xa836, 0x2900, 0xa83a, 0xb04a, 0x9185, 0x0600, 0x6062,
-	0x6266, 0x636a, 0x646e, 0x6073, 0x0829, 0x6077, 0x0000, 0x60af,
-	0x9575, 0x60d7, 0x0000, 0x0804, 0xa174, 0x9185, 0x0700, 0x6062,
-	0x6266, 0x636a, 0x646e, 0x7824, 0xd0cc, 0x7826, 0x0118, 0x6073,
-	0x0889, 0x0010, 0x6073, 0x0898, 0x6077, 0x0000, 0xb88c, 0x8000,
-	0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000, 0x2f00,
-	0x6086, 0x7808, 0x6082, 0xa838, 0x608a, 0xa834, 0x608e, 0xa848,
-	0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce, 0x60af, 0x95d5, 0x60d7,
-	0x0000, 0xbac0, 0x629e, 0x7824, 0xd0cc, 0x0120, 0x080c, 0xab11,
-	0x0804, 0xa191, 0x080c, 0xaaee, 0x0804, 0xa191, 0x7a10, 0x00b6,
-	0x2258, 0xba8c, 0x8210, 0x9294, 0x00ff, 0xba8e, 0x00be, 0x8217,
-	0x0005, 0x00d6, 0x2069, 0x19e6, 0x6843, 0x0001, 0x00de, 0x0005,
-	0x60a3, 0x0056, 0x60a7, 0x9575, 0x00f1, 0x080c, 0x8559, 0x0005,
-	0x0016, 0x2001, 0x180c, 0x200c, 0x9184, 0x0600, 0x9086, 0x0600,
-	0x0128, 0x0089, 0x080c, 0x8559, 0x001e, 0x0005, 0xc1e5, 0x2001,
-	0x180c, 0x2102, 0x2001, 0x19e7, 0x2003, 0x0000, 0x2001, 0x19ef,
-	0x2003, 0x0000, 0x0c88, 0x0006, 0x6014, 0x9084, 0x1804, 0x9085,
-	0x0009, 0x6016, 0x000e, 0x0005, 0x0016, 0x00c6, 0x0006, 0x2061,
-	0x0100, 0x61a4, 0x60a7, 0x95f5, 0x6014, 0x9084, 0x1804, 0x9085,
-	0x0008, 0x6016, 0x000e, 0xa001, 0xa001, 0xa001, 0x61a6, 0x00ce,
-	0x001e, 0x0005, 0x00c6, 0x00d6, 0x0016, 0x0026, 0x2061, 0x0100,
-	0x2069, 0x0140, 0x080c, 0x73a5, 0x11e8, 0x2001, 0x1a02, 0x2004,
-	0x9005, 0x1904, 0xa2da, 0x0066, 0x2031, 0x0001, 0x080c, 0x7455,
-	0x006e, 0x1160, 0x2061, 0x0100, 0x6020, 0xd0b4, 0x1120, 0x6024,
-	0xd084, 0x090c, 0x0dd5, 0x080c, 0x8559, 0x0460, 0x00c6, 0x2061,
-	0x19e6, 0x00d0, 0x6904, 0x9194, 0x4000, 0x0548, 0x080c, 0xa274,
-	0x080c, 0x2d01, 0x00c6, 0x2061, 0x19e6, 0x6128, 0x9192, 0x0008,
-	0x1258, 0x8108, 0x612a, 0x6124, 0x00ce, 0x81ff, 0x0198, 0x080c,
-	0x8559, 0x080c, 0xa26b, 0x0070, 0x6124, 0x91e5, 0x0000, 0x0140,
-	0x080c, 0xea1f, 0x080c, 0x8562, 0x2009, 0x0014, 0x080c, 0xaeec,
-	0x00ce, 0x0000, 0x002e, 0x001e, 0x00de, 0x00ce, 0x0005, 0x2001,
-	0x1a02, 0x2004, 0x9005, 0x1db0, 0x00c6, 0x2061, 0x19e6, 0x6128,
-	0x9192, 0x0003, 0x1e08, 0x8108, 0x612a, 0x00ce, 0x080c, 0x8559,
-	0x080c, 0x5ee2, 0x2009, 0x1846, 0x2114, 0x8210, 0x220a, 0x0c10,
-	0x0096, 0x00c6, 0x00d6, 0x00e6, 0x0016, 0x0026, 0x080c, 0x856f,
-	0x2071, 0x19e6, 0x713c, 0x81ff, 0x0904, 0xa37e, 0x2061, 0x0100,
-	0x2069, 0x0140, 0x080c, 0x73a5, 0x1500, 0x0036, 0x2019, 0x0002,
-	0x080c, 0xa5b7, 0x003e, 0x713c, 0x2160, 0x080c, 0xea1f, 0x2009,
-	0x004a, 0x6220, 0x9296, 0x0009, 0x1130, 0x6114, 0x2148, 0xa87b,
-	0x0006, 0x2009, 0x004a, 0x080c, 0xaeec, 0x0066, 0x2031, 0x0001,
-	0x080c, 0x7455, 0x006e, 0x0804, 0xa37e, 0x080c, 0xa38a, 0x0904,
-	0xa37e, 0x6904, 0xd1f4, 0x0904, 0xa385, 0x080c, 0x2d01, 0x00c6,
-	0x703c, 0x9065, 0x090c, 0x0dd5, 0x6020, 0x00ce, 0x9086, 0x0006,
-	0x1528, 0x61c8, 0x60c4, 0x9105, 0x1508, 0x2009, 0x180c, 0x2104,
-	0xd0d4, 0x01e0, 0x6214, 0x9294, 0x1800, 0x1128, 0x6224, 0x9294,
-	0x0002, 0x1560, 0x0030, 0xc0d4, 0x200a, 0xd0cc, 0x0110, 0x080c,
-	0x2c54, 0x6014, 0x9084, 0xe7fd, 0x9085, 0x0010, 0x6016, 0x703c,
-	0x2060, 0x2009, 0x0049, 0x080c, 0xaeec, 0x00c0, 0x0036, 0x2019,
-	0x0001, 0x080c, 0xa5b7, 0x003e, 0x713c, 0x2160, 0x080c, 0xea1f,
-	0x2009, 0x004a, 0x6220, 0x9296, 0x0009, 0x1130, 0x6114, 0x2148,
-	0xa87b, 0x0006, 0x2009, 0x004a, 0x080c, 0xaeec, 0x002e, 0x001e,
-	0x00ee, 0x00de, 0x00ce, 0x009e, 0x0005, 0xd1ec, 0x1904, 0xa335,
-	0x0804, 0xa337, 0x00d6, 0x00c6, 0x0096, 0x703c, 0x9065, 0x090c,
-	0x0dd5, 0x2001, 0x1837, 0x2004, 0xd09c, 0x1904, 0xa416, 0x2001,
-	0x0306, 0x200c, 0x9184, 0x0030, 0x0904, 0xa416, 0x9184, 0x0048,
-	0x9086, 0x0008, 0x1904, 0xa416, 0x2001, 0x020b, 0x2004, 0xd0fc,
-	0x0904, 0xa416, 0xd08c, 0x0904, 0xa416, 0x2009, 0x1a7f, 0x2104,
-	0x8000, 0x0208, 0x200a, 0x2069, 0x0100, 0x6914, 0x918c, 0x0184,
-	0x918d, 0x0010, 0x6916, 0x69c8, 0x2011, 0x0020, 0x68c8, 0x9106,
-	0x1570, 0x8211, 0x1dd8, 0x2001, 0x0306, 0x2003, 0x4800, 0x2001,
-	0x009a, 0x2003, 0x0004, 0x2001, 0x1a65, 0x2003, 0x0000, 0x2001,
-	0x1a6e, 0x2003, 0x0000, 0x6a88, 0x698c, 0x2200, 0x9105, 0x1120,
-	0x2c10, 0x080c, 0x1baf, 0x0040, 0x6014, 0x2048, 0xaa3a, 0xa936,
-	0x6ac4, 0x69c8, 0xa946, 0xaa4a, 0x0126, 0x00c6, 0x2091, 0x2400,
-	0x002e, 0x080c, 0x1c48, 0x190c, 0x0dd5, 0x012e, 0x0090, 0x2009,
-	0x1a80, 0x2104, 0x8000, 0x0208, 0x200a, 0x69c8, 0x2011, 0x0020,
-	0x8211, 0x1df0, 0x68c8, 0x9106, 0x1dc0, 0x69c4, 0x68c8, 0x9105,
-	0x0160, 0x6824, 0xd08c, 0x0110, 0x6827, 0x0002, 0x7048, 0xc085,
-	0x704a, 0x0079, 0x7048, 0xc084, 0x704a, 0x2009, 0x07d0, 0x080c,
-	0x8567, 0x9006, 0x009e, 0x00ce, 0x00de, 0x0005, 0x9085, 0x0001,
-	0x0cc8, 0x0026, 0x00e6, 0x2071, 0x19e6, 0x7048, 0xd084, 0x01d8,
-	0x713c, 0x81ff, 0x01c0, 0x2071, 0x0100, 0x9188, 0x0008, 0x2114,
-	0x928e, 0x0006, 0x1138, 0x7014, 0x9084, 0x1984, 0x9085, 0x0012,
-	0x7016, 0x0048, 0x928e, 0x0009, 0x0db0, 0x7014, 0x9084, 0x1984,
-	0x9085, 0x0016, 0x7016, 0x00ee, 0x002e, 0x0005, 0x00b6, 0x00e6,
-	0x00d6, 0x00c6, 0x0066, 0x0056, 0x0046, 0x0006, 0x0126, 0x2091,
-	0x8000, 0x6010, 0x2058, 0xbca0, 0x2071, 0x19e6, 0x7018, 0x2058,
-	0x8bff, 0x0190, 0xb8a0, 0x9406, 0x0118, 0xb854, 0x2058, 0x0cc0,
-	0x6014, 0x0096, 0x2048, 0xac6c, 0xad70, 0xae78, 0x009e, 0x080c,
-	0x673a, 0x0110, 0x9085, 0x0001, 0x012e, 0x000e, 0x004e, 0x005e,
-	0x006e, 0x00ce, 0x00de, 0x00ee, 0x00be, 0x0005, 0x080c, 0x9c61,
-	0x7003, 0x1200, 0x7838, 0x7012, 0x783c, 0x7016, 0x00c6, 0x7820,
-	0x9086, 0x0004, 0x1148, 0x7810, 0x9005, 0x0130, 0x00b6, 0x2058,
-	0xb810, 0xb914, 0x00be, 0x0020, 0x2061, 0x1800, 0x607c, 0x6180,
-	0x9084, 0x00ff, 0x700a, 0x710e, 0x00ce, 0x60c3, 0x002c, 0x0804,
-	0xa248, 0x080c, 0x9c61, 0x7003, 0x0f00, 0x7808, 0xd09c, 0x0128,
-	0xb810, 0x9084, 0x00ff, 0x700a, 0xb814, 0x700e, 0x60c3, 0x0008,
-	0x0804, 0xa248, 0x0156, 0x080c, 0x9cac, 0x7003, 0x0200, 0x080c,
-	0x85c2, 0x20a9, 0x0006, 0x2011, 0xfff4, 0x2019, 0xfff5, 0x9ef0,
-	0x0002, 0x2305, 0x2072, 0x8e70, 0x2205, 0x2072, 0x8e70, 0x9398,
-	0x0002, 0x9290, 0x0002, 0x1f04, 0xa4b1, 0x60c3, 0x001c, 0x015e,
-	0x0804, 0xa248, 0x0016, 0x0026, 0x080c, 0x9c88, 0x080c, 0x9c9a,
-	0x9e80, 0x0004, 0x20e9, 0x0000, 0x20a0, 0x7814, 0x0096, 0x2048,
-	0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098,
-	0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x9192, 0x0010, 0x1250,
-	0x4003, 0x9080, 0x0004, 0x8003, 0x60c2, 0x080c, 0xa248, 0x002e,
-	0x001e, 0x0005, 0x20a9, 0x0010, 0x4003, 0x080c, 0xab17, 0x20a1,
-	0x0240, 0x22a8, 0x4003, 0x0c68, 0x080c, 0x9c61, 0x7003, 0x6200,
-	0x7808, 0x700e, 0x60c3, 0x0008, 0x0804, 0xa248, 0x0016, 0x0026,
-	0x080c, 0x9c61, 0x20e9, 0x0000, 0x20a1, 0x024c, 0x7814, 0x0096,
-	0x2048, 0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0023,
-	0x2098, 0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x4003, 0x8003,
-	0x60c2, 0x080c, 0xa248, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00c6,
-	0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x700c, 0x2060,
-	0x8cff, 0x0178, 0x080c, 0xcd50, 0x1110, 0x080c, 0xb824, 0x600c,
-	0x0006, 0x080c, 0xcfbc, 0x080c, 0xae71, 0x080c, 0xa693, 0x00ce,
-	0x0c78, 0x2c00, 0x700e, 0x700a, 0x012e, 0x000e, 0x00ce, 0x00ee,
-	0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066,
-	0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001, 0x180c, 0x200c,
-	0x918c, 0xe7ff, 0x2102, 0x2069, 0x0100, 0x2079, 0x0140, 0x2071,
-	0x19e6, 0x7024, 0x2060, 0x8cff, 0x01f8, 0x080c, 0xa274, 0x6ac0,
-	0x68c3, 0x0000, 0x080c, 0x8562, 0x00c6, 0x2061, 0x0100, 0x080c,
-	0xac68, 0x00ce, 0x20a9, 0x01f4, 0x0461, 0x2009, 0x0013, 0x080c,
-	0xaeec, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee,
-	0x00fe, 0x015e, 0x012e, 0x0005, 0x2001, 0x1800, 0x2004, 0x9096,
-	0x0001, 0x0d78, 0x9096, 0x0004, 0x0d60, 0x080c, 0x8562, 0x6814,
-	0x9084, 0x0001, 0x0110, 0x68a7, 0x95f5, 0x6817, 0x0008, 0x68c3,
-	0x0000, 0x2011, 0x5e8c, 0x080c, 0x84dc, 0x20a9, 0x01f4, 0x0009,
-	0x08c0, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004, 0x7804, 0x9084,
-	0x4000, 0x190c, 0x2d01, 0x0090, 0xd084, 0x0118, 0x6827, 0x0001,
-	0x0010, 0x1f04, 0xa599, 0x7804, 0x9084, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2cf1, 0x9006, 0x080c, 0x2cf1, 0x0005, 0x0126,
-	0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0026, 0x0016,
-	0x0006, 0x2091, 0x8000, 0x2001, 0x180c, 0x200c, 0x918c, 0xdbff,
-	0x2102, 0x2069, 0x0100, 0x2079, 0x0140, 0x2071, 0x19e6, 0x703c,
-	0x2060, 0x8cff, 0x0904, 0xa649, 0x9386, 0x0002, 0x1128, 0x6814,
-	0x9084, 0x0002, 0x0904, 0xa649, 0x68af, 0x95f5, 0x6817, 0x0010,
-	0x2009, 0x00fa, 0x8109, 0x1df0, 0x69c6, 0x68cb, 0x0008, 0x080c,
-	0x856f, 0x080c, 0x1ffc, 0x0046, 0x2009, 0x00a5, 0x080c, 0x0e51,
-	0x2021, 0x0169, 0x2404, 0x9084, 0x000f, 0x9086, 0x0004, 0x11f8,
-	0x68af, 0x95f5, 0x68c6, 0x68cb, 0x0008, 0x00e6, 0x00f6, 0x2079,
-	0x0090, 0x2071, 0x1a65, 0x6814, 0x9084, 0x1984, 0x9085, 0x0012,
-	0x6816, 0x782b, 0x0008, 0x7003, 0x0000, 0x00fe, 0x00ee, 0x9386,
-	0x0002, 0x1128, 0x7884, 0x9005, 0x1110, 0x7887, 0x0001, 0x2001,
-	0x1980, 0x200c, 0x080c, 0x0e51, 0x004e, 0x20a9, 0x03e8, 0x6824,
-	0xd094, 0x0140, 0x6827, 0x0004, 0x7804, 0x9084, 0x4000, 0x190c,
-	0x2d01, 0x0090, 0xd08c, 0x0118, 0x6827, 0x0002, 0x0010, 0x1f04,
-	0xa61f, 0x7804, 0x9084, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c,
-	0x2cf1, 0x9006, 0x080c, 0x2cf1, 0x6827, 0x4000, 0x6824, 0x83ff,
-	0x1140, 0x2009, 0x0049, 0x6020, 0x9086, 0x0009, 0x0110, 0x080c,
-	0xaeec, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee,
-	0x00fe, 0x015e, 0x012e, 0x0005, 0x00d6, 0x0126, 0x2091, 0x8000,
-	0x2069, 0x19e6, 0x6a06, 0x012e, 0x00de, 0x0005, 0x00d6, 0x0126,
-	0x2091, 0x8000, 0x2069, 0x19e6, 0x6a32, 0x012e, 0x00de, 0x0005,
-	0x080c, 0x9e1a, 0x7854, 0x7032, 0x7042, 0x7047, 0x1000, 0x00f8,
-	0x080c, 0x9e1a, 0x7854, 0x7032, 0x7042, 0x7047, 0x4000, 0x00b8,
-	0x080c, 0x9e1a, 0x7854, 0x7032, 0x7042, 0x7047, 0x2000, 0x0078,
-	0x080c, 0x9e1a, 0x7854, 0x7032, 0x7042, 0x7047, 0x0400, 0x0038,
-	0x080c, 0x9e1a, 0x7854, 0x7032, 0x7042, 0x7047, 0x0200, 0x60c3,
-	0x0020, 0x0804, 0xa248, 0x00e6, 0x2071, 0x19e6, 0x7020, 0x9005,
-	0x0110, 0x8001, 0x7022, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00d6,
-	0x00c6, 0x0076, 0x0066, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x19e6, 0x7614, 0x2660, 0x2678, 0x2039, 0x0001, 0x87ff, 0x0904,
-	0xa738, 0x8cff, 0x0904, 0xa738, 0x6020, 0x9086, 0x0006, 0x1904,
-	0xa733, 0x88ff, 0x0138, 0x2800, 0x9c06, 0x1904, 0xa733, 0x2039,
-	0x0000, 0x0050, 0x6010, 0x9b06, 0x1904, 0xa733, 0x85ff, 0x0120,
-	0x6054, 0x9106, 0x1904, 0xa733, 0x7024, 0x9c06, 0x15b0, 0x2069,
-	0x0100, 0x68c0, 0x9005, 0x1160, 0x6824, 0xd084, 0x0148, 0x6827,
-	0x0001, 0x080c, 0x8562, 0x080c, 0xa7bd, 0x7027, 0x0000, 0x0428,
-	0x080c, 0x8562, 0x6820, 0xd0b4, 0x0110, 0x68a7, 0x95f5, 0x6817,
-	0x0008, 0x68c3, 0x0000, 0x080c, 0xa7bd, 0x7027, 0x0000, 0x0036,
-	0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100,
-	0x080c, 0x2cf1, 0x9006, 0x080c, 0x2cf1, 0x2069, 0x0100, 0x6824,
-	0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x7014, 0x9c36, 0x1110,
-	0x660c, 0x7616, 0x7010, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118,
-	0x2f00, 0x7012, 0x0010, 0x7013, 0x0000, 0x660c, 0x0066, 0x2c00,
-	0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x89ff, 0x1168, 0x600f,
-	0x0000, 0x6014, 0x0096, 0x2048, 0x080c, 0xcb48, 0x0110, 0x080c,
-	0xe572, 0x009e, 0x080c, 0xaea2, 0x080c, 0xa693, 0x88ff, 0x1190,
-	0x00ce, 0x0804, 0xa6ae, 0x2c78, 0x600c, 0x2060, 0x0804, 0xa6ae,
-	0x9006, 0x012e, 0x000e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee,
-	0x00fe, 0x0005, 0x601b, 0x0000, 0x00ce, 0x98c5, 0x0001, 0x0c88,
-	0x00f6, 0x00e6, 0x00d6, 0x0096, 0x00c6, 0x0066, 0x0026, 0x0006,
-	0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7638, 0x2660, 0x2678,
-	0x8cff, 0x0904, 0xa7ac, 0x6020, 0x9086, 0x0006, 0x1904, 0xa7a7,
-	0x87ff, 0x0128, 0x2700, 0x9c06, 0x1904, 0xa7a7, 0x0040, 0x6010,
-	0x9b06, 0x15e8, 0x85ff, 0x0118, 0x6054, 0x9106, 0x15c0, 0x703c,
-	0x9c06, 0x1168, 0x0036, 0x2019, 0x0001, 0x080c, 0xa5b7, 0x7033,
-	0x0000, 0x9006, 0x703e, 0x7042, 0x7046, 0x704a, 0x003e, 0x7038,
-	0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36, 0x1140, 0x2c00,
-	0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000, 0x660c,
-	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
-	0x0000, 0x6014, 0x2048, 0x080c, 0xcb48, 0x0110, 0x080c, 0xe572,
-	0x080c, 0xaea2, 0x87ff, 0x1198, 0x00ce, 0x0804, 0xa758, 0x2c78,
-	0x600c, 0x2060, 0x0804, 0xa758, 0x9006, 0x012e, 0x000e, 0x002e,
-	0x006e, 0x00ce, 0x009e, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b,
-	0x0000, 0x00ce, 0x97bd, 0x0001, 0x0c80, 0x00e6, 0x2071, 0x19e6,
-	0x2001, 0x1800, 0x2004, 0x9086, 0x0002, 0x1118, 0x7007, 0x0005,
-	0x0010, 0x7007, 0x0000, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00c6,
-	0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6,
-	0x2c10, 0x7638, 0x2660, 0x2678, 0x8cff, 0x0540, 0x2200, 0x9c06,
-	0x1508, 0x7038, 0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36,
+	0xb86c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0x080c, 0xaaff,
+	0x2009, 0x07d0, 0x60c4, 0x9084, 0xfff0, 0x9005, 0x0110, 0x2009,
+	0x1b58, 0x080c, 0x8584, 0x003e, 0x004e, 0x005e, 0x00ce, 0x00de,
+	0x00ee, 0x009e, 0x00be, 0x0005, 0x7804, 0x9086, 0x0040, 0x0904,
+	0xa1fc, 0x9185, 0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073,
+	0x0809, 0x6077, 0x0008, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xb88c,
+	0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000,
+	0x2f00, 0x6082, 0x7808, 0x6086, 0x7814, 0x2048, 0xa838, 0x608a,
+	0xa834, 0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce,
+	0xbac0, 0x629e, 0x080c, 0xaaff, 0x2009, 0x07d0, 0x60c4, 0x9084,
+	0xfff0, 0x9005, 0x0110, 0x2009, 0x1b58, 0x080c, 0x8584, 0x003e,
+	0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x009e, 0x00be, 0x0005,
+	0x7814, 0x2048, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x0904,
+	0xa218, 0x9185, 0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073,
+	0x0880, 0x6077, 0x0008, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e,
+	0x8007, 0x607a, 0x7838, 0x607e, 0x2f00, 0x6086, 0x7808, 0x6082,
+	0xa890, 0x608a, 0xa88c, 0x608e, 0xa8b0, 0x60c6, 0xa8ac, 0x60ca,
+	0xa8ac, 0x7930, 0x9108, 0x7932, 0xa8b0, 0x792c, 0x9109, 0x792e,
+	0xb86c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xbac0, 0x629e,
+	0x080c, 0xaadc, 0x0804, 0xa1ac, 0xb8cc, 0xd084, 0x0148, 0xb88c,
+	0x7814, 0x2048, 0xb88c, 0x7846, 0xa836, 0x2900, 0xa83a, 0xb04a,
+	0x9185, 0x0600, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073, 0x0829,
+	0x6077, 0x0000, 0x60af, 0x9575, 0x60d7, 0x0000, 0x0804, 0xa18f,
+	0x9185, 0x0700, 0x6062, 0x6266, 0x636a, 0x646e, 0x7824, 0xd0cc,
+	0x7826, 0x0118, 0x6073, 0x0889, 0x0010, 0x6073, 0x0898, 0x6077,
+	0x0000, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a,
+	0x607f, 0x0000, 0x2f00, 0x6086, 0x7808, 0x6082, 0xa838, 0x608a,
+	0xa834, 0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce,
+	0x60af, 0x95d5, 0x60d7, 0x0000, 0xbac0, 0x629e, 0x7824, 0xd0cc,
+	0x0120, 0x080c, 0xaaff, 0x0804, 0xa1ac, 0x080c, 0xaadc, 0x0804,
+	0xa1ac, 0x7a10, 0x00b6, 0x2258, 0xba8c, 0x8210, 0x9294, 0x00ff,
+	0xba8e, 0x00be, 0x8217, 0x0005, 0x00d6, 0x2069, 0x19e6, 0x6843,
+	0x0001, 0x00de, 0x0005, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x00f1,
+	0x080c, 0x8576, 0x0005, 0x0016, 0x2001, 0x180c, 0x200c, 0x9184,
+	0x0600, 0x9086, 0x0600, 0x0128, 0x0089, 0x080c, 0x8576, 0x001e,
+	0x0005, 0xc1e5, 0x2001, 0x180c, 0x2102, 0x2001, 0x19e7, 0x2003,
+	0x0000, 0x2001, 0x19ef, 0x2003, 0x0000, 0x0c88, 0x0006, 0x6014,
+	0x9084, 0x1804, 0x9085, 0x0009, 0x6016, 0x000e, 0x0005, 0x0016,
+	0x00c6, 0x0006, 0x2061, 0x0100, 0x61a4, 0x60a7, 0x95f5, 0x6014,
+	0x9084, 0x1804, 0x9085, 0x0008, 0x6016, 0x000e, 0xa001, 0xa001,
+	0xa001, 0x61a6, 0x00ce, 0x001e, 0x0005, 0x00c6, 0x00d6, 0x0016,
+	0x0026, 0x2061, 0x0100, 0x2069, 0x0140, 0x080c, 0x73b3, 0x11c0,
+	0x2001, 0x1a02, 0x2004, 0x9005, 0x15d0, 0x080c, 0x7463, 0x1160,
+	0x2061, 0x0100, 0x6020, 0xd0b4, 0x1120, 0x6024, 0xd084, 0x090c,
+	0x0dd5, 0x080c, 0x8576, 0x0458, 0x00c6, 0x2061, 0x19e6, 0x00c8,
+	0x6904, 0x9194, 0x4000, 0x0540, 0x0811, 0x080c, 0x2d0c, 0x00c6,
+	0x2061, 0x19e6, 0x6128, 0x9192, 0x0008, 0x1258, 0x8108, 0x612a,
+	0x6124, 0x00ce, 0x81ff, 0x0198, 0x080c, 0x8576, 0x080c, 0xa286,
+	0x0070, 0x6124, 0x91e5, 0x0000, 0x0140, 0x080c, 0xea39, 0x080c,
+	0x857f, 0x2009, 0x0014, 0x080c, 0xaeda, 0x00ce, 0x0000, 0x002e,
+	0x001e, 0x00de, 0x00ce, 0x0005, 0x2001, 0x1a02, 0x2004, 0x9005,
+	0x1db0, 0x00c6, 0x2061, 0x19e6, 0x6128, 0x9192, 0x0003, 0x1e08,
+	0x8108, 0x612a, 0x00ce, 0x080c, 0x8576, 0x080c, 0x5eec, 0x2009,
+	0x1846, 0x2114, 0x8210, 0x220a, 0x0c10, 0x0096, 0x00c6, 0x00d6,
+	0x00e6, 0x0016, 0x0026, 0x080c, 0x858c, 0x2071, 0x19e6, 0x713c,
+	0x81ff, 0x0904, 0xa38f, 0x2061, 0x0100, 0x2069, 0x0140, 0x080c,
+	0x73b3, 0x11e0, 0x0036, 0x2019, 0x0002, 0x080c, 0xa5c8, 0x003e,
+	0x713c, 0x2160, 0x080c, 0xea39, 0x2009, 0x004a, 0x6220, 0x9296,
+	0x0009, 0x1130, 0x6114, 0x2148, 0xa87b, 0x0006, 0x2009, 0x004a,
+	0x080c, 0xaeda, 0x080c, 0x7463, 0x0804, 0xa38f, 0x080c, 0xa39b,
+	0x0904, 0xa38f, 0x6904, 0xd1f4, 0x0904, 0xa396, 0x080c, 0x2d0c,
+	0x00c6, 0x703c, 0x9065, 0x090c, 0x0dd5, 0x6020, 0x00ce, 0x9086,
+	0x0006, 0x1528, 0x61c8, 0x60c4, 0x9105, 0x1508, 0x2009, 0x180c,
+	0x2104, 0xd0d4, 0x01e0, 0x6214, 0x9294, 0x1800, 0x1128, 0x6224,
+	0x9294, 0x0002, 0x1560, 0x0030, 0xc0d4, 0x200a, 0xd0cc, 0x0110,
+	0x080c, 0x2c5f, 0x6014, 0x9084, 0xe7fd, 0x9085, 0x0010, 0x6016,
+	0x703c, 0x2060, 0x2009, 0x0049, 0x080c, 0xaeda, 0x00c0, 0x0036,
+	0x2019, 0x0001, 0x080c, 0xa5c8, 0x003e, 0x713c, 0x2160, 0x080c,
+	0xea39, 0x2009, 0x004a, 0x6220, 0x9296, 0x0009, 0x1130, 0x6114,
+	0x2148, 0xa87b, 0x0006, 0x2009, 0x004a, 0x080c, 0xaeda, 0x002e,
+	0x001e, 0x00ee, 0x00de, 0x00ce, 0x009e, 0x0005, 0xd1ec, 0x1904,
+	0xa346, 0x0804, 0xa348, 0x00d6, 0x00c6, 0x0096, 0x703c, 0x9065,
+	0x090c, 0x0dd5, 0x2001, 0x1837, 0x2004, 0xd09c, 0x1904, 0xa427,
+	0x2001, 0x0306, 0x200c, 0x9184, 0x0030, 0x0904, 0xa427, 0x9184,
+	0x0048, 0x9086, 0x0008, 0x1904, 0xa427, 0x2001, 0x020b, 0x2004,
+	0xd0fc, 0x0904, 0xa427, 0xd08c, 0x0904, 0xa427, 0x2009, 0x1a7f,
+	0x2104, 0x8000, 0x0208, 0x200a, 0x2069, 0x0100, 0x6914, 0x918c,
+	0x0184, 0x918d, 0x0010, 0x6916, 0x69c8, 0x2011, 0x0020, 0x68c8,
+	0x9106, 0x1570, 0x8211, 0x1dd8, 0x2001, 0x0306, 0x2003, 0x4800,
+	0x2001, 0x009a, 0x2003, 0x0004, 0x2001, 0x1a65, 0x2003, 0x0000,
+	0x2001, 0x1a6e, 0x2003, 0x0000, 0x6a88, 0x698c, 0x2200, 0x9105,
+	0x1120, 0x2c10, 0x080c, 0x1bba, 0x0040, 0x6014, 0x2048, 0xaa3a,
+	0xa936, 0x6ac4, 0x69c8, 0xa946, 0xaa4a, 0x0126, 0x00c6, 0x2091,
+	0x2400, 0x002e, 0x080c, 0x1c53, 0x190c, 0x0dd5, 0x012e, 0x0090,
+	0x2009, 0x1a80, 0x2104, 0x8000, 0x0208, 0x200a, 0x69c8, 0x2011,
+	0x0020, 0x8211, 0x1df0, 0x68c8, 0x9106, 0x1dc0, 0x69c4, 0x68c8,
+	0x9105, 0x0160, 0x6824, 0xd08c, 0x0110, 0x6827, 0x0002, 0x7048,
+	0xc085, 0x704a, 0x0079, 0x7048, 0xc084, 0x704a, 0x2009, 0x07d0,
+	0x080c, 0x8584, 0x9006, 0x009e, 0x00ce, 0x00de, 0x0005, 0x9085,
+	0x0001, 0x0cc8, 0x0026, 0x00e6, 0x2071, 0x19e6, 0x7048, 0xd084,
+	0x01d8, 0x713c, 0x81ff, 0x01c0, 0x2071, 0x0100, 0x9188, 0x0008,
+	0x2114, 0x928e, 0x0006, 0x1138, 0x7014, 0x9084, 0x1984, 0x9085,
+	0x0012, 0x7016, 0x0048, 0x928e, 0x0009, 0x0db0, 0x7014, 0x9084,
+	0x1984, 0x9085, 0x0016, 0x7016, 0x00ee, 0x002e, 0x0005, 0x00b6,
+	0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0056, 0x0046, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x6010, 0x2058, 0xbca0, 0x2071, 0x19e6, 0x7018,
+	0x2058, 0x8bff, 0x0190, 0xb8a0, 0x9406, 0x0118, 0xb854, 0x2058,
+	0x0cc0, 0x6014, 0x0096, 0x2048, 0xac6c, 0xad70, 0xae78, 0x009e,
+	0x080c, 0x6748, 0x0110, 0x9085, 0x0001, 0x012e, 0x000e, 0x004e,
+	0x005e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00be, 0x0005, 0x080c,
+	0x9c7c, 0x7003, 0x1200, 0x7838, 0x7012, 0x783c, 0x7016, 0x00c6,
+	0x7820, 0x9086, 0x0004, 0x1148, 0x7810, 0x9005, 0x0130, 0x00b6,
+	0x2058, 0xb810, 0xb914, 0x00be, 0x0020, 0x2061, 0x1800, 0x607c,
+	0x6180, 0x9084, 0x00ff, 0x700a, 0x710e, 0x00ce, 0x60c3, 0x002c,
+	0x0804, 0xa263, 0x080c, 0x9c7c, 0x7003, 0x0f00, 0x7808, 0xd09c,
+	0x0128, 0xb810, 0x9084, 0x00ff, 0x700a, 0xb814, 0x700e, 0x60c3,
+	0x0008, 0x0804, 0xa263, 0x0156, 0x080c, 0x9cc7, 0x7003, 0x0200,
+	0x080c, 0x85df, 0x20a9, 0x0006, 0x2011, 0xffec, 0x2019, 0xffed,
+	0x9ef0, 0x0002, 0x2305, 0x2072, 0x8e70, 0x2205, 0x2072, 0x8e70,
+	0x9398, 0x0002, 0x9290, 0x0002, 0x1f04, 0xa4c2, 0x60c3, 0x001c,
+	0x015e, 0x0804, 0xa263, 0x0016, 0x0026, 0x080c, 0x9ca3, 0x080c,
+	0x9cb5, 0x9e80, 0x0004, 0x20e9, 0x0000, 0x20a0, 0x7814, 0x0096,
+	0x2048, 0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021,
+	0x2098, 0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x9192, 0x0010,
+	0x1250, 0x4003, 0x9080, 0x0004, 0x8003, 0x60c2, 0x080c, 0xa263,
+	0x002e, 0x001e, 0x0005, 0x20a9, 0x0010, 0x4003, 0x080c, 0xab05,
+	0x20a1, 0x0240, 0x22a8, 0x4003, 0x0c68, 0x080c, 0x9c7c, 0x7003,
+	0x6200, 0x7808, 0x700e, 0x60c3, 0x0008, 0x0804, 0xa263, 0x0016,
+	0x0026, 0x080c, 0x9c7c, 0x20e9, 0x0000, 0x20a1, 0x024c, 0x7814,
+	0x0096, 0x2048, 0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x0023, 0x2098, 0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x4003,
+	0x8003, 0x60c2, 0x080c, 0xa263, 0x002e, 0x001e, 0x0005, 0x00e6,
+	0x00c6, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x700c,
+	0x2060, 0x8cff, 0x0178, 0x080c, 0xcd60, 0x1110, 0x080c, 0xb821,
+	0x600c, 0x0006, 0x080c, 0xcfcc, 0x080c, 0xae5f, 0x080c, 0xa67d,
+	0x00ce, 0x0c78, 0x2c00, 0x700e, 0x700a, 0x012e, 0x000e, 0x00ce,
+	0x00ee, 0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6,
+	0x0066, 0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001, 0x180c,
+	0x200c, 0x918c, 0xe7ff, 0x2102, 0x2069, 0x0100, 0x2079, 0x0140,
+	0x2071, 0x19e6, 0x7024, 0x2060, 0x8cff, 0x01f8, 0x080c, 0xa28f,
+	0x6ac0, 0x68c3, 0x0000, 0x080c, 0x857f, 0x00c6, 0x2061, 0x0100,
+	0x080c, 0xac56, 0x00ce, 0x20a9, 0x01f4, 0x0461, 0x2009, 0x0013,
+	0x080c, 0xaeda, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce, 0x00de,
+	0x00ee, 0x00fe, 0x015e, 0x012e, 0x0005, 0x2001, 0x1800, 0x2004,
+	0x9096, 0x0001, 0x0d78, 0x9096, 0x0004, 0x0d60, 0x080c, 0x857f,
+	0x6814, 0x9084, 0x0001, 0x0110, 0x68a7, 0x95f5, 0x6817, 0x0008,
+	0x68c3, 0x0000, 0x2011, 0x5e96, 0x080c, 0x84f9, 0x20a9, 0x01f4,
+	0x0009, 0x08c0, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004, 0x7804,
+	0x9084, 0x4000, 0x190c, 0x2d0c, 0x0090, 0xd084, 0x0118, 0x6827,
+	0x0001, 0x0010, 0x1f04, 0xa5aa, 0x7804, 0x9084, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2cfc, 0x9006, 0x080c, 0x2cfc, 0x0005,
+	0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0026,
+	0x0016, 0x0006, 0x2091, 0x8000, 0x2001, 0x180c, 0x200c, 0x918c,
+	0xdbff, 0x2102, 0x2069, 0x0100, 0x2079, 0x0140, 0x2071, 0x19e6,
+	0x703c, 0x2060, 0x8cff, 0x0904, 0xa633, 0x9386, 0x0002, 0x1128,
+	0x6814, 0x9084, 0x0002, 0x0904, 0xa633, 0x68af, 0x95f5, 0x6817,
+	0x0010, 0x2009, 0x00fa, 0x8109, 0x1df0, 0x69c6, 0x68cb, 0x0008,
+	0x080c, 0x858c, 0x080c, 0x2007, 0x2001, 0x0032, 0x6920, 0xd1bc,
+	0x0130, 0x8001, 0x1dd8, 0x692c, 0x918d, 0x0008, 0x692e, 0x20a9,
+	0x03e8, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004, 0x7804, 0x9084,
+	0x4000, 0x190c, 0x2d0c, 0x0090, 0xd08c, 0x0118, 0x6827, 0x0002,
+	0x0010, 0x1f04, 0xa609, 0x7804, 0x9084, 0x1000, 0x0138, 0x2001,
+	0x0100, 0x080c, 0x2cfc, 0x9006, 0x080c, 0x2cfc, 0x6827, 0x4000,
+	0x6824, 0x83ff, 0x1140, 0x2009, 0x0049, 0x6020, 0x9086, 0x0009,
+	0x0110, 0x080c, 0xaeda, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce,
+	0x00de, 0x00ee, 0x00fe, 0x015e, 0x012e, 0x0005, 0x00d6, 0x0126,
+	0x2091, 0x8000, 0x2069, 0x19e6, 0x6a06, 0x012e, 0x00de, 0x0005,
+	0x00d6, 0x0126, 0x2091, 0x8000, 0x2069, 0x19e6, 0x6a32, 0x012e,
+	0x00de, 0x0005, 0x080c, 0x9e35, 0x7854, 0x7032, 0x7042, 0x7047,
+	0x1000, 0x00f8, 0x080c, 0x9e35, 0x7854, 0x7032, 0x7042, 0x7047,
+	0x4000, 0x00b8, 0x080c, 0x9e35, 0x7854, 0x7032, 0x7042, 0x7047,
+	0x2000, 0x0078, 0x080c, 0x9e35, 0x7854, 0x7032, 0x7042, 0x7047,
+	0x0400, 0x0038, 0x080c, 0x9e35, 0x7854, 0x7032, 0x7042, 0x7047,
+	0x0200, 0x60c3, 0x0020, 0x0804, 0xa263, 0x00e6, 0x2071, 0x19e6,
+	0x7020, 0x9005, 0x0110, 0x8001, 0x7022, 0x00ee, 0x0005, 0x00f6,
+	0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066, 0x0006, 0x0126, 0x2091,
+	0x8000, 0x2071, 0x19e6, 0x7614, 0x2660, 0x2678, 0x2039, 0x0001,
+	0x87ff, 0x0904, 0xa722, 0x8cff, 0x0904, 0xa722, 0x6020, 0x9086,
+	0x0006, 0x1904, 0xa71d, 0x88ff, 0x0138, 0x2800, 0x9c06, 0x1904,
+	0xa71d, 0x2039, 0x0000, 0x0050, 0x6010, 0x9b06, 0x1904, 0xa71d,
+	0x85ff, 0x0120, 0x6054, 0x9106, 0x1904, 0xa71d, 0x7024, 0x9c06,
+	0x15b0, 0x2069, 0x0100, 0x68c0, 0x9005, 0x1160, 0x6824, 0xd084,
+	0x0148, 0x6827, 0x0001, 0x080c, 0x857f, 0x080c, 0xa7a7, 0x7027,
+	0x0000, 0x0428, 0x080c, 0x857f, 0x6820, 0xd0b4, 0x0110, 0x68a7,
+	0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000, 0x080c, 0xa7a7, 0x7027,
+	0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2cfc, 0x9006, 0x080c, 0x2cfc, 0x2069,
+	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x7014,
+	0x9c36, 0x1110, 0x660c, 0x7616, 0x7010, 0x9c36, 0x1140, 0x2c00,
+	0x9f36, 0x0118, 0x2f00, 0x7012, 0x0010, 0x7013, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x89ff,
+	0x1168, 0x600f, 0x0000, 0x6014, 0x0096, 0x2048, 0x080c, 0xcb58,
+	0x0110, 0x080c, 0xe58c, 0x009e, 0x080c, 0xae90, 0x080c, 0xa67d,
+	0x88ff, 0x1190, 0x00ce, 0x0804, 0xa698, 0x2c78, 0x600c, 0x2060,
+	0x0804, 0xa698, 0x9006, 0x012e, 0x000e, 0x006e, 0x007e, 0x00ce,
+	0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b, 0x0000, 0x00ce, 0x98c5,
+	0x0001, 0x0c88, 0x00f6, 0x00e6, 0x00d6, 0x0096, 0x00c6, 0x0066,
+	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7638,
+	0x2660, 0x2678, 0x8cff, 0x0904, 0xa796, 0x6020, 0x9086, 0x0006,
+	0x1904, 0xa791, 0x87ff, 0x0128, 0x2700, 0x9c06, 0x1904, 0xa791,
+	0x0040, 0x6010, 0x9b06, 0x15e8, 0x85ff, 0x0118, 0x6054, 0x9106,
+	0x15c0, 0x703c, 0x9c06, 0x1168, 0x0036, 0x2019, 0x0001, 0x080c,
+	0xa5c8, 0x7033, 0x0000, 0x9006, 0x703e, 0x7042, 0x7046, 0x704a,
+	0x003e, 0x7038, 0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36,
 	0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037,
-	0x0000, 0x660c, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678,
-	0x600f, 0x0000, 0x6004, 0x9086, 0x0040, 0x090c, 0x957b, 0x9085,
-	0x0001, 0x0020, 0x2c78, 0x600c, 0x2060, 0x08b0, 0x012e, 0x000e,
-	0x002e, 0x006e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0096, 0x00f6,
-	0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091,
-	0x8000, 0x2071, 0x19e6, 0x760c, 0x2660, 0x2678, 0x8cff, 0x0904,
-	0xa8a3, 0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x1904,
-	0xa89e, 0x7024, 0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0, 0x9005,
-	0x0904, 0xa875, 0x080c, 0xa274, 0x68c3, 0x0000, 0x080c, 0xa7bd,
-	0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000,
-	0x0138, 0x2001, 0x0100, 0x080c, 0x2cf1, 0x9006, 0x080c, 0x2cf1,
-	0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e,
-	0x700c, 0x9c36, 0x1110, 0x660c, 0x760e, 0x7008, 0x9c36, 0x1140,
-	0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700a, 0x0010, 0x700b, 0x0000,
-	0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678,
-	0x600f, 0x0000, 0x080c, 0xcd3f, 0x1180, 0x080c, 0x31ea, 0x080c,
-	0xcd50, 0x1518, 0x080c, 0xb824, 0x0400, 0x080c, 0xa7bd, 0x6824,
-	0xd084, 0x09b0, 0x6827, 0x0001, 0x0898, 0x080c, 0xcd50, 0x1118,
-	0x080c, 0xb824, 0x0090, 0x6014, 0x2048, 0x080c, 0xcb48, 0x0168,
-	0x6020, 0x9086, 0x0003, 0x1508, 0xa867, 0x0103, 0xab7a, 0xa877,
-	0x0000, 0x080c, 0x6c7a, 0x080c, 0xcd33, 0x080c, 0xcfbc, 0x080c,
-	0xaea2, 0x080c, 0xa693, 0x00ce, 0x0804, 0xa81e, 0x2c78, 0x600c,
-	0x2060, 0x0804, 0xa81e, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce,
-	0x00de, 0x00ee, 0x00fe, 0x009e, 0x0005, 0x6020, 0x9086, 0x0006,
-	0x1d20, 0x080c, 0xe572, 0x0c08, 0x00d6, 0x080c, 0x9cac, 0x7003,
-	0x0200, 0x7007, 0x0014, 0x60c3, 0x0014, 0x20e1, 0x0001, 0x2099,
-	0x1988, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x20a9, 0x0004, 0x4003,
-	0x7023, 0x0004, 0x7027, 0x7878, 0x080c, 0xa248, 0x00de, 0x0005,
-	0x080c, 0x9cac, 0x700b, 0x0800, 0x7814, 0x9084, 0xff00, 0x700e,
-	0x7814, 0x9084, 0x00ff, 0x7022, 0x782c, 0x7026, 0x7858, 0x9084,
-	0x00ff, 0x9085, 0x0200, 0x7002, 0x7858, 0x9084, 0xff00, 0x8007,
-	0x7006, 0x60c2, 0x0804, 0xa248, 0x00b6, 0x00d6, 0x0016, 0x00d6,
-	0x2f68, 0x2009, 0x0035, 0x080c, 0xd1c2, 0x00de, 0x1904, 0xa951,
-	0x080c, 0x9c61, 0x7003, 0x1300, 0x782c, 0x080c, 0xaa53, 0x2068,
-	0x6820, 0x9086, 0x0003, 0x0560, 0x7810, 0x2058, 0xbaa0, 0x080c,
-	0xaddb, 0x11d8, 0x9286, 0x007e, 0x1128, 0x700b, 0x00ff, 0x700f,
-	0xfffe, 0x0498, 0x9286, 0x007f, 0x1128, 0x700b, 0x00ff, 0x700f,
-	0xfffd, 0x0458, 0x9284, 0xff80, 0x0180, 0x9286, 0x0080, 0x1128,
-	0x700b, 0x00ff, 0x700f, 0xfffc, 0x0400, 0x92d8, 0x1000, 0x2b5c,
-	0xb810, 0x700a, 0xb814, 0x700e, 0x00c0, 0x6098, 0x700e, 0x00a8,
-	0x080c, 0xaddb, 0x1130, 0x7810, 0x2058, 0xb8a0, 0x9082, 0x007e,
-	0x0250, 0x00d6, 0x2069, 0x181f, 0x2d04, 0x700a, 0x8d68, 0x2d04,
-	0x700e, 0x00de, 0x0010, 0x6034, 0x700e, 0x7838, 0x7012, 0x783c,
-	0x7016, 0x60c3, 0x000c, 0x001e, 0x00de, 0x080c, 0xa248, 0x00be,
-	0x0005, 0x781b, 0x0001, 0x7803, 0x0006, 0x001e, 0x00de, 0x00be,
-	0x0005, 0x792c, 0x9180, 0x0008, 0x200c, 0x9186, 0x0006, 0x01c0,
-	0x9186, 0x0003, 0x0904, 0xa9cb, 0x9186, 0x0005, 0x0904, 0xa9b4,
-	0x9186, 0x0004, 0x05d8, 0x9186, 0x0008, 0x0904, 0xa9bc, 0x7807,
-	0x0037, 0x782f, 0x0003, 0x7817, 0x1700, 0x080c, 0xaa30, 0x0005,
-	0x080c, 0xa9f1, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000,
-	0x6800, 0x0002, 0xa995, 0xa9a0, 0xa997, 0xa9a0, 0xa99c, 0xa995,
-	0xa995, 0xa9a0, 0xa9a0, 0xa9a0, 0xa9a0, 0xa995, 0xa995, 0xa995,
-	0xa995, 0xa995, 0xa9a0, 0xa995, 0xa9a0, 0x080c, 0x0dd5, 0x6824,
-	0xd0e4, 0x0110, 0xd0cc, 0x0110, 0x900e, 0x0010, 0x2009, 0x2000,
-	0x682c, 0x7022, 0x6830, 0x7026, 0x0804, 0xa9ea, 0x080c, 0xa9f1,
-	0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x6a00, 0x9286,
-	0x0002, 0x1108, 0x900e, 0x04b0, 0x04e1, 0x00d6, 0x0026, 0x792c,
-	0x2168, 0x2009, 0x4000, 0x0470, 0x04a1, 0x00d6, 0x0026, 0x792c,
-	0x2168, 0x2009, 0x4000, 0x9286, 0x0005, 0x0118, 0x9286, 0x0002,
-	0x1108, 0x900e, 0x00f8, 0x0429, 0x00d6, 0x0026, 0x792c, 0x2168,
-	0x6814, 0x0096, 0x2048, 0xa9ac, 0xa834, 0x9112, 0xa9b0, 0xa838,
-	0x009e, 0x9103, 0x7022, 0x7226, 0x792c, 0x9180, 0x0000, 0x2004,
-	0x908e, 0x0002, 0x0130, 0x908e, 0x0004, 0x0118, 0x2009, 0x4000,
-	0x0008, 0x900e, 0x712a, 0x60c3, 0x0018, 0x002e, 0x00de, 0x0804,
-	0xa248, 0x00b6, 0x0036, 0x0046, 0x0056, 0x0066, 0x080c, 0x9cac,
-	0x9006, 0x7003, 0x0200, 0x7938, 0x710a, 0x793c, 0x710e, 0x7810,
-	0x2058, 0xb8a0, 0x080c, 0xaddb, 0x1118, 0x9092, 0x007e, 0x0268,
-	0x00d6, 0x2069, 0x181f, 0x2d2c, 0x8d68, 0x2d34, 0x90d8, 0x1000,
-	0x2b5c, 0xbb10, 0xbc14, 0x00de, 0x0028, 0x901e, 0x6498, 0x2029,
-	0x0000, 0x6634, 0x782c, 0x9080, 0x0008, 0x2004, 0x9086, 0x0003,
-	0x1128, 0x7512, 0x7616, 0x731a, 0x741e, 0x0020, 0x7312, 0x7416,
-	0x751a, 0x761e, 0x006e, 0x005e, 0x004e, 0x003e, 0x00be, 0x0005,
-	0x080c, 0x9cac, 0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e,
-	0x700e, 0x60c3, 0x0008, 0x0804, 0xa248, 0x080c, 0x9c58, 0x7003,
-	0x1400, 0x7838, 0x700a, 0x0079, 0x783c, 0x700e, 0x782c, 0x7012,
-	0x7830, 0x7016, 0x7834, 0x9084, 0x00ff, 0x8007, 0x701a, 0x60c3,
-	0x0010, 0x0804, 0xa248, 0x00e6, 0x2071, 0x0240, 0x0006, 0x00f6,
-	0x2078, 0x7810, 0x00b6, 0x2058, 0xb8cc, 0xd084, 0x0120, 0x7848,
-	0x702a, 0x7844, 0x702e, 0x00be, 0x00fe, 0x000e, 0x00ee, 0x0005,
-	0x080c, 0x9ca3, 0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e,
-	0x60c3, 0x0008, 0x0804, 0xa248, 0x0021, 0x60c3, 0x0000, 0x0804,
-	0xa248, 0x00d6, 0x080c, 0xab2c, 0xb810, 0x9085, 0x0300, 0x7002,
-	0xb814, 0x7006, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e,
-	0x7013, 0x0819, 0x080c, 0xa236, 0x721a, 0x2f10, 0x7222, 0x7a08,
-	0x7226, 0x2071, 0x024c, 0x00de, 0x0005, 0x00a9, 0x7914, 0x712a,
-	0x60c3, 0x0000, 0x60a7, 0x9575, 0x0026, 0x080c, 0x2ba7, 0x0228,
-	0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012, 0x002e, 0x080c, 0xa26b,
-	0x080c, 0x8559, 0x0005, 0x0036, 0x0096, 0x00d6, 0x00e6, 0x7858,
-	0x2048, 0xaa7c, 0x9296, 0x00c0, 0x9294, 0xfffd, 0xaa7e, 0xaa80,
-	0x9294, 0x0300, 0xaa82, 0xa96c, 0x9194, 0x00ff, 0xab74, 0x9384,
-	0x00ff, 0x908d, 0xc200, 0xa96e, 0x9384, 0xff00, 0x9215, 0xaa76,
-	0xa870, 0xaa78, 0xa87a, 0xaa72, 0x00d6, 0x2069, 0x0200, 0x080c,
-	0xab2c, 0x00de, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000a,
-	0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098, 0x4003, 0x60a3,
-	0x0035, 0xaa68, 0x9294, 0x7000, 0x9286, 0x3000, 0x0110, 0x60a3,
-	0x0037, 0x00ee, 0x00de, 0x009e, 0x003e, 0x0005, 0x900e, 0x7814,
-	0x0096, 0x2048, 0xa87c, 0xd0fc, 0x01c0, 0x9084, 0x0003, 0x11a8,
-	0x2001, 0x180c, 0x2004, 0xd0bc, 0x0180, 0x7824, 0xd0cc, 0x1168,
-	0xd0c4, 0x1158, 0xa8a8, 0x9005, 0x1140, 0x2001, 0x180c, 0x200c,
-	0xc1d5, 0x2102, 0x2009, 0x19b1, 0x210c, 0x009e, 0x918d, 0x0092,
-	0x0010, 0x2009, 0x0096, 0x60ab, 0x0036, 0x6116, 0x0005, 0x2009,
-	0x0009, 0x00a0, 0x2009, 0x000a, 0x0088, 0x2009, 0x000b, 0x0070,
-	0x2009, 0x000c, 0x0058, 0x2009, 0x000d, 0x0040, 0x2009, 0x000e,
-	0x0028, 0x2009, 0x000f, 0x0010, 0x2009, 0x0008, 0x6912, 0x0005,
-	0x080c, 0x9c61, 0x0016, 0x0026, 0x0096, 0x00d6, 0x7814, 0x2048,
-	0x7013, 0x0138, 0x2001, 0x1837, 0x2004, 0x9084, 0x0028, 0x1138,
-	0x2001, 0x197b, 0x2004, 0x9086, 0xaaaa, 0x1904, 0xabd1, 0x7003,
-	0x5400, 0x00c6, 0x2061, 0x1800, 0x607c, 0x9084, 0x00ff, 0xa998,
-	0x810f, 0x918c, 0xff00, 0x9105, 0x700a, 0x6080, 0x700e, 0xa998,
-	0x918c, 0xff00, 0x7112, 0x20a9, 0x0004, 0x2009, 0x1805, 0x2e10,
-	0x9290, 0x0006, 0x2104, 0x2012, 0x8108, 0x8210, 0x1f04, 0xab62,
-	0x20a9, 0x0004, 0x2009, 0x1801, 0x2104, 0x2012, 0x8108, 0x8210,
-	0x1f04, 0xab6c, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0029, 0x2098,
-	0x2009, 0x0006, 0x20a9, 0x0001, 0x4002, 0x8007, 0x2012, 0x8210,
-	0x8109, 0x1dc0, 0x00d6, 0x2069, 0x0200, 0x080c, 0xab17, 0x00de,
-	0x2071, 0x0240, 0x2011, 0x0240, 0x2009, 0x0002, 0x20a9, 0x0001,
-	0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0, 0x2009, 0x0008,
+	0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
+	0x2678, 0x600f, 0x0000, 0x6014, 0x2048, 0x080c, 0xcb58, 0x0110,
+	0x080c, 0xe58c, 0x080c, 0xae90, 0x87ff, 0x1198, 0x00ce, 0x0804,
+	0xa742, 0x2c78, 0x600c, 0x2060, 0x0804, 0xa742, 0x9006, 0x012e,
+	0x000e, 0x002e, 0x006e, 0x00ce, 0x009e, 0x00de, 0x00ee, 0x00fe,
+	0x0005, 0x601b, 0x0000, 0x00ce, 0x97bd, 0x0001, 0x0c80, 0x00e6,
+	0x2071, 0x19e6, 0x2001, 0x1800, 0x2004, 0x9086, 0x0002, 0x1118,
+	0x7007, 0x0005, 0x0010, 0x7007, 0x0000, 0x00ee, 0x0005, 0x00f6,
+	0x00e6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000,
+	0x2071, 0x19e6, 0x2c10, 0x7638, 0x2660, 0x2678, 0x8cff, 0x0540,
+	0x2200, 0x9c06, 0x1508, 0x7038, 0x9c36, 0x1110, 0x660c, 0x763a,
+	0x7034, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7036,
+	0x0010, 0x7037, 0x0000, 0x660c, 0x2c00, 0x9f06, 0x0110, 0x7e0e,
+	0x0008, 0x2678, 0x600f, 0x0000, 0x6004, 0x9086, 0x0040, 0x090c,
+	0x959a, 0x9085, 0x0001, 0x0020, 0x2c78, 0x600c, 0x2060, 0x08b0,
+	0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x00ee, 0x00fe, 0x0005,
+	0x0096, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0026, 0x0006,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x760c, 0x2660, 0x2678,
+	0x8cff, 0x0904, 0xa88d, 0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be,
+	0x9206, 0x1904, 0xa888, 0x7024, 0x9c06, 0x1520, 0x2069, 0x0100,
+	0x68c0, 0x9005, 0x0904, 0xa85f, 0x080c, 0xa28f, 0x68c3, 0x0000,
+	0x080c, 0xa7a7, 0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04,
+	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2cfc, 0x9006,
+	0x080c, 0x2cfc, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
+	0x0001, 0x003e, 0x700c, 0x9c36, 0x1110, 0x660c, 0x760e, 0x7008,
+	0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700a, 0x0010,
+	0x700b, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e,
+	0x0008, 0x2678, 0x600f, 0x0000, 0x080c, 0xcd4f, 0x1180, 0x080c,
+	0x31f5, 0x080c, 0xcd60, 0x1518, 0x080c, 0xb821, 0x0400, 0x080c,
+	0xa7a7, 0x6824, 0xd084, 0x09b0, 0x6827, 0x0001, 0x0898, 0x080c,
+	0xcd60, 0x1118, 0x080c, 0xb821, 0x0090, 0x6014, 0x2048, 0x080c,
+	0xcb58, 0x0168, 0x6020, 0x9086, 0x0003, 0x1508, 0xa867, 0x0103,
+	0xab7a, 0xa877, 0x0000, 0x080c, 0x6c88, 0x080c, 0xcd43, 0x080c,
+	0xcfcc, 0x080c, 0xae90, 0x080c, 0xa67d, 0x00ce, 0x0804, 0xa808,
+	0x2c78, 0x600c, 0x2060, 0x0804, 0xa808, 0x012e, 0x000e, 0x002e,
+	0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x009e, 0x0005, 0x6020,
+	0x9086, 0x0006, 0x1d20, 0x080c, 0xe58c, 0x0c08, 0x00d6, 0x080c,
+	0x9cc7, 0x7003, 0x0200, 0x7007, 0x0014, 0x60c3, 0x0014, 0x20e1,
+	0x0001, 0x2099, 0x1988, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x20a9,
+	0x0004, 0x4003, 0x7023, 0x0004, 0x7027, 0x7878, 0x080c, 0xa263,
+	0x00de, 0x0005, 0x080c, 0x9cc7, 0x700b, 0x0800, 0x7814, 0x9084,
+	0xff00, 0x700e, 0x7814, 0x9084, 0x00ff, 0x7022, 0x782c, 0x7026,
+	0x7858, 0x9084, 0x00ff, 0x9085, 0x0200, 0x7002, 0x7858, 0x9084,
+	0xff00, 0x8007, 0x7006, 0x60c2, 0x0804, 0xa263, 0x00b6, 0x00d6,
+	0x0016, 0x00d6, 0x2f68, 0x2009, 0x0035, 0x080c, 0xd1d2, 0x00de,
+	0x1904, 0xa93b, 0x080c, 0x9c7c, 0x7003, 0x1300, 0x782c, 0x080c,
+	0xaa41, 0x2068, 0x6820, 0x9086, 0x0003, 0x0560, 0x7810, 0x2058,
+	0xbaa0, 0x080c, 0xadc9, 0x11d8, 0x9286, 0x007e, 0x1128, 0x700b,
+	0x00ff, 0x700f, 0xfffe, 0x0498, 0x9286, 0x007f, 0x1128, 0x700b,
+	0x00ff, 0x700f, 0xfffd, 0x0458, 0x9284, 0xff80, 0x0180, 0x9286,
+	0x0080, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffc, 0x0400, 0x92d8,
+	0x1000, 0x2b5c, 0xb810, 0x700a, 0xb814, 0x700e, 0x00c0, 0x6098,
+	0x700e, 0x00a8, 0x080c, 0xadc9, 0x1130, 0x7810, 0x2058, 0xb8a0,
+	0x9082, 0x007e, 0x0250, 0x00d6, 0x2069, 0x181f, 0x2d04, 0x700a,
+	0x8d68, 0x2d04, 0x700e, 0x00de, 0x0010, 0x6034, 0x700e, 0x7838,
+	0x7012, 0x783c, 0x7016, 0x60c3, 0x000c, 0x001e, 0x00de, 0x080c,
+	0xa263, 0x00be, 0x0005, 0x781b, 0x0001, 0x7803, 0x0006, 0x001e,
+	0x00de, 0x00be, 0x0005, 0x792c, 0x9180, 0x0008, 0x200c, 0x9186,
+	0x0006, 0x01c0, 0x9186, 0x0003, 0x0904, 0xa9b6, 0x9186, 0x0005,
+	0x0904, 0xa99e, 0x9186, 0x0004, 0x05d8, 0x9186, 0x0008, 0x0904,
+	0xa9a7, 0x7807, 0x0037, 0x782f, 0x0003, 0x7817, 0x1700, 0x080c,
+	0xaa1e, 0x0005, 0x080c, 0xa9df, 0x00d6, 0x0026, 0x792c, 0x2168,
+	0x2009, 0x4000, 0x6800, 0x0002, 0xa97f, 0xa98a, 0xa981, 0xa98a,
+	0xa986, 0xa97f, 0xa97f, 0xa98a, 0xa98a, 0xa98a, 0xa98a, 0xa97f,
+	0xa97f, 0xa97f, 0xa97f, 0xa97f, 0xa98a, 0xa97f, 0xa98a, 0x080c,
+	0x0dd5, 0x6824, 0xd0e4, 0x0110, 0xd0cc, 0x0110, 0x900e, 0x0010,
+	0x2009, 0x2000, 0x682c, 0x7022, 0x6830, 0x7026, 0x0804, 0xa9d8,
+	0x080c, 0xa9df, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000,
+	0x6a00, 0x9286, 0x0002, 0x1108, 0x900e, 0x04d0, 0x080c, 0xa9df,
+	0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x0488, 0x04b9,
+	0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x9286, 0x0005,
+	0x0118, 0x9286, 0x0002, 0x1108, 0x900e, 0x0410, 0x0441, 0x00d6,
+	0x0026, 0x792c, 0x2168, 0x6814, 0x6924, 0xc185, 0x6926, 0x0096,
+	0x2048, 0xa9ac, 0xa834, 0x9112, 0xa9b0, 0xa838, 0x009e, 0x9103,
+	0x7022, 0x7226, 0x792c, 0x9180, 0x0000, 0x2004, 0x908e, 0x0002,
+	0x0130, 0x908e, 0x0004, 0x0118, 0x2009, 0x4000, 0x0008, 0x900e,
+	0x712a, 0x60c3, 0x0018, 0x002e, 0x00de, 0x0804, 0xa263, 0x00b6,
+	0x0036, 0x0046, 0x0056, 0x0066, 0x080c, 0x9cc7, 0x9006, 0x7003,
+	0x0200, 0x7938, 0x710a, 0x793c, 0x710e, 0x7810, 0x2058, 0xb8a0,
+	0x080c, 0xadc9, 0x1118, 0x9092, 0x007e, 0x0268, 0x00d6, 0x2069,
+	0x181f, 0x2d2c, 0x8d68, 0x2d34, 0x90d8, 0x1000, 0x2b5c, 0xbb10,
+	0xbc14, 0x00de, 0x0028, 0x901e, 0x6498, 0x2029, 0x0000, 0x6634,
+	0x782c, 0x9080, 0x0008, 0x2004, 0x9086, 0x0003, 0x1128, 0x7512,
+	0x7616, 0x731a, 0x741e, 0x0020, 0x7312, 0x7416, 0x751a, 0x761e,
+	0x006e, 0x005e, 0x004e, 0x003e, 0x00be, 0x0005, 0x080c, 0x9cc7,
+	0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e, 0x700e, 0x60c3,
+	0x0008, 0x0804, 0xa263, 0x080c, 0x9c73, 0x7003, 0x1400, 0x7838,
+	0x700a, 0x0079, 0x783c, 0x700e, 0x782c, 0x7012, 0x7830, 0x7016,
+	0x7834, 0x9084, 0x00ff, 0x8007, 0x701a, 0x60c3, 0x0010, 0x0804,
+	0xa263, 0x00e6, 0x2071, 0x0240, 0x0006, 0x00f6, 0x2078, 0x7810,
+	0x00b6, 0x2058, 0xb8cc, 0xd084, 0x0120, 0x7848, 0x702a, 0x7844,
+	0x702e, 0x00be, 0x00fe, 0x000e, 0x00ee, 0x0005, 0x080c, 0x9cbe,
+	0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e, 0x60c3, 0x0008,
+	0x0804, 0xa263, 0x0021, 0x60c3, 0x0000, 0x0804, 0xa263, 0x00d6,
+	0x080c, 0xab1a, 0xb810, 0x9085, 0x0300, 0x7002, 0xb814, 0x7006,
+	0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x7013, 0x0819,
+	0x080c, 0xa251, 0x721a, 0x2f10, 0x7222, 0x7a08, 0x7226, 0x2071,
+	0x024c, 0x00de, 0x0005, 0x00a9, 0x7914, 0x712a, 0x60c3, 0x0000,
+	0x60a7, 0x9575, 0x0026, 0x080c, 0x2bb2, 0x0228, 0x2011, 0x0101,
+	0x2204, 0xc0c5, 0x2012, 0x002e, 0x080c, 0xa286, 0x080c, 0x8576,
+	0x0005, 0x0036, 0x0096, 0x00d6, 0x00e6, 0x7858, 0x2048, 0xaa7c,
+	0x9296, 0x00c0, 0x9294, 0xfffd, 0xaa7e, 0xaa80, 0x9294, 0x0300,
+	0xaa82, 0xa96c, 0x9194, 0x00ff, 0xab74, 0x9384, 0x00ff, 0x908d,
+	0xc200, 0xa96e, 0x9384, 0xff00, 0x9215, 0xaa76, 0xa870, 0xaa78,
+	0xa87a, 0xaa72, 0x00d6, 0x2069, 0x0200, 0x080c, 0xab1a, 0x00de,
+	0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000a, 0xa860, 0x20e0,
+	0xa85c, 0x9080, 0x001b, 0x2098, 0x4003, 0x60a3, 0x0035, 0xaa68,
+	0x9294, 0x7000, 0x9286, 0x3000, 0x0110, 0x60a3, 0x0037, 0x00ee,
+	0x00de, 0x009e, 0x003e, 0x0005, 0x900e, 0x7814, 0x0096, 0x2048,
+	0xa87c, 0xd0fc, 0x01c0, 0x9084, 0x0003, 0x11a8, 0x2001, 0x180c,
+	0x2004, 0xd0bc, 0x0180, 0x7824, 0xd0cc, 0x1168, 0xd0c4, 0x1158,
+	0xa8a8, 0x9005, 0x1140, 0x2001, 0x180c, 0x200c, 0xc1d5, 0x2102,
+	0x2009, 0x19b1, 0x210c, 0x009e, 0x918d, 0x0092, 0x0010, 0x2009,
+	0x0096, 0x60ab, 0x0036, 0x6116, 0x0005, 0x2009, 0x0009, 0x00a0,
+	0x2009, 0x000a, 0x0088, 0x2009, 0x000b, 0x0070, 0x2009, 0x000c,
+	0x0058, 0x2009, 0x000d, 0x0040, 0x2009, 0x000e, 0x0028, 0x2009,
+	0x000f, 0x0010, 0x2009, 0x0008, 0x6912, 0x0005, 0x080c, 0x9c7c,
+	0x0016, 0x0026, 0x0096, 0x00d6, 0x7814, 0x2048, 0x7013, 0x0138,
+	0x2001, 0x1837, 0x2004, 0x9084, 0x0028, 0x1138, 0x2001, 0x197b,
+	0x2004, 0x9086, 0xaaaa, 0x1904, 0xabbf, 0x7003, 0x5400, 0x00c6,
+	0x2061, 0x1800, 0x607c, 0x9084, 0x00ff, 0xa998, 0x810f, 0x918c,
+	0xff00, 0x9105, 0x700a, 0x6080, 0x700e, 0xa998, 0x918c, 0xff00,
+	0x7112, 0x20a9, 0x0004, 0x2009, 0x1805, 0x2e10, 0x9290, 0x0006,
+	0x2104, 0x2012, 0x8108, 0x8210, 0x1f04, 0xab50, 0x20a9, 0x0004,
+	0x2009, 0x1801, 0x2104, 0x2012, 0x8108, 0x8210, 0x1f04, 0xab5a,
+	0xa860, 0x20e0, 0xa85c, 0x9080, 0x0029, 0x2098, 0x2009, 0x0006,
 	0x20a9, 0x0001, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0,
-	0xa85c, 0x9080, 0x0031, 0x2098, 0x2009, 0x0008, 0x20a9, 0x0001,
-	0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0, 0x00ce, 0x60c3,
-	0x004c, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x2001, 0x1837, 0x2004,
-	0x9084, 0x0028, 0x1168, 0x080c, 0x73a5, 0x0150, 0x6028, 0xc0bd,
-	0x602a, 0x6014, 0x9084, 0x1804, 0x9085, 0x0029, 0x6016, 0x0010,
-	0x080c, 0xa248, 0x080c, 0x8559, 0x00de, 0x009e, 0x002e, 0x001e,
-	0x0005, 0x00e6, 0x2071, 0x0240, 0x2001, 0x2200, 0x9085, 0x00ff,
-	0x7002, 0x7007, 0xffff, 0x2071, 0x0100, 0x709b, 0x00ff, 0x00ee,
-	0x0804, 0xab47, 0x080c, 0x9c61, 0x0016, 0x0026, 0x0096, 0x00d6,
-	0x7814, 0x2048, 0x7013, 0x0138, 0x7003, 0x5500, 0x00c6, 0xa89c,
-	0x9084, 0x00ff, 0xa998, 0x810f, 0x918c, 0xff00, 0x9105, 0x700a,
-	0xa99c, 0x918c, 0xff00, 0xa8a0, 0x9084, 0x00ff, 0x9105, 0x700e,
-	0xa998, 0x918c, 0xff00, 0x2061, 0x1800, 0x607c, 0x9084, 0x00ff,
-	0x910d, 0x7112, 0x6180, 0x7116, 0x2009, 0x0008, 0xa860, 0x20e0,
-	0xa85c, 0x9080, 0x0029, 0x2098, 0x2e10, 0x9290, 0x0006, 0x20a9,
-	0x0001, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0, 0x20a9,
-	0x0004, 0x2009, 0x1805, 0x2104, 0x2012, 0x8108, 0x8210, 0x1f04,
-	0xac23, 0x20a9, 0x0002, 0x2009, 0x1801, 0x2104, 0x2012, 0x8108,
-	0x8210, 0x1f04, 0xac2d, 0x00d6, 0x0016, 0x2069, 0x0200, 0x080c,
-	0xab17, 0x001e, 0x00de, 0x2071, 0x0240, 0x20a9, 0x0002, 0x2009,
-	0x1803, 0x2011, 0x0240, 0x2104, 0x2012, 0x8108, 0x8210, 0x1f04,
-	0xac43, 0x2009, 0x0008, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109,
-	0x1dd0, 0x9006, 0x20a9, 0x0008, 0x2012, 0x8210, 0x1f04, 0xac54,
-	0x00ce, 0x60c3, 0x004c, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c,
-	0xa248, 0x080c, 0x8559, 0x00de, 0x009e, 0x002e, 0x001e, 0x0005,
-	0x00d6, 0x9290, 0x0018, 0x8214, 0x20e9, 0x0000, 0x2069, 0x0200,
-	0x6813, 0x0000, 0x22a8, 0x9284, 0x00e0, 0x0128, 0x20a9, 0x0020,
-	0x9292, 0x0020, 0x0008, 0x9016, 0x20a1, 0x0240, 0x9006, 0x4004,
-	0x82ff, 0x0120, 0x6810, 0x8000, 0x6812, 0x0c60, 0x00de, 0x0005,
-	0x00d6, 0x0096, 0x6014, 0x2048, 0xa878, 0x6056, 0x9006, 0xa836,
-	0xa83a, 0xa99c, 0xa946, 0xa84a, 0x6023, 0x0003, 0x6007, 0x0040,
-	0x6003, 0x0003, 0x600b, 0xffff, 0xa817, 0x0001, 0xa842, 0xa83e,
-	0x2900, 0xa85a, 0xa813, 0x2090, 0x080c, 0x913e, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x97b5, 0x012e, 0x009e, 0x00de, 0x0005, 0x00f6,
-	0x00e6, 0x00d6, 0x00c6, 0x00a6, 0x0096, 0x0066, 0x0126, 0x2091,
-	0x8000, 0x2071, 0x19e6, 0x760c, 0x2660, 0x2678, 0x8cff, 0x0904,
-	0xad3b, 0x7024, 0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0, 0x9005,
-	0x0904, 0xad0d, 0x080c, 0xa274, 0x68c3, 0x0000, 0x080c, 0xa7bd,
-	0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000,
-	0x0138, 0x2001, 0x0100, 0x080c, 0x2cf1, 0x9006, 0x080c, 0x2cf1,
-	0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e,
-	0x700c, 0x9c36, 0x1110, 0x660c, 0x760e, 0x7008, 0x9c36, 0x1140,
-	0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700a, 0x0010, 0x700b, 0x0000,
-	0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678,
-	0x600f, 0x0000, 0x080c, 0xcd3f, 0x1180, 0x080c, 0x31ea, 0x080c,
-	0xcd50, 0x1518, 0x080c, 0xb824, 0x0400, 0x080c, 0xa7bd, 0x6824,
-	0xd084, 0x09b0, 0x6827, 0x0001, 0x0898, 0x080c, 0xcd50, 0x1118,
-	0x080c, 0xb824, 0x0090, 0x6014, 0x2048, 0x080c, 0xcb48, 0x0168,
-	0x6020, 0x9086, 0x0003, 0x1520, 0xa867, 0x0103, 0xab7a, 0xa877,
-	0x0000, 0x080c, 0x6c86, 0x080c, 0xcd33, 0x080c, 0xcfbc, 0x080c,
-	0xaea2, 0x080c, 0xa693, 0x00ce, 0x0804, 0xacbe, 0x2c78, 0x600c,
-	0x2060, 0x0804, 0xacbe, 0x700f, 0x0000, 0x700b, 0x0000, 0x012e,
-	0x006e, 0x009e, 0x00ae, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005,
-	0x6020, 0x9086, 0x0006, 0x1d08, 0x080c, 0xe572, 0x08f0, 0x00d6,
-	0x0156, 0x080c, 0x9cac, 0x7a14, 0x82ff, 0x0138, 0x7003, 0x0100,
-	0x700b, 0x0003, 0x60c3, 0x0008, 0x0490, 0x7003, 0x0200, 0x7007,
-	0x0000, 0x2069, 0x1800, 0x901e, 0x6800, 0x9086, 0x0004, 0x1110,
-	0xc38d, 0x0060, 0x080c, 0x73a5, 0x1110, 0xc3ad, 0x0008, 0xc3a5,
-	0x6adc, 0xd29c, 0x1110, 0xd2ac, 0x0108, 0xc39d, 0x730e, 0x080c,
-	0x85c2, 0x20a9, 0x0006, 0x2011, 0xfff4, 0x2019, 0xfff5, 0x2071,
-	0x0250, 0x2305, 0x2072, 0x8e70, 0x2205, 0x2072, 0x8e70, 0x9398,
-	0x0002, 0x9290, 0x0002, 0x1f04, 0xad81, 0x60c3, 0x0020, 0x080c,
-	0xa248, 0x015e, 0x00de, 0x0005, 0x0156, 0x080c, 0x9cac, 0x7a14,
-	0x82ff, 0x0168, 0x9286, 0xffff, 0x0118, 0x9282, 0x000e, 0x1238,
-	0x7003, 0x0100, 0x700b, 0x0003, 0x60c3, 0x0008, 0x0488, 0x7003,
-	0x0200, 0x7007, 0x001c, 0x700f, 0x0001, 0x2011, 0x19bc, 0x2204,
-	0x8007, 0x701a, 0x8210, 0x2204, 0x8007, 0x701e, 0x0421, 0x1120,
-	0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181f, 0x2004, 0x7022,
-	0x2001, 0x1820, 0x2004, 0x7026, 0x0030, 0x2001, 0x1818, 0x2004,
-	0x9084, 0x00ff, 0x7026, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099,
-	0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256, 0x4003, 0x60c3, 0x001c,
-	0x015e, 0x0804, 0xa248, 0x0006, 0x2001, 0x1837, 0x2004, 0xd0ac,
-	0x000e, 0x0005, 0x2011, 0x0003, 0x080c, 0xa654, 0x2011, 0x0002,
-	0x080c, 0xa65e, 0x080c, 0xa541, 0x0036, 0x901e, 0x080c, 0xa5b7,
-	0x003e, 0x0005, 0x080c, 0x3320, 0x0188, 0x0016, 0x00b6, 0x00c6,
-	0x7010, 0x9085, 0x0020, 0x7012, 0x2009, 0x007e, 0x080c, 0x6608,
-	0xb85c, 0xc0ac, 0xb85e, 0x00ce, 0x00be, 0x001e, 0x0005, 0x2071,
-	0x188d, 0x7000, 0x9005, 0x0140, 0x2001, 0x0976, 0x2071, 0x1800,
-	0x7076, 0x707a, 0x706b, 0xffe0, 0x2071, 0x1800, 0x7074, 0x7056,
-	0x705b, 0x1cd0, 0x0005, 0x00e6, 0x0126, 0x2071, 0x1800, 0x2091,
-	0x8000, 0x7554, 0x9582, 0x0010, 0x0608, 0x7058, 0x2060, 0x6000,
+	0x00d6, 0x2069, 0x0200, 0x080c, 0xab05, 0x00de, 0x2071, 0x0240,
+	0x2011, 0x0240, 0x2009, 0x0002, 0x20a9, 0x0001, 0x4002, 0x8007,
+	0x2012, 0x8210, 0x8109, 0x1dc0, 0x2009, 0x0008, 0x20a9, 0x0001,
+	0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0, 0xa85c, 0x9080,
+	0x0031, 0x2098, 0x2009, 0x0008, 0x20a9, 0x0001, 0x4002, 0x8007,
+	0x2012, 0x8210, 0x8109, 0x1dc0, 0x00ce, 0x60c3, 0x004c, 0x60a3,
+	0x0056, 0x60a7, 0x9575, 0x2001, 0x1837, 0x2004, 0x9084, 0x0028,
+	0x1168, 0x080c, 0x73b3, 0x0150, 0x6028, 0xc0bd, 0x602a, 0x6014,
+	0x9084, 0x1804, 0x9085, 0x0029, 0x6016, 0x0010, 0x080c, 0xa263,
+	0x080c, 0x8576, 0x00de, 0x009e, 0x002e, 0x001e, 0x0005, 0x00e6,
+	0x2071, 0x0240, 0x2001, 0x2200, 0x9085, 0x00ff, 0x7002, 0x7007,
+	0xffff, 0x2071, 0x0100, 0x709b, 0x00ff, 0x00ee, 0x0804, 0xab35,
+	0x080c, 0x9c7c, 0x0016, 0x0026, 0x0096, 0x00d6, 0x7814, 0x2048,
+	0x7013, 0x0138, 0x7003, 0x5500, 0x00c6, 0xa89c, 0x9084, 0x00ff,
+	0xa998, 0x810f, 0x918c, 0xff00, 0x9105, 0x700a, 0xa99c, 0x918c,
+	0xff00, 0xa8a0, 0x9084, 0x00ff, 0x9105, 0x700e, 0xa998, 0x918c,
+	0xff00, 0x2061, 0x1800, 0x607c, 0x9084, 0x00ff, 0x910d, 0x7112,
+	0x6180, 0x7116, 0x2009, 0x0008, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x0029, 0x2098, 0x2e10, 0x9290, 0x0006, 0x20a9, 0x0001, 0x4002,
+	0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0, 0x20a9, 0x0004, 0x2009,
+	0x1805, 0x2104, 0x2012, 0x8108, 0x8210, 0x1f04, 0xac11, 0x20a9,
+	0x0002, 0x2009, 0x1801, 0x2104, 0x2012, 0x8108, 0x8210, 0x1f04,
+	0xac1b, 0x00d6, 0x0016, 0x2069, 0x0200, 0x080c, 0xab05, 0x001e,
+	0x00de, 0x2071, 0x0240, 0x20a9, 0x0002, 0x2009, 0x1803, 0x2011,
+	0x0240, 0x2104, 0x2012, 0x8108, 0x8210, 0x1f04, 0xac31, 0x2009,
+	0x0008, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dd0, 0x9006,
+	0x20a9, 0x0008, 0x2012, 0x8210, 0x1f04, 0xac42, 0x00ce, 0x60c3,
+	0x004c, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0xa263, 0x080c,
+	0x8576, 0x00de, 0x009e, 0x002e, 0x001e, 0x0005, 0x00d6, 0x9290,
+	0x0018, 0x8214, 0x20e9, 0x0000, 0x2069, 0x0200, 0x6813, 0x0000,
+	0x22a8, 0x9284, 0x00e0, 0x0128, 0x20a9, 0x0020, 0x9292, 0x0020,
+	0x0008, 0x9016, 0x20a1, 0x0240, 0x9006, 0x4004, 0x82ff, 0x0120,
+	0x6810, 0x8000, 0x6812, 0x0c60, 0x00de, 0x0005, 0x00d6, 0x0096,
+	0x6014, 0x2048, 0xa878, 0x6056, 0x9006, 0xa836, 0xa83a, 0xa99c,
+	0xa946, 0xa84a, 0x6023, 0x0003, 0x6007, 0x0040, 0x6003, 0x0003,
+	0x600b, 0xffff, 0xa817, 0x0001, 0xa842, 0xa83e, 0x2900, 0xa85a,
+	0xa813, 0x209b, 0x080c, 0x915d, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x97d4, 0x012e, 0x009e, 0x00de, 0x0005, 0x00f6, 0x00e6, 0x00d6,
+	0x00c6, 0x00a6, 0x0096, 0x0066, 0x0126, 0x2091, 0x8000, 0x2071,
+	0x19e6, 0x760c, 0x2660, 0x2678, 0x8cff, 0x0904, 0xad29, 0x7024,
+	0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0904, 0xacfb,
+	0x080c, 0xa28f, 0x68c3, 0x0000, 0x080c, 0xa7a7, 0x7027, 0x0000,
+	0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
+	0x0100, 0x080c, 0x2cfc, 0x9006, 0x080c, 0x2cfc, 0x2069, 0x0100,
+	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x700c, 0x9c36,
+	0x1110, 0x660c, 0x760e, 0x7008, 0x9c36, 0x1140, 0x2c00, 0x9f36,
+	0x0118, 0x2f00, 0x700a, 0x0010, 0x700b, 0x0000, 0x660c, 0x0066,
+	0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000,
+	0x080c, 0xcd4f, 0x1180, 0x080c, 0x31f5, 0x080c, 0xcd60, 0x1518,
+	0x080c, 0xb821, 0x0400, 0x080c, 0xa7a7, 0x6824, 0xd084, 0x09b0,
+	0x6827, 0x0001, 0x0898, 0x080c, 0xcd60, 0x1118, 0x080c, 0xb821,
+	0x0090, 0x6014, 0x2048, 0x080c, 0xcb58, 0x0168, 0x6020, 0x9086,
+	0x0003, 0x1520, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
+	0x6c94, 0x080c, 0xcd43, 0x080c, 0xcfcc, 0x080c, 0xae90, 0x080c,
+	0xa67d, 0x00ce, 0x0804, 0xacac, 0x2c78, 0x600c, 0x2060, 0x0804,
+	0xacac, 0x700f, 0x0000, 0x700b, 0x0000, 0x012e, 0x006e, 0x009e,
+	0x00ae, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086,
+	0x0006, 0x1d08, 0x080c, 0xe58c, 0x08f0, 0x00d6, 0x0156, 0x080c,
+	0x9cc7, 0x7a14, 0x82ff, 0x0138, 0x7003, 0x0100, 0x700b, 0x0003,
+	0x60c3, 0x0008, 0x0490, 0x7003, 0x0200, 0x7007, 0x0000, 0x2069,
+	0x1800, 0x901e, 0x6800, 0x9086, 0x0004, 0x1110, 0xc38d, 0x0060,
+	0x080c, 0x73b3, 0x1110, 0xc3ad, 0x0008, 0xc3a5, 0x6adc, 0xd29c,
+	0x1110, 0xd2ac, 0x0108, 0xc39d, 0x730e, 0x080c, 0x85df, 0x20a9,
+	0x0006, 0x2011, 0xffec, 0x2019, 0xffed, 0x2071, 0x0250, 0x2305,
+	0x2072, 0x8e70, 0x2205, 0x2072, 0x8e70, 0x9398, 0x0002, 0x9290,
+	0x0002, 0x1f04, 0xad6f, 0x60c3, 0x0020, 0x080c, 0xa263, 0x015e,
+	0x00de, 0x0005, 0x0156, 0x080c, 0x9cc7, 0x7a14, 0x82ff, 0x0168,
+	0x9286, 0xffff, 0x0118, 0x9282, 0x000e, 0x1238, 0x7003, 0x0100,
+	0x700b, 0x0003, 0x60c3, 0x0008, 0x0488, 0x7003, 0x0200, 0x7007,
+	0x001c, 0x700f, 0x0001, 0x2011, 0x19bc, 0x2204, 0x8007, 0x701a,
+	0x8210, 0x2204, 0x8007, 0x701e, 0x0421, 0x1120, 0xb8a0, 0x9082,
+	0x007f, 0x0248, 0x2001, 0x181f, 0x2004, 0x7022, 0x2001, 0x1820,
+	0x2004, 0x7026, 0x0030, 0x2001, 0x1818, 0x2004, 0x9084, 0x00ff,
+	0x7026, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9,
+	0x0000, 0x20a1, 0x0256, 0x4003, 0x60c3, 0x001c, 0x015e, 0x0804,
+	0xa263, 0x0006, 0x2001, 0x1837, 0x2004, 0xd0ac, 0x000e, 0x0005,
+	0x2011, 0x0003, 0x080c, 0xa63e, 0x2011, 0x0002, 0x080c, 0xa648,
+	0x080c, 0xa552, 0x0036, 0x901e, 0x080c, 0xa5c8, 0x003e, 0x0005,
+	0x080c, 0x332b, 0x0188, 0x0016, 0x00b6, 0x00c6, 0x7010, 0x9085,
+	0x0020, 0x7012, 0x2009, 0x007e, 0x080c, 0x6616, 0xb85c, 0xc0ac,
+	0xb85e, 0x00ce, 0x00be, 0x001e, 0x0005, 0x2071, 0x188d, 0x7000,
+	0x9005, 0x0140, 0x2001, 0x0976, 0x2071, 0x1800, 0x7076, 0x707a,
+	0x706b, 0xffe0, 0x2071, 0x1800, 0x7074, 0x7056, 0x705b, 0x1cd0,
+	0x0005, 0x00e6, 0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7554,
+	0x9582, 0x0010, 0x0608, 0x7058, 0x2060, 0x6000, 0x9086, 0x0000,
+	0x0148, 0x9ce0, 0x0018, 0x7068, 0x9c02, 0x1208, 0x0cb0, 0x2061,
+	0x1cd0, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7556, 0x9ca8, 0x0018,
+	0x7068, 0x9502, 0x1230, 0x755a, 0x9085, 0x0001, 0x012e, 0x00ee,
+	0x0005, 0x705b, 0x1cd0, 0x0cc0, 0x9006, 0x0cc0, 0x00e6, 0x2071,
+	0x1800, 0x7554, 0x9582, 0x0010, 0x0600, 0x7058, 0x2060, 0x6000,
 	0x9086, 0x0000, 0x0148, 0x9ce0, 0x0018, 0x7068, 0x9c02, 0x1208,
 	0x0cb0, 0x2061, 0x1cd0, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7556,
-	0x9ca8, 0x0018, 0x7068, 0x9502, 0x1230, 0x755a, 0x9085, 0x0001,
-	0x012e, 0x00ee, 0x0005, 0x705b, 0x1cd0, 0x0cc0, 0x9006, 0x0cc0,
-	0x00e6, 0x2071, 0x1800, 0x7554, 0x9582, 0x0010, 0x0600, 0x7058,
+	0x9ca8, 0x0018, 0x7068, 0x9502, 0x1228, 0x755a, 0x9085, 0x0001,
+	0x00ee, 0x0005, 0x705b, 0x1cd0, 0x0cc8, 0x9006, 0x0cc8, 0x9c82,
+	0x1cd0, 0x0a0c, 0x0dd5, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1a0c,
+	0x0dd5, 0x9006, 0x6006, 0x600a, 0x600e, 0x6016, 0x601a, 0x6012,
+	0x6023, 0x0000, 0x6003, 0x0000, 0x601e, 0x6056, 0x605a, 0x6026,
+	0x602a, 0x602e, 0x6032, 0x6036, 0x603a, 0x603e, 0x6042, 0x602a,
+	0x2061, 0x1800, 0x6054, 0x8000, 0x6056, 0x9086, 0x0001, 0x0108,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x96a6, 0x012e, 0x0cc0,
+	0x0006, 0x6000, 0x9086, 0x0000, 0x01b0, 0x601c, 0xd084, 0x190c,
+	0x1a70, 0x6017, 0x0000, 0x6023, 0x0007, 0x2001, 0x1985, 0x2004,
+	0x0006, 0x9082, 0x0051, 0x000e, 0x0208, 0x8004, 0x601a, 0x080c,
+	0xe846, 0x6043, 0x0000, 0x000e, 0x0005, 0x00e6, 0x0126, 0x2071,
+	0x1800, 0x2091, 0x8000, 0x7554, 0x9582, 0x0001, 0x0608, 0x7058,
 	0x2060, 0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0, 0x0018, 0x7068,
 	0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1cd0, 0x0c98, 0x6003, 0x0008,
-	0x8529, 0x7556, 0x9ca8, 0x0018, 0x7068, 0x9502, 0x1228, 0x755a,
-	0x9085, 0x0001, 0x00ee, 0x0005, 0x705b, 0x1cd0, 0x0cc8, 0x9006,
-	0x0cc8, 0x9c82, 0x1cd0, 0x0a0c, 0x0dd5, 0x2001, 0x181a, 0x2004,
-	0x9c02, 0x1a0c, 0x0dd5, 0x9006, 0x6006, 0x600a, 0x600e, 0x6016,
-	0x601a, 0x6012, 0x6023, 0x0000, 0x6003, 0x0000, 0x601e, 0x6056,
-	0x605a, 0x6026, 0x602a, 0x602e, 0x6032, 0x6036, 0x603a, 0x603e,
-	0x6042, 0x602a, 0x2061, 0x1800, 0x6054, 0x8000, 0x6056, 0x9086,
-	0x0001, 0x0108, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x9687,
-	0x012e, 0x0cc0, 0x0006, 0x6000, 0x9086, 0x0000, 0x01b0, 0x601c,
-	0xd084, 0x190c, 0x1a60, 0x6017, 0x0000, 0x6023, 0x0007, 0x2001,
-	0x1985, 0x2004, 0x0006, 0x9082, 0x0051, 0x000e, 0x0208, 0x8004,
-	0x601a, 0x080c, 0xe82c, 0x6043, 0x0000, 0x000e, 0x0005, 0x00e6,
-	0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7554, 0x9582, 0x0001,
-	0x0608, 0x7058, 0x2060, 0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0,
-	0x0018, 0x7068, 0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1cd0, 0x0c98,
-	0x6003, 0x0008, 0x8529, 0x7556, 0x9ca8, 0x0018, 0x7068, 0x9502,
-	0x1230, 0x755a, 0x9085, 0x0001, 0x012e, 0x00ee, 0x0005, 0x705b,
-	0x1cd0, 0x0cc0, 0x9006, 0x0cc0, 0x6020, 0x9084, 0x000f, 0x0002,
-	0xaeff, 0xaf08, 0xaf23, 0xaf3e, 0xd270, 0xd28d, 0xd2a8, 0xaeff,
-	0xaf08, 0x8d74, 0xaf5a, 0xaeff, 0xaeff, 0xaeff, 0xaeff, 0x9186,
-	0x0013, 0x1128, 0x080c, 0x957b, 0x080c, 0x9687, 0x0005, 0x0005,
+	0x8529, 0x7556, 0x9ca8, 0x0018, 0x7068, 0x9502, 0x1230, 0x755a,
+	0x9085, 0x0001, 0x012e, 0x00ee, 0x0005, 0x705b, 0x1cd0, 0x0cc0,
+	0x9006, 0x0cc0, 0x6020, 0x9084, 0x000f, 0x0002, 0xaeed, 0xaef6,
+	0xaf11, 0xaf2c, 0xd280, 0xd29d, 0xd2b8, 0xaeed, 0xaef6, 0x8d93,
+	0xaf48, 0xaeed, 0xaeed, 0xaeed, 0xaeed, 0x9186, 0x0013, 0x1128,
+	0x080c, 0x959a, 0x080c, 0x96a6, 0x0005, 0x0005, 0x0066, 0x6000,
+	0x90b2, 0x0016, 0x1a0c, 0x0dd5, 0x0013, 0x006e, 0x0005, 0xaf0f,
+	0xb68b, 0xb868, 0xaf0f, 0xb8fe, 0xb22b, 0xaf0f, 0xaf0f, 0xb60d,
+	0xbe65, 0xaf0f, 0xaf0f, 0xaf0f, 0xaf0f, 0xaf0f, 0xaf0f, 0x080c,
+	0x0dd5, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0dd5, 0x0013,
+	0x006e, 0x0005, 0xaf2a, 0xc53c, 0xaf2a, 0xaf2a, 0xaf2a, 0xaf2a,
+	0xaf2a, 0xaf2a, 0xc4de, 0xc6be, 0xaf2a, 0xc57d, 0xc5fc, 0xc57d,
+	0xc5fc, 0xaf2a, 0x080c, 0x0dd5, 0x6000, 0x9082, 0x0016, 0x1a0c,
+	0x0dd5, 0x6000, 0x0002, 0xaf46, 0xbeac, 0xbf91, 0xc0c1, 0xc26c,
+	0xaf46, 0xaf46, 0xaf46, 0xbe80, 0xc46a, 0xc46d, 0xaf46, 0xaf46,
+	0xaf46, 0xaf46, 0xc49c, 0xaf46, 0xaf46, 0xaf46, 0x080c, 0x0dd5,
 	0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0dd5, 0x0013, 0x006e,
-	0x0005, 0xaf21, 0xb690, 0xb86b, 0xaf21, 0xb901, 0xb23d, 0xaf21,
-	0xaf21, 0xb612, 0xbe68, 0xaf21, 0xaf21, 0xaf21, 0xaf21, 0xaf21,
-	0xaf21, 0x080c, 0x0dd5, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c,
-	0x0dd5, 0x0013, 0x006e, 0x0005, 0xaf3c, 0xc53c, 0xaf3c, 0xaf3c,
-	0xaf3c, 0xaf3c, 0xaf3c, 0xaf3c, 0xc4e1, 0xc6be, 0xaf3c, 0xc57d,
-	0xc5fc, 0xc57d, 0xc5fc, 0xaf3c, 0x080c, 0x0dd5, 0x6000, 0x9082,
-	0x0016, 0x1a0c, 0x0dd5, 0x6000, 0x0002, 0xaf58, 0xbeaf, 0xbf94,
-	0xc0c4, 0xc26f, 0xaf58, 0xaf58, 0xaf58, 0xbe83, 0xc46d, 0xc470,
-	0xaf58, 0xaf58, 0xaf58, 0xaf58, 0xc49f, 0xaf58, 0xaf58, 0xaf58,
-	0x080c, 0x0dd5, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0dd5,
-	0x0013, 0x006e, 0x0005, 0xaf73, 0xaf73, 0xafb6, 0xb055, 0xb0ea,
-	0xaf73, 0xaf73, 0xaf73, 0xaf75, 0xaf73, 0xaf73, 0xaf73, 0xaf73,
-	0xaf73, 0xaf73, 0xaf73, 0x080c, 0x0dd5, 0x9186, 0x004c, 0x0588,
-	0x9186, 0x0003, 0x190c, 0x0dd5, 0x0096, 0x601c, 0xc0ed, 0x601e,
-	0x6003, 0x0003, 0x6106, 0x6014, 0x2048, 0xa87c, 0x9084, 0xa000,
-	0xc0b5, 0xa87e, 0xa8ac, 0xa846, 0xa8b0, 0xa84a, 0x9006, 0xa836,
-	0xa83a, 0xa884, 0x9092, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003,
-	0x8013, 0x8213, 0x9210, 0x621a, 0x009e, 0x2c10, 0x080c, 0x1baf,
-	0x080c, 0x913e, 0x0126, 0x2091, 0x8000, 0x080c, 0x97b5, 0x012e,
-	0x0005, 0x6010, 0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x080c,
-	0xb10c, 0x080c, 0xd262, 0x6003, 0x0007, 0x0005, 0x00d6, 0x0096,
-	0x00f6, 0x2079, 0x1800, 0x7a90, 0x6014, 0x2048, 0xa87c, 0xd0ec,
-	0x1110, 0x9290, 0x0018, 0xac78, 0xc4fc, 0x0046, 0xa8e0, 0x9005,
-	0x1140, 0xa8dc, 0x921a, 0x0140, 0x0220, 0xa87b, 0x0007, 0x2010,
-	0x0028, 0xa87b, 0x0015, 0x0010, 0xa87b, 0x0000, 0x8214, 0xa883,
-	0x0000, 0xaa02, 0x0006, 0x0016, 0x0026, 0x00c6, 0x00d6, 0x00e6,
-	0x00f6, 0x2400, 0x9005, 0x1108, 0x009a, 0x2100, 0x9086, 0x0015,
-	0x1118, 0x2001, 0x0001, 0x0038, 0x2100, 0x9086, 0x0016, 0x0118,
-	0x2001, 0x0001, 0x002a, 0x94a4, 0x0007, 0x8423, 0x9405, 0x0002,
-	0xb01d, 0xb01d, 0xb018, 0xb01b, 0xb01d, 0xb015, 0xb008, 0xb008,
-	0xb008, 0xb008, 0xb008, 0xb008, 0xb008, 0xb008, 0xb008, 0xb008,
-	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e, 0x001e, 0x000e, 0x004e,
-	0x00fe, 0x009e, 0x00de, 0x080c, 0x0dd5, 0x080c, 0xbac0, 0x0028,
-	0x080c, 0xbba5, 0x0010, 0x080c, 0xbc9b, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x002e, 0x001e, 0x2c00, 0xa896, 0x000e, 0x080c, 0xb1ca,
-	0x0530, 0xa804, 0xa80e, 0x00a6, 0x2050, 0xb100, 0x00ae, 0x8006,
-	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002,
-	0xaacc, 0xabd0, 0xacd4, 0xadd8, 0x2031, 0x0000, 0x2041, 0x125d,
-	0x080c, 0xb38b, 0x0160, 0x000e, 0x9005, 0x0120, 0x00fe, 0x009e,
-	0x00de, 0x0005, 0x00fe, 0x009e, 0x00de, 0x0804, 0xae71, 0x2001,
-	0x002c, 0x900e, 0x080c, 0xb230, 0x0c70, 0x91b6, 0x0015, 0x0170,
-	0x91b6, 0x0016, 0x0158, 0x91b2, 0x0047, 0x0a0c, 0x0dd5, 0x91b2,
-	0x0050, 0x1a0c, 0x0dd5, 0x9182, 0x0047, 0x00ca, 0x2001, 0x0109,
-	0x2004, 0xd08c, 0x0198, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016,
-	0x0026, 0x080c, 0x908b, 0x002e, 0x001e, 0x000e, 0x012e, 0xa001,
-	0x6000, 0x9086, 0x0002, 0x1110, 0x0804, 0xafb6, 0x0005, 0xb088,
-	0xb088, 0xb08a, 0xb0c0, 0xb088, 0xb088, 0xb088, 0xb088, 0xb0d3,
-	0x080c, 0x0dd5, 0x00d6, 0x0016, 0x0096, 0x080c, 0x9637, 0x080c,
-	0x97b5, 0x6003, 0x0004, 0x6114, 0x2148, 0xa87c, 0xd0fc, 0x01c0,
-	0xa878, 0xc0fc, 0x9005, 0x1158, 0xa894, 0x9005, 0x0140, 0x2001,
-	0x0000, 0x900e, 0x080c, 0xb230, 0x080c, 0xae71, 0x00a8, 0x6003,
-	0x0002, 0xa8a4, 0xa9a8, 0x9105, 0x1178, 0xa8ae, 0xa8b2, 0x0c78,
-	0xa87f, 0x0020, 0xa88c, 0xa88a, 0xa8a4, 0xa8ae, 0xa8a8, 0xa8b2,
-	0xa8c7, 0x0000, 0xa8cb, 0x0000, 0x009e, 0x001e, 0x00de, 0x0005,
-	0x080c, 0x9637, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xcb4a,
-	0x0120, 0xa87b, 0x0006, 0x080c, 0x6c86, 0x009e, 0x00de, 0x080c,
-	0xae71, 0x0804, 0x97b5, 0x080c, 0x9637, 0x080c, 0x31c1, 0x080c,
-	0xd25f, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xcb4a, 0x0120,
-	0xa87b, 0x0029, 0x080c, 0x6c86, 0x009e, 0x00de, 0x080c, 0xae71,
-	0x0804, 0x97b5, 0x9182, 0x0047, 0x0002, 0xb0fa, 0xb0fc, 0xb0fa,
-	0xb0fa, 0xb0fa, 0xb0fa, 0xb0fa, 0xb0fa, 0xb0fa, 0xb0fa, 0xb0fa,
-	0xb0fa, 0xb0fc, 0x080c, 0x0dd5, 0x00d6, 0x0096, 0x601f, 0x0000,
-	0x6114, 0x2148, 0xa87b, 0x0000, 0xa883, 0x0000, 0x080c, 0x6c86,
-	0x009e, 0x00de, 0x0804, 0xae71, 0x0026, 0x0036, 0x0056, 0x0066,
-	0x0096, 0x00a6, 0x00f6, 0x0006, 0x080c, 0x0fff, 0x000e, 0x090c,
+	0x0005, 0xaf61, 0xaf61, 0xafa4, 0xb043, 0xb0d8, 0xaf61, 0xaf61,
+	0xaf61, 0xaf63, 0xaf61, 0xaf61, 0xaf61, 0xaf61, 0xaf61, 0xaf61,
+	0xaf61, 0x080c, 0x0dd5, 0x9186, 0x004c, 0x0588, 0x9186, 0x0003,
+	0x190c, 0x0dd5, 0x0096, 0x601c, 0xc0ed, 0x601e, 0x6003, 0x0003,
+	0x6106, 0x6014, 0x2048, 0xa87c, 0x9084, 0xa000, 0xc0b5, 0xa87e,
+	0xa8ac, 0xa846, 0xa8b0, 0xa84a, 0x9006, 0xa836, 0xa83a, 0xa884,
+	0x9092, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x8013, 0x8213,
+	0x9210, 0x621a, 0x009e, 0x2c10, 0x080c, 0x1bba, 0x080c, 0x915d,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x97d4, 0x012e, 0x0005, 0x6010,
+	0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x080c, 0xb0fa, 0x080c,
+	0xd272, 0x6003, 0x0007, 0x0005, 0x00d6, 0x0096, 0x00f6, 0x2079,
+	0x1800, 0x7a90, 0x6014, 0x2048, 0xa87c, 0xd0ec, 0x1110, 0x9290,
+	0x0018, 0xac78, 0xc4fc, 0x0046, 0xa8e0, 0x9005, 0x1140, 0xa8dc,
+	0x921a, 0x0140, 0x0220, 0xa87b, 0x0007, 0x2010, 0x0028, 0xa87b,
+	0x0015, 0x0010, 0xa87b, 0x0000, 0x8214, 0xa883, 0x0000, 0xaa02,
+	0x0006, 0x0016, 0x0026, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2400,
+	0x9005, 0x1108, 0x009a, 0x2100, 0x9086, 0x0015, 0x1118, 0x2001,
+	0x0001, 0x0038, 0x2100, 0x9086, 0x0016, 0x0118, 0x2001, 0x0001,
+	0x002a, 0x94a4, 0x0007, 0x8423, 0x9405, 0x0002, 0xb00b, 0xb00b,
+	0xb006, 0xb009, 0xb00b, 0xb003, 0xaff6, 0xaff6, 0xaff6, 0xaff6,
+	0xaff6, 0xaff6, 0xaff6, 0xaff6, 0xaff6, 0xaff6, 0x00fe, 0x00ee,
+	0x00de, 0x00ce, 0x002e, 0x001e, 0x000e, 0x004e, 0x00fe, 0x009e,
+	0x00de, 0x080c, 0x0dd5, 0x080c, 0xbabd, 0x0028, 0x080c, 0xbba2,
+	0x0010, 0x080c, 0xbc98, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e,
+	0x001e, 0x2c00, 0xa896, 0x000e, 0x080c, 0xb1b8, 0x0530, 0xa804,
+	0xa80e, 0x00a6, 0x2050, 0xb100, 0x00ae, 0x8006, 0x8006, 0x8007,
+	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0xaacc, 0xabd0,
+	0xacd4, 0xadd8, 0x2031, 0x0000, 0x2041, 0x125d, 0x080c, 0xb379,
+	0x0160, 0x000e, 0x9005, 0x0120, 0x00fe, 0x009e, 0x00de, 0x0005,
+	0x00fe, 0x009e, 0x00de, 0x0804, 0xae5f, 0x2001, 0x002c, 0x900e,
+	0x080c, 0xb21e, 0x0c70, 0x91b6, 0x0015, 0x0170, 0x91b6, 0x0016,
+	0x0158, 0x91b2, 0x0047, 0x0a0c, 0x0dd5, 0x91b2, 0x0050, 0x1a0c,
+	0x0dd5, 0x9182, 0x0047, 0x00ca, 0x2001, 0x0109, 0x2004, 0xd08c,
+	0x0198, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x080c,
+	0x90aa, 0x002e, 0x001e, 0x000e, 0x012e, 0xa001, 0x6000, 0x9086,
+	0x0002, 0x1110, 0x0804, 0xafa4, 0x0005, 0xb076, 0xb076, 0xb078,
+	0xb0ae, 0xb076, 0xb076, 0xb076, 0xb076, 0xb0c1, 0x080c, 0x0dd5,
+	0x00d6, 0x0016, 0x0096, 0x080c, 0x9656, 0x080c, 0x97d4, 0x6003,
+	0x0004, 0x6114, 0x2148, 0xa87c, 0xd0fc, 0x01c0, 0xa878, 0xc0fc,
+	0x9005, 0x1158, 0xa894, 0x9005, 0x0140, 0x2001, 0x0000, 0x900e,
+	0x080c, 0xb21e, 0x080c, 0xae5f, 0x00a8, 0x6003, 0x0002, 0xa8a4,
+	0xa9a8, 0x9105, 0x1178, 0xa8ae, 0xa8b2, 0x0c78, 0xa87f, 0x0020,
+	0xa88c, 0xa88a, 0xa8a4, 0xa8ae, 0xa8a8, 0xa8b2, 0xa8c7, 0x0000,
+	0xa8cb, 0x0000, 0x009e, 0x001e, 0x00de, 0x0005, 0x080c, 0x9656,
+	0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xcb5a, 0x0120, 0xa87b,
+	0x0006, 0x080c, 0x6c94, 0x009e, 0x00de, 0x080c, 0xae5f, 0x0804,
+	0x97d4, 0x080c, 0x9656, 0x080c, 0x31cc, 0x080c, 0xd26f, 0x00d6,
+	0x0096, 0x6114, 0x2148, 0x080c, 0xcb5a, 0x0120, 0xa87b, 0x0029,
+	0x080c, 0x6c94, 0x009e, 0x00de, 0x080c, 0xae5f, 0x0804, 0x97d4,
+	0x9182, 0x0047, 0x0002, 0xb0e8, 0xb0ea, 0xb0e8, 0xb0e8, 0xb0e8,
+	0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0ea,
+	0x080c, 0x0dd5, 0x00d6, 0x0096, 0x601f, 0x0000, 0x6114, 0x2148,
+	0xa87b, 0x0000, 0xa883, 0x0000, 0x080c, 0x6c94, 0x009e, 0x00de,
+	0x0804, 0xae5f, 0x0026, 0x0036, 0x0056, 0x0066, 0x0096, 0x00a6,
+	0x00f6, 0x0006, 0x080c, 0x0fff, 0x000e, 0x090c, 0x0dd5, 0xa960,
+	0x21e8, 0xa95c, 0x9188, 0x0019, 0x21a0, 0x900e, 0x20a9, 0x0020,
+	0x4104, 0xa87a, 0x2079, 0x1800, 0x7990, 0x9188, 0x0018, 0x918c,
+	0x0fff, 0xa972, 0xac76, 0x2950, 0x00a6, 0x2001, 0x0205, 0x2003,
+	0x0000, 0x901e, 0x2029, 0x0001, 0x9182, 0x0034, 0x1228, 0x2011,
+	0x001f, 0x080c, 0xc743, 0x04c0, 0x2130, 0x2009, 0x0034, 0x2011,
+	0x001f, 0x080c, 0xc743, 0x96b2, 0x0034, 0xb004, 0x904d, 0x0110,
+	0x080c, 0x0fb1, 0x080c, 0x0fff, 0x01d0, 0x8528, 0xa867, 0x0110,
+	0xa86b, 0x0000, 0x2920, 0xb406, 0x968a, 0x003d, 0x1230, 0x2608,
+	0x2011, 0x001b, 0x080c, 0xc743, 0x00b8, 0x96b2, 0x003c, 0x2009,
+	0x003c, 0x2950, 0x2011, 0x001b, 0x080c, 0xc743, 0x0c18, 0x2001,
+	0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566,
+	0xb070, 0xc0fd, 0xb072, 0x0048, 0x2001, 0x0205, 0x2003, 0x0000,
+	0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566, 0x2a48, 0xa804, 0xa807,
+	0x0000, 0x0006, 0x080c, 0x6c94, 0x000e, 0x2048, 0x9005, 0x1db0,
+	0x00fe, 0x00ae, 0x009e, 0x006e, 0x005e, 0x003e, 0x002e, 0x0005,
+	0x00d6, 0x00f6, 0x0096, 0x0006, 0x080c, 0x0fff, 0x000e, 0x090c,
 	0x0dd5, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019, 0x21a0, 0x900e,
-	0x20a9, 0x0020, 0x4104, 0xa87a, 0x2079, 0x1800, 0x7990, 0x9188,
-	0x0018, 0x918c, 0x0fff, 0xa972, 0xac76, 0x2950, 0x00a6, 0x2001,
-	0x0205, 0x2003, 0x0000, 0x901e, 0x2029, 0x0001, 0x9182, 0x0034,
-	0x1228, 0x2011, 0x001f, 0x080c, 0xc743, 0x04c0, 0x2130, 0x2009,
-	0x0034, 0x2011, 0x001f, 0x080c, 0xc743, 0x96b2, 0x0034, 0xb004,
-	0x904d, 0x0110, 0x080c, 0x0fb1, 0x080c, 0x0fff, 0x01d0, 0x8528,
-	0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406, 0x968a, 0x003d,
-	0x1230, 0x2608, 0x2011, 0x001b, 0x080c, 0xc743, 0x00b8, 0x96b2,
-	0x003c, 0x2009, 0x003c, 0x2950, 0x2011, 0x001b, 0x080c, 0xc743,
-	0x0c18, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad,
-	0x0050, 0xb566, 0xb070, 0xc0fd, 0xb072, 0x0048, 0x2001, 0x0205,
-	0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566, 0x2a48,
-	0xa804, 0xa807, 0x0000, 0x0006, 0x080c, 0x6c86, 0x000e, 0x2048,
-	0x9005, 0x1db0, 0x00fe, 0x00ae, 0x009e, 0x006e, 0x005e, 0x003e,
-	0x002e, 0x0005, 0x00d6, 0x00f6, 0x0096, 0x0006, 0x080c, 0x0fff,
-	0x000e, 0x090c, 0x0dd5, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019,
-	0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104, 0xaa66, 0xa87a, 0x2079,
-	0x1800, 0x7990, 0x810c, 0x9188, 0x000c, 0x9182, 0x001a, 0x0210,
-	0x2009, 0x001a, 0x21a8, 0x810b, 0xa972, 0xac76, 0x2e98, 0xa85c,
-	0x9080, 0x001f, 0x20a0, 0x2001, 0x0205, 0x200c, 0x918d, 0x0080,
-	0x2102, 0x4003, 0x2003, 0x0000, 0x080c, 0x6c86, 0x009e, 0x00fe,
-	0x00de, 0x0005, 0x0016, 0x00d6, 0x00f6, 0x0096, 0x0016, 0x2001,
-	0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x001e, 0x2079, 0x0200,
-	0x2e98, 0xa87c, 0xd0ec, 0x0118, 0x9e80, 0x000c, 0x2098, 0x2021,
-	0x003e, 0x901e, 0x9282, 0x0020, 0x0218, 0x2011, 0x0020, 0x2018,
-	0x9486, 0x003e, 0x1170, 0x0096, 0x080c, 0x0fff, 0x2900, 0x009e,
-	0x05c0, 0xa806, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
-	0x20a0, 0x3300, 0x908e, 0x0260, 0x0140, 0x2009, 0x0280, 0x9102,
-	0x920a, 0x0218, 0x2010, 0x2100, 0x9318, 0x2200, 0x9402, 0x1228,
-	0x2400, 0x9202, 0x2410, 0x9318, 0x9006, 0x2020, 0x22a8, 0xa800,
-	0x9200, 0xa802, 0x20e1, 0x0000, 0x4003, 0x83ff, 0x0180, 0x3300,
-	0x9086, 0x0280, 0x1130, 0x7814, 0x8000, 0x9085, 0x0080, 0x7816,
-	0x2e98, 0x2310, 0x84ff, 0x0904, 0xb1df, 0x0804, 0xb1e1, 0x9085,
-	0x0001, 0x7817, 0x0000, 0x009e, 0x00fe, 0x00de, 0x001e, 0x0005,
-	0x00d6, 0x0036, 0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x080c,
-	0x6c7a, 0x009e, 0x003e, 0x00de, 0x0005, 0x91b6, 0x0015, 0x1118,
-	0x080c, 0xae71, 0x0030, 0x91b6, 0x0016, 0x190c, 0x0dd5, 0x080c,
-	0xae71, 0x0005, 0x20a9, 0x000e, 0x20e1, 0x0000, 0x2e98, 0x6014,
-	0x0096, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x20a0, 0x009e, 0x4003,
-	0x0136, 0x9080, 0x001b, 0x20a0, 0x2011, 0x0006, 0x20a9, 0x0001,
-	0x3418, 0x8318, 0x23a0, 0x4003, 0x3318, 0x8318, 0x2398, 0x8211,
-	0x1db8, 0x2011, 0x0006, 0x013e, 0x20a0, 0x3318, 0x8318, 0x2398,
-	0x4003, 0x3418, 0x8318, 0x23a0, 0x8211, 0x1db8, 0x0096, 0x080c,
-	0xcb4a, 0x0130, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0x009e, 0x0804, 0xae71, 0x0096, 0x00d6, 0x0036, 0x7330, 0x9386,
-	0x0200, 0x11a8, 0x6010, 0x00b6, 0x2058, 0xb8cf, 0x0000, 0x00be,
-	0x6014, 0x9005, 0x0130, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xab32, 0x080c, 0xae71, 0x003e, 0x00de, 0x009e, 0x0005, 0x0011,
-	0x1d48, 0x0cc8, 0x0006, 0x0016, 0x080c, 0xd24a, 0x0188, 0x6014,
-	0x9005, 0x1170, 0x600b, 0x0003, 0x601b, 0x0000, 0x6043, 0x0000,
-	0x2009, 0x0022, 0x080c, 0xb668, 0x9006, 0x001e, 0x000e, 0x0005,
-	0x9085, 0x0001, 0x0cd0, 0x0096, 0x0016, 0x20a9, 0x0014, 0x9e80,
-	0x000c, 0x20e1, 0x0000, 0x2098, 0x6014, 0x2048, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x2001, 0x0205, 0x2003,
-	0x0001, 0x2099, 0x0260, 0x20a9, 0x0016, 0x4003, 0x20a9, 0x000a,
-	0xa804, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0,
-	0x4003, 0x2001, 0x0205, 0x2003, 0x0002, 0x2099, 0x0260, 0x20a9,
-	0x0020, 0x4003, 0x2003, 0x0000, 0x6014, 0x2048, 0xa800, 0x2048,
-	0xa867, 0x0103, 0x080c, 0xae71, 0x001e, 0x009e, 0x0005, 0x0096,
-	0x0016, 0x900e, 0x7030, 0x9086, 0x0100, 0x0140, 0x7038, 0x9084,
-	0x00ff, 0x800c, 0x703c, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0004,
-	0x9108, 0x810b, 0x2011, 0x0002, 0x2019, 0x000c, 0x6014, 0x2048,
-	0x080c, 0xc743, 0x080c, 0xcb4a, 0x0140, 0x6014, 0x2048, 0xa807,
-	0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0xae71, 0x001e,
-	0x009e, 0x0005, 0x0016, 0x2009, 0x0000, 0x7030, 0x9086, 0x0200,
-	0x0110, 0x2009, 0x0001, 0x0096, 0x6014, 0x904d, 0x090c, 0x0dd5,
-	0xa97a, 0x080c, 0x6c86, 0x009e, 0x080c, 0xae71, 0x001e, 0x0005,
-	0x0016, 0x0096, 0x7030, 0x9086, 0x0100, 0x1118, 0x2009, 0x0004,
-	0x0010, 0x7034, 0x800c, 0x810b, 0x2011, 0x000c, 0x2019, 0x000c,
-	0x6014, 0x2048, 0xa804, 0x0096, 0x9005, 0x0108, 0x2048, 0x080c,
-	0xc743, 0x009e, 0x080c, 0xcb4a, 0x0148, 0xa804, 0x9005, 0x1158,
-	0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0xae71,
-	0x009e, 0x001e, 0x0005, 0x0086, 0x2040, 0xa030, 0x8007, 0x9086,
-	0x0100, 0x1118, 0x080c, 0xb824, 0x00e0, 0xa034, 0x8007, 0x800c,
-	0x8806, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
-	0x000c, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xaaa0,
-	0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x1243, 0x0019,
-	0x0d08, 0x008e, 0x0898, 0x0096, 0x0006, 0x080c, 0x0fff, 0x000e,
-	0x01b0, 0xa8ab, 0x0dcb, 0xa876, 0x000e, 0xa8a2, 0x0006, 0xae6a,
-	0x2800, 0xa89e, 0xa97a, 0xaf72, 0xaa8e, 0xab92, 0xac96, 0xad9a,
-	0x0086, 0x2940, 0x080c, 0x10e9, 0x008e, 0x9085, 0x0001, 0x009e,
-	0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210,
-	0x00b6, 0x2258, 0xba10, 0x00be, 0x9206, 0x1520, 0x700c, 0x6210,
-	0x00b6, 0x2258, 0xba14, 0x00be, 0x9206, 0x11e0, 0x6043, 0x0000,
-	0x2c68, 0x0016, 0x2009, 0x0035, 0x080c, 0xd1c2, 0x001e, 0x1158,
-	0x622c, 0x2268, 0x2071, 0x026c, 0x6b20, 0x9386, 0x0003, 0x0130,
-	0x9386, 0x0006, 0x0128, 0x080c, 0xae71, 0x0020, 0x0039, 0x0010,
-	0x080c, 0xb49d, 0x002e, 0x00de, 0x00ee, 0x0005, 0x0096, 0x6814,
-	0x2048, 0x9186, 0x0015, 0x0904, 0xb485, 0x918e, 0x0016, 0x1904,
-	0xb49b, 0x700c, 0x908c, 0xff00, 0x9186, 0x1700, 0x0120, 0x9186,
-	0x0300, 0x1904, 0xb45f, 0x89ff, 0x1138, 0x6800, 0x9086, 0x000f,
-	0x0904, 0xb442, 0x0804, 0xb499, 0x6808, 0x9086, 0xffff, 0x1904,
-	0xb487, 0xa87c, 0x9084, 0x0060, 0x9086, 0x0020, 0x1128, 0xa83c,
-	0xa940, 0x9105, 0x1904, 0xb487, 0x6824, 0xd0b4, 0x1904, 0xb487,
-	0x080c, 0xcd33, 0x685c, 0xa882, 0xa87c, 0xc0dc, 0xc0f4, 0xc0d4,
-	0xa87e, 0x0026, 0x900e, 0x6a18, 0x2001, 0x000a, 0x080c, 0x8f51,
-	0xa884, 0x920a, 0x0208, 0x8011, 0xaa86, 0x82ff, 0x002e, 0x1138,
-	0x00c6, 0x2d60, 0x080c, 0xc86d, 0x00ce, 0x0804, 0xb499, 0x00c6,
-	0xa868, 0xd0fc, 0x1118, 0x080c, 0x60b7, 0x0010, 0x080c, 0x64bd,
-	0x00ce, 0x1904, 0xb487, 0x00c6, 0x2d60, 0x080c, 0xae71, 0x00ce,
-	0x0804, 0xb499, 0x00c6, 0x080c, 0xaebf, 0x0198, 0x6017, 0x0000,
-	0x6810, 0x6012, 0x080c, 0xcfc4, 0x6023, 0x0003, 0x6904, 0x00c6,
-	0x2d60, 0x080c, 0xae71, 0x00ce, 0x080c, 0xaeec, 0x00ce, 0x0804,
-	0xb499, 0x2001, 0x1987, 0x2004, 0x6842, 0x00ce, 0x04d0, 0x7008,
-	0x9086, 0x000b, 0x11c8, 0x6010, 0x00b6, 0x2058, 0xb900, 0xc1bc,
-	0xb902, 0x00be, 0x00c6, 0x2d60, 0xa87b, 0x0003, 0x080c, 0xd204,
-	0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x080c, 0x90d9,
-	0x080c, 0x9687, 0x00ce, 0x00e8, 0x700c, 0x9086, 0x2a00, 0x1138,
-	0x2001, 0x1987, 0x2004, 0x6842, 0x00a0, 0x0479, 0x00a0, 0x89ff,
-	0x090c, 0x0dd5, 0x00c6, 0x00d6, 0x2d60, 0xa867, 0x0103, 0xa87b,
-	0x0003, 0x080c, 0x6aa2, 0x080c, 0xcd33, 0x080c, 0xaea2, 0x00de,
-	0x00ce, 0x080c, 0xae71, 0x009e, 0x0005, 0x9186, 0x0015, 0x1128,
-	0x2001, 0x1987, 0x2004, 0x6842, 0x0068, 0x918e, 0x0016, 0x1160,
-	0x00c6, 0x2d00, 0x2060, 0x080c, 0xe82c, 0x080c, 0x869b, 0x080c,
-	0xae71, 0x00ce, 0x080c, 0xae71, 0x0005, 0x0026, 0x0036, 0x0046,
-	0x7228, 0xacb0, 0xabac, 0xd2f4, 0x0130, 0x2001, 0x1987, 0x2004,
-	0x6842, 0x0804, 0xb517, 0x00c6, 0x2d60, 0x080c, 0xc76e, 0x00ce,
-	0x6804, 0x9086, 0x0050, 0x1168, 0x00c6, 0x2d00, 0x2060, 0x6003,
-	0x0001, 0x6007, 0x0050, 0x080c, 0x90d9, 0x080c, 0x9687, 0x00ce,
-	0x04f0, 0x6800, 0x9086, 0x000f, 0x01a8, 0x89ff, 0x090c, 0x0dd5,
-	0x6800, 0x9086, 0x0004, 0x1190, 0xa87c, 0xd0ac, 0x0178, 0xa843,
-	0x0fff, 0xa83f, 0x0fff, 0xa880, 0xc0fc, 0xa882, 0x2001, 0x0001,
-	0x6832, 0x0400, 0x2001, 0x0007, 0x6832, 0x00e0, 0xa87c, 0xd0b4,
-	0x1150, 0xd0ac, 0x0db8, 0x6824, 0xd0f4, 0x1d48, 0xa838, 0xa934,
-	0x9105, 0x0d80, 0x0c20, 0xd2ec, 0x1d68, 0x7024, 0x9306, 0x1118,
-	0x7020, 0x9406, 0x0d38, 0x7020, 0x683e, 0x7024, 0x683a, 0x2001,
-	0x0005, 0x6832, 0x080c, 0xcebb, 0x080c, 0x9687, 0x0010, 0x080c,
-	0xae71, 0x004e, 0x003e, 0x002e, 0x0005, 0x00e6, 0x00d6, 0x0026,
-	0x7008, 0x9084, 0x00ff, 0x6210, 0x00b6, 0x2258, 0xba10, 0x00be,
-	0x9206, 0x1904, 0xb582, 0x700c, 0x6210, 0x00b6, 0x2258, 0xba14,
-	0x00be, 0x9206, 0x1904, 0xb582, 0x6038, 0x2068, 0x6824, 0xc0dc,
-	0x6826, 0x6a20, 0x9286, 0x0007, 0x0904, 0xb582, 0x9286, 0x0002,
-	0x0904, 0xb582, 0x9286, 0x0000, 0x05e8, 0x6808, 0x633c, 0x9306,
-	0x15c8, 0x2071, 0x026c, 0x9186, 0x0015, 0x0570, 0x918e, 0x0016,
-	0x1100, 0x00c6, 0x6038, 0x2060, 0x6104, 0x9186, 0x004b, 0x01c0,
-	0x9186, 0x004c, 0x01a8, 0x9186, 0x004d, 0x0190, 0x9186, 0x004e,
-	0x0178, 0x9186, 0x0052, 0x0160, 0x6014, 0x0096, 0x2048, 0x080c,
-	0xcb4a, 0x090c, 0x0dd5, 0xa87b, 0x0003, 0x009e, 0x080c, 0xd204,
-	0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x080c, 0x90d9,
-	0x080c, 0x9687, 0x00ce, 0x0030, 0x6038, 0x2070, 0x2001, 0x1987,
-	0x2004, 0x7042, 0x080c, 0xae71, 0x002e, 0x00de, 0x00ee, 0x0005,
-	0x00b6, 0x0096, 0x00f6, 0x6014, 0x2048, 0x6010, 0x2058, 0x91b6,
-	0x0015, 0x0130, 0xba08, 0xbb0c, 0xbc00, 0xc48c, 0xbc02, 0x0460,
-	0x0096, 0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90, 0x0010, 0x2019,
-	0x000a, 0x20a9, 0x0004, 0x080c, 0xbe30, 0x002e, 0x003e, 0x015e,
-	0x009e, 0x1904, 0xb5f1, 0x0096, 0x0156, 0x0036, 0x0026, 0x2b48,
-	0x9e90, 0x0014, 0x2019, 0x0006, 0x20a9, 0x0004, 0x080c, 0xbe30,
-	0x002e, 0x003e, 0x015e, 0x009e, 0x15a0, 0x7238, 0xba0a, 0x733c,
-	0xbb0e, 0xbc00, 0xc48d, 0xbc02, 0xa804, 0x9005, 0x1128, 0x00fe,
-	0x009e, 0x00be, 0x0804, 0xb276, 0x0096, 0x2048, 0xaa12, 0xab16,
-	0xac0a, 0x009e, 0x8006, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
-	0xffc0, 0x9080, 0x0002, 0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8,
-	0xada4, 0x2031, 0x0000, 0x2041, 0x1243, 0x080c, 0xb38b, 0x0130,
-	0x00fe, 0x009e, 0x080c, 0xae71, 0x00be, 0x0005, 0x080c, 0xb824,
-	0x0cb8, 0x2b78, 0x00f6, 0x080c, 0x31c1, 0x080c, 0xd25f, 0x00fe,
-	0x00c6, 0x080c, 0xae1b, 0x2f00, 0x6012, 0x6017, 0x0000, 0x6023,
-	0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x2001, 0x0007, 0x080c,
-	0x6558, 0x080c, 0x6584, 0x080c, 0x9121, 0x080c, 0x9687, 0x00ce,
-	0x0804, 0xb5c4, 0x2100, 0x91b2, 0x0053, 0x1a0c, 0x0dd5, 0x91b2,
-	0x0040, 0x1a04, 0xb67a, 0x0002, 0xb668, 0xb668, 0xb65e, 0xb668,
-	0xb668, 0xb668, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c,
-	0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c,
-	0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c,
-	0xb65c, 0xb65c, 0xb65c, 0xb668, 0xb65c, 0xb668, 0xb668, 0xb65c,
-	0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65e, 0xb65c, 0xb65c, 0xb65c,
-	0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb668, 0xb668,
-	0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c, 0xb65c,
-	0xb65c, 0xb668, 0xb65c, 0xb65c, 0x080c, 0x0dd5, 0x0066, 0x00b6,
-	0x6610, 0x2658, 0xb8cc, 0xc08c, 0xb8ce, 0x00be, 0x006e, 0x0000,
-	0x6003, 0x0001, 0x6106, 0x9186, 0x0032, 0x0118, 0x080c, 0x9121,
-	0x0010, 0x080c, 0x90d9, 0x0126, 0x2091, 0x8000, 0x080c, 0x9687,
-	0x012e, 0x0005, 0x2600, 0x0002, 0xb668, 0xb668, 0xb68e, 0xb668,
-	0xb668, 0xb68e, 0xb68e, 0xb68e, 0xb68e, 0xb668, 0xb68e, 0xb668,
-	0xb68e, 0xb668, 0xb68e, 0xb68e, 0xb68e, 0xb68e, 0x080c, 0x0dd5,
-	0x6004, 0x90b2, 0x0053, 0x1a0c, 0x0dd5, 0x91b6, 0x0013, 0x0904,
-	0xb752, 0x91b6, 0x0027, 0x1904, 0xb70d, 0x080c, 0x957b, 0x6004,
-	0x080c, 0xcd3f, 0x01b0, 0x080c, 0xcd50, 0x01a8, 0x908e, 0x0021,
-	0x0904, 0xb70a, 0x908e, 0x0022, 0x1130, 0x080c, 0xb2a2, 0x0904,
-	0xb706, 0x0804, 0xb707, 0x908e, 0x003d, 0x0904, 0xb70a, 0x0804,
-	0xb700, 0x080c, 0x31ea, 0x2001, 0x0007, 0x080c, 0x6558, 0x6010,
-	0x00b6, 0x2058, 0xb9a0, 0x00be, 0x080c, 0xb824, 0x9186, 0x007e,
-	0x1148, 0x2001, 0x1837, 0x2014, 0xc285, 0x080c, 0x73a5, 0x1108,
-	0xc2ad, 0x2202, 0x0036, 0x0026, 0x2019, 0x0028, 0x2110, 0x080c,
-	0xe938, 0x002e, 0x003e, 0x0016, 0x0026, 0x0036, 0x2110, 0x2019,
-	0x0028, 0x080c, 0x927e, 0x0076, 0x903e, 0x080c, 0x9151, 0x6010,
-	0x00b6, 0x905d, 0x0100, 0x00be, 0x2c08, 0x080c, 0xe30c, 0x007e,
-	0x003e, 0x002e, 0x001e, 0x080c, 0xd25f, 0x0016, 0x080c, 0xcfbc,
-	0x080c, 0xae71, 0x001e, 0x080c, 0x32bd, 0x080c, 0x9687, 0x0030,
-	0x080c, 0xcfbc, 0x080c, 0xae71, 0x080c, 0x9687, 0x0005, 0x080c,
-	0xb824, 0x0cb0, 0x080c, 0xb860, 0x0c98, 0x9186, 0x0014, 0x1db0,
-	0x080c, 0x957b, 0x6004, 0x908e, 0x0022, 0x1118, 0x080c, 0xb2a2,
-	0x0d68, 0x080c, 0x31c1, 0x080c, 0xd25f, 0x080c, 0xcd3f, 0x1190,
-	0x080c, 0x31ea, 0x6010, 0x00b6, 0x2058, 0xb9a0, 0x00be, 0x080c,
-	0xb824, 0x9186, 0x007e, 0x1128, 0x2001, 0x1837, 0x200c, 0xc185,
-	0x2102, 0x0870, 0x080c, 0xcd50, 0x1118, 0x080c, 0xb824, 0x0840,
-	0x6004, 0x908e, 0x0032, 0x1160, 0x00e6, 0x00f6, 0x2071, 0x189e,
-	0x2079, 0x0000, 0x080c, 0x3558, 0x00fe, 0x00ee, 0x0804, 0xb700,
-	0x6004, 0x908e, 0x0021, 0x0d48, 0x908e, 0x0022, 0x090c, 0xb824,
-	0x0804, 0xb700, 0x90b2, 0x0040, 0x1a04, 0xb800, 0x2008, 0x0002,
-	0xb79a, 0xb79b, 0xb79e, 0xb7a1, 0xb7a4, 0xb7a7, 0xb798, 0xb798,
-	0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798,
-	0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798,
-	0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb7aa, 0xb7b5,
-	0xb798, 0xb7b7, 0xb7b5, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798,
-	0xb7b5, 0xb7b5, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798, 0xb798,
-	0xb798, 0xb798, 0xb7e7, 0xb7b5, 0xb798, 0xb7b1, 0xb798, 0xb798,
-	0xb798, 0xb7b2, 0xb798, 0xb798, 0xb798, 0xb7b5, 0xb7de, 0xb798,
-	0x080c, 0x0dd5, 0x00d0, 0x2001, 0x000b, 0x0410, 0x2001, 0x0003,
-	0x00f8, 0x2001, 0x0005, 0x00e0, 0x2001, 0x0001, 0x00c8, 0x2001,
-	0x0009, 0x00b0, 0x080c, 0x957b, 0x6003, 0x0005, 0x080c, 0x9687,
-	0x0070, 0x0018, 0x0010, 0x080c, 0x6558, 0x0804, 0xb7f8, 0x080c,
-	0x957b, 0x080c, 0xd262, 0x6003, 0x0004, 0x080c, 0x9687, 0x0005,
-	0x080c, 0x6558, 0x080c, 0x957b, 0x6003, 0x0002, 0x0036, 0x2019,
-	0x1852, 0x2304, 0x9084, 0xff00, 0x1120, 0x2001, 0x1985, 0x201c,
-	0x0040, 0x8007, 0x909a, 0x0004, 0x0ec0, 0x8003, 0x801b, 0x831b,
-	0x9318, 0x631a, 0x003e, 0x080c, 0x9687, 0x0c08, 0x080c, 0x957b,
-	0x080c, 0xcfbc, 0x080c, 0xae71, 0x080c, 0x9687, 0x08c0, 0x00e6,
-	0x00f6, 0x2071, 0x189e, 0x2079, 0x0000, 0x080c, 0x3558, 0x00fe,
-	0x00ee, 0x080c, 0x957b, 0x080c, 0xae71, 0x080c, 0x9687, 0x0838,
-	0x080c, 0x957b, 0x6003, 0x0002, 0x080c, 0xd262, 0x0804, 0x9687,
-	0x2600, 0x2008, 0x0002, 0xb817, 0xb7f8, 0xb815, 0xb7f8, 0xb7f8,
-	0xb815, 0xb815, 0xb815, 0xb815, 0xb7f8, 0xb815, 0xb7f8, 0xb815,
-	0xb7f8, 0xb815, 0xb815, 0xb815, 0xb815, 0x080c, 0x0dd5, 0x080c,
-	0x957b, 0x0096, 0x6014, 0x2048, 0x080c, 0x6c86, 0x009e, 0x080c,
-	0xae71, 0x080c, 0x9687, 0x0005, 0x00e6, 0x0096, 0x0026, 0x0016,
-	0x080c, 0xcb4a, 0x0568, 0x6014, 0x2048, 0xa864, 0x9086, 0x0139,
-	0x11a8, 0xa894, 0x9086, 0x0056, 0x1148, 0x080c, 0x5481, 0x0130,
-	0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x0028, 0x2001, 0x0030,
-	0x900e, 0x2011, 0x4005, 0x080c, 0xd129, 0x0090, 0xa868, 0xd0fc,
-	0x0178, 0xa807, 0x0000, 0x0016, 0x6004, 0x908e, 0x0021, 0x0168,
-	0x908e, 0x003d, 0x0150, 0x001e, 0xa867, 0x0103, 0xa833, 0x0100,
-	0x001e, 0x002e, 0x009e, 0x00ee, 0x0005, 0x001e, 0x0009, 0x0cc0,
-	0x0096, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103, 0xa823,
-	0x8001, 0x009e, 0x0005, 0x00b6, 0x6610, 0x2658, 0xb804, 0x9084,
-	0x00ff, 0x90b2, 0x000c, 0x1a0c, 0x0dd5, 0x6604, 0x96b6, 0x004d,
-	0x1120, 0x080c, 0xd048, 0x0804, 0xb8f0, 0x6604, 0x96b6, 0x0043,
-	0x1120, 0x080c, 0xd091, 0x0804, 0xb8f0, 0x6604, 0x96b6, 0x004b,
-	0x1120, 0x080c, 0xd0bd, 0x0804, 0xb8f0, 0x6604, 0x96b6, 0x0033,
-	0x1120, 0x080c, 0xcfde, 0x0804, 0xb8f0, 0x6604, 0x96b6, 0x0028,
-	0x1120, 0x080c, 0xcd8e, 0x0804, 0xb8f0, 0x6604, 0x96b6, 0x0029,
-	0x1120, 0x080c, 0xcdcf, 0x0804, 0xb8f0, 0x6604, 0x96b6, 0x001f,
-	0x1120, 0x080c, 0xb24a, 0x0804, 0xb8f0, 0x6604, 0x96b6, 0x0000,
-	0x1118, 0x080c, 0xb588, 0x04e0, 0x6604, 0x96b6, 0x0022, 0x1118,
-	0x080c, 0xb283, 0x04a8, 0x6604, 0x96b6, 0x0035, 0x1118, 0x080c,
-	0xb3a9, 0x0470, 0x6604, 0x96b6, 0x0039, 0x1118, 0x080c, 0xb51d,
-	0x0438, 0x6604, 0x96b6, 0x003d, 0x1118, 0x080c, 0xb2bb, 0x0400,
-	0x6604, 0x96b6, 0x0044, 0x1118, 0x080c, 0xb2f7, 0x00c8, 0x6604,
-	0x96b6, 0x0049, 0x1118, 0x080c, 0xb338, 0x0090, 0x6604, 0x96b6,
-	0x0041, 0x1118, 0x080c, 0xb322, 0x0058, 0x91b6, 0x0015, 0x1110,
-	0x0063, 0x0030, 0x91b6, 0x0016, 0x1128, 0x00be, 0x0804, 0xbb4c,
-	0x00be, 0x0005, 0x080c, 0xaf07, 0x0cd8, 0xb90d, 0xb910, 0xb90d,
-	0xb957, 0xb90d, 0xbac0, 0xbb59, 0xb90d, 0xb90d, 0xbb22, 0xb90d,
-	0xbb38, 0x0096, 0x601f, 0x0000, 0x6014, 0x2048, 0xa800, 0x2048,
-	0xa867, 0x0103, 0x009e, 0x0804, 0xae71, 0xa001, 0xa001, 0x0005,
-	0x00e6, 0x2071, 0x1800, 0x7090, 0x9086, 0x0074, 0x1540, 0x080c,
-	0xe2dd, 0x11b0, 0x6010, 0x00b6, 0x2058, 0x7030, 0xd08c, 0x0128,
-	0xb800, 0xd0bc, 0x0110, 0xc0c5, 0xb802, 0x00f9, 0x00be, 0x2001,
-	0x0006, 0x080c, 0x6558, 0x080c, 0x31ea, 0x080c, 0xae71, 0x0098,
-	0x2001, 0x000a, 0x080c, 0x6558, 0x080c, 0x31ea, 0x6003, 0x0001,
-	0x6007, 0x0001, 0x080c, 0x9121, 0x080c, 0x9687, 0x0020, 0x2001,
-	0x0001, 0x080c, 0xba90, 0x00ee, 0x0005, 0x00d6, 0xb800, 0xd084,
-	0x0160, 0x9006, 0x080c, 0x6544, 0x2069, 0x1847, 0x6804, 0xd0a4,
-	0x0120, 0x2001, 0x0006, 0x080c, 0x6584, 0x00de, 0x0005, 0x00b6,
-	0x0096, 0x00d6, 0x2011, 0x1824, 0x2204, 0x9086, 0x0074, 0x1904,
-	0xba65, 0x6010, 0x2058, 0xbaa0, 0x9286, 0x007e, 0x1120, 0x080c,
-	0xbca6, 0x0804, 0xb9c9, 0x080c, 0xbc9b, 0x6010, 0x2058, 0xbaa0,
-	0x9286, 0x0080, 0x1510, 0x6014, 0x9005, 0x01a8, 0x2048, 0xa864,
-	0x9084, 0x00ff, 0x9086, 0x0039, 0x1140, 0x2001, 0x0000, 0x900e,
-	0x2011, 0x4000, 0x080c, 0xd129, 0x0030, 0xa807, 0x0000, 0xa867,
-	0x0103, 0xa833, 0x0200, 0x2001, 0x0006, 0x080c, 0x6558, 0x080c,
-	0x31ea, 0x080c, 0xae71, 0x0804, 0xba6a, 0x080c, 0xba78, 0x6014,
-	0x9005, 0x0190, 0x2048, 0xa868, 0xd0f4, 0x01e8, 0xa864, 0x9084,
-	0x00ff, 0x9086, 0x0039, 0x1d08, 0x2001, 0x0000, 0x900e, 0x2011,
-	0x4000, 0x080c, 0xd129, 0x08f8, 0x080c, 0xba6e, 0x0160, 0x9006,
-	0x080c, 0x6544, 0x2001, 0x0004, 0x080c, 0x6584, 0x2001, 0x0007,
-	0x080c, 0x6558, 0x08a0, 0x2001, 0x0004, 0x080c, 0x6558, 0x6003,
-	0x0001, 0x6007, 0x0003, 0x080c, 0x9121, 0x080c, 0x9687, 0x0804,
-	0xba6a, 0xb85c, 0xd0e4, 0x01d8, 0x080c, 0xcf5e, 0x080c, 0x73a5,
-	0x0118, 0xd0dc, 0x1904, 0xb98b, 0x2011, 0x1837, 0x2204, 0xc0ad,
-	0x2012, 0x2001, 0x196c, 0x2004, 0x00f6, 0x2079, 0x0100, 0x78e3,
-	0x0000, 0x080c, 0x28b4, 0x78e2, 0x00fe, 0x0804, 0xb98b, 0x080c,
-	0xcf9b, 0x2011, 0x1837, 0x2204, 0xc0a5, 0x2012, 0x0006, 0x080c,
-	0xe462, 0x000e, 0x1904, 0xb98b, 0xc0b5, 0x2012, 0x2001, 0x0006,
-	0x080c, 0x6558, 0x9006, 0x080c, 0x6544, 0x00c6, 0x2001, 0x180f,
-	0x2004, 0xd09c, 0x0520, 0x00f6, 0x2079, 0x0100, 0x00e6, 0x2071,
-	0x1800, 0x700c, 0x9084, 0x00ff, 0x78e6, 0x707e, 0x7010, 0x78ea,
-	0x7082, 0x908c, 0x00ff, 0x00ee, 0x780c, 0xc0b5, 0x780e, 0x00fe,
-	0x080c, 0x2889, 0x00f6, 0x2100, 0x900e, 0x080c, 0x2840, 0x795e,
-	0x00fe, 0x9186, 0x0081, 0x01d8, 0x2009, 0x0081, 0x00c8, 0x2009,
-	0x00ef, 0x00f6, 0x2079, 0x0100, 0x79ea, 0x7932, 0x7936, 0x780c,
-	0xc0b5, 0x780e, 0x00fe, 0x080c, 0x2889, 0x00f6, 0x2079, 0x1800,
-	0x7982, 0x2100, 0x900e, 0x080c, 0x2840, 0x795e, 0x00fe, 0x8108,
-	0x080c, 0x65a7, 0x2b00, 0x00ce, 0x1904, 0xb98b, 0x6012, 0x2009,
-	0x180f, 0x210c, 0xd19c, 0x0150, 0x2009, 0x027c, 0x210c, 0x918c,
-	0x00ff, 0xb912, 0x2009, 0x027d, 0x210c, 0xb916, 0x2001, 0x0002,
-	0x080c, 0x6558, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002,
-	0x080c, 0x9121, 0x080c, 0x9687, 0x0028, 0x080c, 0xb824, 0x2001,
-	0x0001, 0x0431, 0x00de, 0x009e, 0x00be, 0x0005, 0x2001, 0x1810,
-	0x2004, 0xd0a4, 0x0120, 0x2001, 0x1848, 0x2004, 0xd0ac, 0x0005,
-	0x00e6, 0x080c, 0xe991, 0x0190, 0x2071, 0x0260, 0x7108, 0x720c,
-	0x918c, 0x00ff, 0x1118, 0x9284, 0xff00, 0x0140, 0x6010, 0x2058,
-	0xb8a0, 0x9084, 0xff80, 0x1110, 0xb912, 0xba16, 0x00ee, 0x0005,
-	0x2030, 0x9005, 0x0158, 0x2001, 0x0007, 0x080c, 0x6558, 0x080c,
-	0x56ec, 0x1120, 0x2001, 0x0007, 0x080c, 0x6584, 0x2600, 0x9005,
-	0x11b0, 0x6014, 0x0096, 0x2048, 0xa868, 0x009e, 0xd0fc, 0x1178,
-	0x0036, 0x0046, 0x6010, 0x00b6, 0x2058, 0xbba0, 0x00be, 0x2021,
-	0x0004, 0x2011, 0x8014, 0x080c, 0x4b14, 0x004e, 0x003e, 0x080c,
-	0x31ea, 0x6020, 0x9086, 0x000a, 0x1108, 0x0005, 0x0804, 0xae71,
-	0x00b6, 0x00e6, 0x0026, 0x0016, 0x2071, 0x1800, 0x7090, 0x9086,
-	0x0014, 0x1904, 0xbb18, 0x080c, 0x56ec, 0x1170, 0x6014, 0x9005,
-	0x1158, 0x0036, 0x0046, 0x6010, 0x2058, 0xbba0, 0x2021, 0x0006,
-	0x080c, 0x4ccb, 0x004e, 0x003e, 0x00d6, 0x6010, 0x2058, 0x080c,
-	0x66a3, 0x080c, 0xb945, 0x00de, 0x080c, 0xbd6c, 0x1588, 0x6010,
-	0x2058, 0xb890, 0x9005, 0x0560, 0x2001, 0x0006, 0x080c, 0x6558,
-	0x0096, 0x6014, 0x904d, 0x01d0, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x20a9, 0x0020, 0x4104, 0xaa66, 0xa87a, 0x2079, 0x1800, 0x7990,
+	0x810c, 0x9188, 0x000c, 0x9182, 0x001a, 0x0210, 0x2009, 0x001a,
+	0x21a8, 0x810b, 0xa972, 0xac76, 0x2e98, 0xa85c, 0x9080, 0x001f,
+	0x20a0, 0x2001, 0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x4003,
+	0x2003, 0x0000, 0x080c, 0x6c94, 0x009e, 0x00fe, 0x00de, 0x0005,
+	0x0016, 0x00d6, 0x00f6, 0x0096, 0x0016, 0x2001, 0x0205, 0x200c,
+	0x918d, 0x0080, 0x2102, 0x001e, 0x2079, 0x0200, 0x2e98, 0xa87c,
+	0xd0ec, 0x0118, 0x9e80, 0x000c, 0x2098, 0x2021, 0x003e, 0x901e,
+	0x9282, 0x0020, 0x0218, 0x2011, 0x0020, 0x2018, 0x9486, 0x003e,
+	0x1170, 0x0096, 0x080c, 0x0fff, 0x2900, 0x009e, 0x05c0, 0xa806,
+	0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x3300,
+	0x908e, 0x0260, 0x0140, 0x2009, 0x0280, 0x9102, 0x920a, 0x0218,
+	0x2010, 0x2100, 0x9318, 0x2200, 0x9402, 0x1228, 0x2400, 0x9202,
+	0x2410, 0x9318, 0x9006, 0x2020, 0x22a8, 0xa800, 0x9200, 0xa802,
+	0x20e1, 0x0000, 0x4003, 0x83ff, 0x0180, 0x3300, 0x9086, 0x0280,
+	0x1130, 0x7814, 0x8000, 0x9085, 0x0080, 0x7816, 0x2e98, 0x2310,
+	0x84ff, 0x0904, 0xb1cd, 0x0804, 0xb1cf, 0x9085, 0x0001, 0x7817,
+	0x0000, 0x009e, 0x00fe, 0x00de, 0x001e, 0x0005, 0x00d6, 0x0036,
+	0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x080c, 0x6c88, 0x009e,
+	0x003e, 0x00de, 0x0005, 0x91b6, 0x0015, 0x1118, 0x080c, 0xae5f,
+	0x0030, 0x91b6, 0x0016, 0x190c, 0x0dd5, 0x080c, 0xae5f, 0x0005,
+	0x20a9, 0x000e, 0x20e1, 0x0000, 0x2e98, 0x6014, 0x0096, 0x2048,
+	0xa860, 0x20e8, 0xa85c, 0x20a0, 0x009e, 0x4003, 0x0136, 0x9080,
+	0x001b, 0x20a0, 0x2011, 0x0006, 0x20a9, 0x0001, 0x3418, 0x8318,
+	0x23a0, 0x4003, 0x3318, 0x8318, 0x2398, 0x8211, 0x1db8, 0x2011,
+	0x0006, 0x013e, 0x20a0, 0x3318, 0x8318, 0x2398, 0x4003, 0x3418,
+	0x8318, 0x23a0, 0x8211, 0x1db8, 0x0096, 0x080c, 0xcb5a, 0x0130,
+	0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103, 0x009e, 0x0804,
+	0xae5f, 0x0096, 0x00d6, 0x0036, 0x7330, 0x9386, 0x0200, 0x11a8,
+	0x6010, 0x00b6, 0x2058, 0xb8cf, 0x0000, 0x00be, 0x6014, 0x9005,
+	0x0130, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103, 0xab32, 0x080c,
+	0xae5f, 0x003e, 0x00de, 0x009e, 0x0005, 0x0011, 0x1d48, 0x0cc8,
+	0x0006, 0x0016, 0x080c, 0xd25a, 0x0188, 0x6014, 0x9005, 0x1170,
+	0x600b, 0x0003, 0x601b, 0x0000, 0x6043, 0x0000, 0x2009, 0x0022,
+	0x080c, 0xb663, 0x9006, 0x001e, 0x000e, 0x0005, 0x9085, 0x0001,
+	0x0cd0, 0x0096, 0x0016, 0x20a9, 0x0014, 0x9e80, 0x000c, 0x20e1,
+	0x0000, 0x2098, 0x6014, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0002, 0x20a0, 0x4003, 0x2001, 0x0205, 0x2003, 0x0001, 0x2099,
+	0x0260, 0x20a9, 0x0016, 0x4003, 0x20a9, 0x000a, 0xa804, 0x2048,
+	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x2001,
+	0x0205, 0x2003, 0x0002, 0x2099, 0x0260, 0x20a9, 0x0020, 0x4003,
+	0x2003, 0x0000, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103,
+	0x080c, 0xae5f, 0x001e, 0x009e, 0x0005, 0x0096, 0x0016, 0x900e,
+	0x7030, 0x9086, 0x0100, 0x0140, 0x7038, 0x9084, 0x00ff, 0x800c,
+	0x703c, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0004, 0x9108, 0x810b,
+	0x2011, 0x0002, 0x2019, 0x000c, 0x6014, 0x2048, 0x080c, 0xc743,
+	0x080c, 0xcb5a, 0x0140, 0x6014, 0x2048, 0xa807, 0x0000, 0xa864,
+	0xa8e2, 0xa867, 0x0103, 0x080c, 0xae5f, 0x001e, 0x009e, 0x0005,
+	0x0016, 0x2009, 0x0000, 0x7030, 0x9086, 0x0200, 0x0110, 0x2009,
+	0x0001, 0x0096, 0x6014, 0x904d, 0x090c, 0x0dd5, 0xa97a, 0x080c,
+	0x6c94, 0x009e, 0x080c, 0xae5f, 0x001e, 0x0005, 0x0016, 0x0096,
+	0x7030, 0x9086, 0x0100, 0x1118, 0x2009, 0x0004, 0x0010, 0x7034,
+	0x800c, 0x810b, 0x2011, 0x000c, 0x2019, 0x000c, 0x6014, 0x2048,
+	0xa804, 0x0096, 0x9005, 0x0108, 0x2048, 0x080c, 0xc743, 0x009e,
+	0x080c, 0xcb5a, 0x0148, 0xa804, 0x9005, 0x1158, 0xa807, 0x0000,
+	0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0xae5f, 0x009e, 0x001e,
+	0x0005, 0x0086, 0x2040, 0xa030, 0x8007, 0x9086, 0x0100, 0x1118,
+	0x080c, 0xb821, 0x00e0, 0xa034, 0x8007, 0x800c, 0x8806, 0x8006,
+	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x000c, 0xa87b,
+	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xaaa0, 0xab9c, 0xaca8,
+	0xada4, 0x2031, 0x0000, 0x2041, 0x1243, 0x0019, 0x0d08, 0x008e,
+	0x0898, 0x0096, 0x0006, 0x080c, 0x0fff, 0x000e, 0x01b0, 0xa8ab,
+	0x0dcb, 0xa876, 0x000e, 0xa8a2, 0x0006, 0xae6a, 0x2800, 0xa89e,
+	0xa97a, 0xaf72, 0xaa8e, 0xab92, 0xac96, 0xad9a, 0x0086, 0x2940,
+	0x080c, 0x10e9, 0x008e, 0x9085, 0x0001, 0x009e, 0x0005, 0x00e6,
+	0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210, 0x00b6, 0x2258,
+	0xba10, 0x00be, 0x9206, 0x1520, 0x700c, 0x6210, 0x00b6, 0x2258,
+	0xba14, 0x00be, 0x9206, 0x11e0, 0x6043, 0x0000, 0x2c68, 0x0016,
+	0x2009, 0x0035, 0x080c, 0xd1d2, 0x001e, 0x1158, 0x622c, 0x2268,
+	0x2071, 0x026c, 0x6b20, 0x9386, 0x0003, 0x0130, 0x9386, 0x0006,
+	0x0128, 0x080c, 0xae5f, 0x0020, 0x0039, 0x0010, 0x080c, 0xb498,
+	0x002e, 0x00de, 0x00ee, 0x0005, 0x0096, 0x6814, 0x2048, 0x9186,
+	0x0015, 0x0904, 0xb480, 0x918e, 0x0016, 0x1904, 0xb496, 0x700c,
+	0x908c, 0xff00, 0x9186, 0x1700, 0x0120, 0x9186, 0x0300, 0x1904,
+	0xb45a, 0x89ff, 0x1138, 0x6800, 0x9086, 0x000f, 0x0904, 0xb43d,
+	0x0804, 0xb494, 0x6808, 0x9086, 0xffff, 0x1904, 0xb482, 0xa87c,
+	0x9084, 0x0060, 0x9086, 0x0020, 0x1128, 0xa83c, 0xa940, 0x9105,
+	0x1904, 0xb482, 0x6824, 0xd084, 0x1904, 0xb482, 0xd0b4, 0x0158,
+	0x0016, 0x2001, 0x1985, 0x200c, 0x6018, 0x9102, 0x9082, 0x0005,
+	0x001e, 0x1a04, 0xb482, 0x080c, 0xcd43, 0x685c, 0xa882, 0xa87c,
+	0xc0dc, 0xc0f4, 0xc0d4, 0xa87e, 0x0026, 0x900e, 0x6a18, 0x2001,
+	0x000a, 0x080c, 0x8f70, 0xa884, 0x920a, 0x0208, 0x8011, 0xaa86,
+	0x82ff, 0x002e, 0x1138, 0x00c6, 0x2d60, 0x080c, 0xc86d, 0x00ce,
+	0x0804, 0xb494, 0x00c6, 0xa868, 0xd0fc, 0x1118, 0x080c, 0x60c1,
+	0x0010, 0x080c, 0x64cb, 0x00ce, 0x1904, 0xb482, 0x00c6, 0x2d60,
+	0x080c, 0xae5f, 0x00ce, 0x0804, 0xb494, 0x00c6, 0x080c, 0xaead,
+	0x0198, 0x6017, 0x0000, 0x6810, 0x6012, 0x080c, 0xcfd4, 0x6023,
+	0x0003, 0x6904, 0x00c6, 0x2d60, 0x080c, 0xae5f, 0x00ce, 0x080c,
+	0xaeda, 0x00ce, 0x0804, 0xb494, 0x2001, 0x1987, 0x2004, 0x6842,
+	0x00ce, 0x04d0, 0x7008, 0x9086, 0x000b, 0x11c8, 0x6010, 0x00b6,
+	0x2058, 0xb900, 0xc1bc, 0xb902, 0x00be, 0x00c6, 0x2d60, 0xa87b,
+	0x0003, 0x080c, 0xd214, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
+	0x0002, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x00ce, 0x00e8, 0x700c,
+	0x9086, 0x2a00, 0x1138, 0x2001, 0x1987, 0x2004, 0x6842, 0x00a0,
+	0x0479, 0x00a0, 0x89ff, 0x090c, 0x0dd5, 0x00c6, 0x00d6, 0x2d60,
+	0xa867, 0x0103, 0xa87b, 0x0003, 0x080c, 0x6ab0, 0x080c, 0xcd43,
+	0x080c, 0xae90, 0x00de, 0x00ce, 0x080c, 0xae5f, 0x009e, 0x0005,
+	0x9186, 0x0015, 0x1128, 0x2001, 0x1987, 0x2004, 0x6842, 0x0068,
+	0x918e, 0x0016, 0x1160, 0x00c6, 0x2d00, 0x2060, 0x080c, 0xe846,
+	0x080c, 0x86b8, 0x080c, 0xae5f, 0x00ce, 0x080c, 0xae5f, 0x0005,
+	0x0026, 0x0036, 0x0046, 0x7228, 0xacb0, 0xabac, 0xd2f4, 0x0130,
+	0x2001, 0x1987, 0x2004, 0x6842, 0x0804, 0xb512, 0x00c6, 0x2d60,
+	0x080c, 0xc76e, 0x00ce, 0x6804, 0x9086, 0x0050, 0x1168, 0x00c6,
+	0x2d00, 0x2060, 0x6003, 0x0001, 0x6007, 0x0050, 0x080c, 0x90f8,
+	0x080c, 0x96a6, 0x00ce, 0x04f0, 0x6800, 0x9086, 0x000f, 0x01a8,
+	0x89ff, 0x090c, 0x0dd5, 0x6800, 0x9086, 0x0004, 0x1190, 0xa87c,
+	0xd0ac, 0x0178, 0xa843, 0x0fff, 0xa83f, 0x0fff, 0xa880, 0xc0fc,
+	0xa882, 0x2001, 0x0001, 0x6832, 0x0400, 0x2001, 0x0007, 0x6832,
+	0x00e0, 0xa87c, 0xd0b4, 0x1150, 0xd0ac, 0x0db8, 0x6824, 0xd0f4,
+	0x1d48, 0xa838, 0xa934, 0x9105, 0x0d80, 0x0c20, 0xd2ec, 0x1d68,
+	0x7024, 0x9306, 0x1118, 0x7020, 0x9406, 0x0d38, 0x7020, 0x683e,
+	0x7024, 0x683a, 0x2001, 0x0005, 0x6832, 0x080c, 0xcecb, 0x080c,
+	0x96a6, 0x0010, 0x080c, 0xae5f, 0x004e, 0x003e, 0x002e, 0x0005,
+	0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210, 0x00b6,
+	0x2258, 0xba10, 0x00be, 0x9206, 0x1904, 0xb57d, 0x700c, 0x6210,
+	0x00b6, 0x2258, 0xba14, 0x00be, 0x9206, 0x1904, 0xb57d, 0x6038,
+	0x2068, 0x6824, 0xc0dc, 0x6826, 0x6a20, 0x9286, 0x0007, 0x0904,
+	0xb57d, 0x9286, 0x0002, 0x0904, 0xb57d, 0x9286, 0x0000, 0x05e8,
+	0x6808, 0x633c, 0x9306, 0x15c8, 0x2071, 0x026c, 0x9186, 0x0015,
+	0x0570, 0x918e, 0x0016, 0x1100, 0x00c6, 0x6038, 0x2060, 0x6104,
+	0x9186, 0x004b, 0x01c0, 0x9186, 0x004c, 0x01a8, 0x9186, 0x004d,
+	0x0190, 0x9186, 0x004e, 0x0178, 0x9186, 0x0052, 0x0160, 0x6014,
+	0x0096, 0x2048, 0x080c, 0xcb5a, 0x090c, 0x0dd5, 0xa87b, 0x0003,
+	0x009e, 0x080c, 0xd214, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
+	0x0002, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x00ce, 0x0030, 0x6038,
+	0x2070, 0x2001, 0x1987, 0x2004, 0x7042, 0x080c, 0xae5f, 0x002e,
+	0x00de, 0x00ee, 0x0005, 0x00b6, 0x0096, 0x00f6, 0x6014, 0x2048,
+	0x6010, 0x2058, 0x91b6, 0x0015, 0x0130, 0xba08, 0xbb0c, 0xbc00,
+	0xc48c, 0xbc02, 0x0460, 0x0096, 0x0156, 0x0036, 0x0026, 0x2b48,
+	0x9e90, 0x0010, 0x2019, 0x000a, 0x20a9, 0x0004, 0x080c, 0xbe2d,
+	0x002e, 0x003e, 0x015e, 0x009e, 0x1904, 0xb5ec, 0x0096, 0x0156,
+	0x0036, 0x0026, 0x2b48, 0x9e90, 0x0014, 0x2019, 0x0006, 0x20a9,
+	0x0004, 0x080c, 0xbe2d, 0x002e, 0x003e, 0x015e, 0x009e, 0x15a0,
+	0x7238, 0xba0a, 0x733c, 0xbb0e, 0xbc00, 0xc48d, 0xbc02, 0xa804,
+	0x9005, 0x1128, 0x00fe, 0x009e, 0x00be, 0x0804, 0xb264, 0x0096,
+	0x2048, 0xaa12, 0xab16, 0xac0a, 0x009e, 0x8006, 0x8006, 0x8007,
+	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009, 0x002b,
+	0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x1243,
+	0x080c, 0xb379, 0x0130, 0x00fe, 0x009e, 0x080c, 0xae5f, 0x00be,
+	0x0005, 0x080c, 0xb821, 0x0cb8, 0x2b78, 0x00f6, 0x080c, 0x31cc,
+	0x080c, 0xd26f, 0x00fe, 0x00c6, 0x080c, 0xae09, 0x2f00, 0x6012,
+	0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001,
+	0x2001, 0x0007, 0x080c, 0x6566, 0x080c, 0x6592, 0x080c, 0x9140,
+	0x080c, 0x96a6, 0x00ce, 0x0804, 0xb5bf, 0x2100, 0x91b2, 0x0053,
+	0x1a0c, 0x0dd5, 0x91b2, 0x0040, 0x1a04, 0xb675, 0x0002, 0xb663,
+	0xb663, 0xb659, 0xb663, 0xb663, 0xb663, 0xb657, 0xb657, 0xb657,
+	0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657,
+	0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657,
+	0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb663, 0xb657,
+	0xb663, 0xb663, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb659,
+	0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657,
+	0xb657, 0xb663, 0xb663, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657,
+	0xb657, 0xb657, 0xb657, 0xb657, 0xb663, 0xb657, 0xb657, 0x080c,
+	0x0dd5, 0x0066, 0x00b6, 0x6610, 0x2658, 0xb8cc, 0xc08c, 0xb8ce,
+	0x00be, 0x006e, 0x0000, 0x6003, 0x0001, 0x6106, 0x9186, 0x0032,
+	0x0118, 0x080c, 0x9140, 0x0010, 0x080c, 0x90f8, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x96a6, 0x012e, 0x0005, 0x2600, 0x0002, 0xb663,
+	0xb663, 0xb689, 0xb663, 0xb663, 0xb689, 0xb689, 0xb689, 0xb689,
+	0xb663, 0xb689, 0xb663, 0xb689, 0xb663, 0xb689, 0xb689, 0xb689,
+	0xb689, 0x080c, 0x0dd5, 0x6004, 0x90b2, 0x0053, 0x1a0c, 0x0dd5,
+	0x91b6, 0x0013, 0x0904, 0xb74d, 0x91b6, 0x0027, 0x1904, 0xb708,
+	0x080c, 0x959a, 0x6004, 0x080c, 0xcd4f, 0x01b0, 0x080c, 0xcd60,
+	0x01a8, 0x908e, 0x0021, 0x0904, 0xb705, 0x908e, 0x0022, 0x1130,
+	0x080c, 0xb290, 0x0904, 0xb701, 0x0804, 0xb702, 0x908e, 0x003d,
+	0x0904, 0xb705, 0x0804, 0xb6fb, 0x080c, 0x31f5, 0x2001, 0x0007,
+	0x080c, 0x6566, 0x6010, 0x00b6, 0x2058, 0xb9a0, 0x00be, 0x080c,
+	0xb821, 0x9186, 0x007e, 0x1148, 0x2001, 0x1837, 0x2014, 0xc285,
+	0x080c, 0x73b3, 0x1108, 0xc2ad, 0x2202, 0x0036, 0x0026, 0x2019,
+	0x0028, 0x2110, 0x080c, 0xe952, 0x002e, 0x003e, 0x0016, 0x0026,
+	0x0036, 0x2110, 0x2019, 0x0028, 0x080c, 0x929d, 0x0076, 0x903e,
+	0x080c, 0x9170, 0x6010, 0x00b6, 0x905d, 0x0100, 0x00be, 0x2c08,
+	0x080c, 0xe326, 0x007e, 0x003e, 0x002e, 0x001e, 0x080c, 0xd26f,
+	0x0016, 0x080c, 0xcfcc, 0x080c, 0xae5f, 0x001e, 0x080c, 0x32c8,
+	0x080c, 0x96a6, 0x0030, 0x080c, 0xcfcc, 0x080c, 0xae5f, 0x080c,
+	0x96a6, 0x0005, 0x080c, 0xb821, 0x0cb0, 0x080c, 0xb85d, 0x0c98,
+	0x9186, 0x0014, 0x1db0, 0x080c, 0x959a, 0x6004, 0x908e, 0x0022,
+	0x1118, 0x080c, 0xb290, 0x0d68, 0x080c, 0x31cc, 0x080c, 0xd26f,
+	0x080c, 0xcd4f, 0x1190, 0x080c, 0x31f5, 0x6010, 0x00b6, 0x2058,
+	0xb9a0, 0x00be, 0x080c, 0xb821, 0x9186, 0x007e, 0x1128, 0x2001,
+	0x1837, 0x200c, 0xc185, 0x2102, 0x0870, 0x080c, 0xcd60, 0x1118,
+	0x080c, 0xb821, 0x0840, 0x6004, 0x908e, 0x0032, 0x1160, 0x00e6,
+	0x00f6, 0x2071, 0x189e, 0x2079, 0x0000, 0x080c, 0x3563, 0x00fe,
+	0x00ee, 0x0804, 0xb6fb, 0x6004, 0x908e, 0x0021, 0x0d48, 0x908e,
+	0x0022, 0x090c, 0xb821, 0x0804, 0xb6fb, 0x90b2, 0x0040, 0x1a04,
+	0xb7fd, 0x2008, 0x0002, 0xb795, 0xb796, 0xb799, 0xb79c, 0xb79f,
+	0xb7a2, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793,
+	0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793,
+	0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb793,
+	0xb793, 0xb7a5, 0xb7b2, 0xb793, 0xb7b4, 0xb7b2, 0xb793, 0xb793,
+	0xb793, 0xb793, 0xb793, 0xb7b2, 0xb7b2, 0xb793, 0xb793, 0xb793,
+	0xb793, 0xb793, 0xb793, 0xb793, 0xb793, 0xb7e4, 0xb7b2, 0xb793,
+	0xb7ae, 0xb793, 0xb793, 0xb793, 0xb7af, 0xb793, 0xb793, 0xb793,
+	0xb7b2, 0xb7db, 0xb793, 0x080c, 0x0dd5, 0x00e0, 0x2001, 0x000b,
+	0x0420, 0x2001, 0x0003, 0x0408, 0x2001, 0x0005, 0x00f0, 0x2001,
+	0x0001, 0x00d8, 0x2001, 0x0009, 0x00c0, 0x080c, 0x959a, 0x6003,
+	0x0005, 0x080c, 0xd272, 0x080c, 0x96a6, 0x0070, 0x0018, 0x0010,
+	0x080c, 0x6566, 0x0804, 0xb7f5, 0x080c, 0x959a, 0x080c, 0xd272,
+	0x6003, 0x0004, 0x080c, 0x96a6, 0x0005, 0x080c, 0x6566, 0x080c,
+	0x959a, 0x6003, 0x0002, 0x0036, 0x2019, 0x1852, 0x2304, 0x9084,
+	0xff00, 0x1120, 0x2001, 0x1985, 0x201c, 0x0040, 0x8007, 0x909a,
+	0x0004, 0x0ec0, 0x8003, 0x801b, 0x831b, 0x9318, 0x631a, 0x003e,
+	0x080c, 0x96a6, 0x0c08, 0x080c, 0x959a, 0x080c, 0xcfcc, 0x080c,
+	0xae5f, 0x080c, 0x96a6, 0x08c0, 0x00e6, 0x00f6, 0x2071, 0x189e,
+	0x2079, 0x0000, 0x080c, 0x3563, 0x00fe, 0x00ee, 0x080c, 0x959a,
+	0x080c, 0xae5f, 0x080c, 0x96a6, 0x0838, 0x080c, 0x959a, 0x6003,
+	0x0002, 0x080c, 0xd272, 0x0804, 0x96a6, 0x2600, 0x2008, 0x0002,
+	0xb814, 0xb7f5, 0xb812, 0xb7f5, 0xb7f5, 0xb812, 0xb812, 0xb812,
+	0xb812, 0xb7f5, 0xb812, 0xb7f5, 0xb812, 0xb7f5, 0xb812, 0xb812,
+	0xb812, 0xb812, 0x080c, 0x0dd5, 0x080c, 0x959a, 0x0096, 0x6014,
+	0x2048, 0x080c, 0x6c94, 0x009e, 0x080c, 0xae5f, 0x080c, 0x96a6,
+	0x0005, 0x00e6, 0x0096, 0x0026, 0x0016, 0x080c, 0xcb5a, 0x0568,
+	0x6014, 0x2048, 0xa864, 0x9086, 0x0139, 0x11a8, 0xa894, 0x9086,
+	0x0056, 0x1148, 0x080c, 0x548b, 0x0130, 0x2001, 0x0000, 0x900e,
+	0x2011, 0x4000, 0x0028, 0x2001, 0x0030, 0x900e, 0x2011, 0x4005,
+	0x080c, 0xd139, 0x0090, 0xa868, 0xd0fc, 0x0178, 0xa807, 0x0000,
+	0x0016, 0x6004, 0x908e, 0x0021, 0x0168, 0x908e, 0x003d, 0x0150,
+	0x001e, 0xa867, 0x0103, 0xa833, 0x0100, 0x001e, 0x002e, 0x009e,
+	0x00ee, 0x0005, 0x001e, 0x0009, 0x0cc0, 0x0096, 0x6014, 0x2048,
+	0xa800, 0x2048, 0xa867, 0x0103, 0xa823, 0x8001, 0x009e, 0x0005,
+	0x00b6, 0x6610, 0x2658, 0xb804, 0x9084, 0x00ff, 0x90b2, 0x000c,
+	0x1a0c, 0x0dd5, 0x6604, 0x96b6, 0x004d, 0x1120, 0x080c, 0xd058,
+	0x0804, 0xb8ed, 0x6604, 0x96b6, 0x0043, 0x1120, 0x080c, 0xd0a1,
+	0x0804, 0xb8ed, 0x6604, 0x96b6, 0x004b, 0x1120, 0x080c, 0xd0cd,
+	0x0804, 0xb8ed, 0x6604, 0x96b6, 0x0033, 0x1120, 0x080c, 0xcfee,
+	0x0804, 0xb8ed, 0x6604, 0x96b6, 0x0028, 0x1120, 0x080c, 0xcd9e,
+	0x0804, 0xb8ed, 0x6604, 0x96b6, 0x0029, 0x1120, 0x080c, 0xcddf,
+	0x0804, 0xb8ed, 0x6604, 0x96b6, 0x001f, 0x1120, 0x080c, 0xb238,
+	0x0804, 0xb8ed, 0x6604, 0x96b6, 0x0000, 0x1118, 0x080c, 0xb583,
+	0x04e0, 0x6604, 0x96b6, 0x0022, 0x1118, 0x080c, 0xb271, 0x04a8,
+	0x6604, 0x96b6, 0x0035, 0x1118, 0x080c, 0xb397, 0x0470, 0x6604,
+	0x96b6, 0x0039, 0x1118, 0x080c, 0xb518, 0x0438, 0x6604, 0x96b6,
+	0x003d, 0x1118, 0x080c, 0xb2a9, 0x0400, 0x6604, 0x96b6, 0x0044,
+	0x1118, 0x080c, 0xb2e5, 0x00c8, 0x6604, 0x96b6, 0x0049, 0x1118,
+	0x080c, 0xb326, 0x0090, 0x6604, 0x96b6, 0x0041, 0x1118, 0x080c,
+	0xb310, 0x0058, 0x91b6, 0x0015, 0x1110, 0x0063, 0x0030, 0x91b6,
+	0x0016, 0x1128, 0x00be, 0x0804, 0xbb49, 0x00be, 0x0005, 0x080c,
+	0xaef5, 0x0cd8, 0xb90a, 0xb90d, 0xb90a, 0xb954, 0xb90a, 0xbabd,
+	0xbb56, 0xb90a, 0xb90a, 0xbb1f, 0xb90a, 0xbb35, 0x0096, 0x601f,
+	0x0000, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103, 0x009e,
+	0x0804, 0xae5f, 0xa001, 0xa001, 0x0005, 0x00e6, 0x2071, 0x1800,
+	0x7090, 0x9086, 0x0074, 0x1540, 0x080c, 0xe2f7, 0x11b0, 0x6010,
+	0x00b6, 0x2058, 0x7030, 0xd08c, 0x0128, 0xb800, 0xd0bc, 0x0110,
+	0xc0c5, 0xb802, 0x00f9, 0x00be, 0x2001, 0x0006, 0x080c, 0x6566,
+	0x080c, 0x31f5, 0x080c, 0xae5f, 0x0098, 0x2001, 0x000a, 0x080c,
+	0x6566, 0x080c, 0x31f5, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c,
+	0x9140, 0x080c, 0x96a6, 0x0020, 0x2001, 0x0001, 0x080c, 0xba8d,
+	0x00ee, 0x0005, 0x00d6, 0xb800, 0xd084, 0x0160, 0x9006, 0x080c,
+	0x6552, 0x2069, 0x1847, 0x6804, 0xd0a4, 0x0120, 0x2001, 0x0006,
+	0x080c, 0x6592, 0x00de, 0x0005, 0x00b6, 0x0096, 0x00d6, 0x2011,
+	0x1824, 0x2204, 0x9086, 0x0074, 0x1904, 0xba62, 0x6010, 0x2058,
+	0xbaa0, 0x9286, 0x007e, 0x1120, 0x080c, 0xbca3, 0x0804, 0xb9c6,
+	0x080c, 0xbc98, 0x6010, 0x2058, 0xbaa0, 0x9286, 0x0080, 0x1510,
+	0x6014, 0x9005, 0x01a8, 0x2048, 0xa864, 0x9084, 0x00ff, 0x9086,
 	0x0039, 0x1140, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x080c,
-	0xd129, 0x0060, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0029, 0x0130,
-	0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0x0200, 0x009e, 0x080c,
-	0x31ea, 0x6020, 0x9086, 0x000a, 0x0140, 0x080c, 0xae71, 0x0028,
-	0x080c, 0xb824, 0x9006, 0x080c, 0xba90, 0x001e, 0x002e, 0x00ee,
-	0x00be, 0x0005, 0x2011, 0x1824, 0x2204, 0x9086, 0x0014, 0x1160,
-	0x2001, 0x0002, 0x080c, 0x6558, 0x6003, 0x0001, 0x6007, 0x0001,
-	0x080c, 0x9121, 0x0804, 0x9687, 0x2001, 0x0001, 0x0804, 0xba90,
-	0x2030, 0x2011, 0x1824, 0x2204, 0x9086, 0x0004, 0x1148, 0x96b6,
-	0x000b, 0x1120, 0x2001, 0x0007, 0x080c, 0x6558, 0x0804, 0xae71,
-	0x2001, 0x0001, 0x0804, 0xba90, 0x0002, 0xb90d, 0xbb64, 0xb90d,
-	0xbba5, 0xb90d, 0xbc52, 0xbb59, 0xb90d, 0xb90d, 0xbc66, 0xb90d,
-	0xbc78, 0x6604, 0x9686, 0x0003, 0x0904, 0xbac0, 0x96b6, 0x001e,
-	0x1110, 0x080c, 0xae71, 0x0005, 0x00b6, 0x00d6, 0x00c6, 0x080c,
-	0xbc8a, 0x11a0, 0x9006, 0x080c, 0x6544, 0x080c, 0x31c1, 0x080c,
-	0xd25f, 0x2001, 0x0002, 0x080c, 0x6558, 0x6003, 0x0001, 0x6007,
-	0x0002, 0x080c, 0x9121, 0x080c, 0x9687, 0x0418, 0x2009, 0x026e,
-	0x2104, 0x9086, 0x0009, 0x1160, 0x6010, 0x2058, 0xb840, 0x9084,
-	0x00ff, 0x9005, 0x0170, 0x8001, 0xb842, 0x601b, 0x000a, 0x0088,
-	0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086, 0x1900, 0x1108,
-	0x08a0, 0x080c, 0x31c1, 0x080c, 0xd25f, 0x2001, 0x0001, 0x080c,
-	0xba90, 0x00ce, 0x00de, 0x00be, 0x0005, 0x0096, 0x00b6, 0x0026,
-	0x9016, 0x080c, 0xbc98, 0x00d6, 0x2069, 0x197b, 0x2d04, 0x9005,
-	0x0168, 0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e, 0x1138, 0x2069,
-	0x1820, 0x2d04, 0x8000, 0x206a, 0x00de, 0x0010, 0x00de, 0x0088,
-	0x9006, 0x080c, 0x6544, 0x2001, 0x0002, 0x080c, 0x6558, 0x6003,
-	0x0001, 0x6007, 0x0002, 0x080c, 0x9121, 0x080c, 0x9687, 0x0804,
-	0xbc22, 0x080c, 0xcb4a, 0x01b0, 0x6014, 0x2048, 0xa864, 0x2010,
-	0x9086, 0x0139, 0x1138, 0x6007, 0x0016, 0x2001, 0x0002, 0x080c,
-	0xd183, 0x00b0, 0x6014, 0x2048, 0xa864, 0xd0fc, 0x0118, 0x2001,
-	0x0001, 0x0ca8, 0x2001, 0x180e, 0x2004, 0xd0dc, 0x0148, 0x6010,
-	0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x1110, 0x9006, 0x0c38,
-	0x080c, 0xb824, 0x2009, 0x026e, 0x2134, 0x96b4, 0x00ff, 0x9686,
-	0x0005, 0x0520, 0x9686, 0x000b, 0x01c8, 0x2009, 0x026f, 0x2104,
-	0x9084, 0xff00, 0x1118, 0x9686, 0x0009, 0x01c0, 0x9086, 0x1900,
-	0x1168, 0x9686, 0x0009, 0x0190, 0x2001, 0x0004, 0x080c, 0x6558,
-	0x2001, 0x0028, 0x601a, 0x6007, 0x0052, 0x0020, 0x2001, 0x0001,
-	0x080c, 0xba90, 0x002e, 0x00be, 0x009e, 0x0005, 0x9286, 0x0139,
-	0x0160, 0x6014, 0x2048, 0x080c, 0xcb4a, 0x0140, 0xa864, 0x9086,
-	0x0139, 0x0118, 0xa868, 0xd0fc, 0x0108, 0x0c40, 0x6010, 0x2058,
-	0xb840, 0x9084, 0x00ff, 0x9005, 0x0138, 0x8001, 0xb842, 0x601b,
-	0x000a, 0x6007, 0x0016, 0x08f0, 0xb8a0, 0x9086, 0x007e, 0x1138,
-	0x00e6, 0x2071, 0x1800, 0x080c, 0x5fb6, 0x00ee, 0x0010, 0x080c,
-	0x31c1, 0x0860, 0x080c, 0xbc98, 0x1160, 0x2001, 0x0004, 0x080c,
-	0x6558, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c, 0x9121, 0x0804,
-	0x9687, 0x080c, 0xb824, 0x9006, 0x0804, 0xba90, 0x0489, 0x1160,
-	0x2001, 0x0008, 0x080c, 0x6558, 0x6003, 0x0001, 0x6007, 0x0005,
-	0x080c, 0x9121, 0x0804, 0x9687, 0x2001, 0x0001, 0x0804, 0xba90,
-	0x00f9, 0x1160, 0x2001, 0x000a, 0x080c, 0x6558, 0x6003, 0x0001,
-	0x6007, 0x0001, 0x080c, 0x9121, 0x0804, 0x9687, 0x2001, 0x0001,
-	0x0804, 0xba90, 0x2009, 0x026e, 0x2104, 0x9086, 0x0003, 0x1138,
-	0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086, 0x2a00, 0x0005,
-	0x9085, 0x0001, 0x0005, 0x00b6, 0x00c6, 0x0016, 0x6110, 0x2158,
-	0x080c, 0x6617, 0x001e, 0x00ce, 0x00be, 0x0005, 0x00b6, 0x00f6,
-	0x00e6, 0x00d6, 0x0036, 0x0016, 0x6010, 0x2058, 0x2009, 0x1837,
-	0x2104, 0x9085, 0x0003, 0x200a, 0x080c, 0xbd3e, 0x0560, 0x2009,
-	0x1837, 0x2104, 0xc0cd, 0x200a, 0x080c, 0x6977, 0x0158, 0x9006,
-	0x2020, 0x2009, 0x002a, 0x080c, 0xe5cf, 0x2001, 0x180c, 0x200c,
-	0xc195, 0x2102, 0x2019, 0x002a, 0x2009, 0x0001, 0x080c, 0x318c,
-	0x00e6, 0x2071, 0x1800, 0x080c, 0x2f98, 0x00ee, 0x00c6, 0x0156,
-	0x20a9, 0x0781, 0x2009, 0x007f, 0x080c, 0x32bd, 0x8108, 0x1f04,
-	0xbcdc, 0x015e, 0x00ce, 0x080c, 0xbc9b, 0x2071, 0x0260, 0x2079,
-	0x0200, 0x7817, 0x0001, 0x2001, 0x1837, 0x200c, 0xc1c5, 0x7018,
-	0xd0fc, 0x0110, 0xd0dc, 0x0118, 0x7038, 0xd0dc, 0x1108, 0xc1c4,
-	0x7817, 0x0000, 0x2001, 0x1837, 0x2102, 0x2079, 0x0100, 0x2e04,
-	0x9084, 0x00ff, 0x2069, 0x181f, 0x206a, 0x78e6, 0x0006, 0x8e70,
-	0x2e04, 0x2069, 0x1820, 0x206a, 0x78ea, 0x7832, 0x7836, 0x2010,
-	0x9084, 0xff00, 0x001e, 0x9105, 0x2009, 0x182c, 0x200a, 0x2200,
-	0x9084, 0x00ff, 0x2008, 0x080c, 0x2889, 0x080c, 0x73a5, 0x0170,
-	0x2071, 0x0260, 0x2069, 0x1981, 0x7048, 0x206a, 0x704c, 0x6806,
-	0x7050, 0x680a, 0x7054, 0x680e, 0x080c, 0xcf5e, 0x0040, 0x2001,
-	0x0006, 0x080c, 0x6558, 0x080c, 0x31ea, 0x080c, 0xae71, 0x001e,
-	0x003e, 0x00de, 0x00ee, 0x00fe, 0x00be, 0x0005, 0x0096, 0x0026,
-	0x0036, 0x00e6, 0x0156, 0x2019, 0x182c, 0x231c, 0x83ff, 0x01f0,
-	0x2071, 0x0260, 0x7200, 0x9294, 0x00ff, 0x7004, 0x9084, 0xff00,
-	0x9205, 0x9306, 0x1198, 0x2011, 0x0276, 0x20a9, 0x0004, 0x2b48,
-	0x2019, 0x000a, 0x080c, 0xbe30, 0x1148, 0x2011, 0x027a, 0x20a9,
-	0x0004, 0x2019, 0x0006, 0x080c, 0xbe30, 0x1100, 0x015e, 0x00ee,
-	0x003e, 0x002e, 0x009e, 0x0005, 0x00e6, 0x2071, 0x0260, 0x7034,
-	0x9086, 0x0014, 0x11a8, 0x7038, 0x9086, 0x0800, 0x1188, 0x703c,
-	0xd0ec, 0x0160, 0x9084, 0x0f00, 0x9086, 0x0100, 0x1138, 0x7054,
-	0xd0a4, 0x1110, 0xd0ac, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x00ee, 0x0005, 0x00e6, 0x0096, 0x00c6, 0x0076, 0x0056, 0x0046,
-	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2029, 0x19ef, 0x252c,
-	0x2021, 0x19f5, 0x2424, 0x2061, 0x1cd0, 0x2071, 0x1800, 0x7254,
-	0x7074, 0x9202, 0x1a04, 0xbdfc, 0x080c, 0x896a, 0x0904, 0xbdf5,
-	0x080c, 0xe600, 0x0904, 0xbdf5, 0x6720, 0x9786, 0x0007, 0x0904,
-	0xbdf5, 0x2500, 0x9c06, 0x0904, 0xbdf5, 0x2400, 0x9c06, 0x05e8,
-	0x3e08, 0x9186, 0x0002, 0x1148, 0x6010, 0x9005, 0x0130, 0x00b6,
-	0x2058, 0xb800, 0x00be, 0xd0bc, 0x1580, 0x00c6, 0x6000, 0x9086,
-	0x0004, 0x1110, 0x080c, 0x1a60, 0x9786, 0x000a, 0x0148, 0x080c,
-	0xcd50, 0x1130, 0x00ce, 0x080c, 0xb824, 0x080c, 0xaea2, 0x00e8,
-	0x6014, 0x2048, 0x080c, 0xcb4a, 0x01a8, 0x9786, 0x0003, 0x1530,
-	0xa867, 0x0103, 0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048,
-	0x080c, 0x0fb1, 0x009e, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6c7a,
-	0x080c, 0xcd33, 0x080c, 0xaea2, 0x00ce, 0x9ce0, 0x0018, 0x7068,
-	0x9c02, 0x1210, 0x0804, 0xbd9f, 0x012e, 0x000e, 0x002e, 0x004e,
-	0x005e, 0x007e, 0x00ce, 0x009e, 0x00ee, 0x0005, 0x9786, 0x0006,
-	0x1118, 0x080c, 0xe572, 0x0c30, 0x9786, 0x0009, 0x1148, 0x6000,
-	0x9086, 0x0004, 0x0d08, 0x2009, 0x004c, 0x080c, 0xaeec, 0x08e0,
-	0x9786, 0x000a, 0x0938, 0x0820, 0x220c, 0x2304, 0x9106, 0x1130,
-	0x8210, 0x8318, 0x1f04, 0xbe1c, 0x9006, 0x0005, 0x2304, 0x9102,
-	0x0218, 0x2001, 0x0001, 0x0008, 0x9006, 0x918d, 0x0001, 0x0005,
-	0x0136, 0x01c6, 0x0016, 0x8906, 0x8006, 0x8007, 0x908c, 0x003f,
-	0x21e0, 0x9084, 0xffc0, 0x9300, 0x2098, 0x3518, 0x20a9, 0x0001,
-	0x220c, 0x4002, 0x910e, 0x1140, 0x8210, 0x8319, 0x1dc8, 0x9006,
-	0x001e, 0x01ce, 0x013e, 0x0005, 0x220c, 0x9102, 0x0218, 0x2001,
-	0x0001, 0x0010, 0x2001, 0x0000, 0x918d, 0x0001, 0x001e, 0x01ce,
-	0x013e, 0x0005, 0x220c, 0x810f, 0x2304, 0x9106, 0x1130, 0x8210,
-	0x8318, 0x1f04, 0xbe5a, 0x9006, 0x0005, 0x918d, 0x0001, 0x0005,
-	0x6004, 0x908a, 0x0053, 0x1a0c, 0x0dd5, 0x080c, 0xcd3f, 0x0120,
-	0x080c, 0xcd50, 0x0168, 0x0028, 0x080c, 0x31ea, 0x080c, 0xcd50,
-	0x0138, 0x080c, 0x957b, 0x080c, 0xae71, 0x080c, 0x9687, 0x0005,
-	0x080c, 0xb824, 0x0cb0, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040,
-	0x0208, 0x000a, 0x0005, 0xbe9f, 0xbe9f, 0xbe9f, 0xbe9f, 0xbe9f,
-	0xbe9f, 0xbe9f, 0xbe9f, 0xbe9f, 0xbe9f, 0xbe9f, 0xbea1, 0xbea1,
-	0xbea1, 0xbea1, 0xbe9f, 0xbe9f, 0xbe9f, 0xbea1, 0xbe9f, 0x080c,
-	0x0dd5, 0x600b, 0xffff, 0x6003, 0x0001, 0x6106, 0x080c, 0x90d9,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x9687, 0x012e, 0x0005, 0x9186,
-	0x0013, 0x1128, 0x6004, 0x9082, 0x0040, 0x0804, 0xbf56, 0x9186,
-	0x0027, 0x1520, 0x080c, 0x957b, 0x080c, 0x31c1, 0x080c, 0xd25f,
-	0x0096, 0x6114, 0x2148, 0x080c, 0xcb4a, 0x0198, 0x080c, 0xcd50,
-	0x1118, 0x080c, 0xb824, 0x0068, 0xa867, 0x0103, 0xa87b, 0x0029,
-	0xa877, 0x0000, 0xa97c, 0xc1c5, 0xa97e, 0x080c, 0x6c86, 0x080c,
-	0xcd33, 0x009e, 0x080c, 0xae71, 0x0804, 0x9687, 0x9186, 0x0014,
-	0x1120, 0x6004, 0x9082, 0x0040, 0x04a0, 0x9186, 0x0046, 0x0150,
-	0x9186, 0x0045, 0x0138, 0x9186, 0x0053, 0x0120, 0x9186, 0x0048,
-	0x190c, 0x0dd5, 0x2001, 0x0109, 0x2004, 0xd084, 0x0508, 0x0126,
-	0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x0036, 0x00f6, 0x00e6,
-	0x00c6, 0x2079, 0x19e6, 0x2071, 0x1800, 0x2061, 0x0100, 0x080c,
-	0x8fbe, 0x00ce, 0x00ee, 0x00fe, 0x003e, 0x002e, 0x001e, 0x000e,
-	0x012e, 0xa001, 0x6000, 0x9086, 0x0002, 0x1110, 0x0804, 0xbf94,
-	0x0005, 0x0002, 0xbf30, 0xbf2e, 0xbf2e, 0xbf2e, 0xbf2e, 0xbf2e,
-	0xbf2e, 0xbf2e, 0xbf2e, 0xbf2e, 0xbf2e, 0xbf4b, 0xbf4b, 0xbf4b,
-	0xbf4b, 0xbf2e, 0xbf4b, 0xbf2e, 0xbf4b, 0xbf2e, 0x080c, 0x0dd5,
-	0x080c, 0x957b, 0x0096, 0x6114, 0x2148, 0x080c, 0xcb4a, 0x0168,
-	0xa867, 0x0103, 0xa87b, 0x0006, 0xa877, 0x0000, 0xa880, 0xc0ec,
-	0xa882, 0x080c, 0x6c86, 0x080c, 0xcd33, 0x009e, 0x080c, 0xae71,
-	0x080c, 0x9687, 0x0005, 0x080c, 0x957b, 0x080c, 0xcd50, 0x090c,
-	0xb824, 0x080c, 0xae71, 0x080c, 0x9687, 0x0005, 0x0002, 0xbf6d,
-	0xbf6b, 0xbf6b, 0xbf6b, 0xbf6b, 0xbf6b, 0xbf6b, 0xbf6b, 0xbf6b,
-	0xbf6b, 0xbf6b, 0xbf84, 0xbf84, 0xbf84, 0xbf84, 0xbf6b, 0xbf8e,
-	0xbf6b, 0xbf84, 0xbf6b, 0x080c, 0x0dd5, 0x0096, 0x080c, 0x957b,
-	0x6014, 0x2048, 0x2001, 0x1987, 0x2004, 0x6042, 0xa97c, 0xd1ac,
-	0x0140, 0x6003, 0x0004, 0xa87c, 0x9085, 0x0400, 0xa87e, 0x009e,
-	0x0005, 0x6003, 0x0002, 0x0cb8, 0x080c, 0x957b, 0x080c, 0xd262,
-	0x080c, 0xd267, 0x6003, 0x000f, 0x0804, 0x9687, 0x080c, 0x957b,
-	0x080c, 0xae71, 0x0804, 0x9687, 0x9182, 0x0054, 0x1220, 0x9182,
-	0x0040, 0x0208, 0x000a, 0x0005, 0xbfb0, 0xbfb0, 0xbfb0, 0xbfb0,
-	0xbfb0, 0xbfb2, 0xc08f, 0xbfb0, 0xc0c3, 0xbfb0, 0xbfb0, 0xbfb0,
-	0xbfb0, 0xbfb0, 0xbfb0, 0xbfb0, 0xbfb0, 0xbfb0, 0xbfb0, 0xc0c3,
-	0x080c, 0x0dd5, 0x00b6, 0x0096, 0x6114, 0x2148, 0x7644, 0x96b4,
-	0x0fff, 0x86ff, 0x1528, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904,
-	0xc07e, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0xa87c, 0xd0ac,
-	0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xc258, 0x080c, 0x6aa2,
-	0x6210, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x7044,
-	0xd0e4, 0x1904, 0xc062, 0x080c, 0xae71, 0x009e, 0x00be, 0x0005,
-	0x968c, 0x0c00, 0x0150, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904,
-	0xc066, 0x7348, 0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186,
-	0x0002, 0x0508, 0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x00e8,
-	0xd6dc, 0x01a0, 0xa87b, 0x0015, 0xa87c, 0xd0ac, 0x0170, 0xa938,
-	0xaa34, 0x2100, 0x9205, 0x0148, 0x7048, 0x9106, 0x1118, 0x704c,
-	0x9206, 0x0118, 0xa992, 0xaa8e, 0xc6dc, 0x0038, 0xd6d4, 0x0118,
-	0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76,
-	0x901e, 0xd6c4, 0x01d8, 0x9686, 0x0100, 0x1130, 0x7064, 0x9005,
-	0x1118, 0xc6c4, 0x0804, 0xbfb9, 0x735c, 0xab86, 0x83ff, 0x0170,
-	0x938a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019,
-	0x0018, 0x2011, 0x0025, 0x080c, 0xc743, 0x003e, 0xd6cc, 0x0904,
-	0xbfce, 0x7154, 0xa98a, 0x81ff, 0x0904, 0xbfce, 0x9192, 0x0021,
-	0x1278, 0x8304, 0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xc743,
-	0x2011, 0x0205, 0x2013, 0x0000, 0x080c, 0xd1ef, 0x0804, 0xbfce,
-	0xa868, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c50, 0x00a6,
-	0x2950, 0x080c, 0xc6e2, 0x00ae, 0x080c, 0xd1ef, 0x080c, 0xc733,
-	0x0804, 0xbfd0, 0x080c, 0xce48, 0x0804, 0xbfdd, 0xa87c, 0xd0ac,
-	0x0904, 0xbfe9, 0xa880, 0xd0bc, 0x1904, 0xbfe9, 0x7348, 0xa838,
-	0x9306, 0x11c8, 0x734c, 0xa834, 0x931e, 0x0904, 0xbfe9, 0xd6d4,
-	0x0190, 0xab38, 0x9305, 0x0904, 0xbfe9, 0x0068, 0xa87c, 0xd0ac,
-	0x0904, 0xbfc1, 0xa838, 0xa934, 0x9105, 0x0904, 0xbfc1, 0xa880,
-	0xd0bc, 0x1904, 0xbfc1, 0x080c, 0xce82, 0x0804, 0xbfdd, 0x0096,
-	0x00f6, 0x6003, 0x0003, 0x6007, 0x0043, 0x2079, 0x026c, 0x7c04,
-	0x7b00, 0x7e0c, 0x7d08, 0x6014, 0x2048, 0xa87c, 0xd0ac, 0x0140,
-	0x6003, 0x0002, 0x00fe, 0x009e, 0x0005, 0x2130, 0x2228, 0x0058,
-	0x2400, 0xa9ac, 0x910a, 0x2300, 0xaab0, 0x9213, 0x2600, 0x9102,
-	0x2500, 0x9203, 0x0e90, 0xac36, 0xab3a, 0xae46, 0xad4a, 0x00fe,
-	0x6043, 0x0000, 0x2c10, 0x080c, 0x1baf, 0x080c, 0x913e, 0x080c,
-	0x97b5, 0x009e, 0x0005, 0x0005, 0x9182, 0x0054, 0x1220, 0x9182,
-	0x0040, 0x0208, 0x000a, 0x0005, 0xc0e0, 0xc0e0, 0xc0e0, 0xc0e0,
-	0xc0e0, 0xc0e2, 0xc178, 0xc0e0, 0xc0e0, 0xc18f, 0xc21b, 0xc0e0,
-	0xc0e0, 0xc0e0, 0xc0e0, 0xc230, 0xc0e0, 0xc0e0, 0xc0e0, 0xc0e0,
+	0xd139, 0x0030, 0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0x0200,
+	0x2001, 0x0006, 0x080c, 0x6566, 0x080c, 0x31f5, 0x080c, 0xae5f,
+	0x0804, 0xba67, 0x080c, 0xba75, 0x6014, 0x9005, 0x0190, 0x2048,
+	0xa868, 0xd0f4, 0x01e8, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039,
+	0x1d08, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xd139,
+	0x08f8, 0x080c, 0xba6b, 0x0160, 0x9006, 0x080c, 0x6552, 0x2001,
+	0x0004, 0x080c, 0x6592, 0x2001, 0x0007, 0x080c, 0x6566, 0x08a0,
+	0x2001, 0x0004, 0x080c, 0x6566, 0x6003, 0x0001, 0x6007, 0x0003,
+	0x080c, 0x9140, 0x080c, 0x96a6, 0x0804, 0xba67, 0xb85c, 0xd0e4,
+	0x01d8, 0x080c, 0xcf6e, 0x080c, 0x73b3, 0x0118, 0xd0dc, 0x1904,
+	0xb988, 0x2011, 0x1837, 0x2204, 0xc0ad, 0x2012, 0x2001, 0x196c,
+	0x2004, 0x00f6, 0x2079, 0x0100, 0x78e3, 0x0000, 0x080c, 0x28bf,
+	0x78e2, 0x00fe, 0x0804, 0xb988, 0x080c, 0xcfab, 0x2011, 0x1837,
+	0x2204, 0xc0a5, 0x2012, 0x0006, 0x080c, 0xe47c, 0x000e, 0x1904,
+	0xb988, 0xc0b5, 0x2012, 0x2001, 0x0006, 0x080c, 0x6566, 0x9006,
+	0x080c, 0x6552, 0x00c6, 0x2001, 0x180f, 0x2004, 0xd09c, 0x0520,
+	0x00f6, 0x2079, 0x0100, 0x00e6, 0x2071, 0x1800, 0x700c, 0x9084,
+	0x00ff, 0x78e6, 0x707e, 0x7010, 0x78ea, 0x7082, 0x908c, 0x00ff,
+	0x00ee, 0x780c, 0xc0b5, 0x780e, 0x00fe, 0x080c, 0x2894, 0x00f6,
+	0x2100, 0x900e, 0x080c, 0x284b, 0x795e, 0x00fe, 0x9186, 0x0081,
+	0x01d8, 0x2009, 0x0081, 0x00c8, 0x2009, 0x00ef, 0x00f6, 0x2079,
+	0x0100, 0x79ea, 0x7932, 0x7936, 0x780c, 0xc0b5, 0x780e, 0x00fe,
+	0x080c, 0x2894, 0x00f6, 0x2079, 0x1800, 0x7982, 0x2100, 0x900e,
+	0x080c, 0x284b, 0x795e, 0x00fe, 0x8108, 0x080c, 0x65b5, 0x2b00,
+	0x00ce, 0x1904, 0xb988, 0x6012, 0x2009, 0x180f, 0x210c, 0xd19c,
+	0x0150, 0x2009, 0x027c, 0x210c, 0x918c, 0x00ff, 0xb912, 0x2009,
+	0x027d, 0x210c, 0xb916, 0x2001, 0x0002, 0x080c, 0x6566, 0x6023,
+	0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9140, 0x080c,
+	0x96a6, 0x0028, 0x080c, 0xb821, 0x2001, 0x0001, 0x0431, 0x00de,
+	0x009e, 0x00be, 0x0005, 0x2001, 0x1810, 0x2004, 0xd0a4, 0x0120,
+	0x2001, 0x1848, 0x2004, 0xd0ac, 0x0005, 0x00e6, 0x080c, 0xe9ab,
+	0x0190, 0x2071, 0x0260, 0x7108, 0x720c, 0x918c, 0x00ff, 0x1118,
+	0x9284, 0xff00, 0x0140, 0x6010, 0x2058, 0xb8a0, 0x9084, 0xff80,
+	0x1110, 0xb912, 0xba16, 0x00ee, 0x0005, 0x2030, 0x9005, 0x0158,
+	0x2001, 0x0007, 0x080c, 0x6566, 0x080c, 0x56f6, 0x1120, 0x2001,
+	0x0007, 0x080c, 0x6592, 0x2600, 0x9005, 0x11b0, 0x6014, 0x0096,
+	0x2048, 0xa868, 0x009e, 0xd0fc, 0x1178, 0x0036, 0x0046, 0x6010,
+	0x00b6, 0x2058, 0xbba0, 0x00be, 0x2021, 0x0004, 0x2011, 0x8014,
+	0x080c, 0x4b1e, 0x004e, 0x003e, 0x080c, 0x31f5, 0x6020, 0x9086,
+	0x000a, 0x1108, 0x0005, 0x0804, 0xae5f, 0x00b6, 0x00e6, 0x0026,
+	0x0016, 0x2071, 0x1800, 0x7090, 0x9086, 0x0014, 0x1904, 0xbb15,
+	0x080c, 0x56f6, 0x1170, 0x6014, 0x9005, 0x1158, 0x0036, 0x0046,
+	0x6010, 0x2058, 0xbba0, 0x2021, 0x0006, 0x080c, 0x4cd5, 0x004e,
+	0x003e, 0x00d6, 0x6010, 0x2058, 0x080c, 0x66b1, 0x080c, 0xb942,
+	0x00de, 0x080c, 0xbd69, 0x1588, 0x6010, 0x2058, 0xb890, 0x9005,
+	0x0560, 0x2001, 0x0006, 0x080c, 0x6566, 0x0096, 0x6014, 0x904d,
+	0x01d0, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140, 0x2001,
+	0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xd139, 0x0060, 0xa864,
+	0x9084, 0x00ff, 0x9086, 0x0029, 0x0130, 0xa807, 0x0000, 0xa867,
+	0x0103, 0xa833, 0x0200, 0x009e, 0x080c, 0x31f5, 0x6020, 0x9086,
+	0x000a, 0x0140, 0x080c, 0xae5f, 0x0028, 0x080c, 0xb821, 0x9006,
+	0x080c, 0xba8d, 0x001e, 0x002e, 0x00ee, 0x00be, 0x0005, 0x2011,
+	0x1824, 0x2204, 0x9086, 0x0014, 0x1160, 0x2001, 0x0002, 0x080c,
+	0x6566, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x9140, 0x0804,
+	0x96a6, 0x2001, 0x0001, 0x0804, 0xba8d, 0x2030, 0x2011, 0x1824,
+	0x2204, 0x9086, 0x0004, 0x1148, 0x96b6, 0x000b, 0x1120, 0x2001,
+	0x0007, 0x080c, 0x6566, 0x0804, 0xae5f, 0x2001, 0x0001, 0x0804,
+	0xba8d, 0x0002, 0xb90a, 0xbb61, 0xb90a, 0xbba2, 0xb90a, 0xbc4f,
+	0xbb56, 0xb90a, 0xb90a, 0xbc63, 0xb90a, 0xbc75, 0x6604, 0x9686,
+	0x0003, 0x0904, 0xbabd, 0x96b6, 0x001e, 0x1110, 0x080c, 0xae5f,
+	0x0005, 0x00b6, 0x00d6, 0x00c6, 0x080c, 0xbc87, 0x11a0, 0x9006,
+	0x080c, 0x6552, 0x080c, 0x31cc, 0x080c, 0xd26f, 0x2001, 0x0002,
+	0x080c, 0x6566, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9140,
+	0x080c, 0x96a6, 0x0418, 0x2009, 0x026e, 0x2104, 0x9086, 0x0009,
+	0x1160, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0170,
+	0x8001, 0xb842, 0x601b, 0x000a, 0x0088, 0x2009, 0x026f, 0x2104,
+	0x9084, 0xff00, 0x9086, 0x1900, 0x1108, 0x08a0, 0x080c, 0x31cc,
+	0x080c, 0xd26f, 0x2001, 0x0001, 0x080c, 0xba8d, 0x00ce, 0x00de,
+	0x00be, 0x0005, 0x0096, 0x00b6, 0x0026, 0x9016, 0x080c, 0xbc95,
+	0x00d6, 0x2069, 0x197b, 0x2d04, 0x9005, 0x0168, 0x6010, 0x2058,
+	0xb8a0, 0x9086, 0x007e, 0x1138, 0x2069, 0x1820, 0x2d04, 0x8000,
+	0x206a, 0x00de, 0x0010, 0x00de, 0x0088, 0x9006, 0x080c, 0x6552,
+	0x2001, 0x0002, 0x080c, 0x6566, 0x6003, 0x0001, 0x6007, 0x0002,
+	0x080c, 0x9140, 0x080c, 0x96a6, 0x0804, 0xbc1f, 0x080c, 0xcb5a,
+	0x01b0, 0x6014, 0x2048, 0xa864, 0x2010, 0x9086, 0x0139, 0x1138,
+	0x6007, 0x0016, 0x2001, 0x0002, 0x080c, 0xd193, 0x00b0, 0x6014,
+	0x2048, 0xa864, 0xd0fc, 0x0118, 0x2001, 0x0001, 0x0ca8, 0x2001,
+	0x180e, 0x2004, 0xd0dc, 0x0148, 0x6010, 0x2058, 0xb840, 0x9084,
+	0x00ff, 0x9005, 0x1110, 0x9006, 0x0c38, 0x080c, 0xb821, 0x2009,
+	0x026e, 0x2134, 0x96b4, 0x00ff, 0x9686, 0x0005, 0x0520, 0x9686,
+	0x000b, 0x01c8, 0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x1118,
+	0x9686, 0x0009, 0x01c0, 0x9086, 0x1900, 0x1168, 0x9686, 0x0009,
+	0x0190, 0x2001, 0x0004, 0x080c, 0x6566, 0x2001, 0x0028, 0x601a,
+	0x6007, 0x0052, 0x0020, 0x2001, 0x0001, 0x080c, 0xba8d, 0x002e,
+	0x00be, 0x009e, 0x0005, 0x9286, 0x0139, 0x0160, 0x6014, 0x2048,
+	0x080c, 0xcb5a, 0x0140, 0xa864, 0x9086, 0x0139, 0x0118, 0xa868,
+	0xd0fc, 0x0108, 0x0c40, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff,
+	0x9005, 0x0138, 0x8001, 0xb842, 0x601b, 0x000a, 0x6007, 0x0016,
+	0x08f0, 0xb8a0, 0x9086, 0x007e, 0x1138, 0x00e6, 0x2071, 0x1800,
+	0x080c, 0x5fc0, 0x00ee, 0x0010, 0x080c, 0x31cc, 0x0860, 0x080c,
+	0xbc95, 0x1160, 0x2001, 0x0004, 0x080c, 0x6566, 0x6003, 0x0001,
+	0x6007, 0x0003, 0x080c, 0x9140, 0x0804, 0x96a6, 0x080c, 0xb821,
+	0x9006, 0x0804, 0xba8d, 0x0489, 0x1160, 0x2001, 0x0008, 0x080c,
+	0x6566, 0x6003, 0x0001, 0x6007, 0x0005, 0x080c, 0x9140, 0x0804,
+	0x96a6, 0x2001, 0x0001, 0x0804, 0xba8d, 0x00f9, 0x1160, 0x2001,
+	0x000a, 0x080c, 0x6566, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c,
+	0x9140, 0x0804, 0x96a6, 0x2001, 0x0001, 0x0804, 0xba8d, 0x2009,
+	0x026e, 0x2104, 0x9086, 0x0003, 0x1138, 0x2009, 0x026f, 0x2104,
+	0x9084, 0xff00, 0x9086, 0x2a00, 0x0005, 0x9085, 0x0001, 0x0005,
+	0x00b6, 0x00c6, 0x0016, 0x6110, 0x2158, 0x080c, 0x6625, 0x001e,
+	0x00ce, 0x00be, 0x0005, 0x00b6, 0x00f6, 0x00e6, 0x00d6, 0x0036,
+	0x0016, 0x6010, 0x2058, 0x2009, 0x1837, 0x2104, 0x9085, 0x0003,
+	0x200a, 0x080c, 0xbd3b, 0x0560, 0x2009, 0x1837, 0x2104, 0xc0cd,
+	0x200a, 0x080c, 0x6985, 0x0158, 0x9006, 0x2020, 0x2009, 0x002a,
+	0x080c, 0xe5e9, 0x2001, 0x180c, 0x200c, 0xc195, 0x2102, 0x2019,
+	0x002a, 0x2009, 0x0001, 0x080c, 0x3197, 0x00e6, 0x2071, 0x1800,
+	0x080c, 0x2fa3, 0x00ee, 0x00c6, 0x0156, 0x20a9, 0x0781, 0x2009,
+	0x007f, 0x080c, 0x32c8, 0x8108, 0x1f04, 0xbcd9, 0x015e, 0x00ce,
+	0x080c, 0xbc98, 0x2071, 0x0260, 0x2079, 0x0200, 0x7817, 0x0001,
+	0x2001, 0x1837, 0x200c, 0xc1c5, 0x7018, 0xd0fc, 0x0110, 0xd0dc,
+	0x0118, 0x7038, 0xd0dc, 0x1108, 0xc1c4, 0x7817, 0x0000, 0x2001,
+	0x1837, 0x2102, 0x2079, 0x0100, 0x2e04, 0x9084, 0x00ff, 0x2069,
+	0x181f, 0x206a, 0x78e6, 0x0006, 0x8e70, 0x2e04, 0x2069, 0x1820,
+	0x206a, 0x78ea, 0x7832, 0x7836, 0x2010, 0x9084, 0xff00, 0x001e,
+	0x9105, 0x2009, 0x182c, 0x200a, 0x2200, 0x9084, 0x00ff, 0x2008,
+	0x080c, 0x2894, 0x080c, 0x73b3, 0x0170, 0x2071, 0x0260, 0x2069,
+	0x1981, 0x7048, 0x206a, 0x704c, 0x6806, 0x7050, 0x680a, 0x7054,
+	0x680e, 0x080c, 0xcf6e, 0x0040, 0x2001, 0x0006, 0x080c, 0x6566,
+	0x080c, 0x31f5, 0x080c, 0xae5f, 0x001e, 0x003e, 0x00de, 0x00ee,
+	0x00fe, 0x00be, 0x0005, 0x0096, 0x0026, 0x0036, 0x00e6, 0x0156,
+	0x2019, 0x182c, 0x231c, 0x83ff, 0x01f0, 0x2071, 0x0260, 0x7200,
+	0x9294, 0x00ff, 0x7004, 0x9084, 0xff00, 0x9205, 0x9306, 0x1198,
+	0x2011, 0x0276, 0x20a9, 0x0004, 0x2b48, 0x2019, 0x000a, 0x080c,
+	0xbe2d, 0x1148, 0x2011, 0x027a, 0x20a9, 0x0004, 0x2019, 0x0006,
+	0x080c, 0xbe2d, 0x1100, 0x015e, 0x00ee, 0x003e, 0x002e, 0x009e,
+	0x0005, 0x00e6, 0x2071, 0x0260, 0x7034, 0x9086, 0x0014, 0x11a8,
+	0x7038, 0x9086, 0x0800, 0x1188, 0x703c, 0xd0ec, 0x0160, 0x9084,
+	0x0f00, 0x9086, 0x0100, 0x1138, 0x7054, 0xd0a4, 0x1110, 0xd0ac,
+	0x0110, 0x9006, 0x0010, 0x9085, 0x0001, 0x00ee, 0x0005, 0x00e6,
+	0x0096, 0x00c6, 0x0076, 0x0056, 0x0046, 0x0026, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2029, 0x19ef, 0x252c, 0x2021, 0x19f5, 0x2424,
+	0x2061, 0x1cd0, 0x2071, 0x1800, 0x7254, 0x7074, 0x9202, 0x1a04,
+	0xbdf9, 0x080c, 0x8987, 0x0904, 0xbdf2, 0x080c, 0xe61a, 0x0904,
+	0xbdf2, 0x6720, 0x9786, 0x0007, 0x0904, 0xbdf2, 0x2500, 0x9c06,
+	0x0904, 0xbdf2, 0x2400, 0x9c06, 0x05e8, 0x3e08, 0x9186, 0x0002,
+	0x1148, 0x6010, 0x9005, 0x0130, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x1580, 0x00c6, 0x6000, 0x9086, 0x0004, 0x1110, 0x080c,
+	0x1a70, 0x9786, 0x000a, 0x0148, 0x080c, 0xcd60, 0x1130, 0x00ce,
+	0x080c, 0xb821, 0x080c, 0xae90, 0x00e8, 0x6014, 0x2048, 0x080c,
+	0xcb5a, 0x01a8, 0x9786, 0x0003, 0x1530, 0xa867, 0x0103, 0xa87c,
+	0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fb1, 0x009e,
+	0xab7a, 0xa877, 0x0000, 0x080c, 0x6c88, 0x080c, 0xcd43, 0x080c,
+	0xae90, 0x00ce, 0x9ce0, 0x0018, 0x7068, 0x9c02, 0x1210, 0x0804,
+	0xbd9c, 0x012e, 0x000e, 0x002e, 0x004e, 0x005e, 0x007e, 0x00ce,
+	0x009e, 0x00ee, 0x0005, 0x9786, 0x0006, 0x1118, 0x080c, 0xe58c,
+	0x0c30, 0x9786, 0x0009, 0x1148, 0x6000, 0x9086, 0x0004, 0x0d08,
+	0x2009, 0x004c, 0x080c, 0xaeda, 0x08e0, 0x9786, 0x000a, 0x0938,
+	0x0820, 0x220c, 0x2304, 0x9106, 0x1130, 0x8210, 0x8318, 0x1f04,
+	0xbe19, 0x9006, 0x0005, 0x2304, 0x9102, 0x0218, 0x2001, 0x0001,
+	0x0008, 0x9006, 0x918d, 0x0001, 0x0005, 0x0136, 0x01c6, 0x0016,
+	0x8906, 0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0,
+	0x9300, 0x2098, 0x3518, 0x20a9, 0x0001, 0x220c, 0x4002, 0x910e,
+	0x1140, 0x8210, 0x8319, 0x1dc8, 0x9006, 0x001e, 0x01ce, 0x013e,
+	0x0005, 0x220c, 0x9102, 0x0218, 0x2001, 0x0001, 0x0010, 0x2001,
+	0x0000, 0x918d, 0x0001, 0x001e, 0x01ce, 0x013e, 0x0005, 0x220c,
+	0x810f, 0x2304, 0x9106, 0x1130, 0x8210, 0x8318, 0x1f04, 0xbe57,
+	0x9006, 0x0005, 0x918d, 0x0001, 0x0005, 0x6004, 0x908a, 0x0053,
+	0x1a0c, 0x0dd5, 0x080c, 0xcd4f, 0x0120, 0x080c, 0xcd60, 0x0168,
+	0x0028, 0x080c, 0x31f5, 0x080c, 0xcd60, 0x0138, 0x080c, 0x959a,
+	0x080c, 0xae5f, 0x080c, 0x96a6, 0x0005, 0x080c, 0xb821, 0x0cb0,
+	0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005,
+	0xbe9c, 0xbe9c, 0xbe9c, 0xbe9c, 0xbe9c, 0xbe9c, 0xbe9c, 0xbe9c,
+	0xbe9c, 0xbe9c, 0xbe9c, 0xbe9e, 0xbe9e, 0xbe9e, 0xbe9e, 0xbe9c,
+	0xbe9c, 0xbe9c, 0xbe9e, 0xbe9c, 0x080c, 0x0dd5, 0x600b, 0xffff,
+	0x6003, 0x0001, 0x6106, 0x080c, 0x90f8, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x96a6, 0x012e, 0x0005, 0x9186, 0x0013, 0x1128, 0x6004,
+	0x9082, 0x0040, 0x0804, 0xbf53, 0x9186, 0x0027, 0x1520, 0x080c,
+	0x959a, 0x080c, 0x31cc, 0x080c, 0xd26f, 0x0096, 0x6114, 0x2148,
+	0x080c, 0xcb5a, 0x0198, 0x080c, 0xcd60, 0x1118, 0x080c, 0xb821,
+	0x0068, 0xa867, 0x0103, 0xa87b, 0x0029, 0xa877, 0x0000, 0xa97c,
+	0xc1c5, 0xa97e, 0x080c, 0x6c94, 0x080c, 0xcd43, 0x009e, 0x080c,
+	0xae5f, 0x0804, 0x96a6, 0x9186, 0x0014, 0x1120, 0x6004, 0x9082,
+	0x0040, 0x04a0, 0x9186, 0x0046, 0x0150, 0x9186, 0x0045, 0x0138,
+	0x9186, 0x0053, 0x0120, 0x9186, 0x0048, 0x190c, 0x0dd5, 0x2001,
+	0x0109, 0x2004, 0xd084, 0x0508, 0x0126, 0x2091, 0x2800, 0x0006,
+	0x0016, 0x0026, 0x0036, 0x00f6, 0x00e6, 0x00c6, 0x2079, 0x19e6,
+	0x2071, 0x1800, 0x2061, 0x0100, 0x080c, 0x8fdd, 0x00ce, 0x00ee,
+	0x00fe, 0x003e, 0x002e, 0x001e, 0x000e, 0x012e, 0xa001, 0x6000,
+	0x9086, 0x0002, 0x1110, 0x0804, 0xbf91, 0x0005, 0x0002, 0xbf2d,
+	0xbf2b, 0xbf2b, 0xbf2b, 0xbf2b, 0xbf2b, 0xbf2b, 0xbf2b, 0xbf2b,
+	0xbf2b, 0xbf2b, 0xbf48, 0xbf48, 0xbf48, 0xbf48, 0xbf2b, 0xbf48,
+	0xbf2b, 0xbf48, 0xbf2b, 0x080c, 0x0dd5, 0x080c, 0x959a, 0x0096,
+	0x6114, 0x2148, 0x080c, 0xcb5a, 0x0168, 0xa867, 0x0103, 0xa87b,
+	0x0006, 0xa877, 0x0000, 0xa880, 0xc0ec, 0xa882, 0x080c, 0x6c94,
+	0x080c, 0xcd43, 0x009e, 0x080c, 0xae5f, 0x080c, 0x96a6, 0x0005,
+	0x080c, 0x959a, 0x080c, 0xcd60, 0x090c, 0xb821, 0x080c, 0xae5f,
+	0x080c, 0x96a6, 0x0005, 0x0002, 0xbf6a, 0xbf68, 0xbf68, 0xbf68,
+	0xbf68, 0xbf68, 0xbf68, 0xbf68, 0xbf68, 0xbf68, 0xbf68, 0xbf81,
+	0xbf81, 0xbf81, 0xbf81, 0xbf68, 0xbf8b, 0xbf68, 0xbf81, 0xbf68,
+	0x080c, 0x0dd5, 0x0096, 0x080c, 0x959a, 0x6014, 0x2048, 0x2001,
+	0x1987, 0x2004, 0x6042, 0xa97c, 0xd1ac, 0x0140, 0x6003, 0x0004,
+	0xa87c, 0x9085, 0x0400, 0xa87e, 0x009e, 0x0005, 0x6003, 0x0002,
+	0x0cb8, 0x080c, 0x959a, 0x080c, 0xd272, 0x080c, 0xd277, 0x6003,
+	0x000f, 0x0804, 0x96a6, 0x080c, 0x959a, 0x080c, 0xae5f, 0x0804,
+	0x96a6, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a,
+	0x0005, 0xbfad, 0xbfad, 0xbfad, 0xbfad, 0xbfad, 0xbfaf, 0xc08c,
+	0xbfad, 0xc0c0, 0xbfad, 0xbfad, 0xbfad, 0xbfad, 0xbfad, 0xbfad,
+	0xbfad, 0xbfad, 0xbfad, 0xbfad, 0xc0c0, 0x080c, 0x0dd5, 0x00b6,
+	0x0096, 0x6114, 0x2148, 0x7644, 0x96b4, 0x0fff, 0x86ff, 0x1528,
+	0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xc07b, 0xa87b, 0x0000,
+	0xa867, 0x0103, 0xae76, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938,
+	0x9115, 0x190c, 0xc255, 0x080c, 0x6ab0, 0x6210, 0x2258, 0xba3c,
+	0x82ff, 0x0110, 0x8211, 0xba3e, 0x7044, 0xd0e4, 0x1904, 0xc05f,
+	0x080c, 0xae5f, 0x009e, 0x00be, 0x0005, 0x968c, 0x0c00, 0x0150,
+	0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xc063, 0x7348, 0xab92,
+	0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0508, 0x9186,
+	0x0028, 0x1118, 0xa87b, 0x001c, 0x00e8, 0xd6dc, 0x01a0, 0xa87b,
+	0x0015, 0xa87c, 0xd0ac, 0x0170, 0xa938, 0xaa34, 0x2100, 0x9205,
+	0x0148, 0x7048, 0x9106, 0x1118, 0x704c, 0x9206, 0x0118, 0xa992,
+	0xaa8e, 0xc6dc, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010,
+	0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0x901e, 0xd6c4, 0x01d8,
+	0x9686, 0x0100, 0x1130, 0x7064, 0x9005, 0x1118, 0xc6c4, 0x0804,
+	0xbfb6, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009, 0x0210,
+	0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011, 0x0025,
+	0x080c, 0xc743, 0x003e, 0xd6cc, 0x0904, 0xbfcb, 0x7154, 0xa98a,
+	0x81ff, 0x0904, 0xbfcb, 0x9192, 0x0021, 0x1278, 0x8304, 0x9098,
+	0x0018, 0x2011, 0x0029, 0x080c, 0xc743, 0x2011, 0x0205, 0x2013,
+	0x0000, 0x080c, 0xd1ff, 0x0804, 0xbfcb, 0xa868, 0xd0fc, 0x0120,
+	0x2009, 0x0020, 0xa98a, 0x0c50, 0x00a6, 0x2950, 0x080c, 0xc6e2,
+	0x00ae, 0x080c, 0xd1ff, 0x080c, 0xc733, 0x0804, 0xbfcd, 0x080c,
+	0xce58, 0x0804, 0xbfda, 0xa87c, 0xd0ac, 0x0904, 0xbfe6, 0xa880,
+	0xd0bc, 0x1904, 0xbfe6, 0x7348, 0xa838, 0x9306, 0x11c8, 0x734c,
+	0xa834, 0x931e, 0x0904, 0xbfe6, 0xd6d4, 0x0190, 0xab38, 0x9305,
+	0x0904, 0xbfe6, 0x0068, 0xa87c, 0xd0ac, 0x0904, 0xbfbe, 0xa838,
+	0xa934, 0x9105, 0x0904, 0xbfbe, 0xa880, 0xd0bc, 0x1904, 0xbfbe,
+	0x080c, 0xce92, 0x0804, 0xbfda, 0x0096, 0x00f6, 0x6003, 0x0003,
+	0x6007, 0x0043, 0x2079, 0x026c, 0x7c04, 0x7b00, 0x7e0c, 0x7d08,
+	0x6014, 0x2048, 0xa87c, 0xd0ac, 0x0140, 0x6003, 0x0002, 0x00fe,
+	0x009e, 0x0005, 0x2130, 0x2228, 0x0058, 0x2400, 0xa9ac, 0x910a,
+	0x2300, 0xaab0, 0x9213, 0x2600, 0x9102, 0x2500, 0x9203, 0x0e90,
+	0xac36, 0xab3a, 0xae46, 0xad4a, 0x00fe, 0x6043, 0x0000, 0x2c10,
+	0x080c, 0x1bba, 0x080c, 0x915d, 0x080c, 0x97d4, 0x009e, 0x0005,
+	0x0005, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a,
+	0x0005, 0xc0dd, 0xc0dd, 0xc0dd, 0xc0dd, 0xc0dd, 0xc0df, 0xc175,
+	0xc0dd, 0xc0dd, 0xc18c, 0xc218, 0xc0dd, 0xc0dd, 0xc0dd, 0xc0dd,
+	0xc22d, 0xc0dd, 0xc0dd, 0xc0dd, 0xc0dd, 0x080c, 0x0dd5, 0x0076,
+	0x00a6, 0x00e6, 0x0096, 0x2071, 0x0260, 0x6114, 0x2150, 0x7644,
+	0xb676, 0x96b4, 0x0fff, 0xb77c, 0xc7e5, 0xb77e, 0x6210, 0x00b6,
+	0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x86ff,
+	0x0904, 0xc170, 0x9694, 0xff00, 0x9284, 0x0c00, 0x0120, 0x7048,
+	0xb092, 0x704c, 0xb08e, 0x9284, 0x0300, 0x0904, 0xc170, 0x080c,
+	0x0fff, 0x090c, 0x0dd5, 0x2900, 0xb07a, 0xb77c, 0xc7cd, 0xb77e,
+	0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c, 0xa86e, 0xb070, 0xa872,
+	0xae76, 0x968c, 0x0c00, 0x0120, 0x7348, 0xab92, 0x734c, 0xab8e,
+	0x968c, 0x00ff, 0x9186, 0x0002, 0x0180, 0x9186, 0x0028, 0x1118,
+	0xa87b, 0x001c, 0x0060, 0xd6dc, 0x0118, 0xa87b, 0x0015, 0x0038,
+	0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000, 0xaf7e,
+	0xb080, 0xa882, 0xb084, 0xa886, 0x901e, 0xd6c4, 0x0190, 0x735c,
+	0xab86, 0x83ff, 0x0170, 0x938a, 0x0009, 0x0210, 0x2019, 0x0008,
+	0x0036, 0x2308, 0x2019, 0x0018, 0x2011, 0x0025, 0x080c, 0xc743,
+	0x003e, 0xd6cc, 0x01e8, 0x7154, 0xa98a, 0x81ff, 0x01c8, 0x9192,
+	0x0021, 0x1260, 0x8304, 0x9098, 0x0018, 0x2011, 0x0029, 0x080c,
+	0xc743, 0x2011, 0x0205, 0x2013, 0x0000, 0x0050, 0xb068, 0xd0fc,
+	0x0120, 0x2009, 0x0020, 0xa98a, 0x0c68, 0x2950, 0x080c, 0xc6e2,
+	0x009e, 0x00ee, 0x00ae, 0x007e, 0x0005, 0x00f6, 0x00a6, 0x6003,
+	0x0003, 0x2079, 0x026c, 0x7c04, 0x7b00, 0x7e0c, 0x7d08, 0x6014,
+	0x2050, 0xb436, 0xb33a, 0xb646, 0xb54a, 0x00ae, 0x00fe, 0x2c10,
+	0x080c, 0x1bba, 0x0804, 0xa25c, 0x6003, 0x0002, 0x6004, 0x9086,
+	0x0040, 0x11c8, 0x0096, 0x6014, 0x2048, 0xa87c, 0xd0ac, 0x0160,
+	0x601c, 0xd084, 0x1130, 0x00f6, 0x2c00, 0x2078, 0x080c, 0x1727,
+	0x00fe, 0x6003, 0x0004, 0x0010, 0x6003, 0x0002, 0x009e, 0x080c,
+	0x959a, 0x080c, 0x96a6, 0x0096, 0x2001, 0x1987, 0x2004, 0x6042,
+	0x080c, 0x9656, 0x080c, 0x97d4, 0x6114, 0x2148, 0xa97c, 0xd1e4,
+	0x0904, 0xc213, 0xd1cc, 0x05a8, 0xa978, 0xa868, 0xd0fc, 0x0538,
+	0x0016, 0xa87c, 0x0006, 0xa880, 0x0006, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x0019, 0x20a0, 0x810e, 0x810e, 0x810f, 0x9184, 0x003f,
+	0x20e0, 0x9184, 0xffc0, 0x9080, 0x0019, 0x2098, 0x0156, 0x20a9,
+	0x0020, 0x4003, 0x015e, 0x000e, 0xa882, 0x000e, 0xa87e, 0x001e,
+	0xa874, 0x0006, 0x2148, 0x080c, 0x0fb1, 0x001e, 0x0440, 0x0016,
+	0x080c, 0x0fb1, 0x009e, 0xa974, 0x0016, 0x080c, 0xc733, 0x001e,
+	0x00f0, 0xa867, 0x0103, 0xa974, 0x9184, 0x00ff, 0x90b6, 0x0002,
+	0x0180, 0x9086, 0x0028, 0x1118, 0xa87b, 0x001c, 0x0060, 0xd1dc,
+	0x0118, 0xa87b, 0x0015, 0x0038, 0xd1d4, 0x0118, 0xa87b, 0x0007,
+	0x0010, 0xa87b, 0x0000, 0x0016, 0x080c, 0x6ab0, 0x001e, 0xd1e4,
+	0x1120, 0x080c, 0xae5f, 0x009e, 0x0005, 0x080c, 0xce58, 0x0cd8,
+	0x6004, 0x9086, 0x0040, 0x1120, 0x080c, 0x959a, 0x080c, 0x96a6,
+	0x2019, 0x0001, 0x080c, 0xa5c8, 0x6003, 0x0002, 0x080c, 0xd277,
+	0x080c, 0x9656, 0x080c, 0x97d4, 0x0005, 0x6004, 0x9086, 0x0040,
+	0x1120, 0x080c, 0x959a, 0x080c, 0x96a6, 0x2019, 0x0001, 0x080c,
+	0xa5c8, 0x080c, 0x9656, 0x080c, 0x31cc, 0x080c, 0xd26f, 0x0096,
+	0x6114, 0x2148, 0x080c, 0xcb5a, 0x0150, 0xa867, 0x0103, 0xa87b,
+	0x0029, 0xa877, 0x0000, 0x080c, 0x6c94, 0x080c, 0xcd43, 0x009e,
+	0x080c, 0xae5f, 0x080c, 0x97d4, 0x0005, 0xa87b, 0x0015, 0xd1fc,
+	0x0180, 0xa87b, 0x0007, 0x8002, 0x8000, 0x810a, 0x9189, 0x0000,
+	0x0006, 0x0016, 0x2009, 0x1a79, 0x2104, 0x8000, 0x200a, 0x001e,
+	0x000e, 0xa992, 0xa88e, 0x0005, 0x9182, 0x0054, 0x1220, 0x9182,
+	0x0040, 0x0208, 0x000a, 0x0005, 0xc288, 0xc288, 0xc288, 0xc288,
+	0xc288, 0xc28a, 0xc288, 0xc288, 0xc330, 0xc288, 0xc288, 0xc288,
+	0xc288, 0xc288, 0xc288, 0xc288, 0xc288, 0xc288, 0xc288, 0xc461,
 	0x080c, 0x0dd5, 0x0076, 0x00a6, 0x00e6, 0x0096, 0x2071, 0x0260,
 	0x6114, 0x2150, 0x7644, 0xb676, 0x96b4, 0x0fff, 0xb77c, 0xc7e5,
 	0xb77e, 0x6210, 0x00b6, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211,
-	0xba3e, 0x00be, 0x86ff, 0x0904, 0xc173, 0x9694, 0xff00, 0x9284,
+	0xba3e, 0x00be, 0x86ff, 0x0904, 0xc329, 0x9694, 0xff00, 0x9284,
 	0x0c00, 0x0120, 0x7048, 0xb092, 0x704c, 0xb08e, 0x9284, 0x0300,
-	0x0904, 0xc173, 0x080c, 0x0fff, 0x090c, 0x0dd5, 0x2900, 0xb07a,
-	0xb77c, 0xc7cd, 0xb77e, 0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c,
-	0xa86e, 0xb070, 0xa872, 0xae76, 0x968c, 0x0c00, 0x0120, 0x7348,
-	0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0180,
-	0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x0060, 0xd6dc, 0x0118,
-	0xa87b, 0x0015, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010,
-	0xa87b, 0x0000, 0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886, 0x901e,
-	0xd6c4, 0x0190, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009,
-	0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011,
-	0x0025, 0x080c, 0xc743, 0x003e, 0xd6cc, 0x01e8, 0x7154, 0xa98a,
-	0x81ff, 0x01c8, 0x9192, 0x0021, 0x1260, 0x8304, 0x9098, 0x0018,
-	0x2011, 0x0029, 0x080c, 0xc743, 0x2011, 0x0205, 0x2013, 0x0000,
-	0x0050, 0xb068, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c68,
-	0x2950, 0x080c, 0xc6e2, 0x009e, 0x00ee, 0x00ae, 0x007e, 0x0005,
-	0x00f6, 0x00a6, 0x6003, 0x0003, 0x2079, 0x026c, 0x7c04, 0x7b00,
-	0x7e0c, 0x7d08, 0x6014, 0x2050, 0xb436, 0xb33a, 0xb646, 0xb54a,
-	0x00ae, 0x00fe, 0x2c10, 0x080c, 0x1baf, 0x0804, 0xa241, 0x6003,
-	0x0002, 0x6004, 0x9086, 0x0040, 0x11c8, 0x0096, 0x6014, 0x2048,
-	0xa87c, 0xd0ac, 0x0160, 0x601c, 0xd084, 0x1130, 0x00f6, 0x2c00,
-	0x2078, 0x080c, 0x1727, 0x00fe, 0x6003, 0x0004, 0x0010, 0x6003,
-	0x0002, 0x009e, 0x080c, 0x957b, 0x080c, 0x9687, 0x0096, 0x2001,
-	0x1987, 0x2004, 0x6042, 0x080c, 0x9637, 0x080c, 0x97b5, 0x6114,
-	0x2148, 0xa97c, 0xd1e4, 0x0904, 0xc216, 0xd1cc, 0x05a8, 0xa978,
-	0xa868, 0xd0fc, 0x0538, 0x0016, 0xa87c, 0x0006, 0xa880, 0x0006,
-	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0019, 0x20a0, 0x810e, 0x810e,
-	0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080, 0x0019,
-	0x2098, 0x0156, 0x20a9, 0x0020, 0x4003, 0x015e, 0x000e, 0xa882,
-	0x000e, 0xa87e, 0x001e, 0xa874, 0x0006, 0x2148, 0x080c, 0x0fb1,
-	0x001e, 0x0440, 0x0016, 0x080c, 0x0fb1, 0x009e, 0xa974, 0x0016,
-	0x080c, 0xc733, 0x001e, 0x00f0, 0xa867, 0x0103, 0xa974, 0x9184,
-	0x00ff, 0x90b6, 0x0002, 0x0180, 0x9086, 0x0028, 0x1118, 0xa87b,
-	0x001c, 0x0060, 0xd1dc, 0x0118, 0xa87b, 0x0015, 0x0038, 0xd1d4,
-	0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000, 0x0016, 0x080c,
-	0x6aa2, 0x001e, 0xd1e4, 0x1120, 0x080c, 0xae71, 0x009e, 0x0005,
-	0x080c, 0xce48, 0x0cd8, 0x6004, 0x9086, 0x0040, 0x1120, 0x080c,
-	0x957b, 0x080c, 0x9687, 0x2019, 0x0001, 0x080c, 0xa5b7, 0x6003,
-	0x0002, 0x080c, 0xd267, 0x080c, 0x9637, 0x080c, 0x97b5, 0x0005,
-	0x6004, 0x9086, 0x0040, 0x1120, 0x080c, 0x957b, 0x080c, 0x9687,
-	0x2019, 0x0001, 0x080c, 0xa5b7, 0x080c, 0x9637, 0x080c, 0x31c1,
-	0x080c, 0xd25f, 0x0096, 0x6114, 0x2148, 0x080c, 0xcb4a, 0x0150,
-	0xa867, 0x0103, 0xa87b, 0x0029, 0xa877, 0x0000, 0x080c, 0x6c86,
-	0x080c, 0xcd33, 0x009e, 0x080c, 0xae71, 0x080c, 0x97b5, 0x0005,
-	0xa87b, 0x0015, 0xd1fc, 0x0180, 0xa87b, 0x0007, 0x8002, 0x8000,
-	0x810a, 0x9189, 0x0000, 0x0006, 0x0016, 0x2009, 0x1a79, 0x2104,
-	0x8000, 0x200a, 0x001e, 0x000e, 0xa992, 0xa88e, 0x0005, 0x9182,
-	0x0054, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xc28b,
-	0xc28b, 0xc28b, 0xc28b, 0xc28b, 0xc28d, 0xc28b, 0xc28b, 0xc333,
-	0xc28b, 0xc28b, 0xc28b, 0xc28b, 0xc28b, 0xc28b, 0xc28b, 0xc28b,
-	0xc28b, 0xc28b, 0xc464, 0x080c, 0x0dd5, 0x0076, 0x00a6, 0x00e6,
-	0x0096, 0x2071, 0x0260, 0x6114, 0x2150, 0x7644, 0xb676, 0x96b4,
-	0x0fff, 0xb77c, 0xc7e5, 0xb77e, 0x6210, 0x00b6, 0x2258, 0xba3c,
-	0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x86ff, 0x0904, 0xc32c,
-	0x9694, 0xff00, 0x9284, 0x0c00, 0x0120, 0x7048, 0xb092, 0x704c,
-	0xb08e, 0x9284, 0x0300, 0x0904, 0xc32c, 0x9686, 0x0100, 0x1130,
-	0x7064, 0x9005, 0x1118, 0xc6c4, 0xb676, 0x0c38, 0x080c, 0x0fff,
-	0x090c, 0x0dd5, 0x2900, 0xb07a, 0xb77c, 0x97bd, 0x0200, 0xb77e,
-	0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c, 0xa86e, 0xb070, 0xa872,
-	0x7044, 0x9084, 0xf000, 0x9635, 0xae76, 0x968c, 0x0c00, 0x0120,
-	0x7348, 0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002,
-	0x0180, 0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x0060, 0xd6dc,
-	0x0118, 0xa87b, 0x0015, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007,
-	0x0010, 0xa87b, 0x0000, 0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886,
-	0x901e, 0xd6c4, 0x0190, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a,
-	0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018,
-	0x2011, 0x0025, 0x080c, 0xc743, 0x003e, 0xd6cc, 0x01e8, 0x7154,
-	0xa98a, 0x81ff, 0x01c8, 0x9192, 0x0021, 0x1260, 0x8304, 0x9098,
-	0x0018, 0x2011, 0x0029, 0x080c, 0xc743, 0x2011, 0x0205, 0x2013,
-	0x0000, 0x0050, 0xb068, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a,
-	0x0c68, 0x2950, 0x080c, 0xc6e2, 0x080c, 0x1a3e, 0x009e, 0x00ee,
-	0x00ae, 0x007e, 0x0005, 0x2001, 0x1987, 0x2004, 0x6042, 0x0096,
-	0x6114, 0x2148, 0xa83c, 0xa940, 0x9105, 0x1118, 0xa87c, 0xc0dc,
-	0xa87e, 0x6003, 0x0002, 0xa97c, 0xd1e4, 0x0904, 0xc45f, 0x6043,
-	0x0000, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1500,
-	0xd1cc, 0x0904, 0xc42e, 0xa978, 0xa868, 0xd0fc, 0x0904, 0xc3ef,
-	0x0016, 0xa87c, 0x0006, 0xa880, 0x0006, 0x00a6, 0x2150, 0xb174,
-	0x9184, 0x00ff, 0x90b6, 0x0002, 0x0904, 0xc3bd, 0x9086, 0x0028,
-	0x1904, 0xc3a9, 0xa87b, 0x001c, 0xb07b, 0x001c, 0x0804, 0xc3c5,
-	0x6024, 0xd0f4, 0x11d0, 0xa838, 0xaa34, 0x9205, 0x09c8, 0xa838,
-	0xaa90, 0x9206, 0x1120, 0xa88c, 0xaa34, 0x9206, 0x0988, 0x6024,
-	0xd0d4, 0x1148, 0xa9ac, 0xa834, 0x9102, 0x603a, 0xa9b0, 0xa838,
-	0x9103, 0x603e, 0x6024, 0xc0f5, 0x6026, 0x6010, 0x00b6, 0x2058,
-	0xb83c, 0x8000, 0xb83e, 0x00be, 0x9006, 0xa876, 0xa892, 0xa88e,
-	0xa87c, 0xc0e4, 0xa87e, 0xd0cc, 0x0140, 0xc0cc, 0xa87e, 0x0096,
-	0xa878, 0x2048, 0x080c, 0x0fb1, 0x009e, 0x080c, 0xce82, 0x0804,
-	0xc45f, 0xd1dc, 0x0158, 0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c,
-	0xd112, 0x0118, 0xb174, 0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128,
-	0xa87b, 0x0007, 0xb07b, 0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128,
-	0xa834, 0xa938, 0x9115, 0x190c, 0xc258, 0xa87c, 0xb07e, 0xa890,
-	0xb092, 0xa88c, 0xb08e, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0019,
-	0x20a0, 0x20a9, 0x0020, 0x8a06, 0x8006, 0x8007, 0x9094, 0x003f,
-	0x22e0, 0x9084, 0xffc0, 0x9080, 0x0019, 0x2098, 0x4003, 0x00ae,
-	0x000e, 0xa882, 0x000e, 0xa87e, 0x080c, 0xd1ef, 0x001e, 0xa874,
-	0x0006, 0x2148, 0x080c, 0x0fb1, 0x001e, 0x0804, 0xc45b, 0x0016,
-	0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x01e0,
-	0x9086, 0x0028, 0x1128, 0xa87b, 0x001c, 0xb07b, 0x001c, 0x00e0,
-	0xd1dc, 0x0158, 0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c, 0xd112,
-	0x0118, 0xb174, 0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b,
-	0x0007, 0xb07b, 0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834,
-	0xa938, 0x9115, 0x190c, 0xc258, 0xa890, 0xb092, 0xa88c, 0xb08e,
-	0xa87c, 0xb07e, 0x00ae, 0x080c, 0x0fb1, 0x009e, 0x080c, 0xd1ef,
-	0xa974, 0x0016, 0x080c, 0xc733, 0x001e, 0x0468, 0xa867, 0x0103,
-	0xa974, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x01b0, 0x9086, 0x0028,
-	0x1118, 0xa87b, 0x001c, 0x00d0, 0xd1dc, 0x0148, 0xa87b, 0x0015,
-	0x080c, 0xd112, 0x0118, 0xa974, 0xc1dc, 0xa976, 0x0078, 0xd1d4,
-	0x0118, 0xa87b, 0x0007, 0x0050, 0xa87b, 0x0000, 0xa87c, 0xd0ac,
-	0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xc258, 0xa974, 0x0016,
-	0x080c, 0x6aa2, 0x001e, 0xd1e4, 0x1120, 0x080c, 0xae71, 0x009e,
-	0x0005, 0x080c, 0xce48, 0x0cd8, 0x6114, 0x0096, 0x2148, 0xa97c,
-	0xd1e4, 0x190c, 0x1a4c, 0x009e, 0x0005, 0x080c, 0x957b, 0x0010,
-	0x080c, 0x9637, 0x080c, 0xcb4a, 0x01f0, 0x0096, 0x6114, 0x2148,
-	0x080c, 0xcd50, 0x1118, 0x080c, 0xb824, 0x00a0, 0xa867, 0x0103,
-	0x2009, 0x180c, 0x210c, 0xd18c, 0x11b8, 0xd184, 0x1190, 0x6108,
-	0xa97a, 0x918e, 0x0029, 0x1110, 0x080c, 0xe929, 0xa877, 0x0000,
-	0x080c, 0x6c86, 0x009e, 0x080c, 0xae71, 0x080c, 0x9687, 0x0804,
-	0x97b5, 0xa87b, 0x0004, 0x0c90, 0xa87b, 0x0004, 0x0c78, 0x9182,
-	0x0054, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xc4bb,
-	0xc4bb, 0xc4bb, 0xc4bb, 0xc4bb, 0xc4bd, 0xc4bb, 0xc4bb, 0xc4bb,
-	0xc4bb, 0xc4bb, 0xc4bb, 0xc4bb, 0xc4bb, 0xc4bb, 0xc4bb, 0xc4bb,
-	0xc4bb, 0xc4bb, 0xc4bb, 0x080c, 0x0dd5, 0x080c, 0x56e0, 0x01f8,
-	0x6014, 0x7144, 0x918c, 0x0fff, 0x9016, 0xd1c4, 0x0118, 0x7264,
-	0x9294, 0x00ff, 0x0096, 0x904d, 0x0188, 0xa87b, 0x0000, 0xa864,
-	0x9086, 0x0139, 0x0128, 0xa867, 0x0103, 0xa976, 0xaa96, 0x0030,
-	0xa897, 0x4000, 0xa99a, 0xaa9e, 0x080c, 0x6c86, 0x009e, 0x0804,
-	0xae71, 0x9182, 0x0085, 0x0002, 0xc4f3, 0xc4f1, 0xc4f1, 0xc4ff,
-	0xc4f1, 0xc4f1, 0xc4f1, 0xc4f1, 0xc4f1, 0xc4f1, 0xc4f1, 0xc4f1,
-	0xc4f1, 0x080c, 0x0dd5, 0x6003, 0x0001, 0x6106, 0x080c, 0x90d9,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x9687, 0x012e, 0x0005, 0x0026,
-	0x0056, 0x00d6, 0x00e6, 0x2071, 0x0260, 0x7224, 0x6216, 0x7220,
-	0x080c, 0xcb38, 0x01a0, 0x2268, 0x6800, 0x9086, 0x0000, 0x0178,
-	0x6010, 0x6d10, 0x952e, 0x1158, 0x00c6, 0x2d60, 0x080c, 0xc76e,
-	0x00ce, 0x0128, 0x6803, 0x0002, 0x6007, 0x0086, 0x0010, 0x6007,
-	0x0087, 0x6003, 0x0001, 0x080c, 0x90d9, 0x080c, 0x9687, 0x9280,
-	0x0004, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140, 0x6824,
-	0xd0ec, 0x0128, 0x00c6, 0x2260, 0x080c, 0xce82, 0x00ce, 0x00ee,
+	0x0904, 0xc329, 0x9686, 0x0100, 0x1130, 0x7064, 0x9005, 0x1118,
+	0xc6c4, 0xb676, 0x0c38, 0x080c, 0x0fff, 0x090c, 0x0dd5, 0x2900,
+	0xb07a, 0xb77c, 0x97bd, 0x0200, 0xb77e, 0xa867, 0x0103, 0xb068,
+	0xa86a, 0xb06c, 0xa86e, 0xb070, 0xa872, 0x7044, 0x9084, 0xf000,
+	0x9635, 0xae76, 0x968c, 0x0c00, 0x0120, 0x7348, 0xab92, 0x734c,
+	0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0180, 0x9186, 0x0028,
+	0x1118, 0xa87b, 0x001c, 0x0060, 0xd6dc, 0x0118, 0xa87b, 0x0015,
+	0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000,
+	0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886, 0x901e, 0xd6c4, 0x0190,
+	0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009, 0x0210, 0x2019,
+	0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011, 0x0025, 0x080c,
+	0xc743, 0x003e, 0xd6cc, 0x01e8, 0x7154, 0xa98a, 0x81ff, 0x01c8,
+	0x9192, 0x0021, 0x1260, 0x8304, 0x9098, 0x0018, 0x2011, 0x0029,
+	0x080c, 0xc743, 0x2011, 0x0205, 0x2013, 0x0000, 0x0050, 0xb068,
+	0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c68, 0x2950, 0x080c,
+	0xc6e2, 0x080c, 0x1a3e, 0x009e, 0x00ee, 0x00ae, 0x007e, 0x0005,
+	0x2001, 0x1987, 0x2004, 0x6042, 0x0096, 0x6114, 0x2148, 0xa83c,
+	0xa940, 0x9105, 0x1118, 0xa87c, 0xc0dc, 0xa87e, 0x6003, 0x0002,
+	0xa97c, 0xd1e4, 0x0904, 0xc45c, 0x6043, 0x0000, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x1500, 0xd1cc, 0x0904, 0xc42b,
+	0xa978, 0xa868, 0xd0fc, 0x0904, 0xc3ec, 0x0016, 0xa87c, 0x0006,
+	0xa880, 0x0006, 0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff, 0x90b6,
+	0x0002, 0x0904, 0xc3ba, 0x9086, 0x0028, 0x1904, 0xc3a6, 0xa87b,
+	0x001c, 0xb07b, 0x001c, 0x0804, 0xc3c2, 0x6024, 0xd0f4, 0x11d0,
+	0xa838, 0xaa34, 0x9205, 0x09c8, 0xa838, 0xaa90, 0x9206, 0x1120,
+	0xa88c, 0xaa34, 0x9206, 0x0988, 0x6024, 0xd0d4, 0x1148, 0xa9ac,
+	0xa834, 0x9102, 0x603a, 0xa9b0, 0xa838, 0x9103, 0x603e, 0x6024,
+	0xc0f5, 0x6026, 0x6010, 0x00b6, 0x2058, 0xb83c, 0x8000, 0xb83e,
+	0x00be, 0x9006, 0xa876, 0xa892, 0xa88e, 0xa87c, 0xc0e4, 0xa87e,
+	0xd0cc, 0x0140, 0xc0cc, 0xa87e, 0x0096, 0xa878, 0x2048, 0x080c,
+	0x0fb1, 0x009e, 0x080c, 0xce92, 0x0804, 0xc45c, 0xd1dc, 0x0158,
+	0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c, 0xd122, 0x0118, 0xb174,
+	0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b,
+	0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115,
+	0x190c, 0xc255, 0xa87c, 0xb07e, 0xa890, 0xb092, 0xa88c, 0xb08e,
+	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0019, 0x20a0, 0x20a9, 0x0020,
+	0x8a06, 0x8006, 0x8007, 0x9094, 0x003f, 0x22e0, 0x9084, 0xffc0,
+	0x9080, 0x0019, 0x2098, 0x4003, 0x00ae, 0x000e, 0xa882, 0x000e,
+	0xa87e, 0x080c, 0xd1ff, 0x001e, 0xa874, 0x0006, 0x2148, 0x080c,
+	0x0fb1, 0x001e, 0x0804, 0xc458, 0x0016, 0x00a6, 0x2150, 0xb174,
+	0x9184, 0x00ff, 0x90b6, 0x0002, 0x01e0, 0x9086, 0x0028, 0x1128,
+	0xa87b, 0x001c, 0xb07b, 0x001c, 0x00e0, 0xd1dc, 0x0158, 0xa87b,
+	0x0015, 0xb07b, 0x0015, 0x080c, 0xd122, 0x0118, 0xb174, 0xc1dc,
+	0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b, 0x0007,
+	0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c,
+	0xc255, 0xa890, 0xb092, 0xa88c, 0xb08e, 0xa87c, 0xb07e, 0x00ae,
+	0x080c, 0x0fb1, 0x009e, 0x080c, 0xd1ff, 0xa974, 0x0016, 0x080c,
+	0xc733, 0x001e, 0x0468, 0xa867, 0x0103, 0xa974, 0x9184, 0x00ff,
+	0x90b6, 0x0002, 0x01b0, 0x9086, 0x0028, 0x1118, 0xa87b, 0x001c,
+	0x00d0, 0xd1dc, 0x0148, 0xa87b, 0x0015, 0x080c, 0xd122, 0x0118,
+	0xa974, 0xc1dc, 0xa976, 0x0078, 0xd1d4, 0x0118, 0xa87b, 0x0007,
+	0x0050, 0xa87b, 0x0000, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938,
+	0x9115, 0x190c, 0xc255, 0xa974, 0x0016, 0x080c, 0x6ab0, 0x001e,
+	0xd1e4, 0x1120, 0x080c, 0xae5f, 0x009e, 0x0005, 0x080c, 0xce58,
+	0x0cd8, 0x6114, 0x0096, 0x2148, 0xa97c, 0xd1e4, 0x190c, 0x1a5c,
+	0x009e, 0x0005, 0x080c, 0x959a, 0x0010, 0x080c, 0x9656, 0x080c,
+	0xcb5a, 0x01f0, 0x0096, 0x6114, 0x2148, 0x080c, 0xcd60, 0x1118,
+	0x080c, 0xb821, 0x00a0, 0xa867, 0x0103, 0x2009, 0x180c, 0x210c,
+	0xd18c, 0x11b8, 0xd184, 0x1190, 0x6108, 0xa97a, 0x918e, 0x0029,
+	0x1110, 0x080c, 0xe943, 0xa877, 0x0000, 0x080c, 0x6c94, 0x009e,
+	0x080c, 0xae5f, 0x080c, 0x96a6, 0x0804, 0x97d4, 0xa87b, 0x0004,
+	0x0c90, 0xa87b, 0x0004, 0x0c78, 0x9182, 0x0054, 0x1220, 0x9182,
+	0x0040, 0x0208, 0x000a, 0x0005, 0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8,
+	0xc4b8, 0xc4ba, 0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8,
+	0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8, 0xc4b8,
+	0x080c, 0x0dd5, 0x080c, 0x56ea, 0x01f8, 0x6014, 0x7144, 0x918c,
+	0x0fff, 0x9016, 0xd1c4, 0x0118, 0x7264, 0x9294, 0x00ff, 0x0096,
+	0x904d, 0x0188, 0xa87b, 0x0000, 0xa864, 0x9086, 0x0139, 0x0128,
+	0xa867, 0x0103, 0xa976, 0xaa96, 0x0030, 0xa897, 0x4000, 0xa99a,
+	0xaa9e, 0x080c, 0x6c94, 0x009e, 0x0804, 0xae5f, 0x9182, 0x0085,
+	0x0002, 0xc4f0, 0xc4ee, 0xc4ee, 0xc4fc, 0xc4ee, 0xc4ee, 0xc4ee,
+	0xc4ee, 0xc4ee, 0xc4ee, 0xc4ee, 0xc4ee, 0xc4ee, 0x080c, 0x0dd5,
+	0x6003, 0x0001, 0x6106, 0x080c, 0x90f8, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x96a6, 0x012e, 0x0005, 0x0026, 0x0056, 0x00d6, 0x00e6,
+	0x2071, 0x0260, 0x7224, 0x6216, 0x7220, 0x080c, 0xcb48, 0x01a0,
+	0x2268, 0x6800, 0x9086, 0x0000, 0x0178, 0x6010, 0x6d10, 0x952e,
+	0x1158, 0x00c6, 0x2d60, 0x080c, 0xc76e, 0x00ce, 0x0128, 0x6803,
+	0x0002, 0x6007, 0x0086, 0x0010, 0x6007, 0x0087, 0x6003, 0x0001,
+	0x080c, 0x90f8, 0x080c, 0x96a6, 0x7220, 0x080c, 0xcb48, 0x0178,
+	0x6810, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140, 0x6824,
+	0xd0ec, 0x0128, 0x00c6, 0x2d60, 0x080c, 0xce92, 0x00ce, 0x00ee,
 	0x00de, 0x005e, 0x002e, 0x0005, 0x9186, 0x0013, 0x1160, 0x6004,
 	0x908a, 0x0085, 0x0a0c, 0x0dd5, 0x908a, 0x0092, 0x1a0c, 0x0dd5,
 	0x9082, 0x0085, 0x00e2, 0x9186, 0x0027, 0x0120, 0x9186, 0x0014,
-	0x190c, 0x0dd5, 0x080c, 0x957b, 0x0096, 0x6014, 0x2048, 0x080c,
-	0xcb4a, 0x0140, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0029,
-	0x080c, 0x6c86, 0x009e, 0x080c, 0xaea2, 0x0804, 0x9687, 0xc574,
+	0x190c, 0x0dd5, 0x080c, 0x959a, 0x0096, 0x6014, 0x2048, 0x080c,
+	0xcb5a, 0x0140, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0029,
+	0x080c, 0x6c94, 0x009e, 0x080c, 0xae90, 0x0804, 0x96a6, 0xc574,
 	0xc576, 0xc576, 0xc574, 0xc574, 0xc574, 0xc574, 0xc574, 0xc574,
-	0xc574, 0xc574, 0xc574, 0xc574, 0x080c, 0x0dd5, 0x080c, 0x957b,
-	0x080c, 0xaea2, 0x080c, 0x9687, 0x0005, 0x9186, 0x0013, 0x1128,
+	0xc574, 0xc574, 0xc574, 0xc574, 0x080c, 0x0dd5, 0x080c, 0x959a,
+	0x080c, 0xae90, 0x080c, 0x96a6, 0x0005, 0x9186, 0x0013, 0x1128,
 	0x6004, 0x9082, 0x0085, 0x2008, 0x04b8, 0x9186, 0x0027, 0x11f8,
-	0x080c, 0x957b, 0x080c, 0x31c1, 0x080c, 0xd25f, 0x0096, 0x6014,
-	0x2048, 0x080c, 0xcb4a, 0x0150, 0xa867, 0x0103, 0xa877, 0x0000,
-	0xa87b, 0x0029, 0x080c, 0x6c86, 0x080c, 0xcd33, 0x009e, 0x080c,
-	0xae71, 0x080c, 0x9687, 0x0005, 0x080c, 0xaf07, 0x0ce0, 0x9186,
-	0x0014, 0x1dd0, 0x080c, 0x957b, 0x0096, 0x6014, 0x2048, 0x080c,
-	0xcb4a, 0x0d60, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0006,
+	0x080c, 0x959a, 0x080c, 0x31cc, 0x080c, 0xd26f, 0x0096, 0x6014,
+	0x2048, 0x080c, 0xcb5a, 0x0150, 0xa867, 0x0103, 0xa877, 0x0000,
+	0xa87b, 0x0029, 0x080c, 0x6c94, 0x080c, 0xcd43, 0x009e, 0x080c,
+	0xae5f, 0x080c, 0x96a6, 0x0005, 0x080c, 0xaef5, 0x0ce0, 0x9186,
+	0x0014, 0x1dd0, 0x080c, 0x959a, 0x0096, 0x6014, 0x2048, 0x080c,
+	0xcb5a, 0x0d60, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0006,
 	0xa880, 0xc0ec, 0xa882, 0x08f0, 0x0002, 0xc5cc, 0xc5ca, 0xc5ca,
 	0xc5ca, 0xc5ca, 0xc5ca, 0xc5e4, 0xc5ca, 0xc5ca, 0xc5ca, 0xc5ca,
-	0xc5ca, 0xc5ca, 0x080c, 0x0dd5, 0x080c, 0x957b, 0x6034, 0x908c,
+	0xc5ca, 0xc5ca, 0x080c, 0x0dd5, 0x080c, 0x959a, 0x6034, 0x908c,
 	0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118,
 	0x2001, 0x1985, 0x0010, 0x2001, 0x1986, 0x2004, 0x601a, 0x6003,
-	0x000c, 0x080c, 0x9687, 0x0005, 0x080c, 0x957b, 0x6034, 0x908c,
+	0x000c, 0x080c, 0x96a6, 0x0005, 0x080c, 0x959a, 0x6034, 0x908c,
 	0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118,
 	0x2001, 0x1985, 0x0010, 0x2001, 0x1986, 0x2004, 0x601a, 0x6003,
-	0x000e, 0x080c, 0x9687, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182,
-	0x0085, 0x0208, 0x0012, 0x0804, 0xaf07, 0xc612, 0xc612, 0xc612,
+	0x000e, 0x080c, 0x96a6, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182,
+	0x0085, 0x0208, 0x0012, 0x0804, 0xaef5, 0xc612, 0xc612, 0xc612,
 	0xc612, 0xc614, 0xc661, 0xc612, 0xc612, 0xc612, 0xc612, 0xc612,
 	0xc612, 0xc612, 0x080c, 0x0dd5, 0x0096, 0x6010, 0x00b6, 0x2058,
 	0xb800, 0x00be, 0xd0bc, 0x0168, 0x6034, 0x908c, 0xff00, 0x810f,
 	0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x009e, 0x0804,
-	0xc675, 0x080c, 0xcb4a, 0x1118, 0x080c, 0xcd33, 0x0068, 0x6014,
-	0x2048, 0xa87c, 0xd0e4, 0x1110, 0x080c, 0xcd33, 0xa867, 0x0103,
-	0x080c, 0xd22a, 0x080c, 0x6c86, 0x00d6, 0x2c68, 0x080c, 0xae1b,
+	0xc675, 0x080c, 0xcb5a, 0x1118, 0x080c, 0xcd43, 0x0068, 0x6014,
+	0x2048, 0xa87c, 0xd0e4, 0x1110, 0x080c, 0xcd43, 0xa867, 0x0103,
+	0x080c, 0xd23a, 0x080c, 0x6c94, 0x00d6, 0x2c68, 0x080c, 0xae09,
 	0x01d0, 0x6003, 0x0001, 0x6007, 0x001e, 0x600b, 0xffff, 0x2009,
 	0x026e, 0x210c, 0x613a, 0x2009, 0x026f, 0x210c, 0x613e, 0x6910,
-	0x6112, 0x080c, 0xcfc4, 0x6954, 0x6156, 0x6023, 0x0001, 0x080c,
-	0x90d9, 0x080c, 0x9687, 0x2d60, 0x00de, 0x080c, 0xae71, 0x009e,
+	0x6112, 0x080c, 0xcfd4, 0x6954, 0x6156, 0x6023, 0x0001, 0x080c,
+	0x90f8, 0x080c, 0x96a6, 0x2d60, 0x00de, 0x080c, 0xae5f, 0x009e,
 	0x0005, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x05a0,
 	0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0035, 0x0130, 0x9186,
 	0x001e, 0x0118, 0x9186, 0x0039, 0x1538, 0x00d6, 0x2c68, 0x080c,
-	0xd1c2, 0x11f0, 0x080c, 0xae1b, 0x01d8, 0x6106, 0x6003, 0x0001,
+	0xd1d2, 0x11f0, 0x080c, 0xae09, 0x01d8, 0x6106, 0x6003, 0x0001,
 	0x6023, 0x0001, 0x6910, 0x6112, 0x692c, 0x612e, 0x6930, 0x6132,
 	0x6934, 0x918c, 0x00ff, 0x6136, 0x6938, 0x613a, 0x693c, 0x613e,
-	0x6954, 0x6156, 0x080c, 0xcfc4, 0x080c, 0x90d9, 0x080c, 0x9687,
-	0x2d60, 0x00de, 0x0804, 0xae71, 0x0096, 0x6014, 0x2048, 0x080c,
-	0xcb4a, 0x01c8, 0xa867, 0x0103, 0xa880, 0xd0b4, 0x0128, 0xc0ec,
+	0x6954, 0x6156, 0x080c, 0xcfd4, 0x080c, 0x90f8, 0x080c, 0x96a6,
+	0x2d60, 0x00de, 0x0804, 0xae5f, 0x0096, 0x6014, 0x2048, 0x080c,
+	0xcb5a, 0x01c8, 0xa867, 0x0103, 0xa880, 0xd0b4, 0x0128, 0xc0ec,
 	0xa882, 0xa87b, 0x0006, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002,
-	0x0020, 0xa87b, 0x0005, 0x080c, 0xce44, 0xa877, 0x0000, 0x080c,
-	0x6c86, 0x080c, 0xcd33, 0x009e, 0x0804, 0xae71, 0x0016, 0x0096,
-	0x6014, 0x2048, 0x080c, 0xcb4a, 0x0140, 0xa867, 0x0103, 0xa87b,
-	0x0028, 0xa877, 0x0000, 0x080c, 0x6c86, 0x009e, 0x001e, 0x9186,
+	0x0020, 0xa87b, 0x0005, 0x080c, 0xce54, 0xa877, 0x0000, 0x080c,
+	0x6c94, 0x080c, 0xcd43, 0x009e, 0x0804, 0xae5f, 0x0016, 0x0096,
+	0x6014, 0x2048, 0x080c, 0xcb5a, 0x0140, 0xa867, 0x0103, 0xa87b,
+	0x0028, 0xa877, 0x0000, 0x080c, 0x6c94, 0x009e, 0x001e, 0x9186,
 	0x0013, 0x0148, 0x9186, 0x0014, 0x0130, 0x9186, 0x0027, 0x0118,
-	0x080c, 0xaf07, 0x0030, 0x080c, 0x957b, 0x080c, 0xaea2, 0x080c,
-	0x9687, 0x0005, 0x0056, 0x0066, 0x0096, 0x00a6, 0x2029, 0x0001,
+	0x080c, 0xaef5, 0x0030, 0x080c, 0x959a, 0x080c, 0xae90, 0x080c,
+	0x96a6, 0x0005, 0x0056, 0x0066, 0x0096, 0x00a6, 0x2029, 0x0001,
 	0x9182, 0x0101, 0x1208, 0x0010, 0x2009, 0x0100, 0x2130, 0x8304,
 	0x9098, 0x0018, 0x2009, 0x0020, 0x2011, 0x0029, 0x080c, 0xc743,
 	0x96b2, 0x0020, 0xb004, 0x904d, 0x0110, 0x080c, 0x0fb1, 0x080c,
@@ -6169,8 +6169,8 @@
 	0x95ad, 0x0003, 0xb566, 0x95ac, 0x0000, 0x0048, 0x2001, 0x0205,
 	0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0003, 0xb566, 0x009e,
 	0x006e, 0x005e, 0x0005, 0x00a6, 0x89ff, 0x0158, 0xa804, 0x9055,
-	0x0130, 0xa807, 0x0000, 0x080c, 0x6c86, 0x2a48, 0x0cb8, 0x080c,
-	0x6c86, 0x00ae, 0x0005, 0x00f6, 0x2079, 0x0200, 0x7814, 0x9085,
+	0x0130, 0xa807, 0x0000, 0x080c, 0x6c94, 0x2a48, 0x0cb8, 0x080c,
+	0x6c94, 0x00ae, 0x0005, 0x00f6, 0x2079, 0x0200, 0x7814, 0x9085,
 	0x0080, 0x7816, 0xd184, 0x0108, 0x8108, 0x810c, 0x20a9, 0x0001,
 	0xa860, 0x20e8, 0xa85c, 0x9200, 0x20a0, 0x20e1, 0x0000, 0x2300,
 	0x9e00, 0x2098, 0x4003, 0x8318, 0x9386, 0x0020, 0x1148, 0x2018,
@@ -6180,58 +6180,58 @@
 	0x012e, 0x006e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0066, 0x2031,
 	0x0000, 0x6020, 0x9084, 0x000f, 0x001b, 0x006e, 0x012e, 0x0005,
 	0xc7a9, 0xc7a9, 0xc7a4, 0xc7cb, 0xc797, 0xc7a4, 0xc7cb, 0xc7a4,
-	0xc797, 0x8ec2, 0xc7a4, 0xc7a4, 0xc7a4, 0xc797, 0xc797, 0x080c,
-	0x0dd5, 0x0036, 0x2019, 0x0010, 0x080c, 0xe155, 0x6023, 0x0006,
+	0xc797, 0x8ee1, 0xc7a4, 0xc7a4, 0xc7a4, 0xc797, 0xc797, 0x080c,
+	0x0dd5, 0x0036, 0x2019, 0x0010, 0x080c, 0xe16f, 0x6023, 0x0006,
 	0x6003, 0x0007, 0x003e, 0x0005, 0x9006, 0x0005, 0x9085, 0x0001,
-	0x0005, 0x0096, 0x86ff, 0x11d8, 0x6014, 0x2048, 0x080c, 0xcb4a,
+	0x0005, 0x0096, 0x86ff, 0x11d8, 0x6014, 0x2048, 0x080c, 0xcb5a,
 	0x01c0, 0xa864, 0x9086, 0x0139, 0x1128, 0xa87b, 0x0005, 0xa883,
-	0x0000, 0x0028, 0x900e, 0x2001, 0x0005, 0x080c, 0x6eb9, 0x080c,
-	0xce44, 0x080c, 0x6c7a, 0x080c, 0xaea2, 0x9085, 0x0001, 0x009e,
+	0x0000, 0x0028, 0x900e, 0x2001, 0x0005, 0x080c, 0x6ec7, 0x080c,
+	0xce54, 0x080c, 0x6c88, 0x080c, 0xae90, 0x9085, 0x0001, 0x009e,
 	0x0005, 0x9006, 0x0ce0, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0dd5,
 	0x0002, 0xc7e1, 0xc80f, 0xc7e3, 0xc830, 0xc80a, 0xc7e1, 0xc7a4,
 	0xc7a9, 0xc7a9, 0xc7a4, 0xc7a4, 0xc7a4, 0xc7a4, 0xc7a4, 0xc7a4,
 	0xc7a4, 0x080c, 0x0dd5, 0x86ff, 0x1510, 0x6020, 0x9086, 0x0006,
-	0x01f0, 0x0096, 0x6014, 0x2048, 0x080c, 0xcb4a, 0x0158, 0xa87c,
+	0x01f0, 0x0096, 0x6014, 0x2048, 0x080c, 0xcb5a, 0x0158, 0xa87c,
 	0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fb1, 0x009e,
-	0x080c, 0xce44, 0x009e, 0x080c, 0xd204, 0x6007, 0x0085, 0x6003,
-	0x000b, 0x6023, 0x0002, 0x080c, 0x90d9, 0x080c, 0x9687, 0x9085,
-	0x0001, 0x0005, 0x0066, 0x080c, 0x1a60, 0x006e, 0x08a0, 0x00e6,
-	0x2071, 0x19e6, 0x7024, 0x9c06, 0x1120, 0x080c, 0xa541, 0x00ee,
+	0x080c, 0xce54, 0x009e, 0x080c, 0xd214, 0x6007, 0x0085, 0x6003,
+	0x000b, 0x6023, 0x0002, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x9085,
+	0x0001, 0x0005, 0x0066, 0x080c, 0x1a70, 0x006e, 0x08a0, 0x00e6,
+	0x2071, 0x19e6, 0x7024, 0x9c06, 0x1120, 0x080c, 0xa552, 0x00ee,
 	0x0850, 0x6020, 0x9084, 0x000f, 0x9086, 0x0006, 0x1150, 0x0086,
-	0x0096, 0x2049, 0x0001, 0x2c40, 0x080c, 0xa69d, 0x009e, 0x008e,
-	0x0010, 0x080c, 0xa43e, 0x00ee, 0x1904, 0xc7e3, 0x0804, 0xc7a4,
+	0x0096, 0x2049, 0x0001, 0x2c40, 0x080c, 0xa687, 0x009e, 0x008e,
+	0x0010, 0x080c, 0xa44f, 0x00ee, 0x1904, 0xc7e3, 0x0804, 0xc7a4,
 	0x0036, 0x00e6, 0x2071, 0x19e6, 0x703c, 0x9c06, 0x1138, 0x901e,
-	0x080c, 0xa5b7, 0x00ee, 0x003e, 0x0804, 0xc7e3, 0x080c, 0xa7cd,
+	0x080c, 0xa5c8, 0x00ee, 0x003e, 0x0804, 0xc7e3, 0x080c, 0xa7b7,
 	0x00ee, 0x003e, 0x1904, 0xc7e3, 0x0804, 0xc7a4, 0x00c6, 0x6020,
-	0x9084, 0x000f, 0x0013, 0x00ce, 0x0005, 0xc863, 0xc92e, 0xca95,
-	0xc86d, 0xaea2, 0xc863, 0xe147, 0xd26c, 0xc92e, 0x8e94, 0xcb14,
-	0xc85c, 0xc85c, 0xc85c, 0xc85c, 0x080c, 0x0dd5, 0x080c, 0xcd50,
-	0x1110, 0x080c, 0xb824, 0x0005, 0x080c, 0x957b, 0x080c, 0x9687,
-	0x0804, 0xae71, 0x601b, 0x0001, 0x0005, 0x080c, 0xcb4a, 0x0130,
+	0x9084, 0x000f, 0x0013, 0x00ce, 0x0005, 0xc863, 0xc92e, 0xca98,
+	0xc86d, 0xae90, 0xc863, 0xe161, 0xd27c, 0xc92e, 0x8eb3, 0xcb24,
+	0xc85c, 0xc85c, 0xc85c, 0xc85c, 0x080c, 0x0dd5, 0x080c, 0xcd60,
+	0x1110, 0x080c, 0xb821, 0x0005, 0x080c, 0x959a, 0x080c, 0x96a6,
+	0x0804, 0xae5f, 0x601b, 0x0001, 0x0005, 0x080c, 0xcb5a, 0x0130,
 	0x6014, 0x0096, 0x2048, 0x2c00, 0xa896, 0x009e, 0x6000, 0x908a,
 	0x0016, 0x1a0c, 0x0dd5, 0x0002, 0xc88c, 0xc88e, 0xc8b2, 0xc8c6,
 	0xc8ec, 0xc88c, 0xc863, 0xc863, 0xc863, 0xc8c6, 0xc8c6, 0xc88c,
 	0xc88c, 0xc88c, 0xc88c, 0xc8d0, 0x080c, 0x0dd5, 0x00e6, 0x6014,
 	0x0096, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e, 0x2071, 0x19e6,
-	0x7024, 0x9c06, 0x01a0, 0x080c, 0xa43e, 0x080c, 0xd204, 0x6007,
+	0x7024, 0x9c06, 0x01a0, 0x080c, 0xa44f, 0x080c, 0xd214, 0x6007,
 	0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2001, 0x1986, 0x2004,
-	0x601a, 0x080c, 0x90d9, 0x080c, 0x9687, 0x00ee, 0x0005, 0x601b,
+	0x601a, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x00ee, 0x0005, 0x601b,
 	0x0001, 0x0cd8, 0x0096, 0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882,
-	0x009e, 0x080c, 0xd204, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
-	0x0002, 0x080c, 0x90d9, 0x080c, 0x9687, 0x0005, 0x0096, 0x601b,
+	0x009e, 0x080c, 0xd214, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
+	0x0002, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x0005, 0x0096, 0x601b,
 	0x0001, 0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e, 0x0005,
-	0x080c, 0x56e0, 0x01b8, 0x6014, 0x0096, 0x904d, 0x0190, 0xa864,
+	0x080c, 0x56ea, 0x01b8, 0x6014, 0x0096, 0x904d, 0x0190, 0xa864,
 	0xa867, 0x0103, 0xa87b, 0x0006, 0x9086, 0x0139, 0x1150, 0xa867,
 	0x0139, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa89b, 0x0004, 0x080c,
-	0x6c86, 0x009e, 0x0804, 0xae71, 0x6014, 0x0096, 0x904d, 0x05c8,
+	0x6c94, 0x009e, 0x0804, 0xae5f, 0x6014, 0x0096, 0x904d, 0x05c8,
 	0xa97c, 0xd1e4, 0x05b0, 0x2001, 0x180f, 0x2004, 0xd0c4, 0x0110,
 	0x009e, 0x0005, 0xa884, 0x009e, 0x8003, 0x800b, 0x810b, 0x9108,
 	0x611a, 0x2001, 0x0030, 0x2c08, 0x080c, 0x15f0, 0x2001, 0x030c,
 	0x2004, 0x9086, 0x0041, 0x11a0, 0x6014, 0x0096, 0x904d, 0x090c,
 	0x0dd5, 0xa880, 0xd0f4, 0x1130, 0xc0f5, 0xa882, 0x009e, 0x601b,
 	0x0002, 0x0070, 0x009e, 0x2001, 0x0037, 0x2c08, 0x080c, 0x15f0,
-	0x6000, 0x9086, 0x0004, 0x1120, 0x2009, 0x0048, 0x080c, 0xaeec,
-	0x0005, 0x009e, 0x080c, 0x1a60, 0x0804, 0xc8b2, 0x6000, 0x908a,
+	0x6000, 0x9086, 0x0004, 0x1120, 0x2009, 0x0048, 0x080c, 0xaeda,
+	0x0005, 0x009e, 0x080c, 0x1a70, 0x0804, 0xc8b2, 0x6000, 0x908a,
 	0x0016, 0x1a0c, 0x0dd5, 0x000b, 0x0005, 0xc945, 0xc86a, 0xc947,
 	0xc945, 0xc947, 0xc947, 0xc864, 0xc945, 0xc85e, 0xc85e, 0xc945,
 	0xc945, 0xc945, 0xc945, 0xc945, 0xc945, 0x080c, 0x0dd5, 0x6010,
@@ -6240,175 +6240,177 @@
 	0xc964, 0xc9a4, 0xc964, 0xc9a4, 0xc964, 0xc972, 0xc962, 0xc9a4,
 	0xc962, 0xc993, 0x080c, 0x0dd5, 0x6004, 0x908e, 0x0016, 0x05c0,
 	0x908e, 0x0004, 0x05a8, 0x908e, 0x0002, 0x0590, 0x908e, 0x0052,
-	0x0904, 0xca2b, 0x6004, 0x080c, 0xcd50, 0x0904, 0xca48, 0x908e,
-	0x0004, 0x1110, 0x080c, 0x31ea, 0x908e, 0x0021, 0x0904, 0xca4c,
-	0x908e, 0x0022, 0x0904, 0xca90, 0x908e, 0x003d, 0x0904, 0xca4c,
+	0x0904, 0xca2b, 0x6004, 0x080c, 0xcd60, 0x0904, 0xca48, 0x908e,
+	0x0004, 0x1110, 0x080c, 0x31f5, 0x908e, 0x0021, 0x0904, 0xca4c,
+	0x908e, 0x0022, 0x0904, 0xca93, 0x908e, 0x003d, 0x0904, 0xca4c,
 	0x908e, 0x0039, 0x0904, 0xca50, 0x908e, 0x0035, 0x0904, 0xca50,
 	0x908e, 0x001e, 0x0178, 0x908e, 0x0001, 0x1140, 0x6010, 0x2058,
-	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x0110, 0x080c, 0x31c1,
-	0x080c, 0xb824, 0x0804, 0xaea2, 0x00c6, 0x00d6, 0x6104, 0x9186,
+	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x0110, 0x080c, 0x31cc,
+	0x080c, 0xb821, 0x0804, 0xae90, 0x00c6, 0x00d6, 0x6104, 0x9186,
 	0x0016, 0x0904, 0xca1c, 0x9186, 0x0002, 0x1904, 0xc9f1, 0x2001,
-	0x1837, 0x2004, 0xd08c, 0x11c8, 0x080c, 0x73a5, 0x11b0, 0x080c,
-	0xd24a, 0x0138, 0x080c, 0x73c8, 0x1120, 0x080c, 0x72b5, 0x0804,
-	0xca79, 0x2001, 0x197c, 0x2003, 0x0001, 0x2001, 0x1800, 0x2003,
-	0x0001, 0x080c, 0x72d7, 0x0804, 0xca79, 0x6010, 0x2058, 0x2001,
-	0x1837, 0x2004, 0xd0ac, 0x1904, 0xca79, 0xb8a0, 0x9084, 0xff80,
-	0x1904, 0xca79, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0190, 0x8001,
+	0x1837, 0x2004, 0xd08c, 0x11c8, 0x080c, 0x73b3, 0x11b0, 0x080c,
+	0xd25a, 0x0138, 0x080c, 0x73d6, 0x1120, 0x080c, 0x72c3, 0x0804,
+	0xca7c, 0x2001, 0x197c, 0x2003, 0x0001, 0x2001, 0x1800, 0x2003,
+	0x0001, 0x080c, 0x72e5, 0x0804, 0xca7c, 0x6010, 0x2058, 0x2001,
+	0x1837, 0x2004, 0xd0ac, 0x1904, 0xca7c, 0xb8a0, 0x9084, 0xff80,
+	0x1904, 0xca7c, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0190, 0x8001,
 	0xb842, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398, 0x6043,
-	0x0000, 0x080c, 0xae1b, 0x0128, 0x2b00, 0x6012, 0x6023, 0x0001,
+	0x0000, 0x080c, 0xae09, 0x0128, 0x2b00, 0x6012, 0x6023, 0x0001,
 	0x0458, 0x00de, 0x00ce, 0x6004, 0x908e, 0x0002, 0x11a0, 0x6010,
 	0x2058, 0xb8a0, 0x9086, 0x007e, 0x1170, 0x2009, 0x1837, 0x2104,
-	0xc085, 0x200a, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5fb6, 0x00ee,
-	0x080c, 0xb824, 0x0030, 0x080c, 0xb824, 0x080c, 0x31c1, 0x080c,
-	0xd25f, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x31ea, 0x012e,
-	0x00ee, 0x080c, 0xaea2, 0x0005, 0x2001, 0x0002, 0x080c, 0x6558,
-	0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9121, 0x080c, 0x9687,
-	0x00de, 0x00ce, 0x0c80, 0x080c, 0x31ea, 0x0804, 0xc9a0, 0x00c6,
+	0xc085, 0x200a, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5fc0, 0x00ee,
+	0x080c, 0xb821, 0x0030, 0x080c, 0xb821, 0x080c, 0x31cc, 0x080c,
+	0xd26f, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x31f5, 0x012e,
+	0x00ee, 0x080c, 0xae90, 0x0005, 0x2001, 0x0002, 0x080c, 0x6566,
+	0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9140, 0x080c, 0x96a6,
+	0x00de, 0x00ce, 0x0c80, 0x080c, 0x31f5, 0x0804, 0xc9a0, 0x00c6,
 	0x00d6, 0x6104, 0x9186, 0x0016, 0x0d38, 0x6010, 0x2058, 0xb840,
 	0x9084, 0x00ff, 0x9005, 0x0904, 0xc9f1, 0x8001, 0xb842, 0x6003,
-	0x0001, 0x080c, 0x9121, 0x080c, 0x9687, 0x00de, 0x00ce, 0x0898,
-	0x080c, 0xb824, 0x0804, 0xc9a2, 0x080c, 0xb860, 0x0804, 0xc9a2,
-	0x00d6, 0x2c68, 0x6104, 0x080c, 0xd1c2, 0x00de, 0x0118, 0x080c,
-	0xae71, 0x00f0, 0x6004, 0x8007, 0x6134, 0x918c, 0x00ff, 0x9105,
+	0x0001, 0x080c, 0x9140, 0x080c, 0x96a6, 0x00de, 0x00ce, 0x0898,
+	0x080c, 0xb821, 0x0804, 0xc9a2, 0x080c, 0xb85d, 0x0804, 0xc9a2,
+	0x00d6, 0x2c68, 0x6104, 0x080c, 0xd1d2, 0x00de, 0x0118, 0x080c,
+	0xae5f, 0x0408, 0x6004, 0x8007, 0x6134, 0x918c, 0x00ff, 0x9105,
 	0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x603c,
 	0x600a, 0x2001, 0x1986, 0x2004, 0x601a, 0x602c, 0x2c08, 0x2060,
-	0x6024, 0xc0b5, 0x6026, 0x2160, 0x080c, 0x90d9, 0x080c, 0x9687,
-	0x0005, 0x00de, 0x00ce, 0x080c, 0xb824, 0x080c, 0x31c1, 0x00e6,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x31ea, 0x6017, 0x0000, 0x6023,
-	0x0007, 0x601b, 0x0398, 0x6043, 0x0000, 0x012e, 0x00ee, 0x0005,
-	0x080c, 0xb2a2, 0x1904, 0xca48, 0x0005, 0x6000, 0x908a, 0x0016,
-	0x1a0c, 0x0dd5, 0x0096, 0x00d6, 0x001b, 0x00de, 0x009e, 0x0005,
-	0xcab0, 0xcab0, 0xcab0, 0xcab0, 0xcab0, 0xcab0, 0xcab0, 0xcab0,
-	0xcab0, 0xc863, 0xcab0, 0xc86a, 0xcab2, 0xc86a, 0xcabf, 0xcab0,
-	0x080c, 0x0dd5, 0x6004, 0x9086, 0x008b, 0x0148, 0x6007, 0x008b,
-	0x6003, 0x000d, 0x080c, 0x90d9, 0x080c, 0x9687, 0x0005, 0x080c,
-	0xd23e, 0x0118, 0x080c, 0xd251, 0x0010, 0x080c, 0xd25f, 0x080c,
-	0xcd33, 0x080c, 0xcb4a, 0x0570, 0x080c, 0x31c1, 0x080c, 0xcb4a,
+	0x6024, 0xd0b4, 0x0108, 0xc085, 0xc0b5, 0x6026, 0x2160, 0x080c,
+	0x90f8, 0x080c, 0x96a6, 0x0005, 0x00de, 0x00ce, 0x080c, 0xb821,
+	0x080c, 0x31cc, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x31f5,
+	0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398, 0x6043, 0x0000,
+	0x012e, 0x00ee, 0x0005, 0x080c, 0xb290, 0x1904, 0xca48, 0x0005,
+	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0dd5, 0x0096, 0x00d6, 0x001b,
+	0x00de, 0x009e, 0x0005, 0xcab3, 0xcab3, 0xcab3, 0xcab3, 0xcab3,
+	0xcab3, 0xcab3, 0xcab3, 0xcab3, 0xc863, 0xcab3, 0xc86a, 0xcab5,
+	0xc86a, 0xcacf, 0xcab3, 0x080c, 0x0dd5, 0x6004, 0x9086, 0x008b,
+	0x01b0, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0035, 0x1130,
+	0x602c, 0x9080, 0x0009, 0x200c, 0xc185, 0x2102, 0x6007, 0x008b,
+	0x6003, 0x000d, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x0005, 0x080c,
+	0xd24e, 0x0118, 0x080c, 0xd261, 0x0010, 0x080c, 0xd26f, 0x080c,
+	0xcd43, 0x080c, 0xcb5a, 0x0570, 0x080c, 0x31cc, 0x080c, 0xcb5a,
 	0x0168, 0x6014, 0x2048, 0xa867, 0x0103, 0xa87b, 0x0006, 0xa877,
-	0x0000, 0xa880, 0xc0ed, 0xa882, 0x080c, 0x6c86, 0x2c68, 0x080c,
-	0xae1b, 0x0150, 0x6810, 0x6012, 0x080c, 0xcfc4, 0x00c6, 0x2d60,
-	0x080c, 0xaea2, 0x00ce, 0x0008, 0x2d60, 0x6017, 0x0000, 0x6023,
-	0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x9121, 0x080c,
-	0x9687, 0x00c8, 0x080c, 0xd23e, 0x0138, 0x6034, 0x9086, 0x4000,
-	0x1118, 0x080c, 0x31c1, 0x08d0, 0x6034, 0x908c, 0xff00, 0x810f,
-	0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x080c, 0x31c1,
-	0x0868, 0x080c, 0xaea2, 0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c,
-	0x0dd5, 0x0002, 0xcb2a, 0xcb2a, 0xcb2c, 0xcb2c, 0xcb2c, 0xcb2a,
-	0xcb2a, 0xaea2, 0xcb2a, 0xcb2a, 0xcb2a, 0xcb2a, 0xcb2a, 0xcb2a,
-	0xcb2a, 0xcb2a, 0x080c, 0x0dd5, 0x080c, 0xa7cd, 0x6114, 0x0096,
-	0x2148, 0xa87b, 0x0006, 0x080c, 0x6c86, 0x009e, 0x0804, 0xae71,
+	0x0000, 0xa880, 0xc0ed, 0xa882, 0x080c, 0x6c94, 0x2c68, 0x080c,
+	0xae09, 0x0150, 0x6810, 0x6012, 0x080c, 0xcfd4, 0x00c6, 0x2d60,
+	0x080c, 0xae90, 0x00ce, 0x0008, 0x2d60, 0x6017, 0x0000, 0x6023,
+	0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x9140, 0x080c,
+	0x96a6, 0x00c8, 0x080c, 0xd24e, 0x0138, 0x6034, 0x9086, 0x4000,
+	0x1118, 0x080c, 0x31cc, 0x08d0, 0x6034, 0x908c, 0xff00, 0x810f,
+	0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x080c, 0x31cc,
+	0x0868, 0x080c, 0xae90, 0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c,
+	0x0dd5, 0x0002, 0xcb3a, 0xcb3a, 0xcb3c, 0xcb3c, 0xcb3c, 0xcb3a,
+	0xcb3a, 0xae90, 0xcb3a, 0xcb3a, 0xcb3a, 0xcb3a, 0xcb3a, 0xcb3a,
+	0xcb3a, 0xcb3a, 0x080c, 0x0dd5, 0x080c, 0xa7b7, 0x6114, 0x0096,
+	0x2148, 0xa87b, 0x0006, 0x080c, 0x6c94, 0x009e, 0x0804, 0xae5f,
 	0x9284, 0x0007, 0x1158, 0x9282, 0x1cd0, 0x0240, 0x2001, 0x181a,
 	0x2004, 0x9202, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8,
 	0x0096, 0x0028, 0x0096, 0x0006, 0x6014, 0x2048, 0x000e, 0x0006,
 	0x9984, 0xf000, 0x9086, 0xf000, 0x0110, 0x080c, 0x10aa, 0x000e,
 	0x009e, 0x0005, 0x00e6, 0x00c6, 0x0036, 0x0006, 0x0126, 0x2091,
 	0x8000, 0x2061, 0x1cd0, 0x2071, 0x1800, 0x7354, 0x7074, 0x9302,
-	0x1640, 0x6020, 0x9206, 0x11f8, 0x080c, 0xd24a, 0x0180, 0x9286,
-	0x0001, 0x1168, 0x6004, 0x9086, 0x0004, 0x1148, 0x080c, 0x31c1,
-	0x080c, 0xd25f, 0x00c6, 0x080c, 0xaea2, 0x00ce, 0x0060, 0x080c,
-	0xcf3e, 0x0148, 0x080c, 0xcd50, 0x1110, 0x080c, 0xb824, 0x00c6,
-	0x080c, 0xae71, 0x00ce, 0x9ce0, 0x0018, 0x7068, 0x9c02, 0x1208,
+	0x1640, 0x6020, 0x9206, 0x11f8, 0x080c, 0xd25a, 0x0180, 0x9286,
+	0x0001, 0x1168, 0x6004, 0x9086, 0x0004, 0x1148, 0x080c, 0x31cc,
+	0x080c, 0xd26f, 0x00c6, 0x080c, 0xae90, 0x00ce, 0x0060, 0x080c,
+	0xcf4e, 0x0148, 0x080c, 0xcd60, 0x1110, 0x080c, 0xb821, 0x00c6,
+	0x080c, 0xae5f, 0x00ce, 0x9ce0, 0x0018, 0x7068, 0x9c02, 0x1208,
 	0x08a0, 0x012e, 0x000e, 0x003e, 0x00ce, 0x00ee, 0x0005, 0x00e6,
 	0x00c6, 0x0016, 0x9188, 0x1000, 0x210c, 0x81ff, 0x0128, 0x2061,
-	0x1aaf, 0x6112, 0x080c, 0x31c1, 0x9006, 0x0010, 0x9085, 0x0001,
+	0x1aaf, 0x6112, 0x080c, 0x31cc, 0x9006, 0x0010, 0x9085, 0x0001,
 	0x001e, 0x00ce, 0x00ee, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0xae1b, 0x01b0, 0x6656, 0x2b00, 0x6012, 0x080c, 0x56e0,
-	0x0118, 0x080c, 0xcc77, 0x0168, 0x080c, 0xcfc4, 0x6023, 0x0003,
-	0x2009, 0x004b, 0x080c, 0xaeec, 0x9085, 0x0001, 0x012e, 0x00ce,
+	0x080c, 0xae09, 0x01b0, 0x6656, 0x2b00, 0x6012, 0x080c, 0x56ea,
+	0x0118, 0x080c, 0xcc87, 0x0168, 0x080c, 0xcfd4, 0x6023, 0x0003,
+	0x2009, 0x004b, 0x080c, 0xaeda, 0x9085, 0x0001, 0x012e, 0x00ce,
 	0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0xbaa0,
-	0x080c, 0xaebf, 0x0560, 0x6057, 0x0000, 0x2b00, 0x6012, 0x080c,
-	0xcfc4, 0x6023, 0x0003, 0x0016, 0x080c, 0x927e, 0x0076, 0x903e,
-	0x080c, 0x9151, 0x2c08, 0x080c, 0xe30c, 0x007e, 0x001e, 0xd184,
-	0x0128, 0x080c, 0xae71, 0x9085, 0x0001, 0x0070, 0x080c, 0x56e0,
-	0x0128, 0xd18c, 0x1170, 0x080c, 0xcc77, 0x0148, 0x2009, 0x004c,
-	0x080c, 0xaeec, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006,
+	0x080c, 0xaead, 0x0560, 0x6057, 0x0000, 0x2b00, 0x6012, 0x080c,
+	0xcfd4, 0x6023, 0x0003, 0x0016, 0x080c, 0x929d, 0x0076, 0x903e,
+	0x080c, 0x9170, 0x2c08, 0x080c, 0xe326, 0x007e, 0x001e, 0xd184,
+	0x0128, 0x080c, 0xae5f, 0x9085, 0x0001, 0x0070, 0x080c, 0x56ea,
+	0x0128, 0xd18c, 0x1170, 0x080c, 0xcc87, 0x0148, 0x2009, 0x004c,
+	0x080c, 0xaeda, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006,
 	0x0cd8, 0x2900, 0x6016, 0x0c90, 0x2009, 0x004d, 0x0010, 0x2009,
-	0x004e, 0x00f6, 0x00c6, 0x0046, 0x0016, 0x080c, 0xae1b, 0x2c78,
+	0x004e, 0x00f6, 0x00c6, 0x0046, 0x0016, 0x080c, 0xae09, 0x2c78,
 	0x0590, 0x7e56, 0x2b00, 0x7812, 0x7823, 0x0003, 0x2021, 0x0005,
-	0x080c, 0xcc89, 0x9186, 0x004d, 0x0118, 0x9186, 0x004e, 0x0148,
-	0x2001, 0x197f, 0x200c, 0xd1fc, 0x0168, 0x2f60, 0x080c, 0xae71,
+	0x080c, 0xcc99, 0x9186, 0x004d, 0x0118, 0x9186, 0x004e, 0x0148,
+	0x2001, 0x197f, 0x200c, 0xd1fc, 0x0168, 0x2f60, 0x080c, 0xae5f,
 	0x00d0, 0x2001, 0x197e, 0x200c, 0xd1fc, 0x0120, 0x2f60, 0x080c,
-	0xae71, 0x0088, 0x2f60, 0x080c, 0x56e0, 0x0138, 0xd18c, 0x1118,
+	0xae5f, 0x0088, 0x2f60, 0x080c, 0x56ea, 0x0138, 0xd18c, 0x1118,
 	0x04f1, 0x0148, 0x0010, 0x2900, 0x7816, 0x001e, 0x0016, 0x080c,
-	0xaeec, 0x9085, 0x0001, 0x001e, 0x004e, 0x00ce, 0x00fe, 0x0005,
-	0x00f6, 0x00c6, 0x0046, 0x080c, 0xae1b, 0x2c78, 0x0508, 0x7e56,
+	0xaeda, 0x9085, 0x0001, 0x001e, 0x004e, 0x00ce, 0x00fe, 0x0005,
+	0x00f6, 0x00c6, 0x0046, 0x080c, 0xae09, 0x2c78, 0x0508, 0x7e56,
 	0x2b00, 0x7812, 0x7823, 0x0003, 0x0096, 0x2021, 0x0004, 0x0489,
 	0x009e, 0x2001, 0x197d, 0x200c, 0xd1fc, 0x0120, 0x2f60, 0x080c,
-	0xae71, 0x0060, 0x2f60, 0x080c, 0x56e0, 0x0120, 0xd18c, 0x1160,
-	0x0071, 0x0130, 0x2009, 0x0052, 0x080c, 0xaeec, 0x9085, 0x0001,
+	0xae5f, 0x0060, 0x2f60, 0x080c, 0x56ea, 0x0120, 0xd18c, 0x1160,
+	0x0071, 0x0130, 0x2009, 0x0052, 0x080c, 0xaeda, 0x9085, 0x0001,
 	0x004e, 0x00ce, 0x00fe, 0x0005, 0x2900, 0x7816, 0x0c98, 0x00c6,
-	0x080c, 0x4ab4, 0x00ce, 0x1120, 0x080c, 0xae71, 0x9006, 0x0005,
+	0x080c, 0x4abe, 0x00ce, 0x1120, 0x080c, 0xae5f, 0x9006, 0x0005,
 	0xa867, 0x0000, 0xa86b, 0x8000, 0x2900, 0x6016, 0x9085, 0x0001,
-	0x0005, 0x0096, 0x0076, 0x0126, 0x2091, 0x8000, 0x080c, 0x673c,
-	0x0158, 0x2001, 0xcc8e, 0x0006, 0x900e, 0x2400, 0x080c, 0x6eb9,
-	0x080c, 0x6c86, 0x000e, 0x0807, 0x2418, 0x080c, 0x9515, 0xbaa0,
-	0x0086, 0x2041, 0x0001, 0x2039, 0x0001, 0x2608, 0x080c, 0x9296,
-	0x008e, 0x080c, 0x9151, 0x2f08, 0x2648, 0x080c, 0xe30c, 0xb93c,
-	0x81ff, 0x090c, 0x9367, 0x080c, 0x9687, 0x012e, 0x007e, 0x009e,
-	0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xae1b, 0x0190,
-	0x660a, 0x2b08, 0x6112, 0x080c, 0xcfc4, 0x6023, 0x0001, 0x2900,
-	0x6016, 0x2009, 0x001f, 0x080c, 0xaeec, 0x9085, 0x0001, 0x012e,
+	0x0005, 0x0096, 0x0076, 0x0126, 0x2091, 0x8000, 0x080c, 0x674a,
+	0x0158, 0x2001, 0xcc9e, 0x0006, 0x900e, 0x2400, 0x080c, 0x6ec7,
+	0x080c, 0x6c94, 0x000e, 0x0807, 0x2418, 0x080c, 0x9534, 0xbaa0,
+	0x0086, 0x2041, 0x0001, 0x2039, 0x0001, 0x2608, 0x080c, 0x92b5,
+	0x008e, 0x080c, 0x9170, 0x2f08, 0x2648, 0x080c, 0xe326, 0xb93c,
+	0x81ff, 0x090c, 0x9386, 0x080c, 0x96a6, 0x012e, 0x007e, 0x009e,
+	0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xae09, 0x0190,
+	0x660a, 0x2b08, 0x6112, 0x080c, 0xcfd4, 0x6023, 0x0001, 0x2900,
+	0x6016, 0x2009, 0x001f, 0x080c, 0xaeda, 0x9085, 0x0001, 0x012e,
 	0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0xaebf, 0x01b8, 0x660a, 0x2b08, 0x6112, 0x080c, 0xcfc4,
+	0x080c, 0xaead, 0x01b8, 0x660a, 0x2b08, 0x6112, 0x080c, 0xcfd4,
 	0x6023, 0x0008, 0x2900, 0x6016, 0x00f6, 0x2c78, 0x080c, 0x1727,
-	0x00fe, 0x2009, 0x0021, 0x080c, 0xaeec, 0x9085, 0x0001, 0x012e,
+	0x00fe, 0x2009, 0x0021, 0x080c, 0xaeda, 0x9085, 0x0001, 0x012e,
 	0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009, 0x003d, 0x00c6, 0x0126,
-	0x0016, 0x2091, 0x8000, 0x080c, 0xae1b, 0x0198, 0x660a, 0x2b08,
-	0x6112, 0x080c, 0xcfc4, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e,
-	0x0016, 0x080c, 0xaeec, 0x9085, 0x0001, 0x001e, 0x012e, 0x00ce,
+	0x0016, 0x2091, 0x8000, 0x080c, 0xae09, 0x0198, 0x660a, 0x2b08,
+	0x6112, 0x080c, 0xcfd4, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e,
+	0x0016, 0x080c, 0xaeda, 0x9085, 0x0001, 0x001e, 0x012e, 0x00ce,
 	0x0005, 0x9006, 0x0cd0, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c,
-	0xaebf, 0x0188, 0x2b08, 0x6112, 0x080c, 0xcfc4, 0x6023, 0x0001,
-	0x2900, 0x6016, 0x2009, 0x0000, 0x080c, 0xaeec, 0x9085, 0x0001,
+	0xaead, 0x0188, 0x2b08, 0x6112, 0x080c, 0xcfd4, 0x6023, 0x0001,
+	0x2900, 0x6016, 0x2009, 0x0000, 0x080c, 0xaeda, 0x9085, 0x0001,
 	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009, 0x0044, 0x0830,
 	0x2009, 0x0049, 0x0818, 0x0026, 0x00b6, 0x6210, 0x2258, 0xba3c,
 	0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x002e, 0x0005, 0x0006,
 	0x0016, 0x6004, 0x908e, 0x0002, 0x0140, 0x908e, 0x0003, 0x0128,
 	0x908e, 0x0004, 0x0110, 0x9085, 0x0001, 0x001e, 0x000e, 0x0005,
 	0x0006, 0x0086, 0x0096, 0x6020, 0x9086, 0x0004, 0x01a8, 0x6014,
-	0x904d, 0x080c, 0xcb4a, 0x0180, 0xa864, 0x9086, 0x0139, 0x0170,
+	0x904d, 0x080c, 0xcb5a, 0x0180, 0xa864, 0x9086, 0x0139, 0x0170,
 	0x6020, 0x90c6, 0x0003, 0x0140, 0x90c6, 0x0002, 0x0128, 0xa868,
 	0xd0fc, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001, 0x009e, 0x008e,
-	0x000e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xaebf,
-	0x0198, 0x2b08, 0x6112, 0x080c, 0xcfc4, 0x6023, 0x0001, 0x2900,
-	0x6016, 0x080c, 0x31c1, 0x2009, 0x0028, 0x080c, 0xaeec, 0x9085,
+	0x000e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xaead,
+	0x0198, 0x2b08, 0x6112, 0x080c, 0xcfd4, 0x6023, 0x0001, 0x2900,
+	0x6016, 0x080c, 0x31cc, 0x2009, 0x0028, 0x080c, 0xaeda, 0x9085,
 	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x9186, 0x0015,
 	0x11a8, 0x2011, 0x1824, 0x2204, 0x9086, 0x0074, 0x1178, 0x00b6,
-	0x080c, 0xba78, 0x00be, 0x080c, 0xbc9b, 0x6003, 0x0001, 0x6007,
-	0x0029, 0x080c, 0x9121, 0x080c, 0x9687, 0x0078, 0x6014, 0x0096,
+	0x080c, 0xba75, 0x00be, 0x080c, 0xbc98, 0x6003, 0x0001, 0x6007,
+	0x0029, 0x080c, 0x9140, 0x080c, 0x96a6, 0x0078, 0x6014, 0x0096,
 	0x2048, 0xa868, 0x009e, 0xd0fc, 0x0148, 0x2001, 0x0001, 0x080c,
-	0xd183, 0x080c, 0xb824, 0x080c, 0xae71, 0x0005, 0x0096, 0x6014,
+	0xd193, 0x080c, 0xb821, 0x080c, 0xae5f, 0x0005, 0x0096, 0x6014,
 	0x904d, 0x090c, 0x0dd5, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897,
 	0x4005, 0xa89b, 0x0004, 0xa867, 0x0139, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x6c86, 0x012e, 0x009e, 0x080c, 0xae71, 0x0c30, 0x0096,
-	0x9186, 0x0016, 0x1128, 0x2001, 0x0004, 0x080c, 0x6558, 0x00e8,
+	0x080c, 0x6c94, 0x012e, 0x009e, 0x080c, 0xae5f, 0x0c30, 0x0096,
+	0x9186, 0x0016, 0x1128, 0x2001, 0x0004, 0x080c, 0x6566, 0x00e8,
 	0x9186, 0x0015, 0x1510, 0x2011, 0x1824, 0x2204, 0x9086, 0x0014,
-	0x11e0, 0x6010, 0x00b6, 0x2058, 0x080c, 0x66a3, 0x00be, 0x080c,
-	0xbd6c, 0x1198, 0x6010, 0x00b6, 0x2058, 0xb890, 0x00be, 0x9005,
-	0x0160, 0x2001, 0x0006, 0x080c, 0x6558, 0x6014, 0x2048, 0xa868,
-	0xd0fc, 0x0170, 0x080c, 0xb276, 0x0048, 0x6014, 0x2048, 0xa868,
-	0xd0fc, 0x0528, 0x080c, 0xb824, 0x080c, 0xae71, 0x009e, 0x0005,
+	0x11e0, 0x6010, 0x00b6, 0x2058, 0x080c, 0x66b1, 0x00be, 0x080c,
+	0xbd69, 0x1198, 0x6010, 0x00b6, 0x2058, 0xb890, 0x00be, 0x9005,
+	0x0160, 0x2001, 0x0006, 0x080c, 0x6566, 0x6014, 0x2048, 0xa868,
+	0xd0fc, 0x0170, 0x080c, 0xb264, 0x0048, 0x6014, 0x2048, 0xa868,
+	0xd0fc, 0x0528, 0x080c, 0xb821, 0x080c, 0xae5f, 0x009e, 0x0005,
 	0x6014, 0x6310, 0x2358, 0x904d, 0x090c, 0x0dd5, 0xa87b, 0x0000,
-	0xa883, 0x0000, 0xa897, 0x4000, 0x900e, 0x080c, 0x6828, 0x1108,
+	0xa883, 0x0000, 0xa897, 0x4000, 0x900e, 0x080c, 0x6836, 0x1108,
 	0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0xa99a, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x6c86, 0x012e, 0x080c, 0xae71, 0x08f8, 0x6014,
+	0x8000, 0x080c, 0x6c94, 0x012e, 0x080c, 0xae5f, 0x08f8, 0x6014,
 	0x904d, 0x090c, 0x0dd5, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897,
 	0x4005, 0xa89b, 0x0004, 0xa867, 0x0139, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x6c86, 0x012e, 0x080c, 0xae71, 0x0840, 0xa878, 0x9086,
+	0x080c, 0x6c94, 0x012e, 0x080c, 0xae5f, 0x0840, 0xa878, 0x9086,
 	0x0005, 0x1108, 0x0009, 0x0005, 0xa880, 0xc0ad, 0xa882, 0x0005,
 	0x6043, 0x0000, 0x6017, 0x0000, 0x6003, 0x0001, 0x6007, 0x0050,
-	0x080c, 0x90d9, 0x080c, 0x9687, 0x0005, 0x00c6, 0x6010, 0x00b6,
+	0x080c, 0x90f8, 0x080c, 0x96a6, 0x0005, 0x00c6, 0x6010, 0x00b6,
 	0x2058, 0xb800, 0x00be, 0xd0bc, 0x0120, 0x6020, 0x9084, 0x000f,
-	0x0013, 0x00ce, 0x0005, 0xc863, 0xce74, 0xce74, 0xce77, 0xe61e,
-	0xe639, 0xe63c, 0xc863, 0xc863, 0xc863, 0xc863, 0xc863, 0xc863,
+	0x0013, 0x00ce, 0x0005, 0xc863, 0xce84, 0xce84, 0xce87, 0xe638,
+	0xe653, 0xe656, 0xc863, 0xc863, 0xc863, 0xc863, 0xc863, 0xc863,
 	0xc863, 0xc863, 0x080c, 0x0dd5, 0xa001, 0xa001, 0x0005, 0x0096,
 	0x6014, 0x904d, 0x0118, 0xa87c, 0xd0e4, 0x1110, 0x009e, 0x0010,
 	0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
 	0x0550, 0x2001, 0x1834, 0x2004, 0x9005, 0x1540, 0x00f6, 0x2c78,
-	0x080c, 0xae1b, 0x0508, 0x7810, 0x6012, 0x080c, 0xcfc4, 0x7820,
+	0x080c, 0xae09, 0x0508, 0x7810, 0x6012, 0x080c, 0xcfd4, 0x7820,
 	0x9086, 0x0003, 0x0128, 0x7808, 0x603a, 0x2f00, 0x603e, 0x0020,
 	0x7808, 0x603e, 0x2f00, 0x603a, 0x602e, 0x6023, 0x0001, 0x6007,
-	0x0035, 0x6003, 0x0001, 0x7954, 0x6156, 0x080c, 0x90d9, 0x080c,
-	0x9687, 0x2f60, 0x00fe, 0x0005, 0x2f60, 0x00fe, 0x2001, 0x1987,
+	0x0035, 0x6003, 0x0001, 0x7954, 0x6156, 0x080c, 0x90f8, 0x080c,
+	0x96a6, 0x2f60, 0x00fe, 0x0005, 0x2f60, 0x00fe, 0x2001, 0x1987,
 	0x2004, 0x6042, 0x0005, 0x0016, 0x0096, 0x6814, 0x2048, 0xa87c,
 	0xd0e4, 0x0180, 0xc0e4, 0xa87e, 0xa877, 0x0000, 0xa893, 0x0000,
 	0xa88f, 0x0000, 0xd0cc, 0x0130, 0xc0cc, 0xa87e, 0xa878, 0x2048,
@@ -6419,7 +6421,7 @@
 	0x693c, 0x9103, 0x1e48, 0x683c, 0x602e, 0x6838, 0x9084, 0xfffc,
 	0x683a, 0x6032, 0x2d00, 0x603a, 0x6808, 0x603e, 0x6910, 0x6112,
 	0x6954, 0x6156, 0x6023, 0x0001, 0x6007, 0x0039, 0x6003, 0x0001,
-	0x080c, 0x90d9, 0x080c, 0x9687, 0x009e, 0x001e, 0x0005, 0x6024,
+	0x080c, 0x90f8, 0x080c, 0x96a6, 0x009e, 0x001e, 0x0005, 0x6024,
 	0xd0d4, 0x0510, 0xd0f4, 0x11f8, 0x6038, 0x940a, 0x603c, 0x9303,
 	0x0230, 0x9105, 0x0120, 0x6024, 0xc0d4, 0xc0f5, 0x0098, 0x643a,
 	0x633e, 0xac3e, 0xab42, 0x0046, 0x0036, 0x2400, 0xacac, 0x9402,
@@ -6431,273 +6433,273 @@
 	0x908e, 0x0039, 0x0140, 0x908e, 0x003a, 0x0128, 0x908e, 0x003b,
 	0x0110, 0x9085, 0x0001, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016,
 	0x0026, 0x0036, 0x00e6, 0x2001, 0x1981, 0x200c, 0x8000, 0x2014,
-	0x2001, 0x0032, 0x080c, 0x8f51, 0x2001, 0x1985, 0x82ff, 0x1110,
+	0x2001, 0x0032, 0x080c, 0x8f70, 0x2001, 0x1985, 0x82ff, 0x1110,
 	0x2011, 0x0014, 0x2202, 0x2001, 0x1983, 0x200c, 0x8000, 0x2014,
-	0x2071, 0x196b, 0x711a, 0x721e, 0x2001, 0x0064, 0x080c, 0x8f51,
+	0x2071, 0x196b, 0x711a, 0x721e, 0x2001, 0x0064, 0x080c, 0x8f70,
 	0x2001, 0x1986, 0x82ff, 0x1110, 0x2011, 0x0014, 0x2202, 0x2001,
 	0x1987, 0x9288, 0x000a, 0x2102, 0x2001, 0x1a90, 0x2102, 0x2001,
-	0x0032, 0x080c, 0x15f0, 0x080c, 0x695c, 0x00ee, 0x003e, 0x002e,
+	0x0032, 0x080c, 0x15f0, 0x080c, 0x696a, 0x00ee, 0x003e, 0x002e,
 	0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x00e6, 0x2001, 0x1985,
 	0x2003, 0x0028, 0x2001, 0x1986, 0x2003, 0x0014, 0x2071, 0x196b,
 	0x701b, 0x0000, 0x701f, 0x07d0, 0x2001, 0x1987, 0x2009, 0x001e,
 	0x2102, 0x2001, 0x1a90, 0x2102, 0x2001, 0x0032, 0x080c, 0x15f0,
 	0x00ee, 0x001e, 0x000e, 0x0005, 0x0096, 0x6058, 0x904d, 0x0110,
 	0x080c, 0x1031, 0x009e, 0x0005, 0x0005, 0x00c6, 0x0126, 0x2091,
-	0x8000, 0x080c, 0xae1b, 0x0180, 0x2b08, 0x6112, 0x0ca9, 0x6023,
-	0x0001, 0x2900, 0x6016, 0x2009, 0x0033, 0x080c, 0xaeec, 0x9085,
+	0x8000, 0x080c, 0xae09, 0x0180, 0x2b08, 0x6112, 0x0ca9, 0x6023,
+	0x0001, 0x2900, 0x6016, 0x2009, 0x0033, 0x080c, 0xaeda, 0x9085,
 	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x0096, 0x00e6,
 	0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1500, 0x7090, 0x9086,
 	0x0018, 0x11e0, 0x6014, 0x2048, 0xaa3c, 0xd2e4, 0x1160, 0x2c78,
-	0x080c, 0x9921, 0x01d8, 0x707c, 0xaa50, 0x9206, 0x1160, 0x7080,
+	0x080c, 0x993c, 0x01d8, 0x707c, 0xaa50, 0x9206, 0x1160, 0x7080,
 	0xaa54, 0x9206, 0x1140, 0x6210, 0x00b6, 0x2258, 0xbaa0, 0x00be,
-	0x900e, 0x080c, 0x320a, 0x080c, 0xb276, 0x0020, 0x080c, 0xb824,
-	0x080c, 0xae71, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x7060, 0xaa54,
+	0x900e, 0x080c, 0x3215, 0x080c, 0xb264, 0x0020, 0x080c, 0xb821,
+	0x080c, 0xae5f, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x7060, 0xaa54,
 	0x9206, 0x0d48, 0x0c80, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c,
-	0xae1b, 0x0188, 0x2b08, 0x6112, 0x080c, 0xcfc4, 0x6023, 0x0001,
-	0x2900, 0x6016, 0x2009, 0x004d, 0x080c, 0xaeec, 0x9085, 0x0001,
+	0xae09, 0x0188, 0x2b08, 0x6112, 0x080c, 0xcfd4, 0x6023, 0x0001,
+	0x2900, 0x6016, 0x2009, 0x004d, 0x080c, 0xaeda, 0x9085, 0x0001,
 	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091,
-	0x8000, 0x0016, 0x080c, 0xae1b, 0x0180, 0x2b08, 0x6112, 0x080c,
-	0xcfc4, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e, 0x080c, 0xaeec,
+	0x8000, 0x0016, 0x080c, 0xae09, 0x0180, 0x2b08, 0x6112, 0x080c,
+	0xcfd4, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e, 0x080c, 0xaeda,
 	0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x001e, 0x9006, 0x0cd0,
 	0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0066, 0x0096, 0x00e6,
 	0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1568, 0x7190, 0x6014,
 	0x2048, 0xa814, 0x8003, 0x9106, 0x1530, 0x20e1, 0x0000, 0x2001,
 	0x199f, 0x2003, 0x0000, 0x6014, 0x2048, 0xa830, 0x20a8, 0x8906,
 	0x8006, 0x8007, 0x9094, 0x003f, 0x22e8, 0x9084, 0xffc0, 0x9080,
-	0x001b, 0x20a0, 0x2001, 0x199f, 0x0016, 0x200c, 0x080c, 0xd83a,
+	0x001b, 0x20a0, 0x2001, 0x199f, 0x0016, 0x200c, 0x080c, 0xd84a,
 	0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c38, 0x6014, 0x2048,
-	0xa867, 0x0103, 0x0010, 0x080c, 0xb824, 0x080c, 0xae71, 0x00fe,
+	0xa867, 0x0103, 0x0010, 0x080c, 0xb821, 0x080c, 0xae5f, 0x00fe,
 	0x00ee, 0x009e, 0x006e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e,
 	0x0005, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015,
 	0x11b8, 0x7090, 0x9086, 0x0004, 0x1198, 0x6014, 0x2048, 0x2c78,
-	0x080c, 0x9921, 0x01a8, 0x707c, 0xaa74, 0x9206, 0x1130, 0x7080,
-	0xaa78, 0x9206, 0x1110, 0x080c, 0x31c1, 0x080c, 0xb276, 0x0020,
-	0x080c, 0xb824, 0x080c, 0xae71, 0x00fe, 0x00ee, 0x009e, 0x0005,
+	0x080c, 0x993c, 0x01a8, 0x707c, 0xaa74, 0x9206, 0x1130, 0x7080,
+	0xaa78, 0x9206, 0x1110, 0x080c, 0x31cc, 0x080c, 0xb264, 0x0020,
+	0x080c, 0xb821, 0x080c, 0xae5f, 0x00fe, 0x00ee, 0x009e, 0x0005,
 	0x7060, 0xaa78, 0x9206, 0x0d78, 0x0c80, 0x0096, 0x00e6, 0x00f6,
 	0x2071, 0x1800, 0x9186, 0x0015, 0x1550, 0x7090, 0x9086, 0x0004,
-	0x1530, 0x6014, 0x2048, 0x2c78, 0x080c, 0x9921, 0x05f0, 0x707c,
+	0x1530, 0x6014, 0x2048, 0x2c78, 0x080c, 0x993c, 0x05f0, 0x707c,
 	0xaacc, 0x9206, 0x1180, 0x7080, 0xaad0, 0x9206, 0x1160, 0x080c,
-	0x31c1, 0x0016, 0xa998, 0xaab0, 0x9284, 0x1000, 0xc0fd, 0x080c,
-	0x5690, 0x001e, 0x0010, 0x080c, 0x5481, 0x080c, 0xcb4a, 0x0508,
+	0x31cc, 0x0016, 0xa998, 0xaab0, 0x9284, 0x1000, 0xc0fd, 0x080c,
+	0x569a, 0x001e, 0x0010, 0x080c, 0x548b, 0x080c, 0xcb5a, 0x0508,
 	0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x0080, 0x080c,
-	0xcb4a, 0x01b8, 0x6014, 0x2048, 0x080c, 0x5481, 0x1d70, 0xa87b,
+	0xcb5a, 0x01b8, 0x6014, 0x2048, 0x080c, 0x548b, 0x1d70, 0xa87b,
 	0x0030, 0xa883, 0x0000, 0xa897, 0x4005, 0xa89b, 0x0004, 0x0126,
-	0x2091, 0x8000, 0xa867, 0x0139, 0x080c, 0x6c86, 0x012e, 0x080c,
-	0xae71, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x7060, 0xaad0, 0x9206,
+	0x2091, 0x8000, 0xa867, 0x0139, 0x080c, 0x6c94, 0x012e, 0x080c,
+	0xae5f, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x7060, 0xaad0, 0x9206,
 	0x0930, 0x0888, 0x0016, 0x0026, 0xa87c, 0xd0ac, 0x0178, 0xa938,
 	0xaa34, 0x2100, 0x9205, 0x0150, 0xa890, 0x9106, 0x1118, 0xa88c,
 	0x9206, 0x0120, 0xa992, 0xaa8e, 0x9085, 0x0001, 0x002e, 0x001e,
-	0x0005, 0x00b6, 0x00d6, 0x0036, 0x080c, 0xcb4a, 0x0904, 0xd17f,
+	0x0005, 0x00b6, 0x00d6, 0x0036, 0x080c, 0xcb5a, 0x0904, 0xd18f,
 	0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x929e, 0x4000, 0x1580,
 	0x6310, 0x00c6, 0x2358, 0x2009, 0x0000, 0xa868, 0xd0f4, 0x1140,
-	0x080c, 0x6828, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d,
+	0x080c, 0x6836, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d,
 	0xaa96, 0xa99a, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080,
 	0x0031, 0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098,
 	0x080c, 0x0f7c, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x0035, 0x20a0,
 	0xb8c8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0f7c, 0x00ce, 0x0090,
 	0xaa96, 0x3918, 0x9398, 0x0007, 0x231c, 0x6004, 0x9086, 0x0016,
 	0x0110, 0xa89b, 0x0004, 0xaba2, 0x6310, 0x2358, 0xb804, 0x9084,
-	0x00ff, 0xa89e, 0x080c, 0x6c7a, 0x6017, 0x0000, 0x009e, 0x003e,
+	0x00ff, 0xa89e, 0x080c, 0x6c88, 0x6017, 0x0000, 0x009e, 0x003e,
 	0x00de, 0x00be, 0x0005, 0x0026, 0x0036, 0x0046, 0x00b6, 0x0096,
 	0x00f6, 0x6214, 0x2248, 0x6210, 0x2258, 0x2079, 0x0260, 0x9096,
-	0x0000, 0x11a0, 0xb814, 0x9084, 0x00ff, 0x900e, 0x080c, 0x2840,
+	0x0000, 0x11a0, 0xb814, 0x9084, 0x00ff, 0x900e, 0x080c, 0x284b,
 	0x2118, 0x831f, 0x939c, 0xff00, 0x7838, 0x9084, 0x00ff, 0x931d,
-	0x7c3c, 0x2011, 0x8018, 0x080c, 0x4b14, 0x00a8, 0x9096, 0x0001,
+	0x7c3c, 0x2011, 0x8018, 0x080c, 0x4b1e, 0x00a8, 0x9096, 0x0001,
 	0x1148, 0x89ff, 0x0180, 0xa89b, 0x000d, 0x7838, 0xa8a6, 0x783c,
 	0xa8aa, 0x0048, 0x9096, 0x0002, 0x1130, 0xa89b, 0x000d, 0x7838,
 	0xa8a6, 0x783c, 0xa8aa, 0x00fe, 0x009e, 0x00be, 0x004e, 0x003e,
 	0x002e, 0x0005, 0x00c6, 0x0026, 0x0016, 0x9186, 0x0035, 0x0110,
-	0x6a38, 0x0008, 0x6a2c, 0x080c, 0xcb38, 0x01f0, 0x2260, 0x6120,
+	0x6a38, 0x0008, 0x6a2c, 0x080c, 0xcb48, 0x01f0, 0x2260, 0x6120,
 	0x9186, 0x0003, 0x0118, 0x9186, 0x0006, 0x1190, 0x6838, 0x9206,
 	0x0140, 0x683c, 0x9206, 0x1160, 0x6108, 0x6838, 0x9106, 0x1140,
 	0x0020, 0x6008, 0x693c, 0x9106, 0x1118, 0x6010, 0x6910, 0x9106,
 	0x001e, 0x002e, 0x00ce, 0x0005, 0x9085, 0x0001, 0x0cc8, 0xa974,
 	0xd1cc, 0x0188, 0x918c, 0x00ff, 0x918e, 0x0002, 0x1160, 0xa9a8,
 	0x918c, 0x0f00, 0x810f, 0x918e, 0x0001, 0x1128, 0xa834, 0xa938,
-	0x9115, 0x190c, 0xc258, 0x0005, 0x0036, 0x2019, 0x0001, 0x0010,
-	0x0036, 0x901e, 0x0499, 0x01e0, 0x080c, 0xcb4a, 0x01c8, 0x080c,
-	0xcd33, 0x6037, 0x4000, 0x6014, 0x6017, 0x0000, 0x0096, 0x2048,
-	0xa87c, 0x080c, 0xcd50, 0x1118, 0x080c, 0xb824, 0x0040, 0xa867,
-	0x0103, 0xa877, 0x0000, 0x83ff, 0x1129, 0x080c, 0x6c86, 0x009e,
+	0x9115, 0x190c, 0xc255, 0x0005, 0x0036, 0x2019, 0x0001, 0x0010,
+	0x0036, 0x901e, 0x0499, 0x01e0, 0x080c, 0xcb5a, 0x01c8, 0x080c,
+	0xcd43, 0x6037, 0x4000, 0x6014, 0x6017, 0x0000, 0x0096, 0x2048,
+	0xa87c, 0x080c, 0xcd60, 0x1118, 0x080c, 0xb821, 0x0040, 0xa867,
+	0x0103, 0xa877, 0x0000, 0x83ff, 0x1129, 0x080c, 0x6c94, 0x009e,
 	0x003e, 0x0005, 0xa880, 0xd0b4, 0x0128, 0xa87b, 0x0006, 0xc0ec,
 	0xa882, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002, 0x0020, 0xa87b,
-	0x0005, 0x080c, 0xce44, 0xa877, 0x0000, 0x0005, 0x2001, 0x1810,
+	0x0005, 0x080c, 0xce54, 0xa877, 0x0000, 0x0005, 0x2001, 0x1810,
 	0x2004, 0xd0ec, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0f4,
 	0x000e, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0e4, 0x000e,
 	0x0005, 0x0036, 0x0046, 0x6010, 0x00b6, 0x2058, 0xbba0, 0x00be,
-	0x2021, 0x0007, 0x080c, 0x4ccb, 0x004e, 0x003e, 0x0005, 0x0c51,
+	0x2021, 0x0007, 0x080c, 0x4cd5, 0x004e, 0x003e, 0x0005, 0x0c51,
 	0x1d81, 0x0005, 0x2001, 0x1985, 0x2004, 0x601a, 0x0005, 0x2001,
-	0x1987, 0x2004, 0x6042, 0x0005, 0x080c, 0xae71, 0x0804, 0x9687,
+	0x1987, 0x2004, 0x6042, 0x0005, 0x080c, 0xae5f, 0x0804, 0x96a6,
 	0x00b6, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0dd5, 0x001b,
-	0x006e, 0x00be, 0x0005, 0xd28b, 0xd997, 0xdaf4, 0xd28b, 0xd28b,
-	0xd28b, 0xd28b, 0xd28b, 0xd2c2, 0xdb78, 0xd28b, 0xd28b, 0xd28b,
-	0xd28b, 0xd28b, 0xd28b, 0x080c, 0x0dd5, 0x0066, 0x6000, 0x90b2,
-	0x0016, 0x1a0c, 0x0dd5, 0x0013, 0x006e, 0x0005, 0xd2a6, 0xe0e0,
-	0xd2a6, 0xd2a6, 0xd2a6, 0xd2a6, 0xd2a6, 0xd2a6, 0xe08d, 0xe134,
-	0xd2a6, 0xe759, 0xe78f, 0xe759, 0xe78f, 0xd2a6, 0x080c, 0x0dd5,
+	0x006e, 0x00be, 0x0005, 0xd29b, 0xd9a7, 0xdb04, 0xd29b, 0xd29b,
+	0xd29b, 0xd29b, 0xd29b, 0xd2d2, 0xdb88, 0xd29b, 0xd29b, 0xd29b,
+	0xd29b, 0xd29b, 0xd29b, 0x080c, 0x0dd5, 0x0066, 0x6000, 0x90b2,
+	0x0016, 0x1a0c, 0x0dd5, 0x0013, 0x006e, 0x0005, 0xd2b6, 0xe0fa,
+	0xd2b6, 0xd2b6, 0xd2b6, 0xd2b6, 0xd2b6, 0xd2b6, 0xe0a7, 0xe14e,
+	0xd2b6, 0xe773, 0xe7a9, 0xe773, 0xe7a9, 0xd2b6, 0x080c, 0x0dd5,
 	0x6000, 0x9082, 0x0016, 0x1a0c, 0x0dd5, 0x6000, 0x000a, 0x0005,
-	0xd2c0, 0xdd55, 0xde45, 0xde67, 0xdf26, 0xd2c0, 0xe004, 0xdfae,
-	0xdb84, 0xe063, 0xe078, 0xd2c0, 0xd2c0, 0xd2c0, 0xd2c0, 0xd2c0,
+	0xd2d0, 0xdd66, 0xde58, 0xde7b, 0xdf3b, 0xd2d0, 0xe01a, 0xdfc3,
+	0xdb94, 0xe07d, 0xe092, 0xd2d0, 0xd2d0, 0xd2d0, 0xd2d0, 0xd2d0,
 	0x080c, 0x0dd5, 0x91b2, 0x0053, 0x1a0c, 0x0dd5, 0x2100, 0x91b2,
-	0x0040, 0x1a04, 0xd70b, 0x0002, 0xd30c, 0xd4fc, 0xd30c, 0xd30c,
-	0xd30c, 0xd505, 0xd30c, 0xd30c, 0xd30c, 0xd30c, 0xd30c, 0xd30c,
-	0xd30c, 0xd30c, 0xd30c, 0xd30c, 0xd30c, 0xd30c, 0xd30c, 0xd30c,
-	0xd30c, 0xd30c, 0xd30c, 0xd30e, 0xd371, 0xd380, 0xd3e4, 0xd40f,
-	0xd488, 0xd4e7, 0xd30c, 0xd30c, 0xd508, 0xd30c, 0xd30c, 0xd51d,
-	0xd52a, 0xd30c, 0xd30c, 0xd30c, 0xd30c, 0xd30c, 0xd5ad, 0xd30c,
-	0xd30c, 0xd5c1, 0xd30c, 0xd30c, 0xd57c, 0xd30c, 0xd30c, 0xd30c,
-	0xd5d9, 0xd30c, 0xd30c, 0xd30c, 0xd656, 0xd30c, 0xd30c, 0xd30c,
-	0xd30c, 0xd30c, 0xd30c, 0xd6d3, 0x080c, 0x0dd5, 0x080c, 0x6939,
+	0x0040, 0x1a04, 0xd71b, 0x0002, 0xd31c, 0xd50c, 0xd31c, 0xd31c,
+	0xd31c, 0xd515, 0xd31c, 0xd31c, 0xd31c, 0xd31c, 0xd31c, 0xd31c,
+	0xd31c, 0xd31c, 0xd31c, 0xd31c, 0xd31c, 0xd31c, 0xd31c, 0xd31c,
+	0xd31c, 0xd31c, 0xd31c, 0xd31e, 0xd381, 0xd390, 0xd3f4, 0xd41f,
+	0xd498, 0xd4f7, 0xd31c, 0xd31c, 0xd518, 0xd31c, 0xd31c, 0xd52d,
+	0xd53a, 0xd31c, 0xd31c, 0xd31c, 0xd31c, 0xd31c, 0xd5bd, 0xd31c,
+	0xd31c, 0xd5d1, 0xd31c, 0xd31c, 0xd58c, 0xd31c, 0xd31c, 0xd31c,
+	0xd5e9, 0xd31c, 0xd31c, 0xd31c, 0xd666, 0xd31c, 0xd31c, 0xd31c,
+	0xd31c, 0xd31c, 0xd31c, 0xd6e3, 0x080c, 0x0dd5, 0x080c, 0x6947,
 	0x1150, 0x2001, 0x1837, 0x2004, 0xd0cc, 0x1128, 0x9084, 0x0009,
 	0x9086, 0x0008, 0x1140, 0x6007, 0x0009, 0x602f, 0x0009, 0x6017,
-	0x0000, 0x0804, 0xd4f5, 0x080c, 0x68d5, 0x00e6, 0x00c6, 0x0036,
+	0x0000, 0x0804, 0xd505, 0x080c, 0x68e3, 0x00e6, 0x00c6, 0x0036,
 	0x0026, 0x0016, 0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019, 0x0029,
-	0x080c, 0x927e, 0x0076, 0x903e, 0x080c, 0x9151, 0x2c08, 0x080c,
-	0xe30c, 0x007e, 0x001e, 0x001e, 0x002e, 0x003e, 0x00ce, 0x00ee,
-	0x6610, 0x2658, 0x080c, 0x6617, 0xbe04, 0x9684, 0x00ff, 0x9082,
+	0x080c, 0x929d, 0x0076, 0x903e, 0x080c, 0x9170, 0x2c08, 0x080c,
+	0xe326, 0x007e, 0x001e, 0x001e, 0x002e, 0x003e, 0x00ce, 0x00ee,
+	0x6610, 0x2658, 0x080c, 0x6625, 0xbe04, 0x9684, 0x00ff, 0x9082,
 	0x0006, 0x1268, 0x0016, 0x0026, 0x6210, 0x00b6, 0x2258, 0xbaa0,
-	0x00be, 0x2c08, 0x080c, 0xe9b8, 0x002e, 0x001e, 0x1178, 0x080c,
-	0xe23e, 0x1904, 0xd3dc, 0x080c, 0xe1da, 0x1120, 0x6007, 0x0008,
-	0x0804, 0xd4f5, 0x6007, 0x0009, 0x0804, 0xd4f5, 0x080c, 0xe462,
-	0x0128, 0x080c, 0xe23e, 0x0d78, 0x0804, 0xd3dc, 0x6017, 0x1900,
-	0x0c88, 0x080c, 0x32e5, 0x1904, 0xd708, 0x6106, 0x080c, 0xe18f,
-	0x6007, 0x0006, 0x0804, 0xd4f5, 0x6007, 0x0007, 0x0804, 0xd4f5,
-	0x080c, 0xe7cb, 0x1904, 0xd708, 0x080c, 0x32e5, 0x1904, 0xd708,
+	0x00be, 0x2c08, 0x080c, 0xe9d2, 0x002e, 0x001e, 0x1178, 0x080c,
+	0xe258, 0x1904, 0xd3ec, 0x080c, 0xe1f4, 0x1120, 0x6007, 0x0008,
+	0x0804, 0xd505, 0x6007, 0x0009, 0x0804, 0xd505, 0x080c, 0xe47c,
+	0x0128, 0x080c, 0xe258, 0x0d78, 0x0804, 0xd3ec, 0x6017, 0x1900,
+	0x0c88, 0x080c, 0x32f0, 0x1904, 0xd718, 0x6106, 0x080c, 0xe1a9,
+	0x6007, 0x0006, 0x0804, 0xd505, 0x6007, 0x0007, 0x0804, 0xd505,
+	0x080c, 0xe7e5, 0x1904, 0xd718, 0x080c, 0x32f0, 0x1904, 0xd718,
 	0x00d6, 0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006,
-	0x1220, 0x2001, 0x0001, 0x080c, 0x6544, 0x96b4, 0xff00, 0x8637,
+	0x1220, 0x2001, 0x0001, 0x080c, 0x6552, 0x96b4, 0xff00, 0x8637,
 	0x9686, 0x0006, 0x0188, 0x9686, 0x0004, 0x0170, 0xbe04, 0x96b4,
 	0x00ff, 0x9686, 0x0006, 0x0140, 0x9686, 0x0004, 0x0128, 0x9686,
 	0x0005, 0x0110, 0x00de, 0x0480, 0x00e6, 0x2071, 0x0260, 0x7034,
 	0x9084, 0x0003, 0x1140, 0x7034, 0x9082, 0x0014, 0x0220, 0x7030,
 	0x9084, 0x0003, 0x0130, 0x00ee, 0x6017, 0x0000, 0x602f, 0x0007,
-	0x00b0, 0x00ee, 0x080c, 0xe2a2, 0x1190, 0x9686, 0x0006, 0x1140,
-	0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x320a, 0x002e,
-	0x080c, 0x66a3, 0x6007, 0x000a, 0x00de, 0x0804, 0xd4f5, 0x6007,
-	0x000b, 0x00de, 0x0804, 0xd4f5, 0x080c, 0x31c1, 0x080c, 0xd25f,
-	0x6007, 0x0001, 0x0804, 0xd4f5, 0x080c, 0xe7cb, 0x1904, 0xd708,
-	0x080c, 0x32e5, 0x1904, 0xd708, 0x2071, 0x0260, 0x7034, 0x90b4,
+	0x00b0, 0x00ee, 0x080c, 0xe2bc, 0x1190, 0x9686, 0x0006, 0x1140,
+	0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x3215, 0x002e,
+	0x080c, 0x66b1, 0x6007, 0x000a, 0x00de, 0x0804, 0xd505, 0x6007,
+	0x000b, 0x00de, 0x0804, 0xd505, 0x080c, 0x31cc, 0x080c, 0xd26f,
+	0x6007, 0x0001, 0x0804, 0xd505, 0x080c, 0xe7e5, 0x1904, 0xd718,
+	0x080c, 0x32f0, 0x1904, 0xd718, 0x2071, 0x0260, 0x7034, 0x90b4,
 	0x0003, 0x1948, 0x90b2, 0x0014, 0x0a30, 0x7030, 0x9084, 0x0003,
 	0x1910, 0x6610, 0x2658, 0xbe04, 0x9686, 0x0707, 0x09e8, 0x0026,
-	0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x320a, 0x002e, 0x6007,
-	0x000c, 0x2001, 0x0001, 0x080c, 0xe998, 0x0804, 0xd4f5, 0x080c,
-	0x6939, 0x1140, 0x2001, 0x1837, 0x2004, 0x9084, 0x0009, 0x9086,
-	0x0008, 0x1110, 0x0804, 0xd31b, 0x080c, 0x68d5, 0x6610, 0x2658,
+	0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x3215, 0x002e, 0x6007,
+	0x000c, 0x2001, 0x0001, 0x080c, 0xe9b2, 0x0804, 0xd505, 0x080c,
+	0x6947, 0x1140, 0x2001, 0x1837, 0x2004, 0x9084, 0x0009, 0x9086,
+	0x0008, 0x1110, 0x0804, 0xd32b, 0x080c, 0x68e3, 0x6610, 0x2658,
 	0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006, 0x06c8, 0x1138, 0x0026,
-	0x2001, 0x0006, 0x080c, 0x6584, 0x002e, 0x0050, 0x96b4, 0xff00,
-	0x8637, 0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xd3dc,
-	0x080c, 0xe2af, 0x1120, 0x6007, 0x000e, 0x0804, 0xd4f5, 0x0046,
-	0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x31c1, 0x080c, 0xd25f,
+	0x2001, 0x0006, 0x080c, 0x6592, 0x002e, 0x0050, 0x96b4, 0xff00,
+	0x8637, 0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xd3ec,
+	0x080c, 0xe2c9, 0x1120, 0x6007, 0x000e, 0x0804, 0xd505, 0x0046,
+	0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x31cc, 0x080c, 0xd26f,
 	0x004e, 0x0016, 0x9006, 0x2009, 0x1848, 0x210c, 0xd1a4, 0x0148,
-	0x2009, 0x0029, 0x080c, 0xe5cf, 0x6010, 0x2058, 0xb800, 0xc0e5,
-	0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x0804, 0xd4f5, 0x2001,
-	0x0001, 0x080c, 0x6544, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9,
-	0x0004, 0x2019, 0x1805, 0x2011, 0x0270, 0x080c, 0xbe1c, 0x003e,
+	0x2009, 0x0029, 0x080c, 0xe5e9, 0x6010, 0x2058, 0xb800, 0xc0e5,
+	0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x0804, 0xd505, 0x2001,
+	0x0001, 0x080c, 0x6552, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9,
+	0x0004, 0x2019, 0x1805, 0x2011, 0x0270, 0x080c, 0xbe19, 0x003e,
 	0x002e, 0x001e, 0x015e, 0x9005, 0x0168, 0x96b4, 0xff00, 0x8637,
-	0x9682, 0x0004, 0x0a04, 0xd3dc, 0x9682, 0x0007, 0x0a04, 0xd438,
-	0x0804, 0xd3dc, 0x6017, 0x1900, 0x6007, 0x0009, 0x0804, 0xd4f5,
-	0x080c, 0x6939, 0x1140, 0x2001, 0x1837, 0x2004, 0x9084, 0x0009,
-	0x9086, 0x0008, 0x1110, 0x0804, 0xd31b, 0x080c, 0x68d5, 0x6610,
+	0x9682, 0x0004, 0x0a04, 0xd3ec, 0x9682, 0x0007, 0x0a04, 0xd448,
+	0x0804, 0xd3ec, 0x6017, 0x1900, 0x6007, 0x0009, 0x0804, 0xd505,
+	0x080c, 0x6947, 0x1140, 0x2001, 0x1837, 0x2004, 0x9084, 0x0009,
+	0x9086, 0x0008, 0x1110, 0x0804, 0xd32b, 0x080c, 0x68e3, 0x6610,
 	0x2658, 0xbe04, 0x9684, 0x00ff, 0x0006, 0x9086, 0x0001, 0x000e,
 	0x0170, 0x9082, 0x0006, 0x0698, 0x0150, 0x96b4, 0xff00, 0x8637,
-	0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xd3dc, 0x080c,
-	0xe2dd, 0x1130, 0x080c, 0xe1da, 0x1118, 0x6007, 0x0010, 0x04e8,
-	0x0046, 0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x31c1, 0x080c,
-	0xd25f, 0x004e, 0x0016, 0x9006, 0x2009, 0x1848, 0x210c, 0xd1a4,
-	0x0148, 0x2009, 0x0029, 0x080c, 0xe5cf, 0x6010, 0x2058, 0xb800,
+	0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xd3ec, 0x080c,
+	0xe2f7, 0x1130, 0x080c, 0xe1f4, 0x1118, 0x6007, 0x0010, 0x04e8,
+	0x0046, 0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x31cc, 0x080c,
+	0xd26f, 0x004e, 0x0016, 0x9006, 0x2009, 0x1848, 0x210c, 0xd1a4,
+	0x0148, 0x2009, 0x0029, 0x080c, 0xe5e9, 0x6010, 0x2058, 0xb800,
 	0xc0e5, 0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x00f0, 0x080c,
-	0xe462, 0x0140, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0978,
-	0x0804, 0xd3dc, 0x6017, 0x1900, 0x6007, 0x0009, 0x0070, 0x080c,
-	0x32e5, 0x1904, 0xd708, 0x080c, 0xe7cb, 0x1904, 0xd708, 0x080c,
-	0xd8d5, 0x1904, 0xd3dc, 0x6007, 0x0012, 0x6003, 0x0001, 0x080c,
-	0x9121, 0x080c, 0x9687, 0x0005, 0x6007, 0x0001, 0x6003, 0x0001,
-	0x080c, 0x9121, 0x080c, 0x9687, 0x0cb0, 0x6007, 0x0005, 0x0c68,
-	0x080c, 0xe7cb, 0x1904, 0xd708, 0x080c, 0x32e5, 0x1904, 0xd708,
-	0x080c, 0xd8d5, 0x1904, 0xd3dc, 0x6007, 0x0020, 0x6003, 0x0001,
-	0x080c, 0x9121, 0x080c, 0x9687, 0x0005, 0x080c, 0x32e5, 0x1904,
-	0xd708, 0x6007, 0x0023, 0x6003, 0x0001, 0x080c, 0x9121, 0x080c,
-	0x9687, 0x0005, 0x080c, 0xe7cb, 0x1904, 0xd708, 0x080c, 0x32e5,
-	0x1904, 0xd708, 0x080c, 0xd8d5, 0x1904, 0xd3dc, 0x0016, 0x0026,
+	0xe47c, 0x0140, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0978,
+	0x0804, 0xd3ec, 0x6017, 0x1900, 0x6007, 0x0009, 0x0070, 0x080c,
+	0x32f0, 0x1904, 0xd718, 0x080c, 0xe7e5, 0x1904, 0xd718, 0x080c,
+	0xd8e5, 0x1904, 0xd3ec, 0x6007, 0x0012, 0x6003, 0x0001, 0x080c,
+	0x9140, 0x080c, 0x96a6, 0x0005, 0x6007, 0x0001, 0x6003, 0x0001,
+	0x080c, 0x9140, 0x080c, 0x96a6, 0x0cb0, 0x6007, 0x0005, 0x0c68,
+	0x080c, 0xe7e5, 0x1904, 0xd718, 0x080c, 0x32f0, 0x1904, 0xd718,
+	0x080c, 0xd8e5, 0x1904, 0xd3ec, 0x6007, 0x0020, 0x6003, 0x0001,
+	0x080c, 0x9140, 0x080c, 0x96a6, 0x0005, 0x080c, 0x32f0, 0x1904,
+	0xd718, 0x6007, 0x0023, 0x6003, 0x0001, 0x080c, 0x9140, 0x080c,
+	0x96a6, 0x0005, 0x080c, 0xe7e5, 0x1904, 0xd718, 0x080c, 0x32f0,
+	0x1904, 0xd718, 0x080c, 0xd8e5, 0x1904, 0xd3ec, 0x0016, 0x0026,
 	0x00e6, 0x2071, 0x0260, 0x7244, 0x9286, 0xffff, 0x0180, 0x2c08,
-	0x080c, 0xcb38, 0x01b0, 0x2260, 0x7240, 0x6008, 0x9206, 0x1188,
+	0x080c, 0xcb48, 0x01b0, 0x2260, 0x7240, 0x6008, 0x9206, 0x1188,
 	0x6010, 0x9190, 0x0004, 0x2214, 0x9206, 0x01b8, 0x0050, 0x7240,
-	0x2c08, 0x9006, 0x080c, 0xe599, 0x1180, 0x7244, 0x9286, 0xffff,
+	0x2c08, 0x9006, 0x080c, 0xe5b3, 0x1180, 0x7244, 0x9286, 0xffff,
 	0x01b0, 0x2160, 0x6007, 0x0026, 0x6017, 0x1700, 0x7214, 0x9296,
 	0xffff, 0x1180, 0x6007, 0x0025, 0x0068, 0x6020, 0x9086, 0x0007,
-	0x1d80, 0x6004, 0x9086, 0x0024, 0x1110, 0x080c, 0xae71, 0x2160,
-	0x6007, 0x0025, 0x6003, 0x0001, 0x080c, 0x9121, 0x080c, 0x9687,
-	0x00ee, 0x002e, 0x001e, 0x0005, 0x2001, 0x0001, 0x080c, 0x6544,
+	0x1d80, 0x6004, 0x9086, 0x0024, 0x1110, 0x080c, 0xae5f, 0x2160,
+	0x6007, 0x0025, 0x6003, 0x0001, 0x080c, 0x9140, 0x080c, 0x96a6,
+	0x00ee, 0x002e, 0x001e, 0x0005, 0x2001, 0x0001, 0x080c, 0x6552,
 	0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805,
-	0x2011, 0x0276, 0x080c, 0xbe1c, 0x003e, 0x002e, 0x001e, 0x015e,
-	0x0120, 0x6007, 0x0031, 0x0804, 0xd4f5, 0x080c, 0xba90, 0x080c,
-	0x73a5, 0x1190, 0x0006, 0x0026, 0x0036, 0x080c, 0x73bf, 0x1138,
-	0x080c, 0x768d, 0x080c, 0x6023, 0x080c, 0x72d7, 0x0010, 0x080c,
-	0x737d, 0x003e, 0x002e, 0x000e, 0x0005, 0x080c, 0x32e5, 0x1904,
-	0xd708, 0x080c, 0xd8d5, 0x1904, 0xd3dc, 0x6106, 0x080c, 0xd8f1,
-	0x1120, 0x6007, 0x002b, 0x0804, 0xd4f5, 0x6007, 0x002c, 0x0804,
-	0xd4f5, 0x080c, 0xe7cb, 0x1904, 0xd708, 0x080c, 0x32e5, 0x1904,
-	0xd708, 0x080c, 0xd8d5, 0x1904, 0xd3dc, 0x6106, 0x080c, 0xd8f6,
-	0x1120, 0x6007, 0x002e, 0x0804, 0xd4f5, 0x6007, 0x002f, 0x0804,
-	0xd4f5, 0x080c, 0x32e5, 0x1904, 0xd708, 0x00e6, 0x00d6, 0x00c6,
+	0x2011, 0x0276, 0x080c, 0xbe19, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x0120, 0x6007, 0x0031, 0x0804, 0xd505, 0x080c, 0xba8d, 0x080c,
+	0x73b3, 0x1190, 0x0006, 0x0026, 0x0036, 0x080c, 0x73cd, 0x1138,
+	0x080c, 0x7699, 0x080c, 0x602d, 0x080c, 0x72e5, 0x0010, 0x080c,
+	0x738b, 0x003e, 0x002e, 0x000e, 0x0005, 0x080c, 0x32f0, 0x1904,
+	0xd718, 0x080c, 0xd8e5, 0x1904, 0xd3ec, 0x6106, 0x080c, 0xd901,
+	0x1120, 0x6007, 0x002b, 0x0804, 0xd505, 0x6007, 0x002c, 0x0804,
+	0xd505, 0x080c, 0xe7e5, 0x1904, 0xd718, 0x080c, 0x32f0, 0x1904,
+	0xd718, 0x080c, 0xd8e5, 0x1904, 0xd3ec, 0x6106, 0x080c, 0xd906,
+	0x1120, 0x6007, 0x002e, 0x0804, 0xd505, 0x6007, 0x002f, 0x0804,
+	0xd505, 0x080c, 0x32f0, 0x1904, 0xd718, 0x00e6, 0x00d6, 0x00c6,
 	0x6010, 0x2058, 0xb904, 0x9184, 0x00ff, 0x9086, 0x0006, 0x0158,
 	0x9184, 0xff00, 0x8007, 0x9086, 0x0006, 0x0128, 0x00ce, 0x00de,
-	0x00ee, 0x0804, 0xd4fc, 0x080c, 0x56dc, 0xd0e4, 0x0904, 0xd653,
+	0x00ee, 0x0804, 0xd50c, 0x080c, 0x56e6, 0xd0e4, 0x0904, 0xd663,
 	0x2071, 0x026c, 0x7010, 0x603a, 0x7014, 0x603e, 0x7108, 0x720c,
-	0x080c, 0x6977, 0x0140, 0x6010, 0x2058, 0xb810, 0x9106, 0x1118,
-	0xb814, 0x9206, 0x0510, 0x080c, 0x6973, 0x15b8, 0x2069, 0x1800,
+	0x080c, 0x6985, 0x0140, 0x6010, 0x2058, 0xb810, 0x9106, 0x1118,
+	0xb814, 0x9206, 0x0510, 0x080c, 0x6981, 0x15b8, 0x2069, 0x1800,
 	0x6880, 0x9206, 0x1590, 0x687c, 0x9106, 0x1578, 0x7210, 0x080c,
-	0xcb38, 0x0590, 0x080c, 0xd7c0, 0x0578, 0x080c, 0xe64b, 0x0560,
-	0x622e, 0x6007, 0x0036, 0x6003, 0x0001, 0x080c, 0x90d9, 0x080c,
-	0x9687, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x7214, 0x9286, 0xffff,
-	0x0150, 0x080c, 0xcb38, 0x01c0, 0x9280, 0x0002, 0x2004, 0x7110,
+	0xcb48, 0x0590, 0x080c, 0xd7d0, 0x0578, 0x080c, 0xe665, 0x0560,
+	0x622e, 0x6007, 0x0036, 0x6003, 0x0001, 0x080c, 0x90f8, 0x080c,
+	0x96a6, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x7214, 0x9286, 0xffff,
+	0x0150, 0x080c, 0xcb48, 0x01c0, 0x9280, 0x0002, 0x2004, 0x7110,
 	0x9106, 0x1190, 0x08e0, 0x7210, 0x2c08, 0x9085, 0x0001, 0x080c,
-	0xe599, 0x2c10, 0x2160, 0x0140, 0x0890, 0x6007, 0x0037, 0x602f,
+	0xe5b3, 0x2c10, 0x2160, 0x0140, 0x0890, 0x6007, 0x0037, 0x602f,
 	0x0009, 0x6017, 0x1500, 0x08b8, 0x6007, 0x0037, 0x602f, 0x0003,
-	0x6017, 0x1700, 0x0880, 0x6007, 0x0012, 0x0868, 0x080c, 0x32e5,
-	0x1904, 0xd708, 0x6010, 0x2058, 0xb804, 0x9084, 0xff00, 0x8007,
-	0x9086, 0x0006, 0x1904, 0xd4fc, 0x00e6, 0x00d6, 0x00c6, 0x080c,
-	0x56dc, 0xd0e4, 0x0904, 0xd6cb, 0x2069, 0x1800, 0x2071, 0x026c,
+	0x6017, 0x1700, 0x0880, 0x6007, 0x0012, 0x0868, 0x080c, 0x32f0,
+	0x1904, 0xd718, 0x6010, 0x2058, 0xb804, 0x9084, 0xff00, 0x8007,
+	0x9086, 0x0006, 0x1904, 0xd50c, 0x00e6, 0x00d6, 0x00c6, 0x080c,
+	0x56e6, 0xd0e4, 0x0904, 0xd6db, 0x2069, 0x1800, 0x2071, 0x026c,
 	0x7008, 0x603a, 0x720c, 0x623e, 0x9286, 0xffff, 0x1150, 0x7208,
-	0x00c6, 0x2c08, 0x9085, 0x0001, 0x080c, 0xe599, 0x2c10, 0x00ce,
-	0x05e8, 0x080c, 0xcb38, 0x05d0, 0x7108, 0x9280, 0x0002, 0x2004,
+	0x00c6, 0x2c08, 0x9085, 0x0001, 0x080c, 0xe5b3, 0x2c10, 0x00ce,
+	0x05e8, 0x080c, 0xcb48, 0x05d0, 0x7108, 0x9280, 0x0002, 0x2004,
 	0x9106, 0x15a0, 0x00c6, 0x0026, 0x2260, 0x080c, 0xc76e, 0x002e,
 	0x00ce, 0x7118, 0x918c, 0xff00, 0x810f, 0x9186, 0x0001, 0x0178,
 	0x9186, 0x0005, 0x0118, 0x9186, 0x0007, 0x1198, 0x9280, 0x0005,
-	0x2004, 0x9005, 0x0170, 0x080c, 0xd7c0, 0x0904, 0xd64c, 0x0056,
-	0x7510, 0x7614, 0x080c, 0xe664, 0x005e, 0x00ce, 0x00de, 0x00ee,
+	0x2004, 0x9005, 0x0170, 0x080c, 0xd7d0, 0x0904, 0xd65c, 0x0056,
+	0x7510, 0x7614, 0x080c, 0xe67e, 0x005e, 0x00ce, 0x00de, 0x00ee,
 	0x0005, 0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00, 0x6003,
-	0x0001, 0x080c, 0x90d9, 0x080c, 0x9687, 0x0c78, 0x6007, 0x003b,
-	0x602f, 0x0003, 0x6017, 0x0300, 0x6003, 0x0001, 0x080c, 0x90d9,
-	0x080c, 0x9687, 0x0c10, 0x6007, 0x003b, 0x602f, 0x000b, 0x6017,
-	0x0000, 0x0804, 0xd623, 0x00e6, 0x0026, 0x080c, 0x6939, 0x0550,
-	0x080c, 0x68d5, 0x080c, 0xe83d, 0x1518, 0x2071, 0x1800, 0x70dc,
+	0x0001, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x0c78, 0x6007, 0x003b,
+	0x602f, 0x0003, 0x6017, 0x0300, 0x6003, 0x0001, 0x080c, 0x90f8,
+	0x080c, 0x96a6, 0x0c10, 0x6007, 0x003b, 0x602f, 0x000b, 0x6017,
+	0x0000, 0x0804, 0xd633, 0x00e6, 0x0026, 0x080c, 0x6947, 0x0550,
+	0x080c, 0x68e3, 0x080c, 0xe857, 0x1518, 0x2071, 0x1800, 0x70dc,
 	0x9085, 0x0003, 0x70de, 0x00f6, 0x2079, 0x0100, 0x72b0, 0x9284,
 	0x00ff, 0x707e, 0x78e6, 0x9284, 0xff00, 0x7280, 0x9205, 0x7082,
-	0x78ea, 0x00fe, 0x70e7, 0x0000, 0x080c, 0x6977, 0x0120, 0x2011,
-	0x19ff, 0x2013, 0x07d0, 0xd0ac, 0x1128, 0x080c, 0x2f98, 0x0010,
-	0x080c, 0xe86f, 0x002e, 0x00ee, 0x080c, 0xae71, 0x0804, 0xd4fb,
-	0x080c, 0xae71, 0x0005, 0x2600, 0x0002, 0xd71f, 0xd750, 0xd761,
-	0xd71f, 0xd71f, 0xd721, 0xd772, 0xd71f, 0xd71f, 0xd71f, 0xd73e,
-	0xd71f, 0xd71f, 0xd71f, 0xd77d, 0xd78a, 0xd7bb, 0xd71f, 0x080c,
-	0x0dd5, 0x080c, 0xe7cb, 0x1d20, 0x080c, 0x32e5, 0x1d08, 0x080c,
-	0xd8d5, 0x1148, 0x7038, 0x6016, 0x6007, 0x0045, 0x6003, 0x0001,
-	0x080c, 0x9121, 0x0005, 0x080c, 0x31c1, 0x080c, 0xd25f, 0x6007,
-	0x0001, 0x6003, 0x0001, 0x080c, 0x9121, 0x0005, 0x080c, 0xe7cb,
-	0x1938, 0x080c, 0x32e5, 0x1920, 0x080c, 0xd8d5, 0x1d60, 0x703c,
-	0x6016, 0x6007, 0x004a, 0x6003, 0x0001, 0x080c, 0x9121, 0x0005,
-	0x080c, 0x32e5, 0x1904, 0xd708, 0x2009, 0x0041, 0x080c, 0xe878,
-	0x6007, 0x0047, 0x6003, 0x0001, 0x080c, 0x9121, 0x080c, 0x9687,
-	0x0005, 0x080c, 0x32e5, 0x1904, 0xd708, 0x2009, 0x0042, 0x080c,
-	0xe878, 0x6007, 0x0047, 0x6003, 0x0001, 0x080c, 0x9121, 0x080c,
-	0x9687, 0x0005, 0x080c, 0x32e5, 0x1904, 0xd708, 0x2009, 0x0046,
-	0x080c, 0xe878, 0x080c, 0xae71, 0x0005, 0x080c, 0xd7dd, 0x0904,
-	0xd708, 0x6007, 0x004e, 0x6003, 0x0001, 0x080c, 0x9121, 0x080c,
-	0x9687, 0x0005, 0x6007, 0x004f, 0x6017, 0x0000, 0x7134, 0x918c,
+	0x78ea, 0x00fe, 0x70e7, 0x0000, 0x080c, 0x6985, 0x0120, 0x2011,
+	0x19ff, 0x2013, 0x07d0, 0xd0ac, 0x1128, 0x080c, 0x2fa3, 0x0010,
+	0x080c, 0xe889, 0x002e, 0x00ee, 0x080c, 0xae5f, 0x0804, 0xd50b,
+	0x080c, 0xae5f, 0x0005, 0x2600, 0x0002, 0xd72f, 0xd760, 0xd771,
+	0xd72f, 0xd72f, 0xd731, 0xd782, 0xd72f, 0xd72f, 0xd72f, 0xd74e,
+	0xd72f, 0xd72f, 0xd72f, 0xd78d, 0xd79a, 0xd7cb, 0xd72f, 0x080c,
+	0x0dd5, 0x080c, 0xe7e5, 0x1d20, 0x080c, 0x32f0, 0x1d08, 0x080c,
+	0xd8e5, 0x1148, 0x7038, 0x6016, 0x6007, 0x0045, 0x6003, 0x0001,
+	0x080c, 0x9140, 0x0005, 0x080c, 0x31cc, 0x080c, 0xd26f, 0x6007,
+	0x0001, 0x6003, 0x0001, 0x080c, 0x9140, 0x0005, 0x080c, 0xe7e5,
+	0x1938, 0x080c, 0x32f0, 0x1920, 0x080c, 0xd8e5, 0x1d60, 0x703c,
+	0x6016, 0x6007, 0x004a, 0x6003, 0x0001, 0x080c, 0x9140, 0x0005,
+	0x080c, 0x32f0, 0x1904, 0xd718, 0x2009, 0x0041, 0x080c, 0xe892,
+	0x6007, 0x0047, 0x6003, 0x0001, 0x080c, 0x9140, 0x080c, 0x96a6,
+	0x0005, 0x080c, 0x32f0, 0x1904, 0xd718, 0x2009, 0x0042, 0x080c,
+	0xe892, 0x6007, 0x0047, 0x6003, 0x0001, 0x080c, 0x9140, 0x080c,
+	0x96a6, 0x0005, 0x080c, 0x32f0, 0x1904, 0xd718, 0x2009, 0x0046,
+	0x080c, 0xe892, 0x080c, 0xae5f, 0x0005, 0x080c, 0xd7ed, 0x0904,
+	0xd718, 0x6007, 0x004e, 0x6003, 0x0001, 0x080c, 0x9140, 0x080c,
+	0x96a6, 0x0005, 0x6007, 0x004f, 0x6017, 0x0000, 0x7134, 0x918c,
 	0x00ff, 0x81ff, 0x0508, 0x9186, 0x0001, 0x1160, 0x7140, 0x2001,
 	0x19bc, 0x2004, 0x9106, 0x11b0, 0x7144, 0x2001, 0x19bd, 0x2004,
 	0x9106, 0x0190, 0x9186, 0x0002, 0x1168, 0x2011, 0x0276, 0x20a9,
-	0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xbe30,
-	0x009e, 0x0110, 0x6017, 0x0001, 0x6003, 0x0001, 0x080c, 0x9121,
-	0x080c, 0x9687, 0x0005, 0x6007, 0x0050, 0x703c, 0x6016, 0x0ca0,
+	0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xbe2d,
+	0x009e, 0x0110, 0x6017, 0x0001, 0x6003, 0x0001, 0x080c, 0x9140,
+	0x080c, 0x96a6, 0x0005, 0x6007, 0x0050, 0x703c, 0x6016, 0x0ca0,
 	0x0016, 0x00e6, 0x2071, 0x0260, 0x00b6, 0x00c6, 0x2260, 0x6010,
 	0x2058, 0xb8cc, 0xd084, 0x0150, 0x7128, 0x6048, 0x9106, 0x1120,
 	0x712c, 0x6044, 0x9106, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001,
@@ -6714,831 +6716,833 @@
 	0x0048, 0x2071, 0x1800, 0x7093, 0x0000, 0x6014, 0x2048, 0x080c,
 	0x0fb1, 0x9006, 0x012e, 0x01de, 0x01ce, 0x00ee, 0x008e, 0x009e,
 	0x001e, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00c6, 0x918c,
-	0xffff, 0x11a8, 0x080c, 0x23ad, 0x2099, 0x026c, 0x2001, 0x0014,
+	0xffff, 0x11a8, 0x080c, 0x23b8, 0x2099, 0x026c, 0x2001, 0x0014,
 	0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x00f8, 0x20a8, 0x4003,
-	0x22a8, 0x8108, 0x080c, 0x23ad, 0x2099, 0x0260, 0x0ca8, 0x080c,
-	0x23ad, 0x2061, 0x199f, 0x6004, 0x2098, 0x6008, 0x3518, 0x9312,
+	0x22a8, 0x8108, 0x080c, 0x23b8, 0x2099, 0x0260, 0x0ca8, 0x080c,
+	0x23b8, 0x2061, 0x199f, 0x6004, 0x2098, 0x6008, 0x3518, 0x9312,
 	0x1218, 0x23a8, 0x4003, 0x0048, 0x20a8, 0x4003, 0x22a8, 0x8108,
-	0x080c, 0x23ad, 0x2099, 0x0260, 0x0ca8, 0x2061, 0x199f, 0x2019,
+	0x080c, 0x23b8, 0x2099, 0x0260, 0x0ca8, 0x2061, 0x199f, 0x2019,
 	0x0280, 0x3300, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0260,
 	0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a,
 	0x00ce, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016,
-	0x0026, 0x0036, 0x00c6, 0x81ff, 0x11b8, 0x080c, 0x23c5, 0x20a1,
+	0x0026, 0x0036, 0x00c6, 0x81ff, 0x11b8, 0x080c, 0x23d0, 0x20a1,
 	0x024c, 0x2001, 0x0014, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003,
 	0x0418, 0x20a8, 0x4003, 0x82ff, 0x01f8, 0x22a8, 0x8108, 0x080c,
-	0x23c5, 0x20a1, 0x0240, 0x0c98, 0x080c, 0x23c5, 0x2061, 0x19a2,
+	0x23d0, 0x20a1, 0x0240, 0x0c98, 0x080c, 0x23d0, 0x2061, 0x19a2,
 	0x6004, 0x20a0, 0x6008, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003,
 	0x0058, 0x20a8, 0x4003, 0x82ff, 0x0138, 0x22a8, 0x8108, 0x080c,
-	0x23c5, 0x20a1, 0x0240, 0x0c98, 0x2061, 0x19a2, 0x2019, 0x0260,
+	0x23d0, 0x20a1, 0x0240, 0x0c98, 0x2061, 0x19a2, 0x2019, 0x0260,
 	0x3400, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0240, 0x6006,
 	0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a, 0x00ce,
 	0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x00b6, 0x0066, 0x6610,
 	0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0170,
 	0x9686, 0x0004, 0x0158, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006,
 	0x0128, 0x9686, 0x0004, 0x0110, 0x9085, 0x0001, 0x006e, 0x00be,
-	0x0005, 0x00d6, 0x080c, 0xd96d, 0x00de, 0x0005, 0x00d6, 0x080c,
-	0xd97a, 0x1520, 0x680c, 0x908c, 0xff00, 0x6820, 0x9084, 0x00ff,
+	0x0005, 0x00d6, 0x080c, 0xd97d, 0x00de, 0x0005, 0x00d6, 0x080c,
+	0xd98a, 0x1520, 0x680c, 0x908c, 0xff00, 0x6820, 0x9084, 0x00ff,
 	0x9115, 0x6216, 0x6824, 0x602e, 0xd1e4, 0x0130, 0x9006, 0x080c,
-	0xe998, 0x2009, 0x0001, 0x0078, 0xd1ec, 0x0180, 0x6920, 0x918c,
-	0x00ff, 0x6824, 0x080c, 0x2840, 0x1148, 0x2001, 0x0001, 0x080c,
-	0xe998, 0x2110, 0x900e, 0x080c, 0x320a, 0x0018, 0x9085, 0x0001,
-	0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00c6, 0x080c, 0xaebf,
+	0xe9b2, 0x2009, 0x0001, 0x0078, 0xd1ec, 0x0180, 0x6920, 0x918c,
+	0x00ff, 0x6824, 0x080c, 0x284b, 0x1148, 0x2001, 0x0001, 0x080c,
+	0xe9b2, 0x2110, 0x900e, 0x080c, 0x3215, 0x0018, 0x9085, 0x0001,
+	0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00c6, 0x080c, 0xaead,
 	0x05a8, 0x0016, 0x0026, 0x00c6, 0x2011, 0x0263, 0x2204, 0x8211,
-	0x220c, 0x080c, 0x2840, 0x1578, 0x080c, 0x65a7, 0x1560, 0xbe12,
-	0xbd16, 0x00ce, 0x002e, 0x001e, 0x2b00, 0x6012, 0x080c, 0xe7cb,
-	0x11d8, 0x080c, 0x32e5, 0x11c0, 0x080c, 0xd8d5, 0x0510, 0x2001,
-	0x0007, 0x080c, 0x6558, 0x2001, 0x0007, 0x080c, 0x6584, 0x6017,
+	0x220c, 0x080c, 0x284b, 0x1578, 0x080c, 0x65b5, 0x1560, 0xbe12,
+	0xbd16, 0x00ce, 0x002e, 0x001e, 0x2b00, 0x6012, 0x080c, 0xe7e5,
+	0x11d8, 0x080c, 0x32f0, 0x11c0, 0x080c, 0xd8e5, 0x0510, 0x2001,
+	0x0007, 0x080c, 0x6566, 0x2001, 0x0007, 0x080c, 0x6592, 0x6017,
 	0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
-	0x9121, 0x080c, 0x9687, 0x0010, 0x080c, 0xae71, 0x9085, 0x0001,
-	0x00ce, 0x00be, 0x0005, 0x080c, 0xae71, 0x00ce, 0x002e, 0x001e,
-	0x0ca8, 0x080c, 0xae71, 0x9006, 0x0c98, 0x2069, 0x026d, 0x6800,
+	0x9140, 0x080c, 0x96a6, 0x0010, 0x080c, 0xae5f, 0x9085, 0x0001,
+	0x00ce, 0x00be, 0x0005, 0x080c, 0xae5f, 0x00ce, 0x002e, 0x001e,
+	0x0ca8, 0x080c, 0xae5f, 0x9006, 0x0c98, 0x2069, 0x026d, 0x6800,
 	0x9082, 0x0010, 0x1228, 0x6017, 0x0000, 0x9085, 0x0001, 0x0008,
 	0x9006, 0x0005, 0x6017, 0x0000, 0x2069, 0x026c, 0x6808, 0x9084,
 	0xff00, 0x9086, 0x0800, 0x1190, 0x6904, 0x9186, 0x0018, 0x0118,
 	0x9186, 0x0014, 0x1158, 0x810f, 0x6800, 0x9084, 0x00ff, 0x910d,
 	0x615a, 0x908e, 0x0014, 0x0110, 0x908e, 0x0010, 0x0005, 0x6004,
 	0x90b2, 0x0053, 0x1a0c, 0x0dd5, 0x91b6, 0x0013, 0x1130, 0x2008,
-	0x91b2, 0x0040, 0x1a04, 0xdac4, 0x0092, 0x91b6, 0x0027, 0x0120,
-	0x91b6, 0x0014, 0x190c, 0x0dd5, 0x2001, 0x0007, 0x080c, 0x6584,
-	0x080c, 0x957b, 0x080c, 0xaea2, 0x080c, 0x9687, 0x0005, 0xd9f7,
-	0xd9f9, 0xd9f7, 0xd9f7, 0xd9f7, 0xd9f9, 0xda08, 0xdabd, 0xda5a,
-	0xdabd, 0xda6e, 0xdabd, 0xda08, 0xdabd, 0xdab5, 0xdabd, 0xdab5,
-	0xdabd, 0xdabd, 0xd9f7, 0xd9f7, 0xd9f7, 0xd9f7, 0xd9f7, 0xd9f7,
-	0xd9f7, 0xd9f7, 0xd9f7, 0xd9f7, 0xd9f7, 0xd9f9, 0xd9f7, 0xdabd,
-	0xd9f7, 0xd9f7, 0xdabd, 0xd9f7, 0xdaba, 0xdabd, 0xd9f7, 0xd9f7,
-	0xd9f7, 0xd9f7, 0xdabd, 0xdabd, 0xd9f7, 0xdabd, 0xdabd, 0xd9f7,
-	0xda03, 0xd9f7, 0xd9f7, 0xd9f7, 0xd9f7, 0xdab9, 0xdabd, 0xd9f7,
-	0xd9f7, 0xdabd, 0xdabd, 0xd9f7, 0xd9f7, 0xd9f7, 0xd9f7, 0x080c,
-	0x0dd5, 0x080c, 0x957b, 0x080c, 0xd262, 0x6003, 0x0002, 0x080c,
-	0x9687, 0x0804, 0xdac3, 0x9006, 0x080c, 0x6544, 0x0804, 0xdabd,
-	0x080c, 0x6973, 0x1904, 0xdabd, 0x9006, 0x080c, 0x6544, 0x6010,
+	0x91b2, 0x0040, 0x1a04, 0xdad4, 0x0092, 0x91b6, 0x0027, 0x0120,
+	0x91b6, 0x0014, 0x190c, 0x0dd5, 0x2001, 0x0007, 0x080c, 0x6592,
+	0x080c, 0x959a, 0x080c, 0xae90, 0x080c, 0x96a6, 0x0005, 0xda07,
+	0xda09, 0xda07, 0xda07, 0xda07, 0xda09, 0xda18, 0xdacd, 0xda6a,
+	0xdacd, 0xda7e, 0xdacd, 0xda18, 0xdacd, 0xdac5, 0xdacd, 0xdac5,
+	0xdacd, 0xdacd, 0xda07, 0xda07, 0xda07, 0xda07, 0xda07, 0xda07,
+	0xda07, 0xda07, 0xda07, 0xda07, 0xda07, 0xda09, 0xda07, 0xdacd,
+	0xda07, 0xda07, 0xdacd, 0xda07, 0xdaca, 0xdacd, 0xda07, 0xda07,
+	0xda07, 0xda07, 0xdacd, 0xdacd, 0xda07, 0xdacd, 0xdacd, 0xda07,
+	0xda13, 0xda07, 0xda07, 0xda07, 0xda07, 0xdac9, 0xdacd, 0xda07,
+	0xda07, 0xdacd, 0xdacd, 0xda07, 0xda07, 0xda07, 0xda07, 0x080c,
+	0x0dd5, 0x080c, 0x959a, 0x080c, 0xd272, 0x6003, 0x0002, 0x080c,
+	0x96a6, 0x0804, 0xdad3, 0x9006, 0x080c, 0x6552, 0x0804, 0xdacd,
+	0x080c, 0x6981, 0x1904, 0xdacd, 0x9006, 0x080c, 0x6552, 0x6010,
 	0x2058, 0xb810, 0x9086, 0x00ff, 0x1140, 0x00f6, 0x2079, 0x1800,
 	0x78a8, 0x8000, 0x78aa, 0x00fe, 0x0428, 0x6010, 0x2058, 0xb8c0,
-	0x9005, 0x1178, 0x080c, 0xd24a, 0x1904, 0xdabd, 0x0036, 0x0046,
-	0xbba0, 0x2021, 0x0007, 0x080c, 0x4ccb, 0x004e, 0x003e, 0x0804,
-	0xdabd, 0x080c, 0x3316, 0x1904, 0xdabd, 0x2001, 0x1800, 0x2004,
+	0x9005, 0x1178, 0x080c, 0xd25a, 0x1904, 0xdacd, 0x0036, 0x0046,
+	0xbba0, 0x2021, 0x0007, 0x080c, 0x4cd5, 0x004e, 0x003e, 0x0804,
+	0xdacd, 0x080c, 0x3321, 0x1904, 0xdacd, 0x2001, 0x1800, 0x2004,
 	0x9086, 0x0002, 0x1138, 0x00f6, 0x2079, 0x1800, 0x78a8, 0x8000,
-	0x78aa, 0x00fe, 0x2001, 0x0002, 0x080c, 0x6558, 0x080c, 0x957b,
-	0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9121,
-	0x080c, 0x9687, 0x6110, 0x2158, 0x2009, 0x0001, 0x080c, 0x84ea,
-	0x0804, 0xdac3, 0x6610, 0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637,
-	0x9686, 0x0006, 0x0904, 0xdabd, 0x9686, 0x0004, 0x0904, 0xdabd,
-	0x080c, 0x8ca4, 0x2001, 0x0004, 0x0804, 0xdabb, 0x2001, 0x1800,
+	0x78aa, 0x00fe, 0x2001, 0x0002, 0x080c, 0x6566, 0x080c, 0x959a,
+	0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9140,
+	0x080c, 0x96a6, 0x6110, 0x2158, 0x2009, 0x0001, 0x080c, 0x8507,
+	0x0804, 0xdad3, 0x6610, 0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637,
+	0x9686, 0x0006, 0x0904, 0xdacd, 0x9686, 0x0004, 0x0904, 0xdacd,
+	0x080c, 0x8cc3, 0x2001, 0x0004, 0x0804, 0xdacb, 0x2001, 0x1800,
 	0x2004, 0x9086, 0x0003, 0x1158, 0x0036, 0x0046, 0x6010, 0x2058,
-	0xbba0, 0x2021, 0x0006, 0x080c, 0x4ccb, 0x004e, 0x003e, 0x2001,
-	0x0006, 0x080c, 0xdae1, 0x6610, 0x2658, 0xbe04, 0x0066, 0x96b4,
+	0xbba0, 0x2021, 0x0006, 0x080c, 0x4cd5, 0x004e, 0x003e, 0x2001,
+	0x0006, 0x080c, 0xdaf1, 0x6610, 0x2658, 0xbe04, 0x0066, 0x96b4,
 	0xff00, 0x8637, 0x9686, 0x0006, 0x006e, 0x0168, 0x2001, 0x0006,
-	0x080c, 0x6584, 0x9284, 0x00ff, 0x908e, 0x0007, 0x1120, 0x2001,
-	0x0006, 0x080c, 0x6558, 0x080c, 0x6973, 0x11f8, 0x2001, 0x1837,
+	0x080c, 0x6592, 0x9284, 0x00ff, 0x908e, 0x0007, 0x1120, 0x2001,
+	0x0006, 0x080c, 0x6566, 0x080c, 0x6981, 0x11f8, 0x2001, 0x1837,
 	0x2004, 0xd0a4, 0x01d0, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006,
 	0x01a0, 0x00f6, 0x2079, 0x1800, 0x78a8, 0x8000, 0x78aa, 0x00fe,
-	0x0804, 0xda42, 0x2001, 0x0004, 0x0030, 0x2001, 0x0006, 0x0449,
-	0x0020, 0x0018, 0x0010, 0x080c, 0x6584, 0x080c, 0x957b, 0x080c,
-	0xae71, 0x080c, 0x9687, 0x0005, 0x2600, 0x0002, 0xdad8, 0xdad8,
-	0xdad8, 0xdad8, 0xdad8, 0xdada, 0xdad8, 0xdada, 0xdad8, 0xdad8,
-	0xdada, 0xdad8, 0xdad8, 0xdad8, 0xdada, 0xdada, 0xdada, 0xdada,
-	0x080c, 0x0dd5, 0x080c, 0x957b, 0x080c, 0xae71, 0x080c, 0x9687,
+	0x0804, 0xda52, 0x2001, 0x0004, 0x0030, 0x2001, 0x0006, 0x0449,
+	0x0020, 0x0018, 0x0010, 0x080c, 0x6592, 0x080c, 0x959a, 0x080c,
+	0xae5f, 0x080c, 0x96a6, 0x0005, 0x2600, 0x0002, 0xdae8, 0xdae8,
+	0xdae8, 0xdae8, 0xdae8, 0xdaea, 0xdae8, 0xdaea, 0xdae8, 0xdae8,
+	0xdaea, 0xdae8, 0xdae8, 0xdae8, 0xdaea, 0xdaea, 0xdaea, 0xdaea,
+	0x080c, 0x0dd5, 0x080c, 0x959a, 0x080c, 0xae5f, 0x080c, 0x96a6,
 	0x0005, 0x0016, 0x00b6, 0x00d6, 0x6110, 0x2158, 0xb900, 0xd184,
-	0x0138, 0x080c, 0x6558, 0x9006, 0x080c, 0x6544, 0x080c, 0x31ea,
+	0x0138, 0x080c, 0x6566, 0x9006, 0x080c, 0x6552, 0x080c, 0x31f5,
 	0x00de, 0x00be, 0x001e, 0x0005, 0x6610, 0x2658, 0xb804, 0x9084,
 	0xff00, 0x8007, 0x90b2, 0x000c, 0x1a0c, 0x0dd5, 0x91b6, 0x0015,
 	0x1110, 0x003b, 0x0028, 0x91b6, 0x0016, 0x190c, 0x0dd5, 0x006b,
-	0x0005, 0xb90d, 0xb90d, 0xb90d, 0xb90d, 0xdb76, 0xb90d, 0xdb60,
-	0xdb21, 0xb90d, 0xb90d, 0xb90d, 0xb90d, 0xb90d, 0xb90d, 0xb90d,
-	0xb90d, 0xdb76, 0xb90d, 0xdb60, 0xdb67, 0xb90d, 0xb90d, 0xb90d,
-	0xb90d, 0x00f6, 0x080c, 0x6973, 0x11d8, 0x080c, 0xd24a, 0x11c0,
+	0x0005, 0xb90a, 0xb90a, 0xb90a, 0xb90a, 0xdb86, 0xb90a, 0xdb70,
+	0xdb31, 0xb90a, 0xb90a, 0xb90a, 0xb90a, 0xb90a, 0xb90a, 0xb90a,
+	0xb90a, 0xdb86, 0xb90a, 0xdb70, 0xdb77, 0xb90a, 0xb90a, 0xb90a,
+	0xb90a, 0x00f6, 0x080c, 0x6981, 0x11d8, 0x080c, 0xd25a, 0x11c0,
 	0x6010, 0x905d, 0x01a8, 0xb8c0, 0x9005, 0x0190, 0x9006, 0x080c,
-	0x6544, 0x2001, 0x0002, 0x080c, 0x6558, 0x6023, 0x0001, 0x6003,
-	0x0001, 0x6007, 0x0002, 0x080c, 0x9121, 0x080c, 0x9687, 0x00f0,
-	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2840, 0x11b0,
-	0x080c, 0x6608, 0x0118, 0x080c, 0xae71, 0x0080, 0xb810, 0x0006,
-	0xb814, 0x0006, 0xb8c0, 0x0006, 0x080c, 0x603d, 0x000e, 0xb8c2,
-	0x000e, 0xb816, 0x000e, 0xb812, 0x080c, 0xae71, 0x00fe, 0x0005,
-	0x6604, 0x96b6, 0x001e, 0x1110, 0x080c, 0xae71, 0x0005, 0x080c,
-	0xbc98, 0x1148, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x9121,
-	0x080c, 0x9687, 0x0010, 0x080c, 0xae71, 0x0005, 0x0804, 0xae71,
-	0x6004, 0x908a, 0x0053, 0x1a0c, 0x0dd5, 0x080c, 0x957b, 0x080c,
-	0xaea2, 0x080c, 0x9687, 0x0005, 0x9182, 0x0040, 0x0002, 0xdb9a,
-	0xdb9a, 0xdb9a, 0xdb9a, 0xdb9c, 0xdb9a, 0xdb9a, 0xdb9a, 0xdb9a,
-	0xdb9a, 0xdb9a, 0xdb9a, 0xdb9a, 0xdb9a, 0xdb9a, 0xdb9a, 0xdb9a,
-	0xdb9a, 0xdb9a, 0x080c, 0x0dd5, 0x0096, 0x00b6, 0x00d6, 0x00e6,
-	0x00f6, 0x0046, 0x0026, 0x6210, 0x2258, 0xb8bc, 0x9005, 0x11a8,
-	0x6106, 0x2071, 0x0260, 0x7444, 0x94a4, 0xff00, 0x0904, 0xdc02,
-	0x080c, 0xe98c, 0x1170, 0x9486, 0x2000, 0x1158, 0x2009, 0x0001,
-	0x2011, 0x0200, 0x080c, 0x86c6, 0x0020, 0x9026, 0x080c, 0xe810,
-	0x0c38, 0x080c, 0x0fff, 0x090c, 0x0dd5, 0x6003, 0x0007, 0xa867,
-	0x010d, 0x9006, 0xa802, 0xa86a, 0xac8a, 0x2c00, 0xa88e, 0x6008,
-	0xa8e2, 0x6010, 0x2058, 0xb8a0, 0x7130, 0xa97a, 0x0016, 0xa876,
-	0xa87f, 0x0000, 0xa883, 0x0000, 0xa887, 0x0036, 0x080c, 0x6c86,
-	0x001e, 0x080c, 0xe98c, 0x1904, 0xdc62, 0x9486, 0x2000, 0x1130,
-	0x2019, 0x0017, 0x080c, 0xe543, 0x0804, 0xdc62, 0x9486, 0x0200,
-	0x1120, 0x080c, 0xe4df, 0x0804, 0xdc62, 0x9486, 0x0400, 0x0120,
-	0x9486, 0x1000, 0x1904, 0xdc62, 0x2019, 0x0002, 0x080c, 0xe4fa,
-	0x0804, 0xdc62, 0x2069, 0x1a70, 0x6a00, 0xd284, 0x0904, 0xdccc,
-	0x9284, 0x0300, 0x1904, 0xdcc5, 0x6804, 0x9005, 0x0904, 0xdcad,
-	0x2d78, 0x6003, 0x0007, 0x080c, 0x1018, 0x0904, 0xdc6e, 0x7800,
-	0xd08c, 0x1118, 0x7804, 0x8001, 0x7806, 0x6017, 0x0000, 0x2001,
-	0x180f, 0x2004, 0xd084, 0x1904, 0xdcd0, 0x9006, 0xa802, 0xa867,
-	0x0116, 0xa86a, 0x6008, 0xa8e2, 0x2c00, 0xa87a, 0x6010, 0x2058,
-	0xb8a0, 0x7130, 0xa9b6, 0xa876, 0xb928, 0xa9ba, 0xb92c, 0xa9be,
-	0xb930, 0xa9c2, 0xb934, 0xa9c6, 0xa883, 0x003d, 0x7044, 0x9084,
-	0x0003, 0x9080, 0xdc6a, 0x2005, 0xa87e, 0x20a9, 0x000a, 0x2001,
-	0x0270, 0xaa5c, 0x9290, 0x0021, 0x2009, 0x0205, 0x200b, 0x0080,
-	0x20e1, 0x0000, 0xab60, 0x23e8, 0x2098, 0x22a0, 0x4003, 0x200b,
-	0x0000, 0x2001, 0x027a, 0x200c, 0xa9b2, 0x8000, 0x200c, 0xa9ae,
-	0x080c, 0x6c86, 0x002e, 0x004e, 0x00fe, 0x00ee, 0x00de, 0x00be,
-	0x009e, 0x0005, 0x0000, 0x0080, 0x0040, 0x0000, 0x2001, 0x1810,
-	0x2004, 0xd084, 0x0120, 0x080c, 0x0fff, 0x1904, 0xdc17, 0x6017,
-	0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c, 0x90d9, 0x080c,
-	0x9687, 0x0c00, 0x2069, 0x0260, 0x6848, 0x9084, 0xff00, 0x9086,
-	0x1200, 0x1198, 0x686c, 0x9084, 0x00ff, 0x0016, 0x6114, 0x918c,
-	0xf700, 0x910d, 0x6116, 0x001e, 0x6003, 0x0001, 0x6007, 0x0043,
-	0x080c, 0x90d9, 0x080c, 0x9687, 0x0828, 0x6868, 0x602e, 0x686c,
-	0x6032, 0x6017, 0xf200, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c,
-	0x90d9, 0x080c, 0x9687, 0x0804, 0xdc62, 0x2001, 0x180e, 0x2004,
-	0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x4b14, 0x6017, 0xf300,
-	0x0010, 0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c,
-	0x90d9, 0x080c, 0x9687, 0x0804, 0xdc62, 0x6017, 0xf500, 0x0c98,
-	0x6017, 0xf600, 0x0804, 0xdc82, 0x6017, 0xf200, 0x0804, 0xdc82,
-	0xa867, 0x0146, 0xa86b, 0x0000, 0x6008, 0xa886, 0x2c00, 0xa87a,
-	0x7044, 0x9084, 0x0003, 0x9080, 0xdc6a, 0x2005, 0xa87e, 0x2928,
-	0x6010, 0x2058, 0xb8a0, 0xa876, 0xb828, 0xa88a, 0xb82c, 0xa88e,
-	0xb830, 0xa892, 0xb834, 0xa896, 0xa883, 0x003d, 0x2009, 0x0205,
-	0x2104, 0x9085, 0x0080, 0x200a, 0x20e1, 0x0000, 0x2011, 0x0210,
-	0x2214, 0x9294, 0x0fff, 0xaaa2, 0x9282, 0x0111, 0x1a0c, 0x0dd5,
-	0x8210, 0x821c, 0x2001, 0x026c, 0x2098, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x0029, 0x20a0, 0x2011, 0xdd4c, 0x2041, 0x0001, 0x223d,
-	0x9784, 0x00ff, 0x9322, 0x1208, 0x2300, 0x20a8, 0x4003, 0x931a,
-	0x0530, 0x8210, 0xd7fc, 0x1130, 0x8d68, 0x2d0a, 0x2001, 0x0260,
-	0x2098, 0x0c68, 0x2950, 0x080c, 0x1018, 0x0170, 0x2900, 0xb002,
-	0xa867, 0x0147, 0xa86b, 0x0000, 0xa860, 0x20e8, 0xa85c, 0x9080,
-	0x001b, 0x20a0, 0x8840, 0x08d8, 0x2548, 0xa800, 0x902d, 0x0118,
-	0x080c, 0x1031, 0x0cc8, 0x080c, 0x1031, 0x0804, 0xdc6e, 0x2548,
-	0x8847, 0x9885, 0x0046, 0xa866, 0x2009, 0x0205, 0x200b, 0x0000,
-	0x080c, 0xe572, 0x0804, 0xdc62, 0x8010, 0x0004, 0x801a, 0x0006,
-	0x8018, 0x0008, 0x8016, 0x000a, 0x8014, 0x9186, 0x0013, 0x1160,
-	0x6004, 0x908a, 0x0054, 0x1a0c, 0x0dd5, 0x9082, 0x0040, 0x0a0c,
-	0x0dd5, 0x2008, 0x0804, 0xddfd, 0x9186, 0x0051, 0x0108, 0x00c0,
-	0x2001, 0x0109, 0x2004, 0xd084, 0x0904, 0xddae, 0x0126, 0x2091,
-	0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x8fbe, 0x002e, 0x001e,
-	0x000e, 0x012e, 0x6000, 0x9086, 0x0002, 0x1580, 0x0804, 0xde45,
-	0x9186, 0x0027, 0x0530, 0x9186, 0x0048, 0x0128, 0x9186, 0x0014,
-	0x0500, 0x190c, 0x0dd5, 0x2001, 0x0109, 0x2004, 0xd084, 0x01f0,
-	0x00c6, 0x0126, 0x2091, 0x2800, 0x00c6, 0x2061, 0x0100, 0x0006,
-	0x0016, 0x0026, 0x080c, 0x8fbe, 0x002e, 0x001e, 0x000e, 0x00ce,
-	0x012e, 0x00ce, 0x6000, 0x9086, 0x0004, 0x190c, 0x0dd5, 0x0804,
-	0xdf26, 0x6004, 0x9082, 0x0040, 0x2008, 0x001a, 0x080c, 0xaf07,
-	0x0005, 0xddc4, 0xddc6, 0xddc6, 0xdded, 0xddc4, 0xddc4, 0xddc4,
-	0xddc4, 0xddc4, 0xddc4, 0xddc4, 0xddc4, 0xddc4, 0xddc4, 0xddc4,
-	0xddc4, 0xddc4, 0xddc4, 0xddc4, 0x080c, 0x0dd5, 0x080c, 0x957b,
-	0x080c, 0x9687, 0x0036, 0x0096, 0x6014, 0x904d, 0x01d8, 0x080c,
-	0xcb4a, 0x01c0, 0x6003, 0x0002, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x1178, 0x2019, 0x0004, 0x080c, 0xe572, 0x6017,
-	0x0000, 0x6018, 0x9005, 0x1120, 0x2001, 0x1986, 0x2004, 0x601a,
-	0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x0096, 0x080c, 0x957b,
-	0x080c, 0x9687, 0x080c, 0xcb4a, 0x0120, 0x6014, 0x2048, 0x080c,
-	0x1031, 0x080c, 0xaea2, 0x009e, 0x0005, 0x0002, 0xde11, 0xde28,
-	0xde13, 0xde3f, 0xde11, 0xde11, 0xde11, 0xde11, 0xde11, 0xde11,
-	0xde11, 0xde11, 0xde11, 0xde11, 0xde11, 0xde11, 0xde11, 0xde11,
-	0xde11, 0x080c, 0x0dd5, 0x0096, 0x080c, 0x957b, 0x6014, 0x2048,
-	0xa87c, 0xd0b4, 0x0138, 0x6003, 0x0007, 0x2009, 0x0043, 0x080c,
-	0xaeec, 0x0010, 0x6003, 0x0004, 0x080c, 0x9687, 0x009e, 0x0005,
-	0x080c, 0x957b, 0x080c, 0xcb4a, 0x0138, 0x6114, 0x0096, 0x2148,
-	0xa97c, 0x009e, 0xd1ec, 0x1138, 0x080c, 0x869b, 0x080c, 0xae71,
-	0x080c, 0x9687, 0x0005, 0x080c, 0xe7d4, 0x0db0, 0x0cc8, 0x080c,
-	0x957b, 0x2009, 0x0041, 0x0804, 0xdfae, 0x9182, 0x0040, 0x0002,
-	0xde5b, 0xde5d, 0xde5b, 0xde5b, 0xde5b, 0xde5b, 0xde5b, 0xde5b,
-	0xde5b, 0xde5b, 0xde5b, 0xde5b, 0xde5b, 0xde5b, 0xde5b, 0xde5b,
-	0xde5b, 0xde5e, 0xde5b, 0x080c, 0x0dd5, 0x0005, 0x00d6, 0x080c,
-	0x869b, 0x00de, 0x080c, 0xe82c, 0x080c, 0xae71, 0x0005, 0x9182,
-	0x0040, 0x0002, 0xde7d, 0xde7d, 0xde7d, 0xde7d, 0xde7d, 0xde7d,
-	0xde7d, 0xde7d, 0xde7d, 0xde7f, 0xdeee, 0xde7d, 0xde7d, 0xde7d,
-	0xde7d, 0xdeee, 0xde7d, 0xde7d, 0xde7d, 0x080c, 0x0dd5, 0x2001,
-	0x0105, 0x2004, 0x9084, 0x1800, 0x01c8, 0x2001, 0x0132, 0x200c,
-	0x2001, 0x0131, 0x2004, 0x9105, 0x1904, 0xdeee, 0x2009, 0x180c,
-	0x2104, 0xd0d4, 0x0904, 0xdeee, 0xc0d4, 0x200a, 0x2009, 0x0105,
-	0x2104, 0x9084, 0xe7fd, 0x9085, 0x0010, 0x200a, 0x2001, 0x1867,
-	0x2004, 0xd0e4, 0x1528, 0x603b, 0x0000, 0x080c, 0x9637, 0x6014,
-	0x0096, 0x2048, 0xa87c, 0xd0fc, 0x0188, 0x908c, 0x0003, 0x918e,
-	0x0002, 0x0508, 0x2001, 0x180c, 0x2004, 0xd0d4, 0x11e0, 0x080c,
-	0x97b5, 0x2009, 0x0041, 0x009e, 0x0804, 0xdfae, 0x080c, 0x97b5,
-	0x6003, 0x0007, 0x601b, 0x0000, 0x080c, 0x869b, 0x009e, 0x0005,
-	0x2001, 0x0100, 0x2004, 0x9082, 0x0005, 0x0aa8, 0x2001, 0x011f,
-	0x2004, 0x603a, 0x0890, 0x2001, 0x180c, 0x200c, 0xc1d4, 0x2102,
-	0xd1cc, 0x0110, 0x080c, 0x2c54, 0x080c, 0x97b5, 0x6014, 0x2048,
-	0xa97c, 0xd1ec, 0x1130, 0x080c, 0x869b, 0x080c, 0xae71, 0x009e,
-	0x0005, 0x080c, 0xe7d4, 0x0db8, 0x009e, 0x0005, 0x2001, 0x180c,
-	0x200c, 0xc1d4, 0x2102, 0x0036, 0x080c, 0x9637, 0x080c, 0x97b5,
-	0x6014, 0x0096, 0x2048, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
-	0xd0bc, 0x0188, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x0140,
-	0xa8ac, 0x6330, 0x931a, 0x6332, 0xa8b0, 0x632c, 0x931b, 0x632e,
-	0x6003, 0x0002, 0x0080, 0x2019, 0x0004, 0x080c, 0xe572, 0x6018,
-	0x9005, 0x1128, 0x2001, 0x1986, 0x2004, 0x8003, 0x601a, 0x6017,
-	0x0000, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x9182, 0x0040,
-	0x0002, 0xdf3d, 0xdf3d, 0xdf3d, 0xdf3d, 0xdf3d, 0xdf3d, 0xdf3d,
-	0xdf3d, 0xdf3f, 0xdf3d, 0xdf3d, 0xdf3d, 0xdf3d, 0xdf3d, 0xdf3d,
-	0xdf3d, 0xdf3d, 0xdf3d, 0xdf3d, 0xdf8a, 0x080c, 0x0dd5, 0x6014,
-	0x0096, 0x2048, 0xa834, 0xaa38, 0x6110, 0x00b6, 0x2158, 0xb900,
-	0x00be, 0xd1bc, 0x1190, 0x920d, 0x1518, 0xa87c, 0xd0fc, 0x0128,
-	0x2009, 0x0041, 0x009e, 0x0804, 0xdfae, 0x6003, 0x0007, 0x601b,
-	0x0000, 0x080c, 0x869b, 0x009e, 0x0005, 0x6124, 0xd1f4, 0x1d58,
-	0x0006, 0x0046, 0xacac, 0x9422, 0xa9b0, 0x2200, 0x910b, 0x6030,
-	0x9420, 0x6432, 0x602c, 0x9109, 0x612e, 0x004e, 0x000e, 0x08d8,
-	0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1bc, 0x1178, 0x2009,
-	0x180e, 0x210c, 0xd19c, 0x0118, 0x6003, 0x0007, 0x0010, 0x6003,
-	0x0006, 0x00e9, 0x080c, 0x869d, 0x009e, 0x0005, 0x6003, 0x0002,
-	0x009e, 0x0005, 0x6024, 0xd0f4, 0x0128, 0x080c, 0x15e7, 0x1904,
-	0xdf3f, 0x0005, 0x6014, 0x0096, 0x2048, 0xa834, 0xa938, 0x009e,
-	0x9105, 0x1120, 0x080c, 0x15e7, 0x1904, 0xdf3f, 0x0005, 0xd2fc,
-	0x0140, 0x8002, 0x8000, 0x8212, 0x9291, 0x0000, 0x2009, 0x0009,
-	0x0010, 0x2009, 0x0015, 0xaa9a, 0xa896, 0x0005, 0x9182, 0x0040,
-	0x0208, 0x0062, 0x9186, 0x0013, 0x0120, 0x9186, 0x0014, 0x190c,
-	0x0dd5, 0x6024, 0xd0dc, 0x090c, 0x0dd5, 0x0005, 0xdfd1, 0xdfdd,
-	0xdfe9, 0xdff5, 0xdfd1, 0xdfd1, 0xdfd1, 0xdfd1, 0xdfd8, 0xdfd3,
-	0xdfd3, 0xdfd1, 0xdfd1, 0xdfd1, 0xdfd1, 0xdfd3, 0xdfd1, 0xdfd3,
-	0xdfd1, 0x080c, 0x0dd5, 0x6024, 0xd0dc, 0x090c, 0x0dd5, 0x0005,
-	0x6014, 0x9005, 0x190c, 0x0dd5, 0x0005, 0x6003, 0x0001, 0x6106,
-	0x080c, 0x90d9, 0x0126, 0x2091, 0x8000, 0x080c, 0x9687, 0x012e,
-	0x0005, 0x6003, 0x0001, 0x6106, 0x080c, 0x90d9, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x9687, 0x012e, 0x0005, 0x6003, 0x0003, 0x6106,
-	0x2c10, 0x080c, 0x1baf, 0x0126, 0x2091, 0x8000, 0x080c, 0x913e,
-	0x080c, 0x97b5, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0036,
-	0x0096, 0x9182, 0x0040, 0x0023, 0x009e, 0x003e, 0x012e, 0x0005,
-	0xe020, 0xe022, 0xe034, 0xe04e, 0xe020, 0xe020, 0xe020, 0xe020,
-	0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020,
-	0x080c, 0x0dd5, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x01f8, 0x909c,
-	0x0003, 0x939e, 0x0003, 0x01d0, 0x6003, 0x0001, 0x6106, 0x080c,
-	0x90d9, 0x080c, 0x9687, 0x0470, 0x6014, 0x2048, 0xa87c, 0xd0fc,
-	0x0168, 0x909c, 0x0003, 0x939e, 0x0003, 0x0140, 0x6003, 0x0001,
-	0x6106, 0x080c, 0x90d9, 0x080c, 0x9687, 0x00e0, 0x901e, 0x6316,
-	0x631a, 0x2019, 0x0004, 0x080c, 0xe572, 0x00a0, 0x6014, 0x2048,
-	0xa87c, 0xd0fc, 0x0d98, 0x909c, 0x0003, 0x939e, 0x0003, 0x0d70,
-	0x6003, 0x0003, 0x6106, 0x2c10, 0x080c, 0x1baf, 0x080c, 0x913e,
-	0x080c, 0x97b5, 0x0005, 0x080c, 0x957b, 0x6114, 0x81ff, 0x0158,
-	0x0096, 0x2148, 0x080c, 0xe929, 0x0036, 0x2019, 0x0029, 0x080c,
-	0xe572, 0x003e, 0x009e, 0x080c, 0xaea2, 0x080c, 0x9687, 0x0005,
-	0x080c, 0x9637, 0x6114, 0x81ff, 0x0158, 0x0096, 0x2148, 0x080c,
-	0xe929, 0x0036, 0x2019, 0x0029, 0x080c, 0xe572, 0x003e, 0x009e,
-	0x080c, 0xaea2, 0x080c, 0x97b5, 0x0005, 0x9182, 0x0085, 0x0002,
-	0xe09f, 0xe09d, 0xe09d, 0xe0ab, 0xe09d, 0xe09d, 0xe09d, 0xe09d,
-	0xe09d, 0xe09d, 0xe09d, 0xe09d, 0xe09d, 0x080c, 0x0dd5, 0x6003,
-	0x000b, 0x6106, 0x080c, 0x90d9, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x9687, 0x012e, 0x0005, 0x0026, 0x00e6, 0x080c, 0xe7cb, 0x0118,
-	0x080c, 0xae71, 0x0450, 0x2071, 0x0260, 0x7224, 0x6216, 0x2001,
-	0x180e, 0x2004, 0xd0e4, 0x0150, 0x6010, 0x00b6, 0x2058, 0xbca0,
-	0x00be, 0x2c00, 0x2011, 0x014e, 0x080c, 0xb192, 0x7220, 0x080c,
-	0xe418, 0x0118, 0x6007, 0x0086, 0x0040, 0x6007, 0x0087, 0x7224,
-	0x9296, 0xffff, 0x1110, 0x6007, 0x0086, 0x6003, 0x0001, 0x080c,
-	0x90d9, 0x080c, 0x9687, 0x080c, 0x97b5, 0x00ee, 0x002e, 0x0005,
-	0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0dd5,
-	0x908a, 0x0092, 0x1a0c, 0x0dd5, 0x9082, 0x0085, 0x00a2, 0x9186,
-	0x0027, 0x0130, 0x9186, 0x0014, 0x0118, 0x080c, 0xaf07, 0x0050,
-	0x2001, 0x0007, 0x080c, 0x6584, 0x080c, 0x957b, 0x080c, 0xaea2,
-	0x080c, 0x9687, 0x0005, 0xe110, 0xe112, 0xe112, 0xe110, 0xe110,
-	0xe110, 0xe110, 0xe110, 0xe110, 0xe110, 0xe110, 0xe110, 0xe110,
-	0x080c, 0x0dd5, 0x080c, 0x957b, 0x080c, 0xaea2, 0x080c, 0x9687,
-	0x0005, 0x9182, 0x0085, 0x0a0c, 0x0dd5, 0x9182, 0x0092, 0x1a0c,
-	0x0dd5, 0x9182, 0x0085, 0x0002, 0xe131, 0xe131, 0xe131, 0xe133,
-	0xe131, 0xe131, 0xe131, 0xe131, 0xe131, 0xe131, 0xe131, 0xe131,
-	0xe131, 0x080c, 0x0dd5, 0x0005, 0x9186, 0x0013, 0x0148, 0x9186,
-	0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c, 0xaf07, 0x0030,
-	0x080c, 0x957b, 0x080c, 0xaea2, 0x080c, 0x9687, 0x0005, 0x0036,
-	0x080c, 0xe82c, 0x6043, 0x0000, 0x2019, 0x000b, 0x0031, 0x6023,
-	0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x0126, 0x0036, 0x2091,
-	0x8000, 0x0086, 0x2c40, 0x0096, 0x904e, 0x080c, 0xa69d, 0x009e,
-	0x008e, 0x1550, 0x0076, 0x2c38, 0x080c, 0xa748, 0x007e, 0x1520,
-	0x6000, 0x9086, 0x0000, 0x0500, 0x6020, 0x9086, 0x0007, 0x01e0,
-	0x0096, 0x601c, 0xd084, 0x0140, 0x080c, 0xe82c, 0x080c, 0xd262,
-	0x080c, 0x1a60, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c, 0xcb4a,
-	0x0110, 0x080c, 0xe572, 0x009e, 0x6017, 0x0000, 0x080c, 0xe82c,
-	0x6023, 0x0007, 0x080c, 0xd262, 0x003e, 0x012e, 0x0005, 0x00f6,
-	0x00c6, 0x00b6, 0x0036, 0x0156, 0x2079, 0x0260, 0x7938, 0x783c,
-	0x080c, 0x2840, 0x15c8, 0x0016, 0x00c6, 0x080c, 0x6608, 0x1590,
-	0x001e, 0x00c6, 0x2160, 0x080c, 0xd25f, 0x00ce, 0x002e, 0x0026,
-	0x0016, 0x2019, 0x0029, 0x080c, 0xa80e, 0x080c, 0x927e, 0x0076,
-	0x903e, 0x080c, 0x9151, 0x007e, 0x001e, 0x0076, 0x903e, 0x080c,
-	0xe30c, 0x007e, 0x0026, 0xba04, 0x9294, 0xff00, 0x8217, 0x9286,
-	0x0006, 0x0118, 0x9286, 0x0004, 0x1118, 0xbaa0, 0x080c, 0x327f,
-	0x002e, 0xbcc0, 0x001e, 0x080c, 0x603d, 0xbe12, 0xbd16, 0xbcc2,
-	0x9006, 0x0010, 0x00ce, 0x001e, 0x015e, 0x003e, 0x00be, 0x00ce,
-	0x00fe, 0x0005, 0x00c6, 0x00d6, 0x00b6, 0x0016, 0x2009, 0x1824,
-	0x2104, 0x9086, 0x0074, 0x1904, 0xe233, 0x2069, 0x0260, 0x6944,
-	0x9182, 0x0100, 0x06e0, 0x6940, 0x9184, 0x8000, 0x0904, 0xe230,
-	0x2001, 0x197b, 0x2004, 0x9005, 0x1140, 0x6010, 0x2058, 0xb8c0,
-	0x9005, 0x0118, 0x9184, 0x0800, 0x0598, 0x6948, 0x918a, 0x0001,
-	0x0648, 0x080c, 0xe991, 0x0118, 0x6978, 0xd1fc, 0x11b8, 0x2009,
-	0x0205, 0x200b, 0x0001, 0x693c, 0x81ff, 0x1198, 0x6944, 0x9182,
-	0x0100, 0x02a8, 0x6940, 0x81ff, 0x1178, 0x6948, 0x918a, 0x0001,
-	0x0288, 0x6950, 0x918a, 0x0001, 0x0298, 0x00d0, 0x6017, 0x0100,
-	0x00a0, 0x6017, 0x0300, 0x0088, 0x6017, 0x0500, 0x0070, 0x6017,
-	0x0700, 0x0058, 0x6017, 0x0900, 0x0040, 0x6017, 0x0b00, 0x0028,
-	0x6017, 0x0f00, 0x0010, 0x6017, 0x2d00, 0x9085, 0x0001, 0x0008,
-	0x9006, 0x001e, 0x00be, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00b6,
-	0x0026, 0x0036, 0x0156, 0x6210, 0x2258, 0xbb04, 0x9394, 0x00ff,
-	0x9286, 0x0006, 0x0180, 0x9286, 0x0004, 0x0168, 0x9394, 0xff00,
-	0x8217, 0x9286, 0x0006, 0x0138, 0x9286, 0x0004, 0x0120, 0x080c,
-	0x6617, 0x0804, 0xe29b, 0x2011, 0x0276, 0x20a9, 0x0004, 0x0096,
-	0x2b48, 0x2019, 0x000a, 0x080c, 0xbe30, 0x009e, 0x15a8, 0x2011,
-	0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x0006, 0x080c,
-	0xbe30, 0x009e, 0x1548, 0x0046, 0x0016, 0xbaa0, 0x2220, 0x9006,
-	0x2009, 0x1848, 0x210c, 0xd1a4, 0x0138, 0x2009, 0x0029, 0x080c,
-	0xe5cf, 0xb800, 0xc0e5, 0xb802, 0x2019, 0x0029, 0x080c, 0x927e,
-	0x0076, 0x2039, 0x0000, 0x080c, 0x9151, 0x2c08, 0x080c, 0xe30c,
-	0x007e, 0x2001, 0x0007, 0x080c, 0x6584, 0x2001, 0x0007, 0x080c,
-	0x6558, 0x001e, 0x004e, 0x9006, 0x015e, 0x003e, 0x002e, 0x00be,
-	0x00ce, 0x0005, 0x00d6, 0x2069, 0x026e, 0x6800, 0x9086, 0x0800,
-	0x0118, 0x6017, 0x0000, 0x0008, 0x9006, 0x00de, 0x0005, 0x00b6,
-	0x00f6, 0x0016, 0x0026, 0x0036, 0x0156, 0x2079, 0x026c, 0x7930,
-	0x7834, 0x080c, 0x2840, 0x11d0, 0x080c, 0x6608, 0x11b8, 0x2011,
-	0x0270, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c,
-	0xbe30, 0x009e, 0x1158, 0x2011, 0x0274, 0x20a9, 0x0004, 0x0096,
-	0x2b48, 0x2019, 0x0006, 0x080c, 0xbe30, 0x009e, 0x015e, 0x003e,
-	0x002e, 0x001e, 0x00fe, 0x00be, 0x0005, 0x00b6, 0x0006, 0x0016,
-	0x0026, 0x0036, 0x0156, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c,
-	0x080c, 0x2840, 0x11d0, 0x080c, 0x6608, 0x11b8, 0x2011, 0x0276,
-	0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xbe30,
-	0x009e, 0x1158, 0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48,
-	0x2019, 0x0006, 0x080c, 0xbe30, 0x009e, 0x015e, 0x003e, 0x002e,
-	0x001e, 0x000e, 0x00be, 0x0005, 0x00e6, 0x00c6, 0x0086, 0x0076,
-	0x0066, 0x0056, 0x0046, 0x0026, 0x0126, 0x2091, 0x8000, 0x2740,
-	0x2029, 0x19ef, 0x252c, 0x2021, 0x19f5, 0x2424, 0x2061, 0x1cd0,
-	0x2071, 0x1800, 0x7654, 0x7074, 0x81ff, 0x0150, 0x0006, 0x9186,
-	0x1aaf, 0x000e, 0x0128, 0x8001, 0x9602, 0x1a04, 0xe3a9, 0x0018,
-	0x9606, 0x0904, 0xe3a9, 0x080c, 0x896a, 0x0904, 0xe3a0, 0x2100,
-	0x9c06, 0x0904, 0xe3a0, 0x080c, 0xe610, 0x1904, 0xe3a0, 0x080c,
-	0xe9ae, 0x0904, 0xe3a0, 0x080c, 0xe600, 0x0904, 0xe3a0, 0x6720,
-	0x9786, 0x0001, 0x1148, 0x080c, 0x3316, 0x0904, 0xe3e8, 0x6004,
-	0x9086, 0x0000, 0x1904, 0xe3e8, 0x9786, 0x0004, 0x0904, 0xe3e8,
-	0x9786, 0x0007, 0x0904, 0xe3a0, 0x2500, 0x9c06, 0x0904, 0xe3a0,
-	0x2400, 0x9c06, 0x05e8, 0x88ff, 0x0118, 0x6054, 0x9906, 0x15c0,
-	0x0096, 0x6000, 0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x1a60,
-	0x001e, 0x9786, 0x000a, 0x0148, 0x080c, 0xcd50, 0x1130, 0x080c,
-	0xb824, 0x009e, 0x080c, 0xaea2, 0x0418, 0x6014, 0x2048, 0x080c,
-	0xcb4a, 0x01d8, 0x9786, 0x0003, 0x1570, 0xa867, 0x0103, 0xa87c,
-	0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fb1, 0x009e,
-	0xab7a, 0xa877, 0x0000, 0x080c, 0xe929, 0x0016, 0x080c, 0xce3e,
-	0x080c, 0x6c7a, 0x001e, 0x080c, 0xcd33, 0x009e, 0x080c, 0xaea2,
-	0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1210, 0x0804,
-	0xe320, 0x012e, 0x002e, 0x004e, 0x005e, 0x006e, 0x007e, 0x008e,
-	0x00ce, 0x00ee, 0x0005, 0x9786, 0x0006, 0x1150, 0x9386, 0x0005,
-	0x0128, 0x080c, 0xe929, 0x080c, 0xe572, 0x08f8, 0x009e, 0x0c00,
-	0x9786, 0x0009, 0x11f8, 0x6000, 0x9086, 0x0004, 0x01c0, 0x6000,
-	0x9086, 0x0003, 0x11a0, 0x080c, 0x9637, 0x0096, 0x6114, 0x2148,
-	0x080c, 0xcb4a, 0x0118, 0x6010, 0x080c, 0x6c86, 0x009e, 0x00c6,
-	0x080c, 0xae71, 0x00ce, 0x0036, 0x080c, 0x97b5, 0x003e, 0x009e,
-	0x0804, 0xe3a0, 0x9786, 0x000a, 0x0904, 0xe387, 0x0804, 0xe385,
-	0x81ff, 0x0904, 0xe3a0, 0x9180, 0x0001, 0x2004, 0x9086, 0x0018,
-	0x0138, 0x9180, 0x0001, 0x2004, 0x9086, 0x002d, 0x1904, 0xe3a0,
-	0x6000, 0x9086, 0x0002, 0x1904, 0xe3a0, 0x080c, 0xcd3f, 0x0138,
-	0x080c, 0xcd50, 0x1904, 0xe3a0, 0x080c, 0xb824, 0x0038, 0x080c,
-	0x31ea, 0x080c, 0xcd50, 0x1110, 0x080c, 0xb824, 0x080c, 0xaea2,
-	0x0804, 0xe3a0, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x0005,
-	0x00c6, 0x00e6, 0x0016, 0x2c08, 0x2170, 0x9006, 0x080c, 0xe599,
-	0x001e, 0x0120, 0x6020, 0x9084, 0x000f, 0x001b, 0x00ee, 0x00ce,
-	0x0005, 0xe437, 0xe437, 0xe437, 0xe437, 0xe437, 0xe437, 0xe439,
-	0xe437, 0xe437, 0xe437, 0xe437, 0xaea2, 0xaea2, 0xe437, 0x9006,
-	0x0005, 0x0036, 0x0046, 0x0016, 0x7010, 0x00b6, 0x2058, 0xbca0,
-	0x00be, 0x2c00, 0x2009, 0x0020, 0x080c, 0xe5cf, 0x001e, 0x004e,
-	0x2019, 0x0002, 0x080c, 0xe155, 0x003e, 0x9085, 0x0001, 0x0005,
-	0x0096, 0x080c, 0xcb4a, 0x0140, 0x6014, 0x904d, 0x080c, 0xc77b,
-	0x687b, 0x0005, 0x080c, 0x6c86, 0x009e, 0x080c, 0xaea2, 0x9085,
-	0x0001, 0x0005, 0x2001, 0x0001, 0x080c, 0x6544, 0x0156, 0x0016,
-	0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x0276,
-	0x080c, 0xbe1c, 0x003e, 0x002e, 0x001e, 0x015e, 0x9005, 0x0005,
-	0x00f6, 0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066, 0x00b6, 0x0126,
-	0x2091, 0x8000, 0x2740, 0x2061, 0x1cd0, 0x2079, 0x0001, 0x8fff,
-	0x0904, 0xe4d2, 0x2071, 0x1800, 0x7654, 0x7074, 0x8001, 0x9602,
-	0x1a04, 0xe4d2, 0x88ff, 0x0120, 0x2800, 0x9c06, 0x1590, 0x2078,
-	0x080c, 0xe600, 0x0570, 0x2400, 0x9c06, 0x0558, 0x6720, 0x9786,
-	0x0006, 0x1538, 0x9786, 0x0007, 0x0520, 0x88ff, 0x1140, 0x6010,
-	0x9b06, 0x11f8, 0x85ff, 0x0118, 0x6054, 0x9106, 0x11d0, 0x0096,
-	0x601c, 0xd084, 0x0140, 0x080c, 0xe82c, 0x080c, 0xd262, 0x080c,
-	0x1a60, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c, 0xcb4a, 0x0120,
-	0x0046, 0x080c, 0xe572, 0x004e, 0x009e, 0x080c, 0xaea2, 0x88ff,
-	0x1198, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1210,
-	0x0804, 0xe487, 0x9006, 0x012e, 0x00be, 0x006e, 0x007e, 0x008e,
-	0x00ce, 0x00ee, 0x00fe, 0x0005, 0x98c5, 0x0001, 0x0ca0, 0x00b6,
-	0x0076, 0x0056, 0x0086, 0x9046, 0x2029, 0x0001, 0x2c20, 0x2019,
-	0x0002, 0x6210, 0x2258, 0x0096, 0x904e, 0x080c, 0xa69d, 0x009e,
-	0x008e, 0x903e, 0x080c, 0xa748, 0x080c, 0xe478, 0x005e, 0x007e,
-	0x00be, 0x0005, 0x00b6, 0x0046, 0x0056, 0x0076, 0x00c6, 0x0156,
-	0x2c20, 0x2128, 0x20a9, 0x007f, 0x900e, 0x0016, 0x0036, 0x080c,
-	0x6608, 0x1190, 0x0056, 0x0086, 0x9046, 0x2508, 0x2029, 0x0001,
-	0x0096, 0x904e, 0x080c, 0xa69d, 0x009e, 0x008e, 0x903e, 0x080c,
-	0xa748, 0x080c, 0xe478, 0x005e, 0x003e, 0x001e, 0x8108, 0x1f04,
-	0xe505, 0x015e, 0x00ce, 0x007e, 0x005e, 0x004e, 0x00be, 0x0005,
-	0x00b6, 0x0076, 0x0056, 0x6210, 0x2258, 0x0086, 0x9046, 0x2029,
-	0x0001, 0x2019, 0x0048, 0x0096, 0x904e, 0x080c, 0xa69d, 0x009e,
-	0x008e, 0x903e, 0x080c, 0xa748, 0x2c20, 0x080c, 0xe478, 0x005e,
-	0x007e, 0x00be, 0x0005, 0x00b6, 0x0046, 0x0056, 0x0076, 0x00c6,
-	0x0156, 0x2c20, 0x20a9, 0x0800, 0x900e, 0x0016, 0x0036, 0x080c,
-	0x6608, 0x11a0, 0x0086, 0x9046, 0x2828, 0x0046, 0x2021, 0x0001,
-	0x080c, 0xe810, 0x004e, 0x0096, 0x904e, 0x080c, 0xa69d, 0x009e,
-	0x008e, 0x903e, 0x080c, 0xa748, 0x080c, 0xe478, 0x003e, 0x001e,
-	0x8108, 0x1f04, 0xe54d, 0x015e, 0x00ce, 0x007e, 0x005e, 0x004e,
-	0x00be, 0x0005, 0x0016, 0x00f6, 0x080c, 0xcb48, 0x0198, 0xa864,
-	0x9084, 0x00ff, 0x9086, 0x0046, 0x0180, 0xa800, 0x907d, 0x0138,
-	0xa803, 0x0000, 0xab82, 0x080c, 0x6c86, 0x2f48, 0x0cb0, 0xab82,
-	0x080c, 0x6c86, 0x00fe, 0x001e, 0x0005, 0xa800, 0x907d, 0x0130,
-	0xa803, 0x0000, 0x080c, 0x6c86, 0x2f48, 0x0cb8, 0x080c, 0x6c86,
-	0x0c88, 0x00e6, 0x0046, 0x0036, 0x2061, 0x1cd0, 0x9005, 0x1138,
-	0x2071, 0x1800, 0x7454, 0x7074, 0x8001, 0x9402, 0x12f8, 0x2100,
-	0x9c06, 0x0188, 0x6000, 0x9086, 0x0000, 0x0168, 0x6008, 0x9206,
-	0x1150, 0x6320, 0x9386, 0x0009, 0x01b0, 0x6010, 0x91a0, 0x0004,
-	0x2424, 0x9406, 0x0140, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004,
-	0x9c02, 0x1220, 0x0c20, 0x9085, 0x0001, 0x0008, 0x9006, 0x003e,
-	0x004e, 0x00ee, 0x0005, 0x631c, 0xd3c4, 0x1d68, 0x0c30, 0x0096,
-	0x0006, 0x080c, 0x0fff, 0x000e, 0x090c, 0x0dd5, 0xaae2, 0xa867,
-	0x010d, 0xa88e, 0x0026, 0x2010, 0x080c, 0xcb38, 0x2001, 0x0000,
-	0x0120, 0x2200, 0x9080, 0x0015, 0x2004, 0x002e, 0xa87a, 0x9186,
-	0x0020, 0x0110, 0xa8e3, 0xffff, 0xa986, 0xac76, 0xa87f, 0x0000,
-	0x2001, 0x198d, 0x2004, 0xa882, 0x9006, 0xa802, 0xa86a, 0xa88a,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6c86, 0x012e, 0x009e, 0x0005,
-	0x6700, 0x9786, 0x0000, 0x0158, 0x9786, 0x0001, 0x0140, 0x9786,
-	0x000a, 0x0128, 0x9786, 0x0009, 0x0110, 0x9085, 0x0001, 0x0005,
-	0x00e6, 0x6010, 0x9075, 0x0138, 0x00b6, 0x2058, 0xb8a0, 0x00be,
-	0x9206, 0x00ee, 0x0005, 0x9085, 0x0001, 0x0cd8, 0x0016, 0x6004,
-	0x908e, 0x001e, 0x11a0, 0x8007, 0x6134, 0x918c, 0x00ff, 0x9105,
-	0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0005, 0x2001,
-	0x1986, 0x2004, 0x601a, 0x080c, 0x90d9, 0x080c, 0x9687, 0x001e,
-	0x0005, 0xa001, 0xa001, 0x0005, 0x6024, 0xd0e4, 0x0158, 0xd0cc,
-	0x0118, 0x080c, 0xce82, 0x0030, 0x080c, 0xe82c, 0x080c, 0x869b,
-	0x080c, 0xae71, 0x0005, 0x9280, 0x0008, 0x2004, 0x9084, 0x000f,
-	0x0002, 0xe65f, 0xe65f, 0xe65f, 0xe661, 0xe65f, 0xe661, 0xe661,
-	0xe65f, 0xe661, 0xe65f, 0xe65f, 0xe65f, 0xe65f, 0xe65f, 0x9006,
-	0x0005, 0x9085, 0x0001, 0x0005, 0x9280, 0x0008, 0x2004, 0x9084,
-	0x000f, 0x0002, 0xe678, 0xe678, 0xe678, 0xe678, 0xe678, 0xe678,
-	0xe685, 0xe678, 0xe678, 0xe678, 0xe678, 0xe678, 0xe678, 0xe678,
-	0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00, 0x6003, 0x0001,
-	0x080c, 0x90d9, 0x080c, 0x9687, 0x0005, 0x0096, 0x00c6, 0x2260,
-	0x080c, 0xe82c, 0x6043, 0x0000, 0x6024, 0xc0f4, 0xc0e4, 0x6026,
-	0x603b, 0x0000, 0x00ce, 0x00d6, 0x2268, 0x9186, 0x0007, 0x1904,
-	0xe6de, 0x6814, 0x9005, 0x0138, 0x2048, 0xa87c, 0xd0fc, 0x1118,
-	0x00de, 0x009e, 0x08a8, 0x6007, 0x003a, 0x6003, 0x0001, 0x080c,
-	0x90d9, 0x080c, 0x9687, 0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002,
-	0x1904, 0xe755, 0x6014, 0x9005, 0x1138, 0x6000, 0x9086, 0x0007,
-	0x190c, 0x0dd5, 0x0804, 0xe755, 0x2048, 0x080c, 0xcb4a, 0x1130,
-	0x0028, 0x2048, 0xa800, 0x9005, 0x1de0, 0x2900, 0x2048, 0xa87c,
-	0x9084, 0x0003, 0x9086, 0x0002, 0x1168, 0xa87c, 0xc0dc, 0xc0f4,
-	0xa87e, 0xa880, 0xc0fc, 0xa882, 0x2009, 0x0043, 0x080c, 0xdfae,
-	0x0804, 0xe755, 0x2009, 0x0041, 0x0804, 0xe74f, 0x9186, 0x0005,
-	0x15a0, 0x6814, 0x2048, 0xa87c, 0xd0bc, 0x1120, 0x00de, 0x009e,
-	0x0804, 0xe678, 0xd0b4, 0x0128, 0xd0fc, 0x090c, 0x0dd5, 0x0804,
-	0xe699, 0x6007, 0x003a, 0x6003, 0x0001, 0x080c, 0x90d9, 0x080c,
-	0x9687, 0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002, 0x0120, 0x9186,
-	0x0004, 0x1904, 0xe755, 0x6814, 0x2048, 0xa97c, 0xc1f4, 0xc1dc,
-	0xa97e, 0xa980, 0xc1fc, 0xc1bc, 0xa982, 0x00f6, 0x2c78, 0x080c,
-	0x1727, 0x00fe, 0x2009, 0x0042, 0x04d0, 0x0036, 0x080c, 0x0fff,
-	0x090c, 0x0dd5, 0xa867, 0x010d, 0x9006, 0xa802, 0xa86a, 0xa88a,
-	0x2d18, 0xab8e, 0xa887, 0x0045, 0x2c00, 0xa892, 0x6038, 0xa8a2,
-	0x2360, 0x6024, 0xc0dd, 0x6026, 0x6010, 0x00b6, 0x2058, 0xb8a0,
-	0x00be, 0x2004, 0x6354, 0xab7a, 0xa876, 0x9006, 0xa87e, 0xa882,
-	0xad9a, 0xae96, 0xa89f, 0x0001, 0x080c, 0x6c86, 0x2019, 0x0045,
-	0x6008, 0x2068, 0x080c, 0xe155, 0x2d00, 0x600a, 0x6023, 0x0006,
-	0x6003, 0x0007, 0x901e, 0x631a, 0x6342, 0x003e, 0x0038, 0x6043,
-	0x0000, 0x6003, 0x0007, 0x080c, 0xdfae, 0x00ce, 0x00de, 0x009e,
-	0x0005, 0x9186, 0x0013, 0x1128, 0x6004, 0x9082, 0x0085, 0x2008,
-	0x00c2, 0x9186, 0x0027, 0x1178, 0x080c, 0x957b, 0x0036, 0x0096,
-	0x6014, 0x2048, 0x2019, 0x0004, 0x080c, 0xe572, 0x009e, 0x003e,
-	0x080c, 0x9687, 0x0005, 0x9186, 0x0014, 0x0d70, 0x080c, 0xaf07,
-	0x0005, 0xe788, 0xe786, 0xe786, 0xe786, 0xe786, 0xe786, 0xe788,
-	0xe786, 0xe786, 0xe786, 0xe786, 0xe786, 0xe786, 0x080c, 0x0dd5,
-	0x080c, 0x957b, 0x6003, 0x000c, 0x080c, 0x9687, 0x0005, 0x9182,
-	0x0092, 0x1220, 0x9182, 0x0085, 0x0208, 0x001a, 0x080c, 0xaf07,
-	0x0005, 0xe7a6, 0xe7a6, 0xe7a6, 0xe7a6, 0xe7a8, 0xe7c8, 0xe7a6,
-	0xe7a6, 0xe7a6, 0xe7a6, 0xe7a6, 0xe7a6, 0xe7a6, 0x080c, 0x0dd5,
-	0x00d6, 0x2c68, 0x080c, 0xae1b, 0x01b0, 0x6003, 0x0001, 0x6007,
-	0x001e, 0x2009, 0x026e, 0x210c, 0x613a, 0x2009, 0x026f, 0x210c,
-	0x613e, 0x600b, 0xffff, 0x6910, 0x6112, 0x6023, 0x0004, 0x080c,
-	0x90d9, 0x080c, 0x9687, 0x2d60, 0x080c, 0xae71, 0x00de, 0x0005,
-	0x080c, 0xae71, 0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0ec, 0x00ee, 0x0005, 0x2009, 0x1867, 0x210c, 0xd1ec,
-	0x05b0, 0x6003, 0x0002, 0x6024, 0xc0e5, 0x6026, 0xd0cc, 0x0150,
-	0x2001, 0x1987, 0x2004, 0x6042, 0x2009, 0x1867, 0x210c, 0xd1f4,
-	0x1520, 0x00a0, 0x2009, 0x1867, 0x210c, 0xd1f4, 0x0128, 0x6024,
-	0xc0e4, 0x6026, 0x9006, 0x00d8, 0x2001, 0x1987, 0x200c, 0x2001,
-	0x1985, 0x2004, 0x9100, 0x9080, 0x000a, 0x6042, 0x6010, 0x00b6,
-	0x2058, 0xb8bc, 0x00be, 0x0008, 0x2104, 0x9005, 0x0118, 0x9088,
-	0x0003, 0x0cd0, 0x2c0a, 0x600f, 0x0000, 0x9085, 0x0001, 0x0005,
-	0x0016, 0x00c6, 0x00e6, 0x6154, 0xb8bc, 0x2060, 0x8cff, 0x0180,
-	0x84ff, 0x1118, 0x6054, 0x9106, 0x1138, 0x600c, 0x2072, 0x080c,
-	0x869b, 0x080c, 0xae71, 0x0010, 0x9cf0, 0x0003, 0x2e64, 0x0c70,
-	0x00ee, 0x00ce, 0x001e, 0x0005, 0x00d6, 0x00b6, 0x6010, 0x2058,
-	0xb8bc, 0x2068, 0x9005, 0x0130, 0x9c06, 0x0110, 0x680c, 0x0cd0,
-	0x600c, 0x680e, 0x00be, 0x00de, 0x0005, 0x0026, 0x0036, 0x0156,
-	0x2011, 0x182c, 0x2204, 0x9084, 0x00ff, 0x2019, 0x026e, 0x2334,
-	0x9636, 0x1508, 0x8318, 0x2334, 0x2204, 0x9084, 0xff00, 0x9636,
-	0x11d0, 0x2011, 0x0270, 0x20a9, 0x0004, 0x6010, 0x0096, 0x2048,
-	0x2019, 0x000a, 0x080c, 0xbe30, 0x009e, 0x1168, 0x2011, 0x0274,
-	0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x0006, 0x080c,
-	0xbe30, 0x009e, 0x1100, 0x015e, 0x003e, 0x002e, 0x0005, 0x00e6,
-	0x2071, 0x1800, 0x080c, 0x5fb6, 0x080c, 0x2f98, 0x00ee, 0x0005,
-	0x0096, 0x0026, 0x080c, 0x0fff, 0x090c, 0x0dd5, 0xa85c, 0x9080,
-	0x001a, 0x20a0, 0x20a9, 0x000c, 0xa860, 0x20e8, 0x9006, 0x4004,
-	0x9186, 0x0046, 0x1118, 0xa867, 0x0136, 0x0038, 0xa867, 0x0138,
-	0x9186, 0x0041, 0x0110, 0xa87b, 0x0001, 0x7038, 0x9084, 0xff00,
-	0x7240, 0x9294, 0xff00, 0x8007, 0x9215, 0xaa9a, 0x9186, 0x0046,
-	0x1168, 0x7038, 0x9084, 0x00ff, 0x723c, 0x9294, 0xff00, 0x9215,
-	0xaa9e, 0x723c, 0x9294, 0x00ff, 0xaaa2, 0x0060, 0x7040, 0x9084,
-	0x00ff, 0x7244, 0x9294, 0xff00, 0x9215, 0xaa9e, 0x7244, 0x9294,
-	0x00ff, 0xaaa2, 0x9186, 0x0046, 0x1118, 0x9e90, 0x0012, 0x0010,
-	0x9e90, 0x001a, 0x2204, 0x8007, 0xa8a6, 0x8210, 0x2204, 0x8007,
-	0xa8aa, 0x8210, 0x2204, 0x8007, 0xa8ae, 0x8210, 0x2204, 0x8007,
-	0xa8b2, 0x8210, 0x9186, 0x0046, 0x11b8, 0x9e90, 0x0016, 0x2204,
-	0x8007, 0xa8b6, 0x8210, 0x2204, 0x8007, 0xa8ba, 0x8210, 0x2204,
-	0x8007, 0xa8be, 0x8210, 0x2204, 0x8007, 0xa8c2, 0x8210, 0x2011,
-	0x0205, 0x2013, 0x0001, 0x00b0, 0x9e90, 0x001e, 0x2204, 0x8007,
-	0xa8b6, 0x8210, 0x2204, 0x8007, 0xa8ba, 0x2011, 0x0205, 0x2013,
-	0x0001, 0x2011, 0x0260, 0x2204, 0x8007, 0xa8be, 0x8210, 0x2204,
-	0x8007, 0xa8c2, 0x9186, 0x0046, 0x1118, 0x2011, 0x0262, 0x0010,
-	0x2011, 0x026a, 0x0146, 0x01d6, 0x0036, 0x20a9, 0x0001, 0x2019,
-	0x0008, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031, 0x20a0, 0x2204,
-	0x8007, 0x4004, 0x8210, 0x8319, 0x1dd0, 0x003e, 0x01ce, 0x013e,
-	0x2011, 0x0205, 0x2013, 0x0000, 0x002e, 0x080c, 0x6c86, 0x009e,
-	0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0fc,
-	0x0108, 0x0011, 0x00ee, 0x0005, 0xa880, 0xc0e5, 0xa882, 0x0005,
-	0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066, 0x0056, 0x0046, 0x0026,
-	0x0016, 0x0126, 0x2091, 0x8000, 0x2029, 0x19ef, 0x252c, 0x2021,
-	0x19f5, 0x2424, 0x2061, 0x1cd0, 0x2071, 0x1800, 0x7654, 0x7074,
-	0x9606, 0x0578, 0x6720, 0x9786, 0x0001, 0x0118, 0x9786, 0x0008,
-	0x1500, 0x2500, 0x9c06, 0x01e8, 0x2400, 0x9c06, 0x01d0, 0x080c,
-	0xe600, 0x01b8, 0x080c, 0xe610, 0x11a0, 0x6000, 0x9086, 0x0004,
-	0x1120, 0x0016, 0x080c, 0x1a60, 0x001e, 0x080c, 0xcd3f, 0x1110,
-	0x080c, 0x31ea, 0x080c, 0xcd50, 0x1110, 0x080c, 0xb824, 0x080c,
-	0xaea2, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1208,
-	0x0858, 0x012e, 0x001e, 0x002e, 0x004e, 0x005e, 0x006e, 0x007e,
-	0x00ce, 0x00de, 0x00ee, 0x0005, 0x2001, 0x1810, 0x2004, 0xd0dc,
-	0x0005, 0x0006, 0x2001, 0x1837, 0x2004, 0xd09c, 0x000e, 0x0005,
-	0x0006, 0x0036, 0x0046, 0x080c, 0xd24a, 0x0168, 0x2019, 0xffff,
-	0x9005, 0x0128, 0x6010, 0x00b6, 0x2058, 0xbba0, 0x00be, 0x2021,
-	0x0004, 0x080c, 0x4ccb, 0x004e, 0x003e, 0x000e, 0x6004, 0x9086,
-	0x0001, 0x1128, 0x080c, 0xa80e, 0x080c, 0xaea2, 0x9006, 0x0005,
-	0x00e6, 0x00c6, 0x00b6, 0x0046, 0x2061, 0x1cd0, 0x2071, 0x1800,
-	0x7454, 0x7074, 0x8001, 0x9402, 0x12b8, 0x2100, 0x9c06, 0x0148,
-	0x6000, 0x9086, 0x0000, 0x0128, 0x6010, 0x2058, 0xb8a0, 0x9206,
-	0x0140, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1220,
-	0x0c60, 0x9085, 0x0001, 0x0008, 0x9006, 0x004e, 0x00be, 0x00ce,
-	0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6, 0x0016, 0x2091, 0x8000,
-	0x2071, 0x1840, 0xd5a4, 0x0118, 0x7004, 0x8000, 0x7006, 0xd5b4,
-	0x0118, 0x7000, 0x8000, 0x7002, 0xd5ac, 0x0178, 0x2500, 0x9084,
-	0x0007, 0x908e, 0x0003, 0x0148, 0x908e, 0x0004, 0x0130, 0x908e,
-	0x0005, 0x0118, 0x2071, 0xfffe, 0x0089, 0x001e, 0x00ee, 0x000e,
-	0x012e, 0x0005, 0x0126, 0x0006, 0x00e6, 0x2091, 0x8000, 0x2071,
-	0xfff6, 0x0021, 0x00ee, 0x000e, 0x012e, 0x0005, 0x2e05, 0x8000,
-	0x2077, 0x1220, 0x8e70, 0x2e05, 0x8000, 0x2077, 0x0005, 0x00e6,
-	0x2071, 0xfff4, 0x0c99, 0x00ee, 0x0005, 0x00e6, 0x2071, 0xfff8,
-	0x0c69, 0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6, 0x2091, 0x8000,
-	0x2071, 0x1840, 0x7014, 0x8000, 0x7016, 0x00ee, 0x000e, 0x012e,
-	0x0005, 0x0003, 0x000b, 0x079e, 0x0000, 0xc000, 0x0001, 0x8064,
-	0x0008, 0x0010, 0x0000, 0x8066, 0x0000, 0x0101, 0x0008, 0x4407,
-	0x0003, 0x8060, 0x0000, 0x0400, 0x0000, 0x580d, 0x000b, 0x79a8,
-	0x000b, 0x50ee, 0x000b, 0x4c0a, 0x0003, 0xbac0, 0x0009, 0x008a,
-	0x0000, 0x0c0a, 0x000b, 0x15fe, 0x0008, 0x340a, 0x0003, 0xc4c0,
-	0x0009, 0x7000, 0x0000, 0xffa0, 0x0001, 0x2000, 0x0000, 0x1668,
-	0x000b, 0x808c, 0x0008, 0x0001, 0x0000, 0x0000, 0x0007, 0x4028,
-	0x0000, 0x4047, 0x000a, 0x808c, 0x0008, 0x0002, 0x0000, 0x0822,
-	0x0003, 0x4022, 0x0000, 0x0028, 0x000b, 0x4122, 0x0008, 0x94c0,
-	0x0009, 0xff00, 0x0008, 0xffe0, 0x0009, 0x0500, 0x0008, 0x0a93,
-	0x000b, 0x4447, 0x0002, 0x0e90, 0x0003, 0x0bfe, 0x0008, 0x11a0,
-	0x0001, 0x126e, 0x0003, 0x0ca0, 0x0001, 0x126e, 0x0003, 0x9180,
-	0x0001, 0x0004, 0x0000, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62,
-	0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x4436, 0x000b, 0x808c,
-	0x0008, 0x0000, 0x0008, 0x0060, 0x0008, 0x8062, 0x0008, 0x0004,
-	0x0000, 0x8066, 0x0000, 0x0411, 0x0000, 0x443e, 0x0003, 0x03fe,
-	0x0000, 0x43e0, 0x0001, 0x0e6b, 0x000b, 0xc2c0, 0x0009, 0x00ff,
-	0x0008, 0x02e0, 0x0001, 0x0e6b, 0x000b, 0x9180, 0x0001, 0x0005,
-	0x0008, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62, 0x0008, 0x8066,
-	0x0000, 0x0019, 0x0000, 0x444d, 0x000b, 0x0240, 0x0002, 0x0a68,
-	0x0003, 0x00fe, 0x0000, 0x326b, 0x000b, 0x0248, 0x000a, 0x085c,
-	0x0003, 0x9180, 0x0001, 0x0006, 0x0008, 0x7f62, 0x0008, 0x8002,
-	0x0008, 0x0003, 0x0008, 0x8066, 0x0000, 0x020a, 0x0000, 0x445b,
-	0x0003, 0x112a, 0x0000, 0x002e, 0x0008, 0x022c, 0x0008, 0x3a44,
-	0x0002, 0x0c0a, 0x000b, 0x808c, 0x0008, 0x0002, 0x0000, 0x1760,
-	0x0008, 0x8062, 0x0008, 0x000f, 0x0008, 0x8066, 0x0000, 0x0011,
-	0x0008, 0x4468, 0x0003, 0x01fe, 0x0008, 0x42e0, 0x0009, 0x0e5c,
-	0x0003, 0x00fe, 0x0000, 0x43e0, 0x0001, 0x0e5c, 0x0003, 0x1734,
-	0x0000, 0x1530, 0x0000, 0x1632, 0x0008, 0x0d2a, 0x0008, 0x9880,
-	0x0001, 0x0010, 0x0000, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62,
-	0x0008, 0x8066, 0x0000, 0x1e0a, 0x0008, 0x447a, 0x0003, 0x808a,
-	0x0008, 0x0003, 0x0008, 0x1a60, 0x0000, 0x8062, 0x0008, 0x0002,
-	0x0000, 0x5880, 0x000b, 0x8066, 0x0000, 0x3679, 0x0000, 0x4483,
-	0x0003, 0x5884, 0x0003, 0x3efe, 0x0008, 0x7f4f, 0x0002, 0x088a,
-	0x000b, 0x0d00, 0x0000, 0x0092, 0x000c, 0x8054, 0x0008, 0x0011,
-	0x0008, 0x8074, 0x0000, 0x1010, 0x0008, 0x1efe, 0x0000, 0x300a,
-	0x000b, 0x00c8, 0x000c, 0x000a, 0x000b, 0x00fe, 0x0000, 0x349a,
-	0x0003, 0x1a60, 0x0000, 0x8062, 0x0008, 0x0007, 0x0000, 0x8066,
-	0x0000, 0x0231, 0x0008, 0x4499, 0x000b, 0x03fe, 0x0000, 0x04d0,
-	0x0001, 0x0cc0, 0x000b, 0x82c0, 0x0001, 0x1f00, 0x0000, 0xffa0,
-	0x0001, 0x0400, 0x0000, 0x08af, 0x0003, 0x14c0, 0x000b, 0x01fe,
-	0x0008, 0x0580, 0x0009, 0x7f06, 0x0000, 0x02fe, 0x0008, 0xffc0,
-	0x0001, 0x00ff, 0x0008, 0x0690, 0x0001, 0x10af, 0x0003, 0x7f08,
-	0x0008, 0x84c0, 0x0001, 0xff00, 0x0008, 0x08c0, 0x0003, 0x00fe,
-	0x0000, 0x34b6, 0x000b, 0x8072, 0x0000, 0x1010, 0x0008, 0x3944,
-	0x0002, 0x08b1, 0x0003, 0x00ba, 0x0003, 0x8072, 0x0000, 0x2020,
-	0x0008, 0x3945, 0x000a, 0x08b6, 0x000b, 0x3946, 0x000a, 0x0cc7,
-	0x0003, 0x0000, 0x0007, 0x3943, 0x000a, 0x08c7, 0x000b, 0x00ba,
-	0x0003, 0x00fe, 0x0000, 0x34c5, 0x0003, 0x8072, 0x0000, 0x1000,
-	0x0000, 0x00c7, 0x0003, 0x8072, 0x0000, 0x2000, 0x0000, 0x4000,
-	0x000f, 0x1c60, 0x0000, 0x1b62, 0x0000, 0x8066, 0x0000, 0x0231,
-	0x0008, 0x44cc, 0x000b, 0x58cd, 0x000b, 0x0140, 0x0008, 0x0242,
-	0x0000, 0x1f43, 0x0002, 0x0cdb, 0x000b, 0x0d44, 0x0000, 0x0d46,
-	0x0008, 0x0348, 0x0008, 0x044a, 0x0008, 0x030a, 0x0008, 0x040c,
-	0x0000, 0x0d06, 0x0000, 0x0d08, 0x0008, 0x00df, 0x0003, 0x0344,
-	0x0008, 0x0446, 0x0008, 0x0548, 0x0008, 0x064a, 0x0000, 0x1948,
-	0x000a, 0x08e2, 0x0003, 0x0d4a, 0x0008, 0x58e2, 0x0003, 0x3efe,
-	0x0008, 0x7f4f, 0x0002, 0x08e9, 0x000b, 0x8000, 0x0000, 0x0001,
-	0x0000, 0x0092, 0x000c, 0x8054, 0x0008, 0x0001, 0x0000, 0x8074,
-	0x0000, 0x2020, 0x0008, 0x4000, 0x000f, 0x3a40, 0x000a, 0x0c0d,
-	0x0003, 0x2b24, 0x0008, 0x2b24, 0x0008, 0x58f2, 0x000b, 0x8054,
-	0x0008, 0x0002, 0x0000, 0x1242, 0x0002, 0x0940, 0x0003, 0x3a45,
-	0x000a, 0x092f, 0x0003, 0x8072, 0x0000, 0x1000, 0x0000, 0x3945,
-	0x000a, 0x08ff, 0x0003, 0x8072, 0x0000, 0x3010, 0x0000, 0x1e10,
-	0x000a, 0x7f3c, 0x0000, 0x092a, 0x0003, 0x1d00, 0x0002, 0x7f3a,
-	0x0000, 0x0d60, 0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0009,
-	0x0008, 0x4508, 0x000b, 0x00fe, 0x0000, 0x3527, 0x000b, 0x1c60,
+	0x6552, 0x2001, 0x0002, 0x080c, 0x6566, 0x6023, 0x0001, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x080c, 0x9140, 0x080c, 0x96a6, 0x00f0,
+	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x284b, 0x11b0,
+	0x080c, 0x6616, 0x0118, 0x080c, 0xae5f, 0x0080, 0xb810, 0x0006,
+	0xb814, 0x0006, 0xb8c0, 0x0006, 0x080c, 0x6047, 0x000e, 0xb8c2,
+	0x000e, 0xb816, 0x000e, 0xb812, 0x080c, 0xae5f, 0x00fe, 0x0005,
+	0x6604, 0x96b6, 0x001e, 0x1110, 0x080c, 0xae5f, 0x0005, 0x080c,
+	0xbc95, 0x1148, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x9140,
+	0x080c, 0x96a6, 0x0010, 0x080c, 0xae5f, 0x0005, 0x0804, 0xae5f,
+	0x6004, 0x908a, 0x0053, 0x1a0c, 0x0dd5, 0x080c, 0x959a, 0x080c,
+	0xae90, 0x080c, 0x96a6, 0x0005, 0x9182, 0x0040, 0x0002, 0xdbab,
+	0xdbab, 0xdbab, 0xdbab, 0xdbad, 0xdbab, 0xdbab, 0xdbab, 0xdbab,
+	0xdbab, 0xdbab, 0xdbab, 0xdbab, 0xdbab, 0xdbab, 0xdbab, 0xdbab,
+	0xdbab, 0xdbab, 0xdbab, 0x080c, 0x0dd5, 0x0096, 0x00b6, 0x00d6,
+	0x00e6, 0x00f6, 0x0046, 0x0026, 0x6210, 0x2258, 0xb8bc, 0x9005,
+	0x11a8, 0x6106, 0x2071, 0x0260, 0x7444, 0x94a4, 0xff00, 0x0904,
+	0xdc13, 0x080c, 0xe9a6, 0x1170, 0x9486, 0x2000, 0x1158, 0x2009,
+	0x0001, 0x2011, 0x0200, 0x080c, 0x86e3, 0x0020, 0x9026, 0x080c,
+	0xe82a, 0x0c38, 0x080c, 0x0fff, 0x090c, 0x0dd5, 0x6003, 0x0007,
+	0xa867, 0x010d, 0x9006, 0xa802, 0xa86a, 0xac8a, 0x2c00, 0xa88e,
+	0x6008, 0xa8e2, 0x6010, 0x2058, 0xb8a0, 0x7130, 0xa97a, 0x0016,
+	0xa876, 0xa87f, 0x0000, 0xa883, 0x0000, 0xa887, 0x0036, 0x080c,
+	0x6c94, 0x001e, 0x080c, 0xe9a6, 0x1904, 0xdc73, 0x9486, 0x2000,
+	0x1130, 0x2019, 0x0017, 0x080c, 0xe55d, 0x0804, 0xdc73, 0x9486,
+	0x0200, 0x1120, 0x080c, 0xe4f9, 0x0804, 0xdc73, 0x9486, 0x0400,
+	0x0120, 0x9486, 0x1000, 0x1904, 0xdc73, 0x2019, 0x0002, 0x080c,
+	0xe514, 0x0804, 0xdc73, 0x2069, 0x1a70, 0x6a00, 0xd284, 0x0904,
+	0xdcdd, 0x9284, 0x0300, 0x1904, 0xdcd6, 0x6804, 0x9005, 0x0904,
+	0xdcbe, 0x2d78, 0x6003, 0x0007, 0x080c, 0x1018, 0x0904, 0xdc7f,
+	0x7800, 0xd08c, 0x1118, 0x7804, 0x8001, 0x7806, 0x6017, 0x0000,
+	0x2001, 0x180f, 0x2004, 0xd084, 0x1904, 0xdce1, 0x9006, 0xa802,
+	0xa867, 0x0116, 0xa86a, 0x6008, 0xa8e2, 0x2c00, 0xa87a, 0x6010,
+	0x2058, 0xb8a0, 0x7130, 0xa9b6, 0xa876, 0xb928, 0xa9ba, 0xb92c,
+	0xa9be, 0xb930, 0xa9c2, 0xb934, 0xa9c6, 0xa883, 0x003d, 0x7044,
+	0x9084, 0x0003, 0x9080, 0xdc7b, 0x2005, 0xa87e, 0x20a9, 0x000a,
+	0x2001, 0x0270, 0xaa5c, 0x9290, 0x0021, 0x2009, 0x0205, 0x200b,
+	0x0080, 0x20e1, 0x0000, 0xab60, 0x23e8, 0x2098, 0x22a0, 0x4003,
+	0x200b, 0x0000, 0x2001, 0x027a, 0x200c, 0xa9b2, 0x8000, 0x200c,
+	0xa9ae, 0x080c, 0x6c94, 0x002e, 0x004e, 0x00fe, 0x00ee, 0x00de,
+	0x00be, 0x009e, 0x0005, 0x0000, 0x0080, 0x0040, 0x0000, 0x2001,
+	0x1810, 0x2004, 0xd084, 0x0120, 0x080c, 0x0fff, 0x1904, 0xdc28,
+	0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c, 0x90f8,
+	0x080c, 0x96a6, 0x0c00, 0x2069, 0x0260, 0x6848, 0x9084, 0xff00,
+	0x9086, 0x1200, 0x1198, 0x686c, 0x9084, 0x00ff, 0x0016, 0x6114,
+	0x918c, 0xf700, 0x910d, 0x6116, 0x001e, 0x6003, 0x0001, 0x6007,
+	0x0043, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x0828, 0x6868, 0x602e,
+	0x686c, 0x6032, 0x6017, 0xf200, 0x6003, 0x0001, 0x6007, 0x0041,
+	0x080c, 0x90f8, 0x080c, 0x96a6, 0x0804, 0xdc73, 0x2001, 0x180e,
+	0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x4b1e, 0x6017,
+	0xf300, 0x0010, 0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041,
+	0x080c, 0x90f8, 0x080c, 0x96a6, 0x0804, 0xdc73, 0x6017, 0xf500,
+	0x0c98, 0x6017, 0xf600, 0x0804, 0xdc93, 0x6017, 0xf200, 0x0804,
+	0xdc93, 0xa867, 0x0146, 0xa86b, 0x0000, 0x6008, 0xa886, 0x2c00,
+	0xa87a, 0x7044, 0x9084, 0x0003, 0x9080, 0xdc7b, 0x2005, 0xa87e,
+	0x2928, 0x6010, 0x2058, 0xb8a0, 0xa876, 0xb828, 0xa88a, 0xb82c,
+	0xa88e, 0xb830, 0xa892, 0xb834, 0xa896, 0xa883, 0x003d, 0x2009,
+	0x0205, 0x2104, 0x9085, 0x0080, 0x200a, 0x20e1, 0x0000, 0x2011,
+	0x0210, 0x2214, 0x9294, 0x0fff, 0xaaa2, 0x9282, 0x0111, 0x1a0c,
+	0x0dd5, 0x8210, 0x821c, 0x2001, 0x026c, 0x2098, 0xa860, 0x20e8,
+	0xa85c, 0x9080, 0x0029, 0x20a0, 0x2011, 0xdd5d, 0x2041, 0x0001,
+	0x223d, 0x9784, 0x00ff, 0x9322, 0x1208, 0x2300, 0x20a8, 0x4003,
+	0x931a, 0x0530, 0x8210, 0xd7fc, 0x1130, 0x8d68, 0x2d0a, 0x2001,
+	0x0260, 0x2098, 0x0c68, 0x2950, 0x080c, 0x1018, 0x0170, 0x2900,
+	0xb002, 0xa867, 0x0147, 0xa86b, 0x0000, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x001b, 0x20a0, 0x8840, 0x08d8, 0x2548, 0xa800, 0x902d,
+	0x0118, 0x080c, 0x1031, 0x0cc8, 0x080c, 0x1031, 0x0804, 0xdc7f,
+	0x2548, 0x8847, 0x9885, 0x0046, 0xa866, 0x2009, 0x0205, 0x200b,
+	0x0000, 0x080c, 0xe58c, 0x0804, 0xdc73, 0x8010, 0x0004, 0x801a,
+	0x0006, 0x8018, 0x0008, 0x8016, 0x000a, 0x8014, 0x9186, 0x0013,
+	0x1160, 0x6004, 0x908a, 0x0054, 0x1a0c, 0x0dd5, 0x9082, 0x0040,
+	0x0a0c, 0x0dd5, 0x2008, 0x0804, 0xde0f, 0x9186, 0x0051, 0x0108,
+	0x00c0, 0x2001, 0x0109, 0x2004, 0xd084, 0x0904, 0xddbf, 0x0126,
+	0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x8fdd, 0x002e,
+	0x001e, 0x000e, 0x012e, 0x6000, 0x9086, 0x0002, 0x1580, 0x0804,
+	0xde58, 0x9186, 0x0027, 0x0530, 0x9186, 0x0048, 0x0128, 0x9186,
+	0x0014, 0x0500, 0x190c, 0x0dd5, 0x2001, 0x0109, 0x2004, 0xd084,
+	0x01f0, 0x00c6, 0x0126, 0x2091, 0x2800, 0x00c6, 0x2061, 0x0100,
+	0x0006, 0x0016, 0x0026, 0x080c, 0x8fdd, 0x002e, 0x001e, 0x000e,
+	0x00ce, 0x012e, 0x00ce, 0x6000, 0x9086, 0x0004, 0x190c, 0x0dd5,
+	0x0804, 0xdf3b, 0x6004, 0x9082, 0x0040, 0x2008, 0x001a, 0x080c,
+	0xaef5, 0x0005, 0xddd6, 0xddd8, 0xddd8, 0xddff, 0xddd6, 0xddd6,
+	0xddd6, 0xddd6, 0xddd6, 0xddd6, 0xddd6, 0xddd6, 0xddd6, 0xddd6,
+	0xddd6, 0xddd6, 0xddd6, 0xddd6, 0xddd6, 0xddd6, 0x080c, 0x0dd5,
+	0x080c, 0x959a, 0x080c, 0x96a6, 0x0036, 0x0096, 0x6014, 0x904d,
+	0x01d8, 0x080c, 0xcb5a, 0x01c0, 0x6003, 0x0002, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x1178, 0x2019, 0x0004, 0x080c,
+	0xe58c, 0x6017, 0x0000, 0x6018, 0x9005, 0x1120, 0x2001, 0x1986,
+	0x2004, 0x601a, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x0096,
+	0x080c, 0x959a, 0x080c, 0x96a6, 0x080c, 0xcb5a, 0x0120, 0x6014,
+	0x2048, 0x080c, 0x1031, 0x080c, 0xae90, 0x009e, 0x0005, 0x0002,
+	0xde24, 0xde3b, 0xde26, 0xde52, 0xde24, 0xde24, 0xde24, 0xde24,
+	0xde24, 0xde24, 0xde24, 0xde24, 0xde24, 0xde24, 0xde24, 0xde24,
+	0xde24, 0xde24, 0xde24, 0xde24, 0x080c, 0x0dd5, 0x0096, 0x080c,
+	0x959a, 0x6014, 0x2048, 0xa87c, 0xd0b4, 0x0138, 0x6003, 0x0007,
+	0x2009, 0x0043, 0x080c, 0xaeda, 0x0010, 0x6003, 0x0004, 0x080c,
+	0x96a6, 0x009e, 0x0005, 0x080c, 0x959a, 0x080c, 0xcb5a, 0x0138,
+	0x6114, 0x0096, 0x2148, 0xa97c, 0x009e, 0xd1ec, 0x1138, 0x080c,
+	0x86b8, 0x080c, 0xae5f, 0x080c, 0x96a6, 0x0005, 0x080c, 0xe7ee,
+	0x0db0, 0x0cc8, 0x080c, 0x959a, 0x2009, 0x0041, 0x0804, 0xdfc3,
+	0x9182, 0x0040, 0x0002, 0xde6f, 0xde71, 0xde6f, 0xde6f, 0xde6f,
+	0xde6f, 0xde6f, 0xde6f, 0xde6f, 0xde6f, 0xde6f, 0xde6f, 0xde6f,
+	0xde6f, 0xde6f, 0xde6f, 0xde6f, 0xde72, 0xde6f, 0xde6f, 0x080c,
+	0x0dd5, 0x0005, 0x00d6, 0x080c, 0x86b8, 0x00de, 0x080c, 0xe846,
+	0x080c, 0xae5f, 0x0005, 0x9182, 0x0040, 0x0002, 0xde92, 0xde92,
+	0xde92, 0xde92, 0xde92, 0xde92, 0xde92, 0xde92, 0xde92, 0xde94,
+	0xdf03, 0xde92, 0xde92, 0xde92, 0xde92, 0xdf03, 0xde92, 0xde92,
+	0xde92, 0xde92, 0x080c, 0x0dd5, 0x2001, 0x0105, 0x2004, 0x9084,
+	0x1800, 0x01c8, 0x2001, 0x0132, 0x200c, 0x2001, 0x0131, 0x2004,
+	0x9105, 0x1904, 0xdf03, 0x2009, 0x180c, 0x2104, 0xd0d4, 0x0904,
+	0xdf03, 0xc0d4, 0x200a, 0x2009, 0x0105, 0x2104, 0x9084, 0xe7fd,
+	0x9085, 0x0010, 0x200a, 0x2001, 0x1867, 0x2004, 0xd0e4, 0x1528,
+	0x603b, 0x0000, 0x080c, 0x9656, 0x6014, 0x0096, 0x2048, 0xa87c,
+	0xd0fc, 0x0188, 0x908c, 0x0003, 0x918e, 0x0002, 0x0508, 0x2001,
+	0x180c, 0x2004, 0xd0d4, 0x11e0, 0x080c, 0x97d4, 0x2009, 0x0041,
+	0x009e, 0x0804, 0xdfc3, 0x080c, 0x97d4, 0x6003, 0x0007, 0x601b,
+	0x0000, 0x080c, 0x86b8, 0x009e, 0x0005, 0x2001, 0x0100, 0x2004,
+	0x9082, 0x0005, 0x0aa8, 0x2001, 0x011f, 0x2004, 0x603a, 0x0890,
+	0x2001, 0x180c, 0x200c, 0xc1d4, 0x2102, 0xd1cc, 0x0110, 0x080c,
+	0x2c5f, 0x080c, 0x97d4, 0x6014, 0x2048, 0xa97c, 0xd1ec, 0x1130,
+	0x080c, 0x86b8, 0x080c, 0xae5f, 0x009e, 0x0005, 0x080c, 0xe7ee,
+	0x0db8, 0x009e, 0x0005, 0x2001, 0x180c, 0x200c, 0xc1d4, 0x2102,
+	0x0036, 0x080c, 0x9656, 0x080c, 0x97d4, 0x6014, 0x0096, 0x2048,
+	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0188, 0xa87c,
+	0x9084, 0x0003, 0x9086, 0x0002, 0x0140, 0xa8ac, 0x6330, 0x931a,
+	0x6332, 0xa8b0, 0x632c, 0x931b, 0x632e, 0x6003, 0x0002, 0x0080,
+	0x2019, 0x0004, 0x080c, 0xe58c, 0x6018, 0x9005, 0x1128, 0x2001,
+	0x1986, 0x2004, 0x8003, 0x601a, 0x6017, 0x0000, 0x6003, 0x0007,
+	0x009e, 0x003e, 0x0005, 0x9182, 0x0040, 0x0002, 0xdf52, 0xdf52,
+	0xdf52, 0xdf52, 0xdf52, 0xdf52, 0xdf52, 0xdf52, 0xdf54, 0xdf52,
+	0xdf52, 0xdf52, 0xdf52, 0xdf52, 0xdf52, 0xdf52, 0xdf52, 0xdf52,
+	0xdf52, 0xdf9f, 0x080c, 0x0dd5, 0x6014, 0x0096, 0x2048, 0xa834,
+	0xaa38, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1bc, 0x1190,
+	0x920d, 0x1518, 0xa87c, 0xd0fc, 0x0128, 0x2009, 0x0041, 0x009e,
+	0x0804, 0xdfc3, 0x6003, 0x0007, 0x601b, 0x0000, 0x080c, 0x86b8,
+	0x009e, 0x0005, 0x6124, 0xd1f4, 0x1d58, 0x0006, 0x0046, 0xacac,
+	0x9422, 0xa9b0, 0x2200, 0x910b, 0x6030, 0x9420, 0x6432, 0x602c,
+	0x9109, 0x612e, 0x004e, 0x000e, 0x08d8, 0x6110, 0x00b6, 0x2158,
+	0xb900, 0x00be, 0xd1bc, 0x1178, 0x2009, 0x180e, 0x210c, 0xd19c,
+	0x0118, 0x6003, 0x0007, 0x0010, 0x6003, 0x0006, 0x00e9, 0x080c,
+	0x86ba, 0x009e, 0x0005, 0x6003, 0x0002, 0x009e, 0x0005, 0x6024,
+	0xd0f4, 0x0128, 0x080c, 0x15e7, 0x1904, 0xdf54, 0x0005, 0x6014,
+	0x0096, 0x2048, 0xa834, 0xa938, 0x009e, 0x9105, 0x1120, 0x080c,
+	0x15e7, 0x1904, 0xdf54, 0x0005, 0xd2fc, 0x0140, 0x8002, 0x8000,
+	0x8212, 0x9291, 0x0000, 0x2009, 0x0009, 0x0010, 0x2009, 0x0015,
+	0xaa9a, 0xa896, 0x0005, 0x9182, 0x0040, 0x0208, 0x0062, 0x9186,
+	0x0013, 0x0120, 0x9186, 0x0014, 0x190c, 0x0dd5, 0x6024, 0xd0dc,
+	0x090c, 0x0dd5, 0x0005, 0xdfe7, 0xdff3, 0xdfff, 0xe00b, 0xdfe7,
+	0xdfe7, 0xdfe7, 0xdfe7, 0xdfee, 0xdfe9, 0xdfe9, 0xdfe7, 0xdfe7,
+	0xdfe7, 0xdfe7, 0xdfe9, 0xdfe7, 0xdfe9, 0xdfe7, 0xdfee, 0x080c,
+	0x0dd5, 0x6024, 0xd0dc, 0x090c, 0x0dd5, 0x0005, 0x6014, 0x9005,
+	0x190c, 0x0dd5, 0x0005, 0x6003, 0x0001, 0x6106, 0x080c, 0x90f8,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x96a6, 0x012e, 0x0005, 0x6003,
+	0x0001, 0x6106, 0x080c, 0x90f8, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x96a6, 0x012e, 0x0005, 0x6003, 0x0003, 0x6106, 0x2c10, 0x080c,
+	0x1bba, 0x0126, 0x2091, 0x8000, 0x080c, 0x915d, 0x080c, 0x97d4,
+	0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0036, 0x0096, 0x9182,
+	0x0040, 0x0023, 0x009e, 0x003e, 0x012e, 0x0005, 0xe03a, 0xe03c,
+	0xe04e, 0xe068, 0xe03a, 0xe03a, 0xe03a, 0xe03a, 0xe03a, 0xe03a,
+	0xe03a, 0xe03a, 0xe03a, 0xe03a, 0xe03a, 0xe03a, 0xe03a, 0xe03a,
+	0xe03a, 0xe03a, 0x080c, 0x0dd5, 0x6014, 0x2048, 0xa87c, 0xd0fc,
+	0x01f8, 0x909c, 0x0003, 0x939e, 0x0003, 0x01d0, 0x6003, 0x0001,
+	0x6106, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x0470, 0x6014, 0x2048,
+	0xa87c, 0xd0fc, 0x0168, 0x909c, 0x0003, 0x939e, 0x0003, 0x0140,
+	0x6003, 0x0001, 0x6106, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x00e0,
+	0x901e, 0x6316, 0x631a, 0x2019, 0x0004, 0x080c, 0xe58c, 0x00a0,
+	0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0d98, 0x909c, 0x0003, 0x939e,
+	0x0003, 0x0d70, 0x6003, 0x0003, 0x6106, 0x2c10, 0x080c, 0x1bba,
+	0x080c, 0x915d, 0x080c, 0x97d4, 0x0005, 0x080c, 0x959a, 0x6114,
+	0x81ff, 0x0158, 0x0096, 0x2148, 0x080c, 0xe943, 0x0036, 0x2019,
+	0x0029, 0x080c, 0xe58c, 0x003e, 0x009e, 0x080c, 0xae90, 0x080c,
+	0x96a6, 0x0005, 0x080c, 0x9656, 0x6114, 0x81ff, 0x0158, 0x0096,
+	0x2148, 0x080c, 0xe943, 0x0036, 0x2019, 0x0029, 0x080c, 0xe58c,
+	0x003e, 0x009e, 0x080c, 0xae90, 0x080c, 0x97d4, 0x0005, 0x9182,
+	0x0085, 0x0002, 0xe0b9, 0xe0b7, 0xe0b7, 0xe0c5, 0xe0b7, 0xe0b7,
+	0xe0b7, 0xe0b7, 0xe0b7, 0xe0b7, 0xe0b7, 0xe0b7, 0xe0b7, 0x080c,
+	0x0dd5, 0x6003, 0x000b, 0x6106, 0x080c, 0x90f8, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x96a6, 0x012e, 0x0005, 0x0026, 0x00e6, 0x080c,
+	0xe7e5, 0x0118, 0x080c, 0xae5f, 0x0450, 0x2071, 0x0260, 0x7224,
+	0x6216, 0x2001, 0x180e, 0x2004, 0xd0e4, 0x0150, 0x6010, 0x00b6,
+	0x2058, 0xbca0, 0x00be, 0x2c00, 0x2011, 0x014e, 0x080c, 0xb180,
+	0x7220, 0x080c, 0xe432, 0x0118, 0x6007, 0x0086, 0x0040, 0x6007,
+	0x0087, 0x7224, 0x9296, 0xffff, 0x1110, 0x6007, 0x0086, 0x6003,
+	0x0001, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x080c, 0x97d4, 0x00ee,
+	0x002e, 0x0005, 0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085,
+	0x0a0c, 0x0dd5, 0x908a, 0x0092, 0x1a0c, 0x0dd5, 0x9082, 0x0085,
+	0x00a2, 0x9186, 0x0027, 0x0130, 0x9186, 0x0014, 0x0118, 0x080c,
+	0xaef5, 0x0050, 0x2001, 0x0007, 0x080c, 0x6592, 0x080c, 0x959a,
+	0x080c, 0xae90, 0x080c, 0x96a6, 0x0005, 0xe12a, 0xe12c, 0xe12c,
+	0xe12a, 0xe12a, 0xe12a, 0xe12a, 0xe12a, 0xe12a, 0xe12a, 0xe12a,
+	0xe12a, 0xe12a, 0x080c, 0x0dd5, 0x080c, 0x959a, 0x080c, 0xae90,
+	0x080c, 0x96a6, 0x0005, 0x9182, 0x0085, 0x0a0c, 0x0dd5, 0x9182,
+	0x0092, 0x1a0c, 0x0dd5, 0x9182, 0x0085, 0x0002, 0xe14b, 0xe14b,
+	0xe14b, 0xe14d, 0xe14b, 0xe14b, 0xe14b, 0xe14b, 0xe14b, 0xe14b,
+	0xe14b, 0xe14b, 0xe14b, 0x080c, 0x0dd5, 0x0005, 0x9186, 0x0013,
+	0x0148, 0x9186, 0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c,
+	0xaef5, 0x0030, 0x080c, 0x959a, 0x080c, 0xae90, 0x080c, 0x96a6,
+	0x0005, 0x0036, 0x080c, 0xe846, 0x6043, 0x0000, 0x2019, 0x000b,
+	0x0031, 0x6023, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x0126,
+	0x0036, 0x2091, 0x8000, 0x0086, 0x2c40, 0x0096, 0x904e, 0x080c,
+	0xa687, 0x009e, 0x008e, 0x1550, 0x0076, 0x2c38, 0x080c, 0xa732,
+	0x007e, 0x1520, 0x6000, 0x9086, 0x0000, 0x0500, 0x6020, 0x9086,
+	0x0007, 0x01e0, 0x0096, 0x601c, 0xd084, 0x0140, 0x080c, 0xe846,
+	0x080c, 0xd272, 0x080c, 0x1a70, 0x6023, 0x0007, 0x6014, 0x2048,
+	0x080c, 0xcb5a, 0x0110, 0x080c, 0xe58c, 0x009e, 0x6017, 0x0000,
+	0x080c, 0xe846, 0x6023, 0x0007, 0x080c, 0xd272, 0x003e, 0x012e,
+	0x0005, 0x00f6, 0x00c6, 0x00b6, 0x0036, 0x0156, 0x2079, 0x0260,
+	0x7938, 0x783c, 0x080c, 0x284b, 0x15c8, 0x0016, 0x00c6, 0x080c,
+	0x6616, 0x1590, 0x001e, 0x00c6, 0x2160, 0x080c, 0xd26f, 0x00ce,
+	0x002e, 0x0026, 0x0016, 0x2019, 0x0029, 0x080c, 0xa7f8, 0x080c,
+	0x929d, 0x0076, 0x903e, 0x080c, 0x9170, 0x007e, 0x001e, 0x0076,
+	0x903e, 0x080c, 0xe326, 0x007e, 0x0026, 0xba04, 0x9294, 0xff00,
+	0x8217, 0x9286, 0x0006, 0x0118, 0x9286, 0x0004, 0x1118, 0xbaa0,
+	0x080c, 0x328a, 0x002e, 0xbcc0, 0x001e, 0x080c, 0x6047, 0xbe12,
+	0xbd16, 0xbcc2, 0x9006, 0x0010, 0x00ce, 0x001e, 0x015e, 0x003e,
+	0x00be, 0x00ce, 0x00fe, 0x0005, 0x00c6, 0x00d6, 0x00b6, 0x0016,
+	0x2009, 0x1824, 0x2104, 0x9086, 0x0074, 0x1904, 0xe24d, 0x2069,
+	0x0260, 0x6944, 0x9182, 0x0100, 0x06e0, 0x6940, 0x9184, 0x8000,
+	0x0904, 0xe24a, 0x2001, 0x197b, 0x2004, 0x9005, 0x1140, 0x6010,
+	0x2058, 0xb8c0, 0x9005, 0x0118, 0x9184, 0x0800, 0x0598, 0x6948,
+	0x918a, 0x0001, 0x0648, 0x080c, 0xe9ab, 0x0118, 0x6978, 0xd1fc,
+	0x11b8, 0x2009, 0x0205, 0x200b, 0x0001, 0x693c, 0x81ff, 0x1198,
+	0x6944, 0x9182, 0x0100, 0x02a8, 0x6940, 0x81ff, 0x1178, 0x6948,
+	0x918a, 0x0001, 0x0288, 0x6950, 0x918a, 0x0001, 0x0298, 0x00d0,
+	0x6017, 0x0100, 0x00a0, 0x6017, 0x0300, 0x0088, 0x6017, 0x0500,
+	0x0070, 0x6017, 0x0700, 0x0058, 0x6017, 0x0900, 0x0040, 0x6017,
+	0x0b00, 0x0028, 0x6017, 0x0f00, 0x0010, 0x6017, 0x2d00, 0x9085,
+	0x0001, 0x0008, 0x9006, 0x001e, 0x00be, 0x00de, 0x00ce, 0x0005,
+	0x00c6, 0x00b6, 0x0026, 0x0036, 0x0156, 0x6210, 0x2258, 0xbb04,
+	0x9394, 0x00ff, 0x9286, 0x0006, 0x0180, 0x9286, 0x0004, 0x0168,
+	0x9394, 0xff00, 0x8217, 0x9286, 0x0006, 0x0138, 0x9286, 0x0004,
+	0x0120, 0x080c, 0x6625, 0x0804, 0xe2b5, 0x2011, 0x0276, 0x20a9,
+	0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xbe2d, 0x009e,
+	0x15a8, 0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019,
+	0x0006, 0x080c, 0xbe2d, 0x009e, 0x1548, 0x0046, 0x0016, 0xbaa0,
+	0x2220, 0x9006, 0x2009, 0x1848, 0x210c, 0xd1a4, 0x0138, 0x2009,
+	0x0029, 0x080c, 0xe5e9, 0xb800, 0xc0e5, 0xb802, 0x2019, 0x0029,
+	0x080c, 0x929d, 0x0076, 0x2039, 0x0000, 0x080c, 0x9170, 0x2c08,
+	0x080c, 0xe326, 0x007e, 0x2001, 0x0007, 0x080c, 0x6592, 0x2001,
+	0x0007, 0x080c, 0x6566, 0x001e, 0x004e, 0x9006, 0x015e, 0x003e,
+	0x002e, 0x00be, 0x00ce, 0x0005, 0x00d6, 0x2069, 0x026e, 0x6800,
+	0x9086, 0x0800, 0x0118, 0x6017, 0x0000, 0x0008, 0x9006, 0x00de,
+	0x0005, 0x00b6, 0x00f6, 0x0016, 0x0026, 0x0036, 0x0156, 0x2079,
+	0x026c, 0x7930, 0x7834, 0x080c, 0x284b, 0x11d0, 0x080c, 0x6616,
+	0x11b8, 0x2011, 0x0270, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019,
+	0x000a, 0x080c, 0xbe2d, 0x009e, 0x1158, 0x2011, 0x0274, 0x20a9,
+	0x0004, 0x0096, 0x2b48, 0x2019, 0x0006, 0x080c, 0xbe2d, 0x009e,
+	0x015e, 0x003e, 0x002e, 0x001e, 0x00fe, 0x00be, 0x0005, 0x00b6,
+	0x0006, 0x0016, 0x0026, 0x0036, 0x0156, 0x2011, 0x0263, 0x2204,
+	0x8211, 0x220c, 0x080c, 0x284b, 0x11d0, 0x080c, 0x6616, 0x11b8,
+	0x2011, 0x0276, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a,
+	0x080c, 0xbe2d, 0x009e, 0x1158, 0x2011, 0x027a, 0x20a9, 0x0004,
+	0x0096, 0x2b48, 0x2019, 0x0006, 0x080c, 0xbe2d, 0x009e, 0x015e,
+	0x003e, 0x002e, 0x001e, 0x000e, 0x00be, 0x0005, 0x00e6, 0x00c6,
+	0x0086, 0x0076, 0x0066, 0x0056, 0x0046, 0x0026, 0x0126, 0x2091,
+	0x8000, 0x2740, 0x2029, 0x19ef, 0x252c, 0x2021, 0x19f5, 0x2424,
+	0x2061, 0x1cd0, 0x2071, 0x1800, 0x7654, 0x7074, 0x81ff, 0x0150,
+	0x0006, 0x9186, 0x1aaf, 0x000e, 0x0128, 0x8001, 0x9602, 0x1a04,
+	0xe3c3, 0x0018, 0x9606, 0x0904, 0xe3c3, 0x080c, 0x8987, 0x0904,
+	0xe3ba, 0x2100, 0x9c06, 0x0904, 0xe3ba, 0x080c, 0xe62a, 0x1904,
+	0xe3ba, 0x080c, 0xe9c8, 0x0904, 0xe3ba, 0x080c, 0xe61a, 0x0904,
+	0xe3ba, 0x6720, 0x9786, 0x0001, 0x1148, 0x080c, 0x3321, 0x0904,
+	0xe402, 0x6004, 0x9086, 0x0000, 0x1904, 0xe402, 0x9786, 0x0004,
+	0x0904, 0xe402, 0x9786, 0x0007, 0x0904, 0xe3ba, 0x2500, 0x9c06,
+	0x0904, 0xe3ba, 0x2400, 0x9c06, 0x05e8, 0x88ff, 0x0118, 0x6054,
+	0x9906, 0x15c0, 0x0096, 0x6000, 0x9086, 0x0004, 0x1120, 0x0016,
+	0x080c, 0x1a70, 0x001e, 0x9786, 0x000a, 0x0148, 0x080c, 0xcd60,
+	0x1130, 0x080c, 0xb821, 0x009e, 0x080c, 0xae90, 0x0418, 0x6014,
+	0x2048, 0x080c, 0xcb5a, 0x01d8, 0x9786, 0x0003, 0x1570, 0xa867,
+	0x0103, 0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c,
+	0x0fb1, 0x009e, 0xab7a, 0xa877, 0x0000, 0x080c, 0xe943, 0x0016,
+	0x080c, 0xce4e, 0x080c, 0x6c88, 0x001e, 0x080c, 0xcd43, 0x009e,
+	0x080c, 0xae90, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004, 0x9c02,
+	0x1210, 0x0804, 0xe33a, 0x012e, 0x002e, 0x004e, 0x005e, 0x006e,
+	0x007e, 0x008e, 0x00ce, 0x00ee, 0x0005, 0x9786, 0x0006, 0x1150,
+	0x9386, 0x0005, 0x0128, 0x080c, 0xe943, 0x080c, 0xe58c, 0x08f8,
+	0x009e, 0x0c00, 0x9786, 0x0009, 0x11f8, 0x6000, 0x9086, 0x0004,
+	0x01c0, 0x6000, 0x9086, 0x0003, 0x11a0, 0x080c, 0x9656, 0x0096,
+	0x6114, 0x2148, 0x080c, 0xcb5a, 0x0118, 0x6010, 0x080c, 0x6c94,
+	0x009e, 0x00c6, 0x080c, 0xae5f, 0x00ce, 0x0036, 0x080c, 0x97d4,
+	0x003e, 0x009e, 0x0804, 0xe3ba, 0x9786, 0x000a, 0x0904, 0xe3a1,
+	0x0804, 0xe39f, 0x81ff, 0x0904, 0xe3ba, 0x9180, 0x0001, 0x2004,
+	0x9086, 0x0018, 0x0138, 0x9180, 0x0001, 0x2004, 0x9086, 0x002d,
+	0x1904, 0xe3ba, 0x6000, 0x9086, 0x0002, 0x1904, 0xe3ba, 0x080c,
+	0xcd4f, 0x0138, 0x080c, 0xcd60, 0x1904, 0xe3ba, 0x080c, 0xb821,
+	0x0038, 0x080c, 0x31f5, 0x080c, 0xcd60, 0x1110, 0x080c, 0xb821,
+	0x080c, 0xae90, 0x0804, 0xe3ba, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x0039, 0x0005, 0x00c6, 0x00e6, 0x0016, 0x2c08, 0x2170, 0x9006,
+	0x080c, 0xe5b3, 0x001e, 0x0120, 0x6020, 0x9084, 0x000f, 0x001b,
+	0x00ee, 0x00ce, 0x0005, 0xe451, 0xe451, 0xe451, 0xe451, 0xe451,
+	0xe451, 0xe453, 0xe451, 0xe451, 0xe451, 0xe451, 0xae90, 0xae90,
+	0xe451, 0x9006, 0x0005, 0x0036, 0x0046, 0x0016, 0x7010, 0x00b6,
+	0x2058, 0xbca0, 0x00be, 0x2c00, 0x2009, 0x0020, 0x080c, 0xe5e9,
+	0x001e, 0x004e, 0x2019, 0x0002, 0x080c, 0xe16f, 0x003e, 0x9085,
+	0x0001, 0x0005, 0x0096, 0x080c, 0xcb5a, 0x0140, 0x6014, 0x904d,
+	0x080c, 0xc77b, 0x687b, 0x0005, 0x080c, 0x6c94, 0x009e, 0x080c,
+	0xae90, 0x9085, 0x0001, 0x0005, 0x2001, 0x0001, 0x080c, 0x6552,
+	0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805,
+	0x2011, 0x0276, 0x080c, 0xbe19, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x9005, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066,
+	0x00b6, 0x0126, 0x2091, 0x8000, 0x2740, 0x2061, 0x1cd0, 0x2079,
+	0x0001, 0x8fff, 0x0904, 0xe4ec, 0x2071, 0x1800, 0x7654, 0x7074,
+	0x8001, 0x9602, 0x1a04, 0xe4ec, 0x88ff, 0x0120, 0x2800, 0x9c06,
+	0x1590, 0x2078, 0x080c, 0xe61a, 0x0570, 0x2400, 0x9c06, 0x0558,
+	0x6720, 0x9786, 0x0006, 0x1538, 0x9786, 0x0007, 0x0520, 0x88ff,
+	0x1140, 0x6010, 0x9b06, 0x11f8, 0x85ff, 0x0118, 0x6054, 0x9106,
+	0x11d0, 0x0096, 0x601c, 0xd084, 0x0140, 0x080c, 0xe846, 0x080c,
+	0xd272, 0x080c, 0x1a70, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c,
+	0xcb5a, 0x0120, 0x0046, 0x080c, 0xe58c, 0x004e, 0x009e, 0x080c,
+	0xae90, 0x88ff, 0x1198, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004,
+	0x9c02, 0x1210, 0x0804, 0xe4a1, 0x9006, 0x012e, 0x00be, 0x006e,
+	0x007e, 0x008e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x98c5, 0x0001,
+	0x0ca0, 0x00b6, 0x0076, 0x0056, 0x0086, 0x9046, 0x2029, 0x0001,
+	0x2c20, 0x2019, 0x0002, 0x6210, 0x2258, 0x0096, 0x904e, 0x080c,
+	0xa687, 0x009e, 0x008e, 0x903e, 0x080c, 0xa732, 0x080c, 0xe492,
+	0x005e, 0x007e, 0x00be, 0x0005, 0x00b6, 0x0046, 0x0056, 0x0076,
+	0x00c6, 0x0156, 0x2c20, 0x2128, 0x20a9, 0x007f, 0x900e, 0x0016,
+	0x0036, 0x080c, 0x6616, 0x1190, 0x0056, 0x0086, 0x9046, 0x2508,
+	0x2029, 0x0001, 0x0096, 0x904e, 0x080c, 0xa687, 0x009e, 0x008e,
+	0x903e, 0x080c, 0xa732, 0x080c, 0xe492, 0x005e, 0x003e, 0x001e,
+	0x8108, 0x1f04, 0xe51f, 0x015e, 0x00ce, 0x007e, 0x005e, 0x004e,
+	0x00be, 0x0005, 0x00b6, 0x0076, 0x0056, 0x6210, 0x2258, 0x0086,
+	0x9046, 0x2029, 0x0001, 0x2019, 0x0048, 0x0096, 0x904e, 0x080c,
+	0xa687, 0x009e, 0x008e, 0x903e, 0x080c, 0xa732, 0x2c20, 0x080c,
+	0xe492, 0x005e, 0x007e, 0x00be, 0x0005, 0x00b6, 0x0046, 0x0056,
+	0x0076, 0x00c6, 0x0156, 0x2c20, 0x20a9, 0x0800, 0x900e, 0x0016,
+	0x0036, 0x080c, 0x6616, 0x11a0, 0x0086, 0x9046, 0x2828, 0x0046,
+	0x2021, 0x0001, 0x080c, 0xe82a, 0x004e, 0x0096, 0x904e, 0x080c,
+	0xa687, 0x009e, 0x008e, 0x903e, 0x080c, 0xa732, 0x080c, 0xe492,
+	0x003e, 0x001e, 0x8108, 0x1f04, 0xe567, 0x015e, 0x00ce, 0x007e,
+	0x005e, 0x004e, 0x00be, 0x0005, 0x0016, 0x00f6, 0x080c, 0xcb58,
+	0x0198, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0046, 0x0180, 0xa800,
+	0x907d, 0x0138, 0xa803, 0x0000, 0xab82, 0x080c, 0x6c94, 0x2f48,
+	0x0cb0, 0xab82, 0x080c, 0x6c94, 0x00fe, 0x001e, 0x0005, 0xa800,
+	0x907d, 0x0130, 0xa803, 0x0000, 0x080c, 0x6c94, 0x2f48, 0x0cb8,
+	0x080c, 0x6c94, 0x0c88, 0x00e6, 0x0046, 0x0036, 0x2061, 0x1cd0,
+	0x9005, 0x1138, 0x2071, 0x1800, 0x7454, 0x7074, 0x8001, 0x9402,
+	0x12f8, 0x2100, 0x9c06, 0x0188, 0x6000, 0x9086, 0x0000, 0x0168,
+	0x6008, 0x9206, 0x1150, 0x6320, 0x9386, 0x0009, 0x01b0, 0x6010,
+	0x91a0, 0x0004, 0x2424, 0x9406, 0x0140, 0x9ce0, 0x0018, 0x2001,
+	0x181a, 0x2004, 0x9c02, 0x1220, 0x0c20, 0x9085, 0x0001, 0x0008,
+	0x9006, 0x003e, 0x004e, 0x00ee, 0x0005, 0x631c, 0xd3c4, 0x1d68,
+	0x0c30, 0x0096, 0x0006, 0x080c, 0x0fff, 0x000e, 0x090c, 0x0dd5,
+	0xaae2, 0xa867, 0x010d, 0xa88e, 0x0026, 0x2010, 0x080c, 0xcb48,
+	0x2001, 0x0000, 0x0120, 0x2200, 0x9080, 0x0015, 0x2004, 0x002e,
+	0xa87a, 0x9186, 0x0020, 0x0110, 0xa8e3, 0xffff, 0xa986, 0xac76,
+	0xa87f, 0x0000, 0x2001, 0x198d, 0x2004, 0xa882, 0x9006, 0xa802,
+	0xa86a, 0xa88a, 0x0126, 0x2091, 0x8000, 0x080c, 0x6c94, 0x012e,
+	0x009e, 0x0005, 0x6700, 0x9786, 0x0000, 0x0158, 0x9786, 0x0001,
+	0x0140, 0x9786, 0x000a, 0x0128, 0x9786, 0x0009, 0x0110, 0x9085,
+	0x0001, 0x0005, 0x00e6, 0x6010, 0x9075, 0x0138, 0x00b6, 0x2058,
+	0xb8a0, 0x00be, 0x9206, 0x00ee, 0x0005, 0x9085, 0x0001, 0x0cd8,
+	0x0016, 0x6004, 0x908e, 0x001e, 0x11a0, 0x8007, 0x6134, 0x918c,
+	0x00ff, 0x9105, 0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
+	0x0005, 0x2001, 0x1986, 0x2004, 0x601a, 0x080c, 0x90f8, 0x080c,
+	0x96a6, 0x001e, 0x0005, 0xa001, 0xa001, 0x0005, 0x6024, 0xd0e4,
+	0x0158, 0xd0cc, 0x0118, 0x080c, 0xce92, 0x0030, 0x080c, 0xe846,
+	0x080c, 0x86b8, 0x080c, 0xae5f, 0x0005, 0x9280, 0x0008, 0x2004,
+	0x9084, 0x000f, 0x0002, 0xe679, 0xe679, 0xe679, 0xe67b, 0xe679,
+	0xe67b, 0xe67b, 0xe679, 0xe67b, 0xe679, 0xe679, 0xe679, 0xe679,
+	0xe679, 0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x9280, 0x0008,
+	0x2004, 0x9084, 0x000f, 0x0002, 0xe692, 0xe692, 0xe692, 0xe692,
+	0xe692, 0xe692, 0xe69f, 0xe692, 0xe692, 0xe692, 0xe692, 0xe692,
+	0xe692, 0xe692, 0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00,
+	0x6003, 0x0001, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x0005, 0x0096,
+	0x00c6, 0x2260, 0x080c, 0xe846, 0x6043, 0x0000, 0x6024, 0xc0f4,
+	0xc0e4, 0x6026, 0x603b, 0x0000, 0x00ce, 0x00d6, 0x2268, 0x9186,
+	0x0007, 0x1904, 0xe6f8, 0x6814, 0x9005, 0x0138, 0x2048, 0xa87c,
+	0xd0fc, 0x1118, 0x00de, 0x009e, 0x08a8, 0x6007, 0x003a, 0x6003,
+	0x0001, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x00c6, 0x2d60, 0x6100,
+	0x9186, 0x0002, 0x1904, 0xe76f, 0x6014, 0x9005, 0x1138, 0x6000,
+	0x9086, 0x0007, 0x190c, 0x0dd5, 0x0804, 0xe76f, 0x2048, 0x080c,
+	0xcb5a, 0x1130, 0x0028, 0x2048, 0xa800, 0x9005, 0x1de0, 0x2900,
+	0x2048, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x1168, 0xa87c,
+	0xc0dc, 0xc0f4, 0xa87e, 0xa880, 0xc0fc, 0xa882, 0x2009, 0x0043,
+	0x080c, 0xdfc3, 0x0804, 0xe76f, 0x2009, 0x0041, 0x0804, 0xe769,
+	0x9186, 0x0005, 0x15a0, 0x6814, 0x2048, 0xa87c, 0xd0bc, 0x1120,
+	0x00de, 0x009e, 0x0804, 0xe692, 0xd0b4, 0x0128, 0xd0fc, 0x090c,
+	0x0dd5, 0x0804, 0xe6b3, 0x6007, 0x003a, 0x6003, 0x0001, 0x080c,
+	0x90f8, 0x080c, 0x96a6, 0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002,
+	0x0120, 0x9186, 0x0004, 0x1904, 0xe76f, 0x6814, 0x2048, 0xa97c,
+	0xc1f4, 0xc1dc, 0xa97e, 0xa980, 0xc1fc, 0xc1bc, 0xa982, 0x00f6,
+	0x2c78, 0x080c, 0x1727, 0x00fe, 0x2009, 0x0042, 0x04d0, 0x0036,
+	0x080c, 0x0fff, 0x090c, 0x0dd5, 0xa867, 0x010d, 0x9006, 0xa802,
+	0xa86a, 0xa88a, 0x2d18, 0xab8e, 0xa887, 0x0045, 0x2c00, 0xa892,
+	0x6038, 0xa8a2, 0x2360, 0x6024, 0xc0dd, 0x6026, 0x6010, 0x00b6,
+	0x2058, 0xb8a0, 0x00be, 0x2004, 0x6354, 0xab7a, 0xa876, 0x9006,
+	0xa87e, 0xa882, 0xad9a, 0xae96, 0xa89f, 0x0001, 0x080c, 0x6c94,
+	0x2019, 0x0045, 0x6008, 0x2068, 0x080c, 0xe16f, 0x2d00, 0x600a,
+	0x6023, 0x0006, 0x6003, 0x0007, 0x901e, 0x631a, 0x6342, 0x003e,
+	0x0038, 0x6043, 0x0000, 0x6003, 0x0007, 0x080c, 0xdfc3, 0x00ce,
+	0x00de, 0x009e, 0x0005, 0x9186, 0x0013, 0x1128, 0x6004, 0x9082,
+	0x0085, 0x2008, 0x00c2, 0x9186, 0x0027, 0x1178, 0x080c, 0x959a,
+	0x0036, 0x0096, 0x6014, 0x2048, 0x2019, 0x0004, 0x080c, 0xe58c,
+	0x009e, 0x003e, 0x080c, 0x96a6, 0x0005, 0x9186, 0x0014, 0x0d70,
+	0x080c, 0xaef5, 0x0005, 0xe7a2, 0xe7a0, 0xe7a0, 0xe7a0, 0xe7a0,
+	0xe7a0, 0xe7a2, 0xe7a0, 0xe7a0, 0xe7a0, 0xe7a0, 0xe7a0, 0xe7a0,
+	0x080c, 0x0dd5, 0x080c, 0x959a, 0x6003, 0x000c, 0x080c, 0x96a6,
+	0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085, 0x0208, 0x001a,
+	0x080c, 0xaef5, 0x0005, 0xe7c0, 0xe7c0, 0xe7c0, 0xe7c0, 0xe7c2,
+	0xe7e2, 0xe7c0, 0xe7c0, 0xe7c0, 0xe7c0, 0xe7c0, 0xe7c0, 0xe7c0,
+	0x080c, 0x0dd5, 0x00d6, 0x2c68, 0x080c, 0xae09, 0x01b0, 0x6003,
+	0x0001, 0x6007, 0x001e, 0x2009, 0x026e, 0x210c, 0x613a, 0x2009,
+	0x026f, 0x210c, 0x613e, 0x600b, 0xffff, 0x6910, 0x6112, 0x6023,
+	0x0004, 0x080c, 0x90f8, 0x080c, 0x96a6, 0x2d60, 0x080c, 0xae5f,
+	0x00de, 0x0005, 0x080c, 0xae5f, 0x0005, 0x00e6, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0ec, 0x00ee, 0x0005, 0x2009, 0x1867,
+	0x210c, 0xd1ec, 0x05b0, 0x6003, 0x0002, 0x6024, 0xc0e5, 0x6026,
+	0xd0cc, 0x0150, 0x2001, 0x1987, 0x2004, 0x6042, 0x2009, 0x1867,
+	0x210c, 0xd1f4, 0x1520, 0x00a0, 0x2009, 0x1867, 0x210c, 0xd1f4,
+	0x0128, 0x6024, 0xc0e4, 0x6026, 0x9006, 0x00d8, 0x2001, 0x1987,
+	0x200c, 0x2001, 0x1985, 0x2004, 0x9100, 0x9080, 0x000a, 0x6042,
+	0x6010, 0x00b6, 0x2058, 0xb8bc, 0x00be, 0x0008, 0x2104, 0x9005,
+	0x0118, 0x9088, 0x0003, 0x0cd0, 0x2c0a, 0x600f, 0x0000, 0x9085,
+	0x0001, 0x0005, 0x0016, 0x00c6, 0x00e6, 0x6154, 0xb8bc, 0x2060,
+	0x8cff, 0x0180, 0x84ff, 0x1118, 0x6054, 0x9106, 0x1138, 0x600c,
+	0x2072, 0x080c, 0x86b8, 0x080c, 0xae5f, 0x0010, 0x9cf0, 0x0003,
+	0x2e64, 0x0c70, 0x00ee, 0x00ce, 0x001e, 0x0005, 0x00d6, 0x00b6,
+	0x6010, 0x2058, 0xb8bc, 0x2068, 0x9005, 0x0130, 0x9c06, 0x0110,
+	0x680c, 0x0cd0, 0x600c, 0x680e, 0x00be, 0x00de, 0x0005, 0x0026,
+	0x0036, 0x0156, 0x2011, 0x182c, 0x2204, 0x9084, 0x00ff, 0x2019,
+	0x026e, 0x2334, 0x9636, 0x1508, 0x8318, 0x2334, 0x2204, 0x9084,
+	0xff00, 0x9636, 0x11d0, 0x2011, 0x0270, 0x20a9, 0x0004, 0x6010,
+	0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xbe2d, 0x009e, 0x1168,
+	0x2011, 0x0274, 0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019,
+	0x0006, 0x080c, 0xbe2d, 0x009e, 0x1100, 0x015e, 0x003e, 0x002e,
+	0x0005, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5fc0, 0x080c, 0x2fa3,
+	0x00ee, 0x0005, 0x0096, 0x0026, 0x080c, 0x0fff, 0x090c, 0x0dd5,
+	0xa85c, 0x9080, 0x001a, 0x20a0, 0x20a9, 0x000c, 0xa860, 0x20e8,
+	0x9006, 0x4004, 0x9186, 0x0046, 0x1118, 0xa867, 0x0136, 0x0038,
+	0xa867, 0x0138, 0x9186, 0x0041, 0x0110, 0xa87b, 0x0001, 0x7038,
+	0x9084, 0xff00, 0x7240, 0x9294, 0xff00, 0x8007, 0x9215, 0xaa9a,
+	0x9186, 0x0046, 0x1168, 0x7038, 0x9084, 0x00ff, 0x723c, 0x9294,
+	0xff00, 0x9215, 0xaa9e, 0x723c, 0x9294, 0x00ff, 0xaaa2, 0x0060,
+	0x7040, 0x9084, 0x00ff, 0x7244, 0x9294, 0xff00, 0x9215, 0xaa9e,
+	0x7244, 0x9294, 0x00ff, 0xaaa2, 0x9186, 0x0046, 0x1118, 0x9e90,
+	0x0012, 0x0010, 0x9e90, 0x001a, 0x2204, 0x8007, 0xa8a6, 0x8210,
+	0x2204, 0x8007, 0xa8aa, 0x8210, 0x2204, 0x8007, 0xa8ae, 0x8210,
+	0x2204, 0x8007, 0xa8b2, 0x8210, 0x9186, 0x0046, 0x11b8, 0x9e90,
+	0x0016, 0x2204, 0x8007, 0xa8b6, 0x8210, 0x2204, 0x8007, 0xa8ba,
+	0x8210, 0x2204, 0x8007, 0xa8be, 0x8210, 0x2204, 0x8007, 0xa8c2,
+	0x8210, 0x2011, 0x0205, 0x2013, 0x0001, 0x00b0, 0x9e90, 0x001e,
+	0x2204, 0x8007, 0xa8b6, 0x8210, 0x2204, 0x8007, 0xa8ba, 0x2011,
+	0x0205, 0x2013, 0x0001, 0x2011, 0x0260, 0x2204, 0x8007, 0xa8be,
+	0x8210, 0x2204, 0x8007, 0xa8c2, 0x9186, 0x0046, 0x1118, 0x2011,
+	0x0262, 0x0010, 0x2011, 0x026a, 0x0146, 0x01d6, 0x0036, 0x20a9,
+	0x0001, 0x2019, 0x0008, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031,
+	0x20a0, 0x2204, 0x8007, 0x4004, 0x8210, 0x8319, 0x1dd0, 0x003e,
+	0x01ce, 0x013e, 0x2011, 0x0205, 0x2013, 0x0000, 0x002e, 0x080c,
+	0x6c94, 0x009e, 0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800,
+	0x00be, 0xd0fc, 0x0108, 0x0011, 0x00ee, 0x0005, 0xa880, 0xc0e5,
+	0xa882, 0x0005, 0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066, 0x0056,
+	0x0046, 0x0026, 0x0016, 0x0126, 0x2091, 0x8000, 0x2029, 0x19ef,
+	0x252c, 0x2021, 0x19f5, 0x2424, 0x2061, 0x1cd0, 0x2071, 0x1800,
+	0x7654, 0x7074, 0x9606, 0x0578, 0x6720, 0x9786, 0x0001, 0x0118,
+	0x9786, 0x0008, 0x1500, 0x2500, 0x9c06, 0x01e8, 0x2400, 0x9c06,
+	0x01d0, 0x080c, 0xe61a, 0x01b8, 0x080c, 0xe62a, 0x11a0, 0x6000,
+	0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x1a70, 0x001e, 0x080c,
+	0xcd4f, 0x1110, 0x080c, 0x31f5, 0x080c, 0xcd60, 0x1110, 0x080c,
+	0xb821, 0x080c, 0xae90, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004,
+	0x9c02, 0x1208, 0x0858, 0x012e, 0x001e, 0x002e, 0x004e, 0x005e,
+	0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x2001, 0x1810,
+	0x2004, 0xd0dc, 0x0005, 0x0006, 0x2001, 0x1837, 0x2004, 0xd09c,
+	0x000e, 0x0005, 0x0006, 0x0036, 0x0046, 0x080c, 0xd25a, 0x0168,
+	0x2019, 0xffff, 0x9005, 0x0128, 0x6010, 0x00b6, 0x2058, 0xbba0,
+	0x00be, 0x2021, 0x0004, 0x080c, 0x4cd5, 0x004e, 0x003e, 0x000e,
+	0x6004, 0x9086, 0x0001, 0x1128, 0x080c, 0xa7f8, 0x080c, 0xae90,
+	0x9006, 0x0005, 0x00e6, 0x00c6, 0x00b6, 0x0046, 0x2061, 0x1cd0,
+	0x2071, 0x1800, 0x7454, 0x7074, 0x8001, 0x9402, 0x12b8, 0x2100,
+	0x9c06, 0x0148, 0x6000, 0x9086, 0x0000, 0x0128, 0x6010, 0x2058,
+	0xb8a0, 0x9206, 0x0140, 0x9ce0, 0x0018, 0x2001, 0x181a, 0x2004,
+	0x9c02, 0x1220, 0x0c60, 0x9085, 0x0001, 0x0008, 0x9006, 0x004e,
+	0x00be, 0x00ce, 0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6, 0x0016,
+	0x2091, 0x8000, 0x2071, 0x1840, 0xd5a4, 0x0118, 0x7004, 0x8000,
+	0x7006, 0xd5b4, 0x0118, 0x7000, 0x8000, 0x7002, 0xd5ac, 0x0178,
+	0x2500, 0x9084, 0x0007, 0x908e, 0x0003, 0x0148, 0x908e, 0x0004,
+	0x0130, 0x908e, 0x0005, 0x0118, 0x2071, 0xfff6, 0x0089, 0x001e,
+	0x00ee, 0x000e, 0x012e, 0x0005, 0x0126, 0x0006, 0x00e6, 0x2091,
+	0x8000, 0x2071, 0xffee, 0x0021, 0x00ee, 0x000e, 0x012e, 0x0005,
+	0x2e05, 0x8000, 0x2077, 0x1220, 0x8e70, 0x2e05, 0x8000, 0x2077,
+	0x0005, 0x00e6, 0x2071, 0xffec, 0x0c99, 0x00ee, 0x0005, 0x00e6,
+	0x2071, 0xfff0, 0x0c69, 0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6,
+	0x2091, 0x8000, 0x2071, 0x1840, 0x7014, 0x8000, 0x7016, 0x00ee,
+	0x000e, 0x012e, 0x0005, 0x0003, 0x000b, 0x079e, 0x0000, 0xc000,
+	0x0001, 0x8064, 0x0008, 0x0010, 0x0000, 0x8066, 0x0000, 0x0101,
+	0x0008, 0x4407, 0x0003, 0x8060, 0x0000, 0x0400, 0x0000, 0x580d,
+	0x000b, 0x79a8, 0x000b, 0x50ee, 0x000b, 0x4c0a, 0x0003, 0xbac0,
+	0x0009, 0x008a, 0x0000, 0x0c0a, 0x000b, 0x15fe, 0x0008, 0x340a,
+	0x0003, 0xc4c0, 0x0009, 0x7000, 0x0000, 0xffa0, 0x0001, 0x2000,
+	0x0000, 0x1668, 0x000b, 0x808c, 0x0008, 0x0001, 0x0000, 0x0000,
+	0x0007, 0x4028, 0x0000, 0x4047, 0x000a, 0x808c, 0x0008, 0x0002,
+	0x0000, 0x0822, 0x0003, 0x4022, 0x0000, 0x0028, 0x000b, 0x4122,
+	0x0008, 0x94c0, 0x0009, 0xff00, 0x0008, 0xffe0, 0x0009, 0x0500,
+	0x0008, 0x0a93, 0x000b, 0x4447, 0x0002, 0x0e90, 0x0003, 0x0bfe,
+	0x0008, 0x11a0, 0x0001, 0x126e, 0x0003, 0x0ca0, 0x0001, 0x126e,
+	0x0003, 0x9180, 0x0001, 0x0004, 0x0000, 0x8060, 0x0000, 0x0400,
+	0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x4436,
+	0x000b, 0x808c, 0x0008, 0x0000, 0x0008, 0x0060, 0x0008, 0x8062,
+	0x0008, 0x0004, 0x0000, 0x8066, 0x0000, 0x0411, 0x0000, 0x443e,
+	0x0003, 0x03fe, 0x0000, 0x43e0, 0x0001, 0x0e6b, 0x000b, 0xc2c0,
+	0x0009, 0x00ff, 0x0008, 0x02e0, 0x0001, 0x0e6b, 0x000b, 0x9180,
+	0x0001, 0x0005, 0x0008, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62,
+	0x0008, 0x8066, 0x0000, 0x0019, 0x0000, 0x444d, 0x000b, 0x0240,
+	0x0002, 0x0a68, 0x0003, 0x00fe, 0x0000, 0x326b, 0x000b, 0x0248,
+	0x000a, 0x085c, 0x0003, 0x9180, 0x0001, 0x0006, 0x0008, 0x7f62,
+	0x0008, 0x8002, 0x0008, 0x0003, 0x0008, 0x8066, 0x0000, 0x020a,
+	0x0000, 0x445b, 0x0003, 0x112a, 0x0000, 0x002e, 0x0008, 0x022c,
+	0x0008, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x808c, 0x0008, 0x0002,
+	0x0000, 0x1760, 0x0008, 0x8062, 0x0008, 0x000f, 0x0008, 0x8066,
+	0x0000, 0x0011, 0x0008, 0x4468, 0x0003, 0x01fe, 0x0008, 0x42e0,
+	0x0009, 0x0e5c, 0x0003, 0x00fe, 0x0000, 0x43e0, 0x0001, 0x0e5c,
+	0x0003, 0x1734, 0x0000, 0x1530, 0x0000, 0x1632, 0x0008, 0x0d2a,
+	0x0008, 0x9880, 0x0001, 0x0010, 0x0000, 0x8060, 0x0000, 0x0400,
+	0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x1e0a, 0x0008, 0x447a,
+	0x0003, 0x808a, 0x0008, 0x0003, 0x0008, 0x1a60, 0x0000, 0x8062,
+	0x0008, 0x0002, 0x0000, 0x5880, 0x000b, 0x8066, 0x0000, 0x3679,
+	0x0000, 0x4483, 0x0003, 0x5884, 0x0003, 0x3efe, 0x0008, 0x7f4f,
+	0x0002, 0x088a, 0x000b, 0x0d00, 0x0000, 0x0092, 0x000c, 0x8054,
+	0x0008, 0x0011, 0x0008, 0x8074, 0x0000, 0x1010, 0x0008, 0x1efe,
+	0x0000, 0x300a, 0x000b, 0x00c8, 0x000c, 0x000a, 0x000b, 0x00fe,
+	0x0000, 0x349a, 0x0003, 0x1a60, 0x0000, 0x8062, 0x0008, 0x0007,
+	0x0000, 0x8066, 0x0000, 0x0231, 0x0008, 0x4499, 0x000b, 0x03fe,
+	0x0000, 0x04d0, 0x0001, 0x0cc0, 0x000b, 0x82c0, 0x0001, 0x1f00,
+	0x0000, 0xffa0, 0x0001, 0x0400, 0x0000, 0x08af, 0x0003, 0x14c0,
+	0x000b, 0x01fe, 0x0008, 0x0580, 0x0009, 0x7f06, 0x0000, 0x02fe,
+	0x0008, 0xffc0, 0x0001, 0x00ff, 0x0008, 0x0690, 0x0001, 0x10af,
+	0x0003, 0x7f08, 0x0008, 0x84c0, 0x0001, 0xff00, 0x0008, 0x08c0,
+	0x0003, 0x00fe, 0x0000, 0x34b6, 0x000b, 0x8072, 0x0000, 0x1010,
+	0x0008, 0x3944, 0x0002, 0x08b1, 0x0003, 0x00ba, 0x0003, 0x8072,
+	0x0000, 0x2020, 0x0008, 0x3945, 0x000a, 0x08b6, 0x000b, 0x3946,
+	0x000a, 0x0cc7, 0x0003, 0x0000, 0x0007, 0x3943, 0x000a, 0x08c7,
+	0x000b, 0x00ba, 0x0003, 0x00fe, 0x0000, 0x34c5, 0x0003, 0x8072,
+	0x0000, 0x1000, 0x0000, 0x00c7, 0x0003, 0x8072, 0x0000, 0x2000,
+	0x0000, 0x4000, 0x000f, 0x1c60, 0x0000, 0x1b62, 0x0000, 0x8066,
+	0x0000, 0x0231, 0x0008, 0x44cc, 0x000b, 0x58cd, 0x000b, 0x0140,
+	0x0008, 0x0242, 0x0000, 0x1f43, 0x0002, 0x0cdb, 0x000b, 0x0d44,
+	0x0000, 0x0d46, 0x0008, 0x0348, 0x0008, 0x044a, 0x0008, 0x030a,
+	0x0008, 0x040c, 0x0000, 0x0d06, 0x0000, 0x0d08, 0x0008, 0x00df,
+	0x0003, 0x0344, 0x0008, 0x0446, 0x0008, 0x0548, 0x0008, 0x064a,
+	0x0000, 0x1948, 0x000a, 0x08e2, 0x0003, 0x0d4a, 0x0008, 0x58e2,
+	0x0003, 0x3efe, 0x0008, 0x7f4f, 0x0002, 0x08e9, 0x000b, 0x8000,
+	0x0000, 0x0001, 0x0000, 0x0092, 0x000c, 0x8054, 0x0008, 0x0001,
+	0x0000, 0x8074, 0x0000, 0x2020, 0x0008, 0x4000, 0x000f, 0x3a40,
+	0x000a, 0x0c0d, 0x0003, 0x2b24, 0x0008, 0x2b24, 0x0008, 0x58f2,
+	0x000b, 0x8054, 0x0008, 0x0002, 0x0000, 0x1242, 0x0002, 0x0940,
+	0x0003, 0x3a45, 0x000a, 0x092f, 0x0003, 0x8072, 0x0000, 0x1000,
+	0x0000, 0x3945, 0x000a, 0x08ff, 0x0003, 0x8072, 0x0000, 0x3010,
+	0x0000, 0x1e10, 0x000a, 0x7f3c, 0x0000, 0x092a, 0x0003, 0x1d00,
+	0x0002, 0x7f3a, 0x0000, 0x0d60, 0x0000, 0x7f62, 0x0008, 0x8066,
+	0x0000, 0x0009, 0x0008, 0x4508, 0x000b, 0x00fe, 0x0000, 0x3527,
+	0x000b, 0x1c60, 0x0000, 0x8062, 0x0008, 0x0001, 0x0000, 0x8066,
+	0x0000, 0x0009, 0x0008, 0x4510, 0x000b, 0x00fe, 0x0000, 0x3243,
+	0x000b, 0x0038, 0x0000, 0x0060, 0x0008, 0x8062, 0x0008, 0x0019,
+	0x0000, 0x8066, 0x0000, 0x0009, 0x0008, 0x4519, 0x000b, 0x80c0,
+	0x0009, 0x00ff, 0x0008, 0x7f3e, 0x0008, 0x0d60, 0x0000, 0x0efe,
+	0x0008, 0x1f80, 0x0001, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0009,
+	0x0008, 0x4523, 0x000b, 0x003a, 0x0008, 0x1dfe, 0x0000, 0x0104,
+	0x000b, 0x0036, 0x0008, 0x00c8, 0x000c, 0x0140, 0x000b, 0x8074,
+	0x0000, 0x2000, 0x0000, 0x8072, 0x0000, 0x2000, 0x0000, 0x0140,
+	0x000b, 0x3a44, 0x0002, 0x0a71, 0x000b, 0x8074, 0x0000, 0x1000,
+	0x0000, 0x8072, 0x0000, 0x1000, 0x0000, 0x2d0e, 0x0000, 0x2d0e,
+	0x0000, 0x3640, 0x0003, 0x26fe, 0x0008, 0x26fe, 0x0008, 0x2700,
+	0x0008, 0x2700, 0x0008, 0x00d0, 0x0009, 0x0d52, 0x000b, 0x8074,
+	0x0000, 0x4040, 0x0008, 0x5940, 0x0003, 0x50ee, 0x000b, 0x3a46,
+	0x000a, 0x0d52, 0x000b, 0x3a47, 0x0002, 0x094d, 0x000b, 0x8054,
+	0x0008, 0x0004, 0x0000, 0x8074, 0x0000, 0x8000, 0x0000, 0x8072,
+	0x0000, 0x3000, 0x0008, 0x019c, 0x0003, 0x92c0, 0x0009, 0x0fc8,
+	0x0000, 0x080a, 0x0003, 0x1246, 0x000a, 0x0e3a, 0x0003, 0x1a60,
+	0x0000, 0x8062, 0x0008, 0x0002, 0x0000, 0x8066, 0x0000, 0x362a,
+	0x0000, 0x4557, 0x000b, 0x2000, 0x0000, 0x2000, 0x0000, 0x2102,
+	0x0000, 0x2102, 0x0000, 0x2204, 0x0000, 0x2204, 0x0000, 0x2306,
+	0x0000, 0x2306, 0x0000, 0x2408, 0x0000, 0x2408, 0x0000, 0x250a,
+	0x0000, 0x250a, 0x0000, 0x260c, 0x0000, 0x260c, 0x0000, 0x270e,
+	0x0000, 0x270e, 0x0000, 0x2810, 0x0000, 0x2810, 0x0000, 0x2912,
+	0x0000, 0x2912, 0x0000, 0x1a60, 0x0000, 0x8062, 0x0008, 0x0007,
+	0x0000, 0x8066, 0x0000, 0x0052, 0x0000, 0x4571, 0x0003, 0x92c0,
+	0x0009, 0x0780, 0x0008, 0x0e56, 0x0003, 0x124b, 0x0002, 0x097a,
+	0x0003, 0x2e4d, 0x0002, 0x2e4d, 0x0002, 0x0a40, 0x0003, 0x3a46,
+	0x000a, 0x0d8a, 0x000b, 0x597c, 0x0003, 0x8054, 0x0008, 0x0004,
+	0x0000, 0x1243, 0x000a, 0x0998, 0x0003, 0x8010, 0x0008, 0x000d,
+	0x0000, 0x021b, 0x000c, 0x1948, 0x000a, 0x0987, 0x000b, 0x0210,
+	0x0004, 0x1810, 0x0000, 0x021b, 0x000c, 0x0198, 0x000b, 0x1948,
+	0x000a, 0x098e, 0x000b, 0x1243, 0x000a, 0x0a43, 0x0003, 0x194d,
+	0x000a, 0x0992, 0x0003, 0x1243, 0x000a, 0x0a4a, 0x0003, 0x5992,
+	0x0003, 0x8054, 0x0008, 0x0004, 0x0000, 0x0210, 0x0004, 0x1810,
+	0x0000, 0x021b, 0x000c, 0x8074, 0x0000, 0xf000, 0x0008, 0x8072,
+	0x0000, 0x3000, 0x0008, 0x0d30, 0x0000, 0x3a42, 0x0002, 0x0da2,
+	0x000b, 0x15fe, 0x0008, 0x3461, 0x000b, 0x000a, 0x000b, 0x8074,
+	0x0000, 0x0501, 0x0000, 0x8010, 0x0008, 0x000c, 0x0008, 0x021b,
+	0x000c, 0x000a, 0x000b, 0xbbe0, 0x0009, 0x0030, 0x0008, 0x0db8,
+	0x0003, 0x18fe, 0x0000, 0x3ce0, 0x0009, 0x09b5, 0x0003, 0x15fe,
+	0x0008, 0x3ce0, 0x0009, 0x09b5, 0x0003, 0x020b, 0x0004, 0x8076,
+	0x0008, 0x0040, 0x0000, 0x0208, 0x000b, 0x8076, 0x0008, 0x0041,
+	0x0008, 0x0208, 0x000b, 0xbbe0, 0x0009, 0x0032, 0x0000, 0x0dbd,
+	0x0003, 0x3c1e, 0x0008, 0x0208, 0x000b, 0xbbe0, 0x0009, 0x003b,
+	0x0000, 0x0dc2, 0x000b, 0x3c20, 0x0000, 0x0208, 0x000b, 0xbbe0,
+	0x0009, 0x0035, 0x0008, 0x0dc8, 0x000b, 0x8072, 0x0000, 0x8000,
+	0x0000, 0x0384, 0x000b, 0xbbe0, 0x0009, 0x0036, 0x0008, 0x0aa5,
+	0x000b, 0xbbe0, 0x0009, 0x0037, 0x0000, 0x0de9, 0x000b, 0x18fe,
+	0x0000, 0x3ce0, 0x0009, 0x0db5, 0x000b, 0x8076, 0x0008, 0x0040,
+	0x0000, 0x1a60, 0x0000, 0x8062, 0x0008, 0x000d, 0x0000, 0x2604,
+	0x0008, 0x2604, 0x0008, 0x2706, 0x0008, 0x2706, 0x0008, 0x2808,
+	0x0000, 0x2808, 0x0000, 0x290a, 0x0000, 0x290a, 0x0000, 0x8066,
+	0x0000, 0x0422, 0x0000, 0x45e0, 0x000b, 0x0210, 0x0004, 0x8054,
+	0x0008, 0x0004, 0x0000, 0x8074, 0x0000, 0xf000, 0x0008, 0x8072,
+	0x0000, 0xb000, 0x0000, 0x019c, 0x0003, 0xbbe0, 0x0009, 0x0038,
+	0x0000, 0x0dfb, 0x000b, 0x18fe, 0x0000, 0x3ce0, 0x0009, 0x09f8,
+	0x0003, 0x15fe, 0x0008, 0x3ce0, 0x0009, 0x0db1, 0x0003, 0x020b,
+	0x0004, 0x8076, 0x0008, 0x0040, 0x0000, 0x8072, 0x0000, 0x8000,
+	0x0000, 0x0268, 0x000b, 0x8076, 0x0008, 0x0042, 0x0008, 0x0208,
+	0x000b, 0xbbe0, 0x0009, 0x0016, 0x0000, 0x0e08, 0x000b, 0x8074,
+	0x0000, 0x0808, 0x0008, 0x3a44, 0x0002, 0x0c0c, 0x000b, 0x8074,
+	0x0000, 0x0800, 0x0000, 0x8072, 0x0000, 0x8000, 0x0000, 0x8000,
+	0x000f, 0x000a, 0x000b, 0x8072, 0x0000, 0x8000, 0x0000, 0x000a,
+	0x000b, 0x3d30, 0x000a, 0x7f00, 0x0000, 0xbc80, 0x0001, 0x0007,
+	0x0000, 0x0214, 0x0003, 0x1930, 0x000a, 0x7f00, 0x0000, 0x9880,
+	0x0001, 0x0007, 0x0000, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62,
+	0x0008, 0x8066, 0x0000, 0x000a, 0x0008, 0x4619, 0x000b, 0x4000,
+	0x000f, 0x221e, 0x000b, 0x0870, 0x0008, 0x4000, 0x000f, 0x7e1b,
+	0x000b, 0xbbe0, 0x0009, 0x0030, 0x0008, 0x0e1b, 0x0003, 0x18fe,
+	0x0000, 0x3ce0, 0x0009, 0x0a2c, 0x0003, 0x15fe, 0x0008, 0x3ce0,
+	0x0009, 0x0a2c, 0x0003, 0x020b, 0x0004, 0x8076, 0x0008, 0x0040,
+	0x0000, 0x022e, 0x0003, 0x8076, 0x0008, 0x0041, 0x0008, 0x8072,
+	0x0000, 0x8000, 0x0000, 0x021b, 0x0003, 0xbac0, 0x0009, 0x0090,
+	0x0008, 0x0a37, 0x0003, 0x8074, 0x0000, 0x0706, 0x0000, 0x0239,
+	0x0003, 0x8074, 0x0000, 0x0703, 0x0000, 0x4000, 0x000f, 0x8010,
+	0x0008, 0x0023, 0x0000, 0x0276, 0x000b, 0x8010, 0x0008, 0x0008,
+	0x0000, 0x0276, 0x000b, 0x8010, 0x0008, 0x0022, 0x0008, 0x0276,
+	0x000b, 0x0210, 0x0004, 0x8010, 0x0008, 0x0007, 0x0000, 0x021b,
+	0x000c, 0x1810, 0x0000, 0x021b, 0x000c, 0x0282, 0x0003, 0x0210,
+	0x0004, 0x8010, 0x0008, 0x001b, 0x0008, 0x021b, 0x000c, 0x1810,
+	0x0000, 0x021b, 0x000c, 0x8074, 0x0000, 0xf080, 0x0000, 0x8072,
+	0x0000, 0x3000, 0x0008, 0x0d30, 0x0000, 0x000a, 0x000b, 0x8010,
+	0x0008, 0x0009, 0x0008, 0x0276, 0x000b, 0x8010, 0x0008, 0x0005,
+	0x0008, 0x0276, 0x000b, 0x1648, 0x000a, 0x0c6f, 0x000b, 0x808c,
+	0x0008, 0x0001, 0x0000, 0x8010, 0x0008, 0x0004, 0x0000, 0x4143,
+	0x000a, 0x086f, 0x0003, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x0d2a,
+	0x0008, 0x0276, 0x000b, 0x8010, 0x0008, 0x0003, 0x0008, 0x027a,
+	0x000b, 0x8010, 0x0008, 0x000b, 0x0000, 0x027a, 0x000b, 0x8010,
+	0x0008, 0x0002, 0x0000, 0x027a, 0x000b, 0x3a47, 0x0002, 0x0d40,
+	0x000b, 0x8010, 0x0008, 0x0006, 0x0008, 0x027a, 0x000b, 0x8074,
+	0x0000, 0xf000, 0x0008, 0x8072, 0x0000, 0x3000, 0x0008, 0x021b,
+	0x000c, 0x0231, 0x0004, 0x3a40, 0x000a, 0x080a, 0x0003, 0x8010,
+	0x0008, 0x000c, 0x0008, 0x021b, 0x000c, 0x000a, 0x000b, 0x8074,
+	0x0000, 0xf080, 0x0000, 0x8072, 0x0000, 0x3000, 0x0008, 0x0d30,
+	0x0000, 0x2e4d, 0x0002, 0x2e4d, 0x0002, 0x0a8d, 0x000b, 0x8054,
+	0x0008, 0x0019, 0x0000, 0x000a, 0x000b, 0x8054, 0x0008, 0x0009,
+	0x0008, 0x000a, 0x000b, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x026b,
+	0x000b, 0x808c, 0x0008, 0x0000, 0x0008, 0x4447, 0x0002, 0x0ab9,
+	0x0003, 0xc0c0, 0x0001, 0x00ff, 0x0008, 0xffe0, 0x0009, 0x00ff,
+	0x0008, 0x0e90, 0x0003, 0xc1e0, 0x0001, 0xffff, 0x0008, 0x0e90,
+	0x0003, 0x8010, 0x0008, 0x0013, 0x0000, 0x021b, 0x000c, 0x8074,
+	0x0000, 0x0202, 0x0008, 0x000a, 0x000b, 0x3a40, 0x000a, 0x0eb6,
+	0x000b, 0x8074, 0x0000, 0x0200, 0x0000, 0x3d00, 0x0000, 0x3cfe,
+	0x0000, 0x8072, 0x0000, 0x8000, 0x0000, 0x43e0, 0x0001, 0x0eb4,
+	0x0003, 0x42fe, 0x0000, 0xffc0, 0x0001, 0x00ff, 0x0008, 0x00e0,
+	0x0009, 0x0a90, 0x000b, 0x0d08, 0x0008, 0x0309, 0x000b, 0x8072,
+	0x0000, 0x8000, 0x0000, 0x000a, 0x000b, 0x038d, 0x0004, 0x808c,
+	0x0008, 0x0001, 0x0000, 0x04fe, 0x0008, 0x3370, 0x0003, 0x0460,
 	0x0000, 0x8062, 0x0008, 0x0001, 0x0000, 0x8066, 0x0000, 0x0009,
-	0x0008, 0x4510, 0x000b, 0x00fe, 0x0000, 0x3243, 0x000b, 0x0038,
-	0x0000, 0x0060, 0x0008, 0x8062, 0x0008, 0x0019, 0x0000, 0x8066,
-	0x0000, 0x0009, 0x0008, 0x4519, 0x000b, 0x80c0, 0x0009, 0x00ff,
-	0x0008, 0x7f3e, 0x0008, 0x0d60, 0x0000, 0x0efe, 0x0008, 0x1f80,
-	0x0001, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x4523,
-	0x000b, 0x003a, 0x0008, 0x1dfe, 0x0000, 0x0104, 0x000b, 0x0036,
-	0x0008, 0x00c8, 0x000c, 0x0140, 0x000b, 0x8074, 0x0000, 0x2000,
-	0x0000, 0x8072, 0x0000, 0x2000, 0x0000, 0x0140, 0x000b, 0x3a44,
-	0x0002, 0x0a71, 0x000b, 0x8074, 0x0000, 0x1000, 0x0000, 0x8072,
-	0x0000, 0x1000, 0x0000, 0x2d0e, 0x0000, 0x2d0e, 0x0000, 0x3640,
-	0x0003, 0x26fe, 0x0008, 0x26fe, 0x0008, 0x2700, 0x0008, 0x2700,
-	0x0008, 0x00d0, 0x0009, 0x0d52, 0x000b, 0x8074, 0x0000, 0x4040,
-	0x0008, 0x5940, 0x0003, 0x50ee, 0x000b, 0x3a46, 0x000a, 0x0d52,
-	0x000b, 0x3a47, 0x0002, 0x094d, 0x000b, 0x8054, 0x0008, 0x0004,
-	0x0000, 0x8074, 0x0000, 0x8000, 0x0000, 0x8072, 0x0000, 0x3000,
-	0x0008, 0x019c, 0x0003, 0x92c0, 0x0009, 0x0fc8, 0x0000, 0x080a,
-	0x0003, 0x1246, 0x000a, 0x0e3a, 0x0003, 0x1a60, 0x0000, 0x8062,
-	0x0008, 0x0002, 0x0000, 0x8066, 0x0000, 0x362a, 0x0000, 0x4557,
-	0x000b, 0x2000, 0x0000, 0x2000, 0x0000, 0x2102, 0x0000, 0x2102,
-	0x0000, 0x2204, 0x0000, 0x2204, 0x0000, 0x2306, 0x0000, 0x2306,
-	0x0000, 0x2408, 0x0000, 0x2408, 0x0000, 0x250a, 0x0000, 0x250a,
-	0x0000, 0x260c, 0x0000, 0x260c, 0x0000, 0x270e, 0x0000, 0x270e,
-	0x0000, 0x2810, 0x0000, 0x2810, 0x0000, 0x2912, 0x0000, 0x2912,
-	0x0000, 0x1a60, 0x0000, 0x8062, 0x0008, 0x0007, 0x0000, 0x8066,
-	0x0000, 0x0052, 0x0000, 0x4571, 0x0003, 0x92c0, 0x0009, 0x0780,
-	0x0008, 0x0e56, 0x0003, 0x124b, 0x0002, 0x097a, 0x0003, 0x2e4d,
-	0x0002, 0x2e4d, 0x0002, 0x0a40, 0x0003, 0x3a46, 0x000a, 0x0d8a,
-	0x000b, 0x597c, 0x0003, 0x8054, 0x0008, 0x0004, 0x0000, 0x1243,
-	0x000a, 0x0998, 0x0003, 0x8010, 0x0008, 0x000d, 0x0000, 0x021b,
-	0x000c, 0x1948, 0x000a, 0x0987, 0x000b, 0x0210, 0x0004, 0x1810,
-	0x0000, 0x021b, 0x000c, 0x0198, 0x000b, 0x1948, 0x000a, 0x098e,
-	0x000b, 0x1243, 0x000a, 0x0a43, 0x0003, 0x194d, 0x000a, 0x0992,
-	0x0003, 0x1243, 0x000a, 0x0a4a, 0x0003, 0x5992, 0x0003, 0x8054,
-	0x0008, 0x0004, 0x0000, 0x0210, 0x0004, 0x1810, 0x0000, 0x021b,
-	0x000c, 0x8074, 0x0000, 0xf000, 0x0008, 0x8072, 0x0000, 0x3000,
-	0x0008, 0x0d30, 0x0000, 0x3a42, 0x0002, 0x0da2, 0x000b, 0x15fe,
-	0x0008, 0x3461, 0x000b, 0x000a, 0x000b, 0x8074, 0x0000, 0x0501,
-	0x0000, 0x8010, 0x0008, 0x000c, 0x0008, 0x021b, 0x000c, 0x000a,
-	0x000b, 0xbbe0, 0x0009, 0x0030, 0x0008, 0x0db8, 0x0003, 0x18fe,
-	0x0000, 0x3ce0, 0x0009, 0x09b5, 0x0003, 0x15fe, 0x0008, 0x3ce0,
-	0x0009, 0x09b5, 0x0003, 0x020b, 0x0004, 0x8076, 0x0008, 0x0040,
-	0x0000, 0x0208, 0x000b, 0x8076, 0x0008, 0x0041, 0x0008, 0x0208,
-	0x000b, 0xbbe0, 0x0009, 0x0032, 0x0000, 0x0dbd, 0x0003, 0x3c1e,
-	0x0008, 0x0208, 0x000b, 0xbbe0, 0x0009, 0x003b, 0x0000, 0x0dc2,
-	0x000b, 0x3c20, 0x0000, 0x0208, 0x000b, 0xbbe0, 0x0009, 0x0035,
-	0x0008, 0x0dc8, 0x000b, 0x8072, 0x0000, 0x8000, 0x0000, 0x0384,
-	0x000b, 0xbbe0, 0x0009, 0x0036, 0x0008, 0x0aa5, 0x000b, 0xbbe0,
-	0x0009, 0x0037, 0x0000, 0x0de9, 0x000b, 0x18fe, 0x0000, 0x3ce0,
-	0x0009, 0x0db5, 0x000b, 0x8076, 0x0008, 0x0040, 0x0000, 0x1a60,
-	0x0000, 0x8062, 0x0008, 0x000d, 0x0000, 0x2604, 0x0008, 0x2604,
-	0x0008, 0x2706, 0x0008, 0x2706, 0x0008, 0x2808, 0x0000, 0x2808,
-	0x0000, 0x290a, 0x0000, 0x290a, 0x0000, 0x8066, 0x0000, 0x0422,
-	0x0000, 0x45e0, 0x000b, 0x0210, 0x0004, 0x8054, 0x0008, 0x0004,
-	0x0000, 0x8074, 0x0000, 0xf000, 0x0008, 0x8072, 0x0000, 0xb000,
-	0x0000, 0x019c, 0x0003, 0xbbe0, 0x0009, 0x0038, 0x0000, 0x0dfb,
-	0x000b, 0x18fe, 0x0000, 0x3ce0, 0x0009, 0x09f8, 0x0003, 0x15fe,
-	0x0008, 0x3ce0, 0x0009, 0x0db1, 0x0003, 0x020b, 0x0004, 0x8076,
-	0x0008, 0x0040, 0x0000, 0x8072, 0x0000, 0x8000, 0x0000, 0x0268,
-	0x000b, 0x8076, 0x0008, 0x0042, 0x0008, 0x0208, 0x000b, 0xbbe0,
-	0x0009, 0x0016, 0x0000, 0x0e08, 0x000b, 0x8074, 0x0000, 0x0808,
-	0x0008, 0x3a44, 0x0002, 0x0c0c, 0x000b, 0x8074, 0x0000, 0x0800,
-	0x0000, 0x8072, 0x0000, 0x8000, 0x0000, 0x8000, 0x000f, 0x000a,
-	0x000b, 0x8072, 0x0000, 0x8000, 0x0000, 0x000a, 0x000b, 0x3d30,
-	0x000a, 0x7f00, 0x0000, 0xbc80, 0x0001, 0x0007, 0x0000, 0x0214,
-	0x0003, 0x1930, 0x000a, 0x7f00, 0x0000, 0x9880, 0x0001, 0x0007,
+	0x0008, 0x46c3, 0x0003, 0x0004, 0x0000, 0x80c0, 0x0009, 0x00ff,
+	0x0008, 0x7f00, 0x0000, 0x80e0, 0x0001, 0x0004, 0x0000, 0x0add,
+	0x000b, 0x80e0, 0x0001, 0x0005, 0x0008, 0x0add, 0x000b, 0x80e0,
+	0x0001, 0x0006, 0x0008, 0x0add, 0x000b, 0x82c0, 0x0001, 0xff00,
+	0x0008, 0x7f04, 0x0008, 0x82e0, 0x0009, 0x0600, 0x0008, 0x0add,
+	0x000b, 0x82e0, 0x0009, 0x0500, 0x0008, 0x0add, 0x000b, 0x82e0,
+	0x0009, 0x0400, 0x0000, 0x0f70, 0x0003, 0xc4c0, 0x0009, 0x7000,
+	0x0000, 0xffe0, 0x0009, 0x1000, 0x0000, 0x0b09, 0x0003, 0x037e,
+	0x0004, 0x3941, 0x0002, 0x0ae8, 0x000b, 0x8072, 0x0000, 0x0400,
+	0x0000, 0x000a, 0x000b, 0x0460, 0x0000, 0x80fe, 0x0008, 0x002b,
+	0x0008, 0x7f62, 0x0008, 0x8066, 0x0000, 0x2209, 0x0008, 0x46ee,
+	0x0003, 0x11fe, 0x0000, 0x3304, 0x0003, 0x9180, 0x0001, 0x0002,
 	0x0000, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62, 0x0008, 0x8066,
-	0x0000, 0x000a, 0x0008, 0x4619, 0x000b, 0x4000, 0x000f, 0x221e,
-	0x000b, 0x0870, 0x0008, 0x4000, 0x000f, 0x7e1b, 0x000b, 0xbbe0,
-	0x0009, 0x0030, 0x0008, 0x0e1b, 0x0003, 0x18fe, 0x0000, 0x3ce0,
-	0x0009, 0x0a2c, 0x0003, 0x15fe, 0x0008, 0x3ce0, 0x0009, 0x0a2c,
-	0x0003, 0x020b, 0x0004, 0x8076, 0x0008, 0x0040, 0x0000, 0x022e,
-	0x0003, 0x8076, 0x0008, 0x0041, 0x0008, 0x8072, 0x0000, 0x8000,
-	0x0000, 0x021b, 0x0003, 0xbac0, 0x0009, 0x0090, 0x0008, 0x0a37,
-	0x0003, 0x8074, 0x0000, 0x0706, 0x0000, 0x0239, 0x0003, 0x8074,
-	0x0000, 0x0703, 0x0000, 0x4000, 0x000f, 0x8010, 0x0008, 0x0023,
-	0x0000, 0x0276, 0x000b, 0x8010, 0x0008, 0x0008, 0x0000, 0x0276,
-	0x000b, 0x8010, 0x0008, 0x0022, 0x0008, 0x0276, 0x000b, 0x0210,
-	0x0004, 0x8010, 0x0008, 0x0007, 0x0000, 0x021b, 0x000c, 0x1810,
-	0x0000, 0x021b, 0x000c, 0x0282, 0x0003, 0x0210, 0x0004, 0x8010,
-	0x0008, 0x001b, 0x0008, 0x021b, 0x000c, 0x1810, 0x0000, 0x021b,
-	0x000c, 0x8074, 0x0000, 0xf080, 0x0000, 0x8072, 0x0000, 0x3000,
-	0x0008, 0x0d30, 0x0000, 0x000a, 0x000b, 0x8010, 0x0008, 0x0009,
-	0x0008, 0x0276, 0x000b, 0x8010, 0x0008, 0x0005, 0x0008, 0x0276,
-	0x000b, 0x1648, 0x000a, 0x0c6f, 0x000b, 0x808c, 0x0008, 0x0001,
-	0x0000, 0x8010, 0x0008, 0x0004, 0x0000, 0x4143, 0x000a, 0x086f,
-	0x0003, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x0d2a, 0x0008, 0x0276,
-	0x000b, 0x8010, 0x0008, 0x0003, 0x0008, 0x027a, 0x000b, 0x8010,
-	0x0008, 0x000b, 0x0000, 0x027a, 0x000b, 0x8010, 0x0008, 0x0002,
-	0x0000, 0x027a, 0x000b, 0x3a47, 0x0002, 0x0d40, 0x000b, 0x8010,
-	0x0008, 0x0006, 0x0008, 0x027a, 0x000b, 0x8074, 0x0000, 0xf000,
-	0x0008, 0x8072, 0x0000, 0x3000, 0x0008, 0x021b, 0x000c, 0x0231,
-	0x0004, 0x3a40, 0x000a, 0x080a, 0x0003, 0x8010, 0x0008, 0x000c,
-	0x0008, 0x021b, 0x000c, 0x000a, 0x000b, 0x8074, 0x0000, 0xf080,
-	0x0000, 0x8072, 0x0000, 0x3000, 0x0008, 0x0d30, 0x0000, 0x2e4d,
-	0x0002, 0x2e4d, 0x0002, 0x0a8d, 0x000b, 0x8054, 0x0008, 0x0019,
-	0x0000, 0x000a, 0x000b, 0x8054, 0x0008, 0x0009, 0x0008, 0x000a,
-	0x000b, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x026b, 0x000b, 0x808c,
-	0x0008, 0x0000, 0x0008, 0x4447, 0x0002, 0x0ab9, 0x0003, 0xc0c0,
-	0x0001, 0x00ff, 0x0008, 0xffe0, 0x0009, 0x00ff, 0x0008, 0x0e90,
-	0x0003, 0xc1e0, 0x0001, 0xffff, 0x0008, 0x0e90, 0x0003, 0x8010,
-	0x0008, 0x0013, 0x0000, 0x021b, 0x000c, 0x8074, 0x0000, 0x0202,
-	0x0008, 0x000a, 0x000b, 0x3a40, 0x000a, 0x0eb6, 0x000b, 0x8074,
-	0x0000, 0x0200, 0x0000, 0x3d00, 0x0000, 0x3cfe, 0x0000, 0x8072,
-	0x0000, 0x8000, 0x0000, 0x43e0, 0x0001, 0x0eb4, 0x0003, 0x42fe,
-	0x0000, 0xffc0, 0x0001, 0x00ff, 0x0008, 0x00e0, 0x0009, 0x0a90,
-	0x000b, 0x0d08, 0x0008, 0x0309, 0x000b, 0x8072, 0x0000, 0x8000,
-	0x0000, 0x000a, 0x000b, 0x038d, 0x0004, 0x808c, 0x0008, 0x0001,
-	0x0000, 0x04fe, 0x0008, 0x3370, 0x0003, 0x0460, 0x0000, 0x8062,
-	0x0008, 0x0001, 0x0000, 0x8066, 0x0000, 0x0009, 0x0008, 0x46c3,
-	0x0003, 0x0004, 0x0000, 0x80c0, 0x0009, 0x00ff, 0x0008, 0x7f00,
-	0x0000, 0x80e0, 0x0001, 0x0004, 0x0000, 0x0add, 0x000b, 0x80e0,
-	0x0001, 0x0005, 0x0008, 0x0add, 0x000b, 0x80e0, 0x0001, 0x0006,
-	0x0008, 0x0add, 0x000b, 0x82c0, 0x0001, 0xff00, 0x0008, 0x7f04,
-	0x0008, 0x82e0, 0x0009, 0x0600, 0x0008, 0x0add, 0x000b, 0x82e0,
-	0x0009, 0x0500, 0x0008, 0x0add, 0x000b, 0x82e0, 0x0009, 0x0400,
-	0x0000, 0x0f70, 0x0003, 0xc4c0, 0x0009, 0x7000, 0x0000, 0xffe0,
-	0x0009, 0x1000, 0x0000, 0x0b09, 0x0003, 0x037e, 0x0004, 0x3941,
-	0x0002, 0x0ae8, 0x000b, 0x8072, 0x0000, 0x0400, 0x0000, 0x000a,
-	0x000b, 0x0460, 0x0000, 0x80fe, 0x0008, 0x002b, 0x0008, 0x7f62,
-	0x0008, 0x8066, 0x0000, 0x2209, 0x0008, 0x46ee, 0x0003, 0x11fe,
-	0x0000, 0x3304, 0x0003, 0x9180, 0x0001, 0x0002, 0x0000, 0x8060,
-	0x0000, 0x0400, 0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0609,
-	0x0008, 0x46f8, 0x000b, 0x42fe, 0x0000, 0xffc0, 0x0001, 0xff00,
-	0x0008, 0x03e0, 0x0009, 0x0f01, 0x0003, 0x8072, 0x0000, 0x0400,
-	0x0000, 0x0046, 0x0003, 0x9180, 0x0001, 0x0003, 0x0008, 0x02eb,
-	0x0003, 0x8072, 0x0000, 0x0400, 0x0000, 0x8010, 0x0008, 0x0010,
-	0x0000, 0x0361, 0x0003, 0x037e, 0x0004, 0x3941, 0x0002, 0x0b0f,
-	0x0003, 0x8072, 0x0000, 0x0400, 0x0000, 0x000a, 0x000b, 0x0346,
-	0x000c, 0x11fe, 0x0000, 0x3717, 0x0003, 0x8072, 0x0000, 0x0400,
-	0x0000, 0x8010, 0x0008, 0x000e, 0x0000, 0x0361, 0x0003, 0x8060,
-	0x0000, 0x0400, 0x0000, 0x04fe, 0x0008, 0x372c, 0x000b, 0x808c,
-	0x0008, 0x0000, 0x0008, 0x9180, 0x0001, 0x0005, 0x0008, 0x7f62,
-	0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x4722, 0x000b, 0x0060,
-	0x0008, 0x8062, 0x0008, 0x001b, 0x0008, 0x4304, 0x0008, 0x4206,
-	0x0008, 0x8066, 0x0000, 0x0412, 0x0000, 0x472a, 0x0003, 0x0343,
-	0x0003, 0x808c, 0x0008, 0x0001, 0x0000, 0x0460, 0x0000, 0x8062,
-	0x0008, 0x002b, 0x0008, 0x8066, 0x0000, 0x0609, 0x0008, 0x4733,
-	0x000b, 0x8066, 0x0000, 0x220a, 0x0008, 0x4736, 0x000b, 0x42fe,
-	0x0000, 0xffc0, 0x0001, 0xff00, 0x0008, 0x7f04, 0x0008, 0x8060,
-	0x0000, 0x0400, 0x0000, 0x9180, 0x0001, 0x0002, 0x0000, 0x7f62,
-	0x0008, 0x8066, 0x0000, 0x041a, 0x0008, 0x4742, 0x000b, 0x8072,
-	0x0000, 0x0400, 0x0000, 0x0046, 0x0003, 0x8060, 0x0000, 0x0400,
-	0x0000, 0x1362, 0x0008, 0x8066, 0x0000, 0x0411, 0x0000, 0x474b,
-	0x000b, 0x02fe, 0x0008, 0x03e0, 0x0009, 0x0f51, 0x0003, 0x0d22,
-	0x0000, 0x4000, 0x000f, 0x8280, 0x0009, 0x0002, 0x0000, 0x1380,
-	0x0001, 0x7f62, 0x0008, 0x8066, 0x0000, 0x2209, 0x0008, 0x4757,
-	0x0003, 0x0200, 0x000a, 0xffc0, 0x0001, 0x0007, 0x0000, 0x7f06,
-	0x0000, 0x1362, 0x0008, 0x8066, 0x0000, 0x060a, 0x0008, 0x475f,
-	0x000b, 0x4000, 0x000f, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x2f44,
-	0x000a, 0x2f44, 0x000a, 0x0e6b, 0x000b, 0x808a, 0x0008, 0x0003,
-	0x0008, 0x8074, 0x0000, 0xf080, 0x0000, 0x8072, 0x0000, 0x3000,
-	0x0008, 0x5b6c, 0x0003, 0x8054, 0x0008, 0x0019, 0x0000, 0x000a,
-	0x000b, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x808c, 0x0008, 0x0000,
-	0x0008, 0x8010, 0x0008, 0x0011, 0x0008, 0x021b, 0x000c, 0x42fe,
-	0x0000, 0xffc0, 0x0001, 0x00ff, 0x0008, 0x7f10, 0x0008, 0x021b,
-	0x000c, 0x4310, 0x0008, 0x027a, 0x000b, 0x3941, 0x0002, 0x0b81,
-	0x0003, 0x4000, 0x000f, 0x8072, 0x0000, 0x0404, 0x0008, 0x4000,
-	0x000f, 0x8010, 0x0008, 0x0012, 0x0008, 0x021b, 0x000c, 0x0346,
-	0x000c, 0x1110, 0x0000, 0x021b, 0x000c, 0x11fe, 0x0000, 0x3787,
-	0x0003, 0x000a, 0x000b, 0xc2c0, 0x0009, 0x00ff, 0x0008, 0x7f00,
-	0x0000, 0xc3c0, 0x0001, 0xff00, 0x0008, 0x00d0, 0x0009, 0x0bb2,
-	0x0003, 0x0d0a, 0x0000, 0x8580, 0x0001, 0x1000, 0x0000, 0x7f62,
-	0x0008, 0x8060, 0x0000, 0x0400, 0x0000, 0x8066, 0x0000, 0x0809,
-	0x0000, 0x479c, 0x000b, 0x04fe, 0x0008, 0x33ab, 0x0003, 0x0460,
-	0x0000, 0x8062, 0x0008, 0x0004, 0x0000, 0x8066, 0x0000, 0x0211,
-	0x0000, 0x47a4, 0x0003, 0x01fe, 0x0008, 0x00e0, 0x0009, 0x0fab,
-	0x0003, 0x02fe, 0x0008, 0x43e0, 0x0001, 0x0bb1, 0x0003, 0x0500,
-	0x0002, 0x7f0a, 0x0000, 0xffe0, 0x0009, 0x0800, 0x0000, 0x0f95,
-	0x000b, 0x0d08, 0x0008, 0x4000, 0x000f, 0x43fe, 0x0008, 0x3e80,
-	0x0001, 0xffc0, 0x0001, 0x7fff, 0x0000, 0x0d60, 0x0000, 0x7f62,
-	0x0008, 0x8066, 0x0000, 0x0809, 0x0000, 0x47ba, 0x0003, 0x8060,
-	0x0000, 0x0400, 0x0000, 0x84c0, 0x0001, 0xff00, 0x0008, 0x7f60,
+	0x0000, 0x0609, 0x0008, 0x46f8, 0x000b, 0x42fe, 0x0000, 0xffc0,
+	0x0001, 0xff00, 0x0008, 0x03e0, 0x0009, 0x0f01, 0x0003, 0x8072,
+	0x0000, 0x0400, 0x0000, 0x0046, 0x0003, 0x9180, 0x0001, 0x0003,
+	0x0008, 0x02eb, 0x0003, 0x8072, 0x0000, 0x0400, 0x0000, 0x8010,
+	0x0008, 0x0010, 0x0000, 0x0361, 0x0003, 0x037e, 0x0004, 0x3941,
+	0x0002, 0x0b0f, 0x0003, 0x8072, 0x0000, 0x0400, 0x0000, 0x000a,
+	0x000b, 0x0346, 0x000c, 0x11fe, 0x0000, 0x3717, 0x0003, 0x8072,
+	0x0000, 0x0400, 0x0000, 0x8010, 0x0008, 0x000e, 0x0000, 0x0361,
+	0x0003, 0x8060, 0x0000, 0x0400, 0x0000, 0x04fe, 0x0008, 0x372c,
+	0x000b, 0x808c, 0x0008, 0x0000, 0x0008, 0x9180, 0x0001, 0x0005,
+	0x0008, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x4722,
+	0x000b, 0x0060, 0x0008, 0x8062, 0x0008, 0x001b, 0x0008, 0x4304,
+	0x0008, 0x4206, 0x0008, 0x8066, 0x0000, 0x0412, 0x0000, 0x472a,
+	0x0003, 0x0343, 0x0003, 0x808c, 0x0008, 0x0001, 0x0000, 0x0460,
+	0x0000, 0x8062, 0x0008, 0x002b, 0x0008, 0x8066, 0x0000, 0x0609,
+	0x0008, 0x4733, 0x000b, 0x8066, 0x0000, 0x220a, 0x0008, 0x4736,
+	0x000b, 0x42fe, 0x0000, 0xffc0, 0x0001, 0xff00, 0x0008, 0x7f04,
+	0x0008, 0x8060, 0x0000, 0x0400, 0x0000, 0x9180, 0x0001, 0x0002,
+	0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x041a, 0x0008, 0x4742,
+	0x000b, 0x8072, 0x0000, 0x0400, 0x0000, 0x0046, 0x0003, 0x8060,
+	0x0000, 0x0400, 0x0000, 0x1362, 0x0008, 0x8066, 0x0000, 0x0411,
+	0x0000, 0x474b, 0x000b, 0x02fe, 0x0008, 0x03e0, 0x0009, 0x0f51,
+	0x0003, 0x0d22, 0x0000, 0x4000, 0x000f, 0x8280, 0x0009, 0x0002,
+	0x0000, 0x1380, 0x0001, 0x7f62, 0x0008, 0x8066, 0x0000, 0x2209,
+	0x0008, 0x4757, 0x0003, 0x0200, 0x000a, 0xffc0, 0x0001, 0x0007,
+	0x0000, 0x7f06, 0x0000, 0x1362, 0x0008, 0x8066, 0x0000, 0x060a,
+	0x0008, 0x475f, 0x000b, 0x4000, 0x000f, 0x3a44, 0x0002, 0x0c0a,
+	0x000b, 0x2f44, 0x000a, 0x2f44, 0x000a, 0x0e6b, 0x000b, 0x808a,
+	0x0008, 0x0003, 0x0008, 0x8074, 0x0000, 0xf080, 0x0000, 0x8072,
+	0x0000, 0x3000, 0x0008, 0x5b6c, 0x0003, 0x8054, 0x0008, 0x0019,
+	0x0000, 0x000a, 0x000b, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x808c,
+	0x0008, 0x0000, 0x0008, 0x8010, 0x0008, 0x0011, 0x0008, 0x021b,
+	0x000c, 0x42fe, 0x0000, 0xffc0, 0x0001, 0x00ff, 0x0008, 0x7f10,
+	0x0008, 0x021b, 0x000c, 0x4310, 0x0008, 0x027a, 0x000b, 0x3941,
+	0x0002, 0x0b81, 0x0003, 0x4000, 0x000f, 0x8072, 0x0000, 0x0404,
+	0x0008, 0x4000, 0x000f, 0x8010, 0x0008, 0x0012, 0x0008, 0x021b,
+	0x000c, 0x0346, 0x000c, 0x1110, 0x0000, 0x021b, 0x000c, 0x11fe,
+	0x0000, 0x3787, 0x0003, 0x000a, 0x000b, 0xc2c0, 0x0009, 0x00ff,
+	0x0008, 0x7f00, 0x0000, 0xc3c0, 0x0001, 0xff00, 0x0008, 0x00d0,
+	0x0009, 0x0bb2, 0x0003, 0x0d0a, 0x0000, 0x8580, 0x0001, 0x1000,
+	0x0000, 0x7f62, 0x0008, 0x8060, 0x0000, 0x0400, 0x0000, 0x8066,
+	0x0000, 0x0809, 0x0000, 0x479c, 0x000b, 0x04fe, 0x0008, 0x33ab,
+	0x0003, 0x0460, 0x0000, 0x8062, 0x0008, 0x0004, 0x0000, 0x8066,
+	0x0000, 0x0211, 0x0000, 0x47a4, 0x0003, 0x01fe, 0x0008, 0x00e0,
+	0x0009, 0x0fab, 0x0003, 0x02fe, 0x0008, 0x43e0, 0x0001, 0x0bb1,
+	0x0003, 0x0500, 0x0002, 0x7f0a, 0x0000, 0xffe0, 0x0009, 0x0800,
+	0x0000, 0x0f95, 0x000b, 0x0d08, 0x0008, 0x4000, 0x000f, 0x43fe,
+	0x0008, 0x3e80, 0x0001, 0xffc0, 0x0001, 0x7fff, 0x0000, 0x0d60,
+	0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0809, 0x0000, 0x47ba,
+	0x0003, 0x8060, 0x0000, 0x0400, 0x0000, 0x84c0, 0x0001, 0xff00,
+	0x0008, 0x7f60, 0x000a, 0x7f60, 0x000a, 0x7f60, 0x000a, 0x7f60,
 	0x000a, 0x7f60, 0x000a, 0x7f60, 0x000a, 0x7f60, 0x000a, 0x7f60,
-	0x000a, 0x7f60, 0x000a, 0x7f60, 0x000a, 0x7f60, 0x000a, 0xff80,
-	0x0009, 0x1000, 0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0809,
-	0x0000, 0x47cc, 0x000b, 0x4000, 0x000f, 0x5ff4, 0xebed, 0x0001,
-	0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100,
-	0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0x4464
+	0x000a, 0xff80, 0x0009, 0x1000, 0x0000, 0x7f62, 0x0008, 0x8066,
+	0x0000, 0x0809, 0x0000, 0x47cc, 0x000b, 0x4000, 0x000f, 0x5ff4,
+	0xebed, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040,
+	0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000,
+	0x8000, 0x74b9
 };
 #ifdef UNIQUE_FW_NAME
-unsigned short fw2300ipx_length01 = 0xe9e8;
+unsigned short fw2300ipx_length01 = 0xea02;
 #else
-unsigned short risc_code_length01 = 0xe9e8;
+unsigned short risc_code_length01 = 0xea02;
 #endif
 
diff -Nru a/drivers/scsi/qla2xxx/ql2322_fw.c b/drivers/scsi/qla2xxx/ql2322_fw.c
--- a/drivers/scsi/qla2xxx/ql2322_fw.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/qla2xxx/ql2322_fw.c	2004-12-24 13:36:16 -08:00
@@ -18,25 +18,25 @@
  *************************************************************************/
 
 /*
- *	Firmware Version 3.02.30 (07:55 Jun 16, 2004)
+ *	Firmware Version 3.03.02 (16:54 Aug 10, 2004)
  */
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw2322ipx_version = 3*1024+2;
+unsigned short fw2322ipx_version = 3*1024+3;
 #else
-unsigned short risc_code_version = 3*1024+2;
+unsigned short risc_code_version = 3*1024+3;
 #endif
 
 #ifdef UNIQUE_FW_NAME
-unsigned char fw2322ipx_version_str[] = {3, 2,30};
+unsigned char fw2322ipx_version_str[] = {3, 3, 2};
 #else
-unsigned char firmware_version[] = {3, 2,30};
+unsigned char firmware_version[] = {3, 3, 2};
 #endif
 
 #ifdef UNIQUE_FW_NAME
-#define fw2322ipx_VERSION_STRING "3.02.30"
+#define fw2322ipx_VERSION_STRING "3.03.02"
 #else
-#define FW_VERSION_STRING "3.02.30"
+#define FW_VERSION_STRING "3.03.02"
 #endif
 
 #ifdef UNIQUE_FW_NAME
@@ -50,12 +50,12 @@
 #else
 unsigned short risc_code01[] = { 
 #endif
-	0x0470, 0x0000, 0x0000, 0xdf52, 0x0000, 0x0003, 0x0002, 0x001e,
+	0x0470, 0x0000, 0x0000, 0xdf8f, 0x0000, 0x0003, 0x0003, 0x0002,
 	0x0137, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2032, 0x3030,
 	0x3120, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
 	0x5449, 0x4f4e, 0x2049, 0x5350, 0x3233, 0x3030, 0x2046, 0x6972,
 	0x6d77, 0x6172, 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030,
-	0x332e, 0x3032, 0x2e33, 0x3020, 0x2020, 0x2020, 0x2400, 0x20a9,
+	0x332e, 0x3033, 0x2e30, 0x3220, 0x2020, 0x2020, 0x2400, 0x20a9,
 	0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2200, 0x20a9, 0x000f,
 	0x2001, 0x0000, 0x400f, 0x2091, 0x2400, 0x20a9, 0x000f, 0x2001,
 	0x0000, 0x400f, 0x2091, 0x2600, 0x20a9, 0x000f, 0x2001, 0x0000,
@@ -64,11 +64,11 @@
 	0x2c00, 0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2e00,
 	0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2000, 0x2001,
 	0x0000, 0x20c1, 0x0004, 0x20c9, 0x1cff, 0x2059, 0x0000, 0x2b78,
-	0x7883, 0x0004, 0x2089, 0x2ac3, 0x2051, 0x1800, 0x2a70, 0x20e1,
-	0x0001, 0x20e9, 0x0001, 0x2009, 0x0000, 0x080c, 0x0e55, 0x00f6,
-	0x7888, 0x9005, 0x11f8, 0x2061, 0xc000, 0x080c, 0x2067, 0x1170,
-	0x2079, 0x0300, 0x080c, 0x207d, 0x2061, 0xe000, 0x080c, 0x2067,
-	0x1128, 0x2079, 0x0380, 0x080c, 0x207d, 0x0060, 0x00fe, 0x7883,
+	0x7883, 0x0004, 0x2089, 0x2ae3, 0x2051, 0x1800, 0x2a70, 0x20e1,
+	0x0001, 0x20e9, 0x0001, 0x2009, 0x0000, 0x080c, 0x0e62, 0x00f6,
+	0x7888, 0x9005, 0x11f8, 0x2061, 0xc000, 0x080c, 0x207f, 0x1170,
+	0x2079, 0x0300, 0x080c, 0x2095, 0x2061, 0xe000, 0x080c, 0x207f,
+	0x1128, 0x2079, 0x0380, 0x080c, 0x2095, 0x0060, 0x00fe, 0x7883,
 	0x4010, 0x7837, 0x4010, 0x7833, 0x0010, 0x2091, 0x5000, 0x2091,
 	0x4080, 0x0cf8, 0x00fe, 0x2029, 0x5600, 0x2031, 0xffff, 0x2039,
 	0x55dc, 0x2021, 0x0200, 0x20e9, 0x0001, 0x20a1, 0x0000, 0x20a9,
@@ -82,146 +82,146 @@
 	0x20a8, 0x900e, 0x4104, 0x2009, 0x1800, 0x810d, 0x810d, 0x810d,
 	0x810d, 0x810d, 0x918c, 0x001f, 0x2001, 0x0001, 0x9112, 0x20e9,
 	0x0001, 0x20a1, 0x0800, 0x900e, 0x20a9, 0x0800, 0x4104, 0x8211,
-	0x1dd8, 0x080c, 0x0f52, 0x080c, 0x6032, 0x080c, 0xab75, 0x080c,
-	0x1109, 0x080c, 0x1333, 0x080c, 0x1bbd, 0x080c, 0x916f, 0x080c,
-	0x0d0f, 0x080c, 0x108e, 0x080c, 0x3468, 0x080c, 0x77e0, 0x080c,
-	0x6a8e, 0x080c, 0x88e7, 0x080c, 0x8548, 0x080c, 0x2258, 0x080c,
-	0x7eb5, 0x080c, 0x2096, 0x080c, 0x21d4, 0x080c, 0x224d, 0x2091,
+	0x1dd8, 0x080c, 0x0f5f, 0x080c, 0x6052, 0x080c, 0xab86, 0x080c,
+	0x1116, 0x080c, 0x1340, 0x080c, 0x1bd5, 0x080c, 0x91a8, 0x080c,
+	0x0d0f, 0x080c, 0x109b, 0x080c, 0x3488, 0x080c, 0x7803, 0x080c,
+	0x6ab2, 0x080c, 0x891b, 0x080c, 0x857c, 0x080c, 0x2270, 0x080c,
+	0x7ed9, 0x080c, 0x20ae, 0x080c, 0x21ec, 0x080c, 0x2265, 0x2091,
 	0x3009, 0x7883, 0x0000, 0x1004, 0x0943, 0x7880, 0x9086, 0x0002,
 	0x1190, 0x7883, 0x4000, 0x7837, 0x4000, 0x7833, 0x0010, 0x0e04,
 	0x0937, 0x2091, 0x5000, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
-	0xd084, 0x190c, 0x11e1, 0x2071, 0x1800, 0x7003, 0x0000, 0x780c,
+	0xd084, 0x190c, 0x11ee, 0x2071, 0x1800, 0x7003, 0x0000, 0x780c,
 	0x9084, 0x0030, 0x9086, 0x0000, 0x190c, 0x0d7d, 0x2071, 0x1800,
-	0x7000, 0x908e, 0x0003, 0x1168, 0x080c, 0x4bce, 0x080c, 0x348f,
-	0x080c, 0x7848, 0x080c, 0x6fc6, 0x080c, 0x89c5, 0x080c, 0x8571,
+	0x7000, 0x908e, 0x0003, 0x1168, 0x080c, 0x4bee, 0x080c, 0x34af,
+	0x080c, 0x786b, 0x080c, 0x6fea, 0x080c, 0x89f9, 0x080c, 0x85a5,
 	0x0c68, 0x000b, 0x0c88, 0x096d, 0x096e, 0x0b09, 0x096b, 0x0bc3,
 	0x0d0e, 0x0d0e, 0x0d0e, 0x080c, 0x0d7d, 0x0005, 0x0126, 0x00f6,
 	0x2091, 0x8000, 0x7000, 0x9086, 0x0001, 0x1904, 0x0adc, 0x080c,
-	0x0ea5, 0x080c, 0x74c8, 0x0150, 0x080c, 0x74eb, 0x15b0, 0x2079,
-	0x0100, 0x7828, 0x9085, 0x1800, 0x782a, 0x0478, 0x080c, 0x73f9,
+	0x0eb2, 0x080c, 0x74ec, 0x0150, 0x080c, 0x750f, 0x15b0, 0x2079,
+	0x0100, 0x7828, 0x9085, 0x1800, 0x782a, 0x0478, 0x080c, 0x741d,
 	0x7000, 0x9086, 0x0001, 0x1904, 0x0adc, 0x7098, 0x9086, 0x0028,
-	0x1904, 0x0adc, 0x080c, 0x8540, 0x080c, 0x8532, 0x2001, 0x0161,
-	0x2003, 0x0001, 0x2079, 0x0100, 0x2011, 0xffff, 0x080c, 0x2a63,
-	0x7a28, 0x9295, 0x5e2c, 0x7a2a, 0x2011, 0x733e, 0x080c, 0x861d,
-	0x2011, 0x7331, 0x080c, 0x8729, 0x2011, 0x5e89, 0x080c, 0x861d,
-	0x2011, 0x8030, 0x901e, 0x7396, 0x04d0, 0x080c, 0x5736, 0x2079,
-	0x0100, 0x7844, 0x9005, 0x1904, 0x0adc, 0x2011, 0x5e89, 0x080c,
-	0x861d, 0x2011, 0x733e, 0x080c, 0x861d, 0x2011, 0x7331, 0x080c,
-	0x8729, 0x2001, 0x0265, 0x2001, 0x0205, 0x2003, 0x0000, 0x7840,
+	0x1904, 0x0adc, 0x080c, 0x8574, 0x080c, 0x8566, 0x2001, 0x0161,
+	0x2003, 0x0001, 0x2079, 0x0100, 0x2011, 0xffff, 0x080c, 0x2a83,
+	0x7a28, 0x9295, 0x5e2c, 0x7a2a, 0x2011, 0x7362, 0x080c, 0x8651,
+	0x2011, 0x7355, 0x080c, 0x875d, 0x2011, 0x5ea9, 0x080c, 0x8651,
+	0x2011, 0x8030, 0x901e, 0x7396, 0x04d0, 0x080c, 0x5756, 0x2079,
+	0x0100, 0x7844, 0x9005, 0x1904, 0x0adc, 0x2011, 0x5ea9, 0x080c,
+	0x8651, 0x2011, 0x7362, 0x080c, 0x8651, 0x2011, 0x7355, 0x080c,
+	0x875d, 0x2001, 0x0265, 0x2001, 0x0205, 0x2003, 0x0000, 0x7840,
 	0x9084, 0xfffb, 0x7842, 0x2001, 0x19a5, 0x2004, 0x9005, 0x1140,
-	0x00c6, 0x2061, 0x0100, 0x080c, 0x5fda, 0x00ce, 0x0804, 0x0adc,
-	0x780f, 0x006b, 0x7a28, 0x080c, 0x74d0, 0x0118, 0x9295, 0x5e2c,
+	0x00c6, 0x2061, 0x0100, 0x080c, 0x5ffa, 0x00ce, 0x0804, 0x0adc,
+	0x780f, 0x006b, 0x7a28, 0x080c, 0x74f4, 0x0118, 0x9295, 0x5e2c,
 	0x0010, 0x9295, 0x402c, 0x7a2a, 0x2011, 0x8010, 0x73d8, 0x2001,
-	0x19a6, 0x2003, 0x0001, 0x080c, 0x292f, 0x080c, 0x4b09, 0x7248,
+	0x19a6, 0x2003, 0x0001, 0x080c, 0x294b, 0x080c, 0x4b29, 0x7248,
 	0xc284, 0x724a, 0x2001, 0x180c, 0x200c, 0xc1ac, 0xc1cc, 0x2102,
-	0x2001, 0x0390, 0x2003, 0x0400, 0x080c, 0xa888, 0x080c, 0xa055,
-	0x2011, 0x0004, 0x080c, 0xc842, 0x080c, 0xa8a4, 0x080c, 0x6916,
-	0x080c, 0x74c8, 0x1120, 0x080c, 0x2990, 0x0600, 0x0420, 0x080c,
-	0x5fe1, 0x0140, 0x7097, 0x0001, 0x70d3, 0x0000, 0x080c, 0x5903,
-	0x0804, 0x0adc, 0x080c, 0x56d5, 0xd094, 0x01a8, 0x2001, 0x0390,
+	0x2001, 0x0390, 0x2003, 0x0400, 0x080c, 0xa899, 0x080c, 0xa08e,
+	0x2011, 0x0004, 0x080c, 0xc875, 0x080c, 0xa8b5, 0x080c, 0x693a,
+	0x080c, 0x74ec, 0x1120, 0x080c, 0x29ac, 0x0600, 0x0420, 0x080c,
+	0x6001, 0x0140, 0x7097, 0x0001, 0x70d3, 0x0000, 0x080c, 0x5923,
+	0x0804, 0x0adc, 0x080c, 0x56f5, 0xd094, 0x01a8, 0x2001, 0x0390,
 	0x2003, 0x0404, 0x2011, 0x180c, 0x2204, 0xc0cd, 0x2012, 0x080c,
-	0x56d9, 0xd0d4, 0x1118, 0x080c, 0x2990, 0x1270, 0x2011, 0x180c,
-	0x2204, 0xc0bc, 0x00a8, 0x080c, 0x56d9, 0xd0d4, 0x1db8, 0x2011,
+	0x56f9, 0xd0d4, 0x1118, 0x080c, 0x29ac, 0x1270, 0x2011, 0x180c,
+	0x2204, 0xc0bc, 0x00a8, 0x080c, 0x56f9, 0xd0d4, 0x1db8, 0x2011,
 	0x180c, 0x2204, 0xc0bd, 0x0060, 0x2011, 0x180c, 0x2204, 0xc0bd,
-	0x2012, 0x080c, 0x6a62, 0x1128, 0xd0a4, 0x0118, 0x2204, 0xc0fd,
-	0x2012, 0x080c, 0x6a28, 0x0120, 0x7a0c, 0xc2b4, 0x7a0e, 0x00a8,
-	0x707f, 0x0000, 0x080c, 0x74c8, 0x1130, 0x70b0, 0x9005, 0x1168,
-	0x080c, 0xcc9e, 0x0050, 0x080c, 0xcc9e, 0x70dc, 0xd09c, 0x1128,
-	0x70b0, 0x9005, 0x0110, 0x080c, 0x5fb7, 0x70e7, 0x0000, 0x70e3,
-	0x0000, 0x70a7, 0x0000, 0x080c, 0x2998, 0x0228, 0x2011, 0x0101,
-	0x2204, 0xc0c4, 0x2012, 0x72dc, 0x080c, 0x74c8, 0x1178, 0x9016,
-	0x0016, 0x080c, 0x272c, 0x2019, 0x196c, 0x211a, 0x001e, 0x705f,
+	0x2012, 0x080c, 0x6a86, 0x1128, 0xd0a4, 0x0118, 0x2204, 0xc0fd,
+	0x2012, 0x080c, 0x6a4c, 0x0120, 0x7a0c, 0xc2b4, 0x7a0e, 0x00a8,
+	0x707f, 0x0000, 0x080c, 0x74ec, 0x1130, 0x70b0, 0x9005, 0x1168,
+	0x080c, 0xccd1, 0x0050, 0x080c, 0xccd1, 0x70dc, 0xd09c, 0x1128,
+	0x70b0, 0x9005, 0x0110, 0x080c, 0x5fd7, 0x70e7, 0x0000, 0x70e3,
+	0x0000, 0x70a7, 0x0000, 0x080c, 0x29b4, 0x0228, 0x2011, 0x0101,
+	0x2204, 0xc0c4, 0x2012, 0x72dc, 0x080c, 0x74ec, 0x1178, 0x9016,
+	0x0016, 0x080c, 0x2748, 0x2019, 0x196c, 0x211a, 0x001e, 0x705f,
 	0xffff, 0x7063, 0x00ef, 0x7083, 0x0000, 0x0020, 0x2019, 0x196c,
 	0x201b, 0x0000, 0x2079, 0x1847, 0x7804, 0xd0ac, 0x0108, 0xc295,
-	0x72de, 0x080c, 0x74c8, 0x0118, 0x9296, 0x0004, 0x0518, 0x2011,
-	0x0001, 0x080c, 0xc842, 0x70ab, 0x0000, 0x70af, 0xffff, 0x7003,
-	0x0002, 0x00fe, 0x080c, 0x2fc0, 0x080c, 0xa888, 0x2011, 0x0005,
-	0x080c, 0xa1b1, 0x080c, 0xa8a4, 0x080c, 0x74c8, 0x0148, 0x00c6,
-	0x2061, 0x0100, 0x0016, 0x080c, 0x272c, 0x61e2, 0x001e, 0x00ce,
+	0x72de, 0x080c, 0x74ec, 0x0118, 0x9296, 0x0004, 0x0518, 0x2011,
+	0x0001, 0x080c, 0xc875, 0x70ab, 0x0000, 0x70af, 0xffff, 0x7003,
+	0x0002, 0x00fe, 0x080c, 0x2fe0, 0x080c, 0xa899, 0x2011, 0x0005,
+	0x080c, 0xa1be, 0x080c, 0xa8b5, 0x080c, 0x74ec, 0x0148, 0x00c6,
+	0x2061, 0x0100, 0x0016, 0x080c, 0x2748, 0x61e2, 0x001e, 0x00ce,
 	0x012e, 0x00e0, 0x70ab, 0x0000, 0x70af, 0xffff, 0x7003, 0x0002,
-	0x080c, 0xa888, 0x2011, 0x0005, 0x080c, 0xa1b1, 0x080c, 0xa8a4,
-	0x080c, 0x74c8, 0x0148, 0x00c6, 0x2061, 0x0100, 0x0016, 0x080c,
-	0x272c, 0x61e2, 0x001e, 0x00ce, 0x00fe, 0x012e, 0x0005, 0x00c6,
-	0x00b6, 0x080c, 0x74c8, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9,
-	0x0782, 0x080c, 0x74c8, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e,
+	0x080c, 0xa899, 0x2011, 0x0005, 0x080c, 0xa1be, 0x080c, 0xa8b5,
+	0x080c, 0x74ec, 0x0148, 0x00c6, 0x2061, 0x0100, 0x0016, 0x080c,
+	0x2748, 0x61e2, 0x001e, 0x00ce, 0x00fe, 0x012e, 0x0005, 0x00c6,
+	0x00b6, 0x080c, 0x74ec, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9,
+	0x0782, 0x080c, 0x74ec, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e,
 	0x86ff, 0x0138, 0x9180, 0x1000, 0x2004, 0x905d, 0x0110, 0xb800,
-	0xd0bc, 0x090c, 0x32f8, 0x8108, 0x1f04, 0x0af0, 0x707f, 0x0000,
+	0xd0bc, 0x090c, 0x3318, 0x8108, 0x1f04, 0x0af0, 0x707f, 0x0000,
 	0x7080, 0x9084, 0x00ff, 0x7082, 0x70b3, 0x0000, 0x00be, 0x00ce,
 	0x0005, 0x00b6, 0x0126, 0x2091, 0x8000, 0x7000, 0x9086, 0x0002,
-	0x1904, 0x0bc0, 0x70ac, 0x9086, 0xffff, 0x0120, 0x080c, 0x2fc0,
+	0x1904, 0x0bc0, 0x70ac, 0x9086, 0xffff, 0x0120, 0x080c, 0x2fe0,
 	0x0804, 0x0bc0, 0x70dc, 0xd0ac, 0x1110, 0xd09c, 0x0538, 0xd084,
 	0x0528, 0x0006, 0x2001, 0x0103, 0x2003, 0x002b, 0x000e, 0xd08c,
-	0x01e8, 0x080c, 0x3361, 0x11b0, 0x70e0, 0x9086, 0xffff, 0x0190,
-	0x080c, 0x3155, 0x70dc, 0xd094, 0x1904, 0x0bc0, 0x2011, 0x0001,
-	0x080c, 0xcf51, 0x0110, 0x2011, 0x0003, 0x901e, 0x080c, 0x318f,
+	0x01e8, 0x080c, 0x3381, 0x11b0, 0x70e0, 0x9086, 0xffff, 0x0190,
+	0x080c, 0x3175, 0x70dc, 0xd094, 0x1904, 0x0bc0, 0x2011, 0x0001,
+	0x080c, 0xcf84, 0x0110, 0x2011, 0x0003, 0x901e, 0x080c, 0x31af,
 	0x0804, 0x0bc0, 0x70e4, 0x9005, 0x1904, 0x0bc0, 0x70a8, 0x9005,
 	0x1904, 0x0bc0, 0x70dc, 0xd0a4, 0x0118, 0xd0b4, 0x0904, 0x0bc0,
-	0x080c, 0x6a28, 0x1904, 0x0bc0, 0x080c, 0x6a7b, 0x1904, 0x0bc0,
-	0x080c, 0x6a62, 0x01c0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e,
-	0x0016, 0x080c, 0x6620, 0x1118, 0xb800, 0xd0ec, 0x1138, 0x001e,
+	0x080c, 0x6a4c, 0x1904, 0x0bc0, 0x080c, 0x6a9f, 0x1904, 0x0bc0,
+	0x080c, 0x6a86, 0x01c0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e,
+	0x0016, 0x080c, 0x6644, 0x1118, 0xb800, 0xd0ec, 0x1138, 0x001e,
 	0x8108, 0x1f04, 0x0b60, 0x00ce, 0x015e, 0x0028, 0x001e, 0x00ce,
 	0x015e, 0x0804, 0x0bc0, 0x0006, 0x2001, 0x0103, 0x2003, 0x002b,
-	0x000e, 0x2011, 0x19b2, 0x080c, 0x0fc2, 0x2011, 0x19cc, 0x080c,
-	0x0fc2, 0x7030, 0xc08c, 0x7032, 0x7003, 0x0003, 0x70af, 0xffff,
-	0x080c, 0x0e79, 0x9006, 0x080c, 0x25b9, 0x080c, 0x3361, 0x0118,
-	0x080c, 0x4ca6, 0x0050, 0x0036, 0x0046, 0x2019, 0xffff, 0x2021,
-	0x0006, 0x080c, 0x4cc0, 0x004e, 0x003e, 0x00f6, 0x2079, 0x0100,
-	0x080c, 0x74eb, 0x0150, 0x080c, 0x74c8, 0x7828, 0x0118, 0x9084,
-	0xe1ff, 0x0010, 0x9084, 0xffdf, 0x782a, 0x00fe, 0x080c, 0xa888,
+	0x000e, 0x2011, 0x19b2, 0x080c, 0x0fcf, 0x2011, 0x19cc, 0x080c,
+	0x0fcf, 0x7030, 0xc08c, 0x7032, 0x7003, 0x0003, 0x70af, 0xffff,
+	0x080c, 0x0e86, 0x9006, 0x080c, 0x25d5, 0x080c, 0x3381, 0x0118,
+	0x080c, 0x4cc6, 0x0050, 0x0036, 0x0046, 0x2019, 0xffff, 0x2021,
+	0x0006, 0x080c, 0x4ce0, 0x004e, 0x003e, 0x00f6, 0x2079, 0x0100,
+	0x080c, 0x750f, 0x0150, 0x080c, 0x74ec, 0x7828, 0x0118, 0x9084,
+	0xe1ff, 0x0010, 0x9084, 0xffdf, 0x782a, 0x00fe, 0x080c, 0xa899,
 	0x2001, 0x19e7, 0x2004, 0x9086, 0x0005, 0x1120, 0x2011, 0x0000,
-	0x080c, 0xa1b1, 0x2011, 0x0000, 0x080c, 0xa1bb, 0x080c, 0xa8a4,
+	0x080c, 0xa1be, 0x2011, 0x0000, 0x080c, 0xa1c8, 0x080c, 0xa8b5,
 	0x012e, 0x00be, 0x0005, 0x0016, 0x0026, 0x0046, 0x00f6, 0x0126,
 	0x2091, 0x8000, 0x2079, 0x0100, 0x7904, 0x918c, 0xfffd, 0x7906,
-	0x2009, 0x00f7, 0x080c, 0x5fa0, 0x7940, 0x918c, 0x0010, 0x7942,
-	0x7924, 0xd1b4, 0x0120, 0x2011, 0x0040, 0x080c, 0x2a63, 0xd19c,
-	0x0120, 0x2011, 0x0008, 0x080c, 0x2a63, 0x0006, 0x0036, 0x0156,
-	0x0000, 0x2001, 0x19a6, 0x2004, 0x9005, 0x1518, 0x080c, 0x29f7,
-	0x1148, 0x2001, 0x0001, 0x080c, 0x295e, 0x2001, 0x0001, 0x080c,
-	0x2941, 0x00b8, 0x080c, 0x29ff, 0x1138, 0x9006, 0x080c, 0x295e,
-	0x9006, 0x080c, 0x2941, 0x0068, 0x080c, 0x2a07, 0x1d50, 0x2001,
-	0x1997, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c, 0x2758, 0x0804,
-	0x0cc1, 0x080c, 0x2a86, 0x080c, 0x2ab9, 0x20a9, 0x003a, 0x1d04,
-	0x0c17, 0x080c, 0x8709, 0x1f04, 0x0c17, 0x080c, 0x74d9, 0x0148,
-	0x080c, 0x74eb, 0x1118, 0x080c, 0x77db, 0x0050, 0x080c, 0x74d0,
-	0x0dd0, 0x080c, 0x77d6, 0x080c, 0x77cc, 0x080c, 0x73f9, 0x0020,
-	0x2009, 0x00f8, 0x080c, 0x5fa0, 0x7850, 0xc0e5, 0x7852, 0x080c,
-	0x74c8, 0x0120, 0x7843, 0x0090, 0x7843, 0x0010, 0x2021, 0xe678,
-	0x2019, 0xea60, 0x0d0c, 0x8709, 0x7820, 0xd09c, 0x15a0, 0x080c,
-	0x74c8, 0x0904, 0x0ca3, 0x7824, 0xd0ac, 0x1904, 0x0cc6, 0x080c,
-	0x74eb, 0x1548, 0x0046, 0x2021, 0x0320, 0x8421, 0x1df0, 0x004e,
-	0x2011, 0x1800, 0x080c, 0x2a63, 0x080c, 0x2a0f, 0x7824, 0x9084,
+	0x2009, 0x00f7, 0x080c, 0x5fc0, 0x7940, 0x918c, 0x0010, 0x7942,
+	0x7924, 0xd1b4, 0x0120, 0x2011, 0x0040, 0x080c, 0x2a83, 0xd19c,
+	0x0120, 0x2011, 0x0008, 0x080c, 0x2a83, 0x0006, 0x0036, 0x0156,
+	0x0000, 0x2001, 0x19a6, 0x2004, 0x9005, 0x1518, 0x080c, 0x2a17,
+	0x1148, 0x2001, 0x0001, 0x080c, 0x297a, 0x2001, 0x0001, 0x080c,
+	0x295d, 0x00b8, 0x080c, 0x2a1f, 0x1138, 0x9006, 0x080c, 0x297a,
+	0x9006, 0x080c, 0x295d, 0x0068, 0x080c, 0x2a27, 0x1d50, 0x2001,
+	0x1997, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c, 0x2774, 0x0804,
+	0x0cc1, 0x080c, 0x2aa6, 0x080c, 0x2ad9, 0x20a9, 0x003a, 0x1d04,
+	0x0c17, 0x080c, 0x873d, 0x1f04, 0x0c17, 0x080c, 0x74fd, 0x0148,
+	0x080c, 0x750f, 0x1118, 0x080c, 0x77fe, 0x0050, 0x080c, 0x74f4,
+	0x0dd0, 0x080c, 0x77f9, 0x080c, 0x77ef, 0x080c, 0x741d, 0x0020,
+	0x2009, 0x00f8, 0x080c, 0x5fc0, 0x7850, 0xc0e5, 0x7852, 0x080c,
+	0x74ec, 0x0120, 0x7843, 0x0090, 0x7843, 0x0010, 0x2021, 0xe678,
+	0x2019, 0xea60, 0x0d0c, 0x873d, 0x7820, 0xd09c, 0x15a0, 0x080c,
+	0x74ec, 0x0904, 0x0ca3, 0x7824, 0xd0ac, 0x1904, 0x0cc6, 0x080c,
+	0x750f, 0x1548, 0x0046, 0x2021, 0x0320, 0x8421, 0x1df0, 0x004e,
+	0x2011, 0x1800, 0x080c, 0x2a83, 0x080c, 0x2a2f, 0x7824, 0x9084,
 	0x1800, 0x1168, 0x9484, 0x0fff, 0x1140, 0x2001, 0x1810, 0x2004,
 	0x9084, 0x9000, 0x0110, 0x080c, 0x0ce9, 0x8421, 0x1160, 0x1d04,
-	0x0c73, 0x080c, 0x8709, 0x080c, 0x77d6, 0x080c, 0x77cc, 0x7003,
+	0x0c73, 0x080c, 0x873d, 0x080c, 0x77f9, 0x080c, 0x77ef, 0x7003,
 	0x0001, 0x0804, 0x0cc6, 0x8319, 0x1928, 0x2001, 0x1810, 0x2004,
 	0x9084, 0x9000, 0x0110, 0x080c, 0x0ce9, 0x1d04, 0x0c89, 0x080c,
-	0x8709, 0x2009, 0x199a, 0x2104, 0x9005, 0x0118, 0x8001, 0x200a,
-	0x1188, 0x200b, 0x000a, 0x2011, 0x0048, 0x080c, 0x2a63, 0x20a9,
-	0x0002, 0x080c, 0x29f0, 0x7924, 0x080c, 0x2a0f, 0xd19c, 0x0110,
-	0x080c, 0x292f, 0x00f0, 0x080c, 0x74d9, 0x1140, 0x94a2, 0x03e8,
-	0x1128, 0x080c, 0x749c, 0x7003, 0x0001, 0x00c0, 0x2011, 0x1800,
-	0x080c, 0x2a63, 0x080c, 0x2a0f, 0x7824, 0x080c, 0x74e2, 0x0110,
+	0x873d, 0x2009, 0x199a, 0x2104, 0x9005, 0x0118, 0x8001, 0x200a,
+	0x1188, 0x200b, 0x000a, 0x2011, 0x0048, 0x080c, 0x2a83, 0x20a9,
+	0x0002, 0x080c, 0x2a10, 0x7924, 0x080c, 0x2a2f, 0xd19c, 0x0110,
+	0x080c, 0x294b, 0x00f0, 0x080c, 0x74fd, 0x1140, 0x94a2, 0x03e8,
+	0x1128, 0x080c, 0x74c0, 0x7003, 0x0001, 0x00c0, 0x2011, 0x1800,
+	0x080c, 0x2a83, 0x080c, 0x2a2f, 0x7824, 0x080c, 0x7506, 0x0110,
 	0xd0ac, 0x1160, 0x9084, 0x1800, 0x0904, 0x0c7b, 0x7003, 0x0001,
-	0x0028, 0x2001, 0x0001, 0x080c, 0x25b9, 0x00a0, 0x7850, 0xc0e4,
+	0x0028, 0x2001, 0x0001, 0x080c, 0x25d5, 0x00a0, 0x7850, 0xc0e4,
 	0x7852, 0x2009, 0x180c, 0x210c, 0xd19c, 0x1120, 0x7904, 0x918d,
-	0x0002, 0x7906, 0x2011, 0x0048, 0x080c, 0x2a63, 0x7828, 0x9085,
+	0x0002, 0x7906, 0x2011, 0x0048, 0x080c, 0x2a83, 0x7828, 0x9085,
 	0x0028, 0x782a, 0x2001, 0x19a6, 0x2003, 0x0000, 0x9006, 0x78f2,
 	0x015e, 0x003e, 0x000e, 0x012e, 0x00fe, 0x004e, 0x002e, 0x001e,
 	0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x0046, 0x00b6, 0x00c6,
-	0x00d6, 0x00e6, 0x00f6, 0x0156, 0x0071, 0x0d0c, 0x8709, 0x015e,
+	0x00d6, 0x00e6, 0x00f6, 0x0156, 0x0071, 0x0d0c, 0x873d, 0x015e,
 	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x004e, 0x003e, 0x002e,
 	0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0x189e, 0x7004, 0x9086,
-	0x0001, 0x1110, 0x080c, 0x348f, 0x00ee, 0x0005, 0x0005, 0x2a70,
-	0x2061, 0x19aa, 0x2063, 0x0003, 0x6007, 0x0002, 0x600b, 0x001e,
+	0x0001, 0x1110, 0x080c, 0x34af, 0x00ee, 0x0005, 0x0005, 0x2a70,
+	0x2061, 0x19aa, 0x2063, 0x0003, 0x6007, 0x0003, 0x600b, 0x0002,
 	0x600f, 0x0137, 0x2001, 0x197b, 0x900e, 0x2102, 0x7196, 0x2001,
 	0x0100, 0x2004, 0x9082, 0x0002, 0x0218, 0x705f, 0xffff, 0x0008,
-	0x715e, 0x7067, 0xffff, 0x717e, 0x7182, 0x080c, 0xcc9e, 0x70ef,
+	0x715e, 0x7067, 0xffff, 0x717e, 0x7182, 0x080c, 0xccd1, 0x70ef,
 	0x00c0, 0x2061, 0x196b, 0x6003, 0x0909, 0x6106, 0x600b, 0x8800,
 	0x600f, 0x0200, 0x6013, 0x00ff, 0x6017, 0x001f, 0x611a, 0x601f,
 	0x07d0, 0x2061, 0x1973, 0x6003, 0x8000, 0x6106, 0x610a, 0x600f,
 	0x0200, 0x6013, 0x00ff, 0x6116, 0x601b, 0x0001, 0x611e, 0x2061,
 	0x1988, 0x6003, 0x514c, 0x6007, 0x4f47, 0x600b, 0x4943, 0x600f,
-	0x2020, 0x2001, 0x182c, 0x2102, 0x0005, 0x9016, 0x080c, 0x6620,
+	0x2020, 0x2001, 0x182c, 0x2102, 0x0005, 0x9016, 0x080c, 0x6644,
 	0x1178, 0xb804, 0x90c4, 0x00ff, 0x98c6, 0x0006, 0x0128, 0x90c4,
 	0xff00, 0x98c6, 0x0600, 0x1120, 0x9186, 0x0080, 0x0108, 0x8210,
 	0x8108, 0x9186, 0x0800, 0x1d50, 0x2208, 0x0005, 0x2091, 0x8000,
@@ -236,447 +236,450 @@
 	0x0108, 0x0ca8, 0x7808, 0xd09c, 0x0110, 0x2011, 0xdead, 0x2019,
 	0x1b32, 0x782c, 0x201a, 0x8318, 0x221a, 0x7803, 0x0000, 0x2069,
 	0x1a79, 0x901e, 0x20a9, 0x0020, 0x7b26, 0x7a28, 0x226a, 0x8d68,
-	0x8318, 0x1f04, 0x0dcc, 0x0491, 0x002e, 0x003e, 0x00de, 0x015e,
-	0x2079, 0x1800, 0x7803, 0x0005, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x0180, 0x2001, 0x1a21, 0x2004, 0x9005, 0x0128,
-	0x2001, 0x008b, 0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003,
-	0x0002, 0x2003, 0x1001, 0x080c, 0x56e4, 0x1170, 0x080c, 0x0f13,
-	0x0110, 0x080c, 0x0e66, 0x080c, 0x56e4, 0x1130, 0x2071, 0x1800,
-	0x2011, 0x8000, 0x080c, 0x0f27, 0x0c70, 0x0005, 0x2001, 0x0382,
-	0x2004, 0x9084, 0x0007, 0x9086, 0x0001, 0x1120, 0x2001, 0x0015,
-	0x080c, 0xa879, 0x2079, 0x0380, 0x2069, 0x1b03, 0x7818, 0x6802,
-	0x781c, 0x6806, 0x7840, 0x680a, 0x7844, 0x680e, 0x782c, 0x6812,
-	0x2019, 0x1b0e, 0x9016, 0x7808, 0xd09c, 0x0150, 0x7820, 0x201a,
-	0x8210, 0x8318, 0x8210, 0x9282, 0x0011, 0x0ea8, 0x2011, 0xdead,
-	0x6a2a, 0x7830, 0x681a, 0x7834, 0x681e, 0x7838, 0x6822, 0x783c,
-	0x6826, 0x7803, 0x0000, 0x2069, 0x1ac3, 0x901e, 0x20a9, 0x0020,
-	0x7b26, 0x7828, 0x206a, 0x8d68, 0x8318, 0x1f04, 0x0e40, 0x2069,
-	0x1ae3, 0x2019, 0x00b0, 0x20a9, 0x0020, 0x7b26, 0x7828, 0x206a,
-	0x8d68, 0x8318, 0x1f04, 0x0e4d, 0x0005, 0x918c, 0x03ff, 0x2001,
-	0x0003, 0x2004, 0x9084, 0x0600, 0x1118, 0x918d, 0x6c00, 0x0010,
-	0x918d, 0x6400, 0x2001, 0x017f, 0x2102, 0x0005, 0x0026, 0x0126,
-	0x2011, 0x0080, 0x080c, 0x0f05, 0x20a9, 0x0900, 0x080c, 0x0f3b,
-	0x2011, 0x0040, 0x080c, 0x0f05, 0x20a9, 0x0900, 0x080c, 0x0f3b,
-	0x0c78, 0x0026, 0x080c, 0x0f13, 0x1188, 0x2011, 0x010e, 0x2214,
-	0x9294, 0x0007, 0x9296, 0x0007, 0x0118, 0x2011, 0x0947, 0x0010,
-	0x2011, 0x1b47, 0x080c, 0x0f27, 0x002e, 0x0005, 0x2011, 0x010e,
-	0x2214, 0x9294, 0x0007, 0x9296, 0x0007, 0x0118, 0x2011, 0xa880,
-	0x0010, 0x2011, 0x6840, 0xd0e4, 0x70f3, 0x0000, 0x1128, 0x70f3,
-	0x0fa0, 0x080c, 0x0f18, 0x002e, 0x0005, 0x0026, 0x080c, 0x0f13,
-	0x0148, 0xd0a4, 0x1138, 0x2011, 0xcdd5, 0x0010, 0x2011, 0x0080,
-	0x080c, 0x0f18, 0x002e, 0x0005, 0x0026, 0x70f3, 0x0000, 0x080c,
-	0x0f13, 0x1130, 0x2011, 0x8040, 0x080c, 0x0f27, 0x002e, 0x0005,
-	0x080c, 0x2a07, 0x1118, 0x2011, 0xcdc5, 0x0010, 0x2011, 0xcac2,
-	0x080c, 0x0f18, 0x002e, 0x0005, 0x00e6, 0x0016, 0x0006, 0x2071,
-	0x1800, 0xd0b4, 0x70ec, 0x71e8, 0x1118, 0xc0e4, 0xc1f4, 0x0050,
-	0x0006, 0x3b00, 0x9084, 0xff3e, 0x20d8, 0x000e, 0x70f3, 0x0000,
-	0xc0e5, 0xc1f5, 0x0099, 0x000e, 0x001e, 0x00ee, 0x0005, 0x00e6,
-	0x2071, 0x1800, 0xd0e4, 0x70ec, 0x1110, 0xc0dc, 0x0008, 0xc0dd,
-	0x0016, 0x71e8, 0x0019, 0x001e, 0x00ee, 0x0005, 0x70ee, 0x71ea,
-	0x7000, 0x9084, 0x0007, 0x000b, 0x0005, 0x0ecb, 0x0ea5, 0x0ea5,
-	0x0e79, 0x0eb4, 0x0ea5, 0x0ea5, 0x0eb4, 0xc284, 0x0016, 0x3b08,
-	0x3a00, 0x9104, 0x918d, 0x00c1, 0x21d8, 0x9084, 0xff3e, 0x9205,
-	0x20d0, 0x001e, 0x0005, 0x2001, 0x183b, 0x2004, 0xd0dc, 0x0005,
-	0x9e86, 0x1800, 0x190c, 0x0d7d, 0x70ec, 0xd0e4, 0x0108, 0xc2e5,
-	0x72ee, 0xd0e4, 0x1118, 0x9294, 0x00c1, 0x08f9, 0x0005, 0x9e86,
-	0x1800, 0x190c, 0x0d7d, 0x70e8, 0xd0f4, 0x0108, 0xc2f5, 0x72ea,
-	0xd0f4, 0x1140, 0x9284, 0x8000, 0x8005, 0xc284, 0x9215, 0x9294,
-	0x00c1, 0x0861, 0x0005, 0x1d04, 0x0f3b, 0x2091, 0x6000, 0x1f04,
-	0x0f3b, 0x0005, 0x890e, 0x810e, 0x810f, 0x9194, 0x003f, 0x918c,
-	0xffc0, 0x0005, 0x0006, 0x2200, 0x914d, 0x894f, 0x894d, 0x894d,
-	0x000e, 0x0005, 0x01d6, 0x0146, 0x0036, 0x0096, 0x2061, 0x188d,
-	0x600b, 0x0000, 0x600f, 0x0000, 0x6003, 0x0000, 0x6007, 0x0000,
-	0x2009, 0xffc0, 0x2105, 0x0006, 0x2001, 0xaaaa, 0x200f, 0x2019,
-	0x5555, 0x9016, 0x2049, 0x0bff, 0xab02, 0xa001, 0xa001, 0xa800,
-	0x9306, 0x1138, 0x2105, 0x9306, 0x0120, 0x8210, 0x99c8, 0x0400,
-	0x0c98, 0x000e, 0x200f, 0x2001, 0x189d, 0x928a, 0x000e, 0x1638,
-	0x928a, 0x0006, 0x2011, 0x0006, 0x1210, 0x2011, 0x0000, 0x2202,
-	0x9006, 0x2008, 0x82ff, 0x01b0, 0x8200, 0x600a, 0x600f, 0xffff,
-	0x6003, 0x0002, 0x6007, 0x0000, 0x0026, 0x2019, 0x0010, 0x9280,
-	0x0001, 0x20e8, 0x21a0, 0x21a8, 0x4104, 0x8319, 0x1de0, 0x8211,
-	0x1da0, 0x002e, 0x009e, 0x003e, 0x014e, 0x01de, 0x0005, 0x2011,
-	0x000e, 0x08e8, 0x0016, 0x0026, 0x0096, 0x3348, 0x080c, 0x0f42,
-	0x2100, 0x9300, 0x2098, 0x22e0, 0x009e, 0x002e, 0x001e, 0x0036,
-	0x3518, 0x20a9, 0x0001, 0x4002, 0x8007, 0x4004, 0x8319, 0x1dd8,
-	0x003e, 0x0005, 0x20e9, 0x0001, 0x71b8, 0x81ff, 0x11c0, 0x9006,
-	0x2009, 0x0200, 0x20a9, 0x0002, 0x9298, 0x0018, 0x23a0, 0x4001,
-	0x2009, 0x0700, 0x20a9, 0x0002, 0x9298, 0x0008, 0x23a0, 0x4001,
-	0x707c, 0x8007, 0x7180, 0x810f, 0x20a9, 0x0002, 0x4001, 0x9298,
-	0x000c, 0x23a0, 0x900e, 0x080c, 0x0d5d, 0x2001, 0x0000, 0x810f,
-	0x20a9, 0x0002, 0x4001, 0x0005, 0x89ff, 0x0140, 0xa804, 0xa807,
-	0x0000, 0x0006, 0x080c, 0x106c, 0x009e, 0x0cb0, 0x0005, 0x00e6,
-	0x2071, 0x1800, 0x080c, 0x10e5, 0x090c, 0x0d7d, 0x00ee, 0x0005,
-	0x0086, 0x00e6, 0x0006, 0x0026, 0x0036, 0x0126, 0x2091, 0x8000,
-	0x00c9, 0x2071, 0x1800, 0x73c0, 0x702c, 0x9016, 0x9045, 0x0158,
-	0x8210, 0x9906, 0x090c, 0x0d7d, 0x2300, 0x9202, 0x0120, 0x1a0c,
-	0x0d7d, 0xa000, 0x0c98, 0x012e, 0x003e, 0x002e, 0x000e, 0x00ee,
-	0x008e, 0x0005, 0x0086, 0x00e6, 0x0006, 0x0126, 0x2091, 0x8000,
-	0x2071, 0x1910, 0x7010, 0x9005, 0x0140, 0x7018, 0x9045, 0x0128,
-	0x9906, 0x090c, 0x0d7d, 0xa000, 0x0cc8, 0x012e, 0x000e, 0x00ee,
-	0x008e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x0126, 0x2091, 0x8000,
-	0x70c0, 0x8001, 0x0270, 0x70c2, 0x702c, 0x2048, 0x9085, 0x0001,
-	0xa800, 0x702e, 0xa803, 0x0000, 0xa807, 0x0000, 0x012e, 0x00ee,
-	0x0005, 0x904e, 0x0cd8, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x1800, 0x70c0, 0x90ca, 0x0020, 0x0268, 0x8001, 0x70c2, 0x702c,
-	0x2048, 0xa800, 0x702e, 0xa803, 0x0000, 0xa807, 0x0000, 0x012e,
-	0x00ee, 0x0005, 0x904e, 0x0cd8, 0x00e6, 0x0126, 0x2091, 0x8000,
-	0x0016, 0x890e, 0x810e, 0x810f, 0x9184, 0x003f, 0xa862, 0x9184,
-	0xffc0, 0xa85e, 0x001e, 0x0020, 0x00e6, 0x0126, 0x2091, 0x8000,
-	0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000,
-	0x70c2, 0x080c, 0x8532, 0x012e, 0x00ee, 0x0005, 0x2071, 0x1800,
-	0x9026, 0x2009, 0x0000, 0x2049, 0x0400, 0x2900, 0x702e, 0x8940,
-	0x2800, 0xa802, 0xa95e, 0xa863, 0x0001, 0x8420, 0x9886, 0x0440,
-	0x0120, 0x2848, 0x9188, 0x0040, 0x0c90, 0x2071, 0x188d, 0x7000,
-	0x9005, 0x11a0, 0x2001, 0x0558, 0xa802, 0x2048, 0x2009, 0x5600,
-	0x8940, 0x2800, 0xa802, 0xa95e, 0xa863, 0x0001, 0x8420, 0x9886,
-	0x0800, 0x0120, 0x2848, 0x9188, 0x0040, 0x0c90, 0x2071, 0x188d,
-	0x7104, 0x7200, 0x82ff, 0x01d0, 0x7308, 0x8318, 0x831f, 0x831b,
-	0x831b, 0x7312, 0x8319, 0x2001, 0x0800, 0xa802, 0x2048, 0x8900,
-	0xa802, 0x2040, 0xa95e, 0xaa62, 0x8420, 0x2300, 0x9906, 0x0130,
-	0x2848, 0x9188, 0x0040, 0x9291, 0x0000, 0x0c88, 0xa803, 0x0000,
-	0x2071, 0x1800, 0x74be, 0x74c2, 0x0005, 0x00e6, 0x0016, 0x9984,
-	0xfc00, 0x01e8, 0x908c, 0xf800, 0x1168, 0x9982, 0x0400, 0x02b8,
-	0x9982, 0x0440, 0x0278, 0x9982, 0x0558, 0x0288, 0x9982, 0x0800,
-	0x1270, 0x0040, 0x9982, 0x0800, 0x0250, 0x2071, 0x188d, 0x7010,
-	0x9902, 0x1228, 0x9085, 0x0001, 0x001e, 0x00ee, 0x0005, 0x9006,
-	0x0cd8, 0x00e6, 0x2071, 0x1a20, 0x7007, 0x0000, 0x9006, 0x701e,
-	0x7022, 0x7002, 0x2071, 0x0000, 0x7010, 0x9085, 0x8044, 0x7012,
-	0x2071, 0x0080, 0x9006, 0x702b, 0x0060, 0x20a9, 0x0040, 0x7022,
-	0x1f04, 0x111f, 0x702b, 0x0060, 0x702b, 0x0020, 0x20a9, 0x0040,
-	0x7022, 0x1f04, 0x1128, 0x702b, 0x0020, 0x00ee, 0x0005, 0x0126,
-	0x2091, 0x8000, 0x00e6, 0xa06f, 0x0000, 0x2071, 0x1a20, 0x701c,
-	0x9088, 0x1a2a, 0x280a, 0x8000, 0x9084, 0x003f, 0x701e, 0x7120,
-	0x9106, 0x090c, 0x0d7d, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079,
-	0x0080, 0x00a9, 0x00fe, 0x00ee, 0x012e, 0x0005, 0x0126, 0x2091,
-	0x8000, 0x00e6, 0x2071, 0x1a20, 0x7004, 0x9005, 0x1128, 0x00f6,
-	0x2079, 0x0080, 0x0021, 0x00fe, 0x00ee, 0x012e, 0x0005, 0x7004,
-	0x9086, 0x0000, 0x1110, 0x7007, 0x0006, 0x7000, 0x0002, 0x1171,
-	0x12f4, 0x116f, 0x116f, 0x12e8, 0x12e8, 0x12e8, 0x12e8, 0x080c,
-	0x0d7d, 0x701c, 0x7120, 0x9106, 0x1148, 0x792c, 0x9184, 0x0001,
-	0x1120, 0xd1fc, 0x1110, 0x7007, 0x0000, 0x0005, 0x0096, 0x9180,
-	0x1a2a, 0x2004, 0x700a, 0x2048, 0x8108, 0x918c, 0x003f, 0x7122,
-	0x782b, 0x0026, 0xa88c, 0x7802, 0xa890, 0x7806, 0xa894, 0x780a,
-	0xa898, 0x780e, 0xa878, 0x700e, 0xa870, 0x7016, 0xa874, 0x701a,
-	0xa868, 0x009e, 0xd084, 0x0120, 0x7007, 0x0001, 0x0029, 0x0005,
-	0x7007, 0x0002, 0x00b1, 0x0005, 0x0016, 0x0026, 0x710c, 0x2011,
-	0x0040, 0x9182, 0x0040, 0x1210, 0x2110, 0x9006, 0x700e, 0x7212,
-	0x8203, 0x7812, 0x782b, 0x0020, 0x782b, 0x0041, 0x002e, 0x001e,
-	0x0005, 0x0016, 0x0026, 0x0136, 0x0146, 0x0156, 0x7014, 0x20e0,
-	0x7018, 0x2098, 0x20e9, 0x0000, 0x20a1, 0x0088, 0x782b, 0x0026,
-	0x710c, 0x2011, 0x0040, 0x9182, 0x0040, 0x1210, 0x2110, 0x9006,
-	0x700e, 0x22a8, 0x4006, 0x8203, 0x7812, 0x782b, 0x0020, 0x3300,
-	0x701a, 0x782b, 0x0001, 0x015e, 0x014e, 0x013e, 0x002e, 0x001e,
-	0x0005, 0x2009, 0x1a20, 0x2104, 0xc095, 0x200a, 0x080c, 0x114e,
-	0x0005, 0x0016, 0x00e6, 0x2071, 0x1a20, 0x00f6, 0x2079, 0x0080,
-	0x792c, 0xd1bc, 0x190c, 0x0d76, 0x782b, 0x0002, 0xd1fc, 0x0120,
-	0x918c, 0x0700, 0x7004, 0x0023, 0x00fe, 0x00ee, 0x001e, 0x0005,
-	0x115f, 0x1207, 0x123b, 0x1313, 0x0d7d, 0x132e, 0x0d7d, 0x918c,
-	0x0700, 0x1550, 0x0136, 0x0146, 0x0156, 0x7014, 0x20e8, 0x7018,
-	0x20a0, 0x20e1, 0x0000, 0x2099, 0x0088, 0x782b, 0x0040, 0x7010,
-	0x20a8, 0x4005, 0x3400, 0x701a, 0x015e, 0x014e, 0x013e, 0x700c,
-	0x9005, 0x0578, 0x7800, 0x7802, 0x7804, 0x7806, 0x080c, 0x11a4,
-	0x0005, 0x7008, 0x0096, 0x2048, 0xa86f, 0x0100, 0x009e, 0x7007,
-	0x0000, 0x080c, 0x115f, 0x0005, 0x7008, 0x0096, 0x2048, 0xa86f,
-	0x0200, 0x009e, 0x0ca0, 0x918c, 0x0700, 0x1150, 0x700c, 0x9005,
-	0x0180, 0x7800, 0x7802, 0x7804, 0x7806, 0x080c, 0x11b9, 0x0005,
-	0x7008, 0x0096, 0x2048, 0xa86f, 0x0200, 0x009e, 0x7007, 0x0000,
-	0x0080, 0x0096, 0x7008, 0x2048, 0x7800, 0xa88e, 0x7804, 0xa892,
-	0x7808, 0xa896, 0x780c, 0xa89a, 0xa86f, 0x0100, 0x009e, 0x7007,
-	0x0000, 0x0096, 0x00d6, 0x7008, 0x2048, 0x2001, 0x18b9, 0x2004,
-	0x9906, 0x1128, 0xa89c, 0x080f, 0x00de, 0x009e, 0x00a0, 0x00de,
-	0x009e, 0x0096, 0x00d6, 0x7008, 0x2048, 0x0081, 0x0150, 0xa89c,
-	0x0086, 0x2940, 0x080f, 0x008e, 0x00de, 0x009e, 0x080c, 0x114e,
-	0x0005, 0x00de, 0x009e, 0x080c, 0x114e, 0x0005, 0xa8a8, 0xd08c,
-	0x0005, 0x0096, 0xa0a0, 0x904d, 0x090c, 0x0d7d, 0xa06c, 0x908e,
-	0x0100, 0x0130, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002,
-	0x080c, 0x6d6f, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x2848, 0x080c,
-	0x106c, 0x009e, 0x0005, 0x00a6, 0xa0a0, 0x904d, 0x090c, 0x0d7d,
-	0xa06c, 0x908e, 0x0100, 0x0128, 0xa87b, 0x0001, 0xa883, 0x0000,
-	0x00c0, 0xa80c, 0x2050, 0xb004, 0x9005, 0x0198, 0xa80e, 0x2050,
-	0x8006, 0x8006, 0x8007, 0x908c, 0x003f, 0x9084, 0xffc0, 0x9080,
-	0x0002, 0xa076, 0xa172, 0xb000, 0xa07a, 0x2810, 0x080c, 0x112f,
-	0x00e8, 0xa97c, 0xa894, 0x0016, 0x0006, 0x080c, 0x6d6f, 0x000e,
-	0x001e, 0xd1fc, 0x1138, 0xd1f4, 0x0128, 0x00c6, 0x2060, 0x080c,
-	0xabdf, 0x00ce, 0x7008, 0x2048, 0xa89f, 0x0000, 0xa8a3, 0x0000,
-	0x080c, 0x106c, 0x7007, 0x0000, 0x080c, 0x114e, 0x00ae, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x782b, 0x1001, 0x7007, 0x0005, 0x7000,
-	0xc094, 0x7002, 0x012e, 0x0005, 0x0096, 0x2001, 0x192e, 0x204c,
-	0xa87c, 0x7812, 0xa88c, 0x7802, 0xa890, 0x7806, 0xa894, 0x780a,
-	0xa898, 0x780e, 0x782b, 0x0020, 0x0126, 0x2091, 0x8000, 0x782b,
-	0x0041, 0x7007, 0x0003, 0x7000, 0xc084, 0x7002, 0x2900, 0x700a,
-	0x012e, 0x009e, 0x0005, 0x20e1, 0x0000, 0x2099, 0x0088, 0x782b,
-	0x0040, 0x0096, 0x2001, 0x192e, 0x204c, 0xaa7c, 0x009e, 0x080c,
-	0x8bfd, 0x2009, 0x188c, 0x2104, 0x9084, 0xfffc, 0x200a, 0x080c,
-	0x8a70, 0x7007, 0x0000, 0x080c, 0x115f, 0x0005, 0x7007, 0x0000,
-	0x080c, 0x115f, 0x0005, 0x0126, 0x2091, 0x2200, 0x2079, 0x0300,
-	0x2071, 0x1a6a, 0x7003, 0x0000, 0x78bf, 0x00f6, 0x0041, 0x7807,
-	0x0007, 0x7803, 0x0000, 0x7803, 0x0001, 0x012e, 0x0005, 0x00c6,
-	0x7803, 0x0000, 0x2001, 0x0165, 0x2003, 0x4198, 0x7808, 0xd09c,
-	0x0118, 0x7820, 0x04e9, 0x0cd0, 0x2001, 0x1a6b, 0x2003, 0x0000,
-	0x78ab, 0x0004, 0x78ac, 0xd0ac, 0x1de8, 0x78ab, 0x0002, 0x7807,
-	0x0007, 0x7827, 0x0030, 0x782b, 0x0400, 0x7827, 0x0031, 0x782b,
-	0x1a79, 0x781f, 0xff00, 0x781b, 0xff00, 0x2001, 0x0200, 0x2004,
-	0xd0dc, 0x0110, 0x781f, 0x0303, 0x2061, 0x1a79, 0x602f, 0x1ddc,
-	0x2001, 0x181a, 0x2004, 0x9082, 0x1ddc, 0x6032, 0x603b, 0x1e62,
-	0x602b, 0x1ab9, 0x6007, 0x1a99, 0x2061, 0x1a99, 0x60af, 0x193c,
-	0x2001, 0x1927, 0x2004, 0x60ba, 0x783f, 0x3368, 0x00ce, 0x0005,
-	0x9086, 0x000d, 0x11d0, 0x7808, 0xd09c, 0x01b8, 0x7820, 0x0026,
-	0x2010, 0x080c, 0xc820, 0x0180, 0x2260, 0x6000, 0x9086, 0x0004,
-	0x1158, 0x0016, 0x6120, 0x9186, 0x0009, 0x0108, 0x0020, 0x2009,
-	0x004c, 0x080c, 0xac7c, 0x001e, 0x002e, 0x0005, 0x0126, 0x2091,
-	0x2200, 0x7908, 0x9184, 0x0070, 0x190c, 0x0d76, 0xd19c, 0x05a0,
-	0x7820, 0x908c, 0xf000, 0x0540, 0x2060, 0x6020, 0x9086, 0x0003,
-	0x1550, 0x6000, 0x9086, 0x0004, 0x1530, 0x6114, 0x2148, 0xa876,
-	0xa87a, 0xa867, 0x0103, 0x080c, 0x6b91, 0x00b6, 0x6010, 0x2058,
-	0xba3c, 0x8211, 0x0208, 0xba3e, 0xb8d0, 0x9005, 0x190c, 0x674b,
-	0x00be, 0x6044, 0xd0fc, 0x190c, 0xa8b1, 0x080c, 0xac08, 0x7808,
-	0xd09c, 0x19b0, 0x012e, 0x0005, 0x908a, 0x0024, 0x1a0c, 0x0d7d,
-	0x002b, 0x012e, 0x0005, 0x04b0, 0x012e, 0x0005, 0x1412, 0x1438,
-	0x1468, 0x146d, 0x1471, 0x1476, 0x149e, 0x14a2, 0x14b0, 0x14b4,
-	0x1412, 0x1581, 0x1585, 0x15ea, 0x15f1, 0x1412, 0x15f2, 0x15f3,
-	0x15fe, 0x1605, 0x1412, 0x1412, 0x1412, 0x1412, 0x1412, 0x1412,
-	0x1412, 0x1478, 0x1412, 0x1440, 0x1465, 0x142c, 0x1412, 0x144c,
-	0x1416, 0x1414, 0x080c, 0x0d7d, 0x080c, 0x0d76, 0x080c, 0x1610,
-	0x2009, 0x1a78, 0x2104, 0x8000, 0x200a, 0x080c, 0x7f78, 0x080c,
-	0x1ac2, 0x0005, 0x6044, 0xd0fc, 0x190c, 0xa8b1, 0x2009, 0x0055,
-	0x080c, 0xac7c, 0x012e, 0x0005, 0x080c, 0x1610, 0x2060, 0x6044,
-	0xd0fc, 0x190c, 0xa8b1, 0x2009, 0x0055, 0x080c, 0xac7c, 0x0005,
-	0x2009, 0x0048, 0x080c, 0x1610, 0x2060, 0x080c, 0xac7c, 0x0005,
-	0x2009, 0x0054, 0x080c, 0x1610, 0x2060, 0x6044, 0xd0fc, 0x190c,
-	0xa8b1, 0x080c, 0xac7c, 0x0005, 0x080c, 0x1610, 0x2060, 0x0056,
-	0x0066, 0x080c, 0x1610, 0x2028, 0x080c, 0x1610, 0x2030, 0x0036,
-	0x0046, 0x2021, 0x0000, 0x2418, 0x2009, 0x0056, 0x080c, 0xac7c,
-	0x004e, 0x003e, 0x006e, 0x005e, 0x0005, 0x080c, 0x1610, 0x0005,
-	0x7004, 0xc085, 0xc0b5, 0x7006, 0x0005, 0x7004, 0xc085, 0x7006,
-	0x0005, 0x080c, 0x1610, 0x080c, 0x16d4, 0x0005, 0x080c, 0x0d7d,
-	0x080c, 0x1610, 0x2060, 0x6014, 0x0096, 0x2048, 0xa83b, 0xffff,
-	0x009e, 0x2009, 0x0048, 0x080c, 0xac7c, 0x2001, 0x015d, 0x2003,
-	0x0000, 0x2009, 0x03e8, 0x8109, 0x0160, 0x2001, 0x0201, 0x2004,
-	0x9005, 0x0dc8, 0x2001, 0x0218, 0x2004, 0xd0ec, 0x1110, 0x080c,
-	0x1615, 0x2001, 0x0307, 0x2003, 0x8000, 0x0005, 0x7004, 0xc095,
-	0x7006, 0x0005, 0x080c, 0x1610, 0x2060, 0x6014, 0x0096, 0x2048,
-	0xa83b, 0xffff, 0x009e, 0x2009, 0x0048, 0x080c, 0xac7c, 0x0005,
-	0x080c, 0x1610, 0x080c, 0x0d7d, 0x080c, 0x1610, 0x080c, 0x156c,
-	0x7827, 0x0018, 0x79ac, 0xd1dc, 0x0904, 0x151d, 0x7827, 0x0015,
-	0x7828, 0x782b, 0x0000, 0x9065, 0x0140, 0x2001, 0x020d, 0x2003,
-	0x0050, 0x2003, 0x0020, 0x0804, 0x1523, 0x7004, 0x9005, 0x01c8,
-	0x1188, 0x78ab, 0x0004, 0x7827, 0x0018, 0x782b, 0x0000, 0xd1bc,
-	0x090c, 0x0d7d, 0x2001, 0x020d, 0x2003, 0x0050, 0x2003, 0x0020,
-	0x0804, 0x1551, 0x78ab, 0x0004, 0x7803, 0x0001, 0x080c, 0x1585,
-	0x0005, 0x7827, 0x0018, 0xa001, 0x7828, 0x7827, 0x0011, 0xa001,
-	0x7928, 0x9106, 0x0110, 0x79ac, 0x08e0, 0x00e6, 0x2071, 0x0200,
-	0x702c, 0xd0c4, 0x0140, 0x00ee, 0x080c, 0x1ac2, 0x080c, 0x1347,
-	0x7803, 0x0001, 0x0005, 0x7037, 0x0001, 0xa001, 0x7150, 0x00ee,
-	0x918c, 0xff00, 0x9186, 0x0500, 0x0110, 0x79ac, 0x0810, 0x7004,
-	0xc09d, 0x7006, 0x78ab, 0x0004, 0x7803, 0x0001, 0x080c, 0x1585,
-	0x2001, 0x020d, 0x2003, 0x0020, 0x0005, 0x7828, 0x782b, 0x0000,
-	0x9065, 0x090c, 0x0d7d, 0x6014, 0x2048, 0x78ab, 0x0004, 0x918c,
-	0x0700, 0x01a8, 0x080c, 0x7f78, 0x080c, 0x1ac2, 0x080c, 0xc832,
-	0x0158, 0xa9ac, 0xa936, 0xa9b0, 0xa93a, 0xa83f, 0xffff, 0xa843,
-	0xffff, 0xa880, 0xc0bd, 0xa882, 0x080c, 0xc430, 0x0005, 0x6020,
-	0x9086, 0x0009, 0x1128, 0x2009, 0x004c, 0x080c, 0xac7c, 0x0048,
-	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x6024, 0x190c,
-	0xcc33, 0x2029, 0x00c8, 0x8529, 0x0128, 0x2001, 0x0201, 0x2004,
-	0x9005, 0x0dc8, 0x7dbc, 0x080c, 0xe6ea, 0xd5a4, 0x1118, 0x080c,
-	0x1615, 0x0005, 0x080c, 0x7f78, 0x080c, 0x1ac2, 0x0005, 0x781f,
-	0x0300, 0x7803, 0x0001, 0x0005, 0x0016, 0x0066, 0x0076, 0x00f6,
-	0x2079, 0x0300, 0x7908, 0x918c, 0x0007, 0x9186, 0x0003, 0x0120,
-	0x2001, 0x0016, 0x080c, 0x1686, 0x00fe, 0x007e, 0x006e, 0x001e,
-	0x0005, 0x7004, 0xc09d, 0x7006, 0x0005, 0x7104, 0x9184, 0x0004,
-	0x190c, 0x0d7d, 0xd184, 0x1189, 0xd19c, 0x0158, 0xc19c, 0x7106,
-	0x2001, 0x020d, 0x2003, 0x0050, 0x2003, 0x0020, 0x080c, 0x1615,
-	0x0005, 0x81ff, 0x190c, 0x0d7d, 0x0005, 0xc184, 0xd1b4, 0xc1b4,
-	0x7106, 0x0016, 0x00e6, 0x15f0, 0x2071, 0x0200, 0x080c, 0x16c1,
-	0x05c8, 0x6014, 0x9005, 0x05b0, 0x0096, 0x2048, 0xa864, 0x009e,
-	0x9084, 0x00ff, 0x908e, 0x0029, 0x0160, 0x908e, 0x0048, 0x1550,
-	0x601c, 0xd084, 0x11e0, 0x00f6, 0x2c78, 0x080c, 0x173e, 0x00fe,
-	0x00b0, 0x00f6, 0x2c78, 0x080c, 0x18c5, 0x00fe, 0x2009, 0x01f4,
-	0x8109, 0x0168, 0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8, 0x2001,
-	0x0218, 0x2004, 0xd0ec, 0x1118, 0x080c, 0x1615, 0x0040, 0x2001,
-	0x020d, 0x2003, 0x0020, 0x080c, 0x1347, 0x7803, 0x0001, 0x00ee,
-	0x001e, 0x0005, 0x2001, 0x020d, 0x2003, 0x0050, 0x2003, 0x0020,
-	0x0461, 0x0ca8, 0x0429, 0x2060, 0x2009, 0x0053, 0x080c, 0xac7c,
-	0x0005, 0x0005, 0x0005, 0x00e1, 0x2008, 0x00d1, 0x0006, 0x7004,
-	0xc09d, 0x7006, 0x000e, 0x080c, 0x8f5a, 0x0005, 0x0089, 0x9005,
-	0x0118, 0x080c, 0x8b5d, 0x0cd0, 0x0005, 0x2001, 0x0036, 0x2009,
-	0x1820, 0x210c, 0x2011, 0x181f, 0x2214, 0x080c, 0x1686, 0x0005,
-	0x7808, 0xd09c, 0x0de8, 0x7820, 0x0005, 0x080c, 0x156c, 0x00d6,
-	0x2069, 0x0200, 0x2009, 0x01f4, 0x8109, 0x0510, 0x6804, 0x9005,
-	0x0dd8, 0x2001, 0x015d, 0x2003, 0x0000, 0x79bc, 0xd1a4, 0x1528,
-	0x79b8, 0x918c, 0x0fff, 0x0180, 0x9182, 0x0841, 0x1268, 0x9188,
-	0x0007, 0x918c, 0x0ff8, 0x810c, 0x810c, 0x810c, 0x080c, 0x1678,
-	0x6827, 0x0001, 0x8109, 0x1dd0, 0x04d9, 0x6827, 0x0002, 0x04c1,
-	0x6804, 0x9005, 0x1130, 0x682c, 0xd0e4, 0x1500, 0x6804, 0x9005,
-	0x0de8, 0x79b8, 0xd1ec, 0x1130, 0x08c0, 0x080c, 0x7f78, 0x080c,
-	0x1ac2, 0x0090, 0x7827, 0x0015, 0x782b, 0x0000, 0x7827, 0x0018,
-	0x782b, 0x0000, 0x2001, 0x020d, 0x2003, 0x0020, 0x2001, 0x0307,
-	0x2003, 0x0300, 0x7803, 0x0001, 0x00de, 0x0005, 0x682c, 0x9084,
-	0x5400, 0x9086, 0x5400, 0x0d30, 0x7827, 0x0015, 0x782b, 0x0000,
-	0x7803, 0x0001, 0x6800, 0x9085, 0x1800, 0x6802, 0x00de, 0x0005,
-	0x6824, 0x9084, 0x0003, 0x1de0, 0x0005, 0x2001, 0x0030, 0x2c08,
-	0x621c, 0x0021, 0x7830, 0x9086, 0x0041, 0x0005, 0x00f6, 0x2079,
-	0x0300, 0x0006, 0x7808, 0xd09c, 0x0140, 0x0016, 0x0026, 0x00c6,
-	0x080c, 0x13ae, 0x00ce, 0x002e, 0x001e, 0x000e, 0x0006, 0x7832,
-	0x7936, 0x7a3a, 0x781b, 0x8080, 0x0059, 0x1118, 0x000e, 0x00fe,
-	0x0005, 0x000e, 0x792c, 0x3900, 0x8000, 0x2004, 0x080c, 0x0d7d,
-	0x2009, 0xff00, 0x8109, 0x0120, 0x7818, 0xd0bc, 0x1dd8, 0x0005,
-	0x9085, 0x0001, 0x0005, 0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080,
-	0x0c79, 0x1108, 0x0005, 0x792c, 0x3900, 0x8000, 0x2004, 0x080c,
-	0x0d7d, 0x7037, 0x0001, 0x7150, 0x7037, 0x0002, 0x7050, 0x2060,
-	0xd1bc, 0x1110, 0x7054, 0x2060, 0x918c, 0xff00, 0x9186, 0x0500,
-	0x0110, 0x9085, 0x0001, 0x0005, 0x00e6, 0x0016, 0x2071, 0x0200,
-	0x0c41, 0x6124, 0xd1dc, 0x01f8, 0x701c, 0xd08c, 0x0904, 0x1733,
-	0x7017, 0x0000, 0x2001, 0x0264, 0x2004, 0xd0bc, 0x0904, 0x1733,
-	0x2001, 0x0268, 0x00c6, 0x2064, 0x6104, 0x6038, 0x00ce, 0x918e,
-	0x0039, 0x1904, 0x1733, 0x9c06, 0x15f0, 0x0126, 0x2091, 0x2600,
-	0x080c, 0x7ed0, 0x012e, 0x7358, 0x745c, 0x6014, 0x905d, 0x0598,
-	0x2b48, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x190c,
-	0xcc0e, 0xab42, 0xac3e, 0x2001, 0x1869, 0x2004, 0xd0b4, 0x1170,
-	0x601c, 0xd0e4, 0x1158, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
-	0xd0bc, 0x1120, 0xa83b, 0x7fff, 0xa837, 0xffff, 0x080c, 0x1e82,
-	0x1190, 0x080c, 0x1920, 0x2a00, 0xa816, 0x0130, 0x2800, 0xa80e,
-	0x2c05, 0xa80a, 0x2c00, 0xa812, 0x7037, 0x0020, 0x781f, 0x0300,
-	0x001e, 0x00ee, 0x0005, 0x7037, 0x0050, 0x7037, 0x0020, 0x001e,
-	0x00ee, 0x080c, 0x1615, 0x0005, 0x080c, 0x0d7d, 0x2cf0, 0x0126,
-	0x2091, 0x2200, 0x00c6, 0x3e60, 0x6014, 0x2048, 0x2940, 0x903e,
-	0x2730, 0xa864, 0x2068, 0xa81a, 0x9d84, 0x000f, 0x9088, 0x1e62,
-	0x2165, 0x0002, 0x1769, 0x17d7, 0x1769, 0x1769, 0x176d, 0x17b8,
-	0x1769, 0x178d, 0x1762, 0x17ce, 0x1769, 0x1769, 0x1772, 0x18c3,
-	0x17a1, 0x1797, 0xa964, 0x918c, 0x00ff, 0x918e, 0x0048, 0x0904,
-	0x17ce, 0x9085, 0x0001, 0x0804, 0x18ba, 0xa87c, 0xd0ac, 0x0dc8,
-	0x0804, 0x17de, 0xa87c, 0xd0ac, 0x0da0, 0x0804, 0x1849, 0xa898,
-	0x901d, 0x1108, 0xab9c, 0x9016, 0xaab2, 0xaa3e, 0xaa42, 0x3e00,
-	0x9080, 0x0008, 0x2004, 0x9080, 0x9123, 0x2005, 0x9005, 0x090c,
-	0x0d7d, 0x2004, 0xa8ae, 0x0804, 0x18a2, 0xa87c, 0xd0bc, 0x09c8,
-	0xa890, 0xa842, 0xa88c, 0xa83e, 0xa888, 0x0804, 0x17de, 0xa87c,
-	0xd0bc, 0x0978, 0xa890, 0xa842, 0xa88c, 0xa83e, 0xa888, 0x0804,
-	0x1849, 0xa87c, 0xd0bc, 0x0928, 0xa890, 0xa842, 0xa88c, 0xa83e,
-	0xa804, 0x9045, 0x090c, 0x0d7d, 0xa164, 0xa91a, 0x91ec, 0x000f,
-	0x9d80, 0x1e62, 0x2065, 0xa888, 0xd19c, 0x1904, 0x1849, 0x0430,
-	0xa87c, 0xd0ac, 0x0904, 0x1769, 0xa804, 0x9045, 0x090c, 0x0d7d,
-	0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80, 0x1e62, 0x2065, 0x9006,
-	0xa842, 0xa83e, 0xd19c, 0x1904, 0x1849, 0x0080, 0xa87c, 0xd0ac,
-	0x0904, 0x1769, 0x9006, 0xa842, 0xa83e, 0x0804, 0x1849, 0xa87c,
-	0xd0ac, 0x0904, 0x1769, 0x9006, 0xa842, 0xa83e, 0x2c05, 0x908a,
-	0x0036, 0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002, 0x1801, 0x1801,
-	0x1803, 0x1801, 0x1801, 0x1801, 0x180d, 0x1801, 0x1801, 0x1801,
-	0x1817, 0x1801, 0x1801, 0x1801, 0x1821, 0x1801, 0x1801, 0x1801,
-	0x182b, 0x1801, 0x1801, 0x1801, 0x1835, 0x1801, 0x1801, 0x1801,
-	0x183f, 0x080c, 0x0d7d, 0xa574, 0xa478, 0x9d86, 0x0024, 0x0904,
-	0x1777, 0xa37c, 0xa280, 0x0804, 0x18a2, 0xa584, 0xa488, 0x9d86,
-	0x0024, 0x0904, 0x1777, 0xa38c, 0xa290, 0x0804, 0x18a2, 0xa594,
-	0xa498, 0x9d86, 0x0024, 0x0904, 0x1777, 0xa39c, 0xa2a0, 0x0804,
-	0x18a2, 0xa5a4, 0xa4a8, 0x9d86, 0x0024, 0x0904, 0x1777, 0xa3ac,
-	0xa2b0, 0x0804, 0x18a2, 0xa5b4, 0xa4b8, 0x9d86, 0x0024, 0x0904,
-	0x1777, 0xa3bc, 0xa2c0, 0x0804, 0x18a2, 0xa5c4, 0xa4c8, 0x9d86,
-	0x0024, 0x0904, 0x1777, 0xa3cc, 0xa2d0, 0x0804, 0x18a2, 0xa5d4,
-	0xa4d8, 0x9d86, 0x0024, 0x0904, 0x1777, 0xa3dc, 0xa2e0, 0x0804,
-	0x18a2, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0d7d, 0x9082, 0x001b,
-	0x0002, 0x186c, 0x186a, 0x186a, 0x186a, 0x186a, 0x186a, 0x1877,
-	0x186a, 0x186a, 0x186a, 0x186a, 0x186a, 0x1882, 0x186a, 0x186a,
-	0x186a, 0x186a, 0x186a, 0x188d, 0x186a, 0x186a, 0x186a, 0x186a,
-	0x186a, 0x1898, 0x080c, 0x0d7d, 0xa56c, 0xa470, 0xa774, 0xa678,
-	0x9d86, 0x002c, 0x0904, 0x1777, 0xa37c, 0xa280, 0x0458, 0xa584,
-	0xa488, 0xa78c, 0xa690, 0x9d86, 0x002c, 0x0904, 0x1777, 0xa394,
-	0xa298, 0x0400, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8, 0x9d86, 0x002c,
-	0x0904, 0x1777, 0xa3ac, 0xa2b0, 0x00a8, 0xa5b4, 0xa4b8, 0xa7bc,
-	0xa6c0, 0x9d86, 0x002c, 0x0904, 0x1777, 0xa3c4, 0xa2c8, 0x0050,
-	0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8, 0x9d86, 0x002c, 0x0904, 0x1777,
-	0xa3dc, 0xa2e0, 0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a,
-	0xa988, 0x8c60, 0x2c1d, 0xa8ac, 0xaab0, 0xa836, 0xaa3a, 0x8109,
-	0xa916, 0x1158, 0x3e60, 0x601c, 0xc085, 0x601e, 0xa87c, 0xc0dd,
-	0xa87e, 0x9006, 0x00ce, 0x012e, 0x0005, 0x2800, 0xa80e, 0xab0a,
-	0x2c00, 0xa812, 0x0c78, 0x0804, 0x1769, 0x2ff0, 0x0126, 0x2091,
-	0x2200, 0x00c6, 0x3e60, 0x6014, 0x2048, 0x2940, 0xa80e, 0x2061,
-	0x1e5d, 0xa813, 0x1e5d, 0x2c05, 0xa80a, 0xa964, 0xa91a, 0xa87c,
-	0xd0ac, 0x090c, 0x0d7d, 0x9006, 0xa842, 0xa83e, 0x2c05, 0x908a,
-	0x0034, 0x1a0c, 0x0d7d, 0xadcc, 0xacd0, 0xafd4, 0xaed8, 0xabdc,
-	0xaae0, 0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a, 0xa8ac,
-	0xaab0, 0xa836, 0xaa3a, 0xa988, 0xa864, 0x9084, 0x00ff, 0x9086,
-	0x0008, 0x1120, 0x8109, 0xa916, 0x0128, 0x0078, 0x918a, 0x0002,
-	0xa916, 0x1158, 0x3e60, 0x601c, 0xc085, 0x601e, 0xa87c, 0xc0dd,
-	0xa87e, 0x9006, 0x00ce, 0x012e, 0x0005, 0xa804, 0x9045, 0x090c,
-	0x0d7d, 0xa80e, 0xa064, 0xa81a, 0x9084, 0x000f, 0x9080, 0x1e62,
-	0x2015, 0x82ff, 0x090c, 0x0d7d, 0xaa12, 0x2205, 0xa80a, 0x0c10,
-	0x903e, 0x2730, 0xa880, 0xd0fc, 0x1190, 0x2d00, 0x0002, 0x1a4a,
-	0x1977, 0x1977, 0x1a4a, 0x1977, 0x1a44, 0x1a4a, 0x1977, 0x19e7,
-	0x19e7, 0x19e7, 0x1a4a, 0x19e7, 0x1a4a, 0x1a41, 0x19e7, 0xc0fc,
-	0xa882, 0xab2c, 0xaa30, 0xad1c, 0xac20, 0xdd9c, 0x0904, 0x1a4c,
-	0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002,
-	0x1963, 0x1961, 0x1961, 0x1961, 0x1961, 0x1961, 0x1967, 0x1961,
-	0x1961, 0x1961, 0x1961, 0x1961, 0x196b, 0x1961, 0x1961, 0x1961,
-	0x1961, 0x1961, 0x196f, 0x1961, 0x1961, 0x1961, 0x1961, 0x1961,
-	0x1973, 0x080c, 0x0d7d, 0xa774, 0xa678, 0x0804, 0x1a4c, 0xa78c,
-	0xa690, 0x0804, 0x1a4c, 0xa7a4, 0xa6a8, 0x0804, 0x1a4c, 0xa7bc,
-	0xa6c0, 0x0804, 0x1a4c, 0xa7d4, 0xa6d8, 0x0804, 0x1a4c, 0xa898,
-	0x901d, 0x1108, 0xab9c, 0x9016, 0x2c05, 0x908a, 0x0036, 0x1a0c,
-	0x0d7d, 0x9082, 0x001b, 0x0002, 0x199f, 0x199f, 0x19a1, 0x199f,
-	0x199f, 0x199f, 0x19ab, 0x199f, 0x199f, 0x199f, 0x19b5, 0x199f,
-	0x199f, 0x199f, 0x19bf, 0x199f, 0x199f, 0x199f, 0x19c9, 0x199f,
-	0x199f, 0x199f, 0x19d3, 0x199f, 0x199f, 0x199f, 0x19dd, 0x080c,
-	0x0d7d, 0xa574, 0xa478, 0x9d86, 0x0004, 0x0904, 0x1a4c, 0xa37c,
-	0xa280, 0x0804, 0x1a4c, 0xa584, 0xa488, 0x9d86, 0x0004, 0x0904,
-	0x1a4c, 0xa38c, 0xa290, 0x0804, 0x1a4c, 0xa594, 0xa498, 0x9d86,
-	0x0004, 0x0904, 0x1a4c, 0xa39c, 0xa2a0, 0x0804, 0x1a4c, 0xa5a4,
-	0xa4a8, 0x9d86, 0x0004, 0x0904, 0x1a4c, 0xa3ac, 0xa2b0, 0x0804,
-	0x1a4c, 0xa5b4, 0xa4b8, 0x9d86, 0x0004, 0x0904, 0x1a4c, 0xa3bc,
-	0xa2c0, 0x0804, 0x1a4c, 0xa5c4, 0xa4c8, 0x9d86, 0x0004, 0x0904,
-	0x1a4c, 0xa3cc, 0xa2d0, 0x0804, 0x1a4c, 0xa5d4, 0xa4d8, 0x9d86,
-	0x0004, 0x0904, 0x1a4c, 0xa3dc, 0xa2e0, 0x0804, 0x1a4c, 0xa898,
-	0x901d, 0x1108, 0xab9c, 0x9016, 0x2c05, 0x908a, 0x0034, 0x1a0c,
-	0x0d7d, 0x9082, 0x001b, 0x0002, 0x1a0f, 0x1a0d, 0x1a0d, 0x1a0d,
-	0x1a0d, 0x1a0d, 0x1a19, 0x1a0d, 0x1a0d, 0x1a0d, 0x1a0d, 0x1a0d,
-	0x1a23, 0x1a0d, 0x1a0d, 0x1a0d, 0x1a0d, 0x1a0d, 0x1a2d, 0x1a0d,
-	0x1a0d, 0x1a0d, 0x1a0d, 0x1a0d, 0x1a37, 0x080c, 0x0d7d, 0xa56c,
-	0xa470, 0xa774, 0xa678, 0x9d86, 0x000c, 0x05b0, 0xa37c, 0xa280,
-	0x0498, 0xa584, 0xa488, 0xa78c, 0xa690, 0x9d86, 0x000c, 0x0560,
-	0xa394, 0xa298, 0x0448, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8, 0x9d86,
-	0x000c, 0x0510, 0xa3ac, 0xa2b0, 0x00f8, 0xa5b4, 0xa4b8, 0xa7bc,
-	0xa6c0, 0x9d86, 0x000c, 0x01c0, 0xa3c4, 0xa2c8, 0x00a8, 0xa5cc,
-	0xa4d0, 0xa7d4, 0xa6d8, 0x9d86, 0x000c, 0x0170, 0xa3dc, 0xa2e0,
-	0x0058, 0x9d86, 0x000e, 0x1130, 0x080c, 0x1e38, 0x1904, 0x1920,
-	0x900e, 0x0050, 0x080c, 0x0d7d, 0xab2e, 0xaa32, 0xad1e, 0xac22,
-	0xaf26, 0xae2a, 0x080c, 0x1e38, 0x0005, 0x6014, 0x2048, 0x6118,
-	0x810c, 0x810c, 0x810c, 0x81ff, 0x1118, 0xa887, 0x0001, 0x0008,
-	0xa986, 0x601b, 0x0002, 0xa974, 0xd1dc, 0x1108, 0x0005, 0xa934,
-	0xa88c, 0x9106, 0x1158, 0xa938, 0xa890, 0x9106, 0x1138, 0x601c,
-	0xc084, 0x601e, 0x2009, 0x0048, 0x0804, 0xac7c, 0x0005, 0x0126,
-	0x00c6, 0x2091, 0x2200, 0x00ce, 0x7908, 0x918c, 0x0007, 0x9186,
-	0x0000, 0x05b0, 0x9186, 0x0003, 0x0598, 0x6020, 0x6023, 0x0000,
-	0x0006, 0x2031, 0x0008, 0x00c6, 0x781f, 0x0808, 0x7808, 0xd09c,
-	0x0120, 0x080c, 0x13ae, 0x8631, 0x1db8, 0x00ce, 0x781f, 0x0800,
-	0x2031, 0x0168, 0x00c6, 0x7808, 0xd09c, 0x190c, 0x13ae, 0x00ce,
-	0x2001, 0x0038, 0x080c, 0x1b4f, 0x7930, 0x9186, 0x0040, 0x0160,
-	0x9186, 0x0042, 0x190c, 0x0d7d, 0x2001, 0x001e, 0x8001, 0x1df0,
-	0x8631, 0x1d40, 0x080c, 0x1b5e, 0x000e, 0x6022, 0x012e, 0x0005,
-	0x080c, 0x1b4b, 0x7827, 0x0015, 0x7828, 0x9c06, 0x1db8, 0x782b,
-	0x0000, 0x0ca0, 0x00f6, 0x2079, 0x0300, 0x7803, 0x0000, 0x78ab,
-	0x0004, 0x00fe, 0x080c, 0x74c8, 0x11b0, 0x2001, 0x0138, 0x2003,
-	0x0000, 0x2001, 0x0160, 0x2003, 0x0000, 0x2011, 0x012c, 0xa001,
-	0xa001, 0x8211, 0x1de0, 0x0081, 0x2001, 0x0386, 0x2003, 0x2020,
-	0x080c, 0x7569, 0x0005, 0x0479, 0x0039, 0x2001, 0x0160, 0x2502,
+	0x8318, 0x1f04, 0x0dcc, 0x2069, 0x1a99, 0x2019, 0x0050, 0x20a9,
+	0x0020, 0x7b26, 0x7a28, 0x226a, 0x8d68, 0x8318, 0x1f04, 0x0dd9,
+	0x0491, 0x002e, 0x003e, 0x00de, 0x015e, 0x2079, 0x1800, 0x7803,
+	0x0005, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x0180,
+	0x2001, 0x1a21, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b, 0x2004,
+	0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002, 0x2003, 0x1001,
+	0x080c, 0x5704, 0x1170, 0x080c, 0x0f20, 0x0110, 0x080c, 0x0e73,
+	0x080c, 0x5704, 0x1130, 0x2071, 0x1800, 0x2011, 0x8000, 0x080c,
+	0x0f34, 0x0c70, 0x0005, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007,
+	0x9086, 0x0001, 0x1120, 0x2001, 0x0015, 0x080c, 0xa88a, 0x2079,
+	0x0380, 0x2069, 0x1b03, 0x7818, 0x6802, 0x781c, 0x6806, 0x7840,
+	0x680a, 0x7844, 0x680e, 0x782c, 0x6812, 0x2019, 0x1b0e, 0x9016,
+	0x7808, 0xd09c, 0x0150, 0x7820, 0x201a, 0x8210, 0x8318, 0x8210,
+	0x9282, 0x0011, 0x0ea8, 0x2011, 0xdead, 0x6a2a, 0x7830, 0x681a,
+	0x7834, 0x681e, 0x7838, 0x6822, 0x783c, 0x6826, 0x7803, 0x0000,
+	0x2069, 0x1ac3, 0x901e, 0x20a9, 0x0020, 0x7b26, 0x7828, 0x206a,
+	0x8d68, 0x8318, 0x1f04, 0x0e4d, 0x2069, 0x1ae3, 0x2019, 0x00b0,
+	0x20a9, 0x0020, 0x7b26, 0x7828, 0x206a, 0x8d68, 0x8318, 0x1f04,
+	0x0e5a, 0x0005, 0x918c, 0x03ff, 0x2001, 0x0003, 0x2004, 0x9084,
+	0x0600, 0x1118, 0x918d, 0x6c00, 0x0010, 0x918d, 0x6400, 0x2001,
+	0x017f, 0x2102, 0x0005, 0x0026, 0x0126, 0x2011, 0x0080, 0x080c,
+	0x0f12, 0x20a9, 0x0900, 0x080c, 0x0f48, 0x2011, 0x0040, 0x080c,
+	0x0f12, 0x20a9, 0x0900, 0x080c, 0x0f48, 0x0c78, 0x0026, 0x080c,
+	0x0f20, 0x1188, 0x2011, 0x010e, 0x2214, 0x9294, 0x0007, 0x9296,
+	0x0007, 0x0118, 0x2011, 0x0947, 0x0010, 0x2011, 0x1b47, 0x080c,
+	0x0f34, 0x002e, 0x0005, 0x2011, 0x010e, 0x2214, 0x9294, 0x0007,
+	0x9296, 0x0007, 0x0118, 0x2011, 0xa880, 0x0010, 0x2011, 0x6840,
+	0xd0e4, 0x70f3, 0x0000, 0x1128, 0x70f3, 0x0fa0, 0x080c, 0x0f25,
+	0x002e, 0x0005, 0x0026, 0x080c, 0x0f20, 0x0148, 0xd0a4, 0x1138,
+	0x2011, 0xcdd5, 0x0010, 0x2011, 0x0080, 0x080c, 0x0f25, 0x002e,
+	0x0005, 0x0026, 0x70f3, 0x0000, 0x080c, 0x0f20, 0x1130, 0x2011,
+	0x8040, 0x080c, 0x0f34, 0x002e, 0x0005, 0x080c, 0x2a27, 0x1118,
+	0x2011, 0xcdc5, 0x0010, 0x2011, 0xcac2, 0x080c, 0x0f25, 0x002e,
+	0x0005, 0x00e6, 0x0016, 0x0006, 0x2071, 0x1800, 0xd0b4, 0x70ec,
+	0x71e8, 0x1118, 0xc0e4, 0xc1f4, 0x0050, 0x0006, 0x3b00, 0x9084,
+	0xff3e, 0x20d8, 0x000e, 0x70f3, 0x0000, 0xc0e5, 0xc1f5, 0x0099,
+	0x000e, 0x001e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0xd0e4,
+	0x70ec, 0x1110, 0xc0dc, 0x0008, 0xc0dd, 0x0016, 0x71e8, 0x0019,
+	0x001e, 0x00ee, 0x0005, 0x70ee, 0x71ea, 0x7000, 0x9084, 0x0007,
+	0x000b, 0x0005, 0x0ed8, 0x0eb2, 0x0eb2, 0x0e86, 0x0ec1, 0x0eb2,
+	0x0eb2, 0x0ec1, 0xc284, 0x0016, 0x3b08, 0x3a00, 0x9104, 0x918d,
+	0x00c1, 0x21d8, 0x9084, 0xff3e, 0x9205, 0x20d0, 0x001e, 0x0005,
+	0x2001, 0x183b, 0x2004, 0xd0dc, 0x0005, 0x9e86, 0x1800, 0x190c,
+	0x0d7d, 0x70ec, 0xd0e4, 0x0108, 0xc2e5, 0x72ee, 0xd0e4, 0x1118,
+	0x9294, 0x00c1, 0x08f9, 0x0005, 0x9e86, 0x1800, 0x190c, 0x0d7d,
+	0x70e8, 0xd0f4, 0x0108, 0xc2f5, 0x72ea, 0xd0f4, 0x1140, 0x9284,
+	0x8000, 0x8005, 0xc284, 0x9215, 0x9294, 0x00c1, 0x0861, 0x0005,
+	0x1d04, 0x0f48, 0x2091, 0x6000, 0x1f04, 0x0f48, 0x0005, 0x890e,
+	0x810e, 0x810f, 0x9194, 0x003f, 0x918c, 0xffc0, 0x0005, 0x0006,
+	0x2200, 0x914d, 0x894f, 0x894d, 0x894d, 0x000e, 0x0005, 0x01d6,
+	0x0146, 0x0036, 0x0096, 0x2061, 0x188d, 0x600b, 0x0000, 0x600f,
+	0x0000, 0x6003, 0x0000, 0x6007, 0x0000, 0x2009, 0xffc0, 0x2105,
+	0x0006, 0x2001, 0xaaaa, 0x200f, 0x2019, 0x5555, 0x9016, 0x2049,
+	0x0bff, 0xab02, 0xa001, 0xa001, 0xa800, 0x9306, 0x1138, 0x2105,
+	0x9306, 0x0120, 0x8210, 0x99c8, 0x0400, 0x0c98, 0x000e, 0x200f,
+	0x2001, 0x189d, 0x928a, 0x000e, 0x1638, 0x928a, 0x0006, 0x2011,
+	0x0006, 0x1210, 0x2011, 0x0000, 0x2202, 0x9006, 0x2008, 0x82ff,
+	0x01b0, 0x8200, 0x600a, 0x600f, 0xffff, 0x6003, 0x0002, 0x6007,
+	0x0000, 0x0026, 0x2019, 0x0010, 0x9280, 0x0001, 0x20e8, 0x21a0,
+	0x21a8, 0x4104, 0x8319, 0x1de0, 0x8211, 0x1da0, 0x002e, 0x009e,
+	0x003e, 0x014e, 0x01de, 0x0005, 0x2011, 0x000e, 0x08e8, 0x0016,
+	0x0026, 0x0096, 0x3348, 0x080c, 0x0f4f, 0x2100, 0x9300, 0x2098,
+	0x22e0, 0x009e, 0x002e, 0x001e, 0x0036, 0x3518, 0x20a9, 0x0001,
+	0x4002, 0x8007, 0x4004, 0x8319, 0x1dd8, 0x003e, 0x0005, 0x20e9,
+	0x0001, 0x71b8, 0x81ff, 0x11c0, 0x9006, 0x2009, 0x0200, 0x20a9,
+	0x0002, 0x9298, 0x0018, 0x23a0, 0x4001, 0x2009, 0x0700, 0x20a9,
+	0x0002, 0x9298, 0x0008, 0x23a0, 0x4001, 0x707c, 0x8007, 0x7180,
+	0x810f, 0x20a9, 0x0002, 0x4001, 0x9298, 0x000c, 0x23a0, 0x900e,
+	0x080c, 0x0d5d, 0x2001, 0x0000, 0x810f, 0x20a9, 0x0002, 0x4001,
+	0x0005, 0x89ff, 0x0140, 0xa804, 0xa807, 0x0000, 0x0006, 0x080c,
+	0x1079, 0x009e, 0x0cb0, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c,
+	0x10f2, 0x090c, 0x0d7d, 0x00ee, 0x0005, 0x0086, 0x00e6, 0x0006,
+	0x0026, 0x0036, 0x0126, 0x2091, 0x8000, 0x00c9, 0x2071, 0x1800,
+	0x73c0, 0x702c, 0x9016, 0x9045, 0x0158, 0x8210, 0x9906, 0x090c,
+	0x0d7d, 0x2300, 0x9202, 0x0120, 0x1a0c, 0x0d7d, 0xa000, 0x0c98,
+	0x012e, 0x003e, 0x002e, 0x000e, 0x00ee, 0x008e, 0x0005, 0x0086,
+	0x00e6, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x1910, 0x7010,
+	0x9005, 0x0140, 0x7018, 0x9045, 0x0128, 0x9906, 0x090c, 0x0d7d,
+	0xa000, 0x0cc8, 0x012e, 0x000e, 0x00ee, 0x008e, 0x0005, 0x00e6,
+	0x2071, 0x1800, 0x0126, 0x2091, 0x8000, 0x70c0, 0x8001, 0x0270,
+	0x70c2, 0x702c, 0x2048, 0x9085, 0x0001, 0xa800, 0x702e, 0xa803,
+	0x0000, 0xa807, 0x0000, 0x012e, 0x00ee, 0x0005, 0x904e, 0x0cd8,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x70c0, 0x90ca,
+	0x0020, 0x0268, 0x8001, 0x70c2, 0x702c, 0x2048, 0xa800, 0x702e,
+	0xa803, 0x0000, 0xa807, 0x0000, 0x012e, 0x00ee, 0x0005, 0x904e,
+	0x0cd8, 0x00e6, 0x0126, 0x2091, 0x8000, 0x0016, 0x890e, 0x810e,
+	0x810f, 0x9184, 0x003f, 0xa862, 0x9184, 0xffc0, 0xa85e, 0x001e,
+	0x0020, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x702c,
+	0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x8566,
+	0x012e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9026, 0x2009, 0x0000,
+	0x2049, 0x0400, 0x2900, 0x702e, 0x8940, 0x2800, 0xa802, 0xa95e,
+	0xa863, 0x0001, 0x8420, 0x9886, 0x0440, 0x0120, 0x2848, 0x9188,
+	0x0040, 0x0c90, 0x2071, 0x188d, 0x7000, 0x9005, 0x11a0, 0x2001,
+	0x0558, 0xa802, 0x2048, 0x2009, 0x5600, 0x8940, 0x2800, 0xa802,
+	0xa95e, 0xa863, 0x0001, 0x8420, 0x9886, 0x0800, 0x0120, 0x2848,
+	0x9188, 0x0040, 0x0c90, 0x2071, 0x188d, 0x7104, 0x7200, 0x82ff,
+	0x01d0, 0x7308, 0x8318, 0x831f, 0x831b, 0x831b, 0x7312, 0x8319,
+	0x2001, 0x0800, 0xa802, 0x2048, 0x8900, 0xa802, 0x2040, 0xa95e,
+	0xaa62, 0x8420, 0x2300, 0x9906, 0x0130, 0x2848, 0x9188, 0x0040,
+	0x9291, 0x0000, 0x0c88, 0xa803, 0x0000, 0x2071, 0x1800, 0x74be,
+	0x74c2, 0x0005, 0x00e6, 0x0016, 0x9984, 0xfc00, 0x01e8, 0x908c,
+	0xf800, 0x1168, 0x9982, 0x0400, 0x02b8, 0x9982, 0x0440, 0x0278,
+	0x9982, 0x0558, 0x0288, 0x9982, 0x0800, 0x1270, 0x0040, 0x9982,
+	0x0800, 0x0250, 0x2071, 0x188d, 0x7010, 0x9902, 0x1228, 0x9085,
+	0x0001, 0x001e, 0x00ee, 0x0005, 0x9006, 0x0cd8, 0x00e6, 0x2071,
+	0x1a20, 0x7007, 0x0000, 0x9006, 0x701e, 0x7022, 0x7002, 0x2071,
+	0x0000, 0x7010, 0x9085, 0x8044, 0x7012, 0x2071, 0x0080, 0x9006,
+	0x702b, 0x0060, 0x20a9, 0x0040, 0x7022, 0x1f04, 0x112c, 0x702b,
+	0x0060, 0x702b, 0x0020, 0x20a9, 0x0040, 0x7022, 0x1f04, 0x1135,
+	0x702b, 0x0020, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x00e6,
+	0xa06f, 0x0000, 0x2071, 0x1a20, 0x701c, 0x9088, 0x1a2a, 0x280a,
+	0x8000, 0x9084, 0x003f, 0x701e, 0x7120, 0x9106, 0x090c, 0x0d7d,
+	0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080, 0x00a9, 0x00fe,
+	0x00ee, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x00e6, 0x2071,
+	0x1a20, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080, 0x0021,
+	0x00fe, 0x00ee, 0x012e, 0x0005, 0x7004, 0x9086, 0x0000, 0x1110,
+	0x7007, 0x0006, 0x7000, 0x0002, 0x117e, 0x1301, 0x117c, 0x117c,
+	0x12f5, 0x12f5, 0x12f5, 0x12f5, 0x080c, 0x0d7d, 0x701c, 0x7120,
+	0x9106, 0x1148, 0x792c, 0x9184, 0x0001, 0x1120, 0xd1fc, 0x1110,
+	0x7007, 0x0000, 0x0005, 0x0096, 0x9180, 0x1a2a, 0x2004, 0x700a,
+	0x2048, 0x8108, 0x918c, 0x003f, 0x7122, 0x782b, 0x0026, 0xa88c,
+	0x7802, 0xa890, 0x7806, 0xa894, 0x780a, 0xa898, 0x780e, 0xa878,
+	0x700e, 0xa870, 0x7016, 0xa874, 0x701a, 0xa868, 0x009e, 0xd084,
+	0x0120, 0x7007, 0x0001, 0x0029, 0x0005, 0x7007, 0x0002, 0x00b1,
+	0x0005, 0x0016, 0x0026, 0x710c, 0x2011, 0x0040, 0x9182, 0x0040,
+	0x1210, 0x2110, 0x9006, 0x700e, 0x7212, 0x8203, 0x7812, 0x782b,
+	0x0020, 0x782b, 0x0041, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026,
+	0x0136, 0x0146, 0x0156, 0x7014, 0x20e0, 0x7018, 0x2098, 0x20e9,
+	0x0000, 0x20a1, 0x0088, 0x782b, 0x0026, 0x710c, 0x2011, 0x0040,
+	0x9182, 0x0040, 0x1210, 0x2110, 0x9006, 0x700e, 0x22a8, 0x4006,
+	0x8203, 0x7812, 0x782b, 0x0020, 0x3300, 0x701a, 0x782b, 0x0001,
+	0x015e, 0x014e, 0x013e, 0x002e, 0x001e, 0x0005, 0x2009, 0x1a20,
+	0x2104, 0xc095, 0x200a, 0x080c, 0x115b, 0x0005, 0x0016, 0x00e6,
+	0x2071, 0x1a20, 0x00f6, 0x2079, 0x0080, 0x792c, 0xd1bc, 0x190c,
+	0x0d76, 0x782b, 0x0002, 0xd1fc, 0x0120, 0x918c, 0x0700, 0x7004,
+	0x0023, 0x00fe, 0x00ee, 0x001e, 0x0005, 0x116c, 0x1214, 0x1248,
+	0x1320, 0x0d7d, 0x133b, 0x0d7d, 0x918c, 0x0700, 0x1550, 0x0136,
+	0x0146, 0x0156, 0x7014, 0x20e8, 0x7018, 0x20a0, 0x20e1, 0x0000,
+	0x2099, 0x0088, 0x782b, 0x0040, 0x7010, 0x20a8, 0x4005, 0x3400,
+	0x701a, 0x015e, 0x014e, 0x013e, 0x700c, 0x9005, 0x0578, 0x7800,
+	0x7802, 0x7804, 0x7806, 0x080c, 0x11b1, 0x0005, 0x7008, 0x0096,
+	0x2048, 0xa86f, 0x0100, 0x009e, 0x7007, 0x0000, 0x080c, 0x116c,
+	0x0005, 0x7008, 0x0096, 0x2048, 0xa86f, 0x0200, 0x009e, 0x0ca0,
+	0x918c, 0x0700, 0x1150, 0x700c, 0x9005, 0x0180, 0x7800, 0x7802,
+	0x7804, 0x7806, 0x080c, 0x11c6, 0x0005, 0x7008, 0x0096, 0x2048,
+	0xa86f, 0x0200, 0x009e, 0x7007, 0x0000, 0x0080, 0x0096, 0x7008,
+	0x2048, 0x7800, 0xa88e, 0x7804, 0xa892, 0x7808, 0xa896, 0x780c,
+	0xa89a, 0xa86f, 0x0100, 0x009e, 0x7007, 0x0000, 0x0096, 0x00d6,
+	0x7008, 0x2048, 0x2001, 0x18b9, 0x2004, 0x9906, 0x1128, 0xa89c,
+	0x080f, 0x00de, 0x009e, 0x00a0, 0x00de, 0x009e, 0x0096, 0x00d6,
+	0x7008, 0x2048, 0x0081, 0x0150, 0xa89c, 0x0086, 0x2940, 0x080f,
+	0x008e, 0x00de, 0x009e, 0x080c, 0x115b, 0x0005, 0x00de, 0x009e,
+	0x080c, 0x115b, 0x0005, 0xa8a8, 0xd08c, 0x0005, 0x0096, 0xa0a0,
+	0x904d, 0x090c, 0x0d7d, 0xa06c, 0x908e, 0x0100, 0x0130, 0xa87b,
+	0x0030, 0xa883, 0x0000, 0xa897, 0x4002, 0x080c, 0x6d93, 0xa09f,
+	0x0000, 0xa0a3, 0x0000, 0x2848, 0x080c, 0x1079, 0x009e, 0x0005,
+	0x00a6, 0xa0a0, 0x904d, 0x090c, 0x0d7d, 0xa06c, 0x908e, 0x0100,
+	0x0128, 0xa87b, 0x0001, 0xa883, 0x0000, 0x00c0, 0xa80c, 0x2050,
+	0xb004, 0x9005, 0x0198, 0xa80e, 0x2050, 0x8006, 0x8006, 0x8007,
+	0x908c, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0xa076, 0xa172,
+	0xb000, 0xa07a, 0x2810, 0x080c, 0x113c, 0x00e8, 0xa97c, 0xa894,
+	0x0016, 0x0006, 0x080c, 0x6d93, 0x000e, 0x001e, 0xd1fc, 0x1138,
+	0xd1f4, 0x0128, 0x00c6, 0x2060, 0x080c, 0xabf0, 0x00ce, 0x7008,
+	0x2048, 0xa89f, 0x0000, 0xa8a3, 0x0000, 0x080c, 0x1079, 0x7007,
+	0x0000, 0x080c, 0x115b, 0x00ae, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x782b, 0x1001, 0x7007, 0x0005, 0x7000, 0xc094, 0x7002, 0x012e,
+	0x0005, 0x0096, 0x2001, 0x192e, 0x204c, 0xa87c, 0x7812, 0xa88c,
+	0x7802, 0xa890, 0x7806, 0xa894, 0x780a, 0xa898, 0x780e, 0x782b,
+	0x0020, 0x0126, 0x2091, 0x8000, 0x782b, 0x0041, 0x7007, 0x0003,
+	0x7000, 0xc084, 0x7002, 0x2900, 0x700a, 0x012e, 0x009e, 0x0005,
+	0x20e1, 0x0000, 0x2099, 0x0088, 0x782b, 0x0040, 0x0096, 0x2001,
+	0x192e, 0x204c, 0xaa7c, 0x009e, 0x080c, 0x8c34, 0x2009, 0x188c,
+	0x2104, 0x9084, 0xfffc, 0x200a, 0x080c, 0x8aa4, 0x7007, 0x0000,
+	0x080c, 0x116c, 0x0005, 0x7007, 0x0000, 0x080c, 0x116c, 0x0005,
+	0x0126, 0x2091, 0x2200, 0x2079, 0x0300, 0x2071, 0x1a6a, 0x7003,
+	0x0000, 0x78bf, 0x00f6, 0x0041, 0x7807, 0x0007, 0x7803, 0x0000,
+	0x7803, 0x0001, 0x012e, 0x0005, 0x00c6, 0x7803, 0x0000, 0x2001,
+	0x0165, 0x2003, 0x4198, 0x7808, 0xd09c, 0x0118, 0x7820, 0x04e9,
+	0x0cd0, 0x2001, 0x1a6b, 0x2003, 0x0000, 0x78ab, 0x0004, 0x78ac,
+	0xd0ac, 0x1de8, 0x78ab, 0x0002, 0x7807, 0x0007, 0x7827, 0x0030,
+	0x782b, 0x0400, 0x7827, 0x0031, 0x782b, 0x1a79, 0x781f, 0xff00,
+	0x781b, 0xff00, 0x2001, 0x0200, 0x2004, 0xd0dc, 0x0110, 0x781f,
+	0x0303, 0x2061, 0x1a79, 0x602f, 0x1ddc, 0x2001, 0x181a, 0x2004,
+	0x9082, 0x1ddc, 0x6032, 0x603b, 0x1e7a, 0x602b, 0x1ab9, 0x6007,
+	0x1a99, 0x2061, 0x1a99, 0x606f, 0x193c, 0x2001, 0x1927, 0x2004,
+	0x607a, 0x783f, 0x3388, 0x00ce, 0x0005, 0x9086, 0x000d, 0x11d0,
+	0x7808, 0xd09c, 0x01b8, 0x7820, 0x0026, 0x2010, 0x080c, 0xc853,
+	0x0180, 0x2260, 0x6000, 0x9086, 0x0004, 0x1158, 0x0016, 0x6120,
+	0x9186, 0x0009, 0x0108, 0x0020, 0x2009, 0x004c, 0x080c, 0xac8d,
+	0x001e, 0x002e, 0x0005, 0x0126, 0x2091, 0x2200, 0x7908, 0x9184,
+	0x0070, 0x190c, 0x0d76, 0xd19c, 0x05a0, 0x7820, 0x908c, 0xf000,
+	0x0540, 0x2060, 0x6020, 0x9086, 0x0003, 0x1550, 0x6000, 0x9086,
+	0x0004, 0x1530, 0x6114, 0x2148, 0xa876, 0xa87a, 0xa867, 0x0103,
+	0x080c, 0x6bb5, 0x00b6, 0x6010, 0x2058, 0xba3c, 0x8211, 0x0208,
+	0xba3e, 0xb8d0, 0x9005, 0x190c, 0x676f, 0x00be, 0x6044, 0xd0fc,
+	0x190c, 0xa8c2, 0x080c, 0xac19, 0x7808, 0xd09c, 0x19b0, 0x012e,
+	0x0005, 0x908a, 0x0024, 0x1a0c, 0x0d7d, 0x002b, 0x012e, 0x0005,
+	0x04b0, 0x012e, 0x0005, 0x141f, 0x1445, 0x1475, 0x147a, 0x147e,
+	0x1483, 0x14ab, 0x14af, 0x14bd, 0x14c1, 0x141f, 0x158e, 0x1592,
+	0x15f7, 0x15fe, 0x141f, 0x15ff, 0x1600, 0x160b, 0x1612, 0x141f,
+	0x141f, 0x141f, 0x141f, 0x141f, 0x141f, 0x141f, 0x1485, 0x141f,
+	0x144d, 0x1472, 0x1439, 0x141f, 0x1459, 0x1423, 0x1421, 0x080c,
+	0x0d7d, 0x080c, 0x0d76, 0x080c, 0x161d, 0x2009, 0x1a78, 0x2104,
+	0x8000, 0x200a, 0x080c, 0x7f9c, 0x080c, 0x1adf, 0x0005, 0x6044,
+	0xd0fc, 0x190c, 0xa8c2, 0x2009, 0x0055, 0x080c, 0xac8d, 0x012e,
+	0x0005, 0x080c, 0x161d, 0x2060, 0x6044, 0xd0fc, 0x190c, 0xa8c2,
+	0x2009, 0x0055, 0x080c, 0xac8d, 0x0005, 0x2009, 0x0048, 0x080c,
+	0x161d, 0x2060, 0x080c, 0xac8d, 0x0005, 0x2009, 0x0054, 0x080c,
+	0x161d, 0x2060, 0x6044, 0xd0fc, 0x190c, 0xa8c2, 0x080c, 0xac8d,
+	0x0005, 0x080c, 0x161d, 0x2060, 0x0056, 0x0066, 0x080c, 0x161d,
+	0x2028, 0x080c, 0x161d, 0x2030, 0x0036, 0x0046, 0x2021, 0x0000,
+	0x2418, 0x2009, 0x0056, 0x080c, 0xac8d, 0x004e, 0x003e, 0x006e,
+	0x005e, 0x0005, 0x080c, 0x161d, 0x0005, 0x7004, 0xc085, 0xc0b5,
+	0x7006, 0x0005, 0x7004, 0xc085, 0x7006, 0x0005, 0x080c, 0x161d,
+	0x080c, 0x16e1, 0x0005, 0x080c, 0x0d7d, 0x080c, 0x161d, 0x2060,
+	0x6014, 0x0096, 0x2048, 0xa83b, 0xffff, 0x009e, 0x2009, 0x0048,
+	0x080c, 0xac8d, 0x2001, 0x015d, 0x2003, 0x0000, 0x2009, 0x03e8,
+	0x8109, 0x0160, 0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8, 0x2001,
+	0x0218, 0x2004, 0xd0ec, 0x1110, 0x080c, 0x1622, 0x2001, 0x0307,
+	0x2003, 0x8000, 0x0005, 0x7004, 0xc095, 0x7006, 0x0005, 0x080c,
+	0x161d, 0x2060, 0x6014, 0x0096, 0x2048, 0xa83b, 0xffff, 0x009e,
+	0x2009, 0x0048, 0x080c, 0xac8d, 0x0005, 0x080c, 0x161d, 0x080c,
+	0x0d7d, 0x080c, 0x161d, 0x080c, 0x1579, 0x7827, 0x0018, 0x79ac,
+	0xd1dc, 0x0904, 0x152a, 0x7827, 0x0015, 0x7828, 0x782b, 0x0000,
+	0x9065, 0x0140, 0x2001, 0x020d, 0x2003, 0x0050, 0x2003, 0x0020,
+	0x0804, 0x1530, 0x7004, 0x9005, 0x01c8, 0x1188, 0x78ab, 0x0004,
+	0x7827, 0x0018, 0x782b, 0x0000, 0xd1bc, 0x090c, 0x0d7d, 0x2001,
+	0x020d, 0x2003, 0x0050, 0x2003, 0x0020, 0x0804, 0x155e, 0x78ab,
+	0x0004, 0x7803, 0x0001, 0x080c, 0x1592, 0x0005, 0x7827, 0x0018,
+	0xa001, 0x7828, 0x7827, 0x0011, 0xa001, 0x7928, 0x9106, 0x0110,
+	0x79ac, 0x08e0, 0x00e6, 0x2071, 0x0200, 0x702c, 0xd0c4, 0x0140,
+	0x00ee, 0x080c, 0x1adf, 0x080c, 0x1354, 0x7803, 0x0001, 0x0005,
+	0x7037, 0x0001, 0xa001, 0x7150, 0x00ee, 0x918c, 0xff00, 0x9186,
+	0x0500, 0x0110, 0x79ac, 0x0810, 0x7004, 0xc09d, 0x7006, 0x78ab,
+	0x0004, 0x7803, 0x0001, 0x080c, 0x1592, 0x2001, 0x020d, 0x2003,
+	0x0020, 0x0005, 0x7828, 0x782b, 0x0000, 0x9065, 0x090c, 0x0d7d,
+	0x6014, 0x2048, 0x78ab, 0x0004, 0x918c, 0x0700, 0x01a8, 0x080c,
+	0x7f9c, 0x080c, 0x1adf, 0x080c, 0xc865, 0x0158, 0xa9ac, 0xa936,
+	0xa9b0, 0xa93a, 0xa83f, 0xffff, 0xa843, 0xffff, 0xa880, 0xc0bd,
+	0xa882, 0x080c, 0xc453, 0x0005, 0x6020, 0x9086, 0x0009, 0x1128,
+	0x2009, 0x004c, 0x080c, 0xac8d, 0x0048, 0x6010, 0x00b6, 0x2058,
+	0xb800, 0x00be, 0xd0bc, 0x6024, 0x190c, 0xcc66, 0x2029, 0x00c8,
+	0x8529, 0x0128, 0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8, 0x7dbc,
+	0x080c, 0xe727, 0xd5a4, 0x1118, 0x080c, 0x1622, 0x0005, 0x080c,
+	0x7f9c, 0x080c, 0x1adf, 0x0005, 0x781f, 0x0300, 0x7803, 0x0001,
+	0x0005, 0x0016, 0x0066, 0x0076, 0x00f6, 0x2079, 0x0300, 0x7908,
+	0x918c, 0x0007, 0x9186, 0x0003, 0x0120, 0x2001, 0x0016, 0x080c,
+	0x1693, 0x00fe, 0x007e, 0x006e, 0x001e, 0x0005, 0x7004, 0xc09d,
+	0x7006, 0x0005, 0x7104, 0x9184, 0x0004, 0x190c, 0x0d7d, 0xd184,
+	0x1189, 0xd19c, 0x0158, 0xc19c, 0x7106, 0x2001, 0x020d, 0x2003,
+	0x0050, 0x2003, 0x0020, 0x080c, 0x1622, 0x0005, 0x81ff, 0x190c,
+	0x0d7d, 0x0005, 0xc184, 0xd1b4, 0xc1b4, 0x7106, 0x0016, 0x00e6,
+	0x15f0, 0x2071, 0x0200, 0x080c, 0x16ce, 0x05c8, 0x6014, 0x9005,
+	0x05b0, 0x0096, 0x2048, 0xa864, 0x009e, 0x9084, 0x00ff, 0x908e,
+	0x0029, 0x0160, 0x908e, 0x0048, 0x1550, 0x601c, 0xd084, 0x11e0,
+	0x00f6, 0x2c78, 0x080c, 0x174b, 0x00fe, 0x00b0, 0x00f6, 0x2c78,
+	0x080c, 0x18d2, 0x00fe, 0x2009, 0x01f4, 0x8109, 0x0168, 0x2001,
+	0x0201, 0x2004, 0x9005, 0x0dc8, 0x2001, 0x0218, 0x2004, 0xd0ec,
+	0x1118, 0x080c, 0x1622, 0x0040, 0x2001, 0x020d, 0x2003, 0x0020,
+	0x080c, 0x1354, 0x7803, 0x0001, 0x00ee, 0x001e, 0x0005, 0x2001,
+	0x020d, 0x2003, 0x0050, 0x2003, 0x0020, 0x0461, 0x0ca8, 0x0429,
+	0x2060, 0x2009, 0x0053, 0x080c, 0xac8d, 0x0005, 0x0005, 0x0005,
+	0x00e1, 0x2008, 0x00d1, 0x0006, 0x7004, 0xc09d, 0x7006, 0x000e,
+	0x080c, 0x8f93, 0x0005, 0x0089, 0x9005, 0x0118, 0x080c, 0x8b94,
+	0x0cd0, 0x0005, 0x2001, 0x0036, 0x2009, 0x1820, 0x210c, 0x2011,
+	0x181f, 0x2214, 0x080c, 0x1693, 0x0005, 0x7808, 0xd09c, 0x0de8,
+	0x7820, 0x0005, 0x080c, 0x1579, 0x00d6, 0x2069, 0x0200, 0x2009,
+	0x01f4, 0x8109, 0x0510, 0x6804, 0x9005, 0x0dd8, 0x2001, 0x015d,
+	0x2003, 0x0000, 0x79bc, 0xd1a4, 0x1528, 0x79b8, 0x918c, 0x0fff,
+	0x0180, 0x9182, 0x0841, 0x1268, 0x9188, 0x0007, 0x918c, 0x0ff8,
+	0x810c, 0x810c, 0x810c, 0x080c, 0x1685, 0x6827, 0x0001, 0x8109,
+	0x1dd0, 0x04d9, 0x6827, 0x0002, 0x04c1, 0x6804, 0x9005, 0x1130,
+	0x682c, 0xd0e4, 0x1500, 0x6804, 0x9005, 0x0de8, 0x79b8, 0xd1ec,
+	0x1130, 0x08c0, 0x080c, 0x7f9c, 0x080c, 0x1adf, 0x0090, 0x7827,
+	0x0015, 0x782b, 0x0000, 0x7827, 0x0018, 0x782b, 0x0000, 0x2001,
+	0x020d, 0x2003, 0x0020, 0x2001, 0x0307, 0x2003, 0x0300, 0x7803,
+	0x0001, 0x00de, 0x0005, 0x682c, 0x9084, 0x5400, 0x9086, 0x5400,
+	0x0d30, 0x7827, 0x0015, 0x782b, 0x0000, 0x7803, 0x0001, 0x6800,
+	0x9085, 0x1800, 0x6802, 0x00de, 0x0005, 0x6824, 0x9084, 0x0003,
+	0x1de0, 0x0005, 0x2001, 0x0030, 0x2c08, 0x621c, 0x0021, 0x7830,
+	0x9086, 0x0041, 0x0005, 0x00f6, 0x2079, 0x0300, 0x0006, 0x7808,
+	0xd09c, 0x0140, 0x0016, 0x0026, 0x00c6, 0x080c, 0x13bb, 0x00ce,
+	0x002e, 0x001e, 0x000e, 0x0006, 0x7832, 0x7936, 0x7a3a, 0x781b,
+	0x8080, 0x0059, 0x1118, 0x000e, 0x00fe, 0x0005, 0x000e, 0x792c,
+	0x3900, 0x8000, 0x2004, 0x080c, 0x0d7d, 0x2009, 0xff00, 0x8109,
+	0x0120, 0x7818, 0xd0bc, 0x1dd8, 0x0005, 0x9085, 0x0001, 0x0005,
+	0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080, 0x0c79, 0x1108, 0x0005,
+	0x792c, 0x3900, 0x8000, 0x2004, 0x080c, 0x0d7d, 0x7037, 0x0001,
+	0x7150, 0x7037, 0x0002, 0x7050, 0x2060, 0xd1bc, 0x1110, 0x7054,
+	0x2060, 0x918c, 0xff00, 0x9186, 0x0500, 0x0110, 0x9085, 0x0001,
+	0x0005, 0x00e6, 0x0016, 0x2071, 0x0200, 0x0c41, 0x6124, 0xd1dc,
+	0x01f8, 0x701c, 0xd08c, 0x0904, 0x1740, 0x7017, 0x0000, 0x2001,
+	0x0264, 0x2004, 0xd0bc, 0x0904, 0x1740, 0x2001, 0x0268, 0x00c6,
+	0x2064, 0x6104, 0x6038, 0x00ce, 0x918e, 0x0039, 0x1904, 0x1740,
+	0x9c06, 0x15f0, 0x0126, 0x2091, 0x2600, 0x080c, 0x7ef4, 0x012e,
+	0x7358, 0x745c, 0x6014, 0x905d, 0x0598, 0x2b48, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x190c, 0xcc41, 0xab42, 0xac3e,
+	0x2001, 0x1869, 0x2004, 0xd0b4, 0x1170, 0x601c, 0xd0e4, 0x1158,
+	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1120, 0xa83b,
+	0x7fff, 0xa837, 0xffff, 0x080c, 0x1e9a, 0x1190, 0x080c, 0x192d,
+	0x2a00, 0xa816, 0x0130, 0x2800, 0xa80e, 0x2c05, 0xa80a, 0x2c00,
+	0xa812, 0x7037, 0x0020, 0x781f, 0x0300, 0x001e, 0x00ee, 0x0005,
+	0x7037, 0x0050, 0x7037, 0x0020, 0x001e, 0x00ee, 0x080c, 0x1622,
+	0x0005, 0x080c, 0x0d7d, 0x2cf0, 0x0126, 0x2091, 0x2200, 0x00c6,
+	0x3e60, 0x6014, 0x2048, 0x2940, 0x903e, 0x2730, 0xa864, 0x2068,
+	0xa81a, 0x9d84, 0x000f, 0x9088, 0x1e7a, 0x2165, 0x0002, 0x1776,
+	0x17e4, 0x1776, 0x1776, 0x177a, 0x17c5, 0x1776, 0x179a, 0x176f,
+	0x17db, 0x1776, 0x1776, 0x177f, 0x18d0, 0x17ae, 0x17a4, 0xa964,
+	0x918c, 0x00ff, 0x918e, 0x0048, 0x0904, 0x17db, 0x9085, 0x0001,
+	0x0804, 0x18c7, 0xa87c, 0xd0ac, 0x0dc8, 0x0804, 0x17eb, 0xa87c,
+	0xd0ac, 0x0da0, 0x0804, 0x1856, 0xa898, 0x901d, 0x1108, 0xab9c,
+	0x9016, 0xaab2, 0xaa3e, 0xaa42, 0x3e00, 0x9080, 0x0008, 0x2004,
+	0x9080, 0x915c, 0x2005, 0x9005, 0x090c, 0x0d7d, 0x2004, 0xa8ae,
+	0x0804, 0x18af, 0xa87c, 0xd0bc, 0x09c8, 0xa890, 0xa842, 0xa88c,
+	0xa83e, 0xa888, 0x0804, 0x17eb, 0xa87c, 0xd0bc, 0x0978, 0xa890,
+	0xa842, 0xa88c, 0xa83e, 0xa888, 0x0804, 0x1856, 0xa87c, 0xd0bc,
+	0x0928, 0xa890, 0xa842, 0xa88c, 0xa83e, 0xa804, 0x9045, 0x090c,
+	0x0d7d, 0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80, 0x1e7a, 0x2065,
+	0xa888, 0xd19c, 0x1904, 0x1856, 0x0430, 0xa87c, 0xd0ac, 0x0904,
+	0x1776, 0xa804, 0x9045, 0x090c, 0x0d7d, 0xa164, 0xa91a, 0x91ec,
+	0x000f, 0x9d80, 0x1e7a, 0x2065, 0x9006, 0xa842, 0xa83e, 0xd19c,
+	0x1904, 0x1856, 0x0080, 0xa87c, 0xd0ac, 0x0904, 0x1776, 0x9006,
+	0xa842, 0xa83e, 0x0804, 0x1856, 0xa87c, 0xd0ac, 0x0904, 0x1776,
+	0x9006, 0xa842, 0xa83e, 0x2c05, 0x908a, 0x0036, 0x1a0c, 0x0d7d,
+	0x9082, 0x001b, 0x0002, 0x180e, 0x180e, 0x1810, 0x180e, 0x180e,
+	0x180e, 0x181a, 0x180e, 0x180e, 0x180e, 0x1824, 0x180e, 0x180e,
+	0x180e, 0x182e, 0x180e, 0x180e, 0x180e, 0x1838, 0x180e, 0x180e,
+	0x180e, 0x1842, 0x180e, 0x180e, 0x180e, 0x184c, 0x080c, 0x0d7d,
+	0xa574, 0xa478, 0x9d86, 0x0024, 0x0904, 0x1784, 0xa37c, 0xa280,
+	0x0804, 0x18af, 0xa584, 0xa488, 0x9d86, 0x0024, 0x0904, 0x1784,
+	0xa38c, 0xa290, 0x0804, 0x18af, 0xa594, 0xa498, 0x9d86, 0x0024,
+	0x0904, 0x1784, 0xa39c, 0xa2a0, 0x0804, 0x18af, 0xa5a4, 0xa4a8,
+	0x9d86, 0x0024, 0x0904, 0x1784, 0xa3ac, 0xa2b0, 0x0804, 0x18af,
+	0xa5b4, 0xa4b8, 0x9d86, 0x0024, 0x0904, 0x1784, 0xa3bc, 0xa2c0,
+	0x0804, 0x18af, 0xa5c4, 0xa4c8, 0x9d86, 0x0024, 0x0904, 0x1784,
+	0xa3cc, 0xa2d0, 0x0804, 0x18af, 0xa5d4, 0xa4d8, 0x9d86, 0x0024,
+	0x0904, 0x1784, 0xa3dc, 0xa2e0, 0x0804, 0x18af, 0x2c05, 0x908a,
+	0x0034, 0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002, 0x1879, 0x1877,
+	0x1877, 0x1877, 0x1877, 0x1877, 0x1884, 0x1877, 0x1877, 0x1877,
+	0x1877, 0x1877, 0x188f, 0x1877, 0x1877, 0x1877, 0x1877, 0x1877,
+	0x189a, 0x1877, 0x1877, 0x1877, 0x1877, 0x1877, 0x18a5, 0x080c,
+	0x0d7d, 0xa56c, 0xa470, 0xa774, 0xa678, 0x9d86, 0x002c, 0x0904,
+	0x1784, 0xa37c, 0xa280, 0x0458, 0xa584, 0xa488, 0xa78c, 0xa690,
+	0x9d86, 0x002c, 0x0904, 0x1784, 0xa394, 0xa298, 0x0400, 0xa59c,
+	0xa4a0, 0xa7a4, 0xa6a8, 0x9d86, 0x002c, 0x0904, 0x1784, 0xa3ac,
+	0xa2b0, 0x00a8, 0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0, 0x9d86, 0x002c,
+	0x0904, 0x1784, 0xa3c4, 0xa2c8, 0x0050, 0xa5cc, 0xa4d0, 0xa7d4,
+	0xa6d8, 0x9d86, 0x002c, 0x0904, 0x1784, 0xa3dc, 0xa2e0, 0xab2e,
+	0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a, 0xa988, 0x8c60, 0x2c1d,
+	0xa8ac, 0xaab0, 0xa836, 0xaa3a, 0x8109, 0xa916, 0x1158, 0x3e60,
+	0x601c, 0xc085, 0x601e, 0xa87c, 0xc0dd, 0xa87e, 0x9006, 0x00ce,
+	0x012e, 0x0005, 0x2800, 0xa80e, 0xab0a, 0x2c00, 0xa812, 0x0c78,
+	0x0804, 0x1776, 0x2ff0, 0x0126, 0x2091, 0x2200, 0x00c6, 0x3e60,
+	0x6014, 0x2048, 0x2940, 0xa80e, 0x2061, 0x1e75, 0xa813, 0x1e75,
+	0x2c05, 0xa80a, 0xa964, 0xa91a, 0xa87c, 0xd0ac, 0x090c, 0x0d7d,
+	0x9006, 0xa842, 0xa83e, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0d7d,
+	0xadcc, 0xacd0, 0xafd4, 0xaed8, 0xabdc, 0xaae0, 0xab2e, 0xaa32,
+	0xad1e, 0xac22, 0xaf26, 0xae2a, 0xa8ac, 0xaab0, 0xa836, 0xaa3a,
+	0xa988, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0008, 0x1120, 0x8109,
+	0xa916, 0x0128, 0x0078, 0x918a, 0x0002, 0xa916, 0x1158, 0x3e60,
+	0x601c, 0xc085, 0x601e, 0xa87c, 0xc0dd, 0xa87e, 0x9006, 0x00ce,
+	0x012e, 0x0005, 0xa804, 0x9045, 0x090c, 0x0d7d, 0xa80e, 0xa064,
+	0xa81a, 0x9084, 0x000f, 0x9080, 0x1e7a, 0x2015, 0x82ff, 0x090c,
+	0x0d7d, 0xaa12, 0x2205, 0xa80a, 0x0c10, 0x903e, 0x2730, 0xa880,
+	0xd0fc, 0x1190, 0x2d00, 0x0002, 0x1a57, 0x1984, 0x1984, 0x1a57,
+	0x1984, 0x1a51, 0x1a57, 0x1984, 0x19f4, 0x19f4, 0x19f4, 0x1a57,
+	0x19f4, 0x1a57, 0x1a4e, 0x19f4, 0xc0fc, 0xa882, 0xab2c, 0xaa30,
+	0xad1c, 0xac20, 0xdd9c, 0x0904, 0x1a59, 0x2c05, 0x908a, 0x0034,
+	0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002, 0x1970, 0x196e, 0x196e,
+	0x196e, 0x196e, 0x196e, 0x1974, 0x196e, 0x196e, 0x196e, 0x196e,
+	0x196e, 0x1978, 0x196e, 0x196e, 0x196e, 0x196e, 0x196e, 0x197c,
+	0x196e, 0x196e, 0x196e, 0x196e, 0x196e, 0x1980, 0x080c, 0x0d7d,
+	0xa774, 0xa678, 0x0804, 0x1a59, 0xa78c, 0xa690, 0x0804, 0x1a59,
+	0xa7a4, 0xa6a8, 0x0804, 0x1a59, 0xa7bc, 0xa6c0, 0x0804, 0x1a59,
+	0xa7d4, 0xa6d8, 0x0804, 0x1a59, 0xa898, 0x901d, 0x1108, 0xab9c,
+	0x9016, 0x2c05, 0x908a, 0x0036, 0x1a0c, 0x0d7d, 0x9082, 0x001b,
+	0x0002, 0x19ac, 0x19ac, 0x19ae, 0x19ac, 0x19ac, 0x19ac, 0x19b8,
+	0x19ac, 0x19ac, 0x19ac, 0x19c2, 0x19ac, 0x19ac, 0x19ac, 0x19cc,
+	0x19ac, 0x19ac, 0x19ac, 0x19d6, 0x19ac, 0x19ac, 0x19ac, 0x19e0,
+	0x19ac, 0x19ac, 0x19ac, 0x19ea, 0x080c, 0x0d7d, 0xa574, 0xa478,
+	0x9d86, 0x0004, 0x0904, 0x1a59, 0xa37c, 0xa280, 0x0804, 0x1a59,
+	0xa584, 0xa488, 0x9d86, 0x0004, 0x0904, 0x1a59, 0xa38c, 0xa290,
+	0x0804, 0x1a59, 0xa594, 0xa498, 0x9d86, 0x0004, 0x0904, 0x1a59,
+	0xa39c, 0xa2a0, 0x0804, 0x1a59, 0xa5a4, 0xa4a8, 0x9d86, 0x0004,
+	0x0904, 0x1a59, 0xa3ac, 0xa2b0, 0x0804, 0x1a59, 0xa5b4, 0xa4b8,
+	0x9d86, 0x0004, 0x0904, 0x1a59, 0xa3bc, 0xa2c0, 0x0804, 0x1a59,
+	0xa5c4, 0xa4c8, 0x9d86, 0x0004, 0x0904, 0x1a59, 0xa3cc, 0xa2d0,
+	0x0804, 0x1a59, 0xa5d4, 0xa4d8, 0x9d86, 0x0004, 0x0904, 0x1a59,
+	0xa3dc, 0xa2e0, 0x0804, 0x1a59, 0xa898, 0x901d, 0x1108, 0xab9c,
+	0x9016, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0d7d, 0x9082, 0x001b,
+	0x0002, 0x1a1c, 0x1a1a, 0x1a1a, 0x1a1a, 0x1a1a, 0x1a1a, 0x1a26,
+	0x1a1a, 0x1a1a, 0x1a1a, 0x1a1a, 0x1a1a, 0x1a30, 0x1a1a, 0x1a1a,
+	0x1a1a, 0x1a1a, 0x1a1a, 0x1a3a, 0x1a1a, 0x1a1a, 0x1a1a, 0x1a1a,
+	0x1a1a, 0x1a44, 0x080c, 0x0d7d, 0xa56c, 0xa470, 0xa774, 0xa678,
+	0x9d86, 0x000c, 0x05b0, 0xa37c, 0xa280, 0x0498, 0xa584, 0xa488,
+	0xa78c, 0xa690, 0x9d86, 0x000c, 0x0560, 0xa394, 0xa298, 0x0448,
+	0xa59c, 0xa4a0, 0xa7a4, 0xa6a8, 0x9d86, 0x000c, 0x0510, 0xa3ac,
+	0xa2b0, 0x00f8, 0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0, 0x9d86, 0x000c,
+	0x01c0, 0xa3c4, 0xa2c8, 0x00a8, 0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8,
+	0x9d86, 0x000c, 0x0170, 0xa3dc, 0xa2e0, 0x0058, 0x9d86, 0x000e,
+	0x1130, 0x080c, 0x1e50, 0x1904, 0x192d, 0x900e, 0x0050, 0x080c,
+	0x0d7d, 0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a, 0x080c,
+	0x1e50, 0x0005, 0x6014, 0x2048, 0x6118, 0x810c, 0x810c, 0x810c,
+	0x81ff, 0x1118, 0xa887, 0x0001, 0x0008, 0xa986, 0x601b, 0x0002,
+	0xa874, 0x9084, 0x00ff, 0x9084, 0x0008, 0x0150, 0x00e9, 0x6000,
+	0x9086, 0x0004, 0x1120, 0x2009, 0x0048, 0x080c, 0xac8d, 0x0005,
+	0xa974, 0xd1dc, 0x1108, 0x0005, 0xa934, 0xa88c, 0x9106, 0x1158,
+	0xa938, 0xa890, 0x9106, 0x1138, 0x601c, 0xc084, 0x601e, 0x2009,
+	0x0048, 0x0804, 0xac8d, 0x0005, 0x0126, 0x00c6, 0x2091, 0x2200,
+	0x00ce, 0x7908, 0x918c, 0x0007, 0x9186, 0x0000, 0x05b0, 0x9186,
+	0x0003, 0x0598, 0x6020, 0x6023, 0x0000, 0x0006, 0x2031, 0x0008,
+	0x00c6, 0x781f, 0x0808, 0x7808, 0xd09c, 0x0120, 0x080c, 0x13bb,
+	0x8631, 0x1db8, 0x00ce, 0x781f, 0x0800, 0x2031, 0x0168, 0x00c6,
+	0x7808, 0xd09c, 0x190c, 0x13bb, 0x00ce, 0x2001, 0x0038, 0x080c,
+	0x1b67, 0x7930, 0x9186, 0x0040, 0x0160, 0x9186, 0x0042, 0x190c,
+	0x0d7d, 0x2001, 0x001e, 0x8001, 0x1df0, 0x8631, 0x1d40, 0x080c,
+	0x1b76, 0x000e, 0x6022, 0x012e, 0x0005, 0x080c, 0x1b63, 0x7827,
+	0x0015, 0x7828, 0x9c06, 0x1db8, 0x782b, 0x0000, 0x0ca0, 0x00f6,
+	0x2079, 0x0300, 0x7803, 0x0000, 0x78ab, 0x0004, 0x00fe, 0x080c,
+	0x74ec, 0x1188, 0x2001, 0x0138, 0x2003, 0x0000, 0x2001, 0x0160,
+	0x2003, 0x0000, 0x2011, 0x012c, 0xa001, 0xa001, 0x8211, 0x1de0,
+	0x0059, 0x0804, 0x7591, 0x0479, 0x0039, 0x2001, 0x0160, 0x2502,
 	0x2001, 0x0138, 0x2202, 0x0005, 0x00e6, 0x2071, 0x0200, 0x080c,
-	0x2a1b, 0x2009, 0x003c, 0x080c, 0x21c1, 0x2001, 0x015d, 0x2003,
-	0x0000, 0x7000, 0x9084, 0x003c, 0x1de0, 0x080c, 0x8532, 0x70a0,
+	0x2a3b, 0x2009, 0x003c, 0x080c, 0x21d9, 0x2001, 0x015d, 0x2003,
+	0x0000, 0x7000, 0x9084, 0x003c, 0x1de0, 0x080c, 0x8566, 0x70a0,
 	0x70a2, 0x7098, 0x709a, 0x709c, 0x709e, 0x2001, 0x020d, 0x2003,
-	0x0020, 0x00f6, 0x2079, 0x0300, 0x080c, 0x1347, 0x7803, 0x0001,
+	0x0020, 0x00f6, 0x2079, 0x0300, 0x080c, 0x1354, 0x7803, 0x0001,
 	0x00fe, 0x00ee, 0x0005, 0x2001, 0x0138, 0x2014, 0x2003, 0x0000,
-	0x2001, 0x0160, 0x202c, 0x2003, 0x0000, 0x080c, 0x74c8, 0x1108,
+	0x2001, 0x0160, 0x202c, 0x2003, 0x0000, 0x080c, 0x74ec, 0x1108,
 	0x0005, 0x2021, 0x0260, 0x2001, 0x0141, 0x201c, 0xd3dc, 0x1168,
 	0x2001, 0x0109, 0x201c, 0x939c, 0x0048, 0x1160, 0x2001, 0x0111,
 	0x201c, 0x83ff, 0x1110, 0x8421, 0x1d70, 0x2001, 0x015d, 0x2003,
 	0x0000, 0x0005, 0x0046, 0x2021, 0x0019, 0x2003, 0x0048, 0xa001,
 	0xa001, 0x201c, 0x939c, 0x0048, 0x0120, 0x8421, 0x1db0, 0x004e,
 	0x0c60, 0x004e, 0x0c40, 0x601c, 0xc084, 0x601e, 0x0005, 0x2c08,
-	0x621c, 0x080c, 0x1686, 0x7930, 0x0005, 0x2c08, 0x621c, 0x080c,
-	0x16b3, 0x7930, 0x0005, 0x8001, 0x1df0, 0x0005, 0x2031, 0x0005,
+	0x621c, 0x080c, 0x1693, 0x7930, 0x0005, 0x2c08, 0x621c, 0x080c,
+	0x16c0, 0x7930, 0x0005, 0x8001, 0x1df0, 0x0005, 0x2031, 0x0005,
 	0x781c, 0x9084, 0x0007, 0x0170, 0x2001, 0x0038, 0x0c41, 0x9186,
-	0x0040, 0x0904, 0x1bbc, 0x2001, 0x001e, 0x0c69, 0x8631, 0x1d80,
+	0x0040, 0x0904, 0x1bd4, 0x2001, 0x001e, 0x0c69, 0x8631, 0x1d80,
 	0x080c, 0x0d7d, 0x781f, 0x0202, 0x2001, 0x015d, 0x2003, 0x0000,
 	0x2001, 0x0b10, 0x0c01, 0x781c, 0xd084, 0x0110, 0x0861, 0x04e0,
 	0x2001, 0x0030, 0x0891, 0x9186, 0x0040, 0x0568, 0x781c, 0xd084,
 	0x1da8, 0x781f, 0x0101, 0x2001, 0x0014, 0x0869, 0x2001, 0x0037,
-	0x0821, 0x9186, 0x0040, 0x0140, 0x2001, 0x0030, 0x080c, 0x1b55,
+	0x0821, 0x9186, 0x0040, 0x0140, 0x2001, 0x0030, 0x080c, 0x1b6d,
 	0x9186, 0x0040, 0x190c, 0x0d7d, 0x00d6, 0x2069, 0x0200, 0x692c,
 	0xd1f4, 0x1170, 0xd1c4, 0x0160, 0xd19c, 0x0130, 0x6800, 0x9085,
 	0x1800, 0x6802, 0x00de, 0x0080, 0x6908, 0x9184, 0x0007, 0x1db0,
@@ -684,42 +687,42 @@
 	0xa001, 0xa001, 0x781f, 0x0200, 0x0005, 0x0126, 0x2091, 0x2400,
 	0x2079, 0x0380, 0x2001, 0x19e6, 0x2070, 0x012e, 0x0005, 0x2cf0,
 	0x0126, 0x2091, 0x2400, 0x3e60, 0x6014, 0x2048, 0xa964, 0xa91a,
-	0x918c, 0x00ff, 0x9184, 0x000f, 0x0002, 0x1bf1, 0x1bf1, 0x1bf1,
-	0x1bf3, 0x1bf1, 0x1bf1, 0x1bf1, 0x1bf1, 0x1be5, 0x1bfb, 0x1bf1,
-	0x1bf7, 0x1bf1, 0x1bf1, 0x1bf1, 0x1bf1, 0x9086, 0x0008, 0x1148,
-	0xa87c, 0xd0b4, 0x0904, 0x1d6b, 0x2011, 0x1e5d, 0x2205, 0xab88,
+	0x918c, 0x00ff, 0x9184, 0x000f, 0x0002, 0x1c09, 0x1c09, 0x1c09,
+	0x1c0b, 0x1c09, 0x1c09, 0x1c09, 0x1c09, 0x1bfd, 0x1c13, 0x1c09,
+	0x1c0f, 0x1c09, 0x1c09, 0x1c09, 0x1c09, 0x9086, 0x0008, 0x1148,
+	0xa87c, 0xd0b4, 0x0904, 0x1d83, 0x2011, 0x1e75, 0x2205, 0xab88,
 	0x00a8, 0x080c, 0x0d7d, 0x9186, 0x0013, 0x0128, 0x0cd0, 0x9186,
-	0x001b, 0x0108, 0x0cb0, 0xa87c, 0xd0b4, 0x0904, 0x1d6b, 0x9184,
-	0x000f, 0x9080, 0x1e62, 0x2015, 0x2205, 0xab88, 0x2908, 0xa80a,
+	0x001b, 0x0108, 0x0cb0, 0xa87c, 0xd0b4, 0x0904, 0x1d83, 0x9184,
+	0x000f, 0x9080, 0x1e7a, 0x2015, 0x2205, 0xab88, 0x2908, 0xa80a,
 	0xa90e, 0xaa12, 0xab16, 0x9006, 0xa842, 0xa83e, 0x012e, 0x0005,
 	0x2cf0, 0x0126, 0x2091, 0x2400, 0x3e60, 0x6014, 0x2048, 0xa88c,
 	0xa990, 0xaaac, 0xabb0, 0xaa36, 0xab3a, 0xa83e, 0xa942, 0xa846,
 	0xa94a, 0xa964, 0x918c, 0x00ff, 0x9186, 0x001e, 0x0198, 0x2940,
-	0xa064, 0xa81a, 0x90ec, 0x000f, 0x9d80, 0x1e62, 0x2065, 0x2c05,
+	0xa064, 0xa81a, 0x90ec, 0x000f, 0x9d80, 0x1e7a, 0x2065, 0x2c05,
 	0x2808, 0x2c10, 0xab88, 0xa80a, 0xa90e, 0xaa12, 0xab16, 0x012e,
 	0x3e60, 0x0005, 0xa804, 0x2040, 0x0c58, 0x2cf0, 0x0126, 0x2091,
 	0x2400, 0x3e60, 0x6014, 0x2048, 0xa97c, 0x2950, 0xd1dc, 0x1904,
-	0x1d35, 0xc1dd, 0xa97e, 0x9006, 0xa842, 0xa83e, 0xa988, 0x8109,
-	0xa916, 0xa964, 0xa91a, 0x9184, 0x000f, 0x9088, 0x1e62, 0x2145,
-	0x0002, 0x1c69, 0x1c77, 0x1c69, 0x1c69, 0x1c69, 0x1c6b, 0x1c69,
-	0x1c69, 0x1ccc, 0x1ccc, 0x1c69, 0x1c69, 0x1c69, 0x1cca, 0x1c69,
-	0x1c69, 0x080c, 0x0d7d, 0xa804, 0x2050, 0xb164, 0xa91a, 0x9184,
-	0x000f, 0x9080, 0x1e62, 0x2045, 0xd19c, 0x1904, 0x1ccc, 0x9036,
+	0x1d4d, 0xc1dd, 0xa97e, 0x9006, 0xa842, 0xa83e, 0xa988, 0x8109,
+	0xa916, 0xa964, 0xa91a, 0x9184, 0x000f, 0x9088, 0x1e7a, 0x2145,
+	0x0002, 0x1c81, 0x1c8f, 0x1c81, 0x1c81, 0x1c81, 0x1c83, 0x1c81,
+	0x1c81, 0x1ce4, 0x1ce4, 0x1c81, 0x1c81, 0x1c81, 0x1ce2, 0x1c81,
+	0x1c81, 0x080c, 0x0d7d, 0xa804, 0x2050, 0xb164, 0xa91a, 0x9184,
+	0x000f, 0x9080, 0x1e7a, 0x2045, 0xd19c, 0x1904, 0x1ce4, 0x9036,
 	0x2638, 0x2805, 0x908a, 0x0036, 0x1a0c, 0x0d7d, 0x9082, 0x001b,
-	0x0002, 0x1c9c, 0x1c9c, 0x1c9e, 0x1c9c, 0x1c9c, 0x1c9c, 0x1ca4,
-	0x1c9c, 0x1c9c, 0x1c9c, 0x1caa, 0x1c9c, 0x1c9c, 0x1c9c, 0x1cb0,
-	0x1c9c, 0x1c9c, 0x1c9c, 0x1cb6, 0x1c9c, 0x1c9c, 0x1c9c, 0x1cbc,
-	0x1c9c, 0x1c9c, 0x1c9c, 0x1cc2, 0x080c, 0x0d7d, 0xb574, 0xb478,
-	0xb37c, 0xb280, 0x0804, 0x1d11, 0xb584, 0xb488, 0xb38c, 0xb290,
-	0x0804, 0x1d11, 0xb594, 0xb498, 0xb39c, 0xb2a0, 0x0804, 0x1d11,
-	0xb5a4, 0xb4a8, 0xb3ac, 0xb2b0, 0x0804, 0x1d11, 0xb5b4, 0xb4b8,
-	0xb3bc, 0xb2c0, 0x0804, 0x1d11, 0xb5c4, 0xb4c8, 0xb3cc, 0xb2d0,
-	0x0804, 0x1d11, 0xb5d4, 0xb4d8, 0xb3dc, 0xb2e0, 0x0804, 0x1d11,
-	0x0804, 0x1d11, 0x080c, 0x0d7d, 0x2805, 0x908a, 0x0034, 0x1a0c,
-	0x0d7d, 0x9082, 0x001b, 0x0002, 0x1cef, 0x1ced, 0x1ced, 0x1ced,
-	0x1ced, 0x1ced, 0x1cf6, 0x1ced, 0x1ced, 0x1ced, 0x1ced, 0x1ced,
-	0x1cfd, 0x1ced, 0x1ced, 0x1ced, 0x1ced, 0x1ced, 0x1d04, 0x1ced,
-	0x1ced, 0x1ced, 0x1ced, 0x1ced, 0x1d0b, 0x080c, 0x0d7d, 0xb56c,
+	0x0002, 0x1cb4, 0x1cb4, 0x1cb6, 0x1cb4, 0x1cb4, 0x1cb4, 0x1cbc,
+	0x1cb4, 0x1cb4, 0x1cb4, 0x1cc2, 0x1cb4, 0x1cb4, 0x1cb4, 0x1cc8,
+	0x1cb4, 0x1cb4, 0x1cb4, 0x1cce, 0x1cb4, 0x1cb4, 0x1cb4, 0x1cd4,
+	0x1cb4, 0x1cb4, 0x1cb4, 0x1cda, 0x080c, 0x0d7d, 0xb574, 0xb478,
+	0xb37c, 0xb280, 0x0804, 0x1d29, 0xb584, 0xb488, 0xb38c, 0xb290,
+	0x0804, 0x1d29, 0xb594, 0xb498, 0xb39c, 0xb2a0, 0x0804, 0x1d29,
+	0xb5a4, 0xb4a8, 0xb3ac, 0xb2b0, 0x0804, 0x1d29, 0xb5b4, 0xb4b8,
+	0xb3bc, 0xb2c0, 0x0804, 0x1d29, 0xb5c4, 0xb4c8, 0xb3cc, 0xb2d0,
+	0x0804, 0x1d29, 0xb5d4, 0xb4d8, 0xb3dc, 0xb2e0, 0x0804, 0x1d29,
+	0x0804, 0x1d29, 0x080c, 0x0d7d, 0x2805, 0x908a, 0x0034, 0x1a0c,
+	0x0d7d, 0x9082, 0x001b, 0x0002, 0x1d07, 0x1d05, 0x1d05, 0x1d05,
+	0x1d05, 0x1d05, 0x1d0e, 0x1d05, 0x1d05, 0x1d05, 0x1d05, 0x1d05,
+	0x1d15, 0x1d05, 0x1d05, 0x1d05, 0x1d05, 0x1d05, 0x1d1c, 0x1d05,
+	0x1d05, 0x1d05, 0x1d05, 0x1d05, 0x1d23, 0x080c, 0x0d7d, 0xb56c,
 	0xb470, 0xb774, 0xb678, 0xb37c, 0xb280, 0x00d8, 0xb584, 0xb488,
 	0xb78c, 0xb690, 0xb394, 0xb298, 0x00a0, 0xb59c, 0xb4a0, 0xb7a4,
 	0xb6a8, 0xb3ac, 0xb2b0, 0x0068, 0xb5b4, 0xb4b8, 0xb7bc, 0xb6c0,
@@ -727,23 +730,23 @@
 	0xb2e0, 0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a, 0xa988,
 	0x8109, 0xa916, 0x1118, 0x9006, 0x012e, 0x0005, 0x8840, 0x2805,
 	0x9005, 0x1168, 0xb004, 0x9005, 0x090c, 0x0d7d, 0x2050, 0xb164,
-	0xa91a, 0x9184, 0x000f, 0x9080, 0x1e62, 0x2045, 0x2805, 0x2810,
+	0xa91a, 0x9184, 0x000f, 0x9080, 0x1e7a, 0x2045, 0x2805, 0x2810,
 	0x2a08, 0xa80a, 0xa90e, 0xaa12, 0x0c30, 0x3e60, 0x6344, 0xd3fc,
 	0x190c, 0x0d7d, 0xa93c, 0xaa40, 0xa844, 0x9106, 0x1118, 0xa848,
-	0x9206, 0x0508, 0x2958, 0xab48, 0xac44, 0x2940, 0x080c, 0x1e82,
+	0x9206, 0x0508, 0x2958, 0xab48, 0xac44, 0x2940, 0x080c, 0x1e9a,
 	0x1998, 0x2850, 0x2c40, 0xab14, 0xa880, 0xd0fc, 0x1140, 0xa810,
 	0x2005, 0xa80a, 0x2a00, 0xa80e, 0x2009, 0x8015, 0x0070, 0x00c6,
 	0x3e60, 0x6044, 0xc0a4, 0x9085, 0x8005, 0x6046, 0x00ce, 0x8319,
-	0xab16, 0x1904, 0x1d1e, 0x2009, 0x8005, 0x3e60, 0x6044, 0x9105,
-	0x6046, 0x0804, 0x1d1b, 0x080c, 0x0d7d, 0x00f6, 0x00e6, 0x0096,
+	0xab16, 0x1904, 0x1d36, 0x2009, 0x8005, 0x3e60, 0x6044, 0x9105,
+	0x6046, 0x0804, 0x1d33, 0x080c, 0x0d7d, 0x00f6, 0x00e6, 0x0096,
 	0x00c6, 0x0026, 0x704c, 0x9c06, 0x190c, 0x0d7d, 0x2079, 0x0090,
 	0x2001, 0x0105, 0x2003, 0x0010, 0x782b, 0x0004, 0x7057, 0x0000,
-	0x6014, 0x2048, 0x080c, 0xc832, 0x0118, 0xa880, 0xc0bd, 0xa882,
+	0x6014, 0x2048, 0x080c, 0xc865, 0x0118, 0xa880, 0xc0bd, 0xa882,
 	0x6020, 0x9086, 0x0006, 0x1170, 0x2061, 0x0100, 0x62c8, 0x2001,
 	0x00fa, 0x8001, 0x1df0, 0x60c8, 0x9206, 0x1dc0, 0x60c4, 0xa89a,
-	0x60c8, 0xa896, 0x704c, 0x2060, 0x00c6, 0x080c, 0xc430, 0x080c,
-	0xa888, 0x00ce, 0x704c, 0x9c06, 0x1150, 0x2009, 0x0040, 0x080c,
-	0x21c1, 0x080c, 0xa331, 0x2011, 0x0000, 0x080c, 0xa1bb, 0x002e,
+	0x60c8, 0xa896, 0x704c, 0x2060, 0x00c6, 0x080c, 0xc453, 0x080c,
+	0xa899, 0x00ce, 0x704c, 0x9c06, 0x1150, 0x2009, 0x0040, 0x080c,
+	0x21d9, 0x080c, 0xa33e, 0x2011, 0x0000, 0x080c, 0xa1c8, 0x002e,
 	0x00ce, 0x009e, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0090,
 	0x781c, 0x0006, 0x7818, 0x0006, 0x2079, 0x0100, 0x7a14, 0x9284,
 	0x1984, 0x9085, 0x0012, 0x7816, 0x2019, 0x1000, 0x8319, 0x090c,
@@ -751,75 +754,75 @@
 	0x0006, 0x0016, 0x79c4, 0x000e, 0x9103, 0x78c6, 0x000e, 0x78ca,
 	0x9284, 0x1984, 0x9085, 0x0012, 0x7816, 0x2079, 0x0090, 0x782b,
 	0x0008, 0x7057, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x00e6, 0x2071,
-	0x19e6, 0x7054, 0x9086, 0x0000, 0x0904, 0x1e33, 0x2079, 0x0090,
+	0x19e6, 0x7054, 0x9086, 0x0000, 0x0904, 0x1e4b, 0x2079, 0x0090,
 	0x2009, 0x0207, 0x210c, 0xd194, 0x01b8, 0x2009, 0x020c, 0x210c,
-	0x9184, 0x0003, 0x0188, 0x080c, 0xe733, 0x2001, 0x0133, 0x2004,
-	0x9005, 0x090c, 0x0d7d, 0x0016, 0x2009, 0x0040, 0x080c, 0x21c1,
+	0x9184, 0x0003, 0x0188, 0x080c, 0xe770, 0x2001, 0x0133, 0x2004,
+	0x9005, 0x090c, 0x0d7d, 0x0016, 0x2009, 0x0040, 0x080c, 0x21d9,
 	0x001e, 0x2001, 0x020c, 0x2102, 0x2009, 0x0206, 0x2104, 0x2009,
-	0x0203, 0x210c, 0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x21c1,
-	0x782c, 0xd0fc, 0x09a8, 0x080c, 0xa8a4, 0x782c, 0xd0fc, 0x1de8,
-	0x080c, 0xa888, 0x7054, 0x9086, 0x0000, 0x1950, 0x782b, 0x0004,
-	0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x21c1, 0x782b,
+	0x0203, 0x210c, 0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x21d9,
+	0x782c, 0xd0fc, 0x09a8, 0x080c, 0xa8b5, 0x782c, 0xd0fc, 0x1de8,
+	0x080c, 0xa899, 0x7054, 0x9086, 0x0000, 0x1950, 0x782b, 0x0004,
+	0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x21d9, 0x782b,
 	0x0002, 0x7057, 0x0000, 0x00ee, 0x00fe, 0x0005, 0x080c, 0x0d7d,
 	0x8c60, 0x2c05, 0x9005, 0x0110, 0x8a51, 0x0005, 0xa004, 0x9005,
-	0x0168, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x1e62,
+	0x0168, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x1e7a,
 	0x2065, 0x8cff, 0x090c, 0x0d7d, 0x8a51, 0x0005, 0x2050, 0x0005,
 	0x0000, 0x001d, 0x0021, 0x0025, 0x0029, 0x002d, 0x0031, 0x0035,
 	0x0000, 0x001b, 0x0021, 0x0027, 0x002d, 0x0033, 0x0000, 0x0000,
-	0x0023, 0x0000, 0x0000, 0x1e55, 0x1e51, 0x1e55, 0x1e55, 0x1e5f,
-	0x0000, 0x1e55, 0x1e5c, 0x1e5c, 0x1e59, 0x1e5c, 0x1e5c, 0x0000,
-	0x1e5f, 0x1e5c, 0x0000, 0x1e57, 0x1e57, 0x0000, 0x1e57, 0x1e5f,
-	0x0000, 0x1e57, 0x1e5d, 0x1e5d, 0x1e5d, 0x0000, 0x1e5d, 0x0000,
-	0x1e5f, 0x1e5d, 0x00c6, 0x00d6, 0x0086, 0xab42, 0xac3e, 0xa888,
-	0x9055, 0x0904, 0x2061, 0x2940, 0xa064, 0x90ec, 0x000f, 0x9084,
-	0x00ff, 0x9086, 0x0008, 0x1118, 0x2061, 0x1e5d, 0x00d0, 0x9de0,
-	0x1e62, 0x9d86, 0x0007, 0x0130, 0x9d86, 0x000e, 0x0118, 0x9d86,
+	0x0023, 0x0000, 0x0000, 0x1e6d, 0x1e69, 0x1e6d, 0x1e6d, 0x1e77,
+	0x0000, 0x1e6d, 0x1e74, 0x1e74, 0x1e71, 0x1e74, 0x1e74, 0x0000,
+	0x1e77, 0x1e74, 0x0000, 0x1e6f, 0x1e6f, 0x0000, 0x1e6f, 0x1e77,
+	0x0000, 0x1e6f, 0x1e75, 0x1e75, 0x1e75, 0x0000, 0x1e75, 0x0000,
+	0x1e77, 0x1e75, 0x00c6, 0x00d6, 0x0086, 0xab42, 0xac3e, 0xa888,
+	0x9055, 0x0904, 0x2079, 0x2940, 0xa064, 0x90ec, 0x000f, 0x9084,
+	0x00ff, 0x9086, 0x0008, 0x1118, 0x2061, 0x1e75, 0x00d0, 0x9de0,
+	0x1e7a, 0x9d86, 0x0007, 0x0130, 0x9d86, 0x000e, 0x0118, 0x9d86,
 	0x000f, 0x1120, 0xa08c, 0x9422, 0xa090, 0x931b, 0x2c05, 0x9065,
-	0x1140, 0x0310, 0x0804, 0x2061, 0xa004, 0x9045, 0x0904, 0x2061,
-	0x08d8, 0x2c05, 0x9005, 0x0904, 0x1f49, 0xdd9c, 0x1904, 0x1f05,
-	0x908a, 0x0036, 0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002, 0x1eda,
-	0x1eda, 0x1edc, 0x1eda, 0x1eda, 0x1eda, 0x1ee2, 0x1eda, 0x1eda,
-	0x1eda, 0x1ee8, 0x1eda, 0x1eda, 0x1eda, 0x1eee, 0x1eda, 0x1eda,
-	0x1eda, 0x1ef4, 0x1eda, 0x1eda, 0x1eda, 0x1efa, 0x1eda, 0x1eda,
-	0x1eda, 0x1f00, 0x080c, 0x0d7d, 0xa07c, 0x9422, 0xa080, 0x931b,
-	0x0804, 0x1f3f, 0xa08c, 0x9422, 0xa090, 0x931b, 0x0804, 0x1f3f,
-	0xa09c, 0x9422, 0xa0a0, 0x931b, 0x0804, 0x1f3f, 0xa0ac, 0x9422,
-	0xa0b0, 0x931b, 0x0804, 0x1f3f, 0xa0bc, 0x9422, 0xa0c0, 0x931b,
-	0x0804, 0x1f3f, 0xa0cc, 0x9422, 0xa0d0, 0x931b, 0x0804, 0x1f3f,
+	0x1140, 0x0310, 0x0804, 0x2079, 0xa004, 0x9045, 0x0904, 0x2079,
+	0x08d8, 0x2c05, 0x9005, 0x0904, 0x1f61, 0xdd9c, 0x1904, 0x1f1d,
+	0x908a, 0x0036, 0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002, 0x1ef2,
+	0x1ef2, 0x1ef4, 0x1ef2, 0x1ef2, 0x1ef2, 0x1efa, 0x1ef2, 0x1ef2,
+	0x1ef2, 0x1f00, 0x1ef2, 0x1ef2, 0x1ef2, 0x1f06, 0x1ef2, 0x1ef2,
+	0x1ef2, 0x1f0c, 0x1ef2, 0x1ef2, 0x1ef2, 0x1f12, 0x1ef2, 0x1ef2,
+	0x1ef2, 0x1f18, 0x080c, 0x0d7d, 0xa07c, 0x9422, 0xa080, 0x931b,
+	0x0804, 0x1f57, 0xa08c, 0x9422, 0xa090, 0x931b, 0x0804, 0x1f57,
+	0xa09c, 0x9422, 0xa0a0, 0x931b, 0x0804, 0x1f57, 0xa0ac, 0x9422,
+	0xa0b0, 0x931b, 0x0804, 0x1f57, 0xa0bc, 0x9422, 0xa0c0, 0x931b,
+	0x0804, 0x1f57, 0xa0cc, 0x9422, 0xa0d0, 0x931b, 0x0804, 0x1f57,
 	0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x04d0, 0x908a, 0x0034, 0x1a0c,
-	0x0d7d, 0x9082, 0x001b, 0x0002, 0x1f27, 0x1f25, 0x1f25, 0x1f25,
-	0x1f25, 0x1f25, 0x1f2c, 0x1f25, 0x1f25, 0x1f25, 0x1f25, 0x1f25,
-	0x1f31, 0x1f25, 0x1f25, 0x1f25, 0x1f25, 0x1f25, 0x1f36, 0x1f25,
-	0x1f25, 0x1f25, 0x1f25, 0x1f25, 0x1f3b, 0x080c, 0x0d7d, 0xa07c,
+	0x0d7d, 0x9082, 0x001b, 0x0002, 0x1f3f, 0x1f3d, 0x1f3d, 0x1f3d,
+	0x1f3d, 0x1f3d, 0x1f44, 0x1f3d, 0x1f3d, 0x1f3d, 0x1f3d, 0x1f3d,
+	0x1f49, 0x1f3d, 0x1f3d, 0x1f3d, 0x1f3d, 0x1f3d, 0x1f4e, 0x1f3d,
+	0x1f3d, 0x1f3d, 0x1f3d, 0x1f3d, 0x1f53, 0x080c, 0x0d7d, 0xa07c,
 	0x9422, 0xa080, 0x931b, 0x0098, 0xa094, 0x9422, 0xa098, 0x931b,
 	0x0070, 0xa0ac, 0x9422, 0xa0b0, 0x931b, 0x0048, 0xa0c4, 0x9422,
 	0xa0c8, 0x931b, 0x0020, 0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x0630,
-	0x2300, 0x9405, 0x0160, 0x8a51, 0x0904, 0x2061, 0x8c60, 0x0804,
-	0x1eb1, 0xa004, 0x9045, 0x0904, 0x2061, 0x0804, 0x1e8c, 0x8a51,
-	0x0904, 0x2061, 0x8c60, 0x2c05, 0x9005, 0x1158, 0xa004, 0x9045,
-	0x0904, 0x2061, 0xa064, 0x90ec, 0x000f, 0x9de0, 0x1e62, 0x2c05,
-	0x2060, 0xa880, 0xc0fc, 0xa882, 0x0804, 0x2056, 0x2c05, 0x8422,
+	0x2300, 0x9405, 0x0160, 0x8a51, 0x0904, 0x2079, 0x8c60, 0x0804,
+	0x1ec9, 0xa004, 0x9045, 0x0904, 0x2079, 0x0804, 0x1ea4, 0x8a51,
+	0x0904, 0x2079, 0x8c60, 0x2c05, 0x9005, 0x1158, 0xa004, 0x9045,
+	0x0904, 0x2079, 0xa064, 0x90ec, 0x000f, 0x9de0, 0x1e7a, 0x2c05,
+	0x2060, 0xa880, 0xc0fc, 0xa882, 0x0804, 0x206e, 0x2c05, 0x8422,
 	0x8420, 0x831a, 0x9399, 0x0000, 0xac2e, 0xab32, 0xdd9c, 0x1904,
-	0x1ff3, 0x9082, 0x001b, 0x0002, 0x1f8f, 0x1f8f, 0x1f91, 0x1f8f,
-	0x1f8f, 0x1f8f, 0x1f9f, 0x1f8f, 0x1f8f, 0x1f8f, 0x1fad, 0x1f8f,
-	0x1f8f, 0x1f8f, 0x1fbb, 0x1f8f, 0x1f8f, 0x1f8f, 0x1fc9, 0x1f8f,
-	0x1f8f, 0x1f8f, 0x1fd7, 0x1f8f, 0x1f8f, 0x1f8f, 0x1fe5, 0x080c,
+	0x200b, 0x9082, 0x001b, 0x0002, 0x1fa7, 0x1fa7, 0x1fa9, 0x1fa7,
+	0x1fa7, 0x1fa7, 0x1fb7, 0x1fa7, 0x1fa7, 0x1fa7, 0x1fc5, 0x1fa7,
+	0x1fa7, 0x1fa7, 0x1fd3, 0x1fa7, 0x1fa7, 0x1fa7, 0x1fe1, 0x1fa7,
+	0x1fa7, 0x1fa7, 0x1fef, 0x1fa7, 0x1fa7, 0x1fa7, 0x1ffd, 0x080c,
 	0x0d7d, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300, 0x911b, 0x0a0c,
-	0x0d7d, 0xa074, 0x9420, 0xa078, 0x9319, 0x0804, 0x2051, 0xa18c,
+	0x0d7d, 0xa074, 0x9420, 0xa078, 0x9319, 0x0804, 0x2069, 0xa18c,
 	0x2400, 0x9122, 0xa190, 0x2300, 0x911b, 0x0a0c, 0x0d7d, 0xa084,
-	0x9420, 0xa088, 0x9319, 0x0804, 0x2051, 0xa19c, 0x2400, 0x9122,
+	0x9420, 0xa088, 0x9319, 0x0804, 0x2069, 0xa19c, 0x2400, 0x9122,
 	0xa1a0, 0x2300, 0x911b, 0x0a0c, 0x0d7d, 0xa094, 0x9420, 0xa098,
-	0x9319, 0x0804, 0x2051, 0xa1ac, 0x2400, 0x9122, 0xa1b0, 0x2300,
+	0x9319, 0x0804, 0x2069, 0xa1ac, 0x2400, 0x9122, 0xa1b0, 0x2300,
 	0x911b, 0x0a0c, 0x0d7d, 0xa0a4, 0x9420, 0xa0a8, 0x9319, 0x0804,
-	0x2051, 0xa1bc, 0x2400, 0x9122, 0xa1c0, 0x2300, 0x911b, 0x0a0c,
-	0x0d7d, 0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0804, 0x2051, 0xa1cc,
+	0x2069, 0xa1bc, 0x2400, 0x9122, 0xa1c0, 0x2300, 0x911b, 0x0a0c,
+	0x0d7d, 0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0804, 0x2069, 0xa1cc,
 	0x2400, 0x9122, 0xa1d0, 0x2300, 0x911b, 0x0a0c, 0x0d7d, 0xa0c4,
-	0x9420, 0xa0c8, 0x9319, 0x0804, 0x2051, 0xa1dc, 0x2400, 0x9122,
+	0x9420, 0xa0c8, 0x9319, 0x0804, 0x2069, 0xa1dc, 0x2400, 0x9122,
 	0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0d7d, 0xa0d4, 0x9420, 0xa0d8,
-	0x9319, 0x0804, 0x2051, 0x9082, 0x001b, 0x0002, 0x2011, 0x200f,
-	0x200f, 0x200f, 0x200f, 0x200f, 0x201e, 0x200f, 0x200f, 0x200f,
-	0x200f, 0x200f, 0x202b, 0x200f, 0x200f, 0x200f, 0x200f, 0x200f,
-	0x2038, 0x200f, 0x200f, 0x200f, 0x200f, 0x200f, 0x2045, 0x080c,
+	0x9319, 0x0804, 0x2069, 0x9082, 0x001b, 0x0002, 0x2029, 0x2027,
+	0x2027, 0x2027, 0x2027, 0x2027, 0x2036, 0x2027, 0x2027, 0x2027,
+	0x2027, 0x2027, 0x2043, 0x2027, 0x2027, 0x2027, 0x2027, 0x2027,
+	0x2050, 0x2027, 0x2027, 0x2027, 0x2027, 0x2027, 0x205d, 0x080c,
 	0x0d7d, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300, 0x911b, 0x0a0c,
 	0x0d7d, 0xa06c, 0x9420, 0xa070, 0x9319, 0x0498, 0xa194, 0x2400,
 	0x9122, 0xa198, 0x2300, 0x911b, 0x0a0c, 0x0d7d, 0xa084, 0x9420,
@@ -836,26 +839,26 @@
 	0x000f, 0x9405, 0x001e, 0x00ce, 0x0005, 0x7803, 0x0003, 0x780f,
 	0x0000, 0x6004, 0x7812, 0x2c04, 0x7816, 0x9ce0, 0x0002, 0x918a,
 	0x0002, 0x1db8, 0x0005, 0x2001, 0x0005, 0x2004, 0xd0bc, 0x190c,
-	0x0d76, 0xd094, 0x0110, 0x080c, 0x11e9, 0x0005, 0x0126, 0x2091,
+	0x0d76, 0xd094, 0x0110, 0x080c, 0x11f6, 0x0005, 0x0126, 0x2091,
 	0x2600, 0x2079, 0x0200, 0x2071, 0x0260, 0x2069, 0x1800, 0x7817,
 	0x0000, 0x789b, 0x0814, 0x78a3, 0x0406, 0x789f, 0x0410, 0x2009,
 	0x013b, 0x200b, 0x0400, 0x781b, 0x0002, 0x783b, 0x001f, 0x7837,
 	0x0020, 0x7803, 0x1600, 0x012e, 0x0005, 0x2091, 0x2600, 0x781c,
-	0xd0a4, 0x190c, 0x21be, 0x7900, 0xd1dc, 0x1118, 0x9084, 0x0006,
-	0x001a, 0x9084, 0x000e, 0x0002, 0x20dc, 0x20d4, 0x7ed0, 0x20d4,
-	0x20d6, 0x20d6, 0x20d6, 0x20d6, 0x7eb6, 0x20d4, 0x20d8, 0x20d4,
-	0x20d6, 0x20d4, 0x20d6, 0x20d4, 0x080c, 0x0d7d, 0x0031, 0x0020,
-	0x080c, 0x7eb6, 0x080c, 0x7ed0, 0x0005, 0x0006, 0x0016, 0x0026,
-	0x080c, 0xe733, 0x7930, 0x9184, 0x0003, 0x0510, 0x080c, 0xa888,
+	0xd0a4, 0x190c, 0x21d6, 0x7900, 0xd1dc, 0x1118, 0x9084, 0x0006,
+	0x001a, 0x9084, 0x000e, 0x0002, 0x20f4, 0x20ec, 0x7ef4, 0x20ec,
+	0x20ee, 0x20ee, 0x20ee, 0x20ee, 0x7eda, 0x20ec, 0x20f0, 0x20ec,
+	0x20ee, 0x20ec, 0x20ee, 0x20ec, 0x080c, 0x0d7d, 0x0031, 0x0020,
+	0x080c, 0x7eda, 0x080c, 0x7ef4, 0x0005, 0x0006, 0x0016, 0x0026,
+	0x080c, 0xe770, 0x7930, 0x9184, 0x0003, 0x0510, 0x080c, 0xa899,
 	0x2001, 0x19f9, 0x2004, 0x9005, 0x01a0, 0x2001, 0x0133, 0x2004,
 	0x9005, 0x090c, 0x0d7d, 0x00c6, 0x2001, 0x19f9, 0x2064, 0x080c,
-	0xa8a4, 0x080c, 0xc430, 0x2009, 0x0040, 0x080c, 0x21c1, 0x00ce,
-	0x0408, 0x2009, 0x0040, 0x080c, 0x21c1, 0x080c, 0xa8a4, 0x00d0,
+	0xa8b5, 0x080c, 0xc453, 0x2009, 0x0040, 0x080c, 0x21d9, 0x00ce,
+	0x0408, 0x2009, 0x0040, 0x080c, 0x21d9, 0x080c, 0xa8b5, 0x00d0,
 	0x9184, 0x0014, 0x01a0, 0x6a00, 0x9286, 0x0003, 0x0160, 0x080c,
-	0x74c8, 0x1138, 0x080c, 0x77cc, 0x080c, 0x6024, 0x080c, 0x73f9,
-	0x0010, 0x080c, 0x5edf, 0x080c, 0x7f6e, 0x0041, 0x0018, 0x9184,
+	0x74ec, 0x1138, 0x080c, 0x77ef, 0x080c, 0x6044, 0x080c, 0x741d,
+	0x0010, 0x080c, 0x5eff, 0x080c, 0x7f92, 0x0041, 0x0018, 0x9184,
 	0x9540, 0x1dc8, 0x002e, 0x001e, 0x000e, 0x0005, 0x00e6, 0x0036,
-	0x0046, 0x0056, 0x2071, 0x1a6a, 0x080c, 0x1ac2, 0x005e, 0x004e,
+	0x0046, 0x0056, 0x2071, 0x1a6a, 0x080c, 0x1adf, 0x005e, 0x004e,
 	0x003e, 0x00ee, 0x0005, 0x0126, 0x2091, 0x2e00, 0x2071, 0x1800,
 	0x7128, 0x2001, 0x196e, 0x2102, 0x2001, 0x1976, 0x2102, 0x2001,
 	0x013b, 0x2102, 0x2079, 0x0200, 0x2001, 0x0201, 0x789e, 0x78a3,
@@ -877,18 +880,18 @@
 	0x0d76, 0x00f6, 0x2079, 0x0200, 0x7902, 0xa001, 0xa001, 0xa001,
 	0xa001, 0xa001, 0xa001, 0x7902, 0xa001, 0xa001, 0xa001, 0xa001,
 	0xa001, 0xa001, 0x00fe, 0x0005, 0x0126, 0x2091, 0x2800, 0x2061,
-	0x0100, 0x2071, 0x1800, 0x2009, 0x0000, 0x080c, 0x2a15, 0x080c,
-	0x292f, 0x2001, 0x199c, 0x2003, 0x0000, 0x2001, 0x199d, 0x2003,
-	0x0000, 0x080c, 0x2a86, 0x9006, 0x080c, 0x295e, 0x9006, 0x080c,
-	0x2941, 0x20a9, 0x0012, 0x1d04, 0x21f3, 0x2091, 0x6000, 0x1f04,
-	0x21f3, 0x602f, 0x0100, 0x602f, 0x0000, 0x6050, 0x9085, 0x0400,
-	0x9084, 0xdfff, 0x6052, 0x6224, 0x080c, 0x2a63, 0x080c, 0x264d,
-	0x2009, 0x00ef, 0x6132, 0x6136, 0x080c, 0x265d, 0x60e7, 0x0000,
+	0x0100, 0x2071, 0x1800, 0x2009, 0x0000, 0x080c, 0x2a35, 0x080c,
+	0x294b, 0x2001, 0x199c, 0x2003, 0x0700, 0x2001, 0x199d, 0x2003,
+	0x0700, 0x080c, 0x2aa6, 0x9006, 0x080c, 0x297a, 0x9006, 0x080c,
+	0x295d, 0x20a9, 0x0012, 0x1d04, 0x220b, 0x2091, 0x6000, 0x1f04,
+	0x220b, 0x602f, 0x0100, 0x602f, 0x0000, 0x6050, 0x9085, 0x0400,
+	0x9084, 0xdfff, 0x6052, 0x6224, 0x080c, 0x2a83, 0x080c, 0x2669,
+	0x2009, 0x00ef, 0x6132, 0x6136, 0x080c, 0x2679, 0x60e7, 0x0000,
 	0x61ea, 0x60e3, 0x0008, 0x604b, 0xf7f7, 0x6043, 0x0000, 0x602f,
 	0x0080, 0x602f, 0x0000, 0x6007, 0x349f, 0x00c6, 0x2061, 0x0140,
 	0x608b, 0x000b, 0x608f, 0x10b8, 0x6093, 0x0000, 0x6097, 0x0198,
 	0x00ce, 0x6004, 0x9085, 0x8000, 0x6006, 0x60bb, 0x0000, 0x20a9,
-	0x0018, 0x60bf, 0x0000, 0x1f04, 0x2231, 0x60bb, 0x0000, 0x60bf,
+	0x0018, 0x60bf, 0x0000, 0x1f04, 0x2249, 0x60bb, 0x0000, 0x60bf,
 	0x0108, 0x60bf, 0x0012, 0x60bf, 0x0405, 0x60bf, 0x0014, 0x60bf,
 	0x0320, 0x60bf, 0x0018, 0x601b, 0x00f0, 0x601f, 0x001e, 0x600f,
 	0x006b, 0x602b, 0x402c, 0x012e, 0x0005, 0x00f6, 0x2079, 0x0140,
@@ -900,542 +903,543 @@
 	0x1198, 0x9184, 0x5e2c, 0x1118, 0x9184, 0x0007, 0x00aa, 0x9195,
 	0x0004, 0x9284, 0x0007, 0x0082, 0x0016, 0x2001, 0x0387, 0x200c,
 	0xd1a4, 0x001e, 0x0d70, 0x0c98, 0x0016, 0x2001, 0x0387, 0x200c,
-	0xd1b4, 0x001e, 0x0d30, 0x0c58, 0x229f, 0x229c, 0x229c, 0x229c,
-	0x229e, 0x229c, 0x229c, 0x229c, 0x080c, 0x0d7d, 0x0029, 0x002e,
+	0xd1b4, 0x001e, 0x0d30, 0x0c58, 0x22b7, 0x22b4, 0x22b4, 0x22b4,
+	0x22b6, 0x22b4, 0x22b4, 0x22b4, 0x080c, 0x0d7d, 0x0029, 0x002e,
 	0x001e, 0x000e, 0x012e, 0x0005, 0x00a6, 0x6124, 0x6028, 0xd09c,
-	0x0118, 0xd19c, 0x1904, 0x2519, 0xd1f4, 0x190c, 0x0d76, 0x080c,
-	0x74c8, 0x0904, 0x22fc, 0x080c, 0xcf51, 0x1120, 0x7000, 0x9086,
-	0x0003, 0x0580, 0x6024, 0x9084, 0x1800, 0x0560, 0x080c, 0x74eb,
-	0x0118, 0x080c, 0x74d9, 0x1530, 0x2011, 0x0020, 0x080c, 0x2a63,
-	0x6043, 0x0000, 0x080c, 0xcf51, 0x0168, 0x080c, 0x74eb, 0x1150,
-	0x2001, 0x19a6, 0x2003, 0x0001, 0x6027, 0x1800, 0x080c, 0x733e,
-	0x0804, 0x251c, 0x70a4, 0x9005, 0x1150, 0x70a7, 0x0001, 0x00d6,
-	0x2069, 0x0140, 0x080c, 0x751f, 0x00de, 0x1904, 0x251c, 0x080c,
-	0x77d6, 0x0428, 0x080c, 0x74eb, 0x1590, 0x6024, 0x9084, 0x1800,
-	0x1108, 0x0468, 0x080c, 0x77d6, 0x080c, 0x77cc, 0x080c, 0x6024,
-	0x080c, 0x73f9, 0x0804, 0x2519, 0xd1ac, 0x1508, 0x6024, 0xd0dc,
+	0x0118, 0xd19c, 0x1904, 0x2531, 0xd1f4, 0x190c, 0x0d76, 0x080c,
+	0x74ec, 0x0904, 0x2314, 0x080c, 0xcf84, 0x1120, 0x7000, 0x9086,
+	0x0003, 0x0580, 0x6024, 0x9084, 0x1800, 0x0560, 0x080c, 0x750f,
+	0x0118, 0x080c, 0x74fd, 0x1530, 0x2011, 0x0020, 0x080c, 0x2a83,
+	0x6043, 0x0000, 0x080c, 0xcf84, 0x0168, 0x080c, 0x750f, 0x1150,
+	0x2001, 0x19a6, 0x2003, 0x0001, 0x6027, 0x1800, 0x080c, 0x7362,
+	0x0804, 0x2534, 0x70a4, 0x9005, 0x1150, 0x70a7, 0x0001, 0x00d6,
+	0x2069, 0x0140, 0x080c, 0x7543, 0x00de, 0x1904, 0x2534, 0x080c,
+	0x77f9, 0x0428, 0x080c, 0x750f, 0x1590, 0x6024, 0x9084, 0x1800,
+	0x1108, 0x0468, 0x080c, 0x77f9, 0x080c, 0x77ef, 0x080c, 0x6044,
+	0x080c, 0x741d, 0x0804, 0x2531, 0xd1ac, 0x1508, 0x6024, 0xd0dc,
 	0x1170, 0xd0e4, 0x1178, 0xd0d4, 0x1190, 0xd0cc, 0x0130, 0x7098,
-	0x9086, 0x0028, 0x1110, 0x080c, 0x76ad, 0x0804, 0x2519, 0x080c,
-	0x77d1, 0x0048, 0x2001, 0x197c, 0x2003, 0x0002, 0x0020, 0x080c,
-	0x760a, 0x0804, 0x2519, 0x080c, 0x7750, 0x0804, 0x2519, 0x6220,
-	0xd1bc, 0x0138, 0xd2bc, 0x1904, 0x257e, 0xd2b4, 0x1904, 0x2590,
-	0x0000, 0xd1ac, 0x0904, 0x2426, 0x0036, 0x6328, 0xc3bc, 0x632a,
-	0x003e, 0x080c, 0x74c8, 0x11d0, 0x2011, 0x0020, 0x080c, 0x2a63,
-	0x0006, 0x0026, 0x0036, 0x080c, 0x74e2, 0x1158, 0x080c, 0x77cc,
-	0x080c, 0x6024, 0x080c, 0x73f9, 0x003e, 0x002e, 0x000e, 0x00ae,
-	0x0005, 0x003e, 0x002e, 0x000e, 0x080c, 0x749c, 0x0016, 0x0046,
+	0x9086, 0x0028, 0x1110, 0x080c, 0x76d0, 0x0804, 0x2531, 0x080c,
+	0x77f4, 0x0048, 0x2001, 0x197c, 0x2003, 0x0002, 0x0020, 0x080c,
+	0x762d, 0x0804, 0x2531, 0x080c, 0x7773, 0x0804, 0x2531, 0x6220,
+	0xd1bc, 0x0138, 0xd2bc, 0x1904, 0x259a, 0xd2b4, 0x1904, 0x25ac,
+	0x0000, 0xd1ac, 0x0904, 0x243e, 0x0036, 0x6328, 0xc3bc, 0x632a,
+	0x003e, 0x080c, 0x74ec, 0x11d0, 0x2011, 0x0020, 0x080c, 0x2a83,
+	0x0006, 0x0026, 0x0036, 0x080c, 0x7506, 0x1158, 0x080c, 0x77ef,
+	0x080c, 0x6044, 0x080c, 0x741d, 0x003e, 0x002e, 0x000e, 0x00ae,
+	0x0005, 0x003e, 0x002e, 0x000e, 0x080c, 0x74c0, 0x0016, 0x0046,
 	0x00c6, 0x644c, 0x9486, 0xf0f0, 0x1138, 0x2061, 0x0100, 0x644a,
 	0x6043, 0x0090, 0x6043, 0x0010, 0x74da, 0x948c, 0xff00, 0x7038,
 	0xd084, 0x0178, 0x9186, 0xf800, 0x1160, 0x7048, 0xd084, 0x1148,
-	0xc085, 0x704a, 0x0036, 0x2418, 0x2011, 0x8016, 0x080c, 0x4b09,
-	0x003e, 0x080c, 0xcf4a, 0x1904, 0x23fd, 0x9196, 0xff00, 0x05a8,
+	0xc085, 0x704a, 0x0036, 0x2418, 0x2011, 0x8016, 0x080c, 0x4b29,
+	0x003e, 0x080c, 0xcf7d, 0x1904, 0x2415, 0x9196, 0xff00, 0x05a8,
 	0x7060, 0x9084, 0x00ff, 0x810f, 0x81ff, 0x0110, 0x9116, 0x0568,
-	0x7130, 0xd184, 0x1550, 0x080c, 0x335c, 0x0128, 0xc18d, 0x7132,
-	0x080c, 0x6a62, 0x1510, 0x6240, 0x9294, 0x0010, 0x0130, 0x6248,
+	0x7130, 0xd184, 0x1550, 0x080c, 0x337c, 0x0128, 0xc18d, 0x7132,
+	0x080c, 0x6a86, 0x1510, 0x6240, 0x9294, 0x0010, 0x0130, 0x6248,
 	0x9294, 0xff00, 0x9296, 0xff00, 0x01c0, 0x7030, 0xd08c, 0x0904,
-	0x23fd, 0x7038, 0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac,
-	0x1904, 0x23fd, 0xc1ad, 0x2102, 0x0036, 0x73d8, 0x2011, 0x8013,
-	0x080c, 0x4b09, 0x003e, 0x0804, 0x23fd, 0x7038, 0xd08c, 0x1140,
-	0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904, 0x23fd, 0xc1ad, 0x2102,
-	0x0036, 0x73d8, 0x2011, 0x8013, 0x080c, 0x4b09, 0x003e, 0x7130,
+	0x2415, 0x7038, 0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac,
+	0x1904, 0x2415, 0xc1ad, 0x2102, 0x0036, 0x73d8, 0x2011, 0x8013,
+	0x080c, 0x4b29, 0x003e, 0x0804, 0x2415, 0x7038, 0xd08c, 0x1140,
+	0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904, 0x2415, 0xc1ad, 0x2102,
+	0x0036, 0x73d8, 0x2011, 0x8013, 0x080c, 0x4b29, 0x003e, 0x7130,
 	0xc185, 0x7132, 0x2011, 0x1848, 0x220c, 0xd1a4, 0x01f0, 0x0016,
-	0x2009, 0x0001, 0x2011, 0x0100, 0x080c, 0x88ce, 0x2019, 0x000e,
-	0x00c6, 0x2061, 0x0000, 0x080c, 0xe249, 0x00ce, 0x9484, 0x00ff,
-	0x9080, 0x3368, 0x200d, 0x918c, 0xff00, 0x810f, 0x2120, 0x9006,
-	0x2009, 0x000e, 0x080c, 0xe2d9, 0x001e, 0x0016, 0x2009, 0x0002,
-	0x2019, 0x0004, 0x080c, 0x31b4, 0x001e, 0x0078, 0x0156, 0x00b6,
-	0x20a9, 0x007f, 0x900e, 0x080c, 0x6620, 0x1110, 0x080c, 0x603e,
-	0x8108, 0x1f04, 0x23f3, 0x00be, 0x015e, 0x00ce, 0x004e, 0x080c,
-	0xa888, 0x080c, 0xab50, 0x080c, 0xa8a4, 0x60e3, 0x0000, 0x001e,
+	0x2009, 0x0001, 0x2011, 0x0100, 0x080c, 0x8902, 0x2019, 0x000e,
+	0x00c6, 0x2061, 0x0000, 0x080c, 0xe286, 0x00ce, 0x9484, 0x00ff,
+	0x9080, 0x3388, 0x200d, 0x918c, 0xff00, 0x810f, 0x2120, 0x9006,
+	0x2009, 0x000e, 0x080c, 0xe316, 0x001e, 0x0016, 0x2009, 0x0002,
+	0x2019, 0x0004, 0x080c, 0x31d4, 0x001e, 0x0078, 0x0156, 0x00b6,
+	0x20a9, 0x007f, 0x900e, 0x080c, 0x6644, 0x1110, 0x080c, 0x605e,
+	0x8108, 0x1f04, 0x240b, 0x00be, 0x015e, 0x00ce, 0x004e, 0x080c,
+	0xa899, 0x080c, 0xab61, 0x080c, 0xa8b5, 0x60e3, 0x0000, 0x001e,
 	0x2001, 0x1800, 0x2014, 0x9296, 0x0004, 0x1170, 0xd19c, 0x11b0,
 	0x2011, 0x180c, 0x2214, 0xd29c, 0x1120, 0x6204, 0x9295, 0x0002,
 	0x6206, 0x6228, 0xc29d, 0x622a, 0x2003, 0x0001, 0x2001, 0x1826,
-	0x2003, 0x0000, 0x2011, 0x0020, 0x080c, 0x2a63, 0xd194, 0x0904,
-	0x2519, 0x0016, 0x080c, 0xa888, 0x6220, 0xd2b4, 0x0904, 0x24b4,
-	0x080c, 0x86d5, 0x080c, 0x9e16, 0x2011, 0x0004, 0x080c, 0x2a63,
-	0x00f6, 0x2019, 0x19f2, 0x2304, 0x907d, 0x0904, 0x2481, 0x7804,
+	0x2003, 0x0000, 0x2011, 0x0020, 0x080c, 0x2a83, 0xd194, 0x0904,
+	0x2531, 0x0016, 0x080c, 0xa899, 0x6220, 0xd2b4, 0x0904, 0x24cc,
+	0x080c, 0x8709, 0x080c, 0x9e4f, 0x2011, 0x0004, 0x080c, 0x2a83,
+	0x00f6, 0x2019, 0x19f2, 0x2304, 0x907d, 0x0904, 0x2499, 0x7804,
 	0x9086, 0x0032, 0x15f0, 0x00d6, 0x00c6, 0x00e6, 0x0096, 0x2069,
 	0x0140, 0x782c, 0x685e, 0x7808, 0x685a, 0x6043, 0x0002, 0x2001,
 	0x0003, 0x8001, 0x1df0, 0x6043, 0x0000, 0x2001, 0x003c, 0x8001,
-	0x1df0, 0x080c, 0x2a39, 0x2001, 0x001e, 0x8001, 0x0240, 0x20a9,
-	0x0009, 0x080c, 0x29f0, 0x6904, 0xd1dc, 0x1140, 0x0cb0, 0x2001,
-	0x0100, 0x080c, 0x2a29, 0x9006, 0x080c, 0x2a29, 0x080c, 0x95c6,
-	0x080c, 0xa8a4, 0x7814, 0x2048, 0xa867, 0x0103, 0x2f60, 0x080c,
-	0xabdf, 0x009e, 0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e, 0x00ae,
+	0x1df0, 0x080c, 0x2a59, 0x2001, 0x001e, 0x8001, 0x0240, 0x20a9,
+	0x0009, 0x080c, 0x2a10, 0x6904, 0xd1dc, 0x1140, 0x0cb0, 0x2001,
+	0x0100, 0x080c, 0x2a49, 0x9006, 0x080c, 0x2a49, 0x080c, 0x95ff,
+	0x080c, 0xa8b5, 0x7814, 0x2048, 0xa867, 0x0103, 0x2f60, 0x080c,
+	0xabf0, 0x009e, 0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e, 0x00ae,
 	0x0005, 0x00fe, 0x00d6, 0x2069, 0x0140, 0x6804, 0x9084, 0x4000,
-	0x0110, 0x080c, 0x2a39, 0x00de, 0x00c6, 0x2061, 0x19e6, 0x6034,
-	0x080c, 0xcf51, 0x0120, 0x909a, 0x0003, 0x1258, 0x0018, 0x909a,
-	0x00c8, 0x1238, 0x8000, 0x6036, 0x00ce, 0x080c, 0x9dee, 0x0804,
-	0x2516, 0x2061, 0x0100, 0x62c0, 0x080c, 0xa7b9, 0x2019, 0x19f2,
+	0x0110, 0x080c, 0x2a59, 0x00de, 0x00c6, 0x2061, 0x19e6, 0x6034,
+	0x080c, 0xcf84, 0x0120, 0x909a, 0x0003, 0x1258, 0x0018, 0x909a,
+	0x00c8, 0x1238, 0x8000, 0x6036, 0x00ce, 0x080c, 0x9e27, 0x0804,
+	0x252e, 0x2061, 0x0100, 0x62c0, 0x080c, 0xa7ca, 0x2019, 0x19f2,
 	0x2304, 0x9065, 0x0130, 0x6003, 0x0001, 0x2009, 0x0027, 0x080c,
-	0xac7c, 0x00ce, 0x0804, 0x2516, 0xd2bc, 0x0904, 0x24f9, 0x080c,
-	0x86e2, 0x2011, 0x0004, 0x080c, 0x2a63, 0x00d6, 0x2069, 0x0140,
-	0x6804, 0x9084, 0x4000, 0x0110, 0x080c, 0x2a39, 0x00de, 0x00c6,
-	0x2061, 0x19e6, 0x6050, 0x080c, 0xcf51, 0x0120, 0x909a, 0x0003,
+	0xac8d, 0x00ce, 0x0804, 0x252e, 0xd2bc, 0x0904, 0x2511, 0x080c,
+	0x8716, 0x2011, 0x0004, 0x080c, 0x2a83, 0x00d6, 0x2069, 0x0140,
+	0x6804, 0x9084, 0x4000, 0x0110, 0x080c, 0x2a59, 0x00de, 0x00c6,
+	0x2061, 0x19e6, 0x6050, 0x080c, 0xcf84, 0x0120, 0x909a, 0x0003,
 	0x1668, 0x0018, 0x909a, 0x00c8, 0x1648, 0x8000, 0x6052, 0x604c,
-	0x00ce, 0x9005, 0x05d8, 0x2009, 0x07d0, 0x080c, 0x86da, 0x9080,
+	0x00ce, 0x9005, 0x05d8, 0x2009, 0x07d0, 0x080c, 0x870e, 0x9080,
 	0x0008, 0x2004, 0x9086, 0x0006, 0x1138, 0x2009, 0x1984, 0x2011,
-	0x0012, 0x080c, 0x2a72, 0x0450, 0x9080, 0x0008, 0x2004, 0x9086,
-	0x0009, 0x0d98, 0x2009, 0x1984, 0x2011, 0x0016, 0x080c, 0x2a72,
-	0x00e8, 0x2011, 0x0004, 0x080c, 0x2a63, 0x00c0, 0x0036, 0x2019,
-	0x0001, 0x080c, 0xa0fa, 0x003e, 0x2019, 0x19f9, 0x2304, 0x9065,
+	0x0012, 0x080c, 0x2a92, 0x0450, 0x9080, 0x0008, 0x2004, 0x9086,
+	0x0009, 0x0d98, 0x2009, 0x1984, 0x2011, 0x0016, 0x080c, 0x2a92,
+	0x00e8, 0x2011, 0x0004, 0x080c, 0x2a83, 0x00c0, 0x0036, 0x2019,
+	0x0001, 0x080c, 0xa133, 0x003e, 0x2019, 0x19f9, 0x2304, 0x9065,
 	0x0160, 0x2009, 0x004f, 0x6020, 0x9086, 0x0009, 0x1110, 0x2009,
-	0x004f, 0x6003, 0x0003, 0x080c, 0xac7c, 0x00ce, 0x080c, 0xa8a4,
-	0x001e, 0xd19c, 0x0904, 0x2577, 0x7038, 0xd0ac, 0x1538, 0x0016,
-	0x0156, 0x2011, 0x0008, 0x080c, 0x2a63, 0x6050, 0xc0e5, 0x6052,
-	0x20a9, 0x0367, 0x1f04, 0x2544, 0x1d04, 0x252c, 0x080c, 0x8709,
-	0x6020, 0xd09c, 0x1db8, 0x00f6, 0x2079, 0x0100, 0x080c, 0x29a0,
-	0x00fe, 0x1d80, 0x6050, 0xc0e4, 0x6052, 0x2011, 0x0008, 0x080c,
-	0x2a63, 0x015e, 0x001e, 0x0498, 0x015e, 0x001e, 0x0016, 0x6028,
-	0xc09c, 0x602a, 0x080c, 0xa888, 0x080c, 0xab50, 0x080c, 0xa8a4,
-	0x60e3, 0x0000, 0x080c, 0xe712, 0x080c, 0xe72d, 0x080c, 0x56d9,
-	0xd0fc, 0x1138, 0x080c, 0xcf4a, 0x1120, 0x9085, 0x0001, 0x080c,
-	0x750f, 0x9006, 0x080c, 0x2a29, 0x2009, 0x0002, 0x080c, 0x2a15,
-	0x00e6, 0x2071, 0x1800, 0x7003, 0x0004, 0x080c, 0x0eb4, 0x00ee,
-	0x2011, 0x0008, 0x080c, 0x2a63, 0x080c, 0x0bc3, 0x001e, 0x918c,
-	0xffd0, 0x2110, 0x080c, 0x2a63, 0x00ae, 0x0005, 0x0016, 0x2001,
-	0x0387, 0x200c, 0xd1a4, 0x001e, 0x0904, 0x2329, 0x0016, 0x2009,
-	0x258a, 0x00c0, 0x2001, 0x0387, 0x2003, 0x1000, 0x001e, 0x0c38,
-	0x0016, 0x2001, 0x0387, 0x200c, 0xd1b4, 0x001e, 0x0904, 0x2329,
-	0x0016, 0x2009, 0x259c, 0x0030, 0x2001, 0x0387, 0x2003, 0x4000,
-	0x001e, 0x08a8, 0x6028, 0xc0bc, 0x602a, 0x2001, 0x0156, 0x2003,
-	0xbc91, 0x8000, 0x2003, 0xffff, 0x6043, 0x0001, 0x080c, 0x2a0f,
-	0x2011, 0x0080, 0x080c, 0x2a63, 0x6017, 0x0000, 0x6043, 0x0000,
-	0x0817, 0x0006, 0x0016, 0x0026, 0x0036, 0x00e6, 0x00f6, 0x0126,
-	0x2091, 0x8000, 0x2071, 0x1800, 0x71d0, 0x70d2, 0x9116, 0x0904,
-	0x260c, 0x81ff, 0x01a0, 0x2009, 0x0000, 0x080c, 0x2a15, 0x2011,
-	0x8011, 0x2019, 0x010e, 0x231c, 0x939e, 0x0007, 0x1118, 0x2019,
-	0x0001, 0x0010, 0x2019, 0x0000, 0x080c, 0x4b09, 0x0468, 0x2001,
-	0x19a7, 0x200c, 0x81ff, 0x1140, 0x2001, 0x0109, 0x2004, 0xd0b4,
-	0x0118, 0x2019, 0x0003, 0x0008, 0x2118, 0x2011, 0x8012, 0x080c,
-	0x4b09, 0x080c, 0x0eb4, 0x080c, 0x56d9, 0xd0fc, 0x11a8, 0x080c,
-	0xcf4a, 0x1190, 0x00c6, 0x080c, 0x26a8, 0x080c, 0xa888, 0x080c,
-	0xa055, 0x080c, 0xa8a4, 0x2061, 0x0100, 0x2019, 0x0028, 0x2009,
-	0x0002, 0x080c, 0x31b4, 0x00ce, 0x012e, 0x00fe, 0x00ee, 0x003e,
-	0x002e, 0x001e, 0x000e, 0x0005, 0x2028, 0x918c, 0x00ff, 0x2130,
-	0x9094, 0xff00, 0x11f0, 0x2011, 0x1837, 0x2214, 0xd2ac, 0x11c8,
-	0x81ff, 0x01e8, 0x2011, 0x181f, 0x2204, 0x9106, 0x1190, 0x2011,
-	0x1820, 0x2214, 0x9294, 0xff00, 0x9584, 0xff00, 0x9206, 0x1148,
-	0x2011, 0x1820, 0x2214, 0x9294, 0x00ff, 0x9584, 0x00ff, 0x9206,
-	0x1120, 0x2500, 0x080c, 0x81de, 0x0048, 0x9584, 0x00ff, 0x9080,
-	0x3368, 0x200d, 0x918c, 0xff00, 0x810f, 0x9006, 0x0005, 0x9080,
-	0x3368, 0x200d, 0x918c, 0x00ff, 0x0005, 0x00d6, 0x2069, 0x0140,
-	0x2001, 0x1818, 0x2003, 0x00ef, 0x20a9, 0x0010, 0x9006, 0x6852,
-	0x6856, 0x1f04, 0x2658, 0x00de, 0x0005, 0x0006, 0x00d6, 0x0026,
-	0x2069, 0x0140, 0x2001, 0x1818, 0x2102, 0x8114, 0x8214, 0x8214,
-	0x8214, 0x20a9, 0x0010, 0x6853, 0x0000, 0x9006, 0x82ff, 0x1128,
-	0x9184, 0x000f, 0x9080, 0xe741, 0x2005, 0x6856, 0x8211, 0x1f04,
-	0x266d, 0x002e, 0x00de, 0x000e, 0x0005, 0x00c6, 0x2061, 0x1800,
-	0x6030, 0x0110, 0xc09d, 0x0008, 0xc09c, 0x6032, 0x00ce, 0x0005,
-	0x0156, 0x00d6, 0x0026, 0x0016, 0x0006, 0x2069, 0x0140, 0x6980,
-	0x9116, 0x0180, 0x9112, 0x1230, 0x8212, 0x8210, 0x22a8, 0x2001,
-	0x0402, 0x0018, 0x22a8, 0x2001, 0x0404, 0x680e, 0x1f04, 0x269d,
-	0x680f, 0x0000, 0x000e, 0x001e, 0x002e, 0x00de, 0x015e, 0x0005,
-	0x080c, 0x56d5, 0xd0c4, 0x0150, 0xd0a4, 0x0140, 0x9006, 0x0046,
-	0x2020, 0x2009, 0x002e, 0x080c, 0xe2d9, 0x004e, 0x0005, 0x00f6,
-	0x0016, 0x0026, 0x2079, 0x0140, 0x78c4, 0xd0dc, 0x0904, 0x2714,
-	0x080c, 0x2990, 0x0660, 0x9084, 0x0700, 0x908e, 0x0600, 0x1120,
-	0x2011, 0x4000, 0x900e, 0x0458, 0x908e, 0x0500, 0x1120, 0x2011,
-	0x8000, 0x900e, 0x0420, 0x908e, 0x0400, 0x1120, 0x9016, 0x2009,
-	0x0001, 0x00e8, 0x908e, 0x0300, 0x1120, 0x9016, 0x2009, 0x0002,
-	0x00b0, 0x908e, 0x0200, 0x1120, 0x9016, 0x2009, 0x0004, 0x0078,
-	0x908e, 0x0100, 0x1548, 0x9016, 0x2009, 0x0008, 0x0040, 0x9084,
-	0x0700, 0x908e, 0x0300, 0x1500, 0x2011, 0x0030, 0x0058, 0x2300,
-	0x9080, 0x0020, 0x2018, 0x080c, 0x9148, 0x928c, 0xff00, 0x0110,
-	0x2011, 0x00ff, 0x2200, 0x8007, 0x9085, 0x004c, 0x78c2, 0x2009,
-	0x0138, 0x220a, 0x080c, 0x74c8, 0x1118, 0x2009, 0x196c, 0x220a,
-	0x002e, 0x001e, 0x00fe, 0x0005, 0x78c3, 0x0000, 0x0cc8, 0x0126,
-	0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x2001, 0x0170, 0x200c,
-	0x8000, 0x2014, 0x9184, 0x0003, 0x0110, 0x080c, 0x0d76, 0x002e,
-	0x001e, 0x000e, 0x012e, 0x0005, 0x2001, 0x0171, 0x2004, 0xd0dc,
-	0x0168, 0x2001, 0x0170, 0x200c, 0x918c, 0x00ff, 0x918e, 0x004c,
-	0x1128, 0x200c, 0x918c, 0xff00, 0x810f, 0x0005, 0x900e, 0x2001,
-	0x0227, 0x2004, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9108, 0x2001,
-	0x0226, 0x2004, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9108, 0x0005,
-	0x0018, 0x000c, 0x0018, 0x0020, 0x1000, 0x0800, 0x1000, 0x1800,
-	0x0156, 0x0006, 0x0016, 0x0026, 0x00e6, 0x2001, 0x198f, 0x2004,
-	0x908a, 0x0007, 0x1a0c, 0x0d7d, 0x0033, 0x00ee, 0x002e, 0x001e,
-	0x000e, 0x015e, 0x0005, 0x2772, 0x2790, 0x27b4, 0x27b6, 0x27df,
-	0x27e1, 0x27e3, 0x2001, 0x0001, 0x080c, 0x25b9, 0x080c, 0x29da,
-	0x2001, 0x1991, 0x2003, 0x0000, 0x7828, 0x9084, 0xe1d7, 0x782a,
-	0x9006, 0x20a9, 0x0009, 0x080c, 0x29ac, 0x2001, 0x198f, 0x2003,
-	0x0006, 0x2009, 0x001e, 0x2011, 0x27e4, 0x080c, 0x86e7, 0x0005,
-	0x2009, 0x1994, 0x200b, 0x0000, 0x2001, 0x1999, 0x2003, 0x0036,
-	0x2001, 0x1998, 0x2003, 0x002a, 0x2001, 0x1991, 0x2003, 0x0001,
-	0x9006, 0x080c, 0x2941, 0x2001, 0xffff, 0x20a9, 0x0009, 0x080c,
-	0x29ac, 0x2001, 0x198f, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011,
-	0x27e4, 0x080c, 0x86e7, 0x0005, 0x080c, 0x0d7d, 0x2001, 0x1999,
-	0x2003, 0x0036, 0x2001, 0x1991, 0x2003, 0x0003, 0x7a38, 0x9294,
-	0x0005, 0x9296, 0x0004, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001,
-	0x080c, 0x2941, 0x2001, 0x1995, 0x2003, 0x0000, 0x2001, 0xffff,
-	0x20a9, 0x0009, 0x080c, 0x29ac, 0x2001, 0x198f, 0x2003, 0x0006,
-	0x2009, 0x001e, 0x2011, 0x27e4, 0x080c, 0x86e7, 0x0005, 0x080c,
-	0x0d7d, 0x080c, 0x0d7d, 0x0005, 0x0006, 0x0016, 0x0026, 0x00e6,
-	0x00f6, 0x0156, 0x0126, 0x2091, 0x8000, 0x2079, 0x0100, 0x2001,
-	0x1991, 0x2004, 0x908a, 0x0007, 0x1a0c, 0x0d7d, 0x0043, 0x012e,
-	0x015e, 0x00fe, 0x00ee, 0x002e, 0x001e, 0x000e, 0x0005, 0x2806,
-	0x2826, 0x2866, 0x2896, 0x28ba, 0x28ca, 0x28cc, 0x080c, 0x29a0,
-	0x11b0, 0x7850, 0x9084, 0xefff, 0x7852, 0x2009, 0x1997, 0x2104,
-	0x7a38, 0x9294, 0x0005, 0x9296, 0x0004, 0x0110, 0xc08d, 0x0008,
-	0xc085, 0x200a, 0x2001, 0x198f, 0x2003, 0x0001, 0x0030, 0x080c,
-	0x28f0, 0x2001, 0xffff, 0x080c, 0x2781, 0x0005, 0x080c, 0x28ce,
-	0x05e0, 0x2009, 0x1998, 0x2104, 0x8001, 0x200a, 0x080c, 0x29a0,
-	0x1178, 0x7850, 0x9084, 0xefff, 0x7852, 0x7a38, 0x9294, 0x0005,
-	0x9296, 0x0005, 0x0518, 0x2009, 0x1997, 0x2104, 0xc085, 0x200a,
-	0x2009, 0x1994, 0x2104, 0x8000, 0x200a, 0x9086, 0x0005, 0x0118,
-	0x080c, 0x28d6, 0x00c0, 0x200b, 0x0000, 0x7a38, 0x9294, 0x0006,
-	0x9296, 0x0004, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c,
-	0x295e, 0x2001, 0x1991, 0x2003, 0x0002, 0x0028, 0x2001, 0x198f,
-	0x2003, 0x0003, 0x0010, 0x080c, 0x27a3, 0x0005, 0x080c, 0x28ce,
-	0x0560, 0x2009, 0x1998, 0x2104, 0x8001, 0x200a, 0x080c, 0x29a0,
-	0x1168, 0x7850, 0x9084, 0xefff, 0x7852, 0x2001, 0x198f, 0x2003,
-	0x0003, 0x2001, 0x1990, 0x2003, 0x0000, 0x00b8, 0x2009, 0x1998,
-	0x2104, 0x9005, 0x1118, 0x080c, 0x2913, 0x0010, 0x080c, 0x28e3,
-	0x080c, 0x28d6, 0x2009, 0x1994, 0x200b, 0x0000, 0x2001, 0x1991,
-	0x2003, 0x0001, 0x080c, 0x27a3, 0x0000, 0x0005, 0x04b9, 0x0508,
-	0x080c, 0x29a0, 0x11b8, 0x7850, 0x9084, 0xefff, 0x7852, 0x2009,
-	0x1995, 0x2104, 0x8000, 0x200a, 0x9086, 0x0007, 0x0108, 0x0078,
-	0x2001, 0x199a, 0x2003, 0x000a, 0x2009, 0x1997, 0x2104, 0xc0fd,
-	0x200a, 0x0038, 0x0419, 0x2001, 0x1991, 0x2003, 0x0004, 0x080c,
-	0x27ce, 0x0005, 0x0099, 0x0168, 0x080c, 0x29a0, 0x1138, 0x7850,
-	0x9084, 0xefff, 0x7852, 0x080c, 0x27ba, 0x0018, 0x0079, 0x080c,
-	0x27ce, 0x0005, 0x080c, 0x0d7d, 0x080c, 0x0d7d, 0x2009, 0x1999,
-	0x2104, 0x8001, 0x200a, 0x090c, 0x292f, 0x0005, 0x7a38, 0x9294,
-	0x0005, 0x9296, 0x0005, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001,
-	0x080c, 0x295e, 0x0005, 0x7a38, 0x9294, 0x0006, 0x9296, 0x0006,
-	0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x2941, 0x0005,
-	0x2009, 0x1994, 0x2104, 0x8000, 0x200a, 0x9086, 0x0005, 0x0108,
-	0x0068, 0x200b, 0x0000, 0x7a38, 0x9294, 0x0006, 0x9296, 0x0006,
-	0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x04d9, 0x7a38, 0x9294,
-	0x0005, 0x9296, 0x0005, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001,
-	0x080c, 0x295e, 0x0005, 0x0086, 0x2001, 0x1997, 0x2004, 0x9084,
-	0x7fff, 0x090c, 0x0d7d, 0x2009, 0x1996, 0x2144, 0x8846, 0x280a,
-	0x9844, 0x0dd8, 0xd08c, 0x1120, 0xd084, 0x1120, 0x080c, 0x0d7d,
-	0x9006, 0x0010, 0x2001, 0x0001, 0x00a1, 0x008e, 0x0005, 0x0006,
-	0x0156, 0x2001, 0x198f, 0x20a9, 0x0009, 0x2003, 0x0000, 0x8000,
-	0x1f04, 0x2935, 0x2001, 0x1996, 0x2003, 0x8000, 0x015e, 0x000e,
-	0x0005, 0x00f6, 0x2079, 0x0100, 0x9085, 0x0000, 0x0158, 0x7838,
-	0x9084, 0xfff9, 0x9085, 0x0004, 0x783a, 0x2009, 0x199c, 0x210c,
-	0x795a, 0x0050, 0x7838, 0x9084, 0xfffb, 0x9085, 0x0006, 0x783a,
-	0x2009, 0x199d, 0x210c, 0x795a, 0x00fe, 0x0005, 0x00f6, 0x2079,
-	0x0100, 0x9085, 0x0000, 0x0158, 0x7838, 0x9084, 0xfffa, 0x9085,
-	0x0004, 0x783a, 0x7850, 0x9084, 0xfff0, 0x7852, 0x00f8, 0x7838,
-	0x9084, 0xfffb, 0x9085, 0x0005, 0x783a, 0x7850, 0x9084, 0xfff0,
-	0x0016, 0x2009, 0x017f, 0x210c, 0x918e, 0x0005, 0x0140, 0x2009,
-	0x0003, 0x210c, 0x918c, 0x0600, 0x918e, 0x0400, 0x0118, 0x9085,
-	0x000a, 0x0010, 0x9085, 0x0000, 0x001e, 0x7852, 0x00fe, 0x0005,
-	0x0006, 0x2001, 0x0100, 0x2004, 0x9082, 0x0007, 0x000e, 0x0005,
-	0x0006, 0x2001, 0x0100, 0x2004, 0x9082, 0x0009, 0x000e, 0x0005,
-	0x0156, 0x20a9, 0x0064, 0x7820, 0x080c, 0x2a0f, 0xd09c, 0x1110,
-	0x1f04, 0x29a3, 0x015e, 0x0005, 0x0126, 0x0016, 0x0006, 0x2091,
-	0x8000, 0x000e, 0x2008, 0x9186, 0x0000, 0x1118, 0x783b, 0x0007,
+	0x004f, 0x6003, 0x0003, 0x080c, 0xac8d, 0x00ce, 0x080c, 0xa8b5,
+	0x001e, 0xd19c, 0x0904, 0x2593, 0x7038, 0xd0ac, 0x1558, 0x0016,
+	0x0156, 0x2011, 0x0008, 0x080c, 0x2a83, 0x080c, 0x2aa6, 0x080c,
+	0x2ad9, 0x6050, 0xc0e5, 0x6052, 0x20a9, 0x0367, 0x1f04, 0x2560,
+	0x1d04, 0x2548, 0x080c, 0x873d, 0x6020, 0xd09c, 0x1db8, 0x00f6,
+	0x2079, 0x0100, 0x080c, 0x29bc, 0x00fe, 0x1d80, 0x6050, 0xc0e4,
+	0x6052, 0x2011, 0x0008, 0x080c, 0x2a83, 0x015e, 0x001e, 0x0498,
+	0x015e, 0x001e, 0x0016, 0x6028, 0xc09c, 0x602a, 0x080c, 0xa899,
+	0x080c, 0xab61, 0x080c, 0xa8b5, 0x60e3, 0x0000, 0x080c, 0xe74f,
+	0x080c, 0xe76a, 0x080c, 0x56f9, 0xd0fc, 0x1138, 0x080c, 0xcf7d,
+	0x1120, 0x9085, 0x0001, 0x080c, 0x7533, 0x9006, 0x080c, 0x2a49,
+	0x2009, 0x0002, 0x080c, 0x2a35, 0x00e6, 0x2071, 0x1800, 0x7003,
+	0x0004, 0x080c, 0x0ec1, 0x00ee, 0x2011, 0x0008, 0x080c, 0x2a83,
+	0x080c, 0x0bc3, 0x001e, 0x918c, 0xffd0, 0x2110, 0x080c, 0x2a83,
+	0x00ae, 0x0005, 0x0016, 0x2001, 0x0387, 0x200c, 0xd1a4, 0x001e,
+	0x0904, 0x2341, 0x0016, 0x2009, 0x25a6, 0x00c0, 0x2001, 0x0387,
+	0x2003, 0x1000, 0x001e, 0x0c38, 0x0016, 0x2001, 0x0387, 0x200c,
+	0xd1b4, 0x001e, 0x0904, 0x2341, 0x0016, 0x2009, 0x25b8, 0x0030,
+	0x2001, 0x0387, 0x2003, 0x4000, 0x001e, 0x08a8, 0x6028, 0xc0bc,
+	0x602a, 0x2001, 0x0156, 0x2003, 0xbc91, 0x8000, 0x2003, 0xffff,
+	0x6043, 0x0001, 0x080c, 0x2a2f, 0x2011, 0x0080, 0x080c, 0x2a83,
+	0x6017, 0x0000, 0x6043, 0x0000, 0x0817, 0x0006, 0x0016, 0x0026,
+	0x0036, 0x00e6, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800,
+	0x71d0, 0x70d2, 0x9116, 0x0904, 0x2628, 0x81ff, 0x01a0, 0x2009,
+	0x0000, 0x080c, 0x2a35, 0x2011, 0x8011, 0x2019, 0x010e, 0x231c,
+	0x939e, 0x0007, 0x1118, 0x2019, 0x0001, 0x0010, 0x2019, 0x0000,
+	0x080c, 0x4b29, 0x0468, 0x2001, 0x19a7, 0x200c, 0x81ff, 0x1140,
+	0x2001, 0x0109, 0x2004, 0xd0b4, 0x0118, 0x2019, 0x0003, 0x0008,
+	0x2118, 0x2011, 0x8012, 0x080c, 0x4b29, 0x080c, 0x0ec1, 0x080c,
+	0x56f9, 0xd0fc, 0x11a8, 0x080c, 0xcf7d, 0x1190, 0x00c6, 0x080c,
+	0x26c4, 0x080c, 0xa899, 0x080c, 0xa08e, 0x080c, 0xa8b5, 0x2061,
+	0x0100, 0x2019, 0x0028, 0x2009, 0x0002, 0x080c, 0x31d4, 0x00ce,
+	0x012e, 0x00fe, 0x00ee, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005,
+	0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00, 0x11f0, 0x2011,
+	0x1837, 0x2214, 0xd2ac, 0x11c8, 0x81ff, 0x01e8, 0x2011, 0x181f,
+	0x2204, 0x9106, 0x1190, 0x2011, 0x1820, 0x2214, 0x9294, 0xff00,
+	0x9584, 0xff00, 0x9206, 0x1148, 0x2011, 0x1820, 0x2214, 0x9294,
+	0x00ff, 0x9584, 0x00ff, 0x9206, 0x1120, 0x2500, 0x080c, 0x8202,
+	0x0048, 0x9584, 0x00ff, 0x9080, 0x3388, 0x200d, 0x918c, 0xff00,
+	0x810f, 0x9006, 0x0005, 0x9080, 0x3388, 0x200d, 0x918c, 0x00ff,
+	0x0005, 0x00d6, 0x2069, 0x0140, 0x2001, 0x1818, 0x2003, 0x00ef,
+	0x20a9, 0x0010, 0x9006, 0x6852, 0x6856, 0x1f04, 0x2674, 0x00de,
+	0x0005, 0x0006, 0x00d6, 0x0026, 0x2069, 0x0140, 0x2001, 0x1818,
+	0x2102, 0x8114, 0x8214, 0x8214, 0x8214, 0x20a9, 0x0010, 0x6853,
+	0x0000, 0x9006, 0x82ff, 0x1128, 0x9184, 0x000f, 0x9080, 0xe77e,
+	0x2005, 0x6856, 0x8211, 0x1f04, 0x2689, 0x002e, 0x00de, 0x000e,
+	0x0005, 0x00c6, 0x2061, 0x1800, 0x6030, 0x0110, 0xc09d, 0x0008,
+	0xc09c, 0x6032, 0x00ce, 0x0005, 0x0156, 0x00d6, 0x0026, 0x0016,
+	0x0006, 0x2069, 0x0140, 0x6980, 0x9116, 0x0180, 0x9112, 0x1230,
+	0x8212, 0x8210, 0x22a8, 0x2001, 0x0402, 0x0018, 0x22a8, 0x2001,
+	0x0404, 0x680e, 0x1f04, 0x26b9, 0x680f, 0x0000, 0x000e, 0x001e,
+	0x002e, 0x00de, 0x015e, 0x0005, 0x080c, 0x56f5, 0xd0c4, 0x0150,
+	0xd0a4, 0x0140, 0x9006, 0x0046, 0x2020, 0x2009, 0x002e, 0x080c,
+	0xe316, 0x004e, 0x0005, 0x00f6, 0x0016, 0x0026, 0x2079, 0x0140,
+	0x78c4, 0xd0dc, 0x0904, 0x2730, 0x080c, 0x29ac, 0x0660, 0x9084,
+	0x0700, 0x908e, 0x0600, 0x1120, 0x2011, 0x4000, 0x900e, 0x0458,
+	0x908e, 0x0500, 0x1120, 0x2011, 0x8000, 0x900e, 0x0420, 0x908e,
+	0x0400, 0x1120, 0x9016, 0x2009, 0x0001, 0x00e8, 0x908e, 0x0300,
+	0x1120, 0x9016, 0x2009, 0x0002, 0x00b0, 0x908e, 0x0200, 0x1120,
+	0x9016, 0x2009, 0x0004, 0x0078, 0x908e, 0x0100, 0x1548, 0x9016,
+	0x2009, 0x0008, 0x0040, 0x9084, 0x0700, 0x908e, 0x0300, 0x1500,
+	0x2011, 0x0030, 0x0058, 0x2300, 0x9080, 0x0020, 0x2018, 0x080c,
+	0x9181, 0x928c, 0xff00, 0x0110, 0x2011, 0x00ff, 0x2200, 0x8007,
+	0x9085, 0x004c, 0x78c2, 0x2009, 0x0138, 0x220a, 0x080c, 0x74ec,
+	0x1118, 0x2009, 0x196c, 0x220a, 0x002e, 0x001e, 0x00fe, 0x0005,
+	0x78c3, 0x0000, 0x0cc8, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016,
+	0x0026, 0x2001, 0x0170, 0x200c, 0x8000, 0x2014, 0x9184, 0x0003,
+	0x0110, 0x080c, 0x0d76, 0x002e, 0x001e, 0x000e, 0x012e, 0x0005,
+	0x2001, 0x0171, 0x2004, 0xd0dc, 0x0168, 0x2001, 0x0170, 0x200c,
+	0x918c, 0x00ff, 0x918e, 0x004c, 0x1128, 0x200c, 0x918c, 0xff00,
+	0x810f, 0x0005, 0x900e, 0x2001, 0x0227, 0x2004, 0x8007, 0x9084,
+	0x00ff, 0x8004, 0x9108, 0x2001, 0x0226, 0x2004, 0x8007, 0x9084,
+	0x00ff, 0x8004, 0x9108, 0x0005, 0x0018, 0x000c, 0x0018, 0x0020,
+	0x1000, 0x0800, 0x1000, 0x1800, 0x0156, 0x0006, 0x0016, 0x0026,
+	0x00e6, 0x2001, 0x198f, 0x2004, 0x908a, 0x0007, 0x1a0c, 0x0d7d,
+	0x0033, 0x00ee, 0x002e, 0x001e, 0x000e, 0x015e, 0x0005, 0x278e,
+	0x27ac, 0x27d0, 0x27d2, 0x27fb, 0x27fd, 0x27ff, 0x2001, 0x0001,
+	0x080c, 0x25d5, 0x080c, 0x29fa, 0x2001, 0x1991, 0x2003, 0x0000,
+	0x7828, 0x9084, 0xe1d7, 0x782a, 0x9006, 0x20a9, 0x0009, 0x080c,
+	0x29c8, 0x2001, 0x198f, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011,
+	0x2800, 0x080c, 0x871b, 0x0005, 0x2009, 0x1994, 0x200b, 0x0000,
+	0x2001, 0x1999, 0x2003, 0x0036, 0x2001, 0x1998, 0x2003, 0x002a,
+	0x2001, 0x1991, 0x2003, 0x0001, 0x9006, 0x080c, 0x295d, 0x2001,
+	0xffff, 0x20a9, 0x0009, 0x080c, 0x29c8, 0x2001, 0x198f, 0x2003,
+	0x0006, 0x2009, 0x001e, 0x2011, 0x2800, 0x080c, 0x871b, 0x0005,
+	0x080c, 0x0d7d, 0x2001, 0x1999, 0x2003, 0x0036, 0x2001, 0x1991,
+	0x2003, 0x0003, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0004, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x295d, 0x2001, 0x1995,
+	0x2003, 0x0000, 0x2001, 0xffff, 0x20a9, 0x0009, 0x080c, 0x29c8,
+	0x2001, 0x198f, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x2800,
+	0x080c, 0x871b, 0x0005, 0x080c, 0x0d7d, 0x080c, 0x0d7d, 0x0005,
+	0x0006, 0x0016, 0x0026, 0x00e6, 0x00f6, 0x0156, 0x0126, 0x2091,
+	0x8000, 0x2079, 0x0100, 0x2001, 0x1991, 0x2004, 0x908a, 0x0007,
+	0x1a0c, 0x0d7d, 0x0043, 0x012e, 0x015e, 0x00fe, 0x00ee, 0x002e,
+	0x001e, 0x000e, 0x0005, 0x2822, 0x2842, 0x2882, 0x28b2, 0x28d6,
+	0x28e6, 0x28e8, 0x080c, 0x29bc, 0x11b0, 0x7850, 0x9084, 0xefff,
+	0x7852, 0x2009, 0x1997, 0x2104, 0x7a38, 0x9294, 0x0005, 0x9296,
+	0x0004, 0x0110, 0xc08d, 0x0008, 0xc085, 0x200a, 0x2001, 0x198f,
+	0x2003, 0x0001, 0x0030, 0x080c, 0x290c, 0x2001, 0xffff, 0x080c,
+	0x279d, 0x0005, 0x080c, 0x28ea, 0x05e0, 0x2009, 0x1998, 0x2104,
+	0x8001, 0x200a, 0x080c, 0x29bc, 0x1178, 0x7850, 0x9084, 0xefff,
+	0x7852, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0518, 0x2009,
+	0x1997, 0x2104, 0xc085, 0x200a, 0x2009, 0x1994, 0x2104, 0x8000,
+	0x200a, 0x9086, 0x0005, 0x0118, 0x080c, 0x28f2, 0x00c0, 0x200b,
+	0x0000, 0x7a38, 0x9294, 0x0006, 0x9296, 0x0004, 0x0110, 0x9006,
+	0x0010, 0x2001, 0x0001, 0x080c, 0x297a, 0x2001, 0x1991, 0x2003,
+	0x0002, 0x0028, 0x2001, 0x198f, 0x2003, 0x0003, 0x0010, 0x080c,
+	0x27bf, 0x0005, 0x080c, 0x28ea, 0x0560, 0x2009, 0x1998, 0x2104,
+	0x8001, 0x200a, 0x080c, 0x29bc, 0x1168, 0x7850, 0x9084, 0xefff,
+	0x7852, 0x2001, 0x198f, 0x2003, 0x0003, 0x2001, 0x1990, 0x2003,
+	0x0000, 0x00b8, 0x2009, 0x1998, 0x2104, 0x9005, 0x1118, 0x080c,
+	0x292f, 0x0010, 0x080c, 0x28ff, 0x080c, 0x28f2, 0x2009, 0x1994,
+	0x200b, 0x0000, 0x2001, 0x1991, 0x2003, 0x0001, 0x080c, 0x27bf,
+	0x0000, 0x0005, 0x04b9, 0x0508, 0x080c, 0x29bc, 0x11b8, 0x7850,
+	0x9084, 0xefff, 0x7852, 0x2009, 0x1995, 0x2104, 0x8000, 0x200a,
+	0x9086, 0x0007, 0x0108, 0x0078, 0x2001, 0x199a, 0x2003, 0x000a,
+	0x2009, 0x1997, 0x2104, 0xc0fd, 0x200a, 0x0038, 0x0419, 0x2001,
+	0x1991, 0x2003, 0x0004, 0x080c, 0x27ea, 0x0005, 0x0099, 0x0168,
+	0x080c, 0x29bc, 0x1138, 0x7850, 0x9084, 0xefff, 0x7852, 0x080c,
+	0x27d6, 0x0018, 0x0079, 0x080c, 0x27ea, 0x0005, 0x080c, 0x0d7d,
+	0x080c, 0x0d7d, 0x2009, 0x1999, 0x2104, 0x8001, 0x200a, 0x090c,
+	0x294b, 0x0005, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x297a, 0x0005, 0x7a38,
+	0x9294, 0x0006, 0x9296, 0x0006, 0x0110, 0x9006, 0x0010, 0x2001,
+	0x0001, 0x080c, 0x295d, 0x0005, 0x2009, 0x1994, 0x2104, 0x8000,
+	0x200a, 0x9086, 0x0005, 0x0108, 0x0068, 0x200b, 0x0000, 0x7a38,
+	0x9294, 0x0006, 0x9296, 0x0006, 0x0110, 0x9006, 0x0010, 0x2001,
+	0x0001, 0x04d9, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x297a, 0x0005, 0x0086,
+	0x2001, 0x1997, 0x2004, 0x9084, 0x7fff, 0x090c, 0x0d7d, 0x2009,
+	0x1996, 0x2144, 0x8846, 0x280a, 0x9844, 0x0dd8, 0xd08c, 0x1120,
+	0xd084, 0x1120, 0x080c, 0x0d7d, 0x9006, 0x0010, 0x2001, 0x0001,
+	0x00a1, 0x008e, 0x0005, 0x0006, 0x0156, 0x2001, 0x198f, 0x20a9,
+	0x0009, 0x2003, 0x0000, 0x8000, 0x1f04, 0x2951, 0x2001, 0x1996,
+	0x2003, 0x8000, 0x015e, 0x000e, 0x0005, 0x00f6, 0x2079, 0x0100,
+	0x9085, 0x0000, 0x0158, 0x7838, 0x9084, 0xfff9, 0x9085, 0x0004,
+	0x783a, 0x2009, 0x199c, 0x210c, 0x795a, 0x0050, 0x7838, 0x9084,
+	0xfffb, 0x9085, 0x0006, 0x783a, 0x2009, 0x199d, 0x210c, 0x795a,
+	0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100, 0x9085, 0x0000, 0x0158,
+	0x7838, 0x9084, 0xfffa, 0x9085, 0x0004, 0x783a, 0x7850, 0x9084,
+	0xfff0, 0x7852, 0x00f8, 0x7838, 0x9084, 0xfffb, 0x9085, 0x0005,
+	0x783a, 0x7850, 0x9084, 0xfff0, 0x0016, 0x2009, 0x017f, 0x210c,
+	0x918e, 0x0005, 0x0140, 0x2009, 0x0003, 0x210c, 0x918c, 0x0600,
+	0x918e, 0x0400, 0x0118, 0x9085, 0x000a, 0x0010, 0x9085, 0x0000,
+	0x001e, 0x7852, 0x00fe, 0x0005, 0x0006, 0x2001, 0x0100, 0x2004,
+	0x9082, 0x0007, 0x000e, 0x0005, 0x0006, 0x2001, 0x0100, 0x2004,
+	0x9082, 0x0009, 0x000e, 0x0005, 0x0156, 0x20a9, 0x0064, 0x7820,
+	0x080c, 0x2a2f, 0xd09c, 0x1110, 0x1f04, 0x29bf, 0x015e, 0x0005,
+	0x0126, 0x0016, 0x0006, 0x2091, 0x8000, 0x080c, 0x2aa6, 0x080c,
+	0x2ad9, 0x000e, 0x2008, 0x9186, 0x0000, 0x1118, 0x783b, 0x0007,
 	0x0090, 0x9186, 0x0001, 0x1118, 0x783b, 0x0006, 0x0060, 0x9186,
 	0x0002, 0x1118, 0x783b, 0x0005, 0x0030, 0x9186, 0x0003, 0x1118,
-	0x783b, 0x0004, 0x0000, 0x0006, 0x1d04, 0x29cc, 0x080c, 0x8709,
-	0x1f04, 0x29cc, 0x7850, 0x9085, 0x1000, 0x7852, 0x000e, 0x001e,
-	0x012e, 0x0005, 0x080c, 0x2ab9, 0x0005, 0x0006, 0x0156, 0x00f6,
+	0x783b, 0x0004, 0x0000, 0x0006, 0x1d04, 0x29ec, 0x080c, 0x873d,
+	0x1f04, 0x29ec, 0x7850, 0x9085, 0x1000, 0x7852, 0x000e, 0x001e,
+	0x012e, 0x0005, 0x080c, 0x2ad9, 0x0005, 0x0006, 0x0156, 0x00f6,
 	0x2079, 0x0100, 0x20a9, 0x000a, 0x7854, 0xd0ac, 0x1100, 0x7854,
-	0xd08c, 0x1110, 0x1f04, 0x29e7, 0x00fe, 0x015e, 0x000e, 0x0005,
-	0x1d04, 0x29f0, 0x080c, 0x8709, 0x1f04, 0x29f0, 0x0005, 0x0006,
+	0xd08c, 0x1110, 0x1f04, 0x2a07, 0x00fe, 0x015e, 0x000e, 0x0005,
+	0x1d04, 0x2a10, 0x080c, 0x873d, 0x1f04, 0x2a10, 0x0005, 0x0006,
 	0x2001, 0x199b, 0x2004, 0x9086, 0x0000, 0x000e, 0x0005, 0x0006,
 	0x2001, 0x199b, 0x2004, 0x9086, 0x0001, 0x000e, 0x0005, 0x0006,
 	0x2001, 0x199b, 0x2004, 0x9086, 0x0002, 0x000e, 0x0005, 0xa001,
 	0xa001, 0xa001, 0xa001, 0xa001, 0x0005, 0x0006, 0x2001, 0x19a7,
 	0x2102, 0x000e, 0x0005, 0x2009, 0x0171, 0x2104, 0xd0dc, 0x0140,
 	0x2009, 0x0170, 0x2104, 0x200b, 0x0080, 0xa001, 0xa001, 0x200a,
-	0x0005, 0x0016, 0x0026, 0x080c, 0x74e2, 0x0108, 0xc0bc, 0x2009,
+	0x0005, 0x0016, 0x0026, 0x080c, 0x7506, 0x0108, 0xc0bc, 0x2009,
 	0x0140, 0x2114, 0x9294, 0x0001, 0x9215, 0x220a, 0x002e, 0x001e,
 	0x0005, 0x0016, 0x0026, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001,
 	0x9285, 0x1000, 0x200a, 0x220a, 0x002e, 0x001e, 0x0005, 0x0016,
 	0x0026, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001, 0x9215, 0x220a,
 	0x002e, 0x001e, 0x0005, 0x0006, 0x0016, 0x2009, 0x0140, 0x2104,
-	0x1128, 0x080c, 0x74e2, 0x0110, 0xc0bc, 0x0008, 0xc0bd, 0x200a,
+	0x1128, 0x080c, 0x7506, 0x0110, 0xc0bc, 0x0008, 0xc0bd, 0x200a,
 	0x001e, 0x000e, 0x0005, 0x00f6, 0x2079, 0x0380, 0x7843, 0x0101,
 	0x7844, 0xd084, 0x1de8, 0x2001, 0x0109, 0x2202, 0x7843, 0x0100,
 	0x00fe, 0x0005, 0x00f6, 0x2079, 0x0380, 0x7843, 0x0202, 0x7844,
 	0xd08c, 0x1de8, 0x2079, 0x0100, 0x7814, 0x9104, 0x9205, 0x7a16,
 	0x2079, 0x0380, 0x7843, 0x0200, 0x00fe, 0x0005, 0x0016, 0x0026,
 	0x0036, 0x00c6, 0x2061, 0x0100, 0x6050, 0x9084, 0xfbff, 0x9085,
-	0x0040, 0x6052, 0x20a9, 0x0002, 0x080c, 0x29f0, 0x6050, 0x9085,
-	0x0400, 0x9084, 0xff9f, 0x6052, 0x20a9, 0x0005, 0x080c, 0x29f0,
-	0x6054, 0xd0bc, 0x090c, 0x0d7d, 0x20a9, 0x0005, 0x080c, 0x29f0,
+	0x0040, 0x6052, 0x20a9, 0x0002, 0x080c, 0x2a10, 0x6050, 0x9085,
+	0x0400, 0x9084, 0xff9f, 0x6052, 0x20a9, 0x0005, 0x080c, 0x2a10,
+	0x6054, 0xd0bc, 0x090c, 0x0d7d, 0x20a9, 0x0005, 0x080c, 0x2a10,
 	0x6054, 0xd0ac, 0x090c, 0x0d7d, 0x2009, 0x19ae, 0x9084, 0x7e00,
 	0x8007, 0x8004, 0x8004, 0x200a, 0x00ce, 0x003e, 0x002e, 0x001e,
 	0x0005, 0x0006, 0x00c6, 0x2061, 0x0100, 0x6050, 0xc0cd, 0x6052,
-	0x00ce, 0x000e, 0x0005, 0x2fbf, 0x2fbf, 0x2bc3, 0x2bc3, 0x2bcf,
-	0x2bcf, 0x2bdb, 0x2bdb, 0x2be9, 0x2be9, 0x2bf5, 0x2bf5, 0x2c03,
-	0x2c03, 0x2c11, 0x2c11, 0x2c23, 0x2c23, 0x2c2f, 0x2c2f, 0x2c3d,
-	0x2c3d, 0x2c5b, 0x2c5b, 0x2c7b, 0x2c7b, 0x2c4b, 0x2c4b, 0x2c6b,
-	0x2c6b, 0x2c89, 0x2c89, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c9b, 0x2c9b, 0x2ca7, 0x2ca7, 0x2cb5,
-	0x2cb5, 0x2cc3, 0x2cc3, 0x2cd3, 0x2cd3, 0x2ce1, 0x2ce1, 0x2cf1,
-	0x2cf1, 0x2d01, 0x2d01, 0x2d13, 0x2d13, 0x2d21, 0x2d21, 0x2d31,
-	0x2d31, 0x2d53, 0x2d53, 0x2d77, 0x2d77, 0x2d41, 0x2d41, 0x2d65,
-	0x2d65, 0x2d87, 0x2d87, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2d9b, 0x2d9b, 0x2da7, 0x2da7, 0x2db5,
-	0x2db5, 0x2dc3, 0x2dc3, 0x2dd3, 0x2dd3, 0x2de1, 0x2de1, 0x2df1,
-	0x2df1, 0x2e01, 0x2e01, 0x2e13, 0x2e13, 0x2e21, 0x2e21, 0x2e31,
-	0x2e31, 0x2e41, 0x2e41, 0x2e53, 0x2e53, 0x2e63, 0x2e63, 0x2e75,
-	0x2e75, 0x2e87, 0x2e87, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2e9b, 0x2e9b, 0x2ea9, 0x2ea9, 0x2eb9,
-	0x2eb9, 0x2ec9, 0x2ec9, 0x2edb, 0x2edb, 0x2eeb, 0x2eeb, 0x2efd,
-	0x2efd, 0x2f0f, 0x2f0f, 0x2f23, 0x2f23, 0x2f33, 0x2f33, 0x2f45,
-	0x2f45, 0x2f57, 0x2f57, 0x2f6b, 0x2f6b, 0x2f7c, 0x2f7c, 0x2f8f,
-	0x2f8f, 0x2fa2, 0x2fa2, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21, 0x2c21,
-	0x2c21, 0x2c21, 0x2c21, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2261, 0x0804, 0x2fb7, 0x0106,
+	0x00ce, 0x000e, 0x0005, 0x2fdf, 0x2fdf, 0x2be3, 0x2be3, 0x2bef,
+	0x2bef, 0x2bfb, 0x2bfb, 0x2c09, 0x2c09, 0x2c15, 0x2c15, 0x2c23,
+	0x2c23, 0x2c31, 0x2c31, 0x2c43, 0x2c43, 0x2c4f, 0x2c4f, 0x2c5d,
+	0x2c5d, 0x2c7b, 0x2c7b, 0x2c9b, 0x2c9b, 0x2c6b, 0x2c6b, 0x2c8b,
+	0x2c8b, 0x2ca9, 0x2ca9, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2cbb, 0x2cbb, 0x2cc7, 0x2cc7, 0x2cd5,
+	0x2cd5, 0x2ce3, 0x2ce3, 0x2cf3, 0x2cf3, 0x2d01, 0x2d01, 0x2d11,
+	0x2d11, 0x2d21, 0x2d21, 0x2d33, 0x2d33, 0x2d41, 0x2d41, 0x2d51,
+	0x2d51, 0x2d73, 0x2d73, 0x2d97, 0x2d97, 0x2d61, 0x2d61, 0x2d85,
+	0x2d85, 0x2da7, 0x2da7, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2dbb, 0x2dbb, 0x2dc7, 0x2dc7, 0x2dd5,
+	0x2dd5, 0x2de3, 0x2de3, 0x2df3, 0x2df3, 0x2e01, 0x2e01, 0x2e11,
+	0x2e11, 0x2e21, 0x2e21, 0x2e33, 0x2e33, 0x2e41, 0x2e41, 0x2e51,
+	0x2e51, 0x2e61, 0x2e61, 0x2e73, 0x2e73, 0x2e83, 0x2e83, 0x2e95,
+	0x2e95, 0x2ea7, 0x2ea7, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2ebb, 0x2ebb, 0x2ec9, 0x2ec9, 0x2ed9,
+	0x2ed9, 0x2ee9, 0x2ee9, 0x2efb, 0x2efb, 0x2f0b, 0x2f0b, 0x2f1d,
+	0x2f1d, 0x2f2f, 0x2f2f, 0x2f43, 0x2f43, 0x2f53, 0x2f53, 0x2f65,
+	0x2f65, 0x2f77, 0x2f77, 0x2f8b, 0x2f8b, 0x2f9c, 0x2f9c, 0x2faf,
+	0x2faf, 0x2fc2, 0x2fc2, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41, 0x2c41,
+	0x2c41, 0x2c41, 0x2c41, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2279, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x208b, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x208b, 0x080c, 0x2261, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2261, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x208b, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x208b, 0x080c, 0x2261, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0xa001, 0x0cf0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x13ae, 0x0804, 0x2fb7, 0x0106,
+	0x20a3, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x20a3, 0x080c, 0x2279, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2279, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x20a3, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x20a3, 0x080c, 0x2279, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0xa001, 0x0cf0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x13bb, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2261, 0x080c, 0x13ae, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x208b, 0x080c,
-	0x13ae, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2261, 0x080c, 0x13ae, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x208b, 0x080c, 0x2261, 0x080c,
-	0x13ae, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x208b, 0x080c, 0x13ae, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x13ae, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x208b, 0x080c, 0x2261, 0x080c, 0x13ae, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x0804, 0x2fb7, 0x0106,
+	0x2279, 0x080c, 0x13bb, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x20a3, 0x080c,
+	0x13bb, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2279, 0x080c, 0x13bb, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x20a3, 0x080c, 0x2279, 0x080c,
+	0x13bb, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x20a3, 0x080c, 0x13bb, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x13bb, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x20a3, 0x080c, 0x2279, 0x080c, 0x13bb, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2717, 0x080c, 0x2261, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c,
-	0x208b, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0x208b, 0x080c,
-	0x2261, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0x2261, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0x208b, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0x208b, 0x080c, 0x2261, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0x13ae, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0x2261, 0x080c, 0x13ae, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0x208b, 0x080c, 0x13ae, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0x2261, 0x080c, 0x13ae, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0x208b, 0x080c,
-	0x2261, 0x080c, 0x13ae, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c,
-	0x208b, 0x080c, 0x13ae, 0x080c, 0x20b5, 0x0804, 0x2fb7, 0x0106,
+	0x2733, 0x080c, 0x2279, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c,
+	0x20a3, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0x20a3, 0x080c,
+	0x2279, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0x2279, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0x20a3, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0x20a3, 0x080c, 0x2279, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0x13bb, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0x2279, 0x080c, 0x13bb, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0x20a3, 0x080c, 0x13bb, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0x2279, 0x080c, 0x13bb, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0x20a3, 0x080c,
+	0x2279, 0x080c, 0x13bb, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c,
+	0x20a3, 0x080c, 0x13bb, 0x080c, 0x20cd, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2717, 0x080c, 0x13ae, 0x080c, 0x20b5, 0x0804, 0x2fb7, 0x0106,
+	0x2733, 0x080c, 0x13bb, 0x080c, 0x20cd, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2717, 0x080c, 0x208b, 0x080c, 0x2261, 0x080c, 0x13ae, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ee, 0x0804, 0x2fb7, 0x0106,
+	0x2733, 0x080c, 0x20a3, 0x080c, 0x2279, 0x080c, 0x13bb, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ff, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0xa8ee, 0x080c, 0x2261, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x208b, 0x080c,
-	0xa8ee, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x080c,
-	0x2261, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ee, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x080c, 0x20b5, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ee, 0x080c, 0x13ae, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x080c, 0x13ae, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x080c, 0x13ae, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x080c,
-	0x13ae, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ee, 0x080c, 0x13ae, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x080c,
-	0x13ae, 0x080c, 0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x208b, 0x080c,
-	0xa8ee, 0x080c, 0x13ae, 0x080c, 0x20b5, 0x0804, 0x2fb7, 0x0106,
+	0xa8ff, 0x080c, 0x2279, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x20a3, 0x080c,
+	0xa8ff, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x080c,
+	0x2279, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ff, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x080c, 0x20cd, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ff, 0x080c, 0x13bb, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x080c, 0x13bb, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x080c, 0x13bb, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x080c,
+	0x13bb, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ff, 0x080c, 0x13bb, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x080c,
+	0x13bb, 0x080c, 0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x20a3, 0x080c,
+	0xa8ff, 0x080c, 0x13bb, 0x080c, 0x20cd, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x208b, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x080c, 0x13ae, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0xa8ee, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x0804,
-	0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2717, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x080c,
-	0x2261, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0xa8ee, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0xa8ee, 0x080c,
-	0x2261, 0x080c, 0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c,
-	0x208b, 0x080c, 0xa8ee, 0x080c, 0x20b5, 0x0804, 0x2fb7, 0x0106,
+	0x20a3, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x080c, 0x13bb, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0xa8ff, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x0804,
+	0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2733, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x080c,
+	0x2279, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0xa8ff, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0xa8ff, 0x080c,
+	0x2279, 0x080c, 0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c,
+	0x20a3, 0x080c, 0xa8ff, 0x080c, 0x20cd, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2717, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x080c,
-	0x20b5, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0xa8ee, 0x080c,
-	0x13ae, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0xa8ee, 0x080c,
-	0x2261, 0x080c, 0x13ae, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c,
-	0x208b, 0x080c, 0xa8ee, 0x080c, 0x13ae, 0x0804, 0x2fb7, 0x0106,
+	0x2733, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x080c,
+	0x20cd, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0xa8ff, 0x080c,
+	0x13bb, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0xa8ff, 0x080c,
+	0x2279, 0x080c, 0x13bb, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c,
+	0x20a3, 0x080c, 0xa8ff, 0x080c, 0x13bb, 0x0804, 0x2fd7, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2717, 0x080c, 0x208b, 0x080c, 0xa8ee, 0x080c, 0x2261, 0x080c,
-	0x13ae, 0x0804, 0x2fb7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0xa8ee, 0x080c,
-	0x13ae, 0x080c, 0x20b5, 0x04d8, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0xa8ee,
-	0x080c, 0x2261, 0x080c, 0x13ae, 0x080c, 0x20b5, 0x0440, 0x0106,
+	0x2733, 0x080c, 0x20a3, 0x080c, 0xa8ff, 0x080c, 0x2279, 0x080c,
+	0x13bb, 0x0804, 0x2fd7, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0xa8ff, 0x080c,
+	0x13bb, 0x080c, 0x20cd, 0x04d8, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0xa8ff,
+	0x080c, 0x2279, 0x080c, 0x13bb, 0x080c, 0x20cd, 0x0440, 0x0106,
 	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
-	0x2717, 0x080c, 0x208b, 0x080c, 0x13ae, 0x080c, 0xa8ee, 0x080c,
-	0x20b5, 0x00a8, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2717, 0x080c, 0x208b, 0x080c, 0xa8ee,
-	0x080c, 0x2261, 0x080c, 0x13ae, 0x080c, 0x20b5, 0x0000, 0x015e,
+	0x2733, 0x080c, 0x20a3, 0x080c, 0x13bb, 0x080c, 0xa8ff, 0x080c,
+	0x20cd, 0x00a8, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x2733, 0x080c, 0x20a3, 0x080c, 0xa8ff,
+	0x080c, 0x2279, 0x080c, 0x13bb, 0x080c, 0x20cd, 0x0000, 0x015e,
 	0x014e, 0x013e, 0x01de, 0x01ce, 0x012e, 0x000e, 0x010e, 0x000d,
-	0x00b6, 0x00c6, 0x0026, 0x0046, 0x9026, 0x080c, 0x6a28, 0x1904,
-	0x30d0, 0x72dc, 0x2001, 0x197b, 0x2004, 0x9005, 0x1110, 0xd29c,
-	0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904, 0x30d0, 0x080c, 0x30d5,
-	0x0804, 0x30d0, 0xd2cc, 0x1904, 0x30d0, 0x080c, 0x74c8, 0x1120,
-	0x70af, 0xffff, 0x0804, 0x30d0, 0xd294, 0x0120, 0x70af, 0xffff,
-	0x0804, 0x30d0, 0x080c, 0x3357, 0x0160, 0x080c, 0xcf51, 0x0128,
-	0x2001, 0x1818, 0x203c, 0x0804, 0x305d, 0x70af, 0xffff, 0x0804,
-	0x30d0, 0x2001, 0x1818, 0x203c, 0x7294, 0xd284, 0x0904, 0x305d,
-	0xd28c, 0x1904, 0x305d, 0x0036, 0x73ac, 0x938e, 0xffff, 0x1110,
+	0x00b6, 0x00c6, 0x0026, 0x0046, 0x9026, 0x080c, 0x6a4c, 0x1904,
+	0x30f0, 0x72dc, 0x2001, 0x197b, 0x2004, 0x9005, 0x1110, 0xd29c,
+	0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904, 0x30f0, 0x080c, 0x30f5,
+	0x0804, 0x30f0, 0xd2cc, 0x1904, 0x30f0, 0x080c, 0x74ec, 0x1120,
+	0x70af, 0xffff, 0x0804, 0x30f0, 0xd294, 0x0120, 0x70af, 0xffff,
+	0x0804, 0x30f0, 0x080c, 0x3377, 0x0160, 0x080c, 0xcf84, 0x0128,
+	0x2001, 0x1818, 0x203c, 0x0804, 0x307d, 0x70af, 0xffff, 0x0804,
+	0x30f0, 0x2001, 0x1818, 0x203c, 0x7294, 0xd284, 0x0904, 0x307d,
+	0xd28c, 0x1904, 0x307d, 0x0036, 0x73ac, 0x938e, 0xffff, 0x1110,
 	0x2019, 0x0001, 0x8314, 0x92e0, 0x1d80, 0x2c04, 0x938c, 0x0001,
 	0x0120, 0x9084, 0xff00, 0x8007, 0x0010, 0x9084, 0x00ff, 0x970e,
 	0x05d0, 0x908e, 0x0000, 0x05b8, 0x908e, 0x00ff, 0x1150, 0x7230,
 	0xd284, 0x15b0, 0x7294, 0xc28d, 0x7296, 0x70af, 0xffff, 0x003e,
-	0x04a0, 0x900e, 0x080c, 0x2614, 0x080c, 0x65bf, 0x1538, 0x9006,
+	0x04a0, 0x900e, 0x080c, 0x2630, 0x080c, 0x65e3, 0x1538, 0x9006,
 	0xb8bb, 0x0520, 0xb8ac, 0x9005, 0x0148, 0x00c6, 0x2060, 0x080c,
-	0x8b72, 0x00ce, 0x090c, 0x8f16, 0xb8af, 0x0000, 0x080c, 0x6a6a,
+	0x8ba9, 0x00ce, 0x090c, 0x8f4f, 0xb8af, 0x0000, 0x080c, 0x6a8e,
 	0x1168, 0x7030, 0xd08c, 0x0130, 0xb800, 0xd0bc, 0x0138, 0x080c,
-	0x6913, 0x0120, 0x080c, 0x30ee, 0x0148, 0x0028, 0x080c, 0x323a,
-	0x080c, 0x311a, 0x0118, 0x8318, 0x0804, 0x300a, 0x73ae, 0x0010,
-	0x70af, 0xffff, 0x003e, 0x0804, 0x30d0, 0x9780, 0x3368, 0x203d,
+	0x6937, 0x0120, 0x080c, 0x310e, 0x0148, 0x0028, 0x080c, 0x325a,
+	0x080c, 0x313a, 0x0118, 0x8318, 0x0804, 0x302a, 0x73ae, 0x0010,
+	0x70af, 0xffff, 0x003e, 0x0804, 0x30f0, 0x9780, 0x3388, 0x203d,
 	0x97bc, 0xff00, 0x873f, 0x2041, 0x007e, 0x70ac, 0x9096, 0xffff,
 	0x1118, 0x900e, 0x28a8, 0x0050, 0x9812, 0x0220, 0x2008, 0x9802,
-	0x20a8, 0x0020, 0x70af, 0xffff, 0x0804, 0x30d0, 0x2700, 0x0156,
-	0x0016, 0x9106, 0x0904, 0x30c5, 0xc484, 0x080c, 0x6620, 0x0148,
-	0x080c, 0xcf51, 0x1904, 0x30c5, 0x080c, 0x65bf, 0x1904, 0x30cd,
+	0x20a8, 0x0020, 0x70af, 0xffff, 0x0804, 0x30f0, 0x2700, 0x0156,
+	0x0016, 0x9106, 0x0904, 0x30e5, 0xc484, 0x080c, 0x6644, 0x0148,
+	0x080c, 0xcf84, 0x1904, 0x30e5, 0x080c, 0x65e3, 0x1904, 0x30ed,
 	0x0008, 0xc485, 0xb8bb, 0x0520, 0xb8ac, 0x9005, 0x0148, 0x00c6,
-	0x2060, 0x080c, 0x8b72, 0x00ce, 0x090c, 0x8f16, 0xb8af, 0x0000,
-	0x080c, 0x6a6a, 0x1130, 0x7030, 0xd08c, 0x01f8, 0xb800, 0xd0bc,
-	0x11e0, 0x7294, 0xd28c, 0x0180, 0x080c, 0x6a6a, 0x9082, 0x0006,
-	0x02e0, 0xd484, 0x1118, 0x080c, 0x65e4, 0x0028, 0x080c, 0x32cd,
-	0x01a0, 0x080c, 0x32f8, 0x0088, 0x080c, 0x323a, 0x080c, 0xcf51,
-	0x1160, 0x080c, 0x311a, 0x0188, 0x0040, 0x080c, 0xcf51, 0x1118,
-	0x080c, 0x32cd, 0x0110, 0x0451, 0x0140, 0x001e, 0x8108, 0x015e,
-	0x1f04, 0x3076, 0x70af, 0xffff, 0x0018, 0x001e, 0x015e, 0x71ae,
+	0x2060, 0x080c, 0x8ba9, 0x00ce, 0x090c, 0x8f4f, 0xb8af, 0x0000,
+	0x080c, 0x6a8e, 0x1130, 0x7030, 0xd08c, 0x01f8, 0xb800, 0xd0bc,
+	0x11e0, 0x7294, 0xd28c, 0x0180, 0x080c, 0x6a8e, 0x9082, 0x0006,
+	0x02e0, 0xd484, 0x1118, 0x080c, 0x6608, 0x0028, 0x080c, 0x32ed,
+	0x01a0, 0x080c, 0x3318, 0x0088, 0x080c, 0x325a, 0x080c, 0xcf84,
+	0x1160, 0x080c, 0x313a, 0x0188, 0x0040, 0x080c, 0xcf84, 0x1118,
+	0x080c, 0x32ed, 0x0110, 0x0451, 0x0140, 0x001e, 0x8108, 0x015e,
+	0x1f04, 0x3096, 0x70af, 0xffff, 0x0018, 0x001e, 0x015e, 0x71ae,
 	0x004e, 0x002e, 0x00ce, 0x00be, 0x0005, 0x00c6, 0x0016, 0x70af,
-	0x0001, 0x2009, 0x007e, 0x080c, 0x65bf, 0x1168, 0xb813, 0x00ff,
-	0xb817, 0xfffe, 0x080c, 0x323a, 0x04a9, 0x0128, 0x70dc, 0xc0bd,
-	0x70de, 0x080c, 0xcc9e, 0x001e, 0x00ce, 0x0005, 0x0016, 0x0076,
+	0x0001, 0x2009, 0x007e, 0x080c, 0x65e3, 0x1168, 0xb813, 0x00ff,
+	0xb817, 0xfffe, 0x080c, 0x325a, 0x04a9, 0x0128, 0x70dc, 0xc0bd,
+	0x70de, 0x080c, 0xccd1, 0x001e, 0x00ce, 0x0005, 0x0016, 0x0076,
 	0x00d6, 0x00c6, 0x2001, 0x184c, 0x2004, 0x9084, 0x00ff, 0xb842,
-	0x080c, 0xac4f, 0x01d0, 0x2b00, 0x6012, 0x080c, 0xcccb, 0x6023,
-	0x0001, 0x9006, 0x080c, 0x655c, 0x2001, 0x0000, 0x080c, 0x6570,
+	0x080c, 0xac60, 0x01d0, 0x2b00, 0x6012, 0x080c, 0xccfe, 0x6023,
+	0x0001, 0x9006, 0x080c, 0x6580, 0x2001, 0x0000, 0x080c, 0x6594,
 	0x0126, 0x2091, 0x8000, 0x70a8, 0x8000, 0x70aa, 0x012e, 0x2009,
-	0x0004, 0x080c, 0xac7c, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e,
+	0x0004, 0x080c, 0xac8d, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e,
 	0x001e, 0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x2001, 0x184c,
-	0x2004, 0x9084, 0x00ff, 0xb842, 0x080c, 0xac4f, 0x0548, 0x2b00,
+	0x2004, 0x9084, 0x00ff, 0xb842, 0x080c, 0xac60, 0x0548, 0x2b00,
 	0x6012, 0xb800, 0xc0c4, 0xb802, 0xb8a0, 0x9086, 0x007e, 0x0140,
-	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x1110, 0x080c, 0x31ef,
-	0x080c, 0xcccb, 0x6023, 0x0001, 0x9006, 0x080c, 0x655c, 0x2001,
-	0x0002, 0x080c, 0x6570, 0x0126, 0x2091, 0x8000, 0x70a8, 0x8000,
-	0x70aa, 0x012e, 0x2009, 0x0002, 0x080c, 0xac7c, 0x9085, 0x0001,
+	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x1110, 0x080c, 0x320f,
+	0x080c, 0xccfe, 0x6023, 0x0001, 0x9006, 0x080c, 0x6580, 0x2001,
+	0x0002, 0x080c, 0x6594, 0x0126, 0x2091, 0x8000, 0x70a8, 0x8000,
+	0x70aa, 0x012e, 0x2009, 0x0002, 0x080c, 0xac8d, 0x9085, 0x0001,
 	0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00b6, 0x00c6, 0x0026,
-	0x2009, 0x0080, 0x080c, 0x65bf, 0x1140, 0xb813, 0x00ff, 0xb817,
+	0x2009, 0x0080, 0x080c, 0x65e3, 0x1140, 0xb813, 0x00ff, 0xb817,
 	0xfffc, 0x0039, 0x0110, 0x70e3, 0xffff, 0x002e, 0x00ce, 0x00be,
-	0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x080c, 0xab89, 0x01d0,
-	0x2b00, 0x6012, 0x080c, 0xcccb, 0x6023, 0x0001, 0x9006, 0x080c,
-	0x655c, 0x2001, 0x0002, 0x080c, 0x6570, 0x0126, 0x2091, 0x8000,
-	0x70e4, 0x8000, 0x70e6, 0x012e, 0x2009, 0x0002, 0x080c, 0xac7c,
+	0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x080c, 0xab9a, 0x01d0,
+	0x2b00, 0x6012, 0x080c, 0xccfe, 0x6023, 0x0001, 0x9006, 0x080c,
+	0x6580, 0x2001, 0x0002, 0x080c, 0x6594, 0x0126, 0x2091, 0x8000,
+	0x70e4, 0x8000, 0x70e6, 0x012e, 0x2009, 0x0002, 0x080c, 0xac8d,
 	0x9085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00c6,
-	0x00d6, 0x0126, 0x2091, 0x8000, 0x2009, 0x007f, 0x080c, 0x65bf,
+	0x00d6, 0x0126, 0x2091, 0x8000, 0x2009, 0x007f, 0x080c, 0x65e3,
 	0x11b8, 0xb813, 0x00ff, 0xb817, 0xfffd, 0xb8d7, 0x0004, 0x080c,
-	0xab89, 0x0170, 0x2b00, 0x6012, 0x6316, 0x6023, 0x0001, 0x620a,
-	0x080c, 0xcccb, 0x2009, 0x0022, 0x080c, 0xac7c, 0x9085, 0x0001,
+	0xab9a, 0x0170, 0x2b00, 0x6012, 0x6316, 0x6023, 0x0001, 0x620a,
+	0x080c, 0xccfe, 0x2009, 0x0022, 0x080c, 0xac8d, 0x9085, 0x0001,
 	0x012e, 0x00de, 0x00ce, 0x0005, 0x00e6, 0x00c6, 0x0066, 0x0036,
-	0x0026, 0x00b6, 0x21f0, 0x080c, 0xa888, 0x0106, 0x080c, 0x9398,
-	0x080c, 0x9309, 0x080c, 0xa7d9, 0x080c, 0xbb0c, 0x010e, 0x090c,
-	0xa8a4, 0x3e08, 0x2130, 0x81ff, 0x0120, 0x20a9, 0x007e, 0x900e,
-	0x0018, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6620, 0x1140,
-	0x9686, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x1110, 0x080c, 0x603e,
-	0x001e, 0x8108, 0x1f04, 0x31d4, 0x9686, 0x0001, 0x190c, 0x332b,
+	0x0026, 0x00b6, 0x21f0, 0x080c, 0xa899, 0x0106, 0x080c, 0x93d1,
+	0x080c, 0x9342, 0x080c, 0xa7ea, 0x080c, 0xbb2c, 0x010e, 0x090c,
+	0xa8b5, 0x3e08, 0x2130, 0x81ff, 0x0120, 0x20a9, 0x007e, 0x900e,
+	0x0018, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6644, 0x1140,
+	0x9686, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x1110, 0x080c, 0x605e,
+	0x001e, 0x8108, 0x1f04, 0x31f4, 0x9686, 0x0001, 0x190c, 0x334b,
 	0x00be, 0x002e, 0x003e, 0x006e, 0x00ce, 0x00ee, 0x0005, 0x00e6,
-	0x00c6, 0x0046, 0x0036, 0x0026, 0x0016, 0x00b6, 0x080c, 0xa888,
+	0x00c6, 0x0046, 0x0036, 0x0026, 0x0016, 0x00b6, 0x080c, 0xa899,
 	0x0106, 0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c,
-	0x938d, 0x0076, 0x2039, 0x0000, 0x080c, 0x9256, 0x2c08, 0x080c,
-	0xdffb, 0x007e, 0x001e, 0x010e, 0x090c, 0xa8a4, 0xba10, 0xbb14,
-	0xbc84, 0x080c, 0x603e, 0xba12, 0xbb16, 0xbc86, 0x00be, 0x001e,
+	0x93c6, 0x0076, 0x2039, 0x0000, 0x080c, 0x928f, 0x2c08, 0x080c,
+	0xe038, 0x007e, 0x001e, 0x010e, 0x090c, 0xa8b5, 0xba10, 0xbb14,
+	0xbc84, 0x080c, 0x605e, 0xba12, 0xbb16, 0xbc86, 0x00be, 0x001e,
 	0x002e, 0x003e, 0x004e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x0006,
 	0x00b6, 0x6010, 0x2058, 0xb8a0, 0x00be, 0x9086, 0x0080, 0x0150,
 	0x2071, 0x1800, 0x70a8, 0x9005, 0x0110, 0x8001, 0x70aa, 0x000e,
 	0x00ee, 0x0005, 0x2071, 0x1800, 0x70e4, 0x9005, 0x0dc0, 0x8001,
 	0x70e6, 0x0ca8, 0xb800, 0xc08c, 0xb802, 0x0005, 0x00f6, 0x00e6,
 	0x00c6, 0x00b6, 0x0046, 0x0036, 0x0026, 0x0016, 0x0156, 0x2178,
-	0x080c, 0xa888, 0x0106, 0x81ff, 0x1118, 0x20a9, 0x0001, 0x0078,
-	0x080c, 0x56d5, 0xd0c4, 0x0140, 0xd0a4, 0x0130, 0x9006, 0x2020,
-	0x2009, 0x002d, 0x080c, 0xe2d9, 0x20a9, 0x0800, 0x9016, 0x0026,
-	0x928e, 0x007e, 0x0904, 0x32a9, 0x928e, 0x007f, 0x0904, 0x32a9,
+	0x080c, 0xa899, 0x0106, 0x81ff, 0x1118, 0x20a9, 0x0001, 0x0078,
+	0x080c, 0x56f5, 0xd0c4, 0x0140, 0xd0a4, 0x0130, 0x9006, 0x2020,
+	0x2009, 0x002d, 0x080c, 0xe316, 0x20a9, 0x0800, 0x9016, 0x0026,
+	0x928e, 0x007e, 0x0904, 0x32c9, 0x928e, 0x007f, 0x0904, 0x32c9,
 	0x928e, 0x0080, 0x05f0, 0x9288, 0x1000, 0x210c, 0x81ff, 0x05c8,
 	0x8fff, 0x1150, 0x2001, 0x198d, 0x0006, 0x2003, 0x0001, 0x080c,
-	0x32ba, 0x000e, 0x2003, 0x0000, 0x00b6, 0x00c6, 0x2158, 0x2001,
-	0x0001, 0x080c, 0x6a34, 0x00ce, 0x00be, 0x2019, 0x0029, 0x080c,
-	0x938d, 0x0076, 0x2039, 0x0000, 0x080c, 0x9256, 0x00b6, 0x00c6,
+	0x32da, 0x000e, 0x2003, 0x0000, 0x00b6, 0x00c6, 0x2158, 0x2001,
+	0x0001, 0x080c, 0x6a58, 0x00ce, 0x00be, 0x2019, 0x0029, 0x080c,
+	0x93c6, 0x0076, 0x2039, 0x0000, 0x080c, 0x928f, 0x00b6, 0x00c6,
 	0x0026, 0x2158, 0xba04, 0x9294, 0x00ff, 0x9286, 0x0006, 0x1118,
 	0xb807, 0x0404, 0x0028, 0x2001, 0x0004, 0x8007, 0x9215, 0xba06,
-	0x002e, 0x00ce, 0x00be, 0x0016, 0x2c08, 0x080c, 0xdffb, 0x001e,
-	0x007e, 0x002e, 0x8210, 0x1f04, 0x325f, 0x010e, 0x090c, 0xa8a4,
+	0x002e, 0x00ce, 0x00be, 0x0016, 0x2c08, 0x080c, 0xe038, 0x001e,
+	0x007e, 0x002e, 0x8210, 0x1f04, 0x327f, 0x010e, 0x090c, 0xa8b5,
 	0x015e, 0x001e, 0x002e, 0x003e, 0x004e, 0x00be, 0x00ce, 0x00ee,
-	0x00fe, 0x0005, 0x0046, 0x0026, 0x0016, 0x080c, 0x56d5, 0xd0c4,
+	0x00fe, 0x0005, 0x0046, 0x0026, 0x0016, 0x080c, 0x56f5, 0xd0c4,
 	0x0140, 0xd0a4, 0x0130, 0x9006, 0x2220, 0x2009, 0x0029, 0x080c,
-	0xe2d9, 0x001e, 0x002e, 0x004e, 0x0005, 0x0016, 0x0026, 0x0036,
-	0x00c6, 0x7294, 0x82ff, 0x01e8, 0x080c, 0x6a62, 0x11d0, 0x2100,
-	0x080c, 0x2647, 0x81ff, 0x01b8, 0x2019, 0x0001, 0x8314, 0x92e0,
+	0xe316, 0x001e, 0x002e, 0x004e, 0x0005, 0x0016, 0x0026, 0x0036,
+	0x00c6, 0x7294, 0x82ff, 0x01e8, 0x080c, 0x6a86, 0x11d0, 0x2100,
+	0x080c, 0x2663, 0x81ff, 0x01b8, 0x2019, 0x0001, 0x8314, 0x92e0,
 	0x1d80, 0x2c04, 0xd384, 0x0120, 0x9084, 0xff00, 0x8007, 0x0010,
 	0x9084, 0x00ff, 0x9116, 0x0138, 0x9096, 0x00ff, 0x0110, 0x8318,
 	0x0c68, 0x9085, 0x0001, 0x00ce, 0x003e, 0x002e, 0x001e, 0x0005,
-	0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xa888, 0x0106,
-	0x0036, 0x2019, 0x0029, 0x00c1, 0x003e, 0x010e, 0x090c, 0xa8a4,
+	0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xa899, 0x0106,
+	0x0036, 0x2019, 0x0029, 0x00c1, 0x003e, 0x010e, 0x090c, 0xa8b5,
 	0x9180, 0x1000, 0x2004, 0x9065, 0x0158, 0x0016, 0x00c6, 0x2061,
-	0x1b31, 0x001e, 0x6112, 0x080c, 0x31ef, 0x001e, 0x080c, 0x65e4,
+	0x1b31, 0x001e, 0x6112, 0x080c, 0x320f, 0x001e, 0x080c, 0x6608,
 	0x012e, 0x00ce, 0x001e, 0x0005, 0x0016, 0x0026, 0x2110, 0x080c,
-	0xa372, 0x080c, 0xe640, 0x002e, 0x001e, 0x0005, 0x2001, 0x1837,
-	0x2004, 0xd0cc, 0x0005, 0x00c6, 0x00b6, 0x080c, 0x74c8, 0x1118,
-	0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782, 0x080c, 0x74c8, 0x1110,
+	0xa37f, 0x080c, 0xe67d, 0x002e, 0x001e, 0x0005, 0x2001, 0x1837,
+	0x2004, 0xd0cc, 0x0005, 0x00c6, 0x00b6, 0x080c, 0x74ec, 0x1118,
+	0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782, 0x080c, 0x74ec, 0x1110,
 	0x900e, 0x0010, 0x2009, 0x007e, 0x9180, 0x1000, 0x2004, 0x905d,
-	0x0130, 0x86ff, 0x0110, 0xb800, 0xd0bc, 0x090c, 0x65e4, 0x8108,
-	0x1f04, 0x333c, 0x2061, 0x1800, 0x607f, 0x0000, 0x6080, 0x9084,
+	0x0130, 0x86ff, 0x0110, 0xb800, 0xd0bc, 0x090c, 0x6608, 0x8108,
+	0x1f04, 0x335c, 0x2061, 0x1800, 0x607f, 0x0000, 0x6080, 0x9084,
 	0x00ff, 0x6082, 0x60b3, 0x0000, 0x00be, 0x00ce, 0x0005, 0x2001,
 	0x1869, 0x2004, 0xd0bc, 0x0005, 0x2011, 0x1848, 0x2214, 0xd2ec,
 	0x0005, 0x0026, 0x2011, 0x1867, 0x2214, 0xd2dc, 0x002e, 0x0005,
@@ -1473,89 +1477,89 @@
 	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
 	0x2071, 0x189e, 0x7003, 0x0002, 0x9006, 0x7016, 0x701a, 0x704a,
 	0x704e, 0x700e, 0x7042, 0x7046, 0x703b, 0x18ba, 0x703f, 0x18ba,
-	0x7007, 0x0001, 0x080c, 0x1053, 0x090c, 0x0d7d, 0x2900, 0x706a,
-	0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x080c, 0x1053, 0x090c, 0x0d7d,
+	0x7007, 0x0001, 0x080c, 0x1060, 0x090c, 0x0d7d, 0x2900, 0x706a,
+	0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x080c, 0x1060, 0x090c, 0x0d7d,
 	0x2900, 0x706e, 0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x0005, 0x2071,
-	0x189e, 0x7004, 0x0002, 0x3497, 0x3498, 0x34ab, 0x34bf, 0x0005,
-	0x1004, 0x34a8, 0x0e04, 0x34a8, 0x2079, 0x0000, 0x0126, 0x2091,
+	0x189e, 0x7004, 0x0002, 0x34b7, 0x34b8, 0x34cb, 0x34df, 0x0005,
+	0x1004, 0x34c8, 0x0e04, 0x34c8, 0x2079, 0x0000, 0x0126, 0x2091,
 	0x8000, 0x700c, 0x9005, 0x1128, 0x700f, 0x0001, 0x012e, 0x0468,
 	0x0005, 0x012e, 0x0ce8, 0x2079, 0x0000, 0x2061, 0x18b8, 0x2c4c,
-	0xa86c, 0x908e, 0x0100, 0x0128, 0x9086, 0x0200, 0x0904, 0x3593,
+	0xa86c, 0x908e, 0x0100, 0x0128, 0x9086, 0x0200, 0x0904, 0x35b3,
 	0x0005, 0x7018, 0x2048, 0x2061, 0x1800, 0x701c, 0x0807, 0x7014,
 	0x2048, 0xa864, 0x9094, 0x00ff, 0x9296, 0x0029, 0x1120, 0xaa78,
 	0xd2fc, 0x0128, 0x0005, 0x9086, 0x0103, 0x0108, 0x0005, 0x2079,
 	0x0000, 0x2061, 0x1800, 0x701c, 0x0807, 0x2061, 0x1800, 0x7880,
 	0x908a, 0x0040, 0x1210, 0x61d0, 0x0042, 0x2100, 0x908a, 0x003f,
-	0x1a04, 0x3590, 0x61d0, 0x0804, 0x3525, 0x3567, 0x359f, 0x3590,
-	0x35a9, 0x35b3, 0x35b9, 0x35bd, 0x35cd, 0x35d1, 0x35e7, 0x35ed,
-	0x35f3, 0x35fe, 0x3609, 0x3618, 0x3627, 0x3635, 0x364c, 0x3667,
-	0x3590, 0x3710, 0x374e, 0x37f3, 0x3804, 0x3827, 0x3590, 0x3590,
-	0x3590, 0x385f, 0x387f, 0x3888, 0x38b4, 0x38ba, 0x3590, 0x3900,
-	0x3590, 0x3590, 0x3590, 0x3590, 0x3590, 0x390b, 0x3914, 0x391c,
-	0x391e, 0x3590, 0x3590, 0x3590, 0x3590, 0x3590, 0x3590, 0x394e,
-	0x3590, 0x3590, 0x3590, 0x3590, 0x3590, 0x396b, 0x39cf, 0x3590,
-	0x3590, 0x3590, 0x3590, 0x3590, 0x3590, 0x0002, 0x39f9, 0x39fc,
-	0x3a5b, 0x3a74, 0x3aa4, 0x3d46, 0x3590, 0x52a6, 0x3590, 0x3590,
-	0x3590, 0x3590, 0x3590, 0x3590, 0x3590, 0x3590, 0x35e7, 0x35ed,
-	0x4245, 0x56f9, 0x4263, 0x5335, 0x5386, 0x5489, 0x3590, 0x54eb,
-	0x5527, 0x5558, 0x5664, 0x5585, 0x55e4, 0x3590, 0x4267, 0x441c,
-	0x4432, 0x4457, 0x44bc, 0x4530, 0x4550, 0x45c7, 0x4623, 0x467f,
-	0x4682, 0x46a7, 0x4717, 0x4781, 0x4789, 0x48bb, 0x4a33, 0x4a67,
-	0x4ccb, 0x3590, 0x4ce9, 0x4d8e, 0x4e70, 0x4eca, 0x3590, 0x4f7f,
-	0x3590, 0x4fe5, 0x5000, 0x4789, 0x5246, 0x714c, 0x0000, 0x2021,
-	0x4000, 0x080c, 0x4ae5, 0x0126, 0x2091, 0x8000, 0x0e04, 0x3571,
+	0x1a04, 0x35b0, 0x61d0, 0x0804, 0x3545, 0x3587, 0x35bf, 0x35b0,
+	0x35c9, 0x35d3, 0x35d9, 0x35dd, 0x35ed, 0x35f1, 0x3607, 0x360d,
+	0x3613, 0x361e, 0x3629, 0x3638, 0x3647, 0x3655, 0x366c, 0x3687,
+	0x35b0, 0x3730, 0x376e, 0x3813, 0x3824, 0x3847, 0x35b0, 0x35b0,
+	0x35b0, 0x387f, 0x389f, 0x38a8, 0x38d4, 0x38da, 0x35b0, 0x3920,
+	0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x392b, 0x3934, 0x393c,
+	0x393e, 0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x396e,
+	0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x398b, 0x39ef, 0x35b0,
+	0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x0002, 0x3a19, 0x3a1c,
+	0x3a7b, 0x3a94, 0x3ac4, 0x3d66, 0x35b0, 0x52c6, 0x35b0, 0x35b0,
+	0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x35b0, 0x3607, 0x360d,
+	0x4265, 0x5719, 0x4283, 0x5355, 0x53a6, 0x54a9, 0x35b0, 0x550b,
+	0x5547, 0x5578, 0x5684, 0x55a5, 0x5604, 0x35b0, 0x4287, 0x443c,
+	0x4452, 0x4477, 0x44dc, 0x4550, 0x4570, 0x45e7, 0x4643, 0x469f,
+	0x46a2, 0x46c7, 0x4737, 0x47a1, 0x47a9, 0x48db, 0x4a53, 0x4a87,
+	0x4ceb, 0x35b0, 0x4d09, 0x4dae, 0x4e90, 0x4eea, 0x35b0, 0x4f9f,
+	0x35b0, 0x5005, 0x5020, 0x47a9, 0x5266, 0x714c, 0x0000, 0x2021,
+	0x4000, 0x080c, 0x4b05, 0x0126, 0x2091, 0x8000, 0x0e04, 0x3591,
 	0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000, 0x0118, 0x7833,
 	0x0011, 0x0010, 0x7833, 0x0010, 0x7c82, 0x7986, 0x7a8a, 0x7b8e,
-	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11e1,
+	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11ee,
 	0x7007, 0x0001, 0x2091, 0x5000, 0x700f, 0x0000, 0x012e, 0x0005,
 	0x2021, 0x4001, 0x08b0, 0x2021, 0x4002, 0x0898, 0x2021, 0x4003,
 	0x0880, 0x2021, 0x4005, 0x0868, 0x2021, 0x4006, 0x0850, 0x2039,
 	0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884, 0x7990, 0x0804,
-	0x4af2, 0x2039, 0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884,
-	0x7990, 0x0804, 0x4af5, 0x7984, 0x7888, 0x2114, 0x200a, 0x0804,
-	0x3567, 0x7984, 0x2114, 0x0804, 0x3567, 0x20e1, 0x0000, 0x2099,
+	0x4b12, 0x2039, 0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884,
+	0x7990, 0x0804, 0x4b15, 0x7984, 0x7888, 0x2114, 0x200a, 0x0804,
+	0x3587, 0x7984, 0x2114, 0x0804, 0x3587, 0x20e1, 0x0000, 0x2099,
 	0x0021, 0x20e9, 0x0000, 0x20a1, 0x0021, 0x20a9, 0x001f, 0x4003,
-	0x7984, 0x7a88, 0x7b8c, 0x0804, 0x3567, 0x7884, 0x2060, 0x0804,
-	0x361a, 0x2009, 0x0003, 0x2011, 0x0002, 0x2019, 0x001e, 0x789b,
+	0x7984, 0x7a88, 0x7b8c, 0x0804, 0x3587, 0x7884, 0x2060, 0x0804,
+	0x363a, 0x2009, 0x0003, 0x2011, 0x0003, 0x2019, 0x0002, 0x789b,
 	0x0137, 0x7893, 0xffff, 0x2001, 0x188f, 0x2004, 0x9005, 0x0118,
-	0x7896, 0x0804, 0x3567, 0x7897, 0x0001, 0x0804, 0x3567, 0x2039,
-	0x0001, 0x7d98, 0x7c9c, 0x0804, 0x35a3, 0x2039, 0x0001, 0x7d98,
-	0x7c9c, 0x0804, 0x35ad, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804,
-	0x359c, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x35a3, 0x79a0, 0x9182,
-	0x0040, 0x0210, 0x0804, 0x359c, 0x2138, 0x7d98, 0x7c9c, 0x0804,
-	0x35ad, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x359c, 0x21e8,
-	0x7984, 0x7888, 0x20a9, 0x0001, 0x21a0, 0x4004, 0x0804, 0x3567,
+	0x7896, 0x0804, 0x3587, 0x7897, 0x0001, 0x0804, 0x3587, 0x2039,
+	0x0001, 0x7d98, 0x7c9c, 0x0804, 0x35c3, 0x2039, 0x0001, 0x7d98,
+	0x7c9c, 0x0804, 0x35cd, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804,
+	0x35bc, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x35c3, 0x79a0, 0x9182,
+	0x0040, 0x0210, 0x0804, 0x35bc, 0x2138, 0x7d98, 0x7c9c, 0x0804,
+	0x35cd, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x35bc, 0x21e8,
+	0x7984, 0x7888, 0x20a9, 0x0001, 0x21a0, 0x4004, 0x0804, 0x3587,
 	0x2061, 0x0800, 0xe10c, 0x9006, 0x2c15, 0x9200, 0x8c60, 0x8109,
-	0x1dd8, 0x2010, 0x9005, 0x0904, 0x3567, 0x0804, 0x3596, 0x79a0,
-	0x9182, 0x0040, 0x0210, 0x0804, 0x359c, 0x21e0, 0x20a9, 0x0001,
-	0x7984, 0x2198, 0x4012, 0x0804, 0x3567, 0x2069, 0x1847, 0x7884,
-	0x7990, 0x911a, 0x1a04, 0x359c, 0x8019, 0x0904, 0x359c, 0x684a,
+	0x1dd8, 0x2010, 0x9005, 0x0904, 0x3587, 0x0804, 0x35b6, 0x79a0,
+	0x9182, 0x0040, 0x0210, 0x0804, 0x35bc, 0x21e0, 0x20a9, 0x0001,
+	0x7984, 0x2198, 0x4012, 0x0804, 0x3587, 0x2069, 0x1847, 0x7884,
+	0x7990, 0x911a, 0x1a04, 0x35bc, 0x8019, 0x0904, 0x35bc, 0x684a,
 	0x6942, 0x788c, 0x6852, 0x7888, 0x6856, 0x9006, 0x685a, 0x685e,
-	0x080c, 0x77fd, 0x0804, 0x3567, 0x2069, 0x1847, 0x7884, 0x7994,
-	0x911a, 0x1a04, 0x359c, 0x8019, 0x0904, 0x359c, 0x684e, 0x6946,
+	0x080c, 0x7820, 0x0804, 0x3587, 0x2069, 0x1847, 0x7884, 0x7994,
+	0x911a, 0x1a04, 0x35bc, 0x8019, 0x0904, 0x35bc, 0x684e, 0x6946,
 	0x788c, 0x6862, 0x7888, 0x6866, 0x9006, 0x686a, 0x686e, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x6ad0, 0x012e, 0x0804, 0x3567, 0x902e,
-	0x2520, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3599, 0x7984,
+	0x2091, 0x8000, 0x080c, 0x6af4, 0x012e, 0x0804, 0x3587, 0x902e,
+	0x2520, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x35b9, 0x7984,
 	0x7b88, 0x7a8c, 0x20a9, 0x0005, 0x20e9, 0x0001, 0x20a1, 0x18a6,
-	0x4101, 0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804, 0x3599,
-	0x2009, 0x0020, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x4af2,
-	0x701f, 0x368b, 0x0005, 0xa864, 0x2008, 0x9084, 0x00ff, 0x9096,
+	0x4101, 0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804, 0x35b9,
+	0x2009, 0x0020, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x4b12,
+	0x701f, 0x36ab, 0x0005, 0xa864, 0x2008, 0x9084, 0x00ff, 0x9096,
 	0x0011, 0x0168, 0x9096, 0x0019, 0x0150, 0x9096, 0x0015, 0x0138,
-	0x9096, 0x0048, 0x0120, 0x9096, 0x0029, 0x1904, 0x3599, 0x810f,
-	0x918c, 0x00ff, 0x0904, 0x3599, 0x7112, 0x7010, 0x8001, 0x0560,
-	0x7012, 0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804, 0x3599,
+	0x9096, 0x0048, 0x0120, 0x9096, 0x0029, 0x1904, 0x35b9, 0x810f,
+	0x918c, 0x00ff, 0x0904, 0x35b9, 0x7112, 0x7010, 0x8001, 0x0560,
+	0x7012, 0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804, 0x35b9,
 	0x2009, 0x0020, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494, 0xa598,
 	0x9290, 0x0040, 0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000,
-	0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x4af2, 0x701f, 0x36c9,
+	0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x4b12, 0x701f, 0x36e9,
 	0x0005, 0xa864, 0x9084, 0x00ff, 0x9096, 0x0002, 0x0120, 0x9096,
-	0x000a, 0x1904, 0x3599, 0x0888, 0x7014, 0x2048, 0xa868, 0xc0fd,
+	0x000a, 0x1904, 0x35b9, 0x0888, 0x7014, 0x2048, 0xa868, 0xc0fd,
 	0xa86a, 0xa864, 0x9084, 0x00ff, 0x9096, 0x0029, 0x1160, 0xc2fd,
-	0xaa7a, 0x080c, 0x6191, 0x0150, 0x0126, 0x2091, 0x8000, 0xa87a,
-	0xa982, 0x012e, 0x0050, 0x080c, 0x64ba, 0x1128, 0x7007, 0x0003,
-	0x701f, 0x36f5, 0x0005, 0x080c, 0x6faf, 0x0126, 0x2091, 0x8000,
+	0xaa7a, 0x080c, 0x61b1, 0x0150, 0x0126, 0x2091, 0x8000, 0xa87a,
+	0xa982, 0x012e, 0x0050, 0x080c, 0x64de, 0x1128, 0x7007, 0x0003,
+	0x701f, 0x3715, 0x0005, 0x080c, 0x6fd3, 0x0126, 0x2091, 0x8000,
 	0x20a9, 0x0005, 0x20e1, 0x0001, 0x2099, 0x18a6, 0x400a, 0x2100,
 	0x9210, 0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c,
-	0x9080, 0x0019, 0x2009, 0x0020, 0x012e, 0xaf60, 0x0804, 0x4af5,
+	0x9080, 0x0019, 0x2009, 0x0020, 0x012e, 0xaf60, 0x0804, 0x4b15,
 	0x2091, 0x8000, 0x7837, 0x4000, 0x7833, 0x0010, 0x7883, 0x4000,
 	0x7887, 0x4953, 0x788b, 0x5020, 0x788f, 0x2020, 0x2009, 0x017f,
 	0x2104, 0x7892, 0x3f00, 0x7896, 0x2061, 0x0100, 0x6200, 0x2061,
@@ -1564,267 +1568,267 @@
 	0xd084, 0x0180, 0x2001, 0x1a21, 0x2004, 0x9005, 0x0128, 0x2001,
 	0x008b, 0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002,
 	0x2003, 0x1001, 0x2071, 0x0080, 0x0804, 0x0427, 0x81ff, 0x1904,
-	0x3599, 0x7984, 0x080c, 0x6620, 0x1904, 0x359c, 0x7e98, 0x9684,
-	0x3fff, 0x9082, 0x4000, 0x1a04, 0x359c, 0x7c88, 0x7d8c, 0x080c,
-	0x6856, 0x080c, 0x67e3, 0x1518, 0x2061, 0x1ddc, 0x0126, 0x2091,
+	0x35b9, 0x7984, 0x080c, 0x6644, 0x1904, 0x35bc, 0x7e98, 0x9684,
+	0x3fff, 0x9082, 0x4000, 0x1a04, 0x35bc, 0x7c88, 0x7d8c, 0x080c,
+	0x687a, 0x080c, 0x6807, 0x1518, 0x2061, 0x1ddc, 0x0126, 0x2091,
 	0x8000, 0x6000, 0x9086, 0x0000, 0x0148, 0x6014, 0x904d, 0x0130,
 	0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0150, 0x012e, 0x9ce0,
-	0x001c, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1a04, 0x3599, 0x0c30,
-	0x080c, 0xc430, 0x012e, 0x0904, 0x3599, 0x0804, 0x3567, 0x900e,
-	0x2001, 0x0005, 0x080c, 0x6faf, 0x0126, 0x2091, 0x8000, 0x080c,
-	0xcb3b, 0x080c, 0x6d7b, 0x012e, 0x0804, 0x3567, 0x00a6, 0x2950,
-	0xb198, 0x080c, 0x6620, 0x1904, 0x37e0, 0xb6a4, 0x9684, 0x3fff,
-	0x9082, 0x4000, 0x16e8, 0xb49c, 0xb5a0, 0x080c, 0x6856, 0x080c,
-	0x6800, 0x1520, 0x2061, 0x1ddc, 0x0126, 0x2091, 0x8000, 0x6000,
+	0x001c, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1a04, 0x35b9, 0x0c30,
+	0x080c, 0xc453, 0x012e, 0x0904, 0x35b9, 0x0804, 0x3587, 0x900e,
+	0x2001, 0x0005, 0x080c, 0x6fd3, 0x0126, 0x2091, 0x8000, 0x080c,
+	0xcb6e, 0x080c, 0x6d9f, 0x012e, 0x0804, 0x3587, 0x00a6, 0x2950,
+	0xb198, 0x080c, 0x6644, 0x1904, 0x3800, 0xb6a4, 0x9684, 0x3fff,
+	0x9082, 0x4000, 0x16e8, 0xb49c, 0xb5a0, 0x080c, 0x687a, 0x080c,
+	0x6824, 0x1520, 0x2061, 0x1ddc, 0x0126, 0x2091, 0x8000, 0x6000,
 	0x9086, 0x0000, 0x0148, 0x6014, 0x904d, 0x0130, 0xa86c, 0x9406,
 	0x1118, 0xa870, 0x9506, 0x0158, 0x012e, 0x9ce0, 0x001c, 0x2001,
 	0x181a, 0x2004, 0x9c02, 0x2009, 0x000d, 0x12b0, 0x0c28, 0x080c,
-	0xc430, 0x012e, 0x2009, 0x0003, 0x0178, 0x00e0, 0x900e, 0x2001,
-	0x0005, 0x080c, 0x6faf, 0x0126, 0x2091, 0x8000, 0x080c, 0xcb3b,
-	0x080c, 0x6d6f, 0x012e, 0x0070, 0xb097, 0x4005, 0xb19a, 0x0010,
+	0xc453, 0x012e, 0x2009, 0x0003, 0x0178, 0x00e0, 0x900e, 0x2001,
+	0x0005, 0x080c, 0x6fd3, 0x0126, 0x2091, 0x8000, 0x080c, 0xcb6e,
+	0x080c, 0x6d93, 0x012e, 0x0070, 0xb097, 0x4005, 0xb19a, 0x0010,
 	0xb097, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x2a48,
 	0x00ae, 0x0005, 0xb097, 0x4000, 0x9006, 0x918d, 0x0001, 0x2008,
-	0x2a48, 0x00ae, 0x0005, 0x81ff, 0x1904, 0x3599, 0x080c, 0x4ac0,
-	0x0904, 0x359c, 0x080c, 0x66e7, 0x0904, 0x3599, 0x080c, 0x685c,
-	0x0904, 0x3599, 0x0804, 0x4547, 0x81ff, 0x1904, 0x3599, 0x080c,
-	0x4adc, 0x0904, 0x359c, 0x080c, 0x68ea, 0x0904, 0x3599, 0x2019,
-	0x0005, 0x79a8, 0x080c, 0x6877, 0x0904, 0x3599, 0x7888, 0x908a,
-	0x1000, 0x1a04, 0x359c, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c,
-	0x862b, 0x7984, 0xd184, 0x1904, 0x3567, 0x0804, 0x4547, 0x0126,
+	0x2a48, 0x00ae, 0x0005, 0x81ff, 0x1904, 0x35b9, 0x080c, 0x4ae0,
+	0x0904, 0x35bc, 0x080c, 0x670b, 0x0904, 0x35b9, 0x080c, 0x6880,
+	0x0904, 0x35b9, 0x0804, 0x4567, 0x81ff, 0x1904, 0x35b9, 0x080c,
+	0x4afc, 0x0904, 0x35bc, 0x080c, 0x690e, 0x0904, 0x35b9, 0x2019,
+	0x0005, 0x79a8, 0x080c, 0x689b, 0x0904, 0x35b9, 0x7888, 0x908a,
+	0x1000, 0x1a04, 0x35bc, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c,
+	0x865f, 0x7984, 0xd184, 0x1904, 0x3587, 0x0804, 0x4567, 0x0126,
 	0x2091, 0x8000, 0x81ff, 0x0118, 0x2009, 0x0001, 0x0450, 0x2029,
-	0x07ff, 0x645c, 0x2400, 0x9506, 0x01f8, 0x2508, 0x080c, 0x6620,
-	0x11d8, 0x080c, 0x68ea, 0x1128, 0x2009, 0x0002, 0x62c0, 0x2518,
-	0x00c0, 0x2019, 0x0004, 0x900e, 0x080c, 0x6877, 0x1118, 0x2009,
+	0x07ff, 0x645c, 0x2400, 0x9506, 0x01f8, 0x2508, 0x080c, 0x6644,
+	0x11d8, 0x080c, 0x690e, 0x1128, 0x2009, 0x0002, 0x62c0, 0x2518,
+	0x00c0, 0x2019, 0x0004, 0x900e, 0x080c, 0x689b, 0x1118, 0x2009,
 	0x0006, 0x0078, 0x7884, 0x908a, 0x1000, 0x1270, 0x8003, 0x800b,
-	0x810b, 0x9108, 0x080c, 0x862b, 0x8529, 0x1ae0, 0x012e, 0x0804,
-	0x3567, 0x012e, 0x0804, 0x3599, 0x012e, 0x0804, 0x359c, 0x080c,
-	0x4ac0, 0x0904, 0x359c, 0x080c, 0x66e7, 0x0904, 0x3599, 0x080c,
-	0xa888, 0xbaa0, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c, 0x938d,
-	0x0076, 0x903e, 0x080c, 0x9256, 0x900e, 0x080c, 0xdffb, 0x007e,
-	0x00ce, 0x080c, 0xa8a4, 0x080c, 0x6856, 0x0804, 0x3567, 0x080c,
-	0x4ac0, 0x0904, 0x359c, 0x080c, 0x6856, 0x2208, 0x0804, 0x3567,
+	0x810b, 0x9108, 0x080c, 0x865f, 0x8529, 0x1ae0, 0x012e, 0x0804,
+	0x3587, 0x012e, 0x0804, 0x35b9, 0x012e, 0x0804, 0x35bc, 0x080c,
+	0x4ae0, 0x0904, 0x35bc, 0x080c, 0x670b, 0x0904, 0x35b9, 0x080c,
+	0xa899, 0xbaa0, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c, 0x93c6,
+	0x0076, 0x903e, 0x080c, 0x928f, 0x900e, 0x080c, 0xe038, 0x007e,
+	0x00ce, 0x080c, 0xa8b5, 0x080c, 0x687a, 0x0804, 0x3587, 0x080c,
+	0x4ae0, 0x0904, 0x35bc, 0x080c, 0x687a, 0x2208, 0x0804, 0x3587,
 	0x0156, 0x00d6, 0x00e6, 0x00c6, 0x2069, 0x1910, 0x6810, 0x6914,
 	0x910a, 0x1208, 0x900e, 0x6816, 0x9016, 0x901e, 0x2071, 0x19e6,
 	0x7028, 0x9065, 0x0118, 0x8210, 0x600c, 0x0cd8, 0x2300, 0x9218,
-	0x00ce, 0x00ee, 0x00de, 0x015e, 0x0804, 0x3567, 0x00f6, 0x0016,
+	0x00ce, 0x00ee, 0x00de, 0x015e, 0x0804, 0x3587, 0x00f6, 0x0016,
 	0x907d, 0x0138, 0x9006, 0x8000, 0x2f0c, 0x81ff, 0x0110, 0x2178,
 	0x0cd0, 0x001e, 0x00fe, 0x0005, 0x2069, 0x1910, 0x6910, 0x62bc,
-	0x0804, 0x3567, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3599,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x56e9, 0x0128, 0x2009, 0x0007,
-	0x012e, 0x0804, 0x3599, 0x012e, 0x615c, 0x9190, 0x3368, 0x2215,
+	0x0804, 0x3587, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x35b9,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x5709, 0x0128, 0x2009, 0x0007,
+	0x012e, 0x0804, 0x35b9, 0x012e, 0x615c, 0x9190, 0x3388, 0x2215,
 	0x9294, 0x00ff, 0x637c, 0x83ff, 0x0108, 0x6280, 0x67dc, 0x97c4,
 	0x000a, 0x98c6, 0x000a, 0x1118, 0x2031, 0x0001, 0x00e8, 0x97c4,
 	0x0022, 0x98c6, 0x0022, 0x1118, 0x2031, 0x0003, 0x00a8, 0x97c4,
 	0x0012, 0x98c6, 0x0012, 0x1118, 0x2031, 0x0002, 0x0068, 0x080c,
-	0x74c8, 0x1118, 0x2031, 0x0004, 0x0038, 0xd79c, 0x0120, 0x2009,
-	0x0005, 0x0804, 0x3599, 0x9036, 0x7e9a, 0x7f9e, 0x0804, 0x3567,
+	0x74ec, 0x1118, 0x2031, 0x0004, 0x0038, 0xd79c, 0x0120, 0x2009,
+	0x0005, 0x0804, 0x35b9, 0x9036, 0x7e9a, 0x7f9e, 0x0804, 0x3587,
 	0x614c, 0x6250, 0x2019, 0x1985, 0x231c, 0x2001, 0x1986, 0x2004,
-	0x789a, 0x0804, 0x3567, 0x0126, 0x2091, 0x8000, 0x6138, 0x623c,
-	0x6340, 0x012e, 0x0804, 0x3567, 0x080c, 0x4adc, 0x0904, 0x359c,
-	0xba44, 0xbb38, 0x0804, 0x3567, 0x080c, 0x0d7d, 0x080c, 0x4adc,
-	0x2110, 0x0904, 0x359c, 0xb804, 0x908c, 0x00ff, 0x918e, 0x0006,
+	0x789a, 0x0804, 0x3587, 0x0126, 0x2091, 0x8000, 0x6138, 0x623c,
+	0x6340, 0x012e, 0x0804, 0x3587, 0x080c, 0x4afc, 0x0904, 0x35bc,
+	0xba44, 0xbb38, 0x0804, 0x3587, 0x080c, 0x0d7d, 0x080c, 0x4afc,
+	0x2110, 0x0904, 0x35bc, 0xb804, 0x908c, 0x00ff, 0x918e, 0x0006,
 	0x0140, 0x9084, 0xff00, 0x9086, 0x0600, 0x2009, 0x0009, 0x1904,
-	0x3599, 0x0126, 0x2091, 0x8000, 0x2019, 0x0005, 0x00c6, 0x9066,
-	0x080c, 0xa888, 0x080c, 0xa372, 0x080c, 0x938d, 0x0076, 0x903e,
-	0x080c, 0x9256, 0x900e, 0x080c, 0xdffb, 0x007e, 0x00ce, 0x080c,
-	0xa8a4, 0xb807, 0x0407, 0x012e, 0x0804, 0x3567, 0x614c, 0x6250,
+	0x35b9, 0x0126, 0x2091, 0x8000, 0x2019, 0x0005, 0x00c6, 0x9066,
+	0x080c, 0xa899, 0x080c, 0xa37f, 0x080c, 0x93c6, 0x0076, 0x903e,
+	0x080c, 0x928f, 0x900e, 0x080c, 0xe038, 0x007e, 0x00ce, 0x080c,
+	0xa8b5, 0xb807, 0x0407, 0x012e, 0x0804, 0x3587, 0x614c, 0x6250,
 	0x7884, 0x604e, 0x7b88, 0x6352, 0x2069, 0x1847, 0x831f, 0x9305,
 	0x6816, 0x788c, 0x2069, 0x1985, 0x2d1c, 0x206a, 0x7e98, 0x9682,
 	0x0014, 0x1210, 0x2031, 0x07d0, 0x2069, 0x1986, 0x2d04, 0x266a,
-	0x789a, 0x0804, 0x3567, 0x0126, 0x2091, 0x8000, 0x6138, 0x7884,
-	0x603a, 0x910e, 0xd1b4, 0x190c, 0x0ecc, 0xd0c4, 0x01a8, 0x00d6,
+	0x789a, 0x0804, 0x3587, 0x0126, 0x2091, 0x8000, 0x6138, 0x7884,
+	0x603a, 0x910e, 0xd1b4, 0x190c, 0x0ed9, 0xd0c4, 0x01a8, 0x00d6,
 	0x78a8, 0x2009, 0x199c, 0x200a, 0x78ac, 0x2011, 0x199d, 0x2012,
 	0x2069, 0x0100, 0x6838, 0x9086, 0x0007, 0x1118, 0x2214, 0x6a5a,
 	0x0010, 0x210c, 0x695a, 0x00de, 0x7888, 0x603e, 0x2011, 0x0116,
 	0x220c, 0x7888, 0xd08c, 0x0118, 0x918d, 0x0040, 0x0010, 0x918c,
 	0xff7f, 0x2112, 0x6140, 0x788c, 0x6042, 0x910e, 0xd1e4, 0x190c,
-	0x0ee7, 0x9084, 0x0020, 0x0130, 0x78b4, 0x6046, 0x9084, 0x0001,
-	0x090c, 0x4245, 0x6040, 0xd0cc, 0x0120, 0x78b0, 0x2011, 0x0114,
-	0x2012, 0x012e, 0x0804, 0x3567, 0x00f6, 0x2079, 0x1800, 0x7a38,
+	0x0ef4, 0x9084, 0x0020, 0x0130, 0x78b4, 0x6046, 0x9084, 0x0001,
+	0x090c, 0x4265, 0x6040, 0xd0cc, 0x0120, 0x78b0, 0x2011, 0x0114,
+	0x2012, 0x012e, 0x0804, 0x3587, 0x00f6, 0x2079, 0x1800, 0x7a38,
 	0xa898, 0x9084, 0xfebf, 0x9215, 0xa89c, 0x9084, 0xfebf, 0x8002,
 	0x9214, 0x7838, 0x9084, 0x0140, 0x9215, 0x7a3a, 0xa897, 0x4000,
 	0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x00fe, 0x0005, 0x7898,
-	0x9005, 0x01a8, 0x7888, 0x9025, 0x0904, 0x359c, 0x788c, 0x902d,
-	0x0904, 0x359c, 0x900e, 0x080c, 0x6620, 0x1120, 0xba44, 0xbb38,
+	0x9005, 0x01a8, 0x7888, 0x9025, 0x0904, 0x35bc, 0x788c, 0x902d,
+	0x0904, 0x35bc, 0x900e, 0x080c, 0x6644, 0x1120, 0xba44, 0xbb38,
 	0xbc46, 0xbd3a, 0x9186, 0x07ff, 0x0190, 0x8108, 0x0ca0, 0x080c,
-	0x4adc, 0x0904, 0x359c, 0x7888, 0x900d, 0x0904, 0x359c, 0x788c,
-	0x9005, 0x0904, 0x359c, 0xba44, 0xb946, 0xbb38, 0xb83a, 0x0804,
-	0x3567, 0x2011, 0xbc09, 0x0010, 0x2011, 0xbc05, 0x080c, 0x56e9,
-	0x1904, 0x3599, 0x00c6, 0x2061, 0x0100, 0x7984, 0x9186, 0x00ff,
+	0x4afc, 0x0904, 0x35bc, 0x7888, 0x900d, 0x0904, 0x35bc, 0x788c,
+	0x9005, 0x0904, 0x35bc, 0xba44, 0xb946, 0xbb38, 0xb83a, 0x0804,
+	0x3587, 0x2011, 0xbc09, 0x0010, 0x2011, 0xbc05, 0x080c, 0x5709,
+	0x1904, 0x35b9, 0x00c6, 0x2061, 0x0100, 0x7984, 0x9186, 0x00ff,
 	0x1130, 0x2001, 0x1818, 0x2004, 0x9085, 0xff00, 0x0088, 0x9182,
-	0x007f, 0x16e0, 0x9188, 0x3368, 0x210d, 0x918c, 0x00ff, 0x2001,
+	0x007f, 0x16e0, 0x9188, 0x3388, 0x210d, 0x918c, 0x00ff, 0x2001,
 	0x1818, 0x2004, 0x0026, 0x9116, 0x002e, 0x0580, 0x810f, 0x9105,
-	0x0126, 0x2091, 0x8000, 0x0006, 0x080c, 0xab89, 0x000e, 0x0510,
-	0x602e, 0x620a, 0x7984, 0x00b6, 0x080c, 0x65c5, 0x2b08, 0x00be,
-	0x1500, 0x6112, 0x6023, 0x0001, 0x080c, 0x4aa9, 0x01d0, 0x9006,
+	0x0126, 0x2091, 0x8000, 0x0006, 0x080c, 0xab9a, 0x000e, 0x0510,
+	0x602e, 0x620a, 0x7984, 0x00b6, 0x080c, 0x65e9, 0x2b08, 0x00be,
+	0x1500, 0x6112, 0x6023, 0x0001, 0x080c, 0x4ac9, 0x01d0, 0x9006,
 	0xa866, 0x7007, 0x0003, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x701f,
-	0x3a54, 0x2900, 0x6016, 0x2009, 0x0032, 0x080c, 0xac7c, 0x012e,
-	0x00ce, 0x0005, 0x012e, 0x00ce, 0x0804, 0x3599, 0x00ce, 0x0804,
-	0x359c, 0x080c, 0xabdf, 0x0cb0, 0xa830, 0x9086, 0x0100, 0x0904,
-	0x3599, 0x0804, 0x3567, 0x2061, 0x1a6e, 0x0126, 0x2091, 0x8000,
+	0x3a74, 0x2900, 0x6016, 0x2009, 0x0032, 0x080c, 0xac8d, 0x012e,
+	0x00ce, 0x0005, 0x012e, 0x00ce, 0x0804, 0x35b9, 0x00ce, 0x0804,
+	0x35bc, 0x080c, 0xabf0, 0x0cb0, 0xa830, 0x9086, 0x0100, 0x0904,
+	0x35b9, 0x0804, 0x3587, 0x2061, 0x1a6e, 0x0126, 0x2091, 0x8000,
 	0x6000, 0xd084, 0x0170, 0x6104, 0x6208, 0x2061, 0x1800, 0x6354,
 	0x6074, 0x789a, 0x60c0, 0x789e, 0x60bc, 0x78aa, 0x012e, 0x0804,
-	0x3567, 0x900e, 0x2110, 0x0c88, 0x81ff, 0x1904, 0x3599, 0x080c,
-	0x74c8, 0x0904, 0x3599, 0x0126, 0x2091, 0x8000, 0x6254, 0x6074,
-	0x9202, 0x0248, 0x9085, 0x0001, 0x080c, 0x267d, 0x080c, 0x5903,
-	0x012e, 0x0804, 0x3567, 0x012e, 0x0804, 0x359c, 0x0006, 0x0016,
+	0x3587, 0x900e, 0x2110, 0x0c88, 0x81ff, 0x1904, 0x35b9, 0x080c,
+	0x74ec, 0x0904, 0x35b9, 0x0126, 0x2091, 0x8000, 0x6254, 0x6074,
+	0x9202, 0x0248, 0x9085, 0x0001, 0x080c, 0x2699, 0x080c, 0x5923,
+	0x012e, 0x0804, 0x3587, 0x012e, 0x0804, 0x35bc, 0x0006, 0x0016,
 	0x00c6, 0x00e6, 0x2001, 0x19a8, 0x2070, 0x2061, 0x1847, 0x6008,
-	0x2072, 0x900e, 0x2011, 0x1400, 0x080c, 0x9148, 0x7206, 0x00ee,
+	0x2072, 0x900e, 0x2011, 0x1400, 0x080c, 0x9181, 0x7206, 0x00ee,
 	0x00ce, 0x001e, 0x000e, 0x0005, 0x0126, 0x2091, 0x8000, 0x81ff,
-	0x0128, 0x012e, 0x2021, 0x400b, 0x0804, 0x3569, 0x7884, 0xd0fc,
+	0x0128, 0x012e, 0x2021, 0x400b, 0x0804, 0x3589, 0x7884, 0xd0fc,
 	0x0148, 0x2001, 0x002a, 0x2004, 0x9082, 0x00e1, 0x0288, 0x012e,
-	0x0804, 0x359c, 0x2001, 0x002a, 0x2004, 0x2069, 0x1847, 0x6908,
-	0x9102, 0x1230, 0x012e, 0x0804, 0x359c, 0x012e, 0x0804, 0x3599,
-	0x080c, 0xab49, 0x0dd0, 0x7884, 0xd0fc, 0x0904, 0x3b1f, 0x00c6,
-	0x080c, 0x4aa9, 0x00ce, 0x0d88, 0xa867, 0x0000, 0x7884, 0xa80a,
+	0x0804, 0x35bc, 0x2001, 0x002a, 0x2004, 0x2069, 0x1847, 0x6908,
+	0x9102, 0x1230, 0x012e, 0x0804, 0x35bc, 0x012e, 0x0804, 0x35b9,
+	0x080c, 0xab5a, 0x0dd0, 0x7884, 0xd0fc, 0x0904, 0x3b3f, 0x00c6,
+	0x080c, 0x4ac9, 0x00ce, 0x0d88, 0xa867, 0x0000, 0x7884, 0xa80a,
 	0x7898, 0xa80e, 0x789c, 0xa812, 0x2001, 0x002e, 0x2004, 0xa81a,
 	0x2001, 0x002f, 0x2004, 0xa81e, 0x2001, 0x0030, 0x2004, 0xa822,
 	0x2001, 0x0031, 0x2004, 0xa826, 0x2001, 0x0034, 0x2004, 0xa82a,
 	0x2001, 0x0035, 0x2004, 0xa82e, 0x2001, 0x002a, 0x2004, 0x9080,
-	0x0003, 0x9084, 0x00fc, 0x8004, 0xa816, 0x080c, 0x3ca9, 0x0928,
+	0x0003, 0x9084, 0x00fc, 0x8004, 0xa816, 0x080c, 0x3cc9, 0x0928,
 	0x7014, 0x2048, 0xad2c, 0xac28, 0xab1c, 0xaa18, 0xa930, 0xa808,
 	0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021, 0x0000, 0x8906, 0x8006,
 	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x080c,
-	0x4af2, 0x701f, 0x3be6, 0x7023, 0x0001, 0x012e, 0x0005, 0x080c,
-	0xa888, 0x0046, 0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6,
-	0x00e6, 0x00f6, 0x080c, 0x3a8e, 0x2001, 0x199e, 0x2003, 0x0000,
+	0x4b12, 0x701f, 0x3c06, 0x7023, 0x0001, 0x012e, 0x0005, 0x080c,
+	0xa899, 0x0046, 0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6,
+	0x00e6, 0x00f6, 0x080c, 0x3aae, 0x2001, 0x199e, 0x2003, 0x0000,
 	0x2021, 0x000a, 0x2061, 0x0100, 0x6104, 0x0016, 0x60bb, 0x0000,
-	0x60bf, 0x32e1, 0x60bf, 0x0012, 0x080c, 0x3d18, 0x080c, 0x3cd7,
+	0x60bf, 0x32e1, 0x60bf, 0x0012, 0x080c, 0x3d38, 0x080c, 0x3cf7,
 	0x00f6, 0x00e6, 0x0086, 0x2940, 0x2071, 0x19e6, 0x2079, 0x0090,
 	0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0140, 0x2001, 0x0035,
 	0x2004, 0x780e, 0x2001, 0x0034, 0x2004, 0x780a, 0x00de, 0x2011,
-	0x0001, 0x080c, 0x4089, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3fb6,
-	0x080c, 0x3ee3, 0x05b8, 0x2001, 0x020b, 0x2004, 0x9084, 0x0140,
-	0x1db8, 0x080c, 0x40fd, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe,
+	0x0001, 0x080c, 0x40a9, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3fd6,
+	0x080c, 0x3f03, 0x05b8, 0x2001, 0x020b, 0x2004, 0x9084, 0x0140,
+	0x1db8, 0x080c, 0x411d, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe,
 	0x908c, 0x0070, 0x1560, 0x2071, 0x0200, 0x7037, 0x0000, 0x7050,
 	0x9084, 0xff00, 0x9086, 0x3200, 0x1510, 0x7037, 0x0001, 0x7050,
 	0x9084, 0xff00, 0x9086, 0xe100, 0x11d0, 0x7037, 0x0000, 0x7054,
 	0x7037, 0x0000, 0x715c, 0x9106, 0x1190, 0x2001, 0x1820, 0x2004,
 	0x9106, 0x1168, 0x00c6, 0x2061, 0x0100, 0x6024, 0x9084, 0x1e00,
-	0x00ce, 0x0138, 0x080c, 0x3eed, 0x080c, 0x3cd2, 0x0058, 0x080c,
-	0x3cd2, 0x080c, 0x4021, 0x080c, 0x3fac, 0x2001, 0x020b, 0x2004,
+	0x00ce, 0x0138, 0x080c, 0x3f0d, 0x080c, 0x3cf2, 0x0058, 0x080c,
+	0x3cf2, 0x080c, 0x4041, 0x080c, 0x3fcc, 0x2001, 0x020b, 0x2004,
 	0xd0e4, 0x0dd8, 0x2001, 0x032a, 0x2003, 0x0004, 0x2061, 0x0100,
 	0x6027, 0x0002, 0x001e, 0x6106, 0x2011, 0x020d, 0x2013, 0x0020,
 	0x60bb, 0x0000, 0x60bf, 0x0108, 0x60bf, 0x0012, 0x2001, 0x0004,
-	0x200c, 0x918c, 0xfffd, 0x2102, 0x080c, 0x1333, 0x2009, 0x0028,
-	0x080c, 0x21c1, 0x2001, 0x0227, 0x200c, 0x2102, 0x080c, 0xa8a4,
+	0x200c, 0x918c, 0xfffd, 0x2102, 0x080c, 0x1340, 0x2009, 0x0028,
+	0x080c, 0x21d9, 0x2001, 0x0227, 0x200c, 0x2102, 0x080c, 0xa8b5,
 	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e,
 	0x004e, 0x2001, 0x199e, 0x2004, 0x9005, 0x1118, 0x012e, 0x0804,
-	0x3567, 0x012e, 0x2021, 0x400c, 0x0804, 0x3569, 0x0016, 0x0026,
+	0x3587, 0x012e, 0x2021, 0x400c, 0x0804, 0x3589, 0x0016, 0x0026,
 	0x0036, 0x0046, 0x0056, 0x0076, 0x0086, 0x0096, 0x00d6, 0x0156,
 	0x7014, 0x2048, 0x7020, 0x20a8, 0x8000, 0x7022, 0xa804, 0x9005,
-	0x0904, 0x3c42, 0x2048, 0x1f04, 0x3bf6, 0x7068, 0x2040, 0xa28c,
+	0x0904, 0x3c62, 0x2048, 0x1f04, 0x3c16, 0x7068, 0x2040, 0xa28c,
 	0xa390, 0xa494, 0xa598, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029,
 	0x0000, 0x2021, 0x0000, 0x0096, 0x7014, 0x2048, 0xa864, 0x009e,
 	0x9086, 0x0103, 0x0170, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
-	0x9084, 0xffc0, 0x9080, 0x001b, 0x080c, 0x4af2, 0x701f, 0x3be6,
+	0x9084, 0xffc0, 0x9080, 0x001b, 0x080c, 0x4b12, 0x701f, 0x3c06,
 	0x00b0, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
 	0x9080, 0x001b, 0x21a8, 0x27e0, 0x2098, 0x27e8, 0x20a0, 0x0006,
-	0x080c, 0x0fb7, 0x000e, 0x080c, 0x4af5, 0x701f, 0x3be6, 0x015e,
+	0x080c, 0x0fc4, 0x000e, 0x080c, 0x4b15, 0x701f, 0x3c06, 0x015e,
 	0x00de, 0x009e, 0x008e, 0x007e, 0x005e, 0x004e, 0x003e, 0x002e,
 	0x001e, 0x0005, 0x7014, 0x2048, 0xa864, 0x9086, 0x0103, 0x1118,
-	0x701f, 0x3ca7, 0x0450, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a,
-	0x2009, 0x007f, 0x080c, 0x65bf, 0x0110, 0x9006, 0x0030, 0xb813,
-	0x00ff, 0xb817, 0xfffd, 0x080c, 0xcd1a, 0x015e, 0x00de, 0x009e,
+	0x701f, 0x3cc7, 0x0450, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a,
+	0x2009, 0x007f, 0x080c, 0x65e3, 0x0110, 0x9006, 0x0030, 0xb813,
+	0x00ff, 0xb817, 0xfffd, 0x080c, 0xcd4d, 0x015e, 0x00de, 0x009e,
 	0x008e, 0x007e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0904,
-	0x3599, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0076, 0x0086,
-	0x0096, 0x00d6, 0x0156, 0x701f, 0x3c79, 0x7007, 0x0003, 0x0804,
-	0x3c37, 0xa830, 0x9086, 0x0100, 0x2021, 0x400c, 0x0904, 0x3569,
+	0x35b9, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0076, 0x0086,
+	0x0096, 0x00d6, 0x0156, 0x701f, 0x3c99, 0x7007, 0x0003, 0x0804,
+	0x3c57, 0xa830, 0x9086, 0x0100, 0x2021, 0x400c, 0x0904, 0x3589,
 	0x0076, 0xad10, 0xac0c, 0xab24, 0xaa20, 0xa930, 0xa808, 0xd0b4,
 	0x1120, 0x2029, 0x0000, 0x2021, 0x0000, 0x8906, 0x8006, 0x8007,
 	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x21a8, 0x27e0,
-	0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c, 0x0fb7, 0x000e, 0x080c,
-	0x4af5, 0x007e, 0x701f, 0x3be6, 0x7023, 0x0001, 0x0005, 0x0804,
-	0x3567, 0x0156, 0x00c6, 0xa814, 0x908a, 0x001e, 0x0218, 0xa833,
+	0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c, 0x0fc4, 0x000e, 0x080c,
+	0x4b15, 0x007e, 0x701f, 0x3c06, 0x7023, 0x0001, 0x0005, 0x0804,
+	0x3587, 0x0156, 0x00c6, 0xa814, 0x908a, 0x001e, 0x0218, 0xa833,
 	0x001e, 0x0010, 0xa832, 0x0078, 0x81ff, 0x0168, 0x0016, 0x080c,
-	0x4aa9, 0x001e, 0x0130, 0xa800, 0x2040, 0xa008, 0xa80a, 0x2100,
+	0x4ac9, 0x001e, 0x0130, 0xa800, 0x2040, 0xa008, 0xa80a, 0x2100,
 	0x0c58, 0x9006, 0x0010, 0x9085, 0x0001, 0x00ce, 0x015e, 0x0005,
 	0x0006, 0x00f6, 0x2079, 0x0000, 0x7880, 0x9086, 0x0044, 0x00fe,
 	0x000e, 0x0005, 0x2001, 0x199e, 0x2003, 0x0001, 0x0005, 0x00f6,
 	0x00e6, 0x00c6, 0x2061, 0x0200, 0x2001, 0x19a9, 0x2004, 0x601a,
 	0x2061, 0x0100, 0x2001, 0x19a8, 0x2004, 0x60ce, 0x6104, 0xc1ac,
-	0x6106, 0x080c, 0x4aa9, 0xa813, 0x0019, 0xa817, 0x0001, 0x2900,
+	0x6106, 0x080c, 0x4ac9, 0xa813, 0x0019, 0xa817, 0x0001, 0x2900,
 	0xa85a, 0x2001, 0x002e, 0x2004, 0xa866, 0x2001, 0x002f, 0x2004,
 	0xa86a, 0x2061, 0x0090, 0x2079, 0x0100, 0x2001, 0x19a8, 0x2004,
-	0x6036, 0x2009, 0x0040, 0x080c, 0x21c1, 0x2001, 0x002a, 0x2004,
+	0x6036, 0x2009, 0x0040, 0x080c, 0x21d9, 0x2001, 0x002a, 0x2004,
 	0x9084, 0xfff8, 0xa86e, 0x601a, 0xa873, 0x0000, 0x601f, 0x0000,
 	0x78ca, 0x9006, 0x600a, 0x600e, 0x00ce, 0x00ee, 0x00fe, 0x0005,
-	0x00e6, 0x080c, 0x4aa9, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001,
+	0x00e6, 0x080c, 0x4ac9, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001,
 	0x2800, 0xa05a, 0x2001, 0x0030, 0x2004, 0xa866, 0x2001, 0x0031,
 	0x2004, 0xa86a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e,
 	0xa873, 0x0000, 0x2001, 0x032a, 0x2003, 0x0004, 0x2001, 0x0300,
 	0x2003, 0x0000, 0x2001, 0x020d, 0x2003, 0x0000, 0x2001, 0x0004,
 	0x200c, 0x918d, 0x0002, 0x2102, 0x00ee, 0x0005, 0x0126, 0x2091,
-	0x8000, 0x81ff, 0x0148, 0x080c, 0x2a07, 0x1130, 0x9006, 0x080c,
-	0x295e, 0x9006, 0x080c, 0x2941, 0x7884, 0x9084, 0x0007, 0x0002,
-	0x3d63, 0x3d6c, 0x3d75, 0x3d60, 0x3d60, 0x3d60, 0x3d60, 0x3d60,
-	0x012e, 0x0804, 0x359c, 0x2009, 0x0114, 0x2104, 0x9085, 0x0800,
-	0x200a, 0x080c, 0x3f37, 0x00c0, 0x2009, 0x0114, 0x2104, 0x9085,
-	0x4000, 0x200a, 0x080c, 0x3f37, 0x0078, 0x080c, 0x74c8, 0x1128,
-	0x012e, 0x2009, 0x0016, 0x0804, 0x3599, 0x81ff, 0x0128, 0x012e,
-	0x2021, 0x400b, 0x0804, 0x3569, 0x080c, 0xa888, 0x0086, 0x0096,
-	0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x080c, 0x3a8e,
+	0x8000, 0x81ff, 0x0148, 0x080c, 0x2a27, 0x1130, 0x9006, 0x080c,
+	0x297a, 0x9006, 0x080c, 0x295d, 0x7884, 0x9084, 0x0007, 0x0002,
+	0x3d83, 0x3d8c, 0x3d95, 0x3d80, 0x3d80, 0x3d80, 0x3d80, 0x3d80,
+	0x012e, 0x0804, 0x35bc, 0x2009, 0x0114, 0x2104, 0x9085, 0x0800,
+	0x200a, 0x080c, 0x3f57, 0x00c0, 0x2009, 0x0114, 0x2104, 0x9085,
+	0x4000, 0x200a, 0x080c, 0x3f57, 0x0078, 0x080c, 0x74ec, 0x1128,
+	0x012e, 0x2009, 0x0016, 0x0804, 0x35b9, 0x81ff, 0x0128, 0x012e,
+	0x2021, 0x400b, 0x0804, 0x3589, 0x080c, 0xa899, 0x0086, 0x0096,
+	0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x080c, 0x3aae,
 	0x2009, 0x0101, 0x210c, 0x0016, 0x7ec8, 0x7dcc, 0x9006, 0x2068,
-	0x2060, 0x2058, 0x080c, 0x41d8, 0x080c, 0x4128, 0x903e, 0x2720,
+	0x2060, 0x2058, 0x080c, 0x41f8, 0x080c, 0x4148, 0x903e, 0x2720,
 	0x00f6, 0x00e6, 0x0086, 0x2940, 0x2071, 0x19e6, 0x2079, 0x0090,
 	0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120, 0x68d4, 0x780e,
-	0x68d0, 0x780a, 0x00de, 0x2011, 0x0001, 0x080c, 0x4089, 0x080c,
-	0x2a0f, 0x080c, 0x2a0f, 0x080c, 0x2a0f, 0x080c, 0x2a0f, 0x080c,
-	0x4089, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3fb6, 0x2009, 0x9c40,
-	0x8109, 0x11b0, 0x080c, 0x3eed, 0x2001, 0x0004, 0x200c, 0x918c,
+	0x68d0, 0x780a, 0x00de, 0x2011, 0x0001, 0x080c, 0x40a9, 0x080c,
+	0x2a2f, 0x080c, 0x2a2f, 0x080c, 0x2a2f, 0x080c, 0x2a2f, 0x080c,
+	0x40a9, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3fd6, 0x2009, 0x9c40,
+	0x8109, 0x11b0, 0x080c, 0x3f0d, 0x2001, 0x0004, 0x200c, 0x918c,
 	0xfffd, 0x2102, 0x001e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be,
-	0x00ae, 0x009e, 0x008e, 0x2009, 0x0017, 0x080c, 0x3599, 0x0cf8,
+	0x00ae, 0x009e, 0x008e, 0x2009, 0x0017, 0x080c, 0x35b9, 0x0cf8,
 	0x2001, 0x020b, 0x2004, 0x9084, 0x0140, 0x1d10, 0x00f6, 0x2079,
 	0x0000, 0x7884, 0x00fe, 0xd0bc, 0x0178, 0x2001, 0x0201, 0x200c,
-	0x81ff, 0x0150, 0x080c, 0x3f94, 0x2d00, 0x9c05, 0x9b05, 0x0120,
-	0x080c, 0x3eed, 0x0804, 0x3e96, 0x080c, 0x40fd, 0x080c, 0x4021,
-	0x080c, 0x3f77, 0x080c, 0x3fac, 0x00f6, 0x2079, 0x0100, 0x7824,
-	0xd0ac, 0x0130, 0x8b58, 0x080c, 0x3eed, 0x00fe, 0x0804, 0x3e96,
-	0x00fe, 0x080c, 0x3ee3, 0x1150, 0x8d68, 0x2001, 0x0032, 0x2602,
-	0x2001, 0x0033, 0x2502, 0x080c, 0x3eed, 0x0080, 0x87ff, 0x0138,
+	0x81ff, 0x0150, 0x080c, 0x3fb4, 0x2d00, 0x9c05, 0x9b05, 0x0120,
+	0x080c, 0x3f0d, 0x0804, 0x3eb6, 0x080c, 0x411d, 0x080c, 0x4041,
+	0x080c, 0x3f97, 0x080c, 0x3fcc, 0x00f6, 0x2079, 0x0100, 0x7824,
+	0xd0ac, 0x0130, 0x8b58, 0x080c, 0x3f0d, 0x00fe, 0x0804, 0x3eb6,
+	0x00fe, 0x080c, 0x3f03, 0x1150, 0x8d68, 0x2001, 0x0032, 0x2602,
+	0x2001, 0x0033, 0x2502, 0x080c, 0x3f0d, 0x0080, 0x87ff, 0x0138,
 	0x2001, 0x0201, 0x2004, 0x9005, 0x1908, 0x8739, 0x0038, 0x2001,
-	0x1a6a, 0x2004, 0x9086, 0x0000, 0x1904, 0x3de6, 0x2001, 0x032f,
+	0x1a6a, 0x2004, 0x9086, 0x0000, 0x1904, 0x3e06, 0x2001, 0x032f,
 	0x2003, 0x00f6, 0x8631, 0x1208, 0x8529, 0x2500, 0x9605, 0x0904,
-	0x3e96, 0x7884, 0xd0bc, 0x0128, 0x2d00, 0x9c05, 0x9b05, 0x1904,
-	0x3e96, 0xa013, 0x0019, 0x2001, 0x032a, 0x2003, 0x0004, 0x7884,
+	0x3eb6, 0x7884, 0xd0bc, 0x0128, 0x2d00, 0x9c05, 0x9b05, 0x1904,
+	0x3eb6, 0xa013, 0x0019, 0x2001, 0x032a, 0x2003, 0x0004, 0x7884,
 	0xd0ac, 0x1148, 0x2001, 0x1a6a, 0x2003, 0x0003, 0x2001, 0x032a,
 	0x2003, 0x0009, 0x0030, 0xa017, 0x0001, 0x78b4, 0x9005, 0x0108,
-	0xa016, 0x2800, 0xa05a, 0x2009, 0x0040, 0x080c, 0x21c1, 0x2900,
+	0xa016, 0x2800, 0xa05a, 0x2009, 0x0040, 0x080c, 0x21d9, 0x2900,
 	0xa85a, 0xa813, 0x0019, 0x7884, 0xd0a4, 0x1180, 0xa817, 0x0000,
 	0x00c6, 0x20a9, 0x0004, 0x2061, 0x0090, 0x602b, 0x0008, 0x2001,
-	0x0203, 0x2004, 0x1f04, 0x3e6d, 0x00ce, 0x0030, 0xa817, 0x0001,
+	0x0203, 0x2004, 0x1f04, 0x3e8d, 0x00ce, 0x0030, 0xa817, 0x0001,
 	0x78b0, 0x9005, 0x0108, 0xa816, 0x00f6, 0x00c6, 0x2079, 0x0100,
 	0x2061, 0x0090, 0x7827, 0x0002, 0x2001, 0x002a, 0x2004, 0x9084,
 	0xfff8, 0x601a, 0x0006, 0x2001, 0x002b, 0x2004, 0x601e, 0x78c6,
-	0x000e, 0x78ca, 0x00ce, 0x00fe, 0x0804, 0x3da0, 0x001e, 0x00c6,
+	0x000e, 0x78ca, 0x00ce, 0x00fe, 0x0804, 0x3dc0, 0x001e, 0x00c6,
 	0x2001, 0x032a, 0x2003, 0x0004, 0x2061, 0x0100, 0x6027, 0x0002,
 	0x6106, 0x2011, 0x020d, 0x2013, 0x0020, 0x2001, 0x0004, 0x200c,
-	0x918c, 0xfffd, 0x2102, 0x080c, 0x1333, 0x7884, 0x9084, 0x0003,
-	0x9086, 0x0002, 0x01b0, 0x2009, 0x0028, 0x080c, 0x21c1, 0x2001,
-	0x0227, 0x200c, 0x2102, 0x6050, 0x9084, 0xb7ff, 0x080c, 0x2ab9,
+	0x918c, 0xfffd, 0x2102, 0x080c, 0x1340, 0x7884, 0x9084, 0x0003,
+	0x9086, 0x0002, 0x01b0, 0x2009, 0x0028, 0x080c, 0x21d9, 0x2001,
+	0x0227, 0x200c, 0x2102, 0x6050, 0x9084, 0xb7ff, 0x080c, 0x2ad9,
 	0x6052, 0x602f, 0x0000, 0x604b, 0xf7f7, 0x6043, 0x0090, 0x6043,
-	0x0010, 0x080c, 0xa8a4, 0x00ce, 0x2d08, 0x2c10, 0x2b18, 0x2b00,
+	0x0010, 0x080c, 0xa8b5, 0x00ce, 0x2d08, 0x2c10, 0x2b18, 0x2b00,
 	0x9c05, 0x9d05, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae,
-	0x009e, 0x008e, 0x1118, 0x012e, 0x0804, 0x3567, 0x012e, 0x2021,
-	0x400c, 0x0804, 0x3569, 0x9085, 0x0001, 0x1d04, 0x3eec, 0x2091,
+	0x009e, 0x008e, 0x1118, 0x012e, 0x0804, 0x3587, 0x012e, 0x2021,
+	0x400c, 0x0804, 0x3589, 0x9085, 0x0001, 0x1d04, 0x3f0c, 0x2091,
 	0x6000, 0x8420, 0x9486, 0x0064, 0x0005, 0x2001, 0x0105, 0x2003,
 	0x0010, 0x2001, 0x032a, 0x2003, 0x0004, 0x2001, 0x1a6a, 0x2003,
-	0x0000, 0x0071, 0x2009, 0x0048, 0x080c, 0x21c1, 0x2001, 0x0227,
+	0x0000, 0x0071, 0x2009, 0x0048, 0x080c, 0x21d9, 0x2001, 0x0227,
 	0x2024, 0x2402, 0x2001, 0x0109, 0x2003, 0x4000, 0x9026, 0x0005,
 	0x00f6, 0x00e6, 0x2071, 0x19e6, 0x7054, 0x9086, 0x0000, 0x0520,
 	0x2079, 0x0090, 0x2009, 0x0206, 0x2104, 0x2009, 0x0203, 0x210c,
-	0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x21c1, 0x782c, 0xd0fc,
-	0x0d88, 0x080c, 0x40fd, 0x7054, 0x9086, 0x0000, 0x1d58, 0x782b,
-	0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x21c1,
+	0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x21d9, 0x782c, 0xd0fc,
+	0x0d88, 0x080c, 0x411d, 0x7054, 0x9086, 0x0000, 0x1d58, 0x782b,
+	0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x21d9,
 	0x782b, 0x0002, 0x7057, 0x0000, 0x00ee, 0x00fe, 0x0005, 0x00f6,
 	0x2079, 0x0100, 0x2001, 0x1818, 0x200c, 0x7932, 0x7936, 0x080c,
-	0x265d, 0x080c, 0x2a86, 0x080c, 0x2ab9, 0x784b, 0xf7f7, 0x7843,
+	0x2679, 0x080c, 0x2aa6, 0x080c, 0x2ad9, 0x784b, 0xf7f7, 0x7843,
 	0x0090, 0x7843, 0x0010, 0x7850, 0xc0e5, 0x7852, 0x2019, 0x61a8,
 	0x7820, 0xd09c, 0x0110, 0x8319, 0x1dd8, 0x7850, 0xc0e4, 0x7852,
-	0x2011, 0x0048, 0x080c, 0x2a63, 0x7843, 0x0040, 0x2019, 0x01f4,
-	0xa001, 0xa001, 0x8319, 0x1de0, 0x2001, 0x0100, 0x080c, 0x2a29,
-	0x2011, 0x0020, 0x080c, 0x2a63, 0x7843, 0x0000, 0x9006, 0x080c,
-	0x2a29, 0x2011, 0x0048, 0x080c, 0x2a63, 0x00fe, 0x0005, 0x7884,
+	0x2011, 0x0048, 0x080c, 0x2a83, 0x7843, 0x0040, 0x2019, 0x01f4,
+	0xa001, 0xa001, 0x8319, 0x1de0, 0x2001, 0x0100, 0x080c, 0x2a49,
+	0x2011, 0x0020, 0x080c, 0x2a83, 0x7843, 0x0000, 0x9006, 0x080c,
+	0x2a49, 0x2011, 0x0048, 0x080c, 0x2a83, 0x00fe, 0x0005, 0x7884,
 	0xd0ac, 0x11c8, 0x00f6, 0x00e6, 0x2071, 0x1a6a, 0x2079, 0x0320,
 	0x2001, 0x0201, 0x2004, 0x9005, 0x0160, 0x7000, 0x9086, 0x0000,
 	0x1140, 0x0051, 0xd0bc, 0x0108, 0x8738, 0x7003, 0x0003, 0x782b,
@@ -1833,7 +1837,7 @@
 	0x0033, 0x250a, 0xd0b4, 0x0108, 0x8c60, 0xd0ac, 0x0108, 0x8d68,
 	0xd0a4, 0x0108, 0x8b58, 0x0005, 0x00f6, 0x2079, 0x0200, 0x781c,
 	0xd084, 0x0110, 0x7837, 0x0050, 0x00fe, 0x0005, 0x00e6, 0x2071,
-	0x0100, 0x2001, 0x19a9, 0x2004, 0x70e2, 0x080c, 0x3cc8, 0x1188,
+	0x0100, 0x2001, 0x19a9, 0x2004, 0x70e2, 0x080c, 0x3ce8, 0x1188,
 	0x2001, 0x1820, 0x2004, 0x2009, 0x181f, 0x210c, 0x918c, 0x00ff,
 	0x706e, 0x716a, 0x7066, 0x918d, 0x3200, 0x7162, 0x7073, 0xe109,
 	0x0080, 0x702c, 0x9085, 0x0002, 0x702e, 0x2009, 0x1818, 0x210c,
@@ -1841,31 +1845,31 @@
 	0x0809, 0x7077, 0x0008, 0x7078, 0x9080, 0x0100, 0x707a, 0x7080,
 	0x8000, 0x7082, 0x7087, 0xaaaa, 0x9006, 0x708a, 0x708e, 0x707e,
 	0x70d6, 0x70ab, 0x0036, 0x70af, 0x95d5, 0x7014, 0x9084, 0x1984,
-	0x9085, 0x0092, 0x7016, 0x080c, 0x40fd, 0x00f6, 0x2071, 0x1a6a,
+	0x9085, 0x0092, 0x7016, 0x080c, 0x411d, 0x00f6, 0x2071, 0x1a6a,
 	0x2079, 0x0320, 0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120,
 	0x689c, 0x780e, 0x6898, 0x780a, 0x00de, 0x2009, 0x03e8, 0x8109,
 	0x1df0, 0x792c, 0xd1fc, 0x0110, 0x782b, 0x0004, 0x2011, 0x0011,
-	0x080c, 0x4089, 0x2011, 0x0001, 0x080c, 0x4089, 0x00fe, 0x00ee,
+	0x080c, 0x40a9, 0x2011, 0x0001, 0x080c, 0x40a9, 0x00fe, 0x00ee,
 	0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a6a, 0x2079, 0x0320, 0x792c,
-	0xd1fc, 0x0904, 0x4086, 0x782b, 0x0002, 0x9026, 0xd19c, 0x1904,
-	0x4082, 0x7000, 0x0002, 0x4086, 0x4037, 0x4067, 0x4082, 0xd1bc,
+	0xd1fc, 0x0904, 0x40a6, 0x782b, 0x0002, 0x9026, 0xd19c, 0x1904,
+	0x40a2, 0x7000, 0x0002, 0x40a6, 0x4057, 0x4087, 0x40a2, 0xd1bc,
 	0x1170, 0xd1dc, 0x1190, 0x8001, 0x7002, 0x2011, 0x0001, 0x080c,
-	0x4089, 0x0904, 0x4086, 0x080c, 0x4089, 0x0804, 0x4086, 0x00f6,
+	0x40a9, 0x0904, 0x40a6, 0x080c, 0x40a9, 0x0804, 0x40a6, 0x00f6,
 	0x2079, 0x0300, 0x78bf, 0x0000, 0x00fe, 0x7810, 0x7914, 0x782b,
 	0x0004, 0x7812, 0x7916, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0de8,
-	0x080c, 0x3f94, 0x2009, 0x0001, 0x00f6, 0x2079, 0x0300, 0x78b8,
+	0x080c, 0x3fb4, 0x2009, 0x0001, 0x00f6, 0x2079, 0x0300, 0x78b8,
 	0x00fe, 0xd0ec, 0x0110, 0x2009, 0x0011, 0x792a, 0x00f8, 0x8001,
-	0x7002, 0x9184, 0x0880, 0x1140, 0x782c, 0xd0fc, 0x1904, 0x402b,
+	0x7002, 0x9184, 0x0880, 0x1140, 0x782c, 0xd0fc, 0x1904, 0x404b,
 	0x2011, 0x0001, 0x00b1, 0x0090, 0xa010, 0x9092, 0x0004, 0x9086,
 	0x0015, 0x1120, 0xa000, 0xa05a, 0x2011, 0x0031, 0xa212, 0xd1dc,
 	0x1960, 0x0828, 0x782b, 0x0004, 0x7003, 0x0000, 0x00ee, 0x00fe,
 	0x0005, 0xa014, 0x9005, 0x0550, 0x8001, 0x0036, 0x0096, 0xa016,
 	0xa058, 0x2048, 0xa010, 0x2009, 0x0031, 0x911a, 0x831c, 0x831c,
-	0x938a, 0x0007, 0x1a0c, 0x0d7d, 0x9398, 0x40b7, 0x231d, 0x083f,
+	0x938a, 0x0007, 0x1a0c, 0x0d7d, 0x9398, 0x40d7, 0x231d, 0x083f,
 	0x9080, 0x0004, 0x7a2a, 0x7100, 0x8108, 0x7102, 0x009e, 0x003e,
 	0x908a, 0x0035, 0x1140, 0x0096, 0xa058, 0x2048, 0xa804, 0xa05a,
-	0x2001, 0x0019, 0x009e, 0xa012, 0x9085, 0x0001, 0x0005, 0x40f4,
-	0x40eb, 0x40e2, 0x40d9, 0x40d0, 0x40c7, 0x40be, 0xa964, 0x7902,
+	0x2001, 0x0019, 0x009e, 0xa012, 0x9085, 0x0001, 0x0005, 0x4114,
+	0x410b, 0x4102, 0x40f9, 0x40f0, 0x40e7, 0x40de, 0xa964, 0x7902,
 	0xa968, 0x7906, 0xa96c, 0x7912, 0xa970, 0x7916, 0x0005, 0xa974,
 	0x7902, 0xa978, 0x7906, 0xa97c, 0x7912, 0xa980, 0x7916, 0x0005,
 	0xa984, 0x7902, 0xa988, 0x7906, 0xa98c, 0x7912, 0xa990, 0x7916,
@@ -1875,23 +1879,23 @@
 	0x7912, 0xa9c0, 0x7916, 0x0005, 0xa9c4, 0x7902, 0xa9c8, 0x7906,
 	0xa9cc, 0x7912, 0xa9d0, 0x7916, 0x0005, 0x00f6, 0x00e6, 0x0086,
 	0x2071, 0x19e6, 0x2079, 0x0090, 0x792c, 0xd1fc, 0x01e8, 0x782b,
-	0x0002, 0x2940, 0x9026, 0x7054, 0x0002, 0x4124, 0x4110, 0x411b,
-	0x8001, 0x7056, 0xd19c, 0x1180, 0x2011, 0x0001, 0x080c, 0x4089,
-	0x190c, 0x4089, 0x0048, 0x8001, 0x7056, 0x782c, 0xd0fc, 0x1d38,
-	0x2011, 0x0001, 0x080c, 0x4089, 0x008e, 0x00ee, 0x00fe, 0x0005,
+	0x0002, 0x2940, 0x9026, 0x7054, 0x0002, 0x4144, 0x4130, 0x413b,
+	0x8001, 0x7056, 0xd19c, 0x1180, 0x2011, 0x0001, 0x080c, 0x40a9,
+	0x190c, 0x40a9, 0x0048, 0x8001, 0x7056, 0x782c, 0xd0fc, 0x1d38,
+	0x2011, 0x0001, 0x080c, 0x40a9, 0x008e, 0x00ee, 0x00fe, 0x0005,
 	0x00f6, 0x00e6, 0x00c6, 0x0086, 0x2061, 0x0200, 0x2001, 0x19a9,
 	0x2004, 0x601a, 0x2061, 0x0100, 0x2001, 0x19a8, 0x2004, 0x60ce,
 	0x6104, 0xc1ac, 0x6106, 0x2001, 0x002c, 0x2004, 0x9005, 0x0520,
 	0x2038, 0x2001, 0x002e, 0x2024, 0x2001, 0x002f, 0x201c, 0x080c,
-	0x4aa9, 0xa813, 0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007,
+	0x4ac9, 0xa813, 0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007,
 	0x0220, 0x2138, 0x2009, 0x0007, 0x0010, 0x2708, 0x903e, 0x0096,
-	0xa858, 0x2048, 0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x41a0,
-	0x1d68, 0x2900, 0xa85a, 0x00d0, 0x080c, 0x4aa9, 0xa813, 0x0019,
+	0xa858, 0x2048, 0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x41c0,
+	0x1d68, 0x2900, 0xa85a, 0x00d0, 0x080c, 0x4ac9, 0xa813, 0x0019,
 	0xa817, 0x0001, 0x2900, 0xa85a, 0x2001, 0x002e, 0x2004, 0xa866,
 	0x2001, 0x002f, 0x2004, 0xa86a, 0x2001, 0x002a, 0x2004, 0x9084,
 	0xfff8, 0xa86e, 0x2001, 0x002b, 0x2004, 0xa872, 0x2061, 0x0090,
 	0x2079, 0x0100, 0x2001, 0x19a8, 0x2004, 0x6036, 0x2009, 0x0040,
-	0x080c, 0x21c1, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a,
+	0x080c, 0x21d9, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a,
 	0x0006, 0x2001, 0x002b, 0x2004, 0x601e, 0x78c6, 0x000e, 0x78ca,
 	0x9006, 0x600a, 0x600e, 0x008e, 0x00ce, 0x00ee, 0x00fe, 0x0005,
 	0x00e6, 0x2071, 0x0080, 0xaa60, 0x22e8, 0x20a0, 0x20e1, 0x0000,
@@ -1899,14 +1903,14 @@
 	0x700e, 0x810b, 0x810b, 0x21a8, 0x810b, 0x7112, 0x702b, 0x0041,
 	0x702c, 0xd0fc, 0x0de8, 0x702b, 0x0002, 0x702b, 0x0040, 0x4005,
 	0x7400, 0x7304, 0x87ff, 0x0190, 0x0086, 0x0096, 0x2940, 0x0086,
-	0x080c, 0x4aa9, 0x008e, 0xa058, 0x00a6, 0x2050, 0x2900, 0xb006,
+	0x080c, 0x4ac9, 0x008e, 0xa058, 0x00a6, 0x2050, 0x2900, 0xb006,
 	0xa05a, 0x00ae, 0x009e, 0x008e, 0x9085, 0x0001, 0x00ee, 0x0005,
 	0x00e6, 0x2001, 0x002d, 0x2004, 0x9005, 0x0528, 0x2038, 0x2001,
-	0x0030, 0x2024, 0x2001, 0x0031, 0x201c, 0x080c, 0x4aa9, 0x2940,
+	0x0030, 0x2024, 0x2001, 0x0031, 0x201c, 0x080c, 0x4ac9, 0x2940,
 	0xa813, 0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007, 0x0220,
 	0x2138, 0x2009, 0x0007, 0x0010, 0x2708, 0x903e, 0x0096, 0xa858,
-	0x2048, 0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x41a0, 0x1d68,
-	0x2900, 0xa85a, 0x00d8, 0x080c, 0x4aa9, 0x2940, 0xa013, 0x0019,
+	0x2048, 0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x41c0, 0x1d68,
+	0x2900, 0xa85a, 0x00d8, 0x080c, 0x4ac9, 0x2940, 0xa013, 0x0019,
 	0xa017, 0x0001, 0x2800, 0xa05a, 0x2001, 0x0030, 0x2004, 0xa066,
 	0x2001, 0x0031, 0x2004, 0xa06a, 0x2001, 0x002a, 0x2004, 0x9084,
 	0xfff8, 0xa06e, 0x2001, 0x002b, 0x2004, 0xa072, 0x2001, 0x032a,
@@ -1916,679 +1920,679 @@
 	0x0000, 0x2001, 0x020d, 0x2003, 0x0000, 0x2001, 0x0004, 0x200c,
 	0x918d, 0x0002, 0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000,
 	0x20a9, 0x0007, 0x20a1, 0x1840, 0x20e9, 0x0001, 0x9006, 0x4004,
-	0x20a9, 0x000c, 0x20a1, 0xfff4, 0x20e9, 0x0000, 0x9006, 0x4004,
+	0x20a9, 0x0014, 0x20a1, 0xffec, 0x20e9, 0x0000, 0x9006, 0x4004,
 	0x2009, 0x013c, 0x200a, 0x012e, 0x7880, 0x9086, 0x0052, 0x0108,
-	0x0005, 0x0804, 0x3567, 0x7d98, 0x7c9c, 0x0804, 0x3669, 0x080c,
-	0x74c8, 0x190c, 0x5fe9, 0x6040, 0x9084, 0x0020, 0x09b1, 0x2069,
+	0x0005, 0x0804, 0x3587, 0x7d98, 0x7c9c, 0x0804, 0x3689, 0x080c,
+	0x74ec, 0x190c, 0x6009, 0x6040, 0x9084, 0x0020, 0x09b1, 0x2069,
 	0x1847, 0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
-	0x2039, 0x0001, 0x080c, 0x4af2, 0x701f, 0x427f, 0x0005, 0x080c,
-	0x56e4, 0x1130, 0x3b00, 0x3a08, 0xc194, 0xc095, 0x20d8, 0x21d0,
-	0x2069, 0x1847, 0x6800, 0x9005, 0x0904, 0x359c, 0x6804, 0xd0ac,
-	0x0118, 0xd0a4, 0x0904, 0x359c, 0xd094, 0x00c6, 0x2061, 0x0100,
+	0x2039, 0x0001, 0x080c, 0x4b12, 0x701f, 0x429f, 0x0005, 0x080c,
+	0x5704, 0x1130, 0x3b00, 0x3a08, 0xc194, 0xc095, 0x20d8, 0x21d0,
+	0x2069, 0x1847, 0x6800, 0x9005, 0x0904, 0x35bc, 0x6804, 0xd0ac,
+	0x0118, 0xd0a4, 0x0904, 0x35bc, 0xd094, 0x00c6, 0x2061, 0x0100,
 	0x6104, 0x0138, 0x6200, 0x9292, 0x0005, 0x0218, 0x918c, 0xffdf,
 	0x0010, 0x918d, 0x0020, 0x6106, 0x00ce, 0xd08c, 0x00c6, 0x2061,
 	0x0100, 0x6104, 0x0118, 0x918d, 0x0010, 0x0010, 0x918c, 0xffef,
 	0x6106, 0x00ce, 0xd084, 0x0158, 0x6a28, 0x928a, 0x007f, 0x1a04,
-	0x359c, 0x9288, 0x3368, 0x210d, 0x918c, 0x00ff, 0x6166, 0xd0dc,
-	0x0130, 0x6828, 0x908a, 0x007f, 0x1a04, 0x359c, 0x605e, 0x6888,
+	0x35bc, 0x9288, 0x3388, 0x210d, 0x918c, 0x00ff, 0x6166, 0xd0dc,
+	0x0130, 0x6828, 0x908a, 0x007f, 0x1a04, 0x35bc, 0x605e, 0x6888,
 	0x9084, 0x0030, 0x8004, 0x8004, 0x8004, 0x8004, 0x0006, 0x2009,
-	0x19b0, 0x9080, 0x2750, 0x2005, 0x200a, 0x2008, 0x2001, 0x0018,
-	0x080c, 0xa879, 0x2009, 0x0390, 0x200b, 0x0400, 0x000e, 0x2009,
-	0x19b1, 0x9080, 0x2754, 0x2005, 0x200a, 0x6808, 0x908a, 0x0100,
-	0x0a04, 0x359c, 0x908a, 0x0841, 0x1a04, 0x359c, 0x9084, 0x0007,
-	0x1904, 0x359c, 0x680c, 0x9005, 0x0904, 0x359c, 0x6810, 0x9005,
-	0x0904, 0x359c, 0x6848, 0x6940, 0x910a, 0x1a04, 0x359c, 0x8001,
-	0x0904, 0x359c, 0x684c, 0x6944, 0x910a, 0x1a04, 0x359c, 0x8001,
-	0x0904, 0x359c, 0x6814, 0x908c, 0x00ff, 0x614e, 0x8007, 0x9084,
-	0x00ff, 0x6052, 0x080c, 0x77fd, 0x080c, 0x6a9c, 0x080c, 0x6ad0,
-	0x6808, 0x602a, 0x080c, 0x2133, 0x2009, 0x0170, 0x200b, 0x0080,
-	0xa001, 0xa001, 0x200b, 0x0000, 0x0036, 0x6b08, 0x080c, 0x26b7,
-	0x003e, 0x6000, 0x9086, 0x0000, 0x1904, 0x440a, 0x6818, 0x691c,
+	0x19b0, 0x9080, 0x276c, 0x2005, 0x200a, 0x2008, 0x2001, 0x0018,
+	0x080c, 0xa88a, 0x2009, 0x0390, 0x200b, 0x0400, 0x000e, 0x2009,
+	0x19b1, 0x9080, 0x2770, 0x2005, 0x200a, 0x6808, 0x908a, 0x0100,
+	0x0a04, 0x35bc, 0x908a, 0x0841, 0x1a04, 0x35bc, 0x9084, 0x0007,
+	0x1904, 0x35bc, 0x680c, 0x9005, 0x0904, 0x35bc, 0x6810, 0x9005,
+	0x0904, 0x35bc, 0x6848, 0x6940, 0x910a, 0x1a04, 0x35bc, 0x8001,
+	0x0904, 0x35bc, 0x684c, 0x6944, 0x910a, 0x1a04, 0x35bc, 0x8001,
+	0x0904, 0x35bc, 0x6814, 0x908c, 0x00ff, 0x614e, 0x8007, 0x9084,
+	0x00ff, 0x6052, 0x080c, 0x7820, 0x080c, 0x6ac0, 0x080c, 0x6af4,
+	0x6808, 0x602a, 0x080c, 0x214b, 0x2009, 0x0170, 0x200b, 0x0080,
+	0xa001, 0xa001, 0x200b, 0x0000, 0x0036, 0x6b08, 0x080c, 0x26d3,
+	0x003e, 0x6000, 0x9086, 0x0000, 0x1904, 0x442a, 0x6818, 0x691c,
 	0x6a20, 0x6b24, 0x8007, 0x810f, 0x8217, 0x831f, 0x6016, 0x611a,
 	0x621e, 0x6322, 0x6c04, 0xd4f4, 0x0148, 0x6830, 0x6934, 0x6a38,
 	0x6b3c, 0x8007, 0x810f, 0x8217, 0x831f, 0x0010, 0x9084, 0xf0ff,
 	0x6006, 0x610a, 0x620e, 0x6312, 0x8007, 0x810f, 0x8217, 0x831f,
 	0x20a9, 0x0004, 0x20a1, 0x19b2, 0x20e9, 0x0001, 0x4001, 0x20a9,
-	0x0004, 0x20a1, 0x19cc, 0x20e9, 0x0001, 0x4001, 0x080c, 0x87b0,
+	0x0004, 0x20a1, 0x19cc, 0x20e9, 0x0001, 0x4001, 0x080c, 0x87e4,
 	0x00c6, 0x900e, 0x20a9, 0x0001, 0x6b70, 0xd384, 0x01c8, 0x0020,
-	0x839d, 0x12b0, 0x3508, 0x8109, 0x080c, 0x7dbe, 0x6878, 0x6016,
+	0x839d, 0x12b0, 0x3508, 0x8109, 0x080c, 0x7de2, 0x6878, 0x6016,
 	0x6874, 0x2008, 0x9084, 0xff00, 0x8007, 0x600a, 0x9184, 0x00ff,
 	0x6006, 0x8108, 0x1118, 0x6003, 0x0003, 0x0010, 0x6003, 0x0001,
-	0x1f04, 0x4368, 0x00ce, 0x00c6, 0x2061, 0x199b, 0x6a88, 0x9284,
+	0x1f04, 0x4388, 0x00ce, 0x00c6, 0x2061, 0x199b, 0x6a88, 0x9284,
 	0xc000, 0x2010, 0x9286, 0x0000, 0x1158, 0x2063, 0x0000, 0x2001,
-	0x0001, 0x080c, 0x295e, 0x2001, 0x0001, 0x080c, 0x2941, 0x0088,
-	0x9286, 0x4000, 0x1148, 0x2063, 0x0001, 0x9006, 0x080c, 0x295e,
-	0x9006, 0x080c, 0x2941, 0x0028, 0x9286, 0x8000, 0x1d30, 0x2063,
-	0x0002, 0x00ce, 0x00e6, 0x2c70, 0x080c, 0x0eb4, 0x00ee, 0x6888,
+	0x0001, 0x080c, 0x297a, 0x2001, 0x0001, 0x080c, 0x295d, 0x0088,
+	0x9286, 0x4000, 0x1148, 0x2063, 0x0001, 0x9006, 0x080c, 0x297a,
+	0x9006, 0x080c, 0x295d, 0x0028, 0x9286, 0x8000, 0x1d30, 0x2063,
+	0x0002, 0x00ce, 0x00e6, 0x2c70, 0x080c, 0x0ec1, 0x00ee, 0x6888,
 	0xd0ec, 0x0130, 0x2011, 0x0114, 0x2204, 0x9085, 0x0180, 0x2012,
 	0x6a80, 0x9284, 0x0030, 0x9086, 0x0030, 0x1128, 0x9294, 0xffcf,
 	0x9295, 0x0020, 0x6a82, 0x2001, 0x197b, 0x6a80, 0x9294, 0x0030,
 	0x928e, 0x0000, 0x0170, 0x928e, 0x0010, 0x0118, 0x928e, 0x0020,
-	0x0140, 0x2003, 0xaaaa, 0x080c, 0x272c, 0x2001, 0x196c, 0x2102,
+	0x0140, 0x2003, 0xaaaa, 0x080c, 0x2748, 0x2001, 0x196c, 0x2102,
 	0x0008, 0x2102, 0x00c6, 0x2061, 0x0100, 0x602f, 0x0040, 0x602f,
-	0x0000, 0x00ce, 0x080c, 0x74c8, 0x0128, 0x080c, 0x4fd9, 0x0110,
-	0x080c, 0x267d, 0x60d4, 0x9005, 0x01c0, 0x6003, 0x0001, 0x2009,
-	0x43f2, 0x00e0, 0x080c, 0x74c8, 0x1168, 0x2011, 0x733e, 0x080c,
-	0x861d, 0x2011, 0x7331, 0x080c, 0x8729, 0x080c, 0x77d1, 0x080c,
-	0x73f9, 0x0040, 0x080c, 0x5edf, 0x0028, 0x6003, 0x0004, 0x2009,
-	0x440a, 0x0020, 0x080c, 0x69cc, 0x0804, 0x3567, 0x2001, 0x0170,
+	0x0000, 0x00ce, 0x080c, 0x74ec, 0x0128, 0x080c, 0x4ff9, 0x0110,
+	0x080c, 0x2699, 0x60d4, 0x9005, 0x01c0, 0x6003, 0x0001, 0x2009,
+	0x4412, 0x00e0, 0x080c, 0x74ec, 0x1168, 0x2011, 0x7362, 0x080c,
+	0x8651, 0x2011, 0x7355, 0x080c, 0x875d, 0x080c, 0x77f4, 0x080c,
+	0x741d, 0x0040, 0x080c, 0x5eff, 0x0028, 0x6003, 0x0004, 0x2009,
+	0x442a, 0x0020, 0x080c, 0x69f0, 0x0804, 0x3587, 0x2001, 0x0170,
 	0x2004, 0x9084, 0x00ff, 0x9086, 0x004c, 0x1118, 0x2091, 0x31bd,
 	0x0817, 0x2091, 0x313d, 0x0817, 0x6000, 0x9086, 0x0000, 0x0904,
-	0x3599, 0x2069, 0x1847, 0x7890, 0x6842, 0x7894, 0x6846, 0x2d00,
+	0x35b9, 0x2069, 0x1847, 0x7890, 0x6842, 0x7894, 0x6846, 0x2d00,
 	0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0001,
-	0x0804, 0x4af5, 0x9006, 0x080c, 0x267d, 0x81ff, 0x1904, 0x3599,
-	0x080c, 0x74c8, 0x11b0, 0x080c, 0x77cc, 0x080c, 0x6024, 0x080c,
-	0x335c, 0x0118, 0x6130, 0xc18d, 0x6132, 0x080c, 0xcf51, 0x0130,
-	0x080c, 0x74eb, 0x1118, 0x080c, 0x749c, 0x0038, 0x080c, 0x73f9,
-	0x0020, 0x080c, 0x5fe9, 0x080c, 0x5edf, 0x0804, 0x3567, 0x81ff,
-	0x1904, 0x3599, 0x080c, 0x74c8, 0x1110, 0x0804, 0x3599, 0x6194,
+	0x0804, 0x4b15, 0x9006, 0x080c, 0x2699, 0x81ff, 0x1904, 0x35b9,
+	0x080c, 0x74ec, 0x11b0, 0x080c, 0x77ef, 0x080c, 0x6044, 0x080c,
+	0x337c, 0x0118, 0x6130, 0xc18d, 0x6132, 0x080c, 0xcf84, 0x0130,
+	0x080c, 0x750f, 0x1118, 0x080c, 0x74c0, 0x0038, 0x080c, 0x741d,
+	0x0020, 0x080c, 0x6009, 0x080c, 0x5eff, 0x0804, 0x3587, 0x81ff,
+	0x1904, 0x35b9, 0x080c, 0x74ec, 0x1110, 0x0804, 0x35b9, 0x6194,
 	0x81ff, 0x01a8, 0x704f, 0x0000, 0x2001, 0x1d80, 0x2009, 0x0040,
 	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0126, 0x2091, 0x8000, 0x2039,
-	0x0001, 0x080c, 0x4af5, 0x701f, 0x3565, 0x012e, 0x0005, 0x704f,
+	0x0001, 0x080c, 0x4b15, 0x701f, 0x3585, 0x012e, 0x0005, 0x704f,
 	0x0001, 0x00d6, 0x2069, 0x1d80, 0x20a9, 0x0040, 0x20e9, 0x0001,
-	0x20a1, 0x1d80, 0x2019, 0xffff, 0x4304, 0x655c, 0x9588, 0x3368,
+	0x20a1, 0x1d80, 0x2019, 0xffff, 0x4304, 0x655c, 0x9588, 0x3388,
 	0x210d, 0x918c, 0x00ff, 0x216a, 0x900e, 0x2011, 0x0002, 0x2100,
-	0x9506, 0x01a8, 0x080c, 0x6620, 0x1190, 0xb814, 0x821c, 0x0238,
+	0x9506, 0x01a8, 0x080c, 0x6644, 0x1190, 0xb814, 0x821c, 0x0238,
 	0x9398, 0x1d80, 0x9085, 0xff00, 0x8007, 0x201a, 0x0038, 0x9398,
 	0x1d80, 0x2324, 0x94a4, 0xff00, 0x9405, 0x201a, 0x8210, 0x8108,
 	0x9182, 0x0080, 0x1208, 0x0c18, 0x8201, 0x8007, 0x2d0c, 0x9105,
 	0x206a, 0x00de, 0x20a9, 0x0040, 0x20a1, 0x1d80, 0x2099, 0x1d80,
-	0x080c, 0x5f74, 0x0804, 0x4464, 0x080c, 0x4adc, 0x0904, 0x359c,
-	0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804, 0x3599, 0x080c,
-	0x56d5, 0xd0b4, 0x0558, 0x7884, 0x908e, 0x007e, 0x0538, 0x908e,
-	0x007f, 0x0520, 0x908e, 0x0080, 0x0508, 0x080c, 0x3357, 0x1148,
+	0x080c, 0x5f94, 0x0804, 0x4484, 0x080c, 0x4afc, 0x0904, 0x35bc,
+	0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804, 0x35b9, 0x080c,
+	0x56f5, 0xd0b4, 0x0558, 0x7884, 0x908e, 0x007e, 0x0538, 0x908e,
+	0x007f, 0x0520, 0x908e, 0x0080, 0x0508, 0x080c, 0x3377, 0x1148,
 	0xb800, 0xd08c, 0x11d8, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
-	0x11a8, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xca01,
-	0x1120, 0x2009, 0x0003, 0x0804, 0x3599, 0x7007, 0x0003, 0x701f,
-	0x44f2, 0x0005, 0x080c, 0x4adc, 0x0904, 0x359c, 0x20a9, 0x002b,
+	0x11a8, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xca34,
+	0x1120, 0x2009, 0x0003, 0x0804, 0x35b9, 0x7007, 0x0003, 0x701f,
+	0x4512, 0x0005, 0x080c, 0x4afc, 0x0904, 0x35bc, 0x20a9, 0x002b,
 	0xb8c4, 0x20e0, 0xb8c8, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080,
 	0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0,
-	0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098, 0x080c, 0x0fb7,
+	0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098, 0x080c, 0x0fc4,
 	0x0070, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x000a, 0x20a0, 0xb8c4,
-	0x20e0, 0xb8c8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0fb7, 0x8906,
+	0x20e0, 0xb8c8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0fc4, 0x8906,
 	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002,
-	0x2009, 0x002b, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4af5,
-	0x81ff, 0x1904, 0x3599, 0x080c, 0x4ac0, 0x0904, 0x359c, 0x080c,
-	0x6865, 0x0904, 0x3599, 0x0058, 0xa878, 0x9005, 0x0120, 0x2009,
-	0x0004, 0x0804, 0x3599, 0xa974, 0xaa94, 0x0804, 0x3567, 0x080c,
-	0x56dd, 0x0904, 0x3567, 0x701f, 0x453c, 0x7007, 0x0003, 0x0005,
-	0x81ff, 0x1904, 0x3599, 0x7888, 0x908a, 0x1000, 0x1a04, 0x359c,
-	0x080c, 0x4adc, 0x0904, 0x359c, 0x080c, 0x6a6a, 0x0120, 0x080c,
-	0x6a72, 0x1904, 0x359c, 0x080c, 0x68ea, 0x0904, 0x3599, 0x2019,
-	0x0004, 0x900e, 0x080c, 0x6877, 0x0904, 0x3599, 0x7984, 0x7a88,
-	0x04c9, 0x08a8, 0xa89c, 0x908a, 0x1000, 0x12f8, 0x080c, 0x4ada,
-	0x01e0, 0x080c, 0x6a6a, 0x0118, 0x080c, 0x6a72, 0x11b0, 0x080c,
-	0x68ea, 0x2009, 0x0002, 0x0168, 0x2009, 0x0002, 0x2019, 0x0004,
-	0x080c, 0x6877, 0x2009, 0x0003, 0x0120, 0xa998, 0xaa9c, 0x00d1,
+	0x2009, 0x002b, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4b15,
+	0x81ff, 0x1904, 0x35b9, 0x080c, 0x4ae0, 0x0904, 0x35bc, 0x080c,
+	0x6889, 0x0904, 0x35b9, 0x0058, 0xa878, 0x9005, 0x0120, 0x2009,
+	0x0004, 0x0804, 0x35b9, 0xa974, 0xaa94, 0x0804, 0x3587, 0x080c,
+	0x56fd, 0x0904, 0x3587, 0x701f, 0x455c, 0x7007, 0x0003, 0x0005,
+	0x81ff, 0x1904, 0x35b9, 0x7888, 0x908a, 0x1000, 0x1a04, 0x35bc,
+	0x080c, 0x4afc, 0x0904, 0x35bc, 0x080c, 0x6a8e, 0x0120, 0x080c,
+	0x6a96, 0x1904, 0x35bc, 0x080c, 0x690e, 0x0904, 0x35b9, 0x2019,
+	0x0004, 0x900e, 0x080c, 0x689b, 0x0904, 0x35b9, 0x7984, 0x7a88,
+	0x04c9, 0x08a8, 0xa89c, 0x908a, 0x1000, 0x12f8, 0x080c, 0x4afa,
+	0x01e0, 0x080c, 0x6a8e, 0x0118, 0x080c, 0x6a96, 0x11b0, 0x080c,
+	0x690e, 0x2009, 0x0002, 0x0168, 0x2009, 0x0002, 0x2019, 0x0004,
+	0x080c, 0x689b, 0x2009, 0x0003, 0x0120, 0xa998, 0xaa9c, 0x00d1,
 	0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e,
 	0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0x080c,
-	0x56dd, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001,
+	0x56fd, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001,
 	0x0000, 0x0005, 0x9186, 0x00ff, 0x0110, 0x0071, 0x0060, 0x2029,
 	0x007e, 0x2061, 0x1800, 0x645c, 0x2400, 0x9506, 0x0110, 0x2508,
-	0x0019, 0x8529, 0x1ec8, 0x0005, 0x080c, 0x6620, 0x1138, 0x2200,
-	0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x862b, 0x0005, 0x81ff,
-	0x1904, 0x3599, 0x798c, 0x2001, 0x197f, 0x918c, 0x8000, 0x2102,
-	0x080c, 0x4ac0, 0x0904, 0x359c, 0x080c, 0x6a6a, 0x0120, 0x080c,
-	0x6a72, 0x1904, 0x359c, 0x080c, 0x66e7, 0x0904, 0x3599, 0x080c,
-	0x686e, 0x0904, 0x3599, 0x2001, 0x197f, 0x2004, 0xd0fc, 0x1904,
-	0x3567, 0x0804, 0x4547, 0xa9a0, 0x2001, 0x197f, 0x918c, 0x8000,
-	0xc18d, 0x2102, 0x080c, 0x4acd, 0x01a0, 0x080c, 0x6a6a, 0x0118,
-	0x080c, 0x6a72, 0x1170, 0x080c, 0x66e7, 0x2009, 0x0002, 0x0128,
-	0x080c, 0x686e, 0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a,
+	0x0019, 0x8529, 0x1ec8, 0x0005, 0x080c, 0x6644, 0x1138, 0x2200,
+	0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x865f, 0x0005, 0x81ff,
+	0x1904, 0x35b9, 0x798c, 0x2001, 0x197f, 0x918c, 0x8000, 0x2102,
+	0x080c, 0x4ae0, 0x0904, 0x35bc, 0x080c, 0x6a8e, 0x0120, 0x080c,
+	0x6a96, 0x1904, 0x35bc, 0x080c, 0x670b, 0x0904, 0x35b9, 0x080c,
+	0x6892, 0x0904, 0x35b9, 0x2001, 0x197f, 0x2004, 0xd0fc, 0x1904,
+	0x3587, 0x0804, 0x4567, 0xa9a0, 0x2001, 0x197f, 0x918c, 0x8000,
+	0xc18d, 0x2102, 0x080c, 0x4aed, 0x01a0, 0x080c, 0x6a8e, 0x0118,
+	0x080c, 0x6a96, 0x1170, 0x080c, 0x670b, 0x2009, 0x0002, 0x0128,
+	0x080c, 0x6892, 0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a,
 	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
 	0x0005, 0xa897, 0x4000, 0x2001, 0x197f, 0x2004, 0xd0fc, 0x1128,
-	0x080c, 0x56dd, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001,
-	0x2001, 0x0000, 0x0005, 0x81ff, 0x1904, 0x3599, 0x798c, 0x2001,
-	0x197e, 0x918c, 0x8000, 0x2102, 0x080c, 0x4ac0, 0x0904, 0x359c,
-	0x080c, 0x6a6a, 0x0120, 0x080c, 0x6a72, 0x1904, 0x359c, 0x080c,
-	0x66e7, 0x0904, 0x3599, 0x080c, 0x685c, 0x0904, 0x3599, 0x2001,
-	0x197e, 0x2004, 0xd0fc, 0x1904, 0x3567, 0x0804, 0x4547, 0xa9a0,
-	0x2001, 0x197e, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c, 0x4acd,
-	0x01a0, 0x080c, 0x6a6a, 0x0118, 0x080c, 0x6a72, 0x1170, 0x080c,
-	0x66e7, 0x2009, 0x0002, 0x0128, 0x080c, 0x685c, 0x1170, 0x2009,
+	0x080c, 0x56fd, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001,
+	0x2001, 0x0000, 0x0005, 0x81ff, 0x1904, 0x35b9, 0x798c, 0x2001,
+	0x197e, 0x918c, 0x8000, 0x2102, 0x080c, 0x4ae0, 0x0904, 0x35bc,
+	0x080c, 0x6a8e, 0x0120, 0x080c, 0x6a96, 0x1904, 0x35bc, 0x080c,
+	0x670b, 0x0904, 0x35b9, 0x080c, 0x6880, 0x0904, 0x35b9, 0x2001,
+	0x197e, 0x2004, 0xd0fc, 0x1904, 0x3587, 0x0804, 0x4567, 0xa9a0,
+	0x2001, 0x197e, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c, 0x4aed,
+	0x01a0, 0x080c, 0x6a8e, 0x0118, 0x080c, 0x6a96, 0x1170, 0x080c,
+	0x670b, 0x2009, 0x0002, 0x0128, 0x080c, 0x6880, 0x1170, 0x2009,
 	0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e,
 	0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0x2001,
-	0x197e, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x56dd, 0x0110, 0x9006,
+	0x197e, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x56fd, 0x0110, 0x9006,
 	0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x6100,
-	0x0804, 0x3567, 0x080c, 0x4adc, 0x0904, 0x359c, 0x080c, 0x56e9,
-	0x1904, 0x3599, 0x79a8, 0xd184, 0x1158, 0xb834, 0x8007, 0x789e,
+	0x0804, 0x3587, 0x080c, 0x4afc, 0x0904, 0x35bc, 0x080c, 0x5709,
+	0x1904, 0x35b9, 0x79a8, 0xd184, 0x1158, 0xb834, 0x8007, 0x789e,
 	0xb830, 0x8007, 0x789a, 0xbb2c, 0x831f, 0xba28, 0x8217, 0x0050,
 	0xb824, 0x8007, 0x789e, 0xb820, 0x8007, 0x789a, 0xbb1c, 0x831f,
-	0xba18, 0x8217, 0xb900, 0x918c, 0x0200, 0x0804, 0x3567, 0x78a8,
-	0x909c, 0x0003, 0xd0b4, 0x1140, 0x939a, 0x0003, 0x1a04, 0x3599,
-	0x625c, 0x7884, 0x9206, 0x1548, 0x080c, 0x879a, 0x2001, 0xfff4,
-	0x2009, 0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0000,
-	0x0006, 0x78a8, 0x9084, 0x0080, 0x1118, 0x000e, 0x0804, 0x4af5,
+	0xba18, 0x8217, 0xb900, 0x918c, 0x0200, 0x0804, 0x3587, 0x78a8,
+	0x909c, 0x0003, 0xd0ac, 0x1150, 0xd0b4, 0x1140, 0x939a, 0x0003,
+	0x1a04, 0x35b9, 0x625c, 0x7884, 0x9206, 0x1538, 0x080c, 0x87ce,
+	0x2001, 0xffec, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0000,
+	0x0006, 0x78a8, 0x9084, 0x0080, 0x1118, 0x000e, 0x0804, 0x4b15,
 	0x000e, 0x2031, 0x0000, 0x2061, 0x18b8, 0x2c44, 0xa66a, 0xa17a,
-	0xa772, 0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x112f,
-	0x7007, 0x0002, 0x701f, 0x46fd, 0x0005, 0x81ff, 0x1904, 0x3599,
-	0x080c, 0x4adc, 0x0904, 0x359c, 0x080c, 0x6a6a, 0x1904, 0x3599,
-	0x00c6, 0x080c, 0x4aa9, 0x00ce, 0x0904, 0x3599, 0xa867, 0x0000,
-	0xa868, 0xc0fd, 0xa86a, 0x7ea8, 0x080c, 0xc9a7, 0x0904, 0x3599,
-	0x7007, 0x0003, 0x701f, 0x4701, 0x0005, 0x080c, 0x4245, 0x0804,
-	0x3567, 0xa830, 0x9086, 0x0100, 0x0904, 0x3599, 0x8906, 0x8006,
+	0xa772, 0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x113c,
+	0x7007, 0x0002, 0x701f, 0x471d, 0x0005, 0x81ff, 0x1904, 0x35b9,
+	0x080c, 0x4afc, 0x0904, 0x35bc, 0x080c, 0x6a8e, 0x1904, 0x35b9,
+	0x00c6, 0x080c, 0x4ac9, 0x00ce, 0x0904, 0x35b9, 0xa867, 0x0000,
+	0xa868, 0xc0fd, 0xa86a, 0x7ea8, 0x080c, 0xc9da, 0x0904, 0x35b9,
+	0x7007, 0x0003, 0x701f, 0x4721, 0x0005, 0x080c, 0x4265, 0x0804,
+	0x3587, 0xa830, 0x9086, 0x0100, 0x0904, 0x35b9, 0x8906, 0x8006,
 	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x2009,
-	0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4af5, 0x9006,
-	0x080c, 0x267d, 0x78a8, 0x9084, 0x00ff, 0x9086, 0x00ff, 0x0118,
-	0x81ff, 0x1904, 0x3599, 0x080c, 0x74c8, 0x0110, 0x080c, 0x5fe9,
-	0x7888, 0x908a, 0x1000, 0x1a04, 0x359c, 0x7984, 0x9186, 0x00ff,
-	0x0138, 0x9182, 0x007f, 0x1a04, 0x359c, 0x2100, 0x080c, 0x2647,
+	0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x4b15, 0x9006,
+	0x080c, 0x2699, 0x78a8, 0x9084, 0x00ff, 0x9086, 0x00ff, 0x0118,
+	0x81ff, 0x1904, 0x35b9, 0x080c, 0x74ec, 0x0110, 0x080c, 0x6009,
+	0x7888, 0x908a, 0x1000, 0x1a04, 0x35bc, 0x7984, 0x9186, 0x00ff,
+	0x0138, 0x9182, 0x007f, 0x1a04, 0x35bc, 0x2100, 0x080c, 0x2663,
 	0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x2061, 0x1a02, 0x601b,
 	0x0000, 0x601f, 0x0000, 0x6073, 0x0000, 0x6077, 0x0000, 0x080c,
-	0x74c8, 0x1158, 0x080c, 0x77cc, 0x080c, 0x6024, 0x9085, 0x0001,
-	0x080c, 0x750f, 0x080c, 0x73f9, 0x00f0, 0x080c, 0xa888, 0x080c,
-	0xab50, 0x080c, 0xa8a4, 0x2061, 0x0100, 0x2001, 0x1818, 0x2004,
+	0x74ec, 0x1158, 0x080c, 0x77ef, 0x080c, 0x6044, 0x9085, 0x0001,
+	0x080c, 0x7533, 0x080c, 0x741d, 0x00f0, 0x080c, 0xa899, 0x080c,
+	0xab61, 0x080c, 0xa8b5, 0x2061, 0x0100, 0x2001, 0x1818, 0x2004,
 	0x9084, 0x00ff, 0x810f, 0x9105, 0x604a, 0x6043, 0x0090, 0x6043,
 	0x0010, 0x2009, 0x1998, 0x200b, 0x0000, 0x2009, 0x002d, 0x2011,
-	0x5f0f, 0x080c, 0x86e7, 0x7984, 0x080c, 0x74c8, 0x1110, 0x2009,
-	0x00ff, 0x7a88, 0x080c, 0x45aa, 0x012e, 0x00ce, 0x002e, 0x0804,
-	0x3567, 0x7984, 0x080c, 0x65bf, 0x2b08, 0x1904, 0x359c, 0x0804,
-	0x3567, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3599, 0x60dc,
-	0xd0ac, 0x1130, 0xd09c, 0x1120, 0x2009, 0x0005, 0x0804, 0x3599,
-	0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804, 0x3599, 0x7984,
-	0x9192, 0x0021, 0x1a04, 0x359c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
-	0xa85c, 0x9080, 0x0019, 0x702a, 0xaf60, 0x7736, 0x080c, 0x4af2,
-	0x701f, 0x47b9, 0x7880, 0x9086, 0x006e, 0x0110, 0x701f, 0x518b,
-	0x0005, 0x2009, 0x0080, 0x080c, 0x6620, 0x1118, 0x080c, 0x6a6a,
-	0x0120, 0x2021, 0x400a, 0x0804, 0x3569, 0x00d6, 0x0096, 0xa964,
+	0x5f2f, 0x080c, 0x871b, 0x7984, 0x080c, 0x74ec, 0x1110, 0x2009,
+	0x00ff, 0x7a88, 0x080c, 0x45ca, 0x012e, 0x00ce, 0x002e, 0x0804,
+	0x3587, 0x7984, 0x080c, 0x65e3, 0x2b08, 0x1904, 0x35bc, 0x0804,
+	0x3587, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x35b9, 0x60dc,
+	0xd0ac, 0x1130, 0xd09c, 0x1120, 0x2009, 0x0005, 0x0804, 0x35b9,
+	0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804, 0x35b9, 0x7984,
+	0x9192, 0x0021, 0x1a04, 0x35bc, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
+	0xa85c, 0x9080, 0x0019, 0x702a, 0xaf60, 0x7736, 0x080c, 0x4b12,
+	0x701f, 0x47d9, 0x7880, 0x9086, 0x006e, 0x0110, 0x701f, 0x51ab,
+	0x0005, 0x2009, 0x0080, 0x080c, 0x6644, 0x1118, 0x080c, 0x6a8e,
+	0x0120, 0x2021, 0x400a, 0x0804, 0x3589, 0x00d6, 0x0096, 0xa964,
 	0xaa6c, 0xab70, 0xac74, 0xad78, 0xae7c, 0xa884, 0x90be, 0x0100,
-	0x0904, 0x4852, 0x90be, 0x0112, 0x0904, 0x4852, 0x90be, 0x0113,
-	0x0904, 0x4852, 0x90be, 0x0114, 0x0904, 0x4852, 0x90be, 0x0117,
-	0x0904, 0x4852, 0x90be, 0x011a, 0x0904, 0x4852, 0x90be, 0x011c,
-	0x0904, 0x4852, 0x90be, 0x0121, 0x0904, 0x4839, 0x90be, 0x0131,
-	0x0904, 0x4839, 0x90be, 0x0171, 0x0904, 0x4852, 0x90be, 0x0173,
-	0x0904, 0x4852, 0x90be, 0x01a1, 0x1128, 0xa894, 0x8007, 0xa896,
-	0x0804, 0x485d, 0x90be, 0x0212, 0x0904, 0x4846, 0x90be, 0x0213,
+	0x0904, 0x4872, 0x90be, 0x0112, 0x0904, 0x4872, 0x90be, 0x0113,
+	0x0904, 0x4872, 0x90be, 0x0114, 0x0904, 0x4872, 0x90be, 0x0117,
+	0x0904, 0x4872, 0x90be, 0x011a, 0x0904, 0x4872, 0x90be, 0x011c,
+	0x0904, 0x4872, 0x90be, 0x0121, 0x0904, 0x4859, 0x90be, 0x0131,
+	0x0904, 0x4859, 0x90be, 0x0171, 0x0904, 0x4872, 0x90be, 0x0173,
+	0x0904, 0x4872, 0x90be, 0x01a1, 0x1128, 0xa894, 0x8007, 0xa896,
+	0x0804, 0x487d, 0x90be, 0x0212, 0x0904, 0x4866, 0x90be, 0x0213,
 	0x05e8, 0x90be, 0x0214, 0x0500, 0x90be, 0x0217, 0x0188, 0x90be,
 	0x021a, 0x1120, 0xa89c, 0x8007, 0xa89e, 0x04e0, 0x90be, 0x021f,
-	0x05c8, 0x90be, 0x0300, 0x05b0, 0x009e, 0x00de, 0x0804, 0x359c,
+	0x05c8, 0x90be, 0x0300, 0x05b0, 0x009e, 0x00de, 0x0804, 0x35bc,
 	0x7028, 0x9080, 0x0010, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8,
-	0x20a9, 0x0007, 0x080c, 0x489b, 0x7028, 0x9080, 0x000e, 0x2098,
-	0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x489b,
+	0x20a9, 0x0007, 0x080c, 0x48bb, 0x7028, 0x9080, 0x000e, 0x2098,
+	0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x48bb,
 	0x00c8, 0x7028, 0x9080, 0x000c, 0x2098, 0x20a0, 0x7034, 0x20e0,
-	0x20e8, 0x20a9, 0x0001, 0x080c, 0x48a8, 0x00b8, 0x7028, 0x9080,
+	0x20e8, 0x20a9, 0x0001, 0x080c, 0x48c8, 0x00b8, 0x7028, 0x9080,
 	0x000e, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001,
-	0x080c, 0x48a8, 0x7028, 0x9080, 0x000c, 0x2098, 0x20a0, 0x7034,
-	0x20e0, 0x20e8, 0x20a9, 0x0001, 0x04f1, 0x00c6, 0x080c, 0x4aa9,
+	0x080c, 0x48c8, 0x7028, 0x9080, 0x000c, 0x2098, 0x20a0, 0x7034,
+	0x20e0, 0x20e8, 0x20a9, 0x0001, 0x04f1, 0x00c6, 0x080c, 0x4ac9,
 	0x0550, 0xa868, 0xc0fd, 0xa86a, 0xa867, 0x0119, 0x9006, 0xa882,
 	0xa87f, 0x0020, 0xa88b, 0x0001, 0x810b, 0xa9ae, 0xa8b2, 0xaab6,
 	0xabba, 0xacbe, 0xadc2, 0xa9c6, 0xa8ca, 0x00ce, 0x009e, 0x00de,
 	0xa866, 0xa822, 0xa868, 0xc0fd, 0xa86a, 0xa804, 0x2048, 0x080c,
-	0xc9c2, 0x1120, 0x2009, 0x0003, 0x0804, 0x3599, 0x7007, 0x0003,
-	0x701f, 0x4892, 0x0005, 0x00ce, 0x009e, 0x00de, 0x2009, 0x0002,
-	0x0804, 0x3599, 0xa820, 0x9086, 0x8001, 0x1904, 0x3567, 0x2009,
-	0x0004, 0x0804, 0x3599, 0x0016, 0x0026, 0x3510, 0x20a9, 0x0002,
+	0xc9f5, 0x1120, 0x2009, 0x0003, 0x0804, 0x35b9, 0x7007, 0x0003,
+	0x701f, 0x48b2, 0x0005, 0x00ce, 0x009e, 0x00de, 0x2009, 0x0002,
+	0x0804, 0x35b9, 0xa820, 0x9086, 0x8001, 0x1904, 0x3587, 0x2009,
+	0x0004, 0x0804, 0x35b9, 0x0016, 0x0026, 0x3510, 0x20a9, 0x0002,
 	0x4002, 0x4104, 0x4004, 0x8211, 0x1dc8, 0x002e, 0x001e, 0x0005,
 	0x0016, 0x0026, 0x0036, 0x0046, 0x3520, 0x20a9, 0x0004, 0x4002,
 	0x4304, 0x4204, 0x4104, 0x4004, 0x8421, 0x1db8, 0x004e, 0x003e,
 	0x002e, 0x001e, 0x0005, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804,
-	0x3599, 0x60dc, 0xd0ac, 0x1130, 0xd09c, 0x1120, 0x2009, 0x0005,
-	0x0804, 0x3599, 0x7984, 0x78a8, 0x2040, 0x080c, 0xab49, 0x1120,
-	0x9182, 0x007f, 0x0a04, 0x359c, 0x9186, 0x00ff, 0x0904, 0x359c,
-	0x9182, 0x0800, 0x1a04, 0x359c, 0x7a8c, 0x7b88, 0x607c, 0x9306,
-	0x1158, 0x6080, 0x924e, 0x0904, 0x359c, 0x080c, 0xab49, 0x1120,
-	0x99cc, 0xff00, 0x0904, 0x359c, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x49bc, 0x0904, 0x493c, 0x0086, 0x90c6, 0x4000, 0x008e, 0x1538,
+	0x35b9, 0x60dc, 0xd0ac, 0x1130, 0xd09c, 0x1120, 0x2009, 0x0005,
+	0x0804, 0x35b9, 0x7984, 0x78a8, 0x2040, 0x080c, 0xab5a, 0x1120,
+	0x9182, 0x007f, 0x0a04, 0x35bc, 0x9186, 0x00ff, 0x0904, 0x35bc,
+	0x9182, 0x0800, 0x1a04, 0x35bc, 0x7a8c, 0x7b88, 0x607c, 0x9306,
+	0x1158, 0x6080, 0x924e, 0x0904, 0x35bc, 0x080c, 0xab5a, 0x1120,
+	0x99cc, 0xff00, 0x0904, 0x35bc, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x49dc, 0x0904, 0x495c, 0x0086, 0x90c6, 0x4000, 0x008e, 0x1538,
 	0x00c6, 0x0006, 0x0036, 0xb818, 0xbb1c, 0x9305, 0xbb20, 0x9305,
 	0xbb24, 0x9305, 0xbb28, 0x9305, 0xbb2c, 0x9305, 0xbb30, 0x9305,
-	0xbb34, 0x9305, 0x003e, 0x0570, 0xd88c, 0x1128, 0x080c, 0x6a6a,
-	0x0110, 0xc89d, 0x0438, 0x900e, 0x080c, 0x6913, 0x1108, 0xc185,
+	0xbb34, 0x9305, 0x003e, 0x0570, 0xd88c, 0x1128, 0x080c, 0x6a8e,
+	0x0110, 0xc89d, 0x0438, 0x900e, 0x080c, 0x6937, 0x1108, 0xc185,
 	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x000e, 0x00ce, 0x00b8, 0x90c6,
 	0x4007, 0x1110, 0x2408, 0x0090, 0x90c6, 0x4008, 0x1118, 0x2708,
 	0x2610, 0x0060, 0x90c6, 0x4009, 0x1108, 0x0040, 0x90c6, 0x4006,
 	0x1108, 0x0020, 0x2001, 0x4005, 0x2009, 0x000a, 0x2020, 0x012e,
-	0x0804, 0x3569, 0x000e, 0x00ce, 0x2b00, 0x7026, 0x0016, 0x00b6,
-	0x00c6, 0x00e6, 0x2c70, 0x080c, 0xac4f, 0x0904, 0x4991, 0x2b00,
-	0x6012, 0x080c, 0xcccb, 0x2e58, 0x00ee, 0x00e6, 0x00c6, 0x080c,
-	0x4aa9, 0x00ce, 0x2b70, 0x1158, 0x080c, 0xabdf, 0x00ee, 0x00ce,
-	0x00be, 0x001e, 0x012e, 0x2009, 0x0002, 0x0804, 0x3599, 0x900e,
+	0x0804, 0x3589, 0x000e, 0x00ce, 0x2b00, 0x7026, 0x0016, 0x00b6,
+	0x00c6, 0x00e6, 0x2c70, 0x080c, 0xac60, 0x0904, 0x49b1, 0x2b00,
+	0x6012, 0x080c, 0xccfe, 0x2e58, 0x00ee, 0x00e6, 0x00c6, 0x080c,
+	0x4ac9, 0x00ce, 0x2b70, 0x1158, 0x080c, 0xabf0, 0x00ee, 0x00ce,
+	0x00be, 0x001e, 0x012e, 0x2009, 0x0002, 0x0804, 0x35b9, 0x900e,
 	0xa966, 0xa96a, 0x2900, 0x6016, 0xa932, 0xa868, 0xc0fd, 0xd88c,
-	0x0108, 0xc0f5, 0xa86a, 0xd89c, 0x1110, 0x080c, 0x31ef, 0x6023,
-	0x0001, 0x9006, 0x080c, 0x655c, 0xd89c, 0x0138, 0x2001, 0x0004,
-	0x080c, 0x6570, 0x2009, 0x0003, 0x0030, 0x2001, 0x0002, 0x080c,
-	0x6570, 0x2009, 0x0002, 0x080c, 0xac7c, 0x78a8, 0xd094, 0x0138,
+	0x0108, 0xc0f5, 0xa86a, 0xd89c, 0x1110, 0x080c, 0x320f, 0x6023,
+	0x0001, 0x9006, 0x080c, 0x6580, 0xd89c, 0x0138, 0x2001, 0x0004,
+	0x080c, 0x6594, 0x2009, 0x0003, 0x0030, 0x2001, 0x0002, 0x080c,
+	0x6594, 0x2009, 0x0002, 0x080c, 0xac8d, 0x78a8, 0xd094, 0x0138,
 	0x00ee, 0x7024, 0x00e6, 0x2058, 0xb8d4, 0xc08d, 0xb8d6, 0x9085,
 	0x0001, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x1120, 0x2009,
-	0x0003, 0x0804, 0x3599, 0x7007, 0x0003, 0x701f, 0x49a0, 0x0005,
+	0x0003, 0x0804, 0x35b9, 0x7007, 0x0003, 0x701f, 0x49c0, 0x0005,
 	0xa830, 0x9086, 0x0100, 0x7024, 0x2058, 0x1138, 0x2009, 0x0004,
-	0xba04, 0x9294, 0x00ff, 0x0804, 0x5632, 0x900e, 0xa868, 0xd0f4,
-	0x1904, 0x3567, 0x080c, 0x6913, 0x1108, 0xc185, 0xb800, 0xd0bc,
-	0x0108, 0xc18d, 0x0804, 0x3567, 0x00e6, 0x00d6, 0x0096, 0x83ff,
-	0x0904, 0x4a0b, 0x902e, 0x080c, 0xab49, 0x0130, 0x9026, 0x20a9,
+	0xba04, 0x9294, 0x00ff, 0x0804, 0x5652, 0x900e, 0xa868, 0xd0f4,
+	0x1904, 0x3587, 0x080c, 0x6937, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0x0804, 0x3587, 0x00e6, 0x00d6, 0x0096, 0x83ff,
+	0x0904, 0x4a2b, 0x902e, 0x080c, 0xab5a, 0x0130, 0x9026, 0x20a9,
 	0x0800, 0x2071, 0x1000, 0x0030, 0x2021, 0x007f, 0x20a9, 0x0781,
 	0x2071, 0x107f, 0x2e04, 0x9005, 0x11b8, 0x2100, 0x9406, 0x1904,
-	0x4a1c, 0x2428, 0x94ce, 0x007f, 0x1120, 0x92ce, 0xfffd, 0x1558,
+	0x4a3c, 0x2428, 0x94ce, 0x007f, 0x1120, 0x92ce, 0xfffd, 0x1558,
 	0x0030, 0x94ce, 0x0080, 0x1130, 0x92ce, 0xfffc, 0x1520, 0x93ce,
 	0x00ff, 0x1508, 0xc5fd, 0x0480, 0x2058, 0xbf10, 0x2700, 0x9306,
 	0x11e8, 0xbe14, 0x2600, 0x9206, 0x11c8, 0x2400, 0x9106, 0x1180,
-	0xd884, 0x0598, 0xd894, 0x1588, 0x080c, 0x6a0a, 0x1570, 0x2001,
-	0x4000, 0x0460, 0x080c, 0x6a6a, 0x1540, 0x2001, 0x4000, 0x0430,
+	0xd884, 0x0598, 0xd894, 0x1588, 0x080c, 0x6a2e, 0x1570, 0x2001,
+	0x4000, 0x0460, 0x080c, 0x6a8e, 0x1540, 0x2001, 0x4000, 0x0430,
 	0x2001, 0x4007, 0x0418, 0x2001, 0x4006, 0x0400, 0x2400, 0x9106,
-	0x1158, 0xbe14, 0x87ff, 0x1128, 0x86ff, 0x0918, 0x080c, 0xab49,
-	0x1900, 0x2001, 0x4008, 0x0090, 0x8420, 0x8e70, 0x1f04, 0x49d2,
+	0x1158, 0xbe14, 0x87ff, 0x1128, 0x86ff, 0x0918, 0x080c, 0xab5a,
+	0x1900, 0x2001, 0x4008, 0x0090, 0x8420, 0x8e70, 0x1f04, 0x49f2,
 	0x85ff, 0x1130, 0x2001, 0x4009, 0x0048, 0x2001, 0x0001, 0x0030,
-	0x080c, 0x65bf, 0x1dd0, 0xbb12, 0xba16, 0x9006, 0x9005, 0x009e,
+	0x080c, 0x65e3, 0x1dd0, 0xbb12, 0xba16, 0x9006, 0x9005, 0x009e,
 	0x00de, 0x00ee, 0x0005, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804,
-	0x3599, 0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804, 0x3599,
+	0x35b9, 0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804, 0x35b9,
 	0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7884, 0x9005, 0x0904,
-	0x359c, 0x9096, 0x00ff, 0x0120, 0x9092, 0x0004, 0x1a04, 0x359c,
-	0x2010, 0x2918, 0x080c, 0x318f, 0x1120, 0x2009, 0x0003, 0x0804,
-	0x3599, 0x7007, 0x0003, 0x701f, 0x4a5e, 0x0005, 0xa830, 0x9086,
-	0x0100, 0x1904, 0x3567, 0x2009, 0x0004, 0x0804, 0x3599, 0x7984,
-	0x080c, 0xab49, 0x1120, 0x9182, 0x007f, 0x0a04, 0x359c, 0x9186,
-	0x00ff, 0x0904, 0x359c, 0x9182, 0x0800, 0x1a04, 0x359c, 0x2001,
-	0x9000, 0x080c, 0x568d, 0x1904, 0x3599, 0x0804, 0x3567, 0xa998,
-	0x080c, 0xab49, 0x1118, 0x9182, 0x007f, 0x0280, 0x9186, 0x00ff,
-	0x0168, 0x9182, 0x0800, 0x1250, 0x2001, 0x9000, 0x080c, 0x568d,
+	0x35bc, 0x9096, 0x00ff, 0x0120, 0x9092, 0x0004, 0x1a04, 0x35bc,
+	0x2010, 0x2918, 0x080c, 0x31af, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x35b9, 0x7007, 0x0003, 0x701f, 0x4a7e, 0x0005, 0xa830, 0x9086,
+	0x0100, 0x1904, 0x3587, 0x2009, 0x0004, 0x0804, 0x35b9, 0x7984,
+	0x080c, 0xab5a, 0x1120, 0x9182, 0x007f, 0x0a04, 0x35bc, 0x9186,
+	0x00ff, 0x0904, 0x35bc, 0x9182, 0x0800, 0x1a04, 0x35bc, 0x2001,
+	0x9000, 0x080c, 0x56ad, 0x1904, 0x35b9, 0x0804, 0x3587, 0xa998,
+	0x080c, 0xab5a, 0x1118, 0x9182, 0x007f, 0x0280, 0x9186, 0x00ff,
+	0x0168, 0x9182, 0x0800, 0x1250, 0x2001, 0x9000, 0x080c, 0x56ad,
 	0x11a8, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
 	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000,
 	0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x2009, 0x000a,
-	0x0c48, 0x080c, 0x103a, 0x0198, 0x9006, 0xa802, 0x7014, 0x9005,
+	0x0c48, 0x080c, 0x1047, 0x0198, 0x9006, 0xa802, 0x7014, 0x9005,
 	0x1120, 0x2900, 0x7016, 0x701a, 0x0040, 0x7018, 0xa802, 0x0086,
 	0x2040, 0x2900, 0xa006, 0x701a, 0x008e, 0x9085, 0x0001, 0x0005,
-	0x7984, 0x080c, 0x6620, 0x1130, 0x7e88, 0x9684, 0x3fff, 0x9082,
-	0x4000, 0x0208, 0x905e, 0x8bff, 0x0005, 0xa998, 0x080c, 0x6620,
+	0x7984, 0x080c, 0x6644, 0x1130, 0x7e88, 0x9684, 0x3fff, 0x9082,
+	0x4000, 0x0208, 0x905e, 0x8bff, 0x0005, 0xa998, 0x080c, 0x6644,
 	0x1130, 0xae9c, 0x9684, 0x3fff, 0x9082, 0x4000, 0x0208, 0x905e,
-	0x8bff, 0x0005, 0xae98, 0x0008, 0x7e84, 0x2608, 0x080c, 0x6620,
+	0x8bff, 0x0005, 0xae98, 0x0008, 0x7e84, 0x2608, 0x080c, 0x6644,
 	0x1108, 0x0008, 0x905e, 0x8bff, 0x0005, 0x0016, 0x7114, 0x81ff,
-	0x0128, 0x2148, 0xa904, 0x080c, 0x106c, 0x0cc8, 0x7116, 0x711a,
+	0x0128, 0x2148, 0xa904, 0x080c, 0x1079, 0x0cc8, 0x7116, 0x711a,
 	0x001e, 0x0005, 0x2031, 0x0001, 0x0010, 0x2031, 0x0000, 0x2061,
 	0x18b8, 0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e, 0xa392,
-	0xa496, 0xa59a, 0x080c, 0x112f, 0x7007, 0x0002, 0x701f, 0x3567,
+	0xa496, 0xa59a, 0x080c, 0x113c, 0x7007, 0x0002, 0x701f, 0x3587,
 	0x0005, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2079, 0x0000, 0x2001,
-	0x18b0, 0x2004, 0x9005, 0x1190, 0x0e04, 0x4b26, 0x7a36, 0x7833,
+	0x18b0, 0x2004, 0x9005, 0x1190, 0x0e04, 0x4b46, 0x7a36, 0x7833,
 	0x0012, 0x7a82, 0x7b86, 0x7c8a, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x190c, 0x11e1, 0x0804, 0x4b8c, 0x0016, 0x0086,
+	0x2004, 0xd084, 0x190c, 0x11ee, 0x0804, 0x4bac, 0x0016, 0x0086,
 	0x0096, 0x00c6, 0x00e6, 0x2071, 0x189e, 0x7044, 0x9005, 0x1540,
-	0x7148, 0x9182, 0x0010, 0x0288, 0x7038, 0x2060, 0x080c, 0x103a,
-	0x0904, 0x4b84, 0xa84b, 0x0000, 0x2900, 0x7046, 0x2001, 0x0002,
-	0x9080, 0x1e62, 0x2005, 0xa846, 0x0098, 0x7038, 0x90e0, 0x0004,
+	0x7148, 0x9182, 0x0010, 0x0288, 0x7038, 0x2060, 0x080c, 0x1047,
+	0x0904, 0x4ba4, 0xa84b, 0x0000, 0x2900, 0x7046, 0x2001, 0x0002,
+	0x9080, 0x1e7a, 0x2005, 0xa846, 0x0098, 0x7038, 0x90e0, 0x0004,
 	0x2001, 0x18ba, 0x9c82, 0x18fa, 0x0210, 0x2061, 0x18ba, 0x2c00,
 	0x703a, 0x7148, 0x81ff, 0x1108, 0x703e, 0x8108, 0x714a, 0x0460,
 	0x7148, 0x8108, 0x714a, 0x7044, 0x2040, 0xa144, 0x2105, 0x0016,
 	0x908a, 0x0036, 0x1a0c, 0x0d7d, 0x2060, 0x001e, 0x8108, 0x2105,
-	0x9005, 0xa146, 0x1520, 0x080c, 0x103a, 0x1130, 0x8109, 0xa946,
+	0x9005, 0xa146, 0x1520, 0x080c, 0x1047, 0x1130, 0x8109, 0xa946,
 	0x7148, 0x8109, 0x714a, 0x00d8, 0x9006, 0xa806, 0xa84a, 0xa046,
 	0x2800, 0xa802, 0x2900, 0xa006, 0x7046, 0x2001, 0x0002, 0x9080,
-	0x1e62, 0x2005, 0xa846, 0x0058, 0x2262, 0x6306, 0x640a, 0x00ee,
+	0x1e7a, 0x2005, 0xa846, 0x0058, 0x2262, 0x6306, 0x640a, 0x00ee,
 	0x00ce, 0x009e, 0x008e, 0x001e, 0x012e, 0x00fe, 0x0005, 0x2c00,
-	0x9082, 0x001b, 0x0002, 0x4bae, 0x4bae, 0x4bb0, 0x4bae, 0x4bae,
-	0x4bae, 0x4bb4, 0x4bae, 0x4bae, 0x4bae, 0x4bb8, 0x4bae, 0x4bae,
-	0x4bae, 0x4bbc, 0x4bae, 0x4bae, 0x4bae, 0x4bc0, 0x4bae, 0x4bae,
-	0x4bae, 0x4bc4, 0x4bae, 0x4bae, 0x4bae, 0x4bc9, 0x080c, 0x0d7d,
+	0x9082, 0x001b, 0x0002, 0x4bce, 0x4bce, 0x4bd0, 0x4bce, 0x4bce,
+	0x4bce, 0x4bd4, 0x4bce, 0x4bce, 0x4bce, 0x4bd8, 0x4bce, 0x4bce,
+	0x4bce, 0x4bdc, 0x4bce, 0x4bce, 0x4bce, 0x4be0, 0x4bce, 0x4bce,
+	0x4bce, 0x4be4, 0x4bce, 0x4bce, 0x4bce, 0x4be9, 0x080c, 0x0d7d,
 	0xa276, 0xa37a, 0xa47e, 0x0898, 0xa286, 0xa38a, 0xa48e, 0x0878,
 	0xa296, 0xa39a, 0xa49e, 0x0858, 0xa2a6, 0xa3aa, 0xa4ae, 0x0838,
 	0xa2b6, 0xa3ba, 0xa4be, 0x0818, 0xa2c6, 0xa3ca, 0xa4ce, 0x0804,
-	0x4b87, 0xa2d6, 0xa3da, 0xa4de, 0x0804, 0x4b87, 0x00e6, 0x2071,
-	0x189e, 0x7048, 0x9005, 0x0904, 0x4c60, 0x0126, 0x2091, 0x8000,
-	0x0e04, 0x4c5f, 0x00f6, 0x2079, 0x0000, 0x00c6, 0x0096, 0x0086,
+	0x4ba7, 0xa2d6, 0xa3da, 0xa4de, 0x0804, 0x4ba7, 0x00e6, 0x2071,
+	0x189e, 0x7048, 0x9005, 0x0904, 0x4c80, 0x0126, 0x2091, 0x8000,
+	0x0e04, 0x4c7f, 0x00f6, 0x2079, 0x0000, 0x00c6, 0x0096, 0x0086,
 	0x0076, 0x9006, 0x2038, 0x7040, 0x2048, 0x9005, 0x0500, 0xa948,
 	0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c, 0x0d7d, 0x2060, 0x001e,
-	0x8108, 0x2105, 0x9005, 0xa94a, 0x1904, 0x4c62, 0xa804, 0x9005,
+	0x8108, 0x2105, 0x9005, 0xa94a, 0x1904, 0x4c82, 0xa804, 0x9005,
 	0x090c, 0x0d7d, 0x7042, 0x2938, 0x2040, 0xa003, 0x0000, 0x2001,
-	0x0002, 0x9080, 0x1e62, 0x2005, 0xa04a, 0x0804, 0x4c62, 0x703c,
+	0x0002, 0x9080, 0x1e7a, 0x2005, 0xa04a, 0x0804, 0x4c82, 0x703c,
 	0x2060, 0x2c14, 0x6304, 0x6408, 0x650c, 0x2200, 0x7836, 0x7833,
 	0x0012, 0x7882, 0x2300, 0x7886, 0x2400, 0x788a, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11e1, 0x87ff, 0x0118,
-	0x2748, 0x080c, 0x106c, 0x7048, 0x8001, 0x704a, 0x9005, 0x1170,
-	0x7040, 0x2048, 0x9005, 0x0128, 0x080c, 0x106c, 0x9006, 0x7042,
+	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11ee, 0x87ff, 0x0118,
+	0x2748, 0x080c, 0x1079, 0x7048, 0x8001, 0x704a, 0x9005, 0x1170,
+	0x7040, 0x2048, 0x9005, 0x0128, 0x080c, 0x1079, 0x9006, 0x7042,
 	0x7046, 0x703b, 0x18ba, 0x703f, 0x18ba, 0x0420, 0x7040, 0x9005,
 	0x1508, 0x7238, 0x2c00, 0x9206, 0x0148, 0x9c80, 0x0004, 0x90fa,
 	0x18fa, 0x0210, 0x2001, 0x18ba, 0x703e, 0x00a0, 0x9006, 0x703e,
 	0x703a, 0x7044, 0x9005, 0x090c, 0x0d7d, 0x2048, 0xa800, 0x9005,
-	0x1de0, 0x2900, 0x7042, 0x2001, 0x0002, 0x9080, 0x1e62, 0x2005,
+	0x1de0, 0x2900, 0x7042, 0x2001, 0x0002, 0x9080, 0x1e7a, 0x2005,
 	0xa84a, 0x0000, 0x007e, 0x008e, 0x009e, 0x00ce, 0x00fe, 0x012e,
-	0x00ee, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002, 0x4c81, 0x4c81,
-	0x4c83, 0x4c81, 0x4c81, 0x4c81, 0x4c88, 0x4c81, 0x4c81, 0x4c81,
-	0x4c8d, 0x4c81, 0x4c81, 0x4c81, 0x4c92, 0x4c81, 0x4c81, 0x4c81,
-	0x4c97, 0x4c81, 0x4c81, 0x4c81, 0x4c9c, 0x4c81, 0x4c81, 0x4c81,
-	0x4ca1, 0x080c, 0x0d7d, 0xaa74, 0xab78, 0xac7c, 0x0804, 0x4c0d,
-	0xaa84, 0xab88, 0xac8c, 0x0804, 0x4c0d, 0xaa94, 0xab98, 0xac9c,
-	0x0804, 0x4c0d, 0xaaa4, 0xaba8, 0xacac, 0x0804, 0x4c0d, 0xaab4,
-	0xabb8, 0xacbc, 0x0804, 0x4c0d, 0xaac4, 0xabc8, 0xaccc, 0x0804,
-	0x4c0d, 0xaad4, 0xabd8, 0xacdc, 0x0804, 0x4c0d, 0x0016, 0x0026,
-	0x0036, 0x00b6, 0x00c6, 0x2009, 0x007e, 0x080c, 0x6620, 0x2019,
+	0x00ee, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002, 0x4ca1, 0x4ca1,
+	0x4ca3, 0x4ca1, 0x4ca1, 0x4ca1, 0x4ca8, 0x4ca1, 0x4ca1, 0x4ca1,
+	0x4cad, 0x4ca1, 0x4ca1, 0x4ca1, 0x4cb2, 0x4ca1, 0x4ca1, 0x4ca1,
+	0x4cb7, 0x4ca1, 0x4ca1, 0x4ca1, 0x4cbc, 0x4ca1, 0x4ca1, 0x4ca1,
+	0x4cc1, 0x080c, 0x0d7d, 0xaa74, 0xab78, 0xac7c, 0x0804, 0x4c2d,
+	0xaa84, 0xab88, 0xac8c, 0x0804, 0x4c2d, 0xaa94, 0xab98, 0xac9c,
+	0x0804, 0x4c2d, 0xaaa4, 0xaba8, 0xacac, 0x0804, 0x4c2d, 0xaab4,
+	0xabb8, 0xacbc, 0x0804, 0x4c2d, 0xaac4, 0xabc8, 0xaccc, 0x0804,
+	0x4c2d, 0xaad4, 0xabd8, 0xacdc, 0x0804, 0x4c2d, 0x0016, 0x0026,
+	0x0036, 0x00b6, 0x00c6, 0x2009, 0x007e, 0x080c, 0x6644, 0x2019,
 	0x0001, 0xb85c, 0xd0ac, 0x0110, 0x2019, 0x0000, 0x2011, 0x801b,
-	0x080c, 0x4b09, 0x00ce, 0x00be, 0x003e, 0x002e, 0x001e, 0x0005,
-	0x0026, 0x080c, 0x56d5, 0xd0c4, 0x0120, 0x2011, 0x8014, 0x080c,
-	0x4b09, 0x002e, 0x0005, 0x81ff, 0x1904, 0x3599, 0x0126, 0x2091,
-	0x8000, 0x6030, 0xc08d, 0xc085, 0xc0ac, 0x6032, 0x080c, 0x74c8,
-	0x1158, 0x080c, 0x77cc, 0x080c, 0x6024, 0x9085, 0x0001, 0x080c,
-	0x750f, 0x080c, 0x73f9, 0x0010, 0x080c, 0x5edf, 0x012e, 0x0804,
-	0x3567, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3599, 0x080c,
-	0x56e9, 0x0120, 0x2009, 0x0007, 0x0804, 0x3599, 0x080c, 0x6a62,
-	0x0120, 0x2009, 0x0008, 0x0804, 0x3599, 0x7984, 0x080c, 0x65bf,
-	0x1904, 0x359c, 0x2b00, 0x7026, 0x080c, 0x6a6a, 0x7888, 0x1170,
-	0x9084, 0x0005, 0x1158, 0x900e, 0x080c, 0x6913, 0x1108, 0xc185,
-	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3567, 0x080c, 0x4aa9,
-	0x0904, 0x3599, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
-	0x080c, 0xca69, 0x0904, 0x3599, 0x7888, 0xd094, 0x0118, 0xb8d4,
-	0xc08d, 0xb8d6, 0x7007, 0x0003, 0x701f, 0x4d7b, 0x0005, 0x2061,
-	0x1800, 0x080c, 0x56e9, 0x2009, 0x0007, 0x1578, 0x080c, 0x6a62,
-	0x0118, 0x2009, 0x0008, 0x0448, 0x080c, 0x3357, 0x0120, 0xa998,
-	0x080c, 0x65bf, 0x1530, 0x080c, 0x4ada, 0x0518, 0x080c, 0x6a6a,
-	0xa89c, 0x1168, 0x9084, 0x0005, 0x1150, 0x900e, 0x080c, 0x6913,
+	0x080c, 0x4b29, 0x00ce, 0x00be, 0x003e, 0x002e, 0x001e, 0x0005,
+	0x0026, 0x080c, 0x56f5, 0xd0c4, 0x0120, 0x2011, 0x8014, 0x080c,
+	0x4b29, 0x002e, 0x0005, 0x81ff, 0x1904, 0x35b9, 0x0126, 0x2091,
+	0x8000, 0x6030, 0xc08d, 0xc085, 0xc0ac, 0x6032, 0x080c, 0x74ec,
+	0x1158, 0x080c, 0x77ef, 0x080c, 0x6044, 0x9085, 0x0001, 0x080c,
+	0x7533, 0x080c, 0x741d, 0x0010, 0x080c, 0x5eff, 0x012e, 0x0804,
+	0x3587, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x35b9, 0x080c,
+	0x5709, 0x0120, 0x2009, 0x0007, 0x0804, 0x35b9, 0x080c, 0x6a86,
+	0x0120, 0x2009, 0x0008, 0x0804, 0x35b9, 0x7984, 0x080c, 0x65e3,
+	0x1904, 0x35bc, 0x2b00, 0x7026, 0x080c, 0x6a8e, 0x7888, 0x1170,
+	0x9084, 0x0005, 0x1158, 0x900e, 0x080c, 0x6937, 0x1108, 0xc185,
+	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3587, 0x080c, 0x4ac9,
+	0x0904, 0x35b9, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
+	0x080c, 0xca9c, 0x0904, 0x35b9, 0x7888, 0xd094, 0x0118, 0xb8d4,
+	0xc08d, 0xb8d6, 0x7007, 0x0003, 0x701f, 0x4d9b, 0x0005, 0x2061,
+	0x1800, 0x080c, 0x5709, 0x2009, 0x0007, 0x1578, 0x080c, 0x6a86,
+	0x0118, 0x2009, 0x0008, 0x0448, 0x080c, 0x3377, 0x0120, 0xa998,
+	0x080c, 0x65e3, 0x1530, 0x080c, 0x4afa, 0x0518, 0x080c, 0x6a8e,
+	0xa89c, 0x1168, 0x9084, 0x0005, 0x1150, 0x900e, 0x080c, 0x6937,
 	0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x00d0, 0xa868,
-	0xc0fc, 0xa86a, 0x080c, 0xca69, 0x11e0, 0xa89c, 0xd094, 0x0118,
+	0xc0fc, 0xa86a, 0x080c, 0xca9c, 0x11e0, 0xa89c, 0xd094, 0x0118,
 	0xb8d4, 0xc08d, 0xb8d6, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a,
 	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
 	0x0005, 0xa897, 0x4000, 0xa99a, 0x9006, 0x918d, 0x0001, 0x2008,
 	0x0005, 0x9006, 0x0005, 0xa830, 0x9086, 0x0100, 0x7024, 0x2058,
-	0x1110, 0x0804, 0x5632, 0x900e, 0x080c, 0x6913, 0x1108, 0xc185,
-	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3567, 0x080c, 0x56e9,
-	0x0120, 0x2009, 0x0007, 0x0804, 0x3599, 0x7f84, 0x7a8c, 0x7b88,
-	0x7c9c, 0x7d98, 0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804,
-	0x3599, 0x900e, 0x2130, 0x7126, 0x7132, 0xa860, 0x20e8, 0x7036,
-	0xa85c, 0x9080, 0x0005, 0x702a, 0x20a0, 0x080c, 0x6620, 0x1904,
-	0x4e1d, 0x080c, 0x6a6a, 0x0138, 0x080c, 0x6a72, 0x0120, 0x080c,
-	0x6a0a, 0x1904, 0x4e1d, 0xd794, 0x1110, 0xd784, 0x01a8, 0xb8c4,
+	0x1110, 0x0804, 0x5652, 0x900e, 0x080c, 0x6937, 0x1108, 0xc185,
+	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3587, 0x080c, 0x5709,
+	0x0120, 0x2009, 0x0007, 0x0804, 0x35b9, 0x7f84, 0x7a8c, 0x7b88,
+	0x7c9c, 0x7d98, 0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804,
+	0x35b9, 0x900e, 0x2130, 0x7126, 0x7132, 0xa860, 0x20e8, 0x7036,
+	0xa85c, 0x9080, 0x0005, 0x702a, 0x20a0, 0x080c, 0x6644, 0x1904,
+	0x4e3d, 0x080c, 0x6a8e, 0x0138, 0x080c, 0x6a96, 0x0120, 0x080c,
+	0x6a2e, 0x1904, 0x4e3d, 0xd794, 0x1110, 0xd784, 0x01a8, 0xb8c4,
 	0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098, 0x3400, 0xd794, 0x0160,
 	0x20a9, 0x0008, 0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x20a9,
-	0x0002, 0x080c, 0x48a8, 0x0048, 0x20a9, 0x0004, 0x4003, 0x2098,
-	0x20a0, 0x3d00, 0x20e0, 0x080c, 0x48a8, 0x9186, 0x007e, 0x0170,
-	0x9186, 0x0080, 0x0158, 0x080c, 0x6a6a, 0x90c2, 0x0006, 0x1210,
-	0xc1fd, 0x0020, 0x080c, 0x6913, 0x1108, 0xc1fd, 0x4104, 0xc1fc,
+	0x0002, 0x080c, 0x48c8, 0x0048, 0x20a9, 0x0004, 0x4003, 0x2098,
+	0x20a0, 0x3d00, 0x20e0, 0x080c, 0x48c8, 0x9186, 0x007e, 0x0170,
+	0x9186, 0x0080, 0x0158, 0x080c, 0x6a8e, 0x90c2, 0x0006, 0x1210,
+	0xc1fd, 0x0020, 0x080c, 0x6937, 0x1108, 0xc1fd, 0x4104, 0xc1fc,
 	0xd794, 0x0528, 0xb8c4, 0x20e0, 0xb8c8, 0x2060, 0x9c80, 0x0000,
 	0x2098, 0x20a9, 0x0002, 0x4003, 0x9c80, 0x0003, 0x2098, 0x20a9,
 	0x0001, 0x4005, 0x9c80, 0x0004, 0x2098, 0x3400, 0x20a9, 0x0002,
-	0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x080c, 0x489b, 0x9c80,
+	0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x080c, 0x48bb, 0x9c80,
 	0x0026, 0x2098, 0xb8c4, 0x20e0, 0x20a9, 0x0002, 0x4003, 0xd794,
-	0x0110, 0x96b0, 0x000b, 0x96b0, 0x0005, 0x8108, 0x080c, 0xab49,
+	0x0110, 0x96b0, 0x000b, 0x96b0, 0x0005, 0x8108, 0x080c, 0xab5a,
 	0x0118, 0x9186, 0x0800, 0x0040, 0xd78c, 0x0120, 0x9186, 0x0800,
 	0x0170, 0x0018, 0x9186, 0x007e, 0x0150, 0xd794, 0x0118, 0x9686,
-	0x0020, 0x0010, 0x9686, 0x0028, 0x0150, 0x0804, 0x4dad, 0x86ff,
-	0x1120, 0x7124, 0x810b, 0x0804, 0x3567, 0x7033, 0x0001, 0x7122,
+	0x0020, 0x0010, 0x9686, 0x0028, 0x0150, 0x0804, 0x4dcd, 0x86ff,
+	0x1120, 0x7124, 0x810b, 0x0804, 0x3587, 0x7033, 0x0001, 0x7122,
 	0x7024, 0x9600, 0x7026, 0x772e, 0x2061, 0x18b8, 0x2c44, 0xa06b,
 	0x0000, 0xa67a, 0x7034, 0xa072, 0x7028, 0xa076, 0xa28e, 0xa392,
-	0xa496, 0xa59a, 0x080c, 0x112f, 0x7007, 0x0002, 0x701f, 0x4e59,
+	0xa496, 0xa59a, 0x080c, 0x113c, 0x7007, 0x0002, 0x701f, 0x4e79,
 	0x0005, 0x7030, 0x9005, 0x1180, 0x7120, 0x7028, 0x20a0, 0x772c,
 	0x9036, 0x7034, 0x20e8, 0x2061, 0x18b8, 0x2c44, 0xa28c, 0xa390,
-	0xa494, 0xa598, 0x0804, 0x4dad, 0x7124, 0x810b, 0x0804, 0x3567,
+	0xa494, 0xa598, 0x0804, 0x4dcd, 0x7124, 0x810b, 0x0804, 0x3587,
 	0x2029, 0x007e, 0x7984, 0x7a88, 0x7b8c, 0x7c98, 0x9184, 0xff00,
-	0x8007, 0x90e2, 0x0020, 0x0a04, 0x359c, 0x9502, 0x0a04, 0x359c,
-	0x9184, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x359c, 0x9502, 0x0a04,
-	0x359c, 0x9284, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x359c,
-	0x9502, 0x0a04, 0x359c, 0x9284, 0x00ff, 0x90e2, 0x0020, 0x0a04,
-	0x359c, 0x9502, 0x0a04, 0x359c, 0x9384, 0xff00, 0x8007, 0x90e2,
-	0x0020, 0x0a04, 0x359c, 0x9502, 0x0a04, 0x359c, 0x9384, 0x00ff,
-	0x90e2, 0x0020, 0x0a04, 0x359c, 0x9502, 0x0a04, 0x359c, 0x9484,
-	0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x359c, 0x9502, 0x0a04,
-	0x359c, 0x9484, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x359c, 0x9502,
-	0x0a04, 0x359c, 0x2061, 0x1988, 0x6102, 0x6206, 0x630a, 0x640e,
-	0x0804, 0x3567, 0x080c, 0x4aa9, 0x0904, 0x3599, 0x2009, 0x0016,
+	0x8007, 0x90e2, 0x0020, 0x0a04, 0x35bc, 0x9502, 0x0a04, 0x35bc,
+	0x9184, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x35bc, 0x9502, 0x0a04,
+	0x35bc, 0x9284, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x35bc,
+	0x9502, 0x0a04, 0x35bc, 0x9284, 0x00ff, 0x90e2, 0x0020, 0x0a04,
+	0x35bc, 0x9502, 0x0a04, 0x35bc, 0x9384, 0xff00, 0x8007, 0x90e2,
+	0x0020, 0x0a04, 0x35bc, 0x9502, 0x0a04, 0x35bc, 0x9384, 0x00ff,
+	0x90e2, 0x0020, 0x0a04, 0x35bc, 0x9502, 0x0a04, 0x35bc, 0x9484,
+	0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x35bc, 0x9502, 0x0a04,
+	0x35bc, 0x9484, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x35bc, 0x9502,
+	0x0a04, 0x35bc, 0x2061, 0x1988, 0x6102, 0x6206, 0x630a, 0x640e,
+	0x0804, 0x3587, 0x080c, 0x4ac9, 0x0904, 0x35b9, 0x2009, 0x0016,
 	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0xaf60,
-	0x080c, 0x4af2, 0x701f, 0x4edd, 0x0005, 0x2001, 0x0138, 0x2003,
+	0x080c, 0x4b12, 0x701f, 0x4efd, 0x0005, 0x2001, 0x0138, 0x2003,
 	0x0000, 0x00e6, 0x2071, 0x0300, 0x701c, 0xd0a4, 0x1de8, 0x00ee,
 	0x20a9, 0x0016, 0x896e, 0x8d6e, 0x8d6f, 0x9d84, 0xffc0, 0x9080,
 	0x0019, 0x2098, 0x9d84, 0x003f, 0x20e0, 0x2069, 0x1877, 0x20e9,
-	0x0001, 0x2da0, 0x4003, 0x6800, 0x9005, 0x0904, 0x4f5e, 0x6804,
-	0x2008, 0x918c, 0xfff8, 0x1904, 0x4f5e, 0x680c, 0x9005, 0x0904,
-	0x4f5e, 0x9082, 0xff01, 0x1a04, 0x4f5e, 0x6810, 0x9082, 0x005c,
-	0x0a04, 0x4f5e, 0x6824, 0x2008, 0x9082, 0x0008, 0x0a04, 0x4f5e,
-	0x9182, 0x0400, 0x1a04, 0x4f5e, 0x0056, 0x2029, 0x0000, 0x080c,
-	0x8cec, 0x005e, 0x6944, 0x6820, 0x9102, 0x06c0, 0x6820, 0x9082,
+	0x0001, 0x2da0, 0x4003, 0x6800, 0x9005, 0x0904, 0x4f7e, 0x6804,
+	0x2008, 0x918c, 0xfff8, 0x1904, 0x4f7e, 0x680c, 0x9005, 0x0904,
+	0x4f7e, 0x9082, 0xff01, 0x1a04, 0x4f7e, 0x6810, 0x9082, 0x005c,
+	0x0a04, 0x4f7e, 0x6824, 0x2008, 0x9082, 0x0008, 0x0a04, 0x4f7e,
+	0x9182, 0x0400, 0x1a04, 0x4f7e, 0x0056, 0x2029, 0x0000, 0x080c,
+	0x8d23, 0x005e, 0x6944, 0x6820, 0x9102, 0x06c0, 0x6820, 0x9082,
 	0x0019, 0x16a0, 0x6828, 0x6944, 0x810c, 0x9102, 0x0678, 0x6840,
-	0x9082, 0x000f, 0x1658, 0x080c, 0x1053, 0x2900, 0x0904, 0x4f78,
+	0x9082, 0x000f, 0x1658, 0x080c, 0x1060, 0x2900, 0x0904, 0x4f98,
 	0x684e, 0x00e6, 0x2071, 0x1930, 0x00b6, 0x2059, 0x0000, 0x080c,
-	0x8ba8, 0x00be, 0x00ee, 0x0558, 0x080c, 0x8902, 0x080c, 0x8948,
+	0x8bdf, 0x00be, 0x00ee, 0x0558, 0x080c, 0x8936, 0x080c, 0x897c,
 	0x11e0, 0x6857, 0x0000, 0x00c6, 0x2061, 0x0100, 0x6104, 0x918d,
 	0x2000, 0x6106, 0x6b10, 0x2061, 0x1a6a, 0x630a, 0x00ce, 0x080c,
-	0x272c, 0x2001, 0x0138, 0x2102, 0x0804, 0x3567, 0x080c, 0x272c,
-	0x2001, 0x0138, 0x2102, 0x0804, 0x359c, 0x00e6, 0x2071, 0x1930,
-	0x080c, 0x8d7d, 0x080c, 0x8d8c, 0x080c, 0x8b97, 0x00ee, 0x2001,
-	0x188a, 0x204c, 0x080c, 0x106c, 0x2001, 0x188a, 0x2003, 0x0000,
-	0x080c, 0x272c, 0x2001, 0x0138, 0x2102, 0x0804, 0x3599, 0x2001,
-	0x1924, 0x200c, 0x918e, 0x0000, 0x0904, 0x4fd7, 0x080c, 0x8b92,
-	0x0904, 0x4fd7, 0x2001, 0x0101, 0x200c, 0x918c, 0xdfff, 0x2102,
+	0x2748, 0x2001, 0x0138, 0x2102, 0x0804, 0x3587, 0x080c, 0x2748,
+	0x2001, 0x0138, 0x2102, 0x0804, 0x35bc, 0x00e6, 0x2071, 0x1930,
+	0x080c, 0x8db4, 0x080c, 0x8dc3, 0x080c, 0x8bce, 0x00ee, 0x2001,
+	0x188a, 0x204c, 0x080c, 0x1079, 0x2001, 0x188a, 0x2003, 0x0000,
+	0x080c, 0x2748, 0x2001, 0x0138, 0x2102, 0x0804, 0x35b9, 0x2001,
+	0x1924, 0x200c, 0x918e, 0x0000, 0x0904, 0x4ff7, 0x080c, 0x8bc9,
+	0x0904, 0x4ff7, 0x2001, 0x0101, 0x200c, 0x918c, 0xdfff, 0x2102,
 	0x2001, 0x0138, 0x2003, 0x0000, 0x00e6, 0x2071, 0x0300, 0x701c,
-	0xd0a4, 0x1de8, 0x00ee, 0x080c, 0x8b97, 0x2001, 0x0035, 0x080c,
-	0x1686, 0x00c6, 0x2061, 0x193c, 0x6004, 0x6100, 0x9106, 0x1de0,
-	0x00ce, 0x080c, 0x272c, 0x2001, 0x0138, 0x2102, 0x00e6, 0x00f6,
-	0x2071, 0x1923, 0x080c, 0x8ad3, 0x0120, 0x2f00, 0x080c, 0x8b5d,
+	0xd0a4, 0x1de8, 0x00ee, 0x080c, 0x8bce, 0x2001, 0x0035, 0x080c,
+	0x1693, 0x00c6, 0x2061, 0x193c, 0x6004, 0x6100, 0x9106, 0x1de0,
+	0x00ce, 0x080c, 0x2748, 0x2001, 0x0138, 0x2102, 0x00e6, 0x00f6,
+	0x2071, 0x1923, 0x080c, 0x8b0a, 0x0120, 0x2f00, 0x080c, 0x8b94,
 	0x0cc8, 0x00fe, 0x00ee, 0x0126, 0x2091, 0x8000, 0x2001, 0x188a,
-	0x200c, 0x81ff, 0x0138, 0x2148, 0x080c, 0x106c, 0x2001, 0x188a,
+	0x200c, 0x81ff, 0x0138, 0x2148, 0x080c, 0x1079, 0x2001, 0x188a,
 	0x2003, 0x0000, 0x2001, 0x183d, 0x2003, 0x0020, 0x00e6, 0x2071,
-	0x1930, 0x080c, 0x8d7d, 0x080c, 0x8d8c, 0x00ee, 0x012e, 0x0804,
-	0x3567, 0x0006, 0x080c, 0x56d5, 0xd0cc, 0x000e, 0x0005, 0x0006,
-	0x080c, 0x56d9, 0xd0bc, 0x000e, 0x0005, 0x6174, 0x7a84, 0x6300,
-	0x82ff, 0x1118, 0x7986, 0x0804, 0x3567, 0x83ff, 0x1904, 0x359c,
-	0x2001, 0xfff0, 0x9200, 0x1a04, 0x359c, 0x2019, 0xffff, 0x6078,
-	0x9302, 0x9200, 0x0a04, 0x359c, 0x7986, 0x6276, 0x0804, 0x3567,
-	0x080c, 0x56e9, 0x1904, 0x3599, 0x7c88, 0x7d84, 0x7e98, 0x7f8c,
-	0x080c, 0x4aa9, 0x0904, 0x3599, 0x900e, 0x901e, 0x7326, 0x7332,
+	0x1930, 0x080c, 0x8db4, 0x080c, 0x8dc3, 0x00ee, 0x012e, 0x0804,
+	0x3587, 0x0006, 0x080c, 0x56f5, 0xd0cc, 0x000e, 0x0005, 0x0006,
+	0x080c, 0x56f9, 0xd0bc, 0x000e, 0x0005, 0x6174, 0x7a84, 0x6300,
+	0x82ff, 0x1118, 0x7986, 0x0804, 0x3587, 0x83ff, 0x1904, 0x35bc,
+	0x2001, 0xfff0, 0x9200, 0x1a04, 0x35bc, 0x2019, 0xffff, 0x6078,
+	0x9302, 0x9200, 0x0a04, 0x35bc, 0x7986, 0x6276, 0x0804, 0x3587,
+	0x080c, 0x5709, 0x1904, 0x35b9, 0x7c88, 0x7d84, 0x7e98, 0x7f8c,
+	0x080c, 0x4ac9, 0x0904, 0x35b9, 0x900e, 0x901e, 0x7326, 0x7332,
 	0xa860, 0x20e8, 0x7036, 0xa85c, 0x9080, 0x0003, 0x702a, 0x20a0,
-	0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x6a6a, 0x0118,
-	0x080c, 0x6a72, 0x1148, 0x20a9, 0x0001, 0xb814, 0x4004, 0xb810,
+	0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x6a8e, 0x0118,
+	0x080c, 0x6a96, 0x1148, 0x20a9, 0x0001, 0xb814, 0x4004, 0xb810,
 	0x4004, 0x4104, 0x9398, 0x0003, 0x8108, 0x9182, 0x0800, 0x0120,
 	0x9386, 0x003c, 0x0170, 0x0c20, 0x83ff, 0x1148, 0x7224, 0x900e,
-	0x2001, 0x0003, 0x080c, 0x9148, 0x2208, 0x0804, 0x3567, 0x7033,
+	0x2001, 0x0003, 0x080c, 0x9181, 0x2208, 0x0804, 0x3587, 0x7033,
 	0x0001, 0x7122, 0x7024, 0x9300, 0x7026, 0x2061, 0x18b8, 0x2c44,
 	0xa06b, 0x0000, 0xa37a, 0x7028, 0xa076, 0x7034, 0xa072, 0xa48e,
-	0xa592, 0xa696, 0xa79a, 0x080c, 0x112f, 0x7007, 0x0002, 0x701f,
-	0x505a, 0x0005, 0x7030, 0x9005, 0x1178, 0x7120, 0x7028, 0x20a0,
+	0xa592, 0xa696, 0xa79a, 0x080c, 0x113c, 0x7007, 0x0002, 0x701f,
+	0x507a, 0x0005, 0x7030, 0x9005, 0x1178, 0x7120, 0x7028, 0x20a0,
 	0x901e, 0x7034, 0x20e8, 0x2061, 0x18b8, 0x2c44, 0xa48c, 0xa590,
-	0xa694, 0xa798, 0x0804, 0x5018, 0x7224, 0x900e, 0x2001, 0x0003,
-	0x080c, 0x9148, 0x2208, 0x0804, 0x3567, 0x00f6, 0x00e6, 0x080c,
-	0x56e9, 0x2009, 0x0007, 0x1904, 0x50ed, 0x2071, 0x189e, 0x745c,
-	0x84ff, 0x2009, 0x000e, 0x1904, 0x50ed, 0xac9c, 0xad98, 0xaea4,
-	0xafa0, 0x0096, 0x080c, 0x1053, 0x2009, 0x0002, 0x0904, 0x50ed,
+	0xa694, 0xa798, 0x0804, 0x5038, 0x7224, 0x900e, 0x2001, 0x0003,
+	0x080c, 0x9181, 0x2208, 0x0804, 0x3587, 0x00f6, 0x00e6, 0x080c,
+	0x5709, 0x2009, 0x0007, 0x1904, 0x510d, 0x2071, 0x189e, 0x745c,
+	0x84ff, 0x2009, 0x000e, 0x1904, 0x510d, 0xac9c, 0xad98, 0xaea4,
+	0xafa0, 0x0096, 0x080c, 0x1060, 0x2009, 0x0002, 0x0904, 0x510d,
 	0x2900, 0x705e, 0x900e, 0x901e, 0x7356, 0x7362, 0xa860, 0x7066,
 	0xa85c, 0x9080, 0x0003, 0x705a, 0x20a0, 0x91d8, 0x1000, 0x2b5c,
-	0x8bff, 0x0178, 0x080c, 0x6a6a, 0x0118, 0x080c, 0x6a72, 0x1148,
+	0x8bff, 0x0178, 0x080c, 0x6a8e, 0x0118, 0x080c, 0x6a96, 0x1148,
 	0xb814, 0x20a9, 0x0001, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398,
 	0x0003, 0x8108, 0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x01e8,
 	0x0c20, 0x83ff, 0x11c0, 0x7254, 0x900e, 0x2001, 0x0003, 0x080c,
-	0x9148, 0x2208, 0x009e, 0xa897, 0x4000, 0xa99a, 0x715c, 0x81ff,
-	0x090c, 0x0d7d, 0x2148, 0x080c, 0x106c, 0x9006, 0x705e, 0x918d,
+	0x9181, 0x2208, 0x009e, 0xa897, 0x4000, 0xa99a, 0x715c, 0x81ff,
+	0x090c, 0x0d7d, 0x2148, 0x080c, 0x1079, 0x9006, 0x705e, 0x918d,
 	0x0001, 0x2008, 0x0418, 0x7063, 0x0001, 0x7152, 0x7054, 0x9300,
 	0x7056, 0x2061, 0x18b9, 0x2c44, 0xa37a, 0x7058, 0xa076, 0x7064,
-	0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a, 0xa09f, 0x50f9, 0x000e,
-	0xa0a2, 0x080c, 0x112f, 0x9006, 0x0048, 0x009e, 0xa897, 0x4005,
+	0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a, 0xa09f, 0x5119, 0x000e,
+	0xa0a2, 0x080c, 0x113c, 0x9006, 0x0048, 0x009e, 0xa897, 0x4005,
 	0xa99a, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x00ee, 0x00fe,
 	0x0005, 0x00f6, 0xa0a0, 0x904d, 0x090c, 0x0d7d, 0x00e6, 0x2071,
 	0x189e, 0xa06c, 0x908e, 0x0100, 0x0138, 0xa87b, 0x0030, 0xa883,
 	0x0000, 0xa897, 0x4002, 0x00d8, 0x7060, 0x9005, 0x1158, 0x7150,
 	0x7058, 0x20a0, 0x901e, 0x7064, 0x20e8, 0xa48c, 0xa590, 0xa694,
 	0xa798, 0x0428, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000,
-	0x7254, 0x900e, 0x2001, 0x0003, 0x080c, 0x9148, 0xaa9a, 0x715c,
-	0x81ff, 0x090c, 0x0d7d, 0x2148, 0x080c, 0x106c, 0x705f, 0x0000,
-	0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000, 0x080c, 0x6d7b, 0x012e,
+	0x7254, 0x900e, 0x2001, 0x0003, 0x080c, 0x9181, 0xaa9a, 0x715c,
+	0x81ff, 0x090c, 0x0d7d, 0x2148, 0x080c, 0x1079, 0x705f, 0x0000,
+	0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e,
 	0xa09f, 0x0000, 0xa0a3, 0x0000, 0x00ee, 0x00fe, 0x0005, 0x91d8,
-	0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x6a6a, 0x0118, 0x080c,
-	0x6a72, 0x1148, 0xb814, 0x20a9, 0x0001, 0x4004, 0xb810, 0x4004,
+	0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x6a8e, 0x0118, 0x080c,
+	0x6a96, 0x1148, 0xb814, 0x20a9, 0x0001, 0x4004, 0xb810, 0x4004,
 	0x4104, 0x9398, 0x0003, 0x8108, 0x9182, 0x0800, 0x0120, 0x9386,
 	0x003c, 0x0518, 0x0c20, 0x83ff, 0x11f0, 0x7154, 0x810c, 0xa99a,
 	0xa897, 0x4000, 0x715c, 0x81ff, 0x090c, 0x0d7d, 0x2148, 0x080c,
-	0x106c, 0x9006, 0x705e, 0x918d, 0x0001, 0x2008, 0xa0a0, 0x2048,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6d7b, 0x012e, 0xa09f, 0x0000,
+	0x1079, 0x9006, 0x705e, 0x918d, 0x0001, 0x2008, 0xa0a0, 0x2048,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e, 0xa09f, 0x0000,
 	0xa0a3, 0x0000, 0x0070, 0x7063, 0x0001, 0x7152, 0x7054, 0x9300,
-	0x7056, 0xa37a, 0xa48e, 0xa592, 0xa696, 0xa79a, 0x080c, 0x112f,
+	0x7056, 0xa37a, 0xa48e, 0xa592, 0xa696, 0xa79a, 0x080c, 0x113c,
 	0x9006, 0x00ee, 0x0005, 0x0096, 0xa88c, 0x90be, 0x7000, 0x0148,
 	0x90be, 0x7100, 0x0130, 0x90be, 0x7200, 0x0118, 0x009e, 0x0804,
-	0x359c, 0xa884, 0xa988, 0x080c, 0x2614, 0x1518, 0x080c, 0x65bf,
-	0x1500, 0x7126, 0xbe12, 0xbd16, 0xae7c, 0x080c, 0x4aa9, 0x01c8,
-	0x080c, 0x4aa9, 0x01b0, 0x009e, 0xa867, 0x0000, 0xa868, 0xc0fd,
-	0xa86a, 0xa823, 0x0000, 0xa804, 0x2048, 0x080c, 0xc9e2, 0x1120,
-	0x2009, 0x0003, 0x0804, 0x3599, 0x7007, 0x0003, 0x701f, 0x51c6,
-	0x0005, 0x009e, 0x2009, 0x0002, 0x0804, 0x3599, 0x7124, 0x080c,
-	0x32f8, 0xa820, 0x9086, 0x8001, 0x1120, 0x2009, 0x0004, 0x0804,
-	0x3599, 0x2900, 0x7022, 0xa804, 0x0096, 0x2048, 0x8906, 0x8006,
+	0x35bc, 0xa884, 0xa988, 0x080c, 0x2630, 0x1518, 0x080c, 0x65e3,
+	0x1500, 0x7126, 0xbe12, 0xbd16, 0xae7c, 0x080c, 0x4ac9, 0x01c8,
+	0x080c, 0x4ac9, 0x01b0, 0x009e, 0xa867, 0x0000, 0xa868, 0xc0fd,
+	0xa86a, 0xa823, 0x0000, 0xa804, 0x2048, 0x080c, 0xca15, 0x1120,
+	0x2009, 0x0003, 0x0804, 0x35b9, 0x7007, 0x0003, 0x701f, 0x51e6,
+	0x0005, 0x009e, 0x2009, 0x0002, 0x0804, 0x35b9, 0x7124, 0x080c,
+	0x3318, 0xa820, 0x9086, 0x8001, 0x1120, 0x2009, 0x0004, 0x0804,
+	0x35b9, 0x2900, 0x7022, 0xa804, 0x0096, 0x2048, 0x8906, 0x8006,
 	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x009e, 0x9080, 0x0002,
 	0x0076, 0x0006, 0x2098, 0x20a0, 0x27e0, 0x27e8, 0x20a9, 0x002a,
-	0x080c, 0x0fb7, 0xaa6c, 0xab70, 0xac74, 0xad78, 0x2061, 0x18b8,
+	0x080c, 0x0fc4, 0xaa6c, 0xab70, 0xac74, 0xad78, 0x2061, 0x18b8,
 	0x2c44, 0xa06b, 0x0000, 0xae64, 0xaf8c, 0x97c6, 0x7000, 0x0118,
 	0x97c6, 0x7100, 0x1148, 0x96c2, 0x0004, 0x0600, 0x2009, 0x0004,
-	0x000e, 0x007e, 0x0804, 0x4af5, 0x97c6, 0x7200, 0x11b8, 0x96c2,
+	0x000e, 0x007e, 0x0804, 0x4b15, 0x97c6, 0x7200, 0x11b8, 0x96c2,
 	0x0054, 0x02a0, 0x000e, 0x007e, 0x2061, 0x18b8, 0x2c44, 0xa076,
 	0xa772, 0xa07b, 0x002a, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c,
-	0x112f, 0x7007, 0x0002, 0x701f, 0x5222, 0x0005, 0x000e, 0x007e,
-	0x0804, 0x359c, 0x7020, 0x2048, 0xa804, 0x2048, 0xa804, 0x2048,
+	0x113c, 0x7007, 0x0002, 0x701f, 0x5242, 0x0005, 0x000e, 0x007e,
+	0x0804, 0x35bc, 0x7020, 0x2048, 0xa804, 0x2048, 0xa804, 0x2048,
 	0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
 	0x0002, 0x2098, 0x20a0, 0x27e0, 0x27e8, 0x20a9, 0x002a, 0x080c,
-	0x0fb7, 0x2100, 0x2238, 0x2061, 0x18b8, 0x2c44, 0xa28c, 0xa390,
-	0xa494, 0xa598, 0x2009, 0x002a, 0x0804, 0x4af5, 0x81ff, 0x1904,
-	0x3599, 0x798c, 0x2001, 0x197d, 0x918c, 0x8000, 0x2102, 0x080c,
-	0x4ac0, 0x0904, 0x359c, 0x080c, 0x6a6a, 0x0120, 0x080c, 0x6a72,
-	0x1904, 0x359c, 0x080c, 0x66e7, 0x0904, 0x3599, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x6880, 0x012e, 0x0904, 0x3599, 0x2001, 0x197d,
-	0x2004, 0xd0fc, 0x1904, 0x3567, 0x0804, 0x4547, 0xa9a0, 0x2001,
-	0x197d, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c, 0x4acd, 0x01a0,
-	0x080c, 0x6a6a, 0x0118, 0x080c, 0x6a72, 0x1170, 0x080c, 0x66e7,
-	0x2009, 0x0002, 0x0128, 0x080c, 0x6880, 0x1170, 0x2009, 0x0003,
+	0x0fc4, 0x2100, 0x2238, 0x2061, 0x18b8, 0x2c44, 0xa28c, 0xa390,
+	0xa494, 0xa598, 0x2009, 0x002a, 0x0804, 0x4b15, 0x81ff, 0x1904,
+	0x35b9, 0x798c, 0x2001, 0x197d, 0x918c, 0x8000, 0x2102, 0x080c,
+	0x4ae0, 0x0904, 0x35bc, 0x080c, 0x6a8e, 0x0120, 0x080c, 0x6a96,
+	0x1904, 0x35bc, 0x080c, 0x670b, 0x0904, 0x35b9, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x68a4, 0x012e, 0x0904, 0x35b9, 0x2001, 0x197d,
+	0x2004, 0xd0fc, 0x1904, 0x3587, 0x0804, 0x4567, 0xa9a0, 0x2001,
+	0x197d, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c, 0x4aed, 0x01a0,
+	0x080c, 0x6a8e, 0x0118, 0x080c, 0x6a96, 0x1170, 0x080c, 0x670b,
+	0x2009, 0x0002, 0x0128, 0x080c, 0x68a4, 0x1170, 0x2009, 0x0003,
 	0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085,
 	0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0x2001, 0x197d,
-	0x2004, 0xd0fc, 0x1128, 0x080c, 0x56dd, 0x0110, 0x9006, 0x0018,
+	0x2004, 0xd0fc, 0x1128, 0x080c, 0x56fd, 0x0110, 0x9006, 0x0018,
 	0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x78a8, 0xd08c,
-	0x1118, 0xd084, 0x0904, 0x44bc, 0x080c, 0x4adc, 0x0904, 0x359c,
-	0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804, 0x3599, 0x080c,
-	0x6a6a, 0x0130, 0x908e, 0x0004, 0x0118, 0x908e, 0x0005, 0x15a0,
+	0x1118, 0xd084, 0x0904, 0x44dc, 0x080c, 0x4afc, 0x0904, 0x35bc,
+	0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804, 0x35b9, 0x080c,
+	0x6a8e, 0x0130, 0x908e, 0x0004, 0x0118, 0x908e, 0x0005, 0x15a0,
 	0x78a8, 0xd08c, 0x0120, 0xb800, 0xc08c, 0xb802, 0x0028, 0x080c,
-	0x56d5, 0xd0b4, 0x0904, 0x44f6, 0x7884, 0x908e, 0x007e, 0x0904,
-	0x44f6, 0x908e, 0x007f, 0x0904, 0x44f6, 0x908e, 0x0080, 0x0904,
-	0x44f6, 0xb800, 0xd08c, 0x1904, 0x44f6, 0xa867, 0x0000, 0xa868,
-	0xc0fd, 0xa86a, 0x080c, 0xca01, 0x1120, 0x2009, 0x0003, 0x0804,
-	0x3599, 0x7007, 0x0003, 0x701f, 0x52ee, 0x0005, 0x080c, 0x4adc,
-	0x0904, 0x359c, 0x0804, 0x44f6, 0x080c, 0x3357, 0x0108, 0x0005,
+	0x56f5, 0xd0b4, 0x0904, 0x4516, 0x7884, 0x908e, 0x007e, 0x0904,
+	0x4516, 0x908e, 0x007f, 0x0904, 0x4516, 0x908e, 0x0080, 0x0904,
+	0x4516, 0xb800, 0xd08c, 0x1904, 0x4516, 0xa867, 0x0000, 0xa868,
+	0xc0fd, 0xa86a, 0x080c, 0xca34, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x35b9, 0x7007, 0x0003, 0x701f, 0x530e, 0x0005, 0x080c, 0x4afc,
+	0x0904, 0x35bc, 0x0804, 0x4516, 0x080c, 0x3377, 0x0108, 0x0005,
 	0x2009, 0x1834, 0x210c, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804,
-	0x3599, 0x080c, 0x56e9, 0x0120, 0x2009, 0x0007, 0x0804, 0x3599,
-	0x080c, 0x6a62, 0x0120, 0x2009, 0x0008, 0x0804, 0x3599, 0xb89c,
-	0xd0a4, 0x1118, 0xd0ac, 0x1904, 0x44f6, 0x9006, 0xa866, 0xa832,
-	0xa868, 0xc0fd, 0xa86a, 0x080c, 0xca69, 0x1120, 0x2009, 0x0003,
-	0x0804, 0x3599, 0x7007, 0x0003, 0x701f, 0x5327, 0x0005, 0xa830,
-	0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x5632, 0x080c,
-	0x4adc, 0x0904, 0x359c, 0x0804, 0x52c0, 0x81ff, 0x2009, 0x0001,
-	0x1904, 0x3599, 0x080c, 0x56e9, 0x2009, 0x0007, 0x1904, 0x3599,
-	0x080c, 0x6a62, 0x0120, 0x2009, 0x0008, 0x0804, 0x3599, 0x080c,
-	0x4adc, 0x0904, 0x359c, 0x080c, 0x6a6a, 0x2009, 0x0009, 0x1904,
-	0x3599, 0x080c, 0x4aa9, 0x2009, 0x0002, 0x0904, 0x3599, 0x9006,
+	0x35b9, 0x080c, 0x5709, 0x0120, 0x2009, 0x0007, 0x0804, 0x35b9,
+	0x080c, 0x6a86, 0x0120, 0x2009, 0x0008, 0x0804, 0x35b9, 0xb89c,
+	0xd0a4, 0x1118, 0xd0ac, 0x1904, 0x4516, 0x9006, 0xa866, 0xa832,
+	0xa868, 0xc0fd, 0xa86a, 0x080c, 0xca9c, 0x1120, 0x2009, 0x0003,
+	0x0804, 0x35b9, 0x7007, 0x0003, 0x701f, 0x5347, 0x0005, 0xa830,
+	0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x5652, 0x080c,
+	0x4afc, 0x0904, 0x35bc, 0x0804, 0x52e0, 0x81ff, 0x2009, 0x0001,
+	0x1904, 0x35b9, 0x080c, 0x5709, 0x2009, 0x0007, 0x1904, 0x35b9,
+	0x080c, 0x6a86, 0x0120, 0x2009, 0x0008, 0x0804, 0x35b9, 0x080c,
+	0x4afc, 0x0904, 0x35bc, 0x080c, 0x6a8e, 0x2009, 0x0009, 0x1904,
+	0x35b9, 0x080c, 0x4ac9, 0x2009, 0x0002, 0x0904, 0x35b9, 0x9006,
 	0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x7988, 0x9194, 0xff00,
 	0x918c, 0x00ff, 0x9006, 0x82ff, 0x1128, 0xc0ed, 0xa952, 0x798c,
-	0xa956, 0x0038, 0x928e, 0x0100, 0x1904, 0x359c, 0xc0e5, 0xa952,
-	0xa956, 0xa83e, 0x080c, 0xcccc, 0x2009, 0x0003, 0x0904, 0x3599,
-	0x7007, 0x0003, 0x701f, 0x537d, 0x0005, 0xa830, 0x9086, 0x0100,
-	0x2009, 0x0004, 0x0904, 0x3599, 0x0804, 0x3567, 0x7aa8, 0x9284,
-	0xc000, 0x0148, 0xd2ec, 0x01a0, 0x080c, 0x56e9, 0x1188, 0x2009,
-	0x0014, 0x0804, 0x3599, 0xd2dc, 0x1568, 0x81ff, 0x2009, 0x0001,
-	0x1904, 0x3599, 0x080c, 0x56e9, 0x2009, 0x0007, 0x1904, 0x3599,
-	0xd2f4, 0x0130, 0x9284, 0x5000, 0x080c, 0x56b0, 0x0804, 0x3567,
-	0xd2fc, 0x0158, 0x080c, 0x4adc, 0x0904, 0x359c, 0x7984, 0x9284,
-	0x9000, 0x080c, 0x568d, 0x0804, 0x3567, 0x080c, 0x4adc, 0x0904,
-	0x359c, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x2009, 0x0009,
-	0x1904, 0x5466, 0x080c, 0x4aa9, 0x2009, 0x0002, 0x0904, 0x5466,
+	0xa956, 0x0038, 0x928e, 0x0100, 0x1904, 0x35bc, 0xc0e5, 0xa952,
+	0xa956, 0xa83e, 0x080c, 0xccff, 0x2009, 0x0003, 0x0904, 0x35b9,
+	0x7007, 0x0003, 0x701f, 0x539d, 0x0005, 0xa830, 0x9086, 0x0100,
+	0x2009, 0x0004, 0x0904, 0x35b9, 0x0804, 0x3587, 0x7aa8, 0x9284,
+	0xc000, 0x0148, 0xd2ec, 0x01a0, 0x080c, 0x5709, 0x1188, 0x2009,
+	0x0014, 0x0804, 0x35b9, 0xd2dc, 0x1568, 0x81ff, 0x2009, 0x0001,
+	0x1904, 0x35b9, 0x080c, 0x5709, 0x2009, 0x0007, 0x1904, 0x35b9,
+	0xd2f4, 0x0130, 0x9284, 0x5000, 0x080c, 0x56d0, 0x0804, 0x3587,
+	0xd2fc, 0x0158, 0x080c, 0x4afc, 0x0904, 0x35bc, 0x7984, 0x9284,
+	0x9000, 0x080c, 0x56ad, 0x0804, 0x3587, 0x080c, 0x4afc, 0x0904,
+	0x35bc, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x2009, 0x0009,
+	0x1904, 0x5486, 0x080c, 0x4ac9, 0x2009, 0x0002, 0x0904, 0x5486,
 	0xa85c, 0x9080, 0x001b, 0xaf60, 0x2009, 0x0008, 0x7a8c, 0x7b88,
-	0x7c9c, 0x7d98, 0x080c, 0x4af2, 0x701f, 0x53d7, 0x0005, 0xa86c,
+	0x7c9c, 0x7d98, 0x080c, 0x4b12, 0x701f, 0x53f7, 0x0005, 0xa86c,
 	0x9086, 0x0500, 0x1138, 0xa870, 0x9005, 0x1120, 0xa874, 0x9084,
-	0xff00, 0x0110, 0x1904, 0x359c, 0xa866, 0xa832, 0xa868, 0xc0fd,
-	0xa86a, 0x080c, 0x4adc, 0x1110, 0x0804, 0x359c, 0x2009, 0x0043,
-	0x080c, 0xcd34, 0x2009, 0x0003, 0x0904, 0x5466, 0x7007, 0x0003,
-	0x701f, 0x53fb, 0x0005, 0xa830, 0x9086, 0x0100, 0x2009, 0x0004,
-	0x0904, 0x5466, 0x7984, 0x7aa8, 0x9284, 0x1000, 0x080c, 0x568d,
-	0x0804, 0x3567, 0x00c6, 0xaab0, 0x9284, 0xc000, 0x0140, 0xd2ec,
-	0x0168, 0x080c, 0x56e9, 0x1150, 0x2009, 0x0014, 0x04f0, 0x2061,
-	0x1800, 0x080c, 0x56e9, 0x2009, 0x0007, 0x15b8, 0xd2f4, 0x0128,
-	0x9284, 0x5000, 0x080c, 0x56b0, 0x0050, 0xd2fc, 0x0178, 0x080c,
-	0x4ada, 0x0588, 0xa998, 0x9284, 0x9000, 0x080c, 0x568d, 0xa87b,
-	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x0438, 0x080c, 0x4ada,
-	0x0510, 0x080c, 0x6a6a, 0x2009, 0x0009, 0x11b8, 0xa8c4, 0x9086,
+	0xff00, 0x0110, 0x1904, 0x35bc, 0xa866, 0xa832, 0xa868, 0xc0fd,
+	0xa86a, 0x080c, 0x4afc, 0x1110, 0x0804, 0x35bc, 0x2009, 0x0043,
+	0x080c, 0xcd67, 0x2009, 0x0003, 0x0904, 0x5486, 0x7007, 0x0003,
+	0x701f, 0x541b, 0x0005, 0xa830, 0x9086, 0x0100, 0x2009, 0x0004,
+	0x0904, 0x5486, 0x7984, 0x7aa8, 0x9284, 0x1000, 0x080c, 0x56ad,
+	0x0804, 0x3587, 0x00c6, 0xaab0, 0x9284, 0xc000, 0x0140, 0xd2ec,
+	0x0168, 0x080c, 0x5709, 0x1150, 0x2009, 0x0014, 0x04f0, 0x2061,
+	0x1800, 0x080c, 0x5709, 0x2009, 0x0007, 0x15b8, 0xd2f4, 0x0128,
+	0x9284, 0x5000, 0x080c, 0x56d0, 0x0050, 0xd2fc, 0x0178, 0x080c,
+	0x4afa, 0x0588, 0xa998, 0x9284, 0x9000, 0x080c, 0x56ad, 0xa87b,
+	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x0438, 0x080c, 0x4afa,
+	0x0510, 0x080c, 0x6a8e, 0x2009, 0x0009, 0x11b8, 0xa8c4, 0x9086,
 	0x0500, 0x11c8, 0xa8c8, 0x9005, 0x11b0, 0xa8cc, 0x9084, 0xff00,
-	0x1190, 0x080c, 0x4ada, 0x1108, 0x0070, 0x2009, 0x004b, 0x080c,
-	0xcd34, 0x2009, 0x0003, 0x0108, 0x0078, 0x0429, 0x19c0, 0xa897,
+	0x1190, 0x080c, 0x4afa, 0x1108, 0x0070, 0x2009, 0x004b, 0x080c,
+	0xcd67, 0x2009, 0x0003, 0x0108, 0x0078, 0x0429, 0x19c0, 0xa897,
 	0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001,
 	0x2001, 0x0030, 0x00ce, 0x0005, 0x9006, 0x0ce0, 0x7aa8, 0xd2dc,
-	0x0904, 0x3599, 0x0016, 0x7984, 0x9284, 0x1000, 0xc0fd, 0x080c,
-	0x568d, 0x001e, 0x1904, 0x3599, 0x0804, 0x3567, 0x00f6, 0x2d78,
+	0x0904, 0x35b9, 0x0016, 0x7984, 0x9284, 0x1000, 0xc0fd, 0x080c,
+	0x56ad, 0x001e, 0x1904, 0x35b9, 0x0804, 0x3587, 0x00f6, 0x2d78,
 	0x0011, 0x00fe, 0x0005, 0xaab0, 0xd2dc, 0x0150, 0x0016, 0xa998,
-	0x9284, 0x1000, 0xc0fd, 0x080c, 0x568d, 0x001e, 0x9085, 0x0001,
-	0x0005, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3599, 0x080c,
-	0x56e9, 0x0120, 0x2009, 0x0007, 0x0804, 0x3599, 0x7984, 0x7ea8,
-	0x96b4, 0x00ff, 0x080c, 0x6620, 0x1904, 0x359c, 0x9186, 0x007f,
-	0x0138, 0x080c, 0x6a6a, 0x0120, 0x2009, 0x0009, 0x0804, 0x3599,
-	0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804, 0x3599, 0xa867,
+	0x9284, 0x1000, 0xc0fd, 0x080c, 0x56ad, 0x001e, 0x9085, 0x0001,
+	0x0005, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x35b9, 0x080c,
+	0x5709, 0x0120, 0x2009, 0x0007, 0x0804, 0x35b9, 0x7984, 0x7ea8,
+	0x96b4, 0x00ff, 0x080c, 0x6644, 0x1904, 0x35bc, 0x9186, 0x007f,
+	0x0138, 0x080c, 0x6a8e, 0x0120, 0x2009, 0x0009, 0x0804, 0x35b9,
+	0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804, 0x35b9, 0xa867,
 	0x0000, 0xa868, 0xc0fd, 0xa86a, 0x2001, 0x0100, 0x8007, 0xa80a,
-	0x080c, 0xca1b, 0x1120, 0x2009, 0x0003, 0x0804, 0x3599, 0x7007,
-	0x0003, 0x701f, 0x54c4, 0x0005, 0xa808, 0x8007, 0x9086, 0x0100,
-	0x1120, 0x2009, 0x0004, 0x0804, 0x3599, 0xa8e0, 0xa866, 0xa810,
+	0x080c, 0xca4e, 0x1120, 0x2009, 0x0003, 0x0804, 0x35b9, 0x7007,
+	0x0003, 0x701f, 0x54e4, 0x0005, 0xa808, 0x8007, 0x9086, 0x0100,
+	0x1120, 0x2009, 0x0004, 0x0804, 0x35b9, 0xa8e0, 0xa866, 0xa810,
 	0x8007, 0x9084, 0x00ff, 0x800c, 0xa814, 0x8007, 0x9084, 0x00ff,
 	0x8004, 0x9080, 0x0002, 0x9108, 0x8906, 0x8006, 0x8007, 0x90bc,
 	0x003f, 0x9084, 0xffc0, 0x9080, 0x0004, 0x7a8c, 0x7b88, 0x7c9c,
-	0x7d98, 0x0804, 0x4af5, 0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x3599, 0x7984, 0x9194, 0xff00, 0x918c, 0x00ff, 0x8217,
+	0x7d98, 0x0804, 0x4b15, 0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002,
+	0x0804, 0x35b9, 0x7984, 0x9194, 0xff00, 0x918c, 0x00ff, 0x8217,
 	0x82ff, 0x1118, 0x7023, 0x19b2, 0x0040, 0x92c6, 0x0001, 0x1118,
-	0x7023, 0x19cc, 0x0010, 0x0804, 0x359c, 0x2009, 0x001a, 0x7a8c,
+	0x7023, 0x19cc, 0x0010, 0x0804, 0x35bc, 0x2009, 0x001a, 0x7a8c,
 	0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c,
-	0x4af2, 0x701f, 0x5514, 0x0005, 0x2001, 0x182e, 0x2003, 0x0001,
+	0x4b12, 0x701f, 0x5534, 0x0005, 0x2001, 0x182e, 0x2003, 0x0001,
 	0xa85c, 0x9080, 0x0019, 0x2098, 0xa860, 0x20e0, 0x20a9, 0x001a,
-	0x7020, 0x20a0, 0x20e9, 0x0001, 0x4003, 0x0804, 0x3567, 0x080c,
-	0x4aa9, 0x1120, 0x2009, 0x0002, 0x0804, 0x3599, 0x7984, 0x9194,
+	0x7020, 0x20a0, 0x20e9, 0x0001, 0x4003, 0x0804, 0x3587, 0x080c,
+	0x4ac9, 0x1120, 0x2009, 0x0002, 0x0804, 0x35b9, 0x7984, 0x9194,
 	0xff00, 0x918c, 0x00ff, 0x8217, 0x82ff, 0x1118, 0x2099, 0x19b2,
 	0x0040, 0x92c6, 0x0001, 0x1118, 0x2099, 0x19cc, 0x0010, 0x0804,
-	0x359c, 0xa85c, 0x9080, 0x0019, 0x20a0, 0xa860, 0x20e8, 0x20a9,
+	0x35bc, 0xa85c, 0x9080, 0x0019, 0x20a0, 0xa860, 0x20e8, 0x20a9,
 	0x001a, 0x20e1, 0x0001, 0x4003, 0x2009, 0x001a, 0x7a8c, 0x7b88,
-	0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x0804, 0x4af5,
-	0x7884, 0x908a, 0x1000, 0x1a04, 0x359c, 0x0126, 0x2091, 0x8000,
+	0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x0804, 0x4b15,
+	0x7884, 0x908a, 0x1000, 0x1a04, 0x35bc, 0x0126, 0x2091, 0x8000,
 	0x8003, 0x800b, 0x810b, 0x9108, 0x00c6, 0x2061, 0x1a02, 0x6142,
-	0x00ce, 0x012e, 0x0804, 0x3567, 0x00c6, 0x080c, 0x74c8, 0x1160,
-	0x080c, 0x77cc, 0x080c, 0x6024, 0x9085, 0x0001, 0x080c, 0x750f,
-	0x080c, 0x73f9, 0x080c, 0x0d7d, 0x2061, 0x1800, 0x6030, 0xc09d,
-	0x6032, 0x080c, 0x5edf, 0x00ce, 0x0005, 0x00c6, 0x2001, 0x1800,
-	0x2004, 0x908e, 0x0000, 0x0904, 0x3599, 0x7884, 0x9005, 0x0188,
-	0x7888, 0x2061, 0x199b, 0x2c0c, 0x2062, 0x080c, 0x29f7, 0x01a0,
-	0x080c, 0x29ff, 0x0188, 0x080c, 0x2a07, 0x0170, 0x2162, 0x0804,
-	0x359c, 0x2061, 0x0100, 0x6038, 0x9086, 0x0007, 0x1118, 0x2009,
+	0x00ce, 0x012e, 0x0804, 0x3587, 0x00c6, 0x080c, 0x74ec, 0x1160,
+	0x080c, 0x77ef, 0x080c, 0x6044, 0x9085, 0x0001, 0x080c, 0x7533,
+	0x080c, 0x741d, 0x080c, 0x0d7d, 0x2061, 0x1800, 0x6030, 0xc09d,
+	0x6032, 0x080c, 0x5eff, 0x00ce, 0x0005, 0x00c6, 0x2001, 0x1800,
+	0x2004, 0x908e, 0x0000, 0x0904, 0x35b9, 0x7884, 0x9005, 0x0188,
+	0x7888, 0x2061, 0x199b, 0x2c0c, 0x2062, 0x080c, 0x2a17, 0x01a0,
+	0x080c, 0x2a1f, 0x0188, 0x080c, 0x2a27, 0x0170, 0x2162, 0x0804,
+	0x35bc, 0x2061, 0x0100, 0x6038, 0x9086, 0x0007, 0x1118, 0x2009,
 	0x0001, 0x0010, 0x2009, 0x0000, 0x7884, 0x9086, 0x0002, 0x1588,
-	0x2061, 0x0100, 0x6028, 0xc09c, 0x602a, 0x080c, 0xa888, 0x0026,
-	0x2011, 0x0003, 0x080c, 0xa1b1, 0x2011, 0x0002, 0x080c, 0xa1bb,
-	0x002e, 0x080c, 0xa07a, 0x0036, 0x901e, 0x080c, 0xa0fa, 0x003e,
-	0x080c, 0xa8a4, 0x60e3, 0x0000, 0x080c, 0xe712, 0x080c, 0xe72d,
-	0x9085, 0x0001, 0x080c, 0x750f, 0x9006, 0x080c, 0x2a29, 0x2001,
-	0x1800, 0x2003, 0x0004, 0x0026, 0x2011, 0x0008, 0x080c, 0x2a63,
-	0x002e, 0x00ce, 0x0804, 0x3567, 0x81ff, 0x0120, 0x2009, 0x0001,
-	0x0804, 0x3599, 0x080c, 0x56e9, 0x0120, 0x2009, 0x0007, 0x0804,
-	0x3599, 0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c, 0x6620, 0x1904,
-	0x359c, 0x9186, 0x007f, 0x0138, 0x080c, 0x6a6a, 0x0120, 0x2009,
-	0x0009, 0x0804, 0x3599, 0x080c, 0x4aa9, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x3599, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c,
-	0xca1e, 0x1120, 0x2009, 0x0003, 0x0804, 0x3599, 0x7007, 0x0003,
-	0x701f, 0x561b, 0x0005, 0xa830, 0x9086, 0x0100, 0x1120, 0x2009,
-	0x0004, 0x0804, 0x3599, 0xa8e0, 0xa866, 0xa834, 0x8007, 0x800c,
+	0x2061, 0x0100, 0x6028, 0xc09c, 0x602a, 0x080c, 0xa899, 0x0026,
+	0x2011, 0x0003, 0x080c, 0xa1be, 0x2011, 0x0002, 0x080c, 0xa1c8,
+	0x002e, 0x080c, 0xa0b3, 0x0036, 0x901e, 0x080c, 0xa133, 0x003e,
+	0x080c, 0xa8b5, 0x60e3, 0x0000, 0x080c, 0xe74f, 0x080c, 0xe76a,
+	0x9085, 0x0001, 0x080c, 0x7533, 0x9006, 0x080c, 0x2a49, 0x2001,
+	0x1800, 0x2003, 0x0004, 0x0026, 0x2011, 0x0008, 0x080c, 0x2a83,
+	0x002e, 0x00ce, 0x0804, 0x3587, 0x81ff, 0x0120, 0x2009, 0x0001,
+	0x0804, 0x35b9, 0x080c, 0x5709, 0x0120, 0x2009, 0x0007, 0x0804,
+	0x35b9, 0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c, 0x6644, 0x1904,
+	0x35bc, 0x9186, 0x007f, 0x0138, 0x080c, 0x6a8e, 0x0120, 0x2009,
+	0x0009, 0x0804, 0x35b9, 0x080c, 0x4ac9, 0x1120, 0x2009, 0x0002,
+	0x0804, 0x35b9, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c,
+	0xca51, 0x1120, 0x2009, 0x0003, 0x0804, 0x35b9, 0x7007, 0x0003,
+	0x701f, 0x563b, 0x0005, 0xa830, 0x9086, 0x0100, 0x1120, 0x2009,
+	0x0004, 0x0804, 0x35b9, 0xa8e0, 0xa866, 0xa834, 0x8007, 0x800c,
 	0xa85c, 0x9080, 0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xaf60,
-	0x0804, 0x4af5, 0xa898, 0x9086, 0x000d, 0x1904, 0x3599, 0x2021,
-	0x4005, 0x0126, 0x2091, 0x8000, 0x0e04, 0x563f, 0x0010, 0x012e,
+	0x0804, 0x4b15, 0xa898, 0x9086, 0x000d, 0x1904, 0x35b9, 0x2021,
+	0x4005, 0x0126, 0x2091, 0x8000, 0x0e04, 0x565f, 0x0010, 0x012e,
 	0x0cc0, 0x7c36, 0x9486, 0x4000, 0x0118, 0x7833, 0x0011, 0x0010,
 	0x7833, 0x0010, 0x7883, 0x4005, 0xa998, 0x7986, 0xa9a4, 0x799a,
-	0xa9a8, 0x799e, 0x080c, 0x4ae5, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x190c, 0x11e1, 0x7007, 0x0001, 0x2091, 0x5000,
+	0xa9a8, 0x799e, 0x080c, 0x4b05, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x11ee, 0x7007, 0x0001, 0x2091, 0x5000,
 	0x700f, 0x0000, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x00c6,
 	0x2061, 0x1a02, 0x7984, 0x6152, 0x614e, 0x6057, 0x0000, 0x604b,
 	0x0009, 0x7898, 0x606a, 0x789c, 0x6066, 0x7888, 0x6062, 0x788c,
 	0x605e, 0x2001, 0x1a10, 0x2044, 0x2001, 0x1a17, 0xa076, 0xa060,
 	0xa072, 0xa07b, 0x0001, 0xa07f, 0x0002, 0xa06b, 0x0000, 0xa09f,
-	0x0000, 0x00ce, 0x012e, 0x0804, 0x3567, 0x0126, 0x2091, 0x8000,
-	0x00b6, 0x00c6, 0x90e4, 0xc000, 0x0128, 0x0006, 0x080c, 0xc87f,
+	0x0000, 0x00ce, 0x012e, 0x0804, 0x3587, 0x0126, 0x2091, 0x8000,
+	0x00b6, 0x00c6, 0x90e4, 0xc000, 0x0128, 0x0006, 0x080c, 0xc8b2,
 	0x000e, 0x1198, 0xd0e4, 0x0160, 0x9180, 0x1000, 0x2004, 0x905d,
-	0x0160, 0x080c, 0x603e, 0x080c, 0xab49, 0x0110, 0xb817, 0x0000,
+	0x0160, 0x080c, 0x605e, 0x080c, 0xab5a, 0x0110, 0xb817, 0x0000,
 	0x9006, 0x00ce, 0x00be, 0x012e, 0x0005, 0x9085, 0x0001, 0x0cc8,
 	0x0126, 0x2091, 0x8000, 0x0156, 0x2010, 0x900e, 0x20a9, 0x0800,
 	0x0016, 0x9180, 0x1000, 0x2004, 0x9005, 0x0180, 0x9186, 0x007e,
 	0x0168, 0x9186, 0x007f, 0x0150, 0x9186, 0x0080, 0x0138, 0x9186,
 	0x00ff, 0x0120, 0x0026, 0x2200, 0x0801, 0x002e, 0x001e, 0x8108,
-	0x1f04, 0x56b8, 0x015e, 0x012e, 0x0005, 0x2001, 0x1848, 0x2004,
+	0x1f04, 0x56d8, 0x015e, 0x012e, 0x0005, 0x2001, 0x1848, 0x2004,
 	0x0005, 0x2001, 0x1867, 0x2004, 0x0005, 0x0006, 0x2001, 0x1810,
 	0x2004, 0xd0d4, 0x000e, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0b4,
 	0x0005, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x0005, 0x0016,
 	0x00e6, 0x2071, 0x189e, 0x7108, 0x910d, 0x710a, 0x00ee, 0x001e,
-	0x0005, 0x79a4, 0x9182, 0x0081, 0x1a04, 0x359c, 0x810c, 0x0016,
-	0x080c, 0x4aa9, 0x080c, 0x0f42, 0x2100, 0x2238, 0x7d84, 0x7c88,
-	0x7b8c, 0x7a90, 0x001e, 0x080c, 0x4af2, 0x701f, 0x5710, 0x0005,
+	0x0005, 0x79a4, 0x9182, 0x0081, 0x1a04, 0x35bc, 0x810c, 0x0016,
+	0x080c, 0x4ac9, 0x080c, 0x0f4f, 0x2100, 0x2238, 0x7d84, 0x7c88,
+	0x7b8c, 0x7a90, 0x001e, 0x080c, 0x4b12, 0x701f, 0x5730, 0x0005,
 	0x2079, 0x0000, 0x7d94, 0x7c98, 0x7ba8, 0x7aac, 0x79a4, 0x810c,
 	0x2061, 0x18b8, 0x2c44, 0xa770, 0xa074, 0x2071, 0x189e, 0x080c,
-	0x4af5, 0x701f, 0x5724, 0x0005, 0x2061, 0x18b8, 0x2c44, 0x0016,
-	0x0026, 0xa270, 0xa174, 0x080c, 0x0f4a, 0x002e, 0x001e, 0x080c,
-	0x0ff7, 0x9006, 0xa802, 0xa806, 0x0804, 0x3567, 0x0126, 0x0156,
+	0x4b15, 0x701f, 0x5744, 0x0005, 0x2061, 0x18b8, 0x2c44, 0x0016,
+	0x0026, 0xa270, 0xa174, 0x080c, 0x0f57, 0x002e, 0x001e, 0x080c,
+	0x1004, 0x9006, 0xa802, 0xa806, 0x0804, 0x3587, 0x0126, 0x0156,
 	0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
 	0x2061, 0x0100, 0x2069, 0x0200, 0x2071, 0x1800, 0x6044, 0xd0a4,
-	0x11e8, 0xd084, 0x0118, 0x080c, 0x58df, 0x0068, 0xd08c, 0x0118,
-	0x080c, 0x57e8, 0x0040, 0xd094, 0x0118, 0x080c, 0x57b8, 0x0018,
+	0x11e8, 0xd084, 0x0118, 0x080c, 0x58ff, 0x0068, 0xd08c, 0x0118,
+	0x080c, 0x5808, 0x0040, 0xd094, 0x0118, 0x080c, 0x57d8, 0x0018,
 	0xd09c, 0x0108, 0x0099, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de,
 	0x01ce, 0x014e, 0x013e, 0x015e, 0x012e, 0x0005, 0x0016, 0x6128,
 	0xd19c, 0x1110, 0xc19d, 0x612a, 0x001e, 0x0c68, 0x0006, 0x7098,
@@ -2596,216 +2600,216 @@
 	0x9286, 0xf0f0, 0x1150, 0x6048, 0x9086, 0xf0f0, 0x0130, 0x624a,
 	0x6043, 0x0090, 0x6043, 0x0010, 0x0490, 0x9294, 0xff00, 0x9296,
 	0xf700, 0x0178, 0x7138, 0xd1a4, 0x1160, 0x6240, 0x9295, 0x0100,
-	0x6242, 0x9294, 0x0010, 0x0128, 0x2009, 0x00f7, 0x080c, 0x5fa0,
+	0x6242, 0x9294, 0x0010, 0x0128, 0x2009, 0x00f7, 0x080c, 0x5fc0,
 	0x00f0, 0x6040, 0x9084, 0x0010, 0x9085, 0x0140, 0x6042, 0x6043,
 	0x0000, 0x7087, 0x0000, 0x70a3, 0x0001, 0x70c7, 0x0000, 0x70df,
 	0x0000, 0x2009, 0x1d80, 0x200b, 0x0000, 0x7097, 0x0000, 0x708b,
-	0x000f, 0x2009, 0x000f, 0x2011, 0x5e82, 0x080c, 0x86e7, 0x0005,
+	0x000f, 0x2009, 0x000f, 0x2011, 0x5ea2, 0x080c, 0x871b, 0x0005,
 	0x2001, 0x1869, 0x2004, 0xd08c, 0x0110, 0x705f, 0xffff, 0x7088,
-	0x9005, 0x1528, 0x2011, 0x5e82, 0x080c, 0x861d, 0x6040, 0x9094,
+	0x9005, 0x1528, 0x2011, 0x5ea2, 0x080c, 0x8651, 0x6040, 0x9094,
 	0x0010, 0x9285, 0x0020, 0x6042, 0x20a9, 0x00c8, 0x6044, 0xd08c,
-	0x1168, 0x1f04, 0x57ce, 0x6242, 0x709b, 0x0000, 0x6040, 0x9094,
+	0x1168, 0x1f04, 0x57ee, 0x6242, 0x709b, 0x0000, 0x6040, 0x9094,
 	0x0010, 0x9285, 0x0080, 0x6042, 0x6242, 0x0048, 0x6242, 0x709b,
-	0x0000, 0x708f, 0x0000, 0x9006, 0x080c, 0x6029, 0x0000, 0x0005,
-	0x708c, 0x908a, 0x0003, 0x1a0c, 0x0d7d, 0x000b, 0x0005, 0x57f2,
-	0x5843, 0x58de, 0x00f6, 0x0016, 0x6900, 0x918c, 0x0800, 0x708f,
+	0x0000, 0x708f, 0x0000, 0x9006, 0x080c, 0x6049, 0x0000, 0x0005,
+	0x708c, 0x908a, 0x0003, 0x1a0c, 0x0d7d, 0x000b, 0x0005, 0x5812,
+	0x5863, 0x58fe, 0x00f6, 0x0016, 0x6900, 0x918c, 0x0800, 0x708f,
 	0x0001, 0x2001, 0x015d, 0x2003, 0x0000, 0x6803, 0x00fc, 0x20a9,
-	0x0004, 0x6800, 0x9084, 0x00fc, 0x0120, 0x1f04, 0x5801, 0x080c,
+	0x0004, 0x6800, 0x9084, 0x00fc, 0x0120, 0x1f04, 0x5821, 0x080c,
 	0x0d7d, 0x68a0, 0x68a2, 0x689c, 0x689e, 0x6898, 0x689a, 0xa001,
-	0x918d, 0x1600, 0x6902, 0x001e, 0x6837, 0x0020, 0x080c, 0x6005,
+	0x918d, 0x1600, 0x6902, 0x001e, 0x6837, 0x0020, 0x080c, 0x6025,
 	0x2079, 0x1d00, 0x7833, 0x1101, 0x7837, 0x0000, 0x20e1, 0x0001,
 	0x2099, 0x1805, 0x20e9, 0x0001, 0x20a1, 0x1d0e, 0x20a9, 0x0004,
-	0x4003, 0x080c, 0xa67d, 0x20e1, 0x0001, 0x2099, 0x1d00, 0x20e9,
+	0x4003, 0x080c, 0xa68e, 0x20e1, 0x0001, 0x2099, 0x1d00, 0x20e9,
 	0x0000, 0x20a1, 0x0240, 0x20a9, 0x0014, 0x4003, 0x60c3, 0x000c,
-	0x600f, 0x0000, 0x080c, 0x5eb3, 0x00fe, 0x9006, 0x7092, 0x6043,
+	0x600f, 0x0000, 0x080c, 0x5ed3, 0x00fe, 0x9006, 0x7092, 0x6043,
 	0x0008, 0x6042, 0x0005, 0x00f6, 0x7090, 0x7093, 0x0000, 0x9025,
-	0x0904, 0x58bb, 0x6020, 0xd0b4, 0x1904, 0x58b9, 0x71a0, 0x81ff,
-	0x0904, 0x58a7, 0x9486, 0x000c, 0x1904, 0x58b4, 0x9480, 0x0018,
-	0x8004, 0x20a8, 0x080c, 0x5ffe, 0x2011, 0x0260, 0x2019, 0x1d00,
-	0x220c, 0x2304, 0x9106, 0x11e8, 0x8210, 0x8318, 0x1f04, 0x5860,
+	0x0904, 0x58db, 0x6020, 0xd0b4, 0x1904, 0x58d9, 0x71a0, 0x81ff,
+	0x0904, 0x58c7, 0x9486, 0x000c, 0x1904, 0x58d4, 0x9480, 0x0018,
+	0x8004, 0x20a8, 0x080c, 0x601e, 0x2011, 0x0260, 0x2019, 0x1d00,
+	0x220c, 0x2304, 0x9106, 0x11e8, 0x8210, 0x8318, 0x1f04, 0x5880,
 	0x6043, 0x0004, 0x2061, 0x0140, 0x605b, 0xbc94, 0x605f, 0xf0f0,
 	0x2061, 0x0100, 0x6043, 0x0006, 0x708f, 0x0002, 0x709b, 0x0002,
-	0x2009, 0x07d0, 0x2011, 0x5e89, 0x080c, 0x86e7, 0x080c, 0x6005,
-	0x04c0, 0x080c, 0x5ffe, 0x2079, 0x0260, 0x7930, 0x918e, 0x1101,
+	0x2009, 0x07d0, 0x2011, 0x5ea9, 0x080c, 0x871b, 0x080c, 0x6025,
+	0x04c0, 0x080c, 0x601e, 0x2079, 0x0260, 0x7930, 0x918e, 0x1101,
 	0x1558, 0x7834, 0x9005, 0x1540, 0x7900, 0x918c, 0x00ff, 0x1118,
-	0x7804, 0x9005, 0x0190, 0x080c, 0x5ffe, 0x2011, 0x026e, 0x2019,
+	0x7804, 0x9005, 0x0190, 0x080c, 0x601e, 0x2011, 0x026e, 0x2019,
 	0x1805, 0x20a9, 0x0004, 0x220c, 0x2304, 0x9102, 0x0230, 0x11a0,
-	0x8210, 0x8318, 0x1f04, 0x589b, 0x0078, 0x70a3, 0x0000, 0x080c,
-	0x5ffe, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0001, 0x20a1,
+	0x8210, 0x8318, 0x1f04, 0x58bb, 0x0078, 0x70a3, 0x0000, 0x080c,
+	0x601e, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0001, 0x20a1,
 	0x1d00, 0x20a9, 0x0014, 0x4003, 0x6043, 0x0008, 0x6043, 0x0000,
 	0x0010, 0x00fe, 0x0005, 0x6040, 0x9085, 0x0100, 0x6042, 0x6020,
-	0xd0b4, 0x1db8, 0x080c, 0xa67d, 0x20e1, 0x0001, 0x2099, 0x1d00,
+	0xd0b4, 0x1db8, 0x080c, 0xa68e, 0x20e1, 0x0001, 0x2099, 0x1d00,
 	0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x0014, 0x4003, 0x60c3,
 	0x000c, 0x2011, 0x19f3, 0x2013, 0x0000, 0x7093, 0x0000, 0x60a3,
-	0x0056, 0x60a7, 0x9575, 0x080c, 0x9e09, 0x08d8, 0x0005, 0x7098,
-	0x908a, 0x001d, 0x1a0c, 0x0d7d, 0x000b, 0x0005, 0x5910, 0x5923,
-	0x594c, 0x596c, 0x5992, 0x59c1, 0x59e7, 0x5a1f, 0x5a45, 0x5a73,
-	0x5aae, 0x5ae6, 0x5b04, 0x5b2f, 0x5b51, 0x5b6c, 0x5b76, 0x5baa,
-	0x5bd0, 0x5bff, 0x5c25, 0x5c5d, 0x5ca1, 0x5cde, 0x5cff, 0x5d58,
-	0x5d7a, 0x5da8, 0x5da8, 0x00c6, 0x2061, 0x1800, 0x6003, 0x0007,
+	0x0056, 0x60a7, 0x9575, 0x080c, 0x9e42, 0x08d8, 0x0005, 0x7098,
+	0x908a, 0x001d, 0x1a0c, 0x0d7d, 0x000b, 0x0005, 0x5930, 0x5943,
+	0x596c, 0x598c, 0x59b2, 0x59e1, 0x5a07, 0x5a3f, 0x5a65, 0x5a93,
+	0x5ace, 0x5b06, 0x5b24, 0x5b4f, 0x5b71, 0x5b8c, 0x5b96, 0x5bca,
+	0x5bf0, 0x5c1f, 0x5c45, 0x5c7d, 0x5cc1, 0x5cfe, 0x5d1f, 0x5d78,
+	0x5d9a, 0x5dc8, 0x5dc8, 0x00c6, 0x2061, 0x1800, 0x6003, 0x0007,
 	0x2061, 0x0100, 0x6004, 0x9084, 0xfff9, 0x6006, 0x00ce, 0x0005,
 	0x2061, 0x0140, 0x605b, 0xbc94, 0x605f, 0xf0f0, 0x2061, 0x0100,
-	0x6043, 0x0002, 0x709b, 0x0001, 0x2009, 0x07d0, 0x2011, 0x5e89,
-	0x080c, 0x86e7, 0x0005, 0x00f6, 0x7090, 0x9086, 0x0014, 0x1510,
-	0x6042, 0x6020, 0xd0b4, 0x11f0, 0x080c, 0x5ffe, 0x2079, 0x0260,
+	0x6043, 0x0002, 0x709b, 0x0001, 0x2009, 0x07d0, 0x2011, 0x5ea9,
+	0x080c, 0x871b, 0x0005, 0x00f6, 0x7090, 0x9086, 0x0014, 0x1510,
+	0x6042, 0x6020, 0xd0b4, 0x11f0, 0x080c, 0x601e, 0x2079, 0x0260,
 	0x7a30, 0x9296, 0x1102, 0x11a0, 0x7834, 0x9005, 0x1188, 0x7a38,
 	0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x2011,
-	0x5e89, 0x080c, 0x861d, 0x709b, 0x0010, 0x080c, 0x5b76, 0x0010,
+	0x5ea9, 0x080c, 0x8651, 0x709b, 0x0010, 0x080c, 0x5b96, 0x0010,
 	0x7093, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0003, 0x6043,
-	0x0004, 0x2011, 0x5e89, 0x080c, 0x861d, 0x080c, 0x5f82, 0x2079,
+	0x0004, 0x2011, 0x5ea9, 0x080c, 0x8651, 0x080c, 0x5fa2, 0x2079,
 	0x0240, 0x7833, 0x1102, 0x7837, 0x0000, 0x20a9, 0x0008, 0x9f88,
-	0x000e, 0x200b, 0x0000, 0x8108, 0x1f04, 0x5961, 0x60c3, 0x0014,
-	0x080c, 0x5eb3, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500,
-	0x2011, 0x5e89, 0x080c, 0x861d, 0x9086, 0x0014, 0x11b8, 0x080c,
-	0x5ffe, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102, 0x1178, 0x7834,
+	0x000e, 0x200b, 0x0000, 0x8108, 0x1f04, 0x5981, 0x60c3, 0x0014,
+	0x080c, 0x5ed3, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500,
+	0x2011, 0x5ea9, 0x080c, 0x8651, 0x9086, 0x0014, 0x11b8, 0x080c,
+	0x601e, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102, 0x1178, 0x7834,
 	0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110,
-	0x70c7, 0x0001, 0x709b, 0x0004, 0x0029, 0x0010, 0x080c, 0x5fda,
-	0x00fe, 0x0005, 0x00f6, 0x709b, 0x0005, 0x080c, 0x5f82, 0x2079,
-	0x0240, 0x7833, 0x1103, 0x7837, 0x0000, 0x080c, 0x5ffe, 0x080c,
-	0x5fe1, 0x1170, 0x7084, 0x9005, 0x1158, 0x715c, 0x9186, 0xffff,
-	0x0138, 0x2011, 0x0008, 0x080c, 0x5e36, 0x0168, 0x080c, 0x5fb7,
+	0x70c7, 0x0001, 0x709b, 0x0004, 0x0029, 0x0010, 0x080c, 0x5ffa,
+	0x00fe, 0x0005, 0x00f6, 0x709b, 0x0005, 0x080c, 0x5fa2, 0x2079,
+	0x0240, 0x7833, 0x1103, 0x7837, 0x0000, 0x080c, 0x601e, 0x080c,
+	0x6001, 0x1170, 0x7084, 0x9005, 0x1158, 0x715c, 0x9186, 0xffff,
+	0x0138, 0x2011, 0x0008, 0x080c, 0x5e56, 0x0168, 0x080c, 0x5fd7,
 	0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000,
-	0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5eb3, 0x00fe,
-	0x0005, 0x00f6, 0x7090, 0x9005, 0x0500, 0x2011, 0x5e89, 0x080c,
-	0x861d, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5ffe, 0x2079, 0x0260,
+	0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5ed3, 0x00fe,
+	0x0005, 0x00f6, 0x7090, 0x9005, 0x0500, 0x2011, 0x5ea9, 0x080c,
+	0x8651, 0x9086, 0x0014, 0x11b8, 0x080c, 0x601e, 0x2079, 0x0260,
 	0x7a30, 0x9296, 0x1103, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38,
 	0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x709b,
-	0x0006, 0x0029, 0x0010, 0x080c, 0x5fda, 0x00fe, 0x0005, 0x00f6,
-	0x709b, 0x0007, 0x080c, 0x5f82, 0x2079, 0x0240, 0x7833, 0x1104,
-	0x7837, 0x0000, 0x080c, 0x5ffe, 0x080c, 0x5fe1, 0x11b8, 0x7084,
-	0x9005, 0x11a0, 0x7164, 0x9186, 0xffff, 0x0180, 0x9180, 0x3368,
-	0x200d, 0x918c, 0xff00, 0x810f, 0x2011, 0x0008, 0x080c, 0x5e36,
-	0x0180, 0x080c, 0x4fdf, 0x0110, 0x080c, 0x267d, 0x20a9, 0x0008,
+	0x0006, 0x0029, 0x0010, 0x080c, 0x5ffa, 0x00fe, 0x0005, 0x00f6,
+	0x709b, 0x0007, 0x080c, 0x5fa2, 0x2079, 0x0240, 0x7833, 0x1104,
+	0x7837, 0x0000, 0x080c, 0x601e, 0x080c, 0x6001, 0x11b8, 0x7084,
+	0x9005, 0x11a0, 0x7164, 0x9186, 0xffff, 0x0180, 0x9180, 0x3388,
+	0x200d, 0x918c, 0xff00, 0x810f, 0x2011, 0x0008, 0x080c, 0x5e56,
+	0x0180, 0x080c, 0x4fff, 0x0110, 0x080c, 0x2699, 0x20a9, 0x0008,
 	0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e,
-	0x4003, 0x60c3, 0x0014, 0x080c, 0x5eb3, 0x00fe, 0x0005, 0x00f6,
-	0x7090, 0x9005, 0x0500, 0x2011, 0x5e89, 0x080c, 0x861d, 0x9086,
-	0x0014, 0x11b8, 0x080c, 0x5ffe, 0x2079, 0x0260, 0x7a30, 0x9296,
+	0x4003, 0x60c3, 0x0014, 0x080c, 0x5ed3, 0x00fe, 0x0005, 0x00f6,
+	0x7090, 0x9005, 0x0500, 0x2011, 0x5ea9, 0x080c, 0x8651, 0x9086,
+	0x0014, 0x11b8, 0x080c, 0x601e, 0x2079, 0x0260, 0x7a30, 0x9296,
 	0x1104, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128,
 	0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x709b, 0x0008, 0x0029,
-	0x0010, 0x080c, 0x5fda, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0009,
-	0x080c, 0x5f82, 0x2079, 0x0240, 0x7833, 0x1105, 0x7837, 0x0100,
-	0x080c, 0x5fe1, 0x1150, 0x7084, 0x9005, 0x1138, 0x080c, 0x5da9,
-	0x1188, 0x9085, 0x0001, 0x080c, 0x267d, 0x20a9, 0x0008, 0x080c,
-	0x5ffe, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1,
-	0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5eb3, 0x0010, 0x080c,
-	0x5903, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x05a8, 0x2011,
-	0x5e89, 0x080c, 0x861d, 0x9086, 0x0014, 0x1560, 0x080c, 0x5ffe,
+	0x0010, 0x080c, 0x5ffa, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0009,
+	0x080c, 0x5fa2, 0x2079, 0x0240, 0x7833, 0x1105, 0x7837, 0x0100,
+	0x080c, 0x6001, 0x1150, 0x7084, 0x9005, 0x1138, 0x080c, 0x5dc9,
+	0x1188, 0x9085, 0x0001, 0x080c, 0x2699, 0x20a9, 0x0008, 0x080c,
+	0x601e, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1,
+	0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5ed3, 0x0010, 0x080c,
+	0x5923, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005, 0x05a8, 0x2011,
+	0x5ea9, 0x080c, 0x8651, 0x9086, 0x0014, 0x1560, 0x080c, 0x601e,
 	0x2079, 0x0260, 0x7a30, 0x9296, 0x1105, 0x1520, 0x7834, 0x9084,
 	0x0100, 0x2011, 0x0100, 0x921e, 0x1160, 0x7a38, 0xd2fc, 0x0128,
 	0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x709b, 0x000a, 0x00b1,
 	0x0098, 0x9005, 0x1178, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005,
 	0x1110, 0x70c7, 0x0001, 0x7097, 0x0000, 0x709b, 0x000e, 0x080c,
-	0x5b51, 0x0010, 0x080c, 0x5fda, 0x00fe, 0x0005, 0x00f6, 0x709b,
+	0x5b71, 0x0010, 0x080c, 0x5ffa, 0x00fe, 0x0005, 0x00f6, 0x709b,
 	0x000b, 0x2011, 0x1d0e, 0x20e9, 0x0001, 0x22a0, 0x20a9, 0x0040,
-	0x2019, 0xffff, 0x4304, 0x080c, 0x5f82, 0x2079, 0x0240, 0x7833,
-	0x1106, 0x7837, 0x0000, 0x080c, 0x5fe1, 0x0118, 0x2013, 0x0000,
+	0x2019, 0xffff, 0x4304, 0x080c, 0x5fa2, 0x2079, 0x0240, 0x7833,
+	0x1106, 0x7837, 0x0000, 0x080c, 0x6001, 0x0118, 0x2013, 0x0000,
 	0x0020, 0x7060, 0x9085, 0x0100, 0x2012, 0x20a9, 0x0040, 0x2009,
 	0x024e, 0x2011, 0x1d0e, 0x220e, 0x8210, 0x8108, 0x9186, 0x0260,
-	0x1128, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x1f04, 0x5ad3,
-	0x60c3, 0x0084, 0x080c, 0x5eb3, 0x00fe, 0x0005, 0x00f6, 0x7090,
-	0x9005, 0x01c0, 0x2011, 0x5e89, 0x080c, 0x861d, 0x9086, 0x0084,
-	0x1178, 0x080c, 0x5ffe, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1106,
+	0x1128, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x1f04, 0x5af3,
+	0x60c3, 0x0084, 0x080c, 0x5ed3, 0x00fe, 0x0005, 0x00f6, 0x7090,
+	0x9005, 0x01c0, 0x2011, 0x5ea9, 0x080c, 0x8651, 0x9086, 0x0084,
+	0x1178, 0x080c, 0x601e, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1106,
 	0x1138, 0x7834, 0x9005, 0x1120, 0x709b, 0x000c, 0x0029, 0x0010,
-	0x080c, 0x5fda, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x000d, 0x080c,
-	0x5f82, 0x2079, 0x0240, 0x7833, 0x1107, 0x7837, 0x0000, 0x080c,
-	0x5ffe, 0x20a9, 0x0040, 0x2011, 0x026e, 0x2009, 0x024e, 0x220e,
+	0x080c, 0x5ffa, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x000d, 0x080c,
+	0x5fa2, 0x2079, 0x0240, 0x7833, 0x1107, 0x7837, 0x0000, 0x080c,
+	0x601e, 0x20a9, 0x0040, 0x2011, 0x026e, 0x2009, 0x024e, 0x220e,
 	0x8210, 0x8108, 0x9186, 0x0260, 0x1150, 0x6810, 0x8000, 0x6812,
 	0x2009, 0x0240, 0x6814, 0x8000, 0x6816, 0x2011, 0x0260, 0x1f04,
-	0x5b17, 0x60c3, 0x0084, 0x080c, 0x5eb3, 0x00fe, 0x0005, 0x00f6,
-	0x7090, 0x9005, 0x01e0, 0x2011, 0x5e89, 0x080c, 0x861d, 0x9086,
-	0x0084, 0x1198, 0x080c, 0x5ffe, 0x2079, 0x0260, 0x7a30, 0x9296,
+	0x5b37, 0x60c3, 0x0084, 0x080c, 0x5ed3, 0x00fe, 0x0005, 0x00f6,
+	0x7090, 0x9005, 0x01e0, 0x2011, 0x5ea9, 0x080c, 0x8651, 0x9086,
+	0x0084, 0x1198, 0x080c, 0x601e, 0x2079, 0x0260, 0x7a30, 0x9296,
 	0x1107, 0x1158, 0x7834, 0x9005, 0x1140, 0x7097, 0x0001, 0x080c,
-	0x5f54, 0x709b, 0x000e, 0x0029, 0x0010, 0x080c, 0x5fda, 0x00fe,
-	0x0005, 0x918d, 0x0001, 0x080c, 0x6029, 0x709b, 0x000f, 0x7093,
+	0x5f74, 0x709b, 0x000e, 0x0029, 0x0010, 0x080c, 0x5ffa, 0x00fe,
+	0x0005, 0x918d, 0x0001, 0x080c, 0x6049, 0x709b, 0x000f, 0x7093,
 	0x0000, 0x2061, 0x0140, 0x605b, 0xbc85, 0x605f, 0xb5b5, 0x2061,
 	0x0100, 0x6043, 0x0005, 0x6043, 0x0004, 0x2009, 0x07d0, 0x2011,
-	0x5e89, 0x080c, 0x8611, 0x0005, 0x7090, 0x9005, 0x0130, 0x2011,
-	0x5e89, 0x080c, 0x861d, 0x709b, 0x0000, 0x0005, 0x709b, 0x0011,
-	0x080c, 0xa67d, 0x080c, 0x5ffe, 0x20e1, 0x0000, 0x2099, 0x0260,
+	0x5ea9, 0x080c, 0x8645, 0x0005, 0x7090, 0x9005, 0x0130, 0x2011,
+	0x5ea9, 0x080c, 0x8651, 0x709b, 0x0000, 0x0005, 0x709b, 0x0011,
+	0x080c, 0xa68e, 0x080c, 0x601e, 0x20e1, 0x0000, 0x2099, 0x0260,
 	0x20e9, 0x0000, 0x20a1, 0x0240, 0x7490, 0x9480, 0x0018, 0x9080,
-	0x0007, 0x9084, 0x03f8, 0x8004, 0x20a8, 0x4003, 0x080c, 0x5fe1,
+	0x0007, 0x9084, 0x03f8, 0x8004, 0x20a8, 0x4003, 0x080c, 0x6001,
 	0x11a0, 0x717c, 0x81ff, 0x0188, 0x900e, 0x7080, 0x9084, 0x00ff,
-	0x0160, 0x080c, 0x2614, 0x9186, 0x007e, 0x0138, 0x9186, 0x0080,
-	0x0120, 0x2011, 0x0008, 0x080c, 0x5e36, 0x60c3, 0x0014, 0x080c,
-	0x5eb3, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500, 0x2011, 0x5e89,
-	0x080c, 0x861d, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5ffe, 0x2079,
+	0x0160, 0x080c, 0x2630, 0x9186, 0x007e, 0x0138, 0x9186, 0x0080,
+	0x0120, 0x2011, 0x0008, 0x080c, 0x5e56, 0x60c3, 0x0014, 0x080c,
+	0x5ed3, 0x0005, 0x00f6, 0x7090, 0x9005, 0x0500, 0x2011, 0x5ea9,
+	0x080c, 0x8651, 0x9086, 0x0014, 0x11b8, 0x080c, 0x601e, 0x2079,
 	0x0260, 0x7a30, 0x9296, 0x1103, 0x1178, 0x7834, 0x9005, 0x1160,
 	0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001,
 	0x709b, 0x0012, 0x0029, 0x0010, 0x7093, 0x0000, 0x00fe, 0x0005,
-	0x00f6, 0x709b, 0x0013, 0x080c, 0x5f90, 0x2079, 0x0240, 0x7833,
-	0x1103, 0x7837, 0x0000, 0x080c, 0x5ffe, 0x080c, 0x5fe1, 0x1170,
+	0x00f6, 0x709b, 0x0013, 0x080c, 0x5fb0, 0x2079, 0x0240, 0x7833,
+	0x1103, 0x7837, 0x0000, 0x080c, 0x601e, 0x080c, 0x6001, 0x1170,
 	0x7084, 0x9005, 0x1158, 0x715c, 0x9186, 0xffff, 0x0138, 0x2011,
-	0x0008, 0x080c, 0x5e36, 0x0168, 0x080c, 0x5fb7, 0x20a9, 0x0008,
+	0x0008, 0x080c, 0x5e56, 0x0168, 0x080c, 0x5fd7, 0x20a9, 0x0008,
 	0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e,
-	0x4003, 0x60c3, 0x0014, 0x080c, 0x5eb3, 0x00fe, 0x0005, 0x00f6,
-	0x7090, 0x9005, 0x0500, 0x2011, 0x5e89, 0x080c, 0x861d, 0x9086,
-	0x0014, 0x11b8, 0x080c, 0x5ffe, 0x2079, 0x0260, 0x7a30, 0x9296,
+	0x4003, 0x60c3, 0x0014, 0x080c, 0x5ed3, 0x00fe, 0x0005, 0x00f6,
+	0x7090, 0x9005, 0x0500, 0x2011, 0x5ea9, 0x080c, 0x8651, 0x9086,
+	0x0014, 0x11b8, 0x080c, 0x601e, 0x2079, 0x0260, 0x7a30, 0x9296,
 	0x1104, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128,
 	0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x709b, 0x0014, 0x0029,
 	0x0010, 0x7093, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x709b, 0x0015,
-	0x080c, 0x5f90, 0x2079, 0x0240, 0x7833, 0x1104, 0x7837, 0x0000,
-	0x080c, 0x5ffe, 0x080c, 0x5fe1, 0x11b8, 0x7084, 0x9005, 0x11a0,
-	0x7164, 0x9186, 0xffff, 0x0180, 0x9180, 0x3368, 0x200d, 0x918c,
-	0xff00, 0x810f, 0x2011, 0x0008, 0x080c, 0x5e36, 0x0180, 0x080c,
-	0x4fdf, 0x0110, 0x080c, 0x267d, 0x20a9, 0x0008, 0x20e1, 0x0000,
+	0x080c, 0x5fb0, 0x2079, 0x0240, 0x7833, 0x1104, 0x7837, 0x0000,
+	0x080c, 0x601e, 0x080c, 0x6001, 0x11b8, 0x7084, 0x9005, 0x11a0,
+	0x7164, 0x9186, 0xffff, 0x0180, 0x9180, 0x3388, 0x200d, 0x918c,
+	0xff00, 0x810f, 0x2011, 0x0008, 0x080c, 0x5e56, 0x0180, 0x080c,
+	0x4fff, 0x0110, 0x080c, 0x2699, 0x20a9, 0x0008, 0x20e1, 0x0000,
 	0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3,
-	0x0014, 0x080c, 0x5eb3, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005,
-	0x05f0, 0x2011, 0x5e89, 0x080c, 0x861d, 0x9086, 0x0014, 0x15a8,
-	0x080c, 0x5ffe, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1105, 0x1568,
+	0x0014, 0x080c, 0x5ed3, 0x00fe, 0x0005, 0x00f6, 0x7090, 0x9005,
+	0x05f0, 0x2011, 0x5ea9, 0x080c, 0x8651, 0x9086, 0x0014, 0x15a8,
+	0x080c, 0x601e, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1105, 0x1568,
 	0x7834, 0x9084, 0x0100, 0x2011, 0x0100, 0x921e, 0x1168, 0x9085,
-	0x0001, 0x080c, 0x6029, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005,
+	0x0001, 0x080c, 0x6049, 0x7a38, 0xd2fc, 0x0128, 0x70c4, 0x9005,
 	0x1110, 0x70c7, 0x0001, 0x0080, 0x9005, 0x11b8, 0x7a38, 0xd2fc,
 	0x0128, 0x70c4, 0x9005, 0x1110, 0x70c7, 0x0001, 0x9085, 0x0001,
-	0x080c, 0x6029, 0x7097, 0x0000, 0x7a38, 0xd2f4, 0x0110, 0x70df,
+	0x080c, 0x6049, 0x7097, 0x0000, 0x7a38, 0xd2f4, 0x0110, 0x70df,
 	0x0008, 0x709b, 0x0016, 0x0029, 0x0010, 0x7093, 0x0000, 0x00fe,
-	0x0005, 0x080c, 0xa67d, 0x080c, 0x5ffe, 0x20e1, 0x0000, 0x2099,
+	0x0005, 0x080c, 0xa68e, 0x080c, 0x601e, 0x20e1, 0x0000, 0x2099,
 	0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000e, 0x4003,
 	0x2011, 0x026d, 0x2204, 0x9084, 0x0100, 0x2011, 0x024d, 0x2012,
-	0x2011, 0x026e, 0x709b, 0x0017, 0x080c, 0x5fe1, 0x1150, 0x7084,
-	0x9005, 0x1138, 0x080c, 0x5da9, 0x1188, 0x9085, 0x0001, 0x080c,
-	0x267d, 0x20a9, 0x0008, 0x080c, 0x5ffe, 0x20e1, 0x0000, 0x2099,
+	0x2011, 0x026e, 0x709b, 0x0017, 0x080c, 0x6001, 0x1150, 0x7084,
+	0x9005, 0x1138, 0x080c, 0x5dc9, 0x1188, 0x9085, 0x0001, 0x080c,
+	0x2699, 0x20a9, 0x0008, 0x080c, 0x601e, 0x20e1, 0x0000, 0x2099,
 	0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014,
-	0x080c, 0x5eb3, 0x0010, 0x080c, 0x5903, 0x0005, 0x00f6, 0x7090,
-	0x9005, 0x01d8, 0x2011, 0x5e89, 0x080c, 0x861d, 0x9086, 0x0084,
-	0x1190, 0x080c, 0x5ffe, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1106,
-	0x1150, 0x7834, 0x9005, 0x1138, 0x9006, 0x080c, 0x6029, 0x709b,
+	0x080c, 0x5ed3, 0x0010, 0x080c, 0x5923, 0x0005, 0x00f6, 0x7090,
+	0x9005, 0x01d8, 0x2011, 0x5ea9, 0x080c, 0x8651, 0x9086, 0x0084,
+	0x1190, 0x080c, 0x601e, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1106,
+	0x1150, 0x7834, 0x9005, 0x1138, 0x9006, 0x080c, 0x6049, 0x709b,
 	0x0018, 0x0029, 0x0010, 0x7093, 0x0000, 0x00fe, 0x0005, 0x00f6,
-	0x709b, 0x0019, 0x080c, 0x5f90, 0x2079, 0x0240, 0x7833, 0x1106,
-	0x7837, 0x0000, 0x080c, 0x5ffe, 0x2009, 0x026e, 0x2039, 0x1d0e,
+	0x709b, 0x0019, 0x080c, 0x5fb0, 0x2079, 0x0240, 0x7833, 0x1106,
+	0x7837, 0x0000, 0x080c, 0x601e, 0x2009, 0x026e, 0x2039, 0x1d0e,
 	0x20a9, 0x0040, 0x213e, 0x8738, 0x8108, 0x9186, 0x0280, 0x1128,
-	0x6814, 0x8000, 0x6816, 0x2009, 0x0260, 0x1f04, 0x5d12, 0x2039,
-	0x1d0e, 0x080c, 0x5fe1, 0x11e8, 0x2728, 0x2514, 0x8207, 0x9084,
+	0x6814, 0x8000, 0x6816, 0x2009, 0x0260, 0x1f04, 0x5d32, 0x2039,
+	0x1d0e, 0x080c, 0x6001, 0x11e8, 0x2728, 0x2514, 0x8207, 0x9084,
 	0x00ff, 0x8000, 0x2018, 0x9294, 0x00ff, 0x8007, 0x9205, 0x202a,
 	0x7060, 0x2310, 0x8214, 0x92a0, 0x1d0e, 0x2414, 0x938c, 0x0001,
 	0x0118, 0x9294, 0xff00, 0x0018, 0x9294, 0x00ff, 0x8007, 0x9215,
 	0x2222, 0x20a9, 0x0040, 0x2009, 0x024e, 0x270e, 0x8738, 0x8108,
 	0x9186, 0x0260, 0x1128, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240,
-	0x1f04, 0x5d45, 0x60c3, 0x0084, 0x080c, 0x5eb3, 0x00fe, 0x0005,
-	0x00f6, 0x7090, 0x9005, 0x01e0, 0x2011, 0x5e89, 0x080c, 0x861d,
-	0x9086, 0x0084, 0x1198, 0x080c, 0x5ffe, 0x2079, 0x0260, 0x7a30,
+	0x1f04, 0x5d65, 0x60c3, 0x0084, 0x080c, 0x5ed3, 0x00fe, 0x0005,
+	0x00f6, 0x7090, 0x9005, 0x01e0, 0x2011, 0x5ea9, 0x080c, 0x8651,
+	0x9086, 0x0084, 0x1198, 0x080c, 0x601e, 0x2079, 0x0260, 0x7a30,
 	0x9296, 0x1107, 0x1158, 0x7834, 0x9005, 0x1140, 0x7097, 0x0001,
-	0x080c, 0x5f54, 0x709b, 0x001a, 0x0029, 0x0010, 0x7093, 0x0000,
-	0x00fe, 0x0005, 0x9085, 0x0001, 0x080c, 0x6029, 0x709b, 0x001b,
-	0x080c, 0xa67d, 0x080c, 0x5ffe, 0x2011, 0x0260, 0x2009, 0x0240,
+	0x080c, 0x5f74, 0x709b, 0x001a, 0x0029, 0x0010, 0x7093, 0x0000,
+	0x00fe, 0x0005, 0x9085, 0x0001, 0x080c, 0x6049, 0x709b, 0x001b,
+	0x080c, 0xa68e, 0x080c, 0x601e, 0x2011, 0x0260, 0x2009, 0x0240,
 	0x7490, 0x9480, 0x0018, 0x9080, 0x0007, 0x9084, 0x03f8, 0x8004,
 	0x20a8, 0x220e, 0x8210, 0x8108, 0x9186, 0x0260, 0x1150, 0x6810,
 	0x8000, 0x6812, 0x2009, 0x0240, 0x6814, 0x8000, 0x6816, 0x2011,
-	0x0260, 0x1f04, 0x5d91, 0x60c3, 0x0084, 0x080c, 0x5eb3, 0x0005,
+	0x0260, 0x1f04, 0x5db1, 0x60c3, 0x0084, 0x080c, 0x5ed3, 0x0005,
 	0x0005, 0x0086, 0x0096, 0x2029, 0x1848, 0x252c, 0x20a9, 0x0008,
-	0x2041, 0x1d0e, 0x20e9, 0x0001, 0x28a0, 0x080c, 0x5ffe, 0x20e1,
+	0x2041, 0x1d0e, 0x20e9, 0x0001, 0x28a0, 0x080c, 0x601e, 0x20e1,
 	0x0000, 0x2099, 0x026e, 0x4003, 0x20a9, 0x0008, 0x2011, 0x0007,
 	0xd5d4, 0x0108, 0x9016, 0x2800, 0x9200, 0x200c, 0x91a6, 0xffff,
-	0x1148, 0xd5d4, 0x0110, 0x8210, 0x0008, 0x8211, 0x1f04, 0x5dc3,
-	0x0804, 0x5e32, 0x82ff, 0x1160, 0xd5d4, 0x0120, 0x91a6, 0x3fff,
-	0x0d90, 0x0020, 0x91a6, 0x3fff, 0x0904, 0x5e32, 0x918d, 0xc000,
+	0x1148, 0xd5d4, 0x0110, 0x8210, 0x0008, 0x8211, 0x1f04, 0x5de3,
+	0x0804, 0x5e52, 0x82ff, 0x1160, 0xd5d4, 0x0120, 0x91a6, 0x3fff,
+	0x0d90, 0x0020, 0x91a6, 0x3fff, 0x0904, 0x5e52, 0x918d, 0xc000,
 	0x20a9, 0x0010, 0x2019, 0x0001, 0xd5d4, 0x0110, 0x2019, 0x0010,
 	0x2120, 0xd5d4, 0x0110, 0x8423, 0x0008, 0x8424, 0x1240, 0xd5d4,
-	0x0110, 0x8319, 0x0008, 0x8318, 0x1f04, 0x5de9, 0x04d8, 0x23a8,
-	0x2021, 0x0001, 0x8426, 0x8425, 0x1f04, 0x5dfb, 0x2328, 0x8529,
+	0x0110, 0x8319, 0x0008, 0x8318, 0x1f04, 0x5e09, 0x04d8, 0x23a8,
+	0x2021, 0x0001, 0x8426, 0x8425, 0x1f04, 0x5e1b, 0x2328, 0x8529,
 	0x92be, 0x0007, 0x0158, 0x0006, 0x2039, 0x0007, 0x2200, 0x973a,
-	0x000e, 0x27a8, 0x95a8, 0x0010, 0x1f04, 0x5e0a, 0x755e, 0x95c8,
-	0x3368, 0x292d, 0x95ac, 0x00ff, 0x7582, 0x6532, 0x6536, 0x0016,
-	0x2508, 0x080c, 0x265d, 0x001e, 0x60e7, 0x0000, 0x65ea, 0x2018,
+	0x000e, 0x27a8, 0x95a8, 0x0010, 0x1f04, 0x5e2a, 0x755e, 0x95c8,
+	0x3388, 0x292d, 0x95ac, 0x00ff, 0x7582, 0x6532, 0x6536, 0x0016,
+	0x2508, 0x080c, 0x2679, 0x001e, 0x60e7, 0x0000, 0x65ea, 0x2018,
 	0x2304, 0x9405, 0x201a, 0x7087, 0x0001, 0x20e9, 0x0000, 0x20a1,
 	0x024e, 0x20e1, 0x0001, 0x2898, 0x20a9, 0x0008, 0x4003, 0x9085,
 	0x0001, 0x0008, 0x9006, 0x009e, 0x008e, 0x0005, 0x0156, 0x01c6,
@@ -2815,53 +2819,53 @@
 	0x0010, 0x0218, 0x8420, 0x8001, 0x0cd0, 0x2118, 0x84ff, 0x0120,
 	0x939a, 0x0010, 0x8421, 0x1de0, 0x2021, 0x0001, 0x83ff, 0x0118,
 	0x8423, 0x8319, 0x1de8, 0x9238, 0x2029, 0x026e, 0x9528, 0x2504,
-	0x942c, 0x11b8, 0x9405, 0x203a, 0x715e, 0x91a0, 0x3368, 0x242d,
+	0x942c, 0x11b8, 0x9405, 0x203a, 0x715e, 0x91a0, 0x3388, 0x242d,
 	0x95ac, 0x00ff, 0x7582, 0x6532, 0x6536, 0x0016, 0x2508, 0x080c,
-	0x265d, 0x001e, 0x60e7, 0x0000, 0x65ea, 0x7087, 0x0001, 0x9084,
+	0x2679, 0x001e, 0x60e7, 0x0000, 0x65ea, 0x7087, 0x0001, 0x9084,
 	0x0000, 0x0005, 0x00e6, 0x2071, 0x1800, 0x708b, 0x0000, 0x00ee,
 	0x0005, 0x00e6, 0x00f6, 0x2079, 0x0100, 0x2071, 0x0140, 0x080c,
-	0x5f43, 0x080c, 0x9e16, 0x7004, 0x9084, 0x4000, 0x0110, 0x080c,
-	0x2a39, 0x0126, 0x2091, 0x8000, 0x2071, 0x1826, 0x2073, 0x0000,
-	0x7840, 0x0026, 0x0016, 0x2009, 0x00f7, 0x080c, 0x5fa0, 0x001e,
+	0x5f63, 0x080c, 0x9e4f, 0x7004, 0x9084, 0x4000, 0x0110, 0x080c,
+	0x2a59, 0x0126, 0x2091, 0x8000, 0x2071, 0x1826, 0x2073, 0x0000,
+	0x7840, 0x0026, 0x0016, 0x2009, 0x00f7, 0x080c, 0x5fc0, 0x001e,
 	0x9094, 0x0010, 0x9285, 0x0080, 0x7842, 0x7a42, 0x002e, 0x012e,
-	0x00fe, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x2998,
+	0x00fe, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x29b4,
 	0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012, 0x2011, 0x19f3,
 	0x2013, 0x0000, 0x7093, 0x0000, 0x012e, 0x60a3, 0x0056, 0x60a7,
-	0x9575, 0x080c, 0x9e09, 0x6144, 0xd184, 0x0120, 0x7198, 0x918d,
+	0x9575, 0x080c, 0x9e42, 0x6144, 0xd184, 0x0120, 0x7198, 0x918d,
 	0x2000, 0x0018, 0x718c, 0x918d, 0x1000, 0x2011, 0x1998, 0x2112,
-	0x2009, 0x07d0, 0x2011, 0x5e89, 0x080c, 0x86e7, 0x0005, 0x0016,
-	0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xa888, 0x080c,
-	0xab50, 0x080c, 0xa8a4, 0x2009, 0x00f7, 0x080c, 0x5fa0, 0x2061,
+	0x2009, 0x07d0, 0x2011, 0x5ea9, 0x080c, 0x871b, 0x0005, 0x0016,
+	0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xa899, 0x080c,
+	0xab61, 0x080c, 0xa8b5, 0x2009, 0x00f7, 0x080c, 0x5fc0, 0x2061,
 	0x1a02, 0x900e, 0x611a, 0x611e, 0x6172, 0x6176, 0x2061, 0x1800,
 	0x6003, 0x0001, 0x2061, 0x0100, 0x6043, 0x0090, 0x6043, 0x0010,
-	0x2009, 0x1998, 0x200b, 0x0000, 0x2009, 0x002d, 0x2011, 0x5f0f,
-	0x080c, 0x8611, 0x012e, 0x00ce, 0x002e, 0x001e, 0x0005, 0x00e6,
+	0x2009, 0x1998, 0x200b, 0x0000, 0x2009, 0x002d, 0x2011, 0x5f2f,
+	0x080c, 0x8645, 0x012e, 0x00ce, 0x002e, 0x001e, 0x0005, 0x00e6,
 	0x0006, 0x0126, 0x2091, 0x8000, 0x0471, 0x2071, 0x0100, 0x080c,
-	0x9e16, 0x2071, 0x0140, 0x7004, 0x9084, 0x4000, 0x0110, 0x080c,
-	0x2a39, 0x080c, 0x74d0, 0x0188, 0x080c, 0x74eb, 0x1170, 0x080c,
-	0x77d6, 0x0016, 0x080c, 0x272c, 0x2001, 0x196c, 0x2102, 0x001e,
-	0x080c, 0x77d1, 0x080c, 0x73f9, 0x0050, 0x2009, 0x0001, 0x080c,
-	0x2a15, 0x2001, 0x0001, 0x080c, 0x25b9, 0x080c, 0x5edf, 0x012e,
+	0x9e4f, 0x2071, 0x0140, 0x7004, 0x9084, 0x4000, 0x0110, 0x080c,
+	0x2a59, 0x080c, 0x74f4, 0x0188, 0x080c, 0x750f, 0x1170, 0x080c,
+	0x77f9, 0x0016, 0x080c, 0x2748, 0x2001, 0x196c, 0x2102, 0x001e,
+	0x080c, 0x77f4, 0x080c, 0x741d, 0x0050, 0x2009, 0x0001, 0x080c,
+	0x2a35, 0x2001, 0x0001, 0x080c, 0x25d5, 0x080c, 0x5eff, 0x012e,
 	0x000e, 0x00ee, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0bc, 0x0158,
 	0x0026, 0x0036, 0x2011, 0x8017, 0x2001, 0x1998, 0x201c, 0x080c,
-	0x4b09, 0x003e, 0x002e, 0x0005, 0x20a9, 0x0012, 0x20e9, 0x0001,
-	0x20a1, 0x1d80, 0x080c, 0x5ffe, 0x20e9, 0x0000, 0x2099, 0x026e,
-	0x0099, 0x20a9, 0x0020, 0x080c, 0x5ff8, 0x2099, 0x0260, 0x20a1,
-	0x1d92, 0x0051, 0x20a9, 0x000e, 0x080c, 0x5ffb, 0x2099, 0x0260,
+	0x4b29, 0x003e, 0x002e, 0x0005, 0x20a9, 0x0012, 0x20e9, 0x0001,
+	0x20a1, 0x1d80, 0x080c, 0x601e, 0x20e9, 0x0000, 0x2099, 0x026e,
+	0x0099, 0x20a9, 0x0020, 0x080c, 0x6018, 0x2099, 0x0260, 0x20a1,
+	0x1d92, 0x0051, 0x20a9, 0x000e, 0x080c, 0x601b, 0x2099, 0x0260,
 	0x20a1, 0x1db2, 0x0009, 0x0005, 0x0016, 0x0026, 0x3410, 0x3308,
-	0x2104, 0x8007, 0x2012, 0x8108, 0x8210, 0x1f04, 0x5f78, 0x002e,
-	0x001e, 0x0005, 0x080c, 0xa67d, 0x20e1, 0x0001, 0x2099, 0x1d00,
+	0x2104, 0x8007, 0x2012, 0x8108, 0x8210, 0x1f04, 0x5f98, 0x002e,
+	0x001e, 0x0005, 0x080c, 0xa68e, 0x20e1, 0x0001, 0x2099, 0x1d00,
 	0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003, 0x0005,
-	0x080c, 0xa67d, 0x080c, 0x5ffe, 0x20e1, 0x0000, 0x2099, 0x0260,
+	0x080c, 0xa68e, 0x080c, 0x601e, 0x20e1, 0x0000, 0x2099, 0x0260,
 	0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003, 0x0005,
 	0x00c6, 0x0006, 0x2061, 0x0100, 0x810f, 0x2001, 0x1834, 0x2004,
 	0x9005, 0x1138, 0x2001, 0x1818, 0x2004, 0x9084, 0x00ff, 0x9105,
 	0x0010, 0x9185, 0x00f7, 0x604a, 0x000e, 0x00ce, 0x0005, 0x0016,
-	0x0046, 0x080c, 0x6a66, 0x0158, 0x9006, 0x2020, 0x2009, 0x002a,
-	0x080c, 0xe2d9, 0x2001, 0x180c, 0x200c, 0xc195, 0x2102, 0x2019,
-	0x002a, 0x900e, 0x080c, 0x31b4, 0x080c, 0xcf51, 0x0140, 0x0036,
-	0x2019, 0xffff, 0x2021, 0x0007, 0x080c, 0x4cc0, 0x003e, 0x004e,
-	0x001e, 0x0005, 0x080c, 0x5edf, 0x709b, 0x0000, 0x7093, 0x0000,
+	0x0046, 0x080c, 0x6a8a, 0x0158, 0x9006, 0x2020, 0x2009, 0x002a,
+	0x080c, 0xe316, 0x2001, 0x180c, 0x200c, 0xc195, 0x2102, 0x2019,
+	0x002a, 0x900e, 0x080c, 0x31d4, 0x080c, 0xcf84, 0x0140, 0x0036,
+	0x2019, 0xffff, 0x2021, 0x0007, 0x080c, 0x4ce0, 0x003e, 0x004e,
+	0x001e, 0x0005, 0x080c, 0x5eff, 0x709b, 0x0000, 0x7093, 0x0000,
 	0x0005, 0x0006, 0x2001, 0x180c, 0x2004, 0xd09c, 0x0100, 0x000e,
 	0x0005, 0x0006, 0x0016, 0x0126, 0x2091, 0x8000, 0x2001, 0x0101,
 	0x200c, 0x918d, 0x0006, 0x2102, 0x012e, 0x001e, 0x000e, 0x0005,
@@ -2873,29 +2877,29 @@
 	0x014e, 0x015e, 0x00fe, 0x0005, 0x2001, 0x1800, 0x2003, 0x0001,
 	0x0005, 0x2001, 0x19a5, 0x0118, 0x2003, 0x0001, 0x0010, 0x2003,
 	0x0000, 0x0005, 0x0156, 0x20a9, 0x0800, 0x2009, 0x1000, 0x9006,
-	0x200a, 0x8108, 0x1f04, 0x6038, 0x015e, 0x0005, 0x00d6, 0x0036,
+	0x200a, 0x8108, 0x1f04, 0x6058, 0x015e, 0x0005, 0x00d6, 0x0036,
 	0x0156, 0x0136, 0x0146, 0x2069, 0x1847, 0x9006, 0xb802, 0xb8d6,
-	0xb807, 0x0707, 0xb80a, 0xb80e, 0xb812, 0x9198, 0x3368, 0x231d,
-	0x939c, 0x00ff, 0xbb16, 0x0016, 0x0026, 0xb886, 0x080c, 0xab49,
+	0xb807, 0x0707, 0xb80a, 0xb80e, 0xb812, 0x9198, 0x3388, 0x231d,
+	0x939c, 0x00ff, 0xbb16, 0x0016, 0x0026, 0xb886, 0x080c, 0xab5a,
 	0x1120, 0x9192, 0x007e, 0x1208, 0xbb86, 0x20a9, 0x0004, 0xb8c4,
 	0x20e8, 0xb9c8, 0x9198, 0x0006, 0x9006, 0x23a0, 0x4004, 0x20a9,
 	0x0004, 0x9198, 0x000a, 0x23a0, 0x4004, 0x002e, 0x001e, 0xb83e,
 	0xb842, 0xb8ce, 0xb8d2, 0xb85e, 0xb862, 0xb866, 0xb86a, 0xb86f,
 	0x0100, 0xb872, 0xb876, 0xb87a, 0xb88a, 0xb88e, 0xb893, 0x0008,
 	0xb896, 0xb89a, 0xb89e, 0xb8be, 0xb9a2, 0x0096, 0xb8a4, 0x904d,
-	0x0110, 0x080c, 0x106c, 0xb8a7, 0x0000, 0x009e, 0x9006, 0xb84a,
+	0x0110, 0x080c, 0x1079, 0xb8a7, 0x0000, 0x009e, 0x9006, 0xb84a,
 	0x6810, 0xb83a, 0x680c, 0xb846, 0xb8bb, 0x0520, 0xb8ac, 0x9005,
 	0x0198, 0x00c6, 0x2060, 0x9c82, 0x1ddc, 0x0a0c, 0x0d7d, 0x2001,
-	0x181a, 0x2004, 0x9c02, 0x1a0c, 0x0d7d, 0x080c, 0x8b72, 0x00ce,
-	0x090c, 0x8f16, 0xb8af, 0x0000, 0x6814, 0x9084, 0x00ff, 0xb842,
+	0x181a, 0x2004, 0x9c02, 0x1a0c, 0x0d7d, 0x080c, 0x8ba9, 0x00ce,
+	0x090c, 0x8f4f, 0xb8af, 0x0000, 0x6814, 0x9084, 0x00ff, 0xb842,
 	0x014e, 0x013e, 0x015e, 0x003e, 0x00de, 0x0005, 0x0126, 0x2091,
 	0x8000, 0xa974, 0xae78, 0x9684, 0x3fff, 0x9082, 0x4000, 0x1a04,
-	0x6114, 0x9182, 0x0800, 0x1a04, 0x6118, 0x2001, 0x180c, 0x2004,
-	0x9084, 0x0003, 0x1904, 0x611e, 0x9188, 0x1000, 0x2104, 0x905d,
+	0x6134, 0x9182, 0x0800, 0x1a04, 0x6138, 0x2001, 0x180c, 0x2004,
+	0x9084, 0x0003, 0x1904, 0x613e, 0x9188, 0x1000, 0x2104, 0x905d,
 	0x0198, 0xb804, 0x9084, 0x00ff, 0x908e, 0x0006, 0x1188, 0xb8a4,
-	0x900d, 0x1904, 0x6130, 0x080c, 0x64e9, 0x9006, 0x012e, 0x0005,
+	0x900d, 0x1904, 0x6150, 0x080c, 0x650d, 0x9006, 0x012e, 0x0005,
 	0x2001, 0x0005, 0x900e, 0x04b8, 0x2001, 0x0028, 0x900e, 0x0498,
-	0x9082, 0x0006, 0x1290, 0x080c, 0xab49, 0x1160, 0xb8a0, 0x9084,
+	0x9082, 0x0006, 0x1290, 0x080c, 0xab5a, 0x1160, 0xb8a0, 0x9084,
 	0xff80, 0x1140, 0xb900, 0xd1fc, 0x0d10, 0x2001, 0x0029, 0x2009,
 	0x1000, 0x0408, 0x2001, 0x0028, 0x00a8, 0x2009, 0x180c, 0x210c,
 	0xd18c, 0x0118, 0x2001, 0x0004, 0x0068, 0xd184, 0x0118, 0x2001,
@@ -2903,31 +2907,31 @@
 	0x1000, 0x0048, 0x900e, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018,
 	0x2001, 0x0029, 0x900e, 0x9005, 0x012e, 0x0005, 0x2001, 0x180c,
 	0x2004, 0xd084, 0x19d0, 0x9188, 0x1000, 0x2104, 0x9065, 0x09a8,
-	0x080c, 0x6a6a, 0x1990, 0xb800, 0xd0bc, 0x0978, 0x0804, 0x60d7,
-	0x080c, 0x688f, 0x0904, 0x60e0, 0x0804, 0x60db, 0x00e6, 0x2071,
+	0x080c, 0x6a8e, 0x1990, 0xb800, 0xd0bc, 0x0978, 0x0804, 0x60f7,
+	0x080c, 0x68b3, 0x0904, 0x6100, 0x0804, 0x60fb, 0x00e6, 0x2071,
 	0x19e6, 0x7004, 0x9086, 0x0002, 0x1128, 0x7030, 0x9080, 0x0004,
 	0x2004, 0x9b06, 0x00ee, 0x0005, 0x00b6, 0x00e6, 0x0126, 0x2091,
 	0x8000, 0xa874, 0x908e, 0x00ff, 0x1120, 0x2001, 0x196a, 0x205c,
 	0x0060, 0xa974, 0x9182, 0x0800, 0x1690, 0x9188, 0x1000, 0x2104,
-	0x905d, 0x01d0, 0x080c, 0x6a0a, 0x11d0, 0x080c, 0xab89, 0x0570,
+	0x905d, 0x01d0, 0x080c, 0x6a2e, 0x11d0, 0x080c, 0xab9a, 0x0570,
 	0x2b00, 0x6012, 0x2900, 0x6016, 0x6023, 0x0009, 0x602b, 0x0000,
 	0xa874, 0x908e, 0x00ff, 0x1110, 0x602b, 0x8000, 0x2009, 0x0043,
-	0x080c, 0xac7c, 0x9006, 0x00b0, 0x2001, 0x0028, 0x0090, 0x2009,
+	0x080c, 0xac8d, 0x9006, 0x00b0, 0x2001, 0x0028, 0x0090, 0x2009,
 	0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184,
 	0x0118, 0x2001, 0x0004, 0x0010, 0x2001, 0x0029, 0x0010, 0x2001,
 	0x0029, 0x9005, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2001, 0x002c,
 	0x0cc0, 0x00b6, 0x00e6, 0x0126, 0x2091, 0x8000, 0xa974, 0x9182,
-	0x0800, 0x1a04, 0x620c, 0x9188, 0x1000, 0x2104, 0x905d, 0x0904,
-	0x61e4, 0xb8a0, 0x9086, 0x007f, 0x0178, 0x080c, 0x6a72, 0x0160,
+	0x0800, 0x1a04, 0x622c, 0x9188, 0x1000, 0x2104, 0x905d, 0x0904,
+	0x6204, 0xb8a0, 0x9086, 0x007f, 0x0178, 0x080c, 0x6a96, 0x0160,
 	0xa994, 0x81ff, 0x0130, 0x908e, 0x0004, 0x0130, 0x908e, 0x0005,
-	0x0118, 0x080c, 0x6a6a, 0x1598, 0xa87c, 0xd0fc, 0x01e0, 0xa894,
-	0x9005, 0x01c8, 0x2060, 0x0026, 0x2010, 0x080c, 0xc820, 0x002e,
-	0x1120, 0x2001, 0x0008, 0x0804, 0x620e, 0x6020, 0x9086, 0x000a,
-	0x0120, 0x2001, 0x0008, 0x0804, 0x620e, 0x601a, 0x6003, 0x0008,
-	0x2900, 0x6016, 0x0058, 0x080c, 0xab89, 0x05e8, 0x2b00, 0x6012,
+	0x0118, 0x080c, 0x6a8e, 0x1598, 0xa87c, 0xd0fc, 0x01e0, 0xa894,
+	0x9005, 0x01c8, 0x2060, 0x0026, 0x2010, 0x080c, 0xc853, 0x002e,
+	0x1120, 0x2001, 0x0008, 0x0804, 0x622e, 0x6020, 0x9086, 0x000a,
+	0x0120, 0x2001, 0x0008, 0x0804, 0x622e, 0x601a, 0x6003, 0x0008,
+	0x2900, 0x6016, 0x0058, 0x080c, 0xab9a, 0x05e8, 0x2b00, 0x6012,
 	0x2900, 0x6016, 0x600b, 0xffff, 0x6023, 0x000a, 0x2009, 0x0003,
-	0x080c, 0xac7c, 0x9006, 0x0458, 0x2001, 0x0028, 0x0438, 0x9082,
-	0x0006, 0x1290, 0x080c, 0xab49, 0x1160, 0xb8a0, 0x9084, 0xff80,
+	0x080c, 0xac8d, 0x9006, 0x0458, 0x2001, 0x0028, 0x0438, 0x9082,
+	0x0006, 0x1290, 0x080c, 0xab5a, 0x1160, 0xb8a0, 0x9084, 0xff80,
 	0x1140, 0xb900, 0xd1fc, 0x0900, 0x2001, 0x0029, 0x2009, 0x1000,
 	0x00a8, 0x2001, 0x0028, 0x0090, 0x2009, 0x180c, 0x210c, 0xd18c,
 	0x0118, 0x2001, 0x0004, 0x0050, 0xd184, 0x0118, 0x2001, 0x0004,
@@ -2940,2841 +2944,2841 @@
 	0x00ea, 0x7930, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184,
 	0x0118, 0x2001, 0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0038,
 	0x2001, 0x002c, 0x900e, 0x0018, 0x2001, 0x0029, 0x900e, 0x9006,
-	0x0008, 0x9005, 0x012e, 0x00be, 0x00fe, 0x0005, 0x62a3, 0x625e,
-	0x6275, 0x62a3, 0x62a3, 0x62a3, 0x62a3, 0x62a3, 0x2100, 0x9082,
-	0x007e, 0x1278, 0x080c, 0x65bf, 0x0148, 0x9046, 0xb810, 0x9306,
-	0x1904, 0x62ab, 0xb814, 0x9206, 0x15f0, 0x0028, 0xbb12, 0xba16,
-	0x0010, 0x080c, 0x49bc, 0x0150, 0x04b0, 0x080c, 0x6620, 0x1598,
-	0xb810, 0x9306, 0x1580, 0xb814, 0x9206, 0x1568, 0x080c, 0xab89,
-	0x0530, 0x2b00, 0x6012, 0x080c, 0xcccb, 0x2900, 0x6016, 0x600b,
+	0x0008, 0x9005, 0x012e, 0x00be, 0x00fe, 0x0005, 0x62c3, 0x627e,
+	0x6295, 0x62c3, 0x62c3, 0x62c3, 0x62c3, 0x62c3, 0x2100, 0x9082,
+	0x007e, 0x1278, 0x080c, 0x65e3, 0x0148, 0x9046, 0xb810, 0x9306,
+	0x1904, 0x62cb, 0xb814, 0x9206, 0x15f0, 0x0028, 0xbb12, 0xba16,
+	0x0010, 0x080c, 0x49dc, 0x0150, 0x04b0, 0x080c, 0x6644, 0x1598,
+	0xb810, 0x9306, 0x1580, 0xb814, 0x9206, 0x1568, 0x080c, 0xab9a,
+	0x0530, 0x2b00, 0x6012, 0x080c, 0xccfe, 0x2900, 0x6016, 0x600b,
 	0xffff, 0x6023, 0x000a, 0xa878, 0x9086, 0x0001, 0x1170, 0x080c,
-	0x31ef, 0x9006, 0x080c, 0x655c, 0x2001, 0x0002, 0x080c, 0x6570,
+	0x320f, 0x9006, 0x080c, 0x6580, 0x2001, 0x0002, 0x080c, 0x6594,
 	0x2001, 0x0200, 0xb86e, 0xb893, 0x0002, 0x2009, 0x0003, 0x080c,
-	0xac7c, 0x9006, 0x0068, 0x2001, 0x0001, 0x900e, 0x0038, 0x2001,
+	0xac8d, 0x9006, 0x0068, 0x2001, 0x0001, 0x900e, 0x0038, 0x2001,
 	0x002c, 0x900e, 0x0018, 0x2001, 0x0028, 0x900e, 0x9005, 0x0000,
 	0x012e, 0x00be, 0x00fe, 0x0005, 0x00b6, 0x00f6, 0x00e6, 0x0126,
-	0x2091, 0x8000, 0xa894, 0x90c6, 0x0015, 0x0904, 0x6492, 0x90c6,
-	0x0056, 0x0904, 0x6496, 0x90c6, 0x0066, 0x0904, 0x649a, 0x90c6,
-	0x0067, 0x0904, 0x649e, 0x90c6, 0x0068, 0x0904, 0x64a2, 0x90c6,
-	0x0071, 0x0904, 0x64a6, 0x90c6, 0x0074, 0x0904, 0x64aa, 0x90c6,
-	0x007c, 0x0904, 0x64ae, 0x90c6, 0x007e, 0x0904, 0x64b2, 0x90c6,
-	0x0037, 0x0904, 0x64b6, 0x9016, 0x2079, 0x1800, 0xa974, 0x9186,
-	0x00ff, 0x0904, 0x648d, 0x9182, 0x0800, 0x1a04, 0x648d, 0x080c,
-	0x6620, 0x1198, 0xb804, 0x9084, 0x00ff, 0x9082, 0x0006, 0x1268,
-	0xa894, 0x90c6, 0x006f, 0x0148, 0x080c, 0xab49, 0x1904, 0x6476,
-	0xb8a0, 0x9084, 0xff80, 0x1904, 0x6476, 0xa894, 0x90c6, 0x006f,
-	0x0158, 0x90c6, 0x005e, 0x0904, 0x63d6, 0x90c6, 0x0064, 0x0904,
-	0x63ff, 0x2008, 0x0804, 0x6398, 0xa998, 0xa8b0, 0x2040, 0x080c,
-	0xab49, 0x1120, 0x9182, 0x007f, 0x0a04, 0x6398, 0x9186, 0x00ff,
-	0x0904, 0x6398, 0x9182, 0x0800, 0x1a04, 0x6398, 0xaaa0, 0xab9c,
-	0x787c, 0x9306, 0x1188, 0x7880, 0x0096, 0x924e, 0x1128, 0x2208,
-	0x2310, 0x009e, 0x0804, 0x6398, 0x99cc, 0xff00, 0x009e, 0x1120,
-	0x2208, 0x2310, 0x0804, 0x6398, 0x080c, 0x49bc, 0x0904, 0x63a2,
-	0x900e, 0x9016, 0x90c6, 0x4000, 0x15e0, 0x0006, 0x080c, 0x6913,
-	0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x20a9, 0x0004,
-	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031, 0x20a0, 0xb8c4, 0x20e0,
-	0xb8c8, 0x9080, 0x0006, 0x2098, 0x080c, 0x0fb7, 0x20a9, 0x0004,
-	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0035, 0x20a0, 0xb8c4, 0x20e0,
-	0xb8c8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0fb7, 0xa8c4, 0xabc8,
-	0x9305, 0xabcc, 0x9305, 0xabd0, 0x9305, 0xabd4, 0x9305, 0xabd8,
-	0x9305, 0xabdc, 0x9305, 0xabe0, 0x9305, 0x9005, 0x0510, 0x000e,
-	0x00c8, 0x90c6, 0x4007, 0x1110, 0x2408, 0x00a0, 0x90c6, 0x4008,
-	0x1118, 0x2708, 0x2610, 0x0070, 0x90c6, 0x4009, 0x1108, 0x0050,
-	0x90c6, 0x4006, 0x0138, 0x2001, 0x4005, 0x2009, 0x000a, 0x0010,
-	0x2001, 0x4006, 0xa896, 0xa99a, 0xaa9e, 0x2001, 0x0030, 0x900e,
-	0x0478, 0x000e, 0x080c, 0xab89, 0x1130, 0x2001, 0x4005, 0x2009,
-	0x0003, 0x9016, 0x0c78, 0x2b00, 0x6012, 0x080c, 0xcccb, 0x2900,
-	0x6016, 0x6023, 0x0001, 0xa868, 0xd88c, 0x0108, 0xc0f5, 0xa86a,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x31ef, 0x012e, 0x9006, 0x080c,
-	0x655c, 0x2001, 0x0002, 0x080c, 0x6570, 0x2009, 0x0002, 0x080c,
-	0xac7c, 0xa8b0, 0xd094, 0x0118, 0xb8d4, 0xc08d, 0xb8d6, 0x9006,
-	0x9005, 0x012e, 0x00ee, 0x00fe, 0x00be, 0x0005, 0x080c, 0x56e9,
-	0x0118, 0x2009, 0x0007, 0x00f8, 0xa998, 0xaeb0, 0x080c, 0x6620,
-	0x1904, 0x6393, 0x9186, 0x007f, 0x0130, 0x080c, 0x6a6a, 0x0118,
-	0x2009, 0x0009, 0x0080, 0x0096, 0x080c, 0x103a, 0x1120, 0x009e,
-	0x2009, 0x0002, 0x0040, 0x2900, 0x009e, 0xa806, 0x080c, 0xca1e,
-	0x19b0, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804, 0x639a, 0xa998,
-	0xaeb0, 0x080c, 0x6620, 0x1904, 0x6393, 0x0096, 0x080c, 0x103a,
-	0x1128, 0x009e, 0x2009, 0x0002, 0x0804, 0x6453, 0x2900, 0x009e,
-	0xa806, 0x0096, 0x2048, 0x20a9, 0x002b, 0xb8c4, 0x20e0, 0xb8c8,
-	0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003,
-	0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0, 0xbbc8, 0x9398, 0x0006,
-	0x2398, 0x080c, 0x0fb7, 0x009e, 0xa87b, 0x0000, 0xa883, 0x0000,
-	0xa897, 0x4000, 0xd684, 0x1168, 0x080c, 0x56d5, 0xd0b4, 0x1118,
-	0xa89b, 0x000b, 0x00e0, 0xb800, 0xd08c, 0x0118, 0xa89b, 0x000c,
-	0x00b0, 0x080c, 0x6a6a, 0x0118, 0xa89b, 0x0009, 0x0080, 0x080c,
-	0x56e9, 0x0118, 0xa89b, 0x0007, 0x0050, 0x080c, 0xca01, 0x1904,
-	0x63cf, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804, 0x639a, 0xa87b,
-	0x0030, 0xa897, 0x4005, 0xa804, 0x8006, 0x8006, 0x8007, 0x90bc,
-	0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009, 0x002b, 0xaaa0,
-	0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x1289, 0x080c,
-	0xb103, 0x1904, 0x63cf, 0x2009, 0x0002, 0x08e8, 0x2001, 0x0028,
-	0x900e, 0x0804, 0x63d0, 0x2009, 0x180c, 0x210c, 0xd18c, 0x0118,
-	0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004, 0x0010,
-	0x2001, 0x0029, 0x900e, 0x0804, 0x63d0, 0x2001, 0x0029, 0x900e,
-	0x0804, 0x63d0, 0x080c, 0x3796, 0x0804, 0x63d1, 0x080c, 0x540a,
-	0x0804, 0x63d1, 0x080c, 0x4572, 0x0804, 0x63d1, 0x080c, 0x45eb,
-	0x0804, 0x63d1, 0x080c, 0x4647, 0x0804, 0x63d1, 0x080c, 0x4a7f,
-	0x0804, 0x63d1, 0x080c, 0x4d2f, 0x0804, 0x63d1, 0x080c, 0x5075,
-	0x0804, 0x63d1, 0x080c, 0x526e, 0x0804, 0x63d1, 0x080c, 0x39b4,
-	0x0804, 0x63d1, 0x00b6, 0xa974, 0xae78, 0x9684, 0x3fff, 0x9082,
-	0x4000, 0x1608, 0x9182, 0x0800, 0x1258, 0x9188, 0x1000, 0x2104,
-	0x905d, 0x0130, 0x080c, 0x6a6a, 0x1138, 0x00d9, 0x9006, 0x00b0,
-	0x2001, 0x0028, 0x900e, 0x0090, 0x9082, 0x0006, 0x1240, 0xb900,
-	0xd1fc, 0x0d98, 0x2001, 0x0029, 0x2009, 0x1000, 0x0038, 0x2001,
-	0x0029, 0x900e, 0x0018, 0x2001, 0x0029, 0x900e, 0x9005, 0x00be,
-	0x0005, 0xa877, 0x0000, 0xb8d0, 0x9005, 0x1904, 0x6550, 0xb888,
-	0x9005, 0x1904, 0x6550, 0xb838, 0xb93c, 0x9102, 0x1a04, 0x6550,
-	0x2b10, 0x080c, 0xabb6, 0x0904, 0x654c, 0x8108, 0xb93e, 0x6212,
-	0x2900, 0x6016, 0x6023, 0x0003, 0x600b, 0xffff, 0x6007, 0x0040,
-	0xa878, 0x605e, 0xa880, 0x9084, 0x00ff, 0x6066, 0xa883, 0x0000,
-	0xa87c, 0xd0ac, 0x0588, 0xc0dd, 0xa87e, 0xa888, 0x8001, 0x1530,
-	0xa816, 0xa864, 0x9094, 0x00f7, 0x9296, 0x0011, 0x11f8, 0x9084,
-	0x00ff, 0xc0bd, 0x601e, 0xa8ac, 0xaab0, 0xa836, 0xaa3a, 0x2001,
-	0x000f, 0x8001, 0x1df0, 0x2001, 0x8004, 0x6003, 0x0004, 0x6046,
-	0x00f6, 0x2079, 0x0380, 0x7818, 0xd0bc, 0x1de8, 0x7833, 0x0010,
-	0x2c00, 0x7836, 0x781b, 0x8080, 0x00fe, 0x0005, 0x080c, 0x173e,
-	0x601c, 0xc0bd, 0x601e, 0x0c38, 0xd0b4, 0x190c, 0x1c3d, 0x2001,
-	0x8004, 0x6003, 0x0002, 0x0c18, 0x81ff, 0x1110, 0xb88b, 0x0001,
-	0x2908, 0xb8cc, 0xb9ce, 0x9005, 0x1110, 0xb9d2, 0x0020, 0x0096,
-	0x2048, 0xa902, 0x009e, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x0026,
-	0x2091, 0x8000, 0x6210, 0x2258, 0xba00, 0x9005, 0x0110, 0xc285,
-	0x0008, 0xc284, 0xba02, 0x002e, 0x00ce, 0x012e, 0x00be, 0x0005,
-	0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x6210, 0x2258, 0xba04,
-	0x0006, 0x9086, 0x0006, 0x1170, 0xb89c, 0xd0ac, 0x0158, 0x080c,
-	0x6a66, 0x0140, 0x9284, 0xff00, 0x8007, 0x9086, 0x0007, 0x1110,
-	0x2011, 0x0600, 0x000e, 0x9294, 0xff00, 0x9215, 0xba06, 0x0006,
-	0x9086, 0x0006, 0x1120, 0xba90, 0x82ff, 0x090c, 0x0d7d, 0x000e,
+	0x2091, 0x8000, 0xa894, 0x90c6, 0x0015, 0x0904, 0x64b6, 0x90c6,
+	0x0056, 0x0904, 0x64ba, 0x90c6, 0x0066, 0x0904, 0x64be, 0x90c6,
+	0x0067, 0x0904, 0x64c2, 0x90c6, 0x0068, 0x0904, 0x64c6, 0x90c6,
+	0x0071, 0x0904, 0x64ca, 0x90c6, 0x0074, 0x0904, 0x64ce, 0x90c6,
+	0x007c, 0x0904, 0x64d2, 0x90c6, 0x007e, 0x0904, 0x64d6, 0x90c6,
+	0x0037, 0x0904, 0x64da, 0x9016, 0x2079, 0x1800, 0xa974, 0x9186,
+	0x00ff, 0x0904, 0x64b1, 0x9182, 0x0800, 0x1a04, 0x64b1, 0x080c,
+	0x6644, 0x1198, 0xb804, 0x9084, 0x00ff, 0x9082, 0x0006, 0x1268,
+	0xa894, 0x90c6, 0x006f, 0x0148, 0x080c, 0xab5a, 0x1904, 0x649a,
+	0xb8a0, 0x9084, 0xff80, 0x1904, 0x649a, 0xa894, 0x90c6, 0x006f,
+	0x0158, 0x90c6, 0x005e, 0x0904, 0x63fa, 0x90c6, 0x0064, 0x0904,
+	0x6423, 0x2008, 0x0804, 0x63bc, 0xa998, 0xa8b0, 0x2040, 0x080c,
+	0xab5a, 0x1120, 0x9182, 0x007f, 0x0a04, 0x63bc, 0x9186, 0x00ff,
+	0x0904, 0x63bc, 0x9182, 0x0800, 0x1a04, 0x63bc, 0xaaa0, 0xab9c,
+	0x787c, 0x9306, 0x11a8, 0x7880, 0x0096, 0x924e, 0x1128, 0x2208,
+	0x2310, 0x009e, 0x0804, 0x63bc, 0x080c, 0xab5a, 0x1140, 0x99cc,
+	0xff00, 0x009e, 0x1128, 0x2208, 0x2310, 0x0804, 0x63bc, 0x009e,
+	0x080c, 0x49dc, 0x0904, 0x63c6, 0x900e, 0x9016, 0x90c6, 0x4000,
+	0x15e0, 0x0006, 0x080c, 0x6937, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0031, 0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098,
+	0x080c, 0x0fc4, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0035, 0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x000a, 0x2098,
+	0x080c, 0x0fc4, 0xa8c4, 0xabc8, 0x9305, 0xabcc, 0x9305, 0xabd0,
+	0x9305, 0xabd4, 0x9305, 0xabd8, 0x9305, 0xabdc, 0x9305, 0xabe0,
+	0x9305, 0x9005, 0x0510, 0x000e, 0x00c8, 0x90c6, 0x4007, 0x1110,
+	0x2408, 0x00a0, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0070,
+	0x90c6, 0x4009, 0x1108, 0x0050, 0x90c6, 0x4006, 0x0138, 0x2001,
+	0x4005, 0x2009, 0x000a, 0x0010, 0x2001, 0x4006, 0xa896, 0xa99a,
+	0xaa9e, 0x2001, 0x0030, 0x900e, 0x0478, 0x000e, 0x080c, 0xab9a,
+	0x1130, 0x2001, 0x4005, 0x2009, 0x0003, 0x9016, 0x0c78, 0x2b00,
+	0x6012, 0x080c, 0xccfe, 0x2900, 0x6016, 0x6023, 0x0001, 0xa868,
+	0xd88c, 0x0108, 0xc0f5, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x320f, 0x012e, 0x9006, 0x080c, 0x6580, 0x2001, 0x0002, 0x080c,
+	0x6594, 0x2009, 0x0002, 0x080c, 0xac8d, 0xa8b0, 0xd094, 0x0118,
+	0xb8d4, 0xc08d, 0xb8d6, 0x9006, 0x9005, 0x012e, 0x00ee, 0x00fe,
+	0x00be, 0x0005, 0x080c, 0x5709, 0x0118, 0x2009, 0x0007, 0x00f8,
+	0xa998, 0xaeb0, 0x080c, 0x6644, 0x1904, 0x63b7, 0x9186, 0x007f,
+	0x0130, 0x080c, 0x6a8e, 0x0118, 0x2009, 0x0009, 0x0080, 0x0096,
+	0x080c, 0x1047, 0x1120, 0x009e, 0x2009, 0x0002, 0x0040, 0x2900,
+	0x009e, 0xa806, 0x080c, 0xca51, 0x19b0, 0x2009, 0x0003, 0x2001,
+	0x4005, 0x0804, 0x63be, 0xa998, 0xaeb0, 0x080c, 0x6644, 0x1904,
+	0x63b7, 0x0096, 0x080c, 0x1047, 0x1128, 0x009e, 0x2009, 0x0002,
+	0x0804, 0x6477, 0x2900, 0x009e, 0xa806, 0x0096, 0x2048, 0x20a9,
+	0x002b, 0xb8c4, 0x20e0, 0xb8c8, 0x2098, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006,
+	0x20a0, 0xbbc8, 0x9398, 0x0006, 0x2398, 0x080c, 0x0fc4, 0x009e,
+	0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xd684, 0x1168,
+	0x080c, 0x56f5, 0xd0b4, 0x1118, 0xa89b, 0x000b, 0x00e0, 0xb800,
+	0xd08c, 0x0118, 0xa89b, 0x000c, 0x00b0, 0x080c, 0x6a8e, 0x0118,
+	0xa89b, 0x0009, 0x0080, 0x080c, 0x5709, 0x0118, 0xa89b, 0x0007,
+	0x0050, 0x080c, 0xca34, 0x1904, 0x63f3, 0x2009, 0x0003, 0x2001,
+	0x4005, 0x0804, 0x63be, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa804,
+	0x8006, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
+	0x0002, 0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031,
+	0x0000, 0x2041, 0x1296, 0x080c, 0xb114, 0x1904, 0x63f3, 0x2009,
+	0x0002, 0x08e8, 0x2001, 0x0028, 0x900e, 0x0804, 0x63f4, 0x2009,
+	0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184,
+	0x0118, 0x2001, 0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0804,
+	0x63f4, 0x2001, 0x0029, 0x900e, 0x0804, 0x63f4, 0x080c, 0x37b6,
+	0x0804, 0x63f5, 0x080c, 0x542a, 0x0804, 0x63f5, 0x080c, 0x4592,
+	0x0804, 0x63f5, 0x080c, 0x460b, 0x0804, 0x63f5, 0x080c, 0x4667,
+	0x0804, 0x63f5, 0x080c, 0x4a9f, 0x0804, 0x63f5, 0x080c, 0x4d4f,
+	0x0804, 0x63f5, 0x080c, 0x5095, 0x0804, 0x63f5, 0x080c, 0x528e,
+	0x0804, 0x63f5, 0x080c, 0x39d4, 0x0804, 0x63f5, 0x00b6, 0xa974,
+	0xae78, 0x9684, 0x3fff, 0x9082, 0x4000, 0x1608, 0x9182, 0x0800,
+	0x1258, 0x9188, 0x1000, 0x2104, 0x905d, 0x0130, 0x080c, 0x6a8e,
+	0x1138, 0x00d9, 0x9006, 0x00b0, 0x2001, 0x0028, 0x900e, 0x0090,
+	0x9082, 0x0006, 0x1240, 0xb900, 0xd1fc, 0x0d98, 0x2001, 0x0029,
+	0x2009, 0x1000, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018, 0x2001,
+	0x0029, 0x900e, 0x9005, 0x00be, 0x0005, 0xa877, 0x0000, 0xb8d0,
+	0x9005, 0x1904, 0x6574, 0xb888, 0x9005, 0x1904, 0x6574, 0xb838,
+	0xb93c, 0x9102, 0x1a04, 0x6574, 0x2b10, 0x080c, 0xabc7, 0x0904,
+	0x6570, 0x8108, 0xb93e, 0x6212, 0x2900, 0x6016, 0x6023, 0x0003,
+	0x600b, 0xffff, 0x6007, 0x0040, 0xa878, 0x605e, 0xa880, 0x9084,
+	0x00ff, 0x6066, 0xa883, 0x0000, 0xa87c, 0xd0ac, 0x0588, 0xc0dd,
+	0xa87e, 0xa888, 0x8001, 0x1530, 0xa816, 0xa864, 0x9094, 0x00f7,
+	0x9296, 0x0011, 0x11f8, 0x9084, 0x00ff, 0xc0bd, 0x601e, 0xa8ac,
+	0xaab0, 0xa836, 0xaa3a, 0x2001, 0x000f, 0x8001, 0x1df0, 0x2001,
+	0x8004, 0x6003, 0x0004, 0x6046, 0x00f6, 0x2079, 0x0380, 0x7818,
+	0xd0bc, 0x1de8, 0x7833, 0x0010, 0x2c00, 0x7836, 0x781b, 0x8080,
+	0x00fe, 0x0005, 0x080c, 0x174b, 0x601c, 0xc0bd, 0x601e, 0x0c38,
+	0xd0b4, 0x190c, 0x1c55, 0x2001, 0x8004, 0x6003, 0x0002, 0x0c18,
+	0x81ff, 0x1110, 0xb88b, 0x0001, 0x2908, 0xb8cc, 0xb9ce, 0x9005,
+	0x1110, 0xb9d2, 0x0020, 0x0096, 0x2048, 0xa902, 0x009e, 0x0005,
+	0x00b6, 0x0126, 0x00c6, 0x0026, 0x2091, 0x8000, 0x6210, 0x2258,
+	0xba00, 0x9005, 0x0110, 0xc285, 0x0008, 0xc284, 0xba02, 0x002e,
 	0x00ce, 0x012e, 0x00be, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x2091,
-	0x8000, 0x6210, 0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1168,
-	0xb89c, 0xd0a4, 0x0150, 0x080c, 0x6a62, 0x1138, 0x9284, 0x00ff,
-	0x9086, 0x0007, 0x1110, 0x2011, 0x0006, 0x000e, 0x9294, 0x00ff,
-	0x8007, 0x9215, 0xba06, 0x00ce, 0x012e, 0x00be, 0x0005, 0x9182,
-	0x0800, 0x0218, 0x9085, 0x0001, 0x0005, 0x00d6, 0x0026, 0x9190,
-	0x1000, 0x2204, 0x905d, 0x1188, 0x0096, 0x080c, 0x103a, 0x2958,
-	0x009e, 0x0168, 0x2b00, 0x2012, 0xb85c, 0xb8ca, 0xb860, 0xb8c6,
-	0x9006, 0xb8a6, 0xb8ae, 0x080c, 0x603e, 0x9006, 0x0010, 0x9085,
-	0x0001, 0x002e, 0x00de, 0x0005, 0x00b6, 0x0096, 0x0126, 0x2091,
-	0x8000, 0x0026, 0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0458,
-	0x00d6, 0x9190, 0x1000, 0x2204, 0x905d, 0x0518, 0x2013, 0x0000,
-	0xb8a4, 0x904d, 0x0110, 0x080c, 0x106c, 0x00d6, 0x00c6, 0xb8bc,
-	0x2060, 0x8cff, 0x0168, 0x600c, 0x0006, 0x6014, 0x2048, 0x080c,
-	0xc832, 0x0110, 0x080c, 0x0fec, 0x080c, 0xabdf, 0x00ce, 0x0c88,
-	0x00ce, 0x00de, 0x2b48, 0xb8c8, 0xb85e, 0xb8c4, 0xb862, 0x080c,
-	0x107c, 0x00de, 0x9006, 0x002e, 0x012e, 0x009e, 0x00be, 0x0005,
-	0x0016, 0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0030, 0x9188,
-	0x1000, 0x2104, 0x905d, 0x0dc0, 0x9006, 0x001e, 0x0005, 0x00d6,
-	0x0156, 0x0136, 0x0146, 0x9006, 0xb80a, 0xb80e, 0xb800, 0xc08c,
-	0xb802, 0x080c, 0x74c8, 0x1510, 0xb8a0, 0x9086, 0x007e, 0x0120,
-	0x080c, 0xab49, 0x11d8, 0x0078, 0x7040, 0xd0e4, 0x01b8, 0x00c6,
-	0x2061, 0x1981, 0x7048, 0x2062, 0x704c, 0x6006, 0x7050, 0x600a,
-	0x7054, 0x600e, 0x00ce, 0x703c, 0x2069, 0x0140, 0x9005, 0x1110,
-	0x2001, 0x0001, 0x6886, 0x2069, 0x1800, 0x68b6, 0x7040, 0xb85e,
-	0x7048, 0xb862, 0x704c, 0xb866, 0x20e1, 0x0000, 0x2099, 0x0276,
-	0xb8c4, 0x20e8, 0xb8c8, 0x9088, 0x000a, 0x21a0, 0x20a9, 0x0004,
-	0x4003, 0x2099, 0x027a, 0x9088, 0x0006, 0x21a0, 0x20a9, 0x0004,
-	0x4003, 0x2069, 0x0200, 0x6817, 0x0001, 0x7040, 0xb86a, 0x7144,
-	0xb96e, 0x7048, 0xb872, 0x7050, 0xb876, 0x2069, 0x0200, 0x6817,
-	0x0000, 0xb8a0, 0x9086, 0x007e, 0x1110, 0x7144, 0xb96e, 0x9182,
-	0x0211, 0x1218, 0x2009, 0x0008, 0x0400, 0x9182, 0x0259, 0x1218,
-	0x2009, 0x0007, 0x00d0, 0x9182, 0x02c1, 0x1218, 0x2009, 0x0006,
-	0x00a0, 0x9182, 0x0349, 0x1218, 0x2009, 0x0005, 0x0070, 0x9182,
-	0x0421, 0x1218, 0x2009, 0x0004, 0x0040, 0x9182, 0x0581, 0x1218,
-	0x2009, 0x0003, 0x0010, 0x2009, 0x0002, 0xb992, 0x014e, 0x013e,
-	0x015e, 0x00de, 0x0005, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260,
-	0x7034, 0xb896, 0x703c, 0xb89a, 0x7054, 0xb89e, 0x0036, 0xbbd4,
-	0xc384, 0xba00, 0x2009, 0x1867, 0x210c, 0xd0bc, 0x0120, 0xd1ec,
-	0x0110, 0xc2ad, 0x0008, 0xc2ac, 0xd0c4, 0x0148, 0xd1e4, 0x0138,
-	0xc2bd, 0xd0cc, 0x0128, 0xd38c, 0x1108, 0xc385, 0x0008, 0xc2bc,
-	0xba02, 0xbbd6, 0x003e, 0x00ee, 0x002e, 0x001e, 0x0005, 0x0096,
-	0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d, 0x0578, 0xa900, 0x81ff,
-	0x15c0, 0xaa04, 0x9282, 0x0010, 0x16c8, 0x0136, 0x0146, 0x01c6,
-	0x01d6, 0x8906, 0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084,
-	0xffc0, 0x9080, 0x0004, 0x2098, 0x2009, 0x0010, 0x20a9, 0x0001,
-	0x4002, 0x9086, 0xffff, 0x0120, 0x8109, 0x1dd0, 0x080c, 0x0d7d,
-	0x3c00, 0x20e8, 0x3300, 0x8001, 0x20a0, 0x4604, 0x8210, 0xaa06,
-	0x01de, 0x01ce, 0x014e, 0x013e, 0x0060, 0x080c, 0x103a, 0x0170,
-	0x2900, 0xb8a6, 0xa803, 0x0000, 0x080c, 0x68af, 0xa807, 0x0001,
-	0xae12, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8,
-	0x0126, 0x2091, 0x8000, 0x0096, 0xb8a4, 0x904d, 0x0188, 0xa800,
-	0x9005, 0x1150, 0x080c, 0x68be, 0x1158, 0xa804, 0x908a, 0x0002,
-	0x0218, 0x8001, 0xa806, 0x0020, 0x080c, 0x106c, 0xb8a7, 0x0000,
-	0x009e, 0x012e, 0x0005, 0x0096, 0x00c6, 0xb888, 0x9005, 0x1904,
-	0x67a4, 0xb8d0, 0x904d, 0x0904, 0x67a4, 0x080c, 0xabb6, 0x0904,
-	0x67a0, 0x8210, 0xba3e, 0xa800, 0xb8d2, 0x9005, 0x1108, 0xb8ce,
-	0x2b00, 0x6012, 0x2900, 0x6016, 0x6023, 0x0003, 0x600b, 0xffff,
-	0x6007, 0x0040, 0xa878, 0x605e, 0xa880, 0x9084, 0x00ff, 0x6066,
-	0xa883, 0x0000, 0xa87c, 0xd0ac, 0x01c8, 0xc0dd, 0xa87e, 0xa888,
-	0x8001, 0x1568, 0xa816, 0xa864, 0x9094, 0x00f7, 0x9296, 0x0011,
-	0x1530, 0x9084, 0x00ff, 0xc0bd, 0x601e, 0xa8ac, 0xaab0, 0xa836,
-	0xaa3a, 0x2001, 0x8004, 0x6003, 0x0004, 0x0030, 0x080c, 0x1c3d,
-	0x2001, 0x8004, 0x6003, 0x0002, 0x6046, 0x2001, 0x0010, 0x2c08,
-	0x080c, 0xa879, 0xb838, 0xba3c, 0x9202, 0x0a04, 0x6751, 0x0020,
-	0x82ff, 0x1110, 0xb88b, 0x0001, 0x00ce, 0x009e, 0x0005, 0x080c,
-	0x173e, 0x601c, 0xc0bd, 0x601e, 0x08e0, 0x00b6, 0x0096, 0x0016,
-	0x20a9, 0x0800, 0x900e, 0x0016, 0x080c, 0x6620, 0x1158, 0xb8d0,
-	0x904d, 0x0140, 0x3e00, 0x9086, 0x0002, 0x1118, 0xb800, 0xd0bc,
-	0x1108, 0x0041, 0x001e, 0x8108, 0x1f04, 0x67b3, 0x001e, 0x00be,
-	0x009e, 0x0005, 0x0096, 0x0016, 0xb8d0, 0x904d, 0x0188, 0xa800,
-	0xb8d2, 0x9005, 0x1108, 0xb8ce, 0x9006, 0xa802, 0xa867, 0x0103,
-	0xab7a, 0xa877, 0x0000, 0x080c, 0xcb35, 0x080c, 0x6d7b, 0x0c60,
-	0x001e, 0x009e, 0x0005, 0x0086, 0x9046, 0xb8d0, 0x904d, 0x01b0,
-	0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0128, 0x2940, 0xa800,
-	0x904d, 0x0160, 0x0ca8, 0xa800, 0x88ff, 0x1128, 0xb8d2, 0x9005,
-	0x1118, 0xb8ce, 0x0008, 0xa002, 0xa803, 0x0000, 0x008e, 0x0005,
-	0x901e, 0x0010, 0x2019, 0x0001, 0x0126, 0x2091, 0x8000, 0x00e6,
-	0x0096, 0x00c6, 0x0086, 0x0026, 0x2071, 0x19e6, 0x9046, 0x7028,
-	0x9065, 0x01e8, 0x6014, 0x2068, 0x83ff, 0x0120, 0x605c, 0x9606,
-	0x0158, 0x0030, 0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0120,
-	0x2c40, 0x600c, 0x2060, 0x0c60, 0x600c, 0x0006, 0x0066, 0x2830,
-	0x080c, 0x9f84, 0x006e, 0x000e, 0x83ff, 0x0508, 0x0c08, 0x9046,
-	0xb8d0, 0x904d, 0x01e0, 0x83ff, 0x0120, 0xa878, 0x9606, 0x0158,
-	0x0030, 0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0120, 0x2940,
-	0xa800, 0x2048, 0x0c70, 0xb8d0, 0xaa00, 0x0026, 0x9906, 0x1110,
-	0xbad2, 0x0008, 0xa202, 0x000e, 0x83ff, 0x0108, 0x0c10, 0x002e,
-	0x008e, 0x00ce, 0x009e, 0x00ee, 0x012e, 0x0005, 0x9016, 0x0489,
-	0x1110, 0x2011, 0x0001, 0x0005, 0x080c, 0x6913, 0x0128, 0x080c,
-	0xc8f3, 0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6913, 0x0128,
-	0x080c, 0xc894, 0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6913,
-	0x0128, 0x080c, 0xc8f0, 0x0010, 0x9085, 0x0001, 0x0005, 0x080c,
-	0x6913, 0x0128, 0x080c, 0xc8b3, 0x0010, 0x9085, 0x0001, 0x0005,
-	0x080c, 0x6913, 0x0128, 0x080c, 0xc934, 0x0010, 0x9085, 0x0001,
-	0x0005, 0xb8a4, 0x900d, 0x1118, 0x9085, 0x0001, 0x0005, 0x0136,
-	0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e, 0x810e, 0x810f, 0x9184,
-	0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080, 0x0004, 0x2098, 0x20a9,
-	0x0001, 0x2009, 0x0010, 0x4002, 0x9606, 0x0128, 0x8109, 0x1dd8,
-	0x9085, 0x0001, 0x0008, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0146,
-	0x01d6, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0004, 0x20a0, 0x20a9,
-	0x0010, 0x2009, 0xffff, 0x4104, 0x01de, 0x014e, 0x0136, 0x01c6,
-	0xa800, 0x9005, 0x11b8, 0x890e, 0x810e, 0x810f, 0x9184, 0x003f,
-	0x20e0, 0x9184, 0xffc0, 0x9080, 0x0004, 0x2098, 0x20a9, 0x0001,
-	0x2009, 0x0010, 0x4002, 0x9606, 0x0128, 0x8109, 0x1dd8, 0x9085,
-	0x0001, 0x0068, 0x0146, 0x01d6, 0x3300, 0x8001, 0x20a0, 0x3c00,
-	0x20e8, 0x2001, 0xffff, 0x4004, 0x01de, 0x014e, 0x9006, 0x01ce,
-	0x013e, 0x0005, 0x0096, 0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d,
-	0x1128, 0x080c, 0x103a, 0x0168, 0x2900, 0xb8a6, 0x080c, 0x68af,
-	0xa803, 0x0001, 0xa807, 0x0000, 0x9085, 0x0001, 0x012e, 0x009e,
-	0x0005, 0x9006, 0x0cd8, 0x0096, 0x0126, 0x2091, 0x8000, 0xb8a4,
-	0x904d, 0x0130, 0xb8a7, 0x0000, 0x080c, 0x106c, 0x9085, 0x0001,
-	0x012e, 0x009e, 0x0005, 0xb89c, 0xd0a4, 0x0005, 0x00b6, 0x00f6,
-	0x080c, 0x74c8, 0x01b0, 0x71c4, 0x81ff, 0x1198, 0x71dc, 0xd19c,
-	0x0180, 0x2001, 0x007e, 0x9080, 0x1000, 0x2004, 0x905d, 0x0148,
-	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed,
-	0xb802, 0x2079, 0x1847, 0x7804, 0xd0a4, 0x01d0, 0x0156, 0x20a9,
-	0x007f, 0x900e, 0x0016, 0x080c, 0x6620, 0x1168, 0xb804, 0x9084,
-	0xff00, 0x8007, 0x9096, 0x0004, 0x0118, 0x9086, 0x0006, 0x1118,
-	0xb800, 0xc0ed, 0xb802, 0x001e, 0x8108, 0x1f04, 0x693a, 0x015e,
-	0x080c, 0x6a28, 0x0120, 0x2001, 0x1984, 0x200c, 0x0038, 0x2079,
-	0x1847, 0x7804, 0xd0a4, 0x0130, 0x2009, 0x07d0, 0x2011, 0x6965,
-	0x080c, 0x86e7, 0x00fe, 0x00be, 0x0005, 0x00b6, 0x2011, 0x6965,
-	0x080c, 0x861d, 0x080c, 0x6a28, 0x01d8, 0x2001, 0x107e, 0x2004,
-	0x2058, 0xb900, 0xc1ec, 0xb902, 0x080c, 0x6a66, 0x0130, 0x2009,
-	0x07d0, 0x2011, 0x6965, 0x080c, 0x86e7, 0x00e6, 0x2071, 0x1800,
-	0x9006, 0x707e, 0x7060, 0x7082, 0x080c, 0x2fc0, 0x00ee, 0x04d0,
-	0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6620,
-	0x1558, 0xb800, 0xd0ec, 0x0540, 0x0046, 0xbaa0, 0x2220, 0x9006,
-	0x2009, 0x0029, 0x080c, 0xe2d9, 0xb800, 0xc0e5, 0xc0ec, 0xb802,
-	0x080c, 0x6a62, 0x2001, 0x0707, 0x1128, 0xb804, 0x9084, 0x00ff,
-	0x9085, 0x0700, 0xb806, 0x080c, 0xa888, 0x2019, 0x0029, 0x080c,
-	0x938d, 0x0076, 0x903e, 0x080c, 0x9256, 0x900e, 0x080c, 0xdffb,
-	0x007e, 0x004e, 0x080c, 0xa8a4, 0x001e, 0x8108, 0x1f04, 0x698d,
-	0x00ce, 0x015e, 0x00be, 0x0005, 0x00b6, 0x6010, 0x2058, 0xb800,
-	0xc0ec, 0xb802, 0x00be, 0x0005, 0x00b6, 0x00c6, 0x0096, 0x080c,
-	0x1053, 0x090c, 0x0d7d, 0x2958, 0x009e, 0x2001, 0x196a, 0x2b02,
-	0x8b07, 0x8006, 0x8006, 0x908c, 0x003f, 0xb9c6, 0x908c, 0xffc0,
-	0xb9ca, 0xb8af, 0x0000, 0x2009, 0x00ff, 0x080c, 0x603e, 0xb807,
-	0x0006, 0xb813, 0x00ff, 0xb817, 0xffff, 0xb86f, 0x0200, 0xb86c,
-	0xb893, 0x0002, 0xb8bb, 0x0520, 0xb8a3, 0x00ff, 0xb8af, 0x0000,
-	0x00ce, 0x00be, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb800, 0x00be,
-	0xd0ac, 0x0005, 0x6010, 0x00b6, 0x905d, 0x0108, 0xb800, 0x00be,
-	0xd0bc, 0x0005, 0x0006, 0x0016, 0x0026, 0xb804, 0x908c, 0x00ff,
-	0x9196, 0x0006, 0x0188, 0x9196, 0x0004, 0x0170, 0x9196, 0x0005,
-	0x0158, 0x908c, 0xff00, 0x810f, 0x9196, 0x0006, 0x0128, 0x9196,
-	0x0004, 0x0110, 0x9196, 0x0005, 0x002e, 0x001e, 0x000e, 0x0005,
-	0x00b6, 0x00f6, 0x2001, 0x107e, 0x2004, 0x905d, 0x0110, 0xb800,
-	0xd0ec, 0x00fe, 0x00be, 0x0005, 0x0126, 0x0026, 0x2091, 0x8000,
-	0x0006, 0xbaa0, 0x9290, 0x1000, 0x2204, 0x9b06, 0x190c, 0x0d7d,
-	0x000e, 0xba00, 0x9005, 0x0110, 0xc2fd, 0x0008, 0xc2fc, 0xba02,
-	0x002e, 0x012e, 0x0005, 0x2011, 0x1837, 0x2204, 0xd0cc, 0x0138,
-	0x2001, 0x1982, 0x200c, 0x2011, 0x6a58, 0x080c, 0x86e7, 0x0005,
-	0x2011, 0x6a58, 0x080c, 0x861d, 0x2011, 0x1837, 0x2204, 0xc0cc,
-	0x2012, 0x0005, 0x080c, 0x56d5, 0xd0ac, 0x0005, 0x080c, 0x56d5,
-	0xd0a4, 0x0005, 0x0016, 0xb904, 0x9184, 0x00ff, 0x908e, 0x0006,
-	0x001e, 0x0005, 0x0016, 0xb904, 0x9184, 0xff00, 0x8007, 0x908e,
-	0x0006, 0x001e, 0x0005, 0x00b6, 0x00f6, 0x080c, 0xcf51, 0x0158,
-	0x70dc, 0x9084, 0x0028, 0x0138, 0x2001, 0x107f, 0x2004, 0x905d,
-	0x0110, 0xb8d4, 0xd094, 0x00fe, 0x00be, 0x0005, 0x2071, 0x1910,
-	0x7003, 0x0001, 0x7007, 0x0000, 0x9006, 0x7012, 0x7016, 0x701a,
-	0x701e, 0x700a, 0x7046, 0x0005, 0x0016, 0x00e6, 0x2071, 0x1947,
-	0x900e, 0x710a, 0x080c, 0x56d5, 0xd0fc, 0x1140, 0x080c, 0x56d5,
-	0x900e, 0xd09c, 0x0108, 0x8108, 0x7102, 0x00f8, 0x2001, 0x1867,
-	0x200c, 0x9184, 0x0007, 0x0002, 0x6aa6, 0x6aa6, 0x6aa6, 0x6aa6,
-	0x6aa6, 0x6abc, 0x6aca, 0x6aa6, 0x7003, 0x0003, 0x2009, 0x1868,
-	0x210c, 0x9184, 0xff00, 0x8007, 0x9005, 0x1110, 0x2001, 0x0002,
-	0x7006, 0x0018, 0x7003, 0x0005, 0x0c88, 0x00ee, 0x001e, 0x0005,
-	0x00e6, 0x2071, 0x0050, 0x684c, 0x9005, 0x1150, 0x00e6, 0x2071,
-	0x1910, 0x7028, 0xc085, 0x702a, 0x00ee, 0x9085, 0x0001, 0x0488,
-	0x6844, 0x9005, 0x0158, 0x080c, 0x783e, 0x6a60, 0x9200, 0x7002,
-	0x6864, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6860, 0x7002,
-	0x6864, 0x7006, 0x6868, 0x700a, 0x686c, 0x700e, 0x6844, 0x9005,
-	0x1110, 0x7012, 0x7016, 0x684c, 0x701a, 0x701c, 0x9085, 0x0040,
-	0x701e, 0x7037, 0x0019, 0x702b, 0x0001, 0x00e6, 0x2071, 0x1910,
-	0x7028, 0xc084, 0x702a, 0x7007, 0x0001, 0x700b, 0x0000, 0x00ee,
-	0x9006, 0x00ee, 0x0005, 0x00e6, 0x0026, 0x2071, 0x1947, 0x7000,
-	0x9015, 0x0904, 0x6d80, 0x9286, 0x0003, 0x0904, 0x6c10, 0x9286,
-	0x0005, 0x0904, 0x6c10, 0x2071, 0x1877, 0xa87c, 0x9005, 0x0904,
-	0x6b71, 0x7140, 0xa868, 0x9102, 0x0a04, 0x6d80, 0xa878, 0xd084,
-	0x15d8, 0xa853, 0x0019, 0x2001, 0x8023, 0xa84e, 0x2071, 0x1910,
-	0x701c, 0x9005, 0x1904, 0x6f17, 0x0e04, 0x6f85, 0x2071, 0x0000,
-	0xa850, 0x7032, 0xa84c, 0x7082, 0xa870, 0x7086, 0xa86c, 0x708a,
-	0xa880, 0x708e, 0x7036, 0x0146, 0x01d6, 0x0136, 0x01c6, 0x0156,
-	0x20e9, 0x0000, 0x20a1, 0x002a, 0xa868, 0x20a8, 0xa860, 0x20e0,
-	0xa85c, 0x9080, 0x0021, 0x2098, 0x4003, 0x015e, 0x01ce, 0x013e,
-	0x01de, 0x014e, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x11e1, 0x0804, 0x6bf3, 0xa853, 0x001b, 0x2001, 0x8027,
-	0x0820, 0x7004, 0xd08c, 0x1904, 0x6d80, 0xa853, 0x001a, 0x2001,
-	0x8024, 0x0804, 0x6b35, 0x00e6, 0x0026, 0x2071, 0x1947, 0x7000,
-	0x9015, 0x0904, 0x6d80, 0x9286, 0x0003, 0x0904, 0x6c10, 0x9286,
-	0x0005, 0x0904, 0x6c10, 0xa84f, 0x8022, 0xa853, 0x0018, 0x0804,
-	0x6bd8, 0xa868, 0xd0fc, 0x11d8, 0x00e6, 0x0026, 0x2001, 0x1947,
-	0x2004, 0x9005, 0x0904, 0x6d80, 0xa87c, 0xd0bc, 0x1904, 0x6d80,
-	0xa978, 0xa874, 0x9105, 0x1904, 0x6d80, 0x2001, 0x1947, 0x2004,
-	0x0002, 0x6d80, 0x6bd4, 0x6c10, 0x6c10, 0x6d80, 0x6c10, 0x0005,
-	0xa868, 0xd0fc, 0x1500, 0x00e6, 0x0026, 0x2009, 0x1947, 0x210c,
-	0x81ff, 0x0904, 0x6d80, 0xa87c, 0xd0cc, 0x0904, 0x6d80, 0xa880,
-	0x9084, 0x00ff, 0x9086, 0x0001, 0x1904, 0x6d80, 0x9186, 0x0003,
-	0x0904, 0x6c10, 0x9186, 0x0005, 0x0904, 0x6c10, 0xa84f, 0x8021,
-	0xa853, 0x0017, 0x0028, 0x0005, 0xa84f, 0x8020, 0xa853, 0x0016,
-	0x2071, 0x1910, 0x701c, 0x9005, 0x1904, 0x6f17, 0x0e04, 0x6f85,
-	0x2071, 0x0000, 0xa84c, 0x7082, 0xa850, 0x7032, 0xa86c, 0x7086,
-	0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
-	0xd084, 0x190c, 0x11e1, 0x2071, 0x1800, 0x2011, 0x0001, 0xa804,
-	0x900d, 0x702c, 0x1158, 0xa802, 0x2900, 0x702e, 0x70c0, 0x9200,
-	0x70c2, 0x080c, 0x8532, 0x002e, 0x00ee, 0x0005, 0x0096, 0x2148,
-	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x009e, 0x0c58,
-	0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050, 0x2071, 0x1910, 0xa803,
-	0x0000, 0x7010, 0x9005, 0x1904, 0x6d05, 0x782c, 0x908c, 0x0780,
-	0x190c, 0x70d1, 0x8004, 0x8004, 0x8004, 0x9084, 0x0003, 0x0002,
-	0x6c2e, 0x6d05, 0x6c53, 0x6ca0, 0x080c, 0x0d7d, 0x2071, 0x1800,
-	0x2900, 0x7822, 0xa804, 0x900d, 0x1170, 0x2071, 0x1a02, 0x703c,
+	0x8000, 0x6210, 0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1170,
+	0xb89c, 0xd0ac, 0x0158, 0x080c, 0x6a8a, 0x0140, 0x9284, 0xff00,
+	0x8007, 0x9086, 0x0007, 0x1110, 0x2011, 0x0600, 0x000e, 0x9294,
+	0xff00, 0x9215, 0xba06, 0x0006, 0x9086, 0x0006, 0x1120, 0xba90,
+	0x82ff, 0x090c, 0x0d7d, 0x000e, 0x00ce, 0x012e, 0x00be, 0x0005,
+	0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x6210, 0x2258, 0xba04,
+	0x0006, 0x9086, 0x0006, 0x1168, 0xb89c, 0xd0a4, 0x0150, 0x080c,
+	0x6a86, 0x1138, 0x9284, 0x00ff, 0x9086, 0x0007, 0x1110, 0x2011,
+	0x0006, 0x000e, 0x9294, 0x00ff, 0x8007, 0x9215, 0xba06, 0x00ce,
+	0x012e, 0x00be, 0x0005, 0x9182, 0x0800, 0x0218, 0x9085, 0x0001,
+	0x0005, 0x00d6, 0x0026, 0x9190, 0x1000, 0x2204, 0x905d, 0x1188,
+	0x0096, 0x080c, 0x1047, 0x2958, 0x009e, 0x0168, 0x2b00, 0x2012,
+	0xb85c, 0xb8ca, 0xb860, 0xb8c6, 0x9006, 0xb8a6, 0xb8ae, 0x080c,
+	0x605e, 0x9006, 0x0010, 0x9085, 0x0001, 0x002e, 0x00de, 0x0005,
+	0x00b6, 0x0096, 0x0126, 0x2091, 0x8000, 0x0026, 0x9182, 0x0800,
+	0x0218, 0x9085, 0x0001, 0x0458, 0x00d6, 0x9190, 0x1000, 0x2204,
+	0x905d, 0x0518, 0x2013, 0x0000, 0xb8a4, 0x904d, 0x0110, 0x080c,
+	0x1079, 0x00d6, 0x00c6, 0xb8bc, 0x2060, 0x8cff, 0x0168, 0x600c,
+	0x0006, 0x6014, 0x2048, 0x080c, 0xc865, 0x0110, 0x080c, 0x0ff9,
+	0x080c, 0xabf0, 0x00ce, 0x0c88, 0x00ce, 0x00de, 0x2b48, 0xb8c8,
+	0xb85e, 0xb8c4, 0xb862, 0x080c, 0x1089, 0x00de, 0x9006, 0x002e,
+	0x012e, 0x009e, 0x00be, 0x0005, 0x0016, 0x9182, 0x0800, 0x0218,
+	0x9085, 0x0001, 0x0030, 0x9188, 0x1000, 0x2104, 0x905d, 0x0dc0,
+	0x9006, 0x001e, 0x0005, 0x00d6, 0x0156, 0x0136, 0x0146, 0x9006,
+	0xb80a, 0xb80e, 0xb800, 0xc08c, 0xb802, 0x080c, 0x74ec, 0x1510,
+	0xb8a0, 0x9086, 0x007e, 0x0120, 0x080c, 0xab5a, 0x11d8, 0x0078,
+	0x7040, 0xd0e4, 0x01b8, 0x00c6, 0x2061, 0x1981, 0x7048, 0x2062,
+	0x704c, 0x6006, 0x7050, 0x600a, 0x7054, 0x600e, 0x00ce, 0x703c,
+	0x2069, 0x0140, 0x9005, 0x1110, 0x2001, 0x0001, 0x6886, 0x2069,
+	0x1800, 0x68b6, 0x7040, 0xb85e, 0x7048, 0xb862, 0x704c, 0xb866,
+	0x20e1, 0x0000, 0x2099, 0x0276, 0xb8c4, 0x20e8, 0xb8c8, 0x9088,
+	0x000a, 0x21a0, 0x20a9, 0x0004, 0x4003, 0x2099, 0x027a, 0x9088,
+	0x0006, 0x21a0, 0x20a9, 0x0004, 0x4003, 0x2069, 0x0200, 0x6817,
+	0x0001, 0x7040, 0xb86a, 0x7144, 0xb96e, 0x7048, 0xb872, 0x7050,
+	0xb876, 0x2069, 0x0200, 0x6817, 0x0000, 0xb8a0, 0x9086, 0x007e,
+	0x1110, 0x7144, 0xb96e, 0x9182, 0x0211, 0x1218, 0x2009, 0x0008,
+	0x0400, 0x9182, 0x0259, 0x1218, 0x2009, 0x0007, 0x00d0, 0x9182,
+	0x02c1, 0x1218, 0x2009, 0x0006, 0x00a0, 0x9182, 0x0349, 0x1218,
+	0x2009, 0x0005, 0x0070, 0x9182, 0x0421, 0x1218, 0x2009, 0x0004,
+	0x0040, 0x9182, 0x0581, 0x1218, 0x2009, 0x0003, 0x0010, 0x2009,
+	0x0002, 0xb992, 0x014e, 0x013e, 0x015e, 0x00de, 0x0005, 0x0016,
+	0x0026, 0x00e6, 0x2071, 0x0260, 0x7034, 0xb896, 0x703c, 0xb89a,
+	0x7054, 0xb89e, 0x0036, 0xbbd4, 0xc384, 0xba00, 0x2009, 0x1867,
+	0x210c, 0xd0bc, 0x0120, 0xd1ec, 0x0110, 0xc2ad, 0x0008, 0xc2ac,
+	0xd0c4, 0x0148, 0xd1e4, 0x0138, 0xc2bd, 0xd0cc, 0x0128, 0xd38c,
+	0x1108, 0xc385, 0x0008, 0xc2bc, 0xba02, 0xbbd6, 0x003e, 0x00ee,
+	0x002e, 0x001e, 0x0005, 0x0096, 0x0126, 0x2091, 0x8000, 0xb8a4,
+	0x904d, 0x0578, 0xa900, 0x81ff, 0x15c0, 0xaa04, 0x9282, 0x0010,
+	0x16c8, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x8906, 0x8006, 0x8007,
+	0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0, 0x9080, 0x0004, 0x2098,
+	0x2009, 0x0010, 0x20a9, 0x0001, 0x4002, 0x9086, 0xffff, 0x0120,
+	0x8109, 0x1dd0, 0x080c, 0x0d7d, 0x3c00, 0x20e8, 0x3300, 0x8001,
+	0x20a0, 0x4604, 0x8210, 0xaa06, 0x01de, 0x01ce, 0x014e, 0x013e,
+	0x0060, 0x080c, 0x1047, 0x0170, 0x2900, 0xb8a6, 0xa803, 0x0000,
+	0x080c, 0x68d3, 0xa807, 0x0001, 0xae12, 0x9085, 0x0001, 0x012e,
+	0x009e, 0x0005, 0x9006, 0x0cd8, 0x0126, 0x2091, 0x8000, 0x0096,
+	0xb8a4, 0x904d, 0x0188, 0xa800, 0x9005, 0x1150, 0x080c, 0x68e2,
+	0x1158, 0xa804, 0x908a, 0x0002, 0x0218, 0x8001, 0xa806, 0x0020,
+	0x080c, 0x1079, 0xb8a7, 0x0000, 0x009e, 0x012e, 0x0005, 0x0096,
+	0x00c6, 0xb888, 0x9005, 0x1904, 0x67c8, 0xb8d0, 0x904d, 0x0904,
+	0x67c8, 0x080c, 0xabc7, 0x0904, 0x67c4, 0x8210, 0xba3e, 0xa800,
+	0xb8d2, 0x9005, 0x1108, 0xb8ce, 0x2b00, 0x6012, 0x2900, 0x6016,
+	0x6023, 0x0003, 0x600b, 0xffff, 0x6007, 0x0040, 0xa878, 0x605e,
+	0xa880, 0x9084, 0x00ff, 0x6066, 0xa883, 0x0000, 0xa87c, 0xd0ac,
+	0x01c8, 0xc0dd, 0xa87e, 0xa888, 0x8001, 0x1568, 0xa816, 0xa864,
+	0x9094, 0x00f7, 0x9296, 0x0011, 0x1530, 0x9084, 0x00ff, 0xc0bd,
+	0x601e, 0xa8ac, 0xaab0, 0xa836, 0xaa3a, 0x2001, 0x8004, 0x6003,
+	0x0004, 0x0030, 0x080c, 0x1c55, 0x2001, 0x8004, 0x6003, 0x0002,
+	0x6046, 0x2001, 0x0010, 0x2c08, 0x080c, 0xa88a, 0xb838, 0xba3c,
+	0x9202, 0x0a04, 0x6775, 0x0020, 0x82ff, 0x1110, 0xb88b, 0x0001,
+	0x00ce, 0x009e, 0x0005, 0x080c, 0x174b, 0x601c, 0xc0bd, 0x601e,
+	0x08e0, 0x00b6, 0x0096, 0x0016, 0x20a9, 0x0800, 0x900e, 0x0016,
+	0x080c, 0x6644, 0x1158, 0xb8d0, 0x904d, 0x0140, 0x3e00, 0x9086,
+	0x0002, 0x1118, 0xb800, 0xd0bc, 0x1108, 0x0041, 0x001e, 0x8108,
+	0x1f04, 0x67d7, 0x001e, 0x00be, 0x009e, 0x0005, 0x0096, 0x0016,
+	0xb8d0, 0x904d, 0x0188, 0xa800, 0xb8d2, 0x9005, 0x1108, 0xb8ce,
+	0x9006, 0xa802, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
+	0xcb68, 0x080c, 0x6d9f, 0x0c60, 0x001e, 0x009e, 0x0005, 0x0086,
+	0x9046, 0xb8d0, 0x904d, 0x01b0, 0xa86c, 0x9406, 0x1118, 0xa870,
+	0x9506, 0x0128, 0x2940, 0xa800, 0x904d, 0x0160, 0x0ca8, 0xa800,
+	0x88ff, 0x1128, 0xb8d2, 0x9005, 0x1118, 0xb8ce, 0x0008, 0xa002,
+	0xa803, 0x0000, 0x008e, 0x0005, 0x901e, 0x0010, 0x2019, 0x0001,
+	0x0126, 0x2091, 0x8000, 0x00e6, 0x0096, 0x00c6, 0x0086, 0x0026,
+	0x2071, 0x19e6, 0x9046, 0x7028, 0x9065, 0x01e8, 0x6014, 0x2068,
+	0x83ff, 0x0120, 0x605c, 0x9606, 0x0158, 0x0030, 0xa86c, 0x9406,
+	0x1118, 0xa870, 0x9506, 0x0120, 0x2c40, 0x600c, 0x2060, 0x0c60,
+	0x600c, 0x0006, 0x0066, 0x2830, 0x080c, 0x9fbd, 0x006e, 0x000e,
+	0x83ff, 0x0508, 0x0c08, 0x9046, 0xb8d0, 0x904d, 0x01e0, 0x83ff,
+	0x0120, 0xa878, 0x9606, 0x0158, 0x0030, 0xa86c, 0x9406, 0x1118,
+	0xa870, 0x9506, 0x0120, 0x2940, 0xa800, 0x2048, 0x0c70, 0xb8d0,
+	0xaa00, 0x0026, 0x9906, 0x1110, 0xbad2, 0x0008, 0xa202, 0x000e,
+	0x83ff, 0x0108, 0x0c10, 0x002e, 0x008e, 0x00ce, 0x009e, 0x00ee,
+	0x012e, 0x0005, 0x9016, 0x0489, 0x1110, 0x2011, 0x0001, 0x0005,
+	0x080c, 0x6937, 0x0128, 0x080c, 0xc926, 0x0010, 0x9085, 0x0001,
+	0x0005, 0x080c, 0x6937, 0x0128, 0x080c, 0xc8c7, 0x0010, 0x9085,
+	0x0001, 0x0005, 0x080c, 0x6937, 0x0128, 0x080c, 0xc923, 0x0010,
+	0x9085, 0x0001, 0x0005, 0x080c, 0x6937, 0x0128, 0x080c, 0xc8e6,
+	0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6937, 0x0128, 0x080c,
+	0xc967, 0x0010, 0x9085, 0x0001, 0x0005, 0xb8a4, 0x900d, 0x1118,
+	0x9085, 0x0001, 0x0005, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8,
+	0x890e, 0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0,
+	0x9080, 0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002,
+	0x9606, 0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0008, 0x9006,
+	0x01ce, 0x013e, 0x0005, 0x0146, 0x01d6, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x0004, 0x20a0, 0x20a9, 0x0010, 0x2009, 0xffff, 0x4104,
+	0x01de, 0x014e, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e,
+	0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080,
+	0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606,
+	0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0068, 0x0146, 0x01d6,
+	0x3300, 0x8001, 0x20a0, 0x3c00, 0x20e8, 0x2001, 0xffff, 0x4004,
+	0x01de, 0x014e, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0096, 0x0126,
+	0x2091, 0x8000, 0xb8a4, 0x904d, 0x1128, 0x080c, 0x1047, 0x0168,
+	0x2900, 0xb8a6, 0x080c, 0x68d3, 0xa803, 0x0001, 0xa807, 0x0000,
+	0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0096,
+	0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d, 0x0130, 0xb8a7, 0x0000,
+	0x080c, 0x1079, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0xb89c,
+	0xd0a4, 0x0005, 0x00b6, 0x00f6, 0x080c, 0x74ec, 0x01b0, 0x71c4,
+	0x81ff, 0x1198, 0x71dc, 0xd19c, 0x0180, 0x2001, 0x007e, 0x9080,
+	0x1000, 0x2004, 0x905d, 0x0148, 0xb804, 0x9084, 0x00ff, 0x9086,
+	0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x2079, 0x1847, 0x7804,
+	0xd0a4, 0x01d0, 0x0156, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c,
+	0x6644, 0x1168, 0xb804, 0x9084, 0xff00, 0x8007, 0x9096, 0x0004,
+	0x0118, 0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x001e,
+	0x8108, 0x1f04, 0x695e, 0x015e, 0x080c, 0x6a4c, 0x0120, 0x2001,
+	0x1984, 0x200c, 0x0038, 0x2079, 0x1847, 0x7804, 0xd0a4, 0x0130,
+	0x2009, 0x07d0, 0x2011, 0x6989, 0x080c, 0x871b, 0x00fe, 0x00be,
+	0x0005, 0x00b6, 0x2011, 0x6989, 0x080c, 0x8651, 0x080c, 0x6a4c,
+	0x01d8, 0x2001, 0x107e, 0x2004, 0x2058, 0xb900, 0xc1ec, 0xb902,
+	0x080c, 0x6a8a, 0x0130, 0x2009, 0x07d0, 0x2011, 0x6989, 0x080c,
+	0x871b, 0x00e6, 0x2071, 0x1800, 0x9006, 0x707e, 0x7060, 0x7082,
+	0x080c, 0x2fe0, 0x00ee, 0x04d0, 0x0156, 0x00c6, 0x20a9, 0x007f,
+	0x900e, 0x0016, 0x080c, 0x6644, 0x1558, 0xb800, 0xd0ec, 0x0540,
+	0x0046, 0xbaa0, 0x2220, 0x9006, 0x2009, 0x0029, 0x080c, 0xe316,
+	0xb800, 0xc0e5, 0xc0ec, 0xb802, 0x080c, 0x6a86, 0x2001, 0x0707,
+	0x1128, 0xb804, 0x9084, 0x00ff, 0x9085, 0x0700, 0xb806, 0x080c,
+	0xa899, 0x2019, 0x0029, 0x080c, 0x93c6, 0x0076, 0x903e, 0x080c,
+	0x928f, 0x900e, 0x080c, 0xe038, 0x007e, 0x004e, 0x080c, 0xa8b5,
+	0x001e, 0x8108, 0x1f04, 0x69b1, 0x00ce, 0x015e, 0x00be, 0x0005,
+	0x00b6, 0x6010, 0x2058, 0xb800, 0xc0ec, 0xb802, 0x00be, 0x0005,
+	0x00b6, 0x00c6, 0x0096, 0x080c, 0x1060, 0x090c, 0x0d7d, 0x2958,
+	0x009e, 0x2001, 0x196a, 0x2b02, 0x8b07, 0x8006, 0x8006, 0x908c,
+	0x003f, 0xb9c6, 0x908c, 0xffc0, 0xb9ca, 0xb8af, 0x0000, 0x2009,
+	0x00ff, 0x080c, 0x605e, 0xb807, 0x0006, 0xb813, 0x00ff, 0xb817,
+	0xffff, 0xb86f, 0x0200, 0xb86c, 0xb893, 0x0002, 0xb8bb, 0x0520,
+	0xb8a3, 0x00ff, 0xb8af, 0x0000, 0x00ce, 0x00be, 0x0005, 0x7810,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ac, 0x0005, 0x6010, 0x00b6,
+	0x905d, 0x0108, 0xb800, 0x00be, 0xd0bc, 0x0005, 0x0006, 0x0016,
+	0x0026, 0xb804, 0x908c, 0x00ff, 0x9196, 0x0006, 0x0188, 0x9196,
+	0x0004, 0x0170, 0x9196, 0x0005, 0x0158, 0x908c, 0xff00, 0x810f,
+	0x9196, 0x0006, 0x0128, 0x9196, 0x0004, 0x0110, 0x9196, 0x0005,
+	0x002e, 0x001e, 0x000e, 0x0005, 0x00b6, 0x00f6, 0x2001, 0x107e,
+	0x2004, 0x905d, 0x0110, 0xb800, 0xd0ec, 0x00fe, 0x00be, 0x0005,
+	0x0126, 0x0026, 0x2091, 0x8000, 0x0006, 0xbaa0, 0x9290, 0x1000,
+	0x2204, 0x9b06, 0x190c, 0x0d7d, 0x000e, 0xba00, 0x9005, 0x0110,
+	0xc2fd, 0x0008, 0xc2fc, 0xba02, 0x002e, 0x012e, 0x0005, 0x2011,
+	0x1837, 0x2204, 0xd0cc, 0x0138, 0x2001, 0x1982, 0x200c, 0x2011,
+	0x6a7c, 0x080c, 0x871b, 0x0005, 0x2011, 0x6a7c, 0x080c, 0x8651,
+	0x2011, 0x1837, 0x2204, 0xc0cc, 0x2012, 0x0005, 0x080c, 0x56f5,
+	0xd0ac, 0x0005, 0x080c, 0x56f5, 0xd0a4, 0x0005, 0x0016, 0xb904,
+	0x9184, 0x00ff, 0x908e, 0x0006, 0x001e, 0x0005, 0x0016, 0xb904,
+	0x9184, 0xff00, 0x8007, 0x908e, 0x0006, 0x001e, 0x0005, 0x00b6,
+	0x00f6, 0x080c, 0xcf84, 0x0158, 0x70dc, 0x9084, 0x0028, 0x0138,
+	0x2001, 0x107f, 0x2004, 0x905d, 0x0110, 0xb8d4, 0xd094, 0x00fe,
+	0x00be, 0x0005, 0x2071, 0x1910, 0x7003, 0x0001, 0x7007, 0x0000,
+	0x9006, 0x7012, 0x7016, 0x701a, 0x701e, 0x700a, 0x7046, 0x0005,
+	0x0016, 0x00e6, 0x2071, 0x1947, 0x900e, 0x710a, 0x080c, 0x56f5,
+	0xd0fc, 0x1140, 0x080c, 0x56f5, 0x900e, 0xd09c, 0x0108, 0x8108,
+	0x7102, 0x00f8, 0x2001, 0x1867, 0x200c, 0x9184, 0x0007, 0x0002,
+	0x6aca, 0x6aca, 0x6aca, 0x6aca, 0x6aca, 0x6ae0, 0x6aee, 0x6aca,
+	0x7003, 0x0003, 0x2009, 0x1868, 0x210c, 0x9184, 0xff00, 0x8007,
+	0x9005, 0x1110, 0x2001, 0x0002, 0x7006, 0x0018, 0x7003, 0x0005,
+	0x0c88, 0x00ee, 0x001e, 0x0005, 0x00e6, 0x2071, 0x0050, 0x684c,
+	0x9005, 0x1150, 0x00e6, 0x2071, 0x1910, 0x7028, 0xc085, 0x702a,
+	0x00ee, 0x9085, 0x0001, 0x0488, 0x6844, 0x9005, 0x0158, 0x080c,
+	0x7861, 0x6a60, 0x9200, 0x7002, 0x6864, 0x9101, 0x7006, 0x9006,
+	0x7012, 0x7016, 0x6860, 0x7002, 0x6864, 0x7006, 0x6868, 0x700a,
+	0x686c, 0x700e, 0x6844, 0x9005, 0x1110, 0x7012, 0x7016, 0x684c,
+	0x701a, 0x701c, 0x9085, 0x0040, 0x701e, 0x7037, 0x0019, 0x702b,
+	0x0001, 0x00e6, 0x2071, 0x1910, 0x7028, 0xc084, 0x702a, 0x7007,
+	0x0001, 0x700b, 0x0000, 0x00ee, 0x9006, 0x00ee, 0x0005, 0x00e6,
+	0x0026, 0x2071, 0x1947, 0x7000, 0x9015, 0x0904, 0x6da4, 0x9286,
+	0x0003, 0x0904, 0x6c34, 0x9286, 0x0005, 0x0904, 0x6c34, 0x2071,
+	0x1877, 0xa87c, 0x9005, 0x0904, 0x6b95, 0x7140, 0xa868, 0x9102,
+	0x0a04, 0x6da4, 0xa878, 0xd084, 0x15d8, 0xa853, 0x0019, 0x2001,
+	0x8023, 0xa84e, 0x2071, 0x1910, 0x701c, 0x9005, 0x1904, 0x6f3b,
+	0x0e04, 0x6fa9, 0x2071, 0x0000, 0xa850, 0x7032, 0xa84c, 0x7082,
+	0xa870, 0x7086, 0xa86c, 0x708a, 0xa880, 0x708e, 0x7036, 0x0146,
+	0x01d6, 0x0136, 0x01c6, 0x0156, 0x20e9, 0x0000, 0x20a1, 0x002a,
+	0xa868, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098,
+	0x4003, 0x015e, 0x01ce, 0x013e, 0x01de, 0x014e, 0x2091, 0x4080,
+	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11ee, 0x0804, 0x6c17,
+	0xa853, 0x001b, 0x2001, 0x8027, 0x0820, 0x7004, 0xd08c, 0x1904,
+	0x6da4, 0xa853, 0x001a, 0x2001, 0x8024, 0x0804, 0x6b59, 0x00e6,
+	0x0026, 0x2071, 0x1947, 0x7000, 0x9015, 0x0904, 0x6da4, 0x9286,
+	0x0003, 0x0904, 0x6c34, 0x9286, 0x0005, 0x0904, 0x6c34, 0xa84f,
+	0x8022, 0xa853, 0x0018, 0x0804, 0x6bfc, 0xa868, 0xd0fc, 0x11d8,
+	0x00e6, 0x0026, 0x2001, 0x1947, 0x2004, 0x9005, 0x0904, 0x6da4,
+	0xa87c, 0xd0bc, 0x1904, 0x6da4, 0xa978, 0xa874, 0x9105, 0x1904,
+	0x6da4, 0x2001, 0x1947, 0x2004, 0x0002, 0x6da4, 0x6bf8, 0x6c34,
+	0x6c34, 0x6da4, 0x6c34, 0x0005, 0xa868, 0xd0fc, 0x1500, 0x00e6,
+	0x0026, 0x2009, 0x1947, 0x210c, 0x81ff, 0x0904, 0x6da4, 0xa87c,
+	0xd0cc, 0x0904, 0x6da4, 0xa880, 0x9084, 0x00ff, 0x9086, 0x0001,
+	0x1904, 0x6da4, 0x9186, 0x0003, 0x0904, 0x6c34, 0x9186, 0x0005,
+	0x0904, 0x6c34, 0xa84f, 0x8021, 0xa853, 0x0017, 0x0028, 0x0005,
+	0xa84f, 0x8020, 0xa853, 0x0016, 0x2071, 0x1910, 0x701c, 0x9005,
+	0x1904, 0x6f3b, 0x0e04, 0x6fa9, 0x2071, 0x0000, 0xa84c, 0x7082,
+	0xa850, 0x7032, 0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11ee, 0x2071,
+	0x1800, 0x2011, 0x0001, 0xa804, 0x900d, 0x702c, 0x1158, 0xa802,
+	0x2900, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x8566, 0x002e,
+	0x00ee, 0x0005, 0x0096, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x009e, 0x0c58, 0xa84f, 0x0000, 0x00f6, 0x2079,
+	0x0050, 0x2071, 0x1910, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904,
+	0x6d29, 0x782c, 0x908c, 0x0780, 0x190c, 0x70f5, 0x8004, 0x8004,
+	0x8004, 0x9084, 0x0003, 0x0002, 0x6c52, 0x6d29, 0x6c77, 0x6cc4,
+	0x080c, 0x0d7d, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d,
+	0x1170, 0x2071, 0x1a02, 0x703c, 0x9005, 0x1328, 0x2001, 0x1948,
+	0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016,
+	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
+	0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x8566, 0x0c10, 0x2071,
+	0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x15a8, 0x7824, 0x00e6,
+	0x2071, 0x0040, 0x712c, 0xd19c, 0x1170, 0x2009, 0x1830, 0x210c,
+	0x918a, 0x0020, 0x0240, 0x7022, 0x2001, 0x1dc0, 0x200c, 0x8108,
+	0x2102, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900,
+	0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x8566, 0x782c, 0x9094,
+	0x0780, 0x190c, 0x70f5, 0xd0a4, 0x19c8, 0x2071, 0x1a02, 0x703c,
 	0x9005, 0x1328, 0x2001, 0x1948, 0x2004, 0x8005, 0x703e, 0x00fe,
 	0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
 	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2,
-	0x080c, 0x8532, 0x0c10, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804,
-	0x900d, 0x15a8, 0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c,
-	0x1170, 0x2009, 0x1830, 0x210c, 0x918a, 0x0020, 0x0240, 0x7022,
-	0x2001, 0x1dc0, 0x200c, 0x8108, 0x2102, 0x00ee, 0x0058, 0x00ee,
-	0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2,
-	0x080c, 0x8532, 0x782c, 0x9094, 0x0780, 0x190c, 0x70d1, 0xd0a4,
-	0x19c8, 0x2071, 0x1a02, 0x703c, 0x9005, 0x1328, 0x2001, 0x1948,
-	0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016,
-	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
-	0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x8532, 0x0804, 0x6c5a,
-	0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802,
-	0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x8532, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x70d1, 0xd0a4, 0x1d60, 0x00ee, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x70d1, 0xd09c, 0x11a0, 0x009e, 0x2900,
-	0x7822, 0xa804, 0x900d, 0x1560, 0x2071, 0x1a02, 0x703c, 0x9005,
-	0x1328, 0x2001, 0x1948, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e,
-	0x00ee, 0x0005, 0x009e, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018,
-	0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804,
-	0x900d, 0x1170, 0x2071, 0x1a02, 0x703c, 0x9005, 0x1328, 0x2001,
-	0x1948, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
-	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c,
-	0x8532, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908, 0x7010, 0x8000,
-	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
-	0x2148, 0xa804, 0x900d, 0x1904, 0x6d5a, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x70d1, 0xd09c, 0x1198, 0x701c, 0x904d, 0x0180, 0x7010,
-	0x8001, 0x7012, 0x1108, 0x701a, 0xa800, 0x701e, 0x2900, 0x7822,
-	0x782c, 0x9094, 0x0780, 0x190c, 0x70d1, 0xd09c, 0x0d68, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x70d1, 0xd0a4, 0x01b0, 0x00e6, 0x7824,
-	0x2048, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0,
-	0x8000, 0x70c2, 0x080c, 0x8532, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x70d1, 0xd0a4, 0x1d60, 0x00ee, 0x2071, 0x1a02, 0x703c, 0x9005,
-	0x1328, 0x2001, 0x1948, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e,
-	0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
-	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0,
-	0x9200, 0x70c2, 0x080c, 0x8532, 0x00ee, 0x0804, 0x6d15, 0xa868,
-	0xd0fc, 0x1560, 0x0096, 0xa804, 0xa807, 0x0000, 0x904d, 0x190c,
-	0x0fec, 0x009e, 0x0018, 0xa868, 0xd0fc, 0x1500, 0x00e6, 0x0026,
-	0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050, 0x2071, 0x1910, 0xa803,
-	0x0000, 0x7010, 0x9005, 0x1904, 0x6e95, 0x782c, 0x908c, 0x0780,
-	0x190c, 0x70d1, 0x8004, 0x8004, 0x8004, 0x9084, 0x0003, 0x0002,
-	0x6d9f, 0x6e95, 0x6dba, 0x6e28, 0x080c, 0x0d7d, 0x0005, 0x2071,
-	0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1120, 0x00fe, 0x002e,
-	0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
-	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c,
-	0x8532, 0x0c60, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d,
-	0x1904, 0x6e17, 0x7830, 0xd0dc, 0x1120, 0x00fe, 0x002e, 0x00ee,
-	0x0005, 0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1170,
-	0x2009, 0x1830, 0x210c, 0x918a, 0x0020, 0x0240, 0x7022, 0x2001,
-	0x1dc0, 0x200c, 0x8108, 0x2102, 0x00ee, 0x0058, 0x00ee, 0x2048,
-	0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c,
-	0x8532, 0x782c, 0x9094, 0x0780, 0x190c, 0x70d1, 0xd0a4, 0x19c8,
-	0x0e04, 0x6e0e, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069,
-	0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2001, 0x1921, 0x200c,
-	0xc184, 0x2102, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x11e1, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2001, 0x1921,
-	0x200c, 0xc185, 0x2102, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016,
-	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
-	0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x8532, 0x0804, 0x6dc9,
-	0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802,
-	0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x8532, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x70d1, 0xd0a4, 0x1d60, 0x00ee, 0x0e04,
-	0x6e68, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
-	0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084, 0x7046, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11e1, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x70d1, 0xd09c, 0x1170, 0x009e, 0x2900,
-	0x7822, 0xa804, 0x900d, 0x11e0, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x7044, 0xc085, 0x7046, 0x0c58, 0x009e, 0x2908, 0x7010, 0x8000,
-	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
-	0x2148, 0xa804, 0x900d, 0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
-	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c,
-	0x8532, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908, 0x7010, 0x8000,
-	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
-	0x2148, 0xa804, 0x900d, 0x1904, 0x6f02, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x70d1, 0xd09c, 0x11b0, 0x701c, 0x904d, 0x0198, 0xa84c,
-	0x9005, 0x1180, 0x7010, 0x8001, 0x7012, 0x1108, 0x701a, 0xa800,
-	0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780, 0x190c, 0x70d1,
-	0xd09c, 0x0d50, 0x782c, 0x9094, 0x0780, 0x190c, 0x70d1, 0xd0a4,
-	0x05a8, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802,
-	0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x8532, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x70d1, 0xd0a4, 0x1d60, 0x00ee, 0x0e04,
-	0x6efb, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
-	0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084, 0x7046, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11e1, 0x00fe,
-	0x002e, 0x00ee, 0x0005, 0x7044, 0xc085, 0x7046, 0x00fe, 0x002e,
-	0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
-	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0,
-	0x9200, 0x70c2, 0x080c, 0x8532, 0x00ee, 0x0804, 0x6ea5, 0x2071,
-	0x1910, 0xa803, 0x0000, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018,
-	0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804,
-	0x900d, 0x1128, 0x1e04, 0x6f42, 0x002e, 0x00ee, 0x0005, 0x2071,
+	0x080c, 0x8566, 0x0804, 0x6c7e, 0x0096, 0x00e6, 0x7824, 0x2048,
+	0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000,
+	0x70c2, 0x080c, 0x8566, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5,
+	0xd0a4, 0x1d60, 0x00ee, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5,
+	0xd09c, 0x11a0, 0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x1560,
+	0x2071, 0x1a02, 0x703c, 0x9005, 0x1328, 0x2001, 0x1948, 0x2004,
+	0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x009e, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1170, 0x2071, 0x1a02,
+	0x703c, 0x9005, 0x1328, 0x2001, 0x1948, 0x2004, 0x8005, 0x703e,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c,
+	0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e,
+	0x70c0, 0x9200, 0x70c2, 0x080c, 0x8566, 0x00fe, 0x002e, 0x00ee,
+	0x0005, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
+	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904,
+	0x6d7e, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5, 0xd09c, 0x1198,
+	0x701c, 0x904d, 0x0180, 0x7010, 0x8001, 0x7012, 0x1108, 0x701a,
+	0xa800, 0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780, 0x190c,
+	0x70f5, 0xd09c, 0x0d68, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5,
+	0xd0a4, 0x01b0, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c,
+	0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x8566,
+	0x782c, 0x9094, 0x0780, 0x190c, 0x70f5, 0xd0a4, 0x1d60, 0x00ee,
+	0x2071, 0x1a02, 0x703c, 0x9005, 0x1328, 0x2001, 0x1948, 0x2004,
+	0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071,
 	0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
-	0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x8532,
-	0x0e04, 0x6f2c, 0x2071, 0x1910, 0x701c, 0x2048, 0xa84c, 0x900d,
-	0x0d18, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032, 0xa86c, 0x7086,
-	0x7036, 0xa870, 0x708a, 0xa850, 0x9082, 0x0019, 0x1278, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11e1, 0x2071,
-	0x1910, 0x080c, 0x70bd, 0x002e, 0x00ee, 0x0005, 0xa850, 0x9082,
-	0x001c, 0x1e68, 0xa880, 0x708e, 0x7036, 0x0146, 0x01d6, 0x0136,
-	0x01c6, 0x0156, 0x20e9, 0x0000, 0x20a1, 0x002a, 0xa868, 0x20a8,
-	0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098, 0x4003, 0x015e,
-	0x01ce, 0x013e, 0x01de, 0x014e, 0x0890, 0x2071, 0x1910, 0xa803,
-	0x0000, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
-	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1118,
+	0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x8566,
+	0x00ee, 0x0804, 0x6d39, 0xa868, 0xd0fc, 0x1560, 0x0096, 0xa804,
+	0xa807, 0x0000, 0x904d, 0x190c, 0x0ff9, 0x009e, 0x0018, 0xa868,
+	0xd0fc, 0x1500, 0x00e6, 0x0026, 0xa84f, 0x0000, 0x00f6, 0x2079,
+	0x0050, 0x2071, 0x1910, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904,
+	0x6eb9, 0x782c, 0x908c, 0x0780, 0x190c, 0x70f5, 0x8004, 0x8004,
+	0x8004, 0x9084, 0x0003, 0x0002, 0x6dc3, 0x6eb9, 0x6dde, 0x6e4c,
+	0x080c, 0x0d7d, 0x0005, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804,
+	0x900d, 0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c,
+	0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e,
+	0x70c0, 0x9200, 0x70c2, 0x080c, 0x8566, 0x0c60, 0x2071, 0x1800,
+	0x2900, 0x7822, 0xa804, 0x900d, 0x1904, 0x6e3b, 0x7830, 0xd0dc,
+	0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7824, 0x00e6, 0x2071,
+	0x0040, 0x712c, 0xd19c, 0x1170, 0x2009, 0x1830, 0x210c, 0x918a,
+	0x0020, 0x0240, 0x7022, 0x2001, 0x1dc0, 0x200c, 0x8108, 0x2102,
+	0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e,
+	0x70c0, 0x8000, 0x70c2, 0x080c, 0x8566, 0x782c, 0x9094, 0x0780,
+	0x190c, 0x70f5, 0xd0a4, 0x19c8, 0x0e04, 0x6e32, 0x7838, 0x7938,
+	0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013,
+	0x00de, 0x2001, 0x1921, 0x200c, 0xc184, 0x2102, 0x2091, 0x4080,
+	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11ee, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x2001, 0x1921, 0x200c, 0xc185, 0x2102, 0x00fe,
+	0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
+	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2,
+	0x080c, 0x8566, 0x0804, 0x6ded, 0x0096, 0x00e6, 0x7824, 0x2048,
+	0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000,
+	0x70c2, 0x080c, 0x8566, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5,
+	0xd0a4, 0x1d60, 0x00ee, 0x0e04, 0x6e8c, 0x7838, 0x7938, 0x910e,
+	0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de,
+	0x7044, 0xc084, 0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
+	0xd084, 0x190c, 0x11ee, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5,
+	0xd09c, 0x1170, 0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x11e0,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x7044, 0xc085, 0x7046, 0x0c58,
+	0x009e, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
+	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1120,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c,
+	0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e,
+	0x70c0, 0x9200, 0x70c2, 0x080c, 0x8566, 0x00fe, 0x002e, 0x00ee,
+	0x0005, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
+	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904,
+	0x6f26, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5, 0xd09c, 0x11b0,
+	0x701c, 0x904d, 0x0198, 0xa84c, 0x9005, 0x1180, 0x7010, 0x8001,
+	0x7012, 0x1108, 0x701a, 0xa800, 0x701e, 0x2900, 0x7822, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x70f5, 0xd09c, 0x0d50, 0x782c, 0x9094,
+	0x0780, 0x190c, 0x70f5, 0xd0a4, 0x05a8, 0x00e6, 0x7824, 0x2048,
+	0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0, 0x8000,
+	0x70c2, 0x080c, 0x8566, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5,
+	0xd0a4, 0x1d60, 0x00ee, 0x0e04, 0x6f1f, 0x7838, 0x7938, 0x910e,
+	0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de,
+	0x7044, 0xc084, 0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
+	0xd084, 0x190c, 0x11ee, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7044,
+	0xc085, 0x7046, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071,
+	0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x8566,
+	0x00ee, 0x0804, 0x6ec9, 0x2071, 0x1910, 0xa803, 0x0000, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1128, 0x1e04, 0x6f66,
 	0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
 	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70c0,
-	0x9200, 0x70c2, 0x080c, 0x8532, 0x002e, 0x00ee, 0x0005, 0x0006,
-	0xa87c, 0x0006, 0xa867, 0x0103, 0x20a9, 0x001c, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x001d, 0x20a0, 0x9006, 0x4004, 0x000e, 0x9084,
-	0x00ff, 0xa87e, 0x000e, 0xa87a, 0xa982, 0x0005, 0x2071, 0x1910,
-	0x7004, 0x0002, 0x6fd0, 0x6fd1, 0x70bc, 0x6fd1, 0x0d7d, 0x70bc,
-	0x0005, 0x2001, 0x1947, 0x2004, 0x0002, 0x6fdb, 0x6fdb, 0x7055,
-	0x7056, 0x6fdb, 0x7056, 0x0126, 0x2091, 0x8000, 0x1e0c, 0x70dc,
-	0x701c, 0x904d, 0x0508, 0xa84c, 0x9005, 0x0904, 0x7026, 0x0e04,
-	0x7004, 0xa94c, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032, 0xa86c,
-	0x7086, 0x7036, 0xa870, 0x708a, 0xa850, 0x9082, 0x0019, 0x1278,
-	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11e1,
-	0x2071, 0x1910, 0x080c, 0x70bd, 0x012e, 0x0804, 0x7054, 0xa850,
-	0x9082, 0x001c, 0x1e68, 0xa880, 0x708e, 0x7036, 0x0146, 0x01d6,
-	0x0136, 0x01c6, 0x0156, 0x20e9, 0x0000, 0x20a1, 0x002a, 0xa868,
-	0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098, 0x4003,
-	0x015e, 0x01ce, 0x013e, 0x01de, 0x014e, 0x0890, 0x2001, 0x005b,
-	0x2004, 0x9094, 0x0780, 0x190c, 0x70d1, 0xd09c, 0x2071, 0x1910,
-	0x1510, 0x2071, 0x1910, 0x700f, 0x0001, 0xa964, 0x9184, 0x00ff,
-	0x9086, 0x0003, 0x1130, 0x810f, 0x918c, 0x00ff, 0x8101, 0x0108,
-	0x710e, 0x2900, 0x00d6, 0x2069, 0x0050, 0x6822, 0x00de, 0x2071,
-	0x1910, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012, 0xa800, 0x701e,
-	0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005, 0x00d6, 0x2008,
-	0x2069, 0x1a02, 0x683c, 0x9005, 0x0760, 0x0158, 0x9186, 0x0003,
-	0x0540, 0x2001, 0x1815, 0x2004, 0x2009, 0x1b4d, 0x210c, 0x9102,
-	0x1500, 0x0126, 0x2091, 0x8000, 0x2069, 0x0050, 0x693c, 0x6838,
-	0x9106, 0x0190, 0x0e04, 0x7088, 0x2069, 0x0000, 0x6837, 0x8040,
-	0x6833, 0x0012, 0x6883, 0x8040, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x190c, 0x11e1, 0x2069, 0x1a02, 0x683f, 0xffff,
-	0x012e, 0x00de, 0x0126, 0x2091, 0x8000, 0x1e0c, 0x7142, 0x701c,
-	0x904d, 0x0540, 0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x15c9,
-	0xd09c, 0x1500, 0x2071, 0x1910, 0x700f, 0x0001, 0xa964, 0x9184,
-	0x00ff, 0x9086, 0x0003, 0x1130, 0x810f, 0x918c, 0x00ff, 0x8101,
-	0x0108, 0x710e, 0x2900, 0x00d6, 0x2069, 0x0050, 0x6822, 0x00de,
-	0x701c, 0x2048, 0x7010, 0x8001, 0x7012, 0xa800, 0x701e, 0x9005,
-	0x1108, 0x701a, 0x012e, 0x0005, 0x0005, 0x0126, 0x2091, 0x8000,
-	0x701c, 0x904d, 0x0160, 0x7010, 0x8001, 0x7012, 0xa800, 0x701e,
-	0x9005, 0x1108, 0x701a, 0x012e, 0x080c, 0x106c, 0x0005, 0x012e,
-	0x0005, 0x2091, 0x8000, 0x0e04, 0x70d3, 0x0006, 0x0016, 0x2001,
-	0x8004, 0x0006, 0x0804, 0x0d86, 0x0096, 0x00f6, 0x2079, 0x0050,
-	0x7044, 0xd084, 0x01c0, 0xc084, 0x7046, 0x7838, 0x7938, 0x910e,
-	0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de,
-	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11e1,
-	0x00fe, 0x009e, 0x0005, 0x782c, 0x9094, 0x0780, 0x1991, 0xd0a4,
-	0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x00e6, 0x2071, 0x0040,
-	0x712c, 0xd19c, 0x1170, 0x2009, 0x1830, 0x210c, 0x918a, 0x0020,
-	0x0240, 0x7022, 0x2001, 0x1dc0, 0x200c, 0x8108, 0x2102, 0x00ee,
-	0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0,
-	0x8000, 0x70c2, 0x080c, 0x8532, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x70d1, 0xd0a4, 0x19c8, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6,
-	0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11e1, 0x00ee, 0x00fe,
-	0x009e, 0x0005, 0x00f6, 0x2079, 0x0050, 0x7044, 0xd084, 0x01b8,
-	0xc084, 0x7046, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069,
-	0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001,
-	0x0089, 0x2004, 0xd084, 0x190c, 0x11e1, 0x00fe, 0x0005, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x70d1, 0xd0a4, 0x0db8, 0x00e6, 0x2071,
-	0x1800, 0x7824, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70c0,
-	0x8000, 0x70c2, 0x080c, 0x8532, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x70d1, 0xd0a4, 0x1d70, 0x00d6, 0x2069, 0x0050, 0x693c, 0x2069,
-	0x1947, 0x6808, 0x690a, 0x2069, 0x1a02, 0x9102, 0x1118, 0x683c,
-	0x9005, 0x1328, 0x2001, 0x1948, 0x200c, 0x810d, 0x693e, 0x00de,
-	0x00ee, 0x00fe, 0x0005, 0x7098, 0x908a, 0x0029, 0x1a0c, 0x0d7d,
-	0x9082, 0x001d, 0x003b, 0x0026, 0x2011, 0x1e00, 0x080c, 0x2a63,
-	0x002e, 0x0005, 0x726e, 0x71f4, 0x7210, 0x723a, 0x725d, 0x729d,
-	0x72af, 0x7210, 0x7285, 0x71af, 0x71dd, 0x71ae, 0x0005, 0x00d6,
-	0x2069, 0x0200, 0x6804, 0x9005, 0x1180, 0x6808, 0x9005, 0x1518,
-	0x709b, 0x0028, 0x2069, 0x198e, 0x2d04, 0x7002, 0x080c, 0x760a,
-	0x6028, 0x9085, 0x0600, 0x602a, 0x00b0, 0x709b, 0x0028, 0x2069,
-	0x198e, 0x2d04, 0x7002, 0x6028, 0x9085, 0x0600, 0x602a, 0x00e6,
-	0x0036, 0x0046, 0x0056, 0x2071, 0x1a6a, 0x080c, 0x1ac2, 0x005e,
-	0x004e, 0x003e, 0x00ee, 0x00de, 0x0005, 0x00d6, 0x2069, 0x0200,
-	0x6804, 0x9005, 0x1178, 0x6808, 0x9005, 0x1160, 0x709b, 0x0028,
-	0x2069, 0x198e, 0x2d04, 0x7002, 0x080c, 0x76ad, 0x6028, 0x9085,
-	0x0600, 0x602a, 0x00de, 0x0005, 0x0006, 0x2001, 0x0090, 0x080c,
-	0x2a29, 0x000e, 0x6124, 0xd1e4, 0x1190, 0x080c, 0x7320, 0xd1d4,
-	0x1160, 0xd1dc, 0x1138, 0xd1cc, 0x0150, 0x709b, 0x0020, 0x080c,
-	0x7320, 0x0028, 0x709b, 0x001d, 0x0010, 0x709b, 0x001f, 0x0005,
-	0x2001, 0x0088, 0x080c, 0x2a29, 0x6124, 0xd1cc, 0x11e8, 0xd1dc,
-	0x11c0, 0xd1e4, 0x1198, 0x9184, 0x1e00, 0x11d8, 0x080c, 0x1aec,
-	0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c, 0x74f4, 0x2001,
-	0x0080, 0x080c, 0x2a29, 0x709b, 0x0028, 0x0058, 0x709b, 0x001e,
-	0x0040, 0x709b, 0x001d, 0x0028, 0x709b, 0x0020, 0x0010, 0x709b,
-	0x001f, 0x0005, 0x080c, 0x1aec, 0x60e3, 0x0001, 0x600c, 0xc0b4,
-	0x600e, 0x080c, 0x74f4, 0x2001, 0x0080, 0x080c, 0x2a29, 0x6124,
-	0xd1d4, 0x1180, 0xd1dc, 0x1158, 0xd1e4, 0x1130, 0x9184, 0x1e00,
-	0x1158, 0x709b, 0x0028, 0x0040, 0x709b, 0x001e, 0x0028, 0x709b,
-	0x001d, 0x0010, 0x709b, 0x001f, 0x0005, 0x2001, 0x00a0, 0x080c,
-	0x2a29, 0x6124, 0xd1dc, 0x1138, 0xd1e4, 0x0138, 0x080c, 0x1aec,
-	0x709b, 0x001e, 0x0010, 0x709b, 0x001d, 0x0005, 0x080c, 0x73a9,
-	0x6124, 0xd1dc, 0x1188, 0x080c, 0x7320, 0x0016, 0x080c, 0x1aec,
-	0x001e, 0xd1d4, 0x1128, 0xd1e4, 0x0138, 0x709b, 0x001e, 0x0020,
-	0x709b, 0x001f, 0x080c, 0x7320, 0x0005, 0x0006, 0x2001, 0x00a0,
-	0x080c, 0x2a29, 0x000e, 0x6124, 0xd1d4, 0x1160, 0xd1cc, 0x1150,
-	0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x709b, 0x001e, 0x0028, 0x709b,
-	0x001d, 0x0010, 0x709b, 0x0021, 0x0005, 0x080c, 0x73a9, 0x6124,
-	0xd1d4, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x709b, 0x001e,
-	0x0028, 0x709b, 0x001d, 0x0010, 0x709b, 0x001f, 0x0005, 0x0006,
-	0x2001, 0x0090, 0x080c, 0x2a29, 0x000e, 0x6124, 0xd1d4, 0x1178,
-	0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0158, 0x709b, 0x001e,
-	0x0040, 0x709b, 0x001d, 0x0028, 0x709b, 0x0020, 0x0010, 0x709b,
-	0x001f, 0x0005, 0x0016, 0x00c6, 0x00d6, 0x00e6, 0x0126, 0x2061,
-	0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2091, 0x8000, 0x080c,
-	0x74c8, 0x11f8, 0x2001, 0x180c, 0x200c, 0xd1b4, 0x01d0, 0xc1b4,
-	0x2102, 0x0026, 0x2011, 0x0200, 0x080c, 0x2a63, 0x002e, 0x080c,
-	0x2a0f, 0x6024, 0xd0cc, 0x0148, 0x2001, 0x00a0, 0x080c, 0x2a29,
-	0x080c, 0x77cc, 0x080c, 0x6024, 0x0428, 0x6028, 0xc0cd, 0x602a,
-	0x0408, 0x080c, 0x74e2, 0x0150, 0x080c, 0x74d9, 0x1138, 0x2001,
-	0x0001, 0x080c, 0x25b9, 0x080c, 0x749c, 0x00a0, 0x080c, 0x73a6,
-	0x0178, 0x2001, 0x0001, 0x080c, 0x25b9, 0x7098, 0x9086, 0x001e,
-	0x0120, 0x7098, 0x9086, 0x0022, 0x1118, 0x709b, 0x0025, 0x0010,
-	0x709b, 0x0021, 0x012e, 0x00ee, 0x00de, 0x00ce, 0x001e, 0x0005,
-	0x0026, 0x2011, 0x7331, 0x080c, 0x8729, 0x002e, 0x0016, 0x0026,
-	0x2009, 0x0064, 0x2011, 0x7331, 0x080c, 0x8720, 0x002e, 0x001e,
-	0x0005, 0x00e6, 0x00f6, 0x0016, 0x080c, 0x9e16, 0x2071, 0x1800,
-	0x080c, 0x72ca, 0x001e, 0x00fe, 0x00ee, 0x0005, 0x0016, 0x0026,
-	0x0036, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0126, 0x080c, 0x9e16,
-	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2091, 0x8000,
-	0x6028, 0xc09c, 0x602a, 0x080c, 0xa888, 0x2011, 0x0003, 0x080c,
-	0xa1b1, 0x2011, 0x0002, 0x080c, 0xa1bb, 0x080c, 0xa07a, 0x080c,
-	0x86d5, 0x0036, 0x901e, 0x080c, 0xa0fa, 0x003e, 0x080c, 0xa8a4,
-	0x60e3, 0x0000, 0x080c, 0xe712, 0x080c, 0xe72d, 0x2009, 0x0004,
-	0x080c, 0x2a15, 0x080c, 0x292f, 0x2001, 0x1800, 0x2003, 0x0004,
-	0x2011, 0x0008, 0x080c, 0x2a63, 0x2011, 0x7331, 0x080c, 0x8729,
-	0x080c, 0x74e2, 0x0118, 0x9006, 0x080c, 0x2a29, 0x080c, 0x0bc3,
-	0x2001, 0x0001, 0x080c, 0x25b9, 0x012e, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x003e, 0x002e, 0x001e, 0x0005, 0x0026, 0x00e6, 0x2011,
-	0x733e, 0x2071, 0x1a02, 0x701c, 0x9206, 0x1118, 0x7018, 0x9005,
-	0x0110, 0x9085, 0x0001, 0x00ee, 0x002e, 0x0005, 0x6020, 0xd09c,
-	0x0005, 0x6800, 0x9084, 0xfffe, 0x9086, 0x00c0, 0x01b8, 0x2001,
-	0x00c0, 0x080c, 0x2a29, 0x0156, 0x20a9, 0x002d, 0x1d04, 0x73b6,
-	0x2091, 0x6000, 0x1f04, 0x73b6, 0x015e, 0x00d6, 0x2069, 0x1800,
-	0x689c, 0x8001, 0x0220, 0x0118, 0x689e, 0x00de, 0x0005, 0x689f,
-	0x0014, 0x68ec, 0xd0dc, 0x0dc8, 0x6800, 0x9086, 0x0001, 0x1da8,
-	0x080c, 0x8735, 0x0c90, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
-	0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x77db, 0x2001, 0x196c,
-	0x2003, 0x0000, 0x9006, 0x709a, 0x60e2, 0x6886, 0x080c, 0x2688,
-	0x9006, 0x080c, 0x2a29, 0x080c, 0x5edf, 0x0026, 0x2011, 0xffff,
-	0x080c, 0x2a63, 0x002e, 0x602b, 0x182c, 0x00ee, 0x00de, 0x00ce,
-	0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140,
-	0x2071, 0x1800, 0x2001, 0x197c, 0x200c, 0x9186, 0x0000, 0x0158,
-	0x9186, 0x0001, 0x0158, 0x9186, 0x0002, 0x0158, 0x9186, 0x0003,
-	0x0158, 0x0804, 0x748c, 0x709b, 0x0022, 0x0040, 0x709b, 0x0021,
-	0x0028, 0x709b, 0x0023, 0x0010, 0x709b, 0x0024, 0x60e3, 0x0000,
-	0x6887, 0x0001, 0x2001, 0x0001, 0x080c, 0x2688, 0x080c, 0xa888,
-	0x0026, 0x080c, 0xab50, 0x002e, 0x080c, 0xa8a4, 0x7000, 0x908e,
-	0x0004, 0x0118, 0x602b, 0x0028, 0x0010, 0x602b, 0x0020, 0x0156,
-	0x0126, 0x2091, 0x8000, 0x20a9, 0x0005, 0x6024, 0xd0ac, 0x0150,
-	0x012e, 0x015e, 0x080c, 0xcf51, 0x0118, 0x9006, 0x080c, 0x2a53,
-	0x0804, 0x7498, 0x6800, 0x9084, 0x00a1, 0xc0bd, 0x6802, 0x080c,
-	0x2a0f, 0x6904, 0xd1d4, 0x1140, 0x2001, 0x0100, 0x080c, 0x2a29,
-	0x1f04, 0x743d, 0x080c, 0x751f, 0x012e, 0x015e, 0x080c, 0x74d9,
-	0x0170, 0x6044, 0x9005, 0x0130, 0x080c, 0x751f, 0x9006, 0x8001,
-	0x1df0, 0x0028, 0x6804, 0xd0d4, 0x1110, 0x080c, 0x751f, 0x080c,
-	0xcf51, 0x0118, 0x9006, 0x080c, 0x2a53, 0x0016, 0x0026, 0x7000,
-	0x908e, 0x0004, 0x0130, 0x2009, 0x00c8, 0x2011, 0x733e, 0x080c,
-	0x86e7, 0x002e, 0x001e, 0x080c, 0x8529, 0x7034, 0xc085, 0x7036,
-	0x2001, 0x197c, 0x2003, 0x0004, 0x080c, 0x7193, 0x080c, 0x74d9,
-	0x0138, 0x6804, 0xd0d4, 0x1120, 0xd0dc, 0x1100, 0x080c, 0x77d1,
-	0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061,
-	0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x8540, 0x080c,
-	0x8532, 0x080c, 0x77db, 0x2001, 0x196c, 0x2003, 0x0000, 0x9006,
-	0x709a, 0x60e2, 0x6886, 0x080c, 0x2688, 0x9006, 0x080c, 0x2a29,
-	0x6043, 0x0090, 0x6043, 0x0010, 0x0026, 0x2011, 0xffff, 0x080c,
-	0x2a63, 0x002e, 0x602b, 0x182c, 0x00ee, 0x00de, 0x00ce, 0x0005,
-	0x0006, 0x2001, 0x197b, 0x2004, 0x9086, 0xaaaa, 0x000e, 0x0005,
-	0x0006, 0x080c, 0x56d9, 0x9084, 0x0030, 0x9086, 0x0000, 0x000e,
-	0x0005, 0x0006, 0x080c, 0x56d9, 0x9084, 0x0030, 0x9086, 0x0030,
-	0x000e, 0x0005, 0x0006, 0x080c, 0x56d9, 0x9084, 0x0030, 0x9086,
-	0x0010, 0x000e, 0x0005, 0x0006, 0x080c, 0x56d9, 0x9084, 0x0030,
-	0x9086, 0x0020, 0x000e, 0x0005, 0x0036, 0x0016, 0x2001, 0x180c,
-	0x2004, 0x908c, 0x0013, 0x0180, 0x0020, 0x080c, 0x26a8, 0x900e,
-	0x0028, 0x080c, 0x6a62, 0x1dc8, 0x2009, 0x0002, 0x2019, 0x0028,
-	0x080c, 0x31b4, 0x9006, 0x0019, 0x001e, 0x003e, 0x0005, 0x00e6,
-	0x2071, 0x180c, 0x2e04, 0x0130, 0x080c, 0xcf4a, 0x1128, 0x9085,
-	0x0010, 0x0010, 0x9084, 0xffef, 0x2072, 0x00ee, 0x0005, 0x6050,
-	0x0006, 0x60ec, 0x0006, 0x600c, 0x0006, 0x6004, 0x0006, 0x6028,
-	0x0006, 0x602f, 0x0100, 0x602f, 0x0000, 0x602f, 0x0040, 0x602f,
-	0x0000, 0x20a9, 0x0002, 0x080c, 0x29f0, 0x0026, 0x2011, 0x0040,
-	0x080c, 0x2a63, 0x002e, 0x000e, 0x602a, 0x000e, 0x6006, 0x000e,
+	0x9200, 0x70c2, 0x080c, 0x8566, 0x0e04, 0x6f50, 0x2071, 0x1910,
+	0x701c, 0x2048, 0xa84c, 0x900d, 0x0d18, 0x2071, 0x0000, 0x7182,
+	0xa850, 0x7032, 0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0xa850,
+	0x9082, 0x0019, 0x1278, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
+	0xd084, 0x190c, 0x11ee, 0x2071, 0x1910, 0x080c, 0x70e1, 0x002e,
+	0x00ee, 0x0005, 0xa850, 0x9082, 0x001c, 0x1e68, 0xa880, 0x708e,
+	0x7036, 0x0146, 0x01d6, 0x0136, 0x01c6, 0x0156, 0x20e9, 0x0000,
+	0x20a1, 0x002a, 0xa868, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x0021, 0x2098, 0x4003, 0x015e, 0x01ce, 0x013e, 0x01de, 0x014e,
+	0x0890, 0x2071, 0x1910, 0xa803, 0x0000, 0x2908, 0x7010, 0x8000,
+	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
+	0x2148, 0xa804, 0x900d, 0x1118, 0x002e, 0x00ee, 0x0005, 0x2071,
+	0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70c0, 0x9200, 0x70c2, 0x080c, 0x8566,
+	0x002e, 0x00ee, 0x0005, 0x0006, 0xa87c, 0x0006, 0xa867, 0x0103,
+	0x20a9, 0x001c, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001d, 0x20a0,
+	0x9006, 0x4004, 0x000e, 0x9084, 0x00ff, 0xa87e, 0x000e, 0xa87a,
+	0xa982, 0x0005, 0x2071, 0x1910, 0x7004, 0x0002, 0x6ff4, 0x6ff5,
+	0x70e0, 0x6ff5, 0x0d7d, 0x70e0, 0x0005, 0x2001, 0x1947, 0x2004,
+	0x0002, 0x6fff, 0x6fff, 0x7079, 0x707a, 0x6fff, 0x707a, 0x0126,
+	0x2091, 0x8000, 0x1e0c, 0x7100, 0x701c, 0x904d, 0x0508, 0xa84c,
+	0x9005, 0x0904, 0x704a, 0x0e04, 0x7028, 0xa94c, 0x2071, 0x0000,
+	0x7182, 0xa850, 0x7032, 0xa86c, 0x7086, 0x7036, 0xa870, 0x708a,
+	0xa850, 0x9082, 0x0019, 0x1278, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x11ee, 0x2071, 0x1910, 0x080c, 0x70e1,
+	0x012e, 0x0804, 0x7078, 0xa850, 0x9082, 0x001c, 0x1e68, 0xa880,
+	0x708e, 0x7036, 0x0146, 0x01d6, 0x0136, 0x01c6, 0x0156, 0x20e9,
+	0x0000, 0x20a1, 0x002a, 0xa868, 0x20a8, 0xa860, 0x20e0, 0xa85c,
+	0x9080, 0x0021, 0x2098, 0x4003, 0x015e, 0x01ce, 0x013e, 0x01de,
+	0x014e, 0x0890, 0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x190c,
+	0x70f5, 0xd09c, 0x2071, 0x1910, 0x1510, 0x2071, 0x1910, 0x700f,
+	0x0001, 0xa964, 0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f,
+	0x918c, 0x00ff, 0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069,
+	0x0050, 0x6822, 0x00de, 0x2071, 0x1910, 0x701c, 0x2048, 0x7010,
+	0x8001, 0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e,
+	0x0005, 0x0005, 0x00d6, 0x2008, 0x2069, 0x1a02, 0x683c, 0x9005,
+	0x0760, 0x0158, 0x9186, 0x0003, 0x0540, 0x2001, 0x1815, 0x2004,
+	0x2009, 0x1b4d, 0x210c, 0x9102, 0x1500, 0x0126, 0x2091, 0x8000,
+	0x2069, 0x0050, 0x693c, 0x6838, 0x9106, 0x0190, 0x0e04, 0x70ac,
+	0x2069, 0x0000, 0x6837, 0x8040, 0x6833, 0x0012, 0x6883, 0x8040,
+	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11ee,
+	0x2069, 0x1a02, 0x683f, 0xffff, 0x012e, 0x00de, 0x0126, 0x2091,
+	0x8000, 0x1e0c, 0x7166, 0x701c, 0x904d, 0x0540, 0x2001, 0x005b,
+	0x2004, 0x9094, 0x0780, 0x15c9, 0xd09c, 0x1500, 0x2071, 0x1910,
+	0x700f, 0x0001, 0xa964, 0x9184, 0x00ff, 0x9086, 0x0003, 0x1130,
+	0x810f, 0x918c, 0x00ff, 0x8101, 0x0108, 0x710e, 0x2900, 0x00d6,
+	0x2069, 0x0050, 0x6822, 0x00de, 0x701c, 0x2048, 0x7010, 0x8001,
+	0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x701c, 0x904d, 0x0160, 0x7010,
+	0x8001, 0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e,
+	0x080c, 0x1079, 0x0005, 0x012e, 0x0005, 0x2091, 0x8000, 0x0e04,
+	0x70f7, 0x0006, 0x0016, 0x2001, 0x8004, 0x0006, 0x0804, 0x0d86,
+	0x0096, 0x00f6, 0x2079, 0x0050, 0x7044, 0xd084, 0x01c0, 0xc084,
+	0x7046, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
+	0x6836, 0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x11ee, 0x00fe, 0x009e, 0x0005, 0x782c,
+	0x9094, 0x0780, 0x1991, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800,
+	0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1170, 0x2009,
+	0x1830, 0x210c, 0x918a, 0x0020, 0x0240, 0x7022, 0x2001, 0x1dc0,
+	0x200c, 0x8108, 0x2102, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c,
+	0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x8566,
+	0x782c, 0x9094, 0x0780, 0x190c, 0x70f5, 0xd0a4, 0x19c8, 0x7838,
+	0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833,
+	0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x11ee, 0x00ee, 0x00fe, 0x009e, 0x0005, 0x00f6, 0x2079,
+	0x0050, 0x7044, 0xd084, 0x01b8, 0xc084, 0x7046, 0x7838, 0x7938,
+	0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013,
+	0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x11ee, 0x00fe, 0x0005, 0x782c, 0x9094, 0x0780, 0x190c, 0x70f5,
+	0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x2048, 0x702c,
+	0xa802, 0x2900, 0x702e, 0x70c0, 0x8000, 0x70c2, 0x080c, 0x8566,
+	0x782c, 0x9094, 0x0780, 0x190c, 0x70f5, 0xd0a4, 0x1d70, 0x00d6,
+	0x2069, 0x0050, 0x693c, 0x2069, 0x1947, 0x6808, 0x690a, 0x2069,
+	0x1a02, 0x9102, 0x1118, 0x683c, 0x9005, 0x1328, 0x2001, 0x1948,
+	0x200c, 0x810d, 0x693e, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x7098,
+	0x908a, 0x0029, 0x1a0c, 0x0d7d, 0x9082, 0x001d, 0x003b, 0x0026,
+	0x2011, 0x1e00, 0x080c, 0x2a83, 0x002e, 0x0005, 0x7292, 0x7218,
+	0x7234, 0x725e, 0x7281, 0x72c1, 0x72d3, 0x7234, 0x72a9, 0x71d3,
+	0x7201, 0x71d2, 0x0005, 0x00d6, 0x2069, 0x0200, 0x6804, 0x9005,
+	0x1180, 0x6808, 0x9005, 0x1518, 0x709b, 0x0028, 0x2069, 0x198e,
+	0x2d04, 0x7002, 0x080c, 0x762d, 0x6028, 0x9085, 0x0600, 0x602a,
+	0x00b0, 0x709b, 0x0028, 0x2069, 0x198e, 0x2d04, 0x7002, 0x6028,
+	0x9085, 0x0600, 0x602a, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071,
+	0x1a6a, 0x080c, 0x1adf, 0x005e, 0x004e, 0x003e, 0x00ee, 0x00de,
+	0x0005, 0x00d6, 0x2069, 0x0200, 0x6804, 0x9005, 0x1178, 0x6808,
+	0x9005, 0x1160, 0x709b, 0x0028, 0x2069, 0x198e, 0x2d04, 0x7002,
+	0x080c, 0x76d0, 0x6028, 0x9085, 0x0600, 0x602a, 0x00de, 0x0005,
+	0x0006, 0x2001, 0x0090, 0x080c, 0x2a49, 0x000e, 0x6124, 0xd1e4,
+	0x1190, 0x080c, 0x7344, 0xd1d4, 0x1160, 0xd1dc, 0x1138, 0xd1cc,
+	0x0150, 0x709b, 0x0020, 0x080c, 0x7344, 0x0028, 0x709b, 0x001d,
+	0x0010, 0x709b, 0x001f, 0x0005, 0x2001, 0x0088, 0x080c, 0x2a49,
+	0x6124, 0xd1cc, 0x11e8, 0xd1dc, 0x11c0, 0xd1e4, 0x1198, 0x9184,
+	0x1e00, 0x11d8, 0x080c, 0x1b04, 0x60e3, 0x0001, 0x600c, 0xc0b4,
+	0x600e, 0x080c, 0x7518, 0x2001, 0x0080, 0x080c, 0x2a49, 0x709b,
+	0x0028, 0x0058, 0x709b, 0x001e, 0x0040, 0x709b, 0x001d, 0x0028,
+	0x709b, 0x0020, 0x0010, 0x709b, 0x001f, 0x0005, 0x080c, 0x1b04,
+	0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c, 0x7518, 0x2001,
+	0x0080, 0x080c, 0x2a49, 0x6124, 0xd1d4, 0x1180, 0xd1dc, 0x1158,
+	0xd1e4, 0x1130, 0x9184, 0x1e00, 0x1158, 0x709b, 0x0028, 0x0040,
+	0x709b, 0x001e, 0x0028, 0x709b, 0x001d, 0x0010, 0x709b, 0x001f,
+	0x0005, 0x2001, 0x00a0, 0x080c, 0x2a49, 0x6124, 0xd1dc, 0x1138,
+	0xd1e4, 0x0138, 0x080c, 0x1b04, 0x709b, 0x001e, 0x0010, 0x709b,
+	0x001d, 0x0005, 0x080c, 0x73cd, 0x6124, 0xd1dc, 0x1188, 0x080c,
+	0x7344, 0x0016, 0x080c, 0x1b04, 0x001e, 0xd1d4, 0x1128, 0xd1e4,
+	0x0138, 0x709b, 0x001e, 0x0020, 0x709b, 0x001f, 0x080c, 0x7344,
+	0x0005, 0x0006, 0x2001, 0x00a0, 0x080c, 0x2a49, 0x000e, 0x6124,
+	0xd1d4, 0x1160, 0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140,
+	0x709b, 0x001e, 0x0028, 0x709b, 0x001d, 0x0010, 0x709b, 0x0021,
+	0x0005, 0x080c, 0x73cd, 0x6124, 0xd1d4, 0x1150, 0xd1dc, 0x1128,
+	0xd1e4, 0x0140, 0x709b, 0x001e, 0x0028, 0x709b, 0x001d, 0x0010,
+	0x709b, 0x001f, 0x0005, 0x0006, 0x2001, 0x0090, 0x080c, 0x2a49,
+	0x000e, 0x6124, 0xd1d4, 0x1178, 0xd1cc, 0x1150, 0xd1dc, 0x1128,
+	0xd1e4, 0x0158, 0x709b, 0x001e, 0x0040, 0x709b, 0x001d, 0x0028,
+	0x709b, 0x0020, 0x0010, 0x709b, 0x001f, 0x0005, 0x0016, 0x00c6,
+	0x00d6, 0x00e6, 0x0126, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071,
+	0x1800, 0x2091, 0x8000, 0x080c, 0x74ec, 0x11f8, 0x2001, 0x180c,
+	0x200c, 0xd1b4, 0x01d0, 0xc1b4, 0x2102, 0x0026, 0x2011, 0x0200,
+	0x080c, 0x2a83, 0x002e, 0x080c, 0x2a2f, 0x6024, 0xd0cc, 0x0148,
+	0x2001, 0x00a0, 0x080c, 0x2a49, 0x080c, 0x77ef, 0x080c, 0x6044,
+	0x0428, 0x6028, 0xc0cd, 0x602a, 0x0408, 0x080c, 0x7506, 0x0150,
+	0x080c, 0x74fd, 0x1138, 0x2001, 0x0001, 0x080c, 0x25d5, 0x080c,
+	0x74c0, 0x00a0, 0x080c, 0x73ca, 0x0178, 0x2001, 0x0001, 0x080c,
+	0x25d5, 0x7098, 0x9086, 0x001e, 0x0120, 0x7098, 0x9086, 0x0022,
+	0x1118, 0x709b, 0x0025, 0x0010, 0x709b, 0x0021, 0x012e, 0x00ee,
+	0x00de, 0x00ce, 0x001e, 0x0005, 0x0026, 0x2011, 0x7355, 0x080c,
+	0x875d, 0x002e, 0x0016, 0x0026, 0x2009, 0x0064, 0x2011, 0x7355,
+	0x080c, 0x8754, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00f6, 0x0016,
+	0x080c, 0x9e4f, 0x2071, 0x1800, 0x080c, 0x72ee, 0x001e, 0x00fe,
+	0x00ee, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6,
+	0x00f6, 0x0126, 0x080c, 0x9e4f, 0x2061, 0x0100, 0x2069, 0x0140,
+	0x2071, 0x1800, 0x2091, 0x8000, 0x6028, 0xc09c, 0x602a, 0x080c,
+	0xa899, 0x2011, 0x0003, 0x080c, 0xa1be, 0x2011, 0x0002, 0x080c,
+	0xa1c8, 0x080c, 0xa0b3, 0x080c, 0x8709, 0x0036, 0x901e, 0x080c,
+	0xa133, 0x003e, 0x080c, 0xa8b5, 0x60e3, 0x0000, 0x080c, 0xe74f,
+	0x080c, 0xe76a, 0x2009, 0x0004, 0x080c, 0x2a35, 0x080c, 0x294b,
+	0x2001, 0x1800, 0x2003, 0x0004, 0x2011, 0x0008, 0x080c, 0x2a83,
+	0x2011, 0x7355, 0x080c, 0x875d, 0x080c, 0x7506, 0x0118, 0x9006,
+	0x080c, 0x2a49, 0x080c, 0x0bc3, 0x2001, 0x0001, 0x080c, 0x25d5,
+	0x012e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e,
+	0x0005, 0x0026, 0x00e6, 0x2011, 0x7362, 0x2071, 0x1a02, 0x701c,
+	0x9206, 0x1118, 0x7018, 0x9005, 0x0110, 0x9085, 0x0001, 0x00ee,
+	0x002e, 0x0005, 0x6020, 0xd09c, 0x0005, 0x6800, 0x9084, 0xfffe,
+	0x9086, 0x00c0, 0x01b8, 0x2001, 0x00c0, 0x080c, 0x2a49, 0x0156,
+	0x20a9, 0x002d, 0x1d04, 0x73da, 0x2091, 0x6000, 0x1f04, 0x73da,
+	0x015e, 0x00d6, 0x2069, 0x1800, 0x689c, 0x8001, 0x0220, 0x0118,
+	0x689e, 0x00de, 0x0005, 0x689f, 0x0014, 0x68ec, 0xd0dc, 0x0dc8,
+	0x6800, 0x9086, 0x0001, 0x1da8, 0x080c, 0x8769, 0x0c90, 0x00c6,
+	0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800,
+	0x080c, 0x77fe, 0x2001, 0x196c, 0x2003, 0x0000, 0x9006, 0x709a,
+	0x60e2, 0x6886, 0x080c, 0x26a4, 0x9006, 0x080c, 0x2a49, 0x080c,
+	0x5eff, 0x0026, 0x2011, 0xffff, 0x080c, 0x2a83, 0x002e, 0x602b,
+	0x182c, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2001, 0x197c,
+	0x200c, 0x9186, 0x0000, 0x0158, 0x9186, 0x0001, 0x0158, 0x9186,
+	0x0002, 0x0158, 0x9186, 0x0003, 0x0158, 0x0804, 0x74b0, 0x709b,
+	0x0022, 0x0040, 0x709b, 0x0021, 0x0028, 0x709b, 0x0023, 0x0010,
+	0x709b, 0x0024, 0x60e3, 0x0000, 0x6887, 0x0001, 0x2001, 0x0001,
+	0x080c, 0x26a4, 0x080c, 0xa899, 0x0026, 0x080c, 0xab61, 0x002e,
+	0x080c, 0xa8b5, 0x7000, 0x908e, 0x0004, 0x0118, 0x602b, 0x0028,
+	0x0010, 0x602b, 0x0020, 0x0156, 0x0126, 0x2091, 0x8000, 0x20a9,
+	0x0005, 0x6024, 0xd0ac, 0x0150, 0x012e, 0x015e, 0x080c, 0xcf84,
+	0x0118, 0x9006, 0x080c, 0x2a73, 0x0804, 0x74bc, 0x6800, 0x9084,
+	0x00a1, 0xc0bd, 0x6802, 0x080c, 0x2a2f, 0x6904, 0xd1d4, 0x1140,
+	0x2001, 0x0100, 0x080c, 0x2a49, 0x1f04, 0x7461, 0x080c, 0x7543,
+	0x012e, 0x015e, 0x080c, 0x74fd, 0x0170, 0x6044, 0x9005, 0x0130,
+	0x080c, 0x7543, 0x9006, 0x8001, 0x1df0, 0x0028, 0x6804, 0xd0d4,
+	0x1110, 0x080c, 0x7543, 0x080c, 0xcf84, 0x0118, 0x9006, 0x080c,
+	0x2a73, 0x0016, 0x0026, 0x7000, 0x908e, 0x0004, 0x0130, 0x2009,
+	0x00c8, 0x2011, 0x7362, 0x080c, 0x871b, 0x002e, 0x001e, 0x080c,
+	0x855d, 0x7034, 0xc085, 0x7036, 0x2001, 0x197c, 0x2003, 0x0004,
+	0x080c, 0x71b7, 0x080c, 0x74fd, 0x0138, 0x6804, 0xd0d4, 0x1120,
+	0xd0dc, 0x1100, 0x080c, 0x77f4, 0x00ee, 0x00de, 0x00ce, 0x0005,
+	0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071,
+	0x1800, 0x080c, 0x8574, 0x080c, 0x8566, 0x080c, 0x77fe, 0x2001,
+	0x196c, 0x2003, 0x0000, 0x9006, 0x709a, 0x60e2, 0x6886, 0x080c,
+	0x26a4, 0x9006, 0x080c, 0x2a49, 0x6043, 0x0090, 0x6043, 0x0010,
+	0x0026, 0x2011, 0xffff, 0x080c, 0x2a83, 0x002e, 0x602b, 0x182c,
+	0x00ee, 0x00de, 0x00ce, 0x0005, 0x0006, 0x2001, 0x197b, 0x2004,
+	0x9086, 0xaaaa, 0x000e, 0x0005, 0x0006, 0x080c, 0x56f9, 0x9084,
+	0x0030, 0x9086, 0x0000, 0x000e, 0x0005, 0x0006, 0x080c, 0x56f9,
+	0x9084, 0x0030, 0x9086, 0x0030, 0x000e, 0x0005, 0x0006, 0x080c,
+	0x56f9, 0x9084, 0x0030, 0x9086, 0x0010, 0x000e, 0x0005, 0x0006,
+	0x080c, 0x56f9, 0x9084, 0x0030, 0x9086, 0x0020, 0x000e, 0x0005,
+	0x0036, 0x0016, 0x2001, 0x180c, 0x2004, 0x908c, 0x0013, 0x0180,
+	0x0020, 0x080c, 0x26c4, 0x900e, 0x0028, 0x080c, 0x6a86, 0x1dc8,
+	0x2009, 0x0002, 0x2019, 0x0028, 0x080c, 0x31d4, 0x9006, 0x0019,
+	0x001e, 0x003e, 0x0005, 0x00e6, 0x2071, 0x180c, 0x2e04, 0x0130,
+	0x080c, 0xcf7d, 0x1128, 0x9085, 0x0010, 0x0010, 0x9084, 0xffef,
+	0x2072, 0x00ee, 0x0005, 0x6050, 0x0006, 0x60ec, 0x0006, 0x600c,
+	0x0006, 0x6004, 0x0006, 0x6028, 0x0006, 0x080c, 0x2aa6, 0x080c,
+	0x2ad9, 0x602f, 0x0100, 0x602f, 0x0000, 0x602f, 0x0040, 0x602f,
+	0x0000, 0x20a9, 0x0002, 0x080c, 0x2a10, 0x0026, 0x2011, 0x0040,
+	0x080c, 0x2a83, 0x002e, 0x000e, 0x602a, 0x000e, 0x6006, 0x000e,
 	0x600e, 0x000e, 0x60ee, 0x60e3, 0x0000, 0x6887, 0x0001, 0x2001,
-	0x0001, 0x080c, 0x2688, 0x2001, 0x00a0, 0x0006, 0x080c, 0xcf51,
-	0x000e, 0x0130, 0x080c, 0x2a47, 0x9006, 0x080c, 0x2a53, 0x0010,
-	0x080c, 0x2a29, 0x000e, 0x6052, 0x6050, 0x0006, 0xc0e5, 0x6052,
-	0x00f6, 0x2079, 0x0100, 0x080c, 0x29a0, 0x00fe, 0x000e, 0x6052,
+	0x0001, 0x080c, 0x26a4, 0x2001, 0x00a0, 0x0006, 0x080c, 0xcf84,
+	0x000e, 0x0130, 0x080c, 0x2a67, 0x9006, 0x080c, 0x2a73, 0x0010,
+	0x080c, 0x2a49, 0x000e, 0x6052, 0x6050, 0x0006, 0xc0e5, 0x6052,
+	0x00f6, 0x2079, 0x0100, 0x080c, 0x29bc, 0x00fe, 0x000e, 0x6052,
 	0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6,
-	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0xa8e6,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0xa8f7,
 	0x0158, 0x2001, 0x0386, 0x2004, 0xd0b4, 0x1130, 0x2001, 0x0016,
-	0x080c, 0xa879, 0x0804, 0x75fc, 0x2001, 0x180c, 0x200c, 0xc1c4,
+	0x080c, 0xa88a, 0x0804, 0x761f, 0x2001, 0x180c, 0x200c, 0xc1c4,
 	0x2102, 0x6028, 0x9084, 0xe1ff, 0x602a, 0x2011, 0x0200, 0x080c,
-	0x2a63, 0x2001, 0x0090, 0x080c, 0x2a29, 0x20a9, 0x0366, 0x6024,
-	0xd0cc, 0x1558, 0x1d04, 0x7597, 0x2091, 0x6000, 0x1f04, 0x7597,
-	0x080c, 0xa888, 0x2011, 0x0003, 0x080c, 0xa1b1, 0x2011, 0x0002,
-	0x080c, 0xa1bb, 0x080c, 0xa07a, 0x901e, 0x080c, 0xa0fa, 0x2001,
-	0x0386, 0x2003, 0x7000, 0x080c, 0xa8a4, 0x2001, 0x00a0, 0x080c,
-	0x2a29, 0x080c, 0x77cc, 0x080c, 0x6024, 0x080c, 0xcf51, 0x0110,
-	0x080c, 0x0ce9, 0x9085, 0x0001, 0x04e8, 0x2001, 0x0386, 0x2004,
-	0xd0ac, 0x0110, 0x080c, 0x1aec, 0x60e3, 0x0000, 0x2001, 0x196c,
-	0x2004, 0x080c, 0x2688, 0x60e2, 0x2001, 0x0080, 0x080c, 0x2a29,
-	0x20a9, 0x0366, 0x2011, 0x1e00, 0x080c, 0x2a63, 0x2009, 0x1e00,
-	0x080c, 0x2a0f, 0x6024, 0x910c, 0x0140, 0x1d04, 0x75da, 0x2091,
-	0x6000, 0x1f04, 0x75da, 0x0804, 0x75a0, 0x2001, 0x0386, 0x2003,
-	0x7000, 0x6028, 0x9085, 0x1e00, 0x602a, 0x70b4, 0x9005, 0x1118,
-	0x6887, 0x0001, 0x0008, 0x6886, 0x080c, 0xcf51, 0x0110, 0x080c,
-	0x0ce9, 0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e,
-	0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6,
-	0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x7000, 0x9086, 0x0003,
-	0x1168, 0x2001, 0x020b, 0x2004, 0x9084, 0x5540, 0x9086, 0x5540,
-	0x1128, 0x2069, 0x1a76, 0x2d04, 0x8000, 0x206a, 0x2069, 0x0140,
-	0x6020, 0x9084, 0x00c0, 0x0120, 0x6884, 0x9005, 0x1904, 0x7673,
-	0x2001, 0x0088, 0x080c, 0x2a29, 0x9006, 0x60e2, 0x6886, 0x080c,
-	0x2688, 0x2069, 0x0200, 0x6804, 0x9005, 0x1118, 0x6808, 0x9005,
-	0x01d0, 0x6028, 0x9084, 0xfbff, 0x602a, 0x2011, 0x0400, 0x080c,
-	0x2a63, 0x2069, 0x198e, 0x7000, 0x206a, 0x709b, 0x0026, 0x7003,
-	0x0001, 0x20a9, 0x0002, 0x1d04, 0x7653, 0x2091, 0x6000, 0x1f04,
-	0x7653, 0x0804, 0x76a5, 0x2069, 0x0140, 0x20a9, 0x0384, 0x2011,
-	0x1e00, 0x080c, 0x2a63, 0x2009, 0x1e00, 0x080c, 0x2a0f, 0x6024,
-	0x910c, 0x0528, 0x9084, 0x1a00, 0x1510, 0x1d04, 0x765f, 0x2091,
-	0x6000, 0x1f04, 0x765f, 0x080c, 0xa888, 0x2011, 0x0003, 0x080c,
-	0xa1b1, 0x2011, 0x0002, 0x080c, 0xa1bb, 0x080c, 0xa07a, 0x901e,
-	0x080c, 0xa0fa, 0x080c, 0xa8a4, 0x2001, 0x00a0, 0x080c, 0x2a29,
-	0x080c, 0x77cc, 0x080c, 0x6024, 0x9085, 0x0001, 0x00b0, 0x2001,
-	0x0080, 0x080c, 0x2a29, 0x2069, 0x0140, 0x60e3, 0x0000, 0x70b4,
-	0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001, 0x196c,
-	0x2004, 0x080c, 0x2688, 0x60e2, 0x9006, 0x00ee, 0x00de, 0x00ce,
+	0x2a83, 0x2001, 0x0090, 0x080c, 0x2a49, 0x20a9, 0x0366, 0x6024,
+	0xd0cc, 0x1558, 0x1d04, 0x75bf, 0x2091, 0x6000, 0x1f04, 0x75bf,
+	0x080c, 0xa899, 0x2011, 0x0003, 0x080c, 0xa1be, 0x2011, 0x0002,
+	0x080c, 0xa1c8, 0x080c, 0xa0b3, 0x901e, 0x080c, 0xa133, 0x2001,
+	0x0386, 0x2003, 0x7000, 0x080c, 0xa8b5, 0x2001, 0x00a0, 0x080c,
+	0x2a49, 0x080c, 0x77ef, 0x080c, 0x6044, 0x080c, 0xcf84, 0x0110,
+	0x080c, 0x0ce9, 0x9085, 0x0001, 0x04c0, 0x080c, 0x1b04, 0x60e3,
+	0x0000, 0x2001, 0x196c, 0x2004, 0x080c, 0x26a4, 0x60e2, 0x2001,
+	0x0080, 0x080c, 0x2a49, 0x20a9, 0x0366, 0x2011, 0x1e00, 0x080c,
+	0x2a83, 0x2009, 0x1e00, 0x080c, 0x2a2f, 0x6024, 0x910c, 0x0140,
+	0x1d04, 0x75fd, 0x2091, 0x6000, 0x1f04, 0x75fd, 0x0804, 0x75c8,
+	0x2001, 0x0386, 0x2003, 0x7000, 0x6028, 0x9085, 0x1e00, 0x602a,
+	0x70b4, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x080c,
+	0xcf84, 0x0110, 0x080c, 0x0ce9, 0x9006, 0x00ee, 0x00de, 0x00ce,
 	0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026,
 	0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800,
-	0x6020, 0x9084, 0x00c0, 0x01e8, 0x080c, 0xa888, 0x2011, 0x0003,
-	0x080c, 0xa1b1, 0x2011, 0x0002, 0x080c, 0xa1bb, 0x080c, 0xa07a,
-	0x901e, 0x080c, 0xa0fa, 0x080c, 0xa8a4, 0x2069, 0x0140, 0x2001,
-	0x00a0, 0x080c, 0x2a29, 0x080c, 0x77cc, 0x080c, 0x6024, 0x0804,
-	0x7748, 0x2001, 0x180c, 0x200c, 0xd1b4, 0x1160, 0xc1b5, 0x2102,
-	0x080c, 0x7326, 0x2069, 0x0140, 0x2001, 0x0080, 0x080c, 0x2a29,
-	0x60e3, 0x0000, 0x2069, 0x0200, 0x6804, 0x9005, 0x1118, 0x6808,
-	0x9005, 0x0190, 0x6028, 0x9084, 0xfdff, 0x602a, 0x2011, 0x0200,
-	0x080c, 0x2a63, 0x2069, 0x198e, 0x7000, 0x206a, 0x709b, 0x0027,
-	0x7003, 0x0001, 0x0804, 0x7748, 0x2011, 0x1e00, 0x080c, 0x2a63,
-	0x2009, 0x1e00, 0x080c, 0x2a0f, 0x6024, 0x910c, 0x01c8, 0x9084,
-	0x1c00, 0x11b0, 0x1d04, 0x7704, 0x0006, 0x0016, 0x00c6, 0x00d6,
-	0x00e6, 0x080c, 0x8571, 0x00ee, 0x00de, 0x00ce, 0x001e, 0x000e,
-	0x00e6, 0x2071, 0x1a02, 0x7018, 0x00ee, 0x9005, 0x19e8, 0x0500,
-	0x0026, 0x2011, 0x733e, 0x080c, 0x861d, 0x2011, 0x7331, 0x080c,
-	0x8729, 0x002e, 0x2069, 0x0140, 0x60e3, 0x0000, 0x70b4, 0x9005,
-	0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001, 0x196c, 0x2004,
-	0x080c, 0x2688, 0x60e2, 0x2001, 0x180c, 0x200c, 0xc1b4, 0x2102,
+	0x7000, 0x9086, 0x0003, 0x1168, 0x2001, 0x020b, 0x2004, 0x9084,
+	0x5540, 0x9086, 0x5540, 0x1128, 0x2069, 0x1a76, 0x2d04, 0x8000,
+	0x206a, 0x2069, 0x0140, 0x6020, 0x9084, 0x00c0, 0x0120, 0x6884,
+	0x9005, 0x1904, 0x7696, 0x2001, 0x0088, 0x080c, 0x2a49, 0x9006,
+	0x60e2, 0x6886, 0x080c, 0x26a4, 0x2069, 0x0200, 0x6804, 0x9005,
+	0x1118, 0x6808, 0x9005, 0x01d0, 0x6028, 0x9084, 0xfbff, 0x602a,
+	0x2011, 0x0400, 0x080c, 0x2a83, 0x2069, 0x198e, 0x7000, 0x206a,
+	0x709b, 0x0026, 0x7003, 0x0001, 0x20a9, 0x0002, 0x1d04, 0x7676,
+	0x2091, 0x6000, 0x1f04, 0x7676, 0x0804, 0x76c8, 0x2069, 0x0140,
+	0x20a9, 0x0384, 0x2011, 0x1e00, 0x080c, 0x2a83, 0x2009, 0x1e00,
+	0x080c, 0x2a2f, 0x6024, 0x910c, 0x0528, 0x9084, 0x1a00, 0x1510,
+	0x1d04, 0x7682, 0x2091, 0x6000, 0x1f04, 0x7682, 0x080c, 0xa899,
+	0x2011, 0x0003, 0x080c, 0xa1be, 0x2011, 0x0002, 0x080c, 0xa1c8,
+	0x080c, 0xa0b3, 0x901e, 0x080c, 0xa133, 0x080c, 0xa8b5, 0x2001,
+	0x00a0, 0x080c, 0x2a49, 0x080c, 0x77ef, 0x080c, 0x6044, 0x9085,
+	0x0001, 0x00b0, 0x2001, 0x0080, 0x080c, 0x2a49, 0x2069, 0x0140,
+	0x60e3, 0x0000, 0x70b4, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008,
+	0x6886, 0x2001, 0x196c, 0x2004, 0x080c, 0x26a4, 0x60e2, 0x9006,
 	0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005,
-	0x0156, 0x0016, 0x0026, 0x0036, 0x0046, 0x00c6, 0x00e6, 0x2061,
-	0x0100, 0x2071, 0x1800, 0x080c, 0xcf4a, 0x1904, 0x77b6, 0x7130,
-	0xd184, 0x1170, 0x080c, 0x335c, 0x0138, 0xc18d, 0x7132, 0x2011,
-	0x1848, 0x2214, 0xd2ac, 0x1120, 0x7030, 0xd08c, 0x0904, 0x77b6,
-	0x2011, 0x1848, 0x220c, 0xd1a4, 0x0538, 0x0016, 0x2019, 0x000e,
-	0x080c, 0xe249, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e, 0x9186,
-	0x007e, 0x01a0, 0x9186, 0x0080, 0x0188, 0x080c, 0x6620, 0x1170,
-	0x2120, 0x9006, 0x0016, 0x2009, 0x000e, 0x080c, 0xe2d9, 0x2009,
-	0x0001, 0x2011, 0x0100, 0x080c, 0x88ce, 0x001e, 0x8108, 0x1f04,
-	0x777f, 0x00be, 0x015e, 0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009,
-	0x0002, 0x2019, 0x0004, 0x080c, 0x31b4, 0x001e, 0x0078, 0x0156,
-	0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x6620, 0x1110, 0x080c,
-	0x603e, 0x8108, 0x1f04, 0x77ac, 0x00be, 0x015e, 0x080c, 0x1aec,
-	0x080c, 0xa888, 0x080c, 0xab50, 0x080c, 0xa8a4, 0x60e3, 0x0000,
-	0x080c, 0x6024, 0x080c, 0x73f9, 0x00ee, 0x00ce, 0x004e, 0x003e,
-	0x002e, 0x001e, 0x015e, 0x0005, 0x2001, 0x197c, 0x2003, 0x0001,
-	0x0005, 0x2001, 0x197c, 0x2003, 0x0000, 0x0005, 0x2001, 0x197b,
-	0x2003, 0xaaaa, 0x0005, 0x2001, 0x197b, 0x2003, 0x0000, 0x0005,
-	0x2071, 0x18fa, 0x7003, 0x0000, 0x7007, 0x0000, 0x080c, 0x1053,
-	0x090c, 0x0d7d, 0xa8ab, 0xdcb0, 0x2900, 0x704e, 0x080c, 0x1053,
-	0x090c, 0x0d7d, 0xa8ab, 0xdcb0, 0x2900, 0x7052, 0xa867, 0x0000,
-	0xa86b, 0x0001, 0xa89f, 0x0000, 0x0005, 0x00e6, 0x2071, 0x0040,
-	0x6848, 0x9005, 0x1118, 0x9085, 0x0001, 0x04b0, 0x6840, 0x9005,
-	0x0150, 0x04a1, 0x6a50, 0x9200, 0x7002, 0x6854, 0x9101, 0x7006,
-	0x9006, 0x7012, 0x7016, 0x6850, 0x7002, 0x6854, 0x7006, 0x6858,
-	0x700a, 0x685c, 0x700e, 0x6840, 0x9005, 0x1110, 0x7012, 0x7016,
-	0x6848, 0x701a, 0x701c, 0x9085, 0x0040, 0x701e, 0x2001, 0x0019,
-	0x7036, 0x702b, 0x0001, 0x2001, 0x0004, 0x200c, 0x918c, 0xfff7,
-	0x918d, 0x8000, 0x2102, 0x00d6, 0x2069, 0x18fa, 0x6807, 0x0001,
-	0x00de, 0x080c, 0x7dc3, 0x9006, 0x00ee, 0x0005, 0x900e, 0x0156,
-	0x20a9, 0x0006, 0x8003, 0x818d, 0x1f04, 0x7842, 0x015e, 0x0005,
-	0x2079, 0x0040, 0x2071, 0x18fa, 0x7004, 0x0002, 0x7858, 0x7859,
-	0x78a4, 0x78ff, 0x7a0f, 0x7856, 0x7856, 0x7a39, 0x080c, 0x0d7d,
-	0x0005, 0x2079, 0x0040, 0x2001, 0x1dc0, 0x2003, 0x0000, 0x782c,
-	0x908c, 0x0780, 0x190c, 0x7ea5, 0xd0a4, 0x0570, 0x2001, 0x1dc0,
-	0x2004, 0x9082, 0x0080, 0x1640, 0x1d04, 0x7876, 0x2001, 0x1a05,
-	0x200c, 0x8109, 0x0508, 0x2091, 0x6000, 0x2102, 0x7824, 0x2048,
-	0x9006, 0xa802, 0xa806, 0xa864, 0x9084, 0x00ff, 0x908a, 0x0040,
-	0x0608, 0x00b8, 0x2001, 0x1800, 0x200c, 0x9186, 0x0003, 0x1160,
-	0x7104, 0x9186, 0x0004, 0x0140, 0x9186, 0x0007, 0x0128, 0x9186,
-	0x0003, 0x1968, 0x080c, 0x78ff, 0x782c, 0xd09c, 0x090c, 0x7dc3,
-	0x0005, 0x9082, 0x005a, 0x1218, 0x2100, 0x003b, 0x0c18, 0x080c,
-	0x7935, 0x0c90, 0x00e3, 0x08f0, 0x0005, 0x7935, 0x7935, 0x7935,
-	0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7957, 0x7935, 0x7935,
-	0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935,
-	0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935,
-	0x7935, 0x7941, 0x7935, 0x7b2a, 0x7935, 0x7935, 0x7935, 0x7957,
-	0x7935, 0x7941, 0x7b6b, 0x7bac, 0x7bf3, 0x7c07, 0x7935, 0x7935,
-	0x7957, 0x7941, 0x796b, 0x7935, 0x79e3, 0x7cb2, 0x7ccd, 0x7935,
-	0x7957, 0x7935, 0x796b, 0x7935, 0x7935, 0x79d9, 0x7ccd, 0x7935,
-	0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935,
-	0x797f, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935,
-	0x7935, 0x7935, 0x7e49, 0x7935, 0x7df3, 0x7935, 0x7df3, 0x7935,
-	0x7994, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x7935, 0x2079,
-	0x0040, 0x7004, 0x9086, 0x0003, 0x1198, 0x782c, 0x080c, 0x7dec,
-	0xd0a4, 0x0170, 0x7824, 0x2048, 0x9006, 0xa802, 0xa806, 0xa864,
-	0x9084, 0x00ff, 0x908a, 0x001a, 0x1210, 0x002b, 0x0c50, 0x00e9,
-	0x080c, 0x7dc3, 0x0005, 0x7935, 0x7941, 0x7b16, 0x7935, 0x7941,
-	0x7935, 0x7941, 0x7941, 0x7935, 0x7941, 0x7b16, 0x7941, 0x7941,
-	0x7941, 0x7941, 0x7941, 0x7935, 0x7941, 0x7b16, 0x7935, 0x7935,
-	0x7941, 0x7935, 0x7935, 0x7935, 0x7941, 0x00e6, 0x2071, 0x18fa,
-	0x2009, 0x0400, 0x0071, 0x00ee, 0x0005, 0x2009, 0x1000, 0x0049,
-	0x0005, 0x2009, 0x2000, 0x0029, 0x0005, 0x2009, 0x0800, 0x0009,
-	0x0005, 0x7007, 0x0001, 0xa868, 0x9084, 0x00ff, 0x9105, 0xa86a,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6d7b, 0x012e, 0x0005, 0xa864,
-	0x8007, 0x9084, 0x00ff, 0x0d08, 0x8001, 0x1120, 0x7007, 0x0001,
-	0x0804, 0x7ab8, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a,
-	0x704b, 0x7ab8, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0968,
-	0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x7ad3, 0x7007, 0x0003,
-	0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x7ad3, 0x0005, 0xa864,
-	0x8007, 0x9084, 0x00ff, 0x0904, 0x793d, 0x8001, 0x1120, 0x7007,
-	0x0001, 0x0804, 0x7aef, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016,
-	0x701a, 0x704b, 0x7aef, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff,
-	0x9086, 0x0001, 0x1904, 0x793d, 0x7007, 0x0001, 0x2009, 0x1834,
-	0x210c, 0x81ff, 0x11a8, 0xa868, 0x9084, 0x00ff, 0xa86a, 0xa883,
-	0x0000, 0x080c, 0x62b4, 0x1108, 0x0005, 0x0126, 0x2091, 0x8000,
-	0xa867, 0x0139, 0xa87a, 0xa982, 0x080c, 0x6d7b, 0x012e, 0x0ca0,
-	0xa994, 0x9186, 0x0071, 0x0d38, 0x9186, 0x0064, 0x0d20, 0x9186,
-	0x007c, 0x0d08, 0x9186, 0x0028, 0x09f0, 0x9186, 0x0038, 0x09d8,
-	0x9186, 0x0078, 0x09c0, 0x9186, 0x005f, 0x09a8, 0x9186, 0x0056,
-	0x0990, 0xa897, 0x4005, 0xa89b, 0x0001, 0x2001, 0x0030, 0x900e,
-	0x08a0, 0xa87c, 0x9084, 0x00c0, 0x9086, 0x00c0, 0x1120, 0x7007,
-	0x0001, 0x0804, 0x7ce4, 0x2900, 0x7016, 0x701a, 0x20a9, 0x0004,
-	0xa860, 0x20e0, 0xa85c, 0x9080, 0x0030, 0x2098, 0x7050, 0x2040,
-	0xa060, 0x20e8, 0xa05c, 0x9080, 0x0023, 0x20a0, 0x4003, 0xa888,
-	0x7012, 0x9082, 0x0401, 0x1a04, 0x7945, 0xaab4, 0x928a, 0x0002,
-	0x1a04, 0x7945, 0x82ff, 0x1138, 0xa8b8, 0xa9bc, 0x9105, 0x0118,
-	0x2001, 0x7a76, 0x0018, 0x9280, 0x7a6c, 0x2005, 0x7056, 0x7010,
-	0x9015, 0x0904, 0x7a57, 0x080c, 0x1053, 0x1118, 0x7007, 0x0004,
-	0x0005, 0x2900, 0x7022, 0x7054, 0x2060, 0xe000, 0xa866, 0x7050,
-	0x2040, 0xa95c, 0xe004, 0x9100, 0xa076, 0xa860, 0xa072, 0xe008,
-	0x920a, 0x1210, 0x900e, 0x2200, 0x7112, 0xe20c, 0x8003, 0x800b,
-	0x9296, 0x0004, 0x0108, 0x9108, 0xa17a, 0x810b, 0xa17e, 0x080c,
-	0x112f, 0xa06c, 0x908e, 0x0100, 0x0170, 0x9086, 0x0200, 0x0118,
-	0x7007, 0x0007, 0x0005, 0x7020, 0x2048, 0x080c, 0x106c, 0x7014,
-	0x2048, 0x0804, 0x7945, 0x7020, 0x2048, 0x7018, 0xa802, 0xa807,
-	0x0000, 0x2908, 0x2048, 0xa906, 0x711a, 0x0804, 0x7a0f, 0x7014,
-	0x2048, 0x7007, 0x0001, 0xa8b4, 0x9005, 0x1128, 0xa8b8, 0xa9bc,
-	0x9105, 0x0108, 0x00b9, 0xa864, 0x9084, 0x00ff, 0x9086, 0x001e,
-	0x0904, 0x7ce4, 0x0804, 0x7ab8, 0x7a6e, 0x7a72, 0x0002, 0x001d,
-	0x0007, 0x0004, 0x000a, 0x001b, 0x0005, 0x0006, 0x000a, 0x001d,
-	0x0005, 0x0004, 0x0076, 0x0066, 0xafb8, 0xaebc, 0xa804, 0x2050,
-	0xb0c0, 0xb0e2, 0xb0bc, 0xb0de, 0xb0b8, 0xb0d2, 0xb0b4, 0xb0ce,
-	0xb6da, 0xb7d6, 0xb0b0, 0xb0ca, 0xb0ac, 0xb0c6, 0xb0a8, 0xb0ba,
-	0xb0a4, 0xb0b6, 0xb6c2, 0xb7be, 0xb0a0, 0xb0b2, 0xb09c, 0xb0ae,
-	0xb098, 0xb0a2, 0xb094, 0xb09e, 0xb6aa, 0xb7a6, 0xb090, 0xb09a,
-	0xb08c, 0xb096, 0xb088, 0xb08a, 0xb084, 0xb086, 0xb692, 0xb78e,
-	0xb080, 0xb082, 0xb07c, 0xb07e, 0xb078, 0xb072, 0xb074, 0xb06e,
-	0xb67a, 0xb776, 0xb004, 0x9055, 0x1958, 0x006e, 0x007e, 0x0005,
-	0x2009, 0x1834, 0x210c, 0x81ff, 0x1178, 0x080c, 0x60b6, 0x1108,
-	0x0005, 0x080c, 0x6faf, 0x0126, 0x2091, 0x8000, 0x080c, 0xcb35,
-	0x080c, 0x6d7b, 0x012e, 0x0ca0, 0x080c, 0xcf4a, 0x1d70, 0x2001,
-	0x0028, 0x900e, 0x0c70, 0x2009, 0x1834, 0x210c, 0x81ff, 0x1188,
-	0xa888, 0x9005, 0x0188, 0xa883, 0x0000, 0x080c, 0x6144, 0x1108,
-	0x0005, 0xa87a, 0x0126, 0x2091, 0x8000, 0x080c, 0x6d7b, 0x012e,
-	0x0cb8, 0x2001, 0x0028, 0x0ca8, 0x2001, 0x0000, 0x0c90, 0x2009,
-	0x1834, 0x210c, 0x81ff, 0x11d8, 0xa888, 0x9005, 0x01e0, 0xa883,
-	0x0000, 0xa87c, 0xd0f4, 0x0120, 0x080c, 0x6216, 0x1138, 0x0005,
-	0x9006, 0xa87a, 0x080c, 0x6191, 0x1108, 0x0005, 0x0126, 0x2091,
-	0x8000, 0xa87a, 0xa982, 0x080c, 0x6d7b, 0x012e, 0x0cb0, 0x2001,
-	0x0028, 0x900e, 0x0c98, 0x2001, 0x0000, 0x0c80, 0x7018, 0xa802,
-	0x2908, 0x2048, 0xa906, 0x711a, 0x7010, 0x8001, 0x7012, 0x0118,
-	0x7007, 0x0003, 0x0030, 0x7014, 0x2048, 0x7007, 0x0001, 0x7048,
-	0x080f, 0x0005, 0x00b6, 0x7007, 0x0001, 0xa974, 0xa878, 0x9084,
-	0x00ff, 0x9096, 0x0004, 0x0540, 0x20a9, 0x0001, 0x9096, 0x0001,
-	0x0190, 0x900e, 0x20a9, 0x0800, 0x9096, 0x0002, 0x0160, 0x9005,
-	0x11d8, 0xa974, 0x080c, 0x6620, 0x11b8, 0x0066, 0xae80, 0x080c,
-	0x6730, 0x006e, 0x0088, 0x0046, 0x2011, 0x180c, 0x2224, 0xc484,
-	0x2412, 0x004e, 0x00c6, 0x080c, 0x6620, 0x1110, 0x080c, 0x6903,
-	0x8108, 0x1f04, 0x7b53, 0x00ce, 0xa87c, 0xd084, 0x1120, 0x080c,
-	0x106c, 0x00be, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x6d7b,
-	0x012e, 0x00be, 0x0005, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001,
-	0x080c, 0x6a66, 0x0580, 0x2061, 0x1a6e, 0x6100, 0xd184, 0x0178,
-	0xa888, 0x9084, 0x00ff, 0x1550, 0x6000, 0xd084, 0x0520, 0x6004,
-	0x9005, 0x1538, 0x6003, 0x0000, 0x600b, 0x0000, 0x00c8, 0x2011,
-	0x0001, 0xa890, 0x9005, 0x1110, 0x2001, 0x001e, 0x8000, 0x6016,
-	0xa888, 0x9084, 0x00ff, 0x0178, 0x6006, 0xa888, 0x8007, 0x9084,
-	0x00ff, 0x0148, 0x600a, 0xa888, 0x8000, 0x1108, 0xc28d, 0x6202,
-	0x012e, 0x0804, 0x7dad, 0x012e, 0x0804, 0x7da7, 0x012e, 0x0804,
-	0x7da1, 0x012e, 0x0804, 0x7da4, 0x0126, 0x2091, 0x8000, 0x7007,
-	0x0001, 0x080c, 0x6a66, 0x05e0, 0x2061, 0x1a6e, 0x6000, 0xd084,
-	0x05b8, 0x6204, 0x6308, 0xd08c, 0x1530, 0xac78, 0x9484, 0x0003,
-	0x0170, 0xa988, 0x918c, 0x00ff, 0x8001, 0x1120, 0x2100, 0x9210,
-	0x0620, 0x0028, 0x8001, 0x1508, 0x2100, 0x9212, 0x02f0, 0x9484,
-	0x000c, 0x0188, 0xa988, 0x810f, 0x918c, 0x00ff, 0x9082, 0x0004,
-	0x1120, 0x2100, 0x9318, 0x0288, 0x0030, 0x9082, 0x0004, 0x1168,
-	0x2100, 0x931a, 0x0250, 0xa890, 0x9005, 0x0110, 0x8000, 0x6016,
-	0x6206, 0x630a, 0x012e, 0x0804, 0x7dad, 0x012e, 0x0804, 0x7daa,
-	0x012e, 0x0804, 0x7da7, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001,
-	0x2061, 0x1a6e, 0x6300, 0xd38c, 0x1120, 0x6308, 0x8318, 0x0220,
-	0x630a, 0x012e, 0x0804, 0x7dbb, 0x012e, 0x0804, 0x7daa, 0x00b6,
-	0x0126, 0x00c6, 0x2091, 0x8000, 0x7007, 0x0001, 0xa87c, 0xd0ac,
-	0x0148, 0x00c6, 0x2061, 0x1a6e, 0x6000, 0x9084, 0xfcff, 0x6002,
-	0x00ce, 0x0440, 0xa888, 0x9005, 0x05d8, 0xa88c, 0x9065, 0x0598,
-	0x2001, 0x1834, 0x2004, 0x9005, 0x0118, 0x080c, 0xac1a, 0x0068,
-	0x6017, 0xf400, 0x6063, 0x0000, 0xa97c, 0xd1a4, 0x0110, 0xa980,
-	0x6162, 0x2009, 0x0041, 0x080c, 0xac7c, 0xa988, 0x918c, 0xff00,
-	0x9186, 0x2000, 0x1138, 0x0026, 0x900e, 0x2011, 0xfdff, 0x080c,
-	0x88ce, 0x002e, 0xa87c, 0xd0c4, 0x0148, 0x2061, 0x1a6e, 0x6000,
-	0xd08c, 0x1120, 0x6008, 0x8000, 0x0208, 0x600a, 0x00ce, 0x012e,
-	0x00be, 0x0804, 0x7dad, 0x00ce, 0x012e, 0x00be, 0x0804, 0x7da7,
-	0xa984, 0x9186, 0x002e, 0x0d30, 0x9186, 0x002d, 0x0d18, 0x9186,
-	0x0045, 0x0510, 0x9186, 0x002a, 0x1130, 0x2001, 0x180c, 0x200c,
-	0xc194, 0x2102, 0x08b8, 0x9186, 0x0020, 0x0158, 0x9186, 0x0029,
-	0x1d10, 0xa974, 0x080c, 0x6620, 0x1968, 0xb800, 0xc0e4, 0xb802,
-	0x0848, 0xa88c, 0x9065, 0x09b8, 0x6007, 0x0024, 0x2001, 0x1985,
-	0x2004, 0x601a, 0x0804, 0x7c42, 0xa88c, 0x9065, 0x0960, 0x00e6,
-	0xa890, 0x9075, 0x2001, 0x1834, 0x2004, 0x9005, 0x0150, 0x080c,
-	0xac1a, 0x8eff, 0x0118, 0x2e60, 0x080c, 0xac1a, 0x00ee, 0x0804,
-	0x7c42, 0x6024, 0xc0dc, 0xc0d5, 0x6026, 0x2e60, 0x6007, 0x003a,
-	0xa8a0, 0x9005, 0x0130, 0x6007, 0x003b, 0xa8a4, 0x602e, 0xa8a8,
-	0x6016, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x9200, 0x00ee,
-	0x0804, 0x7c42, 0x2061, 0x1a6e, 0x6000, 0xd084, 0x0190, 0xd08c,
-	0x1904, 0x7dbb, 0x0126, 0x2091, 0x8000, 0x6204, 0x8210, 0x0220,
-	0x6206, 0x012e, 0x0804, 0x7dbb, 0x012e, 0xa883, 0x0016, 0x0804,
-	0x7db4, 0xa883, 0x0007, 0x0804, 0x7db4, 0xa864, 0x8007, 0x9084,
-	0x00ff, 0x0130, 0x8001, 0x1138, 0x7007, 0x0001, 0x0069, 0x0005,
-	0x080c, 0x793d, 0x0040, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016,
-	0x701a, 0x704b, 0x7ce4, 0x0005, 0x00b6, 0x00e6, 0x0126, 0x2091,
-	0x8000, 0x903e, 0x2061, 0x1800, 0x61d0, 0x81ff, 0x1904, 0x7d66,
-	0x6130, 0xd194, 0x1904, 0x7d90, 0xa878, 0x2070, 0x9e82, 0x1ddc,
-	0x0a04, 0x7d5a, 0x6068, 0x9e02, 0x1a04, 0x7d5a, 0x7120, 0x9186,
-	0x0006, 0x1904, 0x7d4c, 0x7010, 0x905d, 0x0904, 0x7d66, 0xb800,
-	0xd0e4, 0x1904, 0x7d8a, 0x2061, 0x1a6e, 0x6100, 0x9184, 0x0301,
-	0x9086, 0x0001, 0x15a0, 0x7024, 0xd0dc, 0x1904, 0x7d93, 0xa883,
-	0x0000, 0xa803, 0x0000, 0x2908, 0x7014, 0x9005, 0x1198, 0x7116,
-	0xa87c, 0xd0f4, 0x1904, 0x7d96, 0x080c, 0x56d5, 0xd09c, 0x1118,
-	0xa87c, 0xc0cc, 0xa87e, 0x2e60, 0x080c, 0x87be, 0x012e, 0x00ee,
-	0x00be, 0x0005, 0x2048, 0xa800, 0x9005, 0x1de0, 0xa902, 0x2148,
-	0xa87c, 0xd0f4, 0x1904, 0x7d96, 0x012e, 0x00ee, 0x00be, 0x0005,
-	0x012e, 0x00ee, 0xa883, 0x0006, 0x00be, 0x0804, 0x7db4, 0xd184,
-	0x0db8, 0xd1c4, 0x1190, 0x00a0, 0xa974, 0x080c, 0x6620, 0x15d0,
-	0xb800, 0xd0e4, 0x15b8, 0x7120, 0x9186, 0x0007, 0x1118, 0xa883,
-	0x0002, 0x0490, 0xa883, 0x0008, 0x0478, 0xa883, 0x000e, 0x0460,
-	0xa883, 0x0017, 0x0448, 0xa883, 0x0035, 0x0430, 0x080c, 0x56d9,
-	0xd0fc, 0x01e8, 0xa878, 0x2070, 0x9e82, 0x1ddc, 0x02c0, 0x6068,
-	0x9e02, 0x12a8, 0x7120, 0x9186, 0x0006, 0x1188, 0x7010, 0x905d,
-	0x0170, 0xb800, 0xd0bc, 0x0158, 0x2039, 0x0001, 0x7000, 0x9086,
-	0x0007, 0x1904, 0x7cf0, 0x7003, 0x0002, 0x0804, 0x7cf0, 0xa883,
-	0x0028, 0x0010, 0xa883, 0x0029, 0x012e, 0x00ee, 0x00be, 0x0420,
-	0xa883, 0x002a, 0x0cc8, 0xa883, 0x0045, 0x0cb0, 0x2e60, 0x2019,
-	0x0002, 0x601b, 0x0014, 0x080c, 0xde2a, 0x012e, 0x00ee, 0x00be,
-	0x0005, 0x2009, 0x003e, 0x0058, 0x2009, 0x0004, 0x0040, 0x2009,
-	0x0006, 0x0028, 0x2009, 0x0016, 0x0010, 0x2009, 0x0001, 0xa884,
-	0x9084, 0xff00, 0x9105, 0xa886, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x6d7b, 0x012e, 0x0005, 0x080c, 0x106c, 0x0005, 0x00d6, 0x080c,
-	0x87b5, 0x00de, 0x0005, 0x00d6, 0x00e6, 0x0126, 0x2091, 0x8000,
-	0x2071, 0x0040, 0x702c, 0xd084, 0x01d8, 0x908c, 0x0780, 0x190c,
-	0x7ea5, 0xd09c, 0x11a8, 0x2071, 0x1800, 0x70c0, 0x90ea, 0x0020,
-	0x0278, 0x8001, 0x70c2, 0x702c, 0x2048, 0xa800, 0x702e, 0x9006,
-	0xa802, 0xa806, 0x2071, 0x0040, 0x2900, 0x7022, 0x702c, 0x0c28,
-	0x012e, 0x00ee, 0x00de, 0x0005, 0x0006, 0x9084, 0x0780, 0x190c,
-	0x7ea5, 0x000e, 0x0005, 0xa898, 0x9084, 0x0003, 0x05a8, 0x080c,
-	0xab89, 0x05d8, 0x2900, 0x6016, 0xa864, 0x9084, 0x00ff, 0x9086,
-	0x0035, 0x1138, 0x6028, 0xc0fd, 0x602a, 0x2001, 0x196a, 0x2004,
-	0x0098, 0xa8a0, 0x9084, 0x00ff, 0xa99c, 0x918c, 0xff00, 0x9105,
-	0xa99c, 0x918c, 0x00ff, 0x080c, 0x2614, 0x1540, 0x00b6, 0x080c,
-	0x6620, 0x2b00, 0x00be, 0x1510, 0x6012, 0x6023, 0x0001, 0x2009,
-	0x0040, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0035, 0x0110, 0x2009,
-	0x0041, 0x080c, 0xac7c, 0x0005, 0xa87b, 0x0101, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x6d7b, 0x012e, 0x0005, 0xa87b, 0x002c, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x6d7b, 0x012e, 0x0005, 0xa87b, 0x0028,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6d7b, 0x012e, 0x080c, 0xabdf,
-	0x0005, 0x00d6, 0x00c6, 0x0036, 0x0026, 0x0016, 0x00b6, 0x7007,
-	0x0001, 0xaa74, 0x9282, 0x0004, 0x1a04, 0x7e96, 0xa97c, 0x9188,
-	0x1000, 0x2104, 0x905d, 0xb804, 0xd284, 0x0140, 0x05e8, 0x8007,
-	0x9084, 0x00ff, 0x9084, 0x0006, 0x1108, 0x04b0, 0x2b10, 0x080c,
-	0xab89, 0x1118, 0x080c, 0xac4f, 0x05a8, 0x6212, 0xa874, 0x0002,
-	0x7e74, 0x7e79, 0x7e7c, 0x7e82, 0x2019, 0x0002, 0x080c, 0xe249,
-	0x0060, 0x080c, 0xe1d9, 0x0048, 0x2019, 0x0002, 0xa980, 0x080c,
-	0xe1f8, 0x0018, 0xa980, 0x080c, 0xe1d9, 0x080c, 0xabdf, 0xa887,
-	0x0000, 0x0126, 0x2091, 0x8000, 0x080c, 0x6d7b, 0x012e, 0x00be,
-	0x001e, 0x002e, 0x003e, 0x00ce, 0x00de, 0x0005, 0xa887, 0x0006,
-	0x0c80, 0xa887, 0x0002, 0x0c68, 0xa887, 0x0005, 0x0c50, 0xa887,
-	0x0004, 0x0c38, 0xa887, 0x0007, 0x0c20, 0x2091, 0x8000, 0x0e04,
-	0x7ea7, 0x0006, 0x0016, 0x2001, 0x8003, 0x0006, 0x0804, 0x0d86,
-	0x2001, 0x1834, 0x2004, 0x9005, 0x0005, 0x0005, 0x00f6, 0x2079,
-	0x0300, 0x2001, 0x0200, 0x200c, 0xc1e5, 0xc1dc, 0x2102, 0x2009,
-	0x0218, 0x210c, 0xd1ec, 0x1120, 0x080c, 0x1615, 0x00fe, 0x0005,
-	0x2001, 0x020d, 0x2003, 0x0020, 0x781f, 0x0300, 0x00fe, 0x0005,
-	0x781c, 0xd08c, 0x0904, 0x7f28, 0x68c0, 0x90aa, 0x0005, 0x0a04,
-	0x8529, 0x7d44, 0x7c40, 0xd59c, 0x190c, 0x0d7d, 0x9584, 0x00f6,
-	0x1508, 0x9484, 0x7000, 0x0138, 0x908a, 0x2000, 0x1258, 0x9584,
-	0x0700, 0x8007, 0x04f0, 0x7000, 0x9084, 0xff00, 0x9086, 0x8100,
-	0x0db0, 0x00b0, 0x9484, 0x0fff, 0x1130, 0x7000, 0x9084, 0xff00,
-	0x9086, 0x8100, 0x11c0, 0x080c, 0xe6ea, 0x080c, 0x8420, 0x7817,
-	0x0140, 0x00a8, 0x9584, 0x0076, 0x1118, 0x080c, 0x847c, 0x19c8,
-	0xd5a4, 0x0148, 0x0046, 0x0056, 0x080c, 0x7f78, 0x080c, 0x2126,
-	0x005e, 0x004e, 0x0020, 0x080c, 0xe6ea, 0x7817, 0x0140, 0x080c,
-	0x74c8, 0x0168, 0x2001, 0x0111, 0x2004, 0xd08c, 0x0140, 0x6893,
-	0x0000, 0x2001, 0x0110, 0x2003, 0x0008, 0x2003, 0x0000, 0x0489,
-	0x0005, 0x0002, 0x7f35, 0x8242, 0x7f32, 0x7f32, 0x7f32, 0x7f32,
-	0x7f32, 0x7f32, 0x7817, 0x0140, 0x0005, 0x7000, 0x908c, 0xff00,
-	0x9194, 0xf000, 0x810f, 0x9484, 0x0fff, 0x6892, 0x9286, 0x2000,
-	0x1150, 0x6800, 0x9086, 0x0001, 0x1118, 0x080c, 0x5736, 0x0070,
-	0x080c, 0x7f98, 0x0058, 0x9286, 0x3000, 0x1118, 0x080c, 0x817f,
-	0x0028, 0x9286, 0x8000, 0x1110, 0x080c, 0x8356, 0x7817, 0x0140,
-	0x0005, 0x2001, 0x1810, 0x2004, 0xd08c, 0x0178, 0x2001, 0x1800,
-	0x2004, 0x9086, 0x0003, 0x1148, 0x0026, 0x0036, 0x2011, 0x8048,
-	0x2518, 0x080c, 0x4b09, 0x003e, 0x002e, 0x0005, 0x0036, 0x0046,
-	0x0056, 0x00f6, 0x2079, 0x0200, 0x2019, 0xfffe, 0x7c30, 0x0050,
-	0x0036, 0x0046, 0x0056, 0x00f6, 0x2079, 0x0200, 0x7d44, 0x7c40,
-	0x2019, 0xffff, 0x2001, 0x1810, 0x2004, 0xd08c, 0x0160, 0x2001,
-	0x1800, 0x2004, 0x9086, 0x0003, 0x1130, 0x0026, 0x2011, 0x8048,
-	0x080c, 0x4b09, 0x002e, 0x00fe, 0x005e, 0x004e, 0x003e, 0x0005,
-	0x00b6, 0x00c6, 0x7010, 0x9084, 0xff00, 0x8007, 0x9096, 0x0001,
-	0x0120, 0x9096, 0x0023, 0x1904, 0x8150, 0x9186, 0x0023, 0x15c0,
-	0x080c, 0x83eb, 0x0904, 0x8150, 0x6120, 0x9186, 0x0001, 0x0150,
-	0x9186, 0x0004, 0x0138, 0x9186, 0x0008, 0x0120, 0x9186, 0x000a,
-	0x1904, 0x8150, 0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1130,
-	0x2009, 0x0015, 0x080c, 0xac7c, 0x0804, 0x8150, 0x908e, 0x0214,
-	0x0118, 0x908e, 0x0210, 0x1130, 0x2009, 0x0015, 0x080c, 0xac7c,
-	0x0804, 0x8150, 0x908e, 0x0100, 0x1904, 0x8150, 0x7034, 0x9005,
-	0x1904, 0x8150, 0x2009, 0x0016, 0x080c, 0xac7c, 0x0804, 0x8150,
-	0x9186, 0x0022, 0x1904, 0x8150, 0x7030, 0x908e, 0x0300, 0x1580,
-	0x68dc, 0xd0a4, 0x0528, 0xc0b5, 0x68de, 0x7100, 0x918c, 0x00ff,
-	0x697e, 0x7004, 0x6882, 0x00f6, 0x2079, 0x0100, 0x79e6, 0x78ea,
-	0x0006, 0x9084, 0x00ff, 0x0016, 0x2008, 0x080c, 0x265d, 0x7932,
-	0x7936, 0x001e, 0x000e, 0x00fe, 0x080c, 0x2614, 0x695e, 0x703c,
-	0x00e6, 0x2071, 0x0140, 0x7086, 0x2071, 0x1800, 0x70b6, 0x00ee,
-	0x7034, 0x9005, 0x1904, 0x8150, 0x2009, 0x0017, 0x0804, 0x8100,
-	0x908e, 0x0400, 0x1190, 0x7034, 0x9005, 0x1904, 0x8150, 0x080c,
-	0x74c8, 0x0120, 0x2009, 0x001d, 0x0804, 0x8100, 0x68dc, 0xc0a5,
-	0x68de, 0x2009, 0x0030, 0x0804, 0x8100, 0x908e, 0x0500, 0x1140,
-	0x7034, 0x9005, 0x1904, 0x8150, 0x2009, 0x0018, 0x0804, 0x8100,
-	0x908e, 0x2010, 0x1120, 0x2009, 0x0019, 0x0804, 0x8100, 0x908e,
-	0x2110, 0x1120, 0x2009, 0x001a, 0x0804, 0x8100, 0x908e, 0x5200,
-	0x1140, 0x7034, 0x9005, 0x1904, 0x8150, 0x2009, 0x001b, 0x0804,
-	0x8100, 0x908e, 0x5000, 0x1140, 0x7034, 0x9005, 0x1904, 0x8150,
-	0x2009, 0x001c, 0x0804, 0x8100, 0x908e, 0x1300, 0x1120, 0x2009,
-	0x0034, 0x0804, 0x8100, 0x908e, 0x1200, 0x1140, 0x7034, 0x9005,
-	0x1904, 0x8150, 0x2009, 0x0024, 0x0804, 0x8100, 0x908c, 0xff00,
-	0x918e, 0x2400, 0x1170, 0x2009, 0x002d, 0x2001, 0x1810, 0x2004,
-	0xd09c, 0x0904, 0x8100, 0x080c, 0xd65c, 0x1904, 0x8150, 0x0804,
-	0x80fe, 0x908c, 0xff00, 0x918e, 0x5300, 0x1120, 0x2009, 0x002a,
-	0x0804, 0x8100, 0x908e, 0x0f00, 0x1120, 0x2009, 0x0020, 0x0804,
-	0x8100, 0x908e, 0x6104, 0x1530, 0x2029, 0x0205, 0x2011, 0x026d,
-	0x8208, 0x2204, 0x9082, 0x0004, 0x8004, 0x8004, 0x20a8, 0x2011,
-	0x8015, 0x211c, 0x8108, 0x0046, 0x2124, 0x080c, 0x4b09, 0x004e,
-	0x8108, 0x0f04, 0x80b4, 0x9186, 0x0280, 0x1d88, 0x2504, 0x8000,
-	0x202a, 0x2009, 0x0260, 0x0c58, 0x202b, 0x0000, 0x2009, 0x0023,
-	0x0804, 0x8100, 0x908e, 0x6000, 0x1120, 0x2009, 0x003f, 0x0804,
-	0x8100, 0x908e, 0x5400, 0x1138, 0x080c, 0x84d9, 0x1904, 0x8150,
-	0x2009, 0x0046, 0x04a8, 0x908e, 0x5500, 0x1148, 0x080c, 0x8501,
-	0x1118, 0x2009, 0x0041, 0x0460, 0x2009, 0x0042, 0x0448, 0x908e,
-	0x7800, 0x1118, 0x2009, 0x0045, 0x0418, 0x908e, 0x1000, 0x1118,
-	0x2009, 0x004e, 0x00e8, 0x908e, 0x6300, 0x1118, 0x2009, 0x004a,
-	0x00b8, 0x908c, 0xff00, 0x918e, 0x5600, 0x1118, 0x2009, 0x004f,
-	0x0078, 0x908c, 0xff00, 0x918e, 0x5700, 0x1118, 0x2009, 0x0050,
-	0x0038, 0x2009, 0x001d, 0x6838, 0xd0d4, 0x0110, 0x2009, 0x004c,
-	0x0016, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2614,
-	0x1904, 0x8153, 0x080c, 0x65bf, 0x1904, 0x8153, 0xbe12, 0xbd16,
-	0x001e, 0x0016, 0x080c, 0x74c8, 0x01c0, 0x68dc, 0xd08c, 0x1148,
-	0x7000, 0x9084, 0x00ff, 0x1188, 0x7004, 0x9084, 0xff00, 0x1168,
-	0x0040, 0x687c, 0x9606, 0x1148, 0x6880, 0x9506, 0x9084, 0xff00,
-	0x1120, 0x9584, 0x00ff, 0xb886, 0x0080, 0xb884, 0x9005, 0x1168,
-	0x9186, 0x0046, 0x1150, 0x687c, 0x9606, 0x1138, 0x6880, 0x9506,
-	0x9084, 0xff00, 0x1110, 0x001e, 0x0098, 0x080c, 0xab89, 0x01a8,
-	0x2b08, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x9186,
-	0x004c, 0x1110, 0x6023, 0x000a, 0x0016, 0x001e, 0x080c, 0xac7c,
-	0x00ce, 0x00be, 0x0005, 0x001e, 0x0cd8, 0x2001, 0x180e, 0x2004,
-	0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x4b09, 0x080c, 0xac4f,
-	0x0d90, 0x2b08, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e,
-	0x0016, 0x9186, 0x0017, 0x0118, 0x9186, 0x0030, 0x1128, 0x6007,
-	0x0009, 0x6017, 0x2900, 0x0020, 0x6007, 0x0051, 0x6017, 0x0000,
-	0x602f, 0x0009, 0x6003, 0x0001, 0x080c, 0x9207, 0x08a0, 0x080c,
-	0x3326, 0x1140, 0x7010, 0x9084, 0xff00, 0x8007, 0x908e, 0x0008,
-	0x1108, 0x0009, 0x0005, 0x00b6, 0x00c6, 0x0046, 0x7000, 0x908c,
-	0xff00, 0x810f, 0x9186, 0x0033, 0x11e8, 0x080c, 0x83eb, 0x0904,
-	0x81da, 0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1140, 0x7034,
-	0x9005, 0x15c0, 0x2009, 0x0015, 0x080c, 0xac7c, 0x0498, 0x908e,
-	0x0100, 0x1580, 0x7034, 0x9005, 0x1568, 0x2009, 0x0016, 0x080c,
-	0xac7c, 0x0440, 0x9186, 0x0032, 0x1528, 0x7030, 0x908e, 0x1400,
-	0x1508, 0x2009, 0x0038, 0x0016, 0x2011, 0x0263, 0x2204, 0x8211,
-	0x220c, 0x080c, 0x2614, 0x11a8, 0x080c, 0x65bf, 0x1190, 0xbe12,
-	0xbd16, 0x080c, 0xab89, 0x0168, 0x2b08, 0x6112, 0x080c, 0xcccb,
-	0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x080c, 0xac7c, 0x0010,
-	0x00ce, 0x001e, 0x004e, 0x00ce, 0x00be, 0x0005, 0x00b6, 0x0046,
-	0x00e6, 0x00d6, 0x2028, 0x2130, 0x9696, 0x00ff, 0x11b8, 0x9592,
-	0xfffc, 0x02a0, 0x9596, 0xfffd, 0x1120, 0x2009, 0x007f, 0x0804,
-	0x823c, 0x9596, 0xfffe, 0x1120, 0x2009, 0x007e, 0x0804, 0x823c,
-	0x9596, 0xfffc, 0x1118, 0x2009, 0x0080, 0x04f0, 0x2011, 0x0000,
-	0x2019, 0x1837, 0x231c, 0xd3ac, 0x0130, 0x9026, 0x20a9, 0x0800,
-	0x2071, 0x1000, 0x0030, 0x2021, 0x0081, 0x20a9, 0x077f, 0x2071,
-	0x1081, 0x2e1c, 0x93dd, 0x0000, 0x1140, 0x82ff, 0x11d0, 0x9496,
-	0x00ff, 0x01b8, 0x2410, 0xc2fd, 0x00a0, 0xbf10, 0x2600, 0x9706,
-	0xb814, 0x1120, 0x9546, 0x1110, 0x2408, 0x00b0, 0x9745, 0x1148,
-	0x94c6, 0x007e, 0x0130, 0x94c6, 0x007f, 0x0118, 0x94c6, 0x0080,
-	0x1d20, 0x8420, 0x8e70, 0x1f04, 0x8211, 0x82ff, 0x1118, 0x9085,
-	0x0001, 0x0018, 0xc2fc, 0x2208, 0x9006, 0x00de, 0x00ee, 0x004e,
-	0x00be, 0x0005, 0x7000, 0x908c, 0xff00, 0x810f, 0x9184, 0x000f,
-	0x0002, 0x8259, 0x8259, 0x8259, 0x83fd, 0x8259, 0x825c, 0x8281,
-	0x830a, 0x8259, 0x8259, 0x8259, 0x8259, 0x8259, 0x8259, 0x8259,
-	0x8259, 0x7817, 0x0140, 0x0005, 0x00b6, 0x7110, 0xd1bc, 0x01e8,
-	0x7120, 0x2160, 0x9c8c, 0x0003, 0x11c0, 0x9c8a, 0x1ddc, 0x02a8,
-	0x6868, 0x9c02, 0x1290, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158,
-	0xb910, 0x9106, 0x1150, 0x700c, 0xb914, 0x9106, 0x1130, 0x7124,
-	0x610a, 0x2009, 0x0046, 0x080c, 0xac7c, 0x7817, 0x0140, 0x00be,
-	0x0005, 0x00b6, 0x00c6, 0x9484, 0x0fff, 0x0904, 0x82e6, 0x7110,
-	0xd1bc, 0x1904, 0x82e6, 0x7108, 0x700c, 0x2028, 0x918c, 0x00ff,
-	0x2130, 0x9094, 0xff00, 0x15c8, 0x81ff, 0x15b8, 0x9080, 0x3368,
-	0x200d, 0x918c, 0xff00, 0x810f, 0x2001, 0x0080, 0x9106, 0x0904,
-	0x82e6, 0x9182, 0x0801, 0x1a04, 0x82e6, 0x9190, 0x1000, 0x2204,
-	0x905d, 0x05e0, 0xbe12, 0xbd16, 0xb800, 0xd0ec, 0x15b8, 0xba04,
-	0x9294, 0xff00, 0x9286, 0x0600, 0x1190, 0x080c, 0xab89, 0x0598,
-	0x2b08, 0x7028, 0x6052, 0x702c, 0x604e, 0x6112, 0x6023, 0x0006,
-	0x7120, 0x610a, 0x7130, 0x615e, 0x080c, 0xd8c4, 0x00f8, 0x080c,
-	0x6a6a, 0x1138, 0xb807, 0x0606, 0x0c40, 0x190c, 0x81de, 0x11b0,
-	0x0880, 0x080c, 0xab89, 0x2b08, 0x0188, 0x6112, 0x6023, 0x0004,
-	0x7120, 0x610a, 0x9286, 0x0400, 0x1118, 0x6007, 0x0005, 0x0010,
-	0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x9207, 0x7817, 0x0140,
-	0x00ce, 0x00be, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0ec, 0x0120,
-	0x2011, 0x8049, 0x080c, 0x4b09, 0x080c, 0xac4f, 0x0d78, 0x2b08,
-	0x6112, 0x6023, 0x0006, 0x7120, 0x610a, 0x7130, 0x615e, 0x6017,
-	0xf300, 0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022, 0x080c,
-	0x9200, 0x08e0, 0x00b6, 0x7110, 0xd1bc, 0x05d0, 0x7020, 0x2060,
-	0x9c84, 0x0003, 0x15a8, 0x9c82, 0x1ddc, 0x0690, 0x6868, 0x9c02,
-	0x1678, 0x9484, 0x0fff, 0x9082, 0x000c, 0x0650, 0x7008, 0x9084,
-	0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1510, 0x700c, 0xb914,
-	0x9106, 0x11f0, 0x7124, 0x610a, 0x601c, 0xd0fc, 0x11c8, 0x2001,
-	0x0271, 0x2004, 0x9005, 0x1180, 0x9484, 0x0fff, 0x9082, 0x000c,
-	0x0158, 0x0066, 0x2031, 0x0100, 0xa001, 0xa001, 0x8631, 0x1de0,
-	0x006e, 0x601c, 0xd0fc, 0x1120, 0x2009, 0x0045, 0x080c, 0xac7c,
-	0x7817, 0x0140, 0x00be, 0x0005, 0x6120, 0x9186, 0x0002, 0x0128,
-	0x9186, 0x0005, 0x0110, 0x9085, 0x0001, 0x0005, 0x080c, 0x3326,
-	0x1168, 0x7010, 0x9084, 0xff00, 0x8007, 0x9086, 0x0000, 0x1130,
-	0x9184, 0x000f, 0x908a, 0x0006, 0x1208, 0x000b, 0x0005, 0x836d,
-	0x836e, 0x836d, 0x836d, 0x83cd, 0x83dc, 0x0005, 0x00b6, 0x7110,
-	0xd1bc, 0x0120, 0x702c, 0xd084, 0x0904, 0x83cb, 0x700c, 0x7108,
-	0x080c, 0x2614, 0x1904, 0x83cb, 0x080c, 0x65bf, 0x1904, 0x83cb,
-	0xbe12, 0xbd16, 0x7110, 0xd1bc, 0x01d8, 0x080c, 0x6a6a, 0x0118,
-	0x9086, 0x0004, 0x1588, 0x00c6, 0x080c, 0x83eb, 0x00ce, 0x05d8,
-	0x080c, 0xab89, 0x2b08, 0x05b8, 0x6112, 0x080c, 0xcccb, 0x6023,
-	0x0002, 0x7120, 0x610a, 0x2009, 0x0088, 0x080c, 0xac7c, 0x0458,
-	0x080c, 0x6a6a, 0x0148, 0x9086, 0x0004, 0x0130, 0x080c, 0x6a72,
-	0x0118, 0x9086, 0x0004, 0x1180, 0x080c, 0xab89, 0x2b08, 0x01d8,
-	0x6112, 0x080c, 0xcccb, 0x6023, 0x0005, 0x7120, 0x610a, 0x2009,
-	0x0088, 0x080c, 0xac7c, 0x0078, 0x080c, 0xab89, 0x2b08, 0x0158,
-	0x6112, 0x080c, 0xcccb, 0x6023, 0x0004, 0x7120, 0x610a, 0x2009,
-	0x0001, 0x080c, 0xac7c, 0x00be, 0x0005, 0x7110, 0xd1bc, 0x0158,
-	0x00d1, 0x0148, 0x080c, 0x834c, 0x1130, 0x7124, 0x610a, 0x2009,
-	0x0089, 0x080c, 0xac7c, 0x0005, 0x7110, 0xd1bc, 0x0158, 0x0059,
-	0x0148, 0x080c, 0x834c, 0x1130, 0x7124, 0x610a, 0x2009, 0x008a,
-	0x080c, 0xac7c, 0x0005, 0x7020, 0x2060, 0x9c84, 0x0003, 0x1158,
-	0x9c82, 0x1ddc, 0x0240, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1218,
-	0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8, 0x00b6, 0x7110, 0xd1bc,
-	0x11d8, 0x7024, 0x2060, 0x9c84, 0x0003, 0x11b0, 0x9c82, 0x1ddc,
-	0x0298, 0x6868, 0x9c02, 0x1280, 0x7008, 0x9084, 0x00ff, 0x6110,
-	0x2158, 0xb910, 0x9106, 0x1140, 0x700c, 0xb914, 0x9106, 0x1120,
-	0x2009, 0x0051, 0x080c, 0xac7c, 0x7817, 0x0140, 0x00be, 0x0005,
-	0x2031, 0x0105, 0x0069, 0x0005, 0x2031, 0x0206, 0x0049, 0x0005,
-	0x2031, 0x0207, 0x0029, 0x0005, 0x2031, 0x0213, 0x0009, 0x0005,
-	0x00c6, 0x0096, 0x00f6, 0x7000, 0x9084, 0xf000, 0x9086, 0xc000,
-	0x05c0, 0x080c, 0xab89, 0x05a8, 0x0066, 0x00c6, 0x0046, 0x2011,
-	0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2614, 0x1590, 0x080c,
-	0x65bf, 0x1578, 0xbe12, 0xbd16, 0x2b00, 0x004e, 0x00ce, 0x6012,
-	0x080c, 0xcccb, 0x080c, 0x103a, 0x0500, 0x2900, 0x6062, 0x9006,
-	0xa802, 0xa866, 0xac6a, 0xa85c, 0x90f8, 0x001b, 0x20a9, 0x000e,
-	0xa860, 0x20e8, 0x20e1, 0x0000, 0x2fa0, 0x2e98, 0x4003, 0x006e,
-	0x6616, 0x6007, 0x003e, 0x6023, 0x0001, 0x6003, 0x0001, 0x080c,
-	0x9207, 0x00fe, 0x009e, 0x00ce, 0x0005, 0x080c, 0xabdf, 0x006e,
-	0x0cc0, 0x004e, 0x00ce, 0x0cc8, 0x00c6, 0x7000, 0x908c, 0xff00,
-	0x9184, 0xf000, 0x810f, 0x9086, 0x2000, 0x1904, 0x84d3, 0x9186,
-	0x0022, 0x15f0, 0x2001, 0x0111, 0x2004, 0x9005, 0x1904, 0x84d5,
-	0x7030, 0x908e, 0x0400, 0x0904, 0x84d5, 0x908e, 0x6000, 0x05e8,
-	0x908e, 0x5400, 0x05d0, 0x908e, 0x0300, 0x11d8, 0x2009, 0x1837,
-	0x210c, 0xd18c, 0x1590, 0xd1a4, 0x1580, 0x080c, 0x6a28, 0x0558,
-	0x68b0, 0x9084, 0x00ff, 0x7100, 0x918c, 0x00ff, 0x9106, 0x1518,
-	0x6880, 0x69b0, 0x918c, 0xff00, 0x9105, 0x7104, 0x9106, 0x11d8,
-	0x00e0, 0x2009, 0x0103, 0x210c, 0xd1b4, 0x11a8, 0x908e, 0x5200,
-	0x09e8, 0x908e, 0x0500, 0x09d0, 0x908e, 0x5000, 0x09b8, 0x0058,
-	0x9186, 0x0023, 0x1140, 0x080c, 0x83eb, 0x0128, 0x6004, 0x9086,
-	0x0002, 0x0118, 0x0000, 0x9006, 0x0010, 0x9085, 0x0001, 0x00ce,
-	0x0005, 0x0156, 0x0046, 0x0016, 0x0036, 0x7038, 0x2020, 0x8427,
-	0x94a4, 0x0007, 0xd484, 0x0148, 0x20a9, 0x0004, 0x2019, 0x1805,
-	0x2011, 0x027a, 0x080c, 0xbba1, 0x1178, 0xd48c, 0x0148, 0x20a9,
-	0x0004, 0x2019, 0x1801, 0x2011, 0x027e, 0x080c, 0xbba1, 0x1120,
-	0xd494, 0x0110, 0x9085, 0x0001, 0x003e, 0x001e, 0x004e, 0x015e,
-	0x0005, 0x0156, 0x0046, 0x0016, 0x0036, 0x7038, 0x2020, 0x8427,
-	0x94a4, 0x0007, 0xd484, 0x0148, 0x20a9, 0x0004, 0x2019, 0x1805,
-	0x2011, 0x0272, 0x080c, 0xbba1, 0x1178, 0xd48c, 0x0148, 0x20a9,
-	0x0004, 0x2019, 0x1801, 0x2011, 0x0276, 0x080c, 0xbba1, 0x1120,
-	0xd494, 0x0110, 0x9085, 0x0001, 0x003e, 0x001e, 0x004e, 0x015e,
-	0x0005, 0x00f6, 0x2079, 0x0200, 0x7800, 0xc0e5, 0xc0cc, 0x7802,
-	0x00fe, 0x0005, 0x00f6, 0x2079, 0x1800, 0x7834, 0xd084, 0x1130,
-	0x2079, 0x0200, 0x7800, 0x9085, 0x1200, 0x7802, 0x00fe, 0x0005,
-	0x00e6, 0x2071, 0x1800, 0x7034, 0xc084, 0x7036, 0x00ee, 0x0005,
-	0x2071, 0x1a02, 0x7003, 0x0003, 0x700f, 0x0361, 0x9006, 0x701a,
-	0x7072, 0x7012, 0x7017, 0x1ddc, 0x7007, 0x0000, 0x7026, 0x702b,
-	0x9e36, 0x7032, 0x7037, 0x9eb3, 0x703f, 0xffff, 0x7042, 0x7047,
-	0x556c, 0x704a, 0x705b, 0x86f0, 0x080c, 0x1053, 0x090c, 0x0d7d,
-	0x2900, 0x703a, 0xa867, 0x0003, 0xa86f, 0x0100, 0xa8ab, 0xdcb0,
-	0x0005, 0x2071, 0x1a02, 0x1d04, 0x860c, 0x2091, 0x6000, 0x700c,
-	0x8001, 0x700e, 0x1590, 0x2001, 0x013c, 0x2004, 0x9005, 0x190c,
-	0x879a, 0x2001, 0x1869, 0x2004, 0xd0c4, 0x0158, 0x3a00, 0xd08c,
-	0x1140, 0x20d1, 0x0000, 0x20d1, 0x0001, 0x20d1, 0x0000, 0x080c,
-	0x0d7d, 0x700f, 0x0361, 0x7007, 0x0001, 0x0126, 0x2091, 0x8000,
-	0x2069, 0x1800, 0x69ec, 0xd1e4, 0x1138, 0xd1dc, 0x1118, 0x080c,
-	0x875e, 0x0010, 0x080c, 0x8735, 0x7040, 0x900d, 0x0148, 0x8109,
-	0x7142, 0x1130, 0x7044, 0x080f, 0x0018, 0x0126, 0x2091, 0x8000,
-	0x7024, 0x900d, 0x0188, 0x7020, 0x8001, 0x7022, 0x1168, 0x7023,
-	0x0009, 0x8109, 0x7126, 0x9186, 0x03e8, 0x1110, 0x7028, 0x080f,
-	0x81ff, 0x1110, 0x7028, 0x080f, 0x7030, 0x900d, 0x0180, 0x702c,
-	0x8001, 0x702e, 0x1160, 0x702f, 0x0009, 0x8109, 0x7132, 0x0128,
-	0x9184, 0x007f, 0x090c, 0x9f4f, 0x0010, 0x7034, 0x080f, 0x703c,
-	0x9005, 0x0118, 0x0310, 0x8001, 0x703e, 0x704c, 0x900d, 0x0168,
-	0x7048, 0x8001, 0x704a, 0x1148, 0x704b, 0x0009, 0x8109, 0x714e,
-	0x1120, 0x7150, 0x714e, 0x7058, 0x080f, 0x7018, 0x900d, 0x01d8,
-	0x0016, 0x7070, 0x900d, 0x0158, 0x706c, 0x8001, 0x706e, 0x1138,
-	0x706f, 0x0009, 0x8109, 0x7172, 0x1110, 0x7074, 0x080f, 0x001e,
-	0x7008, 0x8001, 0x700a, 0x1138, 0x700b, 0x0009, 0x8109, 0x711a,
-	0x1110, 0x701c, 0x080f, 0x012e, 0x7004, 0x0002, 0x8634, 0x8635,
-	0x865f, 0x00e6, 0x2071, 0x1a02, 0x7018, 0x9005, 0x1120, 0x711a,
-	0x721e, 0x700b, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071,
-	0x1a02, 0x701c, 0x9206, 0x1120, 0x701a, 0x701e, 0x7072, 0x7076,
-	0x000e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1a02, 0xb888, 0x9102,
-	0x0208, 0xb98a, 0x00ee, 0x0005, 0x0005, 0x00b6, 0x2031, 0x0010,
-	0x7110, 0x080c, 0x6620, 0x11a8, 0xb888, 0x8001, 0x0290, 0xb88a,
-	0x1180, 0x0126, 0x2091, 0x8000, 0x0066, 0xb8d0, 0x9005, 0x0138,
-	0x0026, 0xba3c, 0x0016, 0x080c, 0x674b, 0x001e, 0x002e, 0x006e,
-	0x012e, 0x8108, 0x9182, 0x0800, 0x1220, 0x8631, 0x0128, 0x7112,
-	0x0c00, 0x900e, 0x7007, 0x0002, 0x7112, 0x00be, 0x0005, 0x2031,
-	0x0010, 0x7014, 0x2060, 0x0126, 0x2091, 0x8000, 0x6048, 0x9005,
-	0x0128, 0x8001, 0x604a, 0x1110, 0x080c, 0xcb4c, 0x6018, 0x9005,
-	0x0904, 0x86b7, 0x00f6, 0x2079, 0x0300, 0x7918, 0xd1b4, 0x1904,
-	0x86ca, 0x781b, 0x2020, 0xa001, 0x7918, 0xd1b4, 0x0120, 0x781b,
-	0x2000, 0x0804, 0x86ca, 0x8001, 0x601a, 0x0106, 0x781b, 0x2000,
-	0xa001, 0x7918, 0xd1ac, 0x1dd0, 0x010e, 0x00fe, 0x1540, 0x6120,
-	0x9186, 0x0003, 0x0148, 0x9186, 0x0006, 0x0130, 0x9186, 0x0009,
-	0x11e0, 0x611c, 0xd1c4, 0x1100, 0x080c, 0xc832, 0x01b0, 0x6014,
-	0x2048, 0xa884, 0x908a, 0x199a, 0x0280, 0x9082, 0x1999, 0xa886,
-	0x908a, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x800b, 0x810b,
-	0x9108, 0x611a, 0x080c, 0xcf7d, 0x0110, 0x080c, 0xc523, 0x012e,
-	0x9c88, 0x001c, 0x7116, 0x2001, 0x181a, 0x2004, 0x9102, 0x1228,
-	0x8631, 0x0138, 0x2160, 0x0804, 0x8663, 0x7017, 0x1ddc, 0x7007,
-	0x0000, 0x0005, 0x00fe, 0x0c58, 0x00e6, 0x2071, 0x1a02, 0x7027,
-	0x07d0, 0x7023, 0x0009, 0x00ee, 0x0005, 0x2001, 0x1a0b, 0x2003,
-	0x0000, 0x0005, 0x00e6, 0x2071, 0x1a02, 0x7132, 0x702f, 0x0009,
-	0x00ee, 0x0005, 0x2011, 0x1a0e, 0x2013, 0x0000, 0x0005, 0x00e6,
-	0x2071, 0x1a02, 0x711a, 0x721e, 0x700b, 0x0009, 0x00ee, 0x0005,
-	0x0086, 0x0026, 0x7054, 0x8000, 0x7056, 0x2001, 0x1a10, 0x2044,
-	0xa06c, 0x9086, 0x0000, 0x0150, 0x7068, 0xa09a, 0x7064, 0xa096,
-	0x7060, 0xa092, 0x705c, 0xa08e, 0x080c, 0x112f, 0x002e, 0x008e,
-	0x0005, 0x0006, 0x0016, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6,
-	0x00e6, 0x00f6, 0x0156, 0x080c, 0x8571, 0x015e, 0x00fe, 0x00ee,
-	0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x001e, 0x000e, 0x0005,
-	0x00e6, 0x2071, 0x1a02, 0x7172, 0x7276, 0x706f, 0x0009, 0x00ee,
-	0x0005, 0x00e6, 0x0006, 0x2071, 0x1a02, 0x7074, 0x9206, 0x1110,
-	0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x2069, 0x1800, 0x69ec,
-	0xd1e4, 0x1518, 0x0026, 0xd1ec, 0x0140, 0x6a54, 0x6874, 0x9202,
-	0x0288, 0x8117, 0x9294, 0x00c1, 0x0088, 0x9184, 0x0007, 0x01a0,
-	0x8109, 0x9184, 0x0007, 0x0110, 0x69ee, 0x0070, 0x8107, 0x9084,
-	0x0007, 0x910d, 0x8107, 0x9106, 0x9094, 0x00c1, 0x9184, 0xff3e,
-	0x9205, 0x68ee, 0x080c, 0x0f05, 0x002e, 0x0005, 0x69e8, 0x9184,
-	0x003f, 0x05b8, 0x8109, 0x9184, 0x003f, 0x01a8, 0x6a54, 0x6874,
-	0x9202, 0x0220, 0xd1bc, 0x0168, 0xc1bc, 0x0018, 0xd1bc, 0x1148,
-	0xc1bd, 0x2110, 0x00e6, 0x2071, 0x1800, 0x080c, 0x0f27, 0x00ee,
-	0x0400, 0x69ea, 0x00f0, 0x0026, 0x8107, 0x9094, 0x0007, 0x0128,
-	0x8001, 0x8007, 0x9085, 0x0007, 0x0050, 0x2010, 0x8004, 0x8004,
-	0x8004, 0x9084, 0x0007, 0x9205, 0x8007, 0x9085, 0x0028, 0x9086,
-	0x0040, 0x2010, 0x00e6, 0x2071, 0x1800, 0x080c, 0x0f27, 0x00ee,
-	0x002e, 0x0005, 0x0016, 0x00c6, 0x2009, 0xfffc, 0x210d, 0x2061,
-	0x0100, 0x60f0, 0x9100, 0x60f3, 0x0000, 0x2009, 0xfffc, 0x200f,
-	0x1220, 0x8108, 0x2105, 0x8000, 0x200f, 0x00ce, 0x001e, 0x0005,
-	0x00c6, 0x2061, 0x1a6e, 0x00ce, 0x0005, 0x9184, 0x000f, 0x8003,
-	0x8003, 0x8003, 0x9080, 0x1a6e, 0x2060, 0x0005, 0xa884, 0x908a,
-	0x199a, 0x1638, 0x9005, 0x1150, 0x00c6, 0x2061, 0x1a6e, 0x6014,
-	0x00ce, 0x9005, 0x1130, 0x2001, 0x001e, 0x0018, 0x908e, 0xffff,
-	0x01b0, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0xa87c, 0x908c,
-	0x00c0, 0x918e, 0x00c0, 0x0904, 0x8878, 0xd0b4, 0x1168, 0xd0bc,
-	0x1904, 0x8851, 0x2009, 0x0006, 0x080c, 0x88a5, 0x0005, 0x900e,
-	0x0c60, 0x2001, 0x1999, 0x08b0, 0xd0fc, 0x05e0, 0x908c, 0x2023,
-	0x1568, 0x87ff, 0x1558, 0xa9a8, 0x81ff, 0x1540, 0x6124, 0x918c,
-	0x0500, 0x1520, 0x6100, 0x918e, 0x0007, 0x1500, 0x2009, 0x1869,
-	0x210c, 0xd184, 0x11d8, 0x6003, 0x0003, 0x6007, 0x0043, 0x6047,
-	0xb035, 0x080c, 0x1c10, 0xa87c, 0xc0dd, 0xa87e, 0x600f, 0x0000,
-	0x00f6, 0x2079, 0x0380, 0x7818, 0xd0bc, 0x1de8, 0x7833, 0x0013,
-	0x2c00, 0x7836, 0x781b, 0x8080, 0x00fe, 0x0005, 0x908c, 0x0003,
-	0x0120, 0x918e, 0x0003, 0x1904, 0x889f, 0x908c, 0x2020, 0x918e,
-	0x2020, 0x01a8, 0x6024, 0xd0d4, 0x11e8, 0x2009, 0x1869, 0x2104,
-	0xd084, 0x1138, 0x87ff, 0x1120, 0x2009, 0x0043, 0x0804, 0xac7c,
-	0x0005, 0x87ff, 0x1de8, 0x2009, 0x0042, 0x0804, 0xac7c, 0x6110,
-	0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20, 0x6024, 0xc0cd,
-	0x6026, 0x0c00, 0xc0d4, 0x6026, 0xa890, 0x602e, 0xa88c, 0x6032,
-	0x08e0, 0xd0fc, 0x0160, 0x908c, 0x0003, 0x0120, 0x918e, 0x0003,
-	0x1904, 0x889f, 0x908c, 0x2020, 0x918e, 0x2020, 0x0170, 0x0076,
-	0x00f6, 0x2c78, 0x080c, 0x173e, 0x00fe, 0x007e, 0x87ff, 0x1120,
-	0x2009, 0x0042, 0x080c, 0xac7c, 0x0005, 0x6110, 0x00b6, 0x2158,
-	0xb900, 0x00be, 0xd1ac, 0x0d58, 0x6124, 0xc1cd, 0x6126, 0x0c38,
-	0xd0fc, 0x0188, 0x908c, 0x2020, 0x918e, 0x2020, 0x01a8, 0x9084,
-	0x0003, 0x908e, 0x0002, 0x0148, 0x87ff, 0x1120, 0x2009, 0x0041,
-	0x080c, 0xac7c, 0x0005, 0x00b9, 0x0ce8, 0x87ff, 0x1dd8, 0x2009,
-	0x0043, 0x080c, 0xac7c, 0x0cb0, 0x6110, 0x00b6, 0x2158, 0xb900,
-	0x00be, 0xd1ac, 0x0d20, 0x6124, 0xc1cd, 0x6126, 0x0c00, 0x2009,
-	0x0004, 0x0019, 0x0005, 0x2009, 0x0001, 0x0096, 0x080c, 0xc832,
-	0x0518, 0x6014, 0x2048, 0xa982, 0xa800, 0x6016, 0x9186, 0x0001,
-	0x1188, 0xa97c, 0x918c, 0x8100, 0x918e, 0x8100, 0x1158, 0x00c6,
-	0x2061, 0x1a6e, 0x6200, 0xd28c, 0x1120, 0x6204, 0x8210, 0x0208,
-	0x6206, 0x00ce, 0x080c, 0x6bb0, 0x6014, 0x904d, 0x0076, 0x2039,
-	0x0000, 0x190c, 0x87be, 0x007e, 0x009e, 0x0005, 0x0156, 0x00c6,
-	0x2061, 0x1a6e, 0x6000, 0x81ff, 0x0110, 0x9205, 0x0008, 0x9204,
-	0x6002, 0x00ce, 0x015e, 0x0005, 0x6800, 0xd08c, 0x1138, 0x6808,
-	0x9005, 0x0120, 0x8001, 0x680a, 0x9085, 0x0001, 0x0005, 0x2071,
-	0x1923, 0x7003, 0x0006, 0x7007, 0x0000, 0x700f, 0x0000, 0x7013,
-	0x0001, 0x080c, 0x1053, 0x090c, 0x0d7d, 0xa867, 0x0006, 0xa86b,
-	0x0001, 0xa8ab, 0xdcb0, 0xa89f, 0x0000, 0x2900, 0x702e, 0x7033,
-	0x0000, 0x0005, 0x0096, 0x00e6, 0x2071, 0x1923, 0x702c, 0x2048,
-	0x6a2c, 0x721e, 0x6b30, 0x7322, 0x6834, 0x7026, 0xa896, 0x6838,
-	0x702a, 0xa89a, 0x6824, 0x7016, 0x683c, 0x701a, 0x2009, 0x0028,
-	0x200a, 0x9005, 0x0148, 0x900e, 0x9188, 0x000c, 0x8001, 0x1de0,
-	0x2100, 0x9210, 0x1208, 0x8318, 0xaa8e, 0xab92, 0x7010, 0xd084,
-	0x0178, 0xc084, 0x7007, 0x0001, 0x700f, 0x0000, 0x0006, 0x2009,
-	0x181d, 0x2104, 0x9082, 0x0007, 0x2009, 0x1b4d, 0x200a, 0x000e,
-	0xc095, 0x7012, 0x2008, 0x2001, 0x003b, 0x080c, 0x1686, 0x9006,
-	0x2071, 0x193c, 0x7002, 0x7006, 0x702a, 0x00ee, 0x009e, 0x0005,
-	0x00e6, 0x0126, 0x0156, 0x2091, 0x8000, 0x2071, 0x1800, 0x7154,
-	0x2001, 0x0008, 0x910a, 0x0638, 0x2001, 0x187d, 0x20ac, 0x9006,
-	0x9080, 0x0008, 0x1f04, 0x8958, 0x71c0, 0x9102, 0x02e0, 0x2071,
-	0x1877, 0x20a9, 0x0007, 0x00c6, 0x080c, 0xab89, 0x6023, 0x0009,
-	0x6003, 0x0004, 0x601f, 0x0101, 0x0089, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x8ade, 0x012e, 0x1f04, 0x8964, 0x9006, 0x00ce, 0x015e,
-	0x012e, 0x00ee, 0x0005, 0x9085, 0x0001, 0x0cc8, 0x00e6, 0x00b6,
-	0x0096, 0x0086, 0x0056, 0x0046, 0x0026, 0x7118, 0x720c, 0x7620,
-	0x7004, 0xd084, 0x1128, 0x2021, 0x0024, 0x2029, 0x0002, 0x0020,
-	0x2021, 0x002c, 0x2029, 0x000a, 0x080c, 0x103a, 0x090c, 0x0d7d,
-	0x2900, 0x6016, 0x2058, 0xac66, 0x9006, 0xa802, 0xa806, 0xa86a,
-	0xa87a, 0xa8aa, 0xa887, 0x0005, 0xa87f, 0x0020, 0x7008, 0xa89a,
-	0x7010, 0xa89e, 0xae8a, 0xa8af, 0xffff, 0xa8b3, 0x0000, 0x8109,
-	0x0160, 0x080c, 0x103a, 0x090c, 0x0d7d, 0xad66, 0x2b00, 0xa802,
-	0x2900, 0xb806, 0x2058, 0x8109, 0x1da0, 0x002e, 0x004e, 0x005e,
-	0x008e, 0x009e, 0x00be, 0x00ee, 0x0005, 0x2079, 0x0000, 0x2071,
-	0x1923, 0x7004, 0x004b, 0x700c, 0x0002, 0x89d0, 0x89c9, 0x89c9,
-	0x0005, 0x89da, 0x8a3b, 0x8a3b, 0x8a3b, 0x8a3c, 0x8a4d, 0x8a4d,
-	0x700c, 0x0cba, 0x0126, 0x2091, 0x8000, 0x78a0, 0x79a0, 0x9106,
-	0x0128, 0x78a0, 0x79a0, 0x9106, 0x1904, 0x8a2e, 0x2001, 0x0005,
-	0x2004, 0xd0bc, 0x0130, 0x2011, 0x0004, 0x2204, 0xc0c5, 0x2012,
-	0x0ca8, 0x012e, 0x7018, 0x910a, 0x1130, 0x7030, 0x9005, 0x05a8,
-	0x080c, 0x8a7c, 0x0490, 0x1210, 0x7114, 0x910a, 0x9192, 0x000a,
-	0x0210, 0x2009, 0x000a, 0x2001, 0x1888, 0x2014, 0x2001, 0x1935,
-	0x2004, 0x9100, 0x9202, 0x0e48, 0x080c, 0x8bc8, 0x2200, 0x9102,
-	0x0208, 0x2208, 0x0096, 0x702c, 0x2048, 0xa873, 0x0001, 0xa976,
-	0x080c, 0x8cd1, 0x2100, 0xa87e, 0xa86f, 0x0000, 0x009e, 0x0126,
-	0x2091, 0x8000, 0x2009, 0x1a20, 0x2104, 0xc085, 0x200a, 0x700f,
-	0x0002, 0x012e, 0x080c, 0x114e, 0x1de8, 0x0005, 0x2001, 0x0005,
-	0x2004, 0xd0bc, 0x0130, 0x2011, 0x0004, 0x2204, 0xc0c5, 0x2012,
-	0x0ca8, 0x012e, 0x0005, 0x0005, 0x700c, 0x0002, 0x8a41, 0x8a44,
-	0x8a43, 0x080c, 0x89d8, 0x0005, 0x8001, 0x700e, 0x0096, 0x702c,
-	0x2048, 0xa974, 0x009e, 0x0011, 0x0ca0, 0x0005, 0x0096, 0x702c,
-	0x2048, 0x7018, 0x9100, 0x7214, 0x921a, 0x1130, 0x701c, 0xa88e,
-	0x7020, 0xa892, 0x9006, 0x0068, 0x0006, 0x080c, 0x8cd1, 0x2100,
-	0xaa8c, 0x9210, 0xaa8e, 0x1220, 0xa890, 0x9081, 0x0000, 0xa892,
-	0x000e, 0x009e, 0x2f08, 0x9188, 0x0028, 0x200a, 0x701a, 0x0005,
-	0x00e6, 0x2071, 0x1923, 0x700c, 0x0002, 0x8a7a, 0x8a7a, 0x8a78,
-	0x700f, 0x0001, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x7030,
-	0x9005, 0x0508, 0x2078, 0x7814, 0x2048, 0xae88, 0x00b6, 0x2059,
-	0x0000, 0x080c, 0x8ae7, 0x00be, 0x01b0, 0x00e6, 0x2071, 0x193c,
-	0x080c, 0x8b2e, 0x00ee, 0x0178, 0x0096, 0x080c, 0x1053, 0x2900,
-	0x009e, 0x0148, 0xa8aa, 0x04b9, 0x0041, 0x2001, 0x1946, 0x2003,
-	0x0000, 0x012e, 0x08c8, 0x012e, 0x0005, 0x00d6, 0x00c6, 0x0086,
-	0x00a6, 0x2940, 0x2650, 0x2600, 0x9005, 0x0180, 0xa864, 0x9084,
-	0x000f, 0x2068, 0x9d88, 0x1e62, 0x2165, 0x0056, 0x2029, 0x0000,
-	0x080c, 0x8c56, 0x080c, 0x1e38, 0x1dd8, 0x005e, 0x00ae, 0x2001,
-	0x187f, 0x2004, 0xa88a, 0x080c, 0x173e, 0x781f, 0x0101, 0x7813,
-	0x0000, 0x0126, 0x2091, 0x8000, 0x080c, 0x8b3d, 0x012e, 0x008e,
-	0x00ce, 0x00de, 0x0005, 0x7030, 0x9005, 0x0138, 0x2078, 0x780c,
-	0x7032, 0x2001, 0x1946, 0x2003, 0x0001, 0x0005, 0x00e6, 0x2071,
-	0x1923, 0x7030, 0x600e, 0x2c00, 0x7032, 0x00ee, 0x0005, 0x00d6,
-	0x00c6, 0x0026, 0x9b80, 0x8db0, 0x2005, 0x906d, 0x090c, 0x0d7d,
-	0x9b80, 0x8da8, 0x2005, 0x9065, 0x090c, 0x0d7d, 0x6114, 0x2600,
-	0x9102, 0x0248, 0x6828, 0x9102, 0x02f0, 0x9085, 0x0001, 0x002e,
-	0x00ce, 0x00de, 0x0005, 0x6804, 0xd094, 0x0148, 0x6854, 0xd084,
-	0x1178, 0xc085, 0x6856, 0x2011, 0x8026, 0x080c, 0x4b09, 0x684c,
-	0x0096, 0x904d, 0x090c, 0x0d7d, 0xa804, 0x8000, 0xa806, 0x009e,
-	0x9006, 0x2030, 0x0c20, 0x6854, 0xd08c, 0x1d08, 0xc08d, 0x6856,
-	0x2011, 0x8025, 0x080c, 0x4b09, 0x684c, 0x0096, 0x904d, 0x090c,
-	0x0d7d, 0xa800, 0x8000, 0xa802, 0x009e, 0x0888, 0x7000, 0x2019,
-	0x0008, 0x8319, 0x7104, 0x9102, 0x1118, 0x2300, 0x9005, 0x0020,
-	0x0210, 0x9302, 0x0008, 0x8002, 0x0005, 0x00d6, 0x7814, 0x9005,
-	0x090c, 0x0d7d, 0x781c, 0x9084, 0x0101, 0x9086, 0x0101, 0x190c,
-	0x0d7d, 0x2069, 0x193c, 0x6804, 0x9080, 0x193e, 0x2f08, 0x2102,
-	0x6904, 0x8108, 0x9182, 0x0008, 0x0208, 0x900e, 0x6906, 0x9180,
-	0x193e, 0x2003, 0x0000, 0x00de, 0x0005, 0x0096, 0x00c6, 0x2060,
-	0x6014, 0x2048, 0xa8a8, 0x0096, 0x2048, 0x9005, 0x190c, 0x106c,
-	0x009e, 0xa8ab, 0x0000, 0x080c, 0x0fec, 0x080c, 0xabdf, 0x00ce,
-	0x009e, 0x0005, 0x6020, 0x9086, 0x0009, 0x1128, 0x601c, 0xd0c4,
-	0x0110, 0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x6000, 0x9086,
-	0x0000, 0x0178, 0x6010, 0x9005, 0x0150, 0x00b6, 0x2058, 0x080c,
-	0x8ee3, 0x00be, 0x6013, 0x0000, 0x601b, 0x0000, 0x0010, 0x2c00,
-	0x0861, 0x0005, 0x2009, 0x1927, 0x210c, 0xd194, 0x0005, 0x00e6,
-	0x2071, 0x1923, 0x7110, 0xc194, 0xd19c, 0x1118, 0xc185, 0x7007,
-	0x0000, 0x7112, 0x2001, 0x003b, 0x080c, 0x1686, 0x00ee, 0x0005,
-	0x0096, 0x00d6, 0x9006, 0x7006, 0x700e, 0x701a, 0x701e, 0x7022,
-	0x7016, 0x702a, 0x7026, 0x702f, 0x0000, 0x080c, 0x8d30, 0x0170,
-	0x080c, 0x8d65, 0x0158, 0x2900, 0x7002, 0x700a, 0x701a, 0x7013,
-	0x0001, 0x701f, 0x000a, 0x00de, 0x009e, 0x0005, 0x900e, 0x0cd8,
-	0x00e6, 0x0096, 0x0086, 0x00d6, 0x00c6, 0x2071, 0x1930, 0x721c,
-	0x2100, 0x9202, 0x1618, 0x080c, 0x8d65, 0x090c, 0x0d7d, 0x7018,
-	0x9005, 0x1160, 0x2900, 0x7002, 0x700a, 0x701a, 0x9006, 0x7006,
-	0x700e, 0xa806, 0xa802, 0x7012, 0x701e, 0x0038, 0x2040, 0xa806,
-	0x2900, 0xa002, 0x701a, 0xa803, 0x0000, 0x7010, 0x8000, 0x7012,
-	0x701c, 0x9080, 0x000a, 0x701e, 0x721c, 0x08d0, 0x721c, 0x00ce,
-	0x00de, 0x008e, 0x009e, 0x00ee, 0x0005, 0x0096, 0x0156, 0x0136,
-	0x0146, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1930, 0x7300,
-	0x831f, 0x831e, 0x831e, 0x9384, 0x003f, 0x20e8, 0x939c, 0xffc0,
-	0x9398, 0x0003, 0x7104, 0x080c, 0x8cd1, 0x810c, 0x2100, 0x9318,
-	0x8003, 0x2228, 0x2021, 0x0078, 0x9402, 0x9532, 0x0208, 0x2028,
-	0x2500, 0x8004, 0x20a8, 0x23a0, 0xa001, 0xa001, 0x4005, 0x2508,
-	0x080c, 0x8cda, 0x2130, 0x7014, 0x9600, 0x7016, 0x2600, 0x711c,
-	0x9102, 0x701e, 0x7004, 0x9600, 0x2008, 0x9082, 0x000a, 0x1190,
-	0x7000, 0x2048, 0xa800, 0x9005, 0x1148, 0x2009, 0x0001, 0x0026,
-	0x080c, 0x8bc8, 0x002e, 0x7000, 0x2048, 0xa800, 0x7002, 0x7007,
-	0x0000, 0x0008, 0x7106, 0x2500, 0x9212, 0x1904, 0x8c07, 0x012e,
-	0x00ee, 0x014e, 0x013e, 0x015e, 0x009e, 0x0005, 0x0016, 0x0026,
-	0x00e6, 0x0126, 0x2091, 0x8000, 0x9580, 0x8da8, 0x2005, 0x9075,
-	0x090c, 0x0d7d, 0x080c, 0x8cac, 0x012e, 0x9580, 0x8da4, 0x2005,
-	0x9075, 0x090c, 0x0d7d, 0x0156, 0x0136, 0x01c6, 0x0146, 0x01d6,
-	0x831f, 0x831e, 0x831e, 0x9384, 0x003f, 0x20e0, 0x9384, 0xffc0,
-	0x9100, 0x2098, 0xa860, 0x20e8, 0xa95c, 0x2c05, 0x9100, 0x20a0,
-	0x20a9, 0x0002, 0x4003, 0x2e0c, 0x2d00, 0x0002, 0x8c96, 0x8c96,
-	0x8c98, 0x8c96, 0x8c98, 0x8c96, 0x8c96, 0x8c96, 0x8c96, 0x8c96,
-	0x8c9e, 0x8c96, 0x8c9e, 0x8c96, 0x8c96, 0x8c96, 0x080c, 0x0d7d,
-	0x4104, 0x20a9, 0x0002, 0x4002, 0x4003, 0x0028, 0x20a9, 0x0002,
-	0x4003, 0x4104, 0x4003, 0x01de, 0x014e, 0x01ce, 0x013e, 0x015e,
-	0x00ee, 0x002e, 0x001e, 0x0005, 0x0096, 0x7014, 0x8001, 0x7016,
-	0x710c, 0x2110, 0x00f1, 0x810c, 0x9188, 0x0003, 0x7308, 0x8210,
-	0x9282, 0x000a, 0x1198, 0x7008, 0x2048, 0xa800, 0x9005, 0x0158,
-	0x0006, 0x080c, 0x8d74, 0x009e, 0xa807, 0x0000, 0x2900, 0x700a,
-	0x7010, 0x8001, 0x7012, 0x700f, 0x0000, 0x0008, 0x720e, 0x009e,
-	0x0005, 0x0006, 0x810b, 0x810b, 0x2100, 0x810b, 0x9100, 0x2008,
-	0x000e, 0x0005, 0x0006, 0x0026, 0x2100, 0x9005, 0x0158, 0x9092,
-	0x000c, 0x0240, 0x900e, 0x8108, 0x9082, 0x000c, 0x1de0, 0x002e,
-	0x000e, 0x0005, 0x900e, 0x0cd8, 0x2d00, 0x90b8, 0x0008, 0x690c,
-	0x6810, 0x2019, 0x0001, 0x2031, 0x8d1a, 0x9112, 0x0220, 0x0118,
-	0x8318, 0x2208, 0x0cd0, 0x6808, 0x9005, 0x0108, 0x8318, 0x233a,
-	0x6804, 0xd084, 0x2300, 0x2021, 0x0001, 0x1150, 0x9082, 0x0003,
-	0x0967, 0x0a67, 0x8420, 0x9082, 0x0007, 0x0967, 0x0a67, 0x0cd0,
-	0x9082, 0x0002, 0x0967, 0x0a67, 0x8420, 0x9082, 0x0005, 0x0967,
-	0x0a67, 0x0cd0, 0x6c1a, 0x2d00, 0x90b8, 0x0007, 0x00e6, 0x2071,
-	0x1800, 0x7128, 0x6810, 0x2019, 0x0001, 0x910a, 0x0118, 0x0210,
-	0x8318, 0x0cd8, 0x2031, 0x8d2d, 0x0870, 0x6c16, 0x00ee, 0x0005,
-	0x0096, 0x0046, 0x0126, 0x2091, 0x8000, 0x2b00, 0x9080, 0x8dac,
-	0x2005, 0x9005, 0x090c, 0x0d7d, 0x2004, 0x90a0, 0x000a, 0x080c,
-	0x1053, 0x01d0, 0x2900, 0x7026, 0xa803, 0x0000, 0xa807, 0x0000,
-	0x080c, 0x1053, 0x0188, 0x7024, 0xa802, 0xa807, 0x0000, 0x2900,
-	0x7026, 0x94a2, 0x000a, 0x0110, 0x0208, 0x0c90, 0x9085, 0x0001,
-	0x012e, 0x004e, 0x009e, 0x0005, 0x7024, 0x9005, 0x0dc8, 0x2048,
-	0xac00, 0x080c, 0x106c, 0x2400, 0x0cc0, 0x0126, 0x2091, 0x8000,
-	0x7024, 0x2048, 0x9005, 0x0130, 0xa800, 0x7026, 0xa803, 0x0000,
-	0xa807, 0x0000, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x7024,
-	0xa802, 0x2900, 0x7026, 0x012e, 0x0005, 0x0096, 0x9e80, 0x0009,
-	0x2004, 0x9005, 0x0138, 0x2048, 0xa800, 0x0006, 0x080c, 0x106c,
-	0x000e, 0x0cb8, 0x009e, 0x0005, 0x0096, 0x7008, 0x9005, 0x0138,
-	0x2048, 0xa800, 0x0006, 0x080c, 0x106c, 0x000e, 0x0cb8, 0x9006,
-	0x7002, 0x700a, 0x7006, 0x700e, 0x701a, 0x701e, 0x7022, 0x702a,
-	0x7026, 0x702e, 0x009e, 0x0005, 0x1a6c, 0x0000, 0x0000, 0x0000,
-	0x1930, 0x0000, 0x0000, 0x0000, 0x1888, 0x0000, 0x0000, 0x0000,
-	0x1877, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00c6, 0x00b6, 0x00a6,
-	0xa8a8, 0x2040, 0x2071, 0x1877, 0x080c, 0x8ece, 0xa067, 0x0023,
-	0x6010, 0x905d, 0x0904, 0x8ea3, 0xb814, 0xa06e, 0xb910, 0xa172,
-	0xb9a0, 0xa176, 0x2001, 0x0003, 0xa07e, 0xa834, 0xa082, 0xa07b,
-	0x0000, 0xa898, 0x9005, 0x0118, 0xa078, 0xc085, 0xa07a, 0x2858,
-	0x2031, 0x0018, 0xa068, 0x908a, 0x0019, 0x1a0c, 0x0d7d, 0x2020,
-	0x2050, 0x2940, 0xa864, 0x90bc, 0x00ff, 0x908c, 0x000f, 0x91e0,
-	0x1e62, 0x2c65, 0x9786, 0x0024, 0x2c05, 0x1590, 0x908a, 0x0036,
-	0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002, 0x8e10, 0x8e10, 0x8e12,
-	0x8e10, 0x8e10, 0x8e10, 0x8e14, 0x8e10, 0x8e10, 0x8e10, 0x8e16,
-	0x8e10, 0x8e10, 0x8e10, 0x8e18, 0x8e10, 0x8e10, 0x8e10, 0x8e1a,
-	0x8e10, 0x8e10, 0x8e10, 0x8e1c, 0x8e10, 0x8e10, 0x8e10, 0x8e1e,
-	0x080c, 0x0d7d, 0xa180, 0x04b8, 0xa190, 0x04a8, 0xa1a0, 0x0498,
-	0xa1b0, 0x0488, 0xa1c0, 0x0478, 0xa1d0, 0x0468, 0xa1e0, 0x0458,
-	0x908a, 0x0034, 0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002, 0x8e42,
-	0x8e40, 0x8e40, 0x8e40, 0x8e40, 0x8e40, 0x8e44, 0x8e40, 0x8e40,
-	0x8e40, 0x8e40, 0x8e40, 0x8e46, 0x8e40, 0x8e40, 0x8e40, 0x8e40,
-	0x8e40, 0x8e48, 0x8e40, 0x8e40, 0x8e40, 0x8e40, 0x8e40, 0x8e4a,
-	0x080c, 0x0d7d, 0xa180, 0x0038, 0xa198, 0x0028, 0xa1b0, 0x0018,
-	0xa1c8, 0x0008, 0xa1e0, 0x2600, 0x0002, 0x8e66, 0x8e68, 0x8e6a,
-	0x8e6c, 0x8e6e, 0x8e70, 0x8e72, 0x8e74, 0x8e76, 0x8e78, 0x8e7a,
-	0x8e7c, 0x8e7e, 0x8e80, 0x8e82, 0x8e84, 0x8e86, 0x8e88, 0x8e8a,
-	0x8e8c, 0x8e8e, 0x8e90, 0x8e92, 0x8e94, 0x8e96, 0x080c, 0x0d7d,
-	0xb9e2, 0x0468, 0xb9de, 0x0458, 0xb9da, 0x0448, 0xb9d6, 0x0438,
-	0xb9d2, 0x0428, 0xb9ce, 0x0418, 0xb9ca, 0x0408, 0xb9c6, 0x00f8,
-	0xb9c2, 0x00e8, 0xb9be, 0x00d8, 0xb9ba, 0x00c8, 0xb9b6, 0x00b8,
-	0xb9b2, 0x00a8, 0xb9ae, 0x0098, 0xb9aa, 0x0088, 0xb9a6, 0x0078,
-	0xb9a2, 0x0068, 0xb99e, 0x0058, 0xb99a, 0x0048, 0xb996, 0x0038,
-	0xb992, 0x0028, 0xb98e, 0x0018, 0xb98a, 0x0008, 0xb986, 0x8631,
-	0x8421, 0x0120, 0x080c, 0x1e38, 0x0804, 0x8dea, 0x00ae, 0x00be,
-	0x00ce, 0x00ee, 0x0005, 0xa86c, 0xa06e, 0xa870, 0xa072, 0xa077,
-	0x00ff, 0x9006, 0x0804, 0x8dcc, 0x0006, 0x0016, 0x00b6, 0x6010,
-	0x2058, 0xb810, 0x9005, 0x01b0, 0x2001, 0x1924, 0x2004, 0x9005,
-	0x0188, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x1158, 0x0036,
-	0x0046, 0xbba0, 0x2021, 0x0004, 0x2011, 0x8014, 0x080c, 0x4b09,
-	0x004e, 0x003e, 0x00be, 0x001e, 0x000e, 0x0005, 0x9016, 0x710c,
-	0xa834, 0x910a, 0xa936, 0x7008, 0x9005, 0x0120, 0x8210, 0x910a,
-	0x0238, 0x0130, 0x7010, 0x8210, 0x910a, 0x0210, 0x0108, 0x0cd8,
-	0xaa8a, 0xa26a, 0x0005, 0x00f6, 0x00d6, 0x0036, 0x2079, 0x0300,
-	0x781b, 0x0200, 0x7818, 0xd094, 0x1dd8, 0x781b, 0x0202, 0xa001,
-	0xa001, 0x7818, 0xd094, 0x1da0, 0xb8ac, 0x9005, 0x01b8, 0x2068,
-	0x2079, 0x0000, 0x2c08, 0x911e, 0x1118, 0x680c, 0xb8ae, 0x0060,
-	0x9106, 0x0140, 0x2d00, 0x2078, 0x680c, 0x9005, 0x090c, 0x0d7d,
-	0x2068, 0x0cb0, 0x6b0c, 0x7b0e, 0x600f, 0x0000, 0x2079, 0x0300,
-	0x781b, 0x0200, 0x003e, 0x00de, 0x00fe, 0x0005, 0x00e6, 0x00d6,
-	0x0096, 0x00c6, 0x0036, 0x0126, 0x2091, 0x8000, 0x0156, 0x20a9,
-	0x01ff, 0x2071, 0x0300, 0x701b, 0x0200, 0x7018, 0xd094, 0x0110,
-	0x1f04, 0x8f23, 0x701b, 0x0202, 0xa001, 0xa001, 0x7018, 0xd094,
-	0x1d90, 0xb8ac, 0x9005, 0x01d0, 0x2060, 0x600c, 0xb8ae, 0x6003,
-	0x0004, 0x601b, 0x0000, 0x6013, 0x0000, 0x601f, 0x0101, 0x6014,
-	0x2048, 0xa88b, 0x0000, 0xa8a8, 0xa8ab, 0x0000, 0x904d, 0x090c,
-	0x0d7d, 0x080c, 0x106c, 0x080c, 0x8ade, 0x0c18, 0x2071, 0x0300,
-	0x701b, 0x0200, 0x015e, 0x012e, 0x003e, 0x00ce, 0x009e, 0x00de,
-	0x00ee, 0x0005, 0x00c6, 0x00b6, 0x0016, 0x0006, 0x0156, 0x080c,
-	0x2614, 0x015e, 0x11b0, 0x080c, 0x65bf, 0x190c, 0x0d7d, 0x000e,
-	0x001e, 0xb912, 0xb816, 0x080c, 0xab89, 0x0140, 0x2b00, 0x6012,
-	0x6023, 0x0001, 0x2009, 0x0001, 0x080c, 0xac7c, 0x00be, 0x00ce,
-	0x0005, 0x000e, 0x001e, 0x0cd0, 0x0066, 0x6000, 0x90b2, 0x0016,
-	0x1a0c, 0x0d7d, 0x0013, 0x006e, 0x0005, 0x8f95, 0x8f95, 0x8f95,
-	0x8f97, 0x8fe0, 0x8f95, 0x8f95, 0x8f95, 0x9043, 0x8f95, 0x907b,
-	0x8f95, 0x8f95, 0x8f95, 0x8f95, 0x8f95, 0x080c, 0x0d7d, 0x9182,
-	0x0040, 0x0002, 0x8faa, 0x8faa, 0x8faa, 0x8faa, 0x8faa, 0x8faa,
-	0x8faa, 0x8faa, 0x8faa, 0x8fac, 0x8fbd, 0x8faa, 0x8faa, 0x8faa,
-	0x8faa, 0x8fce, 0x080c, 0x0d7d, 0x0096, 0x6114, 0x2148, 0xa87b,
-	0x0000, 0x6010, 0x00b6, 0x2058, 0xb8bb, 0x0500, 0x00be, 0x080c,
-	0x6b7b, 0x080c, 0xabdf, 0x009e, 0x0005, 0x080c, 0x9621, 0x00d6,
-	0x6114, 0x080c, 0xc832, 0x0130, 0x0096, 0x6114, 0x2148, 0x080c,
-	0x6d7b, 0x009e, 0x00de, 0x080c, 0xabdf, 0x0005, 0x080c, 0x9621,
-	0x080c, 0x31ef, 0x6114, 0x0096, 0x2148, 0x080c, 0xc832, 0x0120,
-	0xa87b, 0x0029, 0x080c, 0x6d7b, 0x009e, 0x080c, 0xabdf, 0x0005,
-	0x601b, 0x0000, 0x9182, 0x0040, 0x0096, 0x0002, 0x8ffb, 0x8ffb,
-	0x8ffb, 0x8ffb, 0x8ffb, 0x8ffb, 0x8ffb, 0x8ffb, 0x8ffd, 0x8ffb,
-	0x8ffb, 0x8ffb, 0x903f, 0x8ffb, 0x8ffb, 0x8ffb, 0x8ffb, 0x8ffb,
-	0x8ffb, 0x9003, 0x8ffb, 0x080c, 0x0d7d, 0x6114, 0x2148, 0xa938,
-	0x918e, 0xffff, 0x05e0, 0x00e6, 0x6114, 0x2148, 0x080c, 0x8db4,
-	0x0096, 0xa8a8, 0x2048, 0x080c, 0x6b13, 0x009e, 0xa8ab, 0x0000,
-	0x6010, 0x9005, 0x0128, 0x00b6, 0x2058, 0x080c, 0x8ee3, 0x00be,
-	0xae88, 0x00b6, 0x2059, 0x0000, 0x080c, 0x8ae7, 0x00be, 0x01e0,
-	0x2071, 0x193c, 0x080c, 0x8b2e, 0x01b8, 0x9086, 0x0001, 0x1128,
-	0x2001, 0x1946, 0x2004, 0x9005, 0x1178, 0x0096, 0x080c, 0x103a,
-	0x2900, 0x009e, 0x0148, 0xa8aa, 0x00f6, 0x2c78, 0x080c, 0x8aa5,
-	0x00fe, 0x00ee, 0x009e, 0x0005, 0x080c, 0x8ade, 0x0cd0, 0x080c,
-	0x90f7, 0x009e, 0x0005, 0x9182, 0x0040, 0x0096, 0x0002, 0x9057,
-	0x9057, 0x9057, 0x9059, 0x9057, 0x9057, 0x9057, 0x9079, 0x9057,
-	0x9057, 0x9057, 0x9057, 0x9057, 0x9057, 0x9057, 0x9057, 0x080c,
-	0x0d7d, 0x6003, 0x0003, 0x6106, 0x6014, 0x2048, 0xa8ac, 0xa836,
-	0xa8b0, 0xa83a, 0xa847, 0x0000, 0xa84b, 0x0000, 0xa884, 0x9092,
-	0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x8013, 0x8213, 0x9210,
-	0x621a, 0x080c, 0x1bc7, 0x2009, 0x8030, 0x080c, 0x9247, 0x009e,
-	0x0005, 0x080c, 0x0d7d, 0x080c, 0x9621, 0x6114, 0x2148, 0xa87b,
-	0x0000, 0x6010, 0x00b6, 0x2058, 0xb8bb, 0x0500, 0x00be, 0x080c,
-	0x6d7b, 0x080c, 0xabdf, 0x009e, 0x0005, 0x080c, 0xa888, 0x6144,
-	0xd1fc, 0x0120, 0xd1ac, 0x1110, 0x6003, 0x0003, 0x6000, 0x908a,
-	0x0016, 0x1a0c, 0x0d7d, 0x0096, 0x0023, 0x009e, 0x080c, 0xa8a4,
-	0x0005, 0x90b1, 0x90b1, 0x90b1, 0x90b3, 0x90c4, 0x90b1, 0x90b1,
-	0x90b1, 0x90b1, 0x90b1, 0x90b1, 0x90b1, 0x90b1, 0x90b1, 0x90b1,
-	0x90b1, 0x080c, 0x0d7d, 0x080c, 0xaa1c, 0x6114, 0x2148, 0xa87b,
-	0x0006, 0x6010, 0x00b6, 0x2058, 0xb8bb, 0x0500, 0x00be, 0x080c,
-	0x6d7b, 0x080c, 0xabdf, 0x0005, 0x0491, 0x0005, 0x080c, 0xa888,
-	0x6000, 0x6144, 0xd1fc, 0x0130, 0xd1ac, 0x1120, 0x6003, 0x0003,
-	0x2009, 0x0003, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0096, 0x0033,
-	0x009e, 0x0106, 0x080c, 0xa8a4, 0x010e, 0x0005, 0x90ee, 0x90ee,
-	0x90ee, 0x90f0, 0x90f7, 0x90ee, 0x90ee, 0x90ee, 0x90ee, 0x90ee,
-	0x90ee, 0x90ee, 0x90ee, 0x90ee, 0x90ee, 0x90ee, 0x080c, 0x0d7d,
-	0x0036, 0x00e6, 0x080c, 0xaa1c, 0x00ee, 0x003e, 0x0005, 0x00f6,
-	0x00e6, 0x601b, 0x0000, 0x6014, 0x2048, 0x6010, 0x9005, 0x0128,
-	0x00b6, 0x2058, 0x080c, 0x8ee3, 0x00be, 0x2071, 0x193c, 0x080c,
-	0x8b2e, 0x0160, 0x2001, 0x187f, 0x2004, 0xa88a, 0x2031, 0x0000,
-	0x2c78, 0x080c, 0x8aa5, 0x00ee, 0x00fe, 0x0005, 0x0096, 0xa88b,
-	0x0000, 0xa8a8, 0x2048, 0x080c, 0x106c, 0x009e, 0xa8ab, 0x0000,
-	0x080c, 0x8ade, 0x0c80, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x187a, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0126, 0x2091, 0x8000, 0x0036, 0x0046,
-	0x20a9, 0x0010, 0x9006, 0x8004, 0x8086, 0x818e, 0x1208, 0x9200,
-	0x1f04, 0x913c, 0x8086, 0x818e, 0x004e, 0x003e, 0x012e, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x0076, 0x0156, 0x20a9, 0x0010, 0x9005,
-	0x01c8, 0x911a, 0x12b8, 0x8213, 0x818d, 0x0228, 0x911a, 0x1220,
-	0x1f04, 0x9153, 0x0028, 0x911a, 0x2308, 0x8210, 0x1f04, 0x9153,
-	0x0006, 0x3200, 0x9084, 0xefff, 0x2080, 0x000e, 0x015e, 0x007e,
-	0x012e, 0x0005, 0x0006, 0x3200, 0x9085, 0x1000, 0x0ca8, 0x0126,
-	0x2091, 0x2800, 0x2079, 0x19e6, 0x012e, 0x00d6, 0x2069, 0x19e6,
-	0x6803, 0x0005, 0x0156, 0x0146, 0x01d6, 0x20e9, 0x0000, 0x2069,
-	0x0200, 0x080c, 0xa67d, 0x04a9, 0x080c, 0xa668, 0x0491, 0x080c,
-	0xa66b, 0x0479, 0x080c, 0xa66e, 0x0461, 0x080c, 0xa671, 0x0449,
-	0x080c, 0xa674, 0x0431, 0x080c, 0xa677, 0x0419, 0x080c, 0xa67a,
-	0x0401, 0x01de, 0x014e, 0x015e, 0x6857, 0x0000, 0x00f6, 0x2079,
-	0x0380, 0x00f9, 0x7807, 0x0003, 0x7803, 0x0000, 0x7803, 0x0001,
-	0x2069, 0x0004, 0x2d04, 0x9084, 0xfffe, 0x9085, 0x8000, 0x206a,
-	0x2069, 0x0100, 0x6828, 0x9084, 0xfffc, 0x682a, 0x00fe, 0x00de,
-	0x0005, 0x20a9, 0x0020, 0x20a1, 0x0240, 0x2001, 0x0000, 0x4004,
-	0x0005, 0x00c6, 0x7803, 0x0000, 0x9006, 0x7827, 0x0030, 0x782b,
-	0x0400, 0x7827, 0x0031, 0x782b, 0x1aee, 0x781f, 0xff00, 0x781b,
-	0xff00, 0x2061, 0x1ae3, 0x602f, 0x19e6, 0x6033, 0x1800, 0x6037,
-	0x1a02, 0x603b, 0x1e62, 0x603f, 0x1e72, 0x6042, 0x6047, 0x1ab9,
-	0x00ce, 0x0005, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007, 0x9086,
-	0x0001, 0x01b0, 0x00c6, 0x6146, 0x600f, 0x0000, 0x2c08, 0x2061,
-	0x19e6, 0x602c, 0x8000, 0x602e, 0x601c, 0x9005, 0x0130, 0x9080,
-	0x0003, 0x2102, 0x611e, 0x00ce, 0x0005, 0x6122, 0x611e, 0x0cd8,
-	0x6146, 0x2c08, 0x2001, 0x0012, 0x080c, 0xa879, 0x0005, 0x0016,
-	0x2009, 0x8020, 0x6146, 0x2c08, 0x2001, 0x0382, 0x2004, 0x9084,
-	0x0007, 0x9086, 0x0001, 0x1128, 0x2001, 0x0019, 0x080c, 0xa879,
-	0x0088, 0x00c6, 0x2061, 0x19e6, 0x602c, 0x8000, 0x602e, 0x600c,
-	0x9005, 0x0128, 0x9080, 0x0003, 0x2102, 0x610e, 0x0010, 0x6112,
-	0x610e, 0x00ce, 0x001e, 0x0005, 0x2001, 0x0382, 0x2004, 0x9084,
-	0x0007, 0x9086, 0x0001, 0x0198, 0x00c6, 0x6146, 0x600f, 0x0000,
-	0x2c08, 0x2061, 0x19e6, 0x6044, 0x9005, 0x0130, 0x9080, 0x0003,
-	0x2102, 0x6146, 0x00ce, 0x0005, 0x614a, 0x6146, 0x0cd8, 0x6146,
-	0x600f, 0x0000, 0x2c08, 0x2001, 0x0013, 0x080c, 0xa879, 0x0005,
-	0x6044, 0xd0dc, 0x0110, 0x080c, 0xa31a, 0x0005, 0x00f6, 0x00e6,
-	0x00d6, 0x00c6, 0x00b6, 0x0096, 0x0076, 0x0066, 0x0056, 0x0036,
-	0x0026, 0x0016, 0x0006, 0x0126, 0x902e, 0x2071, 0x19e6, 0x7648,
-	0x2660, 0x2678, 0x2091, 0x8000, 0x8cff, 0x0904, 0x92d3, 0x6010,
-	0x2058, 0xb8a0, 0x9206, 0x1904, 0x92ce, 0x87ff, 0x0120, 0x605c,
-	0x9106, 0x1904, 0x92ce, 0x704c, 0x9c06, 0x1178, 0x0036, 0x2019,
-	0x0001, 0x080c, 0xa0fa, 0x703f, 0x0000, 0x9006, 0x704e, 0x706a,
-	0x7052, 0x706e, 0x003e, 0x2029, 0x0001, 0x0811, 0x7048, 0x9c36,
-	0x1110, 0x660c, 0x764a, 0x7044, 0x9c36, 0x1140, 0x2c00, 0x9f36,
-	0x0118, 0x2f00, 0x7046, 0x0010, 0x7047, 0x0000, 0x660c, 0x0066,
-	0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000,
-	0x080c, 0xc832, 0x01f0, 0x6014, 0x2048, 0x6020, 0x9086, 0x0003,
-	0x1588, 0x6004, 0x9086, 0x0040, 0x090c, 0xa31a, 0xa867, 0x0103,
-	0xab7a, 0xa877, 0x0000, 0x0016, 0x0036, 0x0076, 0x080c, 0xcb35,
-	0x080c, 0xe631, 0x080c, 0x6d7b, 0x007e, 0x003e, 0x001e, 0x080c,
-	0xca21, 0x080c, 0xac1a, 0x00ce, 0x0804, 0x926c, 0x2c78, 0x600c,
-	0x2060, 0x0804, 0x926c, 0x012e, 0x000e, 0x001e, 0x002e, 0x003e,
-	0x005e, 0x006e, 0x007e, 0x009e, 0x00be, 0x00ce, 0x00de, 0x00ee,
-	0x00fe, 0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016, 0x0036,
-	0x0076, 0x080c, 0xe631, 0x080c, 0xe27c, 0x007e, 0x003e, 0x001e,
-	0x08c0, 0x6020, 0x9086, 0x0009, 0x1168, 0xa87b, 0x0006, 0x0016,
-	0x0036, 0x0076, 0x080c, 0x6d7b, 0x080c, 0xabdf, 0x007e, 0x003e,
-	0x001e, 0x0848, 0x6020, 0x9086, 0x000a, 0x0904, 0x92b8, 0x0804,
-	0x92b1, 0x0006, 0x0066, 0x0096, 0x00c6, 0x00d6, 0x00f6, 0x9036,
-	0x0126, 0x2091, 0x8000, 0x2079, 0x19e6, 0x7848, 0x9065, 0x0904,
-	0x936d, 0x600c, 0x0006, 0x600f, 0x0000, 0x784c, 0x9c06, 0x11a0,
-	0x0036, 0x2019, 0x0001, 0x080c, 0xa0fa, 0x783f, 0x0000, 0x901e,
-	0x7b4e, 0x7b6a, 0x7b52, 0x7b6e, 0x003e, 0x000e, 0x9005, 0x1118,
-	0x600c, 0x600f, 0x0000, 0x0006, 0x00e6, 0x2f70, 0x080c, 0x9250,
-	0x00ee, 0x080c, 0xc832, 0x0548, 0x6014, 0x2048, 0x6020, 0x9086,
-	0x0003, 0x15a8, 0x3e08, 0x918e, 0x0002, 0x1188, 0x6010, 0x9005,
-	0x0170, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140, 0x6048,
-	0x9005, 0x11c0, 0x2001, 0x1987, 0x2004, 0x604a, 0x0098, 0x6004,
-	0x9086, 0x0040, 0x090c, 0xa31a, 0xa867, 0x0103, 0xab7a, 0xa877,
-	0x0000, 0x080c, 0x6d6f, 0x080c, 0xca21, 0x6044, 0xc0fc, 0x6046,
-	0x080c, 0xac1a, 0x000e, 0x0804, 0x9316, 0x7e4a, 0x7e46, 0x012e,
-	0x00fe, 0x00de, 0x00ce, 0x009e, 0x006e, 0x000e, 0x0005, 0x6020,
-	0x9086, 0x0006, 0x1118, 0x080c, 0xe27c, 0x0c38, 0x6020, 0x9086,
-	0x0009, 0x1130, 0xab7a, 0x080c, 0x6d7b, 0x080c, 0xabdf, 0x0c10,
-	0x6020, 0x9086, 0x000a, 0x0990, 0x0850, 0x0016, 0x0026, 0x0086,
-	0x9046, 0x00a9, 0x080c, 0x947e, 0x008e, 0x002e, 0x001e, 0x0005,
-	0x00f6, 0x0126, 0x2079, 0x19e6, 0x2091, 0x8000, 0x080c, 0x94c7,
-	0x080c, 0x955b, 0x080c, 0x67ad, 0x012e, 0x00fe, 0x0005, 0x00b6,
-	0x0096, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0016, 0x0006,
-	0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7620, 0x2660, 0x2678,
-	0x8cff, 0x0904, 0x9443, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904,
-	0x943e, 0x88ff, 0x0120, 0x605c, 0x9106, 0x1904, 0x943e, 0x7030,
-	0x9c06, 0x1570, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508, 0x080c,
-	0x86d5, 0x080c, 0x9e16, 0x68c3, 0x0000, 0x080c, 0xa31a, 0x7033,
-	0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
-	0x2001, 0x0100, 0x080c, 0x2a29, 0x9006, 0x080c, 0x2a29, 0x2069,
-	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x0040,
-	0x7008, 0xc0ad, 0x700a, 0x6003, 0x0009, 0x630a, 0x0804, 0x943e,
-	0x7020, 0x9c36, 0x1110, 0x660c, 0x7622, 0x701c, 0x9c36, 0x1140,
-	0x2c00, 0x9f36, 0x0118, 0x2f00, 0x701e, 0x0010, 0x701f, 0x0000,
-	0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678,
-	0x600f, 0x0000, 0x6044, 0xc0fc, 0x6046, 0x6014, 0x2048, 0x080c,
-	0xc832, 0x01e8, 0x6020, 0x9086, 0x0003, 0x1580, 0x080c, 0xca47,
-	0x1118, 0x080c, 0xb5a6, 0x0098, 0xa867, 0x0103, 0xab7a, 0xa877,
-	0x0000, 0x0016, 0x0036, 0x0086, 0x080c, 0xcb35, 0x080c, 0xe631,
-	0x080c, 0x6d7b, 0x008e, 0x003e, 0x001e, 0x080c, 0xca21, 0x080c,
-	0xac1a, 0x080c, 0xa1f0, 0x00ce, 0x0804, 0x93b8, 0x2c78, 0x600c,
-	0x2060, 0x0804, 0x93b8, 0x012e, 0x000e, 0x001e, 0x006e, 0x00ce,
-	0x00de, 0x00ee, 0x00fe, 0x009e, 0x00be, 0x0005, 0x6020, 0x9086,
-	0x0006, 0x1158, 0x0016, 0x0036, 0x0086, 0x080c, 0xe631, 0x080c,
-	0xe27c, 0x008e, 0x003e, 0x001e, 0x08d0, 0x080c, 0xb5a6, 0x6020,
-	0x9086, 0x0002, 0x1160, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e,
-	0x0904, 0x9424, 0x9086, 0x008b, 0x0904, 0x9424, 0x0840, 0x6020,
-	0x9086, 0x0005, 0x1920, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e,
-	0x09c8, 0x9086, 0x008b, 0x09b0, 0x0804, 0x9437, 0x0006, 0x00f6,
-	0x00e6, 0x0096, 0x00b6, 0x00c6, 0x0066, 0x0016, 0x0126, 0x2091,
-	0x8000, 0x9280, 0x1000, 0x2004, 0x905d, 0x2079, 0x19e6, 0x9036,
-	0x7828, 0x2060, 0x8cff, 0x0538, 0x6010, 0x9b06, 0x1500, 0x6043,
-	0xffff, 0x080c, 0xaa67, 0x01d8, 0x610c, 0x0016, 0x080c, 0x9f84,
-	0x6014, 0x2048, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x0016,
-	0x0036, 0x0086, 0x080c, 0xcb35, 0x080c, 0xe631, 0x080c, 0x6d7b,
-	0x008e, 0x003e, 0x001e, 0x080c, 0xac1a, 0x00ce, 0x08d8, 0x2c30,
-	0x600c, 0x2060, 0x08b8, 0x080c, 0x67ca, 0x012e, 0x001e, 0x006e,
-	0x00ce, 0x00be, 0x009e, 0x00ee, 0x00fe, 0x000e, 0x0005, 0x0096,
-	0x0006, 0x0066, 0x00c6, 0x00d6, 0x9036, 0x7820, 0x9065, 0x0904,
-	0x952e, 0x600c, 0x0006, 0x6044, 0xc0fc, 0x6046, 0x600f, 0x0000,
-	0x7830, 0x9c06, 0x1588, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508,
-	0x080c, 0x86d5, 0x080c, 0x9e16, 0x68c3, 0x0000, 0x080c, 0xa31a,
-	0x7833, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000,
-	0x0138, 0x2001, 0x0100, 0x080c, 0x2a29, 0x9006, 0x080c, 0x2a29,
+	0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061,
+	0x0100, 0x2071, 0x1800, 0x6020, 0x9084, 0x00c0, 0x01e8, 0x080c,
+	0xa899, 0x2011, 0x0003, 0x080c, 0xa1be, 0x2011, 0x0002, 0x080c,
+	0xa1c8, 0x080c, 0xa0b3, 0x901e, 0x080c, 0xa133, 0x080c, 0xa8b5,
+	0x2069, 0x0140, 0x2001, 0x00a0, 0x080c, 0x2a49, 0x080c, 0x77ef,
+	0x080c, 0x6044, 0x0804, 0x776b, 0x2001, 0x180c, 0x200c, 0xd1b4,
+	0x1160, 0xc1b5, 0x2102, 0x080c, 0x734a, 0x2069, 0x0140, 0x2001,
+	0x0080, 0x080c, 0x2a49, 0x60e3, 0x0000, 0x2069, 0x0200, 0x6804,
+	0x9005, 0x1118, 0x6808, 0x9005, 0x0190, 0x6028, 0x9084, 0xfdff,
+	0x602a, 0x2011, 0x0200, 0x080c, 0x2a83, 0x2069, 0x198e, 0x7000,
+	0x206a, 0x709b, 0x0027, 0x7003, 0x0001, 0x0804, 0x776b, 0x2011,
+	0x1e00, 0x080c, 0x2a83, 0x2009, 0x1e00, 0x080c, 0x2a2f, 0x6024,
+	0x910c, 0x01c8, 0x9084, 0x1c00, 0x11b0, 0x1d04, 0x7727, 0x0006,
+	0x0016, 0x00c6, 0x00d6, 0x00e6, 0x080c, 0x85a5, 0x00ee, 0x00de,
+	0x00ce, 0x001e, 0x000e, 0x00e6, 0x2071, 0x1a02, 0x7070, 0x00ee,
+	0x9005, 0x19e8, 0x0400, 0x0026, 0x2011, 0x7362, 0x080c, 0x8651,
+	0x2011, 0x7355, 0x080c, 0x875d, 0x002e, 0x2069, 0x0140, 0x60e3,
+	0x0000, 0x70b4, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886,
+	0x2001, 0x196c, 0x2004, 0x080c, 0x26a4, 0x60e2, 0x2001, 0x180c,
+	0x200c, 0xc1b4, 0x2102, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e,
+	0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x0046,
+	0x00c6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x080c, 0xcf7d,
+	0x1904, 0x77d9, 0x7130, 0xd184, 0x1170, 0x080c, 0x337c, 0x0138,
+	0xc18d, 0x7132, 0x2011, 0x1848, 0x2214, 0xd2ac, 0x1120, 0x7030,
+	0xd08c, 0x0904, 0x77d9, 0x2011, 0x1848, 0x220c, 0xd1a4, 0x0538,
+	0x0016, 0x2019, 0x000e, 0x080c, 0xe286, 0x0156, 0x00b6, 0x20a9,
+	0x007f, 0x900e, 0x9186, 0x007e, 0x01a0, 0x9186, 0x0080, 0x0188,
+	0x080c, 0x6644, 0x1170, 0x2120, 0x9006, 0x0016, 0x2009, 0x000e,
+	0x080c, 0xe316, 0x2009, 0x0001, 0x2011, 0x0100, 0x080c, 0x8902,
+	0x001e, 0x8108, 0x1f04, 0x77a2, 0x00be, 0x015e, 0x001e, 0xd1ac,
+	0x1148, 0x0016, 0x2009, 0x0002, 0x2019, 0x0004, 0x080c, 0x31d4,
+	0x001e, 0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c,
+	0x6644, 0x1110, 0x080c, 0x605e, 0x8108, 0x1f04, 0x77cf, 0x00be,
+	0x015e, 0x080c, 0x1b04, 0x080c, 0xa899, 0x080c, 0xab61, 0x080c,
+	0xa8b5, 0x60e3, 0x0000, 0x080c, 0x6044, 0x080c, 0x741d, 0x00ee,
+	0x00ce, 0x004e, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x2001,
+	0x197c, 0x2003, 0x0001, 0x0005, 0x2001, 0x197c, 0x2003, 0x0000,
+	0x0005, 0x2001, 0x197b, 0x2003, 0xaaaa, 0x0005, 0x2001, 0x197b,
+	0x2003, 0x0000, 0x0005, 0x2071, 0x18fa, 0x7003, 0x0000, 0x7007,
+	0x0000, 0x080c, 0x1060, 0x090c, 0x0d7d, 0xa8ab, 0xdcb0, 0x2900,
+	0x704e, 0x080c, 0x1060, 0x090c, 0x0d7d, 0xa8ab, 0xdcb0, 0x2900,
+	0x7052, 0xa867, 0x0000, 0xa86b, 0x0001, 0xa89f, 0x0000, 0x0005,
+	0x00e6, 0x2071, 0x0040, 0x6848, 0x9005, 0x1118, 0x9085, 0x0001,
+	0x04b0, 0x6840, 0x9005, 0x0150, 0x04a1, 0x6a50, 0x9200, 0x7002,
+	0x6854, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6850, 0x7002,
+	0x6854, 0x7006, 0x6858, 0x700a, 0x685c, 0x700e, 0x6840, 0x9005,
+	0x1110, 0x7012, 0x7016, 0x6848, 0x701a, 0x701c, 0x9085, 0x0040,
+	0x701e, 0x2001, 0x0019, 0x7036, 0x702b, 0x0001, 0x2001, 0x0004,
+	0x200c, 0x918c, 0xfff7, 0x918d, 0x8000, 0x2102, 0x00d6, 0x2069,
+	0x18fa, 0x6807, 0x0001, 0x00de, 0x080c, 0x7de7, 0x9006, 0x00ee,
+	0x0005, 0x900e, 0x0156, 0x20a9, 0x0006, 0x8003, 0x818d, 0x1f04,
+	0x7865, 0x015e, 0x0005, 0x2079, 0x0040, 0x2071, 0x18fa, 0x7004,
+	0x0002, 0x787b, 0x787c, 0x78c8, 0x7923, 0x7a33, 0x7879, 0x7879,
+	0x7a5d, 0x080c, 0x0d7d, 0x0005, 0x2079, 0x0040, 0x2001, 0x1dc0,
+	0x2003, 0x0000, 0x782c, 0x908c, 0x0780, 0x190c, 0x7ec9, 0xd0a4,
+	0x0578, 0x2001, 0x1dc0, 0x2004, 0x9082, 0x0080, 0x1648, 0x1d04,
+	0x7899, 0x2001, 0x1a05, 0x200c, 0x8109, 0x0510, 0x2091, 0x6000,
+	0x2102, 0x7824, 0x2048, 0x9006, 0xa802, 0xa806, 0xa864, 0x9084,
+	0x00ff, 0x908a, 0x0040, 0x0610, 0x00c0, 0x2001, 0x1800, 0x200c,
+	0x9186, 0x0003, 0x1168, 0x7004, 0x0002, 0x78b8, 0x7882, 0x78b8,
+	0x78b6, 0x78b8, 0x78b8, 0x78b8, 0x78b8, 0x78b8, 0x080c, 0x7923,
+	0x782c, 0xd09c, 0x090c, 0x7de7, 0x0005, 0x9082, 0x005a, 0x1218,
+	0x2100, 0x003b, 0x0c10, 0x080c, 0x7959, 0x0c90, 0x00e3, 0x08e8,
+	0x0005, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959,
+	0x7959, 0x797b, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959,
+	0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959,
+	0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7965, 0x7959, 0x7b4e,
+	0x7959, 0x7959, 0x7959, 0x797b, 0x7959, 0x7965, 0x7b8f, 0x7bd0,
+	0x7c17, 0x7c2b, 0x7959, 0x7959, 0x797b, 0x7965, 0x798f, 0x7959,
+	0x7a07, 0x7cd6, 0x7cf1, 0x7959, 0x797b, 0x7959, 0x798f, 0x7959,
+	0x7959, 0x79fd, 0x7cf1, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959,
+	0x7959, 0x7959, 0x7959, 0x7959, 0x79a3, 0x7959, 0x7959, 0x7959,
+	0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7959, 0x7e6d, 0x7959,
+	0x7e17, 0x7959, 0x7e17, 0x7959, 0x79b8, 0x7959, 0x7959, 0x7959,
+	0x7959, 0x7959, 0x7959, 0x2079, 0x0040, 0x7004, 0x9086, 0x0003,
+	0x1198, 0x782c, 0x080c, 0x7e10, 0xd0a4, 0x0170, 0x7824, 0x2048,
+	0x9006, 0xa802, 0xa806, 0xa864, 0x9084, 0x00ff, 0x908a, 0x001a,
+	0x1210, 0x002b, 0x0c50, 0x00e9, 0x080c, 0x7de7, 0x0005, 0x7959,
+	0x7965, 0x7b3a, 0x7959, 0x7965, 0x7959, 0x7965, 0x7965, 0x7959,
+	0x7965, 0x7b3a, 0x7965, 0x7965, 0x7965, 0x7965, 0x7965, 0x7959,
+	0x7965, 0x7b3a, 0x7959, 0x7959, 0x7965, 0x7959, 0x7959, 0x7959,
+	0x7965, 0x00e6, 0x2071, 0x18fa, 0x2009, 0x0400, 0x0071, 0x00ee,
+	0x0005, 0x2009, 0x1000, 0x0049, 0x0005, 0x2009, 0x2000, 0x0029,
+	0x0005, 0x2009, 0x0800, 0x0009, 0x0005, 0x7007, 0x0001, 0xa868,
+	0x9084, 0x00ff, 0x9105, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x6d9f, 0x012e, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0d08,
+	0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x7adc, 0x7007, 0x0003,
+	0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x7adc, 0x0005, 0xa864,
+	0x8007, 0x9084, 0x00ff, 0x0968, 0x8001, 0x1120, 0x7007, 0x0001,
+	0x0804, 0x7af7, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a,
+	0x704b, 0x7af7, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0904,
+	0x7961, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x7b13, 0x7007,
+	0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x7b13, 0x0005,
+	0xa864, 0x8007, 0x9084, 0x00ff, 0x9086, 0x0001, 0x1904, 0x7961,
+	0x7007, 0x0001, 0x2009, 0x1834, 0x210c, 0x81ff, 0x11a8, 0xa868,
+	0x9084, 0x00ff, 0xa86a, 0xa883, 0x0000, 0x080c, 0x62d4, 0x1108,
+	0x0005, 0x0126, 0x2091, 0x8000, 0xa867, 0x0139, 0xa87a, 0xa982,
+	0x080c, 0x6d9f, 0x012e, 0x0ca0, 0xa994, 0x9186, 0x0071, 0x0d38,
+	0x9186, 0x0064, 0x0d20, 0x9186, 0x007c, 0x0d08, 0x9186, 0x0028,
+	0x09f0, 0x9186, 0x0038, 0x09d8, 0x9186, 0x0078, 0x09c0, 0x9186,
+	0x005f, 0x09a8, 0x9186, 0x0056, 0x0990, 0xa897, 0x4005, 0xa89b,
+	0x0001, 0x2001, 0x0030, 0x900e, 0x08a0, 0xa87c, 0x9084, 0x00c0,
+	0x9086, 0x00c0, 0x1120, 0x7007, 0x0001, 0x0804, 0x7d08, 0x2900,
+	0x7016, 0x701a, 0x20a9, 0x0004, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x0030, 0x2098, 0x7050, 0x2040, 0xa060, 0x20e8, 0xa05c, 0x9080,
+	0x0023, 0x20a0, 0x4003, 0xa888, 0x7012, 0x9082, 0x0401, 0x1a04,
+	0x7969, 0xaab4, 0x928a, 0x0002, 0x1a04, 0x7969, 0x82ff, 0x1138,
+	0xa8b8, 0xa9bc, 0x9105, 0x0118, 0x2001, 0x7a9a, 0x0018, 0x9280,
+	0x7a90, 0x2005, 0x7056, 0x7010, 0x9015, 0x0904, 0x7a7b, 0x080c,
+	0x1060, 0x1118, 0x7007, 0x0004, 0x0005, 0x2900, 0x7022, 0x7054,
+	0x2060, 0xe000, 0xa866, 0x7050, 0x2040, 0xa95c, 0xe004, 0x9100,
+	0xa076, 0xa860, 0xa072, 0xe008, 0x920a, 0x1210, 0x900e, 0x2200,
+	0x7112, 0xe20c, 0x8003, 0x800b, 0x9296, 0x0004, 0x0108, 0x9108,
+	0xa17a, 0x810b, 0xa17e, 0x080c, 0x113c, 0xa06c, 0x908e, 0x0100,
+	0x0170, 0x9086, 0x0200, 0x0118, 0x7007, 0x0007, 0x0005, 0x7020,
+	0x2048, 0x080c, 0x1079, 0x7014, 0x2048, 0x0804, 0x7969, 0x7020,
+	0x2048, 0x7018, 0xa802, 0xa807, 0x0000, 0x2908, 0x2048, 0xa906,
+	0x711a, 0x0804, 0x7a33, 0x7014, 0x2048, 0x7007, 0x0001, 0xa8b4,
+	0x9005, 0x1128, 0xa8b8, 0xa9bc, 0x9105, 0x0108, 0x00b9, 0xa864,
+	0x9084, 0x00ff, 0x9086, 0x001e, 0x0904, 0x7d08, 0x0804, 0x7adc,
+	0x7a92, 0x7a96, 0x0002, 0x001d, 0x0007, 0x0004, 0x000a, 0x001b,
+	0x0005, 0x0006, 0x000a, 0x001d, 0x0005, 0x0004, 0x0076, 0x0066,
+	0xafb8, 0xaebc, 0xa804, 0x2050, 0xb0c0, 0xb0e2, 0xb0bc, 0xb0de,
+	0xb0b8, 0xb0d2, 0xb0b4, 0xb0ce, 0xb6da, 0xb7d6, 0xb0b0, 0xb0ca,
+	0xb0ac, 0xb0c6, 0xb0a8, 0xb0ba, 0xb0a4, 0xb0b6, 0xb6c2, 0xb7be,
+	0xb0a0, 0xb0b2, 0xb09c, 0xb0ae, 0xb098, 0xb0a2, 0xb094, 0xb09e,
+	0xb6aa, 0xb7a6, 0xb090, 0xb09a, 0xb08c, 0xb096, 0xb088, 0xb08a,
+	0xb084, 0xb086, 0xb692, 0xb78e, 0xb080, 0xb082, 0xb07c, 0xb07e,
+	0xb078, 0xb072, 0xb074, 0xb06e, 0xb67a, 0xb776, 0xb004, 0x9055,
+	0x1958, 0x006e, 0x007e, 0x0005, 0x2009, 0x1834, 0x210c, 0x81ff,
+	0x1178, 0x080c, 0x60d6, 0x1108, 0x0005, 0x080c, 0x6fd3, 0x0126,
+	0x2091, 0x8000, 0x080c, 0xcb68, 0x080c, 0x6d9f, 0x012e, 0x0ca0,
+	0x080c, 0xcf7d, 0x1d70, 0x2001, 0x0028, 0x900e, 0x0c70, 0x2009,
+	0x1834, 0x210c, 0x81ff, 0x1188, 0xa888, 0x9005, 0x0188, 0xa883,
+	0x0000, 0x080c, 0x6164, 0x1108, 0x0005, 0xa87a, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x6d9f, 0x012e, 0x0cb8, 0x2001, 0x0028, 0x0ca8,
+	0x2001, 0x0000, 0x0c90, 0x2009, 0x1834, 0x210c, 0x81ff, 0x11d8,
+	0xa888, 0x9005, 0x01e0, 0xa883, 0x0000, 0xa87c, 0xd0f4, 0x0120,
+	0x080c, 0x6236, 0x1138, 0x0005, 0x9006, 0xa87a, 0x080c, 0x61b1,
+	0x1108, 0x0005, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982, 0x080c,
+	0x6d9f, 0x012e, 0x0cb0, 0x2001, 0x0028, 0x900e, 0x0c98, 0x2001,
+	0x0000, 0x0c80, 0x7018, 0xa802, 0x2908, 0x2048, 0xa906, 0x711a,
+	0x7010, 0x8001, 0x7012, 0x0118, 0x7007, 0x0003, 0x0030, 0x7014,
+	0x2048, 0x7007, 0x0001, 0x7048, 0x080f, 0x0005, 0x00b6, 0x7007,
+	0x0001, 0xa974, 0xa878, 0x9084, 0x00ff, 0x9096, 0x0004, 0x0540,
+	0x20a9, 0x0001, 0x9096, 0x0001, 0x0190, 0x900e, 0x20a9, 0x0800,
+	0x9096, 0x0002, 0x0160, 0x9005, 0x11d8, 0xa974, 0x080c, 0x6644,
+	0x11b8, 0x0066, 0xae80, 0x080c, 0x6754, 0x006e, 0x0088, 0x0046,
+	0x2011, 0x180c, 0x2224, 0xc484, 0x2412, 0x004e, 0x00c6, 0x080c,
+	0x6644, 0x1110, 0x080c, 0x6927, 0x8108, 0x1f04, 0x7b77, 0x00ce,
+	0xa87c, 0xd084, 0x1120, 0x080c, 0x1079, 0x00be, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e, 0x00be, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x7007, 0x0001, 0x080c, 0x6a8a, 0x0580, 0x2061,
+	0x1a6e, 0x6100, 0xd184, 0x0178, 0xa888, 0x9084, 0x00ff, 0x1550,
+	0x6000, 0xd084, 0x0520, 0x6004, 0x9005, 0x1538, 0x6003, 0x0000,
+	0x600b, 0x0000, 0x00c8, 0x2011, 0x0001, 0xa890, 0x9005, 0x1110,
+	0x2001, 0x001e, 0x8000, 0x6016, 0xa888, 0x9084, 0x00ff, 0x0178,
+	0x6006, 0xa888, 0x8007, 0x9084, 0x00ff, 0x0148, 0x600a, 0xa888,
+	0x8000, 0x1108, 0xc28d, 0x6202, 0x012e, 0x0804, 0x7dd1, 0x012e,
+	0x0804, 0x7dcb, 0x012e, 0x0804, 0x7dc5, 0x012e, 0x0804, 0x7dc8,
+	0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x080c, 0x6a8a, 0x05e0,
+	0x2061, 0x1a6e, 0x6000, 0xd084, 0x05b8, 0x6204, 0x6308, 0xd08c,
+	0x1530, 0xac78, 0x9484, 0x0003, 0x0170, 0xa988, 0x918c, 0x00ff,
+	0x8001, 0x1120, 0x2100, 0x9210, 0x0620, 0x0028, 0x8001, 0x1508,
+	0x2100, 0x9212, 0x02f0, 0x9484, 0x000c, 0x0188, 0xa988, 0x810f,
+	0x918c, 0x00ff, 0x9082, 0x0004, 0x1120, 0x2100, 0x9318, 0x0288,
+	0x0030, 0x9082, 0x0004, 0x1168, 0x2100, 0x931a, 0x0250, 0xa890,
+	0x9005, 0x0110, 0x8000, 0x6016, 0x6206, 0x630a, 0x012e, 0x0804,
+	0x7dd1, 0x012e, 0x0804, 0x7dce, 0x012e, 0x0804, 0x7dcb, 0x0126,
+	0x2091, 0x8000, 0x7007, 0x0001, 0x2061, 0x1a6e, 0x6300, 0xd38c,
+	0x1120, 0x6308, 0x8318, 0x0220, 0x630a, 0x012e, 0x0804, 0x7ddf,
+	0x012e, 0x0804, 0x7dce, 0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000,
+	0x7007, 0x0001, 0xa87c, 0xd0ac, 0x0148, 0x00c6, 0x2061, 0x1a6e,
+	0x6000, 0x9084, 0xfcff, 0x6002, 0x00ce, 0x0440, 0xa888, 0x9005,
+	0x05d8, 0xa88c, 0x9065, 0x0598, 0x2001, 0x1834, 0x2004, 0x9005,
+	0x0118, 0x080c, 0xac2b, 0x0068, 0x6017, 0xf400, 0x6063, 0x0000,
+	0xa97c, 0xd1a4, 0x0110, 0xa980, 0x6162, 0x2009, 0x0041, 0x080c,
+	0xac8d, 0xa988, 0x918c, 0xff00, 0x9186, 0x2000, 0x1138, 0x0026,
+	0x900e, 0x2011, 0xfdff, 0x080c, 0x8902, 0x002e, 0xa87c, 0xd0c4,
+	0x0148, 0x2061, 0x1a6e, 0x6000, 0xd08c, 0x1120, 0x6008, 0x8000,
+	0x0208, 0x600a, 0x00ce, 0x012e, 0x00be, 0x0804, 0x7dd1, 0x00ce,
+	0x012e, 0x00be, 0x0804, 0x7dcb, 0xa984, 0x9186, 0x002e, 0x0d30,
+	0x9186, 0x002d, 0x0d18, 0x9186, 0x0045, 0x0510, 0x9186, 0x002a,
+	0x1130, 0x2001, 0x180c, 0x200c, 0xc194, 0x2102, 0x08b8, 0x9186,
+	0x0020, 0x0158, 0x9186, 0x0029, 0x1d10, 0xa974, 0x080c, 0x6644,
+	0x1968, 0xb800, 0xc0e4, 0xb802, 0x0848, 0xa88c, 0x9065, 0x09b8,
+	0x6007, 0x0024, 0x2001, 0x1985, 0x2004, 0x601a, 0x0804, 0x7c66,
+	0xa88c, 0x9065, 0x0960, 0x00e6, 0xa890, 0x9075, 0x2001, 0x1834,
+	0x2004, 0x9005, 0x0150, 0x080c, 0xac2b, 0x8eff, 0x0118, 0x2e60,
+	0x080c, 0xac2b, 0x00ee, 0x0804, 0x7c66, 0x6024, 0xc0dc, 0xc0d5,
+	0x6026, 0x2e60, 0x6007, 0x003a, 0xa8a0, 0x9005, 0x0130, 0x6007,
+	0x003b, 0xa8a4, 0x602e, 0xa8a8, 0x6016, 0x6003, 0x0001, 0x2009,
+	0x8020, 0x080c, 0x9239, 0x00ee, 0x0804, 0x7c66, 0x2061, 0x1a6e,
+	0x6000, 0xd084, 0x0190, 0xd08c, 0x1904, 0x7ddf, 0x0126, 0x2091,
+	0x8000, 0x6204, 0x8210, 0x0220, 0x6206, 0x012e, 0x0804, 0x7ddf,
+	0x012e, 0xa883, 0x0016, 0x0804, 0x7dd8, 0xa883, 0x0007, 0x0804,
+	0x7dd8, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0130, 0x8001, 0x1138,
+	0x7007, 0x0001, 0x0069, 0x0005, 0x080c, 0x7961, 0x0040, 0x7007,
+	0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x7d08, 0x0005,
+	0x00b6, 0x00e6, 0x0126, 0x2091, 0x8000, 0x903e, 0x2061, 0x1800,
+	0x61d0, 0x81ff, 0x1904, 0x7d8a, 0x6130, 0xd194, 0x1904, 0x7db4,
+	0xa878, 0x2070, 0x9e82, 0x1ddc, 0x0a04, 0x7d7e, 0x6068, 0x9e02,
+	0x1a04, 0x7d7e, 0x7120, 0x9186, 0x0006, 0x1904, 0x7d70, 0x7010,
+	0x905d, 0x0904, 0x7d8a, 0xb800, 0xd0e4, 0x1904, 0x7dae, 0x2061,
+	0x1a6e, 0x6100, 0x9184, 0x0301, 0x9086, 0x0001, 0x15a0, 0x7024,
+	0xd0dc, 0x1904, 0x7db7, 0xa883, 0x0000, 0xa803, 0x0000, 0x2908,
+	0x7014, 0x9005, 0x1198, 0x7116, 0xa87c, 0xd0f4, 0x1904, 0x7dba,
+	0x080c, 0x56f5, 0xd09c, 0x1118, 0xa87c, 0xc0cc, 0xa87e, 0x2e60,
+	0x080c, 0x87f2, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2048, 0xa800,
+	0x9005, 0x1de0, 0xa902, 0x2148, 0xa87c, 0xd0f4, 0x1904, 0x7dba,
+	0x012e, 0x00ee, 0x00be, 0x0005, 0x012e, 0x00ee, 0xa883, 0x0006,
+	0x00be, 0x0804, 0x7dd8, 0xd184, 0x0db8, 0xd1c4, 0x1190, 0x00a0,
+	0xa974, 0x080c, 0x6644, 0x15d0, 0xb800, 0xd0e4, 0x15b8, 0x7120,
+	0x9186, 0x0007, 0x1118, 0xa883, 0x0002, 0x0490, 0xa883, 0x0008,
+	0x0478, 0xa883, 0x000e, 0x0460, 0xa883, 0x0017, 0x0448, 0xa883,
+	0x0035, 0x0430, 0x080c, 0x56f9, 0xd0fc, 0x01e8, 0xa878, 0x2070,
+	0x9e82, 0x1ddc, 0x02c0, 0x6068, 0x9e02, 0x12a8, 0x7120, 0x9186,
+	0x0006, 0x1188, 0x7010, 0x905d, 0x0170, 0xb800, 0xd0bc, 0x0158,
+	0x2039, 0x0001, 0x7000, 0x9086, 0x0007, 0x1904, 0x7d14, 0x7003,
+	0x0002, 0x0804, 0x7d14, 0xa883, 0x0028, 0x0010, 0xa883, 0x0029,
+	0x012e, 0x00ee, 0x00be, 0x0420, 0xa883, 0x002a, 0x0cc8, 0xa883,
+	0x0045, 0x0cb0, 0x2e60, 0x2019, 0x0002, 0x601b, 0x0014, 0x080c,
+	0xde67, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2009, 0x003e, 0x0058,
+	0x2009, 0x0004, 0x0040, 0x2009, 0x0006, 0x0028, 0x2009, 0x0016,
+	0x0010, 0x2009, 0x0001, 0xa884, 0x9084, 0xff00, 0x9105, 0xa886,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e, 0x0005, 0x080c,
+	0x1079, 0x0005, 0x00d6, 0x080c, 0x87e9, 0x00de, 0x0005, 0x00d6,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x0040, 0x702c, 0xd084,
+	0x01d8, 0x908c, 0x0780, 0x190c, 0x7ec9, 0xd09c, 0x11a8, 0x2071,
+	0x1800, 0x70c0, 0x90ea, 0x0020, 0x0278, 0x8001, 0x70c2, 0x702c,
+	0x2048, 0xa800, 0x702e, 0x9006, 0xa802, 0xa806, 0x2071, 0x0040,
+	0x2900, 0x7022, 0x702c, 0x0c28, 0x012e, 0x00ee, 0x00de, 0x0005,
+	0x0006, 0x9084, 0x0780, 0x190c, 0x7ec9, 0x000e, 0x0005, 0xa898,
+	0x9084, 0x0003, 0x05a8, 0x080c, 0xab9a, 0x05d8, 0x2900, 0x6016,
+	0xa864, 0x9084, 0x00ff, 0x9086, 0x0035, 0x1138, 0x6028, 0xc0fd,
+	0x602a, 0x2001, 0x196a, 0x2004, 0x0098, 0xa8a0, 0x9084, 0x00ff,
+	0xa99c, 0x918c, 0xff00, 0x9105, 0xa99c, 0x918c, 0x00ff, 0x080c,
+	0x2630, 0x1540, 0x00b6, 0x080c, 0x6644, 0x2b00, 0x00be, 0x1510,
+	0x6012, 0x6023, 0x0001, 0x2009, 0x0040, 0xa864, 0x9084, 0x00ff,
+	0x9086, 0x0035, 0x0110, 0x2009, 0x0041, 0x080c, 0xac8d, 0x0005,
+	0xa87b, 0x0101, 0x0126, 0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e,
+	0x0005, 0xa87b, 0x002c, 0x0126, 0x2091, 0x8000, 0x080c, 0x6d9f,
+	0x012e, 0x0005, 0xa87b, 0x0028, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x6d9f, 0x012e, 0x080c, 0xabf0, 0x0005, 0x00d6, 0x00c6, 0x0036,
+	0x0026, 0x0016, 0x00b6, 0x7007, 0x0001, 0xaa74, 0x9282, 0x0004,
+	0x1a04, 0x7eba, 0xa97c, 0x9188, 0x1000, 0x2104, 0x905d, 0xb804,
+	0xd284, 0x0140, 0x05e8, 0x8007, 0x9084, 0x00ff, 0x9084, 0x0006,
+	0x1108, 0x04b0, 0x2b10, 0x080c, 0xab9a, 0x1118, 0x080c, 0xac60,
+	0x05a8, 0x6212, 0xa874, 0x0002, 0x7e98, 0x7e9d, 0x7ea0, 0x7ea6,
+	0x2019, 0x0002, 0x080c, 0xe286, 0x0060, 0x080c, 0xe216, 0x0048,
+	0x2019, 0x0002, 0xa980, 0x080c, 0xe235, 0x0018, 0xa980, 0x080c,
+	0xe216, 0x080c, 0xabf0, 0xa887, 0x0000, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x6d9f, 0x012e, 0x00be, 0x001e, 0x002e, 0x003e, 0x00ce,
+	0x00de, 0x0005, 0xa887, 0x0006, 0x0c80, 0xa887, 0x0002, 0x0c68,
+	0xa887, 0x0005, 0x0c50, 0xa887, 0x0004, 0x0c38, 0xa887, 0x0007,
+	0x0c20, 0x2091, 0x8000, 0x0e04, 0x7ecb, 0x0006, 0x0016, 0x2001,
+	0x8003, 0x0006, 0x0804, 0x0d86, 0x2001, 0x1834, 0x2004, 0x9005,
+	0x0005, 0x0005, 0x00f6, 0x2079, 0x0300, 0x2001, 0x0200, 0x200c,
+	0xc1e5, 0xc1dc, 0x2102, 0x2009, 0x0218, 0x210c, 0xd1ec, 0x1120,
+	0x080c, 0x1622, 0x00fe, 0x0005, 0x2001, 0x020d, 0x2003, 0x0020,
+	0x781f, 0x0300, 0x00fe, 0x0005, 0x781c, 0xd08c, 0x0904, 0x7f4c,
+	0x68c0, 0x90aa, 0x0005, 0x0a04, 0x855d, 0x7d44, 0x7c40, 0xd59c,
+	0x190c, 0x0d7d, 0x9584, 0x00f6, 0x1508, 0x9484, 0x7000, 0x0138,
+	0x908a, 0x2000, 0x1258, 0x9584, 0x0700, 0x8007, 0x04f0, 0x7000,
+	0x9084, 0xff00, 0x9086, 0x8100, 0x0db0, 0x00b0, 0x9484, 0x0fff,
+	0x1130, 0x7000, 0x9084, 0xff00, 0x9086, 0x8100, 0x11c0, 0x080c,
+	0xe727, 0x080c, 0x8444, 0x7817, 0x0140, 0x00a8, 0x9584, 0x0076,
+	0x1118, 0x080c, 0x84a0, 0x19c8, 0xd5a4, 0x0148, 0x0046, 0x0056,
+	0x080c, 0x7f9c, 0x080c, 0x213e, 0x005e, 0x004e, 0x0020, 0x080c,
+	0xe727, 0x7817, 0x0140, 0x080c, 0x74ec, 0x0168, 0x2001, 0x0111,
+	0x2004, 0xd08c, 0x0140, 0x6893, 0x0000, 0x2001, 0x0110, 0x2003,
+	0x0008, 0x2003, 0x0000, 0x0489, 0x0005, 0x0002, 0x7f59, 0x8266,
+	0x7f56, 0x7f56, 0x7f56, 0x7f56, 0x7f56, 0x7f56, 0x7817, 0x0140,
+	0x0005, 0x7000, 0x908c, 0xff00, 0x9194, 0xf000, 0x810f, 0x9484,
+	0x0fff, 0x6892, 0x9286, 0x2000, 0x1150, 0x6800, 0x9086, 0x0001,
+	0x1118, 0x080c, 0x5756, 0x0070, 0x080c, 0x7fbc, 0x0058, 0x9286,
+	0x3000, 0x1118, 0x080c, 0x81a3, 0x0028, 0x9286, 0x8000, 0x1110,
+	0x080c, 0x837a, 0x7817, 0x0140, 0x0005, 0x2001, 0x1810, 0x2004,
+	0xd08c, 0x0178, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x1148,
+	0x0026, 0x0036, 0x2011, 0x8048, 0x2518, 0x080c, 0x4b29, 0x003e,
+	0x002e, 0x0005, 0x0036, 0x0046, 0x0056, 0x00f6, 0x2079, 0x0200,
+	0x2019, 0xfffe, 0x7c30, 0x0050, 0x0036, 0x0046, 0x0056, 0x00f6,
+	0x2079, 0x0200, 0x7d44, 0x7c40, 0x2019, 0xffff, 0x2001, 0x1810,
+	0x2004, 0xd08c, 0x0160, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003,
+	0x1130, 0x0026, 0x2011, 0x8048, 0x080c, 0x4b29, 0x002e, 0x00fe,
+	0x005e, 0x004e, 0x003e, 0x0005, 0x00b6, 0x00c6, 0x7010, 0x9084,
+	0xff00, 0x8007, 0x9096, 0x0001, 0x0120, 0x9096, 0x0023, 0x1904,
+	0x8174, 0x9186, 0x0023, 0x15c0, 0x080c, 0x840f, 0x0904, 0x8174,
+	0x6120, 0x9186, 0x0001, 0x0150, 0x9186, 0x0004, 0x0138, 0x9186,
+	0x0008, 0x0120, 0x9186, 0x000a, 0x1904, 0x8174, 0x7124, 0x610a,
+	0x7030, 0x908e, 0x0200, 0x1130, 0x2009, 0x0015, 0x080c, 0xac8d,
+	0x0804, 0x8174, 0x908e, 0x0214, 0x0118, 0x908e, 0x0210, 0x1130,
+	0x2009, 0x0015, 0x080c, 0xac8d, 0x0804, 0x8174, 0x908e, 0x0100,
+	0x1904, 0x8174, 0x7034, 0x9005, 0x1904, 0x8174, 0x2009, 0x0016,
+	0x080c, 0xac8d, 0x0804, 0x8174, 0x9186, 0x0022, 0x1904, 0x8174,
+	0x7030, 0x908e, 0x0300, 0x1580, 0x68dc, 0xd0a4, 0x0528, 0xc0b5,
+	0x68de, 0x7100, 0x918c, 0x00ff, 0x697e, 0x7004, 0x6882, 0x00f6,
+	0x2079, 0x0100, 0x79e6, 0x78ea, 0x0006, 0x9084, 0x00ff, 0x0016,
+	0x2008, 0x080c, 0x2679, 0x7932, 0x7936, 0x001e, 0x000e, 0x00fe,
+	0x080c, 0x2630, 0x695e, 0x703c, 0x00e6, 0x2071, 0x0140, 0x7086,
+	0x2071, 0x1800, 0x70b6, 0x00ee, 0x7034, 0x9005, 0x1904, 0x8174,
+	0x2009, 0x0017, 0x0804, 0x8124, 0x908e, 0x0400, 0x1190, 0x7034,
+	0x9005, 0x1904, 0x8174, 0x080c, 0x74ec, 0x0120, 0x2009, 0x001d,
+	0x0804, 0x8124, 0x68dc, 0xc0a5, 0x68de, 0x2009, 0x0030, 0x0804,
+	0x8124, 0x908e, 0x0500, 0x1140, 0x7034, 0x9005, 0x1904, 0x8174,
+	0x2009, 0x0018, 0x0804, 0x8124, 0x908e, 0x2010, 0x1120, 0x2009,
+	0x0019, 0x0804, 0x8124, 0x908e, 0x2110, 0x1120, 0x2009, 0x001a,
+	0x0804, 0x8124, 0x908e, 0x5200, 0x1140, 0x7034, 0x9005, 0x1904,
+	0x8174, 0x2009, 0x001b, 0x0804, 0x8124, 0x908e, 0x5000, 0x1140,
+	0x7034, 0x9005, 0x1904, 0x8174, 0x2009, 0x001c, 0x0804, 0x8124,
+	0x908e, 0x1300, 0x1120, 0x2009, 0x0034, 0x0804, 0x8124, 0x908e,
+	0x1200, 0x1140, 0x7034, 0x9005, 0x1904, 0x8174, 0x2009, 0x0024,
+	0x0804, 0x8124, 0x908c, 0xff00, 0x918e, 0x2400, 0x1170, 0x2009,
+	0x002d, 0x2001, 0x1810, 0x2004, 0xd09c, 0x0904, 0x8124, 0x080c,
+	0xd68f, 0x1904, 0x8174, 0x0804, 0x8122, 0x908c, 0xff00, 0x918e,
+	0x5300, 0x1120, 0x2009, 0x002a, 0x0804, 0x8124, 0x908e, 0x0f00,
+	0x1120, 0x2009, 0x0020, 0x0804, 0x8124, 0x908e, 0x6104, 0x1530,
+	0x2029, 0x0205, 0x2011, 0x026d, 0x8208, 0x2204, 0x9082, 0x0004,
+	0x8004, 0x8004, 0x20a8, 0x2011, 0x8015, 0x211c, 0x8108, 0x0046,
+	0x2124, 0x080c, 0x4b29, 0x004e, 0x8108, 0x0f04, 0x80d8, 0x9186,
+	0x0280, 0x1d88, 0x2504, 0x8000, 0x202a, 0x2009, 0x0260, 0x0c58,
+	0x202b, 0x0000, 0x2009, 0x0023, 0x0804, 0x8124, 0x908e, 0x6000,
+	0x1120, 0x2009, 0x003f, 0x0804, 0x8124, 0x908e, 0x5400, 0x1138,
+	0x080c, 0x850d, 0x1904, 0x8174, 0x2009, 0x0046, 0x04a8, 0x908e,
+	0x5500, 0x1148, 0x080c, 0x8535, 0x1118, 0x2009, 0x0041, 0x0460,
+	0x2009, 0x0042, 0x0448, 0x908e, 0x7800, 0x1118, 0x2009, 0x0045,
+	0x0418, 0x908e, 0x1000, 0x1118, 0x2009, 0x004e, 0x00e8, 0x908e,
+	0x6300, 0x1118, 0x2009, 0x004a, 0x00b8, 0x908c, 0xff00, 0x918e,
+	0x5600, 0x1118, 0x2009, 0x004f, 0x0078, 0x908c, 0xff00, 0x918e,
+	0x5700, 0x1118, 0x2009, 0x0050, 0x0038, 0x2009, 0x001d, 0x6838,
+	0xd0d4, 0x0110, 0x2009, 0x004c, 0x0016, 0x2011, 0x0263, 0x2204,
+	0x8211, 0x220c, 0x080c, 0x2630, 0x1904, 0x8177, 0x080c, 0x65e3,
+	0x1904, 0x8177, 0xbe12, 0xbd16, 0x001e, 0x0016, 0x080c, 0x74ec,
+	0x01c0, 0x68dc, 0xd08c, 0x1148, 0x7000, 0x9084, 0x00ff, 0x1188,
+	0x7004, 0x9084, 0xff00, 0x1168, 0x0040, 0x687c, 0x9606, 0x1148,
+	0x6880, 0x9506, 0x9084, 0xff00, 0x1120, 0x9584, 0x00ff, 0xb886,
+	0x0080, 0xb884, 0x9005, 0x1168, 0x9186, 0x0046, 0x1150, 0x687c,
+	0x9606, 0x1138, 0x6880, 0x9506, 0x9084, 0xff00, 0x1110, 0x001e,
+	0x0098, 0x080c, 0xab9a, 0x01a8, 0x2b08, 0x6112, 0x6023, 0x0004,
+	0x7120, 0x610a, 0x001e, 0x9186, 0x004c, 0x1110, 0x6023, 0x000a,
+	0x0016, 0x001e, 0x080c, 0xac8d, 0x00ce, 0x00be, 0x0005, 0x001e,
+	0x0cd8, 0x2001, 0x180e, 0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049,
+	0x080c, 0x4b29, 0x080c, 0xac60, 0x0d90, 0x2b08, 0x6112, 0x6023,
+	0x0004, 0x7120, 0x610a, 0x001e, 0x0016, 0x9186, 0x0017, 0x0118,
+	0x9186, 0x0030, 0x1128, 0x6007, 0x0009, 0x6017, 0x2900, 0x0020,
+	0x6007, 0x0051, 0x6017, 0x0000, 0x602f, 0x0009, 0x6003, 0x0001,
+	0x080c, 0x9240, 0x08a0, 0x080c, 0x3346, 0x1140, 0x7010, 0x9084,
+	0xff00, 0x8007, 0x908e, 0x0008, 0x1108, 0x0009, 0x0005, 0x00b6,
+	0x00c6, 0x0046, 0x7000, 0x908c, 0xff00, 0x810f, 0x9186, 0x0033,
+	0x11e8, 0x080c, 0x840f, 0x0904, 0x81fe, 0x7124, 0x610a, 0x7030,
+	0x908e, 0x0200, 0x1140, 0x7034, 0x9005, 0x15c0, 0x2009, 0x0015,
+	0x080c, 0xac8d, 0x0498, 0x908e, 0x0100, 0x1580, 0x7034, 0x9005,
+	0x1568, 0x2009, 0x0016, 0x080c, 0xac8d, 0x0440, 0x9186, 0x0032,
+	0x1528, 0x7030, 0x908e, 0x1400, 0x1508, 0x2009, 0x0038, 0x0016,
+	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2630, 0x11a8,
+	0x080c, 0x65e3, 0x1190, 0xbe12, 0xbd16, 0x080c, 0xab9a, 0x0168,
+	0x2b08, 0x6112, 0x080c, 0xccfe, 0x6023, 0x0004, 0x7120, 0x610a,
+	0x001e, 0x080c, 0xac8d, 0x0010, 0x00ce, 0x001e, 0x004e, 0x00ce,
+	0x00be, 0x0005, 0x00b6, 0x0046, 0x00e6, 0x00d6, 0x2028, 0x2130,
+	0x9696, 0x00ff, 0x11b8, 0x9592, 0xfffc, 0x02a0, 0x9596, 0xfffd,
+	0x1120, 0x2009, 0x007f, 0x0804, 0x8260, 0x9596, 0xfffe, 0x1120,
+	0x2009, 0x007e, 0x0804, 0x8260, 0x9596, 0xfffc, 0x1118, 0x2009,
+	0x0080, 0x04f0, 0x2011, 0x0000, 0x2019, 0x1837, 0x231c, 0xd3ac,
+	0x0130, 0x9026, 0x20a9, 0x0800, 0x2071, 0x1000, 0x0030, 0x2021,
+	0x0081, 0x20a9, 0x077f, 0x2071, 0x1081, 0x2e1c, 0x93dd, 0x0000,
+	0x1140, 0x82ff, 0x11d0, 0x9496, 0x00ff, 0x01b8, 0x2410, 0xc2fd,
+	0x00a0, 0xbf10, 0x2600, 0x9706, 0xb814, 0x1120, 0x9546, 0x1110,
+	0x2408, 0x00b0, 0x9745, 0x1148, 0x94c6, 0x007e, 0x0130, 0x94c6,
+	0x007f, 0x0118, 0x94c6, 0x0080, 0x1d20, 0x8420, 0x8e70, 0x1f04,
+	0x8235, 0x82ff, 0x1118, 0x9085, 0x0001, 0x0018, 0xc2fc, 0x2208,
+	0x9006, 0x00de, 0x00ee, 0x004e, 0x00be, 0x0005, 0x7000, 0x908c,
+	0xff00, 0x810f, 0x9184, 0x000f, 0x0002, 0x827d, 0x827d, 0x827d,
+	0x8421, 0x827d, 0x8280, 0x82a5, 0x832e, 0x827d, 0x827d, 0x827d,
+	0x827d, 0x827d, 0x827d, 0x827d, 0x827d, 0x7817, 0x0140, 0x0005,
+	0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7120, 0x2160, 0x9c8c, 0x0003,
+	0x11c0, 0x9c8a, 0x1ddc, 0x02a8, 0x6868, 0x9c02, 0x1290, 0x7008,
+	0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1150, 0x700c,
+	0xb914, 0x9106, 0x1130, 0x7124, 0x610a, 0x2009, 0x0046, 0x080c,
+	0xac8d, 0x7817, 0x0140, 0x00be, 0x0005, 0x00b6, 0x00c6, 0x9484,
+	0x0fff, 0x0904, 0x830a, 0x7110, 0xd1bc, 0x1904, 0x830a, 0x7108,
+	0x700c, 0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00, 0x15c8,
+	0x81ff, 0x15b8, 0x9080, 0x3388, 0x200d, 0x918c, 0xff00, 0x810f,
+	0x2001, 0x0080, 0x9106, 0x0904, 0x830a, 0x9182, 0x0801, 0x1a04,
+	0x830a, 0x9190, 0x1000, 0x2204, 0x905d, 0x05e0, 0xbe12, 0xbd16,
+	0xb800, 0xd0ec, 0x15b8, 0xba04, 0x9294, 0xff00, 0x9286, 0x0600,
+	0x1190, 0x080c, 0xab9a, 0x0598, 0x2b08, 0x7028, 0x6052, 0x702c,
+	0x604e, 0x6112, 0x6023, 0x0006, 0x7120, 0x610a, 0x7130, 0x615e,
+	0x080c, 0xd8f8, 0x00f8, 0x080c, 0x6a8e, 0x1138, 0xb807, 0x0606,
+	0x0c40, 0x190c, 0x8202, 0x11b0, 0x0880, 0x080c, 0xab9a, 0x2b08,
+	0x0188, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x9286, 0x0400,
+	0x1118, 0x6007, 0x0005, 0x0010, 0x6007, 0x0001, 0x6003, 0x0001,
+	0x080c, 0x9240, 0x7817, 0x0140, 0x00ce, 0x00be, 0x0005, 0x2001,
+	0x180e, 0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x4b29,
+	0x080c, 0xac60, 0x0d78, 0x2b08, 0x6112, 0x6023, 0x0006, 0x7120,
+	0x610a, 0x7130, 0x615e, 0x6017, 0xf300, 0x6003, 0x0001, 0x6007,
+	0x0041, 0x2009, 0xa022, 0x080c, 0x9239, 0x08e0, 0x00b6, 0x7110,
+	0xd1bc, 0x05d0, 0x7020, 0x2060, 0x9c84, 0x0003, 0x15a8, 0x9c82,
+	0x1ddc, 0x0690, 0x6868, 0x9c02, 0x1678, 0x9484, 0x0fff, 0x9082,
+	0x000c, 0x0650, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910,
+	0x9106, 0x1510, 0x700c, 0xb914, 0x9106, 0x11f0, 0x7124, 0x610a,
+	0x601c, 0xd0fc, 0x11c8, 0x2001, 0x0271, 0x2004, 0x9005, 0x1180,
+	0x9484, 0x0fff, 0x9082, 0x000c, 0x0158, 0x0066, 0x2031, 0x0100,
+	0xa001, 0xa001, 0x8631, 0x1de0, 0x006e, 0x601c, 0xd0fc, 0x1120,
+	0x2009, 0x0045, 0x080c, 0xac8d, 0x7817, 0x0140, 0x00be, 0x0005,
+	0x6120, 0x9186, 0x0002, 0x0128, 0x9186, 0x0005, 0x0110, 0x9085,
+	0x0001, 0x0005, 0x080c, 0x3346, 0x1168, 0x7010, 0x9084, 0xff00,
+	0x8007, 0x9086, 0x0000, 0x1130, 0x9184, 0x000f, 0x908a, 0x0006,
+	0x1208, 0x000b, 0x0005, 0x8391, 0x8392, 0x8391, 0x8391, 0x83f1,
+	0x8400, 0x0005, 0x00b6, 0x7110, 0xd1bc, 0x0120, 0x702c, 0xd084,
+	0x0904, 0x83ef, 0x700c, 0x7108, 0x080c, 0x2630, 0x1904, 0x83ef,
+	0x080c, 0x65e3, 0x1904, 0x83ef, 0xbe12, 0xbd16, 0x7110, 0xd1bc,
+	0x01d8, 0x080c, 0x6a8e, 0x0118, 0x9086, 0x0004, 0x1588, 0x00c6,
+	0x080c, 0x840f, 0x00ce, 0x05d8, 0x080c, 0xab9a, 0x2b08, 0x05b8,
+	0x6112, 0x080c, 0xccfe, 0x6023, 0x0002, 0x7120, 0x610a, 0x2009,
+	0x0088, 0x080c, 0xac8d, 0x0458, 0x080c, 0x6a8e, 0x0148, 0x9086,
+	0x0004, 0x0130, 0x080c, 0x6a96, 0x0118, 0x9086, 0x0004, 0x1180,
+	0x080c, 0xab9a, 0x2b08, 0x01d8, 0x6112, 0x080c, 0xccfe, 0x6023,
+	0x0005, 0x7120, 0x610a, 0x2009, 0x0088, 0x080c, 0xac8d, 0x0078,
+	0x080c, 0xab9a, 0x2b08, 0x0158, 0x6112, 0x080c, 0xccfe, 0x6023,
+	0x0004, 0x7120, 0x610a, 0x2009, 0x0001, 0x080c, 0xac8d, 0x00be,
+	0x0005, 0x7110, 0xd1bc, 0x0158, 0x00d1, 0x0148, 0x080c, 0x8370,
+	0x1130, 0x7124, 0x610a, 0x2009, 0x0089, 0x080c, 0xac8d, 0x0005,
+	0x7110, 0xd1bc, 0x0158, 0x0059, 0x0148, 0x080c, 0x8370, 0x1130,
+	0x7124, 0x610a, 0x2009, 0x008a, 0x080c, 0xac8d, 0x0005, 0x7020,
+	0x2060, 0x9c84, 0x0003, 0x1158, 0x9c82, 0x1ddc, 0x0240, 0x2001,
+	0x181a, 0x2004, 0x9c02, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006,
+	0x0ce8, 0x00b6, 0x7110, 0xd1bc, 0x11d8, 0x7024, 0x2060, 0x9c84,
+	0x0003, 0x11b0, 0x9c82, 0x1ddc, 0x0298, 0x6868, 0x9c02, 0x1280,
+	0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1140,
+	0x700c, 0xb914, 0x9106, 0x1120, 0x2009, 0x0051, 0x080c, 0xac8d,
+	0x7817, 0x0140, 0x00be, 0x0005, 0x2031, 0x0105, 0x0069, 0x0005,
+	0x2031, 0x0206, 0x0049, 0x0005, 0x2031, 0x0207, 0x0029, 0x0005,
+	0x2031, 0x0213, 0x0009, 0x0005, 0x00c6, 0x0096, 0x00f6, 0x7000,
+	0x9084, 0xf000, 0x9086, 0xc000, 0x05c0, 0x080c, 0xab9a, 0x05a8,
+	0x0066, 0x00c6, 0x0046, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c,
+	0x080c, 0x2630, 0x1590, 0x080c, 0x65e3, 0x1578, 0xbe12, 0xbd16,
+	0x2b00, 0x004e, 0x00ce, 0x6012, 0x080c, 0xccfe, 0x080c, 0x1047,
+	0x0500, 0x2900, 0x6062, 0x9006, 0xa802, 0xa866, 0xac6a, 0xa85c,
+	0x90f8, 0x001b, 0x20a9, 0x000e, 0xa860, 0x20e8, 0x20e1, 0x0000,
+	0x2fa0, 0x2e98, 0x4003, 0x006e, 0x6616, 0x6007, 0x003e, 0x6023,
+	0x0001, 0x6003, 0x0001, 0x080c, 0x9240, 0x00fe, 0x009e, 0x00ce,
+	0x0005, 0x080c, 0xabf0, 0x006e, 0x0cc0, 0x004e, 0x00ce, 0x0cc8,
+	0x00c6, 0x7000, 0x908c, 0xff00, 0x9184, 0xf000, 0x810f, 0x9086,
+	0x2000, 0x1904, 0x84f7, 0x9186, 0x0022, 0x15f0, 0x2001, 0x0111,
+	0x2004, 0x9005, 0x1904, 0x84f9, 0x7030, 0x908e, 0x0400, 0x0904,
+	0x84f9, 0x908e, 0x6000, 0x05e8, 0x908e, 0x5400, 0x05d0, 0x908e,
+	0x0300, 0x11d8, 0x2009, 0x1837, 0x210c, 0xd18c, 0x1590, 0xd1a4,
+	0x1580, 0x080c, 0x6a4c, 0x0588, 0x68b0, 0x9084, 0x00ff, 0x7100,
+	0x918c, 0x00ff, 0x9106, 0x1518, 0x6880, 0x69b0, 0x918c, 0xff00,
+	0x9105, 0x7104, 0x9106, 0x11d8, 0x00e0, 0x2009, 0x0103, 0x210c,
+	0xd1b4, 0x11a8, 0x908e, 0x5200, 0x09e8, 0x908e, 0x0500, 0x09d0,
+	0x908e, 0x5000, 0x09b8, 0x0058, 0x9186, 0x0023, 0x1140, 0x080c,
+	0x840f, 0x0128, 0x6004, 0x9086, 0x0002, 0x0118, 0x0000, 0x9006,
+	0x0010, 0x9085, 0x0001, 0x00ce, 0x0005, 0x7030, 0x908e, 0x0300,
+	0x0118, 0x908e, 0x5200, 0x1d98, 0x2001, 0x1837, 0x2004, 0x9084,
+	0x0009, 0x9086, 0x0008, 0x0d68, 0x0c50, 0x0156, 0x0046, 0x0016,
+	0x0036, 0x7038, 0x2020, 0x8427, 0x94a4, 0x0007, 0xd484, 0x0148,
+	0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x027a, 0x080c, 0xbbc1,
+	0x1178, 0xd48c, 0x0148, 0x20a9, 0x0004, 0x2019, 0x1801, 0x2011,
+	0x027e, 0x080c, 0xbbc1, 0x1120, 0xd494, 0x0110, 0x9085, 0x0001,
+	0x003e, 0x001e, 0x004e, 0x015e, 0x0005, 0x0156, 0x0046, 0x0016,
+	0x0036, 0x7038, 0x2020, 0x8427, 0x94a4, 0x0007, 0xd484, 0x0148,
+	0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x0272, 0x080c, 0xbbc1,
+	0x1178, 0xd48c, 0x0148, 0x20a9, 0x0004, 0x2019, 0x1801, 0x2011,
+	0x0276, 0x080c, 0xbbc1, 0x1120, 0xd494, 0x0110, 0x9085, 0x0001,
+	0x003e, 0x001e, 0x004e, 0x015e, 0x0005, 0x00f6, 0x2079, 0x0200,
+	0x7800, 0xc0e5, 0xc0cc, 0x7802, 0x00fe, 0x0005, 0x00f6, 0x2079,
+	0x1800, 0x7834, 0xd084, 0x1130, 0x2079, 0x0200, 0x7800, 0x9085,
+	0x1200, 0x7802, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x1800, 0x7034,
+	0xc084, 0x7036, 0x00ee, 0x0005, 0x2071, 0x1a02, 0x7003, 0x0003,
+	0x700f, 0x0361, 0x9006, 0x701a, 0x7072, 0x7012, 0x7017, 0x1ddc,
+	0x7007, 0x0000, 0x7026, 0x702b, 0x9e6f, 0x7032, 0x7037, 0x9eec,
+	0x703f, 0xffff, 0x7042, 0x7047, 0x558c, 0x704a, 0x705b, 0x8724,
+	0x080c, 0x1060, 0x090c, 0x0d7d, 0x2900, 0x703a, 0xa867, 0x0003,
+	0xa86f, 0x0100, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x1a02, 0x1d04,
+	0x8640, 0x2091, 0x6000, 0x700c, 0x8001, 0x700e, 0x1590, 0x2001,
+	0x013c, 0x2004, 0x9005, 0x190c, 0x87ce, 0x2001, 0x1869, 0x2004,
+	0xd0c4, 0x0158, 0x3a00, 0xd08c, 0x1140, 0x20d1, 0x0000, 0x20d1,
+	0x0001, 0x20d1, 0x0000, 0x080c, 0x0d7d, 0x700f, 0x0361, 0x7007,
+	0x0001, 0x0126, 0x2091, 0x8000, 0x2069, 0x1800, 0x69ec, 0xd1e4,
+	0x1138, 0xd1dc, 0x1118, 0x080c, 0x8792, 0x0010, 0x080c, 0x8769,
+	0x7040, 0x900d, 0x0148, 0x8109, 0x7142, 0x1130, 0x7044, 0x080f,
+	0x0018, 0x0126, 0x2091, 0x8000, 0x7024, 0x900d, 0x0188, 0x7020,
+	0x8001, 0x7022, 0x1168, 0x7023, 0x0009, 0x8109, 0x7126, 0x9186,
+	0x03e8, 0x1110, 0x7028, 0x080f, 0x81ff, 0x1110, 0x7028, 0x080f,
+	0x7030, 0x900d, 0x0180, 0x702c, 0x8001, 0x702e, 0x1160, 0x702f,
+	0x0009, 0x8109, 0x7132, 0x0128, 0x9184, 0x007f, 0x090c, 0x9f88,
+	0x0010, 0x7034, 0x080f, 0x703c, 0x9005, 0x0118, 0x0310, 0x8001,
+	0x703e, 0x704c, 0x900d, 0x0168, 0x7048, 0x8001, 0x704a, 0x1148,
+	0x704b, 0x0009, 0x8109, 0x714e, 0x1120, 0x7150, 0x714e, 0x7058,
+	0x080f, 0x7018, 0x900d, 0x01d8, 0x0016, 0x7070, 0x900d, 0x0158,
+	0x706c, 0x8001, 0x706e, 0x1138, 0x706f, 0x0009, 0x8109, 0x7172,
+	0x1110, 0x7074, 0x080f, 0x001e, 0x7008, 0x8001, 0x700a, 0x1138,
+	0x700b, 0x0009, 0x8109, 0x711a, 0x1110, 0x701c, 0x080f, 0x012e,
+	0x7004, 0x0002, 0x8668, 0x8669, 0x8693, 0x00e6, 0x2071, 0x1a02,
+	0x7018, 0x9005, 0x1120, 0x711a, 0x721e, 0x700b, 0x0009, 0x00ee,
+	0x0005, 0x00e6, 0x0006, 0x2071, 0x1a02, 0x701c, 0x9206, 0x1120,
+	0x701a, 0x701e, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x00e6,
+	0x2071, 0x1a02, 0xb888, 0x9102, 0x0208, 0xb98a, 0x00ee, 0x0005,
+	0x0005, 0x00b6, 0x2031, 0x0010, 0x7110, 0x080c, 0x6644, 0x11a8,
+	0xb888, 0x8001, 0x0290, 0xb88a, 0x1180, 0x0126, 0x2091, 0x8000,
+	0x0066, 0xb8d0, 0x9005, 0x0138, 0x0026, 0xba3c, 0x0016, 0x080c,
+	0x676f, 0x001e, 0x002e, 0x006e, 0x012e, 0x8108, 0x9182, 0x0800,
+	0x1220, 0x8631, 0x0128, 0x7112, 0x0c00, 0x900e, 0x7007, 0x0002,
+	0x7112, 0x00be, 0x0005, 0x2031, 0x0010, 0x7014, 0x2060, 0x0126,
+	0x2091, 0x8000, 0x6048, 0x9005, 0x0128, 0x8001, 0x604a, 0x1110,
+	0x080c, 0xcb7f, 0x6018, 0x9005, 0x0904, 0x86eb, 0x00f6, 0x2079,
+	0x0300, 0x7918, 0xd1b4, 0x1904, 0x86fe, 0x781b, 0x2020, 0xa001,
+	0x7918, 0xd1b4, 0x0120, 0x781b, 0x2000, 0x0804, 0x86fe, 0x8001,
+	0x601a, 0x0106, 0x781b, 0x2000, 0xa001, 0x7918, 0xd1ac, 0x1dd0,
+	0x010e, 0x00fe, 0x1540, 0x6120, 0x9186, 0x0003, 0x0148, 0x9186,
+	0x0006, 0x0130, 0x9186, 0x0009, 0x11e0, 0x611c, 0xd1c4, 0x1100,
+	0x080c, 0xc865, 0x01b0, 0x6014, 0x2048, 0xa884, 0x908a, 0x199a,
+	0x0280, 0x9082, 0x1999, 0xa886, 0x908a, 0x199a, 0x0210, 0x2001,
+	0x1999, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0x080c, 0xcfb0,
+	0x0110, 0x080c, 0xc546, 0x012e, 0x9c88, 0x001c, 0x7116, 0x2001,
+	0x181a, 0x2004, 0x9102, 0x1228, 0x8631, 0x0138, 0x2160, 0x0804,
+	0x8697, 0x7017, 0x1ddc, 0x7007, 0x0000, 0x0005, 0x00fe, 0x0c58,
+	0x00e6, 0x2071, 0x1a02, 0x7027, 0x07d0, 0x7023, 0x0009, 0x00ee,
+	0x0005, 0x2001, 0x1a0b, 0x2003, 0x0000, 0x0005, 0x00e6, 0x2071,
+	0x1a02, 0x7132, 0x702f, 0x0009, 0x00ee, 0x0005, 0x2011, 0x1a0e,
+	0x2013, 0x0000, 0x0005, 0x00e6, 0x2071, 0x1a02, 0x711a, 0x721e,
+	0x700b, 0x0009, 0x00ee, 0x0005, 0x0086, 0x0026, 0x7054, 0x8000,
+	0x7056, 0x2001, 0x1a10, 0x2044, 0xa06c, 0x9086, 0x0000, 0x0150,
+	0x7068, 0xa09a, 0x7064, 0xa096, 0x7060, 0xa092, 0x705c, 0xa08e,
+	0x080c, 0x113c, 0x002e, 0x008e, 0x0005, 0x0006, 0x0016, 0x0096,
+	0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0156, 0x080c,
+	0x85a5, 0x015e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae,
+	0x009e, 0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0x1a02, 0x7172,
+	0x7276, 0x706f, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071,
+	0x1a02, 0x7074, 0x9206, 0x1110, 0x7072, 0x7076, 0x000e, 0x00ee,
+	0x0005, 0x2069, 0x1800, 0x69ec, 0xd1e4, 0x1518, 0x0026, 0xd1ec,
+	0x0140, 0x6a54, 0x6874, 0x9202, 0x0288, 0x8117, 0x9294, 0x00c1,
+	0x0088, 0x9184, 0x0007, 0x01a0, 0x8109, 0x9184, 0x0007, 0x0110,
+	0x69ee, 0x0070, 0x8107, 0x9084, 0x0007, 0x910d, 0x8107, 0x9106,
+	0x9094, 0x00c1, 0x9184, 0xff3e, 0x9205, 0x68ee, 0x080c, 0x0f12,
+	0x002e, 0x0005, 0x69e8, 0x9184, 0x003f, 0x05b8, 0x8109, 0x9184,
+	0x003f, 0x01a8, 0x6a54, 0x6874, 0x9202, 0x0220, 0xd1bc, 0x0168,
+	0xc1bc, 0x0018, 0xd1bc, 0x1148, 0xc1bd, 0x2110, 0x00e6, 0x2071,
+	0x1800, 0x080c, 0x0f34, 0x00ee, 0x0400, 0x69ea, 0x00f0, 0x0026,
+	0x8107, 0x9094, 0x0007, 0x0128, 0x8001, 0x8007, 0x9085, 0x0007,
+	0x0050, 0x2010, 0x8004, 0x8004, 0x8004, 0x9084, 0x0007, 0x9205,
+	0x8007, 0x9085, 0x0028, 0x9086, 0x0040, 0x2010, 0x00e6, 0x2071,
+	0x1800, 0x080c, 0x0f34, 0x00ee, 0x002e, 0x0005, 0x0016, 0x00c6,
+	0x2009, 0xfff4, 0x210d, 0x2061, 0x0100, 0x60f0, 0x9100, 0x60f3,
+	0x0000, 0x2009, 0xfff4, 0x200f, 0x1220, 0x8108, 0x2105, 0x8000,
+	0x200f, 0x00ce, 0x001e, 0x0005, 0x00c6, 0x2061, 0x1a6e, 0x00ce,
+	0x0005, 0x9184, 0x000f, 0x8003, 0x8003, 0x8003, 0x9080, 0x1a6e,
+	0x2060, 0x0005, 0xa884, 0x908a, 0x199a, 0x1638, 0x9005, 0x1150,
+	0x00c6, 0x2061, 0x1a6e, 0x6014, 0x00ce, 0x9005, 0x1130, 0x2001,
+	0x001e, 0x0018, 0x908e, 0xffff, 0x01b0, 0x8003, 0x800b, 0x810b,
+	0x9108, 0x611a, 0xa87c, 0x908c, 0x00c0, 0x918e, 0x00c0, 0x0904,
+	0x88ac, 0xd0b4, 0x1168, 0xd0bc, 0x1904, 0x8885, 0x2009, 0x0006,
+	0x080c, 0x88d9, 0x0005, 0x900e, 0x0c60, 0x2001, 0x1999, 0x08b0,
+	0xd0fc, 0x05e0, 0x908c, 0x2023, 0x1568, 0x87ff, 0x1558, 0xa9a8,
+	0x81ff, 0x1540, 0x6124, 0x918c, 0x0500, 0x1520, 0x6100, 0x918e,
+	0x0007, 0x1500, 0x2009, 0x1869, 0x210c, 0xd184, 0x11d8, 0x6003,
+	0x0003, 0x6007, 0x0043, 0x6047, 0xb035, 0x080c, 0x1c28, 0xa87c,
+	0xc0dd, 0xa87e, 0x600f, 0x0000, 0x00f6, 0x2079, 0x0380, 0x7818,
+	0xd0bc, 0x1de8, 0x7833, 0x0013, 0x2c00, 0x7836, 0x781b, 0x8080,
+	0x00fe, 0x0005, 0x908c, 0x0003, 0x0120, 0x918e, 0x0003, 0x1904,
+	0x88d3, 0x908c, 0x2020, 0x918e, 0x2020, 0x01a8, 0x6024, 0xd0d4,
+	0x11e8, 0x2009, 0x1869, 0x2104, 0xd084, 0x1138, 0x87ff, 0x1120,
+	0x2009, 0x0043, 0x0804, 0xac8d, 0x0005, 0x87ff, 0x1de8, 0x2009,
+	0x0042, 0x0804, 0xac8d, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be,
+	0xd1ac, 0x0d20, 0x6024, 0xc0cd, 0x6026, 0x0c00, 0xc0d4, 0x6026,
+	0xa890, 0x602e, 0xa88c, 0x6032, 0x08e0, 0xd0fc, 0x0160, 0x908c,
+	0x0003, 0x0120, 0x918e, 0x0003, 0x1904, 0x88d3, 0x908c, 0x2020,
+	0x918e, 0x2020, 0x0170, 0x0076, 0x00f6, 0x2c78, 0x080c, 0x174b,
+	0x00fe, 0x007e, 0x87ff, 0x1120, 0x2009, 0x0042, 0x080c, 0xac8d,
+	0x0005, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d58,
+	0x6124, 0xc1cd, 0x6126, 0x0c38, 0xd0fc, 0x0188, 0x908c, 0x2020,
+	0x918e, 0x2020, 0x01a8, 0x9084, 0x0003, 0x908e, 0x0002, 0x0148,
+	0x87ff, 0x1120, 0x2009, 0x0041, 0x080c, 0xac8d, 0x0005, 0x00b9,
+	0x0ce8, 0x87ff, 0x1dd8, 0x2009, 0x0043, 0x080c, 0xac8d, 0x0cb0,
+	0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20, 0x6124,
+	0xc1cd, 0x6126, 0x0c00, 0x2009, 0x0004, 0x0019, 0x0005, 0x2009,
+	0x0001, 0x0096, 0x080c, 0xc865, 0x0518, 0x6014, 0x2048, 0xa982,
+	0xa800, 0x6016, 0x9186, 0x0001, 0x1188, 0xa97c, 0x918c, 0x8100,
+	0x918e, 0x8100, 0x1158, 0x00c6, 0x2061, 0x1a6e, 0x6200, 0xd28c,
+	0x1120, 0x6204, 0x8210, 0x0208, 0x6206, 0x00ce, 0x080c, 0x6bd4,
+	0x6014, 0x904d, 0x0076, 0x2039, 0x0000, 0x190c, 0x87f2, 0x007e,
+	0x009e, 0x0005, 0x0156, 0x00c6, 0x2061, 0x1a6e, 0x6000, 0x81ff,
+	0x0110, 0x9205, 0x0008, 0x9204, 0x6002, 0x00ce, 0x015e, 0x0005,
+	0x6800, 0xd08c, 0x1138, 0x6808, 0x9005, 0x0120, 0x8001, 0x680a,
+	0x9085, 0x0001, 0x0005, 0x2071, 0x1923, 0x7003, 0x0006, 0x7007,
+	0x0000, 0x700f, 0x0000, 0x7013, 0x0001, 0x080c, 0x1060, 0x090c,
+	0x0d7d, 0xa867, 0x0006, 0xa86b, 0x0001, 0xa8ab, 0xdcb0, 0xa89f,
+	0x0000, 0x2900, 0x702e, 0x7033, 0x0000, 0x0005, 0x0096, 0x00e6,
+	0x2071, 0x1923, 0x702c, 0x2048, 0x6a2c, 0x721e, 0x6b30, 0x7322,
+	0x6834, 0x7026, 0xa896, 0x6838, 0x702a, 0xa89a, 0x6824, 0x7016,
+	0x683c, 0x701a, 0x2009, 0x0028, 0x200a, 0x9005, 0x0148, 0x900e,
+	0x9188, 0x000c, 0x8001, 0x1de0, 0x2100, 0x9210, 0x1208, 0x8318,
+	0xaa8e, 0xab92, 0x7010, 0xd084, 0x0178, 0xc084, 0x7007, 0x0001,
+	0x700f, 0x0000, 0x0006, 0x2009, 0x181d, 0x2104, 0x9082, 0x0007,
+	0x2009, 0x1b4d, 0x200a, 0x000e, 0xc095, 0x7012, 0x2008, 0x2001,
+	0x003b, 0x080c, 0x1693, 0x9006, 0x2071, 0x193c, 0x7002, 0x7006,
+	0x702a, 0x00ee, 0x009e, 0x0005, 0x00e6, 0x0126, 0x0156, 0x2091,
+	0x8000, 0x2071, 0x1800, 0x7154, 0x2001, 0x0008, 0x910a, 0x0638,
+	0x2001, 0x187d, 0x20ac, 0x9006, 0x9080, 0x0008, 0x1f04, 0x898c,
+	0x71c0, 0x9102, 0x02e0, 0x2071, 0x1877, 0x20a9, 0x0007, 0x00c6,
+	0x080c, 0xab9a, 0x6023, 0x0009, 0x6003, 0x0004, 0x601f, 0x0101,
+	0x0089, 0x0126, 0x2091, 0x8000, 0x080c, 0x8b15, 0x012e, 0x1f04,
+	0x8998, 0x9006, 0x00ce, 0x015e, 0x012e, 0x00ee, 0x0005, 0x9085,
+	0x0001, 0x0cc8, 0x00e6, 0x00b6, 0x0096, 0x0086, 0x0056, 0x0046,
+	0x0026, 0x7118, 0x720c, 0x7620, 0x7004, 0xd084, 0x1128, 0x2021,
+	0x0024, 0x2029, 0x0002, 0x0020, 0x2021, 0x002c, 0x2029, 0x000a,
+	0x080c, 0x1047, 0x090c, 0x0d7d, 0x2900, 0x6016, 0x2058, 0xac66,
+	0x9006, 0xa802, 0xa806, 0xa86a, 0xa87a, 0xa8aa, 0xa887, 0x0005,
+	0xa87f, 0x0020, 0x7008, 0xa89a, 0x7010, 0xa89e, 0xae8a, 0xa8af,
+	0xffff, 0xa8b3, 0x0000, 0x8109, 0x0160, 0x080c, 0x1047, 0x090c,
+	0x0d7d, 0xad66, 0x2b00, 0xa802, 0x2900, 0xb806, 0x2058, 0x8109,
+	0x1da0, 0x002e, 0x004e, 0x005e, 0x008e, 0x009e, 0x00be, 0x00ee,
+	0x0005, 0x2079, 0x0000, 0x2071, 0x1923, 0x7004, 0x004b, 0x700c,
+	0x0002, 0x8a04, 0x89fd, 0x89fd, 0x0005, 0x8a0e, 0x8a6f, 0x8a6f,
+	0x8a6f, 0x8a70, 0x8a81, 0x8a81, 0x700c, 0x0cba, 0x0126, 0x2091,
+	0x8000, 0x78a0, 0x79a0, 0x9106, 0x0128, 0x78a0, 0x79a0, 0x9106,
+	0x1904, 0x8a62, 0x2001, 0x0005, 0x2004, 0xd0bc, 0x0130, 0x2011,
+	0x0004, 0x2204, 0xc0c5, 0x2012, 0x0ca8, 0x012e, 0x7018, 0x910a,
+	0x1130, 0x7030, 0x9005, 0x05a8, 0x080c, 0x8ab0, 0x0490, 0x1210,
+	0x7114, 0x910a, 0x9192, 0x000a, 0x0210, 0x2009, 0x000a, 0x2001,
+	0x1888, 0x2014, 0x2001, 0x1935, 0x2004, 0x9100, 0x9202, 0x0e48,
+	0x080c, 0x8bff, 0x2200, 0x9102, 0x0208, 0x2208, 0x0096, 0x702c,
+	0x2048, 0xa873, 0x0001, 0xa976, 0x080c, 0x8d08, 0x2100, 0xa87e,
+	0xa86f, 0x0000, 0x009e, 0x0126, 0x2091, 0x8000, 0x2009, 0x1a20,
+	0x2104, 0xc085, 0x200a, 0x700f, 0x0002, 0x012e, 0x080c, 0x115b,
+	0x1de8, 0x0005, 0x2001, 0x0005, 0x2004, 0xd0bc, 0x0130, 0x2011,
+	0x0004, 0x2204, 0xc0c5, 0x2012, 0x0ca8, 0x012e, 0x0005, 0x0005,
+	0x700c, 0x0002, 0x8a75, 0x8a78, 0x8a77, 0x080c, 0x8a0c, 0x0005,
+	0x8001, 0x700e, 0x0096, 0x702c, 0x2048, 0xa974, 0x009e, 0x0011,
+	0x0ca0, 0x0005, 0x0096, 0x702c, 0x2048, 0x7018, 0x9100, 0x7214,
+	0x921a, 0x1130, 0x701c, 0xa88e, 0x7020, 0xa892, 0x9006, 0x0068,
+	0x0006, 0x080c, 0x8d08, 0x2100, 0xaa8c, 0x9210, 0xaa8e, 0x1220,
+	0xa890, 0x9081, 0x0000, 0xa892, 0x000e, 0x009e, 0x2f08, 0x9188,
+	0x0028, 0x200a, 0x701a, 0x0005, 0x00e6, 0x2071, 0x1923, 0x700c,
+	0x0002, 0x8aae, 0x8aae, 0x8aac, 0x700f, 0x0001, 0x00ee, 0x0005,
+	0x0126, 0x2091, 0x8000, 0x7030, 0x9005, 0x0508, 0x2078, 0x7814,
+	0x2048, 0xae88, 0x00b6, 0x2059, 0x0000, 0x080c, 0x8b1e, 0x00be,
+	0x01b0, 0x00e6, 0x2071, 0x193c, 0x080c, 0x8b65, 0x00ee, 0x0178,
+	0x0096, 0x080c, 0x1060, 0x2900, 0x009e, 0x0148, 0xa8aa, 0x04d1,
+	0x0041, 0x2001, 0x1946, 0x2003, 0x0000, 0x012e, 0x08c8, 0x012e,
+	0x0005, 0x00d6, 0x00c6, 0x0086, 0x00a6, 0x2940, 0x2650, 0x2600,
+	0x9005, 0x0180, 0xa864, 0x9084, 0x000f, 0x2068, 0x9d88, 0x1e7a,
+	0x2165, 0x0056, 0x2029, 0x0000, 0x080c, 0x8c8d, 0x080c, 0x1e50,
+	0x1dd8, 0x005e, 0x00ae, 0x2001, 0x187f, 0x2004, 0xa88a, 0x00c6,
+	0x2f60, 0x080c, 0x174b, 0x00ce, 0x781f, 0x0101, 0x7813, 0x0000,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x8b74, 0x012e, 0x008e, 0x00ce,
+	0x00de, 0x0005, 0x7030, 0x9005, 0x0138, 0x2078, 0x780c, 0x7032,
+	0x2001, 0x1946, 0x2003, 0x0001, 0x0005, 0x00e6, 0x2071, 0x1923,
+	0x7030, 0x600e, 0x2c00, 0x7032, 0x00ee, 0x0005, 0x00d6, 0x00c6,
+	0x0026, 0x9b80, 0x8de7, 0x2005, 0x906d, 0x090c, 0x0d7d, 0x9b80,
+	0x8ddf, 0x2005, 0x9065, 0x090c, 0x0d7d, 0x6114, 0x2600, 0x9102,
+	0x0248, 0x6828, 0x9102, 0x02f0, 0x9085, 0x0001, 0x002e, 0x00ce,
+	0x00de, 0x0005, 0x6804, 0xd094, 0x0148, 0x6854, 0xd084, 0x1178,
+	0xc085, 0x6856, 0x2011, 0x8026, 0x080c, 0x4b29, 0x684c, 0x0096,
+	0x904d, 0x090c, 0x0d7d, 0xa804, 0x8000, 0xa806, 0x009e, 0x9006,
+	0x2030, 0x0c20, 0x6854, 0xd08c, 0x1d08, 0xc08d, 0x6856, 0x2011,
+	0x8025, 0x080c, 0x4b29, 0x684c, 0x0096, 0x904d, 0x090c, 0x0d7d,
+	0xa800, 0x8000, 0xa802, 0x009e, 0x0888, 0x7000, 0x2019, 0x0008,
+	0x8319, 0x7104, 0x9102, 0x1118, 0x2300, 0x9005, 0x0020, 0x0210,
+	0x9302, 0x0008, 0x8002, 0x0005, 0x00d6, 0x7814, 0x9005, 0x090c,
+	0x0d7d, 0x781c, 0x9084, 0x0101, 0x9086, 0x0101, 0x190c, 0x0d7d,
+	0x2069, 0x193c, 0x6804, 0x9080, 0x193e, 0x2f08, 0x2102, 0x6904,
+	0x8108, 0x9182, 0x0008, 0x0208, 0x900e, 0x6906, 0x9180, 0x193e,
+	0x2003, 0x0000, 0x00de, 0x0005, 0x0096, 0x00c6, 0x2060, 0x6014,
+	0x2048, 0xa8a8, 0x0096, 0x2048, 0x9005, 0x190c, 0x1079, 0x009e,
+	0xa8ab, 0x0000, 0x080c, 0x0ff9, 0x080c, 0xabf0, 0x00ce, 0x009e,
+	0x0005, 0x6020, 0x9086, 0x0009, 0x1128, 0x601c, 0xd0c4, 0x0110,
+	0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x6000, 0x9086, 0x0000,
+	0x0178, 0x6010, 0x9005, 0x0150, 0x00b6, 0x2058, 0x080c, 0x8f1c,
+	0x00be, 0x6013, 0x0000, 0x601b, 0x0000, 0x0010, 0x2c00, 0x0861,
+	0x0005, 0x2009, 0x1927, 0x210c, 0xd194, 0x0005, 0x00e6, 0x2071,
+	0x1923, 0x7110, 0xc194, 0xd19c, 0x1118, 0xc185, 0x7007, 0x0000,
+	0x7112, 0x2001, 0x003b, 0x080c, 0x1693, 0x00ee, 0x0005, 0x0096,
+	0x00d6, 0x9006, 0x7006, 0x700e, 0x701a, 0x701e, 0x7022, 0x7016,
+	0x702a, 0x7026, 0x702f, 0x0000, 0x080c, 0x8d67, 0x0170, 0x080c,
+	0x8d9c, 0x0158, 0x2900, 0x7002, 0x700a, 0x701a, 0x7013, 0x0001,
+	0x701f, 0x000a, 0x00de, 0x009e, 0x0005, 0x900e, 0x0cd8, 0x00e6,
+	0x0096, 0x0086, 0x00d6, 0x00c6, 0x2071, 0x1930, 0x721c, 0x2100,
+	0x9202, 0x1618, 0x080c, 0x8d9c, 0x090c, 0x0d7d, 0x7018, 0x9005,
+	0x1160, 0x2900, 0x7002, 0x700a, 0x701a, 0x9006, 0x7006, 0x700e,
+	0xa806, 0xa802, 0x7012, 0x701e, 0x0038, 0x2040, 0xa806, 0x2900,
+	0xa002, 0x701a, 0xa803, 0x0000, 0x7010, 0x8000, 0x7012, 0x701c,
+	0x9080, 0x000a, 0x701e, 0x721c, 0x08d0, 0x721c, 0x00ce, 0x00de,
+	0x008e, 0x009e, 0x00ee, 0x0005, 0x0096, 0x0156, 0x0136, 0x0146,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1930, 0x7300, 0x831f,
+	0x831e, 0x831e, 0x9384, 0x003f, 0x20e8, 0x939c, 0xffc0, 0x9398,
+	0x0003, 0x7104, 0x080c, 0x8d08, 0x810c, 0x2100, 0x9318, 0x8003,
+	0x2228, 0x2021, 0x0078, 0x9402, 0x9532, 0x0208, 0x2028, 0x2500,
+	0x8004, 0x20a8, 0x23a0, 0xa001, 0xa001, 0x4005, 0x2508, 0x080c,
+	0x8d11, 0x2130, 0x7014, 0x9600, 0x7016, 0x2600, 0x711c, 0x9102,
+	0x701e, 0x7004, 0x9600, 0x2008, 0x9082, 0x000a, 0x1190, 0x7000,
+	0x2048, 0xa800, 0x9005, 0x1148, 0x2009, 0x0001, 0x0026, 0x080c,
+	0x8bff, 0x002e, 0x7000, 0x2048, 0xa800, 0x7002, 0x7007, 0x0000,
+	0x0008, 0x7106, 0x2500, 0x9212, 0x1904, 0x8c3e, 0x012e, 0x00ee,
+	0x014e, 0x013e, 0x015e, 0x009e, 0x0005, 0x0016, 0x0026, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x9580, 0x8ddf, 0x2005, 0x9075, 0x090c,
+	0x0d7d, 0x080c, 0x8ce3, 0x012e, 0x9580, 0x8ddb, 0x2005, 0x9075,
+	0x090c, 0x0d7d, 0x0156, 0x0136, 0x01c6, 0x0146, 0x01d6, 0x831f,
+	0x831e, 0x831e, 0x9384, 0x003f, 0x20e0, 0x9384, 0xffc0, 0x9100,
+	0x2098, 0xa860, 0x20e8, 0xa95c, 0x2c05, 0x9100, 0x20a0, 0x20a9,
+	0x0002, 0x4003, 0x2e0c, 0x2d00, 0x0002, 0x8ccd, 0x8ccd, 0x8ccf,
+	0x8ccd, 0x8ccf, 0x8ccd, 0x8ccd, 0x8ccd, 0x8ccd, 0x8ccd, 0x8cd5,
+	0x8ccd, 0x8cd5, 0x8ccd, 0x8ccd, 0x8ccd, 0x080c, 0x0d7d, 0x4104,
+	0x20a9, 0x0002, 0x4002, 0x4003, 0x0028, 0x20a9, 0x0002, 0x4003,
+	0x4104, 0x4003, 0x01de, 0x014e, 0x01ce, 0x013e, 0x015e, 0x00ee,
+	0x002e, 0x001e, 0x0005, 0x0096, 0x7014, 0x8001, 0x7016, 0x710c,
+	0x2110, 0x00f1, 0x810c, 0x9188, 0x0003, 0x7308, 0x8210, 0x9282,
+	0x000a, 0x1198, 0x7008, 0x2048, 0xa800, 0x9005, 0x0158, 0x0006,
+	0x080c, 0x8dab, 0x009e, 0xa807, 0x0000, 0x2900, 0x700a, 0x7010,
+	0x8001, 0x7012, 0x700f, 0x0000, 0x0008, 0x720e, 0x009e, 0x0005,
+	0x0006, 0x810b, 0x810b, 0x2100, 0x810b, 0x9100, 0x2008, 0x000e,
+	0x0005, 0x0006, 0x0026, 0x2100, 0x9005, 0x0158, 0x9092, 0x000c,
+	0x0240, 0x900e, 0x8108, 0x9082, 0x000c, 0x1de0, 0x002e, 0x000e,
+	0x0005, 0x900e, 0x0cd8, 0x2d00, 0x90b8, 0x0008, 0x690c, 0x6810,
+	0x2019, 0x0001, 0x2031, 0x8d51, 0x9112, 0x0220, 0x0118, 0x8318,
+	0x2208, 0x0cd0, 0x6808, 0x9005, 0x0108, 0x8318, 0x233a, 0x6804,
+	0xd084, 0x2300, 0x2021, 0x0001, 0x1150, 0x9082, 0x0003, 0x0967,
+	0x0a67, 0x8420, 0x9082, 0x0007, 0x0967, 0x0a67, 0x0cd0, 0x9082,
+	0x0002, 0x0967, 0x0a67, 0x8420, 0x9082, 0x0005, 0x0967, 0x0a67,
+	0x0cd0, 0x6c1a, 0x2d00, 0x90b8, 0x0007, 0x00e6, 0x2071, 0x1800,
+	0x7128, 0x6810, 0x2019, 0x0001, 0x910a, 0x0118, 0x0210, 0x8318,
+	0x0cd8, 0x2031, 0x8d64, 0x0870, 0x6c16, 0x00ee, 0x0005, 0x0096,
+	0x0046, 0x0126, 0x2091, 0x8000, 0x2b00, 0x9080, 0x8de3, 0x2005,
+	0x9005, 0x090c, 0x0d7d, 0x2004, 0x90a0, 0x000a, 0x080c, 0x1060,
+	0x01d0, 0x2900, 0x7026, 0xa803, 0x0000, 0xa807, 0x0000, 0x080c,
+	0x1060, 0x0188, 0x7024, 0xa802, 0xa807, 0x0000, 0x2900, 0x7026,
+	0x94a2, 0x000a, 0x0110, 0x0208, 0x0c90, 0x9085, 0x0001, 0x012e,
+	0x004e, 0x009e, 0x0005, 0x7024, 0x9005, 0x0dc8, 0x2048, 0xac00,
+	0x080c, 0x1079, 0x2400, 0x0cc0, 0x0126, 0x2091, 0x8000, 0x7024,
+	0x2048, 0x9005, 0x0130, 0xa800, 0x7026, 0xa803, 0x0000, 0xa807,
+	0x0000, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x7024, 0xa802,
+	0x2900, 0x7026, 0x012e, 0x0005, 0x0096, 0x9e80, 0x0009, 0x2004,
+	0x9005, 0x0138, 0x2048, 0xa800, 0x0006, 0x080c, 0x1079, 0x000e,
+	0x0cb8, 0x009e, 0x0005, 0x0096, 0x7008, 0x9005, 0x0138, 0x2048,
+	0xa800, 0x0006, 0x080c, 0x1079, 0x000e, 0x0cb8, 0x9006, 0x7002,
+	0x700a, 0x7006, 0x700e, 0x701a, 0x701e, 0x7022, 0x702a, 0x7026,
+	0x702e, 0x009e, 0x0005, 0x1a6c, 0x0000, 0x0000, 0x0000, 0x1930,
+	0x0000, 0x0000, 0x0000, 0x1888, 0x0000, 0x0000, 0x0000, 0x1877,
+	0x0000, 0x0000, 0x0000, 0x00e6, 0x00c6, 0x00b6, 0x00a6, 0xa8a8,
+	0x2040, 0x2071, 0x1877, 0x080c, 0x8f07, 0xa067, 0x0023, 0x6010,
+	0x905d, 0x0904, 0x8edc, 0xb814, 0xa06e, 0xb910, 0xa172, 0xb9a0,
+	0xa176, 0x2001, 0x0003, 0xa07e, 0xa834, 0xa082, 0xa07b, 0x0000,
+	0xa898, 0x9005, 0x0118, 0xa078, 0xc085, 0xa07a, 0x2858, 0x2031,
+	0x0018, 0xa068, 0x908a, 0x0019, 0x1a0c, 0x0d7d, 0x2020, 0x2050,
+	0x2940, 0xa864, 0x90bc, 0x00ff, 0x908c, 0x000f, 0x91e0, 0x1e7a,
+	0x2c65, 0x9786, 0x0024, 0x2c05, 0x1590, 0x908a, 0x0036, 0x1a0c,
+	0x0d7d, 0x9082, 0x001b, 0x0002, 0x8e47, 0x8e47, 0x8e49, 0x8e47,
+	0x8e47, 0x8e47, 0x8e4b, 0x8e47, 0x8e47, 0x8e47, 0x8e4d, 0x8e47,
+	0x8e47, 0x8e47, 0x8e4f, 0x8e47, 0x8e47, 0x8e47, 0x8e51, 0x8e47,
+	0x8e47, 0x8e47, 0x8e53, 0x8e47, 0x8e47, 0x8e47, 0x8e55, 0x080c,
+	0x0d7d, 0xa180, 0x04b8, 0xa190, 0x04a8, 0xa1a0, 0x0498, 0xa1b0,
+	0x0488, 0xa1c0, 0x0478, 0xa1d0, 0x0468, 0xa1e0, 0x0458, 0x908a,
+	0x0034, 0x1a0c, 0x0d7d, 0x9082, 0x001b, 0x0002, 0x8e79, 0x8e77,
+	0x8e77, 0x8e77, 0x8e77, 0x8e77, 0x8e7b, 0x8e77, 0x8e77, 0x8e77,
+	0x8e77, 0x8e77, 0x8e7d, 0x8e77, 0x8e77, 0x8e77, 0x8e77, 0x8e77,
+	0x8e7f, 0x8e77, 0x8e77, 0x8e77, 0x8e77, 0x8e77, 0x8e81, 0x080c,
+	0x0d7d, 0xa180, 0x0038, 0xa198, 0x0028, 0xa1b0, 0x0018, 0xa1c8,
+	0x0008, 0xa1e0, 0x2600, 0x0002, 0x8e9d, 0x8e9f, 0x8ea1, 0x8ea3,
+	0x8ea5, 0x8ea7, 0x8ea9, 0x8eab, 0x8ead, 0x8eaf, 0x8eb1, 0x8eb3,
+	0x8eb5, 0x8eb7, 0x8eb9, 0x8ebb, 0x8ebd, 0x8ebf, 0x8ec1, 0x8ec3,
+	0x8ec5, 0x8ec7, 0x8ec9, 0x8ecb, 0x8ecd, 0x080c, 0x0d7d, 0xb9e2,
+	0x0468, 0xb9de, 0x0458, 0xb9da, 0x0448, 0xb9d6, 0x0438, 0xb9d2,
+	0x0428, 0xb9ce, 0x0418, 0xb9ca, 0x0408, 0xb9c6, 0x00f8, 0xb9c2,
+	0x00e8, 0xb9be, 0x00d8, 0xb9ba, 0x00c8, 0xb9b6, 0x00b8, 0xb9b2,
+	0x00a8, 0xb9ae, 0x0098, 0xb9aa, 0x0088, 0xb9a6, 0x0078, 0xb9a2,
+	0x0068, 0xb99e, 0x0058, 0xb99a, 0x0048, 0xb996, 0x0038, 0xb992,
+	0x0028, 0xb98e, 0x0018, 0xb98a, 0x0008, 0xb986, 0x8631, 0x8421,
+	0x0130, 0x080c, 0x1e50, 0x090c, 0x0d7d, 0x0804, 0x8e21, 0x00ae,
+	0x00be, 0x00ce, 0x00ee, 0x0005, 0xa86c, 0xa06e, 0xa870, 0xa072,
+	0xa077, 0x00ff, 0x9006, 0x0804, 0x8e03, 0x0006, 0x0016, 0x00b6,
+	0x6010, 0x2058, 0xb810, 0x9005, 0x01b0, 0x2001, 0x1924, 0x2004,
+	0x9005, 0x0188, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x1158,
+	0x0036, 0x0046, 0xbba0, 0x2021, 0x0004, 0x2011, 0x8014, 0x080c,
+	0x4b29, 0x004e, 0x003e, 0x00be, 0x001e, 0x000e, 0x0005, 0x9016,
+	0x710c, 0xa834, 0x910a, 0xa936, 0x7008, 0x9005, 0x0120, 0x8210,
+	0x910a, 0x0238, 0x0130, 0x7010, 0x8210, 0x910a, 0x0210, 0x0108,
+	0x0cd8, 0xaa8a, 0xa26a, 0x0005, 0x00f6, 0x00d6, 0x0036, 0x2079,
+	0x0300, 0x781b, 0x0200, 0x7818, 0xd094, 0x1dd8, 0x781b, 0x0202,
+	0xa001, 0xa001, 0x7818, 0xd094, 0x1da0, 0xb8ac, 0x9005, 0x01b8,
+	0x2068, 0x2079, 0x0000, 0x2c08, 0x911e, 0x1118, 0x680c, 0xb8ae,
+	0x0060, 0x9106, 0x0140, 0x2d00, 0x2078, 0x680c, 0x9005, 0x090c,
+	0x0d7d, 0x2068, 0x0cb0, 0x6b0c, 0x7b0e, 0x600f, 0x0000, 0x2079,
+	0x0300, 0x781b, 0x0200, 0x003e, 0x00de, 0x00fe, 0x0005, 0x00e6,
+	0x00d6, 0x0096, 0x00c6, 0x0036, 0x0126, 0x2091, 0x8000, 0x0156,
+	0x20a9, 0x01ff, 0x2071, 0x0300, 0x701b, 0x0200, 0x7018, 0xd094,
+	0x0110, 0x1f04, 0x8f5c, 0x701b, 0x0202, 0xa001, 0xa001, 0x7018,
+	0xd094, 0x1d90, 0xb8ac, 0x9005, 0x01d0, 0x2060, 0x600c, 0xb8ae,
+	0x6003, 0x0004, 0x601b, 0x0000, 0x6013, 0x0000, 0x601f, 0x0101,
+	0x6014, 0x2048, 0xa88b, 0x0000, 0xa8a8, 0xa8ab, 0x0000, 0x904d,
+	0x090c, 0x0d7d, 0x080c, 0x1079, 0x080c, 0x8b15, 0x0c18, 0x2071,
+	0x0300, 0x701b, 0x0200, 0x015e, 0x012e, 0x003e, 0x00ce, 0x009e,
+	0x00de, 0x00ee, 0x0005, 0x00c6, 0x00b6, 0x0016, 0x0006, 0x0156,
+	0x080c, 0x2630, 0x015e, 0x11b0, 0x080c, 0x65e3, 0x190c, 0x0d7d,
+	0x000e, 0x001e, 0xb912, 0xb816, 0x080c, 0xab9a, 0x0140, 0x2b00,
+	0x6012, 0x6023, 0x0001, 0x2009, 0x0001, 0x080c, 0xac8d, 0x00be,
+	0x00ce, 0x0005, 0x000e, 0x001e, 0x0cd0, 0x0066, 0x6000, 0x90b2,
+	0x0016, 0x1a0c, 0x0d7d, 0x0013, 0x006e, 0x0005, 0x8fce, 0x8fce,
+	0x8fce, 0x8fd0, 0x9019, 0x8fce, 0x8fce, 0x8fce, 0x907c, 0x8fce,
+	0x90b4, 0x8fce, 0x8fce, 0x8fce, 0x8fce, 0x8fce, 0x080c, 0x0d7d,
+	0x9182, 0x0040, 0x0002, 0x8fe3, 0x8fe3, 0x8fe3, 0x8fe3, 0x8fe3,
+	0x8fe3, 0x8fe3, 0x8fe3, 0x8fe3, 0x8fe5, 0x8ff6, 0x8fe3, 0x8fe3,
+	0x8fe3, 0x8fe3, 0x9007, 0x080c, 0x0d7d, 0x0096, 0x6114, 0x2148,
+	0xa87b, 0x0000, 0x6010, 0x00b6, 0x2058, 0xb8bb, 0x0500, 0x00be,
+	0x080c, 0x6b9f, 0x080c, 0xabf0, 0x009e, 0x0005, 0x080c, 0x965a,
+	0x00d6, 0x6114, 0x080c, 0xc865, 0x0130, 0x0096, 0x6114, 0x2148,
+	0x080c, 0x6d9f, 0x009e, 0x00de, 0x080c, 0xabf0, 0x0005, 0x080c,
+	0x965a, 0x080c, 0x320f, 0x6114, 0x0096, 0x2148, 0x080c, 0xc865,
+	0x0120, 0xa87b, 0x0029, 0x080c, 0x6d9f, 0x009e, 0x080c, 0xabf0,
+	0x0005, 0x601b, 0x0000, 0x9182, 0x0040, 0x0096, 0x0002, 0x9034,
+	0x9034, 0x9034, 0x9034, 0x9034, 0x9034, 0x9034, 0x9034, 0x9036,
+	0x9034, 0x9034, 0x9034, 0x9078, 0x9034, 0x9034, 0x9034, 0x9034,
+	0x9034, 0x9034, 0x903c, 0x9034, 0x080c, 0x0d7d, 0x6114, 0x2148,
+	0xa938, 0x918e, 0xffff, 0x05e0, 0x00e6, 0x6114, 0x2148, 0x080c,
+	0x8deb, 0x0096, 0xa8a8, 0x2048, 0x080c, 0x6b37, 0x009e, 0xa8ab,
+	0x0000, 0x6010, 0x9005, 0x0128, 0x00b6, 0x2058, 0x080c, 0x8f1c,
+	0x00be, 0xae88, 0x00b6, 0x2059, 0x0000, 0x080c, 0x8b1e, 0x00be,
+	0x01e0, 0x2071, 0x193c, 0x080c, 0x8b65, 0x01b8, 0x9086, 0x0001,
+	0x1128, 0x2001, 0x1946, 0x2004, 0x9005, 0x1178, 0x0096, 0x080c,
+	0x1047, 0x2900, 0x009e, 0x0148, 0xa8aa, 0x00f6, 0x2c78, 0x080c,
+	0x8ad9, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x080c, 0x8b15, 0x0cd0,
+	0x080c, 0x9130, 0x009e, 0x0005, 0x9182, 0x0040, 0x0096, 0x0002,
+	0x9090, 0x9090, 0x9090, 0x9092, 0x9090, 0x9090, 0x9090, 0x90b2,
+	0x9090, 0x9090, 0x9090, 0x9090, 0x9090, 0x9090, 0x9090, 0x9090,
+	0x080c, 0x0d7d, 0x6003, 0x0003, 0x6106, 0x6014, 0x2048, 0xa8ac,
+	0xa836, 0xa8b0, 0xa83a, 0xa847, 0x0000, 0xa84b, 0x0000, 0xa884,
+	0x9092, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x8013, 0x8213,
+	0x9210, 0x621a, 0x080c, 0x1bdf, 0x2009, 0x8030, 0x080c, 0x9280,
+	0x009e, 0x0005, 0x080c, 0x0d7d, 0x080c, 0x965a, 0x6114, 0x2148,
+	0xa87b, 0x0000, 0x6010, 0x00b6, 0x2058, 0xb8bb, 0x0500, 0x00be,
+	0x080c, 0x6d9f, 0x080c, 0xabf0, 0x009e, 0x0005, 0x080c, 0xa899,
+	0x6144, 0xd1fc, 0x0120, 0xd1ac, 0x1110, 0x6003, 0x0003, 0x6000,
+	0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0096, 0x0023, 0x009e, 0x080c,
+	0xa8b5, 0x0005, 0x90ea, 0x90ea, 0x90ea, 0x90ec, 0x90fd, 0x90ea,
+	0x90ea, 0x90ea, 0x90ea, 0x90ea, 0x90ea, 0x90ea, 0x90ea, 0x90ea,
+	0x90ea, 0x90ea, 0x080c, 0x0d7d, 0x080c, 0xaa2d, 0x6114, 0x2148,
+	0xa87b, 0x0006, 0x6010, 0x00b6, 0x2058, 0xb8bb, 0x0500, 0x00be,
+	0x080c, 0x6d9f, 0x080c, 0xabf0, 0x0005, 0x0491, 0x0005, 0x080c,
+	0xa899, 0x6000, 0x6144, 0xd1fc, 0x0130, 0xd1ac, 0x1120, 0x6003,
+	0x0003, 0x2009, 0x0003, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0096,
+	0x0033, 0x009e, 0x0106, 0x080c, 0xa8b5, 0x010e, 0x0005, 0x9127,
+	0x9127, 0x9127, 0x9129, 0x9130, 0x9127, 0x9127, 0x9127, 0x9127,
+	0x9127, 0x9127, 0x9127, 0x9127, 0x9127, 0x9127, 0x9127, 0x080c,
+	0x0d7d, 0x0036, 0x00e6, 0x080c, 0xaa2d, 0x00ee, 0x003e, 0x0005,
+	0x00f6, 0x00e6, 0x601b, 0x0000, 0x6014, 0x2048, 0x6010, 0x9005,
+	0x0128, 0x00b6, 0x2058, 0x080c, 0x8f1c, 0x00be, 0x2071, 0x193c,
+	0x080c, 0x8b65, 0x0160, 0x2001, 0x187f, 0x2004, 0xa88a, 0x2031,
+	0x0000, 0x2c78, 0x080c, 0x8ad9, 0x00ee, 0x00fe, 0x0005, 0x0096,
+	0xa88b, 0x0000, 0xa8a8, 0x2048, 0x080c, 0x1079, 0x009e, 0xa8ab,
+	0x0000, 0x080c, 0x8b15, 0x0c80, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x187a, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0126, 0x2091, 0x8000, 0x0036,
+	0x0046, 0x20a9, 0x0010, 0x9006, 0x8004, 0x8086, 0x818e, 0x1208,
+	0x9200, 0x1f04, 0x9175, 0x8086, 0x818e, 0x004e, 0x003e, 0x012e,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x0076, 0x0156, 0x20a9, 0x0010,
+	0x9005, 0x01c8, 0x911a, 0x12b8, 0x8213, 0x818d, 0x0228, 0x911a,
+	0x1220, 0x1f04, 0x918c, 0x0028, 0x911a, 0x2308, 0x8210, 0x1f04,
+	0x918c, 0x0006, 0x3200, 0x9084, 0xefff, 0x2080, 0x000e, 0x015e,
+	0x007e, 0x012e, 0x0005, 0x0006, 0x3200, 0x9085, 0x1000, 0x0ca8,
+	0x0126, 0x2091, 0x2800, 0x2079, 0x19e6, 0x012e, 0x00d6, 0x2069,
+	0x19e6, 0x6803, 0x0005, 0x0156, 0x0146, 0x01d6, 0x20e9, 0x0000,
+	0x2069, 0x0200, 0x080c, 0xa68e, 0x04a9, 0x080c, 0xa679, 0x0491,
+	0x080c, 0xa67c, 0x0479, 0x080c, 0xa67f, 0x0461, 0x080c, 0xa682,
+	0x0449, 0x080c, 0xa685, 0x0431, 0x080c, 0xa688, 0x0419, 0x080c,
+	0xa68b, 0x0401, 0x01de, 0x014e, 0x015e, 0x6857, 0x0000, 0x00f6,
+	0x2079, 0x0380, 0x00f9, 0x7807, 0x0003, 0x7803, 0x0000, 0x7803,
+	0x0001, 0x2069, 0x0004, 0x2d04, 0x9084, 0xfffe, 0x9085, 0x8000,
+	0x206a, 0x2069, 0x0100, 0x6828, 0x9084, 0xfffc, 0x682a, 0x00fe,
+	0x00de, 0x0005, 0x20a9, 0x0020, 0x20a1, 0x0240, 0x2001, 0x0000,
+	0x4004, 0x0005, 0x00c6, 0x7803, 0x0000, 0x9006, 0x7827, 0x0030,
+	0x782b, 0x0400, 0x7827, 0x0031, 0x782b, 0x1aee, 0x781f, 0xff00,
+	0x781b, 0xff00, 0x2061, 0x1ae3, 0x602f, 0x19e6, 0x6033, 0x1800,
+	0x6037, 0x1a02, 0x603b, 0x1e7a, 0x603f, 0x1e8a, 0x6042, 0x6047,
+	0x1ab9, 0x00ce, 0x0005, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007,
+	0x9086, 0x0001, 0x01b0, 0x00c6, 0x6146, 0x600f, 0x0000, 0x2c08,
+	0x2061, 0x19e6, 0x602c, 0x8000, 0x602e, 0x601c, 0x9005, 0x0130,
+	0x9080, 0x0003, 0x2102, 0x611e, 0x00ce, 0x0005, 0x6122, 0x611e,
+	0x0cd8, 0x6146, 0x2c08, 0x2001, 0x0012, 0x080c, 0xa88a, 0x0005,
+	0x0016, 0x2009, 0x8020, 0x6146, 0x2c08, 0x2001, 0x0382, 0x2004,
+	0x9084, 0x0007, 0x9086, 0x0001, 0x1128, 0x2001, 0x0019, 0x080c,
+	0xa88a, 0x0088, 0x00c6, 0x2061, 0x19e6, 0x602c, 0x8000, 0x602e,
+	0x600c, 0x9005, 0x0128, 0x9080, 0x0003, 0x2102, 0x610e, 0x0010,
+	0x6112, 0x610e, 0x00ce, 0x001e, 0x0005, 0x2001, 0x0382, 0x2004,
+	0x9084, 0x0007, 0x9086, 0x0001, 0x0198, 0x00c6, 0x6146, 0x600f,
+	0x0000, 0x2c08, 0x2061, 0x19e6, 0x6044, 0x9005, 0x0130, 0x9080,
+	0x0003, 0x2102, 0x6146, 0x00ce, 0x0005, 0x614a, 0x6146, 0x0cd8,
+	0x6146, 0x600f, 0x0000, 0x2c08, 0x2001, 0x0013, 0x080c, 0xa88a,
+	0x0005, 0x6044, 0xd0dc, 0x0110, 0x080c, 0xa327, 0x0005, 0x00f6,
+	0x00e6, 0x00d6, 0x00c6, 0x00b6, 0x0096, 0x0076, 0x0066, 0x0056,
+	0x0036, 0x0026, 0x0016, 0x0006, 0x0126, 0x902e, 0x2071, 0x19e6,
+	0x7648, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff, 0x0904, 0x930c,
+	0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x9307, 0x87ff, 0x0120,
+	0x605c, 0x9106, 0x1904, 0x9307, 0x704c, 0x9c06, 0x1178, 0x0036,
+	0x2019, 0x0001, 0x080c, 0xa133, 0x703f, 0x0000, 0x9006, 0x704e,
+	0x706a, 0x7052, 0x706e, 0x003e, 0x2029, 0x0001, 0x0811, 0x7048,
+	0x9c36, 0x1110, 0x660c, 0x764a, 0x7044, 0x9c36, 0x1140, 0x2c00,
+	0x9f36, 0x0118, 0x2f00, 0x7046, 0x0010, 0x7047, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
+	0x0000, 0x080c, 0xc865, 0x01f0, 0x6014, 0x2048, 0x6020, 0x9086,
+	0x0003, 0x1588, 0x6004, 0x9086, 0x0040, 0x090c, 0xa327, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036, 0x0076, 0x080c,
+	0xcb68, 0x080c, 0xe66e, 0x080c, 0x6d9f, 0x007e, 0x003e, 0x001e,
+	0x080c, 0xca54, 0x080c, 0xac2b, 0x00ce, 0x0804, 0x92a5, 0x2c78,
+	0x600c, 0x2060, 0x0804, 0x92a5, 0x012e, 0x000e, 0x001e, 0x002e,
+	0x003e, 0x005e, 0x006e, 0x007e, 0x009e, 0x00be, 0x00ce, 0x00de,
+	0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016,
+	0x0036, 0x0076, 0x080c, 0xe66e, 0x080c, 0xe2b9, 0x007e, 0x003e,
+	0x001e, 0x08c0, 0x6020, 0x9086, 0x0009, 0x1168, 0xa87b, 0x0006,
+	0x0016, 0x0036, 0x0076, 0x080c, 0x6d9f, 0x080c, 0xabf0, 0x007e,
+	0x003e, 0x001e, 0x0848, 0x6020, 0x9086, 0x000a, 0x0904, 0x92f1,
+	0x0804, 0x92ea, 0x0006, 0x0066, 0x0096, 0x00c6, 0x00d6, 0x00f6,
+	0x9036, 0x0126, 0x2091, 0x8000, 0x2079, 0x19e6, 0x7848, 0x9065,
+	0x0904, 0x93a6, 0x600c, 0x0006, 0x600f, 0x0000, 0x784c, 0x9c06,
+	0x11a0, 0x0036, 0x2019, 0x0001, 0x080c, 0xa133, 0x783f, 0x0000,
+	0x901e, 0x7b4e, 0x7b6a, 0x7b52, 0x7b6e, 0x003e, 0x000e, 0x9005,
+	0x1118, 0x600c, 0x600f, 0x0000, 0x0006, 0x00e6, 0x2f70, 0x080c,
+	0x9289, 0x00ee, 0x080c, 0xc865, 0x0548, 0x6014, 0x2048, 0x6020,
+	0x9086, 0x0003, 0x15a8, 0x3e08, 0x918e, 0x0002, 0x1188, 0x6010,
+	0x9005, 0x0170, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140,
+	0x6048, 0x9005, 0x11c0, 0x2001, 0x1987, 0x2004, 0x604a, 0x0098,
+	0x6004, 0x9086, 0x0040, 0x090c, 0xa327, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x080c, 0x6d93, 0x080c, 0xca54, 0x6044, 0xc0fc,
+	0x6046, 0x080c, 0xac2b, 0x000e, 0x0804, 0x934f, 0x7e4a, 0x7e46,
+	0x012e, 0x00fe, 0x00de, 0x00ce, 0x009e, 0x006e, 0x000e, 0x0005,
+	0x6020, 0x9086, 0x0006, 0x1118, 0x080c, 0xe2b9, 0x0c38, 0x6020,
+	0x9086, 0x0009, 0x1130, 0xab7a, 0x080c, 0x6d9f, 0x080c, 0xabf0,
+	0x0c10, 0x6020, 0x9086, 0x000a, 0x0990, 0x0850, 0x0016, 0x0026,
+	0x0086, 0x9046, 0x00a9, 0x080c, 0x94b7, 0x008e, 0x002e, 0x001e,
+	0x0005, 0x00f6, 0x0126, 0x2079, 0x19e6, 0x2091, 0x8000, 0x080c,
+	0x9500, 0x080c, 0x9594, 0x080c, 0x67d1, 0x012e, 0x00fe, 0x0005,
+	0x00b6, 0x0096, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0016,
+	0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7620, 0x2660,
+	0x2678, 0x8cff, 0x0904, 0x947c, 0x6010, 0x2058, 0xb8a0, 0x9206,
+	0x1904, 0x9477, 0x88ff, 0x0120, 0x605c, 0x9106, 0x1904, 0x9477,
+	0x7030, 0x9c06, 0x1570, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508,
+	0x080c, 0x8709, 0x080c, 0x9e4f, 0x68c3, 0x0000, 0x080c, 0xa327,
+	0x7033, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000,
+	0x0138, 0x2001, 0x0100, 0x080c, 0x2a49, 0x9006, 0x080c, 0x2a49,
 	0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e,
-	0x0058, 0x080c, 0x6a02, 0x1538, 0x6003, 0x0009, 0x630a, 0x7808,
-	0xc0ad, 0x780a, 0x2c30, 0x00f8, 0x6014, 0x2048, 0x080c, 0xc830,
-	0x01b0, 0x6020, 0x9086, 0x0003, 0x1508, 0x080c, 0xca47, 0x1118,
-	0x080c, 0xb5a6, 0x0060, 0x080c, 0x6a02, 0x1168, 0xa867, 0x0103,
-	0xab7a, 0xa877, 0x0000, 0x080c, 0x6d7b, 0x080c, 0xca21, 0x080c,
-	0xac1a, 0x080c, 0xa1f0, 0x000e, 0x0804, 0x94ce, 0x7e22, 0x7e1e,
-	0x00de, 0x00ce, 0x006e, 0x000e, 0x009e, 0x0005, 0x6020, 0x9086,
-	0x0006, 0x1118, 0x080c, 0xe27c, 0x0c50, 0x080c, 0xb5a6, 0x6020,
-	0x9086, 0x0002, 0x1150, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e,
-	0x0990, 0x9086, 0x008b, 0x0978, 0x08d0, 0x6020, 0x9086, 0x0005,
-	0x19b0, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0d18, 0x9086,
-	0x008b, 0x0d00, 0x0860, 0x0006, 0x0096, 0x00b6, 0x00c6, 0x0066,
-	0x9036, 0x7828, 0x9065, 0x0510, 0x6010, 0x2058, 0x600c, 0x0006,
-	0x3e08, 0x918e, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x11a8, 0x6043,
-	0xffff, 0x080c, 0xaa67, 0x0180, 0x610c, 0x080c, 0x9f84, 0x6014,
-	0x2048, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6d7b,
-	0x080c, 0xac1a, 0x000e, 0x08f0, 0x2c30, 0x0ce0, 0x006e, 0x00ce,
-	0x00be, 0x009e, 0x000e, 0x0005, 0x00e6, 0x00d6, 0x0096, 0x0066,
-	0x080c, 0x6136, 0x11b0, 0x2071, 0x19e6, 0x7030, 0x9080, 0x0005,
-	0x2004, 0x904d, 0x0170, 0xa878, 0x9606, 0x1158, 0x2071, 0x19e6,
-	0x7030, 0x9035, 0x0130, 0x9080, 0x0005, 0x2004, 0x9906, 0x1108,
-	0x0029, 0x006e, 0x009e, 0x00de, 0x00ee, 0x0005, 0x00c6, 0x2660,
-	0x6043, 0xffff, 0x080c, 0xaa67, 0x0178, 0x080c, 0x9f84, 0x6014,
-	0x2048, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0xcb35,
-	0x080c, 0x6d7b, 0x080c, 0xac1a, 0x00ce, 0x0005, 0x00b6, 0x00e6,
-	0x00c6, 0x080c, 0xa888, 0x0106, 0x2071, 0x0101, 0x2e04, 0xc0c4,
-	0x2072, 0x6044, 0xd0fc, 0x1138, 0x010e, 0x090c, 0xa8a4, 0x00ce,
-	0x00ee, 0x00be, 0x0005, 0x2071, 0x19e6, 0x7030, 0x9005, 0x0da0,
-	0x9c06, 0x190c, 0x0d7d, 0x7036, 0x080c, 0x86d5, 0x7004, 0x9084,
-	0x0007, 0x0002, 0x95f4, 0x95f6, 0x95fd, 0x9607, 0x9615, 0x95f4,
-	0x9602, 0x95f2, 0x080c, 0x0d7d, 0x0428, 0x0005, 0x080c, 0xaa52,
-	0x7007, 0x0000, 0x7033, 0x0000, 0x00e8, 0x0066, 0x9036, 0x080c,
-	0x9f84, 0x006e, 0x7007, 0x0000, 0x7033, 0x0000, 0x0098, 0x080c,
-	0xaa3d, 0x0140, 0x080c, 0xaa52, 0x0128, 0x0066, 0x9036, 0x080c,
-	0x9f84, 0x006e, 0x7033, 0x0000, 0x0028, 0x080c, 0xaa3d, 0x080c,
-	0xa31a, 0x0000, 0x010e, 0x190c, 0xa8a4, 0x00ce, 0x00ee, 0x00be,
-	0x0005, 0x00d6, 0x00c6, 0x080c, 0xa888, 0x0106, 0x6044, 0xd0fc,
-	0x1130, 0x010e, 0x090c, 0xa8a4, 0x00ce, 0x00de, 0x0005, 0x2069,
-	0x19e6, 0x684c, 0x9005, 0x0da8, 0x9c06, 0x190c, 0x0d7d, 0x6852,
-	0x00e6, 0x2d70, 0x080c, 0x9250, 0x00ee, 0x080c, 0x86e2, 0x0016,
-	0x2009, 0x0040, 0x080c, 0x21c1, 0x001e, 0x683c, 0x9084, 0x0003,
-	0x0002, 0x964f, 0x9650, 0x966e, 0x964d, 0x080c, 0x0d7d, 0x0460,
-	0x6868, 0x9086, 0x0001, 0x0190, 0x600c, 0x9015, 0x0160, 0x6a4a,
-	0x600f, 0x0000, 0x6044, 0xc0fc, 0x6046, 0x9006, 0x7042, 0x684e,
-	0x683f, 0x0000, 0x00c8, 0x684a, 0x6846, 0x0ca0, 0x686b, 0x0000,
-	0x6848, 0x9065, 0x0d78, 0x6003, 0x0002, 0x0c60, 0x9006, 0x686a,
-	0x6852, 0x686e, 0x600c, 0x9015, 0x0120, 0x6a4a, 0x600f, 0x0000,
-	0x0018, 0x684e, 0x684a, 0x6846, 0x684f, 0x0000, 0x010e, 0x190c,
-	0xa8a4, 0x00ce, 0x00de, 0x0005, 0x0005, 0x6020, 0x9084, 0x000f,
-	0x000b, 0x0005, 0x969a, 0x969d, 0x9b0b, 0x9b9a, 0x969d, 0x9b0b,
-	0x9b9a, 0x969a, 0x969d, 0x969a, 0x969a, 0x969a, 0x969a, 0x969a,
-	0x969a, 0x969a, 0x080c, 0x95c6, 0x0005, 0x00b6, 0x0156, 0x0136,
-	0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2069,
-	0x0200, 0x2071, 0x0240, 0x6004, 0x908a, 0x0053, 0x1a0c, 0x0d7d,
-	0x6110, 0x2158, 0xb984, 0x2c78, 0x2061, 0x0100, 0x619a, 0x908a,
-	0x0040, 0x1a04, 0x9709, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce,
-	0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0x988e,
-	0x98c9, 0x98f2, 0x999a, 0x99bc, 0x99c2, 0x99cf, 0x99d7, 0x99e3,
-	0x99e9, 0x99fa, 0x99e9, 0x9a52, 0x99d7, 0x9a5e, 0x9a64, 0x99e3,
-	0x9a64, 0x9a70, 0x9707, 0x9707, 0x9707, 0x9707, 0x9707, 0x9707,
-	0x9707, 0x9707, 0x9707, 0x9707, 0x9707, 0x9fa5, 0x9fc8, 0x9fd9,
-	0x9ff9, 0xa02b, 0x99cf, 0x9707, 0x99cf, 0x99e9, 0x9707, 0x98f2,
-	0x999a, 0x9707, 0xa418, 0x99e9, 0x9707, 0xa434, 0x99e9, 0x9707,
-	0x99e3, 0x9888, 0x972a, 0x9707, 0xa450, 0xa4bd, 0xa59d, 0x9707,
-	0xa5aa, 0x99cc, 0xa5d5, 0x9707, 0xa035, 0xa5e1, 0x9707, 0x080c,
-	0x0d7d, 0x2100, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de,
-	0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0xa681, 0xa733,
-	0x9728, 0x9751, 0x97fd, 0x9808, 0x9728, 0x99cf, 0x9728, 0x984f,
-	0x985b, 0x976c, 0x9728, 0x9787, 0x97bb, 0xaabd, 0xab02, 0x99e9,
-	0x080c, 0x0d7d, 0x00d6, 0x0096, 0x080c, 0x9a83, 0x7003, 0x2414,
-	0x7007, 0x0018, 0x700b, 0x0800, 0x7814, 0x2048, 0xa83c, 0x700e,
-	0xa850, 0x7022, 0xa854, 0x7026, 0x60c3, 0x0018, 0x080c, 0x9de6,
-	0x009e, 0x00de, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb8a0, 0x00be,
-	0x080c, 0xab49, 0x1118, 0x9084, 0xff80, 0x0110, 0x9085, 0x0001,
-	0x0005, 0x00d6, 0x0096, 0x080c, 0x9a83, 0x7003, 0x0500, 0x7814,
-	0x2048, 0xa874, 0x700a, 0xa878, 0x700e, 0xa87c, 0x7012, 0xa880,
-	0x7016, 0xa884, 0x701a, 0xa888, 0x701e, 0x60c3, 0x0010, 0x080c,
-	0x9de6, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x080c, 0x9a83,
-	0x7003, 0x0500, 0x7814, 0x2048, 0xa8cc, 0x700a, 0xa8d0, 0x700e,
-	0xa8d4, 0x7012, 0xa8d8, 0x7016, 0xa8dc, 0x701a, 0xa8e0, 0x701e,
-	0x60c3, 0x0010, 0x080c, 0x9de6, 0x009e, 0x00de, 0x0005, 0x00d6,
-	0x0096, 0x0126, 0x2091, 0x8000, 0x080c, 0x9a83, 0x20e9, 0x0000,
-	0x2001, 0x19a2, 0x2003, 0x0000, 0x7814, 0x2048, 0xa814, 0x8003,
-	0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b,
-	0x2098, 0x2001, 0x19a2, 0x0016, 0x200c, 0x2001, 0x0001, 0x080c,
-	0x21a6, 0x080c, 0xd5be, 0x9006, 0x080c, 0x21a6, 0x001e, 0xa804,
-	0x9005, 0x0110, 0x2048, 0x0c28, 0x04d9, 0x080c, 0x9de6, 0x012e,
-	0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x9ace, 0x20e9, 0x0000, 0x2001, 0x19a2, 0x2003, 0x0000,
-	0x7814, 0x2048, 0xa86f, 0x0200, 0xa873, 0x0000, 0xa814, 0x8003,
-	0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b,
-	0x2098, 0x2001, 0x19a2, 0x0016, 0x200c, 0x080c, 0xd5be, 0x001e,
-	0xa804, 0x9005, 0x0110, 0x2048, 0x0c60, 0x0051, 0x7814, 0x2048,
-	0x080c, 0x0fec, 0x080c, 0x9de6, 0x012e, 0x009e, 0x00de, 0x0005,
-	0x60c0, 0x8004, 0x9084, 0x0003, 0x9005, 0x0130, 0x9082, 0x0004,
-	0x20a3, 0x0000, 0x8000, 0x1de0, 0x0005, 0x080c, 0x9a83, 0x7003,
-	0x7800, 0x7808, 0x8007, 0x700a, 0x60c3, 0x0008, 0x0804, 0x9de6,
-	0x00d6, 0x00e6, 0x080c, 0x9ace, 0x7814, 0x9084, 0xff00, 0x2073,
-	0x0200, 0x8e70, 0x8e70, 0x9095, 0x0010, 0x2272, 0x8e70, 0x2073,
-	0x0034, 0x8e70, 0x2069, 0x1805, 0x20a9, 0x0004, 0x2d76, 0x8d68,
-	0x8e70, 0x1f04, 0x981e, 0x2069, 0x1801, 0x20a9, 0x0004, 0x2d76,
-	0x8d68, 0x8e70, 0x1f04, 0x9827, 0x2069, 0x19b2, 0x9086, 0xdf00,
-	0x0110, 0x2069, 0x19cc, 0x20a9, 0x001a, 0x9e86, 0x0260, 0x1148,
-	0x00c6, 0x2061, 0x0200, 0x6010, 0x8000, 0x6012, 0x00ce, 0x2071,
-	0x0240, 0x2d04, 0x8007, 0x2072, 0x8d68, 0x8e70, 0x1f04, 0x9835,
-	0x60c3, 0x004c, 0x080c, 0x9de6, 0x00ee, 0x00de, 0x0005, 0x080c,
-	0x9a83, 0x7003, 0x6300, 0x7007, 0x0028, 0x7808, 0x700e, 0x60c3,
-	0x0008, 0x0804, 0x9de6, 0x00d6, 0x0026, 0x0016, 0x080c, 0x9ace,
-	0x7003, 0x0200, 0x7814, 0x700e, 0x00e6, 0x9ef0, 0x0004, 0x2009,
-	0x0001, 0x2011, 0x000c, 0x2069, 0x1923, 0x6810, 0xd084, 0x1148,
-	0x2073, 0x0500, 0x8e70, 0x2073, 0x0000, 0x8e70, 0x8108, 0x9290,
-	0x0004, 0x2073, 0x0800, 0x8e70, 0x2073, 0x0000, 0x00ee, 0x7206,
-	0x710a, 0x62c2, 0x080c, 0x9de6, 0x001e, 0x002e, 0x00de, 0x0005,
-	0x2001, 0x1818, 0x2004, 0x609a, 0x0804, 0x9de6, 0x080c, 0x9a83,
-	0x7003, 0x5200, 0x2069, 0x1847, 0x6804, 0xd084, 0x0130, 0x6828,
-	0x0016, 0x080c, 0x2647, 0x710e, 0x001e, 0x20a9, 0x0004, 0x20e1,
-	0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003,
-	0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x0254, 0x4003, 0x080c,
-	0xab49, 0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181f,
-	0x2004, 0x7032, 0x2001, 0x1820, 0x2004, 0x7036, 0x0030, 0x2001,
-	0x1818, 0x2004, 0x9084, 0x00ff, 0x7036, 0x60c3, 0x001c, 0x0804,
-	0x9de6, 0x080c, 0x9a83, 0x7003, 0x0500, 0x080c, 0xab49, 0x1120,
-	0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181f, 0x2004, 0x700a,
-	0x2001, 0x1820, 0x2004, 0x700e, 0x0030, 0x2001, 0x1818, 0x2004,
-	0x9084, 0x00ff, 0x700e, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099,
-	0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003, 0x60c3, 0x0010,
-	0x0804, 0x9de6, 0x080c, 0x9a83, 0x9006, 0x080c, 0x6a34, 0xb8a0,
-	0x9086, 0x007e, 0x1130, 0x7003, 0x0400, 0x620c, 0xc2b4, 0x620e,
-	0x0058, 0x7814, 0x0096, 0x904d, 0x0120, 0x9006, 0xa89a, 0xa8a6,
-	0xa8aa, 0x009e, 0x7003, 0x0300, 0xb8a0, 0x9086, 0x007e, 0x1904,
-	0x9961, 0x00d6, 0x2069, 0x196b, 0x2001, 0x1837, 0x2004, 0xd0a4,
-	0x0188, 0x6800, 0x700a, 0x6808, 0x9084, 0x2000, 0x7012, 0x080c,
-	0xab60, 0x680c, 0x7016, 0x701f, 0x2710, 0x6818, 0x7022, 0x681c,
-	0x7026, 0x0090, 0x6800, 0x700a, 0x6804, 0x700e, 0x6808, 0x080c,
-	0x74c8, 0x1118, 0x9084, 0x37ff, 0x0010, 0x9084, 0x3fff, 0x7012,
-	0x080c, 0xab60, 0x680c, 0x7016, 0x00de, 0x20a9, 0x0004, 0x20e1,
-	0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256, 0x4003,
-	0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x00d6,
-	0x080c, 0xa668, 0x2069, 0x1973, 0x2071, 0x024e, 0x6800, 0xc0dd,
-	0x7002, 0x080c, 0x56d9, 0xd0e4, 0x0110, 0x680c, 0x700e, 0x00de,
-	0x04a8, 0x2001, 0x1837, 0x2004, 0xd0a4, 0x0170, 0x0016, 0x2001,
-	0x196c, 0x200c, 0x60e0, 0x9106, 0x0130, 0x2100, 0x60e3, 0x0000,
-	0x080c, 0x2688, 0x61e2, 0x001e, 0x20e1, 0x0001, 0x2099, 0x196b,
-	0x20e9, 0x0000, 0x20a1, 0x024e, 0x20a9, 0x0008, 0x4003, 0x20a9,
-	0x0004, 0x2099, 0x1805, 0x20a1, 0x0256, 0x4003, 0x20a9, 0x0004,
-	0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x080c, 0xa668, 0x20a1,
-	0x024e, 0x20a9, 0x0008, 0x2099, 0x1973, 0x4003, 0x60c3, 0x0074,
-	0x0804, 0x9de6, 0x080c, 0x9a83, 0x7003, 0x2010, 0x7007, 0x0014,
-	0x700b, 0x0800, 0x700f, 0x2000, 0x9006, 0x00f6, 0x2079, 0x1847,
-	0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0xd1a4, 0x0110,
-	0x9085, 0x0010, 0x9085, 0x0002, 0x00d6, 0x0804, 0x9a33, 0x7026,
-	0x60c3, 0x0014, 0x0804, 0x9de6, 0x080c, 0x9a83, 0x7003, 0x5000,
-	0x0804, 0x990c, 0x080c, 0x9a83, 0x7003, 0x2110, 0x7007, 0x0014,
-	0x60c3, 0x0014, 0x0804, 0x9de6, 0x080c, 0x9ac5, 0x0010, 0x080c,
-	0x9ace, 0x7003, 0x0200, 0x60c3, 0x0004, 0x0804, 0x9de6, 0x080c,
-	0x9ace, 0x7003, 0x0100, 0x700b, 0x0003, 0x700f, 0x2a00, 0x60c3,
-	0x0008, 0x0804, 0x9de6, 0x080c, 0x9ace, 0x7003, 0x0200, 0x0804,
-	0x990c, 0x080c, 0x9ace, 0x7003, 0x0100, 0x782c, 0x9005, 0x0110,
-	0x700a, 0x0010, 0x700b, 0x0003, 0x7814, 0x700e, 0x60c3, 0x0008,
-	0x0804, 0x9de6, 0x00d6, 0x080c, 0x9ace, 0x7003, 0x0210, 0x7007,
-	0x0014, 0x700b, 0x0800, 0xb894, 0x9086, 0x0014, 0x1198, 0xb99c,
-	0x9184, 0x0030, 0x0190, 0xb998, 0x9184, 0xc000, 0x1140, 0xd1ec,
-	0x0118, 0x700f, 0x2100, 0x0058, 0x700f, 0x0100, 0x0040, 0x700f,
-	0x0400, 0x0028, 0x700f, 0x0700, 0x0010, 0x700f, 0x0800, 0x00f6,
-	0x2079, 0x1847, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020,
-	0xd1a4, 0x0110, 0x9085, 0x0010, 0x2009, 0x1869, 0x210c, 0xd184,
-	0x1110, 0x9085, 0x0002, 0x0026, 0x2009, 0x1867, 0x210c, 0xd1e4,
-	0x0150, 0xc0c5, 0xbad4, 0xd28c, 0x1108, 0xc0cd, 0x9094, 0x0030,
-	0x9296, 0x0010, 0x0140, 0xd1ec, 0x0130, 0x9094, 0x0030, 0x9296,
-	0x0010, 0x0108, 0xc0bd, 0x002e, 0x7026, 0x60c3, 0x0014, 0x00de,
-	0x0804, 0x9de6, 0x080c, 0x9ace, 0x7003, 0x0210, 0x7007, 0x0014,
-	0x700f, 0x0100, 0x60c3, 0x0014, 0x0804, 0x9de6, 0x080c, 0x9ace,
-	0x7003, 0x0200, 0x0804, 0x9892, 0x080c, 0x9ace, 0x7003, 0x0100,
-	0x700b, 0x0003, 0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804, 0x9de6,
-	0x080c, 0x9ace, 0x7003, 0x0100, 0x700b, 0x000b, 0x60c3, 0x0008,
-	0x0804, 0x9de6, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x3200,
-	0x2021, 0x0800, 0x0040, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019,
-	0x2200, 0x2021, 0x0100, 0x080c, 0xa67d, 0xb810, 0x9305, 0x7002,
-	0xb814, 0x7006, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e,
-	0x9485, 0x0029, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c, 0x9dda,
-	0x721a, 0x9f95, 0x0000, 0x7222, 0x7027, 0xffff, 0x2071, 0x024c,
-	0x002e, 0x0005, 0x0026, 0x080c, 0xa67d, 0x7003, 0x02ff, 0x7007,
-	0xfffc, 0x00d6, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e,
-	0x00de, 0x7013, 0x2029, 0x0c10, 0x7003, 0x0100, 0x7007, 0x0000,
-	0x700b, 0xfc02, 0x700f, 0x0000, 0x0005, 0x0026, 0x00d6, 0x0036,
-	0x0046, 0x2019, 0x3300, 0x2021, 0x0800, 0x0040, 0x0026, 0x00d6,
-	0x0036, 0x0046, 0x2019, 0x2300, 0x2021, 0x0100, 0x080c, 0xa67d,
-	0xb810, 0x9305, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0xb810,
-	0x9005, 0x1140, 0xb814, 0x9005, 0x1128, 0x700b, 0x00ff, 0x700f,
-	0xfffe, 0x0020, 0x687c, 0x700a, 0x6880, 0x700e, 0x0000, 0x9485,
-	0x0098, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c, 0x9dda, 0x721a,
-	0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c, 0x002e, 0x0005,
-	0x080c, 0x9dda, 0x721a, 0x7a08, 0x7222, 0x7814, 0x7026, 0x2071,
-	0x024c, 0x002e, 0x0005, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
-	0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a, 0x0085, 0x0a0c,
-	0x0d7d, 0x908a, 0x0092, 0x1a0c, 0x0d7d, 0x6110, 0x2158, 0xb984,
-	0x2c78, 0x2061, 0x0100, 0x619a, 0x9082, 0x0085, 0x0033, 0x00fe,
-	0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x9b3c, 0x9b4b, 0x9b56,
-	0x9b3a, 0x9b3a, 0x9b3a, 0x9b3c, 0x9b3a, 0x9b3a, 0x9b3a, 0x9b3a,
-	0x9b3a, 0x9b3a, 0x080c, 0x0d7d, 0x0411, 0x60c3, 0x0000, 0x0026,
-	0x080c, 0x2998, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012,
-	0x002e, 0x0804, 0x9de6, 0x0431, 0x7808, 0x700a, 0x7814, 0x700e,
-	0x7017, 0xffff, 0x60c3, 0x000c, 0x0804, 0x9de6, 0x0479, 0x7003,
-	0x0003, 0x7007, 0x0300, 0x60c3, 0x0004, 0x0804, 0x9de6, 0x0026,
-	0x080c, 0xa67d, 0xb810, 0x9085, 0x8100, 0x7002, 0xb814, 0x7006,
-	0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x7013, 0x0009,
-	0x0804, 0x9a9e, 0x0026, 0x080c, 0xa67d, 0xb810, 0x9085, 0x8400,
+	0x0040, 0x7008, 0xc0ad, 0x700a, 0x6003, 0x0009, 0x630a, 0x0804,
+	0x9477, 0x7020, 0x9c36, 0x1110, 0x660c, 0x7622, 0x701c, 0x9c36,
+	0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x701e, 0x0010, 0x701f,
+	0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
+	0x2678, 0x600f, 0x0000, 0x6044, 0xc0fc, 0x6046, 0x6014, 0x2048,
+	0x080c, 0xc865, 0x01e8, 0x6020, 0x9086, 0x0003, 0x1580, 0x080c,
+	0xca7a, 0x1118, 0x080c, 0xb5c6, 0x0098, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x0016, 0x0036, 0x0086, 0x080c, 0xcb68, 0x080c,
+	0xe66e, 0x080c, 0x6d9f, 0x008e, 0x003e, 0x001e, 0x080c, 0xca54,
+	0x080c, 0xac2b, 0x080c, 0xa1fd, 0x00ce, 0x0804, 0x93f1, 0x2c78,
+	0x600c, 0x2060, 0x0804, 0x93f1, 0x012e, 0x000e, 0x001e, 0x006e,
+	0x00ce, 0x00de, 0x00ee, 0x00fe, 0x009e, 0x00be, 0x0005, 0x6020,
+	0x9086, 0x0006, 0x1158, 0x0016, 0x0036, 0x0086, 0x080c, 0xe66e,
+	0x080c, 0xe2b9, 0x008e, 0x003e, 0x001e, 0x08d0, 0x080c, 0xb5c6,
+	0x6020, 0x9086, 0x0002, 0x1160, 0x6004, 0x0006, 0x9086, 0x0085,
+	0x000e, 0x0904, 0x945d, 0x9086, 0x008b, 0x0904, 0x945d, 0x0840,
+	0x6020, 0x9086, 0x0005, 0x1920, 0x6004, 0x0006, 0x9086, 0x0085,
+	0x000e, 0x09c8, 0x9086, 0x008b, 0x09b0, 0x0804, 0x9470, 0x0006,
+	0x00f6, 0x00e6, 0x0096, 0x00b6, 0x00c6, 0x0066, 0x0016, 0x0126,
+	0x2091, 0x8000, 0x9280, 0x1000, 0x2004, 0x905d, 0x2079, 0x19e6,
+	0x9036, 0x7828, 0x2060, 0x8cff, 0x0538, 0x6010, 0x9b06, 0x1500,
+	0x6043, 0xffff, 0x080c, 0xaa78, 0x01d8, 0x610c, 0x0016, 0x080c,
+	0x9fbd, 0x6014, 0x2048, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000,
+	0x0016, 0x0036, 0x0086, 0x080c, 0xcb68, 0x080c, 0xe66e, 0x080c,
+	0x6d9f, 0x008e, 0x003e, 0x001e, 0x080c, 0xac2b, 0x00ce, 0x08d8,
+	0x2c30, 0x600c, 0x2060, 0x08b8, 0x080c, 0x67ee, 0x012e, 0x001e,
+	0x006e, 0x00ce, 0x00be, 0x009e, 0x00ee, 0x00fe, 0x000e, 0x0005,
+	0x0096, 0x0006, 0x0066, 0x00c6, 0x00d6, 0x9036, 0x7820, 0x9065,
+	0x0904, 0x9567, 0x600c, 0x0006, 0x6044, 0xc0fc, 0x6046, 0x600f,
+	0x0000, 0x7830, 0x9c06, 0x1588, 0x2069, 0x0100, 0x6820, 0xd0a4,
+	0x1508, 0x080c, 0x8709, 0x080c, 0x9e4f, 0x68c3, 0x0000, 0x080c,
+	0xa327, 0x7833, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384,
+	0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2a49, 0x9006, 0x080c,
+	0x2a49, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001,
+	0x003e, 0x0058, 0x080c, 0x6a26, 0x1538, 0x6003, 0x0009, 0x630a,
+	0x7808, 0xc0ad, 0x780a, 0x2c30, 0x00f8, 0x6014, 0x2048, 0x080c,
+	0xc863, 0x01b0, 0x6020, 0x9086, 0x0003, 0x1508, 0x080c, 0xca7a,
+	0x1118, 0x080c, 0xb5c6, 0x0060, 0x080c, 0x6a26, 0x1168, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6d9f, 0x080c, 0xca54,
+	0x080c, 0xac2b, 0x080c, 0xa1fd, 0x000e, 0x0804, 0x9507, 0x7e22,
+	0x7e1e, 0x00de, 0x00ce, 0x006e, 0x000e, 0x009e, 0x0005, 0x6020,
+	0x9086, 0x0006, 0x1118, 0x080c, 0xe2b9, 0x0c50, 0x080c, 0xb5c6,
+	0x6020, 0x9086, 0x0002, 0x1150, 0x6004, 0x0006, 0x9086, 0x0085,
+	0x000e, 0x0990, 0x9086, 0x008b, 0x0978, 0x08d0, 0x6020, 0x9086,
+	0x0005, 0x19b0, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0d18,
+	0x9086, 0x008b, 0x0d00, 0x0860, 0x0006, 0x0096, 0x00b6, 0x00c6,
+	0x0066, 0x9036, 0x7828, 0x9065, 0x0510, 0x6010, 0x2058, 0x600c,
+	0x0006, 0x3e08, 0x918e, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x11a8,
+	0x6043, 0xffff, 0x080c, 0xaa78, 0x0180, 0x610c, 0x080c, 0x9fbd,
+	0x6014, 0x2048, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
+	0x6d9f, 0x080c, 0xac2b, 0x000e, 0x08f0, 0x2c30, 0x0ce0, 0x006e,
+	0x00ce, 0x00be, 0x009e, 0x000e, 0x0005, 0x00e6, 0x00d6, 0x0096,
+	0x0066, 0x080c, 0x6156, 0x11b0, 0x2071, 0x19e6, 0x7030, 0x9080,
+	0x0005, 0x2004, 0x904d, 0x0170, 0xa878, 0x9606, 0x1158, 0x2071,
+	0x19e6, 0x7030, 0x9035, 0x0130, 0x9080, 0x0005, 0x2004, 0x9906,
+	0x1108, 0x0029, 0x006e, 0x009e, 0x00de, 0x00ee, 0x0005, 0x00c6,
+	0x2660, 0x6043, 0xffff, 0x080c, 0xaa78, 0x0178, 0x080c, 0x9fbd,
+	0x6014, 0x2048, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
+	0xcb68, 0x080c, 0x6d9f, 0x080c, 0xac2b, 0x00ce, 0x0005, 0x00b6,
+	0x00e6, 0x00c6, 0x080c, 0xa899, 0x0106, 0x2071, 0x0101, 0x2e04,
+	0xc0c4, 0x2072, 0x6044, 0xd0fc, 0x1138, 0x010e, 0x090c, 0xa8b5,
+	0x00ce, 0x00ee, 0x00be, 0x0005, 0x2071, 0x19e6, 0x7030, 0x9005,
+	0x0da0, 0x9c06, 0x190c, 0x0d7d, 0x7036, 0x080c, 0x8709, 0x7004,
+	0x9084, 0x0007, 0x0002, 0x962d, 0x962f, 0x9636, 0x9640, 0x964e,
+	0x962d, 0x963b, 0x962b, 0x080c, 0x0d7d, 0x0428, 0x0005, 0x080c,
+	0xaa63, 0x7007, 0x0000, 0x7033, 0x0000, 0x00e8, 0x0066, 0x9036,
+	0x080c, 0x9fbd, 0x006e, 0x7007, 0x0000, 0x7033, 0x0000, 0x0098,
+	0x080c, 0xaa4e, 0x0140, 0x080c, 0xaa63, 0x0128, 0x0066, 0x9036,
+	0x080c, 0x9fbd, 0x006e, 0x7033, 0x0000, 0x0028, 0x080c, 0xaa4e,
+	0x080c, 0xa327, 0x0000, 0x010e, 0x190c, 0xa8b5, 0x00ce, 0x00ee,
+	0x00be, 0x0005, 0x00d6, 0x00c6, 0x080c, 0xa899, 0x0106, 0x6044,
+	0xd0fc, 0x1130, 0x010e, 0x090c, 0xa8b5, 0x00ce, 0x00de, 0x0005,
+	0x2069, 0x19e6, 0x684c, 0x9005, 0x0da8, 0x9c06, 0x190c, 0x0d7d,
+	0x6852, 0x00e6, 0x2d70, 0x080c, 0x9289, 0x00ee, 0x080c, 0x8716,
+	0x0016, 0x2009, 0x0040, 0x080c, 0x21d9, 0x001e, 0x683c, 0x9084,
+	0x0003, 0x0002, 0x9688, 0x9689, 0x96a7, 0x9686, 0x080c, 0x0d7d,
+	0x0460, 0x6868, 0x9086, 0x0001, 0x0190, 0x600c, 0x9015, 0x0160,
+	0x6a4a, 0x600f, 0x0000, 0x6044, 0xc0fc, 0x6046, 0x9006, 0x7042,
+	0x684e, 0x683f, 0x0000, 0x00c8, 0x684a, 0x6846, 0x0ca0, 0x686b,
+	0x0000, 0x6848, 0x9065, 0x0d78, 0x6003, 0x0002, 0x0c60, 0x9006,
+	0x686a, 0x6852, 0x686e, 0x600c, 0x9015, 0x0120, 0x6a4a, 0x600f,
+	0x0000, 0x0018, 0x684e, 0x684a, 0x6846, 0x684f, 0x0000, 0x010e,
+	0x190c, 0xa8b5, 0x00ce, 0x00de, 0x0005, 0x0005, 0x6020, 0x9084,
+	0x000f, 0x000b, 0x0005, 0x96d3, 0x96d6, 0x9b44, 0x9bd3, 0x96d6,
+	0x9b44, 0x9bd3, 0x96d3, 0x96d6, 0x96d3, 0x96d3, 0x96d3, 0x96d3,
+	0x96d3, 0x96d3, 0x96d3, 0x080c, 0x95ff, 0x0005, 0x00b6, 0x0156,
+	0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a, 0x0053, 0x1a0c,
+	0x0d7d, 0x6110, 0x2158, 0xb984, 0x2c78, 0x2061, 0x0100, 0x619a,
+	0x908a, 0x0040, 0x1a04, 0x9742, 0x005b, 0x00fe, 0x00ee, 0x00de,
+	0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005,
+	0x98c7, 0x9902, 0x992b, 0x99d3, 0x99f5, 0x99fb, 0x9a08, 0x9a10,
+	0x9a1c, 0x9a22, 0x9a33, 0x9a22, 0x9a8b, 0x9a10, 0x9a97, 0x9a9d,
+	0x9a1c, 0x9a9d, 0x9aa9, 0x9740, 0x9740, 0x9740, 0x9740, 0x9740,
+	0x9740, 0x9740, 0x9740, 0x9740, 0x9740, 0x9740, 0x9fde, 0xa001,
+	0xa012, 0xa032, 0xa064, 0x9a08, 0x9740, 0x9a08, 0x9a22, 0x9740,
+	0x992b, 0x99d3, 0x9740, 0xa425, 0x9a22, 0x9740, 0xa441, 0x9a22,
+	0x9740, 0x9a1c, 0x98c1, 0x9763, 0x9740, 0xa45d, 0xa4ca, 0xa5ae,
+	0x9740, 0xa5bb, 0x9a05, 0xa5e6, 0x9740, 0xa06e, 0xa5f2, 0x9740,
+	0x080c, 0x0d7d, 0x2100, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0xa692,
+	0xa744, 0x9761, 0x978a, 0x9836, 0x9841, 0x9761, 0x9a08, 0x9761,
+	0x9888, 0x9894, 0x97a5, 0x9761, 0x97c0, 0x97f4, 0xaace, 0xab13,
+	0x9a22, 0x080c, 0x0d7d, 0x00d6, 0x0096, 0x080c, 0x9abc, 0x7003,
+	0x2414, 0x7007, 0x0018, 0x700b, 0x0800, 0x7814, 0x2048, 0xa83c,
+	0x700e, 0xa850, 0x7022, 0xa854, 0x7026, 0x60c3, 0x0018, 0x080c,
+	0x9e1f, 0x009e, 0x00de, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb8a0,
+	0x00be, 0x080c, 0xab5a, 0x1118, 0x9084, 0xff80, 0x0110, 0x9085,
+	0x0001, 0x0005, 0x00d6, 0x0096, 0x080c, 0x9abc, 0x7003, 0x0500,
+	0x7814, 0x2048, 0xa874, 0x700a, 0xa878, 0x700e, 0xa87c, 0x7012,
+	0xa880, 0x7016, 0xa884, 0x701a, 0xa888, 0x701e, 0x60c3, 0x0010,
+	0x080c, 0x9e1f, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x080c,
+	0x9abc, 0x7003, 0x0500, 0x7814, 0x2048, 0xa8cc, 0x700a, 0xa8d0,
+	0x700e, 0xa8d4, 0x7012, 0xa8d8, 0x7016, 0xa8dc, 0x701a, 0xa8e0,
+	0x701e, 0x60c3, 0x0010, 0x080c, 0x9e1f, 0x009e, 0x00de, 0x0005,
+	0x00d6, 0x0096, 0x0126, 0x2091, 0x8000, 0x080c, 0x9abc, 0x20e9,
+	0x0000, 0x2001, 0x19a2, 0x2003, 0x0000, 0x7814, 0x2048, 0xa814,
+	0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x001b, 0x2098, 0x2001, 0x19a2, 0x0016, 0x200c, 0x2001, 0x0001,
+	0x080c, 0x21be, 0x080c, 0xd5f1, 0x9006, 0x080c, 0x21be, 0x001e,
+	0xa804, 0x9005, 0x0110, 0x2048, 0x0c28, 0x04d9, 0x080c, 0x9e1f,
+	0x012e, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x9b07, 0x20e9, 0x0000, 0x2001, 0x19a2, 0x2003,
+	0x0000, 0x7814, 0x2048, 0xa86f, 0x0200, 0xa873, 0x0000, 0xa814,
+	0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x001b, 0x2098, 0x2001, 0x19a2, 0x0016, 0x200c, 0x080c, 0xd5f1,
+	0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c60, 0x0051, 0x7814,
+	0x2048, 0x080c, 0x0ff9, 0x080c, 0x9e1f, 0x012e, 0x009e, 0x00de,
+	0x0005, 0x60c0, 0x8004, 0x9084, 0x0003, 0x9005, 0x0130, 0x9082,
+	0x0004, 0x20a3, 0x0000, 0x8000, 0x1de0, 0x0005, 0x080c, 0x9abc,
+	0x7003, 0x7800, 0x7808, 0x8007, 0x700a, 0x60c3, 0x0008, 0x0804,
+	0x9e1f, 0x00d6, 0x00e6, 0x080c, 0x9b07, 0x7814, 0x9084, 0xff00,
+	0x2073, 0x0200, 0x8e70, 0x8e70, 0x9095, 0x0010, 0x2272, 0x8e70,
+	0x2073, 0x0034, 0x8e70, 0x2069, 0x1805, 0x20a9, 0x0004, 0x2d76,
+	0x8d68, 0x8e70, 0x1f04, 0x9857, 0x2069, 0x1801, 0x20a9, 0x0004,
+	0x2d76, 0x8d68, 0x8e70, 0x1f04, 0x9860, 0x2069, 0x19b2, 0x9086,
+	0xdf00, 0x0110, 0x2069, 0x19cc, 0x20a9, 0x001a, 0x9e86, 0x0260,
+	0x1148, 0x00c6, 0x2061, 0x0200, 0x6010, 0x8000, 0x6012, 0x00ce,
+	0x2071, 0x0240, 0x2d04, 0x8007, 0x2072, 0x8d68, 0x8e70, 0x1f04,
+	0x986e, 0x60c3, 0x004c, 0x080c, 0x9e1f, 0x00ee, 0x00de, 0x0005,
+	0x080c, 0x9abc, 0x7003, 0x6300, 0x7007, 0x0028, 0x7808, 0x700e,
+	0x60c3, 0x0008, 0x0804, 0x9e1f, 0x00d6, 0x0026, 0x0016, 0x080c,
+	0x9b07, 0x7003, 0x0200, 0x7814, 0x700e, 0x00e6, 0x9ef0, 0x0004,
+	0x2009, 0x0001, 0x2011, 0x000c, 0x2069, 0x1923, 0x6810, 0xd084,
+	0x1148, 0x2073, 0x0500, 0x8e70, 0x2073, 0x0000, 0x8e70, 0x8108,
+	0x9290, 0x0004, 0x2073, 0x0800, 0x8e70, 0x2073, 0x0000, 0x00ee,
+	0x7206, 0x710a, 0x62c2, 0x080c, 0x9e1f, 0x001e, 0x002e, 0x00de,
+	0x0005, 0x2001, 0x1818, 0x2004, 0x609a, 0x0804, 0x9e1f, 0x080c,
+	0x9abc, 0x7003, 0x5200, 0x2069, 0x1847, 0x6804, 0xd084, 0x0130,
+	0x6828, 0x0016, 0x080c, 0x2663, 0x710e, 0x001e, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250,
+	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x0254, 0x4003,
+	0x080c, 0xab5a, 0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001,
+	0x181f, 0x2004, 0x7032, 0x2001, 0x1820, 0x2004, 0x7036, 0x0030,
+	0x2001, 0x1818, 0x2004, 0x9084, 0x00ff, 0x7036, 0x60c3, 0x001c,
+	0x0804, 0x9e1f, 0x080c, 0x9abc, 0x7003, 0x0500, 0x080c, 0xab5a,
+	0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181f, 0x2004,
+	0x700a, 0x2001, 0x1820, 0x2004, 0x700e, 0x0030, 0x2001, 0x1818,
+	0x2004, 0x9084, 0x00ff, 0x700e, 0x20a9, 0x0004, 0x20e1, 0x0001,
+	0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003, 0x60c3,
+	0x0010, 0x0804, 0x9e1f, 0x080c, 0x9abc, 0x9006, 0x080c, 0x6a58,
+	0xb8a0, 0x9086, 0x007e, 0x1130, 0x7003, 0x0400, 0x620c, 0xc2b4,
+	0x620e, 0x0058, 0x7814, 0x0096, 0x904d, 0x0120, 0x9006, 0xa89a,
+	0xa8a6, 0xa8aa, 0x009e, 0x7003, 0x0300, 0xb8a0, 0x9086, 0x007e,
+	0x1904, 0x999a, 0x00d6, 0x2069, 0x196b, 0x2001, 0x1837, 0x2004,
+	0xd0a4, 0x0188, 0x6800, 0x700a, 0x6808, 0x9084, 0x2000, 0x7012,
+	0x080c, 0xab71, 0x680c, 0x7016, 0x701f, 0x2710, 0x6818, 0x7022,
+	0x681c, 0x7026, 0x0090, 0x6800, 0x700a, 0x6804, 0x700e, 0x6808,
+	0x080c, 0x74ec, 0x1118, 0x9084, 0x37ff, 0x0010, 0x9084, 0x3fff,
+	0x7012, 0x080c, 0xab71, 0x680c, 0x7016, 0x00de, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256,
+	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003,
+	0x00d6, 0x080c, 0xa679, 0x2069, 0x1973, 0x2071, 0x024e, 0x6800,
+	0xc0dd, 0x7002, 0x080c, 0x56f9, 0xd0e4, 0x0110, 0x680c, 0x700e,
+	0x00de, 0x04a8, 0x2001, 0x1837, 0x2004, 0xd0a4, 0x0170, 0x0016,
+	0x2001, 0x196c, 0x200c, 0x60e0, 0x9106, 0x0130, 0x2100, 0x60e3,
+	0x0000, 0x080c, 0x26a4, 0x61e2, 0x001e, 0x20e1, 0x0001, 0x2099,
+	0x196b, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x20a9, 0x0008, 0x4003,
+	0x20a9, 0x0004, 0x2099, 0x1805, 0x20a1, 0x0256, 0x4003, 0x20a9,
+	0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x080c, 0xa679,
+	0x20a1, 0x024e, 0x20a9, 0x0008, 0x2099, 0x1973, 0x4003, 0x60c3,
+	0x0074, 0x0804, 0x9e1f, 0x080c, 0x9abc, 0x7003, 0x2010, 0x7007,
+	0x0014, 0x700b, 0x0800, 0x700f, 0x2000, 0x9006, 0x00f6, 0x2079,
+	0x1847, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0xd1a4,
+	0x0110, 0x9085, 0x0010, 0x9085, 0x0002, 0x00d6, 0x0804, 0x9a6c,
+	0x7026, 0x60c3, 0x0014, 0x0804, 0x9e1f, 0x080c, 0x9abc, 0x7003,
+	0x5000, 0x0804, 0x9945, 0x080c, 0x9abc, 0x7003, 0x2110, 0x7007,
+	0x0014, 0x60c3, 0x0014, 0x0804, 0x9e1f, 0x080c, 0x9afe, 0x0010,
+	0x080c, 0x9b07, 0x7003, 0x0200, 0x60c3, 0x0004, 0x0804, 0x9e1f,
+	0x080c, 0x9b07, 0x7003, 0x0100, 0x700b, 0x0003, 0x700f, 0x2a00,
+	0x60c3, 0x0008, 0x0804, 0x9e1f, 0x080c, 0x9b07, 0x7003, 0x0200,
+	0x0804, 0x9945, 0x080c, 0x9b07, 0x7003, 0x0100, 0x782c, 0x9005,
+	0x0110, 0x700a, 0x0010, 0x700b, 0x0003, 0x7814, 0x700e, 0x60c3,
+	0x0008, 0x0804, 0x9e1f, 0x00d6, 0x080c, 0x9b07, 0x7003, 0x0210,
+	0x7007, 0x0014, 0x700b, 0x0800, 0xb894, 0x9086, 0x0014, 0x1198,
+	0xb99c, 0x9184, 0x0030, 0x0190, 0xb998, 0x9184, 0xc000, 0x1140,
+	0xd1ec, 0x0118, 0x700f, 0x2100, 0x0058, 0x700f, 0x0100, 0x0040,
+	0x700f, 0x0400, 0x0028, 0x700f, 0x0700, 0x0010, 0x700f, 0x0800,
+	0x00f6, 0x2079, 0x1847, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085,
+	0x0020, 0xd1a4, 0x0110, 0x9085, 0x0010, 0x2009, 0x1869, 0x210c,
+	0xd184, 0x1110, 0x9085, 0x0002, 0x0026, 0x2009, 0x1867, 0x210c,
+	0xd1e4, 0x0150, 0xc0c5, 0xbad4, 0xd28c, 0x1108, 0xc0cd, 0x9094,
+	0x0030, 0x9296, 0x0010, 0x0140, 0xd1ec, 0x0130, 0x9094, 0x0030,
+	0x9296, 0x0010, 0x0108, 0xc0bd, 0x002e, 0x7026, 0x60c3, 0x0014,
+	0x00de, 0x0804, 0x9e1f, 0x080c, 0x9b07, 0x7003, 0x0210, 0x7007,
+	0x0014, 0x700f, 0x0100, 0x60c3, 0x0014, 0x0804, 0x9e1f, 0x080c,
+	0x9b07, 0x7003, 0x0200, 0x0804, 0x98cb, 0x080c, 0x9b07, 0x7003,
+	0x0100, 0x700b, 0x0003, 0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804,
+	0x9e1f, 0x080c, 0x9b07, 0x7003, 0x0100, 0x700b, 0x000b, 0x60c3,
+	0x0008, 0x0804, 0x9e1f, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019,
+	0x3200, 0x2021, 0x0800, 0x0040, 0x0026, 0x00d6, 0x0036, 0x0046,
+	0x2019, 0x2200, 0x2021, 0x0100, 0x080c, 0xa68e, 0xb810, 0x9305,
 	0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880,
-	0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x9b00, 0x0026, 0x080c,
-	0xa67d, 0xb810, 0x9085, 0x8500, 0x7002, 0xb814, 0x7006, 0x2069,
-	0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x2001, 0x0099, 0x7012,
-	0x0804, 0x9b00, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2c78,
-	0x2069, 0x0200, 0x2071, 0x0240, 0x7804, 0x908a, 0x0040, 0x0a0c,
-	0x0d7d, 0x908a, 0x0057, 0x1a0c, 0x0d7d, 0x7910, 0x2158, 0xb984,
-	0x2061, 0x0100, 0x619a, 0x9082, 0x0040, 0x0033, 0x00fe, 0x00ee,
-	0x00de, 0x00ce, 0x00be, 0x0005, 0x9bcf, 0x9bcf, 0x9bcf, 0x9bf5,
-	0x9bcf, 0x9bcf, 0x9bcf, 0x9bcf, 0x9bcf, 0x9bcf, 0x9bcf, 0xa1cd,
-	0xa1d5, 0xa1dd, 0xa1e5, 0x9bcf, 0x9bcf, 0x9bcf, 0xa1c5, 0x080c,
-	0x0d7d, 0x6813, 0x0008, 0xba8c, 0x8210, 0xb8d4, 0xd084, 0x0128,
-	0x7a4e, 0x7b14, 0x7b52, 0x722e, 0x732a, 0x9294, 0x00ff, 0xba8e,
-	0x8217, 0x721a, 0xba10, 0x9295, 0x0600, 0x7202, 0xba14, 0x7206,
-	0x2069, 0x1800, 0x6a7c, 0x720a, 0x6a80, 0x720e, 0x7013, 0x0829,
-	0x2f10, 0x7222, 0x7027, 0xffff, 0x0005, 0x0016, 0x7814, 0x9084,
-	0x0700, 0x8007, 0x0013, 0x001e, 0x0005, 0x9c05, 0x9c05, 0x9c07,
-	0x9c05, 0x9c05, 0x9c05, 0x9c21, 0x9c05, 0x080c, 0x0d7d, 0x7914,
-	0x918c, 0x08ff, 0x918d, 0xf600, 0x7916, 0x2009, 0x0003, 0x00b9,
-	0x2069, 0x1847, 0x6804, 0xd0bc, 0x0130, 0x682c, 0x9084, 0x00ff,
-	0x8007, 0x7032, 0x0010, 0x7033, 0x3f00, 0x60c3, 0x0001, 0x0804,
-	0x9de6, 0x2009, 0x0003, 0x0019, 0x7033, 0x7f00, 0x0cb0, 0x0016,
-	0x080c, 0xa67d, 0x001e, 0xb810, 0x9085, 0x0100, 0x7002, 0xb814,
-	0x7006, 0x2069, 0x1800, 0x6a7c, 0x720a, 0x6a80, 0x720e, 0x7013,
-	0x0888, 0x918d, 0x0008, 0x7116, 0x080c, 0x9dda, 0x721a, 0x7a08,
-	0x7222, 0x2f10, 0x7226, 0x0005, 0x00b6, 0x00e6, 0x00d6, 0x00c6,
-	0x0066, 0x0056, 0x0046, 0x0036, 0x2061, 0x0100, 0x2071, 0x1800,
-	0x7160, 0x7810, 0x2058, 0x76dc, 0x96b4, 0x0028, 0x0110, 0x737c,
-	0x7480, 0x2500, 0x76dc, 0x96b4, 0x0028, 0x0140, 0x2001, 0x04ff,
-	0x6062, 0x6067, 0xffff, 0x636a, 0x646e, 0x0050, 0x2001, 0x00ff,
-	0x9085, 0x0400, 0x6062, 0x6067, 0xffff, 0x606b, 0x0000, 0x616e,
-	0xb8b8, 0x6073, 0x0530, 0x6077, 0x0008, 0xb88c, 0x8000, 0x9084,
-	0x00ff, 0xb88e, 0x8007, 0x9085, 0x0020, 0x607a, 0x607f, 0x0000,
-	0x2b00, 0x6082, 0x6087, 0xffff, 0x7814, 0x0096, 0x2048, 0xa848,
-	0x608a, 0xa844, 0x608e, 0xa838, 0x60c6, 0xa834, 0x60ca, 0x009e,
-	0xb86c, 0x60ce, 0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7, 0x0000,
-	0x2001, 0x1837, 0x2004, 0x9084, 0x0028, 0x0128, 0x609f, 0x0000,
-	0x2001, 0x0092, 0x0058, 0x6028, 0xc0bd, 0x602a, 0x609f, 0x00ff,
-	0x2011, 0xffff, 0x080c, 0x2a63, 0x2001, 0x00b2, 0x2010, 0x900e,
-	0x080c, 0x2a72, 0x2009, 0x07d0, 0x080c, 0x86da, 0x003e, 0x004e,
-	0x005e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00be, 0x0005, 0x00b6,
-	0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0056, 0x0046, 0x0036, 0x2061,
-	0x0100, 0x2071, 0x1800, 0x7160, 0x7810, 0x2058, 0xb8a0, 0x2028,
-	0x76dc, 0xd6ac, 0x1168, 0x9582, 0x007e, 0x1250, 0x2500, 0x9094,
-	0xff80, 0x1130, 0x9080, 0x3368, 0x2015, 0x9294, 0x00ff, 0x0020,
-	0xb910, 0xba14, 0x737c, 0x7480, 0x70dc, 0xd0ac, 0x1130, 0x9582,
-	0x007e, 0x1218, 0x9584, 0xff80, 0x0138, 0x9185, 0x0400, 0x6062,
-	0x6266, 0x636a, 0x646e, 0x0030, 0x6063, 0x0400, 0x6266, 0x606b,
-	0x0000, 0x616e, 0xb8b8, 0x6072, 0x6077, 0x0000, 0xb864, 0xd0a4,
-	0x0110, 0x6077, 0x0008, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e,
-	0x8007, 0x9085, 0x0020, 0x607a, 0x607f, 0x0000, 0x2b00, 0x6082,
-	0x6087, 0xffff, 0x7814, 0x0096, 0x2048, 0xa848, 0x608a, 0xa844,
-	0x608e, 0xa838, 0x60c6, 0xa834, 0x60ca, 0x009e, 0xb86c, 0x60ce,
-	0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xba84, 0x629e,
-	0x00f6, 0x2079, 0x0140, 0x7803, 0x0000, 0x00fe, 0x900e, 0x2011,
-	0x0092, 0x080c, 0x2a72, 0x2009, 0x07d0, 0x080c, 0x86da, 0x003e,
+	0x700e, 0x9485, 0x0029, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c,
+	0x9e13, 0x721a, 0x9f95, 0x0000, 0x7222, 0x7027, 0xffff, 0x2071,
+	0x024c, 0x002e, 0x0005, 0x0026, 0x080c, 0xa68e, 0x7003, 0x02ff,
+	0x7007, 0xfffc, 0x00d6, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880,
+	0x700e, 0x00de, 0x7013, 0x2029, 0x0c10, 0x7003, 0x0100, 0x7007,
+	0x0000, 0x700b, 0xfc02, 0x700f, 0x0000, 0x0005, 0x0026, 0x00d6,
+	0x0036, 0x0046, 0x2019, 0x3300, 0x2021, 0x0800, 0x0040, 0x0026,
+	0x00d6, 0x0036, 0x0046, 0x2019, 0x2300, 0x2021, 0x0100, 0x080c,
+	0xa68e, 0xb810, 0x9305, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800,
+	0xb810, 0x9005, 0x1140, 0xb814, 0x9005, 0x1128, 0x700b, 0x00ff,
+	0x700f, 0xfffe, 0x0020, 0x687c, 0x700a, 0x6880, 0x700e, 0x0000,
+	0x9485, 0x0098, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c, 0x9e13,
+	0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c, 0x002e,
+	0x0005, 0x080c, 0x9e13, 0x721a, 0x7a08, 0x7222, 0x7814, 0x7026,
+	0x2071, 0x024c, 0x002e, 0x0005, 0x00b6, 0x00c6, 0x00d6, 0x00e6,
+	0x00f6, 0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a, 0x0085,
+	0x0a0c, 0x0d7d, 0x908a, 0x0092, 0x1a0c, 0x0d7d, 0x6110, 0x2158,
+	0xb984, 0x2c78, 0x2061, 0x0100, 0x619a, 0x9082, 0x0085, 0x0033,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x9b75, 0x9b84,
+	0x9b8f, 0x9b73, 0x9b73, 0x9b73, 0x9b75, 0x9b73, 0x9b73, 0x9b73,
+	0x9b73, 0x9b73, 0x9b73, 0x080c, 0x0d7d, 0x0411, 0x60c3, 0x0000,
+	0x0026, 0x080c, 0x29b4, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5,
+	0x2012, 0x002e, 0x0804, 0x9e1f, 0x0431, 0x7808, 0x700a, 0x7814,
+	0x700e, 0x7017, 0xffff, 0x60c3, 0x000c, 0x0804, 0x9e1f, 0x0479,
+	0x7003, 0x0003, 0x7007, 0x0300, 0x60c3, 0x0004, 0x0804, 0x9e1f,
+	0x0026, 0x080c, 0xa68e, 0xb810, 0x9085, 0x8100, 0x7002, 0xb814,
+	0x7006, 0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x7013,
+	0x0009, 0x0804, 0x9ad7, 0x0026, 0x080c, 0xa68e, 0xb810, 0x9085,
+	0x8400, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x687c, 0x700a,
+	0x6880, 0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x9b39, 0x0026,
+	0x080c, 0xa68e, 0xb810, 0x9085, 0x8500, 0x7002, 0xb814, 0x7006,
+	0x2069, 0x1800, 0x687c, 0x700a, 0x6880, 0x700e, 0x2001, 0x0099,
+	0x7012, 0x0804, 0x9b39, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x2c78, 0x2069, 0x0200, 0x2071, 0x0240, 0x7804, 0x908a, 0x0040,
+	0x0a0c, 0x0d7d, 0x908a, 0x0057, 0x1a0c, 0x0d7d, 0x7910, 0x2158,
+	0xb984, 0x2061, 0x0100, 0x619a, 0x9082, 0x0040, 0x0033, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x9c08, 0x9c08, 0x9c08,
+	0x9c2e, 0x9c08, 0x9c08, 0x9c08, 0x9c08, 0x9c08, 0x9c08, 0x9c08,
+	0xa1da, 0xa1e2, 0xa1ea, 0xa1f2, 0x9c08, 0x9c08, 0x9c08, 0xa1d2,
+	0x080c, 0x0d7d, 0x6813, 0x0008, 0xba8c, 0x8210, 0xb8d4, 0xd084,
+	0x0128, 0x7a4e, 0x7b14, 0x7b52, 0x722e, 0x732a, 0x9294, 0x00ff,
+	0xba8e, 0x8217, 0x721a, 0xba10, 0x9295, 0x0600, 0x7202, 0xba14,
+	0x7206, 0x2069, 0x1800, 0x6a7c, 0x720a, 0x6a80, 0x720e, 0x7013,
+	0x0829, 0x2f10, 0x7222, 0x7027, 0xffff, 0x0005, 0x0016, 0x7814,
+	0x9084, 0x0700, 0x8007, 0x0013, 0x001e, 0x0005, 0x9c3e, 0x9c3e,
+	0x9c40, 0x9c3e, 0x9c3e, 0x9c3e, 0x9c5a, 0x9c3e, 0x080c, 0x0d7d,
+	0x7914, 0x918c, 0x08ff, 0x918d, 0xf600, 0x7916, 0x2009, 0x0003,
+	0x00b9, 0x2069, 0x1847, 0x6804, 0xd0bc, 0x0130, 0x682c, 0x9084,
+	0x00ff, 0x8007, 0x7032, 0x0010, 0x7033, 0x3f00, 0x60c3, 0x0001,
+	0x0804, 0x9e1f, 0x2009, 0x0003, 0x0019, 0x7033, 0x7f00, 0x0cb0,
+	0x0016, 0x080c, 0xa68e, 0x001e, 0xb810, 0x9085, 0x0100, 0x7002,
+	0xb814, 0x7006, 0x2069, 0x1800, 0x6a7c, 0x720a, 0x6a80, 0x720e,
+	0x7013, 0x0888, 0x918d, 0x0008, 0x7116, 0x080c, 0x9e13, 0x721a,
+	0x7a08, 0x7222, 0x2f10, 0x7226, 0x0005, 0x00b6, 0x00e6, 0x00d6,
+	0x00c6, 0x0066, 0x0056, 0x0046, 0x0036, 0x2061, 0x0100, 0x2071,
+	0x1800, 0x7160, 0x7810, 0x2058, 0x76dc, 0x96b4, 0x0028, 0x0110,
+	0x737c, 0x7480, 0x2500, 0x76dc, 0x96b4, 0x0028, 0x0140, 0x2001,
+	0x04ff, 0x6062, 0x6067, 0xffff, 0x636a, 0x646e, 0x0050, 0x2001,
+	0x00ff, 0x9085, 0x0400, 0x6062, 0x6067, 0xffff, 0x606b, 0x0000,
+	0x616e, 0xb8b8, 0x6073, 0x0530, 0x6077, 0x0008, 0xb88c, 0x8000,
+	0x9084, 0x00ff, 0xb88e, 0x8007, 0x9085, 0x0020, 0x607a, 0x607f,
+	0x0000, 0x2b00, 0x6082, 0x6087, 0xffff, 0x7814, 0x0096, 0x2048,
+	0xa848, 0x608a, 0xa844, 0x608e, 0xa838, 0x60c6, 0xa834, 0x60ca,
+	0x009e, 0xb86c, 0x60ce, 0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7,
+	0x0000, 0x2001, 0x1837, 0x2004, 0x9084, 0x0028, 0x0128, 0x609f,
+	0x0000, 0x2001, 0x0092, 0x0058, 0x6028, 0xc0bd, 0x602a, 0x609f,
+	0x00ff, 0x2011, 0xffff, 0x080c, 0x2a83, 0x2001, 0x00b2, 0x2010,
+	0x900e, 0x080c, 0x2a92, 0x2009, 0x07d0, 0x080c, 0x870e, 0x003e,
 	0x004e, 0x005e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00be, 0x0005,
-	0x00b6, 0x0096, 0x00e6, 0x00d6, 0x00c6, 0x0056, 0x0046, 0x0036,
-	0x2061, 0x0100, 0x2071, 0x1800, 0x7810, 0x2058, 0xb8a0, 0x2028,
-	0xb910, 0xba14, 0x737c, 0x7480, 0x7820, 0x0002, 0x9d65, 0x9d65,
-	0x9d65, 0x9d65, 0x9d65, 0x9d65, 0x9d65, 0x9d65, 0x9d65, 0x9d65,
-	0x9d67, 0x9d65, 0x9d65, 0x9d65, 0x9d65, 0x080c, 0x0d7d, 0xb884,
-	0x609e, 0x7814, 0x2048, 0xa87c, 0xd0fc, 0x0558, 0xaf90, 0x9784,
-	0xff00, 0x9105, 0x6062, 0x873f, 0x9784, 0xff00, 0x0006, 0x7814,
-	0x2048, 0xa878, 0xc0fc, 0x9005, 0x000e, 0x1160, 0xaf94, 0x87ff,
-	0x0198, 0x2039, 0x0098, 0x9705, 0x6072, 0x7808, 0x6082, 0x2f00,
-	0x6086, 0x0038, 0x9185, 0x2200, 0x6062, 0x6073, 0x0129, 0x6077,
-	0x0000, 0xb884, 0x609e, 0x0050, 0x2039, 0x0029, 0x9705, 0x6072,
-	0x0cc0, 0x9185, 0x0200, 0x6062, 0x6073, 0x2029, 0xa87c, 0xd0fc,
-	0x0118, 0xaf94, 0x87ff, 0x1120, 0x2f00, 0x6082, 0x7808, 0x6086,
-	0x6266, 0x636a, 0x646e, 0x6077, 0x0000, 0xb88c, 0x8000, 0x9084,
-	0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000, 0xa848, 0x608a,
-	0xa844, 0x608e, 0xa838, 0x60c6, 0xa834, 0x60ca, 0xb86c, 0x60ce,
-	0x60af, 0x95d5, 0x60d7, 0x0000, 0x080c, 0xa65d, 0x2009, 0x07d0,
-	0x60c4, 0x9084, 0xfff0, 0x9005, 0x0110, 0x2009, 0x1b58, 0x080c,
-	0x86da, 0x003e, 0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x009e,
-	0x00be, 0x0005, 0x7a40, 0x9294, 0x00ff, 0x8217, 0x0005, 0x00d6,
-	0x2069, 0x19e6, 0x686b, 0x0001, 0x00de, 0x0005, 0x60a3, 0x0056,
-	0x60a7, 0x9575, 0x00f1, 0x080c, 0x86cc, 0x0005, 0x0016, 0x2001,
-	0x180c, 0x200c, 0x9184, 0x0600, 0x9086, 0x0600, 0x0128, 0x0089,
-	0x080c, 0x86cc, 0x001e, 0x0005, 0xc1e5, 0x2001, 0x180c, 0x2102,
-	0x2001, 0x19e7, 0x2003, 0x0000, 0x2001, 0x19f2, 0x2003, 0x0000,
-	0x0c88, 0x0006, 0x0016, 0x0026, 0x2009, 0x1804, 0x2011, 0x0009,
-	0x080c, 0x2a72, 0x002e, 0x001e, 0x000e, 0x0005, 0x0016, 0x00c6,
-	0x0006, 0x080c, 0xa888, 0x0106, 0x2061, 0x0100, 0x61a4, 0x60a7,
-	0x95f5, 0x0016, 0x0026, 0x2009, 0x1804, 0x2011, 0x0008, 0x080c,
-	0x2a72, 0x002e, 0x001e, 0x010e, 0x090c, 0xa8a4, 0x000e, 0xa001,
-	0xa001, 0xa001, 0x61a6, 0x00ce, 0x001e, 0x0005, 0x00c6, 0x00d6,
-	0x0016, 0x0026, 0x2061, 0x0100, 0x2069, 0x0140, 0x080c, 0x74c8,
-	0x1510, 0x2001, 0x1a0b, 0x2004, 0x9005, 0x1904, 0x9e95, 0x080c,
-	0x7569, 0x11a8, 0x2069, 0x0380, 0x6843, 0x0101, 0x6844, 0xd084,
-	0x1de8, 0x2061, 0x0100, 0x6020, 0xd0b4, 0x1120, 0x6024, 0xd084,
-	0x090c, 0x0d7d, 0x6843, 0x0100, 0x080c, 0x86cc, 0x04b0, 0x00c6,
-	0x2061, 0x19e6, 0x00f0, 0x6904, 0x9194, 0x4000, 0x0598, 0x080c,
-	0x9e16, 0x080c, 0x2a39, 0x00c6, 0x2061, 0x19e6, 0x6134, 0x9192,
-	0x0008, 0x1278, 0x8108, 0x6136, 0x080c, 0xa888, 0x6130, 0x080c,
-	0xa8a4, 0x00ce, 0x81ff, 0x01c8, 0x080c, 0x86cc, 0x080c, 0x9e09,
-	0x00a0, 0x080c, 0xa888, 0x6130, 0x91e5, 0x0000, 0x0150, 0x080c,
-	0xe727, 0x080c, 0x86d5, 0x6003, 0x0001, 0x2009, 0x0014, 0x080c,
-	0xac7c, 0x080c, 0xa8a4, 0x00ce, 0x0000, 0x002e, 0x001e, 0x00de,
-	0x00ce, 0x0005, 0x2001, 0x1a0b, 0x2004, 0x9005, 0x1db0, 0x00c6,
-	0x2061, 0x19e6, 0x6134, 0x9192, 0x0003, 0x1ad8, 0x8108, 0x6136,
-	0x00ce, 0x080c, 0x86cc, 0x080c, 0x5edf, 0x2009, 0x1846, 0x2114,
-	0x8210, 0x220a, 0x0c10, 0x0096, 0x00c6, 0x00d6, 0x00e6, 0x0016,
-	0x0026, 0x080c, 0x86e2, 0x080c, 0xa888, 0x2001, 0x0387, 0x2003,
-	0x0202, 0x2071, 0x19e6, 0x714c, 0x81ff, 0x0904, 0x9f3d, 0x2061,
-	0x0100, 0x2069, 0x0140, 0x080c, 0x74c8, 0x1510, 0x0036, 0x2019,
-	0x0002, 0x080c, 0xa0fa, 0x003e, 0x714c, 0x2160, 0x080c, 0xe727,
-	0x2009, 0x004a, 0x6220, 0x9296, 0x0009, 0x1130, 0x6114, 0x2148,
-	0xa87b, 0x0006, 0x2009, 0x004a, 0x6003, 0x0003, 0x080c, 0xac7c,
-	0x2001, 0x0386, 0x2003, 0x5040, 0x080c, 0x7569, 0x0804, 0x9f3d,
-	0x6904, 0xd1f4, 0x0904, 0x9f4a, 0x080c, 0x2a39, 0x00c6, 0x704c,
-	0x9065, 0x090c, 0x0d7d, 0x6020, 0x00ce, 0x9086, 0x0006, 0x1518,
-	0x61c8, 0x60c4, 0x9105, 0x11f8, 0x2009, 0x180c, 0x2104, 0xd0d4,
-	0x01d0, 0x6214, 0x9294, 0x1800, 0x1128, 0x6224, 0x9294, 0x0002,
-	0x1560, 0x0010, 0xc0d4, 0x200a, 0x6014, 0x9084, 0xe7fd, 0x9085,
-	0x0010, 0x6016, 0x704c, 0x2060, 0x080c, 0x9621, 0x2009, 0x0049,
-	0x080c, 0xac7c, 0x00d0, 0x0036, 0x2019, 0x0001, 0x080c, 0xa0fa,
-	0x003e, 0x714c, 0x2160, 0x080c, 0xe727, 0x2009, 0x004a, 0x6220,
-	0x9296, 0x0009, 0x1130, 0x6114, 0x2148, 0xa87b, 0x0006, 0x2009,
-	0x004a, 0x6003, 0x0003, 0x080c, 0xac7c, 0x2001, 0x0387, 0x2003,
-	0x0200, 0x080c, 0xa8a4, 0x002e, 0x001e, 0x00ee, 0x00de, 0x00ce,
-	0x009e, 0x0005, 0xd1ec, 0x1904, 0x9ef4, 0x0804, 0x9ef6, 0x0026,
-	0x00e6, 0x2071, 0x19e6, 0x706c, 0xd084, 0x01e8, 0xc084, 0x706e,
-	0x714c, 0x81ff, 0x01c0, 0x2071, 0x0100, 0x9188, 0x0008, 0x2114,
-	0x928e, 0x0006, 0x1138, 0x2009, 0x1984, 0x2011, 0x0012, 0x080c,
-	0x2a72, 0x0048, 0x928e, 0x0009, 0x0db0, 0x2009, 0x1984, 0x2011,
-	0x0016, 0x080c, 0x2a72, 0x00ee, 0x002e, 0x0005, 0x9036, 0x2001,
-	0x19f0, 0x2004, 0x9005, 0x0128, 0x9c06, 0x0128, 0x2c30, 0x600c,
-	0x0cc8, 0x9085, 0x0001, 0x0005, 0x00f6, 0x2079, 0x19e6, 0x610c,
-	0x9006, 0x600e, 0x6044, 0xc0fc, 0x6046, 0x86ff, 0x1140, 0x7824,
-	0x9c06, 0x1118, 0x7826, 0x782a, 0x0050, 0x792a, 0x0040, 0x00c6,
-	0x2660, 0x610e, 0x00ce, 0x7824, 0x9c06, 0x1108, 0x7e26, 0x080c,
-	0xa1f0, 0x080c, 0xca21, 0x00fe, 0x0005, 0x080c, 0x9a83, 0x7003,
-	0x1200, 0x7838, 0x7012, 0x783c, 0x7016, 0x00c6, 0x7820, 0x9086,
-	0x0004, 0x1148, 0x7810, 0x9005, 0x0130, 0x00b6, 0x2058, 0xb810,
-	0xb914, 0x00be, 0x0020, 0x2061, 0x1800, 0x607c, 0x6180, 0x9084,
-	0x00ff, 0x700a, 0x710e, 0x00ce, 0x60c3, 0x002c, 0x0804, 0x9de6,
-	0x080c, 0x9a83, 0x7003, 0x0f00, 0x7808, 0xd09c, 0x0128, 0xb810,
-	0x9084, 0x00ff, 0x700a, 0xb814, 0x700e, 0x60c3, 0x0008, 0x0804,
-	0x9de6, 0x0156, 0x080c, 0x9ace, 0x7003, 0x0200, 0x080c, 0x879a,
-	0x20a9, 0x0006, 0x2011, 0xfff4, 0x2019, 0xfff5, 0x9ef0, 0x0002,
-	0x2305, 0x2072, 0x8e70, 0x2205, 0x2072, 0x8e70, 0x9398, 0x0002,
-	0x9290, 0x0002, 0x1f04, 0x9fe8, 0x60c3, 0x001c, 0x015e, 0x0804,
-	0x9de6, 0x0016, 0x0026, 0x080c, 0x9aaa, 0x080c, 0x9abc, 0x9e80,
-	0x0004, 0x20e9, 0x0000, 0x20a0, 0x7814, 0x0096, 0x2048, 0xa800,
-	0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098, 0x009e,
-	0x7808, 0x9088, 0x0002, 0x21a8, 0x9192, 0x0010, 0x1250, 0x4003,
-	0x9080, 0x0004, 0x8003, 0x60c2, 0x080c, 0x9de6, 0x002e, 0x001e,
-	0x0005, 0x20a9, 0x0010, 0x4003, 0x080c, 0xa668, 0x20a1, 0x0240,
-	0x22a8, 0x4003, 0x0c68, 0x080c, 0x9a83, 0x7003, 0x6200, 0x7808,
-	0x700e, 0x60c3, 0x0008, 0x0804, 0x9de6, 0x0016, 0x0026, 0x080c,
-	0x9a83, 0x20e9, 0x0000, 0x20a1, 0x024c, 0x7814, 0x0096, 0x2048,
-	0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0023, 0x2098,
-	0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x4003, 0x8003, 0x60c2,
-	0x080c, 0x9de6, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00c6, 0x0006,
-	0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7010, 0x2060, 0x8cff,
-	0x0188, 0x080c, 0xca47, 0x1110, 0x080c, 0xb5a6, 0x600c, 0x0006,
-	0x080c, 0xccc3, 0x600f, 0x0000, 0x080c, 0xabdf, 0x080c, 0xa1f0,
-	0x00ce, 0x0c68, 0x2c00, 0x7012, 0x700e, 0x012e, 0x000e, 0x00ce,
-	0x00ee, 0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6,
-	0x0066, 0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001, 0x180c,
-	0x200c, 0x918c, 0xe7ff, 0x2102, 0x2069, 0x0100, 0x2079, 0x0140,
-	0x2071, 0x19e6, 0x7030, 0x2060, 0x8cff, 0x0548, 0x080c, 0x9e16,
-	0x6ac0, 0x68c3, 0x0000, 0x080c, 0x86d5, 0x00c6, 0x2061, 0x0100,
-	0x080c, 0xa7b9, 0x00ce, 0x20a9, 0x01f4, 0x04b1, 0x080c, 0x95c6,
-	0x6044, 0xd0ac, 0x1128, 0x2001, 0x1987, 0x2004, 0x604a, 0x0020,
-	0x2009, 0x0013, 0x080c, 0xac7c, 0x000e, 0x001e, 0x002e, 0x006e,
-	0x00ce, 0x00de, 0x00ee, 0x00fe, 0x015e, 0x012e, 0x0005, 0x2001,
-	0x1800, 0x2004, 0x9096, 0x0001, 0x0d78, 0x9096, 0x0004, 0x0d60,
-	0x080c, 0x86d5, 0x6814, 0x9084, 0x0001, 0x0110, 0x68a7, 0x95f5,
-	0x6817, 0x0008, 0x68c3, 0x0000, 0x2011, 0x5e89, 0x080c, 0x861d,
-	0x20a9, 0x01f4, 0x0009, 0x08c0, 0x6824, 0xd094, 0x0140, 0x6827,
-	0x0004, 0x7804, 0x9084, 0x4000, 0x190c, 0x2a39, 0x0090, 0xd084,
-	0x0118, 0x6827, 0x0001, 0x0010, 0x1f04, 0xa0dc, 0x7804, 0x9084,
-	0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2a29, 0x9006, 0x080c,
-	0x2a29, 0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6,
-	0x0066, 0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001, 0x180c,
-	0x200c, 0x918c, 0xdbff, 0x2102, 0x2069, 0x0100, 0x2079, 0x0140,
-	0x2071, 0x0380, 0x701c, 0x0006, 0x701f, 0x0202, 0x2071, 0x19e6,
-	0x704c, 0x2060, 0x8cff, 0x0904, 0xa19f, 0x9386, 0x0002, 0x1128,
-	0x6814, 0x9084, 0x0002, 0x0904, 0xa19f, 0x68af, 0x95f5, 0x6817,
-	0x0010, 0x2009, 0x00fa, 0x8109, 0x1df0, 0x69c6, 0x68cb, 0x0008,
-	0x080c, 0x86e2, 0x080c, 0x1de5, 0x0046, 0x2009, 0x00a5, 0x080c,
-	0x0e55, 0x2021, 0x0169, 0x2404, 0x9084, 0x000f, 0x9086, 0x0004,
-	0x11f8, 0x68af, 0x95f5, 0x68c6, 0x68cb, 0x0008, 0x00e6, 0x00f6,
-	0x2079, 0x0090, 0x2071, 0x19e6, 0x6814, 0x9084, 0x1984, 0x9085,
-	0x0012, 0x6816, 0x782b, 0x0008, 0x7057, 0x0000, 0x00fe, 0x00ee,
-	0x9386, 0x0002, 0x1128, 0x7884, 0x9005, 0x1110, 0x7887, 0x0001,
-	0x0016, 0x2009, 0x0040, 0x080c, 0x21c1, 0x001e, 0x2009, 0x0000,
-	0x080c, 0x0e55, 0x004e, 0x20a9, 0x03e8, 0x6824, 0xd094, 0x0140,
-	0x6827, 0x0004, 0x7804, 0x9084, 0x4000, 0x190c, 0x2a39, 0x0090,
-	0xd08c, 0x0118, 0x6827, 0x0002, 0x0010, 0x1f04, 0xa16d, 0x7804,
-	0x9084, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2a29, 0x9006,
-	0x080c, 0x2a29, 0x6827, 0x4000, 0x6824, 0x83ff, 0x1180, 0x2009,
-	0x0049, 0x6020, 0x9086, 0x0009, 0x0150, 0x080c, 0x9621, 0x6044,
-	0xd0ac, 0x1118, 0x6003, 0x0002, 0x0010, 0x080c, 0xac7c, 0x000e,
-	0x2071, 0x0380, 0xd08c, 0x1110, 0x701f, 0x0200, 0x000e, 0x001e,
-	0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x015e, 0x012e,
-	0x0005, 0x00d6, 0x0126, 0x2091, 0x8000, 0x2069, 0x19e6, 0x6a06,
-	0x012e, 0x00de, 0x0005, 0x00d6, 0x0126, 0x2091, 0x8000, 0x2069,
-	0x19e6, 0x6a3e, 0x012e, 0x00de, 0x0005, 0x080c, 0x9bd1, 0x785c,
-	0x7032, 0x7042, 0x7047, 0x1000, 0x00f8, 0x080c, 0x9bd1, 0x785c,
-	0x7032, 0x7042, 0x7047, 0x4000, 0x00b8, 0x080c, 0x9bd1, 0x785c,
-	0x7032, 0x7042, 0x7047, 0x2000, 0x0078, 0x080c, 0x9bd1, 0x785c,
-	0x7032, 0x7042, 0x7047, 0x0400, 0x0038, 0x080c, 0x9bd1, 0x785c,
-	0x7032, 0x7042, 0x7047, 0x0200, 0x60c3, 0x0020, 0x0804, 0x9de6,
-	0x00e6, 0x2071, 0x19e6, 0x702c, 0x9005, 0x0110, 0x8001, 0x702e,
-	0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066,
-	0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7620, 0x2660,
-	0x2678, 0x2039, 0x0001, 0x87ff, 0x0904, 0xa295, 0x8cff, 0x0904,
-	0xa295, 0x6020, 0x9086, 0x0006, 0x1904, 0xa290, 0x88ff, 0x0138,
-	0x2800, 0x9c06, 0x1904, 0xa290, 0x2039, 0x0000, 0x0050, 0x6010,
-	0x9b06, 0x1904, 0xa290, 0x85ff, 0x0120, 0x605c, 0x9106, 0x1904,
-	0xa290, 0x7030, 0x9c06, 0x15b0, 0x2069, 0x0100, 0x68c0, 0x9005,
-	0x1160, 0x6824, 0xd084, 0x0148, 0x6827, 0x0001, 0x080c, 0x86d5,
-	0x080c, 0xa31a, 0x7033, 0x0000, 0x0428, 0x080c, 0x86d5, 0x6820,
-	0xd0b4, 0x0110, 0x68a7, 0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000,
-	0x080c, 0xa31a, 0x7033, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04,
-	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2a29, 0x9006,
-	0x080c, 0x2a29, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
-	0x0001, 0x003e, 0x7020, 0x9c36, 0x1110, 0x660c, 0x7622, 0x701c,
-	0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x701e, 0x0010,
-	0x701f, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e,
-	0x0008, 0x2678, 0x89ff, 0x1168, 0x600f, 0x0000, 0x6014, 0x0096,
-	0x2048, 0x080c, 0xc830, 0x0110, 0x080c, 0xe27c, 0x009e, 0x080c,
-	0xac1a, 0x080c, 0xa1f0, 0x88ff, 0x1190, 0x00ce, 0x0804, 0xa20b,
-	0x2c78, 0x600c, 0x2060, 0x0804, 0xa20b, 0x9006, 0x012e, 0x000e,
-	0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b,
-	0x0000, 0x00ce, 0x98c5, 0x0001, 0x0c88, 0x00f6, 0x00e6, 0x00d6,
-	0x0096, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000,
-	0x2071, 0x19e6, 0x7648, 0x2660, 0x2678, 0x8cff, 0x0904, 0xa309,
-	0x6020, 0x9086, 0x0006, 0x1904, 0xa304, 0x87ff, 0x0128, 0x2700,
-	0x9c06, 0x1904, 0xa304, 0x0040, 0x6010, 0x9b06, 0x15e8, 0x85ff,
-	0x0118, 0x605c, 0x9106, 0x15c0, 0x704c, 0x9c06, 0x1168, 0x0036,
-	0x2019, 0x0001, 0x080c, 0xa0fa, 0x703f, 0x0000, 0x9006, 0x704e,
-	0x706a, 0x7052, 0x706e, 0x003e, 0x7048, 0x9c36, 0x1110, 0x660c,
-	0x764a, 0x7044, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00,
-	0x7046, 0x0010, 0x7047, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06,
-	0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x6014, 0x2048,
-	0x080c, 0xc830, 0x0110, 0x080c, 0xe27c, 0x080c, 0xac1a, 0x87ff,
-	0x1198, 0x00ce, 0x0804, 0xa2b5, 0x2c78, 0x600c, 0x2060, 0x0804,
-	0xa2b5, 0x9006, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x009e,
-	0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b, 0x0000, 0x00ce, 0x97bd,
-	0x0001, 0x0c80, 0x00e6, 0x2071, 0x19e6, 0x9006, 0x7032, 0x700a,
-	0x7004, 0x9086, 0x0003, 0x0158, 0x2001, 0x1800, 0x2004, 0x9086,
-	0x0002, 0x1118, 0x7007, 0x0005, 0x0010, 0x7007, 0x0000, 0x00ee,
-	0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126,
-	0x2091, 0x8000, 0x2071, 0x19e6, 0x2c10, 0x7648, 0x2660, 0x2678,
-	0x8cff, 0x0540, 0x2200, 0x9c06, 0x1508, 0x7048, 0x9c36, 0x1110,
-	0x660c, 0x764a, 0x7044, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118,
-	0x2f00, 0x7046, 0x0010, 0x7047, 0x0000, 0x660c, 0x2c00, 0x9f06,
-	0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x6004, 0x9086,
-	0x0040, 0x090c, 0x95c6, 0x9085, 0x0001, 0x0020, 0x2c78, 0x600c,
-	0x2060, 0x08b0, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x00ee,
-	0x00fe, 0x0005, 0x0096, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066,
-	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7610,
-	0x2660, 0x2678, 0x8cff, 0x0904, 0xa407, 0x6010, 0x00b6, 0x2058,
-	0xb8a0, 0x00be, 0x9206, 0x1904, 0xa402, 0x7030, 0x9c06, 0x1520,
-	0x2069, 0x0100, 0x68c0, 0x9005, 0x0904, 0xa3d9, 0x080c, 0x9e16,
-	0x68c3, 0x0000, 0x080c, 0xa31a, 0x7033, 0x0000, 0x0036, 0x2069,
-	0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c,
-	0x2a29, 0x9006, 0x080c, 0x2a29, 0x2069, 0x0100, 0x6824, 0xd084,
-	0x0110, 0x6827, 0x0001, 0x003e, 0x7010, 0x9c36, 0x1110, 0x660c,
-	0x7612, 0x700c, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00,
-	0x700e, 0x0010, 0x700f, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06,
-	0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x080c, 0xca36,
-	0x1180, 0x080c, 0x321e, 0x080c, 0xca47, 0x1518, 0x080c, 0xb5a6,
-	0x0400, 0x080c, 0xa31a, 0x6824, 0xd084, 0x09b0, 0x6827, 0x0001,
-	0x0898, 0x080c, 0xca47, 0x1118, 0x080c, 0xb5a6, 0x0090, 0x6014,
-	0x2048, 0x080c, 0xc830, 0x0168, 0x6020, 0x9086, 0x0003, 0x1508,
-	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6d6f, 0x080c,
-	0xca21, 0x080c, 0xccc3, 0x080c, 0xac1a, 0x080c, 0xa1f0, 0x00ce,
-	0x0804, 0xa382, 0x2c78, 0x600c, 0x2060, 0x0804, 0xa382, 0x012e,
-	0x000e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x009e,
-	0x0005, 0x6020, 0x9086, 0x0006, 0x1d20, 0x080c, 0xe27c, 0x0c08,
-	0x00d6, 0x080c, 0x9ace, 0x7003, 0x0200, 0x7007, 0x0014, 0x60c3,
-	0x0014, 0x20e1, 0x0001, 0x2099, 0x1988, 0x20e9, 0x0000, 0x20a1,
-	0x0250, 0x20a9, 0x0004, 0x4003, 0x7023, 0x0004, 0x7027, 0x7878,
-	0x080c, 0x9de6, 0x00de, 0x0005, 0x080c, 0x9ace, 0x700b, 0x0800,
-	0x7814, 0x9084, 0xff00, 0x700e, 0x7814, 0x9084, 0x00ff, 0x7022,
-	0x782c, 0x7026, 0x7860, 0x9084, 0x00ff, 0x9085, 0x0200, 0x7002,
-	0x7860, 0x9084, 0xff00, 0x8007, 0x7006, 0x60c2, 0x0804, 0x9de6,
-	0x00b6, 0x00d6, 0x0016, 0x00d6, 0x2f68, 0x2009, 0x0035, 0x080c,
-	0xcec9, 0x00de, 0x1904, 0xa4b5, 0x080c, 0x9a83, 0x7003, 0x1300,
-	0x782c, 0x080c, 0xa5c0, 0x2068, 0x6820, 0x9086, 0x0003, 0x0560,
-	0x7810, 0x2058, 0xbaa0, 0x080c, 0xab49, 0x11d8, 0x9286, 0x007e,
-	0x1128, 0x700b, 0x00ff, 0x700f, 0xfffe, 0x0498, 0x9286, 0x007f,
-	0x1128, 0x700b, 0x00ff, 0x700f, 0xfffd, 0x0458, 0x9284, 0xff80,
-	0x0180, 0x9286, 0x0080, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffc,
-	0x0400, 0x92d8, 0x1000, 0x2b5c, 0xb810, 0x700a, 0xb814, 0x700e,
-	0x00c0, 0xb884, 0x700e, 0x00a8, 0x080c, 0xab49, 0x1130, 0x7810,
-	0x2058, 0xb8a0, 0x9082, 0x007e, 0x0250, 0x00d6, 0x2069, 0x181f,
-	0x2d04, 0x700a, 0x8d68, 0x2d04, 0x700e, 0x00de, 0x0010, 0x6034,
-	0x700e, 0x7838, 0x7012, 0x783c, 0x7016, 0x60c3, 0x000c, 0x001e,
-	0x00de, 0x080c, 0x9de6, 0x00be, 0x0005, 0x781b, 0x0001, 0x7803,
-	0x0006, 0x001e, 0x00de, 0x00be, 0x0005, 0x792c, 0x9180, 0x0008,
-	0x200c, 0x9186, 0x0006, 0x01c0, 0x9186, 0x0003, 0x0904, 0xa533,
-	0x9186, 0x0005, 0x0904, 0xa51b, 0x9186, 0x0004, 0x05f0, 0x9186,
-	0x0008, 0x0904, 0xa524, 0x7807, 0x0037, 0x782f, 0x0003, 0x7817,
-	0x1700, 0x080c, 0xa59d, 0x0005, 0x080c, 0xa55e, 0x00d6, 0x0026,
-	0x792c, 0x2168, 0x2009, 0x4000, 0x6800, 0x6a44, 0xd2fc, 0x11f8,
-	0x0002, 0xa4fc, 0xa507, 0xa4fe, 0xa507, 0xa503, 0xa4fc, 0xa4fc,
-	0xa507, 0xa507, 0xa507, 0xa507, 0xa4fc, 0xa4fc, 0xa4fc, 0xa4fc,
-	0xa4fc, 0xa507, 0xa4fc, 0xa507, 0x080c, 0x0d7d, 0x6824, 0xd0e4,
-	0x0110, 0xd0cc, 0x0110, 0x900e, 0x0010, 0x2009, 0x2000, 0x682c,
-	0x7022, 0x6830, 0x7026, 0x0804, 0xa557, 0x080c, 0xa55e, 0x00d6,
-	0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x6a00, 0x9286, 0x0002,
-	0x1108, 0x900e, 0x04e0, 0x080c, 0xa55e, 0x00d6, 0x0026, 0x792c,
-	0x2168, 0x2009, 0x4000, 0x0498, 0x04c9, 0x00d6, 0x0026, 0x792c,
-	0x2168, 0x2009, 0x4000, 0x9286, 0x0005, 0x0118, 0x9286, 0x0002,
-	0x1108, 0x900e, 0x0420, 0x0451, 0x00d6, 0x0026, 0x792c, 0x2168,
-	0x6814, 0x0096, 0x2048, 0xa9ac, 0xa834, 0x9112, 0xa9b0, 0xa838,
-	0x009e, 0x9103, 0x7022, 0x7226, 0x792c, 0x9180, 0x0011, 0x2004,
-	0xd0fc, 0x1148, 0x9180, 0x0000, 0x2004, 0x908e, 0x0002, 0x0130,
-	0x908e, 0x0004, 0x0118, 0x2009, 0x4000, 0x0008, 0x900e, 0x712a,
-	0x60c3, 0x0018, 0x002e, 0x00de, 0x0804, 0x9de6, 0x00b6, 0x0036,
-	0x0046, 0x0056, 0x0066, 0x080c, 0x9ace, 0x9006, 0x7003, 0x0200,
-	0x7938, 0x710a, 0x793c, 0x710e, 0x7810, 0x2058, 0xb8a0, 0x080c,
-	0xab49, 0x1118, 0x9092, 0x007e, 0x0268, 0x00d6, 0x2069, 0x181f,
-	0x2d2c, 0x8d68, 0x2d34, 0x90d8, 0x1000, 0x2b5c, 0xbb10, 0xbc14,
-	0x00de, 0x0028, 0x901e, 0xbc84, 0x2029, 0x0000, 0x6634, 0x782c,
-	0x9080, 0x0008, 0x2004, 0x9086, 0x0003, 0x1128, 0x7512, 0x7616,
-	0x731a, 0x741e, 0x0020, 0x7312, 0x7416, 0x751a, 0x761e, 0x006e,
-	0x005e, 0x004e, 0x003e, 0x00be, 0x0005, 0x080c, 0x9ace, 0x7003,
-	0x0100, 0x782c, 0x700a, 0x7814, 0x700e, 0x700e, 0x60c3, 0x0008,
-	0x0804, 0x9de6, 0x080c, 0x9a7a, 0x7003, 0x1400, 0x7838, 0x700a,
-	0x0079, 0x783c, 0x700e, 0x782c, 0x7012, 0x7830, 0x7016, 0x7834,
-	0x9084, 0x00ff, 0x8007, 0x701a, 0x60c3, 0x0010, 0x0804, 0x9de6,
-	0x00e6, 0x2071, 0x0240, 0x0006, 0x00f6, 0x2078, 0x7810, 0x00b6,
-	0x2058, 0xb8d4, 0xd084, 0x0120, 0x7850, 0x702a, 0x784c, 0x702e,
-	0x00be, 0x00fe, 0x000e, 0x00ee, 0x0005, 0x080c, 0x9ac5, 0x7003,
-	0x0100, 0x782c, 0x700a, 0x7814, 0x700e, 0x60c3, 0x0008, 0x0804,
-	0x9de6, 0x00a9, 0x7914, 0x712a, 0x60c3, 0x0000, 0x60a7, 0x9575,
-	0x0026, 0x080c, 0x2998, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5,
-	0x2012, 0x002e, 0x080c, 0x9e09, 0x080c, 0x86cc, 0x0005, 0x0036,
-	0x0096, 0x00d6, 0x00e6, 0x7860, 0x2048, 0xaa7c, 0x9296, 0x00c0,
-	0x9294, 0xfffd, 0xaa7e, 0xaa80, 0x9294, 0x0300, 0xaa82, 0xa96c,
-	0x9194, 0x00ff, 0xab74, 0x9384, 0x00ff, 0x908d, 0xc200, 0xa96e,
-	0x9384, 0xff00, 0x9215, 0xaa76, 0xa870, 0xaa78, 0xa87a, 0xaa72,
-	0x00d6, 0x2069, 0x0200, 0x080c, 0xa67d, 0x00de, 0x20e9, 0x0000,
-	0x20a1, 0x0240, 0x20a9, 0x000a, 0xa860, 0x20e0, 0xa85c, 0x9080,
-	0x001b, 0x2098, 0x4003, 0x60a3, 0x0035, 0xaa68, 0x9294, 0x7000,
-	0x9286, 0x3000, 0x0110, 0x60a3, 0x0037, 0x00ee, 0x00de, 0x009e,
-	0x003e, 0x0005, 0x900e, 0x7814, 0x0096, 0x2048, 0xa87c, 0xd0fc,
-	0x01c0, 0x9084, 0x0003, 0x11a8, 0x2001, 0x180c, 0x2004, 0xd0bc,
-	0x0180, 0x7824, 0xd0cc, 0x1168, 0xd0c4, 0x1158, 0xa8a8, 0x9005,
-	0x1140, 0x2001, 0x180c, 0x200c, 0xc1d5, 0x2102, 0x2009, 0x19b1,
-	0x210c, 0x009e, 0x918d, 0x0092, 0x0010, 0x2009, 0x0096, 0x60ab,
-	0x0036, 0x0026, 0x2110, 0x900e, 0x080c, 0x2a72, 0x002e, 0x0005,
-	0x2009, 0x0009, 0x00a0, 0x2009, 0x000a, 0x0088, 0x2009, 0x000b,
-	0x0070, 0x2009, 0x000c, 0x0058, 0x2009, 0x000d, 0x0040, 0x2009,
-	0x000e, 0x0028, 0x2009, 0x000f, 0x0010, 0x2009, 0x0008, 0x6912,
-	0x0005, 0x080c, 0x9a83, 0x0016, 0x0026, 0x0096, 0x00d6, 0x7814,
-	0x2048, 0x7013, 0x0138, 0x2001, 0x1837, 0x2004, 0x9084, 0x0028,
-	0x1138, 0x2001, 0x197b, 0x2004, 0x9086, 0xaaaa, 0x1904, 0xa722,
-	0x7003, 0x5400, 0x00c6, 0x2061, 0x1800, 0x607c, 0x9084, 0x00ff,
-	0xa998, 0x810f, 0x918c, 0xff00, 0x9105, 0x700a, 0x6080, 0x700e,
-	0xa998, 0x918c, 0xff00, 0x7112, 0x20a9, 0x0004, 0x2009, 0x1805,
-	0x2e10, 0x9290, 0x0006, 0x2104, 0x2012, 0x8108, 0x8210, 0x1f04,
-	0xa6b3, 0x20a9, 0x0004, 0x2009, 0x1801, 0x2104, 0x2012, 0x8108,
-	0x8210, 0x1f04, 0xa6bd, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0029,
-	0x2098, 0x2009, 0x0006, 0x20a9, 0x0001, 0x4002, 0x8007, 0x2012,
-	0x8210, 0x8109, 0x1dc0, 0x00d6, 0x2069, 0x0200, 0x080c, 0xa668,
-	0x00de, 0x2071, 0x0240, 0x2011, 0x0240, 0x2009, 0x0002, 0x20a9,
-	0x0001, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0, 0x2009,
-	0x0008, 0x20a9, 0x0001, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109,
-	0x1dc0, 0xa85c, 0x9080, 0x0031, 0x2098, 0x2009, 0x0008, 0x20a9,
-	0x0001, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0, 0x00ce,
-	0x60c3, 0x004c, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x2001, 0x1837,
-	0x2004, 0x9084, 0x0028, 0x1168, 0x080c, 0x74c8, 0x0150, 0x6028,
-	0xc0bd, 0x602a, 0x2009, 0x1804, 0x2011, 0x0029, 0x080c, 0x2a72,
-	0x0010, 0x080c, 0x9de6, 0x080c, 0x86cc, 0x00de, 0x009e, 0x002e,
-	0x001e, 0x0005, 0x00e6, 0x2071, 0x0240, 0x2001, 0x2200, 0x9085,
-	0x00ff, 0x7002, 0x7007, 0xffff, 0x2071, 0x0100, 0x709b, 0x00ff,
-	0x00ee, 0x0804, 0xa698, 0x080c, 0x9a83, 0x0016, 0x0026, 0x0096,
-	0x00d6, 0x7814, 0x2048, 0x7013, 0x0138, 0x7003, 0x5500, 0x00c6,
-	0xa89c, 0x9084, 0x00ff, 0xa998, 0x810f, 0x918c, 0xff00, 0x9105,
-	0x700a, 0xa99c, 0x918c, 0xff00, 0xa8a0, 0x9084, 0x00ff, 0x9105,
-	0x700e, 0xa998, 0x918c, 0xff00, 0x2061, 0x1800, 0x607c, 0x9084,
-	0x00ff, 0x910d, 0x7112, 0x6180, 0x7116, 0x2009, 0x0008, 0xa860,
-	0x20e0, 0xa85c, 0x9080, 0x0029, 0x2098, 0x2e10, 0x9290, 0x0006,
+	0x00b6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0056, 0x0046, 0x0036,
+	0x2061, 0x0100, 0x2071, 0x1800, 0x7160, 0x7810, 0x2058, 0xb8a0,
+	0x2028, 0x76dc, 0xd6ac, 0x1168, 0x9582, 0x007e, 0x1250, 0x2500,
+	0x9094, 0xff80, 0x1130, 0x9080, 0x3388, 0x2015, 0x9294, 0x00ff,
+	0x0020, 0xb910, 0xba14, 0x737c, 0x7480, 0x70dc, 0xd0ac, 0x1130,
+	0x9582, 0x007e, 0x1218, 0x9584, 0xff80, 0x0138, 0x9185, 0x0400,
+	0x6062, 0x6266, 0x636a, 0x646e, 0x0030, 0x6063, 0x0400, 0x6266,
+	0x606b, 0x0000, 0x616e, 0xb8b8, 0x6072, 0x6077, 0x0000, 0xb864,
+	0xd0a4, 0x0110, 0x6077, 0x0008, 0xb88c, 0x8000, 0x9084, 0x00ff,
+	0xb88e, 0x8007, 0x9085, 0x0020, 0x607a, 0x607f, 0x0000, 0x2b00,
+	0x6082, 0x6087, 0xffff, 0x7814, 0x0096, 0x2048, 0xa848, 0x608a,
+	0xa844, 0x608e, 0xa838, 0x60c6, 0xa834, 0x60ca, 0x009e, 0xb86c,
+	0x60ce, 0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xba84,
+	0x629e, 0x00f6, 0x2079, 0x0140, 0x7803, 0x0000, 0x00fe, 0x900e,
+	0x2011, 0x0092, 0x080c, 0x2a92, 0x2009, 0x07d0, 0x080c, 0x870e,
+	0x003e, 0x004e, 0x005e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00be,
+	0x0005, 0x00b6, 0x0096, 0x00e6, 0x00d6, 0x00c6, 0x0056, 0x0046,
+	0x0036, 0x2061, 0x0100, 0x2071, 0x1800, 0x7810, 0x2058, 0xb8a0,
+	0x2028, 0xb910, 0xba14, 0x737c, 0x7480, 0x7820, 0x0002, 0x9d9e,
+	0x9d9e, 0x9d9e, 0x9d9e, 0x9d9e, 0x9d9e, 0x9d9e, 0x9d9e, 0x9d9e,
+	0x9d9e, 0x9da0, 0x9d9e, 0x9d9e, 0x9d9e, 0x9d9e, 0x080c, 0x0d7d,
+	0xb884, 0x609e, 0x7814, 0x2048, 0xa87c, 0xd0fc, 0x0558, 0xaf90,
+	0x9784, 0xff00, 0x9105, 0x6062, 0x873f, 0x9784, 0xff00, 0x0006,
+	0x7814, 0x2048, 0xa878, 0xc0fc, 0x9005, 0x000e, 0x1160, 0xaf94,
+	0x87ff, 0x0198, 0x2039, 0x0098, 0x9705, 0x6072, 0x7808, 0x6082,
+	0x2f00, 0x6086, 0x0038, 0x9185, 0x2200, 0x6062, 0x6073, 0x0129,
+	0x6077, 0x0000, 0xb884, 0x609e, 0x0050, 0x2039, 0x0029, 0x9705,
+	0x6072, 0x0cc0, 0x9185, 0x0200, 0x6062, 0x6073, 0x2029, 0xa87c,
+	0xd0fc, 0x0118, 0xaf94, 0x87ff, 0x1120, 0x2f00, 0x6082, 0x7808,
+	0x6086, 0x6266, 0x636a, 0x646e, 0x6077, 0x0000, 0xb88c, 0x8000,
+	0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000, 0xa848,
+	0x608a, 0xa844, 0x608e, 0xa838, 0x60c6, 0xa834, 0x60ca, 0xb86c,
+	0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0x080c, 0xa66e, 0x2009,
+	0x07d0, 0x60c4, 0x9084, 0xfff0, 0x9005, 0x0110, 0x2009, 0x1b58,
+	0x080c, 0x870e, 0x003e, 0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee,
+	0x009e, 0x00be, 0x0005, 0x7a40, 0x9294, 0x00ff, 0x8217, 0x0005,
+	0x00d6, 0x2069, 0x19e6, 0x686b, 0x0001, 0x00de, 0x0005, 0x60a3,
+	0x0056, 0x60a7, 0x9575, 0x00f1, 0x080c, 0x8700, 0x0005, 0x0016,
+	0x2001, 0x180c, 0x200c, 0x9184, 0x0600, 0x9086, 0x0600, 0x0128,
+	0x0089, 0x080c, 0x8700, 0x001e, 0x0005, 0xc1e5, 0x2001, 0x180c,
+	0x2102, 0x2001, 0x19e7, 0x2003, 0x0000, 0x2001, 0x19f2, 0x2003,
+	0x0000, 0x0c88, 0x0006, 0x0016, 0x0026, 0x2009, 0x1804, 0x2011,
+	0x0009, 0x080c, 0x2a92, 0x002e, 0x001e, 0x000e, 0x0005, 0x0016,
+	0x00c6, 0x0006, 0x080c, 0xa899, 0x0106, 0x2061, 0x0100, 0x61a4,
+	0x60a7, 0x95f5, 0x0016, 0x0026, 0x2009, 0x1804, 0x2011, 0x0008,
+	0x080c, 0x2a92, 0x002e, 0x001e, 0x010e, 0x090c, 0xa8b5, 0x000e,
+	0xa001, 0xa001, 0xa001, 0x61a6, 0x00ce, 0x001e, 0x0005, 0x00c6,
+	0x00d6, 0x0016, 0x0026, 0x2061, 0x0100, 0x2069, 0x0140, 0x080c,
+	0x74ec, 0x1510, 0x2001, 0x1a0b, 0x2004, 0x9005, 0x1904, 0x9ece,
+	0x080c, 0x7591, 0x11a8, 0x2069, 0x0380, 0x6843, 0x0101, 0x6844,
+	0xd084, 0x1de8, 0x2061, 0x0100, 0x6020, 0xd0b4, 0x1120, 0x6024,
+	0xd084, 0x090c, 0x0d7d, 0x6843, 0x0100, 0x080c, 0x8700, 0x04b0,
+	0x00c6, 0x2061, 0x19e6, 0x00f0, 0x6904, 0x9194, 0x4000, 0x0598,
+	0x080c, 0x9e4f, 0x080c, 0x2a59, 0x00c6, 0x2061, 0x19e6, 0x6134,
+	0x9192, 0x0008, 0x1278, 0x8108, 0x6136, 0x080c, 0xa899, 0x6130,
+	0x080c, 0xa8b5, 0x00ce, 0x81ff, 0x01c8, 0x080c, 0x8700, 0x080c,
+	0x9e42, 0x00a0, 0x080c, 0xa899, 0x6130, 0x91e5, 0x0000, 0x0150,
+	0x080c, 0xe764, 0x080c, 0x8709, 0x6003, 0x0001, 0x2009, 0x0014,
+	0x080c, 0xac8d, 0x080c, 0xa8b5, 0x00ce, 0x0000, 0x002e, 0x001e,
+	0x00de, 0x00ce, 0x0005, 0x2001, 0x1a0b, 0x2004, 0x9005, 0x1db0,
+	0x00c6, 0x2061, 0x19e6, 0x6134, 0x9192, 0x0003, 0x1ad8, 0x8108,
+	0x6136, 0x00ce, 0x080c, 0x8700, 0x080c, 0x5eff, 0x2009, 0x1846,
+	0x2114, 0x8210, 0x220a, 0x0c10, 0x0096, 0x00c6, 0x00d6, 0x00e6,
+	0x0016, 0x0026, 0x080c, 0x8716, 0x080c, 0xa899, 0x2001, 0x0387,
+	0x2003, 0x0202, 0x2071, 0x19e6, 0x714c, 0x81ff, 0x0904, 0x9f76,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x080c, 0x74ec, 0x1510, 0x0036,
+	0x2019, 0x0002, 0x080c, 0xa133, 0x003e, 0x714c, 0x2160, 0x080c,
+	0xe764, 0x2009, 0x004a, 0x6220, 0x9296, 0x0009, 0x1130, 0x6114,
+	0x2148, 0xa87b, 0x0006, 0x2009, 0x004a, 0x6003, 0x0003, 0x080c,
+	0xac8d, 0x2001, 0x0386, 0x2003, 0x5040, 0x080c, 0x7591, 0x0804,
+	0x9f76, 0x6904, 0xd1f4, 0x0904, 0x9f83, 0x080c, 0x2a59, 0x00c6,
+	0x704c, 0x9065, 0x090c, 0x0d7d, 0x6020, 0x00ce, 0x9086, 0x0006,
+	0x1518, 0x61c8, 0x60c4, 0x9105, 0x11f8, 0x2009, 0x180c, 0x2104,
+	0xd0d4, 0x01d0, 0x6214, 0x9294, 0x1800, 0x1128, 0x6224, 0x9294,
+	0x0002, 0x1560, 0x0010, 0xc0d4, 0x200a, 0x6014, 0x9084, 0xe7fd,
+	0x9085, 0x0010, 0x6016, 0x704c, 0x2060, 0x080c, 0x965a, 0x2009,
+	0x0049, 0x080c, 0xac8d, 0x00d0, 0x0036, 0x2019, 0x0001, 0x080c,
+	0xa133, 0x003e, 0x714c, 0x2160, 0x080c, 0xe764, 0x2009, 0x004a,
+	0x6220, 0x9296, 0x0009, 0x1130, 0x6114, 0x2148, 0xa87b, 0x0006,
+	0x2009, 0x004a, 0x6003, 0x0003, 0x080c, 0xac8d, 0x2001, 0x0387,
+	0x2003, 0x0200, 0x080c, 0xa8b5, 0x002e, 0x001e, 0x00ee, 0x00de,
+	0x00ce, 0x009e, 0x0005, 0xd1ec, 0x1904, 0x9f2d, 0x0804, 0x9f2f,
+	0x0026, 0x00e6, 0x2071, 0x19e6, 0x706c, 0xd084, 0x01e8, 0xc084,
+	0x706e, 0x714c, 0x81ff, 0x01c0, 0x2071, 0x0100, 0x9188, 0x0008,
+	0x2114, 0x928e, 0x0006, 0x1138, 0x2009, 0x1984, 0x2011, 0x0012,
+	0x080c, 0x2a92, 0x0048, 0x928e, 0x0009, 0x0db0, 0x2009, 0x1984,
+	0x2011, 0x0016, 0x080c, 0x2a92, 0x00ee, 0x002e, 0x0005, 0x9036,
+	0x2001, 0x19f0, 0x2004, 0x9005, 0x0128, 0x9c06, 0x0128, 0x2c30,
+	0x600c, 0x0cc8, 0x9085, 0x0001, 0x0005, 0x00f6, 0x2079, 0x19e6,
+	0x610c, 0x9006, 0x600e, 0x6044, 0xc0fc, 0x6046, 0x86ff, 0x1140,
+	0x7824, 0x9c06, 0x1118, 0x7826, 0x782a, 0x0050, 0x792a, 0x0040,
+	0x00c6, 0x2660, 0x610e, 0x00ce, 0x7824, 0x9c06, 0x1108, 0x7e26,
+	0x080c, 0xa1fd, 0x080c, 0xca54, 0x00fe, 0x0005, 0x080c, 0x9abc,
+	0x7003, 0x1200, 0x7838, 0x7012, 0x783c, 0x7016, 0x00c6, 0x7820,
+	0x9086, 0x0004, 0x1148, 0x7810, 0x9005, 0x0130, 0x00b6, 0x2058,
+	0xb810, 0xb914, 0x00be, 0x0020, 0x2061, 0x1800, 0x607c, 0x6180,
+	0x9084, 0x00ff, 0x700a, 0x710e, 0x00ce, 0x60c3, 0x002c, 0x0804,
+	0x9e1f, 0x080c, 0x9abc, 0x7003, 0x0f00, 0x7808, 0xd09c, 0x0128,
+	0xb810, 0x9084, 0x00ff, 0x700a, 0xb814, 0x700e, 0x60c3, 0x0008,
+	0x0804, 0x9e1f, 0x0156, 0x080c, 0x9b07, 0x7003, 0x0200, 0x080c,
+	0x87ce, 0x20a9, 0x0006, 0x2011, 0xffec, 0x2019, 0xffed, 0x9ef0,
+	0x0002, 0x2305, 0x2072, 0x8e70, 0x2205, 0x2072, 0x8e70, 0x9398,
+	0x0002, 0x9290, 0x0002, 0x1f04, 0xa021, 0x60c3, 0x001c, 0x015e,
+	0x0804, 0x9e1f, 0x0016, 0x0026, 0x080c, 0x9ae3, 0x080c, 0x9af5,
+	0x9e80, 0x0004, 0x20e9, 0x0000, 0x20a0, 0x7814, 0x0096, 0x2048,
+	0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098,
+	0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x9192, 0x0010, 0x1250,
+	0x4003, 0x9080, 0x0004, 0x8003, 0x60c2, 0x080c, 0x9e1f, 0x002e,
+	0x001e, 0x0005, 0x20a9, 0x0010, 0x4003, 0x080c, 0xa679, 0x20a1,
+	0x0240, 0x22a8, 0x4003, 0x0c68, 0x080c, 0x9abc, 0x7003, 0x6200,
+	0x7808, 0x700e, 0x60c3, 0x0008, 0x0804, 0x9e1f, 0x0016, 0x0026,
+	0x080c, 0x9abc, 0x20e9, 0x0000, 0x20a1, 0x024c, 0x7814, 0x0096,
+	0x2048, 0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0023,
+	0x2098, 0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x4003, 0x8003,
+	0x60c2, 0x080c, 0x9e1f, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00c6,
+	0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7010, 0x2060,
+	0x8cff, 0x0188, 0x080c, 0xca7a, 0x1110, 0x080c, 0xb5c6, 0x600c,
+	0x0006, 0x080c, 0xccf6, 0x600f, 0x0000, 0x080c, 0xabf0, 0x080c,
+	0xa1fd, 0x00ce, 0x0c68, 0x2c00, 0x7012, 0x700e, 0x012e, 0x000e,
+	0x00ce, 0x00ee, 0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6,
+	0x00c6, 0x0066, 0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001,
+	0x180c, 0x200c, 0x918c, 0xe7ff, 0x2102, 0x2069, 0x0100, 0x2079,
+	0x0140, 0x2071, 0x19e6, 0x7030, 0x2060, 0x8cff, 0x0548, 0x080c,
+	0x9e4f, 0x6ac0, 0x68c3, 0x0000, 0x080c, 0x8709, 0x00c6, 0x2061,
+	0x0100, 0x080c, 0xa7ca, 0x00ce, 0x20a9, 0x01f4, 0x04b1, 0x080c,
+	0x95ff, 0x6044, 0xd0ac, 0x1128, 0x2001, 0x1987, 0x2004, 0x604a,
+	0x0020, 0x2009, 0x0013, 0x080c, 0xac8d, 0x000e, 0x001e, 0x002e,
+	0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x015e, 0x012e, 0x0005,
+	0x2001, 0x1800, 0x2004, 0x9096, 0x0001, 0x0d78, 0x9096, 0x0004,
+	0x0d60, 0x080c, 0x8709, 0x6814, 0x9084, 0x0001, 0x0110, 0x68a7,
+	0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000, 0x2011, 0x5ea9, 0x080c,
+	0x8651, 0x20a9, 0x01f4, 0x0009, 0x08c0, 0x6824, 0xd094, 0x0140,
+	0x6827, 0x0004, 0x7804, 0x9084, 0x4000, 0x190c, 0x2a59, 0x0090,
+	0xd084, 0x0118, 0x6827, 0x0001, 0x0010, 0x1f04, 0xa115, 0x7804,
+	0x9084, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2a49, 0x9006,
+	0x080c, 0x2a49, 0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6,
+	0x00c6, 0x0066, 0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001,
+	0x180c, 0x200c, 0x918c, 0xdbff, 0x2102, 0x2069, 0x0100, 0x2079,
+	0x0140, 0x2071, 0x0380, 0x701c, 0x0006, 0x701f, 0x0202, 0x2071,
+	0x19e6, 0x704c, 0x2060, 0x8cff, 0x0904, 0xa1ac, 0x9386, 0x0002,
+	0x1128, 0x6814, 0x9084, 0x0002, 0x0904, 0xa1ac, 0x68af, 0x95f5,
+	0x6817, 0x0010, 0x2009, 0x00fa, 0x8109, 0x1df0, 0x69c6, 0x68cb,
+	0x0008, 0x080c, 0x8716, 0x080c, 0x1dfd, 0x2001, 0x0032, 0x6920,
+	0xd1bc, 0x0130, 0x8001, 0x1dd8, 0x692c, 0x918d, 0x0008, 0x692e,
+	0x20a9, 0x03e8, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004, 0x7804,
+	0x9084, 0x4000, 0x190c, 0x2a59, 0x0090, 0xd08c, 0x0118, 0x6827,
+	0x0002, 0x0010, 0x1f04, 0xa17a, 0x7804, 0x9084, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2a49, 0x9006, 0x080c, 0x2a49, 0x6827,
+	0x4000, 0x6824, 0x83ff, 0x1180, 0x2009, 0x0049, 0x6020, 0x9086,
+	0x0009, 0x0150, 0x080c, 0x965a, 0x6044, 0xd0ac, 0x1118, 0x6003,
+	0x0002, 0x0010, 0x080c, 0xac8d, 0x000e, 0x2071, 0x0380, 0xd08c,
+	0x1110, 0x701f, 0x0200, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce,
+	0x00de, 0x00ee, 0x00fe, 0x015e, 0x012e, 0x0005, 0x00d6, 0x0126,
+	0x2091, 0x8000, 0x2069, 0x19e6, 0x6a06, 0x012e, 0x00de, 0x0005,
+	0x00d6, 0x0126, 0x2091, 0x8000, 0x2069, 0x19e6, 0x6a3e, 0x012e,
+	0x00de, 0x0005, 0x080c, 0x9c0a, 0x785c, 0x7032, 0x7042, 0x7047,
+	0x1000, 0x00f8, 0x080c, 0x9c0a, 0x785c, 0x7032, 0x7042, 0x7047,
+	0x4000, 0x00b8, 0x080c, 0x9c0a, 0x785c, 0x7032, 0x7042, 0x7047,
+	0x2000, 0x0078, 0x080c, 0x9c0a, 0x785c, 0x7032, 0x7042, 0x7047,
+	0x0400, 0x0038, 0x080c, 0x9c0a, 0x785c, 0x7032, 0x7042, 0x7047,
+	0x0200, 0x60c3, 0x0020, 0x0804, 0x9e1f, 0x00e6, 0x2071, 0x19e6,
+	0x702c, 0x9005, 0x0110, 0x8001, 0x702e, 0x00ee, 0x0005, 0x00f6,
+	0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066, 0x0006, 0x0126, 0x2091,
+	0x8000, 0x2071, 0x19e6, 0x7620, 0x2660, 0x2678, 0x2039, 0x0001,
+	0x87ff, 0x0904, 0xa2a2, 0x8cff, 0x0904, 0xa2a2, 0x6020, 0x9086,
+	0x0006, 0x1904, 0xa29d, 0x88ff, 0x0138, 0x2800, 0x9c06, 0x1904,
+	0xa29d, 0x2039, 0x0000, 0x0050, 0x6010, 0x9b06, 0x1904, 0xa29d,
+	0x85ff, 0x0120, 0x605c, 0x9106, 0x1904, 0xa29d, 0x7030, 0x9c06,
+	0x15b0, 0x2069, 0x0100, 0x68c0, 0x9005, 0x1160, 0x6824, 0xd084,
+	0x0148, 0x6827, 0x0001, 0x080c, 0x8709, 0x080c, 0xa327, 0x7033,
+	0x0000, 0x0428, 0x080c, 0x8709, 0x6820, 0xd0b4, 0x0110, 0x68a7,
+	0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000, 0x080c, 0xa327, 0x7033,
+	0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2a49, 0x9006, 0x080c, 0x2a49, 0x2069,
+	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x7020,
+	0x9c36, 0x1110, 0x660c, 0x7622, 0x701c, 0x9c36, 0x1140, 0x2c00,
+	0x9f36, 0x0118, 0x2f00, 0x701e, 0x0010, 0x701f, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x89ff,
+	0x1168, 0x600f, 0x0000, 0x6014, 0x0096, 0x2048, 0x080c, 0xc863,
+	0x0110, 0x080c, 0xe2b9, 0x009e, 0x080c, 0xac2b, 0x080c, 0xa1fd,
+	0x88ff, 0x1190, 0x00ce, 0x0804, 0xa218, 0x2c78, 0x600c, 0x2060,
+	0x0804, 0xa218, 0x9006, 0x012e, 0x000e, 0x006e, 0x007e, 0x00ce,
+	0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b, 0x0000, 0x00ce, 0x98c5,
+	0x0001, 0x0c88, 0x00f6, 0x00e6, 0x00d6, 0x0096, 0x00c6, 0x0066,
+	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7648,
+	0x2660, 0x2678, 0x8cff, 0x0904, 0xa316, 0x6020, 0x9086, 0x0006,
+	0x1904, 0xa311, 0x87ff, 0x0128, 0x2700, 0x9c06, 0x1904, 0xa311,
+	0x0040, 0x6010, 0x9b06, 0x15e8, 0x85ff, 0x0118, 0x605c, 0x9106,
+	0x15c0, 0x704c, 0x9c06, 0x1168, 0x0036, 0x2019, 0x0001, 0x080c,
+	0xa133, 0x703f, 0x0000, 0x9006, 0x704e, 0x706a, 0x7052, 0x706e,
+	0x003e, 0x7048, 0x9c36, 0x1110, 0x660c, 0x764a, 0x7044, 0x9c36,
+	0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7046, 0x0010, 0x7047,
+	0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
+	0x2678, 0x600f, 0x0000, 0x6014, 0x2048, 0x080c, 0xc863, 0x0110,
+	0x080c, 0xe2b9, 0x080c, 0xac2b, 0x87ff, 0x1198, 0x00ce, 0x0804,
+	0xa2c2, 0x2c78, 0x600c, 0x2060, 0x0804, 0xa2c2, 0x9006, 0x012e,
+	0x000e, 0x002e, 0x006e, 0x00ce, 0x009e, 0x00de, 0x00ee, 0x00fe,
+	0x0005, 0x601b, 0x0000, 0x00ce, 0x97bd, 0x0001, 0x0c80, 0x00e6,
+	0x2071, 0x19e6, 0x9006, 0x7032, 0x700a, 0x7004, 0x9086, 0x0003,
+	0x0158, 0x2001, 0x1800, 0x2004, 0x9086, 0x0002, 0x1118, 0x7007,
+	0x0005, 0x0010, 0x7007, 0x0000, 0x00ee, 0x0005, 0x00f6, 0x00e6,
+	0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071,
+	0x19e6, 0x2c10, 0x7648, 0x2660, 0x2678, 0x8cff, 0x0540, 0x2200,
+	0x9c06, 0x1508, 0x7048, 0x9c36, 0x1110, 0x660c, 0x764a, 0x7044,
+	0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7046, 0x0010,
+	0x7047, 0x0000, 0x660c, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
+	0x2678, 0x600f, 0x0000, 0x6004, 0x9086, 0x0040, 0x090c, 0x95ff,
+	0x9085, 0x0001, 0x0020, 0x2c78, 0x600c, 0x2060, 0x08b0, 0x012e,
+	0x000e, 0x002e, 0x006e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0096,
+	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2071, 0x19e6, 0x7610, 0x2660, 0x2678, 0x8cff,
+	0x0904, 0xa414, 0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206,
+	0x1904, 0xa40f, 0x7030, 0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0,
+	0x9005, 0x0904, 0xa3e6, 0x080c, 0x9e4f, 0x68c3, 0x0000, 0x080c,
+	0xa327, 0x7033, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384,
+	0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2a49, 0x9006, 0x080c,
+	0x2a49, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001,
+	0x003e, 0x7010, 0x9c36, 0x1110, 0x660c, 0x7612, 0x700c, 0x9c36,
+	0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700e, 0x0010, 0x700f,
+	0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
+	0x2678, 0x600f, 0x0000, 0x080c, 0xca69, 0x1180, 0x080c, 0x323e,
+	0x080c, 0xca7a, 0x1518, 0x080c, 0xb5c6, 0x0400, 0x080c, 0xa327,
+	0x6824, 0xd084, 0x09b0, 0x6827, 0x0001, 0x0898, 0x080c, 0xca7a,
+	0x1118, 0x080c, 0xb5c6, 0x0090, 0x6014, 0x2048, 0x080c, 0xc863,
+	0x0168, 0x6020, 0x9086, 0x0003, 0x1508, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x080c, 0x6d93, 0x080c, 0xca54, 0x080c, 0xccf6,
+	0x080c, 0xac2b, 0x080c, 0xa1fd, 0x00ce, 0x0804, 0xa38f, 0x2c78,
+	0x600c, 0x2060, 0x0804, 0xa38f, 0x012e, 0x000e, 0x002e, 0x006e,
+	0x00ce, 0x00de, 0x00ee, 0x00fe, 0x009e, 0x0005, 0x6020, 0x9086,
+	0x0006, 0x1d20, 0x080c, 0xe2b9, 0x0c08, 0x00d6, 0x080c, 0x9b07,
+	0x7003, 0x0200, 0x7007, 0x0014, 0x60c3, 0x0014, 0x20e1, 0x0001,
+	0x2099, 0x1988, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x20a9, 0x0004,
+	0x4003, 0x7023, 0x0004, 0x7027, 0x7878, 0x080c, 0x9e1f, 0x00de,
+	0x0005, 0x080c, 0x9b07, 0x700b, 0x0800, 0x7814, 0x9084, 0xff00,
+	0x700e, 0x7814, 0x9084, 0x00ff, 0x7022, 0x782c, 0x7026, 0x7860,
+	0x9084, 0x00ff, 0x9085, 0x0200, 0x7002, 0x7860, 0x9084, 0xff00,
+	0x8007, 0x7006, 0x60c2, 0x0804, 0x9e1f, 0x00b6, 0x00d6, 0x0016,
+	0x00d6, 0x2f68, 0x2009, 0x0035, 0x080c, 0xcefc, 0x00de, 0x1904,
+	0xa4c2, 0x080c, 0x9abc, 0x7003, 0x1300, 0x782c, 0x080c, 0xa5d1,
+	0x2068, 0x6820, 0x9086, 0x0003, 0x0560, 0x7810, 0x2058, 0xbaa0,
+	0x080c, 0xab5a, 0x11d8, 0x9286, 0x007e, 0x1128, 0x700b, 0x00ff,
+	0x700f, 0xfffe, 0x0498, 0x9286, 0x007f, 0x1128, 0x700b, 0x00ff,
+	0x700f, 0xfffd, 0x0458, 0x9284, 0xff80, 0x0180, 0x9286, 0x0080,
+	0x1128, 0x700b, 0x00ff, 0x700f, 0xfffc, 0x0400, 0x92d8, 0x1000,
+	0x2b5c, 0xb810, 0x700a, 0xb814, 0x700e, 0x00c0, 0xb884, 0x700e,
+	0x00a8, 0x080c, 0xab5a, 0x1130, 0x7810, 0x2058, 0xb8a0, 0x9082,
+	0x007e, 0x0250, 0x00d6, 0x2069, 0x181f, 0x2d04, 0x700a, 0x8d68,
+	0x2d04, 0x700e, 0x00de, 0x0010, 0x6034, 0x700e, 0x7838, 0x7012,
+	0x783c, 0x7016, 0x60c3, 0x000c, 0x001e, 0x00de, 0x080c, 0x9e1f,
+	0x00be, 0x0005, 0x781b, 0x0001, 0x7803, 0x0006, 0x001e, 0x00de,
+	0x00be, 0x0005, 0x792c, 0x9180, 0x0008, 0x200c, 0x9186, 0x0006,
+	0x01c0, 0x9186, 0x0003, 0x0904, 0xa541, 0x9186, 0x0005, 0x0904,
+	0xa529, 0x9186, 0x0004, 0x05f0, 0x9186, 0x0008, 0x0904, 0xa532,
+	0x7807, 0x0037, 0x782f, 0x0003, 0x7817, 0x1700, 0x080c, 0xa5ae,
+	0x0005, 0x080c, 0xa56f, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009,
+	0x4000, 0x6800, 0x6a44, 0xd2fc, 0x11f8, 0x0002, 0xa509, 0xa514,
+	0xa50b, 0xa514, 0xa510, 0xa509, 0xa509, 0xa514, 0xa514, 0xa514,
+	0xa514, 0xa509, 0xa509, 0xa509, 0xa509, 0xa509, 0xa514, 0xa509,
+	0xa514, 0x080c, 0x0d7d, 0x6824, 0xd0e4, 0x0110, 0xd0cc, 0x0110,
+	0x900e, 0x0010, 0x2009, 0x2000, 0x682c, 0x7022, 0x6830, 0x7026,
+	0x0804, 0xa568, 0x080c, 0xa56f, 0x00d6, 0x0026, 0x792c, 0x2168,
+	0x2009, 0x4000, 0x6a00, 0x9286, 0x0002, 0x1108, 0x900e, 0x0804,
+	0xa568, 0x080c, 0xa56f, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009,
+	0x4000, 0x04b0, 0x04e1, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009,
+	0x4000, 0x9286, 0x0005, 0x0118, 0x9286, 0x0002, 0x1108, 0x900e,
+	0x0438, 0x0469, 0x00d6, 0x0026, 0x792c, 0x2168, 0x6814, 0x6924,
+	0xc185, 0x6926, 0x0096, 0x2048, 0xa9ac, 0xa834, 0x9112, 0xa9b0,
+	0xa838, 0x009e, 0x9103, 0x7022, 0x7226, 0x792c, 0x9180, 0x0011,
+	0x2004, 0xd0fc, 0x1148, 0x9180, 0x0000, 0x2004, 0x908e, 0x0002,
+	0x0130, 0x908e, 0x0004, 0x0118, 0x2009, 0x4000, 0x0008, 0x900e,
+	0x712a, 0x60c3, 0x0018, 0x002e, 0x00de, 0x0804, 0x9e1f, 0x00b6,
+	0x0036, 0x0046, 0x0056, 0x0066, 0x080c, 0x9b07, 0x9006, 0x7003,
+	0x0200, 0x7938, 0x710a, 0x793c, 0x710e, 0x7810, 0x2058, 0xb8a0,
+	0x080c, 0xab5a, 0x1118, 0x9092, 0x007e, 0x0268, 0x00d6, 0x2069,
+	0x181f, 0x2d2c, 0x8d68, 0x2d34, 0x90d8, 0x1000, 0x2b5c, 0xbb10,
+	0xbc14, 0x00de, 0x0028, 0x901e, 0xbc84, 0x2029, 0x0000, 0x6634,
+	0x782c, 0x9080, 0x0008, 0x2004, 0x9086, 0x0003, 0x1128, 0x7512,
+	0x7616, 0x731a, 0x741e, 0x0020, 0x7312, 0x7416, 0x751a, 0x761e,
+	0x006e, 0x005e, 0x004e, 0x003e, 0x00be, 0x0005, 0x080c, 0x9b07,
+	0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e, 0x700e, 0x60c3,
+	0x0008, 0x0804, 0x9e1f, 0x080c, 0x9ab3, 0x7003, 0x1400, 0x7838,
+	0x700a, 0x0079, 0x783c, 0x700e, 0x782c, 0x7012, 0x7830, 0x7016,
+	0x7834, 0x9084, 0x00ff, 0x8007, 0x701a, 0x60c3, 0x0010, 0x0804,
+	0x9e1f, 0x00e6, 0x2071, 0x0240, 0x0006, 0x00f6, 0x2078, 0x7810,
+	0x00b6, 0x2058, 0xb8d4, 0xd084, 0x0120, 0x7850, 0x702a, 0x784c,
+	0x702e, 0x00be, 0x00fe, 0x000e, 0x00ee, 0x0005, 0x080c, 0x9afe,
+	0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e, 0x60c3, 0x0008,
+	0x0804, 0x9e1f, 0x00a9, 0x7914, 0x712a, 0x60c3, 0x0000, 0x60a7,
+	0x9575, 0x0026, 0x080c, 0x29b4, 0x0228, 0x2011, 0x0101, 0x2204,
+	0xc0c5, 0x2012, 0x002e, 0x080c, 0x9e42, 0x080c, 0x8700, 0x0005,
+	0x0036, 0x0096, 0x00d6, 0x00e6, 0x7860, 0x2048, 0xaa7c, 0x9296,
+	0x00c0, 0x9294, 0xfffd, 0xaa7e, 0xaa80, 0x9294, 0x0300, 0xaa82,
+	0xa96c, 0x9194, 0x00ff, 0xab74, 0x9384, 0x00ff, 0x908d, 0xc200,
+	0xa96e, 0x9384, 0xff00, 0x9215, 0xaa76, 0xa870, 0xaa78, 0xa87a,
+	0xaa72, 0x00d6, 0x2069, 0x0200, 0x080c, 0xa68e, 0x00de, 0x20e9,
+	0x0000, 0x20a1, 0x0240, 0x20a9, 0x000a, 0xa860, 0x20e0, 0xa85c,
+	0x9080, 0x001b, 0x2098, 0x4003, 0x60a3, 0x0035, 0xaa68, 0x9294,
+	0x7000, 0x9286, 0x3000, 0x0110, 0x60a3, 0x0037, 0x00ee, 0x00de,
+	0x009e, 0x003e, 0x0005, 0x900e, 0x7814, 0x0096, 0x2048, 0xa87c,
+	0xd0fc, 0x01c0, 0x9084, 0x0003, 0x11a8, 0x2001, 0x180c, 0x2004,
+	0xd0bc, 0x0180, 0x7824, 0xd0cc, 0x1168, 0xd0c4, 0x1158, 0xa8a8,
+	0x9005, 0x1140, 0x2001, 0x180c, 0x200c, 0xc1d5, 0x2102, 0x2009,
+	0x19b1, 0x210c, 0x009e, 0x918d, 0x0092, 0x0010, 0x2009, 0x0096,
+	0x60ab, 0x0036, 0x0026, 0x2110, 0x900e, 0x080c, 0x2a92, 0x002e,
+	0x0005, 0x2009, 0x0009, 0x00a0, 0x2009, 0x000a, 0x0088, 0x2009,
+	0x000b, 0x0070, 0x2009, 0x000c, 0x0058, 0x2009, 0x000d, 0x0040,
+	0x2009, 0x000e, 0x0028, 0x2009, 0x000f, 0x0010, 0x2009, 0x0008,
+	0x6912, 0x0005, 0x080c, 0x9abc, 0x0016, 0x0026, 0x0096, 0x00d6,
+	0x7814, 0x2048, 0x7013, 0x0138, 0x2001, 0x1837, 0x2004, 0x9084,
+	0x0028, 0x1138, 0x2001, 0x197b, 0x2004, 0x9086, 0xaaaa, 0x1904,
+	0xa733, 0x7003, 0x5400, 0x00c6, 0x2061, 0x1800, 0x607c, 0x9084,
+	0x00ff, 0xa998, 0x810f, 0x918c, 0xff00, 0x9105, 0x700a, 0x6080,
+	0x700e, 0xa998, 0x918c, 0xff00, 0x7112, 0x20a9, 0x0004, 0x2009,
+	0x1805, 0x2e10, 0x9290, 0x0006, 0x2104, 0x2012, 0x8108, 0x8210,
+	0x1f04, 0xa6c4, 0x20a9, 0x0004, 0x2009, 0x1801, 0x2104, 0x2012,
+	0x8108, 0x8210, 0x1f04, 0xa6ce, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x0029, 0x2098, 0x2009, 0x0006, 0x20a9, 0x0001, 0x4002, 0x8007,
+	0x2012, 0x8210, 0x8109, 0x1dc0, 0x00d6, 0x2069, 0x0200, 0x080c,
+	0xa679, 0x00de, 0x2071, 0x0240, 0x2011, 0x0240, 0x2009, 0x0002,
 	0x20a9, 0x0001, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0,
-	0x20a9, 0x0004, 0x2009, 0x1805, 0x2104, 0x2012, 0x8108, 0x8210,
-	0x1f04, 0xa774, 0x20a9, 0x0002, 0x2009, 0x1801, 0x2104, 0x2012,
-	0x8108, 0x8210, 0x1f04, 0xa77e, 0x00d6, 0x0016, 0x2069, 0x0200,
-	0x080c, 0xa668, 0x001e, 0x00de, 0x2071, 0x0240, 0x20a9, 0x0002,
-	0x2009, 0x1803, 0x2011, 0x0240, 0x2104, 0x2012, 0x8108, 0x8210,
-	0x1f04, 0xa794, 0x2009, 0x0008, 0x4002, 0x8007, 0x2012, 0x8210,
-	0x8109, 0x1dd0, 0x9006, 0x20a9, 0x0008, 0x2012, 0x8210, 0x1f04,
-	0xa7a5, 0x00ce, 0x60c3, 0x004c, 0x60a3, 0x0056, 0x60a7, 0x9575,
-	0x080c, 0x9de6, 0x080c, 0x86cc, 0x00de, 0x009e, 0x002e, 0x001e,
-	0x0005, 0x00d6, 0x9290, 0x0018, 0x8214, 0x20e9, 0x0000, 0x2069,
-	0x0200, 0x6813, 0x0000, 0x22a8, 0x9284, 0x00e0, 0x0128, 0x20a9,
-	0x0020, 0x9292, 0x0020, 0x0008, 0x9016, 0x20a1, 0x0240, 0x9006,
-	0x4004, 0x82ff, 0x0120, 0x6810, 0x8000, 0x6812, 0x0c60, 0x00de,
-	0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00a6, 0x0096, 0x0066,
-	0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7610, 0x2660, 0x2678,
-	0x8cff, 0x0904, 0xa865, 0x7030, 0x9c06, 0x1520, 0x2069, 0x0100,
-	0x68c0, 0x9005, 0x0904, 0xa837, 0x080c, 0x9e16, 0x68c3, 0x0000,
-	0x080c, 0xa31a, 0x7033, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04,
-	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2a29, 0x9006,
-	0x080c, 0x2a29, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
-	0x0001, 0x003e, 0x7010, 0x9c36, 0x1110, 0x660c, 0x7612, 0x700c,
-	0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700e, 0x0010,
-	0x700f, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e,
-	0x0008, 0x2678, 0x600f, 0x0000, 0x080c, 0xca36, 0x1180, 0x080c,
-	0x321e, 0x080c, 0xca47, 0x1518, 0x080c, 0xb5a6, 0x0400, 0x080c,
-	0xa31a, 0x6824, 0xd084, 0x09b0, 0x6827, 0x0001, 0x0898, 0x080c,
-	0xca47, 0x1118, 0x080c, 0xb5a6, 0x0090, 0x6014, 0x2048, 0x080c,
-	0xc830, 0x0168, 0x6020, 0x9086, 0x0003, 0x1520, 0xa867, 0x0103,
-	0xab7a, 0xa877, 0x0000, 0x080c, 0x6d7b, 0x080c, 0xca21, 0x080c,
-	0xccc3, 0x080c, 0xac1a, 0x080c, 0xa1f0, 0x00ce, 0x0804, 0xa7e8,
-	0x2c78, 0x600c, 0x2060, 0x0804, 0xa7e8, 0x7013, 0x0000, 0x700f,
-	0x0000, 0x012e, 0x006e, 0x009e, 0x00ae, 0x00ce, 0x00de, 0x00ee,
-	0x00fe, 0x0005, 0x6020, 0x9086, 0x0006, 0x1d08, 0x080c, 0xe27c,
-	0x08f0, 0x00f6, 0x0036, 0x2079, 0x0380, 0x7b18, 0xd3bc, 0x1de8,
-	0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080, 0x003e, 0x00fe, 0x0005,
-	0x0016, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0001,
-	0x1188, 0x2001, 0x0015, 0x0c29, 0x2009, 0x1000, 0x2001, 0x0382,
-	0x2004, 0x9084, 0x0007, 0x9086, 0x0003, 0x0120, 0x8109, 0x1db0,
-	0x080c, 0x0d7d, 0x001e, 0x0005, 0x2001, 0x0382, 0x2004, 0x9084,
-	0x0007, 0x9086, 0x0003, 0x1120, 0x2001, 0x0380, 0x2003, 0x0001,
-	0x0005, 0x0156, 0x0016, 0x0026, 0x00e6, 0x900e, 0x2071, 0x19e6,
-	0x0469, 0x0106, 0x0190, 0x7004, 0x9086, 0x0003, 0x0148, 0x20a9,
-	0x1000, 0x6044, 0xd0fc, 0x01d8, 0x1f04, 0xa8c1, 0x080c, 0x0d7d,
-	0x080c, 0xa888, 0x6044, 0xd0fc, 0x0190, 0x7030, 0x9c06, 0x1148,
-	0x080c, 0x95c6, 0x6044, 0xd0dc, 0x0150, 0xc0dc, 0x6046, 0x700a,
-	0x7042, 0x704c, 0x9c06, 0x190c, 0x0d7d, 0x080c, 0x9621, 0x010e,
-	0x1919, 0x00ee, 0x002e, 0x001e, 0x015e, 0x0005, 0x2001, 0x0382,
-	0x2004, 0x9084, 0x0007, 0x9086, 0x0003, 0x0005, 0x0126, 0x2091,
-	0x2400, 0x7808, 0xd0a4, 0x190c, 0x0d76, 0xd09c, 0x0128, 0x7820,
-	0x908c, 0xf000, 0x11b8, 0x0012, 0x012e, 0x0005, 0xa90e, 0xa94c,
-	0xa973, 0xa9aa, 0xa9ba, 0xa9cb, 0xa9da, 0xa9e8, 0xaa15, 0xaa19,
-	0xa90e, 0xa90e, 0xa90e, 0xa90e, 0xa90e, 0xa90e, 0x080c, 0x0d7d,
-	0x012e, 0x0005, 0x2060, 0x6044, 0xd0bc, 0x0140, 0xc0bc, 0x6046,
-	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0012, 0x012e, 0x0005,
-	0xa933, 0xa935, 0xa933, 0xa93b, 0xa933, 0xa933, 0xa933, 0xa933,
-	0xa933, 0xa935, 0xa933, 0xa935, 0xa933, 0xa935, 0xa933, 0xa933,
-	0xa933, 0xa935, 0xa933, 0x080c, 0x0d7d, 0x2009, 0x0013, 0x080c,
-	0xac7c, 0x012e, 0x0005, 0x6014, 0x2048, 0xa87c, 0xd0dc, 0x0130,
-	0x080c, 0x88a3, 0x080c, 0xabdf, 0x012e, 0x0005, 0x2009, 0x0049,
-	0x080c, 0xac7c, 0x012e, 0x0005, 0x080c, 0xa888, 0x2001, 0x1a0b,
-	0x2003, 0x0000, 0x7030, 0x9065, 0x090c, 0x0d7d, 0x7034, 0x9092,
-	0x00c8, 0x1258, 0x8000, 0x7036, 0x7004, 0x9086, 0x0003, 0x0110,
-	0x7007, 0x0000, 0x781f, 0x0808, 0x0040, 0x080c, 0xe727, 0x6003,
-	0x0001, 0x2009, 0x0014, 0x080c, 0xac7c, 0x781f, 0x0100, 0x080c,
-	0xa8a4, 0x012e, 0x0005, 0x080c, 0xa888, 0x714c, 0x81ff, 0x1128,
-	0x2011, 0x1a0e, 0x2013, 0x0000, 0x0438, 0x2061, 0x0100, 0x7150,
-	0x9192, 0x7530, 0x12f0, 0x8108, 0x7152, 0x714c, 0x9188, 0x0008,
-	0x210c, 0x918e, 0x0006, 0x1138, 0x6014, 0x9084, 0x1984, 0x9085,
-	0x0012, 0x6016, 0x0088, 0x714c, 0x9188, 0x0008, 0x210c, 0x918e,
-	0x0009, 0x0d90, 0x6014, 0x9084, 0x1984, 0x9085, 0x0016, 0x6016,
-	0x0018, 0x706c, 0xc085, 0x706e, 0x781f, 0x0200, 0x080c, 0xa8a4,
-	0x012e, 0x0005, 0x080c, 0xa888, 0x714c, 0x2160, 0x6003, 0x0003,
-	0x2009, 0x004a, 0x080c, 0xac7c, 0x781f, 0x0200, 0x080c, 0xa8a4,
-	0x012e, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820, 0x2060, 0x6003,
-	0x0003, 0x080c, 0xa888, 0x080c, 0x1d6d, 0x781f, 0x0400, 0x080c,
-	0xa8a4, 0x012e, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820, 0x2060,
-	0x080c, 0xa888, 0x080c, 0x1db5, 0x781f, 0x0400, 0x080c, 0xa8a4,
-	0x012e, 0x0005, 0x7030, 0x9065, 0x0148, 0x6044, 0xc0bc, 0x6046,
-	0x7104, 0x9186, 0x0003, 0x0110, 0x080c, 0x9685, 0x012e, 0x0005,
-	0x00f6, 0x703c, 0x9086, 0x0002, 0x0528, 0x704c, 0x907d, 0x0510,
-	0x7844, 0xc0bc, 0x7846, 0x7820, 0x9086, 0x0009, 0x0118, 0x080c,
-	0x9d40, 0x00c0, 0x7828, 0xd0fc, 0x1118, 0x080c, 0x9cbf, 0x0090,
-	0x2001, 0x1837, 0x2004, 0x9084, 0x0028, 0x1130, 0x2001, 0x197b,
-	0x2004, 0x9086, 0xaaaa, 0x1120, 0x2001, 0x0387, 0x2003, 0x1000,
-	0x080c, 0x9c44, 0x00fe, 0x012e, 0x0005, 0x080c, 0x7569, 0x012e,
-	0x0005, 0x080c, 0x0d7d, 0x0005, 0x00e6, 0x2071, 0x19e6, 0x6044,
-	0xc0bc, 0x6046, 0xd0fc, 0x01b8, 0x704c, 0x9c06, 0x1190, 0x2019,
-	0x0001, 0x080c, 0xa0fa, 0x704f, 0x0000, 0x2001, 0x0109, 0x2004,
-	0xd08c, 0x1138, 0x2001, 0x0108, 0x2004, 0xd0bc, 0x1110, 0x703f,
-	0x0000, 0x080c, 0xa331, 0x00ee, 0x0005, 0x0026, 0x7010, 0x9c06,
-	0x1178, 0x080c, 0xa1f0, 0x6044, 0xc0fc, 0x6046, 0x600c, 0x9015,
-	0x0120, 0x7212, 0x600f, 0x0000, 0x0010, 0x7212, 0x720e, 0x9006,
-	0x002e, 0x0005, 0x0026, 0x7020, 0x9c06, 0x1178, 0x080c, 0xa1f0,
-	0x6044, 0xc0fc, 0x6046, 0x600c, 0x9015, 0x0120, 0x7222, 0x600f,
-	0x0000, 0x0010, 0x7222, 0x721e, 0x9006, 0x002e, 0x0005, 0x00d6,
-	0x0036, 0x7830, 0x9c06, 0x1558, 0x2069, 0x0100, 0x68c0, 0x9005,
-	0x01f8, 0x080c, 0x86d5, 0x080c, 0x9e16, 0x68c3, 0x0000, 0x080c,
-	0xa31a, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2a29, 0x9006, 0x080c, 0x2a29, 0x2069, 0x0100,
-	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x9085, 0x0001, 0x0038,
-	0x7808, 0xc0ad, 0x780a, 0x6003, 0x0009, 0x630a, 0x9006, 0x003e,
-	0x00de, 0x0005, 0x0016, 0x0026, 0x0036, 0x6100, 0x2019, 0x0100,
-	0x2001, 0x0382, 0x2004, 0xd09c, 0x0190, 0x00c6, 0x0126, 0x2091,
-	0x2800, 0x0016, 0x0036, 0x080c, 0xa8ee, 0x003e, 0x001e, 0x012e,
-	0x00ce, 0x6200, 0x2200, 0x9106, 0x0d58, 0x2200, 0x0010, 0x8319,
-	0x1d38, 0x003e, 0x002e, 0x001e, 0x0005, 0x00d6, 0x0156, 0x080c,
-	0x9ace, 0x7a14, 0x82ff, 0x0138, 0x7003, 0x0100, 0x700b, 0x0003,
-	0x60c3, 0x0008, 0x0490, 0x7003, 0x0200, 0x7007, 0x0000, 0x2069,
-	0x1800, 0x901e, 0x6800, 0x9086, 0x0004, 0x1110, 0xc38d, 0x0060,
-	0x080c, 0x74c8, 0x1110, 0xc3ad, 0x0008, 0xc3a5, 0x6adc, 0xd29c,
-	0x1110, 0xd2ac, 0x0108, 0xc39d, 0x730e, 0x080c, 0x879a, 0x20a9,
-	0x0006, 0x2011, 0xfff4, 0x2019, 0xfff5, 0x2071, 0x0250, 0x2305,
-	0x2072, 0x8e70, 0x2205, 0x2072, 0x8e70, 0x9398, 0x0002, 0x9290,
-	0x0002, 0x1f04, 0xaaef, 0x60c3, 0x0020, 0x080c, 0x9de6, 0x015e,
-	0x00de, 0x0005, 0x0156, 0x080c, 0x9ace, 0x7a14, 0x82ff, 0x0168,
-	0x9286, 0xffff, 0x0118, 0x9282, 0x000e, 0x1238, 0x7003, 0x0100,
-	0x700b, 0x0003, 0x60c3, 0x0008, 0x0488, 0x7003, 0x0200, 0x7007,
-	0x001c, 0x700f, 0x0001, 0x2011, 0x19bc, 0x2204, 0x8007, 0x701a,
-	0x8210, 0x2204, 0x8007, 0x701e, 0x0421, 0x1120, 0xb8a0, 0x9082,
-	0x007f, 0x0248, 0x2001, 0x181f, 0x2004, 0x7022, 0x2001, 0x1820,
-	0x2004, 0x7026, 0x0030, 0x2001, 0x1818, 0x2004, 0x9084, 0x00ff,
-	0x7026, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9,
-	0x0000, 0x20a1, 0x0256, 0x4003, 0x60c3, 0x001c, 0x015e, 0x0804,
-	0x9de6, 0x0006, 0x2001, 0x1837, 0x2004, 0xd0ac, 0x000e, 0x0005,
-	0x2011, 0x0003, 0x080c, 0xa1b1, 0x2011, 0x0002, 0x080c, 0xa1bb,
-	0x080c, 0xa07a, 0x0036, 0x901e, 0x080c, 0xa0fa, 0x003e, 0x0005,
-	0x080c, 0x3361, 0x0188, 0x0016, 0x00b6, 0x00c6, 0x7010, 0x9085,
-	0x0020, 0x7012, 0x2009, 0x007e, 0x080c, 0x6620, 0xb85c, 0xc0ac,
-	0xb85e, 0x00ce, 0x00be, 0x001e, 0x0005, 0x2071, 0x188d, 0x7000,
-	0x9005, 0x0140, 0x2001, 0x0812, 0x2071, 0x1800, 0x7076, 0x707a,
-	0x706b, 0xffd4, 0x2071, 0x1800, 0x7074, 0x7056, 0x705b, 0x1ddc,
-	0x0005, 0x00e6, 0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7554,
-	0x9582, 0x0010, 0x0608, 0x7058, 0x2060, 0x6000, 0x9086, 0x0000,
-	0x0148, 0x9ce0, 0x001c, 0x7068, 0x9c02, 0x1208, 0x0cb0, 0x2061,
-	0x1ddc, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7556, 0x9ca8, 0x001c,
-	0x7068, 0x9502, 0x1230, 0x755a, 0x9085, 0x0001, 0x012e, 0x00ee,
-	0x0005, 0x705b, 0x1ddc, 0x0cc0, 0x9006, 0x0cc0, 0x00e6, 0x2071,
-	0x1800, 0x7554, 0x9582, 0x0010, 0x0600, 0x7058, 0x2060, 0x6000,
-	0x9086, 0x0000, 0x0148, 0x9ce0, 0x001c, 0x7068, 0x9c02, 0x1208,
-	0x0cb0, 0x2061, 0x1ddc, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7556,
-	0x9ca8, 0x001c, 0x7068, 0x9502, 0x1228, 0x755a, 0x9085, 0x0001,
-	0x00ee, 0x0005, 0x705b, 0x1ddc, 0x0cc8, 0x9006, 0x0cc8, 0x9c82,
-	0x1ddc, 0x0a0c, 0x0d7d, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1a0c,
-	0x0d7d, 0x9006, 0x6006, 0x600a, 0x600e, 0x6016, 0x601a, 0x6012,
-	0x6023, 0x0000, 0x6003, 0x0000, 0x601e, 0x605e, 0x6062, 0x6026,
-	0x602a, 0x602e, 0x6032, 0x6036, 0x603a, 0x603e, 0x604a, 0x602a,
-	0x6046, 0x6042, 0x2061, 0x1800, 0x6054, 0x8000, 0x6056, 0x0005,
-	0x9006, 0x600e, 0x6016, 0x601a, 0x6012, 0x6022, 0x6002, 0x601e,
-	0x605e, 0x6062, 0x604a, 0x6046, 0x2061, 0x1800, 0x6054, 0x8000,
-	0x6056, 0x0005, 0x0006, 0x6000, 0x9086, 0x0000, 0x01d0, 0x601c,
-	0xd084, 0x190c, 0x1a77, 0x6023, 0x0007, 0x2001, 0x1985, 0x2004,
-	0x0006, 0x9082, 0x0051, 0x000e, 0x0208, 0x8004, 0x601a, 0x080c,
-	0xe534, 0x604b, 0x0000, 0x6044, 0xd0fc, 0x1129, 0x9006, 0x6046,
-	0x6016, 0x000e, 0x0005, 0x080c, 0xa888, 0x0106, 0x2001, 0x19f9,
-	0x2004, 0x9c06, 0x1130, 0x0036, 0x2019, 0x0001, 0x080c, 0xa0fa,
-	0x003e, 0x080c, 0xa331, 0x010e, 0x090c, 0xa8a4, 0x0005, 0x00e6,
-	0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7554, 0x9582, 0x0001,
-	0x0608, 0x7058, 0x2060, 0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0,
-	0x001c, 0x7068, 0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1ddc, 0x0c98,
-	0x6003, 0x0008, 0x8529, 0x7556, 0x9ca8, 0x001c, 0x7068, 0x9502,
-	0x1230, 0x755a, 0x9085, 0x0001, 0x012e, 0x00ee, 0x0005, 0x705b,
-	0x1ddc, 0x0cc0, 0x9006, 0x0cc0, 0x6020, 0x9084, 0x000f, 0x0002,
-	0xac90, 0xac9a, 0xacb5, 0xacd0, 0xcfa4, 0xcfc1, 0xcfdc, 0xac90,
-	0xac9a, 0x8f7c, 0xacec, 0xac90, 0xac90, 0xac90, 0xac90, 0xac90,
-	0x9186, 0x0013, 0x1130, 0x6044, 0xd0fc, 0x0110, 0x080c, 0x95c6,
-	0x0005, 0x0005, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0d7d,
-	0x0013, 0x006e, 0x0005, 0xacb3, 0xb412, 0xb5ed, 0xacb3, 0xb683,
-	0xafb5, 0xacb3, 0xacb3, 0xb394, 0xbbed, 0xacb3, 0xacb3, 0xacb3,
-	0xacb3, 0xacb3, 0xacb3, 0x080c, 0x0d7d, 0x0066, 0x6000, 0x90b2,
-	0x0016, 0x1a0c, 0x0d7d, 0x0013, 0x006e, 0x0005, 0xacce, 0xc1f2,
-	0xacce, 0xacce, 0xacce, 0xacce, 0xacce, 0xacce, 0xc197, 0xc375,
-	0xacce, 0xc22f, 0xc2b3, 0xc22f, 0xc2b3, 0xacce, 0x080c, 0x0d7d,
-	0x6000, 0x9082, 0x0016, 0x1a0c, 0x0d7d, 0x6000, 0x0002, 0xacea,
-	0xbc37, 0xbcce, 0xbe4e, 0xbebd, 0xacea, 0xacea, 0xacea, 0xbc06,
-	0xc118, 0xc11b, 0xacea, 0xacea, 0xacea, 0xacea, 0xc14b, 0xacea,
-	0xacea, 0xacea, 0x080c, 0x0d7d, 0x0066, 0x6000, 0x90b2, 0x0016,
-	0x1a0c, 0x0d7d, 0x0013, 0x006e, 0x0005, 0xad05, 0xad05, 0xad43,
-	0xade2, 0xae62, 0xad05, 0xad05, 0xad05, 0xad07, 0xad05, 0xad05,
-	0xad05, 0xad05, 0xad05, 0xad05, 0xad05, 0x080c, 0x0d7d, 0x9186,
-	0x004c, 0x0560, 0x9186, 0x0003, 0x190c, 0x0d7d, 0x0096, 0x601c,
-	0xc0ed, 0x601e, 0x6003, 0x0003, 0x6106, 0x6014, 0x2048, 0xa87c,
-	0x9084, 0xa000, 0xc0b5, 0xa87e, 0xa8ac, 0xa836, 0xa8b0, 0xa83a,
-	0x9006, 0xa846, 0xa84a, 0xa884, 0x9092, 0x199a, 0x0210, 0x2001,
-	0x1999, 0x8003, 0x8013, 0x8213, 0x9210, 0x621a, 0x009e, 0x080c,
-	0x1bc7, 0x2009, 0x8030, 0x080c, 0x9247, 0x0005, 0x6010, 0x00b6,
-	0x2058, 0xbca0, 0x00be, 0x2c00, 0x080c, 0xae84, 0x080c, 0xcf69,
-	0x6003, 0x0007, 0x0005, 0x00d6, 0x0096, 0x00f6, 0x2079, 0x1800,
-	0x7a90, 0x6014, 0x2048, 0xa87c, 0xd0ec, 0x1110, 0x9290, 0x0018,
-	0xac78, 0xc4fc, 0x0046, 0xa8e0, 0x9005, 0x1140, 0xa8dc, 0x921a,
-	0x0140, 0x0220, 0xa87b, 0x0007, 0x2010, 0x0028, 0xa87b, 0x0015,
-	0x0010, 0xa87b, 0x0000, 0x8214, 0xa883, 0x0000, 0xaa02, 0x0006,
-	0x0016, 0x0026, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2400, 0x9005,
-	0x1108, 0x009a, 0x2100, 0x9086, 0x0015, 0x1118, 0x2001, 0x0001,
-	0x0038, 0x2100, 0x9086, 0x0016, 0x0118, 0x2001, 0x0001, 0x002a,
-	0x94a4, 0x0007, 0x8423, 0x9405, 0x0002, 0xadaa, 0xadaa, 0xada5,
-	0xada8, 0xadaa, 0xada2, 0xad95, 0xad95, 0xad95, 0xad95, 0xad95,
-	0xad95, 0xad95, 0xad95, 0xad95, 0xad95, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x002e, 0x001e, 0x000e, 0x004e, 0x00fe, 0x009e, 0x00de,
-	0x080c, 0x0d7d, 0x080c, 0xb842, 0x0028, 0x080c, 0xb927, 0x0010,
-	0x080c, 0xba1d, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e, 0x001e,
-	0x2c00, 0xa896, 0x000e, 0x080c, 0xaf42, 0x0530, 0xa804, 0xa80e,
-	0x00a6, 0x2050, 0xb100, 0x00ae, 0x8006, 0x8006, 0x8007, 0x90bc,
-	0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0xaacc, 0xabd0, 0xacd4,
-	0xadd8, 0x2031, 0x0000, 0x2041, 0x12a3, 0x080c, 0xb103, 0x0160,
-	0x000e, 0x9005, 0x0120, 0x00fe, 0x009e, 0x00de, 0x0005, 0x00fe,
-	0x009e, 0x00de, 0x0804, 0xabdf, 0x2001, 0x002c, 0x900e, 0x080c,
-	0xafa8, 0x0c70, 0x91b6, 0x0015, 0x0170, 0x91b6, 0x0016, 0x0158,
-	0x91b2, 0x0047, 0x0a0c, 0x0d7d, 0x91b2, 0x0050, 0x1a0c, 0x0d7d,
-	0x9182, 0x0047, 0x0042, 0x080c, 0xaa9a, 0x0120, 0x9086, 0x0002,
-	0x0904, 0xad43, 0x0005, 0xae04, 0xae04, 0xae06, 0xae38, 0xae04,
-	0xae04, 0xae04, 0xae04, 0xae4b, 0x080c, 0x0d7d, 0x00d6, 0x0016,
-	0x0096, 0x6003, 0x0004, 0x6114, 0x2148, 0xa87c, 0xd0fc, 0x01c0,
-	0xa878, 0xc0fc, 0x9005, 0x1158, 0xa894, 0x9005, 0x0140, 0x2001,
-	0x0000, 0x900e, 0x080c, 0xafa8, 0x080c, 0xabdf, 0x00a8, 0x6003,
-	0x0002, 0xa8a4, 0xa9a8, 0x9105, 0x1178, 0xa8ae, 0xa8b2, 0x0c78,
-	0xa87f, 0x0020, 0xa88c, 0xa88a, 0xa8a4, 0xa8ae, 0xa8a8, 0xa8b2,
-	0xa8c7, 0x0000, 0xa8cb, 0x0000, 0x009e, 0x001e, 0x00de, 0x0005,
-	0x080c, 0x9621, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xc832,
-	0x0120, 0xa87b, 0x0006, 0x080c, 0x6d7b, 0x009e, 0x00de, 0x080c,
-	0xabdf, 0x0804, 0x9684, 0x080c, 0x9621, 0x080c, 0x31ef, 0x080c,
-	0xcf66, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xc832, 0x0120,
-	0xa87b, 0x0029, 0x080c, 0x6d7b, 0x009e, 0x00de, 0x080c, 0xabdf,
-	0x0804, 0x9684, 0x9182, 0x0047, 0x0002, 0xae72, 0xae74, 0xae72,
-	0xae72, 0xae72, 0xae72, 0xae72, 0xae72, 0xae72, 0xae72, 0xae72,
-	0xae72, 0xae74, 0x080c, 0x0d7d, 0x00d6, 0x0096, 0x601f, 0x0000,
-	0x6114, 0x2148, 0xa87b, 0x0000, 0xa883, 0x0000, 0x080c, 0x6d7b,
-	0x009e, 0x00de, 0x0804, 0xabdf, 0x0026, 0x0036, 0x0056, 0x0066,
-	0x0096, 0x00a6, 0x00f6, 0x0006, 0x080c, 0x103a, 0x000e, 0x090c,
-	0x0d7d, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019, 0x21a0, 0x900e,
-	0x20a9, 0x0020, 0x4104, 0xa87a, 0x2079, 0x1800, 0x7990, 0x9188,
-	0x0018, 0x918c, 0x0fff, 0xa972, 0xac76, 0x2950, 0x00a6, 0x2001,
-	0x0205, 0x2003, 0x0000, 0x901e, 0x2029, 0x0001, 0x9182, 0x0034,
-	0x1228, 0x2011, 0x001f, 0x080c, 0xc3f8, 0x04c0, 0x2130, 0x2009,
-	0x0034, 0x2011, 0x001f, 0x080c, 0xc3f8, 0x96b2, 0x0034, 0xb004,
-	0x904d, 0x0110, 0x080c, 0x0fec, 0x080c, 0x103a, 0x01d0, 0x8528,
-	0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406, 0x968a, 0x003d,
-	0x1230, 0x2608, 0x2011, 0x001b, 0x080c, 0xc3f8, 0x00b8, 0x96b2,
-	0x003c, 0x2009, 0x003c, 0x2950, 0x2011, 0x001b, 0x080c, 0xc3f8,
-	0x0c18, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad,
-	0x0050, 0xb566, 0xb070, 0xc0fd, 0xb072, 0x0048, 0x2001, 0x0205,
-	0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566, 0x2a48,
-	0xa804, 0xa807, 0x0000, 0x0006, 0x080c, 0x6d7b, 0x000e, 0x2048,
-	0x9005, 0x1db0, 0x00fe, 0x00ae, 0x009e, 0x006e, 0x005e, 0x003e,
-	0x002e, 0x0005, 0x00d6, 0x00f6, 0x0096, 0x0006, 0x080c, 0x103a,
-	0x000e, 0x090c, 0x0d7d, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019,
-	0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104, 0xaa66, 0xa87a, 0x2079,
-	0x1800, 0x7990, 0x810c, 0x9188, 0x000c, 0x9182, 0x001a, 0x0210,
-	0x2009, 0x001a, 0x21a8, 0x810b, 0xa972, 0xac76, 0x2e98, 0xa85c,
-	0x9080, 0x001f, 0x20a0, 0x2001, 0x0205, 0x200c, 0x918d, 0x0080,
-	0x2102, 0x4003, 0x2003, 0x0000, 0x080c, 0x6d7b, 0x009e, 0x00fe,
-	0x00de, 0x0005, 0x0016, 0x00d6, 0x00f6, 0x0096, 0x0016, 0x2001,
-	0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x001e, 0x2079, 0x0200,
-	0x2e98, 0xa87c, 0xd0ec, 0x0118, 0x9e80, 0x000c, 0x2098, 0x2021,
-	0x003e, 0x901e, 0x9282, 0x0020, 0x0218, 0x2011, 0x0020, 0x2018,
-	0x9486, 0x003e, 0x1170, 0x0096, 0x080c, 0x103a, 0x2900, 0x009e,
-	0x05c0, 0xa806, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
-	0x20a0, 0x3300, 0x908e, 0x0260, 0x0140, 0x2009, 0x0280, 0x9102,
-	0x920a, 0x0218, 0x2010, 0x2100, 0x9318, 0x2200, 0x9402, 0x1228,
-	0x2400, 0x9202, 0x2410, 0x9318, 0x9006, 0x2020, 0x22a8, 0xa800,
-	0x9200, 0xa802, 0x20e1, 0x0000, 0x4003, 0x83ff, 0x0180, 0x3300,
-	0x9086, 0x0280, 0x1130, 0x7814, 0x8000, 0x9085, 0x0080, 0x7816,
-	0x2e98, 0x2310, 0x84ff, 0x0904, 0xaf57, 0x0804, 0xaf59, 0x9085,
-	0x0001, 0x7817, 0x0000, 0x009e, 0x00fe, 0x00de, 0x001e, 0x0005,
-	0x00d6, 0x0036, 0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x080c,
-	0x6d6f, 0x009e, 0x003e, 0x00de, 0x0005, 0x91b6, 0x0015, 0x1118,
-	0x080c, 0xabdf, 0x0030, 0x91b6, 0x0016, 0x190c, 0x0d7d, 0x080c,
-	0xabdf, 0x0005, 0x20a9, 0x000e, 0x20e1, 0x0000, 0x2e98, 0x6014,
-	0x0096, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x20a0, 0x009e, 0x4003,
-	0x0136, 0x9080, 0x001b, 0x20a0, 0x2011, 0x0006, 0x20a9, 0x0001,
-	0x3418, 0x8318, 0x23a0, 0x4003, 0x3318, 0x8318, 0x2398, 0x8211,
-	0x1db8, 0x2011, 0x0006, 0x013e, 0x20a0, 0x3318, 0x8318, 0x2398,
-	0x4003, 0x3418, 0x8318, 0x23a0, 0x8211, 0x1db8, 0x0096, 0x080c,
-	0xc832, 0x0130, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0x009e, 0x0804, 0xabdf, 0x0096, 0x00d6, 0x0036, 0x7330, 0x9386,
-	0x0200, 0x11a8, 0x6010, 0x00b6, 0x2058, 0xb8d7, 0x0000, 0x00be,
-	0x6014, 0x9005, 0x0130, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xab32, 0x080c, 0xabdf, 0x003e, 0x00de, 0x009e, 0x0005, 0x0011,
-	0x1d48, 0x0cc8, 0x0006, 0x0016, 0x080c, 0xcf51, 0x0188, 0x6014,
-	0x9005, 0x1170, 0x600b, 0x0003, 0x601b, 0x0000, 0x604b, 0x0000,
-	0x2009, 0x0022, 0x080c, 0xb3ea, 0x9006, 0x001e, 0x000e, 0x0005,
-	0x9085, 0x0001, 0x0cd0, 0x0096, 0x0016, 0x20a9, 0x0014, 0x9e80,
-	0x000c, 0x20e1, 0x0000, 0x2098, 0x6014, 0x2048, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x2001, 0x0205, 0x2003,
-	0x0001, 0x2099, 0x0260, 0x20a9, 0x0016, 0x4003, 0x20a9, 0x000a,
-	0xa804, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0,
-	0x4003, 0x2001, 0x0205, 0x2003, 0x0002, 0x2099, 0x0260, 0x20a9,
-	0x0020, 0x4003, 0x2003, 0x0000, 0x6014, 0x2048, 0xa800, 0x2048,
-	0xa867, 0x0103, 0x080c, 0xabdf, 0x001e, 0x009e, 0x0005, 0x0096,
-	0x0016, 0x900e, 0x7030, 0x9086, 0x0100, 0x0140, 0x7038, 0x9084,
-	0x00ff, 0x800c, 0x703c, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0004,
-	0x9108, 0x810b, 0x2011, 0x0002, 0x2019, 0x000c, 0x6014, 0x2048,
-	0x080c, 0xc3f8, 0x080c, 0xc832, 0x0140, 0x6014, 0x2048, 0xa807,
-	0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0xabdf, 0x001e,
-	0x009e, 0x0005, 0x0016, 0x2009, 0x0000, 0x7030, 0x9086, 0x0200,
-	0x0110, 0x2009, 0x0001, 0x0096, 0x6014, 0x904d, 0x090c, 0x0d7d,
-	0xa97a, 0x080c, 0x6d7b, 0x009e, 0x080c, 0xabdf, 0x001e, 0x0005,
-	0x0016, 0x0096, 0x7030, 0x9086, 0x0100, 0x1118, 0x2009, 0x0004,
-	0x0010, 0x7034, 0x800c, 0x810b, 0x2011, 0x000c, 0x2019, 0x000c,
-	0x6014, 0x2048, 0xa804, 0x0096, 0x9005, 0x0108, 0x2048, 0x080c,
-	0xc3f8, 0x009e, 0x080c, 0xc832, 0x0148, 0xa804, 0x9005, 0x1158,
-	0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0xabdf,
-	0x009e, 0x001e, 0x0005, 0x0086, 0x2040, 0xa030, 0x8007, 0x9086,
-	0x0100, 0x1118, 0x080c, 0xb5a6, 0x00e0, 0xa034, 0x8007, 0x800c,
-	0x8806, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
-	0x000c, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xaaa0,
-	0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x1289, 0x0019,
-	0x0d08, 0x008e, 0x0898, 0x0096, 0x0006, 0x080c, 0x103a, 0x000e,
-	0x01b0, 0xa8ab, 0x0dcb, 0xa876, 0x000e, 0xa8a2, 0x0006, 0xae6a,
-	0x2800, 0xa89e, 0xa97a, 0xaf72, 0xaa8e, 0xab92, 0xac96, 0xad9a,
-	0x0086, 0x2940, 0x080c, 0x112f, 0x008e, 0x9085, 0x0001, 0x009e,
-	0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210,
-	0x00b6, 0x2258, 0xba10, 0x00be, 0x9206, 0x1520, 0x700c, 0x6210,
-	0x00b6, 0x2258, 0xba14, 0x00be, 0x9206, 0x11e0, 0x604b, 0x0000,
-	0x2c68, 0x0016, 0x2009, 0x0035, 0x080c, 0xcec9, 0x001e, 0x1158,
-	0x622c, 0x2268, 0x2071, 0x026c, 0x6b20, 0x9386, 0x0003, 0x0130,
-	0x9386, 0x0006, 0x0128, 0x080c, 0xabdf, 0x0020, 0x0039, 0x0010,
-	0x080c, 0xb21f, 0x002e, 0x00de, 0x00ee, 0x0005, 0x0096, 0x6814,
-	0x2048, 0x9186, 0x0015, 0x0904, 0xb1fe, 0x918e, 0x0016, 0x1904,
-	0xb21d, 0x700c, 0x908c, 0xff00, 0x9186, 0x1700, 0x0120, 0x9186,
-	0x0300, 0x1904, 0xb1d8, 0x89ff, 0x1138, 0x6800, 0x9086, 0x000f,
-	0x0904, 0xb1ba, 0x0804, 0xb21b, 0x6808, 0x9086, 0xffff, 0x1904,
-	0xb200, 0xa87c, 0x9084, 0x0060, 0x9086, 0x0020, 0x1128, 0xa83c,
-	0xa940, 0x9105, 0x1904, 0xb200, 0x6824, 0xd0b4, 0x1904, 0xb200,
-	0x080c, 0xca21, 0x6864, 0xa882, 0xa87c, 0xc0dc, 0xc0f4, 0xc0d4,
-	0xa87e, 0x0026, 0x900e, 0x6a18, 0x2001, 0x000a, 0x080c, 0x9148,
-	0xa884, 0x920a, 0x0208, 0x8011, 0xaa86, 0x82ff, 0x002e, 0x1138,
-	0x00c6, 0x2d60, 0x080c, 0xc54b, 0x00ce, 0x0804, 0xb21b, 0x00c6,
-	0xa868, 0xd0fc, 0x1118, 0x080c, 0x60b6, 0x0010, 0x080c, 0x64ba,
-	0x00ce, 0x1904, 0xb200, 0x00c6, 0x2d60, 0x080c, 0xabdf, 0x00ce,
-	0x0804, 0xb21b, 0x00c6, 0x080c, 0xac4f, 0x0198, 0x6017, 0x0000,
-	0x6810, 0x6012, 0x080c, 0xcccb, 0x6023, 0x0003, 0x6904, 0x00c6,
-	0x2d60, 0x080c, 0xabdf, 0x00ce, 0x080c, 0xac7c, 0x00ce, 0x0804,
-	0xb21b, 0x2001, 0x1987, 0x2004, 0x684a, 0x00ce, 0x0804, 0xb21b,
-	0x7008, 0x9086, 0x000b, 0x11c8, 0x6010, 0x00b6, 0x2058, 0xb900,
-	0xc1bc, 0xb902, 0x00be, 0x00c6, 0x2d60, 0xa87b, 0x0003, 0x080c,
-	0xcf0b, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2009,
-	0x8020, 0x080c, 0x9200, 0x00ce, 0x0430, 0x700c, 0x9086, 0x2a00,
-	0x1138, 0x2001, 0x1987, 0x2004, 0x684a, 0x00e8, 0x04c1, 0x00e8,
-	0x89ff, 0x090c, 0x0d7d, 0x00c6, 0x00d6, 0x2d60, 0xa867, 0x0103,
-	0xa87b, 0x0003, 0x080c, 0x6b91, 0x080c, 0xca21, 0x080c, 0xac1a,
-	0x0026, 0x6010, 0x00b6, 0x2058, 0xba3c, 0x080c, 0x674b, 0x00be,
-	0x002e, 0x00de, 0x00ce, 0x080c, 0xabdf, 0x009e, 0x0005, 0x9186,
-	0x0015, 0x1128, 0x2001, 0x1987, 0x2004, 0x684a, 0x0068, 0x918e,
-	0x0016, 0x1160, 0x00c6, 0x2d00, 0x2060, 0x080c, 0xe534, 0x080c,
-	0x88a3, 0x080c, 0xabdf, 0x00ce, 0x080c, 0xabdf, 0x0005, 0x0026,
-	0x0036, 0x0046, 0x7228, 0xacb0, 0xabac, 0xd2f4, 0x0130, 0x2001,
-	0x1987, 0x2004, 0x684a, 0x0804, 0xb299, 0x00c6, 0x2d60, 0x080c,
-	0xc423, 0x00ce, 0x6804, 0x9086, 0x0050, 0x1168, 0x00c6, 0x2d00,
-	0x2060, 0x6003, 0x0001, 0x6007, 0x0050, 0x2009, 0x8023, 0x080c,
-	0x9200, 0x00ce, 0x04f0, 0x6800, 0x9086, 0x000f, 0x01a8, 0x89ff,
-	0x090c, 0x0d7d, 0x6800, 0x9086, 0x0004, 0x1190, 0xa87c, 0xd0ac,
-	0x0178, 0xa843, 0x0fff, 0xa83f, 0x0fff, 0xa880, 0xc0fc, 0xa882,
-	0x2001, 0x0001, 0x6832, 0x0400, 0x2001, 0x0007, 0x6832, 0x00e0,
-	0xa87c, 0xd0b4, 0x1150, 0xd0ac, 0x0db8, 0x6824, 0xd0f4, 0x1d48,
-	0xa838, 0xa934, 0x9105, 0x0d80, 0x0c20, 0xd2ec, 0x1d68, 0x7024,
-	0x9306, 0x1118, 0x7020, 0x9406, 0x0d38, 0x7020, 0x683e, 0x7024,
-	0x683a, 0x2001, 0x0005, 0x6832, 0x080c, 0xcbb5, 0x080c, 0x9684,
-	0x0010, 0x080c, 0xabdf, 0x004e, 0x003e, 0x002e, 0x0005, 0x00e6,
-	0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210, 0x00b6, 0x2258,
-	0xba10, 0x00be, 0x9206, 0x1904, 0xb304, 0x700c, 0x6210, 0x00b6,
-	0x2258, 0xba14, 0x00be, 0x9206, 0x1904, 0xb304, 0x6038, 0x2068,
-	0x6824, 0xc0dc, 0x6826, 0x6a20, 0x9286, 0x0007, 0x0904, 0xb304,
-	0x9286, 0x0002, 0x0904, 0xb304, 0x9286, 0x0000, 0x05e8, 0x6808,
-	0x633c, 0x9306, 0x15c8, 0x2071, 0x026c, 0x9186, 0x0015, 0x0570,
-	0x918e, 0x0016, 0x1100, 0x00c6, 0x6038, 0x2060, 0x6104, 0x9186,
-	0x004b, 0x01c0, 0x9186, 0x004c, 0x01a8, 0x9186, 0x004d, 0x0190,
-	0x9186, 0x004e, 0x0178, 0x9186, 0x0052, 0x0160, 0x6014, 0x0096,
-	0x2048, 0x080c, 0xc832, 0x090c, 0x0d7d, 0xa87b, 0x0003, 0x009e,
-	0x080c, 0xcf0b, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002,
-	0x2009, 0x8020, 0x080c, 0x9200, 0x00ce, 0x0030, 0x6038, 0x2070,
-	0x2001, 0x1987, 0x2004, 0x704a, 0x080c, 0xabdf, 0x002e, 0x00de,
-	0x00ee, 0x0005, 0x00b6, 0x0096, 0x00f6, 0x6014, 0x2048, 0x6010,
-	0x2058, 0x91b6, 0x0015, 0x0130, 0xba08, 0xbb0c, 0xbc00, 0xc48c,
-	0xbc02, 0x0460, 0x0096, 0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90,
-	0x0010, 0x2019, 0x000a, 0x20a9, 0x0004, 0x080c, 0xbbb5, 0x002e,
-	0x003e, 0x015e, 0x009e, 0x1904, 0xb373, 0x0096, 0x0156, 0x0036,
-	0x0026, 0x2b48, 0x9e90, 0x0014, 0x2019, 0x0006, 0x20a9, 0x0004,
-	0x080c, 0xbbb5, 0x002e, 0x003e, 0x015e, 0x009e, 0x15a0, 0x7238,
-	0xba0a, 0x733c, 0xbb0e, 0xbc00, 0xc48d, 0xbc02, 0xa804, 0x9005,
-	0x1128, 0x00fe, 0x009e, 0x00be, 0x0804, 0xafee, 0x0096, 0x2048,
-	0xaa12, 0xab16, 0xac0a, 0x009e, 0x8006, 0x8006, 0x8007, 0x90bc,
-	0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009, 0x002b, 0xaaa0,
-	0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x1289, 0x080c,
-	0xb103, 0x0130, 0x00fe, 0x009e, 0x080c, 0xabdf, 0x00be, 0x0005,
-	0x080c, 0xb5a6, 0x0cb8, 0x2b78, 0x00f6, 0x080c, 0x31ef, 0x080c,
-	0xcf66, 0x00fe, 0x00c6, 0x080c, 0xab89, 0x2f00, 0x6012, 0x6017,
-	0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x2001,
-	0x0007, 0x080c, 0x6570, 0x080c, 0x659c, 0x080c, 0x9207, 0x080c,
-	0x9684, 0x00ce, 0x0804, 0xb346, 0x2100, 0x91b2, 0x0053, 0x1a0c,
-	0x0d7d, 0x91b2, 0x0040, 0x1a04, 0xb3fc, 0x0002, 0xb3ea, 0xb3ea,
-	0xb3e0, 0xb3ea, 0xb3ea, 0xb3ea, 0xb3de, 0xb3de, 0xb3de, 0xb3de,
-	0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de,
-	0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de,
-	0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3ea, 0xb3de, 0xb3ea,
-	0xb3ea, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3e0, 0xb3de,
-	0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de,
-	0xb3ea, 0xb3ea, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de, 0xb3de,
-	0xb3de, 0xb3de, 0xb3de, 0xb3ea, 0xb3de, 0xb3de, 0x080c, 0x0d7d,
-	0x0066, 0x00b6, 0x6610, 0x2658, 0xb8d4, 0xc08c, 0xb8d6, 0x00be,
-	0x006e, 0x0000, 0x6003, 0x0001, 0x6106, 0x9186, 0x0032, 0x0118,
-	0x080c, 0x9207, 0x0010, 0x080c, 0x9200, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x9684, 0x012e, 0x0005, 0x2600, 0x0002, 0xb3ea, 0xb3ea,
-	0xb410, 0xb3ea, 0xb3ea, 0xb410, 0xb410, 0xb410, 0xb410, 0xb3ea,
-	0xb410, 0xb3ea, 0xb410, 0xb3ea, 0xb410, 0xb410, 0xb410, 0xb410,
-	0x080c, 0x0d7d, 0x6004, 0x90b2, 0x0053, 0x1a0c, 0x0d7d, 0x91b6,
-	0x0013, 0x0904, 0xb4e7, 0x91b6, 0x0027, 0x1904, 0xb493, 0x080c,
-	0x95c6, 0x6004, 0x080c, 0xca36, 0x01b0, 0x080c, 0xca47, 0x01a8,
-	0x908e, 0x0021, 0x0904, 0xb490, 0x908e, 0x0022, 0x1130, 0x080c,
-	0xb01a, 0x0904, 0xb48c, 0x0804, 0xb48d, 0x908e, 0x003d, 0x0904,
-	0xb490, 0x0804, 0xb486, 0x080c, 0x321e, 0x2001, 0x0007, 0x080c,
-	0x6570, 0x6010, 0x00b6, 0x2058, 0xb9a0, 0x00be, 0x080c, 0xb5a6,
-	0x9186, 0x007e, 0x1148, 0x2001, 0x1837, 0x2014, 0xc285, 0x080c,
-	0x74c8, 0x1108, 0xc2ad, 0x2202, 0x080c, 0xa888, 0x0036, 0x0026,
-	0x2019, 0x0028, 0x2110, 0x080c, 0xe640, 0x002e, 0x003e, 0x0016,
-	0x0026, 0x0036, 0x2110, 0x2019, 0x0028, 0x080c, 0x938d, 0x0076,
-	0x903e, 0x080c, 0x9256, 0x6010, 0x00b6, 0x905d, 0x0100, 0x00be,
-	0x2c08, 0x080c, 0xdffb, 0x007e, 0x003e, 0x002e, 0x001e, 0x080c,
-	0xa8a4, 0x080c, 0xcf66, 0x0016, 0x080c, 0xccc3, 0x080c, 0xabdf,
-	0x001e, 0x080c, 0x32f8, 0x080c, 0x9684, 0x0030, 0x080c, 0xccc3,
-	0x080c, 0xabdf, 0x080c, 0x9684, 0x0005, 0x080c, 0xb5a6, 0x0cb0,
-	0x080c, 0xb5e2, 0x0c98, 0x9186, 0x0015, 0x0118, 0x9186, 0x0016,
-	0x1140, 0x080c, 0xaa9a, 0x0d80, 0x9086, 0x0002, 0x0904, 0xb5ed,
-	0x0c58, 0x9186, 0x0014, 0x1d40, 0x080c, 0x95c6, 0x6004, 0x908e,
-	0x0022, 0x1118, 0x080c, 0xb01a, 0x09f8, 0x080c, 0x31ef, 0x080c,
-	0xcf66, 0x080c, 0xca36, 0x1190, 0x080c, 0x321e, 0x6010, 0x00b6,
-	0x2058, 0xb9a0, 0x00be, 0x080c, 0xb5a6, 0x9186, 0x007e, 0x1128,
-	0x2001, 0x1837, 0x200c, 0xc185, 0x2102, 0x0800, 0x080c, 0xca47,
-	0x1120, 0x080c, 0xb5a6, 0x0804, 0xb486, 0x6004, 0x908e, 0x0032,
-	0x1160, 0x00e6, 0x00f6, 0x2071, 0x189e, 0x2079, 0x0000, 0x080c,
-	0x3599, 0x00fe, 0x00ee, 0x0804, 0xb486, 0x6004, 0x908e, 0x0021,
-	0x0d40, 0x908e, 0x0022, 0x090c, 0xb5a6, 0x0804, 0xb486, 0x90b2,
-	0x0040, 0x1a04, 0xb586, 0x2008, 0x0002, 0xb52f, 0xb530, 0xb533,
-	0xb536, 0xb539, 0xb53c, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d,
-	0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d,
-	0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d,
-	0xb52d, 0xb52d, 0xb52d, 0xb53f, 0xb548, 0xb52d, 0xb549, 0xb548,
-	0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb548, 0xb548, 0xb52d,
-	0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb52d, 0xb571,
-	0xb548, 0xb52d, 0xb544, 0xb52d, 0xb52d, 0xb52d, 0xb545, 0xb52d,
-	0xb52d, 0xb52d, 0xb548, 0xb56c, 0xb52d, 0x080c, 0x0d7d, 0x00c0,
-	0x2001, 0x000b, 0x00e8, 0x2001, 0x0003, 0x00d0, 0x2001, 0x0005,
-	0x00b8, 0x2001, 0x0001, 0x00a0, 0x2001, 0x0009, 0x0088, 0x6003,
-	0x0005, 0x080c, 0x9684, 0x0058, 0x0018, 0x0010, 0x080c, 0x6570,
-	0x04b8, 0x080c, 0xcf69, 0x6003, 0x0004, 0x080c, 0x9684, 0x0005,
-	0x080c, 0x6570, 0x6003, 0x0002, 0x0036, 0x2019, 0x1852, 0x2304,
+	0x2009, 0x0008, 0x20a9, 0x0001, 0x4002, 0x8007, 0x2012, 0x8210,
+	0x8109, 0x1dc0, 0xa85c, 0x9080, 0x0031, 0x2098, 0x2009, 0x0008,
+	0x20a9, 0x0001, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109, 0x1dc0,
+	0x00ce, 0x60c3, 0x004c, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x2001,
+	0x1837, 0x2004, 0x9084, 0x0028, 0x1168, 0x080c, 0x74ec, 0x0150,
+	0x6028, 0xc0bd, 0x602a, 0x2009, 0x1804, 0x2011, 0x0029, 0x080c,
+	0x2a92, 0x0010, 0x080c, 0x9e1f, 0x080c, 0x8700, 0x00de, 0x009e,
+	0x002e, 0x001e, 0x0005, 0x00e6, 0x2071, 0x0240, 0x2001, 0x2200,
+	0x9085, 0x00ff, 0x7002, 0x7007, 0xffff, 0x2071, 0x0100, 0x709b,
+	0x00ff, 0x00ee, 0x0804, 0xa6a9, 0x080c, 0x9abc, 0x0016, 0x0026,
+	0x0096, 0x00d6, 0x7814, 0x2048, 0x7013, 0x0138, 0x7003, 0x5500,
+	0x00c6, 0xa89c, 0x9084, 0x00ff, 0xa998, 0x810f, 0x918c, 0xff00,
+	0x9105, 0x700a, 0xa99c, 0x918c, 0xff00, 0xa8a0, 0x9084, 0x00ff,
+	0x9105, 0x700e, 0xa998, 0x918c, 0xff00, 0x2061, 0x1800, 0x607c,
+	0x9084, 0x00ff, 0x910d, 0x7112, 0x6180, 0x7116, 0x2009, 0x0008,
+	0xa860, 0x20e0, 0xa85c, 0x9080, 0x0029, 0x2098, 0x2e10, 0x9290,
+	0x0006, 0x20a9, 0x0001, 0x4002, 0x8007, 0x2012, 0x8210, 0x8109,
+	0x1dc0, 0x20a9, 0x0004, 0x2009, 0x1805, 0x2104, 0x2012, 0x8108,
+	0x8210, 0x1f04, 0xa785, 0x20a9, 0x0002, 0x2009, 0x1801, 0x2104,
+	0x2012, 0x8108, 0x8210, 0x1f04, 0xa78f, 0x00d6, 0x0016, 0x2069,
+	0x0200, 0x080c, 0xa679, 0x001e, 0x00de, 0x2071, 0x0240, 0x20a9,
+	0x0002, 0x2009, 0x1803, 0x2011, 0x0240, 0x2104, 0x2012, 0x8108,
+	0x8210, 0x1f04, 0xa7a5, 0x2009, 0x0008, 0x4002, 0x8007, 0x2012,
+	0x8210, 0x8109, 0x1dd0, 0x9006, 0x20a9, 0x0008, 0x2012, 0x8210,
+	0x1f04, 0xa7b6, 0x00ce, 0x60c3, 0x004c, 0x60a3, 0x0056, 0x60a7,
+	0x9575, 0x080c, 0x9e1f, 0x080c, 0x8700, 0x00de, 0x009e, 0x002e,
+	0x001e, 0x0005, 0x00d6, 0x9290, 0x0018, 0x8214, 0x20e9, 0x0000,
+	0x2069, 0x0200, 0x6813, 0x0000, 0x22a8, 0x9284, 0x00e0, 0x0128,
+	0x20a9, 0x0020, 0x9292, 0x0020, 0x0008, 0x9016, 0x20a1, 0x0240,
+	0x9006, 0x4004, 0x82ff, 0x0120, 0x6810, 0x8000, 0x6812, 0x0c60,
+	0x00de, 0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00a6, 0x0096,
+	0x0066, 0x0126, 0x2091, 0x8000, 0x2071, 0x19e6, 0x7610, 0x2660,
+	0x2678, 0x8cff, 0x0904, 0xa876, 0x7030, 0x9c06, 0x1520, 0x2069,
+	0x0100, 0x68c0, 0x9005, 0x0904, 0xa848, 0x080c, 0x9e4f, 0x68c3,
+	0x0000, 0x080c, 0xa327, 0x7033, 0x0000, 0x0036, 0x2069, 0x0140,
+	0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2a49,
+	0x9006, 0x080c, 0x2a49, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
+	0x6827, 0x0001, 0x003e, 0x7010, 0x9c36, 0x1110, 0x660c, 0x7612,
+	0x700c, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700e,
+	0x0010, 0x700f, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110,
+	0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x080c, 0xca69, 0x1180,
+	0x080c, 0x323e, 0x080c, 0xca7a, 0x1518, 0x080c, 0xb5c6, 0x0400,
+	0x080c, 0xa327, 0x6824, 0xd084, 0x09b0, 0x6827, 0x0001, 0x0898,
+	0x080c, 0xca7a, 0x1118, 0x080c, 0xb5c6, 0x0090, 0x6014, 0x2048,
+	0x080c, 0xc863, 0x0168, 0x6020, 0x9086, 0x0003, 0x1520, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6d9f, 0x080c, 0xca54,
+	0x080c, 0xccf6, 0x080c, 0xac2b, 0x080c, 0xa1fd, 0x00ce, 0x0804,
+	0xa7f9, 0x2c78, 0x600c, 0x2060, 0x0804, 0xa7f9, 0x7013, 0x0000,
+	0x700f, 0x0000, 0x012e, 0x006e, 0x009e, 0x00ae, 0x00ce, 0x00de,
+	0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086, 0x0006, 0x1d08, 0x080c,
+	0xe2b9, 0x08f0, 0x00f6, 0x0036, 0x2079, 0x0380, 0x7b18, 0xd3bc,
+	0x1de8, 0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080, 0x003e, 0x00fe,
+	0x0005, 0x0016, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007, 0x9086,
+	0x0001, 0x1188, 0x2001, 0x0015, 0x0c29, 0x2009, 0x1000, 0x2001,
+	0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0003, 0x0120, 0x8109,
+	0x1db0, 0x080c, 0x0d7d, 0x001e, 0x0005, 0x2001, 0x0382, 0x2004,
+	0x9084, 0x0007, 0x9086, 0x0003, 0x1120, 0x2001, 0x0380, 0x2003,
+	0x0001, 0x0005, 0x0156, 0x0016, 0x0026, 0x00e6, 0x900e, 0x2071,
+	0x19e6, 0x0469, 0x0106, 0x0190, 0x7004, 0x9086, 0x0003, 0x0148,
+	0x20a9, 0x1000, 0x6044, 0xd0fc, 0x01d8, 0x1f04, 0xa8d2, 0x080c,
+	0x0d7d, 0x080c, 0xa899, 0x6044, 0xd0fc, 0x0190, 0x7030, 0x9c06,
+	0x1148, 0x080c, 0x95ff, 0x6044, 0xd0dc, 0x0150, 0xc0dc, 0x6046,
+	0x700a, 0x7042, 0x704c, 0x9c06, 0x190c, 0x0d7d, 0x080c, 0x965a,
+	0x010e, 0x1919, 0x00ee, 0x002e, 0x001e, 0x015e, 0x0005, 0x2001,
+	0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0003, 0x0005, 0x0126,
+	0x2091, 0x2400, 0x7808, 0xd0a4, 0x190c, 0x0d76, 0xd09c, 0x0128,
+	0x7820, 0x908c, 0xf000, 0x11b8, 0x0012, 0x012e, 0x0005, 0xa91f,
+	0xa95d, 0xa984, 0xa9bb, 0xa9cb, 0xa9dc, 0xa9eb, 0xa9f9, 0xaa26,
+	0xaa2a, 0xa91f, 0xa91f, 0xa91f, 0xa91f, 0xa91f, 0xa91f, 0x080c,
+	0x0d7d, 0x012e, 0x0005, 0x2060, 0x6044, 0xd0bc, 0x0140, 0xc0bc,
+	0x6046, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0012, 0x012e,
+	0x0005, 0xa944, 0xa946, 0xa944, 0xa94c, 0xa944, 0xa944, 0xa944,
+	0xa944, 0xa944, 0xa946, 0xa944, 0xa946, 0xa944, 0xa946, 0xa944,
+	0xa944, 0xa944, 0xa946, 0xa944, 0x080c, 0x0d7d, 0x2009, 0x0013,
+	0x080c, 0xac8d, 0x012e, 0x0005, 0x6014, 0x2048, 0xa87c, 0xd0dc,
+	0x0130, 0x080c, 0x88d7, 0x080c, 0xabf0, 0x012e, 0x0005, 0x2009,
+	0x0049, 0x080c, 0xac8d, 0x012e, 0x0005, 0x080c, 0xa899, 0x2001,
+	0x1a0b, 0x2003, 0x0000, 0x7030, 0x9065, 0x090c, 0x0d7d, 0x7034,
+	0x9092, 0x00c8, 0x1258, 0x8000, 0x7036, 0x7004, 0x9086, 0x0003,
+	0x0110, 0x7007, 0x0000, 0x781f, 0x0808, 0x0040, 0x080c, 0xe764,
+	0x6003, 0x0001, 0x2009, 0x0014, 0x080c, 0xac8d, 0x781f, 0x0100,
+	0x080c, 0xa8b5, 0x012e, 0x0005, 0x080c, 0xa899, 0x714c, 0x81ff,
+	0x1128, 0x2011, 0x1a0e, 0x2013, 0x0000, 0x0438, 0x2061, 0x0100,
+	0x7150, 0x9192, 0x7530, 0x12f0, 0x8108, 0x7152, 0x714c, 0x9188,
+	0x0008, 0x210c, 0x918e, 0x0006, 0x1138, 0x6014, 0x9084, 0x1984,
+	0x9085, 0x0012, 0x6016, 0x0088, 0x714c, 0x9188, 0x0008, 0x210c,
+	0x918e, 0x0009, 0x0d90, 0x6014, 0x9084, 0x1984, 0x9085, 0x0016,
+	0x6016, 0x0018, 0x706c, 0xc085, 0x706e, 0x781f, 0x0200, 0x080c,
+	0xa8b5, 0x012e, 0x0005, 0x080c, 0xa899, 0x714c, 0x2160, 0x6003,
+	0x0003, 0x2009, 0x004a, 0x080c, 0xac8d, 0x781f, 0x0200, 0x080c,
+	0xa8b5, 0x012e, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820, 0x2060,
+	0x6003, 0x0003, 0x080c, 0xa899, 0x080c, 0x1d85, 0x781f, 0x0400,
+	0x080c, 0xa8b5, 0x012e, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820,
+	0x2060, 0x080c, 0xa899, 0x080c, 0x1dcd, 0x781f, 0x0400, 0x080c,
+	0xa8b5, 0x012e, 0x0005, 0x7030, 0x9065, 0x0148, 0x6044, 0xc0bc,
+	0x6046, 0x7104, 0x9186, 0x0003, 0x0110, 0x080c, 0x96be, 0x012e,
+	0x0005, 0x00f6, 0x703c, 0x9086, 0x0002, 0x0528, 0x704c, 0x907d,
+	0x0510, 0x7844, 0xc0bc, 0x7846, 0x7820, 0x9086, 0x0009, 0x0118,
+	0x080c, 0x9d79, 0x00c0, 0x7828, 0xd0fc, 0x1118, 0x080c, 0x9cf8,
+	0x0090, 0x2001, 0x1837, 0x2004, 0x9084, 0x0028, 0x1130, 0x2001,
+	0x197b, 0x2004, 0x9086, 0xaaaa, 0x1120, 0x2001, 0x0387, 0x2003,
+	0x1000, 0x080c, 0x9c7d, 0x00fe, 0x012e, 0x0005, 0x080c, 0x7591,
+	0x012e, 0x0005, 0x080c, 0x0d7d, 0x0005, 0x00e6, 0x2071, 0x19e6,
+	0x6044, 0xc0bc, 0x6046, 0xd0fc, 0x01b8, 0x704c, 0x9c06, 0x1190,
+	0x2019, 0x0001, 0x080c, 0xa133, 0x704f, 0x0000, 0x2001, 0x0109,
+	0x2004, 0xd08c, 0x1138, 0x2001, 0x0108, 0x2004, 0xd0bc, 0x1110,
+	0x703f, 0x0000, 0x080c, 0xa33e, 0x00ee, 0x0005, 0x0026, 0x7010,
+	0x9c06, 0x1178, 0x080c, 0xa1fd, 0x6044, 0xc0fc, 0x6046, 0x600c,
+	0x9015, 0x0120, 0x7212, 0x600f, 0x0000, 0x0010, 0x7212, 0x720e,
+	0x9006, 0x002e, 0x0005, 0x0026, 0x7020, 0x9c06, 0x1178, 0x080c,
+	0xa1fd, 0x6044, 0xc0fc, 0x6046, 0x600c, 0x9015, 0x0120, 0x7222,
+	0x600f, 0x0000, 0x0010, 0x7222, 0x721e, 0x9006, 0x002e, 0x0005,
+	0x00d6, 0x0036, 0x7830, 0x9c06, 0x1558, 0x2069, 0x0100, 0x68c0,
+	0x9005, 0x01f8, 0x080c, 0x8709, 0x080c, 0x9e4f, 0x68c3, 0x0000,
+	0x080c, 0xa327, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2a49, 0x9006, 0x080c, 0x2a49, 0x2069,
+	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x9085, 0x0001,
+	0x0038, 0x7808, 0xc0ad, 0x780a, 0x6003, 0x0009, 0x630a, 0x9006,
+	0x003e, 0x00de, 0x0005, 0x0016, 0x0026, 0x0036, 0x6100, 0x2019,
+	0x0100, 0x2001, 0x0382, 0x2004, 0xd09c, 0x0190, 0x00c6, 0x0126,
+	0x2091, 0x2800, 0x0016, 0x0036, 0x080c, 0xa8ff, 0x003e, 0x001e,
+	0x012e, 0x00ce, 0x6200, 0x2200, 0x9106, 0x0d58, 0x2200, 0x0010,
+	0x8319, 0x1d38, 0x003e, 0x002e, 0x001e, 0x0005, 0x00d6, 0x0156,
+	0x080c, 0x9b07, 0x7a14, 0x82ff, 0x0138, 0x7003, 0x0100, 0x700b,
+	0x0003, 0x60c3, 0x0008, 0x0490, 0x7003, 0x0200, 0x7007, 0x0000,
+	0x2069, 0x1800, 0x901e, 0x6800, 0x9086, 0x0004, 0x1110, 0xc38d,
+	0x0060, 0x080c, 0x74ec, 0x1110, 0xc3ad, 0x0008, 0xc3a5, 0x6adc,
+	0xd29c, 0x1110, 0xd2ac, 0x0108, 0xc39d, 0x730e, 0x080c, 0x87ce,
+	0x20a9, 0x0006, 0x2011, 0xffec, 0x2019, 0xffed, 0x2071, 0x0250,
+	0x2305, 0x2072, 0x8e70, 0x2205, 0x2072, 0x8e70, 0x9398, 0x0002,
+	0x9290, 0x0002, 0x1f04, 0xab00, 0x60c3, 0x0020, 0x080c, 0x9e1f,
+	0x015e, 0x00de, 0x0005, 0x0156, 0x080c, 0x9b07, 0x7a14, 0x82ff,
+	0x0168, 0x9286, 0xffff, 0x0118, 0x9282, 0x000e, 0x1238, 0x7003,
+	0x0100, 0x700b, 0x0003, 0x60c3, 0x0008, 0x0488, 0x7003, 0x0200,
+	0x7007, 0x001c, 0x700f, 0x0001, 0x2011, 0x19bc, 0x2204, 0x8007,
+	0x701a, 0x8210, 0x2204, 0x8007, 0x701e, 0x0421, 0x1120, 0xb8a0,
+	0x9082, 0x007f, 0x0248, 0x2001, 0x181f, 0x2004, 0x7022, 0x2001,
+	0x1820, 0x2004, 0x7026, 0x0030, 0x2001, 0x1818, 0x2004, 0x9084,
+	0x00ff, 0x7026, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805,
+	0x20e9, 0x0000, 0x20a1, 0x0256, 0x4003, 0x60c3, 0x001c, 0x015e,
+	0x0804, 0x9e1f, 0x0006, 0x2001, 0x1837, 0x2004, 0xd0ac, 0x000e,
+	0x0005, 0x2011, 0x0003, 0x080c, 0xa1be, 0x2011, 0x0002, 0x080c,
+	0xa1c8, 0x080c, 0xa0b3, 0x0036, 0x901e, 0x080c, 0xa133, 0x003e,
+	0x0005, 0x080c, 0x3381, 0x0188, 0x0016, 0x00b6, 0x00c6, 0x7010,
+	0x9085, 0x0020, 0x7012, 0x2009, 0x007e, 0x080c, 0x6644, 0xb85c,
+	0xc0ac, 0xb85e, 0x00ce, 0x00be, 0x001e, 0x0005, 0x2071, 0x188d,
+	0x7000, 0x9005, 0x0140, 0x2001, 0x0812, 0x2071, 0x1800, 0x7076,
+	0x707a, 0x706b, 0xffd4, 0x2071, 0x1800, 0x7074, 0x7056, 0x705b,
+	0x1ddc, 0x0005, 0x00e6, 0x0126, 0x2071, 0x1800, 0x2091, 0x8000,
+	0x7554, 0x9582, 0x0010, 0x0608, 0x7058, 0x2060, 0x6000, 0x9086,
+	0x0000, 0x0148, 0x9ce0, 0x001c, 0x7068, 0x9c02, 0x1208, 0x0cb0,
+	0x2061, 0x1ddc, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7556, 0x9ca8,
+	0x001c, 0x7068, 0x9502, 0x1230, 0x755a, 0x9085, 0x0001, 0x012e,
+	0x00ee, 0x0005, 0x705b, 0x1ddc, 0x0cc0, 0x9006, 0x0cc0, 0x00e6,
+	0x2071, 0x1800, 0x7554, 0x9582, 0x0010, 0x0600, 0x7058, 0x2060,
+	0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0, 0x001c, 0x7068, 0x9c02,
+	0x1208, 0x0cb0, 0x2061, 0x1ddc, 0x0c98, 0x6003, 0x0008, 0x8529,
+	0x7556, 0x9ca8, 0x001c, 0x7068, 0x9502, 0x1228, 0x755a, 0x9085,
+	0x0001, 0x00ee, 0x0005, 0x705b, 0x1ddc, 0x0cc8, 0x9006, 0x0cc8,
+	0x9c82, 0x1ddc, 0x0a0c, 0x0d7d, 0x2001, 0x181a, 0x2004, 0x9c02,
+	0x1a0c, 0x0d7d, 0x9006, 0x6006, 0x600a, 0x600e, 0x6016, 0x601a,
+	0x6012, 0x6023, 0x0000, 0x6003, 0x0000, 0x601e, 0x605e, 0x6062,
+	0x6026, 0x602a, 0x602e, 0x6032, 0x6036, 0x603a, 0x603e, 0x604a,
+	0x602a, 0x6046, 0x6042, 0x2061, 0x1800, 0x6054, 0x8000, 0x6056,
+	0x0005, 0x9006, 0x600e, 0x6016, 0x601a, 0x6012, 0x6022, 0x6002,
+	0x601e, 0x605e, 0x6062, 0x604a, 0x6046, 0x2061, 0x1800, 0x6054,
+	0x8000, 0x6056, 0x0005, 0x0006, 0x6000, 0x9086, 0x0000, 0x01d0,
+	0x601c, 0xd084, 0x190c, 0x1a94, 0x6023, 0x0007, 0x2001, 0x1985,
+	0x2004, 0x0006, 0x9082, 0x0051, 0x000e, 0x0208, 0x8004, 0x601a,
+	0x080c, 0xe571, 0x604b, 0x0000, 0x6044, 0xd0fc, 0x1129, 0x9006,
+	0x6046, 0x6016, 0x000e, 0x0005, 0x080c, 0xa899, 0x0106, 0x2001,
+	0x19f9, 0x2004, 0x9c06, 0x1130, 0x0036, 0x2019, 0x0001, 0x080c,
+	0xa133, 0x003e, 0x080c, 0xa33e, 0x010e, 0x090c, 0xa8b5, 0x0005,
+	0x00e6, 0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7554, 0x9582,
+	0x0001, 0x0608, 0x7058, 0x2060, 0x6000, 0x9086, 0x0000, 0x0148,
+	0x9ce0, 0x001c, 0x7068, 0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1ddc,
+	0x0c98, 0x6003, 0x0008, 0x8529, 0x7556, 0x9ca8, 0x001c, 0x7068,
+	0x9502, 0x1230, 0x755a, 0x9085, 0x0001, 0x012e, 0x00ee, 0x0005,
+	0x705b, 0x1ddc, 0x0cc0, 0x9006, 0x0cc0, 0x6020, 0x9084, 0x000f,
+	0x0002, 0xaca1, 0xacab, 0xacc6, 0xace1, 0xcfd7, 0xcff4, 0xd00f,
+	0xaca1, 0xacab, 0x8fb5, 0xacfd, 0xaca1, 0xaca1, 0xaca1, 0xaca1,
+	0xaca1, 0x9186, 0x0013, 0x1130, 0x6044, 0xd0fc, 0x0110, 0x080c,
+	0x95ff, 0x0005, 0x0005, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c,
+	0x0d7d, 0x0013, 0x006e, 0x0005, 0xacc4, 0xb430, 0xb60d, 0xacc4,
+	0xb6a3, 0xafc6, 0xacc4, 0xacc4, 0xb3b2, 0xbc0d, 0xacc4, 0xacc4,
+	0xacc4, 0xacc4, 0xacc4, 0xacc4, 0x080c, 0x0d7d, 0x0066, 0x6000,
+	0x90b2, 0x0016, 0x1a0c, 0x0d7d, 0x0013, 0x006e, 0x0005, 0xacdf,
+	0xc215, 0xacdf, 0xacdf, 0xacdf, 0xacdf, 0xacdf, 0xacdf, 0xc1b7,
+	0xc398, 0xacdf, 0xc252, 0xc2d6, 0xc252, 0xc2d6, 0xacdf, 0x080c,
+	0x0d7d, 0x6000, 0x9082, 0x0016, 0x1a0c, 0x0d7d, 0x6000, 0x0002,
+	0xacfb, 0xbc57, 0xbcee, 0xbe6e, 0xbedd, 0xacfb, 0xacfb, 0xacfb,
+	0xbc26, 0xc138, 0xc13b, 0xacfb, 0xacfb, 0xacfb, 0xacfb, 0xc16b,
+	0xacfb, 0xacfb, 0xacfb, 0x080c, 0x0d7d, 0x0066, 0x6000, 0x90b2,
+	0x0016, 0x1a0c, 0x0d7d, 0x0013, 0x006e, 0x0005, 0xad16, 0xad16,
+	0xad54, 0xadf3, 0xae73, 0xad16, 0xad16, 0xad16, 0xad18, 0xad16,
+	0xad16, 0xad16, 0xad16, 0xad16, 0xad16, 0xad16, 0x080c, 0x0d7d,
+	0x9186, 0x004c, 0x0560, 0x9186, 0x0003, 0x190c, 0x0d7d, 0x0096,
+	0x601c, 0xc0ed, 0x601e, 0x6003, 0x0003, 0x6106, 0x6014, 0x2048,
+	0xa87c, 0x9084, 0xa000, 0xc0b5, 0xa87e, 0xa8ac, 0xa836, 0xa8b0,
+	0xa83a, 0x9006, 0xa846, 0xa84a, 0xa884, 0x9092, 0x199a, 0x0210,
+	0x2001, 0x1999, 0x8003, 0x8013, 0x8213, 0x9210, 0x621a, 0x009e,
+	0x080c, 0x1bdf, 0x2009, 0x8030, 0x080c, 0x9280, 0x0005, 0x6010,
+	0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x080c, 0xae95, 0x080c,
+	0xcf9c, 0x6003, 0x0007, 0x0005, 0x00d6, 0x0096, 0x00f6, 0x2079,
+	0x1800, 0x7a90, 0x6014, 0x2048, 0xa87c, 0xd0ec, 0x1110, 0x9290,
+	0x0018, 0xac78, 0xc4fc, 0x0046, 0xa8e0, 0x9005, 0x1140, 0xa8dc,
+	0x921a, 0x0140, 0x0220, 0xa87b, 0x0007, 0x2010, 0x0028, 0xa87b,
+	0x0015, 0x0010, 0xa87b, 0x0000, 0x8214, 0xa883, 0x0000, 0xaa02,
+	0x0006, 0x0016, 0x0026, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2400,
+	0x9005, 0x1108, 0x009a, 0x2100, 0x9086, 0x0015, 0x1118, 0x2001,
+	0x0001, 0x0038, 0x2100, 0x9086, 0x0016, 0x0118, 0x2001, 0x0001,
+	0x002a, 0x94a4, 0x0007, 0x8423, 0x9405, 0x0002, 0xadbb, 0xadbb,
+	0xadb6, 0xadb9, 0xadbb, 0xadb3, 0xada6, 0xada6, 0xada6, 0xada6,
+	0xada6, 0xada6, 0xada6, 0xada6, 0xada6, 0xada6, 0x00fe, 0x00ee,
+	0x00de, 0x00ce, 0x002e, 0x001e, 0x000e, 0x004e, 0x00fe, 0x009e,
+	0x00de, 0x080c, 0x0d7d, 0x080c, 0xb862, 0x0028, 0x080c, 0xb947,
+	0x0010, 0x080c, 0xba3d, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e,
+	0x001e, 0x2c00, 0xa896, 0x000e, 0x080c, 0xaf53, 0x0530, 0xa804,
+	0xa80e, 0x00a6, 0x2050, 0xb100, 0x00ae, 0x8006, 0x8006, 0x8007,
+	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0xaacc, 0xabd0,
+	0xacd4, 0xadd8, 0x2031, 0x0000, 0x2041, 0x12b0, 0x080c, 0xb114,
+	0x0160, 0x000e, 0x9005, 0x0120, 0x00fe, 0x009e, 0x00de, 0x0005,
+	0x00fe, 0x009e, 0x00de, 0x0804, 0xabf0, 0x2001, 0x002c, 0x900e,
+	0x080c, 0xafb9, 0x0c70, 0x91b6, 0x0015, 0x0170, 0x91b6, 0x0016,
+	0x0158, 0x91b2, 0x0047, 0x0a0c, 0x0d7d, 0x91b2, 0x0050, 0x1a0c,
+	0x0d7d, 0x9182, 0x0047, 0x0042, 0x080c, 0xaaab, 0x0120, 0x9086,
+	0x0002, 0x0904, 0xad54, 0x0005, 0xae15, 0xae15, 0xae17, 0xae49,
+	0xae15, 0xae15, 0xae15, 0xae15, 0xae5c, 0x080c, 0x0d7d, 0x00d6,
+	0x0016, 0x0096, 0x6003, 0x0004, 0x6114, 0x2148, 0xa87c, 0xd0fc,
+	0x01c0, 0xa878, 0xc0fc, 0x9005, 0x1158, 0xa894, 0x9005, 0x0140,
+	0x2001, 0x0000, 0x900e, 0x080c, 0xafb9, 0x080c, 0xabf0, 0x00a8,
+	0x6003, 0x0002, 0xa8a4, 0xa9a8, 0x9105, 0x1178, 0xa8ae, 0xa8b2,
+	0x0c78, 0xa87f, 0x0020, 0xa88c, 0xa88a, 0xa8a4, 0xa8ae, 0xa8a8,
+	0xa8b2, 0xa8c7, 0x0000, 0xa8cb, 0x0000, 0x009e, 0x001e, 0x00de,
+	0x0005, 0x080c, 0x965a, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c,
+	0xc865, 0x0120, 0xa87b, 0x0006, 0x080c, 0x6d9f, 0x009e, 0x00de,
+	0x080c, 0xabf0, 0x0804, 0x96bd, 0x080c, 0x965a, 0x080c, 0x320f,
+	0x080c, 0xcf99, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xc865,
+	0x0120, 0xa87b, 0x0029, 0x080c, 0x6d9f, 0x009e, 0x00de, 0x080c,
+	0xabf0, 0x0804, 0x96bd, 0x9182, 0x0047, 0x0002, 0xae83, 0xae85,
+	0xae83, 0xae83, 0xae83, 0xae83, 0xae83, 0xae83, 0xae83, 0xae83,
+	0xae83, 0xae83, 0xae85, 0x080c, 0x0d7d, 0x00d6, 0x0096, 0x601f,
+	0x0000, 0x6114, 0x2148, 0xa87b, 0x0000, 0xa883, 0x0000, 0x080c,
+	0x6d9f, 0x009e, 0x00de, 0x0804, 0xabf0, 0x0026, 0x0036, 0x0056,
+	0x0066, 0x0096, 0x00a6, 0x00f6, 0x0006, 0x080c, 0x1047, 0x000e,
+	0x090c, 0x0d7d, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019, 0x21a0,
+	0x900e, 0x20a9, 0x0020, 0x4104, 0xa87a, 0x2079, 0x1800, 0x7990,
+	0x9188, 0x0018, 0x918c, 0x0fff, 0xa972, 0xac76, 0x2950, 0x00a6,
+	0x2001, 0x0205, 0x2003, 0x0000, 0x901e, 0x2029, 0x0001, 0x9182,
+	0x0034, 0x1228, 0x2011, 0x001f, 0x080c, 0xc41b, 0x04c0, 0x2130,
+	0x2009, 0x0034, 0x2011, 0x001f, 0x080c, 0xc41b, 0x96b2, 0x0034,
+	0xb004, 0x904d, 0x0110, 0x080c, 0x0ff9, 0x080c, 0x1047, 0x01d0,
+	0x8528, 0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406, 0x968a,
+	0x003d, 0x1230, 0x2608, 0x2011, 0x001b, 0x080c, 0xc41b, 0x00b8,
+	0x96b2, 0x003c, 0x2009, 0x003c, 0x2950, 0x2011, 0x001b, 0x080c,
+	0xc41b, 0x0c18, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f,
+	0x95ad, 0x0050, 0xb566, 0xb070, 0xc0fd, 0xb072, 0x0048, 0x2001,
+	0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566,
+	0x2a48, 0xa804, 0xa807, 0x0000, 0x0006, 0x080c, 0x6d9f, 0x000e,
+	0x2048, 0x9005, 0x1db0, 0x00fe, 0x00ae, 0x009e, 0x006e, 0x005e,
+	0x003e, 0x002e, 0x0005, 0x00d6, 0x00f6, 0x0096, 0x0006, 0x080c,
+	0x1047, 0x000e, 0x090c, 0x0d7d, 0xa960, 0x21e8, 0xa95c, 0x9188,
+	0x0019, 0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104, 0xaa66, 0xa87a,
+	0x2079, 0x1800, 0x7990, 0x810c, 0x9188, 0x000c, 0x9182, 0x001a,
+	0x0210, 0x2009, 0x001a, 0x21a8, 0x810b, 0xa972, 0xac76, 0x2e98,
+	0xa85c, 0x9080, 0x001f, 0x20a0, 0x2001, 0x0205, 0x200c, 0x918d,
+	0x0080, 0x2102, 0x4003, 0x2003, 0x0000, 0x080c, 0x6d9f, 0x009e,
+	0x00fe, 0x00de, 0x0005, 0x0016, 0x00d6, 0x00f6, 0x0096, 0x0016,
+	0x2001, 0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x001e, 0x2079,
+	0x0200, 0x2e98, 0xa87c, 0xd0ec, 0x0118, 0x9e80, 0x000c, 0x2098,
+	0x2021, 0x003e, 0x901e, 0x9282, 0x0020, 0x0218, 0x2011, 0x0020,
+	0x2018, 0x9486, 0x003e, 0x1170, 0x0096, 0x080c, 0x1047, 0x2900,
+	0x009e, 0x05c0, 0xa806, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0002, 0x20a0, 0x3300, 0x908e, 0x0260, 0x0140, 0x2009, 0x0280,
+	0x9102, 0x920a, 0x0218, 0x2010, 0x2100, 0x9318, 0x2200, 0x9402,
+	0x1228, 0x2400, 0x9202, 0x2410, 0x9318, 0x9006, 0x2020, 0x22a8,
+	0xa800, 0x9200, 0xa802, 0x20e1, 0x0000, 0x4003, 0x83ff, 0x0180,
+	0x3300, 0x9086, 0x0280, 0x1130, 0x7814, 0x8000, 0x9085, 0x0080,
+	0x7816, 0x2e98, 0x2310, 0x84ff, 0x0904, 0xaf68, 0x0804, 0xaf6a,
+	0x9085, 0x0001, 0x7817, 0x0000, 0x009e, 0x00fe, 0x00de, 0x001e,
+	0x0005, 0x00d6, 0x0036, 0x0096, 0x6314, 0x2348, 0xa87a, 0xa982,
+	0x080c, 0x6d93, 0x009e, 0x003e, 0x00de, 0x0005, 0x91b6, 0x0015,
+	0x1118, 0x080c, 0xabf0, 0x0030, 0x91b6, 0x0016, 0x190c, 0x0d7d,
+	0x080c, 0xabf0, 0x0005, 0x20a9, 0x000e, 0x20e1, 0x0000, 0x2e98,
+	0x6014, 0x0096, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x20a0, 0x009e,
+	0x4003, 0x0136, 0x9080, 0x001b, 0x20a0, 0x2011, 0x0006, 0x20a9,
+	0x0001, 0x3418, 0x8318, 0x23a0, 0x4003, 0x3318, 0x8318, 0x2398,
+	0x8211, 0x1db8, 0x2011, 0x0006, 0x013e, 0x20a0, 0x3318, 0x8318,
+	0x2398, 0x4003, 0x3418, 0x8318, 0x23a0, 0x8211, 0x1db8, 0x0096,
+	0x080c, 0xc865, 0x0130, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867,
+	0x0103, 0x009e, 0x0804, 0xabf0, 0x0096, 0x00d6, 0x0036, 0x7330,
+	0x9386, 0x0200, 0x11a8, 0x6010, 0x00b6, 0x2058, 0xb8d7, 0x0000,
+	0x00be, 0x6014, 0x9005, 0x0130, 0x2048, 0xa807, 0x0000, 0xa867,
+	0x0103, 0xab32, 0x080c, 0xabf0, 0x003e, 0x00de, 0x009e, 0x0005,
+	0x0011, 0x1d48, 0x0cc8, 0x0006, 0x0016, 0x080c, 0xcf84, 0x0188,
+	0x6014, 0x9005, 0x1170, 0x600b, 0x0003, 0x601b, 0x0000, 0x604b,
+	0x0000, 0x2009, 0x0022, 0x080c, 0xb408, 0x9006, 0x001e, 0x000e,
+	0x0005, 0x9085, 0x0001, 0x0cd0, 0x0096, 0x0016, 0x20a9, 0x0014,
+	0x9e80, 0x000c, 0x20e1, 0x0000, 0x2098, 0x6014, 0x2048, 0xa860,
+	0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x2001, 0x0205,
+	0x2003, 0x0001, 0x2099, 0x0260, 0x20a9, 0x0016, 0x4003, 0x20a9,
+	0x000a, 0xa804, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
+	0x20a0, 0x4003, 0x2001, 0x0205, 0x2003, 0x0002, 0x2099, 0x0260,
+	0x20a9, 0x0020, 0x4003, 0x2003, 0x0000, 0x6014, 0x2048, 0xa800,
+	0x2048, 0xa867, 0x0103, 0x080c, 0xabf0, 0x001e, 0x009e, 0x0005,
+	0x0096, 0x0016, 0x900e, 0x7030, 0x9086, 0x0100, 0x0140, 0x7038,
+	0x9084, 0x00ff, 0x800c, 0x703c, 0x9084, 0x00ff, 0x8004, 0x9080,
+	0x0004, 0x9108, 0x810b, 0x2011, 0x0002, 0x2019, 0x000c, 0x6014,
+	0x2048, 0x080c, 0xc41b, 0x080c, 0xc865, 0x0140, 0x6014, 0x2048,
+	0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0xabf0,
+	0x001e, 0x009e, 0x0005, 0x0016, 0x2009, 0x0000, 0x7030, 0x9086,
+	0x0200, 0x0110, 0x2009, 0x0001, 0x0096, 0x6014, 0x904d, 0x090c,
+	0x0d7d, 0xa97a, 0x080c, 0x6d9f, 0x009e, 0x080c, 0xabf0, 0x001e,
+	0x0005, 0x0016, 0x0096, 0x7030, 0x9086, 0x0100, 0x1118, 0x2009,
+	0x0004, 0x0010, 0x7034, 0x800c, 0x810b, 0x2011, 0x000c, 0x2019,
+	0x000c, 0x6014, 0x2048, 0xa804, 0x0096, 0x9005, 0x0108, 0x2048,
+	0x080c, 0xc41b, 0x009e, 0x080c, 0xc865, 0x0148, 0xa804, 0x9005,
+	0x1158, 0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c,
+	0xabf0, 0x009e, 0x001e, 0x0005, 0x0086, 0x2040, 0xa030, 0x8007,
+	0x9086, 0x0100, 0x1118, 0x080c, 0xb5c6, 0x00e0, 0xa034, 0x8007,
+	0x800c, 0x8806, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
+	0x9080, 0x000c, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000,
+	0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x1296,
+	0x0019, 0x0d08, 0x008e, 0x0898, 0x0096, 0x0006, 0x080c, 0x1047,
+	0x000e, 0x01b0, 0xa8ab, 0x0dcb, 0xa876, 0x000e, 0xa8a2, 0x0006,
+	0xae6a, 0x2800, 0xa89e, 0xa97a, 0xaf72, 0xaa8e, 0xab92, 0xac96,
+	0xad9a, 0x0086, 0x2940, 0x080c, 0x113c, 0x008e, 0x9085, 0x0001,
+	0x009e, 0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff,
+	0x6210, 0x00b6, 0x2258, 0xba10, 0x00be, 0x9206, 0x1520, 0x700c,
+	0x6210, 0x00b6, 0x2258, 0xba14, 0x00be, 0x9206, 0x11e0, 0x604b,
+	0x0000, 0x2c68, 0x0016, 0x2009, 0x0035, 0x080c, 0xcefc, 0x001e,
+	0x1158, 0x622c, 0x2268, 0x2071, 0x026c, 0x6b20, 0x9386, 0x0003,
+	0x0130, 0x9386, 0x0006, 0x0128, 0x080c, 0xabf0, 0x0020, 0x0039,
+	0x0010, 0x080c, 0xb23d, 0x002e, 0x00de, 0x00ee, 0x0005, 0x0096,
+	0x6814, 0x2048, 0x9186, 0x0015, 0x0904, 0xb21c, 0x918e, 0x0016,
+	0x1904, 0xb23b, 0x700c, 0x908c, 0xff00, 0x9186, 0x1700, 0x0120,
+	0x9186, 0x0300, 0x1904, 0xb1f6, 0x89ff, 0x1138, 0x6800, 0x9086,
+	0x000f, 0x0904, 0xb1d8, 0x0804, 0xb239, 0x6808, 0x9086, 0xffff,
+	0x1904, 0xb21e, 0xa87c, 0x9084, 0x0060, 0x9086, 0x0020, 0x1128,
+	0xa83c, 0xa940, 0x9105, 0x1904, 0xb21e, 0x6824, 0xd084, 0x1904,
+	0xb21e, 0xd0b4, 0x0158, 0x0016, 0x2001, 0x1985, 0x200c, 0x6018,
+	0x9102, 0x9082, 0x0005, 0x001e, 0x1a04, 0xb21e, 0x080c, 0xca54,
+	0x6864, 0xa882, 0xa87c, 0xc0dc, 0xc0f4, 0xc0d4, 0xa87e, 0x0026,
+	0x900e, 0x6a18, 0x2001, 0x000a, 0x080c, 0x9181, 0xa884, 0x920a,
+	0x0208, 0x8011, 0xaa86, 0x82ff, 0x002e, 0x1138, 0x00c6, 0x2d60,
+	0x080c, 0xc56e, 0x00ce, 0x0804, 0xb239, 0x00c6, 0xa868, 0xd0fc,
+	0x1118, 0x080c, 0x60d6, 0x0010, 0x080c, 0x64de, 0x00ce, 0x1904,
+	0xb21e, 0x00c6, 0x2d60, 0x080c, 0xabf0, 0x00ce, 0x0804, 0xb239,
+	0x00c6, 0x080c, 0xac60, 0x0198, 0x6017, 0x0000, 0x6810, 0x6012,
+	0x080c, 0xccfe, 0x6023, 0x0003, 0x6904, 0x00c6, 0x2d60, 0x080c,
+	0xabf0, 0x00ce, 0x080c, 0xac8d, 0x00ce, 0x0804, 0xb239, 0x2001,
+	0x1987, 0x2004, 0x684a, 0x00ce, 0x0804, 0xb239, 0x7008, 0x9086,
+	0x000b, 0x11c8, 0x6010, 0x00b6, 0x2058, 0xb900, 0xc1bc, 0xb902,
+	0x00be, 0x00c6, 0x2d60, 0xa87b, 0x0003, 0x080c, 0xcf3e, 0x6007,
+	0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2009, 0x8020, 0x080c,
+	0x9239, 0x00ce, 0x0430, 0x700c, 0x9086, 0x2a00, 0x1138, 0x2001,
+	0x1987, 0x2004, 0x684a, 0x00e8, 0x04c1, 0x00e8, 0x89ff, 0x090c,
+	0x0d7d, 0x00c6, 0x00d6, 0x2d60, 0xa867, 0x0103, 0xa87b, 0x0003,
+	0x080c, 0x6bb5, 0x080c, 0xca54, 0x080c, 0xac2b, 0x0026, 0x6010,
+	0x00b6, 0x2058, 0xba3c, 0x080c, 0x676f, 0x00be, 0x002e, 0x00de,
+	0x00ce, 0x080c, 0xabf0, 0x009e, 0x0005, 0x9186, 0x0015, 0x1128,
+	0x2001, 0x1987, 0x2004, 0x684a, 0x0068, 0x918e, 0x0016, 0x1160,
+	0x00c6, 0x2d00, 0x2060, 0x080c, 0xe571, 0x080c, 0x88d7, 0x080c,
+	0xabf0, 0x00ce, 0x080c, 0xabf0, 0x0005, 0x0026, 0x0036, 0x0046,
+	0x7228, 0xacb0, 0xabac, 0xd2f4, 0x0130, 0x2001, 0x1987, 0x2004,
+	0x684a, 0x0804, 0xb2b7, 0x00c6, 0x2d60, 0x080c, 0xc446, 0x00ce,
+	0x6804, 0x9086, 0x0050, 0x1168, 0x00c6, 0x2d00, 0x2060, 0x6003,
+	0x0001, 0x6007, 0x0050, 0x2009, 0x8023, 0x080c, 0x9239, 0x00ce,
+	0x04f0, 0x6800, 0x9086, 0x000f, 0x01a8, 0x89ff, 0x090c, 0x0d7d,
+	0x6800, 0x9086, 0x0004, 0x1190, 0xa87c, 0xd0ac, 0x0178, 0xa843,
+	0x0fff, 0xa83f, 0x0fff, 0xa880, 0xc0fc, 0xa882, 0x2001, 0x0001,
+	0x6832, 0x0400, 0x2001, 0x0007, 0x6832, 0x00e0, 0xa87c, 0xd0b4,
+	0x1150, 0xd0ac, 0x0db8, 0x6824, 0xd0f4, 0x1d48, 0xa838, 0xa934,
+	0x9105, 0x0d80, 0x0c20, 0xd2ec, 0x1d68, 0x7024, 0x9306, 0x1118,
+	0x7020, 0x9406, 0x0d38, 0x7020, 0x683e, 0x7024, 0x683a, 0x2001,
+	0x0005, 0x6832, 0x080c, 0xcbe8, 0x080c, 0x96bd, 0x0010, 0x080c,
+	0xabf0, 0x004e, 0x003e, 0x002e, 0x0005, 0x00e6, 0x00d6, 0x0026,
+	0x7008, 0x9084, 0x00ff, 0x6210, 0x00b6, 0x2258, 0xba10, 0x00be,
+	0x9206, 0x1904, 0xb322, 0x700c, 0x6210, 0x00b6, 0x2258, 0xba14,
+	0x00be, 0x9206, 0x1904, 0xb322, 0x6038, 0x2068, 0x6824, 0xc0dc,
+	0x6826, 0x6a20, 0x9286, 0x0007, 0x0904, 0xb322, 0x9286, 0x0002,
+	0x0904, 0xb322, 0x9286, 0x0000, 0x05e8, 0x6808, 0x633c, 0x9306,
+	0x15c8, 0x2071, 0x026c, 0x9186, 0x0015, 0x0570, 0x918e, 0x0016,
+	0x1100, 0x00c6, 0x6038, 0x2060, 0x6104, 0x9186, 0x004b, 0x01c0,
+	0x9186, 0x004c, 0x01a8, 0x9186, 0x004d, 0x0190, 0x9186, 0x004e,
+	0x0178, 0x9186, 0x0052, 0x0160, 0x6014, 0x0096, 0x2048, 0x080c,
+	0xc865, 0x090c, 0x0d7d, 0xa87b, 0x0003, 0x009e, 0x080c, 0xcf3e,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2009, 0x8020,
+	0x080c, 0x9239, 0x00ce, 0x0030, 0x6038, 0x2070, 0x2001, 0x1987,
+	0x2004, 0x704a, 0x080c, 0xabf0, 0x002e, 0x00de, 0x00ee, 0x0005,
+	0x00b6, 0x0096, 0x00f6, 0x6014, 0x2048, 0x6010, 0x2058, 0x91b6,
+	0x0015, 0x0130, 0xba08, 0xbb0c, 0xbc00, 0xc48c, 0xbc02, 0x0460,
+	0x0096, 0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90, 0x0010, 0x2019,
+	0x000a, 0x20a9, 0x0004, 0x080c, 0xbbd5, 0x002e, 0x003e, 0x015e,
+	0x009e, 0x1904, 0xb391, 0x0096, 0x0156, 0x0036, 0x0026, 0x2b48,
+	0x9e90, 0x0014, 0x2019, 0x0006, 0x20a9, 0x0004, 0x080c, 0xbbd5,
+	0x002e, 0x003e, 0x015e, 0x009e, 0x15a0, 0x7238, 0xba0a, 0x733c,
+	0xbb0e, 0xbc00, 0xc48d, 0xbc02, 0xa804, 0x9005, 0x1128, 0x00fe,
+	0x009e, 0x00be, 0x0804, 0xafff, 0x0096, 0x2048, 0xaa12, 0xab16,
+	0xac0a, 0x009e, 0x8006, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
+	0xffc0, 0x9080, 0x0002, 0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8,
+	0xada4, 0x2031, 0x0000, 0x2041, 0x1296, 0x080c, 0xb114, 0x0130,
+	0x00fe, 0x009e, 0x080c, 0xabf0, 0x00be, 0x0005, 0x080c, 0xb5c6,
+	0x0cb8, 0x2b78, 0x00f6, 0x080c, 0x320f, 0x080c, 0xcf99, 0x00fe,
+	0x00c6, 0x080c, 0xab9a, 0x2f00, 0x6012, 0x6017, 0x0000, 0x6023,
+	0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x2001, 0x0007, 0x080c,
+	0x6594, 0x080c, 0x65c0, 0x080c, 0x9240, 0x080c, 0x96bd, 0x00ce,
+	0x0804, 0xb364, 0x2100, 0x91b2, 0x0053, 0x1a0c, 0x0d7d, 0x91b2,
+	0x0040, 0x1a04, 0xb41a, 0x0002, 0xb408, 0xb408, 0xb3fe, 0xb408,
+	0xb408, 0xb408, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc,
+	0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc,
+	0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc,
+	0xb3fc, 0xb3fc, 0xb3fc, 0xb408, 0xb3fc, 0xb408, 0xb408, 0xb3fc,
+	0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fe, 0xb3fc, 0xb3fc, 0xb3fc,
+	0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb408, 0xb408,
+	0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc, 0xb3fc,
+	0xb3fc, 0xb408, 0xb3fc, 0xb3fc, 0x080c, 0x0d7d, 0x0066, 0x00b6,
+	0x6610, 0x2658, 0xb8d4, 0xc08c, 0xb8d6, 0x00be, 0x006e, 0x0000,
+	0x6003, 0x0001, 0x6106, 0x9186, 0x0032, 0x0118, 0x080c, 0x9240,
+	0x0010, 0x080c, 0x9239, 0x0126, 0x2091, 0x8000, 0x080c, 0x96bd,
+	0x012e, 0x0005, 0x2600, 0x0002, 0xb408, 0xb408, 0xb42e, 0xb408,
+	0xb408, 0xb42e, 0xb42e, 0xb42e, 0xb42e, 0xb408, 0xb42e, 0xb408,
+	0xb42e, 0xb408, 0xb42e, 0xb42e, 0xb42e, 0xb42e, 0x080c, 0x0d7d,
+	0x6004, 0x90b2, 0x0053, 0x1a0c, 0x0d7d, 0x91b6, 0x0013, 0x0904,
+	0xb505, 0x91b6, 0x0027, 0x1904, 0xb4b1, 0x080c, 0x95ff, 0x6004,
+	0x080c, 0xca69, 0x01b0, 0x080c, 0xca7a, 0x01a8, 0x908e, 0x0021,
+	0x0904, 0xb4ae, 0x908e, 0x0022, 0x1130, 0x080c, 0xb02b, 0x0904,
+	0xb4aa, 0x0804, 0xb4ab, 0x908e, 0x003d, 0x0904, 0xb4ae, 0x0804,
+	0xb4a4, 0x080c, 0x323e, 0x2001, 0x0007, 0x080c, 0x6594, 0x6010,
+	0x00b6, 0x2058, 0xb9a0, 0x00be, 0x080c, 0xb5c6, 0x9186, 0x007e,
+	0x1148, 0x2001, 0x1837, 0x2014, 0xc285, 0x080c, 0x74ec, 0x1108,
+	0xc2ad, 0x2202, 0x080c, 0xa899, 0x0036, 0x0026, 0x2019, 0x0028,
+	0x2110, 0x080c, 0xe67d, 0x002e, 0x003e, 0x0016, 0x0026, 0x0036,
+	0x2110, 0x2019, 0x0028, 0x080c, 0x93c6, 0x0076, 0x903e, 0x080c,
+	0x928f, 0x6010, 0x00b6, 0x905d, 0x0100, 0x00be, 0x2c08, 0x080c,
+	0xe038, 0x007e, 0x003e, 0x002e, 0x001e, 0x080c, 0xa8b5, 0x080c,
+	0xcf99, 0x0016, 0x080c, 0xccf6, 0x080c, 0xabf0, 0x001e, 0x080c,
+	0x3318, 0x080c, 0x96bd, 0x0030, 0x080c, 0xccf6, 0x080c, 0xabf0,
+	0x080c, 0x96bd, 0x0005, 0x080c, 0xb5c6, 0x0cb0, 0x080c, 0xb602,
+	0x0c98, 0x9186, 0x0015, 0x0118, 0x9186, 0x0016, 0x1140, 0x080c,
+	0xaaab, 0x0d80, 0x9086, 0x0002, 0x0904, 0xb60d, 0x0c58, 0x9186,
+	0x0014, 0x1d40, 0x080c, 0x95ff, 0x6004, 0x908e, 0x0022, 0x1118,
+	0x080c, 0xb02b, 0x09f8, 0x080c, 0x320f, 0x080c, 0xcf99, 0x080c,
+	0xca69, 0x1190, 0x080c, 0x323e, 0x6010, 0x00b6, 0x2058, 0xb9a0,
+	0x00be, 0x080c, 0xb5c6, 0x9186, 0x007e, 0x1128, 0x2001, 0x1837,
+	0x200c, 0xc185, 0x2102, 0x0800, 0x080c, 0xca7a, 0x1120, 0x080c,
+	0xb5c6, 0x0804, 0xb4a4, 0x6004, 0x908e, 0x0032, 0x1160, 0x00e6,
+	0x00f6, 0x2071, 0x189e, 0x2079, 0x0000, 0x080c, 0x35b9, 0x00fe,
+	0x00ee, 0x0804, 0xb4a4, 0x6004, 0x908e, 0x0021, 0x0d40, 0x908e,
+	0x0022, 0x090c, 0xb5c6, 0x0804, 0xb4a4, 0x90b2, 0x0040, 0x1a04,
+	0xb5a6, 0x2008, 0x0002, 0xb54d, 0xb54e, 0xb551, 0xb554, 0xb557,
+	0xb55a, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b,
+	0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b,
+	0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b,
+	0xb54b, 0xb55d, 0xb568, 0xb54b, 0xb569, 0xb568, 0xb54b, 0xb54b,
+	0xb54b, 0xb54b, 0xb54b, 0xb568, 0xb568, 0xb54b, 0xb54b, 0xb54b,
+	0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb54b, 0xb591, 0xb568, 0xb54b,
+	0xb564, 0xb54b, 0xb54b, 0xb54b, 0xb565, 0xb54b, 0xb54b, 0xb54b,
+	0xb568, 0xb58c, 0xb54b, 0x080c, 0x0d7d, 0x00d0, 0x2001, 0x000b,
+	0x00f8, 0x2001, 0x0003, 0x00e0, 0x2001, 0x0005, 0x00c8, 0x2001,
+	0x0001, 0x00b0, 0x2001, 0x0009, 0x0098, 0x6003, 0x0005, 0x080c,
+	0xcf9c, 0x080c, 0x96bd, 0x0058, 0x0018, 0x0010, 0x080c, 0x6594,
+	0x04b8, 0x080c, 0xcf9c, 0x6003, 0x0004, 0x080c, 0x96bd, 0x0005,
+	0x080c, 0x6594, 0x6003, 0x0002, 0x0036, 0x2019, 0x1852, 0x2304,
 	0x9084, 0xff00, 0x1120, 0x2001, 0x1985, 0x201c, 0x0040, 0x8007,
 	0x909a, 0x0004, 0x0ec0, 0x8003, 0x801b, 0x831b, 0x9318, 0x631a,
-	0x003e, 0x080c, 0x9684, 0x0c18, 0x080c, 0xccc3, 0x080c, 0xabdf,
+	0x003e, 0x080c, 0x96bd, 0x0c18, 0x080c, 0xccf6, 0x080c, 0xabf0,
 	0x08f0, 0x00e6, 0x00f6, 0x2071, 0x189e, 0x2079, 0x0000, 0x080c,
-	0x3599, 0x00fe, 0x00ee, 0x080c, 0x95c6, 0x080c, 0xabdf, 0x0878,
-	0x6003, 0x0002, 0x080c, 0xcf69, 0x0804, 0x9684, 0x2600, 0x2008,
-	0x0002, 0xb59d, 0xb580, 0xb59b, 0xb580, 0xb580, 0xb59b, 0xb59b,
-	0xb59b, 0xb59b, 0xb580, 0xb59b, 0xb580, 0xb59b, 0xb580, 0xb59b,
-	0xb59b, 0xb59b, 0xb59b, 0x080c, 0x0d7d, 0x0096, 0x6014, 0x2048,
-	0x080c, 0x6d7b, 0x009e, 0x080c, 0xabdf, 0x0005, 0x00e6, 0x0096,
-	0x0026, 0x0016, 0x080c, 0xc832, 0x0568, 0x6014, 0x2048, 0xa864,
+	0x35b9, 0x00fe, 0x00ee, 0x080c, 0x95ff, 0x080c, 0xabf0, 0x0878,
+	0x6003, 0x0002, 0x080c, 0xcf9c, 0x0804, 0x96bd, 0x2600, 0x2008,
+	0x0002, 0xb5bd, 0xb5a0, 0xb5bb, 0xb5a0, 0xb5a0, 0xb5bb, 0xb5bb,
+	0xb5bb, 0xb5bb, 0xb5a0, 0xb5bb, 0xb5a0, 0xb5bb, 0xb5a0, 0xb5bb,
+	0xb5bb, 0xb5bb, 0xb5bb, 0x080c, 0x0d7d, 0x0096, 0x6014, 0x2048,
+	0x080c, 0x6d9f, 0x009e, 0x080c, 0xabf0, 0x0005, 0x00e6, 0x0096,
+	0x0026, 0x0016, 0x080c, 0xc865, 0x0568, 0x6014, 0x2048, 0xa864,
 	0x9086, 0x0139, 0x11a8, 0xa894, 0x9086, 0x0056, 0x1148, 0x080c,
-	0x5476, 0x0130, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x0028,
-	0x2001, 0x0030, 0x900e, 0x2011, 0x4005, 0x080c, 0xce30, 0x0090,
+	0x5496, 0x0130, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x0028,
+	0x2001, 0x0030, 0x900e, 0x2011, 0x4005, 0x080c, 0xce63, 0x0090,
 	0xa868, 0xd0fc, 0x0178, 0xa807, 0x0000, 0x0016, 0x6004, 0x908e,
 	0x0021, 0x0168, 0x908e, 0x003d, 0x0150, 0x001e, 0xa867, 0x0103,
 	0xa833, 0x0100, 0x001e, 0x002e, 0x009e, 0x00ee, 0x0005, 0x001e,
 	0x0009, 0x0cc0, 0x0096, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867,
 	0x0103, 0xa823, 0x8001, 0x009e, 0x0005, 0x00b6, 0x6610, 0x2658,
 	0xb804, 0x9084, 0x00ff, 0x90b2, 0x000c, 0x1a0c, 0x0d7d, 0x6604,
-	0x96b6, 0x004d, 0x1120, 0x080c, 0xcd4f, 0x0804, 0xb672, 0x6604,
-	0x96b6, 0x0043, 0x1120, 0x080c, 0xcd98, 0x0804, 0xb672, 0x6604,
-	0x96b6, 0x004b, 0x1120, 0x080c, 0xcdc4, 0x0804, 0xb672, 0x6604,
-	0x96b6, 0x0033, 0x1120, 0x080c, 0xcce5, 0x0804, 0xb672, 0x6604,
-	0x96b6, 0x0028, 0x1120, 0x080c, 0xca85, 0x0804, 0xb672, 0x6604,
-	0x96b6, 0x0029, 0x1120, 0x080c, 0xcac6, 0x0804, 0xb672, 0x6604,
-	0x96b6, 0x001f, 0x1120, 0x080c, 0xafc2, 0x0804, 0xb672, 0x6604,
-	0x96b6, 0x0000, 0x1118, 0x080c, 0xb30a, 0x04e0, 0x6604, 0x96b6,
-	0x0022, 0x1118, 0x080c, 0xaffb, 0x04a8, 0x6604, 0x96b6, 0x0035,
-	0x1118, 0x080c, 0xb121, 0x0470, 0x6604, 0x96b6, 0x0039, 0x1118,
-	0x080c, 0xb29f, 0x0438, 0x6604, 0x96b6, 0x003d, 0x1118, 0x080c,
-	0xb033, 0x0400, 0x6604, 0x96b6, 0x0044, 0x1118, 0x080c, 0xb06f,
-	0x00c8, 0x6604, 0x96b6, 0x0049, 0x1118, 0x080c, 0xb0b0, 0x0090,
-	0x6604, 0x96b6, 0x0041, 0x1118, 0x080c, 0xb09a, 0x0058, 0x91b6,
+	0x96b6, 0x004d, 0x1120, 0x080c, 0xcd82, 0x0804, 0xb692, 0x6604,
+	0x96b6, 0x0043, 0x1120, 0x080c, 0xcdcb, 0x0804, 0xb692, 0x6604,
+	0x96b6, 0x004b, 0x1120, 0x080c, 0xcdf7, 0x0804, 0xb692, 0x6604,
+	0x96b6, 0x0033, 0x1120, 0x080c, 0xcd18, 0x0804, 0xb692, 0x6604,
+	0x96b6, 0x0028, 0x1120, 0x080c, 0xcab8, 0x0804, 0xb692, 0x6604,
+	0x96b6, 0x0029, 0x1120, 0x080c, 0xcaf9, 0x0804, 0xb692, 0x6604,
+	0x96b6, 0x001f, 0x1120, 0x080c, 0xafd3, 0x0804, 0xb692, 0x6604,
+	0x96b6, 0x0000, 0x1118, 0x080c, 0xb328, 0x04e0, 0x6604, 0x96b6,
+	0x0022, 0x1118, 0x080c, 0xb00c, 0x04a8, 0x6604, 0x96b6, 0x0035,
+	0x1118, 0x080c, 0xb132, 0x0470, 0x6604, 0x96b6, 0x0039, 0x1118,
+	0x080c, 0xb2bd, 0x0438, 0x6604, 0x96b6, 0x003d, 0x1118, 0x080c,
+	0xb044, 0x0400, 0x6604, 0x96b6, 0x0044, 0x1118, 0x080c, 0xb080,
+	0x00c8, 0x6604, 0x96b6, 0x0049, 0x1118, 0x080c, 0xb0c1, 0x0090,
+	0x6604, 0x96b6, 0x0041, 0x1118, 0x080c, 0xb0ab, 0x0058, 0x91b6,
 	0x0015, 0x1110, 0x0063, 0x0030, 0x91b6, 0x0016, 0x1128, 0x00be,
-	0x0804, 0xb8ce, 0x00be, 0x0005, 0x080c, 0xac99, 0x0cd8, 0xb68f,
-	0xb692, 0xb68f, 0xb6d9, 0xb68f, 0xb842, 0xb8db, 0xb68f, 0xb68f,
-	0xb8a4, 0xb68f, 0xb8ba, 0x0096, 0x601f, 0x0000, 0x6014, 0x2048,
-	0xa800, 0x2048, 0xa867, 0x0103, 0x009e, 0x0804, 0xabdf, 0xa001,
+	0x0804, 0xb8ee, 0x00be, 0x0005, 0x080c, 0xacaa, 0x0cd8, 0xb6af,
+	0xb6b2, 0xb6af, 0xb6f9, 0xb6af, 0xb862, 0xb8fb, 0xb6af, 0xb6af,
+	0xb8c4, 0xb6af, 0xb8da, 0x0096, 0x601f, 0x0000, 0x6014, 0x2048,
+	0xa800, 0x2048, 0xa867, 0x0103, 0x009e, 0x0804, 0xabf0, 0xa001,
 	0xa001, 0x0005, 0x00e6, 0x2071, 0x1800, 0x7090, 0x9086, 0x0074,
-	0x1540, 0x080c, 0xdfcc, 0x11b0, 0x6010, 0x00b6, 0x2058, 0x7030,
+	0x1540, 0x080c, 0xe009, 0x11b0, 0x6010, 0x00b6, 0x2058, 0x7030,
 	0xd08c, 0x0128, 0xb800, 0xd0bc, 0x0110, 0xc0c5, 0xb802, 0x00f9,
-	0x00be, 0x2001, 0x0006, 0x080c, 0x6570, 0x080c, 0x321e, 0x080c,
-	0xabdf, 0x0098, 0x2001, 0x000a, 0x080c, 0x6570, 0x080c, 0x321e,
-	0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x9207, 0x080c, 0x9684,
-	0x0020, 0x2001, 0x0001, 0x080c, 0xb812, 0x00ee, 0x0005, 0x00d6,
-	0xb800, 0xd084, 0x0160, 0x9006, 0x080c, 0x655c, 0x2069, 0x1847,
-	0x6804, 0xd0a4, 0x0120, 0x2001, 0x0006, 0x080c, 0x659c, 0x00de,
+	0x00be, 0x2001, 0x0006, 0x080c, 0x6594, 0x080c, 0x323e, 0x080c,
+	0xabf0, 0x0098, 0x2001, 0x000a, 0x080c, 0x6594, 0x080c, 0x323e,
+	0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x9240, 0x080c, 0x96bd,
+	0x0020, 0x2001, 0x0001, 0x080c, 0xb832, 0x00ee, 0x0005, 0x00d6,
+	0xb800, 0xd084, 0x0160, 0x9006, 0x080c, 0x6580, 0x2069, 0x1847,
+	0x6804, 0xd0a4, 0x0120, 0x2001, 0x0006, 0x080c, 0x65c0, 0x00de,
 	0x0005, 0x00b6, 0x0096, 0x00d6, 0x2011, 0x1824, 0x2204, 0x9086,
-	0x0074, 0x1904, 0xb7e7, 0x6010, 0x2058, 0xbaa0, 0x9286, 0x007e,
-	0x1120, 0x080c, 0xba28, 0x0804, 0xb74b, 0x080c, 0xba1d, 0x6010,
+	0x0074, 0x1904, 0xb807, 0x6010, 0x2058, 0xbaa0, 0x9286, 0x007e,
+	0x1120, 0x080c, 0xba48, 0x0804, 0xb76b, 0x080c, 0xba3d, 0x6010,
 	0x2058, 0xbaa0, 0x9286, 0x0080, 0x1510, 0x6014, 0x9005, 0x01a8,
 	0x2048, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140, 0x2001,
-	0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xce30, 0x0030, 0xa807,
+	0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xce63, 0x0030, 0xa807,
 	0x0000, 0xa867, 0x0103, 0xa833, 0x0200, 0x2001, 0x0006, 0x080c,
-	0x6570, 0x080c, 0x321e, 0x080c, 0xabdf, 0x0804, 0xb7ec, 0x080c,
-	0xb7fa, 0x6014, 0x9005, 0x0190, 0x2048, 0xa868, 0xd0f4, 0x01e8,
+	0x6594, 0x080c, 0x323e, 0x080c, 0xabf0, 0x0804, 0xb80c, 0x080c,
+	0xb81a, 0x6014, 0x9005, 0x0190, 0x2048, 0xa868, 0xd0f4, 0x01e8,
 	0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1d08, 0x2001, 0x0000,
-	0x900e, 0x2011, 0x4000, 0x080c, 0xce30, 0x08f8, 0x080c, 0xb7f0,
-	0x0160, 0x9006, 0x080c, 0x655c, 0x2001, 0x0004, 0x080c, 0x659c,
-	0x2001, 0x0007, 0x080c, 0x6570, 0x08a0, 0x2001, 0x0004, 0x080c,
-	0x6570, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c, 0x9207, 0x080c,
-	0x9684, 0x0804, 0xb7ec, 0xb85c, 0xd0e4, 0x01d8, 0x080c, 0xcc5d,
-	0x080c, 0x74c8, 0x0118, 0xd0dc, 0x1904, 0xb70d, 0x2011, 0x1837,
+	0x900e, 0x2011, 0x4000, 0x080c, 0xce63, 0x08f8, 0x080c, 0xb810,
+	0x0160, 0x9006, 0x080c, 0x6580, 0x2001, 0x0004, 0x080c, 0x65c0,
+	0x2001, 0x0007, 0x080c, 0x6594, 0x08a0, 0x2001, 0x0004, 0x080c,
+	0x6594, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c, 0x9240, 0x080c,
+	0x96bd, 0x0804, 0xb80c, 0xb85c, 0xd0e4, 0x01d8, 0x080c, 0xcc90,
+	0x080c, 0x74ec, 0x0118, 0xd0dc, 0x1904, 0xb72d, 0x2011, 0x1837,
 	0x2204, 0xc0ad, 0x2012, 0x2001, 0x196c, 0x2004, 0x00f6, 0x2079,
-	0x0100, 0x78e3, 0x0000, 0x080c, 0x2688, 0x78e2, 0x00fe, 0x0804,
-	0xb70d, 0x080c, 0xcc9e, 0x2011, 0x1837, 0x2204, 0xc0a5, 0x2012,
-	0x0006, 0x080c, 0xe15c, 0x000e, 0x1904, 0xb70d, 0xc0b5, 0x2012,
-	0x2001, 0x0006, 0x080c, 0x6570, 0x9006, 0x080c, 0x655c, 0x00c6,
+	0x0100, 0x78e3, 0x0000, 0x080c, 0x26a4, 0x78e2, 0x00fe, 0x0804,
+	0xb72d, 0x080c, 0xccd1, 0x2011, 0x1837, 0x2204, 0xc0a5, 0x2012,
+	0x0006, 0x080c, 0xe199, 0x000e, 0x1904, 0xb72d, 0xc0b5, 0x2012,
+	0x2001, 0x0006, 0x080c, 0x6594, 0x9006, 0x080c, 0x6580, 0x00c6,
 	0x2001, 0x180f, 0x2004, 0xd09c, 0x0520, 0x00f6, 0x2079, 0x0100,
 	0x00e6, 0x2071, 0x1800, 0x700c, 0x9084, 0x00ff, 0x78e6, 0x707e,
 	0x7010, 0x78ea, 0x7082, 0x908c, 0x00ff, 0x00ee, 0x780c, 0xc0b5,
-	0x780e, 0x00fe, 0x080c, 0x265d, 0x00f6, 0x2100, 0x900e, 0x080c,
-	0x2614, 0x795e, 0x00fe, 0x9186, 0x0081, 0x01d8, 0x2009, 0x0081,
+	0x780e, 0x00fe, 0x080c, 0x2679, 0x00f6, 0x2100, 0x900e, 0x080c,
+	0x2630, 0x795e, 0x00fe, 0x9186, 0x0081, 0x01d8, 0x2009, 0x0081,
 	0x00c8, 0x2009, 0x00ef, 0x00f6, 0x2079, 0x0100, 0x79ea, 0x7932,
-	0x7936, 0x780c, 0xc0b5, 0x780e, 0x00fe, 0x080c, 0x265d, 0x00f6,
-	0x2079, 0x1800, 0x7982, 0x2100, 0x900e, 0x080c, 0x2614, 0x795e,
-	0x00fe, 0x8108, 0x080c, 0x65bf, 0x2b00, 0x00ce, 0x1904, 0xb70d,
+	0x7936, 0x780c, 0xc0b5, 0x780e, 0x00fe, 0x080c, 0x2679, 0x00f6,
+	0x2079, 0x1800, 0x7982, 0x2100, 0x900e, 0x080c, 0x2630, 0x795e,
+	0x00fe, 0x8108, 0x080c, 0x65e3, 0x2b00, 0x00ce, 0x1904, 0xb72d,
 	0x6012, 0x2009, 0x180f, 0x210c, 0xd19c, 0x0150, 0x2009, 0x027c,
 	0x210c, 0x918c, 0x00ff, 0xb912, 0x2009, 0x027d, 0x210c, 0xb916,
-	0x2001, 0x0002, 0x080c, 0x6570, 0x6023, 0x0001, 0x6003, 0x0001,
-	0x6007, 0x0002, 0x080c, 0x9207, 0x080c, 0x9684, 0x0028, 0x080c,
-	0xb5a6, 0x2001, 0x0001, 0x0431, 0x00de, 0x009e, 0x00be, 0x0005,
+	0x2001, 0x0002, 0x080c, 0x6594, 0x6023, 0x0001, 0x6003, 0x0001,
+	0x6007, 0x0002, 0x080c, 0x9240, 0x080c, 0x96bd, 0x0028, 0x080c,
+	0xb5c6, 0x2001, 0x0001, 0x0431, 0x00de, 0x009e, 0x00be, 0x0005,
 	0x2001, 0x1810, 0x2004, 0xd0a4, 0x0120, 0x2001, 0x1848, 0x2004,
-	0xd0ac, 0x0005, 0x00e6, 0x080c, 0xe699, 0x0190, 0x2071, 0x0260,
+	0xd0ac, 0x0005, 0x00e6, 0x080c, 0xe6d6, 0x0190, 0x2071, 0x0260,
 	0x7108, 0x720c, 0x918c, 0x00ff, 0x1118, 0x9284, 0xff00, 0x0140,
 	0x6010, 0x2058, 0xb8a0, 0x9084, 0xff80, 0x1110, 0xb912, 0xba16,
 	0x00ee, 0x0005, 0x2030, 0x9005, 0x0158, 0x2001, 0x0007, 0x080c,
-	0x6570, 0x080c, 0x56e9, 0x1120, 0x2001, 0x0007, 0x080c, 0x659c,
+	0x6594, 0x080c, 0x5709, 0x1120, 0x2001, 0x0007, 0x080c, 0x65c0,
 	0x2600, 0x9005, 0x11b0, 0x6014, 0x0096, 0x2048, 0xa868, 0x009e,
 	0xd0fc, 0x1178, 0x0036, 0x0046, 0x6010, 0x00b6, 0x2058, 0xbba0,
-	0x00be, 0x2021, 0x0004, 0x2011, 0x8014, 0x080c, 0x4b09, 0x004e,
-	0x003e, 0x080c, 0x321e, 0x6020, 0x9086, 0x000a, 0x1108, 0x0005,
-	0x0804, 0xabdf, 0x00b6, 0x00e6, 0x0026, 0x0016, 0x2071, 0x1800,
-	0x7090, 0x9086, 0x0014, 0x1904, 0xb89a, 0x080c, 0x56e9, 0x1170,
+	0x00be, 0x2021, 0x0004, 0x2011, 0x8014, 0x080c, 0x4b29, 0x004e,
+	0x003e, 0x080c, 0x323e, 0x6020, 0x9086, 0x000a, 0x1108, 0x0005,
+	0x0804, 0xabf0, 0x00b6, 0x00e6, 0x0026, 0x0016, 0x2071, 0x1800,
+	0x7090, 0x9086, 0x0014, 0x1904, 0xb8ba, 0x080c, 0x5709, 0x1170,
 	0x6014, 0x9005, 0x1158, 0x0036, 0x0046, 0x6010, 0x2058, 0xbba0,
-	0x2021, 0x0006, 0x080c, 0x4cc0, 0x004e, 0x003e, 0x00d6, 0x6010,
-	0x2058, 0x080c, 0x66bb, 0x080c, 0xb6c7, 0x00de, 0x080c, 0xbaee,
+	0x2021, 0x0006, 0x080c, 0x4ce0, 0x004e, 0x003e, 0x00d6, 0x6010,
+	0x2058, 0x080c, 0x66df, 0x080c, 0xb6e7, 0x00de, 0x080c, 0xbb0e,
 	0x1588, 0x6010, 0x2058, 0xb890, 0x9005, 0x0560, 0x2001, 0x0006,
-	0x080c, 0x6570, 0x0096, 0x6014, 0x904d, 0x01d0, 0xa864, 0x9084,
+	0x080c, 0x6594, 0x0096, 0x6014, 0x904d, 0x01d0, 0xa864, 0x9084,
 	0x00ff, 0x9086, 0x0039, 0x1140, 0x2001, 0x0000, 0x900e, 0x2011,
-	0x4000, 0x080c, 0xce30, 0x0060, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x4000, 0x080c, 0xce63, 0x0060, 0xa864, 0x9084, 0x00ff, 0x9086,
 	0x0029, 0x0130, 0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0x0200,
-	0x009e, 0x080c, 0x321e, 0x6020, 0x9086, 0x000a, 0x0140, 0x080c,
-	0xabdf, 0x0028, 0x080c, 0xb5a6, 0x9006, 0x080c, 0xb812, 0x001e,
+	0x009e, 0x080c, 0x323e, 0x6020, 0x9086, 0x000a, 0x0140, 0x080c,
+	0xabf0, 0x0028, 0x080c, 0xb5c6, 0x9006, 0x080c, 0xb832, 0x001e,
 	0x002e, 0x00ee, 0x00be, 0x0005, 0x2011, 0x1824, 0x2204, 0x9086,
-	0x0014, 0x1160, 0x2001, 0x0002, 0x080c, 0x6570, 0x6003, 0x0001,
-	0x6007, 0x0001, 0x080c, 0x9207, 0x0804, 0x9684, 0x2001, 0x0001,
-	0x0804, 0xb812, 0x2030, 0x2011, 0x1824, 0x2204, 0x9086, 0x0004,
-	0x1148, 0x96b6, 0x000b, 0x1120, 0x2001, 0x0007, 0x080c, 0x6570,
-	0x0804, 0xabdf, 0x2001, 0x0001, 0x0804, 0xb812, 0x0002, 0xb68f,
-	0xb8e6, 0xb68f, 0xb927, 0xb68f, 0xb9d4, 0xb8db, 0xb68f, 0xb68f,
-	0xb9e8, 0xb68f, 0xb9fa, 0x6604, 0x9686, 0x0003, 0x0904, 0xb842,
-	0x96b6, 0x001e, 0x1110, 0x080c, 0xabdf, 0x0005, 0x00b6, 0x00d6,
-	0x00c6, 0x080c, 0xba0c, 0x11a0, 0x9006, 0x080c, 0x655c, 0x080c,
-	0x31ef, 0x080c, 0xcf66, 0x2001, 0x0002, 0x080c, 0x6570, 0x6003,
-	0x0001, 0x6007, 0x0002, 0x080c, 0x9207, 0x080c, 0x9684, 0x0418,
+	0x0014, 0x1160, 0x2001, 0x0002, 0x080c, 0x6594, 0x6003, 0x0001,
+	0x6007, 0x0001, 0x080c, 0x9240, 0x0804, 0x96bd, 0x2001, 0x0001,
+	0x0804, 0xb832, 0x2030, 0x2011, 0x1824, 0x2204, 0x9086, 0x0004,
+	0x1148, 0x96b6, 0x000b, 0x1120, 0x2001, 0x0007, 0x080c, 0x6594,
+	0x0804, 0xabf0, 0x2001, 0x0001, 0x0804, 0xb832, 0x0002, 0xb6af,
+	0xb906, 0xb6af, 0xb947, 0xb6af, 0xb9f4, 0xb8fb, 0xb6af, 0xb6af,
+	0xba08, 0xb6af, 0xba1a, 0x6604, 0x9686, 0x0003, 0x0904, 0xb862,
+	0x96b6, 0x001e, 0x1110, 0x080c, 0xabf0, 0x0005, 0x00b6, 0x00d6,
+	0x00c6, 0x080c, 0xba2c, 0x11a0, 0x9006, 0x080c, 0x6580, 0x080c,
+	0x320f, 0x080c, 0xcf99, 0x2001, 0x0002, 0x080c, 0x6594, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x080c, 0x9240, 0x080c, 0x96bd, 0x0418,
 	0x2009, 0x026e, 0x2104, 0x9086, 0x0009, 0x1160, 0x6010, 0x2058,
 	0xb840, 0x9084, 0x00ff, 0x9005, 0x0170, 0x8001, 0xb842, 0x601b,
 	0x000a, 0x0088, 0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086,
-	0x1900, 0x1108, 0x08a0, 0x080c, 0x31ef, 0x080c, 0xcf66, 0x2001,
-	0x0001, 0x080c, 0xb812, 0x00ce, 0x00de, 0x00be, 0x0005, 0x0096,
-	0x00b6, 0x0026, 0x9016, 0x080c, 0xba1a, 0x00d6, 0x2069, 0x197b,
+	0x1900, 0x1108, 0x08a0, 0x080c, 0x320f, 0x080c, 0xcf99, 0x2001,
+	0x0001, 0x080c, 0xb832, 0x00ce, 0x00de, 0x00be, 0x0005, 0x0096,
+	0x00b6, 0x0026, 0x9016, 0x080c, 0xba3a, 0x00d6, 0x2069, 0x197b,
 	0x2d04, 0x9005, 0x0168, 0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e,
 	0x1138, 0x2069, 0x1820, 0x2d04, 0x8000, 0x206a, 0x00de, 0x0010,
-	0x00de, 0x0088, 0x9006, 0x080c, 0x655c, 0x2001, 0x0002, 0x080c,
-	0x6570, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9207, 0x080c,
-	0x9684, 0x0804, 0xb9a4, 0x080c, 0xc832, 0x01b0, 0x6014, 0x2048,
+	0x00de, 0x0088, 0x9006, 0x080c, 0x6580, 0x2001, 0x0002, 0x080c,
+	0x6594, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9240, 0x080c,
+	0x96bd, 0x0804, 0xb9c4, 0x080c, 0xc865, 0x01b0, 0x6014, 0x2048,
 	0xa864, 0x2010, 0x9086, 0x0139, 0x1138, 0x6007, 0x0016, 0x2001,
-	0x0002, 0x080c, 0xce8a, 0x00b0, 0x6014, 0x2048, 0xa864, 0xd0fc,
+	0x0002, 0x080c, 0xcebd, 0x00b0, 0x6014, 0x2048, 0xa864, 0xd0fc,
 	0x0118, 0x2001, 0x0001, 0x0ca8, 0x2001, 0x180e, 0x2004, 0xd0dc,
 	0x0148, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x1110,
-	0x9006, 0x0c38, 0x080c, 0xb5a6, 0x2009, 0x026e, 0x2134, 0x96b4,
+	0x9006, 0x0c38, 0x080c, 0xb5c6, 0x2009, 0x026e, 0x2134, 0x96b4,
 	0x00ff, 0x9686, 0x0005, 0x0520, 0x9686, 0x000b, 0x01c8, 0x2009,
 	0x026f, 0x2104, 0x9084, 0xff00, 0x1118, 0x9686, 0x0009, 0x01c0,
 	0x9086, 0x1900, 0x1168, 0x9686, 0x0009, 0x0190, 0x2001, 0x0004,
-	0x080c, 0x6570, 0x2001, 0x0028, 0x601a, 0x6007, 0x0052, 0x0020,
-	0x2001, 0x0001, 0x080c, 0xb812, 0x002e, 0x00be, 0x009e, 0x0005,
-	0x9286, 0x0139, 0x0160, 0x6014, 0x2048, 0x080c, 0xc832, 0x0140,
+	0x080c, 0x6594, 0x2001, 0x0028, 0x601a, 0x6007, 0x0052, 0x0020,
+	0x2001, 0x0001, 0x080c, 0xb832, 0x002e, 0x00be, 0x009e, 0x0005,
+	0x9286, 0x0139, 0x0160, 0x6014, 0x2048, 0x080c, 0xc865, 0x0140,
 	0xa864, 0x9086, 0x0139, 0x0118, 0xa868, 0xd0fc, 0x0108, 0x0c40,
 	0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0138, 0x8001,
 	0xb842, 0x601b, 0x000a, 0x6007, 0x0016, 0x08f0, 0xb8a0, 0x9086,
-	0x007e, 0x1138, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5fb7, 0x00ee,
-	0x0010, 0x080c, 0x31ef, 0x0860, 0x080c, 0xba1a, 0x1160, 0x2001,
-	0x0004, 0x080c, 0x6570, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c,
-	0x9207, 0x0804, 0x9684, 0x080c, 0xb5a6, 0x9006, 0x0804, 0xb812,
-	0x0489, 0x1160, 0x2001, 0x0008, 0x080c, 0x6570, 0x6003, 0x0001,
-	0x6007, 0x0005, 0x080c, 0x9207, 0x0804, 0x9684, 0x2001, 0x0001,
-	0x0804, 0xb812, 0x00f9, 0x1160, 0x2001, 0x000a, 0x080c, 0x6570,
-	0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x9207, 0x0804, 0x9684,
-	0x2001, 0x0001, 0x0804, 0xb812, 0x2009, 0x026e, 0x2104, 0x9086,
+	0x007e, 0x1138, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5fd7, 0x00ee,
+	0x0010, 0x080c, 0x320f, 0x0860, 0x080c, 0xba3a, 0x1160, 0x2001,
+	0x0004, 0x080c, 0x6594, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c,
+	0x9240, 0x0804, 0x96bd, 0x080c, 0xb5c6, 0x9006, 0x0804, 0xb832,
+	0x0489, 0x1160, 0x2001, 0x0008, 0x080c, 0x6594, 0x6003, 0x0001,
+	0x6007, 0x0005, 0x080c, 0x9240, 0x0804, 0x96bd, 0x2001, 0x0001,
+	0x0804, 0xb832, 0x00f9, 0x1160, 0x2001, 0x000a, 0x080c, 0x6594,
+	0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x9240, 0x0804, 0x96bd,
+	0x2001, 0x0001, 0x0804, 0xb832, 0x2009, 0x026e, 0x2104, 0x9086,
 	0x0003, 0x1138, 0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086,
 	0x2a00, 0x0005, 0x9085, 0x0001, 0x0005, 0x00b6, 0x00c6, 0x0016,
-	0x6110, 0x2158, 0x080c, 0x662f, 0x001e, 0x00ce, 0x00be, 0x0005,
+	0x6110, 0x2158, 0x080c, 0x6653, 0x001e, 0x00ce, 0x00be, 0x0005,
 	0x00b6, 0x00f6, 0x00e6, 0x00d6, 0x0036, 0x0016, 0x6010, 0x2058,
-	0x2009, 0x1837, 0x2104, 0x9085, 0x0003, 0x200a, 0x080c, 0xbac0,
-	0x0560, 0x2009, 0x1837, 0x2104, 0xc0cd, 0x200a, 0x080c, 0x6a66,
-	0x0158, 0x9006, 0x2020, 0x2009, 0x002a, 0x080c, 0xe2d9, 0x2001,
+	0x2009, 0x1837, 0x2104, 0x9085, 0x0003, 0x200a, 0x080c, 0xbae0,
+	0x0560, 0x2009, 0x1837, 0x2104, 0xc0cd, 0x200a, 0x080c, 0x6a8a,
+	0x0158, 0x9006, 0x2020, 0x2009, 0x002a, 0x080c, 0xe316, 0x2001,
 	0x180c, 0x200c, 0xc195, 0x2102, 0x2019, 0x002a, 0x2009, 0x0001,
-	0x080c, 0x31b4, 0x00e6, 0x2071, 0x1800, 0x080c, 0x2fc0, 0x00ee,
-	0x00c6, 0x0156, 0x20a9, 0x0781, 0x2009, 0x007f, 0x080c, 0x32f8,
-	0x8108, 0x1f04, 0xba5e, 0x015e, 0x00ce, 0x080c, 0xba1d, 0x2071,
+	0x080c, 0x31d4, 0x00e6, 0x2071, 0x1800, 0x080c, 0x2fe0, 0x00ee,
+	0x00c6, 0x0156, 0x20a9, 0x0781, 0x2009, 0x007f, 0x080c, 0x3318,
+	0x8108, 0x1f04, 0xba7e, 0x015e, 0x00ce, 0x080c, 0xba3d, 0x2071,
 	0x0260, 0x2079, 0x0200, 0x7817, 0x0001, 0x2001, 0x1837, 0x200c,
 	0xc1c5, 0x7018, 0xd0fc, 0x0110, 0xd0dc, 0x0118, 0x7038, 0xd0dc,
 	0x1108, 0xc1c4, 0x7817, 0x0000, 0x2001, 0x1837, 0x2102, 0x2079,
 	0x0100, 0x2e04, 0x9084, 0x00ff, 0x2069, 0x181f, 0x206a, 0x78e6,
 	0x0006, 0x8e70, 0x2e04, 0x2069, 0x1820, 0x206a, 0x78ea, 0x7832,
 	0x7836, 0x2010, 0x9084, 0xff00, 0x001e, 0x9105, 0x2009, 0x182c,
-	0x200a, 0x2200, 0x9084, 0x00ff, 0x2008, 0x080c, 0x265d, 0x080c,
-	0x74c8, 0x0170, 0x2071, 0x0260, 0x2069, 0x1981, 0x7048, 0x206a,
-	0x704c, 0x6806, 0x7050, 0x680a, 0x7054, 0x680e, 0x080c, 0xcc5d,
-	0x0040, 0x2001, 0x0006, 0x080c, 0x6570, 0x080c, 0x321e, 0x080c,
-	0xabdf, 0x001e, 0x003e, 0x00de, 0x00ee, 0x00fe, 0x00be, 0x0005,
+	0x200a, 0x2200, 0x9084, 0x00ff, 0x2008, 0x080c, 0x2679, 0x080c,
+	0x74ec, 0x0170, 0x2071, 0x0260, 0x2069, 0x1981, 0x7048, 0x206a,
+	0x704c, 0x6806, 0x7050, 0x680a, 0x7054, 0x680e, 0x080c, 0xcc90,
+	0x0040, 0x2001, 0x0006, 0x080c, 0x6594, 0x080c, 0x323e, 0x080c,
+	0xabf0, 0x001e, 0x003e, 0x00de, 0x00ee, 0x00fe, 0x00be, 0x0005,
 	0x0096, 0x0026, 0x0036, 0x00e6, 0x0156, 0x2019, 0x182c, 0x231c,
 	0x83ff, 0x01f0, 0x2071, 0x0260, 0x7200, 0x9294, 0x00ff, 0x7004,
 	0x9084, 0xff00, 0x9205, 0x9306, 0x1198, 0x2011, 0x0276, 0x20a9,
-	0x0004, 0x2b48, 0x2019, 0x000a, 0x080c, 0xbbb5, 0x1148, 0x2011,
-	0x027a, 0x20a9, 0x0004, 0x2019, 0x0006, 0x080c, 0xbbb5, 0x1100,
+	0x0004, 0x2b48, 0x2019, 0x000a, 0x080c, 0xbbd5, 0x1148, 0x2011,
+	0x027a, 0x20a9, 0x0004, 0x2019, 0x0006, 0x080c, 0xbbd5, 0x1100,
 	0x015e, 0x00ee, 0x003e, 0x002e, 0x009e, 0x0005, 0x00e6, 0x2071,
 	0x0260, 0x7034, 0x9086, 0x0014, 0x11a8, 0x7038, 0x9086, 0x0800,
 	0x1188, 0x703c, 0xd0ec, 0x0160, 0x9084, 0x0f00, 0x9086, 0x0100,
@@ -5782,80 +5786,80 @@
 	0x9085, 0x0001, 0x00ee, 0x0005, 0x00e6, 0x0096, 0x00c6, 0x0076,
 	0x0056, 0x0046, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2029,
 	0x19f2, 0x252c, 0x2021, 0x19f9, 0x2424, 0x2061, 0x1ddc, 0x2071,
-	0x1800, 0x7254, 0x7074, 0x9202, 0x1a04, 0xbb81, 0x080c, 0x8b72,
-	0x0904, 0xbb7a, 0x080c, 0xe30a, 0x0904, 0xbb7a, 0x6720, 0x9786,
-	0x0007, 0x0904, 0xbb7a, 0x2500, 0x9c06, 0x0904, 0xbb7a, 0x2400,
-	0x9c06, 0x0904, 0xbb7a, 0x3e08, 0x9186, 0x0002, 0x1148, 0x6010,
+	0x1800, 0x7254, 0x7074, 0x9202, 0x1a04, 0xbba1, 0x080c, 0x8ba9,
+	0x0904, 0xbb9a, 0x080c, 0xe347, 0x0904, 0xbb9a, 0x6720, 0x9786,
+	0x0007, 0x0904, 0xbb9a, 0x2500, 0x9c06, 0x0904, 0xbb9a, 0x2400,
+	0x9c06, 0x0904, 0xbb9a, 0x3e08, 0x9186, 0x0002, 0x1148, 0x6010,
 	0x9005, 0x0130, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1590,
 	0x00c6, 0x6043, 0xffff, 0x6000, 0x9086, 0x0004, 0x1110, 0x080c,
-	0x1a77, 0x9786, 0x000a, 0x0148, 0x080c, 0xca47, 0x1130, 0x00ce,
-	0x080c, 0xb5a6, 0x080c, 0xac1a, 0x00e8, 0x6014, 0x2048, 0x080c,
-	0xc832, 0x01a8, 0x9786, 0x0003, 0x1530, 0xa867, 0x0103, 0xa87c,
-	0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fec, 0x009e,
-	0xab7a, 0xa877, 0x0000, 0x080c, 0x6d6f, 0x080c, 0xca21, 0x080c,
-	0xac1a, 0x00ce, 0x9ce0, 0x001c, 0x7068, 0x9c02, 0x1210, 0x0804,
-	0xbb21, 0x012e, 0x000e, 0x002e, 0x004e, 0x005e, 0x007e, 0x00ce,
-	0x009e, 0x00ee, 0x0005, 0x9786, 0x0006, 0x1118, 0x080c, 0xe27c,
+	0x1a94, 0x9786, 0x000a, 0x0148, 0x080c, 0xca7a, 0x1130, 0x00ce,
+	0x080c, 0xb5c6, 0x080c, 0xac2b, 0x00e8, 0x6014, 0x2048, 0x080c,
+	0xc865, 0x01a8, 0x9786, 0x0003, 0x1530, 0xa867, 0x0103, 0xa87c,
+	0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0ff9, 0x009e,
+	0xab7a, 0xa877, 0x0000, 0x080c, 0x6d93, 0x080c, 0xca54, 0x080c,
+	0xac2b, 0x00ce, 0x9ce0, 0x001c, 0x7068, 0x9c02, 0x1210, 0x0804,
+	0xbb41, 0x012e, 0x000e, 0x002e, 0x004e, 0x005e, 0x007e, 0x00ce,
+	0x009e, 0x00ee, 0x0005, 0x9786, 0x0006, 0x1118, 0x080c, 0xe2b9,
 	0x0c30, 0x9786, 0x0009, 0x1148, 0x6000, 0x9086, 0x0004, 0x0d08,
-	0x2009, 0x004c, 0x080c, 0xac7c, 0x08e0, 0x9786, 0x000a, 0x0938,
+	0x2009, 0x004c, 0x080c, 0xac8d, 0x08e0, 0x9786, 0x000a, 0x0938,
 	0x0820, 0x220c, 0x2304, 0x9106, 0x1130, 0x8210, 0x8318, 0x1f04,
-	0xbba1, 0x9006, 0x0005, 0x2304, 0x9102, 0x0218, 0x2001, 0x0001,
+	0xbbc1, 0x9006, 0x0005, 0x2304, 0x9102, 0x0218, 0x2001, 0x0001,
 	0x0008, 0x9006, 0x918d, 0x0001, 0x0005, 0x0136, 0x01c6, 0x0016,
 	0x8906, 0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0,
 	0x9300, 0x2098, 0x3518, 0x20a9, 0x0001, 0x220c, 0x4002, 0x910e,
 	0x1140, 0x8210, 0x8319, 0x1dc8, 0x9006, 0x001e, 0x01ce, 0x013e,
 	0x0005, 0x220c, 0x9102, 0x0218, 0x2001, 0x0001, 0x0010, 0x2001,
 	0x0000, 0x918d, 0x0001, 0x001e, 0x01ce, 0x013e, 0x0005, 0x220c,
-	0x810f, 0x2304, 0x9106, 0x1130, 0x8210, 0x8318, 0x1f04, 0xbbdf,
+	0x810f, 0x2304, 0x9106, 0x1130, 0x8210, 0x8318, 0x1f04, 0xbbff,
 	0x9006, 0x0005, 0x918d, 0x0001, 0x0005, 0x6004, 0x908a, 0x0053,
-	0x1a0c, 0x0d7d, 0x080c, 0xca36, 0x0120, 0x080c, 0xca47, 0x0158,
-	0x0028, 0x080c, 0x321e, 0x080c, 0xca47, 0x0128, 0x080c, 0x95c6,
-	0x080c, 0xabdf, 0x0005, 0x080c, 0xb5a6, 0x0cc0, 0x9182, 0x0057,
-	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xbc25, 0xbc25,
-	0xbc25, 0xbc25, 0xbc25, 0xbc25, 0xbc25, 0xbc25, 0xbc25, 0xbc25,
-	0xbc25, 0xbc27, 0xbc27, 0xbc27, 0xbc27, 0xbc25, 0xbc25, 0xbc25,
-	0xbc27, 0xbc25, 0xbc25, 0xbc25, 0xbc25, 0x080c, 0x0d7d, 0x600b,
+	0x1a0c, 0x0d7d, 0x080c, 0xca69, 0x0120, 0x080c, 0xca7a, 0x0158,
+	0x0028, 0x080c, 0x323e, 0x080c, 0xca7a, 0x0128, 0x080c, 0x95ff,
+	0x080c, 0xabf0, 0x0005, 0x080c, 0xb5c6, 0x0cc0, 0x9182, 0x0057,
+	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xbc45, 0xbc45,
+	0xbc45, 0xbc45, 0xbc45, 0xbc45, 0xbc45, 0xbc45, 0xbc45, 0xbc45,
+	0xbc45, 0xbc47, 0xbc47, 0xbc47, 0xbc47, 0xbc45, 0xbc45, 0xbc45,
+	0xbc47, 0xbc45, 0xbc45, 0xbc45, 0xbc45, 0x080c, 0x0d7d, 0x600b,
 	0xffff, 0x6003, 0x000f, 0x6106, 0x0126, 0x2091, 0x8000, 0x080c,
-	0xcf69, 0x2009, 0x8000, 0x080c, 0x9200, 0x012e, 0x0005, 0x9186,
-	0x0013, 0x1128, 0x6004, 0x9082, 0x0040, 0x0804, 0xbcac, 0x9186,
-	0x0027, 0x1520, 0x080c, 0x95c6, 0x080c, 0x31ef, 0x080c, 0xcf66,
-	0x0096, 0x6114, 0x2148, 0x080c, 0xc832, 0x0198, 0x080c, 0xca47,
-	0x1118, 0x080c, 0xb5a6, 0x0068, 0xa867, 0x0103, 0xa87b, 0x0029,
-	0xa877, 0x0000, 0xa97c, 0xc1c5, 0xa97e, 0x080c, 0x6d7b, 0x080c,
-	0xca21, 0x009e, 0x080c, 0xabdf, 0x0804, 0x9684, 0x9186, 0x0014,
+	0xcf9c, 0x2009, 0x8000, 0x080c, 0x9239, 0x012e, 0x0005, 0x9186,
+	0x0013, 0x1128, 0x6004, 0x9082, 0x0040, 0x0804, 0xbccc, 0x9186,
+	0x0027, 0x1520, 0x080c, 0x95ff, 0x080c, 0x320f, 0x080c, 0xcf99,
+	0x0096, 0x6114, 0x2148, 0x080c, 0xc865, 0x0198, 0x080c, 0xca7a,
+	0x1118, 0x080c, 0xb5c6, 0x0068, 0xa867, 0x0103, 0xa87b, 0x0029,
+	0xa877, 0x0000, 0xa97c, 0xc1c5, 0xa97e, 0x080c, 0x6d9f, 0x080c,
+	0xca54, 0x009e, 0x080c, 0xabf0, 0x0804, 0x96bd, 0x9186, 0x0014,
 	0x1120, 0x6004, 0x9082, 0x0040, 0x0018, 0x080c, 0x0d7d, 0x0005,
-	0x0002, 0xbc8a, 0xbc88, 0xbc88, 0xbc88, 0xbc88, 0xbc88, 0xbc88,
-	0xbc88, 0xbc88, 0xbc88, 0xbc88, 0xbca3, 0xbca3, 0xbca3, 0xbca3,
-	0xbc88, 0xbca3, 0xbc88, 0xbca3, 0xbc88, 0xbc88, 0xbc88, 0xbc88,
-	0x080c, 0x0d7d, 0x080c, 0x95c6, 0x0096, 0x6114, 0x2148, 0x080c,
-	0xc832, 0x0168, 0xa867, 0x0103, 0xa87b, 0x0006, 0xa877, 0x0000,
-	0xa880, 0xc0ec, 0xa882, 0x080c, 0x6d7b, 0x080c, 0xca21, 0x009e,
-	0x080c, 0xabdf, 0x0005, 0x080c, 0x95c6, 0x080c, 0xca47, 0x090c,
-	0xb5a6, 0x080c, 0xabdf, 0x0005, 0x0002, 0xbcc6, 0xbcc4, 0xbcc4,
-	0xbcc4, 0xbcc4, 0xbcc4, 0xbcc4, 0xbcc4, 0xbcc4, 0xbcc4, 0xbcc4,
-	0xbcc8, 0xbcc8, 0xbcc8, 0xbcc8, 0xbcc4, 0xbcca, 0xbcc4, 0xbcc8,
-	0xbcc4, 0xbcc4, 0xbcc4, 0xbcc4, 0x080c, 0x0d7d, 0x080c, 0x0d7d,
-	0x080c, 0x0d7d, 0x080c, 0xabdf, 0x0804, 0x9684, 0x9182, 0x0057,
-	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xbced, 0xbced,
-	0xbced, 0xbced, 0xbced, 0xbd26, 0xbe15, 0xbced, 0xbe21, 0xbced,
-	0xbced, 0xbced, 0xbced, 0xbced, 0xbced, 0xbced, 0xbced, 0xbced,
-	0xbced, 0xbe21, 0xbcef, 0xbced, 0xbe1f, 0x080c, 0x0d7d, 0x00b6,
+	0x0002, 0xbcaa, 0xbca8, 0xbca8, 0xbca8, 0xbca8, 0xbca8, 0xbca8,
+	0xbca8, 0xbca8, 0xbca8, 0xbca8, 0xbcc3, 0xbcc3, 0xbcc3, 0xbcc3,
+	0xbca8, 0xbcc3, 0xbca8, 0xbcc3, 0xbca8, 0xbca8, 0xbca8, 0xbca8,
+	0x080c, 0x0d7d, 0x080c, 0x95ff, 0x0096, 0x6114, 0x2148, 0x080c,
+	0xc865, 0x0168, 0xa867, 0x0103, 0xa87b, 0x0006, 0xa877, 0x0000,
+	0xa880, 0xc0ec, 0xa882, 0x080c, 0x6d9f, 0x080c, 0xca54, 0x009e,
+	0x080c, 0xabf0, 0x0005, 0x080c, 0x95ff, 0x080c, 0xca7a, 0x090c,
+	0xb5c6, 0x080c, 0xabf0, 0x0005, 0x0002, 0xbce6, 0xbce4, 0xbce4,
+	0xbce4, 0xbce4, 0xbce4, 0xbce4, 0xbce4, 0xbce4, 0xbce4, 0xbce4,
+	0xbce8, 0xbce8, 0xbce8, 0xbce8, 0xbce4, 0xbcea, 0xbce4, 0xbce8,
+	0xbce4, 0xbce4, 0xbce4, 0xbce4, 0x080c, 0x0d7d, 0x080c, 0x0d7d,
+	0x080c, 0x0d7d, 0x080c, 0xabf0, 0x0804, 0x96bd, 0x9182, 0x0057,
+	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xbd0d, 0xbd0d,
+	0xbd0d, 0xbd0d, 0xbd0d, 0xbd46, 0xbe35, 0xbd0d, 0xbe41, 0xbd0d,
+	0xbd0d, 0xbd0d, 0xbd0d, 0xbd0d, 0xbd0d, 0xbd0d, 0xbd0d, 0xbd0d,
+	0xbd0d, 0xbe41, 0xbd0f, 0xbd0d, 0xbe3f, 0x080c, 0x0d7d, 0x00b6,
 	0x0096, 0x6114, 0x2148, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1508,
 	0xa87b, 0x0000, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87c, 0xd0ac,
-	0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xbea6, 0x080c, 0x6b91,
+	0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xbec6, 0x080c, 0x6bb5,
 	0x6210, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0xb8d0,
-	0x9005, 0x0110, 0x080c, 0x674b, 0x080c, 0xabdf, 0x009e, 0x00be,
+	0x9005, 0x0110, 0x080c, 0x676f, 0x080c, 0xabf0, 0x009e, 0x00be,
 	0x0005, 0xa87c, 0xd0ac, 0x09e0, 0xa838, 0xa934, 0x9105, 0x09c0,
-	0xa880, 0xd0bc, 0x19a8, 0x080c, 0xcb7c, 0x0c80, 0x00b6, 0x0096,
+	0xa880, 0xd0bc, 0x19a8, 0x080c, 0xcbaf, 0x0c80, 0x00b6, 0x0096,
 	0x6114, 0x2148, 0x601c, 0xd0fc, 0x1110, 0x7644, 0x0008, 0x9036,
 	0x96b4, 0x0fff, 0x86ff, 0x1590, 0x6010, 0x2058, 0xb800, 0xd0bc,
-	0x1904, 0xbe04, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0xa87c,
-	0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xbea6, 0x080c,
-	0x6b91, 0x6210, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e,
-	0xb8d0, 0x9005, 0x0110, 0x080c, 0x674b, 0x601c, 0xd0fc, 0x1148,
-	0x7044, 0xd0e4, 0x1904, 0xbde8, 0x080c, 0xabdf, 0x009e, 0x00be,
+	0x1904, 0xbe24, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0xa87c,
+	0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xbec6, 0x080c,
+	0x6bb5, 0x6210, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e,
+	0xb8d0, 0x9005, 0x0110, 0x080c, 0x676f, 0x601c, 0xd0fc, 0x1148,
+	0x7044, 0xd0e4, 0x1904, 0xbe08, 0x080c, 0xabf0, 0x009e, 0x00be,
 	0x0005, 0x2009, 0x0211, 0x210c, 0x080c, 0x0d7d, 0x968c, 0x0c00,
-	0x0150, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xbdec, 0x7348,
+	0x0150, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xbe0c, 0x7348,
 	0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0508,
 	0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x00e8, 0xd6dc, 0x01a0,
 	0xa87b, 0x0015, 0xa87c, 0xd0ac, 0x0170, 0xa938, 0xaa34, 0x2100,
@@ -5863,54 +5867,54 @@
 	0xa992, 0xaa8e, 0xc6dc, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007,
 	0x0010, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0x901e, 0xd6c4,
 	0x01d8, 0x9686, 0x0100, 0x1130, 0x7064, 0x9005, 0x1118, 0xc6c4,
-	0x0804, 0xbd32, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009,
+	0x0804, 0xbd52, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009,
 	0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011,
-	0x0025, 0x080c, 0xc3f8, 0x003e, 0xd6cc, 0x0904, 0xbd47, 0x7154,
-	0xa98a, 0x81ff, 0x0904, 0xbd47, 0x9192, 0x0021, 0x1278, 0x8304,
-	0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xc3f8, 0x2011, 0x0205,
-	0x2013, 0x0000, 0x080c, 0xcef6, 0x0804, 0xbd47, 0xa868, 0xd0fc,
+	0x0025, 0x080c, 0xc41b, 0x003e, 0xd6cc, 0x0904, 0xbd67, 0x7154,
+	0xa98a, 0x81ff, 0x0904, 0xbd67, 0x9192, 0x0021, 0x1278, 0x8304,
+	0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xc41b, 0x2011, 0x0205,
+	0x2013, 0x0000, 0x080c, 0xcf29, 0x0804, 0xbd67, 0xa868, 0xd0fc,
 	0x0120, 0x2009, 0x0020, 0xa98a, 0x0c50, 0x00a6, 0x2950, 0x080c,
-	0xc397, 0x00ae, 0x080c, 0xcef6, 0x080c, 0xc3e8, 0x0804, 0xbd49,
-	0x080c, 0xcb3f, 0x0804, 0xbd5e, 0xa87c, 0xd0ac, 0x0904, 0xbd6f,
-	0xa880, 0xd0bc, 0x1904, 0xbd6f, 0x7348, 0xa838, 0x9306, 0x11c8,
-	0x734c, 0xa834, 0x931e, 0x0904, 0xbd6f, 0xd6d4, 0x0190, 0xab38,
-	0x9305, 0x0904, 0xbd6f, 0x0068, 0xa87c, 0xd0ac, 0x0904, 0xbd3a,
-	0xa838, 0xa934, 0x9105, 0x0904, 0xbd3a, 0xa880, 0xd0bc, 0x1904,
-	0xbd3a, 0x080c, 0xcb7c, 0x0804, 0xbd5e, 0x00f6, 0x2079, 0x026c,
+	0xc3ba, 0x00ae, 0x080c, 0xcf29, 0x080c, 0xc40b, 0x0804, 0xbd69,
+	0x080c, 0xcb72, 0x0804, 0xbd7e, 0xa87c, 0xd0ac, 0x0904, 0xbd8f,
+	0xa880, 0xd0bc, 0x1904, 0xbd8f, 0x7348, 0xa838, 0x9306, 0x11c8,
+	0x734c, 0xa834, 0x931e, 0x0904, 0xbd8f, 0xd6d4, 0x0190, 0xab38,
+	0x9305, 0x0904, 0xbd8f, 0x0068, 0xa87c, 0xd0ac, 0x0904, 0xbd5a,
+	0xa838, 0xa934, 0x9105, 0x0904, 0xbd5a, 0xa880, 0xd0bc, 0x1904,
+	0xbd5a, 0x080c, 0xcbaf, 0x0804, 0xbd7e, 0x00f6, 0x2079, 0x026c,
 	0x7c04, 0x7b00, 0x7e0c, 0x7d08, 0x00fe, 0x0021, 0x0005, 0x0011,
 	0x0005, 0x0005, 0x0096, 0x6003, 0x0002, 0x6007, 0x0043, 0x6014,
 	0x2048, 0xa87c, 0xd0ac, 0x0128, 0x009e, 0x0005, 0x2130, 0x2228,
 	0x0058, 0x2400, 0xa9ac, 0x910a, 0x2300, 0xaab0, 0x9213, 0x2600,
 	0x9102, 0x2500, 0x9203, 0x0e90, 0xac46, 0xab4a, 0xae36, 0xad3a,
-	0x6044, 0xd0fc, 0x190c, 0xa8b1, 0x604b, 0x0000, 0x080c, 0x1c3d,
-	0x1118, 0x6144, 0x080c, 0x922c, 0x009e, 0x0005, 0x9182, 0x0057,
-	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xbe6d, 0xbe6d,
-	0xbe6d, 0xbe6d, 0xbe6d, 0xbe6d, 0xbe6d, 0xbe6d, 0xbe6d, 0xbe6d,
-	0xbe6f, 0xbe6d, 0xbe6d, 0xbe6d, 0xbe6d, 0xbe80, 0xbe6d, 0xbe6d,
-	0xbe6d, 0xbe6d, 0xbea4, 0xbe6d, 0xbe6d, 0x080c, 0x0d7d, 0x6004,
-	0x9086, 0x0040, 0x1110, 0x080c, 0x95c6, 0x2019, 0x0001, 0x080c,
-	0xa0fa, 0x6003, 0x0002, 0x080c, 0xcf6e, 0x080c, 0x9621, 0x0005,
-	0x6004, 0x9086, 0x0040, 0x1110, 0x080c, 0x95c6, 0x2019, 0x0001,
-	0x080c, 0xa0fa, 0x080c, 0x9621, 0x080c, 0x31ef, 0x080c, 0xcf66,
-	0x0096, 0x6114, 0x2148, 0x080c, 0xc832, 0x0150, 0xa867, 0x0103,
-	0xa87b, 0x0029, 0xa877, 0x0000, 0x080c, 0x6d7b, 0x080c, 0xca21,
-	0x009e, 0x080c, 0xabdf, 0x0005, 0x080c, 0x0d7d, 0xa87b, 0x0015,
+	0x6044, 0xd0fc, 0x190c, 0xa8c2, 0x604b, 0x0000, 0x080c, 0x1c55,
+	0x1118, 0x6144, 0x080c, 0x9265, 0x009e, 0x0005, 0x9182, 0x0057,
+	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xbe8d, 0xbe8d,
+	0xbe8d, 0xbe8d, 0xbe8d, 0xbe8d, 0xbe8d, 0xbe8d, 0xbe8d, 0xbe8d,
+	0xbe8f, 0xbe8d, 0xbe8d, 0xbe8d, 0xbe8d, 0xbea0, 0xbe8d, 0xbe8d,
+	0xbe8d, 0xbe8d, 0xbec4, 0xbe8d, 0xbe8d, 0x080c, 0x0d7d, 0x6004,
+	0x9086, 0x0040, 0x1110, 0x080c, 0x95ff, 0x2019, 0x0001, 0x080c,
+	0xa133, 0x6003, 0x0002, 0x080c, 0xcfa1, 0x080c, 0x965a, 0x0005,
+	0x6004, 0x9086, 0x0040, 0x1110, 0x080c, 0x95ff, 0x2019, 0x0001,
+	0x080c, 0xa133, 0x080c, 0x965a, 0x080c, 0x320f, 0x080c, 0xcf99,
+	0x0096, 0x6114, 0x2148, 0x080c, 0xc865, 0x0150, 0xa867, 0x0103,
+	0xa87b, 0x0029, 0xa877, 0x0000, 0x080c, 0x6d9f, 0x080c, 0xca54,
+	0x009e, 0x080c, 0xabf0, 0x0005, 0x080c, 0x0d7d, 0xa87b, 0x0015,
 	0xd1fc, 0x0180, 0xa87b, 0x0007, 0x8002, 0x8000, 0x810a, 0x9189,
 	0x0000, 0x0006, 0x0016, 0x2009, 0x1a77, 0x2104, 0x8000, 0x200a,
 	0x001e, 0x000e, 0xa992, 0xa88e, 0x0005, 0x9182, 0x0057, 0x1220,
-	0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xbedc, 0xbedc, 0xbedc,
-	0xbedc, 0xbedc, 0xbede, 0xbedc, 0xbedc, 0xbf9b, 0xbedc, 0xbedc,
-	0xbedc, 0xbedc, 0xbedc, 0xbedc, 0xbedc, 0xbedc, 0xbedc, 0xbedc,
-	0xc0d9, 0xbedc, 0xc0e3, 0xbedc, 0x080c, 0x0d7d, 0x601c, 0xd0bc,
+	0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xbefc, 0xbefc, 0xbefc,
+	0xbefc, 0xbefc, 0xbefe, 0xbefc, 0xbefc, 0xbfbb, 0xbefc, 0xbefc,
+	0xbefc, 0xbefc, 0xbefc, 0xbefc, 0xbefc, 0xbefc, 0xbefc, 0xbefc,
+	0xc0f9, 0xbefc, 0xc103, 0xbefc, 0x080c, 0x0d7d, 0x601c, 0xd0bc,
 	0x0178, 0xd084, 0x0168, 0xd0f4, 0x0120, 0xc084, 0x601e, 0x0804,
-	0xbcce, 0x6114, 0x0096, 0x2148, 0xa87c, 0xc0e5, 0xa87e, 0x009e,
+	0xbcee, 0x6114, 0x0096, 0x2148, 0xa87c, 0xc0e5, 0xa87e, 0x009e,
 	0x0076, 0x00a6, 0x00e6, 0x0096, 0x2071, 0x0260, 0x6114, 0x2150,
 	0x601c, 0xd0fc, 0x1110, 0x7644, 0x0008, 0x9036, 0xb676, 0x96b4,
 	0x0fff, 0xb77c, 0xc7e5, 0xb77e, 0x6210, 0x00b6, 0x2258, 0xba3c,
-	0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x86ff, 0x0904, 0xbf94,
+	0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x86ff, 0x0904, 0xbfb4,
 	0x9694, 0xff00, 0x9284, 0x0c00, 0x0120, 0x7048, 0xb092, 0x704c,
-	0xb08e, 0x9284, 0x0300, 0x0904, 0xbf94, 0x9686, 0x0100, 0x1130,
-	0x7064, 0x9005, 0x1118, 0xc6c4, 0xb676, 0x0c38, 0x080c, 0x103a,
+	0xb08e, 0x9284, 0x0300, 0x0904, 0xbfb4, 0x9686, 0x0100, 0x1130,
+	0x7064, 0x9005, 0x1118, 0xc6c4, 0xb676, 0x0c38, 0x080c, 0x1047,
 	0x090c, 0x0d7d, 0x2900, 0xb07a, 0xb77c, 0x97bd, 0x0200, 0xb77e,
 	0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c, 0xa86e, 0xb070, 0xa872,
 	0x7044, 0x9084, 0xf000, 0x9635, 0xae76, 0x968c, 0x0c00, 0x0120,
@@ -5920,1288 +5924,1291 @@
 	0x0010, 0xa87b, 0x0000, 0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886,
 	0x901e, 0xd6c4, 0x0190, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a,
 	0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018,
-	0x2011, 0x0025, 0x080c, 0xc3f8, 0x003e, 0xd6cc, 0x01e8, 0x7154,
+	0x2011, 0x0025, 0x080c, 0xc41b, 0x003e, 0xd6cc, 0x01e8, 0x7154,
 	0xa98a, 0x81ff, 0x01c8, 0x9192, 0x0021, 0x1260, 0x8304, 0x9098,
-	0x0018, 0x2011, 0x0029, 0x080c, 0xc3f8, 0x2011, 0x0205, 0x2013,
+	0x0018, 0x2011, 0x0029, 0x080c, 0xc41b, 0x2011, 0x0205, 0x2013,
 	0x0000, 0x0050, 0xb068, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a,
-	0x0c68, 0x2950, 0x080c, 0xc397, 0x080c, 0x1a55, 0x009e, 0x00ee,
+	0x0c68, 0x2950, 0x080c, 0xc3ba, 0x080c, 0x1a62, 0x009e, 0x00ee,
 	0x00ae, 0x007e, 0x0005, 0x2001, 0x1987, 0x2004, 0x604a, 0x0096,
 	0x6114, 0x2148, 0xa83c, 0xa940, 0x9105, 0x1118, 0xa87c, 0xc0dc,
-	0xa87e, 0x6003, 0x0002, 0x080c, 0xcf77, 0x0904, 0xc0d4, 0x604b,
+	0xa87e, 0x6003, 0x0002, 0x080c, 0xcfaa, 0x0904, 0xc0f4, 0x604b,
 	0x0000, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1500,
-	0xd1cc, 0x0904, 0xc099, 0xa978, 0xa868, 0xd0fc, 0x0904, 0xc05a,
+	0xd1cc, 0x0904, 0xc0b9, 0xa978, 0xa868, 0xd0fc, 0x0904, 0xc07a,
 	0x0016, 0xa87c, 0x0006, 0xa880, 0x0006, 0x00a6, 0x2150, 0xb174,
-	0x9184, 0x00ff, 0x90b6, 0x0002, 0x0904, 0xc028, 0x9086, 0x0028,
-	0x1904, 0xc014, 0xa87b, 0x001c, 0xb07b, 0x001c, 0x0804, 0xc030,
+	0x9184, 0x00ff, 0x90b6, 0x0002, 0x0904, 0xc048, 0x9086, 0x0028,
+	0x1904, 0xc034, 0xa87b, 0x001c, 0xb07b, 0x001c, 0x0804, 0xc050,
 	0x6024, 0xd0f4, 0x11d0, 0xa838, 0xaa34, 0x9205, 0x09c8, 0xa838,
 	0xaa90, 0x9206, 0x1120, 0xa88c, 0xaa34, 0x9206, 0x0988, 0x6024,
 	0xd0d4, 0x1148, 0xa9ac, 0xa834, 0x9102, 0x603a, 0xa9b0, 0xa838,
 	0x9103, 0x603e, 0x6024, 0xc0f5, 0x6026, 0x6010, 0x00b6, 0x2058,
 	0xb83c, 0x8000, 0xb83e, 0x00be, 0x601c, 0xc0fc, 0x601e, 0x9006,
 	0xa876, 0xa892, 0xa88e, 0xa87c, 0xc0e4, 0xa87e, 0xd0cc, 0x0140,
-	0xc0cc, 0xa87e, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fec, 0x009e,
-	0x080c, 0xcb7c, 0x0804, 0xc0d4, 0xd1dc, 0x0158, 0xa87b, 0x0015,
-	0xb07b, 0x0015, 0x080c, 0xce19, 0x0118, 0xb174, 0xc1dc, 0xb176,
+	0xc0cc, 0xa87e, 0x0096, 0xa878, 0x2048, 0x080c, 0x0ff9, 0x009e,
+	0x080c, 0xcbaf, 0x0804, 0xc0f4, 0xd1dc, 0x0158, 0xa87b, 0x0015,
+	0xb07b, 0x0015, 0x080c, 0xce4c, 0x0118, 0xb174, 0xc1dc, 0xb176,
 	0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b, 0x0007, 0x0040,
-	0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xbea6,
+	0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xbec6,
 	0xa87c, 0xb07e, 0xa890, 0xb092, 0xa88c, 0xb08e, 0xa860, 0x20e8,
 	0xa85c, 0x9080, 0x0019, 0x20a0, 0x20a9, 0x0020, 0x8a06, 0x8006,
 	0x8007, 0x9094, 0x003f, 0x22e0, 0x9084, 0xffc0, 0x9080, 0x0019,
 	0x2098, 0x4003, 0x00ae, 0x000e, 0xa882, 0x000e, 0xa87e, 0x080c,
-	0xcef6, 0x001e, 0xa874, 0x0006, 0x2148, 0x080c, 0x0fec, 0x001e,
-	0x0804, 0xc0c6, 0x0016, 0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff,
+	0xcf29, 0x001e, 0xa874, 0x0006, 0x2148, 0x080c, 0x0ff9, 0x001e,
+	0x0804, 0xc0e6, 0x0016, 0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff,
 	0x90b6, 0x0002, 0x01e0, 0x9086, 0x0028, 0x1128, 0xa87b, 0x001c,
 	0xb07b, 0x001c, 0x00e0, 0xd1dc, 0x0158, 0xa87b, 0x0015, 0xb07b,
-	0x0015, 0x080c, 0xce19, 0x0118, 0xb174, 0xc1dc, 0xb176, 0x0078,
+	0x0015, 0x080c, 0xce4c, 0x0118, 0xb174, 0xc1dc, 0xb176, 0x0078,
 	0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b, 0x0007, 0x0040, 0xa87c,
-	0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xbea6, 0xa890,
-	0xb092, 0xa88c, 0xb08e, 0xa87c, 0xb07e, 0x00ae, 0x080c, 0x0fec,
-	0x009e, 0x080c, 0xcef6, 0xa974, 0x0016, 0x080c, 0xc3e8, 0x001e,
+	0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xbec6, 0xa890,
+	0xb092, 0xa88c, 0xb08e, 0xa87c, 0xb07e, 0x00ae, 0x080c, 0x0ff9,
+	0x009e, 0x080c, 0xcf29, 0xa974, 0x0016, 0x080c, 0xc40b, 0x001e,
 	0x0468, 0xa867, 0x0103, 0xa974, 0x9184, 0x00ff, 0x90b6, 0x0002,
 	0x01b0, 0x9086, 0x0028, 0x1118, 0xa87b, 0x001c, 0x00d0, 0xd1dc,
-	0x0148, 0xa87b, 0x0015, 0x080c, 0xce19, 0x0118, 0xa974, 0xc1dc,
+	0x0148, 0xa87b, 0x0015, 0x080c, 0xce4c, 0x0118, 0xa974, 0xc1dc,
 	0xa976, 0x0078, 0xd1d4, 0x0118, 0xa87b, 0x0007, 0x0050, 0xa87b,
 	0x0000, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c,
-	0xbea6, 0xa974, 0x0016, 0x080c, 0x6b91, 0x001e, 0x6010, 0x00b6,
-	0x2058, 0xb8d0, 0x0016, 0x9005, 0x190c, 0x674b, 0x001e, 0x00be,
-	0xd1e4, 0x1120, 0x080c, 0xabdf, 0x009e, 0x0005, 0x080c, 0xcb3f,
-	0x0cd8, 0x6114, 0x0096, 0x2148, 0xa97c, 0x080c, 0xcf77, 0x190c,
-	0x1a63, 0x009e, 0x0005, 0x0096, 0x6114, 0x2148, 0xa83c, 0xa940,
+	0xbec6, 0xa974, 0x0016, 0x080c, 0x6bb5, 0x001e, 0x6010, 0x00b6,
+	0x2058, 0xb8d0, 0x0016, 0x9005, 0x190c, 0x676f, 0x001e, 0x00be,
+	0xd1e4, 0x1120, 0x080c, 0xabf0, 0x009e, 0x0005, 0x080c, 0xcb72,
+	0x0cd8, 0x6114, 0x0096, 0x2148, 0xa97c, 0x080c, 0xcfaa, 0x190c,
+	0x1a80, 0x009e, 0x0005, 0x0096, 0x6114, 0x2148, 0xa83c, 0xa940,
 	0x9105, 0x01e8, 0xa877, 0x0000, 0xa87b, 0x0000, 0xa867, 0x0103,
 	0x00b6, 0x6010, 0x2058, 0xa834, 0xa938, 0x9115, 0x11a0, 0x080c,
-	0x6b91, 0xba3c, 0x8211, 0x0208, 0xba3e, 0xb8d0, 0x9005, 0x0110,
-	0x080c, 0x674b, 0x080c, 0xabdf, 0x00be, 0x009e, 0x0005, 0xa87c,
+	0x6bb5, 0xba3c, 0x8211, 0x0208, 0xba3e, 0xb8d0, 0x9005, 0x0110,
+	0x080c, 0x676f, 0x080c, 0xabf0, 0x00be, 0x009e, 0x0005, 0xa87c,
 	0xc0dc, 0xa87e, 0x08f8, 0xb800, 0xd0bc, 0x1120, 0xa834, 0x080c,
-	0xbea6, 0x0c28, 0xa880, 0xd0bc, 0x1dc8, 0x080c, 0xcb7c, 0x0c60,
-	0x080c, 0x95c6, 0x0010, 0x080c, 0x9621, 0x601c, 0xd084, 0x0110,
-	0x080c, 0x1a77, 0x080c, 0xc832, 0x01f0, 0x0096, 0x6114, 0x2148,
-	0x080c, 0xca47, 0x1118, 0x080c, 0xb5a6, 0x00a0, 0xa867, 0x0103,
+	0xbec6, 0x0c28, 0xa880, 0xd0bc, 0x1dc8, 0x080c, 0xcbaf, 0x0c60,
+	0x080c, 0x95ff, 0x0010, 0x080c, 0x965a, 0x601c, 0xd084, 0x0110,
+	0x080c, 0x1a94, 0x080c, 0xc865, 0x01f0, 0x0096, 0x6114, 0x2148,
+	0x080c, 0xca7a, 0x1118, 0x080c, 0xb5c6, 0x00a0, 0xa867, 0x0103,
 	0x2009, 0x180c, 0x210c, 0xd18c, 0x1198, 0xd184, 0x1170, 0x6108,
-	0xa97a, 0x918e, 0x0029, 0x1110, 0x080c, 0xe631, 0xa877, 0x0000,
-	0x080c, 0x6d7b, 0x009e, 0x0804, 0xac1a, 0xa87b, 0x0004, 0x0cb0,
+	0xa97a, 0x918e, 0x0029, 0x1110, 0x080c, 0xe66e, 0xa877, 0x0000,
+	0x080c, 0x6d9f, 0x009e, 0x0804, 0xac2b, 0xa87b, 0x0004, 0x0cb0,
 	0xa87b, 0x0004, 0x0c98, 0x9182, 0x0057, 0x1220, 0x9182, 0x0040,
-	0x0208, 0x000a, 0x0005, 0xc16a, 0xc16a, 0xc16a, 0xc16a, 0xc16a,
-	0xc16c, 0xc16a, 0xc16a, 0xc16a, 0xc16a, 0xc16a, 0xc16a, 0xc16a,
-	0xc16a, 0xc16a, 0xc16a, 0xc16a, 0xc16a, 0xc16a, 0xc16a, 0xc190,
-	0xc16a, 0xc16a, 0x080c, 0x0d7d, 0x080c, 0x56dd, 0x01f8, 0x6014,
+	0x0208, 0x000a, 0x0005, 0xc18a, 0xc18a, 0xc18a, 0xc18a, 0xc18a,
+	0xc18c, 0xc18a, 0xc18a, 0xc18a, 0xc18a, 0xc18a, 0xc18a, 0xc18a,
+	0xc18a, 0xc18a, 0xc18a, 0xc18a, 0xc18a, 0xc18a, 0xc18a, 0xc1b0,
+	0xc18a, 0xc18a, 0x080c, 0x0d7d, 0x080c, 0x56fd, 0x01f8, 0x6014,
 	0x7144, 0x918c, 0x0fff, 0x9016, 0xd1c4, 0x0118, 0x7264, 0x9294,
 	0x00ff, 0x0096, 0x904d, 0x0188, 0xa87b, 0x0000, 0xa864, 0x9086,
 	0x0139, 0x0128, 0xa867, 0x0103, 0xa976, 0xaa96, 0x0030, 0xa897,
-	0x4000, 0xa99a, 0xaa9e, 0x080c, 0x6d7b, 0x009e, 0x0804, 0xabdf,
-	0x080c, 0x56dd, 0x0dd8, 0x6014, 0x900e, 0x9016, 0x0c10, 0x9182,
-	0x0085, 0x0002, 0xc1a9, 0xc1a7, 0xc1a7, 0xc1b5, 0xc1a7, 0xc1a7,
-	0xc1a7, 0xc1a7, 0xc1a7, 0xc1a7, 0xc1a7, 0xc1a7, 0xc1a7, 0x080c,
+	0x4000, 0xa99a, 0xaa9e, 0x080c, 0x6d9f, 0x009e, 0x0804, 0xabf0,
+	0x080c, 0x56fd, 0x0dd8, 0x6014, 0x900e, 0x9016, 0x0c10, 0x9182,
+	0x0085, 0x0002, 0xc1c9, 0xc1c7, 0xc1c7, 0xc1d5, 0xc1c7, 0xc1c7,
+	0xc1c7, 0xc1c7, 0xc1c7, 0xc1c7, 0xc1c7, 0xc1c7, 0xc1c7, 0x080c,
 	0x0d7d, 0x6003, 0x0001, 0x6106, 0x0126, 0x2091, 0x8000, 0x2009,
-	0x8020, 0x080c, 0x9200, 0x012e, 0x0005, 0x0026, 0x0056, 0x00d6,
-	0x00e6, 0x2071, 0x0260, 0x7224, 0x6216, 0x7220, 0x080c, 0xc820,
+	0x8020, 0x080c, 0x9239, 0x012e, 0x0005, 0x0026, 0x0056, 0x00d6,
+	0x00e6, 0x2071, 0x0260, 0x7224, 0x6216, 0x7220, 0x080c, 0xc853,
 	0x01a0, 0x2268, 0x6800, 0x9086, 0x0000, 0x0178, 0x6010, 0x6d10,
-	0x952e, 0x1158, 0x00c6, 0x2d60, 0x080c, 0xc423, 0x00ce, 0x0128,
+	0x952e, 0x1158, 0x00c6, 0x2d60, 0x080c, 0xc446, 0x00ce, 0x0128,
 	0x6803, 0x0002, 0x6007, 0x0086, 0x0010, 0x6007, 0x0087, 0x6003,
-	0x0001, 0x2009, 0x8020, 0x080c, 0x9200, 0x9280, 0x0004, 0x00b6,
-	0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140, 0x6824, 0xd0ec, 0x0128,
-	0x00c6, 0x2260, 0x080c, 0xcb7c, 0x00ce, 0x00ee, 0x00de, 0x005e,
-	0x002e, 0x0005, 0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085,
-	0x0a0c, 0x0d7d, 0x908a, 0x0092, 0x1a0c, 0x0d7d, 0x9082, 0x0085,
-	0x00e2, 0x9186, 0x0027, 0x0120, 0x9186, 0x0014, 0x190c, 0x0d7d,
-	0x080c, 0x95c6, 0x0096, 0x6014, 0x2048, 0x080c, 0xc832, 0x0140,
-	0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0029, 0x080c, 0x6d7b,
-	0x009e, 0x080c, 0xac1a, 0x0804, 0x9684, 0xc22a, 0xc22c, 0xc22c,
-	0xc22a, 0xc22a, 0xc22a, 0xc22a, 0xc22a, 0xc22a, 0xc22a, 0xc22a,
-	0xc22a, 0xc22a, 0x080c, 0x0d7d, 0x080c, 0xac1a, 0x0005, 0x9186,
-	0x0013, 0x1130, 0x6004, 0x9082, 0x0085, 0x2008, 0x0804, 0xc27b,
-	0x9186, 0x0027, 0x1558, 0x080c, 0x95c6, 0x080c, 0x31ef, 0x080c,
-	0xcf66, 0x0096, 0x6014, 0x2048, 0x080c, 0xc832, 0x0150, 0xa867,
-	0x0103, 0xa877, 0x0000, 0xa87b, 0x0029, 0x080c, 0x6d7b, 0x080c,
-	0xca21, 0x009e, 0x080c, 0xabdf, 0x0005, 0x9186, 0x0089, 0x0118,
-	0x9186, 0x008a, 0x1140, 0x080c, 0xaa9a, 0x0128, 0x9086, 0x000c,
-	0x0904, 0xc2b3, 0x0000, 0x080c, 0xac99, 0x0c70, 0x9186, 0x0014,
-	0x1d60, 0x080c, 0x95c6, 0x0096, 0x6014, 0x2048, 0x080c, 0xc832,
-	0x0d00, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0006, 0xa880,
-	0xc0ec, 0xa882, 0x0890, 0x0002, 0xc28b, 0xc289, 0xc289, 0xc289,
-	0xc289, 0xc289, 0xc29f, 0xc289, 0xc289, 0xc289, 0xc289, 0xc289,
-	0xc289, 0x080c, 0x0d7d, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186,
-	0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x2001, 0x1985, 0x0010,
-	0x2001, 0x1986, 0x2004, 0x601a, 0x6003, 0x000c, 0x0005, 0x6034,
-	0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035,
-	0x1118, 0x2001, 0x1985, 0x0010, 0x2001, 0x1986, 0x2004, 0x601a,
-	0x6003, 0x000e, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085,
-	0x0208, 0x0012, 0x0804, 0xac99, 0xc2c9, 0xc2c9, 0xc2c9, 0xc2c9,
-	0xc2cb, 0xc318, 0xc2c9, 0xc2c9, 0xc2c9, 0xc2c9, 0xc2c9, 0xc2c9,
-	0xc2c9, 0x080c, 0x0d7d, 0x0096, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x0168, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186,
-	0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x009e, 0x0804, 0xc32c,
-	0x080c, 0xc832, 0x1118, 0x080c, 0xca21, 0x0068, 0x6014, 0x2048,
-	0x080c, 0xcf7d, 0x1110, 0x080c, 0xca21, 0xa867, 0x0103, 0x080c,
-	0xcf31, 0x080c, 0x6d7b, 0x00d6, 0x2c68, 0x080c, 0xab89, 0x01d0,
-	0x6003, 0x0001, 0x6007, 0x001e, 0x600b, 0xffff, 0x2009, 0x026e,
-	0x210c, 0x613a, 0x2009, 0x026f, 0x210c, 0x613e, 0x6910, 0x6112,
-	0x080c, 0xcccb, 0x695c, 0x615e, 0x6023, 0x0001, 0x2009, 0x8020,
-	0x080c, 0x9200, 0x2d60, 0x00de, 0x080c, 0xabdf, 0x009e, 0x0005,
-	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x05a0, 0x6034,
-	0x908c, 0xff00, 0x810f, 0x9186, 0x0035, 0x0130, 0x9186, 0x001e,
-	0x0118, 0x9186, 0x0039, 0x1538, 0x00d6, 0x2c68, 0x080c, 0xcec9,
-	0x11f0, 0x080c, 0xab89, 0x01d8, 0x6106, 0x6003, 0x0001, 0x6023,
-	0x0001, 0x6910, 0x6112, 0x692c, 0x612e, 0x6930, 0x6132, 0x6934,
-	0x918c, 0x00ff, 0x6136, 0x6938, 0x613a, 0x693c, 0x613e, 0x695c,
-	0x615e, 0x080c, 0xcccb, 0x2009, 0x8020, 0x080c, 0x9200, 0x2d60,
-	0x00de, 0x0804, 0xabdf, 0x0096, 0x6014, 0x2048, 0x080c, 0xc832,
-	0x01c8, 0xa867, 0x0103, 0xa880, 0xd0b4, 0x0128, 0xc0ec, 0xa882,
-	0xa87b, 0x0006, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002, 0x0020,
-	0xa87b, 0x0005, 0x080c, 0xcb3b, 0xa877, 0x0000, 0x080c, 0x6d7b,
-	0x080c, 0xca21, 0x009e, 0x0804, 0xabdf, 0x0016, 0x0096, 0x6014,
-	0x2048, 0x080c, 0xc832, 0x0140, 0xa867, 0x0103, 0xa87b, 0x0028,
-	0xa877, 0x0000, 0x080c, 0x6d7b, 0x009e, 0x001e, 0x9186, 0x0013,
-	0x0158, 0x9186, 0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c,
-	0xac99, 0x0020, 0x080c, 0x95c6, 0x080c, 0xac1a, 0x0005, 0x0056,
-	0x0066, 0x0096, 0x00a6, 0x2029, 0x0001, 0x9182, 0x0101, 0x1208,
-	0x0010, 0x2009, 0x0100, 0x2130, 0x8304, 0x9098, 0x0018, 0x2009,
-	0x0020, 0x2011, 0x0029, 0x080c, 0xc3f8, 0x96b2, 0x0020, 0xb004,
-	0x904d, 0x0110, 0x080c, 0x0fec, 0x080c, 0x103a, 0x0520, 0x8528,
-	0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406, 0x968a, 0x003d,
-	0x1228, 0x2608, 0x2011, 0x001b, 0x0499, 0x00a8, 0x96b2, 0x003c,
-	0x2009, 0x003c, 0x2950, 0x2011, 0x001b, 0x0451, 0x0c28, 0x2001,
-	0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0003, 0xb566,
-	0x95ac, 0x0000, 0x0048, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae,
-	0x852f, 0x95ad, 0x0003, 0xb566, 0x009e, 0x006e, 0x005e, 0x0005,
-	0x00a6, 0x89ff, 0x0158, 0xa804, 0x9055, 0x0130, 0xa807, 0x0000,
-	0x080c, 0x6d7b, 0x2a48, 0x0cb8, 0x080c, 0x6d7b, 0x00ae, 0x0005,
-	0x00f6, 0x2079, 0x0200, 0x7814, 0x9085, 0x0080, 0x7816, 0xd184,
-	0x0108, 0x8108, 0x810c, 0x20a9, 0x0001, 0xa860, 0x20e8, 0xa85c,
-	0x9200, 0x20a0, 0x20e1, 0x0000, 0x2300, 0x9e00, 0x2098, 0x4003,
-	0x8318, 0x9386, 0x0020, 0x1148, 0x2018, 0x2300, 0x9e00, 0x2098,
-	0x7814, 0x8000, 0x9085, 0x0080, 0x7816, 0x8109, 0x1d80, 0x7817,
-	0x0000, 0x00fe, 0x0005, 0x0066, 0x0126, 0x2091, 0x8000, 0x2031,
-	0x0001, 0x6020, 0x9084, 0x000f, 0x0083, 0x012e, 0x006e, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x0066, 0x2031, 0x0000, 0x6020, 0x9084,
-	0x000f, 0x001b, 0x006e, 0x012e, 0x0005, 0xc475, 0xc475, 0xc470,
-	0xc499, 0xc44d, 0xc470, 0xc44f, 0xc470, 0xc44d, 0x90c6, 0xc470,
-	0xc470, 0xc470, 0xc44d, 0xc44d, 0xc44d, 0x080c, 0x0d7d, 0x6010,
-	0x9080, 0x0000, 0x2004, 0xd0bc, 0x190c, 0xc499, 0x0036, 0x6014,
-	0x0096, 0x2048, 0xa880, 0x009e, 0xd0cc, 0x0118, 0x2019, 0x000c,
-	0x0038, 0xd094, 0x0118, 0x2019, 0x000d, 0x0010, 0x2019, 0x0010,
-	0x080c, 0xde2a, 0x6023, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005,
-	0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x0096, 0x86ff, 0x11e8,
-	0x6014, 0x2048, 0x080c, 0xc832, 0x01d0, 0x6043, 0xffff, 0xa864,
-	0x9086, 0x0139, 0x1128, 0xa87b, 0x0005, 0xa883, 0x0000, 0x0028,
-	0x900e, 0x2001, 0x0005, 0x080c, 0x6faf, 0x080c, 0xcb3b, 0x080c,
-	0x6d6f, 0x080c, 0xac1a, 0x9085, 0x0001, 0x009e, 0x0005, 0x9006,
-	0x0ce0, 0x080c, 0xa888, 0x080c, 0xcf8b, 0x6000, 0x908a, 0x0016,
-	0x1a0c, 0x0d7d, 0x002b, 0x0106, 0x080c, 0xa8a4, 0x010e, 0x0005,
-	0xc4b8, 0xc4e6, 0xc4ba, 0xc50d, 0xc4e1, 0xc4b8, 0xc470, 0xc475,
-	0xc475, 0xc470, 0xc470, 0xc470, 0xc470, 0xc470, 0xc470, 0xc470,
-	0x080c, 0x0d7d, 0x86ff, 0x1510, 0x6020, 0x9086, 0x0006, 0x01f0,
-	0x0096, 0x6014, 0x2048, 0x080c, 0xc832, 0x0158, 0xa87c, 0xd0cc,
-	0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fec, 0x009e, 0x080c,
-	0xcb3b, 0x009e, 0x080c, 0xcf0b, 0x6007, 0x0085, 0x6003, 0x000b,
-	0x6023, 0x0002, 0x2009, 0x8020, 0x080c, 0x91e2, 0x9085, 0x0001,
-	0x0005, 0x0066, 0x080c, 0x1a77, 0x006e, 0x08a0, 0x00e6, 0x2071,
-	0x19e6, 0x7030, 0x9c06, 0x1120, 0x080c, 0xa07a, 0x00ee, 0x0850,
-	0x6020, 0x9084, 0x000f, 0x9086, 0x0006, 0x1150, 0x0086, 0x0096,
-	0x2049, 0x0001, 0x2c40, 0x080c, 0xa1fa, 0x009e, 0x008e, 0x0040,
-	0x0066, 0x080c, 0x9f76, 0x190c, 0x0d7d, 0x080c, 0x9f84, 0x006e,
-	0x00ee, 0x1904, 0xc4ba, 0x0804, 0xc470, 0x0036, 0x00e6, 0x2071,
-	0x19e6, 0x704c, 0x9c06, 0x1138, 0x901e, 0x080c, 0xa0fa, 0x00ee,
-	0x003e, 0x0804, 0xc4ba, 0x080c, 0xa331, 0x00ee, 0x003e, 0x1904,
-	0xc4ba, 0x0804, 0xc470, 0x00c6, 0x0066, 0x6020, 0x9084, 0x000f,
-	0x001b, 0x006e, 0x00ce, 0x0005, 0xc543, 0xc612, 0xc779, 0xc54b,
-	0xac1a, 0xc543, 0xde1c, 0xcf73, 0xc612, 0x908d, 0xc7f8, 0xc53c,
-	0xc53c, 0xc53c, 0xc53c, 0xc53c, 0x080c, 0x0d7d, 0x080c, 0xca47,
-	0x1110, 0x080c, 0xb5a6, 0x0005, 0x080c, 0x95c6, 0x0804, 0xabdf,
-	0x601b, 0x0001, 0x0005, 0x080c, 0xc832, 0x0130, 0x6014, 0x0096,
-	0x2048, 0x2c00, 0xa896, 0x009e, 0x080c, 0xa888, 0x080c, 0xcf8b,
-	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0013, 0x0804, 0xa8a4,
-	0xc570, 0xc572, 0xc59c, 0xc5b0, 0xc5dd, 0xc570, 0xc543, 0xc543,
-	0xc543, 0xc5b7, 0xc5b7, 0xc570, 0xc570, 0xc570, 0xc570, 0xc5c1,
-	0x080c, 0x0d7d, 0x00e6, 0x6014, 0x0096, 0x2048, 0xa880, 0xc0b5,
-	0xa882, 0x009e, 0x2071, 0x19e6, 0x7030, 0x9c06, 0x01d0, 0x0066,
-	0x080c, 0x9f76, 0x190c, 0x0d7d, 0x080c, 0x9f84, 0x006e, 0x080c,
-	0xcf0b, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2001,
-	0x1986, 0x2004, 0x601a, 0x2009, 0x8020, 0x080c, 0x91e2, 0x00ee,
-	0x0005, 0x601b, 0x0001, 0x0cd8, 0x0096, 0x6014, 0x2048, 0xa880,
-	0xc0b5, 0xa882, 0x009e, 0x080c, 0xcf0b, 0x6007, 0x0085, 0x6003,
-	0x000b, 0x6023, 0x0002, 0x2009, 0x8020, 0x080c, 0x91e2, 0x0005,
-	0x080c, 0xa888, 0x080c, 0xaa1c, 0x080c, 0xa8a4, 0x0c28, 0x0096,
-	0x601b, 0x0001, 0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e,
-	0x0005, 0x080c, 0x56dd, 0x01b8, 0x6014, 0x0096, 0x904d, 0x0190,
-	0xa864, 0xa867, 0x0103, 0xa87b, 0x0006, 0x9086, 0x0139, 0x1150,
-	0xa867, 0x0139, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa89b, 0x0004,
-	0x080c, 0x6d7b, 0x009e, 0x0804, 0xabdf, 0x6014, 0x0096, 0x904d,
-	0x0560, 0xa97c, 0xd1e4, 0x1158, 0x611c, 0xd1fc, 0x0530, 0x6110,
-	0x00b6, 0x2158, 0xb93c, 0x8109, 0x0208, 0xb93e, 0x00be, 0x080c,
-	0xa8a4, 0x2001, 0x180f, 0x2004, 0xd0c4, 0x0110, 0x009e, 0x0005,
-	0xa884, 0x009e, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0x2001,
-	0x0037, 0x2c08, 0x080c, 0x1686, 0x6000, 0x9086, 0x0004, 0x1120,
-	0x2009, 0x0048, 0x080c, 0xac7c, 0x0005, 0x009e, 0x080c, 0x1a77,
-	0x0804, 0xc59c, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x000b,
-	0x0005, 0xc629, 0xc548, 0xc62b, 0xc629, 0xc62b, 0xc62b, 0xc544,
-	0xc629, 0xc53e, 0xc53e, 0xc629, 0xc629, 0xc629, 0xc629, 0xc629,
-	0xc629, 0x080c, 0x0d7d, 0x6010, 0x00b6, 0x2058, 0xb804, 0x9084,
-	0x00ff, 0x00be, 0x908a, 0x000c, 0x1a0c, 0x0d7d, 0x00b6, 0x0013,
-	0x00be, 0x0005, 0xc646, 0xc713, 0xc648, 0xc688, 0xc648, 0xc688,
-	0xc648, 0xc656, 0xc646, 0xc688, 0xc646, 0xc677, 0x080c, 0x0d7d,
-	0x6004, 0x908e, 0x0016, 0x05c0, 0x908e, 0x0004, 0x05a8, 0x908e,
-	0x0002, 0x0590, 0x908e, 0x0052, 0x0904, 0xc70f, 0x6004, 0x080c,
-	0xca47, 0x0904, 0xc72c, 0x908e, 0x0004, 0x1110, 0x080c, 0x321e,
-	0x908e, 0x0021, 0x0904, 0xc730, 0x908e, 0x0022, 0x0904, 0xc774,
-	0x908e, 0x003d, 0x0904, 0xc730, 0x908e, 0x0039, 0x0904, 0xc734,
-	0x908e, 0x0035, 0x0904, 0xc734, 0x908e, 0x001e, 0x0178, 0x908e,
-	0x0001, 0x1140, 0x6010, 0x2058, 0xb804, 0x9084, 0x00ff, 0x9086,
-	0x0006, 0x0110, 0x080c, 0x31ef, 0x080c, 0xb5a6, 0x0804, 0xac1a,
-	0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016, 0x0904, 0xc700, 0x9186,
-	0x0002, 0x1904, 0xc6d5, 0x2001, 0x1837, 0x2004, 0xd08c, 0x11c8,
-	0x080c, 0x74c8, 0x11b0, 0x080c, 0xcf51, 0x0138, 0x080c, 0x74eb,
-	0x1120, 0x080c, 0x73d3, 0x0804, 0xc75d, 0x2001, 0x197c, 0x2003,
-	0x0001, 0x2001, 0x1800, 0x2003, 0x0001, 0x080c, 0x73f9, 0x0804,
-	0xc75d, 0x6010, 0x2058, 0x2001, 0x1837, 0x2004, 0xd0ac, 0x1904,
-	0xc75d, 0xb8a0, 0x9084, 0xff80, 0x1904, 0xc75d, 0xb840, 0x9084,
-	0x00ff, 0x9005, 0x0190, 0x8001, 0xb842, 0x6017, 0x0000, 0x6023,
-	0x0007, 0x601b, 0x0398, 0x604b, 0x0000, 0x080c, 0xab89, 0x0128,
-	0x2b00, 0x6012, 0x6023, 0x0001, 0x0458, 0x00de, 0x00ce, 0x6004,
-	0x908e, 0x0002, 0x11a0, 0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e,
-	0x1170, 0x2009, 0x1837, 0x2104, 0xc085, 0x200a, 0x00e6, 0x2071,
-	0x1800, 0x080c, 0x5fb7, 0x00ee, 0x080c, 0xb5a6, 0x0030, 0x080c,
-	0xb5a6, 0x080c, 0x31ef, 0x080c, 0xcf66, 0x00e6, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x321e, 0x012e, 0x00ee, 0x080c, 0xac1a, 0x0005,
-	0x2001, 0x0002, 0x080c, 0x6570, 0x6003, 0x0001, 0x6007, 0x0002,
-	0x080c, 0x9207, 0x080c, 0x9684, 0x00de, 0x00ce, 0x0c80, 0x080c,
-	0x321e, 0x0804, 0xc684, 0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016,
-	0x0d38, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0904,
-	0xc6d5, 0x8001, 0xb842, 0x6003, 0x0001, 0x080c, 0x9207, 0x080c,
-	0x9684, 0x00de, 0x00ce, 0x0898, 0x080c, 0xb5a6, 0x0804, 0xc686,
-	0x080c, 0xb5e2, 0x0804, 0xc686, 0x00d6, 0x2c68, 0x6104, 0x080c,
-	0xcec9, 0x00de, 0x0118, 0x080c, 0xabdf, 0x00f0, 0x6004, 0x8007,
-	0x6134, 0x918c, 0x00ff, 0x9105, 0x6036, 0x6007, 0x0085, 0x6003,
-	0x000b, 0x6023, 0x0002, 0x603c, 0x600a, 0x2001, 0x1986, 0x2004,
-	0x601a, 0x602c, 0x2c08, 0x2060, 0x6024, 0xc0b5, 0x6026, 0x2160,
-	0x2009, 0x8020, 0x080c, 0x9200, 0x0005, 0x00de, 0x00ce, 0x080c,
-	0xb5a6, 0x080c, 0x31ef, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x321e, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398, 0x604b,
-	0x0000, 0x012e, 0x00ee, 0x0005, 0x080c, 0xb01a, 0x1904, 0xc72c,
-	0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0096, 0x00d6,
-	0x001b, 0x00de, 0x009e, 0x0005, 0xc794, 0xc794, 0xc794, 0xc794,
-	0xc794, 0xc794, 0xc794, 0xc794, 0xc794, 0xc543, 0xc794, 0xc548,
-	0xc796, 0xc548, 0xc7a3, 0xc794, 0x080c, 0x0d7d, 0x6004, 0x9086,
-	0x008b, 0x0148, 0x6007, 0x008b, 0x6003, 0x000d, 0x2009, 0x8020,
-	0x080c, 0x9200, 0x0005, 0x080c, 0xcf45, 0x0118, 0x080c, 0xcf58,
-	0x0010, 0x080c, 0xcf66, 0x080c, 0xca21, 0x080c, 0xc832, 0x0570,
-	0x080c, 0x31ef, 0x080c, 0xc832, 0x0168, 0x6014, 0x2048, 0xa867,
-	0x0103, 0xa87b, 0x0006, 0xa877, 0x0000, 0xa880, 0xc0ed, 0xa882,
-	0x080c, 0x6d7b, 0x2c68, 0x080c, 0xab89, 0x0150, 0x6810, 0x6012,
-	0x080c, 0xcccb, 0x00c6, 0x2d60, 0x080c, 0xac1a, 0x00ce, 0x0008,
-	0x2d60, 0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003,
-	0x0001, 0x080c, 0x9207, 0x080c, 0x9684, 0x00c8, 0x080c, 0xcf45,
-	0x0138, 0x6034, 0x9086, 0x4000, 0x1118, 0x080c, 0x31ef, 0x08d0,
-	0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186,
-	0x0035, 0x1118, 0x080c, 0x31ef, 0x0868, 0x080c, 0xac1a, 0x0005,
-	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0002, 0xc80e, 0xc80e,
-	0xc810, 0xc810, 0xc810, 0xc80e, 0xc80e, 0xac1a, 0xc80e, 0xc80e,
-	0xc80e, 0xc80e, 0xc80e, 0xc80e, 0xc80e, 0xc80e, 0x080c, 0x0d7d,
-	0x080c, 0xa888, 0x080c, 0xaa1c, 0x080c, 0xa8a4, 0x6114, 0x0096,
-	0x2148, 0xa87b, 0x0006, 0x080c, 0x6d7b, 0x009e, 0x0804, 0xabdf,
-	0x9284, 0x0003, 0x1158, 0x9282, 0x1ddc, 0x0240, 0x2001, 0x181a,
-	0x2004, 0x9202, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8,
-	0x0096, 0x0028, 0x0096, 0x0006, 0x6014, 0x2048, 0x000e, 0x0006,
-	0x9984, 0xf000, 0x9086, 0xf000, 0x0110, 0x080c, 0x10e5, 0x000e,
-	0x009e, 0x0005, 0x00e6, 0x00c6, 0x0036, 0x0006, 0x0126, 0x2091,
-	0x8000, 0x2061, 0x1ddc, 0x2071, 0x1800, 0x7354, 0x7074, 0x9302,
-	0x1640, 0x6020, 0x9206, 0x11f8, 0x080c, 0xcf51, 0x0180, 0x9286,
-	0x0001, 0x1168, 0x6004, 0x9086, 0x0004, 0x1148, 0x080c, 0x31ef,
-	0x080c, 0xcf66, 0x00c6, 0x080c, 0xac1a, 0x00ce, 0x0060, 0x080c,
-	0xcc3d, 0x0148, 0x080c, 0xca47, 0x1110, 0x080c, 0xb5a6, 0x00c6,
-	0x080c, 0xabdf, 0x00ce, 0x9ce0, 0x001c, 0x7068, 0x9c02, 0x1208,
-	0x08a0, 0x012e, 0x000e, 0x003e, 0x00ce, 0x00ee, 0x0005, 0x00e6,
-	0x00c6, 0x0016, 0x9188, 0x1000, 0x210c, 0x81ff, 0x0128, 0x2061,
-	0x1b31, 0x6112, 0x080c, 0x31ef, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x001e, 0x00ce, 0x00ee, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0xab89, 0x01b0, 0x665e, 0x2b00, 0x6012, 0x080c, 0x56dd,
-	0x0118, 0x080c, 0xc963, 0x0168, 0x080c, 0xcccb, 0x6023, 0x0003,
-	0x2009, 0x004b, 0x080c, 0xac7c, 0x9085, 0x0001, 0x012e, 0x00ce,
-	0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0xbaa0,
-	0x080c, 0xac4f, 0x0580, 0x605f, 0x0000, 0x2b00, 0x6012, 0x080c,
-	0xcccb, 0x6023, 0x0003, 0x0016, 0x080c, 0xa888, 0x080c, 0x938d,
-	0x0076, 0x903e, 0x080c, 0x9256, 0x2c08, 0x080c, 0xdffb, 0x007e,
-	0x080c, 0xa8a4, 0x001e, 0xd184, 0x0128, 0x080c, 0xabdf, 0x9085,
-	0x0001, 0x0070, 0x080c, 0x56dd, 0x0128, 0xd18c, 0x1170, 0x080c,
-	0xc963, 0x0148, 0x2009, 0x004c, 0x080c, 0xac7c, 0x9085, 0x0001,
-	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2900, 0x6016, 0x0c90,
-	0x2009, 0x004d, 0x0010, 0x2009, 0x004e, 0x00f6, 0x00c6, 0x0046,
-	0x0016, 0x080c, 0xab89, 0x2c78, 0x0590, 0x7e5e, 0x2b00, 0x7812,
-	0x7823, 0x0003, 0x2021, 0x0005, 0x080c, 0xc975, 0x9186, 0x004d,
-	0x0118, 0x9186, 0x004e, 0x0148, 0x2001, 0x197f, 0x200c, 0xd1fc,
-	0x0168, 0x2f60, 0x080c, 0xabdf, 0x00d0, 0x2001, 0x197e, 0x200c,
-	0xd1fc, 0x0120, 0x2f60, 0x080c, 0xabdf, 0x0088, 0x2f60, 0x080c,
-	0x56dd, 0x0138, 0xd18c, 0x1118, 0x04f1, 0x0148, 0x0010, 0x2900,
-	0x7816, 0x001e, 0x0016, 0x080c, 0xac7c, 0x9085, 0x0001, 0x001e,
-	0x004e, 0x00ce, 0x00fe, 0x0005, 0x00f6, 0x00c6, 0x0046, 0x080c,
-	0xab89, 0x2c78, 0x0508, 0x7e5e, 0x2b00, 0x7812, 0x7823, 0x0003,
-	0x0096, 0x2021, 0x0004, 0x0489, 0x009e, 0x2001, 0x197d, 0x200c,
-	0xd1fc, 0x0120, 0x2f60, 0x080c, 0xabdf, 0x0060, 0x2f60, 0x080c,
-	0x56dd, 0x0120, 0xd18c, 0x1160, 0x0071, 0x0130, 0x2009, 0x0052,
-	0x080c, 0xac7c, 0x9085, 0x0001, 0x004e, 0x00ce, 0x00fe, 0x0005,
-	0x2900, 0x7816, 0x0c98, 0x00c6, 0x080c, 0x4aa9, 0x00ce, 0x1120,
-	0x080c, 0xabdf, 0x9006, 0x0005, 0xa867, 0x0000, 0xa86b, 0x8000,
-	0x2900, 0x6016, 0x9085, 0x0001, 0x0005, 0x0096, 0x0076, 0x0126,
-	0x2091, 0x8000, 0x080c, 0xa888, 0x080c, 0x6802, 0x0158, 0x2001,
-	0xc97c, 0x0006, 0x900e, 0x2400, 0x080c, 0x6faf, 0x080c, 0x6d7b,
-	0x000e, 0x0807, 0x2418, 0x080c, 0x958c, 0xbaa0, 0x0086, 0x2041,
-	0x0001, 0x2039, 0x0001, 0x2608, 0x080c, 0x93a7, 0x008e, 0x080c,
-	0x9256, 0x2f08, 0x2648, 0x080c, 0xdffb, 0xb93c, 0x81ff, 0x090c,
-	0x947e, 0x080c, 0xa8a4, 0x012e, 0x007e, 0x009e, 0x0005, 0x00c6,
-	0x0126, 0x2091, 0x8000, 0x080c, 0xab89, 0x0190, 0x660a, 0x2b08,
-	0x6112, 0x080c, 0xcccb, 0x6023, 0x0001, 0x2900, 0x6016, 0x2009,
-	0x001f, 0x080c, 0xac7c, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005,
-	0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xac4f,
-	0x01b8, 0x660a, 0x2b08, 0x6112, 0x080c, 0xcccb, 0x6023, 0x0008,
-	0x2900, 0x6016, 0x00f6, 0x2c78, 0x080c, 0x173e, 0x00fe, 0x2009,
-	0x0021, 0x080c, 0xac7c, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005,
-	0x9006, 0x0cd8, 0x2009, 0x003d, 0x00c6, 0x0126, 0x0016, 0x2091,
-	0x8000, 0x080c, 0xab89, 0x0198, 0x660a, 0x2b08, 0x6112, 0x080c,
-	0xcccb, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e, 0x0016, 0x080c,
-	0xac7c, 0x9085, 0x0001, 0x001e, 0x012e, 0x00ce, 0x0005, 0x9006,
-	0x0cd0, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xac4f, 0x0188,
-	0x2b08, 0x6112, 0x080c, 0xcccb, 0x6023, 0x0001, 0x2900, 0x6016,
-	0x2009, 0x0000, 0x080c, 0xac7c, 0x9085, 0x0001, 0x012e, 0x00ce,
-	0x0005, 0x9006, 0x0cd8, 0x2009, 0x0044, 0x0830, 0x2009, 0x0049,
-	0x0818, 0x0026, 0x00b6, 0x6210, 0x2258, 0xba3c, 0x82ff, 0x0118,
-	0x8211, 0xba3e, 0x1140, 0xb8d0, 0x9005, 0x0128, 0xb888, 0x9005,
-	0x1110, 0xb88b, 0x0001, 0x00be, 0x002e, 0x0005, 0x0006, 0x0016,
-	0x6004, 0x908e, 0x0002, 0x0140, 0x908e, 0x0003, 0x0128, 0x908e,
-	0x0004, 0x0110, 0x9085, 0x0001, 0x001e, 0x000e, 0x0005, 0x0006,
-	0x0086, 0x0096, 0x6020, 0x9086, 0x0004, 0x01a8, 0x6014, 0x904d,
-	0x080c, 0xc832, 0x0180, 0xa864, 0x9086, 0x0139, 0x0170, 0x6020,
-	0x90c6, 0x0003, 0x0140, 0x90c6, 0x0002, 0x0128, 0xa868, 0xd0fc,
-	0x0110, 0x9006, 0x0010, 0x9085, 0x0001, 0x009e, 0x008e, 0x000e,
-	0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xac4f, 0x0198,
-	0x2b08, 0x6112, 0x080c, 0xcccb, 0x6023, 0x0001, 0x2900, 0x6016,
-	0x080c, 0x31ef, 0x2009, 0x0028, 0x080c, 0xac7c, 0x9085, 0x0001,
-	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x9186, 0x0015, 0x11a8,
-	0x2011, 0x1824, 0x2204, 0x9086, 0x0074, 0x1178, 0x00b6, 0x080c,
-	0xb7fa, 0x00be, 0x080c, 0xba1d, 0x6003, 0x0001, 0x6007, 0x0029,
-	0x080c, 0x9207, 0x080c, 0x9684, 0x0078, 0x6014, 0x0096, 0x2048,
-	0xa868, 0x009e, 0xd0fc, 0x0148, 0x2001, 0x0001, 0x080c, 0xce8a,
-	0x080c, 0xb5a6, 0x080c, 0xabdf, 0x0005, 0x0096, 0x6014, 0x904d,
-	0x090c, 0x0d7d, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005,
-	0xa89b, 0x0004, 0xa867, 0x0139, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x6d7b, 0x012e, 0x009e, 0x080c, 0xabdf, 0x0c30, 0x0096, 0x9186,
-	0x0016, 0x1128, 0x2001, 0x0004, 0x080c, 0x6570, 0x00e8, 0x9186,
-	0x0015, 0x1510, 0x2011, 0x1824, 0x2204, 0x9086, 0x0014, 0x11e0,
-	0x6010, 0x00b6, 0x2058, 0x080c, 0x66bb, 0x00be, 0x080c, 0xbaee,
-	0x1198, 0x6010, 0x00b6, 0x2058, 0xb890, 0x00be, 0x9005, 0x0160,
-	0x2001, 0x0006, 0x080c, 0x6570, 0x6014, 0x2048, 0xa868, 0xd0fc,
-	0x0170, 0x080c, 0xafee, 0x0048, 0x6014, 0x2048, 0xa868, 0xd0fc,
-	0x0528, 0x080c, 0xb5a6, 0x080c, 0xabdf, 0x009e, 0x0005, 0x6014,
-	0x6310, 0x2358, 0x904d, 0x090c, 0x0d7d, 0xa87b, 0x0000, 0xa883,
-	0x0000, 0xa897, 0x4000, 0x900e, 0x080c, 0x6913, 0x1108, 0xc185,
-	0xb800, 0xd0bc, 0x0108, 0xc18d, 0xa99a, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x6d7b, 0x012e, 0x080c, 0xabdf, 0x08f8, 0x6014, 0x904d,
-	0x090c, 0x0d7d, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005,
-	0xa89b, 0x0004, 0xa867, 0x0139, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x6d7b, 0x012e, 0x080c, 0xabdf, 0x0840, 0xa878, 0x9086, 0x0005,
-	0x1108, 0x0009, 0x0005, 0xa880, 0xc0ad, 0xa882, 0x0005, 0x604b,
-	0x0000, 0x6017, 0x0000, 0x6003, 0x0001, 0x6007, 0x0050, 0x2009,
-	0x8023, 0x080c, 0x9200, 0x0005, 0x00c6, 0x6010, 0x00b6, 0x2058,
-	0xb800, 0x00be, 0xd0bc, 0x0130, 0x0066, 0x6020, 0x9084, 0x000f,
-	0x001b, 0x006e, 0x00ce, 0x0005, 0xc543, 0xcb6e, 0xcb6e, 0xcb71,
-	0xe328, 0xe343, 0xe346, 0xc543, 0xc543, 0xc543, 0xc543, 0xc543,
-	0xc543, 0xc543, 0xc543, 0xc543, 0x080c, 0x0d7d, 0xa001, 0xa001,
-	0x0005, 0x0096, 0x6014, 0x904d, 0x0118, 0xa87c, 0xd0e4, 0x1110,
-	0x009e, 0x0010, 0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x0550, 0x2001, 0x1834, 0x2004, 0x9005, 0x1540,
-	0x00f6, 0x2c78, 0x080c, 0xab89, 0x0508, 0x7810, 0x6012, 0x080c,
-	0xcccb, 0x7820, 0x9086, 0x0003, 0x0128, 0x7808, 0x603a, 0x2f00,
-	0x603e, 0x0020, 0x7808, 0x603e, 0x2f00, 0x603a, 0x602e, 0x6023,
-	0x0001, 0x6007, 0x0035, 0x6003, 0x0001, 0x795c, 0x615e, 0x2009,
-	0x8020, 0x080c, 0x9200, 0x2f60, 0x00fe, 0x0005, 0x2f60, 0x00fe,
-	0x2001, 0x1987, 0x2004, 0x604a, 0x0005, 0x0016, 0x0096, 0x6814,
-	0x2048, 0x681c, 0xd0fc, 0xc0fc, 0x681e, 0xa87c, 0x1108, 0xd0e4,
-	0x0180, 0xc0e4, 0xa87e, 0xa877, 0x0000, 0xa893, 0x0000, 0xa88f,
-	0x0000, 0xd0cc, 0x0130, 0xc0cc, 0xa87e, 0xa878, 0x2048, 0x080c,
-	0x0fec, 0x6830, 0x6036, 0x908e, 0x0001, 0x0148, 0x6803, 0x0002,
-	0x9086, 0x0005, 0x0170, 0x9006, 0x602e, 0x6032, 0x00d0, 0x681c,
-	0xc085, 0x681e, 0x6803, 0x0004, 0x6824, 0xc0f4, 0x9085, 0x0c00,
-	0x6826, 0x6814, 0x2048, 0xa8ac, 0x6938, 0x9102, 0xa8b0, 0x693c,
-	0x9103, 0x1e48, 0x683c, 0x602e, 0x6838, 0x9084, 0xfffc, 0x683a,
-	0x6032, 0x2d00, 0x603a, 0x6808, 0x603e, 0x6910, 0x6112, 0x695c,
-	0x615e, 0x6023, 0x0001, 0x6007, 0x0039, 0x6003, 0x0001, 0x2009,
-	0x8020, 0x080c, 0x9200, 0x009e, 0x001e, 0x0005, 0x6024, 0xd0d4,
-	0x0510, 0xd0f4, 0x11f8, 0x6038, 0x940a, 0x603c, 0x9303, 0x0230,
-	0x9105, 0x0120, 0x6024, 0xc0d4, 0xc0f5, 0x0098, 0x643a, 0x633e,
-	0xac3e, 0xab42, 0x0046, 0x0036, 0x2400, 0xacac, 0x9402, 0xa836,
-	0x2300, 0xabb0, 0x9303, 0xa83a, 0x003e, 0x004e, 0x6024, 0xc0d4,
-	0x0000, 0x6026, 0x0005, 0xd0f4, 0x1138, 0xa83c, 0x603a, 0xa840,
-	0x603e, 0x6024, 0xc0f5, 0x6026, 0x0005, 0x0006, 0x0016, 0x6004,
-	0x908e, 0x0034, 0x01b8, 0x908e, 0x0035, 0x01a0, 0x908e, 0x0036,
-	0x0188, 0x908e, 0x0037, 0x0170, 0x908e, 0x0038, 0x0158, 0x908e,
-	0x0039, 0x0140, 0x908e, 0x003a, 0x0128, 0x908e, 0x003b, 0x0110,
-	0x9085, 0x0001, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x0026,
-	0x0036, 0x00e6, 0x2001, 0x1981, 0x200c, 0x8000, 0x2014, 0x2001,
-	0x0032, 0x080c, 0x9148, 0x2001, 0x1985, 0x82ff, 0x1110, 0x2011,
-	0x0014, 0x2202, 0x2001, 0x1983, 0x200c, 0x8000, 0x2014, 0x2071,
-	0x196b, 0x711a, 0x721e, 0x2001, 0x0064, 0x080c, 0x9148, 0x2001,
-	0x1986, 0x82ff, 0x1110, 0x2011, 0x0014, 0x2202, 0x2001, 0x1987,
-	0x9288, 0x000a, 0x2102, 0x2001, 0x0017, 0x080c, 0xa879, 0x2001,
-	0x1a88, 0x2102, 0x2001, 0x0032, 0x080c, 0x1686, 0x080c, 0x6a4b,
-	0x00ee, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016,
-	0x00e6, 0x2001, 0x1985, 0x2003, 0x0028, 0x2001, 0x1986, 0x2003,
-	0x0014, 0x2071, 0x196b, 0x701b, 0x0000, 0x701f, 0x07d0, 0x2001,
-	0x1987, 0x2009, 0x001e, 0x2102, 0x2001, 0x0017, 0x080c, 0xa879,
-	0x2001, 0x1a88, 0x2102, 0x2001, 0x0032, 0x080c, 0x1686, 0x00ee,
-	0x001e, 0x000e, 0x0005, 0x0096, 0x6060, 0x904d, 0x0110, 0x080c,
-	0x106c, 0x009e, 0x0005, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0xab89, 0x0180, 0x2b08, 0x6112, 0x0ca9, 0x6023, 0x0001,
-	0x2900, 0x6016, 0x2009, 0x0033, 0x080c, 0xac7c, 0x9085, 0x0001,
-	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x0096, 0x00e6, 0x00f6,
-	0x2071, 0x1800, 0x9186, 0x0015, 0x1500, 0x7090, 0x9086, 0x0018,
-	0x11e0, 0x6014, 0x2048, 0xaa3c, 0xd2e4, 0x1160, 0x2c78, 0x080c,
-	0x9743, 0x01d8, 0x707c, 0xaa50, 0x9206, 0x1160, 0x7080, 0xaa54,
-	0x9206, 0x1140, 0x6210, 0x00b6, 0x2258, 0xbaa0, 0x00be, 0x900e,
-	0x080c, 0x323e, 0x080c, 0xafee, 0x0020, 0x080c, 0xb5a6, 0x080c,
-	0xabdf, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x7060, 0xaa54, 0x9206,
-	0x0d48, 0x0c80, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xab89,
-	0x0188, 0x2b08, 0x6112, 0x080c, 0xcccb, 0x6023, 0x0001, 0x2900,
-	0x6016, 0x2009, 0x004d, 0x080c, 0xac7c, 0x9085, 0x0001, 0x012e,
-	0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x0016, 0x080c, 0xab89, 0x0180, 0x2b08, 0x6112, 0x080c, 0xcccb,
-	0x6023, 0x0001, 0x2900, 0x6016, 0x001e, 0x080c, 0xac7c, 0x9085,
-	0x0001, 0x012e, 0x00ce, 0x0005, 0x001e, 0x9006, 0x0cd0, 0x0016,
-	0x0026, 0x0036, 0x0046, 0x0056, 0x0066, 0x0096, 0x00e6, 0x00f6,
-	0x2071, 0x1800, 0x9186, 0x0015, 0x1568, 0x7190, 0x6014, 0x2048,
-	0xa814, 0x8003, 0x9106, 0x1530, 0x20e1, 0x0000, 0x2001, 0x199f,
-	0x2003, 0x0000, 0x6014, 0x2048, 0xa830, 0x20a8, 0x8906, 0x8006,
-	0x8007, 0x9094, 0x003f, 0x22e8, 0x9084, 0xffc0, 0x9080, 0x001b,
-	0x20a0, 0x2001, 0x199f, 0x0016, 0x200c, 0x080c, 0xd572, 0x001e,
-	0xa804, 0x9005, 0x0110, 0x2048, 0x0c38, 0x6014, 0x2048, 0xa867,
-	0x0103, 0x0010, 0x080c, 0xb5a6, 0x080c, 0xabdf, 0x00fe, 0x00ee,
-	0x009e, 0x006e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005,
-	0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x11b8,
-	0x7090, 0x9086, 0x0004, 0x1198, 0x6014, 0x2048, 0x2c78, 0x080c,
-	0x9743, 0x01a8, 0x707c, 0xaa74, 0x9206, 0x1130, 0x7080, 0xaa78,
-	0x9206, 0x1110, 0x080c, 0x31ef, 0x080c, 0xafee, 0x0020, 0x080c,
-	0xb5a6, 0x080c, 0xabdf, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x7060,
-	0xaa78, 0x9206, 0x0d78, 0x0c80, 0x0096, 0x00e6, 0x00f6, 0x2071,
-	0x1800, 0x9186, 0x0015, 0x1550, 0x7090, 0x9086, 0x0004, 0x1530,
-	0x6014, 0x2048, 0x2c78, 0x080c, 0x9743, 0x05f0, 0x707c, 0xaacc,
-	0x9206, 0x1180, 0x7080, 0xaad0, 0x9206, 0x1160, 0x080c, 0x31ef,
-	0x0016, 0xa998, 0xaab0, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x568d,
-	0x001e, 0x0010, 0x080c, 0x5476, 0x080c, 0xc832, 0x0508, 0xa87b,
-	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x0080, 0x080c, 0xc832,
-	0x01b8, 0x6014, 0x2048, 0x080c, 0x5476, 0x1d70, 0xa87b, 0x0030,
-	0xa883, 0x0000, 0xa897, 0x4005, 0xa89b, 0x0004, 0x0126, 0x2091,
-	0x8000, 0xa867, 0x0139, 0x080c, 0x6d7b, 0x012e, 0x080c, 0xabdf,
-	0x00fe, 0x00ee, 0x009e, 0x0005, 0x7060, 0xaad0, 0x9206, 0x0930,
-	0x0888, 0x0016, 0x0026, 0xa87c, 0xd0ac, 0x0178, 0xa938, 0xaa34,
-	0x2100, 0x9205, 0x0150, 0xa890, 0x9106, 0x1118, 0xa88c, 0x9206,
-	0x0120, 0xa992, 0xaa8e, 0x9085, 0x0001, 0x002e, 0x001e, 0x0005,
-	0x00b6, 0x00d6, 0x0036, 0x080c, 0xc832, 0x0904, 0xce86, 0x0096,
-	0x6314, 0x2348, 0xa87a, 0xa982, 0x929e, 0x4000, 0x1580, 0x6310,
-	0x00c6, 0x2358, 0x2009, 0x0000, 0xa868, 0xd0f4, 0x1140, 0x080c,
-	0x6913, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0xaa96,
-	0xa99a, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031,
-	0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080, 0x0006, 0x2098, 0x080c,
-	0x0fb7, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x0035, 0x20a0, 0xb8c8,
-	0x9080, 0x000a, 0x2098, 0x080c, 0x0fb7, 0x00ce, 0x0090, 0xaa96,
-	0x3918, 0x9398, 0x0007, 0x231c, 0x6004, 0x9086, 0x0016, 0x0110,
-	0xa89b, 0x0004, 0xaba2, 0x6310, 0x2358, 0xb804, 0x9084, 0x00ff,
-	0xa89e, 0x080c, 0x6d6f, 0x6017, 0x0000, 0x009e, 0x003e, 0x00de,
-	0x00be, 0x0005, 0x0026, 0x0036, 0x0046, 0x00b6, 0x0096, 0x00f6,
-	0x6214, 0x2248, 0x6210, 0x2258, 0x2079, 0x0260, 0x9096, 0x0000,
-	0x11a0, 0xb814, 0x9084, 0x00ff, 0x900e, 0x080c, 0x2614, 0x2118,
-	0x831f, 0x939c, 0xff00, 0x7838, 0x9084, 0x00ff, 0x931d, 0x7c3c,
-	0x2011, 0x8018, 0x080c, 0x4b09, 0x00a8, 0x9096, 0x0001, 0x1148,
-	0x89ff, 0x0180, 0xa89b, 0x000d, 0x7838, 0xa8a6, 0x783c, 0xa8aa,
-	0x0048, 0x9096, 0x0002, 0x1130, 0xa89b, 0x000d, 0x7838, 0xa8a6,
-	0x783c, 0xa8aa, 0x00fe, 0x009e, 0x00be, 0x004e, 0x003e, 0x002e,
-	0x0005, 0x00c6, 0x0026, 0x0016, 0x9186, 0x0035, 0x0110, 0x6a38,
-	0x0008, 0x6a2c, 0x080c, 0xc820, 0x01f0, 0x2260, 0x6120, 0x9186,
-	0x0003, 0x0118, 0x9186, 0x0006, 0x1190, 0x6838, 0x9206, 0x0140,
-	0x683c, 0x9206, 0x1160, 0x6108, 0x6838, 0x9106, 0x1140, 0x0020,
-	0x6008, 0x693c, 0x9106, 0x1118, 0x6010, 0x6910, 0x9106, 0x001e,
-	0x002e, 0x00ce, 0x0005, 0x9085, 0x0001, 0x0cc8, 0xa974, 0xd1cc,
-	0x0188, 0x918c, 0x00ff, 0x918e, 0x0002, 0x1160, 0xa9a8, 0x918c,
-	0x0f00, 0x810f, 0x918e, 0x0001, 0x1128, 0xa834, 0xa938, 0x9115,
-	0x190c, 0xbea6, 0x0005, 0x0036, 0x2019, 0x0001, 0x0010, 0x0036,
-	0x901e, 0x0499, 0x01e0, 0x080c, 0xc832, 0x01c8, 0x080c, 0xca21,
-	0x6037, 0x4000, 0x6014, 0x6017, 0x0000, 0x0096, 0x2048, 0xa87c,
-	0x080c, 0xca47, 0x1118, 0x080c, 0xb5a6, 0x0040, 0xa867, 0x0103,
-	0xa877, 0x0000, 0x83ff, 0x1129, 0x080c, 0x6d7b, 0x009e, 0x003e,
-	0x0005, 0xa880, 0xd0b4, 0x0128, 0xa87b, 0x0006, 0xc0ec, 0xa882,
-	0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002, 0x0020, 0xa87b, 0x0005,
-	0x080c, 0xcb3b, 0xa877, 0x0000, 0x0005, 0x2001, 0x1810, 0x2004,
-	0xd0ec, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0f4, 0x000e,
-	0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0e4, 0x000e, 0x0005,
-	0x0036, 0x0046, 0x6010, 0x00b6, 0x2058, 0xbba0, 0x00be, 0x2021,
-	0x0007, 0x080c, 0x4cc0, 0x004e, 0x003e, 0x0005, 0x0c51, 0x1d81,
-	0x0005, 0x2001, 0x1985, 0x2004, 0x601a, 0x0005, 0x2001, 0x1987,
-	0x2004, 0x604a, 0x0005, 0x080c, 0xabdf, 0x0804, 0x9684, 0x611c,
-	0xd1fc, 0xa97c, 0x1108, 0xd1e4, 0x0005, 0x601c, 0xd0fc, 0xa87c,
-	0x1108, 0xd0e4, 0x0005, 0x601c, 0xd0fc, 0xc0fc, 0x601e, 0xa87c,
-	0x1108, 0xd0e4, 0x0005, 0x6044, 0xd0fc, 0x1138, 0xd0bc, 0x0198,
-	0xc0bc, 0x6046, 0x6003, 0x0002, 0x0070, 0xd0ac, 0x1160, 0xd0dc,
-	0x1128, 0x908c, 0x000f, 0x9186, 0x0005, 0x1118, 0x6003, 0x0003,
-	0x0010, 0x6003, 0x0001, 0x0005, 0x00b6, 0x0066, 0x6000, 0x90b2,
-	0x0016, 0x1a0c, 0x0d7d, 0x001b, 0x006e, 0x00be, 0x0005, 0xcfbf,
-	0xd6cd, 0xd81e, 0xcfbf, 0xcfbf, 0xcfbf, 0xcfbf, 0xcfbf, 0xcff6,
-	0xd8a2, 0xcfbf, 0xcfbf, 0xcfbf, 0xcfbf, 0xcfbf, 0xcfbf, 0x080c,
-	0x0d7d, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0d7d, 0x0013,
-	0x006e, 0x0005, 0xcfda, 0xddb9, 0xcfda, 0xcfda, 0xcfda, 0xcfda,
-	0xcfda, 0xcfda, 0xdd68, 0xde0b, 0xcfda, 0xe463, 0xe497, 0xe463,
-	0xe497, 0xcfda, 0x080c, 0x0d7d, 0x6000, 0x9082, 0x0016, 0x1a0c,
-	0x0d7d, 0x6000, 0x000a, 0x0005, 0xcff4, 0xda7e, 0xdb47, 0xdb69,
-	0xdbe4, 0xcff4, 0xdcde, 0xdc6c, 0xd8ac, 0xdd40, 0xdd55, 0xcff4,
-	0xcff4, 0xcff4, 0xcff4, 0xcff4, 0x080c, 0x0d7d, 0x91b2, 0x0053,
-	0x1a0c, 0x0d7d, 0x2100, 0x91b2, 0x0040, 0x1a04, 0xd443, 0x0002,
-	0xd040, 0xd234, 0xd040, 0xd040, 0xd040, 0xd23d, 0xd040, 0xd040,
-	0xd040, 0xd040, 0xd040, 0xd040, 0xd040, 0xd040, 0xd040, 0xd040,
-	0xd040, 0xd040, 0xd040, 0xd040, 0xd040, 0xd040, 0xd040, 0xd042,
-	0xd0a9, 0xd0b8, 0xd11c, 0xd147, 0xd1c0, 0xd21f, 0xd040, 0xd040,
-	0xd240, 0xd040, 0xd040, 0xd255, 0xd262, 0xd040, 0xd040, 0xd040,
-	0xd040, 0xd040, 0xd2e5, 0xd040, 0xd040, 0xd2f9, 0xd040, 0xd040,
-	0xd2b4, 0xd040, 0xd040, 0xd040, 0xd311, 0xd040, 0xd040, 0xd040,
-	0xd38e, 0xd040, 0xd040, 0xd040, 0xd040, 0xd040, 0xd040, 0xd40b,
-	0x080c, 0x0d7d, 0x080c, 0x6a28, 0x1150, 0x2001, 0x1837, 0x2004,
-	0xd0cc, 0x1128, 0x9084, 0x0009, 0x9086, 0x0008, 0x1140, 0x6007,
-	0x0009, 0x602f, 0x0009, 0x6017, 0x0000, 0x0804, 0xd22d, 0x080c,
-	0x69c4, 0x00e6, 0x00c6, 0x0036, 0x0026, 0x0016, 0x6210, 0x2258,
-	0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c, 0xa888, 0x080c, 0x938d,
-	0x0076, 0x903e, 0x080c, 0x9256, 0x2c08, 0x080c, 0xdffb, 0x007e,
-	0x001e, 0x080c, 0xa8a4, 0x001e, 0x002e, 0x003e, 0x00ce, 0x00ee,
-	0x6610, 0x2658, 0x080c, 0x662f, 0xbe04, 0x9684, 0x00ff, 0x9082,
-	0x0006, 0x1268, 0x0016, 0x0026, 0x6210, 0x00b6, 0x2258, 0xbaa0,
-	0x00be, 0x2c08, 0x080c, 0xe6c0, 0x002e, 0x001e, 0x1178, 0x080c,
-	0xdf29, 0x1904, 0xd114, 0x080c, 0xdec5, 0x1120, 0x6007, 0x0008,
-	0x0804, 0xd22d, 0x6007, 0x0009, 0x0804, 0xd22d, 0x080c, 0xe15c,
-	0x0128, 0x080c, 0xdf29, 0x0d78, 0x0804, 0xd114, 0x6017, 0x1900,
-	0x0c88, 0x080c, 0x3326, 0x1904, 0xd440, 0x6106, 0x080c, 0xde76,
-	0x6007, 0x0006, 0x0804, 0xd22d, 0x6007, 0x0007, 0x0804, 0xd22d,
-	0x080c, 0xe4d3, 0x1904, 0xd440, 0x080c, 0x3326, 0x1904, 0xd440,
-	0x00d6, 0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006,
-	0x1220, 0x2001, 0x0001, 0x080c, 0x655c, 0x96b4, 0xff00, 0x8637,
-	0x9686, 0x0006, 0x0188, 0x9686, 0x0004, 0x0170, 0xbe04, 0x96b4,
-	0x00ff, 0x9686, 0x0006, 0x0140, 0x9686, 0x0004, 0x0128, 0x9686,
-	0x0005, 0x0110, 0x00de, 0x0480, 0x00e6, 0x2071, 0x0260, 0x7034,
-	0x9084, 0x0003, 0x1140, 0x7034, 0x9082, 0x0014, 0x0220, 0x7030,
-	0x9084, 0x0003, 0x0130, 0x00ee, 0x6017, 0x0000, 0x602f, 0x0007,
-	0x00b0, 0x00ee, 0x080c, 0xdf91, 0x1190, 0x9686, 0x0006, 0x1140,
-	0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x323e, 0x002e,
-	0x080c, 0x66bb, 0x6007, 0x000a, 0x00de, 0x0804, 0xd22d, 0x6007,
-	0x000b, 0x00de, 0x0804, 0xd22d, 0x080c, 0x31ef, 0x080c, 0xcf66,
-	0x6007, 0x0001, 0x0804, 0xd22d, 0x080c, 0xe4d3, 0x1904, 0xd440,
-	0x080c, 0x3326, 0x1904, 0xd440, 0x2071, 0x0260, 0x7034, 0x90b4,
-	0x0003, 0x1948, 0x90b2, 0x0014, 0x0a30, 0x7030, 0x9084, 0x0003,
-	0x1910, 0x6610, 0x2658, 0xbe04, 0x9686, 0x0707, 0x09e8, 0x0026,
-	0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x323e, 0x002e, 0x6007,
-	0x000c, 0x2001, 0x0001, 0x080c, 0xe6a0, 0x0804, 0xd22d, 0x080c,
-	0x6a28, 0x1140, 0x2001, 0x1837, 0x2004, 0x9084, 0x0009, 0x9086,
-	0x0008, 0x1110, 0x0804, 0xd04f, 0x080c, 0x69c4, 0x6610, 0x2658,
-	0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006, 0x06c8, 0x1138, 0x0026,
-	0x2001, 0x0006, 0x080c, 0x659c, 0x002e, 0x0050, 0x96b4, 0xff00,
-	0x8637, 0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xd114,
-	0x080c, 0xdf9e, 0x1120, 0x6007, 0x000e, 0x0804, 0xd22d, 0x0046,
-	0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x31ef, 0x080c, 0xcf66,
-	0x004e, 0x0016, 0x9006, 0x2009, 0x1848, 0x210c, 0xd1a4, 0x0148,
-	0x2009, 0x0029, 0x080c, 0xe2d9, 0x6010, 0x2058, 0xb800, 0xc0e5,
-	0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x0804, 0xd22d, 0x2001,
-	0x0001, 0x080c, 0x655c, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9,
-	0x0004, 0x2019, 0x1805, 0x2011, 0x0270, 0x080c, 0xbba1, 0x003e,
-	0x002e, 0x001e, 0x015e, 0x9005, 0x0168, 0x96b4, 0xff00, 0x8637,
-	0x9682, 0x0004, 0x0a04, 0xd114, 0x9682, 0x0007, 0x0a04, 0xd170,
-	0x0804, 0xd114, 0x6017, 0x1900, 0x6007, 0x0009, 0x0804, 0xd22d,
-	0x080c, 0x6a28, 0x1140, 0x2001, 0x1837, 0x2004, 0x9084, 0x0009,
-	0x9086, 0x0008, 0x1110, 0x0804, 0xd04f, 0x080c, 0x69c4, 0x6610,
-	0x2658, 0xbe04, 0x9684, 0x00ff, 0x0006, 0x9086, 0x0001, 0x000e,
-	0x0170, 0x9082, 0x0006, 0x0698, 0x0150, 0x96b4, 0xff00, 0x8637,
-	0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xd114, 0x080c,
-	0xdfcc, 0x1130, 0x080c, 0xdec5, 0x1118, 0x6007, 0x0010, 0x04e8,
-	0x0046, 0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x31ef, 0x080c,
-	0xcf66, 0x004e, 0x0016, 0x9006, 0x2009, 0x1848, 0x210c, 0xd1a4,
-	0x0148, 0x2009, 0x0029, 0x080c, 0xe2d9, 0x6010, 0x2058, 0xb800,
-	0xc0e5, 0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x00f0, 0x080c,
-	0xe15c, 0x0140, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0978,
-	0x0804, 0xd114, 0x6017, 0x1900, 0x6007, 0x0009, 0x0070, 0x080c,
-	0x3326, 0x1904, 0xd440, 0x080c, 0xe4d3, 0x1904, 0xd440, 0x080c,
-	0xd60d, 0x1904, 0xd114, 0x6007, 0x0012, 0x6003, 0x0001, 0x080c,
-	0x9207, 0x080c, 0x9684, 0x0005, 0x6007, 0x0001, 0x6003, 0x0001,
-	0x080c, 0x9207, 0x080c, 0x9684, 0x0cb0, 0x6007, 0x0005, 0x0c68,
-	0x080c, 0xe4d3, 0x1904, 0xd440, 0x080c, 0x3326, 0x1904, 0xd440,
-	0x080c, 0xd60d, 0x1904, 0xd114, 0x6007, 0x0020, 0x6003, 0x0001,
-	0x080c, 0x9207, 0x080c, 0x9684, 0x0005, 0x080c, 0x3326, 0x1904,
-	0xd440, 0x6007, 0x0023, 0x6003, 0x0001, 0x080c, 0x9207, 0x080c,
-	0x9684, 0x0005, 0x080c, 0xe4d3, 0x1904, 0xd440, 0x080c, 0x3326,
-	0x1904, 0xd440, 0x080c, 0xd60d, 0x1904, 0xd114, 0x0016, 0x0026,
-	0x00e6, 0x2071, 0x0260, 0x7244, 0x9286, 0xffff, 0x0180, 0x2c08,
-	0x080c, 0xc820, 0x01b0, 0x2260, 0x7240, 0x6008, 0x9206, 0x1188,
-	0x6010, 0x9190, 0x0004, 0x2214, 0x9206, 0x01b8, 0x0050, 0x7240,
-	0x2c08, 0x9006, 0x080c, 0xe2a3, 0x1180, 0x7244, 0x9286, 0xffff,
-	0x01b0, 0x2160, 0x6007, 0x0026, 0x6017, 0x1700, 0x7214, 0x9296,
-	0xffff, 0x1180, 0x6007, 0x0025, 0x0068, 0x6020, 0x9086, 0x0007,
-	0x1d80, 0x6004, 0x9086, 0x0024, 0x1110, 0x080c, 0xabdf, 0x2160,
-	0x6007, 0x0025, 0x6003, 0x0001, 0x080c, 0x9207, 0x080c, 0x9684,
-	0x00ee, 0x002e, 0x001e, 0x0005, 0x2001, 0x0001, 0x080c, 0x655c,
-	0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805,
-	0x2011, 0x0276, 0x080c, 0xbba1, 0x003e, 0x002e, 0x001e, 0x015e,
-	0x0120, 0x6007, 0x0031, 0x0804, 0xd22d, 0x080c, 0xb812, 0x080c,
-	0x74c8, 0x1190, 0x0006, 0x0026, 0x0036, 0x080c, 0x74e2, 0x1138,
-	0x080c, 0x77cc, 0x080c, 0x6024, 0x080c, 0x73f9, 0x0010, 0x080c,
-	0x749c, 0x003e, 0x002e, 0x000e, 0x0005, 0x080c, 0x3326, 0x1904,
-	0xd440, 0x080c, 0xd60d, 0x1904, 0xd114, 0x6106, 0x080c, 0xd629,
-	0x1120, 0x6007, 0x002b, 0x0804, 0xd22d, 0x6007, 0x002c, 0x0804,
-	0xd22d, 0x080c, 0xe4d3, 0x1904, 0xd440, 0x080c, 0x3326, 0x1904,
-	0xd440, 0x080c, 0xd60d, 0x1904, 0xd114, 0x6106, 0x080c, 0xd62e,
-	0x1120, 0x6007, 0x002e, 0x0804, 0xd22d, 0x6007, 0x002f, 0x0804,
-	0xd22d, 0x080c, 0x3326, 0x1904, 0xd440, 0x00e6, 0x00d6, 0x00c6,
-	0x6010, 0x2058, 0xb904, 0x9184, 0x00ff, 0x9086, 0x0006, 0x0158,
-	0x9184, 0xff00, 0x8007, 0x9086, 0x0006, 0x0128, 0x00ce, 0x00de,
-	0x00ee, 0x0804, 0xd234, 0x080c, 0x56d9, 0xd0e4, 0x0904, 0xd38b,
-	0x2071, 0x026c, 0x7010, 0x603a, 0x7014, 0x603e, 0x7108, 0x720c,
-	0x080c, 0x6a66, 0x0140, 0x6010, 0x2058, 0xb810, 0x9106, 0x1118,
-	0xb814, 0x9206, 0x0510, 0x080c, 0x6a62, 0x15b8, 0x2069, 0x1800,
-	0x6880, 0x9206, 0x1590, 0x687c, 0x9106, 0x1578, 0x7210, 0x080c,
-	0xc820, 0x0590, 0x080c, 0xd4f8, 0x0578, 0x080c, 0xe355, 0x0560,
-	0x622e, 0x6007, 0x0036, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c,
-	0x9200, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x7214, 0x9286, 0xffff,
-	0x0150, 0x080c, 0xc820, 0x01c0, 0x9280, 0x0002, 0x2004, 0x7110,
-	0x9106, 0x1190, 0x08e0, 0x7210, 0x2c08, 0x9085, 0x0001, 0x080c,
-	0xe2a3, 0x2c10, 0x2160, 0x0140, 0x0890, 0x6007, 0x0037, 0x602f,
-	0x0009, 0x6017, 0x1500, 0x08b8, 0x6007, 0x0037, 0x602f, 0x0003,
-	0x6017, 0x1700, 0x0880, 0x6007, 0x0012, 0x0868, 0x080c, 0x3326,
-	0x1904, 0xd440, 0x6010, 0x2058, 0xb804, 0x9084, 0xff00, 0x8007,
-	0x9086, 0x0006, 0x1904, 0xd234, 0x00e6, 0x00d6, 0x00c6, 0x080c,
-	0x56d9, 0xd0e4, 0x0904, 0xd403, 0x2069, 0x1800, 0x2071, 0x026c,
-	0x7008, 0x603a, 0x720c, 0x623e, 0x9286, 0xffff, 0x1150, 0x7208,
-	0x00c6, 0x2c08, 0x9085, 0x0001, 0x080c, 0xe2a3, 0x2c10, 0x00ce,
-	0x05e8, 0x080c, 0xc820, 0x05d0, 0x7108, 0x9280, 0x0002, 0x2004,
-	0x9106, 0x15a0, 0x00c6, 0x0026, 0x2260, 0x080c, 0xc423, 0x002e,
-	0x00ce, 0x7118, 0x918c, 0xff00, 0x810f, 0x9186, 0x0001, 0x0178,
-	0x9186, 0x0005, 0x0118, 0x9186, 0x0007, 0x1198, 0x9280, 0x0005,
-	0x2004, 0x9005, 0x0170, 0x080c, 0xd4f8, 0x0904, 0xd384, 0x0056,
-	0x7510, 0x7614, 0x080c, 0xe36e, 0x005e, 0x00ce, 0x00de, 0x00ee,
-	0x0005, 0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00, 0x6003,
-	0x0001, 0x2009, 0x8020, 0x080c, 0x9200, 0x0c78, 0x6007, 0x003b,
-	0x602f, 0x0003, 0x6017, 0x0300, 0x6003, 0x0001, 0x2009, 0x8020,
-	0x080c, 0x9200, 0x0c10, 0x6007, 0x003b, 0x602f, 0x000b, 0x6017,
-	0x0000, 0x0804, 0xd35b, 0x00e6, 0x0026, 0x080c, 0x6a28, 0x0550,
-	0x080c, 0x69c4, 0x080c, 0xe545, 0x1518, 0x2071, 0x1800, 0x70dc,
-	0x9085, 0x0003, 0x70de, 0x00f6, 0x2079, 0x0100, 0x72b0, 0x9284,
-	0x00ff, 0x707e, 0x78e6, 0x9284, 0xff00, 0x7280, 0x9205, 0x7082,
-	0x78ea, 0x00fe, 0x70e7, 0x0000, 0x080c, 0x6a66, 0x0120, 0x2011,
-	0x1a08, 0x2013, 0x07d0, 0xd0ac, 0x1128, 0x080c, 0x2fc0, 0x0010,
-	0x080c, 0xe577, 0x002e, 0x00ee, 0x080c, 0xabdf, 0x0804, 0xd233,
-	0x080c, 0xabdf, 0x0005, 0x2600, 0x0002, 0xd457, 0xd488, 0xd499,
-	0xd457, 0xd457, 0xd459, 0xd4aa, 0xd457, 0xd457, 0xd457, 0xd476,
-	0xd457, 0xd457, 0xd457, 0xd4b5, 0xd4c2, 0xd4f3, 0xd457, 0x080c,
-	0x0d7d, 0x080c, 0xe4d3, 0x1d20, 0x080c, 0x3326, 0x1d08, 0x080c,
-	0xd60d, 0x1148, 0x7038, 0x6016, 0x6007, 0x0045, 0x6003, 0x0001,
-	0x080c, 0x9207, 0x0005, 0x080c, 0x31ef, 0x080c, 0xcf66, 0x6007,
-	0x0001, 0x6003, 0x0001, 0x080c, 0x9207, 0x0005, 0x080c, 0xe4d3,
-	0x1938, 0x080c, 0x3326, 0x1920, 0x080c, 0xd60d, 0x1d60, 0x703c,
-	0x6016, 0x6007, 0x004a, 0x6003, 0x0001, 0x080c, 0x9207, 0x0005,
-	0x080c, 0x3326, 0x1904, 0xd440, 0x2009, 0x0041, 0x080c, 0xe580,
-	0x6007, 0x0047, 0x6003, 0x0001, 0x080c, 0x9207, 0x080c, 0x9684,
-	0x0005, 0x080c, 0x3326, 0x1904, 0xd440, 0x2009, 0x0042, 0x080c,
-	0xe580, 0x6007, 0x0047, 0x6003, 0x0001, 0x080c, 0x9207, 0x080c,
-	0x9684, 0x0005, 0x080c, 0x3326, 0x1904, 0xd440, 0x2009, 0x0046,
-	0x080c, 0xe580, 0x080c, 0xabdf, 0x0005, 0x080c, 0xd515, 0x0904,
-	0xd440, 0x6007, 0x004e, 0x6003, 0x0001, 0x080c, 0x9207, 0x080c,
-	0x9684, 0x0005, 0x6007, 0x004f, 0x6017, 0x0000, 0x7134, 0x918c,
-	0x00ff, 0x81ff, 0x0508, 0x9186, 0x0001, 0x1160, 0x7140, 0x2001,
-	0x19bc, 0x2004, 0x9106, 0x11b0, 0x7144, 0x2001, 0x19bd, 0x2004,
-	0x9106, 0x0190, 0x9186, 0x0002, 0x1168, 0x2011, 0x0276, 0x20a9,
-	0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xbbb5,
-	0x009e, 0x0110, 0x6017, 0x0001, 0x6003, 0x0001, 0x080c, 0x9207,
-	0x080c, 0x9684, 0x0005, 0x6007, 0x0050, 0x703c, 0x6016, 0x0ca0,
-	0x0016, 0x00e6, 0x2071, 0x0260, 0x00b6, 0x00c6, 0x2260, 0x6010,
-	0x2058, 0xb8d4, 0xd084, 0x0150, 0x7128, 0x6050, 0x9106, 0x1120,
-	0x712c, 0x604c, 0x9106, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x00ce, 0x00be, 0x00ee, 0x001e, 0x0005, 0x0016, 0x0096, 0x0086,
-	0x00e6, 0x01c6, 0x01d6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800,
-	0x7090, 0x908a, 0x00f9, 0x16e8, 0x20e1, 0x0000, 0x2001, 0x199f,
-	0x2003, 0x0000, 0x080c, 0x1053, 0x05a0, 0x2900, 0x6016, 0x7090,
-	0x8004, 0xa816, 0x908a, 0x001e, 0x02d0, 0xa833, 0x001e, 0x20a9,
-	0x001e, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0, 0x2001,
-	0x199f, 0x0016, 0x200c, 0x0471, 0x001e, 0x2940, 0x080c, 0x1053,
-	0x01c0, 0x2900, 0xa006, 0x2100, 0x81ff, 0x0180, 0x0c18, 0xa832,
-	0x20a8, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0, 0x2001,
-	0x199f, 0x0016, 0x200c, 0x00b1, 0x001e, 0x0000, 0x9085, 0x0001,
-	0x0048, 0x2071, 0x1800, 0x7093, 0x0000, 0x6014, 0x2048, 0x080c,
-	0x0fec, 0x9006, 0x012e, 0x01de, 0x01ce, 0x00ee, 0x008e, 0x009e,
-	0x001e, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00c6, 0x918c,
-	0xffff, 0x11a8, 0x080c, 0x219a, 0x2099, 0x026c, 0x2001, 0x0014,
-	0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x00f8, 0x20a8, 0x4003,
-	0x22a8, 0x8108, 0x080c, 0x219a, 0x2099, 0x0260, 0x0ca8, 0x080c,
-	0x219a, 0x2061, 0x199f, 0x6004, 0x2098, 0x6008, 0x3518, 0x9312,
-	0x1218, 0x23a8, 0x4003, 0x0048, 0x20a8, 0x4003, 0x22a8, 0x8108,
-	0x080c, 0x219a, 0x2099, 0x0260, 0x0ca8, 0x2061, 0x199f, 0x2019,
-	0x0280, 0x3300, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0260,
-	0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a,
-	0x00ce, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016,
-	0x0026, 0x0036, 0x00c6, 0x81ff, 0x11b8, 0x080c, 0x21b2, 0x20a1,
-	0x024c, 0x2001, 0x0014, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003,
-	0x0418, 0x20a8, 0x4003, 0x82ff, 0x01f8, 0x22a8, 0x8108, 0x080c,
-	0x21b2, 0x20a1, 0x0240, 0x0c98, 0x080c, 0x21b2, 0x2061, 0x19a2,
-	0x6004, 0x20a0, 0x6008, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003,
-	0x0058, 0x20a8, 0x4003, 0x82ff, 0x0138, 0x22a8, 0x8108, 0x080c,
-	0x21b2, 0x20a1, 0x0240, 0x0c98, 0x2061, 0x19a2, 0x2019, 0x0260,
-	0x3400, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0240, 0x6006,
-	0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a, 0x00ce,
-	0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x00b6, 0x0066, 0x6610,
-	0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0170,
-	0x9686, 0x0004, 0x0158, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006,
-	0x0128, 0x9686, 0x0004, 0x0110, 0x9085, 0x0001, 0x006e, 0x00be,
-	0x0005, 0x00d6, 0x080c, 0xd6a3, 0x00de, 0x0005, 0x00d6, 0x080c,
-	0xd6b0, 0x1520, 0x680c, 0x908c, 0xff00, 0x6820, 0x9084, 0x00ff,
-	0x9115, 0x6216, 0x6824, 0x602e, 0xd1e4, 0x0130, 0x9006, 0x080c,
-	0xe6a0, 0x2009, 0x0001, 0x0078, 0xd1ec, 0x0180, 0x6920, 0x918c,
-	0x00ff, 0x6824, 0x080c, 0x2614, 0x1148, 0x2001, 0x0001, 0x080c,
-	0xe6a0, 0x2110, 0x900e, 0x080c, 0x323e, 0x0018, 0x9085, 0x0001,
-	0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00c6, 0x080c, 0xac4f,
-	0x0598, 0x0016, 0x0026, 0x00c6, 0x2011, 0x0263, 0x2204, 0x8211,
-	0x220c, 0x080c, 0x2614, 0x1568, 0x080c, 0x65bf, 0x1550, 0xbe12,
-	0xbd16, 0x00ce, 0x002e, 0x001e, 0x2b00, 0x6012, 0x080c, 0xe4d3,
-	0x11c8, 0x080c, 0x3326, 0x11b0, 0x080c, 0xd60d, 0x0500, 0x2001,
-	0x0007, 0x080c, 0x6570, 0x2001, 0x0007, 0x080c, 0x659c, 0x6017,
-	0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
-	0x9207, 0x0010, 0x080c, 0xabdf, 0x9085, 0x0001, 0x00ce, 0x00be,
-	0x0005, 0x080c, 0xabdf, 0x00ce, 0x002e, 0x001e, 0x0ca8, 0x080c,
-	0xabdf, 0x9006, 0x0c98, 0x2069, 0x026d, 0x6800, 0x9082, 0x0010,
-	0x1228, 0x6017, 0x0000, 0x9085, 0x0001, 0x0008, 0x9006, 0x0005,
-	0x6017, 0x0000, 0x2069, 0x026c, 0x6808, 0x9084, 0xff00, 0x9086,
-	0x0800, 0x1190, 0x6904, 0x9186, 0x0018, 0x0118, 0x9186, 0x0014,
-	0x1158, 0x810f, 0x6800, 0x9084, 0x00ff, 0x910d, 0x6162, 0x908e,
-	0x0014, 0x0110, 0x908e, 0x0010, 0x0005, 0x6004, 0x90b2, 0x0053,
-	0x1a0c, 0x0d7d, 0x91b6, 0x0013, 0x1130, 0x2008, 0x91b2, 0x0040,
-	0x1a04, 0xd7f2, 0x0092, 0x91b6, 0x0027, 0x0120, 0x91b6, 0x0014,
-	0x190c, 0x0d7d, 0x2001, 0x0007, 0x080c, 0x659c, 0x080c, 0x95c6,
-	0x080c, 0xac1a, 0x080c, 0x9684, 0x0005, 0xd72d, 0xd72f, 0xd72d,
-	0xd72d, 0xd72d, 0xd72f, 0xd73c, 0xd7ef, 0xd78c, 0xd7ef, 0xd7a0,
-	0xd7ef, 0xd73c, 0xd7ef, 0xd7e7, 0xd7ef, 0xd7e7, 0xd7ef, 0xd7ef,
-	0xd72d, 0xd72d, 0xd72d, 0xd72d, 0xd72d, 0xd72d, 0xd72d, 0xd72d,
-	0xd72d, 0xd72d, 0xd72d, 0xd72f, 0xd72d, 0xd7ef, 0xd72d, 0xd72d,
-	0xd7ef, 0xd72d, 0xd7ec, 0xd7ef, 0xd72d, 0xd72d, 0xd72d, 0xd72d,
-	0xd7ef, 0xd7ef, 0xd72d, 0xd7ef, 0xd7ef, 0xd72d, 0xd737, 0xd72d,
-	0xd72d, 0xd72d, 0xd72d, 0xd7eb, 0xd7ef, 0xd72d, 0xd72d, 0xd7ef,
-	0xd7ef, 0xd72d, 0xd72d, 0xd72d, 0xd72d, 0x080c, 0x0d7d, 0x080c,
-	0xcf69, 0x6003, 0x0002, 0x080c, 0x9684, 0x0804, 0xd7f1, 0x9006,
-	0x080c, 0x655c, 0x0804, 0xd7ef, 0x080c, 0x6a62, 0x1904, 0xd7ef,
-	0x9006, 0x080c, 0x655c, 0x6010, 0x2058, 0xb810, 0x9086, 0x00ff,
-	0x1140, 0x00f6, 0x2079, 0x1800, 0x78a8, 0x8000, 0x78aa, 0x00fe,
-	0x0428, 0x6010, 0x2058, 0xb884, 0x9005, 0x1178, 0x080c, 0xcf51,
-	0x1904, 0xd7ef, 0x0036, 0x0046, 0xbba0, 0x2021, 0x0007, 0x080c,
-	0x4cc0, 0x004e, 0x003e, 0x0804, 0xd7ef, 0x080c, 0x3357, 0x1904,
-	0xd7ef, 0x2001, 0x1800, 0x2004, 0x9086, 0x0002, 0x1138, 0x00f6,
-	0x2079, 0x1800, 0x78a8, 0x8000, 0x78aa, 0x00fe, 0x2001, 0x0002,
-	0x080c, 0x6570, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002,
-	0x080c, 0x9207, 0x080c, 0x9684, 0x6110, 0x2158, 0x2009, 0x0001,
-	0x080c, 0x862b, 0x0804, 0xd7f1, 0x6610, 0x2658, 0xbe04, 0x96b4,
-	0xff00, 0x8637, 0x9686, 0x0006, 0x0904, 0xd7ef, 0x9686, 0x0004,
-	0x0904, 0xd7ef, 0x080c, 0x8eac, 0x2001, 0x0004, 0x0804, 0xd7ed,
-	0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x1158, 0x0036, 0x0046,
-	0x6010, 0x2058, 0xbba0, 0x2021, 0x0006, 0x080c, 0x4cc0, 0x004e,
-	0x003e, 0x2001, 0x0006, 0x080c, 0xd80b, 0x6610, 0x2658, 0xbe04,
-	0x0066, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x006e, 0x0168,
-	0x2001, 0x0006, 0x080c, 0x659c, 0x9284, 0x00ff, 0x908e, 0x0007,
-	0x1120, 0x2001, 0x0006, 0x080c, 0x6570, 0x080c, 0x6a62, 0x11f8,
-	0x2001, 0x1837, 0x2004, 0xd0a4, 0x01d0, 0xbe04, 0x96b4, 0x00ff,
-	0x9686, 0x0006, 0x01a0, 0x00f6, 0x2079, 0x1800, 0x78a8, 0x8000,
-	0x78aa, 0x00fe, 0x0804, 0xd776, 0x2001, 0x0004, 0x0030, 0x2001,
-	0x0006, 0x0409, 0x0020, 0x0018, 0x0010, 0x080c, 0x659c, 0x080c,
-	0xabdf, 0x0005, 0x2600, 0x0002, 0xd806, 0xd806, 0xd806, 0xd806,
-	0xd806, 0xd808, 0xd806, 0xd808, 0xd806, 0xd806, 0xd808, 0xd806,
-	0xd806, 0xd806, 0xd808, 0xd808, 0xd808, 0xd808, 0x080c, 0x0d7d,
-	0x080c, 0xabdf, 0x0005, 0x0016, 0x00b6, 0x00d6, 0x6110, 0x2158,
-	0xb900, 0xd184, 0x0138, 0x080c, 0x6570, 0x9006, 0x080c, 0x655c,
-	0x080c, 0x321e, 0x00de, 0x00be, 0x001e, 0x0005, 0x6610, 0x2658,
-	0xb804, 0x9084, 0xff00, 0x8007, 0x90b2, 0x000c, 0x1a0c, 0x0d7d,
-	0x91b6, 0x0015, 0x1110, 0x003b, 0x0028, 0x91b6, 0x0016, 0x190c,
-	0x0d7d, 0x006b, 0x0005, 0xb68f, 0xb68f, 0xb68f, 0xb68f, 0xd8a0,
-	0xb68f, 0xd88a, 0xd84b, 0xb68f, 0xb68f, 0xb68f, 0xb68f, 0xb68f,
-	0xb68f, 0xb68f, 0xb68f, 0xd8a0, 0xb68f, 0xd88a, 0xd891, 0xb68f,
-	0xb68f, 0xb68f, 0xb68f, 0x00f6, 0x080c, 0x6a62, 0x11d8, 0x080c,
-	0xcf51, 0x11c0, 0x6010, 0x905d, 0x01a8, 0xb884, 0x9005, 0x0190,
-	0x9006, 0x080c, 0x655c, 0x2001, 0x0002, 0x080c, 0x6570, 0x6023,
-	0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x9207, 0x080c,
-	0x9684, 0x00f0, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c,
-	0x2614, 0x11b0, 0x080c, 0x6620, 0x0118, 0x080c, 0xabdf, 0x0080,
-	0xb810, 0x0006, 0xb814, 0x0006, 0xb884, 0x0006, 0x080c, 0x603e,
-	0x000e, 0xb886, 0x000e, 0xb816, 0x000e, 0xb812, 0x080c, 0xabdf,
-	0x00fe, 0x0005, 0x6604, 0x96b6, 0x001e, 0x1110, 0x080c, 0xabdf,
-	0x0005, 0x080c, 0xba1a, 0x1148, 0x6003, 0x0001, 0x6007, 0x0001,
-	0x080c, 0x9207, 0x080c, 0x9684, 0x0010, 0x080c, 0xabdf, 0x0005,
-	0x0804, 0xabdf, 0x6004, 0x908a, 0x0053, 0x1a0c, 0x0d7d, 0x080c,
-	0x95c6, 0x080c, 0xac1a, 0x0005, 0x9182, 0x0040, 0x0002, 0xd8c2,
-	0xd8c2, 0xd8c2, 0xd8c2, 0xd8c4, 0xd8c2, 0xd8c2, 0xd8c2, 0xd8c2,
-	0xd8c2, 0xd8c2, 0xd8c2, 0xd8c2, 0xd8c2, 0xd8c2, 0xd8c2, 0xd8c2,
-	0xd8c2, 0xd8c2, 0x080c, 0x0d7d, 0x0096, 0x00b6, 0x00d6, 0x00e6,
-	0x00f6, 0x0046, 0x0026, 0x6210, 0x2258, 0xb8bc, 0x9005, 0x11b0,
-	0x6007, 0x0044, 0x2071, 0x0260, 0x7444, 0x94a4, 0xff00, 0x0904,
-	0xd92b, 0x080c, 0xe694, 0x1170, 0x9486, 0x2000, 0x1158, 0x2009,
-	0x0001, 0x2011, 0x0200, 0x080c, 0x88ce, 0x0020, 0x9026, 0x080c,
-	0xe518, 0x0c30, 0x080c, 0x103a, 0x090c, 0x0d7d, 0x6003, 0x0007,
-	0xa867, 0x010d, 0x9006, 0xa802, 0xa86a, 0xac8a, 0x2c00, 0xa88e,
-	0x6008, 0xa8e2, 0x6010, 0x2058, 0xb8a0, 0x7130, 0xa97a, 0x0016,
-	0xa876, 0xa87f, 0x0000, 0xa883, 0x0000, 0xa887, 0x0036, 0x080c,
-	0x6d7b, 0x001e, 0x080c, 0xe694, 0x1904, 0xd98b, 0x9486, 0x2000,
-	0x1130, 0x2019, 0x0017, 0x080c, 0xe249, 0x0804, 0xd98b, 0x9486,
-	0x0200, 0x1120, 0x080c, 0xe1d9, 0x0804, 0xd98b, 0x9486, 0x0400,
-	0x0120, 0x9486, 0x1000, 0x1904, 0xd98b, 0x2019, 0x0002, 0x080c,
-	0xe1f8, 0x0804, 0xd98b, 0x2069, 0x1a6e, 0x6a00, 0xd284, 0x0904,
-	0xd9f5, 0x9284, 0x0300, 0x1904, 0xd9ee, 0x6804, 0x9005, 0x0904,
-	0xd9d6, 0x2d78, 0x6003, 0x0007, 0x080c, 0x1053, 0x0904, 0xd997,
-	0x7800, 0xd08c, 0x1118, 0x7804, 0x8001, 0x7806, 0x6017, 0x0000,
-	0x2001, 0x180f, 0x2004, 0xd084, 0x1904, 0xd9f9, 0x9006, 0xa802,
-	0xa867, 0x0116, 0xa86a, 0x6008, 0xa8e2, 0x2c00, 0xa87a, 0x6010,
-	0x2058, 0xb8a0, 0x7130, 0xa9b6, 0xa876, 0xb928, 0xa9ba, 0xb92c,
-	0xa9be, 0xb930, 0xa9c2, 0xb934, 0xa9c6, 0xa883, 0x003d, 0x7044,
-	0x9084, 0x0003, 0x9080, 0xd993, 0x2005, 0xa87e, 0x20a9, 0x000a,
-	0x2001, 0x0270, 0xaa5c, 0x9290, 0x0021, 0x2009, 0x0205, 0x200b,
-	0x0080, 0x20e1, 0x0000, 0xab60, 0x23e8, 0x2098, 0x22a0, 0x4003,
-	0x200b, 0x0000, 0x2001, 0x027a, 0x200c, 0xa9b2, 0x8000, 0x200c,
-	0xa9ae, 0x080c, 0x6d7e, 0x002e, 0x004e, 0x00fe, 0x00ee, 0x00de,
-	0x00be, 0x009e, 0x0005, 0x0000, 0x0080, 0x0040, 0x0000, 0x2001,
-	0x1810, 0x2004, 0xd084, 0x0120, 0x080c, 0x103a, 0x1904, 0xd940,
-	0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022,
-	0x080c, 0x9200, 0x0c00, 0x2069, 0x0260, 0x6848, 0x9084, 0xff00,
-	0x9086, 0x1200, 0x1198, 0x686c, 0x9084, 0x00ff, 0x0016, 0x6114,
-	0x918c, 0xf700, 0x910d, 0x6116, 0x001e, 0x6003, 0x0001, 0x6007,
-	0x0043, 0x2009, 0xa025, 0x080c, 0x9200, 0x0828, 0x6868, 0x602e,
-	0x686c, 0x6032, 0x6017, 0xf200, 0x6003, 0x0001, 0x6007, 0x0041,
-	0x2009, 0xa022, 0x080c, 0x9200, 0x0804, 0xd98b, 0x2001, 0x180e,
-	0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x4b09, 0x6017,
-	0xf300, 0x0010, 0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041,
-	0x2009, 0xa022, 0x080c, 0x9200, 0x0804, 0xd98b, 0x6017, 0xf500,
-	0x0c98, 0x6017, 0xf600, 0x0804, 0xd9ab, 0x6017, 0xf200, 0x0804,
-	0xd9ab, 0xa867, 0x0146, 0xa86b, 0x0000, 0x6008, 0xa886, 0x2c00,
-	0xa87a, 0x7044, 0x9084, 0x0003, 0x9080, 0xd993, 0x2005, 0xa87e,
-	0x2928, 0x6010, 0x2058, 0xb8a0, 0xa876, 0xb828, 0xa88a, 0xb82c,
-	0xa88e, 0xb830, 0xa892, 0xb834, 0xa896, 0xa883, 0x003d, 0x2009,
-	0x0205, 0x2104, 0x9085, 0x0080, 0x200a, 0x20e1, 0x0000, 0x2011,
-	0x0210, 0x2214, 0x9294, 0x0fff, 0xaaa2, 0x9282, 0x0111, 0x1a0c,
-	0x0d7d, 0x8210, 0x821c, 0x2001, 0x026c, 0x2098, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0029, 0x20a0, 0x2011, 0xda75, 0x2041, 0x0001,
-	0x223d, 0x9784, 0x00ff, 0x9322, 0x1208, 0x2300, 0x20a8, 0x4003,
-	0x931a, 0x0530, 0x8210, 0xd7fc, 0x1130, 0x8d68, 0x2d0a, 0x2001,
-	0x0260, 0x2098, 0x0c68, 0x2950, 0x080c, 0x1053, 0x0170, 0x2900,
-	0xb002, 0xa867, 0x0147, 0xa86b, 0x0000, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x001b, 0x20a0, 0x8840, 0x08d8, 0x2548, 0xa800, 0x902d,
-	0x0118, 0x080c, 0x106c, 0x0cc8, 0x080c, 0x106c, 0x0804, 0xd997,
-	0x2548, 0x8847, 0x9885, 0x0046, 0xa866, 0x2009, 0x0205, 0x200b,
-	0x0000, 0x080c, 0xe27c, 0x0804, 0xd98b, 0x8010, 0x0004, 0x801a,
-	0x0006, 0x8018, 0x0008, 0x8016, 0x000a, 0x8014, 0x9186, 0x0013,
-	0x1160, 0x6004, 0x908a, 0x0057, 0x1a0c, 0x0d7d, 0x9082, 0x0040,
-	0x0a0c, 0x0d7d, 0x2008, 0x0804, 0xdb00, 0x9186, 0x0051, 0x0108,
-	0x0040, 0x080c, 0xaa9a, 0x01e8, 0x9086, 0x0002, 0x0904, 0xdb47,
-	0x00c0, 0x9186, 0x0027, 0x0180, 0x9186, 0x0048, 0x0128, 0x9186,
-	0x0014, 0x0150, 0x190c, 0x0d7d, 0x080c, 0xaa9a, 0x0150, 0x9086,
-	0x0004, 0x0904, 0xdbe4, 0x0028, 0x6004, 0x9082, 0x0040, 0x2008,
-	0x001a, 0x080c, 0xac99, 0x0005, 0xdac7, 0xdac9, 0xdac9, 0xdaf0,
-	0xdac7, 0xdac7, 0xdac7, 0xdac7, 0xdac7, 0xdac7, 0xdac7, 0xdac7,
-	0xdac7, 0xdac7, 0xdac7, 0xdac7, 0xdac7, 0xdac7, 0xdac7, 0x080c,
-	0x0d7d, 0x080c, 0x95c6, 0x080c, 0x9684, 0x0036, 0x0096, 0x6014,
-	0x904d, 0x01d8, 0x080c, 0xc832, 0x01c0, 0x6003, 0x0002, 0x6010,
-	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1178, 0x2019, 0x0004,
-	0x080c, 0xe27c, 0x6017, 0x0000, 0x6018, 0x9005, 0x1120, 0x2001,
-	0x1986, 0x2004, 0x601a, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005,
-	0x0096, 0x080c, 0x95c6, 0x080c, 0x9684, 0x080c, 0xc832, 0x0120,
-	0x6014, 0x2048, 0x080c, 0x106c, 0x080c, 0xac1a, 0x009e, 0x0005,
-	0x0002, 0xdb14, 0xdb29, 0xdb16, 0xdb3e, 0xdb14, 0xdb14, 0xdb14,
-	0xdb14, 0xdb14, 0xdb14, 0xdb14, 0xdb14, 0xdb14, 0xdb14, 0xdb14,
-	0xdb14, 0xdb14, 0xdb14, 0xdb14, 0x080c, 0x0d7d, 0x0096, 0x6014,
-	0x2048, 0xa87c, 0xd0b4, 0x0138, 0x6003, 0x0007, 0x2009, 0x0043,
-	0x080c, 0xac7c, 0x0010, 0x6003, 0x0004, 0x080c, 0x9684, 0x009e,
-	0x0005, 0x080c, 0xc832, 0x0138, 0x6114, 0x0096, 0x2148, 0xa97c,
-	0x009e, 0xd1ec, 0x1138, 0x080c, 0x88a3, 0x080c, 0xabdf, 0x080c,
-	0x9684, 0x0005, 0x080c, 0xe4dc, 0x0db0, 0x0cc8, 0x6003, 0x0001,
-	0x6007, 0x0041, 0x2009, 0xa022, 0x080c, 0x9200, 0x0005, 0x9182,
-	0x0040, 0x0002, 0xdb5d, 0xdb5f, 0xdb5d, 0xdb5d, 0xdb5d, 0xdb5d,
-	0xdb5d, 0xdb5d, 0xdb5d, 0xdb5d, 0xdb5d, 0xdb5d, 0xdb5d, 0xdb5d,
-	0xdb5d, 0xdb5d, 0xdb5d, 0xdb60, 0xdb5d, 0x080c, 0x0d7d, 0x0005,
-	0x00d6, 0x080c, 0x88a3, 0x00de, 0x080c, 0xe534, 0x080c, 0xabdf,
-	0x0005, 0x9182, 0x0040, 0x0002, 0xdb7f, 0xdb7f, 0xdb7f, 0xdb7f,
-	0xdb7f, 0xdb7f, 0xdb7f, 0xdb7f, 0xdb7f, 0xdb81, 0xdbac, 0xdb7f,
-	0xdb7f, 0xdb7f, 0xdb7f, 0xdbac, 0xdb7f, 0xdb7f, 0xdb7f, 0x080c,
+	0x0001, 0x2009, 0x8020, 0x080c, 0x9239, 0x7220, 0x080c, 0xc853,
+	0x0178, 0x6810, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140,
+	0x6824, 0xd0ec, 0x0128, 0x00c6, 0x2d60, 0x080c, 0xcbaf, 0x00ce,
+	0x00ee, 0x00de, 0x005e, 0x002e, 0x0005, 0x9186, 0x0013, 0x1160,
+	0x6004, 0x908a, 0x0085, 0x0a0c, 0x0d7d, 0x908a, 0x0092, 0x1a0c,
+	0x0d7d, 0x9082, 0x0085, 0x00e2, 0x9186, 0x0027, 0x0120, 0x9186,
+	0x0014, 0x190c, 0x0d7d, 0x080c, 0x95ff, 0x0096, 0x6014, 0x2048,
+	0x080c, 0xc865, 0x0140, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b,
+	0x0029, 0x080c, 0x6d9f, 0x009e, 0x080c, 0xac2b, 0x0804, 0x96bd,
+	0xc24d, 0xc24f, 0xc24f, 0xc24d, 0xc24d, 0xc24d, 0xc24d, 0xc24d,
+	0xc24d, 0xc24d, 0xc24d, 0xc24d, 0xc24d, 0x080c, 0x0d7d, 0x080c,
+	0xac2b, 0x0005, 0x9186, 0x0013, 0x1130, 0x6004, 0x9082, 0x0085,
+	0x2008, 0x0804, 0xc29e, 0x9186, 0x0027, 0x1558, 0x080c, 0x95ff,
+	0x080c, 0x320f, 0x080c, 0xcf99, 0x0096, 0x6014, 0x2048, 0x080c,
+	0xc865, 0x0150, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0029,
+	0x080c, 0x6d9f, 0x080c, 0xca54, 0x009e, 0x080c, 0xabf0, 0x0005,
+	0x9186, 0x0089, 0x0118, 0x9186, 0x008a, 0x1140, 0x080c, 0xaaab,
+	0x0128, 0x9086, 0x000c, 0x0904, 0xc2d6, 0x0000, 0x080c, 0xacaa,
+	0x0c70, 0x9186, 0x0014, 0x1d60, 0x080c, 0x95ff, 0x0096, 0x6014,
+	0x2048, 0x080c, 0xc865, 0x0d00, 0xa867, 0x0103, 0xa877, 0x0000,
+	0xa87b, 0x0006, 0xa880, 0xc0ec, 0xa882, 0x0890, 0x0002, 0xc2ae,
+	0xc2ac, 0xc2ac, 0xc2ac, 0xc2ac, 0xc2ac, 0xc2c2, 0xc2ac, 0xc2ac,
+	0xc2ac, 0xc2ac, 0xc2ac, 0xc2ac, 0x080c, 0x0d7d, 0x6034, 0x908c,
+	0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118,
+	0x2001, 0x1985, 0x0010, 0x2001, 0x1986, 0x2004, 0x601a, 0x6003,
+	0x000c, 0x0005, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0039,
+	0x0118, 0x9186, 0x0035, 0x1118, 0x2001, 0x1985, 0x0010, 0x2001,
+	0x1986, 0x2004, 0x601a, 0x6003, 0x000e, 0x0005, 0x9182, 0x0092,
+	0x1220, 0x9182, 0x0085, 0x0208, 0x0012, 0x0804, 0xacaa, 0xc2ec,
+	0xc2ec, 0xc2ec, 0xc2ec, 0xc2ee, 0xc33b, 0xc2ec, 0xc2ec, 0xc2ec,
+	0xc2ec, 0xc2ec, 0xc2ec, 0xc2ec, 0x080c, 0x0d7d, 0x0096, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0168, 0x6034, 0x908c,
+	0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118,
+	0x009e, 0x0804, 0xc34f, 0x080c, 0xc865, 0x1118, 0x080c, 0xca54,
+	0x0068, 0x6014, 0x2048, 0x080c, 0xcfb0, 0x1110, 0x080c, 0xca54,
+	0xa867, 0x0103, 0x080c, 0xcf64, 0x080c, 0x6d9f, 0x00d6, 0x2c68,
+	0x080c, 0xab9a, 0x01d0, 0x6003, 0x0001, 0x6007, 0x001e, 0x600b,
+	0xffff, 0x2009, 0x026e, 0x210c, 0x613a, 0x2009, 0x026f, 0x210c,
+	0x613e, 0x6910, 0x6112, 0x080c, 0xccfe, 0x695c, 0x615e, 0x6023,
+	0x0001, 0x2009, 0x8020, 0x080c, 0x9239, 0x2d60, 0x00de, 0x080c,
+	0xabf0, 0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x05a0, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0035,
+	0x0130, 0x9186, 0x001e, 0x0118, 0x9186, 0x0039, 0x1538, 0x00d6,
+	0x2c68, 0x080c, 0xcefc, 0x11f0, 0x080c, 0xab9a, 0x01d8, 0x6106,
+	0x6003, 0x0001, 0x6023, 0x0001, 0x6910, 0x6112, 0x692c, 0x612e,
+	0x6930, 0x6132, 0x6934, 0x918c, 0x00ff, 0x6136, 0x6938, 0x613a,
+	0x693c, 0x613e, 0x695c, 0x615e, 0x080c, 0xccfe, 0x2009, 0x8020,
+	0x080c, 0x9239, 0x2d60, 0x00de, 0x0804, 0xabf0, 0x0096, 0x6014,
+	0x2048, 0x080c, 0xc865, 0x01c8, 0xa867, 0x0103, 0xa880, 0xd0b4,
+	0x0128, 0xc0ec, 0xa882, 0xa87b, 0x0006, 0x0048, 0xd0bc, 0x0118,
+	0xa87b, 0x0002, 0x0020, 0xa87b, 0x0005, 0x080c, 0xcb6e, 0xa877,
+	0x0000, 0x080c, 0x6d9f, 0x080c, 0xca54, 0x009e, 0x0804, 0xabf0,
+	0x0016, 0x0096, 0x6014, 0x2048, 0x080c, 0xc865, 0x0140, 0xa867,
+	0x0103, 0xa87b, 0x0028, 0xa877, 0x0000, 0x080c, 0x6d9f, 0x009e,
+	0x001e, 0x9186, 0x0013, 0x0158, 0x9186, 0x0014, 0x0130, 0x9186,
+	0x0027, 0x0118, 0x080c, 0xacaa, 0x0020, 0x080c, 0x95ff, 0x080c,
+	0xac2b, 0x0005, 0x0056, 0x0066, 0x0096, 0x00a6, 0x2029, 0x0001,
+	0x9182, 0x0101, 0x1208, 0x0010, 0x2009, 0x0100, 0x2130, 0x8304,
+	0x9098, 0x0018, 0x2009, 0x0020, 0x2011, 0x0029, 0x080c, 0xc41b,
+	0x96b2, 0x0020, 0xb004, 0x904d, 0x0110, 0x080c, 0x0ff9, 0x080c,
+	0x1047, 0x0520, 0x8528, 0xa867, 0x0110, 0xa86b, 0x0000, 0x2920,
+	0xb406, 0x968a, 0x003d, 0x1228, 0x2608, 0x2011, 0x001b, 0x0499,
+	0x00a8, 0x96b2, 0x003c, 0x2009, 0x003c, 0x2950, 0x2011, 0x001b,
+	0x0451, 0x0c28, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f,
+	0x95ad, 0x0003, 0xb566, 0x95ac, 0x0000, 0x0048, 0x2001, 0x0205,
+	0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0003, 0xb566, 0x009e,
+	0x006e, 0x005e, 0x0005, 0x00a6, 0x89ff, 0x0158, 0xa804, 0x9055,
+	0x0130, 0xa807, 0x0000, 0x080c, 0x6d9f, 0x2a48, 0x0cb8, 0x080c,
+	0x6d9f, 0x00ae, 0x0005, 0x00f6, 0x2079, 0x0200, 0x7814, 0x9085,
+	0x0080, 0x7816, 0xd184, 0x0108, 0x8108, 0x810c, 0x20a9, 0x0001,
+	0xa860, 0x20e8, 0xa85c, 0x9200, 0x20a0, 0x20e1, 0x0000, 0x2300,
+	0x9e00, 0x2098, 0x4003, 0x8318, 0x9386, 0x0020, 0x1148, 0x2018,
+	0x2300, 0x9e00, 0x2098, 0x7814, 0x8000, 0x9085, 0x0080, 0x7816,
+	0x8109, 0x1d80, 0x7817, 0x0000, 0x00fe, 0x0005, 0x0066, 0x0126,
+	0x2091, 0x8000, 0x2031, 0x0001, 0x6020, 0x9084, 0x000f, 0x0083,
+	0x012e, 0x006e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0066, 0x2031,
+	0x0000, 0x6020, 0x9084, 0x000f, 0x001b, 0x006e, 0x012e, 0x0005,
+	0xc498, 0xc498, 0xc493, 0xc4bc, 0xc470, 0xc493, 0xc472, 0xc493,
+	0xc470, 0x90ff, 0xc493, 0xc493, 0xc493, 0xc470, 0xc470, 0xc470,
+	0x080c, 0x0d7d, 0x6010, 0x9080, 0x0000, 0x2004, 0xd0bc, 0x190c,
+	0xc4bc, 0x0036, 0x6014, 0x0096, 0x2048, 0xa880, 0x009e, 0xd0cc,
+	0x0118, 0x2019, 0x000c, 0x0038, 0xd094, 0x0118, 0x2019, 0x000d,
+	0x0010, 0x2019, 0x0010, 0x080c, 0xde67, 0x6023, 0x0006, 0x6003,
+	0x0007, 0x003e, 0x0005, 0x9006, 0x0005, 0x9085, 0x0001, 0x0005,
+	0x0096, 0x86ff, 0x11e8, 0x6014, 0x2048, 0x080c, 0xc865, 0x01d0,
+	0x6043, 0xffff, 0xa864, 0x9086, 0x0139, 0x1128, 0xa87b, 0x0005,
+	0xa883, 0x0000, 0x0028, 0x900e, 0x2001, 0x0005, 0x080c, 0x6fd3,
+	0x080c, 0xcb6e, 0x080c, 0x6d93, 0x080c, 0xac2b, 0x9085, 0x0001,
+	0x009e, 0x0005, 0x9006, 0x0ce0, 0x080c, 0xa899, 0x080c, 0xcfbe,
+	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x002b, 0x0106, 0x080c,
+	0xa8b5, 0x010e, 0x0005, 0xc4db, 0xc509, 0xc4dd, 0xc530, 0xc504,
+	0xc4db, 0xc493, 0xc498, 0xc498, 0xc493, 0xc493, 0xc493, 0xc493,
+	0xc493, 0xc493, 0xc493, 0x080c, 0x0d7d, 0x86ff, 0x1510, 0x6020,
+	0x9086, 0x0006, 0x01f0, 0x0096, 0x6014, 0x2048, 0x080c, 0xc865,
+	0x0158, 0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c,
+	0x0ff9, 0x009e, 0x080c, 0xcb6e, 0x009e, 0x080c, 0xcf3e, 0x6007,
+	0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2009, 0x8020, 0x080c,
+	0x921b, 0x9085, 0x0001, 0x0005, 0x0066, 0x080c, 0x1a94, 0x006e,
+	0x08a0, 0x00e6, 0x2071, 0x19e6, 0x7030, 0x9c06, 0x1120, 0x080c,
+	0xa0b3, 0x00ee, 0x0850, 0x6020, 0x9084, 0x000f, 0x9086, 0x0006,
+	0x1150, 0x0086, 0x0096, 0x2049, 0x0001, 0x2c40, 0x080c, 0xa207,
+	0x009e, 0x008e, 0x0040, 0x0066, 0x080c, 0x9faf, 0x190c, 0x0d7d,
+	0x080c, 0x9fbd, 0x006e, 0x00ee, 0x1904, 0xc4dd, 0x0804, 0xc493,
+	0x0036, 0x00e6, 0x2071, 0x19e6, 0x704c, 0x9c06, 0x1138, 0x901e,
+	0x080c, 0xa133, 0x00ee, 0x003e, 0x0804, 0xc4dd, 0x080c, 0xa33e,
+	0x00ee, 0x003e, 0x1904, 0xc4dd, 0x0804, 0xc493, 0x00c6, 0x0066,
+	0x6020, 0x9084, 0x000f, 0x001b, 0x006e, 0x00ce, 0x0005, 0xc566,
+	0xc635, 0xc79f, 0xc56e, 0xac2b, 0xc566, 0xde59, 0xcfa6, 0xc635,
+	0x90c6, 0xc82b, 0xc55f, 0xc55f, 0xc55f, 0xc55f, 0xc55f, 0x080c,
+	0x0d7d, 0x080c, 0xca7a, 0x1110, 0x080c, 0xb5c6, 0x0005, 0x080c,
+	0x95ff, 0x0804, 0xabf0, 0x601b, 0x0001, 0x0005, 0x080c, 0xc865,
+	0x0130, 0x6014, 0x0096, 0x2048, 0x2c00, 0xa896, 0x009e, 0x080c,
+	0xa899, 0x080c, 0xcfbe, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d,
+	0x0013, 0x0804, 0xa8b5, 0xc593, 0xc595, 0xc5bf, 0xc5d3, 0xc600,
+	0xc593, 0xc566, 0xc566, 0xc566, 0xc5da, 0xc5da, 0xc593, 0xc593,
+	0xc593, 0xc593, 0xc5e4, 0x080c, 0x0d7d, 0x00e6, 0x6014, 0x0096,
+	0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e, 0x2071, 0x19e6, 0x7030,
+	0x9c06, 0x01d0, 0x0066, 0x080c, 0x9faf, 0x190c, 0x0d7d, 0x080c,
+	0x9fbd, 0x006e, 0x080c, 0xcf3e, 0x6007, 0x0085, 0x6003, 0x000b,
+	0x6023, 0x0002, 0x2001, 0x1986, 0x2004, 0x601a, 0x2009, 0x8020,
+	0x080c, 0x921b, 0x00ee, 0x0005, 0x601b, 0x0001, 0x0cd8, 0x0096,
+	0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e, 0x080c, 0xcf3e,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2009, 0x8020,
+	0x080c, 0x921b, 0x0005, 0x080c, 0xa899, 0x080c, 0xaa2d, 0x080c,
+	0xa8b5, 0x0c28, 0x0096, 0x601b, 0x0001, 0x6014, 0x2048, 0xa880,
+	0xc0b5, 0xa882, 0x009e, 0x0005, 0x080c, 0x56fd, 0x01b8, 0x6014,
+	0x0096, 0x904d, 0x0190, 0xa864, 0xa867, 0x0103, 0xa87b, 0x0006,
+	0x9086, 0x0139, 0x1150, 0xa867, 0x0139, 0xa87b, 0x0030, 0xa897,
+	0x4005, 0xa89b, 0x0004, 0x080c, 0x6d9f, 0x009e, 0x0804, 0xabf0,
+	0x6014, 0x0096, 0x904d, 0x0560, 0xa97c, 0xd1e4, 0x1158, 0x611c,
+	0xd1fc, 0x0530, 0x6110, 0x00b6, 0x2158, 0xb93c, 0x8109, 0x0208,
+	0xb93e, 0x00be, 0x080c, 0xa8b5, 0x2001, 0x180f, 0x2004, 0xd0c4,
+	0x0110, 0x009e, 0x0005, 0xa884, 0x009e, 0x8003, 0x800b, 0x810b,
+	0x9108, 0x611a, 0x2001, 0x0037, 0x2c08, 0x080c, 0x1693, 0x6000,
+	0x9086, 0x0004, 0x1120, 0x2009, 0x0048, 0x080c, 0xac8d, 0x0005,
+	0x009e, 0x080c, 0x1a94, 0x0804, 0xc5bf, 0x6000, 0x908a, 0x0016,
+	0x1a0c, 0x0d7d, 0x000b, 0x0005, 0xc64c, 0xc56b, 0xc64e, 0xc64c,
+	0xc64e, 0xc64e, 0xc567, 0xc64c, 0xc561, 0xc561, 0xc64c, 0xc64c,
+	0xc64c, 0xc64c, 0xc64c, 0xc64c, 0x080c, 0x0d7d, 0x6010, 0x00b6,
+	0x2058, 0xb804, 0x9084, 0x00ff, 0x00be, 0x908a, 0x000c, 0x1a0c,
+	0x0d7d, 0x00b6, 0x0013, 0x00be, 0x0005, 0xc669, 0xc736, 0xc66b,
+	0xc6ab, 0xc66b, 0xc6ab, 0xc66b, 0xc679, 0xc669, 0xc6ab, 0xc669,
+	0xc69a, 0x080c, 0x0d7d, 0x6004, 0x908e, 0x0016, 0x05c0, 0x908e,
+	0x0004, 0x05a8, 0x908e, 0x0002, 0x0590, 0x908e, 0x0052, 0x0904,
+	0xc732, 0x6004, 0x080c, 0xca7a, 0x0904, 0xc74f, 0x908e, 0x0004,
+	0x1110, 0x080c, 0x323e, 0x908e, 0x0021, 0x0904, 0xc753, 0x908e,
+	0x0022, 0x0904, 0xc79a, 0x908e, 0x003d, 0x0904, 0xc753, 0x908e,
+	0x0039, 0x0904, 0xc757, 0x908e, 0x0035, 0x0904, 0xc757, 0x908e,
+	0x001e, 0x0178, 0x908e, 0x0001, 0x1140, 0x6010, 0x2058, 0xb804,
+	0x9084, 0x00ff, 0x9086, 0x0006, 0x0110, 0x080c, 0x320f, 0x080c,
+	0xb5c6, 0x0804, 0xac2b, 0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016,
+	0x0904, 0xc723, 0x9186, 0x0002, 0x1904, 0xc6f8, 0x2001, 0x1837,
+	0x2004, 0xd08c, 0x11c8, 0x080c, 0x74ec, 0x11b0, 0x080c, 0xcf84,
+	0x0138, 0x080c, 0x750f, 0x1120, 0x080c, 0x73f7, 0x0804, 0xc783,
+	0x2001, 0x197c, 0x2003, 0x0001, 0x2001, 0x1800, 0x2003, 0x0001,
+	0x080c, 0x741d, 0x0804, 0xc783, 0x6010, 0x2058, 0x2001, 0x1837,
+	0x2004, 0xd0ac, 0x1904, 0xc783, 0xb8a0, 0x9084, 0xff80, 0x1904,
+	0xc783, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0190, 0x8001, 0xb842,
+	0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398, 0x604b, 0x0000,
+	0x080c, 0xab9a, 0x0128, 0x2b00, 0x6012, 0x6023, 0x0001, 0x0458,
+	0x00de, 0x00ce, 0x6004, 0x908e, 0x0002, 0x11a0, 0x6010, 0x2058,
+	0xb8a0, 0x9086, 0x007e, 0x1170, 0x2009, 0x1837, 0x2104, 0xc085,
+	0x200a, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5fd7, 0x00ee, 0x080c,
+	0xb5c6, 0x0030, 0x080c, 0xb5c6, 0x080c, 0x320f, 0x080c, 0xcf99,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x323e, 0x012e, 0x00ee,
+	0x080c, 0xac2b, 0x0005, 0x2001, 0x0002, 0x080c, 0x6594, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x080c, 0x9240, 0x080c, 0x96bd, 0x00de,
+	0x00ce, 0x0c80, 0x080c, 0x323e, 0x0804, 0xc6a7, 0x00c6, 0x00d6,
+	0x6104, 0x9186, 0x0016, 0x0d38, 0x6010, 0x2058, 0xb840, 0x9084,
+	0x00ff, 0x9005, 0x0904, 0xc6f8, 0x8001, 0xb842, 0x6003, 0x0001,
+	0x080c, 0x9240, 0x080c, 0x96bd, 0x00de, 0x00ce, 0x0898, 0x080c,
+	0xb5c6, 0x0804, 0xc6a9, 0x080c, 0xb602, 0x0804, 0xc6a9, 0x00d6,
+	0x2c68, 0x6104, 0x080c, 0xcefc, 0x00de, 0x0118, 0x080c, 0xabf0,
+	0x0408, 0x6004, 0x8007, 0x6134, 0x918c, 0x00ff, 0x9105, 0x6036,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x603c, 0x600a,
+	0x2001, 0x1986, 0x2004, 0x601a, 0x602c, 0x2c08, 0x2060, 0x6024,
+	0xd0b4, 0x0108, 0xc085, 0xc0b5, 0x6026, 0x2160, 0x2009, 0x8020,
+	0x080c, 0x9239, 0x0005, 0x00de, 0x00ce, 0x080c, 0xb5c6, 0x080c,
+	0x320f, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x323e, 0x6017,
+	0x0000, 0x6023, 0x0007, 0x601b, 0x0398, 0x604b, 0x0000, 0x012e,
+	0x00ee, 0x0005, 0x080c, 0xb02b, 0x1904, 0xc74f, 0x0005, 0x6000,
+	0x908a, 0x0016, 0x1a0c, 0x0d7d, 0x0096, 0x00d6, 0x001b, 0x00de,
+	0x009e, 0x0005, 0xc7ba, 0xc7ba, 0xc7ba, 0xc7ba, 0xc7ba, 0xc7ba,
+	0xc7ba, 0xc7ba, 0xc7ba, 0xc566, 0xc7ba, 0xc56b, 0xc7bc, 0xc56b,
+	0xc7d6, 0xc7ba, 0x080c, 0x0d7d, 0x6004, 0x9086, 0x008b, 0x01b0,
+	0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0035, 0x1130, 0x602c,
+	0x9080, 0x0009, 0x200c, 0xc185, 0x2102, 0x6007, 0x008b, 0x6003,
+	0x000d, 0x2009, 0x8020, 0x080c, 0x9239, 0x0005, 0x080c, 0xcf78,
+	0x0118, 0x080c, 0xcf8b, 0x0010, 0x080c, 0xcf99, 0x080c, 0xca54,
+	0x080c, 0xc865, 0x0570, 0x080c, 0x320f, 0x080c, 0xc865, 0x0168,
+	0x6014, 0x2048, 0xa867, 0x0103, 0xa87b, 0x0006, 0xa877, 0x0000,
+	0xa880, 0xc0ed, 0xa882, 0x080c, 0x6d9f, 0x2c68, 0x080c, 0xab9a,
+	0x0150, 0x6810, 0x6012, 0x080c, 0xccfe, 0x00c6, 0x2d60, 0x080c,
+	0xac2b, 0x00ce, 0x0008, 0x2d60, 0x6017, 0x0000, 0x6023, 0x0001,
+	0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x9240, 0x080c, 0x96bd,
+	0x00c8, 0x080c, 0xcf78, 0x0138, 0x6034, 0x9086, 0x4000, 0x1118,
+	0x080c, 0x320f, 0x08d0, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186,
+	0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x080c, 0x320f, 0x0868,
+	0x080c, 0xac2b, 0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d7d,
+	0x0002, 0xc841, 0xc841, 0xc843, 0xc843, 0xc843, 0xc841, 0xc841,
+	0xac2b, 0xc841, 0xc841, 0xc841, 0xc841, 0xc841, 0xc841, 0xc841,
+	0xc841, 0x080c, 0x0d7d, 0x080c, 0xa899, 0x080c, 0xaa2d, 0x080c,
+	0xa8b5, 0x6114, 0x0096, 0x2148, 0xa87b, 0x0006, 0x080c, 0x6d9f,
+	0x009e, 0x0804, 0xabf0, 0x9284, 0x0003, 0x1158, 0x9282, 0x1ddc,
+	0x0240, 0x2001, 0x181a, 0x2004, 0x9202, 0x1218, 0x9085, 0x0001,
+	0x0005, 0x9006, 0x0ce8, 0x0096, 0x0028, 0x0096, 0x0006, 0x6014,
+	0x2048, 0x000e, 0x0006, 0x9984, 0xf000, 0x9086, 0xf000, 0x0110,
+	0x080c, 0x10f2, 0x000e, 0x009e, 0x0005, 0x00e6, 0x00c6, 0x0036,
+	0x0006, 0x0126, 0x2091, 0x8000, 0x2061, 0x1ddc, 0x2071, 0x1800,
+	0x7354, 0x7074, 0x9302, 0x1640, 0x6020, 0x9206, 0x11f8, 0x080c,
+	0xcf84, 0x0180, 0x9286, 0x0001, 0x1168, 0x6004, 0x9086, 0x0004,
+	0x1148, 0x080c, 0x320f, 0x080c, 0xcf99, 0x00c6, 0x080c, 0xac2b,
+	0x00ce, 0x0060, 0x080c, 0xcc70, 0x0148, 0x080c, 0xca7a, 0x1110,
+	0x080c, 0xb5c6, 0x00c6, 0x080c, 0xabf0, 0x00ce, 0x9ce0, 0x001c,
+	0x7068, 0x9c02, 0x1208, 0x08a0, 0x012e, 0x000e, 0x003e, 0x00ce,
+	0x00ee, 0x0005, 0x00e6, 0x00c6, 0x0016, 0x9188, 0x1000, 0x210c,
+	0x81ff, 0x0128, 0x2061, 0x1b31, 0x6112, 0x080c, 0x320f, 0x9006,
+	0x0010, 0x9085, 0x0001, 0x001e, 0x00ce, 0x00ee, 0x0005, 0x00c6,
+	0x0126, 0x2091, 0x8000, 0x080c, 0xab9a, 0x01b0, 0x665e, 0x2b00,
+	0x6012, 0x080c, 0x56fd, 0x0118, 0x080c, 0xc996, 0x0168, 0x080c,
+	0xccfe, 0x6023, 0x0003, 0x2009, 0x004b, 0x080c, 0xac8d, 0x9085,
+	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126,
+	0x2091, 0x8000, 0xbaa0, 0x080c, 0xac60, 0x0580, 0x605f, 0x0000,
+	0x2b00, 0x6012, 0x080c, 0xccfe, 0x6023, 0x0003, 0x0016, 0x080c,
+	0xa899, 0x080c, 0x93c6, 0x0076, 0x903e, 0x080c, 0x928f, 0x2c08,
+	0x080c, 0xe038, 0x007e, 0x080c, 0xa8b5, 0x001e, 0xd184, 0x0128,
+	0x080c, 0xabf0, 0x9085, 0x0001, 0x0070, 0x080c, 0x56fd, 0x0128,
+	0xd18c, 0x1170, 0x080c, 0xc996, 0x0148, 0x2009, 0x004c, 0x080c,
+	0xac8d, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8,
+	0x2900, 0x6016, 0x0c90, 0x2009, 0x004d, 0x0010, 0x2009, 0x004e,
+	0x00f6, 0x00c6, 0x0046, 0x0016, 0x080c, 0xab9a, 0x2c78, 0x0590,
+	0x7e5e, 0x2b00, 0x7812, 0x7823, 0x0003, 0x2021, 0x0005, 0x080c,
+	0xc9a8, 0x9186, 0x004d, 0x0118, 0x9186, 0x004e, 0x0148, 0x2001,
+	0x197f, 0x200c, 0xd1fc, 0x0168, 0x2f60, 0x080c, 0xabf0, 0x00d0,
+	0x2001, 0x197e, 0x200c, 0xd1fc, 0x0120, 0x2f60, 0x080c, 0xabf0,
+	0x0088, 0x2f60, 0x080c, 0x56fd, 0x0138, 0xd18c, 0x1118, 0x04f1,
+	0x0148, 0x0010, 0x2900, 0x7816, 0x001e, 0x0016, 0x080c, 0xac8d,
+	0x9085, 0x0001, 0x001e, 0x004e, 0x00ce, 0x00fe, 0x0005, 0x00f6,
+	0x00c6, 0x0046, 0x080c, 0xab9a, 0x2c78, 0x0508, 0x7e5e, 0x2b00,
+	0x7812, 0x7823, 0x0003, 0x0096, 0x2021, 0x0004, 0x0489, 0x009e,
+	0x2001, 0x197d, 0x200c, 0xd1fc, 0x0120, 0x2f60, 0x080c, 0xabf0,
+	0x0060, 0x2f60, 0x080c, 0x56fd, 0x0120, 0xd18c, 0x1160, 0x0071,
+	0x0130, 0x2009, 0x0052, 0x080c, 0xac8d, 0x9085, 0x0001, 0x004e,
+	0x00ce, 0x00fe, 0x0005, 0x2900, 0x7816, 0x0c98, 0x00c6, 0x080c,
+	0x4ac9, 0x00ce, 0x1120, 0x080c, 0xabf0, 0x9006, 0x0005, 0xa867,
+	0x0000, 0xa86b, 0x8000, 0x2900, 0x6016, 0x9085, 0x0001, 0x0005,
+	0x0096, 0x0076, 0x0126, 0x2091, 0x8000, 0x080c, 0xa899, 0x080c,
+	0x6826, 0x0158, 0x2001, 0xc9af, 0x0006, 0x900e, 0x2400, 0x080c,
+	0x6fd3, 0x080c, 0x6d9f, 0x000e, 0x0807, 0x2418, 0x080c, 0x95c5,
+	0xbaa0, 0x0086, 0x2041, 0x0001, 0x2039, 0x0001, 0x2608, 0x080c,
+	0x93e0, 0x008e, 0x080c, 0x928f, 0x2f08, 0x2648, 0x080c, 0xe038,
+	0xb93c, 0x81ff, 0x090c, 0x94b7, 0x080c, 0xa8b5, 0x012e, 0x007e,
+	0x009e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0xab9a,
+	0x0190, 0x660a, 0x2b08, 0x6112, 0x080c, 0xccfe, 0x6023, 0x0001,
+	0x2900, 0x6016, 0x2009, 0x001f, 0x080c, 0xac8d, 0x9085, 0x0001,
+	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x080c, 0xac60, 0x01b8, 0x660a, 0x2b08, 0x6112, 0x080c,
+	0xccfe, 0x6023, 0x0008, 0x2900, 0x6016, 0x00f6, 0x2c78, 0x080c,
+	0x174b, 0x00fe, 0x2009, 0x0021, 0x080c, 0xac8d, 0x9085, 0x0001,
+	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009, 0x003d, 0x00c6,
+	0x0126, 0x0016, 0x2091, 0x8000, 0x080c, 0xab9a, 0x0198, 0x660a,
+	0x2b08, 0x6112, 0x080c, 0xccfe, 0x6023, 0x0001, 0x2900, 0x6016,
+	0x001e, 0x0016, 0x080c, 0xac8d, 0x9085, 0x0001, 0x001e, 0x012e,
+	0x00ce, 0x0005, 0x9006, 0x0cd0, 0x00c6, 0x0126, 0x2091, 0x8000,
+	0x080c, 0xac60, 0x0188, 0x2b08, 0x6112, 0x080c, 0xccfe, 0x6023,
+	0x0001, 0x2900, 0x6016, 0x2009, 0x0000, 0x080c, 0xac8d, 0x9085,
+	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009, 0x0044,
+	0x0830, 0x2009, 0x0049, 0x0818, 0x0026, 0x00b6, 0x6210, 0x2258,
+	0xba3c, 0x82ff, 0x0118, 0x8211, 0xba3e, 0x1140, 0xb8d0, 0x9005,
+	0x0128, 0xb888, 0x9005, 0x1110, 0xb88b, 0x0001, 0x00be, 0x002e,
+	0x0005, 0x0006, 0x0016, 0x6004, 0x908e, 0x0002, 0x0140, 0x908e,
+	0x0003, 0x0128, 0x908e, 0x0004, 0x0110, 0x9085, 0x0001, 0x001e,
+	0x000e, 0x0005, 0x0006, 0x0086, 0x0096, 0x6020, 0x9086, 0x0004,
+	0x01a8, 0x6014, 0x904d, 0x080c, 0xc865, 0x0180, 0xa864, 0x9086,
+	0x0139, 0x0170, 0x6020, 0x90c6, 0x0003, 0x0140, 0x90c6, 0x0002,
+	0x0128, 0xa868, 0xd0fc, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001,
+	0x009e, 0x008e, 0x000e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000,
+	0x080c, 0xac60, 0x0198, 0x2b08, 0x6112, 0x080c, 0xccfe, 0x6023,
+	0x0001, 0x2900, 0x6016, 0x080c, 0x320f, 0x2009, 0x0028, 0x080c,
+	0xac8d, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8,
+	0x9186, 0x0015, 0x11a8, 0x2011, 0x1824, 0x2204, 0x9086, 0x0074,
+	0x1178, 0x00b6, 0x080c, 0xb81a, 0x00be, 0x080c, 0xba3d, 0x6003,
+	0x0001, 0x6007, 0x0029, 0x080c, 0x9240, 0x080c, 0x96bd, 0x0078,
+	0x6014, 0x0096, 0x2048, 0xa868, 0x009e, 0xd0fc, 0x0148, 0x2001,
+	0x0001, 0x080c, 0xcebd, 0x080c, 0xb5c6, 0x080c, 0xabf0, 0x0005,
+	0x0096, 0x6014, 0x904d, 0x090c, 0x0d7d, 0xa87b, 0x0030, 0xa883,
+	0x0000, 0xa897, 0x4005, 0xa89b, 0x0004, 0xa867, 0x0139, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e, 0x009e, 0x080c, 0xabf0,
+	0x0c30, 0x0096, 0x9186, 0x0016, 0x1128, 0x2001, 0x0004, 0x080c,
+	0x6594, 0x00e8, 0x9186, 0x0015, 0x1510, 0x2011, 0x1824, 0x2204,
+	0x9086, 0x0014, 0x11e0, 0x6010, 0x00b6, 0x2058, 0x080c, 0x66df,
+	0x00be, 0x080c, 0xbb0e, 0x1198, 0x6010, 0x00b6, 0x2058, 0xb890,
+	0x00be, 0x9005, 0x0160, 0x2001, 0x0006, 0x080c, 0x6594, 0x6014,
+	0x2048, 0xa868, 0xd0fc, 0x0170, 0x080c, 0xafff, 0x0048, 0x6014,
+	0x2048, 0xa868, 0xd0fc, 0x0528, 0x080c, 0xb5c6, 0x080c, 0xabf0,
+	0x009e, 0x0005, 0x6014, 0x6310, 0x2358, 0x904d, 0x090c, 0x0d7d,
+	0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x900e, 0x080c,
+	0x6937, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0xa99a,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e, 0x080c, 0xabf0,
+	0x08f8, 0x6014, 0x904d, 0x090c, 0x0d7d, 0xa87b, 0x0030, 0xa883,
+	0x0000, 0xa897, 0x4005, 0xa89b, 0x0004, 0xa867, 0x0139, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e, 0x080c, 0xabf0, 0x0840,
+	0xa878, 0x9086, 0x0005, 0x1108, 0x0009, 0x0005, 0xa880, 0xc0ad,
+	0xa882, 0x0005, 0x604b, 0x0000, 0x6017, 0x0000, 0x6003, 0x0001,
+	0x6007, 0x0050, 0x2009, 0x8023, 0x080c, 0x9239, 0x0005, 0x00c6,
+	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0130, 0x0066,
+	0x6020, 0x9084, 0x000f, 0x001b, 0x006e, 0x00ce, 0x0005, 0xc566,
+	0xcba1, 0xcba1, 0xcba4, 0xe365, 0xe380, 0xe383, 0xc566, 0xc566,
+	0xc566, 0xc566, 0xc566, 0xc566, 0xc566, 0xc566, 0xc566, 0x080c,
+	0x0d7d, 0xa001, 0xa001, 0x0005, 0x0096, 0x6014, 0x904d, 0x0118,
+	0xa87c, 0xd0e4, 0x1110, 0x009e, 0x0010, 0x009e, 0x0005, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0550, 0x2001, 0x1834,
+	0x2004, 0x9005, 0x1540, 0x00f6, 0x2c78, 0x080c, 0xab9a, 0x0508,
+	0x7810, 0x6012, 0x080c, 0xccfe, 0x7820, 0x9086, 0x0003, 0x0128,
+	0x7808, 0x603a, 0x2f00, 0x603e, 0x0020, 0x7808, 0x603e, 0x2f00,
+	0x603a, 0x602e, 0x6023, 0x0001, 0x6007, 0x0035, 0x6003, 0x0001,
+	0x795c, 0x615e, 0x2009, 0x8020, 0x080c, 0x9239, 0x2f60, 0x00fe,
+	0x0005, 0x2f60, 0x00fe, 0x2001, 0x1987, 0x2004, 0x604a, 0x0005,
+	0x0016, 0x0096, 0x6814, 0x2048, 0x681c, 0xd0fc, 0xc0fc, 0x681e,
+	0xa87c, 0x1108, 0xd0e4, 0x0180, 0xc0e4, 0xa87e, 0xa877, 0x0000,
+	0xa893, 0x0000, 0xa88f, 0x0000, 0xd0cc, 0x0130, 0xc0cc, 0xa87e,
+	0xa878, 0x2048, 0x080c, 0x0ff9, 0x6830, 0x6036, 0x908e, 0x0001,
+	0x0148, 0x6803, 0x0002, 0x9086, 0x0005, 0x0170, 0x9006, 0x602e,
+	0x6032, 0x00d0, 0x681c, 0xc085, 0x681e, 0x6803, 0x0004, 0x6824,
+	0xc0f4, 0x9085, 0x0c00, 0x6826, 0x6814, 0x2048, 0xa8ac, 0x6938,
+	0x9102, 0xa8b0, 0x693c, 0x9103, 0x1e48, 0x683c, 0x602e, 0x6838,
+	0x9084, 0xfffc, 0x683a, 0x6032, 0x2d00, 0x603a, 0x6808, 0x603e,
+	0x6910, 0x6112, 0x695c, 0x615e, 0x6023, 0x0001, 0x6007, 0x0039,
+	0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x9239, 0x009e, 0x001e,
+	0x0005, 0x6024, 0xd0d4, 0x0510, 0xd0f4, 0x11f8, 0x6038, 0x940a,
+	0x603c, 0x9303, 0x0230, 0x9105, 0x0120, 0x6024, 0xc0d4, 0xc0f5,
+	0x0098, 0x643a, 0x633e, 0xac3e, 0xab42, 0x0046, 0x0036, 0x2400,
+	0xacac, 0x9402, 0xa836, 0x2300, 0xabb0, 0x9303, 0xa83a, 0x003e,
+	0x004e, 0x6024, 0xc0d4, 0x0000, 0x6026, 0x0005, 0xd0f4, 0x1138,
+	0xa83c, 0x603a, 0xa840, 0x603e, 0x6024, 0xc0f5, 0x6026, 0x0005,
+	0x0006, 0x0016, 0x6004, 0x908e, 0x0034, 0x01b8, 0x908e, 0x0035,
+	0x01a0, 0x908e, 0x0036, 0x0188, 0x908e, 0x0037, 0x0170, 0x908e,
+	0x0038, 0x0158, 0x908e, 0x0039, 0x0140, 0x908e, 0x003a, 0x0128,
+	0x908e, 0x003b, 0x0110, 0x9085, 0x0001, 0x001e, 0x000e, 0x0005,
+	0x0006, 0x0016, 0x0026, 0x0036, 0x00e6, 0x2001, 0x1981, 0x200c,
+	0x8000, 0x2014, 0x2001, 0x0032, 0x080c, 0x9181, 0x2001, 0x1985,
+	0x82ff, 0x1110, 0x2011, 0x0014, 0x2202, 0x2001, 0x1983, 0x200c,
+	0x8000, 0x2014, 0x2071, 0x196b, 0x711a, 0x721e, 0x2001, 0x0064,
+	0x080c, 0x9181, 0x2001, 0x1986, 0x82ff, 0x1110, 0x2011, 0x0014,
+	0x2202, 0x2001, 0x1987, 0x9288, 0x000a, 0x2102, 0x2001, 0x0017,
+	0x080c, 0xa88a, 0x2001, 0x1a88, 0x2102, 0x2001, 0x0032, 0x080c,
+	0x1693, 0x080c, 0x6a6f, 0x00ee, 0x003e, 0x002e, 0x001e, 0x000e,
+	0x0005, 0x0006, 0x0016, 0x00e6, 0x2001, 0x1985, 0x2003, 0x0028,
+	0x2001, 0x1986, 0x2003, 0x0014, 0x2071, 0x196b, 0x701b, 0x0000,
+	0x701f, 0x07d0, 0x2001, 0x1987, 0x2009, 0x001e, 0x2102, 0x2001,
+	0x0017, 0x080c, 0xa88a, 0x2001, 0x1a88, 0x2102, 0x2001, 0x0032,
+	0x080c, 0x1693, 0x00ee, 0x001e, 0x000e, 0x0005, 0x0096, 0x6060,
+	0x904d, 0x0110, 0x080c, 0x1079, 0x009e, 0x0005, 0x0005, 0x00c6,
+	0x0126, 0x2091, 0x8000, 0x080c, 0xab9a, 0x0180, 0x2b08, 0x6112,
+	0x0ca9, 0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x0033, 0x080c,
+	0xac8d, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8,
+	0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1500,
+	0x7090, 0x9086, 0x0018, 0x11e0, 0x6014, 0x2048, 0xaa3c, 0xd2e4,
+	0x1160, 0x2c78, 0x080c, 0x977c, 0x01d8, 0x707c, 0xaa50, 0x9206,
+	0x1160, 0x7080, 0xaa54, 0x9206, 0x1140, 0x6210, 0x00b6, 0x2258,
+	0xbaa0, 0x00be, 0x900e, 0x080c, 0x325e, 0x080c, 0xafff, 0x0020,
+	0x080c, 0xb5c6, 0x080c, 0xabf0, 0x00fe, 0x00ee, 0x009e, 0x0005,
+	0x7060, 0xaa54, 0x9206, 0x0d48, 0x0c80, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x080c, 0xab9a, 0x0188, 0x2b08, 0x6112, 0x080c, 0xccfe,
+	0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x004d, 0x080c, 0xac8d,
+	0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6,
+	0x0126, 0x2091, 0x8000, 0x0016, 0x080c, 0xab9a, 0x0180, 0x2b08,
+	0x6112, 0x080c, 0xccfe, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e,
+	0x080c, 0xac8d, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x001e,
+	0x9006, 0x0cd0, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0066,
+	0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1568,
+	0x7190, 0x6014, 0x2048, 0xa814, 0x8003, 0x9106, 0x1530, 0x20e1,
+	0x0000, 0x2001, 0x199f, 0x2003, 0x0000, 0x6014, 0x2048, 0xa830,
+	0x20a8, 0x8906, 0x8006, 0x8007, 0x9094, 0x003f, 0x22e8, 0x9084,
+	0xffc0, 0x9080, 0x001b, 0x20a0, 0x2001, 0x199f, 0x0016, 0x200c,
+	0x080c, 0xd5a5, 0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c38,
+	0x6014, 0x2048, 0xa867, 0x0103, 0x0010, 0x080c, 0xb5c6, 0x080c,
+	0xabf0, 0x00fe, 0x00ee, 0x009e, 0x006e, 0x005e, 0x004e, 0x003e,
+	0x002e, 0x001e, 0x0005, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800,
+	0x9186, 0x0015, 0x11b8, 0x7090, 0x9086, 0x0004, 0x1198, 0x6014,
+	0x2048, 0x2c78, 0x080c, 0x977c, 0x01a8, 0x707c, 0xaa74, 0x9206,
+	0x1130, 0x7080, 0xaa78, 0x9206, 0x1110, 0x080c, 0x320f, 0x080c,
+	0xafff, 0x0020, 0x080c, 0xb5c6, 0x080c, 0xabf0, 0x00fe, 0x00ee,
+	0x009e, 0x0005, 0x7060, 0xaa78, 0x9206, 0x0d78, 0x0c80, 0x0096,
+	0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1550, 0x7090,
+	0x9086, 0x0004, 0x1530, 0x6014, 0x2048, 0x2c78, 0x080c, 0x977c,
+	0x05f0, 0x707c, 0xaacc, 0x9206, 0x1180, 0x7080, 0xaad0, 0x9206,
+	0x1160, 0x080c, 0x320f, 0x0016, 0xa998, 0xaab0, 0x9284, 0x1000,
+	0xc0fd, 0x080c, 0x56ad, 0x001e, 0x0010, 0x080c, 0x5496, 0x080c,
+	0xc865, 0x0508, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000,
+	0x0080, 0x080c, 0xc865, 0x01b8, 0x6014, 0x2048, 0x080c, 0x5496,
+	0x1d70, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005, 0xa89b,
+	0x0004, 0x0126, 0x2091, 0x8000, 0xa867, 0x0139, 0x080c, 0x6d9f,
+	0x012e, 0x080c, 0xabf0, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x7060,
+	0xaad0, 0x9206, 0x0930, 0x0888, 0x0016, 0x0026, 0xa87c, 0xd0ac,
+	0x0178, 0xa938, 0xaa34, 0x2100, 0x9205, 0x0150, 0xa890, 0x9106,
+	0x1118, 0xa88c, 0x9206, 0x0120, 0xa992, 0xaa8e, 0x9085, 0x0001,
+	0x002e, 0x001e, 0x0005, 0x00b6, 0x00d6, 0x0036, 0x080c, 0xc865,
+	0x0904, 0xceb9, 0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x929e,
+	0x4000, 0x1580, 0x6310, 0x00c6, 0x2358, 0x2009, 0x0000, 0xa868,
+	0xd0f4, 0x1140, 0x080c, 0x6937, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0xaa96, 0xa99a, 0x20a9, 0x0004, 0xa860, 0x20e8,
+	0xa85c, 0x9080, 0x0031, 0x20a0, 0xb8c4, 0x20e0, 0xb8c8, 0x9080,
+	0x0006, 0x2098, 0x080c, 0x0fc4, 0x20a9, 0x0004, 0xa85c, 0x9080,
+	0x0035, 0x20a0, 0xb8c8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0fc4,
+	0x00ce, 0x0090, 0xaa96, 0x3918, 0x9398, 0x0007, 0x231c, 0x6004,
+	0x9086, 0x0016, 0x0110, 0xa89b, 0x0004, 0xaba2, 0x6310, 0x2358,
+	0xb804, 0x9084, 0x00ff, 0xa89e, 0x080c, 0x6d93, 0x6017, 0x0000,
+	0x009e, 0x003e, 0x00de, 0x00be, 0x0005, 0x0026, 0x0036, 0x0046,
+	0x00b6, 0x0096, 0x00f6, 0x6214, 0x2248, 0x6210, 0x2258, 0x2079,
+	0x0260, 0x9096, 0x0000, 0x11a0, 0xb814, 0x9084, 0x00ff, 0x900e,
+	0x080c, 0x2630, 0x2118, 0x831f, 0x939c, 0xff00, 0x7838, 0x9084,
+	0x00ff, 0x931d, 0x7c3c, 0x2011, 0x8018, 0x080c, 0x4b29, 0x00a8,
+	0x9096, 0x0001, 0x1148, 0x89ff, 0x0180, 0xa89b, 0x000d, 0x7838,
+	0xa8a6, 0x783c, 0xa8aa, 0x0048, 0x9096, 0x0002, 0x1130, 0xa89b,
+	0x000d, 0x7838, 0xa8a6, 0x783c, 0xa8aa, 0x00fe, 0x009e, 0x00be,
+	0x004e, 0x003e, 0x002e, 0x0005, 0x00c6, 0x0026, 0x0016, 0x9186,
+	0x0035, 0x0110, 0x6a38, 0x0008, 0x6a2c, 0x080c, 0xc853, 0x01f0,
+	0x2260, 0x6120, 0x9186, 0x0003, 0x0118, 0x9186, 0x0006, 0x1190,
+	0x6838, 0x9206, 0x0140, 0x683c, 0x9206, 0x1160, 0x6108, 0x6838,
+	0x9106, 0x1140, 0x0020, 0x6008, 0x693c, 0x9106, 0x1118, 0x6010,
+	0x6910, 0x9106, 0x001e, 0x002e, 0x00ce, 0x0005, 0x9085, 0x0001,
+	0x0cc8, 0xa974, 0xd1cc, 0x0188, 0x918c, 0x00ff, 0x918e, 0x0002,
+	0x1160, 0xa9a8, 0x918c, 0x0f00, 0x810f, 0x918e, 0x0001, 0x1128,
+	0xa834, 0xa938, 0x9115, 0x190c, 0xbec6, 0x0005, 0x0036, 0x2019,
+	0x0001, 0x0010, 0x0036, 0x901e, 0x0499, 0x01e0, 0x080c, 0xc865,
+	0x01c8, 0x080c, 0xca54, 0x6037, 0x4000, 0x6014, 0x6017, 0x0000,
+	0x0096, 0x2048, 0xa87c, 0x080c, 0xca7a, 0x1118, 0x080c, 0xb5c6,
+	0x0040, 0xa867, 0x0103, 0xa877, 0x0000, 0x83ff, 0x1129, 0x080c,
+	0x6d9f, 0x009e, 0x003e, 0x0005, 0xa880, 0xd0b4, 0x0128, 0xa87b,
+	0x0006, 0xc0ec, 0xa882, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002,
+	0x0020, 0xa87b, 0x0005, 0x080c, 0xcb6e, 0xa877, 0x0000, 0x0005,
+	0x2001, 0x1810, 0x2004, 0xd0ec, 0x0005, 0x0006, 0x2001, 0x1810,
+	0x2004, 0xd0f4, 0x000e, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004,
+	0xd0e4, 0x000e, 0x0005, 0x0036, 0x0046, 0x6010, 0x00b6, 0x2058,
+	0xbba0, 0x00be, 0x2021, 0x0007, 0x080c, 0x4ce0, 0x004e, 0x003e,
+	0x0005, 0x0c51, 0x1d81, 0x0005, 0x2001, 0x1985, 0x2004, 0x601a,
+	0x0005, 0x2001, 0x1987, 0x2004, 0x604a, 0x0005, 0x080c, 0xabf0,
+	0x0804, 0x96bd, 0x611c, 0xd1fc, 0xa97c, 0x1108, 0xd1e4, 0x0005,
+	0x601c, 0xd0fc, 0xa87c, 0x1108, 0xd0e4, 0x0005, 0x601c, 0xd0fc,
+	0xc0fc, 0x601e, 0xa87c, 0x1108, 0xd0e4, 0x0005, 0x6044, 0xd0fc,
+	0x1138, 0xd0bc, 0x0198, 0xc0bc, 0x6046, 0x6003, 0x0002, 0x0070,
+	0xd0ac, 0x1160, 0xd0dc, 0x1128, 0x908c, 0x000f, 0x9186, 0x0005,
+	0x1118, 0x6003, 0x0003, 0x0010, 0x6003, 0x0001, 0x0005, 0x00b6,
+	0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0d7d, 0x001b, 0x006e,
+	0x00be, 0x0005, 0xcff2, 0xd700, 0xd851, 0xcff2, 0xcff2, 0xcff2,
+	0xcff2, 0xcff2, 0xd029, 0xd8d5, 0xcff2, 0xcff2, 0xcff2, 0xcff2,
+	0xcff2, 0xcff2, 0x080c, 0x0d7d, 0x0066, 0x6000, 0x90b2, 0x0016,
+	0x1a0c, 0x0d7d, 0x0013, 0x006e, 0x0005, 0xd00d, 0xddf6, 0xd00d,
+	0xd00d, 0xd00d, 0xd00d, 0xd00d, 0xd00d, 0xdda5, 0xde48, 0xd00d,
+	0xe4a0, 0xe4d4, 0xe4a0, 0xe4d4, 0xd00d, 0x080c, 0x0d7d, 0x6000,
+	0x9082, 0x0016, 0x1a0c, 0x0d7d, 0x6000, 0x000a, 0x0005, 0xd027,
+	0xdab2, 0xdb7d, 0xdba0, 0xdc1c, 0xd027, 0xdd17, 0xdca4, 0xd8df,
+	0xdd7d, 0xdd92, 0xd027, 0xd027, 0xd027, 0xd027, 0xd027, 0x080c,
+	0x0d7d, 0x91b2, 0x0053, 0x1a0c, 0x0d7d, 0x2100, 0x91b2, 0x0040,
+	0x1a04, 0xd476, 0x0002, 0xd073, 0xd267, 0xd073, 0xd073, 0xd073,
+	0xd270, 0xd073, 0xd073, 0xd073, 0xd073, 0xd073, 0xd073, 0xd073,
+	0xd073, 0xd073, 0xd073, 0xd073, 0xd073, 0xd073, 0xd073, 0xd073,
+	0xd073, 0xd073, 0xd075, 0xd0dc, 0xd0eb, 0xd14f, 0xd17a, 0xd1f3,
+	0xd252, 0xd073, 0xd073, 0xd273, 0xd073, 0xd073, 0xd288, 0xd295,
+	0xd073, 0xd073, 0xd073, 0xd073, 0xd073, 0xd318, 0xd073, 0xd073,
+	0xd32c, 0xd073, 0xd073, 0xd2e7, 0xd073, 0xd073, 0xd073, 0xd344,
+	0xd073, 0xd073, 0xd073, 0xd3c1, 0xd073, 0xd073, 0xd073, 0xd073,
+	0xd073, 0xd073, 0xd43e, 0x080c, 0x0d7d, 0x080c, 0x6a4c, 0x1150,
+	0x2001, 0x1837, 0x2004, 0xd0cc, 0x1128, 0x9084, 0x0009, 0x9086,
+	0x0008, 0x1140, 0x6007, 0x0009, 0x602f, 0x0009, 0x6017, 0x0000,
+	0x0804, 0xd260, 0x080c, 0x69e8, 0x00e6, 0x00c6, 0x0036, 0x0026,
+	0x0016, 0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c,
+	0xa899, 0x080c, 0x93c6, 0x0076, 0x903e, 0x080c, 0x928f, 0x2c08,
+	0x080c, 0xe038, 0x007e, 0x001e, 0x080c, 0xa8b5, 0x001e, 0x002e,
+	0x003e, 0x00ce, 0x00ee, 0x6610, 0x2658, 0x080c, 0x6653, 0xbe04,
+	0x9684, 0x00ff, 0x9082, 0x0006, 0x1268, 0x0016, 0x0026, 0x6210,
+	0x00b6, 0x2258, 0xbaa0, 0x00be, 0x2c08, 0x080c, 0xe6fd, 0x002e,
+	0x001e, 0x1178, 0x080c, 0xdf66, 0x1904, 0xd147, 0x080c, 0xdf02,
+	0x1120, 0x6007, 0x0008, 0x0804, 0xd260, 0x6007, 0x0009, 0x0804,
+	0xd260, 0x080c, 0xe199, 0x0128, 0x080c, 0xdf66, 0x0d78, 0x0804,
+	0xd147, 0x6017, 0x1900, 0x0c88, 0x080c, 0x3346, 0x1904, 0xd473,
+	0x6106, 0x080c, 0xdeb3, 0x6007, 0x0006, 0x0804, 0xd260, 0x6007,
+	0x0007, 0x0804, 0xd260, 0x080c, 0xe510, 0x1904, 0xd473, 0x080c,
+	0x3346, 0x1904, 0xd473, 0x00d6, 0x6610, 0x2658, 0xbe04, 0x9684,
+	0x00ff, 0x9082, 0x0006, 0x1220, 0x2001, 0x0001, 0x080c, 0x6580,
+	0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0188, 0x9686, 0x0004,
+	0x0170, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006, 0x0140, 0x9686,
+	0x0004, 0x0128, 0x9686, 0x0005, 0x0110, 0x00de, 0x0480, 0x00e6,
+	0x2071, 0x0260, 0x7034, 0x9084, 0x0003, 0x1140, 0x7034, 0x9082,
+	0x0014, 0x0220, 0x7030, 0x9084, 0x0003, 0x0130, 0x00ee, 0x6017,
+	0x0000, 0x602f, 0x0007, 0x00b0, 0x00ee, 0x080c, 0xdfce, 0x1190,
+	0x9686, 0x0006, 0x1140, 0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e,
+	0x080c, 0x325e, 0x002e, 0x080c, 0x66df, 0x6007, 0x000a, 0x00de,
+	0x0804, 0xd260, 0x6007, 0x000b, 0x00de, 0x0804, 0xd260, 0x080c,
+	0x320f, 0x080c, 0xcf99, 0x6007, 0x0001, 0x0804, 0xd260, 0x080c,
+	0xe510, 0x1904, 0xd473, 0x080c, 0x3346, 0x1904, 0xd473, 0x2071,
+	0x0260, 0x7034, 0x90b4, 0x0003, 0x1948, 0x90b2, 0x0014, 0x0a30,
+	0x7030, 0x9084, 0x0003, 0x1910, 0x6610, 0x2658, 0xbe04, 0x9686,
+	0x0707, 0x09e8, 0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c,
+	0x325e, 0x002e, 0x6007, 0x000c, 0x2001, 0x0001, 0x080c, 0xe6dd,
+	0x0804, 0xd260, 0x080c, 0x6a4c, 0x1140, 0x2001, 0x1837, 0x2004,
+	0x9084, 0x0009, 0x9086, 0x0008, 0x1110, 0x0804, 0xd082, 0x080c,
+	0x69e8, 0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006,
+	0x06c8, 0x1138, 0x0026, 0x2001, 0x0006, 0x080c, 0x65c0, 0x002e,
+	0x0050, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0004, 0x0120, 0x9686,
+	0x0006, 0x1904, 0xd147, 0x080c, 0xdfdb, 0x1120, 0x6007, 0x000e,
+	0x0804, 0xd260, 0x0046, 0x6410, 0x2458, 0xbca0, 0x0046, 0x080c,
+	0x320f, 0x080c, 0xcf99, 0x004e, 0x0016, 0x9006, 0x2009, 0x1848,
+	0x210c, 0xd1a4, 0x0148, 0x2009, 0x0029, 0x080c, 0xe316, 0x6010,
+	0x2058, 0xb800, 0xc0e5, 0xb802, 0x001e, 0x004e, 0x6007, 0x0001,
+	0x0804, 0xd260, 0x2001, 0x0001, 0x080c, 0x6580, 0x0156, 0x0016,
+	0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x0270,
+	0x080c, 0xbbc1, 0x003e, 0x002e, 0x001e, 0x015e, 0x9005, 0x0168,
+	0x96b4, 0xff00, 0x8637, 0x9682, 0x0004, 0x0a04, 0xd147, 0x9682,
+	0x0007, 0x0a04, 0xd1a3, 0x0804, 0xd147, 0x6017, 0x1900, 0x6007,
+	0x0009, 0x0804, 0xd260, 0x080c, 0x6a4c, 0x1140, 0x2001, 0x1837,
+	0x2004, 0x9084, 0x0009, 0x9086, 0x0008, 0x1110, 0x0804, 0xd082,
+	0x080c, 0x69e8, 0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff, 0x0006,
+	0x9086, 0x0001, 0x000e, 0x0170, 0x9082, 0x0006, 0x0698, 0x0150,
+	0x96b4, 0xff00, 0x8637, 0x9686, 0x0004, 0x0120, 0x9686, 0x0006,
+	0x1904, 0xd147, 0x080c, 0xe009, 0x1130, 0x080c, 0xdf02, 0x1118,
+	0x6007, 0x0010, 0x04e8, 0x0046, 0x6410, 0x2458, 0xbca0, 0x0046,
+	0x080c, 0x320f, 0x080c, 0xcf99, 0x004e, 0x0016, 0x9006, 0x2009,
+	0x1848, 0x210c, 0xd1a4, 0x0148, 0x2009, 0x0029, 0x080c, 0xe316,
+	0x6010, 0x2058, 0xb800, 0xc0e5, 0xb802, 0x001e, 0x004e, 0x6007,
+	0x0001, 0x00f0, 0x080c, 0xe199, 0x0140, 0x96b4, 0xff00, 0x8637,
+	0x9686, 0x0006, 0x0978, 0x0804, 0xd147, 0x6017, 0x1900, 0x6007,
+	0x0009, 0x0070, 0x080c, 0x3346, 0x1904, 0xd473, 0x080c, 0xe510,
+	0x1904, 0xd473, 0x080c, 0xd640, 0x1904, 0xd147, 0x6007, 0x0012,
+	0x6003, 0x0001, 0x080c, 0x9240, 0x080c, 0x96bd, 0x0005, 0x6007,
+	0x0001, 0x6003, 0x0001, 0x080c, 0x9240, 0x080c, 0x96bd, 0x0cb0,
+	0x6007, 0x0005, 0x0c68, 0x080c, 0xe510, 0x1904, 0xd473, 0x080c,
+	0x3346, 0x1904, 0xd473, 0x080c, 0xd640, 0x1904, 0xd147, 0x6007,
+	0x0020, 0x6003, 0x0001, 0x080c, 0x9240, 0x080c, 0x96bd, 0x0005,
+	0x080c, 0x3346, 0x1904, 0xd473, 0x6007, 0x0023, 0x6003, 0x0001,
+	0x080c, 0x9240, 0x080c, 0x96bd, 0x0005, 0x080c, 0xe510, 0x1904,
+	0xd473, 0x080c, 0x3346, 0x1904, 0xd473, 0x080c, 0xd640, 0x1904,
+	0xd147, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260, 0x7244, 0x9286,
+	0xffff, 0x0180, 0x2c08, 0x080c, 0xc853, 0x01b0, 0x2260, 0x7240,
+	0x6008, 0x9206, 0x1188, 0x6010, 0x9190, 0x0004, 0x2214, 0x9206,
+	0x01b8, 0x0050, 0x7240, 0x2c08, 0x9006, 0x080c, 0xe2e0, 0x1180,
+	0x7244, 0x9286, 0xffff, 0x01b0, 0x2160, 0x6007, 0x0026, 0x6017,
+	0x1700, 0x7214, 0x9296, 0xffff, 0x1180, 0x6007, 0x0025, 0x0068,
+	0x6020, 0x9086, 0x0007, 0x1d80, 0x6004, 0x9086, 0x0024, 0x1110,
+	0x080c, 0xabf0, 0x2160, 0x6007, 0x0025, 0x6003, 0x0001, 0x080c,
+	0x9240, 0x080c, 0x96bd, 0x00ee, 0x002e, 0x001e, 0x0005, 0x2001,
+	0x0001, 0x080c, 0x6580, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9,
+	0x0004, 0x2019, 0x1805, 0x2011, 0x0276, 0x080c, 0xbbc1, 0x003e,
+	0x002e, 0x001e, 0x015e, 0x0120, 0x6007, 0x0031, 0x0804, 0xd260,
+	0x080c, 0xb832, 0x080c, 0x74ec, 0x1190, 0x0006, 0x0026, 0x0036,
+	0x080c, 0x7506, 0x1138, 0x080c, 0x77ef, 0x080c, 0x6044, 0x080c,
+	0x741d, 0x0010, 0x080c, 0x74c0, 0x003e, 0x002e, 0x000e, 0x0005,
+	0x080c, 0x3346, 0x1904, 0xd473, 0x080c, 0xd640, 0x1904, 0xd147,
+	0x6106, 0x080c, 0xd65c, 0x1120, 0x6007, 0x002b, 0x0804, 0xd260,
+	0x6007, 0x002c, 0x0804, 0xd260, 0x080c, 0xe510, 0x1904, 0xd473,
+	0x080c, 0x3346, 0x1904, 0xd473, 0x080c, 0xd640, 0x1904, 0xd147,
+	0x6106, 0x080c, 0xd661, 0x1120, 0x6007, 0x002e, 0x0804, 0xd260,
+	0x6007, 0x002f, 0x0804, 0xd260, 0x080c, 0x3346, 0x1904, 0xd473,
+	0x00e6, 0x00d6, 0x00c6, 0x6010, 0x2058, 0xb904, 0x9184, 0x00ff,
+	0x9086, 0x0006, 0x0158, 0x9184, 0xff00, 0x8007, 0x9086, 0x0006,
+	0x0128, 0x00ce, 0x00de, 0x00ee, 0x0804, 0xd267, 0x080c, 0x56f9,
+	0xd0e4, 0x0904, 0xd3be, 0x2071, 0x026c, 0x7010, 0x603a, 0x7014,
+	0x603e, 0x7108, 0x720c, 0x080c, 0x6a8a, 0x0140, 0x6010, 0x2058,
+	0xb810, 0x9106, 0x1118, 0xb814, 0x9206, 0x0510, 0x080c, 0x6a86,
+	0x15b8, 0x2069, 0x1800, 0x6880, 0x9206, 0x1590, 0x687c, 0x9106,
+	0x1578, 0x7210, 0x080c, 0xc853, 0x0590, 0x080c, 0xd52b, 0x0578,
+	0x080c, 0xe392, 0x0560, 0x622e, 0x6007, 0x0036, 0x6003, 0x0001,
+	0x2009, 0x8020, 0x080c, 0x9239, 0x00ce, 0x00de, 0x00ee, 0x0005,
+	0x7214, 0x9286, 0xffff, 0x0150, 0x080c, 0xc853, 0x01c0, 0x9280,
+	0x0002, 0x2004, 0x7110, 0x9106, 0x1190, 0x08e0, 0x7210, 0x2c08,
+	0x9085, 0x0001, 0x080c, 0xe2e0, 0x2c10, 0x2160, 0x0140, 0x0890,
+	0x6007, 0x0037, 0x602f, 0x0009, 0x6017, 0x1500, 0x08b8, 0x6007,
+	0x0037, 0x602f, 0x0003, 0x6017, 0x1700, 0x0880, 0x6007, 0x0012,
+	0x0868, 0x080c, 0x3346, 0x1904, 0xd473, 0x6010, 0x2058, 0xb804,
+	0x9084, 0xff00, 0x8007, 0x9086, 0x0006, 0x1904, 0xd267, 0x00e6,
+	0x00d6, 0x00c6, 0x080c, 0x56f9, 0xd0e4, 0x0904, 0xd436, 0x2069,
+	0x1800, 0x2071, 0x026c, 0x7008, 0x603a, 0x720c, 0x623e, 0x9286,
+	0xffff, 0x1150, 0x7208, 0x00c6, 0x2c08, 0x9085, 0x0001, 0x080c,
+	0xe2e0, 0x2c10, 0x00ce, 0x05e8, 0x080c, 0xc853, 0x05d0, 0x7108,
+	0x9280, 0x0002, 0x2004, 0x9106, 0x15a0, 0x00c6, 0x0026, 0x2260,
+	0x080c, 0xc446, 0x002e, 0x00ce, 0x7118, 0x918c, 0xff00, 0x810f,
+	0x9186, 0x0001, 0x0178, 0x9186, 0x0005, 0x0118, 0x9186, 0x0007,
+	0x1198, 0x9280, 0x0005, 0x2004, 0x9005, 0x0170, 0x080c, 0xd52b,
+	0x0904, 0xd3b7, 0x0056, 0x7510, 0x7614, 0x080c, 0xe3ab, 0x005e,
+	0x00ce, 0x00de, 0x00ee, 0x0005, 0x6007, 0x003b, 0x602f, 0x0009,
+	0x6017, 0x2a00, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x9239,
+	0x0c78, 0x6007, 0x003b, 0x602f, 0x0003, 0x6017, 0x0300, 0x6003,
+	0x0001, 0x2009, 0x8020, 0x080c, 0x9239, 0x0c10, 0x6007, 0x003b,
+	0x602f, 0x000b, 0x6017, 0x0000, 0x0804, 0xd38e, 0x00e6, 0x0026,
+	0x080c, 0x6a4c, 0x0550, 0x080c, 0x69e8, 0x080c, 0xe582, 0x1518,
+	0x2071, 0x1800, 0x70dc, 0x9085, 0x0003, 0x70de, 0x00f6, 0x2079,
+	0x0100, 0x72b0, 0x9284, 0x00ff, 0x707e, 0x78e6, 0x9284, 0xff00,
+	0x7280, 0x9205, 0x7082, 0x78ea, 0x00fe, 0x70e7, 0x0000, 0x080c,
+	0x6a8a, 0x0120, 0x2011, 0x1a08, 0x2013, 0x07d0, 0xd0ac, 0x1128,
+	0x080c, 0x2fe0, 0x0010, 0x080c, 0xe5b4, 0x002e, 0x00ee, 0x080c,
+	0xabf0, 0x0804, 0xd266, 0x080c, 0xabf0, 0x0005, 0x2600, 0x0002,
+	0xd48a, 0xd4bb, 0xd4cc, 0xd48a, 0xd48a, 0xd48c, 0xd4dd, 0xd48a,
+	0xd48a, 0xd48a, 0xd4a9, 0xd48a, 0xd48a, 0xd48a, 0xd4e8, 0xd4f5,
+	0xd526, 0xd48a, 0x080c, 0x0d7d, 0x080c, 0xe510, 0x1d20, 0x080c,
+	0x3346, 0x1d08, 0x080c, 0xd640, 0x1148, 0x7038, 0x6016, 0x6007,
+	0x0045, 0x6003, 0x0001, 0x080c, 0x9240, 0x0005, 0x080c, 0x320f,
+	0x080c, 0xcf99, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x9240,
+	0x0005, 0x080c, 0xe510, 0x1938, 0x080c, 0x3346, 0x1920, 0x080c,
+	0xd640, 0x1d60, 0x703c, 0x6016, 0x6007, 0x004a, 0x6003, 0x0001,
+	0x080c, 0x9240, 0x0005, 0x080c, 0x3346, 0x1904, 0xd473, 0x2009,
+	0x0041, 0x080c, 0xe5bd, 0x6007, 0x0047, 0x6003, 0x0001, 0x080c,
+	0x9240, 0x080c, 0x96bd, 0x0005, 0x080c, 0x3346, 0x1904, 0xd473,
+	0x2009, 0x0042, 0x080c, 0xe5bd, 0x6007, 0x0047, 0x6003, 0x0001,
+	0x080c, 0x9240, 0x080c, 0x96bd, 0x0005, 0x080c, 0x3346, 0x1904,
+	0xd473, 0x2009, 0x0046, 0x080c, 0xe5bd, 0x080c, 0xabf0, 0x0005,
+	0x080c, 0xd548, 0x0904, 0xd473, 0x6007, 0x004e, 0x6003, 0x0001,
+	0x080c, 0x9240, 0x080c, 0x96bd, 0x0005, 0x6007, 0x004f, 0x6017,
+	0x0000, 0x7134, 0x918c, 0x00ff, 0x81ff, 0x0508, 0x9186, 0x0001,
+	0x1160, 0x7140, 0x2001, 0x19bc, 0x2004, 0x9106, 0x11b0, 0x7144,
+	0x2001, 0x19bd, 0x2004, 0x9106, 0x0190, 0x9186, 0x0002, 0x1168,
+	0x2011, 0x0276, 0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019,
+	0x000a, 0x080c, 0xbbd5, 0x009e, 0x0110, 0x6017, 0x0001, 0x6003,
+	0x0001, 0x080c, 0x9240, 0x080c, 0x96bd, 0x0005, 0x6007, 0x0050,
+	0x703c, 0x6016, 0x0ca0, 0x0016, 0x00e6, 0x2071, 0x0260, 0x00b6,
+	0x00c6, 0x2260, 0x6010, 0x2058, 0xb8d4, 0xd084, 0x0150, 0x7128,
+	0x6050, 0x9106, 0x1120, 0x712c, 0x604c, 0x9106, 0x0110, 0x9006,
+	0x0010, 0x9085, 0x0001, 0x00ce, 0x00be, 0x00ee, 0x001e, 0x0005,
+	0x0016, 0x0096, 0x0086, 0x00e6, 0x01c6, 0x01d6, 0x0126, 0x2091,
+	0x8000, 0x2071, 0x1800, 0x7090, 0x908a, 0x00f9, 0x16e8, 0x20e1,
+	0x0000, 0x2001, 0x199f, 0x2003, 0x0000, 0x080c, 0x1060, 0x05a0,
+	0x2900, 0x6016, 0x7090, 0x8004, 0xa816, 0x908a, 0x001e, 0x02d0,
+	0xa833, 0x001e, 0x20a9, 0x001e, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x001b, 0x20a0, 0x2001, 0x199f, 0x0016, 0x200c, 0x0471, 0x001e,
+	0x2940, 0x080c, 0x1060, 0x01c0, 0x2900, 0xa006, 0x2100, 0x81ff,
+	0x0180, 0x0c18, 0xa832, 0x20a8, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x001b, 0x20a0, 0x2001, 0x199f, 0x0016, 0x200c, 0x00b1, 0x001e,
+	0x0000, 0x9085, 0x0001, 0x0048, 0x2071, 0x1800, 0x7093, 0x0000,
+	0x6014, 0x2048, 0x080c, 0x0ff9, 0x9006, 0x012e, 0x01de, 0x01ce,
+	0x00ee, 0x008e, 0x009e, 0x001e, 0x0005, 0x0006, 0x0016, 0x0026,
+	0x0036, 0x00c6, 0x918c, 0xffff, 0x11a8, 0x080c, 0x21b2, 0x2099,
+	0x026c, 0x2001, 0x0014, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003,
+	0x00f8, 0x20a8, 0x4003, 0x22a8, 0x8108, 0x080c, 0x21b2, 0x2099,
+	0x0260, 0x0ca8, 0x080c, 0x21b2, 0x2061, 0x199f, 0x6004, 0x2098,
+	0x6008, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x0048, 0x20a8,
+	0x4003, 0x22a8, 0x8108, 0x080c, 0x21b2, 0x2099, 0x0260, 0x0ca8,
+	0x2061, 0x199f, 0x2019, 0x0280, 0x3300, 0x931e, 0x0110, 0x6006,
+	0x0020, 0x2001, 0x0260, 0x6006, 0x8108, 0x2162, 0x9292, 0x0021,
+	0x9296, 0xffff, 0x620a, 0x00ce, 0x003e, 0x002e, 0x001e, 0x000e,
+	0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00c6, 0x81ff, 0x11b8,
+	0x080c, 0x21ca, 0x20a1, 0x024c, 0x2001, 0x0014, 0x3518, 0x9312,
+	0x1218, 0x23a8, 0x4003, 0x0418, 0x20a8, 0x4003, 0x82ff, 0x01f8,
+	0x22a8, 0x8108, 0x080c, 0x21ca, 0x20a1, 0x0240, 0x0c98, 0x080c,
+	0x21ca, 0x2061, 0x19a2, 0x6004, 0x20a0, 0x6008, 0x3518, 0x9312,
+	0x1218, 0x23a8, 0x4003, 0x0058, 0x20a8, 0x4003, 0x82ff, 0x0138,
+	0x22a8, 0x8108, 0x080c, 0x21ca, 0x20a1, 0x0240, 0x0c98, 0x2061,
+	0x19a2, 0x2019, 0x0260, 0x3400, 0x931e, 0x0110, 0x6006, 0x0020,
+	0x2001, 0x0240, 0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296,
+	0xffff, 0x620a, 0x00ce, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005,
+	0x00b6, 0x0066, 0x6610, 0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637,
+	0x9686, 0x0006, 0x0170, 0x9686, 0x0004, 0x0158, 0xbe04, 0x96b4,
+	0x00ff, 0x9686, 0x0006, 0x0128, 0x9686, 0x0004, 0x0110, 0x9085,
+	0x0001, 0x006e, 0x00be, 0x0005, 0x00d6, 0x080c, 0xd6d6, 0x00de,
+	0x0005, 0x00d6, 0x080c, 0xd6e3, 0x1520, 0x680c, 0x908c, 0xff00,
+	0x6820, 0x9084, 0x00ff, 0x9115, 0x6216, 0x6824, 0x602e, 0xd1e4,
+	0x0130, 0x9006, 0x080c, 0xe6dd, 0x2009, 0x0001, 0x0078, 0xd1ec,
+	0x0180, 0x6920, 0x918c, 0x00ff, 0x6824, 0x080c, 0x2630, 0x1148,
+	0x2001, 0x0001, 0x080c, 0xe6dd, 0x2110, 0x900e, 0x080c, 0x325e,
+	0x0018, 0x9085, 0x0001, 0x0008, 0x9006, 0x00de, 0x0005, 0x00b6,
+	0x00c6, 0x080c, 0xac60, 0x0598, 0x0016, 0x0026, 0x00c6, 0x2011,
+	0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2630, 0x1568, 0x080c,
+	0x65e3, 0x1550, 0xbe12, 0xbd16, 0x00ce, 0x002e, 0x001e, 0x2b00,
+	0x6012, 0x080c, 0xe510, 0x11c8, 0x080c, 0x3346, 0x11b0, 0x080c,
+	0xd640, 0x0500, 0x2001, 0x0007, 0x080c, 0x6594, 0x2001, 0x0007,
+	0x080c, 0x65c0, 0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001,
+	0x6003, 0x0001, 0x080c, 0x9240, 0x0010, 0x080c, 0xabf0, 0x9085,
+	0x0001, 0x00ce, 0x00be, 0x0005, 0x080c, 0xabf0, 0x00ce, 0x002e,
+	0x001e, 0x0ca8, 0x080c, 0xabf0, 0x9006, 0x0c98, 0x2069, 0x026d,
+	0x6800, 0x9082, 0x0010, 0x1228, 0x6017, 0x0000, 0x9085, 0x0001,
+	0x0008, 0x9006, 0x0005, 0x6017, 0x0000, 0x2069, 0x026c, 0x6808,
+	0x9084, 0xff00, 0x9086, 0x0800, 0x1190, 0x6904, 0x9186, 0x0018,
+	0x0118, 0x9186, 0x0014, 0x1158, 0x810f, 0x6800, 0x9084, 0x00ff,
+	0x910d, 0x6162, 0x908e, 0x0014, 0x0110, 0x908e, 0x0010, 0x0005,
+	0x6004, 0x90b2, 0x0053, 0x1a0c, 0x0d7d, 0x91b6, 0x0013, 0x1130,
+	0x2008, 0x91b2, 0x0040, 0x1a04, 0xd825, 0x0092, 0x91b6, 0x0027,
+	0x0120, 0x91b6, 0x0014, 0x190c, 0x0d7d, 0x2001, 0x0007, 0x080c,
+	0x65c0, 0x080c, 0x95ff, 0x080c, 0xac2b, 0x080c, 0x96bd, 0x0005,
+	0xd760, 0xd762, 0xd760, 0xd760, 0xd760, 0xd762, 0xd76f, 0xd822,
+	0xd7bf, 0xd822, 0xd7d3, 0xd822, 0xd76f, 0xd822, 0xd81a, 0xd822,
+	0xd81a, 0xd822, 0xd822, 0xd760, 0xd760, 0xd760, 0xd760, 0xd760,
+	0xd760, 0xd760, 0xd760, 0xd760, 0xd760, 0xd760, 0xd762, 0xd760,
+	0xd822, 0xd760, 0xd760, 0xd822, 0xd760, 0xd81f, 0xd822, 0xd760,
+	0xd760, 0xd760, 0xd760, 0xd822, 0xd822, 0xd760, 0xd822, 0xd822,
+	0xd760, 0xd76a, 0xd760, 0xd760, 0xd760, 0xd760, 0xd81e, 0xd822,
+	0xd760, 0xd760, 0xd822, 0xd822, 0xd760, 0xd760, 0xd760, 0xd760,
+	0x080c, 0x0d7d, 0x080c, 0xcf9c, 0x6003, 0x0002, 0x080c, 0x96bd,
+	0x0804, 0xd824, 0x9006, 0x080c, 0x6580, 0x0804, 0xd822, 0x080c,
+	0x6a86, 0x1904, 0xd822, 0x9006, 0x080c, 0x6580, 0x6010, 0x2058,
+	0xb810, 0x9086, 0x00ff, 0x1140, 0x00f6, 0x2079, 0x1800, 0x78a8,
+	0x8000, 0x78aa, 0x00fe, 0x0428, 0x6010, 0x2058, 0xb884, 0x9005,
+	0x1178, 0x080c, 0xcf84, 0x1904, 0xd822, 0x0036, 0x0046, 0xbba0,
+	0x2021, 0x0007, 0x080c, 0x4ce0, 0x004e, 0x003e, 0x0804, 0xd822,
+	0x080c, 0x3377, 0x1904, 0xd822, 0x2001, 0x1800, 0x2004, 0x9086,
+	0x0002, 0x1138, 0x00f6, 0x2079, 0x1800, 0x78a8, 0x8000, 0x78aa,
+	0x00fe, 0x2001, 0x0002, 0x080c, 0x6594, 0x6023, 0x0001, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x080c, 0x9240, 0x080c, 0x96bd, 0x6110,
+	0x2158, 0x2009, 0x0001, 0x080c, 0x865f, 0x0804, 0xd824, 0x6610,
+	0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0904,
+	0xd822, 0x9686, 0x0004, 0x0904, 0xd822, 0x080c, 0x8ee5, 0x2001,
+	0x0004, 0x0804, 0xd820, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003,
+	0x1158, 0x0036, 0x0046, 0x6010, 0x2058, 0xbba0, 0x2021, 0x0006,
+	0x080c, 0x4ce0, 0x004e, 0x003e, 0x2001, 0x0006, 0x080c, 0xd83e,
+	0x6610, 0x2658, 0xbe04, 0x0066, 0x96b4, 0xff00, 0x8637, 0x9686,
+	0x0006, 0x006e, 0x0168, 0x2001, 0x0006, 0x080c, 0x65c0, 0x9284,
+	0x00ff, 0x908e, 0x0007, 0x1120, 0x2001, 0x0006, 0x080c, 0x6594,
+	0x080c, 0x6a86, 0x11f8, 0x2001, 0x1837, 0x2004, 0xd0a4, 0x01d0,
+	0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006, 0x01a0, 0x00f6, 0x2079,
+	0x1800, 0x78a8, 0x8000, 0x78aa, 0x00fe, 0x0804, 0xd7a9, 0x2001,
+	0x0004, 0x0030, 0x2001, 0x0006, 0x0409, 0x0020, 0x0018, 0x0010,
+	0x080c, 0x65c0, 0x080c, 0xabf0, 0x0005, 0x2600, 0x0002, 0xd839,
+	0xd839, 0xd839, 0xd839, 0xd839, 0xd83b, 0xd839, 0xd83b, 0xd839,
+	0xd839, 0xd83b, 0xd839, 0xd839, 0xd839, 0xd83b, 0xd83b, 0xd83b,
+	0xd83b, 0x080c, 0x0d7d, 0x080c, 0xabf0, 0x0005, 0x0016, 0x00b6,
+	0x00d6, 0x6110, 0x2158, 0xb900, 0xd184, 0x0138, 0x080c, 0x6594,
+	0x9006, 0x080c, 0x6580, 0x080c, 0x323e, 0x00de, 0x00be, 0x001e,
+	0x0005, 0x6610, 0x2658, 0xb804, 0x9084, 0xff00, 0x8007, 0x90b2,
+	0x000c, 0x1a0c, 0x0d7d, 0x91b6, 0x0015, 0x1110, 0x003b, 0x0028,
+	0x91b6, 0x0016, 0x190c, 0x0d7d, 0x006b, 0x0005, 0xb6af, 0xb6af,
+	0xb6af, 0xb6af, 0xd8d3, 0xb6af, 0xd8bd, 0xd87e, 0xb6af, 0xb6af,
+	0xb6af, 0xb6af, 0xb6af, 0xb6af, 0xb6af, 0xb6af, 0xd8d3, 0xb6af,
+	0xd8bd, 0xd8c4, 0xb6af, 0xb6af, 0xb6af, 0xb6af, 0x00f6, 0x080c,
+	0x6a86, 0x11d8, 0x080c, 0xcf84, 0x11c0, 0x6010, 0x905d, 0x01a8,
+	0xb884, 0x9005, 0x0190, 0x9006, 0x080c, 0x6580, 0x2001, 0x0002,
+	0x080c, 0x6594, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002,
+	0x080c, 0x9240, 0x080c, 0x96bd, 0x00f0, 0x2011, 0x0263, 0x2204,
+	0x8211, 0x220c, 0x080c, 0x2630, 0x11b0, 0x080c, 0x6644, 0x0118,
+	0x080c, 0xabf0, 0x0080, 0xb810, 0x0006, 0xb814, 0x0006, 0xb884,
+	0x0006, 0x080c, 0x605e, 0x000e, 0xb886, 0x000e, 0xb816, 0x000e,
+	0xb812, 0x080c, 0xabf0, 0x00fe, 0x0005, 0x6604, 0x96b6, 0x001e,
+	0x1110, 0x080c, 0xabf0, 0x0005, 0x080c, 0xba3a, 0x1148, 0x6003,
+	0x0001, 0x6007, 0x0001, 0x080c, 0x9240, 0x080c, 0x96bd, 0x0010,
+	0x080c, 0xabf0, 0x0005, 0x0804, 0xabf0, 0x6004, 0x908a, 0x0053,
+	0x1a0c, 0x0d7d, 0x080c, 0x95ff, 0x080c, 0xac2b, 0x0005, 0x9182,
+	0x0040, 0x0002, 0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6, 0xd8f8, 0xd8f6,
+	0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6,
+	0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6, 0xd8f6, 0x080c, 0x0d7d,
+	0x0096, 0x00b6, 0x00d6, 0x00e6, 0x00f6, 0x0046, 0x0026, 0x6210,
+	0x2258, 0xb8bc, 0x9005, 0x11b0, 0x6007, 0x0044, 0x2071, 0x0260,
+	0x7444, 0x94a4, 0xff00, 0x0904, 0xd95f, 0x080c, 0xe6d1, 0x1170,
+	0x9486, 0x2000, 0x1158, 0x2009, 0x0001, 0x2011, 0x0200, 0x080c,
+	0x8902, 0x0020, 0x9026, 0x080c, 0xe555, 0x0c30, 0x080c, 0x1047,
+	0x090c, 0x0d7d, 0x6003, 0x0007, 0xa867, 0x010d, 0x9006, 0xa802,
+	0xa86a, 0xac8a, 0x2c00, 0xa88e, 0x6008, 0xa8e2, 0x6010, 0x2058,
+	0xb8a0, 0x7130, 0xa97a, 0x0016, 0xa876, 0xa87f, 0x0000, 0xa883,
+	0x0000, 0xa887, 0x0036, 0x080c, 0x6d9f, 0x001e, 0x080c, 0xe6d1,
+	0x1904, 0xd9bf, 0x9486, 0x2000, 0x1130, 0x2019, 0x0017, 0x080c,
+	0xe286, 0x0804, 0xd9bf, 0x9486, 0x0200, 0x1120, 0x080c, 0xe216,
+	0x0804, 0xd9bf, 0x9486, 0x0400, 0x0120, 0x9486, 0x1000, 0x1904,
+	0xd9bf, 0x2019, 0x0002, 0x080c, 0xe235, 0x0804, 0xd9bf, 0x2069,
+	0x1a6e, 0x6a00, 0xd284, 0x0904, 0xda29, 0x9284, 0x0300, 0x1904,
+	0xda22, 0x6804, 0x9005, 0x0904, 0xda0a, 0x2d78, 0x6003, 0x0007,
+	0x080c, 0x1060, 0x0904, 0xd9cb, 0x7800, 0xd08c, 0x1118, 0x7804,
+	0x8001, 0x7806, 0x6017, 0x0000, 0x2001, 0x180f, 0x2004, 0xd084,
+	0x1904, 0xda2d, 0x9006, 0xa802, 0xa867, 0x0116, 0xa86a, 0x6008,
+	0xa8e2, 0x2c00, 0xa87a, 0x6010, 0x2058, 0xb8a0, 0x7130, 0xa9b6,
+	0xa876, 0xb928, 0xa9ba, 0xb92c, 0xa9be, 0xb930, 0xa9c2, 0xb934,
+	0xa9c6, 0xa883, 0x003d, 0x7044, 0x9084, 0x0003, 0x9080, 0xd9c7,
+	0x2005, 0xa87e, 0x20a9, 0x000a, 0x2001, 0x0270, 0xaa5c, 0x9290,
+	0x0021, 0x2009, 0x0205, 0x200b, 0x0080, 0x20e1, 0x0000, 0xab60,
+	0x23e8, 0x2098, 0x22a0, 0x4003, 0x200b, 0x0000, 0x2001, 0x027a,
+	0x200c, 0xa9b2, 0x8000, 0x200c, 0xa9ae, 0x080c, 0x6da2, 0x002e,
+	0x004e, 0x00fe, 0x00ee, 0x00de, 0x00be, 0x009e, 0x0005, 0x0000,
+	0x0080, 0x0040, 0x0000, 0x2001, 0x1810, 0x2004, 0xd084, 0x0120,
+	0x080c, 0x1047, 0x1904, 0xd974, 0x6017, 0xf100, 0x6003, 0x0001,
+	0x6007, 0x0041, 0x2009, 0xa022, 0x080c, 0x9239, 0x0c00, 0x2069,
+	0x0260, 0x6848, 0x9084, 0xff00, 0x9086, 0x1200, 0x1198, 0x686c,
+	0x9084, 0x00ff, 0x0016, 0x6114, 0x918c, 0xf700, 0x910d, 0x6116,
+	0x001e, 0x6003, 0x0001, 0x6007, 0x0043, 0x2009, 0xa025, 0x080c,
+	0x9239, 0x0828, 0x6868, 0x602e, 0x686c, 0x6032, 0x6017, 0xf200,
+	0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022, 0x080c, 0x9239,
+	0x0804, 0xd9bf, 0x2001, 0x180e, 0x2004, 0xd0ec, 0x0120, 0x2011,
+	0x8049, 0x080c, 0x4b29, 0x6017, 0xf300, 0x0010, 0x6017, 0xf100,
+	0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022, 0x080c, 0x9239,
+	0x0804, 0xd9bf, 0x6017, 0xf500, 0x0c98, 0x6017, 0xf600, 0x0804,
+	0xd9df, 0x6017, 0xf200, 0x0804, 0xd9df, 0xa867, 0x0146, 0xa86b,
+	0x0000, 0x6008, 0xa886, 0x2c00, 0xa87a, 0x7044, 0x9084, 0x0003,
+	0x9080, 0xd9c7, 0x2005, 0xa87e, 0x2928, 0x6010, 0x2058, 0xb8a0,
+	0xa876, 0xb828, 0xa88a, 0xb82c, 0xa88e, 0xb830, 0xa892, 0xb834,
+	0xa896, 0xa883, 0x003d, 0x2009, 0x0205, 0x2104, 0x9085, 0x0080,
+	0x200a, 0x20e1, 0x0000, 0x2011, 0x0210, 0x2214, 0x9294, 0x0fff,
+	0xaaa2, 0x9282, 0x0111, 0x1a0c, 0x0d7d, 0x8210, 0x821c, 0x2001,
+	0x026c, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0029, 0x20a0,
+	0x2011, 0xdaa9, 0x2041, 0x0001, 0x223d, 0x9784, 0x00ff, 0x9322,
+	0x1208, 0x2300, 0x20a8, 0x4003, 0x931a, 0x0530, 0x8210, 0xd7fc,
+	0x1130, 0x8d68, 0x2d0a, 0x2001, 0x0260, 0x2098, 0x0c68, 0x2950,
+	0x080c, 0x1060, 0x0170, 0x2900, 0xb002, 0xa867, 0x0147, 0xa86b,
+	0x0000, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0, 0x8840,
+	0x08d8, 0x2548, 0xa800, 0x902d, 0x0118, 0x080c, 0x1079, 0x0cc8,
+	0x080c, 0x1079, 0x0804, 0xd9cb, 0x2548, 0x8847, 0x9885, 0x0046,
+	0xa866, 0x2009, 0x0205, 0x200b, 0x0000, 0x080c, 0xe2b9, 0x0804,
+	0xd9bf, 0x8010, 0x0004, 0x801a, 0x0006, 0x8018, 0x0008, 0x8016,
+	0x000a, 0x8014, 0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0057,
+	0x1a0c, 0x0d7d, 0x9082, 0x0040, 0x0a0c, 0x0d7d, 0x2008, 0x0804,
+	0xdb35, 0x9186, 0x0051, 0x0108, 0x0040, 0x080c, 0xaaab, 0x01e8,
+	0x9086, 0x0002, 0x0904, 0xdb7d, 0x00c0, 0x9186, 0x0027, 0x0180,
+	0x9186, 0x0048, 0x0128, 0x9186, 0x0014, 0x0150, 0x190c, 0x0d7d,
+	0x080c, 0xaaab, 0x0150, 0x9086, 0x0004, 0x0904, 0xdc1c, 0x0028,
+	0x6004, 0x9082, 0x0040, 0x2008, 0x001a, 0x080c, 0xacaa, 0x0005,
+	0xdafc, 0xdafe, 0xdafe, 0xdb25, 0xdafc, 0xdafc, 0xdafc, 0xdafc,
+	0xdafc, 0xdafc, 0xdafc, 0xdafc, 0xdafc, 0xdafc, 0xdafc, 0xdafc,
+	0xdafc, 0xdafc, 0xdafc, 0xdafc, 0x080c, 0x0d7d, 0x080c, 0x95ff,
+	0x080c, 0x96bd, 0x0036, 0x0096, 0x6014, 0x904d, 0x01d8, 0x080c,
+	0xc865, 0x01c0, 0x6003, 0x0002, 0x6010, 0x00b6, 0x2058, 0xb800,
+	0x00be, 0xd0bc, 0x1178, 0x2019, 0x0004, 0x080c, 0xe2b9, 0x6017,
+	0x0000, 0x6018, 0x9005, 0x1120, 0x2001, 0x1986, 0x2004, 0x601a,
+	0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x0096, 0x080c, 0x95ff,
+	0x080c, 0x96bd, 0x080c, 0xc865, 0x0120, 0x6014, 0x2048, 0x080c,
+	0x1079, 0x080c, 0xac2b, 0x009e, 0x0005, 0x0002, 0xdb4a, 0xdb5f,
+	0xdb4c, 0xdb74, 0xdb4a, 0xdb4a, 0xdb4a, 0xdb4a, 0xdb4a, 0xdb4a,
+	0xdb4a, 0xdb4a, 0xdb4a, 0xdb4a, 0xdb4a, 0xdb4a, 0xdb4a, 0xdb4a,
+	0xdb4a, 0xdb4a, 0x080c, 0x0d7d, 0x0096, 0x6014, 0x2048, 0xa87c,
+	0xd0b4, 0x0138, 0x6003, 0x0007, 0x2009, 0x0043, 0x080c, 0xac8d,
+	0x0010, 0x6003, 0x0004, 0x080c, 0x96bd, 0x009e, 0x0005, 0x080c,
+	0xc865, 0x0138, 0x6114, 0x0096, 0x2148, 0xa97c, 0x009e, 0xd1ec,
+	0x1138, 0x080c, 0x88d7, 0x080c, 0xabf0, 0x080c, 0x96bd, 0x0005,
+	0x080c, 0xe519, 0x0db0, 0x0cc8, 0x6003, 0x0001, 0x6007, 0x0041,
+	0x2009, 0xa022, 0x080c, 0x9239, 0x0005, 0x9182, 0x0040, 0x0002,
+	0xdb94, 0xdb96, 0xdb94, 0xdb94, 0xdb94, 0xdb94, 0xdb94, 0xdb94,
+	0xdb94, 0xdb94, 0xdb94, 0xdb94, 0xdb94, 0xdb94, 0xdb94, 0xdb94,
+	0xdb94, 0xdb97, 0xdb94, 0xdb94, 0x080c, 0x0d7d, 0x0005, 0x00d6,
+	0x080c, 0x88d7, 0x00de, 0x080c, 0xe571, 0x080c, 0xabf0, 0x0005,
+	0x9182, 0x0040, 0x0002, 0xdbb7, 0xdbb7, 0xdbb7, 0xdbb7, 0xdbb7,
+	0xdbb7, 0xdbb7, 0xdbb7, 0xdbb7, 0xdbb9, 0xdbe4, 0xdbb7, 0xdbb7,
+	0xdbb7, 0xdbb7, 0xdbe4, 0xdbb7, 0xdbb7, 0xdbb7, 0xdbb7, 0x080c,
 	0x0d7d, 0x6014, 0x0096, 0x2048, 0xa87c, 0xd0fc, 0x0168, 0x908c,
 	0x0003, 0x918e, 0x0002, 0x0180, 0x6144, 0xd1e4, 0x1168, 0x2009,
-	0x0041, 0x009e, 0x0804, 0xdc6c, 0x6003, 0x0007, 0x601b, 0x0000,
-	0x080c, 0x88a3, 0x009e, 0x0005, 0x6014, 0x2048, 0xa97c, 0xd1ec,
-	0x1130, 0x080c, 0x88a3, 0x080c, 0xabdf, 0x009e, 0x0005, 0x080c,
-	0xe4dc, 0x0db8, 0x009e, 0x0005, 0x2001, 0x180c, 0x200c, 0xc1d4,
-	0x2102, 0x0036, 0x080c, 0x9621, 0x080c, 0x9684, 0x6014, 0x0096,
+	0x0041, 0x009e, 0x0804, 0xdca4, 0x6003, 0x0007, 0x601b, 0x0000,
+	0x080c, 0x88d7, 0x009e, 0x0005, 0x6014, 0x2048, 0xa97c, 0xd1ec,
+	0x1130, 0x080c, 0x88d7, 0x080c, 0xabf0, 0x009e, 0x0005, 0x080c,
+	0xe519, 0x0db8, 0x009e, 0x0005, 0x2001, 0x180c, 0x200c, 0xc1d4,
+	0x2102, 0x0036, 0x080c, 0x965a, 0x080c, 0x96bd, 0x6014, 0x0096,
 	0x2048, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0188,
 	0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x0140, 0xa8ac, 0x6330,
 	0x931a, 0x6332, 0xa8b0, 0x632c, 0x931b, 0x632e, 0x6003, 0x0002,
-	0x0080, 0x2019, 0x0004, 0x080c, 0xe27c, 0x6018, 0x9005, 0x1128,
+	0x0080, 0x2019, 0x0004, 0x080c, 0xe2b9, 0x6018, 0x9005, 0x1128,
 	0x2001, 0x1986, 0x2004, 0x8003, 0x601a, 0x6017, 0x0000, 0x6003,
-	0x0007, 0x009e, 0x003e, 0x0005, 0x9182, 0x0040, 0x0002, 0xdbfb,
-	0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb, 0xdbfd,
-	0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb, 0xdbfb,
-	0xdbfb, 0xdbfb, 0xdc48, 0x080c, 0x0d7d, 0x6014, 0x0096, 0x2048,
+	0x0007, 0x009e, 0x003e, 0x0005, 0x9182, 0x0040, 0x0002, 0xdc33,
+	0xdc33, 0xdc33, 0xdc33, 0xdc33, 0xdc33, 0xdc33, 0xdc33, 0xdc35,
+	0xdc33, 0xdc33, 0xdc33, 0xdc33, 0xdc33, 0xdc33, 0xdc33, 0xdc33,
+	0xdc33, 0xdc33, 0xdc80, 0x080c, 0x0d7d, 0x6014, 0x0096, 0x2048,
 	0xa834, 0xaa38, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1bc,
 	0x1190, 0x920d, 0x1518, 0xa87c, 0xd0fc, 0x0128, 0x2009, 0x0041,
-	0x009e, 0x0804, 0xdc6c, 0x6003, 0x0007, 0x601b, 0x0000, 0x080c,
-	0x88a3, 0x009e, 0x0005, 0x6124, 0xd1f4, 0x1d58, 0x0006, 0x0046,
+	0x009e, 0x0804, 0xdca4, 0x6003, 0x0007, 0x601b, 0x0000, 0x080c,
+	0x88d7, 0x009e, 0x0005, 0x6124, 0xd1f4, 0x1d58, 0x0006, 0x0046,
 	0xacac, 0x9422, 0xa9b0, 0x2200, 0x910b, 0x6030, 0x9420, 0x6432,
 	0x602c, 0x9109, 0x612e, 0x004e, 0x000e, 0x08d8, 0x6110, 0x00b6,
 	0x2158, 0xb900, 0x00be, 0xd1bc, 0x1178, 0x2009, 0x180e, 0x210c,
 	0xd19c, 0x0118, 0x6003, 0x0007, 0x0010, 0x6003, 0x0006, 0x00e9,
-	0x080c, 0x88a5, 0x009e, 0x0005, 0x6003, 0x0002, 0x009e, 0x0005,
-	0x6024, 0xd0f4, 0x0128, 0x080c, 0x167d, 0x1904, 0xdbfd, 0x0005,
+	0x080c, 0x88d9, 0x009e, 0x0005, 0x6003, 0x0002, 0x009e, 0x0005,
+	0x6024, 0xd0f4, 0x0128, 0x080c, 0x168a, 0x1904, 0xdc35, 0x0005,
 	0x6014, 0x0096, 0x2048, 0xa834, 0xa938, 0x009e, 0x9105, 0x1120,
-	0x080c, 0x167d, 0x1904, 0xdbfd, 0x0005, 0xd2fc, 0x0140, 0x8002,
+	0x080c, 0x168a, 0x1904, 0xdc35, 0x0005, 0xd2fc, 0x0140, 0x8002,
 	0x8000, 0x8212, 0x9291, 0x0000, 0x2009, 0x0009, 0x0010, 0x2009,
 	0x0015, 0xaa9a, 0xa896, 0x0005, 0x9182, 0x0040, 0x0208, 0x0062,
 	0x9186, 0x0013, 0x0120, 0x9186, 0x0014, 0x190c, 0x0d7d, 0x6024,
-	0xd0dc, 0x090c, 0x0d7d, 0x0005, 0xdc8f, 0xdc9b, 0xdca7, 0xdcb3,
-	0xdc8f, 0xdc8f, 0xdc8f, 0xdc8f, 0xdc96, 0xdc91, 0xdc91, 0xdc8f,
-	0xdc8f, 0xdc8f, 0xdc8f, 0xdc91, 0xdc8f, 0xdc91, 0xdc8f, 0x080c,
-	0x0d7d, 0x6024, 0xd0dc, 0x090c, 0x0d7d, 0x0005, 0x6014, 0x9005,
-	0x190c, 0x0d7d, 0x0005, 0x6003, 0x0001, 0x6106, 0x0126, 0x2091,
-	0x8000, 0x2009, 0xa022, 0x080c, 0x91e2, 0x012e, 0x0005, 0x6003,
-	0x0004, 0x6106, 0x0126, 0x2091, 0x8000, 0x2009, 0xa001, 0x080c,
-	0x9200, 0x012e, 0x0005, 0x6003, 0x0003, 0x6106, 0x080c, 0x1c10,
-	0x0126, 0x2091, 0x8000, 0x6014, 0x0096, 0x2048, 0xa87c, 0xd0fc,
-	0x0188, 0x9084, 0x0003, 0x9086, 0x0002, 0x01a0, 0x6024, 0xd0cc,
-	0x1148, 0xd0c4, 0x1138, 0xa8a8, 0x9005, 0x1120, 0x6144, 0x918d,
-	0xb035, 0x0018, 0x6144, 0x918d, 0xa035, 0x009e, 0x080c, 0x9247,
-	0x012e, 0x0005, 0x6144, 0x918d, 0xa032, 0x0cb8, 0x0126, 0x2091,
-	0x8000, 0x0036, 0x0096, 0x9182, 0x0040, 0x0023, 0x009e, 0x003e,
-	0x012e, 0x0005, 0xdcfa, 0xdcfc, 0xdd11, 0xdd2b, 0xdcfa, 0xdcfa,
-	0xdcfa, 0xdcfa, 0xdcfa, 0xdcfa, 0xdcfa, 0xdcfa, 0xdcfa, 0xdcfa,
-	0xdcfa, 0xdcfa, 0x080c, 0x0d7d, 0x6014, 0x2048, 0xa87c, 0xd0fc,
-	0x0510, 0x909c, 0x0003, 0x939e, 0x0003, 0x01e8, 0x6003, 0x0001,
-	0x6106, 0x0126, 0x2091, 0x8000, 0x2009, 0xa022, 0x080c, 0x9200,
-	0x0470, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0168, 0x909c, 0x0003,
-	0x939e, 0x0003, 0x0140, 0x6003, 0x0001, 0x6106, 0x2009, 0xa001,
-	0x080c, 0x9200, 0x00e0, 0x901e, 0x6316, 0x631a, 0x2019, 0x0004,
-	0x080c, 0xe27c, 0x00a0, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0d98,
-	0x909c, 0x0003, 0x939e, 0x0003, 0x0d70, 0x6003, 0x0003, 0x6106,
-	0x080c, 0x1c10, 0x6144, 0x918d, 0xa035, 0x080c, 0x9247, 0x0005,
-	0x080c, 0x95c6, 0x6114, 0x81ff, 0x0158, 0x0096, 0x2148, 0x080c,
-	0xe631, 0x0036, 0x2019, 0x0029, 0x080c, 0xe27c, 0x003e, 0x009e,
-	0x080c, 0xac1a, 0x080c, 0x9684, 0x0005, 0x080c, 0x9621, 0x6114,
-	0x81ff, 0x0158, 0x0096, 0x2148, 0x080c, 0xe631, 0x0036, 0x2019,
-	0x0029, 0x080c, 0xe27c, 0x003e, 0x009e, 0x080c, 0xac1a, 0x0005,
-	0x9182, 0x0085, 0x0002, 0xdd7a, 0xdd78, 0xdd78, 0xdd86, 0xdd78,
-	0xdd78, 0xdd78, 0xdd78, 0xdd78, 0xdd78, 0xdd78, 0xdd78, 0xdd78,
-	0x080c, 0x0d7d, 0x6003, 0x000b, 0x6106, 0x0126, 0x2091, 0x8000,
-	0x2009, 0x8020, 0x080c, 0x9200, 0x012e, 0x0005, 0x0026, 0x00e6,
-	0x080c, 0xe4d3, 0x0118, 0x080c, 0xabdf, 0x0440, 0x2071, 0x0260,
-	0x7224, 0x6216, 0x2001, 0x180e, 0x2004, 0xd0e4, 0x0150, 0x6010,
-	0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x2011, 0x014e, 0x080c,
-	0xaf0a, 0x7220, 0x080c, 0xe112, 0x0118, 0x6007, 0x0086, 0x0040,
-	0x6007, 0x0087, 0x7224, 0x9296, 0xffff, 0x1110, 0x6007, 0x0086,
-	0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x9200, 0x00ee, 0x002e,
-	0x0005, 0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085, 0x0a0c,
-	0x0d7d, 0x908a, 0x0092, 0x1a0c, 0x0d7d, 0x9082, 0x0085, 0x00a2,
-	0x9186, 0x0027, 0x0130, 0x9186, 0x0014, 0x0118, 0x080c, 0xac99,
-	0x0050, 0x2001, 0x0007, 0x080c, 0x659c, 0x080c, 0x95c6, 0x080c,
-	0xac1a, 0x080c, 0x9684, 0x0005, 0xdde9, 0xddeb, 0xddeb, 0xdde9,
-	0xdde9, 0xdde9, 0xdde9, 0xdde9, 0xdde9, 0xdde9, 0xdde9, 0xdde9,
-	0xdde9, 0x080c, 0x0d7d, 0x080c, 0xac1a, 0x080c, 0x9684, 0x0005,
-	0x9182, 0x0085, 0x0a0c, 0x0d7d, 0x9182, 0x0092, 0x1a0c, 0x0d7d,
-	0x9182, 0x0085, 0x0002, 0xde08, 0xde08, 0xde08, 0xde0a, 0xde08,
-	0xde08, 0xde08, 0xde08, 0xde08, 0xde08, 0xde08, 0xde08, 0xde08,
-	0x080c, 0x0d7d, 0x0005, 0x9186, 0x0013, 0x0148, 0x9186, 0x0014,
-	0x0130, 0x9186, 0x0027, 0x0118, 0x080c, 0xac99, 0x0020, 0x080c,
-	0x95c6, 0x080c, 0xac1a, 0x0005, 0x0036, 0x080c, 0xe534, 0x604b,
-	0x0000, 0x2019, 0x000b, 0x0031, 0x6023, 0x0006, 0x6003, 0x0007,
-	0x003e, 0x0005, 0x0126, 0x0036, 0x2091, 0x8000, 0x2001, 0x0382,
-	0x2004, 0x9084, 0x0007, 0x0006, 0x9086, 0x0003, 0x0110, 0x080c,
-	0xa888, 0x0086, 0x2c40, 0x0096, 0x904e, 0x080c, 0xa1fa, 0x009e,
-	0x008e, 0x1558, 0x0076, 0x2c38, 0x080c, 0xa2a5, 0x007e, 0x1528,
-	0x6000, 0x9086, 0x0000, 0x0508, 0x6020, 0x9086, 0x0007, 0x01e8,
-	0x0096, 0x601c, 0xd084, 0x0140, 0x080c, 0xe534, 0x080c, 0xcf69,
-	0x080c, 0x1a77, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c, 0xc832,
-	0x0110, 0x080c, 0xe27c, 0x009e, 0x9006, 0x6046, 0x6016, 0x080c,
-	0xe534, 0x6023, 0x0007, 0x080c, 0xcf69, 0x000e, 0x9086, 0x0003,
-	0x0110, 0x080c, 0xa8a4, 0x003e, 0x012e, 0x0005, 0x00f6, 0x00c6,
-	0x00b6, 0x0036, 0x0156, 0x2079, 0x0260, 0x7938, 0x783c, 0x080c,
-	0x2614, 0x15e8, 0x0016, 0x00c6, 0x080c, 0x6620, 0x15b0, 0x001e,
-	0x00c6, 0x2160, 0x080c, 0xcf66, 0x00ce, 0x002e, 0x0026, 0x0016,
-	0x080c, 0xa888, 0x2019, 0x0029, 0x080c, 0xa372, 0x080c, 0x938d,
-	0x0076, 0x903e, 0x080c, 0x9256, 0x007e, 0x001e, 0x0076, 0x903e,
-	0x080c, 0xdffb, 0x007e, 0x080c, 0xa8a4, 0x0026, 0xba04, 0x9294,
-	0xff00, 0x8217, 0x9286, 0x0006, 0x0118, 0x9286, 0x0004, 0x1118,
-	0xbaa0, 0x080c, 0x32ba, 0x002e, 0xbc84, 0x001e, 0x080c, 0x603e,
-	0xbe12, 0xbd16, 0xbc86, 0x9006, 0x0010, 0x00ce, 0x001e, 0x015e,
-	0x003e, 0x00be, 0x00ce, 0x00fe, 0x0005, 0x00c6, 0x00d6, 0x00b6,
-	0x0016, 0x2009, 0x1824, 0x2104, 0x9086, 0x0074, 0x1904, 0xdf1e,
-	0x2069, 0x0260, 0x6944, 0x9182, 0x0100, 0x06e0, 0x6940, 0x9184,
-	0x8000, 0x0904, 0xdf1b, 0x2001, 0x197b, 0x2004, 0x9005, 0x1140,
-	0x6010, 0x2058, 0xb884, 0x9005, 0x0118, 0x9184, 0x0800, 0x0598,
-	0x6948, 0x918a, 0x0001, 0x0648, 0x080c, 0xe699, 0x0118, 0x6978,
-	0xd1fc, 0x11b8, 0x2009, 0x0205, 0x200b, 0x0001, 0x693c, 0x81ff,
-	0x1198, 0x6944, 0x9182, 0x0100, 0x02a8, 0x6940, 0x81ff, 0x1178,
-	0x6948, 0x918a, 0x0001, 0x0288, 0x6950, 0x918a, 0x0001, 0x0298,
-	0x00d0, 0x6017, 0x0100, 0x00a0, 0x6017, 0x0300, 0x0088, 0x6017,
-	0x0500, 0x0070, 0x6017, 0x0700, 0x0058, 0x6017, 0x0900, 0x0040,
-	0x6017, 0x0b00, 0x0028, 0x6017, 0x0f00, 0x0010, 0x6017, 0x2d00,
-	0x9085, 0x0001, 0x0008, 0x9006, 0x001e, 0x00be, 0x00de, 0x00ce,
-	0x0005, 0x00c6, 0x00b6, 0x0026, 0x0036, 0x0156, 0x6210, 0x2258,
-	0xbb04, 0x9394, 0x00ff, 0x9286, 0x0006, 0x0180, 0x9286, 0x0004,
-	0x0168, 0x9394, 0xff00, 0x8217, 0x9286, 0x0006, 0x0138, 0x9286,
-	0x0004, 0x0120, 0x080c, 0x662f, 0x0804, 0xdf8a, 0x2011, 0x0276,
-	0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xbbb5,
-	0x009e, 0x15c8, 0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48,
-	0x2019, 0x0006, 0x080c, 0xbbb5, 0x009e, 0x1568, 0x0046, 0x0016,
-	0xbaa0, 0x2220, 0x9006, 0x2009, 0x1848, 0x210c, 0xd1a4, 0x0138,
-	0x2009, 0x0029, 0x080c, 0xe2d9, 0xb800, 0xc0e5, 0xb802, 0x080c,
-	0xa888, 0x2019, 0x0029, 0x080c, 0x938d, 0x0076, 0x2039, 0x0000,
-	0x080c, 0x9256, 0x2c08, 0x080c, 0xdffb, 0x007e, 0x080c, 0xa8a4,
-	0x2001, 0x0007, 0x080c, 0x659c, 0x2001, 0x0007, 0x080c, 0x6570,
-	0x001e, 0x004e, 0x9006, 0x015e, 0x003e, 0x002e, 0x00be, 0x00ce,
-	0x0005, 0x00d6, 0x2069, 0x026e, 0x6800, 0x9086, 0x0800, 0x0118,
-	0x6017, 0x0000, 0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00f6,
-	0x0016, 0x0026, 0x0036, 0x0156, 0x2079, 0x026c, 0x7930, 0x7834,
-	0x080c, 0x2614, 0x11d0, 0x080c, 0x6620, 0x11b8, 0x2011, 0x0270,
-	0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xbbb5,
-	0x009e, 0x1158, 0x2011, 0x0274, 0x20a9, 0x0004, 0x0096, 0x2b48,
-	0x2019, 0x0006, 0x080c, 0xbbb5, 0x009e, 0x015e, 0x003e, 0x002e,
-	0x001e, 0x00fe, 0x00be, 0x0005, 0x00b6, 0x0006, 0x0016, 0x0026,
-	0x0036, 0x0156, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c,
-	0x2614, 0x11d0, 0x080c, 0x6620, 0x11b8, 0x2011, 0x0276, 0x20a9,
-	0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xbbb5, 0x009e,
-	0x1158, 0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019,
-	0x0006, 0x080c, 0xbbb5, 0x009e, 0x015e, 0x003e, 0x002e, 0x001e,
-	0x000e, 0x00be, 0x0005, 0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066,
-	0x0056, 0x0046, 0x0026, 0x0126, 0x2091, 0x8000, 0x080c, 0xa8e6,
-	0x0106, 0x190c, 0xa888, 0x2740, 0x2029, 0x19f2, 0x252c, 0x2021,
-	0x19f9, 0x2424, 0x2061, 0x1ddc, 0x2071, 0x1800, 0x7654, 0x7074,
-	0x81ff, 0x0150, 0x0006, 0x9186, 0x1b31, 0x000e, 0x0128, 0x8001,
-	0x9602, 0x1a04, 0xe0a0, 0x0018, 0x9606, 0x0904, 0xe0a0, 0x080c,
-	0x8b72, 0x0904, 0xe097, 0x2100, 0x9c06, 0x0904, 0xe097, 0x080c,
-	0xe31a, 0x1904, 0xe097, 0x080c, 0xe6b6, 0x0904, 0xe097, 0x080c,
-	0xe30a, 0x0904, 0xe097, 0x6720, 0x9786, 0x0001, 0x1148, 0x080c,
-	0x3357, 0x0904, 0xe0e2, 0x6004, 0x9086, 0x0000, 0x1904, 0xe0e2,
-	0x9786, 0x0004, 0x0904, 0xe0e2, 0x9786, 0x0007, 0x0904, 0xe097,
-	0x2500, 0x9c06, 0x0904, 0xe097, 0x2400, 0x9c06, 0x0904, 0xe097,
-	0x88ff, 0x0118, 0x605c, 0x9906, 0x15d0, 0x0096, 0x6043, 0xffff,
-	0x6000, 0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x1a77, 0x001e,
-	0x9786, 0x000a, 0x0148, 0x080c, 0xca47, 0x1130, 0x080c, 0xb5a6,
-	0x009e, 0x080c, 0xac1a, 0x0418, 0x6014, 0x2048, 0x080c, 0xc832,
-	0x01d8, 0x9786, 0x0003, 0x1588, 0xa867, 0x0103, 0xa87c, 0xd0cc,
-	0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fec, 0x009e, 0xab7a,
-	0xa877, 0x0000, 0x080c, 0xe631, 0x0016, 0x080c, 0xcb35, 0x080c,
-	0x6d6f, 0x001e, 0x080c, 0xca21, 0x009e, 0x080c, 0xac1a, 0x9ce0,
-	0x001c, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1210, 0x0804, 0xe014,
-	0x010e, 0x190c, 0xa8a4, 0x012e, 0x002e, 0x004e, 0x005e, 0x006e,
-	0x007e, 0x008e, 0x00ce, 0x00ee, 0x0005, 0x9786, 0x0006, 0x1150,
-	0x9386, 0x0005, 0x0128, 0x080c, 0xe631, 0x080c, 0xe27c, 0x08e0,
-	0x009e, 0x08e8, 0x9786, 0x0009, 0x11f8, 0x6000, 0x9086, 0x0004,
-	0x01c0, 0x6000, 0x9086, 0x0003, 0x11a0, 0x080c, 0x9621, 0x0096,
-	0x6114, 0x2148, 0x080c, 0xc832, 0x0118, 0x6010, 0x080c, 0x6d7b,
-	0x009e, 0x00c6, 0x080c, 0xabdf, 0x00ce, 0x0036, 0x080c, 0x9684,
-	0x003e, 0x009e, 0x0804, 0xe097, 0x9786, 0x000a, 0x0904, 0xe07e,
-	0x0804, 0xe07c, 0x81ff, 0x0904, 0xe097, 0x9180, 0x0001, 0x2004,
-	0x9086, 0x0018, 0x0138, 0x9180, 0x0001, 0x2004, 0x9086, 0x002d,
-	0x1904, 0xe097, 0x6000, 0x9086, 0x0002, 0x1904, 0xe097, 0x080c,
-	0xca36, 0x0138, 0x080c, 0xca47, 0x1904, 0xe097, 0x080c, 0xb5a6,
-	0x0038, 0x080c, 0x321e, 0x080c, 0xca47, 0x1110, 0x080c, 0xb5a6,
-	0x080c, 0xac1a, 0x0804, 0xe097, 0xa864, 0x9084, 0x00ff, 0x9086,
-	0x0039, 0x0005, 0x00c6, 0x00e6, 0x0016, 0x2c08, 0x2170, 0x9006,
-	0x080c, 0xe2a3, 0x001e, 0x0120, 0x6020, 0x9084, 0x000f, 0x001b,
-	0x00ee, 0x00ce, 0x0005, 0xe131, 0xe131, 0xe131, 0xe131, 0xe131,
-	0xe131, 0xe133, 0xe131, 0xe131, 0xe131, 0xe131, 0xac1a, 0xac1a,
-	0xe131, 0x9006, 0x0005, 0x0036, 0x0046, 0x0016, 0x7010, 0x00b6,
-	0x2058, 0xbca0, 0x00be, 0x2c00, 0x2009, 0x0020, 0x080c, 0xe2d9,
-	0x001e, 0x004e, 0x2019, 0x0002, 0x080c, 0xde2a, 0x003e, 0x9085,
-	0x0001, 0x0005, 0x0096, 0x080c, 0xc832, 0x0140, 0x6014, 0x904d,
-	0x080c, 0xc430, 0x687b, 0x0005, 0x080c, 0x6d7b, 0x009e, 0x080c,
-	0xac1a, 0x9085, 0x0001, 0x0005, 0x2001, 0x0001, 0x080c, 0x655c,
-	0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805,
-	0x2011, 0x0276, 0x080c, 0xbba1, 0x003e, 0x002e, 0x001e, 0x015e,
-	0x9005, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066,
-	0x00b6, 0x0126, 0x2091, 0x8000, 0x2740, 0x2061, 0x1ddc, 0x2079,
-	0x0001, 0x8fff, 0x0904, 0xe1cc, 0x2071, 0x1800, 0x7654, 0x7074,
-	0x8001, 0x9602, 0x1a04, 0xe1cc, 0x88ff, 0x0120, 0x2800, 0x9c06,
-	0x1590, 0x2078, 0x080c, 0xe30a, 0x0570, 0x2400, 0x9c06, 0x0558,
-	0x6720, 0x9786, 0x0006, 0x1538, 0x9786, 0x0007, 0x0520, 0x88ff,
-	0x1140, 0x6010, 0x9b06, 0x11f8, 0x85ff, 0x0118, 0x605c, 0x9106,
-	0x11d0, 0x0096, 0x601c, 0xd084, 0x0140, 0x080c, 0xe534, 0x080c,
-	0xcf69, 0x080c, 0x1a77, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c,
-	0xc832, 0x0120, 0x0046, 0x080c, 0xe27c, 0x004e, 0x009e, 0x080c,
-	0xac1a, 0x88ff, 0x1198, 0x9ce0, 0x001c, 0x2001, 0x181a, 0x2004,
-	0x9c02, 0x1210, 0x0804, 0xe181, 0x9006, 0x012e, 0x00be, 0x006e,
-	0x007e, 0x008e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x98c5, 0x0001,
-	0x0ca0, 0x080c, 0xa888, 0x00b6, 0x0076, 0x0056, 0x0086, 0x9046,
-	0x2029, 0x0001, 0x2c20, 0x2019, 0x0002, 0x6210, 0x2258, 0x0096,
-	0x904e, 0x080c, 0xa1fa, 0x009e, 0x008e, 0x903e, 0x080c, 0xa2a5,
-	0x080c, 0xe172, 0x005e, 0x007e, 0x00be, 0x080c, 0xa8a4, 0x0005,
-	0x080c, 0xa888, 0x00b6, 0x0046, 0x0056, 0x0076, 0x00c6, 0x0156,
-	0x2c20, 0x2128, 0x20a9, 0x007f, 0x900e, 0x0016, 0x0036, 0x080c,
-	0x6620, 0x1190, 0x0056, 0x0086, 0x9046, 0x2508, 0x2029, 0x0001,
-	0x0096, 0x904e, 0x080c, 0xa1fa, 0x009e, 0x008e, 0x903e, 0x080c,
-	0xa2a5, 0x080c, 0xe172, 0x005e, 0x003e, 0x001e, 0x8108, 0x1f04,
-	0xe205, 0x015e, 0x00ce, 0x007e, 0x005e, 0x004e, 0x00be, 0x080c,
-	0xa8a4, 0x0005, 0x080c, 0xa888, 0x00b6, 0x0076, 0x0056, 0x6210,
-	0x2258, 0x0086, 0x9046, 0x2029, 0x0001, 0x2019, 0x0048, 0x0096,
-	0x904e, 0x080c, 0xa1fa, 0x009e, 0x008e, 0x903e, 0x080c, 0xa2a5,
-	0x2c20, 0x080c, 0xe172, 0x005e, 0x007e, 0x00be, 0x080c, 0xa8a4,
-	0x0005, 0x080c, 0xa888, 0x00b6, 0x0046, 0x0056, 0x0076, 0x00c6,
-	0x0156, 0x2c20, 0x20a9, 0x0800, 0x900e, 0x0016, 0x0036, 0x080c,
-	0x6620, 0x11a0, 0x0086, 0x9046, 0x2828, 0x0046, 0x2021, 0x0001,
-	0x080c, 0xe518, 0x004e, 0x0096, 0x904e, 0x080c, 0xa1fa, 0x009e,
-	0x008e, 0x903e, 0x080c, 0xa2a5, 0x080c, 0xe172, 0x003e, 0x001e,
-	0x8108, 0x1f04, 0xe255, 0x015e, 0x00ce, 0x007e, 0x005e, 0x004e,
-	0x00be, 0x080c, 0xa8a4, 0x0005, 0x0016, 0x00f6, 0x080c, 0xc830,
-	0x0198, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0046, 0x0180, 0xa800,
-	0x907d, 0x0138, 0xa803, 0x0000, 0xab82, 0x080c, 0x6d7b, 0x2f48,
-	0x0cb0, 0xab82, 0x080c, 0x6d7b, 0x00fe, 0x001e, 0x0005, 0xa800,
-	0x907d, 0x0130, 0xa803, 0x0000, 0x080c, 0x6d7b, 0x2f48, 0x0cb8,
-	0x080c, 0x6d7b, 0x0c88, 0x00e6, 0x0046, 0x0036, 0x2061, 0x1ddc,
-	0x9005, 0x1138, 0x2071, 0x1800, 0x7454, 0x7074, 0x8001, 0x9402,
-	0x12f8, 0x2100, 0x9c06, 0x0188, 0x6000, 0x9086, 0x0000, 0x0168,
-	0x6008, 0x9206, 0x1150, 0x6320, 0x9386, 0x0009, 0x01b0, 0x6010,
-	0x91a0, 0x0004, 0x2424, 0x9406, 0x0140, 0x9ce0, 0x001c, 0x2001,
-	0x181a, 0x2004, 0x9c02, 0x1220, 0x0c20, 0x9085, 0x0001, 0x0008,
-	0x9006, 0x003e, 0x004e, 0x00ee, 0x0005, 0x631c, 0xd3c4, 0x1d68,
-	0x0c30, 0x0096, 0x0006, 0x080c, 0x103a, 0x000e, 0x090c, 0x0d7d,
-	0xaae2, 0xa867, 0x010d, 0xa88e, 0x0026, 0x2010, 0x080c, 0xc820,
-	0x2001, 0x0000, 0x0120, 0x2200, 0x9080, 0x0017, 0x2004, 0x002e,
-	0xa87a, 0x9186, 0x0020, 0x0110, 0xa8e3, 0xffff, 0xa986, 0xac76,
-	0xa87f, 0x0000, 0x2001, 0x198d, 0x2004, 0xa882, 0x9006, 0xa802,
-	0xa86a, 0xa88a, 0x0126, 0x2091, 0x8000, 0x080c, 0x6d7b, 0x012e,
-	0x009e, 0x0005, 0x6700, 0x9786, 0x0000, 0x0158, 0x9786, 0x0001,
-	0x0140, 0x9786, 0x000a, 0x0128, 0x9786, 0x0009, 0x0110, 0x9085,
-	0x0001, 0x0005, 0x00e6, 0x6010, 0x9075, 0x0138, 0x00b6, 0x2058,
-	0xb8a0, 0x00be, 0x9206, 0x00ee, 0x0005, 0x9085, 0x0001, 0x0cd8,
-	0x0016, 0x6004, 0x908e, 0x001e, 0x11a0, 0x8007, 0x6134, 0x918c,
-	0x00ff, 0x9105, 0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
-	0x0005, 0x2001, 0x1986, 0x2004, 0x601a, 0x2009, 0x8020, 0x080c,
-	0x9200, 0x001e, 0x0005, 0xa001, 0xa001, 0x0005, 0x6024, 0xd0e4,
-	0x0158, 0xd0cc, 0x0118, 0x080c, 0xcb7c, 0x0030, 0x080c, 0xe534,
-	0x080c, 0x88a3, 0x080c, 0xabdf, 0x0005, 0x9280, 0x0008, 0x2004,
-	0x9084, 0x000f, 0x0002, 0xe369, 0xe369, 0xe369, 0xe36b, 0xe369,
-	0xe36b, 0xe36b, 0xe369, 0xe36b, 0xe369, 0xe369, 0xe369, 0xe369,
-	0xe369, 0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x9280, 0x0008,
-	0x2004, 0x9084, 0x000f, 0x0002, 0xe382, 0xe382, 0xe382, 0xe382,
-	0xe382, 0xe382, 0xe38f, 0xe382, 0xe382, 0xe382, 0xe382, 0xe382,
-	0xe382, 0xe382, 0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00,
-	0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x9200, 0x0005, 0x0096,
-	0x00c6, 0x2260, 0x080c, 0xe534, 0x604b, 0x0000, 0x6024, 0xc0f4,
-	0xc0e4, 0x6026, 0x603b, 0x0000, 0x00ce, 0x00d6, 0x2268, 0x9186,
-	0x0007, 0x1904, 0xe3e8, 0x6814, 0x9005, 0x0138, 0x2048, 0xa87c,
-	0xd0fc, 0x1118, 0x00de, 0x009e, 0x08a8, 0x6007, 0x003a, 0x6003,
-	0x0001, 0x2009, 0x8020, 0x080c, 0x9200, 0x00c6, 0x2d60, 0x6100,
-	0x9186, 0x0002, 0x1904, 0xe45f, 0x6014, 0x9005, 0x1138, 0x6000,
-	0x9086, 0x0007, 0x190c, 0x0d7d, 0x0804, 0xe45f, 0x2048, 0x080c,
-	0xc832, 0x1130, 0x0028, 0x2048, 0xa800, 0x9005, 0x1de0, 0x2900,
-	0x2048, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x1168, 0xa87c,
-	0xc0dc, 0xc0f4, 0xa87e, 0xa880, 0xc0fc, 0xa882, 0x2009, 0x0043,
-	0x080c, 0xdc6c, 0x0804, 0xe45f, 0x2009, 0x0041, 0x0804, 0xe459,
-	0x9186, 0x0005, 0x15a0, 0x6814, 0x2048, 0xa87c, 0xd0bc, 0x1120,
-	0x00de, 0x009e, 0x0804, 0xe382, 0xd0b4, 0x0128, 0xd0fc, 0x090c,
-	0x0d7d, 0x0804, 0xe3a3, 0x6007, 0x003a, 0x6003, 0x0001, 0x2009,
-	0x8020, 0x080c, 0x9200, 0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002,
-	0x0120, 0x9186, 0x0004, 0x1904, 0xe45f, 0x6814, 0x2048, 0xa97c,
-	0xc1f4, 0xc1dc, 0xa97e, 0xa980, 0xc1fc, 0xc1bc, 0xa982, 0x00f6,
-	0x2c78, 0x080c, 0x173e, 0x00fe, 0x2009, 0x0042, 0x04d0, 0x0036,
-	0x080c, 0x103a, 0x090c, 0x0d7d, 0xa867, 0x010d, 0x9006, 0xa802,
-	0xa86a, 0xa88a, 0x2d18, 0xab8e, 0xa887, 0x0045, 0x2c00, 0xa892,
-	0x6038, 0xa8a2, 0x2360, 0x6024, 0xc0dd, 0x6026, 0x6010, 0x00b6,
-	0x2058, 0xb8a0, 0x00be, 0x2004, 0x635c, 0xab7a, 0xa876, 0x9006,
-	0xa87e, 0xa882, 0xad9a, 0xae96, 0xa89f, 0x0001, 0x080c, 0x6d7b,
-	0x2019, 0x0045, 0x6008, 0x2068, 0x080c, 0xde2a, 0x2d00, 0x600a,
-	0x6023, 0x0006, 0x6003, 0x0007, 0x901e, 0x631a, 0x634a, 0x003e,
-	0x0038, 0x604b, 0x0000, 0x6003, 0x0007, 0x080c, 0xdc6c, 0x00ce,
-	0x00de, 0x009e, 0x0005, 0x9186, 0x0013, 0x1128, 0x6004, 0x9082,
-	0x0085, 0x2008, 0x00c2, 0x9186, 0x0027, 0x1178, 0x080c, 0x95c6,
-	0x0036, 0x0096, 0x6014, 0x2048, 0x2019, 0x0004, 0x080c, 0xe27c,
-	0x009e, 0x003e, 0x080c, 0x9684, 0x0005, 0x9186, 0x0014, 0x0d70,
-	0x080c, 0xac99, 0x0005, 0xe492, 0xe490, 0xe490, 0xe490, 0xe490,
-	0xe490, 0xe492, 0xe490, 0xe490, 0xe490, 0xe490, 0xe490, 0xe490,
-	0x080c, 0x0d7d, 0x6003, 0x000c, 0x080c, 0x9684, 0x0005, 0x9182,
-	0x0092, 0x1220, 0x9182, 0x0085, 0x0208, 0x001a, 0x080c, 0xac99,
-	0x0005, 0xe4ae, 0xe4ae, 0xe4ae, 0xe4ae, 0xe4b0, 0xe4d0, 0xe4ae,
-	0xe4ae, 0xe4ae, 0xe4ae, 0xe4ae, 0xe4ae, 0xe4ae, 0x080c, 0x0d7d,
-	0x00d6, 0x2c68, 0x080c, 0xab89, 0x01b0, 0x6003, 0x0001, 0x6007,
-	0x001e, 0x2009, 0x026e, 0x210c, 0x613a, 0x2009, 0x026f, 0x210c,
-	0x613e, 0x600b, 0xffff, 0x6910, 0x6112, 0x6023, 0x0004, 0x2009,
-	0x8020, 0x080c, 0x9200, 0x2d60, 0x080c, 0xabdf, 0x00de, 0x0005,
-	0x080c, 0xabdf, 0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0ec, 0x00ee, 0x0005, 0x2009, 0x1867, 0x210c, 0xd1ec,
-	0x05b0, 0x6003, 0x0002, 0x6024, 0xc0e5, 0x6026, 0xd0cc, 0x0150,
-	0x2001, 0x1987, 0x2004, 0x604a, 0x2009, 0x1867, 0x210c, 0xd1f4,
-	0x1520, 0x00a0, 0x2009, 0x1867, 0x210c, 0xd1f4, 0x0128, 0x6024,
-	0xc0e4, 0x6026, 0x9006, 0x00d8, 0x2001, 0x1987, 0x200c, 0x2001,
-	0x1985, 0x2004, 0x9100, 0x9080, 0x000a, 0x604a, 0x6010, 0x00b6,
-	0x2058, 0xb8bc, 0x00be, 0x0008, 0x2104, 0x9005, 0x0118, 0x9088,
-	0x0003, 0x0cd0, 0x2c0a, 0x600f, 0x0000, 0x9085, 0x0001, 0x0005,
-	0x0016, 0x00c6, 0x00e6, 0x615c, 0xb8bc, 0x2060, 0x8cff, 0x0180,
-	0x84ff, 0x1118, 0x605c, 0x9106, 0x1138, 0x600c, 0x2072, 0x080c,
-	0x88a3, 0x080c, 0xabdf, 0x0010, 0x9cf0, 0x0003, 0x2e64, 0x0c70,
-	0x00ee, 0x00ce, 0x001e, 0x0005, 0x00d6, 0x00b6, 0x6010, 0x2058,
-	0xb8bc, 0x2068, 0x9005, 0x0130, 0x9c06, 0x0110, 0x680c, 0x0cd0,
-	0x600c, 0x680e, 0x00be, 0x00de, 0x0005, 0x0026, 0x0036, 0x0156,
-	0x2011, 0x182c, 0x2204, 0x9084, 0x00ff, 0x2019, 0x026e, 0x2334,
-	0x9636, 0x1508, 0x8318, 0x2334, 0x2204, 0x9084, 0xff00, 0x9636,
-	0x11d0, 0x2011, 0x0270, 0x20a9, 0x0004, 0x6010, 0x0096, 0x2048,
-	0x2019, 0x000a, 0x080c, 0xbbb5, 0x009e, 0x1168, 0x2011, 0x0274,
-	0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x0006, 0x080c,
-	0xbbb5, 0x009e, 0x1100, 0x015e, 0x003e, 0x002e, 0x0005, 0x00e6,
-	0x2071, 0x1800, 0x080c, 0x5fb7, 0x080c, 0x2fc0, 0x00ee, 0x0005,
-	0x0096, 0x0026, 0x080c, 0x103a, 0x090c, 0x0d7d, 0xa85c, 0x9080,
-	0x001a, 0x20a0, 0x20a9, 0x000c, 0xa860, 0x20e8, 0x9006, 0x4004,
-	0x9186, 0x0046, 0x1118, 0xa867, 0x0136, 0x0038, 0xa867, 0x0138,
-	0x9186, 0x0041, 0x0110, 0xa87b, 0x0001, 0x7038, 0x9084, 0xff00,
-	0x7240, 0x9294, 0xff00, 0x8007, 0x9215, 0xaa9a, 0x9186, 0x0046,
-	0x1168, 0x7038, 0x9084, 0x00ff, 0x723c, 0x9294, 0xff00, 0x9215,
-	0xaa9e, 0x723c, 0x9294, 0x00ff, 0xaaa2, 0x0060, 0x7040, 0x9084,
-	0x00ff, 0x7244, 0x9294, 0xff00, 0x9215, 0xaa9e, 0x7244, 0x9294,
-	0x00ff, 0xaaa2, 0x9186, 0x0046, 0x1118, 0x9e90, 0x0012, 0x0010,
-	0x9e90, 0x001a, 0x2204, 0x8007, 0xa8a6, 0x8210, 0x2204, 0x8007,
-	0xa8aa, 0x8210, 0x2204, 0x8007, 0xa8ae, 0x8210, 0x2204, 0x8007,
-	0xa8b2, 0x8210, 0x9186, 0x0046, 0x11b8, 0x9e90, 0x0016, 0x2204,
-	0x8007, 0xa8b6, 0x8210, 0x2204, 0x8007, 0xa8ba, 0x8210, 0x2204,
-	0x8007, 0xa8be, 0x8210, 0x2204, 0x8007, 0xa8c2, 0x8210, 0x2011,
-	0x0205, 0x2013, 0x0001, 0x00b0, 0x9e90, 0x001e, 0x2204, 0x8007,
-	0xa8b6, 0x8210, 0x2204, 0x8007, 0xa8ba, 0x2011, 0x0205, 0x2013,
-	0x0001, 0x2011, 0x0260, 0x2204, 0x8007, 0xa8be, 0x8210, 0x2204,
-	0x8007, 0xa8c2, 0x9186, 0x0046, 0x1118, 0x2011, 0x0262, 0x0010,
-	0x2011, 0x026a, 0x0146, 0x01d6, 0x0036, 0x20a9, 0x0001, 0x2019,
-	0x0008, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031, 0x20a0, 0x2204,
-	0x8007, 0x4004, 0x8210, 0x8319, 0x1dd0, 0x003e, 0x01ce, 0x013e,
-	0x2011, 0x0205, 0x2013, 0x0000, 0x002e, 0x080c, 0x6d7b, 0x009e,
-	0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0fc,
-	0x0108, 0x0011, 0x00ee, 0x0005, 0xa880, 0xc0e5, 0xa882, 0x0005,
-	0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066, 0x0056, 0x0046, 0x0026,
-	0x0016, 0x0126, 0x2091, 0x8000, 0x2029, 0x19f2, 0x252c, 0x2021,
-	0x19f9, 0x2424, 0x2061, 0x1ddc, 0x2071, 0x1800, 0x7654, 0x7074,
-	0x9606, 0x0578, 0x6720, 0x9786, 0x0001, 0x0118, 0x9786, 0x0008,
-	0x1500, 0x2500, 0x9c06, 0x01e8, 0x2400, 0x9c06, 0x01d0, 0x080c,
-	0xe30a, 0x01b8, 0x080c, 0xe31a, 0x11a0, 0x6000, 0x9086, 0x0004,
-	0x1120, 0x0016, 0x080c, 0x1a77, 0x001e, 0x080c, 0xca36, 0x1110,
-	0x080c, 0x321e, 0x080c, 0xca47, 0x1110, 0x080c, 0xb5a6, 0x080c,
-	0xac1a, 0x9ce0, 0x001c, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1208,
-	0x0858, 0x012e, 0x001e, 0x002e, 0x004e, 0x005e, 0x006e, 0x007e,
-	0x00ce, 0x00de, 0x00ee, 0x0005, 0x2001, 0x1810, 0x2004, 0xd0dc,
-	0x0005, 0x0006, 0x2001, 0x1837, 0x2004, 0xd09c, 0x000e, 0x0005,
-	0x0006, 0x0036, 0x0046, 0x080c, 0xcf51, 0x0168, 0x2019, 0xffff,
-	0x9005, 0x0128, 0x6010, 0x00b6, 0x2058, 0xbba0, 0x00be, 0x2021,
-	0x0004, 0x080c, 0x4cc0, 0x004e, 0x003e, 0x000e, 0x6004, 0x9086,
-	0x0001, 0x1128, 0x080c, 0xa372, 0x080c, 0xac1a, 0x9006, 0x0005,
-	0x00e6, 0x00c6, 0x00b6, 0x0046, 0x2061, 0x1ddc, 0x2071, 0x1800,
-	0x7454, 0x7074, 0x8001, 0x9402, 0x12b8, 0x2100, 0x9c06, 0x0148,
-	0x6000, 0x9086, 0x0000, 0x0128, 0x6010, 0x2058, 0xb8a0, 0x9206,
-	0x0140, 0x9ce0, 0x001c, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1220,
-	0x0c60, 0x9085, 0x0001, 0x0008, 0x9006, 0x004e, 0x00be, 0x00ce,
-	0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6, 0x0016, 0x2091, 0x8000,
-	0x2071, 0x1840, 0xd5a4, 0x0118, 0x7004, 0x8000, 0x7006, 0xd5b4,
-	0x0118, 0x7000, 0x8000, 0x7002, 0xd5ac, 0x0178, 0x2500, 0x9084,
-	0x0007, 0x908e, 0x0003, 0x0148, 0x908e, 0x0004, 0x0130, 0x908e,
-	0x0005, 0x0118, 0x2071, 0xfffe, 0x0089, 0x001e, 0x00ee, 0x000e,
-	0x012e, 0x0005, 0x0126, 0x0006, 0x00e6, 0x2091, 0x8000, 0x2071,
-	0xfff6, 0x0021, 0x00ee, 0x000e, 0x012e, 0x0005, 0x2e05, 0x8000,
-	0x2077, 0x1220, 0x8e70, 0x2e05, 0x8000, 0x2077, 0x0005, 0x00e6,
-	0x2071, 0xfff4, 0x0c99, 0x00ee, 0x0005, 0x00e6, 0x2071, 0xfff8,
-	0x0c69, 0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6, 0x2091, 0x8000,
-	0x2071, 0x1840, 0x7014, 0x8000, 0x7016, 0x00ee, 0x000e, 0x012e,
-	0x0005, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040,
-	0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000,
-	0x8000, 0x9d27
+	0xd0dc, 0x090c, 0x0d7d, 0x0005, 0xdcc8, 0xdcd4, 0xdce0, 0xdcec,
+	0xdcc8, 0xdcc8, 0xdcc8, 0xdcc8, 0xdccf, 0xdcca, 0xdcca, 0xdcc8,
+	0xdcc8, 0xdcc8, 0xdcc8, 0xdcca, 0xdcc8, 0xdcca, 0xdcc8, 0xdccf,
+	0x080c, 0x0d7d, 0x6024, 0xd0dc, 0x090c, 0x0d7d, 0x0005, 0x6014,
+	0x9005, 0x190c, 0x0d7d, 0x0005, 0x6003, 0x0001, 0x6106, 0x0126,
+	0x2091, 0x8000, 0x2009, 0xa022, 0x080c, 0x921b, 0x012e, 0x0005,
+	0x6003, 0x0004, 0x6106, 0x0126, 0x2091, 0x8000, 0x2009, 0xa001,
+	0x080c, 0x9239, 0x012e, 0x0005, 0x6003, 0x0003, 0x6106, 0x080c,
+	0x1c28, 0x0126, 0x2091, 0x8000, 0x6014, 0x0096, 0x2048, 0xa87c,
+	0xd0fc, 0x0188, 0x9084, 0x0003, 0x9086, 0x0002, 0x01a0, 0x6024,
+	0xd0cc, 0x1148, 0xd0c4, 0x1138, 0xa8a8, 0x9005, 0x1120, 0x6144,
+	0x918d, 0xb035, 0x0018, 0x6144, 0x918d, 0xa035, 0x009e, 0x080c,
+	0x9280, 0x012e, 0x0005, 0x6144, 0x918d, 0xa032, 0x0cb8, 0x0126,
+	0x2091, 0x8000, 0x0036, 0x0096, 0x9182, 0x0040, 0x0023, 0x009e,
+	0x003e, 0x012e, 0x0005, 0xdd37, 0xdd39, 0xdd4e, 0xdd68, 0xdd37,
+	0xdd37, 0xdd37, 0xdd37, 0xdd37, 0xdd37, 0xdd37, 0xdd37, 0xdd37,
+	0xdd37, 0xdd37, 0xdd37, 0xdd37, 0xdd37, 0xdd37, 0xdd37, 0x080c,
+	0x0d7d, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0510, 0x909c, 0x0003,
+	0x939e, 0x0003, 0x01e8, 0x6003, 0x0001, 0x6106, 0x0126, 0x2091,
+	0x8000, 0x2009, 0xa022, 0x080c, 0x9239, 0x0470, 0x6014, 0x2048,
+	0xa87c, 0xd0fc, 0x0168, 0x909c, 0x0003, 0x939e, 0x0003, 0x0140,
+	0x6003, 0x0001, 0x6106, 0x2009, 0xa001, 0x080c, 0x9239, 0x00e0,
+	0x901e, 0x6316, 0x631a, 0x2019, 0x0004, 0x080c, 0xe2b9, 0x00a0,
+	0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0d98, 0x909c, 0x0003, 0x939e,
+	0x0003, 0x0d70, 0x6003, 0x0003, 0x6106, 0x080c, 0x1c28, 0x6144,
+	0x918d, 0xa035, 0x080c, 0x9280, 0x0005, 0x080c, 0x95ff, 0x6114,
+	0x81ff, 0x0158, 0x0096, 0x2148, 0x080c, 0xe66e, 0x0036, 0x2019,
+	0x0029, 0x080c, 0xe2b9, 0x003e, 0x009e, 0x080c, 0xac2b, 0x080c,
+	0x96bd, 0x0005, 0x080c, 0x965a, 0x6114, 0x81ff, 0x0158, 0x0096,
+	0x2148, 0x080c, 0xe66e, 0x0036, 0x2019, 0x0029, 0x080c, 0xe2b9,
+	0x003e, 0x009e, 0x080c, 0xac2b, 0x0005, 0x9182, 0x0085, 0x0002,
+	0xddb7, 0xddb5, 0xddb5, 0xddc3, 0xddb5, 0xddb5, 0xddb5, 0xddb5,
+	0xddb5, 0xddb5, 0xddb5, 0xddb5, 0xddb5, 0x080c, 0x0d7d, 0x6003,
+	0x000b, 0x6106, 0x0126, 0x2091, 0x8000, 0x2009, 0x8020, 0x080c,
+	0x9239, 0x012e, 0x0005, 0x0026, 0x00e6, 0x080c, 0xe510, 0x0118,
+	0x080c, 0xabf0, 0x0440, 0x2071, 0x0260, 0x7224, 0x6216, 0x2001,
+	0x180e, 0x2004, 0xd0e4, 0x0150, 0x6010, 0x00b6, 0x2058, 0xbca0,
+	0x00be, 0x2c00, 0x2011, 0x014e, 0x080c, 0xaf1b, 0x7220, 0x080c,
+	0xe14f, 0x0118, 0x6007, 0x0086, 0x0040, 0x6007, 0x0087, 0x7224,
+	0x9296, 0xffff, 0x1110, 0x6007, 0x0086, 0x6003, 0x0001, 0x2009,
+	0x8020, 0x080c, 0x9239, 0x00ee, 0x002e, 0x0005, 0x9186, 0x0013,
+	0x1160, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0d7d, 0x908a, 0x0092,
+	0x1a0c, 0x0d7d, 0x9082, 0x0085, 0x00a2, 0x9186, 0x0027, 0x0130,
+	0x9186, 0x0014, 0x0118, 0x080c, 0xacaa, 0x0050, 0x2001, 0x0007,
+	0x080c, 0x65c0, 0x080c, 0x95ff, 0x080c, 0xac2b, 0x080c, 0x96bd,
+	0x0005, 0xde26, 0xde28, 0xde28, 0xde26, 0xde26, 0xde26, 0xde26,
+	0xde26, 0xde26, 0xde26, 0xde26, 0xde26, 0xde26, 0x080c, 0x0d7d,
+	0x080c, 0xac2b, 0x080c, 0x96bd, 0x0005, 0x9182, 0x0085, 0x0a0c,
+	0x0d7d, 0x9182, 0x0092, 0x1a0c, 0x0d7d, 0x9182, 0x0085, 0x0002,
+	0xde45, 0xde45, 0xde45, 0xde47, 0xde45, 0xde45, 0xde45, 0xde45,
+	0xde45, 0xde45, 0xde45, 0xde45, 0xde45, 0x080c, 0x0d7d, 0x0005,
+	0x9186, 0x0013, 0x0148, 0x9186, 0x0014, 0x0130, 0x9186, 0x0027,
+	0x0118, 0x080c, 0xacaa, 0x0020, 0x080c, 0x95ff, 0x080c, 0xac2b,
+	0x0005, 0x0036, 0x080c, 0xe571, 0x604b, 0x0000, 0x2019, 0x000b,
+	0x0031, 0x6023, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x0126,
+	0x0036, 0x2091, 0x8000, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007,
+	0x0006, 0x9086, 0x0003, 0x0110, 0x080c, 0xa899, 0x0086, 0x2c40,
+	0x0096, 0x904e, 0x080c, 0xa207, 0x009e, 0x008e, 0x1558, 0x0076,
+	0x2c38, 0x080c, 0xa2b2, 0x007e, 0x1528, 0x6000, 0x9086, 0x0000,
+	0x0508, 0x6020, 0x9086, 0x0007, 0x01e8, 0x0096, 0x601c, 0xd084,
+	0x0140, 0x080c, 0xe571, 0x080c, 0xcf9c, 0x080c, 0x1a94, 0x6023,
+	0x0007, 0x6014, 0x2048, 0x080c, 0xc865, 0x0110, 0x080c, 0xe2b9,
+	0x009e, 0x9006, 0x6046, 0x6016, 0x080c, 0xe571, 0x6023, 0x0007,
+	0x080c, 0xcf9c, 0x000e, 0x9086, 0x0003, 0x0110, 0x080c, 0xa8b5,
+	0x003e, 0x012e, 0x0005, 0x00f6, 0x00c6, 0x00b6, 0x0036, 0x0156,
+	0x2079, 0x0260, 0x7938, 0x783c, 0x080c, 0x2630, 0x15e8, 0x0016,
+	0x00c6, 0x080c, 0x6644, 0x15b0, 0x001e, 0x00c6, 0x2160, 0x080c,
+	0xcf99, 0x00ce, 0x002e, 0x0026, 0x0016, 0x080c, 0xa899, 0x2019,
+	0x0029, 0x080c, 0xa37f, 0x080c, 0x93c6, 0x0076, 0x903e, 0x080c,
+	0x928f, 0x007e, 0x001e, 0x0076, 0x903e, 0x080c, 0xe038, 0x007e,
+	0x080c, 0xa8b5, 0x0026, 0xba04, 0x9294, 0xff00, 0x8217, 0x9286,
+	0x0006, 0x0118, 0x9286, 0x0004, 0x1118, 0xbaa0, 0x080c, 0x32da,
+	0x002e, 0xbc84, 0x001e, 0x080c, 0x605e, 0xbe12, 0xbd16, 0xbc86,
+	0x9006, 0x0010, 0x00ce, 0x001e, 0x015e, 0x003e, 0x00be, 0x00ce,
+	0x00fe, 0x0005, 0x00c6, 0x00d6, 0x00b6, 0x0016, 0x2009, 0x1824,
+	0x2104, 0x9086, 0x0074, 0x1904, 0xdf5b, 0x2069, 0x0260, 0x6944,
+	0x9182, 0x0100, 0x06e0, 0x6940, 0x9184, 0x8000, 0x0904, 0xdf58,
+	0x2001, 0x197b, 0x2004, 0x9005, 0x1140, 0x6010, 0x2058, 0xb884,
+	0x9005, 0x0118, 0x9184, 0x0800, 0x0598, 0x6948, 0x918a, 0x0001,
+	0x0648, 0x080c, 0xe6d6, 0x0118, 0x6978, 0xd1fc, 0x11b8, 0x2009,
+	0x0205, 0x200b, 0x0001, 0x693c, 0x81ff, 0x1198, 0x6944, 0x9182,
+	0x0100, 0x02a8, 0x6940, 0x81ff, 0x1178, 0x6948, 0x918a, 0x0001,
+	0x0288, 0x6950, 0x918a, 0x0001, 0x0298, 0x00d0, 0x6017, 0x0100,
+	0x00a0, 0x6017, 0x0300, 0x0088, 0x6017, 0x0500, 0x0070, 0x6017,
+	0x0700, 0x0058, 0x6017, 0x0900, 0x0040, 0x6017, 0x0b00, 0x0028,
+	0x6017, 0x0f00, 0x0010, 0x6017, 0x2d00, 0x9085, 0x0001, 0x0008,
+	0x9006, 0x001e, 0x00be, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00b6,
+	0x0026, 0x0036, 0x0156, 0x6210, 0x2258, 0xbb04, 0x9394, 0x00ff,
+	0x9286, 0x0006, 0x0180, 0x9286, 0x0004, 0x0168, 0x9394, 0xff00,
+	0x8217, 0x9286, 0x0006, 0x0138, 0x9286, 0x0004, 0x0120, 0x080c,
+	0x6653, 0x0804, 0xdfc7, 0x2011, 0x0276, 0x20a9, 0x0004, 0x0096,
+	0x2b48, 0x2019, 0x000a, 0x080c, 0xbbd5, 0x009e, 0x15c8, 0x2011,
+	0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x0006, 0x080c,
+	0xbbd5, 0x009e, 0x1568, 0x0046, 0x0016, 0xbaa0, 0x2220, 0x9006,
+	0x2009, 0x1848, 0x210c, 0xd1a4, 0x0138, 0x2009, 0x0029, 0x080c,
+	0xe316, 0xb800, 0xc0e5, 0xb802, 0x080c, 0xa899, 0x2019, 0x0029,
+	0x080c, 0x93c6, 0x0076, 0x2039, 0x0000, 0x080c, 0x928f, 0x2c08,
+	0x080c, 0xe038, 0x007e, 0x080c, 0xa8b5, 0x2001, 0x0007, 0x080c,
+	0x65c0, 0x2001, 0x0007, 0x080c, 0x6594, 0x001e, 0x004e, 0x9006,
+	0x015e, 0x003e, 0x002e, 0x00be, 0x00ce, 0x0005, 0x00d6, 0x2069,
+	0x026e, 0x6800, 0x9086, 0x0800, 0x0118, 0x6017, 0x0000, 0x0008,
+	0x9006, 0x00de, 0x0005, 0x00b6, 0x00f6, 0x0016, 0x0026, 0x0036,
+	0x0156, 0x2079, 0x026c, 0x7930, 0x7834, 0x080c, 0x2630, 0x11d0,
+	0x080c, 0x6644, 0x11b8, 0x2011, 0x0270, 0x20a9, 0x0004, 0x0096,
+	0x2b48, 0x2019, 0x000a, 0x080c, 0xbbd5, 0x009e, 0x1158, 0x2011,
+	0x0274, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x0006, 0x080c,
+	0xbbd5, 0x009e, 0x015e, 0x003e, 0x002e, 0x001e, 0x00fe, 0x00be,
+	0x0005, 0x00b6, 0x0006, 0x0016, 0x0026, 0x0036, 0x0156, 0x2011,
+	0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2630, 0x11d0, 0x080c,
+	0x6644, 0x11b8, 0x2011, 0x0276, 0x20a9, 0x0004, 0x0096, 0x2b48,
+	0x2019, 0x000a, 0x080c, 0xbbd5, 0x009e, 0x1158, 0x2011, 0x027a,
+	0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x0006, 0x080c, 0xbbd5,
+	0x009e, 0x015e, 0x003e, 0x002e, 0x001e, 0x000e, 0x00be, 0x0005,
+	0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066, 0x0056, 0x0046, 0x0026,
+	0x0126, 0x2091, 0x8000, 0x080c, 0xa8f7, 0x0106, 0x190c, 0xa899,
+	0x2740, 0x2029, 0x19f2, 0x252c, 0x2021, 0x19f9, 0x2424, 0x2061,
+	0x1ddc, 0x2071, 0x1800, 0x7654, 0x7074, 0x81ff, 0x0150, 0x0006,
+	0x9186, 0x1b31, 0x000e, 0x0128, 0x8001, 0x9602, 0x1a04, 0xe0dd,
+	0x0018, 0x9606, 0x0904, 0xe0dd, 0x080c, 0x8ba9, 0x0904, 0xe0d4,
+	0x2100, 0x9c06, 0x0904, 0xe0d4, 0x080c, 0xe357, 0x1904, 0xe0d4,
+	0x080c, 0xe6f3, 0x0904, 0xe0d4, 0x080c, 0xe347, 0x0904, 0xe0d4,
+	0x6720, 0x9786, 0x0001, 0x1148, 0x080c, 0x3377, 0x0904, 0xe11f,
+	0x6004, 0x9086, 0x0000, 0x1904, 0xe11f, 0x9786, 0x0004, 0x0904,
+	0xe11f, 0x9786, 0x0007, 0x0904, 0xe0d4, 0x2500, 0x9c06, 0x0904,
+	0xe0d4, 0x2400, 0x9c06, 0x0904, 0xe0d4, 0x88ff, 0x0118, 0x605c,
+	0x9906, 0x15d0, 0x0096, 0x6043, 0xffff, 0x6000, 0x9086, 0x0004,
+	0x1120, 0x0016, 0x080c, 0x1a94, 0x001e, 0x9786, 0x000a, 0x0148,
+	0x080c, 0xca7a, 0x1130, 0x080c, 0xb5c6, 0x009e, 0x080c, 0xac2b,
+	0x0418, 0x6014, 0x2048, 0x080c, 0xc865, 0x01d8, 0x9786, 0x0003,
+	0x1588, 0xa867, 0x0103, 0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878,
+	0x2048, 0x080c, 0x0ff9, 0x009e, 0xab7a, 0xa877, 0x0000, 0x080c,
+	0xe66e, 0x0016, 0x080c, 0xcb68, 0x080c, 0x6d93, 0x001e, 0x080c,
+	0xca54, 0x009e, 0x080c, 0xac2b, 0x9ce0, 0x001c, 0x2001, 0x181a,
+	0x2004, 0x9c02, 0x1210, 0x0804, 0xe051, 0x010e, 0x190c, 0xa8b5,
+	0x012e, 0x002e, 0x004e, 0x005e, 0x006e, 0x007e, 0x008e, 0x00ce,
+	0x00ee, 0x0005, 0x9786, 0x0006, 0x1150, 0x9386, 0x0005, 0x0128,
+	0x080c, 0xe66e, 0x080c, 0xe2b9, 0x08e0, 0x009e, 0x08e8, 0x9786,
+	0x0009, 0x11f8, 0x6000, 0x9086, 0x0004, 0x01c0, 0x6000, 0x9086,
+	0x0003, 0x11a0, 0x080c, 0x965a, 0x0096, 0x6114, 0x2148, 0x080c,
+	0xc865, 0x0118, 0x6010, 0x080c, 0x6d9f, 0x009e, 0x00c6, 0x080c,
+	0xabf0, 0x00ce, 0x0036, 0x080c, 0x96bd, 0x003e, 0x009e, 0x0804,
+	0xe0d4, 0x9786, 0x000a, 0x0904, 0xe0bb, 0x0804, 0xe0b9, 0x81ff,
+	0x0904, 0xe0d4, 0x9180, 0x0001, 0x2004, 0x9086, 0x0018, 0x0138,
+	0x9180, 0x0001, 0x2004, 0x9086, 0x002d, 0x1904, 0xe0d4, 0x6000,
+	0x9086, 0x0002, 0x1904, 0xe0d4, 0x080c, 0xca69, 0x0138, 0x080c,
+	0xca7a, 0x1904, 0xe0d4, 0x080c, 0xb5c6, 0x0038, 0x080c, 0x323e,
+	0x080c, 0xca7a, 0x1110, 0x080c, 0xb5c6, 0x080c, 0xac2b, 0x0804,
+	0xe0d4, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x0005, 0x00c6,
+	0x00e6, 0x0016, 0x2c08, 0x2170, 0x9006, 0x080c, 0xe2e0, 0x001e,
+	0x0120, 0x6020, 0x9084, 0x000f, 0x001b, 0x00ee, 0x00ce, 0x0005,
+	0xe16e, 0xe16e, 0xe16e, 0xe16e, 0xe16e, 0xe16e, 0xe170, 0xe16e,
+	0xe16e, 0xe16e, 0xe16e, 0xac2b, 0xac2b, 0xe16e, 0x9006, 0x0005,
+	0x0036, 0x0046, 0x0016, 0x7010, 0x00b6, 0x2058, 0xbca0, 0x00be,
+	0x2c00, 0x2009, 0x0020, 0x080c, 0xe316, 0x001e, 0x004e, 0x2019,
+	0x0002, 0x080c, 0xde67, 0x003e, 0x9085, 0x0001, 0x0005, 0x0096,
+	0x080c, 0xc865, 0x0140, 0x6014, 0x904d, 0x080c, 0xc453, 0x687b,
+	0x0005, 0x080c, 0x6d9f, 0x009e, 0x080c, 0xac2b, 0x9085, 0x0001,
+	0x0005, 0x2001, 0x0001, 0x080c, 0x6580, 0x0156, 0x0016, 0x0026,
+	0x0036, 0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x0276, 0x080c,
+	0xbbc1, 0x003e, 0x002e, 0x001e, 0x015e, 0x9005, 0x0005, 0x00f6,
+	0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066, 0x00b6, 0x0126, 0x2091,
+	0x8000, 0x2740, 0x2061, 0x1ddc, 0x2079, 0x0001, 0x8fff, 0x0904,
+	0xe209, 0x2071, 0x1800, 0x7654, 0x7074, 0x8001, 0x9602, 0x1a04,
+	0xe209, 0x88ff, 0x0120, 0x2800, 0x9c06, 0x1590, 0x2078, 0x080c,
+	0xe347, 0x0570, 0x2400, 0x9c06, 0x0558, 0x6720, 0x9786, 0x0006,
+	0x1538, 0x9786, 0x0007, 0x0520, 0x88ff, 0x1140, 0x6010, 0x9b06,
+	0x11f8, 0x85ff, 0x0118, 0x605c, 0x9106, 0x11d0, 0x0096, 0x601c,
+	0xd084, 0x0140, 0x080c, 0xe571, 0x080c, 0xcf9c, 0x080c, 0x1a94,
+	0x6023, 0x0007, 0x6014, 0x2048, 0x080c, 0xc865, 0x0120, 0x0046,
+	0x080c, 0xe2b9, 0x004e, 0x009e, 0x080c, 0xac2b, 0x88ff, 0x1198,
+	0x9ce0, 0x001c, 0x2001, 0x181a, 0x2004, 0x9c02, 0x1210, 0x0804,
+	0xe1be, 0x9006, 0x012e, 0x00be, 0x006e, 0x007e, 0x008e, 0x00ce,
+	0x00ee, 0x00fe, 0x0005, 0x98c5, 0x0001, 0x0ca0, 0x080c, 0xa899,
+	0x00b6, 0x0076, 0x0056, 0x0086, 0x9046, 0x2029, 0x0001, 0x2c20,
+	0x2019, 0x0002, 0x6210, 0x2258, 0x0096, 0x904e, 0x080c, 0xa207,
+	0x009e, 0x008e, 0x903e, 0x080c, 0xa2b2, 0x080c, 0xe1af, 0x005e,
+	0x007e, 0x00be, 0x080c, 0xa8b5, 0x0005, 0x080c, 0xa899, 0x00b6,
+	0x0046, 0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20, 0x2128, 0x20a9,
+	0x007f, 0x900e, 0x0016, 0x0036, 0x080c, 0x6644, 0x1190, 0x0056,
+	0x0086, 0x9046, 0x2508, 0x2029, 0x0001, 0x0096, 0x904e, 0x080c,
+	0xa207, 0x009e, 0x008e, 0x903e, 0x080c, 0xa2b2, 0x080c, 0xe1af,
+	0x005e, 0x003e, 0x001e, 0x8108, 0x1f04, 0xe242, 0x015e, 0x00ce,
+	0x007e, 0x005e, 0x004e, 0x00be, 0x080c, 0xa8b5, 0x0005, 0x080c,
+	0xa899, 0x00b6, 0x0076, 0x0056, 0x6210, 0x2258, 0x0086, 0x9046,
+	0x2029, 0x0001, 0x2019, 0x0048, 0x0096, 0x904e, 0x080c, 0xa207,
+	0x009e, 0x008e, 0x903e, 0x080c, 0xa2b2, 0x2c20, 0x080c, 0xe1af,
+	0x005e, 0x007e, 0x00be, 0x080c, 0xa8b5, 0x0005, 0x080c, 0xa899,
+	0x00b6, 0x0046, 0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20, 0x20a9,
+	0x0800, 0x900e, 0x0016, 0x0036, 0x080c, 0x6644, 0x11a0, 0x0086,
+	0x9046, 0x2828, 0x0046, 0x2021, 0x0001, 0x080c, 0xe555, 0x004e,
+	0x0096, 0x904e, 0x080c, 0xa207, 0x009e, 0x008e, 0x903e, 0x080c,
+	0xa2b2, 0x080c, 0xe1af, 0x003e, 0x001e, 0x8108, 0x1f04, 0xe292,
+	0x015e, 0x00ce, 0x007e, 0x005e, 0x004e, 0x00be, 0x080c, 0xa8b5,
+	0x0005, 0x0016, 0x00f6, 0x080c, 0xc863, 0x0198, 0xa864, 0x9084,
+	0x00ff, 0x9086, 0x0046, 0x0180, 0xa800, 0x907d, 0x0138, 0xa803,
+	0x0000, 0xab82, 0x080c, 0x6d9f, 0x2f48, 0x0cb0, 0xab82, 0x080c,
+	0x6d9f, 0x00fe, 0x001e, 0x0005, 0xa800, 0x907d, 0x0130, 0xa803,
+	0x0000, 0x080c, 0x6d9f, 0x2f48, 0x0cb8, 0x080c, 0x6d9f, 0x0c88,
+	0x00e6, 0x0046, 0x0036, 0x2061, 0x1ddc, 0x9005, 0x1138, 0x2071,
+	0x1800, 0x7454, 0x7074, 0x8001, 0x9402, 0x12f8, 0x2100, 0x9c06,
+	0x0188, 0x6000, 0x9086, 0x0000, 0x0168, 0x6008, 0x9206, 0x1150,
+	0x6320, 0x9386, 0x0009, 0x01b0, 0x6010, 0x91a0, 0x0004, 0x2424,
+	0x9406, 0x0140, 0x9ce0, 0x001c, 0x2001, 0x181a, 0x2004, 0x9c02,
+	0x1220, 0x0c20, 0x9085, 0x0001, 0x0008, 0x9006, 0x003e, 0x004e,
+	0x00ee, 0x0005, 0x631c, 0xd3c4, 0x1d68, 0x0c30, 0x0096, 0x0006,
+	0x080c, 0x1047, 0x000e, 0x090c, 0x0d7d, 0xaae2, 0xa867, 0x010d,
+	0xa88e, 0x0026, 0x2010, 0x080c, 0xc853, 0x2001, 0x0000, 0x0120,
+	0x2200, 0x9080, 0x0017, 0x2004, 0x002e, 0xa87a, 0x9186, 0x0020,
+	0x0110, 0xa8e3, 0xffff, 0xa986, 0xac76, 0xa87f, 0x0000, 0x2001,
+	0x198d, 0x2004, 0xa882, 0x9006, 0xa802, 0xa86a, 0xa88a, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x6d9f, 0x012e, 0x009e, 0x0005, 0x6700,
+	0x9786, 0x0000, 0x0158, 0x9786, 0x0001, 0x0140, 0x9786, 0x000a,
+	0x0128, 0x9786, 0x0009, 0x0110, 0x9085, 0x0001, 0x0005, 0x00e6,
+	0x6010, 0x9075, 0x0138, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206,
+	0x00ee, 0x0005, 0x9085, 0x0001, 0x0cd8, 0x0016, 0x6004, 0x908e,
+	0x001e, 0x11a0, 0x8007, 0x6134, 0x918c, 0x00ff, 0x9105, 0x6036,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0005, 0x2001, 0x1986,
+	0x2004, 0x601a, 0x2009, 0x8020, 0x080c, 0x9239, 0x001e, 0x0005,
+	0xa001, 0xa001, 0x0005, 0x6024, 0xd0e4, 0x0158, 0xd0cc, 0x0118,
+	0x080c, 0xcbaf, 0x0030, 0x080c, 0xe571, 0x080c, 0x88d7, 0x080c,
+	0xabf0, 0x0005, 0x9280, 0x0008, 0x2004, 0x9084, 0x000f, 0x0002,
+	0xe3a6, 0xe3a6, 0xe3a6, 0xe3a8, 0xe3a6, 0xe3a8, 0xe3a8, 0xe3a6,
+	0xe3a8, 0xe3a6, 0xe3a6, 0xe3a6, 0xe3a6, 0xe3a6, 0x9006, 0x0005,
+	0x9085, 0x0001, 0x0005, 0x9280, 0x0008, 0x2004, 0x9084, 0x000f,
+	0x0002, 0xe3bf, 0xe3bf, 0xe3bf, 0xe3bf, 0xe3bf, 0xe3bf, 0xe3cc,
+	0xe3bf, 0xe3bf, 0xe3bf, 0xe3bf, 0xe3bf, 0xe3bf, 0xe3bf, 0x6007,
+	0x003b, 0x602f, 0x0009, 0x6017, 0x2a00, 0x6003, 0x0001, 0x2009,
+	0x8020, 0x080c, 0x9239, 0x0005, 0x0096, 0x00c6, 0x2260, 0x080c,
+	0xe571, 0x604b, 0x0000, 0x6024, 0xc0f4, 0xc0e4, 0x6026, 0x603b,
+	0x0000, 0x00ce, 0x00d6, 0x2268, 0x9186, 0x0007, 0x1904, 0xe425,
+	0x6814, 0x9005, 0x0138, 0x2048, 0xa87c, 0xd0fc, 0x1118, 0x00de,
+	0x009e, 0x08a8, 0x6007, 0x003a, 0x6003, 0x0001, 0x2009, 0x8020,
+	0x080c, 0x9239, 0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002, 0x1904,
+	0xe49c, 0x6014, 0x9005, 0x1138, 0x6000, 0x9086, 0x0007, 0x190c,
+	0x0d7d, 0x0804, 0xe49c, 0x2048, 0x080c, 0xc865, 0x1130, 0x0028,
+	0x2048, 0xa800, 0x9005, 0x1de0, 0x2900, 0x2048, 0xa87c, 0x9084,
+	0x0003, 0x9086, 0x0002, 0x1168, 0xa87c, 0xc0dc, 0xc0f4, 0xa87e,
+	0xa880, 0xc0fc, 0xa882, 0x2009, 0x0043, 0x080c, 0xdca4, 0x0804,
+	0xe49c, 0x2009, 0x0041, 0x0804, 0xe496, 0x9186, 0x0005, 0x15a0,
+	0x6814, 0x2048, 0xa87c, 0xd0bc, 0x1120, 0x00de, 0x009e, 0x0804,
+	0xe3bf, 0xd0b4, 0x0128, 0xd0fc, 0x090c, 0x0d7d, 0x0804, 0xe3e0,
+	0x6007, 0x003a, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x9239,
+	0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002, 0x0120, 0x9186, 0x0004,
+	0x1904, 0xe49c, 0x6814, 0x2048, 0xa97c, 0xc1f4, 0xc1dc, 0xa97e,
+	0xa980, 0xc1fc, 0xc1bc, 0xa982, 0x00f6, 0x2c78, 0x080c, 0x174b,
+	0x00fe, 0x2009, 0x0042, 0x04d0, 0x0036, 0x080c, 0x1047, 0x090c,
+	0x0d7d, 0xa867, 0x010d, 0x9006, 0xa802, 0xa86a, 0xa88a, 0x2d18,
+	0xab8e, 0xa887, 0x0045, 0x2c00, 0xa892, 0x6038, 0xa8a2, 0x2360,
+	0x6024, 0xc0dd, 0x6026, 0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be,
+	0x2004, 0x635c, 0xab7a, 0xa876, 0x9006, 0xa87e, 0xa882, 0xad9a,
+	0xae96, 0xa89f, 0x0001, 0x080c, 0x6d9f, 0x2019, 0x0045, 0x6008,
+	0x2068, 0x080c, 0xde67, 0x2d00, 0x600a, 0x6023, 0x0006, 0x6003,
+	0x0007, 0x901e, 0x631a, 0x634a, 0x003e, 0x0038, 0x604b, 0x0000,
+	0x6003, 0x0007, 0x080c, 0xdca4, 0x00ce, 0x00de, 0x009e, 0x0005,
+	0x9186, 0x0013, 0x1128, 0x6004, 0x9082, 0x0085, 0x2008, 0x00c2,
+	0x9186, 0x0027, 0x1178, 0x080c, 0x95ff, 0x0036, 0x0096, 0x6014,
+	0x2048, 0x2019, 0x0004, 0x080c, 0xe2b9, 0x009e, 0x003e, 0x080c,
+	0x96bd, 0x0005, 0x9186, 0x0014, 0x0d70, 0x080c, 0xacaa, 0x0005,
+	0xe4cf, 0xe4cd, 0xe4cd, 0xe4cd, 0xe4cd, 0xe4cd, 0xe4cf, 0xe4cd,
+	0xe4cd, 0xe4cd, 0xe4cd, 0xe4cd, 0xe4cd, 0x080c, 0x0d7d, 0x6003,
+	0x000c, 0x080c, 0x96bd, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182,
+	0x0085, 0x0208, 0x001a, 0x080c, 0xacaa, 0x0005, 0xe4eb, 0xe4eb,
+	0xe4eb, 0xe4eb, 0xe4ed, 0xe50d, 0xe4eb, 0xe4eb, 0xe4eb, 0xe4eb,
+	0xe4eb, 0xe4eb, 0xe4eb, 0x080c, 0x0d7d, 0x00d6, 0x2c68, 0x080c,
+	0xab9a, 0x01b0, 0x6003, 0x0001, 0x6007, 0x001e, 0x2009, 0x026e,
+	0x210c, 0x613a, 0x2009, 0x026f, 0x210c, 0x613e, 0x600b, 0xffff,
+	0x6910, 0x6112, 0x6023, 0x0004, 0x2009, 0x8020, 0x080c, 0x9239,
+	0x2d60, 0x080c, 0xabf0, 0x00de, 0x0005, 0x080c, 0xabf0, 0x0005,
+	0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ec, 0x00ee,
+	0x0005, 0x2009, 0x1867, 0x210c, 0xd1ec, 0x05b0, 0x6003, 0x0002,
+	0x6024, 0xc0e5, 0x6026, 0xd0cc, 0x0150, 0x2001, 0x1987, 0x2004,
+	0x604a, 0x2009, 0x1867, 0x210c, 0xd1f4, 0x1520, 0x00a0, 0x2009,
+	0x1867, 0x210c, 0xd1f4, 0x0128, 0x6024, 0xc0e4, 0x6026, 0x9006,
+	0x00d8, 0x2001, 0x1987, 0x200c, 0x2001, 0x1985, 0x2004, 0x9100,
+	0x9080, 0x000a, 0x604a, 0x6010, 0x00b6, 0x2058, 0xb8bc, 0x00be,
+	0x0008, 0x2104, 0x9005, 0x0118, 0x9088, 0x0003, 0x0cd0, 0x2c0a,
+	0x600f, 0x0000, 0x9085, 0x0001, 0x0005, 0x0016, 0x00c6, 0x00e6,
+	0x615c, 0xb8bc, 0x2060, 0x8cff, 0x0180, 0x84ff, 0x1118, 0x605c,
+	0x9106, 0x1138, 0x600c, 0x2072, 0x080c, 0x88d7, 0x080c, 0xabf0,
+	0x0010, 0x9cf0, 0x0003, 0x2e64, 0x0c70, 0x00ee, 0x00ce, 0x001e,
+	0x0005, 0x00d6, 0x00b6, 0x6010, 0x2058, 0xb8bc, 0x2068, 0x9005,
+	0x0130, 0x9c06, 0x0110, 0x680c, 0x0cd0, 0x600c, 0x680e, 0x00be,
+	0x00de, 0x0005, 0x0026, 0x0036, 0x0156, 0x2011, 0x182c, 0x2204,
+	0x9084, 0x00ff, 0x2019, 0x026e, 0x2334, 0x9636, 0x1508, 0x8318,
+	0x2334, 0x2204, 0x9084, 0xff00, 0x9636, 0x11d0, 0x2011, 0x0270,
+	0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c,
+	0xbbd5, 0x009e, 0x1168, 0x2011, 0x0274, 0x20a9, 0x0004, 0x6010,
+	0x0096, 0x2048, 0x2019, 0x0006, 0x080c, 0xbbd5, 0x009e, 0x1100,
+	0x015e, 0x003e, 0x002e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c,
+	0x5fd7, 0x080c, 0x2fe0, 0x00ee, 0x0005, 0x0096, 0x0026, 0x080c,
+	0x1047, 0x090c, 0x0d7d, 0xa85c, 0x9080, 0x001a, 0x20a0, 0x20a9,
+	0x000c, 0xa860, 0x20e8, 0x9006, 0x4004, 0x9186, 0x0046, 0x1118,
+	0xa867, 0x0136, 0x0038, 0xa867, 0x0138, 0x9186, 0x0041, 0x0110,
+	0xa87b, 0x0001, 0x7038, 0x9084, 0xff00, 0x7240, 0x9294, 0xff00,
+	0x8007, 0x9215, 0xaa9a, 0x9186, 0x0046, 0x1168, 0x7038, 0x9084,
+	0x00ff, 0x723c, 0x9294, 0xff00, 0x9215, 0xaa9e, 0x723c, 0x9294,
+	0x00ff, 0xaaa2, 0x0060, 0x7040, 0x9084, 0x00ff, 0x7244, 0x9294,
+	0xff00, 0x9215, 0xaa9e, 0x7244, 0x9294, 0x00ff, 0xaaa2, 0x9186,
+	0x0046, 0x1118, 0x9e90, 0x0012, 0x0010, 0x9e90, 0x001a, 0x2204,
+	0x8007, 0xa8a6, 0x8210, 0x2204, 0x8007, 0xa8aa, 0x8210, 0x2204,
+	0x8007, 0xa8ae, 0x8210, 0x2204, 0x8007, 0xa8b2, 0x8210, 0x9186,
+	0x0046, 0x11b8, 0x9e90, 0x0016, 0x2204, 0x8007, 0xa8b6, 0x8210,
+	0x2204, 0x8007, 0xa8ba, 0x8210, 0x2204, 0x8007, 0xa8be, 0x8210,
+	0x2204, 0x8007, 0xa8c2, 0x8210, 0x2011, 0x0205, 0x2013, 0x0001,
+	0x00b0, 0x9e90, 0x001e, 0x2204, 0x8007, 0xa8b6, 0x8210, 0x2204,
+	0x8007, 0xa8ba, 0x2011, 0x0205, 0x2013, 0x0001, 0x2011, 0x0260,
+	0x2204, 0x8007, 0xa8be, 0x8210, 0x2204, 0x8007, 0xa8c2, 0x9186,
+	0x0046, 0x1118, 0x2011, 0x0262, 0x0010, 0x2011, 0x026a, 0x0146,
+	0x01d6, 0x0036, 0x20a9, 0x0001, 0x2019, 0x0008, 0xa860, 0x20e8,
+	0xa85c, 0x9080, 0x0031, 0x20a0, 0x2204, 0x8007, 0x4004, 0x8210,
+	0x8319, 0x1dd0, 0x003e, 0x01ce, 0x013e, 0x2011, 0x0205, 0x2013,
+	0x0000, 0x002e, 0x080c, 0x6d9f, 0x009e, 0x0005, 0x00e6, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0fc, 0x0108, 0x0011, 0x00ee,
+	0x0005, 0xa880, 0xc0e5, 0xa882, 0x0005, 0x00e6, 0x00d6, 0x00c6,
+	0x0076, 0x0066, 0x0056, 0x0046, 0x0026, 0x0016, 0x0126, 0x2091,
+	0x8000, 0x2029, 0x19f2, 0x252c, 0x2021, 0x19f9, 0x2424, 0x2061,
+	0x1ddc, 0x2071, 0x1800, 0x7654, 0x7074, 0x9606, 0x0578, 0x6720,
+	0x9786, 0x0001, 0x0118, 0x9786, 0x0008, 0x1500, 0x2500, 0x9c06,
+	0x01e8, 0x2400, 0x9c06, 0x01d0, 0x080c, 0xe347, 0x01b8, 0x080c,
+	0xe357, 0x11a0, 0x6000, 0x9086, 0x0004, 0x1120, 0x0016, 0x080c,
+	0x1a94, 0x001e, 0x080c, 0xca69, 0x1110, 0x080c, 0x323e, 0x080c,
+	0xca7a, 0x1110, 0x080c, 0xb5c6, 0x080c, 0xac2b, 0x9ce0, 0x001c,
+	0x2001, 0x181a, 0x2004, 0x9c02, 0x1208, 0x0858, 0x012e, 0x001e,
+	0x002e, 0x004e, 0x005e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee,
+	0x0005, 0x2001, 0x1810, 0x2004, 0xd0dc, 0x0005, 0x0006, 0x2001,
+	0x1837, 0x2004, 0xd09c, 0x000e, 0x0005, 0x0006, 0x0036, 0x0046,
+	0x080c, 0xcf84, 0x0168, 0x2019, 0xffff, 0x9005, 0x0128, 0x6010,
+	0x00b6, 0x2058, 0xbba0, 0x00be, 0x2021, 0x0004, 0x080c, 0x4ce0,
+	0x004e, 0x003e, 0x000e, 0x6004, 0x9086, 0x0001, 0x1128, 0x080c,
+	0xa37f, 0x080c, 0xac2b, 0x9006, 0x0005, 0x00e6, 0x00c6, 0x00b6,
+	0x0046, 0x2061, 0x1ddc, 0x2071, 0x1800, 0x7454, 0x7074, 0x8001,
+	0x9402, 0x12b8, 0x2100, 0x9c06, 0x0148, 0x6000, 0x9086, 0x0000,
+	0x0128, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x0140, 0x9ce0, 0x001c,
+	0x2001, 0x181a, 0x2004, 0x9c02, 0x1220, 0x0c60, 0x9085, 0x0001,
+	0x0008, 0x9006, 0x004e, 0x00be, 0x00ce, 0x00ee, 0x0005, 0x0126,
+	0x0006, 0x00e6, 0x0016, 0x2091, 0x8000, 0x2071, 0x1840, 0xd5a4,
+	0x0118, 0x7004, 0x8000, 0x7006, 0xd5b4, 0x0118, 0x7000, 0x8000,
+	0x7002, 0xd5ac, 0x0178, 0x2500, 0x9084, 0x0007, 0x908e, 0x0003,
+	0x0148, 0x908e, 0x0004, 0x0130, 0x908e, 0x0005, 0x0118, 0x2071,
+	0xfff6, 0x0089, 0x001e, 0x00ee, 0x000e, 0x012e, 0x0005, 0x0126,
+	0x0006, 0x00e6, 0x2091, 0x8000, 0x2071, 0xffee, 0x0021, 0x00ee,
+	0x000e, 0x012e, 0x0005, 0x2e05, 0x8000, 0x2077, 0x1220, 0x8e70,
+	0x2e05, 0x8000, 0x2077, 0x0005, 0x00e6, 0x2071, 0xffec, 0x0c99,
+	0x00ee, 0x0005, 0x00e6, 0x2071, 0xfff0, 0x0c69, 0x00ee, 0x0005,
+	0x0126, 0x0006, 0x00e6, 0x2091, 0x8000, 0x2071, 0x1840, 0x7014,
+	0x8000, 0x7016, 0x00ee, 0x000e, 0x012e, 0x0005, 0x0001, 0x0002,
+	0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200,
+	0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0x97f5
 };
 #ifdef UNIQUE_FW_NAME
-unsigned short fw2322ipx_length01 = 0xdf52;
+unsigned short fw2322ipx_length01 = 0xdf8f;
 #else
-unsigned short risc_code_length01 = 0xdf52;
+unsigned short risc_code_length01 = 0xdf8f;
 #endif
 
 /*
@@ -7689,7 +7696,7 @@
 	0x0002, 0x1f43, 0x001b, 0x1261, 0x0001, 0xff88, 0x0000, 0x0002,
 	0x0003, 0x0263, 0x0001, 0xff88, 0x0000, 0x0004, 0x0000, 0xff31,
 	0x0015, 0x0033, 0x0000, 0xb011, 0x000b, 0x8266, 0x0000, 0xb0ff,
-	0x0011, 0x16a0, 0x0000, 0xff16, 0x000b, 0x24e2, 0x0002, 0xb100,
+	0x0011, 0x16a0, 0x0000, 0xff16, 0x001b, 0x226d, 0x0002, 0xb100,
 	0x0013, 0x026e, 0x0010, 0xb1ff, 0x0001, 0x17a0, 0x0010, 0xff17,
 	0x0013, 0x022c, 0x0000, 0x16ff, 0x0001, 0x18a0, 0x0010, 0xff00,
 	0x000b, 0x2278, 0x0002, 0x1700, 0x0003, 0x12cb, 0x0013, 0x0279,
@@ -8073,6 +8080,6 @@
 	0x000b, 0x885c, 0x0012, 0x1027, 0x0010, 0xffb2, 0x0011, 0x1388,
 	0x0010, 0x0011, 0x0000, 0xff31, 0x0015, 0x0033, 0x0010, 0xb20a,
 	0x001b, 0x8864, 0x0015, 0x00b8, 0x0000, 0x0007, 0x0003, 0x4867,
-	0x0000, 0xb838, 0x0017, 0x4000, 0xa317, 0x2238
+	0x0000, 0xb838, 0x0017, 0x4000, 0xa307, 0x24ad
 };
 unsigned short xseqipx_code_length01 = 0x10d6;
diff -Nru a/drivers/scsi/qla2xxx/ql6312_fw.c b/drivers/scsi/qla2xxx/ql6312_fw.c
--- a/drivers/scsi/qla2xxx/ql6312_fw.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/scsi/qla2xxx/ql6312_fw.c	2004-12-24 13:36:19 -08:00
@@ -18,25 +18,25 @@
  *************************************************************************/
 
 /*
- *	Firmware Version 3.02.30 (07:52 Jun 16, 2004)
+ *	Firmware Version 3.03.02 (16:50 Aug 10, 2004)
  */
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw2300flx_version = 3*1024+2;
+unsigned short fw2300flx_version = 3*1024+3;
 #else
-unsigned short risc_code_version = 3*1024+2;
+unsigned short risc_code_version = 3*1024+3;
 #endif
 
 #ifdef UNIQUE_FW_NAME
-unsigned char fw2300flx_version_str[] = {3, 2,30};
+unsigned char fw2300flx_version_str[] = {3, 3, 2};
 #else
-unsigned char firmware_version[] = {3, 2,30};
+unsigned char firmware_version[] = {3, 3, 2};
 #endif
 
 #ifdef UNIQUE_FW_NAME
-#define fw2300flx_VERSION_STRING "3.02.30"
+#define fw2300flx_VERSION_STRING "3.03.02"
 #else
-#define FW_VERSION_STRING "3.02.30"
+#define FW_VERSION_STRING "3.03.02"
 #endif
 
 #ifdef UNIQUE_FW_NAME
@@ -50,12 +50,12 @@
 #else
 unsigned short risc_code01[] = { 
 #endif
-	0x0470, 0x0000, 0x0000, 0xd5bb, 0x0000, 0x0003, 0x0002, 0x001e,
+	0x0470, 0x0000, 0x0000, 0xd5d4, 0x0000, 0x0003, 0x0003, 0x0002,
 	0x0317, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2032, 0x3030,
 	0x3120, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
 	0x5449, 0x4f4e, 0x2049, 0x5350, 0x3233, 0x3030, 0x2046, 0x6972,
 	0x6d77, 0x6172, 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030,
-	0x332e, 0x3032, 0x2e33, 0x3020, 0x2020, 0x2020, 0x2400, 0x20a9,
+	0x332e, 0x3033, 0x2e30, 0x3220, 0x2020, 0x2020, 0x2400, 0x20a9,
 	0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2200, 0x20a9, 0x000f,
 	0x2001, 0x0000, 0x400f, 0x2091, 0x2400, 0x20a9, 0x000f, 0x2001,
 	0x0000, 0x400f, 0x2091, 0x2600, 0x20a9, 0x000f, 0x2001, 0x0000,
@@ -64,171 +64,171 @@
 	0x2c00, 0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2e00,
 	0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2000, 0x2001,
 	0x0000, 0x20c1, 0x0004, 0x20c9, 0x1bff, 0x2059, 0x0000, 0x2b78,
-	0x7883, 0x0004, 0x2089, 0x2b50, 0x2051, 0x1800, 0x2a70, 0x20e1,
+	0x7883, 0x0004, 0x2089, 0x2b5b, 0x2051, 0x1800, 0x2a70, 0x20e1,
 	0x0001, 0x20e9, 0x0001, 0x2009, 0x0000, 0x080c, 0x0e2f, 0x2029,
 	0x2480, 0x2031, 0xffff, 0x2039, 0x2450, 0x2021, 0x0050, 0x20e9,
 	0x0001, 0x20a1, 0x0000, 0x20a9, 0x0800, 0x900e, 0x4104, 0x20e9,
 	0x0001, 0x20a1, 0x1000, 0x900e, 0x2001, 0x0cc0, 0x9084, 0x0fff,
 	0x20a8, 0x4104, 0x2001, 0x0000, 0x9086, 0x0000, 0x0120, 0x21a8,
 	0x4104, 0x8001, 0x1de0, 0x756a, 0x766e, 0x7766, 0x7472, 0x7476,
-	0x00e6, 0x2071, 0x1a97, 0x2472, 0x00ee, 0x20a1, 0x1cd0, 0x716c,
+	0x00e6, 0x2071, 0x1a9f, 0x2472, 0x00ee, 0x20a1, 0x1cd0, 0x716c,
 	0x810d, 0x810d, 0x810d, 0x810d, 0x918c, 0x000f, 0x2001, 0x0001,
 	0x9112, 0x900e, 0x21a8, 0x4104, 0x8211, 0x1de0, 0x716c, 0x3400,
 	0x8001, 0x9102, 0x0120, 0x0218, 0x20a8, 0x900e, 0x4104, 0x2009,
 	0x1800, 0x810d, 0x810d, 0x810d, 0x810d, 0x810d, 0x918c, 0x001f,
 	0x2001, 0x0001, 0x9112, 0x20e9, 0x0001, 0x20a1, 0x0800, 0x900e,
 	0x20a9, 0x0800, 0x4104, 0x8211, 0x1dd8, 0x080c, 0x0f03, 0x080c,
-	0x5ce8, 0x080c, 0x9dd8, 0x080c, 0x10ba, 0x080c, 0x129f, 0x080c,
-	0x1a55, 0x080c, 0x0d46, 0x080c, 0x103f, 0x080c, 0x323a, 0x080c,
-	0x7293, 0x080c, 0x6626, 0x080c, 0x7f5c, 0x080c, 0x230c, 0x080c,
-	0x8289, 0x080c, 0x791c, 0x080c, 0x2149, 0x080c, 0x227d, 0x080c,
-	0x2301, 0x2091, 0x3009, 0x7883, 0x0000, 0x1004, 0x091d, 0x7880,
+	0x5cf3, 0x080c, 0x9dc5, 0x080c, 0x10ba, 0x080c, 0x129f, 0x080c,
+	0x1a60, 0x080c, 0x0d46, 0x080c, 0x103f, 0x080c, 0x3245, 0x080c,
+	0x72a0, 0x080c, 0x6635, 0x080c, 0x7f7a, 0x080c, 0x2317, 0x080c,
+	0x82a7, 0x080c, 0x792a, 0x080c, 0x2154, 0x080c, 0x2288, 0x080c,
+	0x230c, 0x2091, 0x3009, 0x7883, 0x0000, 0x1004, 0x091d, 0x7880,
 	0x9086, 0x0002, 0x1190, 0x7883, 0x4000, 0x7837, 0x4000, 0x7833,
 	0x0010, 0x0e04, 0x0911, 0x2091, 0x5000, 0x2091, 0x4080, 0x2001,
 	0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x2071, 0x1800, 0x7003,
 	0x0000, 0x2071, 0x1800, 0x7000, 0x908e, 0x0003, 0x1168, 0x080c,
-	0x49ae, 0x080c, 0x3261, 0x080c, 0x7304, 0x080c, 0x6ad6, 0x080c,
-	0x7f85, 0x080c, 0x2aba, 0x0c68, 0x000b, 0x0c88, 0x0940, 0x0941,
+	0x49b9, 0x080c, 0x326c, 0x080c, 0x7311, 0x080c, 0x6ae5, 0x080c,
+	0x7fa3, 0x080c, 0x2ac5, 0x0c68, 0x000b, 0x0c88, 0x0940, 0x0941,
 	0x0ad8, 0x093e, 0x0b8f, 0x0d45, 0x0d45, 0x0d45, 0x080c, 0x0db4,
 	0x0005, 0x0126, 0x00f6, 0x2091, 0x8000, 0x7000, 0x9086, 0x0001,
-	0x1904, 0x0aab, 0x080c, 0x0e71, 0x080c, 0x6f9b, 0x0150, 0x080c,
-	0x6fbe, 0x15a0, 0x2079, 0x0100, 0x7828, 0x9085, 0x1800, 0x782a,
-	0x0468, 0x080c, 0x6ecd, 0x7000, 0x9086, 0x0001, 0x1904, 0x0aab,
-	0x7094, 0x9086, 0x0028, 0x1904, 0x0aab, 0x080c, 0x7f54, 0x080c,
-	0x7f46, 0x2001, 0x0161, 0x2003, 0x0001, 0x2079, 0x0100, 0x7827,
-	0xffff, 0x7a28, 0x9295, 0x5e2f, 0x7a2a, 0x2011, 0x6e1c, 0x080c,
-	0x8021, 0x2011, 0x6e0f, 0x080c, 0x80f5, 0x2011, 0x5b43, 0x080c,
-	0x8021, 0x2011, 0x8030, 0x901e, 0x7392, 0x04d0, 0x080c, 0x53f0,
-	0x2079, 0x0100, 0x7844, 0x9005, 0x1904, 0x0aab, 0x2011, 0x5b43,
-	0x080c, 0x8021, 0x2011, 0x6e1c, 0x080c, 0x8021, 0x2011, 0x6e0f,
-	0x080c, 0x80f5, 0x2001, 0x0265, 0x2001, 0x0205, 0x2003, 0x0000,
-	0x7840, 0x9084, 0xfffb, 0x7842, 0x2001, 0x1976, 0x2004, 0x9005,
-	0x1140, 0x00c6, 0x2061, 0x0100, 0x080c, 0x5c90, 0x00ce, 0x0804,
-	0x0aab, 0x780f, 0x006b, 0x7a28, 0x080c, 0x6fa3, 0x0118, 0x9295,
+	0x1904, 0x0aab, 0x080c, 0x0e71, 0x080c, 0x6faa, 0x0150, 0x080c,
+	0x6fcd, 0x15a0, 0x2079, 0x0100, 0x7828, 0x9085, 0x1800, 0x782a,
+	0x0468, 0x080c, 0x6edc, 0x7000, 0x9086, 0x0001, 0x1904, 0x0aab,
+	0x7094, 0x9086, 0x0028, 0x1904, 0x0aab, 0x080c, 0x7f72, 0x080c,
+	0x7f64, 0x2001, 0x0161, 0x2003, 0x0001, 0x2079, 0x0100, 0x7827,
+	0xffff, 0x7a28, 0x9295, 0x5e2f, 0x7a2a, 0x2011, 0x6e2b, 0x080c,
+	0x803f, 0x2011, 0x6e1e, 0x080c, 0x8113, 0x2011, 0x5b4e, 0x080c,
+	0x803f, 0x2011, 0x8030, 0x901e, 0x7392, 0x04d0, 0x080c, 0x53fb,
+	0x2079, 0x0100, 0x7844, 0x9005, 0x1904, 0x0aab, 0x2011, 0x5b4e,
+	0x080c, 0x803f, 0x2011, 0x6e2b, 0x080c, 0x803f, 0x2011, 0x6e1e,
+	0x080c, 0x8113, 0x2001, 0x0265, 0x2001, 0x0205, 0x2003, 0x0000,
+	0x7840, 0x9084, 0xfffb, 0x7842, 0x2001, 0x197e, 0x2004, 0x9005,
+	0x1140, 0x00c6, 0x2061, 0x0100, 0x080c, 0x5c9b, 0x00ce, 0x0804,
+	0x0aab, 0x780f, 0x006b, 0x7a28, 0x080c, 0x6fb2, 0x0118, 0x9295,
 	0x5e2f, 0x0010, 0x9295, 0x402f, 0x7a2a, 0x2011, 0x8010, 0x73d4,
-	0x2001, 0x1977, 0x2003, 0x0001, 0x080c, 0x2980, 0x080c, 0x48e9,
+	0x2001, 0x197f, 0x2003, 0x0001, 0x080c, 0x298b, 0x080c, 0x48f4,
 	0x7244, 0xc284, 0x7246, 0x2001, 0x180c, 0x200c, 0xc1ac, 0xc1cc,
-	0x2102, 0x080c, 0x9640, 0x2011, 0x0004, 0x080c, 0xbb3c, 0x080c,
-	0x646a, 0x080c, 0x6f9b, 0x1120, 0x080c, 0x29c4, 0x02e0, 0x0400,
-	0x080c, 0x5c97, 0x0140, 0x7093, 0x0001, 0x70cf, 0x0000, 0x080c,
-	0x55bd, 0x0804, 0x0aab, 0x080c, 0x538f, 0xd094, 0x0188, 0x2011,
-	0x180c, 0x2204, 0xc0cd, 0x2012, 0x080c, 0x5393, 0xd0d4, 0x1118,
-	0x080c, 0x29c4, 0x1270, 0x2011, 0x180c, 0x2204, 0xc0bc, 0x0088,
-	0x080c, 0x5393, 0xd0d4, 0x1db8, 0x2011, 0x180c, 0x2204, 0xc0bd,
-	0x0040, 0x2011, 0x180c, 0x2204, 0xc0bd, 0x2012, 0x080c, 0x6563,
-	0x0008, 0x2012, 0x080c, 0x6529, 0x0120, 0x7a0c, 0xc2b4, 0x7a0e,
-	0x00a8, 0x707b, 0x0000, 0x080c, 0x6f9b, 0x1130, 0x70ac, 0x9005,
-	0x1168, 0x080c, 0xbf7d, 0x0050, 0x080c, 0xbf7d, 0x70d8, 0xd09c,
-	0x1128, 0x70ac, 0x9005, 0x0110, 0x080c, 0x5c6d, 0x70e3, 0x0000,
-	0x70df, 0x0000, 0x70a3, 0x0000, 0x080c, 0x29cc, 0x0228, 0x2011,
-	0x0101, 0x2204, 0xc0c4, 0x2012, 0x72d8, 0x080c, 0x6f9b, 0x1178,
-	0x9016, 0x0016, 0x2009, 0x0002, 0x2019, 0x193d, 0x211a, 0x001e,
+	0x2102, 0x080c, 0x9650, 0x2011, 0x0004, 0x080c, 0xbb4b, 0x080c,
+	0x6479, 0x080c, 0x6faa, 0x1120, 0x080c, 0x29cf, 0x02e0, 0x0400,
+	0x080c, 0x5ca2, 0x0140, 0x7093, 0x0001, 0x70cf, 0x0000, 0x080c,
+	0x55c8, 0x0804, 0x0aab, 0x080c, 0x539a, 0xd094, 0x0188, 0x2011,
+	0x180c, 0x2204, 0xc0cd, 0x2012, 0x080c, 0x539e, 0xd0d4, 0x1118,
+	0x080c, 0x29cf, 0x1270, 0x2011, 0x180c, 0x2204, 0xc0bc, 0x0088,
+	0x080c, 0x539e, 0xd0d4, 0x1db8, 0x2011, 0x180c, 0x2204, 0xc0bd,
+	0x0040, 0x2011, 0x180c, 0x2204, 0xc0bd, 0x2012, 0x080c, 0x6572,
+	0x0008, 0x2012, 0x080c, 0x6538, 0x0120, 0x7a0c, 0xc2b4, 0x7a0e,
+	0x00a8, 0x707b, 0x0000, 0x080c, 0x6faa, 0x1130, 0x70ac, 0x9005,
+	0x1168, 0x080c, 0xbf8c, 0x0050, 0x080c, 0xbf8c, 0x70d8, 0xd09c,
+	0x1128, 0x70ac, 0x9005, 0x0110, 0x080c, 0x5c78, 0x70e3, 0x0000,
+	0x70df, 0x0000, 0x70a3, 0x0000, 0x080c, 0x29d7, 0x0228, 0x2011,
+	0x0101, 0x2204, 0xc0c4, 0x2012, 0x72d8, 0x080c, 0x6faa, 0x1178,
+	0x9016, 0x0016, 0x2009, 0x0002, 0x2019, 0x1945, 0x211a, 0x001e,
 	0x705b, 0xffff, 0x705f, 0x00ef, 0x707f, 0x0000, 0x0020, 0x2019,
-	0x193d, 0x201b, 0x0000, 0x2079, 0x1853, 0x7804, 0xd0ac, 0x0108,
-	0xc295, 0x72da, 0x080c, 0x6f9b, 0x0118, 0x9296, 0x0004, 0x0548,
-	0x2011, 0x0001, 0x080c, 0xbb3c, 0x70a7, 0x0000, 0x70ab, 0xffff,
+	0x1945, 0x201b, 0x0000, 0x2079, 0x185b, 0x7804, 0xd0ac, 0x0108,
+	0xc295, 0x72da, 0x080c, 0x6faa, 0x0118, 0x9296, 0x0004, 0x0548,
+	0x2011, 0x0001, 0x080c, 0xbb4b, 0x70a7, 0x0000, 0x70ab, 0xffff,
 	0x7003, 0x0002, 0x2079, 0x0100, 0x7827, 0x0003, 0x7828, 0x9085,
-	0x0003, 0x782a, 0x00fe, 0x080c, 0x2dbd, 0x2011, 0x0005, 0x080c,
-	0x9772, 0x080c, 0x896d, 0x080c, 0x6f9b, 0x0148, 0x00c6, 0x2061,
+	0x0003, 0x782a, 0x00fe, 0x080c, 0x2dc8, 0x2011, 0x0005, 0x080c,
+	0x975b, 0x080c, 0x898b, 0x080c, 0x6faa, 0x0148, 0x00c6, 0x2061,
 	0x0100, 0x0016, 0x2009, 0x0002, 0x61e2, 0x001e, 0x00ce, 0x012e,
 	0x0420, 0x70a7, 0x0000, 0x70ab, 0xffff, 0x7003, 0x0002, 0x00f6,
 	0x2079, 0x0100, 0x7827, 0x0003, 0x7828, 0x9085, 0x0003, 0x782a,
-	0x00fe, 0x2011, 0x0005, 0x080c, 0x9772, 0x080c, 0x896d, 0x080c,
-	0x6f9b, 0x0148, 0x00c6, 0x2061, 0x0100, 0x0016, 0x2009, 0x0002,
+	0x00fe, 0x2011, 0x0005, 0x080c, 0x975b, 0x080c, 0x898b, 0x080c,
+	0x6faa, 0x0148, 0x00c6, 0x2061, 0x0100, 0x0016, 0x2009, 0x0002,
 	0x61e2, 0x001e, 0x00ce, 0x00fe, 0x012e, 0x0005, 0x00c6, 0x00b6,
-	0x080c, 0x6f9b, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782,
-	0x080c, 0x6f9b, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e, 0x86ff,
+	0x080c, 0x6faa, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782,
+	0x080c, 0x6faa, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e, 0x86ff,
 	0x0138, 0x9180, 0x1000, 0x2004, 0x905d, 0x0110, 0xb800, 0xd0bc,
-	0x090c, 0x30d7, 0x8108, 0x1f04, 0x0abf, 0x707b, 0x0000, 0x707c,
+	0x090c, 0x30e2, 0x8108, 0x1f04, 0x0abf, 0x707b, 0x0000, 0x707c,
 	0x9084, 0x00ff, 0x707e, 0x70af, 0x0000, 0x00be, 0x00ce, 0x0005,
 	0x00b6, 0x0126, 0x2091, 0x8000, 0x7000, 0x9086, 0x0002, 0x1904,
-	0x0b8c, 0x70a8, 0x9086, 0xffff, 0x0130, 0x080c, 0x2dbd, 0x080c,
-	0x896d, 0x0804, 0x0b8c, 0x70d8, 0xd0ac, 0x1110, 0xd09c, 0x0540,
+	0x0b8c, 0x70a8, 0x9086, 0xffff, 0x0130, 0x080c, 0x2dc8, 0x080c,
+	0x898b, 0x0804, 0x0b8c, 0x70d8, 0xd0ac, 0x1110, 0xd09c, 0x0540,
 	0xd084, 0x0530, 0x0006, 0x2001, 0x0103, 0x2003, 0x002b, 0x000e,
-	0xd08c, 0x01f0, 0x70dc, 0x9086, 0xffff, 0x01b0, 0x080c, 0x2f48,
-	0x080c, 0x896d, 0x70d8, 0xd094, 0x1904, 0x0b8c, 0x2011, 0x0001,
-	0x080c, 0xc22c, 0x0110, 0x2011, 0x0003, 0x901e, 0x080c, 0x2f82,
-	0x080c, 0x896d, 0x0804, 0x0b8c, 0x70e0, 0x9005, 0x1904, 0x0b8c,
+	0xd08c, 0x01f0, 0x70dc, 0x9086, 0xffff, 0x01b0, 0x080c, 0x2f53,
+	0x080c, 0x898b, 0x70d8, 0xd094, 0x1904, 0x0b8c, 0x2011, 0x0001,
+	0x080c, 0xc23b, 0x0110, 0x2011, 0x0003, 0x901e, 0x080c, 0x2f8d,
+	0x080c, 0x898b, 0x0804, 0x0b8c, 0x70e0, 0x9005, 0x1904, 0x0b8c,
 	0x70a4, 0x9005, 0x1904, 0x0b8c, 0x70d8, 0xd0a4, 0x0118, 0xd0b4,
-	0x0904, 0x0b8c, 0x080c, 0x6529, 0x1904, 0x0b8c, 0x080c, 0x657c,
-	0x1904, 0x0b8c, 0x080c, 0x6563, 0x01c0, 0x0156, 0x00c6, 0x20a9,
-	0x007f, 0x900e, 0x0016, 0x080c, 0x6247, 0x1118, 0xb800, 0xd0ec,
+	0x0904, 0x0b8c, 0x080c, 0x6538, 0x1904, 0x0b8c, 0x080c, 0x658b,
+	0x1904, 0x0b8c, 0x080c, 0x6572, 0x01c0, 0x0156, 0x00c6, 0x20a9,
+	0x007f, 0x900e, 0x0016, 0x080c, 0x6256, 0x1118, 0xb800, 0xd0ec,
 	0x1138, 0x001e, 0x8108, 0x1f04, 0x0b32, 0x00ce, 0x015e, 0x0028,
 	0x001e, 0x00ce, 0x015e, 0x0804, 0x0b8c, 0x0006, 0x2001, 0x0103,
-	0x2003, 0x006b, 0x000e, 0x2011, 0x1983, 0x080c, 0x0f73, 0x2011,
-	0x199d, 0x080c, 0x0f73, 0x7030, 0xc08c, 0x7032, 0x7003, 0x0003,
-	0x70ab, 0xffff, 0x080c, 0x0e53, 0x9006, 0x080c, 0x260e, 0x0036,
-	0x0046, 0x2019, 0xffff, 0x2021, 0x0006, 0x080c, 0x4a86, 0x004e,
-	0x003e, 0x00f6, 0x2079, 0x0100, 0x080c, 0x6fbe, 0x0150, 0x080c,
-	0x6f9b, 0x7828, 0x0118, 0x9084, 0xe1ff, 0x0010, 0x9084, 0xffdf,
-	0x782a, 0x00fe, 0x2001, 0x19b8, 0x2004, 0x9086, 0x0005, 0x1120,
-	0x2011, 0x0000, 0x080c, 0x9772, 0x2011, 0x0000, 0x080c, 0x977c,
-	0x080c, 0x896d, 0x080c, 0x8a4a, 0x012e, 0x00be, 0x0005, 0x0016,
+	0x2003, 0x006b, 0x000e, 0x2011, 0x198b, 0x080c, 0x0f73, 0x2011,
+	0x19a5, 0x080c, 0x0f73, 0x7030, 0xc08c, 0x7032, 0x7003, 0x0003,
+	0x70ab, 0xffff, 0x080c, 0x0e53, 0x9006, 0x080c, 0x2619, 0x0036,
+	0x0046, 0x2019, 0xffff, 0x2021, 0x0006, 0x080c, 0x4a91, 0x004e,
+	0x003e, 0x00f6, 0x2079, 0x0100, 0x080c, 0x6fcd, 0x0150, 0x080c,
+	0x6faa, 0x7828, 0x0118, 0x9084, 0xe1ff, 0x0010, 0x9084, 0xffdf,
+	0x782a, 0x00fe, 0x2001, 0x19c0, 0x2004, 0x9086, 0x0005, 0x1120,
+	0x2011, 0x0000, 0x080c, 0x975b, 0x2011, 0x0000, 0x080c, 0x9765,
+	0x080c, 0x898b, 0x080c, 0x8a68, 0x012e, 0x00be, 0x0005, 0x0016,
 	0x0046, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2079, 0x0100, 0x7904,
-	0x918c, 0xfffd, 0x7906, 0x2009, 0x00f7, 0x080c, 0x5c56, 0x7940,
+	0x918c, 0xfffd, 0x7906, 0x2009, 0x00f7, 0x080c, 0x5c61, 0x7940,
 	0x918c, 0x0010, 0x7942, 0x7924, 0xd1b4, 0x0110, 0x7827, 0x0040,
 	0xd19c, 0x0110, 0x7827, 0x0008, 0x0006, 0x0036, 0x0156, 0x7954,
-	0xd1ac, 0x1904, 0x0c1c, 0x2001, 0x1977, 0x2004, 0x9005, 0x1518,
-	0x080c, 0x2a47, 0x1148, 0x2001, 0x0001, 0x080c, 0x29af, 0x2001,
-	0x0001, 0x080c, 0x2992, 0x00b8, 0x080c, 0x2a4f, 0x1138, 0x9006,
-	0x080c, 0x29af, 0x9006, 0x080c, 0x2992, 0x0068, 0x080c, 0x2a57,
-	0x1d50, 0x2001, 0x1968, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c,
-	0x27a9, 0x0804, 0x0cfc, 0x080c, 0x6fac, 0x0148, 0x080c, 0x6fbe,
-	0x1118, 0x080c, 0x728e, 0x0050, 0x080c, 0x6fa3, 0x0dd0, 0x080c,
-	0x7289, 0x080c, 0x727f, 0x080c, 0x6ecd, 0x0058, 0x080c, 0x6f9b,
-	0x0140, 0x2009, 0x00f8, 0x080c, 0x5c56, 0x7843, 0x0090, 0x7843,
-	0x0010, 0x20a9, 0x09c4, 0x7820, 0xd09c, 0x1138, 0x080c, 0x6f9b,
+	0xd1ac, 0x1904, 0x0c1c, 0x2001, 0x197f, 0x2004, 0x9005, 0x1518,
+	0x080c, 0x2a52, 0x1148, 0x2001, 0x0001, 0x080c, 0x29ba, 0x2001,
+	0x0001, 0x080c, 0x299d, 0x00b8, 0x080c, 0x2a5a, 0x1138, 0x9006,
+	0x080c, 0x29ba, 0x9006, 0x080c, 0x299d, 0x0068, 0x080c, 0x2a62,
+	0x1d50, 0x2001, 0x1970, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c,
+	0x27b4, 0x0804, 0x0cfc, 0x080c, 0x6fbb, 0x0148, 0x080c, 0x6fcd,
+	0x1118, 0x080c, 0x729b, 0x0050, 0x080c, 0x6fb2, 0x0dd0, 0x080c,
+	0x7296, 0x080c, 0x728c, 0x080c, 0x6edc, 0x0058, 0x080c, 0x6faa,
+	0x0140, 0x2009, 0x00f8, 0x080c, 0x5c61, 0x7843, 0x0090, 0x7843,
+	0x0010, 0x20a9, 0x09c4, 0x7820, 0xd09c, 0x1138, 0x080c, 0x6faa,
 	0x0138, 0x7824, 0xd0ac, 0x1904, 0x0d01, 0x1f04, 0x0bfb, 0x0070,
-	0x7824, 0x080c, 0x6fb5, 0x0118, 0xd0ac, 0x1904, 0x0d01, 0x9084,
+	0x7824, 0x080c, 0x6fc4, 0x0118, 0xd0ac, 0x1904, 0x0d01, 0x9084,
 	0x1800, 0x0d98, 0x7003, 0x0001, 0x0804, 0x0d01, 0x2001, 0x0001,
-	0x080c, 0x260e, 0x0804, 0x0d14, 0x2001, 0x1977, 0x2004, 0x9005,
-	0x1518, 0x080c, 0x2a47, 0x1148, 0x2001, 0x0001, 0x080c, 0x29af,
-	0x2001, 0x0001, 0x080c, 0x2992, 0x00b8, 0x080c, 0x2a4f, 0x1138,
-	0x9006, 0x080c, 0x29af, 0x9006, 0x080c, 0x2992, 0x0068, 0x080c,
-	0x2a57, 0x1d50, 0x2001, 0x1968, 0x2004, 0xd0fc, 0x0108, 0x0020,
-	0x080c, 0x27a9, 0x0804, 0x0cfc, 0x7850, 0x9085, 0x0040, 0x7852,
-	0x7938, 0x7850, 0x9084, 0xfbcf, 0x7852, 0x080c, 0x2a5f, 0x9085,
+	0x080c, 0x2619, 0x0804, 0x0d14, 0x2001, 0x197f, 0x2004, 0x9005,
+	0x1518, 0x080c, 0x2a52, 0x1148, 0x2001, 0x0001, 0x080c, 0x29ba,
+	0x2001, 0x0001, 0x080c, 0x299d, 0x00b8, 0x080c, 0x2a5a, 0x1138,
+	0x9006, 0x080c, 0x29ba, 0x9006, 0x080c, 0x299d, 0x0068, 0x080c,
+	0x2a62, 0x1d50, 0x2001, 0x1970, 0x2004, 0xd0fc, 0x0108, 0x0020,
+	0x080c, 0x27b4, 0x0804, 0x0cfc, 0x7850, 0x9085, 0x0040, 0x7852,
+	0x7938, 0x7850, 0x9084, 0xfbcf, 0x7852, 0x080c, 0x2a6a, 0x9085,
 	0x2000, 0x7852, 0x793a, 0x20a9, 0x0046, 0x1d04, 0x0c55, 0x080c,
-	0x80d5, 0x1f04, 0x0c55, 0x7850, 0x9085, 0x0400, 0x9084, 0xdfbf,
-	0x7852, 0x793a, 0x080c, 0x6fac, 0x0148, 0x080c, 0x6fbe, 0x1118,
-	0x080c, 0x728e, 0x0050, 0x080c, 0x6fa3, 0x0dd0, 0x080c, 0x7289,
-	0x080c, 0x727f, 0x080c, 0x6ecd, 0x0020, 0x2009, 0x00f8, 0x080c,
-	0x5c56, 0x20a9, 0x0028, 0xa001, 0x1f04, 0x0c7b, 0x7850, 0x9085,
-	0x1400, 0x7852, 0x080c, 0x6f9b, 0x0120, 0x7843, 0x0090, 0x7843,
-	0x0010, 0x2021, 0xe678, 0x2019, 0xea60, 0x0d0c, 0x80d5, 0x7820,
-	0xd09c, 0x1588, 0x080c, 0x6f9b, 0x0904, 0x0ce1, 0x7824, 0xd0ac,
-	0x1904, 0x0d01, 0x080c, 0x6fbe, 0x1530, 0x0046, 0x2021, 0x0320,
-	0x8421, 0x1df0, 0x004e, 0x7827, 0x1800, 0x080c, 0x2a5f, 0x7824,
+	0x80f3, 0x1f04, 0x0c55, 0x7850, 0x9085, 0x0400, 0x9084, 0xdfbf,
+	0x7852, 0x793a, 0x080c, 0x6fbb, 0x0148, 0x080c, 0x6fcd, 0x1118,
+	0x080c, 0x729b, 0x0050, 0x080c, 0x6fb2, 0x0dd0, 0x080c, 0x7296,
+	0x080c, 0x728c, 0x080c, 0x6edc, 0x0020, 0x2009, 0x00f8, 0x080c,
+	0x5c61, 0x20a9, 0x0028, 0xa001, 0x1f04, 0x0c7b, 0x7850, 0x9085,
+	0x1400, 0x7852, 0x080c, 0x6faa, 0x0120, 0x7843, 0x0090, 0x7843,
+	0x0010, 0x2021, 0xe678, 0x2019, 0xea60, 0x0d0c, 0x80f3, 0x7820,
+	0xd09c, 0x1588, 0x080c, 0x6faa, 0x0904, 0x0ce1, 0x7824, 0xd0ac,
+	0x1904, 0x0d01, 0x080c, 0x6fcd, 0x1530, 0x0046, 0x2021, 0x0320,
+	0x8421, 0x1df0, 0x004e, 0x7827, 0x1800, 0x080c, 0x2a6a, 0x7824,
 	0x9084, 0x1800, 0x1168, 0x9484, 0x0fff, 0x1140, 0x2001, 0x1810,
 	0x2004, 0x9084, 0x9000, 0x0110, 0x080c, 0x0d22, 0x8421, 0x1158,
-	0x1d04, 0x0cbc, 0x080c, 0x80d5, 0x080c, 0x7289, 0x080c, 0x727f,
+	0x1d04, 0x0cbc, 0x080c, 0x80f3, 0x080c, 0x7296, 0x080c, 0x728c,
 	0x7003, 0x0001, 0x04f0, 0x8319, 0x1940, 0x1d04, 0x0cc9, 0x080c,
-	0x80d5, 0x2009, 0x196b, 0x2104, 0x9005, 0x0118, 0x8001, 0x200a,
+	0x80f3, 0x2009, 0x1973, 0x2104, 0x9005, 0x0118, 0x8001, 0x200a,
 	0x1178, 0x200b, 0x000a, 0x7827, 0x0048, 0x20a9, 0x0002, 0x080c,
-	0x2a40, 0x7924, 0x080c, 0x2a5f, 0xd19c, 0x0110, 0x080c, 0x2980,
-	0x00d8, 0x080c, 0x6fac, 0x1140, 0x94a2, 0x03e8, 0x1128, 0x080c,
-	0x6f73, 0x7003, 0x0001, 0x00a8, 0x7827, 0x1800, 0x080c, 0x2a5f,
-	0x7824, 0x080c, 0x6fb5, 0x0110, 0xd0ac, 0x1158, 0x9084, 0x1800,
-	0x0950, 0x7003, 0x0001, 0x0028, 0x2001, 0x0001, 0x080c, 0x260e,
+	0x2a4b, 0x7924, 0x080c, 0x2a6a, 0xd19c, 0x0110, 0x080c, 0x298b,
+	0x00d8, 0x080c, 0x6fbb, 0x1140, 0x94a2, 0x03e8, 0x1128, 0x080c,
+	0x6f82, 0x7003, 0x0001, 0x00a8, 0x7827, 0x1800, 0x080c, 0x2a6a,
+	0x7824, 0x080c, 0x6fc4, 0x0110, 0xd0ac, 0x1158, 0x9084, 0x1800,
+	0x0950, 0x7003, 0x0001, 0x0028, 0x2001, 0x0001, 0x080c, 0x2619,
 	0x0078, 0x2009, 0x180c, 0x210c, 0xd19c, 0x1120, 0x7904, 0x918d,
 	0x0002, 0x7906, 0x7827, 0x0048, 0x7828, 0x9085, 0x0028, 0x782a,
-	0x7850, 0x9085, 0x0400, 0x7852, 0x2001, 0x1977, 0x2003, 0x0000,
+	0x7850, 0x9085, 0x0400, 0x7852, 0x2001, 0x197f, 0x2003, 0x0000,
 	0x9006, 0x78f2, 0x015e, 0x003e, 0x000e, 0x012e, 0x00fe, 0x004e,
 	0x001e, 0x0005, 0x0006, 0x0016, 0x0036, 0x0046, 0x00b6, 0x00c6,
-	0x00d6, 0x00e6, 0x00f6, 0x0156, 0x0069, 0x0d0c, 0x80d5, 0x015e,
+	0x00d6, 0x00e6, 0x00f6, 0x0156, 0x0069, 0x0d0c, 0x80f3, 0x015e,
 	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x004e, 0x003e, 0x001e,
-	0x000e, 0x0005, 0x00e6, 0x2071, 0x1894, 0x7004, 0x9086, 0x0001,
-	0x1110, 0x080c, 0x3261, 0x00ee, 0x0005, 0x0005, 0x2a70, 0x2061,
-	0x197b, 0x2063, 0x0003, 0x6007, 0x0002, 0x600b, 0x001e, 0x600f,
-	0x0317, 0x2001, 0x194c, 0x900e, 0x2102, 0x7192, 0x2001, 0x0100,
+	0x000e, 0x0005, 0x00e6, 0x2071, 0x189c, 0x7004, 0x9086, 0x0001,
+	0x1110, 0x080c, 0x326c, 0x00ee, 0x0005, 0x0005, 0x2a70, 0x2061,
+	0x1983, 0x2063, 0x0003, 0x6007, 0x0003, 0x600b, 0x0002, 0x600f,
+	0x0317, 0x2001, 0x1954, 0x900e, 0x2102, 0x7192, 0x2001, 0x0100,
 	0x2004, 0x9082, 0x0002, 0x0218, 0x705b, 0xffff, 0x0008, 0x715a,
-	0x7063, 0xffff, 0x717a, 0x717e, 0x080c, 0xbf7d, 0x70e7, 0x00c0,
-	0x2061, 0x193c, 0x6003, 0x0909, 0x6106, 0x600b, 0x8800, 0x600f,
+	0x7063, 0xffff, 0x717a, 0x717e, 0x080c, 0xbf8c, 0x70e7, 0x00c0,
+	0x2061, 0x1944, 0x6003, 0x0909, 0x6106, 0x600b, 0x8800, 0x600f,
 	0x0200, 0x6013, 0x00ff, 0x6017, 0x000f, 0x611a, 0x601f, 0x07d0,
-	0x2061, 0x1944, 0x6003, 0x8000, 0x6106, 0x610a, 0x600f, 0x0200,
-	0x6013, 0x00ff, 0x6116, 0x601b, 0x0001, 0x611e, 0x2061, 0x1959,
+	0x2061, 0x194c, 0x6003, 0x8000, 0x6106, 0x610a, 0x600f, 0x0200,
+	0x6013, 0x00ff, 0x6116, 0x601b, 0x0001, 0x611e, 0x2061, 0x1961,
 	0x6003, 0x514c, 0x6007, 0x4f47, 0x600b, 0x4943, 0x600f, 0x2020,
-	0x2001, 0x182b, 0x2102, 0x0005, 0x9016, 0x080c, 0x6247, 0x1178,
+	0x2001, 0x182b, 0x2102, 0x0005, 0x9016, 0x080c, 0x6256, 0x1178,
 	0xb804, 0x90c4, 0x00ff, 0x98c6, 0x0006, 0x0128, 0x90c4, 0xff00,
 	0x98c6, 0x0600, 0x1120, 0x9186, 0x0080, 0x0108, 0x8210, 0x8108,
 	0x9186, 0x0800, 0x1d50, 0x2208, 0x0005, 0x2091, 0x8000, 0x2079,
@@ -236,18 +236,18 @@
 	0x0006, 0x0016, 0x2001, 0x8002, 0x0006, 0x2079, 0x0000, 0x000e,
 	0x7882, 0x7836, 0x001e, 0x798e, 0x000e, 0x788a, 0x000e, 0x7886,
 	0x3900, 0x789a, 0x7833, 0x0012, 0x2091, 0x5000, 0x0156, 0x00d6,
-	0x0036, 0x0026, 0x2079, 0x0300, 0x2069, 0x1a71, 0x7a08, 0x226a,
-	0x2069, 0x1a72, 0x7a18, 0x226a, 0x8d68, 0x7a1c, 0x226a, 0x782c,
-	0x2019, 0x1a7f, 0x201a, 0x2019, 0x1a82, 0x9016, 0x7808, 0xd09c,
-	0x0168, 0x7820, 0x201a, 0x8210, 0x8318, 0x9386, 0x1a97, 0x0108,
-	0x0ca8, 0x7808, 0xd09c, 0x0110, 0x2011, 0xdead, 0x2019, 0x1a80,
-	0x782c, 0x201a, 0x8318, 0x221a, 0x7803, 0x0000, 0x2069, 0x1a51,
+	0x0036, 0x0026, 0x2079, 0x0300, 0x2069, 0x1a79, 0x7a08, 0x226a,
+	0x2069, 0x1a7a, 0x7a18, 0x226a, 0x8d68, 0x7a1c, 0x226a, 0x782c,
+	0x2019, 0x1a87, 0x201a, 0x2019, 0x1a8a, 0x9016, 0x7808, 0xd09c,
+	0x0168, 0x7820, 0x201a, 0x8210, 0x8318, 0x9386, 0x1a9f, 0x0108,
+	0x0ca8, 0x7808, 0xd09c, 0x0110, 0x2011, 0xdead, 0x2019, 0x1a88,
+	0x782c, 0x201a, 0x8318, 0x221a, 0x7803, 0x0000, 0x2069, 0x1a59,
 	0x901e, 0x20a9, 0x0020, 0x7b26, 0x7a28, 0x226a, 0x8d68, 0x8318,
 	0x1f04, 0x0e03, 0x002e, 0x003e, 0x00de, 0x015e, 0x2079, 0x1800,
 	0x7803, 0x0005, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x0180, 0x2001, 0x19e9, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b,
+	0x0180, 0x2001, 0x19f1, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b,
 	0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002, 0x2003,
-	0x1001, 0x080c, 0x539e, 0x1108, 0x0099, 0x0cd8, 0x0005, 0x918c,
+	0x1001, 0x080c, 0x53a9, 0x1108, 0x0099, 0x0cd8, 0x0005, 0x918c,
 	0x03ff, 0x2001, 0x0003, 0x2004, 0x9084, 0x0600, 0x1118, 0x918d,
 	0x2800, 0x0010, 0x918d, 0x2000, 0x2001, 0x017f, 0x2102, 0x0005,
 	0x0026, 0x0126, 0x2011, 0x0080, 0x080c, 0x0ecb, 0x20a9, 0x0900,
@@ -258,9 +258,9 @@
 	0x70eb, 0x0000, 0x1128, 0x70eb, 0x0fa0, 0x080c, 0x0edd, 0x002e,
 	0x0005, 0x0026, 0x080c, 0x0ed8, 0x0128, 0xd0a4, 0x1138, 0x2011,
 	0xcdd5, 0x0010, 0x2011, 0x0080, 0x080c, 0x0edd, 0x002e, 0x0005,
-	0x0026, 0x70eb, 0x0000, 0x080c, 0x0ed8, 0x1148, 0x080c, 0x2a57,
+	0x0026, 0x70eb, 0x0000, 0x080c, 0x0ed8, 0x1148, 0x080c, 0x2a62,
 	0x1118, 0x2011, 0x8484, 0x0058, 0x2011, 0x8282, 0x0040, 0x080c,
-	0x2a57, 0x1118, 0x2011, 0xcdc5, 0x0010, 0x2011, 0xcac2, 0x080c,
+	0x2a62, 0x1118, 0x2011, 0xcdc5, 0x0010, 0x2011, 0xcac2, 0x080c,
 	0x0edd, 0x002e, 0x0005, 0x00e6, 0x0006, 0x2071, 0x1800, 0xd0b4,
 	0x70e4, 0x1110, 0xc0e4, 0x0048, 0x0006, 0x3b00, 0x9084, 0xff3f,
 	0x20d8, 0x000e, 0x70eb, 0x0000, 0xc0e5, 0x0079, 0x000e, 0x00ee,
@@ -275,11 +275,11 @@
 	0x1f04, 0x0eec, 0x0005, 0x890e, 0x810e, 0x810f, 0x9194, 0x003f,
 	0x918c, 0xffc0, 0x0005, 0x0006, 0x2200, 0x914d, 0x894f, 0x894d,
 	0x894d, 0x000e, 0x0005, 0x01d6, 0x0146, 0x0036, 0x0096, 0x2061,
-	0x1883, 0x600b, 0x0000, 0x600f, 0x0000, 0x6003, 0x0000, 0x6007,
+	0x188b, 0x600b, 0x0000, 0x600f, 0x0000, 0x6003, 0x0000, 0x6007,
 	0x0000, 0x2009, 0xffc0, 0x2105, 0x0006, 0x2001, 0xaaaa, 0x200f,
 	0x2019, 0x5555, 0x9016, 0x2049, 0x0bff, 0xab02, 0xa001, 0xa001,
 	0xa800, 0x9306, 0x1138, 0x2105, 0x9306, 0x0120, 0x8210, 0x99c8,
-	0x0400, 0x0c98, 0x000e, 0x200f, 0x2001, 0x1893, 0x928a, 0x000e,
+	0x0400, 0x0c98, 0x000e, 0x200f, 0x2001, 0x189b, 0x928a, 0x000e,
 	0x1638, 0x928a, 0x0006, 0x2011, 0x0006, 0x1210, 0x2011, 0x0000,
 	0x2202, 0x9006, 0x2008, 0x82ff, 0x01b0, 0x8200, 0x600a, 0x600f,
 	0xffff, 0x6003, 0x0002, 0x6007, 0x0000, 0x0026, 0x2019, 0x0010,
@@ -301,7 +301,7 @@
 	0x0158, 0x8210, 0x9906, 0x090c, 0x0db4, 0x2300, 0x9202, 0x0120,
 	0x1a0c, 0x0db4, 0xa000, 0x0c98, 0x012e, 0x003e, 0x002e, 0x000e,
 	0x00ee, 0x008e, 0x0005, 0x0086, 0x00e6, 0x0006, 0x0126, 0x2091,
-	0x8000, 0x2071, 0x1906, 0x7010, 0x9005, 0x0140, 0x7018, 0x9045,
+	0x8000, 0x2071, 0x190e, 0x7010, 0x9005, 0x0140, 0x7018, 0x9045,
 	0x0128, 0x9906, 0x090c, 0x0db4, 0xa000, 0x0cc8, 0x012e, 0x000e,
 	0x00ee, 0x008e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x0126, 0x2091,
 	0x8000, 0x70bc, 0x8001, 0x0270, 0x70be, 0x702c, 0x2048, 0x9085,
@@ -313,36 +313,36 @@
 	0x8000, 0x0016, 0x890e, 0x810e, 0x810f, 0x9184, 0x003f, 0xa862,
 	0x9184, 0xffc0, 0xa85e, 0x001e, 0x0020, 0x00e6, 0x0126, 0x2091,
 	0x8000, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc,
-	0x8000, 0x70be, 0x080c, 0x7f46, 0x012e, 0x00ee, 0x0005, 0x2071,
+	0x8000, 0x70be, 0x080c, 0x7f64, 0x012e, 0x00ee, 0x0005, 0x2071,
 	0x1800, 0x9026, 0x2009, 0x0000, 0x2049, 0x0400, 0x2900, 0x702e,
 	0x8940, 0x2800, 0xa802, 0xa95e, 0xa863, 0x0001, 0x8420, 0x9886,
-	0x0440, 0x0120, 0x2848, 0x9188, 0x0040, 0x0c90, 0x2071, 0x1883,
+	0x0440, 0x0120, 0x2848, 0x9188, 0x0040, 0x0c90, 0x2071, 0x188b,
 	0x7000, 0x9005, 0x11a0, 0x2001, 0x0492, 0xa802, 0x2048, 0x2009,
 	0x2480, 0x8940, 0x2800, 0xa802, 0xa95e, 0xa863, 0x0001, 0x8420,
 	0x9886, 0x0800, 0x0120, 0x2848, 0x9188, 0x0040, 0x0c90, 0x2071,
-	0x1883, 0x7104, 0x7200, 0x82ff, 0x01d0, 0x7308, 0x8318, 0x831f,
+	0x188b, 0x7104, 0x7200, 0x82ff, 0x01d0, 0x7308, 0x8318, 0x831f,
 	0x831b, 0x831b, 0x7312, 0x8319, 0x2001, 0x0800, 0xa802, 0x2048,
 	0x8900, 0xa802, 0x2040, 0xa95e, 0xaa62, 0x8420, 0x2300, 0x9906,
 	0x0130, 0x2848, 0x9188, 0x0040, 0x9291, 0x0000, 0x0c88, 0xa803,
 	0x0000, 0x2071, 0x1800, 0x74ba, 0x74be, 0x0005, 0x00e6, 0x0016,
 	0x9984, 0xfc00, 0x01e8, 0x908c, 0xf800, 0x1168, 0x9982, 0x0400,
 	0x02b8, 0x9982, 0x0440, 0x0278, 0x9982, 0x0492, 0x0288, 0x9982,
-	0x0800, 0x1270, 0x0040, 0x9982, 0x0800, 0x0250, 0x2071, 0x1883,
+	0x0800, 0x1270, 0x0040, 0x9982, 0x0800, 0x0250, 0x2071, 0x188b,
 	0x7010, 0x9902, 0x1228, 0x9085, 0x0001, 0x001e, 0x00ee, 0x0005,
-	0x9006, 0x0cd8, 0x00e6, 0x2071, 0x19e8, 0x7007, 0x0000, 0x9006,
+	0x9006, 0x0cd8, 0x00e6, 0x2071, 0x19f0, 0x7007, 0x0000, 0x9006,
 	0x701e, 0x7022, 0x7002, 0x2071, 0x0000, 0x7010, 0x9085, 0x8044,
 	0x7012, 0x2071, 0x0080, 0x9006, 0x20a9, 0x0040, 0x7022, 0x1f04,
 	0x10ce, 0x702b, 0x0020, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000,
-	0x00e6, 0xa06f, 0x0000, 0x2071, 0x19e8, 0x701c, 0x9088, 0x19f2,
+	0x00e6, 0xa06f, 0x0000, 0x2071, 0x19f0, 0x701c, 0x9088, 0x19fa,
 	0x280a, 0x8000, 0x9084, 0x003f, 0x701e, 0x7120, 0x9106, 0x090c,
 	0x0db4, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080, 0x00a9,
 	0x00fe, 0x00ee, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x00e6,
-	0x2071, 0x19e8, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080,
+	0x2071, 0x19f0, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080,
 	0x0021, 0x00fe, 0x00ee, 0x012e, 0x0005, 0x7004, 0x9086, 0x0000,
 	0x1110, 0x7007, 0x0006, 0x7000, 0x0002, 0x1117, 0x1115, 0x1115,
 	0x1115, 0x128e, 0x128e, 0x128e, 0x128e, 0x080c, 0x0db4, 0x701c,
 	0x7120, 0x9106, 0x1148, 0x792c, 0x9184, 0x0001, 0x1120, 0xd1fc,
-	0x1110, 0x7007, 0x0000, 0x0005, 0x0096, 0x9180, 0x19f2, 0x2004,
+	0x1110, 0x7007, 0x0000, 0x0005, 0x0096, 0x9180, 0x19fa, 0x2004,
 	0x700a, 0x2048, 0x8108, 0x918c, 0x003f, 0x7122, 0x782b, 0x0026,
 	0xa88c, 0x7802, 0xa890, 0x7806, 0xa894, 0x780a, 0xa898, 0x780e,
 	0xa878, 0x700e, 0xa870, 0x7016, 0xa874, 0x701a, 0xa868, 0x009e,
@@ -355,8 +355,8 @@
 	0x0040, 0x9182, 0x0040, 0x1210, 0x2110, 0x9006, 0x700e, 0x22a8,
 	0x4006, 0x8203, 0x7812, 0x782b, 0x0020, 0x3300, 0x701a, 0x782b,
 	0x0001, 0x015e, 0x014e, 0x013e, 0x002e, 0x001e, 0x0005, 0x2009,
-	0x19e8, 0x2104, 0xc095, 0x200a, 0x080c, 0x10f4, 0x0005, 0x0016,
-	0x00e6, 0x2071, 0x19e8, 0x00f6, 0x2079, 0x0080, 0x792c, 0xd1bc,
+	0x19f0, 0x2104, 0xc095, 0x200a, 0x080c, 0x10f4, 0x0005, 0x0016,
+	0x00e6, 0x2071, 0x19f0, 0x00f6, 0x2079, 0x0080, 0x792c, 0xd1bc,
 	0x190c, 0x0dad, 0x782b, 0x0002, 0xd1fc, 0x0120, 0x918c, 0x0700,
 	0x7004, 0x0023, 0x00fe, 0x00ee, 0x001e, 0x0005, 0x1105, 0x11ad,
 	0x11e1, 0x0db4, 0x0db4, 0x129a, 0x0db4, 0x918c, 0x0700, 0x1550,
@@ -371,39 +371,39 @@
 	0x2048, 0xa86f, 0x0200, 0x009e, 0x7007, 0x0000, 0x0080, 0x0096,
 	0x7008, 0x2048, 0x7800, 0xa88e, 0x7804, 0xa892, 0x7808, 0xa896,
 	0x780c, 0xa89a, 0xa86f, 0x0100, 0x009e, 0x7007, 0x0000, 0x0096,
-	0x00d6, 0x7008, 0x2048, 0x2001, 0x18af, 0x2004, 0x9906, 0x1128,
+	0x00d6, 0x7008, 0x2048, 0x2001, 0x18b7, 0x2004, 0x9906, 0x1128,
 	0xa89c, 0x080f, 0x00de, 0x009e, 0x00a0, 0x00de, 0x009e, 0x0096,
 	0x00d6, 0x7008, 0x2048, 0x0081, 0x0150, 0xa89c, 0x0086, 0x2940,
 	0x080f, 0x008e, 0x00de, 0x009e, 0x080c, 0x10f4, 0x0005, 0x00de,
 	0x009e, 0x080c, 0x10f4, 0x0005, 0xa8a8, 0xd08c, 0x0005, 0x0096,
 	0xa0a0, 0x904d, 0x090c, 0x0db4, 0xa06c, 0x908e, 0x0100, 0x0130,
-	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002, 0x080c, 0x6884,
+	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002, 0x080c, 0x6893,
 	0xa09f, 0x0000, 0xa0a3, 0x0000, 0x2848, 0x080c, 0x101d, 0x009e,
 	0x0005, 0x00a6, 0xa0a0, 0x904d, 0x090c, 0x0db4, 0xa06c, 0x908e,
 	0x0100, 0x0128, 0xa87b, 0x0001, 0xa883, 0x0000, 0x00c0, 0xa80c,
 	0x2050, 0xb004, 0x9005, 0x0198, 0xa80e, 0x2050, 0x8006, 0x8006,
 	0x8007, 0x908c, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0xa076,
 	0xa172, 0xb000, 0xa07a, 0x2810, 0x080c, 0x10d5, 0x00e8, 0xa97c,
-	0xa894, 0x0016, 0x0006, 0x080c, 0x6884, 0x000e, 0x001e, 0xd1fc,
-	0x1138, 0xd1f4, 0x0128, 0x00c6, 0x2060, 0x080c, 0x9e42, 0x00ce,
+	0xa894, 0x0016, 0x0006, 0x080c, 0x6893, 0x000e, 0x001e, 0xd1fc,
+	0x1138, 0xd1f4, 0x0128, 0x00c6, 0x2060, 0x080c, 0x9e2f, 0x00ce,
 	0x7008, 0x2048, 0xa89f, 0x0000, 0xa8a3, 0x0000, 0x080c, 0x101d,
 	0x7007, 0x0000, 0x080c, 0x10f4, 0x00ae, 0x0005, 0x0126, 0x2091,
 	0x8000, 0x782b, 0x1001, 0x7007, 0x0005, 0x7000, 0xc094, 0x7002,
 	0x012e, 0x0005, 0x7007, 0x0000, 0x080c, 0x1105, 0x0005, 0x0126,
-	0x2091, 0x2200, 0x2079, 0x0300, 0x2071, 0x1a32, 0x7003, 0x0000,
+	0x2091, 0x2200, 0x2079, 0x0300, 0x2071, 0x1a3a, 0x7003, 0x0000,
 	0x78bf, 0x00f6, 0x781b, 0x4800, 0x00c1, 0x7803, 0x0003, 0x780f,
-	0x0000, 0x20a9, 0x0254, 0x2061, 0xd904, 0x2c0d, 0x7912, 0xe104,
+	0x0000, 0x20a9, 0x0254, 0x2061, 0xd91d, 0x2c0d, 0x7912, 0xe104,
 	0x9ce0, 0x0002, 0x7916, 0x1f04, 0x12b5, 0x7807, 0x0007, 0x7803,
 	0x0000, 0x7803, 0x0001, 0x012e, 0x0005, 0x00c6, 0x7803, 0x0000,
-	0x7808, 0xd09c, 0x0110, 0x7820, 0x0cd8, 0x2001, 0x1a33, 0x2003,
+	0x7808, 0xd09c, 0x0110, 0x7820, 0x0cd8, 0x2001, 0x1a3b, 0x2003,
 	0x0000, 0x78ab, 0x0004, 0x78ac, 0xd0ac, 0x1de8, 0x78ab, 0x0002,
 	0x7807, 0x0007, 0x7827, 0x0030, 0x782b, 0x0400, 0x7827, 0x0031,
-	0x782b, 0x1a51, 0x781f, 0xff00, 0x781b, 0xb700, 0x2001, 0x0200,
-	0x2004, 0xd0dc, 0x0110, 0x781f, 0x0303, 0x2061, 0x1a51, 0x602f,
+	0x782b, 0x1a59, 0x781f, 0xff00, 0x781b, 0xb700, 0x2001, 0x0200,
+	0x2004, 0xd0dc, 0x0110, 0x781f, 0x0303, 0x2061, 0x1a59, 0x602f,
 	0x1cd0, 0x2001, 0x1819, 0x2004, 0x9082, 0x1cd0, 0x6032, 0x603b,
-	0x1f28, 0x2001, 0x313a, 0xd0fc, 0x190c, 0x0db4, 0x2001, 0x0003,
-	0x2004, 0xd0d4, 0x1118, 0x783f, 0x313a, 0x0020, 0x9084, 0xc000,
-	0x783f, 0xb13a, 0x00ce, 0x0005, 0x0126, 0x2091, 0x2200, 0x7908,
+	0x1f33, 0x2001, 0x3145, 0xd0fc, 0x190c, 0x0db4, 0x2001, 0x0003,
+	0x2004, 0xd0d4, 0x1118, 0x783f, 0x3145, 0x0020, 0x9084, 0xc000,
+	0x783f, 0xb145, 0x00ce, 0x0005, 0x0126, 0x2091, 0x2200, 0x7908,
 	0x9184, 0x0070, 0x190c, 0x0dad, 0xd19c, 0x0158, 0x7820, 0x908c,
 	0xf000, 0x15e8, 0x908a, 0x0024, 0x1a0c, 0x0db4, 0x0023, 0x012e,
 	0x0005, 0x012e, 0x0005, 0x1347, 0x1347, 0x135e, 0x1363, 0x1367,
@@ -411,18 +411,18 @@
 	0x149d, 0x1347, 0x1347, 0x1347, 0x1347, 0x1347, 0x1347, 0x1347,
 	0x1347, 0x1347, 0x1347, 0x1347, 0x1347, 0x1347, 0x136e, 0x1347,
 	0x1347, 0x1347, 0x1347, 0x1347, 0x1347, 0x134b, 0x1349, 0x080c,
-	0x0db4, 0x080c, 0x0dad, 0x080c, 0x14a4, 0x2009, 0x1a4a, 0x2104,
-	0x8000, 0x200a, 0x080c, 0x79f0, 0x080c, 0x195a, 0x0005, 0x2009,
-	0x0048, 0x2060, 0x080c, 0x9ebc, 0x012e, 0x0005, 0x7004, 0xc085,
+	0x0db4, 0x080c, 0x0dad, 0x080c, 0x14a4, 0x2009, 0x1a52, 0x2104,
+	0x8000, 0x200a, 0x080c, 0x79fe, 0x080c, 0x196a, 0x0005, 0x2009,
+	0x0048, 0x2060, 0x080c, 0x9ea9, 0x012e, 0x0005, 0x7004, 0xc085,
 	0xc0b5, 0x7006, 0x0005, 0x7004, 0xc085, 0x7006, 0x0005, 0x080c,
 	0x14a4, 0x080c, 0x15e0, 0x0005, 0x080c, 0x0db4, 0x080c, 0x14a4,
 	0x2060, 0x6014, 0x0096, 0x2048, 0xa83b, 0xffff, 0x009e, 0x2009,
-	0x0048, 0x080c, 0x9ebc, 0x2001, 0x015d, 0x2003, 0x0000, 0x2009,
+	0x0048, 0x080c, 0x9ea9, 0x2001, 0x015d, 0x2003, 0x0000, 0x2009,
 	0x03e8, 0x8109, 0x0160, 0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8,
 	0x2001, 0x0218, 0x2004, 0xd0ec, 0x1110, 0x080c, 0x14a9, 0x2001,
 	0x0307, 0x2003, 0x8000, 0x0005, 0x7004, 0xc095, 0x7006, 0x0005,
 	0x080c, 0x14a4, 0x2060, 0x6014, 0x0096, 0x2048, 0xa83b, 0xffff,
-	0x009e, 0x2009, 0x0048, 0x080c, 0x9ebc, 0x0005, 0x080c, 0x14a4,
+	0x009e, 0x2009, 0x0048, 0x080c, 0x9ea9, 0x0005, 0x080c, 0x14a4,
 	0x080c, 0x0db4, 0x080c, 0x14a4, 0x080c, 0x1421, 0x7827, 0x0018,
 	0x79ac, 0xd1dc, 0x0540, 0x7827, 0x0015, 0x7828, 0x782b, 0x0000,
 	0x9065, 0x0138, 0x2001, 0x020d, 0x2003, 0x0050, 0x2003, 0x0020,
@@ -431,13 +431,13 @@
 	0x0050, 0x2003, 0x0020, 0x0490, 0x78ab, 0x0004, 0x7803, 0x0001,
 	0x080c, 0x143a, 0x0005, 0x7828, 0x782b, 0x0000, 0x9065, 0x090c,
 	0x0db4, 0x6014, 0x2048, 0x78ab, 0x0004, 0x918c, 0x0700, 0x01a8,
-	0x080c, 0x79f0, 0x080c, 0x195a, 0x080c, 0xbb2c, 0x0158, 0xa9ac,
+	0x080c, 0x79fe, 0x080c, 0x196a, 0x080c, 0xbb3b, 0x0158, 0xa9ac,
 	0xa936, 0xa9b0, 0xa93a, 0xa83f, 0xffff, 0xa843, 0xffff, 0xa880,
-	0xc0bd, 0xa882, 0x080c, 0xb75d, 0x0005, 0x6010, 0x00b6, 0x2058,
-	0xb800, 0x00be, 0xd0bc, 0x6024, 0x190c, 0xbf16, 0x2029, 0x00c8,
+	0xc0bd, 0xa882, 0x080c, 0xb75c, 0x0005, 0x6010, 0x00b6, 0x2058,
+	0xb800, 0x00be, 0xd0bc, 0x6024, 0x190c, 0xbf25, 0x2029, 0x00c8,
 	0x8529, 0x0128, 0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8, 0x7dbc,
-	0x080c, 0xd8ad, 0xd5a4, 0x1118, 0x080c, 0x14a9, 0x0005, 0x080c,
-	0x79f0, 0x080c, 0x195a, 0x0005, 0x781f, 0x0300, 0x7803, 0x0001,
+	0x080c, 0xd8c6, 0xd5a4, 0x1118, 0x080c, 0x14a9, 0x0005, 0x080c,
+	0x79fe, 0x080c, 0x196a, 0x0005, 0x781f, 0x0300, 0x7803, 0x0001,
 	0x0005, 0x0016, 0x0066, 0x0076, 0x00f6, 0x2079, 0x0300, 0x7908,
 	0x918c, 0x0007, 0x9186, 0x0003, 0x0120, 0x2001, 0x0016, 0x080c,
 	0x151a, 0x00fe, 0x007e, 0x006e, 0x001e, 0x0005, 0x7004, 0xc09d,
@@ -454,7 +454,7 @@
 	0x0401, 0x0040, 0x2001, 0x020d, 0x2003, 0x0020, 0x080c, 0x12c5,
 	0x7803, 0x0001, 0x00ee, 0x001e, 0x0005, 0x2001, 0x020d, 0x2003,
 	0x0050, 0x2003, 0x0020, 0x0069, 0x0ca8, 0x0031, 0x2060, 0x2009,
-	0x0053, 0x080c, 0x9ebc, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820,
+	0x0053, 0x080c, 0x9ea9, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820,
 	0x0005, 0x080c, 0x1421, 0x00d6, 0x2069, 0x0200, 0x2009, 0x01f4,
 	0x8109, 0x0510, 0x6804, 0x9005, 0x0dd8, 0x2001, 0x015d, 0x2003,
 	0x0000, 0x79bc, 0xd1a4, 0x1528, 0x79b8, 0x918c, 0x0fff, 0x0180,
@@ -462,7 +462,7 @@
 	0x810c, 0x810c, 0x080c, 0x150c, 0x6827, 0x0001, 0x8109, 0x1dd0,
 	0x04d9, 0x6827, 0x0002, 0x04c1, 0x6804, 0x9005, 0x1130, 0x682c,
 	0xd0e4, 0x1500, 0x6804, 0x9005, 0x0de8, 0x79b8, 0xd1ec, 0x1130,
-	0x08c0, 0x080c, 0x79f0, 0x080c, 0x195a, 0x0090, 0x7827, 0x0015,
+	0x08c0, 0x080c, 0x79fe, 0x080c, 0x196a, 0x0090, 0x7827, 0x0015,
 	0x782b, 0x0000, 0x7827, 0x0018, 0x782b, 0x0000, 0x2001, 0x020d,
 	0x2003, 0x0020, 0x2001, 0x0307, 0x2003, 0x0300, 0x7803, 0x0001,
 	0x00de, 0x0005, 0x682c, 0x9084, 0x5400, 0x9086, 0x5400, 0x0d30,
@@ -478,18 +478,18 @@
 	0x0030, 0x0904, 0x1593, 0x9284, 0x0048, 0x9086, 0x0008, 0x1904,
 	0x1593, 0x2001, 0x0109, 0x2004, 0xd08c, 0x01f0, 0x0006, 0x01c6,
 	0x01d6, 0x0136, 0x0146, 0x0156, 0x0126, 0x2091, 0x2800, 0x00f6,
-	0x0026, 0x0016, 0x2009, 0x1a4c, 0x2104, 0x8000, 0x0208, 0x200a,
-	0x080c, 0x8393, 0x001e, 0x002e, 0x00fe, 0x012e, 0x015e, 0x014e,
+	0x0026, 0x0016, 0x2009, 0x1a54, 0x2104, 0x8000, 0x0208, 0x200a,
+	0x080c, 0x83b1, 0x001e, 0x002e, 0x00fe, 0x012e, 0x015e, 0x014e,
 	0x013e, 0x01de, 0x01ce, 0x000e, 0x2001, 0x009b, 0x2004, 0xd0fc,
 	0x01d0, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x00f6, 0x0016, 0x2009, 0x1a4d, 0x2104, 0x8000, 0x0208, 0x200a,
-	0x080c, 0x1d4c, 0x001e, 0x00fe, 0x015e, 0x014e, 0x013e, 0x01de,
+	0x00f6, 0x0016, 0x2009, 0x1a55, 0x2104, 0x8000, 0x0208, 0x200a,
+	0x080c, 0x1d57, 0x001e, 0x00fe, 0x015e, 0x014e, 0x013e, 0x01de,
 	0x01ce, 0x012e, 0x000e, 0x7818, 0xd0bc, 0x1904, 0x1543, 0x0005,
 	0x2001, 0x180c, 0x2004, 0xd0f4, 0x1528, 0x7a18, 0x9284, 0x0030,
-	0x0508, 0x9284, 0x0048, 0x9086, 0x0008, 0x11e0, 0x2001, 0x19c6,
-	0x2004, 0x9005, 0x01b8, 0x2001, 0x1a35, 0x2004, 0x9086, 0x0000,
-	0x0188, 0x2009, 0x1a4b, 0x2104, 0x8000, 0x0208, 0x200a, 0x080c,
-	0x9431, 0x2009, 0x180c, 0x2104, 0xc0f5, 0x200a, 0x2009, 0xff00,
+	0x0508, 0x9284, 0x0048, 0x9086, 0x0008, 0x11e0, 0x2001, 0x19ce,
+	0x2004, 0x9005, 0x01b8, 0x2001, 0x1a3d, 0x2004, 0x9086, 0x0000,
+	0x0188, 0x2009, 0x1a53, 0x2104, 0x8000, 0x0208, 0x200a, 0x080c,
+	0x9445, 0x2009, 0x180c, 0x2104, 0xc0f5, 0x200a, 0x2009, 0xff00,
 	0x0804, 0x1543, 0x9085, 0x0001, 0x0005, 0x7832, 0x7936, 0x7a3a,
 	0x781b, 0x8080, 0x080c, 0x153c, 0x1108, 0x0005, 0x792c, 0x3900,
 	0x8000, 0x2004, 0x080c, 0x0db4, 0x7037, 0x0001, 0x7150, 0x7037,
@@ -498,19 +498,19 @@
 	0x701c, 0xd08c, 0x0904, 0x163f, 0x7017, 0x0000, 0x2001, 0x0264,
 	0x2004, 0xd0bc, 0x0904, 0x163f, 0x2001, 0x0268, 0x00c6, 0x2064,
 	0x6104, 0x6038, 0x00ce, 0x918e, 0x0039, 0x1904, 0x163f, 0x9c06,
-	0x15f0, 0x0126, 0x2091, 0x2600, 0x080c, 0x7937, 0x012e, 0x7358,
+	0x15f0, 0x0126, 0x2091, 0x2600, 0x080c, 0x7945, 0x012e, 0x7358,
 	0x745c, 0x6014, 0x905d, 0x0598, 0x2b48, 0x6010, 0x00b6, 0x2058,
-	0xb800, 0x00be, 0xd0bc, 0x190c, 0xbef1, 0xab42, 0xac3e, 0x2001,
-	0x1875, 0x2004, 0xd0b4, 0x1170, 0x601c, 0xd0e4, 0x1158, 0x6010,
+	0xb800, 0x00be, 0xd0bc, 0x190c, 0xbf00, 0xab42, 0xac3e, 0x2001,
+	0x187d, 0x2004, 0xd0b4, 0x1170, 0x601c, 0xd0e4, 0x1158, 0x6010,
 	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1120, 0xa83b, 0x7fff,
-	0xa837, 0xffff, 0x080c, 0x1f48, 0x1190, 0x080c, 0x17ed, 0x2a00,
+	0xa837, 0xffff, 0x080c, 0x1f53, 0x1190, 0x080c, 0x17ed, 0x2a00,
 	0xa816, 0x0130, 0x2800, 0xa80e, 0x2c05, 0xa80a, 0x2c00, 0xa812,
 	0x7037, 0x0020, 0x781f, 0x0300, 0x001e, 0x00ee, 0x0005, 0x7037,
 	0x0050, 0x7037, 0x0020, 0x001e, 0x00ee, 0x080c, 0x14a9, 0x0005,
 	0x080c, 0x0db4, 0x0016, 0x2009, 0x00a0, 0x8109, 0xa001, 0xa001,
 	0xa001, 0x1dd8, 0x001e, 0x2ff0, 0x0126, 0x2091, 0x2200, 0x00c6,
 	0x3e60, 0x6014, 0x2048, 0x2940, 0x903e, 0x2730, 0xa864, 0x2068,
-	0xa81a, 0x9d84, 0x000f, 0x9088, 0x1f28, 0x2165, 0x0002, 0x167e,
+	0xa81a, 0x9d84, 0x000f, 0x9088, 0x1f33, 0x2165, 0x0002, 0x167e,
 	0x16cb, 0x167e, 0x167e, 0x167e, 0x16ad, 0x167e, 0x1682, 0x1677,
 	0x16c2, 0x167e, 0x167e, 0x167e, 0x1787, 0x1696, 0x168c, 0xa964,
 	0x918c, 0x00ff, 0x918e, 0x0048, 0x0904, 0x16c2, 0x9085, 0x0001,
@@ -518,10 +518,10 @@
 	0xa83e, 0xa888, 0x0804, 0x16d2, 0xa87c, 0xd0bc, 0x0d78, 0xa890,
 	0xa842, 0xa88c, 0xa83e, 0xa888, 0x0804, 0x1721, 0xa87c, 0xd0bc,
 	0x0d28, 0xa890, 0xa842, 0xa88c, 0xa83e, 0xa804, 0x9045, 0x090c,
-	0x0db4, 0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80, 0x1f28, 0x2065,
+	0x0db4, 0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80, 0x1f33, 0x2065,
 	0xa888, 0xd19c, 0x1904, 0x1721, 0x0428, 0xa87c, 0xd0ac, 0x0970,
 	0xa804, 0x9045, 0x090c, 0x0db4, 0xa164, 0xa91a, 0x91ec, 0x000f,
-	0x9d80, 0x1f28, 0x2065, 0x9006, 0xa842, 0xa83e, 0xd19c, 0x1904,
+	0x9d80, 0x1f33, 0x2065, 0x9006, 0xa842, 0xa83e, 0xd19c, 0x1904,
 	0x1721, 0x0080, 0xa87c, 0xd0ac, 0x0904, 0x167e, 0x9006, 0xa842,
 	0xa83e, 0x0804, 0x1721, 0xa87c, 0xd0ac, 0x0904, 0x167e, 0x9006,
 	0xa842, 0xa83e, 0x2c05, 0x908a, 0x0036, 0x1a0c, 0x0db4, 0x9082,
@@ -549,7 +549,7 @@
 	0x0005, 0x2800, 0xa80e, 0xab0a, 0x2c00, 0xa812, 0x0c78, 0x0804,
 	0x167e, 0x0016, 0x2009, 0x00a0, 0x8109, 0xa001, 0xa001, 0xa001,
 	0x1dd8, 0x001e, 0x2ff0, 0x0126, 0x2091, 0x2200, 0x00c6, 0x3e60,
-	0x6014, 0x2048, 0x2940, 0xa80e, 0x2061, 0x1f23, 0xa813, 0x1f23,
+	0x6014, 0x2048, 0x2940, 0xa80e, 0x2061, 0x1f2e, 0xa813, 0x1f2e,
 	0x2c05, 0xa80a, 0xa964, 0xa91a, 0xa87c, 0xd0ac, 0x090c, 0x0db4,
 	0x9006, 0xa842, 0xa83e, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0db4,
 	0xadcc, 0xacd0, 0xafd4, 0xaed8, 0xabdc, 0xaae0, 0xab2e, 0xaa32,
@@ -558,7 +558,7 @@
 	0xa916, 0x0128, 0x0078, 0x918a, 0x0002, 0xa916, 0x1158, 0x3e60,
 	0x601c, 0xc085, 0x601e, 0xa87c, 0xc0dd, 0xa87e, 0x9006, 0x00ce,
 	0x012e, 0x0005, 0xa804, 0x9045, 0x090c, 0x0db4, 0xa80e, 0xa064,
-	0xa81a, 0x9084, 0x000f, 0x9080, 0x1f28, 0x2015, 0x82ff, 0x090c,
+	0xa81a, 0x9084, 0x000f, 0x9080, 0x1f33, 0x2015, 0x82ff, 0x090c,
 	0x0db4, 0xaa12, 0x2205, 0xa80a, 0x0c10, 0x903e, 0x2730, 0xa880,
 	0xd0fc, 0x1190, 0x2d00, 0x0002, 0x18e2, 0x1844, 0x1844, 0x18e2,
 	0x18e2, 0x18dc, 0x18e2, 0x1844, 0x1893, 0x1893, 0x1893, 0x18e2,
@@ -589,6311 +589,6314 @@
 	0xa690, 0xa394, 0xa298, 0x0400, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8,
 	0xa3ac, 0xa2b0, 0x00c8, 0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0, 0xa3c4,
 	0xa2c8, 0x0090, 0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8, 0xa3dc, 0xa2e0,
-	0x0058, 0x9d86, 0x000e, 0x1130, 0x080c, 0x1ee0, 0x1904, 0x17ed,
+	0x0058, 0x9d86, 0x000e, 0x1130, 0x080c, 0x1eeb, 0x1904, 0x17ed,
 	0x900e, 0x0050, 0x080c, 0x0db4, 0xab2e, 0xaa32, 0xad1e, 0xac22,
-	0xaf26, 0xae2a, 0x080c, 0x1ee0, 0x0005, 0x6014, 0x2048, 0x6118,
+	0xaf26, 0xae2a, 0x080c, 0x1eeb, 0x0005, 0x6014, 0x2048, 0x6118,
 	0x810c, 0x810c, 0x810c, 0x81ff, 0x1118, 0xa887, 0x0001, 0x0008,
-	0xa986, 0x601b, 0x0002, 0xa974, 0xd1dc, 0x1108, 0x0005, 0xa934,
+	0xa986, 0x601b, 0x0002, 0xa874, 0x9084, 0x00ff, 0x9084, 0x0008,
+	0x0150, 0x00e9, 0x6000, 0x9086, 0x0004, 0x1120, 0x2009, 0x0048,
+	0x080c, 0x9ea9, 0x0005, 0xa974, 0xd1dc, 0x1108, 0x0005, 0xa934,
 	0xa88c, 0x9106, 0x1158, 0xa938, 0xa890, 0x9106, 0x1138, 0x601c,
-	0xc084, 0x601e, 0x2009, 0x0048, 0x0804, 0x9ebc, 0x0005, 0x0126,
+	0xc084, 0x601e, 0x2009, 0x0048, 0x0804, 0x9ea9, 0x0005, 0x0126,
 	0x00c6, 0x2091, 0x2200, 0x00ce, 0x7908, 0x918c, 0x0007, 0x9186,
 	0x0000, 0x05b0, 0x9186, 0x0003, 0x0598, 0x6020, 0x6023, 0x0000,
 	0x0006, 0x2031, 0x0008, 0x00c6, 0x781f, 0x0808, 0x7808, 0xd09c,
 	0x0120, 0x080c, 0x130c, 0x8631, 0x1db8, 0x00ce, 0x781f, 0x0800,
 	0x2031, 0x0168, 0x00c6, 0x7808, 0xd09c, 0x190c, 0x130c, 0x00ce,
-	0x2001, 0x0038, 0x080c, 0x19e7, 0x7930, 0x9186, 0x0040, 0x0160,
+	0x2001, 0x0038, 0x080c, 0x19f2, 0x7930, 0x9186, 0x0040, 0x0160,
 	0x9186, 0x0042, 0x190c, 0x0db4, 0x2001, 0x001e, 0x8001, 0x1df0,
-	0x8631, 0x1d40, 0x080c, 0x19f6, 0x000e, 0x6022, 0x012e, 0x0005,
-	0x080c, 0x19e3, 0x7827, 0x0015, 0x7828, 0x9c06, 0x1db8, 0x782b,
+	0x8631, 0x1d40, 0x080c, 0x1a01, 0x000e, 0x6022, 0x012e, 0x0005,
+	0x080c, 0x19ee, 0x7827, 0x0015, 0x7828, 0x9c06, 0x1db8, 0x782b,
 	0x0000, 0x0ca0, 0x00f6, 0x2079, 0x0300, 0x7803, 0x0000, 0x78ab,
-	0x0004, 0x00fe, 0x080c, 0x6f9b, 0x11b0, 0x2001, 0x0138, 0x2003,
+	0x0004, 0x00fe, 0x080c, 0x6faa, 0x1188, 0x2001, 0x0138, 0x2003,
 	0x0000, 0x2001, 0x0160, 0x2003, 0x0000, 0x2011, 0x012c, 0xa001,
-	0xa001, 0x8211, 0x1de0, 0x0081, 0x0066, 0x2031, 0x0000, 0x080c,
-	0x704b, 0x006e, 0x0005, 0x0479, 0x0039, 0x2001, 0x0160, 0x2502,
-	0x2001, 0x0138, 0x2202, 0x0005, 0x00e6, 0x2071, 0x0200, 0x080c,
-	0x2a6b, 0x2009, 0x003c, 0x080c, 0x226a, 0x2001, 0x015d, 0x2003,
-	0x0000, 0x7000, 0x9084, 0x003c, 0x1de0, 0x080c, 0x7f46, 0x70a0,
-	0x70a2, 0x7098, 0x709a, 0x709c, 0x709e, 0x2001, 0x020d, 0x2003,
-	0x0020, 0x00f6, 0x2079, 0x0300, 0x080c, 0x12c5, 0x7803, 0x0001,
-	0x00fe, 0x00ee, 0x0005, 0x2001, 0x0138, 0x2014, 0x2003, 0x0000,
-	0x2001, 0x0160, 0x202c, 0x2003, 0x0000, 0x080c, 0x6f9b, 0x1108,
-	0x0005, 0x2021, 0x0260, 0x2001, 0x0141, 0x201c, 0xd3dc, 0x1168,
-	0x2001, 0x0109, 0x201c, 0x939c, 0x0048, 0x1160, 0x2001, 0x0111,
-	0x201c, 0x83ff, 0x1110, 0x8421, 0x1d70, 0x2001, 0x015d, 0x2003,
-	0x0000, 0x0005, 0x0046, 0x2021, 0x0019, 0x2003, 0x0048, 0xa001,
-	0xa001, 0x201c, 0x939c, 0x0048, 0x0120, 0x8421, 0x1db0, 0x004e,
-	0x0c60, 0x004e, 0x0c40, 0x601c, 0xc084, 0x601e, 0x0005, 0x2c08,
-	0x621c, 0x080c, 0x151a, 0x7930, 0x0005, 0x2c08, 0x621c, 0x080c,
-	0x15c5, 0x7930, 0x0005, 0x8001, 0x1df0, 0x0005, 0x2031, 0x0005,
-	0x781c, 0x9084, 0x0007, 0x0170, 0x2001, 0x0038, 0x0c41, 0x9186,
-	0x0040, 0x0904, 0x1a54, 0x2001, 0x001e, 0x0c69, 0x8631, 0x1d80,
-	0x080c, 0x0db4, 0x781f, 0x0202, 0x2001, 0x015d, 0x2003, 0x0000,
-	0x2001, 0x0b10, 0x0c01, 0x781c, 0xd084, 0x0110, 0x0861, 0x04e0,
-	0x2001, 0x0030, 0x0891, 0x9186, 0x0040, 0x0568, 0x781c, 0xd084,
-	0x1da8, 0x781f, 0x0101, 0x2001, 0x0014, 0x0869, 0x2001, 0x0037,
-	0x0821, 0x9186, 0x0040, 0x0140, 0x2001, 0x0030, 0x080c, 0x19ed,
-	0x9186, 0x0040, 0x190c, 0x0db4, 0x00d6, 0x2069, 0x0200, 0x692c,
-	0xd1f4, 0x1170, 0xd1c4, 0x0160, 0xd19c, 0x0130, 0x6800, 0x9085,
-	0x1800, 0x6802, 0x00de, 0x0080, 0x6908, 0x9184, 0x0007, 0x1db0,
-	0x00de, 0x781f, 0x0100, 0x791c, 0x9184, 0x0007, 0x090c, 0x0db4,
-	0xa001, 0xa001, 0x781f, 0x0200, 0x0005, 0x0126, 0x2091, 0x2400,
-	0x2071, 0x1a35, 0x2079, 0x0090, 0x012e, 0x0005, 0x9280, 0x0005,
-	0x2004, 0x2048, 0xa97c, 0xd1dc, 0x1904, 0x1ae9, 0xa964, 0x9184,
-	0x0007, 0x0002, 0x1a72, 0x1ad4, 0x1a89, 0x1a89, 0x1a89, 0x1abc,
-	0x1a9c, 0x1a8b, 0x918c, 0x00ff, 0x9186, 0x0008, 0x1170, 0xa87c,
-	0xd0b4, 0x0904, 0x1d07, 0x9006, 0xa842, 0xa83e, 0xa988, 0x2900,
-	0xa85a, 0xa813, 0x1f23, 0x0804, 0x1ae5, 0x9186, 0x0048, 0x0904,
-	0x1ad4, 0x080c, 0x0db4, 0xa87c, 0xd0b4, 0x0904, 0x1d07, 0xa890,
-	0xa842, 0xa83a, 0xa88c, 0xa83e, 0xa836, 0xa8ac, 0xa846, 0xa8b0,
-	0xa84a, 0xa988, 0x0804, 0x1adc, 0xa864, 0x9084, 0x00ff, 0x9086,
-	0x001e, 0x1d38, 0xa87c, 0xd0b4, 0x0904, 0x1d07, 0xa890, 0xa842,
-	0xa83a, 0xa88c, 0xa83e, 0xa836, 0xa8ac, 0xa846, 0xa8b0, 0xa84a,
-	0xa804, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x1f28,
-	0x2005, 0xa812, 0xa988, 0x0448, 0x918c, 0x00ff, 0x9186, 0x0015,
-	0x1540, 0xa87c, 0xd0b4, 0x0904, 0x1d07, 0xa804, 0xa85a, 0x2040,
-	0xa064, 0x9084, 0x000f, 0x9080, 0x1f28, 0x2005, 0xa812, 0xa988,
-	0x9006, 0xa842, 0xa83e, 0x0088, 0xa87c, 0xd0b4, 0x0904, 0x1d07,
-	0xa988, 0x9006, 0xa842, 0xa83e, 0x2900, 0xa85a, 0xa864, 0x9084,
-	0x000f, 0x9080, 0x1f28, 0x2005, 0xa812, 0xa916, 0xa87c, 0xc0dd,
-	0xa87e, 0x0005, 0x00f6, 0x2079, 0x0090, 0x782c, 0xd0fc, 0x190c,
-	0x1d4c, 0x00e6, 0x2071, 0x1a35, 0x7000, 0x9005, 0x1904, 0x1b52,
-	0x7206, 0x9280, 0x0005, 0x204c, 0x9280, 0x0004, 0x2004, 0x782b,
-	0x0004, 0x00f6, 0x2079, 0x0200, 0x7803, 0x0040, 0x00fe, 0x00b6,
-	0x2058, 0xb86c, 0x7836, 0xb890, 0x00be, 0x00f6, 0x2079, 0x0200,
-	0x7803, 0x0040, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001,
-	0x781a, 0x2079, 0x0100, 0x8004, 0x78d6, 0x00fe, 0xa814, 0x2050,
-	0xa858, 0x2040, 0xa810, 0x2060, 0xa064, 0x90ec, 0x000f, 0xa944,
-	0x791a, 0x7116, 0xa848, 0x781e, 0x701a, 0x9006, 0x700e, 0x7012,
-	0x7004, 0xa940, 0xa838, 0x9106, 0x1500, 0xa93c, 0xa834, 0x9106,
-	0x11e0, 0x0006, 0x0016, 0xa938, 0xa834, 0x9105, 0x0118, 0x001e,
-	0x000e, 0x0098, 0x001e, 0x000e, 0x8aff, 0x01c8, 0x0126, 0x2091,
-	0x8000, 0x2009, 0x0306, 0x200b, 0x0808, 0x00d9, 0x0108, 0x00c9,
-	0x012e, 0x9006, 0x00ee, 0x00fe, 0x0005, 0x0036, 0x0046, 0xab38,
-	0xac34, 0x080c, 0x1f48, 0x004e, 0x003e, 0x0d30, 0x0c98, 0x9085,
-	0x0001, 0x0c80, 0x2009, 0x0306, 0x200b, 0x4800, 0x7027, 0x0000,
-	0x0005, 0x0076, 0x0066, 0x0056, 0x0046, 0x0036, 0x0026, 0x8aff,
-	0x0904, 0x1d00, 0x700c, 0x7214, 0x923a, 0x7010, 0x7218, 0x9203,
-	0x0a04, 0x1cff, 0x9705, 0x0904, 0x1cff, 0x903e, 0x2730, 0xa880,
-	0xd0fc, 0x1190, 0x2d00, 0x0002, 0x1c94, 0x1bd4, 0x1bd4, 0x1c94,
-	0x1c94, 0x1c71, 0x1c94, 0x1bd4, 0x1c78, 0x1c23, 0x1c23, 0x1c94,
-	0x1c94, 0x1c94, 0x1c6b, 0x1c23, 0xc0fc, 0xa882, 0xab2c, 0xaa30,
-	0xad1c, 0xac20, 0xdd9c, 0x0904, 0x1c96, 0x2c05, 0x908a, 0x0034,
-	0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002, 0x1bc0, 0x1bbe, 0x1bbe,
-	0x1bbe, 0x1bbe, 0x1bbe, 0x1bc4, 0x1bbe, 0x1bbe, 0x1bbe, 0x1bbe,
-	0x1bbe, 0x1bc8, 0x1bbe, 0x1bbe, 0x1bbe, 0x1bbe, 0x1bbe, 0x1bcc,
-	0x1bbe, 0x1bbe, 0x1bbe, 0x1bbe, 0x1bbe, 0x1bd0, 0x080c, 0x0db4,
-	0xa774, 0xa678, 0x0804, 0x1c96, 0xa78c, 0xa690, 0x0804, 0x1c96,
-	0xa7a4, 0xa6a8, 0x0804, 0x1c96, 0xa7bc, 0xa6c0, 0x0804, 0x1c96,
-	0xa7d4, 0xa6d8, 0x0804, 0x1c96, 0x2c05, 0x908a, 0x0036, 0x1a0c,
-	0x0db4, 0x9082, 0x001b, 0x0002, 0x1bf7, 0x1bf7, 0x1bf9, 0x1bf7,
-	0x1bf7, 0x1bf7, 0x1bff, 0x1bf7, 0x1bf7, 0x1bf7, 0x1c05, 0x1bf7,
-	0x1bf7, 0x1bf7, 0x1c0b, 0x1bf7, 0x1bf7, 0x1bf7, 0x1c11, 0x1bf7,
-	0x1bf7, 0x1bf7, 0x1c17, 0x1bf7, 0x1bf7, 0x1bf7, 0x1c1d, 0x080c,
-	0x0db4, 0xa574, 0xa478, 0xa37c, 0xa280, 0x0804, 0x1c96, 0xa584,
-	0xa488, 0xa38c, 0xa290, 0x0804, 0x1c96, 0xa594, 0xa498, 0xa39c,
-	0xa2a0, 0x0804, 0x1c96, 0xa5a4, 0xa4a8, 0xa3ac, 0xa2b0, 0x0804,
-	0x1c96, 0xa5b4, 0xa4b8, 0xa3bc, 0xa2c0, 0x0804, 0x1c96, 0xa5c4,
-	0xa4c8, 0xa3cc, 0xa2d0, 0x0804, 0x1c96, 0xa5d4, 0xa4d8, 0xa3dc,
-	0xa2e0, 0x0804, 0x1c96, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0db4,
-	0x9082, 0x001b, 0x0002, 0x1c46, 0x1c44, 0x1c44, 0x1c44, 0x1c44,
-	0x1c44, 0x1c4e, 0x1c44, 0x1c44, 0x1c44, 0x1c44, 0x1c44, 0x1c56,
-	0x1c44, 0x1c44, 0x1c44, 0x1c44, 0x1c44, 0x1c5d, 0x1c44, 0x1c44,
-	0x1c44, 0x1c44, 0x1c44, 0x1c64, 0x080c, 0x0db4, 0xa56c, 0xa470,
-	0xa774, 0xa678, 0xa37c, 0xa280, 0x0804, 0x1c96, 0xa584, 0xa488,
-	0xa78c, 0xa690, 0xa394, 0xa298, 0x0804, 0x1c96, 0xa59c, 0xa4a0,
-	0xa7a4, 0xa6a8, 0xa3ac, 0xa2b0, 0x04c8, 0xa5b4, 0xa4b8, 0xa7bc,
-	0xa6c0, 0xa3c4, 0xa2c8, 0x0490, 0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8,
-	0xa3dc, 0xa2e0, 0x0458, 0xa864, 0x9084, 0x00ff, 0x9086, 0x001e,
-	0x1518, 0x080c, 0x1ee0, 0x1904, 0x1b6f, 0x900e, 0x0804, 0x1d00,
-	0xab64, 0x939c, 0x00ff, 0x9386, 0x0048, 0x1180, 0x00c6, 0x7004,
-	0x2060, 0x6004, 0x9086, 0x0043, 0x00ce, 0x0904, 0x1c23, 0xab9c,
-	0x9016, 0xad8c, 0xac90, 0xaf94, 0xae98, 0x0040, 0x9386, 0x0008,
-	0x0904, 0x1c23, 0x080c, 0x0db4, 0x080c, 0x0db4, 0x2009, 0x030f,
-	0x2104, 0xd0fc, 0x0530, 0x0066, 0x2009, 0x0306, 0x2104, 0x9084,
-	0x0030, 0x15c8, 0x2031, 0x1000, 0x200b, 0x4000, 0x2600, 0x9302,
-	0x928b, 0x0000, 0xa82e, 0xa932, 0x0278, 0x9105, 0x0168, 0x2011,
-	0x0000, 0x2618, 0x2600, 0x9500, 0xa81e, 0x9481, 0x0000, 0xa822,
-	0xa880, 0xc0fd, 0xa882, 0x0020, 0xa82f, 0x0000, 0xa833, 0x0000,
-	0x006e, 0x7b12, 0x7a16, 0x7d02, 0x7c06, 0x7f0a, 0x7e0e, 0x782b,
-	0x0001, 0x7000, 0x8000, 0x7002, 0xa83c, 0x9300, 0xa83e, 0xa840,
-	0x9201, 0xa842, 0x700c, 0x9300, 0x700e, 0x7010, 0x9201, 0x7012,
-	0x080c, 0x1ee0, 0x0428, 0x2031, 0x0080, 0x9584, 0x007f, 0x0108,
-	0x9632, 0x7124, 0x7000, 0x9086, 0x0000, 0x1198, 0xc185, 0x7126,
-	0x2009, 0x0306, 0x2104, 0xd0b4, 0x1904, 0x1ca6, 0x200b, 0x4040,
-	0x2009, 0x1a4e, 0x2104, 0x8000, 0x0a04, 0x1ca6, 0x200a, 0x0804,
-	0x1ca6, 0xc18d, 0x7126, 0xd184, 0x1d58, 0x0804, 0x1ca6, 0x9006,
-	0x002e, 0x003e, 0x004e, 0x005e, 0x006e, 0x007e, 0x0005, 0x080c,
-	0x0db4, 0x0026, 0x2001, 0x0105, 0x2003, 0x0010, 0x782b, 0x0004,
-	0x7003, 0x0000, 0x7004, 0x0016, 0x080c, 0x1b62, 0x001e, 0x2060,
-	0x6014, 0x2048, 0x080c, 0xbb2c, 0x0118, 0xa880, 0xc0bd, 0xa882,
-	0x6020, 0x9086, 0x0006, 0x1180, 0x2061, 0x0100, 0x62c8, 0x2001,
-	0x00fa, 0x8001, 0x1df0, 0x60c8, 0x9206, 0x1dc0, 0x60c4, 0xa89a,
-	0x60c8, 0xa896, 0x7004, 0x2060, 0x00c6, 0x080c, 0xb75d, 0x00ce,
-	0x2001, 0x19c6, 0x2004, 0x9c06, 0x1160, 0x2009, 0x0040, 0x080c,
-	0x226a, 0x080c, 0x98eb, 0x2011, 0x0000, 0x080c, 0x977c, 0x080c,
-	0x8a4a, 0x002e, 0x0804, 0x1e90, 0x0126, 0x2091, 0x2400, 0xa858,
-	0x2040, 0x792c, 0x782b, 0x0002, 0x9184, 0x0700, 0x1904, 0x1d09,
-	0x7000, 0x0002, 0x1e90, 0x1d5e, 0x1dde, 0x1e8e, 0x8001, 0x7002,
-	0x7027, 0x0000, 0xd19c, 0x1158, 0x8aff, 0x0904, 0x1dab, 0x080c,
-	0x1b69, 0x0904, 0x1e90, 0x080c, 0x1b69, 0x0804, 0x1e90, 0x782b,
-	0x0004, 0xd194, 0x0148, 0xa880, 0xc0fc, 0xa882, 0x8aff, 0x1518,
-	0xa87c, 0xc0f5, 0xa87e, 0x00f8, 0x0026, 0x0036, 0xab3c, 0xaa40,
-	0x0016, 0x7910, 0xa82c, 0x9100, 0xa82e, 0x7914, 0xa830, 0x9101,
-	0xa832, 0x001e, 0x7810, 0x931a, 0x7814, 0x9213, 0x7800, 0xa81e,
-	0x7804, 0xa822, 0xab3e, 0xaa42, 0x003e, 0x002e, 0x080c, 0x1efb,
-	0xa880, 0xc0fd, 0xa882, 0x2a00, 0xa816, 0x2800, 0xa85a, 0x2c00,
-	0xa812, 0x7003, 0x0000, 0x2009, 0x0306, 0x200b, 0x4800, 0x7027,
-	0x0000, 0x0804, 0x1e90, 0x00f6, 0x0026, 0x781c, 0x0006, 0x7818,
-	0x0006, 0x2079, 0x0100, 0x7a14, 0x9284, 0x1984, 0x9085, 0x0012,
-	0x7816, 0x0036, 0x2019, 0x1000, 0x8319, 0x090c, 0x0db4, 0x7820,
-	0xd0bc, 0x1dd0, 0x003e, 0x79c8, 0x000e, 0x9102, 0x001e, 0x0006,
-	0x0016, 0x79c4, 0x000e, 0x9103, 0x78c6, 0x000e, 0x78ca, 0x9284,
-	0x1984, 0x9085, 0x0012, 0x7816, 0x002e, 0x00fe, 0x782b, 0x0008,
-	0x7003, 0x0000, 0x080c, 0x1b62, 0x0804, 0x1e90, 0x8001, 0x7002,
-	0x7024, 0x8004, 0x7026, 0xd194, 0x0170, 0x782c, 0xd0fc, 0x1904,
-	0x1d51, 0xd19c, 0x1904, 0x1e8c, 0x8aff, 0x0904, 0x1e90, 0x080c,
-	0x1b69, 0x0804, 0x1e90, 0x0026, 0x0036, 0xab3c, 0xaa40, 0x080c,
-	0x1efb, 0xdd9c, 0x1904, 0x1e4b, 0x2c05, 0x908a, 0x0036, 0x1a0c,
-	0x0db4, 0x9082, 0x001b, 0x0002, 0x1e1f, 0x1e1f, 0x1e21, 0x1e1f,
-	0x1e1f, 0x1e1f, 0x1e27, 0x1e1f, 0x1e1f, 0x1e1f, 0x1e2d, 0x1e1f,
-	0x1e1f, 0x1e1f, 0x1e33, 0x1e1f, 0x1e1f, 0x1e1f, 0x1e39, 0x1e1f,
-	0x1e1f, 0x1e1f, 0x1e3f, 0x1e1f, 0x1e1f, 0x1e1f, 0x1e45, 0x080c,
-	0x0db4, 0xa07c, 0x931a, 0xa080, 0x9213, 0x0804, 0x1d80, 0xa08c,
-	0x931a, 0xa090, 0x9213, 0x0804, 0x1d80, 0xa09c, 0x931a, 0xa0a0,
-	0x9213, 0x0804, 0x1d80, 0xa0ac, 0x931a, 0xa0b0, 0x9213, 0x0804,
-	0x1d80, 0xa0bc, 0x931a, 0xa0c0, 0x9213, 0x0804, 0x1d80, 0xa0cc,
-	0x931a, 0xa0d0, 0x9213, 0x0804, 0x1d80, 0xa0dc, 0x931a, 0xa0e0,
-	0x9213, 0x0804, 0x1d80, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0db4,
-	0x9082, 0x001b, 0x0002, 0x1e6e, 0x1e6c, 0x1e6c, 0x1e6c, 0x1e6c,
-	0x1e6c, 0x1e74, 0x1e6c, 0x1e6c, 0x1e6c, 0x1e6c, 0x1e6c, 0x1e7a,
-	0x1e6c, 0x1e6c, 0x1e6c, 0x1e6c, 0x1e6c, 0x1e80, 0x1e6c, 0x1e6c,
-	0x1e6c, 0x1e6c, 0x1e6c, 0x1e86, 0x080c, 0x0db4, 0xa07c, 0x931a,
-	0xa080, 0x9213, 0x0804, 0x1d80, 0xa094, 0x931a, 0xa098, 0x9213,
-	0x0804, 0x1d80, 0xa0ac, 0x931a, 0xa0b0, 0x9213, 0x0804, 0x1d80,
-	0xa0c4, 0x931a, 0xa0c8, 0x9213, 0x0804, 0x1d80, 0xa0dc, 0x931a,
-	0xa0e0, 0x9213, 0x0804, 0x1d80, 0x0804, 0x1d7c, 0x080c, 0x0db4,
-	0x012e, 0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a35, 0x7000, 0x9086,
-	0x0000, 0x0904, 0x1edb, 0x2079, 0x0090, 0x2009, 0x0207, 0x210c,
-	0xd194, 0x01b8, 0x2009, 0x020c, 0x210c, 0x9184, 0x0003, 0x0188,
-	0x080c, 0xd8f6, 0x2001, 0x0133, 0x2004, 0x9005, 0x090c, 0x0db4,
-	0x0016, 0x2009, 0x0040, 0x080c, 0x226a, 0x001e, 0x2001, 0x020c,
-	0x2102, 0x2009, 0x0206, 0x2104, 0x2009, 0x0203, 0x210c, 0x9106,
-	0x1120, 0x2009, 0x0040, 0x080c, 0x226a, 0x782c, 0xd0fc, 0x09a8,
-	0x080c, 0x1d4c, 0x7000, 0x9086, 0x0000, 0x1978, 0x782b, 0x0004,
-	0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x226a, 0x782b,
-	0x0002, 0x7003, 0x0000, 0x080c, 0x1b62, 0x00ee, 0x00fe, 0x0005,
-	0xa880, 0xd0fc, 0x11a8, 0x8c60, 0x2c05, 0x9005, 0x0110, 0x8a51,
-	0x0005, 0xa004, 0x9005, 0x0168, 0xa85a, 0x2040, 0xa064, 0x9084,
-	0x000f, 0x9080, 0x1f28, 0x2065, 0x8cff, 0x090c, 0x0db4, 0x8a51,
-	0x0005, 0x2050, 0x0005, 0xa880, 0xd0fc, 0x11b8, 0x8a50, 0x8c61,
-	0x2c05, 0x9005, 0x1190, 0x2800, 0x9906, 0x0120, 0xa000, 0x9005,
-	0x1108, 0x2900, 0x2040, 0xa85a, 0xa064, 0x9084, 0x000f, 0x9080,
-	0x1f38, 0x2065, 0x8cff, 0x090c, 0x0db4, 0x0005, 0x0000, 0x001d,
-	0x0021, 0x0025, 0x0029, 0x002d, 0x0031, 0x0035, 0x0000, 0x001b,
-	0x0021, 0x0027, 0x002d, 0x0033, 0x0000, 0x0000, 0x0023, 0x0000,
-	0x0000, 0x1f1b, 0x1f17, 0x0000, 0x0000, 0x1f25, 0x0000, 0x1f1b,
-	0x1f22, 0x1f22, 0x1f1f, 0x0000, 0x0000, 0x0000, 0x1f25, 0x1f22,
-	0x0000, 0x1f1d, 0x1f1d, 0x0000, 0x0000, 0x1f25, 0x0000, 0x1f1d,
-	0x1f23, 0x1f23, 0x1f23, 0x0000, 0x0000, 0x0000, 0x1f25, 0x1f23,
-	0x00c6, 0x00d6, 0x0086, 0xab42, 0xac3e, 0xa888, 0x9055, 0x0904,
-	0x2127, 0x2940, 0xa064, 0x90ec, 0x000f, 0x9084, 0x00ff, 0x9086,
-	0x0008, 0x1118, 0x2061, 0x1f23, 0x00d0, 0x9de0, 0x1f28, 0x9d86,
-	0x0007, 0x0130, 0x9d86, 0x000e, 0x0118, 0x9d86, 0x000f, 0x1120,
-	0xa08c, 0x9422, 0xa090, 0x931b, 0x2c05, 0x9065, 0x1140, 0x0310,
-	0x0804, 0x2127, 0xa004, 0x9045, 0x0904, 0x2127, 0x08d8, 0x2c05,
-	0x9005, 0x0904, 0x200f, 0xdd9c, 0x1904, 0x1fcb, 0x908a, 0x0036,
-	0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002, 0x1fa0, 0x1fa0, 0x1fa2,
-	0x1fa0, 0x1fa0, 0x1fa0, 0x1fa8, 0x1fa0, 0x1fa0, 0x1fa0, 0x1fae,
-	0x1fa0, 0x1fa0, 0x1fa0, 0x1fb4, 0x1fa0, 0x1fa0, 0x1fa0, 0x1fba,
-	0x1fa0, 0x1fa0, 0x1fa0, 0x1fc0, 0x1fa0, 0x1fa0, 0x1fa0, 0x1fc6,
-	0x080c, 0x0db4, 0xa07c, 0x9422, 0xa080, 0x931b, 0x0804, 0x2005,
-	0xa08c, 0x9422, 0xa090, 0x931b, 0x0804, 0x2005, 0xa09c, 0x9422,
-	0xa0a0, 0x931b, 0x0804, 0x2005, 0xa0ac, 0x9422, 0xa0b0, 0x931b,
-	0x0804, 0x2005, 0xa0bc, 0x9422, 0xa0c0, 0x931b, 0x0804, 0x2005,
-	0xa0cc, 0x9422, 0xa0d0, 0x931b, 0x0804, 0x2005, 0xa0dc, 0x9422,
-	0xa0e0, 0x931b, 0x04d0, 0x908a, 0x0034, 0x1a0c, 0x0db4, 0x9082,
-	0x001b, 0x0002, 0x1fed, 0x1feb, 0x1feb, 0x1feb, 0x1feb, 0x1feb,
-	0x1ff2, 0x1feb, 0x1feb, 0x1feb, 0x1feb, 0x1feb, 0x1ff7, 0x1feb,
-	0x1feb, 0x1feb, 0x1feb, 0x1feb, 0x1ffc, 0x1feb, 0x1feb, 0x1feb,
-	0x1feb, 0x1feb, 0x2001, 0x080c, 0x0db4, 0xa07c, 0x9422, 0xa080,
-	0x931b, 0x0098, 0xa094, 0x9422, 0xa098, 0x931b, 0x0070, 0xa0ac,
-	0x9422, 0xa0b0, 0x931b, 0x0048, 0xa0c4, 0x9422, 0xa0c8, 0x931b,
-	0x0020, 0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x0630, 0x2300, 0x9405,
-	0x0160, 0x8a51, 0x0904, 0x2127, 0x8c60, 0x0804, 0x1f77, 0xa004,
-	0x9045, 0x0904, 0x2127, 0x0804, 0x1f52, 0x8a51, 0x0904, 0x2127,
-	0x8c60, 0x2c05, 0x9005, 0x1158, 0xa004, 0x9045, 0x0904, 0x2127,
-	0xa064, 0x90ec, 0x000f, 0x9de0, 0x1f28, 0x2c05, 0x2060, 0xa880,
-	0xc0fc, 0xa882, 0x0804, 0x211c, 0x2c05, 0x8422, 0x8420, 0x831a,
-	0x9399, 0x0000, 0xac2e, 0xab32, 0xdd9c, 0x1904, 0x20b9, 0x9082,
-	0x001b, 0x0002, 0x2055, 0x2055, 0x2057, 0x2055, 0x2055, 0x2055,
-	0x2065, 0x2055, 0x2055, 0x2055, 0x2073, 0x2055, 0x2055, 0x2055,
-	0x2081, 0x2055, 0x2055, 0x2055, 0x208f, 0x2055, 0x2055, 0x2055,
-	0x209d, 0x2055, 0x2055, 0x2055, 0x20ab, 0x080c, 0x0db4, 0xa17c,
-	0x2400, 0x9122, 0xa180, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa074,
-	0x9420, 0xa078, 0x9319, 0x0804, 0x2117, 0xa18c, 0x2400, 0x9122,
-	0xa190, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa084, 0x9420, 0xa088,
-	0x9319, 0x0804, 0x2117, 0xa19c, 0x2400, 0x9122, 0xa1a0, 0x2300,
-	0x911b, 0x0a0c, 0x0db4, 0xa094, 0x9420, 0xa098, 0x9319, 0x0804,
-	0x2117, 0xa1ac, 0x2400, 0x9122, 0xa1b0, 0x2300, 0x911b, 0x0a0c,
-	0x0db4, 0xa0a4, 0x9420, 0xa0a8, 0x9319, 0x0804, 0x2117, 0xa1bc,
-	0x2400, 0x9122, 0xa1c0, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa0b4,
-	0x9420, 0xa0b8, 0x9319, 0x0804, 0x2117, 0xa1cc, 0x2400, 0x9122,
-	0xa1d0, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa0c4, 0x9420, 0xa0c8,
-	0x9319, 0x0804, 0x2117, 0xa1dc, 0x2400, 0x9122, 0xa1e0, 0x2300,
-	0x911b, 0x0a0c, 0x0db4, 0xa0d4, 0x9420, 0xa0d8, 0x9319, 0x0804,
-	0x2117, 0x9082, 0x001b, 0x0002, 0x20d7, 0x20d5, 0x20d5, 0x20d5,
-	0x20d5, 0x20d5, 0x20e4, 0x20d5, 0x20d5, 0x20d5, 0x20d5, 0x20d5,
-	0x20f1, 0x20d5, 0x20d5, 0x20d5, 0x20d5, 0x20d5, 0x20fe, 0x20d5,
-	0x20d5, 0x20d5, 0x20d5, 0x20d5, 0x210b, 0x080c, 0x0db4, 0xa17c,
-	0x2400, 0x9122, 0xa180, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa06c,
-	0x9420, 0xa070, 0x9319, 0x0498, 0xa194, 0x2400, 0x9122, 0xa198,
-	0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa084, 0x9420, 0xa088, 0x9319,
-	0x0430, 0xa1ac, 0x2400, 0x9122, 0xa1b0, 0x2300, 0x911b, 0x0a0c,
-	0x0db4, 0xa09c, 0x9420, 0xa0a0, 0x9319, 0x00c8, 0xa1c4, 0x2400,
-	0x9122, 0xa1c8, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa0b4, 0x9420,
-	0xa0b8, 0x9319, 0x0060, 0xa1dc, 0x2400, 0x9122, 0xa1e0, 0x2300,
-	0x911b, 0x0a0c, 0x0db4, 0xa0cc, 0x9420, 0xa0d0, 0x9319, 0xac1e,
-	0xab22, 0xa880, 0xc0fd, 0xa882, 0x2800, 0xa85a, 0x2c00, 0xa812,
-	0x2a00, 0xa816, 0x000e, 0x000e, 0x000e, 0x9006, 0x0028, 0x008e,
-	0x00de, 0x00ce, 0x9085, 0x0001, 0x0005, 0x2001, 0x0005, 0x2004,
-	0xd0bc, 0x190c, 0x0dad, 0x9084, 0x0007, 0x0002, 0x2148, 0x1d4c,
-	0x2148, 0x213e, 0x2141, 0x2144, 0x2141, 0x2144, 0x080c, 0x1d4c,
-	0x0005, 0x080c, 0x118f, 0x0005, 0x080c, 0x1d4c, 0x080c, 0x118f,
-	0x0005, 0x0126, 0x2091, 0x2600, 0x2079, 0x0200, 0x2071, 0x0260,
-	0x2069, 0x1800, 0x7817, 0x0000, 0x789b, 0x0814, 0x78a3, 0x0406,
-	0x789f, 0x0410, 0x2009, 0x013b, 0x200b, 0x0400, 0x781b, 0x0002,
-	0x783b, 0x001f, 0x7837, 0x0020, 0x7803, 0x1600, 0x012e, 0x0005,
-	0x2091, 0x2600, 0x781c, 0xd0a4, 0x190c, 0x2267, 0x7900, 0xd1dc,
-	0x1118, 0x9084, 0x0006, 0x001a, 0x9084, 0x000e, 0x0002, 0x218f,
-	0x2187, 0x7937, 0x2187, 0x2189, 0x2189, 0x2189, 0x2189, 0x791d,
-	0x2187, 0x218b, 0x2187, 0x2189, 0x2187, 0x2189, 0x2187, 0x080c,
-	0x0db4, 0x0031, 0x0020, 0x080c, 0x791d, 0x080c, 0x7937, 0x0005,
-	0x0006, 0x0016, 0x0026, 0x080c, 0xd8f6, 0x7930, 0x9184, 0x0003,
-	0x01c0, 0x2001, 0x19c6, 0x2004, 0x9005, 0x0170, 0x2001, 0x0133,
-	0x2004, 0x9005, 0x090c, 0x0db4, 0x00c6, 0x2001, 0x19c6, 0x2064,
-	0x080c, 0xb75d, 0x00ce, 0x00f8, 0x2009, 0x0040, 0x080c, 0x226a,
-	0x00d0, 0x9184, 0x0014, 0x01a0, 0x6a00, 0x9286, 0x0003, 0x0160,
-	0x080c, 0x6f9b, 0x1138, 0x080c, 0x727f, 0x080c, 0x5cda, 0x080c,
-	0x6ecd, 0x0010, 0x080c, 0x5b99, 0x080c, 0x79e6, 0x0041, 0x0018,
-	0x9184, 0x9540, 0x1dc8, 0x002e, 0x001e, 0x000e, 0x0005, 0x00e6,
-	0x0036, 0x0046, 0x0056, 0x2071, 0x1a32, 0x080c, 0x195a, 0x005e,
-	0x004e, 0x003e, 0x00ee, 0x0005, 0x0126, 0x2091, 0x2e00, 0x2071,
-	0x1800, 0x7128, 0x2001, 0x193f, 0x2102, 0x2001, 0x1947, 0x2102,
-	0x2001, 0x013b, 0x2102, 0x2079, 0x0200, 0x2001, 0x0201, 0x789e,
-	0x78a3, 0x0200, 0x9198, 0x0007, 0x831c, 0x831c, 0x831c, 0x9398,
-	0x0005, 0x2320, 0x9182, 0x0204, 0x1230, 0x2011, 0x0008, 0x8423,
-	0x8423, 0x8423, 0x0488, 0x9182, 0x024c, 0x1240, 0x2011, 0x0007,
-	0x8403, 0x8003, 0x9400, 0x9400, 0x9420, 0x0430, 0x9182, 0x02bc,
-	0x1238, 0x2011, 0x0006, 0x8403, 0x8003, 0x9400, 0x9420, 0x00e0,
-	0x9182, 0x034c, 0x1230, 0x2011, 0x0005, 0x8403, 0x8003, 0x9420,
-	0x0098, 0x9182, 0x042c, 0x1228, 0x2011, 0x0004, 0x8423, 0x8423,
-	0x0058, 0x9182, 0x059c, 0x1228, 0x2011, 0x0003, 0x8403, 0x9420,
-	0x0018, 0x2011, 0x0002, 0x8423, 0x9482, 0x0228, 0x8002, 0x8020,
-	0x8301, 0x9402, 0x0110, 0x0208, 0x8321, 0x8217, 0x8203, 0x9405,
-	0x789a, 0x012e, 0x0005, 0x0006, 0x00d6, 0x2069, 0x0200, 0x6814,
-	0x9084, 0xffc0, 0x910d, 0x6916, 0x00de, 0x000e, 0x0005, 0x00d6,
-	0x2069, 0x0200, 0x9005, 0x6810, 0x0110, 0xc0a5, 0x0008, 0xc0a4,
-	0x6812, 0x00de, 0x0005, 0x0006, 0x00d6, 0x2069, 0x0200, 0x6810,
-	0x9084, 0xfff8, 0x910d, 0x6912, 0x00de, 0x000e, 0x0005, 0x7938,
-	0x080c, 0x0dad, 0x00f6, 0x2079, 0x0200, 0x7902, 0xa001, 0xa001,
-	0xa001, 0xa001, 0xa001, 0xa001, 0x7902, 0xa001, 0xa001, 0xa001,
-	0xa001, 0xa001, 0xa001, 0x00fe, 0x0005, 0x0126, 0x2091, 0x2800,
-	0x2061, 0x0100, 0x2071, 0x1800, 0x2009, 0x0000, 0x080c, 0x2a65,
-	0x080c, 0x2980, 0x6054, 0x8004, 0x8004, 0x8004, 0x8004, 0x9084,
-	0x000c, 0x6150, 0x918c, 0xfff3, 0x9105, 0x6052, 0x6050, 0x9084,
-	0xb17f, 0x9085, 0x2000, 0x6052, 0x2009, 0x196d, 0x2011, 0x196e,
-	0x6358, 0x939c, 0x38f0, 0x2320, 0x080c, 0x29c4, 0x1238, 0x939d,
-	0x4003, 0x94a5, 0x8603, 0x230a, 0x2412, 0x0030, 0x939d, 0x0203,
-	0x94a5, 0x8603, 0x230a, 0x2412, 0x9006, 0x080c, 0x29af, 0x9006,
-	0x080c, 0x2992, 0x20a9, 0x0012, 0x1d04, 0x22bc, 0x2091, 0x6000,
-	0x1f04, 0x22bc, 0x602f, 0x0100, 0x602f, 0x0000, 0x6050, 0x9085,
-	0x0400, 0x9084, 0xdfff, 0x6052, 0x6024, 0x6026, 0x080c, 0x269e,
-	0x2009, 0x00ef, 0x6132, 0x6136, 0x080c, 0x26ae, 0x60e7, 0x0000,
-	0x61ea, 0x60e3, 0x0002, 0x604b, 0xf7f7, 0x6043, 0x0000, 0x602f,
-	0x0080, 0x602f, 0x0000, 0x6007, 0x149f, 0x60bb, 0x0000, 0x20a9,
-	0x0018, 0x60bf, 0x0000, 0x1f04, 0x22e9, 0x60bb, 0x0000, 0x60bf,
-	0x0108, 0x60bf, 0x0012, 0x60bf, 0x0320, 0x60bf, 0x0018, 0x601b,
-	0x00f0, 0x601f, 0x001e, 0x600f, 0x006b, 0x602b, 0x402f, 0x012e,
-	0x0005, 0x00f6, 0x2079, 0x0140, 0x78c3, 0x0080, 0x78c3, 0x0083,
-	0x78c3, 0x0000, 0x00fe, 0x0005, 0x2001, 0x1834, 0x2003, 0x0000,
-	0x2001, 0x1833, 0x2003, 0x0001, 0x0005, 0x0126, 0x2091, 0x2800,
-	0x0006, 0x0016, 0x0026, 0x6124, 0x9184, 0x5e2c, 0x1118, 0x9184,
-	0x0007, 0x002a, 0x9195, 0x0004, 0x9284, 0x0007, 0x0002, 0x2349,
-	0x232f, 0x2332, 0x2335, 0x233a, 0x233c, 0x2340, 0x2344, 0x080c,
-	0x82c6, 0x00b8, 0x080c, 0x8393, 0x00a0, 0x080c, 0x8393, 0x080c,
-	0x82c6, 0x0078, 0x0099, 0x0068, 0x080c, 0x82c6, 0x0079, 0x0048,
-	0x080c, 0x8393, 0x0059, 0x0028, 0x080c, 0x8393, 0x080c, 0x82c6,
-	0x0029, 0x002e, 0x001e, 0x000e, 0x012e, 0x0005, 0x00a6, 0x6124,
-	0x6028, 0xd09c, 0x0118, 0xd19c, 0x1904, 0x2597, 0xd1f4, 0x190c,
-	0x0dad, 0x080c, 0x6f9b, 0x0904, 0x23a4, 0x080c, 0xc22c, 0x1120,
-	0x7000, 0x9086, 0x0003, 0x0570, 0x6024, 0x9084, 0x1800, 0x0550,
-	0x080c, 0x6fbe, 0x0118, 0x080c, 0x6fac, 0x1520, 0x6027, 0x0020,
-	0x6043, 0x0000, 0x080c, 0xc22c, 0x0168, 0x080c, 0x6fbe, 0x1150,
-	0x2001, 0x1977, 0x2003, 0x0001, 0x6027, 0x1800, 0x080c, 0x6e1c,
-	0x0804, 0x259a, 0x70a0, 0x9005, 0x1150, 0x70a3, 0x0001, 0x00d6,
-	0x2069, 0x0140, 0x080c, 0x6ff2, 0x00de, 0x1904, 0x259a, 0x080c,
-	0x7289, 0x0428, 0x080c, 0x6fbe, 0x1590, 0x6024, 0x9084, 0x1800,
-	0x1108, 0x0468, 0x080c, 0x7289, 0x080c, 0x727f, 0x080c, 0x5cda,
-	0x080c, 0x6ecd, 0x0804, 0x2597, 0xd1ac, 0x1508, 0x6024, 0xd0dc,
-	0x1170, 0xd0e4, 0x1178, 0xd0d4, 0x1190, 0xd0cc, 0x0130, 0x7094,
-	0x9086, 0x0028, 0x1110, 0x080c, 0x716e, 0x0804, 0x2597, 0x080c,
-	0x7284, 0x0048, 0x2001, 0x194d, 0x2003, 0x0002, 0x0020, 0x080c,
-	0x70d4, 0x0804, 0x2597, 0x080c, 0x7208, 0x0804, 0x2597, 0xd1ac,
-	0x0904, 0x24b8, 0x080c, 0x6f9b, 0x11c0, 0x6027, 0x0020, 0x0006,
-	0x0026, 0x0036, 0x080c, 0x6fb5, 0x1158, 0x080c, 0x727f, 0x080c,
-	0x5cda, 0x080c, 0x6ecd, 0x003e, 0x002e, 0x000e, 0x00ae, 0x0005,
-	0x003e, 0x002e, 0x000e, 0x080c, 0x6f73, 0x0016, 0x0046, 0x00c6,
-	0x644c, 0x9486, 0xf0f0, 0x1138, 0x2061, 0x0100, 0x644a, 0x6043,
-	0x0090, 0x6043, 0x0010, 0x74d6, 0x948c, 0xff00, 0x7038, 0xd084,
-	0x0178, 0x9186, 0xf800, 0x1160, 0x7044, 0xd084, 0x1148, 0xc085,
-	0x7046, 0x0036, 0x2418, 0x2011, 0x8016, 0x080c, 0x48e9, 0x003e,
-	0x080c, 0xc225, 0x1904, 0x2495, 0x9196, 0xff00, 0x05a8, 0x705c,
-	0x9084, 0x00ff, 0x810f, 0x81ff, 0x0110, 0x9116, 0x0568, 0x7130,
-	0xd184, 0x1550, 0x080c, 0x3135, 0x0128, 0xc18d, 0x7132, 0x080c,
-	0x6563, 0x1510, 0x6240, 0x9294, 0x0010, 0x0130, 0x6248, 0x9294,
-	0xff00, 0x9296, 0xff00, 0x01c0, 0x7030, 0xd08c, 0x0904, 0x2495,
-	0x7038, 0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904,
-	0x2495, 0xc1ad, 0x2102, 0x0036, 0x73d4, 0x2011, 0x8013, 0x080c,
-	0x48e9, 0x003e, 0x0804, 0x2495, 0x7038, 0xd08c, 0x1140, 0x2001,
-	0x180c, 0x200c, 0xd1ac, 0x1904, 0x2495, 0xc1ad, 0x2102, 0x0036,
-	0x73d4, 0x2011, 0x8013, 0x080c, 0x48e9, 0x003e, 0x7130, 0xc185,
-	0x7132, 0x2011, 0x1854, 0x220c, 0x00f0, 0x0016, 0x2009, 0x0001,
-	0x2011, 0x0100, 0x080c, 0x8218, 0x2019, 0x000e, 0x00c6, 0x2061,
-	0x0000, 0x080c, 0xd4c7, 0x00ce, 0x9484, 0x00ff, 0x9080, 0x313a,
-	0x200d, 0x918c, 0xff00, 0x810f, 0x2120, 0x9006, 0x2009, 0x000e,
-	0x080c, 0xd54b, 0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009, 0x0002,
-	0x2019, 0x0004, 0x080c, 0x2fa7, 0x001e, 0x0078, 0x0156, 0x00b6,
-	0x20a9, 0x007f, 0x900e, 0x080c, 0x6247, 0x1110, 0x080c, 0x5cf4,
-	0x8108, 0x1f04, 0x248b, 0x00be, 0x015e, 0x00ce, 0x004e, 0x080c,
-	0x9dc8, 0x60e3, 0x0000, 0x001e, 0x2001, 0x1800, 0x2014, 0x9296,
-	0x0004, 0x1170, 0xd19c, 0x11a0, 0x2011, 0x180c, 0x2214, 0xd29c,
-	0x1120, 0x6204, 0x9295, 0x0002, 0x6206, 0x6228, 0xc29d, 0x622a,
-	0x2003, 0x0001, 0x2001, 0x1825, 0x2003, 0x0000, 0x6027, 0x0020,
-	0xd194, 0x0904, 0x2597, 0x0016, 0x6220, 0xd2b4, 0x0904, 0x2540,
-	0x080c, 0x80a1, 0x080c, 0x93ad, 0x6027, 0x0004, 0x00f6, 0x2019,
-	0x19c0, 0x2304, 0x907d, 0x0904, 0x250f, 0x7804, 0x9086, 0x0032,
-	0x15f0, 0x00d6, 0x00c6, 0x00e6, 0x0096, 0x2069, 0x0140, 0x782c,
-	0x685e, 0x7808, 0x685a, 0x6043, 0x0002, 0x2001, 0x0003, 0x8001,
-	0x1df0, 0x6043, 0x0000, 0x2001, 0x003c, 0x8001, 0x1df0, 0x080c,
-	0x2b26, 0x2001, 0x001e, 0x8001, 0x0240, 0x20a9, 0x0009, 0x080c,
-	0x2a40, 0x6904, 0xd1dc, 0x1140, 0x0cb0, 0x2001, 0x0100, 0x080c,
-	0x2b16, 0x9006, 0x080c, 0x2b16, 0x080c, 0x8861, 0x080c, 0x896d,
-	0x7814, 0x2048, 0xa867, 0x0103, 0x2f60, 0x080c, 0x9e42, 0x009e,
-	0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e, 0x00ae, 0x0005, 0x00fe,
+	0xa001, 0x8211, 0x1de0, 0x0059, 0x0804, 0x705a, 0x0479, 0x0039,
+	0x2001, 0x0160, 0x2502, 0x2001, 0x0138, 0x2202, 0x0005, 0x00e6,
+	0x2071, 0x0200, 0x080c, 0x2a76, 0x2009, 0x003c, 0x080c, 0x2275,
+	0x2001, 0x015d, 0x2003, 0x0000, 0x7000, 0x9084, 0x003c, 0x1de0,
+	0x080c, 0x7f64, 0x70a0, 0x70a2, 0x7098, 0x709a, 0x709c, 0x709e,
+	0x2001, 0x020d, 0x2003, 0x0020, 0x00f6, 0x2079, 0x0300, 0x080c,
+	0x12c5, 0x7803, 0x0001, 0x00fe, 0x00ee, 0x0005, 0x2001, 0x0138,
+	0x2014, 0x2003, 0x0000, 0x2001, 0x0160, 0x202c, 0x2003, 0x0000,
+	0x080c, 0x6faa, 0x1108, 0x0005, 0x2021, 0x0260, 0x2001, 0x0141,
+	0x201c, 0xd3dc, 0x1168, 0x2001, 0x0109, 0x201c, 0x939c, 0x0048,
+	0x1160, 0x2001, 0x0111, 0x201c, 0x83ff, 0x1110, 0x8421, 0x1d70,
+	0x2001, 0x015d, 0x2003, 0x0000, 0x0005, 0x0046, 0x2021, 0x0019,
+	0x2003, 0x0048, 0xa001, 0xa001, 0x201c, 0x939c, 0x0048, 0x0120,
+	0x8421, 0x1db0, 0x004e, 0x0c60, 0x004e, 0x0c40, 0x601c, 0xc084,
+	0x601e, 0x0005, 0x2c08, 0x621c, 0x080c, 0x151a, 0x7930, 0x0005,
+	0x2c08, 0x621c, 0x080c, 0x15c5, 0x7930, 0x0005, 0x8001, 0x1df0,
+	0x0005, 0x2031, 0x0005, 0x781c, 0x9084, 0x0007, 0x0170, 0x2001,
+	0x0038, 0x0c41, 0x9186, 0x0040, 0x0904, 0x1a5f, 0x2001, 0x001e,
+	0x0c69, 0x8631, 0x1d80, 0x080c, 0x0db4, 0x781f, 0x0202, 0x2001,
+	0x015d, 0x2003, 0x0000, 0x2001, 0x0b10, 0x0c01, 0x781c, 0xd084,
+	0x0110, 0x0861, 0x04e0, 0x2001, 0x0030, 0x0891, 0x9186, 0x0040,
+	0x0568, 0x781c, 0xd084, 0x1da8, 0x781f, 0x0101, 0x2001, 0x0014,
+	0x0869, 0x2001, 0x0037, 0x0821, 0x9186, 0x0040, 0x0140, 0x2001,
+	0x0030, 0x080c, 0x19f8, 0x9186, 0x0040, 0x190c, 0x0db4, 0x00d6,
+	0x2069, 0x0200, 0x692c, 0xd1f4, 0x1170, 0xd1c4, 0x0160, 0xd19c,
+	0x0130, 0x6800, 0x9085, 0x1800, 0x6802, 0x00de, 0x0080, 0x6908,
+	0x9184, 0x0007, 0x1db0, 0x00de, 0x781f, 0x0100, 0x791c, 0x9184,
+	0x0007, 0x090c, 0x0db4, 0xa001, 0xa001, 0x781f, 0x0200, 0x0005,
+	0x0126, 0x2091, 0x2400, 0x2071, 0x1a3d, 0x2079, 0x0090, 0x012e,
+	0x0005, 0x9280, 0x0005, 0x2004, 0x2048, 0xa97c, 0xd1dc, 0x1904,
+	0x1af4, 0xa964, 0x9184, 0x0007, 0x0002, 0x1a7d, 0x1adf, 0x1a94,
+	0x1a94, 0x1a94, 0x1ac7, 0x1aa7, 0x1a96, 0x918c, 0x00ff, 0x9186,
+	0x0008, 0x1170, 0xa87c, 0xd0b4, 0x0904, 0x1d12, 0x9006, 0xa842,
+	0xa83e, 0xa988, 0x2900, 0xa85a, 0xa813, 0x1f2e, 0x0804, 0x1af0,
+	0x9186, 0x0048, 0x0904, 0x1adf, 0x080c, 0x0db4, 0xa87c, 0xd0b4,
+	0x0904, 0x1d12, 0xa890, 0xa842, 0xa83a, 0xa88c, 0xa83e, 0xa836,
+	0xa8ac, 0xa846, 0xa8b0, 0xa84a, 0xa988, 0x0804, 0x1ae7, 0xa864,
+	0x9084, 0x00ff, 0x9086, 0x001e, 0x1d38, 0xa87c, 0xd0b4, 0x0904,
+	0x1d12, 0xa890, 0xa842, 0xa83a, 0xa88c, 0xa83e, 0xa836, 0xa8ac,
+	0xa846, 0xa8b0, 0xa84a, 0xa804, 0xa85a, 0x2040, 0xa064, 0x9084,
+	0x000f, 0x9080, 0x1f33, 0x2005, 0xa812, 0xa988, 0x0448, 0x918c,
+	0x00ff, 0x9186, 0x0015, 0x1540, 0xa87c, 0xd0b4, 0x0904, 0x1d12,
+	0xa804, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x1f33,
+	0x2005, 0xa812, 0xa988, 0x9006, 0xa842, 0xa83e, 0x0088, 0xa87c,
+	0xd0b4, 0x0904, 0x1d12, 0xa988, 0x9006, 0xa842, 0xa83e, 0x2900,
+	0xa85a, 0xa864, 0x9084, 0x000f, 0x9080, 0x1f33, 0x2005, 0xa812,
+	0xa916, 0xa87c, 0xc0dd, 0xa87e, 0x0005, 0x00f6, 0x2079, 0x0090,
+	0x782c, 0xd0fc, 0x190c, 0x1d57, 0x00e6, 0x2071, 0x1a3d, 0x7000,
+	0x9005, 0x1904, 0x1b5d, 0x7206, 0x9280, 0x0005, 0x204c, 0x9280,
+	0x0004, 0x2004, 0x782b, 0x0004, 0x00f6, 0x2079, 0x0200, 0x7803,
+	0x0040, 0x00fe, 0x00b6, 0x2058, 0xb86c, 0x7836, 0xb890, 0x00be,
+	0x00f6, 0x2079, 0x0200, 0x7803, 0x0040, 0xa001, 0xa001, 0xa001,
+	0xa001, 0xa001, 0xa001, 0x781a, 0x2079, 0x0100, 0x8004, 0x78d6,
+	0x00fe, 0xa814, 0x2050, 0xa858, 0x2040, 0xa810, 0x2060, 0xa064,
+	0x90ec, 0x000f, 0xa944, 0x791a, 0x7116, 0xa848, 0x781e, 0x701a,
+	0x9006, 0x700e, 0x7012, 0x7004, 0xa940, 0xa838, 0x9106, 0x1500,
+	0xa93c, 0xa834, 0x9106, 0x11e0, 0x0006, 0x0016, 0xa938, 0xa834,
+	0x9105, 0x0118, 0x001e, 0x000e, 0x0098, 0x001e, 0x000e, 0x8aff,
+	0x01c8, 0x0126, 0x2091, 0x8000, 0x2009, 0x0306, 0x200b, 0x0808,
+	0x00d9, 0x0108, 0x00c9, 0x012e, 0x9006, 0x00ee, 0x00fe, 0x0005,
+	0x0036, 0x0046, 0xab38, 0xac34, 0x080c, 0x1f53, 0x004e, 0x003e,
+	0x0d30, 0x0c98, 0x9085, 0x0001, 0x0c80, 0x2009, 0x0306, 0x200b,
+	0x4800, 0x7027, 0x0000, 0x0005, 0x0076, 0x0066, 0x0056, 0x0046,
+	0x0036, 0x0026, 0x8aff, 0x0904, 0x1d0b, 0x700c, 0x7214, 0x923a,
+	0x7010, 0x7218, 0x9203, 0x0a04, 0x1d0a, 0x9705, 0x0904, 0x1d0a,
+	0x903e, 0x2730, 0xa880, 0xd0fc, 0x1190, 0x2d00, 0x0002, 0x1c9f,
+	0x1bdf, 0x1bdf, 0x1c9f, 0x1c9f, 0x1c7c, 0x1c9f, 0x1bdf, 0x1c83,
+	0x1c2e, 0x1c2e, 0x1c9f, 0x1c9f, 0x1c9f, 0x1c76, 0x1c2e, 0xc0fc,
+	0xa882, 0xab2c, 0xaa30, 0xad1c, 0xac20, 0xdd9c, 0x0904, 0x1ca1,
+	0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002,
+	0x1bcb, 0x1bc9, 0x1bc9, 0x1bc9, 0x1bc9, 0x1bc9, 0x1bcf, 0x1bc9,
+	0x1bc9, 0x1bc9, 0x1bc9, 0x1bc9, 0x1bd3, 0x1bc9, 0x1bc9, 0x1bc9,
+	0x1bc9, 0x1bc9, 0x1bd7, 0x1bc9, 0x1bc9, 0x1bc9, 0x1bc9, 0x1bc9,
+	0x1bdb, 0x080c, 0x0db4, 0xa774, 0xa678, 0x0804, 0x1ca1, 0xa78c,
+	0xa690, 0x0804, 0x1ca1, 0xa7a4, 0xa6a8, 0x0804, 0x1ca1, 0xa7bc,
+	0xa6c0, 0x0804, 0x1ca1, 0xa7d4, 0xa6d8, 0x0804, 0x1ca1, 0x2c05,
+	0x908a, 0x0036, 0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002, 0x1c02,
+	0x1c02, 0x1c04, 0x1c02, 0x1c02, 0x1c02, 0x1c0a, 0x1c02, 0x1c02,
+	0x1c02, 0x1c10, 0x1c02, 0x1c02, 0x1c02, 0x1c16, 0x1c02, 0x1c02,
+	0x1c02, 0x1c1c, 0x1c02, 0x1c02, 0x1c02, 0x1c22, 0x1c02, 0x1c02,
+	0x1c02, 0x1c28, 0x080c, 0x0db4, 0xa574, 0xa478, 0xa37c, 0xa280,
+	0x0804, 0x1ca1, 0xa584, 0xa488, 0xa38c, 0xa290, 0x0804, 0x1ca1,
+	0xa594, 0xa498, 0xa39c, 0xa2a0, 0x0804, 0x1ca1, 0xa5a4, 0xa4a8,
+	0xa3ac, 0xa2b0, 0x0804, 0x1ca1, 0xa5b4, 0xa4b8, 0xa3bc, 0xa2c0,
+	0x0804, 0x1ca1, 0xa5c4, 0xa4c8, 0xa3cc, 0xa2d0, 0x0804, 0x1ca1,
+	0xa5d4, 0xa4d8, 0xa3dc, 0xa2e0, 0x0804, 0x1ca1, 0x2c05, 0x908a,
+	0x0034, 0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002, 0x1c51, 0x1c4f,
+	0x1c4f, 0x1c4f, 0x1c4f, 0x1c4f, 0x1c59, 0x1c4f, 0x1c4f, 0x1c4f,
+	0x1c4f, 0x1c4f, 0x1c61, 0x1c4f, 0x1c4f, 0x1c4f, 0x1c4f, 0x1c4f,
+	0x1c68, 0x1c4f, 0x1c4f, 0x1c4f, 0x1c4f, 0x1c4f, 0x1c6f, 0x080c,
+	0x0db4, 0xa56c, 0xa470, 0xa774, 0xa678, 0xa37c, 0xa280, 0x0804,
+	0x1ca1, 0xa584, 0xa488, 0xa78c, 0xa690, 0xa394, 0xa298, 0x0804,
+	0x1ca1, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8, 0xa3ac, 0xa2b0, 0x04c8,
+	0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0, 0xa3c4, 0xa2c8, 0x0490, 0xa5cc,
+	0xa4d0, 0xa7d4, 0xa6d8, 0xa3dc, 0xa2e0, 0x0458, 0xa864, 0x9084,
+	0x00ff, 0x9086, 0x001e, 0x1518, 0x080c, 0x1eeb, 0x1904, 0x1b7a,
+	0x900e, 0x0804, 0x1d0b, 0xab64, 0x939c, 0x00ff, 0x9386, 0x0048,
+	0x1180, 0x00c6, 0x7004, 0x2060, 0x6004, 0x9086, 0x0043, 0x00ce,
+	0x0904, 0x1c2e, 0xab9c, 0x9016, 0xad8c, 0xac90, 0xaf94, 0xae98,
+	0x0040, 0x9386, 0x0008, 0x0904, 0x1c2e, 0x080c, 0x0db4, 0x080c,
+	0x0db4, 0x2009, 0x030f, 0x2104, 0xd0fc, 0x0530, 0x0066, 0x2009,
+	0x0306, 0x2104, 0x9084, 0x0030, 0x15c8, 0x2031, 0x1000, 0x200b,
+	0x4000, 0x2600, 0x9302, 0x928b, 0x0000, 0xa82e, 0xa932, 0x0278,
+	0x9105, 0x0168, 0x2011, 0x0000, 0x2618, 0x2600, 0x9500, 0xa81e,
+	0x9481, 0x0000, 0xa822, 0xa880, 0xc0fd, 0xa882, 0x0020, 0xa82f,
+	0x0000, 0xa833, 0x0000, 0x006e, 0x7b12, 0x7a16, 0x7d02, 0x7c06,
+	0x7f0a, 0x7e0e, 0x782b, 0x0001, 0x7000, 0x8000, 0x7002, 0xa83c,
+	0x9300, 0xa83e, 0xa840, 0x9201, 0xa842, 0x700c, 0x9300, 0x700e,
+	0x7010, 0x9201, 0x7012, 0x080c, 0x1eeb, 0x0428, 0x2031, 0x0080,
+	0x9584, 0x007f, 0x0108, 0x9632, 0x7124, 0x7000, 0x9086, 0x0000,
+	0x1198, 0xc185, 0x7126, 0x2009, 0x0306, 0x2104, 0xd0b4, 0x1904,
+	0x1cb1, 0x200b, 0x4040, 0x2009, 0x1a56, 0x2104, 0x8000, 0x0a04,
+	0x1cb1, 0x200a, 0x0804, 0x1cb1, 0xc18d, 0x7126, 0xd184, 0x1d58,
+	0x0804, 0x1cb1, 0x9006, 0x002e, 0x003e, 0x004e, 0x005e, 0x006e,
+	0x007e, 0x0005, 0x080c, 0x0db4, 0x0026, 0x2001, 0x0105, 0x2003,
+	0x0010, 0x782b, 0x0004, 0x7003, 0x0000, 0x7004, 0x0016, 0x080c,
+	0x1b6d, 0x001e, 0x2060, 0x6014, 0x2048, 0x080c, 0xbb3b, 0x0118,
+	0xa880, 0xc0bd, 0xa882, 0x6020, 0x9086, 0x0006, 0x1180, 0x2061,
+	0x0100, 0x62c8, 0x2001, 0x00fa, 0x8001, 0x1df0, 0x60c8, 0x9206,
+	0x1dc0, 0x60c4, 0xa89a, 0x60c8, 0xa896, 0x7004, 0x2060, 0x00c6,
+	0x080c, 0xb75c, 0x00ce, 0x2001, 0x19ce, 0x2004, 0x9c06, 0x1160,
+	0x2009, 0x0040, 0x080c, 0x2275, 0x080c, 0x98d4, 0x2011, 0x0000,
+	0x080c, 0x9765, 0x080c, 0x8a68, 0x002e, 0x0804, 0x1e9b, 0x0126,
+	0x2091, 0x2400, 0xa858, 0x2040, 0x792c, 0x782b, 0x0002, 0x9184,
+	0x0700, 0x1904, 0x1d14, 0x7000, 0x0002, 0x1e9b, 0x1d69, 0x1de9,
+	0x1e99, 0x8001, 0x7002, 0x7027, 0x0000, 0xd19c, 0x1158, 0x8aff,
+	0x0904, 0x1db6, 0x080c, 0x1b74, 0x0904, 0x1e9b, 0x080c, 0x1b74,
+	0x0804, 0x1e9b, 0x782b, 0x0004, 0xd194, 0x0148, 0xa880, 0xc0fc,
+	0xa882, 0x8aff, 0x1518, 0xa87c, 0xc0f5, 0xa87e, 0x00f8, 0x0026,
+	0x0036, 0xab3c, 0xaa40, 0x0016, 0x7910, 0xa82c, 0x9100, 0xa82e,
+	0x7914, 0xa830, 0x9101, 0xa832, 0x001e, 0x7810, 0x931a, 0x7814,
+	0x9213, 0x7800, 0xa81e, 0x7804, 0xa822, 0xab3e, 0xaa42, 0x003e,
+	0x002e, 0x080c, 0x1f06, 0xa880, 0xc0fd, 0xa882, 0x2a00, 0xa816,
+	0x2800, 0xa85a, 0x2c00, 0xa812, 0x7003, 0x0000, 0x2009, 0x0306,
+	0x200b, 0x4800, 0x7027, 0x0000, 0x0804, 0x1e9b, 0x00f6, 0x0026,
+	0x781c, 0x0006, 0x7818, 0x0006, 0x2079, 0x0100, 0x7a14, 0x9284,
+	0x1984, 0x9085, 0x0012, 0x7816, 0x0036, 0x2019, 0x1000, 0x8319,
+	0x090c, 0x0db4, 0x7820, 0xd0bc, 0x1dd0, 0x003e, 0x79c8, 0x000e,
+	0x9102, 0x001e, 0x0006, 0x0016, 0x79c4, 0x000e, 0x9103, 0x78c6,
+	0x000e, 0x78ca, 0x9284, 0x1984, 0x9085, 0x0012, 0x7816, 0x002e,
+	0x00fe, 0x782b, 0x0008, 0x7003, 0x0000, 0x080c, 0x1b6d, 0x0804,
+	0x1e9b, 0x8001, 0x7002, 0x7024, 0x8004, 0x7026, 0xd194, 0x0170,
+	0x782c, 0xd0fc, 0x1904, 0x1d5c, 0xd19c, 0x1904, 0x1e97, 0x8aff,
+	0x0904, 0x1e9b, 0x080c, 0x1b74, 0x0804, 0x1e9b, 0x0026, 0x0036,
+	0xab3c, 0xaa40, 0x080c, 0x1f06, 0xdd9c, 0x1904, 0x1e56, 0x2c05,
+	0x908a, 0x0036, 0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002, 0x1e2a,
+	0x1e2a, 0x1e2c, 0x1e2a, 0x1e2a, 0x1e2a, 0x1e32, 0x1e2a, 0x1e2a,
+	0x1e2a, 0x1e38, 0x1e2a, 0x1e2a, 0x1e2a, 0x1e3e, 0x1e2a, 0x1e2a,
+	0x1e2a, 0x1e44, 0x1e2a, 0x1e2a, 0x1e2a, 0x1e4a, 0x1e2a, 0x1e2a,
+	0x1e2a, 0x1e50, 0x080c, 0x0db4, 0xa07c, 0x931a, 0xa080, 0x9213,
+	0x0804, 0x1d8b, 0xa08c, 0x931a, 0xa090, 0x9213, 0x0804, 0x1d8b,
+	0xa09c, 0x931a, 0xa0a0, 0x9213, 0x0804, 0x1d8b, 0xa0ac, 0x931a,
+	0xa0b0, 0x9213, 0x0804, 0x1d8b, 0xa0bc, 0x931a, 0xa0c0, 0x9213,
+	0x0804, 0x1d8b, 0xa0cc, 0x931a, 0xa0d0, 0x9213, 0x0804, 0x1d8b,
+	0xa0dc, 0x931a, 0xa0e0, 0x9213, 0x0804, 0x1d8b, 0x2c05, 0x908a,
+	0x0034, 0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002, 0x1e79, 0x1e77,
+	0x1e77, 0x1e77, 0x1e77, 0x1e77, 0x1e7f, 0x1e77, 0x1e77, 0x1e77,
+	0x1e77, 0x1e77, 0x1e85, 0x1e77, 0x1e77, 0x1e77, 0x1e77, 0x1e77,
+	0x1e8b, 0x1e77, 0x1e77, 0x1e77, 0x1e77, 0x1e77, 0x1e91, 0x080c,
+	0x0db4, 0xa07c, 0x931a, 0xa080, 0x9213, 0x0804, 0x1d8b, 0xa094,
+	0x931a, 0xa098, 0x9213, 0x0804, 0x1d8b, 0xa0ac, 0x931a, 0xa0b0,
+	0x9213, 0x0804, 0x1d8b, 0xa0c4, 0x931a, 0xa0c8, 0x9213, 0x0804,
+	0x1d8b, 0xa0dc, 0x931a, 0xa0e0, 0x9213, 0x0804, 0x1d8b, 0x0804,
+	0x1d87, 0x080c, 0x0db4, 0x012e, 0x0005, 0x00f6, 0x00e6, 0x2071,
+	0x1a3d, 0x7000, 0x9086, 0x0000, 0x0904, 0x1ee6, 0x2079, 0x0090,
+	0x2009, 0x0207, 0x210c, 0xd194, 0x01b8, 0x2009, 0x020c, 0x210c,
+	0x9184, 0x0003, 0x0188, 0x080c, 0xd90f, 0x2001, 0x0133, 0x2004,
+	0x9005, 0x090c, 0x0db4, 0x0016, 0x2009, 0x0040, 0x080c, 0x2275,
+	0x001e, 0x2001, 0x020c, 0x2102, 0x2009, 0x0206, 0x2104, 0x2009,
+	0x0203, 0x210c, 0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x2275,
+	0x782c, 0xd0fc, 0x09a8, 0x080c, 0x1d57, 0x7000, 0x9086, 0x0000,
+	0x1978, 0x782b, 0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040,
+	0x080c, 0x2275, 0x782b, 0x0002, 0x7003, 0x0000, 0x080c, 0x1b6d,
+	0x00ee, 0x00fe, 0x0005, 0xa880, 0xd0fc, 0x11a8, 0x8c60, 0x2c05,
+	0x9005, 0x0110, 0x8a51, 0x0005, 0xa004, 0x9005, 0x0168, 0xa85a,
+	0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x1f33, 0x2065, 0x8cff,
+	0x090c, 0x0db4, 0x8a51, 0x0005, 0x2050, 0x0005, 0xa880, 0xd0fc,
+	0x11b8, 0x8a50, 0x8c61, 0x2c05, 0x9005, 0x1190, 0x2800, 0x9906,
+	0x0120, 0xa000, 0x9005, 0x1108, 0x2900, 0x2040, 0xa85a, 0xa064,
+	0x9084, 0x000f, 0x9080, 0x1f43, 0x2065, 0x8cff, 0x090c, 0x0db4,
+	0x0005, 0x0000, 0x001d, 0x0021, 0x0025, 0x0029, 0x002d, 0x0031,
+	0x0035, 0x0000, 0x001b, 0x0021, 0x0027, 0x002d, 0x0033, 0x0000,
+	0x0000, 0x0023, 0x0000, 0x0000, 0x1f26, 0x1f22, 0x0000, 0x0000,
+	0x1f30, 0x0000, 0x1f26, 0x1f2d, 0x1f2d, 0x1f2a, 0x0000, 0x0000,
+	0x0000, 0x1f30, 0x1f2d, 0x0000, 0x1f28, 0x1f28, 0x0000, 0x0000,
+	0x1f30, 0x0000, 0x1f28, 0x1f2e, 0x1f2e, 0x1f2e, 0x0000, 0x0000,
+	0x0000, 0x1f30, 0x1f2e, 0x00c6, 0x00d6, 0x0086, 0xab42, 0xac3e,
+	0xa888, 0x9055, 0x0904, 0x2132, 0x2940, 0xa064, 0x90ec, 0x000f,
+	0x9084, 0x00ff, 0x9086, 0x0008, 0x1118, 0x2061, 0x1f2e, 0x00d0,
+	0x9de0, 0x1f33, 0x9d86, 0x0007, 0x0130, 0x9d86, 0x000e, 0x0118,
+	0x9d86, 0x000f, 0x1120, 0xa08c, 0x9422, 0xa090, 0x931b, 0x2c05,
+	0x9065, 0x1140, 0x0310, 0x0804, 0x2132, 0xa004, 0x9045, 0x0904,
+	0x2132, 0x08d8, 0x2c05, 0x9005, 0x0904, 0x201a, 0xdd9c, 0x1904,
+	0x1fd6, 0x908a, 0x0036, 0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002,
+	0x1fab, 0x1fab, 0x1fad, 0x1fab, 0x1fab, 0x1fab, 0x1fb3, 0x1fab,
+	0x1fab, 0x1fab, 0x1fb9, 0x1fab, 0x1fab, 0x1fab, 0x1fbf, 0x1fab,
+	0x1fab, 0x1fab, 0x1fc5, 0x1fab, 0x1fab, 0x1fab, 0x1fcb, 0x1fab,
+	0x1fab, 0x1fab, 0x1fd1, 0x080c, 0x0db4, 0xa07c, 0x9422, 0xa080,
+	0x931b, 0x0804, 0x2010, 0xa08c, 0x9422, 0xa090, 0x931b, 0x0804,
+	0x2010, 0xa09c, 0x9422, 0xa0a0, 0x931b, 0x0804, 0x2010, 0xa0ac,
+	0x9422, 0xa0b0, 0x931b, 0x0804, 0x2010, 0xa0bc, 0x9422, 0xa0c0,
+	0x931b, 0x0804, 0x2010, 0xa0cc, 0x9422, 0xa0d0, 0x931b, 0x0804,
+	0x2010, 0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x04d0, 0x908a, 0x0034,
+	0x1a0c, 0x0db4, 0x9082, 0x001b, 0x0002, 0x1ff8, 0x1ff6, 0x1ff6,
+	0x1ff6, 0x1ff6, 0x1ff6, 0x1ffd, 0x1ff6, 0x1ff6, 0x1ff6, 0x1ff6,
+	0x1ff6, 0x2002, 0x1ff6, 0x1ff6, 0x1ff6, 0x1ff6, 0x1ff6, 0x2007,
+	0x1ff6, 0x1ff6, 0x1ff6, 0x1ff6, 0x1ff6, 0x200c, 0x080c, 0x0db4,
+	0xa07c, 0x9422, 0xa080, 0x931b, 0x0098, 0xa094, 0x9422, 0xa098,
+	0x931b, 0x0070, 0xa0ac, 0x9422, 0xa0b0, 0x931b, 0x0048, 0xa0c4,
+	0x9422, 0xa0c8, 0x931b, 0x0020, 0xa0dc, 0x9422, 0xa0e0, 0x931b,
+	0x0630, 0x2300, 0x9405, 0x0160, 0x8a51, 0x0904, 0x2132, 0x8c60,
+	0x0804, 0x1f82, 0xa004, 0x9045, 0x0904, 0x2132, 0x0804, 0x1f5d,
+	0x8a51, 0x0904, 0x2132, 0x8c60, 0x2c05, 0x9005, 0x1158, 0xa004,
+	0x9045, 0x0904, 0x2132, 0xa064, 0x90ec, 0x000f, 0x9de0, 0x1f33,
+	0x2c05, 0x2060, 0xa880, 0xc0fc, 0xa882, 0x0804, 0x2127, 0x2c05,
+	0x8422, 0x8420, 0x831a, 0x9399, 0x0000, 0xac2e, 0xab32, 0xdd9c,
+	0x1904, 0x20c4, 0x9082, 0x001b, 0x0002, 0x2060, 0x2060, 0x2062,
+	0x2060, 0x2060, 0x2060, 0x2070, 0x2060, 0x2060, 0x2060, 0x207e,
+	0x2060, 0x2060, 0x2060, 0x208c, 0x2060, 0x2060, 0x2060, 0x209a,
+	0x2060, 0x2060, 0x2060, 0x20a8, 0x2060, 0x2060, 0x2060, 0x20b6,
+	0x080c, 0x0db4, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300, 0x911b,
+	0x0a0c, 0x0db4, 0xa074, 0x9420, 0xa078, 0x9319, 0x0804, 0x2122,
+	0xa18c, 0x2400, 0x9122, 0xa190, 0x2300, 0x911b, 0x0a0c, 0x0db4,
+	0xa084, 0x9420, 0xa088, 0x9319, 0x0804, 0x2122, 0xa19c, 0x2400,
+	0x9122, 0xa1a0, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa094, 0x9420,
+	0xa098, 0x9319, 0x0804, 0x2122, 0xa1ac, 0x2400, 0x9122, 0xa1b0,
+	0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa0a4, 0x9420, 0xa0a8, 0x9319,
+	0x0804, 0x2122, 0xa1bc, 0x2400, 0x9122, 0xa1c0, 0x2300, 0x911b,
+	0x0a0c, 0x0db4, 0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0804, 0x2122,
+	0xa1cc, 0x2400, 0x9122, 0xa1d0, 0x2300, 0x911b, 0x0a0c, 0x0db4,
+	0xa0c4, 0x9420, 0xa0c8, 0x9319, 0x0804, 0x2122, 0xa1dc, 0x2400,
+	0x9122, 0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa0d4, 0x9420,
+	0xa0d8, 0x9319, 0x0804, 0x2122, 0x9082, 0x001b, 0x0002, 0x20e2,
+	0x20e0, 0x20e0, 0x20e0, 0x20e0, 0x20e0, 0x20ef, 0x20e0, 0x20e0,
+	0x20e0, 0x20e0, 0x20e0, 0x20fc, 0x20e0, 0x20e0, 0x20e0, 0x20e0,
+	0x20e0, 0x2109, 0x20e0, 0x20e0, 0x20e0, 0x20e0, 0x20e0, 0x2116,
+	0x080c, 0x0db4, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300, 0x911b,
+	0x0a0c, 0x0db4, 0xa06c, 0x9420, 0xa070, 0x9319, 0x0498, 0xa194,
+	0x2400, 0x9122, 0xa198, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa084,
+	0x9420, 0xa088, 0x9319, 0x0430, 0xa1ac, 0x2400, 0x9122, 0xa1b0,
+	0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa09c, 0x9420, 0xa0a0, 0x9319,
+	0x00c8, 0xa1c4, 0x2400, 0x9122, 0xa1c8, 0x2300, 0x911b, 0x0a0c,
+	0x0db4, 0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0060, 0xa1dc, 0x2400,
+	0x9122, 0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0db4, 0xa0cc, 0x9420,
+	0xa0d0, 0x9319, 0xac1e, 0xab22, 0xa880, 0xc0fd, 0xa882, 0x2800,
+	0xa85a, 0x2c00, 0xa812, 0x2a00, 0xa816, 0x000e, 0x000e, 0x000e,
+	0x9006, 0x0028, 0x008e, 0x00de, 0x00ce, 0x9085, 0x0001, 0x0005,
+	0x2001, 0x0005, 0x2004, 0xd0bc, 0x190c, 0x0dad, 0x9084, 0x0007,
+	0x0002, 0x2153, 0x1d57, 0x2153, 0x2149, 0x214c, 0x214f, 0x214c,
+	0x214f, 0x080c, 0x1d57, 0x0005, 0x080c, 0x118f, 0x0005, 0x080c,
+	0x1d57, 0x080c, 0x118f, 0x0005, 0x0126, 0x2091, 0x2600, 0x2079,
+	0x0200, 0x2071, 0x0260, 0x2069, 0x1800, 0x7817, 0x0000, 0x789b,
+	0x0814, 0x78a3, 0x0406, 0x789f, 0x0410, 0x2009, 0x013b, 0x200b,
+	0x0400, 0x781b, 0x0002, 0x783b, 0x001f, 0x7837, 0x0020, 0x7803,
+	0x1600, 0x012e, 0x0005, 0x2091, 0x2600, 0x781c, 0xd0a4, 0x190c,
+	0x2272, 0x7900, 0xd1dc, 0x1118, 0x9084, 0x0006, 0x001a, 0x9084,
+	0x000e, 0x0002, 0x219a, 0x2192, 0x7945, 0x2192, 0x2194, 0x2194,
+	0x2194, 0x2194, 0x792b, 0x2192, 0x2196, 0x2192, 0x2194, 0x2192,
+	0x2194, 0x2192, 0x080c, 0x0db4, 0x0031, 0x0020, 0x080c, 0x792b,
+	0x080c, 0x7945, 0x0005, 0x0006, 0x0016, 0x0026, 0x080c, 0xd90f,
+	0x7930, 0x9184, 0x0003, 0x01c0, 0x2001, 0x19ce, 0x2004, 0x9005,
+	0x0170, 0x2001, 0x0133, 0x2004, 0x9005, 0x090c, 0x0db4, 0x00c6,
+	0x2001, 0x19ce, 0x2064, 0x080c, 0xb75c, 0x00ce, 0x00f8, 0x2009,
+	0x0040, 0x080c, 0x2275, 0x00d0, 0x9184, 0x0014, 0x01a0, 0x6a00,
+	0x9286, 0x0003, 0x0160, 0x080c, 0x6faa, 0x1138, 0x080c, 0x728c,
+	0x080c, 0x5ce5, 0x080c, 0x6edc, 0x0010, 0x080c, 0x5ba4, 0x080c,
+	0x79f4, 0x0041, 0x0018, 0x9184, 0x9540, 0x1dc8, 0x002e, 0x001e,
+	0x000e, 0x0005, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a3a,
+	0x080c, 0x196a, 0x005e, 0x004e, 0x003e, 0x00ee, 0x0005, 0x0126,
+	0x2091, 0x2e00, 0x2071, 0x1800, 0x7128, 0x2001, 0x1947, 0x2102,
+	0x2001, 0x194f, 0x2102, 0x2001, 0x013b, 0x2102, 0x2079, 0x0200,
+	0x2001, 0x0201, 0x789e, 0x78a3, 0x0200, 0x9198, 0x0007, 0x831c,
+	0x831c, 0x831c, 0x9398, 0x0005, 0x2320, 0x9182, 0x0204, 0x1230,
+	0x2011, 0x0008, 0x8423, 0x8423, 0x8423, 0x0488, 0x9182, 0x024c,
+	0x1240, 0x2011, 0x0007, 0x8403, 0x8003, 0x9400, 0x9400, 0x9420,
+	0x0430, 0x9182, 0x02bc, 0x1238, 0x2011, 0x0006, 0x8403, 0x8003,
+	0x9400, 0x9420, 0x00e0, 0x9182, 0x034c, 0x1230, 0x2011, 0x0005,
+	0x8403, 0x8003, 0x9420, 0x0098, 0x9182, 0x042c, 0x1228, 0x2011,
+	0x0004, 0x8423, 0x8423, 0x0058, 0x9182, 0x059c, 0x1228, 0x2011,
+	0x0003, 0x8403, 0x9420, 0x0018, 0x2011, 0x0002, 0x8423, 0x9482,
+	0x0228, 0x8002, 0x8020, 0x8301, 0x9402, 0x0110, 0x0208, 0x8321,
+	0x8217, 0x8203, 0x9405, 0x789a, 0x012e, 0x0005, 0x0006, 0x00d6,
+	0x2069, 0x0200, 0x6814, 0x9084, 0xffc0, 0x910d, 0x6916, 0x00de,
+	0x000e, 0x0005, 0x00d6, 0x2069, 0x0200, 0x9005, 0x6810, 0x0110,
+	0xc0a5, 0x0008, 0xc0a4, 0x6812, 0x00de, 0x0005, 0x0006, 0x00d6,
+	0x2069, 0x0200, 0x6810, 0x9084, 0xfff8, 0x910d, 0x6912, 0x00de,
+	0x000e, 0x0005, 0x7938, 0x080c, 0x0dad, 0x00f6, 0x2079, 0x0200,
+	0x7902, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x7902,
+	0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x00fe, 0x0005,
+	0x0126, 0x2091, 0x2800, 0x2061, 0x0100, 0x2071, 0x1800, 0x2009,
+	0x0000, 0x080c, 0x2a70, 0x080c, 0x298b, 0x6054, 0x8004, 0x8004,
+	0x8004, 0x8004, 0x9084, 0x000c, 0x6150, 0x918c, 0xfff3, 0x9105,
+	0x6052, 0x6050, 0x9084, 0xb17f, 0x9085, 0x2000, 0x6052, 0x2009,
+	0x1975, 0x2011, 0x1976, 0x6358, 0x939c, 0x38f0, 0x2320, 0x080c,
+	0x29cf, 0x1238, 0x939d, 0x4003, 0x94a5, 0x8603, 0x230a, 0x2412,
+	0x0030, 0x939d, 0x0203, 0x94a5, 0x8603, 0x230a, 0x2412, 0x9006,
+	0x080c, 0x29ba, 0x9006, 0x080c, 0x299d, 0x20a9, 0x0012, 0x1d04,
+	0x22c7, 0x2091, 0x6000, 0x1f04, 0x22c7, 0x602f, 0x0100, 0x602f,
+	0x0000, 0x6050, 0x9085, 0x0400, 0x9084, 0xdfff, 0x6052, 0x6024,
+	0x6026, 0x080c, 0x26a9, 0x2009, 0x00ef, 0x6132, 0x6136, 0x080c,
+	0x26b9, 0x60e7, 0x0000, 0x61ea, 0x60e3, 0x0002, 0x604b, 0xf7f7,
+	0x6043, 0x0000, 0x602f, 0x0080, 0x602f, 0x0000, 0x6007, 0x149f,
+	0x60bb, 0x0000, 0x20a9, 0x0018, 0x60bf, 0x0000, 0x1f04, 0x22f4,
+	0x60bb, 0x0000, 0x60bf, 0x0108, 0x60bf, 0x0012, 0x60bf, 0x0320,
+	0x60bf, 0x0018, 0x601b, 0x00f0, 0x601f, 0x001e, 0x600f, 0x006b,
+	0x602b, 0x402f, 0x012e, 0x0005, 0x00f6, 0x2079, 0x0140, 0x78c3,
+	0x0080, 0x78c3, 0x0083, 0x78c3, 0x0000, 0x00fe, 0x0005, 0x2001,
+	0x1834, 0x2003, 0x0000, 0x2001, 0x1833, 0x2003, 0x0001, 0x0005,
+	0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x6124, 0x9184,
+	0x5e2c, 0x1118, 0x9184, 0x0007, 0x002a, 0x9195, 0x0004, 0x9284,
+	0x0007, 0x0002, 0x2354, 0x233a, 0x233d, 0x2340, 0x2345, 0x2347,
+	0x234b, 0x234f, 0x080c, 0x82e4, 0x00b8, 0x080c, 0x83b1, 0x00a0,
+	0x080c, 0x83b1, 0x080c, 0x82e4, 0x0078, 0x0099, 0x0068, 0x080c,
+	0x82e4, 0x0079, 0x0048, 0x080c, 0x83b1, 0x0059, 0x0028, 0x080c,
+	0x83b1, 0x080c, 0x82e4, 0x0029, 0x002e, 0x001e, 0x000e, 0x012e,
+	0x0005, 0x00a6, 0x6124, 0x6028, 0xd09c, 0x0118, 0xd19c, 0x1904,
+	0x25a2, 0xd1f4, 0x190c, 0x0dad, 0x080c, 0x6faa, 0x0904, 0x23af,
+	0x080c, 0xc23b, 0x1120, 0x7000, 0x9086, 0x0003, 0x0570, 0x6024,
+	0x9084, 0x1800, 0x0550, 0x080c, 0x6fcd, 0x0118, 0x080c, 0x6fbb,
+	0x1520, 0x6027, 0x0020, 0x6043, 0x0000, 0x080c, 0xc23b, 0x0168,
+	0x080c, 0x6fcd, 0x1150, 0x2001, 0x197f, 0x2003, 0x0001, 0x6027,
+	0x1800, 0x080c, 0x6e2b, 0x0804, 0x25a5, 0x70a0, 0x9005, 0x1150,
+	0x70a3, 0x0001, 0x00d6, 0x2069, 0x0140, 0x080c, 0x7001, 0x00de,
+	0x1904, 0x25a5, 0x080c, 0x7296, 0x0428, 0x080c, 0x6fcd, 0x1590,
+	0x6024, 0x9084, 0x1800, 0x1108, 0x0468, 0x080c, 0x7296, 0x080c,
+	0x728c, 0x080c, 0x5ce5, 0x080c, 0x6edc, 0x0804, 0x25a2, 0xd1ac,
+	0x1508, 0x6024, 0xd0dc, 0x1170, 0xd0e4, 0x1178, 0xd0d4, 0x1190,
+	0xd0cc, 0x0130, 0x7094, 0x9086, 0x0028, 0x1110, 0x080c, 0x717b,
+	0x0804, 0x25a2, 0x080c, 0x7291, 0x0048, 0x2001, 0x1955, 0x2003,
+	0x0002, 0x0020, 0x080c, 0x70e1, 0x0804, 0x25a2, 0x080c, 0x7215,
+	0x0804, 0x25a2, 0xd1ac, 0x0904, 0x24c3, 0x080c, 0x6faa, 0x11c0,
+	0x6027, 0x0020, 0x0006, 0x0026, 0x0036, 0x080c, 0x6fc4, 0x1158,
+	0x080c, 0x728c, 0x080c, 0x5ce5, 0x080c, 0x6edc, 0x003e, 0x002e,
+	0x000e, 0x00ae, 0x0005, 0x003e, 0x002e, 0x000e, 0x080c, 0x6f82,
+	0x0016, 0x0046, 0x00c6, 0x644c, 0x9486, 0xf0f0, 0x1138, 0x2061,
+	0x0100, 0x644a, 0x6043, 0x0090, 0x6043, 0x0010, 0x74d6, 0x948c,
+	0xff00, 0x7038, 0xd084, 0x0178, 0x9186, 0xf800, 0x1160, 0x7044,
+	0xd084, 0x1148, 0xc085, 0x7046, 0x0036, 0x2418, 0x2011, 0x8016,
+	0x080c, 0x48f4, 0x003e, 0x080c, 0xc234, 0x1904, 0x24a0, 0x9196,
+	0xff00, 0x05a8, 0x705c, 0x9084, 0x00ff, 0x810f, 0x81ff, 0x0110,
+	0x9116, 0x0568, 0x7130, 0xd184, 0x1550, 0x080c, 0x3140, 0x0128,
+	0xc18d, 0x7132, 0x080c, 0x6572, 0x1510, 0x6240, 0x9294, 0x0010,
+	0x0130, 0x6248, 0x9294, 0xff00, 0x9296, 0xff00, 0x01c0, 0x7030,
+	0xd08c, 0x0904, 0x24a0, 0x7038, 0xd08c, 0x1140, 0x2001, 0x180c,
+	0x200c, 0xd1ac, 0x1904, 0x24a0, 0xc1ad, 0x2102, 0x0036, 0x73d4,
+	0x2011, 0x8013, 0x080c, 0x48f4, 0x003e, 0x0804, 0x24a0, 0x7038,
+	0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904, 0x24a0,
+	0xc1ad, 0x2102, 0x0036, 0x73d4, 0x2011, 0x8013, 0x080c, 0x48f4,
+	0x003e, 0x7130, 0xc185, 0x7132, 0x2011, 0x185c, 0x220c, 0x00f0,
+	0x0016, 0x2009, 0x0001, 0x2011, 0x0100, 0x080c, 0x8236, 0x2019,
+	0x000e, 0x00c6, 0x2061, 0x0000, 0x080c, 0xd4e0, 0x00ce, 0x9484,
+	0x00ff, 0x9080, 0x3145, 0x200d, 0x918c, 0xff00, 0x810f, 0x2120,
+	0x9006, 0x2009, 0x000e, 0x080c, 0xd564, 0x001e, 0xd1ac, 0x1148,
+	0x0016, 0x2009, 0x0002, 0x2019, 0x0004, 0x080c, 0x2fb2, 0x001e,
+	0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x6256,
+	0x1110, 0x080c, 0x5cff, 0x8108, 0x1f04, 0x2496, 0x00be, 0x015e,
+	0x00ce, 0x004e, 0x080c, 0x9db5, 0x60e3, 0x0000, 0x001e, 0x2001,
+	0x1800, 0x2014, 0x9296, 0x0004, 0x1170, 0xd19c, 0x11a0, 0x2011,
+	0x180c, 0x2214, 0xd29c, 0x1120, 0x6204, 0x9295, 0x0002, 0x6206,
+	0x6228, 0xc29d, 0x622a, 0x2003, 0x0001, 0x2001, 0x1825, 0x2003,
+	0x0000, 0x6027, 0x0020, 0xd194, 0x0904, 0x25a2, 0x0016, 0x6220,
+	0xd2b4, 0x0904, 0x254b, 0x080c, 0x80bf, 0x080c, 0x93c7, 0x6027,
+	0x0004, 0x00f6, 0x2019, 0x19c8, 0x2304, 0x907d, 0x0904, 0x251a,
+	0x7804, 0x9086, 0x0032, 0x15f0, 0x00d6, 0x00c6, 0x00e6, 0x0096,
+	0x2069, 0x0140, 0x782c, 0x685e, 0x7808, 0x685a, 0x6043, 0x0002,
+	0x2001, 0x0003, 0x8001, 0x1df0, 0x6043, 0x0000, 0x2001, 0x003c,
+	0x8001, 0x1df0, 0x080c, 0x2b31, 0x2001, 0x001e, 0x8001, 0x0240,
+	0x20a9, 0x0009, 0x080c, 0x2a4b, 0x6904, 0xd1dc, 0x1140, 0x0cb0,
+	0x2001, 0x0100, 0x080c, 0x2b21, 0x9006, 0x080c, 0x2b21, 0x080c,
+	0x887f, 0x080c, 0x898b, 0x7814, 0x2048, 0xa867, 0x0103, 0x2f60,
+	0x080c, 0x9e2f, 0x009e, 0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e,
+	0x00ae, 0x0005, 0x00fe, 0x00d6, 0x2069, 0x0140, 0x6804, 0x9084,
+	0x4000, 0x0110, 0x080c, 0x2b31, 0x00de, 0x00c6, 0x2061, 0x19bf,
+	0x6028, 0x080c, 0xc23b, 0x0120, 0x909a, 0x0003, 0x1258, 0x0018,
+	0x909a, 0x00c8, 0x1238, 0x8000, 0x602a, 0x00ce, 0x080c, 0x93a3,
+	0x0804, 0x25a1, 0x2061, 0x0100, 0x62c0, 0x080c, 0x9c3b, 0x2019,
+	0x19c8, 0x2304, 0x9065, 0x0120, 0x2009, 0x0027, 0x080c, 0x9ea9,
+	0x00ce, 0x0804, 0x25a1, 0xd2bc, 0x0904, 0x258e, 0x080c, 0x80cc,
+	0x6014, 0x9084, 0x1984, 0x9085, 0x0010, 0x6016, 0x6027, 0x0004,
 	0x00d6, 0x2069, 0x0140, 0x6804, 0x9084, 0x4000, 0x0110, 0x080c,
-	0x2b26, 0x00de, 0x00c6, 0x2061, 0x19b7, 0x6028, 0x080c, 0xc22c,
-	0x0120, 0x909a, 0x0003, 0x1258, 0x0018, 0x909a, 0x00c8, 0x1238,
-	0x8000, 0x602a, 0x00ce, 0x080c, 0x9389, 0x0804, 0x2596, 0x2061,
-	0x0100, 0x62c0, 0x080c, 0x9c4e, 0x2019, 0x19c0, 0x2304, 0x9065,
-	0x0120, 0x2009, 0x0027, 0x080c, 0x9ebc, 0x00ce, 0x0804, 0x2596,
-	0xd2bc, 0x0904, 0x2583, 0x080c, 0x80ae, 0x6014, 0x9084, 0x1984,
-	0x9085, 0x0010, 0x6016, 0x6027, 0x0004, 0x00d6, 0x2069, 0x0140,
-	0x6804, 0x9084, 0x4000, 0x0110, 0x080c, 0x2b26, 0x00de, 0x00c6,
-	0x2061, 0x19b7, 0x6044, 0x080c, 0xc22c, 0x0120, 0x909a, 0x0003,
-	0x1628, 0x0018, 0x909a, 0x00c8, 0x1608, 0x8000, 0x6046, 0x603c,
-	0x00ce, 0x9005, 0x0558, 0x2009, 0x07d0, 0x080c, 0x80a6, 0x9080,
-	0x0008, 0x2004, 0x9086, 0x0006, 0x1138, 0x6114, 0x918c, 0x1984,
-	0x918d, 0x0012, 0x6116, 0x00d0, 0x6114, 0x918c, 0x1984, 0x918d,
-	0x0016, 0x6116, 0x0098, 0x6027, 0x0004, 0x0080, 0x0036, 0x2019,
-	0x0001, 0x080c, 0x96d9, 0x003e, 0x2019, 0x19c6, 0x2304, 0x9065,
-	0x0120, 0x2009, 0x004f, 0x080c, 0x9ebc, 0x00ce, 0x001e, 0xd19c,
-	0x0904, 0x2609, 0x7038, 0xd0ac, 0x1904, 0x25de, 0x0016, 0x0156,
-	0x6027, 0x0008, 0x6050, 0x9085, 0x0040, 0x6052, 0x6050, 0x9084,
-	0xfbcf, 0x6052, 0x080c, 0x2a5f, 0x9085, 0x2000, 0x6052, 0x20a9,
-	0x0012, 0x1d04, 0x25b1, 0x080c, 0x80d5, 0x1f04, 0x25b1, 0x6050,
-	0x9085, 0x0400, 0x9084, 0xdfbf, 0x6052, 0x20a9, 0x0028, 0xa001,
-	0x1f04, 0x25bf, 0x6150, 0x9185, 0x1400, 0x6052, 0x20a9, 0x0366,
-	0x1d04, 0x25c8, 0x080c, 0x80d5, 0x6020, 0xd09c, 0x1130, 0x015e,
-	0x6152, 0x001e, 0x6027, 0x0008, 0x04a0, 0x080c, 0x2a27, 0x1f04,
-	0x25c8, 0x015e, 0x6152, 0x001e, 0x6027, 0x0008, 0x0016, 0x6028,
-	0xc09c, 0x602a, 0x080c, 0x9dc8, 0x60e3, 0x0000, 0x080c, 0xd8d5,
-	0x080c, 0xd8f0, 0x080c, 0x5393, 0xd0fc, 0x1138, 0x080c, 0xc225,
-	0x1120, 0x9085, 0x0001, 0x080c, 0x6fe2, 0x9006, 0x080c, 0x2b16,
-	0x2009, 0x0002, 0x080c, 0x2a65, 0x00e6, 0x2071, 0x1800, 0x7003,
-	0x0004, 0x080c, 0x0e80, 0x00ee, 0x6027, 0x0008, 0x080c, 0x0b8f,
-	0x001e, 0x918c, 0xffd0, 0x6126, 0x00ae, 0x0005, 0x0006, 0x0016,
-	0x0026, 0x0036, 0x00e6, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x1800, 0x71cc, 0x70ce, 0x9116, 0x0904, 0x265d, 0x81ff, 0x01a0,
-	0x2009, 0x0000, 0x080c, 0x2a65, 0x2011, 0x8011, 0x2019, 0x010e,
-	0x231c, 0x939e, 0x0007, 0x1118, 0x2019, 0x0001, 0x0010, 0x2019,
-	0x0000, 0x080c, 0x48e9, 0x0448, 0x2001, 0x1978, 0x200c, 0x81ff,
-	0x1140, 0x2001, 0x0109, 0x2004, 0xd0b4, 0x0118, 0x2019, 0x0003,
-	0x0008, 0x2118, 0x2011, 0x8012, 0x080c, 0x48e9, 0x080c, 0x0e80,
-	0x080c, 0x5393, 0xd0fc, 0x1188, 0x080c, 0xc225, 0x1170, 0x00c6,
-	0x080c, 0x26f9, 0x080c, 0x9640, 0x2061, 0x0100, 0x2019, 0x0028,
-	0x2009, 0x0002, 0x080c, 0x2fa7, 0x00ce, 0x012e, 0x00fe, 0x00ee,
-	0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x2028, 0x918c, 0x00ff,
-	0x2130, 0x9094, 0xff00, 0x11f0, 0x2011, 0x1836, 0x2214, 0xd2ac,
-	0x11c8, 0x81ff, 0x01e8, 0x2011, 0x181e, 0x2204, 0x9106, 0x1190,
-	0x2011, 0x181f, 0x2214, 0x9294, 0xff00, 0x9584, 0xff00, 0x9206,
-	0x1148, 0x2011, 0x181f, 0x2214, 0x9294, 0x00ff, 0x9584, 0x00ff,
-	0x9206, 0x1120, 0x2500, 0x080c, 0x7c40, 0x0048, 0x9584, 0x00ff,
-	0x9080, 0x313a, 0x200d, 0x918c, 0xff00, 0x810f, 0x9006, 0x0005,
-	0x9080, 0x313a, 0x200d, 0x918c, 0x00ff, 0x0005, 0x00d6, 0x2069,
-	0x0140, 0x2001, 0x1817, 0x2003, 0x00ef, 0x20a9, 0x0010, 0x9006,
-	0x6852, 0x6856, 0x1f04, 0x26a9, 0x00de, 0x0005, 0x0006, 0x00d6,
-	0x0026, 0x2069, 0x0140, 0x2001, 0x1817, 0x2102, 0x8114, 0x8214,
-	0x8214, 0x8214, 0x20a9, 0x0010, 0x6853, 0x0000, 0x9006, 0x82ff,
-	0x1128, 0x9184, 0x000f, 0x9080, 0xddaa, 0x2005, 0x6856, 0x8211,
-	0x1f04, 0x26be, 0x002e, 0x00de, 0x000e, 0x0005, 0x00c6, 0x2061,
-	0x1800, 0x6030, 0x0110, 0xc09d, 0x0008, 0xc09c, 0x6032, 0x00ce,
-	0x0005, 0x0156, 0x00d6, 0x0026, 0x0016, 0x0006, 0x2069, 0x0140,
-	0x6980, 0x9116, 0x0180, 0x9112, 0x1230, 0x8212, 0x8210, 0x22a8,
-	0x2001, 0x0402, 0x0018, 0x22a8, 0x2001, 0x0404, 0x680e, 0x1f04,
-	0x26ee, 0x680f, 0x0000, 0x000e, 0x001e, 0x002e, 0x00de, 0x015e,
-	0x0005, 0x080c, 0x538f, 0xd0c4, 0x0150, 0xd0a4, 0x0140, 0x9006,
-	0x0046, 0x2020, 0x2009, 0x002e, 0x080c, 0xd54b, 0x004e, 0x0005,
-	0x00f6, 0x0016, 0x0026, 0x2079, 0x0140, 0x78c4, 0xd0dc, 0x0904,
-	0x2765, 0x080c, 0x29c4, 0x0660, 0x9084, 0x0700, 0x908e, 0x0600,
-	0x1120, 0x2011, 0x4000, 0x900e, 0x0458, 0x908e, 0x0500, 0x1120,
-	0x2011, 0x8000, 0x900e, 0x0420, 0x908e, 0x0400, 0x1120, 0x9016,
-	0x2009, 0x0001, 0x00e8, 0x908e, 0x0300, 0x1120, 0x9016, 0x2009,
-	0x0002, 0x00b0, 0x908e, 0x0200, 0x1120, 0x9016, 0x2009, 0x0004,
-	0x0078, 0x908e, 0x0100, 0x1548, 0x9016, 0x2009, 0x0008, 0x0040,
-	0x9084, 0x0700, 0x908e, 0x0300, 0x1500, 0x2011, 0x0030, 0x0058,
-	0x2300, 0x9080, 0x0020, 0x2018, 0x080c, 0x8259, 0x928c, 0xff00,
-	0x0110, 0x2011, 0x00ff, 0x2200, 0x8007, 0x9085, 0x004c, 0x78c2,
-	0x2009, 0x0138, 0x220a, 0x080c, 0x6f9b, 0x1118, 0x2009, 0x193d,
-	0x220a, 0x002e, 0x001e, 0x00fe, 0x0005, 0x78c3, 0x0000, 0x0cc8,
-	0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x2001, 0x0170,
-	0x200c, 0x8000, 0x2014, 0x9184, 0x0003, 0x0110, 0x080c, 0x0dad,
-	0x002e, 0x001e, 0x000e, 0x012e, 0x0005, 0x2001, 0x0171, 0x2004,
-	0xd0dc, 0x0168, 0x2001, 0x0170, 0x200c, 0x918c, 0x00ff, 0x918e,
-	0x004c, 0x1128, 0x200c, 0x918c, 0xff00, 0x810f, 0x0005, 0x900e,
-	0x2001, 0x0227, 0x2004, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9108,
-	0x2001, 0x0226, 0x2004, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9108,
-	0x0005, 0x0018, 0x000c, 0x0018, 0x0020, 0x1000, 0x0800, 0x1000,
-	0x1800, 0x0156, 0x0006, 0x0016, 0x0026, 0x00e6, 0x2001, 0x1960,
-	0x2004, 0x908a, 0x0007, 0x1a0c, 0x0db4, 0x0033, 0x00ee, 0x002e,
-	0x001e, 0x000e, 0x015e, 0x0005, 0x27c3, 0x27e1, 0x2805, 0x2807,
-	0x2830, 0x2832, 0x2834, 0x2001, 0x0001, 0x080c, 0x260e, 0x080c,
-	0x2a22, 0x2001, 0x1962, 0x2003, 0x0000, 0x7828, 0x9084, 0xe1d7,
-	0x782a, 0x9006, 0x20a9, 0x0009, 0x080c, 0x29e0, 0x2001, 0x1960,
-	0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x2835, 0x080c, 0x80b3,
-	0x0005, 0x2009, 0x1965, 0x200b, 0x0000, 0x2001, 0x196a, 0x2003,
-	0x0036, 0x2001, 0x1969, 0x2003, 0x002a, 0x2001, 0x1962, 0x2003,
-	0x0001, 0x9006, 0x080c, 0x2992, 0x2001, 0xffff, 0x20a9, 0x0009,
-	0x080c, 0x29e0, 0x2001, 0x1960, 0x2003, 0x0006, 0x2009, 0x001e,
-	0x2011, 0x2835, 0x080c, 0x80b3, 0x0005, 0x080c, 0x0db4, 0x2001,
-	0x196a, 0x2003, 0x0036, 0x2001, 0x1962, 0x2003, 0x0003, 0x7a38,
-	0x9294, 0x0005, 0x9296, 0x0004, 0x0110, 0x9006, 0x0010, 0x2001,
-	0x0001, 0x080c, 0x2992, 0x2001, 0x1966, 0x2003, 0x0000, 0x2001,
-	0xffff, 0x20a9, 0x0009, 0x080c, 0x29e0, 0x2001, 0x1960, 0x2003,
-	0x0006, 0x2009, 0x001e, 0x2011, 0x2835, 0x080c, 0x80b3, 0x0005,
-	0x080c, 0x0db4, 0x080c, 0x0db4, 0x0005, 0x0006, 0x0016, 0x0026,
-	0x00e6, 0x00f6, 0x0156, 0x0126, 0x2091, 0x8000, 0x2079, 0x0100,
-	0x2001, 0x1962, 0x2004, 0x908a, 0x0007, 0x1a0c, 0x0db4, 0x0043,
-	0x012e, 0x015e, 0x00fe, 0x00ee, 0x002e, 0x001e, 0x000e, 0x0005,
-	0x2857, 0x2877, 0x28b7, 0x28e7, 0x290b, 0x291b, 0x291d, 0x080c,
-	0x29d4, 0x11b0, 0x7850, 0x9084, 0xefff, 0x7852, 0x2009, 0x1968,
-	0x2104, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0004, 0x0110, 0xc08d,
-	0x0008, 0xc085, 0x200a, 0x2001, 0x1960, 0x2003, 0x0001, 0x0030,
-	0x080c, 0x2941, 0x2001, 0xffff, 0x080c, 0x27d2, 0x0005, 0x080c,
-	0x291f, 0x05e0, 0x2009, 0x1969, 0x2104, 0x8001, 0x200a, 0x080c,
-	0x29d4, 0x1178, 0x7850, 0x9084, 0xefff, 0x7852, 0x7a38, 0x9294,
-	0x0005, 0x9296, 0x0005, 0x0518, 0x2009, 0x1968, 0x2104, 0xc085,
-	0x200a, 0x2009, 0x1965, 0x2104, 0x8000, 0x200a, 0x9086, 0x0005,
-	0x0118, 0x080c, 0x2927, 0x00c0, 0x200b, 0x0000, 0x7a38, 0x9294,
-	0x0006, 0x9296, 0x0004, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001,
-	0x080c, 0x29af, 0x2001, 0x1962, 0x2003, 0x0002, 0x0028, 0x2001,
-	0x1960, 0x2003, 0x0003, 0x0010, 0x080c, 0x27f4, 0x0005, 0x080c,
-	0x291f, 0x0560, 0x2009, 0x1969, 0x2104, 0x8001, 0x200a, 0x080c,
-	0x29d4, 0x1168, 0x7850, 0x9084, 0xefff, 0x7852, 0x2001, 0x1960,
-	0x2003, 0x0003, 0x2001, 0x1961, 0x2003, 0x0000, 0x00b8, 0x2009,
-	0x1969, 0x2104, 0x9005, 0x1118, 0x080c, 0x2964, 0x0010, 0x080c,
-	0x2934, 0x080c, 0x2927, 0x2009, 0x1965, 0x200b, 0x0000, 0x2001,
-	0x1962, 0x2003, 0x0001, 0x080c, 0x27f4, 0x0000, 0x0005, 0x04b9,
-	0x0508, 0x080c, 0x29d4, 0x11b8, 0x7850, 0x9084, 0xefff, 0x7852,
-	0x2009, 0x1966, 0x2104, 0x8000, 0x200a, 0x9086, 0x0007, 0x0108,
-	0x0078, 0x2001, 0x196b, 0x2003, 0x000a, 0x2009, 0x1968, 0x2104,
-	0xc0fd, 0x200a, 0x0038, 0x0419, 0x2001, 0x1962, 0x2003, 0x0004,
-	0x080c, 0x281f, 0x0005, 0x0099, 0x0168, 0x080c, 0x29d4, 0x1138,
-	0x7850, 0x9084, 0xefff, 0x7852, 0x080c, 0x280b, 0x0018, 0x0079,
-	0x080c, 0x281f, 0x0005, 0x080c, 0x0db4, 0x080c, 0x0db4, 0x2009,
-	0x196a, 0x2104, 0x8001, 0x200a, 0x090c, 0x2980, 0x0005, 0x7a38,
-	0x9294, 0x0005, 0x9296, 0x0005, 0x0110, 0x9006, 0x0010, 0x2001,
-	0x0001, 0x080c, 0x29af, 0x0005, 0x7a38, 0x9294, 0x0006, 0x9296,
-	0x0006, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x2992,
-	0x0005, 0x2009, 0x1965, 0x2104, 0x8000, 0x200a, 0x9086, 0x0005,
-	0x0108, 0x0068, 0x200b, 0x0000, 0x7a38, 0x9294, 0x0006, 0x9296,
-	0x0006, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x04d9, 0x7a38,
-	0x9294, 0x0005, 0x9296, 0x0005, 0x0110, 0x9006, 0x0010, 0x2001,
-	0x0001, 0x080c, 0x29af, 0x0005, 0x0086, 0x2001, 0x1968, 0x2004,
-	0x9084, 0x7fff, 0x090c, 0x0db4, 0x2009, 0x1967, 0x2144, 0x8846,
-	0x280a, 0x9844, 0x0dd8, 0xd08c, 0x1120, 0xd084, 0x1120, 0x080c,
-	0x0db4, 0x9006, 0x0010, 0x2001, 0x0001, 0x00a1, 0x008e, 0x0005,
-	0x0006, 0x0156, 0x2001, 0x1960, 0x20a9, 0x0009, 0x2003, 0x0000,
-	0x8000, 0x1f04, 0x2986, 0x2001, 0x1967, 0x2003, 0x8000, 0x015e,
-	0x000e, 0x0005, 0x00f6, 0x2079, 0x0100, 0x9085, 0x0000, 0x0158,
-	0x7838, 0x9084, 0xfff9, 0x9085, 0x0004, 0x783a, 0x2009, 0x196d,
-	0x210c, 0x795a, 0x0050, 0x7838, 0x9084, 0xfffb, 0x9085, 0x0006,
-	0x783a, 0x2009, 0x196e, 0x210c, 0x795a, 0x00fe, 0x0005, 0x00f6,
-	0x2079, 0x0100, 0x9085, 0x0000, 0x0138, 0x7838, 0x9084, 0xfffa,
-	0x9085, 0x0004, 0x783a, 0x0030, 0x7838, 0x9084, 0xfffb, 0x9085,
-	0x0005, 0x783a, 0x00fe, 0x0005, 0x0006, 0x2001, 0x0100, 0x2004,
-	0x9082, 0x0007, 0x000e, 0x0005, 0x0006, 0x2001, 0x0100, 0x2004,
-	0x9082, 0x0009, 0x000e, 0x0005, 0x0156, 0x20a9, 0x0064, 0x7820,
-	0x080c, 0x2a5f, 0xd09c, 0x1110, 0x1f04, 0x29d7, 0x015e, 0x0005,
-	0x0126, 0x0016, 0x0006, 0x2091, 0x8000, 0x7850, 0x9085, 0x0040,
-	0x7852, 0x7850, 0x9084, 0xfbcf, 0x7852, 0x080c, 0x2a5f, 0x9085,
-	0x2000, 0x7852, 0x000e, 0x2008, 0x9186, 0x0000, 0x1118, 0x783b,
-	0x0007, 0x0090, 0x9186, 0x0001, 0x1118, 0x783b, 0x0006, 0x0060,
-	0x9186, 0x0002, 0x1118, 0x783b, 0x0005, 0x0030, 0x9186, 0x0003,
-	0x1118, 0x783b, 0x0004, 0x0000, 0x0006, 0x1d04, 0x2a0d, 0x080c,
-	0x80d5, 0x1f04, 0x2a0d, 0x7850, 0x9085, 0x0400, 0x9084, 0xdfbf,
-	0x7852, 0x080c, 0x2a5f, 0x9085, 0x1000, 0x7852, 0x000e, 0x001e,
-	0x012e, 0x0005, 0x7850, 0x9084, 0xffcf, 0x7852, 0x0005, 0x0006,
-	0x0156, 0x00f6, 0x2079, 0x0100, 0x20a9, 0x000a, 0x7854, 0xd0ac,
-	0x1130, 0x7820, 0xd0e4, 0x1140, 0x1f04, 0x2a31, 0x0028, 0x7854,
-	0xd08c, 0x1110, 0x1f04, 0x2a37, 0x00fe, 0x015e, 0x000e, 0x0005,
-	0x1d04, 0x2a40, 0x080c, 0x80d5, 0x1f04, 0x2a40, 0x0005, 0x0006,
-	0x2001, 0x196c, 0x2004, 0x9086, 0x0000, 0x000e, 0x0005, 0x0006,
-	0x2001, 0x196c, 0x2004, 0x9086, 0x0001, 0x000e, 0x0005, 0x0006,
-	0x2001, 0x196c, 0x2004, 0x9086, 0x0002, 0x000e, 0x0005, 0xa001,
-	0xa001, 0xa001, 0xa001, 0xa001, 0x0005, 0x0006, 0x2001, 0x1978,
-	0x2102, 0x000e, 0x0005, 0x2009, 0x0171, 0x2104, 0xd0dc, 0x0140,
-	0x2009, 0x0170, 0x2104, 0x200b, 0x0080, 0xa001, 0xa001, 0x200a,
-	0x0005, 0x0036, 0x0046, 0x2001, 0x0141, 0x200c, 0x918c, 0xff00,
-	0x9186, 0x2000, 0x0118, 0x9186, 0x0100, 0x1588, 0x2009, 0x00a2,
-	0x080c, 0x0e2f, 0x2019, 0x0160, 0x2324, 0x2011, 0x0003, 0x2009,
-	0x0169, 0x2104, 0x9084, 0x0007, 0x210c, 0x918c, 0x0007, 0x910e,
-	0x1db0, 0x9086, 0x0003, 0x11b8, 0x2304, 0x9402, 0x02a0, 0x1d60,
-	0x8211, 0x1d68, 0x84ff, 0x0170, 0x2001, 0x0141, 0x200c, 0x918c,
-	0xff00, 0x9186, 0x0100, 0x0130, 0x2009, 0x180c, 0x2104, 0xc0dd,
-	0x200a, 0x0008, 0x0419, 0x2009, 0x0000, 0x080c, 0x0e2f, 0x004e,
-	0x003e, 0x0005, 0x2001, 0x180c, 0x2004, 0xd0dc, 0x01b0, 0x2001,
-	0x0160, 0x2004, 0x9005, 0x0140, 0x2001, 0x0141, 0x2004, 0x9084,
-	0xff00, 0x9086, 0x0100, 0x1148, 0x0126, 0x2091, 0x8000, 0x0016,
-	0x0026, 0x0021, 0x002e, 0x001e, 0x012e, 0x0005, 0x00c6, 0x2061,
-	0x0100, 0x6014, 0x0006, 0x2001, 0x0161, 0x2003, 0x0000, 0x6017,
-	0x0018, 0xa001, 0xa001, 0x602f, 0x0008, 0x6104, 0x918e, 0x0010,
-	0x6106, 0x918e, 0x0010, 0x6106, 0x6017, 0x0040, 0x04b9, 0x001e,
-	0x9184, 0x0003, 0x01e0, 0x0036, 0x0016, 0x2019, 0x0141, 0x6124,
-	0x918c, 0x0028, 0x1120, 0x2304, 0x9084, 0x2800, 0x0dc0, 0x001e,
-	0x919c, 0xffe4, 0x9184, 0x0001, 0x0118, 0x9385, 0x0009, 0x6016,
-	0x9184, 0x0002, 0x0118, 0x9385, 0x0012, 0x6016, 0x003e, 0x2001,
-	0x180c, 0x200c, 0xc1dc, 0x2102, 0x00ce, 0x0005, 0x0016, 0x0026,
-	0x080c, 0x6fb5, 0x0108, 0xc0bc, 0x2009, 0x0140, 0x2114, 0x9294,
-	0x0001, 0x9215, 0x220a, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026,
-	0x2009, 0x0140, 0x2114, 0x9294, 0x0001, 0x9285, 0x1000, 0x200a,
-	0x220a, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026, 0x2009, 0x0140,
-	0x2114, 0x9294, 0x0001, 0x9215, 0x220a, 0x002e, 0x001e, 0x0005,
-	0x0006, 0x0016, 0x2009, 0x0140, 0x2104, 0x1128, 0x080c, 0x6fb5,
-	0x0110, 0xc0bc, 0x0008, 0xc0bd, 0x200a, 0x001e, 0x000e, 0x0005,
-	0x2dbc, 0x2dbc, 0x2be0, 0x2be0, 0x2bec, 0x2bec, 0x2bf8, 0x2bf8,
-	0x2c06, 0x2c06, 0x2c12, 0x2c12, 0x2c20, 0x2c20, 0x2c2e, 0x2c2e,
-	0x2c40, 0x2c40, 0x2c4c, 0x2c4c, 0x2c5a, 0x2c5a, 0x2c78, 0x2c78,
-	0x2c98, 0x2c98, 0x2c68, 0x2c68, 0x2c88, 0x2c88, 0x2ca6, 0x2ca6,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2cb8, 0x2cb8, 0x2cc4, 0x2cc4, 0x2cd2, 0x2cd2, 0x2ce0, 0x2ce0,
-	0x2cf0, 0x2cf0, 0x2cfe, 0x2cfe, 0x2d0e, 0x2d0e, 0x2d1e, 0x2d1e,
-	0x2d30, 0x2d30, 0x2d3e, 0x2d3e, 0x2d4e, 0x2d4e, 0x2d70, 0x2d70,
-	0x2d92, 0x2d92, 0x2d5e, 0x2d5e, 0x2d81, 0x2d81, 0x2da1, 0x2da1,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e, 0x2c3e,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2315, 0x0804, 0x2db4, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x212d, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x212d, 0x080c, 0x2315, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2168,
-	0x0804, 0x2db4, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2315, 0x080c, 0x2168, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x212d, 0x080c, 0x2168, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x212d,
-	0x080c, 0x2315, 0x080c, 0x2168, 0x0804, 0x2db4, 0xa001, 0x0cf0,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x130c, 0x0804, 0x2db4, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2315, 0x080c, 0x130c,
-	0x0804, 0x2db4, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x212d, 0x080c, 0x130c, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2315, 0x080c, 0x130c, 0x080c, 0x2168, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x212d, 0x080c, 0x2315, 0x080c, 0x130c, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x212d, 0x080c, 0x130c, 0x080c, 0x2168, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x130c, 0x080c, 0x2168, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x212d,
-	0x080c, 0x2315, 0x080c, 0x130c, 0x080c, 0x2168, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2768, 0x0804, 0x2db4, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2768, 0x080c, 0x2315,
-	0x0804, 0x2db4, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2768, 0x080c, 0x212d, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2768, 0x080c, 0x212d, 0x080c, 0x2315, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2768, 0x080c, 0x2168, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2768,
-	0x080c, 0x2315, 0x080c, 0x2168, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2768,
-	0x080c, 0x212d, 0x080c, 0x2168, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2768,
-	0x080c, 0x212d, 0x080c, 0x2315, 0x080c, 0x2168, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2768, 0x080c, 0x130c, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2768,
-	0x080c, 0x2315, 0x080c, 0x130c, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2768,
-	0x080c, 0x212d, 0x080c, 0x130c, 0x0804, 0x2db4, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2768,
-	0x080c, 0x2315, 0x080c, 0x130c, 0x080c, 0x2168, 0x0804, 0x2db4,
-	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2768, 0x080c, 0x212d, 0x080c, 0x2315, 0x080c, 0x130c,
-	0x0498, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2768, 0x080c, 0x212d, 0x080c, 0x130c, 0x080c,
-	0x2168, 0x0410, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2768, 0x080c, 0x130c, 0x080c, 0x2168,
-	0x0098, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
-	0x0156, 0x080c, 0x2768, 0x080c, 0x212d, 0x080c, 0x2315, 0x080c,
-	0x130c, 0x080c, 0x2168, 0x0000, 0x015e, 0x014e, 0x013e, 0x01de,
-	0x01ce, 0x012e, 0x000e, 0x010e, 0x000d, 0x00b6, 0x00c6, 0x0026,
-	0x0046, 0x9026, 0x080c, 0x6529, 0x1904, 0x2ec3, 0x72d8, 0x2001,
-	0x194c, 0x2004, 0x9005, 0x1110, 0xd29c, 0x0148, 0xd284, 0x1138,
-	0xd2bc, 0x1904, 0x2ec3, 0x080c, 0x2ec8, 0x0804, 0x2ec3, 0xd2cc,
-	0x1904, 0x2ec3, 0x080c, 0x6f9b, 0x1120, 0x70ab, 0xffff, 0x0804,
-	0x2ec3, 0xd294, 0x0120, 0x70ab, 0xffff, 0x0804, 0x2ec3, 0x080c,
-	0x3130, 0x0160, 0x080c, 0xc22c, 0x0128, 0x2001, 0x1817, 0x203c,
-	0x0804, 0x2e55, 0x70ab, 0xffff, 0x0804, 0x2ec3, 0x2001, 0x1817,
-	0x203c, 0x7290, 0xd284, 0x0904, 0x2e55, 0xd28c, 0x1904, 0x2e55,
-	0x0036, 0x73a8, 0x938e, 0xffff, 0x1110, 0x2019, 0x0001, 0x8314,
-	0x92e0, 0x1c80, 0x2c04, 0x938c, 0x0001, 0x0120, 0x9084, 0xff00,
-	0x8007, 0x0010, 0x9084, 0x00ff, 0x970e, 0x05a8, 0x908e, 0x0000,
-	0x0590, 0x908e, 0x00ff, 0x1150, 0x7230, 0xd284, 0x1588, 0x7290,
-	0xc28d, 0x7292, 0x70ab, 0xffff, 0x003e, 0x0478, 0x0026, 0x2011,
-	0x0010, 0x080c, 0x658f, 0x002e, 0x0118, 0x70ab, 0xffff, 0x0410,
-	0x900e, 0x080c, 0x2665, 0x080c, 0x61e7, 0x11c0, 0x080c, 0x656b,
-	0x1168, 0x7030, 0xd08c, 0x0130, 0xb800, 0xd0bc, 0x0138, 0x080c,
-	0x6467, 0x0120, 0x080c, 0x2ee1, 0x0148, 0x0028, 0x080c, 0x3021,
-	0x080c, 0x2f0d, 0x0118, 0x8318, 0x0804, 0x2e07, 0x73aa, 0x0010,
-	0x70ab, 0xffff, 0x003e, 0x0804, 0x2ec3, 0x9780, 0x313a, 0x203d,
-	0x97bc, 0xff00, 0x873f, 0x2041, 0x007e, 0x70a8, 0x9096, 0xffff,
-	0x1118, 0x900e, 0x28a8, 0x0050, 0x9812, 0x0220, 0x2008, 0x9802,
-	0x20a8, 0x0020, 0x70ab, 0xffff, 0x0804, 0x2ec3, 0x2700, 0x0156,
-	0x0016, 0x9106, 0x0904, 0x2eb8, 0x0026, 0x2011, 0x0010, 0x080c,
-	0x658f, 0x002e, 0x0120, 0x2009, 0xffff, 0x0804, 0x2ec0, 0xc484,
-	0x080c, 0x6247, 0x0138, 0x080c, 0xc22c, 0x1590, 0x080c, 0x61e7,
-	0x15b8, 0x0008, 0xc485, 0x080c, 0x656b, 0x1130, 0x7030, 0xd08c,
-	0x01f8, 0xb800, 0xd0bc, 0x11e0, 0x7290, 0xd28c, 0x0180, 0x080c,
-	0x656b, 0x9082, 0x0006, 0x02e0, 0xd484, 0x1118, 0x080c, 0x620b,
-	0x0028, 0x080c, 0x30ac, 0x01a0, 0x080c, 0x30d7, 0x0088, 0x080c,
-	0x3021, 0x080c, 0xc22c, 0x1160, 0x080c, 0x2f0d, 0x0188, 0x0040,
-	0x080c, 0xc22c, 0x1118, 0x080c, 0x30ac, 0x0110, 0x0451, 0x0140,
-	0x001e, 0x8108, 0x015e, 0x1f04, 0x2e6e, 0x70ab, 0xffff, 0x0018,
-	0x001e, 0x015e, 0x71aa, 0x004e, 0x002e, 0x00ce, 0x00be, 0x0005,
-	0x00c6, 0x0016, 0x70ab, 0x0001, 0x2009, 0x007e, 0x080c, 0x61e7,
-	0x1168, 0xb813, 0x00ff, 0xb817, 0xfffe, 0x080c, 0x3021, 0x04a9,
-	0x0128, 0x70d8, 0xc0bd, 0x70da, 0x080c, 0xbf7d, 0x001e, 0x00ce,
-	0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x2001, 0x1858, 0x2004,
-	0x9084, 0x00ff, 0xb842, 0x080c, 0x9e8f, 0x01d0, 0x2b00, 0x6012,
-	0x080c, 0xbfa6, 0x6023, 0x0001, 0x9006, 0x080c, 0x6184, 0x2001,
-	0x0000, 0x080c, 0x6198, 0x0126, 0x2091, 0x8000, 0x70a4, 0x8000,
-	0x70a6, 0x012e, 0x2009, 0x0004, 0x080c, 0x9ebc, 0x9085, 0x0001,
-	0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x0016, 0x0076, 0x00d6,
-	0x00c6, 0x2001, 0x1858, 0x2004, 0x9084, 0x00ff, 0xb842, 0x080c,
-	0x9e8f, 0x0548, 0x2b00, 0x6012, 0xb800, 0xc0c4, 0xb802, 0xb8a0,
-	0x9086, 0x007e, 0x0140, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
-	0x1110, 0x080c, 0x2fdc, 0x080c, 0xbfa6, 0x6023, 0x0001, 0x9006,
-	0x080c, 0x6184, 0x2001, 0x0002, 0x080c, 0x6198, 0x0126, 0x2091,
-	0x8000, 0x70a4, 0x8000, 0x70a6, 0x012e, 0x2009, 0x0002, 0x080c,
-	0x9ebc, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005,
-	0x00b6, 0x00c6, 0x0026, 0x2009, 0x0080, 0x080c, 0x61e7, 0x1140,
-	0xb813, 0x00ff, 0xb817, 0xfffc, 0x0039, 0x0110, 0x70df, 0xffff,
-	0x002e, 0x00ce, 0x00be, 0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6,
-	0x080c, 0x9dec, 0x01d0, 0x2b00, 0x6012, 0x080c, 0xbfa6, 0x6023,
-	0x0001, 0x9006, 0x080c, 0x6184, 0x2001, 0x0002, 0x080c, 0x6198,
-	0x0126, 0x2091, 0x8000, 0x70e0, 0x8000, 0x70e2, 0x012e, 0x2009,
-	0x0002, 0x080c, 0x9ebc, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e,
-	0x001e, 0x0005, 0x00c6, 0x00d6, 0x0126, 0x2091, 0x8000, 0x2009,
-	0x007f, 0x080c, 0x61e7, 0x11b8, 0xb813, 0x00ff, 0xb817, 0xfffd,
-	0xb8bf, 0x0004, 0x080c, 0x9dec, 0x0170, 0x2b00, 0x6012, 0x6316,
-	0x6023, 0x0001, 0x620a, 0x080c, 0xbfa6, 0x2009, 0x0022, 0x080c,
-	0x9ebc, 0x9085, 0x0001, 0x012e, 0x00de, 0x00ce, 0x0005, 0x00e6,
-	0x00c6, 0x0066, 0x0036, 0x0026, 0x00b6, 0x21f0, 0x080c, 0x856f,
-	0x080c, 0x84f9, 0x080c, 0x9c95, 0x080c, 0xad8a, 0x3e08, 0x2130,
-	0x81ff, 0x0120, 0x20a9, 0x007e, 0x900e, 0x0018, 0x20a9, 0x007f,
-	0x900e, 0x0016, 0x080c, 0x6247, 0x1140, 0x9686, 0x0002, 0x1118,
-	0xb800, 0xd0bc, 0x1110, 0x080c, 0x5cf4, 0x001e, 0x8108, 0x1f04,
-	0x2fc1, 0x9686, 0x0001, 0x190c, 0x3104, 0x00be, 0x002e, 0x003e,
-	0x006e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x00c6, 0x0046, 0x0036,
-	0x0026, 0x0016, 0x00b6, 0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019,
-	0x0029, 0x080c, 0x8564, 0x0076, 0x2039, 0x0000, 0x080c, 0x8452,
-	0x2c08, 0x080c, 0xd2bc, 0x007e, 0x001e, 0xba10, 0xbb14, 0xbcb0,
-	0x080c, 0x5cf4, 0xba12, 0xbb16, 0xbcb2, 0x00be, 0x001e, 0x002e,
-	0x003e, 0x004e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x00b6,
-	0x6010, 0x2058, 0xb8a0, 0x00be, 0x9086, 0x0080, 0x0150, 0x2071,
-	0x1800, 0x70a4, 0x9005, 0x0110, 0x8001, 0x70a6, 0x000e, 0x00ee,
-	0x0005, 0x2071, 0x1800, 0x70e0, 0x9005, 0x0dc0, 0x8001, 0x70e2,
-	0x0ca8, 0xb800, 0xc08c, 0xb802, 0x0005, 0x00f6, 0x00e6, 0x00c6,
-	0x00b6, 0x0046, 0x0036, 0x0026, 0x0016, 0x0156, 0x2178, 0x81ff,
-	0x1118, 0x20a9, 0x0001, 0x0070, 0x080c, 0x538f, 0xd0c4, 0x0138,
-	0x0030, 0x9006, 0x2020, 0x2009, 0x002d, 0x080c, 0xd54b, 0x20a9,
-	0x0800, 0x9016, 0x0026, 0x928e, 0x007e, 0x0904, 0x308b, 0x928e,
-	0x007f, 0x0904, 0x308b, 0x928e, 0x0080, 0x05e8, 0x9288, 0x1000,
-	0x210c, 0x81ff, 0x05c0, 0x8fff, 0x1148, 0x2001, 0x195e, 0x0006,
-	0x2003, 0x0001, 0x04f1, 0x000e, 0x2003, 0x0000, 0x00b6, 0x00c6,
-	0x2158, 0x2001, 0x0001, 0x080c, 0x6535, 0x00ce, 0x00be, 0x2019,
-	0x0029, 0x080c, 0x8564, 0x0076, 0x2039, 0x0000, 0x080c, 0x8452,
-	0x00b6, 0x00c6, 0x0026, 0x2158, 0xba04, 0x9294, 0x00ff, 0x9286,
-	0x0006, 0x1118, 0xb807, 0x0404, 0x0028, 0x2001, 0x0004, 0x8007,
-	0x9215, 0xba06, 0x002e, 0x00ce, 0x00be, 0x0016, 0x2c08, 0x080c,
-	0xd2bc, 0x001e, 0x007e, 0x002e, 0x8210, 0x1f04, 0x3042, 0x015e,
-	0x001e, 0x002e, 0x003e, 0x004e, 0x00be, 0x00ce, 0x00ee, 0x00fe,
-	0x0005, 0x0046, 0x0026, 0x0016, 0x080c, 0x538f, 0xd0c4, 0x0140,
-	0xd0a4, 0x0130, 0x9006, 0x2220, 0x2009, 0x0029, 0x080c, 0xd54b,
-	0x001e, 0x002e, 0x004e, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6,
-	0x7290, 0x82ff, 0x01e8, 0x080c, 0x6563, 0x11d0, 0x2100, 0x080c,
-	0x2698, 0x81ff, 0x01b8, 0x2019, 0x0001, 0x8314, 0x92e0, 0x1c80,
-	0x2c04, 0xd384, 0x0120, 0x9084, 0xff00, 0x8007, 0x0010, 0x9084,
-	0x00ff, 0x9116, 0x0138, 0x9096, 0x00ff, 0x0110, 0x8318, 0x0c68,
-	0x9085, 0x0001, 0x00ce, 0x003e, 0x002e, 0x001e, 0x0005, 0x0016,
-	0x00c6, 0x0126, 0x2091, 0x8000, 0x0036, 0x2019, 0x0029, 0x00a9,
-	0x003e, 0x9180, 0x1000, 0x2004, 0x9065, 0x0158, 0x0016, 0x00c6,
-	0x2061, 0x1a7f, 0x001e, 0x6112, 0x080c, 0x2fdc, 0x001e, 0x080c,
-	0x620b, 0x012e, 0x00ce, 0x001e, 0x0005, 0x0016, 0x0026, 0x2110,
-	0x080c, 0x992c, 0x080c, 0xd803, 0x002e, 0x001e, 0x0005, 0x2001,
-	0x1836, 0x2004, 0xd0cc, 0x0005, 0x00c6, 0x00b6, 0x080c, 0x6f9b,
-	0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782, 0x080c, 0x6f9b,
-	0x1110, 0x900e, 0x0010, 0x2009, 0x007e, 0x9180, 0x1000, 0x2004,
-	0x905d, 0x0130, 0x86ff, 0x0110, 0xb800, 0xd0bc, 0x090c, 0x620b,
-	0x8108, 0x1f04, 0x3115, 0x2061, 0x1800, 0x607b, 0x0000, 0x607c,
-	0x9084, 0x00ff, 0x607e, 0x60af, 0x0000, 0x00be, 0x00ce, 0x0005,
-	0x2001, 0x1875, 0x2004, 0xd0bc, 0x0005, 0x2011, 0x1854, 0x2214,
-	0xd2ec, 0x0005, 0x7eef, 0x7de8, 0x7ce4, 0x80e2, 0x7be1, 0x80e0,
-	0x80dc, 0x80da, 0x7ad9, 0x80d6, 0x80d5, 0x80d4, 0x80d3, 0x80d2,
-	0x80d1, 0x79ce, 0x78cd, 0x80cc, 0x80cb, 0x80ca, 0x80c9, 0x80c7,
-	0x80c6, 0x77c5, 0x76c3, 0x80bc, 0x80ba, 0x75b9, 0x80b6, 0x74b5,
-	0x73b4, 0x72b3, 0x80b2, 0x80b1, 0x80ae, 0x71ad, 0x80ac, 0x70ab,
-	0x6faa, 0x6ea9, 0x80a7, 0x6da6, 0x6ca5, 0x6ba3, 0x6a9f, 0x699e,
-	0x689d, 0x809b, 0x8098, 0x6797, 0x6690, 0x658f, 0x6488, 0x6384,
-	0x6282, 0x8081, 0x8080, 0x617c, 0x607a, 0x8079, 0x5f76, 0x8075,
-	0x8074, 0x8073, 0x8072, 0x8071, 0x806e, 0x5e6d, 0x806c, 0x5d6b,
-	0x5c6a, 0x5b69, 0x8067, 0x5a66, 0x5965, 0x5863, 0x575c, 0x565a,
-	0x5559, 0x8056, 0x8055, 0x5454, 0x5353, 0x5252, 0x5151, 0x504e,
-	0x4f4d, 0x804c, 0x804b, 0x4e4a, 0x4d49, 0x8047, 0x4c46, 0x8045,
-	0x8043, 0x803c, 0x803a, 0x8039, 0x8036, 0x4b35, 0x8034, 0x4a33,
-	0x4932, 0x4831, 0x802e, 0x472d, 0x462c, 0x452b, 0x442a, 0x4329,
-	0x4227, 0x8026, 0x8025, 0x4123, 0x401f, 0x3f1e, 0x3e1d, 0x3d1b,
-	0x3c18, 0x8017, 0x8010, 0x3b0f, 0x3a08, 0x8004, 0x3902, 0x8001,
-	0x8000, 0x8000, 0x3800, 0x3700, 0x3600, 0x8000, 0x3500, 0x8000,
-	0x8000, 0x8000, 0x3400, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-	0x8000, 0x3300, 0x3200, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-	0x8000, 0x3100, 0x3000, 0x8000, 0x8000, 0x2f00, 0x8000, 0x2e00,
-	0x2d00, 0x2c00, 0x8000, 0x8000, 0x8000, 0x2b00, 0x8000, 0x2a00,
-	0x2900, 0x2800, 0x8000, 0x2700, 0x2600, 0x2500, 0x2400, 0x2300,
-	0x2200, 0x8000, 0x8000, 0x2100, 0x2000, 0x1f00, 0x1e00, 0x1d00,
-	0x1c00, 0x8000, 0x8000, 0x1b00, 0x1a00, 0x8000, 0x1900, 0x8000,
-	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x1800, 0x8000, 0x1700,
-	0x1600, 0x1500, 0x8000, 0x1400, 0x1300, 0x1200, 0x1100, 0x1000,
-	0x0f00, 0x8000, 0x8000, 0x0e00, 0x0d00, 0x0c00, 0x0b00, 0x0a00,
-	0x0900, 0x8000, 0x8000, 0x0800, 0x0700, 0x8000, 0x0600, 0x8000,
-	0x8000, 0x8000, 0x0500, 0x0400, 0x0300, 0x8000, 0x0200, 0x8000,
-	0x8000, 0x8000, 0x0100, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-	0x8000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x2b31, 0x00de, 0x00c6, 0x2061, 0x19bf, 0x6044, 0x080c, 0xc23b,
+	0x0120, 0x909a, 0x0003, 0x1628, 0x0018, 0x909a, 0x00c8, 0x1608,
+	0x8000, 0x6046, 0x603c, 0x00ce, 0x9005, 0x0558, 0x2009, 0x07d0,
+	0x080c, 0x80c4, 0x9080, 0x0008, 0x2004, 0x9086, 0x0006, 0x1138,
+	0x6114, 0x918c, 0x1984, 0x918d, 0x0012, 0x6116, 0x00d0, 0x6114,
+	0x918c, 0x1984, 0x918d, 0x0016, 0x6116, 0x0098, 0x6027, 0x0004,
+	0x0080, 0x0036, 0x2019, 0x0001, 0x080c, 0x96e9, 0x003e, 0x2019,
+	0x19ce, 0x2304, 0x9065, 0x0120, 0x2009, 0x004f, 0x080c, 0x9ea9,
+	0x00ce, 0x001e, 0xd19c, 0x0904, 0x2614, 0x7038, 0xd0ac, 0x1904,
+	0x25e9, 0x0016, 0x0156, 0x6027, 0x0008, 0x6050, 0x9085, 0x0040,
+	0x6052, 0x6050, 0x9084, 0xfbcf, 0x6052, 0x080c, 0x2a6a, 0x9085,
+	0x2000, 0x6052, 0x20a9, 0x0012, 0x1d04, 0x25bc, 0x080c, 0x80f3,
+	0x1f04, 0x25bc, 0x6050, 0x9085, 0x0400, 0x9084, 0xdfbf, 0x6052,
+	0x20a9, 0x0028, 0xa001, 0x1f04, 0x25ca, 0x6150, 0x9185, 0x1400,
+	0x6052, 0x20a9, 0x0366, 0x1d04, 0x25d3, 0x080c, 0x80f3, 0x6020,
+	0xd09c, 0x1130, 0x015e, 0x6152, 0x001e, 0x6027, 0x0008, 0x04a0,
+	0x080c, 0x2a32, 0x1f04, 0x25d3, 0x015e, 0x6152, 0x001e, 0x6027,
+	0x0008, 0x0016, 0x6028, 0xc09c, 0x602a, 0x080c, 0x9db5, 0x60e3,
+	0x0000, 0x080c, 0xd8ee, 0x080c, 0xd909, 0x080c, 0x539e, 0xd0fc,
+	0x1138, 0x080c, 0xc234, 0x1120, 0x9085, 0x0001, 0x080c, 0x6ff1,
+	0x9006, 0x080c, 0x2b21, 0x2009, 0x0002, 0x080c, 0x2a70, 0x00e6,
+	0x2071, 0x1800, 0x7003, 0x0004, 0x080c, 0x0e80, 0x00ee, 0x6027,
+	0x0008, 0x080c, 0x0b8f, 0x001e, 0x918c, 0xffd0, 0x6126, 0x00ae,
+	0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00e6, 0x00f6, 0x0126,
+	0x2091, 0x8000, 0x2071, 0x1800, 0x71cc, 0x70ce, 0x9116, 0x0904,
+	0x2668, 0x81ff, 0x01a0, 0x2009, 0x0000, 0x080c, 0x2a70, 0x2011,
+	0x8011, 0x2019, 0x010e, 0x231c, 0x939e, 0x0007, 0x1118, 0x2019,
+	0x0001, 0x0010, 0x2019, 0x0000, 0x080c, 0x48f4, 0x0448, 0x2001,
+	0x1980, 0x200c, 0x81ff, 0x1140, 0x2001, 0x0109, 0x2004, 0xd0b4,
+	0x0118, 0x2019, 0x0003, 0x0008, 0x2118, 0x2011, 0x8012, 0x080c,
+	0x48f4, 0x080c, 0x0e80, 0x080c, 0x539e, 0xd0fc, 0x1188, 0x080c,
+	0xc234, 0x1170, 0x00c6, 0x080c, 0x2704, 0x080c, 0x9650, 0x2061,
+	0x0100, 0x2019, 0x0028, 0x2009, 0x0002, 0x080c, 0x2fb2, 0x00ce,
+	0x012e, 0x00fe, 0x00ee, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005,
+	0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00, 0x11f0, 0x2011,
+	0x1836, 0x2214, 0xd2ac, 0x11c8, 0x81ff, 0x01e8, 0x2011, 0x181e,
+	0x2204, 0x9106, 0x1190, 0x2011, 0x181f, 0x2214, 0x9294, 0xff00,
+	0x9584, 0xff00, 0x9206, 0x1148, 0x2011, 0x181f, 0x2214, 0x9294,
+	0x00ff, 0x9584, 0x00ff, 0x9206, 0x1120, 0x2500, 0x080c, 0x7c4e,
+	0x0048, 0x9584, 0x00ff, 0x9080, 0x3145, 0x200d, 0x918c, 0xff00,
+	0x810f, 0x9006, 0x0005, 0x9080, 0x3145, 0x200d, 0x918c, 0x00ff,
+	0x0005, 0x00d6, 0x2069, 0x0140, 0x2001, 0x1817, 0x2003, 0x00ef,
+	0x20a9, 0x0010, 0x9006, 0x6852, 0x6856, 0x1f04, 0x26b4, 0x00de,
+	0x0005, 0x0006, 0x00d6, 0x0026, 0x2069, 0x0140, 0x2001, 0x1817,
+	0x2102, 0x8114, 0x8214, 0x8214, 0x8214, 0x20a9, 0x0010, 0x6853,
+	0x0000, 0x9006, 0x82ff, 0x1128, 0x9184, 0x000f, 0x9080, 0xddc3,
+	0x2005, 0x6856, 0x8211, 0x1f04, 0x26c9, 0x002e, 0x00de, 0x000e,
+	0x0005, 0x00c6, 0x2061, 0x1800, 0x6030, 0x0110, 0xc09d, 0x0008,
+	0xc09c, 0x6032, 0x00ce, 0x0005, 0x0156, 0x00d6, 0x0026, 0x0016,
+	0x0006, 0x2069, 0x0140, 0x6980, 0x9116, 0x0180, 0x9112, 0x1230,
+	0x8212, 0x8210, 0x22a8, 0x2001, 0x0402, 0x0018, 0x22a8, 0x2001,
+	0x0404, 0x680e, 0x1f04, 0x26f9, 0x680f, 0x0000, 0x000e, 0x001e,
+	0x002e, 0x00de, 0x015e, 0x0005, 0x080c, 0x539a, 0xd0c4, 0x0150,
+	0xd0a4, 0x0140, 0x9006, 0x0046, 0x2020, 0x2009, 0x002e, 0x080c,
+	0xd564, 0x004e, 0x0005, 0x00f6, 0x0016, 0x0026, 0x2079, 0x0140,
+	0x78c4, 0xd0dc, 0x0904, 0x2770, 0x080c, 0x29cf, 0x0660, 0x9084,
+	0x0700, 0x908e, 0x0600, 0x1120, 0x2011, 0x4000, 0x900e, 0x0458,
+	0x908e, 0x0500, 0x1120, 0x2011, 0x8000, 0x900e, 0x0420, 0x908e,
+	0x0400, 0x1120, 0x9016, 0x2009, 0x0001, 0x00e8, 0x908e, 0x0300,
+	0x1120, 0x9016, 0x2009, 0x0002, 0x00b0, 0x908e, 0x0200, 0x1120,
+	0x9016, 0x2009, 0x0004, 0x0078, 0x908e, 0x0100, 0x1548, 0x9016,
+	0x2009, 0x0008, 0x0040, 0x9084, 0x0700, 0x908e, 0x0300, 0x1500,
+	0x2011, 0x0030, 0x0058, 0x2300, 0x9080, 0x0020, 0x2018, 0x080c,
+	0x8277, 0x928c, 0xff00, 0x0110, 0x2011, 0x00ff, 0x2200, 0x8007,
+	0x9085, 0x004c, 0x78c2, 0x2009, 0x0138, 0x220a, 0x080c, 0x6faa,
+	0x1118, 0x2009, 0x1945, 0x220a, 0x002e, 0x001e, 0x00fe, 0x0005,
+	0x78c3, 0x0000, 0x0cc8, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016,
+	0x0026, 0x2001, 0x0170, 0x200c, 0x8000, 0x2014, 0x9184, 0x0003,
+	0x0110, 0x080c, 0x0dad, 0x002e, 0x001e, 0x000e, 0x012e, 0x0005,
+	0x2001, 0x0171, 0x2004, 0xd0dc, 0x0168, 0x2001, 0x0170, 0x200c,
+	0x918c, 0x00ff, 0x918e, 0x004c, 0x1128, 0x200c, 0x918c, 0xff00,
+	0x810f, 0x0005, 0x900e, 0x2001, 0x0227, 0x2004, 0x8007, 0x9084,
+	0x00ff, 0x8004, 0x9108, 0x2001, 0x0226, 0x2004, 0x8007, 0x9084,
+	0x00ff, 0x8004, 0x9108, 0x0005, 0x0018, 0x000c, 0x0018, 0x0020,
+	0x1000, 0x0800, 0x1000, 0x1800, 0x0156, 0x0006, 0x0016, 0x0026,
+	0x00e6, 0x2001, 0x1968, 0x2004, 0x908a, 0x0007, 0x1a0c, 0x0db4,
+	0x0033, 0x00ee, 0x002e, 0x001e, 0x000e, 0x015e, 0x0005, 0x27ce,
+	0x27ec, 0x2810, 0x2812, 0x283b, 0x283d, 0x283f, 0x2001, 0x0001,
+	0x080c, 0x2619, 0x080c, 0x2a2d, 0x2001, 0x196a, 0x2003, 0x0000,
+	0x7828, 0x9084, 0xe1d7, 0x782a, 0x9006, 0x20a9, 0x0009, 0x080c,
+	0x29eb, 0x2001, 0x1968, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011,
+	0x2840, 0x080c, 0x80d1, 0x0005, 0x2009, 0x196d, 0x200b, 0x0000,
+	0x2001, 0x1972, 0x2003, 0x0036, 0x2001, 0x1971, 0x2003, 0x002a,
+	0x2001, 0x196a, 0x2003, 0x0001, 0x9006, 0x080c, 0x299d, 0x2001,
+	0xffff, 0x20a9, 0x0009, 0x080c, 0x29eb, 0x2001, 0x1968, 0x2003,
+	0x0006, 0x2009, 0x001e, 0x2011, 0x2840, 0x080c, 0x80d1, 0x0005,
+	0x080c, 0x0db4, 0x2001, 0x1972, 0x2003, 0x0036, 0x2001, 0x196a,
+	0x2003, 0x0003, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0004, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x299d, 0x2001, 0x196e,
+	0x2003, 0x0000, 0x2001, 0xffff, 0x20a9, 0x0009, 0x080c, 0x29eb,
+	0x2001, 0x1968, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x2840,
+	0x080c, 0x80d1, 0x0005, 0x080c, 0x0db4, 0x080c, 0x0db4, 0x0005,
+	0x0006, 0x0016, 0x0026, 0x00e6, 0x00f6, 0x0156, 0x0126, 0x2091,
+	0x8000, 0x2079, 0x0100, 0x2001, 0x196a, 0x2004, 0x908a, 0x0007,
+	0x1a0c, 0x0db4, 0x0043, 0x012e, 0x015e, 0x00fe, 0x00ee, 0x002e,
+	0x001e, 0x000e, 0x0005, 0x2862, 0x2882, 0x28c2, 0x28f2, 0x2916,
+	0x2926, 0x2928, 0x080c, 0x29df, 0x11b0, 0x7850, 0x9084, 0xefff,
+	0x7852, 0x2009, 0x1970, 0x2104, 0x7a38, 0x9294, 0x0005, 0x9296,
+	0x0004, 0x0110, 0xc08d, 0x0008, 0xc085, 0x200a, 0x2001, 0x1968,
+	0x2003, 0x0001, 0x0030, 0x080c, 0x294c, 0x2001, 0xffff, 0x080c,
+	0x27dd, 0x0005, 0x080c, 0x292a, 0x05e0, 0x2009, 0x1971, 0x2104,
+	0x8001, 0x200a, 0x080c, 0x29df, 0x1178, 0x7850, 0x9084, 0xefff,
+	0x7852, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0518, 0x2009,
+	0x1970, 0x2104, 0xc085, 0x200a, 0x2009, 0x196d, 0x2104, 0x8000,
+	0x200a, 0x9086, 0x0005, 0x0118, 0x080c, 0x2932, 0x00c0, 0x200b,
+	0x0000, 0x7a38, 0x9294, 0x0006, 0x9296, 0x0004, 0x0110, 0x9006,
+	0x0010, 0x2001, 0x0001, 0x080c, 0x29ba, 0x2001, 0x196a, 0x2003,
+	0x0002, 0x0028, 0x2001, 0x1968, 0x2003, 0x0003, 0x0010, 0x080c,
+	0x27ff, 0x0005, 0x080c, 0x292a, 0x0560, 0x2009, 0x1971, 0x2104,
+	0x8001, 0x200a, 0x080c, 0x29df, 0x1168, 0x7850, 0x9084, 0xefff,
+	0x7852, 0x2001, 0x1968, 0x2003, 0x0003, 0x2001, 0x1969, 0x2003,
+	0x0000, 0x00b8, 0x2009, 0x1971, 0x2104, 0x9005, 0x1118, 0x080c,
+	0x296f, 0x0010, 0x080c, 0x293f, 0x080c, 0x2932, 0x2009, 0x196d,
+	0x200b, 0x0000, 0x2001, 0x196a, 0x2003, 0x0001, 0x080c, 0x27ff,
+	0x0000, 0x0005, 0x04b9, 0x0508, 0x080c, 0x29df, 0x11b8, 0x7850,
+	0x9084, 0xefff, 0x7852, 0x2009, 0x196e, 0x2104, 0x8000, 0x200a,
+	0x9086, 0x0007, 0x0108, 0x0078, 0x2001, 0x1973, 0x2003, 0x000a,
+	0x2009, 0x1970, 0x2104, 0xc0fd, 0x200a, 0x0038, 0x0419, 0x2001,
+	0x196a, 0x2003, 0x0004, 0x080c, 0x282a, 0x0005, 0x0099, 0x0168,
+	0x080c, 0x29df, 0x1138, 0x7850, 0x9084, 0xefff, 0x7852, 0x080c,
+	0x2816, 0x0018, 0x0079, 0x080c, 0x282a, 0x0005, 0x080c, 0x0db4,
+	0x080c, 0x0db4, 0x2009, 0x1972, 0x2104, 0x8001, 0x200a, 0x090c,
+	0x298b, 0x0005, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x29ba, 0x0005, 0x7a38,
+	0x9294, 0x0006, 0x9296, 0x0006, 0x0110, 0x9006, 0x0010, 0x2001,
+	0x0001, 0x080c, 0x299d, 0x0005, 0x2009, 0x196d, 0x2104, 0x8000,
+	0x200a, 0x9086, 0x0005, 0x0108, 0x0068, 0x200b, 0x0000, 0x7a38,
+	0x9294, 0x0006, 0x9296, 0x0006, 0x0110, 0x9006, 0x0010, 0x2001,
+	0x0001, 0x04d9, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x29ba, 0x0005, 0x0086,
+	0x2001, 0x1970, 0x2004, 0x9084, 0x7fff, 0x090c, 0x0db4, 0x2009,
+	0x196f, 0x2144, 0x8846, 0x280a, 0x9844, 0x0dd8, 0xd08c, 0x1120,
+	0xd084, 0x1120, 0x080c, 0x0db4, 0x9006, 0x0010, 0x2001, 0x0001,
+	0x00a1, 0x008e, 0x0005, 0x0006, 0x0156, 0x2001, 0x1968, 0x20a9,
+	0x0009, 0x2003, 0x0000, 0x8000, 0x1f04, 0x2991, 0x2001, 0x196f,
+	0x2003, 0x8000, 0x015e, 0x000e, 0x0005, 0x00f6, 0x2079, 0x0100,
+	0x9085, 0x0000, 0x0158, 0x7838, 0x9084, 0xfff9, 0x9085, 0x0004,
+	0x783a, 0x2009, 0x1975, 0x210c, 0x795a, 0x0050, 0x7838, 0x9084,
+	0xfffb, 0x9085, 0x0006, 0x783a, 0x2009, 0x1976, 0x210c, 0x795a,
+	0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100, 0x9085, 0x0000, 0x0138,
+	0x7838, 0x9084, 0xfffa, 0x9085, 0x0004, 0x783a, 0x0030, 0x7838,
+	0x9084, 0xfffb, 0x9085, 0x0005, 0x783a, 0x00fe, 0x0005, 0x0006,
+	0x2001, 0x0100, 0x2004, 0x9082, 0x0007, 0x000e, 0x0005, 0x0006,
+	0x2001, 0x0100, 0x2004, 0x9082, 0x0009, 0x000e, 0x0005, 0x0156,
+	0x20a9, 0x0064, 0x7820, 0x080c, 0x2a6a, 0xd09c, 0x1110, 0x1f04,
+	0x29e2, 0x015e, 0x0005, 0x0126, 0x0016, 0x0006, 0x2091, 0x8000,
+	0x7850, 0x9085, 0x0040, 0x7852, 0x7850, 0x9084, 0xfbcf, 0x7852,
+	0x080c, 0x2a6a, 0x9085, 0x2000, 0x7852, 0x000e, 0x2008, 0x9186,
+	0x0000, 0x1118, 0x783b, 0x0007, 0x0090, 0x9186, 0x0001, 0x1118,
+	0x783b, 0x0006, 0x0060, 0x9186, 0x0002, 0x1118, 0x783b, 0x0005,
+	0x0030, 0x9186, 0x0003, 0x1118, 0x783b, 0x0004, 0x0000, 0x0006,
+	0x1d04, 0x2a18, 0x080c, 0x80f3, 0x1f04, 0x2a18, 0x7850, 0x9085,
+	0x0400, 0x9084, 0xdfbf, 0x7852, 0x080c, 0x2a6a, 0x9085, 0x1000,
+	0x7852, 0x000e, 0x001e, 0x012e, 0x0005, 0x7850, 0x9084, 0xffcf,
+	0x7852, 0x0005, 0x0006, 0x0156, 0x00f6, 0x2079, 0x0100, 0x20a9,
+	0x000a, 0x7854, 0xd0ac, 0x1130, 0x7820, 0xd0e4, 0x1140, 0x1f04,
+	0x2a3c, 0x0028, 0x7854, 0xd08c, 0x1110, 0x1f04, 0x2a42, 0x00fe,
+	0x015e, 0x000e, 0x0005, 0x1d04, 0x2a4b, 0x080c, 0x80f3, 0x1f04,
+	0x2a4b, 0x0005, 0x0006, 0x2001, 0x1974, 0x2004, 0x9086, 0x0000,
+	0x000e, 0x0005, 0x0006, 0x2001, 0x1974, 0x2004, 0x9086, 0x0001,
+	0x000e, 0x0005, 0x0006, 0x2001, 0x1974, 0x2004, 0x9086, 0x0002,
+	0x000e, 0x0005, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x0005,
+	0x0006, 0x2001, 0x1980, 0x2102, 0x000e, 0x0005, 0x2009, 0x0171,
+	0x2104, 0xd0dc, 0x0140, 0x2009, 0x0170, 0x2104, 0x200b, 0x0080,
+	0xa001, 0xa001, 0x200a, 0x0005, 0x0036, 0x0046, 0x2001, 0x0141,
+	0x200c, 0x918c, 0xff00, 0x9186, 0x2000, 0x0118, 0x9186, 0x0100,
+	0x1588, 0x2009, 0x00a2, 0x080c, 0x0e2f, 0x2019, 0x0160, 0x2324,
+	0x2011, 0x0003, 0x2009, 0x0169, 0x2104, 0x9084, 0x0007, 0x210c,
+	0x918c, 0x0007, 0x910e, 0x1db0, 0x9086, 0x0003, 0x11b8, 0x2304,
+	0x9402, 0x02a0, 0x1d60, 0x8211, 0x1d68, 0x84ff, 0x0170, 0x2001,
+	0x0141, 0x200c, 0x918c, 0xff00, 0x9186, 0x0100, 0x0130, 0x2009,
+	0x180c, 0x2104, 0xc0dd, 0x200a, 0x0008, 0x0419, 0x2009, 0x0000,
+	0x080c, 0x0e2f, 0x004e, 0x003e, 0x0005, 0x2001, 0x180c, 0x2004,
+	0xd0dc, 0x01b0, 0x2001, 0x0160, 0x2004, 0x9005, 0x0140, 0x2001,
+	0x0141, 0x2004, 0x9084, 0xff00, 0x9086, 0x0100, 0x1148, 0x0126,
+	0x2091, 0x8000, 0x0016, 0x0026, 0x0021, 0x002e, 0x001e, 0x012e,
+	0x0005, 0x00c6, 0x2061, 0x0100, 0x6014, 0x0006, 0x2001, 0x0161,
+	0x2003, 0x0000, 0x6017, 0x0018, 0xa001, 0xa001, 0x602f, 0x0008,
+	0x6104, 0x918e, 0x0010, 0x6106, 0x918e, 0x0010, 0x6106, 0x6017,
+	0x0040, 0x04b9, 0x001e, 0x9184, 0x0003, 0x01e0, 0x0036, 0x0016,
+	0x2019, 0x0141, 0x6124, 0x918c, 0x0028, 0x1120, 0x2304, 0x9084,
+	0x2800, 0x0dc0, 0x001e, 0x919c, 0xffe4, 0x9184, 0x0001, 0x0118,
+	0x9385, 0x0009, 0x6016, 0x9184, 0x0002, 0x0118, 0x9385, 0x0012,
+	0x6016, 0x003e, 0x2001, 0x180c, 0x200c, 0xc1dc, 0x2102, 0x00ce,
+	0x0005, 0x0016, 0x0026, 0x080c, 0x6fc4, 0x0108, 0xc0bc, 0x2009,
+	0x0140, 0x2114, 0x9294, 0x0001, 0x9215, 0x220a, 0x002e, 0x001e,
+	0x0005, 0x0016, 0x0026, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001,
+	0x9285, 0x1000, 0x200a, 0x220a, 0x002e, 0x001e, 0x0005, 0x0016,
+	0x0026, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001, 0x9215, 0x220a,
+	0x002e, 0x001e, 0x0005, 0x0006, 0x0016, 0x2009, 0x0140, 0x2104,
+	0x1128, 0x080c, 0x6fc4, 0x0110, 0xc0bc, 0x0008, 0xc0bd, 0x200a,
+	0x001e, 0x000e, 0x0005, 0x2dc7, 0x2dc7, 0x2beb, 0x2beb, 0x2bf7,
+	0x2bf7, 0x2c03, 0x2c03, 0x2c11, 0x2c11, 0x2c1d, 0x2c1d, 0x2c2b,
+	0x2c2b, 0x2c39, 0x2c39, 0x2c4b, 0x2c4b, 0x2c57, 0x2c57, 0x2c65,
+	0x2c65, 0x2c83, 0x2c83, 0x2ca3, 0x2ca3, 0x2c73, 0x2c73, 0x2c93,
+	0x2c93, 0x2cb1, 0x2cb1, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2cc3, 0x2cc3, 0x2ccf, 0x2ccf, 0x2cdd,
+	0x2cdd, 0x2ceb, 0x2ceb, 0x2cfb, 0x2cfb, 0x2d09, 0x2d09, 0x2d19,
+	0x2d19, 0x2d29, 0x2d29, 0x2d3b, 0x2d3b, 0x2d49, 0x2d49, 0x2d59,
+	0x2d59, 0x2d7b, 0x2d7b, 0x2d9d, 0x2d9d, 0x2d69, 0x2d69, 0x2d8c,
+	0x2d8c, 0x2dac, 0x2dac, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49, 0x2c49,
+	0x2c49, 0x2c49, 0x2c49, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2320, 0x0804, 0x2dbf, 0x0106,
+	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
+	0x2138, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2138, 0x080c, 0x2320, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2173, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2320, 0x080c,
+	0x2173, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2138, 0x080c, 0x2173, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2138, 0x080c, 0x2320, 0x080c, 0x2173, 0x0804,
+	0x2dbf, 0xa001, 0x0cf0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x130c, 0x0804, 0x2dbf, 0x0106,
+	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
+	0x2320, 0x080c, 0x130c, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2138, 0x080c,
+	0x130c, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2320, 0x080c, 0x130c, 0x080c,
+	0x2173, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2138, 0x080c, 0x2320, 0x080c,
+	0x130c, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2138, 0x080c, 0x130c, 0x080c,
+	0x2173, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x130c, 0x080c, 0x2173, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2138, 0x080c, 0x2320, 0x080c, 0x130c, 0x080c,
+	0x2173, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x0804, 0x2dbf, 0x0106,
+	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
+	0x2773, 0x080c, 0x2320, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x080c,
+	0x2138, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x080c, 0x2138, 0x080c,
+	0x2320, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x080c, 0x2173, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2773, 0x080c, 0x2320, 0x080c, 0x2173, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2773, 0x080c, 0x2138, 0x080c, 0x2173, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2773, 0x080c, 0x2138, 0x080c, 0x2320, 0x080c,
+	0x2173, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x080c, 0x130c, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2773, 0x080c, 0x2320, 0x080c, 0x130c, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2773, 0x080c, 0x2138, 0x080c, 0x130c, 0x0804,
+	0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x0156, 0x080c, 0x2773, 0x080c, 0x2320, 0x080c, 0x130c, 0x080c,
+	0x2173, 0x0804, 0x2dbf, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x080c, 0x2138, 0x080c,
+	0x2320, 0x080c, 0x130c, 0x0498, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x080c, 0x2138,
+	0x080c, 0x130c, 0x080c, 0x2173, 0x0410, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x080c,
+	0x130c, 0x080c, 0x2173, 0x0098, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2773, 0x080c, 0x2138,
+	0x080c, 0x2320, 0x080c, 0x130c, 0x080c, 0x2173, 0x0000, 0x015e,
+	0x014e, 0x013e, 0x01de, 0x01ce, 0x012e, 0x000e, 0x010e, 0x000d,
+	0x00b6, 0x00c6, 0x0026, 0x0046, 0x9026, 0x080c, 0x6538, 0x1904,
+	0x2ece, 0x72d8, 0x2001, 0x1954, 0x2004, 0x9005, 0x1110, 0xd29c,
+	0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904, 0x2ece, 0x080c, 0x2ed3,
+	0x0804, 0x2ece, 0xd2cc, 0x1904, 0x2ece, 0x080c, 0x6faa, 0x1120,
+	0x70ab, 0xffff, 0x0804, 0x2ece, 0xd294, 0x0120, 0x70ab, 0xffff,
+	0x0804, 0x2ece, 0x080c, 0x313b, 0x0160, 0x080c, 0xc23b, 0x0128,
+	0x2001, 0x1817, 0x203c, 0x0804, 0x2e60, 0x70ab, 0xffff, 0x0804,
+	0x2ece, 0x2001, 0x1817, 0x203c, 0x7290, 0xd284, 0x0904, 0x2e60,
+	0xd28c, 0x1904, 0x2e60, 0x0036, 0x73a8, 0x938e, 0xffff, 0x1110,
+	0x2019, 0x0001, 0x8314, 0x92e0, 0x1c80, 0x2c04, 0x938c, 0x0001,
+	0x0120, 0x9084, 0xff00, 0x8007, 0x0010, 0x9084, 0x00ff, 0x970e,
+	0x05a8, 0x908e, 0x0000, 0x0590, 0x908e, 0x00ff, 0x1150, 0x7230,
+	0xd284, 0x1588, 0x7290, 0xc28d, 0x7292, 0x70ab, 0xffff, 0x003e,
+	0x0478, 0x0026, 0x2011, 0x0010, 0x080c, 0x659e, 0x002e, 0x0118,
+	0x70ab, 0xffff, 0x0410, 0x900e, 0x080c, 0x2670, 0x080c, 0x61f6,
+	0x11c0, 0x080c, 0x657a, 0x1168, 0x7030, 0xd08c, 0x0130, 0xb800,
+	0xd0bc, 0x0138, 0x080c, 0x6476, 0x0120, 0x080c, 0x2eec, 0x0148,
+	0x0028, 0x080c, 0x302c, 0x080c, 0x2f18, 0x0118, 0x8318, 0x0804,
+	0x2e12, 0x73aa, 0x0010, 0x70ab, 0xffff, 0x003e, 0x0804, 0x2ece,
+	0x9780, 0x3145, 0x203d, 0x97bc, 0xff00, 0x873f, 0x2041, 0x007e,
+	0x70a8, 0x9096, 0xffff, 0x1118, 0x900e, 0x28a8, 0x0050, 0x9812,
+	0x0220, 0x2008, 0x9802, 0x20a8, 0x0020, 0x70ab, 0xffff, 0x0804,
+	0x2ece, 0x2700, 0x0156, 0x0016, 0x9106, 0x0904, 0x2ec3, 0x0026,
+	0x2011, 0x0010, 0x080c, 0x659e, 0x002e, 0x0120, 0x2009, 0xffff,
+	0x0804, 0x2ecb, 0xc484, 0x080c, 0x6256, 0x0138, 0x080c, 0xc23b,
+	0x1590, 0x080c, 0x61f6, 0x15b8, 0x0008, 0xc485, 0x080c, 0x657a,
+	0x1130, 0x7030, 0xd08c, 0x01f8, 0xb800, 0xd0bc, 0x11e0, 0x7290,
+	0xd28c, 0x0180, 0x080c, 0x657a, 0x9082, 0x0006, 0x02e0, 0xd484,
+	0x1118, 0x080c, 0x621a, 0x0028, 0x080c, 0x30b7, 0x01a0, 0x080c,
+	0x30e2, 0x0088, 0x080c, 0x302c, 0x080c, 0xc23b, 0x1160, 0x080c,
+	0x2f18, 0x0188, 0x0040, 0x080c, 0xc23b, 0x1118, 0x080c, 0x30b7,
+	0x0110, 0x0451, 0x0140, 0x001e, 0x8108, 0x015e, 0x1f04, 0x2e79,
+	0x70ab, 0xffff, 0x0018, 0x001e, 0x015e, 0x71aa, 0x004e, 0x002e,
+	0x00ce, 0x00be, 0x0005, 0x00c6, 0x0016, 0x70ab, 0x0001, 0x2009,
+	0x007e, 0x080c, 0x61f6, 0x1168, 0xb813, 0x00ff, 0xb817, 0xfffe,
+	0x080c, 0x302c, 0x04a9, 0x0128, 0x70d8, 0xc0bd, 0x70da, 0x080c,
+	0xbf8c, 0x001e, 0x00ce, 0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6,
+	0x2001, 0x1860, 0x2004, 0x9084, 0x00ff, 0xb842, 0x080c, 0x9e7c,
+	0x01d0, 0x2b00, 0x6012, 0x080c, 0xbfb5, 0x6023, 0x0001, 0x9006,
+	0x080c, 0x6193, 0x2001, 0x0000, 0x080c, 0x61a7, 0x0126, 0x2091,
+	0x8000, 0x70a4, 0x8000, 0x70a6, 0x012e, 0x2009, 0x0004, 0x080c,
+	0x9ea9, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005,
+	0x0016, 0x0076, 0x00d6, 0x00c6, 0x2001, 0x1860, 0x2004, 0x9084,
+	0x00ff, 0xb842, 0x080c, 0x9e7c, 0x0548, 0x2b00, 0x6012, 0xb800,
+	0xc0c4, 0xb802, 0xb8a0, 0x9086, 0x007e, 0x0140, 0xb804, 0x9084,
+	0x00ff, 0x9086, 0x0006, 0x1110, 0x080c, 0x2fe7, 0x080c, 0xbfb5,
+	0x6023, 0x0001, 0x9006, 0x080c, 0x6193, 0x2001, 0x0002, 0x080c,
+	0x61a7, 0x0126, 0x2091, 0x8000, 0x70a4, 0x8000, 0x70a6, 0x012e,
+	0x2009, 0x0002, 0x080c, 0x9ea9, 0x9085, 0x0001, 0x00ce, 0x00de,
+	0x007e, 0x001e, 0x0005, 0x00b6, 0x00c6, 0x0026, 0x2009, 0x0080,
+	0x080c, 0x61f6, 0x1140, 0xb813, 0x00ff, 0xb817, 0xfffc, 0x0039,
+	0x0110, 0x70df, 0xffff, 0x002e, 0x00ce, 0x00be, 0x0005, 0x0016,
+	0x0076, 0x00d6, 0x00c6, 0x080c, 0x9dd9, 0x01d0, 0x2b00, 0x6012,
+	0x080c, 0xbfb5, 0x6023, 0x0001, 0x9006, 0x080c, 0x6193, 0x2001,
+	0x0002, 0x080c, 0x61a7, 0x0126, 0x2091, 0x8000, 0x70e0, 0x8000,
+	0x70e2, 0x012e, 0x2009, 0x0002, 0x080c, 0x9ea9, 0x9085, 0x0001,
+	0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00c6, 0x00d6, 0x0126,
+	0x2091, 0x8000, 0x2009, 0x007f, 0x080c, 0x61f6, 0x11b8, 0xb813,
+	0x00ff, 0xb817, 0xfffd, 0xb8bf, 0x0004, 0x080c, 0x9dd9, 0x0170,
+	0x2b00, 0x6012, 0x6316, 0x6023, 0x0001, 0x620a, 0x080c, 0xbfb5,
+	0x2009, 0x0022, 0x080c, 0x9ea9, 0x9085, 0x0001, 0x012e, 0x00de,
+	0x00ce, 0x0005, 0x00e6, 0x00c6, 0x0066, 0x0036, 0x0026, 0x00b6,
+	0x21f0, 0x080c, 0x858d, 0x080c, 0x8517, 0x080c, 0x9c82, 0x080c,
+	0xad86, 0x3e08, 0x2130, 0x81ff, 0x0120, 0x20a9, 0x007e, 0x900e,
+	0x0018, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6256, 0x1140,
+	0x9686, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x1110, 0x080c, 0x5cff,
+	0x001e, 0x8108, 0x1f04, 0x2fcc, 0x9686, 0x0001, 0x190c, 0x310f,
+	0x00be, 0x002e, 0x003e, 0x006e, 0x00ce, 0x00ee, 0x0005, 0x00e6,
+	0x00c6, 0x0046, 0x0036, 0x0026, 0x0016, 0x00b6, 0x6210, 0x2258,
+	0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c, 0x8582, 0x0076, 0x2039,
+	0x0000, 0x080c, 0x8470, 0x2c08, 0x080c, 0xd2d5, 0x007e, 0x001e,
+	0xba10, 0xbb14, 0xbcb0, 0x080c, 0x5cff, 0xba12, 0xbb16, 0xbcb2,
+	0x00be, 0x001e, 0x002e, 0x003e, 0x004e, 0x00ce, 0x00ee, 0x0005,
+	0x00e6, 0x0006, 0x00b6, 0x6010, 0x2058, 0xb8a0, 0x00be, 0x9086,
+	0x0080, 0x0150, 0x2071, 0x1800, 0x70a4, 0x9005, 0x0110, 0x8001,
+	0x70a6, 0x000e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x70e0, 0x9005,
+	0x0dc0, 0x8001, 0x70e2, 0x0ca8, 0xb800, 0xc08c, 0xb802, 0x0005,
+	0x00f6, 0x00e6, 0x00c6, 0x00b6, 0x0046, 0x0036, 0x0026, 0x0016,
+	0x0156, 0x2178, 0x81ff, 0x1118, 0x20a9, 0x0001, 0x0070, 0x080c,
+	0x539a, 0xd0c4, 0x0138, 0x0030, 0x9006, 0x2020, 0x2009, 0x002d,
+	0x080c, 0xd564, 0x20a9, 0x0800, 0x9016, 0x0026, 0x928e, 0x007e,
+	0x0904, 0x3096, 0x928e, 0x007f, 0x0904, 0x3096, 0x928e, 0x0080,
+	0x05e8, 0x9288, 0x1000, 0x210c, 0x81ff, 0x05c0, 0x8fff, 0x1148,
+	0x2001, 0x1966, 0x0006, 0x2003, 0x0001, 0x04f1, 0x000e, 0x2003,
+	0x0000, 0x00b6, 0x00c6, 0x2158, 0x2001, 0x0001, 0x080c, 0x6544,
+	0x00ce, 0x00be, 0x2019, 0x0029, 0x080c, 0x8582, 0x0076, 0x2039,
+	0x0000, 0x080c, 0x8470, 0x00b6, 0x00c6, 0x0026, 0x2158, 0xba04,
+	0x9294, 0x00ff, 0x9286, 0x0006, 0x1118, 0xb807, 0x0404, 0x0028,
+	0x2001, 0x0004, 0x8007, 0x9215, 0xba06, 0x002e, 0x00ce, 0x00be,
+	0x0016, 0x2c08, 0x080c, 0xd2d5, 0x001e, 0x007e, 0x002e, 0x8210,
+	0x1f04, 0x304d, 0x015e, 0x001e, 0x002e, 0x003e, 0x004e, 0x00be,
+	0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0046, 0x0026, 0x0016, 0x080c,
+	0x539a, 0xd0c4, 0x0140, 0xd0a4, 0x0130, 0x9006, 0x2220, 0x2009,
+	0x0029, 0x080c, 0xd564, 0x001e, 0x002e, 0x004e, 0x0005, 0x0016,
+	0x0026, 0x0036, 0x00c6, 0x7290, 0x82ff, 0x01e8, 0x080c, 0x6572,
+	0x11d0, 0x2100, 0x080c, 0x26a3, 0x81ff, 0x01b8, 0x2019, 0x0001,
+	0x8314, 0x92e0, 0x1c80, 0x2c04, 0xd384, 0x0120, 0x9084, 0xff00,
+	0x8007, 0x0010, 0x9084, 0x00ff, 0x9116, 0x0138, 0x9096, 0x00ff,
+	0x0110, 0x8318, 0x0c68, 0x9085, 0x0001, 0x00ce, 0x003e, 0x002e,
+	0x001e, 0x0005, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x0036,
+	0x2019, 0x0029, 0x00a9, 0x003e, 0x9180, 0x1000, 0x2004, 0x9065,
+	0x0158, 0x0016, 0x00c6, 0x2061, 0x1a87, 0x001e, 0x6112, 0x080c,
+	0x2fe7, 0x001e, 0x080c, 0x621a, 0x012e, 0x00ce, 0x001e, 0x0005,
+	0x0016, 0x0026, 0x2110, 0x080c, 0x9915, 0x080c, 0xd81c, 0x002e,
+	0x001e, 0x0005, 0x2001, 0x1836, 0x2004, 0xd0cc, 0x0005, 0x00c6,
+	0x00b6, 0x080c, 0x6faa, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9,
+	0x0782, 0x080c, 0x6faa, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e,
+	0x9180, 0x1000, 0x2004, 0x905d, 0x0130, 0x86ff, 0x0110, 0xb800,
+	0xd0bc, 0x090c, 0x621a, 0x8108, 0x1f04, 0x3120, 0x2061, 0x1800,
+	0x607b, 0x0000, 0x607c, 0x9084, 0x00ff, 0x607e, 0x60af, 0x0000,
+	0x00be, 0x00ce, 0x0005, 0x2001, 0x187d, 0x2004, 0xd0bc, 0x0005,
+	0x2011, 0x185c, 0x2214, 0xd2ec, 0x0005, 0x7eef, 0x7de8, 0x7ce4,
+	0x80e2, 0x7be1, 0x80e0, 0x80dc, 0x80da, 0x7ad9, 0x80d6, 0x80d5,
+	0x80d4, 0x80d3, 0x80d2, 0x80d1, 0x79ce, 0x78cd, 0x80cc, 0x80cb,
+	0x80ca, 0x80c9, 0x80c7, 0x80c6, 0x77c5, 0x76c3, 0x80bc, 0x80ba,
+	0x75b9, 0x80b6, 0x74b5, 0x73b4, 0x72b3, 0x80b2, 0x80b1, 0x80ae,
+	0x71ad, 0x80ac, 0x70ab, 0x6faa, 0x6ea9, 0x80a7, 0x6da6, 0x6ca5,
+	0x6ba3, 0x6a9f, 0x699e, 0x689d, 0x809b, 0x8098, 0x6797, 0x6690,
+	0x658f, 0x6488, 0x6384, 0x6282, 0x8081, 0x8080, 0x617c, 0x607a,
+	0x8079, 0x5f76, 0x8075, 0x8074, 0x8073, 0x8072, 0x8071, 0x806e,
+	0x5e6d, 0x806c, 0x5d6b, 0x5c6a, 0x5b69, 0x8067, 0x5a66, 0x5965,
+	0x5863, 0x575c, 0x565a, 0x5559, 0x8056, 0x8055, 0x5454, 0x5353,
+	0x5252, 0x5151, 0x504e, 0x4f4d, 0x804c, 0x804b, 0x4e4a, 0x4d49,
+	0x8047, 0x4c46, 0x8045, 0x8043, 0x803c, 0x803a, 0x8039, 0x8036,
+	0x4b35, 0x8034, 0x4a33, 0x4932, 0x4831, 0x802e, 0x472d, 0x462c,
+	0x452b, 0x442a, 0x4329, 0x4227, 0x8026, 0x8025, 0x4123, 0x401f,
+	0x3f1e, 0x3e1d, 0x3d1b, 0x3c18, 0x8017, 0x8010, 0x3b0f, 0x3a08,
+	0x8004, 0x3902, 0x8001, 0x8000, 0x8000, 0x3800, 0x3700, 0x3600,
+	0x8000, 0x3500, 0x8000, 0x8000, 0x8000, 0x3400, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x3300, 0x3200, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x3100, 0x3000, 0x8000, 0x8000,
+	0x2f00, 0x8000, 0x2e00, 0x2d00, 0x2c00, 0x8000, 0x8000, 0x8000,
+	0x2b00, 0x8000, 0x2a00, 0x2900, 0x2800, 0x8000, 0x2700, 0x2600,
+	0x2500, 0x2400, 0x2300, 0x2200, 0x8000, 0x8000, 0x2100, 0x2000,
+	0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x8000, 0x8000, 0x1b00, 0x1a00,
+	0x8000, 0x1900, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x1800, 0x8000, 0x1700, 0x1600, 0x1500, 0x8000, 0x1400, 0x1300,
+	0x1200, 0x1100, 0x1000, 0x0f00, 0x8000, 0x8000, 0x0e00, 0x0d00,
+	0x0c00, 0x0b00, 0x0a00, 0x0900, 0x8000, 0x8000, 0x0800, 0x0700,
+	0x8000, 0x0600, 0x8000, 0x8000, 0x8000, 0x0500, 0x0400, 0x0300,
+	0x8000, 0x0200, 0x8000, 0x8000, 0x8000, 0x0100, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x8000, 0x8000, 0x8000,
 	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
-	0x8000, 0x8000, 0x2071, 0x1894, 0x7003, 0x0002, 0x9006, 0x7016,
-	0x701a, 0x704a, 0x704e, 0x700e, 0x7042, 0x7046, 0x703b, 0x18b0,
-	0x703f, 0x18b0, 0x7007, 0x0001, 0x080c, 0x1004, 0x090c, 0x0db4,
-	0x2900, 0x706a, 0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x080c, 0x1004,
-	0x090c, 0x0db4, 0x2900, 0x706e, 0xa867, 0x0002, 0xa8ab, 0xdcb0,
-	0x0005, 0x2071, 0x1894, 0x7004, 0x0002, 0x3269, 0x326a, 0x327d,
-	0x3291, 0x0005, 0x1004, 0x327a, 0x0e04, 0x327a, 0x2079, 0x0000,
-	0x0126, 0x2091, 0x8000, 0x700c, 0x9005, 0x1128, 0x700f, 0x0001,
-	0x012e, 0x0468, 0x0005, 0x012e, 0x0ce8, 0x2079, 0x0000, 0x2061,
-	0x18ae, 0x2c4c, 0xa86c, 0x908e, 0x0100, 0x0128, 0x9086, 0x0200,
-	0x0904, 0x3365, 0x0005, 0x7018, 0x2048, 0x2061, 0x1800, 0x701c,
-	0x0807, 0x7014, 0x2048, 0xa864, 0x9094, 0x00ff, 0x9296, 0x0029,
-	0x1120, 0xaa78, 0xd2fc, 0x0128, 0x0005, 0x9086, 0x0103, 0x0108,
-	0x0005, 0x2079, 0x0000, 0x2061, 0x1800, 0x701c, 0x0807, 0x2061,
-	0x1800, 0x7880, 0x908a, 0x0040, 0x1210, 0x61cc, 0x0042, 0x2100,
-	0x908a, 0x003f, 0x1a04, 0x3362, 0x61cc, 0x0804, 0x32f7, 0x3339,
-	0x3371, 0x3362, 0x337b, 0x3385, 0x338b, 0x338f, 0x339f, 0x33a3,
-	0x33b9, 0x33bf, 0x33c5, 0x33d0, 0x33db, 0x33ea, 0x33f9, 0x3407,
-	0x341e, 0x3439, 0x3362, 0x34e2, 0x3520, 0x35c6, 0x35d7, 0x35fa,
-	0x3362, 0x3362, 0x3362, 0x3632, 0x364e, 0x3657, 0x3686, 0x368c,
-	0x3362, 0x36d2, 0x3362, 0x3362, 0x3362, 0x3362, 0x3362, 0x36dd,
-	0x36e6, 0x36ee, 0x36f0, 0x3362, 0x3362, 0x3362, 0x3362, 0x3362,
-	0x3362, 0x371c, 0x3362, 0x3362, 0x3362, 0x3362, 0x3362, 0x3739,
-	0x3794, 0x3362, 0x3362, 0x3362, 0x3362, 0x3362, 0x3362, 0x0002,
-	0x37be, 0x37c1, 0x3820, 0x3839, 0x3869, 0x3b07, 0x3362, 0x4f68,
-	0x3362, 0x3362, 0x3362, 0x3362, 0x3362, 0x3362, 0x3362, 0x3362,
-	0x33b9, 0x33bf, 0x4028, 0x53b3, 0x403e, 0x4ff7, 0x5048, 0x514b,
-	0x3362, 0x51ad, 0x51e9, 0x521a, 0x531e, 0x5247, 0x529e, 0x3362,
-	0x4042, 0x41e3, 0x41f9, 0x421e, 0x4283, 0x42f7, 0x4317, 0x438e,
-	0x43ea, 0x4446, 0x4449, 0x446e, 0x450e, 0x4574, 0x457c, 0x46ae,
-	0x4813, 0x4847, 0x4a91, 0x3362, 0x4aaf, 0x4b6b, 0x4c41, 0x3362,
-	0x3362, 0x3362, 0x3362, 0x4ca7, 0x4cc2, 0x457c, 0x4f08, 0x714c,
-	0x0000, 0x2021, 0x4000, 0x080c, 0x48c5, 0x0126, 0x2091, 0x8000,
-	0x0e04, 0x3343, 0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000,
-	0x0118, 0x7833, 0x0011, 0x0010, 0x7833, 0x0010, 0x7c82, 0x7986,
-	0x7a8a, 0x7b8e, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x1187, 0x7007, 0x0001, 0x2091, 0x5000, 0x700f, 0x0000,
-	0x012e, 0x0005, 0x2021, 0x4001, 0x08b0, 0x2021, 0x4002, 0x0898,
-	0x2021, 0x4003, 0x0880, 0x2021, 0x4005, 0x0868, 0x2021, 0x4006,
-	0x0850, 0x2039, 0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884,
-	0x7990, 0x0804, 0x48d2, 0x2039, 0x0001, 0x902e, 0x2520, 0x7b88,
-	0x7a8c, 0x7884, 0x7990, 0x0804, 0x48d5, 0x7984, 0x7888, 0x2114,
-	0x200a, 0x0804, 0x3339, 0x7984, 0x2114, 0x0804, 0x3339, 0x20e1,
-	0x0000, 0x2099, 0x0021, 0x20e9, 0x0000, 0x20a1, 0x0021, 0x20a9,
-	0x001f, 0x4003, 0x7984, 0x7a88, 0x7b8c, 0x0804, 0x3339, 0x7884,
-	0x2060, 0x0804, 0x33ec, 0x2009, 0x0003, 0x2011, 0x0002, 0x2019,
-	0x001e, 0x789b, 0x0317, 0x7893, 0xffff, 0x2001, 0x1885, 0x2004,
-	0x9005, 0x0118, 0x7896, 0x0804, 0x3339, 0x7897, 0x0001, 0x0804,
-	0x3339, 0x2039, 0x0001, 0x7d98, 0x7c9c, 0x0804, 0x3375, 0x2039,
-	0x0001, 0x7d98, 0x7c9c, 0x0804, 0x337f, 0x79a0, 0x9182, 0x0040,
-	0x0210, 0x0804, 0x336e, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x3375,
-	0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x336e, 0x2138, 0x7d98,
-	0x7c9c, 0x0804, 0x337f, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804,
-	0x336e, 0x21e8, 0x7984, 0x7888, 0x20a9, 0x0001, 0x21a0, 0x4004,
-	0x0804, 0x3339, 0x2061, 0x0800, 0xe10c, 0x9006, 0x2c15, 0x9200,
-	0x8c60, 0x8109, 0x1dd8, 0x2010, 0x9005, 0x0904, 0x3339, 0x0804,
-	0x3368, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x336e, 0x21e0,
-	0x20a9, 0x0001, 0x7984, 0x2198, 0x4012, 0x0804, 0x3339, 0x2069,
-	0x1853, 0x7884, 0x7990, 0x911a, 0x1a04, 0x336e, 0x8019, 0x0904,
-	0x336e, 0x684a, 0x6942, 0x788c, 0x6852, 0x7888, 0x6856, 0x9006,
-	0x685a, 0x685e, 0x080c, 0x72b0, 0x0804, 0x3339, 0x2069, 0x1853,
-	0x7884, 0x7994, 0x911a, 0x1a04, 0x336e, 0x8019, 0x0904, 0x336e,
-	0x684e, 0x6946, 0x788c, 0x6862, 0x7888, 0x6866, 0x9006, 0x686a,
-	0x686e, 0x0126, 0x2091, 0x8000, 0x080c, 0x6669, 0x012e, 0x0804,
-	0x3339, 0x902e, 0x2520, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804,
-	0x336b, 0x7984, 0x7b88, 0x7a8c, 0x20a9, 0x0005, 0x20e9, 0x0001,
-	0x20a1, 0x189c, 0x4101, 0x080c, 0x4889, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x336b, 0x2009, 0x0020, 0xa85c, 0x9080, 0x0019, 0xaf60,
-	0x080c, 0x48d2, 0x701f, 0x345d, 0x0005, 0xa864, 0x2008, 0x9084,
-	0x00ff, 0x9096, 0x0011, 0x0168, 0x9096, 0x0019, 0x0150, 0x9096,
-	0x0015, 0x0138, 0x9096, 0x0048, 0x0120, 0x9096, 0x0029, 0x1904,
-	0x336b, 0x810f, 0x918c, 0x00ff, 0x0904, 0x336b, 0x7112, 0x7010,
-	0x8001, 0x0560, 0x7012, 0x080c, 0x4889, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x336b, 0x2009, 0x0020, 0x7068, 0x2040, 0xa28c, 0xa390,
-	0xa494, 0xa598, 0x9290, 0x0040, 0x9399, 0x0000, 0x94a1, 0x0000,
-	0x95a9, 0x0000, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x48d2,
-	0x701f, 0x349b, 0x0005, 0xa864, 0x9084, 0x00ff, 0x9096, 0x0002,
-	0x0120, 0x9096, 0x000a, 0x1904, 0x336b, 0x0888, 0x7014, 0x2048,
-	0xa868, 0xc0fd, 0xa86a, 0xa864, 0x9084, 0x00ff, 0x9096, 0x0029,
-	0x1160, 0xc2fd, 0xaa7a, 0x080c, 0x5de6, 0x0150, 0x0126, 0x2091,
-	0x8000, 0xa87a, 0xa982, 0x012e, 0x0050, 0x080c, 0x60fd, 0x1128,
-	0x7007, 0x0003, 0x701f, 0x34c7, 0x0005, 0x080c, 0x6abf, 0x0126,
-	0x2091, 0x8000, 0x20a9, 0x0005, 0x20e1, 0x0001, 0x2099, 0x189c,
-	0x400a, 0x2100, 0x9210, 0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9,
-	0x0000, 0xa85c, 0x9080, 0x0019, 0x2009, 0x0020, 0x012e, 0xaf60,
-	0x0804, 0x48d5, 0x2091, 0x8000, 0x7837, 0x4000, 0x7833, 0x0010,
-	0x7883, 0x4000, 0x7887, 0x4953, 0x788b, 0x5020, 0x788f, 0x2020,
-	0x2009, 0x017f, 0x2104, 0x7892, 0x3f00, 0x7896, 0x2061, 0x0100,
-	0x6200, 0x2061, 0x0200, 0x603c, 0x8007, 0x9205, 0x789a, 0x2009,
-	0x04fd, 0x2104, 0x789e, 0x2091, 0x5000, 0x2091, 0x4080, 0x2001,
-	0x0089, 0x2004, 0xd084, 0x0180, 0x2001, 0x19e9, 0x2004, 0x9005,
-	0x0128, 0x2001, 0x008b, 0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a,
-	0x2003, 0x0002, 0x2003, 0x1001, 0x2071, 0x0080, 0x0804, 0x0427,
-	0x81ff, 0x1904, 0x336b, 0x7984, 0x080c, 0x6247, 0x1904, 0x336e,
-	0x7e98, 0x9684, 0x3fff, 0x9082, 0x4000, 0x1a04, 0x336e, 0x7c88,
-	0x7d8c, 0x080c, 0x63aa, 0x080c, 0x6379, 0x0000, 0x1518, 0x2061,
-	0x1cd0, 0x0126, 0x2091, 0x8000, 0x6000, 0x9086, 0x0000, 0x0148,
-	0x6014, 0x904d, 0x0130, 0xa86c, 0x9406, 0x1118, 0xa870, 0x9506,
-	0x0150, 0x012e, 0x9ce0, 0x0018, 0x2001, 0x1819, 0x2004, 0x9c02,
-	0x1a04, 0x336b, 0x0c30, 0x080c, 0xb75d, 0x012e, 0x0904, 0x336b,
-	0x0804, 0x3339, 0x900e, 0x2001, 0x0005, 0x080c, 0x6abf, 0x0126,
-	0x2091, 0x8000, 0x080c, 0xbe26, 0x080c, 0x6891, 0x012e, 0x0804,
-	0x3339, 0x00a6, 0x2950, 0xb198, 0x080c, 0x6247, 0x1904, 0x35b3,
-	0xb6a4, 0x9684, 0x3fff, 0x9082, 0x4000, 0x16e8, 0xb49c, 0xb5a0,
-	0x080c, 0x63aa, 0x080c, 0x6379, 0x1520, 0x2061, 0x1cd0, 0x0126,
-	0x2091, 0x8000, 0x6000, 0x9086, 0x0000, 0x0148, 0x6014, 0x904d,
-	0x0130, 0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0158, 0x012e,
-	0x9ce0, 0x0018, 0x2001, 0x1819, 0x2004, 0x9c02, 0x2009, 0x000d,
-	0x12b0, 0x0c28, 0x080c, 0xb75d, 0x012e, 0x2009, 0x0003, 0x0178,
-	0x00e0, 0x900e, 0x2001, 0x0005, 0x080c, 0x6abf, 0x0126, 0x2091,
-	0x8000, 0x080c, 0xbe26, 0x080c, 0x6884, 0x012e, 0x0070, 0xb097,
-	0x4005, 0xb19a, 0x0010, 0xb097, 0x4006, 0x900e, 0x9085, 0x0001,
-	0x2001, 0x0030, 0x2a48, 0x00ae, 0x0005, 0xb097, 0x4000, 0x9006,
-	0x918d, 0x0001, 0x2008, 0x2a48, 0x00ae, 0x0005, 0x81ff, 0x1904,
-	0x336b, 0x080c, 0x48a0, 0x0904, 0x336e, 0x080c, 0x630e, 0x0904,
-	0x336b, 0x080c, 0x63b0, 0x0904, 0x336b, 0x0804, 0x430e, 0x81ff,
-	0x1904, 0x336b, 0x080c, 0x48bc, 0x0904, 0x336e, 0x080c, 0x643e,
-	0x0904, 0x336b, 0x2019, 0x0005, 0x79a8, 0x080c, 0x63cb, 0x0904,
-	0x336b, 0x7888, 0x908a, 0x1000, 0x1a04, 0x336e, 0x8003, 0x800b,
-	0x810b, 0x9108, 0x080c, 0x802f, 0x7984, 0xd184, 0x1904, 0x3339,
-	0x0804, 0x430e, 0x0126, 0x2091, 0x8000, 0x81ff, 0x0118, 0x2009,
-	0x0001, 0x0450, 0x2029, 0x07ff, 0x6458, 0x2400, 0x9506, 0x01f8,
-	0x2508, 0x080c, 0x6247, 0x11d8, 0x080c, 0x643e, 0x1128, 0x2009,
-	0x0002, 0x62bc, 0x2518, 0x00c0, 0x2019, 0x0004, 0x900e, 0x080c,
-	0x63cb, 0x1118, 0x2009, 0x0006, 0x0078, 0x7884, 0x908a, 0x1000,
-	0x1270, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x802f, 0x8529,
-	0x1ae0, 0x012e, 0x0804, 0x3339, 0x012e, 0x0804, 0x336b, 0x012e,
-	0x0804, 0x336e, 0x080c, 0x48a0, 0x0904, 0x336e, 0x080c, 0x630e,
-	0x0904, 0x336b, 0xbaa0, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c,
-	0x8564, 0x0076, 0x903e, 0x080c, 0x8452, 0x900e, 0x080c, 0xd2bc,
-	0x007e, 0x00ce, 0x080c, 0x63aa, 0x0804, 0x3339, 0x080c, 0x48a0,
-	0x0904, 0x336e, 0x080c, 0x63aa, 0x2208, 0x0804, 0x3339, 0x0156,
-	0x00d6, 0x00e6, 0x2069, 0x1906, 0x6810, 0x6914, 0x910a, 0x1208,
-	0x900e, 0x6816, 0x9016, 0x901e, 0x20a9, 0x007e, 0x2069, 0x1000,
-	0x2d04, 0x905d, 0x0118, 0xb84c, 0x0059, 0x9210, 0x8d68, 0x1f04,
-	0x3668, 0x2300, 0x9218, 0x00ee, 0x00de, 0x015e, 0x0804, 0x3339,
-	0x00f6, 0x0016, 0x907d, 0x0138, 0x9006, 0x8000, 0x2f0c, 0x81ff,
-	0x0110, 0x2178, 0x0cd0, 0x001e, 0x00fe, 0x0005, 0x2069, 0x1906,
-	0x6910, 0x62b8, 0x0804, 0x3339, 0x81ff, 0x0120, 0x2009, 0x0001,
-	0x0804, 0x336b, 0x0126, 0x2091, 0x8000, 0x080c, 0x53a3, 0x0128,
-	0x2009, 0x0007, 0x012e, 0x0804, 0x336b, 0x012e, 0x6158, 0x9190,
-	0x313a, 0x2215, 0x9294, 0x00ff, 0x6378, 0x83ff, 0x0108, 0x627c,
-	0x67d8, 0x97c4, 0x000a, 0x98c6, 0x000a, 0x1118, 0x2031, 0x0001,
-	0x00e8, 0x97c4, 0x0022, 0x98c6, 0x0022, 0x1118, 0x2031, 0x0003,
-	0x00a8, 0x97c4, 0x0012, 0x98c6, 0x0012, 0x1118, 0x2031, 0x0002,
-	0x0068, 0x080c, 0x6f9b, 0x1118, 0x2031, 0x0004, 0x0038, 0xd79c,
-	0x0120, 0x2009, 0x0005, 0x0804, 0x336b, 0x9036, 0x7e9a, 0x7f9e,
-	0x0804, 0x3339, 0x6148, 0x624c, 0x2019, 0x1956, 0x231c, 0x2001,
-	0x1957, 0x2004, 0x789a, 0x0804, 0x3339, 0x0126, 0x2091, 0x8000,
-	0x6138, 0x623c, 0x6340, 0x012e, 0x0804, 0x3339, 0x080c, 0x48bc,
-	0x0904, 0x336e, 0xba44, 0xbb38, 0x0804, 0x3339, 0x080c, 0x0db4,
-	0x080c, 0x48bc, 0x2110, 0x0904, 0x336e, 0xb804, 0x908c, 0x00ff,
-	0x918e, 0x0006, 0x0140, 0x9084, 0xff00, 0x9086, 0x0600, 0x2009,
-	0x0009, 0x1904, 0x336b, 0x0126, 0x2091, 0x8000, 0x2019, 0x0005,
-	0x00c6, 0x9066, 0x080c, 0x992c, 0x080c, 0x8564, 0x0076, 0x903e,
-	0x080c, 0x8452, 0x900e, 0x080c, 0xd2bc, 0x007e, 0x00ce, 0xb807,
-	0x0407, 0x012e, 0x0804, 0x3339, 0x6148, 0x624c, 0x7884, 0x604a,
-	0x7b88, 0x634e, 0x2069, 0x1853, 0x831f, 0x9305, 0x6816, 0x788c,
-	0x2069, 0x1956, 0x2d1c, 0x206a, 0x7e98, 0x9682, 0x0014, 0x1210,
-	0x2031, 0x07d0, 0x2069, 0x1957, 0x2d04, 0x266a, 0x789a, 0x0804,
-	0x3339, 0x0126, 0x2091, 0x8000, 0x6138, 0x7884, 0x603a, 0x910e,
-	0xd1b4, 0x190c, 0x0e9b, 0xd0c4, 0x01a8, 0x00d6, 0x78a8, 0x2009,
-	0x196d, 0x200a, 0x78ac, 0x2011, 0x196e, 0x2012, 0x2069, 0x0100,
-	0x6838, 0x9086, 0x0007, 0x1118, 0x2214, 0x6a5a, 0x0010, 0x210c,
-	0x695a, 0x00de, 0x7888, 0x603e, 0x2011, 0x0114, 0x220c, 0x7888,
-	0xd08c, 0x0118, 0x918d, 0x0080, 0x0010, 0x918c, 0xff7f, 0x2112,
-	0x6140, 0x788c, 0x6042, 0x910e, 0xd1e4, 0x190c, 0x0eb1, 0x6040,
-	0xd0cc, 0x0120, 0x78b0, 0x2011, 0x0114, 0x2012, 0x012e, 0x0804,
-	0x3339, 0x00f6, 0x2079, 0x1800, 0x7a38, 0xa898, 0x9084, 0xfebf,
-	0x9215, 0xa89c, 0x9084, 0xfebf, 0x8002, 0x9214, 0x7838, 0x9084,
-	0x0140, 0x9215, 0x7a3a, 0xa897, 0x4000, 0x900e, 0x9085, 0x0001,
-	0x2001, 0x0000, 0x00fe, 0x0005, 0x7898, 0x9005, 0x01a8, 0x7888,
-	0x9025, 0x0904, 0x336e, 0x788c, 0x902d, 0x0904, 0x336e, 0x900e,
-	0x080c, 0x6247, 0x1120, 0xba44, 0xbb38, 0xbc46, 0xbd3a, 0x9186,
-	0x07ff, 0x0190, 0x8108, 0x0ca0, 0x080c, 0x48bc, 0x0904, 0x336e,
-	0x7888, 0x900d, 0x0904, 0x336e, 0x788c, 0x9005, 0x0904, 0x336e,
-	0xba44, 0xb946, 0xbb38, 0xb83a, 0x0804, 0x3339, 0x2011, 0xbc09,
-	0x0010, 0x2011, 0xbc05, 0x080c, 0x53a3, 0x1904, 0x336b, 0x00c6,
-	0x2061, 0x0100, 0x7984, 0x9186, 0x00ff, 0x1130, 0x2001, 0x1817,
-	0x2004, 0x9085, 0xff00, 0x0088, 0x9182, 0x007f, 0x16e0, 0x9188,
-	0x313a, 0x210d, 0x918c, 0x00ff, 0x2001, 0x1817, 0x2004, 0x0026,
-	0x9116, 0x002e, 0x0580, 0x810f, 0x9105, 0x0126, 0x2091, 0x8000,
-	0x0006, 0x080c, 0x9dec, 0x000e, 0x0510, 0x602e, 0x620a, 0x7984,
-	0x00b6, 0x080c, 0x61ed, 0x2b08, 0x00be, 0x1500, 0x6112, 0x6023,
-	0x0001, 0x080c, 0x4889, 0x01d0, 0x9006, 0xa866, 0x7007, 0x0003,
-	0xa832, 0xa868, 0xc0fd, 0xa86a, 0x701f, 0x3819, 0x2900, 0x6016,
-	0x2009, 0x0032, 0x080c, 0x9ebc, 0x012e, 0x00ce, 0x0005, 0x012e,
-	0x00ce, 0x0804, 0x336b, 0x00ce, 0x0804, 0x336e, 0x080c, 0x9e42,
-	0x0cb0, 0xa830, 0x9086, 0x0100, 0x0904, 0x336b, 0x0804, 0x3339,
-	0x2061, 0x1a40, 0x0126, 0x2091, 0x8000, 0x6000, 0xd084, 0x0170,
-	0x6104, 0x6208, 0x2061, 0x1800, 0x6350, 0x6070, 0x789a, 0x60bc,
-	0x789e, 0x60b8, 0x78aa, 0x012e, 0x0804, 0x3339, 0x900e, 0x2110,
-	0x0c88, 0x81ff, 0x1904, 0x336b, 0x080c, 0x6f9b, 0x0904, 0x336b,
-	0x0126, 0x2091, 0x8000, 0x6250, 0x6070, 0x9202, 0x0248, 0x9085,
-	0x0001, 0x080c, 0x26ce, 0x080c, 0x55bd, 0x012e, 0x0804, 0x3339,
-	0x012e, 0x0804, 0x336e, 0x0006, 0x0016, 0x00c6, 0x00e6, 0x2001,
-	0x1979, 0x2070, 0x2061, 0x1853, 0x6008, 0x2072, 0x900e, 0x2011,
-	0x1400, 0x080c, 0x8259, 0x7206, 0x00ee, 0x00ce, 0x001e, 0x000e,
-	0x0005, 0x0126, 0x2091, 0x8000, 0x81ff, 0x0128, 0x012e, 0x2021,
-	0x400b, 0x0804, 0x333b, 0x7884, 0xd0fc, 0x0148, 0x2001, 0x002a,
-	0x2004, 0x9082, 0x00e1, 0x0288, 0x012e, 0x0804, 0x336e, 0x2001,
-	0x002a, 0x2004, 0x2069, 0x1853, 0x6908, 0x9102, 0x1230, 0x012e,
-	0x0804, 0x336e, 0x012e, 0x0804, 0x336b, 0x080c, 0x9dc1, 0x0dd0,
-	0x7884, 0xd0fc, 0x0904, 0x38e4, 0x00c6, 0x080c, 0x4889, 0x00ce,
-	0x0d88, 0xa867, 0x0000, 0x7884, 0xa80a, 0x7898, 0xa80e, 0x789c,
-	0xa812, 0x2001, 0x002e, 0x2004, 0xa81a, 0x2001, 0x002f, 0x2004,
-	0xa81e, 0x2001, 0x0030, 0x2004, 0xa822, 0x2001, 0x0031, 0x2004,
-	0xa826, 0x2001, 0x0034, 0x2004, 0xa82a, 0x2001, 0x0035, 0x2004,
-	0xa82e, 0x2001, 0x002a, 0x2004, 0x9080, 0x0003, 0x9084, 0x00fc,
-	0x8004, 0xa816, 0x080c, 0x3a6a, 0x0928, 0x7014, 0x2048, 0xad2c,
-	0xac28, 0xab1c, 0xaa18, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029,
-	0x0000, 0x2021, 0x0000, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
-	0x9084, 0xffc0, 0x9080, 0x001b, 0x080c, 0x48d2, 0x701f, 0x39a7,
-	0x7023, 0x0001, 0x012e, 0x0005, 0x0046, 0x0086, 0x0096, 0x00a6,
-	0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x080c, 0x3853, 0x2001,
-	0x196f, 0x2003, 0x0000, 0x2021, 0x000a, 0x2061, 0x0100, 0x6104,
-	0x0016, 0x60bb, 0x0000, 0x60bf, 0x32e1, 0x60bf, 0x0012, 0x080c,
-	0x3ad9, 0x080c, 0x3a98, 0x00f6, 0x00e6, 0x0086, 0x2940, 0x2071,
-	0x1a35, 0x2079, 0x0090, 0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4,
-	0x0140, 0x2001, 0x0035, 0x2004, 0x780e, 0x2001, 0x0034, 0x2004,
-	0x780a, 0x00de, 0x2011, 0x0001, 0x080c, 0x3e6c, 0x008e, 0x00ee,
-	0x00fe, 0x080c, 0x3d99, 0x080c, 0x3c9e, 0x05b8, 0x2001, 0x020b,
-	0x2004, 0x9084, 0x0140, 0x1db8, 0x080c, 0x3ee0, 0x00f6, 0x2079,
-	0x0300, 0x78bc, 0x00fe, 0x908c, 0x0070, 0x1560, 0x2071, 0x0200,
-	0x7037, 0x0000, 0x7050, 0x9084, 0xff00, 0x9086, 0x3200, 0x1510,
-	0x7037, 0x0001, 0x7050, 0x9084, 0xff00, 0x9086, 0xe100, 0x11d0,
-	0x7037, 0x0000, 0x7054, 0x7037, 0x0000, 0x715c, 0x9106, 0x1190,
-	0x2001, 0x181f, 0x2004, 0x9106, 0x1168, 0x00c6, 0x2061, 0x0100,
-	0x6024, 0x9084, 0x1e00, 0x00ce, 0x0138, 0x080c, 0x3ca8, 0x080c,
-	0x3a93, 0x0058, 0x080c, 0x3a93, 0x080c, 0x3e04, 0x080c, 0x3d8f,
-	0x2001, 0x020b, 0x2004, 0xd0e4, 0x0dd8, 0x2001, 0x032a, 0x2003,
-	0x0004, 0x2061, 0x0100, 0x6027, 0x0002, 0x001e, 0x6106, 0x2011,
-	0x020d, 0x2013, 0x0020, 0x60bb, 0x0000, 0x60bf, 0x0108, 0x60bf,
-	0x0012, 0x2001, 0x0004, 0x200c, 0x918c, 0xfffd, 0x2102, 0x080c,
-	0x129f, 0x2009, 0x0028, 0x080c, 0x226a, 0x2001, 0x0227, 0x200c,
-	0x2102, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e,
-	0x008e, 0x004e, 0x2001, 0x196f, 0x2004, 0x9005, 0x1118, 0x012e,
-	0x0804, 0x3339, 0x012e, 0x2021, 0x400c, 0x0804, 0x333b, 0x0016,
-	0x0026, 0x0036, 0x0046, 0x0056, 0x0076, 0x0086, 0x0096, 0x00d6,
-	0x0156, 0x7014, 0x2048, 0x7020, 0x20a8, 0x8000, 0x7022, 0xa804,
-	0x9005, 0x0904, 0x3a03, 0x2048, 0x1f04, 0x39b7, 0x7068, 0x2040,
-	0xa28c, 0xa390, 0xa494, 0xa598, 0xa930, 0xa808, 0xd0b4, 0x1120,
-	0x2029, 0x0000, 0x2021, 0x0000, 0x0096, 0x7014, 0x2048, 0xa864,
-	0x009e, 0x9086, 0x0103, 0x0170, 0x8906, 0x8006, 0x8007, 0x90bc,
-	0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x080c, 0x48d2, 0x701f,
-	0x39a7, 0x00b0, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
-	0xffc0, 0x9080, 0x001b, 0x21a8, 0x27e0, 0x2098, 0x27e8, 0x20a0,
-	0x0006, 0x080c, 0x0f68, 0x000e, 0x080c, 0x48d5, 0x701f, 0x39a7,
-	0x015e, 0x00de, 0x009e, 0x008e, 0x007e, 0x005e, 0x004e, 0x003e,
-	0x002e, 0x001e, 0x0005, 0x7014, 0x2048, 0xa864, 0x9086, 0x0103,
-	0x1118, 0x701f, 0x3a68, 0x0450, 0x7014, 0x2048, 0xa868, 0xc0fd,
-	0xa86a, 0x2009, 0x007f, 0x080c, 0x61e7, 0x0110, 0x9006, 0x0030,
-	0xb813, 0x00ff, 0xb817, 0xfffd, 0x080c, 0xbff5, 0x015e, 0x00de,
-	0x009e, 0x008e, 0x007e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e,
-	0x0904, 0x336b, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0076,
-	0x0086, 0x0096, 0x00d6, 0x0156, 0x701f, 0x3a3a, 0x7007, 0x0003,
-	0x0804, 0x39f8, 0xa830, 0x9086, 0x0100, 0x2021, 0x400c, 0x0904,
-	0x333b, 0x0076, 0xad10, 0xac0c, 0xab24, 0xaa20, 0xa930, 0xa808,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x2071, 0x189c, 0x7003,
+	0x0002, 0x9006, 0x7016, 0x701a, 0x704a, 0x704e, 0x700e, 0x7042,
+	0x7046, 0x703b, 0x18b8, 0x703f, 0x18b8, 0x7007, 0x0001, 0x080c,
+	0x1004, 0x090c, 0x0db4, 0x2900, 0x706a, 0xa867, 0x0002, 0xa8ab,
+	0xdcb0, 0x080c, 0x1004, 0x090c, 0x0db4, 0x2900, 0x706e, 0xa867,
+	0x0002, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x189c, 0x7004, 0x0002,
+	0x3274, 0x3275, 0x3288, 0x329c, 0x0005, 0x1004, 0x3285, 0x0e04,
+	0x3285, 0x2079, 0x0000, 0x0126, 0x2091, 0x8000, 0x700c, 0x9005,
+	0x1128, 0x700f, 0x0001, 0x012e, 0x0468, 0x0005, 0x012e, 0x0ce8,
+	0x2079, 0x0000, 0x2061, 0x18b6, 0x2c4c, 0xa86c, 0x908e, 0x0100,
+	0x0128, 0x9086, 0x0200, 0x0904, 0x3370, 0x0005, 0x7018, 0x2048,
+	0x2061, 0x1800, 0x701c, 0x0807, 0x7014, 0x2048, 0xa864, 0x9094,
+	0x00ff, 0x9296, 0x0029, 0x1120, 0xaa78, 0xd2fc, 0x0128, 0x0005,
+	0x9086, 0x0103, 0x0108, 0x0005, 0x2079, 0x0000, 0x2061, 0x1800,
+	0x701c, 0x0807, 0x2061, 0x1800, 0x7880, 0x908a, 0x0040, 0x1210,
+	0x61cc, 0x0042, 0x2100, 0x908a, 0x003f, 0x1a04, 0x336d, 0x61cc,
+	0x0804, 0x3302, 0x3344, 0x337c, 0x336d, 0x3386, 0x3390, 0x3396,
+	0x339a, 0x33aa, 0x33ae, 0x33c4, 0x33ca, 0x33d0, 0x33db, 0x33e6,
+	0x33f5, 0x3404, 0x3412, 0x3429, 0x3444, 0x336d, 0x34ed, 0x352b,
+	0x35d1, 0x35e2, 0x3605, 0x336d, 0x336d, 0x336d, 0x363d, 0x3659,
+	0x3662, 0x3691, 0x3697, 0x336d, 0x36dd, 0x336d, 0x336d, 0x336d,
+	0x336d, 0x336d, 0x36e8, 0x36f1, 0x36f9, 0x36fb, 0x336d, 0x336d,
+	0x336d, 0x336d, 0x336d, 0x336d, 0x3727, 0x336d, 0x336d, 0x336d,
+	0x336d, 0x336d, 0x3744, 0x379f, 0x336d, 0x336d, 0x336d, 0x336d,
+	0x336d, 0x336d, 0x0002, 0x37c9, 0x37cc, 0x382b, 0x3844, 0x3874,
+	0x3b12, 0x336d, 0x4f73, 0x336d, 0x336d, 0x336d, 0x336d, 0x336d,
+	0x336d, 0x336d, 0x336d, 0x33c4, 0x33ca, 0x4033, 0x53be, 0x4049,
+	0x5002, 0x5053, 0x5156, 0x336d, 0x51b8, 0x51f4, 0x5225, 0x5329,
+	0x5252, 0x52a9, 0x336d, 0x404d, 0x41ee, 0x4204, 0x4229, 0x428e,
+	0x4302, 0x4322, 0x4399, 0x43f5, 0x4451, 0x4454, 0x4479, 0x4519,
+	0x457f, 0x4587, 0x46b9, 0x481e, 0x4852, 0x4a9c, 0x336d, 0x4aba,
+	0x4b76, 0x4c4c, 0x336d, 0x336d, 0x336d, 0x336d, 0x4cb2, 0x4ccd,
+	0x4587, 0x4f13, 0x714c, 0x0000, 0x2021, 0x4000, 0x080c, 0x48d0,
+	0x0126, 0x2091, 0x8000, 0x0e04, 0x334e, 0x0010, 0x012e, 0x0cc0,
+	0x7c36, 0x9486, 0x4000, 0x0118, 0x7833, 0x0011, 0x0010, 0x7833,
+	0x0010, 0x7c82, 0x7986, 0x7a8a, 0x7b8e, 0x2091, 0x4080, 0x2001,
+	0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x7007, 0x0001, 0x2091,
+	0x5000, 0x700f, 0x0000, 0x012e, 0x0005, 0x2021, 0x4001, 0x08b0,
+	0x2021, 0x4002, 0x0898, 0x2021, 0x4003, 0x0880, 0x2021, 0x4005,
+	0x0868, 0x2021, 0x4006, 0x0850, 0x2039, 0x0001, 0x902e, 0x2520,
+	0x7b88, 0x7a8c, 0x7884, 0x7990, 0x0804, 0x48dd, 0x2039, 0x0001,
+	0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884, 0x7990, 0x0804, 0x48e0,
+	0x7984, 0x7888, 0x2114, 0x200a, 0x0804, 0x3344, 0x7984, 0x2114,
+	0x0804, 0x3344, 0x20e1, 0x0000, 0x2099, 0x0021, 0x20e9, 0x0000,
+	0x20a1, 0x0021, 0x20a9, 0x001f, 0x4003, 0x7984, 0x7a88, 0x7b8c,
+	0x0804, 0x3344, 0x7884, 0x2060, 0x0804, 0x33f7, 0x2009, 0x0003,
+	0x2011, 0x0003, 0x2019, 0x0002, 0x789b, 0x0317, 0x7893, 0xffff,
+	0x2001, 0x188d, 0x2004, 0x9005, 0x0118, 0x7896, 0x0804, 0x3344,
+	0x7897, 0x0001, 0x0804, 0x3344, 0x2039, 0x0001, 0x7d98, 0x7c9c,
+	0x0804, 0x3380, 0x2039, 0x0001, 0x7d98, 0x7c9c, 0x0804, 0x338a,
+	0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x3379, 0x2138, 0x7d98,
+	0x7c9c, 0x0804, 0x3380, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804,
+	0x3379, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x338a, 0x79a0, 0x9182,
+	0x0040, 0x0210, 0x0804, 0x3379, 0x21e8, 0x7984, 0x7888, 0x20a9,
+	0x0001, 0x21a0, 0x4004, 0x0804, 0x3344, 0x2061, 0x0800, 0xe10c,
+	0x9006, 0x2c15, 0x9200, 0x8c60, 0x8109, 0x1dd8, 0x2010, 0x9005,
+	0x0904, 0x3344, 0x0804, 0x3373, 0x79a0, 0x9182, 0x0040, 0x0210,
+	0x0804, 0x3379, 0x21e0, 0x20a9, 0x0001, 0x7984, 0x2198, 0x4012,
+	0x0804, 0x3344, 0x2069, 0x185b, 0x7884, 0x7990, 0x911a, 0x1a04,
+	0x3379, 0x8019, 0x0904, 0x3379, 0x684a, 0x6942, 0x788c, 0x6852,
+	0x7888, 0x6856, 0x9006, 0x685a, 0x685e, 0x080c, 0x72bd, 0x0804,
+	0x3344, 0x2069, 0x185b, 0x7884, 0x7994, 0x911a, 0x1a04, 0x3379,
+	0x8019, 0x0904, 0x3379, 0x684e, 0x6946, 0x788c, 0x6862, 0x7888,
+	0x6866, 0x9006, 0x686a, 0x686e, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x6678, 0x012e, 0x0804, 0x3344, 0x902e, 0x2520, 0x81ff, 0x0120,
+	0x2009, 0x0001, 0x0804, 0x3376, 0x7984, 0x7b88, 0x7a8c, 0x20a9,
+	0x0005, 0x20e9, 0x0001, 0x20a1, 0x18a4, 0x4101, 0x080c, 0x4894,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x3376, 0x2009, 0x0020, 0xa85c,
+	0x9080, 0x0019, 0xaf60, 0x080c, 0x48dd, 0x701f, 0x3468, 0x0005,
+	0xa864, 0x2008, 0x9084, 0x00ff, 0x9096, 0x0011, 0x0168, 0x9096,
+	0x0019, 0x0150, 0x9096, 0x0015, 0x0138, 0x9096, 0x0048, 0x0120,
+	0x9096, 0x0029, 0x1904, 0x3376, 0x810f, 0x918c, 0x00ff, 0x0904,
+	0x3376, 0x7112, 0x7010, 0x8001, 0x0560, 0x7012, 0x080c, 0x4894,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x3376, 0x2009, 0x0020, 0x7068,
+	0x2040, 0xa28c, 0xa390, 0xa494, 0xa598, 0x9290, 0x0040, 0x9399,
+	0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c, 0x9080, 0x0019,
+	0xaf60, 0x080c, 0x48dd, 0x701f, 0x34a6, 0x0005, 0xa864, 0x9084,
+	0x00ff, 0x9096, 0x0002, 0x0120, 0x9096, 0x000a, 0x1904, 0x3376,
+	0x0888, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a, 0xa864, 0x9084,
+	0x00ff, 0x9096, 0x0029, 0x1160, 0xc2fd, 0xaa7a, 0x080c, 0x5df1,
+	0x0150, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982, 0x012e, 0x0050,
+	0x080c, 0x610c, 0x1128, 0x7007, 0x0003, 0x701f, 0x34d2, 0x0005,
+	0x080c, 0x6ace, 0x0126, 0x2091, 0x8000, 0x20a9, 0x0005, 0x20e1,
+	0x0001, 0x2099, 0x18a4, 0x400a, 0x2100, 0x9210, 0x9399, 0x0000,
+	0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c, 0x9080, 0x0019, 0x2009,
+	0x0020, 0x012e, 0xaf60, 0x0804, 0x48e0, 0x2091, 0x8000, 0x7837,
+	0x4000, 0x7833, 0x0010, 0x7883, 0x4000, 0x7887, 0x4953, 0x788b,
+	0x5020, 0x788f, 0x2020, 0x2009, 0x017f, 0x2104, 0x7892, 0x3f00,
+	0x7896, 0x2061, 0x0100, 0x6200, 0x2061, 0x0200, 0x603c, 0x8007,
+	0x9205, 0x789a, 0x2009, 0x04fd, 0x2104, 0x789e, 0x2091, 0x5000,
+	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x0180, 0x2001,
+	0x19f1, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b, 0x2004, 0xd0fc,
+	0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002, 0x2003, 0x1001, 0x2071,
+	0x0080, 0x0804, 0x0427, 0x81ff, 0x1904, 0x3376, 0x7984, 0x080c,
+	0x6256, 0x1904, 0x3379, 0x7e98, 0x9684, 0x3fff, 0x9082, 0x4000,
+	0x1a04, 0x3379, 0x7c88, 0x7d8c, 0x080c, 0x63b9, 0x080c, 0x6388,
+	0x0000, 0x1518, 0x2061, 0x1cd0, 0x0126, 0x2091, 0x8000, 0x6000,
+	0x9086, 0x0000, 0x0148, 0x6014, 0x904d, 0x0130, 0xa86c, 0x9406,
+	0x1118, 0xa870, 0x9506, 0x0150, 0x012e, 0x9ce0, 0x0018, 0x2001,
+	0x1819, 0x2004, 0x9c02, 0x1a04, 0x3376, 0x0c30, 0x080c, 0xb75c,
+	0x012e, 0x0904, 0x3376, 0x0804, 0x3344, 0x900e, 0x2001, 0x0005,
+	0x080c, 0x6ace, 0x0126, 0x2091, 0x8000, 0x080c, 0xbe35, 0x080c,
+	0x68a0, 0x012e, 0x0804, 0x3344, 0x00a6, 0x2950, 0xb198, 0x080c,
+	0x6256, 0x1904, 0x35be, 0xb6a4, 0x9684, 0x3fff, 0x9082, 0x4000,
+	0x16e8, 0xb49c, 0xb5a0, 0x080c, 0x63b9, 0x080c, 0x6388, 0x1520,
+	0x2061, 0x1cd0, 0x0126, 0x2091, 0x8000, 0x6000, 0x9086, 0x0000,
+	0x0148, 0x6014, 0x904d, 0x0130, 0xa86c, 0x9406, 0x1118, 0xa870,
+	0x9506, 0x0158, 0x012e, 0x9ce0, 0x0018, 0x2001, 0x1819, 0x2004,
+	0x9c02, 0x2009, 0x000d, 0x12b0, 0x0c28, 0x080c, 0xb75c, 0x012e,
+	0x2009, 0x0003, 0x0178, 0x00e0, 0x900e, 0x2001, 0x0005, 0x080c,
+	0x6ace, 0x0126, 0x2091, 0x8000, 0x080c, 0xbe35, 0x080c, 0x6893,
+	0x012e, 0x0070, 0xb097, 0x4005, 0xb19a, 0x0010, 0xb097, 0x4006,
+	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x2a48, 0x00ae, 0x0005,
+	0xb097, 0x4000, 0x9006, 0x918d, 0x0001, 0x2008, 0x2a48, 0x00ae,
+	0x0005, 0x81ff, 0x1904, 0x3376, 0x080c, 0x48ab, 0x0904, 0x3379,
+	0x080c, 0x631d, 0x0904, 0x3376, 0x080c, 0x63bf, 0x0904, 0x3376,
+	0x0804, 0x4319, 0x81ff, 0x1904, 0x3376, 0x080c, 0x48c7, 0x0904,
+	0x3379, 0x080c, 0x644d, 0x0904, 0x3376, 0x2019, 0x0005, 0x79a8,
+	0x080c, 0x63da, 0x0904, 0x3376, 0x7888, 0x908a, 0x1000, 0x1a04,
+	0x3379, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x804d, 0x7984,
+	0xd184, 0x1904, 0x3344, 0x0804, 0x4319, 0x0126, 0x2091, 0x8000,
+	0x81ff, 0x0118, 0x2009, 0x0001, 0x0450, 0x2029, 0x07ff, 0x6458,
+	0x2400, 0x9506, 0x01f8, 0x2508, 0x080c, 0x6256, 0x11d8, 0x080c,
+	0x644d, 0x1128, 0x2009, 0x0002, 0x62bc, 0x2518, 0x00c0, 0x2019,
+	0x0004, 0x900e, 0x080c, 0x63da, 0x1118, 0x2009, 0x0006, 0x0078,
+	0x7884, 0x908a, 0x1000, 0x1270, 0x8003, 0x800b, 0x810b, 0x9108,
+	0x080c, 0x804d, 0x8529, 0x1ae0, 0x012e, 0x0804, 0x3344, 0x012e,
+	0x0804, 0x3376, 0x012e, 0x0804, 0x3379, 0x080c, 0x48ab, 0x0904,
+	0x3379, 0x080c, 0x631d, 0x0904, 0x3376, 0xbaa0, 0x2019, 0x0005,
+	0x00c6, 0x9066, 0x080c, 0x8582, 0x0076, 0x903e, 0x080c, 0x8470,
+	0x900e, 0x080c, 0xd2d5, 0x007e, 0x00ce, 0x080c, 0x63b9, 0x0804,
+	0x3344, 0x080c, 0x48ab, 0x0904, 0x3379, 0x080c, 0x63b9, 0x2208,
+	0x0804, 0x3344, 0x0156, 0x00d6, 0x00e6, 0x2069, 0x190e, 0x6810,
+	0x6914, 0x910a, 0x1208, 0x900e, 0x6816, 0x9016, 0x901e, 0x20a9,
+	0x007e, 0x2069, 0x1000, 0x2d04, 0x905d, 0x0118, 0xb84c, 0x0059,
+	0x9210, 0x8d68, 0x1f04, 0x3673, 0x2300, 0x9218, 0x00ee, 0x00de,
+	0x015e, 0x0804, 0x3344, 0x00f6, 0x0016, 0x907d, 0x0138, 0x9006,
+	0x8000, 0x2f0c, 0x81ff, 0x0110, 0x2178, 0x0cd0, 0x001e, 0x00fe,
+	0x0005, 0x2069, 0x190e, 0x6910, 0x62b8, 0x0804, 0x3344, 0x81ff,
+	0x0120, 0x2009, 0x0001, 0x0804, 0x3376, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x53ae, 0x0128, 0x2009, 0x0007, 0x012e, 0x0804, 0x3376,
+	0x012e, 0x6158, 0x9190, 0x3145, 0x2215, 0x9294, 0x00ff, 0x6378,
+	0x83ff, 0x0108, 0x627c, 0x67d8, 0x97c4, 0x000a, 0x98c6, 0x000a,
+	0x1118, 0x2031, 0x0001, 0x00e8, 0x97c4, 0x0022, 0x98c6, 0x0022,
+	0x1118, 0x2031, 0x0003, 0x00a8, 0x97c4, 0x0012, 0x98c6, 0x0012,
+	0x1118, 0x2031, 0x0002, 0x0068, 0x080c, 0x6faa, 0x1118, 0x2031,
+	0x0004, 0x0038, 0xd79c, 0x0120, 0x2009, 0x0005, 0x0804, 0x3376,
+	0x9036, 0x7e9a, 0x7f9e, 0x0804, 0x3344, 0x6148, 0x624c, 0x2019,
+	0x195e, 0x231c, 0x2001, 0x195f, 0x2004, 0x789a, 0x0804, 0x3344,
+	0x0126, 0x2091, 0x8000, 0x6138, 0x623c, 0x6340, 0x012e, 0x0804,
+	0x3344, 0x080c, 0x48c7, 0x0904, 0x3379, 0xba44, 0xbb38, 0x0804,
+	0x3344, 0x080c, 0x0db4, 0x080c, 0x48c7, 0x2110, 0x0904, 0x3379,
+	0xb804, 0x908c, 0x00ff, 0x918e, 0x0006, 0x0140, 0x9084, 0xff00,
+	0x9086, 0x0600, 0x2009, 0x0009, 0x1904, 0x3376, 0x0126, 0x2091,
+	0x8000, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c, 0x9915, 0x080c,
+	0x8582, 0x0076, 0x903e, 0x080c, 0x8470, 0x900e, 0x080c, 0xd2d5,
+	0x007e, 0x00ce, 0xb807, 0x0407, 0x012e, 0x0804, 0x3344, 0x6148,
+	0x624c, 0x7884, 0x604a, 0x7b88, 0x634e, 0x2069, 0x185b, 0x831f,
+	0x9305, 0x6816, 0x788c, 0x2069, 0x195e, 0x2d1c, 0x206a, 0x7e98,
+	0x9682, 0x0014, 0x1210, 0x2031, 0x07d0, 0x2069, 0x195f, 0x2d04,
+	0x266a, 0x789a, 0x0804, 0x3344, 0x0126, 0x2091, 0x8000, 0x6138,
+	0x7884, 0x603a, 0x910e, 0xd1b4, 0x190c, 0x0e9b, 0xd0c4, 0x01a8,
+	0x00d6, 0x78a8, 0x2009, 0x1975, 0x200a, 0x78ac, 0x2011, 0x1976,
+	0x2012, 0x2069, 0x0100, 0x6838, 0x9086, 0x0007, 0x1118, 0x2214,
+	0x6a5a, 0x0010, 0x210c, 0x695a, 0x00de, 0x7888, 0x603e, 0x2011,
+	0x0114, 0x220c, 0x7888, 0xd08c, 0x0118, 0x918d, 0x0080, 0x0010,
+	0x918c, 0xff7f, 0x2112, 0x6140, 0x788c, 0x6042, 0x910e, 0xd1e4,
+	0x190c, 0x0eb1, 0x6040, 0xd0cc, 0x0120, 0x78b0, 0x2011, 0x0114,
+	0x2012, 0x012e, 0x0804, 0x3344, 0x00f6, 0x2079, 0x1800, 0x7a38,
+	0xa898, 0x9084, 0xfebf, 0x9215, 0xa89c, 0x9084, 0xfebf, 0x8002,
+	0x9214, 0x7838, 0x9084, 0x0140, 0x9215, 0x7a3a, 0xa897, 0x4000,
+	0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x00fe, 0x0005, 0x7898,
+	0x9005, 0x01a8, 0x7888, 0x9025, 0x0904, 0x3379, 0x788c, 0x902d,
+	0x0904, 0x3379, 0x900e, 0x080c, 0x6256, 0x1120, 0xba44, 0xbb38,
+	0xbc46, 0xbd3a, 0x9186, 0x07ff, 0x0190, 0x8108, 0x0ca0, 0x080c,
+	0x48c7, 0x0904, 0x3379, 0x7888, 0x900d, 0x0904, 0x3379, 0x788c,
+	0x9005, 0x0904, 0x3379, 0xba44, 0xb946, 0xbb38, 0xb83a, 0x0804,
+	0x3344, 0x2011, 0xbc09, 0x0010, 0x2011, 0xbc05, 0x080c, 0x53ae,
+	0x1904, 0x3376, 0x00c6, 0x2061, 0x0100, 0x7984, 0x9186, 0x00ff,
+	0x1130, 0x2001, 0x1817, 0x2004, 0x9085, 0xff00, 0x0088, 0x9182,
+	0x007f, 0x16e0, 0x9188, 0x3145, 0x210d, 0x918c, 0x00ff, 0x2001,
+	0x1817, 0x2004, 0x0026, 0x9116, 0x002e, 0x0580, 0x810f, 0x9105,
+	0x0126, 0x2091, 0x8000, 0x0006, 0x080c, 0x9dd9, 0x000e, 0x0510,
+	0x602e, 0x620a, 0x7984, 0x00b6, 0x080c, 0x61fc, 0x2b08, 0x00be,
+	0x1500, 0x6112, 0x6023, 0x0001, 0x080c, 0x4894, 0x01d0, 0x9006,
+	0xa866, 0x7007, 0x0003, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x701f,
+	0x3824, 0x2900, 0x6016, 0x2009, 0x0032, 0x080c, 0x9ea9, 0x012e,
+	0x00ce, 0x0005, 0x012e, 0x00ce, 0x0804, 0x3376, 0x00ce, 0x0804,
+	0x3379, 0x080c, 0x9e2f, 0x0cb0, 0xa830, 0x9086, 0x0100, 0x0904,
+	0x3376, 0x0804, 0x3344, 0x2061, 0x1a48, 0x0126, 0x2091, 0x8000,
+	0x6000, 0xd084, 0x0170, 0x6104, 0x6208, 0x2061, 0x1800, 0x6350,
+	0x6070, 0x789a, 0x60bc, 0x789e, 0x60b8, 0x78aa, 0x012e, 0x0804,
+	0x3344, 0x900e, 0x2110, 0x0c88, 0x81ff, 0x1904, 0x3376, 0x080c,
+	0x6faa, 0x0904, 0x3376, 0x0126, 0x2091, 0x8000, 0x6250, 0x6070,
+	0x9202, 0x0248, 0x9085, 0x0001, 0x080c, 0x26d9, 0x080c, 0x55c8,
+	0x012e, 0x0804, 0x3344, 0x012e, 0x0804, 0x3379, 0x0006, 0x0016,
+	0x00c6, 0x00e6, 0x2001, 0x1981, 0x2070, 0x2061, 0x185b, 0x6008,
+	0x2072, 0x900e, 0x2011, 0x1400, 0x080c, 0x8277, 0x7206, 0x00ee,
+	0x00ce, 0x001e, 0x000e, 0x0005, 0x0126, 0x2091, 0x8000, 0x81ff,
+	0x0128, 0x012e, 0x2021, 0x400b, 0x0804, 0x3346, 0x7884, 0xd0fc,
+	0x0148, 0x2001, 0x002a, 0x2004, 0x9082, 0x00e1, 0x0288, 0x012e,
+	0x0804, 0x3379, 0x2001, 0x002a, 0x2004, 0x2069, 0x185b, 0x6908,
+	0x9102, 0x1230, 0x012e, 0x0804, 0x3379, 0x012e, 0x0804, 0x3376,
+	0x080c, 0x9dae, 0x0dd0, 0x7884, 0xd0fc, 0x0904, 0x38ef, 0x00c6,
+	0x080c, 0x4894, 0x00ce, 0x0d88, 0xa867, 0x0000, 0x7884, 0xa80a,
+	0x7898, 0xa80e, 0x789c, 0xa812, 0x2001, 0x002e, 0x2004, 0xa81a,
+	0x2001, 0x002f, 0x2004, 0xa81e, 0x2001, 0x0030, 0x2004, 0xa822,
+	0x2001, 0x0031, 0x2004, 0xa826, 0x2001, 0x0034, 0x2004, 0xa82a,
+	0x2001, 0x0035, 0x2004, 0xa82e, 0x2001, 0x002a, 0x2004, 0x9080,
+	0x0003, 0x9084, 0x00fc, 0x8004, 0xa816, 0x080c, 0x3a75, 0x0928,
+	0x7014, 0x2048, 0xad2c, 0xac28, 0xab1c, 0xaa18, 0xa930, 0xa808,
 	0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021, 0x0000, 0x8906, 0x8006,
-	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x21a8,
-	0x27e0, 0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c, 0x0f68, 0x000e,
-	0x080c, 0x48d5, 0x007e, 0x701f, 0x39a7, 0x7023, 0x0001, 0x0005,
-	0x0804, 0x3339, 0x0156, 0x00c6, 0xa814, 0x908a, 0x001e, 0x0218,
-	0xa833, 0x001e, 0x0010, 0xa832, 0x0078, 0x81ff, 0x0168, 0x0016,
-	0x080c, 0x4889, 0x001e, 0x0130, 0xa800, 0x2040, 0xa008, 0xa80a,
-	0x2100, 0x0c58, 0x9006, 0x0010, 0x9085, 0x0001, 0x00ce, 0x015e,
-	0x0005, 0x0006, 0x00f6, 0x2079, 0x0000, 0x7880, 0x9086, 0x0044,
-	0x00fe, 0x000e, 0x0005, 0x2001, 0x196f, 0x2003, 0x0001, 0x0005,
-	0x00f6, 0x00e6, 0x00c6, 0x2061, 0x0200, 0x2001, 0x197a, 0x2004,
-	0x601a, 0x2061, 0x0100, 0x2001, 0x1979, 0x2004, 0x60ce, 0x6104,
-	0xc1ac, 0x6106, 0x080c, 0x4889, 0xa813, 0x0019, 0xa817, 0x0001,
+	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x080c,
+	0x48dd, 0x701f, 0x39b2, 0x7023, 0x0001, 0x012e, 0x0005, 0x0046,
+	0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x080c, 0x385e, 0x2001, 0x1977, 0x2003, 0x0000, 0x2021, 0x000a,
+	0x2061, 0x0100, 0x6104, 0x0016, 0x60bb, 0x0000, 0x60bf, 0x32e1,
+	0x60bf, 0x0012, 0x080c, 0x3ae4, 0x080c, 0x3aa3, 0x00f6, 0x00e6,
+	0x0086, 0x2940, 0x2071, 0x1a3d, 0x2079, 0x0090, 0x00d6, 0x2069,
+	0x0000, 0x6884, 0xd0b4, 0x0140, 0x2001, 0x0035, 0x2004, 0x780e,
+	0x2001, 0x0034, 0x2004, 0x780a, 0x00de, 0x2011, 0x0001, 0x080c,
+	0x3e77, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3da4, 0x080c, 0x3ca9,
+	0x05b8, 0x2001, 0x020b, 0x2004, 0x9084, 0x0140, 0x1db8, 0x080c,
+	0x3eeb, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe, 0x908c, 0x0070,
+	0x1560, 0x2071, 0x0200, 0x7037, 0x0000, 0x7050, 0x9084, 0xff00,
+	0x9086, 0x3200, 0x1510, 0x7037, 0x0001, 0x7050, 0x9084, 0xff00,
+	0x9086, 0xe100, 0x11d0, 0x7037, 0x0000, 0x7054, 0x7037, 0x0000,
+	0x715c, 0x9106, 0x1190, 0x2001, 0x181f, 0x2004, 0x9106, 0x1168,
+	0x00c6, 0x2061, 0x0100, 0x6024, 0x9084, 0x1e00, 0x00ce, 0x0138,
+	0x080c, 0x3cb3, 0x080c, 0x3a9e, 0x0058, 0x080c, 0x3a9e, 0x080c,
+	0x3e0f, 0x080c, 0x3d9a, 0x2001, 0x020b, 0x2004, 0xd0e4, 0x0dd8,
+	0x2001, 0x032a, 0x2003, 0x0004, 0x2061, 0x0100, 0x6027, 0x0002,
+	0x001e, 0x6106, 0x2011, 0x020d, 0x2013, 0x0020, 0x60bb, 0x0000,
+	0x60bf, 0x0108, 0x60bf, 0x0012, 0x2001, 0x0004, 0x200c, 0x918c,
+	0xfffd, 0x2102, 0x080c, 0x129f, 0x2009, 0x0028, 0x080c, 0x2275,
+	0x2001, 0x0227, 0x200c, 0x2102, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x00be, 0x00ae, 0x009e, 0x008e, 0x004e, 0x2001, 0x1977, 0x2004,
+	0x9005, 0x1118, 0x012e, 0x0804, 0x3344, 0x012e, 0x2021, 0x400c,
+	0x0804, 0x3346, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0076,
+	0x0086, 0x0096, 0x00d6, 0x0156, 0x7014, 0x2048, 0x7020, 0x20a8,
+	0x8000, 0x7022, 0xa804, 0x9005, 0x0904, 0x3a0e, 0x2048, 0x1f04,
+	0x39c2, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494, 0xa598, 0xa930,
+	0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021, 0x0000, 0x0096,
+	0x7014, 0x2048, 0xa864, 0x009e, 0x9086, 0x0103, 0x0170, 0x8906,
+	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b,
+	0x080c, 0x48dd, 0x701f, 0x39b2, 0x00b0, 0x8906, 0x8006, 0x8007,
+	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x21a8, 0x27e0,
+	0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c, 0x0f68, 0x000e, 0x080c,
+	0x48e0, 0x701f, 0x39b2, 0x015e, 0x00de, 0x009e, 0x008e, 0x007e,
+	0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005, 0x7014, 0x2048,
+	0xa864, 0x9086, 0x0103, 0x1118, 0x701f, 0x3a73, 0x0450, 0x7014,
+	0x2048, 0xa868, 0xc0fd, 0xa86a, 0x2009, 0x007f, 0x080c, 0x61f6,
+	0x0110, 0x9006, 0x0030, 0xb813, 0x00ff, 0xb817, 0xfffd, 0x080c,
+	0xc004, 0x015e, 0x00de, 0x009e, 0x008e, 0x007e, 0x005e, 0x004e,
+	0x003e, 0x002e, 0x001e, 0x0904, 0x3376, 0x0016, 0x0026, 0x0036,
+	0x0046, 0x0056, 0x0076, 0x0086, 0x0096, 0x00d6, 0x0156, 0x701f,
+	0x3a45, 0x7007, 0x0003, 0x0804, 0x3a03, 0xa830, 0x9086, 0x0100,
+	0x2021, 0x400c, 0x0904, 0x3346, 0x0076, 0xad10, 0xac0c, 0xab24,
+	0xaa20, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021,
+	0x0000, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
+	0x9080, 0x001b, 0x21a8, 0x27e0, 0x2098, 0x27e8, 0x20a0, 0x0006,
+	0x080c, 0x0f68, 0x000e, 0x080c, 0x48e0, 0x007e, 0x701f, 0x39b2,
+	0x7023, 0x0001, 0x0005, 0x0804, 0x3344, 0x0156, 0x00c6, 0xa814,
+	0x908a, 0x001e, 0x0218, 0xa833, 0x001e, 0x0010, 0xa832, 0x0078,
+	0x81ff, 0x0168, 0x0016, 0x080c, 0x4894, 0x001e, 0x0130, 0xa800,
+	0x2040, 0xa008, 0xa80a, 0x2100, 0x0c58, 0x9006, 0x0010, 0x9085,
+	0x0001, 0x00ce, 0x015e, 0x0005, 0x0006, 0x00f6, 0x2079, 0x0000,
+	0x7880, 0x9086, 0x0044, 0x00fe, 0x000e, 0x0005, 0x2001, 0x1977,
+	0x2003, 0x0001, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x2061, 0x0200,
+	0x2001, 0x1982, 0x2004, 0x601a, 0x2061, 0x0100, 0x2001, 0x1981,
+	0x2004, 0x60ce, 0x6104, 0xc1ac, 0x6106, 0x080c, 0x4894, 0xa813,
+	0x0019, 0xa817, 0x0001, 0x2900, 0xa85a, 0x2001, 0x002e, 0x2004,
+	0xa866, 0x2001, 0x002f, 0x2004, 0xa86a, 0x2061, 0x0090, 0x2079,
+	0x0100, 0x2001, 0x1981, 0x2004, 0x6036, 0x2009, 0x0040, 0x080c,
+	0x2275, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e, 0x601a,
+	0xa873, 0x0000, 0x601f, 0x0000, 0x78ca, 0x9006, 0x600a, 0x600e,
+	0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00e6, 0x080c, 0x4894, 0x2940,
+	0xa013, 0x0019, 0xa017, 0x0001, 0x2800, 0xa05a, 0x2001, 0x0030,
+	0x2004, 0xa866, 0x2001, 0x0031, 0x2004, 0xa86a, 0x2001, 0x002a,
+	0x2004, 0x9084, 0xfff8, 0xa86e, 0xa873, 0x0000, 0x2001, 0x032a,
+	0x2003, 0x0004, 0x2001, 0x0300, 0x2003, 0x0000, 0x2001, 0x020d,
+	0x2003, 0x0000, 0x2001, 0x0004, 0x200c, 0x918d, 0x0002, 0x2102,
+	0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x81ff, 0x0148, 0x080c,
+	0x2a62, 0x1130, 0x9006, 0x080c, 0x29ba, 0x9006, 0x080c, 0x299d,
+	0x7884, 0x9084, 0x0007, 0x0002, 0x3b2f, 0x3b38, 0x3b41, 0x3b2c,
+	0x3b2c, 0x3b2c, 0x3b2c, 0x3b2c, 0x012e, 0x0804, 0x3379, 0x2009,
+	0x0114, 0x2104, 0x9085, 0x0800, 0x200a, 0x080c, 0x3cfd, 0x00c0,
+	0x2009, 0x0114, 0x2104, 0x9085, 0x4000, 0x200a, 0x080c, 0x3cfd,
+	0x0078, 0x080c, 0x6faa, 0x1128, 0x012e, 0x2009, 0x0016, 0x0804,
+	0x3376, 0x81ff, 0x0128, 0x012e, 0x2021, 0x400b, 0x0804, 0x3346,
+	0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x080c, 0x385e, 0x2009, 0x0101, 0x210c, 0x0016, 0x7ec8, 0x7dcc,
+	0x9006, 0x2068, 0x2060, 0x2058, 0x080c, 0x3fc6, 0x080c, 0x3f16,
+	0x903e, 0x2720, 0x00f6, 0x00e6, 0x0086, 0x2940, 0x2071, 0x1a3d,
+	0x2079, 0x0090, 0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120,
+	0x68d4, 0x780e, 0x68d0, 0x780a, 0x00de, 0x2011, 0x0001, 0x080c,
+	0x3e77, 0x080c, 0x2a6a, 0x080c, 0x2a6a, 0x080c, 0x2a6a, 0x080c,
+	0x2a6a, 0x080c, 0x3e77, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3da4,
+	0x2009, 0x9c40, 0x8109, 0x11b0, 0x080c, 0x3cb3, 0x2001, 0x0004,
+	0x200c, 0x918c, 0xfffd, 0x2102, 0x001e, 0x00fe, 0x00ee, 0x00de,
+	0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e, 0x2009, 0x0017, 0x080c,
+	0x3376, 0x0cf8, 0x2001, 0x020b, 0x2004, 0x9084, 0x0140, 0x1d10,
+	0x00f6, 0x2079, 0x0000, 0x7884, 0x00fe, 0xd0bc, 0x0178, 0x2001,
+	0x0201, 0x200c, 0x81ff, 0x0150, 0x080c, 0x3d82, 0x2d00, 0x9c05,
+	0x9b05, 0x0120, 0x080c, 0x3cb3, 0x0804, 0x3c60, 0x080c, 0x3eeb,
+	0x080c, 0x3e0f, 0x080c, 0x3d65, 0x080c, 0x3d9a, 0x00f6, 0x2079,
+	0x0100, 0x7824, 0xd0ac, 0x0130, 0x8b58, 0x080c, 0x3cb3, 0x00fe,
+	0x0804, 0x3c60, 0x00fe, 0x080c, 0x3ca9, 0x1150, 0x8d68, 0x2001,
+	0x0032, 0x2602, 0x2001, 0x0033, 0x2502, 0x080c, 0x3cb3, 0x0080,
+	0x87ff, 0x0138, 0x2001, 0x0201, 0x2004, 0x9005, 0x1908, 0x8739,
+	0x0038, 0x2001, 0x1a3a, 0x2004, 0x9086, 0x0000, 0x1904, 0x3bb0,
+	0x2001, 0x032f, 0x2003, 0x00f6, 0x8631, 0x1208, 0x8529, 0x2500,
+	0x9605, 0x0904, 0x3c60, 0x7884, 0xd0bc, 0x0128, 0x2d00, 0x9c05,
+	0x9b05, 0x1904, 0x3c60, 0xa013, 0x0019, 0x2001, 0x032a, 0x2003,
+	0x0004, 0x7884, 0xd0ac, 0x1148, 0x2001, 0x1a3a, 0x2003, 0x0003,
+	0x2001, 0x032a, 0x2003, 0x0009, 0x0030, 0xa017, 0x0001, 0x78b4,
+	0x9005, 0x0108, 0xa016, 0x2800, 0xa05a, 0x2009, 0x0040, 0x080c,
+	0x2275, 0x2900, 0xa85a, 0xa813, 0x0019, 0x7884, 0xd0a4, 0x1180,
+	0xa817, 0x0000, 0x00c6, 0x20a9, 0x0004, 0x2061, 0x0090, 0x602b,
+	0x0008, 0x2001, 0x0203, 0x2004, 0x1f04, 0x3c37, 0x00ce, 0x0030,
+	0xa817, 0x0001, 0x78b0, 0x9005, 0x0108, 0xa816, 0x00f6, 0x00c6,
+	0x2079, 0x0100, 0x2061, 0x0090, 0x7827, 0x0002, 0x2001, 0x002a,
+	0x2004, 0x9084, 0xfff8, 0x601a, 0x0006, 0x2001, 0x002b, 0x2004,
+	0x601e, 0x78c6, 0x000e, 0x78ca, 0x00ce, 0x00fe, 0x0804, 0x3b6a,
+	0x001e, 0x00c6, 0x2001, 0x032a, 0x2003, 0x0004, 0x2061, 0x0100,
+	0x6027, 0x0002, 0x6106, 0x2011, 0x020d, 0x2013, 0x0020, 0x2001,
+	0x0004, 0x200c, 0x918c, 0xfffd, 0x2102, 0x080c, 0x129f, 0x7884,
+	0x9084, 0x0003, 0x9086, 0x0002, 0x01a0, 0x2009, 0x0028, 0x080c,
+	0x2275, 0x2001, 0x0227, 0x200c, 0x2102, 0x6050, 0x9084, 0xb7ef,
+	0x6052, 0x602f, 0x0000, 0x604b, 0xf7f7, 0x6043, 0x0090, 0x6043,
+	0x0010, 0x00ce, 0x2d08, 0x2c10, 0x2b18, 0x2b00, 0x9c05, 0x9d05,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e,
+	0x1118, 0x012e, 0x0804, 0x3344, 0x012e, 0x2021, 0x400c, 0x0804,
+	0x3346, 0x9085, 0x0001, 0x1d04, 0x3cb2, 0x2091, 0x6000, 0x8420,
+	0x9486, 0x0064, 0x0005, 0x2001, 0x0105, 0x2003, 0x0010, 0x2001,
+	0x032a, 0x2003, 0x0004, 0x2001, 0x1a3a, 0x2003, 0x0000, 0x0071,
+	0x2009, 0x0048, 0x080c, 0x2275, 0x2001, 0x0227, 0x2024, 0x2402,
+	0x2001, 0x0109, 0x2003, 0x4000, 0x9026, 0x0005, 0x00f6, 0x00e6,
+	0x2071, 0x1a3d, 0x7000, 0x9086, 0x0000, 0x0520, 0x2079, 0x0090,
+	0x2009, 0x0206, 0x2104, 0x2009, 0x0203, 0x210c, 0x9106, 0x1120,
+	0x2009, 0x0040, 0x080c, 0x2275, 0x782c, 0xd0fc, 0x0d88, 0x080c,
+	0x3eeb, 0x7000, 0x9086, 0x0000, 0x1d58, 0x782b, 0x0004, 0x782c,
+	0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x2275, 0x782b, 0x0002,
+	0x7003, 0x0000, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100,
+	0x2001, 0x1817, 0x200c, 0x7932, 0x7936, 0x080c, 0x26b9, 0x7850,
+	0x9084, 0xfbff, 0x9085, 0x0030, 0x7852, 0x2019, 0x01f4, 0x8319,
+	0x1df0, 0x9084, 0xffcf, 0x9085, 0x2000, 0x7852, 0x20a9, 0x0046,
+	0x1d04, 0x3d18, 0x2091, 0x6000, 0x1f04, 0x3d18, 0x7850, 0x9085,
+	0x0400, 0x9084, 0xdfff, 0x7852, 0x2001, 0x0021, 0x2004, 0x9084,
+	0x0003, 0x9086, 0x0001, 0x1120, 0x7850, 0x9084, 0xdfff, 0x7852,
+	0x784b, 0xf7f7, 0x7843, 0x0090, 0x7843, 0x0010, 0x20a9, 0x0028,
+	0xa001, 0x1f04, 0x3d38, 0x7850, 0x9085, 0x1400, 0x7852, 0x2019,
+	0x61a8, 0x7854, 0xa001, 0xa001, 0xd08c, 0x1110, 0x8319, 0x1dc8,
+	0x7827, 0x0048, 0x7850, 0x9085, 0x0400, 0x7852, 0x7843, 0x0040,
+	0x2019, 0x01f4, 0xa001, 0xa001, 0x8319, 0x1de0, 0x2001, 0x0100,
+	0x080c, 0x2b21, 0x7827, 0x0020, 0x7843, 0x0000, 0x9006, 0x080c,
+	0x2b21, 0x7827, 0x0048, 0x00fe, 0x0005, 0x7884, 0xd0ac, 0x11c8,
+	0x00f6, 0x00e6, 0x2071, 0x1a3a, 0x2079, 0x0320, 0x2001, 0x0201,
+	0x2004, 0x9005, 0x0160, 0x7000, 0x9086, 0x0000, 0x1140, 0x0051,
+	0xd0bc, 0x0108, 0x8738, 0x7003, 0x0003, 0x782b, 0x0019, 0x00ee,
+	0x00fe, 0x0005, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe, 0x908c,
+	0x0070, 0x0178, 0x2009, 0x0032, 0x260a, 0x2009, 0x0033, 0x250a,
+	0xd0b4, 0x0108, 0x8c60, 0xd0ac, 0x0108, 0x8d68, 0xd0a4, 0x0108,
+	0x8b58, 0x0005, 0x00f6, 0x2079, 0x0200, 0x781c, 0xd084, 0x0110,
+	0x7837, 0x0050, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x0100, 0x2001,
+	0x1982, 0x2004, 0x70e2, 0x080c, 0x3a94, 0x1188, 0x2001, 0x181f,
+	0x2004, 0x2009, 0x181e, 0x210c, 0x918c, 0x00ff, 0x706e, 0x716a,
+	0x7066, 0x918d, 0x3200, 0x7162, 0x7073, 0xe109, 0x0080, 0x702c,
+	0x9085, 0x0002, 0x702e, 0x2009, 0x1817, 0x210c, 0x716e, 0x7063,
+	0x0100, 0x7166, 0x719e, 0x706b, 0x0000, 0x7073, 0x0809, 0x7077,
+	0x0008, 0x7078, 0x9080, 0x0100, 0x707a, 0x7080, 0x8000, 0x7082,
+	0x7087, 0xaaaa, 0x9006, 0x708a, 0x708e, 0x707e, 0x70d6, 0x70ab,
+	0x0036, 0x70af, 0x95d5, 0x7014, 0x9084, 0x1984, 0x9085, 0x0092,
+	0x7016, 0x080c, 0x3eeb, 0x00f6, 0x2071, 0x1a3a, 0x2079, 0x0320,
+	0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120, 0x689c, 0x780e,
+	0x6898, 0x780a, 0x00de, 0x2009, 0x03e8, 0x8109, 0x1df0, 0x792c,
+	0xd1fc, 0x0110, 0x782b, 0x0004, 0x2011, 0x0011, 0x080c, 0x3e77,
+	0x2011, 0x0001, 0x080c, 0x3e77, 0x00fe, 0x00ee, 0x0005, 0x00f6,
+	0x00e6, 0x2071, 0x1a3a, 0x2079, 0x0320, 0x792c, 0xd1fc, 0x0904,
+	0x3e74, 0x782b, 0x0002, 0x9026, 0xd19c, 0x1904, 0x3e70, 0x7000,
+	0x0002, 0x3e74, 0x3e25, 0x3e55, 0x3e70, 0xd1bc, 0x1170, 0xd1dc,
+	0x1190, 0x8001, 0x7002, 0x2011, 0x0001, 0x080c, 0x3e77, 0x0904,
+	0x3e74, 0x080c, 0x3e77, 0x0804, 0x3e74, 0x00f6, 0x2079, 0x0300,
+	0x78bf, 0x0000, 0x00fe, 0x7810, 0x7914, 0x782b, 0x0004, 0x7812,
+	0x7916, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0de8, 0x080c, 0x3d82,
+	0x2009, 0x0001, 0x00f6, 0x2079, 0x0300, 0x78b8, 0x00fe, 0xd0ec,
+	0x0110, 0x2009, 0x0011, 0x792a, 0x00f8, 0x8001, 0x7002, 0x9184,
+	0x0880, 0x1140, 0x782c, 0xd0fc, 0x1904, 0x3e19, 0x2011, 0x0001,
+	0x00b1, 0x0090, 0xa010, 0x9092, 0x0004, 0x9086, 0x0015, 0x1120,
+	0xa000, 0xa05a, 0x2011, 0x0031, 0xa212, 0xd1dc, 0x1960, 0x0828,
+	0x782b, 0x0004, 0x7003, 0x0000, 0x00ee, 0x00fe, 0x0005, 0xa014,
+	0x9005, 0x0550, 0x8001, 0x0036, 0x0096, 0xa016, 0xa058, 0x2048,
+	0xa010, 0x2009, 0x0031, 0x911a, 0x831c, 0x831c, 0x938a, 0x0007,
+	0x1a0c, 0x0db4, 0x9398, 0x3ea5, 0x231d, 0x083f, 0x9080, 0x0004,
+	0x7a2a, 0x7100, 0x8108, 0x7102, 0x009e, 0x003e, 0x908a, 0x0035,
+	0x1140, 0x0096, 0xa058, 0x2048, 0xa804, 0xa05a, 0x2001, 0x0019,
+	0x009e, 0xa012, 0x9085, 0x0001, 0x0005, 0x3ee2, 0x3ed9, 0x3ed0,
+	0x3ec7, 0x3ebe, 0x3eb5, 0x3eac, 0xa964, 0x7902, 0xa968, 0x7906,
+	0xa96c, 0x7912, 0xa970, 0x7916, 0x0005, 0xa974, 0x7902, 0xa978,
+	0x7906, 0xa97c, 0x7912, 0xa980, 0x7916, 0x0005, 0xa984, 0x7902,
+	0xa988, 0x7906, 0xa98c, 0x7912, 0xa990, 0x7916, 0x0005, 0xa994,
+	0x7902, 0xa998, 0x7906, 0xa99c, 0x7912, 0xa9a0, 0x7916, 0x0005,
+	0xa9a4, 0x7902, 0xa9a8, 0x7906, 0xa9ac, 0x7912, 0xa9b0, 0x7916,
+	0x0005, 0xa9b4, 0x7902, 0xa9b8, 0x7906, 0xa9bc, 0x7912, 0xa9c0,
+	0x7916, 0x0005, 0xa9c4, 0x7902, 0xa9c8, 0x7906, 0xa9cc, 0x7912,
+	0xa9d0, 0x7916, 0x0005, 0x00f6, 0x00e6, 0x0086, 0x2071, 0x1a3d,
+	0x2079, 0x0090, 0x792c, 0xd1fc, 0x01e8, 0x782b, 0x0002, 0x2940,
+	0x9026, 0x7000, 0x0002, 0x3f12, 0x3efe, 0x3f09, 0x8001, 0x7002,
+	0xd19c, 0x1180, 0x2011, 0x0001, 0x080c, 0x3e77, 0x190c, 0x3e77,
+	0x0048, 0x8001, 0x7002, 0x782c, 0xd0fc, 0x1d38, 0x2011, 0x0001,
+	0x080c, 0x3e77, 0x008e, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x00e6,
+	0x00c6, 0x0086, 0x2061, 0x0200, 0x2001, 0x1982, 0x2004, 0x601a,
+	0x2061, 0x0100, 0x2001, 0x1981, 0x2004, 0x60ce, 0x6104, 0xc1ac,
+	0x6106, 0x2001, 0x002c, 0x2004, 0x9005, 0x0520, 0x2038, 0x2001,
+	0x002e, 0x2024, 0x2001, 0x002f, 0x201c, 0x080c, 0x4894, 0xa813,
+	0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007, 0x0220, 0x2138,
+	0x2009, 0x0007, 0x0010, 0x2708, 0x903e, 0x0096, 0xa858, 0x2048,
+	0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x3f8e, 0x1d68, 0x2900,
+	0xa85a, 0x00d0, 0x080c, 0x4894, 0xa813, 0x0019, 0xa817, 0x0001,
 	0x2900, 0xa85a, 0x2001, 0x002e, 0x2004, 0xa866, 0x2001, 0x002f,
-	0x2004, 0xa86a, 0x2061, 0x0090, 0x2079, 0x0100, 0x2001, 0x1979,
-	0x2004, 0x6036, 0x2009, 0x0040, 0x080c, 0x226a, 0x2001, 0x002a,
-	0x2004, 0x9084, 0xfff8, 0xa86e, 0x601a, 0xa873, 0x0000, 0x601f,
-	0x0000, 0x78ca, 0x9006, 0x600a, 0x600e, 0x00ce, 0x00ee, 0x00fe,
-	0x0005, 0x00e6, 0x080c, 0x4889, 0x2940, 0xa013, 0x0019, 0xa017,
-	0x0001, 0x2800, 0xa05a, 0x2001, 0x0030, 0x2004, 0xa866, 0x2001,
-	0x0031, 0x2004, 0xa86a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8,
-	0xa86e, 0xa873, 0x0000, 0x2001, 0x032a, 0x2003, 0x0004, 0x2001,
-	0x0300, 0x2003, 0x0000, 0x2001, 0x020d, 0x2003, 0x0000, 0x2001,
-	0x0004, 0x200c, 0x918d, 0x0002, 0x2102, 0x00ee, 0x0005, 0x0126,
-	0x2091, 0x8000, 0x81ff, 0x0148, 0x080c, 0x2a57, 0x1130, 0x9006,
-	0x080c, 0x29af, 0x9006, 0x080c, 0x2992, 0x7884, 0x9084, 0x0007,
-	0x0002, 0x3b24, 0x3b2d, 0x3b36, 0x3b21, 0x3b21, 0x3b21, 0x3b21,
-	0x3b21, 0x012e, 0x0804, 0x336e, 0x2009, 0x0114, 0x2104, 0x9085,
-	0x0800, 0x200a, 0x080c, 0x3cf2, 0x00c0, 0x2009, 0x0114, 0x2104,
-	0x9085, 0x4000, 0x200a, 0x080c, 0x3cf2, 0x0078, 0x080c, 0x6f9b,
-	0x1128, 0x012e, 0x2009, 0x0016, 0x0804, 0x336b, 0x81ff, 0x0128,
-	0x012e, 0x2021, 0x400b, 0x0804, 0x333b, 0x0086, 0x0096, 0x00a6,
-	0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x080c, 0x3853, 0x2009,
-	0x0101, 0x210c, 0x0016, 0x7ec8, 0x7dcc, 0x9006, 0x2068, 0x2060,
-	0x2058, 0x080c, 0x3fbb, 0x080c, 0x3f0b, 0x903e, 0x2720, 0x00f6,
-	0x00e6, 0x0086, 0x2940, 0x2071, 0x1a35, 0x2079, 0x0090, 0x00d6,
-	0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120, 0x68d4, 0x780e, 0x68d0,
-	0x780a, 0x00de, 0x2011, 0x0001, 0x080c, 0x3e6c, 0x080c, 0x2a5f,
-	0x080c, 0x2a5f, 0x080c, 0x2a5f, 0x080c, 0x2a5f, 0x080c, 0x3e6c,
-	0x008e, 0x00ee, 0x00fe, 0x080c, 0x3d99, 0x2009, 0x9c40, 0x8109,
-	0x11b0, 0x080c, 0x3ca8, 0x2001, 0x0004, 0x200c, 0x918c, 0xfffd,
-	0x2102, 0x001e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae,
-	0x009e, 0x008e, 0x2009, 0x0017, 0x080c, 0x336b, 0x0cf8, 0x2001,
-	0x020b, 0x2004, 0x9084, 0x0140, 0x1d10, 0x00f6, 0x2079, 0x0000,
-	0x7884, 0x00fe, 0xd0bc, 0x0178, 0x2001, 0x0201, 0x200c, 0x81ff,
-	0x0150, 0x080c, 0x3d77, 0x2d00, 0x9c05, 0x9b05, 0x0120, 0x080c,
-	0x3ca8, 0x0804, 0x3c55, 0x080c, 0x3ee0, 0x080c, 0x3e04, 0x080c,
-	0x3d5a, 0x080c, 0x3d8f, 0x00f6, 0x2079, 0x0100, 0x7824, 0xd0ac,
-	0x0130, 0x8b58, 0x080c, 0x3ca8, 0x00fe, 0x0804, 0x3c55, 0x00fe,
-	0x080c, 0x3c9e, 0x1150, 0x8d68, 0x2001, 0x0032, 0x2602, 0x2001,
-	0x0033, 0x2502, 0x080c, 0x3ca8, 0x0080, 0x87ff, 0x0138, 0x2001,
-	0x0201, 0x2004, 0x9005, 0x1908, 0x8739, 0x0038, 0x2001, 0x1a32,
-	0x2004, 0x9086, 0x0000, 0x1904, 0x3ba5, 0x2001, 0x032f, 0x2003,
-	0x00f6, 0x8631, 0x1208, 0x8529, 0x2500, 0x9605, 0x0904, 0x3c55,
-	0x7884, 0xd0bc, 0x0128, 0x2d00, 0x9c05, 0x9b05, 0x1904, 0x3c55,
-	0xa013, 0x0019, 0x2001, 0x032a, 0x2003, 0x0004, 0x7884, 0xd0ac,
-	0x1148, 0x2001, 0x1a32, 0x2003, 0x0003, 0x2001, 0x032a, 0x2003,
-	0x0009, 0x0030, 0xa017, 0x0001, 0x78b4, 0x9005, 0x0108, 0xa016,
-	0x2800, 0xa05a, 0x2009, 0x0040, 0x080c, 0x226a, 0x2900, 0xa85a,
-	0xa813, 0x0019, 0x7884, 0xd0a4, 0x1180, 0xa817, 0x0000, 0x00c6,
-	0x20a9, 0x0004, 0x2061, 0x0090, 0x602b, 0x0008, 0x2001, 0x0203,
-	0x2004, 0x1f04, 0x3c2c, 0x00ce, 0x0030, 0xa817, 0x0001, 0x78b0,
-	0x9005, 0x0108, 0xa816, 0x00f6, 0x00c6, 0x2079, 0x0100, 0x2061,
-	0x0090, 0x7827, 0x0002, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8,
-	0x601a, 0x0006, 0x2001, 0x002b, 0x2004, 0x601e, 0x78c6, 0x000e,
-	0x78ca, 0x00ce, 0x00fe, 0x0804, 0x3b5f, 0x001e, 0x00c6, 0x2001,
-	0x032a, 0x2003, 0x0004, 0x2061, 0x0100, 0x6027, 0x0002, 0x6106,
-	0x2011, 0x020d, 0x2013, 0x0020, 0x2001, 0x0004, 0x200c, 0x918c,
-	0xfffd, 0x2102, 0x080c, 0x129f, 0x7884, 0x9084, 0x0003, 0x9086,
-	0x0002, 0x01a0, 0x2009, 0x0028, 0x080c, 0x226a, 0x2001, 0x0227,
-	0x200c, 0x2102, 0x6050, 0x9084, 0xb7ef, 0x6052, 0x602f, 0x0000,
-	0x604b, 0xf7f7, 0x6043, 0x0090, 0x6043, 0x0010, 0x00ce, 0x2d08,
-	0x2c10, 0x2b18, 0x2b00, 0x9c05, 0x9d05, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e, 0x1118, 0x012e, 0x0804,
-	0x3339, 0x012e, 0x2021, 0x400c, 0x0804, 0x333b, 0x9085, 0x0001,
-	0x1d04, 0x3ca7, 0x2091, 0x6000, 0x8420, 0x9486, 0x0064, 0x0005,
-	0x2001, 0x0105, 0x2003, 0x0010, 0x2001, 0x032a, 0x2003, 0x0004,
-	0x2001, 0x1a32, 0x2003, 0x0000, 0x0071, 0x2009, 0x0048, 0x080c,
-	0x226a, 0x2001, 0x0227, 0x2024, 0x2402, 0x2001, 0x0109, 0x2003,
-	0x4000, 0x9026, 0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a35, 0x7000,
-	0x9086, 0x0000, 0x0520, 0x2079, 0x0090, 0x2009, 0x0206, 0x2104,
-	0x2009, 0x0203, 0x210c, 0x9106, 0x1120, 0x2009, 0x0040, 0x080c,
-	0x226a, 0x782c, 0xd0fc, 0x0d88, 0x080c, 0x3ee0, 0x7000, 0x9086,
-	0x0000, 0x1d58, 0x782b, 0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009,
-	0x0040, 0x080c, 0x226a, 0x782b, 0x0002, 0x7003, 0x0000, 0x00ee,
-	0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100, 0x2001, 0x1817, 0x200c,
-	0x7932, 0x7936, 0x080c, 0x26ae, 0x7850, 0x9084, 0xfbff, 0x9085,
-	0x0030, 0x7852, 0x2019, 0x01f4, 0x8319, 0x1df0, 0x9084, 0xffcf,
-	0x9085, 0x2000, 0x7852, 0x20a9, 0x0046, 0x1d04, 0x3d0d, 0x2091,
-	0x6000, 0x1f04, 0x3d0d, 0x7850, 0x9085, 0x0400, 0x9084, 0xdfff,
-	0x7852, 0x2001, 0x0021, 0x2004, 0x9084, 0x0003, 0x9086, 0x0001,
-	0x1120, 0x7850, 0x9084, 0xdfff, 0x7852, 0x784b, 0xf7f7, 0x7843,
-	0x0090, 0x7843, 0x0010, 0x20a9, 0x0028, 0xa001, 0x1f04, 0x3d2d,
-	0x7850, 0x9085, 0x1400, 0x7852, 0x2019, 0x61a8, 0x7854, 0xa001,
-	0xa001, 0xd08c, 0x1110, 0x8319, 0x1dc8, 0x7827, 0x0048, 0x7850,
-	0x9085, 0x0400, 0x7852, 0x7843, 0x0040, 0x2019, 0x01f4, 0xa001,
-	0xa001, 0x8319, 0x1de0, 0x2001, 0x0100, 0x080c, 0x2b16, 0x7827,
-	0x0020, 0x7843, 0x0000, 0x9006, 0x080c, 0x2b16, 0x7827, 0x0048,
-	0x00fe, 0x0005, 0x7884, 0xd0ac, 0x11c8, 0x00f6, 0x00e6, 0x2071,
-	0x1a32, 0x2079, 0x0320, 0x2001, 0x0201, 0x2004, 0x9005, 0x0160,
-	0x7000, 0x9086, 0x0000, 0x1140, 0x0051, 0xd0bc, 0x0108, 0x8738,
-	0x7003, 0x0003, 0x782b, 0x0019, 0x00ee, 0x00fe, 0x0005, 0x00f6,
-	0x2079, 0x0300, 0x78bc, 0x00fe, 0x908c, 0x0070, 0x0178, 0x2009,
-	0x0032, 0x260a, 0x2009, 0x0033, 0x250a, 0xd0b4, 0x0108, 0x8c60,
-	0xd0ac, 0x0108, 0x8d68, 0xd0a4, 0x0108, 0x8b58, 0x0005, 0x00f6,
-	0x2079, 0x0200, 0x781c, 0xd084, 0x0110, 0x7837, 0x0050, 0x00fe,
-	0x0005, 0x00e6, 0x2071, 0x0100, 0x2001, 0x197a, 0x2004, 0x70e2,
-	0x080c, 0x3a89, 0x1188, 0x2001, 0x181f, 0x2004, 0x2009, 0x181e,
-	0x210c, 0x918c, 0x00ff, 0x706e, 0x716a, 0x7066, 0x918d, 0x3200,
-	0x7162, 0x7073, 0xe109, 0x0080, 0x702c, 0x9085, 0x0002, 0x702e,
-	0x2009, 0x1817, 0x210c, 0x716e, 0x7063, 0x0100, 0x7166, 0x719e,
-	0x706b, 0x0000, 0x7073, 0x0809, 0x7077, 0x0008, 0x7078, 0x9080,
-	0x0100, 0x707a, 0x7080, 0x8000, 0x7082, 0x7087, 0xaaaa, 0x9006,
-	0x708a, 0x708e, 0x707e, 0x70d6, 0x70ab, 0x0036, 0x70af, 0x95d5,
-	0x7014, 0x9084, 0x1984, 0x9085, 0x0092, 0x7016, 0x080c, 0x3ee0,
-	0x00f6, 0x2071, 0x1a32, 0x2079, 0x0320, 0x00d6, 0x2069, 0x0000,
-	0x6884, 0xd0b4, 0x0120, 0x689c, 0x780e, 0x6898, 0x780a, 0x00de,
-	0x2009, 0x03e8, 0x8109, 0x1df0, 0x792c, 0xd1fc, 0x0110, 0x782b,
-	0x0004, 0x2011, 0x0011, 0x080c, 0x3e6c, 0x2011, 0x0001, 0x080c,
-	0x3e6c, 0x00fe, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a32,
-	0x2079, 0x0320, 0x792c, 0xd1fc, 0x0904, 0x3e69, 0x782b, 0x0002,
-	0x9026, 0xd19c, 0x1904, 0x3e65, 0x7000, 0x0002, 0x3e69, 0x3e1a,
-	0x3e4a, 0x3e65, 0xd1bc, 0x1170, 0xd1dc, 0x1190, 0x8001, 0x7002,
-	0x2011, 0x0001, 0x080c, 0x3e6c, 0x0904, 0x3e69, 0x080c, 0x3e6c,
-	0x0804, 0x3e69, 0x00f6, 0x2079, 0x0300, 0x78bf, 0x0000, 0x00fe,
-	0x7810, 0x7914, 0x782b, 0x0004, 0x7812, 0x7916, 0x2001, 0x0201,
-	0x200c, 0x81ff, 0x0de8, 0x080c, 0x3d77, 0x2009, 0x0001, 0x00f6,
-	0x2079, 0x0300, 0x78b8, 0x00fe, 0xd0ec, 0x0110, 0x2009, 0x0011,
-	0x792a, 0x00f8, 0x8001, 0x7002, 0x9184, 0x0880, 0x1140, 0x782c,
-	0xd0fc, 0x1904, 0x3e0e, 0x2011, 0x0001, 0x00b1, 0x0090, 0xa010,
-	0x9092, 0x0004, 0x9086, 0x0015, 0x1120, 0xa000, 0xa05a, 0x2011,
-	0x0031, 0xa212, 0xd1dc, 0x1960, 0x0828, 0x782b, 0x0004, 0x7003,
-	0x0000, 0x00ee, 0x00fe, 0x0005, 0xa014, 0x9005, 0x0550, 0x8001,
-	0x0036, 0x0096, 0xa016, 0xa058, 0x2048, 0xa010, 0x2009, 0x0031,
-	0x911a, 0x831c, 0x831c, 0x938a, 0x0007, 0x1a0c, 0x0db4, 0x9398,
-	0x3e9a, 0x231d, 0x083f, 0x9080, 0x0004, 0x7a2a, 0x7100, 0x8108,
-	0x7102, 0x009e, 0x003e, 0x908a, 0x0035, 0x1140, 0x0096, 0xa058,
-	0x2048, 0xa804, 0xa05a, 0x2001, 0x0019, 0x009e, 0xa012, 0x9085,
-	0x0001, 0x0005, 0x3ed7, 0x3ece, 0x3ec5, 0x3ebc, 0x3eb3, 0x3eaa,
-	0x3ea1, 0xa964, 0x7902, 0xa968, 0x7906, 0xa96c, 0x7912, 0xa970,
-	0x7916, 0x0005, 0xa974, 0x7902, 0xa978, 0x7906, 0xa97c, 0x7912,
-	0xa980, 0x7916, 0x0005, 0xa984, 0x7902, 0xa988, 0x7906, 0xa98c,
-	0x7912, 0xa990, 0x7916, 0x0005, 0xa994, 0x7902, 0xa998, 0x7906,
-	0xa99c, 0x7912, 0xa9a0, 0x7916, 0x0005, 0xa9a4, 0x7902, 0xa9a8,
-	0x7906, 0xa9ac, 0x7912, 0xa9b0, 0x7916, 0x0005, 0xa9b4, 0x7902,
-	0xa9b8, 0x7906, 0xa9bc, 0x7912, 0xa9c0, 0x7916, 0x0005, 0xa9c4,
-	0x7902, 0xa9c8, 0x7906, 0xa9cc, 0x7912, 0xa9d0, 0x7916, 0x0005,
-	0x00f6, 0x00e6, 0x0086, 0x2071, 0x1a35, 0x2079, 0x0090, 0x792c,
-	0xd1fc, 0x01e8, 0x782b, 0x0002, 0x2940, 0x9026, 0x7000, 0x0002,
-	0x3f07, 0x3ef3, 0x3efe, 0x8001, 0x7002, 0xd19c, 0x1180, 0x2011,
-	0x0001, 0x080c, 0x3e6c, 0x190c, 0x3e6c, 0x0048, 0x8001, 0x7002,
-	0x782c, 0xd0fc, 0x1d38, 0x2011, 0x0001, 0x080c, 0x3e6c, 0x008e,
-	0x00ee, 0x00fe, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0086, 0x2061,
-	0x0200, 0x2001, 0x197a, 0x2004, 0x601a, 0x2061, 0x0100, 0x2001,
-	0x1979, 0x2004, 0x60ce, 0x6104, 0xc1ac, 0x6106, 0x2001, 0x002c,
-	0x2004, 0x9005, 0x0520, 0x2038, 0x2001, 0x002e, 0x2024, 0x2001,
-	0x002f, 0x201c, 0x080c, 0x4889, 0xa813, 0x0019, 0xaf16, 0x2900,
-	0xa85a, 0x978a, 0x0007, 0x0220, 0x2138, 0x2009, 0x0007, 0x0010,
-	0x2708, 0x903e, 0x0096, 0xa858, 0x2048, 0xa85c, 0x9080, 0x0019,
-	0x009e, 0x080c, 0x3f83, 0x1d68, 0x2900, 0xa85a, 0x00d0, 0x080c,
-	0x4889, 0xa813, 0x0019, 0xa817, 0x0001, 0x2900, 0xa85a, 0x2001,
-	0x002e, 0x2004, 0xa866, 0x2001, 0x002f, 0x2004, 0xa86a, 0x2001,
-	0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e, 0x2001, 0x002b, 0x2004,
-	0xa872, 0x2061, 0x0090, 0x2079, 0x0100, 0x2001, 0x1979, 0x2004,
-	0x6036, 0x2009, 0x0040, 0x080c, 0x226a, 0x2001, 0x002a, 0x2004,
-	0x9084, 0xfff8, 0x601a, 0x0006, 0x2001, 0x002b, 0x2004, 0x601e,
-	0x78c6, 0x000e, 0x78ca, 0x9006, 0x600a, 0x600e, 0x008e, 0x00ce,
-	0x00ee, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x0080, 0xaa60, 0x22e8,
-	0x20a0, 0x20e1, 0x0000, 0x2099, 0x0088, 0x702b, 0x0026, 0x7402,
-	0x7306, 0x9006, 0x700a, 0x700e, 0x810b, 0x810b, 0x21a8, 0x810b,
-	0x7112, 0x702b, 0x0041, 0x702c, 0xd0fc, 0x0de8, 0x702b, 0x0002,
-	0x702b, 0x0040, 0x4005, 0x7400, 0x7304, 0x87ff, 0x0190, 0x0086,
-	0x0096, 0x2940, 0x0086, 0x080c, 0x4889, 0x008e, 0xa058, 0x00a6,
-	0x2050, 0x2900, 0xb006, 0xa05a, 0x00ae, 0x009e, 0x008e, 0x9085,
-	0x0001, 0x00ee, 0x0005, 0x00e6, 0x2001, 0x002d, 0x2004, 0x9005,
-	0x0528, 0x2038, 0x2001, 0x0030, 0x2024, 0x2001, 0x0031, 0x201c,
-	0x080c, 0x4889, 0x2940, 0xa813, 0x0019, 0xaf16, 0x2900, 0xa85a,
-	0x978a, 0x0007, 0x0220, 0x2138, 0x2009, 0x0007, 0x0010, 0x2708,
-	0x903e, 0x0096, 0xa858, 0x2048, 0xa85c, 0x9080, 0x0019, 0x009e,
-	0x080c, 0x3f83, 0x1d68, 0x2900, 0xa85a, 0x00d8, 0x080c, 0x4889,
-	0x2940, 0xa013, 0x0019, 0xa017, 0x0001, 0x2800, 0xa05a, 0x2001,
-	0x0030, 0x2004, 0xa066, 0x2001, 0x0031, 0x2004, 0xa06a, 0x2001,
-	0x002a, 0x2004, 0x9084, 0xfff8, 0xa06e, 0x2001, 0x002b, 0x2004,
-	0xa072, 0x2001, 0x032a, 0x2003, 0x0004, 0x7884, 0xd0ac, 0x1180,
-	0x2001, 0x0101, 0x200c, 0x918d, 0x0200, 0x2102, 0xa017, 0x0000,
-	0x2001, 0x1a32, 0x2003, 0x0003, 0x2001, 0x032a, 0x2003, 0x0009,
-	0x2001, 0x0300, 0x2003, 0x0000, 0x2001, 0x020d, 0x2003, 0x0000,
-	0x2001, 0x0004, 0x200c, 0x918d, 0x0002, 0x2102, 0x00ee, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x20a9, 0x0013, 0x20a1, 0x1840, 0x20e9,
-	0x0001, 0x9006, 0x4004, 0x2009, 0x013c, 0x200a, 0x012e, 0x7880,
-	0x9086, 0x0052, 0x0108, 0x0005, 0x0804, 0x3339, 0x7d98, 0x7c9c,
-	0x0804, 0x343b, 0x080c, 0x6f9b, 0x190c, 0x5c9f, 0x2069, 0x1853,
-	0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039,
-	0x0001, 0x080c, 0x48d2, 0x701f, 0x4056, 0x0005, 0x080c, 0x539e,
-	0x1130, 0x3b00, 0x3a08, 0xc194, 0xc095, 0x20d8, 0x21d0, 0x2069,
-	0x1853, 0x6800, 0x9005, 0x0904, 0x336e, 0x6804, 0xd094, 0x00c6,
-	0x2061, 0x0100, 0x6104, 0x0138, 0x6200, 0x9292, 0x0005, 0x0218,
-	0x918c, 0xffdf, 0x0010, 0x918d, 0x0020, 0x6106, 0x00ce, 0xd08c,
-	0x00c6, 0x2061, 0x0100, 0x6104, 0x0118, 0x918d, 0x0010, 0x0010,
-	0x918c, 0xffef, 0x6106, 0x00ce, 0xd084, 0x0158, 0x6a28, 0x928a,
-	0x007f, 0x1a04, 0x336e, 0x9288, 0x313a, 0x210d, 0x918c, 0x00ff,
-	0x6162, 0xd0dc, 0x0130, 0x6828, 0x908a, 0x007f, 0x1a04, 0x336e,
-	0x605a, 0x6888, 0x9084, 0x0030, 0x8004, 0x8004, 0x8004, 0x8004,
-	0x0006, 0x2009, 0x1981, 0x9080, 0x27a1, 0x2005, 0x200a, 0x000e,
-	0x2009, 0x1982, 0x9080, 0x27a5, 0x2005, 0x200a, 0x6808, 0x908a,
-	0x0100, 0x0a04, 0x336e, 0x908a, 0x0841, 0x1a04, 0x336e, 0x9084,
-	0x0007, 0x1904, 0x336e, 0x680c, 0x9005, 0x0904, 0x336e, 0x6810,
-	0x9005, 0x0904, 0x336e, 0x6848, 0x6940, 0x910a, 0x1a04, 0x336e,
-	0x8001, 0x0904, 0x336e, 0x684c, 0x6944, 0x910a, 0x1a04, 0x336e,
-	0x8001, 0x0904, 0x336e, 0x2009, 0x1951, 0x200b, 0x0000, 0x2001,
-	0x1875, 0x2004, 0xd0c4, 0x0140, 0x7884, 0x200a, 0x2009, 0x017f,
-	0x200a, 0x3b00, 0xc085, 0x20d8, 0x6814, 0x908c, 0x00ff, 0x614a,
-	0x8007, 0x9084, 0x00ff, 0x604e, 0x080c, 0x72b0, 0x080c, 0x6634,
-	0x080c, 0x6669, 0x6808, 0x602a, 0x080c, 0x21dc, 0x2009, 0x0170,
-	0x200b, 0x0080, 0xa001, 0xa001, 0x200b, 0x0000, 0x0036, 0x6b08,
-	0x080c, 0x2708, 0x003e, 0x6000, 0x9086, 0x0000, 0x1904, 0x41d3,
-	0x6818, 0x691c, 0x6a20, 0x6b24, 0x8007, 0x810f, 0x8217, 0x831f,
-	0x6016, 0x611a, 0x621e, 0x6322, 0x6c04, 0xd4f4, 0x0148, 0x6830,
-	0x6934, 0x6a38, 0x6b3c, 0x8007, 0x810f, 0x8217, 0x831f, 0x0010,
-	0x9084, 0xf0ff, 0x6006, 0x610a, 0x620e, 0x6312, 0x8007, 0x810f,
-	0x8217, 0x831f, 0x20a9, 0x0004, 0x20a1, 0x1983, 0x20e9, 0x0001,
-	0x4001, 0x20a9, 0x0004, 0x20a1, 0x199d, 0x20e9, 0x0001, 0x4001,
-	0x080c, 0x812a, 0x00c6, 0x900e, 0x20a9, 0x0001, 0x6b70, 0xd384,
-	0x0510, 0x0068, 0x2009, 0x0100, 0x210c, 0x918e, 0x0008, 0x1110,
-	0x839d, 0x0010, 0x83f5, 0x3e18, 0x12b0, 0x3508, 0x8109, 0x080c,
-	0x787b, 0x6878, 0x6016, 0x6874, 0x2008, 0x9084, 0xff00, 0x8007,
-	0x600a, 0x9184, 0x00ff, 0x6006, 0x8108, 0x1118, 0x6003, 0x0003,
-	0x0010, 0x6003, 0x0001, 0x1f04, 0x4142, 0x00ce, 0x00c6, 0x2061,
-	0x196c, 0x2063, 0x0001, 0x9006, 0x080c, 0x29af, 0x9006, 0x080c,
-	0x2992, 0x0000, 0x00ce, 0x00e6, 0x2c70, 0x080c, 0x0e80, 0x00ee,
-	0x6888, 0xd0ec, 0x0130, 0x2011, 0x0114, 0x2204, 0x9085, 0x0100,
-	0x2012, 0x6a80, 0x9284, 0x0030, 0x9086, 0x0030, 0x1128, 0x9294,
-	0xffcf, 0x9295, 0x0020, 0x6a82, 0x2001, 0x194c, 0x6a80, 0x9294,
-	0x0030, 0x928e, 0x0000, 0x0170, 0x928e, 0x0010, 0x0118, 0x928e,
-	0x0020, 0x0140, 0x2003, 0xaaaa, 0x080c, 0x277d, 0x2001, 0x193d,
-	0x2102, 0x0008, 0x2102, 0x00c6, 0x2061, 0x0100, 0x602f, 0x0040,
-	0x602f, 0x0000, 0x00ce, 0x080c, 0x6f9b, 0x0128, 0x080c, 0x4c9b,
-	0x0110, 0x080c, 0x26ce, 0x60d0, 0x9005, 0x01c0, 0x6003, 0x0001,
-	0x2009, 0x41bb, 0x00d0, 0x080c, 0x6f9b, 0x1168, 0x2011, 0x6e1c,
-	0x080c, 0x8021, 0x2011, 0x6e0f, 0x080c, 0x80f5, 0x080c, 0x7284,
-	0x080c, 0x6ecd, 0x0040, 0x080c, 0x5b99, 0x0028, 0x6003, 0x0004,
-	0x2009, 0x41d3, 0x0010, 0x0804, 0x3339, 0x2001, 0x0170, 0x2004,
-	0x9084, 0x00ff, 0x9086, 0x004c, 0x1118, 0x2091, 0x30bd, 0x0817,
-	0x2091, 0x303d, 0x0817, 0x6000, 0x9086, 0x0000, 0x0904, 0x336b,
-	0x2069, 0x1853, 0x7890, 0x6842, 0x7894, 0x6846, 0x2d00, 0x2009,
-	0x0030, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0001, 0x0804,
-	0x48d5, 0x9006, 0x080c, 0x26ce, 0x81ff, 0x1904, 0x336b, 0x080c,
-	0x6f9b, 0x11b0, 0x080c, 0x727f, 0x080c, 0x5cda, 0x080c, 0x3135,
-	0x0118, 0x6130, 0xc18d, 0x6132, 0x080c, 0xc22c, 0x0130, 0x080c,
-	0x6fbe, 0x1118, 0x080c, 0x6f73, 0x0038, 0x080c, 0x6ecd, 0x0020,
-	0x080c, 0x5c9f, 0x080c, 0x5b99, 0x0804, 0x3339, 0x81ff, 0x1904,
-	0x336b, 0x080c, 0x6f9b, 0x1110, 0x0804, 0x336b, 0x6190, 0x81ff,
-	0x01a8, 0x704f, 0x0000, 0x2001, 0x1c80, 0x2009, 0x0040, 0x7a8c,
-	0x7b88, 0x7c9c, 0x7d98, 0x0126, 0x2091, 0x8000, 0x2039, 0x0001,
-	0x080c, 0x48d5, 0x701f, 0x3337, 0x012e, 0x0005, 0x704f, 0x0001,
-	0x00d6, 0x2069, 0x1c80, 0x20a9, 0x0040, 0x20e9, 0x0001, 0x20a1,
-	0x1c80, 0x2019, 0xffff, 0x4304, 0x6558, 0x9588, 0x313a, 0x210d,
-	0x918c, 0x00ff, 0x216a, 0x900e, 0x2011, 0x0002, 0x2100, 0x9506,
-	0x01a8, 0x080c, 0x6247, 0x1190, 0xb814, 0x821c, 0x0238, 0x9398,
-	0x1c80, 0x9085, 0xff00, 0x8007, 0x201a, 0x0038, 0x9398, 0x1c80,
-	0x2324, 0x94a4, 0xff00, 0x9405, 0x201a, 0x8210, 0x8108, 0x9182,
-	0x0080, 0x1208, 0x0c18, 0x8201, 0x8007, 0x2d0c, 0x9105, 0x206a,
-	0x00de, 0x20a9, 0x0040, 0x20a1, 0x1c80, 0x2099, 0x1c80, 0x080c,
-	0x5c2a, 0x0804, 0x422b, 0x080c, 0x48bc, 0x0904, 0x336e, 0x080c,
-	0x4889, 0x1120, 0x2009, 0x0002, 0x0804, 0x336b, 0x080c, 0x538f,
-	0xd0b4, 0x0558, 0x7884, 0x908e, 0x007e, 0x0538, 0x908e, 0x007f,
-	0x0520, 0x908e, 0x0080, 0x0508, 0x080c, 0x3130, 0x1148, 0xb800,
-	0xd08c, 0x11d8, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x11a8,
-	0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xbcf5, 0x1120,
-	0x2009, 0x0003, 0x0804, 0x336b, 0x7007, 0x0003, 0x701f, 0x42b9,
-	0x0005, 0x080c, 0x48bc, 0x0904, 0x336e, 0x20a9, 0x002b, 0xb8b4,
-	0x20e0, 0xb8b8, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
-	0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0, 0xb8b4,
-	0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098, 0x080c, 0x0f68, 0x0070,
-	0x20a9, 0x0004, 0xa85c, 0x9080, 0x000a, 0x20a0, 0xb8b4, 0x20e0,
-	0xb8b8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0f68, 0x8906, 0x8006,
-	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009,
-	0x002b, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x48d5, 0x81ff,
-	0x1904, 0x336b, 0x080c, 0x48a0, 0x0904, 0x336e, 0x080c, 0x63b9,
-	0x0904, 0x336b, 0x0058, 0xa878, 0x9005, 0x0120, 0x2009, 0x0004,
-	0x0804, 0x336b, 0xa974, 0xaa94, 0x0804, 0x3339, 0x080c, 0x5397,
-	0x0904, 0x3339, 0x701f, 0x4303, 0x7007, 0x0003, 0x0005, 0x81ff,
-	0x1904, 0x336b, 0x7888, 0x908a, 0x1000, 0x1a04, 0x336e, 0x080c,
-	0x48bc, 0x0904, 0x336e, 0x080c, 0x656b, 0x0120, 0x080c, 0x6573,
-	0x1904, 0x336e, 0x080c, 0x643e, 0x0904, 0x336b, 0x2019, 0x0004,
-	0x900e, 0x080c, 0x63cb, 0x0904, 0x336b, 0x7984, 0x7a88, 0x04c9,
-	0x08a8, 0xa89c, 0x908a, 0x1000, 0x12f8, 0x080c, 0x48ba, 0x01e0,
-	0x080c, 0x656b, 0x0118, 0x080c, 0x6573, 0x11b0, 0x080c, 0x643e,
-	0x2009, 0x0002, 0x0168, 0x2009, 0x0002, 0x2019, 0x0004, 0x080c,
-	0x63cb, 0x2009, 0x0003, 0x0120, 0xa998, 0xaa9c, 0x00d1, 0x0060,
-	0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085,
-	0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0x080c, 0x5397,
+	0x2004, 0xa86a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e,
+	0x2001, 0x002b, 0x2004, 0xa872, 0x2061, 0x0090, 0x2079, 0x0100,
+	0x2001, 0x1981, 0x2004, 0x6036, 0x2009, 0x0040, 0x080c, 0x2275,
+	0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a, 0x0006, 0x2001,
+	0x002b, 0x2004, 0x601e, 0x78c6, 0x000e, 0x78ca, 0x9006, 0x600a,
+	0x600e, 0x008e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00e6, 0x2071,
+	0x0080, 0xaa60, 0x22e8, 0x20a0, 0x20e1, 0x0000, 0x2099, 0x0088,
+	0x702b, 0x0026, 0x7402, 0x7306, 0x9006, 0x700a, 0x700e, 0x810b,
+	0x810b, 0x21a8, 0x810b, 0x7112, 0x702b, 0x0041, 0x702c, 0xd0fc,
+	0x0de8, 0x702b, 0x0002, 0x702b, 0x0040, 0x4005, 0x7400, 0x7304,
+	0x87ff, 0x0190, 0x0086, 0x0096, 0x2940, 0x0086, 0x080c, 0x4894,
+	0x008e, 0xa058, 0x00a6, 0x2050, 0x2900, 0xb006, 0xa05a, 0x00ae,
+	0x009e, 0x008e, 0x9085, 0x0001, 0x00ee, 0x0005, 0x00e6, 0x2001,
+	0x002d, 0x2004, 0x9005, 0x0528, 0x2038, 0x2001, 0x0030, 0x2024,
+	0x2001, 0x0031, 0x201c, 0x080c, 0x4894, 0x2940, 0xa813, 0x0019,
+	0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007, 0x0220, 0x2138, 0x2009,
+	0x0007, 0x0010, 0x2708, 0x903e, 0x0096, 0xa858, 0x2048, 0xa85c,
+	0x9080, 0x0019, 0x009e, 0x080c, 0x3f8e, 0x1d68, 0x2900, 0xa85a,
+	0x00d8, 0x080c, 0x4894, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001,
+	0x2800, 0xa05a, 0x2001, 0x0030, 0x2004, 0xa066, 0x2001, 0x0031,
+	0x2004, 0xa06a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa06e,
+	0x2001, 0x002b, 0x2004, 0xa072, 0x2001, 0x032a, 0x2003, 0x0004,
+	0x7884, 0xd0ac, 0x1180, 0x2001, 0x0101, 0x200c, 0x918d, 0x0200,
+	0x2102, 0xa017, 0x0000, 0x2001, 0x1a3a, 0x2003, 0x0003, 0x2001,
+	0x032a, 0x2003, 0x0009, 0x2001, 0x0300, 0x2003, 0x0000, 0x2001,
+	0x020d, 0x2003, 0x0000, 0x2001, 0x0004, 0x200c, 0x918d, 0x0002,
+	0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x20a9, 0x001b,
+	0x20a1, 0x1840, 0x20e9, 0x0001, 0x9006, 0x4004, 0x2009, 0x013c,
+	0x200a, 0x012e, 0x7880, 0x9086, 0x0052, 0x0108, 0x0005, 0x0804,
+	0x3344, 0x7d98, 0x7c9c, 0x0804, 0x3446, 0x080c, 0x6faa, 0x190c,
+	0x5caa, 0x2069, 0x185b, 0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88,
+	0x7c9c, 0x7d98, 0x2039, 0x0001, 0x080c, 0x48dd, 0x701f, 0x4061,
+	0x0005, 0x080c, 0x53a9, 0x1130, 0x3b00, 0x3a08, 0xc194, 0xc095,
+	0x20d8, 0x21d0, 0x2069, 0x185b, 0x6800, 0x9005, 0x0904, 0x3379,
+	0x6804, 0xd094, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0138, 0x6200,
+	0x9292, 0x0005, 0x0218, 0x918c, 0xffdf, 0x0010, 0x918d, 0x0020,
+	0x6106, 0x00ce, 0xd08c, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0118,
+	0x918d, 0x0010, 0x0010, 0x918c, 0xffef, 0x6106, 0x00ce, 0xd084,
+	0x0158, 0x6a28, 0x928a, 0x007f, 0x1a04, 0x3379, 0x9288, 0x3145,
+	0x210d, 0x918c, 0x00ff, 0x6162, 0xd0dc, 0x0130, 0x6828, 0x908a,
+	0x007f, 0x1a04, 0x3379, 0x605a, 0x6888, 0x9084, 0x0030, 0x8004,
+	0x8004, 0x8004, 0x8004, 0x0006, 0x2009, 0x1989, 0x9080, 0x27ac,
+	0x2005, 0x200a, 0x000e, 0x2009, 0x198a, 0x9080, 0x27b0, 0x2005,
+	0x200a, 0x6808, 0x908a, 0x0100, 0x0a04, 0x3379, 0x908a, 0x0841,
+	0x1a04, 0x3379, 0x9084, 0x0007, 0x1904, 0x3379, 0x680c, 0x9005,
+	0x0904, 0x3379, 0x6810, 0x9005, 0x0904, 0x3379, 0x6848, 0x6940,
+	0x910a, 0x1a04, 0x3379, 0x8001, 0x0904, 0x3379, 0x684c, 0x6944,
+	0x910a, 0x1a04, 0x3379, 0x8001, 0x0904, 0x3379, 0x2009, 0x1959,
+	0x200b, 0x0000, 0x2001, 0x187d, 0x2004, 0xd0c4, 0x0140, 0x7884,
+	0x200a, 0x2009, 0x017f, 0x200a, 0x3b00, 0xc085, 0x20d8, 0x6814,
+	0x908c, 0x00ff, 0x614a, 0x8007, 0x9084, 0x00ff, 0x604e, 0x080c,
+	0x72bd, 0x080c, 0x6643, 0x080c, 0x6678, 0x6808, 0x602a, 0x080c,
+	0x21e7, 0x2009, 0x0170, 0x200b, 0x0080, 0xa001, 0xa001, 0x200b,
+	0x0000, 0x0036, 0x6b08, 0x080c, 0x2713, 0x003e, 0x6000, 0x9086,
+	0x0000, 0x1904, 0x41de, 0x6818, 0x691c, 0x6a20, 0x6b24, 0x8007,
+	0x810f, 0x8217, 0x831f, 0x6016, 0x611a, 0x621e, 0x6322, 0x6c04,
+	0xd4f4, 0x0148, 0x6830, 0x6934, 0x6a38, 0x6b3c, 0x8007, 0x810f,
+	0x8217, 0x831f, 0x0010, 0x9084, 0xf0ff, 0x6006, 0x610a, 0x620e,
+	0x6312, 0x8007, 0x810f, 0x8217, 0x831f, 0x20a9, 0x0004, 0x20a1,
+	0x198b, 0x20e9, 0x0001, 0x4001, 0x20a9, 0x0004, 0x20a1, 0x19a5,
+	0x20e9, 0x0001, 0x4001, 0x080c, 0x8148, 0x00c6, 0x900e, 0x20a9,
+	0x0001, 0x6b70, 0xd384, 0x0510, 0x0068, 0x2009, 0x0100, 0x210c,
+	0x918e, 0x0008, 0x1110, 0x839d, 0x0010, 0x83f5, 0x3e18, 0x12b0,
+	0x3508, 0x8109, 0x080c, 0x7889, 0x6878, 0x6016, 0x6874, 0x2008,
+	0x9084, 0xff00, 0x8007, 0x600a, 0x9184, 0x00ff, 0x6006, 0x8108,
+	0x1118, 0x6003, 0x0003, 0x0010, 0x6003, 0x0001, 0x1f04, 0x414d,
+	0x00ce, 0x00c6, 0x2061, 0x1974, 0x2063, 0x0001, 0x9006, 0x080c,
+	0x29ba, 0x9006, 0x080c, 0x299d, 0x0000, 0x00ce, 0x00e6, 0x2c70,
+	0x080c, 0x0e80, 0x00ee, 0x6888, 0xd0ec, 0x0130, 0x2011, 0x0114,
+	0x2204, 0x9085, 0x0100, 0x2012, 0x6a80, 0x9284, 0x0030, 0x9086,
+	0x0030, 0x1128, 0x9294, 0xffcf, 0x9295, 0x0020, 0x6a82, 0x2001,
+	0x1954, 0x6a80, 0x9294, 0x0030, 0x928e, 0x0000, 0x0170, 0x928e,
+	0x0010, 0x0118, 0x928e, 0x0020, 0x0140, 0x2003, 0xaaaa, 0x080c,
+	0x2788, 0x2001, 0x1945, 0x2102, 0x0008, 0x2102, 0x00c6, 0x2061,
+	0x0100, 0x602f, 0x0040, 0x602f, 0x0000, 0x00ce, 0x080c, 0x6faa,
+	0x0128, 0x080c, 0x4ca6, 0x0110, 0x080c, 0x26d9, 0x60d0, 0x9005,
+	0x01c0, 0x6003, 0x0001, 0x2009, 0x41c6, 0x00d0, 0x080c, 0x6faa,
+	0x1168, 0x2011, 0x6e2b, 0x080c, 0x803f, 0x2011, 0x6e1e, 0x080c,
+	0x8113, 0x080c, 0x7291, 0x080c, 0x6edc, 0x0040, 0x080c, 0x5ba4,
+	0x0028, 0x6003, 0x0004, 0x2009, 0x41de, 0x0010, 0x0804, 0x3344,
+	0x2001, 0x0170, 0x2004, 0x9084, 0x00ff, 0x9086, 0x004c, 0x1118,
+	0x2091, 0x30bd, 0x0817, 0x2091, 0x303d, 0x0817, 0x6000, 0x9086,
+	0x0000, 0x0904, 0x3376, 0x2069, 0x185b, 0x7890, 0x6842, 0x7894,
+	0x6846, 0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
+	0x2039, 0x0001, 0x0804, 0x48e0, 0x9006, 0x080c, 0x26d9, 0x81ff,
+	0x1904, 0x3376, 0x080c, 0x6faa, 0x11b0, 0x080c, 0x728c, 0x080c,
+	0x5ce5, 0x080c, 0x3140, 0x0118, 0x6130, 0xc18d, 0x6132, 0x080c,
+	0xc23b, 0x0130, 0x080c, 0x6fcd, 0x1118, 0x080c, 0x6f82, 0x0038,
+	0x080c, 0x6edc, 0x0020, 0x080c, 0x5caa, 0x080c, 0x5ba4, 0x0804,
+	0x3344, 0x81ff, 0x1904, 0x3376, 0x080c, 0x6faa, 0x1110, 0x0804,
+	0x3376, 0x6190, 0x81ff, 0x01a8, 0x704f, 0x0000, 0x2001, 0x1c80,
+	0x2009, 0x0040, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0126, 0x2091,
+	0x8000, 0x2039, 0x0001, 0x080c, 0x48e0, 0x701f, 0x3342, 0x012e,
+	0x0005, 0x704f, 0x0001, 0x00d6, 0x2069, 0x1c80, 0x20a9, 0x0040,
+	0x20e9, 0x0001, 0x20a1, 0x1c80, 0x2019, 0xffff, 0x4304, 0x6558,
+	0x9588, 0x3145, 0x210d, 0x918c, 0x00ff, 0x216a, 0x900e, 0x2011,
+	0x0002, 0x2100, 0x9506, 0x01a8, 0x080c, 0x6256, 0x1190, 0xb814,
+	0x821c, 0x0238, 0x9398, 0x1c80, 0x9085, 0xff00, 0x8007, 0x201a,
+	0x0038, 0x9398, 0x1c80, 0x2324, 0x94a4, 0xff00, 0x9405, 0x201a,
+	0x8210, 0x8108, 0x9182, 0x0080, 0x1208, 0x0c18, 0x8201, 0x8007,
+	0x2d0c, 0x9105, 0x206a, 0x00de, 0x20a9, 0x0040, 0x20a1, 0x1c80,
+	0x2099, 0x1c80, 0x080c, 0x5c35, 0x0804, 0x4236, 0x080c, 0x48c7,
+	0x0904, 0x3379, 0x080c, 0x4894, 0x1120, 0x2009, 0x0002, 0x0804,
+	0x3376, 0x080c, 0x539a, 0xd0b4, 0x0558, 0x7884, 0x908e, 0x007e,
+	0x0538, 0x908e, 0x007f, 0x0520, 0x908e, 0x0080, 0x0508, 0x080c,
+	0x313b, 0x1148, 0xb800, 0xd08c, 0x11d8, 0xb804, 0x9084, 0x00ff,
+	0x9086, 0x0006, 0x11a8, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a,
+	0x080c, 0xbd04, 0x1120, 0x2009, 0x0003, 0x0804, 0x3376, 0x7007,
+	0x0003, 0x701f, 0x42c4, 0x0005, 0x080c, 0x48c7, 0x0904, 0x3379,
+	0x20a9, 0x002b, 0xb8b4, 0x20e0, 0xb8b8, 0x2098, 0xa860, 0x20e8,
+	0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080,
+	0x0006, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098,
+	0x080c, 0x0f68, 0x0070, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x000a,
+	0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x000a, 0x2098, 0x080c,
+	0x0f68, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
+	0x9080, 0x0002, 0x2009, 0x002b, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
+	0x0804, 0x48e0, 0x81ff, 0x1904, 0x3376, 0x080c, 0x48ab, 0x0904,
+	0x3379, 0x080c, 0x63c8, 0x0904, 0x3376, 0x0058, 0xa878, 0x9005,
+	0x0120, 0x2009, 0x0004, 0x0804, 0x3376, 0xa974, 0xaa94, 0x0804,
+	0x3344, 0x080c, 0x53a2, 0x0904, 0x3344, 0x701f, 0x430e, 0x7007,
+	0x0003, 0x0005, 0x81ff, 0x1904, 0x3376, 0x7888, 0x908a, 0x1000,
+	0x1a04, 0x3379, 0x080c, 0x48c7, 0x0904, 0x3379, 0x080c, 0x657a,
+	0x0120, 0x080c, 0x6582, 0x1904, 0x3379, 0x080c, 0x644d, 0x0904,
+	0x3376, 0x2019, 0x0004, 0x900e, 0x080c, 0x63da, 0x0904, 0x3376,
+	0x7984, 0x7a88, 0x04c9, 0x08a8, 0xa89c, 0x908a, 0x1000, 0x12f8,
+	0x080c, 0x48c5, 0x01e0, 0x080c, 0x657a, 0x0118, 0x080c, 0x6582,
+	0x11b0, 0x080c, 0x644d, 0x2009, 0x0002, 0x0168, 0x2009, 0x0002,
+	0x2019, 0x0004, 0x080c, 0x63da, 0x2009, 0x0003, 0x0120, 0xa998,
+	0xaa9c, 0x00d1, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
+	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
+	0x4000, 0x080c, 0x53a2, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085,
+	0x0001, 0x2001, 0x0000, 0x0005, 0x9186, 0x00ff, 0x0110, 0x0071,
+	0x0060, 0x2029, 0x007e, 0x2061, 0x1800, 0x6458, 0x2400, 0x9506,
+	0x0110, 0x2508, 0x0019, 0x8529, 0x1ec8, 0x0005, 0x080c, 0x6256,
+	0x1138, 0x2200, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x804d,
+	0x0005, 0x81ff, 0x1904, 0x3376, 0x798c, 0x2001, 0x1958, 0x918c,
+	0x8000, 0x2102, 0x080c, 0x48ab, 0x0904, 0x3379, 0x080c, 0x657a,
+	0x0120, 0x080c, 0x6582, 0x1904, 0x3379, 0x080c, 0x631d, 0x0904,
+	0x3376, 0x080c, 0x63d1, 0x0904, 0x3376, 0x2001, 0x1958, 0x2004,
+	0xd0fc, 0x1904, 0x3344, 0x0804, 0x4319, 0xa9a0, 0x2001, 0x1958,
+	0x918c, 0x8000, 0xc18d, 0x2102, 0x080c, 0x48b8, 0x01a0, 0x080c,
+	0x657a, 0x0118, 0x080c, 0x6582, 0x1170, 0x080c, 0x631d, 0x2009,
+	0x0002, 0x0128, 0x080c, 0x63d1, 0x1170, 0x2009, 0x0003, 0xa897,
+	0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001,
+	0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0x2001, 0x1958, 0x2004,
+	0xd0fc, 0x1128, 0x080c, 0x53a2, 0x0110, 0x9006, 0x0018, 0x900e,
+	0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x81ff, 0x1904, 0x3376,
+	0x798c, 0x2001, 0x1957, 0x918c, 0x8000, 0x2102, 0x080c, 0x48ab,
+	0x0904, 0x3379, 0x080c, 0x657a, 0x0120, 0x080c, 0x6582, 0x1904,
+	0x3379, 0x080c, 0x631d, 0x0904, 0x3376, 0x080c, 0x63bf, 0x0904,
+	0x3376, 0x2001, 0x1957, 0x2004, 0xd0fc, 0x1904, 0x3344, 0x0804,
+	0x4319, 0xa9a0, 0x2001, 0x1957, 0x918c, 0x8000, 0xc18d, 0x2102,
+	0x080c, 0x48b8, 0x01a0, 0x080c, 0x657a, 0x0118, 0x080c, 0x6582,
+	0x1170, 0x080c, 0x631d, 0x2009, 0x0002, 0x0128, 0x080c, 0x63bf,
+	0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
+	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
+	0x4000, 0x2001, 0x1957, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x53a2,
 	0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000,
-	0x0005, 0x9186, 0x00ff, 0x0110, 0x0071, 0x0060, 0x2029, 0x007e,
-	0x2061, 0x1800, 0x6458, 0x2400, 0x9506, 0x0110, 0x2508, 0x0019,
-	0x8529, 0x1ec8, 0x0005, 0x080c, 0x6247, 0x1138, 0x2200, 0x8003,
-	0x800b, 0x810b, 0x9108, 0x080c, 0x802f, 0x0005, 0x81ff, 0x1904,
-	0x336b, 0x798c, 0x2001, 0x1950, 0x918c, 0x8000, 0x2102, 0x080c,
-	0x48a0, 0x0904, 0x336e, 0x080c, 0x656b, 0x0120, 0x080c, 0x6573,
-	0x1904, 0x336e, 0x080c, 0x630e, 0x0904, 0x336b, 0x080c, 0x63c2,
-	0x0904, 0x336b, 0x2001, 0x1950, 0x2004, 0xd0fc, 0x1904, 0x3339,
-	0x0804, 0x430e, 0xa9a0, 0x2001, 0x1950, 0x918c, 0x8000, 0xc18d,
-	0x2102, 0x080c, 0x48ad, 0x01a0, 0x080c, 0x656b, 0x0118, 0x080c,
-	0x6573, 0x1170, 0x080c, 0x630e, 0x2009, 0x0002, 0x0128, 0x080c,
-	0x63c2, 0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010,
-	0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005,
-	0xa897, 0x4000, 0x2001, 0x1950, 0x2004, 0xd0fc, 0x1128, 0x080c,
-	0x5397, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001,
-	0x0000, 0x0005, 0x81ff, 0x1904, 0x336b, 0x798c, 0x2001, 0x194f,
-	0x918c, 0x8000, 0x2102, 0x080c, 0x48a0, 0x0904, 0x336e, 0x080c,
-	0x656b, 0x0120, 0x080c, 0x6573, 0x1904, 0x336e, 0x080c, 0x630e,
-	0x0904, 0x336b, 0x080c, 0x63b0, 0x0904, 0x336b, 0x2001, 0x194f,
-	0x2004, 0xd0fc, 0x1904, 0x3339, 0x0804, 0x430e, 0xa9a0, 0x2001,
-	0x194f, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c, 0x48ad, 0x01a0,
-	0x080c, 0x656b, 0x0118, 0x080c, 0x6573, 0x1170, 0x080c, 0x630e,
-	0x2009, 0x0002, 0x0128, 0x080c, 0x63b0, 0x1170, 0x2009, 0x0003,
-	0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085,
-	0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000, 0x2001, 0x194f,
-	0x2004, 0xd0fc, 0x1128, 0x080c, 0x5397, 0x0110, 0x9006, 0x0018,
-	0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x6100, 0x0804,
-	0x3339, 0x080c, 0x48bc, 0x0904, 0x336e, 0x080c, 0x53a3, 0x1904,
-	0x336b, 0x79a8, 0xd184, 0x1158, 0xb834, 0x8007, 0x789e, 0xb830,
-	0x8007, 0x789a, 0xbb2c, 0x831f, 0xba28, 0x8217, 0x0050, 0xb824,
-	0x8007, 0x789e, 0xb820, 0x8007, 0x789a, 0xbb1c, 0x831f, 0xba18,
-	0x8217, 0xb900, 0x918c, 0x0200, 0x0804, 0x3339, 0x78a8, 0x909c,
-	0x0003, 0xd0b4, 0x1148, 0x939a, 0x0003, 0x1a04, 0x336b, 0x6258,
-	0x7884, 0x9206, 0x1904, 0x44be, 0x2031, 0x1848, 0x2009, 0x013c,
-	0x2136, 0x2001, 0x1840, 0x2009, 0x000c, 0x7a8c, 0x7b88, 0x7c9c,
-	0x7d98, 0x2039, 0x0001, 0x0006, 0x78a8, 0x9084, 0x0080, 0x11c8,
-	0x0006, 0x0036, 0x2001, 0x1a4e, 0x201c, 0x7b9a, 0x2003, 0x0000,
-	0x2001, 0x1a4f, 0x201c, 0x7b9e, 0x2003, 0x0000, 0x2001, 0x1a50,
-	0x201c, 0x7ba2, 0x2003, 0x0000, 0x003e, 0x000e, 0x000e, 0x0804,
-	0x48d5, 0x000e, 0x2031, 0x0000, 0x2061, 0x18ae, 0x2c44, 0xa66a,
-	0xa17a, 0xa772, 0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c,
-	0x10d5, 0x7007, 0x0002, 0x701f, 0x44de, 0x0005, 0x81ff, 0x1904,
-	0x336b, 0x080c, 0x48bc, 0x0904, 0x336e, 0x080c, 0x656b, 0x1904,
-	0x336b, 0x00c6, 0x080c, 0x4889, 0x00ce, 0x0904, 0x336b, 0xa867,
-	0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7ea8, 0x080c, 0xbc9b, 0x0904,
-	0x336b, 0x7007, 0x0003, 0x701f, 0x44f8, 0x0005, 0x080c, 0x4028,
-	0x0006, 0x0036, 0x2001, 0x1a4e, 0x201c, 0x7b9a, 0x2003, 0x0000,
-	0x2001, 0x1a4f, 0x201c, 0x7b9e, 0x2003, 0x0000, 0x2001, 0x1a50,
-	0x201c, 0x7ba2, 0x2003, 0x0000, 0x003e, 0x000e, 0x0804, 0x3339,
-	0xa830, 0x9086, 0x0100, 0x0904, 0x336b, 0x8906, 0x8006, 0x8007,
-	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x2009, 0x000c,
-	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x48d5, 0x9006, 0x080c,
-	0x26ce, 0x78a8, 0x9084, 0x00ff, 0x9086, 0x00ff, 0x0118, 0x81ff,
-	0x1904, 0x336b, 0x080c, 0x6f9b, 0x0110, 0x080c, 0x5c9f, 0x7888,
-	0x908a, 0x1000, 0x1a04, 0x336e, 0x7984, 0x9186, 0x00ff, 0x0138,
-	0x9182, 0x007f, 0x1a04, 0x336e, 0x2100, 0x080c, 0x2698, 0x0026,
-	0x00c6, 0x0126, 0x2091, 0x8000, 0x2061, 0x19ca, 0x601b, 0x0000,
-	0x601f, 0x0000, 0x6073, 0x0000, 0x6077, 0x0000, 0x080c, 0x6f9b,
-	0x1158, 0x080c, 0x727f, 0x080c, 0x5cda, 0x9085, 0x0001, 0x080c,
-	0x6fe2, 0x080c, 0x6ecd, 0x00d0, 0x080c, 0x9dc8, 0x2061, 0x0100,
-	0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x810f, 0x9105, 0x604a,
-	0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x1969, 0x200b, 0x0000,
-	0x2009, 0x002d, 0x2011, 0x5bc5, 0x080c, 0x80b3, 0x7984, 0x080c,
-	0x6f9b, 0x1110, 0x2009, 0x00ff, 0x7a88, 0x080c, 0x4371, 0x012e,
-	0x00ce, 0x002e, 0x0804, 0x3339, 0x7984, 0x080c, 0x61e7, 0x2b08,
-	0x1904, 0x336e, 0x0804, 0x3339, 0x81ff, 0x0120, 0x2009, 0x0001,
-	0x0804, 0x336b, 0x60d8, 0xd0ac, 0x1130, 0xd09c, 0x1120, 0x2009,
-	0x0005, 0x0804, 0x336b, 0x080c, 0x4889, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x336b, 0x7984, 0x9192, 0x0021, 0x1a04, 0x336e, 0x7a8c,
-	0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0x702a, 0xaf60,
-	0x7736, 0x080c, 0x48d2, 0x701f, 0x45ac, 0x7880, 0x9086, 0x006e,
-	0x0110, 0x701f, 0x4e4d, 0x0005, 0x2009, 0x0080, 0x080c, 0x6247,
-	0x1118, 0x080c, 0x656b, 0x0120, 0x2021, 0x400a, 0x0804, 0x333b,
-	0x00d6, 0x0096, 0xa964, 0xaa6c, 0xab70, 0xac74, 0xad78, 0xae7c,
-	0xa884, 0x90be, 0x0100, 0x0904, 0x4645, 0x90be, 0x0112, 0x0904,
-	0x4645, 0x90be, 0x0113, 0x0904, 0x4645, 0x90be, 0x0114, 0x0904,
-	0x4645, 0x90be, 0x0117, 0x0904, 0x4645, 0x90be, 0x011a, 0x0904,
-	0x4645, 0x90be, 0x011c, 0x0904, 0x4645, 0x90be, 0x0121, 0x0904,
-	0x462c, 0x90be, 0x0131, 0x0904, 0x462c, 0x90be, 0x0171, 0x0904,
-	0x4645, 0x90be, 0x0173, 0x0904, 0x4645, 0x90be, 0x01a1, 0x1128,
-	0xa894, 0x8007, 0xa896, 0x0804, 0x4650, 0x90be, 0x0212, 0x0904,
-	0x4639, 0x90be, 0x0213, 0x05e8, 0x90be, 0x0214, 0x0500, 0x90be,
-	0x0217, 0x0188, 0x90be, 0x021a, 0x1120, 0xa89c, 0x8007, 0xa89e,
-	0x04e0, 0x90be, 0x021f, 0x05c8, 0x90be, 0x0300, 0x05b0, 0x009e,
-	0x00de, 0x0804, 0x336e, 0x7028, 0x9080, 0x0010, 0x2098, 0x20a0,
-	0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0007, 0x080c, 0x468e, 0x7028,
-	0x9080, 0x000e, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9,
-	0x0001, 0x080c, 0x468e, 0x00c8, 0x7028, 0x9080, 0x000c, 0x2098,
-	0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x469b,
-	0x00b8, 0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034, 0x20e0,
-	0x20e8, 0x20a9, 0x0001, 0x080c, 0x469b, 0x7028, 0x9080, 0x000c,
-	0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x04f1,
-	0x00c6, 0x080c, 0x4889, 0x0550, 0xa868, 0xc0fd, 0xa86a, 0xa867,
-	0x0119, 0x9006, 0xa882, 0xa87f, 0x0020, 0xa88b, 0x0001, 0x810b,
-	0xa9ae, 0xa8b2, 0xaab6, 0xabba, 0xacbe, 0xadc2, 0xa9c6, 0xa8ca,
-	0x00ce, 0x009e, 0x00de, 0xa866, 0xa822, 0xa868, 0xc0fd, 0xa86a,
-	0xa804, 0x2048, 0x080c, 0xbcb6, 0x1120, 0x2009, 0x0003, 0x0804,
-	0x336b, 0x7007, 0x0003, 0x701f, 0x4685, 0x0005, 0x00ce, 0x009e,
-	0x00de, 0x2009, 0x0002, 0x0804, 0x336b, 0xa820, 0x9086, 0x8001,
-	0x1904, 0x3339, 0x2009, 0x0004, 0x0804, 0x336b, 0x0016, 0x0026,
-	0x3510, 0x20a9, 0x0002, 0x4002, 0x4104, 0x4004, 0x8211, 0x1dc8,
-	0x002e, 0x001e, 0x0005, 0x0016, 0x0026, 0x0036, 0x0046, 0x3520,
-	0x20a9, 0x0004, 0x4002, 0x4304, 0x4204, 0x4104, 0x4004, 0x8421,
-	0x1db8, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005, 0x81ff, 0x0120,
-	0x2009, 0x0001, 0x0804, 0x336b, 0x60d8, 0xd0ac, 0x1160, 0xd09c,
-	0x0120, 0x2009, 0x0016, 0x0804, 0x336b, 0xd09c, 0x1120, 0x2009,
-	0x0005, 0x0804, 0x336b, 0x7984, 0x78a8, 0x2040, 0x080c, 0x9dc1,
-	0x1120, 0x9182, 0x007f, 0x0a04, 0x336e, 0x9186, 0x00ff, 0x0904,
-	0x336e, 0x9182, 0x0800, 0x1a04, 0x336e, 0x7a8c, 0x7b88, 0x6078,
-	0x9306, 0x1158, 0x607c, 0x924e, 0x0904, 0x336e, 0x080c, 0x9dc1,
-	0x1120, 0x99cc, 0xff00, 0x0904, 0x336e, 0x0126, 0x2091, 0x8000,
-	0x0026, 0x2011, 0x8008, 0x080c, 0x658f, 0x002e, 0x0140, 0x918d,
-	0x8000, 0x080c, 0x65d9, 0x1118, 0x2001, 0x4009, 0x0458, 0x080c,
-	0x47a3, 0x0560, 0x90c6, 0x4000, 0x1170, 0x00c6, 0x0006, 0x900e,
-	0x080c, 0x6467, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d,
-	0x000e, 0x00ce, 0x00b8, 0x90c6, 0x4007, 0x1110, 0x2408, 0x0090,
-	0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0060, 0x90c6, 0x4009,
-	0x1108, 0x0040, 0x90c6, 0x4006, 0x1108, 0x0020, 0x2001, 0x4005,
-	0x2009, 0x000a, 0x2020, 0x012e, 0x0804, 0x333b, 0x2b00, 0x7026,
-	0x0016, 0x00b6, 0x00c6, 0x00e6, 0x2c70, 0x080c, 0x9e8f, 0x0904,
-	0x4770, 0x2b00, 0x6012, 0x080c, 0xbfa6, 0x2e58, 0x00ee, 0x00e6,
-	0x00c6, 0x080c, 0x4889, 0x00ce, 0x2b70, 0x1158, 0x080c, 0x9e42,
-	0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x2009, 0x0002, 0x0804,
-	0x336b, 0x900e, 0xa966, 0xa96a, 0x2900, 0x6016, 0xa932, 0xa868,
-	0xc0fd, 0xd88c, 0x0108, 0xc0f5, 0xa86a, 0x080c, 0x2fdc, 0x6023,
-	0x0001, 0x9006, 0x080c, 0x6184, 0x2001, 0x0002, 0x080c, 0x6198,
-	0x2009, 0x0002, 0x080c, 0x9ebc, 0x78a8, 0xd094, 0x0138, 0x00ee,
-	0x7024, 0x00e6, 0x2058, 0xb8bc, 0xc08d, 0xb8be, 0x9085, 0x0001,
-	0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x1120, 0x2009, 0x0003,
-	0x0804, 0x336b, 0x7007, 0x0003, 0x701f, 0x477f, 0x0005, 0xa830,
-	0x2008, 0x918e, 0xdead, 0x1120, 0x2021, 0x4009, 0x0804, 0x333b,
-	0x9086, 0x0100, 0x7024, 0x2058, 0x1138, 0x2009, 0x0004, 0xba04,
-	0x9294, 0x00ff, 0x0804, 0x52ec, 0x900e, 0xa868, 0xd0f4, 0x1904,
-	0x3339, 0x080c, 0x6467, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
-	0xc18d, 0x0804, 0x3339, 0x00e6, 0x00d6, 0x0096, 0x83ff, 0x0904,
-	0x47eb, 0x902e, 0x080c, 0x9dc1, 0x0130, 0x9026, 0x20a9, 0x0800,
-	0x2071, 0x1000, 0x0030, 0x2021, 0x007f, 0x20a9, 0x0781, 0x2071,
-	0x107f, 0x2e04, 0x9005, 0x11b0, 0x2100, 0x9406, 0x15e8, 0x2428,
-	0x94ce, 0x007f, 0x1120, 0x92ce, 0xfffd, 0x1528, 0x0030, 0x94ce,
-	0x0080, 0x1130, 0x92ce, 0xfffc, 0x11f0, 0x93ce, 0x00ff, 0x11d8,
-	0xc5fd, 0x0450, 0x2058, 0xbf10, 0x2700, 0x9306, 0x11b8, 0xbe14,
-	0x2600, 0x9206, 0x1198, 0x2400, 0x9106, 0x1150, 0xd884, 0x0568,
-	0xd894, 0x1558, 0x080c, 0x656b, 0x1540, 0x2001, 0x4000, 0x0430,
-	0x2001, 0x4007, 0x0418, 0x2001, 0x4006, 0x0400, 0x2400, 0x9106,
-	0x1158, 0xbe14, 0x87ff, 0x1128, 0x86ff, 0x0948, 0x080c, 0x9dc1,
-	0x1930, 0x2001, 0x4008, 0x0090, 0x8420, 0x8e70, 0x1f04, 0x47b9,
-	0x85ff, 0x1130, 0x2001, 0x4009, 0x0048, 0x2001, 0x0001, 0x0030,
-	0x080c, 0x61e7, 0x1dd0, 0xbb12, 0xba16, 0x9006, 0x9005, 0x009e,
-	0x00de, 0x00ee, 0x0005, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804,
-	0x336b, 0x080c, 0x4889, 0x1120, 0x2009, 0x0002, 0x0804, 0x336b,
-	0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7884, 0x9005, 0x0904,
-	0x336e, 0x9096, 0x00ff, 0x0120, 0x9092, 0x0004, 0x1a04, 0x336e,
-	0x2010, 0x2918, 0x080c, 0x2f82, 0x1120, 0x2009, 0x0003, 0x0804,
-	0x336b, 0x7007, 0x0003, 0x701f, 0x483e, 0x0005, 0xa830, 0x9086,
-	0x0100, 0x1904, 0x3339, 0x2009, 0x0004, 0x0804, 0x336b, 0x7984,
-	0x080c, 0x9dc1, 0x1120, 0x9182, 0x007f, 0x0a04, 0x336e, 0x9186,
-	0x00ff, 0x0904, 0x336e, 0x9182, 0x0800, 0x1a04, 0x336e, 0x2001,
-	0x9000, 0x080c, 0x5347, 0x1904, 0x336b, 0x0804, 0x3339, 0xa998,
-	0x080c, 0x9dc1, 0x1118, 0x9182, 0x007f, 0x0280, 0x9186, 0x00ff,
-	0x0168, 0x9182, 0x0800, 0x1250, 0x2001, 0x9000, 0x080c, 0x5347,
-	0x11a8, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
-	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000,
-	0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x2009, 0x000a,
-	0x0c48, 0x080c, 0x0feb, 0x0198, 0x9006, 0xa802, 0x7014, 0x9005,
-	0x1120, 0x2900, 0x7016, 0x701a, 0x0040, 0x7018, 0xa802, 0x0086,
-	0x2040, 0x2900, 0xa006, 0x701a, 0x008e, 0x9085, 0x0001, 0x0005,
-	0x7984, 0x080c, 0x6247, 0x1130, 0x7e88, 0x9684, 0x3fff, 0x9082,
-	0x4000, 0x0208, 0x905e, 0x8bff, 0x0005, 0xa998, 0x080c, 0x6247,
-	0x1130, 0xae9c, 0x9684, 0x3fff, 0x9082, 0x4000, 0x0208, 0x905e,
-	0x8bff, 0x0005, 0xae98, 0x0008, 0x7e84, 0x2608, 0x080c, 0x6247,
-	0x1108, 0x0008, 0x905e, 0x8bff, 0x0005, 0x0016, 0x7114, 0x81ff,
-	0x0128, 0x2148, 0xa904, 0x080c, 0x101d, 0x0cc8, 0x7116, 0x711a,
-	0x001e, 0x0005, 0x2031, 0x0001, 0x0010, 0x2031, 0x0000, 0x2061,
-	0x18ae, 0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e, 0xa392,
-	0xa496, 0xa59a, 0x080c, 0x10d5, 0x7007, 0x0002, 0x701f, 0x3339,
-	0x0005, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2079, 0x0000, 0x2001,
-	0x18a6, 0x2004, 0x9005, 0x1190, 0x0e04, 0x4906, 0x7a36, 0x7833,
-	0x0012, 0x7a82, 0x7b86, 0x7c8a, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x190c, 0x1187, 0x0804, 0x496c, 0x0016, 0x0086,
-	0x0096, 0x00c6, 0x00e6, 0x2071, 0x1894, 0x7044, 0x9005, 0x1540,
-	0x7148, 0x9182, 0x0010, 0x0288, 0x7038, 0x2060, 0x080c, 0x0feb,
-	0x0904, 0x4964, 0xa84b, 0x0000, 0x2900, 0x7046, 0x2001, 0x0002,
-	0x9080, 0x1f28, 0x2005, 0xa846, 0x0098, 0x7038, 0x90e0, 0x0004,
-	0x2001, 0x18b0, 0x9c82, 0x18f0, 0x0210, 0x2061, 0x18b0, 0x2c00,
-	0x703a, 0x7148, 0x81ff, 0x1108, 0x703e, 0x8108, 0x714a, 0x0460,
-	0x7148, 0x8108, 0x714a, 0x7044, 0x2040, 0xa144, 0x2105, 0x0016,
-	0x908a, 0x0036, 0x1a0c, 0x0db4, 0x2060, 0x001e, 0x8108, 0x2105,
-	0x9005, 0xa146, 0x1520, 0x080c, 0x0feb, 0x1130, 0x8109, 0xa946,
-	0x7148, 0x8109, 0x714a, 0x00d8, 0x9006, 0xa806, 0xa84a, 0xa046,
-	0x2800, 0xa802, 0x2900, 0xa006, 0x7046, 0x2001, 0x0002, 0x9080,
-	0x1f28, 0x2005, 0xa846, 0x0058, 0x2262, 0x6306, 0x640a, 0x00ee,
-	0x00ce, 0x009e, 0x008e, 0x001e, 0x012e, 0x00fe, 0x0005, 0x2c00,
-	0x9082, 0x001b, 0x0002, 0x498e, 0x498e, 0x4990, 0x498e, 0x498e,
-	0x498e, 0x4994, 0x498e, 0x498e, 0x498e, 0x4998, 0x498e, 0x498e,
-	0x498e, 0x499c, 0x498e, 0x498e, 0x498e, 0x49a0, 0x498e, 0x498e,
-	0x498e, 0x49a4, 0x498e, 0x498e, 0x498e, 0x49a9, 0x080c, 0x0db4,
-	0xa276, 0xa37a, 0xa47e, 0x0898, 0xa286, 0xa38a, 0xa48e, 0x0878,
-	0xa296, 0xa39a, 0xa49e, 0x0858, 0xa2a6, 0xa3aa, 0xa4ae, 0x0838,
-	0xa2b6, 0xa3ba, 0xa4be, 0x0818, 0xa2c6, 0xa3ca, 0xa4ce, 0x0804,
-	0x4967, 0xa2d6, 0xa3da, 0xa4de, 0x0804, 0x4967, 0x00e6, 0x2071,
-	0x1894, 0x7048, 0x9005, 0x0904, 0x4a40, 0x0126, 0x2091, 0x8000,
-	0x0e04, 0x4a3f, 0x00f6, 0x2079, 0x0000, 0x00c6, 0x0096, 0x0086,
-	0x0076, 0x9006, 0x2038, 0x7040, 0x2048, 0x9005, 0x0500, 0xa948,
-	0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c, 0x0db4, 0x2060, 0x001e,
-	0x8108, 0x2105, 0x9005, 0xa94a, 0x1904, 0x4a42, 0xa804, 0x9005,
-	0x090c, 0x0db4, 0x7042, 0x2938, 0x2040, 0xa003, 0x0000, 0x2001,
-	0x0002, 0x9080, 0x1f28, 0x2005, 0xa04a, 0x0804, 0x4a42, 0x703c,
-	0x2060, 0x2c14, 0x6304, 0x6408, 0x650c, 0x2200, 0x7836, 0x7833,
-	0x0012, 0x7882, 0x2300, 0x7886, 0x2400, 0x788a, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x87ff, 0x0118,
-	0x2748, 0x080c, 0x101d, 0x7048, 0x8001, 0x704a, 0x9005, 0x1170,
-	0x7040, 0x2048, 0x9005, 0x0128, 0x080c, 0x101d, 0x9006, 0x7042,
-	0x7046, 0x703b, 0x18b0, 0x703f, 0x18b0, 0x0420, 0x7040, 0x9005,
-	0x1508, 0x7238, 0x2c00, 0x9206, 0x0148, 0x9c80, 0x0004, 0x90fa,
-	0x18f0, 0x0210, 0x2001, 0x18b0, 0x703e, 0x00a0, 0x9006, 0x703e,
-	0x703a, 0x7044, 0x9005, 0x090c, 0x0db4, 0x2048, 0xa800, 0x9005,
-	0x1de0, 0x2900, 0x7042, 0x2001, 0x0002, 0x9080, 0x1f28, 0x2005,
-	0xa84a, 0x0000, 0x007e, 0x008e, 0x009e, 0x00ce, 0x00fe, 0x012e,
-	0x00ee, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002, 0x4a61, 0x4a61,
-	0x4a63, 0x4a61, 0x4a61, 0x4a61, 0x4a68, 0x4a61, 0x4a61, 0x4a61,
-	0x4a6d, 0x4a61, 0x4a61, 0x4a61, 0x4a72, 0x4a61, 0x4a61, 0x4a61,
-	0x4a77, 0x4a61, 0x4a61, 0x4a61, 0x4a7c, 0x4a61, 0x4a61, 0x4a61,
-	0x4a81, 0x080c, 0x0db4, 0xaa74, 0xab78, 0xac7c, 0x0804, 0x49ed,
-	0xaa84, 0xab88, 0xac8c, 0x0804, 0x49ed, 0xaa94, 0xab98, 0xac9c,
-	0x0804, 0x49ed, 0xaaa4, 0xaba8, 0xacac, 0x0804, 0x49ed, 0xaab4,
-	0xabb8, 0xacbc, 0x0804, 0x49ed, 0xaac4, 0xabc8, 0xaccc, 0x0804,
-	0x49ed, 0xaad4, 0xabd8, 0xacdc, 0x0804, 0x49ed, 0x0026, 0x080c,
-	0x538f, 0xd0c4, 0x0120, 0x2011, 0x8014, 0x080c, 0x48e9, 0x002e,
-	0x0005, 0x81ff, 0x1904, 0x336b, 0x0126, 0x2091, 0x8000, 0x6030,
-	0xc08d, 0xc085, 0xc0ac, 0x6032, 0x080c, 0x6f9b, 0x1158, 0x080c,
-	0x727f, 0x080c, 0x5cda, 0x9085, 0x0001, 0x080c, 0x6fe2, 0x080c,
-	0x6ecd, 0x0010, 0x080c, 0x5b99, 0x012e, 0x0804, 0x3339, 0x81ff,
-	0x0120, 0x2009, 0x0001, 0x0804, 0x336b, 0x080c, 0x53a3, 0x0120,
-	0x2009, 0x0007, 0x0804, 0x336b, 0x080c, 0x6563, 0x0120, 0x2009,
-	0x0008, 0x0804, 0x336b, 0x0026, 0x2011, 0x0010, 0x080c, 0x658f,
-	0x002e, 0x0140, 0x7984, 0x080c, 0x65d9, 0x1120, 0x2009, 0x4009,
-	0x0804, 0x336b, 0x7984, 0x080c, 0x61e7, 0x1904, 0x336e, 0x2b00,
-	0x7026, 0x080c, 0x656b, 0x7888, 0x1170, 0x9084, 0x0005, 0x1158,
-	0x900e, 0x080c, 0x6467, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
-	0xc18d, 0x0804, 0x3339, 0x080c, 0x4889, 0x0904, 0x336b, 0x9006,
-	0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xbd54, 0x0904,
-	0x336b, 0x7888, 0xd094, 0x0118, 0xb8bc, 0xc08d, 0xb8be, 0x7007,
-	0x0003, 0x701f, 0x4b50, 0x0005, 0x2061, 0x1800, 0x080c, 0x53a3,
-	0x2009, 0x0007, 0x1578, 0x080c, 0x6563, 0x0118, 0x2009, 0x0008,
-	0x0448, 0x080c, 0x3130, 0x0120, 0xa998, 0x080c, 0x61e7, 0x1530,
-	0x080c, 0x48ba, 0x0518, 0x080c, 0x656b, 0xa89c, 0x1168, 0x9084,
-	0x0005, 0x1150, 0x900e, 0x080c, 0x6467, 0x1108, 0xc185, 0xb800,
-	0xd0bc, 0x0108, 0xc18d, 0x00d0, 0xa868, 0xc0fc, 0xa86a, 0x080c,
-	0xbd54, 0x11e0, 0xa89c, 0xd094, 0x0118, 0xb8bc, 0xc08d, 0xb8be,
-	0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
-	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000,
-	0xa99a, 0x9006, 0x918d, 0x0001, 0x2008, 0x0005, 0x9006, 0x0005,
-	0xa830, 0x2008, 0x918e, 0xdead, 0x1120, 0x2021, 0x4009, 0x0804,
-	0x333b, 0x9086, 0x0100, 0x7024, 0x2058, 0x1110, 0x0804, 0x52ec,
-	0x900e, 0x080c, 0x6467, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
-	0xc18d, 0x0804, 0x3339, 0x080c, 0x53a3, 0x0120, 0x2009, 0x0007,
-	0x0804, 0x336b, 0x7f84, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c,
-	0x4889, 0x1120, 0x2009, 0x0002, 0x0804, 0x336b, 0x900e, 0x2130,
-	0x7126, 0x7132, 0xa860, 0x20e8, 0x7036, 0xa85c, 0x9080, 0x0005,
-	0x702a, 0x20a0, 0x080c, 0x6247, 0x1904, 0x4bee, 0x080c, 0x656b,
-	0x0120, 0x080c, 0x6573, 0x1904, 0x4bee, 0x080c, 0x6563, 0x1130,
-	0x080c, 0x6467, 0x1118, 0xd79c, 0x0904, 0x4bee, 0xd794, 0x1110,
-	0xd784, 0x01a8, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098,
-	0x3400, 0xd794, 0x0160, 0x20a9, 0x0008, 0x4003, 0x2098, 0x20a0,
-	0x3d00, 0x20e0, 0x20a9, 0x0002, 0x080c, 0x469b, 0x0048, 0x20a9,
-	0x0004, 0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x080c, 0x469b,
-	0x4104, 0xd794, 0x0528, 0xb8b4, 0x20e0, 0xb8b8, 0x2060, 0x9c80,
-	0x0000, 0x2098, 0x20a9, 0x0002, 0x4003, 0x9c80, 0x0003, 0x2098,
-	0x20a9, 0x0001, 0x4005, 0x9c80, 0x0004, 0x2098, 0x3400, 0x20a9,
-	0x0002, 0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x080c, 0x468e,
-	0x9c80, 0x0026, 0x2098, 0xb8b4, 0x20e0, 0x20a9, 0x0002, 0x4003,
-	0xd794, 0x0110, 0x96b0, 0x000b, 0x96b0, 0x0005, 0x8108, 0x080c,
-	0x9dc1, 0x0118, 0x9186, 0x0800, 0x0040, 0xd78c, 0x0120, 0x9186,
-	0x0800, 0x0170, 0x0018, 0x9186, 0x007e, 0x0150, 0xd794, 0x0118,
-	0x9686, 0x0020, 0x0010, 0x9686, 0x0028, 0x0150, 0x0804, 0x4b8a,
-	0x86ff, 0x1120, 0x7124, 0x810b, 0x0804, 0x3339, 0x7033, 0x0001,
-	0x7122, 0x7024, 0x9600, 0x7026, 0x772e, 0x2061, 0x18ae, 0x2c44,
-	0xa06b, 0x0000, 0xa67a, 0x7034, 0xa072, 0x7028, 0xa076, 0xa28e,
-	0xa392, 0xa496, 0xa59a, 0x080c, 0x10d5, 0x7007, 0x0002, 0x701f,
-	0x4c2a, 0x0005, 0x7030, 0x9005, 0x1180, 0x7120, 0x7028, 0x20a0,
-	0x772c, 0x9036, 0x7034, 0x20e8, 0x2061, 0x18ae, 0x2c44, 0xa28c,
-	0xa390, 0xa494, 0xa598, 0x0804, 0x4b8a, 0x7124, 0x810b, 0x0804,
-	0x3339, 0x2029, 0x007e, 0x7984, 0x7a88, 0x7b8c, 0x7c98, 0x9184,
-	0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x336e, 0x9502, 0x0a04,
-	0x336e, 0x9184, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x336e, 0x9502,
-	0x0a04, 0x336e, 0x9284, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04,
-	0x336e, 0x9502, 0x0a04, 0x336e, 0x9284, 0x00ff, 0x90e2, 0x0020,
-	0x0a04, 0x336e, 0x9502, 0x0a04, 0x336e, 0x9384, 0xff00, 0x8007,
-	0x90e2, 0x0020, 0x0a04, 0x336e, 0x9502, 0x0a04, 0x336e, 0x9384,
-	0x00ff, 0x90e2, 0x0020, 0x0a04, 0x336e, 0x9502, 0x0a04, 0x336e,
-	0x9484, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x336e, 0x9502,
-	0x0a04, 0x336e, 0x9484, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x336e,
-	0x9502, 0x0a04, 0x336e, 0x2061, 0x1959, 0x6102, 0x6206, 0x630a,
-	0x640e, 0x0804, 0x3339, 0x0006, 0x080c, 0x538f, 0xd0cc, 0x000e,
-	0x0005, 0x0006, 0x080c, 0x5393, 0xd0bc, 0x000e, 0x0005, 0x6170,
-	0x7a84, 0x6300, 0x82ff, 0x1118, 0x7986, 0x0804, 0x3339, 0x83ff,
-	0x1904, 0x336e, 0x2001, 0xfff0, 0x9200, 0x1a04, 0x336e, 0x2019,
-	0xffff, 0x6074, 0x9302, 0x9200, 0x0a04, 0x336e, 0x7986, 0x6272,
-	0x0804, 0x3339, 0x080c, 0x53a3, 0x1904, 0x336b, 0x7c88, 0x7d84,
-	0x7e98, 0x7f8c, 0x080c, 0x4889, 0x0904, 0x336b, 0x900e, 0x901e,
-	0x7326, 0x7332, 0xa860, 0x20e8, 0x7036, 0xa85c, 0x9080, 0x0003,
-	0x702a, 0x20a0, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c,
-	0x656b, 0x0118, 0x080c, 0x6573, 0x1148, 0x20a9, 0x0001, 0xb814,
+	0x0005, 0x6100, 0x0804, 0x3344, 0x080c, 0x48c7, 0x0904, 0x3379,
+	0x080c, 0x53ae, 0x1904, 0x3376, 0x79a8, 0xd184, 0x1158, 0xb834,
+	0x8007, 0x789e, 0xb830, 0x8007, 0x789a, 0xbb2c, 0x831f, 0xba28,
+	0x8217, 0x0050, 0xb824, 0x8007, 0x789e, 0xb820, 0x8007, 0x789a,
+	0xbb1c, 0x831f, 0xba18, 0x8217, 0xb900, 0x918c, 0x0200, 0x0804,
+	0x3344, 0x78a8, 0x909c, 0x0003, 0xd0ac, 0x1158, 0xd0b4, 0x1148,
+	0x939a, 0x0003, 0x1a04, 0x3376, 0x6258, 0x7884, 0x9206, 0x1904,
+	0x44c9, 0x2031, 0x1848, 0x2009, 0x013c, 0x2136, 0x2001, 0x1840,
+	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0001, 0x0006, 0x78a8,
+	0x9084, 0x0080, 0x11c8, 0x0006, 0x0036, 0x2001, 0x1a56, 0x201c,
+	0x7b9a, 0x2003, 0x0000, 0x2001, 0x1a57, 0x201c, 0x7b9e, 0x2003,
+	0x0000, 0x2001, 0x1a58, 0x201c, 0x7ba2, 0x2003, 0x0000, 0x003e,
+	0x000e, 0x000e, 0x0804, 0x48e0, 0x000e, 0x2031, 0x0000, 0x2061,
+	0x18b6, 0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e, 0xa392,
+	0xa496, 0xa59a, 0x080c, 0x10d5, 0x7007, 0x0002, 0x701f, 0x44e9,
+	0x0005, 0x81ff, 0x1904, 0x3376, 0x080c, 0x48c7, 0x0904, 0x3379,
+	0x080c, 0x657a, 0x1904, 0x3376, 0x00c6, 0x080c, 0x4894, 0x00ce,
+	0x0904, 0x3376, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7ea8,
+	0x080c, 0xbcaa, 0x0904, 0x3376, 0x7007, 0x0003, 0x701f, 0x4503,
+	0x0005, 0x080c, 0x4033, 0x0006, 0x0036, 0x2001, 0x1a56, 0x201c,
+	0x7b9a, 0x2003, 0x0000, 0x2001, 0x1a57, 0x201c, 0x7b9e, 0x2003,
+	0x0000, 0x2001, 0x1a58, 0x201c, 0x7ba2, 0x2003, 0x0000, 0x003e,
+	0x000e, 0x0804, 0x3344, 0xa830, 0x9086, 0x0100, 0x0904, 0x3376,
+	0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
+	0x001b, 0x2009, 0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804,
+	0x48e0, 0x9006, 0x080c, 0x26d9, 0x78a8, 0x9084, 0x00ff, 0x9086,
+	0x00ff, 0x0118, 0x81ff, 0x1904, 0x3376, 0x080c, 0x6faa, 0x0110,
+	0x080c, 0x5caa, 0x7888, 0x908a, 0x1000, 0x1a04, 0x3379, 0x7984,
+	0x9186, 0x00ff, 0x0138, 0x9182, 0x007f, 0x1a04, 0x3379, 0x2100,
+	0x080c, 0x26a3, 0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x2061,
+	0x19d2, 0x601b, 0x0000, 0x601f, 0x0000, 0x6073, 0x0000, 0x6077,
+	0x0000, 0x080c, 0x6faa, 0x1158, 0x080c, 0x728c, 0x080c, 0x5ce5,
+	0x9085, 0x0001, 0x080c, 0x6ff1, 0x080c, 0x6edc, 0x00d0, 0x080c,
+	0x9db5, 0x2061, 0x0100, 0x2001, 0x1817, 0x2004, 0x9084, 0x00ff,
+	0x810f, 0x9105, 0x604a, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009,
+	0x1971, 0x200b, 0x0000, 0x2009, 0x002d, 0x2011, 0x5bd0, 0x080c,
+	0x80d1, 0x7984, 0x080c, 0x6faa, 0x1110, 0x2009, 0x00ff, 0x7a88,
+	0x080c, 0x437c, 0x012e, 0x00ce, 0x002e, 0x0804, 0x3344, 0x7984,
+	0x080c, 0x61f6, 0x2b08, 0x1904, 0x3379, 0x0804, 0x3344, 0x81ff,
+	0x0120, 0x2009, 0x0001, 0x0804, 0x3376, 0x60d8, 0xd0ac, 0x1130,
+	0xd09c, 0x1120, 0x2009, 0x0005, 0x0804, 0x3376, 0x080c, 0x4894,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x3376, 0x7984, 0x9192, 0x0021,
+	0x1a04, 0x3379, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080,
+	0x0019, 0x702a, 0xaf60, 0x7736, 0x080c, 0x48dd, 0x701f, 0x45b7,
+	0x7880, 0x9086, 0x006e, 0x0110, 0x701f, 0x4e58, 0x0005, 0x2009,
+	0x0080, 0x080c, 0x6256, 0x1118, 0x080c, 0x657a, 0x0120, 0x2021,
+	0x400a, 0x0804, 0x3346, 0x00d6, 0x0096, 0xa964, 0xaa6c, 0xab70,
+	0xac74, 0xad78, 0xae7c, 0xa884, 0x90be, 0x0100, 0x0904, 0x4650,
+	0x90be, 0x0112, 0x0904, 0x4650, 0x90be, 0x0113, 0x0904, 0x4650,
+	0x90be, 0x0114, 0x0904, 0x4650, 0x90be, 0x0117, 0x0904, 0x4650,
+	0x90be, 0x011a, 0x0904, 0x4650, 0x90be, 0x011c, 0x0904, 0x4650,
+	0x90be, 0x0121, 0x0904, 0x4637, 0x90be, 0x0131, 0x0904, 0x4637,
+	0x90be, 0x0171, 0x0904, 0x4650, 0x90be, 0x0173, 0x0904, 0x4650,
+	0x90be, 0x01a1, 0x1128, 0xa894, 0x8007, 0xa896, 0x0804, 0x465b,
+	0x90be, 0x0212, 0x0904, 0x4644, 0x90be, 0x0213, 0x05e8, 0x90be,
+	0x0214, 0x0500, 0x90be, 0x0217, 0x0188, 0x90be, 0x021a, 0x1120,
+	0xa89c, 0x8007, 0xa89e, 0x04e0, 0x90be, 0x021f, 0x05c8, 0x90be,
+	0x0300, 0x05b0, 0x009e, 0x00de, 0x0804, 0x3379, 0x7028, 0x9080,
+	0x0010, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0007,
+	0x080c, 0x4699, 0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034,
+	0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x4699, 0x00c8, 0x7028,
+	0x9080, 0x000c, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9,
+	0x0001, 0x080c, 0x46a6, 0x00b8, 0x7028, 0x9080, 0x000e, 0x2098,
+	0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x46a6,
+	0x7028, 0x9080, 0x000c, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8,
+	0x20a9, 0x0001, 0x04f1, 0x00c6, 0x080c, 0x4894, 0x0550, 0xa868,
+	0xc0fd, 0xa86a, 0xa867, 0x0119, 0x9006, 0xa882, 0xa87f, 0x0020,
+	0xa88b, 0x0001, 0x810b, 0xa9ae, 0xa8b2, 0xaab6, 0xabba, 0xacbe,
+	0xadc2, 0xa9c6, 0xa8ca, 0x00ce, 0x009e, 0x00de, 0xa866, 0xa822,
+	0xa868, 0xc0fd, 0xa86a, 0xa804, 0x2048, 0x080c, 0xbcc5, 0x1120,
+	0x2009, 0x0003, 0x0804, 0x3376, 0x7007, 0x0003, 0x701f, 0x4690,
+	0x0005, 0x00ce, 0x009e, 0x00de, 0x2009, 0x0002, 0x0804, 0x3376,
+	0xa820, 0x9086, 0x8001, 0x1904, 0x3344, 0x2009, 0x0004, 0x0804,
+	0x3376, 0x0016, 0x0026, 0x3510, 0x20a9, 0x0002, 0x4002, 0x4104,
+	0x4004, 0x8211, 0x1dc8, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026,
+	0x0036, 0x0046, 0x3520, 0x20a9, 0x0004, 0x4002, 0x4304, 0x4204,
+	0x4104, 0x4004, 0x8421, 0x1db8, 0x004e, 0x003e, 0x002e, 0x001e,
+	0x0005, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3376, 0x60d8,
+	0xd0ac, 0x1160, 0xd09c, 0x0120, 0x2009, 0x0016, 0x0804, 0x3376,
+	0xd09c, 0x1120, 0x2009, 0x0005, 0x0804, 0x3376, 0x7984, 0x78a8,
+	0x2040, 0x080c, 0x9dae, 0x1120, 0x9182, 0x007f, 0x0a04, 0x3379,
+	0x9186, 0x00ff, 0x0904, 0x3379, 0x9182, 0x0800, 0x1a04, 0x3379,
+	0x7a8c, 0x7b88, 0x6078, 0x9306, 0x1158, 0x607c, 0x924e, 0x0904,
+	0x3379, 0x080c, 0x9dae, 0x1120, 0x99cc, 0xff00, 0x0904, 0x3379,
+	0x0126, 0x2091, 0x8000, 0x0026, 0x2011, 0x8008, 0x080c, 0x659e,
+	0x002e, 0x0140, 0x918d, 0x8000, 0x080c, 0x65e8, 0x1118, 0x2001,
+	0x4009, 0x0458, 0x080c, 0x47ae, 0x0560, 0x90c6, 0x4000, 0x1170,
+	0x00c6, 0x0006, 0x900e, 0x080c, 0x6476, 0x1108, 0xc185, 0xb800,
+	0xd0bc, 0x0108, 0xc18d, 0x000e, 0x00ce, 0x00b8, 0x90c6, 0x4007,
+	0x1110, 0x2408, 0x0090, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610,
+	0x0060, 0x90c6, 0x4009, 0x1108, 0x0040, 0x90c6, 0x4006, 0x1108,
+	0x0020, 0x2001, 0x4005, 0x2009, 0x000a, 0x2020, 0x012e, 0x0804,
+	0x3346, 0x2b00, 0x7026, 0x0016, 0x00b6, 0x00c6, 0x00e6, 0x2c70,
+	0x080c, 0x9e7c, 0x0904, 0x477b, 0x2b00, 0x6012, 0x080c, 0xbfb5,
+	0x2e58, 0x00ee, 0x00e6, 0x00c6, 0x080c, 0x4894, 0x00ce, 0x2b70,
+	0x1158, 0x080c, 0x9e2f, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e,
+	0x2009, 0x0002, 0x0804, 0x3376, 0x900e, 0xa966, 0xa96a, 0x2900,
+	0x6016, 0xa932, 0xa868, 0xc0fd, 0xd88c, 0x0108, 0xc0f5, 0xa86a,
+	0x080c, 0x2fe7, 0x6023, 0x0001, 0x9006, 0x080c, 0x6193, 0x2001,
+	0x0002, 0x080c, 0x61a7, 0x2009, 0x0002, 0x080c, 0x9ea9, 0x78a8,
+	0xd094, 0x0138, 0x00ee, 0x7024, 0x00e6, 0x2058, 0xb8bc, 0xc08d,
+	0xb8be, 0x9085, 0x0001, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e,
+	0x1120, 0x2009, 0x0003, 0x0804, 0x3376, 0x7007, 0x0003, 0x701f,
+	0x478a, 0x0005, 0xa830, 0x2008, 0x918e, 0xdead, 0x1120, 0x2021,
+	0x4009, 0x0804, 0x3346, 0x9086, 0x0100, 0x7024, 0x2058, 0x1138,
+	0x2009, 0x0004, 0xba04, 0x9294, 0x00ff, 0x0804, 0x52f7, 0x900e,
+	0xa868, 0xd0f4, 0x1904, 0x3344, 0x080c, 0x6476, 0x1108, 0xc185,
+	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3344, 0x00e6, 0x00d6,
+	0x0096, 0x83ff, 0x0904, 0x47f6, 0x902e, 0x080c, 0x9dae, 0x0130,
+	0x9026, 0x20a9, 0x0800, 0x2071, 0x1000, 0x0030, 0x2021, 0x007f,
+	0x20a9, 0x0781, 0x2071, 0x107f, 0x2e04, 0x9005, 0x11b0, 0x2100,
+	0x9406, 0x15e8, 0x2428, 0x94ce, 0x007f, 0x1120, 0x92ce, 0xfffd,
+	0x1528, 0x0030, 0x94ce, 0x0080, 0x1130, 0x92ce, 0xfffc, 0x11f0,
+	0x93ce, 0x00ff, 0x11d8, 0xc5fd, 0x0450, 0x2058, 0xbf10, 0x2700,
+	0x9306, 0x11b8, 0xbe14, 0x2600, 0x9206, 0x1198, 0x2400, 0x9106,
+	0x1150, 0xd884, 0x0568, 0xd894, 0x1558, 0x080c, 0x657a, 0x1540,
+	0x2001, 0x4000, 0x0430, 0x2001, 0x4007, 0x0418, 0x2001, 0x4006,
+	0x0400, 0x2400, 0x9106, 0x1158, 0xbe14, 0x87ff, 0x1128, 0x86ff,
+	0x0948, 0x080c, 0x9dae, 0x1930, 0x2001, 0x4008, 0x0090, 0x8420,
+	0x8e70, 0x1f04, 0x47c4, 0x85ff, 0x1130, 0x2001, 0x4009, 0x0048,
+	0x2001, 0x0001, 0x0030, 0x080c, 0x61f6, 0x1dd0, 0xbb12, 0xba16,
+	0x9006, 0x9005, 0x009e, 0x00de, 0x00ee, 0x0005, 0x81ff, 0x0120,
+	0x2009, 0x0001, 0x0804, 0x3376, 0x080c, 0x4894, 0x1120, 0x2009,
+	0x0002, 0x0804, 0x3376, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a,
+	0x7884, 0x9005, 0x0904, 0x3379, 0x9096, 0x00ff, 0x0120, 0x9092,
+	0x0004, 0x1a04, 0x3379, 0x2010, 0x2918, 0x080c, 0x2f8d, 0x1120,
+	0x2009, 0x0003, 0x0804, 0x3376, 0x7007, 0x0003, 0x701f, 0x4849,
+	0x0005, 0xa830, 0x9086, 0x0100, 0x1904, 0x3344, 0x2009, 0x0004,
+	0x0804, 0x3376, 0x7984, 0x080c, 0x9dae, 0x1120, 0x9182, 0x007f,
+	0x0a04, 0x3379, 0x9186, 0x00ff, 0x0904, 0x3379, 0x9182, 0x0800,
+	0x1a04, 0x3379, 0x2001, 0x9000, 0x080c, 0x5352, 0x1904, 0x3376,
+	0x0804, 0x3344, 0xa998, 0x080c, 0x9dae, 0x1118, 0x9182, 0x007f,
+	0x0280, 0x9186, 0x00ff, 0x0168, 0x9182, 0x0800, 0x1250, 0x2001,
+	0x9000, 0x080c, 0x5352, 0x11a8, 0x0060, 0xa897, 0x4005, 0xa99a,
+	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
+	0x0005, 0xa897, 0x4000, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000,
+	0x0005, 0x2009, 0x000a, 0x0c48, 0x080c, 0x0feb, 0x0198, 0x9006,
+	0xa802, 0x7014, 0x9005, 0x1120, 0x2900, 0x7016, 0x701a, 0x0040,
+	0x7018, 0xa802, 0x0086, 0x2040, 0x2900, 0xa006, 0x701a, 0x008e,
+	0x9085, 0x0001, 0x0005, 0x7984, 0x080c, 0x6256, 0x1130, 0x7e88,
+	0x9684, 0x3fff, 0x9082, 0x4000, 0x0208, 0x905e, 0x8bff, 0x0005,
+	0xa998, 0x080c, 0x6256, 0x1130, 0xae9c, 0x9684, 0x3fff, 0x9082,
+	0x4000, 0x0208, 0x905e, 0x8bff, 0x0005, 0xae98, 0x0008, 0x7e84,
+	0x2608, 0x080c, 0x6256, 0x1108, 0x0008, 0x905e, 0x8bff, 0x0005,
+	0x0016, 0x7114, 0x81ff, 0x0128, 0x2148, 0xa904, 0x080c, 0x101d,
+	0x0cc8, 0x7116, 0x711a, 0x001e, 0x0005, 0x2031, 0x0001, 0x0010,
+	0x2031, 0x0000, 0x2061, 0x18b6, 0x2c44, 0xa66a, 0xa17a, 0xa772,
+	0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10d5, 0x7007,
+	0x0002, 0x701f, 0x3344, 0x0005, 0x00f6, 0x0126, 0x2091, 0x8000,
+	0x2079, 0x0000, 0x2001, 0x18ae, 0x2004, 0x9005, 0x1190, 0x0e04,
+	0x4911, 0x7a36, 0x7833, 0x0012, 0x7a82, 0x7b86, 0x7c8a, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x0804,
+	0x4977, 0x0016, 0x0086, 0x0096, 0x00c6, 0x00e6, 0x2071, 0x189c,
+	0x7044, 0x9005, 0x1540, 0x7148, 0x9182, 0x0010, 0x0288, 0x7038,
+	0x2060, 0x080c, 0x0feb, 0x0904, 0x496f, 0xa84b, 0x0000, 0x2900,
+	0x7046, 0x2001, 0x0002, 0x9080, 0x1f33, 0x2005, 0xa846, 0x0098,
+	0x7038, 0x90e0, 0x0004, 0x2001, 0x18b8, 0x9c82, 0x18f8, 0x0210,
+	0x2061, 0x18b8, 0x2c00, 0x703a, 0x7148, 0x81ff, 0x1108, 0x703e,
+	0x8108, 0x714a, 0x0460, 0x7148, 0x8108, 0x714a, 0x7044, 0x2040,
+	0xa144, 0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c, 0x0db4, 0x2060,
+	0x001e, 0x8108, 0x2105, 0x9005, 0xa146, 0x1520, 0x080c, 0x0feb,
+	0x1130, 0x8109, 0xa946, 0x7148, 0x8109, 0x714a, 0x00d8, 0x9006,
+	0xa806, 0xa84a, 0xa046, 0x2800, 0xa802, 0x2900, 0xa006, 0x7046,
+	0x2001, 0x0002, 0x9080, 0x1f33, 0x2005, 0xa846, 0x0058, 0x2262,
+	0x6306, 0x640a, 0x00ee, 0x00ce, 0x009e, 0x008e, 0x001e, 0x012e,
+	0x00fe, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002, 0x4999, 0x4999,
+	0x499b, 0x4999, 0x4999, 0x4999, 0x499f, 0x4999, 0x4999, 0x4999,
+	0x49a3, 0x4999, 0x4999, 0x4999, 0x49a7, 0x4999, 0x4999, 0x4999,
+	0x49ab, 0x4999, 0x4999, 0x4999, 0x49af, 0x4999, 0x4999, 0x4999,
+	0x49b4, 0x080c, 0x0db4, 0xa276, 0xa37a, 0xa47e, 0x0898, 0xa286,
+	0xa38a, 0xa48e, 0x0878, 0xa296, 0xa39a, 0xa49e, 0x0858, 0xa2a6,
+	0xa3aa, 0xa4ae, 0x0838, 0xa2b6, 0xa3ba, 0xa4be, 0x0818, 0xa2c6,
+	0xa3ca, 0xa4ce, 0x0804, 0x4972, 0xa2d6, 0xa3da, 0xa4de, 0x0804,
+	0x4972, 0x00e6, 0x2071, 0x189c, 0x7048, 0x9005, 0x0904, 0x4a4b,
+	0x0126, 0x2091, 0x8000, 0x0e04, 0x4a4a, 0x00f6, 0x2079, 0x0000,
+	0x00c6, 0x0096, 0x0086, 0x0076, 0x9006, 0x2038, 0x7040, 0x2048,
+	0x9005, 0x0500, 0xa948, 0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c,
+	0x0db4, 0x2060, 0x001e, 0x8108, 0x2105, 0x9005, 0xa94a, 0x1904,
+	0x4a4d, 0xa804, 0x9005, 0x090c, 0x0db4, 0x7042, 0x2938, 0x2040,
+	0xa003, 0x0000, 0x2001, 0x0002, 0x9080, 0x1f33, 0x2005, 0xa04a,
+	0x0804, 0x4a4d, 0x703c, 0x2060, 0x2c14, 0x6304, 0x6408, 0x650c,
+	0x2200, 0x7836, 0x7833, 0x0012, 0x7882, 0x2300, 0x7886, 0x2400,
+	0x788a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x1187, 0x87ff, 0x0118, 0x2748, 0x080c, 0x101d, 0x7048, 0x8001,
+	0x704a, 0x9005, 0x1170, 0x7040, 0x2048, 0x9005, 0x0128, 0x080c,
+	0x101d, 0x9006, 0x7042, 0x7046, 0x703b, 0x18b8, 0x703f, 0x18b8,
+	0x0420, 0x7040, 0x9005, 0x1508, 0x7238, 0x2c00, 0x9206, 0x0148,
+	0x9c80, 0x0004, 0x90fa, 0x18f8, 0x0210, 0x2001, 0x18b8, 0x703e,
+	0x00a0, 0x9006, 0x703e, 0x703a, 0x7044, 0x9005, 0x090c, 0x0db4,
+	0x2048, 0xa800, 0x9005, 0x1de0, 0x2900, 0x7042, 0x2001, 0x0002,
+	0x9080, 0x1f33, 0x2005, 0xa84a, 0x0000, 0x007e, 0x008e, 0x009e,
+	0x00ce, 0x00fe, 0x012e, 0x00ee, 0x0005, 0x2c00, 0x9082, 0x001b,
+	0x0002, 0x4a6c, 0x4a6c, 0x4a6e, 0x4a6c, 0x4a6c, 0x4a6c, 0x4a73,
+	0x4a6c, 0x4a6c, 0x4a6c, 0x4a78, 0x4a6c, 0x4a6c, 0x4a6c, 0x4a7d,
+	0x4a6c, 0x4a6c, 0x4a6c, 0x4a82, 0x4a6c, 0x4a6c, 0x4a6c, 0x4a87,
+	0x4a6c, 0x4a6c, 0x4a6c, 0x4a8c, 0x080c, 0x0db4, 0xaa74, 0xab78,
+	0xac7c, 0x0804, 0x49f8, 0xaa84, 0xab88, 0xac8c, 0x0804, 0x49f8,
+	0xaa94, 0xab98, 0xac9c, 0x0804, 0x49f8, 0xaaa4, 0xaba8, 0xacac,
+	0x0804, 0x49f8, 0xaab4, 0xabb8, 0xacbc, 0x0804, 0x49f8, 0xaac4,
+	0xabc8, 0xaccc, 0x0804, 0x49f8, 0xaad4, 0xabd8, 0xacdc, 0x0804,
+	0x49f8, 0x0026, 0x080c, 0x539a, 0xd0c4, 0x0120, 0x2011, 0x8014,
+	0x080c, 0x48f4, 0x002e, 0x0005, 0x81ff, 0x1904, 0x3376, 0x0126,
+	0x2091, 0x8000, 0x6030, 0xc08d, 0xc085, 0xc0ac, 0x6032, 0x080c,
+	0x6faa, 0x1158, 0x080c, 0x728c, 0x080c, 0x5ce5, 0x9085, 0x0001,
+	0x080c, 0x6ff1, 0x080c, 0x6edc, 0x0010, 0x080c, 0x5ba4, 0x012e,
+	0x0804, 0x3344, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3376,
+	0x080c, 0x53ae, 0x0120, 0x2009, 0x0007, 0x0804, 0x3376, 0x080c,
+	0x6572, 0x0120, 0x2009, 0x0008, 0x0804, 0x3376, 0x0026, 0x2011,
+	0x0010, 0x080c, 0x659e, 0x002e, 0x0140, 0x7984, 0x080c, 0x65e8,
+	0x1120, 0x2009, 0x4009, 0x0804, 0x3376, 0x7984, 0x080c, 0x61f6,
+	0x1904, 0x3379, 0x2b00, 0x7026, 0x080c, 0x657a, 0x7888, 0x1170,
+	0x9084, 0x0005, 0x1158, 0x900e, 0x080c, 0x6476, 0x1108, 0xc185,
+	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3344, 0x080c, 0x4894,
+	0x0904, 0x3376, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
+	0x080c, 0xbd63, 0x0904, 0x3376, 0x7888, 0xd094, 0x0118, 0xb8bc,
+	0xc08d, 0xb8be, 0x7007, 0x0003, 0x701f, 0x4b5b, 0x0005, 0x2061,
+	0x1800, 0x080c, 0x53ae, 0x2009, 0x0007, 0x1578, 0x080c, 0x6572,
+	0x0118, 0x2009, 0x0008, 0x0448, 0x080c, 0x313b, 0x0120, 0xa998,
+	0x080c, 0x61f6, 0x1530, 0x080c, 0x48c5, 0x0518, 0x080c, 0x657a,
+	0xa89c, 0x1168, 0x9084, 0x0005, 0x1150, 0x900e, 0x080c, 0x6476,
+	0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x00d0, 0xa868,
+	0xc0fc, 0xa86a, 0x080c, 0xbd63, 0x11e0, 0xa89c, 0xd094, 0x0118,
+	0xb8bc, 0xc08d, 0xb8be, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a,
+	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
+	0x0005, 0xa897, 0x4000, 0xa99a, 0x9006, 0x918d, 0x0001, 0x2008,
+	0x0005, 0x9006, 0x0005, 0xa830, 0x2008, 0x918e, 0xdead, 0x1120,
+	0x2021, 0x4009, 0x0804, 0x3346, 0x9086, 0x0100, 0x7024, 0x2058,
+	0x1110, 0x0804, 0x52f7, 0x900e, 0x080c, 0x6476, 0x1108, 0xc185,
+	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3344, 0x080c, 0x53ae,
+	0x0120, 0x2009, 0x0007, 0x0804, 0x3376, 0x7f84, 0x7a8c, 0x7b88,
+	0x7c9c, 0x7d98, 0x080c, 0x4894, 0x1120, 0x2009, 0x0002, 0x0804,
+	0x3376, 0x900e, 0x2130, 0x7126, 0x7132, 0xa860, 0x20e8, 0x7036,
+	0xa85c, 0x9080, 0x0005, 0x702a, 0x20a0, 0x080c, 0x6256, 0x1904,
+	0x4bf9, 0x080c, 0x657a, 0x0120, 0x080c, 0x6582, 0x1904, 0x4bf9,
+	0x080c, 0x6572, 0x1130, 0x080c, 0x6476, 0x1118, 0xd79c, 0x0904,
+	0x4bf9, 0xd794, 0x1110, 0xd784, 0x01a8, 0xb8b4, 0x20e0, 0xb8b8,
+	0x9080, 0x0006, 0x2098, 0x3400, 0xd794, 0x0160, 0x20a9, 0x0008,
+	0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x20a9, 0x0002, 0x080c,
+	0x46a6, 0x0048, 0x20a9, 0x0004, 0x4003, 0x2098, 0x20a0, 0x3d00,
+	0x20e0, 0x080c, 0x46a6, 0x4104, 0xd794, 0x0528, 0xb8b4, 0x20e0,
+	0xb8b8, 0x2060, 0x9c80, 0x0000, 0x2098, 0x20a9, 0x0002, 0x4003,
+	0x9c80, 0x0003, 0x2098, 0x20a9, 0x0001, 0x4005, 0x9c80, 0x0004,
+	0x2098, 0x3400, 0x20a9, 0x0002, 0x4003, 0x2098, 0x20a0, 0x3d00,
+	0x20e0, 0x080c, 0x4699, 0x9c80, 0x0026, 0x2098, 0xb8b4, 0x20e0,
+	0x20a9, 0x0002, 0x4003, 0xd794, 0x0110, 0x96b0, 0x000b, 0x96b0,
+	0x0005, 0x8108, 0x080c, 0x9dae, 0x0118, 0x9186, 0x0800, 0x0040,
+	0xd78c, 0x0120, 0x9186, 0x0800, 0x0170, 0x0018, 0x9186, 0x007e,
+	0x0150, 0xd794, 0x0118, 0x9686, 0x0020, 0x0010, 0x9686, 0x0028,
+	0x0150, 0x0804, 0x4b95, 0x86ff, 0x1120, 0x7124, 0x810b, 0x0804,
+	0x3344, 0x7033, 0x0001, 0x7122, 0x7024, 0x9600, 0x7026, 0x772e,
+	0x2061, 0x18b6, 0x2c44, 0xa06b, 0x0000, 0xa67a, 0x7034, 0xa072,
+	0x7028, 0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10d5,
+	0x7007, 0x0002, 0x701f, 0x4c35, 0x0005, 0x7030, 0x9005, 0x1180,
+	0x7120, 0x7028, 0x20a0, 0x772c, 0x9036, 0x7034, 0x20e8, 0x2061,
+	0x18b6, 0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x0804, 0x4b95,
+	0x7124, 0x810b, 0x0804, 0x3344, 0x2029, 0x007e, 0x7984, 0x7a88,
+	0x7b8c, 0x7c98, 0x9184, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04,
+	0x3379, 0x9502, 0x0a04, 0x3379, 0x9184, 0x00ff, 0x90e2, 0x0020,
+	0x0a04, 0x3379, 0x9502, 0x0a04, 0x3379, 0x9284, 0xff00, 0x8007,
+	0x90e2, 0x0020, 0x0a04, 0x3379, 0x9502, 0x0a04, 0x3379, 0x9284,
+	0x00ff, 0x90e2, 0x0020, 0x0a04, 0x3379, 0x9502, 0x0a04, 0x3379,
+	0x9384, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x3379, 0x9502,
+	0x0a04, 0x3379, 0x9384, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x3379,
+	0x9502, 0x0a04, 0x3379, 0x9484, 0xff00, 0x8007, 0x90e2, 0x0020,
+	0x0a04, 0x3379, 0x9502, 0x0a04, 0x3379, 0x9484, 0x00ff, 0x90e2,
+	0x0020, 0x0a04, 0x3379, 0x9502, 0x0a04, 0x3379, 0x2061, 0x1961,
+	0x6102, 0x6206, 0x630a, 0x640e, 0x0804, 0x3344, 0x0006, 0x080c,
+	0x539a, 0xd0cc, 0x000e, 0x0005, 0x0006, 0x080c, 0x539e, 0xd0bc,
+	0x000e, 0x0005, 0x6170, 0x7a84, 0x6300, 0x82ff, 0x1118, 0x7986,
+	0x0804, 0x3344, 0x83ff, 0x1904, 0x3379, 0x2001, 0xfff0, 0x9200,
+	0x1a04, 0x3379, 0x2019, 0xffff, 0x6074, 0x9302, 0x9200, 0x0a04,
+	0x3379, 0x7986, 0x6272, 0x0804, 0x3344, 0x080c, 0x53ae, 0x1904,
+	0x3376, 0x7c88, 0x7d84, 0x7e98, 0x7f8c, 0x080c, 0x4894, 0x0904,
+	0x3376, 0x900e, 0x901e, 0x7326, 0x7332, 0xa860, 0x20e8, 0x7036,
+	0xa85c, 0x9080, 0x0003, 0x702a, 0x20a0, 0x91d8, 0x1000, 0x2b5c,
+	0x8bff, 0x0178, 0x080c, 0x657a, 0x0118, 0x080c, 0x6582, 0x1148,
+	0x20a9, 0x0001, 0xb814, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398,
+	0x0003, 0x8108, 0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x0170,
+	0x0c20, 0x83ff, 0x1148, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c,
+	0x8277, 0x2208, 0x0804, 0x3344, 0x7033, 0x0001, 0x7122, 0x7024,
+	0x9300, 0x7026, 0x2061, 0x18b6, 0x2c44, 0xa06b, 0x0000, 0xa37a,
+	0x7028, 0xa076, 0x7034, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a,
+	0x080c, 0x10d5, 0x7007, 0x0002, 0x701f, 0x4d27, 0x0005, 0x7030,
+	0x9005, 0x1178, 0x7120, 0x7028, 0x20a0, 0x901e, 0x7034, 0x20e8,
+	0x2061, 0x18b6, 0x2c44, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0804,
+	0x4ce5, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c, 0x8277, 0x2208,
+	0x0804, 0x3344, 0x00f6, 0x00e6, 0x080c, 0x53ae, 0x2009, 0x0007,
+	0x1904, 0x4dba, 0x2071, 0x189c, 0x745c, 0x84ff, 0x2009, 0x000e,
+	0x1904, 0x4dba, 0xac9c, 0xad98, 0xaea4, 0xafa0, 0x0096, 0x080c,
+	0x1004, 0x2009, 0x0002, 0x0904, 0x4dba, 0x2900, 0x705e, 0x900e,
+	0x901e, 0x7356, 0x7362, 0xa860, 0x7066, 0xa85c, 0x9080, 0x0003,
+	0x705a, 0x20a0, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c,
+	0x657a, 0x0118, 0x080c, 0x6582, 0x1148, 0xb814, 0x20a9, 0x0001,
 	0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003, 0x8108, 0x9182,
-	0x0800, 0x0120, 0x9386, 0x003c, 0x0170, 0x0c20, 0x83ff, 0x1148,
-	0x7224, 0x900e, 0x2001, 0x0003, 0x080c, 0x8259, 0x2208, 0x0804,
-	0x3339, 0x7033, 0x0001, 0x7122, 0x7024, 0x9300, 0x7026, 0x2061,
-	0x18ae, 0x2c44, 0xa06b, 0x0000, 0xa37a, 0x7028, 0xa076, 0x7034,
-	0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a, 0x080c, 0x10d5, 0x7007,
-	0x0002, 0x701f, 0x4d1c, 0x0005, 0x7030, 0x9005, 0x1178, 0x7120,
-	0x7028, 0x20a0, 0x901e, 0x7034, 0x20e8, 0x2061, 0x18ae, 0x2c44,
-	0xa48c, 0xa590, 0xa694, 0xa798, 0x0804, 0x4cda, 0x7224, 0x900e,
-	0x2001, 0x0003, 0x080c, 0x8259, 0x2208, 0x0804, 0x3339, 0x00f6,
-	0x00e6, 0x080c, 0x53a3, 0x2009, 0x0007, 0x1904, 0x4daf, 0x2071,
-	0x1894, 0x745c, 0x84ff, 0x2009, 0x000e, 0x1904, 0x4daf, 0xac9c,
-	0xad98, 0xaea4, 0xafa0, 0x0096, 0x080c, 0x1004, 0x2009, 0x0002,
-	0x0904, 0x4daf, 0x2900, 0x705e, 0x900e, 0x901e, 0x7356, 0x7362,
-	0xa860, 0x7066, 0xa85c, 0x9080, 0x0003, 0x705a, 0x20a0, 0x91d8,
-	0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x656b, 0x0118, 0x080c,
-	0x6573, 0x1148, 0xb814, 0x20a9, 0x0001, 0x4004, 0xb810, 0x4004,
-	0x4104, 0x9398, 0x0003, 0x8108, 0x9182, 0x0800, 0x0120, 0x9386,
-	0x003c, 0x01e8, 0x0c20, 0x83ff, 0x11c0, 0x7254, 0x900e, 0x2001,
-	0x0003, 0x080c, 0x8259, 0x2208, 0x009e, 0xa897, 0x4000, 0xa99a,
-	0x715c, 0x81ff, 0x090c, 0x0db4, 0x2148, 0x080c, 0x101d, 0x9006,
-	0x705e, 0x918d, 0x0001, 0x2008, 0x0418, 0x7063, 0x0001, 0x7152,
-	0x7054, 0x9300, 0x7056, 0x2061, 0x18af, 0x2c44, 0xa37a, 0x7058,
-	0xa076, 0x7064, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a, 0xa09f,
-	0x4dbb, 0x000e, 0xa0a2, 0x080c, 0x10d5, 0x9006, 0x0048, 0x009e,
-	0xa897, 0x4005, 0xa99a, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
-	0x00ee, 0x00fe, 0x0005, 0x00f6, 0xa0a0, 0x904d, 0x090c, 0x0db4,
-	0x00e6, 0x2071, 0x1894, 0xa06c, 0x908e, 0x0100, 0x0138, 0xa87b,
-	0x0030, 0xa883, 0x0000, 0xa897, 0x4002, 0x00d8, 0x7060, 0x9005,
-	0x1158, 0x7150, 0x7058, 0x20a0, 0x901e, 0x7064, 0x20e8, 0xa48c,
-	0xa590, 0xa694, 0xa798, 0x0428, 0xa87b, 0x0000, 0xa883, 0x0000,
-	0xa897, 0x4000, 0x7254, 0x900e, 0x2001, 0x0003, 0x080c, 0x8259,
-	0xaa9a, 0x715c, 0x81ff, 0x090c, 0x0db4, 0x2148, 0x080c, 0x101d,
-	0x705f, 0x0000, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x6891, 0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x00ee, 0x00fe,
-	0x0005, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x656b,
-	0x0118, 0x080c, 0x6573, 0x1148, 0xb814, 0x20a9, 0x0001, 0x4004,
-	0xb810, 0x4004, 0x4104, 0x9398, 0x0003, 0x8108, 0x9182, 0x0800,
-	0x0120, 0x9386, 0x003c, 0x0518, 0x0c20, 0x83ff, 0x11f0, 0x7154,
-	0x810c, 0xa99a, 0xa897, 0x4000, 0x715c, 0x81ff, 0x090c, 0x0db4,
-	0x2148, 0x080c, 0x101d, 0x9006, 0x705e, 0x918d, 0x0001, 0x2008,
-	0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000, 0x080c, 0x6891, 0x012e,
-	0xa09f, 0x0000, 0xa0a3, 0x0000, 0x0070, 0x7063, 0x0001, 0x7152,
-	0x7054, 0x9300, 0x7056, 0xa37a, 0xa48e, 0xa592, 0xa696, 0xa79a,
-	0x080c, 0x10d5, 0x9006, 0x00ee, 0x0005, 0x0096, 0xa88c, 0x90be,
-	0x7000, 0x0148, 0x90be, 0x7100, 0x0130, 0x90be, 0x7200, 0x0118,
-	0x009e, 0x0804, 0x336e, 0xa884, 0xa988, 0x080c, 0x2665, 0x1518,
-	0x080c, 0x61e7, 0x1500, 0x7126, 0xbe12, 0xbd16, 0xae7c, 0x080c,
-	0x4889, 0x01c8, 0x080c, 0x4889, 0x01b0, 0x009e, 0xa867, 0x0000,
-	0xa868, 0xc0fd, 0xa86a, 0xa823, 0x0000, 0xa804, 0x2048, 0x080c,
-	0xbcd6, 0x1120, 0x2009, 0x0003, 0x0804, 0x336b, 0x7007, 0x0003,
-	0x701f, 0x4e88, 0x0005, 0x009e, 0x2009, 0x0002, 0x0804, 0x336b,
-	0x7124, 0x080c, 0x30d7, 0xa820, 0x9086, 0x8001, 0x1120, 0x2009,
-	0x0004, 0x0804, 0x336b, 0x2900, 0x7022, 0xa804, 0x0096, 0x2048,
-	0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x009e,
-	0x9080, 0x0002, 0x0076, 0x0006, 0x2098, 0x20a0, 0x27e0, 0x27e8,
-	0x20a9, 0x002a, 0x080c, 0x0f68, 0xaa6c, 0xab70, 0xac74, 0xad78,
-	0x2061, 0x18ae, 0x2c44, 0xa06b, 0x0000, 0xae64, 0xaf8c, 0x97c6,
-	0x7000, 0x0118, 0x97c6, 0x7100, 0x1148, 0x96c2, 0x0004, 0x0600,
-	0x2009, 0x0004, 0x000e, 0x007e, 0x0804, 0x48d5, 0x97c6, 0x7200,
-	0x11b8, 0x96c2, 0x0054, 0x02a0, 0x000e, 0x007e, 0x2061, 0x18ae,
-	0x2c44, 0xa076, 0xa772, 0xa07b, 0x002a, 0xa28e, 0xa392, 0xa496,
-	0xa59a, 0x080c, 0x10d5, 0x7007, 0x0002, 0x701f, 0x4ee4, 0x0005,
-	0x000e, 0x007e, 0x0804, 0x336e, 0x7020, 0x2048, 0xa804, 0x2048,
-	0xa804, 0x2048, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
-	0xffc0, 0x9080, 0x0002, 0x2098, 0x20a0, 0x27e0, 0x27e8, 0x20a9,
-	0x002a, 0x080c, 0x0f68, 0x2100, 0x2238, 0x2061, 0x18ae, 0x2c44,
-	0xa28c, 0xa390, 0xa494, 0xa598, 0x2009, 0x002a, 0x0804, 0x48d5,
-	0x81ff, 0x1904, 0x336b, 0x798c, 0x2001, 0x194e, 0x918c, 0x8000,
-	0x2102, 0x080c, 0x48a0, 0x0904, 0x336e, 0x080c, 0x656b, 0x0120,
-	0x080c, 0x6573, 0x1904, 0x336e, 0x080c, 0x630e, 0x0904, 0x336b,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x63d4, 0x012e, 0x0904, 0x336b,
-	0x2001, 0x194e, 0x2004, 0xd0fc, 0x1904, 0x3339, 0x0804, 0x430e,
-	0xa9a0, 0x2001, 0x194e, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c,
-	0x48ad, 0x01a0, 0x080c, 0x656b, 0x0118, 0x080c, 0x6573, 0x1170,
-	0x080c, 0x630e, 0x2009, 0x0002, 0x0128, 0x080c, 0x63d4, 0x1170,
-	0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
-	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000,
-	0x2001, 0x194e, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x5397, 0x0110,
-	0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005,
-	0x78a8, 0xd08c, 0x1118, 0xd084, 0x0904, 0x4283, 0x080c, 0x48bc,
-	0x0904, 0x336e, 0x080c, 0x4889, 0x1120, 0x2009, 0x0002, 0x0804,
-	0x336b, 0x080c, 0x656b, 0x0130, 0x908e, 0x0004, 0x0118, 0x908e,
-	0x0005, 0x15a0, 0x78a8, 0xd08c, 0x0120, 0xb800, 0xc08c, 0xb802,
-	0x0028, 0x080c, 0x538f, 0xd0b4, 0x0904, 0x42bd, 0x7884, 0x908e,
-	0x007e, 0x0904, 0x42bd, 0x908e, 0x007f, 0x0904, 0x42bd, 0x908e,
-	0x0080, 0x0904, 0x42bd, 0xb800, 0xd08c, 0x1904, 0x42bd, 0xa867,
-	0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xbcf5, 0x1120, 0x2009,
-	0x0003, 0x0804, 0x336b, 0x7007, 0x0003, 0x701f, 0x4fb0, 0x0005,
-	0x080c, 0x48bc, 0x0904, 0x336e, 0x0804, 0x42bd, 0x080c, 0x3130,
-	0x0108, 0x0005, 0x2009, 0x1833, 0x210c, 0x81ff, 0x0120, 0x2009,
-	0x0001, 0x0804, 0x336b, 0x080c, 0x53a3, 0x0120, 0x2009, 0x0007,
-	0x0804, 0x336b, 0x080c, 0x6563, 0x0120, 0x2009, 0x0008, 0x0804,
-	0x336b, 0xb89c, 0xd0a4, 0x1118, 0xd0ac, 0x1904, 0x42bd, 0x9006,
-	0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xbd54, 0x1120,
-	0x2009, 0x0003, 0x0804, 0x336b, 0x7007, 0x0003, 0x701f, 0x4fe9,
-	0x0005, 0xa830, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804,
-	0x52ec, 0x080c, 0x48bc, 0x0904, 0x336e, 0x0804, 0x4f82, 0x81ff,
-	0x2009, 0x0001, 0x1904, 0x336b, 0x080c, 0x53a3, 0x2009, 0x0007,
-	0x1904, 0x336b, 0x080c, 0x6563, 0x0120, 0x2009, 0x0008, 0x0804,
-	0x336b, 0x080c, 0x48bc, 0x0904, 0x336e, 0x080c, 0x656b, 0x2009,
-	0x0009, 0x1904, 0x336b, 0x080c, 0x4889, 0x2009, 0x0002, 0x0904,
-	0x336b, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x7988,
-	0x9194, 0xff00, 0x918c, 0x00ff, 0x9006, 0x82ff, 0x1128, 0xc0ed,
-	0xa952, 0x798c, 0xa956, 0x0038, 0x928e, 0x0100, 0x1904, 0x336e,
-	0xc0e5, 0xa952, 0xa956, 0xa83e, 0x080c, 0xbfa7, 0x2009, 0x0003,
-	0x0904, 0x336b, 0x7007, 0x0003, 0x701f, 0x503f, 0x0005, 0xa830,
-	0x9086, 0x0100, 0x2009, 0x0004, 0x0904, 0x336b, 0x0804, 0x3339,
-	0x7aa8, 0x9284, 0xc000, 0x0148, 0xd2ec, 0x01a0, 0x080c, 0x53a3,
-	0x1188, 0x2009, 0x0014, 0x0804, 0x336b, 0xd2dc, 0x1568, 0x81ff,
-	0x2009, 0x0001, 0x1904, 0x336b, 0x080c, 0x53a3, 0x2009, 0x0007,
-	0x1904, 0x336b, 0xd2f4, 0x0130, 0x9284, 0x5000, 0x080c, 0x536a,
-	0x0804, 0x3339, 0xd2fc, 0x0158, 0x080c, 0x48bc, 0x0904, 0x336e,
-	0x7984, 0x9284, 0x9000, 0x080c, 0x5347, 0x0804, 0x3339, 0x080c,
-	0x48bc, 0x0904, 0x336e, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
-	0x2009, 0x0009, 0x1904, 0x5128, 0x080c, 0x4889, 0x2009, 0x0002,
-	0x0904, 0x5128, 0xa85c, 0x9080, 0x001b, 0xaf60, 0x2009, 0x0008,
-	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c, 0x48d2, 0x701f, 0x5099,
-	0x0005, 0xa86c, 0x9086, 0x0500, 0x1138, 0xa870, 0x9005, 0x1120,
-	0xa874, 0x9084, 0xff00, 0x0110, 0x1904, 0x336e, 0xa866, 0xa832,
-	0xa868, 0xc0fd, 0xa86a, 0x080c, 0x48bc, 0x1110, 0x0804, 0x336e,
-	0x2009, 0x0043, 0x080c, 0xc00f, 0x2009, 0x0003, 0x0904, 0x5128,
-	0x7007, 0x0003, 0x701f, 0x50bd, 0x0005, 0xa830, 0x9086, 0x0100,
-	0x2009, 0x0004, 0x0904, 0x5128, 0x7984, 0x7aa8, 0x9284, 0x1000,
-	0x080c, 0x5347, 0x0804, 0x3339, 0x00c6, 0xaab0, 0x9284, 0xc000,
-	0x0140, 0xd2ec, 0x0168, 0x080c, 0x53a3, 0x1150, 0x2009, 0x0014,
-	0x04f0, 0x2061, 0x1800, 0x080c, 0x53a3, 0x2009, 0x0007, 0x15b8,
-	0xd2f4, 0x0128, 0x9284, 0x5000, 0x080c, 0x536a, 0x0050, 0xd2fc,
-	0x0178, 0x080c, 0x48ba, 0x0588, 0xa998, 0x9284, 0x9000, 0x080c,
-	0x5347, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x0438,
-	0x080c, 0x48ba, 0x0510, 0x080c, 0x656b, 0x2009, 0x0009, 0x11b8,
-	0xa8c4, 0x9086, 0x0500, 0x11c8, 0xa8c8, 0x9005, 0x11b0, 0xa8cc,
-	0x9084, 0xff00, 0x1190, 0x080c, 0x48ba, 0x1108, 0x0070, 0x2009,
-	0x004b, 0x080c, 0xc00f, 0x2009, 0x0003, 0x0108, 0x0078, 0x0429,
-	0x19c0, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006, 0x900e,
-	0x9085, 0x0001, 0x2001, 0x0030, 0x00ce, 0x0005, 0x9006, 0x0ce0,
-	0x7aa8, 0xd2dc, 0x0904, 0x336b, 0x0016, 0x7984, 0x9284, 0x1000,
-	0xc0fd, 0x080c, 0x5347, 0x001e, 0x1904, 0x336b, 0x0804, 0x3339,
-	0x00f6, 0x2d78, 0x0011, 0x00fe, 0x0005, 0xaab0, 0xd2dc, 0x0150,
-	0x0016, 0xa998, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x5347, 0x001e,
-	0x9085, 0x0001, 0x0005, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804,
-	0x336b, 0x080c, 0x53a3, 0x0120, 0x2009, 0x0007, 0x0804, 0x336b,
-	0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c, 0x6247, 0x1904, 0x336e,
-	0x9186, 0x007f, 0x0138, 0x080c, 0x656b, 0x0120, 0x2009, 0x0009,
-	0x0804, 0x336b, 0x080c, 0x4889, 0x1120, 0x2009, 0x0002, 0x0804,
-	0x336b, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x2001, 0x0100,
-	0x8007, 0xa80a, 0x080c, 0xbd0f, 0x1120, 0x2009, 0x0003, 0x0804,
-	0x336b, 0x7007, 0x0003, 0x701f, 0x5186, 0x0005, 0xa808, 0x8007,
-	0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x336b, 0xa8e0,
-	0xa866, 0xa810, 0x8007, 0x9084, 0x00ff, 0x800c, 0xa814, 0x8007,
-	0x9084, 0x00ff, 0x8004, 0x9080, 0x0002, 0x9108, 0x8906, 0x8006,
-	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0004, 0x7a8c,
-	0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x48d5, 0x080c, 0x4889, 0x1120,
-	0x2009, 0x0002, 0x0804, 0x336b, 0x7984, 0x9194, 0xff00, 0x918c,
-	0x00ff, 0x8217, 0x82ff, 0x1118, 0x7023, 0x1983, 0x0040, 0x92c6,
-	0x0001, 0x1118, 0x7023, 0x199d, 0x0010, 0x0804, 0x336e, 0x2009,
-	0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019,
-	0xaf60, 0x080c, 0x48d2, 0x701f, 0x51d6, 0x0005, 0x2001, 0x182d,
-	0x2003, 0x0001, 0xa85c, 0x9080, 0x0019, 0x2098, 0xa860, 0x20e0,
-	0x20a9, 0x001a, 0x7020, 0x20a0, 0x20e9, 0x0001, 0x4003, 0x0804,
-	0x3339, 0x080c, 0x4889, 0x1120, 0x2009, 0x0002, 0x0804, 0x336b,
-	0x7984, 0x9194, 0xff00, 0x918c, 0x00ff, 0x8217, 0x82ff, 0x1118,
-	0x2099, 0x1983, 0x0040, 0x92c6, 0x0001, 0x1118, 0x2099, 0x199d,
-	0x0010, 0x0804, 0x336e, 0xa85c, 0x9080, 0x0019, 0x20a0, 0xa860,
-	0x20e8, 0x20a9, 0x001a, 0x20e1, 0x0001, 0x4003, 0x2009, 0x001a,
-	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0xaf60,
-	0x0804, 0x48d5, 0x7884, 0x908a, 0x1000, 0x1a04, 0x336e, 0x0126,
-	0x2091, 0x8000, 0x8003, 0x800b, 0x810b, 0x9108, 0x00c6, 0x2061,
-	0x19ca, 0x6142, 0x00ce, 0x012e, 0x0804, 0x3339, 0x00c6, 0x080c,
-	0x6f9b, 0x1160, 0x080c, 0x727f, 0x080c, 0x5cda, 0x9085, 0x0001,
-	0x080c, 0x6fe2, 0x080c, 0x6ecd, 0x080c, 0x0db4, 0x2061, 0x1800,
-	0x6030, 0xc09d, 0x6032, 0x080c, 0x5b99, 0x00ce, 0x0005, 0x00c6,
-	0x2001, 0x1800, 0x2004, 0x908e, 0x0000, 0x0904, 0x336b, 0x7884,
-	0x9005, 0x0188, 0x7888, 0x2061, 0x196c, 0x2c0c, 0x2062, 0x080c,
-	0x2a47, 0x01a0, 0x080c, 0x2a4f, 0x0188, 0x080c, 0x2a57, 0x0170,
-	0x2162, 0x0804, 0x336e, 0x2061, 0x0100, 0x6038, 0x9086, 0x0007,
-	0x1118, 0x2009, 0x0001, 0x0010, 0x2009, 0x0000, 0x7884, 0x9086,
-	0x0002, 0x1548, 0x2061, 0x0100, 0x6028, 0xc09c, 0x602a, 0x0026,
-	0x2011, 0x0003, 0x080c, 0x9772, 0x2011, 0x0002, 0x080c, 0x977c,
-	0x002e, 0x080c, 0x9663, 0x0036, 0x901e, 0x080c, 0x96d9, 0x003e,
-	0x60e3, 0x0000, 0x080c, 0xd8d5, 0x080c, 0xd8f0, 0x9085, 0x0001,
-	0x080c, 0x6fe2, 0x9006, 0x080c, 0x2b16, 0x2001, 0x1800, 0x2003,
-	0x0004, 0x6027, 0x0008, 0x00ce, 0x0804, 0x3339, 0x81ff, 0x0120,
-	0x2009, 0x0001, 0x0804, 0x336b, 0x080c, 0x53a3, 0x0120, 0x2009,
-	0x0007, 0x0804, 0x336b, 0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c,
-	0x6247, 0x1904, 0x336e, 0x9186, 0x007f, 0x0138, 0x080c, 0x656b,
-	0x0120, 0x2009, 0x0009, 0x0804, 0x336b, 0x080c, 0x4889, 0x1120,
-	0x2009, 0x0002, 0x0804, 0x336b, 0xa867, 0x0000, 0xa868, 0xc0fd,
-	0xa86a, 0x080c, 0xbd12, 0x1120, 0x2009, 0x0003, 0x0804, 0x336b,
-	0x7007, 0x0003, 0x701f, 0x52d5, 0x0005, 0xa830, 0x9086, 0x0100,
-	0x1120, 0x2009, 0x0004, 0x0804, 0x336b, 0xa8e0, 0xa866, 0xa834,
-	0x8007, 0x800c, 0xa85c, 0x9080, 0x000c, 0x7a8c, 0x7b88, 0x7c9c,
-	0x7d98, 0xaf60, 0x0804, 0x48d5, 0xa898, 0x9086, 0x000d, 0x1904,
-	0x336b, 0x2021, 0x4005, 0x0126, 0x2091, 0x8000, 0x0e04, 0x52f9,
-	0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000, 0x0118, 0x7833,
-	0x0011, 0x0010, 0x7833, 0x0010, 0x7883, 0x4005, 0xa998, 0x7986,
-	0xa9a4, 0x799a, 0xa9a8, 0x799e, 0x080c, 0x48c5, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x7007, 0x0001,
-	0x2091, 0x5000, 0x700f, 0x0000, 0x012e, 0x0005, 0x0126, 0x2091,
-	0x8000, 0x00c6, 0x2061, 0x19ca, 0x7984, 0x6152, 0x614e, 0x6057,
-	0x0000, 0x604b, 0x0009, 0x7898, 0x606a, 0x789c, 0x6066, 0x7888,
-	0x6062, 0x788c, 0x605e, 0x2001, 0x19d8, 0x2044, 0x2001, 0x19df,
-	0xa076, 0xa060, 0xa072, 0xa07b, 0x0001, 0xa07f, 0x0002, 0xa06b,
-	0x0000, 0xa09f, 0x0000, 0x00ce, 0x012e, 0x0804, 0x3339, 0x0126,
-	0x2091, 0x8000, 0x00b6, 0x00c6, 0x90e4, 0xc000, 0x0128, 0x0006,
-	0x080c, 0xbb79, 0x000e, 0x1198, 0xd0e4, 0x0160, 0x9180, 0x1000,
-	0x2004, 0x905d, 0x0160, 0x080c, 0x5cf4, 0x080c, 0x9dc1, 0x0110,
-	0xb817, 0x0000, 0x9006, 0x00ce, 0x00be, 0x012e, 0x0005, 0x9085,
-	0x0001, 0x0cc8, 0x0126, 0x2091, 0x8000, 0x0156, 0x2010, 0x900e,
-	0x20a9, 0x0800, 0x0016, 0x9180, 0x1000, 0x2004, 0x9005, 0x0180,
-	0x9186, 0x007e, 0x0168, 0x9186, 0x007f, 0x0150, 0x9186, 0x0080,
-	0x0138, 0x9186, 0x00ff, 0x0120, 0x0026, 0x2200, 0x0801, 0x002e,
-	0x001e, 0x8108, 0x1f04, 0x5372, 0x015e, 0x012e, 0x0005, 0x2001,
-	0x1854, 0x2004, 0x0005, 0x2001, 0x1873, 0x2004, 0x0005, 0x0006,
-	0x2001, 0x1810, 0x2004, 0xd0d4, 0x000e, 0x0005, 0x2001, 0x180e,
-	0x2004, 0xd0b4, 0x0005, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003,
-	0x0005, 0x0016, 0x00e6, 0x2071, 0x1894, 0x7108, 0x910d, 0x710a,
-	0x00ee, 0x001e, 0x0005, 0x79a4, 0x9182, 0x0081, 0x1a04, 0x336e,
-	0x810c, 0x0016, 0x080c, 0x4889, 0x080c, 0x0ef3, 0x2100, 0x2238,
-	0x7d84, 0x7c88, 0x7b8c, 0x7a90, 0x001e, 0x080c, 0x48d2, 0x701f,
-	0x53ca, 0x0005, 0x2079, 0x0000, 0x7d94, 0x7c98, 0x7ba8, 0x7aac,
-	0x79a4, 0x810c, 0x2061, 0x18ae, 0x2c44, 0xa770, 0xa074, 0x2071,
-	0x1894, 0x080c, 0x48d5, 0x701f, 0x53de, 0x0005, 0x2061, 0x18ae,
-	0x2c44, 0x0016, 0x0026, 0xa270, 0xa174, 0x080c, 0x0efb, 0x002e,
-	0x001e, 0x080c, 0x0fa8, 0x9006, 0xa802, 0xa806, 0x0804, 0x3339,
-	0x0126, 0x0156, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6,
-	0x00e6, 0x00f6, 0x2061, 0x0100, 0x2069, 0x0200, 0x2071, 0x1800,
-	0x6044, 0xd0a4, 0x11e8, 0xd084, 0x0118, 0x080c, 0x5599, 0x0068,
-	0xd08c, 0x0118, 0x080c, 0x54a2, 0x0040, 0xd094, 0x0118, 0x080c,
-	0x5472, 0x0018, 0xd09c, 0x0108, 0x0099, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x012e, 0x0005,
-	0x0016, 0x6128, 0xd19c, 0x1110, 0xc19d, 0x612a, 0x001e, 0x0c68,
-	0x0006, 0x7094, 0x9005, 0x000e, 0x0120, 0x7097, 0x0000, 0x708f,
-	0x0000, 0x624c, 0x9286, 0xf0f0, 0x1150, 0x6048, 0x9086, 0xf0f0,
-	0x0130, 0x624a, 0x6043, 0x0090, 0x6043, 0x0010, 0x0490, 0x9294,
-	0xff00, 0x9296, 0xf700, 0x0178, 0x7138, 0xd1a4, 0x1160, 0x6240,
-	0x9295, 0x0100, 0x6242, 0x9294, 0x0010, 0x0128, 0x2009, 0x00f7,
-	0x080c, 0x5c56, 0x00f0, 0x6040, 0x9084, 0x0010, 0x9085, 0x0140,
-	0x6042, 0x6043, 0x0000, 0x7083, 0x0000, 0x709f, 0x0001, 0x70c3,
-	0x0000, 0x70db, 0x0000, 0x2009, 0x1c80, 0x200b, 0x0000, 0x7093,
-	0x0000, 0x7087, 0x000f, 0x2009, 0x000f, 0x2011, 0x5b3c, 0x080c,
-	0x80b3, 0x0005, 0x2001, 0x1875, 0x2004, 0xd08c, 0x0110, 0x705b,
-	0xffff, 0x7084, 0x9005, 0x1528, 0x2011, 0x5b3c, 0x080c, 0x8021,
-	0x6040, 0x9094, 0x0010, 0x9285, 0x0020, 0x6042, 0x20a9, 0x00c8,
-	0x6044, 0xd08c, 0x1168, 0x1f04, 0x5488, 0x6242, 0x7097, 0x0000,
-	0x6040, 0x9094, 0x0010, 0x9285, 0x0080, 0x6042, 0x6242, 0x0048,
-	0x6242, 0x7097, 0x0000, 0x708b, 0x0000, 0x9006, 0x080c, 0x5cdf,
-	0x0000, 0x0005, 0x7088, 0x908a, 0x0003, 0x1a0c, 0x0db4, 0x000b,
-	0x0005, 0x54ac, 0x54fd, 0x5598, 0x00f6, 0x0016, 0x6900, 0x918c,
-	0x0800, 0x708b, 0x0001, 0x2001, 0x015d, 0x2003, 0x0000, 0x6803,
-	0x00fc, 0x20a9, 0x0004, 0x6800, 0x9084, 0x00fc, 0x0120, 0x1f04,
-	0x54bb, 0x080c, 0x0db4, 0x68a0, 0x68a2, 0x689c, 0x689e, 0x6898,
-	0x689a, 0xa001, 0x918d, 0x1600, 0x6902, 0x001e, 0x6837, 0x0020,
-	0x080c, 0x5cbb, 0x2079, 0x1c00, 0x7833, 0x1101, 0x7837, 0x0000,
-	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0001, 0x20a1, 0x1c0e,
-	0x20a9, 0x0004, 0x4003, 0x080c, 0x9c4a, 0x20e1, 0x0001, 0x2099,
-	0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x0014, 0x4003,
-	0x60c3, 0x000c, 0x600f, 0x0000, 0x080c, 0x5b6d, 0x00fe, 0x9006,
-	0x708e, 0x6043, 0x0008, 0x6042, 0x0005, 0x00f6, 0x708c, 0x708f,
-	0x0000, 0x9025, 0x0904, 0x5575, 0x6020, 0xd0b4, 0x1904, 0x5573,
-	0x719c, 0x81ff, 0x0904, 0x5561, 0x9486, 0x000c, 0x1904, 0x556e,
-	0x9480, 0x0018, 0x8004, 0x20a8, 0x080c, 0x5cb4, 0x2011, 0x0260,
-	0x2019, 0x1c00, 0x220c, 0x2304, 0x9106, 0x11e8, 0x8210, 0x8318,
-	0x1f04, 0x551a, 0x6043, 0x0004, 0x2061, 0x0140, 0x605b, 0xbc94,
-	0x605f, 0xf0f0, 0x2061, 0x0100, 0x6043, 0x0006, 0x708b, 0x0002,
-	0x7097, 0x0002, 0x2009, 0x07d0, 0x2011, 0x5b43, 0x080c, 0x80b3,
-	0x080c, 0x5cbb, 0x04c0, 0x080c, 0x5cb4, 0x2079, 0x0260, 0x7930,
-	0x918e, 0x1101, 0x1558, 0x7834, 0x9005, 0x1540, 0x7900, 0x918c,
-	0x00ff, 0x1118, 0x7804, 0x9005, 0x0190, 0x080c, 0x5cb4, 0x2011,
-	0x026e, 0x2019, 0x1805, 0x20a9, 0x0004, 0x220c, 0x2304, 0x9102,
-	0x0230, 0x11a0, 0x8210, 0x8318, 0x1f04, 0x5555, 0x0078, 0x709f,
-	0x0000, 0x080c, 0x5cb4, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9,
-	0x0001, 0x20a1, 0x1c00, 0x20a9, 0x0014, 0x4003, 0x6043, 0x0008,
-	0x6043, 0x0000, 0x0010, 0x00fe, 0x0005, 0x6040, 0x9085, 0x0100,
-	0x6042, 0x6020, 0xd0b4, 0x1db8, 0x080c, 0x9c4a, 0x20e1, 0x0001,
-	0x2099, 0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x0014,
-	0x4003, 0x60c3, 0x000c, 0x2011, 0x19c1, 0x2013, 0x0000, 0x708f,
-	0x0000, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0x93a4, 0x08d8,
-	0x0005, 0x7094, 0x908a, 0x001d, 0x1a0c, 0x0db4, 0x000b, 0x0005,
-	0x55ca, 0x55dd, 0x5606, 0x5626, 0x564c, 0x567b, 0x56a1, 0x56d9,
-	0x56ff, 0x572d, 0x5768, 0x57a0, 0x57be, 0x57e9, 0x580b, 0x5826,
-	0x5830, 0x5864, 0x588a, 0x58b9, 0x58df, 0x5917, 0x595b, 0x5998,
-	0x59b9, 0x5a12, 0x5a34, 0x5a62, 0x5a62, 0x00c6, 0x2061, 0x1800,
-	0x6003, 0x0007, 0x2061, 0x0100, 0x6004, 0x9084, 0xfff9, 0x6006,
-	0x00ce, 0x0005, 0x2061, 0x0140, 0x605b, 0xbc94, 0x605f, 0xf0f0,
-	0x2061, 0x0100, 0x6043, 0x0002, 0x7097, 0x0001, 0x2009, 0x07d0,
-	0x2011, 0x5b43, 0x080c, 0x80b3, 0x0005, 0x00f6, 0x708c, 0x9086,
-	0x0014, 0x1510, 0x6042, 0x6020, 0xd0b4, 0x11f0, 0x080c, 0x5cb4,
-	0x2079, 0x0260, 0x7a30, 0x9296, 0x1102, 0x11a0, 0x7834, 0x9005,
-	0x1188, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3,
-	0x0001, 0x2011, 0x5b43, 0x080c, 0x8021, 0x7097, 0x0010, 0x080c,
-	0x5830, 0x0010, 0x708f, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x7097,
-	0x0003, 0x6043, 0x0004, 0x2011, 0x5b43, 0x080c, 0x8021, 0x080c,
-	0x5c38, 0x2079, 0x0240, 0x7833, 0x1102, 0x7837, 0x0000, 0x20a9,
-	0x0008, 0x9f88, 0x000e, 0x200b, 0x0000, 0x8108, 0x1f04, 0x561b,
-	0x60c3, 0x0014, 0x080c, 0x5b6d, 0x00fe, 0x0005, 0x00f6, 0x708c,
-	0x9005, 0x0500, 0x2011, 0x5b43, 0x080c, 0x8021, 0x9086, 0x0014,
-	0x11b8, 0x080c, 0x5cb4, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102,
-	0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c0,
-	0x9005, 0x1110, 0x70c3, 0x0001, 0x7097, 0x0004, 0x0029, 0x0010,
-	0x080c, 0x5c90, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x0005, 0x080c,
-	0x5c38, 0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000, 0x080c,
-	0x5cb4, 0x080c, 0x5c97, 0x1170, 0x7080, 0x9005, 0x1158, 0x7158,
-	0x9186, 0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5af0, 0x0168,
-	0x080c, 0x5c6d, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e,
-	0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c,
-	0x5b6d, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500, 0x2011,
-	0x5b43, 0x080c, 0x8021, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5cb4,
-	0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178, 0x7834, 0x9005,
-	0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3,
-	0x0001, 0x7097, 0x0006, 0x0029, 0x0010, 0x080c, 0x5c90, 0x00fe,
-	0x0005, 0x00f6, 0x7097, 0x0007, 0x080c, 0x5c38, 0x2079, 0x0240,
-	0x7833, 0x1104, 0x7837, 0x0000, 0x080c, 0x5cb4, 0x080c, 0x5c97,
-	0x11b8, 0x7080, 0x9005, 0x11a0, 0x7160, 0x9186, 0xffff, 0x0180,
-	0x9180, 0x313a, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011, 0x0008,
-	0x080c, 0x5af0, 0x0180, 0x080c, 0x4ca1, 0x0110, 0x080c, 0x26ce,
-	0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000,
-	0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b6d, 0x00fe,
-	0x0005, 0x00f6, 0x708c, 0x9005, 0x0500, 0x2011, 0x5b43, 0x080c,
-	0x8021, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5cb4, 0x2079, 0x0260,
-	0x7a30, 0x9296, 0x1104, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38,
-	0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x7097,
-	0x0008, 0x0029, 0x0010, 0x080c, 0x5c90, 0x00fe, 0x0005, 0x00f6,
-	0x7097, 0x0009, 0x080c, 0x5c38, 0x2079, 0x0240, 0x7833, 0x1105,
-	0x7837, 0x0100, 0x080c, 0x5c97, 0x1150, 0x7080, 0x9005, 0x1138,
-	0x080c, 0x5a63, 0x1188, 0x9085, 0x0001, 0x080c, 0x26ce, 0x20a9,
-	0x0008, 0x080c, 0x5cb4, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
-	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b6d,
-	0x0010, 0x080c, 0x55bd, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005,
-	0x05a8, 0x2011, 0x5b43, 0x080c, 0x8021, 0x9086, 0x0014, 0x1560,
-	0x080c, 0x5cb4, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1105, 0x1520,
-	0x7834, 0x9084, 0x0100, 0x2011, 0x0100, 0x921e, 0x1160, 0x7a38,
+	0x0800, 0x0120, 0x9386, 0x003c, 0x01e8, 0x0c20, 0x83ff, 0x11c0,
+	0x7254, 0x900e, 0x2001, 0x0003, 0x080c, 0x8277, 0x2208, 0x009e,
+	0xa897, 0x4000, 0xa99a, 0x715c, 0x81ff, 0x090c, 0x0db4, 0x2148,
+	0x080c, 0x101d, 0x9006, 0x705e, 0x918d, 0x0001, 0x2008, 0x0418,
+	0x7063, 0x0001, 0x7152, 0x7054, 0x9300, 0x7056, 0x2061, 0x18b7,
+	0x2c44, 0xa37a, 0x7058, 0xa076, 0x7064, 0xa072, 0xa48e, 0xa592,
+	0xa696, 0xa79a, 0xa09f, 0x4dc6, 0x000e, 0xa0a2, 0x080c, 0x10d5,
+	0x9006, 0x0048, 0x009e, 0xa897, 0x4005, 0xa99a, 0x900e, 0x9085,
+	0x0001, 0x2001, 0x0030, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0xa0a0,
+	0x904d, 0x090c, 0x0db4, 0x00e6, 0x2071, 0x189c, 0xa06c, 0x908e,
+	0x0100, 0x0138, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002,
+	0x00d8, 0x7060, 0x9005, 0x1158, 0x7150, 0x7058, 0x20a0, 0x901e,
+	0x7064, 0x20e8, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0428, 0xa87b,
+	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x7254, 0x900e, 0x2001,
+	0x0003, 0x080c, 0x8277, 0xaa9a, 0x715c, 0x81ff, 0x090c, 0x0db4,
+	0x2148, 0x080c, 0x101d, 0x705f, 0x0000, 0xa0a0, 0x2048, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x68a0, 0x012e, 0xa09f, 0x0000, 0xa0a3,
+	0x0000, 0x00ee, 0x00fe, 0x0005, 0x91d8, 0x1000, 0x2b5c, 0x8bff,
+	0x0178, 0x080c, 0x657a, 0x0118, 0x080c, 0x6582, 0x1148, 0xb814,
+	0x20a9, 0x0001, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003,
+	0x8108, 0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x0518, 0x0c20,
+	0x83ff, 0x11f0, 0x7154, 0x810c, 0xa99a, 0xa897, 0x4000, 0x715c,
+	0x81ff, 0x090c, 0x0db4, 0x2148, 0x080c, 0x101d, 0x9006, 0x705e,
+	0x918d, 0x0001, 0x2008, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x68a0, 0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x0070,
+	0x7063, 0x0001, 0x7152, 0x7054, 0x9300, 0x7056, 0xa37a, 0xa48e,
+	0xa592, 0xa696, 0xa79a, 0x080c, 0x10d5, 0x9006, 0x00ee, 0x0005,
+	0x0096, 0xa88c, 0x90be, 0x7000, 0x0148, 0x90be, 0x7100, 0x0130,
+	0x90be, 0x7200, 0x0118, 0x009e, 0x0804, 0x3379, 0xa884, 0xa988,
+	0x080c, 0x2670, 0x1518, 0x080c, 0x61f6, 0x1500, 0x7126, 0xbe12,
+	0xbd16, 0xae7c, 0x080c, 0x4894, 0x01c8, 0x080c, 0x4894, 0x01b0,
+	0x009e, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0xa823, 0x0000,
+	0xa804, 0x2048, 0x080c, 0xbce5, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x3376, 0x7007, 0x0003, 0x701f, 0x4e93, 0x0005, 0x009e, 0x2009,
+	0x0002, 0x0804, 0x3376, 0x7124, 0x080c, 0x30e2, 0xa820, 0x9086,
+	0x8001, 0x1120, 0x2009, 0x0004, 0x0804, 0x3376, 0x2900, 0x7022,
+	0xa804, 0x0096, 0x2048, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
+	0x9084, 0xffc0, 0x009e, 0x9080, 0x0002, 0x0076, 0x0006, 0x2098,
+	0x20a0, 0x27e0, 0x27e8, 0x20a9, 0x002a, 0x080c, 0x0f68, 0xaa6c,
+	0xab70, 0xac74, 0xad78, 0x2061, 0x18b6, 0x2c44, 0xa06b, 0x0000,
+	0xae64, 0xaf8c, 0x97c6, 0x7000, 0x0118, 0x97c6, 0x7100, 0x1148,
+	0x96c2, 0x0004, 0x0600, 0x2009, 0x0004, 0x000e, 0x007e, 0x0804,
+	0x48e0, 0x97c6, 0x7200, 0x11b8, 0x96c2, 0x0054, 0x02a0, 0x000e,
+	0x007e, 0x2061, 0x18b6, 0x2c44, 0xa076, 0xa772, 0xa07b, 0x002a,
+	0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10d5, 0x7007, 0x0002,
+	0x701f, 0x4eef, 0x0005, 0x000e, 0x007e, 0x0804, 0x3379, 0x7020,
+	0x2048, 0xa804, 0x2048, 0xa804, 0x2048, 0x8906, 0x8006, 0x8007,
+	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2098, 0x20a0,
+	0x27e0, 0x27e8, 0x20a9, 0x002a, 0x080c, 0x0f68, 0x2100, 0x2238,
+	0x2061, 0x18b6, 0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x2009,
+	0x002a, 0x0804, 0x48e0, 0x81ff, 0x1904, 0x3376, 0x798c, 0x2001,
+	0x1956, 0x918c, 0x8000, 0x2102, 0x080c, 0x48ab, 0x0904, 0x3379,
+	0x080c, 0x657a, 0x0120, 0x080c, 0x6582, 0x1904, 0x3379, 0x080c,
+	0x631d, 0x0904, 0x3376, 0x0126, 0x2091, 0x8000, 0x080c, 0x63e3,
+	0x012e, 0x0904, 0x3376, 0x2001, 0x1956, 0x2004, 0xd0fc, 0x1904,
+	0x3344, 0x0804, 0x4319, 0xa9a0, 0x2001, 0x1956, 0x918c, 0x8000,
+	0xc18d, 0x2102, 0x080c, 0x48b8, 0x01a0, 0x080c, 0x657a, 0x0118,
+	0x080c, 0x6582, 0x1170, 0x080c, 0x631d, 0x2009, 0x0002, 0x0128,
+	0x080c, 0x63e3, 0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a,
+	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
+	0x0005, 0xa897, 0x4000, 0x2001, 0x1956, 0x2004, 0xd0fc, 0x1128,
+	0x080c, 0x53a2, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001,
+	0x2001, 0x0000, 0x0005, 0x78a8, 0xd08c, 0x1118, 0xd084, 0x0904,
+	0x428e, 0x080c, 0x48c7, 0x0904, 0x3379, 0x080c, 0x4894, 0x1120,
+	0x2009, 0x0002, 0x0804, 0x3376, 0x080c, 0x657a, 0x0130, 0x908e,
+	0x0004, 0x0118, 0x908e, 0x0005, 0x15a0, 0x78a8, 0xd08c, 0x0120,
+	0xb800, 0xc08c, 0xb802, 0x0028, 0x080c, 0x539a, 0xd0b4, 0x0904,
+	0x42c8, 0x7884, 0x908e, 0x007e, 0x0904, 0x42c8, 0x908e, 0x007f,
+	0x0904, 0x42c8, 0x908e, 0x0080, 0x0904, 0x42c8, 0xb800, 0xd08c,
+	0x1904, 0x42c8, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c,
+	0xbd04, 0x1120, 0x2009, 0x0003, 0x0804, 0x3376, 0x7007, 0x0003,
+	0x701f, 0x4fbb, 0x0005, 0x080c, 0x48c7, 0x0904, 0x3379, 0x0804,
+	0x42c8, 0x080c, 0x313b, 0x0108, 0x0005, 0x2009, 0x1833, 0x210c,
+	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3376, 0x080c, 0x53ae,
+	0x0120, 0x2009, 0x0007, 0x0804, 0x3376, 0x080c, 0x6572, 0x0120,
+	0x2009, 0x0008, 0x0804, 0x3376, 0xb89c, 0xd0a4, 0x1118, 0xd0ac,
+	0x1904, 0x42c8, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
+	0x080c, 0xbd63, 0x1120, 0x2009, 0x0003, 0x0804, 0x3376, 0x7007,
+	0x0003, 0x701f, 0x4ff4, 0x0005, 0xa830, 0x9086, 0x0100, 0x1120,
+	0x2009, 0x0004, 0x0804, 0x52f7, 0x080c, 0x48c7, 0x0904, 0x3379,
+	0x0804, 0x4f8d, 0x81ff, 0x2009, 0x0001, 0x1904, 0x3376, 0x080c,
+	0x53ae, 0x2009, 0x0007, 0x1904, 0x3376, 0x080c, 0x6572, 0x0120,
+	0x2009, 0x0008, 0x0804, 0x3376, 0x080c, 0x48c7, 0x0904, 0x3379,
+	0x080c, 0x657a, 0x2009, 0x0009, 0x1904, 0x3376, 0x080c, 0x4894,
+	0x2009, 0x0002, 0x0904, 0x3376, 0x9006, 0xa866, 0xa832, 0xa868,
+	0xc0fd, 0xa86a, 0x7988, 0x9194, 0xff00, 0x918c, 0x00ff, 0x9006,
+	0x82ff, 0x1128, 0xc0ed, 0xa952, 0x798c, 0xa956, 0x0038, 0x928e,
+	0x0100, 0x1904, 0x3379, 0xc0e5, 0xa952, 0xa956, 0xa83e, 0x080c,
+	0xbfb6, 0x2009, 0x0003, 0x0904, 0x3376, 0x7007, 0x0003, 0x701f,
+	0x504a, 0x0005, 0xa830, 0x9086, 0x0100, 0x2009, 0x0004, 0x0904,
+	0x3376, 0x0804, 0x3344, 0x7aa8, 0x9284, 0xc000, 0x0148, 0xd2ec,
+	0x01a0, 0x080c, 0x53ae, 0x1188, 0x2009, 0x0014, 0x0804, 0x3376,
+	0xd2dc, 0x1568, 0x81ff, 0x2009, 0x0001, 0x1904, 0x3376, 0x080c,
+	0x53ae, 0x2009, 0x0007, 0x1904, 0x3376, 0xd2f4, 0x0130, 0x9284,
+	0x5000, 0x080c, 0x5375, 0x0804, 0x3344, 0xd2fc, 0x0158, 0x080c,
+	0x48c7, 0x0904, 0x3379, 0x7984, 0x9284, 0x9000, 0x080c, 0x5352,
+	0x0804, 0x3344, 0x080c, 0x48c7, 0x0904, 0x3379, 0xb804, 0x9084,
+	0x00ff, 0x9086, 0x0006, 0x2009, 0x0009, 0x1904, 0x5133, 0x080c,
+	0x4894, 0x2009, 0x0002, 0x0904, 0x5133, 0xa85c, 0x9080, 0x001b,
+	0xaf60, 0x2009, 0x0008, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c,
+	0x48dd, 0x701f, 0x50a4, 0x0005, 0xa86c, 0x9086, 0x0500, 0x1138,
+	0xa870, 0x9005, 0x1120, 0xa874, 0x9084, 0xff00, 0x0110, 0x1904,
+	0x3379, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0x48c7,
+	0x1110, 0x0804, 0x3379, 0x2009, 0x0043, 0x080c, 0xc01e, 0x2009,
+	0x0003, 0x0904, 0x5133, 0x7007, 0x0003, 0x701f, 0x50c8, 0x0005,
+	0xa830, 0x9086, 0x0100, 0x2009, 0x0004, 0x0904, 0x5133, 0x7984,
+	0x7aa8, 0x9284, 0x1000, 0x080c, 0x5352, 0x0804, 0x3344, 0x00c6,
+	0xaab0, 0x9284, 0xc000, 0x0140, 0xd2ec, 0x0168, 0x080c, 0x53ae,
+	0x1150, 0x2009, 0x0014, 0x04f0, 0x2061, 0x1800, 0x080c, 0x53ae,
+	0x2009, 0x0007, 0x15b8, 0xd2f4, 0x0128, 0x9284, 0x5000, 0x080c,
+	0x5375, 0x0050, 0xd2fc, 0x0178, 0x080c, 0x48c5, 0x0588, 0xa998,
+	0x9284, 0x9000, 0x080c, 0x5352, 0xa87b, 0x0000, 0xa883, 0x0000,
+	0xa897, 0x4000, 0x0438, 0x080c, 0x48c5, 0x0510, 0x080c, 0x657a,
+	0x2009, 0x0009, 0x11b8, 0xa8c4, 0x9086, 0x0500, 0x11c8, 0xa8c8,
+	0x9005, 0x11b0, 0xa8cc, 0x9084, 0xff00, 0x1190, 0x080c, 0x48c5,
+	0x1108, 0x0070, 0x2009, 0x004b, 0x080c, 0xc01e, 0x2009, 0x0003,
+	0x0108, 0x0078, 0x0429, 0x19c0, 0xa897, 0x4005, 0xa99a, 0x0010,
+	0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x00ce,
+	0x0005, 0x9006, 0x0ce0, 0x7aa8, 0xd2dc, 0x0904, 0x3376, 0x0016,
+	0x7984, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x5352, 0x001e, 0x1904,
+	0x3376, 0x0804, 0x3344, 0x00f6, 0x2d78, 0x0011, 0x00fe, 0x0005,
+	0xaab0, 0xd2dc, 0x0150, 0x0016, 0xa998, 0x9284, 0x1000, 0xc0fd,
+	0x080c, 0x5352, 0x001e, 0x9085, 0x0001, 0x0005, 0x81ff, 0x0120,
+	0x2009, 0x0001, 0x0804, 0x3376, 0x080c, 0x53ae, 0x0120, 0x2009,
+	0x0007, 0x0804, 0x3376, 0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c,
+	0x6256, 0x1904, 0x3379, 0x9186, 0x007f, 0x0138, 0x080c, 0x657a,
+	0x0120, 0x2009, 0x0009, 0x0804, 0x3376, 0x080c, 0x4894, 0x1120,
+	0x2009, 0x0002, 0x0804, 0x3376, 0xa867, 0x0000, 0xa868, 0xc0fd,
+	0xa86a, 0x2001, 0x0100, 0x8007, 0xa80a, 0x080c, 0xbd1e, 0x1120,
+	0x2009, 0x0003, 0x0804, 0x3376, 0x7007, 0x0003, 0x701f, 0x5191,
+	0x0005, 0xa808, 0x8007, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004,
+	0x0804, 0x3376, 0xa8e0, 0xa866, 0xa810, 0x8007, 0x9084, 0x00ff,
+	0x800c, 0xa814, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0002,
+	0x9108, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
+	0x9080, 0x0004, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x48e0,
+	0x080c, 0x4894, 0x1120, 0x2009, 0x0002, 0x0804, 0x3376, 0x7984,
+	0x9194, 0xff00, 0x918c, 0x00ff, 0x8217, 0x82ff, 0x1118, 0x7023,
+	0x198b, 0x0040, 0x92c6, 0x0001, 0x1118, 0x7023, 0x19a5, 0x0010,
+	0x0804, 0x3379, 0x2009, 0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
+	0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x48dd, 0x701f, 0x51e1,
+	0x0005, 0x2001, 0x182d, 0x2003, 0x0001, 0xa85c, 0x9080, 0x0019,
+	0x2098, 0xa860, 0x20e0, 0x20a9, 0x001a, 0x7020, 0x20a0, 0x20e9,
+	0x0001, 0x4003, 0x0804, 0x3344, 0x080c, 0x4894, 0x1120, 0x2009,
+	0x0002, 0x0804, 0x3376, 0x7984, 0x9194, 0xff00, 0x918c, 0x00ff,
+	0x8217, 0x82ff, 0x1118, 0x2099, 0x198b, 0x0040, 0x92c6, 0x0001,
+	0x1118, 0x2099, 0x19a5, 0x0010, 0x0804, 0x3379, 0xa85c, 0x9080,
+	0x0019, 0x20a0, 0xa860, 0x20e8, 0x20a9, 0x001a, 0x20e1, 0x0001,
+	0x4003, 0x2009, 0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c,
+	0x9080, 0x0019, 0xaf60, 0x0804, 0x48e0, 0x7884, 0x908a, 0x1000,
+	0x1a04, 0x3379, 0x0126, 0x2091, 0x8000, 0x8003, 0x800b, 0x810b,
+	0x9108, 0x00c6, 0x2061, 0x19d2, 0x6142, 0x00ce, 0x012e, 0x0804,
+	0x3344, 0x00c6, 0x080c, 0x6faa, 0x1160, 0x080c, 0x728c, 0x080c,
+	0x5ce5, 0x9085, 0x0001, 0x080c, 0x6ff1, 0x080c, 0x6edc, 0x080c,
+	0x0db4, 0x2061, 0x1800, 0x6030, 0xc09d, 0x6032, 0x080c, 0x5ba4,
+	0x00ce, 0x0005, 0x00c6, 0x2001, 0x1800, 0x2004, 0x908e, 0x0000,
+	0x0904, 0x3376, 0x7884, 0x9005, 0x0188, 0x7888, 0x2061, 0x1974,
+	0x2c0c, 0x2062, 0x080c, 0x2a52, 0x01a0, 0x080c, 0x2a5a, 0x0188,
+	0x080c, 0x2a62, 0x0170, 0x2162, 0x0804, 0x3379, 0x2061, 0x0100,
+	0x6038, 0x9086, 0x0007, 0x1118, 0x2009, 0x0001, 0x0010, 0x2009,
+	0x0000, 0x7884, 0x9086, 0x0002, 0x1548, 0x2061, 0x0100, 0x6028,
+	0xc09c, 0x602a, 0x0026, 0x2011, 0x0003, 0x080c, 0x975b, 0x2011,
+	0x0002, 0x080c, 0x9765, 0x002e, 0x080c, 0x9673, 0x0036, 0x901e,
+	0x080c, 0x96e9, 0x003e, 0x60e3, 0x0000, 0x080c, 0xd8ee, 0x080c,
+	0xd909, 0x9085, 0x0001, 0x080c, 0x6ff1, 0x9006, 0x080c, 0x2b21,
+	0x2001, 0x1800, 0x2003, 0x0004, 0x6027, 0x0008, 0x00ce, 0x0804,
+	0x3344, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x3376, 0x080c,
+	0x53ae, 0x0120, 0x2009, 0x0007, 0x0804, 0x3376, 0x7984, 0x7ea8,
+	0x96b4, 0x00ff, 0x080c, 0x6256, 0x1904, 0x3379, 0x9186, 0x007f,
+	0x0138, 0x080c, 0x657a, 0x0120, 0x2009, 0x0009, 0x0804, 0x3376,
+	0x080c, 0x4894, 0x1120, 0x2009, 0x0002, 0x0804, 0x3376, 0xa867,
+	0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xbd21, 0x1120, 0x2009,
+	0x0003, 0x0804, 0x3376, 0x7007, 0x0003, 0x701f, 0x52e0, 0x0005,
+	0xa830, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x3376,
+	0xa8e0, 0xa866, 0xa834, 0x8007, 0x800c, 0xa85c, 0x9080, 0x000c,
+	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xaf60, 0x0804, 0x48e0, 0xa898,
+	0x9086, 0x000d, 0x1904, 0x3376, 0x2021, 0x4005, 0x0126, 0x2091,
+	0x8000, 0x0e04, 0x5304, 0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486,
+	0x4000, 0x0118, 0x7833, 0x0011, 0x0010, 0x7833, 0x0010, 0x7883,
+	0x4005, 0xa998, 0x7986, 0xa9a4, 0x799a, 0xa9a8, 0x799e, 0x080c,
+	0x48d0, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x1187, 0x7007, 0x0001, 0x2091, 0x5000, 0x700f, 0x0000, 0x012e,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x00c6, 0x2061, 0x19d2, 0x7984,
+	0x6152, 0x614e, 0x6057, 0x0000, 0x604b, 0x0009, 0x7898, 0x606a,
+	0x789c, 0x6066, 0x7888, 0x6062, 0x788c, 0x605e, 0x2001, 0x19e0,
+	0x2044, 0x2001, 0x19e7, 0xa076, 0xa060, 0xa072, 0xa07b, 0x0001,
+	0xa07f, 0x0002, 0xa06b, 0x0000, 0xa09f, 0x0000, 0x00ce, 0x012e,
+	0x0804, 0x3344, 0x0126, 0x2091, 0x8000, 0x00b6, 0x00c6, 0x90e4,
+	0xc000, 0x0128, 0x0006, 0x080c, 0xbb88, 0x000e, 0x1198, 0xd0e4,
+	0x0160, 0x9180, 0x1000, 0x2004, 0x905d, 0x0160, 0x080c, 0x5cff,
+	0x080c, 0x9dae, 0x0110, 0xb817, 0x0000, 0x9006, 0x00ce, 0x00be,
+	0x012e, 0x0005, 0x9085, 0x0001, 0x0cc8, 0x0126, 0x2091, 0x8000,
+	0x0156, 0x2010, 0x900e, 0x20a9, 0x0800, 0x0016, 0x9180, 0x1000,
+	0x2004, 0x9005, 0x0180, 0x9186, 0x007e, 0x0168, 0x9186, 0x007f,
+	0x0150, 0x9186, 0x0080, 0x0138, 0x9186, 0x00ff, 0x0120, 0x0026,
+	0x2200, 0x0801, 0x002e, 0x001e, 0x8108, 0x1f04, 0x537d, 0x015e,
+	0x012e, 0x0005, 0x2001, 0x185c, 0x2004, 0x0005, 0x2001, 0x187b,
+	0x2004, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0d4, 0x000e,
+	0x0005, 0x2001, 0x180e, 0x2004, 0xd0b4, 0x0005, 0x2001, 0x1800,
+	0x2004, 0x9086, 0x0003, 0x0005, 0x0016, 0x00e6, 0x2071, 0x189c,
+	0x7108, 0x910d, 0x710a, 0x00ee, 0x001e, 0x0005, 0x79a4, 0x9182,
+	0x0081, 0x1a04, 0x3379, 0x810c, 0x0016, 0x080c, 0x4894, 0x080c,
+	0x0ef3, 0x2100, 0x2238, 0x7d84, 0x7c88, 0x7b8c, 0x7a90, 0x001e,
+	0x080c, 0x48dd, 0x701f, 0x53d5, 0x0005, 0x2079, 0x0000, 0x7d94,
+	0x7c98, 0x7ba8, 0x7aac, 0x79a4, 0x810c, 0x2061, 0x18b6, 0x2c44,
+	0xa770, 0xa074, 0x2071, 0x189c, 0x080c, 0x48e0, 0x701f, 0x53e9,
+	0x0005, 0x2061, 0x18b6, 0x2c44, 0x0016, 0x0026, 0xa270, 0xa174,
+	0x080c, 0x0efb, 0x002e, 0x001e, 0x080c, 0x0fa8, 0x9006, 0xa802,
+	0xa806, 0x0804, 0x3344, 0x0126, 0x0156, 0x0136, 0x0146, 0x01c6,
+	0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2061, 0x0100, 0x2069,
+	0x0200, 0x2071, 0x1800, 0x6044, 0xd0a4, 0x11e8, 0xd084, 0x0118,
+	0x080c, 0x55a4, 0x0068, 0xd08c, 0x0118, 0x080c, 0x54ad, 0x0040,
+	0xd094, 0x0118, 0x080c, 0x547d, 0x0018, 0xd09c, 0x0108, 0x0099,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e,
+	0x015e, 0x012e, 0x0005, 0x0016, 0x6128, 0xd19c, 0x1110, 0xc19d,
+	0x612a, 0x001e, 0x0c68, 0x0006, 0x7094, 0x9005, 0x000e, 0x0120,
+	0x7097, 0x0000, 0x708f, 0x0000, 0x624c, 0x9286, 0xf0f0, 0x1150,
+	0x6048, 0x9086, 0xf0f0, 0x0130, 0x624a, 0x6043, 0x0090, 0x6043,
+	0x0010, 0x0490, 0x9294, 0xff00, 0x9296, 0xf700, 0x0178, 0x7138,
+	0xd1a4, 0x1160, 0x6240, 0x9295, 0x0100, 0x6242, 0x9294, 0x0010,
+	0x0128, 0x2009, 0x00f7, 0x080c, 0x5c61, 0x00f0, 0x6040, 0x9084,
+	0x0010, 0x9085, 0x0140, 0x6042, 0x6043, 0x0000, 0x7083, 0x0000,
+	0x709f, 0x0001, 0x70c3, 0x0000, 0x70db, 0x0000, 0x2009, 0x1c80,
+	0x200b, 0x0000, 0x7093, 0x0000, 0x7087, 0x000f, 0x2009, 0x000f,
+	0x2011, 0x5b47, 0x080c, 0x80d1, 0x0005, 0x2001, 0x187d, 0x2004,
+	0xd08c, 0x0110, 0x705b, 0xffff, 0x7084, 0x9005, 0x1528, 0x2011,
+	0x5b47, 0x080c, 0x803f, 0x6040, 0x9094, 0x0010, 0x9285, 0x0020,
+	0x6042, 0x20a9, 0x00c8, 0x6044, 0xd08c, 0x1168, 0x1f04, 0x5493,
+	0x6242, 0x7097, 0x0000, 0x6040, 0x9094, 0x0010, 0x9285, 0x0080,
+	0x6042, 0x6242, 0x0048, 0x6242, 0x7097, 0x0000, 0x708b, 0x0000,
+	0x9006, 0x080c, 0x5cea, 0x0000, 0x0005, 0x7088, 0x908a, 0x0003,
+	0x1a0c, 0x0db4, 0x000b, 0x0005, 0x54b7, 0x5508, 0x55a3, 0x00f6,
+	0x0016, 0x6900, 0x918c, 0x0800, 0x708b, 0x0001, 0x2001, 0x015d,
+	0x2003, 0x0000, 0x6803, 0x00fc, 0x20a9, 0x0004, 0x6800, 0x9084,
+	0x00fc, 0x0120, 0x1f04, 0x54c6, 0x080c, 0x0db4, 0x68a0, 0x68a2,
+	0x689c, 0x689e, 0x6898, 0x689a, 0xa001, 0x918d, 0x1600, 0x6902,
+	0x001e, 0x6837, 0x0020, 0x080c, 0x5cc6, 0x2079, 0x1c00, 0x7833,
+	0x1101, 0x7837, 0x0000, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9,
+	0x0001, 0x20a1, 0x1c0e, 0x20a9, 0x0004, 0x4003, 0x080c, 0x9c37,
+	0x20e1, 0x0001, 0x2099, 0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240,
+	0x20a9, 0x0014, 0x4003, 0x60c3, 0x000c, 0x600f, 0x0000, 0x080c,
+	0x5b78, 0x00fe, 0x9006, 0x708e, 0x6043, 0x0008, 0x6042, 0x0005,
+	0x00f6, 0x708c, 0x708f, 0x0000, 0x9025, 0x0904, 0x5580, 0x6020,
+	0xd0b4, 0x1904, 0x557e, 0x719c, 0x81ff, 0x0904, 0x556c, 0x9486,
+	0x000c, 0x1904, 0x5579, 0x9480, 0x0018, 0x8004, 0x20a8, 0x080c,
+	0x5cbf, 0x2011, 0x0260, 0x2019, 0x1c00, 0x220c, 0x2304, 0x9106,
+	0x11e8, 0x8210, 0x8318, 0x1f04, 0x5525, 0x6043, 0x0004, 0x2061,
+	0x0140, 0x605b, 0xbc94, 0x605f, 0xf0f0, 0x2061, 0x0100, 0x6043,
+	0x0006, 0x708b, 0x0002, 0x7097, 0x0002, 0x2009, 0x07d0, 0x2011,
+	0x5b4e, 0x080c, 0x80d1, 0x080c, 0x5cc6, 0x04c0, 0x080c, 0x5cbf,
+	0x2079, 0x0260, 0x7930, 0x918e, 0x1101, 0x1558, 0x7834, 0x9005,
+	0x1540, 0x7900, 0x918c, 0x00ff, 0x1118, 0x7804, 0x9005, 0x0190,
+	0x080c, 0x5cbf, 0x2011, 0x026e, 0x2019, 0x1805, 0x20a9, 0x0004,
+	0x220c, 0x2304, 0x9102, 0x0230, 0x11a0, 0x8210, 0x8318, 0x1f04,
+	0x5560, 0x0078, 0x709f, 0x0000, 0x080c, 0x5cbf, 0x20e1, 0x0000,
+	0x2099, 0x0260, 0x20e9, 0x0001, 0x20a1, 0x1c00, 0x20a9, 0x0014,
+	0x4003, 0x6043, 0x0008, 0x6043, 0x0000, 0x0010, 0x00fe, 0x0005,
+	0x6040, 0x9085, 0x0100, 0x6042, 0x6020, 0xd0b4, 0x1db8, 0x080c,
+	0x9c37, 0x20e1, 0x0001, 0x2099, 0x1c00, 0x20e9, 0x0000, 0x20a1,
+	0x0240, 0x20a9, 0x0014, 0x4003, 0x60c3, 0x000c, 0x2011, 0x19c9,
+	0x2013, 0x0000, 0x708f, 0x0000, 0x60a3, 0x0056, 0x60a7, 0x9575,
+	0x080c, 0x93be, 0x08d8, 0x0005, 0x7094, 0x908a, 0x001d, 0x1a0c,
+	0x0db4, 0x000b, 0x0005, 0x55d5, 0x55e8, 0x5611, 0x5631, 0x5657,
+	0x5686, 0x56ac, 0x56e4, 0x570a, 0x5738, 0x5773, 0x57ab, 0x57c9,
+	0x57f4, 0x5816, 0x5831, 0x583b, 0x586f, 0x5895, 0x58c4, 0x58ea,
+	0x5922, 0x5966, 0x59a3, 0x59c4, 0x5a1d, 0x5a3f, 0x5a6d, 0x5a6d,
+	0x00c6, 0x2061, 0x1800, 0x6003, 0x0007, 0x2061, 0x0100, 0x6004,
+	0x9084, 0xfff9, 0x6006, 0x00ce, 0x0005, 0x2061, 0x0140, 0x605b,
+	0xbc94, 0x605f, 0xf0f0, 0x2061, 0x0100, 0x6043, 0x0002, 0x7097,
+	0x0001, 0x2009, 0x07d0, 0x2011, 0x5b4e, 0x080c, 0x80d1, 0x0005,
+	0x00f6, 0x708c, 0x9086, 0x0014, 0x1510, 0x6042, 0x6020, 0xd0b4,
+	0x11f0, 0x080c, 0x5cbf, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102,
+	0x11a0, 0x7834, 0x9005, 0x1188, 0x7a38, 0xd2fc, 0x0128, 0x70c0,
+	0x9005, 0x1110, 0x70c3, 0x0001, 0x2011, 0x5b4e, 0x080c, 0x803f,
+	0x7097, 0x0010, 0x080c, 0x583b, 0x0010, 0x708f, 0x0000, 0x00fe,
+	0x0005, 0x00f6, 0x7097, 0x0003, 0x6043, 0x0004, 0x2011, 0x5b4e,
+	0x080c, 0x803f, 0x080c, 0x5c43, 0x2079, 0x0240, 0x7833, 0x1102,
+	0x7837, 0x0000, 0x20a9, 0x0008, 0x9f88, 0x000e, 0x200b, 0x0000,
+	0x8108, 0x1f04, 0x5626, 0x60c3, 0x0014, 0x080c, 0x5b78, 0x00fe,
+	0x0005, 0x00f6, 0x708c, 0x9005, 0x0500, 0x2011, 0x5b4e, 0x080c,
+	0x803f, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5cbf, 0x2079, 0x0260,
+	0x7a30, 0x9296, 0x1102, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38,
 	0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x7097,
-	0x000a, 0x00b1, 0x0098, 0x9005, 0x1178, 0x7a38, 0xd2fc, 0x0128,
-	0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x7093, 0x0000, 0x7097,
-	0x000e, 0x080c, 0x580b, 0x0010, 0x080c, 0x5c90, 0x00fe, 0x0005,
-	0x00f6, 0x7097, 0x000b, 0x2011, 0x1c0e, 0x20e9, 0x0001, 0x22a0,
-	0x20a9, 0x0040, 0x2019, 0xffff, 0x4304, 0x080c, 0x5c38, 0x2079,
-	0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x5c97, 0x0118,
-	0x2013, 0x0000, 0x0020, 0x705c, 0x9085, 0x0100, 0x2012, 0x20a9,
-	0x0040, 0x2009, 0x024e, 0x2011, 0x1c0e, 0x220e, 0x8210, 0x8108,
-	0x9186, 0x0260, 0x1128, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240,
-	0x1f04, 0x578d, 0x60c3, 0x0084, 0x080c, 0x5b6d, 0x00fe, 0x0005,
-	0x00f6, 0x708c, 0x9005, 0x01c0, 0x2011, 0x5b43, 0x080c, 0x8021,
-	0x9086, 0x0084, 0x1178, 0x080c, 0x5cb4, 0x2079, 0x0260, 0x7a30,
-	0x9296, 0x1106, 0x1138, 0x7834, 0x9005, 0x1120, 0x7097, 0x000c,
-	0x0029, 0x0010, 0x080c, 0x5c90, 0x00fe, 0x0005, 0x00f6, 0x7097,
-	0x000d, 0x080c, 0x5c38, 0x2079, 0x0240, 0x7833, 0x1107, 0x7837,
-	0x0000, 0x080c, 0x5cb4, 0x20a9, 0x0040, 0x2011, 0x026e, 0x2009,
-	0x024e, 0x220e, 0x8210, 0x8108, 0x9186, 0x0260, 0x1150, 0x6810,
-	0x8000, 0x6812, 0x2009, 0x0240, 0x6814, 0x8000, 0x6816, 0x2011,
-	0x0260, 0x1f04, 0x57d1, 0x60c3, 0x0084, 0x080c, 0x5b6d, 0x00fe,
-	0x0005, 0x00f6, 0x708c, 0x9005, 0x01e0, 0x2011, 0x5b43, 0x080c,
-	0x8021, 0x9086, 0x0084, 0x1198, 0x080c, 0x5cb4, 0x2079, 0x0260,
-	0x7a30, 0x9296, 0x1107, 0x1158, 0x7834, 0x9005, 0x1140, 0x7093,
-	0x0001, 0x080c, 0x5c0a, 0x7097, 0x000e, 0x0029, 0x0010, 0x080c,
-	0x5c90, 0x00fe, 0x0005, 0x918d, 0x0001, 0x080c, 0x5cdf, 0x7097,
-	0x000f, 0x708f, 0x0000, 0x2061, 0x0140, 0x605b, 0xbc85, 0x605f,
-	0xb5b5, 0x2061, 0x0100, 0x6043, 0x0005, 0x6043, 0x0004, 0x2009,
-	0x07d0, 0x2011, 0x5b43, 0x080c, 0x8015, 0x0005, 0x708c, 0x9005,
-	0x0130, 0x2011, 0x5b43, 0x080c, 0x8021, 0x7097, 0x0000, 0x0005,
-	0x7097, 0x0011, 0x080c, 0x9c4a, 0x080c, 0x5cb4, 0x20e1, 0x0000,
-	0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x748c, 0x9480,
-	0x0018, 0x9080, 0x0007, 0x9084, 0x03f8, 0x8004, 0x20a8, 0x4003,
-	0x080c, 0x5c97, 0x11a0, 0x7178, 0x81ff, 0x0188, 0x900e, 0x707c,
-	0x9084, 0x00ff, 0x0160, 0x080c, 0x2665, 0x9186, 0x007e, 0x0138,
-	0x9186, 0x0080, 0x0120, 0x2011, 0x0008, 0x080c, 0x5af0, 0x60c3,
-	0x0014, 0x080c, 0x5b6d, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500,
-	0x2011, 0x5b43, 0x080c, 0x8021, 0x9086, 0x0014, 0x11b8, 0x080c,
-	0x5cb4, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178, 0x7834,
+	0x0004, 0x0029, 0x0010, 0x080c, 0x5c9b, 0x00fe, 0x0005, 0x00f6,
+	0x7097, 0x0005, 0x080c, 0x5c43, 0x2079, 0x0240, 0x7833, 0x1103,
+	0x7837, 0x0000, 0x080c, 0x5cbf, 0x080c, 0x5ca2, 0x1170, 0x7080,
+	0x9005, 0x1158, 0x7158, 0x9186, 0xffff, 0x0138, 0x2011, 0x0008,
+	0x080c, 0x5afb, 0x0168, 0x080c, 0x5c78, 0x20a9, 0x0008, 0x20e1,
+	0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003,
+	0x60c3, 0x0014, 0x080c, 0x5b78, 0x00fe, 0x0005, 0x00f6, 0x708c,
+	0x9005, 0x0500, 0x2011, 0x5b4e, 0x080c, 0x803f, 0x9086, 0x0014,
+	0x11b8, 0x080c, 0x5cbf, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103,
+	0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c0,
+	0x9005, 0x1110, 0x70c3, 0x0001, 0x7097, 0x0006, 0x0029, 0x0010,
+	0x080c, 0x5c9b, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x0007, 0x080c,
+	0x5c43, 0x2079, 0x0240, 0x7833, 0x1104, 0x7837, 0x0000, 0x080c,
+	0x5cbf, 0x080c, 0x5ca2, 0x11b8, 0x7080, 0x9005, 0x11a0, 0x7160,
+	0x9186, 0xffff, 0x0180, 0x9180, 0x3145, 0x200d, 0x918c, 0xff00,
+	0x810f, 0x2011, 0x0008, 0x080c, 0x5afb, 0x0180, 0x080c, 0x4cac,
+	0x0110, 0x080c, 0x26d9, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099,
+	0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014,
+	0x080c, 0x5b78, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500,
+	0x2011, 0x5b4e, 0x080c, 0x803f, 0x9086, 0x0014, 0x11b8, 0x080c,
+	0x5cbf, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1104, 0x1178, 0x7834,
 	0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110,
-	0x70c3, 0x0001, 0x7097, 0x0012, 0x0029, 0x0010, 0x708f, 0x0000,
-	0x00fe, 0x0005, 0x00f6, 0x7097, 0x0013, 0x080c, 0x5c46, 0x2079,
-	0x0240, 0x7833, 0x1103, 0x7837, 0x0000, 0x080c, 0x5cb4, 0x080c,
-	0x5c97, 0x1170, 0x7080, 0x9005, 0x1158, 0x7158, 0x9186, 0xffff,
-	0x0138, 0x2011, 0x0008, 0x080c, 0x5af0, 0x0168, 0x080c, 0x5c6d,
-	0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000,
-	0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b6d, 0x00fe,
-	0x0005, 0x00f6, 0x708c, 0x9005, 0x0500, 0x2011, 0x5b43, 0x080c,
-	0x8021, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5cb4, 0x2079, 0x0260,
-	0x7a30, 0x9296, 0x1104, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38,
-	0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x7097,
-	0x0014, 0x0029, 0x0010, 0x708f, 0x0000, 0x00fe, 0x0005, 0x00f6,
-	0x7097, 0x0015, 0x080c, 0x5c46, 0x2079, 0x0240, 0x7833, 0x1104,
-	0x7837, 0x0000, 0x080c, 0x5cb4, 0x080c, 0x5c97, 0x11b8, 0x7080,
-	0x9005, 0x11a0, 0x7160, 0x9186, 0xffff, 0x0180, 0x9180, 0x313a,
-	0x200d, 0x918c, 0xff00, 0x810f, 0x2011, 0x0008, 0x080c, 0x5af0,
-	0x0180, 0x080c, 0x4ca1, 0x0110, 0x080c, 0x26ce, 0x20a9, 0x0008,
-	0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e,
-	0x4003, 0x60c3, 0x0014, 0x080c, 0x5b6d, 0x00fe, 0x0005, 0x00f6,
-	0x708c, 0x9005, 0x05f0, 0x2011, 0x5b43, 0x080c, 0x8021, 0x9086,
-	0x0014, 0x15a8, 0x080c, 0x5cb4, 0x2079, 0x0260, 0x7a30, 0x9296,
-	0x1105, 0x1568, 0x7834, 0x9084, 0x0100, 0x2011, 0x0100, 0x921e,
-	0x1168, 0x9085, 0x0001, 0x080c, 0x5cdf, 0x7a38, 0xd2fc, 0x0128,
-	0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x0080, 0x9005, 0x11b8,
+	0x70c3, 0x0001, 0x7097, 0x0008, 0x0029, 0x0010, 0x080c, 0x5c9b,
+	0x00fe, 0x0005, 0x00f6, 0x7097, 0x0009, 0x080c, 0x5c43, 0x2079,
+	0x0240, 0x7833, 0x1105, 0x7837, 0x0100, 0x080c, 0x5ca2, 0x1150,
+	0x7080, 0x9005, 0x1138, 0x080c, 0x5a6e, 0x1188, 0x9085, 0x0001,
+	0x080c, 0x26d9, 0x20a9, 0x0008, 0x080c, 0x5cbf, 0x20e1, 0x0000,
+	0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3,
+	0x0014, 0x080c, 0x5b78, 0x0010, 0x080c, 0x55c8, 0x00fe, 0x0005,
+	0x00f6, 0x708c, 0x9005, 0x05a8, 0x2011, 0x5b4e, 0x080c, 0x803f,
+	0x9086, 0x0014, 0x1560, 0x080c, 0x5cbf, 0x2079, 0x0260, 0x7a30,
+	0x9296, 0x1105, 0x1520, 0x7834, 0x9084, 0x0100, 0x2011, 0x0100,
+	0x921e, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110,
+	0x70c3, 0x0001, 0x7097, 0x000a, 0x00b1, 0x0098, 0x9005, 0x1178,
 	0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001,
-	0x9085, 0x0001, 0x080c, 0x5cdf, 0x7093, 0x0000, 0x7a38, 0xd2f4,
-	0x0110, 0x70db, 0x0008, 0x7097, 0x0016, 0x0029, 0x0010, 0x708f,
-	0x0000, 0x00fe, 0x0005, 0x080c, 0x9c4a, 0x080c, 0x5cb4, 0x20e1,
-	0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9,
-	0x000e, 0x4003, 0x2011, 0x026d, 0x2204, 0x9084, 0x0100, 0x2011,
-	0x024d, 0x2012, 0x2011, 0x026e, 0x7097, 0x0017, 0x080c, 0x5c97,
-	0x1150, 0x7080, 0x9005, 0x1138, 0x080c, 0x5a63, 0x1188, 0x9085,
-	0x0001, 0x080c, 0x26ce, 0x20a9, 0x0008, 0x080c, 0x5cb4, 0x20e1,
-	0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003,
-	0x60c3, 0x0014, 0x080c, 0x5b6d, 0x0010, 0x080c, 0x55bd, 0x0005,
-	0x00f6, 0x708c, 0x9005, 0x01d8, 0x2011, 0x5b43, 0x080c, 0x8021,
-	0x9086, 0x0084, 0x1190, 0x080c, 0x5cb4, 0x2079, 0x0260, 0x7a30,
-	0x9296, 0x1106, 0x1150, 0x7834, 0x9005, 0x1138, 0x9006, 0x080c,
-	0x5cdf, 0x7097, 0x0018, 0x0029, 0x0010, 0x708f, 0x0000, 0x00fe,
-	0x0005, 0x00f6, 0x7097, 0x0019, 0x080c, 0x5c46, 0x2079, 0x0240,
-	0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x5cb4, 0x2009, 0x026e,
-	0x2039, 0x1c0e, 0x20a9, 0x0040, 0x213e, 0x8738, 0x8108, 0x9186,
-	0x0280, 0x1128, 0x6814, 0x8000, 0x6816, 0x2009, 0x0260, 0x1f04,
-	0x59cc, 0x2039, 0x1c0e, 0x080c, 0x5c97, 0x11e8, 0x2728, 0x2514,
-	0x8207, 0x9084, 0x00ff, 0x8000, 0x2018, 0x9294, 0x00ff, 0x8007,
-	0x9205, 0x202a, 0x705c, 0x2310, 0x8214, 0x92a0, 0x1c0e, 0x2414,
-	0x938c, 0x0001, 0x0118, 0x9294, 0xff00, 0x0018, 0x9294, 0x00ff,
-	0x8007, 0x9215, 0x2222, 0x20a9, 0x0040, 0x2009, 0x024e, 0x270e,
-	0x8738, 0x8108, 0x9186, 0x0260, 0x1128, 0x6810, 0x8000, 0x6812,
-	0x2009, 0x0240, 0x1f04, 0x59ff, 0x60c3, 0x0084, 0x080c, 0x5b6d,
-	0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x01e0, 0x2011, 0x5b43,
-	0x080c, 0x8021, 0x9086, 0x0084, 0x1198, 0x080c, 0x5cb4, 0x2079,
-	0x0260, 0x7a30, 0x9296, 0x1107, 0x1158, 0x7834, 0x9005, 0x1140,
-	0x7093, 0x0001, 0x080c, 0x5c0a, 0x7097, 0x001a, 0x0029, 0x0010,
-	0x708f, 0x0000, 0x00fe, 0x0005, 0x9085, 0x0001, 0x080c, 0x5cdf,
-	0x7097, 0x001b, 0x080c, 0x9c4a, 0x080c, 0x5cb4, 0x2011, 0x0260,
-	0x2009, 0x0240, 0x748c, 0x9480, 0x0018, 0x9080, 0x0007, 0x9084,
-	0x03f8, 0x8004, 0x20a8, 0x220e, 0x8210, 0x8108, 0x9186, 0x0260,
-	0x1150, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x6814, 0x8000,
-	0x6816, 0x2011, 0x0260, 0x1f04, 0x5a4b, 0x60c3, 0x0084, 0x080c,
-	0x5b6d, 0x0005, 0x0005, 0x0086, 0x0096, 0x2029, 0x1854, 0x252c,
-	0x20a9, 0x0008, 0x2041, 0x1c0e, 0x20e9, 0x0001, 0x28a0, 0x080c,
-	0x5cb4, 0x20e1, 0x0000, 0x2099, 0x026e, 0x4003, 0x20a9, 0x0008,
-	0x2011, 0x0007, 0xd5d4, 0x0108, 0x9016, 0x2800, 0x9200, 0x200c,
-	0x91a6, 0xffff, 0x1148, 0xd5d4, 0x0110, 0x8210, 0x0008, 0x8211,
-	0x1f04, 0x5a7d, 0x0804, 0x5aec, 0x82ff, 0x1160, 0xd5d4, 0x0120,
-	0x91a6, 0x3fff, 0x0d90, 0x0020, 0x91a6, 0x3fff, 0x0904, 0x5aec,
-	0x918d, 0xc000, 0x20a9, 0x0010, 0x2019, 0x0001, 0xd5d4, 0x0110,
-	0x2019, 0x0010, 0x2120, 0xd5d4, 0x0110, 0x8423, 0x0008, 0x8424,
-	0x1240, 0xd5d4, 0x0110, 0x8319, 0x0008, 0x8318, 0x1f04, 0x5aa3,
-	0x04d8, 0x23a8, 0x2021, 0x0001, 0x8426, 0x8425, 0x1f04, 0x5ab5,
-	0x2328, 0x8529, 0x92be, 0x0007, 0x0158, 0x0006, 0x2039, 0x0007,
-	0x2200, 0x973a, 0x000e, 0x27a8, 0x95a8, 0x0010, 0x1f04, 0x5ac4,
-	0x755a, 0x95c8, 0x313a, 0x292d, 0x95ac, 0x00ff, 0x757e, 0x6532,
-	0x6536, 0x0016, 0x2508, 0x080c, 0x26ae, 0x001e, 0x60e7, 0x0000,
-	0x65ea, 0x2018, 0x2304, 0x9405, 0x201a, 0x7083, 0x0001, 0x20e9,
-	0x0000, 0x20a1, 0x024e, 0x20e1, 0x0001, 0x2898, 0x20a9, 0x0008,
-	0x4003, 0x9085, 0x0001, 0x0008, 0x9006, 0x009e, 0x008e, 0x0005,
-	0x0156, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x22a8, 0x20e1, 0x0000,
-	0x2099, 0x026e, 0x20e9, 0x0000, 0x2011, 0x024e, 0x22a0, 0x4003,
-	0x014e, 0x013e, 0x01de, 0x01ce, 0x015e, 0x2118, 0x9026, 0x2001,
-	0x0007, 0x939a, 0x0010, 0x0218, 0x8420, 0x8001, 0x0cd0, 0x2118,
-	0x84ff, 0x0120, 0x939a, 0x0010, 0x8421, 0x1de0, 0x2021, 0x0001,
-	0x83ff, 0x0118, 0x8423, 0x8319, 0x1de8, 0x9238, 0x2029, 0x026e,
-	0x9528, 0x2504, 0x942c, 0x11b8, 0x9405, 0x203a, 0x715a, 0x91a0,
-	0x313a, 0x242d, 0x95ac, 0x00ff, 0x757e, 0x6532, 0x6536, 0x0016,
-	0x2508, 0x080c, 0x26ae, 0x001e, 0x60e7, 0x0000, 0x65ea, 0x7083,
-	0x0001, 0x9084, 0x0000, 0x0005, 0x00e6, 0x2071, 0x1800, 0x7087,
-	0x0000, 0x00ee, 0x0005, 0x00e6, 0x00f6, 0x2079, 0x0100, 0x2071,
-	0x0140, 0x080c, 0x5bf9, 0x080c, 0x93ad, 0x7004, 0x9084, 0x4000,
-	0x0110, 0x080c, 0x2b26, 0x0126, 0x2091, 0x8000, 0x2071, 0x1825,
-	0x2073, 0x0000, 0x7840, 0x0026, 0x0016, 0x2009, 0x00f7, 0x080c,
-	0x5c56, 0x001e, 0x9094, 0x0010, 0x9285, 0x0080, 0x7842, 0x7a42,
-	0x002e, 0x012e, 0x00fe, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x29cc, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012,
-	0x2011, 0x19c1, 0x2013, 0x0000, 0x708f, 0x0000, 0x012e, 0x60a3,
-	0x0056, 0x60a7, 0x9575, 0x080c, 0x93a4, 0x6144, 0xd184, 0x0120,
-	0x7194, 0x918d, 0x2000, 0x0018, 0x7188, 0x918d, 0x1000, 0x2011,
-	0x1969, 0x2112, 0x2009, 0x07d0, 0x2011, 0x5b43, 0x080c, 0x80b3,
-	0x0005, 0x0016, 0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x9dc8, 0x2009, 0x00f7, 0x080c, 0x5c56, 0x2061, 0x19ca, 0x900e,
-	0x611a, 0x611e, 0x6172, 0x6176, 0x2061, 0x1800, 0x6003, 0x0001,
-	0x2061, 0x0100, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x1969,
-	0x200b, 0x0000, 0x2009, 0x002d, 0x2011, 0x5bc5, 0x080c, 0x8015,
-	0x012e, 0x00ce, 0x002e, 0x001e, 0x0005, 0x00e6, 0x0006, 0x0126,
-	0x2091, 0x8000, 0x0471, 0x2071, 0x0100, 0x080c, 0x93ad, 0x2071,
-	0x0140, 0x7004, 0x9084, 0x4000, 0x0110, 0x080c, 0x2b26, 0x080c,
-	0x6fa3, 0x0188, 0x080c, 0x6fbe, 0x1170, 0x080c, 0x7289, 0x0016,
-	0x080c, 0x277d, 0x2001, 0x193d, 0x2102, 0x001e, 0x080c, 0x7284,
-	0x080c, 0x6ecd, 0x0050, 0x2009, 0x0001, 0x080c, 0x2a65, 0x2001,
-	0x0001, 0x080c, 0x260e, 0x080c, 0x5b99, 0x012e, 0x000e, 0x00ee,
-	0x0005, 0x2001, 0x180e, 0x2004, 0xd0bc, 0x0158, 0x0026, 0x0036,
-	0x2011, 0x8017, 0x2001, 0x1969, 0x201c, 0x080c, 0x48e9, 0x003e,
-	0x002e, 0x0005, 0x20a9, 0x0012, 0x20e9, 0x0001, 0x20a1, 0x1c80,
-	0x080c, 0x5cb4, 0x20e9, 0x0000, 0x2099, 0x026e, 0x0099, 0x20a9,
-	0x0020, 0x080c, 0x5cae, 0x2099, 0x0260, 0x20a1, 0x1c92, 0x0051,
-	0x20a9, 0x000e, 0x080c, 0x5cb1, 0x2099, 0x0260, 0x20a1, 0x1cb2,
-	0x0009, 0x0005, 0x0016, 0x0026, 0x3410, 0x3308, 0x2104, 0x8007,
-	0x2012, 0x8108, 0x8210, 0x1f04, 0x5c2e, 0x002e, 0x001e, 0x0005,
-	0x080c, 0x9c4a, 0x20e1, 0x0001, 0x2099, 0x1c00, 0x20e9, 0x0000,
-	0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003, 0x0005, 0x080c, 0x9c4a,
-	0x080c, 0x5cb4, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0000,
-	0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003, 0x0005, 0x00c6, 0x0006,
-	0x2061, 0x0100, 0x810f, 0x2001, 0x1833, 0x2004, 0x9005, 0x1138,
-	0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x9105, 0x0010, 0x9185,
-	0x00f7, 0x604a, 0x000e, 0x00ce, 0x0005, 0x0016, 0x0046, 0x080c,
-	0x6567, 0x0158, 0x9006, 0x2020, 0x2009, 0x002a, 0x080c, 0xd54b,
-	0x2001, 0x180c, 0x200c, 0xc195, 0x2102, 0x2019, 0x002a, 0x900e,
-	0x080c, 0x2fa7, 0x080c, 0xc22c, 0x0140, 0x0036, 0x2019, 0xffff,
-	0x2021, 0x0007, 0x080c, 0x4a86, 0x003e, 0x004e, 0x001e, 0x0005,
-	0x080c, 0x5b99, 0x7097, 0x0000, 0x708f, 0x0000, 0x0005, 0x0006,
-	0x2001, 0x180c, 0x2004, 0xd09c, 0x0100, 0x000e, 0x0005, 0x0006,
-	0x0016, 0x0126, 0x2091, 0x8000, 0x2001, 0x0101, 0x200c, 0x918d,
-	0x0006, 0x2102, 0x012e, 0x001e, 0x000e, 0x0005, 0x2009, 0x0001,
-	0x0020, 0x2009, 0x0002, 0x0008, 0x900e, 0x6814, 0x9084, 0xffc0,
-	0x910d, 0x6916, 0x0005, 0x00f6, 0x0156, 0x0146, 0x01d6, 0x9006,
-	0x20a9, 0x0080, 0x20e9, 0x0001, 0x20a1, 0x1c00, 0x4004, 0x2079,
-	0x1c00, 0x7803, 0x2200, 0x7807, 0x00ef, 0x780f, 0x00ef, 0x7813,
-	0x0138, 0x7823, 0xffff, 0x7827, 0xffff, 0x01de, 0x014e, 0x015e,
-	0x00fe, 0x0005, 0x2001, 0x1800, 0x2003, 0x0001, 0x0005, 0x2001,
-	0x1976, 0x0118, 0x2003, 0x0001, 0x0010, 0x2003, 0x0000, 0x0005,
-	0x0156, 0x20a9, 0x0800, 0x2009, 0x1000, 0x9006, 0x200a, 0x8108,
-	0x1f04, 0x5cee, 0x015e, 0x0005, 0x00d6, 0x0036, 0x0156, 0x0136,
-	0x0146, 0x2069, 0x1853, 0x9006, 0xb802, 0xb8be, 0xb807, 0x0707,
-	0xb80a, 0xb80e, 0xb812, 0x9198, 0x313a, 0x231d, 0x939c, 0x00ff,
-	0xbb16, 0x0016, 0x0026, 0xb8b2, 0x080c, 0x9dc1, 0x1120, 0x9192,
-	0x007e, 0x1208, 0xbbb2, 0x20a9, 0x0004, 0xb8b4, 0x20e8, 0xb9b8,
-	0x9198, 0x0006, 0x9006, 0x23a0, 0x4004, 0x20a9, 0x0004, 0x9198,
-	0x000a, 0x23a0, 0x4004, 0x002e, 0x001e, 0xb83e, 0xb842, 0xb84e,
-	0xb852, 0xb856, 0xb85a, 0xb85e, 0xb862, 0xb866, 0xb86a, 0xb86f,
-	0x0100, 0xb872, 0xb876, 0xb87a, 0xb88a, 0xb88e, 0xb893, 0x0008,
-	0xb896, 0xb89a, 0xb89e, 0xb8ae, 0xb9a2, 0x0096, 0xb8a4, 0x904d,
-	0x0110, 0x080c, 0x101d, 0xb8a7, 0x0000, 0x009e, 0x9006, 0xb84a,
-	0x6810, 0xb83a, 0x680c, 0xb846, 0x6814, 0x9084, 0x00ff, 0xb842,
-	0x014e, 0x013e, 0x015e, 0x003e, 0x00de, 0x0005, 0x0126, 0x2091,
-	0x8000, 0xa974, 0xae78, 0x9684, 0x3fff, 0x9082, 0x4000, 0x1a04,
-	0x5dc4, 0x9182, 0x0800, 0x1a04, 0x5dc8, 0x2001, 0x180c, 0x2004,
-	0x9084, 0x0003, 0x1904, 0x5dce, 0x9188, 0x1000, 0x2104, 0x905d,
-	0x0518, 0xb804, 0x9084, 0x00ff, 0x908e, 0x0006, 0x1508, 0xb8a4,
-	0x900d, 0x1904, 0x5de0, 0xb850, 0x900d, 0x1148, 0xa802, 0x2900,
-	0xb852, 0xb84e, 0x080c, 0x83f7, 0x9006, 0x012e, 0x0005, 0x00a6,
-	0x2150, 0x2900, 0xb002, 0xa803, 0x0000, 0x00ae, 0xb852, 0x0c90,
-	0x2001, 0x0005, 0x900e, 0x04b8, 0x2001, 0x0028, 0x900e, 0x0498,
-	0x9082, 0x0006, 0x1290, 0x080c, 0x9dc1, 0x1160, 0xb8a0, 0x9084,
-	0xff80, 0x1140, 0xb900, 0xd1fc, 0x0990, 0x2001, 0x0029, 0x2009,
-	0x1000, 0x0408, 0x2001, 0x0028, 0x00a8, 0x2009, 0x180c, 0x210c,
-	0xd18c, 0x0118, 0x2001, 0x0004, 0x0068, 0xd184, 0x0118, 0x2001,
-	0x0004, 0x0040, 0x2001, 0x0029, 0xb900, 0xd1fc, 0x0118, 0x2009,
-	0x1000, 0x0048, 0x900e, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018,
-	0x2001, 0x0029, 0x900e, 0x9005, 0x012e, 0x0005, 0x2001, 0x180c,
-	0x2004, 0xd084, 0x19d0, 0x9188, 0x1000, 0x2104, 0x905d, 0x09a8,
-	0x080c, 0x656b, 0x1990, 0xb800, 0xd0bc, 0x0978, 0x0804, 0x5d77,
-	0x080c, 0x63e3, 0x0904, 0x5d90, 0x0804, 0x5d7b, 0x00b6, 0x00e6,
-	0x0126, 0x2091, 0x8000, 0xa974, 0x9182, 0x0800, 0x1a04, 0x5e61,
-	0x9188, 0x1000, 0x2104, 0x905d, 0x0904, 0x5e39, 0xb8a0, 0x9086,
-	0x007f, 0x0178, 0x080c, 0x6573, 0x0160, 0xa994, 0x81ff, 0x0130,
-	0x908e, 0x0004, 0x0130, 0x908e, 0x0005, 0x0118, 0x080c, 0x656b,
-	0x1598, 0xa87c, 0xd0fc, 0x01e0, 0xa894, 0x9005, 0x01c8, 0x2060,
-	0x0026, 0x2010, 0x080c, 0xbb1a, 0x002e, 0x1120, 0x2001, 0x0008,
-	0x0804, 0x5e63, 0x6020, 0x9086, 0x000a, 0x0120, 0x2001, 0x0008,
-	0x0804, 0x5e63, 0x601a, 0x6003, 0x0008, 0x2900, 0x6016, 0x0058,
-	0x080c, 0x9dec, 0x05e8, 0x2b00, 0x6012, 0x2900, 0x6016, 0x600b,
-	0xffff, 0x6023, 0x000a, 0x2009, 0x0003, 0x080c, 0x9ebc, 0x9006,
-	0x0458, 0x2001, 0x0028, 0x0438, 0x9082, 0x0006, 0x1290, 0x080c,
-	0x9dc1, 0x1160, 0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900, 0xd1fc,
-	0x0900, 0x2001, 0x0029, 0x2009, 0x1000, 0x00a8, 0x2001, 0x0028,
-	0x0090, 0x2009, 0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004,
-	0x0050, 0xd184, 0x0118, 0x2001, 0x0004, 0x0028, 0x2001, 0x0029,
-	0x0010, 0x2001, 0x0029, 0x9005, 0x012e, 0x00ee, 0x00be, 0x0005,
-	0x2001, 0x002c, 0x0cc0, 0x00f6, 0x00b6, 0x0126, 0x2091, 0x8000,
-	0xa8e0, 0x9005, 0x1550, 0xa8dc, 0x9082, 0x0101, 0x1630, 0xa8c8,
-	0x9005, 0x1518, 0xa8c4, 0x9082, 0x0101, 0x12f8, 0xa974, 0x2079,
-	0x1800, 0x9182, 0x0800, 0x12e8, 0x7830, 0x9084, 0x0003, 0x1130,
-	0xaa98, 0xab94, 0xa878, 0x9084, 0x0007, 0x00ea, 0x7930, 0xd18c,
-	0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004,
-	0x0010, 0x2001, 0x0029, 0x900e, 0x0038, 0x2001, 0x002c, 0x900e,
-	0x0018, 0x2001, 0x0029, 0x900e, 0x9006, 0x0008, 0x9005, 0x012e,
-	0x00be, 0x00fe, 0x0005, 0x5ef8, 0x5eb3, 0x5eca, 0x5ef8, 0x5ef8,
-	0x5ef8, 0x5ef8, 0x5ef8, 0x2100, 0x9082, 0x007e, 0x1278, 0x080c,
-	0x61e7, 0x0148, 0x9046, 0xb810, 0x9306, 0x1904, 0x5f00, 0xb814,
-	0x9206, 0x15f0, 0x0028, 0xbb12, 0xba16, 0x0010, 0x080c, 0x47a3,
-	0x0150, 0x04b0, 0x080c, 0x6247, 0x1598, 0xb810, 0x9306, 0x1580,
-	0xb814, 0x9206, 0x1568, 0x080c, 0x9dec, 0x0530, 0x2b00, 0x6012,
-	0x080c, 0xbfa6, 0x2900, 0x6016, 0x600b, 0xffff, 0x6023, 0x000a,
-	0xa878, 0x9086, 0x0001, 0x1170, 0x080c, 0x2fdc, 0x9006, 0x080c,
-	0x6184, 0x2001, 0x0002, 0x080c, 0x6198, 0x2001, 0x0200, 0xb86e,
-	0xb893, 0x0002, 0x2009, 0x0003, 0x080c, 0x9ebc, 0x9006, 0x0068,
-	0x2001, 0x0001, 0x900e, 0x0038, 0x2001, 0x002c, 0x900e, 0x0018,
-	0x2001, 0x0028, 0x900e, 0x9005, 0x0000, 0x012e, 0x00be, 0x00fe,
-	0x0005, 0x00b6, 0x00f6, 0x00e6, 0x0126, 0x2091, 0x8000, 0xa894,
-	0x90c6, 0x0015, 0x0904, 0x60d5, 0x90c6, 0x0056, 0x0904, 0x60d9,
-	0x90c6, 0x0066, 0x0904, 0x60dd, 0x90c6, 0x0067, 0x0904, 0x60e1,
-	0x90c6, 0x0068, 0x0904, 0x60e5, 0x90c6, 0x0071, 0x0904, 0x60e9,
-	0x90c6, 0x0074, 0x0904, 0x60ed, 0x90c6, 0x007c, 0x0904, 0x60f1,
-	0x90c6, 0x007e, 0x0904, 0x60f5, 0x90c6, 0x0037, 0x0904, 0x60f9,
-	0x9016, 0x2079, 0x1800, 0xa974, 0x9186, 0x00ff, 0x0904, 0x60d0,
-	0x9182, 0x0800, 0x1a04, 0x60d0, 0x080c, 0x6247, 0x1198, 0xb804,
-	0x9084, 0x00ff, 0x9082, 0x0006, 0x1268, 0xa894, 0x90c6, 0x006f,
-	0x0148, 0x080c, 0x9dc1, 0x1904, 0x60b9, 0xb8a0, 0x9084, 0xff80,
-	0x1904, 0x60b9, 0xa894, 0x90c6, 0x006f, 0x0158, 0x90c6, 0x005e,
-	0x0904, 0x6019, 0x90c6, 0x0064, 0x0904, 0x6042, 0x2008, 0x0804,
-	0x5fdc, 0xa998, 0xa8b0, 0x2040, 0x080c, 0x9dc1, 0x1120, 0x9182,
-	0x007f, 0x0a04, 0x5fdc, 0x9186, 0x00ff, 0x0904, 0x5fdc, 0x9182,
-	0x0800, 0x1a04, 0x5fdc, 0xaaa0, 0xab9c, 0x7878, 0x9306, 0x1188,
-	0x787c, 0x0096, 0x924e, 0x1128, 0x2208, 0x2310, 0x009e, 0x0804,
-	0x5fdc, 0x99cc, 0xff00, 0x009e, 0x1120, 0x2208, 0x2310, 0x0804,
-	0x5fdc, 0x080c, 0x47a3, 0x0904, 0x5fe5, 0x900e, 0x9016, 0x90c6,
-	0x4000, 0x1558, 0x0006, 0x080c, 0x6467, 0x1108, 0xc185, 0xb800,
-	0xd0bc, 0x0108, 0xc18d, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x0031, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006,
-	0x2098, 0x080c, 0x0f68, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x0035, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x000a,
-	0x2098, 0x080c, 0x0f68, 0x000e, 0x00c8, 0x90c6, 0x4007, 0x1110,
-	0x2408, 0x00a0, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0070,
-	0x90c6, 0x4009, 0x1108, 0x0050, 0x90c6, 0x4006, 0x0138, 0x2001,
-	0x4005, 0x2009, 0x000a, 0x0010, 0x2001, 0x4006, 0xa896, 0xa99a,
-	0xaa9e, 0x2001, 0x0030, 0x900e, 0x0470, 0x080c, 0x9dec, 0x1130,
-	0x2001, 0x4005, 0x2009, 0x0003, 0x9016, 0x0c80, 0x2b00, 0x6012,
-	0x080c, 0xbfa6, 0x2900, 0x6016, 0x6023, 0x0001, 0xa868, 0xd88c,
-	0x0108, 0xc0f5, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c, 0x2fdc,
-	0x012e, 0x9006, 0x080c, 0x6184, 0x2001, 0x0002, 0x080c, 0x6198,
-	0x2009, 0x0002, 0x080c, 0x9ebc, 0xa8b0, 0xd094, 0x0118, 0xb8bc,
-	0xc08d, 0xb8be, 0x9006, 0x9005, 0x012e, 0x00ee, 0x00fe, 0x00be,
-	0x0005, 0x080c, 0x53a3, 0x0118, 0x2009, 0x0007, 0x00f8, 0xa998,
-	0xaeb0, 0x080c, 0x6247, 0x1904, 0x5fd7, 0x9186, 0x007f, 0x0130,
-	0x080c, 0x656b, 0x0118, 0x2009, 0x0009, 0x0080, 0x0096, 0x080c,
-	0x0feb, 0x1120, 0x009e, 0x2009, 0x0002, 0x0040, 0x2900, 0x009e,
-	0xa806, 0x080c, 0xbd12, 0x19b0, 0x2009, 0x0003, 0x2001, 0x4005,
-	0x0804, 0x5fde, 0xa998, 0xaeb0, 0x080c, 0x6247, 0x1904, 0x5fd7,
-	0x0096, 0x080c, 0x0feb, 0x1128, 0x009e, 0x2009, 0x0002, 0x0804,
-	0x6096, 0x2900, 0x009e, 0xa806, 0x0096, 0x2048, 0x20a9, 0x002b,
-	0xb8b4, 0x20e0, 0xb8b8, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080,
-	0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0,
-	0xbbb8, 0x9398, 0x0006, 0x2398, 0x080c, 0x0f68, 0x009e, 0xa87b,
-	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xd684, 0x1168, 0x080c,
-	0x538f, 0xd0b4, 0x1118, 0xa89b, 0x000b, 0x00e0, 0xb800, 0xd08c,
-	0x0118, 0xa89b, 0x000c, 0x00b0, 0x080c, 0x656b, 0x0118, 0xa89b,
-	0x0009, 0x0080, 0x080c, 0x53a3, 0x0118, 0xa89b, 0x0007, 0x0050,
-	0x080c, 0xbcf5, 0x1904, 0x6012, 0x2009, 0x0003, 0x2001, 0x4005,
-	0x0804, 0x5fde, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa804, 0x8006,
-	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002,
-	0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000,
-	0x2041, 0x122f, 0x080c, 0xa345, 0x1904, 0x6012, 0x2009, 0x0002,
-	0x08e8, 0x2001, 0x0028, 0x900e, 0x0804, 0x6013, 0x2009, 0x180c,
-	0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118,
-	0x2001, 0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0804, 0x6013,
-	0x2001, 0x0029, 0x900e, 0x0804, 0x6013, 0x080c, 0x3569, 0x0804,
-	0x6014, 0x080c, 0x50cc, 0x0804, 0x6014, 0x080c, 0x4339, 0x0804,
-	0x6014, 0x080c, 0x43b2, 0x0804, 0x6014, 0x080c, 0x440e, 0x0804,
-	0x6014, 0x080c, 0x485f, 0x0804, 0x6014, 0x080c, 0x4b04, 0x0804,
-	0x6014, 0x080c, 0x4d37, 0x0804, 0x6014, 0x080c, 0x4f30, 0x0804,
-	0x6014, 0x080c, 0x3779, 0x0804, 0x6014, 0x00b6, 0xa974, 0xae78,
-	0x9684, 0x3fff, 0x9082, 0x4000, 0x1618, 0x9182, 0x0800, 0x1268,
-	0x9188, 0x1000, 0x2104, 0x905d, 0x0140, 0x080c, 0x656b, 0x1148,
-	0x00e9, 0x080c, 0x6372, 0x9006, 0x00b0, 0x2001, 0x0028, 0x900e,
-	0x0090, 0x9082, 0x0006, 0x1240, 0xb900, 0xd1fc, 0x0d88, 0x2001,
-	0x0029, 0x2009, 0x1000, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018,
-	0x2001, 0x0029, 0x900e, 0x9005, 0x00be, 0x0005, 0x0126, 0x2091,
-	0x8000, 0xb850, 0x900d, 0x0150, 0x2900, 0x0096, 0x2148, 0xa802,
-	0x009e, 0xa803, 0x0000, 0xb852, 0x012e, 0x0005, 0x2900, 0xb852,
-	0xb84e, 0xa803, 0x0000, 0x0cc0, 0x0126, 0x2091, 0x8000, 0xb84c,
-	0x9005, 0x0170, 0x00e6, 0x2071, 0x19b7, 0x7004, 0x9086, 0x0002,
-	0x0168, 0x00ee, 0xb84c, 0xa802, 0x2900, 0xb84e, 0x012e, 0x0005,
-	0x2900, 0xb852, 0xb84e, 0xa803, 0x0000, 0x0cc0, 0x701c, 0x9b06,
-	0x1d80, 0xb84c, 0x00a6, 0x2050, 0xb000, 0xa802, 0x2900, 0xb002,
-	0x00ae, 0x00ee, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0xb84c,
-	0x904d, 0x0130, 0xa800, 0x9005, 0x1108, 0xb852, 0xb84e, 0x9905,
-	0x012e, 0x0005, 0xb84c, 0x904d, 0x0130, 0xa800, 0x9005, 0x1108,
-	0xb852, 0xb84e, 0x9905, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x0026,
-	0x2091, 0x8000, 0x6210, 0x2258, 0xba00, 0x9005, 0x0110, 0xc285,
-	0x0008, 0xc284, 0xba02, 0x002e, 0x00ce, 0x012e, 0x00be, 0x0005,
-	0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x6210, 0x2258, 0xba04,
-	0x0006, 0x9086, 0x0006, 0x1170, 0xb89c, 0xd0ac, 0x0158, 0x080c,
-	0x6567, 0x0140, 0x9284, 0xff00, 0x8007, 0x9086, 0x0007, 0x1110,
-	0x2011, 0x0600, 0x000e, 0x9294, 0xff00, 0x9215, 0xba06, 0x0006,
-	0x9086, 0x0006, 0x1120, 0xba90, 0x82ff, 0x090c, 0x0db4, 0x000e,
-	0x00ce, 0x012e, 0x00be, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x2091,
-	0x8000, 0x6210, 0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1168,
-	0xb89c, 0xd0a4, 0x0150, 0x080c, 0x6563, 0x1138, 0x9284, 0x00ff,
-	0x9086, 0x0007, 0x1110, 0x2011, 0x0006, 0x000e, 0x9294, 0x00ff,
-	0x8007, 0x9215, 0xba06, 0x00ce, 0x012e, 0x00be, 0x0005, 0x9182,
-	0x0800, 0x0218, 0x9085, 0x0001, 0x0005, 0x00d6, 0x0026, 0x9190,
-	0x1000, 0x2204, 0x905d, 0x1180, 0x0096, 0x080c, 0x0feb, 0x2958,
-	0x009e, 0x0160, 0x2b00, 0x2012, 0xb85c, 0xb8ba, 0xb860, 0xb8b6,
-	0x9006, 0xb8a6, 0x080c, 0x5cf4, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x002e, 0x00de, 0x0005, 0x00b6, 0x0096, 0x0126, 0x2091, 0x8000,
-	0x0026, 0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0458, 0x00d6,
-	0x9190, 0x1000, 0x2204, 0x905d, 0x0518, 0x2013, 0x0000, 0xb8a4,
-	0x904d, 0x0110, 0x080c, 0x101d, 0x00d6, 0x00c6, 0xb8ac, 0x2060,
-	0x8cff, 0x0168, 0x600c, 0x0006, 0x6014, 0x2048, 0x080c, 0xbb2c,
-	0x0110, 0x080c, 0x0f9d, 0x080c, 0x9e42, 0x00ce, 0x0c88, 0x00ce,
-	0x00de, 0x2b48, 0xb8b8, 0xb85e, 0xb8b4, 0xb862, 0x080c, 0x102d,
-	0x00de, 0x9006, 0x002e, 0x012e, 0x009e, 0x00be, 0x0005, 0x0016,
-	0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0030, 0x9188, 0x1000,
-	0x2104, 0x905d, 0x0dc0, 0x9006, 0x001e, 0x0005, 0x00d6, 0x0156,
-	0x0136, 0x0146, 0x9006, 0xb80a, 0xb80e, 0xb800, 0xc08c, 0xb802,
-	0x080c, 0x6f9b, 0x1510, 0xb8a0, 0x9086, 0x007e, 0x0120, 0x080c,
-	0x9dc1, 0x11d8, 0x0078, 0x7040, 0xd0e4, 0x01b8, 0x00c6, 0x2061,
-	0x1952, 0x7048, 0x2062, 0x704c, 0x6006, 0x7050, 0x600a, 0x7054,
-	0x600e, 0x00ce, 0x703c, 0x2069, 0x0140, 0x9005, 0x1110, 0x2001,
-	0x0001, 0x6886, 0x2069, 0x1800, 0x68b2, 0x7040, 0xb85e, 0x7048,
-	0xb862, 0x704c, 0xb866, 0x20e1, 0x0000, 0x2099, 0x0276, 0xb8b4,
-	0x20e8, 0xb8b8, 0x9088, 0x000a, 0x21a0, 0x20a9, 0x0004, 0x4003,
-	0x2099, 0x027a, 0x9088, 0x0006, 0x21a0, 0x20a9, 0x0004, 0x4003,
-	0x2069, 0x0200, 0x6817, 0x0001, 0x7040, 0xb86a, 0x7144, 0xb96e,
-	0x7048, 0xb872, 0x7050, 0xb876, 0x2069, 0x0200, 0x6817, 0x0000,
-	0xb8a0, 0x9086, 0x007e, 0x1110, 0x7144, 0xb96e, 0x9182, 0x0211,
-	0x1218, 0x2009, 0x0008, 0x0400, 0x9182, 0x0259, 0x1218, 0x2009,
-	0x0007, 0x00d0, 0x9182, 0x02c1, 0x1218, 0x2009, 0x0006, 0x00a0,
-	0x9182, 0x0349, 0x1218, 0x2009, 0x0005, 0x0070, 0x9182, 0x0421,
-	0x1218, 0x2009, 0x0004, 0x0040, 0x9182, 0x0581, 0x1218, 0x2009,
-	0x0003, 0x0010, 0x2009, 0x0002, 0xb992, 0x014e, 0x013e, 0x015e,
-	0x00de, 0x0005, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260, 0x7034,
-	0xb896, 0x703c, 0xb89a, 0x7054, 0xb89e, 0x0036, 0xbbbc, 0xc384,
-	0xba00, 0x2009, 0x1873, 0x210c, 0xd0bc, 0x0120, 0xd1ec, 0x0110,
-	0xc2ad, 0x0008, 0xc2ac, 0xd0c4, 0x0148, 0xd1e4, 0x0138, 0xc2bd,
-	0xd0cc, 0x0128, 0xd38c, 0x1108, 0xc385, 0x0008, 0xc2bc, 0xba02,
-	0xbbbe, 0x003e, 0x00ee, 0x002e, 0x001e, 0x0005, 0x0096, 0x0126,
-	0x2091, 0x8000, 0xb8a4, 0x904d, 0x0578, 0xa900, 0x81ff, 0x15c0,
-	0xaa04, 0x9282, 0x0010, 0x16c8, 0x0136, 0x0146, 0x01c6, 0x01d6,
-	0x8906, 0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0,
-	0x9080, 0x0004, 0x2098, 0x2009, 0x0010, 0x20a9, 0x0001, 0x4002,
-	0x9086, 0xffff, 0x0120, 0x8109, 0x1dd0, 0x080c, 0x0db4, 0x3c00,
-	0x20e8, 0x3300, 0x8001, 0x20a0, 0x4604, 0x8210, 0xaa06, 0x01de,
-	0x01ce, 0x014e, 0x013e, 0x0060, 0x080c, 0x0feb, 0x0170, 0x2900,
-	0xb8a6, 0xa803, 0x0000, 0x080c, 0x6403, 0xa807, 0x0001, 0xae12,
-	0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0126,
-	0x2091, 0x8000, 0x0096, 0xb8a4, 0x904d, 0x0188, 0xa800, 0x9005,
-	0x1150, 0x080c, 0x6412, 0x1158, 0xa804, 0x908a, 0x0002, 0x0218,
-	0x8001, 0xa806, 0x0020, 0x080c, 0x101d, 0xb8a7, 0x0000, 0x009e,
-	0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x83f7, 0x012e,
-	0x0005, 0x901e, 0x0010, 0x2019, 0x0001, 0x900e, 0x0126, 0x2091,
-	0x8000, 0xb84c, 0x2048, 0xb800, 0xd0dc, 0x1170, 0x89ff, 0x0500,
-	0x83ff, 0x0120, 0xa878, 0x9606, 0x0158, 0x0030, 0xa86c, 0x9406,
-	0x1118, 0xa870, 0x9506, 0x0120, 0x2908, 0xa800, 0x2048, 0x0c70,
-	0x080c, 0x97b1, 0xaa00, 0xb84c, 0x9906, 0x1110, 0xba4e, 0x0020,
-	0x00a6, 0x2150, 0xb202, 0x00ae, 0x82ff, 0x1110, 0xb952, 0x89ff,
-	0x012e, 0x0005, 0x9016, 0x0489, 0x1110, 0x2011, 0x0001, 0x0005,
-	0x080c, 0x6467, 0x0128, 0x080c, 0xbbe9, 0x0010, 0x9085, 0x0001,
-	0x0005, 0x080c, 0x6467, 0x0128, 0x080c, 0xbb8e, 0x0010, 0x9085,
-	0x0001, 0x0005, 0x080c, 0x6467, 0x0128, 0x080c, 0xbbe6, 0x0010,
-	0x9085, 0x0001, 0x0005, 0x080c, 0x6467, 0x0128, 0x080c, 0xbbad,
-	0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6467, 0x0128, 0x080c,
-	0xbc2a, 0x0010, 0x9085, 0x0001, 0x0005, 0xb8a4, 0x900d, 0x1118,
-	0x9085, 0x0001, 0x0005, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8,
-	0x890e, 0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0,
-	0x9080, 0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002,
-	0x9606, 0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0008, 0x9006,
-	0x01ce, 0x013e, 0x0005, 0x0146, 0x01d6, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x0004, 0x20a0, 0x20a9, 0x0010, 0x2009, 0xffff, 0x4104,
-	0x01de, 0x014e, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e,
+	0x7093, 0x0000, 0x7097, 0x000e, 0x080c, 0x5816, 0x0010, 0x080c,
+	0x5c9b, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x000b, 0x2011, 0x1c0e,
+	0x20e9, 0x0001, 0x22a0, 0x20a9, 0x0040, 0x2019, 0xffff, 0x4304,
+	0x080c, 0x5c43, 0x2079, 0x0240, 0x7833, 0x1106, 0x7837, 0x0000,
+	0x080c, 0x5ca2, 0x0118, 0x2013, 0x0000, 0x0020, 0x705c, 0x9085,
+	0x0100, 0x2012, 0x20a9, 0x0040, 0x2009, 0x024e, 0x2011, 0x1c0e,
+	0x220e, 0x8210, 0x8108, 0x9186, 0x0260, 0x1128, 0x6810, 0x8000,
+	0x6812, 0x2009, 0x0240, 0x1f04, 0x5798, 0x60c3, 0x0084, 0x080c,
+	0x5b78, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x01c0, 0x2011,
+	0x5b4e, 0x080c, 0x803f, 0x9086, 0x0084, 0x1178, 0x080c, 0x5cbf,
+	0x2079, 0x0260, 0x7a30, 0x9296, 0x1106, 0x1138, 0x7834, 0x9005,
+	0x1120, 0x7097, 0x000c, 0x0029, 0x0010, 0x080c, 0x5c9b, 0x00fe,
+	0x0005, 0x00f6, 0x7097, 0x000d, 0x080c, 0x5c43, 0x2079, 0x0240,
+	0x7833, 0x1107, 0x7837, 0x0000, 0x080c, 0x5cbf, 0x20a9, 0x0040,
+	0x2011, 0x026e, 0x2009, 0x024e, 0x220e, 0x8210, 0x8108, 0x9186,
+	0x0260, 0x1150, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x6814,
+	0x8000, 0x6816, 0x2011, 0x0260, 0x1f04, 0x57dc, 0x60c3, 0x0084,
+	0x080c, 0x5b78, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x01e0,
+	0x2011, 0x5b4e, 0x080c, 0x803f, 0x9086, 0x0084, 0x1198, 0x080c,
+	0x5cbf, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1107, 0x1158, 0x7834,
+	0x9005, 0x1140, 0x7093, 0x0001, 0x080c, 0x5c15, 0x7097, 0x000e,
+	0x0029, 0x0010, 0x080c, 0x5c9b, 0x00fe, 0x0005, 0x918d, 0x0001,
+	0x080c, 0x5cea, 0x7097, 0x000f, 0x708f, 0x0000, 0x2061, 0x0140,
+	0x605b, 0xbc85, 0x605f, 0xb5b5, 0x2061, 0x0100, 0x6043, 0x0005,
+	0x6043, 0x0004, 0x2009, 0x07d0, 0x2011, 0x5b4e, 0x080c, 0x8033,
+	0x0005, 0x708c, 0x9005, 0x0130, 0x2011, 0x5b4e, 0x080c, 0x803f,
+	0x7097, 0x0000, 0x0005, 0x7097, 0x0011, 0x080c, 0x9c37, 0x080c,
+	0x5cbf, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1,
+	0x0240, 0x748c, 0x9480, 0x0018, 0x9080, 0x0007, 0x9084, 0x03f8,
+	0x8004, 0x20a8, 0x4003, 0x080c, 0x5ca2, 0x11a0, 0x7178, 0x81ff,
+	0x0188, 0x900e, 0x707c, 0x9084, 0x00ff, 0x0160, 0x080c, 0x2670,
+	0x9186, 0x007e, 0x0138, 0x9186, 0x0080, 0x0120, 0x2011, 0x0008,
+	0x080c, 0x5afb, 0x60c3, 0x0014, 0x080c, 0x5b78, 0x0005, 0x00f6,
+	0x708c, 0x9005, 0x0500, 0x2011, 0x5b4e, 0x080c, 0x803f, 0x9086,
+	0x0014, 0x11b8, 0x080c, 0x5cbf, 0x2079, 0x0260, 0x7a30, 0x9296,
+	0x1103, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128,
+	0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x7097, 0x0012, 0x0029,
+	0x0010, 0x708f, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x0013,
+	0x080c, 0x5c51, 0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000,
+	0x080c, 0x5cbf, 0x080c, 0x5ca2, 0x1170, 0x7080, 0x9005, 0x1158,
+	0x7158, 0x9186, 0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5afb,
+	0x0168, 0x080c, 0x5c78, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099,
+	0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014,
+	0x080c, 0x5b78, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500,
+	0x2011, 0x5b4e, 0x080c, 0x803f, 0x9086, 0x0014, 0x11b8, 0x080c,
+	0x5cbf, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1104, 0x1178, 0x7834,
+	0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110,
+	0x70c3, 0x0001, 0x7097, 0x0014, 0x0029, 0x0010, 0x708f, 0x0000,
+	0x00fe, 0x0005, 0x00f6, 0x7097, 0x0015, 0x080c, 0x5c51, 0x2079,
+	0x0240, 0x7833, 0x1104, 0x7837, 0x0000, 0x080c, 0x5cbf, 0x080c,
+	0x5ca2, 0x11b8, 0x7080, 0x9005, 0x11a0, 0x7160, 0x9186, 0xffff,
+	0x0180, 0x9180, 0x3145, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011,
+	0x0008, 0x080c, 0x5afb, 0x0180, 0x080c, 0x4cac, 0x0110, 0x080c,
+	0x26d9, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
+	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b78,
+	0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x05f0, 0x2011, 0x5b4e,
+	0x080c, 0x803f, 0x9086, 0x0014, 0x15a8, 0x080c, 0x5cbf, 0x2079,
+	0x0260, 0x7a30, 0x9296, 0x1105, 0x1568, 0x7834, 0x9084, 0x0100,
+	0x2011, 0x0100, 0x921e, 0x1168, 0x9085, 0x0001, 0x080c, 0x5cea,
+	0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001,
+	0x0080, 0x9005, 0x11b8, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005,
+	0x1110, 0x70c3, 0x0001, 0x9085, 0x0001, 0x080c, 0x5cea, 0x7093,
+	0x0000, 0x7a38, 0xd2f4, 0x0110, 0x70db, 0x0008, 0x7097, 0x0016,
+	0x0029, 0x0010, 0x708f, 0x0000, 0x00fe, 0x0005, 0x080c, 0x9c37,
+	0x080c, 0x5cbf, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0000,
+	0x20a1, 0x0240, 0x20a9, 0x000e, 0x4003, 0x2011, 0x026d, 0x2204,
+	0x9084, 0x0100, 0x2011, 0x024d, 0x2012, 0x2011, 0x026e, 0x7097,
+	0x0017, 0x080c, 0x5ca2, 0x1150, 0x7080, 0x9005, 0x1138, 0x080c,
+	0x5a6e, 0x1188, 0x9085, 0x0001, 0x080c, 0x26d9, 0x20a9, 0x0008,
+	0x080c, 0x5cbf, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000,
+	0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b78, 0x0010,
+	0x080c, 0x55c8, 0x0005, 0x00f6, 0x708c, 0x9005, 0x01d8, 0x2011,
+	0x5b4e, 0x080c, 0x803f, 0x9086, 0x0084, 0x1190, 0x080c, 0x5cbf,
+	0x2079, 0x0260, 0x7a30, 0x9296, 0x1106, 0x1150, 0x7834, 0x9005,
+	0x1138, 0x9006, 0x080c, 0x5cea, 0x7097, 0x0018, 0x0029, 0x0010,
+	0x708f, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x0019, 0x080c,
+	0x5c51, 0x2079, 0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c,
+	0x5cbf, 0x2009, 0x026e, 0x2039, 0x1c0e, 0x20a9, 0x0040, 0x213e,
+	0x8738, 0x8108, 0x9186, 0x0280, 0x1128, 0x6814, 0x8000, 0x6816,
+	0x2009, 0x0260, 0x1f04, 0x59d7, 0x2039, 0x1c0e, 0x080c, 0x5ca2,
+	0x11e8, 0x2728, 0x2514, 0x8207, 0x9084, 0x00ff, 0x8000, 0x2018,
+	0x9294, 0x00ff, 0x8007, 0x9205, 0x202a, 0x705c, 0x2310, 0x8214,
+	0x92a0, 0x1c0e, 0x2414, 0x938c, 0x0001, 0x0118, 0x9294, 0xff00,
+	0x0018, 0x9294, 0x00ff, 0x8007, 0x9215, 0x2222, 0x20a9, 0x0040,
+	0x2009, 0x024e, 0x270e, 0x8738, 0x8108, 0x9186, 0x0260, 0x1128,
+	0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x1f04, 0x5a0a, 0x60c3,
+	0x0084, 0x080c, 0x5b78, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005,
+	0x01e0, 0x2011, 0x5b4e, 0x080c, 0x803f, 0x9086, 0x0084, 0x1198,
+	0x080c, 0x5cbf, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1107, 0x1158,
+	0x7834, 0x9005, 0x1140, 0x7093, 0x0001, 0x080c, 0x5c15, 0x7097,
+	0x001a, 0x0029, 0x0010, 0x708f, 0x0000, 0x00fe, 0x0005, 0x9085,
+	0x0001, 0x080c, 0x5cea, 0x7097, 0x001b, 0x080c, 0x9c37, 0x080c,
+	0x5cbf, 0x2011, 0x0260, 0x2009, 0x0240, 0x748c, 0x9480, 0x0018,
+	0x9080, 0x0007, 0x9084, 0x03f8, 0x8004, 0x20a8, 0x220e, 0x8210,
+	0x8108, 0x9186, 0x0260, 0x1150, 0x6810, 0x8000, 0x6812, 0x2009,
+	0x0240, 0x6814, 0x8000, 0x6816, 0x2011, 0x0260, 0x1f04, 0x5a56,
+	0x60c3, 0x0084, 0x080c, 0x5b78, 0x0005, 0x0005, 0x0086, 0x0096,
+	0x2029, 0x185c, 0x252c, 0x20a9, 0x0008, 0x2041, 0x1c0e, 0x20e9,
+	0x0001, 0x28a0, 0x080c, 0x5cbf, 0x20e1, 0x0000, 0x2099, 0x026e,
+	0x4003, 0x20a9, 0x0008, 0x2011, 0x0007, 0xd5d4, 0x0108, 0x9016,
+	0x2800, 0x9200, 0x200c, 0x91a6, 0xffff, 0x1148, 0xd5d4, 0x0110,
+	0x8210, 0x0008, 0x8211, 0x1f04, 0x5a88, 0x0804, 0x5af7, 0x82ff,
+	0x1160, 0xd5d4, 0x0120, 0x91a6, 0x3fff, 0x0d90, 0x0020, 0x91a6,
+	0x3fff, 0x0904, 0x5af7, 0x918d, 0xc000, 0x20a9, 0x0010, 0x2019,
+	0x0001, 0xd5d4, 0x0110, 0x2019, 0x0010, 0x2120, 0xd5d4, 0x0110,
+	0x8423, 0x0008, 0x8424, 0x1240, 0xd5d4, 0x0110, 0x8319, 0x0008,
+	0x8318, 0x1f04, 0x5aae, 0x04d8, 0x23a8, 0x2021, 0x0001, 0x8426,
+	0x8425, 0x1f04, 0x5ac0, 0x2328, 0x8529, 0x92be, 0x0007, 0x0158,
+	0x0006, 0x2039, 0x0007, 0x2200, 0x973a, 0x000e, 0x27a8, 0x95a8,
+	0x0010, 0x1f04, 0x5acf, 0x755a, 0x95c8, 0x3145, 0x292d, 0x95ac,
+	0x00ff, 0x757e, 0x6532, 0x6536, 0x0016, 0x2508, 0x080c, 0x26b9,
+	0x001e, 0x60e7, 0x0000, 0x65ea, 0x2018, 0x2304, 0x9405, 0x201a,
+	0x7083, 0x0001, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x20e1, 0x0001,
+	0x2898, 0x20a9, 0x0008, 0x4003, 0x9085, 0x0001, 0x0008, 0x9006,
+	0x009e, 0x008e, 0x0005, 0x0156, 0x01c6, 0x01d6, 0x0136, 0x0146,
+	0x22a8, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x2011,
+	0x024e, 0x22a0, 0x4003, 0x014e, 0x013e, 0x01de, 0x01ce, 0x015e,
+	0x2118, 0x9026, 0x2001, 0x0007, 0x939a, 0x0010, 0x0218, 0x8420,
+	0x8001, 0x0cd0, 0x2118, 0x84ff, 0x0120, 0x939a, 0x0010, 0x8421,
+	0x1de0, 0x2021, 0x0001, 0x83ff, 0x0118, 0x8423, 0x8319, 0x1de8,
+	0x9238, 0x2029, 0x026e, 0x9528, 0x2504, 0x942c, 0x11b8, 0x9405,
+	0x203a, 0x715a, 0x91a0, 0x3145, 0x242d, 0x95ac, 0x00ff, 0x757e,
+	0x6532, 0x6536, 0x0016, 0x2508, 0x080c, 0x26b9, 0x001e, 0x60e7,
+	0x0000, 0x65ea, 0x7083, 0x0001, 0x9084, 0x0000, 0x0005, 0x00e6,
+	0x2071, 0x1800, 0x7087, 0x0000, 0x00ee, 0x0005, 0x00e6, 0x00f6,
+	0x2079, 0x0100, 0x2071, 0x0140, 0x080c, 0x5c04, 0x080c, 0x93c7,
+	0x7004, 0x9084, 0x4000, 0x0110, 0x080c, 0x2b31, 0x0126, 0x2091,
+	0x8000, 0x2071, 0x1825, 0x2073, 0x0000, 0x7840, 0x0026, 0x0016,
+	0x2009, 0x00f7, 0x080c, 0x5c61, 0x001e, 0x9094, 0x0010, 0x9285,
+	0x0080, 0x7842, 0x7a42, 0x002e, 0x012e, 0x00fe, 0x00ee, 0x0005,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x29d7, 0x0228, 0x2011, 0x0101,
+	0x2204, 0xc0c5, 0x2012, 0x2011, 0x19c9, 0x2013, 0x0000, 0x708f,
+	0x0000, 0x012e, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0x93be,
+	0x6144, 0xd184, 0x0120, 0x7194, 0x918d, 0x2000, 0x0018, 0x7188,
+	0x918d, 0x1000, 0x2011, 0x1971, 0x2112, 0x2009, 0x07d0, 0x2011,
+	0x5b4e, 0x080c, 0x80d1, 0x0005, 0x0016, 0x0026, 0x00c6, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x9db5, 0x2009, 0x00f7, 0x080c, 0x5c61,
+	0x2061, 0x19d2, 0x900e, 0x611a, 0x611e, 0x6172, 0x6176, 0x2061,
+	0x1800, 0x6003, 0x0001, 0x2061, 0x0100, 0x6043, 0x0090, 0x6043,
+	0x0010, 0x2009, 0x1971, 0x200b, 0x0000, 0x2009, 0x002d, 0x2011,
+	0x5bd0, 0x080c, 0x8033, 0x012e, 0x00ce, 0x002e, 0x001e, 0x0005,
+	0x00e6, 0x0006, 0x0126, 0x2091, 0x8000, 0x0471, 0x2071, 0x0100,
+	0x080c, 0x93c7, 0x2071, 0x0140, 0x7004, 0x9084, 0x4000, 0x0110,
+	0x080c, 0x2b31, 0x080c, 0x6fb2, 0x0188, 0x080c, 0x6fcd, 0x1170,
+	0x080c, 0x7296, 0x0016, 0x080c, 0x2788, 0x2001, 0x1945, 0x2102,
+	0x001e, 0x080c, 0x7291, 0x080c, 0x6edc, 0x0050, 0x2009, 0x0001,
+	0x080c, 0x2a70, 0x2001, 0x0001, 0x080c, 0x2619, 0x080c, 0x5ba4,
+	0x012e, 0x000e, 0x00ee, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0bc,
+	0x0158, 0x0026, 0x0036, 0x2011, 0x8017, 0x2001, 0x1971, 0x201c,
+	0x080c, 0x48f4, 0x003e, 0x002e, 0x0005, 0x20a9, 0x0012, 0x20e9,
+	0x0001, 0x20a1, 0x1c80, 0x080c, 0x5cbf, 0x20e9, 0x0000, 0x2099,
+	0x026e, 0x0099, 0x20a9, 0x0020, 0x080c, 0x5cb9, 0x2099, 0x0260,
+	0x20a1, 0x1c92, 0x0051, 0x20a9, 0x000e, 0x080c, 0x5cbc, 0x2099,
+	0x0260, 0x20a1, 0x1cb2, 0x0009, 0x0005, 0x0016, 0x0026, 0x3410,
+	0x3308, 0x2104, 0x8007, 0x2012, 0x8108, 0x8210, 0x1f04, 0x5c39,
+	0x002e, 0x001e, 0x0005, 0x080c, 0x9c37, 0x20e1, 0x0001, 0x2099,
+	0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003,
+	0x0005, 0x080c, 0x9c37, 0x080c, 0x5cbf, 0x20e1, 0x0000, 0x2099,
+	0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000c, 0x4003,
+	0x0005, 0x00c6, 0x0006, 0x2061, 0x0100, 0x810f, 0x2001, 0x1833,
+	0x2004, 0x9005, 0x1138, 0x2001, 0x1817, 0x2004, 0x9084, 0x00ff,
+	0x9105, 0x0010, 0x9185, 0x00f7, 0x604a, 0x000e, 0x00ce, 0x0005,
+	0x0016, 0x0046, 0x080c, 0x6576, 0x0158, 0x9006, 0x2020, 0x2009,
+	0x002a, 0x080c, 0xd564, 0x2001, 0x180c, 0x200c, 0xc195, 0x2102,
+	0x2019, 0x002a, 0x900e, 0x080c, 0x2fb2, 0x080c, 0xc23b, 0x0140,
+	0x0036, 0x2019, 0xffff, 0x2021, 0x0007, 0x080c, 0x4a91, 0x003e,
+	0x004e, 0x001e, 0x0005, 0x080c, 0x5ba4, 0x7097, 0x0000, 0x708f,
+	0x0000, 0x0005, 0x0006, 0x2001, 0x180c, 0x2004, 0xd09c, 0x0100,
+	0x000e, 0x0005, 0x0006, 0x0016, 0x0126, 0x2091, 0x8000, 0x2001,
+	0x0101, 0x200c, 0x918d, 0x0006, 0x2102, 0x012e, 0x001e, 0x000e,
+	0x0005, 0x2009, 0x0001, 0x0020, 0x2009, 0x0002, 0x0008, 0x900e,
+	0x6814, 0x9084, 0xffc0, 0x910d, 0x6916, 0x0005, 0x00f6, 0x0156,
+	0x0146, 0x01d6, 0x9006, 0x20a9, 0x0080, 0x20e9, 0x0001, 0x20a1,
+	0x1c00, 0x4004, 0x2079, 0x1c00, 0x7803, 0x2200, 0x7807, 0x00ef,
+	0x780f, 0x00ef, 0x7813, 0x0138, 0x7823, 0xffff, 0x7827, 0xffff,
+	0x01de, 0x014e, 0x015e, 0x00fe, 0x0005, 0x2001, 0x1800, 0x2003,
+	0x0001, 0x0005, 0x2001, 0x197e, 0x0118, 0x2003, 0x0001, 0x0010,
+	0x2003, 0x0000, 0x0005, 0x0156, 0x20a9, 0x0800, 0x2009, 0x1000,
+	0x9006, 0x200a, 0x8108, 0x1f04, 0x5cf9, 0x015e, 0x0005, 0x00d6,
+	0x0036, 0x0156, 0x0136, 0x0146, 0x2069, 0x185b, 0x9006, 0xb802,
+	0xb8be, 0xb807, 0x0707, 0xb80a, 0xb80e, 0xb812, 0x9198, 0x3145,
+	0x231d, 0x939c, 0x00ff, 0xbb16, 0x0016, 0x0026, 0xb8b2, 0x080c,
+	0x9dae, 0x1120, 0x9192, 0x007e, 0x1208, 0xbbb2, 0x20a9, 0x0004,
+	0xb8b4, 0x20e8, 0xb9b8, 0x9198, 0x0006, 0x9006, 0x23a0, 0x4004,
+	0x20a9, 0x0004, 0x9198, 0x000a, 0x23a0, 0x4004, 0x002e, 0x001e,
+	0xb83e, 0xb842, 0xb84e, 0xb852, 0xb856, 0xb85a, 0xb85e, 0xb862,
+	0xb866, 0xb86a, 0xb86f, 0x0100, 0xb872, 0xb876, 0xb87a, 0xb88a,
+	0xb88e, 0xb893, 0x0008, 0xb896, 0xb89a, 0xb89e, 0xb8ae, 0xb9a2,
+	0x0096, 0xb8a4, 0x904d, 0x0110, 0x080c, 0x101d, 0xb8a7, 0x0000,
+	0x009e, 0x9006, 0xb84a, 0x6810, 0xb83a, 0x680c, 0xb846, 0x6814,
+	0x9084, 0x00ff, 0xb842, 0x014e, 0x013e, 0x015e, 0x003e, 0x00de,
+	0x0005, 0x0126, 0x2091, 0x8000, 0xa974, 0xae78, 0x9684, 0x3fff,
+	0x9082, 0x4000, 0x1a04, 0x5dcf, 0x9182, 0x0800, 0x1a04, 0x5dd3,
+	0x2001, 0x180c, 0x2004, 0x9084, 0x0003, 0x1904, 0x5dd9, 0x9188,
+	0x1000, 0x2104, 0x905d, 0x0518, 0xb804, 0x9084, 0x00ff, 0x908e,
+	0x0006, 0x1508, 0xb8a4, 0x900d, 0x1904, 0x5deb, 0xb850, 0x900d,
+	0x1148, 0xa802, 0x2900, 0xb852, 0xb84e, 0x080c, 0x8415, 0x9006,
+	0x012e, 0x0005, 0x00a6, 0x2150, 0x2900, 0xb002, 0xa803, 0x0000,
+	0x00ae, 0xb852, 0x0c90, 0x2001, 0x0005, 0x900e, 0x04b8, 0x2001,
+	0x0028, 0x900e, 0x0498, 0x9082, 0x0006, 0x1290, 0x080c, 0x9dae,
+	0x1160, 0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900, 0xd1fc, 0x0990,
+	0x2001, 0x0029, 0x2009, 0x1000, 0x0408, 0x2001, 0x0028, 0x00a8,
+	0x2009, 0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0068,
+	0xd184, 0x0118, 0x2001, 0x0004, 0x0040, 0x2001, 0x0029, 0xb900,
+	0xd1fc, 0x0118, 0x2009, 0x1000, 0x0048, 0x900e, 0x0038, 0x2001,
+	0x0029, 0x900e, 0x0018, 0x2001, 0x0029, 0x900e, 0x9005, 0x012e,
+	0x0005, 0x2001, 0x180c, 0x2004, 0xd084, 0x19d0, 0x9188, 0x1000,
+	0x2104, 0x905d, 0x09a8, 0x080c, 0x657a, 0x1990, 0xb800, 0xd0bc,
+	0x0978, 0x0804, 0x5d82, 0x080c, 0x63f2, 0x0904, 0x5d9b, 0x0804,
+	0x5d86, 0x00b6, 0x00e6, 0x0126, 0x2091, 0x8000, 0xa974, 0x9182,
+	0x0800, 0x1a04, 0x5e6c, 0x9188, 0x1000, 0x2104, 0x905d, 0x0904,
+	0x5e44, 0xb8a0, 0x9086, 0x007f, 0x0178, 0x080c, 0x6582, 0x0160,
+	0xa994, 0x81ff, 0x0130, 0x908e, 0x0004, 0x0130, 0x908e, 0x0005,
+	0x0118, 0x080c, 0x657a, 0x1598, 0xa87c, 0xd0fc, 0x01e0, 0xa894,
+	0x9005, 0x01c8, 0x2060, 0x0026, 0x2010, 0x080c, 0xbb29, 0x002e,
+	0x1120, 0x2001, 0x0008, 0x0804, 0x5e6e, 0x6020, 0x9086, 0x000a,
+	0x0120, 0x2001, 0x0008, 0x0804, 0x5e6e, 0x601a, 0x6003, 0x0008,
+	0x2900, 0x6016, 0x0058, 0x080c, 0x9dd9, 0x05e8, 0x2b00, 0x6012,
+	0x2900, 0x6016, 0x600b, 0xffff, 0x6023, 0x000a, 0x2009, 0x0003,
+	0x080c, 0x9ea9, 0x9006, 0x0458, 0x2001, 0x0028, 0x0438, 0x9082,
+	0x0006, 0x1290, 0x080c, 0x9dae, 0x1160, 0xb8a0, 0x9084, 0xff80,
+	0x1140, 0xb900, 0xd1fc, 0x0900, 0x2001, 0x0029, 0x2009, 0x1000,
+	0x00a8, 0x2001, 0x0028, 0x0090, 0x2009, 0x180c, 0x210c, 0xd18c,
+	0x0118, 0x2001, 0x0004, 0x0050, 0xd184, 0x0118, 0x2001, 0x0004,
+	0x0028, 0x2001, 0x0029, 0x0010, 0x2001, 0x0029, 0x9005, 0x012e,
+	0x00ee, 0x00be, 0x0005, 0x2001, 0x002c, 0x0cc0, 0x00f6, 0x00b6,
+	0x0126, 0x2091, 0x8000, 0xa8e0, 0x9005, 0x1550, 0xa8dc, 0x9082,
+	0x0101, 0x1630, 0xa8c8, 0x9005, 0x1518, 0xa8c4, 0x9082, 0x0101,
+	0x12f8, 0xa974, 0x2079, 0x1800, 0x9182, 0x0800, 0x12e8, 0x7830,
+	0x9084, 0x0003, 0x1130, 0xaa98, 0xab94, 0xa878, 0x9084, 0x0007,
+	0x00ea, 0x7930, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184,
+	0x0118, 0x2001, 0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0038,
+	0x2001, 0x002c, 0x900e, 0x0018, 0x2001, 0x0029, 0x900e, 0x9006,
+	0x0008, 0x9005, 0x012e, 0x00be, 0x00fe, 0x0005, 0x5f03, 0x5ebe,
+	0x5ed5, 0x5f03, 0x5f03, 0x5f03, 0x5f03, 0x5f03, 0x2100, 0x9082,
+	0x007e, 0x1278, 0x080c, 0x61f6, 0x0148, 0x9046, 0xb810, 0x9306,
+	0x1904, 0x5f0b, 0xb814, 0x9206, 0x15f0, 0x0028, 0xbb12, 0xba16,
+	0x0010, 0x080c, 0x47ae, 0x0150, 0x04b0, 0x080c, 0x6256, 0x1598,
+	0xb810, 0x9306, 0x1580, 0xb814, 0x9206, 0x1568, 0x080c, 0x9dd9,
+	0x0530, 0x2b00, 0x6012, 0x080c, 0xbfb5, 0x2900, 0x6016, 0x600b,
+	0xffff, 0x6023, 0x000a, 0xa878, 0x9086, 0x0001, 0x1170, 0x080c,
+	0x2fe7, 0x9006, 0x080c, 0x6193, 0x2001, 0x0002, 0x080c, 0x61a7,
+	0x2001, 0x0200, 0xb86e, 0xb893, 0x0002, 0x2009, 0x0003, 0x080c,
+	0x9ea9, 0x9006, 0x0068, 0x2001, 0x0001, 0x900e, 0x0038, 0x2001,
+	0x002c, 0x900e, 0x0018, 0x2001, 0x0028, 0x900e, 0x9005, 0x0000,
+	0x012e, 0x00be, 0x00fe, 0x0005, 0x00b6, 0x00f6, 0x00e6, 0x0126,
+	0x2091, 0x8000, 0xa894, 0x90c6, 0x0015, 0x0904, 0x60e4, 0x90c6,
+	0x0056, 0x0904, 0x60e8, 0x90c6, 0x0066, 0x0904, 0x60ec, 0x90c6,
+	0x0067, 0x0904, 0x60f0, 0x90c6, 0x0068, 0x0904, 0x60f4, 0x90c6,
+	0x0071, 0x0904, 0x60f8, 0x90c6, 0x0074, 0x0904, 0x60fc, 0x90c6,
+	0x007c, 0x0904, 0x6100, 0x90c6, 0x007e, 0x0904, 0x6104, 0x90c6,
+	0x0037, 0x0904, 0x6108, 0x9016, 0x2079, 0x1800, 0xa974, 0x9186,
+	0x00ff, 0x0904, 0x60df, 0x9182, 0x0800, 0x1a04, 0x60df, 0x080c,
+	0x6256, 0x1198, 0xb804, 0x9084, 0x00ff, 0x9082, 0x0006, 0x1268,
+	0xa894, 0x90c6, 0x006f, 0x0148, 0x080c, 0x9dae, 0x1904, 0x60c8,
+	0xb8a0, 0x9084, 0xff80, 0x1904, 0x60c8, 0xa894, 0x90c6, 0x006f,
+	0x0158, 0x90c6, 0x005e, 0x0904, 0x6028, 0x90c6, 0x0064, 0x0904,
+	0x6051, 0x2008, 0x0804, 0x5feb, 0xa998, 0xa8b0, 0x2040, 0x080c,
+	0x9dae, 0x1120, 0x9182, 0x007f, 0x0a04, 0x5feb, 0x9186, 0x00ff,
+	0x0904, 0x5feb, 0x9182, 0x0800, 0x1a04, 0x5feb, 0xaaa0, 0xab9c,
+	0x7878, 0x9306, 0x11a8, 0x787c, 0x0096, 0x924e, 0x1128, 0x2208,
+	0x2310, 0x009e, 0x0804, 0x5feb, 0x080c, 0x9dae, 0x1140, 0x99cc,
+	0xff00, 0x009e, 0x1128, 0x2208, 0x2310, 0x0804, 0x5feb, 0x009e,
+	0x080c, 0x47ae, 0x0904, 0x5ff4, 0x900e, 0x9016, 0x90c6, 0x4000,
+	0x1558, 0x0006, 0x080c, 0x6476, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0031, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098,
+	0x080c, 0x0f68, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0035, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x000a, 0x2098,
+	0x080c, 0x0f68, 0x000e, 0x00c8, 0x90c6, 0x4007, 0x1110, 0x2408,
+	0x00a0, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0070, 0x90c6,
+	0x4009, 0x1108, 0x0050, 0x90c6, 0x4006, 0x0138, 0x2001, 0x4005,
+	0x2009, 0x000a, 0x0010, 0x2001, 0x4006, 0xa896, 0xa99a, 0xaa9e,
+	0x2001, 0x0030, 0x900e, 0x0470, 0x080c, 0x9dd9, 0x1130, 0x2001,
+	0x4005, 0x2009, 0x0003, 0x9016, 0x0c80, 0x2b00, 0x6012, 0x080c,
+	0xbfb5, 0x2900, 0x6016, 0x6023, 0x0001, 0xa868, 0xd88c, 0x0108,
+	0xc0f5, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c, 0x2fe7, 0x012e,
+	0x9006, 0x080c, 0x6193, 0x2001, 0x0002, 0x080c, 0x61a7, 0x2009,
+	0x0002, 0x080c, 0x9ea9, 0xa8b0, 0xd094, 0x0118, 0xb8bc, 0xc08d,
+	0xb8be, 0x9006, 0x9005, 0x012e, 0x00ee, 0x00fe, 0x00be, 0x0005,
+	0x080c, 0x53ae, 0x0118, 0x2009, 0x0007, 0x00f8, 0xa998, 0xaeb0,
+	0x080c, 0x6256, 0x1904, 0x5fe6, 0x9186, 0x007f, 0x0130, 0x080c,
+	0x657a, 0x0118, 0x2009, 0x0009, 0x0080, 0x0096, 0x080c, 0x0feb,
+	0x1120, 0x009e, 0x2009, 0x0002, 0x0040, 0x2900, 0x009e, 0xa806,
+	0x080c, 0xbd21, 0x19b0, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804,
+	0x5fed, 0xa998, 0xaeb0, 0x080c, 0x6256, 0x1904, 0x5fe6, 0x0096,
+	0x080c, 0x0feb, 0x1128, 0x009e, 0x2009, 0x0002, 0x0804, 0x60a5,
+	0x2900, 0x009e, 0xa806, 0x0096, 0x2048, 0x20a9, 0x002b, 0xb8b4,
+	0x20e0, 0xb8b8, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
+	0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0, 0xbbb8,
+	0x9398, 0x0006, 0x2398, 0x080c, 0x0f68, 0x009e, 0xa87b, 0x0000,
+	0xa883, 0x0000, 0xa897, 0x4000, 0xd684, 0x1168, 0x080c, 0x539a,
+	0xd0b4, 0x1118, 0xa89b, 0x000b, 0x00e0, 0xb800, 0xd08c, 0x0118,
+	0xa89b, 0x000c, 0x00b0, 0x080c, 0x657a, 0x0118, 0xa89b, 0x0009,
+	0x0080, 0x080c, 0x53ae, 0x0118, 0xa89b, 0x0007, 0x0050, 0x080c,
+	0xbd04, 0x1904, 0x6021, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804,
+	0x5fed, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa804, 0x8006, 0x8006,
+	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009,
+	0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041,
+	0x122f, 0x080c, 0xa332, 0x1904, 0x6021, 0x2009, 0x0002, 0x08e8,
+	0x2001, 0x0028, 0x900e, 0x0804, 0x6022, 0x2009, 0x180c, 0x210c,
+	0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001,
+	0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0804, 0x6022, 0x2001,
+	0x0029, 0x900e, 0x0804, 0x6022, 0x080c, 0x3574, 0x0804, 0x6023,
+	0x080c, 0x50d7, 0x0804, 0x6023, 0x080c, 0x4344, 0x0804, 0x6023,
+	0x080c, 0x43bd, 0x0804, 0x6023, 0x080c, 0x4419, 0x0804, 0x6023,
+	0x080c, 0x486a, 0x0804, 0x6023, 0x080c, 0x4b0f, 0x0804, 0x6023,
+	0x080c, 0x4d42, 0x0804, 0x6023, 0x080c, 0x4f3b, 0x0804, 0x6023,
+	0x080c, 0x3784, 0x0804, 0x6023, 0x00b6, 0xa974, 0xae78, 0x9684,
+	0x3fff, 0x9082, 0x4000, 0x1618, 0x9182, 0x0800, 0x1268, 0x9188,
+	0x1000, 0x2104, 0x905d, 0x0140, 0x080c, 0x657a, 0x1148, 0x00e9,
+	0x080c, 0x6381, 0x9006, 0x00b0, 0x2001, 0x0028, 0x900e, 0x0090,
+	0x9082, 0x0006, 0x1240, 0xb900, 0xd1fc, 0x0d88, 0x2001, 0x0029,
+	0x2009, 0x1000, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018, 0x2001,
+	0x0029, 0x900e, 0x9005, 0x00be, 0x0005, 0x0126, 0x2091, 0x8000,
+	0xb850, 0x900d, 0x0150, 0x2900, 0x0096, 0x2148, 0xa802, 0x009e,
+	0xa803, 0x0000, 0xb852, 0x012e, 0x0005, 0x2900, 0xb852, 0xb84e,
+	0xa803, 0x0000, 0x0cc0, 0x0126, 0x2091, 0x8000, 0xb84c, 0x9005,
+	0x0170, 0x00e6, 0x2071, 0x19bf, 0x7004, 0x9086, 0x0002, 0x0168,
+	0x00ee, 0xb84c, 0xa802, 0x2900, 0xb84e, 0x012e, 0x0005, 0x2900,
+	0xb852, 0xb84e, 0xa803, 0x0000, 0x0cc0, 0x701c, 0x9b06, 0x1d80,
+	0xb84c, 0x00a6, 0x2050, 0xb000, 0xa802, 0x2900, 0xb002, 0x00ae,
+	0x00ee, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0xb84c, 0x904d,
+	0x0130, 0xa800, 0x9005, 0x1108, 0xb852, 0xb84e, 0x9905, 0x012e,
+	0x0005, 0xb84c, 0x904d, 0x0130, 0xa800, 0x9005, 0x1108, 0xb852,
+	0xb84e, 0x9905, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x0026, 0x2091,
+	0x8000, 0x6210, 0x2258, 0xba00, 0x9005, 0x0110, 0xc285, 0x0008,
+	0xc284, 0xba02, 0x002e, 0x00ce, 0x012e, 0x00be, 0x0005, 0x00b6,
+	0x0126, 0x00c6, 0x2091, 0x8000, 0x6210, 0x2258, 0xba04, 0x0006,
+	0x9086, 0x0006, 0x1170, 0xb89c, 0xd0ac, 0x0158, 0x080c, 0x6576,
+	0x0140, 0x9284, 0xff00, 0x8007, 0x9086, 0x0007, 0x1110, 0x2011,
+	0x0600, 0x000e, 0x9294, 0xff00, 0x9215, 0xba06, 0x0006, 0x9086,
+	0x0006, 0x1120, 0xba90, 0x82ff, 0x090c, 0x0db4, 0x000e, 0x00ce,
+	0x012e, 0x00be, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000,
+	0x6210, 0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1168, 0xb89c,
+	0xd0a4, 0x0150, 0x080c, 0x6572, 0x1138, 0x9284, 0x00ff, 0x9086,
+	0x0007, 0x1110, 0x2011, 0x0006, 0x000e, 0x9294, 0x00ff, 0x8007,
+	0x9215, 0xba06, 0x00ce, 0x012e, 0x00be, 0x0005, 0x9182, 0x0800,
+	0x0218, 0x9085, 0x0001, 0x0005, 0x00d6, 0x0026, 0x9190, 0x1000,
+	0x2204, 0x905d, 0x1180, 0x0096, 0x080c, 0x0feb, 0x2958, 0x009e,
+	0x0160, 0x2b00, 0x2012, 0xb85c, 0xb8ba, 0xb860, 0xb8b6, 0x9006,
+	0xb8a6, 0x080c, 0x5cff, 0x9006, 0x0010, 0x9085, 0x0001, 0x002e,
+	0x00de, 0x0005, 0x00b6, 0x0096, 0x0126, 0x2091, 0x8000, 0x0026,
+	0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0458, 0x00d6, 0x9190,
+	0x1000, 0x2204, 0x905d, 0x0518, 0x2013, 0x0000, 0xb8a4, 0x904d,
+	0x0110, 0x080c, 0x101d, 0x00d6, 0x00c6, 0xb8ac, 0x2060, 0x8cff,
+	0x0168, 0x600c, 0x0006, 0x6014, 0x2048, 0x080c, 0xbb3b, 0x0110,
+	0x080c, 0x0f9d, 0x080c, 0x9e2f, 0x00ce, 0x0c88, 0x00ce, 0x00de,
+	0x2b48, 0xb8b8, 0xb85e, 0xb8b4, 0xb862, 0x080c, 0x102d, 0x00de,
+	0x9006, 0x002e, 0x012e, 0x009e, 0x00be, 0x0005, 0x0016, 0x9182,
+	0x0800, 0x0218, 0x9085, 0x0001, 0x0030, 0x9188, 0x1000, 0x2104,
+	0x905d, 0x0dc0, 0x9006, 0x001e, 0x0005, 0x00d6, 0x0156, 0x0136,
+	0x0146, 0x9006, 0xb80a, 0xb80e, 0xb800, 0xc08c, 0xb802, 0x080c,
+	0x6faa, 0x1510, 0xb8a0, 0x9086, 0x007e, 0x0120, 0x080c, 0x9dae,
+	0x11d8, 0x0078, 0x7040, 0xd0e4, 0x01b8, 0x00c6, 0x2061, 0x195a,
+	0x7048, 0x2062, 0x704c, 0x6006, 0x7050, 0x600a, 0x7054, 0x600e,
+	0x00ce, 0x703c, 0x2069, 0x0140, 0x9005, 0x1110, 0x2001, 0x0001,
+	0x6886, 0x2069, 0x1800, 0x68b2, 0x7040, 0xb85e, 0x7048, 0xb862,
+	0x704c, 0xb866, 0x20e1, 0x0000, 0x2099, 0x0276, 0xb8b4, 0x20e8,
+	0xb8b8, 0x9088, 0x000a, 0x21a0, 0x20a9, 0x0004, 0x4003, 0x2099,
+	0x027a, 0x9088, 0x0006, 0x21a0, 0x20a9, 0x0004, 0x4003, 0x2069,
+	0x0200, 0x6817, 0x0001, 0x7040, 0xb86a, 0x7144, 0xb96e, 0x7048,
+	0xb872, 0x7050, 0xb876, 0x2069, 0x0200, 0x6817, 0x0000, 0xb8a0,
+	0x9086, 0x007e, 0x1110, 0x7144, 0xb96e, 0x9182, 0x0211, 0x1218,
+	0x2009, 0x0008, 0x0400, 0x9182, 0x0259, 0x1218, 0x2009, 0x0007,
+	0x00d0, 0x9182, 0x02c1, 0x1218, 0x2009, 0x0006, 0x00a0, 0x9182,
+	0x0349, 0x1218, 0x2009, 0x0005, 0x0070, 0x9182, 0x0421, 0x1218,
+	0x2009, 0x0004, 0x0040, 0x9182, 0x0581, 0x1218, 0x2009, 0x0003,
+	0x0010, 0x2009, 0x0002, 0xb992, 0x014e, 0x013e, 0x015e, 0x00de,
+	0x0005, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260, 0x7034, 0xb896,
+	0x703c, 0xb89a, 0x7054, 0xb89e, 0x0036, 0xbbbc, 0xc384, 0xba00,
+	0x2009, 0x187b, 0x210c, 0xd0bc, 0x0120, 0xd1ec, 0x0110, 0xc2ad,
+	0x0008, 0xc2ac, 0xd0c4, 0x0148, 0xd1e4, 0x0138, 0xc2bd, 0xd0cc,
+	0x0128, 0xd38c, 0x1108, 0xc385, 0x0008, 0xc2bc, 0xba02, 0xbbbe,
+	0x003e, 0x00ee, 0x002e, 0x001e, 0x0005, 0x0096, 0x0126, 0x2091,
+	0x8000, 0xb8a4, 0x904d, 0x0578, 0xa900, 0x81ff, 0x15c0, 0xaa04,
+	0x9282, 0x0010, 0x16c8, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x8906,
+	0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0, 0x9080,
+	0x0004, 0x2098, 0x2009, 0x0010, 0x20a9, 0x0001, 0x4002, 0x9086,
+	0xffff, 0x0120, 0x8109, 0x1dd0, 0x080c, 0x0db4, 0x3c00, 0x20e8,
+	0x3300, 0x8001, 0x20a0, 0x4604, 0x8210, 0xaa06, 0x01de, 0x01ce,
+	0x014e, 0x013e, 0x0060, 0x080c, 0x0feb, 0x0170, 0x2900, 0xb8a6,
+	0xa803, 0x0000, 0x080c, 0x6412, 0xa807, 0x0001, 0xae12, 0x9085,
+	0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0126, 0x2091,
+	0x8000, 0x0096, 0xb8a4, 0x904d, 0x0188, 0xa800, 0x9005, 0x1150,
+	0x080c, 0x6421, 0x1158, 0xa804, 0x908a, 0x0002, 0x0218, 0x8001,
+	0xa806, 0x0020, 0x080c, 0x101d, 0xb8a7, 0x0000, 0x009e, 0x012e,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x8415, 0x012e, 0x0005,
+	0x901e, 0x0010, 0x2019, 0x0001, 0x900e, 0x0126, 0x2091, 0x8000,
+	0xb84c, 0x2048, 0xb800, 0xd0dc, 0x1170, 0x89ff, 0x0500, 0x83ff,
+	0x0120, 0xa878, 0x9606, 0x0158, 0x0030, 0xa86c, 0x9406, 0x1118,
+	0xa870, 0x9506, 0x0120, 0x2908, 0xa800, 0x2048, 0x0c70, 0x080c,
+	0x979a, 0xaa00, 0xb84c, 0x9906, 0x1110, 0xba4e, 0x0020, 0x00a6,
+	0x2150, 0xb202, 0x00ae, 0x82ff, 0x1110, 0xb952, 0x89ff, 0x012e,
+	0x0005, 0x9016, 0x0489, 0x1110, 0x2011, 0x0001, 0x0005, 0x080c,
+	0x6476, 0x0128, 0x080c, 0xbbf8, 0x0010, 0x9085, 0x0001, 0x0005,
+	0x080c, 0x6476, 0x0128, 0x080c, 0xbb9d, 0x0010, 0x9085, 0x0001,
+	0x0005, 0x080c, 0x6476, 0x0128, 0x080c, 0xbbf5, 0x0010, 0x9085,
+	0x0001, 0x0005, 0x080c, 0x6476, 0x0128, 0x080c, 0xbbbc, 0x0010,
+	0x9085, 0x0001, 0x0005, 0x080c, 0x6476, 0x0128, 0x080c, 0xbc39,
+	0x0010, 0x9085, 0x0001, 0x0005, 0xb8a4, 0x900d, 0x1118, 0x9085,
+	0x0001, 0x0005, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e,
 	0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080,
 	0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606,
-	0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0068, 0x0146, 0x01d6,
-	0x3300, 0x8001, 0x20a0, 0x3c00, 0x20e8, 0x2001, 0xffff, 0x4004,
-	0x01de, 0x014e, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0096, 0x0126,
-	0x2091, 0x8000, 0xb8a4, 0x904d, 0x1128, 0x080c, 0x0feb, 0x0168,
-	0x2900, 0xb8a6, 0x080c, 0x6403, 0xa803, 0x0001, 0xa807, 0x0000,
-	0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0096,
-	0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d, 0x0130, 0xb8a7, 0x0000,
-	0x080c, 0x101d, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0xb89c,
-	0xd0a4, 0x0005, 0x00b6, 0x00f6, 0x080c, 0x6f9b, 0x01b0, 0x71c0,
-	0x81ff, 0x1198, 0x71d8, 0xd19c, 0x0180, 0x2001, 0x007e, 0x9080,
-	0x1000, 0x2004, 0x905d, 0x0148, 0xb804, 0x9084, 0x00ff, 0x9086,
-	0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x2079, 0x1853, 0x7804,
-	0x00d0, 0x0156, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6247,
-	0x1168, 0xb804, 0x9084, 0xff00, 0x8007, 0x9096, 0x0004, 0x0118,
-	0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x001e, 0x8108,
-	0x1f04, 0x648d, 0x015e, 0x080c, 0x6529, 0x0120, 0x2001, 0x1955,
-	0x200c, 0x0030, 0x2079, 0x1853, 0x7804, 0x0030, 0x2009, 0x07d0,
-	0x2011, 0x64b7, 0x080c, 0x80b3, 0x00fe, 0x00be, 0x0005, 0x00b6,
-	0x2011, 0x64b7, 0x080c, 0x8021, 0x080c, 0x6529, 0x01d8, 0x2001,
-	0x107e, 0x2004, 0x2058, 0xb900, 0xc1ec, 0xb902, 0x080c, 0x6567,
-	0x0130, 0x2009, 0x07d0, 0x2011, 0x64b7, 0x080c, 0x80b3, 0x00e6,
-	0x2071, 0x1800, 0x9006, 0x707a, 0x705c, 0x707e, 0x080c, 0x2dbd,
-	0x00ee, 0x04b0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e, 0x0016,
-	0x080c, 0x6247, 0x1538, 0xb800, 0xd0ec, 0x0520, 0x0046, 0xbaa0,
-	0x2220, 0x9006, 0x2009, 0x0029, 0x080c, 0xd54b, 0xb800, 0xc0e5,
-	0xc0ec, 0xb802, 0x080c, 0x6563, 0x2001, 0x0707, 0x1128, 0xb804,
-	0x9084, 0x00ff, 0x9085, 0x0700, 0xb806, 0x2019, 0x0029, 0x080c,
-	0x8564, 0x0076, 0x903e, 0x080c, 0x8452, 0x900e, 0x080c, 0xd2bc,
-	0x007e, 0x004e, 0x001e, 0x8108, 0x1f04, 0x64df, 0x00ce, 0x015e,
-	0x00be, 0x0005, 0x00b6, 0x6010, 0x2058, 0xb800, 0xc0ec, 0xb802,
-	0x00be, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ac,
-	0x0005, 0x6010, 0x00b6, 0x905d, 0x0108, 0xb800, 0x00be, 0xd0bc,
-	0x0005, 0x00b6, 0x00f6, 0x2001, 0x107e, 0x2004, 0x905d, 0x0110,
-	0xb800, 0xd0ec, 0x00fe, 0x00be, 0x0005, 0x0126, 0x0026, 0x2091,
-	0x8000, 0x0006, 0xbaa0, 0x9290, 0x1000, 0x2204, 0x9b06, 0x190c,
-	0x0db4, 0x000e, 0xba00, 0x9005, 0x0110, 0xc2fd, 0x0008, 0xc2fc,
-	0xba02, 0x002e, 0x012e, 0x0005, 0x2011, 0x1836, 0x2204, 0xd0cc,
-	0x0138, 0x2001, 0x1953, 0x200c, 0x2011, 0x6559, 0x080c, 0x80b3,
-	0x0005, 0x2011, 0x6559, 0x080c, 0x8021, 0x2011, 0x1836, 0x2204,
-	0xc0cc, 0x2012, 0x0005, 0x080c, 0x538f, 0xd0ac, 0x0005, 0x080c,
-	0x538f, 0xd0a4, 0x0005, 0x0016, 0xb904, 0x9184, 0x00ff, 0x908e,
-	0x0006, 0x001e, 0x0005, 0x0016, 0xb904, 0x9184, 0xff00, 0x8007,
-	0x908e, 0x0006, 0x001e, 0x0005, 0x00b6, 0x00f6, 0x080c, 0xc22c,
-	0x0158, 0x70d8, 0x9084, 0x0028, 0x0138, 0x2001, 0x107f, 0x2004,
-	0x905d, 0x0110, 0xb8bc, 0xd094, 0x00fe, 0x00be, 0x0005, 0x0006,
-	0x0016, 0x0036, 0x0046, 0x0076, 0x00b6, 0x2001, 0x1817, 0x203c,
-	0x9780, 0x313a, 0x203d, 0x97bc, 0xff00, 0x873f, 0x9006, 0x2018,
-	0x2008, 0x9284, 0x8000, 0x0110, 0x2019, 0x0001, 0x9294, 0x7fff,
-	0x2100, 0x9706, 0x0190, 0x91a0, 0x1000, 0x2404, 0x905d, 0x0168,
-	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x1138, 0x83ff, 0x0118,
-	0xb89c, 0xd0a4, 0x0110, 0x8211, 0x0158, 0x8108, 0x83ff, 0x0120,
-	0x9182, 0x0800, 0x0e28, 0x0068, 0x9182, 0x007e, 0x0e08, 0x0048,
-	0x00be, 0x007e, 0x004e, 0x003e, 0x001e, 0x9085, 0x0001, 0x000e,
-	0x0005, 0x00be, 0x007e, 0x004e, 0x003e, 0x001e, 0x9006, 0x000e,
-	0x0005, 0x0046, 0x0056, 0x0076, 0x00b6, 0x2100, 0x9084, 0x7fff,
-	0x9080, 0x1000, 0x2004, 0x905d, 0x0130, 0xb804, 0x9084, 0x00ff,
-	0x9086, 0x0006, 0x0550, 0x9184, 0x8000, 0x0580, 0x2001, 0x1817,
-	0x203c, 0x9780, 0x313a, 0x203d, 0x97bc, 0xff00, 0x873f, 0x9006,
-	0x2020, 0x2400, 0x9706, 0x01a0, 0x94a8, 0x1000, 0x2504, 0x905d,
-	0x0178, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x1148, 0xb89c,
-	0xd0a4, 0x0130, 0xb814, 0x9206, 0x1118, 0xb810, 0x9306, 0x0128,
-	0x8420, 0x9482, 0x0800, 0x0e28, 0x0048, 0x918c, 0x7fff, 0x00be,
-	0x007e, 0x005e, 0x004e, 0x9085, 0x0001, 0x0005, 0x918c, 0x7fff,
-	0x00be, 0x007e, 0x005e, 0x004e, 0x9006, 0x0005, 0x2071, 0x1906,
-	0x7003, 0x0001, 0x7007, 0x0000, 0x9006, 0x7012, 0x7016, 0x701a,
-	0x701e, 0x700a, 0x7046, 0x0005, 0x0016, 0x00e6, 0x2071, 0x1919,
-	0x900e, 0x710a, 0x080c, 0x538f, 0xd0fc, 0x1140, 0x080c, 0x538f,
-	0x900e, 0xd09c, 0x0108, 0x8108, 0x7102, 0x0400, 0x2001, 0x1873,
-	0x200c, 0x9184, 0x0007, 0x9006, 0x0002, 0x663e, 0x663e, 0x663e,
-	0x663e, 0x663e, 0x6655, 0x6663, 0x663e, 0x7003, 0x0003, 0x2009,
-	0x1874, 0x210c, 0x9184, 0xff00, 0x8007, 0x9005, 0x1110, 0x2001,
-	0x0002, 0x7006, 0x0018, 0x7003, 0x0005, 0x0c88, 0x00ee, 0x001e,
-	0x0005, 0x00e6, 0x2071, 0x0050, 0x684c, 0x9005, 0x1150, 0x00e6,
-	0x2071, 0x1906, 0x7028, 0xc085, 0x702a, 0x00ee, 0x9085, 0x0001,
-	0x0488, 0x6844, 0x9005, 0x0158, 0x080c, 0x72f1, 0x6a60, 0x9200,
-	0x7002, 0x6864, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6860,
-	0x7002, 0x6864, 0x7006, 0x6868, 0x700a, 0x686c, 0x700e, 0x6844,
-	0x9005, 0x1110, 0x7012, 0x7016, 0x684c, 0x701a, 0x701c, 0x9085,
-	0x0040, 0x701e, 0x7037, 0x0019, 0x702b, 0x0001, 0x00e6, 0x2071,
-	0x1906, 0x7028, 0xc084, 0x702a, 0x7007, 0x0001, 0x700b, 0x0000,
-	0x00ee, 0x9006, 0x00ee, 0x0005, 0xa868, 0xd0fc, 0x11d8, 0x00e6,
-	0x0026, 0x2001, 0x1919, 0x2004, 0x9005, 0x0904, 0x6896, 0xa87c,
-	0xd0bc, 0x1904, 0x6896, 0xa978, 0xa874, 0x9105, 0x1904, 0x6896,
-	0x2001, 0x1919, 0x2004, 0x0002, 0x6896, 0x66ef, 0x672b, 0x672b,
-	0x6896, 0x672b, 0x0005, 0xa868, 0xd0fc, 0x1500, 0x00e6, 0x0026,
-	0x2009, 0x1919, 0x210c, 0x81ff, 0x0904, 0x6896, 0xa87c, 0xd0cc,
-	0x0904, 0x6896, 0xa880, 0x9084, 0x00ff, 0x9086, 0x0001, 0x1904,
-	0x6896, 0x9186, 0x0003, 0x0904, 0x672b, 0x9186, 0x0005, 0x0904,
-	0x672b, 0xa84f, 0x8021, 0xa853, 0x0017, 0x0028, 0x0005, 0xa84f,
-	0x8020, 0xa853, 0x0016, 0x2071, 0x1906, 0x701c, 0x9005, 0x1904,
-	0x6a4a, 0x0e04, 0x6a95, 0x2071, 0x0000, 0xa84c, 0x7082, 0xa850,
-	0x7032, 0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x2071, 0x1800,
-	0x2011, 0x0001, 0xa804, 0x900d, 0x702c, 0x1158, 0xa802, 0x2900,
-	0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x7f46, 0x002e, 0x00ee,
-	0x0005, 0x0096, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff,
-	0x1dc8, 0x009e, 0x0c58, 0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050,
-	0x2071, 0x1906, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x681a,
-	0x782c, 0x908c, 0x0780, 0x190c, 0x6bbc, 0x8004, 0x8004, 0x8004,
-	0x9084, 0x0003, 0x0002, 0x6749, 0x681a, 0x676e, 0x67b5, 0x080c,
-	0x0db4, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1170,
-	0x2071, 0x19ca, 0x703c, 0x9005, 0x1328, 0x2001, 0x191a, 0x2004,
-	0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c,
-	0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e,
-	0x70bc, 0x9200, 0x70be, 0x080c, 0x7f46, 0x0c10, 0x2071, 0x1800,
-	0x2900, 0x7822, 0xa804, 0x900d, 0x1580, 0x7824, 0x00e6, 0x2071,
-	0x0040, 0x712c, 0xd19c, 0x1148, 0x2009, 0x182f, 0x210c, 0x918a,
-	0x0040, 0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c,
-	0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x7f46,
-	0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd0a4, 0x19f0, 0x2071,
-	0x19ca, 0x703c, 0x9005, 0x1328, 0x2001, 0x191a, 0x2004, 0x8005,
+	0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0008, 0x9006, 0x01ce,
+	0x013e, 0x0005, 0x0146, 0x01d6, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0004, 0x20a0, 0x20a9, 0x0010, 0x2009, 0xffff, 0x4104, 0x01de,
+	0x014e, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e, 0x810e,
+	0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080, 0x0004,
+	0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606, 0x0128,
+	0x8109, 0x1dd8, 0x9085, 0x0001, 0x0068, 0x0146, 0x01d6, 0x3300,
+	0x8001, 0x20a0, 0x3c00, 0x20e8, 0x2001, 0xffff, 0x4004, 0x01de,
+	0x014e, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0096, 0x0126, 0x2091,
+	0x8000, 0xb8a4, 0x904d, 0x1128, 0x080c, 0x0feb, 0x0168, 0x2900,
+	0xb8a6, 0x080c, 0x6412, 0xa803, 0x0001, 0xa807, 0x0000, 0x9085,
+	0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0096, 0x0126,
+	0x2091, 0x8000, 0xb8a4, 0x904d, 0x0130, 0xb8a7, 0x0000, 0x080c,
+	0x101d, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0xb89c, 0xd0a4,
+	0x0005, 0x00b6, 0x00f6, 0x080c, 0x6faa, 0x01b0, 0x71c0, 0x81ff,
+	0x1198, 0x71d8, 0xd19c, 0x0180, 0x2001, 0x007e, 0x9080, 0x1000,
+	0x2004, 0x905d, 0x0148, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
+	0x1118, 0xb800, 0xc0ed, 0xb802, 0x2079, 0x185b, 0x7804, 0x00d0,
+	0x0156, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x6256, 0x1168,
+	0xb804, 0x9084, 0xff00, 0x8007, 0x9096, 0x0004, 0x0118, 0x9086,
+	0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x001e, 0x8108, 0x1f04,
+	0x649c, 0x015e, 0x080c, 0x6538, 0x0120, 0x2001, 0x195d, 0x200c,
+	0x0030, 0x2079, 0x185b, 0x7804, 0x0030, 0x2009, 0x07d0, 0x2011,
+	0x64c6, 0x080c, 0x80d1, 0x00fe, 0x00be, 0x0005, 0x00b6, 0x2011,
+	0x64c6, 0x080c, 0x803f, 0x080c, 0x6538, 0x01d8, 0x2001, 0x107e,
+	0x2004, 0x2058, 0xb900, 0xc1ec, 0xb902, 0x080c, 0x6576, 0x0130,
+	0x2009, 0x07d0, 0x2011, 0x64c6, 0x080c, 0x80d1, 0x00e6, 0x2071,
+	0x1800, 0x9006, 0x707a, 0x705c, 0x707e, 0x080c, 0x2dc8, 0x00ee,
+	0x04b0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c,
+	0x6256, 0x1538, 0xb800, 0xd0ec, 0x0520, 0x0046, 0xbaa0, 0x2220,
+	0x9006, 0x2009, 0x0029, 0x080c, 0xd564, 0xb800, 0xc0e5, 0xc0ec,
+	0xb802, 0x080c, 0x6572, 0x2001, 0x0707, 0x1128, 0xb804, 0x9084,
+	0x00ff, 0x9085, 0x0700, 0xb806, 0x2019, 0x0029, 0x080c, 0x8582,
+	0x0076, 0x903e, 0x080c, 0x8470, 0x900e, 0x080c, 0xd2d5, 0x007e,
+	0x004e, 0x001e, 0x8108, 0x1f04, 0x64ee, 0x00ce, 0x015e, 0x00be,
+	0x0005, 0x00b6, 0x6010, 0x2058, 0xb800, 0xc0ec, 0xb802, 0x00be,
+	0x0005, 0x7810, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ac, 0x0005,
+	0x6010, 0x00b6, 0x905d, 0x0108, 0xb800, 0x00be, 0xd0bc, 0x0005,
+	0x00b6, 0x00f6, 0x2001, 0x107e, 0x2004, 0x905d, 0x0110, 0xb800,
+	0xd0ec, 0x00fe, 0x00be, 0x0005, 0x0126, 0x0026, 0x2091, 0x8000,
+	0x0006, 0xbaa0, 0x9290, 0x1000, 0x2204, 0x9b06, 0x190c, 0x0db4,
+	0x000e, 0xba00, 0x9005, 0x0110, 0xc2fd, 0x0008, 0xc2fc, 0xba02,
+	0x002e, 0x012e, 0x0005, 0x2011, 0x1836, 0x2204, 0xd0cc, 0x0138,
+	0x2001, 0x195b, 0x200c, 0x2011, 0x6568, 0x080c, 0x80d1, 0x0005,
+	0x2011, 0x6568, 0x080c, 0x803f, 0x2011, 0x1836, 0x2204, 0xc0cc,
+	0x2012, 0x0005, 0x080c, 0x539a, 0xd0ac, 0x0005, 0x080c, 0x539a,
+	0xd0a4, 0x0005, 0x0016, 0xb904, 0x9184, 0x00ff, 0x908e, 0x0006,
+	0x001e, 0x0005, 0x0016, 0xb904, 0x9184, 0xff00, 0x8007, 0x908e,
+	0x0006, 0x001e, 0x0005, 0x00b6, 0x00f6, 0x080c, 0xc23b, 0x0158,
+	0x70d8, 0x9084, 0x0028, 0x0138, 0x2001, 0x107f, 0x2004, 0x905d,
+	0x0110, 0xb8bc, 0xd094, 0x00fe, 0x00be, 0x0005, 0x0006, 0x0016,
+	0x0036, 0x0046, 0x0076, 0x00b6, 0x2001, 0x1817, 0x203c, 0x9780,
+	0x3145, 0x203d, 0x97bc, 0xff00, 0x873f, 0x9006, 0x2018, 0x2008,
+	0x9284, 0x8000, 0x0110, 0x2019, 0x0001, 0x9294, 0x7fff, 0x2100,
+	0x9706, 0x0190, 0x91a0, 0x1000, 0x2404, 0x905d, 0x0168, 0xb804,
+	0x9084, 0x00ff, 0x9086, 0x0006, 0x1138, 0x83ff, 0x0118, 0xb89c,
+	0xd0a4, 0x0110, 0x8211, 0x0158, 0x8108, 0x83ff, 0x0120, 0x9182,
+	0x0800, 0x0e28, 0x0068, 0x9182, 0x007e, 0x0e08, 0x0048, 0x00be,
+	0x007e, 0x004e, 0x003e, 0x001e, 0x9085, 0x0001, 0x000e, 0x0005,
+	0x00be, 0x007e, 0x004e, 0x003e, 0x001e, 0x9006, 0x000e, 0x0005,
+	0x0046, 0x0056, 0x0076, 0x00b6, 0x2100, 0x9084, 0x7fff, 0x9080,
+	0x1000, 0x2004, 0x905d, 0x0130, 0xb804, 0x9084, 0x00ff, 0x9086,
+	0x0006, 0x0550, 0x9184, 0x8000, 0x0580, 0x2001, 0x1817, 0x203c,
+	0x9780, 0x3145, 0x203d, 0x97bc, 0xff00, 0x873f, 0x9006, 0x2020,
+	0x2400, 0x9706, 0x01a0, 0x94a8, 0x1000, 0x2504, 0x905d, 0x0178,
+	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x1148, 0xb89c, 0xd0a4,
+	0x0130, 0xb814, 0x9206, 0x1118, 0xb810, 0x9306, 0x0128, 0x8420,
+	0x9482, 0x0800, 0x0e28, 0x0048, 0x918c, 0x7fff, 0x00be, 0x007e,
+	0x005e, 0x004e, 0x9085, 0x0001, 0x0005, 0x918c, 0x7fff, 0x00be,
+	0x007e, 0x005e, 0x004e, 0x9006, 0x0005, 0x2071, 0x190e, 0x7003,
+	0x0001, 0x7007, 0x0000, 0x9006, 0x7012, 0x7016, 0x701a, 0x701e,
+	0x700a, 0x7046, 0x0005, 0x0016, 0x00e6, 0x2071, 0x1921, 0x900e,
+	0x710a, 0x080c, 0x539a, 0xd0fc, 0x1140, 0x080c, 0x539a, 0x900e,
+	0xd09c, 0x0108, 0x8108, 0x7102, 0x0400, 0x2001, 0x187b, 0x200c,
+	0x9184, 0x0007, 0x9006, 0x0002, 0x664d, 0x664d, 0x664d, 0x664d,
+	0x664d, 0x6664, 0x6672, 0x664d, 0x7003, 0x0003, 0x2009, 0x187c,
+	0x210c, 0x9184, 0xff00, 0x8007, 0x9005, 0x1110, 0x2001, 0x0002,
+	0x7006, 0x0018, 0x7003, 0x0005, 0x0c88, 0x00ee, 0x001e, 0x0005,
+	0x00e6, 0x2071, 0x0050, 0x684c, 0x9005, 0x1150, 0x00e6, 0x2071,
+	0x190e, 0x7028, 0xc085, 0x702a, 0x00ee, 0x9085, 0x0001, 0x0488,
+	0x6844, 0x9005, 0x0158, 0x080c, 0x72fe, 0x6a60, 0x9200, 0x7002,
+	0x6864, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6860, 0x7002,
+	0x6864, 0x7006, 0x6868, 0x700a, 0x686c, 0x700e, 0x6844, 0x9005,
+	0x1110, 0x7012, 0x7016, 0x684c, 0x701a, 0x701c, 0x9085, 0x0040,
+	0x701e, 0x7037, 0x0019, 0x702b, 0x0001, 0x00e6, 0x2071, 0x190e,
+	0x7028, 0xc084, 0x702a, 0x7007, 0x0001, 0x700b, 0x0000, 0x00ee,
+	0x9006, 0x00ee, 0x0005, 0xa868, 0xd0fc, 0x11d8, 0x00e6, 0x0026,
+	0x2001, 0x1921, 0x2004, 0x9005, 0x0904, 0x68a5, 0xa87c, 0xd0bc,
+	0x1904, 0x68a5, 0xa978, 0xa874, 0x9105, 0x1904, 0x68a5, 0x2001,
+	0x1921, 0x2004, 0x0002, 0x68a5, 0x66fe, 0x673a, 0x673a, 0x68a5,
+	0x673a, 0x0005, 0xa868, 0xd0fc, 0x1500, 0x00e6, 0x0026, 0x2009,
+	0x1921, 0x210c, 0x81ff, 0x0904, 0x68a5, 0xa87c, 0xd0cc, 0x0904,
+	0x68a5, 0xa880, 0x9084, 0x00ff, 0x9086, 0x0001, 0x1904, 0x68a5,
+	0x9186, 0x0003, 0x0904, 0x673a, 0x9186, 0x0005, 0x0904, 0x673a,
+	0xa84f, 0x8021, 0xa853, 0x0017, 0x0028, 0x0005, 0xa84f, 0x8020,
+	0xa853, 0x0016, 0x2071, 0x190e, 0x701c, 0x9005, 0x1904, 0x6a59,
+	0x0e04, 0x6aa4, 0x2071, 0x0000, 0xa84c, 0x7082, 0xa850, 0x7032,
+	0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001,
+	0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x2071, 0x1800, 0x2011,
+	0x0001, 0xa804, 0x900d, 0x702c, 0x1158, 0xa802, 0x2900, 0x702e,
+	0x70bc, 0x9200, 0x70be, 0x080c, 0x7f64, 0x002e, 0x00ee, 0x0005,
+	0x0096, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
+	0x009e, 0x0c58, 0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050, 0x2071,
+	0x190e, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x6829, 0x782c,
+	0x908c, 0x0780, 0x190c, 0x6bcb, 0x8004, 0x8004, 0x8004, 0x9084,
+	0x0003, 0x0002, 0x6758, 0x6829, 0x677d, 0x67c4, 0x080c, 0x0db4,
+	0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1170, 0x2071,
+	0x19d2, 0x703c, 0x9005, 0x1328, 0x2001, 0x1922, 0x2004, 0x8005,
 	0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148,
 	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc,
-	0x9200, 0x70be, 0x080c, 0x7f46, 0x0800, 0x0096, 0x00e6, 0x7824,
-	0x2048, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc,
-	0x8000, 0x70be, 0x080c, 0x7f46, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x6bbc, 0xd0a4, 0x1d60, 0x00ee, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x6bbc, 0xd09c, 0x11a0, 0x009e, 0x2900, 0x7822, 0xa804, 0x900d,
-	0x1560, 0x2071, 0x19ca, 0x703c, 0x9005, 0x1328, 0x2001, 0x191a,
-	0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x009e,
-	0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110,
-	0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1170, 0x2071,
-	0x19ca, 0x703c, 0x9005, 0x1328, 0x2001, 0x191a, 0x2004, 0x8005,
-	0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016,
-	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
-	0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x7f46, 0x00fe, 0x002e,
-	0x00ee, 0x0005, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d,
-	0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d,
-	0x1904, 0x686f, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd09c,
-	0x1198, 0x701c, 0x904d, 0x0180, 0x7010, 0x8001, 0x7012, 0x1108,
-	0x701a, 0xa800, 0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6bbc, 0xd09c, 0x0d68, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x6bbc, 0xd0a4, 0x01b0, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
-	0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c,
-	0x7f46, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd0a4, 0x1d60,
-	0x00ee, 0x2071, 0x19ca, 0x703c, 0x9005, 0x1328, 0x2001, 0x191a,
-	0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6,
-	0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
-	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c,
-	0x7f46, 0x00ee, 0x0804, 0x682a, 0xa868, 0xd0fc, 0x1904, 0x68d2,
-	0x0096, 0xa804, 0xa807, 0x0000, 0x904d, 0x190c, 0x0f9d, 0x009e,
-	0x0018, 0xa868, 0xd0fc, 0x15f0, 0x00e6, 0x0026, 0xa84f, 0x0000,
-	0x00f6, 0x2079, 0x0050, 0x2071, 0x1800, 0x70e8, 0x8001, 0x01d0,
-	0x1678, 0x2071, 0x1906, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904,
-	0x69c8, 0x782c, 0x908c, 0x0780, 0x190c, 0x6bbc, 0x8004, 0x8004,
-	0x8004, 0x9084, 0x0003, 0x0002, 0x68d3, 0x69c8, 0x68ee, 0x695b,
-	0x080c, 0x0db4, 0x70eb, 0x0fa0, 0x71e4, 0x8107, 0x9106, 0x9094,
-	0x00c0, 0x9184, 0xff3f, 0x9205, 0x70e6, 0x3b08, 0x3a00, 0x9104,
-	0x918d, 0x00c0, 0x21d8, 0x9084, 0xff3f, 0x9205, 0x20d0, 0x0888,
-	0x70ea, 0x0878, 0x0005, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804,
-	0x900d, 0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c,
+	0x9200, 0x70be, 0x080c, 0x7f64, 0x0c10, 0x2071, 0x1800, 0x2900,
+	0x7822, 0xa804, 0x900d, 0x1580, 0x7824, 0x00e6, 0x2071, 0x0040,
+	0x712c, 0xd19c, 0x1148, 0x2009, 0x182f, 0x210c, 0x918a, 0x0040,
+	0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802,
+	0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x7f64, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6bcb, 0xd0a4, 0x19f0, 0x2071, 0x19d2,
+	0x703c, 0x9005, 0x1328, 0x2001, 0x1922, 0x2004, 0x8005, 0x703e,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904,
+	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200,
+	0x70be, 0x080c, 0x7f64, 0x0800, 0x0096, 0x00e6, 0x7824, 0x2048,
+	0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000,
+	0x70be, 0x080c, 0x7f64, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb,
+	0xd0a4, 0x1d60, 0x00ee, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb,
+	0xd09c, 0x11a0, 0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x1560,
+	0x2071, 0x19d2, 0x703c, 0x9005, 0x1328, 0x2001, 0x1922, 0x2004,
+	0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x009e, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1170, 0x2071, 0x19d2,
+	0x703c, 0x9005, 0x1328, 0x2001, 0x1922, 0x2004, 0x8005, 0x703e,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c,
 	0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e,
-	0x70bc, 0x9200, 0x70be, 0x080c, 0x7f46, 0x0c60, 0x2071, 0x1800,
-	0x2900, 0x7822, 0xa804, 0x900d, 0x1904, 0x694a, 0x7830, 0x8007,
-	0x9084, 0x001f, 0x9082, 0x0001, 0x1220, 0x00fe, 0x002e, 0x00ee,
-	0x0005, 0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1148,
-	0x2009, 0x182f, 0x210c, 0x918a, 0x0040, 0x0218, 0x7022, 0x00ee,
-	0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc,
-	0x8000, 0x70be, 0x080c, 0x7f46, 0x782c, 0x9094, 0x0780, 0x190c,
-	0x6bbc, 0xd0a4, 0x19f0, 0x0e04, 0x6941, 0x7838, 0x7938, 0x910e,
-	0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de,
-	0x2001, 0x1917, 0x200c, 0xc184, 0x2102, 0x2091, 0x4080, 0x2001,
-	0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x00fe, 0x002e, 0x00ee,
-	0x0005, 0x2001, 0x1917, 0x200c, 0xc185, 0x2102, 0x00fe, 0x002e,
-	0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
-	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c,
-	0x7f46, 0x0804, 0x6901, 0x0096, 0x00e6, 0x7824, 0x2048, 0x2071,
-	0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be,
-	0x080c, 0x7f46, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd0a4,
-	0x1d60, 0x00ee, 0x0e04, 0x699b, 0x7838, 0x7938, 0x910e, 0x1de0,
-	0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x7044,
-	0xc084, 0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x1187, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd09c,
-	0x1170, 0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x11e0, 0x00fe,
-	0x002e, 0x00ee, 0x0005, 0x7044, 0xc085, 0x7046, 0x0c58, 0x009e,
-	0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110,
-	0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1120, 0x00fe,
-	0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
+	0x70bc, 0x9200, 0x70be, 0x080c, 0x7f64, 0x00fe, 0x002e, 0x00ee,
+	0x0005, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
+	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904,
+	0x687e, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb, 0xd09c, 0x1198,
+	0x701c, 0x904d, 0x0180, 0x7010, 0x8001, 0x7012, 0x1108, 0x701a,
+	0xa800, 0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780, 0x190c,
+	0x6bcb, 0xd09c, 0x0d68, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb,
+	0xd0a4, 0x01b0, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c,
+	0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x7f64,
+	0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb, 0xd0a4, 0x1d60, 0x00ee,
+	0x2071, 0x19d2, 0x703c, 0x9005, 0x1328, 0x2001, 0x1922, 0x2004,
+	0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071,
+	0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x7f64,
+	0x00ee, 0x0804, 0x6839, 0xa868, 0xd0fc, 0x1904, 0x68e1, 0x0096,
+	0xa804, 0xa807, 0x0000, 0x904d, 0x190c, 0x0f9d, 0x009e, 0x0018,
+	0xa868, 0xd0fc, 0x15f0, 0x00e6, 0x0026, 0xa84f, 0x0000, 0x00f6,
+	0x2079, 0x0050, 0x2071, 0x1800, 0x70e8, 0x8001, 0x01d0, 0x1678,
+	0x2071, 0x190e, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x69d7,
+	0x782c, 0x908c, 0x0780, 0x190c, 0x6bcb, 0x8004, 0x8004, 0x8004,
+	0x9084, 0x0003, 0x0002, 0x68e2, 0x69d7, 0x68fd, 0x696a, 0x080c,
+	0x0db4, 0x70eb, 0x0fa0, 0x71e4, 0x8107, 0x9106, 0x9094, 0x00c0,
+	0x9184, 0xff3f, 0x9205, 0x70e6, 0x3b08, 0x3a00, 0x9104, 0x918d,
+	0x00c0, 0x21d8, 0x9084, 0xff3f, 0x9205, 0x20d0, 0x0888, 0x70ea,
+	0x0878, 0x0005, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d,
+	0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148,
 	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc,
-	0x9200, 0x70be, 0x080c, 0x7f46, 0x00fe, 0x002e, 0x00ee, 0x0005,
+	0x9200, 0x70be, 0x080c, 0x7f64, 0x0c60, 0x2071, 0x1800, 0x2900,
+	0x7822, 0xa804, 0x900d, 0x1904, 0x6959, 0x7830, 0x8007, 0x9084,
+	0x001f, 0x9082, 0x0001, 0x1220, 0x00fe, 0x002e, 0x00ee, 0x0005,
+	0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1148, 0x2009,
+	0x182f, 0x210c, 0x918a, 0x0040, 0x0218, 0x7022, 0x00ee, 0x0058,
+	0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000,
+	0x70be, 0x080c, 0x7f64, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb,
+	0xd0a4, 0x19f0, 0x0e04, 0x6950, 0x7838, 0x7938, 0x910e, 0x1de0,
+	0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2001,
+	0x191f, 0x200c, 0xc184, 0x2102, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x1187, 0x00fe, 0x002e, 0x00ee, 0x0005,
+	0x2001, 0x191f, 0x200c, 0xc185, 0x2102, 0x00fe, 0x002e, 0x00ee,
+	0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x7f64,
+	0x0804, 0x6910, 0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c,
+	0x7f64, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb, 0xd0a4, 0x1d60,
+	0x00ee, 0x0e04, 0x69aa, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6,
+	0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084,
+	0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x1187, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb, 0xd09c, 0x1170,
+	0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x11e0, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x7044, 0xc085, 0x7046, 0x0c58, 0x009e, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1120, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904,
+	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200,
+	0x70be, 0x080c, 0x7f64, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904, 0x6a44, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6bcb, 0xd09c, 0x11b0, 0x701c, 0x904d,
+	0x0198, 0xa84c, 0x9005, 0x1180, 0x7010, 0x8001, 0x7012, 0x1108,
+	0x701a, 0xa800, 0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780,
+	0x190c, 0x6bcb, 0xd09c, 0x0d50, 0x782c, 0x9094, 0x0780, 0x190c,
+	0x6bcb, 0xd0a4, 0x05a8, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c,
+	0x7f64, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb, 0xd0a4, 0x1d60,
+	0x00ee, 0x0e04, 0x6a3d, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6,
+	0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084,
+	0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x1187, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7044, 0xc085, 0x7046,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016,
+	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
+	0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x7f64, 0x00ee, 0x0804,
+	0x69e7, 0x2071, 0x190e, 0xa803, 0x0000, 0x2908, 0x7010, 0x8000,
+	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
+	0x2148, 0xa804, 0x900d, 0x1128, 0x1e04, 0x6a84, 0x002e, 0x00ee,
+	0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
+	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be,
+	0x080c, 0x7f64, 0x0e04, 0x6a6e, 0x2071, 0x190e, 0x701c, 0x2048,
+	0xa84c, 0x900d, 0x0d18, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032,
+	0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001,
+	0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x2071, 0x190e, 0x080c,
+	0x6bb7, 0x002e, 0x00ee, 0x0005, 0x2071, 0x190e, 0xa803, 0x0000,
 	0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110,
-	0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904, 0x6a35,
-	0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd09c, 0x11b0, 0x701c,
-	0x904d, 0x0198, 0xa84c, 0x9005, 0x1180, 0x7010, 0x8001, 0x7012,
-	0x1108, 0x701a, 0xa800, 0x701e, 0x2900, 0x7822, 0x782c, 0x9094,
-	0x0780, 0x190c, 0x6bbc, 0xd09c, 0x0d50, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6bbc, 0xd0a4, 0x05a8, 0x00e6, 0x7824, 0x2048, 0x2071,
-	0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be,
-	0x080c, 0x7f46, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd0a4,
-	0x1d60, 0x00ee, 0x0e04, 0x6a2e, 0x7838, 0x7938, 0x910e, 0x1de0,
-	0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x7044,
-	0xc084, 0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x1187, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7044, 0xc085,
-	0x7046, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800,
-	0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff,
-	0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x7f46, 0x00ee,
-	0x0804, 0x69d8, 0x2071, 0x1906, 0xa803, 0x0000, 0x2908, 0x7010,
-	0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008,
-	0x711e, 0x2148, 0xa804, 0x900d, 0x1128, 0x1e04, 0x6a75, 0x002e,
+	0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1118, 0x002e,
 	0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904,
 	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200,
-	0x70be, 0x080c, 0x7f46, 0x0e04, 0x6a5f, 0x2071, 0x1906, 0x701c,
-	0x2048, 0xa84c, 0x900d, 0x0d18, 0x2071, 0x0000, 0x7182, 0xa850,
-	0x7032, 0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x2071, 0x1906,
-	0x080c, 0x6ba8, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1906, 0xa803,
-	0x0000, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
-	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1118,
-	0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
-	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc,
-	0x9200, 0x70be, 0x080c, 0x7f46, 0x002e, 0x00ee, 0x0005, 0x0006,
-	0xa87c, 0x0006, 0xa867, 0x0103, 0x20a9, 0x001c, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x001d, 0x20a0, 0x9006, 0x4004, 0x000e, 0x9084,
-	0x00ff, 0xa87e, 0x000e, 0xa87a, 0xa982, 0x0005, 0x2071, 0x1906,
-	0x7004, 0x0002, 0x6ae0, 0x6ae1, 0x6ba7, 0x6ae1, 0x0db4, 0x6ba7,
-	0x0005, 0x2001, 0x1919, 0x2004, 0x0002, 0x6aeb, 0x6aeb, 0x6b40,
-	0x6b41, 0x6aeb, 0x6b41, 0x0126, 0x2091, 0x8000, 0x1e0c, 0x6bc7,
-	0x701c, 0x904d, 0x01e0, 0xa84c, 0x9005, 0x01d8, 0x0e04, 0x6b0f,
-	0xa94c, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032, 0xa86c, 0x7086,
-	0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
-	0xd084, 0x190c, 0x1187, 0x2071, 0x1906, 0x080c, 0x6ba8, 0x012e,
-	0x0470, 0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x190c, 0x6bbc,
-	0xd09c, 0x2071, 0x1906, 0x1510, 0x2071, 0x1906, 0x700f, 0x0001,
+	0x70be, 0x080c, 0x7f64, 0x002e, 0x00ee, 0x0005, 0x0006, 0xa87c,
+	0x0006, 0xa867, 0x0103, 0x20a9, 0x001c, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x001d, 0x20a0, 0x9006, 0x4004, 0x000e, 0x9084, 0x00ff,
+	0xa87e, 0x000e, 0xa87a, 0xa982, 0x0005, 0x2071, 0x190e, 0x7004,
+	0x0002, 0x6aef, 0x6af0, 0x6bb6, 0x6af0, 0x0db4, 0x6bb6, 0x0005,
+	0x2001, 0x1921, 0x2004, 0x0002, 0x6afa, 0x6afa, 0x6b4f, 0x6b50,
+	0x6afa, 0x6b50, 0x0126, 0x2091, 0x8000, 0x1e0c, 0x6bd6, 0x701c,
+	0x904d, 0x01e0, 0xa84c, 0x9005, 0x01d8, 0x0e04, 0x6b1e, 0xa94c,
+	0x2071, 0x0000, 0x7182, 0xa850, 0x7032, 0xa86c, 0x7086, 0x7036,
+	0xa870, 0x708a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x1187, 0x2071, 0x190e, 0x080c, 0x6bb7, 0x012e, 0x0470,
+	0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x190c, 0x6bcb, 0xd09c,
+	0x2071, 0x190e, 0x1510, 0x2071, 0x190e, 0x700f, 0x0001, 0xa964,
+	0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f, 0x918c, 0x00ff,
+	0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069, 0x0050, 0x6822,
+	0x00de, 0x2071, 0x190e, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012,
+	0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005,
+	0x00d6, 0x2008, 0x2069, 0x19d2, 0x683c, 0x9005, 0x0760, 0x0158,
+	0x9186, 0x0003, 0x0540, 0x2001, 0x1814, 0x2004, 0x2009, 0x1a9f,
+	0x210c, 0x9102, 0x1500, 0x0126, 0x2091, 0x8000, 0x2069, 0x0050,
+	0x693c, 0x6838, 0x9106, 0x0190, 0x0e04, 0x6b82, 0x2069, 0x0000,
+	0x6837, 0x8040, 0x6833, 0x0012, 0x6883, 0x8040, 0x2091, 0x4080,
+	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x2069, 0x19d2,
+	0x683f, 0xffff, 0x012e, 0x00de, 0x0126, 0x2091, 0x8000, 0x1e0c,
+	0x6c37, 0x701c, 0x904d, 0x0540, 0x2001, 0x005b, 0x2004, 0x9094,
+	0x0780, 0x15c9, 0xd09c, 0x1500, 0x2071, 0x190e, 0x700f, 0x0001,
 	0xa964, 0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f, 0x918c,
 	0x00ff, 0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069, 0x0050,
-	0x6822, 0x00de, 0x2071, 0x1906, 0x701c, 0x2048, 0x7010, 0x8001,
-	0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005,
-	0x0005, 0x00d6, 0x2008, 0x2069, 0x19ca, 0x683c, 0x9005, 0x0760,
-	0x0158, 0x9186, 0x0003, 0x0540, 0x2001, 0x1814, 0x2004, 0x2009,
-	0x1a97, 0x210c, 0x9102, 0x1500, 0x0126, 0x2091, 0x8000, 0x2069,
-	0x0050, 0x693c, 0x6838, 0x9106, 0x0190, 0x0e04, 0x6b73, 0x2069,
-	0x0000, 0x6837, 0x8040, 0x6833, 0x0012, 0x6883, 0x8040, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1187, 0x2069,
-	0x19ca, 0x683f, 0xffff, 0x012e, 0x00de, 0x0126, 0x2091, 0x8000,
-	0x1e0c, 0x6c28, 0x701c, 0x904d, 0x0540, 0x2001, 0x005b, 0x2004,
-	0x9094, 0x0780, 0x15c9, 0xd09c, 0x1500, 0x2071, 0x1906, 0x700f,
-	0x0001, 0xa964, 0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f,
-	0x918c, 0x00ff, 0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069,
-	0x0050, 0x6822, 0x00de, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012,
-	0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x701c, 0x904d, 0x0160, 0x7010, 0x8001,
-	0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x080c,
-	0x101d, 0x0005, 0x012e, 0x0005, 0x2091, 0x8000, 0x0e04, 0x6bbe,
-	0x0006, 0x0016, 0x2001, 0x8004, 0x0006, 0x0804, 0x0dbd, 0x0096,
-	0x00f6, 0x2079, 0x0050, 0x7044, 0xd084, 0x01c0, 0xc084, 0x7046,
-	0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836,
-	0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
-	0xd084, 0x190c, 0x1187, 0x00fe, 0x009e, 0x0005, 0x782c, 0x9094,
-	0x0780, 0x1991, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824,
-	0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1148, 0x2009, 0x182f,
-	0x210c, 0x918a, 0x0040, 0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee,
-	0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be,
-	0x080c, 0x7f46, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd0a4,
-	0x19f0, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
-	0x6836, 0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x190c, 0x1187, 0x00ee, 0x00fe, 0x009e, 0x0005,
-	0x00f6, 0x2079, 0x0050, 0x7044, 0xd084, 0x01b8, 0xc084, 0x7046,
+	0x6822, 0x00de, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012, 0xa800,
+	0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x701c, 0x904d, 0x0160, 0x7010, 0x8001, 0x7012,
+	0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x080c, 0x101d,
+	0x0005, 0x012e, 0x0005, 0x2091, 0x8000, 0x0e04, 0x6bcd, 0x0006,
+	0x0016, 0x2001, 0x8004, 0x0006, 0x0804, 0x0dbd, 0x0096, 0x00f6,
+	0x2079, 0x0050, 0x7044, 0xd084, 0x01c0, 0xc084, 0x7046, 0x7838,
+	0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833,
+	0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x1187, 0x00fe, 0x009e, 0x0005, 0x782c, 0x9094, 0x0780,
+	0x1991, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x00e6,
+	0x2071, 0x0040, 0x712c, 0xd19c, 0x1148, 0x2009, 0x182f, 0x210c,
+	0x918a, 0x0040, 0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c,
+	0x7f64, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb, 0xd0a4, 0x19f0,
 	0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836,
 	0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
-	0xd084, 0x190c, 0x1187, 0x00fe, 0x0005, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6bbc, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824,
-	0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be,
-	0x080c, 0x7f46, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bbc, 0xd0a4,
-	0x1d70, 0x00d6, 0x2069, 0x0050, 0x693c, 0x2069, 0x1919, 0x6808,
-	0x690a, 0x2069, 0x19ca, 0x9102, 0x1118, 0x683c, 0x9005, 0x1328,
-	0x2001, 0x191a, 0x200c, 0x810d, 0x693e, 0x00de, 0x00ee, 0x00fe,
-	0x0005, 0x7094, 0x908a, 0x0029, 0x1a0c, 0x0db4, 0x9082, 0x001d,
-	0x001b, 0x6027, 0x1e00, 0x0005, 0x6d50, 0x6cd6, 0x6cf2, 0x6d1c,
-	0x6d3f, 0x6d7f, 0x6d91, 0x6cf2, 0x6d67, 0x6c91, 0x6cbf, 0x6c90,
-	0x0005, 0x00d6, 0x2069, 0x0200, 0x6804, 0x9005, 0x1180, 0x6808,
-	0x9005, 0x1518, 0x7097, 0x0028, 0x2069, 0x195f, 0x2d04, 0x7002,
-	0x080c, 0x70d4, 0x6028, 0x9085, 0x0600, 0x602a, 0x00b0, 0x7097,
-	0x0028, 0x2069, 0x195f, 0x2d04, 0x7002, 0x6028, 0x9085, 0x0600,
-	0x602a, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a32, 0x080c,
-	0x195a, 0x005e, 0x004e, 0x003e, 0x00ee, 0x00de, 0x0005, 0x00d6,
-	0x2069, 0x0200, 0x6804, 0x9005, 0x1178, 0x6808, 0x9005, 0x1160,
-	0x7097, 0x0028, 0x2069, 0x195f, 0x2d04, 0x7002, 0x080c, 0x716e,
-	0x6028, 0x9085, 0x0600, 0x602a, 0x00de, 0x0005, 0x0006, 0x2001,
-	0x0090, 0x080c, 0x2b16, 0x000e, 0x6124, 0xd1e4, 0x1190, 0x080c,
-	0x6dfe, 0xd1d4, 0x1160, 0xd1dc, 0x1138, 0xd1cc, 0x0150, 0x7097,
-	0x0020, 0x080c, 0x6dfe, 0x0028, 0x7097, 0x001d, 0x0010, 0x7097,
-	0x001f, 0x0005, 0x2001, 0x0088, 0x080c, 0x2b16, 0x6124, 0xd1cc,
-	0x11e8, 0xd1dc, 0x11c0, 0xd1e4, 0x1198, 0x9184, 0x1e00, 0x11d8,
-	0x080c, 0x1984, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c,
-	0x6fc7, 0x2001, 0x0080, 0x080c, 0x2b16, 0x7097, 0x0028, 0x0058,
-	0x7097, 0x001e, 0x0040, 0x7097, 0x001d, 0x0028, 0x7097, 0x0020,
-	0x0010, 0x7097, 0x001f, 0x0005, 0x080c, 0x1984, 0x60e3, 0x0001,
-	0x600c, 0xc0b4, 0x600e, 0x080c, 0x6fc7, 0x2001, 0x0080, 0x080c,
-	0x2b16, 0x6124, 0xd1d4, 0x1180, 0xd1dc, 0x1158, 0xd1e4, 0x1130,
-	0x9184, 0x1e00, 0x1158, 0x7097, 0x0028, 0x0040, 0x7097, 0x001e,
-	0x0028, 0x7097, 0x001d, 0x0010, 0x7097, 0x001f, 0x0005, 0x2001,
-	0x00a0, 0x080c, 0x2b16, 0x6124, 0xd1dc, 0x1138, 0xd1e4, 0x0138,
-	0x080c, 0x1984, 0x7097, 0x001e, 0x0010, 0x7097, 0x001d, 0x0005,
-	0x080c, 0x6e81, 0x6124, 0xd1dc, 0x1188, 0x080c, 0x6dfe, 0x0016,
-	0x080c, 0x1984, 0x001e, 0xd1d4, 0x1128, 0xd1e4, 0x0138, 0x7097,
-	0x001e, 0x0020, 0x7097, 0x001f, 0x080c, 0x6dfe, 0x0005, 0x0006,
-	0x2001, 0x00a0, 0x080c, 0x2b16, 0x000e, 0x6124, 0xd1d4, 0x1160,
-	0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x7097, 0x001e,
-	0x0028, 0x7097, 0x001d, 0x0010, 0x7097, 0x0021, 0x0005, 0x080c,
-	0x6e81, 0x6124, 0xd1d4, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140,
-	0x7097, 0x001e, 0x0028, 0x7097, 0x001d, 0x0010, 0x7097, 0x001f,
-	0x0005, 0x0006, 0x2001, 0x0090, 0x080c, 0x2b16, 0x000e, 0x6124,
-	0xd1d4, 0x1178, 0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0158,
-	0x7097, 0x001e, 0x0040, 0x7097, 0x001d, 0x0028, 0x7097, 0x0020,
-	0x0010, 0x7097, 0x001f, 0x0005, 0x0016, 0x00c6, 0x00d6, 0x00e6,
-	0x0126, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2091,
-	0x8000, 0x080c, 0x6f9b, 0x11d8, 0x2001, 0x180c, 0x200c, 0xd1b4,
-	0x01b0, 0xc1b4, 0x2102, 0x6027, 0x0200, 0x080c, 0x2a5f, 0x6024,
-	0xd0cc, 0x0148, 0x2001, 0x00a0, 0x080c, 0x2b16, 0x080c, 0x727f,
-	0x080c, 0x5cda, 0x0428, 0x6028, 0xc0cd, 0x602a, 0x0408, 0x080c,
-	0x6fb5, 0x0150, 0x080c, 0x6fac, 0x1138, 0x2001, 0x0001, 0x080c,
-	0x260e, 0x080c, 0x6f73, 0x00a0, 0x080c, 0x6e7e, 0x0178, 0x2001,
-	0x0001, 0x080c, 0x260e, 0x7094, 0x9086, 0x001e, 0x0120, 0x7094,
-	0x9086, 0x0022, 0x1118, 0x7097, 0x0025, 0x0010, 0x7097, 0x0021,
-	0x012e, 0x00ee, 0x00de, 0x00ce, 0x001e, 0x0005, 0x0026, 0x2011,
-	0x6e0f, 0x080c, 0x80f5, 0x002e, 0x0016, 0x0026, 0x2009, 0x0064,
-	0x2011, 0x6e0f, 0x080c, 0x80ec, 0x002e, 0x001e, 0x0005, 0x00e6,
-	0x00f6, 0x0016, 0x080c, 0x93ad, 0x2071, 0x1800, 0x080c, 0x6dac,
-	0x001e, 0x00fe, 0x00ee, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6,
-	0x00d6, 0x00e6, 0x00f6, 0x0126, 0x080c, 0x93ad, 0x2061, 0x0100,
-	0x2069, 0x0140, 0x2071, 0x1800, 0x2091, 0x8000, 0x6028, 0xc09c,
-	0x602a, 0x2011, 0x0003, 0x080c, 0x9772, 0x2011, 0x0002, 0x080c,
-	0x977c, 0x080c, 0x9663, 0x080c, 0x80a1, 0x0036, 0x901e, 0x080c,
-	0x96d9, 0x003e, 0x60e3, 0x0000, 0x080c, 0xd8d5, 0x080c, 0xd8f0,
-	0x2009, 0x0004, 0x080c, 0x2a65, 0x080c, 0x2980, 0x2001, 0x1800,
-	0x2003, 0x0004, 0x6027, 0x0008, 0x2011, 0x6e0f, 0x080c, 0x80f5,
-	0x080c, 0x6fb5, 0x0118, 0x9006, 0x080c, 0x2b16, 0x080c, 0x0b8f,
-	0x2001, 0x0001, 0x080c, 0x260e, 0x012e, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x003e, 0x002e, 0x001e, 0x0005, 0x0026, 0x00e6, 0x2011,
-	0x6e1c, 0x2071, 0x19ca, 0x701c, 0x9206, 0x1118, 0x7018, 0x9005,
-	0x0110, 0x9085, 0x0001, 0x00ee, 0x002e, 0x0005, 0x6020, 0xd09c,
-	0x0005, 0x6800, 0x9084, 0xfffe, 0x9086, 0x00c0, 0x01b8, 0x2001,
-	0x00c0, 0x080c, 0x2b16, 0x0156, 0x20a9, 0x002d, 0x1d04, 0x6e8e,
-	0x2091, 0x6000, 0x1f04, 0x6e8e, 0x015e, 0x00d6, 0x2069, 0x1800,
-	0x6898, 0x8001, 0x0220, 0x0118, 0x689a, 0x00de, 0x0005, 0x689b,
-	0x0014, 0x68e4, 0xd0dc, 0x0dc8, 0x6800, 0x9086, 0x0001, 0x1da8,
-	0x080c, 0x8101, 0x0c90, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
-	0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x728e, 0x2001, 0x193d,
-	0x2003, 0x0000, 0x9006, 0x7096, 0x60e2, 0x6886, 0x080c, 0x26d9,
-	0x9006, 0x080c, 0x2b16, 0x080c, 0x5b99, 0x6027, 0xffff, 0x602b,
-	0x182f, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6,
-	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2001, 0x194d,
-	0x200c, 0x9186, 0x0000, 0x0158, 0x9186, 0x0001, 0x0158, 0x9186,
-	0x0002, 0x0158, 0x9186, 0x0003, 0x0158, 0x0804, 0x6f63, 0x7097,
-	0x0022, 0x0040, 0x7097, 0x0021, 0x0028, 0x7097, 0x0023, 0x0010,
-	0x7097, 0x0024, 0x60e3, 0x0000, 0x6887, 0x0001, 0x2001, 0x0001,
-	0x080c, 0x26d9, 0x0026, 0x080c, 0x9dc8, 0x002e, 0x7000, 0x908e,
-	0x0004, 0x0118, 0x602b, 0x0028, 0x0010, 0x602b, 0x0020, 0x0156,
-	0x0126, 0x2091, 0x8000, 0x20a9, 0x0005, 0x6024, 0xd0ac, 0x0150,
-	0x012e, 0x015e, 0x080c, 0xc22c, 0x0118, 0x9006, 0x080c, 0x2b40,
-	0x0804, 0x6f6f, 0x6800, 0x9084, 0x00a1, 0xc0bd, 0x6802, 0x080c,
-	0x2a5f, 0x6904, 0xd1d4, 0x1140, 0x2001, 0x0100, 0x080c, 0x2b16,
-	0x1f04, 0x6f0d, 0x080c, 0x6ff2, 0x012e, 0x015e, 0x080c, 0x6fac,
-	0x01a8, 0x6044, 0x9005, 0x0168, 0x6050, 0x0006, 0x9085, 0x0020,
-	0x6052, 0x080c, 0x6ff2, 0x9006, 0x8001, 0x1df0, 0x000e, 0x6052,
-	0x0028, 0x6804, 0xd0d4, 0x1110, 0x080c, 0x6ff2, 0x080c, 0xc22c,
-	0x0118, 0x9006, 0x080c, 0x2b40, 0x0016, 0x0026, 0x7000, 0x908e,
-	0x0004, 0x0130, 0x2009, 0x00c8, 0x2011, 0x6e1c, 0x080c, 0x80b3,
-	0x002e, 0x001e, 0x080c, 0x7f3d, 0x7034, 0xc085, 0x7036, 0x2001,
-	0x194d, 0x2003, 0x0004, 0x080c, 0x6c79, 0x080c, 0x6fac, 0x0138,
-	0x6804, 0xd0d4, 0x1120, 0xd0dc, 0x1100, 0x080c, 0x7284, 0x00ee,
-	0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
-	0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x7f54, 0x080c, 0x7f46,
-	0x080c, 0x728e, 0x2001, 0x193d, 0x2003, 0x0000, 0x9006, 0x7096,
-	0x60e2, 0x6886, 0x080c, 0x26d9, 0x9006, 0x080c, 0x2b16, 0x6043,
-	0x0090, 0x6043, 0x0010, 0x6027, 0xffff, 0x602b, 0x182f, 0x00ee,
-	0x00de, 0x00ce, 0x0005, 0x0006, 0x2001, 0x194c, 0x2004, 0x9086,
-	0xaaaa, 0x000e, 0x0005, 0x0006, 0x080c, 0x5393, 0x9084, 0x0030,
-	0x9086, 0x0000, 0x000e, 0x0005, 0x0006, 0x080c, 0x5393, 0x9084,
-	0x0030, 0x9086, 0x0030, 0x000e, 0x0005, 0x0006, 0x080c, 0x5393,
-	0x9084, 0x0030, 0x9086, 0x0010, 0x000e, 0x0005, 0x0006, 0x080c,
-	0x5393, 0x9084, 0x0030, 0x9086, 0x0020, 0x000e, 0x0005, 0x0036,
-	0x0016, 0x2001, 0x180c, 0x2004, 0x908c, 0x0013, 0x0180, 0x0020,
-	0x080c, 0x26f9, 0x900e, 0x0028, 0x080c, 0x6563, 0x1dc8, 0x2009,
-	0x0002, 0x2019, 0x0028, 0x080c, 0x2fa7, 0x9006, 0x0019, 0x001e,
-	0x003e, 0x0005, 0x00e6, 0x2071, 0x180c, 0x2e04, 0x0130, 0x080c,
-	0xc225, 0x1128, 0x9085, 0x0010, 0x0010, 0x9084, 0xffef, 0x2072,
-	0x00ee, 0x0005, 0x6050, 0x0006, 0x60ec, 0x0006, 0x600c, 0x0006,
-	0x6004, 0x0006, 0x6028, 0x0006, 0x0016, 0x6138, 0x6050, 0x9084,
-	0xfbff, 0x9085, 0x2000, 0x6052, 0x613a, 0x20a9, 0x0012, 0x1d04,
-	0x7007, 0x2091, 0x6000, 0x1f04, 0x7007, 0x602f, 0x0100, 0x602f,
-	0x0000, 0x6050, 0x9085, 0x0400, 0x9084, 0xdfff, 0x6052, 0x613a,
-	0x001e, 0x602f, 0x0040, 0x602f, 0x0000, 0x000e, 0x602a, 0x000e,
-	0x6006, 0x000e, 0x600e, 0x000e, 0x60ee, 0x60e3, 0x0000, 0x6887,
-	0x0001, 0x2001, 0x0001, 0x080c, 0x26d9, 0x2001, 0x00a0, 0x0006,
-	0x080c, 0xc22c, 0x000e, 0x0130, 0x080c, 0x2b34, 0x9006, 0x080c,
-	0x2b40, 0x0010, 0x080c, 0x2b16, 0x000e, 0x6052, 0x6050, 0x0006,
-	0xc0e5, 0x6052, 0x00f6, 0x2079, 0x0100, 0x080c, 0x29d4, 0x00fe,
-	0x000e, 0x6052, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6,
-	0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800,
-	0x6020, 0x9084, 0x0080, 0x0138, 0x2001, 0x180c, 0x200c, 0xc1c5,
-	0x2102, 0x0804, 0x70c6, 0x2001, 0x180c, 0x200c, 0xc1c4, 0x2102,
-	0x6028, 0x9084, 0xe1ff, 0x602a, 0x6027, 0x0200, 0x2001, 0x0090,
-	0x080c, 0x2b16, 0x20a9, 0x0366, 0x6024, 0xd0cc, 0x1518, 0x1d04,
-	0x7074, 0x2091, 0x6000, 0x1f04, 0x7074, 0x2011, 0x0003, 0x080c,
-	0x9772, 0x2011, 0x0002, 0x080c, 0x977c, 0x080c, 0x9663, 0x901e,
-	0x080c, 0x96d9, 0x2001, 0x00a0, 0x080c, 0x2b16, 0x080c, 0x727f,
-	0x080c, 0x5cda, 0x080c, 0xc22c, 0x0110, 0x080c, 0x0d22, 0x9085,
-	0x0001, 0x0490, 0x86ff, 0x1110, 0x080c, 0x1984, 0x60e3, 0x0000,
-	0x2001, 0x0002, 0x080c, 0x26d9, 0x60e2, 0x2001, 0x0080, 0x080c,
-	0x2b16, 0x20a9, 0x0366, 0x6027, 0x1e00, 0x2009, 0x1e00, 0x080c,
-	0x2a5f, 0x6024, 0x910c, 0x0138, 0x1d04, 0x70ab, 0x2091, 0x6000,
-	0x1f04, 0x70ab, 0x0810, 0x6028, 0x9085, 0x1e00, 0x602a, 0x70b0,
-	0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x080c, 0xc22c,
-	0x0110, 0x080c, 0x0d22, 0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e,
-	0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036,
-	0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x7000,
-	0x9086, 0x0003, 0x1168, 0x2001, 0x020b, 0x2004, 0x9084, 0x5540,
-	0x9086, 0x5540, 0x1128, 0x2069, 0x1a48, 0x2d04, 0x8000, 0x206a,
-	0x2069, 0x0140, 0x6020, 0x9084, 0x00c0, 0x0120, 0x6884, 0x9005,
-	0x1904, 0x7139, 0x2001, 0x0088, 0x080c, 0x2b16, 0x9006, 0x60e2,
-	0x6886, 0x080c, 0x26d9, 0x2069, 0x0200, 0x6804, 0x9005, 0x1118,
-	0x6808, 0x9005, 0x01c0, 0x6028, 0x9084, 0xfbff, 0x602a, 0x6027,
-	0x0400, 0x2069, 0x195f, 0x7000, 0x206a, 0x7097, 0x0026, 0x7003,
-	0x0001, 0x20a9, 0x0002, 0x1d04, 0x711b, 0x2091, 0x6000, 0x1f04,
-	0x711b, 0x0804, 0x7166, 0x2069, 0x0140, 0x20a9, 0x0384, 0x6027,
-	0x1e00, 0x2009, 0x1e00, 0x080c, 0x2a5f, 0x6024, 0x910c, 0x0508,
-	0x9084, 0x1a00, 0x11f0, 0x1d04, 0x7127, 0x2091, 0x6000, 0x1f04,
-	0x7127, 0x2011, 0x0003, 0x080c, 0x9772, 0x2011, 0x0002, 0x080c,
-	0x977c, 0x080c, 0x9663, 0x901e, 0x080c, 0x96d9, 0x2001, 0x00a0,
-	0x080c, 0x2b16, 0x080c, 0x727f, 0x080c, 0x5cda, 0x9085, 0x0001,
-	0x00a8, 0x2001, 0x0080, 0x080c, 0x2b16, 0x2069, 0x0140, 0x60e3,
-	0x0000, 0x70b0, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886,
-	0x2001, 0x0002, 0x080c, 0x26d9, 0x60e2, 0x9006, 0x00ee, 0x00de,
-	0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016,
-	0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071,
-	0x1800, 0x6020, 0x9084, 0x00c0, 0x01c8, 0x2011, 0x0003, 0x080c,
-	0x9772, 0x2011, 0x0002, 0x080c, 0x977c, 0x080c, 0x9663, 0x901e,
-	0x080c, 0x96d9, 0x2069, 0x0140, 0x2001, 0x00a0, 0x080c, 0x2b16,
-	0x080c, 0x727f, 0x080c, 0x5cda, 0x0804, 0x7200, 0x2001, 0x180c,
-	0x200c, 0xd1b4, 0x1160, 0xc1b5, 0x2102, 0x080c, 0x6e04, 0x2069,
-	0x0140, 0x2001, 0x0080, 0x080c, 0x2b16, 0x60e3, 0x0000, 0x2069,
-	0x0200, 0x6804, 0x9005, 0x1118, 0x6808, 0x9005, 0x0180, 0x6028,
-	0x9084, 0xfdff, 0x602a, 0x6027, 0x0200, 0x2069, 0x195f, 0x7000,
-	0x206a, 0x7097, 0x0027, 0x7003, 0x0001, 0x0804, 0x7200, 0x6027,
-	0x1e00, 0x2009, 0x1e00, 0x080c, 0x2a5f, 0x6024, 0x910c, 0x01c8,
-	0x9084, 0x1c00, 0x11b0, 0x1d04, 0x71bf, 0x0006, 0x0016, 0x00c6,
-	0x00d6, 0x00e6, 0x080c, 0x7f85, 0x00ee, 0x00de, 0x00ce, 0x001e,
-	0x000e, 0x00e6, 0x2071, 0x19ca, 0x7018, 0x00ee, 0x9005, 0x19f8,
-	0x01f8, 0x0026, 0x2011, 0x6e1c, 0x080c, 0x8021, 0x2011, 0x6e0f,
-	0x080c, 0x80f5, 0x002e, 0x2069, 0x0140, 0x60e3, 0x0000, 0x70b0,
-	0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001, 0x0002,
-	0x080c, 0x26d9, 0x60e2, 0x2001, 0x180c, 0x200c, 0xc1b4, 0x2102,
-	0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005,
-	0x0156, 0x0016, 0x0026, 0x0036, 0x0046, 0x00c6, 0x00e6, 0x2061,
-	0x0100, 0x2071, 0x1800, 0x080c, 0xc225, 0x1904, 0x726d, 0x7130,
-	0xd184, 0x1170, 0x080c, 0x3135, 0x0138, 0xc18d, 0x7132, 0x2011,
-	0x1854, 0x2214, 0xd2ac, 0x1120, 0x7030, 0xd08c, 0x0904, 0x726d,
-	0x2011, 0x1854, 0x220c, 0x0438, 0x0016, 0x2019, 0x000e, 0x080c,
-	0xd4c7, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e, 0x9186, 0x007e,
-	0x01a0, 0x9186, 0x0080, 0x0188, 0x080c, 0x6247, 0x1170, 0x2120,
-	0x9006, 0x0016, 0x2009, 0x000e, 0x080c, 0xd54b, 0x2009, 0x0001,
-	0x2011, 0x0100, 0x080c, 0x8218, 0x001e, 0x8108, 0x1f04, 0x7236,
-	0x00be, 0x015e, 0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009, 0x0002,
-	0x2019, 0x0004, 0x080c, 0x2fa7, 0x001e, 0x0078, 0x0156, 0x00b6,
-	0x20a9, 0x007f, 0x900e, 0x080c, 0x6247, 0x1110, 0x080c, 0x5cf4,
-	0x8108, 0x1f04, 0x7263, 0x00be, 0x015e, 0x080c, 0x1984, 0x080c,
-	0x9dc8, 0x60e3, 0x0000, 0x080c, 0x5cda, 0x080c, 0x6ecd, 0x00ee,
-	0x00ce, 0x004e, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x2001,
-	0x194d, 0x2003, 0x0001, 0x0005, 0x2001, 0x194d, 0x2003, 0x0000,
-	0x0005, 0x2001, 0x194c, 0x2003, 0xaaaa, 0x0005, 0x2001, 0x194c,
-	0x2003, 0x0000, 0x0005, 0x2071, 0x18f0, 0x7003, 0x0000, 0x7007,
-	0x0000, 0x080c, 0x1004, 0x090c, 0x0db4, 0xa8ab, 0xdcb0, 0x2900,
-	0x704e, 0x080c, 0x1004, 0x090c, 0x0db4, 0xa8ab, 0xdcb0, 0x2900,
-	0x7052, 0xa867, 0x0000, 0xa86b, 0x0001, 0xa89f, 0x0000, 0x0005,
-	0x00e6, 0x2071, 0x0040, 0x6848, 0x9005, 0x1118, 0x9085, 0x0001,
-	0x04b0, 0x6840, 0x9005, 0x0150, 0x04a1, 0x6a50, 0x9200, 0x7002,
-	0x6854, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6850, 0x7002,
-	0x6854, 0x7006, 0x6858, 0x700a, 0x685c, 0x700e, 0x6840, 0x9005,
-	0x1110, 0x7012, 0x7016, 0x6848, 0x701a, 0x701c, 0x9085, 0x0040,
-	0x701e, 0x2001, 0x0019, 0x7036, 0x702b, 0x0001, 0x2001, 0x0004,
-	0x200c, 0x918c, 0xfff7, 0x918d, 0x8000, 0x2102, 0x00d6, 0x2069,
-	0x18f0, 0x6807, 0x0001, 0x00de, 0x080c, 0x7880, 0x9006, 0x00ee,
-	0x0005, 0x900e, 0x0156, 0x20a9, 0x0006, 0x8003, 0x2011, 0x0100,
-	0x2214, 0x9296, 0x0008, 0x1110, 0x818d, 0x0010, 0x81f5, 0x3e08,
-	0x1f04, 0x72f5, 0x015e, 0x0005, 0x2079, 0x0040, 0x2071, 0x18f0,
-	0x7004, 0x0002, 0x7314, 0x7315, 0x734c, 0x73a7, 0x74e8, 0x7312,
-	0x7312, 0x7512, 0x080c, 0x0db4, 0x0005, 0x2079, 0x0040, 0x782c,
-	0x908c, 0x0780, 0x190c, 0x790c, 0xd0a4, 0x01f0, 0x7824, 0x2048,
-	0x9006, 0xa802, 0xa806, 0xa864, 0x9084, 0x00ff, 0x908a, 0x0040,
-	0x0608, 0x00b8, 0x2001, 0x1800, 0x200c, 0x9186, 0x0003, 0x1160,
-	0x7104, 0x9186, 0x0004, 0x0140, 0x9186, 0x0007, 0x0128, 0x9186,
-	0x0003, 0x19e8, 0x080c, 0x73a7, 0x782c, 0xd09c, 0x090c, 0x7880,
-	0x0005, 0x9082, 0x005a, 0x1218, 0x2100, 0x003b, 0x0c18, 0x080c,
-	0x73dd, 0x0c90, 0x00e3, 0x08f0, 0x0005, 0x73dd, 0x73dd, 0x73dd,
-	0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73ff, 0x73dd, 0x73dd,
-	0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd,
-	0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd,
-	0x73dd, 0x73e9, 0x73dd, 0x75e7, 0x73dd, 0x73dd, 0x73dd, 0x73ff,
-	0x73dd, 0x73e9, 0x7628, 0x7669, 0x76b0, 0x76c4, 0x73dd, 0x73dd,
-	0x73ff, 0x73e9, 0x73dd, 0x73dd, 0x74bc, 0x776f, 0x778a, 0x73dd,
-	0x73ff, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x74b2, 0x778a, 0x73dd,
-	0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd,
-	0x7413, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd,
-	0x73dd, 0x73dd, 0x78b0, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd,
-	0x7427, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x73dd, 0x2079,
-	0x0040, 0x7004, 0x9086, 0x0003, 0x1198, 0x782c, 0x080c, 0x78a9,
-	0xd0a4, 0x0170, 0x7824, 0x2048, 0x9006, 0xa802, 0xa806, 0xa864,
-	0x9084, 0x00ff, 0x908a, 0x001a, 0x1210, 0x002b, 0x0c50, 0x00e9,
-	0x080c, 0x7880, 0x0005, 0x73dd, 0x73e9, 0x75d3, 0x73dd, 0x73e9,
-	0x73dd, 0x73e9, 0x73e9, 0x73dd, 0x73e9, 0x75d3, 0x73e9, 0x73e9,
-	0x73e9, 0x73e9, 0x73e9, 0x73dd, 0x73e9, 0x75d3, 0x73dd, 0x73dd,
-	0x73e9, 0x73dd, 0x73dd, 0x73dd, 0x73e9, 0x00e6, 0x2071, 0x18f0,
-	0x2009, 0x0400, 0x0071, 0x00ee, 0x0005, 0x2009, 0x1000, 0x0049,
-	0x0005, 0x2009, 0x2000, 0x0029, 0x0005, 0x2009, 0x0800, 0x0009,
-	0x0005, 0x7007, 0x0001, 0xa868, 0x9084, 0x00ff, 0x9105, 0xa86a,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6891, 0x012e, 0x0005, 0xa864,
-	0x8007, 0x9084, 0x00ff, 0x0d08, 0x8001, 0x1120, 0x7007, 0x0001,
-	0x0804, 0x7591, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a,
-	0x704b, 0x7591, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0968,
-	0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x75ac, 0x7007, 0x0003,
-	0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x75ac, 0x0005, 0xa864,
-	0x8007, 0x9084, 0x00ff, 0x9086, 0x0001, 0x1904, 0x73e5, 0x7007,
-	0x0001, 0x2009, 0x1833, 0x210c, 0x81ff, 0x1904, 0x7489, 0xa994,
-	0x9186, 0x006f, 0x0188, 0x9186, 0x0074, 0x15b0, 0x0026, 0x2011,
-	0x0010, 0x080c, 0x658f, 0x002e, 0x0578, 0x0016, 0xa998, 0x080c,
-	0x65d9, 0x001e, 0x1548, 0x0400, 0x080c, 0x6f9b, 0x0140, 0xa897,
-	0x4005, 0xa89b, 0x0016, 0x2001, 0x0030, 0x900e, 0x0438, 0x0026,
-	0x2011, 0x8008, 0x080c, 0x658f, 0x002e, 0x01b0, 0x0016, 0x0026,
-	0x0036, 0xa998, 0xaaa0, 0xab9c, 0x918d, 0x8000, 0x080c, 0x65d9,
-	0x003e, 0x002e, 0x001e, 0x1140, 0xa897, 0x4005, 0xa89b, 0x4009,
-	0x2001, 0x0030, 0x900e, 0x0050, 0xa868, 0x9084, 0x00ff, 0xa86a,
-	0xa883, 0x0000, 0x080c, 0x5f09, 0x1108, 0x0005, 0x0126, 0x2091,
-	0x8000, 0xa867, 0x0139, 0xa87a, 0xa982, 0x080c, 0x6891, 0x012e,
-	0x0ca0, 0xa994, 0x9186, 0x0071, 0x0904, 0x7437, 0x9186, 0x0064,
-	0x0904, 0x7437, 0x9186, 0x007c, 0x0904, 0x7437, 0x9186, 0x0028,
-	0x0904, 0x7437, 0x9186, 0x0038, 0x0904, 0x7437, 0x9186, 0x0078,
-	0x0904, 0x7437, 0x9186, 0x005f, 0x0904, 0x7437, 0x9186, 0x0056,
-	0x0904, 0x7437, 0xa897, 0x4005, 0xa89b, 0x0001, 0x2001, 0x0030,
-	0x900e, 0x0860, 0xa87c, 0x9084, 0x00c0, 0x9086, 0x00c0, 0x1120,
-	0x7007, 0x0001, 0x0804, 0x77a1, 0x2900, 0x7016, 0x701a, 0x20a9,
-	0x0004, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0030, 0x2098, 0x7050,
-	0x2040, 0xa060, 0x20e8, 0xa05c, 0x9080, 0x0023, 0x20a0, 0x4003,
-	0xa888, 0x7012, 0x9082, 0x0401, 0x1a04, 0x73ed, 0xaab4, 0x928a,
-	0x0002, 0x1a04, 0x73ed, 0x82ff, 0x1138, 0xa8b8, 0xa9bc, 0x9105,
-	0x0118, 0x2001, 0x754f, 0x0018, 0x9280, 0x7545, 0x2005, 0x7056,
-	0x7010, 0x9015, 0x0904, 0x7530, 0x080c, 0x1004, 0x1118, 0x7007,
-	0x0004, 0x0005, 0x2900, 0x7022, 0x7054, 0x2060, 0xe000, 0xa866,
-	0x7050, 0x2040, 0xa95c, 0xe004, 0x9100, 0xa076, 0xa860, 0xa072,
-	0xe008, 0x920a, 0x1210, 0x900e, 0x2200, 0x7112, 0xe20c, 0x8003,
-	0x800b, 0x9296, 0x0004, 0x0108, 0x9108, 0xa17a, 0x810b, 0xa17e,
-	0x080c, 0x10d5, 0xa06c, 0x908e, 0x0100, 0x0170, 0x9086, 0x0200,
-	0x0118, 0x7007, 0x0007, 0x0005, 0x7020, 0x2048, 0x080c, 0x101d,
-	0x7014, 0x2048, 0x0804, 0x73ed, 0x7020, 0x2048, 0x7018, 0xa802,
-	0xa807, 0x0000, 0x2908, 0x2048, 0xa906, 0x711a, 0x0804, 0x74e8,
-	0x7014, 0x2048, 0x7007, 0x0001, 0xa8b4, 0x9005, 0x1128, 0xa8b8,
-	0xa9bc, 0x9105, 0x0108, 0x00b9, 0xa864, 0x9084, 0x00ff, 0x9086,
-	0x001e, 0x0904, 0x77a1, 0x0804, 0x7591, 0x7547, 0x754b, 0x0002,
-	0x001d, 0x0007, 0x0004, 0x000a, 0x001b, 0x0005, 0x0006, 0x000a,
-	0x001d, 0x0005, 0x0004, 0x0076, 0x0066, 0xafb8, 0xaebc, 0xa804,
-	0x2050, 0xb0c0, 0xb0e2, 0xb0bc, 0xb0de, 0xb0b8, 0xb0d2, 0xb0b4,
-	0xb0ce, 0xb6da, 0xb7d6, 0xb0b0, 0xb0ca, 0xb0ac, 0xb0c6, 0xb0a8,
-	0xb0ba, 0xb0a4, 0xb0b6, 0xb6c2, 0xb7be, 0xb0a0, 0xb0b2, 0xb09c,
-	0xb0ae, 0xb098, 0xb0a2, 0xb094, 0xb09e, 0xb6aa, 0xb7a6, 0xb090,
-	0xb09a, 0xb08c, 0xb096, 0xb088, 0xb08a, 0xb084, 0xb086, 0xb692,
-	0xb78e, 0xb080, 0xb082, 0xb07c, 0xb07e, 0xb078, 0xb072, 0xb074,
-	0xb06e, 0xb67a, 0xb776, 0xb004, 0x9055, 0x1958, 0x006e, 0x007e,
-	0x0005, 0x2009, 0x1833, 0x210c, 0x81ff, 0x1178, 0x080c, 0x5d56,
-	0x1108, 0x0005, 0x080c, 0x6abf, 0x0126, 0x2091, 0x8000, 0x080c,
-	0xbe20, 0x080c, 0x6891, 0x012e, 0x0ca0, 0x080c, 0xc225, 0x1d70,
-	0x2001, 0x0028, 0x900e, 0x0c70, 0x2009, 0x1833, 0x210c, 0x81ff,
-	0x11d8, 0xa888, 0x9005, 0x01e0, 0xa883, 0x0000, 0xa87c, 0xd0f4,
-	0x0120, 0x080c, 0x5e6b, 0x1138, 0x0005, 0x9006, 0xa87a, 0x080c,
-	0x5de6, 0x1108, 0x0005, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982,
-	0x080c, 0x6891, 0x012e, 0x0cb0, 0x2001, 0x0028, 0x900e, 0x0c98,
-	0x2001, 0x0000, 0x0c80, 0x7018, 0xa802, 0x2908, 0x2048, 0xa906,
-	0x711a, 0x7010, 0x8001, 0x7012, 0x0118, 0x7007, 0x0003, 0x0030,
-	0x7014, 0x2048, 0x7007, 0x0001, 0x7048, 0x080f, 0x0005, 0x00b6,
-	0x7007, 0x0001, 0xa974, 0xa878, 0x9084, 0x00ff, 0x9096, 0x0004,
-	0x0540, 0x20a9, 0x0001, 0x9096, 0x0001, 0x0190, 0x900e, 0x20a9,
-	0x0800, 0x9096, 0x0002, 0x0160, 0x9005, 0x11d8, 0xa974, 0x080c,
-	0x6247, 0x11b8, 0x0066, 0xae80, 0x080c, 0x6357, 0x006e, 0x0088,
-	0x0046, 0x2011, 0x180c, 0x2224, 0xc484, 0x2412, 0x004e, 0x00c6,
-	0x080c, 0x6247, 0x1110, 0x080c, 0x6457, 0x8108, 0x1f04, 0x7610,
-	0x00ce, 0xa87c, 0xd084, 0x1120, 0x080c, 0x101d, 0x00be, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6891, 0x012e, 0x00be, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x080c, 0x6567, 0x0580,
-	0x2061, 0x1a40, 0x6100, 0xd184, 0x0178, 0xa888, 0x9084, 0x00ff,
-	0x1550, 0x6000, 0xd084, 0x0520, 0x6004, 0x9005, 0x1538, 0x6003,
-	0x0000, 0x600b, 0x0000, 0x00c8, 0x2011, 0x0001, 0xa890, 0x9005,
-	0x1110, 0x2001, 0x001e, 0x8000, 0x6016, 0xa888, 0x9084, 0x00ff,
-	0x0178, 0x6006, 0xa888, 0x8007, 0x9084, 0x00ff, 0x0148, 0x600a,
-	0xa888, 0x8000, 0x1108, 0xc28d, 0x6202, 0x012e, 0x0804, 0x786a,
-	0x012e, 0x0804, 0x7864, 0x012e, 0x0804, 0x785e, 0x012e, 0x0804,
-	0x7861, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x080c, 0x6567,
-	0x05e0, 0x2061, 0x1a40, 0x6000, 0xd084, 0x05b8, 0x6204, 0x6308,
-	0xd08c, 0x1530, 0xac78, 0x9484, 0x0003, 0x0170, 0xa988, 0x918c,
-	0x00ff, 0x8001, 0x1120, 0x2100, 0x9210, 0x0620, 0x0028, 0x8001,
-	0x1508, 0x2100, 0x9212, 0x02f0, 0x9484, 0x000c, 0x0188, 0xa988,
-	0x810f, 0x918c, 0x00ff, 0x9082, 0x0004, 0x1120, 0x2100, 0x9318,
-	0x0288, 0x0030, 0x9082, 0x0004, 0x1168, 0x2100, 0x931a, 0x0250,
-	0xa890, 0x9005, 0x0110, 0x8000, 0x6016, 0x6206, 0x630a, 0x012e,
-	0x0804, 0x786a, 0x012e, 0x0804, 0x7867, 0x012e, 0x0804, 0x7864,
-	0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x2061, 0x1a40, 0x6300,
-	0xd38c, 0x1120, 0x6308, 0x8318, 0x0220, 0x630a, 0x012e, 0x0804,
-	0x7878, 0x012e, 0x0804, 0x7867, 0x00b6, 0x0126, 0x00c6, 0x2091,
-	0x8000, 0x7007, 0x0001, 0xa87c, 0xd0ac, 0x0148, 0x00c6, 0x2061,
-	0x1a40, 0x6000, 0x9084, 0xfcff, 0x6002, 0x00ce, 0x0440, 0xa888,
-	0x9005, 0x05d8, 0xa88c, 0x9065, 0x0598, 0x2001, 0x1833, 0x2004,
-	0x9005, 0x0118, 0x080c, 0x9e72, 0x0068, 0x6017, 0xf400, 0x605b,
-	0x0000, 0xa97c, 0xd1a4, 0x0110, 0xa980, 0x615a, 0x2009, 0x0041,
-	0x080c, 0x9ebc, 0xa988, 0x918c, 0xff00, 0x9186, 0x2000, 0x1138,
-	0x0026, 0x900e, 0x2011, 0xfdff, 0x080c, 0x8218, 0x002e, 0xa87c,
-	0xd0c4, 0x0148, 0x2061, 0x1a40, 0x6000, 0xd08c, 0x1120, 0x6008,
-	0x8000, 0x0208, 0x600a, 0x00ce, 0x012e, 0x00be, 0x0804, 0x786a,
-	0x00ce, 0x012e, 0x00be, 0x0804, 0x7864, 0xa984, 0x9186, 0x002e,
-	0x0d30, 0x9186, 0x002d, 0x0d18, 0x9186, 0x0045, 0x0510, 0x9186,
-	0x002a, 0x1130, 0x2001, 0x180c, 0x200c, 0xc194, 0x2102, 0x08b8,
-	0x9186, 0x0020, 0x0158, 0x9186, 0x0029, 0x1d10, 0xa974, 0x080c,
-	0x6247, 0x1968, 0xb800, 0xc0e4, 0xb802, 0x0848, 0xa88c, 0x9065,
-	0x09b8, 0x6007, 0x0024, 0x2001, 0x1956, 0x2004, 0x601a, 0x0804,
-	0x76ff, 0xa88c, 0x9065, 0x0960, 0x00e6, 0xa890, 0x9075, 0x2001,
-	0x1833, 0x2004, 0x9005, 0x0150, 0x080c, 0x9e72, 0x8eff, 0x0118,
-	0x2e60, 0x080c, 0x9e72, 0x00ee, 0x0804, 0x76ff, 0x6024, 0xc0dc,
-	0xc0d5, 0x6026, 0x2e60, 0x6007, 0x003a, 0xa8a0, 0x9005, 0x0130,
-	0x6007, 0x003b, 0xa8a4, 0x602e, 0xa8a8, 0x6016, 0x6003, 0x0001,
-	0x080c, 0x83da, 0x080c, 0x896d, 0x00ee, 0x0804, 0x76ff, 0x2061,
-	0x1a40, 0x6000, 0xd084, 0x0190, 0xd08c, 0x1904, 0x7878, 0x0126,
-	0x2091, 0x8000, 0x6204, 0x8210, 0x0220, 0x6206, 0x012e, 0x0804,
-	0x7878, 0x012e, 0xa883, 0x0016, 0x0804, 0x7871, 0xa883, 0x0007,
-	0x0804, 0x7871, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0130, 0x8001,
-	0x1138, 0x7007, 0x0001, 0x0069, 0x0005, 0x080c, 0x73e5, 0x0040,
-	0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x77a1,
-	0x0005, 0x00b6, 0x00e6, 0x0126, 0x2091, 0x8000, 0x903e, 0x2061,
-	0x1800, 0x61cc, 0x81ff, 0x1904, 0x7823, 0x6130, 0xd194, 0x1904,
-	0x784d, 0xa878, 0x2070, 0x9e82, 0x1cd0, 0x0a04, 0x7817, 0x6064,
-	0x9e02, 0x1a04, 0x7817, 0x7120, 0x9186, 0x0006, 0x1904, 0x7809,
-	0x7010, 0x905d, 0x0904, 0x7823, 0xb800, 0xd0e4, 0x1904, 0x7847,
-	0x2061, 0x1a40, 0x6100, 0x9184, 0x0301, 0x9086, 0x0001, 0x15a0,
-	0x7024, 0xd0dc, 0x1904, 0x7850, 0xa883, 0x0000, 0xa803, 0x0000,
-	0x2908, 0x7014, 0x9005, 0x1198, 0x7116, 0xa87c, 0xd0f4, 0x1904,
-	0x7853, 0x080c, 0x538f, 0xd09c, 0x1118, 0xa87c, 0xc0cc, 0xa87e,
-	0x2e60, 0x080c, 0x8138, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2048,
-	0xa800, 0x9005, 0x1de0, 0xa902, 0x2148, 0xa87c, 0xd0f4, 0x1904,
-	0x7853, 0x012e, 0x00ee, 0x00be, 0x0005, 0x012e, 0x00ee, 0xa883,
-	0x0006, 0x00be, 0x0804, 0x7871, 0xd184, 0x0db8, 0xd1c4, 0x1190,
-	0x00a0, 0xa974, 0x080c, 0x6247, 0x15d0, 0xb800, 0xd0e4, 0x15b8,
-	0x7120, 0x9186, 0x0007, 0x1118, 0xa883, 0x0002, 0x0490, 0xa883,
-	0x0008, 0x0478, 0xa883, 0x000e, 0x0460, 0xa883, 0x0017, 0x0448,
-	0xa883, 0x0035, 0x0430, 0x080c, 0x5393, 0xd0fc, 0x01e8, 0xa878,
-	0x2070, 0x9e82, 0x1cd0, 0x02c0, 0x6064, 0x9e02, 0x12a8, 0x7120,
-	0x9186, 0x0006, 0x1188, 0x7010, 0x905d, 0x0170, 0xb800, 0xd0bc,
-	0x0158, 0x2039, 0x0001, 0x7000, 0x9086, 0x0007, 0x1904, 0x77ad,
-	0x7003, 0x0002, 0x0804, 0x77ad, 0xa883, 0x0028, 0x0010, 0xa883,
-	0x0029, 0x012e, 0x00ee, 0x00be, 0x0420, 0xa883, 0x002a, 0x0cc8,
-	0xa883, 0x0045, 0x0cb0, 0x2e60, 0x2019, 0x0002, 0x601b, 0x0014,
-	0x080c, 0xd106, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2009, 0x003e,
-	0x0058, 0x2009, 0x0004, 0x0040, 0x2009, 0x0006, 0x0028, 0x2009,
-	0x0016, 0x0010, 0x2009, 0x0001, 0xa884, 0x9084, 0xff00, 0x9105,
-	0xa886, 0x0126, 0x2091, 0x8000, 0x080c, 0x6891, 0x012e, 0x0005,
-	0x080c, 0x101d, 0x0005, 0x00d6, 0x080c, 0x812f, 0x00de, 0x0005,
-	0x00d6, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x0040, 0x702c,
-	0xd084, 0x01d8, 0x908c, 0x0780, 0x190c, 0x790c, 0xd09c, 0x11a8,
-	0x2071, 0x1800, 0x70bc, 0x90ea, 0x0040, 0x0278, 0x8001, 0x70be,
-	0x702c, 0x2048, 0xa800, 0x702e, 0x9006, 0xa802, 0xa806, 0x2071,
-	0x0040, 0x2900, 0x7022, 0x702c, 0x0c28, 0x012e, 0x00ee, 0x00de,
-	0x0005, 0x0006, 0x9084, 0x0780, 0x190c, 0x790c, 0x000e, 0x0005,
-	0x00d6, 0x00c6, 0x0036, 0x0026, 0x0016, 0x00b6, 0x7007, 0x0001,
-	0xaa74, 0x9282, 0x0004, 0x1a04, 0x78fd, 0xa97c, 0x9188, 0x1000,
-	0x2104, 0x905d, 0xb804, 0xd284, 0x0140, 0x05e8, 0x8007, 0x9084,
-	0x00ff, 0x9084, 0x0006, 0x1108, 0x04b0, 0x2b10, 0x080c, 0x9dec,
-	0x1118, 0x080c, 0x9e8f, 0x05a8, 0x6212, 0xa874, 0x0002, 0x78db,
-	0x78e0, 0x78e3, 0x78e9, 0x2019, 0x0002, 0x080c, 0xd4c7, 0x0060,
-	0x080c, 0xd463, 0x0048, 0x2019, 0x0002, 0xa980, 0x080c, 0xd47e,
-	0x0018, 0xa980, 0x080c, 0xd463, 0x080c, 0x9e42, 0xa887, 0x0000,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6891, 0x012e, 0x00be, 0x001e,
-	0x002e, 0x003e, 0x00ce, 0x00de, 0x0005, 0xa887, 0x0006, 0x0c80,
-	0xa887, 0x0002, 0x0c68, 0xa887, 0x0005, 0x0c50, 0xa887, 0x0004,
-	0x0c38, 0xa887, 0x0007, 0x0c20, 0x2091, 0x8000, 0x0e04, 0x790e,
-	0x0006, 0x0016, 0x2001, 0x8003, 0x0006, 0x0804, 0x0dbd, 0x2001,
-	0x1833, 0x2004, 0x9005, 0x0005, 0x0005, 0x00f6, 0x2079, 0x0300,
-	0x2001, 0x0200, 0x200c, 0xc1e5, 0xc1dc, 0x2102, 0x2009, 0x0218,
-	0x210c, 0xd1ec, 0x1120, 0x080c, 0x14a9, 0x00fe, 0x0005, 0x2001,
-	0x020d, 0x2003, 0x0020, 0x781f, 0x0300, 0x00fe, 0x0005, 0x781c,
-	0xd08c, 0x0904, 0x798e, 0x68bc, 0x90aa, 0x0005, 0x0a04, 0x7f3d,
-	0x7d44, 0x7c40, 0x9584, 0x00f6, 0x1510, 0x9484, 0x7000, 0x0140,
-	0x908a, 0x2000, 0x1260, 0x9584, 0x0700, 0x8007, 0x0804, 0x7995,
-	0x7000, 0x9084, 0xff00, 0x9086, 0x8100, 0x0da8, 0x00b0, 0x9484,
-	0x0fff, 0x1130, 0x7000, 0x9084, 0xff00, 0x9086, 0x8100, 0x11c0,
-	0x080c, 0xd8ad, 0x080c, 0x7e82, 0x7817, 0x0140, 0x00a8, 0x9584,
-	0x0076, 0x1118, 0x080c, 0x7ee0, 0x19c0, 0xd5a4, 0x0148, 0x0046,
-	0x0056, 0x080c, 0x79f0, 0x080c, 0x21cf, 0x005e, 0x004e, 0x0020,
-	0x080c, 0xd8ad, 0x7817, 0x0140, 0x080c, 0x6f9b, 0x0168, 0x2001,
-	0x0111, 0x2004, 0xd08c, 0x0140, 0x688f, 0x0000, 0x2001, 0x0110,
-	0x2003, 0x0008, 0x2003, 0x0000, 0x080c, 0x79d1, 0x2001, 0x19c0,
-	0x2004, 0x9005, 0x090c, 0x896d, 0x0005, 0x0002, 0x79a7, 0x7ca4,
-	0x799e, 0x799e, 0x799e, 0x799e, 0x799e, 0x799e, 0x7817, 0x0140,
-	0x2001, 0x19c0, 0x2004, 0x9005, 0x090c, 0x896d, 0x0005, 0x7000,
-	0x908c, 0xff00, 0x9194, 0xf000, 0x810f, 0x9484, 0x0fff, 0x688e,
-	0x9286, 0x2000, 0x1150, 0x6800, 0x9086, 0x0001, 0x1118, 0x080c,
-	0x53f0, 0x0070, 0x080c, 0x7a10, 0x0058, 0x9286, 0x3000, 0x1118,
-	0x080c, 0x7bdf, 0x0028, 0x9286, 0x8000, 0x1110, 0x080c, 0x7db2,
-	0x7817, 0x0140, 0x2001, 0x19c0, 0x2004, 0x9005, 0x090c, 0x896d,
-	0x0005, 0x2001, 0x1810, 0x2004, 0xd08c, 0x0178, 0x2001, 0x1800,
-	0x2004, 0x9086, 0x0003, 0x1148, 0x0026, 0x0036, 0x2011, 0x8048,
-	0x2518, 0x080c, 0x48e9, 0x003e, 0x002e, 0x0005, 0x0036, 0x0046,
-	0x0056, 0x00f6, 0x2079, 0x0200, 0x2019, 0xfffe, 0x7c30, 0x0050,
-	0x0036, 0x0046, 0x0056, 0x00f6, 0x2079, 0x0200, 0x7d44, 0x7c40,
-	0x2019, 0xffff, 0x2001, 0x1810, 0x2004, 0xd08c, 0x0160, 0x2001,
-	0x1800, 0x2004, 0x9086, 0x0003, 0x1130, 0x0026, 0x2011, 0x8048,
-	0x080c, 0x48e9, 0x002e, 0x00fe, 0x005e, 0x004e, 0x003e, 0x0005,
-	0x00b6, 0x00c6, 0x7010, 0x9084, 0xff00, 0x8007, 0x9096, 0x0001,
-	0x0120, 0x9096, 0x0023, 0x1904, 0x7bb0, 0x9186, 0x0023, 0x15c0,
-	0x080c, 0x7e47, 0x0904, 0x7bb0, 0x6120, 0x9186, 0x0001, 0x0150,
-	0x9186, 0x0004, 0x0138, 0x9186, 0x0008, 0x0120, 0x9186, 0x000a,
-	0x1904, 0x7bb0, 0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1130,
-	0x2009, 0x0015, 0x080c, 0x9ebc, 0x0804, 0x7bb0, 0x908e, 0x0214,
-	0x0118, 0x908e, 0x0210, 0x1130, 0x2009, 0x0015, 0x080c, 0x9ebc,
-	0x0804, 0x7bb0, 0x908e, 0x0100, 0x1904, 0x7bb0, 0x7034, 0x9005,
-	0x1904, 0x7bb0, 0x2009, 0x0016, 0x080c, 0x9ebc, 0x0804, 0x7bb0,
-	0x9186, 0x0022, 0x1904, 0x7bb0, 0x7030, 0x908e, 0x0300, 0x1580,
-	0x68d8, 0xd0a4, 0x0528, 0xc0b5, 0x68da, 0x7100, 0x918c, 0x00ff,
-	0x697a, 0x7004, 0x687e, 0x00f6, 0x2079, 0x0100, 0x79e6, 0x78ea,
-	0x0006, 0x9084, 0x00ff, 0x0016, 0x2008, 0x080c, 0x26ae, 0x7932,
-	0x7936, 0x001e, 0x000e, 0x00fe, 0x080c, 0x2665, 0x695a, 0x703c,
-	0x00e6, 0x2071, 0x0140, 0x7086, 0x2071, 0x1800, 0x70b2, 0x00ee,
-	0x7034, 0x9005, 0x1904, 0x7bb0, 0x2009, 0x0017, 0x0804, 0x7b60,
-	0x908e, 0x0400, 0x1190, 0x7034, 0x9005, 0x1904, 0x7bb0, 0x080c,
-	0x6f9b, 0x0120, 0x2009, 0x001d, 0x0804, 0x7b60, 0x68d8, 0xc0a5,
-	0x68da, 0x2009, 0x0030, 0x0804, 0x7b60, 0x908e, 0x0500, 0x1140,
-	0x7034, 0x9005, 0x1904, 0x7bb0, 0x2009, 0x0018, 0x0804, 0x7b60,
-	0x908e, 0x2010, 0x1120, 0x2009, 0x0019, 0x0804, 0x7b60, 0x908e,
-	0x2110, 0x1120, 0x2009, 0x001a, 0x0804, 0x7b60, 0x908e, 0x5200,
-	0x1140, 0x7034, 0x9005, 0x1904, 0x7bb0, 0x2009, 0x001b, 0x0804,
-	0x7b60, 0x908e, 0x5000, 0x1140, 0x7034, 0x9005, 0x1904, 0x7bb0,
-	0x2009, 0x001c, 0x0804, 0x7b60, 0x908e, 0x1300, 0x1120, 0x2009,
-	0x0034, 0x0804, 0x7b60, 0x908e, 0x1200, 0x1140, 0x7034, 0x9005,
-	0x1904, 0x7bb0, 0x2009, 0x0024, 0x0804, 0x7b60, 0x908c, 0xff00,
-	0x918e, 0x2400, 0x1170, 0x2009, 0x002d, 0x2001, 0x1810, 0x2004,
-	0xd09c, 0x0904, 0x7b60, 0x080c, 0xc8d7, 0x1904, 0x7bb0, 0x0804,
-	0x7b5e, 0x908c, 0xff00, 0x918e, 0x5300, 0x1120, 0x2009, 0x002a,
-	0x0804, 0x7b60, 0x908e, 0x0f00, 0x1120, 0x2009, 0x0020, 0x0804,
-	0x7b60, 0x908e, 0x6104, 0x1528, 0x2029, 0x0205, 0x2011, 0x026d,
-	0x8208, 0x2204, 0x9082, 0x0004, 0x8004, 0x8004, 0x20a8, 0x2011,
-	0x8015, 0x211c, 0x8108, 0x0046, 0x2124, 0x080c, 0x48e9, 0x004e,
-	0x8108, 0x0f04, 0x7b2c, 0x9186, 0x0280, 0x1d88, 0x2504, 0x8000,
-	0x202a, 0x2009, 0x0260, 0x0c58, 0x202b, 0x0000, 0x2009, 0x0023,
-	0x0478, 0x908e, 0x6000, 0x1118, 0x2009, 0x003f, 0x0448, 0x908e,
-	0x7800, 0x1118, 0x2009, 0x0045, 0x0418, 0x908e, 0x1000, 0x1118,
-	0x2009, 0x004e, 0x00e8, 0x908e, 0x6300, 0x1118, 0x2009, 0x004a,
-	0x00b8, 0x908c, 0xff00, 0x918e, 0x5600, 0x1118, 0x2009, 0x004f,
-	0x0078, 0x908c, 0xff00, 0x918e, 0x5700, 0x1118, 0x2009, 0x0050,
-	0x0038, 0x2009, 0x001d, 0x6838, 0xd0d4, 0x0110, 0x2009, 0x004c,
-	0x0016, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2665,
-	0x1904, 0x7bb3, 0x080c, 0x61e7, 0x1904, 0x7bb3, 0xbe12, 0xbd16,
-	0x001e, 0x0016, 0x080c, 0x6f9b, 0x01c0, 0x68d8, 0xd08c, 0x1148,
-	0x7000, 0x9084, 0x00ff, 0x1188, 0x7004, 0x9084, 0xff00, 0x1168,
-	0x0040, 0x6878, 0x9606, 0x1148, 0x687c, 0x9506, 0x9084, 0xff00,
-	0x1120, 0x9584, 0x00ff, 0xb8b2, 0x0080, 0xb8b0, 0x9005, 0x1168,
-	0x9186, 0x0046, 0x1150, 0x6878, 0x9606, 0x1138, 0x687c, 0x9506,
-	0x9084, 0xff00, 0x1110, 0x001e, 0x0098, 0x080c, 0x9dec, 0x01a8,
-	0x2b08, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x9186,
-	0x004c, 0x1110, 0x6023, 0x000a, 0x0016, 0x001e, 0x080c, 0x9ebc,
-	0x00ce, 0x00be, 0x0005, 0x001e, 0x0cd8, 0x2001, 0x180e, 0x2004,
-	0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x48e9, 0x080c, 0x9e8f,
-	0x0d90, 0x2b08, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e,
-	0x0016, 0x9186, 0x0017, 0x0118, 0x9186, 0x0030, 0x1128, 0x6007,
-	0x0009, 0x6017, 0x2900, 0x0020, 0x6007, 0x0051, 0x6017, 0x0000,
-	0x602f, 0x0009, 0x6003, 0x0001, 0x080c, 0x8422, 0x08a0, 0x080c,
-	0x30ff, 0x1140, 0x7010, 0x9084, 0xff00, 0x8007, 0x908e, 0x0008,
-	0x1108, 0x0009, 0x0005, 0x00b6, 0x00c6, 0x0046, 0x7000, 0x908c,
-	0xff00, 0x810f, 0x9186, 0x0033, 0x11e8, 0x080c, 0x7e47, 0x0904,
-	0x7c3c, 0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1140, 0x7034,
-	0x9005, 0x15d0, 0x2009, 0x0015, 0x080c, 0x9ebc, 0x04a8, 0x908e,
-	0x0100, 0x1590, 0x7034, 0x9005, 0x1578, 0x2009, 0x0016, 0x080c,
-	0x9ebc, 0x0450, 0x9186, 0x0032, 0x1538, 0x7030, 0x908e, 0x1400,
-	0x1518, 0x2009, 0x0038, 0x0016, 0x2011, 0x0263, 0x2204, 0x8211,
-	0x220c, 0x080c, 0x2665, 0x11b8, 0x080c, 0x61e7, 0x11a0, 0xbe12,
-	0xbd16, 0x080c, 0x9dec, 0x0178, 0x2b08, 0x6112, 0x080c, 0xbfa6,
-	0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x080c, 0x9ebc, 0x080c,
-	0x896d, 0x0010, 0x00ce, 0x001e, 0x004e, 0x00ce, 0x00be, 0x0005,
-	0x00b6, 0x0046, 0x00e6, 0x00d6, 0x2028, 0x2130, 0x9696, 0x00ff,
-	0x11b8, 0x9592, 0xfffc, 0x02a0, 0x9596, 0xfffd, 0x1120, 0x2009,
-	0x007f, 0x0804, 0x7c9e, 0x9596, 0xfffe, 0x1120, 0x2009, 0x007e,
-	0x0804, 0x7c9e, 0x9596, 0xfffc, 0x1118, 0x2009, 0x0080, 0x04f0,
-	0x2011, 0x0000, 0x2019, 0x1836, 0x231c, 0xd3ac, 0x0130, 0x9026,
-	0x20a9, 0x0800, 0x2071, 0x1000, 0x0030, 0x2021, 0x0081, 0x20a9,
-	0x077f, 0x2071, 0x1081, 0x2e1c, 0x93dd, 0x0000, 0x1140, 0x82ff,
-	0x11d0, 0x9496, 0x00ff, 0x01b8, 0x2410, 0xc2fd, 0x00a0, 0xbf10,
-	0x2600, 0x9706, 0xb814, 0x1120, 0x9546, 0x1110, 0x2408, 0x00b0,
-	0x9745, 0x1148, 0x94c6, 0x007e, 0x0130, 0x94c6, 0x007f, 0x0118,
-	0x94c6, 0x0080, 0x1d20, 0x8420, 0x8e70, 0x1f04, 0x7c73, 0x82ff,
-	0x1118, 0x9085, 0x0001, 0x0018, 0xc2fc, 0x2208, 0x9006, 0x00de,
-	0x00ee, 0x004e, 0x00be, 0x0005, 0x7000, 0x908c, 0xff00, 0x810f,
-	0x9184, 0x000f, 0x0002, 0x7cbb, 0x7cbb, 0x7cbb, 0x7e59, 0x7cbb,
-	0x7cc4, 0x7cef, 0x7d7d, 0x7cbb, 0x7cbb, 0x7cbb, 0x7cbb, 0x7cbb,
-	0x7cbb, 0x7cbb, 0x7cbb, 0x7817, 0x0140, 0x2001, 0x19c0, 0x2004,
-	0x9005, 0x090c, 0x896d, 0x0005, 0x00b6, 0x7110, 0xd1bc, 0x01e8,
-	0x7120, 0x2160, 0x9c8c, 0x0007, 0x11c0, 0x9c8a, 0x1cd0, 0x02a8,
-	0x6864, 0x9c02, 0x1290, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158,
-	0xb910, 0x9106, 0x1150, 0x700c, 0xb914, 0x9106, 0x1130, 0x7124,
-	0x610a, 0x2009, 0x0046, 0x080c, 0x9ebc, 0x7817, 0x0140, 0x2001,
-	0x19c0, 0x2004, 0x9005, 0x090c, 0x896d, 0x00be, 0x0005, 0x00b6,
-	0x00c6, 0x9484, 0x0fff, 0x0904, 0x7d53, 0x7110, 0xd1bc, 0x1904,
-	0x7d53, 0x7108, 0x700c, 0x2028, 0x918c, 0x00ff, 0x2130, 0x9094,
-	0xff00, 0x15b0, 0x81ff, 0x15a0, 0x9080, 0x313a, 0x200d, 0x918c,
-	0xff00, 0x810f, 0x2001, 0x0080, 0x9106, 0x0904, 0x7d53, 0x080c,
-	0x61e7, 0x1904, 0x7d53, 0xbe12, 0xbd16, 0xb800, 0xd0ec, 0x15d8,
-	0xba04, 0x9294, 0xff00, 0x9286, 0x0600, 0x11a0, 0x080c, 0x9dec,
-	0x05e8, 0x2b08, 0x7028, 0x604a, 0x702c, 0x6046, 0x6112, 0x6023,
-	0x0006, 0x7120, 0x610a, 0x7130, 0x6156, 0x2009, 0x0044, 0x080c,
-	0xcb35, 0x0408, 0x080c, 0x656b, 0x1138, 0xb807, 0x0606, 0x0c30,
-	0x190c, 0x7c40, 0x11c0, 0x0898, 0x080c, 0x9dec, 0x2b08, 0x0198,
-	0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x9286, 0x0400, 0x1118,
-	0x6007, 0x0005, 0x0010, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
-	0x8422, 0x080c, 0x896d, 0x7817, 0x0140, 0x2001, 0x19c0, 0x2004,
-	0x9005, 0x090c, 0x896d, 0x00ce, 0x00be, 0x0005, 0x2001, 0x180e,
-	0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x48e9, 0x080c,
-	0x9e8f, 0x0d48, 0x2b08, 0x6112, 0x6023, 0x0006, 0x7120, 0x610a,
-	0x7130, 0x6156, 0x6017, 0xf300, 0x6003, 0x0001, 0x6007, 0x0041,
-	0x080c, 0x83da, 0x080c, 0x896d, 0x08b0, 0x00b6, 0x7110, 0xd1bc,
-	0x01e8, 0x7020, 0x2060, 0x9c84, 0x0007, 0x11c0, 0x9c82, 0x1cd0,
-	0x02a8, 0x6864, 0x9c02, 0x1290, 0x7008, 0x9084, 0x00ff, 0x6110,
-	0x2158, 0xb910, 0x9106, 0x1150, 0x700c, 0xb914, 0x9106, 0x1130,
-	0x7124, 0x610a, 0x2009, 0x0045, 0x080c, 0x9ebc, 0x7817, 0x0140,
-	0x2001, 0x19c0, 0x2004, 0x9005, 0x090c, 0x896d, 0x00be, 0x0005,
-	0x6120, 0x9186, 0x0002, 0x0128, 0x9186, 0x0005, 0x0110, 0x9085,
-	0x0001, 0x0005, 0x080c, 0x30ff, 0x1168, 0x7010, 0x9084, 0xff00,
-	0x8007, 0x9086, 0x0000, 0x1130, 0x9184, 0x000f, 0x908a, 0x0006,
-	0x1208, 0x000b, 0x0005, 0x7dc9, 0x7dca, 0x7dc9, 0x7dc9, 0x7e29,
-	0x7e38, 0x0005, 0x00b6, 0x7110, 0xd1bc, 0x0120, 0x702c, 0xd084,
-	0x0904, 0x7e27, 0x700c, 0x7108, 0x080c, 0x2665, 0x1904, 0x7e27,
-	0x080c, 0x61e7, 0x1904, 0x7e27, 0xbe12, 0xbd16, 0x7110, 0xd1bc,
-	0x01d8, 0x080c, 0x656b, 0x0118, 0x9086, 0x0004, 0x1588, 0x00c6,
-	0x080c, 0x7e47, 0x00ce, 0x05d8, 0x080c, 0x9dec, 0x2b08, 0x05b8,
-	0x6112, 0x080c, 0xbfa6, 0x6023, 0x0002, 0x7120, 0x610a, 0x2009,
-	0x0088, 0x080c, 0x9ebc, 0x0458, 0x080c, 0x656b, 0x0148, 0x9086,
-	0x0004, 0x0130, 0x080c, 0x6573, 0x0118, 0x9086, 0x0004, 0x1180,
-	0x080c, 0x9dec, 0x2b08, 0x01d8, 0x6112, 0x080c, 0xbfa6, 0x6023,
-	0x0005, 0x7120, 0x610a, 0x2009, 0x0088, 0x080c, 0x9ebc, 0x0078,
-	0x080c, 0x9dec, 0x2b08, 0x0158, 0x6112, 0x080c, 0xbfa6, 0x6023,
-	0x0004, 0x7120, 0x610a, 0x2009, 0x0001, 0x080c, 0x9ebc, 0x00be,
-	0x0005, 0x7110, 0xd1bc, 0x0158, 0x00d1, 0x0148, 0x080c, 0x7da8,
-	0x1130, 0x7124, 0x610a, 0x2009, 0x0089, 0x080c, 0x9ebc, 0x0005,
-	0x7110, 0xd1bc, 0x0158, 0x0059, 0x0148, 0x080c, 0x7da8, 0x1130,
-	0x7124, 0x610a, 0x2009, 0x008a, 0x080c, 0x9ebc, 0x0005, 0x7020,
-	0x2060, 0x9c84, 0x0007, 0x1158, 0x9c82, 0x1cd0, 0x0240, 0x2001,
-	0x1819, 0x2004, 0x9c02, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006,
-	0x0ce8, 0x00b6, 0x7110, 0xd1bc, 0x11d8, 0x7024, 0x2060, 0x9c84,
-	0x0007, 0x11b0, 0x9c82, 0x1cd0, 0x0298, 0x6864, 0x9c02, 0x1280,
-	0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1140,
-	0x700c, 0xb914, 0x9106, 0x1120, 0x2009, 0x0051, 0x080c, 0x9ebc,
-	0x7817, 0x0140, 0x2001, 0x19c0, 0x2004, 0x9005, 0x090c, 0x896d,
-	0x00be, 0x0005, 0x2031, 0x0105, 0x0069, 0x0005, 0x2031, 0x0206,
-	0x0049, 0x0005, 0x2031, 0x0207, 0x0029, 0x0005, 0x2031, 0x0213,
-	0x0009, 0x0005, 0x00c6, 0x0096, 0x00f6, 0x7000, 0x9084, 0xf000,
-	0x9086, 0xc000, 0x05d0, 0x080c, 0x9dec, 0x05b8, 0x0066, 0x00c6,
-	0x0046, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2665,
-	0x15a0, 0x080c, 0x61e7, 0x1588, 0xbe12, 0xbd16, 0x2b00, 0x004e,
-	0x00ce, 0x6012, 0x080c, 0xbfa6, 0x080c, 0x0feb, 0x0510, 0x2900,
-	0x605a, 0x9006, 0xa802, 0xa866, 0xac6a, 0xa85c, 0x90f8, 0x001b,
-	0x20a9, 0x000e, 0xa860, 0x20e8, 0x20e1, 0x0000, 0x2fa0, 0x2e98,
-	0x4003, 0x006e, 0x6616, 0x6007, 0x003e, 0x6023, 0x0001, 0x6003,
-	0x0001, 0x080c, 0x8422, 0x080c, 0x896d, 0x00fe, 0x009e, 0x00ce,
-	0x0005, 0x080c, 0x9e42, 0x006e, 0x0cc0, 0x004e, 0x00ce, 0x0cc8,
-	0x00c6, 0x7000, 0x908c, 0xff00, 0x9184, 0xf000, 0x810f, 0x9086,
-	0x2000, 0x1904, 0x7f37, 0x9186, 0x0022, 0x15f0, 0x2001, 0x0111,
-	0x2004, 0x9005, 0x1904, 0x7f39, 0x7030, 0x908e, 0x0400, 0x0904,
-	0x7f39, 0x908e, 0x6000, 0x05e8, 0x908e, 0x5400, 0x05d0, 0x908e,
-	0x0300, 0x11d8, 0x2009, 0x1836, 0x210c, 0xd18c, 0x1590, 0xd1a4,
-	0x1580, 0x080c, 0x6529, 0x0558, 0x68ac, 0x9084, 0x00ff, 0x7100,
-	0x918c, 0x00ff, 0x9106, 0x1518, 0x687c, 0x69ac, 0x918c, 0xff00,
-	0x9105, 0x7104, 0x9106, 0x11d8, 0x00e0, 0x2009, 0x0103, 0x210c,
-	0xd1b4, 0x11a8, 0x908e, 0x5200, 0x09e8, 0x908e, 0x0500, 0x09d0,
-	0x908e, 0x5000, 0x09b8, 0x0058, 0x9186, 0x0023, 0x1140, 0x080c,
-	0x7e47, 0x0128, 0x6004, 0x9086, 0x0002, 0x0118, 0x0000, 0x9006,
-	0x0010, 0x9085, 0x0001, 0x00ce, 0x0005, 0x00f6, 0x2079, 0x0200,
-	0x7800, 0xc0e5, 0xc0cc, 0x7802, 0x00fe, 0x0005, 0x00f6, 0x2079,
-	0x1800, 0x7834, 0xd084, 0x1130, 0x2079, 0x0200, 0x7800, 0x9085,
-	0x1200, 0x7802, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x1800, 0x7034,
-	0xc084, 0x7036, 0x00ee, 0x0005, 0x2071, 0x19ca, 0x7003, 0x0003,
-	0x700f, 0x0361, 0x9006, 0x701a, 0x7072, 0x7012, 0x7017, 0x1cd0,
-	0x7007, 0x0000, 0x7026, 0x702b, 0x93c3, 0x7032, 0x7037, 0x9431,
-	0x703f, 0xffff, 0x7042, 0x7047, 0x522e, 0x704a, 0x705b, 0x80bc,
-	0x080c, 0x1004, 0x090c, 0x0db4, 0x2900, 0x703a, 0xa867, 0x0003,
-	0xa86f, 0x0100, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x19ca, 0x1d04,
-	0x8010, 0x2091, 0x6000, 0x700c, 0x8001, 0x700e, 0x1510, 0x2001,
-	0x1875, 0x2004, 0xd0c4, 0x0158, 0x3a00, 0xd08c, 0x1140, 0x20d1,
-	0x0000, 0x20d1, 0x0001, 0x20d1, 0x0000, 0x080c, 0x0db4, 0x700f,
-	0x0361, 0x7007, 0x0001, 0x0126, 0x2091, 0x8000, 0x080c, 0x8101,
-	0x7040, 0x900d, 0x0148, 0x8109, 0x7142, 0x1130, 0x7044, 0x080f,
-	0x0018, 0x0126, 0x2091, 0x8000, 0x7024, 0x900d, 0x0188, 0x7020,
-	0x8001, 0x7022, 0x1168, 0x7023, 0x0009, 0x8109, 0x7126, 0x9186,
-	0x03e8, 0x1110, 0x7028, 0x080f, 0x81ff, 0x1110, 0x7028, 0x080f,
-	0x7030, 0x900d, 0x0180, 0x702c, 0x8001, 0x702e, 0x1160, 0x702f,
-	0x0009, 0x8109, 0x7132, 0x0128, 0x9184, 0x007f, 0x090c, 0x953e,
-	0x0010, 0x7034, 0x080f, 0x703c, 0x9005, 0x0118, 0x0310, 0x8001,
-	0x703e, 0x704c, 0x900d, 0x0168, 0x7048, 0x8001, 0x704a, 0x1148,
-	0x704b, 0x0009, 0x8109, 0x714e, 0x1120, 0x7150, 0x714e, 0x7058,
-	0x080f, 0x7018, 0x900d, 0x01d8, 0x0016, 0x7070, 0x900d, 0x0158,
-	0x706c, 0x8001, 0x706e, 0x1138, 0x706f, 0x0009, 0x8109, 0x7172,
-	0x1110, 0x7074, 0x080f, 0x001e, 0x7008, 0x8001, 0x700a, 0x1138,
-	0x700b, 0x0009, 0x8109, 0x711a, 0x1110, 0x701c, 0x080f, 0x012e,
-	0x7004, 0x0002, 0x8038, 0x8039, 0x8055, 0x00e6, 0x2071, 0x19ca,
-	0x7018, 0x9005, 0x1120, 0x711a, 0x721e, 0x700b, 0x0009, 0x00ee,
-	0x0005, 0x00e6, 0x0006, 0x2071, 0x19ca, 0x701c, 0x9206, 0x1120,
-	0x701a, 0x701e, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x00e6,
-	0x2071, 0x19ca, 0xb888, 0x9102, 0x0208, 0xb98a, 0x00ee, 0x0005,
-	0x0005, 0x00b6, 0x7110, 0x080c, 0x6247, 0x1168, 0xb888, 0x8001,
-	0x0250, 0xb88a, 0x1140, 0x0126, 0x2091, 0x8000, 0x0016, 0x080c,
-	0x896d, 0x001e, 0x012e, 0x8108, 0x9182, 0x0800, 0x0218, 0x900e,
-	0x7007, 0x0002, 0x7112, 0x00be, 0x0005, 0x7014, 0x2060, 0x0126,
-	0x2091, 0x8000, 0x6040, 0x9005, 0x0128, 0x8001, 0x6042, 0x1110,
-	0x080c, 0xbe37, 0x6018, 0x9005, 0x0528, 0x8001, 0x601a, 0x1510,
-	0x6120, 0x9186, 0x0003, 0x0118, 0x9186, 0x0006, 0x11c8, 0x080c,
-	0xbb2c, 0x01b0, 0x6014, 0x2048, 0xa884, 0x908a, 0x199a, 0x0280,
-	0x9082, 0x1999, 0xa886, 0x908a, 0x199a, 0x0210, 0x2001, 0x1999,
-	0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0xa87c, 0xd0e4, 0x0110,
-	0x080c, 0xb828, 0x012e, 0x9c88, 0x0018, 0x7116, 0x2001, 0x1819,
-	0x2004, 0x9102, 0x0220, 0x7017, 0x1cd0, 0x7007, 0x0000, 0x0005,
-	0x00e6, 0x2071, 0x19ca, 0x7027, 0x07d0, 0x7023, 0x0009, 0x00ee,
-	0x0005, 0x2001, 0x19d3, 0x2003, 0x0000, 0x0005, 0x00e6, 0x2071,
-	0x19ca, 0x7132, 0x702f, 0x0009, 0x00ee, 0x0005, 0x2011, 0x19d6,
-	0x2013, 0x0000, 0x0005, 0x00e6, 0x2071, 0x19ca, 0x711a, 0x721e,
-	0x700b, 0x0009, 0x00ee, 0x0005, 0x0086, 0x0026, 0x7054, 0x8000,
-	0x7056, 0x2001, 0x19d8, 0x2044, 0xa06c, 0x9086, 0x0000, 0x0150,
-	0x7068, 0xa09a, 0x7064, 0xa096, 0x7060, 0xa092, 0x705c, 0xa08e,
-	0x080c, 0x10d5, 0x002e, 0x008e, 0x0005, 0x0006, 0x0016, 0x0096,
-	0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0156, 0x080c,
-	0x7f85, 0x015e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae,
-	0x009e, 0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0x19ca, 0x7172,
-	0x7276, 0x706f, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071,
-	0x19ca, 0x7074, 0x9206, 0x1110, 0x7072, 0x7076, 0x000e, 0x00ee,
-	0x0005, 0x2069, 0x1800, 0x69e4, 0xd1e4, 0x1518, 0x0026, 0xd1ec,
-	0x0140, 0x6a50, 0x6870, 0x9202, 0x0288, 0x8117, 0x9294, 0x00c0,
-	0x0088, 0x9184, 0x0007, 0x01a0, 0x8109, 0x9184, 0x0007, 0x0110,
-	0x69e6, 0x0070, 0x8107, 0x9084, 0x0007, 0x910d, 0x8107, 0x9106,
-	0x9094, 0x00c0, 0x9184, 0xff3f, 0x9205, 0x68e6, 0x080c, 0x0ecb,
-	0x002e, 0x0005, 0x00c6, 0x2061, 0x1a40, 0x00ce, 0x0005, 0x9184,
-	0x000f, 0x8003, 0x8003, 0x8003, 0x9080, 0x1a40, 0x2060, 0x0005,
-	0xa884, 0x908a, 0x199a, 0x1638, 0x9005, 0x1150, 0x00c6, 0x2061,
-	0x1a40, 0x6014, 0x00ce, 0x9005, 0x1130, 0x2001, 0x001e, 0x0018,
-	0x908e, 0xffff, 0x01b0, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a,
-	0xa87c, 0x908c, 0x00c0, 0x918e, 0x00c0, 0x0904, 0x81c2, 0xd0b4,
-	0x1168, 0xd0bc, 0x1904, 0x819b, 0x2009, 0x0006, 0x080c, 0x81ef,
-	0x0005, 0x900e, 0x0c60, 0x2001, 0x1999, 0x08b0, 0xd0fc, 0x0160,
-	0x908c, 0x0003, 0x0120, 0x918e, 0x0003, 0x1904, 0x81e9, 0x908c,
-	0x2020, 0x918e, 0x2020, 0x01a8, 0x6024, 0xd0d4, 0x11e8, 0x2009,
-	0x1875, 0x2104, 0xd084, 0x1138, 0x87ff, 0x1120, 0x2009, 0x0043,
-	0x0804, 0x9ebc, 0x0005, 0x87ff, 0x1de8, 0x2009, 0x0042, 0x0804,
-	0x9ebc, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20,
-	0x6024, 0xc0cd, 0x6026, 0x0c00, 0xc0d4, 0x6026, 0xa890, 0x602e,
-	0xa88c, 0x6032, 0x08e0, 0xd0fc, 0x0160, 0x908c, 0x0003, 0x0120,
-	0x918e, 0x0003, 0x1904, 0x81e9, 0x908c, 0x2020, 0x918e, 0x2020,
-	0x0170, 0x0076, 0x00f6, 0x2c78, 0x080c, 0x164a, 0x00fe, 0x007e,
-	0x87ff, 0x1120, 0x2009, 0x0042, 0x080c, 0x9ebc, 0x0005, 0x6110,
-	0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d58, 0x6124, 0xc1cd,
-	0x6126, 0x0c38, 0xd0fc, 0x0188, 0x908c, 0x2020, 0x918e, 0x2020,
-	0x01a8, 0x9084, 0x0003, 0x908e, 0x0002, 0x0148, 0x87ff, 0x1120,
-	0x2009, 0x0041, 0x080c, 0x9ebc, 0x0005, 0x00b9, 0x0ce8, 0x87ff,
-	0x1dd8, 0x2009, 0x0043, 0x080c, 0x9ebc, 0x0cb0, 0x6110, 0x00b6,
-	0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20, 0x6124, 0xc1cd, 0x6126,
-	0x0c00, 0x2009, 0x0004, 0x0019, 0x0005, 0x2009, 0x0001, 0x0096,
-	0x080c, 0xbb2c, 0x0518, 0x6014, 0x2048, 0xa982, 0xa800, 0x6016,
-	0x9186, 0x0001, 0x1188, 0xa97c, 0x918c, 0x8100, 0x918e, 0x8100,
-	0x1158, 0x00c6, 0x2061, 0x1a40, 0x6200, 0xd28c, 0x1120, 0x6204,
-	0x8210, 0x0208, 0x6206, 0x00ce, 0x080c, 0x66cb, 0x6014, 0x904d,
-	0x0076, 0x2039, 0x0000, 0x190c, 0x8138, 0x007e, 0x009e, 0x0005,
-	0x0156, 0x00c6, 0x2061, 0x1a40, 0x6000, 0x81ff, 0x0110, 0x9205,
-	0x0008, 0x9204, 0x6002, 0x00ce, 0x015e, 0x0005, 0x6800, 0xd08c,
-	0x1138, 0x6808, 0x9005, 0x0120, 0x8001, 0x680a, 0x9085, 0x0001,
-	0x0005, 0x0126, 0x2091, 0x8000, 0x0036, 0x0046, 0x20a9, 0x0010,
-	0x9006, 0x8004, 0x2019, 0x0100, 0x231c, 0x93a6, 0x0008, 0x1118,
-	0x8086, 0x818e, 0x0020, 0x80f6, 0x3e00, 0x81f6, 0x3e08, 0x1208,
-	0x9200, 0x1f04, 0x823a, 0x93a6, 0x0008, 0x1118, 0x8086, 0x818e,
-	0x0020, 0x80f6, 0x3e00, 0x81f6, 0x3e08, 0x004e, 0x003e, 0x012e,
-	0x0005, 0x0126, 0x2091, 0x8000, 0x0076, 0x0156, 0x20a9, 0x0010,
-	0x9005, 0x0510, 0x911a, 0x1600, 0x8213, 0x2039, 0x0100, 0x273c,
-	0x97be, 0x0008, 0x1110, 0x818d, 0x0010, 0x81f5, 0x3e08, 0x0228,
-	0x911a, 0x1220, 0x1f04, 0x8264, 0x0028, 0x911a, 0x2308, 0x8210,
-	0x1f04, 0x8264, 0x0006, 0x3200, 0x9084, 0xefff, 0x2080, 0x000e,
-	0x015e, 0x007e, 0x012e, 0x0005, 0x0006, 0x3200, 0x9085, 0x1000,
-	0x0ca8, 0x0126, 0x2091, 0x2800, 0x2079, 0x19b7, 0x012e, 0x00d6,
-	0x2069, 0x19b7, 0x6803, 0x0005, 0x0156, 0x0146, 0x01d6, 0x20e9,
-	0x0000, 0x2069, 0x0200, 0x080c, 0x9c4a, 0x0401, 0x080c, 0x9c35,
-	0x00e9, 0x080c, 0x9c38, 0x00d1, 0x080c, 0x9c3b, 0x00b9, 0x080c,
-	0x9c3e, 0x00a1, 0x080c, 0x9c41, 0x0089, 0x080c, 0x9c44, 0x0071,
-	0x080c, 0x9c47, 0x0059, 0x01de, 0x014e, 0x015e, 0x2069, 0x0004,
-	0x2d04, 0x9085, 0x8001, 0x206a, 0x00de, 0x0005, 0x20a9, 0x0020,
-	0x20a1, 0x0240, 0x2001, 0x0000, 0x4004, 0x0005, 0x00c6, 0x6027,
-	0x0001, 0x7804, 0x9084, 0x0007, 0x0002, 0x82d7, 0x82fb, 0x833a,
-	0x82dd, 0x82fb, 0x82d7, 0x82d5, 0x82d5, 0x080c, 0x0db4, 0x080c,
-	0x80a1, 0x080c, 0x896d, 0x00ce, 0x0005, 0x62c0, 0x82ff, 0x1110,
-	0x00ce, 0x0005, 0x2011, 0x5b43, 0x080c, 0x8021, 0x7828, 0x9092,
-	0x00c8, 0x1228, 0x8000, 0x782a, 0x080c, 0x5b83, 0x0c88, 0x62c0,
-	0x080c, 0x9c4e, 0x080c, 0x5b43, 0x7807, 0x0003, 0x7827, 0x0000,
-	0x782b, 0x0000, 0x0c28, 0x080c, 0x80a1, 0x6220, 0xd2a4, 0x0160,
-	0x782b, 0x0000, 0x7824, 0x9065, 0x090c, 0x0db4, 0x2009, 0x0013,
-	0x080c, 0x9ebc, 0x00ce, 0x0005, 0x00c6, 0x7824, 0x9065, 0x090c,
-	0x0db4, 0x7828, 0x9092, 0xc350, 0x12c0, 0x8000, 0x782a, 0x00ce,
-	0x080c, 0x29cc, 0x0278, 0x00c6, 0x7924, 0x2160, 0x6010, 0x906d,
-	0x090c, 0x0db4, 0x7807, 0x0000, 0x7827, 0x0000, 0x00ce, 0x080c,
-	0x896d, 0x0c00, 0x080c, 0x9389, 0x08e8, 0x2011, 0x0130, 0x2214,
-	0x080c, 0x9c4e, 0x080c, 0xd8ea, 0x2009, 0x0014, 0x080c, 0x9ebc,
-	0x00ce, 0x0880, 0x2001, 0x19d3, 0x2003, 0x0000, 0x62c0, 0x82ff,
-	0x1160, 0x782b, 0x0000, 0x7824, 0x9065, 0x090c, 0x0db4, 0x2009,
-	0x0013, 0x080c, 0x9f0e, 0x00ce, 0x0005, 0x00b6, 0x00c6, 0x00d6,
-	0x7824, 0x9005, 0x090c, 0x0db4, 0x7828, 0x9092, 0xc350, 0x1648,
-	0x8000, 0x782a, 0x00de, 0x00ce, 0x00be, 0x080c, 0x29cc, 0x02f0,
-	0x00b6, 0x00c6, 0x00d6, 0x781c, 0x905d, 0x090c, 0x0db4, 0xb800,
-	0xc0dc, 0xb802, 0x7924, 0x2160, 0x080c, 0x9e42, 0xb93c, 0x81ff,
-	0x090c, 0x0db4, 0x8109, 0xb93e, 0x7807, 0x0000, 0x7827, 0x0000,
-	0x00de, 0x00ce, 0x00be, 0x080c, 0x896d, 0x0868, 0x080c, 0x9389,
-	0x0850, 0x2011, 0x0130, 0x2214, 0x080c, 0x9c4e, 0x080c, 0xd8ea,
-	0x7824, 0x9065, 0x2009, 0x0014, 0x080c, 0x9ebc, 0x00de, 0x00ce,
-	0x00be, 0x0804, 0x834b, 0x00c6, 0x2001, 0x009b, 0x2004, 0xd0fc,
-	0x190c, 0x1d4c, 0x6024, 0x6027, 0x0002, 0xd0f4, 0x1580, 0x62c8,
-	0x60c4, 0x9205, 0x1170, 0x783c, 0x9065, 0x0130, 0x2009, 0x0049,
-	0x080c, 0x9ebc, 0x00ce, 0x0005, 0x2011, 0x19d6, 0x2013, 0x0000,
-	0x0cc8, 0x793c, 0x81ff, 0x0dc0, 0x7944, 0x9192, 0x7530, 0x12f0,
-	0x8108, 0x7946, 0x793c, 0x9188, 0x0008, 0x210c, 0x918e, 0x0006,
-	0x1138, 0x6014, 0x9084, 0x1984, 0x9085, 0x0012, 0x6016, 0x0c10,
-	0x6014, 0x9084, 0x1984, 0x9085, 0x0016, 0x6016, 0x08d8, 0x793c,
-	0x2160, 0x2009, 0x004a, 0x080c, 0x9ebc, 0x08a0, 0x7848, 0xc085,
-	0x784a, 0x0880, 0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x600f, 0x0000, 0x2c08, 0x2061, 0x19b7, 0x6020, 0x8000, 0x6022,
-	0x6010, 0x9005, 0x0148, 0x9080, 0x0003, 0x2102, 0x6112, 0x012e,
-	0x00ce, 0x001e, 0x000e, 0x0005, 0x6116, 0x6112, 0x0cc0, 0x00d6,
-	0x2069, 0x19b7, 0xb800, 0xd0d4, 0x0168, 0x6820, 0x8000, 0x6822,
-	0x9086, 0x0001, 0x1110, 0x2b00, 0x681e, 0x00de, 0x0804, 0x896d,
-	0x00de, 0x0005, 0xc0d5, 0xb802, 0x6818, 0x9005, 0x0168, 0xb856,
-	0xb85b, 0x0000, 0x0086, 0x0006, 0x2b00, 0x681a, 0x008e, 0xa05a,
-	0x008e, 0x2069, 0x19b7, 0x0c08, 0xb856, 0xb85a, 0x2b00, 0x681a,
-	0x681e, 0x08d8, 0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x600f, 0x0000, 0x2c08, 0x2061, 0x19b7, 0x6020, 0x8000, 0x6022,
-	0x6008, 0x9005, 0x0148, 0x9080, 0x0003, 0x2102, 0x610a, 0x012e,
-	0x00ce, 0x001e, 0x000e, 0x0005, 0x610e, 0x610a, 0x0cc0, 0x00c6,
-	0x600f, 0x0000, 0x2c08, 0x2061, 0x19b7, 0x6034, 0x9005, 0x0130,
-	0x9080, 0x0003, 0x2102, 0x6136, 0x00ce, 0x0005, 0x613a, 0x6136,
-	0x00ce, 0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00b6, 0x0096,
-	0x0076, 0x0066, 0x0056, 0x0036, 0x0026, 0x0016, 0x0006, 0x0126,
-	0x902e, 0x2071, 0x19b7, 0x7638, 0x2660, 0x2678, 0x2091, 0x8000,
-	0x8cff, 0x0904, 0x84ce, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904,
-	0x84c9, 0x87ff, 0x0120, 0x6054, 0x9106, 0x1904, 0x84c9, 0x703c,
-	0x9c06, 0x1178, 0x0036, 0x2019, 0x0001, 0x080c, 0x96d9, 0x7033,
-	0x0000, 0x9006, 0x703e, 0x7042, 0x7046, 0x704a, 0x003e, 0x2029,
-	0x0001, 0x7038, 0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36,
-	0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037,
-	0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
-	0x2678, 0x600f, 0x0000, 0x080c, 0xbb2c, 0x01f0, 0x6014, 0x2048,
-	0x6020, 0x9086, 0x0003, 0x15b8, 0x6004, 0x9086, 0x0040, 0x090c,
-	0x98db, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036,
-	0x0076, 0x080c, 0xbe20, 0x080c, 0xd7f4, 0x080c, 0x6891, 0x007e,
-	0x003e, 0x001e, 0x080c, 0xbd15, 0x080c, 0x9e72, 0x00ce, 0x0804,
-	0x8468, 0x2c78, 0x600c, 0x2060, 0x0804, 0x8468, 0x85ff, 0x0120,
-	0x0036, 0x080c, 0x8a4a, 0x003e, 0x012e, 0x000e, 0x001e, 0x002e,
-	0x003e, 0x005e, 0x006e, 0x007e, 0x009e, 0x00be, 0x00ce, 0x00de,
-	0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016,
-	0x0036, 0x0076, 0x080c, 0xd7f4, 0x080c, 0xd4f6, 0x007e, 0x003e,
-	0x001e, 0x0890, 0x6020, 0x9086, 0x000a, 0x0904, 0x84b3, 0x0804,
-	0x84ac, 0x0006, 0x0066, 0x0096, 0x00c6, 0x00d6, 0x00f6, 0x9036,
-	0x0126, 0x2091, 0x8000, 0x2079, 0x19b7, 0x7838, 0x9065, 0x0904,
-	0x854e, 0x600c, 0x0006, 0x600f, 0x0000, 0x783c, 0x9c06, 0x1168,
-	0x0036, 0x2019, 0x0001, 0x080c, 0x96d9, 0x7833, 0x0000, 0x901e,
-	0x7b3e, 0x7b42, 0x7b46, 0x7b4a, 0x003e, 0x080c, 0xbb2c, 0x0548,
-	0x6014, 0x2048, 0x6020, 0x9086, 0x0003, 0x1590, 0x3e08, 0x918e,
-	0x0002, 0x1188, 0x6010, 0x9005, 0x0170, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x0140, 0x6040, 0x9005, 0x11a8, 0x2001, 0x1958,
-	0x2004, 0x6042, 0x0080, 0x6004, 0x9086, 0x0040, 0x090c, 0x98db,
-	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6884, 0x080c,
-	0xbd15, 0x080c, 0x9e72, 0x000e, 0x0804, 0x8506, 0x7e3a, 0x7e36,
-	0x012e, 0x00fe, 0x00de, 0x00ce, 0x009e, 0x006e, 0x000e, 0x0005,
-	0x6020, 0x9086, 0x0006, 0x1118, 0x080c, 0xd4f6, 0x0c50, 0x6020,
-	0x9086, 0x000a, 0x09f8, 0x08b8, 0x0016, 0x0026, 0x0086, 0x9046,
-	0x0099, 0x080c, 0x864d, 0x008e, 0x002e, 0x001e, 0x0005, 0x00f6,
-	0x0126, 0x2079, 0x19b7, 0x2091, 0x8000, 0x080c, 0x86e4, 0x080c,
-	0x8772, 0x012e, 0x00fe, 0x0005, 0x00b6, 0x0096, 0x00f6, 0x00e6,
-	0x00d6, 0x00c6, 0x0066, 0x0016, 0x0006, 0x0126, 0x2091, 0x8000,
-	0x2071, 0x19b7, 0x7614, 0x2660, 0x2678, 0x8cff, 0x0904, 0x8612,
-	0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x860d, 0x88ff, 0x0120,
-	0x6054, 0x9106, 0x1904, 0x860d, 0x7024, 0x9c06, 0x1558, 0x2069,
-	0x0100, 0x6820, 0xd0a4, 0x1508, 0x080c, 0x80a1, 0x080c, 0x93ad,
-	0x68c3, 0x0000, 0x080c, 0x98db, 0x7027, 0x0000, 0x0036, 0x2069,
-	0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c,
-	0x2b16, 0x9006, 0x080c, 0x2b16, 0x2069, 0x0100, 0x6824, 0xd084,
-	0x0110, 0x6827, 0x0001, 0x003e, 0x0028, 0x6003, 0x0009, 0x630a,
-	0x0804, 0x860d, 0x7014, 0x9c36, 0x1110, 0x660c, 0x7616, 0x7010,
-	0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7012, 0x0010,
-	0x7013, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e,
-	0x0008, 0x2678, 0x600f, 0x0000, 0x6014, 0x2048, 0x080c, 0xbb2c,
-	0x01e8, 0x6020, 0x9086, 0x0003, 0x1580, 0x080c, 0xbd32, 0x1118,
-	0x080c, 0xa7d1, 0x0098, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000,
-	0x0016, 0x0036, 0x0086, 0x080c, 0xbe20, 0x080c, 0xd7f4, 0x080c,
-	0x6891, 0x008e, 0x003e, 0x001e, 0x080c, 0xbd15, 0x080c, 0x9e72,
-	0x080c, 0x97b1, 0x00ce, 0x0804, 0x858d, 0x2c78, 0x600c, 0x2060,
-	0x0804, 0x858d, 0x012e, 0x000e, 0x001e, 0x006e, 0x00ce, 0x00de,
-	0x00ee, 0x00fe, 0x009e, 0x00be, 0x0005, 0x6020, 0x9086, 0x0006,
-	0x1158, 0x0016, 0x0036, 0x0086, 0x080c, 0xd7f4, 0x080c, 0xd4f6,
-	0x008e, 0x003e, 0x001e, 0x08d0, 0x080c, 0xa7d1, 0x6020, 0x9086,
-	0x0002, 0x1160, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0904,
-	0x85f3, 0x9086, 0x008b, 0x0904, 0x85f3, 0x0840, 0x6020, 0x9086,
-	0x0005, 0x1920, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x09c8,
-	0x9086, 0x008b, 0x09b0, 0x0804, 0x8606, 0x00b6, 0x00a6, 0x0096,
-	0x00c6, 0x0006, 0x0126, 0x2091, 0x8000, 0x9280, 0x1000, 0x2004,
-	0x905d, 0x0904, 0x86dd, 0x00f6, 0x00e6, 0x00d6, 0x0066, 0x2071,
-	0x19b7, 0xbe54, 0x7018, 0x9b06, 0x1108, 0x761a, 0x701c, 0x9b06,
-	0x1130, 0x86ff, 0x1118, 0x7018, 0x701e, 0x0008, 0x761e, 0xb858,
-	0x904d, 0x0108, 0xae56, 0x96d5, 0x0000, 0x0110, 0x2900, 0xb05a,
-	0xb857, 0x0000, 0xb85b, 0x0000, 0xb800, 0xc0d4, 0xc0dc, 0xb802,
-	0x080c, 0x617a, 0x0904, 0x86d9, 0x7624, 0x86ff, 0x0904, 0x86c8,
-	0x9680, 0x0005, 0x2004, 0x9906, 0x15d8, 0x00d6, 0x2069, 0x0100,
-	0x68c0, 0x9005, 0x0560, 0x080c, 0x80a1, 0x080c, 0x93ad, 0x68c3,
-	0x0000, 0x080c, 0x98db, 0x7027, 0x0000, 0x0036, 0x2069, 0x0140,
-	0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2b16,
-	0x9006, 0x080c, 0x2b16, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
-	0x6827, 0x0001, 0x003e, 0x00de, 0x00c6, 0xb83c, 0x9005, 0x0110,
-	0x8001, 0xb83e, 0x2660, 0x080c, 0x9e72, 0x00ce, 0x0048, 0x00de,
-	0x00c6, 0x2660, 0x6003, 0x0009, 0x630a, 0x00ce, 0x0804, 0x8680,
-	0x89ff, 0x0158, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
-	0xbe20, 0x080c, 0xd7f4, 0x080c, 0x6891, 0x080c, 0x97b1, 0x0804,
-	0x8680, 0x006e, 0x00de, 0x00ee, 0x00fe, 0x012e, 0x000e, 0x00ce,
-	0x009e, 0x00ae, 0x00be, 0x0005, 0x0096, 0x0006, 0x0066, 0x00c6,
-	0x00d6, 0x9036, 0x7814, 0x9065, 0x0904, 0x8745, 0x600c, 0x0006,
-	0x600f, 0x0000, 0x7824, 0x9c06, 0x1570, 0x2069, 0x0100, 0x6820,
-	0xd0a4, 0x1508, 0x080c, 0x80a1, 0x080c, 0x93ad, 0x68c3, 0x0000,
-	0x080c, 0x98db, 0x7827, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04,
-	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2b16, 0x9006,
-	0x080c, 0x2b16, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
-	0x0001, 0x003e, 0x0040, 0x080c, 0x6521, 0x1520, 0x6003, 0x0009,
-	0x630a, 0x2c30, 0x00f8, 0x6014, 0x2048, 0x080c, 0xbb2a, 0x01b0,
-	0x6020, 0x9086, 0x0003, 0x1508, 0x080c, 0xbd32, 0x1118, 0x080c,
-	0xa7d1, 0x0060, 0x080c, 0x6521, 0x1168, 0xa867, 0x0103, 0xab7a,
-	0xa877, 0x0000, 0x080c, 0x6891, 0x080c, 0xbd15, 0x080c, 0x9e72,
-	0x080c, 0x97b1, 0x000e, 0x0804, 0x86eb, 0x7e16, 0x7e12, 0x00de,
-	0x00ce, 0x006e, 0x000e, 0x009e, 0x0005, 0x6020, 0x9086, 0x0006,
-	0x1118, 0x080c, 0xd4f6, 0x0c50, 0x080c, 0xa7d1, 0x6020, 0x9086,
-	0x0002, 0x1150, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0990,
-	0x9086, 0x008b, 0x0978, 0x08d0, 0x6020, 0x9086, 0x0005, 0x19b0,
-	0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0d18, 0x9086, 0x008b,
-	0x0d00, 0x0860, 0x0006, 0x0066, 0x0096, 0x00b6, 0x00c6, 0x00d6,
-	0x7818, 0x905d, 0x0904, 0x87f2, 0xb854, 0x0006, 0x9006, 0xb856,
-	0xb85a, 0xb800, 0xc0d4, 0xc0dc, 0xb802, 0x080c, 0x617a, 0x0904,
-	0x87ef, 0x7e24, 0x86ff, 0x0904, 0x87e2, 0x9680, 0x0005, 0x2004,
-	0x9906, 0x1904, 0x87e2, 0x00d6, 0x2069, 0x0100, 0x68c0, 0x9005,
-	0x0904, 0x87d9, 0x080c, 0x80a1, 0x080c, 0x93ad, 0x68c3, 0x0000,
-	0x080c, 0x98db, 0x7827, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04,
-	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2b16, 0x9006,
-	0x080c, 0x2b16, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
-	0x0001, 0x003e, 0x00de, 0x00c6, 0x3e08, 0x918e, 0x0002, 0x1168,
-	0xb800, 0xd0bc, 0x0150, 0x9680, 0x0010, 0x200c, 0x81ff, 0x1518,
-	0x2009, 0x1958, 0x210c, 0x2102, 0x00f0, 0xb83c, 0x9005, 0x0110,
-	0x8001, 0xb83e, 0x2660, 0x600f, 0x0000, 0x080c, 0x9e72, 0x00ce,
-	0x0048, 0x00de, 0x00c6, 0x2660, 0x6003, 0x0009, 0x630a, 0x00ce,
-	0x0804, 0x8785, 0x89ff, 0x0138, 0xa867, 0x0103, 0xab7a, 0xa877,
-	0x0000, 0x080c, 0x6891, 0x080c, 0x97b1, 0x0804, 0x8785, 0x000e,
-	0x0804, 0x8779, 0x781e, 0x781a, 0x00de, 0x00ce, 0x00be, 0x009e,
-	0x006e, 0x000e, 0x0005, 0x00e6, 0x00d6, 0x0096, 0x0066, 0xb800,
-	0xd0dc, 0x01a0, 0xb84c, 0x904d, 0x0188, 0xa878, 0x9606, 0x1170,
-	0x2071, 0x19b7, 0x7024, 0x9035, 0x0148, 0x9080, 0x0005, 0x2004,
-	0x9906, 0x1120, 0xb800, 0xc0dc, 0xb802, 0x0029, 0x006e, 0x009e,
-	0x00de, 0x00ee, 0x0005, 0x00f6, 0x2079, 0x0100, 0x78c0, 0x9005,
-	0x1138, 0x00c6, 0x2660, 0x6003, 0x0009, 0x630a, 0x00ce, 0x04b8,
-	0x080c, 0x93ad, 0x78c3, 0x0000, 0x080c, 0x98db, 0x7027, 0x0000,
-	0x0036, 0x2079, 0x0140, 0x7b04, 0x9384, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2b16, 0x9006, 0x080c, 0x2b16, 0x2079, 0x0100,
-	0x7824, 0xd084, 0x0110, 0x7827, 0x0001, 0x080c, 0x98db, 0x003e,
-	0x080c, 0x617a, 0x00c6, 0xb83c, 0x9005, 0x0110, 0x8001, 0xb83e,
-	0x2660, 0x080c, 0x9e42, 0x00ce, 0xa867, 0x0103, 0xab7a, 0xa877,
-	0x0000, 0x080c, 0xbe20, 0x080c, 0x6891, 0x080c, 0x97b1, 0x00fe,
-	0x0005, 0x00b6, 0x00e6, 0x00c6, 0x2011, 0x0101, 0x2204, 0xc0c4,
-	0x2012, 0x2001, 0x180c, 0x2014, 0xc2e4, 0x2202, 0x2071, 0x19b7,
-	0x7004, 0x9084, 0x0007, 0x0002, 0x887e, 0x8882, 0x88a0, 0x88c9,
-	0x8907, 0x887e, 0x8899, 0x887c, 0x080c, 0x0db4, 0x00ce, 0x00ee,
-	0x00be, 0x0005, 0x7024, 0x9065, 0x0148, 0x7020, 0x8001, 0x7022,
-	0x600c, 0x9015, 0x0158, 0x7216, 0x600f, 0x0000, 0x7007, 0x0000,
-	0x7027, 0x0000, 0x00ce, 0x00ee, 0x00be, 0x0005, 0x7216, 0x7212,
-	0x0ca8, 0x7007, 0x0000, 0x7027, 0x0000, 0x7020, 0x9005, 0x0070,
-	0x6010, 0x2058, 0x080c, 0x617a, 0xb800, 0xc0dc, 0xb802, 0x7007,
-	0x0000, 0x7027, 0x0000, 0x7020, 0x8001, 0x7022, 0x1148, 0x2001,
-	0x180c, 0x2014, 0xd2ec, 0x1180, 0x00ce, 0x00ee, 0x00be, 0x0005,
-	0xb854, 0x9015, 0x0120, 0x721e, 0x080c, 0x896d, 0x0ca8, 0x7218,
-	0x721e, 0x080c, 0x896d, 0x0c80, 0xc2ec, 0x2202, 0x080c, 0x8a4a,
-	0x0c58, 0x7024, 0x9065, 0x05b8, 0x700c, 0x9c06, 0x1160, 0x080c,
-	0x97b1, 0x600c, 0x9015, 0x0120, 0x720e, 0x600f, 0x0000, 0x0448,
-	0x720e, 0x720a, 0x0430, 0x7014, 0x9c06, 0x1160, 0x080c, 0x97b1,
-	0x600c, 0x9015, 0x0120, 0x7216, 0x600f, 0x0000, 0x00d0, 0x7216,
-	0x7212, 0x00b8, 0x6020, 0x9086, 0x0003, 0x1198, 0x6010, 0x2058,
-	0x080c, 0x617a, 0xb800, 0xc0dc, 0xb802, 0x080c, 0x97b1, 0x701c,
-	0x9065, 0x0138, 0xb854, 0x9015, 0x0110, 0x721e, 0x0010, 0x7218,
-	0x721e, 0x7027, 0x0000, 0x00ce, 0x00ee, 0x00be, 0x0005, 0x7024,
-	0x9065, 0x0140, 0x080c, 0x97b1, 0x600c, 0x9015, 0x0158, 0x720e,
-	0x600f, 0x0000, 0x080c, 0x98db, 0x7027, 0x0000, 0x00ce, 0x00ee,
-	0x00be, 0x0005, 0x720e, 0x720a, 0x0ca8, 0x00d6, 0x2069, 0x19b7,
-	0x6830, 0x9084, 0x0003, 0x0002, 0x892a, 0x892c, 0x8950, 0x8928,
-	0x080c, 0x0db4, 0x00de, 0x0005, 0x00c6, 0x6840, 0x9086, 0x0001,
-	0x01b8, 0x683c, 0x9065, 0x0130, 0x600c, 0x9015, 0x0170, 0x6a3a,
-	0x600f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000, 0x2011, 0x19d6,
-	0x2013, 0x0000, 0x00ce, 0x00de, 0x0005, 0x683a, 0x6836, 0x0c90,
-	0x6843, 0x0000, 0x6838, 0x9065, 0x0d68, 0x6003, 0x0003, 0x0c50,
-	0x00c6, 0x9006, 0x6842, 0x6846, 0x684a, 0x683c, 0x9065, 0x0160,
-	0x600c, 0x9015, 0x0130, 0x6a3a, 0x600f, 0x0000, 0x683f, 0x0000,
-	0x0018, 0x683e, 0x683a, 0x6836, 0x00ce, 0x00de, 0x0005, 0x2001,
-	0x180c, 0x200c, 0xc1e5, 0x2102, 0x0005, 0x2001, 0x180c, 0x200c,
-	0xd1ec, 0x0120, 0xc1ec, 0x2102, 0x080c, 0x8a4a, 0x2001, 0x19c3,
-	0x2004, 0x9086, 0x0001, 0x0d58, 0x00d6, 0x2069, 0x19b7, 0x6804,
-	0x9084, 0x0007, 0x0002, 0x898d, 0x8a32, 0x8a32, 0x8a32, 0x8a32,
-	0x8a34, 0x8a32, 0x898b, 0x080c, 0x0db4, 0x6820, 0x9005, 0x1110,
-	0x00de, 0x0005, 0x00c6, 0x680c, 0x9065, 0x0150, 0x6807, 0x0004,
-	0x6826, 0x682b, 0x0000, 0x080c, 0x8aa5, 0x00ce, 0x00de, 0x0005,
-	0x6814, 0x9065, 0x0150, 0x6807, 0x0001, 0x6826, 0x682b, 0x0000,
-	0x080c, 0x8aa5, 0x00ce, 0x00de, 0x0005, 0x00b6, 0x00e6, 0x6a1c,
-	0x92dd, 0x0000, 0x0904, 0x8a1c, 0xb84c, 0x900d, 0x0118, 0xb888,
-	0x9005, 0x01a0, 0xb854, 0x905d, 0x0120, 0x920e, 0x0904, 0x8a1c,
-	0x0028, 0x6818, 0x920e, 0x0904, 0x8a1c, 0x2058, 0xb84c, 0x900d,
-	0x0d88, 0xb888, 0x9005, 0x1d70, 0x2b00, 0x681e, 0xbb3c, 0xb838,
-	0x9302, 0x1e40, 0x080c, 0x9e19, 0x0904, 0x8a1c, 0x8318, 0xbb3e,
-	0x6116, 0x2b10, 0x6212, 0x0096, 0x2148, 0xa880, 0x9084, 0x00ff,
-	0x605e, 0xa883, 0x0000, 0xa884, 0x009e, 0x908a, 0x199a, 0x0210,
-	0x2001, 0x1999, 0x8003, 0x801b, 0x831b, 0x9318, 0x631a, 0x6114,
-	0x0096, 0x2148, 0xa964, 0x009e, 0x918c, 0x00ff, 0x918e, 0x0048,
-	0x0538, 0x00f6, 0x2c78, 0x2061, 0x0100, 0xbab0, 0x629a, 0x2069,
-	0x0200, 0x2071, 0x0240, 0x080c, 0x8fdd, 0x2069, 0x19b7, 0xbb00,
-	0xc3dd, 0xbb02, 0x6807, 0x0002, 0x2f18, 0x6b26, 0x682b, 0x0000,
-	0x7823, 0x0003, 0x7803, 0x0001, 0x7807, 0x0040, 0x00fe, 0x00ee,
-	0x00be, 0x00ce, 0x00de, 0x0005, 0x00ee, 0x00be, 0x00ce, 0x0cd0,
-	0x6807, 0x0006, 0x2c18, 0x6b26, 0x6820, 0x8001, 0x6822, 0x682b,
-	0x0000, 0x080c, 0x617a, 0x080c, 0x9c6e, 0x00ee, 0x00be, 0x00ce,
-	0x00de, 0x0005, 0x00de, 0x0005, 0x00c6, 0x680c, 0x9065, 0x0138,
-	0x6807, 0x0004, 0x6826, 0x682b, 0x0000, 0x080c, 0x8aa5, 0x00ce,
-	0x00de, 0x0005, 0x2001, 0x180c, 0x2014, 0xc2ed, 0x2202, 0x00de,
-	0x00fe, 0x0005, 0x00f6, 0x00d6, 0x2069, 0x19b7, 0x6830, 0x9086,
-	0x0000, 0x1548, 0x2001, 0x180c, 0x2014, 0xd2e4, 0x0130, 0xc2e4,
-	0x2202, 0x080c, 0x897c, 0x2069, 0x19b7, 0x2001, 0x180c, 0x200c,
-	0xd1c4, 0x11e0, 0x6838, 0x907d, 0x01b0, 0x6a04, 0x9296, 0x0000,
-	0x1588, 0x6833, 0x0001, 0x683e, 0x6847, 0x0000, 0x684b, 0x0000,
-	0x0126, 0x00f6, 0x2091, 0x2400, 0x002e, 0x080c, 0x1aea, 0x1178,
-	0x012e, 0x080c, 0x920a, 0x00de, 0x00fe, 0x0005, 0xc1c4, 0x2102,
-	0x0066, 0x2031, 0x0001, 0x080c, 0x704b, 0x006e, 0x08d8, 0x012e,
-	0x6843, 0x0000, 0x7803, 0x0002, 0x780c, 0x9015, 0x0140, 0x6a3a,
-	0x780f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000, 0x0c20, 0x683a,
-	0x6836, 0x0cc0, 0x6a04, 0x9296, 0x0006, 0x1904, 0x8a42, 0x6a30,
-	0x9296, 0x0000, 0x0930, 0x0804, 0x8a42, 0x6020, 0x9084, 0x000f,
-	0x000b, 0x0005, 0x8ab9, 0x8abe, 0x8f17, 0x8fa6, 0x8abe, 0x8f17,
-	0x8fa6, 0x8ab9, 0x8abe, 0x8ab9, 0x8ab9, 0x8ab9, 0x8ab9, 0x8ab9,
-	0x8ab9, 0x080c, 0x8861, 0x080c, 0x896d, 0x0005, 0x00b6, 0x0156,
-	0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
-	0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a, 0x0053, 0x1a0c,
-	0x0db4, 0x6110, 0x2158, 0xb9b0, 0x2c78, 0x2061, 0x0100, 0x619a,
-	0x908a, 0x0040, 0x1a04, 0x8b2a, 0x005b, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005,
-	0x8ca1, 0x8cdc, 0x8d05, 0x8da8, 0x8dc9, 0x8dcf, 0x8ddc, 0x8de4,
-	0x8df0, 0x8df6, 0x8e07, 0x8df6, 0x8e5e, 0x8de4, 0x8e6a, 0x8e70,
-	0x8df0, 0x8e70, 0x8e7c, 0x8b28, 0x8b28, 0x8b28, 0x8b28, 0x8b28,
-	0x8b28, 0x8b28, 0x8b28, 0x8b28, 0x8b28, 0x8b28, 0x9590, 0x95b3,
-	0x95c4, 0x95e4, 0x9616, 0x8ddc, 0x8b28, 0x8ddc, 0x8df6, 0x8b28,
-	0x8d05, 0x8da8, 0x8b28, 0x99d2, 0x8df6, 0x8b28, 0x99ee, 0x8df6,
-	0x8b28, 0x8df0, 0x8c9b, 0x8b4b, 0x8b28, 0x9a0a, 0x9a77, 0x9b4e,
-	0x8b28, 0x9b5b, 0x8dd9, 0x9b86, 0x8b28, 0x9620, 0x9bb3, 0x8b28,
-	0x080c, 0x0db4, 0x2100, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce,
-	0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0x8b49,
-	0x8b49, 0x8b49, 0x8b72, 0x8c1e, 0x8c29, 0x8b49, 0x8b49, 0x8b49,
-	0x8c70, 0x8c7c, 0x8b8d, 0x8b49, 0x8ba8, 0x8bdc, 0x9d35, 0x9d7a,
-	0x8df6, 0x080c, 0x0db4, 0x00d6, 0x0096, 0x080c, 0x8e8f, 0x7003,
-	0x2414, 0x7007, 0x0018, 0x700b, 0x0800, 0x7814, 0x2048, 0xa83c,
-	0x700e, 0xa850, 0x7022, 0xa854, 0x7026, 0x60c3, 0x0018, 0x080c,
-	0x9381, 0x009e, 0x00de, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb8a0,
-	0x00be, 0x080c, 0x9dc1, 0x1118, 0x9084, 0xff80, 0x0110, 0x9085,
-	0x0001, 0x0005, 0x00d6, 0x0096, 0x080c, 0x8e8f, 0x7003, 0x0500,
-	0x7814, 0x2048, 0xa874, 0x700a, 0xa878, 0x700e, 0xa87c, 0x7012,
-	0xa880, 0x7016, 0xa884, 0x701a, 0xa888, 0x701e, 0x60c3, 0x0010,
-	0x080c, 0x9381, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x080c,
-	0x8e8f, 0x7003, 0x0500, 0x7814, 0x2048, 0xa8cc, 0x700a, 0xa8d0,
-	0x700e, 0xa8d4, 0x7012, 0xa8d8, 0x7016, 0xa8dc, 0x701a, 0xa8e0,
-	0x701e, 0x60c3, 0x0010, 0x080c, 0x9381, 0x009e, 0x00de, 0x0005,
-	0x00d6, 0x0096, 0x0126, 0x2091, 0x8000, 0x080c, 0x8e8f, 0x20e9,
-	0x0000, 0x2001, 0x1973, 0x2003, 0x0000, 0x7814, 0x2048, 0xa814,
-	0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080,
-	0x001b, 0x2098, 0x2001, 0x1973, 0x0016, 0x200c, 0x2001, 0x0001,
-	0x080c, 0x224f, 0x080c, 0xc839, 0x9006, 0x080c, 0x224f, 0x001e,
-	0xa804, 0x9005, 0x0110, 0x2048, 0x0c28, 0x04d9, 0x080c, 0x9381,
-	0x012e, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x8eda, 0x20e9, 0x0000, 0x2001, 0x1973, 0x2003,
-	0x0000, 0x7814, 0x2048, 0xa86f, 0x0200, 0xa873, 0x0000, 0xa814,
-	0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080,
-	0x001b, 0x2098, 0x2001, 0x1973, 0x0016, 0x200c, 0x080c, 0xc839,
-	0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c60, 0x0051, 0x7814,
-	0x2048, 0x080c, 0x0f9d, 0x080c, 0x9381, 0x012e, 0x009e, 0x00de,
-	0x0005, 0x60c0, 0x8004, 0x9084, 0x0003, 0x9005, 0x0130, 0x9082,
-	0x0004, 0x20a3, 0x0000, 0x8000, 0x1de0, 0x0005, 0x080c, 0x8e8f,
-	0x7003, 0x7800, 0x7808, 0x8007, 0x700a, 0x60c3, 0x0008, 0x0804,
-	0x9381, 0x00d6, 0x00e6, 0x080c, 0x8eda, 0x7814, 0x9084, 0xff00,
-	0x2073, 0x0200, 0x8e70, 0x8e70, 0x9095, 0x0010, 0x2272, 0x8e70,
-	0x2073, 0x0034, 0x8e70, 0x2069, 0x1805, 0x20a9, 0x0004, 0x2d76,
-	0x8d68, 0x8e70, 0x1f04, 0x8c3f, 0x2069, 0x1801, 0x20a9, 0x0004,
-	0x2d76, 0x8d68, 0x8e70, 0x1f04, 0x8c48, 0x2069, 0x1983, 0x9086,
-	0xdf00, 0x0110, 0x2069, 0x199d, 0x20a9, 0x001a, 0x9e86, 0x0260,
-	0x1148, 0x00c6, 0x2061, 0x0200, 0x6010, 0x8000, 0x6012, 0x00ce,
-	0x2071, 0x0240, 0x2d04, 0x8007, 0x2072, 0x8d68, 0x8e70, 0x1f04,
-	0x8c56, 0x60c3, 0x004c, 0x080c, 0x9381, 0x00ee, 0x00de, 0x0005,
-	0x080c, 0x8e8f, 0x7003, 0x6300, 0x7007, 0x0028, 0x7808, 0x700e,
-	0x60c3, 0x0008, 0x0804, 0x9381, 0x00d6, 0x0026, 0x0016, 0x080c,
-	0x8eda, 0x7003, 0x0200, 0x7814, 0x700e, 0x00e6, 0x9ef0, 0x0004,
-	0x2009, 0x0001, 0x2011, 0x000c, 0x2073, 0x0800, 0x8e70, 0x2073,
-	0x0000, 0x00ee, 0x7206, 0x710a, 0x62c2, 0x080c, 0x9381, 0x001e,
-	0x002e, 0x00de, 0x0005, 0x2001, 0x1817, 0x2004, 0x609a, 0x0804,
-	0x9381, 0x080c, 0x8e8f, 0x7003, 0x5200, 0x2069, 0x1853, 0x6804,
-	0xd084, 0x0130, 0x6828, 0x0016, 0x080c, 0x2698, 0x710e, 0x001e,
+	0xd084, 0x190c, 0x1187, 0x00ee, 0x00fe, 0x009e, 0x0005, 0x00f6,
+	0x2079, 0x0050, 0x7044, 0xd084, 0x01b8, 0xc084, 0x7046, 0x7838,
+	0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833,
+	0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x1187, 0x00fe, 0x0005, 0x782c, 0x9094, 0x0780, 0x190c,
+	0x6bcb, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x2048,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c,
+	0x7f64, 0x782c, 0x9094, 0x0780, 0x190c, 0x6bcb, 0xd0a4, 0x1d70,
+	0x00d6, 0x2069, 0x0050, 0x693c, 0x2069, 0x1921, 0x6808, 0x690a,
+	0x2069, 0x19d2, 0x9102, 0x1118, 0x683c, 0x9005, 0x1328, 0x2001,
+	0x1922, 0x200c, 0x810d, 0x693e, 0x00de, 0x00ee, 0x00fe, 0x0005,
+	0x7094, 0x908a, 0x0029, 0x1a0c, 0x0db4, 0x9082, 0x001d, 0x001b,
+	0x6027, 0x1e00, 0x0005, 0x6d5f, 0x6ce5, 0x6d01, 0x6d2b, 0x6d4e,
+	0x6d8e, 0x6da0, 0x6d01, 0x6d76, 0x6ca0, 0x6cce, 0x6c9f, 0x0005,
+	0x00d6, 0x2069, 0x0200, 0x6804, 0x9005, 0x1180, 0x6808, 0x9005,
+	0x1518, 0x7097, 0x0028, 0x2069, 0x1967, 0x2d04, 0x7002, 0x080c,
+	0x70e1, 0x6028, 0x9085, 0x0600, 0x602a, 0x00b0, 0x7097, 0x0028,
+	0x2069, 0x1967, 0x2d04, 0x7002, 0x6028, 0x9085, 0x0600, 0x602a,
+	0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a3a, 0x080c, 0x196a,
+	0x005e, 0x004e, 0x003e, 0x00ee, 0x00de, 0x0005, 0x00d6, 0x2069,
+	0x0200, 0x6804, 0x9005, 0x1178, 0x6808, 0x9005, 0x1160, 0x7097,
+	0x0028, 0x2069, 0x1967, 0x2d04, 0x7002, 0x080c, 0x717b, 0x6028,
+	0x9085, 0x0600, 0x602a, 0x00de, 0x0005, 0x0006, 0x2001, 0x0090,
+	0x080c, 0x2b21, 0x000e, 0x6124, 0xd1e4, 0x1190, 0x080c, 0x6e0d,
+	0xd1d4, 0x1160, 0xd1dc, 0x1138, 0xd1cc, 0x0150, 0x7097, 0x0020,
+	0x080c, 0x6e0d, 0x0028, 0x7097, 0x001d, 0x0010, 0x7097, 0x001f,
+	0x0005, 0x2001, 0x0088, 0x080c, 0x2b21, 0x6124, 0xd1cc, 0x11e8,
+	0xd1dc, 0x11c0, 0xd1e4, 0x1198, 0x9184, 0x1e00, 0x11d8, 0x080c,
+	0x198f, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c, 0x6fd6,
+	0x2001, 0x0080, 0x080c, 0x2b21, 0x7097, 0x0028, 0x0058, 0x7097,
+	0x001e, 0x0040, 0x7097, 0x001d, 0x0028, 0x7097, 0x0020, 0x0010,
+	0x7097, 0x001f, 0x0005, 0x080c, 0x198f, 0x60e3, 0x0001, 0x600c,
+	0xc0b4, 0x600e, 0x080c, 0x6fd6, 0x2001, 0x0080, 0x080c, 0x2b21,
+	0x6124, 0xd1d4, 0x1180, 0xd1dc, 0x1158, 0xd1e4, 0x1130, 0x9184,
+	0x1e00, 0x1158, 0x7097, 0x0028, 0x0040, 0x7097, 0x001e, 0x0028,
+	0x7097, 0x001d, 0x0010, 0x7097, 0x001f, 0x0005, 0x2001, 0x00a0,
+	0x080c, 0x2b21, 0x6124, 0xd1dc, 0x1138, 0xd1e4, 0x0138, 0x080c,
+	0x198f, 0x7097, 0x001e, 0x0010, 0x7097, 0x001d, 0x0005, 0x080c,
+	0x6e90, 0x6124, 0xd1dc, 0x1188, 0x080c, 0x6e0d, 0x0016, 0x080c,
+	0x198f, 0x001e, 0xd1d4, 0x1128, 0xd1e4, 0x0138, 0x7097, 0x001e,
+	0x0020, 0x7097, 0x001f, 0x080c, 0x6e0d, 0x0005, 0x0006, 0x2001,
+	0x00a0, 0x080c, 0x2b21, 0x000e, 0x6124, 0xd1d4, 0x1160, 0xd1cc,
+	0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x7097, 0x001e, 0x0028,
+	0x7097, 0x001d, 0x0010, 0x7097, 0x0021, 0x0005, 0x080c, 0x6e90,
+	0x6124, 0xd1d4, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x7097,
+	0x001e, 0x0028, 0x7097, 0x001d, 0x0010, 0x7097, 0x001f, 0x0005,
+	0x0006, 0x2001, 0x0090, 0x080c, 0x2b21, 0x000e, 0x6124, 0xd1d4,
+	0x1178, 0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0158, 0x7097,
+	0x001e, 0x0040, 0x7097, 0x001d, 0x0028, 0x7097, 0x0020, 0x0010,
+	0x7097, 0x001f, 0x0005, 0x0016, 0x00c6, 0x00d6, 0x00e6, 0x0126,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2091, 0x8000,
+	0x080c, 0x6faa, 0x11d8, 0x2001, 0x180c, 0x200c, 0xd1b4, 0x01b0,
+	0xc1b4, 0x2102, 0x6027, 0x0200, 0x080c, 0x2a6a, 0x6024, 0xd0cc,
+	0x0148, 0x2001, 0x00a0, 0x080c, 0x2b21, 0x080c, 0x728c, 0x080c,
+	0x5ce5, 0x0428, 0x6028, 0xc0cd, 0x602a, 0x0408, 0x080c, 0x6fc4,
+	0x0150, 0x080c, 0x6fbb, 0x1138, 0x2001, 0x0001, 0x080c, 0x2619,
+	0x080c, 0x6f82, 0x00a0, 0x080c, 0x6e8d, 0x0178, 0x2001, 0x0001,
+	0x080c, 0x2619, 0x7094, 0x9086, 0x001e, 0x0120, 0x7094, 0x9086,
+	0x0022, 0x1118, 0x7097, 0x0025, 0x0010, 0x7097, 0x0021, 0x012e,
+	0x00ee, 0x00de, 0x00ce, 0x001e, 0x0005, 0x0026, 0x2011, 0x6e1e,
+	0x080c, 0x8113, 0x002e, 0x0016, 0x0026, 0x2009, 0x0064, 0x2011,
+	0x6e1e, 0x080c, 0x810a, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00f6,
+	0x0016, 0x080c, 0x93c7, 0x2071, 0x1800, 0x080c, 0x6dbb, 0x001e,
+	0x00fe, 0x00ee, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6,
+	0x00e6, 0x00f6, 0x0126, 0x080c, 0x93c7, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x2071, 0x1800, 0x2091, 0x8000, 0x6028, 0xc09c, 0x602a,
+	0x2011, 0x0003, 0x080c, 0x975b, 0x2011, 0x0002, 0x080c, 0x9765,
+	0x080c, 0x9673, 0x080c, 0x80bf, 0x0036, 0x901e, 0x080c, 0x96e9,
+	0x003e, 0x60e3, 0x0000, 0x080c, 0xd8ee, 0x080c, 0xd909, 0x2009,
+	0x0004, 0x080c, 0x2a70, 0x080c, 0x298b, 0x2001, 0x1800, 0x2003,
+	0x0004, 0x6027, 0x0008, 0x2011, 0x6e1e, 0x080c, 0x8113, 0x080c,
+	0x6fc4, 0x0118, 0x9006, 0x080c, 0x2b21, 0x080c, 0x0b8f, 0x2001,
+	0x0001, 0x080c, 0x2619, 0x012e, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x003e, 0x002e, 0x001e, 0x0005, 0x0026, 0x00e6, 0x2011, 0x6e2b,
+	0x2071, 0x19d2, 0x701c, 0x9206, 0x1118, 0x7018, 0x9005, 0x0110,
+	0x9085, 0x0001, 0x00ee, 0x002e, 0x0005, 0x6020, 0xd09c, 0x0005,
+	0x6800, 0x9084, 0xfffe, 0x9086, 0x00c0, 0x01b8, 0x2001, 0x00c0,
+	0x080c, 0x2b21, 0x0156, 0x20a9, 0x002d, 0x1d04, 0x6e9d, 0x2091,
+	0x6000, 0x1f04, 0x6e9d, 0x015e, 0x00d6, 0x2069, 0x1800, 0x6898,
+	0x8001, 0x0220, 0x0118, 0x689a, 0x00de, 0x0005, 0x689b, 0x0014,
+	0x68e4, 0xd0dc, 0x0dc8, 0x6800, 0x9086, 0x0001, 0x1da8, 0x080c,
+	0x811f, 0x0c90, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x2071, 0x1800, 0x080c, 0x729b, 0x2001, 0x1945, 0x2003,
+	0x0000, 0x9006, 0x7096, 0x60e2, 0x6886, 0x080c, 0x26e4, 0x9006,
+	0x080c, 0x2b21, 0x080c, 0x5ba4, 0x6027, 0xffff, 0x602b, 0x182f,
+	0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061,
+	0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2001, 0x1955, 0x200c,
+	0x9186, 0x0000, 0x0158, 0x9186, 0x0001, 0x0158, 0x9186, 0x0002,
+	0x0158, 0x9186, 0x0003, 0x0158, 0x0804, 0x6f72, 0x7097, 0x0022,
+	0x0040, 0x7097, 0x0021, 0x0028, 0x7097, 0x0023, 0x0010, 0x7097,
+	0x0024, 0x60e3, 0x0000, 0x6887, 0x0001, 0x2001, 0x0001, 0x080c,
+	0x26e4, 0x0026, 0x080c, 0x9db5, 0x002e, 0x7000, 0x908e, 0x0004,
+	0x0118, 0x602b, 0x0028, 0x0010, 0x602b, 0x0020, 0x0156, 0x0126,
+	0x2091, 0x8000, 0x20a9, 0x0005, 0x6024, 0xd0ac, 0x0150, 0x012e,
+	0x015e, 0x080c, 0xc23b, 0x0118, 0x9006, 0x080c, 0x2b4b, 0x0804,
+	0x6f7e, 0x6800, 0x9084, 0x00a1, 0xc0bd, 0x6802, 0x080c, 0x2a6a,
+	0x6904, 0xd1d4, 0x1140, 0x2001, 0x0100, 0x080c, 0x2b21, 0x1f04,
+	0x6f1c, 0x080c, 0x7001, 0x012e, 0x015e, 0x080c, 0x6fbb, 0x01a8,
+	0x6044, 0x9005, 0x0168, 0x6050, 0x0006, 0x9085, 0x0020, 0x6052,
+	0x080c, 0x7001, 0x9006, 0x8001, 0x1df0, 0x000e, 0x6052, 0x0028,
+	0x6804, 0xd0d4, 0x1110, 0x080c, 0x7001, 0x080c, 0xc23b, 0x0118,
+	0x9006, 0x080c, 0x2b4b, 0x0016, 0x0026, 0x7000, 0x908e, 0x0004,
+	0x0130, 0x2009, 0x00c8, 0x2011, 0x6e2b, 0x080c, 0x80d1, 0x002e,
+	0x001e, 0x080c, 0x7f5b, 0x7034, 0xc085, 0x7036, 0x2001, 0x1955,
+	0x2003, 0x0004, 0x080c, 0x6c88, 0x080c, 0x6fbb, 0x0138, 0x6804,
+	0xd0d4, 0x1120, 0xd0dc, 0x1100, 0x080c, 0x7291, 0x00ee, 0x00de,
+	0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x2071, 0x1800, 0x080c, 0x7f72, 0x080c, 0x7f64, 0x080c,
+	0x729b, 0x2001, 0x1945, 0x2003, 0x0000, 0x9006, 0x7096, 0x60e2,
+	0x6886, 0x080c, 0x26e4, 0x9006, 0x080c, 0x2b21, 0x6043, 0x0090,
+	0x6043, 0x0010, 0x6027, 0xffff, 0x602b, 0x182f, 0x00ee, 0x00de,
+	0x00ce, 0x0005, 0x0006, 0x2001, 0x1954, 0x2004, 0x9086, 0xaaaa,
+	0x000e, 0x0005, 0x0006, 0x080c, 0x539e, 0x9084, 0x0030, 0x9086,
+	0x0000, 0x000e, 0x0005, 0x0006, 0x080c, 0x539e, 0x9084, 0x0030,
+	0x9086, 0x0030, 0x000e, 0x0005, 0x0006, 0x080c, 0x539e, 0x9084,
+	0x0030, 0x9086, 0x0010, 0x000e, 0x0005, 0x0006, 0x080c, 0x539e,
+	0x9084, 0x0030, 0x9086, 0x0020, 0x000e, 0x0005, 0x0036, 0x0016,
+	0x2001, 0x180c, 0x2004, 0x908c, 0x0013, 0x0180, 0x0020, 0x080c,
+	0x2704, 0x900e, 0x0028, 0x080c, 0x6572, 0x1dc8, 0x2009, 0x0002,
+	0x2019, 0x0028, 0x080c, 0x2fb2, 0x9006, 0x0019, 0x001e, 0x003e,
+	0x0005, 0x00e6, 0x2071, 0x180c, 0x2e04, 0x0130, 0x080c, 0xc234,
+	0x1128, 0x9085, 0x0010, 0x0010, 0x9084, 0xffef, 0x2072, 0x00ee,
+	0x0005, 0x6050, 0x0006, 0x60ec, 0x0006, 0x600c, 0x0006, 0x6004,
+	0x0006, 0x6028, 0x0006, 0x0016, 0x6138, 0x6050, 0x9084, 0xfbff,
+	0x9085, 0x2000, 0x6052, 0x613a, 0x20a9, 0x0012, 0x1d04, 0x7016,
+	0x2091, 0x6000, 0x1f04, 0x7016, 0x602f, 0x0100, 0x602f, 0x0000,
+	0x6050, 0x9085, 0x0400, 0x9084, 0xdfff, 0x6052, 0x613a, 0x001e,
+	0x602f, 0x0040, 0x602f, 0x0000, 0x000e, 0x602a, 0x000e, 0x6006,
+	0x000e, 0x600e, 0x000e, 0x60ee, 0x60e3, 0x0000, 0x6887, 0x0001,
+	0x2001, 0x0001, 0x080c, 0x26e4, 0x2001, 0x00a0, 0x0006, 0x080c,
+	0xc23b, 0x000e, 0x0130, 0x080c, 0x2b3f, 0x9006, 0x080c, 0x2b4b,
+	0x0010, 0x080c, 0x2b21, 0x000e, 0x6052, 0x6050, 0x0006, 0xc0e5,
+	0x6052, 0x00f6, 0x2079, 0x0100, 0x080c, 0x29df, 0x00fe, 0x000e,
+	0x6052, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6,
+	0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x6020,
+	0x9084, 0x0080, 0x0138, 0x2001, 0x180c, 0x200c, 0xc1c5, 0x2102,
+	0x0804, 0x70d3, 0x2001, 0x180c, 0x200c, 0xc1c4, 0x2102, 0x6028,
+	0x9084, 0xe1ff, 0x602a, 0x6027, 0x0200, 0x2001, 0x0090, 0x080c,
+	0x2b21, 0x20a9, 0x0366, 0x6024, 0xd0cc, 0x1518, 0x1d04, 0x7083,
+	0x2091, 0x6000, 0x1f04, 0x7083, 0x2011, 0x0003, 0x080c, 0x975b,
+	0x2011, 0x0002, 0x080c, 0x9765, 0x080c, 0x9673, 0x901e, 0x080c,
+	0x96e9, 0x2001, 0x00a0, 0x080c, 0x2b21, 0x080c, 0x728c, 0x080c,
+	0x5ce5, 0x080c, 0xc23b, 0x0110, 0x080c, 0x0d22, 0x9085, 0x0001,
+	0x0480, 0x080c, 0x198f, 0x60e3, 0x0000, 0x2001, 0x0002, 0x080c,
+	0x26e4, 0x60e2, 0x2001, 0x0080, 0x080c, 0x2b21, 0x20a9, 0x0366,
+	0x6027, 0x1e00, 0x2009, 0x1e00, 0x080c, 0x2a6a, 0x6024, 0x910c,
+	0x0138, 0x1d04, 0x70b8, 0x2091, 0x6000, 0x1f04, 0x70b8, 0x0820,
+	0x6028, 0x9085, 0x1e00, 0x602a, 0x70b0, 0x9005, 0x1118, 0x6887,
+	0x0001, 0x0008, 0x6886, 0x080c, 0xc23b, 0x0110, 0x080c, 0x0d22,
+	0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6,
+	0x2061, 0x0100, 0x2071, 0x1800, 0x7000, 0x9086, 0x0003, 0x1168,
+	0x2001, 0x020b, 0x2004, 0x9084, 0x5540, 0x9086, 0x5540, 0x1128,
+	0x2069, 0x1a50, 0x2d04, 0x8000, 0x206a, 0x2069, 0x0140, 0x6020,
+	0x9084, 0x00c0, 0x0120, 0x6884, 0x9005, 0x1904, 0x7146, 0x2001,
+	0x0088, 0x080c, 0x2b21, 0x9006, 0x60e2, 0x6886, 0x080c, 0x26e4,
+	0x2069, 0x0200, 0x6804, 0x9005, 0x1118, 0x6808, 0x9005, 0x01c0,
+	0x6028, 0x9084, 0xfbff, 0x602a, 0x6027, 0x0400, 0x2069, 0x1967,
+	0x7000, 0x206a, 0x7097, 0x0026, 0x7003, 0x0001, 0x20a9, 0x0002,
+	0x1d04, 0x7128, 0x2091, 0x6000, 0x1f04, 0x7128, 0x0804, 0x7173,
+	0x2069, 0x0140, 0x20a9, 0x0384, 0x6027, 0x1e00, 0x2009, 0x1e00,
+	0x080c, 0x2a6a, 0x6024, 0x910c, 0x0508, 0x9084, 0x1a00, 0x11f0,
+	0x1d04, 0x7134, 0x2091, 0x6000, 0x1f04, 0x7134, 0x2011, 0x0003,
+	0x080c, 0x975b, 0x2011, 0x0002, 0x080c, 0x9765, 0x080c, 0x9673,
+	0x901e, 0x080c, 0x96e9, 0x2001, 0x00a0, 0x080c, 0x2b21, 0x080c,
+	0x728c, 0x080c, 0x5ce5, 0x9085, 0x0001, 0x00a8, 0x2001, 0x0080,
+	0x080c, 0x2b21, 0x2069, 0x0140, 0x60e3, 0x0000, 0x70b0, 0x9005,
+	0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001, 0x0002, 0x080c,
+	0x26e4, 0x60e2, 0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e,
+	0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6,
+	0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x6020, 0x9084,
+	0x00c0, 0x01c8, 0x2011, 0x0003, 0x080c, 0x975b, 0x2011, 0x0002,
+	0x080c, 0x9765, 0x080c, 0x9673, 0x901e, 0x080c, 0x96e9, 0x2069,
+	0x0140, 0x2001, 0x00a0, 0x080c, 0x2b21, 0x080c, 0x728c, 0x080c,
+	0x5ce5, 0x0804, 0x720d, 0x2001, 0x180c, 0x200c, 0xd1b4, 0x1160,
+	0xc1b5, 0x2102, 0x080c, 0x6e13, 0x2069, 0x0140, 0x2001, 0x0080,
+	0x080c, 0x2b21, 0x60e3, 0x0000, 0x2069, 0x0200, 0x6804, 0x9005,
+	0x1118, 0x6808, 0x9005, 0x0180, 0x6028, 0x9084, 0xfdff, 0x602a,
+	0x6027, 0x0200, 0x2069, 0x1967, 0x7000, 0x206a, 0x7097, 0x0027,
+	0x7003, 0x0001, 0x0804, 0x720d, 0x6027, 0x1e00, 0x2009, 0x1e00,
+	0x080c, 0x2a6a, 0x6024, 0x910c, 0x01c8, 0x9084, 0x1c00, 0x11b0,
+	0x1d04, 0x71cc, 0x0006, 0x0016, 0x00c6, 0x00d6, 0x00e6, 0x080c,
+	0x7fa3, 0x00ee, 0x00de, 0x00ce, 0x001e, 0x000e, 0x00e6, 0x2071,
+	0x19d2, 0x7070, 0x00ee, 0x9005, 0x19f8, 0x00f8, 0x0026, 0x2011,
+	0x6e2b, 0x080c, 0x803f, 0x2011, 0x6e1e, 0x080c, 0x8113, 0x002e,
+	0x2069, 0x0140, 0x60e3, 0x0000, 0x70b0, 0x9005, 0x1118, 0x6887,
+	0x0001, 0x0008, 0x6886, 0x2001, 0x0002, 0x080c, 0x26e4, 0x60e2,
+	0x2001, 0x180c, 0x200c, 0xc1b4, 0x2102, 0x00ee, 0x00de, 0x00ce,
+	0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026,
+	0x0036, 0x0046, 0x00c6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800,
+	0x080c, 0xc234, 0x1904, 0x727a, 0x7130, 0xd184, 0x1170, 0x080c,
+	0x3140, 0x0138, 0xc18d, 0x7132, 0x2011, 0x185c, 0x2214, 0xd2ac,
+	0x1120, 0x7030, 0xd08c, 0x0904, 0x727a, 0x2011, 0x185c, 0x220c,
+	0x0438, 0x0016, 0x2019, 0x000e, 0x080c, 0xd4e0, 0x0156, 0x00b6,
+	0x20a9, 0x007f, 0x900e, 0x9186, 0x007e, 0x01a0, 0x9186, 0x0080,
+	0x0188, 0x080c, 0x6256, 0x1170, 0x2120, 0x9006, 0x0016, 0x2009,
+	0x000e, 0x080c, 0xd564, 0x2009, 0x0001, 0x2011, 0x0100, 0x080c,
+	0x8236, 0x001e, 0x8108, 0x1f04, 0x7243, 0x00be, 0x015e, 0x001e,
+	0xd1ac, 0x1148, 0x0016, 0x2009, 0x0002, 0x2019, 0x0004, 0x080c,
+	0x2fb2, 0x001e, 0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e,
+	0x080c, 0x6256, 0x1110, 0x080c, 0x5cff, 0x8108, 0x1f04, 0x7270,
+	0x00be, 0x015e, 0x080c, 0x198f, 0x080c, 0x9db5, 0x60e3, 0x0000,
+	0x080c, 0x5ce5, 0x080c, 0x6edc, 0x00ee, 0x00ce, 0x004e, 0x003e,
+	0x002e, 0x001e, 0x015e, 0x0005, 0x2001, 0x1955, 0x2003, 0x0001,
+	0x0005, 0x2001, 0x1955, 0x2003, 0x0000, 0x0005, 0x2001, 0x1954,
+	0x2003, 0xaaaa, 0x0005, 0x2001, 0x1954, 0x2003, 0x0000, 0x0005,
+	0x2071, 0x18f8, 0x7003, 0x0000, 0x7007, 0x0000, 0x080c, 0x1004,
+	0x090c, 0x0db4, 0xa8ab, 0xdcb0, 0x2900, 0x704e, 0x080c, 0x1004,
+	0x090c, 0x0db4, 0xa8ab, 0xdcb0, 0x2900, 0x7052, 0xa867, 0x0000,
+	0xa86b, 0x0001, 0xa89f, 0x0000, 0x0005, 0x00e6, 0x2071, 0x0040,
+	0x6848, 0x9005, 0x1118, 0x9085, 0x0001, 0x04b0, 0x6840, 0x9005,
+	0x0150, 0x04a1, 0x6a50, 0x9200, 0x7002, 0x6854, 0x9101, 0x7006,
+	0x9006, 0x7012, 0x7016, 0x6850, 0x7002, 0x6854, 0x7006, 0x6858,
+	0x700a, 0x685c, 0x700e, 0x6840, 0x9005, 0x1110, 0x7012, 0x7016,
+	0x6848, 0x701a, 0x701c, 0x9085, 0x0040, 0x701e, 0x2001, 0x0019,
+	0x7036, 0x702b, 0x0001, 0x2001, 0x0004, 0x200c, 0x918c, 0xfff7,
+	0x918d, 0x8000, 0x2102, 0x00d6, 0x2069, 0x18f8, 0x6807, 0x0001,
+	0x00de, 0x080c, 0x788e, 0x9006, 0x00ee, 0x0005, 0x900e, 0x0156,
+	0x20a9, 0x0006, 0x8003, 0x2011, 0x0100, 0x2214, 0x9296, 0x0008,
+	0x1110, 0x818d, 0x0010, 0x81f5, 0x3e08, 0x1f04, 0x7302, 0x015e,
+	0x0005, 0x2079, 0x0040, 0x2071, 0x18f8, 0x7004, 0x0002, 0x7321,
+	0x7322, 0x735a, 0x73b5, 0x74f6, 0x731f, 0x731f, 0x7520, 0x080c,
+	0x0db4, 0x0005, 0x2079, 0x0040, 0x782c, 0x908c, 0x0780, 0x190c,
+	0x791a, 0xd0a4, 0x01f8, 0x7824, 0x2048, 0x9006, 0xa802, 0xa806,
+	0xa864, 0x9084, 0x00ff, 0x908a, 0x0040, 0x0610, 0x00c0, 0x2001,
+	0x1800, 0x200c, 0x9186, 0x0003, 0x1168, 0x7004, 0x0002, 0x734a,
+	0x7324, 0x734a, 0x7348, 0x734a, 0x734a, 0x734a, 0x734a, 0x734a,
+	0x080c, 0x73b5, 0x782c, 0xd09c, 0x090c, 0x788e, 0x0005, 0x9082,
+	0x005a, 0x1218, 0x2100, 0x003b, 0x0c10, 0x080c, 0x73eb, 0x0c90,
+	0x00e3, 0x08e8, 0x0005, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb,
+	0x73eb, 0x73eb, 0x73eb, 0x740d, 0x73eb, 0x73eb, 0x73eb, 0x73eb,
+	0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb,
+	0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73f7,
+	0x73eb, 0x75f5, 0x73eb, 0x73eb, 0x73eb, 0x740d, 0x73eb, 0x73f7,
+	0x7636, 0x7677, 0x76be, 0x76d2, 0x73eb, 0x73eb, 0x740d, 0x73f7,
+	0x73eb, 0x73eb, 0x74ca, 0x777d, 0x7798, 0x73eb, 0x740d, 0x73eb,
+	0x73eb, 0x73eb, 0x73eb, 0x74c0, 0x7798, 0x73eb, 0x73eb, 0x73eb,
+	0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x7421, 0x73eb,
+	0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb,
+	0x78be, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x7435, 0x73eb,
+	0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x73eb, 0x2079, 0x0040, 0x7004,
+	0x9086, 0x0003, 0x1198, 0x782c, 0x080c, 0x78b7, 0xd0a4, 0x0170,
+	0x7824, 0x2048, 0x9006, 0xa802, 0xa806, 0xa864, 0x9084, 0x00ff,
+	0x908a, 0x001a, 0x1210, 0x002b, 0x0c50, 0x00e9, 0x080c, 0x788e,
+	0x0005, 0x73eb, 0x73f7, 0x75e1, 0x73eb, 0x73f7, 0x73eb, 0x73f7,
+	0x73f7, 0x73eb, 0x73f7, 0x75e1, 0x73f7, 0x73f7, 0x73f7, 0x73f7,
+	0x73f7, 0x73eb, 0x73f7, 0x75e1, 0x73eb, 0x73eb, 0x73f7, 0x73eb,
+	0x73eb, 0x73eb, 0x73f7, 0x00e6, 0x2071, 0x18f8, 0x2009, 0x0400,
+	0x0071, 0x00ee, 0x0005, 0x2009, 0x1000, 0x0049, 0x0005, 0x2009,
+	0x2000, 0x0029, 0x0005, 0x2009, 0x0800, 0x0009, 0x0005, 0x7007,
+	0x0001, 0xa868, 0x9084, 0x00ff, 0x9105, 0xa86a, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x68a0, 0x012e, 0x0005, 0xa864, 0x8007, 0x9084,
+	0x00ff, 0x0d08, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x759f,
+	0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x759f,
+	0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0968, 0x8001, 0x1120,
+	0x7007, 0x0001, 0x0804, 0x75ba, 0x7007, 0x0003, 0x7012, 0x2900,
+	0x7016, 0x701a, 0x704b, 0x75ba, 0x0005, 0xa864, 0x8007, 0x9084,
+	0x00ff, 0x9086, 0x0001, 0x1904, 0x73f3, 0x7007, 0x0001, 0x2009,
+	0x1833, 0x210c, 0x81ff, 0x1904, 0x7497, 0xa994, 0x9186, 0x006f,
+	0x0188, 0x9186, 0x0074, 0x15b0, 0x0026, 0x2011, 0x0010, 0x080c,
+	0x659e, 0x002e, 0x0578, 0x0016, 0xa998, 0x080c, 0x65e8, 0x001e,
+	0x1548, 0x0400, 0x080c, 0x6faa, 0x0140, 0xa897, 0x4005, 0xa89b,
+	0x0016, 0x2001, 0x0030, 0x900e, 0x0438, 0x0026, 0x2011, 0x8008,
+	0x080c, 0x659e, 0x002e, 0x01b0, 0x0016, 0x0026, 0x0036, 0xa998,
+	0xaaa0, 0xab9c, 0x918d, 0x8000, 0x080c, 0x65e8, 0x003e, 0x002e,
+	0x001e, 0x1140, 0xa897, 0x4005, 0xa89b, 0x4009, 0x2001, 0x0030,
+	0x900e, 0x0050, 0xa868, 0x9084, 0x00ff, 0xa86a, 0xa883, 0x0000,
+	0x080c, 0x5f14, 0x1108, 0x0005, 0x0126, 0x2091, 0x8000, 0xa867,
+	0x0139, 0xa87a, 0xa982, 0x080c, 0x68a0, 0x012e, 0x0ca0, 0xa994,
+	0x9186, 0x0071, 0x0904, 0x7445, 0x9186, 0x0064, 0x0904, 0x7445,
+	0x9186, 0x007c, 0x0904, 0x7445, 0x9186, 0x0028, 0x0904, 0x7445,
+	0x9186, 0x0038, 0x0904, 0x7445, 0x9186, 0x0078, 0x0904, 0x7445,
+	0x9186, 0x005f, 0x0904, 0x7445, 0x9186, 0x0056, 0x0904, 0x7445,
+	0xa897, 0x4005, 0xa89b, 0x0001, 0x2001, 0x0030, 0x900e, 0x0860,
+	0xa87c, 0x9084, 0x00c0, 0x9086, 0x00c0, 0x1120, 0x7007, 0x0001,
+	0x0804, 0x77af, 0x2900, 0x7016, 0x701a, 0x20a9, 0x0004, 0xa860,
+	0x20e0, 0xa85c, 0x9080, 0x0030, 0x2098, 0x7050, 0x2040, 0xa060,
+	0x20e8, 0xa05c, 0x9080, 0x0023, 0x20a0, 0x4003, 0xa888, 0x7012,
+	0x9082, 0x0401, 0x1a04, 0x73fb, 0xaab4, 0x928a, 0x0002, 0x1a04,
+	0x73fb, 0x82ff, 0x1138, 0xa8b8, 0xa9bc, 0x9105, 0x0118, 0x2001,
+	0x755d, 0x0018, 0x9280, 0x7553, 0x2005, 0x7056, 0x7010, 0x9015,
+	0x0904, 0x753e, 0x080c, 0x1004, 0x1118, 0x7007, 0x0004, 0x0005,
+	0x2900, 0x7022, 0x7054, 0x2060, 0xe000, 0xa866, 0x7050, 0x2040,
+	0xa95c, 0xe004, 0x9100, 0xa076, 0xa860, 0xa072, 0xe008, 0x920a,
+	0x1210, 0x900e, 0x2200, 0x7112, 0xe20c, 0x8003, 0x800b, 0x9296,
+	0x0004, 0x0108, 0x9108, 0xa17a, 0x810b, 0xa17e, 0x080c, 0x10d5,
+	0xa06c, 0x908e, 0x0100, 0x0170, 0x9086, 0x0200, 0x0118, 0x7007,
+	0x0007, 0x0005, 0x7020, 0x2048, 0x080c, 0x101d, 0x7014, 0x2048,
+	0x0804, 0x73fb, 0x7020, 0x2048, 0x7018, 0xa802, 0xa807, 0x0000,
+	0x2908, 0x2048, 0xa906, 0x711a, 0x0804, 0x74f6, 0x7014, 0x2048,
+	0x7007, 0x0001, 0xa8b4, 0x9005, 0x1128, 0xa8b8, 0xa9bc, 0x9105,
+	0x0108, 0x00b9, 0xa864, 0x9084, 0x00ff, 0x9086, 0x001e, 0x0904,
+	0x77af, 0x0804, 0x759f, 0x7555, 0x7559, 0x0002, 0x001d, 0x0007,
+	0x0004, 0x000a, 0x001b, 0x0005, 0x0006, 0x000a, 0x001d, 0x0005,
+	0x0004, 0x0076, 0x0066, 0xafb8, 0xaebc, 0xa804, 0x2050, 0xb0c0,
+	0xb0e2, 0xb0bc, 0xb0de, 0xb0b8, 0xb0d2, 0xb0b4, 0xb0ce, 0xb6da,
+	0xb7d6, 0xb0b0, 0xb0ca, 0xb0ac, 0xb0c6, 0xb0a8, 0xb0ba, 0xb0a4,
+	0xb0b6, 0xb6c2, 0xb7be, 0xb0a0, 0xb0b2, 0xb09c, 0xb0ae, 0xb098,
+	0xb0a2, 0xb094, 0xb09e, 0xb6aa, 0xb7a6, 0xb090, 0xb09a, 0xb08c,
+	0xb096, 0xb088, 0xb08a, 0xb084, 0xb086, 0xb692, 0xb78e, 0xb080,
+	0xb082, 0xb07c, 0xb07e, 0xb078, 0xb072, 0xb074, 0xb06e, 0xb67a,
+	0xb776, 0xb004, 0x9055, 0x1958, 0x006e, 0x007e, 0x0005, 0x2009,
+	0x1833, 0x210c, 0x81ff, 0x1178, 0x080c, 0x5d61, 0x1108, 0x0005,
+	0x080c, 0x6ace, 0x0126, 0x2091, 0x8000, 0x080c, 0xbe2f, 0x080c,
+	0x68a0, 0x012e, 0x0ca0, 0x080c, 0xc234, 0x1d70, 0x2001, 0x0028,
+	0x900e, 0x0c70, 0x2009, 0x1833, 0x210c, 0x81ff, 0x11d8, 0xa888,
+	0x9005, 0x01e0, 0xa883, 0x0000, 0xa87c, 0xd0f4, 0x0120, 0x080c,
+	0x5e76, 0x1138, 0x0005, 0x9006, 0xa87a, 0x080c, 0x5df1, 0x1108,
+	0x0005, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982, 0x080c, 0x68a0,
+	0x012e, 0x0cb0, 0x2001, 0x0028, 0x900e, 0x0c98, 0x2001, 0x0000,
+	0x0c80, 0x7018, 0xa802, 0x2908, 0x2048, 0xa906, 0x711a, 0x7010,
+	0x8001, 0x7012, 0x0118, 0x7007, 0x0003, 0x0030, 0x7014, 0x2048,
+	0x7007, 0x0001, 0x7048, 0x080f, 0x0005, 0x00b6, 0x7007, 0x0001,
+	0xa974, 0xa878, 0x9084, 0x00ff, 0x9096, 0x0004, 0x0540, 0x20a9,
+	0x0001, 0x9096, 0x0001, 0x0190, 0x900e, 0x20a9, 0x0800, 0x9096,
+	0x0002, 0x0160, 0x9005, 0x11d8, 0xa974, 0x080c, 0x6256, 0x11b8,
+	0x0066, 0xae80, 0x080c, 0x6366, 0x006e, 0x0088, 0x0046, 0x2011,
+	0x180c, 0x2224, 0xc484, 0x2412, 0x004e, 0x00c6, 0x080c, 0x6256,
+	0x1110, 0x080c, 0x6466, 0x8108, 0x1f04, 0x761e, 0x00ce, 0xa87c,
+	0xd084, 0x1120, 0x080c, 0x101d, 0x00be, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x68a0, 0x012e, 0x00be, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x7007, 0x0001, 0x080c, 0x6576, 0x0580, 0x2061, 0x1a48,
+	0x6100, 0xd184, 0x0178, 0xa888, 0x9084, 0x00ff, 0x1550, 0x6000,
+	0xd084, 0x0520, 0x6004, 0x9005, 0x1538, 0x6003, 0x0000, 0x600b,
+	0x0000, 0x00c8, 0x2011, 0x0001, 0xa890, 0x9005, 0x1110, 0x2001,
+	0x001e, 0x8000, 0x6016, 0xa888, 0x9084, 0x00ff, 0x0178, 0x6006,
+	0xa888, 0x8007, 0x9084, 0x00ff, 0x0148, 0x600a, 0xa888, 0x8000,
+	0x1108, 0xc28d, 0x6202, 0x012e, 0x0804, 0x7878, 0x012e, 0x0804,
+	0x7872, 0x012e, 0x0804, 0x786c, 0x012e, 0x0804, 0x786f, 0x0126,
+	0x2091, 0x8000, 0x7007, 0x0001, 0x080c, 0x6576, 0x05e0, 0x2061,
+	0x1a48, 0x6000, 0xd084, 0x05b8, 0x6204, 0x6308, 0xd08c, 0x1530,
+	0xac78, 0x9484, 0x0003, 0x0170, 0xa988, 0x918c, 0x00ff, 0x8001,
+	0x1120, 0x2100, 0x9210, 0x0620, 0x0028, 0x8001, 0x1508, 0x2100,
+	0x9212, 0x02f0, 0x9484, 0x000c, 0x0188, 0xa988, 0x810f, 0x918c,
+	0x00ff, 0x9082, 0x0004, 0x1120, 0x2100, 0x9318, 0x0288, 0x0030,
+	0x9082, 0x0004, 0x1168, 0x2100, 0x931a, 0x0250, 0xa890, 0x9005,
+	0x0110, 0x8000, 0x6016, 0x6206, 0x630a, 0x012e, 0x0804, 0x7878,
+	0x012e, 0x0804, 0x7875, 0x012e, 0x0804, 0x7872, 0x0126, 0x2091,
+	0x8000, 0x7007, 0x0001, 0x2061, 0x1a48, 0x6300, 0xd38c, 0x1120,
+	0x6308, 0x8318, 0x0220, 0x630a, 0x012e, 0x0804, 0x7886, 0x012e,
+	0x0804, 0x7875, 0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x7007,
+	0x0001, 0xa87c, 0xd0ac, 0x0148, 0x00c6, 0x2061, 0x1a48, 0x6000,
+	0x9084, 0xfcff, 0x6002, 0x00ce, 0x0440, 0xa888, 0x9005, 0x05d8,
+	0xa88c, 0x9065, 0x0598, 0x2001, 0x1833, 0x2004, 0x9005, 0x0118,
+	0x080c, 0x9e5f, 0x0068, 0x6017, 0xf400, 0x605b, 0x0000, 0xa97c,
+	0xd1a4, 0x0110, 0xa980, 0x615a, 0x2009, 0x0041, 0x080c, 0x9ea9,
+	0xa988, 0x918c, 0xff00, 0x9186, 0x2000, 0x1138, 0x0026, 0x900e,
+	0x2011, 0xfdff, 0x080c, 0x8236, 0x002e, 0xa87c, 0xd0c4, 0x0148,
+	0x2061, 0x1a48, 0x6000, 0xd08c, 0x1120, 0x6008, 0x8000, 0x0208,
+	0x600a, 0x00ce, 0x012e, 0x00be, 0x0804, 0x7878, 0x00ce, 0x012e,
+	0x00be, 0x0804, 0x7872, 0xa984, 0x9186, 0x002e, 0x0d30, 0x9186,
+	0x002d, 0x0d18, 0x9186, 0x0045, 0x0510, 0x9186, 0x002a, 0x1130,
+	0x2001, 0x180c, 0x200c, 0xc194, 0x2102, 0x08b8, 0x9186, 0x0020,
+	0x0158, 0x9186, 0x0029, 0x1d10, 0xa974, 0x080c, 0x6256, 0x1968,
+	0xb800, 0xc0e4, 0xb802, 0x0848, 0xa88c, 0x9065, 0x09b8, 0x6007,
+	0x0024, 0x2001, 0x195e, 0x2004, 0x601a, 0x0804, 0x770d, 0xa88c,
+	0x9065, 0x0960, 0x00e6, 0xa890, 0x9075, 0x2001, 0x1833, 0x2004,
+	0x9005, 0x0150, 0x080c, 0x9e5f, 0x8eff, 0x0118, 0x2e60, 0x080c,
+	0x9e5f, 0x00ee, 0x0804, 0x770d, 0x6024, 0xc0dc, 0xc0d5, 0x6026,
+	0x2e60, 0x6007, 0x003a, 0xa8a0, 0x9005, 0x0130, 0x6007, 0x003b,
+	0xa8a4, 0x602e, 0xa8a8, 0x6016, 0x6003, 0x0001, 0x080c, 0x83f8,
+	0x080c, 0x898b, 0x00ee, 0x0804, 0x770d, 0x2061, 0x1a48, 0x6000,
+	0xd084, 0x0190, 0xd08c, 0x1904, 0x7886, 0x0126, 0x2091, 0x8000,
+	0x6204, 0x8210, 0x0220, 0x6206, 0x012e, 0x0804, 0x7886, 0x012e,
+	0xa883, 0x0016, 0x0804, 0x787f, 0xa883, 0x0007, 0x0804, 0x787f,
+	0xa864, 0x8007, 0x9084, 0x00ff, 0x0130, 0x8001, 0x1138, 0x7007,
+	0x0001, 0x0069, 0x0005, 0x080c, 0x73f3, 0x0040, 0x7007, 0x0003,
+	0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x77af, 0x0005, 0x00b6,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x903e, 0x2061, 0x1800, 0x61cc,
+	0x81ff, 0x1904, 0x7831, 0x6130, 0xd194, 0x1904, 0x785b, 0xa878,
+	0x2070, 0x9e82, 0x1cd0, 0x0a04, 0x7825, 0x6064, 0x9e02, 0x1a04,
+	0x7825, 0x7120, 0x9186, 0x0006, 0x1904, 0x7817, 0x7010, 0x905d,
+	0x0904, 0x7831, 0xb800, 0xd0e4, 0x1904, 0x7855, 0x2061, 0x1a48,
+	0x6100, 0x9184, 0x0301, 0x9086, 0x0001, 0x15a0, 0x7024, 0xd0dc,
+	0x1904, 0x785e, 0xa883, 0x0000, 0xa803, 0x0000, 0x2908, 0x7014,
+	0x9005, 0x1198, 0x7116, 0xa87c, 0xd0f4, 0x1904, 0x7861, 0x080c,
+	0x539a, 0xd09c, 0x1118, 0xa87c, 0xc0cc, 0xa87e, 0x2e60, 0x080c,
+	0x8156, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2048, 0xa800, 0x9005,
+	0x1de0, 0xa902, 0x2148, 0xa87c, 0xd0f4, 0x1904, 0x7861, 0x012e,
+	0x00ee, 0x00be, 0x0005, 0x012e, 0x00ee, 0xa883, 0x0006, 0x00be,
+	0x0804, 0x787f, 0xd184, 0x0db8, 0xd1c4, 0x1190, 0x00a0, 0xa974,
+	0x080c, 0x6256, 0x15d0, 0xb800, 0xd0e4, 0x15b8, 0x7120, 0x9186,
+	0x0007, 0x1118, 0xa883, 0x0002, 0x0490, 0xa883, 0x0008, 0x0478,
+	0xa883, 0x000e, 0x0460, 0xa883, 0x0017, 0x0448, 0xa883, 0x0035,
+	0x0430, 0x080c, 0x539e, 0xd0fc, 0x01e8, 0xa878, 0x2070, 0x9e82,
+	0x1cd0, 0x02c0, 0x6064, 0x9e02, 0x12a8, 0x7120, 0x9186, 0x0006,
+	0x1188, 0x7010, 0x905d, 0x0170, 0xb800, 0xd0bc, 0x0158, 0x2039,
+	0x0001, 0x7000, 0x9086, 0x0007, 0x1904, 0x77bb, 0x7003, 0x0002,
+	0x0804, 0x77bb, 0xa883, 0x0028, 0x0010, 0xa883, 0x0029, 0x012e,
+	0x00ee, 0x00be, 0x0420, 0xa883, 0x002a, 0x0cc8, 0xa883, 0x0045,
+	0x0cb0, 0x2e60, 0x2019, 0x0002, 0x601b, 0x0014, 0x080c, 0xd11f,
+	0x012e, 0x00ee, 0x00be, 0x0005, 0x2009, 0x003e, 0x0058, 0x2009,
+	0x0004, 0x0040, 0x2009, 0x0006, 0x0028, 0x2009, 0x0016, 0x0010,
+	0x2009, 0x0001, 0xa884, 0x9084, 0xff00, 0x9105, 0xa886, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x68a0, 0x012e, 0x0005, 0x080c, 0x101d,
+	0x0005, 0x00d6, 0x080c, 0x814d, 0x00de, 0x0005, 0x00d6, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x0040, 0x702c, 0xd084, 0x01d8,
+	0x908c, 0x0780, 0x190c, 0x791a, 0xd09c, 0x11a8, 0x2071, 0x1800,
+	0x70bc, 0x90ea, 0x0040, 0x0278, 0x8001, 0x70be, 0x702c, 0x2048,
+	0xa800, 0x702e, 0x9006, 0xa802, 0xa806, 0x2071, 0x0040, 0x2900,
+	0x7022, 0x702c, 0x0c28, 0x012e, 0x00ee, 0x00de, 0x0005, 0x0006,
+	0x9084, 0x0780, 0x190c, 0x791a, 0x000e, 0x0005, 0x00d6, 0x00c6,
+	0x0036, 0x0026, 0x0016, 0x00b6, 0x7007, 0x0001, 0xaa74, 0x9282,
+	0x0004, 0x1a04, 0x790b, 0xa97c, 0x9188, 0x1000, 0x2104, 0x905d,
+	0xb804, 0xd284, 0x0140, 0x05e8, 0x8007, 0x9084, 0x00ff, 0x9084,
+	0x0006, 0x1108, 0x04b0, 0x2b10, 0x080c, 0x9dd9, 0x1118, 0x080c,
+	0x9e7c, 0x05a8, 0x6212, 0xa874, 0x0002, 0x78e9, 0x78ee, 0x78f1,
+	0x78f7, 0x2019, 0x0002, 0x080c, 0xd4e0, 0x0060, 0x080c, 0xd47c,
+	0x0048, 0x2019, 0x0002, 0xa980, 0x080c, 0xd497, 0x0018, 0xa980,
+	0x080c, 0xd47c, 0x080c, 0x9e2f, 0xa887, 0x0000, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x68a0, 0x012e, 0x00be, 0x001e, 0x002e, 0x003e,
+	0x00ce, 0x00de, 0x0005, 0xa887, 0x0006, 0x0c80, 0xa887, 0x0002,
+	0x0c68, 0xa887, 0x0005, 0x0c50, 0xa887, 0x0004, 0x0c38, 0xa887,
+	0x0007, 0x0c20, 0x2091, 0x8000, 0x0e04, 0x791c, 0x0006, 0x0016,
+	0x2001, 0x8003, 0x0006, 0x0804, 0x0dbd, 0x2001, 0x1833, 0x2004,
+	0x9005, 0x0005, 0x0005, 0x00f6, 0x2079, 0x0300, 0x2001, 0x0200,
+	0x200c, 0xc1e5, 0xc1dc, 0x2102, 0x2009, 0x0218, 0x210c, 0xd1ec,
+	0x1120, 0x080c, 0x14a9, 0x00fe, 0x0005, 0x2001, 0x020d, 0x2003,
+	0x0020, 0x781f, 0x0300, 0x00fe, 0x0005, 0x781c, 0xd08c, 0x0904,
+	0x799c, 0x68bc, 0x90aa, 0x0005, 0x0a04, 0x7f5b, 0x7d44, 0x7c40,
+	0x9584, 0x00f6, 0x1510, 0x9484, 0x7000, 0x0140, 0x908a, 0x2000,
+	0x1260, 0x9584, 0x0700, 0x8007, 0x0804, 0x79a3, 0x7000, 0x9084,
+	0xff00, 0x9086, 0x8100, 0x0da8, 0x00b0, 0x9484, 0x0fff, 0x1130,
+	0x7000, 0x9084, 0xff00, 0x9086, 0x8100, 0x11c0, 0x080c, 0xd8c6,
+	0x080c, 0x7e90, 0x7817, 0x0140, 0x00a8, 0x9584, 0x0076, 0x1118,
+	0x080c, 0x7eee, 0x19c0, 0xd5a4, 0x0148, 0x0046, 0x0056, 0x080c,
+	0x79fe, 0x080c, 0x21da, 0x005e, 0x004e, 0x0020, 0x080c, 0xd8c6,
+	0x7817, 0x0140, 0x080c, 0x6faa, 0x0168, 0x2001, 0x0111, 0x2004,
+	0xd08c, 0x0140, 0x688f, 0x0000, 0x2001, 0x0110, 0x2003, 0x0008,
+	0x2003, 0x0000, 0x080c, 0x79df, 0x2001, 0x19c8, 0x2004, 0x9005,
+	0x090c, 0x898b, 0x0005, 0x0002, 0x79b5, 0x7cb2, 0x79ac, 0x79ac,
+	0x79ac, 0x79ac, 0x79ac, 0x79ac, 0x7817, 0x0140, 0x2001, 0x19c8,
+	0x2004, 0x9005, 0x090c, 0x898b, 0x0005, 0x7000, 0x908c, 0xff00,
+	0x9194, 0xf000, 0x810f, 0x9484, 0x0fff, 0x688e, 0x9286, 0x2000,
+	0x1150, 0x6800, 0x9086, 0x0001, 0x1118, 0x080c, 0x53fb, 0x0070,
+	0x080c, 0x7a1e, 0x0058, 0x9286, 0x3000, 0x1118, 0x080c, 0x7bed,
+	0x0028, 0x9286, 0x8000, 0x1110, 0x080c, 0x7dc0, 0x7817, 0x0140,
+	0x2001, 0x19c8, 0x2004, 0x9005, 0x090c, 0x898b, 0x0005, 0x2001,
+	0x1810, 0x2004, 0xd08c, 0x0178, 0x2001, 0x1800, 0x2004, 0x9086,
+	0x0003, 0x1148, 0x0026, 0x0036, 0x2011, 0x8048, 0x2518, 0x080c,
+	0x48f4, 0x003e, 0x002e, 0x0005, 0x0036, 0x0046, 0x0056, 0x00f6,
+	0x2079, 0x0200, 0x2019, 0xfffe, 0x7c30, 0x0050, 0x0036, 0x0046,
+	0x0056, 0x00f6, 0x2079, 0x0200, 0x7d44, 0x7c40, 0x2019, 0xffff,
+	0x2001, 0x1810, 0x2004, 0xd08c, 0x0160, 0x2001, 0x1800, 0x2004,
+	0x9086, 0x0003, 0x1130, 0x0026, 0x2011, 0x8048, 0x080c, 0x48f4,
+	0x002e, 0x00fe, 0x005e, 0x004e, 0x003e, 0x0005, 0x00b6, 0x00c6,
+	0x7010, 0x9084, 0xff00, 0x8007, 0x9096, 0x0001, 0x0120, 0x9096,
+	0x0023, 0x1904, 0x7bbe, 0x9186, 0x0023, 0x15c0, 0x080c, 0x7e55,
+	0x0904, 0x7bbe, 0x6120, 0x9186, 0x0001, 0x0150, 0x9186, 0x0004,
+	0x0138, 0x9186, 0x0008, 0x0120, 0x9186, 0x000a, 0x1904, 0x7bbe,
+	0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1130, 0x2009, 0x0015,
+	0x080c, 0x9ea9, 0x0804, 0x7bbe, 0x908e, 0x0214, 0x0118, 0x908e,
+	0x0210, 0x1130, 0x2009, 0x0015, 0x080c, 0x9ea9, 0x0804, 0x7bbe,
+	0x908e, 0x0100, 0x1904, 0x7bbe, 0x7034, 0x9005, 0x1904, 0x7bbe,
+	0x2009, 0x0016, 0x080c, 0x9ea9, 0x0804, 0x7bbe, 0x9186, 0x0022,
+	0x1904, 0x7bbe, 0x7030, 0x908e, 0x0300, 0x1580, 0x68d8, 0xd0a4,
+	0x0528, 0xc0b5, 0x68da, 0x7100, 0x918c, 0x00ff, 0x697a, 0x7004,
+	0x687e, 0x00f6, 0x2079, 0x0100, 0x79e6, 0x78ea, 0x0006, 0x9084,
+	0x00ff, 0x0016, 0x2008, 0x080c, 0x26b9, 0x7932, 0x7936, 0x001e,
+	0x000e, 0x00fe, 0x080c, 0x2670, 0x695a, 0x703c, 0x00e6, 0x2071,
+	0x0140, 0x7086, 0x2071, 0x1800, 0x70b2, 0x00ee, 0x7034, 0x9005,
+	0x1904, 0x7bbe, 0x2009, 0x0017, 0x0804, 0x7b6e, 0x908e, 0x0400,
+	0x1190, 0x7034, 0x9005, 0x1904, 0x7bbe, 0x080c, 0x6faa, 0x0120,
+	0x2009, 0x001d, 0x0804, 0x7b6e, 0x68d8, 0xc0a5, 0x68da, 0x2009,
+	0x0030, 0x0804, 0x7b6e, 0x908e, 0x0500, 0x1140, 0x7034, 0x9005,
+	0x1904, 0x7bbe, 0x2009, 0x0018, 0x0804, 0x7b6e, 0x908e, 0x2010,
+	0x1120, 0x2009, 0x0019, 0x0804, 0x7b6e, 0x908e, 0x2110, 0x1120,
+	0x2009, 0x001a, 0x0804, 0x7b6e, 0x908e, 0x5200, 0x1140, 0x7034,
+	0x9005, 0x1904, 0x7bbe, 0x2009, 0x001b, 0x0804, 0x7b6e, 0x908e,
+	0x5000, 0x1140, 0x7034, 0x9005, 0x1904, 0x7bbe, 0x2009, 0x001c,
+	0x0804, 0x7b6e, 0x908e, 0x1300, 0x1120, 0x2009, 0x0034, 0x0804,
+	0x7b6e, 0x908e, 0x1200, 0x1140, 0x7034, 0x9005, 0x1904, 0x7bbe,
+	0x2009, 0x0024, 0x0804, 0x7b6e, 0x908c, 0xff00, 0x918e, 0x2400,
+	0x1170, 0x2009, 0x002d, 0x2001, 0x1810, 0x2004, 0xd09c, 0x0904,
+	0x7b6e, 0x080c, 0xc8e6, 0x1904, 0x7bbe, 0x0804, 0x7b6c, 0x908c,
+	0xff00, 0x918e, 0x5300, 0x1120, 0x2009, 0x002a, 0x0804, 0x7b6e,
+	0x908e, 0x0f00, 0x1120, 0x2009, 0x0020, 0x0804, 0x7b6e, 0x908e,
+	0x6104, 0x1528, 0x2029, 0x0205, 0x2011, 0x026d, 0x8208, 0x2204,
+	0x9082, 0x0004, 0x8004, 0x8004, 0x20a8, 0x2011, 0x8015, 0x211c,
+	0x8108, 0x0046, 0x2124, 0x080c, 0x48f4, 0x004e, 0x8108, 0x0f04,
+	0x7b3a, 0x9186, 0x0280, 0x1d88, 0x2504, 0x8000, 0x202a, 0x2009,
+	0x0260, 0x0c58, 0x202b, 0x0000, 0x2009, 0x0023, 0x0478, 0x908e,
+	0x6000, 0x1118, 0x2009, 0x003f, 0x0448, 0x908e, 0x7800, 0x1118,
+	0x2009, 0x0045, 0x0418, 0x908e, 0x1000, 0x1118, 0x2009, 0x004e,
+	0x00e8, 0x908e, 0x6300, 0x1118, 0x2009, 0x004a, 0x00b8, 0x908c,
+	0xff00, 0x918e, 0x5600, 0x1118, 0x2009, 0x004f, 0x0078, 0x908c,
+	0xff00, 0x918e, 0x5700, 0x1118, 0x2009, 0x0050, 0x0038, 0x2009,
+	0x001d, 0x6838, 0xd0d4, 0x0110, 0x2009, 0x004c, 0x0016, 0x2011,
+	0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2670, 0x1904, 0x7bc1,
+	0x080c, 0x61f6, 0x1904, 0x7bc1, 0xbe12, 0xbd16, 0x001e, 0x0016,
+	0x080c, 0x6faa, 0x01c0, 0x68d8, 0xd08c, 0x1148, 0x7000, 0x9084,
+	0x00ff, 0x1188, 0x7004, 0x9084, 0xff00, 0x1168, 0x0040, 0x6878,
+	0x9606, 0x1148, 0x687c, 0x9506, 0x9084, 0xff00, 0x1120, 0x9584,
+	0x00ff, 0xb8b2, 0x0080, 0xb8b0, 0x9005, 0x1168, 0x9186, 0x0046,
+	0x1150, 0x6878, 0x9606, 0x1138, 0x687c, 0x9506, 0x9084, 0xff00,
+	0x1110, 0x001e, 0x0098, 0x080c, 0x9dd9, 0x01a8, 0x2b08, 0x6112,
+	0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x9186, 0x004c, 0x1110,
+	0x6023, 0x000a, 0x0016, 0x001e, 0x080c, 0x9ea9, 0x00ce, 0x00be,
+	0x0005, 0x001e, 0x0cd8, 0x2001, 0x180e, 0x2004, 0xd0ec, 0x0120,
+	0x2011, 0x8049, 0x080c, 0x48f4, 0x080c, 0x9e7c, 0x0d90, 0x2b08,
+	0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x0016, 0x9186,
+	0x0017, 0x0118, 0x9186, 0x0030, 0x1128, 0x6007, 0x0009, 0x6017,
+	0x2900, 0x0020, 0x6007, 0x0051, 0x6017, 0x0000, 0x602f, 0x0009,
+	0x6003, 0x0001, 0x080c, 0x8440, 0x08a0, 0x080c, 0x310a, 0x1140,
+	0x7010, 0x9084, 0xff00, 0x8007, 0x908e, 0x0008, 0x1108, 0x0009,
+	0x0005, 0x00b6, 0x00c6, 0x0046, 0x7000, 0x908c, 0xff00, 0x810f,
+	0x9186, 0x0033, 0x11e8, 0x080c, 0x7e55, 0x0904, 0x7c4a, 0x7124,
+	0x610a, 0x7030, 0x908e, 0x0200, 0x1140, 0x7034, 0x9005, 0x15d0,
+	0x2009, 0x0015, 0x080c, 0x9ea9, 0x04a8, 0x908e, 0x0100, 0x1590,
+	0x7034, 0x9005, 0x1578, 0x2009, 0x0016, 0x080c, 0x9ea9, 0x0450,
+	0x9186, 0x0032, 0x1538, 0x7030, 0x908e, 0x1400, 0x1518, 0x2009,
+	0x0038, 0x0016, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c,
+	0x2670, 0x11b8, 0x080c, 0x61f6, 0x11a0, 0xbe12, 0xbd16, 0x080c,
+	0x9dd9, 0x0178, 0x2b08, 0x6112, 0x080c, 0xbfb5, 0x6023, 0x0004,
+	0x7120, 0x610a, 0x001e, 0x080c, 0x9ea9, 0x080c, 0x898b, 0x0010,
+	0x00ce, 0x001e, 0x004e, 0x00ce, 0x00be, 0x0005, 0x00b6, 0x0046,
+	0x00e6, 0x00d6, 0x2028, 0x2130, 0x9696, 0x00ff, 0x11b8, 0x9592,
+	0xfffc, 0x02a0, 0x9596, 0xfffd, 0x1120, 0x2009, 0x007f, 0x0804,
+	0x7cac, 0x9596, 0xfffe, 0x1120, 0x2009, 0x007e, 0x0804, 0x7cac,
+	0x9596, 0xfffc, 0x1118, 0x2009, 0x0080, 0x04f0, 0x2011, 0x0000,
+	0x2019, 0x1836, 0x231c, 0xd3ac, 0x0130, 0x9026, 0x20a9, 0x0800,
+	0x2071, 0x1000, 0x0030, 0x2021, 0x0081, 0x20a9, 0x077f, 0x2071,
+	0x1081, 0x2e1c, 0x93dd, 0x0000, 0x1140, 0x82ff, 0x11d0, 0x9496,
+	0x00ff, 0x01b8, 0x2410, 0xc2fd, 0x00a0, 0xbf10, 0x2600, 0x9706,
+	0xb814, 0x1120, 0x9546, 0x1110, 0x2408, 0x00b0, 0x9745, 0x1148,
+	0x94c6, 0x007e, 0x0130, 0x94c6, 0x007f, 0x0118, 0x94c6, 0x0080,
+	0x1d20, 0x8420, 0x8e70, 0x1f04, 0x7c81, 0x82ff, 0x1118, 0x9085,
+	0x0001, 0x0018, 0xc2fc, 0x2208, 0x9006, 0x00de, 0x00ee, 0x004e,
+	0x00be, 0x0005, 0x7000, 0x908c, 0xff00, 0x810f, 0x9184, 0x000f,
+	0x0002, 0x7cc9, 0x7cc9, 0x7cc9, 0x7e67, 0x7cc9, 0x7cd2, 0x7cfd,
+	0x7d8b, 0x7cc9, 0x7cc9, 0x7cc9, 0x7cc9, 0x7cc9, 0x7cc9, 0x7cc9,
+	0x7cc9, 0x7817, 0x0140, 0x2001, 0x19c8, 0x2004, 0x9005, 0x090c,
+	0x898b, 0x0005, 0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7120, 0x2160,
+	0x9c8c, 0x0007, 0x11c0, 0x9c8a, 0x1cd0, 0x02a8, 0x6864, 0x9c02,
+	0x1290, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106,
+	0x1150, 0x700c, 0xb914, 0x9106, 0x1130, 0x7124, 0x610a, 0x2009,
+	0x0046, 0x080c, 0x9ea9, 0x7817, 0x0140, 0x2001, 0x19c8, 0x2004,
+	0x9005, 0x090c, 0x898b, 0x00be, 0x0005, 0x00b6, 0x00c6, 0x9484,
+	0x0fff, 0x0904, 0x7d61, 0x7110, 0xd1bc, 0x1904, 0x7d61, 0x7108,
+	0x700c, 0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00, 0x15b0,
+	0x81ff, 0x15a0, 0x9080, 0x3145, 0x200d, 0x918c, 0xff00, 0x810f,
+	0x2001, 0x0080, 0x9106, 0x0904, 0x7d61, 0x080c, 0x61f6, 0x1904,
+	0x7d61, 0xbe12, 0xbd16, 0xb800, 0xd0ec, 0x15d8, 0xba04, 0x9294,
+	0xff00, 0x9286, 0x0600, 0x11a0, 0x080c, 0x9dd9, 0x05e8, 0x2b08,
+	0x7028, 0x604a, 0x702c, 0x6046, 0x6112, 0x6023, 0x0006, 0x7120,
+	0x610a, 0x7130, 0x6156, 0x2009, 0x0044, 0x080c, 0xcb44, 0x0408,
+	0x080c, 0x657a, 0x1138, 0xb807, 0x0606, 0x0c30, 0x190c, 0x7c4e,
+	0x11c0, 0x0898, 0x080c, 0x9dd9, 0x2b08, 0x0198, 0x6112, 0x6023,
+	0x0004, 0x7120, 0x610a, 0x9286, 0x0400, 0x1118, 0x6007, 0x0005,
+	0x0010, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x8440, 0x080c,
+	0x898b, 0x7817, 0x0140, 0x2001, 0x19c8, 0x2004, 0x9005, 0x090c,
+	0x898b, 0x00ce, 0x00be, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0ec,
+	0x0120, 0x2011, 0x8049, 0x080c, 0x48f4, 0x080c, 0x9e7c, 0x0d48,
+	0x2b08, 0x6112, 0x6023, 0x0006, 0x7120, 0x610a, 0x7130, 0x6156,
+	0x6017, 0xf300, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c, 0x83f8,
+	0x080c, 0x898b, 0x08b0, 0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7020,
+	0x2060, 0x9c84, 0x0007, 0x11c0, 0x9c82, 0x1cd0, 0x02a8, 0x6864,
+	0x9c02, 0x1290, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910,
+	0x9106, 0x1150, 0x700c, 0xb914, 0x9106, 0x1130, 0x7124, 0x610a,
+	0x2009, 0x0045, 0x080c, 0x9ea9, 0x7817, 0x0140, 0x2001, 0x19c8,
+	0x2004, 0x9005, 0x090c, 0x898b, 0x00be, 0x0005, 0x6120, 0x9186,
+	0x0002, 0x0128, 0x9186, 0x0005, 0x0110, 0x9085, 0x0001, 0x0005,
+	0x080c, 0x310a, 0x1168, 0x7010, 0x9084, 0xff00, 0x8007, 0x9086,
+	0x0000, 0x1130, 0x9184, 0x000f, 0x908a, 0x0006, 0x1208, 0x000b,
+	0x0005, 0x7dd7, 0x7dd8, 0x7dd7, 0x7dd7, 0x7e37, 0x7e46, 0x0005,
+	0x00b6, 0x7110, 0xd1bc, 0x0120, 0x702c, 0xd084, 0x0904, 0x7e35,
+	0x700c, 0x7108, 0x080c, 0x2670, 0x1904, 0x7e35, 0x080c, 0x61f6,
+	0x1904, 0x7e35, 0xbe12, 0xbd16, 0x7110, 0xd1bc, 0x01d8, 0x080c,
+	0x657a, 0x0118, 0x9086, 0x0004, 0x1588, 0x00c6, 0x080c, 0x7e55,
+	0x00ce, 0x05d8, 0x080c, 0x9dd9, 0x2b08, 0x05b8, 0x6112, 0x080c,
+	0xbfb5, 0x6023, 0x0002, 0x7120, 0x610a, 0x2009, 0x0088, 0x080c,
+	0x9ea9, 0x0458, 0x080c, 0x657a, 0x0148, 0x9086, 0x0004, 0x0130,
+	0x080c, 0x6582, 0x0118, 0x9086, 0x0004, 0x1180, 0x080c, 0x9dd9,
+	0x2b08, 0x01d8, 0x6112, 0x080c, 0xbfb5, 0x6023, 0x0005, 0x7120,
+	0x610a, 0x2009, 0x0088, 0x080c, 0x9ea9, 0x0078, 0x080c, 0x9dd9,
+	0x2b08, 0x0158, 0x6112, 0x080c, 0xbfb5, 0x6023, 0x0004, 0x7120,
+	0x610a, 0x2009, 0x0001, 0x080c, 0x9ea9, 0x00be, 0x0005, 0x7110,
+	0xd1bc, 0x0158, 0x00d1, 0x0148, 0x080c, 0x7db6, 0x1130, 0x7124,
+	0x610a, 0x2009, 0x0089, 0x080c, 0x9ea9, 0x0005, 0x7110, 0xd1bc,
+	0x0158, 0x0059, 0x0148, 0x080c, 0x7db6, 0x1130, 0x7124, 0x610a,
+	0x2009, 0x008a, 0x080c, 0x9ea9, 0x0005, 0x7020, 0x2060, 0x9c84,
+	0x0007, 0x1158, 0x9c82, 0x1cd0, 0x0240, 0x2001, 0x1819, 0x2004,
+	0x9c02, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8, 0x00b6,
+	0x7110, 0xd1bc, 0x11d8, 0x7024, 0x2060, 0x9c84, 0x0007, 0x11b0,
+	0x9c82, 0x1cd0, 0x0298, 0x6864, 0x9c02, 0x1280, 0x7008, 0x9084,
+	0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1140, 0x700c, 0xb914,
+	0x9106, 0x1120, 0x2009, 0x0051, 0x080c, 0x9ea9, 0x7817, 0x0140,
+	0x2001, 0x19c8, 0x2004, 0x9005, 0x090c, 0x898b, 0x00be, 0x0005,
+	0x2031, 0x0105, 0x0069, 0x0005, 0x2031, 0x0206, 0x0049, 0x0005,
+	0x2031, 0x0207, 0x0029, 0x0005, 0x2031, 0x0213, 0x0009, 0x0005,
+	0x00c6, 0x0096, 0x00f6, 0x7000, 0x9084, 0xf000, 0x9086, 0xc000,
+	0x05d0, 0x080c, 0x9dd9, 0x05b8, 0x0066, 0x00c6, 0x0046, 0x2011,
+	0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2670, 0x15a0, 0x080c,
+	0x61f6, 0x1588, 0xbe12, 0xbd16, 0x2b00, 0x004e, 0x00ce, 0x6012,
+	0x080c, 0xbfb5, 0x080c, 0x0feb, 0x0510, 0x2900, 0x605a, 0x9006,
+	0xa802, 0xa866, 0xac6a, 0xa85c, 0x90f8, 0x001b, 0x20a9, 0x000e,
+	0xa860, 0x20e8, 0x20e1, 0x0000, 0x2fa0, 0x2e98, 0x4003, 0x006e,
+	0x6616, 0x6007, 0x003e, 0x6023, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x8440, 0x080c, 0x898b, 0x00fe, 0x009e, 0x00ce, 0x0005, 0x080c,
+	0x9e2f, 0x006e, 0x0cc0, 0x004e, 0x00ce, 0x0cc8, 0x00c6, 0x7000,
+	0x908c, 0xff00, 0x9184, 0xf000, 0x810f, 0x9086, 0x2000, 0x1904,
+	0x7f45, 0x9186, 0x0022, 0x15f0, 0x2001, 0x0111, 0x2004, 0x9005,
+	0x1904, 0x7f47, 0x7030, 0x908e, 0x0400, 0x0904, 0x7f47, 0x908e,
+	0x6000, 0x05e8, 0x908e, 0x5400, 0x05d0, 0x908e, 0x0300, 0x11d8,
+	0x2009, 0x1836, 0x210c, 0xd18c, 0x1590, 0xd1a4, 0x1580, 0x080c,
+	0x6538, 0x0588, 0x68ac, 0x9084, 0x00ff, 0x7100, 0x918c, 0x00ff,
+	0x9106, 0x1518, 0x687c, 0x69ac, 0x918c, 0xff00, 0x9105, 0x7104,
+	0x9106, 0x11d8, 0x00e0, 0x2009, 0x0103, 0x210c, 0xd1b4, 0x11a8,
+	0x908e, 0x5200, 0x09e8, 0x908e, 0x0500, 0x09d0, 0x908e, 0x5000,
+	0x09b8, 0x0058, 0x9186, 0x0023, 0x1140, 0x080c, 0x7e55, 0x0128,
+	0x6004, 0x9086, 0x0002, 0x0118, 0x0000, 0x9006, 0x0010, 0x9085,
+	0x0001, 0x00ce, 0x0005, 0x7030, 0x908e, 0x0300, 0x0118, 0x908e,
+	0x5200, 0x1d98, 0x2001, 0x1836, 0x2004, 0x9084, 0x0009, 0x9086,
+	0x0008, 0x0d68, 0x0c50, 0x00f6, 0x2079, 0x0200, 0x7800, 0xc0e5,
+	0xc0cc, 0x7802, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x1800, 0x7834,
+	0xd084, 0x1130, 0x2079, 0x0200, 0x7800, 0x9085, 0x1200, 0x7802,
+	0x00fe, 0x0005, 0x00e6, 0x2071, 0x1800, 0x7034, 0xc084, 0x7036,
+	0x00ee, 0x0005, 0x2071, 0x19d2, 0x7003, 0x0003, 0x700f, 0x0361,
+	0x9006, 0x701a, 0x7072, 0x7012, 0x7017, 0x1cd0, 0x7007, 0x0000,
+	0x7026, 0x702b, 0x93dd, 0x7032, 0x7037, 0x9445, 0x703f, 0xffff,
+	0x7042, 0x7047, 0x5239, 0x704a, 0x705b, 0x80da, 0x080c, 0x1004,
+	0x090c, 0x0db4, 0x2900, 0x703a, 0xa867, 0x0003, 0xa86f, 0x0100,
+	0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x19d2, 0x1d04, 0x802e, 0x2091,
+	0x6000, 0x700c, 0x8001, 0x700e, 0x1510, 0x2001, 0x187d, 0x2004,
+	0xd0c4, 0x0158, 0x3a00, 0xd08c, 0x1140, 0x20d1, 0x0000, 0x20d1,
+	0x0001, 0x20d1, 0x0000, 0x080c, 0x0db4, 0x700f, 0x0361, 0x7007,
+	0x0001, 0x0126, 0x2091, 0x8000, 0x080c, 0x811f, 0x7040, 0x900d,
+	0x0148, 0x8109, 0x7142, 0x1130, 0x7044, 0x080f, 0x0018, 0x0126,
+	0x2091, 0x8000, 0x7024, 0x900d, 0x0188, 0x7020, 0x8001, 0x7022,
+	0x1168, 0x7023, 0x0009, 0x8109, 0x7126, 0x9186, 0x03e8, 0x1110,
+	0x7028, 0x080f, 0x81ff, 0x1110, 0x7028, 0x080f, 0x7030, 0x900d,
+	0x0180, 0x702c, 0x8001, 0x702e, 0x1160, 0x702f, 0x0009, 0x8109,
+	0x7132, 0x0128, 0x9184, 0x007f, 0x090c, 0x954e, 0x0010, 0x7034,
+	0x080f, 0x703c, 0x9005, 0x0118, 0x0310, 0x8001, 0x703e, 0x704c,
+	0x900d, 0x0168, 0x7048, 0x8001, 0x704a, 0x1148, 0x704b, 0x0009,
+	0x8109, 0x714e, 0x1120, 0x7150, 0x714e, 0x7058, 0x080f, 0x7018,
+	0x900d, 0x01d8, 0x0016, 0x7070, 0x900d, 0x0158, 0x706c, 0x8001,
+	0x706e, 0x1138, 0x706f, 0x0009, 0x8109, 0x7172, 0x1110, 0x7074,
+	0x080f, 0x001e, 0x7008, 0x8001, 0x700a, 0x1138, 0x700b, 0x0009,
+	0x8109, 0x711a, 0x1110, 0x701c, 0x080f, 0x012e, 0x7004, 0x0002,
+	0x8056, 0x8057, 0x8073, 0x00e6, 0x2071, 0x19d2, 0x7018, 0x9005,
+	0x1120, 0x711a, 0x721e, 0x700b, 0x0009, 0x00ee, 0x0005, 0x00e6,
+	0x0006, 0x2071, 0x19d2, 0x701c, 0x9206, 0x1120, 0x701a, 0x701e,
+	0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x19d2,
+	0xb888, 0x9102, 0x0208, 0xb98a, 0x00ee, 0x0005, 0x0005, 0x00b6,
+	0x7110, 0x080c, 0x6256, 0x1168, 0xb888, 0x8001, 0x0250, 0xb88a,
+	0x1140, 0x0126, 0x2091, 0x8000, 0x0016, 0x080c, 0x898b, 0x001e,
+	0x012e, 0x8108, 0x9182, 0x0800, 0x0218, 0x900e, 0x7007, 0x0002,
+	0x7112, 0x00be, 0x0005, 0x7014, 0x2060, 0x0126, 0x2091, 0x8000,
+	0x6040, 0x9005, 0x0128, 0x8001, 0x6042, 0x1110, 0x080c, 0xbe46,
+	0x6018, 0x9005, 0x0528, 0x8001, 0x601a, 0x1510, 0x6120, 0x9186,
+	0x0003, 0x0118, 0x9186, 0x0006, 0x11c8, 0x080c, 0xbb3b, 0x01b0,
+	0x6014, 0x2048, 0xa884, 0x908a, 0x199a, 0x0280, 0x9082, 0x1999,
+	0xa886, 0x908a, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x800b,
+	0x810b, 0x9108, 0x611a, 0xa87c, 0xd0e4, 0x0110, 0x080c, 0xb827,
+	0x012e, 0x9c88, 0x0018, 0x7116, 0x2001, 0x1819, 0x2004, 0x9102,
+	0x0220, 0x7017, 0x1cd0, 0x7007, 0x0000, 0x0005, 0x00e6, 0x2071,
+	0x19d2, 0x7027, 0x07d0, 0x7023, 0x0009, 0x00ee, 0x0005, 0x2001,
+	0x19db, 0x2003, 0x0000, 0x0005, 0x00e6, 0x2071, 0x19d2, 0x7132,
+	0x702f, 0x0009, 0x00ee, 0x0005, 0x2011, 0x19de, 0x2013, 0x0000,
+	0x0005, 0x00e6, 0x2071, 0x19d2, 0x711a, 0x721e, 0x700b, 0x0009,
+	0x00ee, 0x0005, 0x0086, 0x0026, 0x7054, 0x8000, 0x7056, 0x2001,
+	0x19e0, 0x2044, 0xa06c, 0x9086, 0x0000, 0x0150, 0x7068, 0xa09a,
+	0x7064, 0xa096, 0x7060, 0xa092, 0x705c, 0xa08e, 0x080c, 0x10d5,
+	0x002e, 0x008e, 0x0005, 0x0006, 0x0016, 0x0096, 0x00a6, 0x00b6,
+	0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0156, 0x080c, 0x7fa3, 0x015e,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x001e,
+	0x000e, 0x0005, 0x00e6, 0x2071, 0x19d2, 0x7172, 0x7276, 0x706f,
+	0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0x19d2, 0x7074,
+	0x9206, 0x1110, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x2069,
+	0x1800, 0x69e4, 0xd1e4, 0x1518, 0x0026, 0xd1ec, 0x0140, 0x6a50,
+	0x6870, 0x9202, 0x0288, 0x8117, 0x9294, 0x00c0, 0x0088, 0x9184,
+	0x0007, 0x01a0, 0x8109, 0x9184, 0x0007, 0x0110, 0x69e6, 0x0070,
+	0x8107, 0x9084, 0x0007, 0x910d, 0x8107, 0x9106, 0x9094, 0x00c0,
+	0x9184, 0xff3f, 0x9205, 0x68e6, 0x080c, 0x0ecb, 0x002e, 0x0005,
+	0x00c6, 0x2061, 0x1a48, 0x00ce, 0x0005, 0x9184, 0x000f, 0x8003,
+	0x8003, 0x8003, 0x9080, 0x1a48, 0x2060, 0x0005, 0xa884, 0x908a,
+	0x199a, 0x1638, 0x9005, 0x1150, 0x00c6, 0x2061, 0x1a48, 0x6014,
+	0x00ce, 0x9005, 0x1130, 0x2001, 0x001e, 0x0018, 0x908e, 0xffff,
+	0x01b0, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0xa87c, 0x908c,
+	0x00c0, 0x918e, 0x00c0, 0x0904, 0x81e0, 0xd0b4, 0x1168, 0xd0bc,
+	0x1904, 0x81b9, 0x2009, 0x0006, 0x080c, 0x820d, 0x0005, 0x900e,
+	0x0c60, 0x2001, 0x1999, 0x08b0, 0xd0fc, 0x0160, 0x908c, 0x0003,
+	0x0120, 0x918e, 0x0003, 0x1904, 0x8207, 0x908c, 0x2020, 0x918e,
+	0x2020, 0x01a8, 0x6024, 0xd0d4, 0x11e8, 0x2009, 0x187d, 0x2104,
+	0xd084, 0x1138, 0x87ff, 0x1120, 0x2009, 0x0043, 0x0804, 0x9ea9,
+	0x0005, 0x87ff, 0x1de8, 0x2009, 0x0042, 0x0804, 0x9ea9, 0x6110,
+	0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20, 0x6024, 0xc0cd,
+	0x6026, 0x0c00, 0xc0d4, 0x6026, 0xa890, 0x602e, 0xa88c, 0x6032,
+	0x08e0, 0xd0fc, 0x0160, 0x908c, 0x0003, 0x0120, 0x918e, 0x0003,
+	0x1904, 0x8207, 0x908c, 0x2020, 0x918e, 0x2020, 0x0170, 0x0076,
+	0x00f6, 0x2c78, 0x080c, 0x164a, 0x00fe, 0x007e, 0x87ff, 0x1120,
+	0x2009, 0x0042, 0x080c, 0x9ea9, 0x0005, 0x6110, 0x00b6, 0x2158,
+	0xb900, 0x00be, 0xd1ac, 0x0d58, 0x6124, 0xc1cd, 0x6126, 0x0c38,
+	0xd0fc, 0x0188, 0x908c, 0x2020, 0x918e, 0x2020, 0x01a8, 0x9084,
+	0x0003, 0x908e, 0x0002, 0x0148, 0x87ff, 0x1120, 0x2009, 0x0041,
+	0x080c, 0x9ea9, 0x0005, 0x00b9, 0x0ce8, 0x87ff, 0x1dd8, 0x2009,
+	0x0043, 0x080c, 0x9ea9, 0x0cb0, 0x6110, 0x00b6, 0x2158, 0xb900,
+	0x00be, 0xd1ac, 0x0d20, 0x6124, 0xc1cd, 0x6126, 0x0c00, 0x2009,
+	0x0004, 0x0019, 0x0005, 0x2009, 0x0001, 0x0096, 0x080c, 0xbb3b,
+	0x0518, 0x6014, 0x2048, 0xa982, 0xa800, 0x6016, 0x9186, 0x0001,
+	0x1188, 0xa97c, 0x918c, 0x8100, 0x918e, 0x8100, 0x1158, 0x00c6,
+	0x2061, 0x1a48, 0x6200, 0xd28c, 0x1120, 0x6204, 0x8210, 0x0208,
+	0x6206, 0x00ce, 0x080c, 0x66da, 0x6014, 0x904d, 0x0076, 0x2039,
+	0x0000, 0x190c, 0x8156, 0x007e, 0x009e, 0x0005, 0x0156, 0x00c6,
+	0x2061, 0x1a48, 0x6000, 0x81ff, 0x0110, 0x9205, 0x0008, 0x9204,
+	0x6002, 0x00ce, 0x015e, 0x0005, 0x6800, 0xd08c, 0x1138, 0x6808,
+	0x9005, 0x0120, 0x8001, 0x680a, 0x9085, 0x0001, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x0036, 0x0046, 0x20a9, 0x0010, 0x9006, 0x8004,
+	0x2019, 0x0100, 0x231c, 0x93a6, 0x0008, 0x1118, 0x8086, 0x818e,
+	0x0020, 0x80f6, 0x3e00, 0x81f6, 0x3e08, 0x1208, 0x9200, 0x1f04,
+	0x8258, 0x93a6, 0x0008, 0x1118, 0x8086, 0x818e, 0x0020, 0x80f6,
+	0x3e00, 0x81f6, 0x3e08, 0x004e, 0x003e, 0x012e, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x0076, 0x0156, 0x20a9, 0x0010, 0x9005, 0x0510,
+	0x911a, 0x1600, 0x8213, 0x2039, 0x0100, 0x273c, 0x97be, 0x0008,
+	0x1110, 0x818d, 0x0010, 0x81f5, 0x3e08, 0x0228, 0x911a, 0x1220,
+	0x1f04, 0x8282, 0x0028, 0x911a, 0x2308, 0x8210, 0x1f04, 0x8282,
+	0x0006, 0x3200, 0x9084, 0xefff, 0x2080, 0x000e, 0x015e, 0x007e,
+	0x012e, 0x0005, 0x0006, 0x3200, 0x9085, 0x1000, 0x0ca8, 0x0126,
+	0x2091, 0x2800, 0x2079, 0x19bf, 0x012e, 0x00d6, 0x2069, 0x19bf,
+	0x6803, 0x0005, 0x0156, 0x0146, 0x01d6, 0x20e9, 0x0000, 0x2069,
+	0x0200, 0x080c, 0x9c37, 0x0401, 0x080c, 0x9c22, 0x00e9, 0x080c,
+	0x9c25, 0x00d1, 0x080c, 0x9c28, 0x00b9, 0x080c, 0x9c2b, 0x00a1,
+	0x080c, 0x9c2e, 0x0089, 0x080c, 0x9c31, 0x0071, 0x080c, 0x9c34,
+	0x0059, 0x01de, 0x014e, 0x015e, 0x2069, 0x0004, 0x2d04, 0x9085,
+	0x8001, 0x206a, 0x00de, 0x0005, 0x20a9, 0x0020, 0x20a1, 0x0240,
+	0x2001, 0x0000, 0x4004, 0x0005, 0x00c6, 0x6027, 0x0001, 0x7804,
+	0x9084, 0x0007, 0x0002, 0x82f5, 0x8319, 0x8358, 0x82fb, 0x8319,
+	0x82f5, 0x82f3, 0x82f3, 0x080c, 0x0db4, 0x080c, 0x80bf, 0x080c,
+	0x898b, 0x00ce, 0x0005, 0x62c0, 0x82ff, 0x1110, 0x00ce, 0x0005,
+	0x2011, 0x5b4e, 0x080c, 0x803f, 0x7828, 0x9092, 0x00c8, 0x1228,
+	0x8000, 0x782a, 0x080c, 0x5b8e, 0x0c88, 0x62c0, 0x080c, 0x9c3b,
+	0x080c, 0x5b4e, 0x7807, 0x0003, 0x7827, 0x0000, 0x782b, 0x0000,
+	0x0c28, 0x080c, 0x80bf, 0x6220, 0xd2a4, 0x0160, 0x782b, 0x0000,
+	0x7824, 0x9065, 0x090c, 0x0db4, 0x2009, 0x0013, 0x080c, 0x9ea9,
+	0x00ce, 0x0005, 0x00c6, 0x7824, 0x9065, 0x090c, 0x0db4, 0x7828,
+	0x9092, 0xc350, 0x12c0, 0x8000, 0x782a, 0x00ce, 0x080c, 0x29d7,
+	0x0278, 0x00c6, 0x7924, 0x2160, 0x6010, 0x906d, 0x090c, 0x0db4,
+	0x7807, 0x0000, 0x7827, 0x0000, 0x00ce, 0x080c, 0x898b, 0x0c00,
+	0x080c, 0x93a3, 0x08e8, 0x2011, 0x0130, 0x2214, 0x080c, 0x9c3b,
+	0x080c, 0xd903, 0x2009, 0x0014, 0x080c, 0x9ea9, 0x00ce, 0x0880,
+	0x2001, 0x19db, 0x2003, 0x0000, 0x62c0, 0x82ff, 0x1160, 0x782b,
+	0x0000, 0x7824, 0x9065, 0x090c, 0x0db4, 0x2009, 0x0013, 0x080c,
+	0x9efb, 0x00ce, 0x0005, 0x00b6, 0x00c6, 0x00d6, 0x7824, 0x9005,
+	0x090c, 0x0db4, 0x7828, 0x9092, 0xc350, 0x1648, 0x8000, 0x782a,
+	0x00de, 0x00ce, 0x00be, 0x080c, 0x29d7, 0x02f0, 0x00b6, 0x00c6,
+	0x00d6, 0x781c, 0x905d, 0x090c, 0x0db4, 0xb800, 0xc0dc, 0xb802,
+	0x7924, 0x2160, 0x080c, 0x9e2f, 0xb93c, 0x81ff, 0x090c, 0x0db4,
+	0x8109, 0xb93e, 0x7807, 0x0000, 0x7827, 0x0000, 0x00de, 0x00ce,
+	0x00be, 0x080c, 0x898b, 0x0868, 0x080c, 0x93a3, 0x0850, 0x2011,
+	0x0130, 0x2214, 0x080c, 0x9c3b, 0x080c, 0xd903, 0x7824, 0x9065,
+	0x2009, 0x0014, 0x080c, 0x9ea9, 0x00de, 0x00ce, 0x00be, 0x0804,
+	0x8369, 0x00c6, 0x2001, 0x009b, 0x2004, 0xd0fc, 0x190c, 0x1d57,
+	0x6024, 0x6027, 0x0002, 0xd0f4, 0x1580, 0x62c8, 0x60c4, 0x9205,
+	0x1170, 0x783c, 0x9065, 0x0130, 0x2009, 0x0049, 0x080c, 0x9ea9,
+	0x00ce, 0x0005, 0x2011, 0x19de, 0x2013, 0x0000, 0x0cc8, 0x793c,
+	0x81ff, 0x0dc0, 0x7944, 0x9192, 0x7530, 0x12f0, 0x8108, 0x7946,
+	0x793c, 0x9188, 0x0008, 0x210c, 0x918e, 0x0006, 0x1138, 0x6014,
+	0x9084, 0x1984, 0x9085, 0x0012, 0x6016, 0x0c10, 0x6014, 0x9084,
+	0x1984, 0x9085, 0x0016, 0x6016, 0x08d8, 0x793c, 0x2160, 0x2009,
+	0x004a, 0x080c, 0x9ea9, 0x08a0, 0x7848, 0xc085, 0x784a, 0x0880,
+	0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19bf, 0x6020, 0x8000, 0x6022, 0x6010, 0x9005,
+	0x0148, 0x9080, 0x0003, 0x2102, 0x6112, 0x012e, 0x00ce, 0x001e,
+	0x000e, 0x0005, 0x6116, 0x6112, 0x0cc0, 0x00d6, 0x2069, 0x19bf,
+	0xb800, 0xd0d4, 0x0168, 0x6820, 0x8000, 0x6822, 0x9086, 0x0001,
+	0x1110, 0x2b00, 0x681e, 0x00de, 0x0804, 0x898b, 0x00de, 0x0005,
+	0xc0d5, 0xb802, 0x6818, 0x9005, 0x0168, 0xb856, 0xb85b, 0x0000,
+	0x0086, 0x0006, 0x2b00, 0x681a, 0x008e, 0xa05a, 0x008e, 0x2069,
+	0x19bf, 0x0c08, 0xb856, 0xb85a, 0x2b00, 0x681a, 0x681e, 0x08d8,
+	0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19bf, 0x6020, 0x8000, 0x6022, 0x6008, 0x9005,
+	0x0148, 0x9080, 0x0003, 0x2102, 0x610a, 0x012e, 0x00ce, 0x001e,
+	0x000e, 0x0005, 0x610e, 0x610a, 0x0cc0, 0x00c6, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19bf, 0x6034, 0x9005, 0x0130, 0x9080, 0x0003,
+	0x2102, 0x6136, 0x00ce, 0x0005, 0x613a, 0x6136, 0x00ce, 0x0005,
+	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00b6, 0x0096, 0x0076, 0x0066,
+	0x0056, 0x0036, 0x0026, 0x0016, 0x0006, 0x0126, 0x902e, 0x2071,
+	0x19bf, 0x7638, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff, 0x0904,
+	0x84ec, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x84e7, 0x87ff,
+	0x0120, 0x6054, 0x9106, 0x1904, 0x84e7, 0x703c, 0x9c06, 0x1178,
+	0x0036, 0x2019, 0x0001, 0x080c, 0x96e9, 0x7033, 0x0000, 0x9006,
+	0x703e, 0x7042, 0x7046, 0x704a, 0x003e, 0x2029, 0x0001, 0x7038,
+	0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36, 0x1140, 0x2c00,
+	0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
+	0x0000, 0x080c, 0xbb3b, 0x01f0, 0x6014, 0x2048, 0x6020, 0x9086,
+	0x0003, 0x15b8, 0x6004, 0x9086, 0x0040, 0x090c, 0x98c4, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036, 0x0076, 0x080c,
+	0xbe2f, 0x080c, 0xd80d, 0x080c, 0x68a0, 0x007e, 0x003e, 0x001e,
+	0x080c, 0xbd24, 0x080c, 0x9e5f, 0x00ce, 0x0804, 0x8486, 0x2c78,
+	0x600c, 0x2060, 0x0804, 0x8486, 0x85ff, 0x0120, 0x0036, 0x080c,
+	0x8a68, 0x003e, 0x012e, 0x000e, 0x001e, 0x002e, 0x003e, 0x005e,
+	0x006e, 0x007e, 0x009e, 0x00be, 0x00ce, 0x00de, 0x00ee, 0x00fe,
+	0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016, 0x0036, 0x0076,
+	0x080c, 0xd80d, 0x080c, 0xd50f, 0x007e, 0x003e, 0x001e, 0x0890,
+	0x6020, 0x9086, 0x000a, 0x0904, 0x84d1, 0x0804, 0x84ca, 0x0006,
+	0x0066, 0x0096, 0x00c6, 0x00d6, 0x00f6, 0x9036, 0x0126, 0x2091,
+	0x8000, 0x2079, 0x19bf, 0x7838, 0x9065, 0x0904, 0x856c, 0x600c,
+	0x0006, 0x600f, 0x0000, 0x783c, 0x9c06, 0x1168, 0x0036, 0x2019,
+	0x0001, 0x080c, 0x96e9, 0x7833, 0x0000, 0x901e, 0x7b3e, 0x7b42,
+	0x7b46, 0x7b4a, 0x003e, 0x080c, 0xbb3b, 0x0548, 0x6014, 0x2048,
+	0x6020, 0x9086, 0x0003, 0x1590, 0x3e08, 0x918e, 0x0002, 0x1188,
+	0x6010, 0x9005, 0x0170, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
+	0x0140, 0x6040, 0x9005, 0x11a8, 0x2001, 0x1960, 0x2004, 0x6042,
+	0x0080, 0x6004, 0x9086, 0x0040, 0x090c, 0x98c4, 0xa867, 0x0103,
+	0xab7a, 0xa877, 0x0000, 0x080c, 0x6893, 0x080c, 0xbd24, 0x080c,
+	0x9e5f, 0x000e, 0x0804, 0x8524, 0x7e3a, 0x7e36, 0x012e, 0x00fe,
+	0x00de, 0x00ce, 0x009e, 0x006e, 0x000e, 0x0005, 0x6020, 0x9086,
+	0x0006, 0x1118, 0x080c, 0xd50f, 0x0c50, 0x6020, 0x9086, 0x000a,
+	0x09f8, 0x08b8, 0x0016, 0x0026, 0x0086, 0x9046, 0x0099, 0x080c,
+	0x866b, 0x008e, 0x002e, 0x001e, 0x0005, 0x00f6, 0x0126, 0x2079,
+	0x19bf, 0x2091, 0x8000, 0x080c, 0x8702, 0x080c, 0x8790, 0x012e,
+	0x00fe, 0x0005, 0x00b6, 0x0096, 0x00f6, 0x00e6, 0x00d6, 0x00c6,
+	0x0066, 0x0016, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19bf,
+	0x7614, 0x2660, 0x2678, 0x8cff, 0x0904, 0x8630, 0x6010, 0x2058,
+	0xb8a0, 0x9206, 0x1904, 0x862b, 0x88ff, 0x0120, 0x6054, 0x9106,
+	0x1904, 0x862b, 0x7024, 0x9c06, 0x1558, 0x2069, 0x0100, 0x6820,
+	0xd0a4, 0x1508, 0x080c, 0x80bf, 0x080c, 0x93c7, 0x68c3, 0x0000,
+	0x080c, 0x98c4, 0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04,
+	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2b21, 0x9006,
+	0x080c, 0x2b21, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
+	0x0001, 0x003e, 0x0028, 0x6003, 0x0009, 0x630a, 0x0804, 0x862b,
+	0x7014, 0x9c36, 0x1110, 0x660c, 0x7616, 0x7010, 0x9c36, 0x1140,
+	0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7012, 0x0010, 0x7013, 0x0000,
+	0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678,
+	0x600f, 0x0000, 0x6014, 0x2048, 0x080c, 0xbb3b, 0x01e8, 0x6020,
+	0x9086, 0x0003, 0x1580, 0x080c, 0xbd41, 0x1118, 0x080c, 0xa7cd,
+	0x0098, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036,
+	0x0086, 0x080c, 0xbe2f, 0x080c, 0xd80d, 0x080c, 0x68a0, 0x008e,
+	0x003e, 0x001e, 0x080c, 0xbd24, 0x080c, 0x9e5f, 0x080c, 0x979a,
+	0x00ce, 0x0804, 0x85ab, 0x2c78, 0x600c, 0x2060, 0x0804, 0x85ab,
+	0x012e, 0x000e, 0x001e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe,
+	0x009e, 0x00be, 0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016,
+	0x0036, 0x0086, 0x080c, 0xd80d, 0x080c, 0xd50f, 0x008e, 0x003e,
+	0x001e, 0x08d0, 0x080c, 0xa7cd, 0x6020, 0x9086, 0x0002, 0x1160,
+	0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0904, 0x8611, 0x9086,
+	0x008b, 0x0904, 0x8611, 0x0840, 0x6020, 0x9086, 0x0005, 0x1920,
+	0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x09c8, 0x9086, 0x008b,
+	0x09b0, 0x0804, 0x8624, 0x00b6, 0x00a6, 0x0096, 0x00c6, 0x0006,
+	0x0126, 0x2091, 0x8000, 0x9280, 0x1000, 0x2004, 0x905d, 0x0904,
+	0x86fb, 0x00f6, 0x00e6, 0x00d6, 0x0066, 0x2071, 0x19bf, 0xbe54,
+	0x7018, 0x9b06, 0x1108, 0x761a, 0x701c, 0x9b06, 0x1130, 0x86ff,
+	0x1118, 0x7018, 0x701e, 0x0008, 0x761e, 0xb858, 0x904d, 0x0108,
+	0xae56, 0x96d5, 0x0000, 0x0110, 0x2900, 0xb05a, 0xb857, 0x0000,
+	0xb85b, 0x0000, 0xb800, 0xc0d4, 0xc0dc, 0xb802, 0x080c, 0x6189,
+	0x0904, 0x86f7, 0x7624, 0x86ff, 0x0904, 0x86e6, 0x9680, 0x0005,
+	0x2004, 0x9906, 0x15d8, 0x00d6, 0x2069, 0x0100, 0x68c0, 0x9005,
+	0x0560, 0x080c, 0x80bf, 0x080c, 0x93c7, 0x68c3, 0x0000, 0x080c,
+	0x98c4, 0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384,
+	0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2b21, 0x9006, 0x080c,
+	0x2b21, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001,
+	0x003e, 0x00de, 0x00c6, 0xb83c, 0x9005, 0x0110, 0x8001, 0xb83e,
+	0x2660, 0x080c, 0x9e5f, 0x00ce, 0x0048, 0x00de, 0x00c6, 0x2660,
+	0x6003, 0x0009, 0x630a, 0x00ce, 0x0804, 0x869e, 0x89ff, 0x0158,
+	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0xbe2f, 0x080c,
+	0xd80d, 0x080c, 0x68a0, 0x080c, 0x979a, 0x0804, 0x869e, 0x006e,
+	0x00de, 0x00ee, 0x00fe, 0x012e, 0x000e, 0x00ce, 0x009e, 0x00ae,
+	0x00be, 0x0005, 0x0096, 0x0006, 0x0066, 0x00c6, 0x00d6, 0x9036,
+	0x7814, 0x9065, 0x0904, 0x8763, 0x600c, 0x0006, 0x600f, 0x0000,
+	0x7824, 0x9c06, 0x1570, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508,
+	0x080c, 0x80bf, 0x080c, 0x93c7, 0x68c3, 0x0000, 0x080c, 0x98c4,
+	0x7827, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000,
+	0x0138, 0x2001, 0x0100, 0x080c, 0x2b21, 0x9006, 0x080c, 0x2b21,
+	0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e,
+	0x0040, 0x080c, 0x6530, 0x1520, 0x6003, 0x0009, 0x630a, 0x2c30,
+	0x00f8, 0x6014, 0x2048, 0x080c, 0xbb39, 0x01b0, 0x6020, 0x9086,
+	0x0003, 0x1508, 0x080c, 0xbd41, 0x1118, 0x080c, 0xa7cd, 0x0060,
+	0x080c, 0x6530, 0x1168, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000,
+	0x080c, 0x68a0, 0x080c, 0xbd24, 0x080c, 0x9e5f, 0x080c, 0x979a,
+	0x000e, 0x0804, 0x8709, 0x7e16, 0x7e12, 0x00de, 0x00ce, 0x006e,
+	0x000e, 0x009e, 0x0005, 0x6020, 0x9086, 0x0006, 0x1118, 0x080c,
+	0xd50f, 0x0c50, 0x080c, 0xa7cd, 0x6020, 0x9086, 0x0002, 0x1150,
+	0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0990, 0x9086, 0x008b,
+	0x0978, 0x08d0, 0x6020, 0x9086, 0x0005, 0x19b0, 0x6004, 0x0006,
+	0x9086, 0x0085, 0x000e, 0x0d18, 0x9086, 0x008b, 0x0d00, 0x0860,
+	0x0006, 0x0066, 0x0096, 0x00b6, 0x00c6, 0x00d6, 0x7818, 0x905d,
+	0x0904, 0x8810, 0xb854, 0x0006, 0x9006, 0xb856, 0xb85a, 0xb800,
+	0xc0d4, 0xc0dc, 0xb802, 0x080c, 0x6189, 0x0904, 0x880d, 0x7e24,
+	0x86ff, 0x0904, 0x8800, 0x9680, 0x0005, 0x2004, 0x9906, 0x1904,
+	0x8800, 0x00d6, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0904, 0x87f7,
+	0x080c, 0x80bf, 0x080c, 0x93c7, 0x68c3, 0x0000, 0x080c, 0x98c4,
+	0x7827, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000,
+	0x0138, 0x2001, 0x0100, 0x080c, 0x2b21, 0x9006, 0x080c, 0x2b21,
+	0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e,
+	0x00de, 0x00c6, 0x3e08, 0x918e, 0x0002, 0x1168, 0xb800, 0xd0bc,
+	0x0150, 0x9680, 0x0010, 0x200c, 0x81ff, 0x1518, 0x2009, 0x1960,
+	0x210c, 0x2102, 0x00f0, 0xb83c, 0x9005, 0x0110, 0x8001, 0xb83e,
+	0x2660, 0x600f, 0x0000, 0x080c, 0x9e5f, 0x00ce, 0x0048, 0x00de,
+	0x00c6, 0x2660, 0x6003, 0x0009, 0x630a, 0x00ce, 0x0804, 0x87a3,
+	0x89ff, 0x0138, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
+	0x68a0, 0x080c, 0x979a, 0x0804, 0x87a3, 0x000e, 0x0804, 0x8797,
+	0x781e, 0x781a, 0x00de, 0x00ce, 0x00be, 0x009e, 0x006e, 0x000e,
+	0x0005, 0x00e6, 0x00d6, 0x0096, 0x0066, 0xb800, 0xd0dc, 0x01a0,
+	0xb84c, 0x904d, 0x0188, 0xa878, 0x9606, 0x1170, 0x2071, 0x19bf,
+	0x7024, 0x9035, 0x0148, 0x9080, 0x0005, 0x2004, 0x9906, 0x1120,
+	0xb800, 0xc0dc, 0xb802, 0x0029, 0x006e, 0x009e, 0x00de, 0x00ee,
+	0x0005, 0x00f6, 0x2079, 0x0100, 0x78c0, 0x9005, 0x1138, 0x00c6,
+	0x2660, 0x6003, 0x0009, 0x630a, 0x00ce, 0x04b8, 0x080c, 0x93c7,
+	0x78c3, 0x0000, 0x080c, 0x98c4, 0x7027, 0x0000, 0x0036, 0x2079,
+	0x0140, 0x7b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c,
+	0x2b21, 0x9006, 0x080c, 0x2b21, 0x2079, 0x0100, 0x7824, 0xd084,
+	0x0110, 0x7827, 0x0001, 0x080c, 0x98c4, 0x003e, 0x080c, 0x6189,
+	0x00c6, 0xb83c, 0x9005, 0x0110, 0x8001, 0xb83e, 0x2660, 0x080c,
+	0x9e2f, 0x00ce, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
+	0xbe2f, 0x080c, 0x68a0, 0x080c, 0x979a, 0x00fe, 0x0005, 0x00b6,
+	0x00e6, 0x00c6, 0x2011, 0x0101, 0x2204, 0xc0c4, 0x2012, 0x2001,
+	0x180c, 0x2014, 0xc2e4, 0x2202, 0x2071, 0x19bf, 0x7004, 0x9084,
+	0x0007, 0x0002, 0x889c, 0x88a0, 0x88be, 0x88e7, 0x8925, 0x889c,
+	0x88b7, 0x889a, 0x080c, 0x0db4, 0x00ce, 0x00ee, 0x00be, 0x0005,
+	0x7024, 0x9065, 0x0148, 0x7020, 0x8001, 0x7022, 0x600c, 0x9015,
+	0x0158, 0x7216, 0x600f, 0x0000, 0x7007, 0x0000, 0x7027, 0x0000,
+	0x00ce, 0x00ee, 0x00be, 0x0005, 0x7216, 0x7212, 0x0ca8, 0x7007,
+	0x0000, 0x7027, 0x0000, 0x7020, 0x9005, 0x0070, 0x6010, 0x2058,
+	0x080c, 0x6189, 0xb800, 0xc0dc, 0xb802, 0x7007, 0x0000, 0x7027,
+	0x0000, 0x7020, 0x8001, 0x7022, 0x1148, 0x2001, 0x180c, 0x2014,
+	0xd2ec, 0x1180, 0x00ce, 0x00ee, 0x00be, 0x0005, 0xb854, 0x9015,
+	0x0120, 0x721e, 0x080c, 0x898b, 0x0ca8, 0x7218, 0x721e, 0x080c,
+	0x898b, 0x0c80, 0xc2ec, 0x2202, 0x080c, 0x8a68, 0x0c58, 0x7024,
+	0x9065, 0x05b8, 0x700c, 0x9c06, 0x1160, 0x080c, 0x979a, 0x600c,
+	0x9015, 0x0120, 0x720e, 0x600f, 0x0000, 0x0448, 0x720e, 0x720a,
+	0x0430, 0x7014, 0x9c06, 0x1160, 0x080c, 0x979a, 0x600c, 0x9015,
+	0x0120, 0x7216, 0x600f, 0x0000, 0x00d0, 0x7216, 0x7212, 0x00b8,
+	0x6020, 0x9086, 0x0003, 0x1198, 0x6010, 0x2058, 0x080c, 0x6189,
+	0xb800, 0xc0dc, 0xb802, 0x080c, 0x979a, 0x701c, 0x9065, 0x0138,
+	0xb854, 0x9015, 0x0110, 0x721e, 0x0010, 0x7218, 0x721e, 0x7027,
+	0x0000, 0x00ce, 0x00ee, 0x00be, 0x0005, 0x7024, 0x9065, 0x0140,
+	0x080c, 0x979a, 0x600c, 0x9015, 0x0158, 0x720e, 0x600f, 0x0000,
+	0x080c, 0x98c4, 0x7027, 0x0000, 0x00ce, 0x00ee, 0x00be, 0x0005,
+	0x720e, 0x720a, 0x0ca8, 0x00d6, 0x2069, 0x19bf, 0x6830, 0x9084,
+	0x0003, 0x0002, 0x8948, 0x894a, 0x896e, 0x8946, 0x080c, 0x0db4,
+	0x00de, 0x0005, 0x00c6, 0x6840, 0x9086, 0x0001, 0x01b8, 0x683c,
+	0x9065, 0x0130, 0x600c, 0x9015, 0x0170, 0x6a3a, 0x600f, 0x0000,
+	0x6833, 0x0000, 0x683f, 0x0000, 0x2011, 0x19de, 0x2013, 0x0000,
+	0x00ce, 0x00de, 0x0005, 0x683a, 0x6836, 0x0c90, 0x6843, 0x0000,
+	0x6838, 0x9065, 0x0d68, 0x6003, 0x0003, 0x0c50, 0x00c6, 0x9006,
+	0x6842, 0x6846, 0x684a, 0x683c, 0x9065, 0x0160, 0x600c, 0x9015,
+	0x0130, 0x6a3a, 0x600f, 0x0000, 0x683f, 0x0000, 0x0018, 0x683e,
+	0x683a, 0x6836, 0x00ce, 0x00de, 0x0005, 0x2001, 0x180c, 0x200c,
+	0xc1e5, 0x2102, 0x0005, 0x2001, 0x180c, 0x200c, 0xd1ec, 0x0120,
+	0xc1ec, 0x2102, 0x080c, 0x8a68, 0x2001, 0x19cb, 0x2004, 0x9086,
+	0x0001, 0x0d58, 0x00d6, 0x2069, 0x19bf, 0x6804, 0x9084, 0x0007,
+	0x0002, 0x89ab, 0x8a50, 0x8a50, 0x8a50, 0x8a50, 0x8a52, 0x8a50,
+	0x89a9, 0x080c, 0x0db4, 0x6820, 0x9005, 0x1110, 0x00de, 0x0005,
+	0x00c6, 0x680c, 0x9065, 0x0150, 0x6807, 0x0004, 0x6826, 0x682b,
+	0x0000, 0x080c, 0x8abf, 0x00ce, 0x00de, 0x0005, 0x6814, 0x9065,
+	0x0150, 0x6807, 0x0001, 0x6826, 0x682b, 0x0000, 0x080c, 0x8abf,
+	0x00ce, 0x00de, 0x0005, 0x00b6, 0x00e6, 0x6a1c, 0x92dd, 0x0000,
+	0x0904, 0x8a3a, 0xb84c, 0x900d, 0x0118, 0xb888, 0x9005, 0x01a0,
+	0xb854, 0x905d, 0x0120, 0x920e, 0x0904, 0x8a3a, 0x0028, 0x6818,
+	0x920e, 0x0904, 0x8a3a, 0x2058, 0xb84c, 0x900d, 0x0d88, 0xb888,
+	0x9005, 0x1d70, 0x2b00, 0x681e, 0xbb3c, 0xb838, 0x9302, 0x1e40,
+	0x080c, 0x9e06, 0x0904, 0x8a3a, 0x8318, 0xbb3e, 0x6116, 0x2b10,
+	0x6212, 0x0096, 0x2148, 0xa880, 0x9084, 0x00ff, 0x605e, 0xa883,
+	0x0000, 0xa884, 0x009e, 0x908a, 0x199a, 0x0210, 0x2001, 0x1999,
+	0x8003, 0x801b, 0x831b, 0x9318, 0x631a, 0x6114, 0x0096, 0x2148,
+	0xa964, 0x009e, 0x918c, 0x00ff, 0x918e, 0x0048, 0x0538, 0x00f6,
+	0x2c78, 0x2061, 0x0100, 0xbab0, 0x629a, 0x2069, 0x0200, 0x2071,
+	0x0240, 0x080c, 0x8ff7, 0x2069, 0x19bf, 0xbb00, 0xc3dd, 0xbb02,
+	0x6807, 0x0002, 0x2f18, 0x6b26, 0x682b, 0x0000, 0x7823, 0x0003,
+	0x7803, 0x0001, 0x7807, 0x0040, 0x00fe, 0x00ee, 0x00be, 0x00ce,
+	0x00de, 0x0005, 0x00ee, 0x00be, 0x00ce, 0x0cd0, 0x6807, 0x0006,
+	0x2c18, 0x6b26, 0x6820, 0x8001, 0x6822, 0x682b, 0x0000, 0x080c,
+	0x6189, 0x080c, 0x9c5b, 0x00ee, 0x00be, 0x00ce, 0x00de, 0x0005,
+	0x00de, 0x0005, 0x00c6, 0x680c, 0x9065, 0x0138, 0x6807, 0x0004,
+	0x6826, 0x682b, 0x0000, 0x080c, 0x8abf, 0x00ce, 0x00de, 0x0005,
+	0x2001, 0x180c, 0x2014, 0xc2ed, 0x2202, 0x00de, 0x00fe, 0x0005,
+	0x00f6, 0x00d6, 0x2069, 0x19bf, 0x6830, 0x9086, 0x0000, 0x1548,
+	0x2001, 0x180c, 0x2014, 0xd2e4, 0x0130, 0xc2e4, 0x2202, 0x080c,
+	0x899a, 0x2069, 0x19bf, 0x2001, 0x180c, 0x200c, 0xd1c4, 0x11e0,
+	0x6838, 0x907d, 0x01b0, 0x6a04, 0x9296, 0x0000, 0x1568, 0x6833,
+	0x0001, 0x683e, 0x6847, 0x0000, 0x684b, 0x0000, 0x0126, 0x00f6,
+	0x2091, 0x2400, 0x002e, 0x080c, 0x1af5, 0x1158, 0x012e, 0x080c,
+	0x9224, 0x00de, 0x00fe, 0x0005, 0xc1c4, 0x2102, 0x080c, 0x705a,
+	0x08f8, 0x012e, 0x6843, 0x0000, 0x7803, 0x0002, 0x780c, 0x9015,
+	0x0140, 0x6a3a, 0x780f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000,
+	0x0c40, 0x683a, 0x6836, 0x0cc0, 0x6a04, 0x9296, 0x0006, 0x1904,
+	0x8a60, 0x6a30, 0x9296, 0x0000, 0x0950, 0x0804, 0x8a60, 0x6020,
+	0x9084, 0x000f, 0x000b, 0x0005, 0x8ad3, 0x8ad8, 0x8f31, 0x8fc0,
+	0x8ad8, 0x8f31, 0x8fc0, 0x8ad3, 0x8ad8, 0x8ad3, 0x8ad3, 0x8ad3,
+	0x8ad3, 0x8ad3, 0x8ad3, 0x080c, 0x887f, 0x080c, 0x898b, 0x0005,
+	0x00b6, 0x0156, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6,
+	0x00e6, 0x00f6, 0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a,
+	0x0053, 0x1a0c, 0x0db4, 0x6110, 0x2158, 0xb9b0, 0x2c78, 0x2061,
+	0x0100, 0x619a, 0x908a, 0x0040, 0x1a04, 0x8b44, 0x005b, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e,
+	0x00be, 0x0005, 0x8cbb, 0x8cf6, 0x8d1f, 0x8dc2, 0x8de3, 0x8de9,
+	0x8df6, 0x8dfe, 0x8e0a, 0x8e10, 0x8e21, 0x8e10, 0x8e78, 0x8dfe,
+	0x8e84, 0x8e8a, 0x8e0a, 0x8e8a, 0x8e96, 0x8b42, 0x8b42, 0x8b42,
+	0x8b42, 0x8b42, 0x8b42, 0x8b42, 0x8b42, 0x8b42, 0x8b42, 0x8b42,
+	0x95a0, 0x95c3, 0x95d4, 0x95f4, 0x9626, 0x8df6, 0x8b42, 0x8df6,
+	0x8e10, 0x8b42, 0x8d1f, 0x8dc2, 0x8b42, 0x99bb, 0x8e10, 0x8b42,
+	0x99d7, 0x8e10, 0x8b42, 0x8e0a, 0x8cb5, 0x8b65, 0x8b42, 0x99f3,
+	0x9a60, 0x9b3b, 0x8b42, 0x9b48, 0x8df3, 0x9b73, 0x8b42, 0x9630,
+	0x9ba0, 0x8b42, 0x080c, 0x0db4, 0x2100, 0x005b, 0x00fe, 0x00ee,
+	0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be,
+	0x0005, 0x8b63, 0x8b63, 0x8b63, 0x8b8c, 0x8c38, 0x8c43, 0x8b63,
+	0x8b63, 0x8b63, 0x8c8a, 0x8c96, 0x8ba7, 0x8b63, 0x8bc2, 0x8bf6,
+	0x9d22, 0x9d67, 0x8e10, 0x080c, 0x0db4, 0x00d6, 0x0096, 0x080c,
+	0x8ea9, 0x7003, 0x2414, 0x7007, 0x0018, 0x700b, 0x0800, 0x7814,
+	0x2048, 0xa83c, 0x700e, 0xa850, 0x7022, 0xa854, 0x7026, 0x60c3,
+	0x0018, 0x080c, 0x939b, 0x009e, 0x00de, 0x0005, 0x7810, 0x00b6,
+	0x2058, 0xb8a0, 0x00be, 0x080c, 0x9dae, 0x1118, 0x9084, 0xff80,
+	0x0110, 0x9085, 0x0001, 0x0005, 0x00d6, 0x0096, 0x080c, 0x8ea9,
+	0x7003, 0x0500, 0x7814, 0x2048, 0xa874, 0x700a, 0xa878, 0x700e,
+	0xa87c, 0x7012, 0xa880, 0x7016, 0xa884, 0x701a, 0xa888, 0x701e,
+	0x60c3, 0x0010, 0x080c, 0x939b, 0x009e, 0x00de, 0x0005, 0x00d6,
+	0x0096, 0x080c, 0x8ea9, 0x7003, 0x0500, 0x7814, 0x2048, 0xa8cc,
+	0x700a, 0xa8d0, 0x700e, 0xa8d4, 0x7012, 0xa8d8, 0x7016, 0xa8dc,
+	0x701a, 0xa8e0, 0x701e, 0x60c3, 0x0010, 0x080c, 0x939b, 0x009e,
+	0x00de, 0x0005, 0x00d6, 0x0096, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x8ea9, 0x20e9, 0x0000, 0x2001, 0x197b, 0x2003, 0x0000, 0x7814,
+	0x2048, 0xa814, 0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0,
+	0xa85c, 0x9080, 0x001b, 0x2098, 0x2001, 0x197b, 0x0016, 0x200c,
+	0x2001, 0x0001, 0x080c, 0x225a, 0x080c, 0xc848, 0x9006, 0x080c,
+	0x225a, 0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c28, 0x04d9,
+	0x080c, 0x939b, 0x012e, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x8ef4, 0x20e9, 0x0000, 0x2001,
+	0x197b, 0x2003, 0x0000, 0x7814, 0x2048, 0xa86f, 0x0200, 0xa873,
+	0x0000, 0xa814, 0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0,
+	0xa85c, 0x9080, 0x001b, 0x2098, 0x2001, 0x197b, 0x0016, 0x200c,
+	0x080c, 0xc848, 0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c60,
+	0x0051, 0x7814, 0x2048, 0x080c, 0x0f9d, 0x080c, 0x939b, 0x012e,
+	0x009e, 0x00de, 0x0005, 0x60c0, 0x8004, 0x9084, 0x0003, 0x9005,
+	0x0130, 0x9082, 0x0004, 0x20a3, 0x0000, 0x8000, 0x1de0, 0x0005,
+	0x080c, 0x8ea9, 0x7003, 0x7800, 0x7808, 0x8007, 0x700a, 0x60c3,
+	0x0008, 0x0804, 0x939b, 0x00d6, 0x00e6, 0x080c, 0x8ef4, 0x7814,
+	0x9084, 0xff00, 0x2073, 0x0200, 0x8e70, 0x8e70, 0x9095, 0x0010,
+	0x2272, 0x8e70, 0x2073, 0x0034, 0x8e70, 0x2069, 0x1805, 0x20a9,
+	0x0004, 0x2d76, 0x8d68, 0x8e70, 0x1f04, 0x8c59, 0x2069, 0x1801,
+	0x20a9, 0x0004, 0x2d76, 0x8d68, 0x8e70, 0x1f04, 0x8c62, 0x2069,
+	0x198b, 0x9086, 0xdf00, 0x0110, 0x2069, 0x19a5, 0x20a9, 0x001a,
+	0x9e86, 0x0260, 0x1148, 0x00c6, 0x2061, 0x0200, 0x6010, 0x8000,
+	0x6012, 0x00ce, 0x2071, 0x0240, 0x2d04, 0x8007, 0x2072, 0x8d68,
+	0x8e70, 0x1f04, 0x8c70, 0x60c3, 0x004c, 0x080c, 0x939b, 0x00ee,
+	0x00de, 0x0005, 0x080c, 0x8ea9, 0x7003, 0x6300, 0x7007, 0x0028,
+	0x7808, 0x700e, 0x60c3, 0x0008, 0x0804, 0x939b, 0x00d6, 0x0026,
+	0x0016, 0x080c, 0x8ef4, 0x7003, 0x0200, 0x7814, 0x700e, 0x00e6,
+	0x9ef0, 0x0004, 0x2009, 0x0001, 0x2011, 0x000c, 0x2073, 0x0800,
+	0x8e70, 0x2073, 0x0000, 0x00ee, 0x7206, 0x710a, 0x62c2, 0x080c,
+	0x939b, 0x001e, 0x002e, 0x00de, 0x0005, 0x2001, 0x1817, 0x2004,
+	0x609a, 0x0804, 0x939b, 0x080c, 0x8ea9, 0x7003, 0x5200, 0x2069,
+	0x185b, 0x6804, 0xd084, 0x0130, 0x6828, 0x0016, 0x080c, 0x26a3,
+	0x710e, 0x001e, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805,
+	0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003, 0x20a9, 0x0004, 0x2099,
+	0x1801, 0x20a1, 0x0254, 0x4003, 0x080c, 0x9dae, 0x1120, 0xb8a0,
+	0x9082, 0x007f, 0x0248, 0x2001, 0x181e, 0x2004, 0x7032, 0x2001,
+	0x181f, 0x2004, 0x7036, 0x0030, 0x2001, 0x1817, 0x2004, 0x9084,
+	0x00ff, 0x7036, 0x60c3, 0x001c, 0x0804, 0x939b, 0x080c, 0x8ea9,
+	0x7003, 0x0500, 0x080c, 0x9dae, 0x1120, 0xb8a0, 0x9082, 0x007f,
+	0x0248, 0x2001, 0x181e, 0x2004, 0x700a, 0x2001, 0x181f, 0x2004,
+	0x700e, 0x0030, 0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x700e,
 	0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000,
-	0x20a1, 0x0250, 0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1,
-	0x0254, 0x4003, 0x080c, 0x9dc1, 0x1120, 0xb8a0, 0x9082, 0x007f,
-	0x0248, 0x2001, 0x181e, 0x2004, 0x7032, 0x2001, 0x181f, 0x2004,
-	0x7036, 0x0030, 0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x7036,
-	0x60c3, 0x001c, 0x0804, 0x9381, 0x080c, 0x8e8f, 0x7003, 0x0500,
-	0x080c, 0x9dc1, 0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001,
-	0x181e, 0x2004, 0x700a, 0x2001, 0x181f, 0x2004, 0x700e, 0x0030,
-	0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x700e, 0x20a9, 0x0004,
-	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250,
-	0x4003, 0x60c3, 0x0010, 0x0804, 0x9381, 0x080c, 0x8e8f, 0x9006,
-	0x080c, 0x6535, 0xb8a0, 0x9086, 0x007e, 0x1130, 0x7003, 0x0400,
-	0x620c, 0xc2b4, 0x620e, 0x0058, 0x7814, 0x0096, 0x904d, 0x0120,
-	0x9006, 0xa89a, 0xa8a6, 0xa8aa, 0x009e, 0x7003, 0x0300, 0xb8a0,
-	0x9086, 0x007e, 0x1904, 0x8d70, 0x00d6, 0x2069, 0x193c, 0x2001,
-	0x1836, 0x2004, 0xd0a4, 0x0178, 0x6800, 0x700a, 0x6808, 0x9084,
-	0x2000, 0x7012, 0x680c, 0x7016, 0x701f, 0x2710, 0x6818, 0x7022,
-	0x681c, 0x7026, 0x0080, 0x6800, 0x700a, 0x6804, 0x700e, 0x6808,
-	0x080c, 0x6f9b, 0x1118, 0x9084, 0x37ff, 0x0010, 0x9084, 0x3fff,
-	0x7012, 0x680c, 0x7016, 0x00de, 0x20a9, 0x0004, 0x20e1, 0x0001,
-	0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256, 0x4003, 0x20a9,
-	0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x00d6, 0x080c,
-	0x9c35, 0x2069, 0x1944, 0x2071, 0x024e, 0x6800, 0xc0dd, 0x7002,
-	0x080c, 0x5393, 0xd0e4, 0x0110, 0x680c, 0x700e, 0x00de, 0x04a0,
-	0x2001, 0x1836, 0x2004, 0xd0a4, 0x0168, 0x0016, 0x2009, 0x0002,
-	0x60e0, 0x9106, 0x0130, 0x2100, 0x60e3, 0x0000, 0x080c, 0x26d9,
-	0x61e2, 0x001e, 0x20e1, 0x0001, 0x2099, 0x193c, 0x20e9, 0x0000,
-	0x20a1, 0x024e, 0x20a9, 0x0008, 0x4003, 0x20a9, 0x0004, 0x2099,
-	0x1805, 0x20a1, 0x0256, 0x4003, 0x20a9, 0x0004, 0x2099, 0x1801,
-	0x20a1, 0x025a, 0x4003, 0x080c, 0x9c35, 0x20a1, 0x024e, 0x20a9,
-	0x0008, 0x2099, 0x1944, 0x4003, 0x60c3, 0x0074, 0x0804, 0x9381,
-	0x080c, 0x8e8f, 0x7003, 0x2010, 0x7007, 0x0014, 0x700b, 0x0800,
-	0x700f, 0x2000, 0x9006, 0x00f6, 0x2079, 0x1853, 0x7904, 0x00fe,
-	0xd1ac, 0x1110, 0x9085, 0x0020, 0x0010, 0x9085, 0x0010, 0x9085,
-	0x0002, 0x00d6, 0x0804, 0x8e3f, 0x7026, 0x60c3, 0x0014, 0x0804,
-	0x9381, 0x080c, 0x8e8f, 0x7003, 0x5000, 0x0804, 0x8d1f, 0x080c,
-	0x8e8f, 0x7003, 0x2110, 0x7007, 0x0014, 0x60c3, 0x0014, 0x0804,
-	0x9381, 0x080c, 0x8ed1, 0x0010, 0x080c, 0x8eda, 0x7003, 0x0200,
-	0x60c3, 0x0004, 0x0804, 0x9381, 0x080c, 0x8eda, 0x7003, 0x0100,
-	0x700b, 0x0003, 0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804, 0x9381,
-	0x080c, 0x8eda, 0x7003, 0x0200, 0x0804, 0x8d1f, 0x080c, 0x8eda,
-	0x7003, 0x0100, 0x782c, 0x9005, 0x0110, 0x700a, 0x0010, 0x700b,
-	0x0003, 0x7814, 0x700e, 0x60c3, 0x0008, 0x0804, 0x9381, 0x00d6,
-	0x080c, 0x8eda, 0x7003, 0x0210, 0x7007, 0x0014, 0x700b, 0x0800,
-	0xb894, 0x9086, 0x0014, 0x1198, 0xb99c, 0x9184, 0x0030, 0x0190,
-	0xb998, 0x9184, 0xc000, 0x1140, 0xd1ec, 0x0118, 0x700f, 0x2100,
-	0x0058, 0x700f, 0x0100, 0x0040, 0x700f, 0x0400, 0x0028, 0x700f,
-	0x0700, 0x0010, 0x700f, 0x0800, 0x00f6, 0x2079, 0x1853, 0x7904,
-	0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0x0010, 0x9085, 0x0010,
-	0x2009, 0x1875, 0x210c, 0xd184, 0x1110, 0x9085, 0x0002, 0x0026,
-	0x2009, 0x1873, 0x210c, 0xd1e4, 0x0150, 0xc0c5, 0xbabc, 0xd28c,
-	0x1108, 0xc0cd, 0x9094, 0x0030, 0x9296, 0x0010, 0x0140, 0xd1ec,
-	0x0130, 0x9094, 0x0030, 0x9296, 0x0010, 0x0108, 0xc0bd, 0x002e,
-	0x7026, 0x60c3, 0x0014, 0x00de, 0x0804, 0x9381, 0x080c, 0x8eda,
-	0x7003, 0x0210, 0x7007, 0x0014, 0x700f, 0x0100, 0x60c3, 0x0014,
-	0x0804, 0x9381, 0x080c, 0x8eda, 0x7003, 0x0200, 0x0804, 0x8ca5,
-	0x080c, 0x8eda, 0x7003, 0x0100, 0x700b, 0x0003, 0x700f, 0x2a00,
-	0x60c3, 0x0008, 0x0804, 0x9381, 0x080c, 0x8eda, 0x7003, 0x0100,
-	0x700b, 0x000b, 0x60c3, 0x0008, 0x0804, 0x9381, 0x0026, 0x00d6,
-	0x0036, 0x0046, 0x2019, 0x3200, 0x2021, 0x0800, 0x0040, 0x0026,
-	0x00d6, 0x0036, 0x0046, 0x2019, 0x2200, 0x2021, 0x0100, 0x080c,
-	0x9c4a, 0xb810, 0x9305, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800,
-	0x6878, 0x700a, 0x687c, 0x700e, 0x9485, 0x0029, 0x7012, 0x004e,
-	0x003e, 0x00de, 0x080c, 0x936f, 0x721a, 0x9f95, 0x0000, 0x7222,
-	0x7027, 0xffff, 0x2071, 0x024c, 0x002e, 0x0005, 0x0026, 0x080c,
-	0x9c4a, 0x7003, 0x02ff, 0x7007, 0xfffc, 0x00d6, 0x2069, 0x1800,
-	0x6878, 0x700a, 0x687c, 0x700e, 0x00de, 0x7013, 0x2029, 0x0c10,
-	0x7003, 0x0100, 0x7007, 0x0000, 0x700b, 0xfc02, 0x700f, 0x0000,
-	0x0005, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x3300, 0x2021,
-	0x0800, 0x0040, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x2300,
-	0x2021, 0x0100, 0x080c, 0x9c4a, 0xb810, 0x9305, 0x7002, 0xb814,
-	0x7006, 0x2069, 0x1800, 0xb810, 0x9005, 0x1140, 0xb814, 0x9005,
-	0x1128, 0x700b, 0x00ff, 0x700f, 0xfffe, 0x0020, 0x6878, 0x700a,
-	0x687c, 0x700e, 0x0000, 0x9485, 0x0098, 0x7012, 0x004e, 0x003e,
-	0x00de, 0x080c, 0x936f, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226,
-	0x2071, 0x024c, 0x002e, 0x0005, 0x080c, 0x936f, 0x721a, 0x7a08,
-	0x7222, 0x7814, 0x7026, 0x2071, 0x024c, 0x002e, 0x0005, 0x00b6,
-	0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2069, 0x0200, 0x2071, 0x0240,
-	0x6004, 0x908a, 0x0085, 0x0a0c, 0x0db4, 0x908a, 0x0092, 0x1a0c,
-	0x0db4, 0x6110, 0x2158, 0xb9b0, 0x2c78, 0x2061, 0x0100, 0x619a,
-	0x9082, 0x0085, 0x0033, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be,
-	0x0005, 0x8f48, 0x8f57, 0x8f62, 0x8f46, 0x8f46, 0x8f46, 0x8f48,
-	0x8f46, 0x8f46, 0x8f46, 0x8f46, 0x8f46, 0x8f46, 0x080c, 0x0db4,
-	0x0411, 0x60c3, 0x0000, 0x0026, 0x080c, 0x29cc, 0x0228, 0x2011,
-	0x0101, 0x2204, 0xc0c5, 0x2012, 0x002e, 0x0804, 0x9381, 0x0431,
-	0x7808, 0x700a, 0x7814, 0x700e, 0x7017, 0xffff, 0x60c3, 0x000c,
-	0x0804, 0x9381, 0x0479, 0x7003, 0x0003, 0x7007, 0x0300, 0x60c3,
-	0x0004, 0x0804, 0x9381, 0x0026, 0x080c, 0x9c4a, 0xb810, 0x9085,
-	0x8100, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6878, 0x700a,
-	0x687c, 0x700e, 0x7013, 0x0009, 0x0804, 0x8eaa, 0x0026, 0x080c,
-	0x9c4a, 0xb810, 0x9085, 0x8400, 0x7002, 0xb814, 0x7006, 0x2069,
-	0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x2001, 0x0099, 0x7012,
-	0x0804, 0x8f0c, 0x0026, 0x080c, 0x9c4a, 0xb810, 0x9085, 0x8500,
-	0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6878, 0x700a, 0x687c,
-	0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x8f0c, 0x00b6, 0x00c6,
-	0x00d6, 0x00e6, 0x00f6, 0x2c78, 0x2069, 0x0200, 0x2071, 0x0240,
-	0x7804, 0x908a, 0x0040, 0x0a0c, 0x0db4, 0x908a, 0x0054, 0x1a0c,
-	0x0db4, 0x7910, 0x2158, 0xb9b0, 0x2061, 0x0100, 0x619a, 0x9082,
-	0x0040, 0x0033, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005,
-	0x8fdd, 0x9099, 0x906c, 0x91bb, 0x8fdb, 0x8fdb, 0x8fdb, 0x8fdb,
-	0x8fdb, 0x8fdb, 0x8fdb, 0x978e, 0x9796, 0x979e, 0x97a6, 0x8fdb,
-	0x9b92, 0x8fdb, 0x9786, 0x080c, 0x0db4, 0x0096, 0x780b, 0xffff,
-	0x080c, 0x9048, 0x7914, 0x2148, 0xa978, 0x7956, 0xae64, 0x96b4,
-	0x00ff, 0x9686, 0x0008, 0x1148, 0xa8b4, 0x7032, 0xa8b8, 0x7036,
-	0xa8bc, 0x703a, 0xa8c0, 0x703e, 0x0008, 0x7132, 0xa97c, 0x9184,
-	0x000f, 0x1118, 0x2001, 0x0005, 0x0040, 0xd184, 0x0118, 0x2001,
-	0x0004, 0x0018, 0x9084, 0x0006, 0x8004, 0x2010, 0x785c, 0x9084,
-	0x00ff, 0x8007, 0x9205, 0x7042, 0xd1ac, 0x0158, 0x7047, 0x0002,
-	0x9686, 0x0008, 0x1118, 0x080c, 0x1789, 0x0010, 0x080c, 0x164a,
-	0x0050, 0xd1b4, 0x0118, 0x7047, 0x0001, 0x0028, 0x7047, 0x0000,
-	0x9016, 0x2230, 0x0010, 0xaab0, 0xaeac, 0x726a, 0x766e, 0x20a9,
-	0x0008, 0x20e9, 0x0000, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0023,
-	0x2098, 0x20a1, 0x0252, 0x2069, 0x0200, 0x6813, 0x0018, 0x4003,
-	0x6813, 0x0008, 0x60c3, 0x0020, 0x6017, 0x0009, 0x2001, 0x19d3,
-	0x2003, 0x07d0, 0x2001, 0x19d2, 0x2003, 0x0009, 0x009e, 0x0005,
-	0x6813, 0x0008, 0xba8c, 0x8210, 0xb8bc, 0xd084, 0x0128, 0x7a46,
-	0x7b14, 0x7b4a, 0x722e, 0x732a, 0x9294, 0x00ff, 0xba8e, 0x8217,
-	0x721a, 0xba10, 0x9295, 0x0600, 0x7202, 0xba14, 0x7206, 0x2069,
-	0x1800, 0x6a78, 0x720a, 0x6a7c, 0x720e, 0x7013, 0x0829, 0x2f10,
-	0x7222, 0x7027, 0xffff, 0x0005, 0x00d6, 0x0096, 0x0081, 0x7814,
-	0x2048, 0xa890, 0x7002, 0xa88c, 0x7006, 0xa8b0, 0x700a, 0xa8ac,
-	0x700e, 0x60c3, 0x000c, 0x009e, 0x00de, 0x0804, 0x9381, 0x6813,
-	0x0008, 0xb810, 0x9085, 0x0500, 0x7002, 0xb814, 0x7006, 0x2069,
-	0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x7013, 0x0889, 0x080c,
-	0x936f, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c,
-	0x0005, 0x00d6, 0x0096, 0x080c, 0x9199, 0x7814, 0x2048, 0x080c,
-	0xbb2a, 0x1130, 0x7814, 0x9084, 0x0700, 0x8007, 0x0033, 0x0010,
-	0x9006, 0x001b, 0x009e, 0x00de, 0x0005, 0x90b7, 0x9120, 0x9130,
-	0x9156, 0x9162, 0x9173, 0x917b, 0x90b5, 0x080c, 0x0db4, 0x0016,
-	0x0036, 0xa97c, 0x918c, 0x0003, 0x0118, 0x9186, 0x0003, 0x1198,
-	0xaba8, 0x7824, 0xd0cc, 0x1168, 0x7316, 0xa898, 0x701a, 0xa894,
-	0x701e, 0x003e, 0x001e, 0x2001, 0x1981, 0x2004, 0x60c2, 0x0804,
-	0x9381, 0xc3e5, 0x0c88, 0x9186, 0x0001, 0x190c, 0x0db4, 0xaba8,
-	0x7824, 0xd0cc, 0x1904, 0x911d, 0x7316, 0xa898, 0x701a, 0xa894,
-	0x701e, 0xa8a4, 0x7026, 0xa8ac, 0x702e, 0x2009, 0x0018, 0x9384,
-	0x0300, 0x0570, 0xd3c4, 0x0110, 0xa8ac, 0x9108, 0xd3cc, 0x0110,
-	0xa8a4, 0x9108, 0x6810, 0x9085, 0x0010, 0x6812, 0x2011, 0x0258,
-	0x20e9, 0x0000, 0x22a0, 0x0156, 0x20a9, 0x0008, 0xa860, 0x20e0,
-	0xa85c, 0x9080, 0x002c, 0x2098, 0x4003, 0x6810, 0x8000, 0x6812,
-	0x2011, 0x0240, 0x22a0, 0x20a9, 0x0005, 0x4003, 0x6810, 0xc084,
-	0x6812, 0x015e, 0x9184, 0x0003, 0x0118, 0x2019, 0x0245, 0x201a,
-	0x61c2, 0x003e, 0x001e, 0x0804, 0x9381, 0xc3e5, 0x0804, 0x90dc,
-	0x2011, 0x0008, 0x2001, 0x180f, 0x2004, 0xd0a4, 0x0110, 0x2011,
-	0x0028, 0x7824, 0xd0cc, 0x1110, 0x7216, 0x0470, 0x0ce8, 0xc2e5,
-	0x2011, 0x0302, 0x0016, 0x782c, 0x701a, 0x7930, 0x711e, 0x9105,
-	0x0108, 0xc2dd, 0x001e, 0x7824, 0xd0cc, 0x0108, 0xc2e5, 0x7216,
-	0x7027, 0x0012, 0x702f, 0x0008, 0x7043, 0x7000, 0x7047, 0x0500,
-	0x704f, 0x000a, 0x2069, 0x0200, 0x6813, 0x0009, 0x2071, 0x0240,
-	0x700b, 0x2500, 0x60c3, 0x0032, 0x0804, 0x9381, 0x2011, 0x0028,
-	0x7824, 0xd0cc, 0x1128, 0x7216, 0x60c3, 0x0018, 0x0804, 0x9381,
-	0x0cd0, 0xc2e5, 0x2011, 0x0100, 0x7824, 0xd0cc, 0x0108, 0xc2e5,
-	0x7216, 0x702f, 0x0008, 0x7858, 0x9084, 0x00ff, 0x7036, 0x60c3,
-	0x0020, 0x0804, 0x9381, 0x2011, 0x0008, 0x7824, 0xd0cc, 0x0108,
-	0xc2e5, 0x7216, 0x0c08, 0x0036, 0x7b14, 0x9384, 0xff00, 0x7816,
-	0x9384, 0x00ff, 0x8001, 0x1138, 0x7824, 0xd0cc, 0x0108, 0xc2e5,
-	0x7216, 0x003e, 0x0888, 0x0046, 0x2021, 0x0800, 0x0006, 0x7824,
-	0xd0cc, 0x000e, 0x0108, 0xc4e5, 0x7416, 0x004e, 0x701e, 0x003e,
-	0x0818, 0x00d6, 0x6813, 0x0008, 0xb810, 0x9085, 0x0700, 0x7002,
-	0xb814, 0x7006, 0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e,
-	0x7824, 0xd0cc, 0x1168, 0x7013, 0x0898, 0x080c, 0x936f, 0x721a,
-	0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c, 0x00de, 0x0005,
-	0x7013, 0x0889, 0x0c90, 0x0016, 0x7814, 0x9084, 0x0700, 0x8007,
-	0x0013, 0x001e, 0x0005, 0x91cb, 0x91cb, 0x91cd, 0x91cb, 0x91cb,
-	0x91cb, 0x91e7, 0x91cb, 0x080c, 0x0db4, 0x7914, 0x918c, 0x08ff,
-	0x918d, 0xf600, 0x7916, 0x2009, 0x0003, 0x00b9, 0x2069, 0x1853,
-	0x6804, 0xd0bc, 0x0130, 0x682c, 0x9084, 0x00ff, 0x8007, 0x7032,
-	0x0010, 0x7033, 0x3f00, 0x60c3, 0x0001, 0x0804, 0x9381, 0x2009,
-	0x0003, 0x0019, 0x7033, 0x7f00, 0x0cb0, 0x0016, 0x080c, 0x9c4a,
-	0x001e, 0xb810, 0x9085, 0x0100, 0x7002, 0xb814, 0x7006, 0x2069,
-	0x1800, 0x6a78, 0x720a, 0x6a7c, 0x720e, 0x7013, 0x0888, 0x918d,
-	0x0008, 0x7116, 0x080c, 0x936f, 0x721a, 0x7a08, 0x7222, 0x2f10,
-	0x7226, 0x0005, 0x00b6, 0x0096, 0x00e6, 0x00d6, 0x00c6, 0x0056,
-	0x0046, 0x0036, 0x2061, 0x0100, 0x2071, 0x1800, 0x7810, 0x2058,
-	0xb8a0, 0x2028, 0xb910, 0xba14, 0x7378, 0x747c, 0x7820, 0x90be,
-	0x0006, 0x0904, 0x92de, 0x90be, 0x000a, 0x1904, 0x929a, 0xb8b0,
-	0x609e, 0x7814, 0x2048, 0xa87c, 0xd0fc, 0x0558, 0xaf90, 0x9784,
-	0xff00, 0x9105, 0x6062, 0x873f, 0x9784, 0xff00, 0x0006, 0x7814,
-	0x2048, 0xa878, 0xc0fc, 0x9005, 0x000e, 0x1160, 0xaf94, 0x87ff,
-	0x0198, 0x2039, 0x0098, 0x9705, 0x6072, 0x7808, 0x6082, 0x2f00,
-	0x6086, 0x0038, 0x9185, 0x2200, 0x6062, 0x6073, 0x0129, 0x6077,
-	0x0000, 0xb8b0, 0x609e, 0x0050, 0x2039, 0x0029, 0x9705, 0x6072,
-	0x0cc0, 0x9185, 0x0200, 0x6062, 0x6073, 0x2029, 0xa87c, 0xd0fc,
-	0x0118, 0xaf94, 0x87ff, 0x1120, 0x2f00, 0x6082, 0x7808, 0x6086,
-	0x6266, 0x636a, 0x646e, 0x6077, 0x0000, 0xb88c, 0x8000, 0x9084,
-	0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000, 0xa838, 0x608a,
-	0xa834, 0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce,
-	0x60af, 0x95d5, 0x60d7, 0x0000, 0x080c, 0x9c2f, 0x2009, 0x07d0,
-	0x60c4, 0x9084, 0xfff0, 0x9005, 0x0110, 0x2009, 0x1b58, 0x080c,
-	0x80a6, 0x003e, 0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x009e,
-	0x00be, 0x0005, 0x7804, 0x9086, 0x0040, 0x0904, 0x931a, 0x9185,
-	0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073, 0x0809, 0x6077,
-	0x0008, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xb88c, 0x8000, 0x9084,
-	0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000, 0x2f00, 0x6082,
-	0x7808, 0x6086, 0x7814, 0x2048, 0xa838, 0x608a, 0xa834, 0x608e,
-	0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce, 0xbab0, 0x629e,
-	0x080c, 0x9c2f, 0x2009, 0x07d0, 0x60c4, 0x9084, 0xfff0, 0x9005,
-	0x0110, 0x2009, 0x1b58, 0x080c, 0x80a6, 0x003e, 0x004e, 0x005e,
-	0x00ce, 0x00de, 0x00ee, 0x009e, 0x00be, 0x0005, 0x7814, 0x2048,
-	0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x0904, 0x9336, 0x9185,
-	0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073, 0x0880, 0x6077,
-	0x0008, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a,
-	0x7838, 0x607e, 0x2f00, 0x6086, 0x7808, 0x6082, 0xa890, 0x608a,
-	0xa88c, 0x608e, 0xa8b0, 0x60c6, 0xa8ac, 0x60ca, 0xa8ac, 0x7930,
-	0x9108, 0x7932, 0xa8b0, 0x792c, 0x9109, 0x792e, 0xb86c, 0x60ce,
-	0x60af, 0x95d5, 0x60d7, 0x0000, 0xbab0, 0x629e, 0x080c, 0x9c0c,
-	0x0804, 0x92ca, 0xb8bc, 0xd084, 0x0148, 0xb88c, 0x7814, 0x2048,
-	0xb88c, 0x7846, 0xa836, 0x2900, 0xa83a, 0xb04a, 0x9185, 0x0600,
-	0x6062, 0x6266, 0x636a, 0x646e, 0x6073, 0x0829, 0x6077, 0x0000,
-	0x60af, 0x9575, 0x60d7, 0x0000, 0x0804, 0x92ad, 0x9185, 0x0700,
-	0x6062, 0x6266, 0x636a, 0x646e, 0x7824, 0xd0cc, 0x7826, 0x0118,
-	0x6073, 0x0889, 0x0010, 0x6073, 0x0898, 0x6077, 0x0000, 0xb88c,
+	0x20a1, 0x0250, 0x4003, 0x60c3, 0x0010, 0x0804, 0x939b, 0x080c,
+	0x8ea9, 0x9006, 0x080c, 0x6544, 0xb8a0, 0x9086, 0x007e, 0x1130,
+	0x7003, 0x0400, 0x620c, 0xc2b4, 0x620e, 0x0058, 0x7814, 0x0096,
+	0x904d, 0x0120, 0x9006, 0xa89a, 0xa8a6, 0xa8aa, 0x009e, 0x7003,
+	0x0300, 0xb8a0, 0x9086, 0x007e, 0x1904, 0x8d8a, 0x00d6, 0x2069,
+	0x1944, 0x2001, 0x1836, 0x2004, 0xd0a4, 0x0178, 0x6800, 0x700a,
+	0x6808, 0x9084, 0x2000, 0x7012, 0x680c, 0x7016, 0x701f, 0x2710,
+	0x6818, 0x7022, 0x681c, 0x7026, 0x0080, 0x6800, 0x700a, 0x6804,
+	0x700e, 0x6808, 0x080c, 0x6faa, 0x1118, 0x9084, 0x37ff, 0x0010,
+	0x9084, 0x3fff, 0x7012, 0x680c, 0x7016, 0x00de, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256,
+	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003,
+	0x00d6, 0x080c, 0x9c22, 0x2069, 0x194c, 0x2071, 0x024e, 0x6800,
+	0xc0dd, 0x7002, 0x080c, 0x539e, 0xd0e4, 0x0110, 0x680c, 0x700e,
+	0x00de, 0x04a0, 0x2001, 0x1836, 0x2004, 0xd0a4, 0x0168, 0x0016,
+	0x2009, 0x0002, 0x60e0, 0x9106, 0x0130, 0x2100, 0x60e3, 0x0000,
+	0x080c, 0x26e4, 0x61e2, 0x001e, 0x20e1, 0x0001, 0x2099, 0x1944,
+	0x20e9, 0x0000, 0x20a1, 0x024e, 0x20a9, 0x0008, 0x4003, 0x20a9,
+	0x0004, 0x2099, 0x1805, 0x20a1, 0x0256, 0x4003, 0x20a9, 0x0004,
+	0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x080c, 0x9c22, 0x20a1,
+	0x024e, 0x20a9, 0x0008, 0x2099, 0x194c, 0x4003, 0x60c3, 0x0074,
+	0x0804, 0x939b, 0x080c, 0x8ea9, 0x7003, 0x2010, 0x7007, 0x0014,
+	0x700b, 0x0800, 0x700f, 0x2000, 0x9006, 0x00f6, 0x2079, 0x185b,
+	0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0x0010, 0x9085,
+	0x0010, 0x9085, 0x0002, 0x00d6, 0x0804, 0x8e59, 0x7026, 0x60c3,
+	0x0014, 0x0804, 0x939b, 0x080c, 0x8ea9, 0x7003, 0x5000, 0x0804,
+	0x8d39, 0x080c, 0x8ea9, 0x7003, 0x2110, 0x7007, 0x0014, 0x60c3,
+	0x0014, 0x0804, 0x939b, 0x080c, 0x8eeb, 0x0010, 0x080c, 0x8ef4,
+	0x7003, 0x0200, 0x60c3, 0x0004, 0x0804, 0x939b, 0x080c, 0x8ef4,
+	0x7003, 0x0100, 0x700b, 0x0003, 0x700f, 0x2a00, 0x60c3, 0x0008,
+	0x0804, 0x939b, 0x080c, 0x8ef4, 0x7003, 0x0200, 0x0804, 0x8d39,
+	0x080c, 0x8ef4, 0x7003, 0x0100, 0x782c, 0x9005, 0x0110, 0x700a,
+	0x0010, 0x700b, 0x0003, 0x7814, 0x700e, 0x60c3, 0x0008, 0x0804,
+	0x939b, 0x00d6, 0x080c, 0x8ef4, 0x7003, 0x0210, 0x7007, 0x0014,
+	0x700b, 0x0800, 0xb894, 0x9086, 0x0014, 0x1198, 0xb99c, 0x9184,
+	0x0030, 0x0190, 0xb998, 0x9184, 0xc000, 0x1140, 0xd1ec, 0x0118,
+	0x700f, 0x2100, 0x0058, 0x700f, 0x0100, 0x0040, 0x700f, 0x0400,
+	0x0028, 0x700f, 0x0700, 0x0010, 0x700f, 0x0800, 0x00f6, 0x2079,
+	0x185b, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0x0010,
+	0x9085, 0x0010, 0x2009, 0x187d, 0x210c, 0xd184, 0x1110, 0x9085,
+	0x0002, 0x0026, 0x2009, 0x187b, 0x210c, 0xd1e4, 0x0150, 0xc0c5,
+	0xbabc, 0xd28c, 0x1108, 0xc0cd, 0x9094, 0x0030, 0x9296, 0x0010,
+	0x0140, 0xd1ec, 0x0130, 0x9094, 0x0030, 0x9296, 0x0010, 0x0108,
+	0xc0bd, 0x002e, 0x7026, 0x60c3, 0x0014, 0x00de, 0x0804, 0x939b,
+	0x080c, 0x8ef4, 0x7003, 0x0210, 0x7007, 0x0014, 0x700f, 0x0100,
+	0x60c3, 0x0014, 0x0804, 0x939b, 0x080c, 0x8ef4, 0x7003, 0x0200,
+	0x0804, 0x8cbf, 0x080c, 0x8ef4, 0x7003, 0x0100, 0x700b, 0x0003,
+	0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804, 0x939b, 0x080c, 0x8ef4,
+	0x7003, 0x0100, 0x700b, 0x000b, 0x60c3, 0x0008, 0x0804, 0x939b,
+	0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x3200, 0x2021, 0x0800,
+	0x0040, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x2200, 0x2021,
+	0x0100, 0x080c, 0x9c37, 0xb810, 0x9305, 0x7002, 0xb814, 0x7006,
+	0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x9485, 0x0029,
+	0x7012, 0x004e, 0x003e, 0x00de, 0x080c, 0x9389, 0x721a, 0x9f95,
+	0x0000, 0x7222, 0x7027, 0xffff, 0x2071, 0x024c, 0x002e, 0x0005,
+	0x0026, 0x080c, 0x9c37, 0x7003, 0x02ff, 0x7007, 0xfffc, 0x00d6,
+	0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x00de, 0x7013,
+	0x2029, 0x0c10, 0x7003, 0x0100, 0x7007, 0x0000, 0x700b, 0xfc02,
+	0x700f, 0x0000, 0x0005, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019,
+	0x3300, 0x2021, 0x0800, 0x0040, 0x0026, 0x00d6, 0x0036, 0x0046,
+	0x2019, 0x2300, 0x2021, 0x0100, 0x080c, 0x9c37, 0xb810, 0x9305,
+	0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0xb810, 0x9005, 0x1140,
+	0xb814, 0x9005, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffe, 0x0020,
+	0x6878, 0x700a, 0x687c, 0x700e, 0x0000, 0x9485, 0x0098, 0x7012,
+	0x004e, 0x003e, 0x00de, 0x080c, 0x9389, 0x721a, 0x7a08, 0x7222,
+	0x2f10, 0x7226, 0x2071, 0x024c, 0x002e, 0x0005, 0x080c, 0x9389,
+	0x721a, 0x7a08, 0x7222, 0x7814, 0x7026, 0x2071, 0x024c, 0x002e,
+	0x0005, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2069, 0x0200,
+	0x2071, 0x0240, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0db4, 0x908a,
+	0x0092, 0x1a0c, 0x0db4, 0x6110, 0x2158, 0xb9b0, 0x2c78, 0x2061,
+	0x0100, 0x619a, 0x9082, 0x0085, 0x0033, 0x00fe, 0x00ee, 0x00de,
+	0x00ce, 0x00be, 0x0005, 0x8f62, 0x8f71, 0x8f7c, 0x8f60, 0x8f60,
+	0x8f60, 0x8f62, 0x8f60, 0x8f60, 0x8f60, 0x8f60, 0x8f60, 0x8f60,
+	0x080c, 0x0db4, 0x0411, 0x60c3, 0x0000, 0x0026, 0x080c, 0x29d7,
+	0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012, 0x002e, 0x0804,
+	0x939b, 0x0431, 0x7808, 0x700a, 0x7814, 0x700e, 0x7017, 0xffff,
+	0x60c3, 0x000c, 0x0804, 0x939b, 0x0479, 0x7003, 0x0003, 0x7007,
+	0x0300, 0x60c3, 0x0004, 0x0804, 0x939b, 0x0026, 0x080c, 0x9c37,
+	0xb810, 0x9085, 0x8100, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800,
+	0x6878, 0x700a, 0x687c, 0x700e, 0x7013, 0x0009, 0x0804, 0x8ec4,
+	0x0026, 0x080c, 0x9c37, 0xb810, 0x9085, 0x8400, 0x7002, 0xb814,
+	0x7006, 0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x2001,
+	0x0099, 0x7012, 0x0804, 0x8f26, 0x0026, 0x080c, 0x9c37, 0xb810,
+	0x9085, 0x8500, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6878,
+	0x700a, 0x687c, 0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x8f26,
+	0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2c78, 0x2069, 0x0200,
+	0x2071, 0x0240, 0x7804, 0x908a, 0x0040, 0x0a0c, 0x0db4, 0x908a,
+	0x0054, 0x1a0c, 0x0db4, 0x7910, 0x2158, 0xb9b0, 0x2061, 0x0100,
+	0x619a, 0x9082, 0x0040, 0x0033, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x00be, 0x0005, 0x8ff7, 0x90b3, 0x9086, 0x91d5, 0x8ff5, 0x8ff5,
+	0x8ff5, 0x8ff5, 0x8ff5, 0x8ff5, 0x8ff5, 0x9777, 0x977f, 0x9787,
+	0x978f, 0x8ff5, 0x9b7f, 0x8ff5, 0x976f, 0x080c, 0x0db4, 0x0096,
+	0x780b, 0xffff, 0x080c, 0x9062, 0x7914, 0x2148, 0xa978, 0x7956,
+	0xae64, 0x96b4, 0x00ff, 0x9686, 0x0008, 0x1148, 0xa8b4, 0x7032,
+	0xa8b8, 0x7036, 0xa8bc, 0x703a, 0xa8c0, 0x703e, 0x0008, 0x7132,
+	0xa97c, 0x9184, 0x000f, 0x1118, 0x2001, 0x0005, 0x0040, 0xd184,
+	0x0118, 0x2001, 0x0004, 0x0018, 0x9084, 0x0006, 0x8004, 0x2010,
+	0x785c, 0x9084, 0x00ff, 0x8007, 0x9205, 0x7042, 0xd1ac, 0x0158,
+	0x7047, 0x0002, 0x9686, 0x0008, 0x1118, 0x080c, 0x1789, 0x0010,
+	0x080c, 0x164a, 0x0050, 0xd1b4, 0x0118, 0x7047, 0x0001, 0x0028,
+	0x7047, 0x0000, 0x9016, 0x2230, 0x0010, 0xaab0, 0xaeac, 0x726a,
+	0x766e, 0x20a9, 0x0008, 0x20e9, 0x0000, 0xa860, 0x20e0, 0xa85c,
+	0x9080, 0x0023, 0x2098, 0x20a1, 0x0252, 0x2069, 0x0200, 0x6813,
+	0x0018, 0x4003, 0x6813, 0x0008, 0x60c3, 0x0020, 0x6017, 0x0009,
+	0x2001, 0x19db, 0x2003, 0x07d0, 0x2001, 0x19da, 0x2003, 0x0009,
+	0x009e, 0x0005, 0x6813, 0x0008, 0xba8c, 0x8210, 0xb8bc, 0xd084,
+	0x0128, 0x7a46, 0x7b14, 0x7b4a, 0x722e, 0x732a, 0x9294, 0x00ff,
+	0xba8e, 0x8217, 0x721a, 0xba10, 0x9295, 0x0600, 0x7202, 0xba14,
+	0x7206, 0x2069, 0x1800, 0x6a78, 0x720a, 0x6a7c, 0x720e, 0x7013,
+	0x0829, 0x2f10, 0x7222, 0x7027, 0xffff, 0x0005, 0x00d6, 0x0096,
+	0x0081, 0x7814, 0x2048, 0xa890, 0x7002, 0xa88c, 0x7006, 0xa8b0,
+	0x700a, 0xa8ac, 0x700e, 0x60c3, 0x000c, 0x009e, 0x00de, 0x0804,
+	0x939b, 0x6813, 0x0008, 0xb810, 0x9085, 0x0500, 0x7002, 0xb814,
+	0x7006, 0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x7013,
+	0x0889, 0x080c, 0x9389, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226,
+	0x2071, 0x024c, 0x0005, 0x00d6, 0x0096, 0x080c, 0x91b3, 0x7814,
+	0x2048, 0x080c, 0xbb39, 0x1130, 0x7814, 0x9084, 0x0700, 0x8007,
+	0x0033, 0x0010, 0x9006, 0x001b, 0x009e, 0x00de, 0x0005, 0x90d1,
+	0x913a, 0x914a, 0x9170, 0x917c, 0x918d, 0x9195, 0x90cf, 0x080c,
+	0x0db4, 0x0016, 0x0036, 0xa97c, 0x918c, 0x0003, 0x0118, 0x9186,
+	0x0003, 0x1198, 0xaba8, 0x7824, 0xd0cc, 0x1168, 0x7316, 0xa898,
+	0x701a, 0xa894, 0x701e, 0x003e, 0x001e, 0x2001, 0x1989, 0x2004,
+	0x60c2, 0x0804, 0x939b, 0xc3e5, 0x0c88, 0x9186, 0x0001, 0x190c,
+	0x0db4, 0xaba8, 0x7824, 0xd0cc, 0x1904, 0x9137, 0x7316, 0xa898,
+	0x701a, 0xa894, 0x701e, 0xa8a4, 0x7026, 0xa8ac, 0x702e, 0x2009,
+	0x0018, 0x9384, 0x0300, 0x0570, 0xd3c4, 0x0110, 0xa8ac, 0x9108,
+	0xd3cc, 0x0110, 0xa8a4, 0x9108, 0x6810, 0x9085, 0x0010, 0x6812,
+	0x2011, 0x0258, 0x20e9, 0x0000, 0x22a0, 0x0156, 0x20a9, 0x0008,
+	0xa860, 0x20e0, 0xa85c, 0x9080, 0x002c, 0x2098, 0x4003, 0x6810,
+	0x8000, 0x6812, 0x2011, 0x0240, 0x22a0, 0x20a9, 0x0005, 0x4003,
+	0x6810, 0xc084, 0x6812, 0x015e, 0x9184, 0x0003, 0x0118, 0x2019,
+	0x0245, 0x201a, 0x61c2, 0x003e, 0x001e, 0x0804, 0x939b, 0xc3e5,
+	0x0804, 0x90f6, 0x2011, 0x0008, 0x2001, 0x180f, 0x2004, 0xd0a4,
+	0x0110, 0x2011, 0x0028, 0x7824, 0xd0cc, 0x1110, 0x7216, 0x0470,
+	0x0ce8, 0xc2e5, 0x2011, 0x0302, 0x0016, 0x782c, 0x701a, 0x7930,
+	0x711e, 0x9105, 0x0108, 0xc2dd, 0x001e, 0x7824, 0xd0cc, 0x0108,
+	0xc2e5, 0x7216, 0x7027, 0x0012, 0x702f, 0x0008, 0x7043, 0x7000,
+	0x7047, 0x0500, 0x704f, 0x000a, 0x2069, 0x0200, 0x6813, 0x0009,
+	0x2071, 0x0240, 0x700b, 0x2500, 0x60c3, 0x0032, 0x0804, 0x939b,
+	0x2011, 0x0028, 0x7824, 0xd0cc, 0x1128, 0x7216, 0x60c3, 0x0018,
+	0x0804, 0x939b, 0x0cd0, 0xc2e5, 0x2011, 0x0100, 0x7824, 0xd0cc,
+	0x0108, 0xc2e5, 0x7216, 0x702f, 0x0008, 0x7858, 0x9084, 0x00ff,
+	0x7036, 0x60c3, 0x0020, 0x0804, 0x939b, 0x2011, 0x0008, 0x7824,
+	0xd0cc, 0x0108, 0xc2e5, 0x7216, 0x0c08, 0x0036, 0x7b14, 0x9384,
+	0xff00, 0x7816, 0x9384, 0x00ff, 0x8001, 0x1138, 0x7824, 0xd0cc,
+	0x0108, 0xc2e5, 0x7216, 0x003e, 0x0888, 0x0046, 0x2021, 0x0800,
+	0x0006, 0x7824, 0xd0cc, 0x000e, 0x0108, 0xc4e5, 0x7416, 0x004e,
+	0x701e, 0x003e, 0x0818, 0x00d6, 0x6813, 0x0008, 0xb810, 0x9085,
+	0x0700, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6878, 0x700a,
+	0x687c, 0x700e, 0x7824, 0xd0cc, 0x1168, 0x7013, 0x0898, 0x080c,
+	0x9389, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c,
+	0x00de, 0x0005, 0x7013, 0x0889, 0x0c90, 0x0016, 0x7814, 0x9084,
+	0x0700, 0x8007, 0x0013, 0x001e, 0x0005, 0x91e5, 0x91e5, 0x91e7,
+	0x91e5, 0x91e5, 0x91e5, 0x9201, 0x91e5, 0x080c, 0x0db4, 0x7914,
+	0x918c, 0x08ff, 0x918d, 0xf600, 0x7916, 0x2009, 0x0003, 0x00b9,
+	0x2069, 0x185b, 0x6804, 0xd0bc, 0x0130, 0x682c, 0x9084, 0x00ff,
+	0x8007, 0x7032, 0x0010, 0x7033, 0x3f00, 0x60c3, 0x0001, 0x0804,
+	0x939b, 0x2009, 0x0003, 0x0019, 0x7033, 0x7f00, 0x0cb0, 0x0016,
+	0x080c, 0x9c37, 0x001e, 0xb810, 0x9085, 0x0100, 0x7002, 0xb814,
+	0x7006, 0x2069, 0x1800, 0x6a78, 0x720a, 0x6a7c, 0x720e, 0x7013,
+	0x0888, 0x918d, 0x0008, 0x7116, 0x080c, 0x9389, 0x721a, 0x7a08,
+	0x7222, 0x2f10, 0x7226, 0x0005, 0x00b6, 0x0096, 0x00e6, 0x00d6,
+	0x00c6, 0x0056, 0x0046, 0x0036, 0x2061, 0x0100, 0x2071, 0x1800,
+	0x7810, 0x2058, 0xb8a0, 0x2028, 0xb910, 0xba14, 0x7378, 0x747c,
+	0x7820, 0x90be, 0x0006, 0x0904, 0x92f8, 0x90be, 0x000a, 0x1904,
+	0x92b4, 0xb8b0, 0x609e, 0x7814, 0x2048, 0xa87c, 0xd0fc, 0x0558,
+	0xaf90, 0x9784, 0xff00, 0x9105, 0x6062, 0x873f, 0x9784, 0xff00,
+	0x0006, 0x7814, 0x2048, 0xa878, 0xc0fc, 0x9005, 0x000e, 0x1160,
+	0xaf94, 0x87ff, 0x0198, 0x2039, 0x0098, 0x9705, 0x6072, 0x7808,
+	0x6082, 0x2f00, 0x6086, 0x0038, 0x9185, 0x2200, 0x6062, 0x6073,
+	0x0129, 0x6077, 0x0000, 0xb8b0, 0x609e, 0x0050, 0x2039, 0x0029,
+	0x9705, 0x6072, 0x0cc0, 0x9185, 0x0200, 0x6062, 0x6073, 0x2029,
+	0xa87c, 0xd0fc, 0x0118, 0xaf94, 0x87ff, 0x1120, 0x2f00, 0x6082,
+	0x7808, 0x6086, 0x6266, 0x636a, 0x646e, 0x6077, 0x0000, 0xb88c,
+	0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000,
+	0xa838, 0x608a, 0xa834, 0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca,
+	0xb86c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0x080c, 0x9c1c,
+	0x2009, 0x07d0, 0x60c4, 0x9084, 0xfff0, 0x9005, 0x0110, 0x2009,
+	0x1b58, 0x080c, 0x80c4, 0x003e, 0x004e, 0x005e, 0x00ce, 0x00de,
+	0x00ee, 0x009e, 0x00be, 0x0005, 0x7804, 0x9086, 0x0040, 0x0904,
+	0x9334, 0x9185, 0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073,
+	0x0809, 0x6077, 0x0008, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xb88c,
 	0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000,
-	0x2f00, 0x6086, 0x7808, 0x6082, 0xa838, 0x608a, 0xa834, 0x608e,
-	0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce, 0x60af, 0x95d5,
-	0x60d7, 0x0000, 0xbab0, 0x629e, 0x7824, 0xd0cc, 0x0120, 0x080c,
-	0x9c2f, 0x0804, 0x92ca, 0x080c, 0x9c0c, 0x0804, 0x92ca, 0x7a10,
-	0x00b6, 0x2258, 0xba8c, 0x8210, 0x9294, 0x00ff, 0xba8e, 0x00be,
-	0x8217, 0x0005, 0x00d6, 0x2069, 0x19b7, 0x6843, 0x0001, 0x00de,
-	0x0005, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x00f1, 0x080c, 0x8098,
-	0x0005, 0x0016, 0x2001, 0x180c, 0x200c, 0x9184, 0x0600, 0x9086,
-	0x0600, 0x0128, 0x0089, 0x080c, 0x8098, 0x001e, 0x0005, 0xc1e5,
-	0x2001, 0x180c, 0x2102, 0x2001, 0x19b8, 0x2003, 0x0000, 0x2001,
-	0x19c0, 0x2003, 0x0000, 0x0c88, 0x0006, 0x6014, 0x9084, 0x1804,
-	0x9085, 0x0009, 0x6016, 0x000e, 0x0005, 0x0016, 0x00c6, 0x0006,
-	0x2061, 0x0100, 0x61a4, 0x60a7, 0x95f5, 0x6014, 0x9084, 0x1804,
-	0x9085, 0x0008, 0x6016, 0x000e, 0xa001, 0xa001, 0xa001, 0x61a6,
-	0x00ce, 0x001e, 0x0005, 0x00c6, 0x00d6, 0x0016, 0x0026, 0x2061,
-	0x0100, 0x2069, 0x0140, 0x080c, 0x6f9b, 0x11e8, 0x2001, 0x19d3,
-	0x2004, 0x9005, 0x1904, 0x9413, 0x0066, 0x2031, 0x0001, 0x080c,
-	0x704b, 0x006e, 0x1160, 0x2061, 0x0100, 0x6020, 0xd0b4, 0x1120,
-	0x6024, 0xd084, 0x090c, 0x0db4, 0x080c, 0x8098, 0x0460, 0x00c6,
-	0x2061, 0x19b7, 0x00d0, 0x6904, 0x9194, 0x4000, 0x0548, 0x080c,
-	0x93ad, 0x080c, 0x2b26, 0x00c6, 0x2061, 0x19b7, 0x6128, 0x9192,
-	0x0008, 0x1258, 0x8108, 0x612a, 0x6124, 0x00ce, 0x81ff, 0x0198,
-	0x080c, 0x8098, 0x080c, 0x93a4, 0x0070, 0x6124, 0x91e5, 0x0000,
-	0x0140, 0x080c, 0xd8ea, 0x080c, 0x80a1, 0x2009, 0x0014, 0x080c,
-	0x9ebc, 0x00ce, 0x0000, 0x002e, 0x001e, 0x00de, 0x00ce, 0x0005,
-	0x2001, 0x19d3, 0x2004, 0x9005, 0x1db0, 0x00c6, 0x2061, 0x19b7,
-	0x6128, 0x9192, 0x0003, 0x1e08, 0x8108, 0x612a, 0x00ce, 0x080c,
-	0x8098, 0x080c, 0x5b99, 0x2009, 0x1852, 0x2114, 0x8210, 0x220a,
-	0x0c10, 0x0096, 0x00c6, 0x00d6, 0x00e6, 0x0016, 0x0026, 0x080c,
-	0x80ae, 0x2071, 0x19b7, 0x713c, 0x81ff, 0x0904, 0x94a3, 0x2061,
-	0x0100, 0x2069, 0x0140, 0x080c, 0x6f9b, 0x11b0, 0x0036, 0x2019,
-	0x0002, 0x080c, 0x96d9, 0x003e, 0x713c, 0x2160, 0x080c, 0xd8ea,
-	0x2009, 0x004a, 0x080c, 0x9ebc, 0x0066, 0x2031, 0x0001, 0x080c,
-	0x704b, 0x006e, 0x0804, 0x94a3, 0x080c, 0x94af, 0x0904, 0x94a3,
-	0x6904, 0xd1f4, 0x0904, 0x94aa, 0x080c, 0x2b26, 0x00c6, 0x703c,
+	0x2f00, 0x6082, 0x7808, 0x6086, 0x7814, 0x2048, 0xa838, 0x608a,
+	0xa834, 0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce,
+	0xbab0, 0x629e, 0x080c, 0x9c1c, 0x2009, 0x07d0, 0x60c4, 0x9084,
+	0xfff0, 0x9005, 0x0110, 0x2009, 0x1b58, 0x080c, 0x80c4, 0x003e,
+	0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x009e, 0x00be, 0x0005,
+	0x7814, 0x2048, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x0904,
+	0x9350, 0x9185, 0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073,
+	0x0880, 0x6077, 0x0008, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e,
+	0x8007, 0x607a, 0x7838, 0x607e, 0x2f00, 0x6086, 0x7808, 0x6082,
+	0xa890, 0x608a, 0xa88c, 0x608e, 0xa8b0, 0x60c6, 0xa8ac, 0x60ca,
+	0xa8ac, 0x7930, 0x9108, 0x7932, 0xa8b0, 0x792c, 0x9109, 0x792e,
+	0xb86c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xbab0, 0x629e,
+	0x080c, 0x9bf9, 0x0804, 0x92e4, 0xb8bc, 0xd084, 0x0148, 0xb88c,
+	0x7814, 0x2048, 0xb88c, 0x7846, 0xa836, 0x2900, 0xa83a, 0xb04a,
+	0x9185, 0x0600, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073, 0x0829,
+	0x6077, 0x0000, 0x60af, 0x9575, 0x60d7, 0x0000, 0x0804, 0x92c7,
+	0x9185, 0x0700, 0x6062, 0x6266, 0x636a, 0x646e, 0x7824, 0xd0cc,
+	0x7826, 0x0118, 0x6073, 0x0889, 0x0010, 0x6073, 0x0898, 0x6077,
+	0x0000, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a,
+	0x607f, 0x0000, 0x2f00, 0x6086, 0x7808, 0x6082, 0xa838, 0x608a,
+	0xa834, 0x608e, 0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce,
+	0x60af, 0x95d5, 0x60d7, 0x0000, 0xbab0, 0x629e, 0x7824, 0xd0cc,
+	0x0120, 0x080c, 0x9c1c, 0x0804, 0x92e4, 0x080c, 0x9bf9, 0x0804,
+	0x92e4, 0x7a10, 0x00b6, 0x2258, 0xba8c, 0x8210, 0x9294, 0x00ff,
+	0xba8e, 0x00be, 0x8217, 0x0005, 0x00d6, 0x2069, 0x19bf, 0x6843,
+	0x0001, 0x00de, 0x0005, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x00f1,
+	0x080c, 0x80b6, 0x0005, 0x0016, 0x2001, 0x180c, 0x200c, 0x9184,
+	0x0600, 0x9086, 0x0600, 0x0128, 0x0089, 0x080c, 0x80b6, 0x001e,
+	0x0005, 0xc1e5, 0x2001, 0x180c, 0x2102, 0x2001, 0x19c0, 0x2003,
+	0x0000, 0x2001, 0x19c8, 0x2003, 0x0000, 0x0c88, 0x0006, 0x6014,
+	0x9084, 0x1804, 0x9085, 0x0009, 0x6016, 0x000e, 0x0005, 0x0016,
+	0x00c6, 0x0006, 0x2061, 0x0100, 0x61a4, 0x60a7, 0x95f5, 0x6014,
+	0x9084, 0x1804, 0x9085, 0x0008, 0x6016, 0x000e, 0xa001, 0xa001,
+	0xa001, 0x61a6, 0x00ce, 0x001e, 0x0005, 0x00c6, 0x00d6, 0x0016,
+	0x0026, 0x2061, 0x0100, 0x2069, 0x0140, 0x080c, 0x6faa, 0x11c0,
+	0x2001, 0x19db, 0x2004, 0x9005, 0x15d0, 0x080c, 0x705a, 0x1160,
+	0x2061, 0x0100, 0x6020, 0xd0b4, 0x1120, 0x6024, 0xd084, 0x090c,
+	0x0db4, 0x080c, 0x80b6, 0x0458, 0x00c6, 0x2061, 0x19bf, 0x00c8,
+	0x6904, 0x9194, 0x4000, 0x0540, 0x0811, 0x080c, 0x2b31, 0x00c6,
+	0x2061, 0x19bf, 0x6128, 0x9192, 0x0008, 0x1258, 0x8108, 0x612a,
+	0x6124, 0x00ce, 0x81ff, 0x0198, 0x080c, 0x80b6, 0x080c, 0x93be,
+	0x0070, 0x6124, 0x91e5, 0x0000, 0x0140, 0x080c, 0xd903, 0x080c,
+	0x80bf, 0x2009, 0x0014, 0x080c, 0x9ea9, 0x00ce, 0x0000, 0x002e,
+	0x001e, 0x00de, 0x00ce, 0x0005, 0x2001, 0x19db, 0x2004, 0x9005,
+	0x1db0, 0x00c6, 0x2061, 0x19bf, 0x6128, 0x9192, 0x0003, 0x1e08,
+	0x8108, 0x612a, 0x00ce, 0x080c, 0x80b6, 0x080c, 0x5ba4, 0x2009,
+	0x185a, 0x2114, 0x8210, 0x220a, 0x0c10, 0x0096, 0x00c6, 0x00d6,
+	0x00e6, 0x0016, 0x0026, 0x080c, 0x80cc, 0x2071, 0x19bf, 0x713c,
+	0x81ff, 0x0904, 0x94b3, 0x2061, 0x0100, 0x2069, 0x0140, 0x080c,
+	0x6faa, 0x1190, 0x0036, 0x2019, 0x0002, 0x080c, 0x96e9, 0x003e,
+	0x713c, 0x2160, 0x080c, 0xd903, 0x2009, 0x004a, 0x080c, 0x9ea9,
+	0x080c, 0x705a, 0x0804, 0x94b3, 0x080c, 0x94bf, 0x0904, 0x94b3,
+	0x6904, 0xd1f4, 0x0904, 0x94ba, 0x080c, 0x2b31, 0x00c6, 0x703c,
 	0x9065, 0x090c, 0x0db4, 0x6020, 0x00ce, 0x9086, 0x0006, 0x1528,
 	0x61c8, 0x60c4, 0x9105, 0x1508, 0x2009, 0x180c, 0x2104, 0xd0d4,
 	0x01e0, 0x6214, 0x9294, 0x1800, 0x1128, 0x6224, 0x9294, 0x0002,
-	0x1510, 0x0030, 0xc0d4, 0x200a, 0xd0cc, 0x0110, 0x080c, 0x2a79,
+	0x1510, 0x0030, 0xc0d4, 0x200a, 0xd0cc, 0x0110, 0x080c, 0x2a84,
 	0x6014, 0x9084, 0xe7fd, 0x9085, 0x0010, 0x6016, 0x703c, 0x2060,
-	0x2009, 0x0049, 0x080c, 0x9ebc, 0x0070, 0x0036, 0x2019, 0x0001,
-	0x080c, 0x96d9, 0x003e, 0x713c, 0x2160, 0x080c, 0xd8ea, 0x2009,
-	0x004a, 0x080c, 0x9ebc, 0x002e, 0x001e, 0x00ee, 0x00de, 0x00ce,
-	0x009e, 0x0005, 0xd1ec, 0x1904, 0x9464, 0x0804, 0x9466, 0x00d6,
+	0x2009, 0x0049, 0x080c, 0x9ea9, 0x0070, 0x0036, 0x2019, 0x0001,
+	0x080c, 0x96e9, 0x003e, 0x713c, 0x2160, 0x080c, 0xd903, 0x2009,
+	0x004a, 0x080c, 0x9ea9, 0x002e, 0x001e, 0x00ee, 0x00de, 0x00ce,
+	0x009e, 0x0005, 0xd1ec, 0x1904, 0x9474, 0x0804, 0x9476, 0x00d6,
 	0x00c6, 0x0096, 0x703c, 0x9065, 0x090c, 0x0db4, 0x2001, 0x1836,
-	0x2004, 0xd09c, 0x1904, 0x953b, 0x2001, 0x0306, 0x200c, 0x9184,
-	0x0030, 0x0904, 0x953b, 0x9184, 0x0048, 0x9086, 0x0008, 0x1904,
-	0x953b, 0x2001, 0x020b, 0x2004, 0xd0fc, 0x0904, 0x953b, 0xd08c,
-	0x0904, 0x953b, 0x2009, 0x1a4f, 0x2104, 0x8000, 0x0208, 0x200a,
+	0x2004, 0xd09c, 0x1904, 0x954b, 0x2001, 0x0306, 0x200c, 0x9184,
+	0x0030, 0x0904, 0x954b, 0x9184, 0x0048, 0x9086, 0x0008, 0x1904,
+	0x954b, 0x2001, 0x020b, 0x2004, 0xd0fc, 0x0904, 0x954b, 0xd08c,
+	0x0904, 0x954b, 0x2009, 0x1a57, 0x2104, 0x8000, 0x0208, 0x200a,
 	0x2069, 0x0100, 0x6914, 0x918c, 0x0184, 0x918d, 0x0010, 0x6916,
 	0x69c8, 0x2011, 0x0020, 0x68c8, 0x9106, 0x1570, 0x8211, 0x1dd8,
 	0x2001, 0x0306, 0x2003, 0x4800, 0x2001, 0x009a, 0x2003, 0x0004,
-	0x2001, 0x1a35, 0x2003, 0x0000, 0x2001, 0x1a3e, 0x2003, 0x0000,
-	0x6a88, 0x698c, 0x2200, 0x9105, 0x1120, 0x2c10, 0x080c, 0x1a5e,
+	0x2001, 0x1a3d, 0x2003, 0x0000, 0x2001, 0x1a46, 0x2003, 0x0000,
+	0x6a88, 0x698c, 0x2200, 0x9105, 0x1120, 0x2c10, 0x080c, 0x1a69,
 	0x0040, 0x6014, 0x2048, 0xaa3a, 0xa936, 0x6ac4, 0x69c8, 0xa946,
-	0xaa4a, 0x0126, 0x00c6, 0x2091, 0x2400, 0x002e, 0x080c, 0x1aea,
-	0x190c, 0x0db4, 0x012e, 0x0090, 0x2009, 0x1a50, 0x2104, 0x8000,
+	0xaa4a, 0x0126, 0x00c6, 0x2091, 0x2400, 0x002e, 0x080c, 0x1af5,
+	0x190c, 0x0db4, 0x012e, 0x0090, 0x2009, 0x1a58, 0x2104, 0x8000,
 	0x0208, 0x200a, 0x69c8, 0x2011, 0x0020, 0x8211, 0x1df0, 0x68c8,
 	0x9106, 0x1dc0, 0x69c4, 0x68c8, 0x9105, 0x0160, 0x6824, 0xd08c,
 	0x0110, 0x6827, 0x0002, 0x7048, 0xc085, 0x704a, 0x0079, 0x7048,
-	0xc084, 0x704a, 0x2009, 0x07d0, 0x080c, 0x80a6, 0x9006, 0x009e,
+	0xc084, 0x704a, 0x2009, 0x07d0, 0x080c, 0x80c4, 0x9006, 0x009e,
 	0x00ce, 0x00de, 0x0005, 0x9085, 0x0001, 0x0cc8, 0x0026, 0x00e6,
-	0x2071, 0x19b7, 0x7048, 0xd084, 0x01c0, 0x713c, 0x81ff, 0x01a8,
+	0x2071, 0x19bf, 0x7048, 0xd084, 0x01c0, 0x713c, 0x81ff, 0x01a8,
 	0x2071, 0x0100, 0x9188, 0x0008, 0x2114, 0x928e, 0x0006, 0x1138,
 	0x7014, 0x9084, 0x1984, 0x9085, 0x0012, 0x7016, 0x0030, 0x7014,
 	0x9084, 0x1984, 0x9085, 0x0016, 0x7016, 0x00ee, 0x002e, 0x0005,
 	0x00b6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0056, 0x0046, 0x0006,
-	0x0126, 0x2091, 0x8000, 0x6010, 0x2058, 0xbca0, 0x2071, 0x19b7,
+	0x0126, 0x2091, 0x8000, 0x6010, 0x2058, 0xbca0, 0x2071, 0x19bf,
 	0x7018, 0x2058, 0x8bff, 0x0190, 0xb8a0, 0x9406, 0x0118, 0xb854,
 	0x2058, 0x0cc0, 0x6014, 0x0096, 0x2048, 0xac6c, 0xad70, 0xae78,
-	0x009e, 0x080c, 0x6379, 0x0110, 0x9085, 0x0001, 0x012e, 0x000e,
+	0x009e, 0x080c, 0x6388, 0x0110, 0x9085, 0x0001, 0x012e, 0x000e,
 	0x004e, 0x005e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00be, 0x0005,
-	0x080c, 0x8e8f, 0x7003, 0x1200, 0x7838, 0x7012, 0x783c, 0x7016,
+	0x080c, 0x8ea9, 0x7003, 0x1200, 0x7838, 0x7012, 0x783c, 0x7016,
 	0x00c6, 0x7820, 0x9086, 0x0004, 0x1148, 0x7810, 0x9005, 0x0130,
 	0x00b6, 0x2058, 0xb810, 0xb914, 0x00be, 0x0020, 0x2061, 0x1800,
 	0x6078, 0x617c, 0x9084, 0x00ff, 0x700a, 0x710e, 0x00ce, 0x60c3,
-	0x002c, 0x0804, 0x9381, 0x080c, 0x8e8f, 0x7003, 0x0f00, 0x7808,
+	0x002c, 0x0804, 0x939b, 0x080c, 0x8ea9, 0x7003, 0x0f00, 0x7808,
 	0xd09c, 0x0128, 0xb810, 0x9084, 0x00ff, 0x700a, 0xb814, 0x700e,
-	0x60c3, 0x0008, 0x0804, 0x9381, 0x0156, 0x080c, 0x8eda, 0x7003,
+	0x60c3, 0x0008, 0x0804, 0x939b, 0x0156, 0x080c, 0x8ef4, 0x7003,
 	0x0200, 0x2011, 0x1848, 0x63f0, 0x2312, 0x20a9, 0x0006, 0x2011,
 	0x1840, 0x2019, 0x1841, 0x9ef0, 0x0002, 0x2376, 0x8e70, 0x2276,
-	0x8e70, 0x9398, 0x0002, 0x9290, 0x0002, 0x1f04, 0x95d5, 0x60c3,
-	0x001c, 0x015e, 0x0804, 0x9381, 0x0016, 0x0026, 0x080c, 0x8eb6,
-	0x080c, 0x8ec8, 0x9e80, 0x0004, 0x20e9, 0x0000, 0x20a0, 0x7814,
+	0x8e70, 0x9398, 0x0002, 0x9290, 0x0002, 0x1f04, 0x95e5, 0x60c3,
+	0x001c, 0x015e, 0x0804, 0x939b, 0x0016, 0x0026, 0x080c, 0x8ed0,
+	0x080c, 0x8ee2, 0x9e80, 0x0004, 0x20e9, 0x0000, 0x20a0, 0x7814,
 	0x0096, 0x2048, 0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080,
 	0x0021, 0x2098, 0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x9192,
 	0x0010, 0x1250, 0x4003, 0x9080, 0x0004, 0x8003, 0x60c2, 0x080c,
-	0x9381, 0x002e, 0x001e, 0x0005, 0x20a9, 0x0010, 0x4003, 0x080c,
-	0x9c35, 0x20a1, 0x0240, 0x22a8, 0x4003, 0x0c68, 0x080c, 0x8e8f,
-	0x7003, 0x6200, 0x7808, 0x700e, 0x60c3, 0x0008, 0x0804, 0x9381,
-	0x0016, 0x0026, 0x080c, 0x8e8f, 0x20e9, 0x0000, 0x20a1, 0x024c,
+	0x939b, 0x002e, 0x001e, 0x0005, 0x20a9, 0x0010, 0x4003, 0x080c,
+	0x9c22, 0x20a1, 0x0240, 0x22a8, 0x4003, 0x0c68, 0x080c, 0x8ea9,
+	0x7003, 0x6200, 0x7808, 0x700e, 0x60c3, 0x0008, 0x0804, 0x939b,
+	0x0016, 0x0026, 0x080c, 0x8ea9, 0x20e9, 0x0000, 0x20a1, 0x024c,
 	0x7814, 0x0096, 0x2048, 0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c,
 	0x9080, 0x0023, 0x2098, 0x009e, 0x7808, 0x9088, 0x0002, 0x21a8,
-	0x4003, 0x8003, 0x60c2, 0x080c, 0x9381, 0x002e, 0x001e, 0x0005,
-	0x00e6, 0x00c6, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19b7,
-	0x700c, 0x2060, 0x8cff, 0x0178, 0x080c, 0xbd32, 0x1110, 0x080c,
-	0xa7d1, 0x600c, 0x0006, 0x080c, 0xbf9e, 0x080c, 0x9e42, 0x080c,
-	0x97b1, 0x00ce, 0x0c78, 0x2c00, 0x700e, 0x700a, 0x012e, 0x000e,
+	0x4003, 0x8003, 0x60c2, 0x080c, 0x939b, 0x002e, 0x001e, 0x0005,
+	0x00e6, 0x00c6, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19bf,
+	0x700c, 0x2060, 0x8cff, 0x0178, 0x080c, 0xbd41, 0x1110, 0x080c,
+	0xa7cd, 0x600c, 0x0006, 0x080c, 0xbfad, 0x080c, 0x9e2f, 0x080c,
+	0x979a, 0x00ce, 0x0c78, 0x2c00, 0x700e, 0x700a, 0x012e, 0x000e,
 	0x00ce, 0x00ee, 0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6,
 	0x00c6, 0x0066, 0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001,
 	0x180c, 0x200c, 0x918c, 0xe7ff, 0x2102, 0x2069, 0x0100, 0x2079,
-	0x0140, 0x2071, 0x19b7, 0x7024, 0x2060, 0x8cff, 0x01f8, 0x080c,
-	0x93ad, 0x6ac0, 0x68c3, 0x0000, 0x080c, 0x80a1, 0x00c6, 0x2061,
-	0x0100, 0x080c, 0x9c4e, 0x00ce, 0x20a9, 0x01f4, 0x0461, 0x2009,
-	0x0013, 0x080c, 0x9ebc, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce,
+	0x0140, 0x2071, 0x19bf, 0x7024, 0x2060, 0x8cff, 0x01f8, 0x080c,
+	0x93c7, 0x6ac0, 0x68c3, 0x0000, 0x080c, 0x80bf, 0x00c6, 0x2061,
+	0x0100, 0x080c, 0x9c3b, 0x00ce, 0x20a9, 0x01f4, 0x0461, 0x2009,
+	0x0013, 0x080c, 0x9ea9, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce,
 	0x00de, 0x00ee, 0x00fe, 0x015e, 0x012e, 0x0005, 0x2001, 0x1800,
 	0x2004, 0x9096, 0x0001, 0x0d78, 0x9096, 0x0004, 0x0d60, 0x080c,
-	0x80a1, 0x6814, 0x9084, 0x0001, 0x0110, 0x68a7, 0x95f5, 0x6817,
-	0x0008, 0x68c3, 0x0000, 0x2011, 0x5b43, 0x080c, 0x8021, 0x20a9,
+	0x80bf, 0x6814, 0x9084, 0x0001, 0x0110, 0x68a7, 0x95f5, 0x6817,
+	0x0008, 0x68c3, 0x0000, 0x2011, 0x5b4e, 0x080c, 0x803f, 0x20a9,
 	0x01f4, 0x0009, 0x08c0, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004,
-	0x7804, 0x9084, 0x4000, 0x190c, 0x2b26, 0x0090, 0xd084, 0x0118,
-	0x6827, 0x0001, 0x0010, 0x1f04, 0x96bb, 0x7804, 0x9084, 0x1000,
-	0x0138, 0x2001, 0x0100, 0x080c, 0x2b16, 0x9006, 0x080c, 0x2b16,
+	0x7804, 0x9084, 0x4000, 0x190c, 0x2b31, 0x0090, 0xd084, 0x0118,
+	0x6827, 0x0001, 0x0010, 0x1f04, 0x96cb, 0x7804, 0x9084, 0x1000,
+	0x0138, 0x2001, 0x0100, 0x080c, 0x2b21, 0x9006, 0x080c, 0x2b21,
 	0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066,
 	0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001, 0x180c, 0x200c,
 	0x918c, 0xdbff, 0x2102, 0x2069, 0x0100, 0x2079, 0x0140, 0x2071,
-	0x19b7, 0x703c, 0x2060, 0x8cff, 0x0904, 0x9767, 0x9386, 0x0002,
-	0x1128, 0x6814, 0x9084, 0x0002, 0x0904, 0x9767, 0x68af, 0x95f5,
+	0x19bf, 0x703c, 0x2060, 0x8cff, 0x0904, 0x9750, 0x9386, 0x0002,
+	0x1128, 0x6814, 0x9084, 0x0002, 0x0904, 0x9750, 0x68af, 0x95f5,
 	0x6817, 0x0010, 0x2009, 0x00fa, 0x8109, 0x1df0, 0x69c6, 0x68cb,
-	0x0008, 0x080c, 0x80ae, 0x080c, 0x1e92, 0x0046, 0x2009, 0x00a5,
-	0x080c, 0x0e2f, 0x2021, 0x0169, 0x2404, 0x9084, 0x000f, 0x9086,
-	0x0004, 0x11f8, 0x68af, 0x95f5, 0x68c6, 0x68cb, 0x0008, 0x00e6,
-	0x00f6, 0x2079, 0x0090, 0x2071, 0x1a35, 0x6814, 0x9084, 0x1984,
-	0x9085, 0x0012, 0x6816, 0x782b, 0x0008, 0x7003, 0x0000, 0x00fe,
-	0x00ee, 0x9386, 0x0002, 0x1128, 0x7884, 0x9005, 0x1110, 0x7887,
-	0x0001, 0x2001, 0x1951, 0x200c, 0x080c, 0x0e2f, 0x004e, 0x20a9,
-	0x03e8, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004, 0x7804, 0x9084,
-	0x4000, 0x190c, 0x2b26, 0x0090, 0xd08c, 0x0118, 0x6827, 0x0002,
-	0x0010, 0x1f04, 0x9741, 0x7804, 0x9084, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2b16, 0x9006, 0x080c, 0x2b16, 0x6827, 0x4000,
-	0x6824, 0x83ff, 0x1120, 0x2009, 0x0049, 0x080c, 0x9ebc, 0x000e,
-	0x001e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x015e,
-	0x012e, 0x0005, 0x00d6, 0x0126, 0x2091, 0x8000, 0x2069, 0x19b7,
-	0x6a06, 0x012e, 0x00de, 0x0005, 0x00d6, 0x0126, 0x2091, 0x8000,
-	0x2069, 0x19b7, 0x6a32, 0x012e, 0x00de, 0x0005, 0x080c, 0x9048,
-	0x7854, 0x7032, 0x7042, 0x7047, 0x1000, 0x00f8, 0x080c, 0x9048,
-	0x7854, 0x7032, 0x7042, 0x7047, 0x4000, 0x00b8, 0x080c, 0x9048,
-	0x7854, 0x7032, 0x7042, 0x7047, 0x2000, 0x0078, 0x080c, 0x9048,
-	0x7854, 0x7032, 0x7042, 0x7047, 0x0400, 0x0038, 0x080c, 0x9048,
-	0x7854, 0x7032, 0x7042, 0x7047, 0x0200, 0x60c3, 0x0020, 0x0804,
-	0x9381, 0x00e6, 0x2071, 0x19b7, 0x7020, 0x9005, 0x0110, 0x8001,
-	0x7022, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0076,
-	0x0066, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19b7, 0x7614,
-	0x2660, 0x2678, 0x2039, 0x0001, 0x87ff, 0x0904, 0x9856, 0x8cff,
-	0x0904, 0x9856, 0x6020, 0x9086, 0x0006, 0x1904, 0x9851, 0x88ff,
-	0x0138, 0x2800, 0x9c06, 0x1904, 0x9851, 0x2039, 0x0000, 0x0050,
-	0x6010, 0x9b06, 0x1904, 0x9851, 0x85ff, 0x0120, 0x6054, 0x9106,
-	0x1904, 0x9851, 0x7024, 0x9c06, 0x15b0, 0x2069, 0x0100, 0x68c0,
-	0x9005, 0x1160, 0x6824, 0xd084, 0x0148, 0x6827, 0x0001, 0x080c,
-	0x80a1, 0x080c, 0x98db, 0x7027, 0x0000, 0x0428, 0x080c, 0x80a1,
-	0x6820, 0xd0b4, 0x0110, 0x68a7, 0x95f5, 0x6817, 0x0008, 0x68c3,
-	0x0000, 0x080c, 0x98db, 0x7027, 0x0000, 0x0036, 0x2069, 0x0140,
-	0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2b16,
-	0x9006, 0x080c, 0x2b16, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
-	0x6827, 0x0001, 0x003e, 0x7014, 0x9c36, 0x1110, 0x660c, 0x7616,
-	0x7010, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7012,
-	0x0010, 0x7013, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110,
-	0x7e0e, 0x0008, 0x2678, 0x89ff, 0x1168, 0x600f, 0x0000, 0x6014,
-	0x0096, 0x2048, 0x080c, 0xbb2a, 0x0110, 0x080c, 0xd4f6, 0x009e,
-	0x080c, 0x9e72, 0x080c, 0x97b1, 0x88ff, 0x1190, 0x00ce, 0x0804,
-	0x97cc, 0x2c78, 0x600c, 0x2060, 0x0804, 0x97cc, 0x9006, 0x012e,
-	0x000e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005,
-	0x601b, 0x0000, 0x00ce, 0x98c5, 0x0001, 0x0c88, 0x00f6, 0x00e6,
-	0x00d6, 0x0096, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091,
-	0x8000, 0x2071, 0x19b7, 0x7638, 0x2660, 0x2678, 0x8cff, 0x0904,
-	0x98ca, 0x6020, 0x9086, 0x0006, 0x1904, 0x98c5, 0x87ff, 0x0128,
-	0x2700, 0x9c06, 0x1904, 0x98c5, 0x0040, 0x6010, 0x9b06, 0x15e8,
-	0x85ff, 0x0118, 0x6054, 0x9106, 0x15c0, 0x703c, 0x9c06, 0x1168,
-	0x0036, 0x2019, 0x0001, 0x080c, 0x96d9, 0x7033, 0x0000, 0x9006,
-	0x703e, 0x7042, 0x7046, 0x704a, 0x003e, 0x7038, 0x9c36, 0x1110,
-	0x660c, 0x763a, 0x7034, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118,
-	0x2f00, 0x7036, 0x0010, 0x7037, 0x0000, 0x660c, 0x0066, 0x2c00,
-	0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x6014,
-	0x2048, 0x080c, 0xbb2a, 0x0110, 0x080c, 0xd4f6, 0x080c, 0x9e72,
-	0x87ff, 0x1198, 0x00ce, 0x0804, 0x9876, 0x2c78, 0x600c, 0x2060,
-	0x0804, 0x9876, 0x9006, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce,
-	0x009e, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b, 0x0000, 0x00ce,
-	0x97bd, 0x0001, 0x0c80, 0x00e6, 0x2071, 0x19b7, 0x2001, 0x1800,
-	0x2004, 0x9086, 0x0002, 0x1118, 0x7007, 0x0005, 0x0010, 0x7007,
-	0x0000, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0066, 0x0026,
-	0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19b7, 0x2c10, 0x7638,
-	0x2660, 0x2678, 0x8cff, 0x0540, 0x2200, 0x9c06, 0x1508, 0x7038,
-	0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36, 0x1140, 0x2c00,
-	0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000, 0x660c,
-	0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000,
-	0x6004, 0x9086, 0x0040, 0x090c, 0x8861, 0x9085, 0x0001, 0x0020,
-	0x2c78, 0x600c, 0x2060, 0x08b0, 0x012e, 0x000e, 0x002e, 0x006e,
-	0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0096, 0x00f6, 0x00e6, 0x00d6,
-	0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x19b7, 0x760c, 0x2660, 0x2678, 0x8cff, 0x0904, 0x99c1, 0x6010,
-	0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x1904, 0x99bc, 0x7024,
-	0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0904, 0x9993,
-	0x080c, 0x93ad, 0x68c3, 0x0000, 0x080c, 0x98db, 0x7027, 0x0000,
-	0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2b16, 0x9006, 0x080c, 0x2b16, 0x2069, 0x0100,
-	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x700c, 0x9c36,
-	0x1110, 0x660c, 0x760e, 0x7008, 0x9c36, 0x1140, 0x2c00, 0x9f36,
-	0x0118, 0x2f00, 0x700a, 0x0010, 0x700b, 0x0000, 0x660c, 0x0066,
-	0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000,
-	0x080c, 0xbd21, 0x1180, 0x080c, 0x3005, 0x080c, 0xbd32, 0x1518,
-	0x080c, 0xa7d1, 0x0400, 0x080c, 0x98db, 0x6824, 0xd084, 0x09b0,
-	0x6827, 0x0001, 0x0898, 0x080c, 0xbd32, 0x1118, 0x080c, 0xa7d1,
-	0x0090, 0x6014, 0x2048, 0x080c, 0xbb2a, 0x0168, 0x6020, 0x9086,
-	0x0003, 0x1508, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
-	0x6884, 0x080c, 0xbd15, 0x080c, 0xbf9e, 0x080c, 0x9e72, 0x080c,
-	0x97b1, 0x00ce, 0x0804, 0x993c, 0x2c78, 0x600c, 0x2060, 0x0804,
-	0x993c, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee,
-	0x00fe, 0x009e, 0x0005, 0x6020, 0x9086, 0x0006, 0x1d20, 0x080c,
-	0xd4f6, 0x0c08, 0x00d6, 0x080c, 0x8eda, 0x7003, 0x0200, 0x7007,
-	0x0014, 0x60c3, 0x0014, 0x20e1, 0x0001, 0x2099, 0x1959, 0x20e9,
-	0x0000, 0x20a1, 0x0250, 0x20a9, 0x0004, 0x4003, 0x7023, 0x0004,
-	0x7027, 0x7878, 0x080c, 0x9381, 0x00de, 0x0005, 0x080c, 0x8eda,
-	0x700b, 0x0800, 0x7814, 0x9084, 0xff00, 0x700e, 0x7814, 0x9084,
-	0x00ff, 0x7022, 0x782c, 0x7026, 0x7858, 0x9084, 0x00ff, 0x9085,
-	0x0200, 0x7002, 0x7858, 0x9084, 0xff00, 0x8007, 0x7006, 0x60c2,
-	0x0804, 0x9381, 0x00b6, 0x00d6, 0x0016, 0x00d6, 0x2f68, 0x2009,
-	0x0035, 0x080c, 0xc1a4, 0x00de, 0x1904, 0x9a6f, 0x080c, 0x8e8f,
-	0x7003, 0x1300, 0x782c, 0x080c, 0x9b71, 0x2068, 0x6820, 0x9086,
-	0x0003, 0x0560, 0x7810, 0x2058, 0xbaa0, 0x080c, 0x9dc1, 0x11d8,
-	0x9286, 0x007e, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffe, 0x0498,
-	0x9286, 0x007f, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffd, 0x0458,
-	0x9284, 0xff80, 0x0180, 0x9286, 0x0080, 0x1128, 0x700b, 0x00ff,
-	0x700f, 0xfffc, 0x0400, 0x92d8, 0x1000, 0x2b5c, 0xb810, 0x700a,
-	0xb814, 0x700e, 0x00c0, 0x6098, 0x700e, 0x00a8, 0x080c, 0x9dc1,
-	0x1130, 0x7810, 0x2058, 0xb8a0, 0x9082, 0x007e, 0x0250, 0x00d6,
-	0x2069, 0x181e, 0x2d04, 0x700a, 0x8d68, 0x2d04, 0x700e, 0x00de,
-	0x0010, 0x6034, 0x700e, 0x7838, 0x7012, 0x783c, 0x7016, 0x60c3,
-	0x000c, 0x001e, 0x00de, 0x080c, 0x9381, 0x00be, 0x0005, 0x781b,
-	0x0001, 0x7803, 0x0006, 0x001e, 0x00de, 0x00be, 0x0005, 0x792c,
-	0x9180, 0x0008, 0x200c, 0x9186, 0x0006, 0x01c0, 0x9186, 0x0003,
-	0x0904, 0x9ae9, 0x9186, 0x0005, 0x0904, 0x9ad2, 0x9186, 0x0004,
-	0x05d8, 0x9186, 0x0008, 0x0904, 0x9ada, 0x7807, 0x0037, 0x782f,
-	0x0003, 0x7817, 0x1700, 0x080c, 0x9b4e, 0x0005, 0x080c, 0x9b0f,
-	0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x6800, 0x0002,
-	0x9ab3, 0x9abe, 0x9ab5, 0x9abe, 0x9aba, 0x9ab3, 0x9ab3, 0x9abe,
-	0x9abe, 0x9abe, 0x9abe, 0x9ab3, 0x9ab3, 0x9ab3, 0x9ab3, 0x9ab3,
-	0x9abe, 0x9ab3, 0x9abe, 0x080c, 0x0db4, 0x6824, 0xd0e4, 0x0110,
-	0xd0cc, 0x0110, 0x900e, 0x0010, 0x2009, 0x2000, 0x682c, 0x7022,
-	0x6830, 0x7026, 0x0804, 0x9b08, 0x080c, 0x9b0f, 0x00d6, 0x0026,
-	0x792c, 0x2168, 0x2009, 0x4000, 0x6a00, 0x9286, 0x0002, 0x1108,
-	0x900e, 0x04b0, 0x04e1, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009,
-	0x4000, 0x0470, 0x04a1, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009,
-	0x4000, 0x9286, 0x0005, 0x0118, 0x9286, 0x0002, 0x1108, 0x900e,
-	0x00f8, 0x0429, 0x00d6, 0x0026, 0x792c, 0x2168, 0x6814, 0x0096,
-	0x2048, 0xa9ac, 0xa834, 0x9112, 0xa9b0, 0xa838, 0x009e, 0x9103,
-	0x7022, 0x7226, 0x792c, 0x9180, 0x0000, 0x2004, 0x908e, 0x0002,
-	0x0130, 0x908e, 0x0004, 0x0118, 0x2009, 0x4000, 0x0008, 0x900e,
-	0x712a, 0x60c3, 0x0018, 0x002e, 0x00de, 0x0804, 0x9381, 0x00b6,
-	0x0036, 0x0046, 0x0056, 0x0066, 0x080c, 0x8eda, 0x9006, 0x7003,
-	0x0200, 0x7938, 0x710a, 0x793c, 0x710e, 0x7810, 0x2058, 0xb8a0,
-	0x080c, 0x9dc1, 0x1118, 0x9092, 0x007e, 0x0268, 0x00d6, 0x2069,
-	0x181e, 0x2d2c, 0x8d68, 0x2d34, 0x90d8, 0x1000, 0x2b5c, 0xbb10,
-	0xbc14, 0x00de, 0x0028, 0x901e, 0x6498, 0x2029, 0x0000, 0x6634,
-	0x782c, 0x9080, 0x0008, 0x2004, 0x9086, 0x0003, 0x1128, 0x7512,
-	0x7616, 0x731a, 0x741e, 0x0020, 0x7312, 0x7416, 0x751a, 0x761e,
-	0x006e, 0x005e, 0x004e, 0x003e, 0x00be, 0x0005, 0x080c, 0x8eda,
-	0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e, 0x700e, 0x60c3,
-	0x0008, 0x0804, 0x9381, 0x080c, 0x8e86, 0x7003, 0x1400, 0x7838,
-	0x700a, 0x0079, 0x783c, 0x700e, 0x782c, 0x7012, 0x7830, 0x7016,
-	0x7834, 0x9084, 0x00ff, 0x8007, 0x701a, 0x60c3, 0x0010, 0x0804,
-	0x9381, 0x00e6, 0x2071, 0x0240, 0x0006, 0x00f6, 0x2078, 0x7810,
-	0x00b6, 0x2058, 0xb8bc, 0xd084, 0x0120, 0x7848, 0x702a, 0x7844,
-	0x702e, 0x00be, 0x00fe, 0x000e, 0x00ee, 0x0005, 0x080c, 0x8ed1,
-	0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e, 0x60c3, 0x0008,
-	0x0804, 0x9381, 0x0021, 0x60c3, 0x0000, 0x0804, 0x9381, 0x00d6,
-	0x080c, 0x9c4a, 0xb810, 0x9085, 0x0300, 0x7002, 0xb814, 0x7006,
-	0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x7013, 0x0819,
-	0x080c, 0x936f, 0x721a, 0x2f10, 0x7222, 0x7a08, 0x7226, 0x2071,
-	0x024c, 0x00de, 0x0005, 0x00a9, 0x7914, 0x712a, 0x60c3, 0x0000,
-	0x60a7, 0x9575, 0x0026, 0x080c, 0x29cc, 0x0228, 0x2011, 0x0101,
-	0x2204, 0xc0c5, 0x2012, 0x002e, 0x080c, 0x93a4, 0x080c, 0x8098,
-	0x0005, 0x0036, 0x0096, 0x00d6, 0x00e6, 0x7858, 0x2048, 0xaa7c,
-	0x9296, 0x00c0, 0x9294, 0xfffd, 0xaa7e, 0xaa80, 0x9294, 0x0300,
-	0xaa82, 0xa96c, 0x9194, 0x00ff, 0xab74, 0x9384, 0x00ff, 0x908d,
-	0xc200, 0xa96e, 0x9384, 0xff00, 0x9215, 0xaa76, 0xa870, 0xaa78,
-	0xa87a, 0xaa72, 0x00d6, 0x2069, 0x0200, 0x080c, 0x9c4a, 0x00de,
-	0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000a, 0xa860, 0x20e0,
-	0xa85c, 0x9080, 0x001b, 0x2098, 0x4003, 0x60a3, 0x0035, 0xaa68,
-	0x9294, 0x7000, 0x9286, 0x3000, 0x0110, 0x60a3, 0x0037, 0x00ee,
-	0x00de, 0x009e, 0x003e, 0x0005, 0x900e, 0x7814, 0x0096, 0x2048,
-	0xa87c, 0xd0fc, 0x01c0, 0x9084, 0x0003, 0x11a8, 0x2001, 0x180c,
-	0x2004, 0xd0bc, 0x0180, 0x7824, 0xd0cc, 0x1168, 0xd0c4, 0x1158,
-	0xa8a8, 0x9005, 0x1140, 0x2001, 0x180c, 0x200c, 0xc1d5, 0x2102,
-	0x2009, 0x1982, 0x210c, 0x009e, 0x918d, 0x0092, 0x0010, 0x2009,
-	0x0096, 0x60ab, 0x0036, 0x6116, 0x0005, 0x2009, 0x0009, 0x00a0,
-	0x2009, 0x000a, 0x0088, 0x2009, 0x000b, 0x0070, 0x2009, 0x000c,
-	0x0058, 0x2009, 0x000d, 0x0040, 0x2009, 0x000e, 0x0028, 0x2009,
-	0x000f, 0x0010, 0x2009, 0x0008, 0x6912, 0x0005, 0x00d6, 0x9290,
-	0x0018, 0x8214, 0x20e9, 0x0000, 0x2069, 0x0200, 0x6813, 0x0000,
-	0x22a8, 0x9284, 0x00e0, 0x0128, 0x20a9, 0x0020, 0x9292, 0x0020,
-	0x0008, 0x9016, 0x20a1, 0x0240, 0x9006, 0x4004, 0x82ff, 0x0120,
-	0x6810, 0x8000, 0x6812, 0x0c60, 0x00de, 0x0005, 0x00d6, 0x0096,
-	0x6014, 0x2048, 0xa878, 0x6056, 0x9006, 0xa836, 0xa83a, 0xa99c,
-	0xa946, 0xa84a, 0x6023, 0x0003, 0x6007, 0x0040, 0x6003, 0x0003,
-	0x600b, 0xffff, 0xa817, 0x0001, 0xa842, 0xa83e, 0x2900, 0xa85a,
-	0xa813, 0x1f26, 0x080c, 0x843f, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x8a4a, 0x012e, 0x009e, 0x00de, 0x0005, 0x00f6, 0x00e6, 0x00d6,
-	0x00c6, 0x00a6, 0x0096, 0x0066, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x19b7, 0x760c, 0x2660, 0x2678, 0x8cff, 0x0904, 0x9d21, 0x7024,
-	0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0904, 0x9cf3,
-	0x080c, 0x93ad, 0x68c3, 0x0000, 0x080c, 0x98db, 0x7027, 0x0000,
-	0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2b16, 0x9006, 0x080c, 0x2b16, 0x2069, 0x0100,
-	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x700c, 0x9c36,
-	0x1110, 0x660c, 0x760e, 0x7008, 0x9c36, 0x1140, 0x2c00, 0x9f36,
-	0x0118, 0x2f00, 0x700a, 0x0010, 0x700b, 0x0000, 0x660c, 0x0066,
+	0x0008, 0x080c, 0x80cc, 0x080c, 0x1e9d, 0x2001, 0x0032, 0x6920,
+	0xd1bc, 0x0130, 0x8001, 0x1dd8, 0x692c, 0x918d, 0x0008, 0x692e,
+	0x20a9, 0x03e8, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004, 0x7804,
+	0x9084, 0x4000, 0x190c, 0x2b31, 0x0090, 0xd08c, 0x0118, 0x6827,
+	0x0002, 0x0010, 0x1f04, 0x972a, 0x7804, 0x9084, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2b21, 0x9006, 0x080c, 0x2b21, 0x6827,
+	0x4000, 0x6824, 0x83ff, 0x1120, 0x2009, 0x0049, 0x080c, 0x9ea9,
+	0x000e, 0x001e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe,
+	0x015e, 0x012e, 0x0005, 0x00d6, 0x0126, 0x2091, 0x8000, 0x2069,
+	0x19bf, 0x6a06, 0x012e, 0x00de, 0x0005, 0x00d6, 0x0126, 0x2091,
+	0x8000, 0x2069, 0x19bf, 0x6a32, 0x012e, 0x00de, 0x0005, 0x080c,
+	0x9062, 0x7854, 0x7032, 0x7042, 0x7047, 0x1000, 0x00f8, 0x080c,
+	0x9062, 0x7854, 0x7032, 0x7042, 0x7047, 0x4000, 0x00b8, 0x080c,
+	0x9062, 0x7854, 0x7032, 0x7042, 0x7047, 0x2000, 0x0078, 0x080c,
+	0x9062, 0x7854, 0x7032, 0x7042, 0x7047, 0x0400, 0x0038, 0x080c,
+	0x9062, 0x7854, 0x7032, 0x7042, 0x7047, 0x0200, 0x60c3, 0x0020,
+	0x0804, 0x939b, 0x00e6, 0x2071, 0x19bf, 0x7020, 0x9005, 0x0110,
+	0x8001, 0x7022, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6,
+	0x0076, 0x0066, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19bf,
+	0x7614, 0x2660, 0x2678, 0x2039, 0x0001, 0x87ff, 0x0904, 0x983f,
+	0x8cff, 0x0904, 0x983f, 0x6020, 0x9086, 0x0006, 0x1904, 0x983a,
+	0x88ff, 0x0138, 0x2800, 0x9c06, 0x1904, 0x983a, 0x2039, 0x0000,
+	0x0050, 0x6010, 0x9b06, 0x1904, 0x983a, 0x85ff, 0x0120, 0x6054,
+	0x9106, 0x1904, 0x983a, 0x7024, 0x9c06, 0x15b0, 0x2069, 0x0100,
+	0x68c0, 0x9005, 0x1160, 0x6824, 0xd084, 0x0148, 0x6827, 0x0001,
+	0x080c, 0x80bf, 0x080c, 0x98c4, 0x7027, 0x0000, 0x0428, 0x080c,
+	0x80bf, 0x6820, 0xd0b4, 0x0110, 0x68a7, 0x95f5, 0x6817, 0x0008,
+	0x68c3, 0x0000, 0x080c, 0x98c4, 0x7027, 0x0000, 0x0036, 0x2069,
+	0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c,
+	0x2b21, 0x9006, 0x080c, 0x2b21, 0x2069, 0x0100, 0x6824, 0xd084,
+	0x0110, 0x6827, 0x0001, 0x003e, 0x7014, 0x9c36, 0x1110, 0x660c,
+	0x7616, 0x7010, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00,
+	0x7012, 0x0010, 0x7013, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06,
+	0x0110, 0x7e0e, 0x0008, 0x2678, 0x89ff, 0x1168, 0x600f, 0x0000,
+	0x6014, 0x0096, 0x2048, 0x080c, 0xbb39, 0x0110, 0x080c, 0xd50f,
+	0x009e, 0x080c, 0x9e5f, 0x080c, 0x979a, 0x88ff, 0x1190, 0x00ce,
+	0x0804, 0x97b5, 0x2c78, 0x600c, 0x2060, 0x0804, 0x97b5, 0x9006,
+	0x012e, 0x000e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x00fe,
+	0x0005, 0x601b, 0x0000, 0x00ce, 0x98c5, 0x0001, 0x0c88, 0x00f6,
+	0x00e6, 0x00d6, 0x0096, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2071, 0x19bf, 0x7638, 0x2660, 0x2678, 0x8cff,
+	0x0904, 0x98b3, 0x6020, 0x9086, 0x0006, 0x1904, 0x98ae, 0x87ff,
+	0x0128, 0x2700, 0x9c06, 0x1904, 0x98ae, 0x0040, 0x6010, 0x9b06,
+	0x15e8, 0x85ff, 0x0118, 0x6054, 0x9106, 0x15c0, 0x703c, 0x9c06,
+	0x1168, 0x0036, 0x2019, 0x0001, 0x080c, 0x96e9, 0x7033, 0x0000,
+	0x9006, 0x703e, 0x7042, 0x7046, 0x704a, 0x003e, 0x7038, 0x9c36,
+	0x1110, 0x660c, 0x763a, 0x7034, 0x9c36, 0x1140, 0x2c00, 0x9f36,
+	0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000, 0x660c, 0x0066,
 	0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000,
-	0x080c, 0xbd21, 0x1180, 0x080c, 0x3005, 0x080c, 0xbd32, 0x1518,
-	0x080c, 0xa7d1, 0x0400, 0x080c, 0x98db, 0x6824, 0xd084, 0x09b0,
-	0x6827, 0x0001, 0x0898, 0x080c, 0xbd32, 0x1118, 0x080c, 0xa7d1,
-	0x0090, 0x6014, 0x2048, 0x080c, 0xbb2a, 0x0168, 0x6020, 0x9086,
-	0x0003, 0x1520, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
-	0x6891, 0x080c, 0xbd15, 0x080c, 0xbf9e, 0x080c, 0x9e72, 0x080c,
-	0x97b1, 0x00ce, 0x0804, 0x9ca4, 0x2c78, 0x600c, 0x2060, 0x0804,
-	0x9ca4, 0x700f, 0x0000, 0x700b, 0x0000, 0x012e, 0x006e, 0x009e,
-	0x00ae, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086,
-	0x0006, 0x1d08, 0x080c, 0xd4f6, 0x08f0, 0x00d6, 0x0156, 0x080c,
-	0x8eda, 0x7a14, 0x82ff, 0x0138, 0x7003, 0x0100, 0x700b, 0x0003,
-	0x60c3, 0x0008, 0x0490, 0x7003, 0x0200, 0x7007, 0x0000, 0x2069,
-	0x1800, 0x901e, 0x6800, 0x9086, 0x0004, 0x1110, 0xc38d, 0x0060,
-	0x080c, 0x6f9b, 0x1110, 0xc3ad, 0x0008, 0xc3a5, 0x6ad8, 0xd29c,
-	0x1110, 0xd2ac, 0x0108, 0xc39d, 0x730e, 0x2011, 0x1848, 0x63f0,
-	0x2312, 0x20a9, 0x0006, 0x2011, 0x1840, 0x2019, 0x1841, 0x2071,
-	0x0250, 0x2376, 0x8e70, 0x2276, 0x8e70, 0x9398, 0x0002, 0x9290,
-	0x0002, 0x1f04, 0x9d69, 0x60c3, 0x0020, 0x080c, 0x9381, 0x015e,
-	0x00de, 0x0005, 0x0156, 0x080c, 0x8eda, 0x7a14, 0x82ff, 0x0168,
-	0x9286, 0xffff, 0x0118, 0x9282, 0x000e, 0x1238, 0x7003, 0x0100,
-	0x700b, 0x0003, 0x60c3, 0x0008, 0x0488, 0x7003, 0x0200, 0x7007,
-	0x001c, 0x700f, 0x0001, 0x2011, 0x198d, 0x2204, 0x8007, 0x701a,
-	0x8210, 0x2204, 0x8007, 0x701e, 0x0421, 0x1120, 0xb8a0, 0x9082,
-	0x007f, 0x0248, 0x2001, 0x181e, 0x2004, 0x7022, 0x2001, 0x181f,
-	0x2004, 0x7026, 0x0030, 0x2001, 0x1817, 0x2004, 0x9084, 0x00ff,
-	0x7026, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9,
-	0x0000, 0x20a1, 0x0256, 0x4003, 0x60c3, 0x001c, 0x015e, 0x0804,
-	0x9381, 0x0006, 0x2001, 0x1836, 0x2004, 0xd0ac, 0x000e, 0x0005,
-	0x2011, 0x0003, 0x080c, 0x9772, 0x2011, 0x0002, 0x080c, 0x977c,
-	0x080c, 0x9663, 0x0036, 0x901e, 0x080c, 0x96d9, 0x003e, 0x0005,
-	0x2071, 0x1883, 0x7000, 0x9005, 0x0140, 0x2001, 0x0976, 0x2071,
-	0x1800, 0x7072, 0x7076, 0x7067, 0xffe0, 0x2071, 0x1800, 0x7070,
-	0x7052, 0x7057, 0x1cd0, 0x0005, 0x00e6, 0x0126, 0x2071, 0x1800,
-	0x2091, 0x8000, 0x7550, 0x9582, 0x0010, 0x0608, 0x7054, 0x2060,
+	0x6014, 0x2048, 0x080c, 0xbb39, 0x0110, 0x080c, 0xd50f, 0x080c,
+	0x9e5f, 0x87ff, 0x1198, 0x00ce, 0x0804, 0x985f, 0x2c78, 0x600c,
+	0x2060, 0x0804, 0x985f, 0x9006, 0x012e, 0x000e, 0x002e, 0x006e,
+	0x00ce, 0x009e, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b, 0x0000,
+	0x00ce, 0x97bd, 0x0001, 0x0c80, 0x00e6, 0x2071, 0x19bf, 0x2001,
+	0x1800, 0x2004, 0x9086, 0x0002, 0x1118, 0x7007, 0x0005, 0x0010,
+	0x7007, 0x0000, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0066,
+	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19bf, 0x2c10,
+	0x7638, 0x2660, 0x2678, 0x8cff, 0x0540, 0x2200, 0x9c06, 0x1508,
+	0x7038, 0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36, 0x1140,
+	0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000,
+	0x660c, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
+	0x0000, 0x6004, 0x9086, 0x0040, 0x090c, 0x887f, 0x9085, 0x0001,
+	0x0020, 0x2c78, 0x600c, 0x2060, 0x08b0, 0x012e, 0x000e, 0x002e,
+	0x006e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0096, 0x00f6, 0x00e6,
+	0x00d6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000,
+	0x2071, 0x19bf, 0x760c, 0x2660, 0x2678, 0x8cff, 0x0904, 0x99aa,
+	0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x1904, 0x99a5,
+	0x7024, 0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0904,
+	0x997c, 0x080c, 0x93c7, 0x68c3, 0x0000, 0x080c, 0x98c4, 0x7027,
+	0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2b21, 0x9006, 0x080c, 0x2b21, 0x2069,
+	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x700c,
+	0x9c36, 0x1110, 0x660c, 0x760e, 0x7008, 0x9c36, 0x1140, 0x2c00,
+	0x9f36, 0x0118, 0x2f00, 0x700a, 0x0010, 0x700b, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
+	0x0000, 0x080c, 0xbd30, 0x1180, 0x080c, 0x3010, 0x080c, 0xbd41,
+	0x1518, 0x080c, 0xa7cd, 0x0400, 0x080c, 0x98c4, 0x6824, 0xd084,
+	0x09b0, 0x6827, 0x0001, 0x0898, 0x080c, 0xbd41, 0x1118, 0x080c,
+	0xa7cd, 0x0090, 0x6014, 0x2048, 0x080c, 0xbb39, 0x0168, 0x6020,
+	0x9086, 0x0003, 0x1508, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000,
+	0x080c, 0x6893, 0x080c, 0xbd24, 0x080c, 0xbfad, 0x080c, 0x9e5f,
+	0x080c, 0x979a, 0x00ce, 0x0804, 0x9925, 0x2c78, 0x600c, 0x2060,
+	0x0804, 0x9925, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x00de,
+	0x00ee, 0x00fe, 0x009e, 0x0005, 0x6020, 0x9086, 0x0006, 0x1d20,
+	0x080c, 0xd50f, 0x0c08, 0x00d6, 0x080c, 0x8ef4, 0x7003, 0x0200,
+	0x7007, 0x0014, 0x60c3, 0x0014, 0x20e1, 0x0001, 0x2099, 0x1961,
+	0x20e9, 0x0000, 0x20a1, 0x0250, 0x20a9, 0x0004, 0x4003, 0x7023,
+	0x0004, 0x7027, 0x7878, 0x080c, 0x939b, 0x00de, 0x0005, 0x080c,
+	0x8ef4, 0x700b, 0x0800, 0x7814, 0x9084, 0xff00, 0x700e, 0x7814,
+	0x9084, 0x00ff, 0x7022, 0x782c, 0x7026, 0x7858, 0x9084, 0x00ff,
+	0x9085, 0x0200, 0x7002, 0x7858, 0x9084, 0xff00, 0x8007, 0x7006,
+	0x60c2, 0x0804, 0x939b, 0x00b6, 0x00d6, 0x0016, 0x00d6, 0x2f68,
+	0x2009, 0x0035, 0x080c, 0xc1b3, 0x00de, 0x1904, 0x9a58, 0x080c,
+	0x8ea9, 0x7003, 0x1300, 0x782c, 0x080c, 0x9b5e, 0x2068, 0x6820,
+	0x9086, 0x0003, 0x0560, 0x7810, 0x2058, 0xbaa0, 0x080c, 0x9dae,
+	0x11d8, 0x9286, 0x007e, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffe,
+	0x0498, 0x9286, 0x007f, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffd,
+	0x0458, 0x9284, 0xff80, 0x0180, 0x9286, 0x0080, 0x1128, 0x700b,
+	0x00ff, 0x700f, 0xfffc, 0x0400, 0x92d8, 0x1000, 0x2b5c, 0xb810,
+	0x700a, 0xb814, 0x700e, 0x00c0, 0x6098, 0x700e, 0x00a8, 0x080c,
+	0x9dae, 0x1130, 0x7810, 0x2058, 0xb8a0, 0x9082, 0x007e, 0x0250,
+	0x00d6, 0x2069, 0x181e, 0x2d04, 0x700a, 0x8d68, 0x2d04, 0x700e,
+	0x00de, 0x0010, 0x6034, 0x700e, 0x7838, 0x7012, 0x783c, 0x7016,
+	0x60c3, 0x000c, 0x001e, 0x00de, 0x080c, 0x939b, 0x00be, 0x0005,
+	0x781b, 0x0001, 0x7803, 0x0006, 0x001e, 0x00de, 0x00be, 0x0005,
+	0x792c, 0x9180, 0x0008, 0x200c, 0x9186, 0x0006, 0x01c0, 0x9186,
+	0x0003, 0x0904, 0x9ad3, 0x9186, 0x0005, 0x0904, 0x9abb, 0x9186,
+	0x0004, 0x05d8, 0x9186, 0x0008, 0x0904, 0x9ac4, 0x7807, 0x0037,
+	0x782f, 0x0003, 0x7817, 0x1700, 0x080c, 0x9b3b, 0x0005, 0x080c,
+	0x9afc, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x6800,
+	0x0002, 0x9a9c, 0x9aa7, 0x9a9e, 0x9aa7, 0x9aa3, 0x9a9c, 0x9a9c,
+	0x9aa7, 0x9aa7, 0x9aa7, 0x9aa7, 0x9a9c, 0x9a9c, 0x9a9c, 0x9a9c,
+	0x9a9c, 0x9aa7, 0x9a9c, 0x9aa7, 0x080c, 0x0db4, 0x6824, 0xd0e4,
+	0x0110, 0xd0cc, 0x0110, 0x900e, 0x0010, 0x2009, 0x2000, 0x682c,
+	0x7022, 0x6830, 0x7026, 0x0804, 0x9af5, 0x080c, 0x9afc, 0x00d6,
+	0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x6a00, 0x9286, 0x0002,
+	0x1108, 0x900e, 0x04d0, 0x080c, 0x9afc, 0x00d6, 0x0026, 0x792c,
+	0x2168, 0x2009, 0x4000, 0x0488, 0x04b9, 0x00d6, 0x0026, 0x792c,
+	0x2168, 0x2009, 0x4000, 0x9286, 0x0005, 0x0118, 0x9286, 0x0002,
+	0x1108, 0x900e, 0x0410, 0x0441, 0x00d6, 0x0026, 0x792c, 0x2168,
+	0x6814, 0x6924, 0xc185, 0x6926, 0x0096, 0x2048, 0xa9ac, 0xa834,
+	0x9112, 0xa9b0, 0xa838, 0x009e, 0x9103, 0x7022, 0x7226, 0x792c,
+	0x9180, 0x0000, 0x2004, 0x908e, 0x0002, 0x0130, 0x908e, 0x0004,
+	0x0118, 0x2009, 0x4000, 0x0008, 0x900e, 0x712a, 0x60c3, 0x0018,
+	0x002e, 0x00de, 0x0804, 0x939b, 0x00b6, 0x0036, 0x0046, 0x0056,
+	0x0066, 0x080c, 0x8ef4, 0x9006, 0x7003, 0x0200, 0x7938, 0x710a,
+	0x793c, 0x710e, 0x7810, 0x2058, 0xb8a0, 0x080c, 0x9dae, 0x1118,
+	0x9092, 0x007e, 0x0268, 0x00d6, 0x2069, 0x181e, 0x2d2c, 0x8d68,
+	0x2d34, 0x90d8, 0x1000, 0x2b5c, 0xbb10, 0xbc14, 0x00de, 0x0028,
+	0x901e, 0x6498, 0x2029, 0x0000, 0x6634, 0x782c, 0x9080, 0x0008,
+	0x2004, 0x9086, 0x0003, 0x1128, 0x7512, 0x7616, 0x731a, 0x741e,
+	0x0020, 0x7312, 0x7416, 0x751a, 0x761e, 0x006e, 0x005e, 0x004e,
+	0x003e, 0x00be, 0x0005, 0x080c, 0x8ef4, 0x7003, 0x0100, 0x782c,
+	0x700a, 0x7814, 0x700e, 0x700e, 0x60c3, 0x0008, 0x0804, 0x939b,
+	0x080c, 0x8ea0, 0x7003, 0x1400, 0x7838, 0x700a, 0x0079, 0x783c,
+	0x700e, 0x782c, 0x7012, 0x7830, 0x7016, 0x7834, 0x9084, 0x00ff,
+	0x8007, 0x701a, 0x60c3, 0x0010, 0x0804, 0x939b, 0x00e6, 0x2071,
+	0x0240, 0x0006, 0x00f6, 0x2078, 0x7810, 0x00b6, 0x2058, 0xb8bc,
+	0xd084, 0x0120, 0x7848, 0x702a, 0x7844, 0x702e, 0x00be, 0x00fe,
+	0x000e, 0x00ee, 0x0005, 0x080c, 0x8eeb, 0x7003, 0x0100, 0x782c,
+	0x700a, 0x7814, 0x700e, 0x60c3, 0x0008, 0x0804, 0x939b, 0x0021,
+	0x60c3, 0x0000, 0x0804, 0x939b, 0x00d6, 0x080c, 0x9c37, 0xb810,
+	0x9085, 0x0300, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6878,
+	0x700a, 0x687c, 0x700e, 0x7013, 0x0819, 0x080c, 0x9389, 0x721a,
+	0x2f10, 0x7222, 0x7a08, 0x7226, 0x2071, 0x024c, 0x00de, 0x0005,
+	0x00a9, 0x7914, 0x712a, 0x60c3, 0x0000, 0x60a7, 0x9575, 0x0026,
+	0x080c, 0x29d7, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012,
+	0x002e, 0x080c, 0x93be, 0x080c, 0x80b6, 0x0005, 0x0036, 0x0096,
+	0x00d6, 0x00e6, 0x7858, 0x2048, 0xaa7c, 0x9296, 0x00c0, 0x9294,
+	0xfffd, 0xaa7e, 0xaa80, 0x9294, 0x0300, 0xaa82, 0xa96c, 0x9194,
+	0x00ff, 0xab74, 0x9384, 0x00ff, 0x908d, 0xc200, 0xa96e, 0x9384,
+	0xff00, 0x9215, 0xaa76, 0xa870, 0xaa78, 0xa87a, 0xaa72, 0x00d6,
+	0x2069, 0x0200, 0x080c, 0x9c37, 0x00de, 0x20e9, 0x0000, 0x20a1,
+	0x0240, 0x20a9, 0x000a, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b,
+	0x2098, 0x4003, 0x60a3, 0x0035, 0xaa68, 0x9294, 0x7000, 0x9286,
+	0x3000, 0x0110, 0x60a3, 0x0037, 0x00ee, 0x00de, 0x009e, 0x003e,
+	0x0005, 0x900e, 0x7814, 0x0096, 0x2048, 0xa87c, 0xd0fc, 0x01c0,
+	0x9084, 0x0003, 0x11a8, 0x2001, 0x180c, 0x2004, 0xd0bc, 0x0180,
+	0x7824, 0xd0cc, 0x1168, 0xd0c4, 0x1158, 0xa8a8, 0x9005, 0x1140,
+	0x2001, 0x180c, 0x200c, 0xc1d5, 0x2102, 0x2009, 0x198a, 0x210c,
+	0x009e, 0x918d, 0x0092, 0x0010, 0x2009, 0x0096, 0x60ab, 0x0036,
+	0x6116, 0x0005, 0x2009, 0x0009, 0x00a0, 0x2009, 0x000a, 0x0088,
+	0x2009, 0x000b, 0x0070, 0x2009, 0x000c, 0x0058, 0x2009, 0x000d,
+	0x0040, 0x2009, 0x000e, 0x0028, 0x2009, 0x000f, 0x0010, 0x2009,
+	0x0008, 0x6912, 0x0005, 0x00d6, 0x9290, 0x0018, 0x8214, 0x20e9,
+	0x0000, 0x2069, 0x0200, 0x6813, 0x0000, 0x22a8, 0x9284, 0x00e0,
+	0x0128, 0x20a9, 0x0020, 0x9292, 0x0020, 0x0008, 0x9016, 0x20a1,
+	0x0240, 0x9006, 0x4004, 0x82ff, 0x0120, 0x6810, 0x8000, 0x6812,
+	0x0c60, 0x00de, 0x0005, 0x00d6, 0x0096, 0x6014, 0x2048, 0xa878,
+	0x6056, 0x9006, 0xa836, 0xa83a, 0xa99c, 0xa946, 0xa84a, 0x6023,
+	0x0003, 0x6007, 0x0040, 0x6003, 0x0003, 0x600b, 0xffff, 0xa817,
+	0x0001, 0xa842, 0xa83e, 0x2900, 0xa85a, 0xa813, 0x1f31, 0x080c,
+	0x845d, 0x0126, 0x2091, 0x8000, 0x080c, 0x8a68, 0x012e, 0x009e,
+	0x00de, 0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00a6, 0x0096,
+	0x0066, 0x0126, 0x2091, 0x8000, 0x2071, 0x19bf, 0x760c, 0x2660,
+	0x2678, 0x8cff, 0x0904, 0x9d0e, 0x7024, 0x9c06, 0x1520, 0x2069,
+	0x0100, 0x68c0, 0x9005, 0x0904, 0x9ce0, 0x080c, 0x93c7, 0x68c3,
+	0x0000, 0x080c, 0x98c4, 0x7027, 0x0000, 0x0036, 0x2069, 0x0140,
+	0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2b21,
+	0x9006, 0x080c, 0x2b21, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
+	0x6827, 0x0001, 0x003e, 0x700c, 0x9c36, 0x1110, 0x660c, 0x760e,
+	0x7008, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700a,
+	0x0010, 0x700b, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110,
+	0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x080c, 0xbd30, 0x1180,
+	0x080c, 0x3010, 0x080c, 0xbd41, 0x1518, 0x080c, 0xa7cd, 0x0400,
+	0x080c, 0x98c4, 0x6824, 0xd084, 0x09b0, 0x6827, 0x0001, 0x0898,
+	0x080c, 0xbd41, 0x1118, 0x080c, 0xa7cd, 0x0090, 0x6014, 0x2048,
+	0x080c, 0xbb39, 0x0168, 0x6020, 0x9086, 0x0003, 0x1520, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x68a0, 0x080c, 0xbd24,
+	0x080c, 0xbfad, 0x080c, 0x9e5f, 0x080c, 0x979a, 0x00ce, 0x0804,
+	0x9c91, 0x2c78, 0x600c, 0x2060, 0x0804, 0x9c91, 0x700f, 0x0000,
+	0x700b, 0x0000, 0x012e, 0x006e, 0x009e, 0x00ae, 0x00ce, 0x00de,
+	0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086, 0x0006, 0x1d08, 0x080c,
+	0xd50f, 0x08f0, 0x00d6, 0x0156, 0x080c, 0x8ef4, 0x7a14, 0x82ff,
+	0x0138, 0x7003, 0x0100, 0x700b, 0x0003, 0x60c3, 0x0008, 0x0490,
+	0x7003, 0x0200, 0x7007, 0x0000, 0x2069, 0x1800, 0x901e, 0x6800,
+	0x9086, 0x0004, 0x1110, 0xc38d, 0x0060, 0x080c, 0x6faa, 0x1110,
+	0xc3ad, 0x0008, 0xc3a5, 0x6ad8, 0xd29c, 0x1110, 0xd2ac, 0x0108,
+	0xc39d, 0x730e, 0x2011, 0x1848, 0x63f0, 0x2312, 0x20a9, 0x0006,
+	0x2011, 0x1840, 0x2019, 0x1841, 0x2071, 0x0250, 0x2376, 0x8e70,
+	0x2276, 0x8e70, 0x9398, 0x0002, 0x9290, 0x0002, 0x1f04, 0x9d56,
+	0x60c3, 0x0020, 0x080c, 0x939b, 0x015e, 0x00de, 0x0005, 0x0156,
+	0x080c, 0x8ef4, 0x7a14, 0x82ff, 0x0168, 0x9286, 0xffff, 0x0118,
+	0x9282, 0x000e, 0x1238, 0x7003, 0x0100, 0x700b, 0x0003, 0x60c3,
+	0x0008, 0x0488, 0x7003, 0x0200, 0x7007, 0x001c, 0x700f, 0x0001,
+	0x2011, 0x1995, 0x2204, 0x8007, 0x701a, 0x8210, 0x2204, 0x8007,
+	0x701e, 0x0421, 0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001,
+	0x181e, 0x2004, 0x7022, 0x2001, 0x181f, 0x2004, 0x7026, 0x0030,
+	0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x7026, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256,
+	0x4003, 0x60c3, 0x001c, 0x015e, 0x0804, 0x939b, 0x0006, 0x2001,
+	0x1836, 0x2004, 0xd0ac, 0x000e, 0x0005, 0x2011, 0x0003, 0x080c,
+	0x975b, 0x2011, 0x0002, 0x080c, 0x9765, 0x080c, 0x9673, 0x0036,
+	0x901e, 0x080c, 0x96e9, 0x003e, 0x0005, 0x2071, 0x188b, 0x7000,
+	0x9005, 0x0140, 0x2001, 0x0976, 0x2071, 0x1800, 0x7072, 0x7076,
+	0x7067, 0xffe0, 0x2071, 0x1800, 0x7070, 0x7052, 0x7057, 0x1cd0,
+	0x0005, 0x00e6, 0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7550,
+	0x9582, 0x0010, 0x0608, 0x7054, 0x2060, 0x6000, 0x9086, 0x0000,
+	0x0148, 0x9ce0, 0x0018, 0x7064, 0x9c02, 0x1208, 0x0cb0, 0x2061,
+	0x1cd0, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7552, 0x9ca8, 0x0018,
+	0x7064, 0x9502, 0x1230, 0x7556, 0x9085, 0x0001, 0x012e, 0x00ee,
+	0x0005, 0x7057, 0x1cd0, 0x0cc0, 0x9006, 0x0cc0, 0x00e6, 0x2071,
+	0x1800, 0x7550, 0x9582, 0x0010, 0x0600, 0x7054, 0x2060, 0x6000,
+	0x9086, 0x0000, 0x0148, 0x9ce0, 0x0018, 0x7064, 0x9c02, 0x1208,
+	0x0cb0, 0x2061, 0x1cd0, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7552,
+	0x9ca8, 0x0018, 0x7064, 0x9502, 0x1228, 0x7556, 0x9085, 0x0001,
+	0x00ee, 0x0005, 0x7057, 0x1cd0, 0x0cc8, 0x9006, 0x0cc8, 0x9c82,
+	0x1cd0, 0x0a0c, 0x0db4, 0x2001, 0x1819, 0x2004, 0x9c02, 0x1a0c,
+	0x0db4, 0x9006, 0x6006, 0x600a, 0x600e, 0x6016, 0x601a, 0x6012,
+	0x6023, 0x0000, 0x6003, 0x0000, 0x601e, 0x6056, 0x605a, 0x6026,
+	0x602a, 0x602e, 0x6032, 0x6036, 0x603a, 0x603e, 0x6042, 0x2061,
+	0x1800, 0x6050, 0x8000, 0x6052, 0x9086, 0x0001, 0x0108, 0x0005,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x898b, 0x012e, 0x0cc0, 0x0006,
+	0x6000, 0x9086, 0x0000, 0x01b0, 0x601c, 0xd084, 0x190c, 0x191f,
+	0x6017, 0x0000, 0x6023, 0x0007, 0x2001, 0x195e, 0x2004, 0x0006,
+	0x9082, 0x0051, 0x000e, 0x0208, 0x8004, 0x601a, 0x080c, 0xd7c1,
+	0x6043, 0x0000, 0x000e, 0x0005, 0x00e6, 0x0126, 0x2071, 0x1800,
+	0x2091, 0x8000, 0x7550, 0x9582, 0x0001, 0x0608, 0x7054, 0x2060,
 	0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0, 0x0018, 0x7064, 0x9c02,
 	0x1208, 0x0cb0, 0x2061, 0x1cd0, 0x0c98, 0x6003, 0x0008, 0x8529,
 	0x7552, 0x9ca8, 0x0018, 0x7064, 0x9502, 0x1230, 0x7556, 0x9085,
 	0x0001, 0x012e, 0x00ee, 0x0005, 0x7057, 0x1cd0, 0x0cc0, 0x9006,
-	0x0cc0, 0x00e6, 0x2071, 0x1800, 0x7550, 0x9582, 0x0010, 0x0600,
-	0x7054, 0x2060, 0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0, 0x0018,
-	0x7064, 0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1cd0, 0x0c98, 0x6003,
-	0x0008, 0x8529, 0x7552, 0x9ca8, 0x0018, 0x7064, 0x9502, 0x1228,
-	0x7556, 0x9085, 0x0001, 0x00ee, 0x0005, 0x7057, 0x1cd0, 0x0cc8,
-	0x9006, 0x0cc8, 0x9c82, 0x1cd0, 0x0a0c, 0x0db4, 0x2001, 0x1819,
-	0x2004, 0x9c02, 0x1a0c, 0x0db4, 0x9006, 0x6006, 0x600a, 0x600e,
-	0x6016, 0x601a, 0x6012, 0x6023, 0x0000, 0x6003, 0x0000, 0x601e,
-	0x6056, 0x605a, 0x6026, 0x602a, 0x602e, 0x6032, 0x6036, 0x603a,
-	0x603e, 0x6042, 0x2061, 0x1800, 0x6050, 0x8000, 0x6052, 0x9086,
-	0x0001, 0x0108, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x896d,
-	0x012e, 0x0cc0, 0x0006, 0x6000, 0x9086, 0x0000, 0x01b0, 0x601c,
-	0xd084, 0x190c, 0x190f, 0x6017, 0x0000, 0x6023, 0x0007, 0x2001,
-	0x1956, 0x2004, 0x0006, 0x9082, 0x0051, 0x000e, 0x0208, 0x8004,
-	0x601a, 0x080c, 0xd7a8, 0x6043, 0x0000, 0x000e, 0x0005, 0x00e6,
-	0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7550, 0x9582, 0x0001,
-	0x0608, 0x7054, 0x2060, 0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0,
-	0x0018, 0x7064, 0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1cd0, 0x0c98,
-	0x6003, 0x0008, 0x8529, 0x7552, 0x9ca8, 0x0018, 0x7064, 0x9502,
-	0x1230, 0x7556, 0x9085, 0x0001, 0x012e, 0x00ee, 0x0005, 0x7057,
-	0x1cd0, 0x0cc0, 0x9006, 0x0cc0, 0x6020, 0x9084, 0x000f, 0x0002,
-	0x9ecf, 0x9ed8, 0x9ef3, 0x9f0e, 0xc252, 0xc26f, 0xc28a, 0x9ecf,
-	0x9ed8, 0x9ecf, 0x9f2a, 0x9ecf, 0x9ecf, 0x9ecf, 0x9ecf, 0x9186,
-	0x0013, 0x1128, 0x080c, 0x8861, 0x080c, 0x896d, 0x0005, 0x0005,
+	0x0cc0, 0x6020, 0x9084, 0x000f, 0x0002, 0x9ebc, 0x9ec5, 0x9ee0,
+	0x9efb, 0xc261, 0xc27e, 0xc299, 0x9ebc, 0x9ec5, 0x9ebc, 0x9f17,
+	0x9ebc, 0x9ebc, 0x9ebc, 0x9ebc, 0x9186, 0x0013, 0x1128, 0x080c,
+	0x887f, 0x080c, 0x898b, 0x0005, 0x0005, 0x0066, 0x6000, 0x90b2,
+	0x0016, 0x1a0c, 0x0db4, 0x0013, 0x006e, 0x0005, 0x9ede, 0xa644,
+	0xa814, 0x9ede, 0xa8a2, 0xa1fa, 0x9ede, 0x9ede, 0xa5c6, 0xae46,
+	0x9ede, 0x9ede, 0x9ede, 0x9ede, 0x9ede, 0x9ede, 0x080c, 0x0db4,
 	0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0db4, 0x0013, 0x006e,
-	0x0005, 0x9ef1, 0xa64a, 0xa818, 0x9ef1, 0xa8a6, 0xa20d, 0x9ef1,
-	0x9ef1, 0xa5cc, 0xae4a, 0x9ef1, 0x9ef1, 0x9ef1, 0x9ef1, 0x9ef1,
-	0x9ef1, 0x080c, 0x0db4, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c,
-	0x0db4, 0x0013, 0x006e, 0x0005, 0x9f0c, 0xb51e, 0x9f0c, 0x9f0c,
-	0x9f0c, 0x9f0c, 0x9f0c, 0x9f0c, 0xb4c3, 0xb6a0, 0x9f0c, 0xb55f,
-	0xb5de, 0xb55f, 0xb5de, 0x9f0c, 0x080c, 0x0db4, 0x6000, 0x9082,
-	0x0016, 0x1a0c, 0x0db4, 0x6000, 0x0002, 0x9f28, 0xae91, 0xaf76,
-	0xb0a6, 0xb251, 0x9f28, 0x9f28, 0x9f28, 0xae65, 0xb44f, 0xb452,
-	0x9f28, 0x9f28, 0x9f28, 0x9f28, 0xb481, 0x9f28, 0x9f28, 0x9f28,
-	0x080c, 0x0db4, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0db4,
-	0x0013, 0x006e, 0x0005, 0x9f43, 0x9f43, 0x9f86, 0xa025, 0xa0ba,
-	0x9f43, 0x9f43, 0x9f43, 0x9f45, 0x9f43, 0x9f43, 0x9f43, 0x9f43,
-	0x9f43, 0x9f43, 0x9f43, 0x080c, 0x0db4, 0x9186, 0x004c, 0x0588,
-	0x9186, 0x0003, 0x190c, 0x0db4, 0x0096, 0x601c, 0xc0ed, 0x601e,
-	0x6003, 0x0003, 0x6106, 0x6014, 0x2048, 0xa87c, 0x9084, 0xa000,
-	0xc0b5, 0xa87e, 0xa8ac, 0xa846, 0xa8b0, 0xa84a, 0x9006, 0xa836,
-	0xa83a, 0xa884, 0x9092, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003,
-	0x8013, 0x8213, 0x9210, 0x621a, 0x009e, 0x2c10, 0x080c, 0x1a5e,
-	0x080c, 0x843f, 0x0126, 0x2091, 0x8000, 0x080c, 0x8a4a, 0x012e,
-	0x0005, 0x6010, 0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x080c,
-	0xa0dc, 0x080c, 0xc244, 0x6003, 0x0007, 0x0005, 0x00d6, 0x0096,
-	0x00f6, 0x2079, 0x1800, 0x7a8c, 0x6014, 0x2048, 0xa87c, 0xd0ec,
-	0x1110, 0x9290, 0x0018, 0xac78, 0xc4fc, 0x0046, 0xa8e0, 0x9005,
-	0x1140, 0xa8dc, 0x921a, 0x0140, 0x0220, 0xa87b, 0x0007, 0x2010,
-	0x0028, 0xa87b, 0x0015, 0x0010, 0xa87b, 0x0000, 0x8214, 0xa883,
-	0x0000, 0xaa02, 0x0006, 0x0016, 0x0026, 0x00c6, 0x00d6, 0x00e6,
-	0x00f6, 0x2400, 0x9005, 0x1108, 0x009a, 0x2100, 0x9086, 0x0015,
-	0x1118, 0x2001, 0x0001, 0x0038, 0x2100, 0x9086, 0x0016, 0x0118,
-	0x2001, 0x0001, 0x002a, 0x94a4, 0x0007, 0x8423, 0x9405, 0x0002,
-	0x9fed, 0x9fed, 0x9fe8, 0x9feb, 0x9fed, 0x9fe5, 0x9fd8, 0x9fd8,
-	0x9fd8, 0x9fd8, 0x9fd8, 0x9fd8, 0x9fd8, 0x9fd8, 0x9fd8, 0x9fd8,
-	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e, 0x001e, 0x000e, 0x004e,
-	0x00fe, 0x009e, 0x00de, 0x080c, 0x0db4, 0x080c, 0xaa89, 0x0028,
-	0x080c, 0xabac, 0x0010, 0x080c, 0xac9b, 0x00fe, 0x00ee, 0x00de,
-	0x00ce, 0x002e, 0x001e, 0x2c00, 0xa896, 0x000e, 0x080c, 0xa19a,
-	0x0530, 0xa804, 0xa80e, 0x00a6, 0x2050, 0xb100, 0x00ae, 0x8006,
-	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002,
-	0xaacc, 0xabd0, 0xacd4, 0xadd8, 0x2031, 0x0000, 0x2041, 0x1249,
-	0x080c, 0xa345, 0x0160, 0x000e, 0x9005, 0x0120, 0x00fe, 0x009e,
-	0x00de, 0x0005, 0x00fe, 0x009e, 0x00de, 0x0804, 0x9e42, 0x2001,
-	0x002c, 0x900e, 0x080c, 0xa200, 0x0c70, 0x91b6, 0x0015, 0x0170,
-	0x91b6, 0x0016, 0x0158, 0x91b2, 0x0047, 0x0a0c, 0x0db4, 0x91b2,
-	0x0050, 0x1a0c, 0x0db4, 0x9182, 0x0047, 0x00ca, 0x2001, 0x0109,
-	0x2004, 0xd08c, 0x0198, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016,
-	0x0026, 0x080c, 0x8393, 0x002e, 0x001e, 0x000e, 0x012e, 0xa001,
-	0x6000, 0x9086, 0x0002, 0x1110, 0x0804, 0x9f86, 0x0005, 0xa058,
-	0xa058, 0xa05a, 0xa090, 0xa058, 0xa058, 0xa058, 0xa058, 0xa0a3,
-	0x080c, 0x0db4, 0x00d6, 0x0016, 0x0096, 0x080c, 0x891d, 0x080c,
-	0x8a4a, 0x6003, 0x0004, 0x6114, 0x2148, 0xa87c, 0xd0fc, 0x01c0,
-	0xa878, 0xc0fc, 0x9005, 0x1158, 0xa894, 0x9005, 0x0140, 0x2001,
-	0x0000, 0x900e, 0x080c, 0xa200, 0x080c, 0x9e42, 0x00a8, 0x6003,
-	0x0002, 0xa8a4, 0xa9a8, 0x9105, 0x1178, 0xa8ae, 0xa8b2, 0x0c78,
-	0xa87f, 0x0020, 0xa88c, 0xa88a, 0xa8a4, 0xa8ae, 0xa8a8, 0xa8b2,
-	0xa8c7, 0x0000, 0xa8cb, 0x0000, 0x009e, 0x001e, 0x00de, 0x0005,
-	0x080c, 0x891d, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xbb2c,
-	0x0120, 0xa87b, 0x0006, 0x080c, 0x6891, 0x009e, 0x00de, 0x080c,
-	0x9e42, 0x0804, 0x8a4a, 0x080c, 0x891d, 0x080c, 0x2fdc, 0x080c,
-	0xc241, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xbb2c, 0x0120,
-	0xa87b, 0x0029, 0x080c, 0x6891, 0x009e, 0x00de, 0x080c, 0x9e42,
-	0x0804, 0x8a4a, 0x9182, 0x0047, 0x0002, 0xa0ca, 0xa0cc, 0xa0ca,
-	0xa0ca, 0xa0ca, 0xa0ca, 0xa0ca, 0xa0ca, 0xa0ca, 0xa0ca, 0xa0ca,
-	0xa0ca, 0xa0cc, 0x080c, 0x0db4, 0x00d6, 0x0096, 0x080c, 0x1511,
-	0x6114, 0x2148, 0xa87b, 0x0000, 0xa883, 0x0000, 0x080c, 0x6891,
-	0x009e, 0x00de, 0x0804, 0x9e42, 0x0026, 0x0036, 0x0056, 0x0066,
-	0x0096, 0x00a6, 0x00f6, 0x0006, 0x080c, 0x0feb, 0x000e, 0x090c,
-	0x0db4, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019, 0x21a0, 0x900e,
-	0x20a9, 0x0020, 0x4104, 0xa87a, 0x2079, 0x1800, 0x798c, 0x9188,
-	0x0018, 0x918c, 0x0fff, 0xa972, 0xac76, 0x2950, 0x00a6, 0x2001,
-	0x0205, 0x2003, 0x0000, 0x901e, 0x2029, 0x0001, 0x9182, 0x0034,
-	0x1228, 0x2011, 0x001f, 0x080c, 0xb725, 0x04c0, 0x2130, 0x2009,
-	0x0034, 0x2011, 0x001f, 0x080c, 0xb725, 0x96b2, 0x0034, 0xb004,
-	0x904d, 0x0110, 0x080c, 0x0f9d, 0x080c, 0x0feb, 0x01d0, 0x8528,
-	0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406, 0x968a, 0x003d,
-	0x1230, 0x2608, 0x2011, 0x001b, 0x080c, 0xb725, 0x00b8, 0x96b2,
-	0x003c, 0x2009, 0x003c, 0x2950, 0x2011, 0x001b, 0x080c, 0xb725,
-	0x0c18, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad,
-	0x0050, 0xb566, 0xb070, 0xc0fd, 0xb072, 0x0048, 0x2001, 0x0205,
-	0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566, 0x2a48,
-	0xa804, 0xa807, 0x0000, 0x0006, 0x080c, 0x6891, 0x000e, 0x2048,
-	0x9005, 0x1db0, 0x00fe, 0x00ae, 0x009e, 0x006e, 0x005e, 0x003e,
-	0x002e, 0x0005, 0x00d6, 0x00f6, 0x0096, 0x0006, 0x080c, 0x0feb,
-	0x000e, 0x090c, 0x0db4, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019,
-	0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104, 0xaa66, 0xa87a, 0x2079,
-	0x1800, 0x798c, 0x810c, 0x9188, 0x000c, 0x9182, 0x001a, 0x0210,
-	0x2009, 0x001a, 0x21a8, 0x810b, 0xa972, 0xac76, 0x2e98, 0xa85c,
-	0x9080, 0x001f, 0x20a0, 0x2001, 0x0205, 0x200c, 0x918d, 0x0080,
-	0x2102, 0x4003, 0x2003, 0x0000, 0x080c, 0x6891, 0x009e, 0x00fe,
-	0x00de, 0x0005, 0x0016, 0x00d6, 0x00f6, 0x0096, 0x0016, 0x2001,
-	0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x001e, 0x2079, 0x0200,
-	0x2e98, 0xa87c, 0xd0ec, 0x0118, 0x9e80, 0x000c, 0x2098, 0x2021,
-	0x003e, 0x901e, 0x9282, 0x0020, 0x0218, 0x2011, 0x0020, 0x2018,
-	0x9486, 0x003e, 0x1170, 0x0096, 0x080c, 0x0feb, 0x2900, 0x009e,
-	0x05c0, 0xa806, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
-	0x20a0, 0x3300, 0x908e, 0x0260, 0x0140, 0x2009, 0x0280, 0x9102,
-	0x920a, 0x0218, 0x2010, 0x2100, 0x9318, 0x2200, 0x9402, 0x1228,
-	0x2400, 0x9202, 0x2410, 0x9318, 0x9006, 0x2020, 0x22a8, 0xa800,
-	0x9200, 0xa802, 0x20e1, 0x0000, 0x4003, 0x83ff, 0x0180, 0x3300,
-	0x9086, 0x0280, 0x1130, 0x7814, 0x8000, 0x9085, 0x0080, 0x7816,
-	0x2e98, 0x2310, 0x84ff, 0x0904, 0xa1af, 0x0804, 0xa1b1, 0x9085,
-	0x0001, 0x7817, 0x0000, 0x009e, 0x00fe, 0x00de, 0x001e, 0x0005,
-	0x00d6, 0x0036, 0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x080c,
-	0x6884, 0x009e, 0x003e, 0x00de, 0x0005, 0x91b6, 0x0015, 0x1118,
-	0x080c, 0x9e42, 0x0030, 0x91b6, 0x0016, 0x190c, 0x0db4, 0x080c,
-	0x9e42, 0x0005, 0x20a9, 0x000e, 0x20e1, 0x0000, 0x2e98, 0x6014,
-	0x0096, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x20a0, 0x009e, 0x4003,
-	0x0136, 0x9080, 0x001b, 0x20a0, 0x2011, 0x0006, 0x20a9, 0x0001,
-	0x3418, 0x8318, 0x23a0, 0x4003, 0x3318, 0x8318, 0x2398, 0x8211,
-	0x1db8, 0x2011, 0x0006, 0x013e, 0x20a0, 0x3318, 0x8318, 0x2398,
-	0x4003, 0x3418, 0x8318, 0x23a0, 0x8211, 0x1db8, 0x0096, 0x080c,
-	0xbb2c, 0x0130, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0x009e, 0x0804, 0x9e42, 0x0096, 0x00d6, 0x0036, 0x7330, 0x9386,
-	0x0200, 0x11a8, 0x6010, 0x00b6, 0x2058, 0xb8bf, 0x0000, 0x00be,
-	0x6014, 0x9005, 0x0130, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xab32, 0x080c, 0x9e42, 0x003e, 0x00de, 0x009e, 0x0005, 0x0011,
-	0x1d48, 0x0cc8, 0x0006, 0x0016, 0x080c, 0xc22c, 0x0188, 0x6014,
-	0x9005, 0x1170, 0x600b, 0x0003, 0x601b, 0x0000, 0x6043, 0x0000,
-	0x2009, 0x0022, 0x080c, 0xa622, 0x9006, 0x001e, 0x000e, 0x0005,
-	0x9085, 0x0001, 0x0cd0, 0x0096, 0x0016, 0x20a9, 0x0014, 0x9e80,
-	0x000c, 0x20e1, 0x0000, 0x2098, 0x6014, 0x2048, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x2001, 0x0205, 0x2003,
-	0x0001, 0x2099, 0x0260, 0x20a9, 0x0016, 0x4003, 0x20a9, 0x000a,
-	0xa804, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0,
-	0x4003, 0x2001, 0x0205, 0x2003, 0x0002, 0x2099, 0x0260, 0x20a9,
-	0x0020, 0x4003, 0x2003, 0x0000, 0x6014, 0x2048, 0xa800, 0x2048,
-	0xa867, 0x0103, 0x080c, 0x9e42, 0x001e, 0x009e, 0x0005, 0x0096,
-	0x0016, 0x900e, 0x7030, 0x9086, 0x0100, 0x0140, 0x7038, 0x9084,
-	0x00ff, 0x800c, 0x703c, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0004,
-	0x9108, 0x810b, 0x2011, 0x0002, 0x2019, 0x000c, 0x6014, 0x2048,
-	0x080c, 0xb725, 0x080c, 0xbb2c, 0x0140, 0x6014, 0x2048, 0xa807,
-	0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0x9e42, 0x001e,
-	0x009e, 0x0005, 0x0016, 0x0096, 0x7030, 0x9086, 0x0100, 0x1118,
-	0x2009, 0x0004, 0x0010, 0x7034, 0x800c, 0x810b, 0x2011, 0x000c,
-	0x2019, 0x000c, 0x6014, 0x2048, 0xa804, 0x0096, 0x9005, 0x0108,
-	0x2048, 0x080c, 0xb725, 0x009e, 0x080c, 0xbb2c, 0x0148, 0xa804,
-	0x9005, 0x1158, 0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103,
-	0x080c, 0x9e42, 0x009e, 0x001e, 0x0005, 0x0086, 0x2040, 0xa030,
-	0x8007, 0x9086, 0x0100, 0x1118, 0x080c, 0xa7d1, 0x00e0, 0xa034,
-	0x8007, 0x800c, 0x8806, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
-	0xffc0, 0x9080, 0x000c, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897,
-	0x4000, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041,
-	0x122f, 0x0019, 0x0d08, 0x008e, 0x0898, 0x0096, 0x0006, 0x080c,
-	0x0feb, 0x000e, 0x01b0, 0xa8ab, 0x0dcb, 0xa876, 0x000e, 0xa8a2,
-	0x0006, 0xae6a, 0x2800, 0xa89e, 0xa97a, 0xaf72, 0xaa8e, 0xab92,
-	0xac96, 0xad9a, 0x0086, 0x2940, 0x080c, 0x10d5, 0x008e, 0x9085,
-	0x0001, 0x009e, 0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084,
-	0x00ff, 0x6210, 0x00b6, 0x2258, 0xba10, 0x00be, 0x9206, 0x1520,
-	0x700c, 0x6210, 0x00b6, 0x2258, 0xba14, 0x00be, 0x9206, 0x11e0,
-	0x6043, 0x0000, 0x2c68, 0x0016, 0x2009, 0x0035, 0x080c, 0xc1a4,
-	0x001e, 0x1158, 0x622c, 0x2268, 0x2071, 0x026c, 0x6b20, 0x9386,
-	0x0003, 0x0130, 0x9386, 0x0006, 0x0128, 0x080c, 0x9e42, 0x0020,
-	0x0039, 0x0010, 0x080c, 0xa457, 0x002e, 0x00de, 0x00ee, 0x0005,
-	0x0096, 0x6814, 0x2048, 0x9186, 0x0015, 0x0904, 0xa43f, 0x918e,
-	0x0016, 0x1904, 0xa455, 0x700c, 0x908c, 0xff00, 0x9186, 0x1700,
-	0x0120, 0x9186, 0x0300, 0x1904, 0xa419, 0x89ff, 0x1138, 0x6800,
-	0x9086, 0x000f, 0x0904, 0xa3fc, 0x0804, 0xa453, 0x6808, 0x9086,
-	0xffff, 0x1904, 0xa441, 0xa87c, 0x9084, 0x0060, 0x9086, 0x0020,
-	0x1128, 0xa83c, 0xa940, 0x9105, 0x1904, 0xa441, 0x6824, 0xd0b4,
-	0x1904, 0xa441, 0x080c, 0xbd15, 0x685c, 0xa882, 0xa87c, 0xc0dc,
-	0xc0f4, 0xc0d4, 0xa87e, 0x0026, 0x900e, 0x6a18, 0x2001, 0x000a,
-	0x080c, 0x8259, 0xa884, 0x920a, 0x0208, 0x8011, 0xaa86, 0x82ff,
-	0x002e, 0x1138, 0x00c6, 0x2d60, 0x080c, 0xb84f, 0x00ce, 0x0804,
-	0xa453, 0x00c6, 0xa868, 0xd0fc, 0x1118, 0x080c, 0x5d56, 0x0010,
-	0x080c, 0x60fd, 0x00ce, 0x1904, 0xa441, 0x00c6, 0x2d60, 0x080c,
-	0x9e42, 0x00ce, 0x0804, 0xa453, 0x00c6, 0x080c, 0x9e8f, 0x0198,
-	0x6017, 0x0000, 0x6810, 0x6012, 0x080c, 0xbfa6, 0x6023, 0x0003,
-	0x6904, 0x00c6, 0x2d60, 0x080c, 0x9e42, 0x00ce, 0x080c, 0x9ebc,
-	0x00ce, 0x0804, 0xa453, 0x2001, 0x1958, 0x2004, 0x6842, 0x00ce,
-	0x04d0, 0x7008, 0x9086, 0x000b, 0x11c8, 0x6010, 0x00b6, 0x2058,
-	0xb900, 0xc1bc, 0xb902, 0x00be, 0x00c6, 0x2d60, 0xa87b, 0x0003,
-	0x080c, 0xc1e6, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002,
-	0x080c, 0x83da, 0x080c, 0x896d, 0x00ce, 0x00e8, 0x700c, 0x9086,
-	0x2a00, 0x1138, 0x2001, 0x1958, 0x2004, 0x6842, 0x00a0, 0x0479,
-	0x00a0, 0x89ff, 0x090c, 0x0db4, 0x00c6, 0x00d6, 0x2d60, 0xa867,
-	0x0103, 0xa87b, 0x0003, 0x080c, 0x66ac, 0x080c, 0xbd15, 0x080c,
-	0x9e72, 0x00de, 0x00ce, 0x080c, 0x9e42, 0x009e, 0x0005, 0x9186,
-	0x0015, 0x1128, 0x2001, 0x1958, 0x2004, 0x6842, 0x0068, 0x918e,
-	0x0016, 0x1160, 0x00c6, 0x2d00, 0x2060, 0x080c, 0xd7a8, 0x080c,
-	0x81ed, 0x080c, 0x9e42, 0x00ce, 0x080c, 0x9e42, 0x0005, 0x0026,
-	0x0036, 0x0046, 0x7228, 0xacb0, 0xabac, 0xd2f4, 0x0130, 0x2001,
-	0x1958, 0x2004, 0x6842, 0x0804, 0xa4d1, 0x00c6, 0x2d60, 0x080c,
-	0xb750, 0x00ce, 0x6804, 0x9086, 0x0050, 0x1168, 0x00c6, 0x2d00,
-	0x2060, 0x6003, 0x0001, 0x6007, 0x0050, 0x080c, 0x83da, 0x080c,
-	0x896d, 0x00ce, 0x04f0, 0x6800, 0x9086, 0x000f, 0x01a8, 0x89ff,
-	0x090c, 0x0db4, 0x6800, 0x9086, 0x0004, 0x1190, 0xa87c, 0xd0ac,
-	0x0178, 0xa843, 0x0fff, 0xa83f, 0x0fff, 0xa880, 0xc0fc, 0xa882,
-	0x2001, 0x0001, 0x6832, 0x0400, 0x2001, 0x0007, 0x6832, 0x00e0,
-	0xa87c, 0xd0b4, 0x1150, 0xd0ac, 0x0db8, 0x6824, 0xd0f4, 0x1d48,
-	0xa838, 0xa934, 0x9105, 0x0d80, 0x0c20, 0xd2ec, 0x1d68, 0x7024,
-	0x9306, 0x1118, 0x7020, 0x9406, 0x0d38, 0x7020, 0x683e, 0x7024,
-	0x683a, 0x2001, 0x0005, 0x6832, 0x080c, 0xbe9d, 0x080c, 0x896d,
-	0x0010, 0x080c, 0x9e42, 0x004e, 0x003e, 0x002e, 0x0005, 0x00e6,
-	0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210, 0x00b6, 0x2258,
-	0xba10, 0x00be, 0x9206, 0x1904, 0xa53c, 0x700c, 0x6210, 0x00b6,
-	0x2258, 0xba14, 0x00be, 0x9206, 0x1904, 0xa53c, 0x6038, 0x2068,
-	0x6824, 0xc0dc, 0x6826, 0x6a20, 0x9286, 0x0007, 0x0904, 0xa53c,
-	0x9286, 0x0002, 0x0904, 0xa53c, 0x9286, 0x0000, 0x05e8, 0x6808,
-	0x633c, 0x9306, 0x15c8, 0x2071, 0x026c, 0x9186, 0x0015, 0x0570,
-	0x918e, 0x0016, 0x1100, 0x00c6, 0x6038, 0x2060, 0x6104, 0x9186,
-	0x004b, 0x01c0, 0x9186, 0x004c, 0x01a8, 0x9186, 0x004d, 0x0190,
-	0x9186, 0x004e, 0x0178, 0x9186, 0x0052, 0x0160, 0x6014, 0x0096,
-	0x2048, 0x080c, 0xbb2c, 0x090c, 0x0db4, 0xa87b, 0x0003, 0x009e,
-	0x080c, 0xc1e6, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002,
-	0x080c, 0x83da, 0x080c, 0x896d, 0x00ce, 0x0030, 0x6038, 0x2070,
-	0x2001, 0x1958, 0x2004, 0x7042, 0x080c, 0x9e42, 0x002e, 0x00de,
-	0x00ee, 0x0005, 0x00b6, 0x0096, 0x00f6, 0x6014, 0x2048, 0x6010,
-	0x2058, 0x91b6, 0x0015, 0x0130, 0xba08, 0xbb0c, 0xbc00, 0xc48c,
-	0xbc02, 0x0460, 0x0096, 0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90,
-	0x0010, 0x2019, 0x000a, 0x20a9, 0x0004, 0x080c, 0xae20, 0x002e,
-	0x003e, 0x015e, 0x009e, 0x1904, 0xa5ab, 0x0096, 0x0156, 0x0036,
-	0x0026, 0x2b48, 0x9e90, 0x0014, 0x2019, 0x0006, 0x20a9, 0x0004,
-	0x080c, 0xae20, 0x002e, 0x003e, 0x015e, 0x009e, 0x15a0, 0x7238,
-	0xba0a, 0x733c, 0xbb0e, 0xbc00, 0xc48d, 0xbc02, 0xa804, 0x9005,
-	0x1128, 0x00fe, 0x009e, 0x00be, 0x0804, 0xa246, 0x0096, 0x2048,
-	0xaa12, 0xab16, 0xac0a, 0x009e, 0x8006, 0x8006, 0x8007, 0x90bc,
-	0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009, 0x002b, 0xaaa0,
-	0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x122f, 0x080c,
-	0xa345, 0x0130, 0x00fe, 0x009e, 0x080c, 0x9e42, 0x00be, 0x0005,
-	0x080c, 0xa7d1, 0x0cb8, 0x2b78, 0x00f6, 0x080c, 0x2fdc, 0x080c,
-	0xc241, 0x00fe, 0x00c6, 0x080c, 0x9dec, 0x2f00, 0x6012, 0x6017,
-	0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x2001,
-	0x0007, 0x080c, 0x6198, 0x080c, 0x61c4, 0x080c, 0x8422, 0x080c,
-	0x896d, 0x00ce, 0x0804, 0xa57e, 0x2100, 0x91b2, 0x0053, 0x1a0c,
-	0x0db4, 0x91b2, 0x0040, 0x1a04, 0xa634, 0x0002, 0xa622, 0xa622,
-	0xa618, 0xa622, 0xa622, 0xa622, 0xa616, 0xa616, 0xa616, 0xa616,
-	0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616,
-	0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616,
-	0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa622, 0xa616, 0xa622,
-	0xa622, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa618, 0xa616,
-	0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616,
-	0xa622, 0xa622, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616, 0xa616,
-	0xa616, 0xa616, 0xa616, 0xa622, 0xa616, 0xa616, 0x080c, 0x0db4,
-	0x0066, 0x00b6, 0x6610, 0x2658, 0xb8bc, 0xc08c, 0xb8be, 0x00be,
-	0x006e, 0x0000, 0x6003, 0x0001, 0x6106, 0x9186, 0x0032, 0x0118,
-	0x080c, 0x8422, 0x0010, 0x080c, 0x83da, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x896d, 0x012e, 0x0005, 0x2600, 0x0002, 0xa648, 0xa648,
-	0xa648, 0xa622, 0xa622, 0xa648, 0xa648, 0xa648, 0xa648, 0xa622,
-	0xa648, 0xa622, 0xa648, 0xa622, 0xa648, 0xa648, 0xa648, 0xa648,
-	0x080c, 0x0db4, 0x6004, 0x90b2, 0x0053, 0x1a0c, 0x0db4, 0x91b6,
-	0x0013, 0x0904, 0xa70c, 0x91b6, 0x0027, 0x1904, 0xa6c7, 0x080c,
-	0x8861, 0x6004, 0x080c, 0xbd21, 0x01b0, 0x080c, 0xbd32, 0x01a8,
-	0x908e, 0x0021, 0x0904, 0xa6c4, 0x908e, 0x0022, 0x1130, 0x080c,
-	0xa272, 0x0904, 0xa6c0, 0x0804, 0xa6c1, 0x908e, 0x003d, 0x0904,
-	0xa6c4, 0x0804, 0xa6ba, 0x080c, 0x3005, 0x2001, 0x0007, 0x080c,
-	0x6198, 0x6010, 0x00b6, 0x2058, 0xb9a0, 0x00be, 0x080c, 0xa7d1,
-	0x9186, 0x007e, 0x1148, 0x2001, 0x1836, 0x2014, 0xc285, 0x080c,
-	0x6f9b, 0x1108, 0xc2ad, 0x2202, 0x0036, 0x0026, 0x2019, 0x0028,
-	0x2110, 0x080c, 0xd803, 0x002e, 0x003e, 0x0016, 0x0026, 0x0036,
-	0x2110, 0x2019, 0x0028, 0x080c, 0x8564, 0x0076, 0x903e, 0x080c,
-	0x8452, 0x6010, 0x00b6, 0x905d, 0x0100, 0x00be, 0x2c08, 0x080c,
-	0xd2bc, 0x007e, 0x003e, 0x002e, 0x001e, 0x080c, 0xc241, 0x0016,
-	0x080c, 0xbf9e, 0x080c, 0x9e42, 0x001e, 0x080c, 0x30d7, 0x080c,
-	0x896d, 0x0030, 0x080c, 0xbf9e, 0x080c, 0x9e42, 0x080c, 0x896d,
-	0x0005, 0x080c, 0xa7d1, 0x0cb0, 0x080c, 0xa80d, 0x0c98, 0x9186,
-	0x0014, 0x1db0, 0x080c, 0x8861, 0x6004, 0x908e, 0x0022, 0x1118,
-	0x080c, 0xa272, 0x0d68, 0x080c, 0x2fdc, 0x080c, 0xc241, 0x080c,
-	0xbd21, 0x1190, 0x080c, 0x3005, 0x6010, 0x00b6, 0x2058, 0xb9a0,
-	0x00be, 0x080c, 0xa7d1, 0x9186, 0x007e, 0x1128, 0x2001, 0x1836,
-	0x200c, 0xc185, 0x2102, 0x0870, 0x080c, 0xbd32, 0x1118, 0x080c,
-	0xa7d1, 0x0840, 0x6004, 0x908e, 0x0032, 0x1160, 0x00e6, 0x00f6,
-	0x2071, 0x1894, 0x2079, 0x0000, 0x080c, 0x336b, 0x00fe, 0x00ee,
-	0x0804, 0xa6ba, 0x6004, 0x908e, 0x0021, 0x0d48, 0x908e, 0x0022,
-	0x090c, 0xa7d1, 0x0804, 0xa6ba, 0x90b2, 0x0040, 0x1a04, 0xa7ba,
-	0x2008, 0x0002, 0xa754, 0xa755, 0xa758, 0xa75b, 0xa75e, 0xa761,
-	0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752,
-	0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752,
-	0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752, 0xa752,
-	0xa764, 0xa76f, 0xa752, 0xa771, 0xa76f, 0xa752, 0xa752, 0xa752,
-	0xa752, 0xa752, 0xa76f, 0xa76f, 0xa752, 0xa752, 0xa752, 0xa752,
-	0xa752, 0xa752, 0xa752, 0xa752, 0xa7a1, 0xa76f, 0xa752, 0xa76b,
-	0xa752, 0xa752, 0xa752, 0xa76c, 0xa752, 0xa752, 0xa752, 0xa76f,
-	0xa798, 0xa752, 0x080c, 0x0db4, 0x00d0, 0x2001, 0x000b, 0x0410,
-	0x2001, 0x0003, 0x00f8, 0x2001, 0x0005, 0x00e0, 0x2001, 0x0001,
-	0x00c8, 0x2001, 0x0009, 0x00b0, 0x080c, 0x8861, 0x6003, 0x0005,
-	0x080c, 0x896d, 0x0070, 0x0018, 0x0010, 0x080c, 0x6198, 0x0804,
-	0xa7b2, 0x080c, 0x8861, 0x080c, 0xc244, 0x6003, 0x0004, 0x080c,
-	0x896d, 0x0005, 0x080c, 0x6198, 0x080c, 0x8861, 0x6003, 0x0002,
-	0x0036, 0x2019, 0x185e, 0x2304, 0x9084, 0xff00, 0x1120, 0x2001,
-	0x1956, 0x201c, 0x0040, 0x8007, 0x909a, 0x0004, 0x0ec0, 0x8003,
-	0x801b, 0x831b, 0x9318, 0x631a, 0x003e, 0x080c, 0x896d, 0x0c08,
-	0x080c, 0x8861, 0x080c, 0xbf9e, 0x080c, 0x9e42, 0x080c, 0x896d,
-	0x08c0, 0x00e6, 0x00f6, 0x2071, 0x1894, 0x2079, 0x0000, 0x080c,
-	0x336b, 0x00fe, 0x00ee, 0x080c, 0x8861, 0x080c, 0x9e42, 0x080c,
-	0x896d, 0x0838, 0x080c, 0x8861, 0x6003, 0x0002, 0x080c, 0xc244,
-	0x0804, 0x896d, 0x2600, 0x2008, 0x0002, 0xa7cf, 0xa7cf, 0xa7cf,
-	0xa7b2, 0xa7b2, 0xa7cf, 0xa7cf, 0xa7cf, 0xa7cf, 0xa7b2, 0xa7cf,
-	0xa7b2, 0xa7cf, 0xa7b2, 0xa7cf, 0xa7cf, 0xa7cf, 0xa7cf, 0x080c,
-	0x0db4, 0x00e6, 0x0096, 0x0026, 0x0016, 0x080c, 0xbb2c, 0x0568,
-	0x6014, 0x2048, 0xa864, 0x9086, 0x0139, 0x11a8, 0xa894, 0x9086,
-	0x0056, 0x1148, 0x080c, 0x5138, 0x0130, 0x2001, 0x0000, 0x900e,
-	0x2011, 0x4000, 0x0028, 0x2001, 0x0030, 0x900e, 0x2011, 0x4005,
-	0x080c, 0xc10b, 0x0090, 0xa868, 0xd0fc, 0x0178, 0xa807, 0x0000,
-	0x0016, 0x6004, 0x908e, 0x0021, 0x0168, 0x908e, 0x003d, 0x0150,
-	0x001e, 0xa867, 0x0103, 0xa833, 0x0100, 0x001e, 0x002e, 0x009e,
-	0x00ee, 0x0005, 0x001e, 0x0009, 0x0cc0, 0x0096, 0x6014, 0x2048,
-	0xa800, 0x2048, 0xa867, 0x0103, 0xa823, 0x8001, 0x009e, 0x0005,
-	0x00b6, 0x6610, 0x2658, 0xb804, 0x9084, 0x00ff, 0x90b2, 0x000c,
-	0x1a0c, 0x0db4, 0x6604, 0x96b6, 0x004d, 0x1120, 0x080c, 0xc02a,
-	0x0804, 0xa895, 0x6604, 0x96b6, 0x0043, 0x1120, 0x080c, 0xc073,
-	0x0804, 0xa895, 0x6604, 0x96b6, 0x004b, 0x1120, 0x080c, 0xc09f,
-	0x0804, 0xa895, 0x6604, 0x96b6, 0x0033, 0x1120, 0x080c, 0xbfc0,
-	0x0804, 0xa895, 0x6604, 0x96b6, 0x0028, 0x1120, 0x080c, 0xbd70,
-	0x0804, 0xa895, 0x6604, 0x96b6, 0x0029, 0x1120, 0x080c, 0xbdb1,
-	0x0804, 0xa895, 0x6604, 0x96b6, 0x001f, 0x1118, 0x080c, 0xa21a,
-	0x04e0, 0x6604, 0x96b6, 0x0000, 0x1118, 0x080c, 0xa542, 0x04a8,
-	0x6604, 0x96b6, 0x0022, 0x1118, 0x080c, 0xa253, 0x0470, 0x6604,
-	0x96b6, 0x0035, 0x1118, 0x080c, 0xa363, 0x0438, 0x6604, 0x96b6,
-	0x0039, 0x1118, 0x080c, 0xa4d7, 0x0400, 0x6604, 0x96b6, 0x003d,
-	0x1118, 0x080c, 0xa28b, 0x00c8, 0x6604, 0x96b6, 0x0044, 0x1118,
-	0x080c, 0xa2c7, 0x0090, 0x6604, 0x96b6, 0x0049, 0x1118, 0x080c,
-	0xa2f2, 0x0058, 0x91b6, 0x0015, 0x1110, 0x0063, 0x0030, 0x91b6,
-	0x0016, 0x1128, 0x00be, 0x0804, 0xab55, 0x00be, 0x0005, 0x080c,
-	0x9ed7, 0x0cd8, 0xa8b2, 0xa8b5, 0xa8b2, 0xa8f9, 0xa8b2, 0xaa89,
-	0xab62, 0xa8b2, 0xa8b2, 0xab2f, 0xa8b2, 0xab43, 0x0096, 0x080c,
-	0x1511, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103, 0x009e,
-	0x0804, 0x9e42, 0xa001, 0xa001, 0x0005, 0x00e6, 0x2071, 0x1800,
-	0x708c, 0x9086, 0x0074, 0x1540, 0x080c, 0xd28d, 0x11b0, 0x6010,
-	0x00b6, 0x2058, 0x7030, 0xd08c, 0x0128, 0xb800, 0xd0bc, 0x0110,
-	0xc0c5, 0xb802, 0x00e9, 0x00be, 0x2001, 0x0006, 0x080c, 0x6198,
-	0x080c, 0x3005, 0x080c, 0x9e42, 0x0088, 0x2001, 0x000a, 0x080c,
-	0x6198, 0x080c, 0x3005, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c,
-	0x8422, 0x080c, 0x896d, 0x0010, 0x080c, 0xaa74, 0x00ee, 0x0005,
-	0x00d6, 0xb800, 0xd084, 0x0158, 0x9006, 0x080c, 0x6184, 0x2069,
-	0x1853, 0x6804, 0x0020, 0x2001, 0x0006, 0x080c, 0x61c4, 0x00de,
-	0x0005, 0x00b6, 0x0096, 0x00d6, 0x2011, 0x1823, 0x2204, 0x9086,
-	0x0074, 0x1904, 0xaa4b, 0x6010, 0x2058, 0xbaa0, 0x9286, 0x007e,
-	0x1120, 0x080c, 0xaca6, 0x0804, 0xa9b0, 0x00d6, 0x080c, 0x6f9b,
-	0x0198, 0x0026, 0x2011, 0x0010, 0x080c, 0x658f, 0x002e, 0x05c8,
-	0x080c, 0x53a3, 0x1540, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867,
-	0x0103, 0xa833, 0xdead, 0x00f8, 0x0026, 0x2011, 0x8008, 0x080c,
-	0x658f, 0x002e, 0x0530, 0x6014, 0x2048, 0xa864, 0x9084, 0x00ff,
-	0x9086, 0x0039, 0x1140, 0x2001, 0x0030, 0x900e, 0x2011, 0x4009,
-	0x080c, 0xc10b, 0x0040, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867,
-	0x0103, 0xa833, 0xdead, 0x6010, 0x2058, 0xb9a0, 0x0016, 0x080c,
-	0x3005, 0x080c, 0x9e42, 0x001e, 0x080c, 0x30d7, 0x00de, 0x0804,
-	0xaa4e, 0x00de, 0x080c, 0xac9b, 0x6010, 0x2058, 0xbaa0, 0x9286,
-	0x0080, 0x1510, 0x6014, 0x9005, 0x01a8, 0x2048, 0xa864, 0x9084,
+	0x0005, 0x9ef9, 0xb51d, 0x9ef9, 0x9ef9, 0x9ef9, 0x9ef9, 0x9ef9,
+	0x9ef9, 0xb4bf, 0xb69f, 0x9ef9, 0xb55e, 0xb5dd, 0xb55e, 0xb5dd,
+	0x9ef9, 0x080c, 0x0db4, 0x6000, 0x9082, 0x0016, 0x1a0c, 0x0db4,
+	0x6000, 0x0002, 0x9f15, 0xae8d, 0xaf72, 0xb0a2, 0xb24d, 0x9f15,
+	0x9f15, 0x9f15, 0xae61, 0xb44b, 0xb44e, 0x9f15, 0x9f15, 0x9f15,
+	0x9f15, 0xb47d, 0x9f15, 0x9f15, 0x9f15, 0x080c, 0x0db4, 0x0066,
+	0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0db4, 0x0013, 0x006e, 0x0005,
+	0x9f30, 0x9f30, 0x9f73, 0xa012, 0xa0a7, 0x9f30, 0x9f30, 0x9f30,
+	0x9f32, 0x9f30, 0x9f30, 0x9f30, 0x9f30, 0x9f30, 0x9f30, 0x9f30,
+	0x080c, 0x0db4, 0x9186, 0x004c, 0x0588, 0x9186, 0x0003, 0x190c,
+	0x0db4, 0x0096, 0x601c, 0xc0ed, 0x601e, 0x6003, 0x0003, 0x6106,
+	0x6014, 0x2048, 0xa87c, 0x9084, 0xa000, 0xc0b5, 0xa87e, 0xa8ac,
+	0xa846, 0xa8b0, 0xa84a, 0x9006, 0xa836, 0xa83a, 0xa884, 0x9092,
+	0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x8013, 0x8213, 0x9210,
+	0x621a, 0x009e, 0x2c10, 0x080c, 0x1a69, 0x080c, 0x845d, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x8a68, 0x012e, 0x0005, 0x6010, 0x00b6,
+	0x2058, 0xbca0, 0x00be, 0x2c00, 0x080c, 0xa0c9, 0x080c, 0xc253,
+	0x6003, 0x0007, 0x0005, 0x00d6, 0x0096, 0x00f6, 0x2079, 0x1800,
+	0x7a8c, 0x6014, 0x2048, 0xa87c, 0xd0ec, 0x1110, 0x9290, 0x0018,
+	0xac78, 0xc4fc, 0x0046, 0xa8e0, 0x9005, 0x1140, 0xa8dc, 0x921a,
+	0x0140, 0x0220, 0xa87b, 0x0007, 0x2010, 0x0028, 0xa87b, 0x0015,
+	0x0010, 0xa87b, 0x0000, 0x8214, 0xa883, 0x0000, 0xaa02, 0x0006,
+	0x0016, 0x0026, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2400, 0x9005,
+	0x1108, 0x009a, 0x2100, 0x9086, 0x0015, 0x1118, 0x2001, 0x0001,
+	0x0038, 0x2100, 0x9086, 0x0016, 0x0118, 0x2001, 0x0001, 0x002a,
+	0x94a4, 0x0007, 0x8423, 0x9405, 0x0002, 0x9fda, 0x9fda, 0x9fd5,
+	0x9fd8, 0x9fda, 0x9fd2, 0x9fc5, 0x9fc5, 0x9fc5, 0x9fc5, 0x9fc5,
+	0x9fc5, 0x9fc5, 0x9fc5, 0x9fc5, 0x9fc5, 0x00fe, 0x00ee, 0x00de,
+	0x00ce, 0x002e, 0x001e, 0x000e, 0x004e, 0x00fe, 0x009e, 0x00de,
+	0x080c, 0x0db4, 0x080c, 0xaa85, 0x0028, 0x080c, 0xaba8, 0x0010,
+	0x080c, 0xac97, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e, 0x001e,
+	0x2c00, 0xa896, 0x000e, 0x080c, 0xa187, 0x0530, 0xa804, 0xa80e,
+	0x00a6, 0x2050, 0xb100, 0x00ae, 0x8006, 0x8006, 0x8007, 0x90bc,
+	0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0xaacc, 0xabd0, 0xacd4,
+	0xadd8, 0x2031, 0x0000, 0x2041, 0x1249, 0x080c, 0xa332, 0x0160,
+	0x000e, 0x9005, 0x0120, 0x00fe, 0x009e, 0x00de, 0x0005, 0x00fe,
+	0x009e, 0x00de, 0x0804, 0x9e2f, 0x2001, 0x002c, 0x900e, 0x080c,
+	0xa1ed, 0x0c70, 0x91b6, 0x0015, 0x0170, 0x91b6, 0x0016, 0x0158,
+	0x91b2, 0x0047, 0x0a0c, 0x0db4, 0x91b2, 0x0050, 0x1a0c, 0x0db4,
+	0x9182, 0x0047, 0x00ca, 0x2001, 0x0109, 0x2004, 0xd08c, 0x0198,
+	0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x83b1,
+	0x002e, 0x001e, 0x000e, 0x012e, 0xa001, 0x6000, 0x9086, 0x0002,
+	0x1110, 0x0804, 0x9f73, 0x0005, 0xa045, 0xa045, 0xa047, 0xa07d,
+	0xa045, 0xa045, 0xa045, 0xa045, 0xa090, 0x080c, 0x0db4, 0x00d6,
+	0x0016, 0x0096, 0x080c, 0x893b, 0x080c, 0x8a68, 0x6003, 0x0004,
+	0x6114, 0x2148, 0xa87c, 0xd0fc, 0x01c0, 0xa878, 0xc0fc, 0x9005,
+	0x1158, 0xa894, 0x9005, 0x0140, 0x2001, 0x0000, 0x900e, 0x080c,
+	0xa1ed, 0x080c, 0x9e2f, 0x00a8, 0x6003, 0x0002, 0xa8a4, 0xa9a8,
+	0x9105, 0x1178, 0xa8ae, 0xa8b2, 0x0c78, 0xa87f, 0x0020, 0xa88c,
+	0xa88a, 0xa8a4, 0xa8ae, 0xa8a8, 0xa8b2, 0xa8c7, 0x0000, 0xa8cb,
+	0x0000, 0x009e, 0x001e, 0x00de, 0x0005, 0x080c, 0x893b, 0x00d6,
+	0x0096, 0x6114, 0x2148, 0x080c, 0xbb3b, 0x0120, 0xa87b, 0x0006,
+	0x080c, 0x68a0, 0x009e, 0x00de, 0x080c, 0x9e2f, 0x0804, 0x8a68,
+	0x080c, 0x893b, 0x080c, 0x2fe7, 0x080c, 0xc250, 0x00d6, 0x0096,
+	0x6114, 0x2148, 0x080c, 0xbb3b, 0x0120, 0xa87b, 0x0029, 0x080c,
+	0x68a0, 0x009e, 0x00de, 0x080c, 0x9e2f, 0x0804, 0x8a68, 0x9182,
+	0x0047, 0x0002, 0xa0b7, 0xa0b9, 0xa0b7, 0xa0b7, 0xa0b7, 0xa0b7,
+	0xa0b7, 0xa0b7, 0xa0b7, 0xa0b7, 0xa0b7, 0xa0b7, 0xa0b9, 0x080c,
+	0x0db4, 0x00d6, 0x0096, 0x080c, 0x1511, 0x6114, 0x2148, 0xa87b,
+	0x0000, 0xa883, 0x0000, 0x080c, 0x68a0, 0x009e, 0x00de, 0x0804,
+	0x9e2f, 0x0026, 0x0036, 0x0056, 0x0066, 0x0096, 0x00a6, 0x00f6,
+	0x0006, 0x080c, 0x0feb, 0x000e, 0x090c, 0x0db4, 0xa960, 0x21e8,
+	0xa95c, 0x9188, 0x0019, 0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104,
+	0xa87a, 0x2079, 0x1800, 0x798c, 0x9188, 0x0018, 0x918c, 0x0fff,
+	0xa972, 0xac76, 0x2950, 0x00a6, 0x2001, 0x0205, 0x2003, 0x0000,
+	0x901e, 0x2029, 0x0001, 0x9182, 0x0034, 0x1228, 0x2011, 0x001f,
+	0x080c, 0xb724, 0x04c0, 0x2130, 0x2009, 0x0034, 0x2011, 0x001f,
+	0x080c, 0xb724, 0x96b2, 0x0034, 0xb004, 0x904d, 0x0110, 0x080c,
+	0x0f9d, 0x080c, 0x0feb, 0x01d0, 0x8528, 0xa867, 0x0110, 0xa86b,
+	0x0000, 0x2920, 0xb406, 0x968a, 0x003d, 0x1230, 0x2608, 0x2011,
+	0x001b, 0x080c, 0xb724, 0x00b8, 0x96b2, 0x003c, 0x2009, 0x003c,
+	0x2950, 0x2011, 0x001b, 0x080c, 0xb724, 0x0c18, 0x2001, 0x0205,
+	0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566, 0xb070,
+	0xc0fd, 0xb072, 0x0048, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae,
+	0x852f, 0x95ad, 0x0050, 0xb566, 0x2a48, 0xa804, 0xa807, 0x0000,
+	0x0006, 0x080c, 0x68a0, 0x000e, 0x2048, 0x9005, 0x1db0, 0x00fe,
+	0x00ae, 0x009e, 0x006e, 0x005e, 0x003e, 0x002e, 0x0005, 0x00d6,
+	0x00f6, 0x0096, 0x0006, 0x080c, 0x0feb, 0x000e, 0x090c, 0x0db4,
+	0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019, 0x21a0, 0x900e, 0x20a9,
+	0x0020, 0x4104, 0xaa66, 0xa87a, 0x2079, 0x1800, 0x798c, 0x810c,
+	0x9188, 0x000c, 0x9182, 0x001a, 0x0210, 0x2009, 0x001a, 0x21a8,
+	0x810b, 0xa972, 0xac76, 0x2e98, 0xa85c, 0x9080, 0x001f, 0x20a0,
+	0x2001, 0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x4003, 0x2003,
+	0x0000, 0x080c, 0x68a0, 0x009e, 0x00fe, 0x00de, 0x0005, 0x0016,
+	0x00d6, 0x00f6, 0x0096, 0x0016, 0x2001, 0x0205, 0x200c, 0x918d,
+	0x0080, 0x2102, 0x001e, 0x2079, 0x0200, 0x2e98, 0xa87c, 0xd0ec,
+	0x0118, 0x9e80, 0x000c, 0x2098, 0x2021, 0x003e, 0x901e, 0x9282,
+	0x0020, 0x0218, 0x2011, 0x0020, 0x2018, 0x9486, 0x003e, 0x1170,
+	0x0096, 0x080c, 0x0feb, 0x2900, 0x009e, 0x05c0, 0xa806, 0x2048,
+	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x3300, 0x908e,
+	0x0260, 0x0140, 0x2009, 0x0280, 0x9102, 0x920a, 0x0218, 0x2010,
+	0x2100, 0x9318, 0x2200, 0x9402, 0x1228, 0x2400, 0x9202, 0x2410,
+	0x9318, 0x9006, 0x2020, 0x22a8, 0xa800, 0x9200, 0xa802, 0x20e1,
+	0x0000, 0x4003, 0x83ff, 0x0180, 0x3300, 0x9086, 0x0280, 0x1130,
+	0x7814, 0x8000, 0x9085, 0x0080, 0x7816, 0x2e98, 0x2310, 0x84ff,
+	0x0904, 0xa19c, 0x0804, 0xa19e, 0x9085, 0x0001, 0x7817, 0x0000,
+	0x009e, 0x00fe, 0x00de, 0x001e, 0x0005, 0x00d6, 0x0036, 0x0096,
+	0x6314, 0x2348, 0xa87a, 0xa982, 0x080c, 0x6893, 0x009e, 0x003e,
+	0x00de, 0x0005, 0x91b6, 0x0015, 0x1118, 0x080c, 0x9e2f, 0x0030,
+	0x91b6, 0x0016, 0x190c, 0x0db4, 0x080c, 0x9e2f, 0x0005, 0x20a9,
+	0x000e, 0x20e1, 0x0000, 0x2e98, 0x6014, 0x0096, 0x2048, 0xa860,
+	0x20e8, 0xa85c, 0x20a0, 0x009e, 0x4003, 0x0136, 0x9080, 0x001b,
+	0x20a0, 0x2011, 0x0006, 0x20a9, 0x0001, 0x3418, 0x8318, 0x23a0,
+	0x4003, 0x3318, 0x8318, 0x2398, 0x8211, 0x1db8, 0x2011, 0x0006,
+	0x013e, 0x20a0, 0x3318, 0x8318, 0x2398, 0x4003, 0x3418, 0x8318,
+	0x23a0, 0x8211, 0x1db8, 0x0096, 0x080c, 0xbb3b, 0x0130, 0x6014,
+	0x2048, 0xa807, 0x0000, 0xa867, 0x0103, 0x009e, 0x0804, 0x9e2f,
+	0x0096, 0x00d6, 0x0036, 0x7330, 0x9386, 0x0200, 0x11a8, 0x6010,
+	0x00b6, 0x2058, 0xb8bf, 0x0000, 0x00be, 0x6014, 0x9005, 0x0130,
+	0x2048, 0xa807, 0x0000, 0xa867, 0x0103, 0xab32, 0x080c, 0x9e2f,
+	0x003e, 0x00de, 0x009e, 0x0005, 0x0011, 0x1d48, 0x0cc8, 0x0006,
+	0x0016, 0x080c, 0xc23b, 0x0188, 0x6014, 0x9005, 0x1170, 0x600b,
+	0x0003, 0x601b, 0x0000, 0x6043, 0x0000, 0x2009, 0x0022, 0x080c,
+	0xa61c, 0x9006, 0x001e, 0x000e, 0x0005, 0x9085, 0x0001, 0x0cd0,
+	0x0096, 0x0016, 0x20a9, 0x0014, 0x9e80, 0x000c, 0x20e1, 0x0000,
+	0x2098, 0x6014, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
+	0x20a0, 0x4003, 0x2001, 0x0205, 0x2003, 0x0001, 0x2099, 0x0260,
+	0x20a9, 0x0016, 0x4003, 0x20a9, 0x000a, 0xa804, 0x2048, 0xa860,
+	0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x2001, 0x0205,
+	0x2003, 0x0002, 0x2099, 0x0260, 0x20a9, 0x0020, 0x4003, 0x2003,
+	0x0000, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103, 0x080c,
+	0x9e2f, 0x001e, 0x009e, 0x0005, 0x0096, 0x0016, 0x900e, 0x7030,
+	0x9086, 0x0100, 0x0140, 0x7038, 0x9084, 0x00ff, 0x800c, 0x703c,
+	0x9084, 0x00ff, 0x8004, 0x9080, 0x0004, 0x9108, 0x810b, 0x2011,
+	0x0002, 0x2019, 0x000c, 0x6014, 0x2048, 0x080c, 0xb724, 0x080c,
+	0xbb3b, 0x0140, 0x6014, 0x2048, 0xa807, 0x0000, 0xa864, 0xa8e2,
+	0xa867, 0x0103, 0x080c, 0x9e2f, 0x001e, 0x009e, 0x0005, 0x0016,
+	0x0096, 0x7030, 0x9086, 0x0100, 0x1118, 0x2009, 0x0004, 0x0010,
+	0x7034, 0x800c, 0x810b, 0x2011, 0x000c, 0x2019, 0x000c, 0x6014,
+	0x2048, 0xa804, 0x0096, 0x9005, 0x0108, 0x2048, 0x080c, 0xb724,
+	0x009e, 0x080c, 0xbb3b, 0x0148, 0xa804, 0x9005, 0x1158, 0xa807,
+	0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0x9e2f, 0x009e,
+	0x001e, 0x0005, 0x0086, 0x2040, 0xa030, 0x8007, 0x9086, 0x0100,
+	0x1118, 0x080c, 0xa7cd, 0x00e0, 0xa034, 0x8007, 0x800c, 0x8806,
+	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x000c,
+	0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xaaa0, 0xab9c,
+	0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x122f, 0x0019, 0x0d08,
+	0x008e, 0x0898, 0x0096, 0x0006, 0x080c, 0x0feb, 0x000e, 0x01b0,
+	0xa8ab, 0x0dcb, 0xa876, 0x000e, 0xa8a2, 0x0006, 0xae6a, 0x2800,
+	0xa89e, 0xa97a, 0xaf72, 0xaa8e, 0xab92, 0xac96, 0xad9a, 0x0086,
+	0x2940, 0x080c, 0x10d5, 0x008e, 0x9085, 0x0001, 0x009e, 0x0005,
+	0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210, 0x00b6,
+	0x2258, 0xba10, 0x00be, 0x9206, 0x1520, 0x700c, 0x6210, 0x00b6,
+	0x2258, 0xba14, 0x00be, 0x9206, 0x11e0, 0x6043, 0x0000, 0x2c68,
+	0x0016, 0x2009, 0x0035, 0x080c, 0xc1b3, 0x001e, 0x1158, 0x622c,
+	0x2268, 0x2071, 0x026c, 0x6b20, 0x9386, 0x0003, 0x0130, 0x9386,
+	0x0006, 0x0128, 0x080c, 0x9e2f, 0x0020, 0x0039, 0x0010, 0x080c,
+	0xa451, 0x002e, 0x00de, 0x00ee, 0x0005, 0x0096, 0x6814, 0x2048,
+	0x9186, 0x0015, 0x0904, 0xa439, 0x918e, 0x0016, 0x1904, 0xa44f,
+	0x700c, 0x908c, 0xff00, 0x9186, 0x1700, 0x0120, 0x9186, 0x0300,
+	0x1904, 0xa413, 0x89ff, 0x1138, 0x6800, 0x9086, 0x000f, 0x0904,
+	0xa3f6, 0x0804, 0xa44d, 0x6808, 0x9086, 0xffff, 0x1904, 0xa43b,
+	0xa87c, 0x9084, 0x0060, 0x9086, 0x0020, 0x1128, 0xa83c, 0xa940,
+	0x9105, 0x1904, 0xa43b, 0x6824, 0xd084, 0x1904, 0xa43b, 0xd0b4,
+	0x0158, 0x0016, 0x2001, 0x195e, 0x200c, 0x6018, 0x9102, 0x9082,
+	0x0005, 0x001e, 0x1a04, 0xa43b, 0x080c, 0xbd24, 0x685c, 0xa882,
+	0xa87c, 0xc0dc, 0xc0f4, 0xc0d4, 0xa87e, 0x0026, 0x900e, 0x6a18,
+	0x2001, 0x000a, 0x080c, 0x8277, 0xa884, 0x920a, 0x0208, 0x8011,
+	0xaa86, 0x82ff, 0x002e, 0x1138, 0x00c6, 0x2d60, 0x080c, 0xb84e,
+	0x00ce, 0x0804, 0xa44d, 0x00c6, 0xa868, 0xd0fc, 0x1118, 0x080c,
+	0x5d61, 0x0010, 0x080c, 0x610c, 0x00ce, 0x1904, 0xa43b, 0x00c6,
+	0x2d60, 0x080c, 0x9e2f, 0x00ce, 0x0804, 0xa44d, 0x00c6, 0x080c,
+	0x9e7c, 0x0198, 0x6017, 0x0000, 0x6810, 0x6012, 0x080c, 0xbfb5,
+	0x6023, 0x0003, 0x6904, 0x00c6, 0x2d60, 0x080c, 0x9e2f, 0x00ce,
+	0x080c, 0x9ea9, 0x00ce, 0x0804, 0xa44d, 0x2001, 0x1960, 0x2004,
+	0x6842, 0x00ce, 0x04d0, 0x7008, 0x9086, 0x000b, 0x11c8, 0x6010,
+	0x00b6, 0x2058, 0xb900, 0xc1bc, 0xb902, 0x00be, 0x00c6, 0x2d60,
+	0xa87b, 0x0003, 0x080c, 0xc1f5, 0x6007, 0x0085, 0x6003, 0x000b,
+	0x6023, 0x0002, 0x080c, 0x83f8, 0x080c, 0x898b, 0x00ce, 0x00e8,
+	0x700c, 0x9086, 0x2a00, 0x1138, 0x2001, 0x1960, 0x2004, 0x6842,
+	0x00a0, 0x0479, 0x00a0, 0x89ff, 0x090c, 0x0db4, 0x00c6, 0x00d6,
+	0x2d60, 0xa867, 0x0103, 0xa87b, 0x0003, 0x080c, 0x66bb, 0x080c,
+	0xbd24, 0x080c, 0x9e5f, 0x00de, 0x00ce, 0x080c, 0x9e2f, 0x009e,
+	0x0005, 0x9186, 0x0015, 0x1128, 0x2001, 0x1960, 0x2004, 0x6842,
+	0x0068, 0x918e, 0x0016, 0x1160, 0x00c6, 0x2d00, 0x2060, 0x080c,
+	0xd7c1, 0x080c, 0x820b, 0x080c, 0x9e2f, 0x00ce, 0x080c, 0x9e2f,
+	0x0005, 0x0026, 0x0036, 0x0046, 0x7228, 0xacb0, 0xabac, 0xd2f4,
+	0x0130, 0x2001, 0x1960, 0x2004, 0x6842, 0x0804, 0xa4cb, 0x00c6,
+	0x2d60, 0x080c, 0xb74f, 0x00ce, 0x6804, 0x9086, 0x0050, 0x1168,
+	0x00c6, 0x2d00, 0x2060, 0x6003, 0x0001, 0x6007, 0x0050, 0x080c,
+	0x83f8, 0x080c, 0x898b, 0x00ce, 0x04f0, 0x6800, 0x9086, 0x000f,
+	0x01a8, 0x89ff, 0x090c, 0x0db4, 0x6800, 0x9086, 0x0004, 0x1190,
+	0xa87c, 0xd0ac, 0x0178, 0xa843, 0x0fff, 0xa83f, 0x0fff, 0xa880,
+	0xc0fc, 0xa882, 0x2001, 0x0001, 0x6832, 0x0400, 0x2001, 0x0007,
+	0x6832, 0x00e0, 0xa87c, 0xd0b4, 0x1150, 0xd0ac, 0x0db8, 0x6824,
+	0xd0f4, 0x1d48, 0xa838, 0xa934, 0x9105, 0x0d80, 0x0c20, 0xd2ec,
+	0x1d68, 0x7024, 0x9306, 0x1118, 0x7020, 0x9406, 0x0d38, 0x7020,
+	0x683e, 0x7024, 0x683a, 0x2001, 0x0005, 0x6832, 0x080c, 0xbeac,
+	0x080c, 0x898b, 0x0010, 0x080c, 0x9e2f, 0x004e, 0x003e, 0x002e,
+	0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210,
+	0x00b6, 0x2258, 0xba10, 0x00be, 0x9206, 0x1904, 0xa536, 0x700c,
+	0x6210, 0x00b6, 0x2258, 0xba14, 0x00be, 0x9206, 0x1904, 0xa536,
+	0x6038, 0x2068, 0x6824, 0xc0dc, 0x6826, 0x6a20, 0x9286, 0x0007,
+	0x0904, 0xa536, 0x9286, 0x0002, 0x0904, 0xa536, 0x9286, 0x0000,
+	0x05e8, 0x6808, 0x633c, 0x9306, 0x15c8, 0x2071, 0x026c, 0x9186,
+	0x0015, 0x0570, 0x918e, 0x0016, 0x1100, 0x00c6, 0x6038, 0x2060,
+	0x6104, 0x9186, 0x004b, 0x01c0, 0x9186, 0x004c, 0x01a8, 0x9186,
+	0x004d, 0x0190, 0x9186, 0x004e, 0x0178, 0x9186, 0x0052, 0x0160,
+	0x6014, 0x0096, 0x2048, 0x080c, 0xbb3b, 0x090c, 0x0db4, 0xa87b,
+	0x0003, 0x009e, 0x080c, 0xc1f5, 0x6007, 0x0085, 0x6003, 0x000b,
+	0x6023, 0x0002, 0x080c, 0x83f8, 0x080c, 0x898b, 0x00ce, 0x0030,
+	0x6038, 0x2070, 0x2001, 0x1960, 0x2004, 0x7042, 0x080c, 0x9e2f,
+	0x002e, 0x00de, 0x00ee, 0x0005, 0x00b6, 0x0096, 0x00f6, 0x6014,
+	0x2048, 0x6010, 0x2058, 0x91b6, 0x0015, 0x0130, 0xba08, 0xbb0c,
+	0xbc00, 0xc48c, 0xbc02, 0x0460, 0x0096, 0x0156, 0x0036, 0x0026,
+	0x2b48, 0x9e90, 0x0010, 0x2019, 0x000a, 0x20a9, 0x0004, 0x080c,
+	0xae1c, 0x002e, 0x003e, 0x015e, 0x009e, 0x1904, 0xa5a5, 0x0096,
+	0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90, 0x0014, 0x2019, 0x0006,
+	0x20a9, 0x0004, 0x080c, 0xae1c, 0x002e, 0x003e, 0x015e, 0x009e,
+	0x15a0, 0x7238, 0xba0a, 0x733c, 0xbb0e, 0xbc00, 0xc48d, 0xbc02,
+	0xa804, 0x9005, 0x1128, 0x00fe, 0x009e, 0x00be, 0x0804, 0xa233,
+	0x0096, 0x2048, 0xaa12, 0xab16, 0xac0a, 0x009e, 0x8006, 0x8006,
+	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009,
+	0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041,
+	0x122f, 0x080c, 0xa332, 0x0130, 0x00fe, 0x009e, 0x080c, 0x9e2f,
+	0x00be, 0x0005, 0x080c, 0xa7cd, 0x0cb8, 0x2b78, 0x00f6, 0x080c,
+	0x2fe7, 0x080c, 0xc250, 0x00fe, 0x00c6, 0x080c, 0x9dd9, 0x2f00,
+	0x6012, 0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003,
+	0x0001, 0x2001, 0x0007, 0x080c, 0x61a7, 0x080c, 0x61d3, 0x080c,
+	0x8440, 0x080c, 0x898b, 0x00ce, 0x0804, 0xa578, 0x2100, 0x91b2,
+	0x0053, 0x1a0c, 0x0db4, 0x91b2, 0x0040, 0x1a04, 0xa62e, 0x0002,
+	0xa61c, 0xa61c, 0xa612, 0xa61c, 0xa61c, 0xa61c, 0xa610, 0xa610,
+	0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610,
+	0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610,
+	0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa61c,
+	0xa610, 0xa61c, 0xa61c, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610,
+	0xa612, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa610,
+	0xa610, 0xa610, 0xa61c, 0xa61c, 0xa610, 0xa610, 0xa610, 0xa610,
+	0xa610, 0xa610, 0xa610, 0xa610, 0xa610, 0xa61c, 0xa610, 0xa610,
+	0x080c, 0x0db4, 0x0066, 0x00b6, 0x6610, 0x2658, 0xb8bc, 0xc08c,
+	0xb8be, 0x00be, 0x006e, 0x0000, 0x6003, 0x0001, 0x6106, 0x9186,
+	0x0032, 0x0118, 0x080c, 0x8440, 0x0010, 0x080c, 0x83f8, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x898b, 0x012e, 0x0005, 0x2600, 0x0002,
+	0xa642, 0xa642, 0xa642, 0xa61c, 0xa61c, 0xa642, 0xa642, 0xa642,
+	0xa642, 0xa61c, 0xa642, 0xa61c, 0xa642, 0xa61c, 0xa642, 0xa642,
+	0xa642, 0xa642, 0x080c, 0x0db4, 0x6004, 0x90b2, 0x0053, 0x1a0c,
+	0x0db4, 0x91b6, 0x0013, 0x0904, 0xa706, 0x91b6, 0x0027, 0x1904,
+	0xa6c1, 0x080c, 0x887f, 0x6004, 0x080c, 0xbd30, 0x01b0, 0x080c,
+	0xbd41, 0x01a8, 0x908e, 0x0021, 0x0904, 0xa6be, 0x908e, 0x0022,
+	0x1130, 0x080c, 0xa25f, 0x0904, 0xa6ba, 0x0804, 0xa6bb, 0x908e,
+	0x003d, 0x0904, 0xa6be, 0x0804, 0xa6b4, 0x080c, 0x3010, 0x2001,
+	0x0007, 0x080c, 0x61a7, 0x6010, 0x00b6, 0x2058, 0xb9a0, 0x00be,
+	0x080c, 0xa7cd, 0x9186, 0x007e, 0x1148, 0x2001, 0x1836, 0x2014,
+	0xc285, 0x080c, 0x6faa, 0x1108, 0xc2ad, 0x2202, 0x0036, 0x0026,
+	0x2019, 0x0028, 0x2110, 0x080c, 0xd81c, 0x002e, 0x003e, 0x0016,
+	0x0026, 0x0036, 0x2110, 0x2019, 0x0028, 0x080c, 0x8582, 0x0076,
+	0x903e, 0x080c, 0x8470, 0x6010, 0x00b6, 0x905d, 0x0100, 0x00be,
+	0x2c08, 0x080c, 0xd2d5, 0x007e, 0x003e, 0x002e, 0x001e, 0x080c,
+	0xc250, 0x0016, 0x080c, 0xbfad, 0x080c, 0x9e2f, 0x001e, 0x080c,
+	0x30e2, 0x080c, 0x898b, 0x0030, 0x080c, 0xbfad, 0x080c, 0x9e2f,
+	0x080c, 0x898b, 0x0005, 0x080c, 0xa7cd, 0x0cb0, 0x080c, 0xa809,
+	0x0c98, 0x9186, 0x0014, 0x1db0, 0x080c, 0x887f, 0x6004, 0x908e,
+	0x0022, 0x1118, 0x080c, 0xa25f, 0x0d68, 0x080c, 0x2fe7, 0x080c,
+	0xc250, 0x080c, 0xbd30, 0x1190, 0x080c, 0x3010, 0x6010, 0x00b6,
+	0x2058, 0xb9a0, 0x00be, 0x080c, 0xa7cd, 0x9186, 0x007e, 0x1128,
+	0x2001, 0x1836, 0x200c, 0xc185, 0x2102, 0x0870, 0x080c, 0xbd41,
+	0x1118, 0x080c, 0xa7cd, 0x0840, 0x6004, 0x908e, 0x0032, 0x1160,
+	0x00e6, 0x00f6, 0x2071, 0x189c, 0x2079, 0x0000, 0x080c, 0x3376,
+	0x00fe, 0x00ee, 0x0804, 0xa6b4, 0x6004, 0x908e, 0x0021, 0x0d48,
+	0x908e, 0x0022, 0x090c, 0xa7cd, 0x0804, 0xa6b4, 0x90b2, 0x0040,
+	0x1a04, 0xa7b6, 0x2008, 0x0002, 0xa74e, 0xa74f, 0xa752, 0xa755,
+	0xa758, 0xa75b, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c,
+	0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c,
+	0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c,
+	0xa74c, 0xa74c, 0xa75e, 0xa76b, 0xa74c, 0xa76d, 0xa76b, 0xa74c,
+	0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa76b, 0xa76b, 0xa74c, 0xa74c,
+	0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa74c, 0xa79d, 0xa76b,
+	0xa74c, 0xa767, 0xa74c, 0xa74c, 0xa74c, 0xa768, 0xa74c, 0xa74c,
+	0xa74c, 0xa76b, 0xa794, 0xa74c, 0x080c, 0x0db4, 0x00e0, 0x2001,
+	0x000b, 0x0420, 0x2001, 0x0003, 0x0408, 0x2001, 0x0005, 0x00f0,
+	0x2001, 0x0001, 0x00d8, 0x2001, 0x0009, 0x00c0, 0x080c, 0x887f,
+	0x6003, 0x0005, 0x080c, 0xc253, 0x080c, 0x898b, 0x0070, 0x0018,
+	0x0010, 0x080c, 0x61a7, 0x0804, 0xa7ae, 0x080c, 0x887f, 0x080c,
+	0xc253, 0x6003, 0x0004, 0x080c, 0x898b, 0x0005, 0x080c, 0x61a7,
+	0x080c, 0x887f, 0x6003, 0x0002, 0x0036, 0x2019, 0x1866, 0x2304,
+	0x9084, 0xff00, 0x1120, 0x2001, 0x195e, 0x201c, 0x0040, 0x8007,
+	0x909a, 0x0004, 0x0ec0, 0x8003, 0x801b, 0x831b, 0x9318, 0x631a,
+	0x003e, 0x080c, 0x898b, 0x0c08, 0x080c, 0x887f, 0x080c, 0xbfad,
+	0x080c, 0x9e2f, 0x080c, 0x898b, 0x08c0, 0x00e6, 0x00f6, 0x2071,
+	0x189c, 0x2079, 0x0000, 0x080c, 0x3376, 0x00fe, 0x00ee, 0x080c,
+	0x887f, 0x080c, 0x9e2f, 0x080c, 0x898b, 0x0838, 0x080c, 0x887f,
+	0x6003, 0x0002, 0x080c, 0xc253, 0x0804, 0x898b, 0x2600, 0x2008,
+	0x0002, 0xa7cb, 0xa7cb, 0xa7cb, 0xa7ae, 0xa7ae, 0xa7cb, 0xa7cb,
+	0xa7cb, 0xa7cb, 0xa7ae, 0xa7cb, 0xa7ae, 0xa7cb, 0xa7ae, 0xa7cb,
+	0xa7cb, 0xa7cb, 0xa7cb, 0x080c, 0x0db4, 0x00e6, 0x0096, 0x0026,
+	0x0016, 0x080c, 0xbb3b, 0x0568, 0x6014, 0x2048, 0xa864, 0x9086,
+	0x0139, 0x11a8, 0xa894, 0x9086, 0x0056, 0x1148, 0x080c, 0x5143,
+	0x0130, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x0028, 0x2001,
+	0x0030, 0x900e, 0x2011, 0x4005, 0x080c, 0xc11a, 0x0090, 0xa868,
+	0xd0fc, 0x0178, 0xa807, 0x0000, 0x0016, 0x6004, 0x908e, 0x0021,
+	0x0168, 0x908e, 0x003d, 0x0150, 0x001e, 0xa867, 0x0103, 0xa833,
+	0x0100, 0x001e, 0x002e, 0x009e, 0x00ee, 0x0005, 0x001e, 0x0009,
+	0x0cc0, 0x0096, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103,
+	0xa823, 0x8001, 0x009e, 0x0005, 0x00b6, 0x6610, 0x2658, 0xb804,
+	0x9084, 0x00ff, 0x90b2, 0x000c, 0x1a0c, 0x0db4, 0x6604, 0x96b6,
+	0x004d, 0x1120, 0x080c, 0xc039, 0x0804, 0xa891, 0x6604, 0x96b6,
+	0x0043, 0x1120, 0x080c, 0xc082, 0x0804, 0xa891, 0x6604, 0x96b6,
+	0x004b, 0x1120, 0x080c, 0xc0ae, 0x0804, 0xa891, 0x6604, 0x96b6,
+	0x0033, 0x1120, 0x080c, 0xbfcf, 0x0804, 0xa891, 0x6604, 0x96b6,
+	0x0028, 0x1120, 0x080c, 0xbd7f, 0x0804, 0xa891, 0x6604, 0x96b6,
+	0x0029, 0x1120, 0x080c, 0xbdc0, 0x0804, 0xa891, 0x6604, 0x96b6,
+	0x001f, 0x1118, 0x080c, 0xa207, 0x04e0, 0x6604, 0x96b6, 0x0000,
+	0x1118, 0x080c, 0xa53c, 0x04a8, 0x6604, 0x96b6, 0x0022, 0x1118,
+	0x080c, 0xa240, 0x0470, 0x6604, 0x96b6, 0x0035, 0x1118, 0x080c,
+	0xa350, 0x0438, 0x6604, 0x96b6, 0x0039, 0x1118, 0x080c, 0xa4d1,
+	0x0400, 0x6604, 0x96b6, 0x003d, 0x1118, 0x080c, 0xa278, 0x00c8,
+	0x6604, 0x96b6, 0x0044, 0x1118, 0x080c, 0xa2b4, 0x0090, 0x6604,
+	0x96b6, 0x0049, 0x1118, 0x080c, 0xa2df, 0x0058, 0x91b6, 0x0015,
+	0x1110, 0x0063, 0x0030, 0x91b6, 0x0016, 0x1128, 0x00be, 0x0804,
+	0xab51, 0x00be, 0x0005, 0x080c, 0x9ec4, 0x0cd8, 0xa8ae, 0xa8b1,
+	0xa8ae, 0xa8f5, 0xa8ae, 0xaa85, 0xab5e, 0xa8ae, 0xa8ae, 0xab2b,
+	0xa8ae, 0xab3f, 0x0096, 0x080c, 0x1511, 0x6014, 0x2048, 0xa800,
+	0x2048, 0xa867, 0x0103, 0x009e, 0x0804, 0x9e2f, 0xa001, 0xa001,
+	0x0005, 0x00e6, 0x2071, 0x1800, 0x708c, 0x9086, 0x0074, 0x1540,
+	0x080c, 0xd2a6, 0x11b0, 0x6010, 0x00b6, 0x2058, 0x7030, 0xd08c,
+	0x0128, 0xb800, 0xd0bc, 0x0110, 0xc0c5, 0xb802, 0x00e9, 0x00be,
+	0x2001, 0x0006, 0x080c, 0x61a7, 0x080c, 0x3010, 0x080c, 0x9e2f,
+	0x0088, 0x2001, 0x000a, 0x080c, 0x61a7, 0x080c, 0x3010, 0x6003,
+	0x0001, 0x6007, 0x0001, 0x080c, 0x8440, 0x080c, 0x898b, 0x0010,
+	0x080c, 0xaa70, 0x00ee, 0x0005, 0x00d6, 0xb800, 0xd084, 0x0158,
+	0x9006, 0x080c, 0x6193, 0x2069, 0x185b, 0x6804, 0x0020, 0x2001,
+	0x0006, 0x080c, 0x61d3, 0x00de, 0x0005, 0x00b6, 0x0096, 0x00d6,
+	0x2011, 0x1823, 0x2204, 0x9086, 0x0074, 0x1904, 0xaa47, 0x6010,
+	0x2058, 0xbaa0, 0x9286, 0x007e, 0x1120, 0x080c, 0xaca2, 0x0804,
+	0xa9ac, 0x00d6, 0x080c, 0x6faa, 0x0198, 0x0026, 0x2011, 0x0010,
+	0x080c, 0x659e, 0x002e, 0x05c8, 0x080c, 0x53ae, 0x1540, 0x6014,
+	0x2048, 0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0xdead, 0x00f8,
+	0x0026, 0x2011, 0x8008, 0x080c, 0x659e, 0x002e, 0x0530, 0x6014,
+	0x2048, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140, 0x2001,
+	0x0030, 0x900e, 0x2011, 0x4009, 0x080c, 0xc11a, 0x0040, 0x6014,
+	0x2048, 0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0xdead, 0x6010,
+	0x2058, 0xb9a0, 0x0016, 0x080c, 0x3010, 0x080c, 0x9e2f, 0x001e,
+	0x080c, 0x30e2, 0x00de, 0x0804, 0xaa4a, 0x00de, 0x080c, 0xac97,
+	0x6010, 0x2058, 0xbaa0, 0x9286, 0x0080, 0x1510, 0x6014, 0x9005,
+	0x01a8, 0x2048, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140,
+	0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xc11a, 0x0030,
+	0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0x0200, 0x2001, 0x0006,
+	0x080c, 0x61a7, 0x080c, 0x3010, 0x080c, 0x9e2f, 0x0804, 0xaa4a,
+	0x080c, 0xaa58, 0x6014, 0x9005, 0x0190, 0x2048, 0xa868, 0xd0f4,
+	0x01e8, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1d08, 0x2001,
+	0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xc11a, 0x08f8, 0x080c,
+	0xaa4e, 0x0160, 0x9006, 0x080c, 0x6193, 0x2001, 0x0004, 0x080c,
+	0x61d3, 0x2001, 0x0007, 0x080c, 0x61a7, 0x08a0, 0x2001, 0x0004,
+	0x080c, 0x61a7, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c, 0x8440,
+	0x080c, 0x898b, 0x0804, 0xaa4a, 0xb85c, 0xd0e4, 0x01d0, 0x080c,
+	0xbf4f, 0x080c, 0x6faa, 0x0118, 0xd0dc, 0x1904, 0xa96e, 0x2011,
+	0x1836, 0x2204, 0xc0ad, 0x2012, 0x2001, 0x0002, 0x00f6, 0x2079,
+	0x0100, 0x78e3, 0x0000, 0x080c, 0x26e4, 0x78e2, 0x00fe, 0x0804,
+	0xa96e, 0x080c, 0xbf8c, 0x2011, 0x1836, 0x2204, 0xc0a5, 0x2012,
+	0x0006, 0x080c, 0xd3ff, 0x000e, 0x1904, 0xa96e, 0xc0b5, 0x2012,
+	0x2001, 0x0006, 0x080c, 0x61a7, 0x9006, 0x080c, 0x6193, 0x00c6,
+	0x2001, 0x180f, 0x2004, 0xd09c, 0x0520, 0x00f6, 0x2079, 0x0100,
+	0x00e6, 0x2071, 0x1800, 0x700c, 0x9084, 0x00ff, 0x78e6, 0x707a,
+	0x7010, 0x78ea, 0x707e, 0x908c, 0x00ff, 0x00ee, 0x780c, 0xc0b5,
+	0x780e, 0x00fe, 0x080c, 0x26b9, 0x00f6, 0x2100, 0x900e, 0x080c,
+	0x2670, 0x795a, 0x00fe, 0x9186, 0x0081, 0x01d8, 0x2009, 0x0081,
+	0x00c8, 0x2009, 0x00ef, 0x00f6, 0x2079, 0x0100, 0x79ea, 0x7932,
+	0x7936, 0x780c, 0xc0b5, 0x780e, 0x00fe, 0x080c, 0x26b9, 0x00f6,
+	0x2079, 0x1800, 0x797e, 0x2100, 0x900e, 0x080c, 0x2670, 0x795a,
+	0x00fe, 0x8108, 0x080c, 0x61f6, 0x2b00, 0x00ce, 0x1904, 0xa96e,
+	0x6012, 0x2009, 0x180f, 0x210c, 0xd19c, 0x0150, 0x2009, 0x027c,
+	0x210c, 0x918c, 0x00ff, 0xb912, 0x2009, 0x027d, 0x210c, 0xb916,
+	0x2001, 0x0002, 0x080c, 0x61a7, 0x6023, 0x0001, 0x6003, 0x0001,
+	0x6007, 0x0002, 0x080c, 0x8440, 0x080c, 0x898b, 0x0018, 0x080c,
+	0xa7cd, 0x0431, 0x00de, 0x009e, 0x00be, 0x0005, 0x2001, 0x1810,
+	0x2004, 0xd0a4, 0x0120, 0x2001, 0x185c, 0x2004, 0xd0ac, 0x0005,
+	0x00e6, 0x080c, 0xd875, 0x0190, 0x2071, 0x0260, 0x7108, 0x720c,
+	0x918c, 0x00ff, 0x1118, 0x9284, 0xff00, 0x0140, 0x6010, 0x2058,
+	0xb8a0, 0x9084, 0xff80, 0x1110, 0xb912, 0xba16, 0x00ee, 0x0005,
+	0x2030, 0x2001, 0x0007, 0x080c, 0x61a7, 0x080c, 0x53ae, 0x1120,
+	0x2001, 0x0007, 0x080c, 0x61d3, 0x080c, 0x3010, 0x6020, 0x9086,
+	0x000a, 0x1108, 0x0005, 0x0804, 0x9e2f, 0x00b6, 0x00e6, 0x0026,
+	0x0016, 0x2071, 0x1800, 0x708c, 0x9086, 0x0014, 0x1904, 0xab22,
+	0x00d6, 0x080c, 0x6faa, 0x0198, 0x0026, 0x2011, 0x0010, 0x080c,
+	0x659e, 0x002e, 0x05c8, 0x080c, 0x53ae, 0x1540, 0x6014, 0x2048,
+	0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0xdead, 0x00f8, 0x0026,
+	0x2011, 0x8008, 0x080c, 0x659e, 0x002e, 0x0530, 0x6014, 0x2048,
+	0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140, 0x2001, 0x0030,
+	0x900e, 0x2011, 0x4009, 0x080c, 0xc11a, 0x0040, 0x6014, 0x2048,
+	0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0xdead, 0x6010, 0x2058,
+	0xb9a0, 0x0016, 0x080c, 0x3010, 0x080c, 0x9e2f, 0x001e, 0x080c,
+	0x30e2, 0x00de, 0x0804, 0xab26, 0x00de, 0x080c, 0x53ae, 0x1170,
+	0x6014, 0x9005, 0x1158, 0x0036, 0x0046, 0x6010, 0x2058, 0xbba0,
+	0x2021, 0x0006, 0x080c, 0x4a91, 0x004e, 0x003e, 0x00d6, 0x6010,
+	0x2058, 0x080c, 0x62f1, 0x080c, 0xa8e4, 0x00de, 0x080c, 0xad68,
+	0x1588, 0x6010, 0x2058, 0xb890, 0x9005, 0x0560, 0x2001, 0x0006,
+	0x080c, 0x61a7, 0x0096, 0x6014, 0x904d, 0x01d0, 0xa864, 0x9084,
 	0x00ff, 0x9086, 0x0039, 0x1140, 0x2001, 0x0000, 0x900e, 0x2011,
-	0x4000, 0x080c, 0xc10b, 0x0030, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xa833, 0x0200, 0x2001, 0x0006, 0x080c, 0x6198, 0x080c, 0x3005,
-	0x080c, 0x9e42, 0x0804, 0xaa4e, 0x080c, 0xaa5c, 0x6014, 0x9005,
-	0x0190, 0x2048, 0xa868, 0xd0f4, 0x01e8, 0xa864, 0x9084, 0x00ff,
-	0x9086, 0x0039, 0x1d08, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000,
-	0x080c, 0xc10b, 0x08f8, 0x080c, 0xaa52, 0x0160, 0x9006, 0x080c,
-	0x6184, 0x2001, 0x0004, 0x080c, 0x61c4, 0x2001, 0x0007, 0x080c,
-	0x6198, 0x08a0, 0x2001, 0x0004, 0x080c, 0x6198, 0x6003, 0x0001,
-	0x6007, 0x0003, 0x080c, 0x8422, 0x080c, 0x896d, 0x0804, 0xaa4e,
-	0xb85c, 0xd0e4, 0x01d0, 0x080c, 0xbf40, 0x080c, 0x6f9b, 0x0118,
-	0xd0dc, 0x1904, 0xa972, 0x2011, 0x1836, 0x2204, 0xc0ad, 0x2012,
-	0x2001, 0x0002, 0x00f6, 0x2079, 0x0100, 0x78e3, 0x0000, 0x080c,
-	0x26d9, 0x78e2, 0x00fe, 0x0804, 0xa972, 0x080c, 0xbf7d, 0x2011,
-	0x1836, 0x2204, 0xc0a5, 0x2012, 0x0006, 0x080c, 0xd3e6, 0x000e,
-	0x1904, 0xa972, 0xc0b5, 0x2012, 0x2001, 0x0006, 0x080c, 0x6198,
-	0x9006, 0x080c, 0x6184, 0x00c6, 0x2001, 0x180f, 0x2004, 0xd09c,
-	0x0520, 0x00f6, 0x2079, 0x0100, 0x00e6, 0x2071, 0x1800, 0x700c,
-	0x9084, 0x00ff, 0x78e6, 0x707a, 0x7010, 0x78ea, 0x707e, 0x908c,
-	0x00ff, 0x00ee, 0x780c, 0xc0b5, 0x780e, 0x00fe, 0x080c, 0x26ae,
-	0x00f6, 0x2100, 0x900e, 0x080c, 0x2665, 0x795a, 0x00fe, 0x9186,
-	0x0081, 0x01d8, 0x2009, 0x0081, 0x00c8, 0x2009, 0x00ef, 0x00f6,
-	0x2079, 0x0100, 0x79ea, 0x7932, 0x7936, 0x780c, 0xc0b5, 0x780e,
-	0x00fe, 0x080c, 0x26ae, 0x00f6, 0x2079, 0x1800, 0x797e, 0x2100,
-	0x900e, 0x080c, 0x2665, 0x795a, 0x00fe, 0x8108, 0x080c, 0x61e7,
-	0x2b00, 0x00ce, 0x1904, 0xa972, 0x6012, 0x2009, 0x180f, 0x210c,
-	0xd19c, 0x0150, 0x2009, 0x027c, 0x210c, 0x918c, 0x00ff, 0xb912,
-	0x2009, 0x027d, 0x210c, 0xb916, 0x2001, 0x0002, 0x080c, 0x6198,
-	0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8422,
-	0x080c, 0x896d, 0x0018, 0x080c, 0xa7d1, 0x0431, 0x00de, 0x009e,
-	0x00be, 0x0005, 0x2001, 0x1810, 0x2004, 0xd0a4, 0x0120, 0x2001,
-	0x1854, 0x2004, 0xd0ac, 0x0005, 0x00e6, 0x080c, 0xd85c, 0x0190,
-	0x2071, 0x0260, 0x7108, 0x720c, 0x918c, 0x00ff, 0x1118, 0x9284,
-	0xff00, 0x0140, 0x6010, 0x2058, 0xb8a0, 0x9084, 0xff80, 0x1110,
-	0xb912, 0xba16, 0x00ee, 0x0005, 0x2030, 0x2001, 0x0007, 0x080c,
-	0x6198, 0x080c, 0x53a3, 0x1120, 0x2001, 0x0007, 0x080c, 0x61c4,
-	0x080c, 0x3005, 0x6020, 0x9086, 0x000a, 0x1108, 0x0005, 0x0804,
-	0x9e42, 0x00b6, 0x00e6, 0x0026, 0x0016, 0x2071, 0x1800, 0x708c,
-	0x9086, 0x0014, 0x1904, 0xab26, 0x00d6, 0x080c, 0x6f9b, 0x0198,
-	0x0026, 0x2011, 0x0010, 0x080c, 0x658f, 0x002e, 0x05c8, 0x080c,
-	0x53a3, 0x1540, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xa833, 0xdead, 0x00f8, 0x0026, 0x2011, 0x8008, 0x080c, 0x658f,
-	0x002e, 0x0530, 0x6014, 0x2048, 0xa864, 0x9084, 0x00ff, 0x9086,
-	0x0039, 0x1140, 0x2001, 0x0030, 0x900e, 0x2011, 0x4009, 0x080c,
-	0xc10b, 0x0040, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xa833, 0xdead, 0x6010, 0x2058, 0xb9a0, 0x0016, 0x080c, 0x3005,
-	0x080c, 0x9e42, 0x001e, 0x080c, 0x30d7, 0x00de, 0x0804, 0xab2a,
-	0x00de, 0x080c, 0x53a3, 0x1170, 0x6014, 0x9005, 0x1158, 0x0036,
-	0x0046, 0x6010, 0x2058, 0xbba0, 0x2021, 0x0006, 0x080c, 0x4a86,
-	0x004e, 0x003e, 0x00d6, 0x6010, 0x2058, 0x080c, 0x62e2, 0x080c,
-	0xa8e8, 0x00de, 0x080c, 0xad6c, 0x1588, 0x6010, 0x2058, 0xb890,
-	0x9005, 0x0560, 0x2001, 0x0006, 0x080c, 0x6198, 0x0096, 0x6014,
-	0x904d, 0x01d0, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140,
-	0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xc10b, 0x0060,
-	0xa864, 0x9084, 0x00ff, 0x9086, 0x0029, 0x0130, 0xa807, 0x0000,
-	0xa867, 0x0103, 0xa833, 0x0200, 0x009e, 0x080c, 0x3005, 0x6020,
-	0x9086, 0x000a, 0x0138, 0x080c, 0x9e42, 0x0020, 0x080c, 0xa7d1,
-	0x080c, 0xaa74, 0x001e, 0x002e, 0x00ee, 0x00be, 0x0005, 0x2011,
-	0x1823, 0x2204, 0x9086, 0x0014, 0x1160, 0x2001, 0x0002, 0x080c,
-	0x6198, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x8422, 0x0804,
-	0x896d, 0x0804, 0xaa74, 0x2030, 0x2011, 0x1823, 0x2204, 0x9086,
-	0x0004, 0x1148, 0x96b6, 0x000b, 0x1120, 0x2001, 0x0007, 0x080c,
-	0x6198, 0x0804, 0x9e42, 0x0804, 0xaa74, 0x0002, 0xa8b2, 0xab6d,
-	0xa8b2, 0xabac, 0xa8b2, 0xac57, 0xab62, 0xa8b2, 0xa8b2, 0xac6a,
-	0xa8b2, 0xac7a, 0x6604, 0x9686, 0x0003, 0x0904, 0xaa89, 0x96b6,
-	0x001e, 0x1110, 0x080c, 0x9e42, 0x0005, 0x00b6, 0x00d6, 0x00c6,
-	0x080c, 0xac8a, 0x11a0, 0x9006, 0x080c, 0x6184, 0x080c, 0x2fdc,
-	0x080c, 0xc241, 0x2001, 0x0002, 0x080c, 0x6198, 0x6003, 0x0001,
-	0x6007, 0x0002, 0x080c, 0x8422, 0x080c, 0x896d, 0x0408, 0x2009,
-	0x026e, 0x2104, 0x9086, 0x0009, 0x1160, 0x6010, 0x2058, 0xb840,
-	0x9084, 0x00ff, 0x9005, 0x0170, 0x8001, 0xb842, 0x601b, 0x000a,
-	0x0078, 0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086, 0x1900,
-	0x1108, 0x08a0, 0x080c, 0x2fdc, 0x080c, 0xc241, 0x080c, 0xaa74,
-	0x00ce, 0x00de, 0x00be, 0x0005, 0x0096, 0x00b6, 0x0026, 0x9016,
-	0x080c, 0xac98, 0x00d6, 0x2069, 0x194c, 0x2d04, 0x9005, 0x0168,
-	0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e, 0x1138, 0x2069, 0x181f,
-	0x2d04, 0x8000, 0x206a, 0x00de, 0x0010, 0x00de, 0x0088, 0x9006,
-	0x080c, 0x6184, 0x2001, 0x0002, 0x080c, 0x6198, 0x6003, 0x0001,
-	0x6007, 0x0002, 0x080c, 0x8422, 0x080c, 0x896d, 0x0804, 0xac27,
-	0x080c, 0xbb2c, 0x01b0, 0x6014, 0x2048, 0xa864, 0x2010, 0x9086,
-	0x0139, 0x1138, 0x6007, 0x0016, 0x2001, 0x0002, 0x080c, 0xc165,
-	0x00b0, 0x6014, 0x2048, 0xa864, 0xd0fc, 0x0118, 0x2001, 0x0001,
-	0x0ca8, 0x2001, 0x180e, 0x2004, 0xd0dc, 0x0148, 0x6010, 0x2058,
-	0xb840, 0x9084, 0x00ff, 0x9005, 0x1110, 0x9006, 0x0c38, 0x080c,
-	0xa7d1, 0x2009, 0x026e, 0x2134, 0x96b4, 0x00ff, 0x9686, 0x0005,
-	0x0510, 0x9686, 0x000b, 0x01c8, 0x2009, 0x026f, 0x2104, 0x9084,
-	0xff00, 0x1118, 0x9686, 0x0009, 0x01b0, 0x9086, 0x1900, 0x1168,
-	0x9686, 0x0009, 0x0180, 0x2001, 0x0004, 0x080c, 0x6198, 0x2001,
-	0x0028, 0x601a, 0x6007, 0x0052, 0x0010, 0x080c, 0xaa74, 0x002e,
-	0x00be, 0x009e, 0x0005, 0x9286, 0x0139, 0x0160, 0x6014, 0x2048,
-	0x080c, 0xbb2c, 0x0140, 0xa864, 0x9086, 0x0139, 0x0118, 0xa868,
-	0xd0fc, 0x0108, 0x0c50, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff,
-	0x9005, 0x0138, 0x8001, 0xb842, 0x601b, 0x000a, 0x6007, 0x0016,
-	0x08f0, 0xb8a0, 0x9086, 0x007e, 0x1138, 0x00e6, 0x2071, 0x1800,
-	0x080c, 0x5c6d, 0x00ee, 0x0010, 0x080c, 0x2fdc, 0x0870, 0x080c,
-	0xac98, 0x1160, 0x2001, 0x0004, 0x080c, 0x6198, 0x6003, 0x0001,
-	0x6007, 0x0003, 0x080c, 0x8422, 0x0804, 0x896d, 0x080c, 0xa7d1,
-	0x0804, 0xaa74, 0x0469, 0x1160, 0x2001, 0x0008, 0x080c, 0x6198,
-	0x6003, 0x0001, 0x6007, 0x0005, 0x080c, 0x8422, 0x0804, 0x896d,
-	0x0804, 0xaa74, 0x00e9, 0x1160, 0x2001, 0x000a, 0x080c, 0x6198,
-	0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x8422, 0x0804, 0x896d,
-	0x0804, 0xaa74, 0x2009, 0x026e, 0x2104, 0x9086, 0x0003, 0x1138,
-	0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086, 0x2a00, 0x0005,
-	0x9085, 0x0001, 0x0005, 0x00b6, 0x00c6, 0x0016, 0x6110, 0x2158,
-	0x080c, 0x6256, 0x001e, 0x00ce, 0x00be, 0x0005, 0x00b6, 0x00f6,
-	0x00e6, 0x00d6, 0x0036, 0x0016, 0x6010, 0x2058, 0x2009, 0x1836,
-	0x2104, 0x9085, 0x0003, 0x200a, 0x080c, 0xad3e, 0x0560, 0x2009,
-	0x1836, 0x2104, 0xc0cd, 0x200a, 0x080c, 0x6567, 0x0158, 0x9006,
-	0x2020, 0x2009, 0x002a, 0x080c, 0xd54b, 0x2001, 0x180c, 0x200c,
-	0xc195, 0x2102, 0x2019, 0x002a, 0x2009, 0x0001, 0x080c, 0x2fa7,
-	0x00e6, 0x2071, 0x1800, 0x080c, 0x2dbd, 0x00ee, 0x00c6, 0x0156,
-	0x20a9, 0x0781, 0x2009, 0x007f, 0x080c, 0x30d7, 0x8108, 0x1f04,
-	0xacdc, 0x015e, 0x00ce, 0x080c, 0xac9b, 0x2071, 0x0260, 0x2079,
-	0x0200, 0x7817, 0x0001, 0x2001, 0x1836, 0x200c, 0xc1c5, 0x7018,
-	0xd0fc, 0x0110, 0xd0dc, 0x0118, 0x7038, 0xd0dc, 0x1108, 0xc1c4,
-	0x7817, 0x0000, 0x2001, 0x1836, 0x2102, 0x2079, 0x0100, 0x2e04,
-	0x9084, 0x00ff, 0x2069, 0x181e, 0x206a, 0x78e6, 0x0006, 0x8e70,
-	0x2e04, 0x2069, 0x181f, 0x206a, 0x78ea, 0x7832, 0x7836, 0x2010,
-	0x9084, 0xff00, 0x001e, 0x9105, 0x2009, 0x182b, 0x200a, 0x2200,
-	0x9084, 0x00ff, 0x2008, 0x080c, 0x26ae, 0x080c, 0x6f9b, 0x0170,
-	0x2071, 0x0260, 0x2069, 0x1952, 0x7048, 0x206a, 0x704c, 0x6806,
-	0x7050, 0x680a, 0x7054, 0x680e, 0x080c, 0xbf40, 0x0040, 0x2001,
-	0x0006, 0x080c, 0x6198, 0x080c, 0x3005, 0x080c, 0x9e42, 0x001e,
-	0x003e, 0x00de, 0x00ee, 0x00fe, 0x00be, 0x0005, 0x0096, 0x0026,
-	0x0036, 0x00e6, 0x0156, 0x2019, 0x182b, 0x231c, 0x83ff, 0x01f0,
-	0x2071, 0x0260, 0x7200, 0x9294, 0x00ff, 0x7004, 0x9084, 0xff00,
-	0x9205, 0x9306, 0x1198, 0x2011, 0x0276, 0x20a9, 0x0004, 0x2b48,
-	0x2019, 0x000a, 0x080c, 0xae20, 0x1148, 0x2011, 0x027a, 0x20a9,
-	0x0004, 0x2019, 0x0006, 0x080c, 0xae20, 0x1100, 0x015e, 0x00ee,
-	0x003e, 0x002e, 0x009e, 0x0005, 0x00e6, 0x2071, 0x0260, 0x7034,
-	0x9086, 0x0014, 0x11a8, 0x7038, 0x9086, 0x0800, 0x1188, 0x703c,
-	0xd0ec, 0x0160, 0x9084, 0x0f00, 0x9086, 0x0100, 0x1138, 0x7054,
-	0xd0a4, 0x1110, 0xd0ac, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x00ee, 0x0005, 0x00e6, 0x0096, 0x00c6, 0x0076, 0x0056, 0x0046,
-	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2029, 0x19c0, 0x252c,
-	0x2021, 0x19c6, 0x2424, 0x2061, 0x1cd0, 0x2071, 0x1800, 0x7250,
-	0x7070, 0x9202, 0x1a04, 0xadf8, 0x080c, 0xd57c, 0x0904, 0xadf1,
-	0x6720, 0x9786, 0x0007, 0x0904, 0xadf1, 0x2500, 0x9c06, 0x0904,
-	0xadf1, 0x2400, 0x9c06, 0x05e8, 0x3e08, 0x9186, 0x0002, 0x1148,
-	0x6010, 0x9005, 0x0130, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
-	0x1580, 0x00c6, 0x6000, 0x9086, 0x0004, 0x1110, 0x080c, 0x190f,
-	0x9786, 0x000a, 0x0148, 0x080c, 0xbd32, 0x1130, 0x00ce, 0x080c,
-	0xa7d1, 0x080c, 0x9e72, 0x00e8, 0x6014, 0x2048, 0x080c, 0xbb2c,
-	0x01a8, 0x9786, 0x0003, 0x1530, 0xa867, 0x0103, 0xa87c, 0xd0cc,
-	0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0f9d, 0x009e, 0xab7a,
-	0xa877, 0x0000, 0x080c, 0x6884, 0x080c, 0xbd15, 0x080c, 0x9e72,
-	0x00ce, 0x9ce0, 0x0018, 0x7064, 0x9c02, 0x1210, 0x0804, 0xad9f,
-	0x012e, 0x000e, 0x002e, 0x004e, 0x005e, 0x007e, 0x00ce, 0x009e,
-	0x00ee, 0x0005, 0x9786, 0x0006, 0x1118, 0x080c, 0xd4f6, 0x0c30,
-	0x9786, 0x000a, 0x0998, 0x0880, 0x220c, 0x2304, 0x9106, 0x1130,
-	0x8210, 0x8318, 0x1f04, 0xae0c, 0x9006, 0x0005, 0x2304, 0x9102,
-	0x0218, 0x2001, 0x0001, 0x0008, 0x9006, 0x918d, 0x0001, 0x0005,
-	0x0136, 0x01c6, 0x0016, 0x8906, 0x8006, 0x8007, 0x908c, 0x003f,
-	0x21e0, 0x9084, 0xffc0, 0x9300, 0x2098, 0x3518, 0x20a9, 0x0001,
-	0x220c, 0x4002, 0x910e, 0x1140, 0x8210, 0x8319, 0x1dc8, 0x9006,
-	0x001e, 0x01ce, 0x013e, 0x0005, 0x220c, 0x9102, 0x0218, 0x2001,
-	0x0001, 0x0010, 0x2001, 0x0000, 0x918d, 0x0001, 0x001e, 0x01ce,
-	0x013e, 0x0005, 0x6004, 0x908a, 0x0053, 0x1a0c, 0x0db4, 0x080c,
-	0xbd21, 0x0120, 0x080c, 0xbd32, 0x0168, 0x0028, 0x080c, 0x3005,
-	0x080c, 0xbd32, 0x0138, 0x080c, 0x8861, 0x080c, 0x9e42, 0x080c,
-	0x896d, 0x0005, 0x080c, 0xa7d1, 0x0cb0, 0x9182, 0x0054, 0x1220,
-	0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xae81, 0xae81, 0xae81,
-	0xae81, 0xae81, 0xae81, 0xae81, 0xae81, 0xae81, 0xae81, 0xae81,
-	0xae83, 0xae83, 0xae83, 0xae83, 0xae81, 0xae81, 0xae81, 0xae83,
-	0xae81, 0x080c, 0x0db4, 0x600b, 0xffff, 0x6003, 0x0001, 0x6106,
-	0x080c, 0x83da, 0x0126, 0x2091, 0x8000, 0x080c, 0x896d, 0x012e,
-	0x0005, 0x9186, 0x0013, 0x1128, 0x6004, 0x9082, 0x0040, 0x0804,
-	0xaf38, 0x9186, 0x0027, 0x1520, 0x080c, 0x8861, 0x080c, 0x2fdc,
-	0x080c, 0xc241, 0x0096, 0x6114, 0x2148, 0x080c, 0xbb2c, 0x0198,
-	0x080c, 0xbd32, 0x1118, 0x080c, 0xa7d1, 0x0068, 0xa867, 0x0103,
-	0xa87b, 0x0029, 0xa877, 0x0000, 0xa97c, 0xc1c5, 0xa97e, 0x080c,
-	0x6891, 0x080c, 0xbd15, 0x009e, 0x080c, 0x9e42, 0x0804, 0x896d,
-	0x9186, 0x0014, 0x1120, 0x6004, 0x9082, 0x0040, 0x04a0, 0x9186,
-	0x0046, 0x0150, 0x9186, 0x0045, 0x0138, 0x9186, 0x0053, 0x0120,
-	0x9186, 0x0048, 0x190c, 0x0db4, 0x2001, 0x0109, 0x2004, 0xd084,
-	0x0508, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x0036,
-	0x00f6, 0x00e6, 0x00c6, 0x2079, 0x19b7, 0x2071, 0x1800, 0x2061,
-	0x0100, 0x080c, 0x82c6, 0x00ce, 0x00ee, 0x00fe, 0x003e, 0x002e,
-	0x001e, 0x000e, 0x012e, 0xa001, 0x6000, 0x9086, 0x0002, 0x1110,
-	0x0804, 0xaf76, 0x0005, 0x0002, 0xaf12, 0xaf10, 0xaf10, 0xaf10,
-	0xaf10, 0xaf10, 0xaf10, 0xaf10, 0xaf10, 0xaf10, 0xaf10, 0xaf2d,
-	0xaf2d, 0xaf2d, 0xaf2d, 0xaf10, 0xaf2d, 0xaf10, 0xaf2d, 0xaf10,
-	0x080c, 0x0db4, 0x080c, 0x8861, 0x0096, 0x6114, 0x2148, 0x080c,
-	0xbb2c, 0x0168, 0xa867, 0x0103, 0xa87b, 0x0006, 0xa877, 0x0000,
-	0xa880, 0xc0ec, 0xa882, 0x080c, 0x6891, 0x080c, 0xbd15, 0x009e,
-	0x080c, 0x9e42, 0x080c, 0x896d, 0x0005, 0x080c, 0x8861, 0x080c,
-	0xbd32, 0x090c, 0xa7d1, 0x080c, 0x9e42, 0x080c, 0x896d, 0x0005,
-	0x0002, 0xaf4f, 0xaf4d, 0xaf4d, 0xaf4d, 0xaf4d, 0xaf4d, 0xaf4d,
-	0xaf4d, 0xaf4d, 0xaf4d, 0xaf4d, 0xaf66, 0xaf66, 0xaf66, 0xaf66,
-	0xaf4d, 0xaf70, 0xaf4d, 0xaf66, 0xaf4d, 0x080c, 0x0db4, 0x0096,
-	0x080c, 0x8861, 0x6014, 0x2048, 0x2001, 0x1958, 0x2004, 0x6042,
-	0xa97c, 0xd1ac, 0x0140, 0x6003, 0x0004, 0xa87c, 0x9085, 0x0400,
-	0xa87e, 0x009e, 0x0005, 0x6003, 0x0002, 0x0cb8, 0x080c, 0x8861,
-	0x080c, 0xc244, 0x080c, 0xc249, 0x6003, 0x000f, 0x0804, 0x896d,
-	0x080c, 0x8861, 0x080c, 0x9e42, 0x0804, 0x896d, 0x9182, 0x0054,
-	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xaf92, 0xaf92,
-	0xaf92, 0xaf92, 0xaf92, 0xaf94, 0xb071, 0xaf92, 0xb0a5, 0xaf92,
-	0xaf92, 0xaf92, 0xaf92, 0xaf92, 0xaf92, 0xaf92, 0xaf92, 0xaf92,
-	0xaf92, 0xb0a5, 0x080c, 0x0db4, 0x00b6, 0x0096, 0x6114, 0x2148,
-	0x7644, 0x96b4, 0x0fff, 0x86ff, 0x1528, 0x6010, 0x2058, 0xb800,
-	0xd0bc, 0x1904, 0xb060, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76,
-	0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xb23a,
-	0x080c, 0x66ac, 0x6210, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211,
-	0xba3e, 0x7044, 0xd0e4, 0x1904, 0xb044, 0x080c, 0x9e42, 0x009e,
-	0x00be, 0x0005, 0x968c, 0x0c00, 0x0150, 0x6010, 0x2058, 0xb800,
-	0xd0bc, 0x1904, 0xb048, 0x7348, 0xab92, 0x734c, 0xab8e, 0x968c,
-	0x00ff, 0x9186, 0x0002, 0x0508, 0x9186, 0x0028, 0x1118, 0xa87b,
-	0x001c, 0x00e8, 0xd6dc, 0x01a0, 0xa87b, 0x0015, 0xa87c, 0xd0ac,
-	0x0170, 0xa938, 0xaa34, 0x2100, 0x9205, 0x0148, 0x7048, 0x9106,
-	0x1118, 0x704c, 0x9206, 0x0118, 0xa992, 0xaa8e, 0xc6dc, 0x0038,
-	0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000, 0xa867,
-	0x0103, 0xae76, 0x901e, 0xd6c4, 0x01d8, 0x9686, 0x0100, 0x1130,
-	0x7064, 0x9005, 0x1118, 0xc6c4, 0x0804, 0xaf9b, 0x735c, 0xab86,
-	0x83ff, 0x0170, 0x938a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036,
-	0x2308, 0x2019, 0x0018, 0x2011, 0x0025, 0x080c, 0xb725, 0x003e,
-	0xd6cc, 0x0904, 0xafb0, 0x7154, 0xa98a, 0x81ff, 0x0904, 0xafb0,
-	0x9192, 0x0021, 0x1278, 0x8304, 0x9098, 0x0018, 0x2011, 0x0029,
-	0x080c, 0xb725, 0x2011, 0x0205, 0x2013, 0x0000, 0x080c, 0xc1d1,
-	0x0804, 0xafb0, 0xa868, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a,
-	0x0c50, 0x00a6, 0x2950, 0x080c, 0xb6c4, 0x00ae, 0x080c, 0xc1d1,
-	0x080c, 0xb715, 0x0804, 0xafb2, 0x080c, 0xbe2a, 0x0804, 0xafbf,
-	0xa87c, 0xd0ac, 0x0904, 0xafcb, 0xa880, 0xd0bc, 0x1904, 0xafcb,
-	0x7348, 0xa838, 0x9306, 0x11c8, 0x734c, 0xa834, 0x931e, 0x0904,
-	0xafcb, 0xd6d4, 0x0190, 0xab38, 0x9305, 0x0904, 0xafcb, 0x0068,
-	0xa87c, 0xd0ac, 0x0904, 0xafa3, 0xa838, 0xa934, 0x9105, 0x0904,
-	0xafa3, 0xa880, 0xd0bc, 0x1904, 0xafa3, 0x080c, 0xbe64, 0x0804,
-	0xafbf, 0x0096, 0x00f6, 0x6003, 0x0003, 0x6007, 0x0043, 0x2079,
-	0x026c, 0x7c04, 0x7b00, 0x7e0c, 0x7d08, 0x6014, 0x2048, 0xa87c,
-	0xd0ac, 0x0140, 0x6003, 0x0002, 0x00fe, 0x009e, 0x0005, 0x2130,
-	0x2228, 0x0058, 0x2400, 0xa9ac, 0x910a, 0x2300, 0xaab0, 0x9213,
-	0x2600, 0x9102, 0x2500, 0x9203, 0x0e90, 0xac36, 0xab3a, 0xae46,
-	0xad4a, 0x00fe, 0x6043, 0x0000, 0x2c10, 0x080c, 0x1a5e, 0x080c,
-	0x843f, 0x080c, 0x8a4a, 0x009e, 0x0005, 0x0005, 0x9182, 0x0054,
-	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xb0c2, 0xb0c2,
-	0xb0c2, 0xb0c2, 0xb0c2, 0xb0c4, 0xb15a, 0xb0c2, 0xb0c2, 0xb171,
-	0xb1fd, 0xb0c2, 0xb0c2, 0xb0c2, 0xb0c2, 0xb212, 0xb0c2, 0xb0c2,
-	0xb0c2, 0xb0c2, 0x080c, 0x0db4, 0x0076, 0x00a6, 0x00e6, 0x0096,
-	0x2071, 0x0260, 0x6114, 0x2150, 0x7644, 0xb676, 0x96b4, 0x0fff,
-	0xb77c, 0xc7e5, 0xb77e, 0x6210, 0x00b6, 0x2258, 0xba3c, 0x82ff,
-	0x0110, 0x8211, 0xba3e, 0x00be, 0x86ff, 0x0904, 0xb155, 0x9694,
-	0xff00, 0x9284, 0x0c00, 0x0120, 0x7048, 0xb092, 0x704c, 0xb08e,
-	0x9284, 0x0300, 0x0904, 0xb155, 0x080c, 0x0feb, 0x090c, 0x0db4,
-	0x2900, 0xb07a, 0xb77c, 0xc7cd, 0xb77e, 0xa867, 0x0103, 0xb068,
-	0xa86a, 0xb06c, 0xa86e, 0xb070, 0xa872, 0xae76, 0x968c, 0x0c00,
-	0x0120, 0x7348, 0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186,
-	0x0002, 0x0180, 0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x0060,
-	0xd6dc, 0x0118, 0xa87b, 0x0015, 0x0038, 0xd6d4, 0x0118, 0xa87b,
-	0x0007, 0x0010, 0xa87b, 0x0000, 0xaf7e, 0xb080, 0xa882, 0xb084,
-	0xa886, 0x901e, 0xd6c4, 0x0190, 0x735c, 0xab86, 0x83ff, 0x0170,
-	0x938a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019,
-	0x0018, 0x2011, 0x0025, 0x080c, 0xb725, 0x003e, 0xd6cc, 0x01e8,
-	0x7154, 0xa98a, 0x81ff, 0x01c8, 0x9192, 0x0021, 0x1260, 0x8304,
-	0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xb725, 0x2011, 0x0205,
-	0x2013, 0x0000, 0x0050, 0xb068, 0xd0fc, 0x0120, 0x2009, 0x0020,
-	0xa98a, 0x0c68, 0x2950, 0x080c, 0xb6c4, 0x009e, 0x00ee, 0x00ae,
-	0x007e, 0x0005, 0x00f6, 0x00a6, 0x6003, 0x0003, 0x2079, 0x026c,
-	0x7c04, 0x7b00, 0x7e0c, 0x7d08, 0x6014, 0x2050, 0xb436, 0xb33a,
-	0xb646, 0xb54a, 0x00ae, 0x00fe, 0x2c10, 0x080c, 0x1a5e, 0x0804,
-	0x937a, 0x6003, 0x0002, 0x6004, 0x9086, 0x0040, 0x11c8, 0x0096,
-	0x6014, 0x2048, 0xa87c, 0xd0ac, 0x0160, 0x601c, 0xd084, 0x1130,
-	0x00f6, 0x2c00, 0x2078, 0x080c, 0x164a, 0x00fe, 0x6003, 0x0004,
-	0x0010, 0x6003, 0x0002, 0x009e, 0x080c, 0x8861, 0x080c, 0x896d,
-	0x0096, 0x2001, 0x1958, 0x2004, 0x6042, 0x080c, 0x891d, 0x080c,
-	0x8a4a, 0x6114, 0x2148, 0xa97c, 0xd1e4, 0x0904, 0xb1f8, 0xd1cc,
-	0x05a8, 0xa978, 0xa868, 0xd0fc, 0x0538, 0x0016, 0xa87c, 0x0006,
-	0xa880, 0x0006, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0019, 0x20a0,
-	0x810e, 0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0,
-	0x9080, 0x0019, 0x2098, 0x0156, 0x20a9, 0x0020, 0x4003, 0x015e,
-	0x000e, 0xa882, 0x000e, 0xa87e, 0x001e, 0xa874, 0x0006, 0x2148,
-	0x080c, 0x0f9d, 0x001e, 0x0440, 0x0016, 0x080c, 0x0f9d, 0x009e,
-	0xa974, 0x0016, 0x080c, 0xb715, 0x001e, 0x00f0, 0xa867, 0x0103,
-	0xa974, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x0180, 0x9086, 0x0028,
-	0x1118, 0xa87b, 0x001c, 0x0060, 0xd1dc, 0x0118, 0xa87b, 0x0015,
-	0x0038, 0xd1d4, 0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000,
-	0x0016, 0x080c, 0x66ac, 0x001e, 0xd1e4, 0x1120, 0x080c, 0x9e42,
-	0x009e, 0x0005, 0x080c, 0xbe2a, 0x0cd8, 0x6004, 0x9086, 0x0040,
-	0x1120, 0x080c, 0x8861, 0x080c, 0x896d, 0x2019, 0x0001, 0x080c,
-	0x96d9, 0x6003, 0x0002, 0x080c, 0xc249, 0x080c, 0x891d, 0x080c,
-	0x8a4a, 0x0005, 0x6004, 0x9086, 0x0040, 0x1120, 0x080c, 0x8861,
-	0x080c, 0x896d, 0x2019, 0x0001, 0x080c, 0x96d9, 0x080c, 0x891d,
-	0x080c, 0x2fdc, 0x080c, 0xc241, 0x0096, 0x6114, 0x2148, 0x080c,
-	0xbb2c, 0x0150, 0xa867, 0x0103, 0xa87b, 0x0029, 0xa877, 0x0000,
-	0x080c, 0x6891, 0x080c, 0xbd15, 0x009e, 0x080c, 0x9e42, 0x080c,
-	0x8a4a, 0x0005, 0xa87b, 0x0015, 0xd1fc, 0x0180, 0xa87b, 0x0007,
-	0x8002, 0x8000, 0x810a, 0x9189, 0x0000, 0x0006, 0x0016, 0x2009,
-	0x1a49, 0x2104, 0x8000, 0x200a, 0x001e, 0x000e, 0xa992, 0xa88e,
-	0x0005, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a,
-	0x0005, 0xb26d, 0xb26d, 0xb26d, 0xb26d, 0xb26d, 0xb26f, 0xb26d,
-	0xb26d, 0xb315, 0xb26d, 0xb26d, 0xb26d, 0xb26d, 0xb26d, 0xb26d,
-	0xb26d, 0xb26d, 0xb26d, 0xb26d, 0xb446, 0x080c, 0x0db4, 0x0076,
-	0x00a6, 0x00e6, 0x0096, 0x2071, 0x0260, 0x6114, 0x2150, 0x7644,
-	0xb676, 0x96b4, 0x0fff, 0xb77c, 0xc7e5, 0xb77e, 0x6210, 0x00b6,
-	0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x86ff,
-	0x0904, 0xb30e, 0x9694, 0xff00, 0x9284, 0x0c00, 0x0120, 0x7048,
-	0xb092, 0x704c, 0xb08e, 0x9284, 0x0300, 0x0904, 0xb30e, 0x9686,
-	0x0100, 0x1130, 0x7064, 0x9005, 0x1118, 0xc6c4, 0xb676, 0x0c38,
-	0x080c, 0x0feb, 0x090c, 0x0db4, 0x2900, 0xb07a, 0xb77c, 0x97bd,
-	0x0200, 0xb77e, 0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c, 0xa86e,
-	0xb070, 0xa872, 0x7044, 0x9084, 0xf000, 0x9635, 0xae76, 0x968c,
-	0x0c00, 0x0120, 0x7348, 0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff,
-	0x9186, 0x0002, 0x0180, 0x9186, 0x0028, 0x1118, 0xa87b, 0x001c,
-	0x0060, 0xd6dc, 0x0118, 0xa87b, 0x0015, 0x0038, 0xd6d4, 0x0118,
-	0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000, 0xaf7e, 0xb080, 0xa882,
-	0xb084, 0xa886, 0x901e, 0xd6c4, 0x0190, 0x735c, 0xab86, 0x83ff,
-	0x0170, 0x938a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308,
-	0x2019, 0x0018, 0x2011, 0x0025, 0x080c, 0xb725, 0x003e, 0xd6cc,
-	0x01e8, 0x7154, 0xa98a, 0x81ff, 0x01c8, 0x9192, 0x0021, 0x1260,
-	0x8304, 0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xb725, 0x2011,
-	0x0205, 0x2013, 0x0000, 0x0050, 0xb068, 0xd0fc, 0x0120, 0x2009,
-	0x0020, 0xa98a, 0x0c68, 0x2950, 0x080c, 0xb6c4, 0x080c, 0x18ed,
-	0x009e, 0x00ee, 0x00ae, 0x007e, 0x0005, 0x2001, 0x1958, 0x2004,
-	0x6042, 0x0096, 0x6114, 0x2148, 0xa83c, 0xa940, 0x9105, 0x1118,
-	0xa87c, 0xc0dc, 0xa87e, 0x6003, 0x0002, 0xa97c, 0xd1e4, 0x0904,
-	0xb441, 0x6043, 0x0000, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
-	0xd0bc, 0x1500, 0xd1cc, 0x0904, 0xb410, 0xa978, 0xa868, 0xd0fc,
-	0x0904, 0xb3d1, 0x0016, 0xa87c, 0x0006, 0xa880, 0x0006, 0x00a6,
-	0x2150, 0xb174, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x0904, 0xb39f,
-	0x9086, 0x0028, 0x1904, 0xb38b, 0xa87b, 0x001c, 0xb07b, 0x001c,
-	0x0804, 0xb3a7, 0x6024, 0xd0f4, 0x11d0, 0xa838, 0xaa34, 0x9205,
-	0x09c8, 0xa838, 0xaa90, 0x9206, 0x1120, 0xa88c, 0xaa34, 0x9206,
-	0x0988, 0x6024, 0xd0d4, 0x1148, 0xa9ac, 0xa834, 0x9102, 0x603a,
-	0xa9b0, 0xa838, 0x9103, 0x603e, 0x6024, 0xc0f5, 0x6026, 0x6010,
-	0x00b6, 0x2058, 0xb83c, 0x8000, 0xb83e, 0x00be, 0x9006, 0xa876,
-	0xa892, 0xa88e, 0xa87c, 0xc0e4, 0xa87e, 0xd0cc, 0x0140, 0xc0cc,
-	0xa87e, 0x0096, 0xa878, 0x2048, 0x080c, 0x0f9d, 0x009e, 0x080c,
-	0xbe64, 0x0804, 0xb441, 0xd1dc, 0x0158, 0xa87b, 0x0015, 0xb07b,
-	0x0015, 0x080c, 0xc0f4, 0x0118, 0xb174, 0xc1dc, 0xb176, 0x0078,
-	0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b, 0x0007, 0x0040, 0xa87c,
-	0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xb23a, 0xa87c,
-	0xb07e, 0xa890, 0xb092, 0xa88c, 0xb08e, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x0019, 0x20a0, 0x20a9, 0x0020, 0x8a06, 0x8006, 0x8007,
-	0x9094, 0x003f, 0x22e0, 0x9084, 0xffc0, 0x9080, 0x0019, 0x2098,
-	0x4003, 0x00ae, 0x000e, 0xa882, 0x000e, 0xa87e, 0x080c, 0xc1d1,
-	0x001e, 0xa874, 0x0006, 0x2148, 0x080c, 0x0f9d, 0x001e, 0x0804,
-	0xb43d, 0x0016, 0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff, 0x90b6,
-	0x0002, 0x01e0, 0x9086, 0x0028, 0x1128, 0xa87b, 0x001c, 0xb07b,
-	0x001c, 0x00e0, 0xd1dc, 0x0158, 0xa87b, 0x0015, 0xb07b, 0x0015,
-	0x080c, 0xc0f4, 0x0118, 0xb174, 0xc1dc, 0xb176, 0x0078, 0xd1d4,
-	0x0128, 0xa87b, 0x0007, 0xb07b, 0x0007, 0x0040, 0xa87c, 0xd0ac,
-	0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xb23a, 0xa890, 0xb092,
-	0xa88c, 0xb08e, 0xa87c, 0xb07e, 0x00ae, 0x080c, 0x0f9d, 0x009e,
-	0x080c, 0xc1d1, 0xa974, 0x0016, 0x080c, 0xb715, 0x001e, 0x0468,
-	0xa867, 0x0103, 0xa974, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x01b0,
-	0x9086, 0x0028, 0x1118, 0xa87b, 0x001c, 0x00d0, 0xd1dc, 0x0148,
-	0xa87b, 0x0015, 0x080c, 0xc0f4, 0x0118, 0xa974, 0xc1dc, 0xa976,
-	0x0078, 0xd1d4, 0x0118, 0xa87b, 0x0007, 0x0050, 0xa87b, 0x0000,
-	0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xb23a,
-	0xa974, 0x0016, 0x080c, 0x66ac, 0x001e, 0xd1e4, 0x1120, 0x080c,
-	0x9e42, 0x009e, 0x0005, 0x080c, 0xbe2a, 0x0cd8, 0x6114, 0x0096,
-	0x2148, 0xa97c, 0xd1e4, 0x190c, 0x18fb, 0x009e, 0x0005, 0x080c,
-	0x8861, 0x0010, 0x080c, 0x891d, 0x080c, 0xbb2c, 0x01f0, 0x0096,
-	0x6114, 0x2148, 0x080c, 0xbd32, 0x1118, 0x080c, 0xa7d1, 0x00a0,
-	0xa867, 0x0103, 0x2009, 0x180c, 0x210c, 0xd18c, 0x11b8, 0xd184,
-	0x1190, 0x6108, 0xa97a, 0x918e, 0x0029, 0x1110, 0x080c, 0xd7f4,
-	0xa877, 0x0000, 0x080c, 0x6891, 0x009e, 0x080c, 0x9e42, 0x080c,
-	0x896d, 0x0804, 0x8a4a, 0xa87b, 0x0004, 0x0c90, 0xa87b, 0x0004,
-	0x0c78, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a,
-	0x0005, 0xb49d, 0xb49d, 0xb49d, 0xb49d, 0xb49d, 0xb49f, 0xb49d,
-	0xb49d, 0xb49d, 0xb49d, 0xb49d, 0xb49d, 0xb49d, 0xb49d, 0xb49d,
-	0xb49d, 0xb49d, 0xb49d, 0xb49d, 0xb49d, 0x080c, 0x0db4, 0x080c,
-	0x5397, 0x01f8, 0x6014, 0x7144, 0x918c, 0x0fff, 0x9016, 0xd1c4,
-	0x0118, 0x7264, 0x9294, 0x00ff, 0x0096, 0x904d, 0x0188, 0xa87b,
-	0x0000, 0xa864, 0x9086, 0x0139, 0x0128, 0xa867, 0x0103, 0xa976,
-	0xaa96, 0x0030, 0xa897, 0x4000, 0xa99a, 0xaa9e, 0x080c, 0x6891,
-	0x009e, 0x0804, 0x9e42, 0x9182, 0x0085, 0x0002, 0xb4d5, 0xb4d3,
-	0xb4d3, 0xb4e1, 0xb4d3, 0xb4d3, 0xb4d3, 0xb4d3, 0xb4d3, 0xb4d3,
-	0xb4d3, 0xb4d3, 0xb4d3, 0x080c, 0x0db4, 0x6003, 0x0001, 0x6106,
-	0x080c, 0x83da, 0x0126, 0x2091, 0x8000, 0x080c, 0x896d, 0x012e,
-	0x0005, 0x0026, 0x0056, 0x00d6, 0x00e6, 0x2071, 0x0260, 0x7224,
-	0x6216, 0x7220, 0x080c, 0xbb1a, 0x01a0, 0x2268, 0x6800, 0x9086,
-	0x0000, 0x0178, 0x6010, 0x6d10, 0x952e, 0x1158, 0x00c6, 0x2d60,
-	0x080c, 0xb750, 0x00ce, 0x0128, 0x6803, 0x0002, 0x6007, 0x0086,
-	0x0010, 0x6007, 0x0087, 0x6003, 0x0001, 0x080c, 0x83da, 0x080c,
-	0x896d, 0x9280, 0x0004, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
-	0x0140, 0x6824, 0xd0ec, 0x0128, 0x00c6, 0x2260, 0x080c, 0xbe64,
-	0x00ce, 0x00ee, 0x00de, 0x005e, 0x002e, 0x0005, 0x9186, 0x0013,
-	0x1160, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0db4, 0x908a, 0x0092,
-	0x1a0c, 0x0db4, 0x9082, 0x0085, 0x00e2, 0x9186, 0x0027, 0x0120,
-	0x9186, 0x0014, 0x190c, 0x0db4, 0x080c, 0x8861, 0x0096, 0x6014,
-	0x2048, 0x080c, 0xbb2c, 0x0140, 0xa867, 0x0103, 0xa877, 0x0000,
-	0xa87b, 0x0029, 0x080c, 0x6891, 0x009e, 0x080c, 0x9e72, 0x0804,
-	0x896d, 0xb556, 0xb558, 0xb558, 0xb556, 0xb556, 0xb556, 0xb556,
-	0xb556, 0xb556, 0xb556, 0xb556, 0xb556, 0xb556, 0x080c, 0x0db4,
-	0x080c, 0x8861, 0x080c, 0x9e72, 0x080c, 0x896d, 0x0005, 0x9186,
-	0x0013, 0x1128, 0x6004, 0x9082, 0x0085, 0x2008, 0x04b8, 0x9186,
-	0x0027, 0x11f8, 0x080c, 0x8861, 0x080c, 0x2fdc, 0x080c, 0xc241,
-	0x0096, 0x6014, 0x2048, 0x080c, 0xbb2c, 0x0150, 0xa867, 0x0103,
-	0xa877, 0x0000, 0xa87b, 0x0029, 0x080c, 0x6891, 0x080c, 0xbd15,
-	0x009e, 0x080c, 0x9e42, 0x080c, 0x896d, 0x0005, 0x080c, 0x9ed7,
-	0x0ce0, 0x9186, 0x0014, 0x1dd0, 0x080c, 0x8861, 0x0096, 0x6014,
-	0x2048, 0x080c, 0xbb2c, 0x0d60, 0xa867, 0x0103, 0xa877, 0x0000,
-	0xa87b, 0x0006, 0xa880, 0xc0ec, 0xa882, 0x08f0, 0x0002, 0xb5ae,
-	0xb5ac, 0xb5ac, 0xb5ac, 0xb5ac, 0xb5ac, 0xb5c6, 0xb5ac, 0xb5ac,
-	0xb5ac, 0xb5ac, 0xb5ac, 0xb5ac, 0x080c, 0x0db4, 0x080c, 0x8861,
-	0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186,
-	0x0035, 0x1118, 0x2001, 0x1956, 0x0010, 0x2001, 0x1957, 0x2004,
-	0x601a, 0x6003, 0x000c, 0x080c, 0x896d, 0x0005, 0x080c, 0x8861,
-	0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186,
-	0x0035, 0x1118, 0x2001, 0x1956, 0x0010, 0x2001, 0x1957, 0x2004,
-	0x601a, 0x6003, 0x000e, 0x080c, 0x896d, 0x0005, 0x9182, 0x0092,
-	0x1220, 0x9182, 0x0085, 0x0208, 0x0012, 0x0804, 0x9ed7, 0xb5f4,
-	0xb5f4, 0xb5f4, 0xb5f4, 0xb5f6, 0xb643, 0xb5f4, 0xb5f4, 0xb5f4,
-	0xb5f4, 0xb5f4, 0xb5f4, 0xb5f4, 0x080c, 0x0db4, 0x0096, 0x6010,
-	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0168, 0x6034, 0x908c,
-	0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118,
-	0x009e, 0x0804, 0xb657, 0x080c, 0xbb2c, 0x1118, 0x080c, 0xbd15,
-	0x0068, 0x6014, 0x2048, 0xa87c, 0xd0e4, 0x1110, 0x080c, 0xbd15,
-	0xa867, 0x0103, 0x080c, 0xc20c, 0x080c, 0x6891, 0x00d6, 0x2c68,
-	0x080c, 0x9dec, 0x01d0, 0x6003, 0x0001, 0x6007, 0x001e, 0x600b,
-	0xffff, 0x2009, 0x026e, 0x210c, 0x613a, 0x2009, 0x026f, 0x210c,
-	0x613e, 0x6910, 0x6112, 0x080c, 0xbfa6, 0x6954, 0x6156, 0x6023,
-	0x0001, 0x080c, 0x83da, 0x080c, 0x896d, 0x2d60, 0x00de, 0x080c,
-	0x9e42, 0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
-	0xd0bc, 0x05a0, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0035,
-	0x0130, 0x9186, 0x001e, 0x0118, 0x9186, 0x0039, 0x1538, 0x00d6,
-	0x2c68, 0x080c, 0xc1a4, 0x11f0, 0x080c, 0x9dec, 0x01d8, 0x6106,
-	0x6003, 0x0001, 0x6023, 0x0001, 0x6910, 0x6112, 0x692c, 0x612e,
-	0x6930, 0x6132, 0x6934, 0x918c, 0x00ff, 0x6136, 0x6938, 0x613a,
-	0x693c, 0x613e, 0x6954, 0x6156, 0x080c, 0xbfa6, 0x080c, 0x83da,
-	0x080c, 0x896d, 0x2d60, 0x00de, 0x0804, 0x9e42, 0x0096, 0x6014,
-	0x2048, 0x080c, 0xbb2c, 0x01c8, 0xa867, 0x0103, 0xa880, 0xd0b4,
-	0x0128, 0xc0ec, 0xa882, 0xa87b, 0x0006, 0x0048, 0xd0bc, 0x0118,
-	0xa87b, 0x0002, 0x0020, 0xa87b, 0x0005, 0x080c, 0xbe26, 0xa877,
-	0x0000, 0x080c, 0x6891, 0x080c, 0xbd15, 0x009e, 0x0804, 0x9e42,
-	0x0016, 0x0096, 0x6014, 0x2048, 0x080c, 0xbb2c, 0x0140, 0xa867,
-	0x0103, 0xa87b, 0x0028, 0xa877, 0x0000, 0x080c, 0x6891, 0x009e,
-	0x001e, 0x9186, 0x0013, 0x0148, 0x9186, 0x0014, 0x0130, 0x9186,
-	0x0027, 0x0118, 0x080c, 0x9ed7, 0x0030, 0x080c, 0x8861, 0x080c,
-	0x9e72, 0x080c, 0x896d, 0x0005, 0x0056, 0x0066, 0x0096, 0x00a6,
-	0x2029, 0x0001, 0x9182, 0x0101, 0x1208, 0x0010, 0x2009, 0x0100,
-	0x2130, 0x8304, 0x9098, 0x0018, 0x2009, 0x0020, 0x2011, 0x0029,
-	0x080c, 0xb725, 0x96b2, 0x0020, 0xb004, 0x904d, 0x0110, 0x080c,
-	0x0f9d, 0x080c, 0x0feb, 0x0520, 0x8528, 0xa867, 0x0110, 0xa86b,
-	0x0000, 0x2920, 0xb406, 0x968a, 0x003d, 0x1228, 0x2608, 0x2011,
-	0x001b, 0x0499, 0x00a8, 0x96b2, 0x003c, 0x2009, 0x003c, 0x2950,
-	0x2011, 0x001b, 0x0451, 0x0c28, 0x2001, 0x0205, 0x2003, 0x0000,
-	0x00ae, 0x852f, 0x95ad, 0x0003, 0xb566, 0x95ac, 0x0000, 0x0048,
-	0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0003,
-	0xb566, 0x009e, 0x006e, 0x005e, 0x0005, 0x00a6, 0x89ff, 0x0158,
-	0xa804, 0x9055, 0x0130, 0xa807, 0x0000, 0x080c, 0x6891, 0x2a48,
-	0x0cb8, 0x080c, 0x6891, 0x00ae, 0x0005, 0x00f6, 0x2079, 0x0200,
-	0x7814, 0x9085, 0x0080, 0x7816, 0xd184, 0x0108, 0x8108, 0x810c,
-	0x20a9, 0x0001, 0xa860, 0x20e8, 0xa85c, 0x9200, 0x20a0, 0x20e1,
-	0x0000, 0x2300, 0x9e00, 0x2098, 0x4003, 0x8318, 0x9386, 0x0020,
-	0x1148, 0x2018, 0x2300, 0x9e00, 0x2098, 0x7814, 0x8000, 0x9085,
-	0x0080, 0x7816, 0x8109, 0x1d80, 0x7817, 0x0000, 0x00fe, 0x0005,
-	0x0066, 0x0126, 0x2091, 0x8000, 0x2031, 0x0001, 0x6020, 0x9084,
-	0x000f, 0x0083, 0x012e, 0x006e, 0x0005, 0x0126, 0x2091, 0x8000,
-	0x0066, 0x2031, 0x0000, 0x6020, 0x9084, 0x000f, 0x001b, 0x006e,
-	0x012e, 0x0005, 0xb78b, 0xb78b, 0xb786, 0xb7ad, 0xb779, 0xb786,
-	0xb7ad, 0xb786, 0xb779, 0xb779, 0xb786, 0xb786, 0xb786, 0xb779,
-	0xb779, 0x080c, 0x0db4, 0x0036, 0x2019, 0x0010, 0x080c, 0xd106,
-	0x6023, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x9006, 0x0005,
-	0x9085, 0x0001, 0x0005, 0x0096, 0x86ff, 0x11d8, 0x6014, 0x2048,
-	0x080c, 0xbb2c, 0x01c0, 0xa864, 0x9086, 0x0139, 0x1128, 0xa87b,
-	0x0005, 0xa883, 0x0000, 0x0028, 0x900e, 0x2001, 0x0005, 0x080c,
-	0x6abf, 0x080c, 0xbe26, 0x080c, 0x6884, 0x080c, 0x9e72, 0x9085,
-	0x0001, 0x009e, 0x0005, 0x9006, 0x0ce0, 0x6000, 0x908a, 0x0016,
-	0x1a0c, 0x0db4, 0x0002, 0xb7c3, 0xb7f1, 0xb7c5, 0xb812, 0xb7ec,
-	0xb7c3, 0xb786, 0xb78b, 0xb78b, 0xb786, 0xb786, 0xb786, 0xb786,
-	0xb786, 0xb786, 0xb786, 0x080c, 0x0db4, 0x86ff, 0x1510, 0x6020,
-	0x9086, 0x0006, 0x01f0, 0x0096, 0x6014, 0x2048, 0x080c, 0xbb2c,
-	0x0158, 0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c,
-	0x0f9d, 0x009e, 0x080c, 0xbe26, 0x009e, 0x080c, 0xc1e6, 0x6007,
-	0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x080c, 0x83da, 0x080c,
-	0x896d, 0x9085, 0x0001, 0x0005, 0x0066, 0x080c, 0x190f, 0x006e,
-	0x08a0, 0x00e6, 0x2071, 0x19b7, 0x7024, 0x9c06, 0x1120, 0x080c,
-	0x9663, 0x00ee, 0x0850, 0x6020, 0x9084, 0x000f, 0x9086, 0x0006,
-	0x1150, 0x0086, 0x0096, 0x2049, 0x0001, 0x2c40, 0x080c, 0x97bb,
-	0x009e, 0x008e, 0x0010, 0x080c, 0x9560, 0x00ee, 0x1904, 0xb7c5,
-	0x0804, 0xb786, 0x0036, 0x00e6, 0x2071, 0x19b7, 0x703c, 0x9c06,
-	0x1138, 0x901e, 0x080c, 0x96d9, 0x00ee, 0x003e, 0x0804, 0xb7c5,
-	0x080c, 0x98eb, 0x00ee, 0x003e, 0x1904, 0xb7c5, 0x0804, 0xb786,
-	0x00c6, 0x6020, 0x9084, 0x000f, 0x0013, 0x00ce, 0x0005, 0xb845,
-	0xb910, 0xba77, 0xb84f, 0x9e72, 0xb845, 0xd0f8, 0xc24e, 0xb910,
-	0xb83e, 0xbaf6, 0xb83e, 0xb83e, 0xb83e, 0xb83e, 0x080c, 0x0db4,
-	0x080c, 0xbd32, 0x1110, 0x080c, 0xa7d1, 0x0005, 0x080c, 0x8861,
-	0x080c, 0x896d, 0x0804, 0x9e42, 0x601b, 0x0001, 0x0005, 0x080c,
-	0xbb2c, 0x0130, 0x6014, 0x0096, 0x2048, 0x2c00, 0xa896, 0x009e,
-	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0db4, 0x0002, 0xb86e, 0xb870,
-	0xb894, 0xb8a8, 0xb8ce, 0xb86e, 0xb845, 0xb845, 0xb845, 0xb8a8,
-	0xb8a8, 0xb86e, 0xb86e, 0xb86e, 0xb86e, 0xb8b2, 0x080c, 0x0db4,
-	0x00e6, 0x6014, 0x0096, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e,
-	0x2071, 0x19b7, 0x7024, 0x9c06, 0x01a0, 0x080c, 0x9560, 0x080c,
-	0xc1e6, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2001,
-	0x1957, 0x2004, 0x601a, 0x080c, 0x83da, 0x080c, 0x896d, 0x00ee,
-	0x0005, 0x601b, 0x0001, 0x0cd8, 0x0096, 0x6014, 0x2048, 0xa880,
-	0xc0b5, 0xa882, 0x009e, 0x080c, 0xc1e6, 0x6007, 0x0085, 0x6003,
-	0x000b, 0x6023, 0x0002, 0x080c, 0x83da, 0x080c, 0x896d, 0x0005,
-	0x0096, 0x601b, 0x0001, 0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882,
-	0x009e, 0x0005, 0x080c, 0x5397, 0x01b8, 0x6014, 0x0096, 0x904d,
-	0x0190, 0xa864, 0xa867, 0x0103, 0xa87b, 0x0006, 0x9086, 0x0139,
-	0x1150, 0xa867, 0x0139, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa89b,
-	0x0004, 0x080c, 0x6891, 0x009e, 0x0804, 0x9e42, 0x6014, 0x0096,
-	0x904d, 0x05c8, 0xa97c, 0xd1e4, 0x05b0, 0x2001, 0x180f, 0x2004,
-	0xd0c4, 0x0110, 0x009e, 0x0005, 0xa884, 0x009e, 0x8003, 0x800b,
-	0x810b, 0x9108, 0x611a, 0x2001, 0x0030, 0x2c08, 0x080c, 0x151a,
-	0x2001, 0x030c, 0x2004, 0x9086, 0x0041, 0x11a0, 0x6014, 0x0096,
-	0x904d, 0x090c, 0x0db4, 0xa880, 0xd0f4, 0x1130, 0xc0f5, 0xa882,
-	0x009e, 0x601b, 0x0002, 0x0070, 0x009e, 0x2001, 0x0037, 0x2c08,
-	0x080c, 0x151a, 0x6000, 0x9086, 0x0004, 0x1120, 0x2009, 0x0048,
-	0x080c, 0x9ebc, 0x0005, 0x009e, 0x080c, 0x190f, 0x0804, 0xb894,
-	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0db4, 0x000b, 0x0005, 0xb927,
-	0xb84c, 0xb929, 0xb927, 0xb929, 0xb929, 0xb846, 0xb927, 0xb840,
-	0xb840, 0xb927, 0xb927, 0xb927, 0xb927, 0xb927, 0xb927, 0x080c,
-	0x0db4, 0x6010, 0x00b6, 0x2058, 0xb804, 0x9084, 0x00ff, 0x00be,
-	0x908a, 0x000c, 0x1a0c, 0x0db4, 0x00b6, 0x0013, 0x00be, 0x0005,
-	0xb944, 0xba11, 0xb946, 0xb986, 0xb946, 0xb986, 0xb946, 0xb954,
-	0xb944, 0xb986, 0xb944, 0xb975, 0x080c, 0x0db4, 0x6004, 0x908e,
-	0x0016, 0x05c0, 0x908e, 0x0004, 0x05a8, 0x908e, 0x0002, 0x0590,
-	0x908e, 0x0052, 0x0904, 0xba0d, 0x6004, 0x080c, 0xbd32, 0x0904,
-	0xba2a, 0x908e, 0x0004, 0x1110, 0x080c, 0x3005, 0x908e, 0x0021,
-	0x0904, 0xba2e, 0x908e, 0x0022, 0x0904, 0xba72, 0x908e, 0x003d,
-	0x0904, 0xba2e, 0x908e, 0x0039, 0x0904, 0xba32, 0x908e, 0x0035,
-	0x0904, 0xba32, 0x908e, 0x001e, 0x0178, 0x908e, 0x0001, 0x1140,
-	0x6010, 0x2058, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x0110,
-	0x080c, 0x2fdc, 0x080c, 0xa7d1, 0x0804, 0x9e72, 0x00c6, 0x00d6,
-	0x6104, 0x9186, 0x0016, 0x0904, 0xb9fe, 0x9186, 0x0002, 0x1904,
-	0xb9d3, 0x2001, 0x1836, 0x2004, 0xd08c, 0x11c8, 0x080c, 0x6f9b,
-	0x11b0, 0x080c, 0xc22c, 0x0138, 0x080c, 0x6fbe, 0x1120, 0x080c,
-	0x6eab, 0x0804, 0xba5b, 0x2001, 0x194d, 0x2003, 0x0001, 0x2001,
-	0x1800, 0x2003, 0x0001, 0x080c, 0x6ecd, 0x0804, 0xba5b, 0x6010,
-	0x2058, 0x2001, 0x1836, 0x2004, 0xd0ac, 0x1904, 0xba5b, 0xb8a0,
-	0x9084, 0xff80, 0x1904, 0xba5b, 0xb840, 0x9084, 0x00ff, 0x9005,
-	0x0190, 0x8001, 0xb842, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b,
-	0x0398, 0x6043, 0x0000, 0x080c, 0x9dec, 0x0128, 0x2b00, 0x6012,
-	0x6023, 0x0001, 0x0458, 0x00de, 0x00ce, 0x6004, 0x908e, 0x0002,
-	0x11a0, 0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e, 0x1170, 0x2009,
-	0x1836, 0x2104, 0xc085, 0x200a, 0x00e6, 0x2071, 0x1800, 0x080c,
-	0x5c6d, 0x00ee, 0x080c, 0xa7d1, 0x0030, 0x080c, 0xa7d1, 0x080c,
-	0x2fdc, 0x080c, 0xc241, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x3005, 0x012e, 0x00ee, 0x080c, 0x9e72, 0x0005, 0x2001, 0x0002,
-	0x080c, 0x6198, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8422,
-	0x080c, 0x896d, 0x00de, 0x00ce, 0x0c80, 0x080c, 0x3005, 0x0804,
-	0xb982, 0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016, 0x0d38, 0x6010,
-	0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0904, 0xb9d3, 0x8001,
-	0xb842, 0x6003, 0x0001, 0x080c, 0x8422, 0x080c, 0x896d, 0x00de,
-	0x00ce, 0x0898, 0x080c, 0xa7d1, 0x0804, 0xb984, 0x080c, 0xa80d,
-	0x0804, 0xb984, 0x00d6, 0x2c68, 0x6104, 0x080c, 0xc1a4, 0x00de,
-	0x0118, 0x080c, 0x9e42, 0x00f0, 0x6004, 0x8007, 0x6134, 0x918c,
-	0x00ff, 0x9105, 0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
-	0x0002, 0x603c, 0x600a, 0x2001, 0x1957, 0x2004, 0x601a, 0x602c,
-	0x2c08, 0x2060, 0x6024, 0xc0b5, 0x6026, 0x2160, 0x080c, 0x83da,
-	0x080c, 0x896d, 0x0005, 0x00de, 0x00ce, 0x080c, 0xa7d1, 0x080c,
-	0x2fdc, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x3005, 0x6017,
-	0x0000, 0x6023, 0x0007, 0x601b, 0x0398, 0x6043, 0x0000, 0x012e,
-	0x00ee, 0x0005, 0x080c, 0xa272, 0x1904, 0xba2a, 0x0005, 0x6000,
-	0x908a, 0x0016, 0x1a0c, 0x0db4, 0x0096, 0x00d6, 0x001b, 0x00de,
-	0x009e, 0x0005, 0xba92, 0xba92, 0xba92, 0xba92, 0xba92, 0xba92,
-	0xba92, 0xba92, 0xba92, 0xb845, 0xba92, 0xb84c, 0xba94, 0xb84c,
-	0xbaa1, 0xba92, 0x080c, 0x0db4, 0x6004, 0x9086, 0x008b, 0x0148,
-	0x6007, 0x008b, 0x6003, 0x000d, 0x080c, 0x83da, 0x080c, 0x896d,
-	0x0005, 0x080c, 0xc220, 0x0118, 0x080c, 0xc233, 0x0010, 0x080c,
-	0xc241, 0x080c, 0xbd15, 0x080c, 0xbb2c, 0x0570, 0x080c, 0x2fdc,
-	0x080c, 0xbb2c, 0x0168, 0x6014, 0x2048, 0xa867, 0x0103, 0xa87b,
-	0x0006, 0xa877, 0x0000, 0xa880, 0xc0ed, 0xa882, 0x080c, 0x6891,
-	0x2c68, 0x080c, 0x9dec, 0x0150, 0x6810, 0x6012, 0x080c, 0xbfa6,
-	0x00c6, 0x2d60, 0x080c, 0x9e72, 0x00ce, 0x0008, 0x2d60, 0x6017,
-	0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
-	0x8422, 0x080c, 0x896d, 0x00c8, 0x080c, 0xc220, 0x0138, 0x6034,
-	0x9086, 0x4000, 0x1118, 0x080c, 0x2fdc, 0x08d0, 0x6034, 0x908c,
-	0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118,
-	0x080c, 0x2fdc, 0x0868, 0x080c, 0x9e72, 0x0005, 0x6000, 0x908a,
-	0x0016, 0x1a0c, 0x0db4, 0x0002, 0xbb0c, 0xbb0c, 0xbb0e, 0xbb0e,
-	0xbb0e, 0xbb0c, 0xbb0c, 0x9e72, 0xbb0c, 0xbb0c, 0xbb0c, 0xbb0c,
-	0xbb0c, 0xbb0c, 0xbb0c, 0xbb0c, 0x080c, 0x0db4, 0x080c, 0x98eb,
-	0x6114, 0x0096, 0x2148, 0xa87b, 0x0006, 0x080c, 0x6891, 0x009e,
-	0x0804, 0x9e42, 0x9284, 0x0007, 0x1158, 0x9282, 0x1cd0, 0x0240,
-	0x2001, 0x1819, 0x2004, 0x9202, 0x1218, 0x9085, 0x0001, 0x0005,
-	0x9006, 0x0ce8, 0x0096, 0x0028, 0x0096, 0x0006, 0x6014, 0x2048,
-	0x000e, 0x0006, 0x9984, 0xf000, 0x9086, 0xf000, 0x0110, 0x080c,
-	0x1096, 0x000e, 0x009e, 0x0005, 0x00e6, 0x00c6, 0x0036, 0x0006,
-	0x0126, 0x2091, 0x8000, 0x2061, 0x1cd0, 0x2071, 0x1800, 0x7350,
-	0x7070, 0x9302, 0x1640, 0x6020, 0x9206, 0x11f8, 0x080c, 0xc22c,
-	0x0180, 0x9286, 0x0001, 0x1168, 0x6004, 0x9086, 0x0004, 0x1148,
-	0x080c, 0x2fdc, 0x080c, 0xc241, 0x00c6, 0x080c, 0x9e72, 0x00ce,
-	0x0060, 0x080c, 0xbf20, 0x0148, 0x080c, 0xbd32, 0x1110, 0x080c,
-	0xa7d1, 0x00c6, 0x080c, 0x9e42, 0x00ce, 0x9ce0, 0x0018, 0x7064,
-	0x9c02, 0x1208, 0x08a0, 0x012e, 0x000e, 0x003e, 0x00ce, 0x00ee,
-	0x0005, 0x00e6, 0x00c6, 0x0016, 0x9188, 0x1000, 0x210c, 0x81ff,
-	0x0128, 0x2061, 0x1a7f, 0x6112, 0x080c, 0x2fdc, 0x9006, 0x0010,
-	0x9085, 0x0001, 0x001e, 0x00ce, 0x00ee, 0x0005, 0x00c6, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x9dec, 0x01b0, 0x6656, 0x2b00, 0x6012,
-	0x080c, 0x5397, 0x0118, 0x080c, 0xbc59, 0x0168, 0x080c, 0xbfa6,
-	0x6023, 0x0003, 0x2009, 0x004b, 0x080c, 0x9ebc, 0x9085, 0x0001,
+	0x4000, 0x080c, 0xc11a, 0x0060, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x0029, 0x0130, 0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0x0200,
+	0x009e, 0x080c, 0x3010, 0x6020, 0x9086, 0x000a, 0x0138, 0x080c,
+	0x9e2f, 0x0020, 0x080c, 0xa7cd, 0x080c, 0xaa70, 0x001e, 0x002e,
+	0x00ee, 0x00be, 0x0005, 0x2011, 0x1823, 0x2204, 0x9086, 0x0014,
+	0x1160, 0x2001, 0x0002, 0x080c, 0x61a7, 0x6003, 0x0001, 0x6007,
+	0x0001, 0x080c, 0x8440, 0x0804, 0x898b, 0x0804, 0xaa70, 0x2030,
+	0x2011, 0x1823, 0x2204, 0x9086, 0x0004, 0x1148, 0x96b6, 0x000b,
+	0x1120, 0x2001, 0x0007, 0x080c, 0x61a7, 0x0804, 0x9e2f, 0x0804,
+	0xaa70, 0x0002, 0xa8ae, 0xab69, 0xa8ae, 0xaba8, 0xa8ae, 0xac53,
+	0xab5e, 0xa8ae, 0xa8ae, 0xac66, 0xa8ae, 0xac76, 0x6604, 0x9686,
+	0x0003, 0x0904, 0xaa85, 0x96b6, 0x001e, 0x1110, 0x080c, 0x9e2f,
+	0x0005, 0x00b6, 0x00d6, 0x00c6, 0x080c, 0xac86, 0x11a0, 0x9006,
+	0x080c, 0x6193, 0x080c, 0x2fe7, 0x080c, 0xc250, 0x2001, 0x0002,
+	0x080c, 0x61a7, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8440,
+	0x080c, 0x898b, 0x0408, 0x2009, 0x026e, 0x2104, 0x9086, 0x0009,
+	0x1160, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0170,
+	0x8001, 0xb842, 0x601b, 0x000a, 0x0078, 0x2009, 0x026f, 0x2104,
+	0x9084, 0xff00, 0x9086, 0x1900, 0x1108, 0x08a0, 0x080c, 0x2fe7,
+	0x080c, 0xc250, 0x080c, 0xaa70, 0x00ce, 0x00de, 0x00be, 0x0005,
+	0x0096, 0x00b6, 0x0026, 0x9016, 0x080c, 0xac94, 0x00d6, 0x2069,
+	0x1954, 0x2d04, 0x9005, 0x0168, 0x6010, 0x2058, 0xb8a0, 0x9086,
+	0x007e, 0x1138, 0x2069, 0x181f, 0x2d04, 0x8000, 0x206a, 0x00de,
+	0x0010, 0x00de, 0x0088, 0x9006, 0x080c, 0x6193, 0x2001, 0x0002,
+	0x080c, 0x61a7, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8440,
+	0x080c, 0x898b, 0x0804, 0xac23, 0x080c, 0xbb3b, 0x01b0, 0x6014,
+	0x2048, 0xa864, 0x2010, 0x9086, 0x0139, 0x1138, 0x6007, 0x0016,
+	0x2001, 0x0002, 0x080c, 0xc174, 0x00b0, 0x6014, 0x2048, 0xa864,
+	0xd0fc, 0x0118, 0x2001, 0x0001, 0x0ca8, 0x2001, 0x180e, 0x2004,
+	0xd0dc, 0x0148, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005,
+	0x1110, 0x9006, 0x0c38, 0x080c, 0xa7cd, 0x2009, 0x026e, 0x2134,
+	0x96b4, 0x00ff, 0x9686, 0x0005, 0x0510, 0x9686, 0x000b, 0x01c8,
+	0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x1118, 0x9686, 0x0009,
+	0x01b0, 0x9086, 0x1900, 0x1168, 0x9686, 0x0009, 0x0180, 0x2001,
+	0x0004, 0x080c, 0x61a7, 0x2001, 0x0028, 0x601a, 0x6007, 0x0052,
+	0x0010, 0x080c, 0xaa70, 0x002e, 0x00be, 0x009e, 0x0005, 0x9286,
+	0x0139, 0x0160, 0x6014, 0x2048, 0x080c, 0xbb3b, 0x0140, 0xa864,
+	0x9086, 0x0139, 0x0118, 0xa868, 0xd0fc, 0x0108, 0x0c50, 0x6010,
+	0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0138, 0x8001, 0xb842,
+	0x601b, 0x000a, 0x6007, 0x0016, 0x08f0, 0xb8a0, 0x9086, 0x007e,
+	0x1138, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5c78, 0x00ee, 0x0010,
+	0x080c, 0x2fe7, 0x0870, 0x080c, 0xac94, 0x1160, 0x2001, 0x0004,
+	0x080c, 0x61a7, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c, 0x8440,
+	0x0804, 0x898b, 0x080c, 0xa7cd, 0x0804, 0xaa70, 0x0469, 0x1160,
+	0x2001, 0x0008, 0x080c, 0x61a7, 0x6003, 0x0001, 0x6007, 0x0005,
+	0x080c, 0x8440, 0x0804, 0x898b, 0x0804, 0xaa70, 0x00e9, 0x1160,
+	0x2001, 0x000a, 0x080c, 0x61a7, 0x6003, 0x0001, 0x6007, 0x0001,
+	0x080c, 0x8440, 0x0804, 0x898b, 0x0804, 0xaa70, 0x2009, 0x026e,
+	0x2104, 0x9086, 0x0003, 0x1138, 0x2009, 0x026f, 0x2104, 0x9084,
+	0xff00, 0x9086, 0x2a00, 0x0005, 0x9085, 0x0001, 0x0005, 0x00b6,
+	0x00c6, 0x0016, 0x6110, 0x2158, 0x080c, 0x6265, 0x001e, 0x00ce,
+	0x00be, 0x0005, 0x00b6, 0x00f6, 0x00e6, 0x00d6, 0x0036, 0x0016,
+	0x6010, 0x2058, 0x2009, 0x1836, 0x2104, 0x9085, 0x0003, 0x200a,
+	0x080c, 0xad3a, 0x0560, 0x2009, 0x1836, 0x2104, 0xc0cd, 0x200a,
+	0x080c, 0x6576, 0x0158, 0x9006, 0x2020, 0x2009, 0x002a, 0x080c,
+	0xd564, 0x2001, 0x180c, 0x200c, 0xc195, 0x2102, 0x2019, 0x002a,
+	0x2009, 0x0001, 0x080c, 0x2fb2, 0x00e6, 0x2071, 0x1800, 0x080c,
+	0x2dc8, 0x00ee, 0x00c6, 0x0156, 0x20a9, 0x0781, 0x2009, 0x007f,
+	0x080c, 0x30e2, 0x8108, 0x1f04, 0xacd8, 0x015e, 0x00ce, 0x080c,
+	0xac97, 0x2071, 0x0260, 0x2079, 0x0200, 0x7817, 0x0001, 0x2001,
+	0x1836, 0x200c, 0xc1c5, 0x7018, 0xd0fc, 0x0110, 0xd0dc, 0x0118,
+	0x7038, 0xd0dc, 0x1108, 0xc1c4, 0x7817, 0x0000, 0x2001, 0x1836,
+	0x2102, 0x2079, 0x0100, 0x2e04, 0x9084, 0x00ff, 0x2069, 0x181e,
+	0x206a, 0x78e6, 0x0006, 0x8e70, 0x2e04, 0x2069, 0x181f, 0x206a,
+	0x78ea, 0x7832, 0x7836, 0x2010, 0x9084, 0xff00, 0x001e, 0x9105,
+	0x2009, 0x182b, 0x200a, 0x2200, 0x9084, 0x00ff, 0x2008, 0x080c,
+	0x26b9, 0x080c, 0x6faa, 0x0170, 0x2071, 0x0260, 0x2069, 0x195a,
+	0x7048, 0x206a, 0x704c, 0x6806, 0x7050, 0x680a, 0x7054, 0x680e,
+	0x080c, 0xbf4f, 0x0040, 0x2001, 0x0006, 0x080c, 0x61a7, 0x080c,
+	0x3010, 0x080c, 0x9e2f, 0x001e, 0x003e, 0x00de, 0x00ee, 0x00fe,
+	0x00be, 0x0005, 0x0096, 0x0026, 0x0036, 0x00e6, 0x0156, 0x2019,
+	0x182b, 0x231c, 0x83ff, 0x01f0, 0x2071, 0x0260, 0x7200, 0x9294,
+	0x00ff, 0x7004, 0x9084, 0xff00, 0x9205, 0x9306, 0x1198, 0x2011,
+	0x0276, 0x20a9, 0x0004, 0x2b48, 0x2019, 0x000a, 0x080c, 0xae1c,
+	0x1148, 0x2011, 0x027a, 0x20a9, 0x0004, 0x2019, 0x0006, 0x080c,
+	0xae1c, 0x1100, 0x015e, 0x00ee, 0x003e, 0x002e, 0x009e, 0x0005,
+	0x00e6, 0x2071, 0x0260, 0x7034, 0x9086, 0x0014, 0x11a8, 0x7038,
+	0x9086, 0x0800, 0x1188, 0x703c, 0xd0ec, 0x0160, 0x9084, 0x0f00,
+	0x9086, 0x0100, 0x1138, 0x7054, 0xd0a4, 0x1110, 0xd0ac, 0x0110,
+	0x9006, 0x0010, 0x9085, 0x0001, 0x00ee, 0x0005, 0x00e6, 0x0096,
+	0x00c6, 0x0076, 0x0056, 0x0046, 0x0026, 0x0006, 0x0126, 0x2091,
+	0x8000, 0x2029, 0x19c8, 0x252c, 0x2021, 0x19ce, 0x2424, 0x2061,
+	0x1cd0, 0x2071, 0x1800, 0x7250, 0x7070, 0x9202, 0x1a04, 0xadf4,
+	0x080c, 0xd595, 0x0904, 0xaded, 0x6720, 0x9786, 0x0007, 0x0904,
+	0xaded, 0x2500, 0x9c06, 0x0904, 0xaded, 0x2400, 0x9c06, 0x05e8,
+	0x3e08, 0x9186, 0x0002, 0x1148, 0x6010, 0x9005, 0x0130, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x1580, 0x00c6, 0x6000, 0x9086,
+	0x0004, 0x1110, 0x080c, 0x191f, 0x9786, 0x000a, 0x0148, 0x080c,
+	0xbd41, 0x1130, 0x00ce, 0x080c, 0xa7cd, 0x080c, 0x9e5f, 0x00e8,
+	0x6014, 0x2048, 0x080c, 0xbb3b, 0x01a8, 0x9786, 0x0003, 0x1530,
+	0xa867, 0x0103, 0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048,
+	0x080c, 0x0f9d, 0x009e, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6893,
+	0x080c, 0xbd24, 0x080c, 0x9e5f, 0x00ce, 0x9ce0, 0x0018, 0x7064,
+	0x9c02, 0x1210, 0x0804, 0xad9b, 0x012e, 0x000e, 0x002e, 0x004e,
+	0x005e, 0x007e, 0x00ce, 0x009e, 0x00ee, 0x0005, 0x9786, 0x0006,
+	0x1118, 0x080c, 0xd50f, 0x0c30, 0x9786, 0x000a, 0x0998, 0x0880,
+	0x220c, 0x2304, 0x9106, 0x1130, 0x8210, 0x8318, 0x1f04, 0xae08,
+	0x9006, 0x0005, 0x2304, 0x9102, 0x0218, 0x2001, 0x0001, 0x0008,
+	0x9006, 0x918d, 0x0001, 0x0005, 0x0136, 0x01c6, 0x0016, 0x8906,
+	0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0, 0x9300,
+	0x2098, 0x3518, 0x20a9, 0x0001, 0x220c, 0x4002, 0x910e, 0x1140,
+	0x8210, 0x8319, 0x1dc8, 0x9006, 0x001e, 0x01ce, 0x013e, 0x0005,
+	0x220c, 0x9102, 0x0218, 0x2001, 0x0001, 0x0010, 0x2001, 0x0000,
+	0x918d, 0x0001, 0x001e, 0x01ce, 0x013e, 0x0005, 0x6004, 0x908a,
+	0x0053, 0x1a0c, 0x0db4, 0x080c, 0xbd30, 0x0120, 0x080c, 0xbd41,
+	0x0168, 0x0028, 0x080c, 0x3010, 0x080c, 0xbd41, 0x0138, 0x080c,
+	0x887f, 0x080c, 0x9e2f, 0x080c, 0x898b, 0x0005, 0x080c, 0xa7cd,
+	0x0cb0, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a,
+	0x0005, 0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae7d,
+	0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae7f, 0xae7f, 0xae7f, 0xae7f,
+	0xae7d, 0xae7d, 0xae7d, 0xae7f, 0xae7d, 0x080c, 0x0db4, 0x600b,
+	0xffff, 0x6003, 0x0001, 0x6106, 0x080c, 0x83f8, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x898b, 0x012e, 0x0005, 0x9186, 0x0013, 0x1128,
+	0x6004, 0x9082, 0x0040, 0x0804, 0xaf34, 0x9186, 0x0027, 0x1520,
+	0x080c, 0x887f, 0x080c, 0x2fe7, 0x080c, 0xc250, 0x0096, 0x6114,
+	0x2148, 0x080c, 0xbb3b, 0x0198, 0x080c, 0xbd41, 0x1118, 0x080c,
+	0xa7cd, 0x0068, 0xa867, 0x0103, 0xa87b, 0x0029, 0xa877, 0x0000,
+	0xa97c, 0xc1c5, 0xa97e, 0x080c, 0x68a0, 0x080c, 0xbd24, 0x009e,
+	0x080c, 0x9e2f, 0x0804, 0x898b, 0x9186, 0x0014, 0x1120, 0x6004,
+	0x9082, 0x0040, 0x04a0, 0x9186, 0x0046, 0x0150, 0x9186, 0x0045,
+	0x0138, 0x9186, 0x0053, 0x0120, 0x9186, 0x0048, 0x190c, 0x0db4,
+	0x2001, 0x0109, 0x2004, 0xd084, 0x0508, 0x0126, 0x2091, 0x2800,
+	0x0006, 0x0016, 0x0026, 0x0036, 0x00f6, 0x00e6, 0x00c6, 0x2079,
+	0x19bf, 0x2071, 0x1800, 0x2061, 0x0100, 0x080c, 0x82e4, 0x00ce,
+	0x00ee, 0x00fe, 0x003e, 0x002e, 0x001e, 0x000e, 0x012e, 0xa001,
+	0x6000, 0x9086, 0x0002, 0x1110, 0x0804, 0xaf72, 0x0005, 0x0002,
+	0xaf0e, 0xaf0c, 0xaf0c, 0xaf0c, 0xaf0c, 0xaf0c, 0xaf0c, 0xaf0c,
+	0xaf0c, 0xaf0c, 0xaf0c, 0xaf29, 0xaf29, 0xaf29, 0xaf29, 0xaf0c,
+	0xaf29, 0xaf0c, 0xaf29, 0xaf0c, 0x080c, 0x0db4, 0x080c, 0x887f,
+	0x0096, 0x6114, 0x2148, 0x080c, 0xbb3b, 0x0168, 0xa867, 0x0103,
+	0xa87b, 0x0006, 0xa877, 0x0000, 0xa880, 0xc0ec, 0xa882, 0x080c,
+	0x68a0, 0x080c, 0xbd24, 0x009e, 0x080c, 0x9e2f, 0x080c, 0x898b,
+	0x0005, 0x080c, 0x887f, 0x080c, 0xbd41, 0x090c, 0xa7cd, 0x080c,
+	0x9e2f, 0x080c, 0x898b, 0x0005, 0x0002, 0xaf4b, 0xaf49, 0xaf49,
+	0xaf49, 0xaf49, 0xaf49, 0xaf49, 0xaf49, 0xaf49, 0xaf49, 0xaf49,
+	0xaf62, 0xaf62, 0xaf62, 0xaf62, 0xaf49, 0xaf6c, 0xaf49, 0xaf62,
+	0xaf49, 0x080c, 0x0db4, 0x0096, 0x080c, 0x887f, 0x6014, 0x2048,
+	0x2001, 0x1960, 0x2004, 0x6042, 0xa97c, 0xd1ac, 0x0140, 0x6003,
+	0x0004, 0xa87c, 0x9085, 0x0400, 0xa87e, 0x009e, 0x0005, 0x6003,
+	0x0002, 0x0cb8, 0x080c, 0x887f, 0x080c, 0xc253, 0x080c, 0xc258,
+	0x6003, 0x000f, 0x0804, 0x898b, 0x080c, 0x887f, 0x080c, 0x9e2f,
+	0x0804, 0x898b, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208,
+	0x000a, 0x0005, 0xaf8e, 0xaf8e, 0xaf8e, 0xaf8e, 0xaf8e, 0xaf90,
+	0xb06d, 0xaf8e, 0xb0a1, 0xaf8e, 0xaf8e, 0xaf8e, 0xaf8e, 0xaf8e,
+	0xaf8e, 0xaf8e, 0xaf8e, 0xaf8e, 0xaf8e, 0xb0a1, 0x080c, 0x0db4,
+	0x00b6, 0x0096, 0x6114, 0x2148, 0x7644, 0x96b4, 0x0fff, 0x86ff,
+	0x1528, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xb05c, 0xa87b,
+	0x0000, 0xa867, 0x0103, 0xae76, 0xa87c, 0xd0ac, 0x0128, 0xa834,
+	0xa938, 0x9115, 0x190c, 0xb236, 0x080c, 0x66bb, 0x6210, 0x2258,
+	0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x7044, 0xd0e4, 0x1904,
+	0xb040, 0x080c, 0x9e2f, 0x009e, 0x00be, 0x0005, 0x968c, 0x0c00,
+	0x0150, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xb044, 0x7348,
+	0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0508,
+	0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x00e8, 0xd6dc, 0x01a0,
+	0xa87b, 0x0015, 0xa87c, 0xd0ac, 0x0170, 0xa938, 0xaa34, 0x2100,
+	0x9205, 0x0148, 0x7048, 0x9106, 0x1118, 0x704c, 0x9206, 0x0118,
+	0xa992, 0xaa8e, 0xc6dc, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007,
+	0x0010, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0x901e, 0xd6c4,
+	0x01d8, 0x9686, 0x0100, 0x1130, 0x7064, 0x9005, 0x1118, 0xc6c4,
+	0x0804, 0xaf97, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009,
+	0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011,
+	0x0025, 0x080c, 0xb724, 0x003e, 0xd6cc, 0x0904, 0xafac, 0x7154,
+	0xa98a, 0x81ff, 0x0904, 0xafac, 0x9192, 0x0021, 0x1278, 0x8304,
+	0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xb724, 0x2011, 0x0205,
+	0x2013, 0x0000, 0x080c, 0xc1e0, 0x0804, 0xafac, 0xa868, 0xd0fc,
+	0x0120, 0x2009, 0x0020, 0xa98a, 0x0c50, 0x00a6, 0x2950, 0x080c,
+	0xb6c3, 0x00ae, 0x080c, 0xc1e0, 0x080c, 0xb714, 0x0804, 0xafae,
+	0x080c, 0xbe39, 0x0804, 0xafbb, 0xa87c, 0xd0ac, 0x0904, 0xafc7,
+	0xa880, 0xd0bc, 0x1904, 0xafc7, 0x7348, 0xa838, 0x9306, 0x11c8,
+	0x734c, 0xa834, 0x931e, 0x0904, 0xafc7, 0xd6d4, 0x0190, 0xab38,
+	0x9305, 0x0904, 0xafc7, 0x0068, 0xa87c, 0xd0ac, 0x0904, 0xaf9f,
+	0xa838, 0xa934, 0x9105, 0x0904, 0xaf9f, 0xa880, 0xd0bc, 0x1904,
+	0xaf9f, 0x080c, 0xbe73, 0x0804, 0xafbb, 0x0096, 0x00f6, 0x6003,
+	0x0003, 0x6007, 0x0043, 0x2079, 0x026c, 0x7c04, 0x7b00, 0x7e0c,
+	0x7d08, 0x6014, 0x2048, 0xa87c, 0xd0ac, 0x0140, 0x6003, 0x0002,
+	0x00fe, 0x009e, 0x0005, 0x2130, 0x2228, 0x0058, 0x2400, 0xa9ac,
+	0x910a, 0x2300, 0xaab0, 0x9213, 0x2600, 0x9102, 0x2500, 0x9203,
+	0x0e90, 0xac36, 0xab3a, 0xae46, 0xad4a, 0x00fe, 0x6043, 0x0000,
+	0x2c10, 0x080c, 0x1a69, 0x080c, 0x845d, 0x080c, 0x8a68, 0x009e,
+	0x0005, 0x0005, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208,
+	0x000a, 0x0005, 0xb0be, 0xb0be, 0xb0be, 0xb0be, 0xb0be, 0xb0c0,
+	0xb156, 0xb0be, 0xb0be, 0xb16d, 0xb1f9, 0xb0be, 0xb0be, 0xb0be,
+	0xb0be, 0xb20e, 0xb0be, 0xb0be, 0xb0be, 0xb0be, 0x080c, 0x0db4,
+	0x0076, 0x00a6, 0x00e6, 0x0096, 0x2071, 0x0260, 0x6114, 0x2150,
+	0x7644, 0xb676, 0x96b4, 0x0fff, 0xb77c, 0xc7e5, 0xb77e, 0x6210,
+	0x00b6, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be,
+	0x86ff, 0x0904, 0xb151, 0x9694, 0xff00, 0x9284, 0x0c00, 0x0120,
+	0x7048, 0xb092, 0x704c, 0xb08e, 0x9284, 0x0300, 0x0904, 0xb151,
+	0x080c, 0x0feb, 0x090c, 0x0db4, 0x2900, 0xb07a, 0xb77c, 0xc7cd,
+	0xb77e, 0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c, 0xa86e, 0xb070,
+	0xa872, 0xae76, 0x968c, 0x0c00, 0x0120, 0x7348, 0xab92, 0x734c,
+	0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0180, 0x9186, 0x0028,
+	0x1118, 0xa87b, 0x001c, 0x0060, 0xd6dc, 0x0118, 0xa87b, 0x0015,
+	0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000,
+	0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886, 0x901e, 0xd6c4, 0x0190,
+	0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009, 0x0210, 0x2019,
+	0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011, 0x0025, 0x080c,
+	0xb724, 0x003e, 0xd6cc, 0x01e8, 0x7154, 0xa98a, 0x81ff, 0x01c8,
+	0x9192, 0x0021, 0x1260, 0x8304, 0x9098, 0x0018, 0x2011, 0x0029,
+	0x080c, 0xb724, 0x2011, 0x0205, 0x2013, 0x0000, 0x0050, 0xb068,
+	0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c68, 0x2950, 0x080c,
+	0xb6c3, 0x009e, 0x00ee, 0x00ae, 0x007e, 0x0005, 0x00f6, 0x00a6,
+	0x6003, 0x0003, 0x2079, 0x026c, 0x7c04, 0x7b00, 0x7e0c, 0x7d08,
+	0x6014, 0x2050, 0xb436, 0xb33a, 0xb646, 0xb54a, 0x00ae, 0x00fe,
+	0x2c10, 0x080c, 0x1a69, 0x0804, 0x9394, 0x6003, 0x0002, 0x6004,
+	0x9086, 0x0040, 0x11c8, 0x0096, 0x6014, 0x2048, 0xa87c, 0xd0ac,
+	0x0160, 0x601c, 0xd084, 0x1130, 0x00f6, 0x2c00, 0x2078, 0x080c,
+	0x164a, 0x00fe, 0x6003, 0x0004, 0x0010, 0x6003, 0x0002, 0x009e,
+	0x080c, 0x887f, 0x080c, 0x898b, 0x0096, 0x2001, 0x1960, 0x2004,
+	0x6042, 0x080c, 0x893b, 0x080c, 0x8a68, 0x6114, 0x2148, 0xa97c,
+	0xd1e4, 0x0904, 0xb1f4, 0xd1cc, 0x05a8, 0xa978, 0xa868, 0xd0fc,
+	0x0538, 0x0016, 0xa87c, 0x0006, 0xa880, 0x0006, 0xa860, 0x20e8,
+	0xa85c, 0x9080, 0x0019, 0x20a0, 0x810e, 0x810e, 0x810f, 0x9184,
+	0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080, 0x0019, 0x2098, 0x0156,
+	0x20a9, 0x0020, 0x4003, 0x015e, 0x000e, 0xa882, 0x000e, 0xa87e,
+	0x001e, 0xa874, 0x0006, 0x2148, 0x080c, 0x0f9d, 0x001e, 0x0440,
+	0x0016, 0x080c, 0x0f9d, 0x009e, 0xa974, 0x0016, 0x080c, 0xb714,
+	0x001e, 0x00f0, 0xa867, 0x0103, 0xa974, 0x9184, 0x00ff, 0x90b6,
+	0x0002, 0x0180, 0x9086, 0x0028, 0x1118, 0xa87b, 0x001c, 0x0060,
+	0xd1dc, 0x0118, 0xa87b, 0x0015, 0x0038, 0xd1d4, 0x0118, 0xa87b,
+	0x0007, 0x0010, 0xa87b, 0x0000, 0x0016, 0x080c, 0x66bb, 0x001e,
+	0xd1e4, 0x1120, 0x080c, 0x9e2f, 0x009e, 0x0005, 0x080c, 0xbe39,
+	0x0cd8, 0x6004, 0x9086, 0x0040, 0x1120, 0x080c, 0x887f, 0x080c,
+	0x898b, 0x2019, 0x0001, 0x080c, 0x96e9, 0x6003, 0x0002, 0x080c,
+	0xc258, 0x080c, 0x893b, 0x080c, 0x8a68, 0x0005, 0x6004, 0x9086,
+	0x0040, 0x1120, 0x080c, 0x887f, 0x080c, 0x898b, 0x2019, 0x0001,
+	0x080c, 0x96e9, 0x080c, 0x893b, 0x080c, 0x2fe7, 0x080c, 0xc250,
+	0x0096, 0x6114, 0x2148, 0x080c, 0xbb3b, 0x0150, 0xa867, 0x0103,
+	0xa87b, 0x0029, 0xa877, 0x0000, 0x080c, 0x68a0, 0x080c, 0xbd24,
+	0x009e, 0x080c, 0x9e2f, 0x080c, 0x8a68, 0x0005, 0xa87b, 0x0015,
+	0xd1fc, 0x0180, 0xa87b, 0x0007, 0x8002, 0x8000, 0x810a, 0x9189,
+	0x0000, 0x0006, 0x0016, 0x2009, 0x1a51, 0x2104, 0x8000, 0x200a,
+	0x001e, 0x000e, 0xa992, 0xa88e, 0x0005, 0x9182, 0x0054, 0x1220,
+	0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xb269, 0xb269, 0xb269,
+	0xb269, 0xb269, 0xb26b, 0xb269, 0xb269, 0xb311, 0xb269, 0xb269,
+	0xb269, 0xb269, 0xb269, 0xb269, 0xb269, 0xb269, 0xb269, 0xb269,
+	0xb442, 0x080c, 0x0db4, 0x0076, 0x00a6, 0x00e6, 0x0096, 0x2071,
+	0x0260, 0x6114, 0x2150, 0x7644, 0xb676, 0x96b4, 0x0fff, 0xb77c,
+	0xc7e5, 0xb77e, 0x6210, 0x00b6, 0x2258, 0xba3c, 0x82ff, 0x0110,
+	0x8211, 0xba3e, 0x00be, 0x86ff, 0x0904, 0xb30a, 0x9694, 0xff00,
+	0x9284, 0x0c00, 0x0120, 0x7048, 0xb092, 0x704c, 0xb08e, 0x9284,
+	0x0300, 0x0904, 0xb30a, 0x9686, 0x0100, 0x1130, 0x7064, 0x9005,
+	0x1118, 0xc6c4, 0xb676, 0x0c38, 0x080c, 0x0feb, 0x090c, 0x0db4,
+	0x2900, 0xb07a, 0xb77c, 0x97bd, 0x0200, 0xb77e, 0xa867, 0x0103,
+	0xb068, 0xa86a, 0xb06c, 0xa86e, 0xb070, 0xa872, 0x7044, 0x9084,
+	0xf000, 0x9635, 0xae76, 0x968c, 0x0c00, 0x0120, 0x7348, 0xab92,
+	0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0180, 0x9186,
+	0x0028, 0x1118, 0xa87b, 0x001c, 0x0060, 0xd6dc, 0x0118, 0xa87b,
+	0x0015, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b,
+	0x0000, 0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886, 0x901e, 0xd6c4,
+	0x0190, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009, 0x0210,
+	0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011, 0x0025,
+	0x080c, 0xb724, 0x003e, 0xd6cc, 0x01e8, 0x7154, 0xa98a, 0x81ff,
+	0x01c8, 0x9192, 0x0021, 0x1260, 0x8304, 0x9098, 0x0018, 0x2011,
+	0x0029, 0x080c, 0xb724, 0x2011, 0x0205, 0x2013, 0x0000, 0x0050,
+	0xb068, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c68, 0x2950,
+	0x080c, 0xb6c3, 0x080c, 0x18ed, 0x009e, 0x00ee, 0x00ae, 0x007e,
+	0x0005, 0x2001, 0x1960, 0x2004, 0x6042, 0x0096, 0x6114, 0x2148,
+	0xa83c, 0xa940, 0x9105, 0x1118, 0xa87c, 0xc0dc, 0xa87e, 0x6003,
+	0x0002, 0xa97c, 0xd1e4, 0x0904, 0xb43d, 0x6043, 0x0000, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1500, 0xd1cc, 0x0904,
+	0xb40c, 0xa978, 0xa868, 0xd0fc, 0x0904, 0xb3cd, 0x0016, 0xa87c,
+	0x0006, 0xa880, 0x0006, 0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff,
+	0x90b6, 0x0002, 0x0904, 0xb39b, 0x9086, 0x0028, 0x1904, 0xb387,
+	0xa87b, 0x001c, 0xb07b, 0x001c, 0x0804, 0xb3a3, 0x6024, 0xd0f4,
+	0x11d0, 0xa838, 0xaa34, 0x9205, 0x09c8, 0xa838, 0xaa90, 0x9206,
+	0x1120, 0xa88c, 0xaa34, 0x9206, 0x0988, 0x6024, 0xd0d4, 0x1148,
+	0xa9ac, 0xa834, 0x9102, 0x603a, 0xa9b0, 0xa838, 0x9103, 0x603e,
+	0x6024, 0xc0f5, 0x6026, 0x6010, 0x00b6, 0x2058, 0xb83c, 0x8000,
+	0xb83e, 0x00be, 0x9006, 0xa876, 0xa892, 0xa88e, 0xa87c, 0xc0e4,
+	0xa87e, 0xd0cc, 0x0140, 0xc0cc, 0xa87e, 0x0096, 0xa878, 0x2048,
+	0x080c, 0x0f9d, 0x009e, 0x080c, 0xbe73, 0x0804, 0xb43d, 0xd1dc,
+	0x0158, 0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c, 0xc103, 0x0118,
+	0xb174, 0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007,
+	0xb07b, 0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938,
+	0x9115, 0x190c, 0xb236, 0xa87c, 0xb07e, 0xa890, 0xb092, 0xa88c,
+	0xb08e, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0019, 0x20a0, 0x20a9,
+	0x0020, 0x8a06, 0x8006, 0x8007, 0x9094, 0x003f, 0x22e0, 0x9084,
+	0xffc0, 0x9080, 0x0019, 0x2098, 0x4003, 0x00ae, 0x000e, 0xa882,
+	0x000e, 0xa87e, 0x080c, 0xc1e0, 0x001e, 0xa874, 0x0006, 0x2148,
+	0x080c, 0x0f9d, 0x001e, 0x0804, 0xb439, 0x0016, 0x00a6, 0x2150,
+	0xb174, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x01e0, 0x9086, 0x0028,
+	0x1128, 0xa87b, 0x001c, 0xb07b, 0x001c, 0x00e0, 0xd1dc, 0x0158,
+	0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c, 0xc103, 0x0118, 0xb174,
+	0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b,
+	0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115,
+	0x190c, 0xb236, 0xa890, 0xb092, 0xa88c, 0xb08e, 0xa87c, 0xb07e,
+	0x00ae, 0x080c, 0x0f9d, 0x009e, 0x080c, 0xc1e0, 0xa974, 0x0016,
+	0x080c, 0xb714, 0x001e, 0x0468, 0xa867, 0x0103, 0xa974, 0x9184,
+	0x00ff, 0x90b6, 0x0002, 0x01b0, 0x9086, 0x0028, 0x1118, 0xa87b,
+	0x001c, 0x00d0, 0xd1dc, 0x0148, 0xa87b, 0x0015, 0x080c, 0xc103,
+	0x0118, 0xa974, 0xc1dc, 0xa976, 0x0078, 0xd1d4, 0x0118, 0xa87b,
+	0x0007, 0x0050, 0xa87b, 0x0000, 0xa87c, 0xd0ac, 0x0128, 0xa834,
+	0xa938, 0x9115, 0x190c, 0xb236, 0xa974, 0x0016, 0x080c, 0x66bb,
+	0x001e, 0xd1e4, 0x1120, 0x080c, 0x9e2f, 0x009e, 0x0005, 0x080c,
+	0xbe39, 0x0cd8, 0x6114, 0x0096, 0x2148, 0xa97c, 0xd1e4, 0x190c,
+	0x190b, 0x009e, 0x0005, 0x080c, 0x887f, 0x0010, 0x080c, 0x893b,
+	0x080c, 0xbb3b, 0x01f0, 0x0096, 0x6114, 0x2148, 0x080c, 0xbd41,
+	0x1118, 0x080c, 0xa7cd, 0x00a0, 0xa867, 0x0103, 0x2009, 0x180c,
+	0x210c, 0xd18c, 0x11b8, 0xd184, 0x1190, 0x6108, 0xa97a, 0x918e,
+	0x0029, 0x1110, 0x080c, 0xd80d, 0xa877, 0x0000, 0x080c, 0x68a0,
+	0x009e, 0x080c, 0x9e2f, 0x080c, 0x898b, 0x0804, 0x8a68, 0xa87b,
+	0x0004, 0x0c90, 0xa87b, 0x0004, 0x0c78, 0x9182, 0x0054, 0x1220,
+	0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xb499, 0xb499, 0xb499,
+	0xb499, 0xb499, 0xb49b, 0xb499, 0xb499, 0xb499, 0xb499, 0xb499,
+	0xb499, 0xb499, 0xb499, 0xb499, 0xb499, 0xb499, 0xb499, 0xb499,
+	0xb499, 0x080c, 0x0db4, 0x080c, 0x53a2, 0x01f8, 0x6014, 0x7144,
+	0x918c, 0x0fff, 0x9016, 0xd1c4, 0x0118, 0x7264, 0x9294, 0x00ff,
+	0x0096, 0x904d, 0x0188, 0xa87b, 0x0000, 0xa864, 0x9086, 0x0139,
+	0x0128, 0xa867, 0x0103, 0xa976, 0xaa96, 0x0030, 0xa897, 0x4000,
+	0xa99a, 0xaa9e, 0x080c, 0x68a0, 0x009e, 0x0804, 0x9e2f, 0x9182,
+	0x0085, 0x0002, 0xb4d1, 0xb4cf, 0xb4cf, 0xb4dd, 0xb4cf, 0xb4cf,
+	0xb4cf, 0xb4cf, 0xb4cf, 0xb4cf, 0xb4cf, 0xb4cf, 0xb4cf, 0x080c,
+	0x0db4, 0x6003, 0x0001, 0x6106, 0x080c, 0x83f8, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x898b, 0x012e, 0x0005, 0x0026, 0x0056, 0x00d6,
+	0x00e6, 0x2071, 0x0260, 0x7224, 0x6216, 0x7220, 0x080c, 0xbb29,
+	0x01a0, 0x2268, 0x6800, 0x9086, 0x0000, 0x0178, 0x6010, 0x6d10,
+	0x952e, 0x1158, 0x00c6, 0x2d60, 0x080c, 0xb74f, 0x00ce, 0x0128,
+	0x6803, 0x0002, 0x6007, 0x0086, 0x0010, 0x6007, 0x0087, 0x6003,
+	0x0001, 0x080c, 0x83f8, 0x080c, 0x898b, 0x7220, 0x080c, 0xbb29,
+	0x0178, 0x6810, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140,
+	0x6824, 0xd0ec, 0x0128, 0x00c6, 0x2d60, 0x080c, 0xbe73, 0x00ce,
+	0x00ee, 0x00de, 0x005e, 0x002e, 0x0005, 0x9186, 0x0013, 0x1160,
+	0x6004, 0x908a, 0x0085, 0x0a0c, 0x0db4, 0x908a, 0x0092, 0x1a0c,
+	0x0db4, 0x9082, 0x0085, 0x00e2, 0x9186, 0x0027, 0x0120, 0x9186,
+	0x0014, 0x190c, 0x0db4, 0x080c, 0x887f, 0x0096, 0x6014, 0x2048,
+	0x080c, 0xbb3b, 0x0140, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b,
+	0x0029, 0x080c, 0x68a0, 0x009e, 0x080c, 0x9e5f, 0x0804, 0x898b,
+	0xb555, 0xb557, 0xb557, 0xb555, 0xb555, 0xb555, 0xb555, 0xb555,
+	0xb555, 0xb555, 0xb555, 0xb555, 0xb555, 0x080c, 0x0db4, 0x080c,
+	0x887f, 0x080c, 0x9e5f, 0x080c, 0x898b, 0x0005, 0x9186, 0x0013,
+	0x1128, 0x6004, 0x9082, 0x0085, 0x2008, 0x04b8, 0x9186, 0x0027,
+	0x11f8, 0x080c, 0x887f, 0x080c, 0x2fe7, 0x080c, 0xc250, 0x0096,
+	0x6014, 0x2048, 0x080c, 0xbb3b, 0x0150, 0xa867, 0x0103, 0xa877,
+	0x0000, 0xa87b, 0x0029, 0x080c, 0x68a0, 0x080c, 0xbd24, 0x009e,
+	0x080c, 0x9e2f, 0x080c, 0x898b, 0x0005, 0x080c, 0x9ec4, 0x0ce0,
+	0x9186, 0x0014, 0x1dd0, 0x080c, 0x887f, 0x0096, 0x6014, 0x2048,
+	0x080c, 0xbb3b, 0x0d60, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b,
+	0x0006, 0xa880, 0xc0ec, 0xa882, 0x08f0, 0x0002, 0xb5ad, 0xb5ab,
+	0xb5ab, 0xb5ab, 0xb5ab, 0xb5ab, 0xb5c5, 0xb5ab, 0xb5ab, 0xb5ab,
+	0xb5ab, 0xb5ab, 0xb5ab, 0x080c, 0x0db4, 0x080c, 0x887f, 0x6034,
+	0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035,
+	0x1118, 0x2001, 0x195e, 0x0010, 0x2001, 0x195f, 0x2004, 0x601a,
+	0x6003, 0x000c, 0x080c, 0x898b, 0x0005, 0x080c, 0x887f, 0x6034,
+	0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035,
+	0x1118, 0x2001, 0x195e, 0x0010, 0x2001, 0x195f, 0x2004, 0x601a,
+	0x6003, 0x000e, 0x080c, 0x898b, 0x0005, 0x9182, 0x0092, 0x1220,
+	0x9182, 0x0085, 0x0208, 0x0012, 0x0804, 0x9ec4, 0xb5f3, 0xb5f3,
+	0xb5f3, 0xb5f3, 0xb5f5, 0xb642, 0xb5f3, 0xb5f3, 0xb5f3, 0xb5f3,
+	0xb5f3, 0xb5f3, 0xb5f3, 0x080c, 0x0db4, 0x0096, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x0168, 0x6034, 0x908c, 0xff00,
+	0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x009e,
+	0x0804, 0xb656, 0x080c, 0xbb3b, 0x1118, 0x080c, 0xbd24, 0x0068,
+	0x6014, 0x2048, 0xa87c, 0xd0e4, 0x1110, 0x080c, 0xbd24, 0xa867,
+	0x0103, 0x080c, 0xc21b, 0x080c, 0x68a0, 0x00d6, 0x2c68, 0x080c,
+	0x9dd9, 0x01d0, 0x6003, 0x0001, 0x6007, 0x001e, 0x600b, 0xffff,
+	0x2009, 0x026e, 0x210c, 0x613a, 0x2009, 0x026f, 0x210c, 0x613e,
+	0x6910, 0x6112, 0x080c, 0xbfb5, 0x6954, 0x6156, 0x6023, 0x0001,
+	0x080c, 0x83f8, 0x080c, 0x898b, 0x2d60, 0x00de, 0x080c, 0x9e2f,
+	0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
+	0x05a0, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0035, 0x0130,
+	0x9186, 0x001e, 0x0118, 0x9186, 0x0039, 0x1538, 0x00d6, 0x2c68,
+	0x080c, 0xc1b3, 0x11f0, 0x080c, 0x9dd9, 0x01d8, 0x6106, 0x6003,
+	0x0001, 0x6023, 0x0001, 0x6910, 0x6112, 0x692c, 0x612e, 0x6930,
+	0x6132, 0x6934, 0x918c, 0x00ff, 0x6136, 0x6938, 0x613a, 0x693c,
+	0x613e, 0x6954, 0x6156, 0x080c, 0xbfb5, 0x080c, 0x83f8, 0x080c,
+	0x898b, 0x2d60, 0x00de, 0x0804, 0x9e2f, 0x0096, 0x6014, 0x2048,
+	0x080c, 0xbb3b, 0x01c8, 0xa867, 0x0103, 0xa880, 0xd0b4, 0x0128,
+	0xc0ec, 0xa882, 0xa87b, 0x0006, 0x0048, 0xd0bc, 0x0118, 0xa87b,
+	0x0002, 0x0020, 0xa87b, 0x0005, 0x080c, 0xbe35, 0xa877, 0x0000,
+	0x080c, 0x68a0, 0x080c, 0xbd24, 0x009e, 0x0804, 0x9e2f, 0x0016,
+	0x0096, 0x6014, 0x2048, 0x080c, 0xbb3b, 0x0140, 0xa867, 0x0103,
+	0xa87b, 0x0028, 0xa877, 0x0000, 0x080c, 0x68a0, 0x009e, 0x001e,
+	0x9186, 0x0013, 0x0148, 0x9186, 0x0014, 0x0130, 0x9186, 0x0027,
+	0x0118, 0x080c, 0x9ec4, 0x0030, 0x080c, 0x887f, 0x080c, 0x9e5f,
+	0x080c, 0x898b, 0x0005, 0x0056, 0x0066, 0x0096, 0x00a6, 0x2029,
+	0x0001, 0x9182, 0x0101, 0x1208, 0x0010, 0x2009, 0x0100, 0x2130,
+	0x8304, 0x9098, 0x0018, 0x2009, 0x0020, 0x2011, 0x0029, 0x080c,
+	0xb724, 0x96b2, 0x0020, 0xb004, 0x904d, 0x0110, 0x080c, 0x0f9d,
+	0x080c, 0x0feb, 0x0520, 0x8528, 0xa867, 0x0110, 0xa86b, 0x0000,
+	0x2920, 0xb406, 0x968a, 0x003d, 0x1228, 0x2608, 0x2011, 0x001b,
+	0x0499, 0x00a8, 0x96b2, 0x003c, 0x2009, 0x003c, 0x2950, 0x2011,
+	0x001b, 0x0451, 0x0c28, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae,
+	0x852f, 0x95ad, 0x0003, 0xb566, 0x95ac, 0x0000, 0x0048, 0x2001,
+	0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0003, 0xb566,
+	0x009e, 0x006e, 0x005e, 0x0005, 0x00a6, 0x89ff, 0x0158, 0xa804,
+	0x9055, 0x0130, 0xa807, 0x0000, 0x080c, 0x68a0, 0x2a48, 0x0cb8,
+	0x080c, 0x68a0, 0x00ae, 0x0005, 0x00f6, 0x2079, 0x0200, 0x7814,
+	0x9085, 0x0080, 0x7816, 0xd184, 0x0108, 0x8108, 0x810c, 0x20a9,
+	0x0001, 0xa860, 0x20e8, 0xa85c, 0x9200, 0x20a0, 0x20e1, 0x0000,
+	0x2300, 0x9e00, 0x2098, 0x4003, 0x8318, 0x9386, 0x0020, 0x1148,
+	0x2018, 0x2300, 0x9e00, 0x2098, 0x7814, 0x8000, 0x9085, 0x0080,
+	0x7816, 0x8109, 0x1d80, 0x7817, 0x0000, 0x00fe, 0x0005, 0x0066,
+	0x0126, 0x2091, 0x8000, 0x2031, 0x0001, 0x6020, 0x9084, 0x000f,
+	0x0083, 0x012e, 0x006e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0066,
+	0x2031, 0x0000, 0x6020, 0x9084, 0x000f, 0x001b, 0x006e, 0x012e,
+	0x0005, 0xb78a, 0xb78a, 0xb785, 0xb7ac, 0xb778, 0xb785, 0xb7ac,
+	0xb785, 0xb778, 0xb778, 0xb785, 0xb785, 0xb785, 0xb778, 0xb778,
+	0x080c, 0x0db4, 0x0036, 0x2019, 0x0010, 0x080c, 0xd11f, 0x6023,
+	0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x9006, 0x0005, 0x9085,
+	0x0001, 0x0005, 0x0096, 0x86ff, 0x11d8, 0x6014, 0x2048, 0x080c,
+	0xbb3b, 0x01c0, 0xa864, 0x9086, 0x0139, 0x1128, 0xa87b, 0x0005,
+	0xa883, 0x0000, 0x0028, 0x900e, 0x2001, 0x0005, 0x080c, 0x6ace,
+	0x080c, 0xbe35, 0x080c, 0x6893, 0x080c, 0x9e5f, 0x9085, 0x0001,
+	0x009e, 0x0005, 0x9006, 0x0ce0, 0x6000, 0x908a, 0x0016, 0x1a0c,
+	0x0db4, 0x0002, 0xb7c2, 0xb7f0, 0xb7c4, 0xb811, 0xb7eb, 0xb7c2,
+	0xb785, 0xb78a, 0xb78a, 0xb785, 0xb785, 0xb785, 0xb785, 0xb785,
+	0xb785, 0xb785, 0x080c, 0x0db4, 0x86ff, 0x1510, 0x6020, 0x9086,
+	0x0006, 0x01f0, 0x0096, 0x6014, 0x2048, 0x080c, 0xbb3b, 0x0158,
+	0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0f9d,
+	0x009e, 0x080c, 0xbe35, 0x009e, 0x080c, 0xc1f5, 0x6007, 0x0085,
+	0x6003, 0x000b, 0x6023, 0x0002, 0x080c, 0x83f8, 0x080c, 0x898b,
+	0x9085, 0x0001, 0x0005, 0x0066, 0x080c, 0x191f, 0x006e, 0x08a0,
+	0x00e6, 0x2071, 0x19bf, 0x7024, 0x9c06, 0x1120, 0x080c, 0x9673,
+	0x00ee, 0x0850, 0x6020, 0x9084, 0x000f, 0x9086, 0x0006, 0x1150,
+	0x0086, 0x0096, 0x2049, 0x0001, 0x2c40, 0x080c, 0x97a4, 0x009e,
+	0x008e, 0x0010, 0x080c, 0x9570, 0x00ee, 0x1904, 0xb7c4, 0x0804,
+	0xb785, 0x0036, 0x00e6, 0x2071, 0x19bf, 0x703c, 0x9c06, 0x1138,
+	0x901e, 0x080c, 0x96e9, 0x00ee, 0x003e, 0x0804, 0xb7c4, 0x080c,
+	0x98d4, 0x00ee, 0x003e, 0x1904, 0xb7c4, 0x0804, 0xb785, 0x00c6,
+	0x6020, 0x9084, 0x000f, 0x0013, 0x00ce, 0x0005, 0xb844, 0xb90f,
+	0xba79, 0xb84e, 0x9e5f, 0xb844, 0xd111, 0xc25d, 0xb90f, 0xb83d,
+	0xbb05, 0xb83d, 0xb83d, 0xb83d, 0xb83d, 0x080c, 0x0db4, 0x080c,
+	0xbd41, 0x1110, 0x080c, 0xa7cd, 0x0005, 0x080c, 0x887f, 0x080c,
+	0x898b, 0x0804, 0x9e2f, 0x601b, 0x0001, 0x0005, 0x080c, 0xbb3b,
+	0x0130, 0x6014, 0x0096, 0x2048, 0x2c00, 0xa896, 0x009e, 0x6000,
+	0x908a, 0x0016, 0x1a0c, 0x0db4, 0x0002, 0xb86d, 0xb86f, 0xb893,
+	0xb8a7, 0xb8cd, 0xb86d, 0xb844, 0xb844, 0xb844, 0xb8a7, 0xb8a7,
+	0xb86d, 0xb86d, 0xb86d, 0xb86d, 0xb8b1, 0x080c, 0x0db4, 0x00e6,
+	0x6014, 0x0096, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e, 0x2071,
+	0x19bf, 0x7024, 0x9c06, 0x01a0, 0x080c, 0x9570, 0x080c, 0xc1f5,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2001, 0x195f,
+	0x2004, 0x601a, 0x080c, 0x83f8, 0x080c, 0x898b, 0x00ee, 0x0005,
+	0x601b, 0x0001, 0x0cd8, 0x0096, 0x6014, 0x2048, 0xa880, 0xc0b5,
+	0xa882, 0x009e, 0x080c, 0xc1f5, 0x6007, 0x0085, 0x6003, 0x000b,
+	0x6023, 0x0002, 0x080c, 0x83f8, 0x080c, 0x898b, 0x0005, 0x0096,
+	0x601b, 0x0001, 0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e,
+	0x0005, 0x080c, 0x53a2, 0x01b8, 0x6014, 0x0096, 0x904d, 0x0190,
+	0xa864, 0xa867, 0x0103, 0xa87b, 0x0006, 0x9086, 0x0139, 0x1150,
+	0xa867, 0x0139, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa89b, 0x0004,
+	0x080c, 0x68a0, 0x009e, 0x0804, 0x9e2f, 0x6014, 0x0096, 0x904d,
+	0x05c8, 0xa97c, 0xd1e4, 0x05b0, 0x2001, 0x180f, 0x2004, 0xd0c4,
+	0x0110, 0x009e, 0x0005, 0xa884, 0x009e, 0x8003, 0x800b, 0x810b,
+	0x9108, 0x611a, 0x2001, 0x0030, 0x2c08, 0x080c, 0x151a, 0x2001,
+	0x030c, 0x2004, 0x9086, 0x0041, 0x11a0, 0x6014, 0x0096, 0x904d,
+	0x090c, 0x0db4, 0xa880, 0xd0f4, 0x1130, 0xc0f5, 0xa882, 0x009e,
+	0x601b, 0x0002, 0x0070, 0x009e, 0x2001, 0x0037, 0x2c08, 0x080c,
+	0x151a, 0x6000, 0x9086, 0x0004, 0x1120, 0x2009, 0x0048, 0x080c,
+	0x9ea9, 0x0005, 0x009e, 0x080c, 0x191f, 0x0804, 0xb893, 0x6000,
+	0x908a, 0x0016, 0x1a0c, 0x0db4, 0x000b, 0x0005, 0xb926, 0xb84b,
+	0xb928, 0xb926, 0xb928, 0xb928, 0xb845, 0xb926, 0xb83f, 0xb83f,
+	0xb926, 0xb926, 0xb926, 0xb926, 0xb926, 0xb926, 0x080c, 0x0db4,
+	0x6010, 0x00b6, 0x2058, 0xb804, 0x9084, 0x00ff, 0x00be, 0x908a,
+	0x000c, 0x1a0c, 0x0db4, 0x00b6, 0x0013, 0x00be, 0x0005, 0xb943,
+	0xba10, 0xb945, 0xb985, 0xb945, 0xb985, 0xb945, 0xb953, 0xb943,
+	0xb985, 0xb943, 0xb974, 0x080c, 0x0db4, 0x6004, 0x908e, 0x0016,
+	0x05c0, 0x908e, 0x0004, 0x05a8, 0x908e, 0x0002, 0x0590, 0x908e,
+	0x0052, 0x0904, 0xba0c, 0x6004, 0x080c, 0xbd41, 0x0904, 0xba29,
+	0x908e, 0x0004, 0x1110, 0x080c, 0x3010, 0x908e, 0x0021, 0x0904,
+	0xba2d, 0x908e, 0x0022, 0x0904, 0xba74, 0x908e, 0x003d, 0x0904,
+	0xba2d, 0x908e, 0x0039, 0x0904, 0xba31, 0x908e, 0x0035, 0x0904,
+	0xba31, 0x908e, 0x001e, 0x0178, 0x908e, 0x0001, 0x1140, 0x6010,
+	0x2058, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x0110, 0x080c,
+	0x2fe7, 0x080c, 0xa7cd, 0x0804, 0x9e5f, 0x00c6, 0x00d6, 0x6104,
+	0x9186, 0x0016, 0x0904, 0xb9fd, 0x9186, 0x0002, 0x1904, 0xb9d2,
+	0x2001, 0x1836, 0x2004, 0xd08c, 0x11c8, 0x080c, 0x6faa, 0x11b0,
+	0x080c, 0xc23b, 0x0138, 0x080c, 0x6fcd, 0x1120, 0x080c, 0x6eba,
+	0x0804, 0xba5d, 0x2001, 0x1955, 0x2003, 0x0001, 0x2001, 0x1800,
+	0x2003, 0x0001, 0x080c, 0x6edc, 0x0804, 0xba5d, 0x6010, 0x2058,
+	0x2001, 0x1836, 0x2004, 0xd0ac, 0x1904, 0xba5d, 0xb8a0, 0x9084,
+	0xff80, 0x1904, 0xba5d, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0190,
+	0x8001, 0xb842, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398,
+	0x6043, 0x0000, 0x080c, 0x9dd9, 0x0128, 0x2b00, 0x6012, 0x6023,
+	0x0001, 0x0458, 0x00de, 0x00ce, 0x6004, 0x908e, 0x0002, 0x11a0,
+	0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e, 0x1170, 0x2009, 0x1836,
+	0x2104, 0xc085, 0x200a, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5c78,
+	0x00ee, 0x080c, 0xa7cd, 0x0030, 0x080c, 0xa7cd, 0x080c, 0x2fe7,
+	0x080c, 0xc250, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x3010,
+	0x012e, 0x00ee, 0x080c, 0x9e5f, 0x0005, 0x2001, 0x0002, 0x080c,
+	0x61a7, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8440, 0x080c,
+	0x898b, 0x00de, 0x00ce, 0x0c80, 0x080c, 0x3010, 0x0804, 0xb981,
+	0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016, 0x0d38, 0x6010, 0x2058,
+	0xb840, 0x9084, 0x00ff, 0x9005, 0x0904, 0xb9d2, 0x8001, 0xb842,
+	0x6003, 0x0001, 0x080c, 0x8440, 0x080c, 0x898b, 0x00de, 0x00ce,
+	0x0898, 0x080c, 0xa7cd, 0x0804, 0xb983, 0x080c, 0xa809, 0x0804,
+	0xb983, 0x00d6, 0x2c68, 0x6104, 0x080c, 0xc1b3, 0x00de, 0x0118,
+	0x080c, 0x9e2f, 0x0408, 0x6004, 0x8007, 0x6134, 0x918c, 0x00ff,
+	0x9105, 0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002,
+	0x603c, 0x600a, 0x2001, 0x195f, 0x2004, 0x601a, 0x602c, 0x2c08,
+	0x2060, 0x6024, 0xd0b4, 0x0108, 0xc085, 0xc0b5, 0x6026, 0x2160,
+	0x080c, 0x83f8, 0x080c, 0x898b, 0x0005, 0x00de, 0x00ce, 0x080c,
+	0xa7cd, 0x080c, 0x2fe7, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x3010, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398, 0x6043,
+	0x0000, 0x012e, 0x00ee, 0x0005, 0x080c, 0xa25f, 0x1904, 0xba29,
+	0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0db4, 0x0096, 0x00d6,
+	0x001b, 0x00de, 0x009e, 0x0005, 0xba94, 0xba94, 0xba94, 0xba94,
+	0xba94, 0xba94, 0xba94, 0xba94, 0xba94, 0xb844, 0xba94, 0xb84b,
+	0xba96, 0xb84b, 0xbab0, 0xba94, 0x080c, 0x0db4, 0x6004, 0x9086,
+	0x008b, 0x01b0, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0035,
+	0x1130, 0x602c, 0x9080, 0x0009, 0x200c, 0xc185, 0x2102, 0x6007,
+	0x008b, 0x6003, 0x000d, 0x080c, 0x83f8, 0x080c, 0x898b, 0x0005,
+	0x080c, 0xc22f, 0x0118, 0x080c, 0xc242, 0x0010, 0x080c, 0xc250,
+	0x080c, 0xbd24, 0x080c, 0xbb3b, 0x0570, 0x080c, 0x2fe7, 0x080c,
+	0xbb3b, 0x0168, 0x6014, 0x2048, 0xa867, 0x0103, 0xa87b, 0x0006,
+	0xa877, 0x0000, 0xa880, 0xc0ed, 0xa882, 0x080c, 0x68a0, 0x2c68,
+	0x080c, 0x9dd9, 0x0150, 0x6810, 0x6012, 0x080c, 0xbfb5, 0x00c6,
+	0x2d60, 0x080c, 0x9e5f, 0x00ce, 0x0008, 0x2d60, 0x6017, 0x0000,
+	0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x8440,
+	0x080c, 0x898b, 0x00c8, 0x080c, 0xc22f, 0x0138, 0x6034, 0x9086,
+	0x4000, 0x1118, 0x080c, 0x2fe7, 0x08d0, 0x6034, 0x908c, 0xff00,
+	0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x080c,
+	0x2fe7, 0x0868, 0x080c, 0x9e5f, 0x0005, 0x6000, 0x908a, 0x0016,
+	0x1a0c, 0x0db4, 0x0002, 0xbb1b, 0xbb1b, 0xbb1d, 0xbb1d, 0xbb1d,
+	0xbb1b, 0xbb1b, 0x9e5f, 0xbb1b, 0xbb1b, 0xbb1b, 0xbb1b, 0xbb1b,
+	0xbb1b, 0xbb1b, 0xbb1b, 0x080c, 0x0db4, 0x080c, 0x98d4, 0x6114,
+	0x0096, 0x2148, 0xa87b, 0x0006, 0x080c, 0x68a0, 0x009e, 0x0804,
+	0x9e2f, 0x9284, 0x0007, 0x1158, 0x9282, 0x1cd0, 0x0240, 0x2001,
+	0x1819, 0x2004, 0x9202, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006,
+	0x0ce8, 0x0096, 0x0028, 0x0096, 0x0006, 0x6014, 0x2048, 0x000e,
+	0x0006, 0x9984, 0xf000, 0x9086, 0xf000, 0x0110, 0x080c, 0x1096,
+	0x000e, 0x009e, 0x0005, 0x00e6, 0x00c6, 0x0036, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2061, 0x1cd0, 0x2071, 0x1800, 0x7350, 0x7070,
+	0x9302, 0x1640, 0x6020, 0x9206, 0x11f8, 0x080c, 0xc23b, 0x0180,
+	0x9286, 0x0001, 0x1168, 0x6004, 0x9086, 0x0004, 0x1148, 0x080c,
+	0x2fe7, 0x080c, 0xc250, 0x00c6, 0x080c, 0x9e5f, 0x00ce, 0x0060,
+	0x080c, 0xbf2f, 0x0148, 0x080c, 0xbd41, 0x1110, 0x080c, 0xa7cd,
+	0x00c6, 0x080c, 0x9e2f, 0x00ce, 0x9ce0, 0x0018, 0x7064, 0x9c02,
+	0x1208, 0x08a0, 0x012e, 0x000e, 0x003e, 0x00ce, 0x00ee, 0x0005,
+	0x00e6, 0x00c6, 0x0016, 0x9188, 0x1000, 0x210c, 0x81ff, 0x0128,
+	0x2061, 0x1a87, 0x6112, 0x080c, 0x2fe7, 0x9006, 0x0010, 0x9085,
+	0x0001, 0x001e, 0x00ce, 0x00ee, 0x0005, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x9dd9, 0x01b0, 0x6656, 0x2b00, 0x6012, 0x080c,
+	0x53a2, 0x0118, 0x080c, 0xbc68, 0x0168, 0x080c, 0xbfb5, 0x6023,
+	0x0003, 0x2009, 0x004b, 0x080c, 0x9ea9, 0x9085, 0x0001, 0x012e,
+	0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000,
+	0xbaa0, 0x080c, 0x9e7c, 0x0560, 0x6057, 0x0000, 0x2b00, 0x6012,
+	0x080c, 0xbfb5, 0x6023, 0x0003, 0x0016, 0x080c, 0x8582, 0x0076,
+	0x903e, 0x080c, 0x8470, 0x2c08, 0x080c, 0xd2d5, 0x007e, 0x001e,
+	0xd184, 0x0128, 0x080c, 0x9e2f, 0x9085, 0x0001, 0x0070, 0x080c,
+	0x53a2, 0x0128, 0xd18c, 0x1170, 0x080c, 0xbc68, 0x0148, 0x2009,
+	0x004c, 0x080c, 0x9ea9, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005,
+	0x9006, 0x0cd8, 0x2900, 0x6016, 0x0c90, 0x2009, 0x004d, 0x0010,
+	0x2009, 0x004e, 0x00f6, 0x00c6, 0x0046, 0x0016, 0x080c, 0x9dd9,
+	0x2c78, 0x0590, 0x7e56, 0x2b00, 0x7812, 0x7823, 0x0003, 0x2021,
+	0x0005, 0x080c, 0xbc7a, 0x9186, 0x004d, 0x0118, 0x9186, 0x004e,
+	0x0148, 0x2001, 0x1958, 0x200c, 0xd1fc, 0x0168, 0x2f60, 0x080c,
+	0x9e2f, 0x00d0, 0x2001, 0x1957, 0x200c, 0xd1fc, 0x0120, 0x2f60,
+	0x080c, 0x9e2f, 0x0088, 0x2f60, 0x080c, 0x53a2, 0x0138, 0xd18c,
+	0x1118, 0x04f1, 0x0148, 0x0010, 0x2900, 0x7816, 0x001e, 0x0016,
+	0x080c, 0x9ea9, 0x9085, 0x0001, 0x001e, 0x004e, 0x00ce, 0x00fe,
+	0x0005, 0x00f6, 0x00c6, 0x0046, 0x080c, 0x9dd9, 0x2c78, 0x0508,
+	0x7e56, 0x2b00, 0x7812, 0x7823, 0x0003, 0x0096, 0x2021, 0x0004,
+	0x0489, 0x009e, 0x2001, 0x1956, 0x200c, 0xd1fc, 0x0120, 0x2f60,
+	0x080c, 0x9e2f, 0x0060, 0x2f60, 0x080c, 0x53a2, 0x0120, 0xd18c,
+	0x1160, 0x0071, 0x0130, 0x2009, 0x0052, 0x080c, 0x9ea9, 0x9085,
+	0x0001, 0x004e, 0x00ce, 0x00fe, 0x0005, 0x2900, 0x7816, 0x0c98,
+	0x00c6, 0x080c, 0x4894, 0x00ce, 0x1120, 0x080c, 0x9e2f, 0x9006,
+	0x0005, 0xa867, 0x0000, 0xa86b, 0x8000, 0x2900, 0x6016, 0x9085,
+	0x0001, 0x0005, 0x0096, 0x0076, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x638a, 0x0158, 0x2001, 0xbc7f, 0x0006, 0x900e, 0x2400, 0x080c,
+	0x6ace, 0x080c, 0x68a0, 0x000e, 0x0807, 0x2418, 0x080c, 0x8819,
+	0xbaa0, 0x0086, 0x2041, 0x0001, 0x2039, 0x0001, 0x2608, 0x080c,
+	0x859a, 0x008e, 0x080c, 0x8470, 0x2f08, 0x2648, 0x080c, 0xd2d5,
+	0xb93c, 0x81ff, 0x090c, 0x866b, 0x080c, 0x898b, 0x012e, 0x007e,
+	0x009e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9dd9,
+	0x0190, 0x660a, 0x2b08, 0x6112, 0x080c, 0xbfb5, 0x6023, 0x0001,
+	0x2900, 0x6016, 0x2009, 0x001f, 0x080c, 0x9ea9, 0x9085, 0x0001,
 	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091,
-	0x8000, 0xbaa0, 0x080c, 0x9e8f, 0x0560, 0x6057, 0x0000, 0x2b00,
-	0x6012, 0x080c, 0xbfa6, 0x6023, 0x0003, 0x0016, 0x080c, 0x8564,
-	0x0076, 0x903e, 0x080c, 0x8452, 0x2c08, 0x080c, 0xd2bc, 0x007e,
-	0x001e, 0xd184, 0x0128, 0x080c, 0x9e42, 0x9085, 0x0001, 0x0070,
-	0x080c, 0x5397, 0x0128, 0xd18c, 0x1170, 0x080c, 0xbc59, 0x0148,
-	0x2009, 0x004c, 0x080c, 0x9ebc, 0x9085, 0x0001, 0x012e, 0x00ce,
-	0x0005, 0x9006, 0x0cd8, 0x2900, 0x6016, 0x0c90, 0x2009, 0x004d,
-	0x0010, 0x2009, 0x004e, 0x00f6, 0x00c6, 0x0046, 0x0016, 0x080c,
-	0x9dec, 0x2c78, 0x0590, 0x7e56, 0x2b00, 0x7812, 0x7823, 0x0003,
-	0x2021, 0x0005, 0x080c, 0xbc6b, 0x9186, 0x004d, 0x0118, 0x9186,
-	0x004e, 0x0148, 0x2001, 0x1950, 0x200c, 0xd1fc, 0x0168, 0x2f60,
-	0x080c, 0x9e42, 0x00d0, 0x2001, 0x194f, 0x200c, 0xd1fc, 0x0120,
-	0x2f60, 0x080c, 0x9e42, 0x0088, 0x2f60, 0x080c, 0x5397, 0x0138,
-	0xd18c, 0x1118, 0x04f1, 0x0148, 0x0010, 0x2900, 0x7816, 0x001e,
-	0x0016, 0x080c, 0x9ebc, 0x9085, 0x0001, 0x001e, 0x004e, 0x00ce,
-	0x00fe, 0x0005, 0x00f6, 0x00c6, 0x0046, 0x080c, 0x9dec, 0x2c78,
-	0x0508, 0x7e56, 0x2b00, 0x7812, 0x7823, 0x0003, 0x0096, 0x2021,
-	0x0004, 0x0489, 0x009e, 0x2001, 0x194e, 0x200c, 0xd1fc, 0x0120,
-	0x2f60, 0x080c, 0x9e42, 0x0060, 0x2f60, 0x080c, 0x5397, 0x0120,
-	0xd18c, 0x1160, 0x0071, 0x0130, 0x2009, 0x0052, 0x080c, 0x9ebc,
-	0x9085, 0x0001, 0x004e, 0x00ce, 0x00fe, 0x0005, 0x2900, 0x7816,
-	0x0c98, 0x00c6, 0x080c, 0x4889, 0x00ce, 0x1120, 0x080c, 0x9e42,
-	0x9006, 0x0005, 0xa867, 0x0000, 0xa86b, 0x8000, 0x2900, 0x6016,
-	0x9085, 0x0001, 0x0005, 0x0096, 0x0076, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x637b, 0x0158, 0x2001, 0xbc70, 0x0006, 0x900e, 0x2400,
-	0x080c, 0x6abf, 0x080c, 0x6891, 0x000e, 0x0807, 0x2418, 0x080c,
-	0x87fb, 0xbaa0, 0x0086, 0x2041, 0x0001, 0x2039, 0x0001, 0x2608,
-	0x080c, 0x857c, 0x008e, 0x080c, 0x8452, 0x2f08, 0x2648, 0x080c,
-	0xd2bc, 0xb93c, 0x81ff, 0x090c, 0x864d, 0x080c, 0x896d, 0x012e,
-	0x007e, 0x009e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x9dec, 0x0190, 0x660a, 0x2b08, 0x6112, 0x080c, 0xbfa6, 0x6023,
-	0x0001, 0x2900, 0x6016, 0x2009, 0x001f, 0x080c, 0x9ebc, 0x9085,
+	0x8000, 0x080c, 0x9e7c, 0x01b8, 0x660a, 0x2b08, 0x6112, 0x080c,
+	0xbfb5, 0x6023, 0x0008, 0x2900, 0x6016, 0x00f6, 0x2c78, 0x080c,
+	0x164a, 0x00fe, 0x2009, 0x0021, 0x080c, 0x9ea9, 0x9085, 0x0001,
+	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009, 0x003d, 0x00c6,
+	0x0126, 0x0016, 0x2091, 0x8000, 0x080c, 0x9dd9, 0x0198, 0x660a,
+	0x2b08, 0x6112, 0x080c, 0xbfb5, 0x6023, 0x0001, 0x2900, 0x6016,
+	0x001e, 0x0016, 0x080c, 0x9ea9, 0x9085, 0x0001, 0x001e, 0x012e,
+	0x00ce, 0x0005, 0x9006, 0x0cd0, 0x00c6, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x9e7c, 0x0188, 0x2b08, 0x6112, 0x080c, 0xbfb5, 0x6023,
+	0x0001, 0x2900, 0x6016, 0x2009, 0x0000, 0x080c, 0x9ea9, 0x9085,
+	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009, 0x0044,
+	0x0830, 0x2009, 0x0049, 0x0818, 0x0026, 0x00b6, 0x6210, 0x2258,
+	0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x002e, 0x0005,
+	0x0006, 0x0016, 0x6004, 0x908e, 0x0002, 0x0140, 0x908e, 0x0003,
+	0x0128, 0x908e, 0x0004, 0x0110, 0x9085, 0x0001, 0x001e, 0x000e,
+	0x0005, 0x0006, 0x0086, 0x0096, 0x6020, 0x9086, 0x0004, 0x01a8,
+	0x6014, 0x904d, 0x080c, 0xbb3b, 0x0180, 0xa864, 0x9086, 0x0139,
+	0x0170, 0x6020, 0x90c6, 0x0003, 0x0140, 0x90c6, 0x0002, 0x0128,
+	0xa868, 0xd0fc, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001, 0x009e,
+	0x008e, 0x000e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x9e7c, 0x0198, 0x2b08, 0x6112, 0x080c, 0xbfb5, 0x6023, 0x0001,
+	0x2900, 0x6016, 0x080c, 0x2fe7, 0x2009, 0x0028, 0x080c, 0x9ea9,
+	0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x9186,
+	0x0015, 0x11a8, 0x2011, 0x1823, 0x2204, 0x9086, 0x0074, 0x1178,
+	0x00b6, 0x080c, 0xaa58, 0x00be, 0x080c, 0xac97, 0x6003, 0x0001,
+	0x6007, 0x0029, 0x080c, 0x8440, 0x080c, 0x898b, 0x0078, 0x6014,
+	0x0096, 0x2048, 0xa868, 0x009e, 0xd0fc, 0x0148, 0x2001, 0x0001,
+	0x080c, 0xc174, 0x080c, 0xa7cd, 0x080c, 0x9e2f, 0x0005, 0x0096,
+	0x6014, 0x904d, 0x090c, 0x0db4, 0xa87b, 0x0030, 0xa883, 0x0000,
+	0xa897, 0x4005, 0xa89b, 0x0004, 0xa867, 0x0139, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x68a0, 0x012e, 0x009e, 0x080c, 0x9e2f, 0x0c30,
+	0x0096, 0x9186, 0x0016, 0x1128, 0x2001, 0x0004, 0x080c, 0x61a7,
+	0x00e8, 0x9186, 0x0015, 0x1510, 0x2011, 0x1823, 0x2204, 0x9086,
+	0x0014, 0x11e0, 0x6010, 0x00b6, 0x2058, 0x080c, 0x62f1, 0x00be,
+	0x080c, 0xad68, 0x1198, 0x6010, 0x00b6, 0x2058, 0xb890, 0x00be,
+	0x9005, 0x0160, 0x2001, 0x0006, 0x080c, 0x61a7, 0x6014, 0x2048,
+	0xa868, 0xd0fc, 0x0170, 0x080c, 0xa233, 0x0048, 0x6014, 0x2048,
+	0xa868, 0xd0fc, 0x0528, 0x080c, 0xa7cd, 0x080c, 0x9e2f, 0x009e,
+	0x0005, 0x6014, 0x6310, 0x2358, 0x904d, 0x090c, 0x0db4, 0xa87b,
+	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x900e, 0x080c, 0x6476,
+	0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0xa99a, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x68a0, 0x012e, 0x080c, 0x9e2f, 0x08f8,
+	0x6014, 0x904d, 0x090c, 0x0db4, 0xa87b, 0x0030, 0xa883, 0x0000,
+	0xa897, 0x4005, 0xa89b, 0x0004, 0xa867, 0x0139, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x68a0, 0x012e, 0x080c, 0x9e2f, 0x0840, 0xa878,
+	0x9086, 0x0005, 0x1108, 0x0009, 0x0005, 0xa880, 0xc0ad, 0xa882,
+	0x0005, 0x6043, 0x0000, 0x6017, 0x0000, 0x6003, 0x0001, 0x6007,
+	0x0050, 0x080c, 0x83f8, 0x080c, 0x898b, 0x0005, 0x00c6, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0120, 0x6020, 0x9084,
+	0x000f, 0x0013, 0x00ce, 0x0005, 0xb844, 0xbe65, 0xbe65, 0xbe68,
+	0xd5b3, 0xd5ce, 0xd5d1, 0xb844, 0xb844, 0xb844, 0xb844, 0xb844,
+	0xb844, 0xb844, 0xb844, 0x080c, 0x0db4, 0xa001, 0xa001, 0x0005,
+	0x0096, 0x6014, 0x904d, 0x0118, 0xa87c, 0xd0e4, 0x1110, 0x009e,
+	0x0010, 0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x0550, 0x2001, 0x1833, 0x2004, 0x9005, 0x1540, 0x00f6,
+	0x2c78, 0x080c, 0x9dd9, 0x0508, 0x7810, 0x6012, 0x080c, 0xbfb5,
+	0x7820, 0x9086, 0x0003, 0x0128, 0x7808, 0x603a, 0x2f00, 0x603e,
+	0x0020, 0x7808, 0x603e, 0x2f00, 0x603a, 0x602e, 0x6023, 0x0001,
+	0x6007, 0x0035, 0x6003, 0x0001, 0x7954, 0x6156, 0x080c, 0x83f8,
+	0x080c, 0x898b, 0x2f60, 0x00fe, 0x0005, 0x2f60, 0x00fe, 0x2001,
+	0x1960, 0x2004, 0x6042, 0x0005, 0x0016, 0x0096, 0x6814, 0x2048,
+	0xa87c, 0xd0e4, 0x0180, 0xc0e4, 0xa87e, 0xa877, 0x0000, 0xa893,
+	0x0000, 0xa88f, 0x0000, 0xd0cc, 0x0130, 0xc0cc, 0xa87e, 0xa878,
+	0x2048, 0x080c, 0x0f9d, 0x6830, 0x6036, 0x908e, 0x0001, 0x0148,
+	0x6803, 0x0002, 0x9086, 0x0005, 0x0170, 0x9006, 0x602e, 0x6032,
+	0x00d0, 0x681c, 0xc085, 0x681e, 0x6803, 0x0004, 0x6824, 0xc0f4,
+	0x9085, 0x0c00, 0x6826, 0x6814, 0x2048, 0xa8ac, 0x6938, 0x9102,
+	0xa8b0, 0x693c, 0x9103, 0x1e48, 0x683c, 0x602e, 0x6838, 0x9084,
+	0xfffc, 0x683a, 0x6032, 0x2d00, 0x603a, 0x6808, 0x603e, 0x6910,
+	0x6112, 0x6954, 0x6156, 0x6023, 0x0001, 0x6007, 0x0039, 0x6003,
+	0x0001, 0x080c, 0x83f8, 0x080c, 0x898b, 0x009e, 0x001e, 0x0005,
+	0x6024, 0xd0d4, 0x0510, 0xd0f4, 0x11f8, 0x6038, 0x940a, 0x603c,
+	0x9303, 0x0230, 0x9105, 0x0120, 0x6024, 0xc0d4, 0xc0f5, 0x0098,
+	0x643a, 0x633e, 0xac3e, 0xab42, 0x0046, 0x0036, 0x2400, 0xacac,
+	0x9402, 0xa836, 0x2300, 0xabb0, 0x9303, 0xa83a, 0x003e, 0x004e,
+	0x6024, 0xc0d4, 0x0000, 0x6026, 0x0005, 0xd0f4, 0x1138, 0xa83c,
+	0x603a, 0xa840, 0x603e, 0x6024, 0xc0f5, 0x6026, 0x0005, 0x0006,
+	0x0016, 0x6004, 0x908e, 0x0034, 0x01b8, 0x908e, 0x0035, 0x01a0,
+	0x908e, 0x0036, 0x0188, 0x908e, 0x0037, 0x0170, 0x908e, 0x0038,
+	0x0158, 0x908e, 0x0039, 0x0140, 0x908e, 0x003a, 0x0128, 0x908e,
+	0x003b, 0x0110, 0x9085, 0x0001, 0x001e, 0x000e, 0x0005, 0x0006,
+	0x0016, 0x0026, 0x0036, 0x00e6, 0x2001, 0x195a, 0x200c, 0x8000,
+	0x2014, 0x2001, 0x0032, 0x080c, 0x8277, 0x2001, 0x195e, 0x82ff,
+	0x1110, 0x2011, 0x0014, 0x2202, 0x2001, 0x195c, 0x200c, 0x8000,
+	0x2014, 0x2071, 0x1944, 0x711a, 0x721e, 0x2001, 0x0064, 0x080c,
+	0x8277, 0x2001, 0x195f, 0x82ff, 0x1110, 0x2011, 0x0014, 0x2202,
+	0x2001, 0x1960, 0x9288, 0x000a, 0x2102, 0x2001, 0x1a68, 0x2102,
+	0x2001, 0x0032, 0x080c, 0x151a, 0x080c, 0x655b, 0x00ee, 0x003e,
+	0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x00e6, 0x2001,
+	0x195e, 0x2003, 0x0028, 0x2001, 0x195f, 0x2003, 0x0014, 0x2071,
+	0x1944, 0x701b, 0x0000, 0x701f, 0x07d0, 0x2001, 0x1960, 0x2009,
+	0x001e, 0x2102, 0x2001, 0x1a68, 0x2102, 0x2001, 0x0032, 0x080c,
+	0x151a, 0x00ee, 0x001e, 0x000e, 0x0005, 0x0096, 0x6058, 0x904d,
+	0x0110, 0x080c, 0x101d, 0x009e, 0x0005, 0x0005, 0x00c6, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x9dd9, 0x0180, 0x2b08, 0x6112, 0x0ca9,
+	0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x0033, 0x080c, 0x9ea9,
+	0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x0096,
+	0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1500, 0x708c,
+	0x9086, 0x0018, 0x11e0, 0x6014, 0x2048, 0xaa3c, 0xd2e4, 0x1160,
+	0x2c78, 0x080c, 0x8b7e, 0x01d8, 0x7078, 0xaa50, 0x9206, 0x1160,
+	0x707c, 0xaa54, 0x9206, 0x1140, 0x6210, 0x00b6, 0x2258, 0xbaa0,
+	0x00be, 0x900e, 0x080c, 0x3030, 0x080c, 0xa233, 0x0020, 0x080c,
+	0xa7cd, 0x080c, 0x9e2f, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x705c,
+	0xaa54, 0x9206, 0x0d48, 0x0c80, 0x00c6, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x9dd9, 0x0188, 0x2b08, 0x6112, 0x080c, 0xbfb5, 0x6023,
+	0x0001, 0x2900, 0x6016, 0x2009, 0x004d, 0x080c, 0x9ea9, 0x9085,
 	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x9e8f, 0x01b8, 0x660a, 0x2b08, 0x6112,
-	0x080c, 0xbfa6, 0x6023, 0x0008, 0x2900, 0x6016, 0x00f6, 0x2c78,
-	0x080c, 0x164a, 0x00fe, 0x2009, 0x0021, 0x080c, 0x9ebc, 0x9085,
-	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009, 0x003d,
-	0x00c6, 0x0126, 0x0016, 0x2091, 0x8000, 0x080c, 0x9dec, 0x0198,
-	0x660a, 0x2b08, 0x6112, 0x080c, 0xbfa6, 0x6023, 0x0001, 0x2900,
-	0x6016, 0x001e, 0x0016, 0x080c, 0x9ebc, 0x9085, 0x0001, 0x001e,
-	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd0, 0x00c6, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x9e8f, 0x0188, 0x2b08, 0x6112, 0x080c, 0xbfa6,
-	0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x0000, 0x080c, 0x9ebc,
-	0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009,
-	0x0044, 0x0830, 0x2009, 0x0049, 0x0818, 0x0026, 0x00b6, 0x6210,
-	0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x002e,
-	0x0005, 0x0006, 0x0016, 0x6004, 0x908e, 0x0002, 0x0140, 0x908e,
-	0x0003, 0x0128, 0x908e, 0x0004, 0x0110, 0x9085, 0x0001, 0x001e,
-	0x000e, 0x0005, 0x0006, 0x0086, 0x0096, 0x6020, 0x9086, 0x0004,
-	0x01a8, 0x6014, 0x904d, 0x080c, 0xbb2c, 0x0180, 0xa864, 0x9086,
-	0x0139, 0x0170, 0x6020, 0x90c6, 0x0003, 0x0140, 0x90c6, 0x0002,
-	0x0128, 0xa868, 0xd0fc, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x009e, 0x008e, 0x000e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x9e8f, 0x0198, 0x2b08, 0x6112, 0x080c, 0xbfa6, 0x6023,
-	0x0001, 0x2900, 0x6016, 0x080c, 0x2fdc, 0x2009, 0x0028, 0x080c,
-	0x9ebc, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8,
-	0x9186, 0x0015, 0x11a8, 0x2011, 0x1823, 0x2204, 0x9086, 0x0074,
-	0x1178, 0x00b6, 0x080c, 0xaa5c, 0x00be, 0x080c, 0xac9b, 0x6003,
-	0x0001, 0x6007, 0x0029, 0x080c, 0x8422, 0x080c, 0x896d, 0x0078,
-	0x6014, 0x0096, 0x2048, 0xa868, 0x009e, 0xd0fc, 0x0148, 0x2001,
-	0x0001, 0x080c, 0xc165, 0x080c, 0xa7d1, 0x080c, 0x9e42, 0x0005,
-	0x0096, 0x6014, 0x904d, 0x090c, 0x0db4, 0xa87b, 0x0030, 0xa883,
-	0x0000, 0xa897, 0x4005, 0xa89b, 0x0004, 0xa867, 0x0139, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x6891, 0x012e, 0x009e, 0x080c, 0x9e42,
-	0x0c30, 0x0096, 0x9186, 0x0016, 0x1128, 0x2001, 0x0004, 0x080c,
-	0x6198, 0x00e8, 0x9186, 0x0015, 0x1510, 0x2011, 0x1823, 0x2204,
-	0x9086, 0x0014, 0x11e0, 0x6010, 0x00b6, 0x2058, 0x080c, 0x62e2,
-	0x00be, 0x080c, 0xad6c, 0x1198, 0x6010, 0x00b6, 0x2058, 0xb890,
-	0x00be, 0x9005, 0x0160, 0x2001, 0x0006, 0x080c, 0x6198, 0x6014,
-	0x2048, 0xa868, 0xd0fc, 0x0170, 0x080c, 0xa246, 0x0048, 0x6014,
-	0x2048, 0xa868, 0xd0fc, 0x0528, 0x080c, 0xa7d1, 0x080c, 0x9e42,
-	0x009e, 0x0005, 0x6014, 0x6310, 0x2358, 0x904d, 0x090c, 0x0db4,
-	0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x900e, 0x080c,
-	0x6467, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0xa99a,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x6891, 0x012e, 0x080c, 0x9e42,
-	0x08f8, 0x6014, 0x904d, 0x090c, 0x0db4, 0xa87b, 0x0030, 0xa883,
-	0x0000, 0xa897, 0x4005, 0xa89b, 0x0004, 0xa867, 0x0139, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x6891, 0x012e, 0x080c, 0x9e42, 0x0840,
-	0xa878, 0x9086, 0x0005, 0x1108, 0x0009, 0x0005, 0xa880, 0xc0ad,
-	0xa882, 0x0005, 0x6043, 0x0000, 0x6017, 0x0000, 0x6003, 0x0001,
-	0x6007, 0x0050, 0x080c, 0x83da, 0x080c, 0x896d, 0x0005, 0x00c6,
-	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0120, 0x6020,
-	0x9084, 0x000f, 0x0013, 0x00ce, 0x0005, 0xb845, 0xbe56, 0xbe56,
-	0xbe59, 0xd59a, 0xd5b5, 0xd5b8, 0xb845, 0xb845, 0xb845, 0xb845,
-	0xb845, 0xb845, 0xb845, 0xb845, 0x080c, 0x0db4, 0xa001, 0xa001,
-	0x0005, 0x0096, 0x6014, 0x904d, 0x0118, 0xa87c, 0xd0e4, 0x1110,
-	0x009e, 0x0010, 0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x0550, 0x2001, 0x1833, 0x2004, 0x9005, 0x1540,
-	0x00f6, 0x2c78, 0x080c, 0x9dec, 0x0508, 0x7810, 0x6012, 0x080c,
-	0xbfa6, 0x7820, 0x9086, 0x0003, 0x0128, 0x7808, 0x603a, 0x2f00,
-	0x603e, 0x0020, 0x7808, 0x603e, 0x2f00, 0x603a, 0x602e, 0x6023,
-	0x0001, 0x6007, 0x0035, 0x6003, 0x0001, 0x7954, 0x6156, 0x080c,
-	0x83da, 0x080c, 0x896d, 0x2f60, 0x00fe, 0x0005, 0x2f60, 0x00fe,
-	0x2001, 0x1958, 0x2004, 0x6042, 0x0005, 0x0016, 0x0096, 0x6814,
-	0x2048, 0xa87c, 0xd0e4, 0x0180, 0xc0e4, 0xa87e, 0xa877, 0x0000,
-	0xa893, 0x0000, 0xa88f, 0x0000, 0xd0cc, 0x0130, 0xc0cc, 0xa87e,
-	0xa878, 0x2048, 0x080c, 0x0f9d, 0x6830, 0x6036, 0x908e, 0x0001,
-	0x0148, 0x6803, 0x0002, 0x9086, 0x0005, 0x0170, 0x9006, 0x602e,
-	0x6032, 0x00d0, 0x681c, 0xc085, 0x681e, 0x6803, 0x0004, 0x6824,
-	0xc0f4, 0x9085, 0x0c00, 0x6826, 0x6814, 0x2048, 0xa8ac, 0x6938,
-	0x9102, 0xa8b0, 0x693c, 0x9103, 0x1e48, 0x683c, 0x602e, 0x6838,
-	0x9084, 0xfffc, 0x683a, 0x6032, 0x2d00, 0x603a, 0x6808, 0x603e,
-	0x6910, 0x6112, 0x6954, 0x6156, 0x6023, 0x0001, 0x6007, 0x0039,
-	0x6003, 0x0001, 0x080c, 0x83da, 0x080c, 0x896d, 0x009e, 0x001e,
-	0x0005, 0x6024, 0xd0d4, 0x0510, 0xd0f4, 0x11f8, 0x6038, 0x940a,
-	0x603c, 0x9303, 0x0230, 0x9105, 0x0120, 0x6024, 0xc0d4, 0xc0f5,
-	0x0098, 0x643a, 0x633e, 0xac3e, 0xab42, 0x0046, 0x0036, 0x2400,
-	0xacac, 0x9402, 0xa836, 0x2300, 0xabb0, 0x9303, 0xa83a, 0x003e,
-	0x004e, 0x6024, 0xc0d4, 0x0000, 0x6026, 0x0005, 0xd0f4, 0x1138,
-	0xa83c, 0x603a, 0xa840, 0x603e, 0x6024, 0xc0f5, 0x6026, 0x0005,
-	0x0006, 0x0016, 0x6004, 0x908e, 0x0034, 0x01b8, 0x908e, 0x0035,
-	0x01a0, 0x908e, 0x0036, 0x0188, 0x908e, 0x0037, 0x0170, 0x908e,
-	0x0038, 0x0158, 0x908e, 0x0039, 0x0140, 0x908e, 0x003a, 0x0128,
-	0x908e, 0x003b, 0x0110, 0x9085, 0x0001, 0x001e, 0x000e, 0x0005,
-	0x0006, 0x0016, 0x0026, 0x0036, 0x00e6, 0x2001, 0x1952, 0x200c,
-	0x8000, 0x2014, 0x2001, 0x0032, 0x080c, 0x8259, 0x2001, 0x1956,
-	0x82ff, 0x1110, 0x2011, 0x0014, 0x2202, 0x2001, 0x1954, 0x200c,
-	0x8000, 0x2014, 0x2071, 0x193c, 0x711a, 0x721e, 0x2001, 0x0064,
-	0x080c, 0x8259, 0x2001, 0x1957, 0x82ff, 0x1110, 0x2011, 0x0014,
-	0x2202, 0x2001, 0x1958, 0x9288, 0x000a, 0x2102, 0x2001, 0x1a60,
-	0x2102, 0x2001, 0x0032, 0x080c, 0x151a, 0x080c, 0x654c, 0x00ee,
-	0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x00e6,
-	0x2001, 0x1956, 0x2003, 0x0028, 0x2001, 0x1957, 0x2003, 0x0014,
-	0x2071, 0x193c, 0x701b, 0x0000, 0x701f, 0x07d0, 0x2001, 0x1958,
-	0x2009, 0x001e, 0x2102, 0x2001, 0x1a60, 0x2102, 0x2001, 0x0032,
-	0x080c, 0x151a, 0x00ee, 0x001e, 0x000e, 0x0005, 0x0096, 0x6058,
-	0x904d, 0x0110, 0x080c, 0x101d, 0x009e, 0x0005, 0x0005, 0x00c6,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x9dec, 0x0180, 0x2b08, 0x6112,
-	0x0ca9, 0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x0033, 0x080c,
-	0x9ebc, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8,
-	0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1500,
-	0x708c, 0x9086, 0x0018, 0x11e0, 0x6014, 0x2048, 0xaa3c, 0xd2e4,
-	0x1160, 0x2c78, 0x080c, 0x8b64, 0x01d8, 0x7078, 0xaa50, 0x9206,
-	0x1160, 0x707c, 0xaa54, 0x9206, 0x1140, 0x6210, 0x00b6, 0x2258,
-	0xbaa0, 0x00be, 0x900e, 0x080c, 0x3025, 0x080c, 0xa246, 0x0020,
-	0x080c, 0xa7d1, 0x080c, 0x9e42, 0x00fe, 0x00ee, 0x009e, 0x0005,
-	0x705c, 0xaa54, 0x9206, 0x0d48, 0x0c80, 0x00c6, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x9dec, 0x0188, 0x2b08, 0x6112, 0x080c, 0xbfa6,
-	0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x004d, 0x080c, 0x9ebc,
-	0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6,
-	0x0126, 0x2091, 0x8000, 0x0016, 0x080c, 0x9dec, 0x0180, 0x2b08,
-	0x6112, 0x080c, 0xbfa6, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e,
-	0x080c, 0x9ebc, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x001e,
-	0x9006, 0x0cd0, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0066,
-	0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1568,
-	0x718c, 0x6014, 0x2048, 0xa814, 0x8003, 0x9106, 0x1530, 0x20e1,
-	0x0000, 0x2001, 0x1970, 0x2003, 0x0000, 0x6014, 0x2048, 0xa830,
-	0x20a8, 0x8906, 0x8006, 0x8007, 0x9094, 0x003f, 0x22e8, 0x9084,
-	0xffc0, 0x9080, 0x001b, 0x20a0, 0x2001, 0x1970, 0x0016, 0x200c,
-	0x080c, 0xc7ed, 0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c38,
-	0x6014, 0x2048, 0xa867, 0x0103, 0x0010, 0x080c, 0xa7d1, 0x080c,
-	0x9e42, 0x00fe, 0x00ee, 0x009e, 0x006e, 0x005e, 0x004e, 0x003e,
-	0x002e, 0x001e, 0x0005, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800,
-	0x9186, 0x0015, 0x11b8, 0x708c, 0x9086, 0x0004, 0x1198, 0x6014,
-	0x2048, 0x2c78, 0x080c, 0x8b64, 0x01a8, 0x7078, 0xaa74, 0x9206,
-	0x1130, 0x707c, 0xaa78, 0x9206, 0x1110, 0x080c, 0x2fdc, 0x080c,
-	0xa246, 0x0020, 0x080c, 0xa7d1, 0x080c, 0x9e42, 0x00fe, 0x00ee,
-	0x009e, 0x0005, 0x705c, 0xaa78, 0x9206, 0x0d78, 0x0c80, 0x0096,
-	0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1550, 0x708c,
-	0x9086, 0x0004, 0x1530, 0x6014, 0x2048, 0x2c78, 0x080c, 0x8b64,
-	0x05f0, 0x7078, 0xaacc, 0x9206, 0x1180, 0x707c, 0xaad0, 0x9206,
-	0x1160, 0x080c, 0x2fdc, 0x0016, 0xa998, 0xaab0, 0x9284, 0x1000,
-	0xc0fd, 0x080c, 0x5347, 0x001e, 0x0010, 0x080c, 0x5138, 0x080c,
-	0xbb2c, 0x0508, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000,
-	0x0080, 0x080c, 0xbb2c, 0x01b8, 0x6014, 0x2048, 0x080c, 0x5138,
-	0x1d70, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005, 0xa89b,
-	0x0004, 0x0126, 0x2091, 0x8000, 0xa867, 0x0139, 0x080c, 0x6891,
-	0x012e, 0x080c, 0x9e42, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x705c,
-	0xaad0, 0x9206, 0x0930, 0x0888, 0x0016, 0x0026, 0xa87c, 0xd0ac,
-	0x0178, 0xa938, 0xaa34, 0x2100, 0x9205, 0x0150, 0xa890, 0x9106,
-	0x1118, 0xa88c, 0x9206, 0x0120, 0xa992, 0xaa8e, 0x9085, 0x0001,
-	0x002e, 0x001e, 0x0005, 0x00b6, 0x00d6, 0x0036, 0x080c, 0xbb2c,
-	0x0904, 0xc161, 0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x929e,
-	0x4000, 0x1580, 0x6310, 0x00c6, 0x2358, 0x2009, 0x0000, 0xa868,
-	0xd0f4, 0x1140, 0x080c, 0x6467, 0x1108, 0xc185, 0xb800, 0xd0bc,
-	0x0108, 0xc18d, 0xaa96, 0xa99a, 0x20a9, 0x0004, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0031, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080,
-	0x0006, 0x2098, 0x080c, 0x0f68, 0x20a9, 0x0004, 0xa85c, 0x9080,
-	0x0035, 0x20a0, 0xb8b8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0f68,
-	0x00ce, 0x0090, 0xaa96, 0x3918, 0x9398, 0x0007, 0x231c, 0x6004,
-	0x9086, 0x0016, 0x0110, 0xa89b, 0x0004, 0xaba2, 0x6310, 0x2358,
-	0xb804, 0x9084, 0x00ff, 0xa89e, 0x080c, 0x6884, 0x6017, 0x0000,
-	0x009e, 0x003e, 0x00de, 0x00be, 0x0005, 0x0026, 0x0036, 0x0046,
-	0x00b6, 0x0096, 0x00f6, 0x6214, 0x2248, 0x6210, 0x2258, 0x2079,
-	0x0260, 0x9096, 0x0000, 0x11a0, 0xb814, 0x9084, 0x00ff, 0x900e,
-	0x080c, 0x2665, 0x2118, 0x831f, 0x939c, 0xff00, 0x7838, 0x9084,
-	0x00ff, 0x931d, 0x7c3c, 0x2011, 0x8018, 0x080c, 0x48e9, 0x00a8,
-	0x9096, 0x0001, 0x1148, 0x89ff, 0x0180, 0xa89b, 0x000d, 0x7838,
-	0xa8a6, 0x783c, 0xa8aa, 0x0048, 0x9096, 0x0002, 0x1130, 0xa89b,
-	0x000d, 0x7838, 0xa8a6, 0x783c, 0xa8aa, 0x00fe, 0x009e, 0x00be,
-	0x004e, 0x003e, 0x002e, 0x0005, 0x00c6, 0x0026, 0x0016, 0x9186,
-	0x0035, 0x0110, 0x6a38, 0x0008, 0x6a2c, 0x080c, 0xbb1a, 0x01f0,
-	0x2260, 0x6120, 0x9186, 0x0003, 0x0118, 0x9186, 0x0006, 0x1190,
-	0x6838, 0x9206, 0x0140, 0x683c, 0x9206, 0x1160, 0x6108, 0x6838,
-	0x9106, 0x1140, 0x0020, 0x6008, 0x693c, 0x9106, 0x1118, 0x6010,
-	0x6910, 0x9106, 0x001e, 0x002e, 0x00ce, 0x0005, 0x9085, 0x0001,
-	0x0cc8, 0xa974, 0xd1cc, 0x0188, 0x918c, 0x00ff, 0x918e, 0x0002,
-	0x1160, 0xa9a8, 0x918c, 0x0f00, 0x810f, 0x918e, 0x0001, 0x1128,
-	0xa834, 0xa938, 0x9115, 0x190c, 0xb23a, 0x0005, 0x0036, 0x2019,
-	0x0001, 0x0010, 0x0036, 0x901e, 0x0499, 0x01e0, 0x080c, 0xbb2c,
-	0x01c8, 0x080c, 0xbd15, 0x6037, 0x4000, 0x6014, 0x6017, 0x0000,
-	0x0096, 0x2048, 0xa87c, 0x080c, 0xbd32, 0x1118, 0x080c, 0xa7d1,
-	0x0040, 0xa867, 0x0103, 0xa877, 0x0000, 0x83ff, 0x1129, 0x080c,
-	0x6891, 0x009e, 0x003e, 0x0005, 0xa880, 0xd0b4, 0x0128, 0xa87b,
-	0x0006, 0xc0ec, 0xa882, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002,
-	0x0020, 0xa87b, 0x0005, 0x080c, 0xbe26, 0xa877, 0x0000, 0x0005,
-	0x2001, 0x1810, 0x2004, 0xd0ec, 0x0005, 0x0006, 0x2001, 0x1810,
-	0x2004, 0xd0f4, 0x000e, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004,
-	0xd0e4, 0x000e, 0x0005, 0x0036, 0x0046, 0x6010, 0x00b6, 0x2058,
-	0xbba0, 0x00be, 0x2021, 0x0007, 0x080c, 0x4a86, 0x004e, 0x003e,
-	0x0005, 0x0c51, 0x1d81, 0x0005, 0x2001, 0x1956, 0x2004, 0x601a,
-	0x0005, 0x2001, 0x1958, 0x2004, 0x6042, 0x0005, 0x080c, 0x9e42,
-	0x0804, 0x896d, 0x00b6, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c,
-	0x0db4, 0x001b, 0x006e, 0x00be, 0x0005, 0xc26d, 0xc94a, 0xcaa5,
-	0xc26d, 0xc26d, 0xc26d, 0xc26d, 0xc26d, 0xc2a4, 0xcb29, 0xc26d,
-	0xc26d, 0xc26d, 0xc26d, 0xc26d, 0xc26d, 0x080c, 0x0db4, 0x0066,
-	0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0db4, 0x0013, 0x006e, 0x0005,
-	0xc288, 0xd091, 0xc288, 0xc288, 0xc288, 0xc288, 0xc288, 0xc288,
-	0xd03e, 0xd0e5, 0xc288, 0xd6d5, 0xd70b, 0xd6d5, 0xd70b, 0xc288,
-	0x080c, 0x0db4, 0x6000, 0x9082, 0x0016, 0x1a0c, 0x0db4, 0x6000,
-	0x000a, 0x0005, 0xc2a2, 0xcd06, 0xcdf6, 0xce18, 0xced7, 0xc2a2,
-	0xcfb5, 0xcf5f, 0xcb35, 0xd014, 0xd029, 0xc2a2, 0xc2a2, 0xc2a2,
-	0xc2a2, 0xc2a2, 0x080c, 0x0db4, 0x91b2, 0x0053, 0x1a0c, 0x0db4,
-	0x2100, 0x91b2, 0x0040, 0x1a04, 0xc6eb, 0x0002, 0xc2ee, 0xc4dc,
-	0xc2ee, 0xc2ee, 0xc2ee, 0xc4e5, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee,
-	0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee,
-	0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2f0, 0xc353, 0xc362,
-	0xc3c6, 0xc3f1, 0xc469, 0xc4c7, 0xc2ee, 0xc2ee, 0xc4e8, 0xc2ee,
-	0xc2ee, 0xc4fd, 0xc50a, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee,
-	0xc58d, 0xc2ee, 0xc2ee, 0xc5a1, 0xc2ee, 0xc2ee, 0xc55c, 0xc2ee,
-	0xc2ee, 0xc2ee, 0xc5b9, 0xc2ee, 0xc2ee, 0xc2ee, 0xc636, 0xc2ee,
-	0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc2ee, 0xc6b3, 0x080c, 0x0db4,
-	0x080c, 0x6529, 0x1150, 0x2001, 0x1836, 0x2004, 0xd0cc, 0x1128,
-	0x9084, 0x0009, 0x9086, 0x0008, 0x1140, 0x6007, 0x0009, 0x602f,
-	0x0009, 0x6017, 0x0000, 0x0804, 0xc4d5, 0x080c, 0x6512, 0x00e6,
-	0x00c6, 0x0036, 0x0026, 0x0016, 0x6210, 0x2258, 0xbaa0, 0x0026,
-	0x2019, 0x0029, 0x080c, 0x8564, 0x0076, 0x903e, 0x080c, 0x8452,
-	0x2c08, 0x080c, 0xd2bc, 0x007e, 0x001e, 0x001e, 0x002e, 0x003e,
-	0x00ce, 0x00ee, 0x6610, 0x2658, 0x080c, 0x6256, 0xbe04, 0x9684,
-	0x00ff, 0x9082, 0x0006, 0x1268, 0x0016, 0x0026, 0x6210, 0x00b6,
-	0x2258, 0xbaa0, 0x00be, 0x2c08, 0x080c, 0xd883, 0x002e, 0x001e,
-	0x1178, 0x080c, 0xd1ef, 0x1904, 0xc3be, 0x080c, 0xd18b, 0x1120,
-	0x6007, 0x0008, 0x0804, 0xc4d5, 0x6007, 0x0009, 0x0804, 0xc4d5,
-	0x080c, 0xd3e6, 0x0128, 0x080c, 0xd1ef, 0x0d78, 0x0804, 0xc3be,
-	0x6017, 0x1900, 0x0c88, 0x080c, 0x30ff, 0x1904, 0xc6e8, 0x6106,
-	0x080c, 0xd140, 0x6007, 0x0006, 0x0804, 0xc4d5, 0x6007, 0x0007,
-	0x0804, 0xc4d5, 0x080c, 0xd747, 0x1904, 0xc6e8, 0x080c, 0x30ff,
-	0x1904, 0xc6e8, 0x00d6, 0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff,
-	0x9082, 0x0006, 0x1220, 0x2001, 0x0001, 0x080c, 0x6184, 0x96b4,
-	0xff00, 0x8637, 0x9686, 0x0006, 0x0188, 0x9686, 0x0004, 0x0170,
-	0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006, 0x0140, 0x9686, 0x0004,
-	0x0128, 0x9686, 0x0005, 0x0110, 0x00de, 0x0480, 0x00e6, 0x2071,
-	0x0260, 0x7034, 0x9084, 0x0003, 0x1140, 0x7034, 0x9082, 0x0014,
-	0x0220, 0x7030, 0x9084, 0x0003, 0x0130, 0x00ee, 0x6017, 0x0000,
-	0x602f, 0x0007, 0x00b0, 0x00ee, 0x080c, 0xd252, 0x1190, 0x9686,
-	0x0006, 0x1140, 0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c,
-	0x3025, 0x002e, 0x080c, 0x62e2, 0x6007, 0x000a, 0x00de, 0x0804,
-	0xc4d5, 0x6007, 0x000b, 0x00de, 0x0804, 0xc4d5, 0x080c, 0x2fdc,
-	0x080c, 0xc241, 0x6007, 0x0001, 0x0804, 0xc4d5, 0x080c, 0xd747,
-	0x1904, 0xc6e8, 0x080c, 0x30ff, 0x1904, 0xc6e8, 0x2071, 0x0260,
-	0x7034, 0x90b4, 0x0003, 0x1948, 0x90b2, 0x0014, 0x0a30, 0x7030,
-	0x9084, 0x0003, 0x1910, 0x6610, 0x2658, 0xbe04, 0x9686, 0x0707,
-	0x09e8, 0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x3025,
-	0x002e, 0x6007, 0x000c, 0x2001, 0x0001, 0x080c, 0xd863, 0x0804,
-	0xc4d5, 0x080c, 0x6529, 0x1140, 0x2001, 0x1836, 0x2004, 0x9084,
-	0x0009, 0x9086, 0x0008, 0x1110, 0x0804, 0xc2fd, 0x080c, 0x6512,
-	0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006, 0x06c0,
-	0x1138, 0x0026, 0x2001, 0x0006, 0x080c, 0x61c4, 0x002e, 0x0050,
-	0x96b4, 0xff00, 0x8637, 0x9686, 0x0004, 0x0120, 0x9686, 0x0006,
-	0x1904, 0xc3be, 0x080c, 0xd25f, 0x1120, 0x6007, 0x000e, 0x0804,
-	0xc4d5, 0x0046, 0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x2fdc,
-	0x080c, 0xc241, 0x004e, 0x0016, 0x9006, 0x2009, 0x1854, 0x210c,
-	0x0048, 0x2009, 0x0029, 0x080c, 0xd54b, 0x6010, 0x2058, 0xb800,
-	0xc0e5, 0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x0804, 0xc4d5,
-	0x2001, 0x0001, 0x080c, 0x6184, 0x0156, 0x0016, 0x0026, 0x0036,
-	0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x0270, 0x080c, 0xae0c,
-	0x003e, 0x002e, 0x001e, 0x015e, 0x9005, 0x0168, 0x96b4, 0xff00,
-	0x8637, 0x9682, 0x0004, 0x0a04, 0xc3be, 0x9682, 0x0007, 0x0a04,
-	0xc41a, 0x0804, 0xc3be, 0x6017, 0x1900, 0x6007, 0x0009, 0x0804,
-	0xc4d5, 0x080c, 0x6529, 0x1140, 0x2001, 0x1836, 0x2004, 0x9084,
-	0x0009, 0x9086, 0x0008, 0x1110, 0x0804, 0xc2fd, 0x080c, 0x6512,
-	0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff, 0x0006, 0x9086, 0x0001,
-	0x000e, 0x0170, 0x9082, 0x0006, 0x0690, 0x0150, 0x96b4, 0xff00,
-	0x8637, 0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xc3be,
-	0x080c, 0xd28d, 0x1130, 0x080c, 0xd18b, 0x1118, 0x6007, 0x0010,
-	0x04e0, 0x0046, 0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x2fdc,
-	0x080c, 0xc241, 0x004e, 0x0016, 0x9006, 0x2009, 0x1854, 0x210c,
-	0x0048, 0x2009, 0x0029, 0x080c, 0xd54b, 0x6010, 0x2058, 0xb800,
-	0xc0e5, 0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x00f0, 0x080c,
-	0xd3e6, 0x0140, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0980,
-	0x0804, 0xc3be, 0x6017, 0x1900, 0x6007, 0x0009, 0x0070, 0x080c,
-	0x30ff, 0x1904, 0xc6e8, 0x080c, 0xd747, 0x1904, 0xc6e8, 0x080c,
-	0xc888, 0x1904, 0xc3be, 0x6007, 0x0012, 0x6003, 0x0001, 0x080c,
-	0x8422, 0x080c, 0x896d, 0x0005, 0x6007, 0x0001, 0x6003, 0x0001,
-	0x080c, 0x8422, 0x080c, 0x896d, 0x0cb0, 0x6007, 0x0005, 0x0c68,
-	0x080c, 0xd747, 0x1904, 0xc6e8, 0x080c, 0x30ff, 0x1904, 0xc6e8,
-	0x080c, 0xc888, 0x1904, 0xc3be, 0x6007, 0x0020, 0x6003, 0x0001,
-	0x080c, 0x8422, 0x080c, 0x896d, 0x0005, 0x080c, 0x30ff, 0x1904,
-	0xc6e8, 0x6007, 0x0023, 0x6003, 0x0001, 0x080c, 0x8422, 0x080c,
-	0x896d, 0x0005, 0x080c, 0xd747, 0x1904, 0xc6e8, 0x080c, 0x30ff,
-	0x1904, 0xc6e8, 0x080c, 0xc888, 0x1904, 0xc3be, 0x0016, 0x0026,
-	0x00e6, 0x2071, 0x0260, 0x7244, 0x9286, 0xffff, 0x0180, 0x2c08,
-	0x080c, 0xbb1a, 0x01b0, 0x2260, 0x7240, 0x6008, 0x9206, 0x1188,
-	0x6010, 0x9190, 0x0004, 0x2214, 0x9206, 0x01b8, 0x0050, 0x7240,
-	0x2c08, 0x9006, 0x080c, 0xd51d, 0x1180, 0x7244, 0x9286, 0xffff,
-	0x01b0, 0x2160, 0x6007, 0x0026, 0x6017, 0x1700, 0x7214, 0x9296,
-	0xffff, 0x1180, 0x6007, 0x0025, 0x0068, 0x6020, 0x9086, 0x0007,
-	0x1d80, 0x6004, 0x9086, 0x0024, 0x1110, 0x080c, 0x9e42, 0x2160,
-	0x6007, 0x0025, 0x6003, 0x0001, 0x080c, 0x8422, 0x080c, 0x896d,
-	0x00ee, 0x002e, 0x001e, 0x0005, 0x2001, 0x0001, 0x080c, 0x6184,
-	0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805,
-	0x2011, 0x0276, 0x080c, 0xae0c, 0x003e, 0x002e, 0x001e, 0x015e,
-	0x0120, 0x6007, 0x0031, 0x0804, 0xc4d5, 0x080c, 0xaa74, 0x080c,
-	0x6f9b, 0x1190, 0x0006, 0x0026, 0x0036, 0x080c, 0x6fb5, 0x1138,
-	0x080c, 0x727f, 0x080c, 0x5cda, 0x080c, 0x6ecd, 0x0010, 0x080c,
-	0x6f73, 0x003e, 0x002e, 0x000e, 0x0005, 0x080c, 0x30ff, 0x1904,
-	0xc6e8, 0x080c, 0xc888, 0x1904, 0xc3be, 0x6106, 0x080c, 0xc8a4,
-	0x1120, 0x6007, 0x002b, 0x0804, 0xc4d5, 0x6007, 0x002c, 0x0804,
-	0xc4d5, 0x080c, 0xd747, 0x1904, 0xc6e8, 0x080c, 0x30ff, 0x1904,
-	0xc6e8, 0x080c, 0xc888, 0x1904, 0xc3be, 0x6106, 0x080c, 0xc8a9,
-	0x1120, 0x6007, 0x002e, 0x0804, 0xc4d5, 0x6007, 0x002f, 0x0804,
-	0xc4d5, 0x080c, 0x30ff, 0x1904, 0xc6e8, 0x00e6, 0x00d6, 0x00c6,
-	0x6010, 0x2058, 0xb904, 0x9184, 0x00ff, 0x9086, 0x0006, 0x0158,
-	0x9184, 0xff00, 0x8007, 0x9086, 0x0006, 0x0128, 0x00ce, 0x00de,
-	0x00ee, 0x0804, 0xc4dc, 0x080c, 0x5393, 0xd0e4, 0x0904, 0xc633,
-	0x2071, 0x026c, 0x7010, 0x603a, 0x7014, 0x603e, 0x7108, 0x720c,
-	0x080c, 0x6567, 0x0140, 0x6010, 0x2058, 0xb810, 0x9106, 0x1118,
-	0xb814, 0x9206, 0x0510, 0x080c, 0x6563, 0x15b8, 0x2069, 0x1800,
-	0x687c, 0x9206, 0x1590, 0x6878, 0x9106, 0x1578, 0x7210, 0x080c,
-	0xbb1a, 0x0590, 0x080c, 0xc773, 0x0578, 0x080c, 0xd5c7, 0x0560,
-	0x622e, 0x6007, 0x0036, 0x6003, 0x0001, 0x080c, 0x83da, 0x080c,
-	0x896d, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x7214, 0x9286, 0xffff,
-	0x0150, 0x080c, 0xbb1a, 0x01c0, 0x9280, 0x0002, 0x2004, 0x7110,
-	0x9106, 0x1190, 0x08e0, 0x7210, 0x2c08, 0x9085, 0x0001, 0x080c,
-	0xd51d, 0x2c10, 0x2160, 0x0140, 0x0890, 0x6007, 0x0037, 0x602f,
-	0x0009, 0x6017, 0x1500, 0x08b8, 0x6007, 0x0037, 0x602f, 0x0003,
-	0x6017, 0x1700, 0x0880, 0x6007, 0x0012, 0x0868, 0x080c, 0x30ff,
-	0x1904, 0xc6e8, 0x6010, 0x2058, 0xb804, 0x9084, 0xff00, 0x8007,
-	0x9086, 0x0006, 0x1904, 0xc4dc, 0x00e6, 0x00d6, 0x00c6, 0x080c,
-	0x5393, 0xd0e4, 0x0904, 0xc6ab, 0x2069, 0x1800, 0x2071, 0x026c,
-	0x7008, 0x603a, 0x720c, 0x623e, 0x9286, 0xffff, 0x1150, 0x7208,
-	0x00c6, 0x2c08, 0x9085, 0x0001, 0x080c, 0xd51d, 0x2c10, 0x00ce,
-	0x05e8, 0x080c, 0xbb1a, 0x05d0, 0x7108, 0x9280, 0x0002, 0x2004,
-	0x9106, 0x15a0, 0x00c6, 0x0026, 0x2260, 0x080c, 0xb750, 0x002e,
-	0x00ce, 0x7118, 0x918c, 0xff00, 0x810f, 0x9186, 0x0001, 0x0178,
-	0x9186, 0x0005, 0x0118, 0x9186, 0x0007, 0x1198, 0x9280, 0x0005,
-	0x2004, 0x9005, 0x0170, 0x080c, 0xc773, 0x0904, 0xc62c, 0x0056,
-	0x7510, 0x7614, 0x080c, 0xd5e0, 0x005e, 0x00ce, 0x00de, 0x00ee,
-	0x0005, 0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00, 0x6003,
-	0x0001, 0x080c, 0x83da, 0x080c, 0x896d, 0x0c78, 0x6007, 0x003b,
-	0x602f, 0x0003, 0x6017, 0x0300, 0x6003, 0x0001, 0x080c, 0x83da,
-	0x080c, 0x896d, 0x0c10, 0x6007, 0x003b, 0x602f, 0x000b, 0x6017,
-	0x0000, 0x0804, 0xc603, 0x00e6, 0x0026, 0x080c, 0x6529, 0x0550,
-	0x080c, 0x6512, 0x080c, 0xd7b9, 0x1518, 0x2071, 0x1800, 0x70d8,
-	0x9085, 0x0003, 0x70da, 0x00f6, 0x2079, 0x0100, 0x72ac, 0x9284,
-	0x00ff, 0x707a, 0x78e6, 0x9284, 0xff00, 0x727c, 0x9205, 0x707e,
-	0x78ea, 0x00fe, 0x70e3, 0x0000, 0x080c, 0x6567, 0x0120, 0x2011,
-	0x19d0, 0x2013, 0x07d0, 0xd0ac, 0x1128, 0x080c, 0x2dbd, 0x0010,
-	0x080c, 0xd7eb, 0x002e, 0x00ee, 0x080c, 0x9e42, 0x0804, 0xc4db,
-	0x080c, 0x9e42, 0x0005, 0x2600, 0x0002, 0xc6ff, 0xc6ff, 0xc6ff,
-	0xc6ff, 0xc6ff, 0xc701, 0xc6ff, 0xc6ff, 0xc6ff, 0xc6ff, 0xc71e,
-	0xc6ff, 0xc6ff, 0xc6ff, 0xc730, 0xc73d, 0xc76e, 0xc6ff, 0x080c,
-	0x0db4, 0x080c, 0xd747, 0x1d20, 0x080c, 0x30ff, 0x1d08, 0x080c,
-	0xc888, 0x1148, 0x7038, 0x6016, 0x6007, 0x0045, 0x6003, 0x0001,
-	0x080c, 0x8422, 0x0005, 0x080c, 0x2fdc, 0x080c, 0xc241, 0x6007,
-	0x0001, 0x6003, 0x0001, 0x080c, 0x8422, 0x0005, 0x080c, 0xd747,
-	0x1938, 0x080c, 0x30ff, 0x1920, 0x080c, 0xc888, 0x1d60, 0x703c,
-	0x6016, 0x6007, 0x004a, 0x6003, 0x0001, 0x080c, 0x8422, 0x0005,
-	0x080c, 0xc790, 0x0904, 0xc6e8, 0x6007, 0x004e, 0x6003, 0x0001,
-	0x080c, 0x8422, 0x080c, 0x896d, 0x0005, 0x6007, 0x004f, 0x6017,
-	0x0000, 0x7134, 0x918c, 0x00ff, 0x81ff, 0x0508, 0x9186, 0x0001,
-	0x1160, 0x7140, 0x2001, 0x198d, 0x2004, 0x9106, 0x11b0, 0x7144,
-	0x2001, 0x198e, 0x2004, 0x9106, 0x0190, 0x9186, 0x0002, 0x1168,
-	0x2011, 0x0276, 0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019,
-	0x000a, 0x080c, 0xae20, 0x009e, 0x0110, 0x6017, 0x0001, 0x6003,
-	0x0001, 0x080c, 0x8422, 0x080c, 0x896d, 0x0005, 0x6007, 0x0050,
-	0x703c, 0x6016, 0x0ca0, 0x0016, 0x00e6, 0x2071, 0x0260, 0x00b6,
-	0x00c6, 0x2260, 0x6010, 0x2058, 0xb8bc, 0xd084, 0x0150, 0x7128,
-	0x6048, 0x9106, 0x1120, 0x712c, 0x6044, 0x9106, 0x0110, 0x9006,
-	0x0010, 0x9085, 0x0001, 0x00ce, 0x00be, 0x00ee, 0x001e, 0x0005,
-	0x0016, 0x0096, 0x0086, 0x00e6, 0x01c6, 0x01d6, 0x0126, 0x2091,
-	0x8000, 0x2071, 0x1800, 0x708c, 0x908a, 0x00f9, 0x16e8, 0x20e1,
-	0x0000, 0x2001, 0x1970, 0x2003, 0x0000, 0x080c, 0x1004, 0x05a0,
-	0x2900, 0x6016, 0x708c, 0x8004, 0xa816, 0x908a, 0x001e, 0x02d0,
-	0xa833, 0x001e, 0x20a9, 0x001e, 0xa860, 0x20e8, 0xa85c, 0x9080,
-	0x001b, 0x20a0, 0x2001, 0x1970, 0x0016, 0x200c, 0x0471, 0x001e,
-	0x2940, 0x080c, 0x1004, 0x01c0, 0x2900, 0xa006, 0x2100, 0x81ff,
-	0x0180, 0x0c18, 0xa832, 0x20a8, 0xa860, 0x20e8, 0xa85c, 0x9080,
-	0x001b, 0x20a0, 0x2001, 0x1970, 0x0016, 0x200c, 0x00b1, 0x001e,
-	0x0000, 0x9085, 0x0001, 0x0048, 0x2071, 0x1800, 0x708f, 0x0000,
-	0x6014, 0x2048, 0x080c, 0x0f9d, 0x9006, 0x012e, 0x01de, 0x01ce,
-	0x00ee, 0x008e, 0x009e, 0x001e, 0x0005, 0x0006, 0x0016, 0x0026,
-	0x0036, 0x00c6, 0x918c, 0xffff, 0x11a8, 0x080c, 0x2243, 0x2099,
-	0x026c, 0x2001, 0x0014, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003,
-	0x00f8, 0x20a8, 0x4003, 0x22a8, 0x8108, 0x080c, 0x2243, 0x2099,
-	0x0260, 0x0ca8, 0x080c, 0x2243, 0x2061, 0x1970, 0x6004, 0x2098,
-	0x6008, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x0048, 0x20a8,
-	0x4003, 0x22a8, 0x8108, 0x080c, 0x2243, 0x2099, 0x0260, 0x0ca8,
-	0x2061, 0x1970, 0x2019, 0x0280, 0x3300, 0x931e, 0x0110, 0x6006,
-	0x0020, 0x2001, 0x0260, 0x6006, 0x8108, 0x2162, 0x9292, 0x0021,
-	0x9296, 0xffff, 0x620a, 0x00ce, 0x003e, 0x002e, 0x001e, 0x000e,
-	0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00c6, 0x81ff, 0x11b8,
-	0x080c, 0x225b, 0x20a1, 0x024c, 0x2001, 0x0014, 0x3518, 0x9312,
-	0x1218, 0x23a8, 0x4003, 0x0418, 0x20a8, 0x4003, 0x82ff, 0x01f8,
-	0x22a8, 0x8108, 0x080c, 0x225b, 0x20a1, 0x0240, 0x0c98, 0x080c,
-	0x225b, 0x2061, 0x1973, 0x6004, 0x20a0, 0x6008, 0x3518, 0x9312,
-	0x1218, 0x23a8, 0x4003, 0x0058, 0x20a8, 0x4003, 0x82ff, 0x0138,
-	0x22a8, 0x8108, 0x080c, 0x225b, 0x20a1, 0x0240, 0x0c98, 0x2061,
-	0x1973, 0x2019, 0x0260, 0x3400, 0x931e, 0x0110, 0x6006, 0x0020,
-	0x2001, 0x0240, 0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296,
+	0x2091, 0x8000, 0x0016, 0x080c, 0x9dd9, 0x0180, 0x2b08, 0x6112,
+	0x080c, 0xbfb5, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e, 0x080c,
+	0x9ea9, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x001e, 0x9006,
+	0x0cd0, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0066, 0x0096,
+	0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1568, 0x718c,
+	0x6014, 0x2048, 0xa814, 0x8003, 0x9106, 0x1530, 0x20e1, 0x0000,
+	0x2001, 0x1978, 0x2003, 0x0000, 0x6014, 0x2048, 0xa830, 0x20a8,
+	0x8906, 0x8006, 0x8007, 0x9094, 0x003f, 0x22e8, 0x9084, 0xffc0,
+	0x9080, 0x001b, 0x20a0, 0x2001, 0x1978, 0x0016, 0x200c, 0x080c,
+	0xc7fc, 0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c38, 0x6014,
+	0x2048, 0xa867, 0x0103, 0x0010, 0x080c, 0xa7cd, 0x080c, 0x9e2f,
+	0x00fe, 0x00ee, 0x009e, 0x006e, 0x005e, 0x004e, 0x003e, 0x002e,
+	0x001e, 0x0005, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186,
+	0x0015, 0x11b8, 0x708c, 0x9086, 0x0004, 0x1198, 0x6014, 0x2048,
+	0x2c78, 0x080c, 0x8b7e, 0x01a8, 0x7078, 0xaa74, 0x9206, 0x1130,
+	0x707c, 0xaa78, 0x9206, 0x1110, 0x080c, 0x2fe7, 0x080c, 0xa233,
+	0x0020, 0x080c, 0xa7cd, 0x080c, 0x9e2f, 0x00fe, 0x00ee, 0x009e,
+	0x0005, 0x705c, 0xaa78, 0x9206, 0x0d78, 0x0c80, 0x0096, 0x00e6,
+	0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x1550, 0x708c, 0x9086,
+	0x0004, 0x1530, 0x6014, 0x2048, 0x2c78, 0x080c, 0x8b7e, 0x05f0,
+	0x7078, 0xaacc, 0x9206, 0x1180, 0x707c, 0xaad0, 0x9206, 0x1160,
+	0x080c, 0x2fe7, 0x0016, 0xa998, 0xaab0, 0x9284, 0x1000, 0xc0fd,
+	0x080c, 0x5352, 0x001e, 0x0010, 0x080c, 0x5143, 0x080c, 0xbb3b,
+	0x0508, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x0080,
+	0x080c, 0xbb3b, 0x01b8, 0x6014, 0x2048, 0x080c, 0x5143, 0x1d70,
+	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005, 0xa89b, 0x0004,
+	0x0126, 0x2091, 0x8000, 0xa867, 0x0139, 0x080c, 0x68a0, 0x012e,
+	0x080c, 0x9e2f, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x705c, 0xaad0,
+	0x9206, 0x0930, 0x0888, 0x0016, 0x0026, 0xa87c, 0xd0ac, 0x0178,
+	0xa938, 0xaa34, 0x2100, 0x9205, 0x0150, 0xa890, 0x9106, 0x1118,
+	0xa88c, 0x9206, 0x0120, 0xa992, 0xaa8e, 0x9085, 0x0001, 0x002e,
+	0x001e, 0x0005, 0x00b6, 0x00d6, 0x0036, 0x080c, 0xbb3b, 0x0904,
+	0xc170, 0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x929e, 0x4000,
+	0x1580, 0x6310, 0x00c6, 0x2358, 0x2009, 0x0000, 0xa868, 0xd0f4,
+	0x1140, 0x080c, 0x6476, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
+	0xc18d, 0xaa96, 0xa99a, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x0031, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006,
+	0x2098, 0x080c, 0x0f68, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x0035,
+	0x20a0, 0xb8b8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0f68, 0x00ce,
+	0x0090, 0xaa96, 0x3918, 0x9398, 0x0007, 0x231c, 0x6004, 0x9086,
+	0x0016, 0x0110, 0xa89b, 0x0004, 0xaba2, 0x6310, 0x2358, 0xb804,
+	0x9084, 0x00ff, 0xa89e, 0x080c, 0x6893, 0x6017, 0x0000, 0x009e,
+	0x003e, 0x00de, 0x00be, 0x0005, 0x0026, 0x0036, 0x0046, 0x00b6,
+	0x0096, 0x00f6, 0x6214, 0x2248, 0x6210, 0x2258, 0x2079, 0x0260,
+	0x9096, 0x0000, 0x11a0, 0xb814, 0x9084, 0x00ff, 0x900e, 0x080c,
+	0x2670, 0x2118, 0x831f, 0x939c, 0xff00, 0x7838, 0x9084, 0x00ff,
+	0x931d, 0x7c3c, 0x2011, 0x8018, 0x080c, 0x48f4, 0x00a8, 0x9096,
+	0x0001, 0x1148, 0x89ff, 0x0180, 0xa89b, 0x000d, 0x7838, 0xa8a6,
+	0x783c, 0xa8aa, 0x0048, 0x9096, 0x0002, 0x1130, 0xa89b, 0x000d,
+	0x7838, 0xa8a6, 0x783c, 0xa8aa, 0x00fe, 0x009e, 0x00be, 0x004e,
+	0x003e, 0x002e, 0x0005, 0x00c6, 0x0026, 0x0016, 0x9186, 0x0035,
+	0x0110, 0x6a38, 0x0008, 0x6a2c, 0x080c, 0xbb29, 0x01f0, 0x2260,
+	0x6120, 0x9186, 0x0003, 0x0118, 0x9186, 0x0006, 0x1190, 0x6838,
+	0x9206, 0x0140, 0x683c, 0x9206, 0x1160, 0x6108, 0x6838, 0x9106,
+	0x1140, 0x0020, 0x6008, 0x693c, 0x9106, 0x1118, 0x6010, 0x6910,
+	0x9106, 0x001e, 0x002e, 0x00ce, 0x0005, 0x9085, 0x0001, 0x0cc8,
+	0xa974, 0xd1cc, 0x0188, 0x918c, 0x00ff, 0x918e, 0x0002, 0x1160,
+	0xa9a8, 0x918c, 0x0f00, 0x810f, 0x918e, 0x0001, 0x1128, 0xa834,
+	0xa938, 0x9115, 0x190c, 0xb236, 0x0005, 0x0036, 0x2019, 0x0001,
+	0x0010, 0x0036, 0x901e, 0x0499, 0x01e0, 0x080c, 0xbb3b, 0x01c8,
+	0x080c, 0xbd24, 0x6037, 0x4000, 0x6014, 0x6017, 0x0000, 0x0096,
+	0x2048, 0xa87c, 0x080c, 0xbd41, 0x1118, 0x080c, 0xa7cd, 0x0040,
+	0xa867, 0x0103, 0xa877, 0x0000, 0x83ff, 0x1129, 0x080c, 0x68a0,
+	0x009e, 0x003e, 0x0005, 0xa880, 0xd0b4, 0x0128, 0xa87b, 0x0006,
+	0xc0ec, 0xa882, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002, 0x0020,
+	0xa87b, 0x0005, 0x080c, 0xbe35, 0xa877, 0x0000, 0x0005, 0x2001,
+	0x1810, 0x2004, 0xd0ec, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004,
+	0xd0f4, 0x000e, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0e4,
+	0x000e, 0x0005, 0x0036, 0x0046, 0x6010, 0x00b6, 0x2058, 0xbba0,
+	0x00be, 0x2021, 0x0007, 0x080c, 0x4a91, 0x004e, 0x003e, 0x0005,
+	0x0c51, 0x1d81, 0x0005, 0x2001, 0x195e, 0x2004, 0x601a, 0x0005,
+	0x2001, 0x1960, 0x2004, 0x6042, 0x0005, 0x080c, 0x9e2f, 0x0804,
+	0x898b, 0x00b6, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0db4,
+	0x001b, 0x006e, 0x00be, 0x0005, 0xc27c, 0xc959, 0xcab4, 0xc27c,
+	0xc27c, 0xc27c, 0xc27c, 0xc27c, 0xc2b3, 0xcb38, 0xc27c, 0xc27c,
+	0xc27c, 0xc27c, 0xc27c, 0xc27c, 0x080c, 0x0db4, 0x0066, 0x6000,
+	0x90b2, 0x0016, 0x1a0c, 0x0db4, 0x0013, 0x006e, 0x0005, 0xc297,
+	0xd0aa, 0xc297, 0xc297, 0xc297, 0xc297, 0xc297, 0xc297, 0xd057,
+	0xd0fe, 0xc297, 0xd6ee, 0xd724, 0xd6ee, 0xd724, 0xc297, 0x080c,
+	0x0db4, 0x6000, 0x9082, 0x0016, 0x1a0c, 0x0db4, 0x6000, 0x000a,
+	0x0005, 0xc2b1, 0xcd16, 0xce08, 0xce2b, 0xceeb, 0xc2b1, 0xcfca,
+	0xcf73, 0xcb44, 0xd02d, 0xd042, 0xc2b1, 0xc2b1, 0xc2b1, 0xc2b1,
+	0xc2b1, 0x080c, 0x0db4, 0x91b2, 0x0053, 0x1a0c, 0x0db4, 0x2100,
+	0x91b2, 0x0040, 0x1a04, 0xc6fa, 0x0002, 0xc2fd, 0xc4eb, 0xc2fd,
+	0xc2fd, 0xc2fd, 0xc4f4, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd,
+	0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd,
+	0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2ff, 0xc362, 0xc371, 0xc3d5,
+	0xc400, 0xc478, 0xc4d6, 0xc2fd, 0xc2fd, 0xc4f7, 0xc2fd, 0xc2fd,
+	0xc50c, 0xc519, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc59c,
+	0xc2fd, 0xc2fd, 0xc5b0, 0xc2fd, 0xc2fd, 0xc56b, 0xc2fd, 0xc2fd,
+	0xc2fd, 0xc5c8, 0xc2fd, 0xc2fd, 0xc2fd, 0xc645, 0xc2fd, 0xc2fd,
+	0xc2fd, 0xc2fd, 0xc2fd, 0xc2fd, 0xc6c2, 0x080c, 0x0db4, 0x080c,
+	0x6538, 0x1150, 0x2001, 0x1836, 0x2004, 0xd0cc, 0x1128, 0x9084,
+	0x0009, 0x9086, 0x0008, 0x1140, 0x6007, 0x0009, 0x602f, 0x0009,
+	0x6017, 0x0000, 0x0804, 0xc4e4, 0x080c, 0x6521, 0x00e6, 0x00c6,
+	0x0036, 0x0026, 0x0016, 0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019,
+	0x0029, 0x080c, 0x8582, 0x0076, 0x903e, 0x080c, 0x8470, 0x2c08,
+	0x080c, 0xd2d5, 0x007e, 0x001e, 0x001e, 0x002e, 0x003e, 0x00ce,
+	0x00ee, 0x6610, 0x2658, 0x080c, 0x6265, 0xbe04, 0x9684, 0x00ff,
+	0x9082, 0x0006, 0x1268, 0x0016, 0x0026, 0x6210, 0x00b6, 0x2258,
+	0xbaa0, 0x00be, 0x2c08, 0x080c, 0xd89c, 0x002e, 0x001e, 0x1178,
+	0x080c, 0xd208, 0x1904, 0xc3cd, 0x080c, 0xd1a4, 0x1120, 0x6007,
+	0x0008, 0x0804, 0xc4e4, 0x6007, 0x0009, 0x0804, 0xc4e4, 0x080c,
+	0xd3ff, 0x0128, 0x080c, 0xd208, 0x0d78, 0x0804, 0xc3cd, 0x6017,
+	0x1900, 0x0c88, 0x080c, 0x310a, 0x1904, 0xc6f7, 0x6106, 0x080c,
+	0xd159, 0x6007, 0x0006, 0x0804, 0xc4e4, 0x6007, 0x0007, 0x0804,
+	0xc4e4, 0x080c, 0xd760, 0x1904, 0xc6f7, 0x080c, 0x310a, 0x1904,
+	0xc6f7, 0x00d6, 0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff, 0x9082,
+	0x0006, 0x1220, 0x2001, 0x0001, 0x080c, 0x6193, 0x96b4, 0xff00,
+	0x8637, 0x9686, 0x0006, 0x0188, 0x9686, 0x0004, 0x0170, 0xbe04,
+	0x96b4, 0x00ff, 0x9686, 0x0006, 0x0140, 0x9686, 0x0004, 0x0128,
+	0x9686, 0x0005, 0x0110, 0x00de, 0x0480, 0x00e6, 0x2071, 0x0260,
+	0x7034, 0x9084, 0x0003, 0x1140, 0x7034, 0x9082, 0x0014, 0x0220,
+	0x7030, 0x9084, 0x0003, 0x0130, 0x00ee, 0x6017, 0x0000, 0x602f,
+	0x0007, 0x00b0, 0x00ee, 0x080c, 0xd26b, 0x1190, 0x9686, 0x0006,
+	0x1140, 0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x3030,
+	0x002e, 0x080c, 0x62f1, 0x6007, 0x000a, 0x00de, 0x0804, 0xc4e4,
+	0x6007, 0x000b, 0x00de, 0x0804, 0xc4e4, 0x080c, 0x2fe7, 0x080c,
+	0xc250, 0x6007, 0x0001, 0x0804, 0xc4e4, 0x080c, 0xd760, 0x1904,
+	0xc6f7, 0x080c, 0x310a, 0x1904, 0xc6f7, 0x2071, 0x0260, 0x7034,
+	0x90b4, 0x0003, 0x1948, 0x90b2, 0x0014, 0x0a30, 0x7030, 0x9084,
+	0x0003, 0x1910, 0x6610, 0x2658, 0xbe04, 0x9686, 0x0707, 0x09e8,
+	0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x3030, 0x002e,
+	0x6007, 0x000c, 0x2001, 0x0001, 0x080c, 0xd87c, 0x0804, 0xc4e4,
+	0x080c, 0x6538, 0x1140, 0x2001, 0x1836, 0x2004, 0x9084, 0x0009,
+	0x9086, 0x0008, 0x1110, 0x0804, 0xc30c, 0x080c, 0x6521, 0x6610,
+	0x2658, 0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006, 0x06c0, 0x1138,
+	0x0026, 0x2001, 0x0006, 0x080c, 0x61d3, 0x002e, 0x0050, 0x96b4,
+	0xff00, 0x8637, 0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904,
+	0xc3cd, 0x080c, 0xd278, 0x1120, 0x6007, 0x000e, 0x0804, 0xc4e4,
+	0x0046, 0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x2fe7, 0x080c,
+	0xc250, 0x004e, 0x0016, 0x9006, 0x2009, 0x185c, 0x210c, 0x0048,
+	0x2009, 0x0029, 0x080c, 0xd564, 0x6010, 0x2058, 0xb800, 0xc0e5,
+	0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x0804, 0xc4e4, 0x2001,
+	0x0001, 0x080c, 0x6193, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9,
+	0x0004, 0x2019, 0x1805, 0x2011, 0x0270, 0x080c, 0xae08, 0x003e,
+	0x002e, 0x001e, 0x015e, 0x9005, 0x0168, 0x96b4, 0xff00, 0x8637,
+	0x9682, 0x0004, 0x0a04, 0xc3cd, 0x9682, 0x0007, 0x0a04, 0xc429,
+	0x0804, 0xc3cd, 0x6017, 0x1900, 0x6007, 0x0009, 0x0804, 0xc4e4,
+	0x080c, 0x6538, 0x1140, 0x2001, 0x1836, 0x2004, 0x9084, 0x0009,
+	0x9086, 0x0008, 0x1110, 0x0804, 0xc30c, 0x080c, 0x6521, 0x6610,
+	0x2658, 0xbe04, 0x9684, 0x00ff, 0x0006, 0x9086, 0x0001, 0x000e,
+	0x0170, 0x9082, 0x0006, 0x0690, 0x0150, 0x96b4, 0xff00, 0x8637,
+	0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xc3cd, 0x080c,
+	0xd2a6, 0x1130, 0x080c, 0xd1a4, 0x1118, 0x6007, 0x0010, 0x04e0,
+	0x0046, 0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x2fe7, 0x080c,
+	0xc250, 0x004e, 0x0016, 0x9006, 0x2009, 0x185c, 0x210c, 0x0048,
+	0x2009, 0x0029, 0x080c, 0xd564, 0x6010, 0x2058, 0xb800, 0xc0e5,
+	0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x00f0, 0x080c, 0xd3ff,
+	0x0140, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0980, 0x0804,
+	0xc3cd, 0x6017, 0x1900, 0x6007, 0x0009, 0x0070, 0x080c, 0x310a,
+	0x1904, 0xc6f7, 0x080c, 0xd760, 0x1904, 0xc6f7, 0x080c, 0xc897,
+	0x1904, 0xc3cd, 0x6007, 0x0012, 0x6003, 0x0001, 0x080c, 0x8440,
+	0x080c, 0x898b, 0x0005, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x8440, 0x080c, 0x898b, 0x0cb0, 0x6007, 0x0005, 0x0c68, 0x080c,
+	0xd760, 0x1904, 0xc6f7, 0x080c, 0x310a, 0x1904, 0xc6f7, 0x080c,
+	0xc897, 0x1904, 0xc3cd, 0x6007, 0x0020, 0x6003, 0x0001, 0x080c,
+	0x8440, 0x080c, 0x898b, 0x0005, 0x080c, 0x310a, 0x1904, 0xc6f7,
+	0x6007, 0x0023, 0x6003, 0x0001, 0x080c, 0x8440, 0x080c, 0x898b,
+	0x0005, 0x080c, 0xd760, 0x1904, 0xc6f7, 0x080c, 0x310a, 0x1904,
+	0xc6f7, 0x080c, 0xc897, 0x1904, 0xc3cd, 0x0016, 0x0026, 0x00e6,
+	0x2071, 0x0260, 0x7244, 0x9286, 0xffff, 0x0180, 0x2c08, 0x080c,
+	0xbb29, 0x01b0, 0x2260, 0x7240, 0x6008, 0x9206, 0x1188, 0x6010,
+	0x9190, 0x0004, 0x2214, 0x9206, 0x01b8, 0x0050, 0x7240, 0x2c08,
+	0x9006, 0x080c, 0xd536, 0x1180, 0x7244, 0x9286, 0xffff, 0x01b0,
+	0x2160, 0x6007, 0x0026, 0x6017, 0x1700, 0x7214, 0x9296, 0xffff,
+	0x1180, 0x6007, 0x0025, 0x0068, 0x6020, 0x9086, 0x0007, 0x1d80,
+	0x6004, 0x9086, 0x0024, 0x1110, 0x080c, 0x9e2f, 0x2160, 0x6007,
+	0x0025, 0x6003, 0x0001, 0x080c, 0x8440, 0x080c, 0x898b, 0x00ee,
+	0x002e, 0x001e, 0x0005, 0x2001, 0x0001, 0x080c, 0x6193, 0x0156,
+	0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805, 0x2011,
+	0x0276, 0x080c, 0xae08, 0x003e, 0x002e, 0x001e, 0x015e, 0x0120,
+	0x6007, 0x0031, 0x0804, 0xc4e4, 0x080c, 0xaa70, 0x080c, 0x6faa,
+	0x1190, 0x0006, 0x0026, 0x0036, 0x080c, 0x6fc4, 0x1138, 0x080c,
+	0x728c, 0x080c, 0x5ce5, 0x080c, 0x6edc, 0x0010, 0x080c, 0x6f82,
+	0x003e, 0x002e, 0x000e, 0x0005, 0x080c, 0x310a, 0x1904, 0xc6f7,
+	0x080c, 0xc897, 0x1904, 0xc3cd, 0x6106, 0x080c, 0xc8b3, 0x1120,
+	0x6007, 0x002b, 0x0804, 0xc4e4, 0x6007, 0x002c, 0x0804, 0xc4e4,
+	0x080c, 0xd760, 0x1904, 0xc6f7, 0x080c, 0x310a, 0x1904, 0xc6f7,
+	0x080c, 0xc897, 0x1904, 0xc3cd, 0x6106, 0x080c, 0xc8b8, 0x1120,
+	0x6007, 0x002e, 0x0804, 0xc4e4, 0x6007, 0x002f, 0x0804, 0xc4e4,
+	0x080c, 0x310a, 0x1904, 0xc6f7, 0x00e6, 0x00d6, 0x00c6, 0x6010,
+	0x2058, 0xb904, 0x9184, 0x00ff, 0x9086, 0x0006, 0x0158, 0x9184,
+	0xff00, 0x8007, 0x9086, 0x0006, 0x0128, 0x00ce, 0x00de, 0x00ee,
+	0x0804, 0xc4eb, 0x080c, 0x539e, 0xd0e4, 0x0904, 0xc642, 0x2071,
+	0x026c, 0x7010, 0x603a, 0x7014, 0x603e, 0x7108, 0x720c, 0x080c,
+	0x6576, 0x0140, 0x6010, 0x2058, 0xb810, 0x9106, 0x1118, 0xb814,
+	0x9206, 0x0510, 0x080c, 0x6572, 0x15b8, 0x2069, 0x1800, 0x687c,
+	0x9206, 0x1590, 0x6878, 0x9106, 0x1578, 0x7210, 0x080c, 0xbb29,
+	0x0590, 0x080c, 0xc782, 0x0578, 0x080c, 0xd5e0, 0x0560, 0x622e,
+	0x6007, 0x0036, 0x6003, 0x0001, 0x080c, 0x83f8, 0x080c, 0x898b,
+	0x00ce, 0x00de, 0x00ee, 0x0005, 0x7214, 0x9286, 0xffff, 0x0150,
+	0x080c, 0xbb29, 0x01c0, 0x9280, 0x0002, 0x2004, 0x7110, 0x9106,
+	0x1190, 0x08e0, 0x7210, 0x2c08, 0x9085, 0x0001, 0x080c, 0xd536,
+	0x2c10, 0x2160, 0x0140, 0x0890, 0x6007, 0x0037, 0x602f, 0x0009,
+	0x6017, 0x1500, 0x08b8, 0x6007, 0x0037, 0x602f, 0x0003, 0x6017,
+	0x1700, 0x0880, 0x6007, 0x0012, 0x0868, 0x080c, 0x310a, 0x1904,
+	0xc6f7, 0x6010, 0x2058, 0xb804, 0x9084, 0xff00, 0x8007, 0x9086,
+	0x0006, 0x1904, 0xc4eb, 0x00e6, 0x00d6, 0x00c6, 0x080c, 0x539e,
+	0xd0e4, 0x0904, 0xc6ba, 0x2069, 0x1800, 0x2071, 0x026c, 0x7008,
+	0x603a, 0x720c, 0x623e, 0x9286, 0xffff, 0x1150, 0x7208, 0x00c6,
+	0x2c08, 0x9085, 0x0001, 0x080c, 0xd536, 0x2c10, 0x00ce, 0x05e8,
+	0x080c, 0xbb29, 0x05d0, 0x7108, 0x9280, 0x0002, 0x2004, 0x9106,
+	0x15a0, 0x00c6, 0x0026, 0x2260, 0x080c, 0xb74f, 0x002e, 0x00ce,
+	0x7118, 0x918c, 0xff00, 0x810f, 0x9186, 0x0001, 0x0178, 0x9186,
+	0x0005, 0x0118, 0x9186, 0x0007, 0x1198, 0x9280, 0x0005, 0x2004,
+	0x9005, 0x0170, 0x080c, 0xc782, 0x0904, 0xc63b, 0x0056, 0x7510,
+	0x7614, 0x080c, 0xd5f9, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x0005,
+	0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00, 0x6003, 0x0001,
+	0x080c, 0x83f8, 0x080c, 0x898b, 0x0c78, 0x6007, 0x003b, 0x602f,
+	0x0003, 0x6017, 0x0300, 0x6003, 0x0001, 0x080c, 0x83f8, 0x080c,
+	0x898b, 0x0c10, 0x6007, 0x003b, 0x602f, 0x000b, 0x6017, 0x0000,
+	0x0804, 0xc612, 0x00e6, 0x0026, 0x080c, 0x6538, 0x0550, 0x080c,
+	0x6521, 0x080c, 0xd7d2, 0x1518, 0x2071, 0x1800, 0x70d8, 0x9085,
+	0x0003, 0x70da, 0x00f6, 0x2079, 0x0100, 0x72ac, 0x9284, 0x00ff,
+	0x707a, 0x78e6, 0x9284, 0xff00, 0x727c, 0x9205, 0x707e, 0x78ea,
+	0x00fe, 0x70e3, 0x0000, 0x080c, 0x6576, 0x0120, 0x2011, 0x19d8,
+	0x2013, 0x07d0, 0xd0ac, 0x1128, 0x080c, 0x2dc8, 0x0010, 0x080c,
+	0xd804, 0x002e, 0x00ee, 0x080c, 0x9e2f, 0x0804, 0xc4ea, 0x080c,
+	0x9e2f, 0x0005, 0x2600, 0x0002, 0xc70e, 0xc70e, 0xc70e, 0xc70e,
+	0xc70e, 0xc710, 0xc70e, 0xc70e, 0xc70e, 0xc70e, 0xc72d, 0xc70e,
+	0xc70e, 0xc70e, 0xc73f, 0xc74c, 0xc77d, 0xc70e, 0x080c, 0x0db4,
+	0x080c, 0xd760, 0x1d20, 0x080c, 0x310a, 0x1d08, 0x080c, 0xc897,
+	0x1148, 0x7038, 0x6016, 0x6007, 0x0045, 0x6003, 0x0001, 0x080c,
+	0x8440, 0x0005, 0x080c, 0x2fe7, 0x080c, 0xc250, 0x6007, 0x0001,
+	0x6003, 0x0001, 0x080c, 0x8440, 0x0005, 0x080c, 0xd760, 0x1938,
+	0x080c, 0x310a, 0x1920, 0x080c, 0xc897, 0x1d60, 0x703c, 0x6016,
+	0x6007, 0x004a, 0x6003, 0x0001, 0x080c, 0x8440, 0x0005, 0x080c,
+	0xc79f, 0x0904, 0xc6f7, 0x6007, 0x004e, 0x6003, 0x0001, 0x080c,
+	0x8440, 0x080c, 0x898b, 0x0005, 0x6007, 0x004f, 0x6017, 0x0000,
+	0x7134, 0x918c, 0x00ff, 0x81ff, 0x0508, 0x9186, 0x0001, 0x1160,
+	0x7140, 0x2001, 0x1995, 0x2004, 0x9106, 0x11b0, 0x7144, 0x2001,
+	0x1996, 0x2004, 0x9106, 0x0190, 0x9186, 0x0002, 0x1168, 0x2011,
+	0x0276, 0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a,
+	0x080c, 0xae1c, 0x009e, 0x0110, 0x6017, 0x0001, 0x6003, 0x0001,
+	0x080c, 0x8440, 0x080c, 0x898b, 0x0005, 0x6007, 0x0050, 0x703c,
+	0x6016, 0x0ca0, 0x0016, 0x00e6, 0x2071, 0x0260, 0x00b6, 0x00c6,
+	0x2260, 0x6010, 0x2058, 0xb8bc, 0xd084, 0x0150, 0x7128, 0x6048,
+	0x9106, 0x1120, 0x712c, 0x6044, 0x9106, 0x0110, 0x9006, 0x0010,
+	0x9085, 0x0001, 0x00ce, 0x00be, 0x00ee, 0x001e, 0x0005, 0x0016,
+	0x0096, 0x0086, 0x00e6, 0x01c6, 0x01d6, 0x0126, 0x2091, 0x8000,
+	0x2071, 0x1800, 0x708c, 0x908a, 0x00f9, 0x16e8, 0x20e1, 0x0000,
+	0x2001, 0x1978, 0x2003, 0x0000, 0x080c, 0x1004, 0x05a0, 0x2900,
+	0x6016, 0x708c, 0x8004, 0xa816, 0x908a, 0x001e, 0x02d0, 0xa833,
+	0x001e, 0x20a9, 0x001e, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b,
+	0x20a0, 0x2001, 0x1978, 0x0016, 0x200c, 0x0471, 0x001e, 0x2940,
+	0x080c, 0x1004, 0x01c0, 0x2900, 0xa006, 0x2100, 0x81ff, 0x0180,
+	0x0c18, 0xa832, 0x20a8, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b,
+	0x20a0, 0x2001, 0x1978, 0x0016, 0x200c, 0x00b1, 0x001e, 0x0000,
+	0x9085, 0x0001, 0x0048, 0x2071, 0x1800, 0x708f, 0x0000, 0x6014,
+	0x2048, 0x080c, 0x0f9d, 0x9006, 0x012e, 0x01de, 0x01ce, 0x00ee,
+	0x008e, 0x009e, 0x001e, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036,
+	0x00c6, 0x918c, 0xffff, 0x11a8, 0x080c, 0x224e, 0x2099, 0x026c,
+	0x2001, 0x0014, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x00f8,
+	0x20a8, 0x4003, 0x22a8, 0x8108, 0x080c, 0x224e, 0x2099, 0x0260,
+	0x0ca8, 0x080c, 0x224e, 0x2061, 0x1978, 0x6004, 0x2098, 0x6008,
+	0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x0048, 0x20a8, 0x4003,
+	0x22a8, 0x8108, 0x080c, 0x224e, 0x2099, 0x0260, 0x0ca8, 0x2061,
+	0x1978, 0x2019, 0x0280, 0x3300, 0x931e, 0x0110, 0x6006, 0x0020,
+	0x2001, 0x0260, 0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296,
 	0xffff, 0x620a, 0x00ce, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005,
-	0x00b6, 0x0066, 0x6610, 0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637,
-	0x9686, 0x0006, 0x0170, 0x9686, 0x0004, 0x0158, 0xbe04, 0x96b4,
-	0x00ff, 0x9686, 0x0006, 0x0128, 0x9686, 0x0004, 0x0110, 0x9085,
-	0x0001, 0x006e, 0x00be, 0x0005, 0x00d6, 0x080c, 0xc920, 0x00de,
-	0x0005, 0x00d6, 0x080c, 0xc92d, 0x1520, 0x680c, 0x908c, 0xff00,
-	0x6820, 0x9084, 0x00ff, 0x9115, 0x6216, 0x6824, 0x602e, 0xd1e4,
-	0x0130, 0x9006, 0x080c, 0xd863, 0x2009, 0x0001, 0x0078, 0xd1ec,
-	0x0180, 0x6920, 0x918c, 0x00ff, 0x6824, 0x080c, 0x2665, 0x1148,
-	0x2001, 0x0001, 0x080c, 0xd863, 0x2110, 0x900e, 0x080c, 0x3025,
-	0x0018, 0x9085, 0x0001, 0x0008, 0x9006, 0x00de, 0x0005, 0x00b6,
-	0x00c6, 0x080c, 0x9e8f, 0x05a8, 0x0016, 0x0026, 0x00c6, 0x2011,
-	0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2665, 0x1578, 0x080c,
-	0x61e7, 0x1560, 0xbe12, 0xbd16, 0x00ce, 0x002e, 0x001e, 0x2b00,
-	0x6012, 0x080c, 0xd747, 0x11d8, 0x080c, 0x30ff, 0x11c0, 0x080c,
-	0xc888, 0x0510, 0x2001, 0x0007, 0x080c, 0x6198, 0x2001, 0x0007,
-	0x080c, 0x61c4, 0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001,
-	0x6003, 0x0001, 0x080c, 0x8422, 0x080c, 0x896d, 0x0010, 0x080c,
-	0x9e42, 0x9085, 0x0001, 0x00ce, 0x00be, 0x0005, 0x080c, 0x9e42,
-	0x00ce, 0x002e, 0x001e, 0x0ca8, 0x080c, 0x9e42, 0x9006, 0x0c98,
-	0x2069, 0x026d, 0x6800, 0x9082, 0x0010, 0x1228, 0x6017, 0x0000,
-	0x9085, 0x0001, 0x0008, 0x9006, 0x0005, 0x6017, 0x0000, 0x2069,
-	0x026c, 0x6808, 0x9084, 0xff00, 0x9086, 0x0800, 0x1190, 0x6904,
-	0x9186, 0x0018, 0x0118, 0x9186, 0x0014, 0x1158, 0x810f, 0x6800,
-	0x9084, 0x00ff, 0x910d, 0x615a, 0x908e, 0x0014, 0x0110, 0x908e,
-	0x0010, 0x0005, 0x6004, 0x90b2, 0x0053, 0x1a0c, 0x0db4, 0x91b6,
-	0x0013, 0x1130, 0x2008, 0x91b2, 0x0040, 0x1a04, 0xca75, 0x0092,
-	0x91b6, 0x0027, 0x0120, 0x91b6, 0x0014, 0x190c, 0x0db4, 0x2001,
-	0x0007, 0x080c, 0x61c4, 0x080c, 0x8861, 0x080c, 0x9e72, 0x080c,
-	0x896d, 0x0005, 0xc9aa, 0xc9ac, 0xc9aa, 0xc9aa, 0xc9aa, 0xc9ac,
-	0xc9bb, 0xca6e, 0xca0d, 0xca6e, 0xca1f, 0xca6e, 0xc9bb, 0xca6e,
-	0xca66, 0xca6e, 0xca66, 0xca6e, 0xca6e, 0xc9aa, 0xc9aa, 0xc9aa,
-	0xc9aa, 0xc9aa, 0xc9aa, 0xc9aa, 0xc9aa, 0xc9aa, 0xc9aa, 0xc9aa,
-	0xc9ac, 0xc9aa, 0xca6e, 0xc9aa, 0xc9aa, 0xca6e, 0xc9aa, 0xca6b,
-	0xca6e, 0xc9aa, 0xc9aa, 0xc9aa, 0xc9aa, 0xca6e, 0xca6e, 0xc9aa,
-	0xca6e, 0xca6e, 0xc9aa, 0xc9b6, 0xc9aa, 0xc9aa, 0xc9aa, 0xc9aa,
-	0xca6a, 0xca6e, 0xc9aa, 0xc9aa, 0xca6e, 0xca6e, 0xc9aa, 0xc9aa,
-	0xc9aa, 0xc9aa, 0x080c, 0x0db4, 0x080c, 0x8861, 0x080c, 0xc244,
-	0x6003, 0x0002, 0x080c, 0x896d, 0x0804, 0xca74, 0x9006, 0x080c,
-	0x6184, 0x0804, 0xca6e, 0x080c, 0x6563, 0x1904, 0xca6e, 0x9006,
-	0x080c, 0x6184, 0x6010, 0x2058, 0xb810, 0x9086, 0x00ff, 0x1140,
-	0x00f6, 0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6, 0x00fe, 0x0428,
-	0x6010, 0x2058, 0xb8b0, 0x9005, 0x1178, 0x080c, 0xc22c, 0x1904,
-	0xca6e, 0x0036, 0x0046, 0xbba0, 0x2021, 0x0007, 0x080c, 0x4a86,
-	0x004e, 0x003e, 0x0804, 0xca6e, 0x080c, 0x3130, 0x1904, 0xca6e,
-	0x2001, 0x1800, 0x2004, 0x9086, 0x0002, 0x1138, 0x00f6, 0x2079,
-	0x1800, 0x78a4, 0x8000, 0x78a6, 0x00fe, 0x2001, 0x0002, 0x080c,
-	0x6198, 0x080c, 0x8861, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007,
-	0x0002, 0x080c, 0x8422, 0x080c, 0x896d, 0x6110, 0x2158, 0x2009,
-	0x0001, 0x080c, 0x802f, 0x0804, 0xca74, 0x6610, 0x2658, 0xbe04,
-	0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0904, 0xca6e, 0x9686,
-	0x0004, 0x0904, 0xca6e, 0x2001, 0x0004, 0x0804, 0xca6c, 0x2001,
-	0x1800, 0x2004, 0x9086, 0x0003, 0x1158, 0x0036, 0x0046, 0x6010,
-	0x2058, 0xbba0, 0x2021, 0x0006, 0x080c, 0x4a86, 0x004e, 0x003e,
-	0x2001, 0x0006, 0x080c, 0xca92, 0x6610, 0x2658, 0xbe04, 0x0066,
-	0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x006e, 0x0168, 0x2001,
-	0x0006, 0x080c, 0x61c4, 0x9284, 0x00ff, 0x908e, 0x0007, 0x1120,
-	0x2001, 0x0006, 0x080c, 0x6198, 0x080c, 0x6563, 0x11f8, 0x2001,
-	0x1836, 0x2004, 0xd0a4, 0x01d0, 0xbe04, 0x96b4, 0x00ff, 0x9686,
-	0x0006, 0x01a0, 0x00f6, 0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6,
-	0x00fe, 0x0804, 0xc9f5, 0x2001, 0x0004, 0x0030, 0x2001, 0x0006,
-	0x0449, 0x0020, 0x0018, 0x0010, 0x080c, 0x61c4, 0x080c, 0x8861,
-	0x080c, 0x9e42, 0x080c, 0x896d, 0x0005, 0x2600, 0x0002, 0xca89,
-	0xca89, 0xca89, 0xca89, 0xca89, 0xca8b, 0xca89, 0xca89, 0xca89,
-	0xca89, 0xca8b, 0xca89, 0xca89, 0xca89, 0xca8b, 0xca8b, 0xca8b,
-	0xca8b, 0x080c, 0x0db4, 0x080c, 0x8861, 0x080c, 0x9e42, 0x080c,
-	0x896d, 0x0005, 0x0016, 0x00b6, 0x00d6, 0x6110, 0x2158, 0xb900,
-	0xd184, 0x0138, 0x080c, 0x6198, 0x9006, 0x080c, 0x6184, 0x080c,
-	0x3005, 0x00de, 0x00be, 0x001e, 0x0005, 0x6610, 0x2658, 0xb804,
-	0x9084, 0xff00, 0x8007, 0x90b2, 0x000c, 0x1a0c, 0x0db4, 0x91b6,
-	0x0015, 0x1110, 0x003b, 0x0028, 0x91b6, 0x0016, 0x190c, 0x0db4,
-	0x006b, 0x0005, 0xa8b2, 0xa8b2, 0xa8b2, 0xa8b2, 0xcb27, 0xa8b2,
-	0xcb11, 0xcad2, 0xa8b2, 0xa8b2, 0xa8b2, 0xa8b2, 0xa8b2, 0xa8b2,
-	0xa8b2, 0xa8b2, 0xcb27, 0xa8b2, 0xcb11, 0xcb18, 0xa8b2, 0xa8b2,
-	0xa8b2, 0xa8b2, 0x00f6, 0x080c, 0x6563, 0x11d8, 0x080c, 0xc22c,
-	0x11c0, 0x6010, 0x905d, 0x01a8, 0xb8b0, 0x9005, 0x0190, 0x9006,
-	0x080c, 0x6184, 0x2001, 0x0002, 0x080c, 0x6198, 0x6023, 0x0001,
-	0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8422, 0x080c, 0x896d,
-	0x00f0, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2665,
-	0x11b0, 0x080c, 0x6247, 0x0118, 0x080c, 0x9e42, 0x0080, 0xb810,
-	0x0006, 0xb814, 0x0006, 0xb8b0, 0x0006, 0x080c, 0x5cf4, 0x000e,
-	0xb8b2, 0x000e, 0xb816, 0x000e, 0xb812, 0x080c, 0x9e42, 0x00fe,
-	0x0005, 0x6604, 0x96b6, 0x001e, 0x1110, 0x080c, 0x9e42, 0x0005,
-	0x080c, 0xac98, 0x1148, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c,
-	0x8422, 0x080c, 0x896d, 0x0010, 0x080c, 0x9e42, 0x0005, 0x0804,
-	0x9e42, 0x6004, 0x908a, 0x0053, 0x1a0c, 0x0db4, 0x080c, 0x8861,
-	0x080c, 0x9e72, 0x080c, 0x896d, 0x0005, 0x9182, 0x0040, 0x0002,
-	0xcb4b, 0xcb4b, 0xcb4b, 0xcb4b, 0xcb4d, 0xcb4b, 0xcb4b, 0xcb4b,
-	0xcb4b, 0xcb4b, 0xcb4b, 0xcb4b, 0xcb4b, 0xcb4b, 0xcb4b, 0xcb4b,
-	0xcb4b, 0xcb4b, 0xcb4b, 0x080c, 0x0db4, 0x0096, 0x00b6, 0x00d6,
+	0x0006, 0x0016, 0x0026, 0x0036, 0x00c6, 0x81ff, 0x11b8, 0x080c,
+	0x2266, 0x20a1, 0x024c, 0x2001, 0x0014, 0x3518, 0x9312, 0x1218,
+	0x23a8, 0x4003, 0x0418, 0x20a8, 0x4003, 0x82ff, 0x01f8, 0x22a8,
+	0x8108, 0x080c, 0x2266, 0x20a1, 0x0240, 0x0c98, 0x080c, 0x2266,
+	0x2061, 0x197b, 0x6004, 0x20a0, 0x6008, 0x3518, 0x9312, 0x1218,
+	0x23a8, 0x4003, 0x0058, 0x20a8, 0x4003, 0x82ff, 0x0138, 0x22a8,
+	0x8108, 0x080c, 0x2266, 0x20a1, 0x0240, 0x0c98, 0x2061, 0x197b,
+	0x2019, 0x0260, 0x3400, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001,
+	0x0240, 0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff,
+	0x620a, 0x00ce, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x00b6,
+	0x0066, 0x6610, 0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637, 0x9686,
+	0x0006, 0x0170, 0x9686, 0x0004, 0x0158, 0xbe04, 0x96b4, 0x00ff,
+	0x9686, 0x0006, 0x0128, 0x9686, 0x0004, 0x0110, 0x9085, 0x0001,
+	0x006e, 0x00be, 0x0005, 0x00d6, 0x080c, 0xc92f, 0x00de, 0x0005,
+	0x00d6, 0x080c, 0xc93c, 0x1520, 0x680c, 0x908c, 0xff00, 0x6820,
+	0x9084, 0x00ff, 0x9115, 0x6216, 0x6824, 0x602e, 0xd1e4, 0x0130,
+	0x9006, 0x080c, 0xd87c, 0x2009, 0x0001, 0x0078, 0xd1ec, 0x0180,
+	0x6920, 0x918c, 0x00ff, 0x6824, 0x080c, 0x2670, 0x1148, 0x2001,
+	0x0001, 0x080c, 0xd87c, 0x2110, 0x900e, 0x080c, 0x3030, 0x0018,
+	0x9085, 0x0001, 0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00c6,
+	0x080c, 0x9e7c, 0x05a8, 0x0016, 0x0026, 0x00c6, 0x2011, 0x0263,
+	0x2204, 0x8211, 0x220c, 0x080c, 0x2670, 0x1578, 0x080c, 0x61f6,
+	0x1560, 0xbe12, 0xbd16, 0x00ce, 0x002e, 0x001e, 0x2b00, 0x6012,
+	0x080c, 0xd760, 0x11d8, 0x080c, 0x310a, 0x11c0, 0x080c, 0xc897,
+	0x0510, 0x2001, 0x0007, 0x080c, 0x61a7, 0x2001, 0x0007, 0x080c,
+	0x61d3, 0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003,
+	0x0001, 0x080c, 0x8440, 0x080c, 0x898b, 0x0010, 0x080c, 0x9e2f,
+	0x9085, 0x0001, 0x00ce, 0x00be, 0x0005, 0x080c, 0x9e2f, 0x00ce,
+	0x002e, 0x001e, 0x0ca8, 0x080c, 0x9e2f, 0x9006, 0x0c98, 0x2069,
+	0x026d, 0x6800, 0x9082, 0x0010, 0x1228, 0x6017, 0x0000, 0x9085,
+	0x0001, 0x0008, 0x9006, 0x0005, 0x6017, 0x0000, 0x2069, 0x026c,
+	0x6808, 0x9084, 0xff00, 0x9086, 0x0800, 0x1190, 0x6904, 0x9186,
+	0x0018, 0x0118, 0x9186, 0x0014, 0x1158, 0x810f, 0x6800, 0x9084,
+	0x00ff, 0x910d, 0x615a, 0x908e, 0x0014, 0x0110, 0x908e, 0x0010,
+	0x0005, 0x6004, 0x90b2, 0x0053, 0x1a0c, 0x0db4, 0x91b6, 0x0013,
+	0x1130, 0x2008, 0x91b2, 0x0040, 0x1a04, 0xca84, 0x0092, 0x91b6,
+	0x0027, 0x0120, 0x91b6, 0x0014, 0x190c, 0x0db4, 0x2001, 0x0007,
+	0x080c, 0x61d3, 0x080c, 0x887f, 0x080c, 0x9e5f, 0x080c, 0x898b,
+	0x0005, 0xc9b9, 0xc9bb, 0xc9b9, 0xc9b9, 0xc9b9, 0xc9bb, 0xc9ca,
+	0xca7d, 0xca1c, 0xca7d, 0xca2e, 0xca7d, 0xc9ca, 0xca7d, 0xca75,
+	0xca7d, 0xca75, 0xca7d, 0xca7d, 0xc9b9, 0xc9b9, 0xc9b9, 0xc9b9,
+	0xc9b9, 0xc9b9, 0xc9b9, 0xc9b9, 0xc9b9, 0xc9b9, 0xc9b9, 0xc9bb,
+	0xc9b9, 0xca7d, 0xc9b9, 0xc9b9, 0xca7d, 0xc9b9, 0xca7a, 0xca7d,
+	0xc9b9, 0xc9b9, 0xc9b9, 0xc9b9, 0xca7d, 0xca7d, 0xc9b9, 0xca7d,
+	0xca7d, 0xc9b9, 0xc9c5, 0xc9b9, 0xc9b9, 0xc9b9, 0xc9b9, 0xca79,
+	0xca7d, 0xc9b9, 0xc9b9, 0xca7d, 0xca7d, 0xc9b9, 0xc9b9, 0xc9b9,
+	0xc9b9, 0x080c, 0x0db4, 0x080c, 0x887f, 0x080c, 0xc253, 0x6003,
+	0x0002, 0x080c, 0x898b, 0x0804, 0xca83, 0x9006, 0x080c, 0x6193,
+	0x0804, 0xca7d, 0x080c, 0x6572, 0x1904, 0xca7d, 0x9006, 0x080c,
+	0x6193, 0x6010, 0x2058, 0xb810, 0x9086, 0x00ff, 0x1140, 0x00f6,
+	0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6, 0x00fe, 0x0428, 0x6010,
+	0x2058, 0xb8b0, 0x9005, 0x1178, 0x080c, 0xc23b, 0x1904, 0xca7d,
+	0x0036, 0x0046, 0xbba0, 0x2021, 0x0007, 0x080c, 0x4a91, 0x004e,
+	0x003e, 0x0804, 0xca7d, 0x080c, 0x313b, 0x1904, 0xca7d, 0x2001,
+	0x1800, 0x2004, 0x9086, 0x0002, 0x1138, 0x00f6, 0x2079, 0x1800,
+	0x78a4, 0x8000, 0x78a6, 0x00fe, 0x2001, 0x0002, 0x080c, 0x61a7,
+	0x080c, 0x887f, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002,
+	0x080c, 0x8440, 0x080c, 0x898b, 0x6110, 0x2158, 0x2009, 0x0001,
+	0x080c, 0x804d, 0x0804, 0xca83, 0x6610, 0x2658, 0xbe04, 0x96b4,
+	0xff00, 0x8637, 0x9686, 0x0006, 0x0904, 0xca7d, 0x9686, 0x0004,
+	0x0904, 0xca7d, 0x2001, 0x0004, 0x0804, 0xca7b, 0x2001, 0x1800,
+	0x2004, 0x9086, 0x0003, 0x1158, 0x0036, 0x0046, 0x6010, 0x2058,
+	0xbba0, 0x2021, 0x0006, 0x080c, 0x4a91, 0x004e, 0x003e, 0x2001,
+	0x0006, 0x080c, 0xcaa1, 0x6610, 0x2658, 0xbe04, 0x0066, 0x96b4,
+	0xff00, 0x8637, 0x9686, 0x0006, 0x006e, 0x0168, 0x2001, 0x0006,
+	0x080c, 0x61d3, 0x9284, 0x00ff, 0x908e, 0x0007, 0x1120, 0x2001,
+	0x0006, 0x080c, 0x61a7, 0x080c, 0x6572, 0x11f8, 0x2001, 0x1836,
+	0x2004, 0xd0a4, 0x01d0, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006,
+	0x01a0, 0x00f6, 0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6, 0x00fe,
+	0x0804, 0xca04, 0x2001, 0x0004, 0x0030, 0x2001, 0x0006, 0x0449,
+	0x0020, 0x0018, 0x0010, 0x080c, 0x61d3, 0x080c, 0x887f, 0x080c,
+	0x9e2f, 0x080c, 0x898b, 0x0005, 0x2600, 0x0002, 0xca98, 0xca98,
+	0xca98, 0xca98, 0xca98, 0xca9a, 0xca98, 0xca98, 0xca98, 0xca98,
+	0xca9a, 0xca98, 0xca98, 0xca98, 0xca9a, 0xca9a, 0xca9a, 0xca9a,
+	0x080c, 0x0db4, 0x080c, 0x887f, 0x080c, 0x9e2f, 0x080c, 0x898b,
+	0x0005, 0x0016, 0x00b6, 0x00d6, 0x6110, 0x2158, 0xb900, 0xd184,
+	0x0138, 0x080c, 0x61a7, 0x9006, 0x080c, 0x6193, 0x080c, 0x3010,
+	0x00de, 0x00be, 0x001e, 0x0005, 0x6610, 0x2658, 0xb804, 0x9084,
+	0xff00, 0x8007, 0x90b2, 0x000c, 0x1a0c, 0x0db4, 0x91b6, 0x0015,
+	0x1110, 0x003b, 0x0028, 0x91b6, 0x0016, 0x190c, 0x0db4, 0x006b,
+	0x0005, 0xa8ae, 0xa8ae, 0xa8ae, 0xa8ae, 0xcb36, 0xa8ae, 0xcb20,
+	0xcae1, 0xa8ae, 0xa8ae, 0xa8ae, 0xa8ae, 0xa8ae, 0xa8ae, 0xa8ae,
+	0xa8ae, 0xcb36, 0xa8ae, 0xcb20, 0xcb27, 0xa8ae, 0xa8ae, 0xa8ae,
+	0xa8ae, 0x00f6, 0x080c, 0x6572, 0x11d8, 0x080c, 0xc23b, 0x11c0,
+	0x6010, 0x905d, 0x01a8, 0xb8b0, 0x9005, 0x0190, 0x9006, 0x080c,
+	0x6193, 0x2001, 0x0002, 0x080c, 0x61a7, 0x6023, 0x0001, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x080c, 0x8440, 0x080c, 0x898b, 0x00f0,
+	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2670, 0x11b0,
+	0x080c, 0x6256, 0x0118, 0x080c, 0x9e2f, 0x0080, 0xb810, 0x0006,
+	0xb814, 0x0006, 0xb8b0, 0x0006, 0x080c, 0x5cff, 0x000e, 0xb8b2,
+	0x000e, 0xb816, 0x000e, 0xb812, 0x080c, 0x9e2f, 0x00fe, 0x0005,
+	0x6604, 0x96b6, 0x001e, 0x1110, 0x080c, 0x9e2f, 0x0005, 0x080c,
+	0xac94, 0x1148, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x8440,
+	0x080c, 0x898b, 0x0010, 0x080c, 0x9e2f, 0x0005, 0x0804, 0x9e2f,
+	0x6004, 0x908a, 0x0053, 0x1a0c, 0x0db4, 0x080c, 0x887f, 0x080c,
+	0x9e5f, 0x080c, 0x898b, 0x0005, 0x9182, 0x0040, 0x0002, 0xcb5b,
+	0xcb5b, 0xcb5b, 0xcb5b, 0xcb5d, 0xcb5b, 0xcb5b, 0xcb5b, 0xcb5b,
+	0xcb5b, 0xcb5b, 0xcb5b, 0xcb5b, 0xcb5b, 0xcb5b, 0xcb5b, 0xcb5b,
+	0xcb5b, 0xcb5b, 0xcb5b, 0x080c, 0x0db4, 0x0096, 0x00b6, 0x00d6,
 	0x00e6, 0x00f6, 0x0046, 0x0026, 0x6210, 0x2258, 0xb8ac, 0x9005,
 	0x11a8, 0x6106, 0x2071, 0x0260, 0x7444, 0x94a4, 0xff00, 0x0904,
-	0xcbb3, 0x080c, 0xd857, 0x1170, 0x9486, 0x2000, 0x1158, 0x2009,
-	0x0001, 0x2011, 0x0200, 0x080c, 0x8218, 0x0020, 0x9026, 0x080c,
-	0xd78c, 0x0c38, 0x080c, 0x0feb, 0x090c, 0x0db4, 0x6003, 0x0007,
+	0xcbc3, 0x080c, 0xd870, 0x1170, 0x9486, 0x2000, 0x1158, 0x2009,
+	0x0001, 0x2011, 0x0200, 0x080c, 0x8236, 0x0020, 0x9026, 0x080c,
+	0xd7a5, 0x0c38, 0x080c, 0x0feb, 0x090c, 0x0db4, 0x6003, 0x0007,
 	0xa867, 0x010d, 0x9006, 0xa802, 0xa86a, 0xac8a, 0x2c00, 0xa88e,
 	0x6008, 0xa8e2, 0x6010, 0x2058, 0xb8a0, 0x7130, 0xa97a, 0x0016,
 	0xa876, 0xa87f, 0x0000, 0xa883, 0x0000, 0xa887, 0x0036, 0x080c,
-	0x6891, 0x001e, 0x080c, 0xd857, 0x1904, 0xcc13, 0x9486, 0x2000,
-	0x1130, 0x2019, 0x0017, 0x080c, 0xd4c7, 0x0804, 0xcc13, 0x9486,
-	0x0200, 0x1120, 0x080c, 0xd463, 0x0804, 0xcc13, 0x9486, 0x0400,
-	0x0120, 0x9486, 0x1000, 0x1904, 0xcc13, 0x2019, 0x0002, 0x080c,
-	0xd47e, 0x0804, 0xcc13, 0x2069, 0x1a40, 0x6a00, 0xd284, 0x0904,
-	0xcc7d, 0x9284, 0x0300, 0x1904, 0xcc76, 0x6804, 0x9005, 0x0904,
-	0xcc5e, 0x2d78, 0x6003, 0x0007, 0x080c, 0x1004, 0x0904, 0xcc1f,
+	0x68a0, 0x001e, 0x080c, 0xd870, 0x1904, 0xcc23, 0x9486, 0x2000,
+	0x1130, 0x2019, 0x0017, 0x080c, 0xd4e0, 0x0804, 0xcc23, 0x9486,
+	0x0200, 0x1120, 0x080c, 0xd47c, 0x0804, 0xcc23, 0x9486, 0x0400,
+	0x0120, 0x9486, 0x1000, 0x1904, 0xcc23, 0x2019, 0x0002, 0x080c,
+	0xd497, 0x0804, 0xcc23, 0x2069, 0x1a48, 0x6a00, 0xd284, 0x0904,
+	0xcc8d, 0x9284, 0x0300, 0x1904, 0xcc86, 0x6804, 0x9005, 0x0904,
+	0xcc6e, 0x2d78, 0x6003, 0x0007, 0x080c, 0x1004, 0x0904, 0xcc2f,
 	0x7800, 0xd08c, 0x1118, 0x7804, 0x8001, 0x7806, 0x6017, 0x0000,
-	0x2001, 0x180f, 0x2004, 0xd084, 0x1904, 0xcc81, 0x9006, 0xa802,
+	0x2001, 0x180f, 0x2004, 0xd084, 0x1904, 0xcc91, 0x9006, 0xa802,
 	0xa867, 0x0116, 0xa86a, 0x6008, 0xa8e2, 0x2c00, 0xa87a, 0x6010,
 	0x2058, 0xb8a0, 0x7130, 0xa9b6, 0xa876, 0xb928, 0xa9ba, 0xb92c,
 	0xa9be, 0xb930, 0xa9c2, 0xb934, 0xa9c6, 0xa883, 0x003d, 0x7044,
-	0x9084, 0x0003, 0x9080, 0xcc1b, 0x2005, 0xa87e, 0x20a9, 0x000a,
+	0x9084, 0x0003, 0x9080, 0xcc2b, 0x2005, 0xa87e, 0x20a9, 0x000a,
 	0x2001, 0x0270, 0xaa5c, 0x9290, 0x0021, 0x2009, 0x0205, 0x200b,
 	0x0080, 0x20e1, 0x0000, 0xab60, 0x23e8, 0x2098, 0x22a0, 0x4003,
 	0x200b, 0x0000, 0x2001, 0x027a, 0x200c, 0xa9b2, 0x8000, 0x200c,
-	0xa9ae, 0x080c, 0x6891, 0x002e, 0x004e, 0x00fe, 0x00ee, 0x00de,
+	0xa9ae, 0x080c, 0x68a0, 0x002e, 0x004e, 0x00fe, 0x00ee, 0x00de,
 	0x00be, 0x009e, 0x0005, 0x0000, 0x0080, 0x0040, 0x0000, 0x2001,
-	0x1810, 0x2004, 0xd084, 0x0120, 0x080c, 0x0feb, 0x1904, 0xcbc8,
-	0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c, 0x83da,
-	0x080c, 0x896d, 0x0c00, 0x2069, 0x0260, 0x6848, 0x9084, 0xff00,
+	0x1810, 0x2004, 0xd084, 0x0120, 0x080c, 0x0feb, 0x1904, 0xcbd8,
+	0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c, 0x83f8,
+	0x080c, 0x898b, 0x0c00, 0x2069, 0x0260, 0x6848, 0x9084, 0xff00,
 	0x9086, 0x1200, 0x1198, 0x686c, 0x9084, 0x00ff, 0x0016, 0x6114,
 	0x918c, 0xf700, 0x910d, 0x6116, 0x001e, 0x6003, 0x0001, 0x6007,
-	0x0043, 0x080c, 0x83da, 0x080c, 0x896d, 0x0828, 0x6868, 0x602e,
+	0x0043, 0x080c, 0x83f8, 0x080c, 0x898b, 0x0828, 0x6868, 0x602e,
 	0x686c, 0x6032, 0x6017, 0xf200, 0x6003, 0x0001, 0x6007, 0x0041,
-	0x080c, 0x83da, 0x080c, 0x896d, 0x0804, 0xcc13, 0x2001, 0x180e,
-	0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x48e9, 0x6017,
+	0x080c, 0x83f8, 0x080c, 0x898b, 0x0804, 0xcc23, 0x2001, 0x180e,
+	0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x48f4, 0x6017,
 	0xf300, 0x0010, 0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041,
-	0x080c, 0x83da, 0x080c, 0x896d, 0x0804, 0xcc13, 0x6017, 0xf500,
-	0x0c98, 0x6017, 0xf600, 0x0804, 0xcc33, 0x6017, 0xf200, 0x0804,
-	0xcc33, 0xa867, 0x0146, 0xa86b, 0x0000, 0x6008, 0xa886, 0x2c00,
-	0xa87a, 0x7044, 0x9084, 0x0003, 0x9080, 0xcc1b, 0x2005, 0xa87e,
+	0x080c, 0x83f8, 0x080c, 0x898b, 0x0804, 0xcc23, 0x6017, 0xf500,
+	0x0c98, 0x6017, 0xf600, 0x0804, 0xcc43, 0x6017, 0xf200, 0x0804,
+	0xcc43, 0xa867, 0x0146, 0xa86b, 0x0000, 0x6008, 0xa886, 0x2c00,
+	0xa87a, 0x7044, 0x9084, 0x0003, 0x9080, 0xcc2b, 0x2005, 0xa87e,
 	0x2928, 0x6010, 0x2058, 0xb8a0, 0xa876, 0xb828, 0xa88a, 0xb82c,
 	0xa88e, 0xb830, 0xa892, 0xb834, 0xa896, 0xa883, 0x003d, 0x2009,
 	0x0205, 0x2104, 0x9085, 0x0080, 0x200a, 0x20e1, 0x0000, 0x2011,
 	0x0210, 0x2214, 0x9294, 0x0fff, 0xaaa2, 0x9282, 0x0111, 0x1a0c,
 	0x0db4, 0x8210, 0x821c, 0x2001, 0x026c, 0x2098, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0029, 0x20a0, 0x2011, 0xccfd, 0x2041, 0x0001,
+	0xa85c, 0x9080, 0x0029, 0x20a0, 0x2011, 0xcd0d, 0x2041, 0x0001,
 	0x223d, 0x9784, 0x00ff, 0x9322, 0x1208, 0x2300, 0x20a8, 0x4003,
 	0x931a, 0x0530, 0x8210, 0xd7fc, 0x1130, 0x8d68, 0x2d0a, 0x2001,
 	0x0260, 0x2098, 0x0c68, 0x2950, 0x080c, 0x1004, 0x0170, 0x2900,
 	0xb002, 0xa867, 0x0147, 0xa86b, 0x0000, 0xa860, 0x20e8, 0xa85c,
 	0x9080, 0x001b, 0x20a0, 0x8840, 0x08d8, 0x2548, 0xa800, 0x902d,
-	0x0118, 0x080c, 0x101d, 0x0cc8, 0x080c, 0x101d, 0x0804, 0xcc1f,
+	0x0118, 0x080c, 0x101d, 0x0cc8, 0x080c, 0x101d, 0x0804, 0xcc2f,
 	0x2548, 0x8847, 0x9885, 0x0046, 0xa866, 0x2009, 0x0205, 0x200b,
-	0x0000, 0x080c, 0xd4f6, 0x0804, 0xcc13, 0x8010, 0x0004, 0x801a,
+	0x0000, 0x080c, 0xd50f, 0x0804, 0xcc23, 0x8010, 0x0004, 0x801a,
 	0x0006, 0x8018, 0x0008, 0x8016, 0x000a, 0x8014, 0x9186, 0x0013,
 	0x1160, 0x6004, 0x908a, 0x0054, 0x1a0c, 0x0db4, 0x9082, 0x0040,
-	0x0a0c, 0x0db4, 0x2008, 0x0804, 0xcdae, 0x9186, 0x0051, 0x0108,
-	0x00c0, 0x2001, 0x0109, 0x2004, 0xd084, 0x0904, 0xcd5f, 0x0126,
-	0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x82c6, 0x002e,
+	0x0a0c, 0x0db4, 0x2008, 0x0804, 0xcdbf, 0x9186, 0x0051, 0x0108,
+	0x00c0, 0x2001, 0x0109, 0x2004, 0xd084, 0x0904, 0xcd6f, 0x0126,
+	0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x82e4, 0x002e,
 	0x001e, 0x000e, 0x012e, 0x6000, 0x9086, 0x0002, 0x1580, 0x0804,
-	0xcdf6, 0x9186, 0x0027, 0x0530, 0x9186, 0x0048, 0x0128, 0x9186,
+	0xce08, 0x9186, 0x0027, 0x0530, 0x9186, 0x0048, 0x0128, 0x9186,
 	0x0014, 0x0500, 0x190c, 0x0db4, 0x2001, 0x0109, 0x2004, 0xd084,
 	0x01f0, 0x00c6, 0x0126, 0x2091, 0x2800, 0x00c6, 0x2061, 0x0100,
-	0x0006, 0x0016, 0x0026, 0x080c, 0x82c6, 0x002e, 0x001e, 0x000e,
+	0x0006, 0x0016, 0x0026, 0x080c, 0x82e4, 0x002e, 0x001e, 0x000e,
 	0x00ce, 0x012e, 0x00ce, 0x6000, 0x9086, 0x0004, 0x190c, 0x0db4,
-	0x0804, 0xced7, 0x6004, 0x9082, 0x0040, 0x2008, 0x001a, 0x080c,
-	0x9ed7, 0x0005, 0xcd75, 0xcd77, 0xcd77, 0xcd9e, 0xcd75, 0xcd75,
-	0xcd75, 0xcd75, 0xcd75, 0xcd75, 0xcd75, 0xcd75, 0xcd75, 0xcd75,
-	0xcd75, 0xcd75, 0xcd75, 0xcd75, 0xcd75, 0x080c, 0x0db4, 0x080c,
-	0x8861, 0x080c, 0x896d, 0x0036, 0x0096, 0x6014, 0x904d, 0x01d8,
-	0x080c, 0xbb2c, 0x01c0, 0x6003, 0x0002, 0x6010, 0x00b6, 0x2058,
-	0xb800, 0x00be, 0xd0bc, 0x1178, 0x2019, 0x0004, 0x080c, 0xd4f6,
-	0x6017, 0x0000, 0x6018, 0x9005, 0x1120, 0x2001, 0x1957, 0x2004,
-	0x601a, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x0096, 0x080c,
-	0x8861, 0x080c, 0x896d, 0x080c, 0xbb2c, 0x0120, 0x6014, 0x2048,
-	0x080c, 0x101d, 0x080c, 0x9e72, 0x009e, 0x0005, 0x0002, 0xcdc2,
-	0xcdd9, 0xcdc4, 0xcdf0, 0xcdc2, 0xcdc2, 0xcdc2, 0xcdc2, 0xcdc2,
-	0xcdc2, 0xcdc2, 0xcdc2, 0xcdc2, 0xcdc2, 0xcdc2, 0xcdc2, 0xcdc2,
-	0xcdc2, 0xcdc2, 0x080c, 0x0db4, 0x0096, 0x080c, 0x8861, 0x6014,
-	0x2048, 0xa87c, 0xd0b4, 0x0138, 0x6003, 0x0007, 0x2009, 0x0043,
-	0x080c, 0x9ebc, 0x0010, 0x6003, 0x0004, 0x080c, 0x896d, 0x009e,
-	0x0005, 0x080c, 0x8861, 0x080c, 0xbb2c, 0x0138, 0x6114, 0x0096,
-	0x2148, 0xa97c, 0x009e, 0xd1ec, 0x1138, 0x080c, 0x81ed, 0x080c,
-	0x9e42, 0x080c, 0x896d, 0x0005, 0x080c, 0xd750, 0x0db0, 0x0cc8,
-	0x080c, 0x8861, 0x2009, 0x0041, 0x0804, 0xcf5f, 0x9182, 0x0040,
-	0x0002, 0xce0c, 0xce0e, 0xce0c, 0xce0c, 0xce0c, 0xce0c, 0xce0c,
-	0xce0c, 0xce0c, 0xce0c, 0xce0c, 0xce0c, 0xce0c, 0xce0c, 0xce0c,
-	0xce0c, 0xce0c, 0xce0f, 0xce0c, 0x080c, 0x0db4, 0x0005, 0x00d6,
-	0x080c, 0x81ed, 0x00de, 0x080c, 0xd7a8, 0x080c, 0x9e42, 0x0005,
-	0x9182, 0x0040, 0x0002, 0xce2e, 0xce2e, 0xce2e, 0xce2e, 0xce2e,
-	0xce2e, 0xce2e, 0xce2e, 0xce2e, 0xce30, 0xce9f, 0xce2e, 0xce2e,
-	0xce2e, 0xce2e, 0xce9f, 0xce2e, 0xce2e, 0xce2e, 0x080c, 0x0db4,
-	0x2001, 0x0105, 0x2004, 0x9084, 0x1800, 0x01c8, 0x2001, 0x0132,
-	0x200c, 0x2001, 0x0131, 0x2004, 0x9105, 0x1904, 0xce9f, 0x2009,
-	0x180c, 0x2104, 0xd0d4, 0x0904, 0xce9f, 0xc0d4, 0x200a, 0x2009,
-	0x0105, 0x2104, 0x9084, 0xe7fd, 0x9085, 0x0010, 0x200a, 0x2001,
-	0x1873, 0x2004, 0xd0e4, 0x1528, 0x603b, 0x0000, 0x080c, 0x891d,
-	0x6014, 0x0096, 0x2048, 0xa87c, 0xd0fc, 0x0188, 0x908c, 0x0003,
-	0x918e, 0x0002, 0x0508, 0x2001, 0x180c, 0x2004, 0xd0d4, 0x11e0,
-	0x080c, 0x8a4a, 0x2009, 0x0041, 0x009e, 0x0804, 0xcf5f, 0x080c,
-	0x8a4a, 0x6003, 0x0007, 0x601b, 0x0000, 0x080c, 0x81ed, 0x009e,
-	0x0005, 0x2001, 0x0100, 0x2004, 0x9082, 0x0005, 0x0aa8, 0x2001,
-	0x011f, 0x2004, 0x603a, 0x0890, 0x2001, 0x180c, 0x200c, 0xc1d4,
-	0x2102, 0xd1cc, 0x0110, 0x080c, 0x2a79, 0x080c, 0x8a4a, 0x6014,
-	0x2048, 0xa97c, 0xd1ec, 0x1130, 0x080c, 0x81ed, 0x080c, 0x9e42,
-	0x009e, 0x0005, 0x080c, 0xd750, 0x0db8, 0x009e, 0x0005, 0x2001,
-	0x180c, 0x200c, 0xc1d4, 0x2102, 0x0036, 0x080c, 0x891d, 0x080c,
-	0x8a4a, 0x6014, 0x0096, 0x2048, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x0188, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002,
-	0x0140, 0xa8ac, 0x6330, 0x931a, 0x6332, 0xa8b0, 0x632c, 0x931b,
-	0x632e, 0x6003, 0x0002, 0x0080, 0x2019, 0x0004, 0x080c, 0xd4f6,
-	0x6018, 0x9005, 0x1128, 0x2001, 0x1957, 0x2004, 0x8003, 0x601a,
-	0x6017, 0x0000, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x9182,
-	0x0040, 0x0002, 0xceee, 0xceee, 0xceee, 0xceee, 0xceee, 0xceee,
-	0xceee, 0xceee, 0xcef0, 0xceee, 0xceee, 0xceee, 0xceee, 0xceee,
-	0xceee, 0xceee, 0xceee, 0xceee, 0xceee, 0xcf3b, 0x080c, 0x0db4,
-	0x6014, 0x0096, 0x2048, 0xa834, 0xaa38, 0x6110, 0x00b6, 0x2158,
-	0xb900, 0x00be, 0xd1bc, 0x1190, 0x920d, 0x1518, 0xa87c, 0xd0fc,
-	0x0128, 0x2009, 0x0041, 0x009e, 0x0804, 0xcf5f, 0x6003, 0x0007,
-	0x601b, 0x0000, 0x080c, 0x81ed, 0x009e, 0x0005, 0x6124, 0xd1f4,
-	0x1d58, 0x0006, 0x0046, 0xacac, 0x9422, 0xa9b0, 0x2200, 0x910b,
-	0x6030, 0x9420, 0x6432, 0x602c, 0x9109, 0x612e, 0x004e, 0x000e,
-	0x08d8, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1bc, 0x1178,
-	0x2009, 0x180e, 0x210c, 0xd19c, 0x0118, 0x6003, 0x0007, 0x0010,
-	0x6003, 0x0006, 0x00e9, 0x080c, 0x81ef, 0x009e, 0x0005, 0x6003,
-	0x0002, 0x009e, 0x0005, 0x6024, 0xd0f4, 0x0128, 0x080c, 0x1511,
-	0x1904, 0xcef0, 0x0005, 0x6014, 0x0096, 0x2048, 0xa834, 0xa938,
-	0x009e, 0x9105, 0x1120, 0x080c, 0x1511, 0x1904, 0xcef0, 0x0005,
-	0xd2fc, 0x0140, 0x8002, 0x8000, 0x8212, 0x9291, 0x0000, 0x2009,
-	0x0009, 0x0010, 0x2009, 0x0015, 0xaa9a, 0xa896, 0x0005, 0x9182,
-	0x0040, 0x0208, 0x0062, 0x9186, 0x0013, 0x0120, 0x9186, 0x0014,
-	0x190c, 0x0db4, 0x6024, 0xd0dc, 0x090c, 0x0db4, 0x0005, 0xcf82,
-	0xcf8e, 0xcf9a, 0xcfa6, 0xcf82, 0xcf82, 0xcf82, 0xcf82, 0xcf89,
-	0xcf84, 0xcf84, 0xcf82, 0xcf82, 0xcf82, 0xcf82, 0xcf84, 0xcf82,
-	0xcf84, 0xcf82, 0x080c, 0x0db4, 0x6024, 0xd0dc, 0x090c, 0x0db4,
-	0x0005, 0x6014, 0x9005, 0x190c, 0x0db4, 0x0005, 0x6003, 0x0001,
-	0x6106, 0x080c, 0x83da, 0x0126, 0x2091, 0x8000, 0x080c, 0x896d,
-	0x012e, 0x0005, 0x6003, 0x0001, 0x6106, 0x080c, 0x83da, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x896d, 0x012e, 0x0005, 0x6003, 0x0003,
-	0x6106, 0x2c10, 0x080c, 0x1a5e, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x843f, 0x080c, 0x8a4a, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000,
-	0x0036, 0x0096, 0x9182, 0x0040, 0x0023, 0x009e, 0x003e, 0x012e,
-	0x0005, 0xcfd1, 0xcfd3, 0xcfe5, 0xcfff, 0xcfd1, 0xcfd1, 0xcfd1,
-	0xcfd1, 0xcfd1, 0xcfd1, 0xcfd1, 0xcfd1, 0xcfd1, 0xcfd1, 0xcfd1,
-	0xcfd1, 0x080c, 0x0db4, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x01f8,
-	0x909c, 0x0003, 0x939e, 0x0003, 0x01d0, 0x6003, 0x0001, 0x6106,
-	0x080c, 0x83da, 0x080c, 0x896d, 0x0470, 0x6014, 0x2048, 0xa87c,
-	0xd0fc, 0x0168, 0x909c, 0x0003, 0x939e, 0x0003, 0x0140, 0x6003,
-	0x0001, 0x6106, 0x080c, 0x83da, 0x080c, 0x896d, 0x00e0, 0x901e,
-	0x6316, 0x631a, 0x2019, 0x0004, 0x080c, 0xd4f6, 0x00a0, 0x6014,
-	0x2048, 0xa87c, 0xd0fc, 0x0d98, 0x909c, 0x0003, 0x939e, 0x0003,
-	0x0d70, 0x6003, 0x0003, 0x6106, 0x2c10, 0x080c, 0x1a5e, 0x080c,
-	0x843f, 0x080c, 0x8a4a, 0x0005, 0x080c, 0x8861, 0x6114, 0x81ff,
-	0x0158, 0x0096, 0x2148, 0x080c, 0xd7f4, 0x0036, 0x2019, 0x0029,
-	0x080c, 0xd4f6, 0x003e, 0x009e, 0x080c, 0x9e72, 0x080c, 0x896d,
-	0x0005, 0x080c, 0x891d, 0x6114, 0x81ff, 0x0158, 0x0096, 0x2148,
-	0x080c, 0xd7f4, 0x0036, 0x2019, 0x0029, 0x080c, 0xd4f6, 0x003e,
-	0x009e, 0x080c, 0x9e72, 0x080c, 0x8a4a, 0x0005, 0x9182, 0x0085,
-	0x0002, 0xd050, 0xd04e, 0xd04e, 0xd05c, 0xd04e, 0xd04e, 0xd04e,
-	0xd04e, 0xd04e, 0xd04e, 0xd04e, 0xd04e, 0xd04e, 0x080c, 0x0db4,
-	0x6003, 0x000b, 0x6106, 0x080c, 0x83da, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x896d, 0x012e, 0x0005, 0x0026, 0x00e6, 0x080c, 0xd747,
-	0x0118, 0x080c, 0x9e42, 0x0450, 0x2071, 0x0260, 0x7224, 0x6216,
-	0x2001, 0x180e, 0x2004, 0xd0e4, 0x0150, 0x6010, 0x00b6, 0x2058,
-	0xbca0, 0x00be, 0x2c00, 0x2011, 0x014e, 0x080c, 0xa162, 0x7220,
-	0x080c, 0xd39c, 0x0118, 0x6007, 0x0086, 0x0040, 0x6007, 0x0087,
-	0x7224, 0x9296, 0xffff, 0x1110, 0x6007, 0x0086, 0x6003, 0x0001,
-	0x080c, 0x83da, 0x080c, 0x896d, 0x080c, 0x8a4a, 0x00ee, 0x002e,
-	0x0005, 0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085, 0x0a0c,
-	0x0db4, 0x908a, 0x0092, 0x1a0c, 0x0db4, 0x9082, 0x0085, 0x00a2,
-	0x9186, 0x0027, 0x0130, 0x9186, 0x0014, 0x0118, 0x080c, 0x9ed7,
-	0x0050, 0x2001, 0x0007, 0x080c, 0x61c4, 0x080c, 0x8861, 0x080c,
-	0x9e72, 0x080c, 0x896d, 0x0005, 0xd0c1, 0xd0c3, 0xd0c3, 0xd0c1,
-	0xd0c1, 0xd0c1, 0xd0c1, 0xd0c1, 0xd0c1, 0xd0c1, 0xd0c1, 0xd0c1,
-	0xd0c1, 0x080c, 0x0db4, 0x080c, 0x8861, 0x080c, 0x9e72, 0x080c,
-	0x896d, 0x0005, 0x9182, 0x0085, 0x0a0c, 0x0db4, 0x9182, 0x0092,
-	0x1a0c, 0x0db4, 0x9182, 0x0085, 0x0002, 0xd0e2, 0xd0e2, 0xd0e2,
-	0xd0e4, 0xd0e2, 0xd0e2, 0xd0e2, 0xd0e2, 0xd0e2, 0xd0e2, 0xd0e2,
-	0xd0e2, 0xd0e2, 0x080c, 0x0db4, 0x0005, 0x9186, 0x0013, 0x0148,
-	0x9186, 0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c, 0x9ed7,
-	0x0030, 0x080c, 0x8861, 0x080c, 0x9e72, 0x080c, 0x896d, 0x0005,
-	0x0036, 0x080c, 0xd7a8, 0x6043, 0x0000, 0x2019, 0x000b, 0x0031,
-	0x6023, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x0126, 0x0036,
-	0x2091, 0x8000, 0x0086, 0x2c40, 0x0096, 0x904e, 0x080c, 0x97bb,
-	0x009e, 0x008e, 0x1550, 0x0076, 0x2c38, 0x080c, 0x9866, 0x007e,
-	0x1520, 0x6000, 0x9086, 0x0000, 0x0500, 0x6020, 0x9086, 0x0007,
-	0x01e0, 0x0096, 0x601c, 0xd084, 0x0140, 0x080c, 0xd7a8, 0x080c,
-	0xc244, 0x080c, 0x190f, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c,
-	0xbb2c, 0x0110, 0x080c, 0xd4f6, 0x009e, 0x6017, 0x0000, 0x080c,
-	0xd7a8, 0x6023, 0x0007, 0x080c, 0xc244, 0x003e, 0x012e, 0x0005,
-	0x00f6, 0x00c6, 0x00b6, 0x0036, 0x0156, 0x2079, 0x0260, 0x7938,
-	0x783c, 0x080c, 0x2665, 0x15c8, 0x0016, 0x00c6, 0x080c, 0x6247,
-	0x1590, 0x001e, 0x00c6, 0x2160, 0x080c, 0xc241, 0x00ce, 0x002e,
-	0x0026, 0x0016, 0x2019, 0x0029, 0x080c, 0x992c, 0x080c, 0x8564,
-	0x0076, 0x903e, 0x080c, 0x8452, 0x007e, 0x001e, 0x0076, 0x903e,
-	0x080c, 0xd2bc, 0x007e, 0x0026, 0xba04, 0x9294, 0xff00, 0x8217,
-	0x9286, 0x0006, 0x0118, 0x9286, 0x0004, 0x1118, 0xbaa0, 0x080c,
-	0x3099, 0x002e, 0xbcb0, 0x001e, 0x080c, 0x5cf4, 0xbe12, 0xbd16,
-	0xbcb2, 0x9006, 0x0010, 0x00ce, 0x001e, 0x015e, 0x003e, 0x00be,
-	0x00ce, 0x00fe, 0x0005, 0x00c6, 0x00d6, 0x00b6, 0x0016, 0x2009,
-	0x1823, 0x2104, 0x9086, 0x0074, 0x1904, 0xd1e4, 0x2069, 0x0260,
-	0x6944, 0x9182, 0x0100, 0x06e0, 0x6940, 0x9184, 0x8000, 0x0904,
-	0xd1e1, 0x2001, 0x194c, 0x2004, 0x9005, 0x1140, 0x6010, 0x2058,
-	0xb8b0, 0x9005, 0x0118, 0x9184, 0x0800, 0x0598, 0x6948, 0x918a,
-	0x0001, 0x0648, 0x080c, 0xd85c, 0x0118, 0x6978, 0xd1fc, 0x11b8,
-	0x2009, 0x0205, 0x200b, 0x0001, 0x693c, 0x81ff, 0x1198, 0x6944,
-	0x9182, 0x0100, 0x02a8, 0x6940, 0x81ff, 0x1178, 0x6948, 0x918a,
-	0x0001, 0x0288, 0x6950, 0x918a, 0x0001, 0x0298, 0x00d0, 0x6017,
-	0x0100, 0x00a0, 0x6017, 0x0300, 0x0088, 0x6017, 0x0500, 0x0070,
-	0x6017, 0x0700, 0x0058, 0x6017, 0x0900, 0x0040, 0x6017, 0x0b00,
-	0x0028, 0x6017, 0x0f00, 0x0010, 0x6017, 0x2d00, 0x9085, 0x0001,
-	0x0008, 0x9006, 0x001e, 0x00be, 0x00de, 0x00ce, 0x0005, 0x00c6,
-	0x00b6, 0x0026, 0x0036, 0x0156, 0x6210, 0x2258, 0xbb04, 0x9394,
-	0x00ff, 0x9286, 0x0006, 0x0180, 0x9286, 0x0004, 0x0168, 0x9394,
-	0xff00, 0x8217, 0x9286, 0x0006, 0x0138, 0x9286, 0x0004, 0x0120,
-	0x080c, 0x6256, 0x0804, 0xd24b, 0x2011, 0x0276, 0x20a9, 0x0004,
-	0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xae20, 0x009e, 0x15a0,
-	0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x0006,
-	0x080c, 0xae20, 0x009e, 0x1540, 0x0046, 0x0016, 0xbaa0, 0x2220,
-	0x9006, 0x2009, 0x1854, 0x210c, 0x0038, 0x2009, 0x0029, 0x080c,
-	0xd54b, 0xb800, 0xc0e5, 0xb802, 0x2019, 0x0029, 0x080c, 0x8564,
-	0x0076, 0x2039, 0x0000, 0x080c, 0x8452, 0x2c08, 0x080c, 0xd2bc,
-	0x007e, 0x2001, 0x0007, 0x080c, 0x61c4, 0x2001, 0x0007, 0x080c,
-	0x6198, 0x001e, 0x004e, 0x9006, 0x015e, 0x003e, 0x002e, 0x00be,
-	0x00ce, 0x0005, 0x00d6, 0x2069, 0x026e, 0x6800, 0x9086, 0x0800,
-	0x0118, 0x6017, 0x0000, 0x0008, 0x9006, 0x00de, 0x0005, 0x00b6,
-	0x00f6, 0x0016, 0x0026, 0x0036, 0x0156, 0x2079, 0x026c, 0x7930,
-	0x7834, 0x080c, 0x2665, 0x11d0, 0x080c, 0x6247, 0x11b8, 0x2011,
-	0x0270, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c,
-	0xae20, 0x009e, 0x1158, 0x2011, 0x0274, 0x20a9, 0x0004, 0x0096,
-	0x2b48, 0x2019, 0x0006, 0x080c, 0xae20, 0x009e, 0x015e, 0x003e,
-	0x002e, 0x001e, 0x00fe, 0x00be, 0x0005, 0x00b6, 0x0006, 0x0016,
-	0x0026, 0x0036, 0x0156, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c,
-	0x080c, 0x2665, 0x11d0, 0x080c, 0x6247, 0x11b8, 0x2011, 0x0276,
-	0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xae20,
-	0x009e, 0x1158, 0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48,
-	0x2019, 0x0006, 0x080c, 0xae20, 0x009e, 0x015e, 0x003e, 0x002e,
-	0x001e, 0x000e, 0x00be, 0x0005, 0x00e6, 0x00c6, 0x0086, 0x0076,
-	0x0066, 0x0056, 0x0046, 0x0026, 0x0126, 0x2091, 0x8000, 0x2740,
-	0x2029, 0x19c0, 0x252c, 0x2021, 0x19c6, 0x2424, 0x2061, 0x1cd0,
-	0x2071, 0x1800, 0x7650, 0x7070, 0x81ff, 0x0150, 0x0006, 0x9186,
-	0x1a7f, 0x000e, 0x0128, 0x8001, 0x9602, 0x1a04, 0xd355, 0x0018,
-	0x9606, 0x0904, 0xd355, 0x2100, 0x9c06, 0x0904, 0xd34c, 0x080c,
-	0xd58c, 0x1904, 0xd34c, 0x080c, 0xd879, 0x0904, 0xd34c, 0x080c,
-	0xd57c, 0x0904, 0xd34c, 0x6720, 0x9786, 0x0001, 0x1148, 0x080c,
-	0x3130, 0x0904, 0xd370, 0x6004, 0x9086, 0x0000, 0x1904, 0xd370,
-	0x9786, 0x0004, 0x0904, 0xd370, 0x9786, 0x0007, 0x0904, 0xd34c,
-	0x2500, 0x9c06, 0x0904, 0xd34c, 0x2400, 0x9c06, 0x05e8, 0x88ff,
-	0x0118, 0x6054, 0x9906, 0x15c0, 0x0096, 0x6000, 0x9086, 0x0004,
-	0x1120, 0x0016, 0x080c, 0x190f, 0x001e, 0x9786, 0x000a, 0x0148,
-	0x080c, 0xbd32, 0x1130, 0x080c, 0xa7d1, 0x009e, 0x080c, 0x9e72,
-	0x0418, 0x6014, 0x2048, 0x080c, 0xbb2c, 0x01d8, 0x9786, 0x0003,
-	0x1570, 0xa867, 0x0103, 0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878,
-	0x2048, 0x080c, 0x0f9d, 0x009e, 0xab7a, 0xa877, 0x0000, 0x080c,
-	0xd7f4, 0x0016, 0x080c, 0xbe20, 0x080c, 0x6884, 0x001e, 0x080c,
-	0xbd15, 0x009e, 0x080c, 0x9e72, 0x9ce0, 0x0018, 0x2001, 0x1819,
-	0x2004, 0x9c02, 0x1210, 0x0804, 0xd2d0, 0x012e, 0x002e, 0x004e,
-	0x005e, 0x006e, 0x007e, 0x008e, 0x00ce, 0x00ee, 0x0005, 0x9786,
-	0x0006, 0x1150, 0x9386, 0x0005, 0x0128, 0x080c, 0xd7f4, 0x080c,
-	0xd4f6, 0x08f8, 0x009e, 0x0c00, 0x9786, 0x000a, 0x0920, 0x0808,
-	0x81ff, 0x09d0, 0x9180, 0x0001, 0x2004, 0x9086, 0x0018, 0x0130,
-	0x9180, 0x0001, 0x2004, 0x9086, 0x002d, 0x1970, 0x6000, 0x9086,
-	0x0002, 0x1950, 0x080c, 0xbd21, 0x0130, 0x080c, 0xbd32, 0x1920,
-	0x080c, 0xa7d1, 0x0038, 0x080c, 0x3005, 0x080c, 0xbd32, 0x1110,
-	0x080c, 0xa7d1, 0x080c, 0x9e72, 0x0804, 0xd34c, 0xa864, 0x9084,
-	0x00ff, 0x9086, 0x0039, 0x0005, 0x00c6, 0x00e6, 0x0016, 0x2c08,
-	0x2170, 0x9006, 0x080c, 0xd51d, 0x001e, 0x0120, 0x6020, 0x9084,
-	0x000f, 0x001b, 0x00ee, 0x00ce, 0x0005, 0xd3bb, 0xd3bb, 0xd3bb,
-	0xd3bb, 0xd3bb, 0xd3bb, 0xd3bd, 0xd3bb, 0xd3bb, 0xd3bb, 0xd3bb,
-	0x9e72, 0x9e72, 0xd3bb, 0x9006, 0x0005, 0x0036, 0x0046, 0x0016,
-	0x7010, 0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x2009, 0x0020,
-	0x080c, 0xd54b, 0x001e, 0x004e, 0x2019, 0x0002, 0x080c, 0xd106,
-	0x003e, 0x9085, 0x0001, 0x0005, 0x0096, 0x080c, 0xbb2c, 0x0140,
-	0x6014, 0x904d, 0x080c, 0xb75d, 0x687b, 0x0005, 0x080c, 0x6891,
-	0x009e, 0x080c, 0x9e72, 0x9085, 0x0001, 0x0005, 0x2001, 0x0001,
-	0x080c, 0x6184, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004,
-	0x2019, 0x1805, 0x2011, 0x0276, 0x080c, 0xae0c, 0x003e, 0x002e,
-	0x001e, 0x015e, 0x9005, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0086,
-	0x0076, 0x0066, 0x00b6, 0x0126, 0x2091, 0x8000, 0x2740, 0x2061,
-	0x1cd0, 0x2079, 0x0001, 0x8fff, 0x0904, 0xd456, 0x2071, 0x1800,
-	0x7650, 0x7070, 0x8001, 0x9602, 0x1a04, 0xd456, 0x88ff, 0x0120,
-	0x2800, 0x9c06, 0x1590, 0x2078, 0x080c, 0xd57c, 0x0570, 0x2400,
-	0x9c06, 0x0558, 0x6720, 0x9786, 0x0006, 0x1538, 0x9786, 0x0007,
-	0x0520, 0x88ff, 0x1140, 0x6010, 0x9b06, 0x11f8, 0x85ff, 0x0118,
-	0x6054, 0x9106, 0x11d0, 0x0096, 0x601c, 0xd084, 0x0140, 0x080c,
-	0xd7a8, 0x080c, 0xc244, 0x080c, 0x190f, 0x6023, 0x0007, 0x6014,
-	0x2048, 0x080c, 0xbb2c, 0x0120, 0x0046, 0x080c, 0xd4f6, 0x004e,
-	0x009e, 0x080c, 0x9e72, 0x88ff, 0x1198, 0x9ce0, 0x0018, 0x2001,
-	0x1819, 0x2004, 0x9c02, 0x1210, 0x0804, 0xd40b, 0x9006, 0x012e,
-	0x00be, 0x006e, 0x007e, 0x008e, 0x00ce, 0x00ee, 0x00fe, 0x0005,
-	0x98c5, 0x0001, 0x0ca0, 0x00b6, 0x0076, 0x0056, 0x0086, 0x9046,
-	0x2029, 0x0001, 0x2c20, 0x2019, 0x0002, 0x6210, 0x2258, 0x0096,
-	0x904e, 0x080c, 0x97bb, 0x009e, 0x008e, 0x903e, 0x080c, 0x9866,
-	0x080c, 0xd3fc, 0x005e, 0x007e, 0x00be, 0x0005, 0x00b6, 0x0046,
-	0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20, 0x2128, 0x20a9, 0x007f,
-	0x900e, 0x0016, 0x0036, 0x080c, 0x6247, 0x1190, 0x0056, 0x0086,
-	0x9046, 0x2508, 0x2029, 0x0001, 0x0096, 0x904e, 0x080c, 0x97bb,
-	0x009e, 0x008e, 0x903e, 0x080c, 0x9866, 0x080c, 0xd3fc, 0x005e,
-	0x003e, 0x001e, 0x8108, 0x1f04, 0xd489, 0x015e, 0x00ce, 0x007e,
-	0x005e, 0x004e, 0x00be, 0x0005, 0x00b6, 0x0076, 0x0056, 0x6210,
-	0x2258, 0x0086, 0x9046, 0x2029, 0x0001, 0x2019, 0x0048, 0x0096,
-	0x904e, 0x080c, 0x97bb, 0x009e, 0x008e, 0x903e, 0x080c, 0x9866,
-	0x2c20, 0x080c, 0xd3fc, 0x005e, 0x007e, 0x00be, 0x0005, 0x00b6,
-	0x0046, 0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20, 0x20a9, 0x0800,
-	0x900e, 0x0016, 0x0036, 0x080c, 0x6247, 0x11a0, 0x0086, 0x9046,
-	0x2828, 0x0046, 0x2021, 0x0001, 0x080c, 0xd78c, 0x004e, 0x0096,
-	0x904e, 0x080c, 0x97bb, 0x009e, 0x008e, 0x903e, 0x080c, 0x9866,
-	0x080c, 0xd3fc, 0x003e, 0x001e, 0x8108, 0x1f04, 0xd4d1, 0x015e,
-	0x00ce, 0x007e, 0x005e, 0x004e, 0x00be, 0x0005, 0x0016, 0x00f6,
-	0x080c, 0xbb2a, 0x0198, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0046,
-	0x0180, 0xa800, 0x907d, 0x0138, 0xa803, 0x0000, 0xab82, 0x080c,
-	0x6891, 0x2f48, 0x0cb0, 0xab82, 0x080c, 0x6891, 0x00fe, 0x001e,
-	0x0005, 0xa800, 0x907d, 0x0130, 0xa803, 0x0000, 0x080c, 0x6891,
-	0x2f48, 0x0cb8, 0x080c, 0x6891, 0x0c88, 0x00e6, 0x0046, 0x0036,
-	0x2061, 0x1cd0, 0x9005, 0x1138, 0x2071, 0x1800, 0x7450, 0x7070,
-	0x8001, 0x9402, 0x12d8, 0x2100, 0x9c06, 0x0168, 0x6000, 0x9086,
-	0x0000, 0x0148, 0x6008, 0x9206, 0x1130, 0x6010, 0x91a0, 0x0004,
-	0x2424, 0x9406, 0x0140, 0x9ce0, 0x0018, 0x2001, 0x1819, 0x2004,
-	0x9c02, 0x1220, 0x0c40, 0x9085, 0x0001, 0x0008, 0x9006, 0x003e,
-	0x004e, 0x00ee, 0x0005, 0x0096, 0x0006, 0x080c, 0x0feb, 0x000e,
-	0x090c, 0x0db4, 0xaae2, 0xa867, 0x010d, 0xa88e, 0x0026, 0x2010,
-	0x080c, 0xbb1a, 0x2001, 0x0000, 0x0120, 0x2200, 0x9080, 0x0015,
-	0x2004, 0x002e, 0xa87a, 0x9186, 0x0020, 0x0110, 0xa8e3, 0xffff,
-	0xa986, 0xac76, 0xa87f, 0x0000, 0x2001, 0x195e, 0x2004, 0xa882,
-	0x9006, 0xa802, 0xa86a, 0xa88a, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x6891, 0x012e, 0x009e, 0x0005, 0x6700, 0x9786, 0x0000, 0x0158,
-	0x9786, 0x0001, 0x0140, 0x9786, 0x000a, 0x0128, 0x9786, 0x0009,
-	0x0110, 0x9085, 0x0001, 0x0005, 0x00e6, 0x6010, 0x9075, 0x0138,
-	0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x00ee, 0x0005, 0x9085,
-	0x0001, 0x0cd8, 0x0016, 0x6004, 0x908e, 0x001e, 0x11a0, 0x8007,
-	0x6134, 0x918c, 0x00ff, 0x9105, 0x6036, 0x6007, 0x0085, 0x6003,
-	0x000b, 0x6023, 0x0005, 0x2001, 0x1957, 0x2004, 0x601a, 0x080c,
-	0x83da, 0x080c, 0x896d, 0x001e, 0x0005, 0xa001, 0xa001, 0x0005,
-	0x6024, 0xd0e4, 0x0158, 0xd0cc, 0x0118, 0x080c, 0xbe64, 0x0030,
-	0x080c, 0xd7a8, 0x080c, 0x81ed, 0x080c, 0x9e42, 0x0005, 0x9280,
-	0x0008, 0x2004, 0x9084, 0x000f, 0x0002, 0xd5db, 0xd5db, 0xd5db,
-	0xd5dd, 0xd5db, 0xd5dd, 0xd5dd, 0xd5db, 0xd5dd, 0xd5db, 0xd5db,
-	0xd5db, 0xd5db, 0xd5db, 0x9006, 0x0005, 0x9085, 0x0001, 0x0005,
+	0x0804, 0xceeb, 0x6004, 0x9082, 0x0040, 0x2008, 0x001a, 0x080c,
+	0x9ec4, 0x0005, 0xcd86, 0xcd88, 0xcd88, 0xcdaf, 0xcd86, 0xcd86,
+	0xcd86, 0xcd86, 0xcd86, 0xcd86, 0xcd86, 0xcd86, 0xcd86, 0xcd86,
+	0xcd86, 0xcd86, 0xcd86, 0xcd86, 0xcd86, 0xcd86, 0x080c, 0x0db4,
+	0x080c, 0x887f, 0x080c, 0x898b, 0x0036, 0x0096, 0x6014, 0x904d,
+	0x01d8, 0x080c, 0xbb3b, 0x01c0, 0x6003, 0x0002, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x1178, 0x2019, 0x0004, 0x080c,
+	0xd50f, 0x6017, 0x0000, 0x6018, 0x9005, 0x1120, 0x2001, 0x195f,
+	0x2004, 0x601a, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x0096,
+	0x080c, 0x887f, 0x080c, 0x898b, 0x080c, 0xbb3b, 0x0120, 0x6014,
+	0x2048, 0x080c, 0x101d, 0x080c, 0x9e5f, 0x009e, 0x0005, 0x0002,
+	0xcdd4, 0xcdeb, 0xcdd6, 0xce02, 0xcdd4, 0xcdd4, 0xcdd4, 0xcdd4,
+	0xcdd4, 0xcdd4, 0xcdd4, 0xcdd4, 0xcdd4, 0xcdd4, 0xcdd4, 0xcdd4,
+	0xcdd4, 0xcdd4, 0xcdd4, 0xcdd4, 0x080c, 0x0db4, 0x0096, 0x080c,
+	0x887f, 0x6014, 0x2048, 0xa87c, 0xd0b4, 0x0138, 0x6003, 0x0007,
+	0x2009, 0x0043, 0x080c, 0x9ea9, 0x0010, 0x6003, 0x0004, 0x080c,
+	0x898b, 0x009e, 0x0005, 0x080c, 0x887f, 0x080c, 0xbb3b, 0x0138,
+	0x6114, 0x0096, 0x2148, 0xa97c, 0x009e, 0xd1ec, 0x1138, 0x080c,
+	0x820b, 0x080c, 0x9e2f, 0x080c, 0x898b, 0x0005, 0x080c, 0xd769,
+	0x0db0, 0x0cc8, 0x080c, 0x887f, 0x2009, 0x0041, 0x0804, 0xcf73,
+	0x9182, 0x0040, 0x0002, 0xce1f, 0xce21, 0xce1f, 0xce1f, 0xce1f,
+	0xce1f, 0xce1f, 0xce1f, 0xce1f, 0xce1f, 0xce1f, 0xce1f, 0xce1f,
+	0xce1f, 0xce1f, 0xce1f, 0xce1f, 0xce22, 0xce1f, 0xce1f, 0x080c,
+	0x0db4, 0x0005, 0x00d6, 0x080c, 0x820b, 0x00de, 0x080c, 0xd7c1,
+	0x080c, 0x9e2f, 0x0005, 0x9182, 0x0040, 0x0002, 0xce42, 0xce42,
+	0xce42, 0xce42, 0xce42, 0xce42, 0xce42, 0xce42, 0xce42, 0xce44,
+	0xceb3, 0xce42, 0xce42, 0xce42, 0xce42, 0xceb3, 0xce42, 0xce42,
+	0xce42, 0xce42, 0x080c, 0x0db4, 0x2001, 0x0105, 0x2004, 0x9084,
+	0x1800, 0x01c8, 0x2001, 0x0132, 0x200c, 0x2001, 0x0131, 0x2004,
+	0x9105, 0x1904, 0xceb3, 0x2009, 0x180c, 0x2104, 0xd0d4, 0x0904,
+	0xceb3, 0xc0d4, 0x200a, 0x2009, 0x0105, 0x2104, 0x9084, 0xe7fd,
+	0x9085, 0x0010, 0x200a, 0x2001, 0x187b, 0x2004, 0xd0e4, 0x1528,
+	0x603b, 0x0000, 0x080c, 0x893b, 0x6014, 0x0096, 0x2048, 0xa87c,
+	0xd0fc, 0x0188, 0x908c, 0x0003, 0x918e, 0x0002, 0x0508, 0x2001,
+	0x180c, 0x2004, 0xd0d4, 0x11e0, 0x080c, 0x8a68, 0x2009, 0x0041,
+	0x009e, 0x0804, 0xcf73, 0x080c, 0x8a68, 0x6003, 0x0007, 0x601b,
+	0x0000, 0x080c, 0x820b, 0x009e, 0x0005, 0x2001, 0x0100, 0x2004,
+	0x9082, 0x0005, 0x0aa8, 0x2001, 0x011f, 0x2004, 0x603a, 0x0890,
+	0x2001, 0x180c, 0x200c, 0xc1d4, 0x2102, 0xd1cc, 0x0110, 0x080c,
+	0x2a84, 0x080c, 0x8a68, 0x6014, 0x2048, 0xa97c, 0xd1ec, 0x1130,
+	0x080c, 0x820b, 0x080c, 0x9e2f, 0x009e, 0x0005, 0x080c, 0xd769,
+	0x0db8, 0x009e, 0x0005, 0x2001, 0x180c, 0x200c, 0xc1d4, 0x2102,
+	0x0036, 0x080c, 0x893b, 0x080c, 0x8a68, 0x6014, 0x0096, 0x2048,
+	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0188, 0xa87c,
+	0x9084, 0x0003, 0x9086, 0x0002, 0x0140, 0xa8ac, 0x6330, 0x931a,
+	0x6332, 0xa8b0, 0x632c, 0x931b, 0x632e, 0x6003, 0x0002, 0x0080,
+	0x2019, 0x0004, 0x080c, 0xd50f, 0x6018, 0x9005, 0x1128, 0x2001,
+	0x195f, 0x2004, 0x8003, 0x601a, 0x6017, 0x0000, 0x6003, 0x0007,
+	0x009e, 0x003e, 0x0005, 0x9182, 0x0040, 0x0002, 0xcf02, 0xcf02,
+	0xcf02, 0xcf02, 0xcf02, 0xcf02, 0xcf02, 0xcf02, 0xcf04, 0xcf02,
+	0xcf02, 0xcf02, 0xcf02, 0xcf02, 0xcf02, 0xcf02, 0xcf02, 0xcf02,
+	0xcf02, 0xcf4f, 0x080c, 0x0db4, 0x6014, 0x0096, 0x2048, 0xa834,
+	0xaa38, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1bc, 0x1190,
+	0x920d, 0x1518, 0xa87c, 0xd0fc, 0x0128, 0x2009, 0x0041, 0x009e,
+	0x0804, 0xcf73, 0x6003, 0x0007, 0x601b, 0x0000, 0x080c, 0x820b,
+	0x009e, 0x0005, 0x6124, 0xd1f4, 0x1d58, 0x0006, 0x0046, 0xacac,
+	0x9422, 0xa9b0, 0x2200, 0x910b, 0x6030, 0x9420, 0x6432, 0x602c,
+	0x9109, 0x612e, 0x004e, 0x000e, 0x08d8, 0x6110, 0x00b6, 0x2158,
+	0xb900, 0x00be, 0xd1bc, 0x1178, 0x2009, 0x180e, 0x210c, 0xd19c,
+	0x0118, 0x6003, 0x0007, 0x0010, 0x6003, 0x0006, 0x00e9, 0x080c,
+	0x820d, 0x009e, 0x0005, 0x6003, 0x0002, 0x009e, 0x0005, 0x6024,
+	0xd0f4, 0x0128, 0x080c, 0x1511, 0x1904, 0xcf04, 0x0005, 0x6014,
+	0x0096, 0x2048, 0xa834, 0xa938, 0x009e, 0x9105, 0x1120, 0x080c,
+	0x1511, 0x1904, 0xcf04, 0x0005, 0xd2fc, 0x0140, 0x8002, 0x8000,
+	0x8212, 0x9291, 0x0000, 0x2009, 0x0009, 0x0010, 0x2009, 0x0015,
+	0xaa9a, 0xa896, 0x0005, 0x9182, 0x0040, 0x0208, 0x0062, 0x9186,
+	0x0013, 0x0120, 0x9186, 0x0014, 0x190c, 0x0db4, 0x6024, 0xd0dc,
+	0x090c, 0x0db4, 0x0005, 0xcf97, 0xcfa3, 0xcfaf, 0xcfbb, 0xcf97,
+	0xcf97, 0xcf97, 0xcf97, 0xcf9e, 0xcf99, 0xcf99, 0xcf97, 0xcf97,
+	0xcf97, 0xcf97, 0xcf99, 0xcf97, 0xcf99, 0xcf97, 0xcf9e, 0x080c,
+	0x0db4, 0x6024, 0xd0dc, 0x090c, 0x0db4, 0x0005, 0x6014, 0x9005,
+	0x190c, 0x0db4, 0x0005, 0x6003, 0x0001, 0x6106, 0x080c, 0x83f8,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x898b, 0x012e, 0x0005, 0x6003,
+	0x0001, 0x6106, 0x080c, 0x83f8, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x898b, 0x012e, 0x0005, 0x6003, 0x0003, 0x6106, 0x2c10, 0x080c,
+	0x1a69, 0x0126, 0x2091, 0x8000, 0x080c, 0x845d, 0x080c, 0x8a68,
+	0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0036, 0x0096, 0x9182,
+	0x0040, 0x0023, 0x009e, 0x003e, 0x012e, 0x0005, 0xcfea, 0xcfec,
+	0xcffe, 0xd018, 0xcfea, 0xcfea, 0xcfea, 0xcfea, 0xcfea, 0xcfea,
+	0xcfea, 0xcfea, 0xcfea, 0xcfea, 0xcfea, 0xcfea, 0xcfea, 0xcfea,
+	0xcfea, 0xcfea, 0x080c, 0x0db4, 0x6014, 0x2048, 0xa87c, 0xd0fc,
+	0x01f8, 0x909c, 0x0003, 0x939e, 0x0003, 0x01d0, 0x6003, 0x0001,
+	0x6106, 0x080c, 0x83f8, 0x080c, 0x898b, 0x0470, 0x6014, 0x2048,
+	0xa87c, 0xd0fc, 0x0168, 0x909c, 0x0003, 0x939e, 0x0003, 0x0140,
+	0x6003, 0x0001, 0x6106, 0x080c, 0x83f8, 0x080c, 0x898b, 0x00e0,
+	0x901e, 0x6316, 0x631a, 0x2019, 0x0004, 0x080c, 0xd50f, 0x00a0,
+	0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0d98, 0x909c, 0x0003, 0x939e,
+	0x0003, 0x0d70, 0x6003, 0x0003, 0x6106, 0x2c10, 0x080c, 0x1a69,
+	0x080c, 0x845d, 0x080c, 0x8a68, 0x0005, 0x080c, 0x887f, 0x6114,
+	0x81ff, 0x0158, 0x0096, 0x2148, 0x080c, 0xd80d, 0x0036, 0x2019,
+	0x0029, 0x080c, 0xd50f, 0x003e, 0x009e, 0x080c, 0x9e5f, 0x080c,
+	0x898b, 0x0005, 0x080c, 0x893b, 0x6114, 0x81ff, 0x0158, 0x0096,
+	0x2148, 0x080c, 0xd80d, 0x0036, 0x2019, 0x0029, 0x080c, 0xd50f,
+	0x003e, 0x009e, 0x080c, 0x9e5f, 0x080c, 0x8a68, 0x0005, 0x9182,
+	0x0085, 0x0002, 0xd069, 0xd067, 0xd067, 0xd075, 0xd067, 0xd067,
+	0xd067, 0xd067, 0xd067, 0xd067, 0xd067, 0xd067, 0xd067, 0x080c,
+	0x0db4, 0x6003, 0x000b, 0x6106, 0x080c, 0x83f8, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x898b, 0x012e, 0x0005, 0x0026, 0x00e6, 0x080c,
+	0xd760, 0x0118, 0x080c, 0x9e2f, 0x0450, 0x2071, 0x0260, 0x7224,
+	0x6216, 0x2001, 0x180e, 0x2004, 0xd0e4, 0x0150, 0x6010, 0x00b6,
+	0x2058, 0xbca0, 0x00be, 0x2c00, 0x2011, 0x014e, 0x080c, 0xa14f,
+	0x7220, 0x080c, 0xd3b5, 0x0118, 0x6007, 0x0086, 0x0040, 0x6007,
+	0x0087, 0x7224, 0x9296, 0xffff, 0x1110, 0x6007, 0x0086, 0x6003,
+	0x0001, 0x080c, 0x83f8, 0x080c, 0x898b, 0x080c, 0x8a68, 0x00ee,
+	0x002e, 0x0005, 0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085,
+	0x0a0c, 0x0db4, 0x908a, 0x0092, 0x1a0c, 0x0db4, 0x9082, 0x0085,
+	0x00a2, 0x9186, 0x0027, 0x0130, 0x9186, 0x0014, 0x0118, 0x080c,
+	0x9ec4, 0x0050, 0x2001, 0x0007, 0x080c, 0x61d3, 0x080c, 0x887f,
+	0x080c, 0x9e5f, 0x080c, 0x898b, 0x0005, 0xd0da, 0xd0dc, 0xd0dc,
+	0xd0da, 0xd0da, 0xd0da, 0xd0da, 0xd0da, 0xd0da, 0xd0da, 0xd0da,
+	0xd0da, 0xd0da, 0x080c, 0x0db4, 0x080c, 0x887f, 0x080c, 0x9e5f,
+	0x080c, 0x898b, 0x0005, 0x9182, 0x0085, 0x0a0c, 0x0db4, 0x9182,
+	0x0092, 0x1a0c, 0x0db4, 0x9182, 0x0085, 0x0002, 0xd0fb, 0xd0fb,
+	0xd0fb, 0xd0fd, 0xd0fb, 0xd0fb, 0xd0fb, 0xd0fb, 0xd0fb, 0xd0fb,
+	0xd0fb, 0xd0fb, 0xd0fb, 0x080c, 0x0db4, 0x0005, 0x9186, 0x0013,
+	0x0148, 0x9186, 0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c,
+	0x9ec4, 0x0030, 0x080c, 0x887f, 0x080c, 0x9e5f, 0x080c, 0x898b,
+	0x0005, 0x0036, 0x080c, 0xd7c1, 0x6043, 0x0000, 0x2019, 0x000b,
+	0x0031, 0x6023, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x0126,
+	0x0036, 0x2091, 0x8000, 0x0086, 0x2c40, 0x0096, 0x904e, 0x080c,
+	0x97a4, 0x009e, 0x008e, 0x1550, 0x0076, 0x2c38, 0x080c, 0x984f,
+	0x007e, 0x1520, 0x6000, 0x9086, 0x0000, 0x0500, 0x6020, 0x9086,
+	0x0007, 0x01e0, 0x0096, 0x601c, 0xd084, 0x0140, 0x080c, 0xd7c1,
+	0x080c, 0xc253, 0x080c, 0x191f, 0x6023, 0x0007, 0x6014, 0x2048,
+	0x080c, 0xbb3b, 0x0110, 0x080c, 0xd50f, 0x009e, 0x6017, 0x0000,
+	0x080c, 0xd7c1, 0x6023, 0x0007, 0x080c, 0xc253, 0x003e, 0x012e,
+	0x0005, 0x00f6, 0x00c6, 0x00b6, 0x0036, 0x0156, 0x2079, 0x0260,
+	0x7938, 0x783c, 0x080c, 0x2670, 0x15c8, 0x0016, 0x00c6, 0x080c,
+	0x6256, 0x1590, 0x001e, 0x00c6, 0x2160, 0x080c, 0xc250, 0x00ce,
+	0x002e, 0x0026, 0x0016, 0x2019, 0x0029, 0x080c, 0x9915, 0x080c,
+	0x8582, 0x0076, 0x903e, 0x080c, 0x8470, 0x007e, 0x001e, 0x0076,
+	0x903e, 0x080c, 0xd2d5, 0x007e, 0x0026, 0xba04, 0x9294, 0xff00,
+	0x8217, 0x9286, 0x0006, 0x0118, 0x9286, 0x0004, 0x1118, 0xbaa0,
+	0x080c, 0x30a4, 0x002e, 0xbcb0, 0x001e, 0x080c, 0x5cff, 0xbe12,
+	0xbd16, 0xbcb2, 0x9006, 0x0010, 0x00ce, 0x001e, 0x015e, 0x003e,
+	0x00be, 0x00ce, 0x00fe, 0x0005, 0x00c6, 0x00d6, 0x00b6, 0x0016,
+	0x2009, 0x1823, 0x2104, 0x9086, 0x0074, 0x1904, 0xd1fd, 0x2069,
+	0x0260, 0x6944, 0x9182, 0x0100, 0x06e0, 0x6940, 0x9184, 0x8000,
+	0x0904, 0xd1fa, 0x2001, 0x1954, 0x2004, 0x9005, 0x1140, 0x6010,
+	0x2058, 0xb8b0, 0x9005, 0x0118, 0x9184, 0x0800, 0x0598, 0x6948,
+	0x918a, 0x0001, 0x0648, 0x080c, 0xd875, 0x0118, 0x6978, 0xd1fc,
+	0x11b8, 0x2009, 0x0205, 0x200b, 0x0001, 0x693c, 0x81ff, 0x1198,
+	0x6944, 0x9182, 0x0100, 0x02a8, 0x6940, 0x81ff, 0x1178, 0x6948,
+	0x918a, 0x0001, 0x0288, 0x6950, 0x918a, 0x0001, 0x0298, 0x00d0,
+	0x6017, 0x0100, 0x00a0, 0x6017, 0x0300, 0x0088, 0x6017, 0x0500,
+	0x0070, 0x6017, 0x0700, 0x0058, 0x6017, 0x0900, 0x0040, 0x6017,
+	0x0b00, 0x0028, 0x6017, 0x0f00, 0x0010, 0x6017, 0x2d00, 0x9085,
+	0x0001, 0x0008, 0x9006, 0x001e, 0x00be, 0x00de, 0x00ce, 0x0005,
+	0x00c6, 0x00b6, 0x0026, 0x0036, 0x0156, 0x6210, 0x2258, 0xbb04,
+	0x9394, 0x00ff, 0x9286, 0x0006, 0x0180, 0x9286, 0x0004, 0x0168,
+	0x9394, 0xff00, 0x8217, 0x9286, 0x0006, 0x0138, 0x9286, 0x0004,
+	0x0120, 0x080c, 0x6265, 0x0804, 0xd264, 0x2011, 0x0276, 0x20a9,
+	0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xae1c, 0x009e,
+	0x15a0, 0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019,
+	0x0006, 0x080c, 0xae1c, 0x009e, 0x1540, 0x0046, 0x0016, 0xbaa0,
+	0x2220, 0x9006, 0x2009, 0x185c, 0x210c, 0x0038, 0x2009, 0x0029,
+	0x080c, 0xd564, 0xb800, 0xc0e5, 0xb802, 0x2019, 0x0029, 0x080c,
+	0x8582, 0x0076, 0x2039, 0x0000, 0x080c, 0x8470, 0x2c08, 0x080c,
+	0xd2d5, 0x007e, 0x2001, 0x0007, 0x080c, 0x61d3, 0x2001, 0x0007,
+	0x080c, 0x61a7, 0x001e, 0x004e, 0x9006, 0x015e, 0x003e, 0x002e,
+	0x00be, 0x00ce, 0x0005, 0x00d6, 0x2069, 0x026e, 0x6800, 0x9086,
+	0x0800, 0x0118, 0x6017, 0x0000, 0x0008, 0x9006, 0x00de, 0x0005,
+	0x00b6, 0x00f6, 0x0016, 0x0026, 0x0036, 0x0156, 0x2079, 0x026c,
+	0x7930, 0x7834, 0x080c, 0x2670, 0x11d0, 0x080c, 0x6256, 0x11b8,
+	0x2011, 0x0270, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a,
+	0x080c, 0xae1c, 0x009e, 0x1158, 0x2011, 0x0274, 0x20a9, 0x0004,
+	0x0096, 0x2b48, 0x2019, 0x0006, 0x080c, 0xae1c, 0x009e, 0x015e,
+	0x003e, 0x002e, 0x001e, 0x00fe, 0x00be, 0x0005, 0x00b6, 0x0006,
+	0x0016, 0x0026, 0x0036, 0x0156, 0x2011, 0x0263, 0x2204, 0x8211,
+	0x220c, 0x080c, 0x2670, 0x11d0, 0x080c, 0x6256, 0x11b8, 0x2011,
+	0x0276, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c,
+	0xae1c, 0x009e, 0x1158, 0x2011, 0x027a, 0x20a9, 0x0004, 0x0096,
+	0x2b48, 0x2019, 0x0006, 0x080c, 0xae1c, 0x009e, 0x015e, 0x003e,
+	0x002e, 0x001e, 0x000e, 0x00be, 0x0005, 0x00e6, 0x00c6, 0x0086,
+	0x0076, 0x0066, 0x0056, 0x0046, 0x0026, 0x0126, 0x2091, 0x8000,
+	0x2740, 0x2029, 0x19c8, 0x252c, 0x2021, 0x19ce, 0x2424, 0x2061,
+	0x1cd0, 0x2071, 0x1800, 0x7650, 0x7070, 0x81ff, 0x0150, 0x0006,
+	0x9186, 0x1a87, 0x000e, 0x0128, 0x8001, 0x9602, 0x1a04, 0xd36e,
+	0x0018, 0x9606, 0x0904, 0xd36e, 0x2100, 0x9c06, 0x0904, 0xd365,
+	0x080c, 0xd5a5, 0x1904, 0xd365, 0x080c, 0xd892, 0x0904, 0xd365,
+	0x080c, 0xd595, 0x0904, 0xd365, 0x6720, 0x9786, 0x0001, 0x1148,
+	0x080c, 0x313b, 0x0904, 0xd389, 0x6004, 0x9086, 0x0000, 0x1904,
+	0xd389, 0x9786, 0x0004, 0x0904, 0xd389, 0x9786, 0x0007, 0x0904,
+	0xd365, 0x2500, 0x9c06, 0x0904, 0xd365, 0x2400, 0x9c06, 0x05e8,
+	0x88ff, 0x0118, 0x6054, 0x9906, 0x15c0, 0x0096, 0x6000, 0x9086,
+	0x0004, 0x1120, 0x0016, 0x080c, 0x191f, 0x001e, 0x9786, 0x000a,
+	0x0148, 0x080c, 0xbd41, 0x1130, 0x080c, 0xa7cd, 0x009e, 0x080c,
+	0x9e5f, 0x0418, 0x6014, 0x2048, 0x080c, 0xbb3b, 0x01d8, 0x9786,
+	0x0003, 0x1570, 0xa867, 0x0103, 0xa87c, 0xd0cc, 0x0130, 0x0096,
+	0xa878, 0x2048, 0x080c, 0x0f9d, 0x009e, 0xab7a, 0xa877, 0x0000,
+	0x080c, 0xd80d, 0x0016, 0x080c, 0xbe2f, 0x080c, 0x6893, 0x001e,
+	0x080c, 0xbd24, 0x009e, 0x080c, 0x9e5f, 0x9ce0, 0x0018, 0x2001,
+	0x1819, 0x2004, 0x9c02, 0x1210, 0x0804, 0xd2e9, 0x012e, 0x002e,
+	0x004e, 0x005e, 0x006e, 0x007e, 0x008e, 0x00ce, 0x00ee, 0x0005,
+	0x9786, 0x0006, 0x1150, 0x9386, 0x0005, 0x0128, 0x080c, 0xd80d,
+	0x080c, 0xd50f, 0x08f8, 0x009e, 0x0c00, 0x9786, 0x000a, 0x0920,
+	0x0808, 0x81ff, 0x09d0, 0x9180, 0x0001, 0x2004, 0x9086, 0x0018,
+	0x0130, 0x9180, 0x0001, 0x2004, 0x9086, 0x002d, 0x1970, 0x6000,
+	0x9086, 0x0002, 0x1950, 0x080c, 0xbd30, 0x0130, 0x080c, 0xbd41,
+	0x1920, 0x080c, 0xa7cd, 0x0038, 0x080c, 0x3010, 0x080c, 0xbd41,
+	0x1110, 0x080c, 0xa7cd, 0x080c, 0x9e5f, 0x0804, 0xd365, 0xa864,
+	0x9084, 0x00ff, 0x9086, 0x0039, 0x0005, 0x00c6, 0x00e6, 0x0016,
+	0x2c08, 0x2170, 0x9006, 0x080c, 0xd536, 0x001e, 0x0120, 0x6020,
+	0x9084, 0x000f, 0x001b, 0x00ee, 0x00ce, 0x0005, 0xd3d4, 0xd3d4,
+	0xd3d4, 0xd3d4, 0xd3d4, 0xd3d4, 0xd3d6, 0xd3d4, 0xd3d4, 0xd3d4,
+	0xd3d4, 0x9e5f, 0x9e5f, 0xd3d4, 0x9006, 0x0005, 0x0036, 0x0046,
+	0x0016, 0x7010, 0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x2009,
+	0x0020, 0x080c, 0xd564, 0x001e, 0x004e, 0x2019, 0x0002, 0x080c,
+	0xd11f, 0x003e, 0x9085, 0x0001, 0x0005, 0x0096, 0x080c, 0xbb3b,
+	0x0140, 0x6014, 0x904d, 0x080c, 0xb75c, 0x687b, 0x0005, 0x080c,
+	0x68a0, 0x009e, 0x080c, 0x9e5f, 0x9085, 0x0001, 0x0005, 0x2001,
+	0x0001, 0x080c, 0x6193, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9,
+	0x0004, 0x2019, 0x1805, 0x2011, 0x0276, 0x080c, 0xae08, 0x003e,
+	0x002e, 0x001e, 0x015e, 0x9005, 0x0005, 0x00f6, 0x00e6, 0x00c6,
+	0x0086, 0x0076, 0x0066, 0x00b6, 0x0126, 0x2091, 0x8000, 0x2740,
+	0x2061, 0x1cd0, 0x2079, 0x0001, 0x8fff, 0x0904, 0xd46f, 0x2071,
+	0x1800, 0x7650, 0x7070, 0x8001, 0x9602, 0x1a04, 0xd46f, 0x88ff,
+	0x0120, 0x2800, 0x9c06, 0x1590, 0x2078, 0x080c, 0xd595, 0x0570,
+	0x2400, 0x9c06, 0x0558, 0x6720, 0x9786, 0x0006, 0x1538, 0x9786,
+	0x0007, 0x0520, 0x88ff, 0x1140, 0x6010, 0x9b06, 0x11f8, 0x85ff,
+	0x0118, 0x6054, 0x9106, 0x11d0, 0x0096, 0x601c, 0xd084, 0x0140,
+	0x080c, 0xd7c1, 0x080c, 0xc253, 0x080c, 0x191f, 0x6023, 0x0007,
+	0x6014, 0x2048, 0x080c, 0xbb3b, 0x0120, 0x0046, 0x080c, 0xd50f,
+	0x004e, 0x009e, 0x080c, 0x9e5f, 0x88ff, 0x1198, 0x9ce0, 0x0018,
+	0x2001, 0x1819, 0x2004, 0x9c02, 0x1210, 0x0804, 0xd424, 0x9006,
+	0x012e, 0x00be, 0x006e, 0x007e, 0x008e, 0x00ce, 0x00ee, 0x00fe,
+	0x0005, 0x98c5, 0x0001, 0x0ca0, 0x00b6, 0x0076, 0x0056, 0x0086,
+	0x9046, 0x2029, 0x0001, 0x2c20, 0x2019, 0x0002, 0x6210, 0x2258,
+	0x0096, 0x904e, 0x080c, 0x97a4, 0x009e, 0x008e, 0x903e, 0x080c,
+	0x984f, 0x080c, 0xd415, 0x005e, 0x007e, 0x00be, 0x0005, 0x00b6,
+	0x0046, 0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20, 0x2128, 0x20a9,
+	0x007f, 0x900e, 0x0016, 0x0036, 0x080c, 0x6256, 0x1190, 0x0056,
+	0x0086, 0x9046, 0x2508, 0x2029, 0x0001, 0x0096, 0x904e, 0x080c,
+	0x97a4, 0x009e, 0x008e, 0x903e, 0x080c, 0x984f, 0x080c, 0xd415,
+	0x005e, 0x003e, 0x001e, 0x8108, 0x1f04, 0xd4a2, 0x015e, 0x00ce,
+	0x007e, 0x005e, 0x004e, 0x00be, 0x0005, 0x00b6, 0x0076, 0x0056,
+	0x6210, 0x2258, 0x0086, 0x9046, 0x2029, 0x0001, 0x2019, 0x0048,
+	0x0096, 0x904e, 0x080c, 0x97a4, 0x009e, 0x008e, 0x903e, 0x080c,
+	0x984f, 0x2c20, 0x080c, 0xd415, 0x005e, 0x007e, 0x00be, 0x0005,
+	0x00b6, 0x0046, 0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20, 0x20a9,
+	0x0800, 0x900e, 0x0016, 0x0036, 0x080c, 0x6256, 0x11a0, 0x0086,
+	0x9046, 0x2828, 0x0046, 0x2021, 0x0001, 0x080c, 0xd7a5, 0x004e,
+	0x0096, 0x904e, 0x080c, 0x97a4, 0x009e, 0x008e, 0x903e, 0x080c,
+	0x984f, 0x080c, 0xd415, 0x003e, 0x001e, 0x8108, 0x1f04, 0xd4ea,
+	0x015e, 0x00ce, 0x007e, 0x005e, 0x004e, 0x00be, 0x0005, 0x0016,
+	0x00f6, 0x080c, 0xbb39, 0x0198, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x0046, 0x0180, 0xa800, 0x907d, 0x0138, 0xa803, 0x0000, 0xab82,
+	0x080c, 0x68a0, 0x2f48, 0x0cb0, 0xab82, 0x080c, 0x68a0, 0x00fe,
+	0x001e, 0x0005, 0xa800, 0x907d, 0x0130, 0xa803, 0x0000, 0x080c,
+	0x68a0, 0x2f48, 0x0cb8, 0x080c, 0x68a0, 0x0c88, 0x00e6, 0x0046,
+	0x0036, 0x2061, 0x1cd0, 0x9005, 0x1138, 0x2071, 0x1800, 0x7450,
+	0x7070, 0x8001, 0x9402, 0x12d8, 0x2100, 0x9c06, 0x0168, 0x6000,
+	0x9086, 0x0000, 0x0148, 0x6008, 0x9206, 0x1130, 0x6010, 0x91a0,
+	0x0004, 0x2424, 0x9406, 0x0140, 0x9ce0, 0x0018, 0x2001, 0x1819,
+	0x2004, 0x9c02, 0x1220, 0x0c40, 0x9085, 0x0001, 0x0008, 0x9006,
+	0x003e, 0x004e, 0x00ee, 0x0005, 0x0096, 0x0006, 0x080c, 0x0feb,
+	0x000e, 0x090c, 0x0db4, 0xaae2, 0xa867, 0x010d, 0xa88e, 0x0026,
+	0x2010, 0x080c, 0xbb29, 0x2001, 0x0000, 0x0120, 0x2200, 0x9080,
+	0x0015, 0x2004, 0x002e, 0xa87a, 0x9186, 0x0020, 0x0110, 0xa8e3,
+	0xffff, 0xa986, 0xac76, 0xa87f, 0x0000, 0x2001, 0x1966, 0x2004,
+	0xa882, 0x9006, 0xa802, 0xa86a, 0xa88a, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x68a0, 0x012e, 0x009e, 0x0005, 0x6700, 0x9786, 0x0000,
+	0x0158, 0x9786, 0x0001, 0x0140, 0x9786, 0x000a, 0x0128, 0x9786,
+	0x0009, 0x0110, 0x9085, 0x0001, 0x0005, 0x00e6, 0x6010, 0x9075,
+	0x0138, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x00ee, 0x0005,
+	0x9085, 0x0001, 0x0cd8, 0x0016, 0x6004, 0x908e, 0x001e, 0x11a0,
+	0x8007, 0x6134, 0x918c, 0x00ff, 0x9105, 0x6036, 0x6007, 0x0085,
+	0x6003, 0x000b, 0x6023, 0x0005, 0x2001, 0x195f, 0x2004, 0x601a,
+	0x080c, 0x83f8, 0x080c, 0x898b, 0x001e, 0x0005, 0xa001, 0xa001,
+	0x0005, 0x6024, 0xd0e4, 0x0158, 0xd0cc, 0x0118, 0x080c, 0xbe73,
+	0x0030, 0x080c, 0xd7c1, 0x080c, 0x820b, 0x080c, 0x9e2f, 0x0005,
 	0x9280, 0x0008, 0x2004, 0x9084, 0x000f, 0x0002, 0xd5f4, 0xd5f4,
-	0xd5f4, 0xd5f4, 0xd5f4, 0xd5f4, 0xd601, 0xd5f4, 0xd5f4, 0xd5f4,
-	0xd5f4, 0xd5f4, 0xd5f4, 0xd5f4, 0x6007, 0x003b, 0x602f, 0x0009,
-	0x6017, 0x2a00, 0x6003, 0x0001, 0x080c, 0x83da, 0x080c, 0x896d,
-	0x0005, 0x0096, 0x00c6, 0x2260, 0x080c, 0xd7a8, 0x6043, 0x0000,
-	0x6024, 0xc0f4, 0xc0e4, 0x6026, 0x603b, 0x0000, 0x00ce, 0x00d6,
-	0x2268, 0x9186, 0x0007, 0x1904, 0xd65a, 0x6814, 0x9005, 0x0138,
-	0x2048, 0xa87c, 0xd0fc, 0x1118, 0x00de, 0x009e, 0x08a8, 0x6007,
-	0x003a, 0x6003, 0x0001, 0x080c, 0x83da, 0x080c, 0x896d, 0x00c6,
-	0x2d60, 0x6100, 0x9186, 0x0002, 0x1904, 0xd6d1, 0x6014, 0x9005,
-	0x1138, 0x6000, 0x9086, 0x0007, 0x190c, 0x0db4, 0x0804, 0xd6d1,
-	0x2048, 0x080c, 0xbb2c, 0x1130, 0x0028, 0x2048, 0xa800, 0x9005,
-	0x1de0, 0x2900, 0x2048, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002,
-	0x1168, 0xa87c, 0xc0dc, 0xc0f4, 0xa87e, 0xa880, 0xc0fc, 0xa882,
-	0x2009, 0x0043, 0x080c, 0xcf5f, 0x0804, 0xd6d1, 0x2009, 0x0041,
-	0x0804, 0xd6cb, 0x9186, 0x0005, 0x15a0, 0x6814, 0x2048, 0xa87c,
-	0xd0bc, 0x1120, 0x00de, 0x009e, 0x0804, 0xd5f4, 0xd0b4, 0x0128,
-	0xd0fc, 0x090c, 0x0db4, 0x0804, 0xd615, 0x6007, 0x003a, 0x6003,
-	0x0001, 0x080c, 0x83da, 0x080c, 0x896d, 0x00c6, 0x2d60, 0x6100,
-	0x9186, 0x0002, 0x0120, 0x9186, 0x0004, 0x1904, 0xd6d1, 0x6814,
-	0x2048, 0xa97c, 0xc1f4, 0xc1dc, 0xa97e, 0xa980, 0xc1fc, 0xc1bc,
-	0xa982, 0x00f6, 0x2c78, 0x080c, 0x164a, 0x00fe, 0x2009, 0x0042,
-	0x04d0, 0x0036, 0x080c, 0x0feb, 0x090c, 0x0db4, 0xa867, 0x010d,
-	0x9006, 0xa802, 0xa86a, 0xa88a, 0x2d18, 0xab8e, 0xa887, 0x0045,
-	0x2c00, 0xa892, 0x6038, 0xa8a2, 0x2360, 0x6024, 0xc0dd, 0x6026,
-	0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x2004, 0x6354, 0xab7a,
-	0xa876, 0x9006, 0xa87e, 0xa882, 0xad9a, 0xae96, 0xa89f, 0x0001,
-	0x080c, 0x6891, 0x2019, 0x0045, 0x6008, 0x2068, 0x080c, 0xd106,
-	0x2d00, 0x600a, 0x6023, 0x0006, 0x6003, 0x0007, 0x901e, 0x631a,
-	0x6342, 0x003e, 0x0038, 0x6043, 0x0000, 0x6003, 0x0007, 0x080c,
-	0xcf5f, 0x00ce, 0x00de, 0x009e, 0x0005, 0x9186, 0x0013, 0x1128,
-	0x6004, 0x9082, 0x0085, 0x2008, 0x00c2, 0x9186, 0x0027, 0x1178,
-	0x080c, 0x8861, 0x0036, 0x0096, 0x6014, 0x2048, 0x2019, 0x0004,
-	0x080c, 0xd4f6, 0x009e, 0x003e, 0x080c, 0x896d, 0x0005, 0x9186,
-	0x0014, 0x0d70, 0x080c, 0x9ed7, 0x0005, 0xd704, 0xd702, 0xd702,
-	0xd702, 0xd702, 0xd702, 0xd704, 0xd702, 0xd702, 0xd702, 0xd702,
-	0xd702, 0xd702, 0x080c, 0x0db4, 0x080c, 0x8861, 0x6003, 0x000c,
-	0x080c, 0x896d, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085,
-	0x0208, 0x001a, 0x080c, 0x9ed7, 0x0005, 0xd722, 0xd722, 0xd722,
-	0xd722, 0xd724, 0xd744, 0xd722, 0xd722, 0xd722, 0xd722, 0xd722,
-	0xd722, 0xd722, 0x080c, 0x0db4, 0x00d6, 0x2c68, 0x080c, 0x9dec,
-	0x01b0, 0x6003, 0x0001, 0x6007, 0x001e, 0x2009, 0x026e, 0x210c,
-	0x613a, 0x2009, 0x026f, 0x210c, 0x613e, 0x600b, 0xffff, 0x6910,
-	0x6112, 0x6023, 0x0004, 0x080c, 0x83da, 0x080c, 0x896d, 0x2d60,
-	0x080c, 0x9e42, 0x00de, 0x0005, 0x080c, 0x9e42, 0x0005, 0x00e6,
-	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ec, 0x00ee, 0x0005,
-	0x2009, 0x1873, 0x210c, 0xd1ec, 0x05b0, 0x6003, 0x0002, 0x6024,
-	0xc0e5, 0x6026, 0xd0cc, 0x0150, 0x2001, 0x1958, 0x2004, 0x6042,
-	0x2009, 0x1873, 0x210c, 0xd1f4, 0x1520, 0x00a0, 0x2009, 0x1873,
-	0x210c, 0xd1f4, 0x0128, 0x6024, 0xc0e4, 0x6026, 0x9006, 0x00d8,
-	0x2001, 0x1958, 0x200c, 0x2001, 0x1956, 0x2004, 0x9100, 0x9080,
-	0x000a, 0x6042, 0x6010, 0x00b6, 0x2058, 0xb8ac, 0x00be, 0x0008,
-	0x2104, 0x9005, 0x0118, 0x9088, 0x0003, 0x0cd0, 0x2c0a, 0x600f,
-	0x0000, 0x9085, 0x0001, 0x0005, 0x0016, 0x00c6, 0x00e6, 0x6154,
-	0xb8ac, 0x2060, 0x8cff, 0x0180, 0x84ff, 0x1118, 0x6054, 0x9106,
-	0x1138, 0x600c, 0x2072, 0x080c, 0x81ed, 0x080c, 0x9e42, 0x0010,
-	0x9cf0, 0x0003, 0x2e64, 0x0c70, 0x00ee, 0x00ce, 0x001e, 0x0005,
-	0x00d6, 0x00b6, 0x6010, 0x2058, 0xb8ac, 0x2068, 0x9005, 0x0130,
-	0x9c06, 0x0110, 0x680c, 0x0cd0, 0x600c, 0x680e, 0x00be, 0x00de,
-	0x0005, 0x0026, 0x0036, 0x0156, 0x2011, 0x182b, 0x2204, 0x9084,
-	0x00ff, 0x2019, 0x026e, 0x2334, 0x9636, 0x1508, 0x8318, 0x2334,
-	0x2204, 0x9084, 0xff00, 0x9636, 0x11d0, 0x2011, 0x0270, 0x20a9,
-	0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xae20,
-	0x009e, 0x1168, 0x2011, 0x0274, 0x20a9, 0x0004, 0x6010, 0x0096,
-	0x2048, 0x2019, 0x0006, 0x080c, 0xae20, 0x009e, 0x1100, 0x015e,
-	0x003e, 0x002e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5c6d,
-	0x080c, 0x2dbd, 0x00ee, 0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058,
-	0xb800, 0x00be, 0xd0fc, 0x0108, 0x0011, 0x00ee, 0x0005, 0xa880,
-	0xc0e5, 0xa882, 0x0005, 0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066,
-	0x0056, 0x0046, 0x0026, 0x0016, 0x0126, 0x2091, 0x8000, 0x2029,
-	0x19c0, 0x252c, 0x2021, 0x19c6, 0x2424, 0x2061, 0x1cd0, 0x2071,
-	0x1800, 0x7650, 0x7070, 0x9606, 0x0578, 0x6720, 0x9786, 0x0001,
-	0x0118, 0x9786, 0x0008, 0x1500, 0x2500, 0x9c06, 0x01e8, 0x2400,
-	0x9c06, 0x01d0, 0x080c, 0xd57c, 0x01b8, 0x080c, 0xd58c, 0x11a0,
-	0x6000, 0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x190f, 0x001e,
-	0x080c, 0xbd21, 0x1110, 0x080c, 0x3005, 0x080c, 0xbd32, 0x1110,
-	0x080c, 0xa7d1, 0x080c, 0x9e72, 0x9ce0, 0x0018, 0x2001, 0x1819,
-	0x2004, 0x9c02, 0x1208, 0x0858, 0x012e, 0x001e, 0x002e, 0x004e,
-	0x005e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x2001,
-	0x1810, 0x2004, 0xd0dc, 0x0005, 0x0006, 0x2001, 0x1836, 0x2004,
-	0xd09c, 0x000e, 0x0005, 0x0006, 0x0036, 0x0046, 0x080c, 0xc22c,
-	0x0168, 0x2019, 0xffff, 0x9005, 0x0128, 0x6010, 0x00b6, 0x2058,
-	0xbba0, 0x00be, 0x2021, 0x0004, 0x080c, 0x4a86, 0x004e, 0x003e,
-	0x000e, 0x6004, 0x9086, 0x0001, 0x1128, 0x080c, 0x992c, 0x080c,
-	0x9e72, 0x9006, 0x0005, 0x00e6, 0x00c6, 0x00b6, 0x0046, 0x2061,
-	0x1cd0, 0x2071, 0x1800, 0x7450, 0x7070, 0x8001, 0x9402, 0x12b8,
-	0x2100, 0x9c06, 0x0148, 0x6000, 0x9086, 0x0000, 0x0128, 0x6010,
-	0x2058, 0xb8a0, 0x9206, 0x0140, 0x9ce0, 0x0018, 0x2001, 0x1819,
-	0x2004, 0x9c02, 0x1220, 0x0c60, 0x9085, 0x0001, 0x0008, 0x9006,
-	0x004e, 0x00be, 0x00ce, 0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6,
-	0x0016, 0x2091, 0x8000, 0x2071, 0x1840, 0xd5a4, 0x0118, 0x7034,
-	0x8000, 0x7036, 0xd5b4, 0x0118, 0x7030, 0x8000, 0x7032, 0xd5ac,
-	0x0178, 0x2500, 0x9084, 0x0007, 0x908e, 0x0003, 0x0148, 0x908e,
-	0x0004, 0x0130, 0x908e, 0x0005, 0x0118, 0x2071, 0x184a, 0x0089,
-	0x001e, 0x00ee, 0x000e, 0x012e, 0x0005, 0x0126, 0x0006, 0x00e6,
-	0x2091, 0x8000, 0x2071, 0x1842, 0x0021, 0x00ee, 0x000e, 0x012e,
-	0x0005, 0x2e04, 0x8000, 0x2072, 0x1220, 0x8e70, 0x2e04, 0x8000,
-	0x2072, 0x0005, 0x00e6, 0x2071, 0x1840, 0x0c99, 0x00ee, 0x0005,
-	0x00e6, 0x2071, 0x1844, 0x0c69, 0x00ee, 0x0005, 0x0126, 0x0006,
-	0x00e6, 0x2091, 0x8000, 0x2071, 0x1840, 0x7044, 0x8000, 0x7046,
-	0x00ee, 0x000e, 0x012e, 0x0005, 0x0003, 0x000b, 0x04a6, 0x0000,
-	0xc000, 0x0001, 0x8064, 0x0008, 0x0010, 0x0000, 0x8066, 0x0000,
-	0x0101, 0x0008, 0x4407, 0x0003, 0x8060, 0x0000, 0x0400, 0x0000,
-	0x580d, 0x000b, 0x798e, 0x0003, 0x50db, 0x000b, 0x4c0a, 0x0003,
-	0xbac0, 0x0009, 0x008a, 0x0000, 0x0c0a, 0x000b, 0x15fe, 0x0008,
-	0x340a, 0x0003, 0xc4c0, 0x0009, 0x7000, 0x0000, 0xffa0, 0x0001,
-	0x2000, 0x0000, 0x1627, 0x0003, 0x808c, 0x0008, 0x0001, 0x0000,
-	0x0000, 0x0007, 0x4047, 0x000a, 0x808c, 0x0008, 0x0002, 0x0000,
-	0x0821, 0x0003, 0x4022, 0x0000, 0x0022, 0x000b, 0x4122, 0x0008,
-	0x4447, 0x0002, 0x0e4f, 0x000b, 0x0bfe, 0x0008, 0x11a0, 0x0001,
-	0x122d, 0x000b, 0x0ca0, 0x0001, 0x122d, 0x000b, 0x9180, 0x0001,
-	0x0004, 0x0000, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62, 0x0008,
-	0x8066, 0x0000, 0x0009, 0x0008, 0x4430, 0x000b, 0x808c, 0x0008,
-	0x0000, 0x0008, 0x0060, 0x0008, 0x8062, 0x0008, 0x0004, 0x0000,
-	0x8066, 0x0000, 0x0411, 0x0000, 0x4438, 0x0003, 0x03fe, 0x0000,
-	0x43e0, 0x0001, 0x0e2a, 0x000b, 0xc2c0, 0x0009, 0x00ff, 0x0008,
-	0x02e0, 0x0001, 0x0e2a, 0x000b, 0x9180, 0x0001, 0x0005, 0x0008,
-	0x8060, 0x0000, 0x0400, 0x0000, 0x7f62, 0x0008, 0x8066, 0x0000,
-	0x0019, 0x0000, 0x4447, 0x000b, 0x0240, 0x0002, 0x0a27, 0x000b,
-	0x00fe, 0x0000, 0x322a, 0x000b, 0x112a, 0x0000, 0x002e, 0x0008,
-	0x022c, 0x0008, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x808c, 0x0008,
-	0x0002, 0x0000, 0x1760, 0x0008, 0x8062, 0x0008, 0x000f, 0x0008,
-	0x8066, 0x0000, 0x0011, 0x0008, 0x4458, 0x0003, 0x01fe, 0x0008,
-	0x42e0, 0x0009, 0x0e1d, 0x0003, 0x00fe, 0x0000, 0x43e0, 0x0001,
-	0x0e1d, 0x0003, 0x1734, 0x0000, 0x1530, 0x0000, 0x1632, 0x0008,
-	0x0d2a, 0x0008, 0x9880, 0x0001, 0x0010, 0x0000, 0x8060, 0x0000,
-	0x0400, 0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x1e0a, 0x0008,
-	0x446a, 0x000b, 0x808a, 0x0008, 0x0003, 0x0008, 0x1a60, 0x0000,
-	0x8062, 0x0008, 0x0002, 0x0000, 0x5870, 0x000b, 0x8066, 0x0000,
-	0x3679, 0x0000, 0x4473, 0x0003, 0x5874, 0x0003, 0x3efe, 0x0008,
-	0x7f4f, 0x0002, 0x087a, 0x000b, 0x0d00, 0x0000, 0x0082, 0x0004,
-	0x8054, 0x0008, 0x0011, 0x0008, 0x8074, 0x0000, 0x1010, 0x0008,
-	0x1efe, 0x0000, 0x300a, 0x000b, 0x00b8, 0x0004, 0x000a, 0x000b,
-	0x00fe, 0x0000, 0x348a, 0x000b, 0x1a60, 0x0000, 0x8062, 0x0008,
-	0x0007, 0x0000, 0x8066, 0x0000, 0x0231, 0x0008, 0x4489, 0x0003,
-	0x03fe, 0x0000, 0x04d0, 0x0001, 0x0cb0, 0x0003, 0x82c0, 0x0001,
-	0x1f00, 0x0000, 0xffa0, 0x0001, 0x0400, 0x0000, 0x089f, 0x0003,
-	0x14b0, 0x0003, 0x01fe, 0x0008, 0x0580, 0x0009, 0x7f06, 0x0000,
-	0x02fe, 0x0008, 0xffc0, 0x0001, 0x00ff, 0x0008, 0x0690, 0x0001,
-	0x109f, 0x0003, 0x7f08, 0x0008, 0x84c0, 0x0001, 0xff00, 0x0008,
-	0x08b0, 0x000b, 0x00fe, 0x0000, 0x34a6, 0x0003, 0x8072, 0x0000,
-	0x1010, 0x0008, 0x3944, 0x0002, 0x08a1, 0x000b, 0x00aa, 0x000b,
-	0x8072, 0x0000, 0x2020, 0x0008, 0x3945, 0x000a, 0x08a6, 0x0003,
-	0x3946, 0x000a, 0x0cb7, 0x000b, 0x0000, 0x0007, 0x3943, 0x000a,
-	0x08b7, 0x0003, 0x00aa, 0x000b, 0x00fe, 0x0000, 0x34b5, 0x000b,
-	0x8072, 0x0000, 0x1000, 0x0000, 0x00b7, 0x000b, 0x8072, 0x0000,
-	0x2000, 0x0000, 0x4000, 0x000f, 0x1c60, 0x0000, 0x1b62, 0x0000,
-	0x8066, 0x0000, 0x0231, 0x0008, 0x44bc, 0x0003, 0x58bd, 0x0003,
-	0x0140, 0x0008, 0x0242, 0x0000, 0x1f43, 0x0002, 0x0ccb, 0x0003,
-	0x0d44, 0x0000, 0x0d46, 0x0008, 0x0348, 0x0008, 0x044a, 0x0008,
-	0x030a, 0x0008, 0x040c, 0x0000, 0x0d06, 0x0000, 0x0d08, 0x0008,
-	0x00cf, 0x000b, 0x0344, 0x0008, 0x0446, 0x0008, 0x0548, 0x0008,
-	0x064a, 0x0000, 0x58cf, 0x0003, 0x3efe, 0x0008, 0x7f4f, 0x0002,
-	0x08d6, 0x000b, 0x8000, 0x0000, 0x0001, 0x0000, 0x0082, 0x0004,
-	0x8054, 0x0008, 0x0001, 0x0000, 0x8074, 0x0000, 0x2020, 0x0008,
-	0x4000, 0x000f, 0x3a40, 0x000a, 0x0c0d, 0x0003, 0x2b24, 0x0008,
-	0x2b24, 0x0008, 0x58df, 0x000b, 0x8054, 0x0008, 0x0002, 0x0000,
-	0x1242, 0x0002, 0x092d, 0x000b, 0x3a45, 0x000a, 0x091c, 0x0003,
-	0x8072, 0x0000, 0x1000, 0x0000, 0x3945, 0x000a, 0x08ec, 0x000b,
-	0x8072, 0x0000, 0x3010, 0x0000, 0x1e10, 0x000a, 0x7f3c, 0x0000,
-	0x0917, 0x000b, 0x1d00, 0x0002, 0x7f3a, 0x0000, 0x0d60, 0x0000,
-	0x7f62, 0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x44f5, 0x000b,
-	0x00fe, 0x0000, 0x3514, 0x000b, 0x1c60, 0x0000, 0x8062, 0x0008,
-	0x0001, 0x0000, 0x8066, 0x0000, 0x0009, 0x0008, 0x44fd, 0x0003,
-	0x00fe, 0x0000, 0x3204, 0x000b, 0x0038, 0x0000, 0x0060, 0x0008,
-	0x8062, 0x0008, 0x0019, 0x0000, 0x8066, 0x0000, 0x0009, 0x0008,
-	0x4506, 0x0003, 0x80c0, 0x0009, 0x00ff, 0x0008, 0x7f3e, 0x0008,
-	0x0d60, 0x0000, 0x0efe, 0x0008, 0x1f80, 0x0001, 0x7f62, 0x0008,
-	0x8066, 0x0000, 0x0009, 0x0008, 0x4510, 0x000b, 0x003a, 0x0008,
-	0x1dfe, 0x0000, 0x00f1, 0x0003, 0x0036, 0x0008, 0x00b8, 0x0004,
-	0x012d, 0x0003, 0x8074, 0x0000, 0x2000, 0x0000, 0x8072, 0x0000,
-	0x2000, 0x0000, 0x012d, 0x0003, 0x3a44, 0x0002, 0x0a30, 0x000b,
-	0x8074, 0x0000, 0x1000, 0x0000, 0x8072, 0x0000, 0x1000, 0x0000,
-	0x2d0e, 0x0000, 0x2d0e, 0x0000, 0x3601, 0x0003, 0x26fe, 0x0008,
-	0x26fe, 0x0008, 0x2700, 0x0008, 0x2700, 0x0008, 0x00d0, 0x0009,
-	0x0d3f, 0x0003, 0x8074, 0x0000, 0x4040, 0x0008, 0x592d, 0x000b,
-	0x50db, 0x000b, 0x3a46, 0x000a, 0x0d3f, 0x0003, 0x3a47, 0x0002,
-	0x093a, 0x000b, 0x8054, 0x0008, 0x0004, 0x0000, 0x8074, 0x0000,
-	0x8000, 0x0000, 0x8072, 0x0000, 0x3000, 0x0008, 0x0182, 0x0003,
-	0x92c0, 0x0009, 0x0fc8, 0x0000, 0x080a, 0x0003, 0x1246, 0x000a,
-	0x0dfb, 0x000b, 0x1a60, 0x0000, 0x8062, 0x0008, 0x0002, 0x0000,
-	0x8066, 0x0000, 0x362a, 0x0000, 0x4544, 0x0003, 0x2000, 0x0000,
-	0x2000, 0x0000, 0x2102, 0x0000, 0x2102, 0x0000, 0x2204, 0x0000,
-	0x2204, 0x0000, 0x2306, 0x0000, 0x2306, 0x0000, 0x2408, 0x0000,
-	0x2408, 0x0000, 0x250a, 0x0000, 0x250a, 0x0000, 0x260c, 0x0000,
-	0x260c, 0x0000, 0x270e, 0x0000, 0x270e, 0x0000, 0x2810, 0x0000,
-	0x2810, 0x0000, 0x2912, 0x0000, 0x2912, 0x0000, 0x1a60, 0x0000,
-	0x8062, 0x0008, 0x0007, 0x0000, 0x8066, 0x0000, 0x0052, 0x0000,
-	0x455e, 0x000b, 0x92c0, 0x0009, 0x0780, 0x0008, 0x0e17, 0x0003,
-	0x124b, 0x0002, 0x0967, 0x0003, 0x2e4d, 0x0002, 0x2e4d, 0x0002,
-	0x0a01, 0x0003, 0x3a46, 0x000a, 0x0d74, 0x0003, 0x5969, 0x000b,
-	0x8054, 0x0008, 0x0004, 0x0000, 0x1243, 0x000a, 0x097e, 0x000b,
-	0x8010, 0x0008, 0x000d, 0x0000, 0x01ef, 0x0004, 0x1810, 0x0000,
-	0x01ef, 0x0004, 0x017e, 0x0003, 0x194d, 0x000a, 0x0978, 0x000b,
-	0x1243, 0x000a, 0x0a0b, 0x0003, 0x5978, 0x000b, 0x8054, 0x0008,
-	0x0004, 0x0000, 0x01e4, 0x000c, 0x1810, 0x0000, 0x01ef, 0x0004,
-	0x8074, 0x0000, 0xf000, 0x0008, 0x8072, 0x0000, 0x3000, 0x0008,
-	0x0d30, 0x0000, 0x3a42, 0x0002, 0x0d88, 0x0003, 0x15fe, 0x0008,
-	0x3451, 0x000b, 0x000a, 0x000b, 0x8074, 0x0000, 0x0501, 0x0000,
-	0x8010, 0x0008, 0x000c, 0x0008, 0x01ef, 0x0004, 0x000a, 0x000b,
-	0xbbe0, 0x0009, 0x0030, 0x0008, 0x0d9e, 0x000b, 0x18fe, 0x0000,
-	0x3ce0, 0x0009, 0x099b, 0x0003, 0x15fe, 0x0008, 0x3ce0, 0x0009,
-	0x099b, 0x0003, 0x01df, 0x0004, 0x8076, 0x0008, 0x0040, 0x0000,
-	0x01dc, 0x000b, 0x8076, 0x0008, 0x0041, 0x0008, 0x01dc, 0x000b,
-	0xbbe0, 0x0009, 0x0032, 0x0000, 0x0da3, 0x0003, 0x3c1e, 0x0008,
-	0x01dc, 0x000b, 0xbbe0, 0x0009, 0x0037, 0x0000, 0x0dc1, 0x000b,
-	0x18fe, 0x0000, 0x3ce0, 0x0009, 0x0d9b, 0x000b, 0x8076, 0x0008,
-	0x0040, 0x0000, 0x1a60, 0x0000, 0x8062, 0x0008, 0x000d, 0x0000,
-	0x2604, 0x0008, 0x2604, 0x0008, 0x2706, 0x0008, 0x2706, 0x0008,
-	0x2808, 0x0000, 0x2808, 0x0000, 0x290a, 0x0000, 0x290a, 0x0000,
-	0x8066, 0x0000, 0x0422, 0x0000, 0x45b8, 0x0003, 0x01e4, 0x000c,
-	0x8054, 0x0008, 0x0004, 0x0000, 0x8074, 0x0000, 0xf000, 0x0008,
-	0x8072, 0x0000, 0xb000, 0x0000, 0x0182, 0x0003, 0xbbe0, 0x0009,
-	0x0038, 0x0000, 0x0dd3, 0x000b, 0x18fe, 0x0000, 0x3ce0, 0x0009,
-	0x09d0, 0x0003, 0x15fe, 0x0008, 0x3ce0, 0x0009, 0x0d97, 0x000b,
-	0x01df, 0x0004, 0x8076, 0x0008, 0x0040, 0x0000, 0x8072, 0x0000,
-	0x8000, 0x0000, 0x0227, 0x0003, 0x8076, 0x0008, 0x0042, 0x0008,
-	0x01dc, 0x000b, 0xbbe0, 0x0009, 0x0016, 0x0000, 0x0ddc, 0x000b,
-	0x3a44, 0x0002, 0x0c0c, 0x000b, 0x8072, 0x0000, 0x8000, 0x0000,
-	0x8000, 0x000f, 0x000a, 0x000b, 0x8072, 0x0000, 0x8000, 0x0000,
-	0x000a, 0x000b, 0x3d30, 0x000a, 0x7f00, 0x0000, 0xbc80, 0x0001,
-	0x0007, 0x0000, 0x01e8, 0x0003, 0x1930, 0x000a, 0x7f00, 0x0000,
-	0x9880, 0x0001, 0x0007, 0x0000, 0x8060, 0x0000, 0x0400, 0x0000,
-	0x7f62, 0x0008, 0x8066, 0x0000, 0x000a, 0x0008, 0x45ed, 0x0003,
-	0x4000, 0x000f, 0x21ef, 0x0003, 0x0870, 0x0008, 0x4000, 0x000f,
-	0xbac0, 0x0009, 0x0090, 0x0008, 0x09f8, 0x0003, 0x8074, 0x0000,
-	0x0706, 0x0000, 0x01fa, 0x0003, 0x8074, 0x0000, 0x0703, 0x0000,
-	0x4000, 0x000f, 0x8010, 0x0008, 0x0023, 0x0000, 0x0235, 0x0003,
-	0x8010, 0x0008, 0x0008, 0x0000, 0x0235, 0x0003, 0x8010, 0x0008,
-	0x0022, 0x0008, 0x0235, 0x0003, 0x01e4, 0x000c, 0x8010, 0x0008,
-	0x0007, 0x0000, 0x01ef, 0x0004, 0x1810, 0x0000, 0x01ef, 0x0004,
-	0x0241, 0x0003, 0x01e4, 0x000c, 0x8010, 0x0008, 0x001b, 0x0008,
-	0x01ef, 0x0004, 0x1810, 0x0000, 0x01ef, 0x0004, 0x8074, 0x0000,
-	0xf080, 0x0000, 0x8072, 0x0000, 0x3000, 0x0008, 0x0d30, 0x0000,
-	0x000a, 0x000b, 0x8010, 0x0008, 0x0009, 0x0008, 0x0235, 0x0003,
-	0x8010, 0x0008, 0x0005, 0x0008, 0x0235, 0x0003, 0x808c, 0x0008,
-	0x0001, 0x0000, 0x8010, 0x0008, 0x0004, 0x0000, 0x4143, 0x000a,
-	0x085f, 0x0003, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x0d2a, 0x0008,
-	0x0235, 0x0003, 0x8010, 0x0008, 0x0003, 0x0008, 0x0239, 0x0003,
-	0x8010, 0x0008, 0x000b, 0x0000, 0x0239, 0x0003, 0x8010, 0x0008,
-	0x0002, 0x0000, 0x0239, 0x0003, 0x3a47, 0x0002, 0x0d2d, 0x0003,
-	0x8010, 0x0008, 0x0006, 0x0008, 0x0239, 0x0003, 0x8074, 0x0000,
-	0xf000, 0x0008, 0x8072, 0x0000, 0x3000, 0x0008, 0x01ef, 0x0004,
-	0x01f2, 0x0004, 0x3a40, 0x000a, 0x080a, 0x0003, 0x8010, 0x0008,
-	0x000c, 0x0008, 0x01ef, 0x0004, 0x000a, 0x000b, 0x8074, 0x0000,
-	0xf080, 0x0000, 0x8072, 0x0000, 0x3000, 0x0008, 0x0d30, 0x0000,
-	0x2e4d, 0x0002, 0x2e4d, 0x0002, 0x0a4c, 0x0003, 0x8054, 0x0008,
-	0x0019, 0x0000, 0x000a, 0x000b, 0x8054, 0x0008, 0x0009, 0x0008,
-	0x000a, 0x000b, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x022a, 0x000b,
-	0x15b6, 0xf4ac, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020,
-	0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000,
-	0x4000, 0x8000, 0x0a42
+	0xd5f4, 0xd5f6, 0xd5f4, 0xd5f6, 0xd5f6, 0xd5f4, 0xd5f6, 0xd5f4,
+	0xd5f4, 0xd5f4, 0xd5f4, 0xd5f4, 0x9006, 0x0005, 0x9085, 0x0001,
+	0x0005, 0x9280, 0x0008, 0x2004, 0x9084, 0x000f, 0x0002, 0xd60d,
+	0xd60d, 0xd60d, 0xd60d, 0xd60d, 0xd60d, 0xd61a, 0xd60d, 0xd60d,
+	0xd60d, 0xd60d, 0xd60d, 0xd60d, 0xd60d, 0x6007, 0x003b, 0x602f,
+	0x0009, 0x6017, 0x2a00, 0x6003, 0x0001, 0x080c, 0x83f8, 0x080c,
+	0x898b, 0x0005, 0x0096, 0x00c6, 0x2260, 0x080c, 0xd7c1, 0x6043,
+	0x0000, 0x6024, 0xc0f4, 0xc0e4, 0x6026, 0x603b, 0x0000, 0x00ce,
+	0x00d6, 0x2268, 0x9186, 0x0007, 0x1904, 0xd673, 0x6814, 0x9005,
+	0x0138, 0x2048, 0xa87c, 0xd0fc, 0x1118, 0x00de, 0x009e, 0x08a8,
+	0x6007, 0x003a, 0x6003, 0x0001, 0x080c, 0x83f8, 0x080c, 0x898b,
+	0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002, 0x1904, 0xd6ea, 0x6014,
+	0x9005, 0x1138, 0x6000, 0x9086, 0x0007, 0x190c, 0x0db4, 0x0804,
+	0xd6ea, 0x2048, 0x080c, 0xbb3b, 0x1130, 0x0028, 0x2048, 0xa800,
+	0x9005, 0x1de0, 0x2900, 0x2048, 0xa87c, 0x9084, 0x0003, 0x9086,
+	0x0002, 0x1168, 0xa87c, 0xc0dc, 0xc0f4, 0xa87e, 0xa880, 0xc0fc,
+	0xa882, 0x2009, 0x0043, 0x080c, 0xcf73, 0x0804, 0xd6ea, 0x2009,
+	0x0041, 0x0804, 0xd6e4, 0x9186, 0x0005, 0x15a0, 0x6814, 0x2048,
+	0xa87c, 0xd0bc, 0x1120, 0x00de, 0x009e, 0x0804, 0xd60d, 0xd0b4,
+	0x0128, 0xd0fc, 0x090c, 0x0db4, 0x0804, 0xd62e, 0x6007, 0x003a,
+	0x6003, 0x0001, 0x080c, 0x83f8, 0x080c, 0x898b, 0x00c6, 0x2d60,
+	0x6100, 0x9186, 0x0002, 0x0120, 0x9186, 0x0004, 0x1904, 0xd6ea,
+	0x6814, 0x2048, 0xa97c, 0xc1f4, 0xc1dc, 0xa97e, 0xa980, 0xc1fc,
+	0xc1bc, 0xa982, 0x00f6, 0x2c78, 0x080c, 0x164a, 0x00fe, 0x2009,
+	0x0042, 0x04d0, 0x0036, 0x080c, 0x0feb, 0x090c, 0x0db4, 0xa867,
+	0x010d, 0x9006, 0xa802, 0xa86a, 0xa88a, 0x2d18, 0xab8e, 0xa887,
+	0x0045, 0x2c00, 0xa892, 0x6038, 0xa8a2, 0x2360, 0x6024, 0xc0dd,
+	0x6026, 0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x2004, 0x6354,
+	0xab7a, 0xa876, 0x9006, 0xa87e, 0xa882, 0xad9a, 0xae96, 0xa89f,
+	0x0001, 0x080c, 0x68a0, 0x2019, 0x0045, 0x6008, 0x2068, 0x080c,
+	0xd11f, 0x2d00, 0x600a, 0x6023, 0x0006, 0x6003, 0x0007, 0x901e,
+	0x631a, 0x6342, 0x003e, 0x0038, 0x6043, 0x0000, 0x6003, 0x0007,
+	0x080c, 0xcf73, 0x00ce, 0x00de, 0x009e, 0x0005, 0x9186, 0x0013,
+	0x1128, 0x6004, 0x9082, 0x0085, 0x2008, 0x00c2, 0x9186, 0x0027,
+	0x1178, 0x080c, 0x887f, 0x0036, 0x0096, 0x6014, 0x2048, 0x2019,
+	0x0004, 0x080c, 0xd50f, 0x009e, 0x003e, 0x080c, 0x898b, 0x0005,
+	0x9186, 0x0014, 0x0d70, 0x080c, 0x9ec4, 0x0005, 0xd71d, 0xd71b,
+	0xd71b, 0xd71b, 0xd71b, 0xd71b, 0xd71d, 0xd71b, 0xd71b, 0xd71b,
+	0xd71b, 0xd71b, 0xd71b, 0x080c, 0x0db4, 0x080c, 0x887f, 0x6003,
+	0x000c, 0x080c, 0x898b, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182,
+	0x0085, 0x0208, 0x001a, 0x080c, 0x9ec4, 0x0005, 0xd73b, 0xd73b,
+	0xd73b, 0xd73b, 0xd73d, 0xd75d, 0xd73b, 0xd73b, 0xd73b, 0xd73b,
+	0xd73b, 0xd73b, 0xd73b, 0x080c, 0x0db4, 0x00d6, 0x2c68, 0x080c,
+	0x9dd9, 0x01b0, 0x6003, 0x0001, 0x6007, 0x001e, 0x2009, 0x026e,
+	0x210c, 0x613a, 0x2009, 0x026f, 0x210c, 0x613e, 0x600b, 0xffff,
+	0x6910, 0x6112, 0x6023, 0x0004, 0x080c, 0x83f8, 0x080c, 0x898b,
+	0x2d60, 0x080c, 0x9e2f, 0x00de, 0x0005, 0x080c, 0x9e2f, 0x0005,
+	0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ec, 0x00ee,
+	0x0005, 0x2009, 0x187b, 0x210c, 0xd1ec, 0x05b0, 0x6003, 0x0002,
+	0x6024, 0xc0e5, 0x6026, 0xd0cc, 0x0150, 0x2001, 0x1960, 0x2004,
+	0x6042, 0x2009, 0x187b, 0x210c, 0xd1f4, 0x1520, 0x00a0, 0x2009,
+	0x187b, 0x210c, 0xd1f4, 0x0128, 0x6024, 0xc0e4, 0x6026, 0x9006,
+	0x00d8, 0x2001, 0x1960, 0x200c, 0x2001, 0x195e, 0x2004, 0x9100,
+	0x9080, 0x000a, 0x6042, 0x6010, 0x00b6, 0x2058, 0xb8ac, 0x00be,
+	0x0008, 0x2104, 0x9005, 0x0118, 0x9088, 0x0003, 0x0cd0, 0x2c0a,
+	0x600f, 0x0000, 0x9085, 0x0001, 0x0005, 0x0016, 0x00c6, 0x00e6,
+	0x6154, 0xb8ac, 0x2060, 0x8cff, 0x0180, 0x84ff, 0x1118, 0x6054,
+	0x9106, 0x1138, 0x600c, 0x2072, 0x080c, 0x820b, 0x080c, 0x9e2f,
+	0x0010, 0x9cf0, 0x0003, 0x2e64, 0x0c70, 0x00ee, 0x00ce, 0x001e,
+	0x0005, 0x00d6, 0x00b6, 0x6010, 0x2058, 0xb8ac, 0x2068, 0x9005,
+	0x0130, 0x9c06, 0x0110, 0x680c, 0x0cd0, 0x600c, 0x680e, 0x00be,
+	0x00de, 0x0005, 0x0026, 0x0036, 0x0156, 0x2011, 0x182b, 0x2204,
+	0x9084, 0x00ff, 0x2019, 0x026e, 0x2334, 0x9636, 0x1508, 0x8318,
+	0x2334, 0x2204, 0x9084, 0xff00, 0x9636, 0x11d0, 0x2011, 0x0270,
+	0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c,
+	0xae1c, 0x009e, 0x1168, 0x2011, 0x0274, 0x20a9, 0x0004, 0x6010,
+	0x0096, 0x2048, 0x2019, 0x0006, 0x080c, 0xae1c, 0x009e, 0x1100,
+	0x015e, 0x003e, 0x002e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c,
+	0x5c78, 0x080c, 0x2dc8, 0x00ee, 0x0005, 0x00e6, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0fc, 0x0108, 0x0011, 0x00ee, 0x0005,
+	0xa880, 0xc0e5, 0xa882, 0x0005, 0x00e6, 0x00d6, 0x00c6, 0x0076,
+	0x0066, 0x0056, 0x0046, 0x0026, 0x0016, 0x0126, 0x2091, 0x8000,
+	0x2029, 0x19c8, 0x252c, 0x2021, 0x19ce, 0x2424, 0x2061, 0x1cd0,
+	0x2071, 0x1800, 0x7650, 0x7070, 0x9606, 0x0578, 0x6720, 0x9786,
+	0x0001, 0x0118, 0x9786, 0x0008, 0x1500, 0x2500, 0x9c06, 0x01e8,
+	0x2400, 0x9c06, 0x01d0, 0x080c, 0xd595, 0x01b8, 0x080c, 0xd5a5,
+	0x11a0, 0x6000, 0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x191f,
+	0x001e, 0x080c, 0xbd30, 0x1110, 0x080c, 0x3010, 0x080c, 0xbd41,
+	0x1110, 0x080c, 0xa7cd, 0x080c, 0x9e5f, 0x9ce0, 0x0018, 0x2001,
+	0x1819, 0x2004, 0x9c02, 0x1208, 0x0858, 0x012e, 0x001e, 0x002e,
+	0x004e, 0x005e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x0005,
+	0x2001, 0x1810, 0x2004, 0xd0dc, 0x0005, 0x0006, 0x2001, 0x1836,
+	0x2004, 0xd09c, 0x000e, 0x0005, 0x0006, 0x0036, 0x0046, 0x080c,
+	0xc23b, 0x0168, 0x2019, 0xffff, 0x9005, 0x0128, 0x6010, 0x00b6,
+	0x2058, 0xbba0, 0x00be, 0x2021, 0x0004, 0x080c, 0x4a91, 0x004e,
+	0x003e, 0x000e, 0x6004, 0x9086, 0x0001, 0x1128, 0x080c, 0x9915,
+	0x080c, 0x9e5f, 0x9006, 0x0005, 0x00e6, 0x00c6, 0x00b6, 0x0046,
+	0x2061, 0x1cd0, 0x2071, 0x1800, 0x7450, 0x7070, 0x8001, 0x9402,
+	0x12b8, 0x2100, 0x9c06, 0x0148, 0x6000, 0x9086, 0x0000, 0x0128,
+	0x6010, 0x2058, 0xb8a0, 0x9206, 0x0140, 0x9ce0, 0x0018, 0x2001,
+	0x1819, 0x2004, 0x9c02, 0x1220, 0x0c60, 0x9085, 0x0001, 0x0008,
+	0x9006, 0x004e, 0x00be, 0x00ce, 0x00ee, 0x0005, 0x0126, 0x0006,
+	0x00e6, 0x0016, 0x2091, 0x8000, 0x2071, 0x1840, 0xd5a4, 0x0118,
+	0x7054, 0x8000, 0x7056, 0xd5b4, 0x0118, 0x7050, 0x8000, 0x7052,
+	0xd5ac, 0x0178, 0x2500, 0x9084, 0x0007, 0x908e, 0x0003, 0x0148,
+	0x908e, 0x0004, 0x0130, 0x908e, 0x0005, 0x0118, 0x2071, 0x184a,
+	0x0089, 0x001e, 0x00ee, 0x000e, 0x012e, 0x0005, 0x0126, 0x0006,
+	0x00e6, 0x2091, 0x8000, 0x2071, 0x1842, 0x0021, 0x00ee, 0x000e,
+	0x012e, 0x0005, 0x2e04, 0x8000, 0x2072, 0x1220, 0x8e70, 0x2e04,
+	0x8000, 0x2072, 0x0005, 0x00e6, 0x2071, 0x1840, 0x0c99, 0x00ee,
+	0x0005, 0x00e6, 0x2071, 0x1844, 0x0c69, 0x00ee, 0x0005, 0x0126,
+	0x0006, 0x00e6, 0x2091, 0x8000, 0x2071, 0x1840, 0x7064, 0x8000,
+	0x7066, 0x00ee, 0x000e, 0x012e, 0x0005, 0x0003, 0x000b, 0x04a6,
+	0x0000, 0xc000, 0x0001, 0x8064, 0x0008, 0x0010, 0x0000, 0x8066,
+	0x0000, 0x0101, 0x0008, 0x4407, 0x0003, 0x8060, 0x0000, 0x0400,
+	0x0000, 0x580d, 0x000b, 0x798e, 0x0003, 0x50db, 0x000b, 0x4c0a,
+	0x0003, 0xbac0, 0x0009, 0x008a, 0x0000, 0x0c0a, 0x000b, 0x15fe,
+	0x0008, 0x340a, 0x0003, 0xc4c0, 0x0009, 0x7000, 0x0000, 0xffa0,
+	0x0001, 0x2000, 0x0000, 0x1627, 0x0003, 0x808c, 0x0008, 0x0001,
+	0x0000, 0x0000, 0x0007, 0x4047, 0x000a, 0x808c, 0x0008, 0x0002,
+	0x0000, 0x0821, 0x0003, 0x4022, 0x0000, 0x0022, 0x000b, 0x4122,
+	0x0008, 0x4447, 0x0002, 0x0e4f, 0x000b, 0x0bfe, 0x0008, 0x11a0,
+	0x0001, 0x122d, 0x000b, 0x0ca0, 0x0001, 0x122d, 0x000b, 0x9180,
+	0x0001, 0x0004, 0x0000, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62,
+	0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x4430, 0x000b, 0x808c,
+	0x0008, 0x0000, 0x0008, 0x0060, 0x0008, 0x8062, 0x0008, 0x0004,
+	0x0000, 0x8066, 0x0000, 0x0411, 0x0000, 0x4438, 0x0003, 0x03fe,
+	0x0000, 0x43e0, 0x0001, 0x0e2a, 0x000b, 0xc2c0, 0x0009, 0x00ff,
+	0x0008, 0x02e0, 0x0001, 0x0e2a, 0x000b, 0x9180, 0x0001, 0x0005,
+	0x0008, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62, 0x0008, 0x8066,
+	0x0000, 0x0019, 0x0000, 0x4447, 0x000b, 0x0240, 0x0002, 0x0a27,
+	0x000b, 0x00fe, 0x0000, 0x322a, 0x000b, 0x112a, 0x0000, 0x002e,
+	0x0008, 0x022c, 0x0008, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x808c,
+	0x0008, 0x0002, 0x0000, 0x1760, 0x0008, 0x8062, 0x0008, 0x000f,
+	0x0008, 0x8066, 0x0000, 0x0011, 0x0008, 0x4458, 0x0003, 0x01fe,
+	0x0008, 0x42e0, 0x0009, 0x0e1d, 0x0003, 0x00fe, 0x0000, 0x43e0,
+	0x0001, 0x0e1d, 0x0003, 0x1734, 0x0000, 0x1530, 0x0000, 0x1632,
+	0x0008, 0x0d2a, 0x0008, 0x9880, 0x0001, 0x0010, 0x0000, 0x8060,
+	0x0000, 0x0400, 0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x1e0a,
+	0x0008, 0x446a, 0x000b, 0x808a, 0x0008, 0x0003, 0x0008, 0x1a60,
+	0x0000, 0x8062, 0x0008, 0x0002, 0x0000, 0x5870, 0x000b, 0x8066,
+	0x0000, 0x3679, 0x0000, 0x4473, 0x0003, 0x5874, 0x0003, 0x3efe,
+	0x0008, 0x7f4f, 0x0002, 0x087a, 0x000b, 0x0d00, 0x0000, 0x0082,
+	0x0004, 0x8054, 0x0008, 0x0011, 0x0008, 0x8074, 0x0000, 0x1010,
+	0x0008, 0x1efe, 0x0000, 0x300a, 0x000b, 0x00b8, 0x0004, 0x000a,
+	0x000b, 0x00fe, 0x0000, 0x348a, 0x000b, 0x1a60, 0x0000, 0x8062,
+	0x0008, 0x0007, 0x0000, 0x8066, 0x0000, 0x0231, 0x0008, 0x4489,
+	0x0003, 0x03fe, 0x0000, 0x04d0, 0x0001, 0x0cb0, 0x0003, 0x82c0,
+	0x0001, 0x1f00, 0x0000, 0xffa0, 0x0001, 0x0400, 0x0000, 0x089f,
+	0x0003, 0x14b0, 0x0003, 0x01fe, 0x0008, 0x0580, 0x0009, 0x7f06,
+	0x0000, 0x02fe, 0x0008, 0xffc0, 0x0001, 0x00ff, 0x0008, 0x0690,
+	0x0001, 0x109f, 0x0003, 0x7f08, 0x0008, 0x84c0, 0x0001, 0xff00,
+	0x0008, 0x08b0, 0x000b, 0x00fe, 0x0000, 0x34a6, 0x0003, 0x8072,
+	0x0000, 0x1010, 0x0008, 0x3944, 0x0002, 0x08a1, 0x000b, 0x00aa,
+	0x000b, 0x8072, 0x0000, 0x2020, 0x0008, 0x3945, 0x000a, 0x08a6,
+	0x0003, 0x3946, 0x000a, 0x0cb7, 0x000b, 0x0000, 0x0007, 0x3943,
+	0x000a, 0x08b7, 0x0003, 0x00aa, 0x000b, 0x00fe, 0x0000, 0x34b5,
+	0x000b, 0x8072, 0x0000, 0x1000, 0x0000, 0x00b7, 0x000b, 0x8072,
+	0x0000, 0x2000, 0x0000, 0x4000, 0x000f, 0x1c60, 0x0000, 0x1b62,
+	0x0000, 0x8066, 0x0000, 0x0231, 0x0008, 0x44bc, 0x0003, 0x58bd,
+	0x0003, 0x0140, 0x0008, 0x0242, 0x0000, 0x1f43, 0x0002, 0x0ccb,
+	0x0003, 0x0d44, 0x0000, 0x0d46, 0x0008, 0x0348, 0x0008, 0x044a,
+	0x0008, 0x030a, 0x0008, 0x040c, 0x0000, 0x0d06, 0x0000, 0x0d08,
+	0x0008, 0x00cf, 0x000b, 0x0344, 0x0008, 0x0446, 0x0008, 0x0548,
+	0x0008, 0x064a, 0x0000, 0x58cf, 0x0003, 0x3efe, 0x0008, 0x7f4f,
+	0x0002, 0x08d6, 0x000b, 0x8000, 0x0000, 0x0001, 0x0000, 0x0082,
+	0x0004, 0x8054, 0x0008, 0x0001, 0x0000, 0x8074, 0x0000, 0x2020,
+	0x0008, 0x4000, 0x000f, 0x3a40, 0x000a, 0x0c0d, 0x0003, 0x2b24,
+	0x0008, 0x2b24, 0x0008, 0x58df, 0x000b, 0x8054, 0x0008, 0x0002,
+	0x0000, 0x1242, 0x0002, 0x092d, 0x000b, 0x3a45, 0x000a, 0x091c,
+	0x0003, 0x8072, 0x0000, 0x1000, 0x0000, 0x3945, 0x000a, 0x08ec,
+	0x000b, 0x8072, 0x0000, 0x3010, 0x0000, 0x1e10, 0x000a, 0x7f3c,
+	0x0000, 0x0917, 0x000b, 0x1d00, 0x0002, 0x7f3a, 0x0000, 0x0d60,
+	0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x44f5,
+	0x000b, 0x00fe, 0x0000, 0x3514, 0x000b, 0x1c60, 0x0000, 0x8062,
+	0x0008, 0x0001, 0x0000, 0x8066, 0x0000, 0x0009, 0x0008, 0x44fd,
+	0x0003, 0x00fe, 0x0000, 0x3204, 0x000b, 0x0038, 0x0000, 0x0060,
+	0x0008, 0x8062, 0x0008, 0x0019, 0x0000, 0x8066, 0x0000, 0x0009,
+	0x0008, 0x4506, 0x0003, 0x80c0, 0x0009, 0x00ff, 0x0008, 0x7f3e,
+	0x0008, 0x0d60, 0x0000, 0x0efe, 0x0008, 0x1f80, 0x0001, 0x7f62,
+	0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x4510, 0x000b, 0x003a,
+	0x0008, 0x1dfe, 0x0000, 0x00f1, 0x0003, 0x0036, 0x0008, 0x00b8,
+	0x0004, 0x012d, 0x0003, 0x8074, 0x0000, 0x2000, 0x0000, 0x8072,
+	0x0000, 0x2000, 0x0000, 0x012d, 0x0003, 0x3a44, 0x0002, 0x0a30,
+	0x000b, 0x8074, 0x0000, 0x1000, 0x0000, 0x8072, 0x0000, 0x1000,
+	0x0000, 0x2d0e, 0x0000, 0x2d0e, 0x0000, 0x3601, 0x0003, 0x26fe,
+	0x0008, 0x26fe, 0x0008, 0x2700, 0x0008, 0x2700, 0x0008, 0x00d0,
+	0x0009, 0x0d3f, 0x0003, 0x8074, 0x0000, 0x4040, 0x0008, 0x592d,
+	0x000b, 0x50db, 0x000b, 0x3a46, 0x000a, 0x0d3f, 0x0003, 0x3a47,
+	0x0002, 0x093a, 0x000b, 0x8054, 0x0008, 0x0004, 0x0000, 0x8074,
+	0x0000, 0x8000, 0x0000, 0x8072, 0x0000, 0x3000, 0x0008, 0x0182,
+	0x0003, 0x92c0, 0x0009, 0x0fc8, 0x0000, 0x080a, 0x0003, 0x1246,
+	0x000a, 0x0dfb, 0x000b, 0x1a60, 0x0000, 0x8062, 0x0008, 0x0002,
+	0x0000, 0x8066, 0x0000, 0x362a, 0x0000, 0x4544, 0x0003, 0x2000,
+	0x0000, 0x2000, 0x0000, 0x2102, 0x0000, 0x2102, 0x0000, 0x2204,
+	0x0000, 0x2204, 0x0000, 0x2306, 0x0000, 0x2306, 0x0000, 0x2408,
+	0x0000, 0x2408, 0x0000, 0x250a, 0x0000, 0x250a, 0x0000, 0x260c,
+	0x0000, 0x260c, 0x0000, 0x270e, 0x0000, 0x270e, 0x0000, 0x2810,
+	0x0000, 0x2810, 0x0000, 0x2912, 0x0000, 0x2912, 0x0000, 0x1a60,
+	0x0000, 0x8062, 0x0008, 0x0007, 0x0000, 0x8066, 0x0000, 0x0052,
+	0x0000, 0x455e, 0x000b, 0x92c0, 0x0009, 0x0780, 0x0008, 0x0e17,
+	0x0003, 0x124b, 0x0002, 0x0967, 0x0003, 0x2e4d, 0x0002, 0x2e4d,
+	0x0002, 0x0a01, 0x0003, 0x3a46, 0x000a, 0x0d74, 0x0003, 0x5969,
+	0x000b, 0x8054, 0x0008, 0x0004, 0x0000, 0x1243, 0x000a, 0x097e,
+	0x000b, 0x8010, 0x0008, 0x000d, 0x0000, 0x01ef, 0x0004, 0x1810,
+	0x0000, 0x01ef, 0x0004, 0x017e, 0x0003, 0x194d, 0x000a, 0x0978,
+	0x000b, 0x1243, 0x000a, 0x0a0b, 0x0003, 0x5978, 0x000b, 0x8054,
+	0x0008, 0x0004, 0x0000, 0x01e4, 0x000c, 0x1810, 0x0000, 0x01ef,
+	0x0004, 0x8074, 0x0000, 0xf000, 0x0008, 0x8072, 0x0000, 0x3000,
+	0x0008, 0x0d30, 0x0000, 0x3a42, 0x0002, 0x0d88, 0x0003, 0x15fe,
+	0x0008, 0x3451, 0x000b, 0x000a, 0x000b, 0x8074, 0x0000, 0x0501,
+	0x0000, 0x8010, 0x0008, 0x000c, 0x0008, 0x01ef, 0x0004, 0x000a,
+	0x000b, 0xbbe0, 0x0009, 0x0030, 0x0008, 0x0d9e, 0x000b, 0x18fe,
+	0x0000, 0x3ce0, 0x0009, 0x099b, 0x0003, 0x15fe, 0x0008, 0x3ce0,
+	0x0009, 0x099b, 0x0003, 0x01df, 0x0004, 0x8076, 0x0008, 0x0040,
+	0x0000, 0x01dc, 0x000b, 0x8076, 0x0008, 0x0041, 0x0008, 0x01dc,
+	0x000b, 0xbbe0, 0x0009, 0x0032, 0x0000, 0x0da3, 0x0003, 0x3c1e,
+	0x0008, 0x01dc, 0x000b, 0xbbe0, 0x0009, 0x0037, 0x0000, 0x0dc1,
+	0x000b, 0x18fe, 0x0000, 0x3ce0, 0x0009, 0x0d9b, 0x000b, 0x8076,
+	0x0008, 0x0040, 0x0000, 0x1a60, 0x0000, 0x8062, 0x0008, 0x000d,
+	0x0000, 0x2604, 0x0008, 0x2604, 0x0008, 0x2706, 0x0008, 0x2706,
+	0x0008, 0x2808, 0x0000, 0x2808, 0x0000, 0x290a, 0x0000, 0x290a,
+	0x0000, 0x8066, 0x0000, 0x0422, 0x0000, 0x45b8, 0x0003, 0x01e4,
+	0x000c, 0x8054, 0x0008, 0x0004, 0x0000, 0x8074, 0x0000, 0xf000,
+	0x0008, 0x8072, 0x0000, 0xb000, 0x0000, 0x0182, 0x0003, 0xbbe0,
+	0x0009, 0x0038, 0x0000, 0x0dd3, 0x000b, 0x18fe, 0x0000, 0x3ce0,
+	0x0009, 0x09d0, 0x0003, 0x15fe, 0x0008, 0x3ce0, 0x0009, 0x0d97,
+	0x000b, 0x01df, 0x0004, 0x8076, 0x0008, 0x0040, 0x0000, 0x8072,
+	0x0000, 0x8000, 0x0000, 0x0227, 0x0003, 0x8076, 0x0008, 0x0042,
+	0x0008, 0x01dc, 0x000b, 0xbbe0, 0x0009, 0x0016, 0x0000, 0x0ddc,
+	0x000b, 0x3a44, 0x0002, 0x0c0c, 0x000b, 0x8072, 0x0000, 0x8000,
+	0x0000, 0x8000, 0x000f, 0x000a, 0x000b, 0x8072, 0x0000, 0x8000,
+	0x0000, 0x000a, 0x000b, 0x3d30, 0x000a, 0x7f00, 0x0000, 0xbc80,
+	0x0001, 0x0007, 0x0000, 0x01e8, 0x0003, 0x1930, 0x000a, 0x7f00,
+	0x0000, 0x9880, 0x0001, 0x0007, 0x0000, 0x8060, 0x0000, 0x0400,
+	0x0000, 0x7f62, 0x0008, 0x8066, 0x0000, 0x000a, 0x0008, 0x45ed,
+	0x0003, 0x4000, 0x000f, 0x21ef, 0x0003, 0x0870, 0x0008, 0x4000,
+	0x000f, 0xbac0, 0x0009, 0x0090, 0x0008, 0x09f8, 0x0003, 0x8074,
+	0x0000, 0x0706, 0x0000, 0x01fa, 0x0003, 0x8074, 0x0000, 0x0703,
+	0x0000, 0x4000, 0x000f, 0x8010, 0x0008, 0x0023, 0x0000, 0x0235,
+	0x0003, 0x8010, 0x0008, 0x0008, 0x0000, 0x0235, 0x0003, 0x8010,
+	0x0008, 0x0022, 0x0008, 0x0235, 0x0003, 0x01e4, 0x000c, 0x8010,
+	0x0008, 0x0007, 0x0000, 0x01ef, 0x0004, 0x1810, 0x0000, 0x01ef,
+	0x0004, 0x0241, 0x0003, 0x01e4, 0x000c, 0x8010, 0x0008, 0x001b,
+	0x0008, 0x01ef, 0x0004, 0x1810, 0x0000, 0x01ef, 0x0004, 0x8074,
+	0x0000, 0xf080, 0x0000, 0x8072, 0x0000, 0x3000, 0x0008, 0x0d30,
+	0x0000, 0x000a, 0x000b, 0x8010, 0x0008, 0x0009, 0x0008, 0x0235,
+	0x0003, 0x8010, 0x0008, 0x0005, 0x0008, 0x0235, 0x0003, 0x808c,
+	0x0008, 0x0001, 0x0000, 0x8010, 0x0008, 0x0004, 0x0000, 0x4143,
+	0x000a, 0x085f, 0x0003, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x0d2a,
+	0x0008, 0x0235, 0x0003, 0x8010, 0x0008, 0x0003, 0x0008, 0x0239,
+	0x0003, 0x8010, 0x0008, 0x000b, 0x0000, 0x0239, 0x0003, 0x8010,
+	0x0008, 0x0002, 0x0000, 0x0239, 0x0003, 0x3a47, 0x0002, 0x0d2d,
+	0x0003, 0x8010, 0x0008, 0x0006, 0x0008, 0x0239, 0x0003, 0x8074,
+	0x0000, 0xf000, 0x0008, 0x8072, 0x0000, 0x3000, 0x0008, 0x01ef,
+	0x0004, 0x01f2, 0x0004, 0x3a40, 0x000a, 0x080a, 0x0003, 0x8010,
+	0x0008, 0x000c, 0x0008, 0x01ef, 0x0004, 0x000a, 0x000b, 0x8074,
+	0x0000, 0xf080, 0x0000, 0x8072, 0x0000, 0x3000, 0x0008, 0x0d30,
+	0x0000, 0x2e4d, 0x0002, 0x2e4d, 0x0002, 0x0a4c, 0x0003, 0x8054,
+	0x0008, 0x0019, 0x0000, 0x000a, 0x000b, 0x8054, 0x0008, 0x0009,
+	0x0008, 0x000a, 0x000b, 0x3a44, 0x0002, 0x0c0a, 0x000b, 0x022a,
+	0x000b, 0x15b6, 0xf4ac, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010,
+	0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000,
+	0x2000, 0x4000, 0x8000, 0x2a9a
 };
 #ifdef UNIQUE_FW_NAME
-unsigned short fw2300flx_length01 = 0xd5bb;
+unsigned short fw2300flx_length01 = 0xd5d4;
 #else
-unsigned short risc_code_length01 = 0xd5bb;
+unsigned short risc_code_length01 = 0xd5d4;
 #endif
 
diff -Nru a/drivers/scsi/qla2xxx/ql6322_fw.c b/drivers/scsi/qla2xxx/ql6322_fw.c
--- a/drivers/scsi/qla2xxx/ql6322_fw.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/scsi/qla2xxx/ql6322_fw.c	2004-12-24 13:37:30 -08:00
@@ -18,25 +18,25 @@
  *************************************************************************/
 
 /*
- *	Firmware Version 3.02.30 (07:56 Jun 16, 2004)
+ *	Firmware Version 3.03.02 (16:54 Aug 10, 2004)
  */
 
 #ifdef UNIQUE_FW_NAME
-unsigned short fw2322flx_version = 3*1024+2;
+unsigned short fw2322flx_version = 3*1024+3;
 #else
-unsigned short risc_code_version = 3*1024+2;
+unsigned short risc_code_version = 3*1024+3;
 #endif
 
 #ifdef UNIQUE_FW_NAME
-unsigned char fw2322flx_version_str[] = {3, 2,30};
+unsigned char fw2322flx_version_str[] = {3, 3, 2};
 #else
-unsigned char firmware_version[] = {3, 2,30};
+unsigned char firmware_version[] = {3, 3, 2};
 #endif
 
 #ifdef UNIQUE_FW_NAME
-#define fw2322flx_VERSION_STRING "3.02.30"
+#define fw2322flx_VERSION_STRING "3.03.02"
 #else
-#define FW_VERSION_STRING "3.02.30"
+#define FW_VERSION_STRING "3.03.02"
 #endif
 
 #ifdef UNIQUE_FW_NAME
@@ -50,12 +50,12 @@
 #else
 unsigned short risc_code01[] = { 
 #endif
-	0x0470, 0x0000, 0x0000, 0xce4c, 0x0000, 0x0003, 0x0002, 0x001e,
+	0x0470, 0x0000, 0x0000, 0xce84, 0x0000, 0x0003, 0x0003, 0x0002,
 	0x0317, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2032, 0x3030,
 	0x3120, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
 	0x5449, 0x4f4e, 0x2049, 0x5350, 0x3233, 0x3030, 0x2046, 0x6972,
 	0x6d77, 0x6172, 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030,
-	0x332e, 0x3032, 0x2e33, 0x3020, 0x2020, 0x2020, 0x2400, 0x20a9,
+	0x332e, 0x3033, 0x2e30, 0x3220, 0x2020, 0x2020, 0x2400, 0x20a9,
 	0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2200, 0x20a9, 0x000f,
 	0x2001, 0x0000, 0x400f, 0x2091, 0x2400, 0x20a9, 0x000f, 0x2001,
 	0x0000, 0x400f, 0x2091, 0x2600, 0x20a9, 0x000f, 0x2001, 0x0000,
@@ -64,161 +64,161 @@
 	0x2c00, 0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2e00,
 	0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2000, 0x2001,
 	0x0000, 0x20c1, 0x0004, 0x20c9, 0x1cff, 0x2059, 0x0000, 0x2b78,
-	0x7883, 0x0004, 0x2089, 0x28ec, 0x2051, 0x1800, 0x2a70, 0x20e1,
-	0x0001, 0x20e9, 0x0001, 0x2009, 0x0000, 0x080c, 0x0e3d, 0x00f6,
-	0x7888, 0x9005, 0x11f8, 0x2061, 0xc000, 0x080c, 0x1f09, 0x1170,
-	0x2079, 0x0300, 0x080c, 0x1f1f, 0x2061, 0xe000, 0x080c, 0x1f09,
-	0x1128, 0x2079, 0x0380, 0x080c, 0x1f1f, 0x0060, 0x00fe, 0x7883,
+	0x7883, 0x0004, 0x2089, 0x290c, 0x2051, 0x1800, 0x2a70, 0x20e1,
+	0x0001, 0x20e9, 0x0001, 0x2009, 0x0000, 0x080c, 0x0e4a, 0x00f6,
+	0x7888, 0x9005, 0x11f8, 0x2061, 0xc000, 0x080c, 0x1f21, 0x1170,
+	0x2079, 0x0300, 0x080c, 0x1f37, 0x2061, 0xe000, 0x080c, 0x1f21,
+	0x1128, 0x2079, 0x0380, 0x080c, 0x1f37, 0x0060, 0x00fe, 0x7883,
 	0x4010, 0x7837, 0x4010, 0x7833, 0x0010, 0x2091, 0x5000, 0x2091,
 	0x4080, 0x0cf8, 0x00fe, 0x2029, 0x26c0, 0x2031, 0xffff, 0x2039,
 	0x269c, 0x2021, 0x0050, 0x20e9, 0x0001, 0x20a1, 0x0000, 0x20a9,
 	0x0800, 0x900e, 0x4104, 0x20e9, 0x0001, 0x20a1, 0x1000, 0x900e,
 	0x2001, 0x0dc1, 0x9084, 0x0fff, 0x20a8, 0x4104, 0x2001, 0x0000,
 	0x9086, 0x0000, 0x0120, 0x21a8, 0x4104, 0x8001, 0x1de0, 0x756a,
-	0x766e, 0x7766, 0x7472, 0x7476, 0x00e6, 0x2071, 0x1b1d, 0x2472,
+	0x766e, 0x7766, 0x7472, 0x7476, 0x00e6, 0x2071, 0x1b25, 0x2472,
 	0x00ee, 0x20a1, 0x1ddc, 0x716c, 0x810d, 0x810d, 0x810d, 0x810d,
 	0x918c, 0x000f, 0x2001, 0x0001, 0x9112, 0x900e, 0x21a8, 0x4104,
 	0x8211, 0x1de0, 0x716c, 0x3400, 0x8001, 0x9102, 0x0120, 0x0218,
 	0x20a8, 0x900e, 0x4104, 0x2009, 0x1800, 0x810d, 0x810d, 0x810d,
 	0x810d, 0x810d, 0x918c, 0x001f, 0x2001, 0x0001, 0x9112, 0x20e9,
 	0x0001, 0x20a1, 0x0800, 0x900e, 0x20a9, 0x0800, 0x4104, 0x8211,
-	0x1dd8, 0x080c, 0x0f3a, 0x080c, 0x5ce5, 0x080c, 0x9b70, 0x080c,
-	0x10f1, 0x080c, 0x12e1, 0x080c, 0x1a67, 0x080c, 0x8422, 0x080c,
-	0x0cf7, 0x080c, 0x1076, 0x080c, 0x327f, 0x080c, 0x73aa, 0x080c,
-	0x6721, 0x080c, 0x8069, 0x080c, 0x20f6, 0x080c, 0x7a3e, 0x080c,
-	0x1f38, 0x080c, 0x2076, 0x080c, 0x20eb, 0x2091, 0x3009, 0x7883,
+	0x1dd8, 0x080c, 0x0f47, 0x080c, 0x5d05, 0x080c, 0x9b7c, 0x080c,
+	0x10fe, 0x080c, 0x12ee, 0x080c, 0x1a7f, 0x080c, 0x8456, 0x080c,
+	0x0cf7, 0x080c, 0x1083, 0x080c, 0x329f, 0x080c, 0x73cd, 0x080c,
+	0x6745, 0x080c, 0x809d, 0x080c, 0x210e, 0x080c, 0x7a62, 0x080c,
+	0x1f50, 0x080c, 0x208e, 0x080c, 0x2103, 0x2091, 0x3009, 0x7883,
 	0x0000, 0x1004, 0x0941, 0x7880, 0x9086, 0x0002, 0x1190, 0x7883,
 	0x4000, 0x7837, 0x4000, 0x7833, 0x0010, 0x0e04, 0x0935, 0x2091,
 	0x5000, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
-	0x11c9, 0x2071, 0x1800, 0x7003, 0x0000, 0x2071, 0x1800, 0x7000,
-	0x908e, 0x0003, 0x1158, 0x080c, 0x499f, 0x080c, 0x32a6, 0x080c,
-	0x7412, 0x080c, 0x6bb9, 0x080c, 0x8092, 0x0c78, 0x000b, 0x0c98,
+	0x11d6, 0x2071, 0x1800, 0x7003, 0x0000, 0x2071, 0x1800, 0x7000,
+	0x908e, 0x0003, 0x1158, 0x080c, 0x49bf, 0x080c, 0x32c6, 0x080c,
+	0x7435, 0x080c, 0x6bdd, 0x080c, 0x80c6, 0x0c78, 0x000b, 0x0c98,
 	0x0962, 0x0963, 0x0afa, 0x0960, 0x0bab, 0x0cf6, 0x0cf6, 0x0cf6,
 	0x080c, 0x0d65, 0x0005, 0x0126, 0x00f6, 0x2091, 0x8000, 0x7000,
-	0x9086, 0x0001, 0x1904, 0x0acd, 0x080c, 0x0e8d, 0x080c, 0x7096,
-	0x0150, 0x080c, 0x70b9, 0x15b0, 0x2079, 0x0100, 0x7828, 0x9085,
-	0x1800, 0x782a, 0x0478, 0x080c, 0x6fc7, 0x7000, 0x9086, 0x0001,
+	0x9086, 0x0001, 0x1904, 0x0acd, 0x080c, 0x0e9a, 0x080c, 0x70ba,
+	0x0150, 0x080c, 0x70dd, 0x15b0, 0x2079, 0x0100, 0x7828, 0x9085,
+	0x1800, 0x782a, 0x0478, 0x080c, 0x6feb, 0x7000, 0x9086, 0x0001,
 	0x1904, 0x0acd, 0x7094, 0x9086, 0x0028, 0x1904, 0x0acd, 0x080c,
-	0x8061, 0x080c, 0x8053, 0x2001, 0x0161, 0x2003, 0x0001, 0x2079,
-	0x0100, 0x2011, 0xffff, 0x080c, 0x288c, 0x7a28, 0x9295, 0x5e2c,
-	0x7a2a, 0x2011, 0x6f0c, 0x080c, 0x8138, 0x2011, 0x6eff, 0x080c,
-	0x823e, 0x2011, 0x5b3c, 0x080c, 0x8138, 0x2011, 0x8030, 0x901e,
-	0x7392, 0x04d0, 0x080c, 0x53e9, 0x2079, 0x0100, 0x7844, 0x9005,
-	0x1904, 0x0acd, 0x2011, 0x5b3c, 0x080c, 0x8138, 0x2011, 0x6f0c,
-	0x080c, 0x8138, 0x2011, 0x6eff, 0x080c, 0x823e, 0x2001, 0x0265,
+	0x8095, 0x080c, 0x8087, 0x2001, 0x0161, 0x2003, 0x0001, 0x2079,
+	0x0100, 0x2011, 0xffff, 0x080c, 0x28ac, 0x7a28, 0x9295, 0x5e2c,
+	0x7a2a, 0x2011, 0x6f30, 0x080c, 0x816c, 0x2011, 0x6f23, 0x080c,
+	0x8272, 0x2011, 0x5b5c, 0x080c, 0x816c, 0x2011, 0x8030, 0x901e,
+	0x7392, 0x04d0, 0x080c, 0x5409, 0x2079, 0x0100, 0x7844, 0x9005,
+	0x1904, 0x0acd, 0x2011, 0x5b5c, 0x080c, 0x816c, 0x2011, 0x6f30,
+	0x080c, 0x816c, 0x2011, 0x6f23, 0x080c, 0x8272, 0x2001, 0x0265,
 	0x2001, 0x0205, 0x2003, 0x0000, 0x7840, 0x9084, 0xfffb, 0x7842,
-	0x2001, 0x1976, 0x2004, 0x9005, 0x1140, 0x00c6, 0x2061, 0x0100,
-	0x080c, 0x5c8d, 0x00ce, 0x0804, 0x0acd, 0x780f, 0x006b, 0x7a28,
-	0x080c, 0x709e, 0x0118, 0x9295, 0x5e2c, 0x0010, 0x9295, 0x402c,
-	0x7a2a, 0x2011, 0x8010, 0x73d4, 0x2001, 0x1977, 0x2003, 0x0001,
-	0x080c, 0x2758, 0x080c, 0x48da, 0x7244, 0xc284, 0x7246, 0x2001,
+	0x2001, 0x197e, 0x2004, 0x9005, 0x1140, 0x00c6, 0x2061, 0x0100,
+	0x080c, 0x5cad, 0x00ce, 0x0804, 0x0acd, 0x780f, 0x006b, 0x7a28,
+	0x080c, 0x70c2, 0x0118, 0x9295, 0x5e2c, 0x0010, 0x9295, 0x402c,
+	0x7a2a, 0x2011, 0x8010, 0x73d4, 0x2001, 0x197f, 0x2003, 0x0001,
+	0x080c, 0x2774, 0x080c, 0x48fa, 0x7244, 0xc284, 0x7246, 0x2001,
 	0x180c, 0x200c, 0xc1ac, 0xc1cc, 0x2102, 0x2001, 0x0390, 0x2003,
-	0x0400, 0x080c, 0x98bb, 0x080c, 0x91c4, 0x2011, 0x0004, 0x080c,
-	0xb852, 0x080c, 0x98d7, 0x080c, 0x6561, 0x080c, 0x7096, 0x1120,
-	0x080c, 0x27b9, 0x0600, 0x0420, 0x080c, 0x5c94, 0x0140, 0x7093,
-	0x0001, 0x70cf, 0x0000, 0x080c, 0x55b6, 0x0804, 0x0acd, 0x080c,
-	0x5388, 0xd094, 0x01a8, 0x2001, 0x0390, 0x2003, 0x0404, 0x2011,
-	0x180c, 0x2204, 0xc0cd, 0x2012, 0x080c, 0x538c, 0xd0d4, 0x1118,
-	0x080c, 0x27b9, 0x1270, 0x2011, 0x180c, 0x2204, 0xc0bc, 0x0088,
-	0x080c, 0x538c, 0xd0d4, 0x1db8, 0x2011, 0x180c, 0x2204, 0xc0bd,
-	0x0040, 0x2011, 0x180c, 0x2204, 0xc0bd, 0x2012, 0x080c, 0x665e,
-	0x0008, 0x2012, 0x080c, 0x6624, 0x0120, 0x7a0c, 0xc2b4, 0x7a0e,
-	0x00a8, 0x707b, 0x0000, 0x080c, 0x7096, 0x1130, 0x70ac, 0x9005,
-	0x1168, 0x080c, 0xbcae, 0x0050, 0x080c, 0xbcae, 0x70d8, 0xd09c,
-	0x1128, 0x70ac, 0x9005, 0x0110, 0x080c, 0x5c6a, 0x70e3, 0x0000,
-	0x70df, 0x0000, 0x70a3, 0x0000, 0x080c, 0x27c1, 0x0228, 0x2011,
-	0x0101, 0x2204, 0xc0c4, 0x2012, 0x72d8, 0x080c, 0x7096, 0x1178,
-	0x9016, 0x0016, 0x2009, 0x0002, 0x2019, 0x193d, 0x211a, 0x001e,
+	0x0400, 0x080c, 0x98c7, 0x080c, 0x91f8, 0x2011, 0x0004, 0x080c,
+	0xb880, 0x080c, 0x98e3, 0x080c, 0x6585, 0x080c, 0x70ba, 0x1120,
+	0x080c, 0x27d5, 0x0600, 0x0420, 0x080c, 0x5cb4, 0x0140, 0x7093,
+	0x0001, 0x70cf, 0x0000, 0x080c, 0x55d6, 0x0804, 0x0acd, 0x080c,
+	0x53a8, 0xd094, 0x01a8, 0x2001, 0x0390, 0x2003, 0x0404, 0x2011,
+	0x180c, 0x2204, 0xc0cd, 0x2012, 0x080c, 0x53ac, 0xd0d4, 0x1118,
+	0x080c, 0x27d5, 0x1270, 0x2011, 0x180c, 0x2204, 0xc0bc, 0x0088,
+	0x080c, 0x53ac, 0xd0d4, 0x1db8, 0x2011, 0x180c, 0x2204, 0xc0bd,
+	0x0040, 0x2011, 0x180c, 0x2204, 0xc0bd, 0x2012, 0x080c, 0x6682,
+	0x0008, 0x2012, 0x080c, 0x6648, 0x0120, 0x7a0c, 0xc2b4, 0x7a0e,
+	0x00a8, 0x707b, 0x0000, 0x080c, 0x70ba, 0x1130, 0x70ac, 0x9005,
+	0x1168, 0x080c, 0xbcdc, 0x0050, 0x080c, 0xbcdc, 0x70d8, 0xd09c,
+	0x1128, 0x70ac, 0x9005, 0x0110, 0x080c, 0x5c8a, 0x70e3, 0x0000,
+	0x70df, 0x0000, 0x70a3, 0x0000, 0x080c, 0x27dd, 0x0228, 0x2011,
+	0x0101, 0x2204, 0xc0c4, 0x2012, 0x72d8, 0x080c, 0x70ba, 0x1178,
+	0x9016, 0x0016, 0x2009, 0x0002, 0x2019, 0x1945, 0x211a, 0x001e,
 	0x705b, 0xffff, 0x705f, 0x00ef, 0x707f, 0x0000, 0x0020, 0x2019,
-	0x193d, 0x201b, 0x0000, 0x2079, 0x1853, 0x7804, 0xd0ac, 0x0108,
-	0xc295, 0x72da, 0x080c, 0x7096, 0x0118, 0x9296, 0x0004, 0x0518,
-	0x2011, 0x0001, 0x080c, 0xb852, 0x70a7, 0x0000, 0x70ab, 0xffff,
-	0x7003, 0x0002, 0x00fe, 0x080c, 0x2de9, 0x080c, 0x98bb, 0x2011,
-	0x0005, 0x080c, 0x931c, 0x080c, 0x98d7, 0x080c, 0x7096, 0x0148,
+	0x1945, 0x201b, 0x0000, 0x2079, 0x185b, 0x7804, 0xd0ac, 0x0108,
+	0xc295, 0x72da, 0x080c, 0x70ba, 0x0118, 0x9296, 0x0004, 0x0518,
+	0x2011, 0x0001, 0x080c, 0xb880, 0x70a7, 0x0000, 0x70ab, 0xffff,
+	0x7003, 0x0002, 0x00fe, 0x080c, 0x2e09, 0x080c, 0x98c7, 0x2011,
+	0x0005, 0x080c, 0x9324, 0x080c, 0x98e3, 0x080c, 0x70ba, 0x0148,
 	0x00c6, 0x2061, 0x0100, 0x0016, 0x2009, 0x0002, 0x61e2, 0x001e,
 	0x00ce, 0x012e, 0x00e0, 0x70a7, 0x0000, 0x70ab, 0xffff, 0x7003,
-	0x0002, 0x080c, 0x98bb, 0x2011, 0x0005, 0x080c, 0x931c, 0x080c,
-	0x98d7, 0x080c, 0x7096, 0x0148, 0x00c6, 0x2061, 0x0100, 0x0016,
+	0x0002, 0x080c, 0x98c7, 0x2011, 0x0005, 0x080c, 0x9324, 0x080c,
+	0x98e3, 0x080c, 0x70ba, 0x0148, 0x00c6, 0x2061, 0x0100, 0x0016,
 	0x2009, 0x0002, 0x61e2, 0x001e, 0x00ce, 0x00fe, 0x012e, 0x0005,
-	0x00c6, 0x00b6, 0x080c, 0x7096, 0x1118, 0x20a9, 0x0800, 0x0010,
-	0x20a9, 0x0782, 0x080c, 0x7096, 0x1110, 0x900e, 0x0010, 0x2009,
+	0x00c6, 0x00b6, 0x080c, 0x70ba, 0x1118, 0x20a9, 0x0800, 0x0010,
+	0x20a9, 0x0782, 0x080c, 0x70ba, 0x1110, 0x900e, 0x0010, 0x2009,
 	0x007e, 0x86ff, 0x0138, 0x9180, 0x1000, 0x2004, 0x905d, 0x0110,
-	0xb800, 0xd0bc, 0x090c, 0x3116, 0x8108, 0x1f04, 0x0ae1, 0x707b,
+	0xb800, 0xd0bc, 0x090c, 0x3136, 0x8108, 0x1f04, 0x0ae1, 0x707b,
 	0x0000, 0x707c, 0x9084, 0x00ff, 0x707e, 0x70af, 0x0000, 0x00be,
 	0x00ce, 0x0005, 0x00b6, 0x0126, 0x2091, 0x8000, 0x7000, 0x9086,
 	0x0002, 0x1904, 0x0ba8, 0x70a8, 0x9086, 0xffff, 0x0120, 0x080c,
-	0x2de9, 0x0804, 0x0ba8, 0x70d8, 0xd0ac, 0x1110, 0xd09c, 0x0520,
+	0x2e09, 0x0804, 0x0ba8, 0x70d8, 0xd0ac, 0x1110, 0xd09c, 0x0520,
 	0xd084, 0x0510, 0x0006, 0x2001, 0x0103, 0x2003, 0x002b, 0x000e,
-	0xd08c, 0x01d0, 0x70dc, 0x9086, 0xffff, 0x0190, 0x080c, 0x2f74,
-	0x70d8, 0xd094, 0x1904, 0x0ba8, 0x2011, 0x0001, 0x080c, 0xbf61,
-	0x0110, 0x2011, 0x0003, 0x901e, 0x080c, 0x2fae, 0x0804, 0x0ba8,
+	0xd08c, 0x01d0, 0x70dc, 0x9086, 0xffff, 0x0190, 0x080c, 0x2f94,
+	0x70d8, 0xd094, 0x1904, 0x0ba8, 0x2011, 0x0001, 0x080c, 0xbf8f,
+	0x0110, 0x2011, 0x0003, 0x901e, 0x080c, 0x2fce, 0x0804, 0x0ba8,
 	0x70e0, 0x9005, 0x1904, 0x0ba8, 0x70a4, 0x9005, 0x1904, 0x0ba8,
-	0x70d8, 0xd0a4, 0x0118, 0xd0b4, 0x0904, 0x0ba8, 0x080c, 0x6624,
-	0x1904, 0x0ba8, 0x080c, 0x6677, 0x1904, 0x0ba8, 0x080c, 0x665e,
+	0x70d8, 0xd0a4, 0x0118, 0xd0b4, 0x0904, 0x0ba8, 0x080c, 0x6648,
+	0x1904, 0x0ba8, 0x080c, 0x669b, 0x1904, 0x0ba8, 0x080c, 0x6682,
 	0x01c0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c,
-	0x626b, 0x1118, 0xb800, 0xd0ec, 0x1138, 0x001e, 0x8108, 0x1f04,
+	0x628f, 0x1118, 0xb800, 0xd0ec, 0x1138, 0x001e, 0x8108, 0x1f04,
 	0x0b4e, 0x00ce, 0x015e, 0x0028, 0x001e, 0x00ce, 0x015e, 0x0804,
 	0x0ba8, 0x0006, 0x2001, 0x0103, 0x2003, 0x006b, 0x000e, 0x2011,
-	0x1983, 0x080c, 0x0faa, 0x2011, 0x199d, 0x080c, 0x0faa, 0x7030,
-	0xc08c, 0x7032, 0x7003, 0x0003, 0x70ab, 0xffff, 0x080c, 0x0e61,
-	0x9006, 0x080c, 0x23e2, 0x0036, 0x0046, 0x2019, 0xffff, 0x2021,
-	0x0006, 0x080c, 0x4a77, 0x004e, 0x003e, 0x00f6, 0x2079, 0x0100,
-	0x080c, 0x70b9, 0x0150, 0x080c, 0x7096, 0x7828, 0x0118, 0x9084,
-	0xe1ff, 0x0010, 0x9084, 0xffdf, 0x782a, 0x00fe, 0x080c, 0x98bb,
-	0x2001, 0x19b8, 0x2004, 0x9086, 0x0005, 0x1120, 0x2011, 0x0000,
-	0x080c, 0x931c, 0x2011, 0x0000, 0x080c, 0x9326, 0x080c, 0x98d7,
+	0x198b, 0x080c, 0x0fb7, 0x2011, 0x19a5, 0x080c, 0x0fb7, 0x7030,
+	0xc08c, 0x7032, 0x7003, 0x0003, 0x70ab, 0xffff, 0x080c, 0x0e6e,
+	0x9006, 0x080c, 0x23fe, 0x0036, 0x0046, 0x2019, 0xffff, 0x2021,
+	0x0006, 0x080c, 0x4a97, 0x004e, 0x003e, 0x00f6, 0x2079, 0x0100,
+	0x080c, 0x70dd, 0x0150, 0x080c, 0x70ba, 0x7828, 0x0118, 0x9084,
+	0xe1ff, 0x0010, 0x9084, 0xffdf, 0x782a, 0x00fe, 0x080c, 0x98c7,
+	0x2001, 0x19c0, 0x2004, 0x9086, 0x0005, 0x1120, 0x2011, 0x0000,
+	0x080c, 0x9324, 0x2011, 0x0000, 0x080c, 0x932e, 0x080c, 0x98e3,
 	0x012e, 0x00be, 0x0005, 0x0016, 0x0026, 0x0046, 0x00f6, 0x0126,
 	0x2091, 0x8000, 0x2079, 0x0100, 0x7904, 0x918c, 0xfffd, 0x7906,
-	0x2009, 0x00f7, 0x080c, 0x5c53, 0x7940, 0x918c, 0x0010, 0x7942,
-	0x7924, 0xd1b4, 0x0120, 0x2011, 0x0040, 0x080c, 0x288c, 0xd19c,
-	0x0120, 0x2011, 0x0008, 0x080c, 0x288c, 0x0006, 0x0036, 0x0156,
-	0x0000, 0x2001, 0x1977, 0x2004, 0x9005, 0x1518, 0x080c, 0x2820,
-	0x1148, 0x2001, 0x0001, 0x080c, 0x2787, 0x2001, 0x0001, 0x080c,
-	0x276a, 0x00b8, 0x080c, 0x2828, 0x1138, 0x9006, 0x080c, 0x2787,
-	0x9006, 0x080c, 0x276a, 0x0068, 0x080c, 0x2830, 0x1d50, 0x2001,
-	0x1968, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c, 0x2581, 0x0804,
-	0x0ca9, 0x080c, 0x28af, 0x080c, 0x28e2, 0x20a9, 0x003a, 0x1d04,
-	0x0bff, 0x080c, 0x821e, 0x1f04, 0x0bff, 0x080c, 0x70a7, 0x0148,
-	0x080c, 0x70b9, 0x1118, 0x080c, 0x73a5, 0x0050, 0x080c, 0x709e,
-	0x0dd0, 0x080c, 0x73a0, 0x080c, 0x7396, 0x080c, 0x6fc7, 0x0020,
-	0x2009, 0x00f8, 0x080c, 0x5c53, 0x7850, 0xc0e5, 0x7852, 0x080c,
-	0x7096, 0x0120, 0x7843, 0x0090, 0x7843, 0x0010, 0x2021, 0xe678,
-	0x2019, 0xea60, 0x0d0c, 0x821e, 0x7820, 0xd09c, 0x15a0, 0x080c,
-	0x7096, 0x0904, 0x0c8b, 0x7824, 0xd0ac, 0x1904, 0x0cae, 0x080c,
-	0x70b9, 0x1548, 0x0046, 0x2021, 0x0320, 0x8421, 0x1df0, 0x004e,
-	0x2011, 0x1800, 0x080c, 0x288c, 0x080c, 0x2838, 0x7824, 0x9084,
+	0x2009, 0x00f7, 0x080c, 0x5c73, 0x7940, 0x918c, 0x0010, 0x7942,
+	0x7924, 0xd1b4, 0x0120, 0x2011, 0x0040, 0x080c, 0x28ac, 0xd19c,
+	0x0120, 0x2011, 0x0008, 0x080c, 0x28ac, 0x0006, 0x0036, 0x0156,
+	0x0000, 0x2001, 0x197f, 0x2004, 0x9005, 0x1518, 0x080c, 0x2840,
+	0x1148, 0x2001, 0x0001, 0x080c, 0x27a3, 0x2001, 0x0001, 0x080c,
+	0x2786, 0x00b8, 0x080c, 0x2848, 0x1138, 0x9006, 0x080c, 0x27a3,
+	0x9006, 0x080c, 0x2786, 0x0068, 0x080c, 0x2850, 0x1d50, 0x2001,
+	0x1970, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c, 0x259d, 0x0804,
+	0x0ca9, 0x080c, 0x28cf, 0x080c, 0x2902, 0x20a9, 0x003a, 0x1d04,
+	0x0bff, 0x080c, 0x8252, 0x1f04, 0x0bff, 0x080c, 0x70cb, 0x0148,
+	0x080c, 0x70dd, 0x1118, 0x080c, 0x73c8, 0x0050, 0x080c, 0x70c2,
+	0x0dd0, 0x080c, 0x73c3, 0x080c, 0x73b9, 0x080c, 0x6feb, 0x0020,
+	0x2009, 0x00f8, 0x080c, 0x5c73, 0x7850, 0xc0e5, 0x7852, 0x080c,
+	0x70ba, 0x0120, 0x7843, 0x0090, 0x7843, 0x0010, 0x2021, 0xe678,
+	0x2019, 0xea60, 0x0d0c, 0x8252, 0x7820, 0xd09c, 0x15a0, 0x080c,
+	0x70ba, 0x0904, 0x0c8b, 0x7824, 0xd0ac, 0x1904, 0x0cae, 0x080c,
+	0x70dd, 0x1548, 0x0046, 0x2021, 0x0320, 0x8421, 0x1df0, 0x004e,
+	0x2011, 0x1800, 0x080c, 0x28ac, 0x080c, 0x2858, 0x7824, 0x9084,
 	0x1800, 0x1168, 0x9484, 0x0fff, 0x1140, 0x2001, 0x1810, 0x2004,
 	0x9084, 0x9000, 0x0110, 0x080c, 0x0cd1, 0x8421, 0x1160, 0x1d04,
-	0x0c5b, 0x080c, 0x821e, 0x080c, 0x73a0, 0x080c, 0x7396, 0x7003,
+	0x0c5b, 0x080c, 0x8252, 0x080c, 0x73c3, 0x080c, 0x73b9, 0x7003,
 	0x0001, 0x0804, 0x0cae, 0x8319, 0x1928, 0x2001, 0x1810, 0x2004,
 	0x9084, 0x9000, 0x0110, 0x080c, 0x0cd1, 0x1d04, 0x0c71, 0x080c,
-	0x821e, 0x2009, 0x196b, 0x2104, 0x9005, 0x0118, 0x8001, 0x200a,
-	0x1188, 0x200b, 0x000a, 0x2011, 0x0048, 0x080c, 0x288c, 0x20a9,
-	0x0002, 0x080c, 0x2819, 0x7924, 0x080c, 0x2838, 0xd19c, 0x0110,
-	0x080c, 0x2758, 0x00f0, 0x080c, 0x70a7, 0x1140, 0x94a2, 0x03e8,
-	0x1128, 0x080c, 0x706a, 0x7003, 0x0001, 0x00c0, 0x2011, 0x1800,
-	0x080c, 0x288c, 0x080c, 0x2838, 0x7824, 0x080c, 0x70b0, 0x0110,
+	0x8252, 0x2009, 0x1973, 0x2104, 0x9005, 0x0118, 0x8001, 0x200a,
+	0x1188, 0x200b, 0x000a, 0x2011, 0x0048, 0x080c, 0x28ac, 0x20a9,
+	0x0002, 0x080c, 0x2839, 0x7924, 0x080c, 0x2858, 0xd19c, 0x0110,
+	0x080c, 0x2774, 0x00f0, 0x080c, 0x70cb, 0x1140, 0x94a2, 0x03e8,
+	0x1128, 0x080c, 0x708e, 0x7003, 0x0001, 0x00c0, 0x2011, 0x1800,
+	0x080c, 0x28ac, 0x080c, 0x2858, 0x7824, 0x080c, 0x70d4, 0x0110,
 	0xd0ac, 0x1160, 0x9084, 0x1800, 0x0904, 0x0c63, 0x7003, 0x0001,
-	0x0028, 0x2001, 0x0001, 0x080c, 0x23e2, 0x00a0, 0x7850, 0xc0e4,
+	0x0028, 0x2001, 0x0001, 0x080c, 0x23fe, 0x00a0, 0x7850, 0xc0e4,
 	0x7852, 0x2009, 0x180c, 0x210c, 0xd19c, 0x1120, 0x7904, 0x918d,
-	0x0002, 0x7906, 0x2011, 0x0048, 0x080c, 0x288c, 0x7828, 0x9085,
-	0x0028, 0x782a, 0x2001, 0x1977, 0x2003, 0x0000, 0x9006, 0x78f2,
+	0x0002, 0x7906, 0x2011, 0x0048, 0x080c, 0x28ac, 0x7828, 0x9085,
+	0x0028, 0x782a, 0x2001, 0x197f, 0x2003, 0x0000, 0x9006, 0x78f2,
 	0x015e, 0x003e, 0x000e, 0x012e, 0x00fe, 0x004e, 0x002e, 0x001e,
 	0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x0046, 0x00b6, 0x00c6,
-	0x00d6, 0x00e6, 0x00f6, 0x0156, 0x0071, 0x0d0c, 0x821e, 0x015e,
+	0x00d6, 0x00e6, 0x00f6, 0x0156, 0x0071, 0x0d0c, 0x8252, 0x015e,
 	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x004e, 0x003e, 0x002e,
-	0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0x1894, 0x7004, 0x9086,
-	0x0001, 0x1110, 0x080c, 0x32a6, 0x00ee, 0x0005, 0x0005, 0x2a70,
-	0x2061, 0x197b, 0x2063, 0x0003, 0x6007, 0x0002, 0x600b, 0x001e,
-	0x600f, 0x0317, 0x2001, 0x194c, 0x900e, 0x2102, 0x7192, 0x2001,
+	0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0x189c, 0x7004, 0x9086,
+	0x0001, 0x1110, 0x080c, 0x32c6, 0x00ee, 0x0005, 0x0005, 0x2a70,
+	0x2061, 0x1983, 0x2063, 0x0003, 0x6007, 0x0003, 0x600b, 0x0002,
+	0x600f, 0x0317, 0x2001, 0x1954, 0x900e, 0x2102, 0x7192, 0x2001,
 	0x0100, 0x2004, 0x9082, 0x0002, 0x0218, 0x705b, 0xffff, 0x0008,
-	0x715a, 0x7063, 0xffff, 0x717a, 0x717e, 0x080c, 0xbcae, 0x70eb,
-	0x00c0, 0x2061, 0x193c, 0x6003, 0x0909, 0x6106, 0x600b, 0x8800,
+	0x715a, 0x7063, 0xffff, 0x717a, 0x717e, 0x080c, 0xbcdc, 0x70eb,
+	0x00c0, 0x2061, 0x1944, 0x6003, 0x0909, 0x6106, 0x600b, 0x8800,
 	0x600f, 0x0200, 0x6013, 0x00ff, 0x6017, 0x000f, 0x611a, 0x601f,
-	0x07d0, 0x2061, 0x1944, 0x6003, 0x8000, 0x6106, 0x610a, 0x600f,
+	0x07d0, 0x2061, 0x194c, 0x6003, 0x8000, 0x6106, 0x610a, 0x600f,
 	0x0200, 0x6013, 0x00ff, 0x6116, 0x601b, 0x0001, 0x611e, 0x2061,
-	0x1959, 0x6003, 0x514c, 0x6007, 0x4f47, 0x600b, 0x4943, 0x600f,
-	0x2020, 0x2001, 0x182b, 0x2102, 0x0005, 0x9016, 0x080c, 0x626b,
+	0x1961, 0x6003, 0x514c, 0x6007, 0x4f47, 0x600b, 0x4943, 0x600f,
+	0x2020, 0x2001, 0x182b, 0x2102, 0x0005, 0x9016, 0x080c, 0x628f,
 	0x1178, 0xb804, 0x90c4, 0x00ff, 0x98c6, 0x0006, 0x0128, 0x90c4,
 	0xff00, 0x98c6, 0x0600, 0x1120, 0x9186, 0x0080, 0x0108, 0x8210,
 	0x8108, 0x9186, 0x0800, 0x1d50, 0x2208, 0x0005, 0x2091, 0x8000,
@@ -226,456 +226,459 @@
 	0x0d67, 0x0006, 0x0016, 0x2001, 0x8002, 0x0006, 0x2079, 0x0000,
 	0x000e, 0x7882, 0x7836, 0x001e, 0x798e, 0x000e, 0x788a, 0x000e,
 	0x7886, 0x3900, 0x789a, 0x7833, 0x0012, 0x2091, 0x5000, 0x0156,
-	0x00d6, 0x0036, 0x0026, 0x2079, 0x0300, 0x2069, 0x1af3, 0x7a08,
-	0x226a, 0x2069, 0x1af4, 0x7a18, 0x226a, 0x8d68, 0x7a1c, 0x226a,
-	0x782c, 0x2019, 0x1b01, 0x201a, 0x2019, 0x1b04, 0x9016, 0x7808,
-	0xd09c, 0x0168, 0x7820, 0x201a, 0x8210, 0x8318, 0x9386, 0x1b1d,
+	0x00d6, 0x0036, 0x0026, 0x2079, 0x0300, 0x2069, 0x1afb, 0x7a08,
+	0x226a, 0x2069, 0x1afc, 0x7a18, 0x226a, 0x8d68, 0x7a1c, 0x226a,
+	0x782c, 0x2019, 0x1b09, 0x201a, 0x2019, 0x1b0c, 0x9016, 0x7808,
+	0xd09c, 0x0168, 0x7820, 0x201a, 0x8210, 0x8318, 0x9386, 0x1b25,
 	0x0108, 0x0ca8, 0x7808, 0xd09c, 0x0110, 0x2011, 0xdead, 0x2019,
-	0x1b02, 0x782c, 0x201a, 0x8318, 0x221a, 0x7803, 0x0000, 0x2069,
-	0x1a49, 0x901e, 0x20a9, 0x0020, 0x7b26, 0x7a28, 0x226a, 0x8d68,
-	0x8318, 0x1f04, 0x0db4, 0x0491, 0x002e, 0x003e, 0x00de, 0x015e,
-	0x2079, 0x1800, 0x7803, 0x0005, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x0180, 0x2001, 0x19f2, 0x2004, 0x9005, 0x0128,
-	0x2001, 0x008b, 0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003,
-	0x0002, 0x2003, 0x1001, 0x080c, 0x5397, 0x1170, 0x080c, 0x0efb,
-	0x0110, 0x080c, 0x0e4e, 0x080c, 0x5397, 0x1130, 0x2071, 0x1800,
-	0x2011, 0x8000, 0x080c, 0x0f0f, 0x0c70, 0x0005, 0x2001, 0x0382,
-	0x2004, 0x9084, 0x0007, 0x9086, 0x0001, 0x1120, 0x2001, 0x0015,
-	0x080c, 0x98ac, 0x2079, 0x0380, 0x2069, 0x1ad3, 0x7818, 0x6802,
-	0x781c, 0x6806, 0x7840, 0x680a, 0x7844, 0x680e, 0x782c, 0x6812,
-	0x2019, 0x1ade, 0x9016, 0x7808, 0xd09c, 0x0150, 0x7820, 0x201a,
-	0x8210, 0x8318, 0x8210, 0x9282, 0x0011, 0x0ea8, 0x2011, 0xdead,
-	0x6a2a, 0x7830, 0x681a, 0x7834, 0x681e, 0x7838, 0x6822, 0x783c,
-	0x6826, 0x7803, 0x0000, 0x2069, 0x1a93, 0x901e, 0x20a9, 0x0020,
-	0x7b26, 0x7828, 0x206a, 0x8d68, 0x8318, 0x1f04, 0x0e28, 0x2069,
-	0x1ab3, 0x2019, 0x00b0, 0x20a9, 0x0020, 0x7b26, 0x7828, 0x206a,
-	0x8d68, 0x8318, 0x1f04, 0x0e35, 0x0005, 0x918c, 0x03ff, 0x2001,
-	0x0003, 0x2004, 0x9084, 0x0600, 0x1118, 0x918d, 0x6c00, 0x0010,
-	0x918d, 0x6400, 0x2001, 0x017f, 0x2102, 0x0005, 0x0026, 0x0126,
-	0x2011, 0x0080, 0x080c, 0x0eed, 0x20a9, 0x0900, 0x080c, 0x0f23,
-	0x2011, 0x0040, 0x080c, 0x0eed, 0x20a9, 0x0900, 0x080c, 0x0f23,
-	0x0c78, 0x0026, 0x080c, 0x0efb, 0x1188, 0x2011, 0x010e, 0x2214,
-	0x9294, 0x0007, 0x9296, 0x0007, 0x0118, 0x2011, 0x0947, 0x0010,
-	0x2011, 0x1b47, 0x080c, 0x0f0f, 0x002e, 0x0005, 0x2011, 0x010e,
-	0x2214, 0x9294, 0x0007, 0x9296, 0x0007, 0x0118, 0x2011, 0xa880,
-	0x0010, 0x2011, 0x6840, 0xd0e4, 0x70ef, 0x0000, 0x1128, 0x70ef,
-	0x0fa0, 0x080c, 0x0f00, 0x002e, 0x0005, 0x0026, 0x080c, 0x0efb,
-	0x0148, 0xd0a4, 0x1138, 0x2011, 0xcdd5, 0x0010, 0x2011, 0x0080,
-	0x080c, 0x0f00, 0x002e, 0x0005, 0x0026, 0x70ef, 0x0000, 0x080c,
-	0x0efb, 0x1130, 0x2011, 0x8040, 0x080c, 0x0f0f, 0x002e, 0x0005,
-	0x080c, 0x2830, 0x1118, 0x2011, 0xcdc5, 0x0010, 0x2011, 0xcac2,
-	0x080c, 0x0f00, 0x002e, 0x0005, 0x00e6, 0x0016, 0x0006, 0x2071,
-	0x1800, 0xd0b4, 0x70e8, 0x71e4, 0x1118, 0xc0e4, 0xc1f4, 0x0050,
-	0x0006, 0x3b00, 0x9084, 0xff3e, 0x20d8, 0x000e, 0x70ef, 0x0000,
-	0xc0e5, 0xc1f5, 0x0099, 0x000e, 0x001e, 0x00ee, 0x0005, 0x00e6,
-	0x2071, 0x1800, 0xd0e4, 0x70e8, 0x1110, 0xc0dc, 0x0008, 0xc0dd,
-	0x0016, 0x71e4, 0x0019, 0x001e, 0x00ee, 0x0005, 0x70ea, 0x71e6,
-	0x7000, 0x9084, 0x0007, 0x000b, 0x0005, 0x0eb3, 0x0e8d, 0x0e8d,
-	0x0e61, 0x0e9c, 0x0e8d, 0x0e8d, 0x0e9c, 0xc284, 0x0016, 0x3b08,
-	0x3a00, 0x9104, 0x918d, 0x00c1, 0x21d8, 0x9084, 0xff3e, 0x9205,
-	0x20d0, 0x001e, 0x0005, 0x2001, 0x183a, 0x2004, 0xd0dc, 0x0005,
-	0x9e86, 0x1800, 0x190c, 0x0d65, 0x70e8, 0xd0e4, 0x0108, 0xc2e5,
-	0x72ea, 0xd0e4, 0x1118, 0x9294, 0x00c1, 0x08f9, 0x0005, 0x9e86,
-	0x1800, 0x190c, 0x0d65, 0x70e4, 0xd0f4, 0x0108, 0xc2f5, 0x72e6,
-	0xd0f4, 0x1140, 0x9284, 0x8000, 0x8005, 0xc284, 0x9215, 0x9294,
-	0x00c1, 0x0861, 0x0005, 0x1d04, 0x0f23, 0x2091, 0x6000, 0x1f04,
-	0x0f23, 0x0005, 0x890e, 0x810e, 0x810f, 0x9194, 0x003f, 0x918c,
-	0xffc0, 0x0005, 0x0006, 0x2200, 0x914d, 0x894f, 0x894d, 0x894d,
-	0x000e, 0x0005, 0x01d6, 0x0146, 0x0036, 0x0096, 0x2061, 0x1883,
-	0x600b, 0x0000, 0x600f, 0x0000, 0x6003, 0x0000, 0x6007, 0x0000,
-	0x2009, 0xffc0, 0x2105, 0x0006, 0x2001, 0xaaaa, 0x200f, 0x2019,
-	0x5555, 0x9016, 0x2049, 0x0bff, 0xab02, 0xa001, 0xa001, 0xa800,
-	0x9306, 0x1138, 0x2105, 0x9306, 0x0120, 0x8210, 0x99c8, 0x0400,
-	0x0c98, 0x000e, 0x200f, 0x2001, 0x1893, 0x928a, 0x000e, 0x1638,
-	0x928a, 0x0006, 0x2011, 0x0006, 0x1210, 0x2011, 0x0000, 0x2202,
-	0x9006, 0x2008, 0x82ff, 0x01b0, 0x8200, 0x600a, 0x600f, 0xffff,
-	0x6003, 0x0002, 0x6007, 0x0000, 0x0026, 0x2019, 0x0010, 0x9280,
-	0x0001, 0x20e8, 0x21a0, 0x21a8, 0x4104, 0x8319, 0x1de0, 0x8211,
-	0x1da0, 0x002e, 0x009e, 0x003e, 0x014e, 0x01de, 0x0005, 0x2011,
-	0x000e, 0x08e8, 0x0016, 0x0026, 0x0096, 0x3348, 0x080c, 0x0f2a,
-	0x2100, 0x9300, 0x2098, 0x22e0, 0x009e, 0x002e, 0x001e, 0x0036,
-	0x3518, 0x20a9, 0x0001, 0x4002, 0x8007, 0x4004, 0x8319, 0x1dd8,
-	0x003e, 0x0005, 0x20e9, 0x0001, 0x71b4, 0x81ff, 0x11c0, 0x9006,
-	0x2009, 0x0200, 0x20a9, 0x0002, 0x9298, 0x0018, 0x23a0, 0x4001,
-	0x2009, 0x0700, 0x20a9, 0x0002, 0x9298, 0x0008, 0x23a0, 0x4001,
-	0x7078, 0x8007, 0x717c, 0x810f, 0x20a9, 0x0002, 0x4001, 0x9298,
-	0x000c, 0x23a0, 0x900e, 0x080c, 0x0d45, 0x2001, 0x0000, 0x810f,
-	0x20a9, 0x0002, 0x4001, 0x0005, 0x89ff, 0x0140, 0xa804, 0xa807,
-	0x0000, 0x0006, 0x080c, 0x1054, 0x009e, 0x0cb0, 0x0005, 0x00e6,
-	0x2071, 0x1800, 0x080c, 0x10cd, 0x090c, 0x0d65, 0x00ee, 0x0005,
-	0x0086, 0x00e6, 0x0006, 0x0026, 0x0036, 0x0126, 0x2091, 0x8000,
-	0x00c9, 0x2071, 0x1800, 0x73bc, 0x702c, 0x9016, 0x9045, 0x0158,
-	0x8210, 0x9906, 0x090c, 0x0d65, 0x2300, 0x9202, 0x0120, 0x1a0c,
-	0x0d65, 0xa000, 0x0c98, 0x012e, 0x003e, 0x002e, 0x000e, 0x00ee,
-	0x008e, 0x0005, 0x0086, 0x00e6, 0x0006, 0x0126, 0x2091, 0x8000,
-	0x2071, 0x1906, 0x7010, 0x9005, 0x0140, 0x7018, 0x9045, 0x0128,
-	0x9906, 0x090c, 0x0d65, 0xa000, 0x0cc8, 0x012e, 0x000e, 0x00ee,
-	0x008e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x0126, 0x2091, 0x8000,
-	0x70bc, 0x8001, 0x0270, 0x70be, 0x702c, 0x2048, 0x9085, 0x0001,
-	0xa800, 0x702e, 0xa803, 0x0000, 0xa807, 0x0000, 0x012e, 0x00ee,
-	0x0005, 0x904e, 0x0cd8, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x1800, 0x70bc, 0x90ca, 0x0040, 0x0268, 0x8001, 0x70be, 0x702c,
-	0x2048, 0xa800, 0x702e, 0xa803, 0x0000, 0xa807, 0x0000, 0x012e,
-	0x00ee, 0x0005, 0x904e, 0x0cd8, 0x00e6, 0x0126, 0x2091, 0x8000,
-	0x0016, 0x890e, 0x810e, 0x810f, 0x9184, 0x003f, 0xa862, 0x9184,
-	0xffc0, 0xa85e, 0x001e, 0x0020, 0x00e6, 0x0126, 0x2091, 0x8000,
-	0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000,
-	0x70be, 0x080c, 0x8053, 0x012e, 0x00ee, 0x0005, 0x2071, 0x1800,
-	0x9026, 0x2009, 0x0000, 0x2049, 0x0400, 0x2900, 0x702e, 0x8940,
-	0x2800, 0xa802, 0xa95e, 0xa863, 0x0001, 0x8420, 0x9886, 0x0440,
-	0x0120, 0x2848, 0x9188, 0x0040, 0x0c90, 0x2071, 0x1883, 0x7000,
-	0x9005, 0x11a0, 0x2001, 0x049b, 0xa802, 0x2048, 0x2009, 0x26c0,
-	0x8940, 0x2800, 0xa802, 0xa95e, 0xa863, 0x0001, 0x8420, 0x9886,
-	0x0800, 0x0120, 0x2848, 0x9188, 0x0040, 0x0c90, 0x2071, 0x1883,
-	0x7104, 0x7200, 0x82ff, 0x01d0, 0x7308, 0x8318, 0x831f, 0x831b,
-	0x831b, 0x7312, 0x8319, 0x2001, 0x0800, 0xa802, 0x2048, 0x8900,
-	0xa802, 0x2040, 0xa95e, 0xaa62, 0x8420, 0x2300, 0x9906, 0x0130,
-	0x2848, 0x9188, 0x0040, 0x9291, 0x0000, 0x0c88, 0xa803, 0x0000,
-	0x2071, 0x1800, 0x74ba, 0x74be, 0x0005, 0x00e6, 0x0016, 0x9984,
-	0xfc00, 0x01e8, 0x908c, 0xf800, 0x1168, 0x9982, 0x0400, 0x02b8,
-	0x9982, 0x0440, 0x0278, 0x9982, 0x049b, 0x0288, 0x9982, 0x0800,
-	0x1270, 0x0040, 0x9982, 0x0800, 0x0250, 0x2071, 0x1883, 0x7010,
-	0x9902, 0x1228, 0x9085, 0x0001, 0x001e, 0x00ee, 0x0005, 0x9006,
-	0x0cd8, 0x00e6, 0x2071, 0x19f1, 0x7007, 0x0000, 0x9006, 0x701e,
-	0x7022, 0x7002, 0x2071, 0x0000, 0x7010, 0x9085, 0x8044, 0x7012,
-	0x2071, 0x0080, 0x9006, 0x702b, 0x0060, 0x20a9, 0x0040, 0x7022,
-	0x1f04, 0x1107, 0x702b, 0x0060, 0x702b, 0x0020, 0x20a9, 0x0040,
-	0x7022, 0x1f04, 0x1110, 0x702b, 0x0020, 0x00ee, 0x0005, 0x0126,
-	0x2091, 0x8000, 0x00e6, 0xa06f, 0x0000, 0x2071, 0x19f1, 0x701c,
-	0x9088, 0x19fb, 0x280a, 0x8000, 0x9084, 0x003f, 0x701e, 0x7120,
-	0x9106, 0x090c, 0x0d65, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079,
-	0x0080, 0x00a9, 0x00fe, 0x00ee, 0x012e, 0x0005, 0x0126, 0x2091,
-	0x8000, 0x00e6, 0x2071, 0x19f1, 0x7004, 0x9005, 0x1128, 0x00f6,
-	0x2079, 0x0080, 0x0021, 0x00fe, 0x00ee, 0x012e, 0x0005, 0x7004,
-	0x9086, 0x0000, 0x1110, 0x7007, 0x0006, 0x7000, 0x0002, 0x1159,
-	0x1157, 0x1157, 0x1157, 0x12d0, 0x12d0, 0x12d0, 0x12d0, 0x080c,
-	0x0d65, 0x701c, 0x7120, 0x9106, 0x1148, 0x792c, 0x9184, 0x0001,
-	0x1120, 0xd1fc, 0x1110, 0x7007, 0x0000, 0x0005, 0x0096, 0x9180,
-	0x19fb, 0x2004, 0x700a, 0x2048, 0x8108, 0x918c, 0x003f, 0x7122,
-	0x782b, 0x0026, 0xa88c, 0x7802, 0xa890, 0x7806, 0xa894, 0x780a,
-	0xa898, 0x780e, 0xa878, 0x700e, 0xa870, 0x7016, 0xa874, 0x701a,
-	0xa868, 0x009e, 0xd084, 0x0120, 0x7007, 0x0001, 0x0029, 0x0005,
-	0x7007, 0x0002, 0x00b1, 0x0005, 0x0016, 0x0026, 0x710c, 0x2011,
-	0x0040, 0x9182, 0x0040, 0x1210, 0x2110, 0x9006, 0x700e, 0x7212,
-	0x8203, 0x7812, 0x782b, 0x0020, 0x782b, 0x0041, 0x002e, 0x001e,
-	0x0005, 0x0016, 0x0026, 0x0136, 0x0146, 0x0156, 0x7014, 0x20e0,
-	0x7018, 0x2098, 0x20e9, 0x0000, 0x20a1, 0x0088, 0x782b, 0x0026,
-	0x710c, 0x2011, 0x0040, 0x9182, 0x0040, 0x1210, 0x2110, 0x9006,
-	0x700e, 0x22a8, 0x4006, 0x8203, 0x7812, 0x782b, 0x0020, 0x3300,
-	0x701a, 0x782b, 0x0001, 0x015e, 0x014e, 0x013e, 0x002e, 0x001e,
-	0x0005, 0x2009, 0x19f1, 0x2104, 0xc095, 0x200a, 0x080c, 0x1136,
-	0x0005, 0x0016, 0x00e6, 0x2071, 0x19f1, 0x00f6, 0x2079, 0x0080,
-	0x792c, 0xd1bc, 0x190c, 0x0d5e, 0x782b, 0x0002, 0xd1fc, 0x0120,
-	0x918c, 0x0700, 0x7004, 0x0023, 0x00fe, 0x00ee, 0x001e, 0x0005,
-	0x1147, 0x11ef, 0x1223, 0x0d65, 0x0d65, 0x12dc, 0x0d65, 0x918c,
-	0x0700, 0x1550, 0x0136, 0x0146, 0x0156, 0x7014, 0x20e8, 0x7018,
-	0x20a0, 0x20e1, 0x0000, 0x2099, 0x0088, 0x782b, 0x0040, 0x7010,
-	0x20a8, 0x4005, 0x3400, 0x701a, 0x015e, 0x014e, 0x013e, 0x700c,
-	0x9005, 0x0578, 0x7800, 0x7802, 0x7804, 0x7806, 0x080c, 0x118c,
-	0x0005, 0x7008, 0x0096, 0x2048, 0xa86f, 0x0100, 0x009e, 0x7007,
-	0x0000, 0x080c, 0x1147, 0x0005, 0x7008, 0x0096, 0x2048, 0xa86f,
-	0x0200, 0x009e, 0x0ca0, 0x918c, 0x0700, 0x1150, 0x700c, 0x9005,
-	0x0180, 0x7800, 0x7802, 0x7804, 0x7806, 0x080c, 0x11a1, 0x0005,
-	0x7008, 0x0096, 0x2048, 0xa86f, 0x0200, 0x009e, 0x7007, 0x0000,
-	0x0080, 0x0096, 0x7008, 0x2048, 0x7800, 0xa88e, 0x7804, 0xa892,
-	0x7808, 0xa896, 0x780c, 0xa89a, 0xa86f, 0x0100, 0x009e, 0x7007,
-	0x0000, 0x0096, 0x00d6, 0x7008, 0x2048, 0x2001, 0x18af, 0x2004,
-	0x9906, 0x1128, 0xa89c, 0x080f, 0x00de, 0x009e, 0x00a0, 0x00de,
-	0x009e, 0x0096, 0x00d6, 0x7008, 0x2048, 0x0081, 0x0150, 0xa89c,
-	0x0086, 0x2940, 0x080f, 0x008e, 0x00de, 0x009e, 0x080c, 0x1136,
-	0x0005, 0x00de, 0x009e, 0x080c, 0x1136, 0x0005, 0xa8a8, 0xd08c,
-	0x0005, 0x0096, 0xa0a0, 0x904d, 0x090c, 0x0d65, 0xa06c, 0x908e,
-	0x0100, 0x0130, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002,
-	0x080c, 0x6985, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x2848, 0x080c,
-	0x1054, 0x009e, 0x0005, 0x00a6, 0xa0a0, 0x904d, 0x090c, 0x0d65,
-	0xa06c, 0x908e, 0x0100, 0x0128, 0xa87b, 0x0001, 0xa883, 0x0000,
-	0x00c0, 0xa80c, 0x2050, 0xb004, 0x9005, 0x0198, 0xa80e, 0x2050,
-	0x8006, 0x8006, 0x8007, 0x908c, 0x003f, 0x9084, 0xffc0, 0x9080,
-	0x0002, 0xa076, 0xa172, 0xb000, 0xa07a, 0x2810, 0x080c, 0x1117,
-	0x00e8, 0xa97c, 0xa894, 0x0016, 0x0006, 0x080c, 0x6985, 0x000e,
-	0x001e, 0xd1fc, 0x1138, 0xd1f4, 0x0128, 0x00c6, 0x2060, 0x080c,
-	0x9bda, 0x00ce, 0x7008, 0x2048, 0xa89f, 0x0000, 0xa8a3, 0x0000,
-	0x080c, 0x1054, 0x7007, 0x0000, 0x080c, 0x1136, 0x00ae, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x782b, 0x1001, 0x7007, 0x0005, 0x7000,
-	0xc094, 0x7002, 0x012e, 0x0005, 0x7007, 0x0000, 0x080c, 0x1147,
-	0x0005, 0x0126, 0x2091, 0x2200, 0x2079, 0x0300, 0x2071, 0x1a3b,
-	0x7003, 0x0000, 0x78bf, 0x00f6, 0x0041, 0x7807, 0x0007, 0x7803,
-	0x0000, 0x7803, 0x0001, 0x012e, 0x0005, 0x00c6, 0x7803, 0x0000,
-	0x2001, 0x0165, 0x2003, 0x4198, 0x7808, 0xd09c, 0x0110, 0x7820,
-	0x0cd8, 0x2001, 0x1a3c, 0x2003, 0x0000, 0x78ab, 0x0004, 0x78ac,
-	0xd0ac, 0x1de8, 0x78ab, 0x0002, 0x7807, 0x0007, 0x7827, 0x0030,
-	0x782b, 0x0400, 0x7827, 0x0031, 0x782b, 0x1a49, 0x781f, 0xff00,
-	0x781b, 0xff00, 0x2001, 0x0200, 0x2004, 0xd0dc, 0x0110, 0x781f,
-	0x0303, 0x2061, 0x1a49, 0x602f, 0x1ddc, 0x2001, 0x1819, 0x2004,
-	0x9082, 0x1ddc, 0x6032, 0x603b, 0x1d04, 0x602b, 0x1a89, 0x6007,
-	0x1a69, 0x2061, 0x1a69, 0x00ce, 0x0005, 0x0126, 0x2091, 0x2200,
-	0x7908, 0x9184, 0x0070, 0x190c, 0x0d5e, 0xd19c, 0x05a0, 0x7820,
-	0x908c, 0xf000, 0x0540, 0x2060, 0x6020, 0x9086, 0x0003, 0x1550,
-	0x6000, 0x9086, 0x0004, 0x1530, 0x6114, 0x2148, 0xa876, 0xa87a,
-	0xa867, 0x0103, 0x080c, 0x67a7, 0x00b6, 0x6010, 0x2058, 0xba3c,
-	0x8211, 0x0208, 0xba3e, 0xb8c0, 0x9005, 0x190c, 0x6396, 0x00be,
-	0x6044, 0xd0fc, 0x190c, 0x98e4, 0x080c, 0x9c02, 0x7808, 0xd09c,
-	0x19b0, 0x012e, 0x0005, 0x908a, 0x0024, 0x1a0c, 0x0d65, 0x002b,
-	0x012e, 0x0005, 0x04b0, 0x012e, 0x0005, 0x1399, 0x13bf, 0x13ef,
-	0x13f4, 0x13f8, 0x13fd, 0x1425, 0x1429, 0x1437, 0x143b, 0x1399,
-	0x14c7, 0x14cb, 0x152e, 0x1399, 0x1399, 0x1399, 0x1399, 0x1399,
-	0x1399, 0x1399, 0x1399, 0x1399, 0x1399, 0x1399, 0x1399, 0x1399,
-	0x13ff, 0x1399, 0x13c7, 0x13ec, 0x13b3, 0x1399, 0x13d3, 0x139d,
-	0x139b, 0x080c, 0x0d65, 0x080c, 0x0d5e, 0x080c, 0x1535, 0x2009,
-	0x1a48, 0x2104, 0x8000, 0x200a, 0x080c, 0x7b01, 0x080c, 0x196c,
-	0x0005, 0x6044, 0xd0fc, 0x190c, 0x98e4, 0x2009, 0x0055, 0x080c,
-	0x9c76, 0x012e, 0x0005, 0x080c, 0x1535, 0x2060, 0x6044, 0xd0fc,
-	0x190c, 0x98e4, 0x2009, 0x0055, 0x080c, 0x9c76, 0x0005, 0x2009,
-	0x0048, 0x080c, 0x1535, 0x2060, 0x080c, 0x9c76, 0x0005, 0x2009,
-	0x0054, 0x080c, 0x1535, 0x2060, 0x6044, 0xd0fc, 0x190c, 0x98e4,
-	0x080c, 0x9c76, 0x0005, 0x080c, 0x1535, 0x2060, 0x0056, 0x0066,
-	0x080c, 0x1535, 0x2028, 0x080c, 0x1535, 0x2030, 0x0036, 0x0046,
-	0x2021, 0x0000, 0x2418, 0x2009, 0x0056, 0x080c, 0x9c76, 0x004e,
-	0x003e, 0x006e, 0x005e, 0x0005, 0x080c, 0x1535, 0x0005, 0x7004,
-	0xc085, 0xc0b5, 0x7006, 0x0005, 0x7004, 0xc085, 0x7006, 0x0005,
-	0x080c, 0x1535, 0x080c, 0x15f2, 0x0005, 0x080c, 0x0d65, 0x080c,
-	0x1535, 0x2060, 0x6014, 0x0096, 0x2048, 0xa83b, 0xffff, 0x009e,
-	0x2009, 0x0048, 0x080c, 0x9c76, 0x2001, 0x015d, 0x2003, 0x0000,
-	0x2009, 0x03e8, 0x8109, 0x0160, 0x2001, 0x0201, 0x2004, 0x9005,
-	0x0dc8, 0x2001, 0x0218, 0x2004, 0xd0ec, 0x1110, 0x080c, 0x153a,
-	0x2001, 0x0307, 0x2003, 0x8000, 0x0005, 0x7004, 0xc095, 0x7006,
-	0x0005, 0x080c, 0x1535, 0x2060, 0x6014, 0x0096, 0x2048, 0xa83b,
-	0xffff, 0x009e, 0x2009, 0x0048, 0x080c, 0x9c76, 0x0005, 0x080c,
-	0x1535, 0x080c, 0x0d65, 0x080c, 0x1535, 0x080c, 0x14b2, 0x7827,
-	0x0018, 0x79ac, 0xd1dc, 0x0540, 0x7827, 0x0015, 0x7828, 0x782b,
-	0x0000, 0x9065, 0x0138, 0x2001, 0x020d, 0x2003, 0x0050, 0x2003,
-	0x0020, 0x0400, 0x7004, 0x9005, 0x1180, 0x78ab, 0x0004, 0x7827,
-	0x0018, 0x782b, 0x0000, 0xd1bc, 0x090c, 0x0d65, 0x2001, 0x020d,
-	0x2003, 0x0050, 0x2003, 0x0020, 0x0490, 0x78ab, 0x0004, 0x7803,
-	0x0001, 0x080c, 0x14cb, 0x0005, 0x7828, 0x782b, 0x0000, 0x9065,
-	0x090c, 0x0d65, 0x6014, 0x2048, 0x78ab, 0x0004, 0x918c, 0x0700,
-	0x01a8, 0x080c, 0x7b01, 0x080c, 0x196c, 0x080c, 0xb842, 0x0158,
-	0xa9ac, 0xa936, 0xa9b0, 0xa93a, 0xa83f, 0xffff, 0xa843, 0xffff,
-	0xa880, 0xc0bd, 0xa882, 0x080c, 0xb440, 0x0005, 0x6010, 0x00b6,
-	0x2058, 0xb800, 0x00be, 0xd0bc, 0x6024, 0x190c, 0xbc43, 0x2029,
-	0x00c8, 0x8529, 0x0128, 0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8,
-	0x7dbc, 0x080c, 0xd5e4, 0xd5a4, 0x1118, 0x080c, 0x153a, 0x0005,
-	0x080c, 0x7b01, 0x080c, 0x196c, 0x0005, 0x781f, 0x0300, 0x7803,
-	0x0001, 0x0005, 0x0016, 0x0066, 0x0076, 0x00f6, 0x2079, 0x0300,
-	0x7908, 0x918c, 0x0007, 0x9186, 0x0003, 0x0120, 0x2001, 0x0016,
-	0x080c, 0x15ab, 0x00fe, 0x007e, 0x006e, 0x001e, 0x0005, 0x7004,
-	0xc09d, 0x7006, 0x0005, 0x7104, 0x9184, 0x0004, 0x190c, 0x0d65,
-	0xd184, 0x1189, 0xd19c, 0x0158, 0xc19c, 0x7106, 0x2001, 0x020d,
-	0x2003, 0x0050, 0x2003, 0x0020, 0x080c, 0x153a, 0x0005, 0x81ff,
-	0x190c, 0x0d65, 0x0005, 0xc184, 0xd1b4, 0xc1b4, 0x7106, 0x0016,
-	0x00e6, 0x15e0, 0x2071, 0x0200, 0x080c, 0x15e6, 0x6014, 0x9005,
-	0x05a8, 0x0096, 0x2048, 0xa864, 0x009e, 0x9084, 0x00ff, 0x908e,
-	0x0029, 0x0160, 0x908e, 0x0048, 0x1548, 0x601c, 0xd084, 0x11d8,
-	0x00f6, 0x2c78, 0x080c, 0x165c, 0x00fe, 0x00a8, 0x00f6, 0x2c78,
-	0x080c, 0x17a4, 0x00fe, 0x2009, 0x01f4, 0x8109, 0x0160, 0x2001,
-	0x0201, 0x2004, 0x9005, 0x0dc8, 0x2001, 0x0218, 0x2004, 0xd0ec,
-	0x1110, 0x0401, 0x0040, 0x2001, 0x020d, 0x2003, 0x0020, 0x080c,
-	0x12f5, 0x7803, 0x0001, 0x00ee, 0x001e, 0x0005, 0x2001, 0x020d,
-	0x2003, 0x0050, 0x2003, 0x0020, 0x0069, 0x0ca8, 0x0031, 0x2060,
-	0x2009, 0x0053, 0x080c, 0x9c76, 0x0005, 0x7808, 0xd09c, 0x0de8,
-	0x7820, 0x0005, 0x080c, 0x14b2, 0x00d6, 0x2069, 0x0200, 0x2009,
-	0x01f4, 0x8109, 0x0510, 0x6804, 0x9005, 0x0dd8, 0x2001, 0x015d,
-	0x2003, 0x0000, 0x79bc, 0xd1a4, 0x1528, 0x79b8, 0x918c, 0x0fff,
-	0x0180, 0x9182, 0x0841, 0x1268, 0x9188, 0x0007, 0x918c, 0x0ff8,
-	0x810c, 0x810c, 0x810c, 0x080c, 0x159d, 0x6827, 0x0001, 0x8109,
-	0x1dd0, 0x04d9, 0x6827, 0x0002, 0x04c1, 0x6804, 0x9005, 0x1130,
-	0x682c, 0xd0e4, 0x1500, 0x6804, 0x9005, 0x0de8, 0x79b8, 0xd1ec,
-	0x1130, 0x08c0, 0x080c, 0x7b01, 0x080c, 0x196c, 0x0090, 0x7827,
-	0x0015, 0x782b, 0x0000, 0x7827, 0x0018, 0x782b, 0x0000, 0x2001,
-	0x020d, 0x2003, 0x0020, 0x2001, 0x0307, 0x2003, 0x0300, 0x7803,
-	0x0001, 0x00de, 0x0005, 0x682c, 0x9084, 0x5400, 0x9086, 0x5400,
-	0x0d30, 0x7827, 0x0015, 0x782b, 0x0000, 0x7803, 0x0001, 0x6800,
-	0x9085, 0x1800, 0x6802, 0x00de, 0x0005, 0x6824, 0x9084, 0x0003,
-	0x1de0, 0x0005, 0x2001, 0x0030, 0x2c08, 0x621c, 0x0021, 0x7830,
-	0x9086, 0x0041, 0x0005, 0x00f6, 0x2079, 0x0300, 0x0006, 0x7808,
-	0xd09c, 0x0140, 0x0016, 0x0026, 0x00c6, 0x080c, 0x1335, 0x00ce,
-	0x002e, 0x001e, 0x000e, 0x0006, 0x7832, 0x7936, 0x7a3a, 0x781b,
-	0x8080, 0x0059, 0x1118, 0x000e, 0x00fe, 0x0005, 0x000e, 0x792c,
-	0x3900, 0x8000, 0x2004, 0x080c, 0x0d65, 0x2009, 0xff00, 0x8109,
-	0x0120, 0x7818, 0xd0bc, 0x1dd8, 0x0005, 0x9085, 0x0001, 0x0005,
-	0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080, 0x0c79, 0x1108, 0x0005,
-	0x792c, 0x3900, 0x8000, 0x2004, 0x080c, 0x0d65, 0x7037, 0x0001,
-	0x7150, 0x7037, 0x0002, 0x7050, 0x2060, 0xd1bc, 0x1110, 0x7054,
-	0x2060, 0x0005, 0x00e6, 0x0016, 0x2071, 0x0200, 0x0c79, 0x6124,
-	0xd1dc, 0x01f8, 0x701c, 0xd08c, 0x0904, 0x1651, 0x7017, 0x0000,
-	0x2001, 0x0264, 0x2004, 0xd0bc, 0x0904, 0x1651, 0x2001, 0x0268,
-	0x00c6, 0x2064, 0x6104, 0x6038, 0x00ce, 0x918e, 0x0039, 0x1904,
-	0x1651, 0x9c06, 0x15f0, 0x0126, 0x2091, 0x2600, 0x080c, 0x7a59,
-	0x012e, 0x7358, 0x745c, 0x6014, 0x905d, 0x0598, 0x2b48, 0x6010,
-	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x190c, 0xbc1e, 0xab42,
-	0xac3e, 0x2001, 0x1875, 0x2004, 0xd0b4, 0x1170, 0x601c, 0xd0e4,
-	0x1158, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1120,
-	0xa83b, 0x7fff, 0xa837, 0xffff, 0x080c, 0x1d24, 0x1190, 0x080c,
-	0x17ff, 0x2a00, 0xa816, 0x0130, 0x2800, 0xa80e, 0x2c05, 0xa80a,
-	0x2c00, 0xa812, 0x7037, 0x0020, 0x781f, 0x0300, 0x001e, 0x00ee,
-	0x0005, 0x7037, 0x0050, 0x7037, 0x0020, 0x001e, 0x00ee, 0x080c,
-	0x153a, 0x0005, 0x080c, 0x0d65, 0x0016, 0x2009, 0x00a0, 0x8109,
-	0xa001, 0xa001, 0xa001, 0x1dd8, 0x001e, 0x2cf0, 0x0126, 0x2091,
-	0x2200, 0x00c6, 0x3e60, 0x6014, 0x2048, 0x2940, 0x903e, 0x2730,
-	0xa864, 0x2068, 0xa81a, 0x9d84, 0x000f, 0x9088, 0x1d04, 0x2165,
-	0x0002, 0x1690, 0x16dd, 0x1690, 0x1690, 0x1690, 0x16bf, 0x1690,
-	0x1694, 0x1689, 0x16d4, 0x1690, 0x1690, 0x1690, 0x1799, 0x16a8,
-	0x169e, 0xa964, 0x918c, 0x00ff, 0x918e, 0x0048, 0x0904, 0x16d4,
-	0x9085, 0x0001, 0x0804, 0x1790, 0xa87c, 0xd0bc, 0x0dc8, 0xa890,
-	0xa842, 0xa88c, 0xa83e, 0xa888, 0x0804, 0x16e4, 0xa87c, 0xd0bc,
-	0x0d78, 0xa890, 0xa842, 0xa88c, 0xa83e, 0xa888, 0x0804, 0x1733,
-	0xa87c, 0xd0bc, 0x0d28, 0xa890, 0xa842, 0xa88c, 0xa83e, 0xa804,
+	0x1b0a, 0x782c, 0x201a, 0x8318, 0x221a, 0x7803, 0x0000, 0x2069,
+	0x1a51, 0x901e, 0x20a9, 0x0020, 0x7b26, 0x7a28, 0x226a, 0x8d68,
+	0x8318, 0x1f04, 0x0db4, 0x2069, 0x1a71, 0x2019, 0x0050, 0x20a9,
+	0x0020, 0x7b26, 0x7a28, 0x226a, 0x8d68, 0x8318, 0x1f04, 0x0dc1,
+	0x0491, 0x002e, 0x003e, 0x00de, 0x015e, 0x2079, 0x1800, 0x7803,
+	0x0005, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x0180,
+	0x2001, 0x19fa, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b, 0x2004,
+	0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002, 0x2003, 0x1001,
+	0x080c, 0x53b7, 0x1170, 0x080c, 0x0f08, 0x0110, 0x080c, 0x0e5b,
+	0x080c, 0x53b7, 0x1130, 0x2071, 0x1800, 0x2011, 0x8000, 0x080c,
+	0x0f1c, 0x0c70, 0x0005, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007,
+	0x9086, 0x0001, 0x1120, 0x2001, 0x0015, 0x080c, 0x98b8, 0x2079,
+	0x0380, 0x2069, 0x1adb, 0x7818, 0x6802, 0x781c, 0x6806, 0x7840,
+	0x680a, 0x7844, 0x680e, 0x782c, 0x6812, 0x2019, 0x1ae6, 0x9016,
+	0x7808, 0xd09c, 0x0150, 0x7820, 0x201a, 0x8210, 0x8318, 0x8210,
+	0x9282, 0x0011, 0x0ea8, 0x2011, 0xdead, 0x6a2a, 0x7830, 0x681a,
+	0x7834, 0x681e, 0x7838, 0x6822, 0x783c, 0x6826, 0x7803, 0x0000,
+	0x2069, 0x1a9b, 0x901e, 0x20a9, 0x0020, 0x7b26, 0x7828, 0x206a,
+	0x8d68, 0x8318, 0x1f04, 0x0e35, 0x2069, 0x1abb, 0x2019, 0x00b0,
+	0x20a9, 0x0020, 0x7b26, 0x7828, 0x206a, 0x8d68, 0x8318, 0x1f04,
+	0x0e42, 0x0005, 0x918c, 0x03ff, 0x2001, 0x0003, 0x2004, 0x9084,
+	0x0600, 0x1118, 0x918d, 0x6c00, 0x0010, 0x918d, 0x6400, 0x2001,
+	0x017f, 0x2102, 0x0005, 0x0026, 0x0126, 0x2011, 0x0080, 0x080c,
+	0x0efa, 0x20a9, 0x0900, 0x080c, 0x0f30, 0x2011, 0x0040, 0x080c,
+	0x0efa, 0x20a9, 0x0900, 0x080c, 0x0f30, 0x0c78, 0x0026, 0x080c,
+	0x0f08, 0x1188, 0x2011, 0x010e, 0x2214, 0x9294, 0x0007, 0x9296,
+	0x0007, 0x0118, 0x2011, 0x0947, 0x0010, 0x2011, 0x1b47, 0x080c,
+	0x0f1c, 0x002e, 0x0005, 0x2011, 0x010e, 0x2214, 0x9294, 0x0007,
+	0x9296, 0x0007, 0x0118, 0x2011, 0xa880, 0x0010, 0x2011, 0x6840,
+	0xd0e4, 0x70ef, 0x0000, 0x1128, 0x70ef, 0x0fa0, 0x080c, 0x0f0d,
+	0x002e, 0x0005, 0x0026, 0x080c, 0x0f08, 0x0148, 0xd0a4, 0x1138,
+	0x2011, 0xcdd5, 0x0010, 0x2011, 0x0080, 0x080c, 0x0f0d, 0x002e,
+	0x0005, 0x0026, 0x70ef, 0x0000, 0x080c, 0x0f08, 0x1130, 0x2011,
+	0x8040, 0x080c, 0x0f1c, 0x002e, 0x0005, 0x080c, 0x2850, 0x1118,
+	0x2011, 0xcdc5, 0x0010, 0x2011, 0xcac2, 0x080c, 0x0f0d, 0x002e,
+	0x0005, 0x00e6, 0x0016, 0x0006, 0x2071, 0x1800, 0xd0b4, 0x70e8,
+	0x71e4, 0x1118, 0xc0e4, 0xc1f4, 0x0050, 0x0006, 0x3b00, 0x9084,
+	0xff3e, 0x20d8, 0x000e, 0x70ef, 0x0000, 0xc0e5, 0xc1f5, 0x0099,
+	0x000e, 0x001e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0xd0e4,
+	0x70e8, 0x1110, 0xc0dc, 0x0008, 0xc0dd, 0x0016, 0x71e4, 0x0019,
+	0x001e, 0x00ee, 0x0005, 0x70ea, 0x71e6, 0x7000, 0x9084, 0x0007,
+	0x000b, 0x0005, 0x0ec0, 0x0e9a, 0x0e9a, 0x0e6e, 0x0ea9, 0x0e9a,
+	0x0e9a, 0x0ea9, 0xc284, 0x0016, 0x3b08, 0x3a00, 0x9104, 0x918d,
+	0x00c1, 0x21d8, 0x9084, 0xff3e, 0x9205, 0x20d0, 0x001e, 0x0005,
+	0x2001, 0x183a, 0x2004, 0xd0dc, 0x0005, 0x9e86, 0x1800, 0x190c,
+	0x0d65, 0x70e8, 0xd0e4, 0x0108, 0xc2e5, 0x72ea, 0xd0e4, 0x1118,
+	0x9294, 0x00c1, 0x08f9, 0x0005, 0x9e86, 0x1800, 0x190c, 0x0d65,
+	0x70e4, 0xd0f4, 0x0108, 0xc2f5, 0x72e6, 0xd0f4, 0x1140, 0x9284,
+	0x8000, 0x8005, 0xc284, 0x9215, 0x9294, 0x00c1, 0x0861, 0x0005,
+	0x1d04, 0x0f30, 0x2091, 0x6000, 0x1f04, 0x0f30, 0x0005, 0x890e,
+	0x810e, 0x810f, 0x9194, 0x003f, 0x918c, 0xffc0, 0x0005, 0x0006,
+	0x2200, 0x914d, 0x894f, 0x894d, 0x894d, 0x000e, 0x0005, 0x01d6,
+	0x0146, 0x0036, 0x0096, 0x2061, 0x188b, 0x600b, 0x0000, 0x600f,
+	0x0000, 0x6003, 0x0000, 0x6007, 0x0000, 0x2009, 0xffc0, 0x2105,
+	0x0006, 0x2001, 0xaaaa, 0x200f, 0x2019, 0x5555, 0x9016, 0x2049,
+	0x0bff, 0xab02, 0xa001, 0xa001, 0xa800, 0x9306, 0x1138, 0x2105,
+	0x9306, 0x0120, 0x8210, 0x99c8, 0x0400, 0x0c98, 0x000e, 0x200f,
+	0x2001, 0x189b, 0x928a, 0x000e, 0x1638, 0x928a, 0x0006, 0x2011,
+	0x0006, 0x1210, 0x2011, 0x0000, 0x2202, 0x9006, 0x2008, 0x82ff,
+	0x01b0, 0x8200, 0x600a, 0x600f, 0xffff, 0x6003, 0x0002, 0x6007,
+	0x0000, 0x0026, 0x2019, 0x0010, 0x9280, 0x0001, 0x20e8, 0x21a0,
+	0x21a8, 0x4104, 0x8319, 0x1de0, 0x8211, 0x1da0, 0x002e, 0x009e,
+	0x003e, 0x014e, 0x01de, 0x0005, 0x2011, 0x000e, 0x08e8, 0x0016,
+	0x0026, 0x0096, 0x3348, 0x080c, 0x0f37, 0x2100, 0x9300, 0x2098,
+	0x22e0, 0x009e, 0x002e, 0x001e, 0x0036, 0x3518, 0x20a9, 0x0001,
+	0x4002, 0x8007, 0x4004, 0x8319, 0x1dd8, 0x003e, 0x0005, 0x20e9,
+	0x0001, 0x71b4, 0x81ff, 0x11c0, 0x9006, 0x2009, 0x0200, 0x20a9,
+	0x0002, 0x9298, 0x0018, 0x23a0, 0x4001, 0x2009, 0x0700, 0x20a9,
+	0x0002, 0x9298, 0x0008, 0x23a0, 0x4001, 0x7078, 0x8007, 0x717c,
+	0x810f, 0x20a9, 0x0002, 0x4001, 0x9298, 0x000c, 0x23a0, 0x900e,
+	0x080c, 0x0d45, 0x2001, 0x0000, 0x810f, 0x20a9, 0x0002, 0x4001,
+	0x0005, 0x89ff, 0x0140, 0xa804, 0xa807, 0x0000, 0x0006, 0x080c,
+	0x1061, 0x009e, 0x0cb0, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c,
+	0x10da, 0x090c, 0x0d65, 0x00ee, 0x0005, 0x0086, 0x00e6, 0x0006,
+	0x0026, 0x0036, 0x0126, 0x2091, 0x8000, 0x00c9, 0x2071, 0x1800,
+	0x73bc, 0x702c, 0x9016, 0x9045, 0x0158, 0x8210, 0x9906, 0x090c,
+	0x0d65, 0x2300, 0x9202, 0x0120, 0x1a0c, 0x0d65, 0xa000, 0x0c98,
+	0x012e, 0x003e, 0x002e, 0x000e, 0x00ee, 0x008e, 0x0005, 0x0086,
+	0x00e6, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x190e, 0x7010,
+	0x9005, 0x0140, 0x7018, 0x9045, 0x0128, 0x9906, 0x090c, 0x0d65,
+	0xa000, 0x0cc8, 0x012e, 0x000e, 0x00ee, 0x008e, 0x0005, 0x00e6,
+	0x2071, 0x1800, 0x0126, 0x2091, 0x8000, 0x70bc, 0x8001, 0x0270,
+	0x70be, 0x702c, 0x2048, 0x9085, 0x0001, 0xa800, 0x702e, 0xa803,
+	0x0000, 0xa807, 0x0000, 0x012e, 0x00ee, 0x0005, 0x904e, 0x0cd8,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x70bc, 0x90ca,
+	0x0040, 0x0268, 0x8001, 0x70be, 0x702c, 0x2048, 0xa800, 0x702e,
+	0xa803, 0x0000, 0xa807, 0x0000, 0x012e, 0x00ee, 0x0005, 0x904e,
+	0x0cd8, 0x00e6, 0x0126, 0x2091, 0x8000, 0x0016, 0x890e, 0x810e,
+	0x810f, 0x9184, 0x003f, 0xa862, 0x9184, 0xffc0, 0xa85e, 0x001e,
+	0x0020, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x702c,
+	0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x8087,
+	0x012e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9026, 0x2009, 0x0000,
+	0x2049, 0x0400, 0x2900, 0x702e, 0x8940, 0x2800, 0xa802, 0xa95e,
+	0xa863, 0x0001, 0x8420, 0x9886, 0x0440, 0x0120, 0x2848, 0x9188,
+	0x0040, 0x0c90, 0x2071, 0x188b, 0x7000, 0x9005, 0x11a0, 0x2001,
+	0x049b, 0xa802, 0x2048, 0x2009, 0x26c0, 0x8940, 0x2800, 0xa802,
+	0xa95e, 0xa863, 0x0001, 0x8420, 0x9886, 0x0800, 0x0120, 0x2848,
+	0x9188, 0x0040, 0x0c90, 0x2071, 0x188b, 0x7104, 0x7200, 0x82ff,
+	0x01d0, 0x7308, 0x8318, 0x831f, 0x831b, 0x831b, 0x7312, 0x8319,
+	0x2001, 0x0800, 0xa802, 0x2048, 0x8900, 0xa802, 0x2040, 0xa95e,
+	0xaa62, 0x8420, 0x2300, 0x9906, 0x0130, 0x2848, 0x9188, 0x0040,
+	0x9291, 0x0000, 0x0c88, 0xa803, 0x0000, 0x2071, 0x1800, 0x74ba,
+	0x74be, 0x0005, 0x00e6, 0x0016, 0x9984, 0xfc00, 0x01e8, 0x908c,
+	0xf800, 0x1168, 0x9982, 0x0400, 0x02b8, 0x9982, 0x0440, 0x0278,
+	0x9982, 0x049b, 0x0288, 0x9982, 0x0800, 0x1270, 0x0040, 0x9982,
+	0x0800, 0x0250, 0x2071, 0x188b, 0x7010, 0x9902, 0x1228, 0x9085,
+	0x0001, 0x001e, 0x00ee, 0x0005, 0x9006, 0x0cd8, 0x00e6, 0x2071,
+	0x19f9, 0x7007, 0x0000, 0x9006, 0x701e, 0x7022, 0x7002, 0x2071,
+	0x0000, 0x7010, 0x9085, 0x8044, 0x7012, 0x2071, 0x0080, 0x9006,
+	0x702b, 0x0060, 0x20a9, 0x0040, 0x7022, 0x1f04, 0x1114, 0x702b,
+	0x0060, 0x702b, 0x0020, 0x20a9, 0x0040, 0x7022, 0x1f04, 0x111d,
+	0x702b, 0x0020, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x00e6,
+	0xa06f, 0x0000, 0x2071, 0x19f9, 0x701c, 0x9088, 0x1a03, 0x280a,
+	0x8000, 0x9084, 0x003f, 0x701e, 0x7120, 0x9106, 0x090c, 0x0d65,
+	0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080, 0x00a9, 0x00fe,
+	0x00ee, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x00e6, 0x2071,
+	0x19f9, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080, 0x0021,
+	0x00fe, 0x00ee, 0x012e, 0x0005, 0x7004, 0x9086, 0x0000, 0x1110,
+	0x7007, 0x0006, 0x7000, 0x0002, 0x1166, 0x1164, 0x1164, 0x1164,
+	0x12dd, 0x12dd, 0x12dd, 0x12dd, 0x080c, 0x0d65, 0x701c, 0x7120,
+	0x9106, 0x1148, 0x792c, 0x9184, 0x0001, 0x1120, 0xd1fc, 0x1110,
+	0x7007, 0x0000, 0x0005, 0x0096, 0x9180, 0x1a03, 0x2004, 0x700a,
+	0x2048, 0x8108, 0x918c, 0x003f, 0x7122, 0x782b, 0x0026, 0xa88c,
+	0x7802, 0xa890, 0x7806, 0xa894, 0x780a, 0xa898, 0x780e, 0xa878,
+	0x700e, 0xa870, 0x7016, 0xa874, 0x701a, 0xa868, 0x009e, 0xd084,
+	0x0120, 0x7007, 0x0001, 0x0029, 0x0005, 0x7007, 0x0002, 0x00b1,
+	0x0005, 0x0016, 0x0026, 0x710c, 0x2011, 0x0040, 0x9182, 0x0040,
+	0x1210, 0x2110, 0x9006, 0x700e, 0x7212, 0x8203, 0x7812, 0x782b,
+	0x0020, 0x782b, 0x0041, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026,
+	0x0136, 0x0146, 0x0156, 0x7014, 0x20e0, 0x7018, 0x2098, 0x20e9,
+	0x0000, 0x20a1, 0x0088, 0x782b, 0x0026, 0x710c, 0x2011, 0x0040,
+	0x9182, 0x0040, 0x1210, 0x2110, 0x9006, 0x700e, 0x22a8, 0x4006,
+	0x8203, 0x7812, 0x782b, 0x0020, 0x3300, 0x701a, 0x782b, 0x0001,
+	0x015e, 0x014e, 0x013e, 0x002e, 0x001e, 0x0005, 0x2009, 0x19f9,
+	0x2104, 0xc095, 0x200a, 0x080c, 0x1143, 0x0005, 0x0016, 0x00e6,
+	0x2071, 0x19f9, 0x00f6, 0x2079, 0x0080, 0x792c, 0xd1bc, 0x190c,
+	0x0d5e, 0x782b, 0x0002, 0xd1fc, 0x0120, 0x918c, 0x0700, 0x7004,
+	0x0023, 0x00fe, 0x00ee, 0x001e, 0x0005, 0x1154, 0x11fc, 0x1230,
+	0x0d65, 0x0d65, 0x12e9, 0x0d65, 0x918c, 0x0700, 0x1550, 0x0136,
+	0x0146, 0x0156, 0x7014, 0x20e8, 0x7018, 0x20a0, 0x20e1, 0x0000,
+	0x2099, 0x0088, 0x782b, 0x0040, 0x7010, 0x20a8, 0x4005, 0x3400,
+	0x701a, 0x015e, 0x014e, 0x013e, 0x700c, 0x9005, 0x0578, 0x7800,
+	0x7802, 0x7804, 0x7806, 0x080c, 0x1199, 0x0005, 0x7008, 0x0096,
+	0x2048, 0xa86f, 0x0100, 0x009e, 0x7007, 0x0000, 0x080c, 0x1154,
+	0x0005, 0x7008, 0x0096, 0x2048, 0xa86f, 0x0200, 0x009e, 0x0ca0,
+	0x918c, 0x0700, 0x1150, 0x700c, 0x9005, 0x0180, 0x7800, 0x7802,
+	0x7804, 0x7806, 0x080c, 0x11ae, 0x0005, 0x7008, 0x0096, 0x2048,
+	0xa86f, 0x0200, 0x009e, 0x7007, 0x0000, 0x0080, 0x0096, 0x7008,
+	0x2048, 0x7800, 0xa88e, 0x7804, 0xa892, 0x7808, 0xa896, 0x780c,
+	0xa89a, 0xa86f, 0x0100, 0x009e, 0x7007, 0x0000, 0x0096, 0x00d6,
+	0x7008, 0x2048, 0x2001, 0x18b7, 0x2004, 0x9906, 0x1128, 0xa89c,
+	0x080f, 0x00de, 0x009e, 0x00a0, 0x00de, 0x009e, 0x0096, 0x00d6,
+	0x7008, 0x2048, 0x0081, 0x0150, 0xa89c, 0x0086, 0x2940, 0x080f,
+	0x008e, 0x00de, 0x009e, 0x080c, 0x1143, 0x0005, 0x00de, 0x009e,
+	0x080c, 0x1143, 0x0005, 0xa8a8, 0xd08c, 0x0005, 0x0096, 0xa0a0,
+	0x904d, 0x090c, 0x0d65, 0xa06c, 0x908e, 0x0100, 0x0130, 0xa87b,
+	0x0030, 0xa883, 0x0000, 0xa897, 0x4002, 0x080c, 0x69a9, 0xa09f,
+	0x0000, 0xa0a3, 0x0000, 0x2848, 0x080c, 0x1061, 0x009e, 0x0005,
+	0x00a6, 0xa0a0, 0x904d, 0x090c, 0x0d65, 0xa06c, 0x908e, 0x0100,
+	0x0128, 0xa87b, 0x0001, 0xa883, 0x0000, 0x00c0, 0xa80c, 0x2050,
+	0xb004, 0x9005, 0x0198, 0xa80e, 0x2050, 0x8006, 0x8006, 0x8007,
+	0x908c, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0xa076, 0xa172,
+	0xb000, 0xa07a, 0x2810, 0x080c, 0x1124, 0x00e8, 0xa97c, 0xa894,
+	0x0016, 0x0006, 0x080c, 0x69a9, 0x000e, 0x001e, 0xd1fc, 0x1138,
+	0xd1f4, 0x0128, 0x00c6, 0x2060, 0x080c, 0x9be6, 0x00ce, 0x7008,
+	0x2048, 0xa89f, 0x0000, 0xa8a3, 0x0000, 0x080c, 0x1061, 0x7007,
+	0x0000, 0x080c, 0x1143, 0x00ae, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x782b, 0x1001, 0x7007, 0x0005, 0x7000, 0xc094, 0x7002, 0x012e,
+	0x0005, 0x7007, 0x0000, 0x080c, 0x1154, 0x0005, 0x0126, 0x2091,
+	0x2200, 0x2079, 0x0300, 0x2071, 0x1a43, 0x7003, 0x0000, 0x78bf,
+	0x00f6, 0x0041, 0x7807, 0x0007, 0x7803, 0x0000, 0x7803, 0x0001,
+	0x012e, 0x0005, 0x00c6, 0x7803, 0x0000, 0x2001, 0x0165, 0x2003,
+	0x4198, 0x7808, 0xd09c, 0x0110, 0x7820, 0x0cd8, 0x2001, 0x1a44,
+	0x2003, 0x0000, 0x78ab, 0x0004, 0x78ac, 0xd0ac, 0x1de8, 0x78ab,
+	0x0002, 0x7807, 0x0007, 0x7827, 0x0030, 0x782b, 0x0400, 0x7827,
+	0x0031, 0x782b, 0x1a51, 0x781f, 0xff00, 0x781b, 0xff00, 0x2001,
+	0x0200, 0x2004, 0xd0dc, 0x0110, 0x781f, 0x0303, 0x2061, 0x1a51,
+	0x602f, 0x1ddc, 0x2001, 0x1819, 0x2004, 0x9082, 0x1ddc, 0x6032,
+	0x603b, 0x1d1c, 0x602b, 0x1a91, 0x6007, 0x1a71, 0x2061, 0x1a71,
+	0x00ce, 0x0005, 0x0126, 0x2091, 0x2200, 0x7908, 0x9184, 0x0070,
+	0x190c, 0x0d5e, 0xd19c, 0x05a0, 0x7820, 0x908c, 0xf000, 0x0540,
+	0x2060, 0x6020, 0x9086, 0x0003, 0x1550, 0x6000, 0x9086, 0x0004,
+	0x1530, 0x6114, 0x2148, 0xa876, 0xa87a, 0xa867, 0x0103, 0x080c,
+	0x67cb, 0x00b6, 0x6010, 0x2058, 0xba3c, 0x8211, 0x0208, 0xba3e,
+	0xb8c0, 0x9005, 0x190c, 0x63ba, 0x00be, 0x6044, 0xd0fc, 0x190c,
+	0x98f0, 0x080c, 0x9c0e, 0x7808, 0xd09c, 0x19b0, 0x012e, 0x0005,
+	0x908a, 0x0024, 0x1a0c, 0x0d65, 0x002b, 0x012e, 0x0005, 0x04b0,
+	0x012e, 0x0005, 0x13a6, 0x13cc, 0x13fc, 0x1401, 0x1405, 0x140a,
+	0x1432, 0x1436, 0x1444, 0x1448, 0x13a6, 0x14d4, 0x14d8, 0x153b,
+	0x13a6, 0x13a6, 0x13a6, 0x13a6, 0x13a6, 0x13a6, 0x13a6, 0x13a6,
+	0x13a6, 0x13a6, 0x13a6, 0x13a6, 0x13a6, 0x140c, 0x13a6, 0x13d4,
+	0x13f9, 0x13c0, 0x13a6, 0x13e0, 0x13aa, 0x13a8, 0x080c, 0x0d65,
+	0x080c, 0x0d5e, 0x080c, 0x1542, 0x2009, 0x1a50, 0x2104, 0x8000,
+	0x200a, 0x080c, 0x7b25, 0x080c, 0x1989, 0x0005, 0x6044, 0xd0fc,
+	0x190c, 0x98f0, 0x2009, 0x0055, 0x080c, 0x9c82, 0x012e, 0x0005,
+	0x080c, 0x1542, 0x2060, 0x6044, 0xd0fc, 0x190c, 0x98f0, 0x2009,
+	0x0055, 0x080c, 0x9c82, 0x0005, 0x2009, 0x0048, 0x080c, 0x1542,
+	0x2060, 0x080c, 0x9c82, 0x0005, 0x2009, 0x0054, 0x080c, 0x1542,
+	0x2060, 0x6044, 0xd0fc, 0x190c, 0x98f0, 0x080c, 0x9c82, 0x0005,
+	0x080c, 0x1542, 0x2060, 0x0056, 0x0066, 0x080c, 0x1542, 0x2028,
+	0x080c, 0x1542, 0x2030, 0x0036, 0x0046, 0x2021, 0x0000, 0x2418,
+	0x2009, 0x0056, 0x080c, 0x9c82, 0x004e, 0x003e, 0x006e, 0x005e,
+	0x0005, 0x080c, 0x1542, 0x0005, 0x7004, 0xc085, 0xc0b5, 0x7006,
+	0x0005, 0x7004, 0xc085, 0x7006, 0x0005, 0x080c, 0x1542, 0x080c,
+	0x15ff, 0x0005, 0x080c, 0x0d65, 0x080c, 0x1542, 0x2060, 0x6014,
+	0x0096, 0x2048, 0xa83b, 0xffff, 0x009e, 0x2009, 0x0048, 0x080c,
+	0x9c82, 0x2001, 0x015d, 0x2003, 0x0000, 0x2009, 0x03e8, 0x8109,
+	0x0160, 0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8, 0x2001, 0x0218,
+	0x2004, 0xd0ec, 0x1110, 0x080c, 0x1547, 0x2001, 0x0307, 0x2003,
+	0x8000, 0x0005, 0x7004, 0xc095, 0x7006, 0x0005, 0x080c, 0x1542,
+	0x2060, 0x6014, 0x0096, 0x2048, 0xa83b, 0xffff, 0x009e, 0x2009,
+	0x0048, 0x080c, 0x9c82, 0x0005, 0x080c, 0x1542, 0x080c, 0x0d65,
+	0x080c, 0x1542, 0x080c, 0x14bf, 0x7827, 0x0018, 0x79ac, 0xd1dc,
+	0x0540, 0x7827, 0x0015, 0x7828, 0x782b, 0x0000, 0x9065, 0x0138,
+	0x2001, 0x020d, 0x2003, 0x0050, 0x2003, 0x0020, 0x0400, 0x7004,
+	0x9005, 0x1180, 0x78ab, 0x0004, 0x7827, 0x0018, 0x782b, 0x0000,
+	0xd1bc, 0x090c, 0x0d65, 0x2001, 0x020d, 0x2003, 0x0050, 0x2003,
+	0x0020, 0x0490, 0x78ab, 0x0004, 0x7803, 0x0001, 0x080c, 0x14d8,
+	0x0005, 0x7828, 0x782b, 0x0000, 0x9065, 0x090c, 0x0d65, 0x6014,
+	0x2048, 0x78ab, 0x0004, 0x918c, 0x0700, 0x01a8, 0x080c, 0x7b25,
+	0x080c, 0x1989, 0x080c, 0xb870, 0x0158, 0xa9ac, 0xa936, 0xa9b0,
+	0xa93a, 0xa83f, 0xffff, 0xa843, 0xffff, 0xa880, 0xc0bd, 0xa882,
+	0x080c, 0xb45e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x6024, 0x190c, 0xbc71, 0x2029, 0x00c8, 0x8529, 0x0128,
+	0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8, 0x7dbc, 0x080c, 0xd61c,
+	0xd5a4, 0x1118, 0x080c, 0x1547, 0x0005, 0x080c, 0x7b25, 0x080c,
+	0x1989, 0x0005, 0x781f, 0x0300, 0x7803, 0x0001, 0x0005, 0x0016,
+	0x0066, 0x0076, 0x00f6, 0x2079, 0x0300, 0x7908, 0x918c, 0x0007,
+	0x9186, 0x0003, 0x0120, 0x2001, 0x0016, 0x080c, 0x15b8, 0x00fe,
+	0x007e, 0x006e, 0x001e, 0x0005, 0x7004, 0xc09d, 0x7006, 0x0005,
+	0x7104, 0x9184, 0x0004, 0x190c, 0x0d65, 0xd184, 0x1189, 0xd19c,
+	0x0158, 0xc19c, 0x7106, 0x2001, 0x020d, 0x2003, 0x0050, 0x2003,
+	0x0020, 0x080c, 0x1547, 0x0005, 0x81ff, 0x190c, 0x0d65, 0x0005,
+	0xc184, 0xd1b4, 0xc1b4, 0x7106, 0x0016, 0x00e6, 0x15e0, 0x2071,
+	0x0200, 0x080c, 0x15f3, 0x6014, 0x9005, 0x05a8, 0x0096, 0x2048,
+	0xa864, 0x009e, 0x9084, 0x00ff, 0x908e, 0x0029, 0x0160, 0x908e,
+	0x0048, 0x1548, 0x601c, 0xd084, 0x11d8, 0x00f6, 0x2c78, 0x080c,
+	0x1669, 0x00fe, 0x00a8, 0x00f6, 0x2c78, 0x080c, 0x17b1, 0x00fe,
+	0x2009, 0x01f4, 0x8109, 0x0160, 0x2001, 0x0201, 0x2004, 0x9005,
+	0x0dc8, 0x2001, 0x0218, 0x2004, 0xd0ec, 0x1110, 0x0401, 0x0040,
+	0x2001, 0x020d, 0x2003, 0x0020, 0x080c, 0x1302, 0x7803, 0x0001,
+	0x00ee, 0x001e, 0x0005, 0x2001, 0x020d, 0x2003, 0x0050, 0x2003,
+	0x0020, 0x0069, 0x0ca8, 0x0031, 0x2060, 0x2009, 0x0053, 0x080c,
+	0x9c82, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820, 0x0005, 0x080c,
+	0x14bf, 0x00d6, 0x2069, 0x0200, 0x2009, 0x01f4, 0x8109, 0x0510,
+	0x6804, 0x9005, 0x0dd8, 0x2001, 0x015d, 0x2003, 0x0000, 0x79bc,
+	0xd1a4, 0x1528, 0x79b8, 0x918c, 0x0fff, 0x0180, 0x9182, 0x0841,
+	0x1268, 0x9188, 0x0007, 0x918c, 0x0ff8, 0x810c, 0x810c, 0x810c,
+	0x080c, 0x15aa, 0x6827, 0x0001, 0x8109, 0x1dd0, 0x04d9, 0x6827,
+	0x0002, 0x04c1, 0x6804, 0x9005, 0x1130, 0x682c, 0xd0e4, 0x1500,
+	0x6804, 0x9005, 0x0de8, 0x79b8, 0xd1ec, 0x1130, 0x08c0, 0x080c,
+	0x7b25, 0x080c, 0x1989, 0x0090, 0x7827, 0x0015, 0x782b, 0x0000,
+	0x7827, 0x0018, 0x782b, 0x0000, 0x2001, 0x020d, 0x2003, 0x0020,
+	0x2001, 0x0307, 0x2003, 0x0300, 0x7803, 0x0001, 0x00de, 0x0005,
+	0x682c, 0x9084, 0x5400, 0x9086, 0x5400, 0x0d30, 0x7827, 0x0015,
+	0x782b, 0x0000, 0x7803, 0x0001, 0x6800, 0x9085, 0x1800, 0x6802,
+	0x00de, 0x0005, 0x6824, 0x9084, 0x0003, 0x1de0, 0x0005, 0x2001,
+	0x0030, 0x2c08, 0x621c, 0x0021, 0x7830, 0x9086, 0x0041, 0x0005,
+	0x00f6, 0x2079, 0x0300, 0x0006, 0x7808, 0xd09c, 0x0140, 0x0016,
+	0x0026, 0x00c6, 0x080c, 0x1342, 0x00ce, 0x002e, 0x001e, 0x000e,
+	0x0006, 0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080, 0x0059, 0x1118,
+	0x000e, 0x00fe, 0x0005, 0x000e, 0x792c, 0x3900, 0x8000, 0x2004,
+	0x080c, 0x0d65, 0x2009, 0xff00, 0x8109, 0x0120, 0x7818, 0xd0bc,
+	0x1dd8, 0x0005, 0x9085, 0x0001, 0x0005, 0x7832, 0x7936, 0x7a3a,
+	0x781b, 0x8080, 0x0c79, 0x1108, 0x0005, 0x792c, 0x3900, 0x8000,
+	0x2004, 0x080c, 0x0d65, 0x7037, 0x0001, 0x7150, 0x7037, 0x0002,
+	0x7050, 0x2060, 0xd1bc, 0x1110, 0x7054, 0x2060, 0x0005, 0x00e6,
+	0x0016, 0x2071, 0x0200, 0x0c79, 0x6124, 0xd1dc, 0x01f8, 0x701c,
+	0xd08c, 0x0904, 0x165e, 0x7017, 0x0000, 0x2001, 0x0264, 0x2004,
+	0xd0bc, 0x0904, 0x165e, 0x2001, 0x0268, 0x00c6, 0x2064, 0x6104,
+	0x6038, 0x00ce, 0x918e, 0x0039, 0x1904, 0x165e, 0x9c06, 0x15f0,
+	0x0126, 0x2091, 0x2600, 0x080c, 0x7a7d, 0x012e, 0x7358, 0x745c,
+	0x6014, 0x905d, 0x0598, 0x2b48, 0x6010, 0x00b6, 0x2058, 0xb800,
+	0x00be, 0xd0bc, 0x190c, 0xbc4c, 0xab42, 0xac3e, 0x2001, 0x187d,
+	0x2004, 0xd0b4, 0x1170, 0x601c, 0xd0e4, 0x1158, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x1120, 0xa83b, 0x7fff, 0xa837,
+	0xffff, 0x080c, 0x1d3c, 0x1190, 0x080c, 0x180c, 0x2a00, 0xa816,
+	0x0130, 0x2800, 0xa80e, 0x2c05, 0xa80a, 0x2c00, 0xa812, 0x7037,
+	0x0020, 0x781f, 0x0300, 0x001e, 0x00ee, 0x0005, 0x7037, 0x0050,
+	0x7037, 0x0020, 0x001e, 0x00ee, 0x080c, 0x1547, 0x0005, 0x080c,
+	0x0d65, 0x0016, 0x2009, 0x00a0, 0x8109, 0xa001, 0xa001, 0xa001,
+	0x1dd8, 0x001e, 0x2cf0, 0x0126, 0x2091, 0x2200, 0x00c6, 0x3e60,
+	0x6014, 0x2048, 0x2940, 0x903e, 0x2730, 0xa864, 0x2068, 0xa81a,
+	0x9d84, 0x000f, 0x9088, 0x1d1c, 0x2165, 0x0002, 0x169d, 0x16ea,
+	0x169d, 0x169d, 0x169d, 0x16cc, 0x169d, 0x16a1, 0x1696, 0x16e1,
+	0x169d, 0x169d, 0x169d, 0x17a6, 0x16b5, 0x16ab, 0xa964, 0x918c,
+	0x00ff, 0x918e, 0x0048, 0x0904, 0x16e1, 0x9085, 0x0001, 0x0804,
+	0x179d, 0xa87c, 0xd0bc, 0x0dc8, 0xa890, 0xa842, 0xa88c, 0xa83e,
+	0xa888, 0x0804, 0x16f1, 0xa87c, 0xd0bc, 0x0d78, 0xa890, 0xa842,
+	0xa88c, 0xa83e, 0xa888, 0x0804, 0x1740, 0xa87c, 0xd0bc, 0x0d28,
+	0xa890, 0xa842, 0xa88c, 0xa83e, 0xa804, 0x9045, 0x090c, 0x0d65,
+	0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80, 0x1d1c, 0x2065, 0xa888,
+	0xd19c, 0x1904, 0x1740, 0x0428, 0xa87c, 0xd0ac, 0x0970, 0xa804,
 	0x9045, 0x090c, 0x0d65, 0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80,
-	0x1d04, 0x2065, 0xa888, 0xd19c, 0x1904, 0x1733, 0x0428, 0xa87c,
-	0xd0ac, 0x0970, 0xa804, 0x9045, 0x090c, 0x0d65, 0xa164, 0xa91a,
-	0x91ec, 0x000f, 0x9d80, 0x1d04, 0x2065, 0x9006, 0xa842, 0xa83e,
-	0xd19c, 0x1904, 0x1733, 0x0080, 0xa87c, 0xd0ac, 0x0904, 0x1690,
-	0x9006, 0xa842, 0xa83e, 0x0804, 0x1733, 0xa87c, 0xd0ac, 0x0904,
-	0x1690, 0x9006, 0xa842, 0xa83e, 0x2c05, 0x908a, 0x0036, 0x1a0c,
-	0x0d65, 0x9082, 0x001b, 0x0002, 0x1707, 0x1707, 0x1709, 0x1707,
-	0x1707, 0x1707, 0x170f, 0x1707, 0x1707, 0x1707, 0x1715, 0x1707,
-	0x1707, 0x1707, 0x171b, 0x1707, 0x1707, 0x1707, 0x1721, 0x1707,
-	0x1707, 0x1707, 0x1727, 0x1707, 0x1707, 0x1707, 0x172d, 0x080c,
-	0x0d65, 0xa574, 0xa478, 0xa37c, 0xa280, 0x0804, 0x1778, 0xa584,
-	0xa488, 0xa38c, 0xa290, 0x0804, 0x1778, 0xa594, 0xa498, 0xa39c,
-	0xa2a0, 0x0804, 0x1778, 0xa5a4, 0xa4a8, 0xa3ac, 0xa2b0, 0x0804,
-	0x1778, 0xa5b4, 0xa4b8, 0xa3bc, 0xa2c0, 0x0804, 0x1778, 0xa5c4,
-	0xa4c8, 0xa3cc, 0xa2d0, 0x0804, 0x1778, 0xa5d4, 0xa4d8, 0xa3dc,
-	0xa2e0, 0x0804, 0x1778, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0d65,
-	0x9082, 0x001b, 0x0002, 0x1756, 0x1754, 0x1754, 0x1754, 0x1754,
-	0x1754, 0x175d, 0x1754, 0x1754, 0x1754, 0x1754, 0x1754, 0x1764,
-	0x1754, 0x1754, 0x1754, 0x1754, 0x1754, 0x176b, 0x1754, 0x1754,
-	0x1754, 0x1754, 0x1754, 0x1772, 0x080c, 0x0d65, 0xa56c, 0xa470,
-	0xa774, 0xa678, 0xa37c, 0xa280, 0x00d8, 0xa584, 0xa488, 0xa78c,
-	0xa690, 0xa394, 0xa298, 0x00a0, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8,
-	0xa3ac, 0xa2b0, 0x0068, 0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0, 0xa3c4,
-	0xa2c8, 0x0030, 0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8, 0xa3dc, 0xa2e0,
-	0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a, 0xa988, 0x8c60,
-	0x2c1d, 0xa8ac, 0xaab0, 0xa836, 0xaa3a, 0x8109, 0xa916, 0x1158,
-	0x3e60, 0x601c, 0xc085, 0x601e, 0xa87c, 0xc0dd, 0xa87e, 0x9006,
-	0x00ce, 0x012e, 0x0005, 0x2800, 0xa80e, 0xab0a, 0x2c00, 0xa812,
-	0x0c78, 0x0804, 0x1690, 0x0016, 0x2009, 0x00a0, 0x8109, 0xa001,
-	0xa001, 0xa001, 0x1dd8, 0x001e, 0x2ff0, 0x0126, 0x2091, 0x2200,
-	0x00c6, 0x3e60, 0x6014, 0x2048, 0x2940, 0xa80e, 0x2061, 0x1cff,
-	0xa813, 0x1cff, 0x2c05, 0xa80a, 0xa964, 0xa91a, 0xa87c, 0xd0ac,
-	0x090c, 0x0d65, 0x9006, 0xa842, 0xa83e, 0x2c05, 0x908a, 0x0034,
-	0x1a0c, 0x0d65, 0xadcc, 0xacd0, 0xafd4, 0xaed8, 0xabdc, 0xaae0,
-	0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a, 0xa8ac, 0xaab0,
-	0xa836, 0xaa3a, 0xa988, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0008,
-	0x1120, 0x8109, 0xa916, 0x0128, 0x0078, 0x918a, 0x0002, 0xa916,
-	0x1158, 0x3e60, 0x601c, 0xc085, 0x601e, 0xa87c, 0xc0dd, 0xa87e,
-	0x9006, 0x00ce, 0x012e, 0x0005, 0xa804, 0x9045, 0x090c, 0x0d65,
-	0xa80e, 0xa064, 0xa81a, 0x9084, 0x000f, 0x9080, 0x1d04, 0x2015,
-	0x82ff, 0x090c, 0x0d65, 0xaa12, 0x2205, 0xa80a, 0x0c10, 0x903e,
-	0x2730, 0xa880, 0xd0fc, 0x1190, 0x2d00, 0x0002, 0x18f4, 0x1856,
-	0x1856, 0x18f4, 0x18f4, 0x18ee, 0x18f4, 0x1856, 0x18a5, 0x18a5,
-	0x18a5, 0x18f4, 0x18f4, 0x18f4, 0x18eb, 0x18a5, 0xc0fc, 0xa882,
-	0xab2c, 0xaa30, 0xad1c, 0xac20, 0xdd9c, 0x0904, 0x18f6, 0x2c05,
-	0x908a, 0x0034, 0x1a0c, 0x0d65, 0x9082, 0x001b, 0x0002, 0x1842,
-	0x1840, 0x1840, 0x1840, 0x1840, 0x1840, 0x1846, 0x1840, 0x1840,
-	0x1840, 0x1840, 0x1840, 0x184a, 0x1840, 0x1840, 0x1840, 0x1840,
-	0x1840, 0x184e, 0x1840, 0x1840, 0x1840, 0x1840, 0x1840, 0x1852,
-	0x080c, 0x0d65, 0xa774, 0xa678, 0x0804, 0x18f6, 0xa78c, 0xa690,
-	0x0804, 0x18f6, 0xa7a4, 0xa6a8, 0x0804, 0x18f6, 0xa7bc, 0xa6c0,
-	0x0804, 0x18f6, 0xa7d4, 0xa6d8, 0x0804, 0x18f6, 0x2c05, 0x908a,
-	0x0036, 0x1a0c, 0x0d65, 0x9082, 0x001b, 0x0002, 0x1879, 0x1879,
-	0x187b, 0x1879, 0x1879, 0x1879, 0x1881, 0x1879, 0x1879, 0x1879,
-	0x1887, 0x1879, 0x1879, 0x1879, 0x188d, 0x1879, 0x1879, 0x1879,
-	0x1893, 0x1879, 0x1879, 0x1879, 0x1899, 0x1879, 0x1879, 0x1879,
-	0x189f, 0x080c, 0x0d65, 0xa574, 0xa478, 0xa37c, 0xa280, 0x0804,
-	0x18f6, 0xa584, 0xa488, 0xa38c, 0xa290, 0x0804, 0x18f6, 0xa594,
-	0xa498, 0xa39c, 0xa2a0, 0x0804, 0x18f6, 0xa5a4, 0xa4a8, 0xa3ac,
-	0xa2b0, 0x0804, 0x18f6, 0xa5b4, 0xa4b8, 0xa3bc, 0xa2c0, 0x0804,
-	0x18f6, 0xa5c4, 0xa4c8, 0xa3cc, 0xa2d0, 0x0804, 0x18f6, 0xa5d4,
-	0xa4d8, 0xa3dc, 0xa2e0, 0x0804, 0x18f6, 0x2c05, 0x908a, 0x0034,
-	0x1a0c, 0x0d65, 0x9082, 0x001b, 0x0002, 0x18c8, 0x18c6, 0x18c6,
-	0x18c6, 0x18c6, 0x18c6, 0x18cf, 0x18c6, 0x18c6, 0x18c6, 0x18c6,
-	0x18c6, 0x18d6, 0x18c6, 0x18c6, 0x18c6, 0x18c6, 0x18c6, 0x18dd,
-	0x18c6, 0x18c6, 0x18c6, 0x18c6, 0x18c6, 0x18e4, 0x080c, 0x0d65,
-	0xa56c, 0xa470, 0xa774, 0xa678, 0xa37c, 0xa280, 0x0438, 0xa584,
-	0xa488, 0xa78c, 0xa690, 0xa394, 0xa298, 0x0400, 0xa59c, 0xa4a0,
-	0xa7a4, 0xa6a8, 0xa3ac, 0xa2b0, 0x00c8, 0xa5b4, 0xa4b8, 0xa7bc,
-	0xa6c0, 0xa3c4, 0xa2c8, 0x0090, 0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8,
-	0xa3dc, 0xa2e0, 0x0058, 0x9d86, 0x000e, 0x1130, 0x080c, 0x1cda,
-	0x1904, 0x17ff, 0x900e, 0x0050, 0x080c, 0x0d65, 0xab2e, 0xaa32,
-	0xad1e, 0xac22, 0xaf26, 0xae2a, 0x080c, 0x1cda, 0x0005, 0x6014,
-	0x2048, 0x6118, 0x810c, 0x810c, 0x810c, 0x81ff, 0x1118, 0xa887,
-	0x0001, 0x0008, 0xa986, 0x601b, 0x0002, 0xa974, 0xd1dc, 0x1108,
-	0x0005, 0xa934, 0xa88c, 0x9106, 0x1158, 0xa938, 0xa890, 0x9106,
-	0x1138, 0x601c, 0xc084, 0x601e, 0x2009, 0x0048, 0x0804, 0x9c76,
-	0x0005, 0x0126, 0x00c6, 0x2091, 0x2200, 0x00ce, 0x7908, 0x918c,
-	0x0007, 0x9186, 0x0000, 0x05b0, 0x9186, 0x0003, 0x0598, 0x6020,
-	0x6023, 0x0000, 0x0006, 0x2031, 0x0008, 0x00c6, 0x781f, 0x0808,
-	0x7808, 0xd09c, 0x0120, 0x080c, 0x1335, 0x8631, 0x1db8, 0x00ce,
-	0x781f, 0x0800, 0x2031, 0x0168, 0x00c6, 0x7808, 0xd09c, 0x190c,
-	0x1335, 0x00ce, 0x2001, 0x0038, 0x080c, 0x19f9, 0x7930, 0x9186,
-	0x0040, 0x0160, 0x9186, 0x0042, 0x190c, 0x0d65, 0x2001, 0x001e,
-	0x8001, 0x1df0, 0x8631, 0x1d40, 0x080c, 0x1a08, 0x000e, 0x6022,
-	0x012e, 0x0005, 0x080c, 0x19f5, 0x7827, 0x0015, 0x7828, 0x9c06,
-	0x1db8, 0x782b, 0x0000, 0x0ca0, 0x00f6, 0x2079, 0x0300, 0x7803,
-	0x0000, 0x78ab, 0x0004, 0x00fe, 0x080c, 0x7096, 0x11b0, 0x2001,
-	0x0138, 0x2003, 0x0000, 0x2001, 0x0160, 0x2003, 0x0000, 0x2011,
-	0x012c, 0xa001, 0xa001, 0x8211, 0x1de0, 0x0081, 0x2001, 0x0386,
-	0x2003, 0x2020, 0x080c, 0x7137, 0x0005, 0x0479, 0x0039, 0x2001,
+	0x1d1c, 0x2065, 0x9006, 0xa842, 0xa83e, 0xd19c, 0x1904, 0x1740,
+	0x0080, 0xa87c, 0xd0ac, 0x0904, 0x169d, 0x9006, 0xa842, 0xa83e,
+	0x0804, 0x1740, 0xa87c, 0xd0ac, 0x0904, 0x169d, 0x9006, 0xa842,
+	0xa83e, 0x2c05, 0x908a, 0x0036, 0x1a0c, 0x0d65, 0x9082, 0x001b,
+	0x0002, 0x1714, 0x1714, 0x1716, 0x1714, 0x1714, 0x1714, 0x171c,
+	0x1714, 0x1714, 0x1714, 0x1722, 0x1714, 0x1714, 0x1714, 0x1728,
+	0x1714, 0x1714, 0x1714, 0x172e, 0x1714, 0x1714, 0x1714, 0x1734,
+	0x1714, 0x1714, 0x1714, 0x173a, 0x080c, 0x0d65, 0xa574, 0xa478,
+	0xa37c, 0xa280, 0x0804, 0x1785, 0xa584, 0xa488, 0xa38c, 0xa290,
+	0x0804, 0x1785, 0xa594, 0xa498, 0xa39c, 0xa2a0, 0x0804, 0x1785,
+	0xa5a4, 0xa4a8, 0xa3ac, 0xa2b0, 0x0804, 0x1785, 0xa5b4, 0xa4b8,
+	0xa3bc, 0xa2c0, 0x0804, 0x1785, 0xa5c4, 0xa4c8, 0xa3cc, 0xa2d0,
+	0x0804, 0x1785, 0xa5d4, 0xa4d8, 0xa3dc, 0xa2e0, 0x0804, 0x1785,
+	0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0d65, 0x9082, 0x001b, 0x0002,
+	0x1763, 0x1761, 0x1761, 0x1761, 0x1761, 0x1761, 0x176a, 0x1761,
+	0x1761, 0x1761, 0x1761, 0x1761, 0x1771, 0x1761, 0x1761, 0x1761,
+	0x1761, 0x1761, 0x1778, 0x1761, 0x1761, 0x1761, 0x1761, 0x1761,
+	0x177f, 0x080c, 0x0d65, 0xa56c, 0xa470, 0xa774, 0xa678, 0xa37c,
+	0xa280, 0x00d8, 0xa584, 0xa488, 0xa78c, 0xa690, 0xa394, 0xa298,
+	0x00a0, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8, 0xa3ac, 0xa2b0, 0x0068,
+	0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0, 0xa3c4, 0xa2c8, 0x0030, 0xa5cc,
+	0xa4d0, 0xa7d4, 0xa6d8, 0xa3dc, 0xa2e0, 0xab2e, 0xaa32, 0xad1e,
+	0xac22, 0xaf26, 0xae2a, 0xa988, 0x8c60, 0x2c1d, 0xa8ac, 0xaab0,
+	0xa836, 0xaa3a, 0x8109, 0xa916, 0x1158, 0x3e60, 0x601c, 0xc085,
+	0x601e, 0xa87c, 0xc0dd, 0xa87e, 0x9006, 0x00ce, 0x012e, 0x0005,
+	0x2800, 0xa80e, 0xab0a, 0x2c00, 0xa812, 0x0c78, 0x0804, 0x169d,
+	0x0016, 0x2009, 0x00a0, 0x8109, 0xa001, 0xa001, 0xa001, 0x1dd8,
+	0x001e, 0x2ff0, 0x0126, 0x2091, 0x2200, 0x00c6, 0x3e60, 0x6014,
+	0x2048, 0x2940, 0xa80e, 0x2061, 0x1d17, 0xa813, 0x1d17, 0x2c05,
+	0xa80a, 0xa964, 0xa91a, 0xa87c, 0xd0ac, 0x090c, 0x0d65, 0x9006,
+	0xa842, 0xa83e, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0d65, 0xadcc,
+	0xacd0, 0xafd4, 0xaed8, 0xabdc, 0xaae0, 0xab2e, 0xaa32, 0xad1e,
+	0xac22, 0xaf26, 0xae2a, 0xa8ac, 0xaab0, 0xa836, 0xaa3a, 0xa988,
+	0xa864, 0x9084, 0x00ff, 0x9086, 0x0008, 0x1120, 0x8109, 0xa916,
+	0x0128, 0x0078, 0x918a, 0x0002, 0xa916, 0x1158, 0x3e60, 0x601c,
+	0xc085, 0x601e, 0xa87c, 0xc0dd, 0xa87e, 0x9006, 0x00ce, 0x012e,
+	0x0005, 0xa804, 0x9045, 0x090c, 0x0d65, 0xa80e, 0xa064, 0xa81a,
+	0x9084, 0x000f, 0x9080, 0x1d1c, 0x2015, 0x82ff, 0x090c, 0x0d65,
+	0xaa12, 0x2205, 0xa80a, 0x0c10, 0x903e, 0x2730, 0xa880, 0xd0fc,
+	0x1190, 0x2d00, 0x0002, 0x1901, 0x1863, 0x1863, 0x1901, 0x1901,
+	0x18fb, 0x1901, 0x1863, 0x18b2, 0x18b2, 0x18b2, 0x1901, 0x1901,
+	0x1901, 0x18f8, 0x18b2, 0xc0fc, 0xa882, 0xab2c, 0xaa30, 0xad1c,
+	0xac20, 0xdd9c, 0x0904, 0x1903, 0x2c05, 0x908a, 0x0034, 0x1a0c,
+	0x0d65, 0x9082, 0x001b, 0x0002, 0x184f, 0x184d, 0x184d, 0x184d,
+	0x184d, 0x184d, 0x1853, 0x184d, 0x184d, 0x184d, 0x184d, 0x184d,
+	0x1857, 0x184d, 0x184d, 0x184d, 0x184d, 0x184d, 0x185b, 0x184d,
+	0x184d, 0x184d, 0x184d, 0x184d, 0x185f, 0x080c, 0x0d65, 0xa774,
+	0xa678, 0x0804, 0x1903, 0xa78c, 0xa690, 0x0804, 0x1903, 0xa7a4,
+	0xa6a8, 0x0804, 0x1903, 0xa7bc, 0xa6c0, 0x0804, 0x1903, 0xa7d4,
+	0xa6d8, 0x0804, 0x1903, 0x2c05, 0x908a, 0x0036, 0x1a0c, 0x0d65,
+	0x9082, 0x001b, 0x0002, 0x1886, 0x1886, 0x1888, 0x1886, 0x1886,
+	0x1886, 0x188e, 0x1886, 0x1886, 0x1886, 0x1894, 0x1886, 0x1886,
+	0x1886, 0x189a, 0x1886, 0x1886, 0x1886, 0x18a0, 0x1886, 0x1886,
+	0x1886, 0x18a6, 0x1886, 0x1886, 0x1886, 0x18ac, 0x080c, 0x0d65,
+	0xa574, 0xa478, 0xa37c, 0xa280, 0x0804, 0x1903, 0xa584, 0xa488,
+	0xa38c, 0xa290, 0x0804, 0x1903, 0xa594, 0xa498, 0xa39c, 0xa2a0,
+	0x0804, 0x1903, 0xa5a4, 0xa4a8, 0xa3ac, 0xa2b0, 0x0804, 0x1903,
+	0xa5b4, 0xa4b8, 0xa3bc, 0xa2c0, 0x0804, 0x1903, 0xa5c4, 0xa4c8,
+	0xa3cc, 0xa2d0, 0x0804, 0x1903, 0xa5d4, 0xa4d8, 0xa3dc, 0xa2e0,
+	0x0804, 0x1903, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0d65, 0x9082,
+	0x001b, 0x0002, 0x18d5, 0x18d3, 0x18d3, 0x18d3, 0x18d3, 0x18d3,
+	0x18dc, 0x18d3, 0x18d3, 0x18d3, 0x18d3, 0x18d3, 0x18e3, 0x18d3,
+	0x18d3, 0x18d3, 0x18d3, 0x18d3, 0x18ea, 0x18d3, 0x18d3, 0x18d3,
+	0x18d3, 0x18d3, 0x18f1, 0x080c, 0x0d65, 0xa56c, 0xa470, 0xa774,
+	0xa678, 0xa37c, 0xa280, 0x0438, 0xa584, 0xa488, 0xa78c, 0xa690,
+	0xa394, 0xa298, 0x0400, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8, 0xa3ac,
+	0xa2b0, 0x00c8, 0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0, 0xa3c4, 0xa2c8,
+	0x0090, 0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8, 0xa3dc, 0xa2e0, 0x0058,
+	0x9d86, 0x000e, 0x1130, 0x080c, 0x1cf2, 0x1904, 0x180c, 0x900e,
+	0x0050, 0x080c, 0x0d65, 0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26,
+	0xae2a, 0x080c, 0x1cf2, 0x0005, 0x6014, 0x2048, 0x6118, 0x810c,
+	0x810c, 0x810c, 0x81ff, 0x1118, 0xa887, 0x0001, 0x0008, 0xa986,
+	0x601b, 0x0002, 0xa874, 0x9084, 0x00ff, 0x9084, 0x0008, 0x0150,
+	0x00e9, 0x6000, 0x9086, 0x0004, 0x1120, 0x2009, 0x0048, 0x080c,
+	0x9c82, 0x0005, 0xa974, 0xd1dc, 0x1108, 0x0005, 0xa934, 0xa88c,
+	0x9106, 0x1158, 0xa938, 0xa890, 0x9106, 0x1138, 0x601c, 0xc084,
+	0x601e, 0x2009, 0x0048, 0x0804, 0x9c82, 0x0005, 0x0126, 0x00c6,
+	0x2091, 0x2200, 0x00ce, 0x7908, 0x918c, 0x0007, 0x9186, 0x0000,
+	0x05b0, 0x9186, 0x0003, 0x0598, 0x6020, 0x6023, 0x0000, 0x0006,
+	0x2031, 0x0008, 0x00c6, 0x781f, 0x0808, 0x7808, 0xd09c, 0x0120,
+	0x080c, 0x1342, 0x8631, 0x1db8, 0x00ce, 0x781f, 0x0800, 0x2031,
+	0x0168, 0x00c6, 0x7808, 0xd09c, 0x190c, 0x1342, 0x00ce, 0x2001,
+	0x0038, 0x080c, 0x1a11, 0x7930, 0x9186, 0x0040, 0x0160, 0x9186,
+	0x0042, 0x190c, 0x0d65, 0x2001, 0x001e, 0x8001, 0x1df0, 0x8631,
+	0x1d40, 0x080c, 0x1a20, 0x000e, 0x6022, 0x012e, 0x0005, 0x080c,
+	0x1a0d, 0x7827, 0x0015, 0x7828, 0x9c06, 0x1db8, 0x782b, 0x0000,
+	0x0ca0, 0x00f6, 0x2079, 0x0300, 0x7803, 0x0000, 0x78ab, 0x0004,
+	0x00fe, 0x080c, 0x70ba, 0x1188, 0x2001, 0x0138, 0x2003, 0x0000,
+	0x2001, 0x0160, 0x2003, 0x0000, 0x2011, 0x012c, 0xa001, 0xa001,
+	0x8211, 0x1de0, 0x0059, 0x0804, 0x715f, 0x0479, 0x0039, 0x2001,
 	0x0160, 0x2502, 0x2001, 0x0138, 0x2202, 0x0005, 0x00e6, 0x2071,
-	0x0200, 0x080c, 0x2844, 0x2009, 0x003c, 0x080c, 0x2063, 0x2001,
+	0x0200, 0x080c, 0x2864, 0x2009, 0x003c, 0x080c, 0x207b, 0x2001,
 	0x015d, 0x2003, 0x0000, 0x7000, 0x9084, 0x003c, 0x1de0, 0x080c,
-	0x8053, 0x70a0, 0x70a2, 0x7098, 0x709a, 0x709c, 0x709e, 0x2001,
-	0x020d, 0x2003, 0x0020, 0x00f6, 0x2079, 0x0300, 0x080c, 0x12f5,
+	0x8087, 0x70a0, 0x70a2, 0x7098, 0x709a, 0x709c, 0x709e, 0x2001,
+	0x020d, 0x2003, 0x0020, 0x00f6, 0x2079, 0x0300, 0x080c, 0x1302,
 	0x7803, 0x0001, 0x00fe, 0x00ee, 0x0005, 0x2001, 0x0138, 0x2014,
 	0x2003, 0x0000, 0x2001, 0x0160, 0x202c, 0x2003, 0x0000, 0x080c,
-	0x7096, 0x1108, 0x0005, 0x2021, 0x0260, 0x2001, 0x0141, 0x201c,
+	0x70ba, 0x1108, 0x0005, 0x2021, 0x0260, 0x2001, 0x0141, 0x201c,
 	0xd3dc, 0x1168, 0x2001, 0x0109, 0x201c, 0x939c, 0x0048, 0x1160,
 	0x2001, 0x0111, 0x201c, 0x83ff, 0x1110, 0x8421, 0x1d70, 0x2001,
 	0x015d, 0x2003, 0x0000, 0x0005, 0x0046, 0x2021, 0x0019, 0x2003,
 	0x0048, 0xa001, 0xa001, 0x201c, 0x939c, 0x0048, 0x0120, 0x8421,
 	0x1db0, 0x004e, 0x0c60, 0x004e, 0x0c40, 0x601c, 0xc084, 0x601e,
-	0x0005, 0x2c08, 0x621c, 0x080c, 0x15ab, 0x7930, 0x0005, 0x2c08,
-	0x621c, 0x080c, 0x15d8, 0x7930, 0x0005, 0x8001, 0x1df0, 0x0005,
+	0x0005, 0x2c08, 0x621c, 0x080c, 0x15b8, 0x7930, 0x0005, 0x2c08,
+	0x621c, 0x080c, 0x15e5, 0x7930, 0x0005, 0x8001, 0x1df0, 0x0005,
 	0x2031, 0x0005, 0x781c, 0x9084, 0x0007, 0x0170, 0x2001, 0x0038,
-	0x0c41, 0x9186, 0x0040, 0x0904, 0x1a66, 0x2001, 0x001e, 0x0c69,
+	0x0c41, 0x9186, 0x0040, 0x0904, 0x1a7e, 0x2001, 0x001e, 0x0c69,
 	0x8631, 0x1d80, 0x080c, 0x0d65, 0x781f, 0x0202, 0x2001, 0x015d,
 	0x2003, 0x0000, 0x2001, 0x0b10, 0x0c01, 0x781c, 0xd084, 0x0110,
 	0x0861, 0x04e0, 0x2001, 0x0030, 0x0891, 0x9186, 0x0040, 0x0568,
 	0x781c, 0xd084, 0x1da8, 0x781f, 0x0101, 0x2001, 0x0014, 0x0869,
 	0x2001, 0x0037, 0x0821, 0x9186, 0x0040, 0x0140, 0x2001, 0x0030,
-	0x080c, 0x19ff, 0x9186, 0x0040, 0x190c, 0x0d65, 0x00d6, 0x2069,
+	0x080c, 0x1a17, 0x9186, 0x0040, 0x190c, 0x0d65, 0x00d6, 0x2069,
 	0x0200, 0x692c, 0xd1f4, 0x1170, 0xd1c4, 0x0160, 0xd19c, 0x0130,
 	0x6800, 0x9085, 0x1800, 0x6802, 0x00de, 0x0080, 0x6908, 0x9184,
 	0x0007, 0x1db0, 0x00de, 0x781f, 0x0100, 0x791c, 0x9184, 0x0007,
 	0x090c, 0x0d65, 0xa001, 0xa001, 0x781f, 0x0200, 0x0005, 0x0126,
-	0x2091, 0x2400, 0x2079, 0x0380, 0x2001, 0x19b7, 0x2070, 0x012e,
+	0x2091, 0x2400, 0x2079, 0x0380, 0x2001, 0x19bf, 0x2070, 0x012e,
 	0x0005, 0x2cf0, 0x0126, 0x2091, 0x2400, 0x3e60, 0x6014, 0x2048,
-	0xa964, 0xa91a, 0x918c, 0x00ff, 0x9184, 0x000f, 0x0002, 0x1a9b,
-	0x1a9b, 0x1a9b, 0x1a9b, 0x1a9b, 0x1a9b, 0x1a9b, 0x1a9b, 0x1a8f,
-	0x1a9d, 0x1a9b, 0x1a9b, 0x1a9b, 0x1a9b, 0x1a9b, 0x1a9b, 0x9086,
-	0x0008, 0x1148, 0xa87c, 0xd0b4, 0x0904, 0x1c0d, 0x2011, 0x1cff,
+	0xa964, 0xa91a, 0x918c, 0x00ff, 0x9184, 0x000f, 0x0002, 0x1ab3,
+	0x1ab3, 0x1ab3, 0x1ab3, 0x1ab3, 0x1ab3, 0x1ab3, 0x1ab3, 0x1aa7,
+	0x1ab5, 0x1ab3, 0x1ab3, 0x1ab3, 0x1ab3, 0x1ab3, 0x1ab3, 0x9086,
+	0x0008, 0x1148, 0xa87c, 0xd0b4, 0x0904, 0x1c25, 0x2011, 0x1d17,
 	0x2205, 0xab88, 0x0068, 0x080c, 0x0d65, 0xa87c, 0xd0b4, 0x0904,
-	0x1c0d, 0x9184, 0x000f, 0x9080, 0x1d04, 0x2015, 0x2205, 0xab88,
+	0x1c25, 0x9184, 0x000f, 0x9080, 0x1d1c, 0x2015, 0x2205, 0xab88,
 	0x2908, 0xa80a, 0xa90e, 0xaa12, 0xab16, 0x9006, 0xa842, 0xa83e,
 	0x012e, 0x0005, 0x2cf0, 0x0126, 0x2091, 0x2400, 0x3e60, 0x6014,
 	0x2048, 0xa88c, 0xa990, 0xaaac, 0xabb0, 0xaa36, 0xab3a, 0xa83e,
 	0xa942, 0xa846, 0xa94a, 0xa964, 0x918c, 0x00ff, 0x9186, 0x001e,
-	0x0198, 0x2940, 0xa064, 0xa81a, 0x90ec, 0x000f, 0x9d80, 0x1d04,
+	0x0198, 0x2940, 0xa064, 0xa81a, 0x90ec, 0x000f, 0x9d80, 0x1d1c,
 	0x2065, 0x2c05, 0x2808, 0x2c10, 0xab88, 0xa80a, 0xa90e, 0xaa12,
 	0xab16, 0x012e, 0x3e60, 0x0005, 0xa804, 0x2040, 0x0c58, 0x2cf0,
 	0x0126, 0x2091, 0x2400, 0x3e60, 0x6014, 0x2048, 0xa97c, 0x2950,
-	0xd1dc, 0x1904, 0x1bd7, 0xc1dd, 0xa97e, 0x9006, 0xa842, 0xa83e,
+	0xd1dc, 0x1904, 0x1bef, 0xc1dd, 0xa97e, 0x9006, 0xa842, 0xa83e,
 	0xa988, 0x8109, 0xa916, 0xa964, 0xa91a, 0x9184, 0x000f, 0x9088,
-	0x1d04, 0x2145, 0x0002, 0x1b0b, 0x1b19, 0x1b0b, 0x1b0b, 0x1b0b,
-	0x1b0d, 0x1b0b, 0x1b0b, 0x1b6e, 0x1b6e, 0x1b0b, 0x1b0b, 0x1b0b,
-	0x1b6c, 0x1b0b, 0x1b0b, 0x080c, 0x0d65, 0xa804, 0x2050, 0xb164,
-	0xa91a, 0x9184, 0x000f, 0x9080, 0x1d04, 0x2045, 0xd19c, 0x1904,
-	0x1b6e, 0x9036, 0x2638, 0x2805, 0x908a, 0x0036, 0x1a0c, 0x0d65,
-	0x9082, 0x001b, 0x0002, 0x1b3e, 0x1b3e, 0x1b40, 0x1b3e, 0x1b3e,
-	0x1b3e, 0x1b46, 0x1b3e, 0x1b3e, 0x1b3e, 0x1b4c, 0x1b3e, 0x1b3e,
-	0x1b3e, 0x1b52, 0x1b3e, 0x1b3e, 0x1b3e, 0x1b58, 0x1b3e, 0x1b3e,
-	0x1b3e, 0x1b5e, 0x1b3e, 0x1b3e, 0x1b3e, 0x1b64, 0x080c, 0x0d65,
-	0xb574, 0xb478, 0xb37c, 0xb280, 0x0804, 0x1bb3, 0xb584, 0xb488,
-	0xb38c, 0xb290, 0x0804, 0x1bb3, 0xb594, 0xb498, 0xb39c, 0xb2a0,
-	0x0804, 0x1bb3, 0xb5a4, 0xb4a8, 0xb3ac, 0xb2b0, 0x0804, 0x1bb3,
-	0xb5b4, 0xb4b8, 0xb3bc, 0xb2c0, 0x0804, 0x1bb3, 0xb5c4, 0xb4c8,
-	0xb3cc, 0xb2d0, 0x0804, 0x1bb3, 0xb5d4, 0xb4d8, 0xb3dc, 0xb2e0,
-	0x0804, 0x1bb3, 0x0804, 0x1bb3, 0x080c, 0x0d65, 0x2805, 0x908a,
-	0x0034, 0x1a0c, 0x0d65, 0x9082, 0x001b, 0x0002, 0x1b91, 0x1b8f,
-	0x1b8f, 0x1b8f, 0x1b8f, 0x1b8f, 0x1b98, 0x1b8f, 0x1b8f, 0x1b8f,
-	0x1b8f, 0x1b8f, 0x1b9f, 0x1b8f, 0x1b8f, 0x1b8f, 0x1b8f, 0x1b8f,
-	0x1ba6, 0x1b8f, 0x1b8f, 0x1b8f, 0x1b8f, 0x1b8f, 0x1bad, 0x080c,
+	0x1d1c, 0x2145, 0x0002, 0x1b23, 0x1b31, 0x1b23, 0x1b23, 0x1b23,
+	0x1b25, 0x1b23, 0x1b23, 0x1b86, 0x1b86, 0x1b23, 0x1b23, 0x1b23,
+	0x1b84, 0x1b23, 0x1b23, 0x080c, 0x0d65, 0xa804, 0x2050, 0xb164,
+	0xa91a, 0x9184, 0x000f, 0x9080, 0x1d1c, 0x2045, 0xd19c, 0x1904,
+	0x1b86, 0x9036, 0x2638, 0x2805, 0x908a, 0x0036, 0x1a0c, 0x0d65,
+	0x9082, 0x001b, 0x0002, 0x1b56, 0x1b56, 0x1b58, 0x1b56, 0x1b56,
+	0x1b56, 0x1b5e, 0x1b56, 0x1b56, 0x1b56, 0x1b64, 0x1b56, 0x1b56,
+	0x1b56, 0x1b6a, 0x1b56, 0x1b56, 0x1b56, 0x1b70, 0x1b56, 0x1b56,
+	0x1b56, 0x1b76, 0x1b56, 0x1b56, 0x1b56, 0x1b7c, 0x080c, 0x0d65,
+	0xb574, 0xb478, 0xb37c, 0xb280, 0x0804, 0x1bcb, 0xb584, 0xb488,
+	0xb38c, 0xb290, 0x0804, 0x1bcb, 0xb594, 0xb498, 0xb39c, 0xb2a0,
+	0x0804, 0x1bcb, 0xb5a4, 0xb4a8, 0xb3ac, 0xb2b0, 0x0804, 0x1bcb,
+	0xb5b4, 0xb4b8, 0xb3bc, 0xb2c0, 0x0804, 0x1bcb, 0xb5c4, 0xb4c8,
+	0xb3cc, 0xb2d0, 0x0804, 0x1bcb, 0xb5d4, 0xb4d8, 0xb3dc, 0xb2e0,
+	0x0804, 0x1bcb, 0x0804, 0x1bcb, 0x080c, 0x0d65, 0x2805, 0x908a,
+	0x0034, 0x1a0c, 0x0d65, 0x9082, 0x001b, 0x0002, 0x1ba9, 0x1ba7,
+	0x1ba7, 0x1ba7, 0x1ba7, 0x1ba7, 0x1bb0, 0x1ba7, 0x1ba7, 0x1ba7,
+	0x1ba7, 0x1ba7, 0x1bb7, 0x1ba7, 0x1ba7, 0x1ba7, 0x1ba7, 0x1ba7,
+	0x1bbe, 0x1ba7, 0x1ba7, 0x1ba7, 0x1ba7, 0x1ba7, 0x1bc5, 0x080c,
 	0x0d65, 0xb56c, 0xb470, 0xb774, 0xb678, 0xb37c, 0xb280, 0x00d8,
 	0xb584, 0xb488, 0xb78c, 0xb690, 0xb394, 0xb298, 0x00a0, 0xb59c,
 	0xb4a0, 0xb7a4, 0xb6a8, 0xb3ac, 0xb2b0, 0x0068, 0xb5b4, 0xb4b8,
@@ -683,100 +686,100 @@
 	0xb6d8, 0xb3dc, 0xb2e0, 0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26,
 	0xae2a, 0xa988, 0x8109, 0xa916, 0x1118, 0x9006, 0x012e, 0x0005,
 	0x8840, 0x2805, 0x9005, 0x1168, 0xb004, 0x9005, 0x090c, 0x0d65,
-	0x2050, 0xb164, 0xa91a, 0x9184, 0x000f, 0x9080, 0x1d04, 0x2045,
+	0x2050, 0xb164, 0xa91a, 0x9184, 0x000f, 0x9080, 0x1d1c, 0x2045,
 	0x2805, 0x2810, 0x2a08, 0xa80a, 0xa90e, 0xaa12, 0x0c30, 0x3e60,
 	0x6344, 0xd3fc, 0x190c, 0x0d65, 0xa93c, 0xaa40, 0xa844, 0x9106,
 	0x1118, 0xa848, 0x9206, 0x0508, 0x2958, 0xab48, 0xac44, 0x2940,
-	0x080c, 0x1d24, 0x1998, 0x2850, 0x2c40, 0xab14, 0xa880, 0xd0fc,
+	0x080c, 0x1d3c, 0x1998, 0x2850, 0x2c40, 0xab14, 0xa880, 0xd0fc,
 	0x1140, 0xa810, 0x2005, 0xa80a, 0x2a00, 0xa80e, 0x2009, 0x8015,
 	0x0070, 0x00c6, 0x3e60, 0x6044, 0xc0a4, 0x9085, 0x8005, 0x6046,
-	0x00ce, 0x8319, 0xab16, 0x1904, 0x1bc0, 0x2009, 0x8005, 0x3e60,
-	0x6044, 0x9105, 0x6046, 0x0804, 0x1bbd, 0x080c, 0x0d65, 0x00f6,
+	0x00ce, 0x8319, 0xab16, 0x1904, 0x1bd8, 0x2009, 0x8005, 0x3e60,
+	0x6044, 0x9105, 0x6046, 0x0804, 0x1bd5, 0x080c, 0x0d65, 0x00f6,
 	0x00e6, 0x0096, 0x00c6, 0x0026, 0x704c, 0x9c06, 0x190c, 0x0d65,
 	0x2079, 0x0090, 0x2001, 0x0105, 0x2003, 0x0010, 0x782b, 0x0004,
-	0x7057, 0x0000, 0x6014, 0x2048, 0x080c, 0xb842, 0x0118, 0xa880,
+	0x7057, 0x0000, 0x6014, 0x2048, 0x080c, 0xb870, 0x0118, 0xa880,
 	0xc0bd, 0xa882, 0x6020, 0x9086, 0x0006, 0x1170, 0x2061, 0x0100,
 	0x62c8, 0x2001, 0x00fa, 0x8001, 0x1df0, 0x60c8, 0x9206, 0x1dc0,
 	0x60c4, 0xa89a, 0x60c8, 0xa896, 0x704c, 0x2060, 0x00c6, 0x080c,
-	0xb440, 0x080c, 0x98bb, 0x00ce, 0x704c, 0x9c06, 0x1150, 0x2009,
-	0x0040, 0x080c, 0x2063, 0x080c, 0x949c, 0x2011, 0x0000, 0x080c,
-	0x9326, 0x002e, 0x00ce, 0x009e, 0x00ee, 0x00fe, 0x0005, 0x00f6,
+	0xb45e, 0x080c, 0x98c7, 0x00ce, 0x704c, 0x9c06, 0x1150, 0x2009,
+	0x0040, 0x080c, 0x207b, 0x080c, 0x94a4, 0x2011, 0x0000, 0x080c,
+	0x932e, 0x002e, 0x00ce, 0x009e, 0x00ee, 0x00fe, 0x0005, 0x00f6,
 	0x2079, 0x0090, 0x781c, 0x0006, 0x7818, 0x0006, 0x2079, 0x0100,
 	0x7a14, 0x9284, 0x1984, 0x9085, 0x0012, 0x7816, 0x2019, 0x1000,
 	0x8319, 0x090c, 0x0d65, 0x7820, 0xd0bc, 0x1dd0, 0x79c8, 0x000e,
 	0x9102, 0x001e, 0x0006, 0x0016, 0x79c4, 0x000e, 0x9103, 0x78c6,
 	0x000e, 0x78ca, 0x9284, 0x1984, 0x9085, 0x0012, 0x7816, 0x2079,
 	0x0090, 0x782b, 0x0008, 0x7057, 0x0000, 0x00fe, 0x0005, 0x00f6,
-	0x00e6, 0x2071, 0x19b7, 0x7054, 0x9086, 0x0000, 0x0904, 0x1cd5,
+	0x00e6, 0x2071, 0x19bf, 0x7054, 0x9086, 0x0000, 0x0904, 0x1ced,
 	0x2079, 0x0090, 0x2009, 0x0207, 0x210c, 0xd194, 0x01b8, 0x2009,
-	0x020c, 0x210c, 0x9184, 0x0003, 0x0188, 0x080c, 0xd62d, 0x2001,
+	0x020c, 0x210c, 0x9184, 0x0003, 0x0188, 0x080c, 0xd665, 0x2001,
 	0x0133, 0x2004, 0x9005, 0x090c, 0x0d65, 0x0016, 0x2009, 0x0040,
-	0x080c, 0x2063, 0x001e, 0x2001, 0x020c, 0x2102, 0x2009, 0x0206,
+	0x080c, 0x207b, 0x001e, 0x2001, 0x020c, 0x2102, 0x2009, 0x0206,
 	0x2104, 0x2009, 0x0203, 0x210c, 0x9106, 0x1120, 0x2009, 0x0040,
-	0x080c, 0x2063, 0x782c, 0xd0fc, 0x09a8, 0x080c, 0x98d7, 0x782c,
-	0xd0fc, 0x1de8, 0x080c, 0x98bb, 0x7054, 0x9086, 0x0000, 0x1950,
+	0x080c, 0x207b, 0x782c, 0xd0fc, 0x09a8, 0x080c, 0x98e3, 0x782c,
+	0xd0fc, 0x1de8, 0x080c, 0x98c7, 0x7054, 0x9086, 0x0000, 0x1950,
 	0x782b, 0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c,
-	0x2063, 0x782b, 0x0002, 0x7057, 0x0000, 0x00ee, 0x00fe, 0x0005,
+	0x207b, 0x782b, 0x0002, 0x7057, 0x0000, 0x00ee, 0x00fe, 0x0005,
 	0x080c, 0x0d65, 0x8c60, 0x2c05, 0x9005, 0x0110, 0x8a51, 0x0005,
 	0xa004, 0x9005, 0x0168, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f,
-	0x9080, 0x1d04, 0x2065, 0x8cff, 0x090c, 0x0d65, 0x8a51, 0x0005,
+	0x9080, 0x1d1c, 0x2065, 0x8cff, 0x090c, 0x0d65, 0x8a51, 0x0005,
 	0x2050, 0x0005, 0x0000, 0x001d, 0x0021, 0x0025, 0x0029, 0x002d,
 	0x0031, 0x0035, 0x0000, 0x001b, 0x0021, 0x0027, 0x002d, 0x0033,
-	0x0000, 0x0000, 0x0023, 0x0000, 0x0000, 0x1cf7, 0x1cf3, 0x0000,
-	0x0000, 0x1d01, 0x0000, 0x1cf7, 0x1cfe, 0x1cfe, 0x1cfb, 0x0000,
-	0x0000, 0x0000, 0x1d01, 0x1cfe, 0x0000, 0x1cf9, 0x1cf9, 0x0000,
-	0x0000, 0x1d01, 0x0000, 0x1cf9, 0x1cff, 0x1cff, 0x1cff, 0x0000,
-	0x0000, 0x0000, 0x1d01, 0x1cff, 0x00c6, 0x00d6, 0x0086, 0xab42,
-	0xac3e, 0xa888, 0x9055, 0x0904, 0x1f03, 0x2940, 0xa064, 0x90ec,
-	0x000f, 0x9084, 0x00ff, 0x9086, 0x0008, 0x1118, 0x2061, 0x1cff,
-	0x00d0, 0x9de0, 0x1d04, 0x9d86, 0x0007, 0x0130, 0x9d86, 0x000e,
+	0x0000, 0x0000, 0x0023, 0x0000, 0x0000, 0x1d0f, 0x1d0b, 0x0000,
+	0x0000, 0x1d19, 0x0000, 0x1d0f, 0x1d16, 0x1d16, 0x1d13, 0x0000,
+	0x0000, 0x0000, 0x1d19, 0x1d16, 0x0000, 0x1d11, 0x1d11, 0x0000,
+	0x0000, 0x1d19, 0x0000, 0x1d11, 0x1d17, 0x1d17, 0x1d17, 0x0000,
+	0x0000, 0x0000, 0x1d19, 0x1d17, 0x00c6, 0x00d6, 0x0086, 0xab42,
+	0xac3e, 0xa888, 0x9055, 0x0904, 0x1f1b, 0x2940, 0xa064, 0x90ec,
+	0x000f, 0x9084, 0x00ff, 0x9086, 0x0008, 0x1118, 0x2061, 0x1d17,
+	0x00d0, 0x9de0, 0x1d1c, 0x9d86, 0x0007, 0x0130, 0x9d86, 0x000e,
 	0x0118, 0x9d86, 0x000f, 0x1120, 0xa08c, 0x9422, 0xa090, 0x931b,
-	0x2c05, 0x9065, 0x1140, 0x0310, 0x0804, 0x1f03, 0xa004, 0x9045,
-	0x0904, 0x1f03, 0x08d8, 0x2c05, 0x9005, 0x0904, 0x1deb, 0xdd9c,
-	0x1904, 0x1da7, 0x908a, 0x0036, 0x1a0c, 0x0d65, 0x9082, 0x001b,
-	0x0002, 0x1d7c, 0x1d7c, 0x1d7e, 0x1d7c, 0x1d7c, 0x1d7c, 0x1d84,
-	0x1d7c, 0x1d7c, 0x1d7c, 0x1d8a, 0x1d7c, 0x1d7c, 0x1d7c, 0x1d90,
-	0x1d7c, 0x1d7c, 0x1d7c, 0x1d96, 0x1d7c, 0x1d7c, 0x1d7c, 0x1d9c,
-	0x1d7c, 0x1d7c, 0x1d7c, 0x1da2, 0x080c, 0x0d65, 0xa07c, 0x9422,
-	0xa080, 0x931b, 0x0804, 0x1de1, 0xa08c, 0x9422, 0xa090, 0x931b,
-	0x0804, 0x1de1, 0xa09c, 0x9422, 0xa0a0, 0x931b, 0x0804, 0x1de1,
-	0xa0ac, 0x9422, 0xa0b0, 0x931b, 0x0804, 0x1de1, 0xa0bc, 0x9422,
-	0xa0c0, 0x931b, 0x0804, 0x1de1, 0xa0cc, 0x9422, 0xa0d0, 0x931b,
-	0x0804, 0x1de1, 0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x04d0, 0x908a,
-	0x0034, 0x1a0c, 0x0d65, 0x9082, 0x001b, 0x0002, 0x1dc9, 0x1dc7,
-	0x1dc7, 0x1dc7, 0x1dc7, 0x1dc7, 0x1dce, 0x1dc7, 0x1dc7, 0x1dc7,
-	0x1dc7, 0x1dc7, 0x1dd3, 0x1dc7, 0x1dc7, 0x1dc7, 0x1dc7, 0x1dc7,
-	0x1dd8, 0x1dc7, 0x1dc7, 0x1dc7, 0x1dc7, 0x1dc7, 0x1ddd, 0x080c,
+	0x2c05, 0x9065, 0x1140, 0x0310, 0x0804, 0x1f1b, 0xa004, 0x9045,
+	0x0904, 0x1f1b, 0x08d8, 0x2c05, 0x9005, 0x0904, 0x1e03, 0xdd9c,
+	0x1904, 0x1dbf, 0x908a, 0x0036, 0x1a0c, 0x0d65, 0x9082, 0x001b,
+	0x0002, 0x1d94, 0x1d94, 0x1d96, 0x1d94, 0x1d94, 0x1d94, 0x1d9c,
+	0x1d94, 0x1d94, 0x1d94, 0x1da2, 0x1d94, 0x1d94, 0x1d94, 0x1da8,
+	0x1d94, 0x1d94, 0x1d94, 0x1dae, 0x1d94, 0x1d94, 0x1d94, 0x1db4,
+	0x1d94, 0x1d94, 0x1d94, 0x1dba, 0x080c, 0x0d65, 0xa07c, 0x9422,
+	0xa080, 0x931b, 0x0804, 0x1df9, 0xa08c, 0x9422, 0xa090, 0x931b,
+	0x0804, 0x1df9, 0xa09c, 0x9422, 0xa0a0, 0x931b, 0x0804, 0x1df9,
+	0xa0ac, 0x9422, 0xa0b0, 0x931b, 0x0804, 0x1df9, 0xa0bc, 0x9422,
+	0xa0c0, 0x931b, 0x0804, 0x1df9, 0xa0cc, 0x9422, 0xa0d0, 0x931b,
+	0x0804, 0x1df9, 0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x04d0, 0x908a,
+	0x0034, 0x1a0c, 0x0d65, 0x9082, 0x001b, 0x0002, 0x1de1, 0x1ddf,
+	0x1ddf, 0x1ddf, 0x1ddf, 0x1ddf, 0x1de6, 0x1ddf, 0x1ddf, 0x1ddf,
+	0x1ddf, 0x1ddf, 0x1deb, 0x1ddf, 0x1ddf, 0x1ddf, 0x1ddf, 0x1ddf,
+	0x1df0, 0x1ddf, 0x1ddf, 0x1ddf, 0x1ddf, 0x1ddf, 0x1df5, 0x080c,
 	0x0d65, 0xa07c, 0x9422, 0xa080, 0x931b, 0x0098, 0xa094, 0x9422,
 	0xa098, 0x931b, 0x0070, 0xa0ac, 0x9422, 0xa0b0, 0x931b, 0x0048,
 	0xa0c4, 0x9422, 0xa0c8, 0x931b, 0x0020, 0xa0dc, 0x9422, 0xa0e0,
-	0x931b, 0x0630, 0x2300, 0x9405, 0x0160, 0x8a51, 0x0904, 0x1f03,
-	0x8c60, 0x0804, 0x1d53, 0xa004, 0x9045, 0x0904, 0x1f03, 0x0804,
-	0x1d2e, 0x8a51, 0x0904, 0x1f03, 0x8c60, 0x2c05, 0x9005, 0x1158,
-	0xa004, 0x9045, 0x0904, 0x1f03, 0xa064, 0x90ec, 0x000f, 0x9de0,
-	0x1d04, 0x2c05, 0x2060, 0xa880, 0xc0fc, 0xa882, 0x0804, 0x1ef8,
+	0x931b, 0x0630, 0x2300, 0x9405, 0x0160, 0x8a51, 0x0904, 0x1f1b,
+	0x8c60, 0x0804, 0x1d6b, 0xa004, 0x9045, 0x0904, 0x1f1b, 0x0804,
+	0x1d46, 0x8a51, 0x0904, 0x1f1b, 0x8c60, 0x2c05, 0x9005, 0x1158,
+	0xa004, 0x9045, 0x0904, 0x1f1b, 0xa064, 0x90ec, 0x000f, 0x9de0,
+	0x1d1c, 0x2c05, 0x2060, 0xa880, 0xc0fc, 0xa882, 0x0804, 0x1f10,
 	0x2c05, 0x8422, 0x8420, 0x831a, 0x9399, 0x0000, 0xac2e, 0xab32,
-	0xdd9c, 0x1904, 0x1e95, 0x9082, 0x001b, 0x0002, 0x1e31, 0x1e31,
-	0x1e33, 0x1e31, 0x1e31, 0x1e31, 0x1e41, 0x1e31, 0x1e31, 0x1e31,
-	0x1e4f, 0x1e31, 0x1e31, 0x1e31, 0x1e5d, 0x1e31, 0x1e31, 0x1e31,
-	0x1e6b, 0x1e31, 0x1e31, 0x1e31, 0x1e79, 0x1e31, 0x1e31, 0x1e31,
-	0x1e87, 0x080c, 0x0d65, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300,
+	0xdd9c, 0x1904, 0x1ead, 0x9082, 0x001b, 0x0002, 0x1e49, 0x1e49,
+	0x1e4b, 0x1e49, 0x1e49, 0x1e49, 0x1e59, 0x1e49, 0x1e49, 0x1e49,
+	0x1e67, 0x1e49, 0x1e49, 0x1e49, 0x1e75, 0x1e49, 0x1e49, 0x1e49,
+	0x1e83, 0x1e49, 0x1e49, 0x1e49, 0x1e91, 0x1e49, 0x1e49, 0x1e49,
+	0x1e9f, 0x080c, 0x0d65, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300,
 	0x911b, 0x0a0c, 0x0d65, 0xa074, 0x9420, 0xa078, 0x9319, 0x0804,
-	0x1ef3, 0xa18c, 0x2400, 0x9122, 0xa190, 0x2300, 0x911b, 0x0a0c,
-	0x0d65, 0xa084, 0x9420, 0xa088, 0x9319, 0x0804, 0x1ef3, 0xa19c,
+	0x1f0b, 0xa18c, 0x2400, 0x9122, 0xa190, 0x2300, 0x911b, 0x0a0c,
+	0x0d65, 0xa084, 0x9420, 0xa088, 0x9319, 0x0804, 0x1f0b, 0xa19c,
 	0x2400, 0x9122, 0xa1a0, 0x2300, 0x911b, 0x0a0c, 0x0d65, 0xa094,
-	0x9420, 0xa098, 0x9319, 0x0804, 0x1ef3, 0xa1ac, 0x2400, 0x9122,
+	0x9420, 0xa098, 0x9319, 0x0804, 0x1f0b, 0xa1ac, 0x2400, 0x9122,
 	0xa1b0, 0x2300, 0x911b, 0x0a0c, 0x0d65, 0xa0a4, 0x9420, 0xa0a8,
-	0x9319, 0x0804, 0x1ef3, 0xa1bc, 0x2400, 0x9122, 0xa1c0, 0x2300,
+	0x9319, 0x0804, 0x1f0b, 0xa1bc, 0x2400, 0x9122, 0xa1c0, 0x2300,
 	0x911b, 0x0a0c, 0x0d65, 0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0804,
-	0x1ef3, 0xa1cc, 0x2400, 0x9122, 0xa1d0, 0x2300, 0x911b, 0x0a0c,
-	0x0d65, 0xa0c4, 0x9420, 0xa0c8, 0x9319, 0x0804, 0x1ef3, 0xa1dc,
+	0x1f0b, 0xa1cc, 0x2400, 0x9122, 0xa1d0, 0x2300, 0x911b, 0x0a0c,
+	0x0d65, 0xa0c4, 0x9420, 0xa0c8, 0x9319, 0x0804, 0x1f0b, 0xa1dc,
 	0x2400, 0x9122, 0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0d65, 0xa0d4,
-	0x9420, 0xa0d8, 0x9319, 0x0804, 0x1ef3, 0x9082, 0x001b, 0x0002,
-	0x1eb3, 0x1eb1, 0x1eb1, 0x1eb1, 0x1eb1, 0x1eb1, 0x1ec0, 0x1eb1,
-	0x1eb1, 0x1eb1, 0x1eb1, 0x1eb1, 0x1ecd, 0x1eb1, 0x1eb1, 0x1eb1,
-	0x1eb1, 0x1eb1, 0x1eda, 0x1eb1, 0x1eb1, 0x1eb1, 0x1eb1, 0x1eb1,
-	0x1ee7, 0x080c, 0x0d65, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300,
+	0x9420, 0xa0d8, 0x9319, 0x0804, 0x1f0b, 0x9082, 0x001b, 0x0002,
+	0x1ecb, 0x1ec9, 0x1ec9, 0x1ec9, 0x1ec9, 0x1ec9, 0x1ed8, 0x1ec9,
+	0x1ec9, 0x1ec9, 0x1ec9, 0x1ec9, 0x1ee5, 0x1ec9, 0x1ec9, 0x1ec9,
+	0x1ec9, 0x1ec9, 0x1ef2, 0x1ec9, 0x1ec9, 0x1ec9, 0x1ec9, 0x1ec9,
+	0x1eff, 0x080c, 0x0d65, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300,
 	0x911b, 0x0a0c, 0x0d65, 0xa06c, 0x9420, 0xa070, 0x9319, 0x0498,
 	0xa194, 0x2400, 0x9122, 0xa198, 0x2300, 0x911b, 0x0a0c, 0x0d65,
 	0xa084, 0x9420, 0xa088, 0x9319, 0x0430, 0xa1ac, 0x2400, 0x9122,
@@ -792,28 +795,28 @@
 	0x1da8, 0x9284, 0x000f, 0x9405, 0x001e, 0x00ce, 0x0005, 0x7803,
 	0x0003, 0x780f, 0x0000, 0x6004, 0x7812, 0x2c04, 0x7816, 0x9ce0,
 	0x0002, 0x918a, 0x0002, 0x1db8, 0x0005, 0x2001, 0x0005, 0x2004,
-	0xd0bc, 0x190c, 0x0d5e, 0xd094, 0x0110, 0x080c, 0x11d1, 0x0005,
+	0xd0bc, 0x190c, 0x0d5e, 0xd094, 0x0110, 0x080c, 0x11de, 0x0005,
 	0x0126, 0x2091, 0x2600, 0x2079, 0x0200, 0x2071, 0x0260, 0x2069,
 	0x1800, 0x7817, 0x0000, 0x789b, 0x0814, 0x78a3, 0x0406, 0x789f,
 	0x0410, 0x2009, 0x013b, 0x200b, 0x0400, 0x781b, 0x0002, 0x783b,
 	0x001f, 0x7837, 0x0020, 0x7803, 0x1600, 0x012e, 0x0005, 0x2091,
-	0x2600, 0x781c, 0xd0a4, 0x190c, 0x2060, 0x7900, 0xd1dc, 0x1118,
-	0x9084, 0x0006, 0x001a, 0x9084, 0x000e, 0x0002, 0x1f7e, 0x1f76,
-	0x7a59, 0x1f76, 0x1f78, 0x1f78, 0x1f78, 0x1f78, 0x7a3f, 0x1f76,
-	0x1f7a, 0x1f76, 0x1f78, 0x1f76, 0x1f78, 0x1f76, 0x080c, 0x0d65,
-	0x0031, 0x0020, 0x080c, 0x7a3f, 0x080c, 0x7a59, 0x0005, 0x0006,
-	0x0016, 0x0026, 0x080c, 0xd62d, 0x7930, 0x9184, 0x0003, 0x0510,
-	0x080c, 0x98bb, 0x2001, 0x19ca, 0x2004, 0x9005, 0x01a0, 0x2001,
-	0x0133, 0x2004, 0x9005, 0x090c, 0x0d65, 0x00c6, 0x2001, 0x19ca,
-	0x2064, 0x080c, 0x98d7, 0x080c, 0xb440, 0x2009, 0x0040, 0x080c,
-	0x2063, 0x00ce, 0x0408, 0x2009, 0x0040, 0x080c, 0x2063, 0x080c,
-	0x98d7, 0x00d0, 0x9184, 0x0014, 0x01a0, 0x6a00, 0x9286, 0x0003,
-	0x0160, 0x080c, 0x7096, 0x1138, 0x080c, 0x7396, 0x080c, 0x5cd7,
-	0x080c, 0x6fc7, 0x0010, 0x080c, 0x5b92, 0x080c, 0x7af7, 0x0041,
+	0x2600, 0x781c, 0xd0a4, 0x190c, 0x2078, 0x7900, 0xd1dc, 0x1118,
+	0x9084, 0x0006, 0x001a, 0x9084, 0x000e, 0x0002, 0x1f96, 0x1f8e,
+	0x7a7d, 0x1f8e, 0x1f90, 0x1f90, 0x1f90, 0x1f90, 0x7a63, 0x1f8e,
+	0x1f92, 0x1f8e, 0x1f90, 0x1f8e, 0x1f90, 0x1f8e, 0x080c, 0x0d65,
+	0x0031, 0x0020, 0x080c, 0x7a63, 0x080c, 0x7a7d, 0x0005, 0x0006,
+	0x0016, 0x0026, 0x080c, 0xd665, 0x7930, 0x9184, 0x0003, 0x0510,
+	0x080c, 0x98c7, 0x2001, 0x19d2, 0x2004, 0x9005, 0x01a0, 0x2001,
+	0x0133, 0x2004, 0x9005, 0x090c, 0x0d65, 0x00c6, 0x2001, 0x19d2,
+	0x2064, 0x080c, 0x98e3, 0x080c, 0xb45e, 0x2009, 0x0040, 0x080c,
+	0x207b, 0x00ce, 0x0408, 0x2009, 0x0040, 0x080c, 0x207b, 0x080c,
+	0x98e3, 0x00d0, 0x9184, 0x0014, 0x01a0, 0x6a00, 0x9286, 0x0003,
+	0x0160, 0x080c, 0x70ba, 0x1138, 0x080c, 0x73b9, 0x080c, 0x5cf7,
+	0x080c, 0x6feb, 0x0010, 0x080c, 0x5bb2, 0x080c, 0x7b1b, 0x0041,
 	0x0018, 0x9184, 0x9540, 0x1dc8, 0x002e, 0x001e, 0x000e, 0x0005,
-	0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a3b, 0x080c, 0x196c,
+	0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a43, 0x080c, 0x1989,
 	0x005e, 0x004e, 0x003e, 0x00ee, 0x0005, 0x0126, 0x2091, 0x2e00,
-	0x2071, 0x1800, 0x7128, 0x2001, 0x193f, 0x2102, 0x2001, 0x1947,
+	0x2071, 0x1800, 0x7128, 0x2001, 0x1947, 0x2102, 0x2001, 0x194f,
 	0x2102, 0x2001, 0x013b, 0x2102, 0x2079, 0x0200, 0x2001, 0x0201,
 	0x789e, 0x78a3, 0x0200, 0x9198, 0x0007, 0x831c, 0x831c, 0x831c,
 	0x9398, 0x0005, 0x2320, 0x9182, 0x0204, 0x1230, 0x2011, 0x0008,
@@ -834,17 +837,17 @@
 	0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x7902, 0xa001, 0xa001,
 	0xa001, 0xa001, 0xa001, 0xa001, 0x00fe, 0x0005, 0x0126, 0x2091,
 	0x2800, 0x2061, 0x0100, 0x2071, 0x1800, 0x2009, 0x0000, 0x080c,
-	0x283e, 0x080c, 0x2758, 0x2001, 0x196d, 0x2003, 0x0000, 0x2001,
-	0x196e, 0x2003, 0x0000, 0x080c, 0x28af, 0x9006, 0x080c, 0x2787,
-	0x9006, 0x080c, 0x276a, 0x20a9, 0x0012, 0x1d04, 0x2095, 0x2091,
-	0x6000, 0x1f04, 0x2095, 0x602f, 0x0100, 0x602f, 0x0000, 0x6050,
-	0x9085, 0x0400, 0x9084, 0xdfff, 0x6052, 0x6224, 0x080c, 0x288c,
-	0x080c, 0x2476, 0x2009, 0x00ef, 0x6132, 0x6136, 0x080c, 0x2486,
+	0x285e, 0x080c, 0x2774, 0x2001, 0x1975, 0x2003, 0x0700, 0x2001,
+	0x1976, 0x2003, 0x0700, 0x080c, 0x28cf, 0x9006, 0x080c, 0x27a3,
+	0x9006, 0x080c, 0x2786, 0x20a9, 0x0012, 0x1d04, 0x20ad, 0x2091,
+	0x6000, 0x1f04, 0x20ad, 0x602f, 0x0100, 0x602f, 0x0000, 0x6050,
+	0x9085, 0x0400, 0x9084, 0xdfff, 0x6052, 0x6224, 0x080c, 0x28ac,
+	0x080c, 0x2492, 0x2009, 0x00ef, 0x6132, 0x6136, 0x080c, 0x24a2,
 	0x60e7, 0x0000, 0x61ea, 0x60e3, 0x0002, 0x604b, 0xf7f7, 0x6043,
 	0x0000, 0x602f, 0x0080, 0x602f, 0x0000, 0x6007, 0x149f, 0x00c6,
 	0x2061, 0x0140, 0x608b, 0x000b, 0x608f, 0x10b8, 0x6093, 0x0000,
 	0x6097, 0x0198, 0x00ce, 0x6004, 0x9085, 0x8000, 0x6006, 0x60bb,
-	0x0000, 0x20a9, 0x0018, 0x60bf, 0x0000, 0x1f04, 0x20d3, 0x60bb,
+	0x0000, 0x20a9, 0x0018, 0x60bf, 0x0000, 0x1f04, 0x20eb, 0x60bb,
 	0x0000, 0x60bf, 0x0108, 0x60bf, 0x0012, 0x60bf, 0x0320, 0x60bf,
 	0x0018, 0x601b, 0x00f0, 0x601f, 0x001e, 0x600f, 0x006b, 0x602b,
 	0x402c, 0x012e, 0x0005, 0x00f6, 0x2079, 0x0140, 0x78c3, 0x0080,
@@ -852,532 +855,533 @@
 	0x2003, 0x0000, 0x2001, 0x1833, 0x2003, 0x0001, 0x0005, 0x0126,
 	0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x6124, 0x6028, 0x910c,
 	0x9184, 0x5e2c, 0x1118, 0x9184, 0x0007, 0x002a, 0x9195, 0x0004,
-	0x9284, 0x0007, 0x0002, 0x211e, 0x211b, 0x211b, 0x211b, 0x211d,
-	0x211b, 0x211b, 0x211b, 0x080c, 0x0d65, 0x0029, 0x002e, 0x001e,
+	0x9284, 0x0007, 0x0002, 0x2136, 0x2133, 0x2133, 0x2133, 0x2135,
+	0x2133, 0x2133, 0x2133, 0x080c, 0x0d65, 0x0029, 0x002e, 0x001e,
 	0x000e, 0x012e, 0x0005, 0x00a6, 0x6124, 0x6028, 0xd09c, 0x0118,
-	0xd19c, 0x1904, 0x237d, 0xd1f4, 0x190c, 0x0d5e, 0x080c, 0x7096,
-	0x0904, 0x217b, 0x080c, 0xbf61, 0x1120, 0x7000, 0x9086, 0x0003,
-	0x0580, 0x6024, 0x9084, 0x1800, 0x0560, 0x080c, 0x70b9, 0x0118,
-	0x080c, 0x70a7, 0x1530, 0x2011, 0x0020, 0x080c, 0x288c, 0x6043,
-	0x0000, 0x080c, 0xbf61, 0x0168, 0x080c, 0x70b9, 0x1150, 0x2001,
-	0x1977, 0x2003, 0x0001, 0x6027, 0x1800, 0x080c, 0x6f0c, 0x0804,
-	0x2380, 0x70a0, 0x9005, 0x1150, 0x70a3, 0x0001, 0x00d6, 0x2069,
-	0x0140, 0x080c, 0x70ed, 0x00de, 0x1904, 0x2380, 0x080c, 0x73a0,
-	0x0428, 0x080c, 0x70b9, 0x1590, 0x6024, 0x9084, 0x1800, 0x1108,
-	0x0468, 0x080c, 0x73a0, 0x080c, 0x7396, 0x080c, 0x5cd7, 0x080c,
-	0x6fc7, 0x0804, 0x237d, 0xd1ac, 0x1508, 0x6024, 0xd0dc, 0x1170,
+	0xd19c, 0x1904, 0x2395, 0xd1f4, 0x190c, 0x0d5e, 0x080c, 0x70ba,
+	0x0904, 0x2193, 0x080c, 0xbf8f, 0x1120, 0x7000, 0x9086, 0x0003,
+	0x0580, 0x6024, 0x9084, 0x1800, 0x0560, 0x080c, 0x70dd, 0x0118,
+	0x080c, 0x70cb, 0x1530, 0x2011, 0x0020, 0x080c, 0x28ac, 0x6043,
+	0x0000, 0x080c, 0xbf8f, 0x0168, 0x080c, 0x70dd, 0x1150, 0x2001,
+	0x197f, 0x2003, 0x0001, 0x6027, 0x1800, 0x080c, 0x6f30, 0x0804,
+	0x2398, 0x70a0, 0x9005, 0x1150, 0x70a3, 0x0001, 0x00d6, 0x2069,
+	0x0140, 0x080c, 0x7111, 0x00de, 0x1904, 0x2398, 0x080c, 0x73c3,
+	0x0428, 0x080c, 0x70dd, 0x1590, 0x6024, 0x9084, 0x1800, 0x1108,
+	0x0468, 0x080c, 0x73c3, 0x080c, 0x73b9, 0x080c, 0x5cf7, 0x080c,
+	0x6feb, 0x0804, 0x2395, 0xd1ac, 0x1508, 0x6024, 0xd0dc, 0x1170,
 	0xd0e4, 0x1178, 0xd0d4, 0x1190, 0xd0cc, 0x0130, 0x7094, 0x9086,
-	0x0028, 0x1110, 0x080c, 0x7279, 0x0804, 0x237d, 0x080c, 0x739b,
-	0x0048, 0x2001, 0x194d, 0x2003, 0x0002, 0x0020, 0x080c, 0x71d7,
-	0x0804, 0x237d, 0x080c, 0x731b, 0x0804, 0x237d, 0xd1ac, 0x0904,
-	0x2297, 0x080c, 0x7096, 0x11d0, 0x2011, 0x0020, 0x080c, 0x288c,
-	0x0006, 0x0026, 0x0036, 0x080c, 0x70b0, 0x1158, 0x080c, 0x7396,
-	0x080c, 0x5cd7, 0x080c, 0x6fc7, 0x003e, 0x002e, 0x000e, 0x00ae,
-	0x0005, 0x003e, 0x002e, 0x000e, 0x080c, 0x706a, 0x0016, 0x0046,
+	0x0028, 0x1110, 0x080c, 0x729c, 0x0804, 0x2395, 0x080c, 0x73be,
+	0x0048, 0x2001, 0x1955, 0x2003, 0x0002, 0x0020, 0x080c, 0x71fa,
+	0x0804, 0x2395, 0x080c, 0x733e, 0x0804, 0x2395, 0xd1ac, 0x0904,
+	0x22af, 0x080c, 0x70ba, 0x11d0, 0x2011, 0x0020, 0x080c, 0x28ac,
+	0x0006, 0x0026, 0x0036, 0x080c, 0x70d4, 0x1158, 0x080c, 0x73b9,
+	0x080c, 0x5cf7, 0x080c, 0x6feb, 0x003e, 0x002e, 0x000e, 0x00ae,
+	0x0005, 0x003e, 0x002e, 0x000e, 0x080c, 0x708e, 0x0016, 0x0046,
 	0x00c6, 0x644c, 0x9486, 0xf0f0, 0x1138, 0x2061, 0x0100, 0x644a,
 	0x6043, 0x0090, 0x6043, 0x0010, 0x74d6, 0x948c, 0xff00, 0x7038,
 	0xd084, 0x0178, 0x9186, 0xf800, 0x1160, 0x7044, 0xd084, 0x1148,
-	0xc085, 0x7046, 0x0036, 0x2418, 0x2011, 0x8016, 0x080c, 0x48da,
-	0x003e, 0x080c, 0xbf5a, 0x1904, 0x226e, 0x9196, 0xff00, 0x05a8,
+	0xc085, 0x7046, 0x0036, 0x2418, 0x2011, 0x8016, 0x080c, 0x48fa,
+	0x003e, 0x080c, 0xbf88, 0x1904, 0x2286, 0x9196, 0xff00, 0x05a8,
 	0x705c, 0x9084, 0x00ff, 0x810f, 0x81ff, 0x0110, 0x9116, 0x0568,
-	0x7130, 0xd184, 0x1550, 0x080c, 0x317a, 0x0128, 0xc18d, 0x7132,
-	0x080c, 0x665e, 0x1510, 0x6240, 0x9294, 0x0010, 0x0130, 0x6248,
+	0x7130, 0xd184, 0x1550, 0x080c, 0x319a, 0x0128, 0xc18d, 0x7132,
+	0x080c, 0x6682, 0x1510, 0x6240, 0x9294, 0x0010, 0x0130, 0x6248,
 	0x9294, 0xff00, 0x9296, 0xff00, 0x01c0, 0x7030, 0xd08c, 0x0904,
-	0x226e, 0x7038, 0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac,
-	0x1904, 0x226e, 0xc1ad, 0x2102, 0x0036, 0x73d4, 0x2011, 0x8013,
-	0x080c, 0x48da, 0x003e, 0x0804, 0x226e, 0x7038, 0xd08c, 0x1140,
-	0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904, 0x226e, 0xc1ad, 0x2102,
-	0x0036, 0x73d4, 0x2011, 0x8013, 0x080c, 0x48da, 0x003e, 0x7130,
-	0xc185, 0x7132, 0x2011, 0x1854, 0x220c, 0x00f0, 0x0016, 0x2009,
-	0x0001, 0x2011, 0x0100, 0x080c, 0x83cd, 0x2019, 0x000e, 0x00c6,
-	0x2061, 0x0000, 0x080c, 0xd1fc, 0x00ce, 0x9484, 0x00ff, 0x9080,
-	0x317f, 0x200d, 0x918c, 0xff00, 0x810f, 0x2120, 0x9006, 0x2009,
-	0x000e, 0x080c, 0xd284, 0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009,
-	0x0002, 0x2019, 0x0004, 0x080c, 0x2fd3, 0x001e, 0x0078, 0x0156,
-	0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x626b, 0x1110, 0x080c,
-	0x5cf1, 0x8108, 0x1f04, 0x2264, 0x00be, 0x015e, 0x00ce, 0x004e,
-	0x080c, 0x98bb, 0x080c, 0x9b60, 0x080c, 0x98d7, 0x60e3, 0x0000,
+	0x2286, 0x7038, 0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac,
+	0x1904, 0x2286, 0xc1ad, 0x2102, 0x0036, 0x73d4, 0x2011, 0x8013,
+	0x080c, 0x48fa, 0x003e, 0x0804, 0x2286, 0x7038, 0xd08c, 0x1140,
+	0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904, 0x2286, 0xc1ad, 0x2102,
+	0x0036, 0x73d4, 0x2011, 0x8013, 0x080c, 0x48fa, 0x003e, 0x7130,
+	0xc185, 0x7132, 0x2011, 0x185c, 0x220c, 0x00f0, 0x0016, 0x2009,
+	0x0001, 0x2011, 0x0100, 0x080c, 0x8401, 0x2019, 0x000e, 0x00c6,
+	0x2061, 0x0000, 0x080c, 0xd234, 0x00ce, 0x9484, 0x00ff, 0x9080,
+	0x319f, 0x200d, 0x918c, 0xff00, 0x810f, 0x2120, 0x9006, 0x2009,
+	0x000e, 0x080c, 0xd2bc, 0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009,
+	0x0002, 0x2019, 0x0004, 0x080c, 0x2ff3, 0x001e, 0x0078, 0x0156,
+	0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x628f, 0x1110, 0x080c,
+	0x5d11, 0x8108, 0x1f04, 0x227c, 0x00be, 0x015e, 0x00ce, 0x004e,
+	0x080c, 0x98c7, 0x080c, 0x9b6c, 0x080c, 0x98e3, 0x60e3, 0x0000,
 	0x001e, 0x2001, 0x1800, 0x2014, 0x9296, 0x0004, 0x1170, 0xd19c,
 	0x11b0, 0x2011, 0x180c, 0x2214, 0xd29c, 0x1120, 0x6204, 0x9295,
 	0x0002, 0x6206, 0x6228, 0xc29d, 0x622a, 0x2003, 0x0001, 0x2001,
-	0x1825, 0x2003, 0x0000, 0x2011, 0x0020, 0x080c, 0x288c, 0xd194,
-	0x0904, 0x237d, 0x0016, 0x080c, 0x98bb, 0x6220, 0xd2b4, 0x0904,
-	0x2325, 0x080c, 0x81ea, 0x080c, 0x8f9c, 0x2011, 0x0004, 0x080c,
-	0x288c, 0x00f6, 0x2019, 0x19c3, 0x2304, 0x907d, 0x0904, 0x22f2,
+	0x1825, 0x2003, 0x0000, 0x2011, 0x0020, 0x080c, 0x28ac, 0xd194,
+	0x0904, 0x2395, 0x0016, 0x080c, 0x98c7, 0x6220, 0xd2b4, 0x0904,
+	0x233d, 0x080c, 0x821e, 0x080c, 0x8fd0, 0x2011, 0x0004, 0x080c,
+	0x28ac, 0x00f6, 0x2019, 0x19cb, 0x2304, 0x907d, 0x0904, 0x230a,
 	0x7804, 0x9086, 0x0032, 0x15f0, 0x00d6, 0x00c6, 0x00e6, 0x0096,
 	0x2069, 0x0140, 0x782c, 0x685e, 0x7808, 0x685a, 0x6043, 0x0002,
 	0x2001, 0x0003, 0x8001, 0x1df0, 0x6043, 0x0000, 0x2001, 0x003c,
-	0x8001, 0x1df0, 0x080c, 0x2862, 0x2001, 0x001e, 0x8001, 0x0240,
-	0x20a9, 0x0009, 0x080c, 0x2819, 0x6904, 0xd1dc, 0x1140, 0x0cb0,
-	0x2001, 0x0100, 0x080c, 0x2852, 0x9006, 0x080c, 0x2852, 0x080c,
-	0x885d, 0x080c, 0x98d7, 0x7814, 0x2048, 0xa867, 0x0103, 0x2f60,
-	0x080c, 0x9bda, 0x009e, 0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e,
+	0x8001, 0x1df0, 0x080c, 0x2882, 0x2001, 0x001e, 0x8001, 0x0240,
+	0x20a9, 0x0009, 0x080c, 0x2839, 0x6904, 0xd1dc, 0x1140, 0x0cb0,
+	0x2001, 0x0100, 0x080c, 0x2872, 0x9006, 0x080c, 0x2872, 0x080c,
+	0x8891, 0x080c, 0x98e3, 0x7814, 0x2048, 0xa867, 0x0103, 0x2f60,
+	0x080c, 0x9be6, 0x009e, 0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e,
 	0x00ae, 0x0005, 0x00fe, 0x00d6, 0x2069, 0x0140, 0x6804, 0x9084,
-	0x4000, 0x0110, 0x080c, 0x2862, 0x00de, 0x00c6, 0x2061, 0x19b7,
-	0x6034, 0x080c, 0xbf61, 0x0120, 0x909a, 0x0003, 0x1258, 0x0018,
-	0x909a, 0x00c8, 0x1238, 0x8000, 0x6036, 0x00ce, 0x080c, 0x8f74,
-	0x0804, 0x237a, 0x2061, 0x0100, 0x62c0, 0x080c, 0x97ec, 0x2019,
-	0x19c3, 0x2304, 0x9065, 0x0130, 0x6003, 0x0001, 0x2009, 0x0027,
-	0x080c, 0x9c76, 0x00ce, 0x0804, 0x237a, 0xd2bc, 0x05e0, 0x080c,
-	0x81f7, 0x2011, 0x0004, 0x080c, 0x288c, 0x00d6, 0x2069, 0x0140,
-	0x6804, 0x9084, 0x4000, 0x0110, 0x080c, 0x2862, 0x00de, 0x00c6,
-	0x2061, 0x19b7, 0x6050, 0x080c, 0xbf61, 0x0120, 0x909a, 0x0003,
+	0x4000, 0x0110, 0x080c, 0x2882, 0x00de, 0x00c6, 0x2061, 0x19bf,
+	0x6034, 0x080c, 0xbf8f, 0x0120, 0x909a, 0x0003, 0x1258, 0x0018,
+	0x909a, 0x00c8, 0x1238, 0x8000, 0x6036, 0x00ce, 0x080c, 0x8fa8,
+	0x0804, 0x2392, 0x2061, 0x0100, 0x62c0, 0x080c, 0x97f8, 0x2019,
+	0x19cb, 0x2304, 0x9065, 0x0130, 0x6003, 0x0001, 0x2009, 0x0027,
+	0x080c, 0x9c82, 0x00ce, 0x0804, 0x2392, 0xd2bc, 0x05e0, 0x080c,
+	0x822b, 0x2011, 0x0004, 0x080c, 0x28ac, 0x00d6, 0x2069, 0x0140,
+	0x6804, 0x9084, 0x4000, 0x0110, 0x080c, 0x2882, 0x00de, 0x00c6,
+	0x2061, 0x19bf, 0x6050, 0x080c, 0xbf8f, 0x0120, 0x909a, 0x0003,
 	0x1638, 0x0018, 0x909a, 0x00c8, 0x1618, 0x8000, 0x6052, 0x604c,
-	0x00ce, 0x9005, 0x0578, 0x2009, 0x07d0, 0x080c, 0x81ef, 0x9080,
+	0x00ce, 0x9005, 0x0578, 0x2009, 0x07d0, 0x080c, 0x8223, 0x9080,
 	0x0008, 0x2004, 0x9086, 0x0006, 0x1138, 0x2009, 0x1984, 0x2011,
-	0x0012, 0x080c, 0x289b, 0x00f0, 0x2009, 0x1984, 0x2011, 0x0016,
-	0x080c, 0x289b, 0x00b8, 0x2011, 0x0004, 0x080c, 0x288c, 0x0090,
-	0x0036, 0x2019, 0x0001, 0x080c, 0x9269, 0x003e, 0x2019, 0x19ca,
+	0x0012, 0x080c, 0x28bb, 0x00f0, 0x2009, 0x1984, 0x2011, 0x0016,
+	0x080c, 0x28bb, 0x00b8, 0x2011, 0x0004, 0x080c, 0x28ac, 0x0090,
+	0x0036, 0x2019, 0x0001, 0x080c, 0x929d, 0x003e, 0x2019, 0x19d2,
 	0x2304, 0x9065, 0x0130, 0x2009, 0x004f, 0x6003, 0x0003, 0x080c,
-	0x9c76, 0x00ce, 0x080c, 0x98d7, 0x001e, 0xd19c, 0x0904, 0x23db,
-	0x7038, 0xd0ac, 0x1538, 0x0016, 0x0156, 0x2011, 0x0008, 0x080c,
-	0x288c, 0x6050, 0xc0e5, 0x6052, 0x20a9, 0x0367, 0x1f04, 0x23a8,
-	0x1d04, 0x2390, 0x080c, 0x821e, 0x6020, 0xd09c, 0x1db8, 0x00f6,
-	0x2079, 0x0100, 0x080c, 0x27c9, 0x00fe, 0x1d80, 0x6050, 0xc0e4,
-	0x6052, 0x2011, 0x0008, 0x080c, 0x288c, 0x015e, 0x001e, 0x0498,
-	0x015e, 0x001e, 0x0016, 0x6028, 0xc09c, 0x602a, 0x080c, 0x98bb,
-	0x080c, 0x9b60, 0x080c, 0x98d7, 0x60e3, 0x0000, 0x080c, 0xd60c,
-	0x080c, 0xd627, 0x080c, 0x538c, 0xd0fc, 0x1138, 0x080c, 0xbf5a,
-	0x1120, 0x9085, 0x0001, 0x080c, 0x70dd, 0x9006, 0x080c, 0x2852,
-	0x2009, 0x0002, 0x080c, 0x283e, 0x00e6, 0x2071, 0x1800, 0x7003,
-	0x0004, 0x080c, 0x0e9c, 0x00ee, 0x2011, 0x0008, 0x080c, 0x288c,
-	0x080c, 0x0bab, 0x001e, 0x918c, 0xffd0, 0x2110, 0x080c, 0x288c,
-	0x00ae, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00e6, 0x00f6,
-	0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x71cc, 0x70ce, 0x9116,
-	0x0904, 0x2435, 0x81ff, 0x01a0, 0x2009, 0x0000, 0x080c, 0x283e,
-	0x2011, 0x8011, 0x2019, 0x010e, 0x231c, 0x939e, 0x0007, 0x1118,
-	0x2019, 0x0001, 0x0010, 0x2019, 0x0000, 0x080c, 0x48da, 0x0468,
-	0x2001, 0x1978, 0x200c, 0x81ff, 0x1140, 0x2001, 0x0109, 0x2004,
-	0xd0b4, 0x0118, 0x2019, 0x0003, 0x0008, 0x2118, 0x2011, 0x8012,
-	0x080c, 0x48da, 0x080c, 0x0e9c, 0x080c, 0x538c, 0xd0fc, 0x11a8,
-	0x080c, 0xbf5a, 0x1190, 0x00c6, 0x080c, 0x24d1, 0x080c, 0x98bb,
-	0x080c, 0x91c4, 0x080c, 0x98d7, 0x2061, 0x0100, 0x2019, 0x0028,
-	0x2009, 0x0002, 0x080c, 0x2fd3, 0x00ce, 0x012e, 0x00fe, 0x00ee,
-	0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x2028, 0x918c, 0x00ff,
-	0x2130, 0x9094, 0xff00, 0x11f0, 0x2011, 0x1836, 0x2214, 0xd2ac,
-	0x11c8, 0x81ff, 0x01e8, 0x2011, 0x181e, 0x2204, 0x9106, 0x1190,
-	0x2011, 0x181f, 0x2214, 0x9294, 0xff00, 0x9584, 0xff00, 0x9206,
-	0x1148, 0x2011, 0x181f, 0x2214, 0x9294, 0x00ff, 0x9584, 0x00ff,
-	0x9206, 0x1120, 0x2500, 0x080c, 0x7d4f, 0x0048, 0x9584, 0x00ff,
-	0x9080, 0x317f, 0x200d, 0x918c, 0xff00, 0x810f, 0x9006, 0x0005,
-	0x9080, 0x317f, 0x200d, 0x918c, 0x00ff, 0x0005, 0x00d6, 0x2069,
-	0x0140, 0x2001, 0x1817, 0x2003, 0x00ef, 0x20a9, 0x0010, 0x9006,
-	0x6852, 0x6856, 0x1f04, 0x2481, 0x00de, 0x0005, 0x0006, 0x00d6,
-	0x0026, 0x2069, 0x0140, 0x2001, 0x1817, 0x2102, 0x8114, 0x8214,
-	0x8214, 0x8214, 0x20a9, 0x0010, 0x6853, 0x0000, 0x9006, 0x82ff,
-	0x1128, 0x9184, 0x000f, 0x9080, 0xd63b, 0x2005, 0x6856, 0x8211,
-	0x1f04, 0x2496, 0x002e, 0x00de, 0x000e, 0x0005, 0x00c6, 0x2061,
-	0x1800, 0x6030, 0x0110, 0xc09d, 0x0008, 0xc09c, 0x6032, 0x00ce,
-	0x0005, 0x0156, 0x00d6, 0x0026, 0x0016, 0x0006, 0x2069, 0x0140,
-	0x6980, 0x9116, 0x0180, 0x9112, 0x1230, 0x8212, 0x8210, 0x22a8,
-	0x2001, 0x0402, 0x0018, 0x22a8, 0x2001, 0x0404, 0x680e, 0x1f04,
-	0x24c6, 0x680f, 0x0000, 0x000e, 0x001e, 0x002e, 0x00de, 0x015e,
-	0x0005, 0x080c, 0x5388, 0xd0c4, 0x0150, 0xd0a4, 0x0140, 0x9006,
-	0x0046, 0x2020, 0x2009, 0x002e, 0x080c, 0xd284, 0x004e, 0x0005,
-	0x00f6, 0x0016, 0x0026, 0x2079, 0x0140, 0x78c4, 0xd0dc, 0x0904,
-	0x253d, 0x080c, 0x27b9, 0x0660, 0x9084, 0x0700, 0x908e, 0x0600,
-	0x1120, 0x2011, 0x4000, 0x900e, 0x0458, 0x908e, 0x0500, 0x1120,
-	0x2011, 0x8000, 0x900e, 0x0420, 0x908e, 0x0400, 0x1120, 0x9016,
-	0x2009, 0x0001, 0x00e8, 0x908e, 0x0300, 0x1120, 0x9016, 0x2009,
-	0x0002, 0x00b0, 0x908e, 0x0200, 0x1120, 0x9016, 0x2009, 0x0004,
-	0x0078, 0x908e, 0x0100, 0x1548, 0x9016, 0x2009, 0x0008, 0x0040,
-	0x9084, 0x0700, 0x908e, 0x0300, 0x1500, 0x2011, 0x0030, 0x0058,
-	0x2300, 0x9080, 0x0020, 0x2018, 0x080c, 0x83fb, 0x928c, 0xff00,
-	0x0110, 0x2011, 0x00ff, 0x2200, 0x8007, 0x9085, 0x004c, 0x78c2,
-	0x2009, 0x0138, 0x220a, 0x080c, 0x7096, 0x1118, 0x2009, 0x193d,
-	0x220a, 0x002e, 0x001e, 0x00fe, 0x0005, 0x78c3, 0x0000, 0x0cc8,
-	0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x2001, 0x0170,
-	0x200c, 0x8000, 0x2014, 0x9184, 0x0003, 0x0110, 0x080c, 0x0d5e,
-	0x002e, 0x001e, 0x000e, 0x012e, 0x0005, 0x2001, 0x0171, 0x2004,
-	0xd0dc, 0x0168, 0x2001, 0x0170, 0x200c, 0x918c, 0x00ff, 0x918e,
-	0x004c, 0x1128, 0x200c, 0x918c, 0xff00, 0x810f, 0x0005, 0x900e,
-	0x2001, 0x0227, 0x2004, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9108,
-	0x2001, 0x0226, 0x2004, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9108,
-	0x0005, 0x0018, 0x000c, 0x0018, 0x0020, 0x1000, 0x0800, 0x1000,
-	0x1800, 0x0156, 0x0006, 0x0016, 0x0026, 0x00e6, 0x2001, 0x1960,
-	0x2004, 0x908a, 0x0007, 0x1a0c, 0x0d65, 0x0033, 0x00ee, 0x002e,
-	0x001e, 0x000e, 0x015e, 0x0005, 0x259b, 0x25b9, 0x25dd, 0x25df,
-	0x2608, 0x260a, 0x260c, 0x2001, 0x0001, 0x080c, 0x23e2, 0x080c,
-	0x2803, 0x2001, 0x1962, 0x2003, 0x0000, 0x7828, 0x9084, 0xe1d7,
-	0x782a, 0x9006, 0x20a9, 0x0009, 0x080c, 0x27d5, 0x2001, 0x1960,
-	0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x260d, 0x080c, 0x81fc,
-	0x0005, 0x2009, 0x1965, 0x200b, 0x0000, 0x2001, 0x196a, 0x2003,
-	0x0036, 0x2001, 0x1969, 0x2003, 0x002a, 0x2001, 0x1962, 0x2003,
-	0x0001, 0x9006, 0x080c, 0x276a, 0x2001, 0xffff, 0x20a9, 0x0009,
-	0x080c, 0x27d5, 0x2001, 0x1960, 0x2003, 0x0006, 0x2009, 0x001e,
-	0x2011, 0x260d, 0x080c, 0x81fc, 0x0005, 0x080c, 0x0d65, 0x2001,
-	0x196a, 0x2003, 0x0036, 0x2001, 0x1962, 0x2003, 0x0003, 0x7a38,
-	0x9294, 0x0005, 0x9296, 0x0004, 0x0110, 0x9006, 0x0010, 0x2001,
-	0x0001, 0x080c, 0x276a, 0x2001, 0x1966, 0x2003, 0x0000, 0x2001,
-	0xffff, 0x20a9, 0x0009, 0x080c, 0x27d5, 0x2001, 0x1960, 0x2003,
-	0x0006, 0x2009, 0x001e, 0x2011, 0x260d, 0x080c, 0x81fc, 0x0005,
-	0x080c, 0x0d65, 0x080c, 0x0d65, 0x0005, 0x0006, 0x0016, 0x0026,
-	0x00e6, 0x00f6, 0x0156, 0x0126, 0x2091, 0x8000, 0x2079, 0x0100,
-	0x2001, 0x1962, 0x2004, 0x908a, 0x0007, 0x1a0c, 0x0d65, 0x0043,
-	0x012e, 0x015e, 0x00fe, 0x00ee, 0x002e, 0x001e, 0x000e, 0x0005,
-	0x262f, 0x264f, 0x268f, 0x26bf, 0x26e3, 0x26f3, 0x26f5, 0x080c,
-	0x27c9, 0x11b0, 0x7850, 0x9084, 0xefff, 0x7852, 0x2009, 0x1968,
-	0x2104, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0004, 0x0110, 0xc08d,
-	0x0008, 0xc085, 0x200a, 0x2001, 0x1960, 0x2003, 0x0001, 0x0030,
-	0x080c, 0x2719, 0x2001, 0xffff, 0x080c, 0x25aa, 0x0005, 0x080c,
-	0x26f7, 0x05e0, 0x2009, 0x1969, 0x2104, 0x8001, 0x200a, 0x080c,
-	0x27c9, 0x1178, 0x7850, 0x9084, 0xefff, 0x7852, 0x7a38, 0x9294,
-	0x0005, 0x9296, 0x0005, 0x0518, 0x2009, 0x1968, 0x2104, 0xc085,
-	0x200a, 0x2009, 0x1965, 0x2104, 0x8000, 0x200a, 0x9086, 0x0005,
-	0x0118, 0x080c, 0x26ff, 0x00c0, 0x200b, 0x0000, 0x7a38, 0x9294,
-	0x0006, 0x9296, 0x0004, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001,
-	0x080c, 0x2787, 0x2001, 0x1962, 0x2003, 0x0002, 0x0028, 0x2001,
-	0x1960, 0x2003, 0x0003, 0x0010, 0x080c, 0x25cc, 0x0005, 0x080c,
-	0x26f7, 0x0560, 0x2009, 0x1969, 0x2104, 0x8001, 0x200a, 0x080c,
-	0x27c9, 0x1168, 0x7850, 0x9084, 0xefff, 0x7852, 0x2001, 0x1960,
-	0x2003, 0x0003, 0x2001, 0x1961, 0x2003, 0x0000, 0x00b8, 0x2009,
-	0x1969, 0x2104, 0x9005, 0x1118, 0x080c, 0x273c, 0x0010, 0x080c,
-	0x270c, 0x080c, 0x26ff, 0x2009, 0x1965, 0x200b, 0x0000, 0x2001,
-	0x1962, 0x2003, 0x0001, 0x080c, 0x25cc, 0x0000, 0x0005, 0x04b9,
-	0x0508, 0x080c, 0x27c9, 0x11b8, 0x7850, 0x9084, 0xefff, 0x7852,
-	0x2009, 0x1966, 0x2104, 0x8000, 0x200a, 0x9086, 0x0007, 0x0108,
-	0x0078, 0x2001, 0x196b, 0x2003, 0x000a, 0x2009, 0x1968, 0x2104,
-	0xc0fd, 0x200a, 0x0038, 0x0419, 0x2001, 0x1962, 0x2003, 0x0004,
-	0x080c, 0x25f7, 0x0005, 0x0099, 0x0168, 0x080c, 0x27c9, 0x1138,
-	0x7850, 0x9084, 0xefff, 0x7852, 0x080c, 0x25e3, 0x0018, 0x0079,
-	0x080c, 0x25f7, 0x0005, 0x080c, 0x0d65, 0x080c, 0x0d65, 0x2009,
-	0x196a, 0x2104, 0x8001, 0x200a, 0x090c, 0x2758, 0x0005, 0x7a38,
-	0x9294, 0x0005, 0x9296, 0x0005, 0x0110, 0x9006, 0x0010, 0x2001,
-	0x0001, 0x080c, 0x2787, 0x0005, 0x7a38, 0x9294, 0x0006, 0x9296,
-	0x0006, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x276a,
-	0x0005, 0x2009, 0x1965, 0x2104, 0x8000, 0x200a, 0x9086, 0x0005,
-	0x0108, 0x0068, 0x200b, 0x0000, 0x7a38, 0x9294, 0x0006, 0x9296,
-	0x0006, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x04d9, 0x7a38,
-	0x9294, 0x0005, 0x9296, 0x0005, 0x0110, 0x9006, 0x0010, 0x2001,
-	0x0001, 0x080c, 0x2787, 0x0005, 0x0086, 0x2001, 0x1968, 0x2004,
-	0x9084, 0x7fff, 0x090c, 0x0d65, 0x2009, 0x1967, 0x2144, 0x8846,
-	0x280a, 0x9844, 0x0dd8, 0xd08c, 0x1120, 0xd084, 0x1120, 0x080c,
-	0x0d65, 0x9006, 0x0010, 0x2001, 0x0001, 0x00a1, 0x008e, 0x0005,
-	0x0006, 0x0156, 0x2001, 0x1960, 0x20a9, 0x0009, 0x2003, 0x0000,
-	0x8000, 0x1f04, 0x275e, 0x2001, 0x1967, 0x2003, 0x8000, 0x015e,
-	0x000e, 0x0005, 0x00f6, 0x2079, 0x0100, 0x9085, 0x0000, 0x0158,
-	0x7838, 0x9084, 0xfff9, 0x9085, 0x0004, 0x783a, 0x2009, 0x196d,
-	0x210c, 0x795a, 0x0050, 0x7838, 0x9084, 0xfffb, 0x9085, 0x0006,
-	0x783a, 0x2009, 0x196e, 0x210c, 0x795a, 0x00fe, 0x0005, 0x00f6,
-	0x2079, 0x0100, 0x9085, 0x0000, 0x0158, 0x7838, 0x9084, 0xfffa,
-	0x9085, 0x0004, 0x783a, 0x7850, 0x9084, 0xfff0, 0x7852, 0x00f8,
-	0x7838, 0x9084, 0xfffb, 0x9085, 0x0005, 0x783a, 0x7850, 0x9084,
-	0xfff0, 0x0016, 0x2009, 0x017f, 0x210c, 0x918e, 0x0005, 0x0140,
-	0x2009, 0x0003, 0x210c, 0x918c, 0x0600, 0x918e, 0x0400, 0x0118,
-	0x9085, 0x000a, 0x0010, 0x9085, 0x0000, 0x001e, 0x7852, 0x00fe,
-	0x0005, 0x0006, 0x2001, 0x0100, 0x2004, 0x9082, 0x0007, 0x000e,
-	0x0005, 0x0006, 0x2001, 0x0100, 0x2004, 0x9082, 0x0009, 0x000e,
-	0x0005, 0x0156, 0x20a9, 0x0064, 0x7820, 0x080c, 0x2838, 0xd09c,
-	0x1110, 0x1f04, 0x27cc, 0x015e, 0x0005, 0x0126, 0x0016, 0x0006,
-	0x2091, 0x8000, 0x000e, 0x2008, 0x9186, 0x0000, 0x1118, 0x783b,
+	0x9c82, 0x00ce, 0x080c, 0x98e3, 0x001e, 0xd19c, 0x0904, 0x23f7,
+	0x7038, 0xd0ac, 0x1558, 0x0016, 0x0156, 0x2011, 0x0008, 0x080c,
+	0x28ac, 0x080c, 0x28cf, 0x080c, 0x2902, 0x6050, 0xc0e5, 0x6052,
+	0x20a9, 0x0367, 0x1f04, 0x23c4, 0x1d04, 0x23ac, 0x080c, 0x8252,
+	0x6020, 0xd09c, 0x1db8, 0x00f6, 0x2079, 0x0100, 0x080c, 0x27e5,
+	0x00fe, 0x1d80, 0x6050, 0xc0e4, 0x6052, 0x2011, 0x0008, 0x080c,
+	0x28ac, 0x015e, 0x001e, 0x0498, 0x015e, 0x001e, 0x0016, 0x6028,
+	0xc09c, 0x602a, 0x080c, 0x98c7, 0x080c, 0x9b6c, 0x080c, 0x98e3,
+	0x60e3, 0x0000, 0x080c, 0xd644, 0x080c, 0xd65f, 0x080c, 0x53ac,
+	0xd0fc, 0x1138, 0x080c, 0xbf88, 0x1120, 0x9085, 0x0001, 0x080c,
+	0x7101, 0x9006, 0x080c, 0x2872, 0x2009, 0x0002, 0x080c, 0x285e,
+	0x00e6, 0x2071, 0x1800, 0x7003, 0x0004, 0x080c, 0x0ea9, 0x00ee,
+	0x2011, 0x0008, 0x080c, 0x28ac, 0x080c, 0x0bab, 0x001e, 0x918c,
+	0xffd0, 0x2110, 0x080c, 0x28ac, 0x00ae, 0x0005, 0x0006, 0x0016,
+	0x0026, 0x0036, 0x00e6, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2071,
+	0x1800, 0x71cc, 0x70ce, 0x9116, 0x0904, 0x2451, 0x81ff, 0x01a0,
+	0x2009, 0x0000, 0x080c, 0x285e, 0x2011, 0x8011, 0x2019, 0x010e,
+	0x231c, 0x939e, 0x0007, 0x1118, 0x2019, 0x0001, 0x0010, 0x2019,
+	0x0000, 0x080c, 0x48fa, 0x0468, 0x2001, 0x1980, 0x200c, 0x81ff,
+	0x1140, 0x2001, 0x0109, 0x2004, 0xd0b4, 0x0118, 0x2019, 0x0003,
+	0x0008, 0x2118, 0x2011, 0x8012, 0x080c, 0x48fa, 0x080c, 0x0ea9,
+	0x080c, 0x53ac, 0xd0fc, 0x11a8, 0x080c, 0xbf88, 0x1190, 0x00c6,
+	0x080c, 0x24ed, 0x080c, 0x98c7, 0x080c, 0x91f8, 0x080c, 0x98e3,
+	0x2061, 0x0100, 0x2019, 0x0028, 0x2009, 0x0002, 0x080c, 0x2ff3,
+	0x00ce, 0x012e, 0x00fe, 0x00ee, 0x003e, 0x002e, 0x001e, 0x000e,
+	0x0005, 0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00, 0x11f0,
+	0x2011, 0x1836, 0x2214, 0xd2ac, 0x11c8, 0x81ff, 0x01e8, 0x2011,
+	0x181e, 0x2204, 0x9106, 0x1190, 0x2011, 0x181f, 0x2214, 0x9294,
+	0xff00, 0x9584, 0xff00, 0x9206, 0x1148, 0x2011, 0x181f, 0x2214,
+	0x9294, 0x00ff, 0x9584, 0x00ff, 0x9206, 0x1120, 0x2500, 0x080c,
+	0x7d73, 0x0048, 0x9584, 0x00ff, 0x9080, 0x319f, 0x200d, 0x918c,
+	0xff00, 0x810f, 0x9006, 0x0005, 0x9080, 0x319f, 0x200d, 0x918c,
+	0x00ff, 0x0005, 0x00d6, 0x2069, 0x0140, 0x2001, 0x1817, 0x2003,
+	0x00ef, 0x20a9, 0x0010, 0x9006, 0x6852, 0x6856, 0x1f04, 0x249d,
+	0x00de, 0x0005, 0x0006, 0x00d6, 0x0026, 0x2069, 0x0140, 0x2001,
+	0x1817, 0x2102, 0x8114, 0x8214, 0x8214, 0x8214, 0x20a9, 0x0010,
+	0x6853, 0x0000, 0x9006, 0x82ff, 0x1128, 0x9184, 0x000f, 0x9080,
+	0xd673, 0x2005, 0x6856, 0x8211, 0x1f04, 0x24b2, 0x002e, 0x00de,
+	0x000e, 0x0005, 0x00c6, 0x2061, 0x1800, 0x6030, 0x0110, 0xc09d,
+	0x0008, 0xc09c, 0x6032, 0x00ce, 0x0005, 0x0156, 0x00d6, 0x0026,
+	0x0016, 0x0006, 0x2069, 0x0140, 0x6980, 0x9116, 0x0180, 0x9112,
+	0x1230, 0x8212, 0x8210, 0x22a8, 0x2001, 0x0402, 0x0018, 0x22a8,
+	0x2001, 0x0404, 0x680e, 0x1f04, 0x24e2, 0x680f, 0x0000, 0x000e,
+	0x001e, 0x002e, 0x00de, 0x015e, 0x0005, 0x080c, 0x53a8, 0xd0c4,
+	0x0150, 0xd0a4, 0x0140, 0x9006, 0x0046, 0x2020, 0x2009, 0x002e,
+	0x080c, 0xd2bc, 0x004e, 0x0005, 0x00f6, 0x0016, 0x0026, 0x2079,
+	0x0140, 0x78c4, 0xd0dc, 0x0904, 0x2559, 0x080c, 0x27d5, 0x0660,
+	0x9084, 0x0700, 0x908e, 0x0600, 0x1120, 0x2011, 0x4000, 0x900e,
+	0x0458, 0x908e, 0x0500, 0x1120, 0x2011, 0x8000, 0x900e, 0x0420,
+	0x908e, 0x0400, 0x1120, 0x9016, 0x2009, 0x0001, 0x00e8, 0x908e,
+	0x0300, 0x1120, 0x9016, 0x2009, 0x0002, 0x00b0, 0x908e, 0x0200,
+	0x1120, 0x9016, 0x2009, 0x0004, 0x0078, 0x908e, 0x0100, 0x1548,
+	0x9016, 0x2009, 0x0008, 0x0040, 0x9084, 0x0700, 0x908e, 0x0300,
+	0x1500, 0x2011, 0x0030, 0x0058, 0x2300, 0x9080, 0x0020, 0x2018,
+	0x080c, 0x842f, 0x928c, 0xff00, 0x0110, 0x2011, 0x00ff, 0x2200,
+	0x8007, 0x9085, 0x004c, 0x78c2, 0x2009, 0x0138, 0x220a, 0x080c,
+	0x70ba, 0x1118, 0x2009, 0x1945, 0x220a, 0x002e, 0x001e, 0x00fe,
+	0x0005, 0x78c3, 0x0000, 0x0cc8, 0x0126, 0x2091, 0x2800, 0x0006,
+	0x0016, 0x0026, 0x2001, 0x0170, 0x200c, 0x8000, 0x2014, 0x9184,
+	0x0003, 0x0110, 0x080c, 0x0d5e, 0x002e, 0x001e, 0x000e, 0x012e,
+	0x0005, 0x2001, 0x0171, 0x2004, 0xd0dc, 0x0168, 0x2001, 0x0170,
+	0x200c, 0x918c, 0x00ff, 0x918e, 0x004c, 0x1128, 0x200c, 0x918c,
+	0xff00, 0x810f, 0x0005, 0x900e, 0x2001, 0x0227, 0x2004, 0x8007,
+	0x9084, 0x00ff, 0x8004, 0x9108, 0x2001, 0x0226, 0x2004, 0x8007,
+	0x9084, 0x00ff, 0x8004, 0x9108, 0x0005, 0x0018, 0x000c, 0x0018,
+	0x0020, 0x1000, 0x0800, 0x1000, 0x1800, 0x0156, 0x0006, 0x0016,
+	0x0026, 0x00e6, 0x2001, 0x1968, 0x2004, 0x908a, 0x0007, 0x1a0c,
+	0x0d65, 0x0033, 0x00ee, 0x002e, 0x001e, 0x000e, 0x015e, 0x0005,
+	0x25b7, 0x25d5, 0x25f9, 0x25fb, 0x2624, 0x2626, 0x2628, 0x2001,
+	0x0001, 0x080c, 0x23fe, 0x080c, 0x2823, 0x2001, 0x196a, 0x2003,
+	0x0000, 0x7828, 0x9084, 0xe1d7, 0x782a, 0x9006, 0x20a9, 0x0009,
+	0x080c, 0x27f1, 0x2001, 0x1968, 0x2003, 0x0006, 0x2009, 0x001e,
+	0x2011, 0x2629, 0x080c, 0x8230, 0x0005, 0x2009, 0x196d, 0x200b,
+	0x0000, 0x2001, 0x1972, 0x2003, 0x0036, 0x2001, 0x1971, 0x2003,
+	0x002a, 0x2001, 0x196a, 0x2003, 0x0001, 0x9006, 0x080c, 0x2786,
+	0x2001, 0xffff, 0x20a9, 0x0009, 0x080c, 0x27f1, 0x2001, 0x1968,
+	0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x2629, 0x080c, 0x8230,
+	0x0005, 0x080c, 0x0d65, 0x2001, 0x1972, 0x2003, 0x0036, 0x2001,
+	0x196a, 0x2003, 0x0003, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0004,
+	0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x2786, 0x2001,
+	0x196e, 0x2003, 0x0000, 0x2001, 0xffff, 0x20a9, 0x0009, 0x080c,
+	0x27f1, 0x2001, 0x1968, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011,
+	0x2629, 0x080c, 0x8230, 0x0005, 0x080c, 0x0d65, 0x080c, 0x0d65,
+	0x0005, 0x0006, 0x0016, 0x0026, 0x00e6, 0x00f6, 0x0156, 0x0126,
+	0x2091, 0x8000, 0x2079, 0x0100, 0x2001, 0x196a, 0x2004, 0x908a,
+	0x0007, 0x1a0c, 0x0d65, 0x0043, 0x012e, 0x015e, 0x00fe, 0x00ee,
+	0x002e, 0x001e, 0x000e, 0x0005, 0x264b, 0x266b, 0x26ab, 0x26db,
+	0x26ff, 0x270f, 0x2711, 0x080c, 0x27e5, 0x11b0, 0x7850, 0x9084,
+	0xefff, 0x7852, 0x2009, 0x1970, 0x2104, 0x7a38, 0x9294, 0x0005,
+	0x9296, 0x0004, 0x0110, 0xc08d, 0x0008, 0xc085, 0x200a, 0x2001,
+	0x1968, 0x2003, 0x0001, 0x0030, 0x080c, 0x2735, 0x2001, 0xffff,
+	0x080c, 0x25c6, 0x0005, 0x080c, 0x2713, 0x05e0, 0x2009, 0x1971,
+	0x2104, 0x8001, 0x200a, 0x080c, 0x27e5, 0x1178, 0x7850, 0x9084,
+	0xefff, 0x7852, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0518,
+	0x2009, 0x1970, 0x2104, 0xc085, 0x200a, 0x2009, 0x196d, 0x2104,
+	0x8000, 0x200a, 0x9086, 0x0005, 0x0118, 0x080c, 0x271b, 0x00c0,
+	0x200b, 0x0000, 0x7a38, 0x9294, 0x0006, 0x9296, 0x0004, 0x0110,
+	0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x27a3, 0x2001, 0x196a,
+	0x2003, 0x0002, 0x0028, 0x2001, 0x1968, 0x2003, 0x0003, 0x0010,
+	0x080c, 0x25e8, 0x0005, 0x080c, 0x2713, 0x0560, 0x2009, 0x1971,
+	0x2104, 0x8001, 0x200a, 0x080c, 0x27e5, 0x1168, 0x7850, 0x9084,
+	0xefff, 0x7852, 0x2001, 0x1968, 0x2003, 0x0003, 0x2001, 0x1969,
+	0x2003, 0x0000, 0x00b8, 0x2009, 0x1971, 0x2104, 0x9005, 0x1118,
+	0x080c, 0x2758, 0x0010, 0x080c, 0x2728, 0x080c, 0x271b, 0x2009,
+	0x196d, 0x200b, 0x0000, 0x2001, 0x196a, 0x2003, 0x0001, 0x080c,
+	0x25e8, 0x0000, 0x0005, 0x04b9, 0x0508, 0x080c, 0x27e5, 0x11b8,
+	0x7850, 0x9084, 0xefff, 0x7852, 0x2009, 0x196e, 0x2104, 0x8000,
+	0x200a, 0x9086, 0x0007, 0x0108, 0x0078, 0x2001, 0x1973, 0x2003,
+	0x000a, 0x2009, 0x1970, 0x2104, 0xc0fd, 0x200a, 0x0038, 0x0419,
+	0x2001, 0x196a, 0x2003, 0x0004, 0x080c, 0x2613, 0x0005, 0x0099,
+	0x0168, 0x080c, 0x27e5, 0x1138, 0x7850, 0x9084, 0xefff, 0x7852,
+	0x080c, 0x25ff, 0x0018, 0x0079, 0x080c, 0x2613, 0x0005, 0x080c,
+	0x0d65, 0x080c, 0x0d65, 0x2009, 0x1972, 0x2104, 0x8001, 0x200a,
+	0x090c, 0x2774, 0x0005, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005,
+	0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x27a3, 0x0005,
+	0x7a38, 0x9294, 0x0006, 0x9296, 0x0006, 0x0110, 0x9006, 0x0010,
+	0x2001, 0x0001, 0x080c, 0x2786, 0x0005, 0x2009, 0x196d, 0x2104,
+	0x8000, 0x200a, 0x9086, 0x0005, 0x0108, 0x0068, 0x200b, 0x0000,
+	0x7a38, 0x9294, 0x0006, 0x9296, 0x0006, 0x0110, 0x9006, 0x0010,
+	0x2001, 0x0001, 0x04d9, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0005,
+	0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c, 0x27a3, 0x0005,
+	0x0086, 0x2001, 0x1970, 0x2004, 0x9084, 0x7fff, 0x090c, 0x0d65,
+	0x2009, 0x196f, 0x2144, 0x8846, 0x280a, 0x9844, 0x0dd8, 0xd08c,
+	0x1120, 0xd084, 0x1120, 0x080c, 0x0d65, 0x9006, 0x0010, 0x2001,
+	0x0001, 0x00a1, 0x008e, 0x0005, 0x0006, 0x0156, 0x2001, 0x1968,
+	0x20a9, 0x0009, 0x2003, 0x0000, 0x8000, 0x1f04, 0x277a, 0x2001,
+	0x196f, 0x2003, 0x8000, 0x015e, 0x000e, 0x0005, 0x00f6, 0x2079,
+	0x0100, 0x9085, 0x0000, 0x0158, 0x7838, 0x9084, 0xfff9, 0x9085,
+	0x0004, 0x783a, 0x2009, 0x1975, 0x210c, 0x795a, 0x0050, 0x7838,
+	0x9084, 0xfffb, 0x9085, 0x0006, 0x783a, 0x2009, 0x1976, 0x210c,
+	0x795a, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100, 0x9085, 0x0000,
+	0x0158, 0x7838, 0x9084, 0xfffa, 0x9085, 0x0004, 0x783a, 0x7850,
+	0x9084, 0xfff0, 0x7852, 0x00f8, 0x7838, 0x9084, 0xfffb, 0x9085,
+	0x0005, 0x783a, 0x7850, 0x9084, 0xfff0, 0x0016, 0x2009, 0x017f,
+	0x210c, 0x918e, 0x0005, 0x0140, 0x2009, 0x0003, 0x210c, 0x918c,
+	0x0600, 0x918e, 0x0400, 0x0118, 0x9085, 0x000a, 0x0010, 0x9085,
+	0x0000, 0x001e, 0x7852, 0x00fe, 0x0005, 0x0006, 0x2001, 0x0100,
+	0x2004, 0x9082, 0x0007, 0x000e, 0x0005, 0x0006, 0x2001, 0x0100,
+	0x2004, 0x9082, 0x0009, 0x000e, 0x0005, 0x0156, 0x20a9, 0x0064,
+	0x7820, 0x080c, 0x2858, 0xd09c, 0x1110, 0x1f04, 0x27e8, 0x015e,
+	0x0005, 0x0126, 0x0016, 0x0006, 0x2091, 0x8000, 0x080c, 0x28cf,
+	0x080c, 0x2902, 0x000e, 0x2008, 0x9186, 0x0000, 0x1118, 0x783b,
 	0x0007, 0x0090, 0x9186, 0x0001, 0x1118, 0x783b, 0x0006, 0x0060,
 	0x9186, 0x0002, 0x1118, 0x783b, 0x0005, 0x0030, 0x9186, 0x0003,
-	0x1118, 0x783b, 0x0004, 0x0000, 0x0006, 0x1d04, 0x27f5, 0x080c,
-	0x821e, 0x1f04, 0x27f5, 0x7850, 0x9085, 0x1000, 0x7852, 0x000e,
-	0x001e, 0x012e, 0x0005, 0x080c, 0x28e2, 0x0005, 0x0006, 0x0156,
+	0x1118, 0x783b, 0x0004, 0x0000, 0x0006, 0x1d04, 0x2815, 0x080c,
+	0x8252, 0x1f04, 0x2815, 0x7850, 0x9085, 0x1000, 0x7852, 0x000e,
+	0x001e, 0x012e, 0x0005, 0x080c, 0x2902, 0x0005, 0x0006, 0x0156,
 	0x00f6, 0x2079, 0x0100, 0x20a9, 0x000a, 0x7854, 0xd0ac, 0x1100,
-	0x7854, 0xd08c, 0x1110, 0x1f04, 0x2810, 0x00fe, 0x015e, 0x000e,
-	0x0005, 0x1d04, 0x2819, 0x080c, 0x821e, 0x1f04, 0x2819, 0x0005,
-	0x0006, 0x2001, 0x196c, 0x2004, 0x9086, 0x0000, 0x000e, 0x0005,
-	0x0006, 0x2001, 0x196c, 0x2004, 0x9086, 0x0001, 0x000e, 0x0005,
-	0x0006, 0x2001, 0x196c, 0x2004, 0x9086, 0x0002, 0x000e, 0x0005,
+	0x7854, 0xd08c, 0x1110, 0x1f04, 0x2830, 0x00fe, 0x015e, 0x000e,
+	0x0005, 0x1d04, 0x2839, 0x080c, 0x8252, 0x1f04, 0x2839, 0x0005,
+	0x0006, 0x2001, 0x1974, 0x2004, 0x9086, 0x0000, 0x000e, 0x0005,
+	0x0006, 0x2001, 0x1974, 0x2004, 0x9086, 0x0001, 0x000e, 0x0005,
+	0x0006, 0x2001, 0x1974, 0x2004, 0x9086, 0x0002, 0x000e, 0x0005,
 	0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x0005, 0x0006, 0x2001,
-	0x1978, 0x2102, 0x000e, 0x0005, 0x2009, 0x0171, 0x2104, 0xd0dc,
+	0x1980, 0x2102, 0x000e, 0x0005, 0x2009, 0x0171, 0x2104, 0xd0dc,
 	0x0140, 0x2009, 0x0170, 0x2104, 0x200b, 0x0080, 0xa001, 0xa001,
-	0x200a, 0x0005, 0x0016, 0x0026, 0x080c, 0x70b0, 0x0108, 0xc0bc,
+	0x200a, 0x0005, 0x0016, 0x0026, 0x080c, 0x70d4, 0x0108, 0xc0bc,
 	0x2009, 0x0140, 0x2114, 0x9294, 0x0001, 0x9215, 0x220a, 0x002e,
 	0x001e, 0x0005, 0x0016, 0x0026, 0x2009, 0x0140, 0x2114, 0x9294,
 	0x0001, 0x9285, 0x1000, 0x200a, 0x220a, 0x002e, 0x001e, 0x0005,
 	0x0016, 0x0026, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001, 0x9215,
 	0x220a, 0x002e, 0x001e, 0x0005, 0x0006, 0x0016, 0x2009, 0x0140,
-	0x2104, 0x1128, 0x080c, 0x70b0, 0x0110, 0xc0bc, 0x0008, 0xc0bd,
+	0x2104, 0x1128, 0x080c, 0x70d4, 0x0110, 0xc0bc, 0x0008, 0xc0bd,
 	0x200a, 0x001e, 0x000e, 0x0005, 0x00f6, 0x2079, 0x0380, 0x7843,
 	0x0101, 0x7844, 0xd084, 0x1de8, 0x2001, 0x0109, 0x2202, 0x7843,
 	0x0100, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0380, 0x7843, 0x0202,
 	0x7844, 0xd08c, 0x1de8, 0x2079, 0x0100, 0x7814, 0x9104, 0x9205,
 	0x7a16, 0x2079, 0x0380, 0x7843, 0x0200, 0x00fe, 0x0005, 0x0016,
 	0x0026, 0x0036, 0x00c6, 0x2061, 0x0100, 0x6050, 0x9084, 0xfbff,
-	0x9085, 0x0040, 0x6052, 0x20a9, 0x0002, 0x080c, 0x2819, 0x6050,
+	0x9085, 0x0040, 0x6052, 0x20a9, 0x0002, 0x080c, 0x2839, 0x6050,
 	0x9085, 0x0400, 0x9084, 0xff9f, 0x6052, 0x20a9, 0x0005, 0x080c,
-	0x2819, 0x6054, 0xd0bc, 0x090c, 0x0d65, 0x20a9, 0x0005, 0x080c,
-	0x2819, 0x6054, 0xd0ac, 0x090c, 0x0d65, 0x2009, 0x197f, 0x9084,
+	0x2839, 0x6054, 0xd0bc, 0x090c, 0x0d65, 0x20a9, 0x0005, 0x080c,
+	0x2839, 0x6054, 0xd0ac, 0x090c, 0x0d65, 0x2009, 0x1987, 0x9084,
 	0x7e00, 0x8007, 0x8004, 0x8004, 0x200a, 0x00ce, 0x003e, 0x002e,
 	0x001e, 0x0005, 0x0006, 0x00c6, 0x2061, 0x0100, 0x6050, 0xc0cd,
-	0x6052, 0x00ce, 0x000e, 0x0005, 0x2de8, 0x2de8, 0x29ec, 0x29ec,
-	0x29f8, 0x29f8, 0x2a04, 0x2a04, 0x2a12, 0x2a12, 0x2a1e, 0x2a1e,
-	0x2a2c, 0x2a2c, 0x2a3a, 0x2a3a, 0x2a4c, 0x2a4c, 0x2a58, 0x2a58,
-	0x2a66, 0x2a66, 0x2a84, 0x2a84, 0x2aa4, 0x2aa4, 0x2a74, 0x2a74,
-	0x2a94, 0x2a94, 0x2ab2, 0x2ab2, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2ac4, 0x2ac4, 0x2ad0, 0x2ad0,
-	0x2ade, 0x2ade, 0x2aec, 0x2aec, 0x2afc, 0x2afc, 0x2b0a, 0x2b0a,
-	0x2b1a, 0x2b1a, 0x2b2a, 0x2b2a, 0x2b3c, 0x2b3c, 0x2b4a, 0x2b4a,
-	0x2b5a, 0x2b5a, 0x2b7c, 0x2b7c, 0x2ba0, 0x2ba0, 0x2b6a, 0x2b6a,
-	0x2b8e, 0x2b8e, 0x2bb0, 0x2bb0, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2bc4, 0x2bc4, 0x2bd0, 0x2bd0,
-	0x2bde, 0x2bde, 0x2bec, 0x2bec, 0x2bfc, 0x2bfc, 0x2c0a, 0x2c0a,
-	0x2c1a, 0x2c1a, 0x2c2a, 0x2c2a, 0x2c3c, 0x2c3c, 0x2c4a, 0x2c4a,
-	0x2c5a, 0x2c5a, 0x2c6a, 0x2c6a, 0x2c7c, 0x2c7c, 0x2c8c, 0x2c8c,
-	0x2c9e, 0x2c9e, 0x2cb0, 0x2cb0, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2cc4, 0x2cc4, 0x2cd2, 0x2cd2,
-	0x2ce2, 0x2ce2, 0x2cf2, 0x2cf2, 0x2d04, 0x2d04, 0x2d14, 0x2d14,
-	0x2d26, 0x2d26, 0x2d38, 0x2d38, 0x2d4c, 0x2d4c, 0x2d5c, 0x2d5c,
-	0x2d6e, 0x2d6e, 0x2d80, 0x2d80, 0x2d94, 0x2d94, 0x2da5, 0x2da5,
-	0x2db8, 0x2db8, 0x2dcb, 0x2dcb, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a,
-	0x2a4a, 0x2a4a, 0x2a4a, 0x2a4a, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x20ff, 0x0804, 0x2de0,
+	0x6052, 0x00ce, 0x000e, 0x0005, 0x2e08, 0x2e08, 0x2a0c, 0x2a0c,
+	0x2a18, 0x2a18, 0x2a24, 0x2a24, 0x2a32, 0x2a32, 0x2a3e, 0x2a3e,
+	0x2a4c, 0x2a4c, 0x2a5a, 0x2a5a, 0x2a6c, 0x2a6c, 0x2a78, 0x2a78,
+	0x2a86, 0x2a86, 0x2aa4, 0x2aa4, 0x2ac4, 0x2ac4, 0x2a94, 0x2a94,
+	0x2ab4, 0x2ab4, 0x2ad2, 0x2ad2, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2ae4, 0x2ae4, 0x2af0, 0x2af0,
+	0x2afe, 0x2afe, 0x2b0c, 0x2b0c, 0x2b1c, 0x2b1c, 0x2b2a, 0x2b2a,
+	0x2b3a, 0x2b3a, 0x2b4a, 0x2b4a, 0x2b5c, 0x2b5c, 0x2b6a, 0x2b6a,
+	0x2b7a, 0x2b7a, 0x2b9c, 0x2b9c, 0x2bc0, 0x2bc0, 0x2b8a, 0x2b8a,
+	0x2bae, 0x2bae, 0x2bd0, 0x2bd0, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2be4, 0x2be4, 0x2bf0, 0x2bf0,
+	0x2bfe, 0x2bfe, 0x2c0c, 0x2c0c, 0x2c1c, 0x2c1c, 0x2c2a, 0x2c2a,
+	0x2c3a, 0x2c3a, 0x2c4a, 0x2c4a, 0x2c5c, 0x2c5c, 0x2c6a, 0x2c6a,
+	0x2c7a, 0x2c7a, 0x2c8a, 0x2c8a, 0x2c9c, 0x2c9c, 0x2cac, 0x2cac,
+	0x2cbe, 0x2cbe, 0x2cd0, 0x2cd0, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2ce4, 0x2ce4, 0x2cf2, 0x2cf2,
+	0x2d02, 0x2d02, 0x2d12, 0x2d12, 0x2d24, 0x2d24, 0x2d34, 0x2d34,
+	0x2d46, 0x2d46, 0x2d58, 0x2d58, 0x2d6c, 0x2d6c, 0x2d7c, 0x2d7c,
+	0x2d8e, 0x2d8e, 0x2da0, 0x2da0, 0x2db4, 0x2db4, 0x2dc5, 0x2dc5,
+	0x2dd8, 0x2dd8, 0x2deb, 0x2deb, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2117, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x1f2d, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x20ff,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x20ff,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x20ff, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0xa001, 0x0cf0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1335, 0x0804, 0x2de0,
+	0x080c, 0x1f45, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x2117,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2117,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x2117, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0xa001, 0x0cf0, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1342, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x20ff, 0x080c, 0x1335, 0x0804, 0x2de0, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f2d,
-	0x080c, 0x1335, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x20ff, 0x080c, 0x1335,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x20ff,
-	0x080c, 0x1335, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x1335,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1335, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x20ff, 0x080c, 0x1335,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x0804, 0x2de0,
+	0x080c, 0x2117, 0x080c, 0x1342, 0x0804, 0x2e00, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f45,
+	0x080c, 0x1342, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2117, 0x080c, 0x1342,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x2117,
+	0x080c, 0x1342, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x1342,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1342, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x2117, 0x080c, 0x1342,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2540, 0x080c, 0x20ff, 0x0804, 0x2de0, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540,
-	0x080c, 0x1f2d, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f2d,
-	0x080c, 0x20ff, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x20ff, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x20ff,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1335,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x20ff, 0x080c, 0x1335,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x1335,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x20ff, 0x080c, 0x1335,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f2d,
-	0x080c, 0x20ff, 0x080c, 0x1335, 0x0804, 0x2de0, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540,
-	0x080c, 0x1f2d, 0x080c, 0x1335, 0x080c, 0x1f57, 0x0804, 0x2de0,
+	0x080c, 0x255c, 0x080c, 0x2117, 0x0804, 0x2e00, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c,
+	0x080c, 0x1f45, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f45,
+	0x080c, 0x2117, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x2117, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x2117,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1342,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x2117, 0x080c, 0x1342,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x1342,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x2117, 0x080c, 0x1342,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f45,
+	0x080c, 0x2117, 0x080c, 0x1342, 0x0804, 0x2e00, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c,
+	0x080c, 0x1f45, 0x080c, 0x1342, 0x080c, 0x1f6f, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2540, 0x080c, 0x1335, 0x080c, 0x1f57, 0x0804, 0x2de0,
+	0x080c, 0x255c, 0x080c, 0x1342, 0x080c, 0x1f6f, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x20ff, 0x080c, 0x1335,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x9921, 0x0804, 0x2de0,
+	0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x2117, 0x080c, 0x1342,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x992d, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x9921, 0x080c, 0x20ff, 0x0804, 0x2de0, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f2d,
-	0x080c, 0x9921, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x9921,
-	0x080c, 0x20ff, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x9921, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x9921, 0x080c, 0x20ff, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x1f57,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x20ff,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x9921, 0x080c, 0x1335,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x9921, 0x080c, 0x20ff, 0x080c, 0x1335,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x1335,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x20ff,
-	0x080c, 0x1335, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x9921, 0x080c, 0x1335,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x9921, 0x080c, 0x20ff,
-	0x080c, 0x1335, 0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f2d,
-	0x080c, 0x9921, 0x080c, 0x1335, 0x080c, 0x1f57, 0x0804, 0x2de0,
+	0x080c, 0x992d, 0x080c, 0x2117, 0x0804, 0x2e00, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f45,
+	0x080c, 0x992d, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x992d,
+	0x080c, 0x2117, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x992d, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x992d, 0x080c, 0x2117, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x1f6f,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x2117,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x992d, 0x080c, 0x1342,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x992d, 0x080c, 0x2117, 0x080c, 0x1342,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x1342,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x2117,
+	0x080c, 0x1342, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x992d, 0x080c, 0x1342,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x992d, 0x080c, 0x2117,
+	0x080c, 0x1342, 0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f45,
+	0x080c, 0x992d, 0x080c, 0x1342, 0x080c, 0x1f6f, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x20ff, 0x080c, 0x1335,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x9921,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x9921, 0x080c, 0x20ff,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x9921,
-	0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
-	0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x9921,
-	0x080c, 0x20ff, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x9921,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x9921,
-	0x080c, 0x20ff, 0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540,
-	0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x1f57, 0x0804, 0x2de0,
+	0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x2117, 0x080c, 0x1342,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x992d,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x992d, 0x080c, 0x2117,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x992d,
+	0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x992d,
+	0x080c, 0x2117, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x992d,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x992d,
+	0x080c, 0x2117, 0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c,
+	0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x1f6f, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x20ff,
-	0x080c, 0x1f57, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x9921,
-	0x080c, 0x1335, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x9921,
-	0x080c, 0x20ff, 0x080c, 0x1335, 0x0804, 0x2de0, 0x0106, 0x0006,
-	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540,
-	0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x1335, 0x0804, 0x2de0,
+	0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x2117,
+	0x080c, 0x1f6f, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x992d,
+	0x080c, 0x1342, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x992d,
+	0x080c, 0x2117, 0x080c, 0x1342, 0x0804, 0x2e00, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c,
+	0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x1342, 0x0804, 0x2e00,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x9921, 0x080c, 0x20ff,
-	0x080c, 0x1335, 0x0804, 0x2de0, 0x0106, 0x0006, 0x0126, 0x01c6,
-	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x9921,
-	0x080c, 0x1335, 0x080c, 0x1f57, 0x04d8, 0x0106, 0x0006, 0x0126,
-	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c,
-	0x9921, 0x080c, 0x20ff, 0x080c, 0x1335, 0x080c, 0x1f57, 0x0440,
+	0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x992d, 0x080c, 0x2117,
+	0x080c, 0x1342, 0x0804, 0x2e00, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x992d,
+	0x080c, 0x1342, 0x080c, 0x1f6f, 0x04d8, 0x0106, 0x0006, 0x0126,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c,
+	0x992d, 0x080c, 0x2117, 0x080c, 0x1342, 0x080c, 0x1f6f, 0x0440,
 	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
-	0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c, 0x1335, 0x080c, 0x9921,
-	0x080c, 0x1f57, 0x00a8, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
-	0x0136, 0x0146, 0x0156, 0x080c, 0x2540, 0x080c, 0x1f2d, 0x080c,
-	0x9921, 0x080c, 0x20ff, 0x080c, 0x1335, 0x080c, 0x1f57, 0x0000,
+	0x080c, 0x255c, 0x080c, 0x1f45, 0x080c, 0x1342, 0x080c, 0x992d,
+	0x080c, 0x1f6f, 0x00a8, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6,
+	0x0136, 0x0146, 0x0156, 0x080c, 0x255c, 0x080c, 0x1f45, 0x080c,
+	0x992d, 0x080c, 0x2117, 0x080c, 0x1342, 0x080c, 0x1f6f, 0x0000,
 	0x015e, 0x014e, 0x013e, 0x01de, 0x01ce, 0x012e, 0x000e, 0x010e,
-	0x000d, 0x00b6, 0x00c6, 0x0026, 0x0046, 0x9026, 0x080c, 0x6624,
-	0x1904, 0x2eef, 0x72d8, 0x2001, 0x194c, 0x2004, 0x9005, 0x1110,
-	0xd29c, 0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904, 0x2eef, 0x080c,
-	0x2ef4, 0x0804, 0x2eef, 0xd2cc, 0x1904, 0x2eef, 0x080c, 0x7096,
-	0x1120, 0x70ab, 0xffff, 0x0804, 0x2eef, 0xd294, 0x0120, 0x70ab,
-	0xffff, 0x0804, 0x2eef, 0x080c, 0x3175, 0x0160, 0x080c, 0xbf61,
-	0x0128, 0x2001, 0x1817, 0x203c, 0x0804, 0x2e81, 0x70ab, 0xffff,
-	0x0804, 0x2eef, 0x2001, 0x1817, 0x203c, 0x7290, 0xd284, 0x0904,
-	0x2e81, 0xd28c, 0x1904, 0x2e81, 0x0036, 0x73a8, 0x938e, 0xffff,
+	0x000d, 0x00b6, 0x00c6, 0x0026, 0x0046, 0x9026, 0x080c, 0x6648,
+	0x1904, 0x2f0f, 0x72d8, 0x2001, 0x1954, 0x2004, 0x9005, 0x1110,
+	0xd29c, 0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904, 0x2f0f, 0x080c,
+	0x2f14, 0x0804, 0x2f0f, 0xd2cc, 0x1904, 0x2f0f, 0x080c, 0x70ba,
+	0x1120, 0x70ab, 0xffff, 0x0804, 0x2f0f, 0xd294, 0x0120, 0x70ab,
+	0xffff, 0x0804, 0x2f0f, 0x080c, 0x3195, 0x0160, 0x080c, 0xbf8f,
+	0x0128, 0x2001, 0x1817, 0x203c, 0x0804, 0x2ea1, 0x70ab, 0xffff,
+	0x0804, 0x2f0f, 0x2001, 0x1817, 0x203c, 0x7290, 0xd284, 0x0904,
+	0x2ea1, 0xd28c, 0x1904, 0x2ea1, 0x0036, 0x73a8, 0x938e, 0xffff,
 	0x1110, 0x2019, 0x0001, 0x8314, 0x92e0, 0x1d80, 0x2c04, 0x938c,
 	0x0001, 0x0120, 0x9084, 0xff00, 0x8007, 0x0010, 0x9084, 0x00ff,
 	0x970e, 0x05a8, 0x908e, 0x0000, 0x0590, 0x908e, 0x00ff, 0x1150,
 	0x7230, 0xd284, 0x1588, 0x7290, 0xc28d, 0x7292, 0x70ab, 0xffff,
-	0x003e, 0x0478, 0x0026, 0x2011, 0x0010, 0x080c, 0x668a, 0x002e,
-	0x0118, 0x70ab, 0xffff, 0x0410, 0x900e, 0x080c, 0x243d, 0x080c,
-	0x620b, 0x11c0, 0x080c, 0x6666, 0x1168, 0x7030, 0xd08c, 0x0130,
-	0xb800, 0xd0bc, 0x0138, 0x080c, 0x655e, 0x0120, 0x080c, 0x2f0d,
-	0x0148, 0x0028, 0x080c, 0x3059, 0x080c, 0x2f39, 0x0118, 0x8318,
-	0x0804, 0x2e33, 0x73aa, 0x0010, 0x70ab, 0xffff, 0x003e, 0x0804,
-	0x2eef, 0x9780, 0x317f, 0x203d, 0x97bc, 0xff00, 0x873f, 0x2041,
+	0x003e, 0x0478, 0x0026, 0x2011, 0x0010, 0x080c, 0x66ae, 0x002e,
+	0x0118, 0x70ab, 0xffff, 0x0410, 0x900e, 0x080c, 0x2459, 0x080c,
+	0x622f, 0x11c0, 0x080c, 0x668a, 0x1168, 0x7030, 0xd08c, 0x0130,
+	0xb800, 0xd0bc, 0x0138, 0x080c, 0x6582, 0x0120, 0x080c, 0x2f2d,
+	0x0148, 0x0028, 0x080c, 0x3079, 0x080c, 0x2f59, 0x0118, 0x8318,
+	0x0804, 0x2e53, 0x73aa, 0x0010, 0x70ab, 0xffff, 0x003e, 0x0804,
+	0x2f0f, 0x9780, 0x319f, 0x203d, 0x97bc, 0xff00, 0x873f, 0x2041,
 	0x007e, 0x70a8, 0x9096, 0xffff, 0x1118, 0x900e, 0x28a8, 0x0050,
 	0x9812, 0x0220, 0x2008, 0x9802, 0x20a8, 0x0020, 0x70ab, 0xffff,
-	0x0804, 0x2eef, 0x2700, 0x0156, 0x0016, 0x9106, 0x0904, 0x2ee4,
-	0x0026, 0x2011, 0x0010, 0x080c, 0x668a, 0x002e, 0x0120, 0x2009,
-	0xffff, 0x0804, 0x2eec, 0xc484, 0x080c, 0x626b, 0x0138, 0x080c,
-	0xbf61, 0x1590, 0x080c, 0x620b, 0x15b8, 0x0008, 0xc485, 0x080c,
-	0x6666, 0x1130, 0x7030, 0xd08c, 0x01f8, 0xb800, 0xd0bc, 0x11e0,
-	0x7290, 0xd28c, 0x0180, 0x080c, 0x6666, 0x9082, 0x0006, 0x02e0,
-	0xd484, 0x1118, 0x080c, 0x622f, 0x0028, 0x080c, 0x30eb, 0x01a0,
-	0x080c, 0x3116, 0x0088, 0x080c, 0x3059, 0x080c, 0xbf61, 0x1160,
-	0x080c, 0x2f39, 0x0188, 0x0040, 0x080c, 0xbf61, 0x1118, 0x080c,
-	0x30eb, 0x0110, 0x0451, 0x0140, 0x001e, 0x8108, 0x015e, 0x1f04,
-	0x2e9a, 0x70ab, 0xffff, 0x0018, 0x001e, 0x015e, 0x71aa, 0x004e,
+	0x0804, 0x2f0f, 0x2700, 0x0156, 0x0016, 0x9106, 0x0904, 0x2f04,
+	0x0026, 0x2011, 0x0010, 0x080c, 0x66ae, 0x002e, 0x0120, 0x2009,
+	0xffff, 0x0804, 0x2f0c, 0xc484, 0x080c, 0x628f, 0x0138, 0x080c,
+	0xbf8f, 0x1590, 0x080c, 0x622f, 0x15b8, 0x0008, 0xc485, 0x080c,
+	0x668a, 0x1130, 0x7030, 0xd08c, 0x01f8, 0xb800, 0xd0bc, 0x11e0,
+	0x7290, 0xd28c, 0x0180, 0x080c, 0x668a, 0x9082, 0x0006, 0x02e0,
+	0xd484, 0x1118, 0x080c, 0x6253, 0x0028, 0x080c, 0x310b, 0x01a0,
+	0x080c, 0x3136, 0x0088, 0x080c, 0x3079, 0x080c, 0xbf8f, 0x1160,
+	0x080c, 0x2f59, 0x0188, 0x0040, 0x080c, 0xbf8f, 0x1118, 0x080c,
+	0x310b, 0x0110, 0x0451, 0x0140, 0x001e, 0x8108, 0x015e, 0x1f04,
+	0x2eba, 0x70ab, 0xffff, 0x0018, 0x001e, 0x015e, 0x71aa, 0x004e,
 	0x002e, 0x00ce, 0x00be, 0x0005, 0x00c6, 0x0016, 0x70ab, 0x0001,
-	0x2009, 0x007e, 0x080c, 0x620b, 0x1168, 0xb813, 0x00ff, 0xb817,
-	0xfffe, 0x080c, 0x3059, 0x04a9, 0x0128, 0x70d8, 0xc0bd, 0x70da,
-	0x080c, 0xbcae, 0x001e, 0x00ce, 0x0005, 0x0016, 0x0076, 0x00d6,
-	0x00c6, 0x2001, 0x1858, 0x2004, 0x9084, 0x00ff, 0xb842, 0x080c,
-	0x9c49, 0x01d0, 0x2b00, 0x6012, 0x080c, 0xbcdb, 0x6023, 0x0001,
-	0x9006, 0x080c, 0x61a8, 0x2001, 0x0000, 0x080c, 0x61bc, 0x0126,
+	0x2009, 0x007e, 0x080c, 0x622f, 0x1168, 0xb813, 0x00ff, 0xb817,
+	0xfffe, 0x080c, 0x3079, 0x04a9, 0x0128, 0x70d8, 0xc0bd, 0x70da,
+	0x080c, 0xbcdc, 0x001e, 0x00ce, 0x0005, 0x0016, 0x0076, 0x00d6,
+	0x00c6, 0x2001, 0x1860, 0x2004, 0x9084, 0x00ff, 0xb842, 0x080c,
+	0x9c55, 0x01d0, 0x2b00, 0x6012, 0x080c, 0xbd09, 0x6023, 0x0001,
+	0x9006, 0x080c, 0x61cc, 0x2001, 0x0000, 0x080c, 0x61e0, 0x0126,
 	0x2091, 0x8000, 0x70a4, 0x8000, 0x70a6, 0x012e, 0x2009, 0x0004,
-	0x080c, 0x9c76, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e,
-	0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x2001, 0x1858, 0x2004,
-	0x9084, 0x00ff, 0xb842, 0x080c, 0x9c49, 0x0548, 0x2b00, 0x6012,
+	0x080c, 0x9c82, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e,
+	0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x2001, 0x1860, 0x2004,
+	0x9084, 0x00ff, 0xb842, 0x080c, 0x9c55, 0x0548, 0x2b00, 0x6012,
 	0xb800, 0xc0c4, 0xb802, 0xb8a0, 0x9086, 0x007e, 0x0140, 0xb804,
-	0x9084, 0x00ff, 0x9086, 0x0006, 0x1110, 0x080c, 0x300e, 0x080c,
-	0xbcdb, 0x6023, 0x0001, 0x9006, 0x080c, 0x61a8, 0x2001, 0x0002,
-	0x080c, 0x61bc, 0x0126, 0x2091, 0x8000, 0x70a4, 0x8000, 0x70a6,
-	0x012e, 0x2009, 0x0002, 0x080c, 0x9c76, 0x9085, 0x0001, 0x00ce,
+	0x9084, 0x00ff, 0x9086, 0x0006, 0x1110, 0x080c, 0x302e, 0x080c,
+	0xbd09, 0x6023, 0x0001, 0x9006, 0x080c, 0x61cc, 0x2001, 0x0002,
+	0x080c, 0x61e0, 0x0126, 0x2091, 0x8000, 0x70a4, 0x8000, 0x70a6,
+	0x012e, 0x2009, 0x0002, 0x080c, 0x9c82, 0x9085, 0x0001, 0x00ce,
 	0x00de, 0x007e, 0x001e, 0x0005, 0x00b6, 0x00c6, 0x0026, 0x2009,
-	0x0080, 0x080c, 0x620b, 0x1140, 0xb813, 0x00ff, 0xb817, 0xfffc,
+	0x0080, 0x080c, 0x622f, 0x1140, 0xb813, 0x00ff, 0xb817, 0xfffc,
 	0x0039, 0x0110, 0x70df, 0xffff, 0x002e, 0x00ce, 0x00be, 0x0005,
-	0x0016, 0x0076, 0x00d6, 0x00c6, 0x080c, 0x9b84, 0x01d0, 0x2b00,
-	0x6012, 0x080c, 0xbcdb, 0x6023, 0x0001, 0x9006, 0x080c, 0x61a8,
-	0x2001, 0x0002, 0x080c, 0x61bc, 0x0126, 0x2091, 0x8000, 0x70e0,
-	0x8000, 0x70e2, 0x012e, 0x2009, 0x0002, 0x080c, 0x9c76, 0x9085,
+	0x0016, 0x0076, 0x00d6, 0x00c6, 0x080c, 0x9b90, 0x01d0, 0x2b00,
+	0x6012, 0x080c, 0xbd09, 0x6023, 0x0001, 0x9006, 0x080c, 0x61cc,
+	0x2001, 0x0002, 0x080c, 0x61e0, 0x0126, 0x2091, 0x8000, 0x70e0,
+	0x8000, 0x70e2, 0x012e, 0x2009, 0x0002, 0x080c, 0x9c82, 0x9085,
 	0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00c6, 0x00d6,
-	0x0126, 0x2091, 0x8000, 0x2009, 0x007f, 0x080c, 0x620b, 0x11b8,
-	0xb813, 0x00ff, 0xb817, 0xfffd, 0xb8c7, 0x0004, 0x080c, 0x9b84,
+	0x0126, 0x2091, 0x8000, 0x2009, 0x007f, 0x080c, 0x622f, 0x11b8,
+	0xb813, 0x00ff, 0xb817, 0xfffd, 0xb8c7, 0x0004, 0x080c, 0x9b90,
 	0x0170, 0x2b00, 0x6012, 0x6316, 0x6023, 0x0001, 0x620a, 0x080c,
-	0xbcdb, 0x2009, 0x0022, 0x080c, 0x9c76, 0x9085, 0x0001, 0x012e,
+	0xbd09, 0x2009, 0x0022, 0x080c, 0x9c82, 0x9085, 0x0001, 0x012e,
 	0x00de, 0x00ce, 0x0005, 0x00e6, 0x00c6, 0x0066, 0x0036, 0x0026,
-	0x00b6, 0x21f0, 0x080c, 0x98bb, 0x0106, 0x080c, 0x862f, 0x080c,
-	0x85aa, 0x080c, 0x980c, 0x080c, 0xab3a, 0x010e, 0x090c, 0x98d7,
+	0x00b6, 0x21f0, 0x080c, 0x98c7, 0x0106, 0x080c, 0x8663, 0x080c,
+	0x85de, 0x080c, 0x9818, 0x080c, 0xab55, 0x010e, 0x090c, 0x98e3,
 	0x3e08, 0x2130, 0x81ff, 0x0120, 0x20a9, 0x007e, 0x900e, 0x0018,
-	0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x626b, 0x1140, 0x9686,
-	0x0002, 0x1118, 0xb800, 0xd0bc, 0x1110, 0x080c, 0x5cf1, 0x001e,
-	0x8108, 0x1f04, 0x2ff3, 0x9686, 0x0001, 0x190c, 0x3149, 0x00be,
+	0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x628f, 0x1140, 0x9686,
+	0x0002, 0x1118, 0xb800, 0xd0bc, 0x1110, 0x080c, 0x5d11, 0x001e,
+	0x8108, 0x1f04, 0x3013, 0x9686, 0x0001, 0x190c, 0x3169, 0x00be,
 	0x002e, 0x003e, 0x006e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x00c6,
-	0x0046, 0x0036, 0x0026, 0x0016, 0x00b6, 0x080c, 0x98bb, 0x0106,
-	0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c, 0x8624,
-	0x0076, 0x2039, 0x0000, 0x080c, 0x8509, 0x2c08, 0x080c, 0xcfd9,
-	0x007e, 0x001e, 0x010e, 0x090c, 0x98d7, 0xba10, 0xbb14, 0xbc84,
-	0x080c, 0x5cf1, 0xba12, 0xbb16, 0xbc86, 0x00be, 0x001e, 0x002e,
+	0x0046, 0x0036, 0x0026, 0x0016, 0x00b6, 0x080c, 0x98c7, 0x0106,
+	0x6210, 0x2258, 0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c, 0x8658,
+	0x0076, 0x2039, 0x0000, 0x080c, 0x853d, 0x2c08, 0x080c, 0xd011,
+	0x007e, 0x001e, 0x010e, 0x090c, 0x98e3, 0xba10, 0xbb14, 0xbc84,
+	0x080c, 0x5d11, 0xba12, 0xbb16, 0xbc86, 0x00be, 0x001e, 0x002e,
 	0x003e, 0x004e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x00b6,
 	0x6010, 0x2058, 0xb8a0, 0x00be, 0x9086, 0x0080, 0x0150, 0x2071,
 	0x1800, 0x70a4, 0x9005, 0x0110, 0x8001, 0x70a6, 0x000e, 0x00ee,
 	0x0005, 0x2071, 0x1800, 0x70e0, 0x9005, 0x0dc0, 0x8001, 0x70e2,
 	0x0ca8, 0xb800, 0xc08c, 0xb802, 0x0005, 0x00f6, 0x00e6, 0x00c6,
 	0x00b6, 0x0046, 0x0036, 0x0026, 0x0016, 0x0156, 0x2178, 0x080c,
-	0x98bb, 0x0106, 0x81ff, 0x1118, 0x20a9, 0x0001, 0x0070, 0x080c,
-	0x5388, 0xd0c4, 0x0138, 0x0030, 0x9006, 0x2020, 0x2009, 0x002d,
-	0x080c, 0xd284, 0x20a9, 0x0800, 0x9016, 0x0026, 0x928e, 0x007e,
-	0x0904, 0x30c7, 0x928e, 0x007f, 0x0904, 0x30c7, 0x928e, 0x0080,
+	0x98c7, 0x0106, 0x81ff, 0x1118, 0x20a9, 0x0001, 0x0070, 0x080c,
+	0x53a8, 0xd0c4, 0x0138, 0x0030, 0x9006, 0x2020, 0x2009, 0x002d,
+	0x080c, 0xd2bc, 0x20a9, 0x0800, 0x9016, 0x0026, 0x928e, 0x007e,
+	0x0904, 0x30e7, 0x928e, 0x007f, 0x0904, 0x30e7, 0x928e, 0x0080,
 	0x05f0, 0x9288, 0x1000, 0x210c, 0x81ff, 0x05c8, 0x8fff, 0x1150,
-	0x2001, 0x195e, 0x0006, 0x2003, 0x0001, 0x080c, 0x30d8, 0x000e,
+	0x2001, 0x1966, 0x0006, 0x2003, 0x0001, 0x080c, 0x30f8, 0x000e,
 	0x2003, 0x0000, 0x00b6, 0x00c6, 0x2158, 0x2001, 0x0001, 0x080c,
-	0x6630, 0x00ce, 0x00be, 0x2019, 0x0029, 0x080c, 0x8624, 0x0076,
-	0x2039, 0x0000, 0x080c, 0x8509, 0x00b6, 0x00c6, 0x0026, 0x2158,
+	0x6654, 0x00ce, 0x00be, 0x2019, 0x0029, 0x080c, 0x8658, 0x0076,
+	0x2039, 0x0000, 0x080c, 0x853d, 0x00b6, 0x00c6, 0x0026, 0x2158,
 	0xba04, 0x9294, 0x00ff, 0x9286, 0x0006, 0x1118, 0xb807, 0x0404,
 	0x0028, 0x2001, 0x0004, 0x8007, 0x9215, 0xba06, 0x002e, 0x00ce,
-	0x00be, 0x0016, 0x2c08, 0x080c, 0xcfd9, 0x001e, 0x007e, 0x002e,
-	0x8210, 0x1f04, 0x307d, 0x010e, 0x090c, 0x98d7, 0x015e, 0x001e,
+	0x00be, 0x0016, 0x2c08, 0x080c, 0xd011, 0x001e, 0x007e, 0x002e,
+	0x8210, 0x1f04, 0x309d, 0x010e, 0x090c, 0x98e3, 0x015e, 0x001e,
 	0x002e, 0x003e, 0x004e, 0x00be, 0x00ce, 0x00ee, 0x00fe, 0x0005,
-	0x0046, 0x0026, 0x0016, 0x080c, 0x5388, 0xd0c4, 0x0140, 0xd0a4,
-	0x0130, 0x9006, 0x2220, 0x2009, 0x0029, 0x080c, 0xd284, 0x001e,
+	0x0046, 0x0026, 0x0016, 0x080c, 0x53a8, 0xd0c4, 0x0140, 0xd0a4,
+	0x0130, 0x9006, 0x2220, 0x2009, 0x0029, 0x080c, 0xd2bc, 0x001e,
 	0x002e, 0x004e, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x7290,
-	0x82ff, 0x01e8, 0x080c, 0x665e, 0x11d0, 0x2100, 0x080c, 0x2470,
+	0x82ff, 0x01e8, 0x080c, 0x6682, 0x11d0, 0x2100, 0x080c, 0x248c,
 	0x81ff, 0x01b8, 0x2019, 0x0001, 0x8314, 0x92e0, 0x1d80, 0x2c04,
 	0xd384, 0x0120, 0x9084, 0xff00, 0x8007, 0x0010, 0x9084, 0x00ff,
 	0x9116, 0x0138, 0x9096, 0x00ff, 0x0110, 0x8318, 0x0c68, 0x9085,
 	0x0001, 0x00ce, 0x003e, 0x002e, 0x001e, 0x0005, 0x0016, 0x00c6,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x98bb, 0x0106, 0x0036, 0x2019,
-	0x0029, 0x00c1, 0x003e, 0x010e, 0x090c, 0x98d7, 0x9180, 0x1000,
-	0x2004, 0x9065, 0x0158, 0x0016, 0x00c6, 0x2061, 0x1b01, 0x001e,
-	0x6112, 0x080c, 0x300e, 0x001e, 0x080c, 0x622f, 0x012e, 0x00ce,
-	0x001e, 0x0005, 0x0016, 0x0026, 0x2110, 0x080c, 0x94dd, 0x080c,
-	0xd53a, 0x002e, 0x001e, 0x0005, 0x2001, 0x1836, 0x2004, 0xd0cc,
-	0x0005, 0x00c6, 0x00b6, 0x080c, 0x7096, 0x1118, 0x20a9, 0x0800,
-	0x0010, 0x20a9, 0x0782, 0x080c, 0x7096, 0x1110, 0x900e, 0x0010,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x98c7, 0x0106, 0x0036, 0x2019,
+	0x0029, 0x00c1, 0x003e, 0x010e, 0x090c, 0x98e3, 0x9180, 0x1000,
+	0x2004, 0x9065, 0x0158, 0x0016, 0x00c6, 0x2061, 0x1b09, 0x001e,
+	0x6112, 0x080c, 0x302e, 0x001e, 0x080c, 0x6253, 0x012e, 0x00ce,
+	0x001e, 0x0005, 0x0016, 0x0026, 0x2110, 0x080c, 0x94e5, 0x080c,
+	0xd572, 0x002e, 0x001e, 0x0005, 0x2001, 0x1836, 0x2004, 0xd0cc,
+	0x0005, 0x00c6, 0x00b6, 0x080c, 0x70ba, 0x1118, 0x20a9, 0x0800,
+	0x0010, 0x20a9, 0x0782, 0x080c, 0x70ba, 0x1110, 0x900e, 0x0010,
 	0x2009, 0x007e, 0x9180, 0x1000, 0x2004, 0x905d, 0x0130, 0x86ff,
-	0x0110, 0xb800, 0xd0bc, 0x090c, 0x622f, 0x8108, 0x1f04, 0x315a,
+	0x0110, 0xb800, 0xd0bc, 0x090c, 0x6253, 0x8108, 0x1f04, 0x317a,
 	0x2061, 0x1800, 0x607b, 0x0000, 0x607c, 0x9084, 0x00ff, 0x607e,
-	0x60af, 0x0000, 0x00be, 0x00ce, 0x0005, 0x2001, 0x1875, 0x2004,
-	0xd0bc, 0x0005, 0x2011, 0x1854, 0x2214, 0xd2ec, 0x0005, 0x7eef,
+	0x60af, 0x0000, 0x00be, 0x00ce, 0x0005, 0x2001, 0x187d, 0x2004,
+	0xd0bc, 0x0005, 0x2011, 0x185c, 0x2214, 0xd2ec, 0x0005, 0x7eef,
 	0x7de8, 0x7ce4, 0x80e2, 0x7be1, 0x80e0, 0x80dc, 0x80da, 0x7ad9,
 	0x80d6, 0x80d5, 0x80d4, 0x80d3, 0x80d2, 0x80d1, 0x79ce, 0x78cd,
 	0x80cc, 0x80cb, 0x80ca, 0x80c9, 0x80c7, 0x80c6, 0x77c5, 0x76c3,
@@ -1410,360 +1414,360 @@
 	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x8000,
 	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
 	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x2071,
-	0x1894, 0x7003, 0x0002, 0x9006, 0x7016, 0x701a, 0x704a, 0x704e,
-	0x700e, 0x7042, 0x7046, 0x703b, 0x18b0, 0x703f, 0x18b0, 0x7007,
-	0x0001, 0x080c, 0x103b, 0x090c, 0x0d65, 0x2900, 0x706a, 0xa867,
-	0x0002, 0xa8ab, 0xdcb0, 0x080c, 0x103b, 0x090c, 0x0d65, 0x2900,
-	0x706e, 0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x1894,
-	0x7004, 0x0002, 0x32ae, 0x32af, 0x32c2, 0x32d6, 0x0005, 0x1004,
-	0x32bf, 0x0e04, 0x32bf, 0x2079, 0x0000, 0x0126, 0x2091, 0x8000,
+	0x189c, 0x7003, 0x0002, 0x9006, 0x7016, 0x701a, 0x704a, 0x704e,
+	0x700e, 0x7042, 0x7046, 0x703b, 0x18b8, 0x703f, 0x18b8, 0x7007,
+	0x0001, 0x080c, 0x1048, 0x090c, 0x0d65, 0x2900, 0x706a, 0xa867,
+	0x0002, 0xa8ab, 0xdcb0, 0x080c, 0x1048, 0x090c, 0x0d65, 0x2900,
+	0x706e, 0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x189c,
+	0x7004, 0x0002, 0x32ce, 0x32cf, 0x32e2, 0x32f6, 0x0005, 0x1004,
+	0x32df, 0x0e04, 0x32df, 0x2079, 0x0000, 0x0126, 0x2091, 0x8000,
 	0x700c, 0x9005, 0x1128, 0x700f, 0x0001, 0x012e, 0x0468, 0x0005,
-	0x012e, 0x0ce8, 0x2079, 0x0000, 0x2061, 0x18ae, 0x2c4c, 0xa86c,
-	0x908e, 0x0100, 0x0128, 0x9086, 0x0200, 0x0904, 0x33aa, 0x0005,
+	0x012e, 0x0ce8, 0x2079, 0x0000, 0x2061, 0x18b6, 0x2c4c, 0xa86c,
+	0x908e, 0x0100, 0x0128, 0x9086, 0x0200, 0x0904, 0x33ca, 0x0005,
 	0x7018, 0x2048, 0x2061, 0x1800, 0x701c, 0x0807, 0x7014, 0x2048,
 	0xa864, 0x9094, 0x00ff, 0x9296, 0x0029, 0x1120, 0xaa78, 0xd2fc,
 	0x0128, 0x0005, 0x9086, 0x0103, 0x0108, 0x0005, 0x2079, 0x0000,
 	0x2061, 0x1800, 0x701c, 0x0807, 0x2061, 0x1800, 0x7880, 0x908a,
 	0x0040, 0x1210, 0x61cc, 0x0042, 0x2100, 0x908a, 0x003f, 0x1a04,
-	0x33a7, 0x61cc, 0x0804, 0x333c, 0x337e, 0x33b6, 0x33a7, 0x33c0,
-	0x33ca, 0x33d0, 0x33d4, 0x33e4, 0x33e8, 0x33fe, 0x3404, 0x340a,
-	0x3415, 0x3420, 0x342f, 0x343e, 0x344c, 0x3463, 0x347e, 0x33a7,
-	0x3527, 0x3565, 0x360a, 0x361b, 0x363e, 0x33a7, 0x33a7, 0x33a7,
-	0x3676, 0x3696, 0x369f, 0x36cb, 0x36d1, 0x33a7, 0x3717, 0x33a7,
-	0x33a7, 0x33a7, 0x33a7, 0x33a7, 0x3722, 0x372b, 0x3733, 0x3735,
-	0x33a7, 0x33a7, 0x33a7, 0x33a7, 0x33a7, 0x33a7, 0x3765, 0x33a7,
-	0x33a7, 0x33a7, 0x33a7, 0x33a7, 0x3782, 0x37dd, 0x33a7, 0x33a7,
-	0x33a7, 0x33a7, 0x33a7, 0x33a7, 0x0002, 0x3807, 0x380a, 0x3869,
-	0x3882, 0x38b2, 0x3b54, 0x33a7, 0x4f59, 0x33a7, 0x33a7, 0x33a7,
-	0x33a7, 0x33a7, 0x33a7, 0x33a7, 0x33a7, 0x33fe, 0x3404, 0x4053,
-	0x53ac, 0x4069, 0x4fe8, 0x5039, 0x513c, 0x33a7, 0x519e, 0x51da,
-	0x520b, 0x5317, 0x5238, 0x5297, 0x33a7, 0x406d, 0x41fd, 0x4213,
-	0x4238, 0x429d, 0x4311, 0x4331, 0x43a8, 0x4404, 0x4460, 0x4463,
-	0x4488, 0x44fb, 0x4565, 0x456d, 0x469f, 0x4804, 0x4838, 0x4a82,
-	0x33a7, 0x4aa0, 0x4b5c, 0x4c32, 0x33a7, 0x33a7, 0x33a7, 0x33a7,
-	0x4c98, 0x4cb3, 0x456d, 0x4ef9, 0x714c, 0x0000, 0x2021, 0x4000,
-	0x080c, 0x48b6, 0x0126, 0x2091, 0x8000, 0x0e04, 0x3388, 0x0010,
+	0x33c7, 0x61cc, 0x0804, 0x335c, 0x339e, 0x33d6, 0x33c7, 0x33e0,
+	0x33ea, 0x33f0, 0x33f4, 0x3404, 0x3408, 0x341e, 0x3424, 0x342a,
+	0x3435, 0x3440, 0x344f, 0x345e, 0x346c, 0x3483, 0x349e, 0x33c7,
+	0x3547, 0x3585, 0x362a, 0x363b, 0x365e, 0x33c7, 0x33c7, 0x33c7,
+	0x3696, 0x36b6, 0x36bf, 0x36eb, 0x36f1, 0x33c7, 0x3737, 0x33c7,
+	0x33c7, 0x33c7, 0x33c7, 0x33c7, 0x3742, 0x374b, 0x3753, 0x3755,
+	0x33c7, 0x33c7, 0x33c7, 0x33c7, 0x33c7, 0x33c7, 0x3785, 0x33c7,
+	0x33c7, 0x33c7, 0x33c7, 0x33c7, 0x37a2, 0x37fd, 0x33c7, 0x33c7,
+	0x33c7, 0x33c7, 0x33c7, 0x33c7, 0x0002, 0x3827, 0x382a, 0x3889,
+	0x38a2, 0x38d2, 0x3b74, 0x33c7, 0x4f79, 0x33c7, 0x33c7, 0x33c7,
+	0x33c7, 0x33c7, 0x33c7, 0x33c7, 0x33c7, 0x341e, 0x3424, 0x4073,
+	0x53cc, 0x4089, 0x5008, 0x5059, 0x515c, 0x33c7, 0x51be, 0x51fa,
+	0x522b, 0x5337, 0x5258, 0x52b7, 0x33c7, 0x408d, 0x421d, 0x4233,
+	0x4258, 0x42bd, 0x4331, 0x4351, 0x43c8, 0x4424, 0x4480, 0x4483,
+	0x44a8, 0x451b, 0x4585, 0x458d, 0x46bf, 0x4824, 0x4858, 0x4aa2,
+	0x33c7, 0x4ac0, 0x4b7c, 0x4c52, 0x33c7, 0x33c7, 0x33c7, 0x33c7,
+	0x4cb8, 0x4cd3, 0x458d, 0x4f19, 0x714c, 0x0000, 0x2021, 0x4000,
+	0x080c, 0x48d6, 0x0126, 0x2091, 0x8000, 0x0e04, 0x33a8, 0x0010,
 	0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000, 0x0118, 0x7833, 0x0011,
 	0x0010, 0x7833, 0x0010, 0x7c82, 0x7986, 0x7a8a, 0x7b8e, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11c9, 0x7007,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11d6, 0x7007,
 	0x0001, 0x2091, 0x5000, 0x700f, 0x0000, 0x012e, 0x0005, 0x2021,
 	0x4001, 0x08b0, 0x2021, 0x4002, 0x0898, 0x2021, 0x4003, 0x0880,
 	0x2021, 0x4005, 0x0868, 0x2021, 0x4006, 0x0850, 0x2039, 0x0001,
-	0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884, 0x7990, 0x0804, 0x48c3,
+	0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884, 0x7990, 0x0804, 0x48e3,
 	0x2039, 0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884, 0x7990,
-	0x0804, 0x48c6, 0x7984, 0x7888, 0x2114, 0x200a, 0x0804, 0x337e,
-	0x7984, 0x2114, 0x0804, 0x337e, 0x20e1, 0x0000, 0x2099, 0x0021,
+	0x0804, 0x48e6, 0x7984, 0x7888, 0x2114, 0x200a, 0x0804, 0x339e,
+	0x7984, 0x2114, 0x0804, 0x339e, 0x20e1, 0x0000, 0x2099, 0x0021,
 	0x20e9, 0x0000, 0x20a1, 0x0021, 0x20a9, 0x001f, 0x4003, 0x7984,
-	0x7a88, 0x7b8c, 0x0804, 0x337e, 0x7884, 0x2060, 0x0804, 0x3431,
-	0x2009, 0x0003, 0x2011, 0x0002, 0x2019, 0x001e, 0x789b, 0x0317,
-	0x7893, 0xffff, 0x2001, 0x1885, 0x2004, 0x9005, 0x0118, 0x7896,
-	0x0804, 0x337e, 0x7897, 0x0001, 0x0804, 0x337e, 0x2039, 0x0001,
-	0x7d98, 0x7c9c, 0x0804, 0x33ba, 0x2039, 0x0001, 0x7d98, 0x7c9c,
-	0x0804, 0x33c4, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x33b3,
-	0x2138, 0x7d98, 0x7c9c, 0x0804, 0x33ba, 0x79a0, 0x9182, 0x0040,
-	0x0210, 0x0804, 0x33b3, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x33c4,
-	0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x33b3, 0x21e8, 0x7984,
-	0x7888, 0x20a9, 0x0001, 0x21a0, 0x4004, 0x0804, 0x337e, 0x2061,
+	0x7a88, 0x7b8c, 0x0804, 0x339e, 0x7884, 0x2060, 0x0804, 0x3451,
+	0x2009, 0x0003, 0x2011, 0x0003, 0x2019, 0x0002, 0x789b, 0x0317,
+	0x7893, 0xffff, 0x2001, 0x188d, 0x2004, 0x9005, 0x0118, 0x7896,
+	0x0804, 0x339e, 0x7897, 0x0001, 0x0804, 0x339e, 0x2039, 0x0001,
+	0x7d98, 0x7c9c, 0x0804, 0x33da, 0x2039, 0x0001, 0x7d98, 0x7c9c,
+	0x0804, 0x33e4, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x33d3,
+	0x2138, 0x7d98, 0x7c9c, 0x0804, 0x33da, 0x79a0, 0x9182, 0x0040,
+	0x0210, 0x0804, 0x33d3, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x33e4,
+	0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x33d3, 0x21e8, 0x7984,
+	0x7888, 0x20a9, 0x0001, 0x21a0, 0x4004, 0x0804, 0x339e, 0x2061,
 	0x0800, 0xe10c, 0x9006, 0x2c15, 0x9200, 0x8c60, 0x8109, 0x1dd8,
-	0x2010, 0x9005, 0x0904, 0x337e, 0x0804, 0x33ad, 0x79a0, 0x9182,
-	0x0040, 0x0210, 0x0804, 0x33b3, 0x21e0, 0x20a9, 0x0001, 0x7984,
-	0x2198, 0x4012, 0x0804, 0x337e, 0x2069, 0x1853, 0x7884, 0x7990,
-	0x911a, 0x1a04, 0x33b3, 0x8019, 0x0904, 0x33b3, 0x684a, 0x6942,
+	0x2010, 0x9005, 0x0904, 0x339e, 0x0804, 0x33cd, 0x79a0, 0x9182,
+	0x0040, 0x0210, 0x0804, 0x33d3, 0x21e0, 0x20a9, 0x0001, 0x7984,
+	0x2198, 0x4012, 0x0804, 0x339e, 0x2069, 0x185b, 0x7884, 0x7990,
+	0x911a, 0x1a04, 0x33d3, 0x8019, 0x0904, 0x33d3, 0x684a, 0x6942,
 	0x788c, 0x6852, 0x7888, 0x6856, 0x9006, 0x685a, 0x685e, 0x080c,
-	0x73c7, 0x0804, 0x337e, 0x2069, 0x1853, 0x7884, 0x7994, 0x911a,
-	0x1a04, 0x33b3, 0x8019, 0x0904, 0x33b3, 0x684e, 0x6946, 0x788c,
+	0x73ea, 0x0804, 0x339e, 0x2069, 0x185b, 0x7884, 0x7994, 0x911a,
+	0x1a04, 0x33d3, 0x8019, 0x0904, 0x33d3, 0x684e, 0x6946, 0x788c,
 	0x6862, 0x7888, 0x6866, 0x9006, 0x686a, 0x686e, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x6764, 0x012e, 0x0804, 0x337e, 0x902e, 0x2520,
-	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x33b0, 0x7984, 0x7b88,
-	0x7a8c, 0x20a9, 0x0005, 0x20e9, 0x0001, 0x20a1, 0x189c, 0x4101,
-	0x080c, 0x487a, 0x1120, 0x2009, 0x0002, 0x0804, 0x33b0, 0x2009,
-	0x0020, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x48c3, 0x701f,
-	0x34a2, 0x0005, 0xa864, 0x2008, 0x9084, 0x00ff, 0x9096, 0x0011,
+	0x8000, 0x080c, 0x6788, 0x012e, 0x0804, 0x339e, 0x902e, 0x2520,
+	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x33d0, 0x7984, 0x7b88,
+	0x7a8c, 0x20a9, 0x0005, 0x20e9, 0x0001, 0x20a1, 0x18a4, 0x4101,
+	0x080c, 0x489a, 0x1120, 0x2009, 0x0002, 0x0804, 0x33d0, 0x2009,
+	0x0020, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x48e3, 0x701f,
+	0x34c2, 0x0005, 0xa864, 0x2008, 0x9084, 0x00ff, 0x9096, 0x0011,
 	0x0168, 0x9096, 0x0019, 0x0150, 0x9096, 0x0015, 0x0138, 0x9096,
-	0x0048, 0x0120, 0x9096, 0x0029, 0x1904, 0x33b0, 0x810f, 0x918c,
-	0x00ff, 0x0904, 0x33b0, 0x7112, 0x7010, 0x8001, 0x0560, 0x7012,
-	0x080c, 0x487a, 0x1120, 0x2009, 0x0002, 0x0804, 0x33b0, 0x2009,
+	0x0048, 0x0120, 0x9096, 0x0029, 0x1904, 0x33d0, 0x810f, 0x918c,
+	0x00ff, 0x0904, 0x33d0, 0x7112, 0x7010, 0x8001, 0x0560, 0x7012,
+	0x080c, 0x489a, 0x1120, 0x2009, 0x0002, 0x0804, 0x33d0, 0x2009,
 	0x0020, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494, 0xa598, 0x9290,
 	0x0040, 0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c,
-	0x9080, 0x0019, 0xaf60, 0x080c, 0x48c3, 0x701f, 0x34e0, 0x0005,
+	0x9080, 0x0019, 0xaf60, 0x080c, 0x48e3, 0x701f, 0x3500, 0x0005,
 	0xa864, 0x9084, 0x00ff, 0x9096, 0x0002, 0x0120, 0x9096, 0x000a,
-	0x1904, 0x33b0, 0x0888, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a,
+	0x1904, 0x33d0, 0x0888, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a,
 	0xa864, 0x9084, 0x00ff, 0x9096, 0x0029, 0x1160, 0xc2fd, 0xaa7a,
-	0x080c, 0x5ddf, 0x0150, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982,
-	0x012e, 0x0050, 0x080c, 0x60f6, 0x1128, 0x7007, 0x0003, 0x701f,
-	0x350c, 0x0005, 0x080c, 0x6ba2, 0x0126, 0x2091, 0x8000, 0x20a9,
-	0x0005, 0x20e1, 0x0001, 0x2099, 0x189c, 0x400a, 0x2100, 0x9210,
+	0x080c, 0x5dff, 0x0150, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982,
+	0x012e, 0x0050, 0x080c, 0x611a, 0x1128, 0x7007, 0x0003, 0x701f,
+	0x352c, 0x0005, 0x080c, 0x6bc6, 0x0126, 0x2091, 0x8000, 0x20a9,
+	0x0005, 0x20e1, 0x0001, 0x2099, 0x18a4, 0x400a, 0x2100, 0x9210,
 	0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c, 0x9080,
-	0x0019, 0x2009, 0x0020, 0x012e, 0xaf60, 0x0804, 0x48c6, 0x2091,
+	0x0019, 0x2009, 0x0020, 0x012e, 0xaf60, 0x0804, 0x48e6, 0x2091,
 	0x8000, 0x7837, 0x4000, 0x7833, 0x0010, 0x7883, 0x4000, 0x7887,
 	0x4953, 0x788b, 0x5020, 0x788f, 0x2020, 0x2009, 0x017f, 0x2104,
 	0x7892, 0x3f00, 0x7896, 0x2061, 0x0100, 0x6200, 0x2061, 0x0200,
 	0x603c, 0x8007, 0x9205, 0x789a, 0x2009, 0x04fd, 0x2104, 0x789e,
 	0x2091, 0x5000, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x0180, 0x2001, 0x19f2, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b,
+	0x0180, 0x2001, 0x19fa, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b,
 	0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002, 0x2003,
-	0x1001, 0x2071, 0x0080, 0x0804, 0x0427, 0x81ff, 0x1904, 0x33b0,
-	0x7984, 0x080c, 0x626b, 0x1904, 0x33b3, 0x7e98, 0x9684, 0x3fff,
-	0x9082, 0x4000, 0x1a04, 0x33b3, 0x7c88, 0x7d8c, 0x080c, 0x64a1,
-	0x080c, 0x642e, 0x1518, 0x2061, 0x1ddc, 0x0126, 0x2091, 0x8000,
+	0x1001, 0x2071, 0x0080, 0x0804, 0x0427, 0x81ff, 0x1904, 0x33d0,
+	0x7984, 0x080c, 0x628f, 0x1904, 0x33d3, 0x7e98, 0x9684, 0x3fff,
+	0x9082, 0x4000, 0x1a04, 0x33d3, 0x7c88, 0x7d8c, 0x080c, 0x64c5,
+	0x080c, 0x6452, 0x1518, 0x2061, 0x1ddc, 0x0126, 0x2091, 0x8000,
 	0x6000, 0x9086, 0x0000, 0x0148, 0x6014, 0x904d, 0x0130, 0xa86c,
 	0x9406, 0x1118, 0xa870, 0x9506, 0x0150, 0x012e, 0x9ce0, 0x001c,
-	0x2001, 0x1819, 0x2004, 0x9c02, 0x1a04, 0x33b0, 0x0c30, 0x080c,
-	0xb440, 0x012e, 0x0904, 0x33b0, 0x0804, 0x337e, 0x900e, 0x2001,
-	0x0005, 0x080c, 0x6ba2, 0x0126, 0x2091, 0x8000, 0x080c, 0xbb4b,
-	0x080c, 0x6991, 0x012e, 0x0804, 0x337e, 0x00a6, 0x2950, 0xb198,
-	0x080c, 0x626b, 0x1904, 0x35f7, 0xb6a4, 0x9684, 0x3fff, 0x9082,
-	0x4000, 0x16e8, 0xb49c, 0xb5a0, 0x080c, 0x64a1, 0x080c, 0x644b,
+	0x2001, 0x1819, 0x2004, 0x9c02, 0x1a04, 0x33d0, 0x0c30, 0x080c,
+	0xb45e, 0x012e, 0x0904, 0x33d0, 0x0804, 0x339e, 0x900e, 0x2001,
+	0x0005, 0x080c, 0x6bc6, 0x0126, 0x2091, 0x8000, 0x080c, 0xbb79,
+	0x080c, 0x69b5, 0x012e, 0x0804, 0x339e, 0x00a6, 0x2950, 0xb198,
+	0x080c, 0x628f, 0x1904, 0x3617, 0xb6a4, 0x9684, 0x3fff, 0x9082,
+	0x4000, 0x16e8, 0xb49c, 0xb5a0, 0x080c, 0x64c5, 0x080c, 0x646f,
 	0x1520, 0x2061, 0x1ddc, 0x0126, 0x2091, 0x8000, 0x6000, 0x9086,
 	0x0000, 0x0148, 0x6014, 0x904d, 0x0130, 0xa86c, 0x9406, 0x1118,
 	0xa870, 0x9506, 0x0158, 0x012e, 0x9ce0, 0x001c, 0x2001, 0x1819,
-	0x2004, 0x9c02, 0x2009, 0x000d, 0x12b0, 0x0c28, 0x080c, 0xb440,
+	0x2004, 0x9c02, 0x2009, 0x000d, 0x12b0, 0x0c28, 0x080c, 0xb45e,
 	0x012e, 0x2009, 0x0003, 0x0178, 0x00e0, 0x900e, 0x2001, 0x0005,
-	0x080c, 0x6ba2, 0x0126, 0x2091, 0x8000, 0x080c, 0xbb4b, 0x080c,
-	0x6985, 0x012e, 0x0070, 0xb097, 0x4005, 0xb19a, 0x0010, 0xb097,
+	0x080c, 0x6bc6, 0x0126, 0x2091, 0x8000, 0x080c, 0xbb79, 0x080c,
+	0x69a9, 0x012e, 0x0070, 0xb097, 0x4005, 0xb19a, 0x0010, 0xb097,
 	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x2a48, 0x00ae,
 	0x0005, 0xb097, 0x4000, 0x9006, 0x918d, 0x0001, 0x2008, 0x2a48,
-	0x00ae, 0x0005, 0x81ff, 0x1904, 0x33b0, 0x080c, 0x4891, 0x0904,
-	0x33b3, 0x080c, 0x6332, 0x0904, 0x33b0, 0x080c, 0x64a7, 0x0904,
-	0x33b0, 0x0804, 0x4328, 0x81ff, 0x1904, 0x33b0, 0x080c, 0x48ad,
-	0x0904, 0x33b3, 0x080c, 0x6535, 0x0904, 0x33b0, 0x2019, 0x0005,
-	0x79a8, 0x080c, 0x64c2, 0x0904, 0x33b0, 0x7888, 0x908a, 0x1000,
-	0x1a04, 0x33b3, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x8146,
-	0x7984, 0xd184, 0x1904, 0x337e, 0x0804, 0x4328, 0x0126, 0x2091,
+	0x00ae, 0x0005, 0x81ff, 0x1904, 0x33d0, 0x080c, 0x48b1, 0x0904,
+	0x33d3, 0x080c, 0x6356, 0x0904, 0x33d0, 0x080c, 0x64cb, 0x0904,
+	0x33d0, 0x0804, 0x4348, 0x81ff, 0x1904, 0x33d0, 0x080c, 0x48cd,
+	0x0904, 0x33d3, 0x080c, 0x6559, 0x0904, 0x33d0, 0x2019, 0x0005,
+	0x79a8, 0x080c, 0x64e6, 0x0904, 0x33d0, 0x7888, 0x908a, 0x1000,
+	0x1a04, 0x33d3, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x817a,
+	0x7984, 0xd184, 0x1904, 0x339e, 0x0804, 0x4348, 0x0126, 0x2091,
 	0x8000, 0x81ff, 0x0118, 0x2009, 0x0001, 0x0450, 0x2029, 0x07ff,
-	0x6458, 0x2400, 0x9506, 0x01f8, 0x2508, 0x080c, 0x626b, 0x11d8,
-	0x080c, 0x6535, 0x1128, 0x2009, 0x0002, 0x62bc, 0x2518, 0x00c0,
-	0x2019, 0x0004, 0x900e, 0x080c, 0x64c2, 0x1118, 0x2009, 0x0006,
+	0x6458, 0x2400, 0x9506, 0x01f8, 0x2508, 0x080c, 0x628f, 0x11d8,
+	0x080c, 0x6559, 0x1128, 0x2009, 0x0002, 0x62bc, 0x2518, 0x00c0,
+	0x2019, 0x0004, 0x900e, 0x080c, 0x64e6, 0x1118, 0x2009, 0x0006,
 	0x0078, 0x7884, 0x908a, 0x1000, 0x1270, 0x8003, 0x800b, 0x810b,
-	0x9108, 0x080c, 0x8146, 0x8529, 0x1ae0, 0x012e, 0x0804, 0x337e,
-	0x012e, 0x0804, 0x33b0, 0x012e, 0x0804, 0x33b3, 0x080c, 0x4891,
-	0x0904, 0x33b3, 0x080c, 0x6332, 0x0904, 0x33b0, 0x080c, 0x98bb,
-	0xbaa0, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c, 0x8624, 0x0076,
-	0x903e, 0x080c, 0x8509, 0x900e, 0x080c, 0xcfd9, 0x007e, 0x00ce,
-	0x080c, 0x98d7, 0x080c, 0x64a1, 0x0804, 0x337e, 0x080c, 0x4891,
-	0x0904, 0x33b3, 0x080c, 0x64a1, 0x2208, 0x0804, 0x337e, 0x0156,
-	0x00d6, 0x00e6, 0x00c6, 0x2069, 0x1906, 0x6810, 0x6914, 0x910a,
-	0x1208, 0x900e, 0x6816, 0x9016, 0x901e, 0x2071, 0x19b7, 0x7028,
+	0x9108, 0x080c, 0x817a, 0x8529, 0x1ae0, 0x012e, 0x0804, 0x339e,
+	0x012e, 0x0804, 0x33d0, 0x012e, 0x0804, 0x33d3, 0x080c, 0x48b1,
+	0x0904, 0x33d3, 0x080c, 0x6356, 0x0904, 0x33d0, 0x080c, 0x98c7,
+	0xbaa0, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c, 0x8658, 0x0076,
+	0x903e, 0x080c, 0x853d, 0x900e, 0x080c, 0xd011, 0x007e, 0x00ce,
+	0x080c, 0x98e3, 0x080c, 0x64c5, 0x0804, 0x339e, 0x080c, 0x48b1,
+	0x0904, 0x33d3, 0x080c, 0x64c5, 0x2208, 0x0804, 0x339e, 0x0156,
+	0x00d6, 0x00e6, 0x00c6, 0x2069, 0x190e, 0x6810, 0x6914, 0x910a,
+	0x1208, 0x900e, 0x6816, 0x9016, 0x901e, 0x2071, 0x19bf, 0x7028,
 	0x9065, 0x0118, 0x8210, 0x600c, 0x0cd8, 0x2300, 0x9218, 0x00ce,
-	0x00ee, 0x00de, 0x015e, 0x0804, 0x337e, 0x00f6, 0x0016, 0x907d,
+	0x00ee, 0x00de, 0x015e, 0x0804, 0x339e, 0x00f6, 0x0016, 0x907d,
 	0x0138, 0x9006, 0x8000, 0x2f0c, 0x81ff, 0x0110, 0x2178, 0x0cd0,
-	0x001e, 0x00fe, 0x0005, 0x2069, 0x1906, 0x6910, 0x62b8, 0x0804,
-	0x337e, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x33b0, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x539c, 0x0128, 0x2009, 0x0007, 0x012e,
-	0x0804, 0x33b0, 0x012e, 0x6158, 0x9190, 0x317f, 0x2215, 0x9294,
+	0x001e, 0x00fe, 0x0005, 0x2069, 0x190e, 0x6910, 0x62b8, 0x0804,
+	0x339e, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x33d0, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x53bc, 0x0128, 0x2009, 0x0007, 0x012e,
+	0x0804, 0x33d0, 0x012e, 0x6158, 0x9190, 0x319f, 0x2215, 0x9294,
 	0x00ff, 0x6378, 0x83ff, 0x0108, 0x627c, 0x67d8, 0x97c4, 0x000a,
 	0x98c6, 0x000a, 0x1118, 0x2031, 0x0001, 0x00e8, 0x97c4, 0x0022,
 	0x98c6, 0x0022, 0x1118, 0x2031, 0x0003, 0x00a8, 0x97c4, 0x0012,
-	0x98c6, 0x0012, 0x1118, 0x2031, 0x0002, 0x0068, 0x080c, 0x7096,
+	0x98c6, 0x0012, 0x1118, 0x2031, 0x0002, 0x0068, 0x080c, 0x70ba,
 	0x1118, 0x2031, 0x0004, 0x0038, 0xd79c, 0x0120, 0x2009, 0x0005,
-	0x0804, 0x33b0, 0x9036, 0x7e9a, 0x7f9e, 0x0804, 0x337e, 0x6148,
-	0x624c, 0x2019, 0x1956, 0x231c, 0x2001, 0x1957, 0x2004, 0x789a,
-	0x0804, 0x337e, 0x0126, 0x2091, 0x8000, 0x6138, 0x623c, 0x6340,
-	0x012e, 0x0804, 0x337e, 0x080c, 0x48ad, 0x0904, 0x33b3, 0xba44,
-	0xbb38, 0x0804, 0x337e, 0x080c, 0x0d65, 0x080c, 0x48ad, 0x2110,
-	0x0904, 0x33b3, 0xb804, 0x908c, 0x00ff, 0x918e, 0x0006, 0x0140,
-	0x9084, 0xff00, 0x9086, 0x0600, 0x2009, 0x0009, 0x1904, 0x33b0,
+	0x0804, 0x33d0, 0x9036, 0x7e9a, 0x7f9e, 0x0804, 0x339e, 0x6148,
+	0x624c, 0x2019, 0x195e, 0x231c, 0x2001, 0x195f, 0x2004, 0x789a,
+	0x0804, 0x339e, 0x0126, 0x2091, 0x8000, 0x6138, 0x623c, 0x6340,
+	0x012e, 0x0804, 0x339e, 0x080c, 0x48cd, 0x0904, 0x33d3, 0xba44,
+	0xbb38, 0x0804, 0x339e, 0x080c, 0x0d65, 0x080c, 0x48cd, 0x2110,
+	0x0904, 0x33d3, 0xb804, 0x908c, 0x00ff, 0x918e, 0x0006, 0x0140,
+	0x9084, 0xff00, 0x9086, 0x0600, 0x2009, 0x0009, 0x1904, 0x33d0,
 	0x0126, 0x2091, 0x8000, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c,
-	0x98bb, 0x080c, 0x94dd, 0x080c, 0x8624, 0x0076, 0x903e, 0x080c,
-	0x8509, 0x900e, 0x080c, 0xcfd9, 0x007e, 0x00ce, 0x080c, 0x98d7,
-	0xb807, 0x0407, 0x012e, 0x0804, 0x337e, 0x6148, 0x624c, 0x7884,
-	0x604a, 0x7b88, 0x634e, 0x2069, 0x1853, 0x831f, 0x9305, 0x6816,
-	0x788c, 0x2069, 0x1956, 0x2d1c, 0x206a, 0x7e98, 0x9682, 0x0014,
-	0x1210, 0x2031, 0x07d0, 0x2069, 0x1957, 0x2d04, 0x266a, 0x789a,
-	0x0804, 0x337e, 0x0126, 0x2091, 0x8000, 0x6138, 0x7884, 0x603a,
-	0x910e, 0xd1b4, 0x190c, 0x0eb4, 0xd0c4, 0x01a8, 0x00d6, 0x78a8,
-	0x2009, 0x196d, 0x200a, 0x78ac, 0x2011, 0x196e, 0x2012, 0x2069,
+	0x98c7, 0x080c, 0x94e5, 0x080c, 0x8658, 0x0076, 0x903e, 0x080c,
+	0x853d, 0x900e, 0x080c, 0xd011, 0x007e, 0x00ce, 0x080c, 0x98e3,
+	0xb807, 0x0407, 0x012e, 0x0804, 0x339e, 0x6148, 0x624c, 0x7884,
+	0x604a, 0x7b88, 0x634e, 0x2069, 0x185b, 0x831f, 0x9305, 0x6816,
+	0x788c, 0x2069, 0x195e, 0x2d1c, 0x206a, 0x7e98, 0x9682, 0x0014,
+	0x1210, 0x2031, 0x07d0, 0x2069, 0x195f, 0x2d04, 0x266a, 0x789a,
+	0x0804, 0x339e, 0x0126, 0x2091, 0x8000, 0x6138, 0x7884, 0x603a,
+	0x910e, 0xd1b4, 0x190c, 0x0ec1, 0xd0c4, 0x01a8, 0x00d6, 0x78a8,
+	0x2009, 0x1975, 0x200a, 0x78ac, 0x2011, 0x1976, 0x2012, 0x2069,
 	0x0100, 0x6838, 0x9086, 0x0007, 0x1118, 0x2214, 0x6a5a, 0x0010,
 	0x210c, 0x695a, 0x00de, 0x7888, 0x603e, 0x2011, 0x0116, 0x220c,
 	0x7888, 0xd08c, 0x0118, 0x918d, 0x0040, 0x0010, 0x918c, 0xff7f,
-	0x2112, 0x6140, 0x788c, 0x6042, 0x910e, 0xd1e4, 0x190c, 0x0ecf,
+	0x2112, 0x6140, 0x788c, 0x6042, 0x910e, 0xd1e4, 0x190c, 0x0edc,
 	0x6040, 0xd0cc, 0x0120, 0x78b0, 0x2011, 0x0114, 0x2012, 0x012e,
-	0x0804, 0x337e, 0x00f6, 0x2079, 0x1800, 0x7a38, 0xa898, 0x9084,
+	0x0804, 0x339e, 0x00f6, 0x2079, 0x1800, 0x7a38, 0xa898, 0x9084,
 	0xfebf, 0x9215, 0xa89c, 0x9084, 0xfebf, 0x8002, 0x9214, 0x7838,
 	0x9084, 0x0140, 0x9215, 0x7a3a, 0xa897, 0x4000, 0x900e, 0x9085,
 	0x0001, 0x2001, 0x0000, 0x00fe, 0x0005, 0x7898, 0x9005, 0x01a8,
-	0x7888, 0x9025, 0x0904, 0x33b3, 0x788c, 0x902d, 0x0904, 0x33b3,
-	0x900e, 0x080c, 0x626b, 0x1120, 0xba44, 0xbb38, 0xbc46, 0xbd3a,
-	0x9186, 0x07ff, 0x0190, 0x8108, 0x0ca0, 0x080c, 0x48ad, 0x0904,
-	0x33b3, 0x7888, 0x900d, 0x0904, 0x33b3, 0x788c, 0x9005, 0x0904,
-	0x33b3, 0xba44, 0xb946, 0xbb38, 0xb83a, 0x0804, 0x337e, 0x2011,
-	0xbc09, 0x0010, 0x2011, 0xbc05, 0x080c, 0x539c, 0x1904, 0x33b0,
+	0x7888, 0x9025, 0x0904, 0x33d3, 0x788c, 0x902d, 0x0904, 0x33d3,
+	0x900e, 0x080c, 0x628f, 0x1120, 0xba44, 0xbb38, 0xbc46, 0xbd3a,
+	0x9186, 0x07ff, 0x0190, 0x8108, 0x0ca0, 0x080c, 0x48cd, 0x0904,
+	0x33d3, 0x7888, 0x900d, 0x0904, 0x33d3, 0x788c, 0x9005, 0x0904,
+	0x33d3, 0xba44, 0xb946, 0xbb38, 0xb83a, 0x0804, 0x339e, 0x2011,
+	0xbc09, 0x0010, 0x2011, 0xbc05, 0x080c, 0x53bc, 0x1904, 0x33d0,
 	0x00c6, 0x2061, 0x0100, 0x7984, 0x9186, 0x00ff, 0x1130, 0x2001,
 	0x1817, 0x2004, 0x9085, 0xff00, 0x0088, 0x9182, 0x007f, 0x16e0,
-	0x9188, 0x317f, 0x210d, 0x918c, 0x00ff, 0x2001, 0x1817, 0x2004,
+	0x9188, 0x319f, 0x210d, 0x918c, 0x00ff, 0x2001, 0x1817, 0x2004,
 	0x0026, 0x9116, 0x002e, 0x0580, 0x810f, 0x9105, 0x0126, 0x2091,
-	0x8000, 0x0006, 0x080c, 0x9b84, 0x000e, 0x0510, 0x602e, 0x620a,
-	0x7984, 0x00b6, 0x080c, 0x6211, 0x2b08, 0x00be, 0x1500, 0x6112,
-	0x6023, 0x0001, 0x080c, 0x487a, 0x01d0, 0x9006, 0xa866, 0x7007,
-	0x0003, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x701f, 0x3862, 0x2900,
-	0x6016, 0x2009, 0x0032, 0x080c, 0x9c76, 0x012e, 0x00ce, 0x0005,
-	0x012e, 0x00ce, 0x0804, 0x33b0, 0x00ce, 0x0804, 0x33b3, 0x080c,
-	0x9bda, 0x0cb0, 0xa830, 0x9086, 0x0100, 0x0904, 0x33b0, 0x0804,
-	0x337e, 0x2061, 0x1a3e, 0x0126, 0x2091, 0x8000, 0x6000, 0xd084,
+	0x8000, 0x0006, 0x080c, 0x9b90, 0x000e, 0x0510, 0x602e, 0x620a,
+	0x7984, 0x00b6, 0x080c, 0x6235, 0x2b08, 0x00be, 0x1500, 0x6112,
+	0x6023, 0x0001, 0x080c, 0x489a, 0x01d0, 0x9006, 0xa866, 0x7007,
+	0x0003, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x701f, 0x3882, 0x2900,
+	0x6016, 0x2009, 0x0032, 0x080c, 0x9c82, 0x012e, 0x00ce, 0x0005,
+	0x012e, 0x00ce, 0x0804, 0x33d0, 0x00ce, 0x0804, 0x33d3, 0x080c,
+	0x9be6, 0x0cb0, 0xa830, 0x9086, 0x0100, 0x0904, 0x33d0, 0x0804,
+	0x339e, 0x2061, 0x1a46, 0x0126, 0x2091, 0x8000, 0x6000, 0xd084,
 	0x0170, 0x6104, 0x6208, 0x2061, 0x1800, 0x6350, 0x6070, 0x789a,
-	0x60bc, 0x789e, 0x60b8, 0x78aa, 0x012e, 0x0804, 0x337e, 0x900e,
-	0x2110, 0x0c88, 0x81ff, 0x1904, 0x33b0, 0x080c, 0x7096, 0x0904,
-	0x33b0, 0x0126, 0x2091, 0x8000, 0x6250, 0x6070, 0x9202, 0x0248,
-	0x9085, 0x0001, 0x080c, 0x24a6, 0x080c, 0x55b6, 0x012e, 0x0804,
-	0x337e, 0x012e, 0x0804, 0x33b3, 0x0006, 0x0016, 0x00c6, 0x00e6,
-	0x2001, 0x1979, 0x2070, 0x2061, 0x1853, 0x6008, 0x2072, 0x900e,
-	0x2011, 0x1400, 0x080c, 0x83fb, 0x7206, 0x00ee, 0x00ce, 0x001e,
+	0x60bc, 0x789e, 0x60b8, 0x78aa, 0x012e, 0x0804, 0x339e, 0x900e,
+	0x2110, 0x0c88, 0x81ff, 0x1904, 0x33d0, 0x080c, 0x70ba, 0x0904,
+	0x33d0, 0x0126, 0x2091, 0x8000, 0x6250, 0x6070, 0x9202, 0x0248,
+	0x9085, 0x0001, 0x080c, 0x24c2, 0x080c, 0x55d6, 0x012e, 0x0804,
+	0x339e, 0x012e, 0x0804, 0x33d3, 0x0006, 0x0016, 0x00c6, 0x00e6,
+	0x2001, 0x1981, 0x2070, 0x2061, 0x185b, 0x6008, 0x2072, 0x900e,
+	0x2011, 0x1400, 0x080c, 0x842f, 0x7206, 0x00ee, 0x00ce, 0x001e,
 	0x000e, 0x0005, 0x0126, 0x2091, 0x8000, 0x81ff, 0x0128, 0x012e,
-	0x2021, 0x400b, 0x0804, 0x3380, 0x7884, 0xd0fc, 0x0148, 0x2001,
-	0x002a, 0x2004, 0x9082, 0x00e1, 0x0288, 0x012e, 0x0804, 0x33b3,
-	0x2001, 0x002a, 0x2004, 0x2069, 0x1853, 0x6908, 0x9102, 0x1230,
-	0x012e, 0x0804, 0x33b3, 0x012e, 0x0804, 0x33b0, 0x080c, 0x9b59,
-	0x0dd0, 0x7884, 0xd0fc, 0x0904, 0x392d, 0x00c6, 0x080c, 0x487a,
+	0x2021, 0x400b, 0x0804, 0x33a0, 0x7884, 0xd0fc, 0x0148, 0x2001,
+	0x002a, 0x2004, 0x9082, 0x00e1, 0x0288, 0x012e, 0x0804, 0x33d3,
+	0x2001, 0x002a, 0x2004, 0x2069, 0x185b, 0x6908, 0x9102, 0x1230,
+	0x012e, 0x0804, 0x33d3, 0x012e, 0x0804, 0x33d0, 0x080c, 0x9b65,
+	0x0dd0, 0x7884, 0xd0fc, 0x0904, 0x394d, 0x00c6, 0x080c, 0x489a,
 	0x00ce, 0x0d88, 0xa867, 0x0000, 0x7884, 0xa80a, 0x7898, 0xa80e,
 	0x789c, 0xa812, 0x2001, 0x002e, 0x2004, 0xa81a, 0x2001, 0x002f,
 	0x2004, 0xa81e, 0x2001, 0x0030, 0x2004, 0xa822, 0x2001, 0x0031,
 	0x2004, 0xa826, 0x2001, 0x0034, 0x2004, 0xa82a, 0x2001, 0x0035,
 	0x2004, 0xa82e, 0x2001, 0x002a, 0x2004, 0x9080, 0x0003, 0x9084,
-	0x00fc, 0x8004, 0xa816, 0x080c, 0x3ab7, 0x0928, 0x7014, 0x2048,
+	0x00fc, 0x8004, 0xa816, 0x080c, 0x3ad7, 0x0928, 0x7014, 0x2048,
 	0xad2c, 0xac28, 0xab1c, 0xaa18, 0xa930, 0xa808, 0xd0b4, 0x1120,
 	0x2029, 0x0000, 0x2021, 0x0000, 0x8906, 0x8006, 0x8007, 0x90bc,
-	0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x080c, 0x48c3, 0x701f,
-	0x39f4, 0x7023, 0x0001, 0x012e, 0x0005, 0x080c, 0x98bb, 0x0046,
+	0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x080c, 0x48e3, 0x701f,
+	0x3a14, 0x7023, 0x0001, 0x012e, 0x0005, 0x080c, 0x98c7, 0x0046,
 	0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
-	0x080c, 0x389c, 0x2001, 0x196f, 0x2003, 0x0000, 0x2021, 0x000a,
+	0x080c, 0x38bc, 0x2001, 0x1977, 0x2003, 0x0000, 0x2021, 0x000a,
 	0x2061, 0x0100, 0x6104, 0x0016, 0x60bb, 0x0000, 0x60bf, 0x32e1,
-	0x60bf, 0x0012, 0x080c, 0x3b26, 0x080c, 0x3ae5, 0x00f6, 0x00e6,
-	0x0086, 0x2940, 0x2071, 0x19b7, 0x2079, 0x0090, 0x00d6, 0x2069,
+	0x60bf, 0x0012, 0x080c, 0x3b46, 0x080c, 0x3b05, 0x00f6, 0x00e6,
+	0x0086, 0x2940, 0x2071, 0x19bf, 0x2079, 0x0090, 0x00d6, 0x2069,
 	0x0000, 0x6884, 0xd0b4, 0x0140, 0x2001, 0x0035, 0x2004, 0x780e,
 	0x2001, 0x0034, 0x2004, 0x780a, 0x00de, 0x2011, 0x0001, 0x080c,
-	0x3e97, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3dc4, 0x080c, 0x3cf1,
+	0x3eb7, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3de4, 0x080c, 0x3d11,
 	0x05b8, 0x2001, 0x020b, 0x2004, 0x9084, 0x0140, 0x1db8, 0x080c,
-	0x3f0b, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe, 0x908c, 0x0070,
+	0x3f2b, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe, 0x908c, 0x0070,
 	0x1560, 0x2071, 0x0200, 0x7037, 0x0000, 0x7050, 0x9084, 0xff00,
 	0x9086, 0x3200, 0x1510, 0x7037, 0x0001, 0x7050, 0x9084, 0xff00,
 	0x9086, 0xe100, 0x11d0, 0x7037, 0x0000, 0x7054, 0x7037, 0x0000,
 	0x715c, 0x9106, 0x1190, 0x2001, 0x181f, 0x2004, 0x9106, 0x1168,
 	0x00c6, 0x2061, 0x0100, 0x6024, 0x9084, 0x1e00, 0x00ce, 0x0138,
-	0x080c, 0x3cfb, 0x080c, 0x3ae0, 0x0058, 0x080c, 0x3ae0, 0x080c,
-	0x3e2f, 0x080c, 0x3dba, 0x2001, 0x020b, 0x2004, 0xd0e4, 0x0dd8,
+	0x080c, 0x3d1b, 0x080c, 0x3b00, 0x0058, 0x080c, 0x3b00, 0x080c,
+	0x3e4f, 0x080c, 0x3dda, 0x2001, 0x020b, 0x2004, 0xd0e4, 0x0dd8,
 	0x2001, 0x032a, 0x2003, 0x0004, 0x2061, 0x0100, 0x6027, 0x0002,
 	0x001e, 0x6106, 0x2011, 0x020d, 0x2013, 0x0020, 0x60bb, 0x0000,
 	0x60bf, 0x0108, 0x60bf, 0x0012, 0x2001, 0x0004, 0x200c, 0x918c,
-	0xfffd, 0x2102, 0x080c, 0x12e1, 0x2009, 0x0028, 0x080c, 0x2063,
-	0x2001, 0x0227, 0x200c, 0x2102, 0x080c, 0x98d7, 0x00fe, 0x00ee,
+	0xfffd, 0x2102, 0x080c, 0x12ee, 0x2009, 0x0028, 0x080c, 0x207b,
+	0x2001, 0x0227, 0x200c, 0x2102, 0x080c, 0x98e3, 0x00fe, 0x00ee,
 	0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e, 0x004e, 0x2001,
-	0x196f, 0x2004, 0x9005, 0x1118, 0x012e, 0x0804, 0x337e, 0x012e,
-	0x2021, 0x400c, 0x0804, 0x3380, 0x0016, 0x0026, 0x0036, 0x0046,
+	0x1977, 0x2004, 0x9005, 0x1118, 0x012e, 0x0804, 0x339e, 0x012e,
+	0x2021, 0x400c, 0x0804, 0x33a0, 0x0016, 0x0026, 0x0036, 0x0046,
 	0x0056, 0x0076, 0x0086, 0x0096, 0x00d6, 0x0156, 0x7014, 0x2048,
-	0x7020, 0x20a8, 0x8000, 0x7022, 0xa804, 0x9005, 0x0904, 0x3a50,
-	0x2048, 0x1f04, 0x3a04, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494,
+	0x7020, 0x20a8, 0x8000, 0x7022, 0xa804, 0x9005, 0x0904, 0x3a70,
+	0x2048, 0x1f04, 0x3a24, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494,
 	0xa598, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021,
 	0x0000, 0x0096, 0x7014, 0x2048, 0xa864, 0x009e, 0x9086, 0x0103,
 	0x0170, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
-	0x9080, 0x001b, 0x080c, 0x48c3, 0x701f, 0x39f4, 0x00b0, 0x8906,
+	0x9080, 0x001b, 0x080c, 0x48e3, 0x701f, 0x3a14, 0x00b0, 0x8906,
 	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b,
-	0x21a8, 0x27e0, 0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c, 0x0f9f,
-	0x000e, 0x080c, 0x48c6, 0x701f, 0x39f4, 0x015e, 0x00de, 0x009e,
+	0x21a8, 0x27e0, 0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c, 0x0fac,
+	0x000e, 0x080c, 0x48e6, 0x701f, 0x3a14, 0x015e, 0x00de, 0x009e,
 	0x008e, 0x007e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005,
-	0x7014, 0x2048, 0xa864, 0x9086, 0x0103, 0x1118, 0x701f, 0x3ab5,
+	0x7014, 0x2048, 0xa864, 0x9086, 0x0103, 0x1118, 0x701f, 0x3ad5,
 	0x0450, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a, 0x2009, 0x007f,
-	0x080c, 0x620b, 0x0110, 0x9006, 0x0030, 0xb813, 0x00ff, 0xb817,
-	0xfffd, 0x080c, 0xbd2a, 0x015e, 0x00de, 0x009e, 0x008e, 0x007e,
-	0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0904, 0x33b0, 0x0016,
+	0x080c, 0x622f, 0x0110, 0x9006, 0x0030, 0xb813, 0x00ff, 0xb817,
+	0xfffd, 0x080c, 0xbd58, 0x015e, 0x00de, 0x009e, 0x008e, 0x007e,
+	0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0904, 0x33d0, 0x0016,
 	0x0026, 0x0036, 0x0046, 0x0056, 0x0076, 0x0086, 0x0096, 0x00d6,
-	0x0156, 0x701f, 0x3a87, 0x7007, 0x0003, 0x0804, 0x3a45, 0xa830,
-	0x9086, 0x0100, 0x2021, 0x400c, 0x0904, 0x3380, 0x0076, 0xad10,
+	0x0156, 0x701f, 0x3aa7, 0x7007, 0x0003, 0x0804, 0x3a65, 0xa830,
+	0x9086, 0x0100, 0x2021, 0x400c, 0x0904, 0x33a0, 0x0076, 0xad10,
 	0xac0c, 0xab24, 0xaa20, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029,
 	0x0000, 0x2021, 0x0000, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
 	0x9084, 0xffc0, 0x9080, 0x001b, 0x21a8, 0x27e0, 0x2098, 0x27e8,
-	0x20a0, 0x0006, 0x080c, 0x0f9f, 0x000e, 0x080c, 0x48c6, 0x007e,
-	0x701f, 0x39f4, 0x7023, 0x0001, 0x0005, 0x0804, 0x337e, 0x0156,
+	0x20a0, 0x0006, 0x080c, 0x0fac, 0x000e, 0x080c, 0x48e6, 0x007e,
+	0x701f, 0x3a14, 0x7023, 0x0001, 0x0005, 0x0804, 0x339e, 0x0156,
 	0x00c6, 0xa814, 0x908a, 0x001e, 0x0218, 0xa833, 0x001e, 0x0010,
-	0xa832, 0x0078, 0x81ff, 0x0168, 0x0016, 0x080c, 0x487a, 0x001e,
+	0xa832, 0x0078, 0x81ff, 0x0168, 0x0016, 0x080c, 0x489a, 0x001e,
 	0x0130, 0xa800, 0x2040, 0xa008, 0xa80a, 0x2100, 0x0c58, 0x9006,
 	0x0010, 0x9085, 0x0001, 0x00ce, 0x015e, 0x0005, 0x0006, 0x00f6,
 	0x2079, 0x0000, 0x7880, 0x9086, 0x0044, 0x00fe, 0x000e, 0x0005,
-	0x2001, 0x196f, 0x2003, 0x0001, 0x0005, 0x00f6, 0x00e6, 0x00c6,
-	0x2061, 0x0200, 0x2001, 0x197a, 0x2004, 0x601a, 0x2061, 0x0100,
-	0x2001, 0x1979, 0x2004, 0x60ce, 0x6104, 0xc1ac, 0x6106, 0x080c,
-	0x487a, 0xa813, 0x0019, 0xa817, 0x0001, 0x2900, 0xa85a, 0x2001,
+	0x2001, 0x1977, 0x2003, 0x0001, 0x0005, 0x00f6, 0x00e6, 0x00c6,
+	0x2061, 0x0200, 0x2001, 0x1982, 0x2004, 0x601a, 0x2061, 0x0100,
+	0x2001, 0x1981, 0x2004, 0x60ce, 0x6104, 0xc1ac, 0x6106, 0x080c,
+	0x489a, 0xa813, 0x0019, 0xa817, 0x0001, 0x2900, 0xa85a, 0x2001,
 	0x002e, 0x2004, 0xa866, 0x2001, 0x002f, 0x2004, 0xa86a, 0x2061,
-	0x0090, 0x2079, 0x0100, 0x2001, 0x1979, 0x2004, 0x6036, 0x2009,
-	0x0040, 0x080c, 0x2063, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8,
+	0x0090, 0x2079, 0x0100, 0x2001, 0x1981, 0x2004, 0x6036, 0x2009,
+	0x0040, 0x080c, 0x207b, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8,
 	0xa86e, 0x601a, 0xa873, 0x0000, 0x601f, 0x0000, 0x78ca, 0x9006,
 	0x600a, 0x600e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00e6, 0x080c,
-	0x487a, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001, 0x2800, 0xa05a,
+	0x489a, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001, 0x2800, 0xa05a,
 	0x2001, 0x0030, 0x2004, 0xa866, 0x2001, 0x0031, 0x2004, 0xa86a,
 	0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e, 0xa873, 0x0000,
 	0x2001, 0x032a, 0x2003, 0x0004, 0x2001, 0x0300, 0x2003, 0x0000,
 	0x2001, 0x020d, 0x2003, 0x0000, 0x2001, 0x0004, 0x200c, 0x918d,
 	0x0002, 0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x81ff,
-	0x0148, 0x080c, 0x2830, 0x1130, 0x9006, 0x080c, 0x2787, 0x9006,
-	0x080c, 0x276a, 0x7884, 0x9084, 0x0007, 0x0002, 0x3b71, 0x3b7a,
-	0x3b83, 0x3b6e, 0x3b6e, 0x3b6e, 0x3b6e, 0x3b6e, 0x012e, 0x0804,
-	0x33b3, 0x2009, 0x0114, 0x2104, 0x9085, 0x0800, 0x200a, 0x080c,
-	0x3d45, 0x00c0, 0x2009, 0x0114, 0x2104, 0x9085, 0x4000, 0x200a,
-	0x080c, 0x3d45, 0x0078, 0x080c, 0x7096, 0x1128, 0x012e, 0x2009,
-	0x0016, 0x0804, 0x33b0, 0x81ff, 0x0128, 0x012e, 0x2021, 0x400b,
-	0x0804, 0x3380, 0x080c, 0x98bb, 0x0086, 0x0096, 0x00a6, 0x00b6,
-	0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x080c, 0x389c, 0x2009, 0x0101,
+	0x0148, 0x080c, 0x2850, 0x1130, 0x9006, 0x080c, 0x27a3, 0x9006,
+	0x080c, 0x2786, 0x7884, 0x9084, 0x0007, 0x0002, 0x3b91, 0x3b9a,
+	0x3ba3, 0x3b8e, 0x3b8e, 0x3b8e, 0x3b8e, 0x3b8e, 0x012e, 0x0804,
+	0x33d3, 0x2009, 0x0114, 0x2104, 0x9085, 0x0800, 0x200a, 0x080c,
+	0x3d65, 0x00c0, 0x2009, 0x0114, 0x2104, 0x9085, 0x4000, 0x200a,
+	0x080c, 0x3d65, 0x0078, 0x080c, 0x70ba, 0x1128, 0x012e, 0x2009,
+	0x0016, 0x0804, 0x33d0, 0x81ff, 0x0128, 0x012e, 0x2021, 0x400b,
+	0x0804, 0x33a0, 0x080c, 0x98c7, 0x0086, 0x0096, 0x00a6, 0x00b6,
+	0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x080c, 0x38bc, 0x2009, 0x0101,
 	0x210c, 0x0016, 0x7ec8, 0x7dcc, 0x9006, 0x2068, 0x2060, 0x2058,
-	0x080c, 0x3fe6, 0x080c, 0x3f36, 0x903e, 0x2720, 0x00f6, 0x00e6,
-	0x0086, 0x2940, 0x2071, 0x19b7, 0x2079, 0x0090, 0x00d6, 0x2069,
+	0x080c, 0x4006, 0x080c, 0x3f56, 0x903e, 0x2720, 0x00f6, 0x00e6,
+	0x0086, 0x2940, 0x2071, 0x19bf, 0x2079, 0x0090, 0x00d6, 0x2069,
 	0x0000, 0x6884, 0xd0b4, 0x0120, 0x68d4, 0x780e, 0x68d0, 0x780a,
-	0x00de, 0x2011, 0x0001, 0x080c, 0x3e97, 0x080c, 0x2838, 0x080c,
-	0x2838, 0x080c, 0x2838, 0x080c, 0x2838, 0x080c, 0x3e97, 0x008e,
-	0x00ee, 0x00fe, 0x080c, 0x3dc4, 0x2009, 0x9c40, 0x8109, 0x11b0,
-	0x080c, 0x3cfb, 0x2001, 0x0004, 0x200c, 0x918c, 0xfffd, 0x2102,
+	0x00de, 0x2011, 0x0001, 0x080c, 0x3eb7, 0x080c, 0x2858, 0x080c,
+	0x2858, 0x080c, 0x2858, 0x080c, 0x2858, 0x080c, 0x3eb7, 0x008e,
+	0x00ee, 0x00fe, 0x080c, 0x3de4, 0x2009, 0x9c40, 0x8109, 0x11b0,
+	0x080c, 0x3d1b, 0x2001, 0x0004, 0x200c, 0x918c, 0xfffd, 0x2102,
 	0x001e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e,
-	0x008e, 0x2009, 0x0017, 0x080c, 0x33b0, 0x0cf8, 0x2001, 0x020b,
+	0x008e, 0x2009, 0x0017, 0x080c, 0x33d0, 0x0cf8, 0x2001, 0x020b,
 	0x2004, 0x9084, 0x0140, 0x1d10, 0x00f6, 0x2079, 0x0000, 0x7884,
 	0x00fe, 0xd0bc, 0x0178, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0150,
-	0x080c, 0x3da2, 0x2d00, 0x9c05, 0x9b05, 0x0120, 0x080c, 0x3cfb,
-	0x0804, 0x3ca4, 0x080c, 0x3f0b, 0x080c, 0x3e2f, 0x080c, 0x3d85,
-	0x080c, 0x3dba, 0x00f6, 0x2079, 0x0100, 0x7824, 0xd0ac, 0x0130,
-	0x8b58, 0x080c, 0x3cfb, 0x00fe, 0x0804, 0x3ca4, 0x00fe, 0x080c,
-	0x3cf1, 0x1150, 0x8d68, 0x2001, 0x0032, 0x2602, 0x2001, 0x0033,
-	0x2502, 0x080c, 0x3cfb, 0x0080, 0x87ff, 0x0138, 0x2001, 0x0201,
-	0x2004, 0x9005, 0x1908, 0x8739, 0x0038, 0x2001, 0x1a3b, 0x2004,
-	0x9086, 0x0000, 0x1904, 0x3bf4, 0x2001, 0x032f, 0x2003, 0x00f6,
-	0x8631, 0x1208, 0x8529, 0x2500, 0x9605, 0x0904, 0x3ca4, 0x7884,
-	0xd0bc, 0x0128, 0x2d00, 0x9c05, 0x9b05, 0x1904, 0x3ca4, 0xa013,
+	0x080c, 0x3dc2, 0x2d00, 0x9c05, 0x9b05, 0x0120, 0x080c, 0x3d1b,
+	0x0804, 0x3cc4, 0x080c, 0x3f2b, 0x080c, 0x3e4f, 0x080c, 0x3da5,
+	0x080c, 0x3dda, 0x00f6, 0x2079, 0x0100, 0x7824, 0xd0ac, 0x0130,
+	0x8b58, 0x080c, 0x3d1b, 0x00fe, 0x0804, 0x3cc4, 0x00fe, 0x080c,
+	0x3d11, 0x1150, 0x8d68, 0x2001, 0x0032, 0x2602, 0x2001, 0x0033,
+	0x2502, 0x080c, 0x3d1b, 0x0080, 0x87ff, 0x0138, 0x2001, 0x0201,
+	0x2004, 0x9005, 0x1908, 0x8739, 0x0038, 0x2001, 0x1a43, 0x2004,
+	0x9086, 0x0000, 0x1904, 0x3c14, 0x2001, 0x032f, 0x2003, 0x00f6,
+	0x8631, 0x1208, 0x8529, 0x2500, 0x9605, 0x0904, 0x3cc4, 0x7884,
+	0xd0bc, 0x0128, 0x2d00, 0x9c05, 0x9b05, 0x1904, 0x3cc4, 0xa013,
 	0x0019, 0x2001, 0x032a, 0x2003, 0x0004, 0x7884, 0xd0ac, 0x1148,
-	0x2001, 0x1a3b, 0x2003, 0x0003, 0x2001, 0x032a, 0x2003, 0x0009,
+	0x2001, 0x1a43, 0x2003, 0x0003, 0x2001, 0x032a, 0x2003, 0x0009,
 	0x0030, 0xa017, 0x0001, 0x78b4, 0x9005, 0x0108, 0xa016, 0x2800,
-	0xa05a, 0x2009, 0x0040, 0x080c, 0x2063, 0x2900, 0xa85a, 0xa813,
+	0xa05a, 0x2009, 0x0040, 0x080c, 0x207b, 0x2900, 0xa85a, 0xa813,
 	0x0019, 0x7884, 0xd0a4, 0x1180, 0xa817, 0x0000, 0x00c6, 0x20a9,
 	0x0004, 0x2061, 0x0090, 0x602b, 0x0008, 0x2001, 0x0203, 0x2004,
-	0x1f04, 0x3c7b, 0x00ce, 0x0030, 0xa817, 0x0001, 0x78b0, 0x9005,
+	0x1f04, 0x3c9b, 0x00ce, 0x0030, 0xa817, 0x0001, 0x78b0, 0x9005,
 	0x0108, 0xa816, 0x00f6, 0x00c6, 0x2079, 0x0100, 0x2061, 0x0090,
 	0x7827, 0x0002, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a,
 	0x0006, 0x2001, 0x002b, 0x2004, 0x601e, 0x78c6, 0x000e, 0x78ca,
-	0x00ce, 0x00fe, 0x0804, 0x3bae, 0x001e, 0x00c6, 0x2001, 0x032a,
+	0x00ce, 0x00fe, 0x0804, 0x3bce, 0x001e, 0x00c6, 0x2001, 0x032a,
 	0x2003, 0x0004, 0x2061, 0x0100, 0x6027, 0x0002, 0x6106, 0x2011,
 	0x020d, 0x2013, 0x0020, 0x2001, 0x0004, 0x200c, 0x918c, 0xfffd,
-	0x2102, 0x080c, 0x12e1, 0x7884, 0x9084, 0x0003, 0x9086, 0x0002,
-	0x01b0, 0x2009, 0x0028, 0x080c, 0x2063, 0x2001, 0x0227, 0x200c,
-	0x2102, 0x6050, 0x9084, 0xb7ff, 0x080c, 0x28e2, 0x6052, 0x602f,
+	0x2102, 0x080c, 0x12ee, 0x7884, 0x9084, 0x0003, 0x9086, 0x0002,
+	0x01b0, 0x2009, 0x0028, 0x080c, 0x207b, 0x2001, 0x0227, 0x200c,
+	0x2102, 0x6050, 0x9084, 0xb7ff, 0x080c, 0x2902, 0x6052, 0x602f,
 	0x0000, 0x604b, 0xf7f7, 0x6043, 0x0090, 0x6043, 0x0010, 0x080c,
-	0x98d7, 0x00ce, 0x2d08, 0x2c10, 0x2b18, 0x2b00, 0x9c05, 0x9d05,
+	0x98e3, 0x00ce, 0x2d08, 0x2c10, 0x2b18, 0x2b00, 0x9c05, 0x9d05,
 	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e,
-	0x1118, 0x012e, 0x0804, 0x337e, 0x012e, 0x2021, 0x400c, 0x0804,
-	0x3380, 0x9085, 0x0001, 0x1d04, 0x3cfa, 0x2091, 0x6000, 0x8420,
+	0x1118, 0x012e, 0x0804, 0x339e, 0x012e, 0x2021, 0x400c, 0x0804,
+	0x33a0, 0x9085, 0x0001, 0x1d04, 0x3d1a, 0x2091, 0x6000, 0x8420,
 	0x9486, 0x0064, 0x0005, 0x2001, 0x0105, 0x2003, 0x0010, 0x2001,
-	0x032a, 0x2003, 0x0004, 0x2001, 0x1a3b, 0x2003, 0x0000, 0x0071,
-	0x2009, 0x0048, 0x080c, 0x2063, 0x2001, 0x0227, 0x2024, 0x2402,
+	0x032a, 0x2003, 0x0004, 0x2001, 0x1a43, 0x2003, 0x0000, 0x0071,
+	0x2009, 0x0048, 0x080c, 0x207b, 0x2001, 0x0227, 0x2024, 0x2402,
 	0x2001, 0x0109, 0x2003, 0x4000, 0x9026, 0x0005, 0x00f6, 0x00e6,
-	0x2071, 0x19b7, 0x7054, 0x9086, 0x0000, 0x0520, 0x2079, 0x0090,
+	0x2071, 0x19bf, 0x7054, 0x9086, 0x0000, 0x0520, 0x2079, 0x0090,
 	0x2009, 0x0206, 0x2104, 0x2009, 0x0203, 0x210c, 0x9106, 0x1120,
-	0x2009, 0x0040, 0x080c, 0x2063, 0x782c, 0xd0fc, 0x0d88, 0x080c,
-	0x3f0b, 0x7054, 0x9086, 0x0000, 0x1d58, 0x782b, 0x0004, 0x782c,
-	0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x2063, 0x782b, 0x0002,
+	0x2009, 0x0040, 0x080c, 0x207b, 0x782c, 0xd0fc, 0x0d88, 0x080c,
+	0x3f2b, 0x7054, 0x9086, 0x0000, 0x1d58, 0x782b, 0x0004, 0x782c,
+	0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x207b, 0x782b, 0x0002,
 	0x7057, 0x0000, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0100,
-	0x2001, 0x1817, 0x200c, 0x7932, 0x7936, 0x080c, 0x2486, 0x080c,
-	0x28af, 0x080c, 0x28e2, 0x784b, 0xf7f7, 0x7843, 0x0090, 0x7843,
+	0x2001, 0x1817, 0x200c, 0x7932, 0x7936, 0x080c, 0x24a2, 0x080c,
+	0x28cf, 0x080c, 0x2902, 0x784b, 0xf7f7, 0x7843, 0x0090, 0x7843,
 	0x0010, 0x7850, 0xc0e5, 0x7852, 0x2019, 0x61a8, 0x7820, 0xd09c,
 	0x0110, 0x8319, 0x1dd8, 0x7850, 0xc0e4, 0x7852, 0x2011, 0x0048,
-	0x080c, 0x288c, 0x7843, 0x0040, 0x2019, 0x01f4, 0xa001, 0xa001,
-	0x8319, 0x1de0, 0x2001, 0x0100, 0x080c, 0x2852, 0x2011, 0x0020,
-	0x080c, 0x288c, 0x7843, 0x0000, 0x9006, 0x080c, 0x2852, 0x2011,
-	0x0048, 0x080c, 0x288c, 0x00fe, 0x0005, 0x7884, 0xd0ac, 0x11c8,
-	0x00f6, 0x00e6, 0x2071, 0x1a3b, 0x2079, 0x0320, 0x2001, 0x0201,
+	0x080c, 0x28ac, 0x7843, 0x0040, 0x2019, 0x01f4, 0xa001, 0xa001,
+	0x8319, 0x1de0, 0x2001, 0x0100, 0x080c, 0x2872, 0x2011, 0x0020,
+	0x080c, 0x28ac, 0x7843, 0x0000, 0x9006, 0x080c, 0x2872, 0x2011,
+	0x0048, 0x080c, 0x28ac, 0x00fe, 0x0005, 0x7884, 0xd0ac, 0x11c8,
+	0x00f6, 0x00e6, 0x2071, 0x1a43, 0x2079, 0x0320, 0x2001, 0x0201,
 	0x2004, 0x9005, 0x0160, 0x7000, 0x9086, 0x0000, 0x1140, 0x0051,
 	0xd0bc, 0x0108, 0x8738, 0x7003, 0x0003, 0x782b, 0x0019, 0x00ee,
 	0x00fe, 0x0005, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe, 0x908c,
@@ -1771,7 +1775,7 @@
 	0xd0b4, 0x0108, 0x8c60, 0xd0ac, 0x0108, 0x8d68, 0xd0a4, 0x0108,
 	0x8b58, 0x0005, 0x00f6, 0x2079, 0x0200, 0x781c, 0xd084, 0x0110,
 	0x7837, 0x0050, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x0100, 0x2001,
-	0x197a, 0x2004, 0x70e2, 0x080c, 0x3ad6, 0x1188, 0x2001, 0x181f,
+	0x1982, 0x2004, 0x70e2, 0x080c, 0x3af6, 0x1188, 0x2001, 0x181f,
 	0x2004, 0x2009, 0x181e, 0x210c, 0x918c, 0x00ff, 0x706e, 0x716a,
 	0x7066, 0x918d, 0x3200, 0x7162, 0x7073, 0xe109, 0x0080, 0x702c,
 	0x9085, 0x0002, 0x702e, 0x2009, 0x1817, 0x210c, 0x716e, 0x7063,
@@ -1779,31 +1783,31 @@
 	0x0008, 0x7078, 0x9080, 0x0100, 0x707a, 0x7080, 0x8000, 0x7082,
 	0x7087, 0xaaaa, 0x9006, 0x708a, 0x708e, 0x707e, 0x70d6, 0x70ab,
 	0x0036, 0x70af, 0x95d5, 0x7014, 0x9084, 0x1984, 0x9085, 0x0092,
-	0x7016, 0x080c, 0x3f0b, 0x00f6, 0x2071, 0x1a3b, 0x2079, 0x0320,
+	0x7016, 0x080c, 0x3f2b, 0x00f6, 0x2071, 0x1a43, 0x2079, 0x0320,
 	0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120, 0x689c, 0x780e,
 	0x6898, 0x780a, 0x00de, 0x2009, 0x03e8, 0x8109, 0x1df0, 0x792c,
-	0xd1fc, 0x0110, 0x782b, 0x0004, 0x2011, 0x0011, 0x080c, 0x3e97,
-	0x2011, 0x0001, 0x080c, 0x3e97, 0x00fe, 0x00ee, 0x0005, 0x00f6,
-	0x00e6, 0x2071, 0x1a3b, 0x2079, 0x0320, 0x792c, 0xd1fc, 0x0904,
-	0x3e94, 0x782b, 0x0002, 0x9026, 0xd19c, 0x1904, 0x3e90, 0x7000,
-	0x0002, 0x3e94, 0x3e45, 0x3e75, 0x3e90, 0xd1bc, 0x1170, 0xd1dc,
-	0x1190, 0x8001, 0x7002, 0x2011, 0x0001, 0x080c, 0x3e97, 0x0904,
-	0x3e94, 0x080c, 0x3e97, 0x0804, 0x3e94, 0x00f6, 0x2079, 0x0300,
+	0xd1fc, 0x0110, 0x782b, 0x0004, 0x2011, 0x0011, 0x080c, 0x3eb7,
+	0x2011, 0x0001, 0x080c, 0x3eb7, 0x00fe, 0x00ee, 0x0005, 0x00f6,
+	0x00e6, 0x2071, 0x1a43, 0x2079, 0x0320, 0x792c, 0xd1fc, 0x0904,
+	0x3eb4, 0x782b, 0x0002, 0x9026, 0xd19c, 0x1904, 0x3eb0, 0x7000,
+	0x0002, 0x3eb4, 0x3e65, 0x3e95, 0x3eb0, 0xd1bc, 0x1170, 0xd1dc,
+	0x1190, 0x8001, 0x7002, 0x2011, 0x0001, 0x080c, 0x3eb7, 0x0904,
+	0x3eb4, 0x080c, 0x3eb7, 0x0804, 0x3eb4, 0x00f6, 0x2079, 0x0300,
 	0x78bf, 0x0000, 0x00fe, 0x7810, 0x7914, 0x782b, 0x0004, 0x7812,
-	0x7916, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0de8, 0x080c, 0x3da2,
+	0x7916, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0de8, 0x080c, 0x3dc2,
 	0x2009, 0x0001, 0x00f6, 0x2079, 0x0300, 0x78b8, 0x00fe, 0xd0ec,
 	0x0110, 0x2009, 0x0011, 0x792a, 0x00f8, 0x8001, 0x7002, 0x9184,
-	0x0880, 0x1140, 0x782c, 0xd0fc, 0x1904, 0x3e39, 0x2011, 0x0001,
+	0x0880, 0x1140, 0x782c, 0xd0fc, 0x1904, 0x3e59, 0x2011, 0x0001,
 	0x00b1, 0x0090, 0xa010, 0x9092, 0x0004, 0x9086, 0x0015, 0x1120,
 	0xa000, 0xa05a, 0x2011, 0x0031, 0xa212, 0xd1dc, 0x1960, 0x0828,
 	0x782b, 0x0004, 0x7003, 0x0000, 0x00ee, 0x00fe, 0x0005, 0xa014,
 	0x9005, 0x0550, 0x8001, 0x0036, 0x0096, 0xa016, 0xa058, 0x2048,
 	0xa010, 0x2009, 0x0031, 0x911a, 0x831c, 0x831c, 0x938a, 0x0007,
-	0x1a0c, 0x0d65, 0x9398, 0x3ec5, 0x231d, 0x083f, 0x9080, 0x0004,
+	0x1a0c, 0x0d65, 0x9398, 0x3ee5, 0x231d, 0x083f, 0x9080, 0x0004,
 	0x7a2a, 0x7100, 0x8108, 0x7102, 0x009e, 0x003e, 0x908a, 0x0035,
 	0x1140, 0x0096, 0xa058, 0x2048, 0xa804, 0xa05a, 0x2001, 0x0019,
-	0x009e, 0xa012, 0x9085, 0x0001, 0x0005, 0x3f02, 0x3ef9, 0x3ef0,
-	0x3ee7, 0x3ede, 0x3ed5, 0x3ecc, 0xa964, 0x7902, 0xa968, 0x7906,
+	0x009e, 0xa012, 0x9085, 0x0001, 0x0005, 0x3f22, 0x3f19, 0x3f10,
+	0x3f07, 0x3efe, 0x3ef5, 0x3eec, 0xa964, 0x7902, 0xa968, 0x7906,
 	0xa96c, 0x7912, 0xa970, 0x7916, 0x0005, 0xa974, 0x7902, 0xa978,
 	0x7906, 0xa97c, 0x7912, 0xa980, 0x7916, 0x0005, 0xa984, 0x7902,
 	0xa988, 0x7906, 0xa98c, 0x7912, 0xa990, 0x7916, 0x0005, 0xa994,
@@ -1811,24 +1815,24 @@
 	0xa9a4, 0x7902, 0xa9a8, 0x7906, 0xa9ac, 0x7912, 0xa9b0, 0x7916,
 	0x0005, 0xa9b4, 0x7902, 0xa9b8, 0x7906, 0xa9bc, 0x7912, 0xa9c0,
 	0x7916, 0x0005, 0xa9c4, 0x7902, 0xa9c8, 0x7906, 0xa9cc, 0x7912,
-	0xa9d0, 0x7916, 0x0005, 0x00f6, 0x00e6, 0x0086, 0x2071, 0x19b7,
+	0xa9d0, 0x7916, 0x0005, 0x00f6, 0x00e6, 0x0086, 0x2071, 0x19bf,
 	0x2079, 0x0090, 0x792c, 0xd1fc, 0x01e8, 0x782b, 0x0002, 0x2940,
-	0x9026, 0x7054, 0x0002, 0x3f32, 0x3f1e, 0x3f29, 0x8001, 0x7056,
-	0xd19c, 0x1180, 0x2011, 0x0001, 0x080c, 0x3e97, 0x190c, 0x3e97,
+	0x9026, 0x7054, 0x0002, 0x3f52, 0x3f3e, 0x3f49, 0x8001, 0x7056,
+	0xd19c, 0x1180, 0x2011, 0x0001, 0x080c, 0x3eb7, 0x190c, 0x3eb7,
 	0x0048, 0x8001, 0x7056, 0x782c, 0xd0fc, 0x1d38, 0x2011, 0x0001,
-	0x080c, 0x3e97, 0x008e, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x00e6,
-	0x00c6, 0x0086, 0x2061, 0x0200, 0x2001, 0x197a, 0x2004, 0x601a,
-	0x2061, 0x0100, 0x2001, 0x1979, 0x2004, 0x60ce, 0x6104, 0xc1ac,
+	0x080c, 0x3eb7, 0x008e, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x00e6,
+	0x00c6, 0x0086, 0x2061, 0x0200, 0x2001, 0x1982, 0x2004, 0x601a,
+	0x2061, 0x0100, 0x2001, 0x1981, 0x2004, 0x60ce, 0x6104, 0xc1ac,
 	0x6106, 0x2001, 0x002c, 0x2004, 0x9005, 0x0520, 0x2038, 0x2001,
-	0x002e, 0x2024, 0x2001, 0x002f, 0x201c, 0x080c, 0x487a, 0xa813,
+	0x002e, 0x2024, 0x2001, 0x002f, 0x201c, 0x080c, 0x489a, 0xa813,
 	0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007, 0x0220, 0x2138,
 	0x2009, 0x0007, 0x0010, 0x2708, 0x903e, 0x0096, 0xa858, 0x2048,
-	0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x3fae, 0x1d68, 0x2900,
-	0xa85a, 0x00d0, 0x080c, 0x487a, 0xa813, 0x0019, 0xa817, 0x0001,
+	0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x3fce, 0x1d68, 0x2900,
+	0xa85a, 0x00d0, 0x080c, 0x489a, 0xa813, 0x0019, 0xa817, 0x0001,
 	0x2900, 0xa85a, 0x2001, 0x002e, 0x2004, 0xa866, 0x2001, 0x002f,
 	0x2004, 0xa86a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e,
 	0x2001, 0x002b, 0x2004, 0xa872, 0x2061, 0x0090, 0x2079, 0x0100,
-	0x2001, 0x1979, 0x2004, 0x6036, 0x2009, 0x0040, 0x080c, 0x2063,
+	0x2001, 0x1981, 0x2004, 0x6036, 0x2009, 0x0040, 0x080c, 0x207b,
 	0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a, 0x0006, 0x2001,
 	0x002b, 0x2004, 0x601e, 0x78c6, 0x000e, 0x78ca, 0x9006, 0x600a,
 	0x600e, 0x008e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00e6, 0x2071,
@@ -1836,654 +1840,654 @@
 	0x702b, 0x0026, 0x7402, 0x7306, 0x9006, 0x700a, 0x700e, 0x810b,
 	0x810b, 0x21a8, 0x810b, 0x7112, 0x702b, 0x0041, 0x702c, 0xd0fc,
 	0x0de8, 0x702b, 0x0002, 0x702b, 0x0040, 0x4005, 0x7400, 0x7304,
-	0x87ff, 0x0190, 0x0086, 0x0096, 0x2940, 0x0086, 0x080c, 0x487a,
+	0x87ff, 0x0190, 0x0086, 0x0096, 0x2940, 0x0086, 0x080c, 0x489a,
 	0x008e, 0xa058, 0x00a6, 0x2050, 0x2900, 0xb006, 0xa05a, 0x00ae,
 	0x009e, 0x008e, 0x9085, 0x0001, 0x00ee, 0x0005, 0x00e6, 0x2001,
 	0x002d, 0x2004, 0x9005, 0x0528, 0x2038, 0x2001, 0x0030, 0x2024,
-	0x2001, 0x0031, 0x201c, 0x080c, 0x487a, 0x2940, 0xa813, 0x0019,
+	0x2001, 0x0031, 0x201c, 0x080c, 0x489a, 0x2940, 0xa813, 0x0019,
 	0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007, 0x0220, 0x2138, 0x2009,
 	0x0007, 0x0010, 0x2708, 0x903e, 0x0096, 0xa858, 0x2048, 0xa85c,
-	0x9080, 0x0019, 0x009e, 0x080c, 0x3fae, 0x1d68, 0x2900, 0xa85a,
-	0x00d8, 0x080c, 0x487a, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001,
+	0x9080, 0x0019, 0x009e, 0x080c, 0x3fce, 0x1d68, 0x2900, 0xa85a,
+	0x00d8, 0x080c, 0x489a, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001,
 	0x2800, 0xa05a, 0x2001, 0x0030, 0x2004, 0xa066, 0x2001, 0x0031,
 	0x2004, 0xa06a, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa06e,
 	0x2001, 0x002b, 0x2004, 0xa072, 0x2001, 0x032a, 0x2003, 0x0004,
 	0x7884, 0xd0ac, 0x1180, 0x2001, 0x0101, 0x200c, 0x918d, 0x0200,
-	0x2102, 0xa017, 0x0000, 0x2001, 0x1a3b, 0x2003, 0x0003, 0x2001,
+	0x2102, 0xa017, 0x0000, 0x2001, 0x1a43, 0x2003, 0x0003, 0x2001,
 	0x032a, 0x2003, 0x0009, 0x2001, 0x0300, 0x2003, 0x0000, 0x2001,
 	0x020d, 0x2003, 0x0000, 0x2001, 0x0004, 0x200c, 0x918d, 0x0002,
-	0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x20a9, 0x0013,
+	0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x20a9, 0x001b,
 	0x20a1, 0x1840, 0x20e9, 0x0001, 0x9006, 0x4004, 0x2009, 0x013c,
 	0x200a, 0x012e, 0x7880, 0x9086, 0x0052, 0x0108, 0x0005, 0x0804,
-	0x337e, 0x7d98, 0x7c9c, 0x0804, 0x3480, 0x080c, 0x7096, 0x190c,
-	0x5c9c, 0x2069, 0x1853, 0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88,
-	0x7c9c, 0x7d98, 0x2039, 0x0001, 0x080c, 0x48c3, 0x701f, 0x4081,
-	0x0005, 0x080c, 0x5397, 0x1130, 0x3b00, 0x3a08, 0xc194, 0xc095,
-	0x20d8, 0x21d0, 0x2069, 0x1853, 0x6800, 0x9005, 0x0904, 0x33b3,
+	0x339e, 0x7d98, 0x7c9c, 0x0804, 0x34a0, 0x080c, 0x70ba, 0x190c,
+	0x5cbc, 0x2069, 0x185b, 0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88,
+	0x7c9c, 0x7d98, 0x2039, 0x0001, 0x080c, 0x48e3, 0x701f, 0x40a1,
+	0x0005, 0x080c, 0x53b7, 0x1130, 0x3b00, 0x3a08, 0xc194, 0xc095,
+	0x20d8, 0x21d0, 0x2069, 0x185b, 0x6800, 0x9005, 0x0904, 0x33d3,
 	0x6804, 0xd094, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0138, 0x6200,
 	0x9292, 0x0005, 0x0218, 0x918c, 0xffdf, 0x0010, 0x918d, 0x0020,
 	0x6106, 0x00ce, 0xd08c, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0118,
 	0x918d, 0x0010, 0x0010, 0x918c, 0xffef, 0x6106, 0x00ce, 0xd084,
-	0x0158, 0x6a28, 0x928a, 0x007f, 0x1a04, 0x33b3, 0x9288, 0x317f,
+	0x0158, 0x6a28, 0x928a, 0x007f, 0x1a04, 0x33d3, 0x9288, 0x319f,
 	0x210d, 0x918c, 0x00ff, 0x6162, 0xd0dc, 0x0130, 0x6828, 0x908a,
-	0x007f, 0x1a04, 0x33b3, 0x605a, 0x6888, 0x9084, 0x0030, 0x8004,
-	0x8004, 0x8004, 0x8004, 0x0006, 0x2009, 0x1981, 0x9080, 0x2579,
-	0x2005, 0x200a, 0x2008, 0x2001, 0x0018, 0x080c, 0x98ac, 0x2009,
-	0x0390, 0x200b, 0x0400, 0x000e, 0x2009, 0x1982, 0x9080, 0x257d,
-	0x2005, 0x200a, 0x6808, 0x908a, 0x0100, 0x0a04, 0x33b3, 0x908a,
-	0x0841, 0x1a04, 0x33b3, 0x9084, 0x0007, 0x1904, 0x33b3, 0x680c,
-	0x9005, 0x0904, 0x33b3, 0x6810, 0x9005, 0x0904, 0x33b3, 0x6848,
-	0x6940, 0x910a, 0x1a04, 0x33b3, 0x8001, 0x0904, 0x33b3, 0x684c,
-	0x6944, 0x910a, 0x1a04, 0x33b3, 0x8001, 0x0904, 0x33b3, 0x6814,
+	0x007f, 0x1a04, 0x33d3, 0x605a, 0x6888, 0x9084, 0x0030, 0x8004,
+	0x8004, 0x8004, 0x8004, 0x0006, 0x2009, 0x1989, 0x9080, 0x2595,
+	0x2005, 0x200a, 0x2008, 0x2001, 0x0018, 0x080c, 0x98b8, 0x2009,
+	0x0390, 0x200b, 0x0400, 0x000e, 0x2009, 0x198a, 0x9080, 0x2599,
+	0x2005, 0x200a, 0x6808, 0x908a, 0x0100, 0x0a04, 0x33d3, 0x908a,
+	0x0841, 0x1a04, 0x33d3, 0x9084, 0x0007, 0x1904, 0x33d3, 0x680c,
+	0x9005, 0x0904, 0x33d3, 0x6810, 0x9005, 0x0904, 0x33d3, 0x6848,
+	0x6940, 0x910a, 0x1a04, 0x33d3, 0x8001, 0x0904, 0x33d3, 0x684c,
+	0x6944, 0x910a, 0x1a04, 0x33d3, 0x8001, 0x0904, 0x33d3, 0x6814,
 	0x908c, 0x00ff, 0x614a, 0x8007, 0x9084, 0x00ff, 0x604e, 0x080c,
-	0x73c7, 0x080c, 0x672f, 0x080c, 0x6764, 0x6808, 0x602a, 0x080c,
-	0x1fd5, 0x2009, 0x0170, 0x200b, 0x0080, 0xa001, 0xa001, 0x200b,
-	0x0000, 0x0036, 0x6b08, 0x080c, 0x24e0, 0x003e, 0x6000, 0x9086,
-	0x0000, 0x1904, 0x41ed, 0x6818, 0x691c, 0x6a20, 0x6b24, 0x8007,
+	0x73ea, 0x080c, 0x6753, 0x080c, 0x6788, 0x6808, 0x602a, 0x080c,
+	0x1fed, 0x2009, 0x0170, 0x200b, 0x0080, 0xa001, 0xa001, 0x200b,
+	0x0000, 0x0036, 0x6b08, 0x080c, 0x24fc, 0x003e, 0x6000, 0x9086,
+	0x0000, 0x1904, 0x420d, 0x6818, 0x691c, 0x6a20, 0x6b24, 0x8007,
 	0x810f, 0x8217, 0x831f, 0x6016, 0x611a, 0x621e, 0x6322, 0x6c04,
 	0xd4f4, 0x0148, 0x6830, 0x6934, 0x6a38, 0x6b3c, 0x8007, 0x810f,
 	0x8217, 0x831f, 0x0010, 0x9084, 0xf0ff, 0x6006, 0x610a, 0x620e,
 	0x6312, 0x8007, 0x810f, 0x8217, 0x831f, 0x20a9, 0x0004, 0x20a1,
-	0x1983, 0x20e9, 0x0001, 0x4001, 0x20a9, 0x0004, 0x20a1, 0x199d,
-	0x20e9, 0x0001, 0x4001, 0x080c, 0x82af, 0x00c6, 0x900e, 0x20a9,
+	0x198b, 0x20e9, 0x0001, 0x4001, 0x20a9, 0x0004, 0x20a1, 0x19a5,
+	0x20e9, 0x0001, 0x4001, 0x080c, 0x82e3, 0x00c6, 0x900e, 0x20a9,
 	0x0001, 0x6b70, 0xd384, 0x01c8, 0x0020, 0x839d, 0x12b0, 0x3508,
-	0x8109, 0x080c, 0x799d, 0x6878, 0x6016, 0x6874, 0x2008, 0x9084,
+	0x8109, 0x080c, 0x79c1, 0x6878, 0x6016, 0x6874, 0x2008, 0x9084,
 	0xff00, 0x8007, 0x600a, 0x9184, 0x00ff, 0x6006, 0x8108, 0x1118,
-	0x6003, 0x0003, 0x0010, 0x6003, 0x0001, 0x1f04, 0x4165, 0x00ce,
-	0x00c6, 0x2061, 0x196c, 0x2063, 0x0001, 0x9006, 0x080c, 0x2787,
-	0x9006, 0x080c, 0x276a, 0x0000, 0x00ce, 0x00e6, 0x2c70, 0x080c,
-	0x0e9c, 0x00ee, 0x6888, 0xd0ec, 0x0130, 0x2011, 0x0114, 0x2204,
+	0x6003, 0x0003, 0x0010, 0x6003, 0x0001, 0x1f04, 0x4185, 0x00ce,
+	0x00c6, 0x2061, 0x1974, 0x2063, 0x0001, 0x9006, 0x080c, 0x27a3,
+	0x9006, 0x080c, 0x2786, 0x0000, 0x00ce, 0x00e6, 0x2c70, 0x080c,
+	0x0ea9, 0x00ee, 0x6888, 0xd0ec, 0x0130, 0x2011, 0x0114, 0x2204,
 	0x9085, 0x0180, 0x2012, 0x6a80, 0x9284, 0x0030, 0x9086, 0x0030,
-	0x1128, 0x9294, 0xffcf, 0x9295, 0x0020, 0x6a82, 0x2001, 0x194c,
+	0x1128, 0x9294, 0xffcf, 0x9295, 0x0020, 0x6a82, 0x2001, 0x1954,
 	0x6a80, 0x9294, 0x0030, 0x928e, 0x0000, 0x0170, 0x928e, 0x0010,
-	0x0118, 0x928e, 0x0020, 0x0140, 0x2003, 0xaaaa, 0x080c, 0x2555,
-	0x2001, 0x193d, 0x2102, 0x0008, 0x2102, 0x00c6, 0x2061, 0x0100,
-	0x602f, 0x0040, 0x602f, 0x0000, 0x00ce, 0x080c, 0x7096, 0x0128,
-	0x080c, 0x4c8c, 0x0110, 0x080c, 0x24a6, 0x60d0, 0x9005, 0x01c0,
-	0x6003, 0x0001, 0x2009, 0x41d5, 0x00d0, 0x080c, 0x7096, 0x1168,
-	0x2011, 0x6f0c, 0x080c, 0x8138, 0x2011, 0x6eff, 0x080c, 0x823e,
-	0x080c, 0x739b, 0x080c, 0x6fc7, 0x0040, 0x080c, 0x5b92, 0x0028,
-	0x6003, 0x0004, 0x2009, 0x41ed, 0x0010, 0x0804, 0x337e, 0x2001,
+	0x0118, 0x928e, 0x0020, 0x0140, 0x2003, 0xaaaa, 0x080c, 0x2571,
+	0x2001, 0x1945, 0x2102, 0x0008, 0x2102, 0x00c6, 0x2061, 0x0100,
+	0x602f, 0x0040, 0x602f, 0x0000, 0x00ce, 0x080c, 0x70ba, 0x0128,
+	0x080c, 0x4cac, 0x0110, 0x080c, 0x24c2, 0x60d0, 0x9005, 0x01c0,
+	0x6003, 0x0001, 0x2009, 0x41f5, 0x00d0, 0x080c, 0x70ba, 0x1168,
+	0x2011, 0x6f30, 0x080c, 0x816c, 0x2011, 0x6f23, 0x080c, 0x8272,
+	0x080c, 0x73be, 0x080c, 0x6feb, 0x0040, 0x080c, 0x5bb2, 0x0028,
+	0x6003, 0x0004, 0x2009, 0x420d, 0x0010, 0x0804, 0x339e, 0x2001,
 	0x0170, 0x2004, 0x9084, 0x00ff, 0x9086, 0x004c, 0x1118, 0x2091,
 	0x31bd, 0x0817, 0x2091, 0x313d, 0x0817, 0x6000, 0x9086, 0x0000,
-	0x0904, 0x33b0, 0x2069, 0x1853, 0x7890, 0x6842, 0x7894, 0x6846,
+	0x0904, 0x33d0, 0x2069, 0x185b, 0x7890, 0x6842, 0x7894, 0x6846,
 	0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039,
-	0x0001, 0x0804, 0x48c6, 0x9006, 0x080c, 0x24a6, 0x81ff, 0x1904,
-	0x33b0, 0x080c, 0x7096, 0x11b0, 0x080c, 0x7396, 0x080c, 0x5cd7,
-	0x080c, 0x317a, 0x0118, 0x6130, 0xc18d, 0x6132, 0x080c, 0xbf61,
-	0x0130, 0x080c, 0x70b9, 0x1118, 0x080c, 0x706a, 0x0038, 0x080c,
-	0x6fc7, 0x0020, 0x080c, 0x5c9c, 0x080c, 0x5b92, 0x0804, 0x337e,
-	0x81ff, 0x1904, 0x33b0, 0x080c, 0x7096, 0x1110, 0x0804, 0x33b0,
+	0x0001, 0x0804, 0x48e6, 0x9006, 0x080c, 0x24c2, 0x81ff, 0x1904,
+	0x33d0, 0x080c, 0x70ba, 0x11b0, 0x080c, 0x73b9, 0x080c, 0x5cf7,
+	0x080c, 0x319a, 0x0118, 0x6130, 0xc18d, 0x6132, 0x080c, 0xbf8f,
+	0x0130, 0x080c, 0x70dd, 0x1118, 0x080c, 0x708e, 0x0038, 0x080c,
+	0x6feb, 0x0020, 0x080c, 0x5cbc, 0x080c, 0x5bb2, 0x0804, 0x339e,
+	0x81ff, 0x1904, 0x33d0, 0x080c, 0x70ba, 0x1110, 0x0804, 0x33d0,
 	0x6190, 0x81ff, 0x01a8, 0x704f, 0x0000, 0x2001, 0x1d80, 0x2009,
 	0x0040, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0126, 0x2091, 0x8000,
-	0x2039, 0x0001, 0x080c, 0x48c6, 0x701f, 0x337c, 0x012e, 0x0005,
+	0x2039, 0x0001, 0x080c, 0x48e6, 0x701f, 0x339c, 0x012e, 0x0005,
 	0x704f, 0x0001, 0x00d6, 0x2069, 0x1d80, 0x20a9, 0x0040, 0x20e9,
 	0x0001, 0x20a1, 0x1d80, 0x2019, 0xffff, 0x4304, 0x6558, 0x9588,
-	0x317f, 0x210d, 0x918c, 0x00ff, 0x216a, 0x900e, 0x2011, 0x0002,
-	0x2100, 0x9506, 0x01a8, 0x080c, 0x626b, 0x1190, 0xb814, 0x821c,
+	0x319f, 0x210d, 0x918c, 0x00ff, 0x216a, 0x900e, 0x2011, 0x0002,
+	0x2100, 0x9506, 0x01a8, 0x080c, 0x628f, 0x1190, 0xb814, 0x821c,
 	0x0238, 0x9398, 0x1d80, 0x9085, 0xff00, 0x8007, 0x201a, 0x0038,
 	0x9398, 0x1d80, 0x2324, 0x94a4, 0xff00, 0x9405, 0x201a, 0x8210,
 	0x8108, 0x9182, 0x0080, 0x1208, 0x0c18, 0x8201, 0x8007, 0x2d0c,
 	0x9105, 0x206a, 0x00de, 0x20a9, 0x0040, 0x20a1, 0x1d80, 0x2099,
-	0x1d80, 0x080c, 0x5c27, 0x0804, 0x4245, 0x080c, 0x48ad, 0x0904,
-	0x33b3, 0x080c, 0x487a, 0x1120, 0x2009, 0x0002, 0x0804, 0x33b0,
-	0x080c, 0x5388, 0xd0b4, 0x0558, 0x7884, 0x908e, 0x007e, 0x0538,
-	0x908e, 0x007f, 0x0520, 0x908e, 0x0080, 0x0508, 0x080c, 0x3175,
+	0x1d80, 0x080c, 0x5c47, 0x0804, 0x4265, 0x080c, 0x48cd, 0x0904,
+	0x33d3, 0x080c, 0x489a, 0x1120, 0x2009, 0x0002, 0x0804, 0x33d0,
+	0x080c, 0x53a8, 0xd0b4, 0x0558, 0x7884, 0x908e, 0x007e, 0x0538,
+	0x908e, 0x007f, 0x0520, 0x908e, 0x0080, 0x0508, 0x080c, 0x3195,
 	0x1148, 0xb800, 0xd08c, 0x11d8, 0xb804, 0x9084, 0x00ff, 0x9086,
 	0x0006, 0x11a8, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c,
-	0xba11, 0x1120, 0x2009, 0x0003, 0x0804, 0x33b0, 0x7007, 0x0003,
-	0x701f, 0x42d3, 0x0005, 0x080c, 0x48ad, 0x0904, 0x33b3, 0x20a9,
+	0xba3f, 0x1120, 0x2009, 0x0003, 0x0804, 0x33d0, 0x7007, 0x0003,
+	0x701f, 0x42f3, 0x0005, 0x080c, 0x48cd, 0x0904, 0x33d3, 0x20a9,
 	0x002b, 0xb8b4, 0x20e0, 0xb8b8, 0x2098, 0xa860, 0x20e8, 0xa85c,
 	0x9080, 0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006,
 	0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098, 0x080c,
-	0x0f9f, 0x0070, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x000a, 0x20a0,
-	0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0f9f,
+	0x0fac, 0x0070, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x000a, 0x20a0,
+	0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0fac,
 	0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
 	0x0002, 0x2009, 0x002b, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804,
-	0x48c6, 0x81ff, 0x1904, 0x33b0, 0x080c, 0x4891, 0x0904, 0x33b3,
-	0x080c, 0x64b0, 0x0904, 0x33b0, 0x0058, 0xa878, 0x9005, 0x0120,
-	0x2009, 0x0004, 0x0804, 0x33b0, 0xa974, 0xaa94, 0x0804, 0x337e,
-	0x080c, 0x5390, 0x0904, 0x337e, 0x701f, 0x431d, 0x7007, 0x0003,
-	0x0005, 0x81ff, 0x1904, 0x33b0, 0x7888, 0x908a, 0x1000, 0x1a04,
-	0x33b3, 0x080c, 0x48ad, 0x0904, 0x33b3, 0x080c, 0x6666, 0x0120,
-	0x080c, 0x666e, 0x1904, 0x33b3, 0x080c, 0x6535, 0x0904, 0x33b0,
-	0x2019, 0x0004, 0x900e, 0x080c, 0x64c2, 0x0904, 0x33b0, 0x7984,
+	0x48e6, 0x81ff, 0x1904, 0x33d0, 0x080c, 0x48b1, 0x0904, 0x33d3,
+	0x080c, 0x64d4, 0x0904, 0x33d0, 0x0058, 0xa878, 0x9005, 0x0120,
+	0x2009, 0x0004, 0x0804, 0x33d0, 0xa974, 0xaa94, 0x0804, 0x339e,
+	0x080c, 0x53b0, 0x0904, 0x339e, 0x701f, 0x433d, 0x7007, 0x0003,
+	0x0005, 0x81ff, 0x1904, 0x33d0, 0x7888, 0x908a, 0x1000, 0x1a04,
+	0x33d3, 0x080c, 0x48cd, 0x0904, 0x33d3, 0x080c, 0x668a, 0x0120,
+	0x080c, 0x6692, 0x1904, 0x33d3, 0x080c, 0x6559, 0x0904, 0x33d0,
+	0x2019, 0x0004, 0x900e, 0x080c, 0x64e6, 0x0904, 0x33d0, 0x7984,
 	0x7a88, 0x04c9, 0x08a8, 0xa89c, 0x908a, 0x1000, 0x12f8, 0x080c,
-	0x48ab, 0x01e0, 0x080c, 0x6666, 0x0118, 0x080c, 0x666e, 0x11b0,
-	0x080c, 0x6535, 0x2009, 0x0002, 0x0168, 0x2009, 0x0002, 0x2019,
-	0x0004, 0x080c, 0x64c2, 0x2009, 0x0003, 0x0120, 0xa998, 0xaa9c,
+	0x48cb, 0x01e0, 0x080c, 0x668a, 0x0118, 0x080c, 0x6692, 0x11b0,
+	0x080c, 0x6559, 0x2009, 0x0002, 0x0168, 0x2009, 0x0002, 0x2019,
+	0x0004, 0x080c, 0x64e6, 0x2009, 0x0003, 0x0120, 0xa998, 0xaa9c,
 	0x00d1, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
 	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000,
-	0x080c, 0x5390, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001,
+	0x080c, 0x53b0, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001,
 	0x2001, 0x0000, 0x0005, 0x9186, 0x00ff, 0x0110, 0x0071, 0x0060,
 	0x2029, 0x007e, 0x2061, 0x1800, 0x6458, 0x2400, 0x9506, 0x0110,
-	0x2508, 0x0019, 0x8529, 0x1ec8, 0x0005, 0x080c, 0x626b, 0x1138,
-	0x2200, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x8146, 0x0005,
-	0x81ff, 0x1904, 0x33b0, 0x798c, 0x2001, 0x1950, 0x918c, 0x8000,
-	0x2102, 0x080c, 0x4891, 0x0904, 0x33b3, 0x080c, 0x6666, 0x0120,
-	0x080c, 0x666e, 0x1904, 0x33b3, 0x080c, 0x6332, 0x0904, 0x33b0,
-	0x080c, 0x64b9, 0x0904, 0x33b0, 0x2001, 0x1950, 0x2004, 0xd0fc,
-	0x1904, 0x337e, 0x0804, 0x4328, 0xa9a0, 0x2001, 0x1950, 0x918c,
-	0x8000, 0xc18d, 0x2102, 0x080c, 0x489e, 0x01a0, 0x080c, 0x6666,
-	0x0118, 0x080c, 0x666e, 0x1170, 0x080c, 0x6332, 0x2009, 0x0002,
-	0x0128, 0x080c, 0x64b9, 0x1170, 0x2009, 0x0003, 0xa897, 0x4005,
+	0x2508, 0x0019, 0x8529, 0x1ec8, 0x0005, 0x080c, 0x628f, 0x1138,
+	0x2200, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c, 0x817a, 0x0005,
+	0x81ff, 0x1904, 0x33d0, 0x798c, 0x2001, 0x1958, 0x918c, 0x8000,
+	0x2102, 0x080c, 0x48b1, 0x0904, 0x33d3, 0x080c, 0x668a, 0x0120,
+	0x080c, 0x6692, 0x1904, 0x33d3, 0x080c, 0x6356, 0x0904, 0x33d0,
+	0x080c, 0x64dd, 0x0904, 0x33d0, 0x2001, 0x1958, 0x2004, 0xd0fc,
+	0x1904, 0x339e, 0x0804, 0x4348, 0xa9a0, 0x2001, 0x1958, 0x918c,
+	0x8000, 0xc18d, 0x2102, 0x080c, 0x48be, 0x01a0, 0x080c, 0x668a,
+	0x0118, 0x080c, 0x6692, 0x1170, 0x080c, 0x6356, 0x2009, 0x0002,
+	0x0128, 0x080c, 0x64dd, 0x1170, 0x2009, 0x0003, 0xa897, 0x4005,
 	0xa99a, 0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001,
-	0x0030, 0x0005, 0xa897, 0x4000, 0x2001, 0x1950, 0x2004, 0xd0fc,
-	0x1128, 0x080c, 0x5390, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085,
-	0x0001, 0x2001, 0x0000, 0x0005, 0x81ff, 0x1904, 0x33b0, 0x798c,
-	0x2001, 0x194f, 0x918c, 0x8000, 0x2102, 0x080c, 0x4891, 0x0904,
-	0x33b3, 0x080c, 0x6666, 0x0120, 0x080c, 0x666e, 0x1904, 0x33b3,
-	0x080c, 0x6332, 0x0904, 0x33b0, 0x080c, 0x64a7, 0x0904, 0x33b0,
-	0x2001, 0x194f, 0x2004, 0xd0fc, 0x1904, 0x337e, 0x0804, 0x4328,
-	0xa9a0, 0x2001, 0x194f, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c,
-	0x489e, 0x01a0, 0x080c, 0x6666, 0x0118, 0x080c, 0x666e, 0x1170,
-	0x080c, 0x6332, 0x2009, 0x0002, 0x0128, 0x080c, 0x64a7, 0x1170,
+	0x0030, 0x0005, 0xa897, 0x4000, 0x2001, 0x1958, 0x2004, 0xd0fc,
+	0x1128, 0x080c, 0x53b0, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085,
+	0x0001, 0x2001, 0x0000, 0x0005, 0x81ff, 0x1904, 0x33d0, 0x798c,
+	0x2001, 0x1957, 0x918c, 0x8000, 0x2102, 0x080c, 0x48b1, 0x0904,
+	0x33d3, 0x080c, 0x668a, 0x0120, 0x080c, 0x6692, 0x1904, 0x33d3,
+	0x080c, 0x6356, 0x0904, 0x33d0, 0x080c, 0x64cb, 0x0904, 0x33d0,
+	0x2001, 0x1957, 0x2004, 0xd0fc, 0x1904, 0x339e, 0x0804, 0x4348,
+	0xa9a0, 0x2001, 0x1957, 0x918c, 0x8000, 0xc18d, 0x2102, 0x080c,
+	0x48be, 0x01a0, 0x080c, 0x668a, 0x0118, 0x080c, 0x6692, 0x1170,
+	0x080c, 0x6356, 0x2009, 0x0002, 0x0128, 0x080c, 0x64cb, 0x1170,
 	0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
 	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897, 0x4000,
-	0x2001, 0x194f, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x5390, 0x0110,
+	0x2001, 0x1957, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x53b0, 0x0110,
 	0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005,
-	0x6100, 0x0804, 0x337e, 0x080c, 0x48ad, 0x0904, 0x33b3, 0x080c,
-	0x539c, 0x1904, 0x33b0, 0x79a8, 0xd184, 0x1158, 0xb834, 0x8007,
+	0x6100, 0x0804, 0x339e, 0x080c, 0x48cd, 0x0904, 0x33d3, 0x080c,
+	0x53bc, 0x1904, 0x33d0, 0x79a8, 0xd184, 0x1158, 0xb834, 0x8007,
 	0x789e, 0xb830, 0x8007, 0x789a, 0xbb2c, 0x831f, 0xba28, 0x8217,
 	0x0050, 0xb824, 0x8007, 0x789e, 0xb820, 0x8007, 0x789a, 0xbb1c,
-	0x831f, 0xba18, 0x8217, 0xb900, 0x918c, 0x0200, 0x0804, 0x337e,
-	0x78a8, 0x909c, 0x0003, 0xd0b4, 0x1140, 0x939a, 0x0003, 0x1a04,
-	0x33b0, 0x6258, 0x7884, 0x9206, 0x1560, 0x2031, 0x1848, 0x2009,
-	0x013c, 0x2136, 0x2001, 0x1840, 0x2009, 0x000c, 0x7a8c, 0x7b88,
+	0x831f, 0xba18, 0x8217, 0xb900, 0x918c, 0x0200, 0x0804, 0x339e,
+	0x78a8, 0x909c, 0x0003, 0xd0ac, 0x1150, 0xd0b4, 0x1140, 0x939a,
+	0x0003, 0x1a04, 0x33d0, 0x6258, 0x7884, 0x9206, 0x1550, 0x2031,
+	0x1848, 0x2009, 0x013c, 0x2136, 0x2001, 0x1840, 0x7a8c, 0x7b88,
 	0x7c9c, 0x7d98, 0x2039, 0x0001, 0x0006, 0x78a8, 0x9084, 0x0080,
-	0x1118, 0x000e, 0x0804, 0x48c6, 0x000e, 0x2031, 0x0000, 0x2061,
-	0x18ae, 0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e, 0xa392,
-	0xa496, 0xa59a, 0x080c, 0x1117, 0x7007, 0x0002, 0x701f, 0x44e1,
-	0x0005, 0x81ff, 0x1904, 0x33b0, 0x080c, 0x48ad, 0x0904, 0x33b3,
-	0x080c, 0x6666, 0x1904, 0x33b0, 0x00c6, 0x080c, 0x487a, 0x00ce,
-	0x0904, 0x33b0, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7ea8,
-	0x080c, 0xb9b7, 0x0904, 0x33b0, 0x7007, 0x0003, 0x701f, 0x44e5,
-	0x0005, 0x080c, 0x4053, 0x0804, 0x337e, 0xa830, 0x9086, 0x0100,
-	0x0904, 0x33b0, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
+	0x1118, 0x000e, 0x0804, 0x48e6, 0x000e, 0x2031, 0x0000, 0x2061,
+	0x18b6, 0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e, 0xa392,
+	0xa496, 0xa59a, 0x080c, 0x1124, 0x7007, 0x0002, 0x701f, 0x4501,
+	0x0005, 0x81ff, 0x1904, 0x33d0, 0x080c, 0x48cd, 0x0904, 0x33d3,
+	0x080c, 0x668a, 0x1904, 0x33d0, 0x00c6, 0x080c, 0x489a, 0x00ce,
+	0x0904, 0x33d0, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7ea8,
+	0x080c, 0xb9e5, 0x0904, 0x33d0, 0x7007, 0x0003, 0x701f, 0x4505,
+	0x0005, 0x080c, 0x4073, 0x0804, 0x339e, 0xa830, 0x9086, 0x0100,
+	0x0904, 0x33d0, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
 	0xffc0, 0x9080, 0x001b, 0x2009, 0x000c, 0x7a8c, 0x7b88, 0x7c9c,
-	0x7d98, 0x0804, 0x48c6, 0x9006, 0x080c, 0x24a6, 0x78a8, 0x9084,
-	0x00ff, 0x9086, 0x00ff, 0x0118, 0x81ff, 0x1904, 0x33b0, 0x080c,
-	0x7096, 0x0110, 0x080c, 0x5c9c, 0x7888, 0x908a, 0x1000, 0x1a04,
-	0x33b3, 0x7984, 0x9186, 0x00ff, 0x0138, 0x9182, 0x007f, 0x1a04,
-	0x33b3, 0x2100, 0x080c, 0x2470, 0x0026, 0x00c6, 0x0126, 0x2091,
-	0x8000, 0x2061, 0x19d3, 0x601b, 0x0000, 0x601f, 0x0000, 0x6073,
-	0x0000, 0x6077, 0x0000, 0x080c, 0x7096, 0x1158, 0x080c, 0x7396,
-	0x080c, 0x5cd7, 0x9085, 0x0001, 0x080c, 0x70dd, 0x080c, 0x6fc7,
-	0x00f0, 0x080c, 0x98bb, 0x080c, 0x9b60, 0x080c, 0x98d7, 0x2061,
+	0x7d98, 0x0804, 0x48e6, 0x9006, 0x080c, 0x24c2, 0x78a8, 0x9084,
+	0x00ff, 0x9086, 0x00ff, 0x0118, 0x81ff, 0x1904, 0x33d0, 0x080c,
+	0x70ba, 0x0110, 0x080c, 0x5cbc, 0x7888, 0x908a, 0x1000, 0x1a04,
+	0x33d3, 0x7984, 0x9186, 0x00ff, 0x0138, 0x9182, 0x007f, 0x1a04,
+	0x33d3, 0x2100, 0x080c, 0x248c, 0x0026, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x2061, 0x19db, 0x601b, 0x0000, 0x601f, 0x0000, 0x6073,
+	0x0000, 0x6077, 0x0000, 0x080c, 0x70ba, 0x1158, 0x080c, 0x73b9,
+	0x080c, 0x5cf7, 0x9085, 0x0001, 0x080c, 0x7101, 0x080c, 0x6feb,
+	0x00f0, 0x080c, 0x98c7, 0x080c, 0x9b6c, 0x080c, 0x98e3, 0x2061,
 	0x0100, 0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x810f, 0x9105,
-	0x604a, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x1969, 0x200b,
-	0x0000, 0x2009, 0x002d, 0x2011, 0x5bc2, 0x080c, 0x81fc, 0x7984,
-	0x080c, 0x7096, 0x1110, 0x2009, 0x00ff, 0x7a88, 0x080c, 0x438b,
-	0x012e, 0x00ce, 0x002e, 0x0804, 0x337e, 0x7984, 0x080c, 0x620b,
-	0x2b08, 0x1904, 0x33b3, 0x0804, 0x337e, 0x81ff, 0x0120, 0x2009,
-	0x0001, 0x0804, 0x33b0, 0x60d8, 0xd0ac, 0x1130, 0xd09c, 0x1120,
-	0x2009, 0x0005, 0x0804, 0x33b0, 0x080c, 0x487a, 0x1120, 0x2009,
-	0x0002, 0x0804, 0x33b0, 0x7984, 0x9192, 0x0021, 0x1a04, 0x33b3,
+	0x604a, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x1971, 0x200b,
+	0x0000, 0x2009, 0x002d, 0x2011, 0x5be2, 0x080c, 0x8230, 0x7984,
+	0x080c, 0x70ba, 0x1110, 0x2009, 0x00ff, 0x7a88, 0x080c, 0x43ab,
+	0x012e, 0x00ce, 0x002e, 0x0804, 0x339e, 0x7984, 0x080c, 0x622f,
+	0x2b08, 0x1904, 0x33d3, 0x0804, 0x339e, 0x81ff, 0x0120, 0x2009,
+	0x0001, 0x0804, 0x33d0, 0x60d8, 0xd0ac, 0x1130, 0xd09c, 0x1120,
+	0x2009, 0x0005, 0x0804, 0x33d0, 0x080c, 0x489a, 0x1120, 0x2009,
+	0x0002, 0x0804, 0x33d0, 0x7984, 0x9192, 0x0021, 0x1a04, 0x33d3,
 	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0x702a,
-	0xaf60, 0x7736, 0x080c, 0x48c3, 0x701f, 0x459d, 0x7880, 0x9086,
-	0x006e, 0x0110, 0x701f, 0x4e3e, 0x0005, 0x2009, 0x0080, 0x080c,
-	0x626b, 0x1118, 0x080c, 0x6666, 0x0120, 0x2021, 0x400a, 0x0804,
-	0x3380, 0x00d6, 0x0096, 0xa964, 0xaa6c, 0xab70, 0xac74, 0xad78,
-	0xae7c, 0xa884, 0x90be, 0x0100, 0x0904, 0x4636, 0x90be, 0x0112,
-	0x0904, 0x4636, 0x90be, 0x0113, 0x0904, 0x4636, 0x90be, 0x0114,
-	0x0904, 0x4636, 0x90be, 0x0117, 0x0904, 0x4636, 0x90be, 0x011a,
-	0x0904, 0x4636, 0x90be, 0x011c, 0x0904, 0x4636, 0x90be, 0x0121,
-	0x0904, 0x461d, 0x90be, 0x0131, 0x0904, 0x461d, 0x90be, 0x0171,
-	0x0904, 0x4636, 0x90be, 0x0173, 0x0904, 0x4636, 0x90be, 0x01a1,
-	0x1128, 0xa894, 0x8007, 0xa896, 0x0804, 0x4641, 0x90be, 0x0212,
-	0x0904, 0x462a, 0x90be, 0x0213, 0x05e8, 0x90be, 0x0214, 0x0500,
+	0xaf60, 0x7736, 0x080c, 0x48e3, 0x701f, 0x45bd, 0x7880, 0x9086,
+	0x006e, 0x0110, 0x701f, 0x4e5e, 0x0005, 0x2009, 0x0080, 0x080c,
+	0x628f, 0x1118, 0x080c, 0x668a, 0x0120, 0x2021, 0x400a, 0x0804,
+	0x33a0, 0x00d6, 0x0096, 0xa964, 0xaa6c, 0xab70, 0xac74, 0xad78,
+	0xae7c, 0xa884, 0x90be, 0x0100, 0x0904, 0x4656, 0x90be, 0x0112,
+	0x0904, 0x4656, 0x90be, 0x0113, 0x0904, 0x4656, 0x90be, 0x0114,
+	0x0904, 0x4656, 0x90be, 0x0117, 0x0904, 0x4656, 0x90be, 0x011a,
+	0x0904, 0x4656, 0x90be, 0x011c, 0x0904, 0x4656, 0x90be, 0x0121,
+	0x0904, 0x463d, 0x90be, 0x0131, 0x0904, 0x463d, 0x90be, 0x0171,
+	0x0904, 0x4656, 0x90be, 0x0173, 0x0904, 0x4656, 0x90be, 0x01a1,
+	0x1128, 0xa894, 0x8007, 0xa896, 0x0804, 0x4661, 0x90be, 0x0212,
+	0x0904, 0x464a, 0x90be, 0x0213, 0x05e8, 0x90be, 0x0214, 0x0500,
 	0x90be, 0x0217, 0x0188, 0x90be, 0x021a, 0x1120, 0xa89c, 0x8007,
 	0xa89e, 0x04e0, 0x90be, 0x021f, 0x05c8, 0x90be, 0x0300, 0x05b0,
-	0x009e, 0x00de, 0x0804, 0x33b3, 0x7028, 0x9080, 0x0010, 0x2098,
-	0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0007, 0x080c, 0x467f,
+	0x009e, 0x00de, 0x0804, 0x33d3, 0x7028, 0x9080, 0x0010, 0x2098,
+	0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0007, 0x080c, 0x469f,
 	0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8,
-	0x20a9, 0x0001, 0x080c, 0x467f, 0x00c8, 0x7028, 0x9080, 0x000c,
+	0x20a9, 0x0001, 0x080c, 0x469f, 0x00c8, 0x7028, 0x9080, 0x000c,
 	0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c,
-	0x468c, 0x00b8, 0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034,
-	0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x468c, 0x7028, 0x9080,
+	0x46ac, 0x00b8, 0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034,
+	0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x46ac, 0x7028, 0x9080,
 	0x000c, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001,
-	0x04f1, 0x00c6, 0x080c, 0x487a, 0x0550, 0xa868, 0xc0fd, 0xa86a,
+	0x04f1, 0x00c6, 0x080c, 0x489a, 0x0550, 0xa868, 0xc0fd, 0xa86a,
 	0xa867, 0x0119, 0x9006, 0xa882, 0xa87f, 0x0020, 0xa88b, 0x0001,
 	0x810b, 0xa9ae, 0xa8b2, 0xaab6, 0xabba, 0xacbe, 0xadc2, 0xa9c6,
 	0xa8ca, 0x00ce, 0x009e, 0x00de, 0xa866, 0xa822, 0xa868, 0xc0fd,
-	0xa86a, 0xa804, 0x2048, 0x080c, 0xb9d2, 0x1120, 0x2009, 0x0003,
-	0x0804, 0x33b0, 0x7007, 0x0003, 0x701f, 0x4676, 0x0005, 0x00ce,
-	0x009e, 0x00de, 0x2009, 0x0002, 0x0804, 0x33b0, 0xa820, 0x9086,
-	0x8001, 0x1904, 0x337e, 0x2009, 0x0004, 0x0804, 0x33b0, 0x0016,
+	0xa86a, 0xa804, 0x2048, 0x080c, 0xba00, 0x1120, 0x2009, 0x0003,
+	0x0804, 0x33d0, 0x7007, 0x0003, 0x701f, 0x4696, 0x0005, 0x00ce,
+	0x009e, 0x00de, 0x2009, 0x0002, 0x0804, 0x33d0, 0xa820, 0x9086,
+	0x8001, 0x1904, 0x339e, 0x2009, 0x0004, 0x0804, 0x33d0, 0x0016,
 	0x0026, 0x3510, 0x20a9, 0x0002, 0x4002, 0x4104, 0x4004, 0x8211,
 	0x1dc8, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026, 0x0036, 0x0046,
 	0x3520, 0x20a9, 0x0004, 0x4002, 0x4304, 0x4204, 0x4104, 0x4004,
 	0x8421, 0x1db8, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005, 0x81ff,
-	0x0120, 0x2009, 0x0001, 0x0804, 0x33b0, 0x60d8, 0xd0ac, 0x1160,
-	0xd09c, 0x0120, 0x2009, 0x0016, 0x0804, 0x33b0, 0xd09c, 0x1120,
-	0x2009, 0x0005, 0x0804, 0x33b0, 0x7984, 0x78a8, 0x2040, 0x080c,
-	0x9b59, 0x1120, 0x9182, 0x007f, 0x0a04, 0x33b3, 0x9186, 0x00ff,
-	0x0904, 0x33b3, 0x9182, 0x0800, 0x1a04, 0x33b3, 0x7a8c, 0x7b88,
-	0x6078, 0x9306, 0x1158, 0x607c, 0x924e, 0x0904, 0x33b3, 0x080c,
-	0x9b59, 0x1120, 0x99cc, 0xff00, 0x0904, 0x33b3, 0x0126, 0x2091,
-	0x8000, 0x0026, 0x2011, 0x8008, 0x080c, 0x668a, 0x002e, 0x0140,
-	0x918d, 0x8000, 0x080c, 0x66d4, 0x1118, 0x2001, 0x4009, 0x0458,
-	0x080c, 0x4794, 0x0560, 0x90c6, 0x4000, 0x1170, 0x00c6, 0x0006,
-	0x900e, 0x080c, 0x655e, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
+	0x0120, 0x2009, 0x0001, 0x0804, 0x33d0, 0x60d8, 0xd0ac, 0x1160,
+	0xd09c, 0x0120, 0x2009, 0x0016, 0x0804, 0x33d0, 0xd09c, 0x1120,
+	0x2009, 0x0005, 0x0804, 0x33d0, 0x7984, 0x78a8, 0x2040, 0x080c,
+	0x9b65, 0x1120, 0x9182, 0x007f, 0x0a04, 0x33d3, 0x9186, 0x00ff,
+	0x0904, 0x33d3, 0x9182, 0x0800, 0x1a04, 0x33d3, 0x7a8c, 0x7b88,
+	0x6078, 0x9306, 0x1158, 0x607c, 0x924e, 0x0904, 0x33d3, 0x080c,
+	0x9b65, 0x1120, 0x99cc, 0xff00, 0x0904, 0x33d3, 0x0126, 0x2091,
+	0x8000, 0x0026, 0x2011, 0x8008, 0x080c, 0x66ae, 0x002e, 0x0140,
+	0x918d, 0x8000, 0x080c, 0x66f8, 0x1118, 0x2001, 0x4009, 0x0458,
+	0x080c, 0x47b4, 0x0560, 0x90c6, 0x4000, 0x1170, 0x00c6, 0x0006,
+	0x900e, 0x080c, 0x6582, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
 	0xc18d, 0x000e, 0x00ce, 0x00b8, 0x90c6, 0x4007, 0x1110, 0x2408,
 	0x0090, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0060, 0x90c6,
 	0x4009, 0x1108, 0x0040, 0x90c6, 0x4006, 0x1108, 0x0020, 0x2001,
-	0x4005, 0x2009, 0x000a, 0x2020, 0x012e, 0x0804, 0x3380, 0x2b00,
-	0x7026, 0x0016, 0x00b6, 0x00c6, 0x00e6, 0x2c70, 0x080c, 0x9c49,
-	0x0904, 0x4761, 0x2b00, 0x6012, 0x080c, 0xbcdb, 0x2e58, 0x00ee,
-	0x00e6, 0x00c6, 0x080c, 0x487a, 0x00ce, 0x2b70, 0x1158, 0x080c,
-	0x9bda, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x2009, 0x0002,
-	0x0804, 0x33b0, 0x900e, 0xa966, 0xa96a, 0x2900, 0x6016, 0xa932,
-	0xa868, 0xc0fd, 0xd88c, 0x0108, 0xc0f5, 0xa86a, 0x080c, 0x300e,
-	0x6023, 0x0001, 0x9006, 0x080c, 0x61a8, 0x2001, 0x0002, 0x080c,
-	0x61bc, 0x2009, 0x0002, 0x080c, 0x9c76, 0x78a8, 0xd094, 0x0138,
+	0x4005, 0x2009, 0x000a, 0x2020, 0x012e, 0x0804, 0x33a0, 0x2b00,
+	0x7026, 0x0016, 0x00b6, 0x00c6, 0x00e6, 0x2c70, 0x080c, 0x9c55,
+	0x0904, 0x4781, 0x2b00, 0x6012, 0x080c, 0xbd09, 0x2e58, 0x00ee,
+	0x00e6, 0x00c6, 0x080c, 0x489a, 0x00ce, 0x2b70, 0x1158, 0x080c,
+	0x9be6, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x2009, 0x0002,
+	0x0804, 0x33d0, 0x900e, 0xa966, 0xa96a, 0x2900, 0x6016, 0xa932,
+	0xa868, 0xc0fd, 0xd88c, 0x0108, 0xc0f5, 0xa86a, 0x080c, 0x302e,
+	0x6023, 0x0001, 0x9006, 0x080c, 0x61cc, 0x2001, 0x0002, 0x080c,
+	0x61e0, 0x2009, 0x0002, 0x080c, 0x9c82, 0x78a8, 0xd094, 0x0138,
 	0x00ee, 0x7024, 0x00e6, 0x2058, 0xb8c4, 0xc08d, 0xb8c6, 0x9085,
 	0x0001, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x1120, 0x2009,
-	0x0003, 0x0804, 0x33b0, 0x7007, 0x0003, 0x701f, 0x4770, 0x0005,
+	0x0003, 0x0804, 0x33d0, 0x7007, 0x0003, 0x701f, 0x4790, 0x0005,
 	0xa830, 0x2008, 0x918e, 0xdead, 0x1120, 0x2021, 0x4009, 0x0804,
-	0x3380, 0x9086, 0x0100, 0x7024, 0x2058, 0x1138, 0x2009, 0x0004,
-	0xba04, 0x9294, 0x00ff, 0x0804, 0x52e5, 0x900e, 0xa868, 0xd0f4,
-	0x1904, 0x337e, 0x080c, 0x655e, 0x1108, 0xc185, 0xb800, 0xd0bc,
-	0x0108, 0xc18d, 0x0804, 0x337e, 0x00e6, 0x00d6, 0x0096, 0x83ff,
-	0x0904, 0x47dc, 0x902e, 0x080c, 0x9b59, 0x0130, 0x9026, 0x20a9,
+	0x33a0, 0x9086, 0x0100, 0x7024, 0x2058, 0x1138, 0x2009, 0x0004,
+	0xba04, 0x9294, 0x00ff, 0x0804, 0x5305, 0x900e, 0xa868, 0xd0f4,
+	0x1904, 0x339e, 0x080c, 0x6582, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0x0804, 0x339e, 0x00e6, 0x00d6, 0x0096, 0x83ff,
+	0x0904, 0x47fc, 0x902e, 0x080c, 0x9b65, 0x0130, 0x9026, 0x20a9,
 	0x0800, 0x2071, 0x1000, 0x0030, 0x2021, 0x007f, 0x20a9, 0x0781,
 	0x2071, 0x107f, 0x2e04, 0x9005, 0x11b0, 0x2100, 0x9406, 0x15e8,
 	0x2428, 0x94ce, 0x007f, 0x1120, 0x92ce, 0xfffd, 0x1528, 0x0030,
 	0x94ce, 0x0080, 0x1130, 0x92ce, 0xfffc, 0x11f0, 0x93ce, 0x00ff,
 	0x11d8, 0xc5fd, 0x0450, 0x2058, 0xbf10, 0x2700, 0x9306, 0x11b8,
 	0xbe14, 0x2600, 0x9206, 0x1198, 0x2400, 0x9106, 0x1150, 0xd884,
-	0x0568, 0xd894, 0x1558, 0x080c, 0x6666, 0x1540, 0x2001, 0x4000,
+	0x0568, 0xd894, 0x1558, 0x080c, 0x668a, 0x1540, 0x2001, 0x4000,
 	0x0430, 0x2001, 0x4007, 0x0418, 0x2001, 0x4006, 0x0400, 0x2400,
 	0x9106, 0x1158, 0xbe14, 0x87ff, 0x1128, 0x86ff, 0x0948, 0x080c,
-	0x9b59, 0x1930, 0x2001, 0x4008, 0x0090, 0x8420, 0x8e70, 0x1f04,
-	0x47aa, 0x85ff, 0x1130, 0x2001, 0x4009, 0x0048, 0x2001, 0x0001,
-	0x0030, 0x080c, 0x620b, 0x1dd0, 0xbb12, 0xba16, 0x9006, 0x9005,
+	0x9b65, 0x1930, 0x2001, 0x4008, 0x0090, 0x8420, 0x8e70, 0x1f04,
+	0x47ca, 0x85ff, 0x1130, 0x2001, 0x4009, 0x0048, 0x2001, 0x0001,
+	0x0030, 0x080c, 0x622f, 0x1dd0, 0xbb12, 0xba16, 0x9006, 0x9005,
 	0x009e, 0x00de, 0x00ee, 0x0005, 0x81ff, 0x0120, 0x2009, 0x0001,
-	0x0804, 0x33b0, 0x080c, 0x487a, 0x1120, 0x2009, 0x0002, 0x0804,
-	0x33b0, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7884, 0x9005,
-	0x0904, 0x33b3, 0x9096, 0x00ff, 0x0120, 0x9092, 0x0004, 0x1a04,
-	0x33b3, 0x2010, 0x2918, 0x080c, 0x2fae, 0x1120, 0x2009, 0x0003,
-	0x0804, 0x33b0, 0x7007, 0x0003, 0x701f, 0x482f, 0x0005, 0xa830,
-	0x9086, 0x0100, 0x1904, 0x337e, 0x2009, 0x0004, 0x0804, 0x33b0,
-	0x7984, 0x080c, 0x9b59, 0x1120, 0x9182, 0x007f, 0x0a04, 0x33b3,
-	0x9186, 0x00ff, 0x0904, 0x33b3, 0x9182, 0x0800, 0x1a04, 0x33b3,
-	0x2001, 0x9000, 0x080c, 0x5340, 0x1904, 0x33b0, 0x0804, 0x337e,
-	0xa998, 0x080c, 0x9b59, 0x1118, 0x9182, 0x007f, 0x0280, 0x9186,
+	0x0804, 0x33d0, 0x080c, 0x489a, 0x1120, 0x2009, 0x0002, 0x0804,
+	0x33d0, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7884, 0x9005,
+	0x0904, 0x33d3, 0x9096, 0x00ff, 0x0120, 0x9092, 0x0004, 0x1a04,
+	0x33d3, 0x2010, 0x2918, 0x080c, 0x2fce, 0x1120, 0x2009, 0x0003,
+	0x0804, 0x33d0, 0x7007, 0x0003, 0x701f, 0x484f, 0x0005, 0xa830,
+	0x9086, 0x0100, 0x1904, 0x339e, 0x2009, 0x0004, 0x0804, 0x33d0,
+	0x7984, 0x080c, 0x9b65, 0x1120, 0x9182, 0x007f, 0x0a04, 0x33d3,
+	0x9186, 0x00ff, 0x0904, 0x33d3, 0x9182, 0x0800, 0x1a04, 0x33d3,
+	0x2001, 0x9000, 0x080c, 0x5360, 0x1904, 0x33d0, 0x0804, 0x339e,
+	0xa998, 0x080c, 0x9b65, 0x1118, 0x9182, 0x007f, 0x0280, 0x9186,
 	0x00ff, 0x0168, 0x9182, 0x0800, 0x1250, 0x2001, 0x9000, 0x080c,
-	0x5340, 0x11a8, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
+	0x5360, 0x11a8, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
 	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
 	0x4000, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x2009,
-	0x000a, 0x0c48, 0x080c, 0x1022, 0x0198, 0x9006, 0xa802, 0x7014,
+	0x000a, 0x0c48, 0x080c, 0x102f, 0x0198, 0x9006, 0xa802, 0x7014,
 	0x9005, 0x1120, 0x2900, 0x7016, 0x701a, 0x0040, 0x7018, 0xa802,
 	0x0086, 0x2040, 0x2900, 0xa006, 0x701a, 0x008e, 0x9085, 0x0001,
-	0x0005, 0x7984, 0x080c, 0x626b, 0x1130, 0x7e88, 0x9684, 0x3fff,
+	0x0005, 0x7984, 0x080c, 0x628f, 0x1130, 0x7e88, 0x9684, 0x3fff,
 	0x9082, 0x4000, 0x0208, 0x905e, 0x8bff, 0x0005, 0xa998, 0x080c,
-	0x626b, 0x1130, 0xae9c, 0x9684, 0x3fff, 0x9082, 0x4000, 0x0208,
+	0x628f, 0x1130, 0xae9c, 0x9684, 0x3fff, 0x9082, 0x4000, 0x0208,
 	0x905e, 0x8bff, 0x0005, 0xae98, 0x0008, 0x7e84, 0x2608, 0x080c,
-	0x626b, 0x1108, 0x0008, 0x905e, 0x8bff, 0x0005, 0x0016, 0x7114,
-	0x81ff, 0x0128, 0x2148, 0xa904, 0x080c, 0x1054, 0x0cc8, 0x7116,
+	0x628f, 0x1108, 0x0008, 0x905e, 0x8bff, 0x0005, 0x0016, 0x7114,
+	0x81ff, 0x0128, 0x2148, 0xa904, 0x080c, 0x1061, 0x0cc8, 0x7116,
 	0x711a, 0x001e, 0x0005, 0x2031, 0x0001, 0x0010, 0x2031, 0x0000,
-	0x2061, 0x18ae, 0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e,
-	0xa392, 0xa496, 0xa59a, 0x080c, 0x1117, 0x7007, 0x0002, 0x701f,
-	0x337e, 0x0005, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2079, 0x0000,
-	0x2001, 0x18a6, 0x2004, 0x9005, 0x1190, 0x0e04, 0x48f7, 0x7a36,
+	0x2061, 0x18b6, 0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e,
+	0xa392, 0xa496, 0xa59a, 0x080c, 0x1124, 0x7007, 0x0002, 0x701f,
+	0x339e, 0x0005, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2079, 0x0000,
+	0x2001, 0x18ae, 0x2004, 0x9005, 0x1190, 0x0e04, 0x4917, 0x7a36,
 	0x7833, 0x0012, 0x7a82, 0x7b86, 0x7c8a, 0x2091, 0x4080, 0x2001,
-	0x0089, 0x2004, 0xd084, 0x190c, 0x11c9, 0x0804, 0x495d, 0x0016,
-	0x0086, 0x0096, 0x00c6, 0x00e6, 0x2071, 0x1894, 0x7044, 0x9005,
+	0x0089, 0x2004, 0xd084, 0x190c, 0x11d6, 0x0804, 0x497d, 0x0016,
+	0x0086, 0x0096, 0x00c6, 0x00e6, 0x2071, 0x189c, 0x7044, 0x9005,
 	0x1540, 0x7148, 0x9182, 0x0010, 0x0288, 0x7038, 0x2060, 0x080c,
-	0x1022, 0x0904, 0x4955, 0xa84b, 0x0000, 0x2900, 0x7046, 0x2001,
-	0x0002, 0x9080, 0x1d04, 0x2005, 0xa846, 0x0098, 0x7038, 0x90e0,
-	0x0004, 0x2001, 0x18b0, 0x9c82, 0x18f0, 0x0210, 0x2061, 0x18b0,
+	0x102f, 0x0904, 0x4975, 0xa84b, 0x0000, 0x2900, 0x7046, 0x2001,
+	0x0002, 0x9080, 0x1d1c, 0x2005, 0xa846, 0x0098, 0x7038, 0x90e0,
+	0x0004, 0x2001, 0x18b8, 0x9c82, 0x18f8, 0x0210, 0x2061, 0x18b8,
 	0x2c00, 0x703a, 0x7148, 0x81ff, 0x1108, 0x703e, 0x8108, 0x714a,
 	0x0460, 0x7148, 0x8108, 0x714a, 0x7044, 0x2040, 0xa144, 0x2105,
 	0x0016, 0x908a, 0x0036, 0x1a0c, 0x0d65, 0x2060, 0x001e, 0x8108,
-	0x2105, 0x9005, 0xa146, 0x1520, 0x080c, 0x1022, 0x1130, 0x8109,
+	0x2105, 0x9005, 0xa146, 0x1520, 0x080c, 0x102f, 0x1130, 0x8109,
 	0xa946, 0x7148, 0x8109, 0x714a, 0x00d8, 0x9006, 0xa806, 0xa84a,
 	0xa046, 0x2800, 0xa802, 0x2900, 0xa006, 0x7046, 0x2001, 0x0002,
-	0x9080, 0x1d04, 0x2005, 0xa846, 0x0058, 0x2262, 0x6306, 0x640a,
+	0x9080, 0x1d1c, 0x2005, 0xa846, 0x0058, 0x2262, 0x6306, 0x640a,
 	0x00ee, 0x00ce, 0x009e, 0x008e, 0x001e, 0x012e, 0x00fe, 0x0005,
-	0x2c00, 0x9082, 0x001b, 0x0002, 0x497f, 0x497f, 0x4981, 0x497f,
-	0x497f, 0x497f, 0x4985, 0x497f, 0x497f, 0x497f, 0x4989, 0x497f,
-	0x497f, 0x497f, 0x498d, 0x497f, 0x497f, 0x497f, 0x4991, 0x497f,
-	0x497f, 0x497f, 0x4995, 0x497f, 0x497f, 0x497f, 0x499a, 0x080c,
+	0x2c00, 0x9082, 0x001b, 0x0002, 0x499f, 0x499f, 0x49a1, 0x499f,
+	0x499f, 0x499f, 0x49a5, 0x499f, 0x499f, 0x499f, 0x49a9, 0x499f,
+	0x499f, 0x499f, 0x49ad, 0x499f, 0x499f, 0x499f, 0x49b1, 0x499f,
+	0x499f, 0x499f, 0x49b5, 0x499f, 0x499f, 0x499f, 0x49ba, 0x080c,
 	0x0d65, 0xa276, 0xa37a, 0xa47e, 0x0898, 0xa286, 0xa38a, 0xa48e,
 	0x0878, 0xa296, 0xa39a, 0xa49e, 0x0858, 0xa2a6, 0xa3aa, 0xa4ae,
 	0x0838, 0xa2b6, 0xa3ba, 0xa4be, 0x0818, 0xa2c6, 0xa3ca, 0xa4ce,
-	0x0804, 0x4958, 0xa2d6, 0xa3da, 0xa4de, 0x0804, 0x4958, 0x00e6,
-	0x2071, 0x1894, 0x7048, 0x9005, 0x0904, 0x4a31, 0x0126, 0x2091,
-	0x8000, 0x0e04, 0x4a30, 0x00f6, 0x2079, 0x0000, 0x00c6, 0x0096,
+	0x0804, 0x4978, 0xa2d6, 0xa3da, 0xa4de, 0x0804, 0x4978, 0x00e6,
+	0x2071, 0x189c, 0x7048, 0x9005, 0x0904, 0x4a51, 0x0126, 0x2091,
+	0x8000, 0x0e04, 0x4a50, 0x00f6, 0x2079, 0x0000, 0x00c6, 0x0096,
 	0x0086, 0x0076, 0x9006, 0x2038, 0x7040, 0x2048, 0x9005, 0x0500,
 	0xa948, 0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c, 0x0d65, 0x2060,
-	0x001e, 0x8108, 0x2105, 0x9005, 0xa94a, 0x1904, 0x4a33, 0xa804,
+	0x001e, 0x8108, 0x2105, 0x9005, 0xa94a, 0x1904, 0x4a53, 0xa804,
 	0x9005, 0x090c, 0x0d65, 0x7042, 0x2938, 0x2040, 0xa003, 0x0000,
-	0x2001, 0x0002, 0x9080, 0x1d04, 0x2005, 0xa04a, 0x0804, 0x4a33,
+	0x2001, 0x0002, 0x9080, 0x1d1c, 0x2005, 0xa04a, 0x0804, 0x4a53,
 	0x703c, 0x2060, 0x2c14, 0x6304, 0x6408, 0x650c, 0x2200, 0x7836,
 	0x7833, 0x0012, 0x7882, 0x2300, 0x7886, 0x2400, 0x788a, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11c9, 0x87ff,
-	0x0118, 0x2748, 0x080c, 0x1054, 0x7048, 0x8001, 0x704a, 0x9005,
-	0x1170, 0x7040, 0x2048, 0x9005, 0x0128, 0x080c, 0x1054, 0x9006,
-	0x7042, 0x7046, 0x703b, 0x18b0, 0x703f, 0x18b0, 0x0420, 0x7040,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11d6, 0x87ff,
+	0x0118, 0x2748, 0x080c, 0x1061, 0x7048, 0x8001, 0x704a, 0x9005,
+	0x1170, 0x7040, 0x2048, 0x9005, 0x0128, 0x080c, 0x1061, 0x9006,
+	0x7042, 0x7046, 0x703b, 0x18b8, 0x703f, 0x18b8, 0x0420, 0x7040,
 	0x9005, 0x1508, 0x7238, 0x2c00, 0x9206, 0x0148, 0x9c80, 0x0004,
-	0x90fa, 0x18f0, 0x0210, 0x2001, 0x18b0, 0x703e, 0x00a0, 0x9006,
+	0x90fa, 0x18f8, 0x0210, 0x2001, 0x18b8, 0x703e, 0x00a0, 0x9006,
 	0x703e, 0x703a, 0x7044, 0x9005, 0x090c, 0x0d65, 0x2048, 0xa800,
-	0x9005, 0x1de0, 0x2900, 0x7042, 0x2001, 0x0002, 0x9080, 0x1d04,
+	0x9005, 0x1de0, 0x2900, 0x7042, 0x2001, 0x0002, 0x9080, 0x1d1c,
 	0x2005, 0xa84a, 0x0000, 0x007e, 0x008e, 0x009e, 0x00ce, 0x00fe,
-	0x012e, 0x00ee, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002, 0x4a52,
-	0x4a52, 0x4a54, 0x4a52, 0x4a52, 0x4a52, 0x4a59, 0x4a52, 0x4a52,
-	0x4a52, 0x4a5e, 0x4a52, 0x4a52, 0x4a52, 0x4a63, 0x4a52, 0x4a52,
-	0x4a52, 0x4a68, 0x4a52, 0x4a52, 0x4a52, 0x4a6d, 0x4a52, 0x4a52,
-	0x4a52, 0x4a72, 0x080c, 0x0d65, 0xaa74, 0xab78, 0xac7c, 0x0804,
-	0x49de, 0xaa84, 0xab88, 0xac8c, 0x0804, 0x49de, 0xaa94, 0xab98,
-	0xac9c, 0x0804, 0x49de, 0xaaa4, 0xaba8, 0xacac, 0x0804, 0x49de,
-	0xaab4, 0xabb8, 0xacbc, 0x0804, 0x49de, 0xaac4, 0xabc8, 0xaccc,
-	0x0804, 0x49de, 0xaad4, 0xabd8, 0xacdc, 0x0804, 0x49de, 0x0026,
-	0x080c, 0x5388, 0xd0c4, 0x0120, 0x2011, 0x8014, 0x080c, 0x48da,
-	0x002e, 0x0005, 0x81ff, 0x1904, 0x33b0, 0x0126, 0x2091, 0x8000,
-	0x6030, 0xc08d, 0xc085, 0xc0ac, 0x6032, 0x080c, 0x7096, 0x1158,
-	0x080c, 0x7396, 0x080c, 0x5cd7, 0x9085, 0x0001, 0x080c, 0x70dd,
-	0x080c, 0x6fc7, 0x0010, 0x080c, 0x5b92, 0x012e, 0x0804, 0x337e,
-	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x33b0, 0x080c, 0x539c,
-	0x0120, 0x2009, 0x0007, 0x0804, 0x33b0, 0x080c, 0x665e, 0x0120,
-	0x2009, 0x0008, 0x0804, 0x33b0, 0x0026, 0x2011, 0x0010, 0x080c,
-	0x668a, 0x002e, 0x0140, 0x7984, 0x080c, 0x66d4, 0x1120, 0x2009,
-	0x4009, 0x0804, 0x33b0, 0x7984, 0x080c, 0x620b, 0x1904, 0x33b3,
-	0x2b00, 0x7026, 0x080c, 0x6666, 0x7888, 0x1170, 0x9084, 0x0005,
-	0x1158, 0x900e, 0x080c, 0x655e, 0x1108, 0xc185, 0xb800, 0xd0bc,
-	0x0108, 0xc18d, 0x0804, 0x337e, 0x080c, 0x487a, 0x0904, 0x33b0,
-	0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xba79,
-	0x0904, 0x33b0, 0x7888, 0xd094, 0x0118, 0xb8c4, 0xc08d, 0xb8c6,
-	0x7007, 0x0003, 0x701f, 0x4b41, 0x0005, 0x2061, 0x1800, 0x080c,
-	0x539c, 0x2009, 0x0007, 0x1578, 0x080c, 0x665e, 0x0118, 0x2009,
-	0x0008, 0x0448, 0x080c, 0x3175, 0x0120, 0xa998, 0x080c, 0x620b,
-	0x1530, 0x080c, 0x48ab, 0x0518, 0x080c, 0x6666, 0xa89c, 0x1168,
-	0x9084, 0x0005, 0x1150, 0x900e, 0x080c, 0x655e, 0x1108, 0xc185,
+	0x012e, 0x00ee, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002, 0x4a72,
+	0x4a72, 0x4a74, 0x4a72, 0x4a72, 0x4a72, 0x4a79, 0x4a72, 0x4a72,
+	0x4a72, 0x4a7e, 0x4a72, 0x4a72, 0x4a72, 0x4a83, 0x4a72, 0x4a72,
+	0x4a72, 0x4a88, 0x4a72, 0x4a72, 0x4a72, 0x4a8d, 0x4a72, 0x4a72,
+	0x4a72, 0x4a92, 0x080c, 0x0d65, 0xaa74, 0xab78, 0xac7c, 0x0804,
+	0x49fe, 0xaa84, 0xab88, 0xac8c, 0x0804, 0x49fe, 0xaa94, 0xab98,
+	0xac9c, 0x0804, 0x49fe, 0xaaa4, 0xaba8, 0xacac, 0x0804, 0x49fe,
+	0xaab4, 0xabb8, 0xacbc, 0x0804, 0x49fe, 0xaac4, 0xabc8, 0xaccc,
+	0x0804, 0x49fe, 0xaad4, 0xabd8, 0xacdc, 0x0804, 0x49fe, 0x0026,
+	0x080c, 0x53a8, 0xd0c4, 0x0120, 0x2011, 0x8014, 0x080c, 0x48fa,
+	0x002e, 0x0005, 0x81ff, 0x1904, 0x33d0, 0x0126, 0x2091, 0x8000,
+	0x6030, 0xc08d, 0xc085, 0xc0ac, 0x6032, 0x080c, 0x70ba, 0x1158,
+	0x080c, 0x73b9, 0x080c, 0x5cf7, 0x9085, 0x0001, 0x080c, 0x7101,
+	0x080c, 0x6feb, 0x0010, 0x080c, 0x5bb2, 0x012e, 0x0804, 0x339e,
+	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x33d0, 0x080c, 0x53bc,
+	0x0120, 0x2009, 0x0007, 0x0804, 0x33d0, 0x080c, 0x6682, 0x0120,
+	0x2009, 0x0008, 0x0804, 0x33d0, 0x0026, 0x2011, 0x0010, 0x080c,
+	0x66ae, 0x002e, 0x0140, 0x7984, 0x080c, 0x66f8, 0x1120, 0x2009,
+	0x4009, 0x0804, 0x33d0, 0x7984, 0x080c, 0x622f, 0x1904, 0x33d3,
+	0x2b00, 0x7026, 0x080c, 0x668a, 0x7888, 0x1170, 0x9084, 0x0005,
+	0x1158, 0x900e, 0x080c, 0x6582, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0x0804, 0x339e, 0x080c, 0x489a, 0x0904, 0x33d0,
+	0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xbaa7,
+	0x0904, 0x33d0, 0x7888, 0xd094, 0x0118, 0xb8c4, 0xc08d, 0xb8c6,
+	0x7007, 0x0003, 0x701f, 0x4b61, 0x0005, 0x2061, 0x1800, 0x080c,
+	0x53bc, 0x2009, 0x0007, 0x1578, 0x080c, 0x6682, 0x0118, 0x2009,
+	0x0008, 0x0448, 0x080c, 0x3195, 0x0120, 0xa998, 0x080c, 0x622f,
+	0x1530, 0x080c, 0x48cb, 0x0518, 0x080c, 0x668a, 0xa89c, 0x1168,
+	0x9084, 0x0005, 0x1150, 0x900e, 0x080c, 0x6582, 0x1108, 0xc185,
 	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x00d0, 0xa868, 0xc0fc, 0xa86a,
-	0x080c, 0xba79, 0x11e0, 0xa89c, 0xd094, 0x0118, 0xb8c4, 0xc08d,
+	0x080c, 0xbaa7, 0x11e0, 0xa89c, 0xd094, 0x0118, 0xb8c4, 0xc08d,
 	0xb8c6, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
 	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
 	0x4000, 0xa99a, 0x9006, 0x918d, 0x0001, 0x2008, 0x0005, 0x9006,
 	0x0005, 0xa830, 0x2008, 0x918e, 0xdead, 0x1120, 0x2021, 0x4009,
-	0x0804, 0x3380, 0x9086, 0x0100, 0x7024, 0x2058, 0x1110, 0x0804,
-	0x52e5, 0x900e, 0x080c, 0x655e, 0x1108, 0xc185, 0xb800, 0xd0bc,
-	0x0108, 0xc18d, 0x0804, 0x337e, 0x080c, 0x539c, 0x0120, 0x2009,
-	0x0007, 0x0804, 0x33b0, 0x7f84, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
-	0x080c, 0x487a, 0x1120, 0x2009, 0x0002, 0x0804, 0x33b0, 0x900e,
+	0x0804, 0x33a0, 0x9086, 0x0100, 0x7024, 0x2058, 0x1110, 0x0804,
+	0x5305, 0x900e, 0x080c, 0x6582, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0x0804, 0x339e, 0x080c, 0x53bc, 0x0120, 0x2009,
+	0x0007, 0x0804, 0x33d0, 0x7f84, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
+	0x080c, 0x489a, 0x1120, 0x2009, 0x0002, 0x0804, 0x33d0, 0x900e,
 	0x2130, 0x7126, 0x7132, 0xa860, 0x20e8, 0x7036, 0xa85c, 0x9080,
-	0x0005, 0x702a, 0x20a0, 0x080c, 0x626b, 0x1904, 0x4bdf, 0x080c,
-	0x6666, 0x0120, 0x080c, 0x666e, 0x1904, 0x4bdf, 0x080c, 0x665e,
-	0x1130, 0x080c, 0x655e, 0x1118, 0xd79c, 0x0904, 0x4bdf, 0xd794,
+	0x0005, 0x702a, 0x20a0, 0x080c, 0x628f, 0x1904, 0x4bff, 0x080c,
+	0x668a, 0x0120, 0x080c, 0x6692, 0x1904, 0x4bff, 0x080c, 0x6682,
+	0x1130, 0x080c, 0x6582, 0x1118, 0xd79c, 0x0904, 0x4bff, 0xd794,
 	0x1110, 0xd784, 0x01a8, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006,
 	0x2098, 0x3400, 0xd794, 0x0160, 0x20a9, 0x0008, 0x4003, 0x2098,
-	0x20a0, 0x3d00, 0x20e0, 0x20a9, 0x0002, 0x080c, 0x468c, 0x0048,
+	0x20a0, 0x3d00, 0x20e0, 0x20a9, 0x0002, 0x080c, 0x46ac, 0x0048,
 	0x20a9, 0x0004, 0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x080c,
-	0x468c, 0x4104, 0xd794, 0x0528, 0xb8b4, 0x20e0, 0xb8b8, 0x2060,
+	0x46ac, 0x4104, 0xd794, 0x0528, 0xb8b4, 0x20e0, 0xb8b8, 0x2060,
 	0x9c80, 0x0000, 0x2098, 0x20a9, 0x0002, 0x4003, 0x9c80, 0x0003,
 	0x2098, 0x20a9, 0x0001, 0x4005, 0x9c80, 0x0004, 0x2098, 0x3400,
 	0x20a9, 0x0002, 0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x080c,
-	0x467f, 0x9c80, 0x0026, 0x2098, 0xb8b4, 0x20e0, 0x20a9, 0x0002,
+	0x469f, 0x9c80, 0x0026, 0x2098, 0xb8b4, 0x20e0, 0x20a9, 0x0002,
 	0x4003, 0xd794, 0x0110, 0x96b0, 0x000b, 0x96b0, 0x0005, 0x8108,
-	0x080c, 0x9b59, 0x0118, 0x9186, 0x0800, 0x0040, 0xd78c, 0x0120,
+	0x080c, 0x9b65, 0x0118, 0x9186, 0x0800, 0x0040, 0xd78c, 0x0120,
 	0x9186, 0x0800, 0x0170, 0x0018, 0x9186, 0x007e, 0x0150, 0xd794,
 	0x0118, 0x9686, 0x0020, 0x0010, 0x9686, 0x0028, 0x0150, 0x0804,
-	0x4b7b, 0x86ff, 0x1120, 0x7124, 0x810b, 0x0804, 0x337e, 0x7033,
-	0x0001, 0x7122, 0x7024, 0x9600, 0x7026, 0x772e, 0x2061, 0x18ae,
+	0x4b9b, 0x86ff, 0x1120, 0x7124, 0x810b, 0x0804, 0x339e, 0x7033,
+	0x0001, 0x7122, 0x7024, 0x9600, 0x7026, 0x772e, 0x2061, 0x18b6,
 	0x2c44, 0xa06b, 0x0000, 0xa67a, 0x7034, 0xa072, 0x7028, 0xa076,
-	0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x1117, 0x7007, 0x0002,
-	0x701f, 0x4c1b, 0x0005, 0x7030, 0x9005, 0x1180, 0x7120, 0x7028,
-	0x20a0, 0x772c, 0x9036, 0x7034, 0x20e8, 0x2061, 0x18ae, 0x2c44,
-	0xa28c, 0xa390, 0xa494, 0xa598, 0x0804, 0x4b7b, 0x7124, 0x810b,
-	0x0804, 0x337e, 0x2029, 0x007e, 0x7984, 0x7a88, 0x7b8c, 0x7c98,
-	0x9184, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x33b3, 0x9502,
-	0x0a04, 0x33b3, 0x9184, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x33b3,
-	0x9502, 0x0a04, 0x33b3, 0x9284, 0xff00, 0x8007, 0x90e2, 0x0020,
-	0x0a04, 0x33b3, 0x9502, 0x0a04, 0x33b3, 0x9284, 0x00ff, 0x90e2,
-	0x0020, 0x0a04, 0x33b3, 0x9502, 0x0a04, 0x33b3, 0x9384, 0xff00,
-	0x8007, 0x90e2, 0x0020, 0x0a04, 0x33b3, 0x9502, 0x0a04, 0x33b3,
-	0x9384, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x33b3, 0x9502, 0x0a04,
-	0x33b3, 0x9484, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x33b3,
-	0x9502, 0x0a04, 0x33b3, 0x9484, 0x00ff, 0x90e2, 0x0020, 0x0a04,
-	0x33b3, 0x9502, 0x0a04, 0x33b3, 0x2061, 0x1959, 0x6102, 0x6206,
-	0x630a, 0x640e, 0x0804, 0x337e, 0x0006, 0x080c, 0x5388, 0xd0cc,
-	0x000e, 0x0005, 0x0006, 0x080c, 0x538c, 0xd0bc, 0x000e, 0x0005,
-	0x6170, 0x7a84, 0x6300, 0x82ff, 0x1118, 0x7986, 0x0804, 0x337e,
-	0x83ff, 0x1904, 0x33b3, 0x2001, 0xfff0, 0x9200, 0x1a04, 0x33b3,
-	0x2019, 0xffff, 0x6074, 0x9302, 0x9200, 0x0a04, 0x33b3, 0x7986,
-	0x6272, 0x0804, 0x337e, 0x080c, 0x539c, 0x1904, 0x33b0, 0x7c88,
-	0x7d84, 0x7e98, 0x7f8c, 0x080c, 0x487a, 0x0904, 0x33b0, 0x900e,
+	0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x1124, 0x7007, 0x0002,
+	0x701f, 0x4c3b, 0x0005, 0x7030, 0x9005, 0x1180, 0x7120, 0x7028,
+	0x20a0, 0x772c, 0x9036, 0x7034, 0x20e8, 0x2061, 0x18b6, 0x2c44,
+	0xa28c, 0xa390, 0xa494, 0xa598, 0x0804, 0x4b9b, 0x7124, 0x810b,
+	0x0804, 0x339e, 0x2029, 0x007e, 0x7984, 0x7a88, 0x7b8c, 0x7c98,
+	0x9184, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x33d3, 0x9502,
+	0x0a04, 0x33d3, 0x9184, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x33d3,
+	0x9502, 0x0a04, 0x33d3, 0x9284, 0xff00, 0x8007, 0x90e2, 0x0020,
+	0x0a04, 0x33d3, 0x9502, 0x0a04, 0x33d3, 0x9284, 0x00ff, 0x90e2,
+	0x0020, 0x0a04, 0x33d3, 0x9502, 0x0a04, 0x33d3, 0x9384, 0xff00,
+	0x8007, 0x90e2, 0x0020, 0x0a04, 0x33d3, 0x9502, 0x0a04, 0x33d3,
+	0x9384, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x33d3, 0x9502, 0x0a04,
+	0x33d3, 0x9484, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x33d3,
+	0x9502, 0x0a04, 0x33d3, 0x9484, 0x00ff, 0x90e2, 0x0020, 0x0a04,
+	0x33d3, 0x9502, 0x0a04, 0x33d3, 0x2061, 0x1961, 0x6102, 0x6206,
+	0x630a, 0x640e, 0x0804, 0x339e, 0x0006, 0x080c, 0x53a8, 0xd0cc,
+	0x000e, 0x0005, 0x0006, 0x080c, 0x53ac, 0xd0bc, 0x000e, 0x0005,
+	0x6170, 0x7a84, 0x6300, 0x82ff, 0x1118, 0x7986, 0x0804, 0x339e,
+	0x83ff, 0x1904, 0x33d3, 0x2001, 0xfff0, 0x9200, 0x1a04, 0x33d3,
+	0x2019, 0xffff, 0x6074, 0x9302, 0x9200, 0x0a04, 0x33d3, 0x7986,
+	0x6272, 0x0804, 0x339e, 0x080c, 0x53bc, 0x1904, 0x33d0, 0x7c88,
+	0x7d84, 0x7e98, 0x7f8c, 0x080c, 0x489a, 0x0904, 0x33d0, 0x900e,
 	0x901e, 0x7326, 0x7332, 0xa860, 0x20e8, 0x7036, 0xa85c, 0x9080,
 	0x0003, 0x702a, 0x20a0, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178,
-	0x080c, 0x6666, 0x0118, 0x080c, 0x666e, 0x1148, 0x20a9, 0x0001,
+	0x080c, 0x668a, 0x0118, 0x080c, 0x6692, 0x1148, 0x20a9, 0x0001,
 	0xb814, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003, 0x8108,
 	0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x0170, 0x0c20, 0x83ff,
-	0x1148, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c, 0x83fb, 0x2208,
-	0x0804, 0x337e, 0x7033, 0x0001, 0x7122, 0x7024, 0x9300, 0x7026,
-	0x2061, 0x18ae, 0x2c44, 0xa06b, 0x0000, 0xa37a, 0x7028, 0xa076,
-	0x7034, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a, 0x080c, 0x1117,
-	0x7007, 0x0002, 0x701f, 0x4d0d, 0x0005, 0x7030, 0x9005, 0x1178,
-	0x7120, 0x7028, 0x20a0, 0x901e, 0x7034, 0x20e8, 0x2061, 0x18ae,
-	0x2c44, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0804, 0x4ccb, 0x7224,
-	0x900e, 0x2001, 0x0003, 0x080c, 0x83fb, 0x2208, 0x0804, 0x337e,
-	0x00f6, 0x00e6, 0x080c, 0x539c, 0x2009, 0x0007, 0x1904, 0x4da0,
-	0x2071, 0x1894, 0x745c, 0x84ff, 0x2009, 0x000e, 0x1904, 0x4da0,
-	0xac9c, 0xad98, 0xaea4, 0xafa0, 0x0096, 0x080c, 0x103b, 0x2009,
-	0x0002, 0x0904, 0x4da0, 0x2900, 0x705e, 0x900e, 0x901e, 0x7356,
+	0x1148, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c, 0x842f, 0x2208,
+	0x0804, 0x339e, 0x7033, 0x0001, 0x7122, 0x7024, 0x9300, 0x7026,
+	0x2061, 0x18b6, 0x2c44, 0xa06b, 0x0000, 0xa37a, 0x7028, 0xa076,
+	0x7034, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a, 0x080c, 0x1124,
+	0x7007, 0x0002, 0x701f, 0x4d2d, 0x0005, 0x7030, 0x9005, 0x1178,
+	0x7120, 0x7028, 0x20a0, 0x901e, 0x7034, 0x20e8, 0x2061, 0x18b6,
+	0x2c44, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0804, 0x4ceb, 0x7224,
+	0x900e, 0x2001, 0x0003, 0x080c, 0x842f, 0x2208, 0x0804, 0x339e,
+	0x00f6, 0x00e6, 0x080c, 0x53bc, 0x2009, 0x0007, 0x1904, 0x4dc0,
+	0x2071, 0x189c, 0x745c, 0x84ff, 0x2009, 0x000e, 0x1904, 0x4dc0,
+	0xac9c, 0xad98, 0xaea4, 0xafa0, 0x0096, 0x080c, 0x1048, 0x2009,
+	0x0002, 0x0904, 0x4dc0, 0x2900, 0x705e, 0x900e, 0x901e, 0x7356,
 	0x7362, 0xa860, 0x7066, 0xa85c, 0x9080, 0x0003, 0x705a, 0x20a0,
-	0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x6666, 0x0118,
-	0x080c, 0x666e, 0x1148, 0xb814, 0x20a9, 0x0001, 0x4004, 0xb810,
+	0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c, 0x668a, 0x0118,
+	0x080c, 0x6692, 0x1148, 0xb814, 0x20a9, 0x0001, 0x4004, 0xb810,
 	0x4004, 0x4104, 0x9398, 0x0003, 0x8108, 0x9182, 0x0800, 0x0120,
 	0x9386, 0x003c, 0x01e8, 0x0c20, 0x83ff, 0x11c0, 0x7254, 0x900e,
-	0x2001, 0x0003, 0x080c, 0x83fb, 0x2208, 0x009e, 0xa897, 0x4000,
-	0xa99a, 0x715c, 0x81ff, 0x090c, 0x0d65, 0x2148, 0x080c, 0x1054,
+	0x2001, 0x0003, 0x080c, 0x842f, 0x2208, 0x009e, 0xa897, 0x4000,
+	0xa99a, 0x715c, 0x81ff, 0x090c, 0x0d65, 0x2148, 0x080c, 0x1061,
 	0x9006, 0x705e, 0x918d, 0x0001, 0x2008, 0x0418, 0x7063, 0x0001,
-	0x7152, 0x7054, 0x9300, 0x7056, 0x2061, 0x18af, 0x2c44, 0xa37a,
+	0x7152, 0x7054, 0x9300, 0x7056, 0x2061, 0x18b7, 0x2c44, 0xa37a,
 	0x7058, 0xa076, 0x7064, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a,
-	0xa09f, 0x4dac, 0x000e, 0xa0a2, 0x080c, 0x1117, 0x9006, 0x0048,
+	0xa09f, 0x4dcc, 0x000e, 0xa0a2, 0x080c, 0x1124, 0x9006, 0x0048,
 	0x009e, 0xa897, 0x4005, 0xa99a, 0x900e, 0x9085, 0x0001, 0x2001,
 	0x0030, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0xa0a0, 0x904d, 0x090c,
-	0x0d65, 0x00e6, 0x2071, 0x1894, 0xa06c, 0x908e, 0x0100, 0x0138,
+	0x0d65, 0x00e6, 0x2071, 0x189c, 0xa06c, 0x908e, 0x0100, 0x0138,
 	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002, 0x00d8, 0x7060,
 	0x9005, 0x1158, 0x7150, 0x7058, 0x20a0, 0x901e, 0x7064, 0x20e8,
 	0xa48c, 0xa590, 0xa694, 0xa798, 0x0428, 0xa87b, 0x0000, 0xa883,
 	0x0000, 0xa897, 0x4000, 0x7254, 0x900e, 0x2001, 0x0003, 0x080c,
-	0x83fb, 0xaa9a, 0x715c, 0x81ff, 0x090c, 0x0d65, 0x2148, 0x080c,
-	0x1054, 0x705f, 0x0000, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x6991, 0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x00ee,
+	0x842f, 0xaa9a, 0x715c, 0x81ff, 0x090c, 0x0d65, 0x2148, 0x080c,
+	0x1061, 0x705f, 0x0000, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x69b5, 0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x00ee,
 	0x00fe, 0x0005, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c,
-	0x6666, 0x0118, 0x080c, 0x666e, 0x1148, 0xb814, 0x20a9, 0x0001,
+	0x668a, 0x0118, 0x080c, 0x6692, 0x1148, 0xb814, 0x20a9, 0x0001,
 	0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003, 0x8108, 0x9182,
 	0x0800, 0x0120, 0x9386, 0x003c, 0x0518, 0x0c20, 0x83ff, 0x11f0,
 	0x7154, 0x810c, 0xa99a, 0xa897, 0x4000, 0x715c, 0x81ff, 0x090c,
-	0x0d65, 0x2148, 0x080c, 0x1054, 0x9006, 0x705e, 0x918d, 0x0001,
-	0x2008, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000, 0x080c, 0x6991,
+	0x0d65, 0x2148, 0x080c, 0x1061, 0x9006, 0x705e, 0x918d, 0x0001,
+	0x2008, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000, 0x080c, 0x69b5,
 	0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x0070, 0x7063, 0x0001,
 	0x7152, 0x7054, 0x9300, 0x7056, 0xa37a, 0xa48e, 0xa592, 0xa696,
-	0xa79a, 0x080c, 0x1117, 0x9006, 0x00ee, 0x0005, 0x0096, 0xa88c,
+	0xa79a, 0x080c, 0x1124, 0x9006, 0x00ee, 0x0005, 0x0096, 0xa88c,
 	0x90be, 0x7000, 0x0148, 0x90be, 0x7100, 0x0130, 0x90be, 0x7200,
-	0x0118, 0x009e, 0x0804, 0x33b3, 0xa884, 0xa988, 0x080c, 0x243d,
-	0x1518, 0x080c, 0x620b, 0x1500, 0x7126, 0xbe12, 0xbd16, 0xae7c,
-	0x080c, 0x487a, 0x01c8, 0x080c, 0x487a, 0x01b0, 0x009e, 0xa867,
+	0x0118, 0x009e, 0x0804, 0x33d3, 0xa884, 0xa988, 0x080c, 0x2459,
+	0x1518, 0x080c, 0x622f, 0x1500, 0x7126, 0xbe12, 0xbd16, 0xae7c,
+	0x080c, 0x489a, 0x01c8, 0x080c, 0x489a, 0x01b0, 0x009e, 0xa867,
 	0x0000, 0xa868, 0xc0fd, 0xa86a, 0xa823, 0x0000, 0xa804, 0x2048,
-	0x080c, 0xb9f2, 0x1120, 0x2009, 0x0003, 0x0804, 0x33b0, 0x7007,
-	0x0003, 0x701f, 0x4e79, 0x0005, 0x009e, 0x2009, 0x0002, 0x0804,
-	0x33b0, 0x7124, 0x080c, 0x3116, 0xa820, 0x9086, 0x8001, 0x1120,
-	0x2009, 0x0004, 0x0804, 0x33b0, 0x2900, 0x7022, 0xa804, 0x0096,
+	0x080c, 0xba20, 0x1120, 0x2009, 0x0003, 0x0804, 0x33d0, 0x7007,
+	0x0003, 0x701f, 0x4e99, 0x0005, 0x009e, 0x2009, 0x0002, 0x0804,
+	0x33d0, 0x7124, 0x080c, 0x3136, 0xa820, 0x9086, 0x8001, 0x1120,
+	0x2009, 0x0004, 0x0804, 0x33d0, 0x2900, 0x7022, 0xa804, 0x0096,
 	0x2048, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
 	0x009e, 0x9080, 0x0002, 0x0076, 0x0006, 0x2098, 0x20a0, 0x27e0,
-	0x27e8, 0x20a9, 0x002a, 0x080c, 0x0f9f, 0xaa6c, 0xab70, 0xac74,
-	0xad78, 0x2061, 0x18ae, 0x2c44, 0xa06b, 0x0000, 0xae64, 0xaf8c,
+	0x27e8, 0x20a9, 0x002a, 0x080c, 0x0fac, 0xaa6c, 0xab70, 0xac74,
+	0xad78, 0x2061, 0x18b6, 0x2c44, 0xa06b, 0x0000, 0xae64, 0xaf8c,
 	0x97c6, 0x7000, 0x0118, 0x97c6, 0x7100, 0x1148, 0x96c2, 0x0004,
-	0x0600, 0x2009, 0x0004, 0x000e, 0x007e, 0x0804, 0x48c6, 0x97c6,
+	0x0600, 0x2009, 0x0004, 0x000e, 0x007e, 0x0804, 0x48e6, 0x97c6,
 	0x7200, 0x11b8, 0x96c2, 0x0054, 0x02a0, 0x000e, 0x007e, 0x2061,
-	0x18ae, 0x2c44, 0xa076, 0xa772, 0xa07b, 0x002a, 0xa28e, 0xa392,
-	0xa496, 0xa59a, 0x080c, 0x1117, 0x7007, 0x0002, 0x701f, 0x4ed5,
-	0x0005, 0x000e, 0x007e, 0x0804, 0x33b3, 0x7020, 0x2048, 0xa804,
+	0x18b6, 0x2c44, 0xa076, 0xa772, 0xa07b, 0x002a, 0xa28e, 0xa392,
+	0xa496, 0xa59a, 0x080c, 0x1124, 0x7007, 0x0002, 0x701f, 0x4ef5,
+	0x0005, 0x000e, 0x007e, 0x0804, 0x33d3, 0x7020, 0x2048, 0xa804,
 	0x2048, 0xa804, 0x2048, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
 	0x9084, 0xffc0, 0x9080, 0x0002, 0x2098, 0x20a0, 0x27e0, 0x27e8,
-	0x20a9, 0x002a, 0x080c, 0x0f9f, 0x2100, 0x2238, 0x2061, 0x18ae,
+	0x20a9, 0x002a, 0x080c, 0x0fac, 0x2100, 0x2238, 0x2061, 0x18b6,
 	0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x2009, 0x002a, 0x0804,
-	0x48c6, 0x81ff, 0x1904, 0x33b0, 0x798c, 0x2001, 0x194e, 0x918c,
-	0x8000, 0x2102, 0x080c, 0x4891, 0x0904, 0x33b3, 0x080c, 0x6666,
-	0x0120, 0x080c, 0x666e, 0x1904, 0x33b3, 0x080c, 0x6332, 0x0904,
-	0x33b0, 0x0126, 0x2091, 0x8000, 0x080c, 0x64cb, 0x012e, 0x0904,
-	0x33b0, 0x2001, 0x194e, 0x2004, 0xd0fc, 0x1904, 0x337e, 0x0804,
-	0x4328, 0xa9a0, 0x2001, 0x194e, 0x918c, 0x8000, 0xc18d, 0x2102,
-	0x080c, 0x489e, 0x01a0, 0x080c, 0x6666, 0x0118, 0x080c, 0x666e,
-	0x1170, 0x080c, 0x6332, 0x2009, 0x0002, 0x0128, 0x080c, 0x64cb,
+	0x48e6, 0x81ff, 0x1904, 0x33d0, 0x798c, 0x2001, 0x1956, 0x918c,
+	0x8000, 0x2102, 0x080c, 0x48b1, 0x0904, 0x33d3, 0x080c, 0x668a,
+	0x0120, 0x080c, 0x6692, 0x1904, 0x33d3, 0x080c, 0x6356, 0x0904,
+	0x33d0, 0x0126, 0x2091, 0x8000, 0x080c, 0x64ef, 0x012e, 0x0904,
+	0x33d0, 0x2001, 0x1956, 0x2004, 0xd0fc, 0x1904, 0x339e, 0x0804,
+	0x4348, 0xa9a0, 0x2001, 0x1956, 0x918c, 0x8000, 0xc18d, 0x2102,
+	0x080c, 0x48be, 0x01a0, 0x080c, 0x668a, 0x0118, 0x080c, 0x6692,
+	0x1170, 0x080c, 0x6356, 0x2009, 0x0002, 0x0128, 0x080c, 0x64ef,
 	0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
 	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
-	0x4000, 0x2001, 0x194e, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x5390,
+	0x4000, 0x2001, 0x1956, 0x2004, 0xd0fc, 0x1128, 0x080c, 0x53b0,
 	0x0110, 0x9006, 0x0018, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000,
-	0x0005, 0x78a8, 0xd08c, 0x1118, 0xd084, 0x0904, 0x429d, 0x080c,
-	0x48ad, 0x0904, 0x33b3, 0x080c, 0x487a, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x33b0, 0x080c, 0x6666, 0x0130, 0x908e, 0x0004, 0x0118,
+	0x0005, 0x78a8, 0xd08c, 0x1118, 0xd084, 0x0904, 0x42bd, 0x080c,
+	0x48cd, 0x0904, 0x33d3, 0x080c, 0x489a, 0x1120, 0x2009, 0x0002,
+	0x0804, 0x33d0, 0x080c, 0x668a, 0x0130, 0x908e, 0x0004, 0x0118,
 	0x908e, 0x0005, 0x15a0, 0x78a8, 0xd08c, 0x0120, 0xb800, 0xc08c,
-	0xb802, 0x0028, 0x080c, 0x5388, 0xd0b4, 0x0904, 0x42d7, 0x7884,
-	0x908e, 0x007e, 0x0904, 0x42d7, 0x908e, 0x007f, 0x0904, 0x42d7,
-	0x908e, 0x0080, 0x0904, 0x42d7, 0xb800, 0xd08c, 0x1904, 0x42d7,
-	0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xba11, 0x1120,
-	0x2009, 0x0003, 0x0804, 0x33b0, 0x7007, 0x0003, 0x701f, 0x4fa1,
-	0x0005, 0x080c, 0x48ad, 0x0904, 0x33b3, 0x0804, 0x42d7, 0x080c,
-	0x3175, 0x0108, 0x0005, 0x2009, 0x1833, 0x210c, 0x81ff, 0x0120,
-	0x2009, 0x0001, 0x0804, 0x33b0, 0x080c, 0x539c, 0x0120, 0x2009,
-	0x0007, 0x0804, 0x33b0, 0x080c, 0x665e, 0x0120, 0x2009, 0x0008,
-	0x0804, 0x33b0, 0xb89c, 0xd0a4, 0x1118, 0xd0ac, 0x1904, 0x42d7,
-	0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xba79,
-	0x1120, 0x2009, 0x0003, 0x0804, 0x33b0, 0x7007, 0x0003, 0x701f,
-	0x4fda, 0x0005, 0xa830, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004,
-	0x0804, 0x52e5, 0x080c, 0x48ad, 0x0904, 0x33b3, 0x0804, 0x4f73,
-	0x81ff, 0x2009, 0x0001, 0x1904, 0x33b0, 0x080c, 0x539c, 0x2009,
-	0x0007, 0x1904, 0x33b0, 0x080c, 0x665e, 0x0120, 0x2009, 0x0008,
-	0x0804, 0x33b0, 0x080c, 0x48ad, 0x0904, 0x33b3, 0x080c, 0x6666,
-	0x2009, 0x0009, 0x1904, 0x33b0, 0x080c, 0x487a, 0x2009, 0x0002,
-	0x0904, 0x33b0, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
+	0xb802, 0x0028, 0x080c, 0x53a8, 0xd0b4, 0x0904, 0x42f7, 0x7884,
+	0x908e, 0x007e, 0x0904, 0x42f7, 0x908e, 0x007f, 0x0904, 0x42f7,
+	0x908e, 0x0080, 0x0904, 0x42f7, 0xb800, 0xd08c, 0x1904, 0x42f7,
+	0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xba3f, 0x1120,
+	0x2009, 0x0003, 0x0804, 0x33d0, 0x7007, 0x0003, 0x701f, 0x4fc1,
+	0x0005, 0x080c, 0x48cd, 0x0904, 0x33d3, 0x0804, 0x42f7, 0x080c,
+	0x3195, 0x0108, 0x0005, 0x2009, 0x1833, 0x210c, 0x81ff, 0x0120,
+	0x2009, 0x0001, 0x0804, 0x33d0, 0x080c, 0x53bc, 0x0120, 0x2009,
+	0x0007, 0x0804, 0x33d0, 0x080c, 0x6682, 0x0120, 0x2009, 0x0008,
+	0x0804, 0x33d0, 0xb89c, 0xd0a4, 0x1118, 0xd0ac, 0x1904, 0x42f7,
+	0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xbaa7,
+	0x1120, 0x2009, 0x0003, 0x0804, 0x33d0, 0x7007, 0x0003, 0x701f,
+	0x4ffa, 0x0005, 0xa830, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004,
+	0x0804, 0x5305, 0x080c, 0x48cd, 0x0904, 0x33d3, 0x0804, 0x4f93,
+	0x81ff, 0x2009, 0x0001, 0x1904, 0x33d0, 0x080c, 0x53bc, 0x2009,
+	0x0007, 0x1904, 0x33d0, 0x080c, 0x6682, 0x0120, 0x2009, 0x0008,
+	0x0804, 0x33d0, 0x080c, 0x48cd, 0x0904, 0x33d3, 0x080c, 0x668a,
+	0x2009, 0x0009, 0x1904, 0x33d0, 0x080c, 0x489a, 0x2009, 0x0002,
+	0x0904, 0x33d0, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
 	0x7988, 0x9194, 0xff00, 0x918c, 0x00ff, 0x9006, 0x82ff, 0x1128,
 	0xc0ed, 0xa952, 0x798c, 0xa956, 0x0038, 0x928e, 0x0100, 0x1904,
-	0x33b3, 0xc0e5, 0xa952, 0xa956, 0xa83e, 0x080c, 0xbcdc, 0x2009,
-	0x0003, 0x0904, 0x33b0, 0x7007, 0x0003, 0x701f, 0x5030, 0x0005,
-	0xa830, 0x9086, 0x0100, 0x2009, 0x0004, 0x0904, 0x33b0, 0x0804,
-	0x337e, 0x7aa8, 0x9284, 0xc000, 0x0148, 0xd2ec, 0x01a0, 0x080c,
-	0x539c, 0x1188, 0x2009, 0x0014, 0x0804, 0x33b0, 0xd2dc, 0x1568,
-	0x81ff, 0x2009, 0x0001, 0x1904, 0x33b0, 0x080c, 0x539c, 0x2009,
-	0x0007, 0x1904, 0x33b0, 0xd2f4, 0x0130, 0x9284, 0x5000, 0x080c,
-	0x5363, 0x0804, 0x337e, 0xd2fc, 0x0158, 0x080c, 0x48ad, 0x0904,
-	0x33b3, 0x7984, 0x9284, 0x9000, 0x080c, 0x5340, 0x0804, 0x337e,
-	0x080c, 0x48ad, 0x0904, 0x33b3, 0xb804, 0x9084, 0x00ff, 0x9086,
-	0x0006, 0x2009, 0x0009, 0x1904, 0x5119, 0x080c, 0x487a, 0x2009,
-	0x0002, 0x0904, 0x5119, 0xa85c, 0x9080, 0x001b, 0xaf60, 0x2009,
-	0x0008, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c, 0x48c3, 0x701f,
-	0x508a, 0x0005, 0xa86c, 0x9086, 0x0500, 0x1138, 0xa870, 0x9005,
-	0x1120, 0xa874, 0x9084, 0xff00, 0x0110, 0x1904, 0x33b3, 0xa866,
-	0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0x48ad, 0x1110, 0x0804,
-	0x33b3, 0x2009, 0x0043, 0x080c, 0xbd44, 0x2009, 0x0003, 0x0904,
-	0x5119, 0x7007, 0x0003, 0x701f, 0x50ae, 0x0005, 0xa830, 0x9086,
-	0x0100, 0x2009, 0x0004, 0x0904, 0x5119, 0x7984, 0x7aa8, 0x9284,
-	0x1000, 0x080c, 0x5340, 0x0804, 0x337e, 0x00c6, 0xaab0, 0x9284,
-	0xc000, 0x0140, 0xd2ec, 0x0168, 0x080c, 0x539c, 0x1150, 0x2009,
-	0x0014, 0x04f0, 0x2061, 0x1800, 0x080c, 0x539c, 0x2009, 0x0007,
-	0x15b8, 0xd2f4, 0x0128, 0x9284, 0x5000, 0x080c, 0x5363, 0x0050,
-	0xd2fc, 0x0178, 0x080c, 0x48ab, 0x0588, 0xa998, 0x9284, 0x9000,
-	0x080c, 0x5340, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000,
-	0x0438, 0x080c, 0x48ab, 0x0510, 0x080c, 0x6666, 0x2009, 0x0009,
+	0x33d3, 0xc0e5, 0xa952, 0xa956, 0xa83e, 0x080c, 0xbd0a, 0x2009,
+	0x0003, 0x0904, 0x33d0, 0x7007, 0x0003, 0x701f, 0x5050, 0x0005,
+	0xa830, 0x9086, 0x0100, 0x2009, 0x0004, 0x0904, 0x33d0, 0x0804,
+	0x339e, 0x7aa8, 0x9284, 0xc000, 0x0148, 0xd2ec, 0x01a0, 0x080c,
+	0x53bc, 0x1188, 0x2009, 0x0014, 0x0804, 0x33d0, 0xd2dc, 0x1568,
+	0x81ff, 0x2009, 0x0001, 0x1904, 0x33d0, 0x080c, 0x53bc, 0x2009,
+	0x0007, 0x1904, 0x33d0, 0xd2f4, 0x0130, 0x9284, 0x5000, 0x080c,
+	0x5383, 0x0804, 0x339e, 0xd2fc, 0x0158, 0x080c, 0x48cd, 0x0904,
+	0x33d3, 0x7984, 0x9284, 0x9000, 0x080c, 0x5360, 0x0804, 0x339e,
+	0x080c, 0x48cd, 0x0904, 0x33d3, 0xb804, 0x9084, 0x00ff, 0x9086,
+	0x0006, 0x2009, 0x0009, 0x1904, 0x5139, 0x080c, 0x489a, 0x2009,
+	0x0002, 0x0904, 0x5139, 0xa85c, 0x9080, 0x001b, 0xaf60, 0x2009,
+	0x0008, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x080c, 0x48e3, 0x701f,
+	0x50aa, 0x0005, 0xa86c, 0x9086, 0x0500, 0x1138, 0xa870, 0x9005,
+	0x1120, 0xa874, 0x9084, 0xff00, 0x0110, 0x1904, 0x33d3, 0xa866,
+	0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0x48cd, 0x1110, 0x0804,
+	0x33d3, 0x2009, 0x0043, 0x080c, 0xbd72, 0x2009, 0x0003, 0x0904,
+	0x5139, 0x7007, 0x0003, 0x701f, 0x50ce, 0x0005, 0xa830, 0x9086,
+	0x0100, 0x2009, 0x0004, 0x0904, 0x5139, 0x7984, 0x7aa8, 0x9284,
+	0x1000, 0x080c, 0x5360, 0x0804, 0x339e, 0x00c6, 0xaab0, 0x9284,
+	0xc000, 0x0140, 0xd2ec, 0x0168, 0x080c, 0x53bc, 0x1150, 0x2009,
+	0x0014, 0x04f0, 0x2061, 0x1800, 0x080c, 0x53bc, 0x2009, 0x0007,
+	0x15b8, 0xd2f4, 0x0128, 0x9284, 0x5000, 0x080c, 0x5383, 0x0050,
+	0xd2fc, 0x0178, 0x080c, 0x48cb, 0x0588, 0xa998, 0x9284, 0x9000,
+	0x080c, 0x5360, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000,
+	0x0438, 0x080c, 0x48cb, 0x0510, 0x080c, 0x668a, 0x2009, 0x0009,
 	0x11b8, 0xa8c4, 0x9086, 0x0500, 0x11c8, 0xa8c8, 0x9005, 0x11b0,
-	0xa8cc, 0x9084, 0xff00, 0x1190, 0x080c, 0x48ab, 0x1108, 0x0070,
-	0x2009, 0x004b, 0x080c, 0xbd44, 0x2009, 0x0003, 0x0108, 0x0078,
+	0xa8cc, 0x9084, 0xff00, 0x1190, 0x080c, 0x48cb, 0x1108, 0x0070,
+	0x2009, 0x004b, 0x080c, 0xbd72, 0x2009, 0x0003, 0x0108, 0x0078,
 	0x0429, 0x19c0, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897, 0x4006,
 	0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x00ce, 0x0005, 0x9006,
-	0x0ce0, 0x7aa8, 0xd2dc, 0x0904, 0x33b0, 0x0016, 0x7984, 0x9284,
-	0x1000, 0xc0fd, 0x080c, 0x5340, 0x001e, 0x1904, 0x33b0, 0x0804,
-	0x337e, 0x00f6, 0x2d78, 0x0011, 0x00fe, 0x0005, 0xaab0, 0xd2dc,
-	0x0150, 0x0016, 0xa998, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x5340,
+	0x0ce0, 0x7aa8, 0xd2dc, 0x0904, 0x33d0, 0x0016, 0x7984, 0x9284,
+	0x1000, 0xc0fd, 0x080c, 0x5360, 0x001e, 0x1904, 0x33d0, 0x0804,
+	0x339e, 0x00f6, 0x2d78, 0x0011, 0x00fe, 0x0005, 0xaab0, 0xd2dc,
+	0x0150, 0x0016, 0xa998, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x5360,
 	0x001e, 0x9085, 0x0001, 0x0005, 0x81ff, 0x0120, 0x2009, 0x0001,
-	0x0804, 0x33b0, 0x080c, 0x539c, 0x0120, 0x2009, 0x0007, 0x0804,
-	0x33b0, 0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c, 0x626b, 0x1904,
-	0x33b3, 0x9186, 0x007f, 0x0138, 0x080c, 0x6666, 0x0120, 0x2009,
-	0x0009, 0x0804, 0x33b0, 0x080c, 0x487a, 0x1120, 0x2009, 0x0002,
-	0x0804, 0x33b0, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x2001,
-	0x0100, 0x8007, 0xa80a, 0x080c, 0xba2b, 0x1120, 0x2009, 0x0003,
-	0x0804, 0x33b0, 0x7007, 0x0003, 0x701f, 0x5177, 0x0005, 0xa808,
-	0x8007, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x33b0,
+	0x0804, 0x33d0, 0x080c, 0x53bc, 0x0120, 0x2009, 0x0007, 0x0804,
+	0x33d0, 0x7984, 0x7ea8, 0x96b4, 0x00ff, 0x080c, 0x628f, 0x1904,
+	0x33d3, 0x9186, 0x007f, 0x0138, 0x080c, 0x668a, 0x0120, 0x2009,
+	0x0009, 0x0804, 0x33d0, 0x080c, 0x489a, 0x1120, 0x2009, 0x0002,
+	0x0804, 0x33d0, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x2001,
+	0x0100, 0x8007, 0xa80a, 0x080c, 0xba59, 0x1120, 0x2009, 0x0003,
+	0x0804, 0x33d0, 0x7007, 0x0003, 0x701f, 0x5197, 0x0005, 0xa808,
+	0x8007, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x33d0,
 	0xa8e0, 0xa866, 0xa810, 0x8007, 0x9084, 0x00ff, 0x800c, 0xa814,
 	0x8007, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0002, 0x9108, 0x8906,
 	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0004,
-	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x48c6, 0x080c, 0x487a,
-	0x1120, 0x2009, 0x0002, 0x0804, 0x33b0, 0x7984, 0x9194, 0xff00,
-	0x918c, 0x00ff, 0x8217, 0x82ff, 0x1118, 0x7023, 0x1983, 0x0040,
-	0x92c6, 0x0001, 0x1118, 0x7023, 0x199d, 0x0010, 0x0804, 0x33b3,
+	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x48e6, 0x080c, 0x489a,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x33d0, 0x7984, 0x9194, 0xff00,
+	0x918c, 0x00ff, 0x8217, 0x82ff, 0x1118, 0x7023, 0x198b, 0x0040,
+	0x92c6, 0x0001, 0x1118, 0x7023, 0x19a5, 0x0010, 0x0804, 0x33d3,
 	0x2009, 0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080,
-	0x0019, 0xaf60, 0x080c, 0x48c3, 0x701f, 0x51c7, 0x0005, 0x2001,
+	0x0019, 0xaf60, 0x080c, 0x48e3, 0x701f, 0x51e7, 0x0005, 0x2001,
 	0x182d, 0x2003, 0x0001, 0xa85c, 0x9080, 0x0019, 0x2098, 0xa860,
 	0x20e0, 0x20a9, 0x001a, 0x7020, 0x20a0, 0x20e9, 0x0001, 0x4003,
-	0x0804, 0x337e, 0x080c, 0x487a, 0x1120, 0x2009, 0x0002, 0x0804,
-	0x33b0, 0x7984, 0x9194, 0xff00, 0x918c, 0x00ff, 0x8217, 0x82ff,
-	0x1118, 0x2099, 0x1983, 0x0040, 0x92c6, 0x0001, 0x1118, 0x2099,
-	0x199d, 0x0010, 0x0804, 0x33b3, 0xa85c, 0x9080, 0x0019, 0x20a0,
+	0x0804, 0x339e, 0x080c, 0x489a, 0x1120, 0x2009, 0x0002, 0x0804,
+	0x33d0, 0x7984, 0x9194, 0xff00, 0x918c, 0x00ff, 0x8217, 0x82ff,
+	0x1118, 0x2099, 0x198b, 0x0040, 0x92c6, 0x0001, 0x1118, 0x2099,
+	0x19a5, 0x0010, 0x0804, 0x33d3, 0xa85c, 0x9080, 0x0019, 0x20a0,
 	0xa860, 0x20e8, 0x20a9, 0x001a, 0x20e1, 0x0001, 0x4003, 0x2009,
 	0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019,
-	0xaf60, 0x0804, 0x48c6, 0x7884, 0x908a, 0x1000, 0x1a04, 0x33b3,
+	0xaf60, 0x0804, 0x48e6, 0x7884, 0x908a, 0x1000, 0x1a04, 0x33d3,
 	0x0126, 0x2091, 0x8000, 0x8003, 0x800b, 0x810b, 0x9108, 0x00c6,
-	0x2061, 0x19d3, 0x6142, 0x00ce, 0x012e, 0x0804, 0x337e, 0x00c6,
-	0x080c, 0x7096, 0x1160, 0x080c, 0x7396, 0x080c, 0x5cd7, 0x9085,
-	0x0001, 0x080c, 0x70dd, 0x080c, 0x6fc7, 0x080c, 0x0d65, 0x2061,
-	0x1800, 0x6030, 0xc09d, 0x6032, 0x080c, 0x5b92, 0x00ce, 0x0005,
-	0x00c6, 0x2001, 0x1800, 0x2004, 0x908e, 0x0000, 0x0904, 0x33b0,
-	0x7884, 0x9005, 0x0188, 0x7888, 0x2061, 0x196c, 0x2c0c, 0x2062,
-	0x080c, 0x2820, 0x01a0, 0x080c, 0x2828, 0x0188, 0x080c, 0x2830,
-	0x0170, 0x2162, 0x0804, 0x33b3, 0x2061, 0x0100, 0x6038, 0x9086,
+	0x2061, 0x19db, 0x6142, 0x00ce, 0x012e, 0x0804, 0x339e, 0x00c6,
+	0x080c, 0x70ba, 0x1160, 0x080c, 0x73b9, 0x080c, 0x5cf7, 0x9085,
+	0x0001, 0x080c, 0x7101, 0x080c, 0x6feb, 0x080c, 0x0d65, 0x2061,
+	0x1800, 0x6030, 0xc09d, 0x6032, 0x080c, 0x5bb2, 0x00ce, 0x0005,
+	0x00c6, 0x2001, 0x1800, 0x2004, 0x908e, 0x0000, 0x0904, 0x33d0,
+	0x7884, 0x9005, 0x0188, 0x7888, 0x2061, 0x1974, 0x2c0c, 0x2062,
+	0x080c, 0x2840, 0x01a0, 0x080c, 0x2848, 0x0188, 0x080c, 0x2850,
+	0x0170, 0x2162, 0x0804, 0x33d3, 0x2061, 0x0100, 0x6038, 0x9086,
 	0x0007, 0x1118, 0x2009, 0x0001, 0x0010, 0x2009, 0x0000, 0x7884,
 	0x9086, 0x0002, 0x1588, 0x2061, 0x0100, 0x6028, 0xc09c, 0x602a,
-	0x080c, 0x98bb, 0x0026, 0x2011, 0x0003, 0x080c, 0x931c, 0x2011,
-	0x0002, 0x080c, 0x9326, 0x002e, 0x080c, 0x91e9, 0x0036, 0x901e,
-	0x080c, 0x9269, 0x003e, 0x080c, 0x98d7, 0x60e3, 0x0000, 0x080c,
-	0xd60c, 0x080c, 0xd627, 0x9085, 0x0001, 0x080c, 0x70dd, 0x9006,
-	0x080c, 0x2852, 0x2001, 0x1800, 0x2003, 0x0004, 0x0026, 0x2011,
-	0x0008, 0x080c, 0x288c, 0x002e, 0x00ce, 0x0804, 0x337e, 0x81ff,
-	0x0120, 0x2009, 0x0001, 0x0804, 0x33b0, 0x080c, 0x539c, 0x0120,
-	0x2009, 0x0007, 0x0804, 0x33b0, 0x7984, 0x7ea8, 0x96b4, 0x00ff,
-	0x080c, 0x626b, 0x1904, 0x33b3, 0x9186, 0x007f, 0x0138, 0x080c,
-	0x6666, 0x0120, 0x2009, 0x0009, 0x0804, 0x33b0, 0x080c, 0x487a,
-	0x1120, 0x2009, 0x0002, 0x0804, 0x33b0, 0xa867, 0x0000, 0xa868,
-	0xc0fd, 0xa86a, 0x080c, 0xba2e, 0x1120, 0x2009, 0x0003, 0x0804,
-	0x33b0, 0x7007, 0x0003, 0x701f, 0x52ce, 0x0005, 0xa830, 0x9086,
-	0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x33b0, 0xa8e0, 0xa866,
+	0x080c, 0x98c7, 0x0026, 0x2011, 0x0003, 0x080c, 0x9324, 0x2011,
+	0x0002, 0x080c, 0x932e, 0x002e, 0x080c, 0x921d, 0x0036, 0x901e,
+	0x080c, 0x929d, 0x003e, 0x080c, 0x98e3, 0x60e3, 0x0000, 0x080c,
+	0xd644, 0x080c, 0xd65f, 0x9085, 0x0001, 0x080c, 0x7101, 0x9006,
+	0x080c, 0x2872, 0x2001, 0x1800, 0x2003, 0x0004, 0x0026, 0x2011,
+	0x0008, 0x080c, 0x28ac, 0x002e, 0x00ce, 0x0804, 0x339e, 0x81ff,
+	0x0120, 0x2009, 0x0001, 0x0804, 0x33d0, 0x080c, 0x53bc, 0x0120,
+	0x2009, 0x0007, 0x0804, 0x33d0, 0x7984, 0x7ea8, 0x96b4, 0x00ff,
+	0x080c, 0x628f, 0x1904, 0x33d3, 0x9186, 0x007f, 0x0138, 0x080c,
+	0x668a, 0x0120, 0x2009, 0x0009, 0x0804, 0x33d0, 0x080c, 0x489a,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x33d0, 0xa867, 0x0000, 0xa868,
+	0xc0fd, 0xa86a, 0x080c, 0xba5c, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x33d0, 0x7007, 0x0003, 0x701f, 0x52ee, 0x0005, 0xa830, 0x9086,
+	0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x33d0, 0xa8e0, 0xa866,
 	0xa834, 0x8007, 0x800c, 0xa85c, 0x9080, 0x000c, 0x7a8c, 0x7b88,
-	0x7c9c, 0x7d98, 0xaf60, 0x0804, 0x48c6, 0xa898, 0x9086, 0x000d,
-	0x1904, 0x33b0, 0x2021, 0x4005, 0x0126, 0x2091, 0x8000, 0x0e04,
-	0x52f2, 0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000, 0x0118,
+	0x7c9c, 0x7d98, 0xaf60, 0x0804, 0x48e6, 0xa898, 0x9086, 0x000d,
+	0x1904, 0x33d0, 0x2021, 0x4005, 0x0126, 0x2091, 0x8000, 0x0e04,
+	0x5312, 0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000, 0x0118,
 	0x7833, 0x0011, 0x0010, 0x7833, 0x0010, 0x7883, 0x4005, 0xa998,
-	0x7986, 0xa9a4, 0x799a, 0xa9a8, 0x799e, 0x080c, 0x48b6, 0x2091,
-	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11c9, 0x7007,
+	0x7986, 0xa9a4, 0x799a, 0xa9a8, 0x799e, 0x080c, 0x48d6, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11d6, 0x7007,
 	0x0001, 0x2091, 0x5000, 0x700f, 0x0000, 0x012e, 0x0005, 0x0126,
-	0x2091, 0x8000, 0x00c6, 0x2061, 0x19d3, 0x7984, 0x6152, 0x614e,
+	0x2091, 0x8000, 0x00c6, 0x2061, 0x19db, 0x7984, 0x6152, 0x614e,
 	0x6057, 0x0000, 0x604b, 0x0009, 0x7898, 0x606a, 0x789c, 0x6066,
-	0x7888, 0x6062, 0x788c, 0x605e, 0x2001, 0x19e1, 0x2044, 0x2001,
-	0x19e8, 0xa076, 0xa060, 0xa072, 0xa07b, 0x0001, 0xa07f, 0x0002,
-	0xa06b, 0x0000, 0xa09f, 0x0000, 0x00ce, 0x012e, 0x0804, 0x337e,
+	0x7888, 0x6062, 0x788c, 0x605e, 0x2001, 0x19e9, 0x2044, 0x2001,
+	0x19f0, 0xa076, 0xa060, 0xa072, 0xa07b, 0x0001, 0xa07f, 0x0002,
+	0xa06b, 0x0000, 0xa09f, 0x0000, 0x00ce, 0x012e, 0x0804, 0x339e,
 	0x0126, 0x2091, 0x8000, 0x00b6, 0x00c6, 0x90e4, 0xc000, 0x0128,
-	0x0006, 0x080c, 0xb88f, 0x000e, 0x1198, 0xd0e4, 0x0160, 0x9180,
-	0x1000, 0x2004, 0x905d, 0x0160, 0x080c, 0x5cf1, 0x080c, 0x9b59,
+	0x0006, 0x080c, 0xb8bd, 0x000e, 0x1198, 0xd0e4, 0x0160, 0x9180,
+	0x1000, 0x2004, 0x905d, 0x0160, 0x080c, 0x5d11, 0x080c, 0x9b65,
 	0x0110, 0xb817, 0x0000, 0x9006, 0x00ce, 0x00be, 0x012e, 0x0005,
 	0x9085, 0x0001, 0x0cc8, 0x0126, 0x2091, 0x8000, 0x0156, 0x2010,
 	0x900e, 0x20a9, 0x0800, 0x0016, 0x9180, 0x1000, 0x2004, 0x9005,
 	0x0180, 0x9186, 0x007e, 0x0168, 0x9186, 0x007f, 0x0150, 0x9186,
 	0x0080, 0x0138, 0x9186, 0x00ff, 0x0120, 0x0026, 0x2200, 0x0801,
-	0x002e, 0x001e, 0x8108, 0x1f04, 0x536b, 0x015e, 0x012e, 0x0005,
-	0x2001, 0x1854, 0x2004, 0x0005, 0x2001, 0x1873, 0x2004, 0x0005,
+	0x002e, 0x001e, 0x8108, 0x1f04, 0x538b, 0x015e, 0x012e, 0x0005,
+	0x2001, 0x185c, 0x2004, 0x0005, 0x2001, 0x187b, 0x2004, 0x0005,
 	0x0006, 0x2001, 0x1810, 0x2004, 0xd0d4, 0x000e, 0x0005, 0x2001,
 	0x180e, 0x2004, 0xd0b4, 0x0005, 0x2001, 0x1800, 0x2004, 0x9086,
-	0x0003, 0x0005, 0x0016, 0x00e6, 0x2071, 0x1894, 0x7108, 0x910d,
+	0x0003, 0x0005, 0x0016, 0x00e6, 0x2071, 0x189c, 0x7108, 0x910d,
 	0x710a, 0x00ee, 0x001e, 0x0005, 0x79a4, 0x9182, 0x0081, 0x1a04,
-	0x33b3, 0x810c, 0x0016, 0x080c, 0x487a, 0x080c, 0x0f2a, 0x2100,
-	0x2238, 0x7d84, 0x7c88, 0x7b8c, 0x7a90, 0x001e, 0x080c, 0x48c3,
-	0x701f, 0x53c3, 0x0005, 0x2079, 0x0000, 0x7d94, 0x7c98, 0x7ba8,
-	0x7aac, 0x79a4, 0x810c, 0x2061, 0x18ae, 0x2c44, 0xa770, 0xa074,
-	0x2071, 0x1894, 0x080c, 0x48c6, 0x701f, 0x53d7, 0x0005, 0x2061,
-	0x18ae, 0x2c44, 0x0016, 0x0026, 0xa270, 0xa174, 0x080c, 0x0f32,
-	0x002e, 0x001e, 0x080c, 0x0fdf, 0x9006, 0xa802, 0xa806, 0x0804,
-	0x337e, 0x0126, 0x0156, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6,
+	0x33d3, 0x810c, 0x0016, 0x080c, 0x489a, 0x080c, 0x0f37, 0x2100,
+	0x2238, 0x7d84, 0x7c88, 0x7b8c, 0x7a90, 0x001e, 0x080c, 0x48e3,
+	0x701f, 0x53e3, 0x0005, 0x2079, 0x0000, 0x7d94, 0x7c98, 0x7ba8,
+	0x7aac, 0x79a4, 0x810c, 0x2061, 0x18b6, 0x2c44, 0xa770, 0xa074,
+	0x2071, 0x189c, 0x080c, 0x48e6, 0x701f, 0x53f7, 0x0005, 0x2061,
+	0x18b6, 0x2c44, 0x0016, 0x0026, 0xa270, 0xa174, 0x080c, 0x0f3f,
+	0x002e, 0x001e, 0x080c, 0x0fec, 0x9006, 0xa802, 0xa806, 0x0804,
+	0x339e, 0x0126, 0x0156, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6,
 	0x00d6, 0x00e6, 0x00f6, 0x2061, 0x0100, 0x2069, 0x0200, 0x2071,
-	0x1800, 0x6044, 0xd0a4, 0x11e8, 0xd084, 0x0118, 0x080c, 0x5592,
-	0x0068, 0xd08c, 0x0118, 0x080c, 0x549b, 0x0040, 0xd094, 0x0118,
-	0x080c, 0x546b, 0x0018, 0xd09c, 0x0108, 0x0099, 0x00fe, 0x00ee,
+	0x1800, 0x6044, 0xd0a4, 0x11e8, 0xd084, 0x0118, 0x080c, 0x55b2,
+	0x0068, 0xd08c, 0x0118, 0x080c, 0x54bb, 0x0040, 0xd094, 0x0118,
+	0x080c, 0x548b, 0x0018, 0xd09c, 0x0108, 0x0099, 0x00fe, 0x00ee,
 	0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x012e,
 	0x0005, 0x0016, 0x6128, 0xd19c, 0x1110, 0xc19d, 0x612a, 0x001e,
 	0x0c68, 0x0006, 0x7094, 0x9005, 0x000e, 0x0120, 0x7097, 0x0000,
@@ -2491,215 +2495,215 @@
 	0xf0f0, 0x0130, 0x624a, 0x6043, 0x0090, 0x6043, 0x0010, 0x0490,
 	0x9294, 0xff00, 0x9296, 0xf700, 0x0178, 0x7138, 0xd1a4, 0x1160,
 	0x6240, 0x9295, 0x0100, 0x6242, 0x9294, 0x0010, 0x0128, 0x2009,
-	0x00f7, 0x080c, 0x5c53, 0x00f0, 0x6040, 0x9084, 0x0010, 0x9085,
+	0x00f7, 0x080c, 0x5c73, 0x00f0, 0x6040, 0x9084, 0x0010, 0x9085,
 	0x0140, 0x6042, 0x6043, 0x0000, 0x7083, 0x0000, 0x709f, 0x0001,
 	0x70c3, 0x0000, 0x70db, 0x0000, 0x2009, 0x1d80, 0x200b, 0x0000,
-	0x7093, 0x0000, 0x7087, 0x000f, 0x2009, 0x000f, 0x2011, 0x5b35,
-	0x080c, 0x81fc, 0x0005, 0x2001, 0x1875, 0x2004, 0xd08c, 0x0110,
-	0x705b, 0xffff, 0x7084, 0x9005, 0x1528, 0x2011, 0x5b35, 0x080c,
-	0x8138, 0x6040, 0x9094, 0x0010, 0x9285, 0x0020, 0x6042, 0x20a9,
-	0x00c8, 0x6044, 0xd08c, 0x1168, 0x1f04, 0x5481, 0x6242, 0x7097,
+	0x7093, 0x0000, 0x7087, 0x000f, 0x2009, 0x000f, 0x2011, 0x5b55,
+	0x080c, 0x8230, 0x0005, 0x2001, 0x187d, 0x2004, 0xd08c, 0x0110,
+	0x705b, 0xffff, 0x7084, 0x9005, 0x1528, 0x2011, 0x5b55, 0x080c,
+	0x816c, 0x6040, 0x9094, 0x0010, 0x9285, 0x0020, 0x6042, 0x20a9,
+	0x00c8, 0x6044, 0xd08c, 0x1168, 0x1f04, 0x54a1, 0x6242, 0x7097,
 	0x0000, 0x6040, 0x9094, 0x0010, 0x9285, 0x0080, 0x6042, 0x6242,
 	0x0048, 0x6242, 0x7097, 0x0000, 0x708b, 0x0000, 0x9006, 0x080c,
-	0x5cdc, 0x0000, 0x0005, 0x7088, 0x908a, 0x0003, 0x1a0c, 0x0d65,
-	0x000b, 0x0005, 0x54a5, 0x54f6, 0x5591, 0x00f6, 0x0016, 0x6900,
+	0x5cfc, 0x0000, 0x0005, 0x7088, 0x908a, 0x0003, 0x1a0c, 0x0d65,
+	0x000b, 0x0005, 0x54c5, 0x5516, 0x55b1, 0x00f6, 0x0016, 0x6900,
 	0x918c, 0x0800, 0x708b, 0x0001, 0x2001, 0x015d, 0x2003, 0x0000,
 	0x6803, 0x00fc, 0x20a9, 0x0004, 0x6800, 0x9084, 0x00fc, 0x0120,
-	0x1f04, 0x54b4, 0x080c, 0x0d65, 0x68a0, 0x68a2, 0x689c, 0x689e,
+	0x1f04, 0x54d4, 0x080c, 0x0d65, 0x68a0, 0x68a2, 0x689c, 0x689e,
 	0x6898, 0x689a, 0xa001, 0x918d, 0x1600, 0x6902, 0x001e, 0x6837,
-	0x0020, 0x080c, 0x5cb8, 0x2079, 0x1d00, 0x7833, 0x1101, 0x7837,
+	0x0020, 0x080c, 0x5cd8, 0x2079, 0x1d00, 0x7833, 0x1101, 0x7837,
 	0x0000, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0001, 0x20a1,
-	0x1d0e, 0x20a9, 0x0004, 0x4003, 0x080c, 0x97e8, 0x20e1, 0x0001,
+	0x1d0e, 0x20a9, 0x0004, 0x4003, 0x080c, 0x97f4, 0x20e1, 0x0001,
 	0x2099, 0x1d00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x0014,
-	0x4003, 0x60c3, 0x000c, 0x600f, 0x0000, 0x080c, 0x5b66, 0x00fe,
+	0x4003, 0x60c3, 0x000c, 0x600f, 0x0000, 0x080c, 0x5b86, 0x00fe,
 	0x9006, 0x708e, 0x6043, 0x0008, 0x6042, 0x0005, 0x00f6, 0x708c,
-	0x708f, 0x0000, 0x9025, 0x0904, 0x556e, 0x6020, 0xd0b4, 0x1904,
-	0x556c, 0x719c, 0x81ff, 0x0904, 0x555a, 0x9486, 0x000c, 0x1904,
-	0x5567, 0x9480, 0x0018, 0x8004, 0x20a8, 0x080c, 0x5cb1, 0x2011,
+	0x708f, 0x0000, 0x9025, 0x0904, 0x558e, 0x6020, 0xd0b4, 0x1904,
+	0x558c, 0x719c, 0x81ff, 0x0904, 0x557a, 0x9486, 0x000c, 0x1904,
+	0x5587, 0x9480, 0x0018, 0x8004, 0x20a8, 0x080c, 0x5cd1, 0x2011,
 	0x0260, 0x2019, 0x1d00, 0x220c, 0x2304, 0x9106, 0x11e8, 0x8210,
-	0x8318, 0x1f04, 0x5513, 0x6043, 0x0004, 0x2061, 0x0140, 0x605b,
+	0x8318, 0x1f04, 0x5533, 0x6043, 0x0004, 0x2061, 0x0140, 0x605b,
 	0xbc94, 0x605f, 0xf0f0, 0x2061, 0x0100, 0x6043, 0x0006, 0x708b,
-	0x0002, 0x7097, 0x0002, 0x2009, 0x07d0, 0x2011, 0x5b3c, 0x080c,
-	0x81fc, 0x080c, 0x5cb8, 0x04c0, 0x080c, 0x5cb1, 0x2079, 0x0260,
+	0x0002, 0x7097, 0x0002, 0x2009, 0x07d0, 0x2011, 0x5b5c, 0x080c,
+	0x8230, 0x080c, 0x5cd8, 0x04c0, 0x080c, 0x5cd1, 0x2079, 0x0260,
 	0x7930, 0x918e, 0x1101, 0x1558, 0x7834, 0x9005, 0x1540, 0x7900,
-	0x918c, 0x00ff, 0x1118, 0x7804, 0x9005, 0x0190, 0x080c, 0x5cb1,
+	0x918c, 0x00ff, 0x1118, 0x7804, 0x9005, 0x0190, 0x080c, 0x5cd1,
 	0x2011, 0x026e, 0x2019, 0x1805, 0x20a9, 0x0004, 0x220c, 0x2304,
-	0x9102, 0x0230, 0x11a0, 0x8210, 0x8318, 0x1f04, 0x554e, 0x0078,
-	0x709f, 0x0000, 0x080c, 0x5cb1, 0x20e1, 0x0000, 0x2099, 0x0260,
+	0x9102, 0x0230, 0x11a0, 0x8210, 0x8318, 0x1f04, 0x556e, 0x0078,
+	0x709f, 0x0000, 0x080c, 0x5cd1, 0x20e1, 0x0000, 0x2099, 0x0260,
 	0x20e9, 0x0001, 0x20a1, 0x1d00, 0x20a9, 0x0014, 0x4003, 0x6043,
 	0x0008, 0x6043, 0x0000, 0x0010, 0x00fe, 0x0005, 0x6040, 0x9085,
-	0x0100, 0x6042, 0x6020, 0xd0b4, 0x1db8, 0x080c, 0x97e8, 0x20e1,
+	0x0100, 0x6042, 0x6020, 0xd0b4, 0x1db8, 0x080c, 0x97f4, 0x20e1,
 	0x0001, 0x2099, 0x1d00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9,
-	0x0014, 0x4003, 0x60c3, 0x000c, 0x2011, 0x19c4, 0x2013, 0x0000,
-	0x708f, 0x0000, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0x8f8f,
+	0x0014, 0x4003, 0x60c3, 0x000c, 0x2011, 0x19cc, 0x2013, 0x0000,
+	0x708f, 0x0000, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0x8fc3,
 	0x08d8, 0x0005, 0x7094, 0x908a, 0x001d, 0x1a0c, 0x0d65, 0x000b,
-	0x0005, 0x55c3, 0x55d6, 0x55ff, 0x561f, 0x5645, 0x5674, 0x569a,
-	0x56d2, 0x56f8, 0x5726, 0x5761, 0x5799, 0x57b7, 0x57e2, 0x5804,
-	0x581f, 0x5829, 0x585d, 0x5883, 0x58b2, 0x58d8, 0x5910, 0x5954,
-	0x5991, 0x59b2, 0x5a0b, 0x5a2d, 0x5a5b, 0x5a5b, 0x00c6, 0x2061,
+	0x0005, 0x55e3, 0x55f6, 0x561f, 0x563f, 0x5665, 0x5694, 0x56ba,
+	0x56f2, 0x5718, 0x5746, 0x5781, 0x57b9, 0x57d7, 0x5802, 0x5824,
+	0x583f, 0x5849, 0x587d, 0x58a3, 0x58d2, 0x58f8, 0x5930, 0x5974,
+	0x59b1, 0x59d2, 0x5a2b, 0x5a4d, 0x5a7b, 0x5a7b, 0x00c6, 0x2061,
 	0x1800, 0x6003, 0x0007, 0x2061, 0x0100, 0x6004, 0x9084, 0xfff9,
 	0x6006, 0x00ce, 0x0005, 0x2061, 0x0140, 0x605b, 0xbc94, 0x605f,
 	0xf0f0, 0x2061, 0x0100, 0x6043, 0x0002, 0x7097, 0x0001, 0x2009,
-	0x07d0, 0x2011, 0x5b3c, 0x080c, 0x81fc, 0x0005, 0x00f6, 0x708c,
+	0x07d0, 0x2011, 0x5b5c, 0x080c, 0x8230, 0x0005, 0x00f6, 0x708c,
 	0x9086, 0x0014, 0x1510, 0x6042, 0x6020, 0xd0b4, 0x11f0, 0x080c,
-	0x5cb1, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102, 0x11a0, 0x7834,
+	0x5cd1, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102, 0x11a0, 0x7834,
 	0x9005, 0x1188, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110,
-	0x70c3, 0x0001, 0x2011, 0x5b3c, 0x080c, 0x8138, 0x7097, 0x0010,
-	0x080c, 0x5829, 0x0010, 0x708f, 0x0000, 0x00fe, 0x0005, 0x00f6,
-	0x7097, 0x0003, 0x6043, 0x0004, 0x2011, 0x5b3c, 0x080c, 0x8138,
-	0x080c, 0x5c35, 0x2079, 0x0240, 0x7833, 0x1102, 0x7837, 0x0000,
+	0x70c3, 0x0001, 0x2011, 0x5b5c, 0x080c, 0x816c, 0x7097, 0x0010,
+	0x080c, 0x5849, 0x0010, 0x708f, 0x0000, 0x00fe, 0x0005, 0x00f6,
+	0x7097, 0x0003, 0x6043, 0x0004, 0x2011, 0x5b5c, 0x080c, 0x816c,
+	0x080c, 0x5c55, 0x2079, 0x0240, 0x7833, 0x1102, 0x7837, 0x0000,
 	0x20a9, 0x0008, 0x9f88, 0x000e, 0x200b, 0x0000, 0x8108, 0x1f04,
-	0x5614, 0x60c3, 0x0014, 0x080c, 0x5b66, 0x00fe, 0x0005, 0x00f6,
-	0x708c, 0x9005, 0x0500, 0x2011, 0x5b3c, 0x080c, 0x8138, 0x9086,
-	0x0014, 0x11b8, 0x080c, 0x5cb1, 0x2079, 0x0260, 0x7a30, 0x9296,
+	0x5634, 0x60c3, 0x0014, 0x080c, 0x5b86, 0x00fe, 0x0005, 0x00f6,
+	0x708c, 0x9005, 0x0500, 0x2011, 0x5b5c, 0x080c, 0x816c, 0x9086,
+	0x0014, 0x11b8, 0x080c, 0x5cd1, 0x2079, 0x0260, 0x7a30, 0x9296,
 	0x1102, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128,
 	0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x7097, 0x0004, 0x0029,
-	0x0010, 0x080c, 0x5c8d, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x0005,
-	0x080c, 0x5c35, 0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000,
-	0x080c, 0x5cb1, 0x080c, 0x5c94, 0x1170, 0x7080, 0x9005, 0x1158,
-	0x7158, 0x9186, 0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5ae9,
-	0x0168, 0x080c, 0x5c6a, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099,
+	0x0010, 0x080c, 0x5cad, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x0005,
+	0x080c, 0x5c55, 0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000,
+	0x080c, 0x5cd1, 0x080c, 0x5cb4, 0x1170, 0x7080, 0x9005, 0x1158,
+	0x7158, 0x9186, 0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5b09,
+	0x0168, 0x080c, 0x5c8a, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099,
 	0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014,
-	0x080c, 0x5b66, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500,
-	0x2011, 0x5b3c, 0x080c, 0x8138, 0x9086, 0x0014, 0x11b8, 0x080c,
-	0x5cb1, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178, 0x7834,
+	0x080c, 0x5b86, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500,
+	0x2011, 0x5b5c, 0x080c, 0x816c, 0x9086, 0x0014, 0x11b8, 0x080c,
+	0x5cd1, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178, 0x7834,
 	0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110,
-	0x70c3, 0x0001, 0x7097, 0x0006, 0x0029, 0x0010, 0x080c, 0x5c8d,
-	0x00fe, 0x0005, 0x00f6, 0x7097, 0x0007, 0x080c, 0x5c35, 0x2079,
-	0x0240, 0x7833, 0x1104, 0x7837, 0x0000, 0x080c, 0x5cb1, 0x080c,
-	0x5c94, 0x11b8, 0x7080, 0x9005, 0x11a0, 0x7160, 0x9186, 0xffff,
-	0x0180, 0x9180, 0x317f, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011,
-	0x0008, 0x080c, 0x5ae9, 0x0180, 0x080c, 0x4c92, 0x0110, 0x080c,
-	0x24a6, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
-	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b66,
-	0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500, 0x2011, 0x5b3c,
-	0x080c, 0x8138, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5cb1, 0x2079,
+	0x70c3, 0x0001, 0x7097, 0x0006, 0x0029, 0x0010, 0x080c, 0x5cad,
+	0x00fe, 0x0005, 0x00f6, 0x7097, 0x0007, 0x080c, 0x5c55, 0x2079,
+	0x0240, 0x7833, 0x1104, 0x7837, 0x0000, 0x080c, 0x5cd1, 0x080c,
+	0x5cb4, 0x11b8, 0x7080, 0x9005, 0x11a0, 0x7160, 0x9186, 0xffff,
+	0x0180, 0x9180, 0x319f, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011,
+	0x0008, 0x080c, 0x5b09, 0x0180, 0x080c, 0x4cb2, 0x0110, 0x080c,
+	0x24c2, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
+	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b86,
+	0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500, 0x2011, 0x5b5c,
+	0x080c, 0x816c, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5cd1, 0x2079,
 	0x0260, 0x7a30, 0x9296, 0x1104, 0x1178, 0x7834, 0x9005, 0x1160,
 	0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001,
-	0x7097, 0x0008, 0x0029, 0x0010, 0x080c, 0x5c8d, 0x00fe, 0x0005,
-	0x00f6, 0x7097, 0x0009, 0x080c, 0x5c35, 0x2079, 0x0240, 0x7833,
-	0x1105, 0x7837, 0x0100, 0x080c, 0x5c94, 0x1150, 0x7080, 0x9005,
-	0x1138, 0x080c, 0x5a5c, 0x1188, 0x9085, 0x0001, 0x080c, 0x24a6,
-	0x20a9, 0x0008, 0x080c, 0x5cb1, 0x20e1, 0x0000, 0x2099, 0x026e,
+	0x7097, 0x0008, 0x0029, 0x0010, 0x080c, 0x5cad, 0x00fe, 0x0005,
+	0x00f6, 0x7097, 0x0009, 0x080c, 0x5c55, 0x2079, 0x0240, 0x7833,
+	0x1105, 0x7837, 0x0100, 0x080c, 0x5cb4, 0x1150, 0x7080, 0x9005,
+	0x1138, 0x080c, 0x5a7c, 0x1188, 0x9085, 0x0001, 0x080c, 0x24c2,
+	0x20a9, 0x0008, 0x080c, 0x5cd1, 0x20e1, 0x0000, 0x2099, 0x026e,
 	0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c,
-	0x5b66, 0x0010, 0x080c, 0x55b6, 0x00fe, 0x0005, 0x00f6, 0x708c,
-	0x9005, 0x05a8, 0x2011, 0x5b3c, 0x080c, 0x8138, 0x9086, 0x0014,
-	0x1560, 0x080c, 0x5cb1, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1105,
+	0x5b86, 0x0010, 0x080c, 0x55d6, 0x00fe, 0x0005, 0x00f6, 0x708c,
+	0x9005, 0x05a8, 0x2011, 0x5b5c, 0x080c, 0x816c, 0x9086, 0x0014,
+	0x1560, 0x080c, 0x5cd1, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1105,
 	0x1520, 0x7834, 0x9084, 0x0100, 0x2011, 0x0100, 0x921e, 0x1160,
 	0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001,
 	0x7097, 0x000a, 0x00b1, 0x0098, 0x9005, 0x1178, 0x7a38, 0xd2fc,
 	0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x7093, 0x0000,
-	0x7097, 0x000e, 0x080c, 0x5804, 0x0010, 0x080c, 0x5c8d, 0x00fe,
+	0x7097, 0x000e, 0x080c, 0x5824, 0x0010, 0x080c, 0x5cad, 0x00fe,
 	0x0005, 0x00f6, 0x7097, 0x000b, 0x2011, 0x1d0e, 0x20e9, 0x0001,
-	0x22a0, 0x20a9, 0x0040, 0x2019, 0xffff, 0x4304, 0x080c, 0x5c35,
-	0x2079, 0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x5c94,
+	0x22a0, 0x20a9, 0x0040, 0x2019, 0xffff, 0x4304, 0x080c, 0x5c55,
+	0x2079, 0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x5cb4,
 	0x0118, 0x2013, 0x0000, 0x0020, 0x705c, 0x9085, 0x0100, 0x2012,
 	0x20a9, 0x0040, 0x2009, 0x024e, 0x2011, 0x1d0e, 0x220e, 0x8210,
 	0x8108, 0x9186, 0x0260, 0x1128, 0x6810, 0x8000, 0x6812, 0x2009,
-	0x0240, 0x1f04, 0x5786, 0x60c3, 0x0084, 0x080c, 0x5b66, 0x00fe,
-	0x0005, 0x00f6, 0x708c, 0x9005, 0x01c0, 0x2011, 0x5b3c, 0x080c,
-	0x8138, 0x9086, 0x0084, 0x1178, 0x080c, 0x5cb1, 0x2079, 0x0260,
+	0x0240, 0x1f04, 0x57a6, 0x60c3, 0x0084, 0x080c, 0x5b86, 0x00fe,
+	0x0005, 0x00f6, 0x708c, 0x9005, 0x01c0, 0x2011, 0x5b5c, 0x080c,
+	0x816c, 0x9086, 0x0084, 0x1178, 0x080c, 0x5cd1, 0x2079, 0x0260,
 	0x7a30, 0x9296, 0x1106, 0x1138, 0x7834, 0x9005, 0x1120, 0x7097,
-	0x000c, 0x0029, 0x0010, 0x080c, 0x5c8d, 0x00fe, 0x0005, 0x00f6,
-	0x7097, 0x000d, 0x080c, 0x5c35, 0x2079, 0x0240, 0x7833, 0x1107,
-	0x7837, 0x0000, 0x080c, 0x5cb1, 0x20a9, 0x0040, 0x2011, 0x026e,
+	0x000c, 0x0029, 0x0010, 0x080c, 0x5cad, 0x00fe, 0x0005, 0x00f6,
+	0x7097, 0x000d, 0x080c, 0x5c55, 0x2079, 0x0240, 0x7833, 0x1107,
+	0x7837, 0x0000, 0x080c, 0x5cd1, 0x20a9, 0x0040, 0x2011, 0x026e,
 	0x2009, 0x024e, 0x220e, 0x8210, 0x8108, 0x9186, 0x0260, 0x1150,
 	0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x6814, 0x8000, 0x6816,
-	0x2011, 0x0260, 0x1f04, 0x57ca, 0x60c3, 0x0084, 0x080c, 0x5b66,
-	0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x01e0, 0x2011, 0x5b3c,
-	0x080c, 0x8138, 0x9086, 0x0084, 0x1198, 0x080c, 0x5cb1, 0x2079,
+	0x2011, 0x0260, 0x1f04, 0x57ea, 0x60c3, 0x0084, 0x080c, 0x5b86,
+	0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x01e0, 0x2011, 0x5b5c,
+	0x080c, 0x816c, 0x9086, 0x0084, 0x1198, 0x080c, 0x5cd1, 0x2079,
 	0x0260, 0x7a30, 0x9296, 0x1107, 0x1158, 0x7834, 0x9005, 0x1140,
-	0x7093, 0x0001, 0x080c, 0x5c07, 0x7097, 0x000e, 0x0029, 0x0010,
-	0x080c, 0x5c8d, 0x00fe, 0x0005, 0x918d, 0x0001, 0x080c, 0x5cdc,
+	0x7093, 0x0001, 0x080c, 0x5c27, 0x7097, 0x000e, 0x0029, 0x0010,
+	0x080c, 0x5cad, 0x00fe, 0x0005, 0x918d, 0x0001, 0x080c, 0x5cfc,
 	0x7097, 0x000f, 0x708f, 0x0000, 0x2061, 0x0140, 0x605b, 0xbc85,
 	0x605f, 0xb5b5, 0x2061, 0x0100, 0x6043, 0x0005, 0x6043, 0x0004,
-	0x2009, 0x07d0, 0x2011, 0x5b3c, 0x080c, 0x812c, 0x0005, 0x708c,
-	0x9005, 0x0130, 0x2011, 0x5b3c, 0x080c, 0x8138, 0x7097, 0x0000,
-	0x0005, 0x7097, 0x0011, 0x080c, 0x97e8, 0x080c, 0x5cb1, 0x20e1,
+	0x2009, 0x07d0, 0x2011, 0x5b5c, 0x080c, 0x8160, 0x0005, 0x708c,
+	0x9005, 0x0130, 0x2011, 0x5b5c, 0x080c, 0x816c, 0x7097, 0x0000,
+	0x0005, 0x7097, 0x0011, 0x080c, 0x97f4, 0x080c, 0x5cd1, 0x20e1,
 	0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x748c,
 	0x9480, 0x0018, 0x9080, 0x0007, 0x9084, 0x03f8, 0x8004, 0x20a8,
-	0x4003, 0x080c, 0x5c94, 0x11a0, 0x7178, 0x81ff, 0x0188, 0x900e,
-	0x707c, 0x9084, 0x00ff, 0x0160, 0x080c, 0x243d, 0x9186, 0x007e,
-	0x0138, 0x9186, 0x0080, 0x0120, 0x2011, 0x0008, 0x080c, 0x5ae9,
-	0x60c3, 0x0014, 0x080c, 0x5b66, 0x0005, 0x00f6, 0x708c, 0x9005,
-	0x0500, 0x2011, 0x5b3c, 0x080c, 0x8138, 0x9086, 0x0014, 0x11b8,
-	0x080c, 0x5cb1, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178,
+	0x4003, 0x080c, 0x5cb4, 0x11a0, 0x7178, 0x81ff, 0x0188, 0x900e,
+	0x707c, 0x9084, 0x00ff, 0x0160, 0x080c, 0x2459, 0x9186, 0x007e,
+	0x0138, 0x9186, 0x0080, 0x0120, 0x2011, 0x0008, 0x080c, 0x5b09,
+	0x60c3, 0x0014, 0x080c, 0x5b86, 0x0005, 0x00f6, 0x708c, 0x9005,
+	0x0500, 0x2011, 0x5b5c, 0x080c, 0x816c, 0x9086, 0x0014, 0x11b8,
+	0x080c, 0x5cd1, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178,
 	0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005,
 	0x1110, 0x70c3, 0x0001, 0x7097, 0x0012, 0x0029, 0x0010, 0x708f,
-	0x0000, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x0013, 0x080c, 0x5c43,
-	0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000, 0x080c, 0x5cb1,
-	0x080c, 0x5c94, 0x1170, 0x7080, 0x9005, 0x1158, 0x7158, 0x9186,
-	0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5ae9, 0x0168, 0x080c,
-	0x5c6a, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
-	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b66,
-	0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500, 0x2011, 0x5b3c,
-	0x080c, 0x8138, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5cb1, 0x2079,
+	0x0000, 0x00fe, 0x0005, 0x00f6, 0x7097, 0x0013, 0x080c, 0x5c63,
+	0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000, 0x080c, 0x5cd1,
+	0x080c, 0x5cb4, 0x1170, 0x7080, 0x9005, 0x1158, 0x7158, 0x9186,
+	0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5b09, 0x0168, 0x080c,
+	0x5c8a, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
+	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b86,
+	0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x0500, 0x2011, 0x5b5c,
+	0x080c, 0x816c, 0x9086, 0x0014, 0x11b8, 0x080c, 0x5cd1, 0x2079,
 	0x0260, 0x7a30, 0x9296, 0x1104, 0x1178, 0x7834, 0x9005, 0x1160,
 	0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001,
 	0x7097, 0x0014, 0x0029, 0x0010, 0x708f, 0x0000, 0x00fe, 0x0005,
-	0x00f6, 0x7097, 0x0015, 0x080c, 0x5c43, 0x2079, 0x0240, 0x7833,
-	0x1104, 0x7837, 0x0000, 0x080c, 0x5cb1, 0x080c, 0x5c94, 0x11b8,
+	0x00f6, 0x7097, 0x0015, 0x080c, 0x5c63, 0x2079, 0x0240, 0x7833,
+	0x1104, 0x7837, 0x0000, 0x080c, 0x5cd1, 0x080c, 0x5cb4, 0x11b8,
 	0x7080, 0x9005, 0x11a0, 0x7160, 0x9186, 0xffff, 0x0180, 0x9180,
-	0x317f, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011, 0x0008, 0x080c,
-	0x5ae9, 0x0180, 0x080c, 0x4c92, 0x0110, 0x080c, 0x24a6, 0x20a9,
+	0x319f, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011, 0x0008, 0x080c,
+	0x5b09, 0x0180, 0x080c, 0x4cb2, 0x0110, 0x080c, 0x24c2, 0x20a9,
 	0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1,
-	0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b66, 0x00fe, 0x0005,
-	0x00f6, 0x708c, 0x9005, 0x05f0, 0x2011, 0x5b3c, 0x080c, 0x8138,
-	0x9086, 0x0014, 0x15a8, 0x080c, 0x5cb1, 0x2079, 0x0260, 0x7a30,
+	0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x5b86, 0x00fe, 0x0005,
+	0x00f6, 0x708c, 0x9005, 0x05f0, 0x2011, 0x5b5c, 0x080c, 0x816c,
+	0x9086, 0x0014, 0x15a8, 0x080c, 0x5cd1, 0x2079, 0x0260, 0x7a30,
 	0x9296, 0x1105, 0x1568, 0x7834, 0x9084, 0x0100, 0x2011, 0x0100,
-	0x921e, 0x1168, 0x9085, 0x0001, 0x080c, 0x5cdc, 0x7a38, 0xd2fc,
+	0x921e, 0x1168, 0x9085, 0x0001, 0x080c, 0x5cfc, 0x7a38, 0xd2fc,
 	0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3, 0x0001, 0x0080, 0x9005,
 	0x11b8, 0x7a38, 0xd2fc, 0x0128, 0x70c0, 0x9005, 0x1110, 0x70c3,
-	0x0001, 0x9085, 0x0001, 0x080c, 0x5cdc, 0x7093, 0x0000, 0x7a38,
+	0x0001, 0x9085, 0x0001, 0x080c, 0x5cfc, 0x7093, 0x0000, 0x7a38,
 	0xd2f4, 0x0110, 0x70db, 0x0008, 0x7097, 0x0016, 0x0029, 0x0010,
-	0x708f, 0x0000, 0x00fe, 0x0005, 0x080c, 0x97e8, 0x080c, 0x5cb1,
+	0x708f, 0x0000, 0x00fe, 0x0005, 0x080c, 0x97f4, 0x080c, 0x5cd1,
 	0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240,
 	0x20a9, 0x000e, 0x4003, 0x2011, 0x026d, 0x2204, 0x9084, 0x0100,
 	0x2011, 0x024d, 0x2012, 0x2011, 0x026e, 0x7097, 0x0017, 0x080c,
-	0x5c94, 0x1150, 0x7080, 0x9005, 0x1138, 0x080c, 0x5a5c, 0x1188,
-	0x9085, 0x0001, 0x080c, 0x24a6, 0x20a9, 0x0008, 0x080c, 0x5cb1,
+	0x5cb4, 0x1150, 0x7080, 0x9005, 0x1138, 0x080c, 0x5a7c, 0x1188,
+	0x9085, 0x0001, 0x080c, 0x24c2, 0x20a9, 0x0008, 0x080c, 0x5cd1,
 	0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e,
-	0x4003, 0x60c3, 0x0014, 0x080c, 0x5b66, 0x0010, 0x080c, 0x55b6,
-	0x0005, 0x00f6, 0x708c, 0x9005, 0x01d8, 0x2011, 0x5b3c, 0x080c,
-	0x8138, 0x9086, 0x0084, 0x1190, 0x080c, 0x5cb1, 0x2079, 0x0260,
+	0x4003, 0x60c3, 0x0014, 0x080c, 0x5b86, 0x0010, 0x080c, 0x55d6,
+	0x0005, 0x00f6, 0x708c, 0x9005, 0x01d8, 0x2011, 0x5b5c, 0x080c,
+	0x816c, 0x9086, 0x0084, 0x1190, 0x080c, 0x5cd1, 0x2079, 0x0260,
 	0x7a30, 0x9296, 0x1106, 0x1150, 0x7834, 0x9005, 0x1138, 0x9006,
-	0x080c, 0x5cdc, 0x7097, 0x0018, 0x0029, 0x0010, 0x708f, 0x0000,
-	0x00fe, 0x0005, 0x00f6, 0x7097, 0x0019, 0x080c, 0x5c43, 0x2079,
-	0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x5cb1, 0x2009,
+	0x080c, 0x5cfc, 0x7097, 0x0018, 0x0029, 0x0010, 0x708f, 0x0000,
+	0x00fe, 0x0005, 0x00f6, 0x7097, 0x0019, 0x080c, 0x5c63, 0x2079,
+	0x0240, 0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x5cd1, 0x2009,
 	0x026e, 0x2039, 0x1d0e, 0x20a9, 0x0040, 0x213e, 0x8738, 0x8108,
 	0x9186, 0x0280, 0x1128, 0x6814, 0x8000, 0x6816, 0x2009, 0x0260,
-	0x1f04, 0x59c5, 0x2039, 0x1d0e, 0x080c, 0x5c94, 0x11e8, 0x2728,
+	0x1f04, 0x59e5, 0x2039, 0x1d0e, 0x080c, 0x5cb4, 0x11e8, 0x2728,
 	0x2514, 0x8207, 0x9084, 0x00ff, 0x8000, 0x2018, 0x9294, 0x00ff,
 	0x8007, 0x9205, 0x202a, 0x705c, 0x2310, 0x8214, 0x92a0, 0x1d0e,
 	0x2414, 0x938c, 0x0001, 0x0118, 0x9294, 0xff00, 0x0018, 0x9294,
 	0x00ff, 0x8007, 0x9215, 0x2222, 0x20a9, 0x0040, 0x2009, 0x024e,
 	0x270e, 0x8738, 0x8108, 0x9186, 0x0260, 0x1128, 0x6810, 0x8000,
-	0x6812, 0x2009, 0x0240, 0x1f04, 0x59f8, 0x60c3, 0x0084, 0x080c,
-	0x5b66, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x01e0, 0x2011,
-	0x5b3c, 0x080c, 0x8138, 0x9086, 0x0084, 0x1198, 0x080c, 0x5cb1,
+	0x6812, 0x2009, 0x0240, 0x1f04, 0x5a18, 0x60c3, 0x0084, 0x080c,
+	0x5b86, 0x00fe, 0x0005, 0x00f6, 0x708c, 0x9005, 0x01e0, 0x2011,
+	0x5b5c, 0x080c, 0x816c, 0x9086, 0x0084, 0x1198, 0x080c, 0x5cd1,
 	0x2079, 0x0260, 0x7a30, 0x9296, 0x1107, 0x1158, 0x7834, 0x9005,
-	0x1140, 0x7093, 0x0001, 0x080c, 0x5c07, 0x7097, 0x001a, 0x0029,
+	0x1140, 0x7093, 0x0001, 0x080c, 0x5c27, 0x7097, 0x001a, 0x0029,
 	0x0010, 0x708f, 0x0000, 0x00fe, 0x0005, 0x9085, 0x0001, 0x080c,
-	0x5cdc, 0x7097, 0x001b, 0x080c, 0x97e8, 0x080c, 0x5cb1, 0x2011,
+	0x5cfc, 0x7097, 0x001b, 0x080c, 0x97f4, 0x080c, 0x5cd1, 0x2011,
 	0x0260, 0x2009, 0x0240, 0x748c, 0x9480, 0x0018, 0x9080, 0x0007,
 	0x9084, 0x03f8, 0x8004, 0x20a8, 0x220e, 0x8210, 0x8108, 0x9186,
 	0x0260, 0x1150, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x6814,
-	0x8000, 0x6816, 0x2011, 0x0260, 0x1f04, 0x5a44, 0x60c3, 0x0084,
-	0x080c, 0x5b66, 0x0005, 0x0005, 0x0086, 0x0096, 0x2029, 0x1854,
+	0x8000, 0x6816, 0x2011, 0x0260, 0x1f04, 0x5a64, 0x60c3, 0x0084,
+	0x080c, 0x5b86, 0x0005, 0x0005, 0x0086, 0x0096, 0x2029, 0x185c,
 	0x252c, 0x20a9, 0x0008, 0x2041, 0x1d0e, 0x20e9, 0x0001, 0x28a0,
-	0x080c, 0x5cb1, 0x20e1, 0x0000, 0x2099, 0x026e, 0x4003, 0x20a9,
+	0x080c, 0x5cd1, 0x20e1, 0x0000, 0x2099, 0x026e, 0x4003, 0x20a9,
 	0x0008, 0x2011, 0x0007, 0xd5d4, 0x0108, 0x9016, 0x2800, 0x9200,
 	0x200c, 0x91a6, 0xffff, 0x1148, 0xd5d4, 0x0110, 0x8210, 0x0008,
-	0x8211, 0x1f04, 0x5a76, 0x0804, 0x5ae5, 0x82ff, 0x1160, 0xd5d4,
+	0x8211, 0x1f04, 0x5a96, 0x0804, 0x5b05, 0x82ff, 0x1160, 0xd5d4,
 	0x0120, 0x91a6, 0x3fff, 0x0d90, 0x0020, 0x91a6, 0x3fff, 0x0904,
-	0x5ae5, 0x918d, 0xc000, 0x20a9, 0x0010, 0x2019, 0x0001, 0xd5d4,
+	0x5b05, 0x918d, 0xc000, 0x20a9, 0x0010, 0x2019, 0x0001, 0xd5d4,
 	0x0110, 0x2019, 0x0010, 0x2120, 0xd5d4, 0x0110, 0x8423, 0x0008,
 	0x8424, 0x1240, 0xd5d4, 0x0110, 0x8319, 0x0008, 0x8318, 0x1f04,
-	0x5a9c, 0x04d8, 0x23a8, 0x2021, 0x0001, 0x8426, 0x8425, 0x1f04,
-	0x5aae, 0x2328, 0x8529, 0x92be, 0x0007, 0x0158, 0x0006, 0x2039,
+	0x5abc, 0x04d8, 0x23a8, 0x2021, 0x0001, 0x8426, 0x8425, 0x1f04,
+	0x5ace, 0x2328, 0x8529, 0x92be, 0x0007, 0x0158, 0x0006, 0x2039,
 	0x0007, 0x2200, 0x973a, 0x000e, 0x27a8, 0x95a8, 0x0010, 0x1f04,
-	0x5abd, 0x755a, 0x95c8, 0x317f, 0x292d, 0x95ac, 0x00ff, 0x757e,
-	0x6532, 0x6536, 0x0016, 0x2508, 0x080c, 0x2486, 0x001e, 0x60e7,
+	0x5add, 0x755a, 0x95c8, 0x319f, 0x292d, 0x95ac, 0x00ff, 0x757e,
+	0x6532, 0x6536, 0x0016, 0x2508, 0x080c, 0x24a2, 0x001e, 0x60e7,
 	0x0000, 0x65ea, 0x2018, 0x2304, 0x9405, 0x201a, 0x7083, 0x0001,
 	0x20e9, 0x0000, 0x20a1, 0x024e, 0x20e1, 0x0001, 0x2898, 0x20a9,
 	0x0008, 0x4003, 0x9085, 0x0001, 0x0008, 0x9006, 0x009e, 0x008e,
@@ -2710,52 +2714,52 @@
 	0x2118, 0x84ff, 0x0120, 0x939a, 0x0010, 0x8421, 0x1de0, 0x2021,
 	0x0001, 0x83ff, 0x0118, 0x8423, 0x8319, 0x1de8, 0x9238, 0x2029,
 	0x026e, 0x9528, 0x2504, 0x942c, 0x11b8, 0x9405, 0x203a, 0x715a,
-	0x91a0, 0x317f, 0x242d, 0x95ac, 0x00ff, 0x757e, 0x6532, 0x6536,
-	0x0016, 0x2508, 0x080c, 0x2486, 0x001e, 0x60e7, 0x0000, 0x65ea,
+	0x91a0, 0x319f, 0x242d, 0x95ac, 0x00ff, 0x757e, 0x6532, 0x6536,
+	0x0016, 0x2508, 0x080c, 0x24a2, 0x001e, 0x60e7, 0x0000, 0x65ea,
 	0x7083, 0x0001, 0x9084, 0x0000, 0x0005, 0x00e6, 0x2071, 0x1800,
 	0x7087, 0x0000, 0x00ee, 0x0005, 0x00e6, 0x00f6, 0x2079, 0x0100,
-	0x2071, 0x0140, 0x080c, 0x5bf6, 0x080c, 0x8f9c, 0x7004, 0x9084,
-	0x4000, 0x0110, 0x080c, 0x2862, 0x0126, 0x2091, 0x8000, 0x2071,
+	0x2071, 0x0140, 0x080c, 0x5c16, 0x080c, 0x8fd0, 0x7004, 0x9084,
+	0x4000, 0x0110, 0x080c, 0x2882, 0x0126, 0x2091, 0x8000, 0x2071,
 	0x1825, 0x2073, 0x0000, 0x7840, 0x0026, 0x0016, 0x2009, 0x00f7,
-	0x080c, 0x5c53, 0x001e, 0x9094, 0x0010, 0x9285, 0x0080, 0x7842,
+	0x080c, 0x5c73, 0x001e, 0x9094, 0x0010, 0x9285, 0x0080, 0x7842,
 	0x7a42, 0x002e, 0x012e, 0x00fe, 0x00ee, 0x0005, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x27c1, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5,
-	0x2012, 0x2011, 0x19c4, 0x2013, 0x0000, 0x708f, 0x0000, 0x012e,
-	0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0x8f8f, 0x6144, 0xd184,
+	0x8000, 0x080c, 0x27dd, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5,
+	0x2012, 0x2011, 0x19cc, 0x2013, 0x0000, 0x708f, 0x0000, 0x012e,
+	0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0x8fc3, 0x6144, 0xd184,
 	0x0120, 0x7194, 0x918d, 0x2000, 0x0018, 0x7188, 0x918d, 0x1000,
-	0x2011, 0x1969, 0x2112, 0x2009, 0x07d0, 0x2011, 0x5b3c, 0x080c,
-	0x81fc, 0x0005, 0x0016, 0x0026, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x98bb, 0x080c, 0x9b60, 0x080c, 0x98d7, 0x2009, 0x00f7,
-	0x080c, 0x5c53, 0x2061, 0x19d3, 0x900e, 0x611a, 0x611e, 0x6172,
+	0x2011, 0x1971, 0x2112, 0x2009, 0x07d0, 0x2011, 0x5b5c, 0x080c,
+	0x8230, 0x0005, 0x0016, 0x0026, 0x00c6, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x98c7, 0x080c, 0x9b6c, 0x080c, 0x98e3, 0x2009, 0x00f7,
+	0x080c, 0x5c73, 0x2061, 0x19db, 0x900e, 0x611a, 0x611e, 0x6172,
 	0x6176, 0x2061, 0x1800, 0x6003, 0x0001, 0x2061, 0x0100, 0x6043,
-	0x0090, 0x6043, 0x0010, 0x2009, 0x1969, 0x200b, 0x0000, 0x2009,
-	0x002d, 0x2011, 0x5bc2, 0x080c, 0x812c, 0x012e, 0x00ce, 0x002e,
+	0x0090, 0x6043, 0x0010, 0x2009, 0x1971, 0x200b, 0x0000, 0x2009,
+	0x002d, 0x2011, 0x5be2, 0x080c, 0x8160, 0x012e, 0x00ce, 0x002e,
 	0x001e, 0x0005, 0x00e6, 0x0006, 0x0126, 0x2091, 0x8000, 0x0471,
-	0x2071, 0x0100, 0x080c, 0x8f9c, 0x2071, 0x0140, 0x7004, 0x9084,
-	0x4000, 0x0110, 0x080c, 0x2862, 0x080c, 0x709e, 0x0188, 0x080c,
-	0x70b9, 0x1170, 0x080c, 0x73a0, 0x0016, 0x080c, 0x2555, 0x2001,
-	0x193d, 0x2102, 0x001e, 0x080c, 0x739b, 0x080c, 0x6fc7, 0x0050,
-	0x2009, 0x0001, 0x080c, 0x283e, 0x2001, 0x0001, 0x080c, 0x23e2,
-	0x080c, 0x5b92, 0x012e, 0x000e, 0x00ee, 0x0005, 0x2001, 0x180e,
+	0x2071, 0x0100, 0x080c, 0x8fd0, 0x2071, 0x0140, 0x7004, 0x9084,
+	0x4000, 0x0110, 0x080c, 0x2882, 0x080c, 0x70c2, 0x0188, 0x080c,
+	0x70dd, 0x1170, 0x080c, 0x73c3, 0x0016, 0x080c, 0x2571, 0x2001,
+	0x1945, 0x2102, 0x001e, 0x080c, 0x73be, 0x080c, 0x6feb, 0x0050,
+	0x2009, 0x0001, 0x080c, 0x285e, 0x2001, 0x0001, 0x080c, 0x23fe,
+	0x080c, 0x5bb2, 0x012e, 0x000e, 0x00ee, 0x0005, 0x2001, 0x180e,
 	0x2004, 0xd0bc, 0x0158, 0x0026, 0x0036, 0x2011, 0x8017, 0x2001,
-	0x1969, 0x201c, 0x080c, 0x48da, 0x003e, 0x002e, 0x0005, 0x20a9,
-	0x0012, 0x20e9, 0x0001, 0x20a1, 0x1d80, 0x080c, 0x5cb1, 0x20e9,
-	0x0000, 0x2099, 0x026e, 0x0099, 0x20a9, 0x0020, 0x080c, 0x5cab,
+	0x1971, 0x201c, 0x080c, 0x48fa, 0x003e, 0x002e, 0x0005, 0x20a9,
+	0x0012, 0x20e9, 0x0001, 0x20a1, 0x1d80, 0x080c, 0x5cd1, 0x20e9,
+	0x0000, 0x2099, 0x026e, 0x0099, 0x20a9, 0x0020, 0x080c, 0x5ccb,
 	0x2099, 0x0260, 0x20a1, 0x1d92, 0x0051, 0x20a9, 0x000e, 0x080c,
-	0x5cae, 0x2099, 0x0260, 0x20a1, 0x1db2, 0x0009, 0x0005, 0x0016,
+	0x5cce, 0x2099, 0x0260, 0x20a1, 0x1db2, 0x0009, 0x0005, 0x0016,
 	0x0026, 0x3410, 0x3308, 0x2104, 0x8007, 0x2012, 0x8108, 0x8210,
-	0x1f04, 0x5c2b, 0x002e, 0x001e, 0x0005, 0x080c, 0x97e8, 0x20e1,
+	0x1f04, 0x5c4b, 0x002e, 0x001e, 0x0005, 0x080c, 0x97f4, 0x20e1,
 	0x0001, 0x2099, 0x1d00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9,
-	0x000c, 0x4003, 0x0005, 0x080c, 0x97e8, 0x080c, 0x5cb1, 0x20e1,
+	0x000c, 0x4003, 0x0005, 0x080c, 0x97f4, 0x080c, 0x5cd1, 0x20e1,
 	0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9,
 	0x000c, 0x4003, 0x0005, 0x00c6, 0x0006, 0x2061, 0x0100, 0x810f,
 	0x2001, 0x1833, 0x2004, 0x9005, 0x1138, 0x2001, 0x1817, 0x2004,
 	0x9084, 0x00ff, 0x9105, 0x0010, 0x9185, 0x00f7, 0x604a, 0x000e,
-	0x00ce, 0x0005, 0x0016, 0x0046, 0x080c, 0x6662, 0x0158, 0x9006,
-	0x2020, 0x2009, 0x002a, 0x080c, 0xd284, 0x2001, 0x180c, 0x200c,
-	0xc195, 0x2102, 0x2019, 0x002a, 0x900e, 0x080c, 0x2fd3, 0x080c,
-	0xbf61, 0x0140, 0x0036, 0x2019, 0xffff, 0x2021, 0x0007, 0x080c,
-	0x4a77, 0x003e, 0x004e, 0x001e, 0x0005, 0x080c, 0x5b92, 0x7097,
+	0x00ce, 0x0005, 0x0016, 0x0046, 0x080c, 0x6686, 0x0158, 0x9006,
+	0x2020, 0x2009, 0x002a, 0x080c, 0xd2bc, 0x2001, 0x180c, 0x200c,
+	0xc195, 0x2102, 0x2019, 0x002a, 0x900e, 0x080c, 0x2ff3, 0x080c,
+	0xbf8f, 0x0140, 0x0036, 0x2019, 0xffff, 0x2021, 0x0007, 0x080c,
+	0x4a97, 0x003e, 0x004e, 0x001e, 0x0005, 0x080c, 0x5bb2, 0x7097,
 	0x0000, 0x708f, 0x0000, 0x0005, 0x0006, 0x2001, 0x180c, 0x2004,
 	0xd09c, 0x0100, 0x000e, 0x0005, 0x0006, 0x0016, 0x0126, 0x2091,
 	0x8000, 0x2001, 0x0101, 0x200c, 0x918d, 0x0006, 0x2102, 0x012e,
@@ -2765,28 +2769,28 @@
 	0x0001, 0x20a1, 0x1d00, 0x4004, 0x2079, 0x1d00, 0x7803, 0x2200,
 	0x7807, 0x00ef, 0x780f, 0x00ef, 0x7813, 0x0138, 0x7823, 0xffff,
 	0x7827, 0xffff, 0x01de, 0x014e, 0x015e, 0x00fe, 0x0005, 0x2001,
-	0x1800, 0x2003, 0x0001, 0x0005, 0x2001, 0x1976, 0x0118, 0x2003,
+	0x1800, 0x2003, 0x0001, 0x0005, 0x2001, 0x197e, 0x0118, 0x2003,
 	0x0001, 0x0010, 0x2003, 0x0000, 0x0005, 0x0156, 0x20a9, 0x0800,
-	0x2009, 0x1000, 0x9006, 0x200a, 0x8108, 0x1f04, 0x5ceb, 0x015e,
-	0x0005, 0x00d6, 0x0036, 0x0156, 0x0136, 0x0146, 0x2069, 0x1853,
+	0x2009, 0x1000, 0x9006, 0x200a, 0x8108, 0x1f04, 0x5d0b, 0x015e,
+	0x0005, 0x00d6, 0x0036, 0x0156, 0x0136, 0x0146, 0x2069, 0x185b,
 	0x9006, 0xb802, 0xb8c6, 0xb807, 0x0707, 0xb80a, 0xb80e, 0xb812,
-	0x9198, 0x317f, 0x231d, 0x939c, 0x00ff, 0xbb16, 0x0016, 0x0026,
-	0xb886, 0x080c, 0x9b59, 0x1120, 0x9192, 0x007e, 0x1208, 0xbb86,
+	0x9198, 0x319f, 0x231d, 0x939c, 0x00ff, 0xbb16, 0x0016, 0x0026,
+	0xb886, 0x080c, 0x9b65, 0x1120, 0x9192, 0x007e, 0x1208, 0xbb86,
 	0x20a9, 0x0004, 0xb8b4, 0x20e8, 0xb9b8, 0x9198, 0x0006, 0x9006,
 	0x23a0, 0x4004, 0x20a9, 0x0004, 0x9198, 0x000a, 0x23a0, 0x4004,
 	0x002e, 0x001e, 0xb83e, 0xb842, 0xb8be, 0xb8c2, 0xb85e, 0xb862,
 	0xb866, 0xb86a, 0xb86f, 0x0100, 0xb872, 0xb876, 0xb87a, 0xb88a,
 	0xb88e, 0xb893, 0x0008, 0xb896, 0xb89a, 0xb89e, 0xb8ae, 0xb9a2,
-	0x0096, 0xb8a4, 0x904d, 0x0110, 0x080c, 0x1054, 0xb8a7, 0x0000,
+	0x0096, 0xb8a4, 0x904d, 0x0110, 0x080c, 0x1061, 0xb8a7, 0x0000,
 	0x009e, 0x9006, 0xb84a, 0x6810, 0xb83a, 0x680c, 0xb846, 0x6814,
 	0x9084, 0x00ff, 0xb842, 0x014e, 0x013e, 0x015e, 0x003e, 0x00de,
 	0x0005, 0x0126, 0x2091, 0x8000, 0xa974, 0xae78, 0x9684, 0x3fff,
-	0x9082, 0x4000, 0x1a04, 0x5daf, 0x9182, 0x0800, 0x1a04, 0x5db3,
-	0x2001, 0x180c, 0x2004, 0x9084, 0x0003, 0x1904, 0x5db9, 0x9188,
+	0x9082, 0x4000, 0x1a04, 0x5dcf, 0x9182, 0x0800, 0x1a04, 0x5dd3,
+	0x2001, 0x180c, 0x2004, 0x9084, 0x0003, 0x1904, 0x5dd9, 0x9188,
 	0x1000, 0x2104, 0x905d, 0x0198, 0xb804, 0x9084, 0x00ff, 0x908e,
-	0x0006, 0x1188, 0xb8a4, 0x900d, 0x1904, 0x5dcb, 0x080c, 0x6125,
+	0x0006, 0x1188, 0xb8a4, 0x900d, 0x1904, 0x5deb, 0x080c, 0x6149,
 	0x9006, 0x012e, 0x0005, 0x2001, 0x0005, 0x900e, 0x04b8, 0x2001,
-	0x0028, 0x900e, 0x0498, 0x9082, 0x0006, 0x1290, 0x080c, 0x9b59,
+	0x0028, 0x900e, 0x0498, 0x9082, 0x0006, 0x1290, 0x080c, 0x9b65,
 	0x1160, 0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900, 0xd1fc, 0x0d10,
 	0x2001, 0x0029, 0x2009, 0x1000, 0x0408, 0x2001, 0x0028, 0x00a8,
 	0x2009, 0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0068,
@@ -2794,22 +2798,22 @@
 	0xd1fc, 0x0118, 0x2009, 0x1000, 0x0048, 0x900e, 0x0038, 0x2001,
 	0x0029, 0x900e, 0x0018, 0x2001, 0x0029, 0x900e, 0x9005, 0x012e,
 	0x0005, 0x2001, 0x180c, 0x2004, 0xd084, 0x19d0, 0x9188, 0x1000,
-	0x2104, 0x9065, 0x09a8, 0x080c, 0x6666, 0x1990, 0xb800, 0xd0bc,
-	0x0978, 0x0804, 0x5d72, 0x080c, 0x64da, 0x0904, 0x5d7b, 0x0804,
-	0x5d76, 0x00e6, 0x2071, 0x19b7, 0x7004, 0x9086, 0x0002, 0x1128,
+	0x2104, 0x9065, 0x09a8, 0x080c, 0x668a, 0x1990, 0xb800, 0xd0bc,
+	0x0978, 0x0804, 0x5d92, 0x080c, 0x64fe, 0x0904, 0x5d9b, 0x0804,
+	0x5d96, 0x00e6, 0x2071, 0x19bf, 0x7004, 0x9086, 0x0002, 0x1128,
 	0x7030, 0x9080, 0x0004, 0x2004, 0x9b06, 0x00ee, 0x0005, 0x00b6,
 	0x00e6, 0x0126, 0x2091, 0x8000, 0xa974, 0x9182, 0x0800, 0x1a04,
-	0x5e5a, 0x9188, 0x1000, 0x2104, 0x905d, 0x0904, 0x5e32, 0xb8a0,
-	0x9086, 0x007f, 0x0178, 0x080c, 0x666e, 0x0160, 0xa994, 0x81ff,
+	0x5e7a, 0x9188, 0x1000, 0x2104, 0x905d, 0x0904, 0x5e52, 0xb8a0,
+	0x9086, 0x007f, 0x0178, 0x080c, 0x6692, 0x0160, 0xa994, 0x81ff,
 	0x0130, 0x908e, 0x0004, 0x0130, 0x908e, 0x0005, 0x0118, 0x080c,
-	0x6666, 0x1598, 0xa87c, 0xd0fc, 0x01e0, 0xa894, 0x9005, 0x01c8,
-	0x2060, 0x0026, 0x2010, 0x080c, 0xb830, 0x002e, 0x1120, 0x2001,
-	0x0008, 0x0804, 0x5e5c, 0x6020, 0x9086, 0x000a, 0x0120, 0x2001,
-	0x0008, 0x0804, 0x5e5c, 0x601a, 0x6003, 0x0008, 0x2900, 0x6016,
-	0x0058, 0x080c, 0x9b84, 0x05e8, 0x2b00, 0x6012, 0x2900, 0x6016,
-	0x600b, 0xffff, 0x6023, 0x000a, 0x2009, 0x0003, 0x080c, 0x9c76,
+	0x668a, 0x1598, 0xa87c, 0xd0fc, 0x01e0, 0xa894, 0x9005, 0x01c8,
+	0x2060, 0x0026, 0x2010, 0x080c, 0xb85e, 0x002e, 0x1120, 0x2001,
+	0x0008, 0x0804, 0x5e7c, 0x6020, 0x9086, 0x000a, 0x0120, 0x2001,
+	0x0008, 0x0804, 0x5e7c, 0x601a, 0x6003, 0x0008, 0x2900, 0x6016,
+	0x0058, 0x080c, 0x9b90, 0x05e8, 0x2b00, 0x6012, 0x2900, 0x6016,
+	0x600b, 0xffff, 0x6023, 0x000a, 0x2009, 0x0003, 0x080c, 0x9c82,
 	0x9006, 0x0458, 0x2001, 0x0028, 0x0438, 0x9082, 0x0006, 0x1290,
-	0x080c, 0x9b59, 0x1160, 0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900,
+	0x080c, 0x9b65, 0x1160, 0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900,
 	0xd1fc, 0x0900, 0x2001, 0x0029, 0x2009, 0x1000, 0x00a8, 0x2001,
 	0x0028, 0x0090, 0x2009, 0x180c, 0x210c, 0xd18c, 0x0118, 0x2001,
 	0x0004, 0x0050, 0xd184, 0x0118, 0x2001, 0x0004, 0x0028, 0x2001,
@@ -2822,3596 +2826,3599 @@
 	0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001,
 	0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0038, 0x2001, 0x002c,
 	0x900e, 0x0018, 0x2001, 0x0029, 0x900e, 0x9006, 0x0008, 0x9005,
-	0x012e, 0x00be, 0x00fe, 0x0005, 0x5ef1, 0x5eac, 0x5ec3, 0x5ef1,
-	0x5ef1, 0x5ef1, 0x5ef1, 0x5ef1, 0x2100, 0x9082, 0x007e, 0x1278,
-	0x080c, 0x620b, 0x0148, 0x9046, 0xb810, 0x9306, 0x1904, 0x5ef9,
+	0x012e, 0x00be, 0x00fe, 0x0005, 0x5f11, 0x5ecc, 0x5ee3, 0x5f11,
+	0x5f11, 0x5f11, 0x5f11, 0x5f11, 0x2100, 0x9082, 0x007e, 0x1278,
+	0x080c, 0x622f, 0x0148, 0x9046, 0xb810, 0x9306, 0x1904, 0x5f19,
 	0xb814, 0x9206, 0x15f0, 0x0028, 0xbb12, 0xba16, 0x0010, 0x080c,
-	0x4794, 0x0150, 0x04b0, 0x080c, 0x626b, 0x1598, 0xb810, 0x9306,
-	0x1580, 0xb814, 0x9206, 0x1568, 0x080c, 0x9b84, 0x0530, 0x2b00,
-	0x6012, 0x080c, 0xbcdb, 0x2900, 0x6016, 0x600b, 0xffff, 0x6023,
-	0x000a, 0xa878, 0x9086, 0x0001, 0x1170, 0x080c, 0x300e, 0x9006,
-	0x080c, 0x61a8, 0x2001, 0x0002, 0x080c, 0x61bc, 0x2001, 0x0200,
-	0xb86e, 0xb893, 0x0002, 0x2009, 0x0003, 0x080c, 0x9c76, 0x9006,
+	0x47b4, 0x0150, 0x04b0, 0x080c, 0x628f, 0x1598, 0xb810, 0x9306,
+	0x1580, 0xb814, 0x9206, 0x1568, 0x080c, 0x9b90, 0x0530, 0x2b00,
+	0x6012, 0x080c, 0xbd09, 0x2900, 0x6016, 0x600b, 0xffff, 0x6023,
+	0x000a, 0xa878, 0x9086, 0x0001, 0x1170, 0x080c, 0x302e, 0x9006,
+	0x080c, 0x61cc, 0x2001, 0x0002, 0x080c, 0x61e0, 0x2001, 0x0200,
+	0xb86e, 0xb893, 0x0002, 0x2009, 0x0003, 0x080c, 0x9c82, 0x9006,
 	0x0068, 0x2001, 0x0001, 0x900e, 0x0038, 0x2001, 0x002c, 0x900e,
 	0x0018, 0x2001, 0x0028, 0x900e, 0x9005, 0x0000, 0x012e, 0x00be,
 	0x00fe, 0x0005, 0x00b6, 0x00f6, 0x00e6, 0x0126, 0x2091, 0x8000,
-	0xa894, 0x90c6, 0x0015, 0x0904, 0x60ce, 0x90c6, 0x0056, 0x0904,
-	0x60d2, 0x90c6, 0x0066, 0x0904, 0x60d6, 0x90c6, 0x0067, 0x0904,
-	0x60da, 0x90c6, 0x0068, 0x0904, 0x60de, 0x90c6, 0x0071, 0x0904,
-	0x60e2, 0x90c6, 0x0074, 0x0904, 0x60e6, 0x90c6, 0x007c, 0x0904,
-	0x60ea, 0x90c6, 0x007e, 0x0904, 0x60ee, 0x90c6, 0x0037, 0x0904,
-	0x60f2, 0x9016, 0x2079, 0x1800, 0xa974, 0x9186, 0x00ff, 0x0904,
-	0x60c9, 0x9182, 0x0800, 0x1a04, 0x60c9, 0x080c, 0x626b, 0x1198,
+	0xa894, 0x90c6, 0x0015, 0x0904, 0x60f2, 0x90c6, 0x0056, 0x0904,
+	0x60f6, 0x90c6, 0x0066, 0x0904, 0x60fa, 0x90c6, 0x0067, 0x0904,
+	0x60fe, 0x90c6, 0x0068, 0x0904, 0x6102, 0x90c6, 0x0071, 0x0904,
+	0x6106, 0x90c6, 0x0074, 0x0904, 0x610a, 0x90c6, 0x007c, 0x0904,
+	0x610e, 0x90c6, 0x007e, 0x0904, 0x6112, 0x90c6, 0x0037, 0x0904,
+	0x6116, 0x9016, 0x2079, 0x1800, 0xa974, 0x9186, 0x00ff, 0x0904,
+	0x60ed, 0x9182, 0x0800, 0x1a04, 0x60ed, 0x080c, 0x628f, 0x1198,
 	0xb804, 0x9084, 0x00ff, 0x9082, 0x0006, 0x1268, 0xa894, 0x90c6,
-	0x006f, 0x0148, 0x080c, 0x9b59, 0x1904, 0x60b2, 0xb8a0, 0x9084,
-	0xff80, 0x1904, 0x60b2, 0xa894, 0x90c6, 0x006f, 0x0158, 0x90c6,
-	0x005e, 0x0904, 0x6012, 0x90c6, 0x0064, 0x0904, 0x603b, 0x2008,
-	0x0804, 0x5fd5, 0xa998, 0xa8b0, 0x2040, 0x080c, 0x9b59, 0x1120,
-	0x9182, 0x007f, 0x0a04, 0x5fd5, 0x9186, 0x00ff, 0x0904, 0x5fd5,
-	0x9182, 0x0800, 0x1a04, 0x5fd5, 0xaaa0, 0xab9c, 0x7878, 0x9306,
-	0x1188, 0x787c, 0x0096, 0x924e, 0x1128, 0x2208, 0x2310, 0x009e,
-	0x0804, 0x5fd5, 0x99cc, 0xff00, 0x009e, 0x1120, 0x2208, 0x2310,
-	0x0804, 0x5fd5, 0x080c, 0x4794, 0x0904, 0x5fde, 0x900e, 0x9016,
-	0x90c6, 0x4000, 0x1558, 0x0006, 0x080c, 0x655e, 0x1108, 0xc185,
-	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x20a9, 0x0004, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0031, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080,
-	0x0006, 0x2098, 0x080c, 0x0f9f, 0x20a9, 0x0004, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0035, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080,
-	0x000a, 0x2098, 0x080c, 0x0f9f, 0x000e, 0x00c8, 0x90c6, 0x4007,
-	0x1110, 0x2408, 0x00a0, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610,
-	0x0070, 0x90c6, 0x4009, 0x1108, 0x0050, 0x90c6, 0x4006, 0x0138,
-	0x2001, 0x4005, 0x2009, 0x000a, 0x0010, 0x2001, 0x4006, 0xa896,
-	0xa99a, 0xaa9e, 0x2001, 0x0030, 0x900e, 0x0470, 0x080c, 0x9b84,
-	0x1130, 0x2001, 0x4005, 0x2009, 0x0003, 0x9016, 0x0c80, 0x2b00,
-	0x6012, 0x080c, 0xbcdb, 0x2900, 0x6016, 0x6023, 0x0001, 0xa868,
-	0xd88c, 0x0108, 0xc0f5, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x300e, 0x012e, 0x9006, 0x080c, 0x61a8, 0x2001, 0x0002, 0x080c,
-	0x61bc, 0x2009, 0x0002, 0x080c, 0x9c76, 0xa8b0, 0xd094, 0x0118,
-	0xb8c4, 0xc08d, 0xb8c6, 0x9006, 0x9005, 0x012e, 0x00ee, 0x00fe,
-	0x00be, 0x0005, 0x080c, 0x539c, 0x0118, 0x2009, 0x0007, 0x00f8,
-	0xa998, 0xaeb0, 0x080c, 0x626b, 0x1904, 0x5fd0, 0x9186, 0x007f,
-	0x0130, 0x080c, 0x6666, 0x0118, 0x2009, 0x0009, 0x0080, 0x0096,
-	0x080c, 0x1022, 0x1120, 0x009e, 0x2009, 0x0002, 0x0040, 0x2900,
-	0x009e, 0xa806, 0x080c, 0xba2e, 0x19b0, 0x2009, 0x0003, 0x2001,
-	0x4005, 0x0804, 0x5fd7, 0xa998, 0xaeb0, 0x080c, 0x626b, 0x1904,
-	0x5fd0, 0x0096, 0x080c, 0x1022, 0x1128, 0x009e, 0x2009, 0x0002,
-	0x0804, 0x608f, 0x2900, 0x009e, 0xa806, 0x0096, 0x2048, 0x20a9,
-	0x002b, 0xb8b4, 0x20e0, 0xb8b8, 0x2098, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006,
-	0x20a0, 0xbbb8, 0x9398, 0x0006, 0x2398, 0x080c, 0x0f9f, 0x009e,
-	0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xd684, 0x1168,
-	0x080c, 0x5388, 0xd0b4, 0x1118, 0xa89b, 0x000b, 0x00e0, 0xb800,
-	0xd08c, 0x0118, 0xa89b, 0x000c, 0x00b0, 0x080c, 0x6666, 0x0118,
-	0xa89b, 0x0009, 0x0080, 0x080c, 0x539c, 0x0118, 0xa89b, 0x0007,
-	0x0050, 0x080c, 0xba11, 0x1904, 0x600b, 0x2009, 0x0003, 0x2001,
-	0x4005, 0x0804, 0x5fd7, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa804,
-	0x8006, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
-	0x0002, 0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031,
-	0x0000, 0x2041, 0x1271, 0x080c, 0xa0e7, 0x1904, 0x600b, 0x2009,
-	0x0002, 0x08e8, 0x2001, 0x0028, 0x900e, 0x0804, 0x600c, 0x2009,
-	0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184,
-	0x0118, 0x2001, 0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0804,
-	0x600c, 0x2001, 0x0029, 0x900e, 0x0804, 0x600c, 0x080c, 0x35ad,
-	0x0804, 0x600d, 0x080c, 0x50bd, 0x0804, 0x600d, 0x080c, 0x4353,
-	0x0804, 0x600d, 0x080c, 0x43cc, 0x0804, 0x600d, 0x080c, 0x4428,
-	0x0804, 0x600d, 0x080c, 0x4850, 0x0804, 0x600d, 0x080c, 0x4af5,
-	0x0804, 0x600d, 0x080c, 0x4d28, 0x0804, 0x600d, 0x080c, 0x4f21,
-	0x0804, 0x600d, 0x080c, 0x37c2, 0x0804, 0x600d, 0x00b6, 0xa974,
-	0xae78, 0x9684, 0x3fff, 0x9082, 0x4000, 0x1608, 0x9182, 0x0800,
-	0x1258, 0x9188, 0x1000, 0x2104, 0x905d, 0x0130, 0x080c, 0x6666,
-	0x1138, 0x00d9, 0x9006, 0x00b0, 0x2001, 0x0028, 0x900e, 0x0090,
-	0x9082, 0x0006, 0x1240, 0xb900, 0xd1fc, 0x0d98, 0x2001, 0x0029,
-	0x2009, 0x1000, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018, 0x2001,
-	0x0029, 0x900e, 0x9005, 0x00be, 0x0005, 0xa877, 0x0000, 0xb8c0,
-	0x9005, 0x1904, 0x619c, 0xb888, 0x9005, 0x1904, 0x619c, 0xb838,
-	0xb93c, 0x9102, 0x1a04, 0x619c, 0x2b10, 0x080c, 0x9bb1, 0x0904,
-	0x6198, 0x8108, 0xb93e, 0x6212, 0x2900, 0x6016, 0x6023, 0x0003,
-	0x600b, 0xffff, 0x6007, 0x0040, 0xa878, 0x605e, 0xa880, 0x9084,
-	0x00ff, 0x6066, 0xa883, 0x0000, 0xa87c, 0xd0ac, 0x05c0, 0xc0dd,
-	0xa87e, 0xa888, 0x8001, 0x1568, 0x2001, 0x00f8, 0x8001, 0xa001,
-	0xa001, 0xa001, 0x1dd8, 0xa816, 0xa864, 0x9094, 0x00f7, 0x9296,
-	0x0011, 0x11f8, 0x9084, 0x00ff, 0xc0bd, 0x601e, 0xa8ac, 0xaab0,
-	0xa836, 0xaa3a, 0x2001, 0x000f, 0x8001, 0x1df0, 0x2001, 0x8004,
-	0x6003, 0x0004, 0x6046, 0x00f6, 0x2079, 0x0380, 0x7818, 0xd0bc,
-	0x1de8, 0x7833, 0x0010, 0x2c00, 0x7836, 0x781b, 0x8080, 0x00fe,
-	0x0005, 0x080c, 0x165c, 0x601c, 0xc0bd, 0x601e, 0x0c38, 0x0006,
-	0x2001, 0x00e8, 0x8001, 0xa001, 0xa001, 0xa001, 0x1dd8, 0x000e,
-	0xd0b4, 0x190c, 0x1adf, 0x2001, 0x8004, 0x6003, 0x0002, 0x08d0,
-	0x81ff, 0x1110, 0xb88b, 0x0001, 0x2908, 0xb8bc, 0xb9be, 0x9005,
-	0x1110, 0xb9c2, 0x0020, 0x0096, 0x2048, 0xa902, 0x009e, 0x0005,
-	0x00b6, 0x0126, 0x00c6, 0x0026, 0x2091, 0x8000, 0x6210, 0x2258,
-	0xba00, 0x9005, 0x0110, 0xc285, 0x0008, 0xc284, 0xba02, 0x002e,
-	0x00ce, 0x012e, 0x00be, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x2091,
-	0x8000, 0x6210, 0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1170,
-	0xb89c, 0xd0ac, 0x0158, 0x080c, 0x6662, 0x0140, 0x9284, 0xff00,
-	0x8007, 0x9086, 0x0007, 0x1110, 0x2011, 0x0600, 0x000e, 0x9294,
-	0xff00, 0x9215, 0xba06, 0x0006, 0x9086, 0x0006, 0x1120, 0xba90,
-	0x82ff, 0x090c, 0x0d65, 0x000e, 0x00ce, 0x012e, 0x00be, 0x0005,
+	0x006f, 0x0148, 0x080c, 0x9b65, 0x1904, 0x60d6, 0xb8a0, 0x9084,
+	0xff80, 0x1904, 0x60d6, 0xa894, 0x90c6, 0x006f, 0x0158, 0x90c6,
+	0x005e, 0x0904, 0x6036, 0x90c6, 0x0064, 0x0904, 0x605f, 0x2008,
+	0x0804, 0x5ff9, 0xa998, 0xa8b0, 0x2040, 0x080c, 0x9b65, 0x1120,
+	0x9182, 0x007f, 0x0a04, 0x5ff9, 0x9186, 0x00ff, 0x0904, 0x5ff9,
+	0x9182, 0x0800, 0x1a04, 0x5ff9, 0xaaa0, 0xab9c, 0x7878, 0x9306,
+	0x11a8, 0x787c, 0x0096, 0x924e, 0x1128, 0x2208, 0x2310, 0x009e,
+	0x0804, 0x5ff9, 0x080c, 0x9b65, 0x1140, 0x99cc, 0xff00, 0x009e,
+	0x1128, 0x2208, 0x2310, 0x0804, 0x5ff9, 0x009e, 0x080c, 0x47b4,
+	0x0904, 0x6002, 0x900e, 0x9016, 0x90c6, 0x4000, 0x1558, 0x0006,
+	0x080c, 0x6582, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d,
+	0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031, 0x20a0,
+	0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098, 0x080c, 0x0fac,
+	0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0035, 0x20a0,
+	0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x000a, 0x2098, 0x080c, 0x0fac,
+	0x000e, 0x00c8, 0x90c6, 0x4007, 0x1110, 0x2408, 0x00a0, 0x90c6,
+	0x4008, 0x1118, 0x2708, 0x2610, 0x0070, 0x90c6, 0x4009, 0x1108,
+	0x0050, 0x90c6, 0x4006, 0x0138, 0x2001, 0x4005, 0x2009, 0x000a,
+	0x0010, 0x2001, 0x4006, 0xa896, 0xa99a, 0xaa9e, 0x2001, 0x0030,
+	0x900e, 0x0470, 0x080c, 0x9b90, 0x1130, 0x2001, 0x4005, 0x2009,
+	0x0003, 0x9016, 0x0c80, 0x2b00, 0x6012, 0x080c, 0xbd09, 0x2900,
+	0x6016, 0x6023, 0x0001, 0xa868, 0xd88c, 0x0108, 0xc0f5, 0xa86a,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x302e, 0x012e, 0x9006, 0x080c,
+	0x61cc, 0x2001, 0x0002, 0x080c, 0x61e0, 0x2009, 0x0002, 0x080c,
+	0x9c82, 0xa8b0, 0xd094, 0x0118, 0xb8c4, 0xc08d, 0xb8c6, 0x9006,
+	0x9005, 0x012e, 0x00ee, 0x00fe, 0x00be, 0x0005, 0x080c, 0x53bc,
+	0x0118, 0x2009, 0x0007, 0x00f8, 0xa998, 0xaeb0, 0x080c, 0x628f,
+	0x1904, 0x5ff4, 0x9186, 0x007f, 0x0130, 0x080c, 0x668a, 0x0118,
+	0x2009, 0x0009, 0x0080, 0x0096, 0x080c, 0x102f, 0x1120, 0x009e,
+	0x2009, 0x0002, 0x0040, 0x2900, 0x009e, 0xa806, 0x080c, 0xba5c,
+	0x19b0, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804, 0x5ffb, 0xa998,
+	0xaeb0, 0x080c, 0x628f, 0x1904, 0x5ff4, 0x0096, 0x080c, 0x102f,
+	0x1128, 0x009e, 0x2009, 0x0002, 0x0804, 0x60b3, 0x2900, 0x009e,
+	0xa806, 0x0096, 0x2048, 0x20a9, 0x002b, 0xb8b4, 0x20e0, 0xb8b8,
+	0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003,
+	0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0, 0xbbb8, 0x9398, 0x0006,
+	0x2398, 0x080c, 0x0fac, 0x009e, 0xa87b, 0x0000, 0xa883, 0x0000,
+	0xa897, 0x4000, 0xd684, 0x1168, 0x080c, 0x53a8, 0xd0b4, 0x1118,
+	0xa89b, 0x000b, 0x00e0, 0xb800, 0xd08c, 0x0118, 0xa89b, 0x000c,
+	0x00b0, 0x080c, 0x668a, 0x0118, 0xa89b, 0x0009, 0x0080, 0x080c,
+	0x53bc, 0x0118, 0xa89b, 0x0007, 0x0050, 0x080c, 0xba3f, 0x1904,
+	0x602f, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804, 0x5ffb, 0xa87b,
+	0x0030, 0xa897, 0x4005, 0xa804, 0x8006, 0x8006, 0x8007, 0x90bc,
+	0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009, 0x002b, 0xaaa0,
+	0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x127e, 0x080c,
+	0xa0f3, 0x1904, 0x602f, 0x2009, 0x0002, 0x08e8, 0x2001, 0x0028,
+	0x900e, 0x0804, 0x6030, 0x2009, 0x180c, 0x210c, 0xd18c, 0x0118,
+	0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004, 0x0010,
+	0x2001, 0x0029, 0x900e, 0x0804, 0x6030, 0x2001, 0x0029, 0x900e,
+	0x0804, 0x6030, 0x080c, 0x35cd, 0x0804, 0x6031, 0x080c, 0x50dd,
+	0x0804, 0x6031, 0x080c, 0x4373, 0x0804, 0x6031, 0x080c, 0x43ec,
+	0x0804, 0x6031, 0x080c, 0x4448, 0x0804, 0x6031, 0x080c, 0x4870,
+	0x0804, 0x6031, 0x080c, 0x4b15, 0x0804, 0x6031, 0x080c, 0x4d48,
+	0x0804, 0x6031, 0x080c, 0x4f41, 0x0804, 0x6031, 0x080c, 0x37e2,
+	0x0804, 0x6031, 0x00b6, 0xa974, 0xae78, 0x9684, 0x3fff, 0x9082,
+	0x4000, 0x1608, 0x9182, 0x0800, 0x1258, 0x9188, 0x1000, 0x2104,
+	0x905d, 0x0130, 0x080c, 0x668a, 0x1138, 0x00d9, 0x9006, 0x00b0,
+	0x2001, 0x0028, 0x900e, 0x0090, 0x9082, 0x0006, 0x1240, 0xb900,
+	0xd1fc, 0x0d98, 0x2001, 0x0029, 0x2009, 0x1000, 0x0038, 0x2001,
+	0x0029, 0x900e, 0x0018, 0x2001, 0x0029, 0x900e, 0x9005, 0x00be,
+	0x0005, 0xa877, 0x0000, 0xb8c0, 0x9005, 0x1904, 0x61c0, 0xb888,
+	0x9005, 0x1904, 0x61c0, 0xb838, 0xb93c, 0x9102, 0x1a04, 0x61c0,
+	0x2b10, 0x080c, 0x9bbd, 0x0904, 0x61bc, 0x8108, 0xb93e, 0x6212,
+	0x2900, 0x6016, 0x6023, 0x0003, 0x600b, 0xffff, 0x6007, 0x0040,
+	0xa878, 0x605e, 0xa880, 0x9084, 0x00ff, 0x6066, 0xa883, 0x0000,
+	0xa87c, 0xd0ac, 0x05c0, 0xc0dd, 0xa87e, 0xa888, 0x8001, 0x1568,
+	0x2001, 0x00f8, 0x8001, 0xa001, 0xa001, 0xa001, 0x1dd8, 0xa816,
+	0xa864, 0x9094, 0x00f7, 0x9296, 0x0011, 0x11f8, 0x9084, 0x00ff,
+	0xc0bd, 0x601e, 0xa8ac, 0xaab0, 0xa836, 0xaa3a, 0x2001, 0x000f,
+	0x8001, 0x1df0, 0x2001, 0x8004, 0x6003, 0x0004, 0x6046, 0x00f6,
+	0x2079, 0x0380, 0x7818, 0xd0bc, 0x1de8, 0x7833, 0x0010, 0x2c00,
+	0x7836, 0x781b, 0x8080, 0x00fe, 0x0005, 0x080c, 0x1669, 0x601c,
+	0xc0bd, 0x601e, 0x0c38, 0x0006, 0x2001, 0x00e8, 0x8001, 0xa001,
+	0xa001, 0xa001, 0x1dd8, 0x000e, 0xd0b4, 0x190c, 0x1af7, 0x2001,
+	0x8004, 0x6003, 0x0002, 0x08d0, 0x81ff, 0x1110, 0xb88b, 0x0001,
+	0x2908, 0xb8bc, 0xb9be, 0x9005, 0x1110, 0xb9c2, 0x0020, 0x0096,
+	0x2048, 0xa902, 0x009e, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x0026,
+	0x2091, 0x8000, 0x6210, 0x2258, 0xba00, 0x9005, 0x0110, 0xc285,
+	0x0008, 0xc284, 0xba02, 0x002e, 0x00ce, 0x012e, 0x00be, 0x0005,
 	0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x6210, 0x2258, 0xba04,
-	0x0006, 0x9086, 0x0006, 0x1168, 0xb89c, 0xd0a4, 0x0150, 0x080c,
-	0x665e, 0x1138, 0x9284, 0x00ff, 0x9086, 0x0007, 0x1110, 0x2011,
-	0x0006, 0x000e, 0x9294, 0x00ff, 0x8007, 0x9215, 0xba06, 0x00ce,
-	0x012e, 0x00be, 0x0005, 0x9182, 0x0800, 0x0218, 0x9085, 0x0001,
-	0x0005, 0x00d6, 0x0026, 0x9190, 0x1000, 0x2204, 0x905d, 0x1180,
-	0x0096, 0x080c, 0x1022, 0x2958, 0x009e, 0x0160, 0x2b00, 0x2012,
-	0xb85c, 0xb8ba, 0xb860, 0xb8b6, 0x9006, 0xb8a6, 0x080c, 0x5cf1,
-	0x9006, 0x0010, 0x9085, 0x0001, 0x002e, 0x00de, 0x0005, 0x00b6,
-	0x0096, 0x0126, 0x2091, 0x8000, 0x0026, 0x9182, 0x0800, 0x0218,
-	0x9085, 0x0001, 0x0458, 0x00d6, 0x9190, 0x1000, 0x2204, 0x905d,
-	0x0518, 0x2013, 0x0000, 0xb8a4, 0x904d, 0x0110, 0x080c, 0x1054,
-	0x00d6, 0x00c6, 0xb8ac, 0x2060, 0x8cff, 0x0168, 0x600c, 0x0006,
-	0x6014, 0x2048, 0x080c, 0xb842, 0x0110, 0x080c, 0x0fd4, 0x080c,
-	0x9bda, 0x00ce, 0x0c88, 0x00ce, 0x00de, 0x2b48, 0xb8b8, 0xb85e,
-	0xb8b4, 0xb862, 0x080c, 0x1064, 0x00de, 0x9006, 0x002e, 0x012e,
-	0x009e, 0x00be, 0x0005, 0x0016, 0x9182, 0x0800, 0x0218, 0x9085,
-	0x0001, 0x0030, 0x9188, 0x1000, 0x2104, 0x905d, 0x0dc0, 0x9006,
-	0x001e, 0x0005, 0x00d6, 0x0156, 0x0136, 0x0146, 0x9006, 0xb80a,
-	0xb80e, 0xb800, 0xc08c, 0xb802, 0x080c, 0x7096, 0x1510, 0xb8a0,
-	0x9086, 0x007e, 0x0120, 0x080c, 0x9b59, 0x11d8, 0x0078, 0x7040,
-	0xd0e4, 0x01b8, 0x00c6, 0x2061, 0x1952, 0x7048, 0x2062, 0x704c,
-	0x6006, 0x7050, 0x600a, 0x7054, 0x600e, 0x00ce, 0x703c, 0x2069,
-	0x0140, 0x9005, 0x1110, 0x2001, 0x0001, 0x6886, 0x2069, 0x1800,
-	0x68b2, 0x7040, 0xb85e, 0x7048, 0xb862, 0x704c, 0xb866, 0x20e1,
-	0x0000, 0x2099, 0x0276, 0xb8b4, 0x20e8, 0xb8b8, 0x9088, 0x000a,
-	0x21a0, 0x20a9, 0x0004, 0x4003, 0x2099, 0x027a, 0x9088, 0x0006,
-	0x21a0, 0x20a9, 0x0004, 0x4003, 0x2069, 0x0200, 0x6817, 0x0001,
-	0x7040, 0xb86a, 0x7144, 0xb96e, 0x7048, 0xb872, 0x7050, 0xb876,
-	0x2069, 0x0200, 0x6817, 0x0000, 0xb8a0, 0x9086, 0x007e, 0x1110,
-	0x7144, 0xb96e, 0x9182, 0x0211, 0x1218, 0x2009, 0x0008, 0x0400,
-	0x9182, 0x0259, 0x1218, 0x2009, 0x0007, 0x00d0, 0x9182, 0x02c1,
-	0x1218, 0x2009, 0x0006, 0x00a0, 0x9182, 0x0349, 0x1218, 0x2009,
-	0x0005, 0x0070, 0x9182, 0x0421, 0x1218, 0x2009, 0x0004, 0x0040,
-	0x9182, 0x0581, 0x1218, 0x2009, 0x0003, 0x0010, 0x2009, 0x0002,
-	0xb992, 0x014e, 0x013e, 0x015e, 0x00de, 0x0005, 0x0016, 0x0026,
-	0x00e6, 0x2071, 0x0260, 0x7034, 0xb896, 0x703c, 0xb89a, 0x7054,
-	0xb89e, 0x0036, 0xbbc4, 0xc384, 0xba00, 0x2009, 0x1873, 0x210c,
-	0xd0bc, 0x0120, 0xd1ec, 0x0110, 0xc2ad, 0x0008, 0xc2ac, 0xd0c4,
-	0x0148, 0xd1e4, 0x0138, 0xc2bd, 0xd0cc, 0x0128, 0xd38c, 0x1108,
-	0xc385, 0x0008, 0xc2bc, 0xba02, 0xbbc6, 0x003e, 0x00ee, 0x002e,
-	0x001e, 0x0005, 0x0096, 0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d,
-	0x0578, 0xa900, 0x81ff, 0x15c0, 0xaa04, 0x9282, 0x0010, 0x16c8,
-	0x0136, 0x0146, 0x01c6, 0x01d6, 0x8906, 0x8006, 0x8007, 0x908c,
-	0x003f, 0x21e0, 0x9084, 0xffc0, 0x9080, 0x0004, 0x2098, 0x2009,
-	0x0010, 0x20a9, 0x0001, 0x4002, 0x9086, 0xffff, 0x0120, 0x8109,
-	0x1dd0, 0x080c, 0x0d65, 0x3c00, 0x20e8, 0x3300, 0x8001, 0x20a0,
-	0x4604, 0x8210, 0xaa06, 0x01de, 0x01ce, 0x014e, 0x013e, 0x0060,
-	0x080c, 0x1022, 0x0170, 0x2900, 0xb8a6, 0xa803, 0x0000, 0x080c,
-	0x64fa, 0xa807, 0x0001, 0xae12, 0x9085, 0x0001, 0x012e, 0x009e,
-	0x0005, 0x9006, 0x0cd8, 0x0126, 0x2091, 0x8000, 0x0096, 0xb8a4,
-	0x904d, 0x0188, 0xa800, 0x9005, 0x1150, 0x080c, 0x6509, 0x1158,
-	0xa804, 0x908a, 0x0002, 0x0218, 0x8001, 0xa806, 0x0020, 0x080c,
-	0x1054, 0xb8a7, 0x0000, 0x009e, 0x012e, 0x0005, 0x0096, 0x00c6,
-	0xb888, 0x9005, 0x1904, 0x63ef, 0xb8c0, 0x904d, 0x0904, 0x63ef,
-	0x080c, 0x9bb1, 0x0904, 0x63eb, 0x8210, 0xba3e, 0xa800, 0xb8c2,
-	0x9005, 0x1108, 0xb8be, 0x2b00, 0x6012, 0x2900, 0x6016, 0x6023,
-	0x0003, 0x600b, 0xffff, 0x6007, 0x0040, 0xa878, 0x605e, 0xa880,
-	0x9084, 0x00ff, 0x6066, 0xa883, 0x0000, 0xa87c, 0xd0ac, 0x01c8,
-	0xc0dd, 0xa87e, 0xa888, 0x8001, 0x1568, 0xa816, 0xa864, 0x9094,
-	0x00f7, 0x9296, 0x0011, 0x1530, 0x9084, 0x00ff, 0xc0bd, 0x601e,
-	0xa8ac, 0xaab0, 0xa836, 0xaa3a, 0x2001, 0x8004, 0x6003, 0x0004,
-	0x0030, 0x080c, 0x1adf, 0x2001, 0x8004, 0x6003, 0x0002, 0x6046,
-	0x2001, 0x0010, 0x2c08, 0x080c, 0x98ac, 0xb838, 0xba3c, 0x9202,
-	0x0a04, 0x639c, 0x0020, 0x82ff, 0x1110, 0xb88b, 0x0001, 0x00ce,
-	0x009e, 0x0005, 0x080c, 0x165c, 0x601c, 0xc0bd, 0x601e, 0x08e0,
-	0x00b6, 0x0096, 0x0016, 0x20a9, 0x0800, 0x900e, 0x0016, 0x080c,
-	0x626b, 0x1158, 0xb8c0, 0x904d, 0x0140, 0x3e00, 0x9086, 0x0002,
-	0x1118, 0xb800, 0xd0bc, 0x1108, 0x0041, 0x001e, 0x8108, 0x1f04,
-	0x63fe, 0x001e, 0x00be, 0x009e, 0x0005, 0x0096, 0x0016, 0xb8c0,
-	0x904d, 0x0188, 0xa800, 0xb8c2, 0x9005, 0x1108, 0xb8be, 0x9006,
-	0xa802, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0xbb45,
-	0x080c, 0x6991, 0x0c60, 0x001e, 0x009e, 0x0005, 0x0086, 0x9046,
-	0xb8c0, 0x904d, 0x01b0, 0xa86c, 0x9406, 0x1118, 0xa870, 0x9506,
-	0x0128, 0x2940, 0xa800, 0x904d, 0x0160, 0x0ca8, 0xa800, 0x88ff,
-	0x1128, 0xb8c2, 0x9005, 0x1118, 0xb8be, 0x0008, 0xa002, 0xa803,
-	0x0000, 0x008e, 0x0005, 0x901e, 0x0010, 0x2019, 0x0001, 0x0126,
-	0x2091, 0x8000, 0x00e6, 0x0096, 0x00c6, 0x0086, 0x0026, 0x2071,
-	0x19b7, 0x9046, 0x7028, 0x9065, 0x01e8, 0x6014, 0x2068, 0x83ff,
-	0x0120, 0x605c, 0x9606, 0x0158, 0x0030, 0xa86c, 0x9406, 0x1118,
-	0xa870, 0x9506, 0x0120, 0x2c40, 0x600c, 0x2060, 0x0c60, 0x600c,
-	0x0006, 0x0066, 0x2830, 0x080c, 0x90f3, 0x006e, 0x000e, 0x83ff,
-	0x0508, 0x0c08, 0x9046, 0xb8c0, 0x904d, 0x01e0, 0x83ff, 0x0120,
-	0xa878, 0x9606, 0x0158, 0x0030, 0xa86c, 0x9406, 0x1118, 0xa870,
-	0x9506, 0x0120, 0x2940, 0xa800, 0x2048, 0x0c70, 0xb8c0, 0xaa00,
-	0x0026, 0x9906, 0x1110, 0xbac2, 0x0008, 0xa202, 0x000e, 0x83ff,
-	0x0108, 0x0c10, 0x002e, 0x008e, 0x00ce, 0x009e, 0x00ee, 0x012e,
-	0x0005, 0x9016, 0x0489, 0x1110, 0x2011, 0x0001, 0x0005, 0x080c,
-	0x655e, 0x0128, 0x080c, 0xb903, 0x0010, 0x9085, 0x0001, 0x0005,
-	0x080c, 0x655e, 0x0128, 0x080c, 0xb8a4, 0x0010, 0x9085, 0x0001,
-	0x0005, 0x080c, 0x655e, 0x0128, 0x080c, 0xb900, 0x0010, 0x9085,
-	0x0001, 0x0005, 0x080c, 0x655e, 0x0128, 0x080c, 0xb8c3, 0x0010,
-	0x9085, 0x0001, 0x0005, 0x080c, 0x655e, 0x0128, 0x080c, 0xb944,
-	0x0010, 0x9085, 0x0001, 0x0005, 0xb8a4, 0x900d, 0x1118, 0x9085,
-	0x0001, 0x0005, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e,
-	0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080,
-	0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606,
-	0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0008, 0x9006, 0x01ce,
-	0x013e, 0x0005, 0x0146, 0x01d6, 0xa860, 0x20e8, 0xa85c, 0x9080,
-	0x0004, 0x20a0, 0x20a9, 0x0010, 0x2009, 0xffff, 0x4104, 0x01de,
-	0x014e, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e, 0x810e,
-	0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080, 0x0004,
-	0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606, 0x0128,
-	0x8109, 0x1dd8, 0x9085, 0x0001, 0x0068, 0x0146, 0x01d6, 0x3300,
-	0x8001, 0x20a0, 0x3c00, 0x20e8, 0x2001, 0xffff, 0x4004, 0x01de,
-	0x014e, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0096, 0x0126, 0x2091,
-	0x8000, 0xb8a4, 0x904d, 0x1128, 0x080c, 0x1022, 0x0168, 0x2900,
-	0xb8a6, 0x080c, 0x64fa, 0xa803, 0x0001, 0xa807, 0x0000, 0x9085,
-	0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0096, 0x0126,
-	0x2091, 0x8000, 0xb8a4, 0x904d, 0x0130, 0xb8a7, 0x0000, 0x080c,
-	0x1054, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0xb89c, 0xd0a4,
-	0x0005, 0x00b6, 0x00f6, 0x080c, 0x7096, 0x01b0, 0x71c0, 0x81ff,
-	0x1198, 0x71d8, 0xd19c, 0x0180, 0x2001, 0x007e, 0x9080, 0x1000,
-	0x2004, 0x905d, 0x0148, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
-	0x1118, 0xb800, 0xc0ed, 0xb802, 0x2079, 0x1853, 0x7804, 0x00d0,
-	0x0156, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x626b, 0x1168,
-	0xb804, 0x9084, 0xff00, 0x8007, 0x9096, 0x0004, 0x0118, 0x9086,
-	0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x001e, 0x8108, 0x1f04,
-	0x6584, 0x015e, 0x080c, 0x6624, 0x0120, 0x2001, 0x1955, 0x200c,
-	0x0030, 0x2079, 0x1853, 0x7804, 0x0030, 0x2009, 0x07d0, 0x2011,
-	0x65ae, 0x080c, 0x81fc, 0x00fe, 0x00be, 0x0005, 0x00b6, 0x2011,
-	0x65ae, 0x080c, 0x8138, 0x080c, 0x6624, 0x01d8, 0x2001, 0x107e,
-	0x2004, 0x2058, 0xb900, 0xc1ec, 0xb902, 0x080c, 0x6662, 0x0130,
-	0x2009, 0x07d0, 0x2011, 0x65ae, 0x080c, 0x81fc, 0x00e6, 0x2071,
-	0x1800, 0x9006, 0x707a, 0x705c, 0x707e, 0x080c, 0x2de9, 0x00ee,
-	0x04d0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c,
-	0x626b, 0x1558, 0xb800, 0xd0ec, 0x0540, 0x0046, 0xbaa0, 0x2220,
-	0x9006, 0x2009, 0x0029, 0x080c, 0xd284, 0xb800, 0xc0e5, 0xc0ec,
-	0xb802, 0x080c, 0x665e, 0x2001, 0x0707, 0x1128, 0xb804, 0x9084,
-	0x00ff, 0x9085, 0x0700, 0xb806, 0x080c, 0x98bb, 0x2019, 0x0029,
-	0x080c, 0x8624, 0x0076, 0x903e, 0x080c, 0x8509, 0x900e, 0x080c,
-	0xcfd9, 0x007e, 0x004e, 0x080c, 0x98d7, 0x001e, 0x8108, 0x1f04,
-	0x65d6, 0x00ce, 0x015e, 0x00be, 0x0005, 0x00b6, 0x6010, 0x2058,
-	0xb800, 0xc0ec, 0xb802, 0x00be, 0x0005, 0x7810, 0x00b6, 0x2058,
-	0xb800, 0x00be, 0xd0ac, 0x0005, 0x6010, 0x00b6, 0x905d, 0x0108,
-	0xb800, 0x00be, 0xd0bc, 0x0005, 0x00b6, 0x00f6, 0x2001, 0x107e,
-	0x2004, 0x905d, 0x0110, 0xb800, 0xd0ec, 0x00fe, 0x00be, 0x0005,
-	0x0126, 0x0026, 0x2091, 0x8000, 0x0006, 0xbaa0, 0x9290, 0x1000,
-	0x2204, 0x9b06, 0x190c, 0x0d65, 0x000e, 0xba00, 0x9005, 0x0110,
-	0xc2fd, 0x0008, 0xc2fc, 0xba02, 0x002e, 0x012e, 0x0005, 0x2011,
-	0x1836, 0x2204, 0xd0cc, 0x0138, 0x2001, 0x1953, 0x200c, 0x2011,
-	0x6654, 0x080c, 0x81fc, 0x0005, 0x2011, 0x6654, 0x080c, 0x8138,
-	0x2011, 0x1836, 0x2204, 0xc0cc, 0x2012, 0x0005, 0x080c, 0x5388,
-	0xd0ac, 0x0005, 0x080c, 0x5388, 0xd0a4, 0x0005, 0x0016, 0xb904,
-	0x9184, 0x00ff, 0x908e, 0x0006, 0x001e, 0x0005, 0x0016, 0xb904,
-	0x9184, 0xff00, 0x8007, 0x908e, 0x0006, 0x001e, 0x0005, 0x00b6,
-	0x00f6, 0x080c, 0xbf61, 0x0158, 0x70d8, 0x9084, 0x0028, 0x0138,
-	0x2001, 0x107f, 0x2004, 0x905d, 0x0110, 0xb8c4, 0xd094, 0x00fe,
-	0x00be, 0x0005, 0x0006, 0x0016, 0x0036, 0x0046, 0x0076, 0x00b6,
-	0x2001, 0x1817, 0x203c, 0x9780, 0x317f, 0x203d, 0x97bc, 0xff00,
-	0x873f, 0x9006, 0x2018, 0x2008, 0x9284, 0x8000, 0x0110, 0x2019,
-	0x0001, 0x9294, 0x7fff, 0x2100, 0x9706, 0x0190, 0x91a0, 0x1000,
-	0x2404, 0x905d, 0x0168, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
-	0x1138, 0x83ff, 0x0118, 0xb89c, 0xd0a4, 0x0110, 0x8211, 0x0158,
-	0x8108, 0x83ff, 0x0120, 0x9182, 0x0800, 0x0e28, 0x0068, 0x9182,
-	0x007e, 0x0e08, 0x0048, 0x00be, 0x007e, 0x004e, 0x003e, 0x001e,
-	0x9085, 0x0001, 0x000e, 0x0005, 0x00be, 0x007e, 0x004e, 0x003e,
-	0x001e, 0x9006, 0x000e, 0x0005, 0x0046, 0x0056, 0x0076, 0x00b6,
-	0x2100, 0x9084, 0x7fff, 0x9080, 0x1000, 0x2004, 0x905d, 0x0130,
-	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x0550, 0x9184, 0x8000,
-	0x0580, 0x2001, 0x1817, 0x203c, 0x9780, 0x317f, 0x203d, 0x97bc,
-	0xff00, 0x873f, 0x9006, 0x2020, 0x2400, 0x9706, 0x01a0, 0x94a8,
-	0x1000, 0x2504, 0x905d, 0x0178, 0xb804, 0x9084, 0x00ff, 0x9086,
-	0x0006, 0x1148, 0xb89c, 0xd0a4, 0x0130, 0xb814, 0x9206, 0x1118,
-	0xb810, 0x9306, 0x0128, 0x8420, 0x9482, 0x0800, 0x0e28, 0x0048,
-	0x918c, 0x7fff, 0x00be, 0x007e, 0x005e, 0x004e, 0x9085, 0x0001,
-	0x0005, 0x918c, 0x7fff, 0x00be, 0x007e, 0x005e, 0x004e, 0x9006,
-	0x0005, 0x2071, 0x1906, 0x7003, 0x0001, 0x7007, 0x0000, 0x9006,
-	0x7012, 0x7016, 0x701a, 0x701e, 0x700a, 0x7046, 0x0005, 0x0016,
-	0x00e6, 0x2071, 0x1919, 0x900e, 0x710a, 0x080c, 0x5388, 0xd0fc,
-	0x1140, 0x080c, 0x5388, 0x900e, 0xd09c, 0x0108, 0x8108, 0x7102,
-	0x0400, 0x2001, 0x1873, 0x200c, 0x9184, 0x0007, 0x9006, 0x0002,
-	0x6739, 0x6739, 0x6739, 0x6739, 0x6739, 0x6750, 0x675e, 0x6739,
-	0x7003, 0x0003, 0x2009, 0x1874, 0x210c, 0x9184, 0xff00, 0x8007,
-	0x9005, 0x1110, 0x2001, 0x0002, 0x7006, 0x0018, 0x7003, 0x0005,
-	0x0c88, 0x00ee, 0x001e, 0x0005, 0x00e6, 0x2071, 0x0050, 0x684c,
-	0x9005, 0x1150, 0x00e6, 0x2071, 0x1906, 0x7028, 0xc085, 0x702a,
-	0x00ee, 0x9085, 0x0001, 0x0488, 0x6844, 0x9005, 0x0158, 0x080c,
-	0x7408, 0x6a60, 0x9200, 0x7002, 0x6864, 0x9101, 0x7006, 0x9006,
-	0x7012, 0x7016, 0x6860, 0x7002, 0x6864, 0x7006, 0x6868, 0x700a,
-	0x686c, 0x700e, 0x6844, 0x9005, 0x1110, 0x7012, 0x7016, 0x684c,
-	0x701a, 0x701c, 0x9085, 0x0040, 0x701e, 0x7037, 0x0019, 0x702b,
-	0x0001, 0x00e6, 0x2071, 0x1906, 0x7028, 0xc084, 0x702a, 0x7007,
-	0x0001, 0x700b, 0x0000, 0x00ee, 0x9006, 0x00ee, 0x0005, 0xa868,
-	0xd0fc, 0x11d8, 0x00e6, 0x0026, 0x2001, 0x1919, 0x2004, 0x9005,
-	0x0904, 0x6996, 0xa87c, 0xd0bc, 0x1904, 0x6996, 0xa978, 0xa874,
-	0x9105, 0x1904, 0x6996, 0x2001, 0x1919, 0x2004, 0x0002, 0x6996,
-	0x67ea, 0x6826, 0x6826, 0x6996, 0x6826, 0x0005, 0xa868, 0xd0fc,
-	0x1500, 0x00e6, 0x0026, 0x2009, 0x1919, 0x210c, 0x81ff, 0x0904,
-	0x6996, 0xa87c, 0xd0cc, 0x0904, 0x6996, 0xa880, 0x9084, 0x00ff,
-	0x9086, 0x0001, 0x1904, 0x6996, 0x9186, 0x0003, 0x0904, 0x6826,
-	0x9186, 0x0005, 0x0904, 0x6826, 0xa84f, 0x8021, 0xa853, 0x0017,
-	0x0028, 0x0005, 0xa84f, 0x8020, 0xa853, 0x0016, 0x2071, 0x1906,
-	0x701c, 0x9005, 0x1904, 0x6b2d, 0x0e04, 0x6b78, 0x2071, 0x0000,
-	0xa84c, 0x7082, 0xa850, 0x7032, 0xa86c, 0x7086, 0x7036, 0xa870,
-	0x708a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
-	0x11c9, 0x2071, 0x1800, 0x2011, 0x0001, 0xa804, 0x900d, 0x702c,
-	0x1158, 0xa802, 0x2900, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c,
-	0x8053, 0x002e, 0x00ee, 0x0005, 0x0096, 0x2148, 0xa904, 0xa802,
-	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x009e, 0x0c58, 0xa84f, 0x0000,
-	0x00f6, 0x2079, 0x0050, 0x2071, 0x1906, 0xa803, 0x0000, 0x7010,
-	0x9005, 0x1904, 0x691b, 0x782c, 0x908c, 0x0780, 0x190c, 0x6c9f,
-	0x8004, 0x8004, 0x8004, 0x9084, 0x0003, 0x0002, 0x6844, 0x691b,
-	0x6869, 0x68b6, 0x080c, 0x0d65, 0x2071, 0x1800, 0x2900, 0x7822,
-	0xa804, 0x900d, 0x1170, 0x2071, 0x19d3, 0x703c, 0x9005, 0x1328,
-	0x2001, 0x191a, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee,
-	0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
-	0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8053,
-	0x0c10, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x15a8,
-	0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1170, 0x2009,
-	0x182f, 0x210c, 0x918a, 0x0040, 0x0240, 0x7022, 0x2001, 0x1dc0,
-	0x200c, 0x8108, 0x2102, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c,
-	0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x8053,
-	0x782c, 0x9094, 0x0780, 0x190c, 0x6c9f, 0xd0a4, 0x19c8, 0x2071,
-	0x19d3, 0x703c, 0x9005, 0x1328, 0x2001, 0x191a, 0x2004, 0x8005,
+	0x0006, 0x9086, 0x0006, 0x1170, 0xb89c, 0xd0ac, 0x0158, 0x080c,
+	0x6686, 0x0140, 0x9284, 0xff00, 0x8007, 0x9086, 0x0007, 0x1110,
+	0x2011, 0x0600, 0x000e, 0x9294, 0xff00, 0x9215, 0xba06, 0x0006,
+	0x9086, 0x0006, 0x1120, 0xba90, 0x82ff, 0x090c, 0x0d65, 0x000e,
+	0x00ce, 0x012e, 0x00be, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x2091,
+	0x8000, 0x6210, 0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1168,
+	0xb89c, 0xd0a4, 0x0150, 0x080c, 0x6682, 0x1138, 0x9284, 0x00ff,
+	0x9086, 0x0007, 0x1110, 0x2011, 0x0006, 0x000e, 0x9294, 0x00ff,
+	0x8007, 0x9215, 0xba06, 0x00ce, 0x012e, 0x00be, 0x0005, 0x9182,
+	0x0800, 0x0218, 0x9085, 0x0001, 0x0005, 0x00d6, 0x0026, 0x9190,
+	0x1000, 0x2204, 0x905d, 0x1180, 0x0096, 0x080c, 0x102f, 0x2958,
+	0x009e, 0x0160, 0x2b00, 0x2012, 0xb85c, 0xb8ba, 0xb860, 0xb8b6,
+	0x9006, 0xb8a6, 0x080c, 0x5d11, 0x9006, 0x0010, 0x9085, 0x0001,
+	0x002e, 0x00de, 0x0005, 0x00b6, 0x0096, 0x0126, 0x2091, 0x8000,
+	0x0026, 0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0458, 0x00d6,
+	0x9190, 0x1000, 0x2204, 0x905d, 0x0518, 0x2013, 0x0000, 0xb8a4,
+	0x904d, 0x0110, 0x080c, 0x1061, 0x00d6, 0x00c6, 0xb8ac, 0x2060,
+	0x8cff, 0x0168, 0x600c, 0x0006, 0x6014, 0x2048, 0x080c, 0xb870,
+	0x0110, 0x080c, 0x0fe1, 0x080c, 0x9be6, 0x00ce, 0x0c88, 0x00ce,
+	0x00de, 0x2b48, 0xb8b8, 0xb85e, 0xb8b4, 0xb862, 0x080c, 0x1071,
+	0x00de, 0x9006, 0x002e, 0x012e, 0x009e, 0x00be, 0x0005, 0x0016,
+	0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0030, 0x9188, 0x1000,
+	0x2104, 0x905d, 0x0dc0, 0x9006, 0x001e, 0x0005, 0x00d6, 0x0156,
+	0x0136, 0x0146, 0x9006, 0xb80a, 0xb80e, 0xb800, 0xc08c, 0xb802,
+	0x080c, 0x70ba, 0x1510, 0xb8a0, 0x9086, 0x007e, 0x0120, 0x080c,
+	0x9b65, 0x11d8, 0x0078, 0x7040, 0xd0e4, 0x01b8, 0x00c6, 0x2061,
+	0x195a, 0x7048, 0x2062, 0x704c, 0x6006, 0x7050, 0x600a, 0x7054,
+	0x600e, 0x00ce, 0x703c, 0x2069, 0x0140, 0x9005, 0x1110, 0x2001,
+	0x0001, 0x6886, 0x2069, 0x1800, 0x68b2, 0x7040, 0xb85e, 0x7048,
+	0xb862, 0x704c, 0xb866, 0x20e1, 0x0000, 0x2099, 0x0276, 0xb8b4,
+	0x20e8, 0xb8b8, 0x9088, 0x000a, 0x21a0, 0x20a9, 0x0004, 0x4003,
+	0x2099, 0x027a, 0x9088, 0x0006, 0x21a0, 0x20a9, 0x0004, 0x4003,
+	0x2069, 0x0200, 0x6817, 0x0001, 0x7040, 0xb86a, 0x7144, 0xb96e,
+	0x7048, 0xb872, 0x7050, 0xb876, 0x2069, 0x0200, 0x6817, 0x0000,
+	0xb8a0, 0x9086, 0x007e, 0x1110, 0x7144, 0xb96e, 0x9182, 0x0211,
+	0x1218, 0x2009, 0x0008, 0x0400, 0x9182, 0x0259, 0x1218, 0x2009,
+	0x0007, 0x00d0, 0x9182, 0x02c1, 0x1218, 0x2009, 0x0006, 0x00a0,
+	0x9182, 0x0349, 0x1218, 0x2009, 0x0005, 0x0070, 0x9182, 0x0421,
+	0x1218, 0x2009, 0x0004, 0x0040, 0x9182, 0x0581, 0x1218, 0x2009,
+	0x0003, 0x0010, 0x2009, 0x0002, 0xb992, 0x014e, 0x013e, 0x015e,
+	0x00de, 0x0005, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260, 0x7034,
+	0xb896, 0x703c, 0xb89a, 0x7054, 0xb89e, 0x0036, 0xbbc4, 0xc384,
+	0xba00, 0x2009, 0x187b, 0x210c, 0xd0bc, 0x0120, 0xd1ec, 0x0110,
+	0xc2ad, 0x0008, 0xc2ac, 0xd0c4, 0x0148, 0xd1e4, 0x0138, 0xc2bd,
+	0xd0cc, 0x0128, 0xd38c, 0x1108, 0xc385, 0x0008, 0xc2bc, 0xba02,
+	0xbbc6, 0x003e, 0x00ee, 0x002e, 0x001e, 0x0005, 0x0096, 0x0126,
+	0x2091, 0x8000, 0xb8a4, 0x904d, 0x0578, 0xa900, 0x81ff, 0x15c0,
+	0xaa04, 0x9282, 0x0010, 0x16c8, 0x0136, 0x0146, 0x01c6, 0x01d6,
+	0x8906, 0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0,
+	0x9080, 0x0004, 0x2098, 0x2009, 0x0010, 0x20a9, 0x0001, 0x4002,
+	0x9086, 0xffff, 0x0120, 0x8109, 0x1dd0, 0x080c, 0x0d65, 0x3c00,
+	0x20e8, 0x3300, 0x8001, 0x20a0, 0x4604, 0x8210, 0xaa06, 0x01de,
+	0x01ce, 0x014e, 0x013e, 0x0060, 0x080c, 0x102f, 0x0170, 0x2900,
+	0xb8a6, 0xa803, 0x0000, 0x080c, 0x651e, 0xa807, 0x0001, 0xae12,
+	0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0126,
+	0x2091, 0x8000, 0x0096, 0xb8a4, 0x904d, 0x0188, 0xa800, 0x9005,
+	0x1150, 0x080c, 0x652d, 0x1158, 0xa804, 0x908a, 0x0002, 0x0218,
+	0x8001, 0xa806, 0x0020, 0x080c, 0x1061, 0xb8a7, 0x0000, 0x009e,
+	0x012e, 0x0005, 0x0096, 0x00c6, 0xb888, 0x9005, 0x1904, 0x6413,
+	0xb8c0, 0x904d, 0x0904, 0x6413, 0x080c, 0x9bbd, 0x0904, 0x640f,
+	0x8210, 0xba3e, 0xa800, 0xb8c2, 0x9005, 0x1108, 0xb8be, 0x2b00,
+	0x6012, 0x2900, 0x6016, 0x6023, 0x0003, 0x600b, 0xffff, 0x6007,
+	0x0040, 0xa878, 0x605e, 0xa880, 0x9084, 0x00ff, 0x6066, 0xa883,
+	0x0000, 0xa87c, 0xd0ac, 0x01c8, 0xc0dd, 0xa87e, 0xa888, 0x8001,
+	0x1568, 0xa816, 0xa864, 0x9094, 0x00f7, 0x9296, 0x0011, 0x1530,
+	0x9084, 0x00ff, 0xc0bd, 0x601e, 0xa8ac, 0xaab0, 0xa836, 0xaa3a,
+	0x2001, 0x8004, 0x6003, 0x0004, 0x0030, 0x080c, 0x1af7, 0x2001,
+	0x8004, 0x6003, 0x0002, 0x6046, 0x2001, 0x0010, 0x2c08, 0x080c,
+	0x98b8, 0xb838, 0xba3c, 0x9202, 0x0a04, 0x63c0, 0x0020, 0x82ff,
+	0x1110, 0xb88b, 0x0001, 0x00ce, 0x009e, 0x0005, 0x080c, 0x1669,
+	0x601c, 0xc0bd, 0x601e, 0x08e0, 0x00b6, 0x0096, 0x0016, 0x20a9,
+	0x0800, 0x900e, 0x0016, 0x080c, 0x628f, 0x1158, 0xb8c0, 0x904d,
+	0x0140, 0x3e00, 0x9086, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x1108,
+	0x0041, 0x001e, 0x8108, 0x1f04, 0x6422, 0x001e, 0x00be, 0x009e,
+	0x0005, 0x0096, 0x0016, 0xb8c0, 0x904d, 0x0188, 0xa800, 0xb8c2,
+	0x9005, 0x1108, 0xb8be, 0x9006, 0xa802, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x080c, 0xbb73, 0x080c, 0x69b5, 0x0c60, 0x001e,
+	0x009e, 0x0005, 0x0086, 0x9046, 0xb8c0, 0x904d, 0x01b0, 0xa86c,
+	0x9406, 0x1118, 0xa870, 0x9506, 0x0128, 0x2940, 0xa800, 0x904d,
+	0x0160, 0x0ca8, 0xa800, 0x88ff, 0x1128, 0xb8c2, 0x9005, 0x1118,
+	0xb8be, 0x0008, 0xa002, 0xa803, 0x0000, 0x008e, 0x0005, 0x901e,
+	0x0010, 0x2019, 0x0001, 0x0126, 0x2091, 0x8000, 0x00e6, 0x0096,
+	0x00c6, 0x0086, 0x0026, 0x2071, 0x19bf, 0x9046, 0x7028, 0x9065,
+	0x01e8, 0x6014, 0x2068, 0x83ff, 0x0120, 0x605c, 0x9606, 0x0158,
+	0x0030, 0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0120, 0x2c40,
+	0x600c, 0x2060, 0x0c60, 0x600c, 0x0006, 0x0066, 0x2830, 0x080c,
+	0x9127, 0x006e, 0x000e, 0x83ff, 0x0508, 0x0c08, 0x9046, 0xb8c0,
+	0x904d, 0x01e0, 0x83ff, 0x0120, 0xa878, 0x9606, 0x0158, 0x0030,
+	0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0120, 0x2940, 0xa800,
+	0x2048, 0x0c70, 0xb8c0, 0xaa00, 0x0026, 0x9906, 0x1110, 0xbac2,
+	0x0008, 0xa202, 0x000e, 0x83ff, 0x0108, 0x0c10, 0x002e, 0x008e,
+	0x00ce, 0x009e, 0x00ee, 0x012e, 0x0005, 0x9016, 0x0489, 0x1110,
+	0x2011, 0x0001, 0x0005, 0x080c, 0x6582, 0x0128, 0x080c, 0xb931,
+	0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6582, 0x0128, 0x080c,
+	0xb8d2, 0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6582, 0x0128,
+	0x080c, 0xb92e, 0x0010, 0x9085, 0x0001, 0x0005, 0x080c, 0x6582,
+	0x0128, 0x080c, 0xb8f1, 0x0010, 0x9085, 0x0001, 0x0005, 0x080c,
+	0x6582, 0x0128, 0x080c, 0xb972, 0x0010, 0x9085, 0x0001, 0x0005,
+	0xb8a4, 0x900d, 0x1118, 0x9085, 0x0001, 0x0005, 0x0136, 0x01c6,
+	0xa800, 0x9005, 0x11b8, 0x890e, 0x810e, 0x810f, 0x9184, 0x003f,
+	0x20e0, 0x9184, 0xffc0, 0x9080, 0x0004, 0x2098, 0x20a9, 0x0001,
+	0x2009, 0x0010, 0x4002, 0x9606, 0x0128, 0x8109, 0x1dd8, 0x9085,
+	0x0001, 0x0008, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0146, 0x01d6,
+	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0004, 0x20a0, 0x20a9, 0x0010,
+	0x2009, 0xffff, 0x4104, 0x01de, 0x014e, 0x0136, 0x01c6, 0xa800,
+	0x9005, 0x11b8, 0x890e, 0x810e, 0x810f, 0x9184, 0x003f, 0x20e0,
+	0x9184, 0xffc0, 0x9080, 0x0004, 0x2098, 0x20a9, 0x0001, 0x2009,
+	0x0010, 0x4002, 0x9606, 0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001,
+	0x0068, 0x0146, 0x01d6, 0x3300, 0x8001, 0x20a0, 0x3c00, 0x20e8,
+	0x2001, 0xffff, 0x4004, 0x01de, 0x014e, 0x9006, 0x01ce, 0x013e,
+	0x0005, 0x0096, 0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d, 0x1128,
+	0x080c, 0x102f, 0x0168, 0x2900, 0xb8a6, 0x080c, 0x651e, 0xa803,
+	0x0001, 0xa807, 0x0000, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005,
+	0x9006, 0x0cd8, 0x0096, 0x0126, 0x2091, 0x8000, 0xb8a4, 0x904d,
+	0x0130, 0xb8a7, 0x0000, 0x080c, 0x1061, 0x9085, 0x0001, 0x012e,
+	0x009e, 0x0005, 0xb89c, 0xd0a4, 0x0005, 0x00b6, 0x00f6, 0x080c,
+	0x70ba, 0x01b0, 0x71c0, 0x81ff, 0x1198, 0x71d8, 0xd19c, 0x0180,
+	0x2001, 0x007e, 0x9080, 0x1000, 0x2004, 0x905d, 0x0148, 0xb804,
+	0x9084, 0x00ff, 0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802,
+	0x2079, 0x185b, 0x7804, 0x00d0, 0x0156, 0x20a9, 0x007f, 0x900e,
+	0x0016, 0x080c, 0x628f, 0x1168, 0xb804, 0x9084, 0xff00, 0x8007,
+	0x9096, 0x0004, 0x0118, 0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed,
+	0xb802, 0x001e, 0x8108, 0x1f04, 0x65a8, 0x015e, 0x080c, 0x6648,
+	0x0120, 0x2001, 0x195d, 0x200c, 0x0030, 0x2079, 0x185b, 0x7804,
+	0x0030, 0x2009, 0x07d0, 0x2011, 0x65d2, 0x080c, 0x8230, 0x00fe,
+	0x00be, 0x0005, 0x00b6, 0x2011, 0x65d2, 0x080c, 0x816c, 0x080c,
+	0x6648, 0x01d8, 0x2001, 0x107e, 0x2004, 0x2058, 0xb900, 0xc1ec,
+	0xb902, 0x080c, 0x6686, 0x0130, 0x2009, 0x07d0, 0x2011, 0x65d2,
+	0x080c, 0x8230, 0x00e6, 0x2071, 0x1800, 0x9006, 0x707a, 0x705c,
+	0x707e, 0x080c, 0x2e09, 0x00ee, 0x04d0, 0x0156, 0x00c6, 0x20a9,
+	0x007f, 0x900e, 0x0016, 0x080c, 0x628f, 0x1558, 0xb800, 0xd0ec,
+	0x0540, 0x0046, 0xbaa0, 0x2220, 0x9006, 0x2009, 0x0029, 0x080c,
+	0xd2bc, 0xb800, 0xc0e5, 0xc0ec, 0xb802, 0x080c, 0x6682, 0x2001,
+	0x0707, 0x1128, 0xb804, 0x9084, 0x00ff, 0x9085, 0x0700, 0xb806,
+	0x080c, 0x98c7, 0x2019, 0x0029, 0x080c, 0x8658, 0x0076, 0x903e,
+	0x080c, 0x853d, 0x900e, 0x080c, 0xd011, 0x007e, 0x004e, 0x080c,
+	0x98e3, 0x001e, 0x8108, 0x1f04, 0x65fa, 0x00ce, 0x015e, 0x00be,
+	0x0005, 0x00b6, 0x6010, 0x2058, 0xb800, 0xc0ec, 0xb802, 0x00be,
+	0x0005, 0x7810, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ac, 0x0005,
+	0x6010, 0x00b6, 0x905d, 0x0108, 0xb800, 0x00be, 0xd0bc, 0x0005,
+	0x00b6, 0x00f6, 0x2001, 0x107e, 0x2004, 0x905d, 0x0110, 0xb800,
+	0xd0ec, 0x00fe, 0x00be, 0x0005, 0x0126, 0x0026, 0x2091, 0x8000,
+	0x0006, 0xbaa0, 0x9290, 0x1000, 0x2204, 0x9b06, 0x190c, 0x0d65,
+	0x000e, 0xba00, 0x9005, 0x0110, 0xc2fd, 0x0008, 0xc2fc, 0xba02,
+	0x002e, 0x012e, 0x0005, 0x2011, 0x1836, 0x2204, 0xd0cc, 0x0138,
+	0x2001, 0x195b, 0x200c, 0x2011, 0x6678, 0x080c, 0x8230, 0x0005,
+	0x2011, 0x6678, 0x080c, 0x816c, 0x2011, 0x1836, 0x2204, 0xc0cc,
+	0x2012, 0x0005, 0x080c, 0x53a8, 0xd0ac, 0x0005, 0x080c, 0x53a8,
+	0xd0a4, 0x0005, 0x0016, 0xb904, 0x9184, 0x00ff, 0x908e, 0x0006,
+	0x001e, 0x0005, 0x0016, 0xb904, 0x9184, 0xff00, 0x8007, 0x908e,
+	0x0006, 0x001e, 0x0005, 0x00b6, 0x00f6, 0x080c, 0xbf8f, 0x0158,
+	0x70d8, 0x9084, 0x0028, 0x0138, 0x2001, 0x107f, 0x2004, 0x905d,
+	0x0110, 0xb8c4, 0xd094, 0x00fe, 0x00be, 0x0005, 0x0006, 0x0016,
+	0x0036, 0x0046, 0x0076, 0x00b6, 0x2001, 0x1817, 0x203c, 0x9780,
+	0x319f, 0x203d, 0x97bc, 0xff00, 0x873f, 0x9006, 0x2018, 0x2008,
+	0x9284, 0x8000, 0x0110, 0x2019, 0x0001, 0x9294, 0x7fff, 0x2100,
+	0x9706, 0x0190, 0x91a0, 0x1000, 0x2404, 0x905d, 0x0168, 0xb804,
+	0x9084, 0x00ff, 0x9086, 0x0006, 0x1138, 0x83ff, 0x0118, 0xb89c,
+	0xd0a4, 0x0110, 0x8211, 0x0158, 0x8108, 0x83ff, 0x0120, 0x9182,
+	0x0800, 0x0e28, 0x0068, 0x9182, 0x007e, 0x0e08, 0x0048, 0x00be,
+	0x007e, 0x004e, 0x003e, 0x001e, 0x9085, 0x0001, 0x000e, 0x0005,
+	0x00be, 0x007e, 0x004e, 0x003e, 0x001e, 0x9006, 0x000e, 0x0005,
+	0x0046, 0x0056, 0x0076, 0x00b6, 0x2100, 0x9084, 0x7fff, 0x9080,
+	0x1000, 0x2004, 0x905d, 0x0130, 0xb804, 0x9084, 0x00ff, 0x9086,
+	0x0006, 0x0550, 0x9184, 0x8000, 0x0580, 0x2001, 0x1817, 0x203c,
+	0x9780, 0x319f, 0x203d, 0x97bc, 0xff00, 0x873f, 0x9006, 0x2020,
+	0x2400, 0x9706, 0x01a0, 0x94a8, 0x1000, 0x2504, 0x905d, 0x0178,
+	0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x1148, 0xb89c, 0xd0a4,
+	0x0130, 0xb814, 0x9206, 0x1118, 0xb810, 0x9306, 0x0128, 0x8420,
+	0x9482, 0x0800, 0x0e28, 0x0048, 0x918c, 0x7fff, 0x00be, 0x007e,
+	0x005e, 0x004e, 0x9085, 0x0001, 0x0005, 0x918c, 0x7fff, 0x00be,
+	0x007e, 0x005e, 0x004e, 0x9006, 0x0005, 0x2071, 0x190e, 0x7003,
+	0x0001, 0x7007, 0x0000, 0x9006, 0x7012, 0x7016, 0x701a, 0x701e,
+	0x700a, 0x7046, 0x0005, 0x0016, 0x00e6, 0x2071, 0x1921, 0x900e,
+	0x710a, 0x080c, 0x53a8, 0xd0fc, 0x1140, 0x080c, 0x53a8, 0x900e,
+	0xd09c, 0x0108, 0x8108, 0x7102, 0x0400, 0x2001, 0x187b, 0x200c,
+	0x9184, 0x0007, 0x9006, 0x0002, 0x675d, 0x675d, 0x675d, 0x675d,
+	0x675d, 0x6774, 0x6782, 0x675d, 0x7003, 0x0003, 0x2009, 0x187c,
+	0x210c, 0x9184, 0xff00, 0x8007, 0x9005, 0x1110, 0x2001, 0x0002,
+	0x7006, 0x0018, 0x7003, 0x0005, 0x0c88, 0x00ee, 0x001e, 0x0005,
+	0x00e6, 0x2071, 0x0050, 0x684c, 0x9005, 0x1150, 0x00e6, 0x2071,
+	0x190e, 0x7028, 0xc085, 0x702a, 0x00ee, 0x9085, 0x0001, 0x0488,
+	0x6844, 0x9005, 0x0158, 0x080c, 0x742b, 0x6a60, 0x9200, 0x7002,
+	0x6864, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6860, 0x7002,
+	0x6864, 0x7006, 0x6868, 0x700a, 0x686c, 0x700e, 0x6844, 0x9005,
+	0x1110, 0x7012, 0x7016, 0x684c, 0x701a, 0x701c, 0x9085, 0x0040,
+	0x701e, 0x7037, 0x0019, 0x702b, 0x0001, 0x00e6, 0x2071, 0x190e,
+	0x7028, 0xc084, 0x702a, 0x7007, 0x0001, 0x700b, 0x0000, 0x00ee,
+	0x9006, 0x00ee, 0x0005, 0xa868, 0xd0fc, 0x11d8, 0x00e6, 0x0026,
+	0x2001, 0x1921, 0x2004, 0x9005, 0x0904, 0x69ba, 0xa87c, 0xd0bc,
+	0x1904, 0x69ba, 0xa978, 0xa874, 0x9105, 0x1904, 0x69ba, 0x2001,
+	0x1921, 0x2004, 0x0002, 0x69ba, 0x680e, 0x684a, 0x684a, 0x69ba,
+	0x684a, 0x0005, 0xa868, 0xd0fc, 0x1500, 0x00e6, 0x0026, 0x2009,
+	0x1921, 0x210c, 0x81ff, 0x0904, 0x69ba, 0xa87c, 0xd0cc, 0x0904,
+	0x69ba, 0xa880, 0x9084, 0x00ff, 0x9086, 0x0001, 0x1904, 0x69ba,
+	0x9186, 0x0003, 0x0904, 0x684a, 0x9186, 0x0005, 0x0904, 0x684a,
+	0xa84f, 0x8021, 0xa853, 0x0017, 0x0028, 0x0005, 0xa84f, 0x8020,
+	0xa853, 0x0016, 0x2071, 0x190e, 0x701c, 0x9005, 0x1904, 0x6b51,
+	0x0e04, 0x6b9c, 0x2071, 0x0000, 0xa84c, 0x7082, 0xa850, 0x7032,
+	0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001,
+	0x0089, 0x2004, 0xd084, 0x190c, 0x11d6, 0x2071, 0x1800, 0x2011,
+	0x0001, 0xa804, 0x900d, 0x702c, 0x1158, 0xa802, 0x2900, 0x702e,
+	0x70bc, 0x9200, 0x70be, 0x080c, 0x8087, 0x002e, 0x00ee, 0x0005,
+	0x0096, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
+	0x009e, 0x0c58, 0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050, 0x2071,
+	0x190e, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x693f, 0x782c,
+	0x908c, 0x0780, 0x190c, 0x6cc3, 0x8004, 0x8004, 0x8004, 0x9084,
+	0x0003, 0x0002, 0x6868, 0x693f, 0x688d, 0x68da, 0x080c, 0x0d65,
+	0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1170, 0x2071,
+	0x19db, 0x703c, 0x9005, 0x1328, 0x2001, 0x1922, 0x2004, 0x8005,
 	0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148,
 	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc,
-	0x9200, 0x70be, 0x080c, 0x8053, 0x0804, 0x6870, 0x0096, 0x00e6,
-	0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e,
-	0x70bc, 0x8000, 0x70be, 0x080c, 0x8053, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6c9f, 0xd0a4, 0x1d60, 0x00ee, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6c9f, 0xd09c, 0x11a0, 0x009e, 0x2900, 0x7822, 0xa804,
-	0x900d, 0x1560, 0x2071, 0x19d3, 0x703c, 0x9005, 0x1328, 0x2001,
-	0x191a, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x009e, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
-	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1170,
-	0x2071, 0x19d3, 0x703c, 0x9005, 0x1328, 0x2001, 0x191a, 0x2004,
-	0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800,
-	0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff,
-	0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8053, 0x00fe,
-	0x002e, 0x00ee, 0x0005, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018,
-	0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804,
-	0x900d, 0x1904, 0x6970, 0x782c, 0x9094, 0x0780, 0x190c, 0x6c9f,
-	0xd09c, 0x1198, 0x701c, 0x904d, 0x0180, 0x7010, 0x8001, 0x7012,
-	0x1108, 0x701a, 0xa800, 0x701e, 0x2900, 0x7822, 0x782c, 0x9094,
-	0x0780, 0x190c, 0x6c9f, 0xd09c, 0x0d68, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6c9f, 0xd0a4, 0x01b0, 0x00e6, 0x7824, 0x2048, 0x2071,
-	0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be,
-	0x080c, 0x8053, 0x782c, 0x9094, 0x0780, 0x190c, 0x6c9f, 0xd0a4,
-	0x1d60, 0x00ee, 0x2071, 0x19d3, 0x703c, 0x9005, 0x1328, 0x2001,
-	0x191a, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x00e6, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
+	0x9200, 0x70be, 0x080c, 0x8087, 0x0c10, 0x2071, 0x1800, 0x2900,
+	0x7822, 0xa804, 0x900d, 0x15a8, 0x7824, 0x00e6, 0x2071, 0x0040,
+	0x712c, 0xd19c, 0x1170, 0x2009, 0x182f, 0x210c, 0x918a, 0x0040,
+	0x0240, 0x7022, 0x2001, 0x1dc0, 0x200c, 0x8108, 0x2102, 0x00ee,
+	0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc,
+	0x8000, 0x70be, 0x080c, 0x8087, 0x782c, 0x9094, 0x0780, 0x190c,
+	0x6cc3, 0xd0a4, 0x19c8, 0x2071, 0x19db, 0x703c, 0x9005, 0x1328,
+	0x2001, 0x1922, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e, 0x00ee,
+	0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8087,
+	0x0804, 0x6894, 0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c,
+	0x8087, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd0a4, 0x1d60,
+	0x00ee, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd09c, 0x11a0,
+	0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x1560, 0x2071, 0x19db,
+	0x703c, 0x9005, 0x1328, 0x2001, 0x1922, 0x2004, 0x8005, 0x703e,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x009e, 0x2908, 0x7010, 0x8000,
+	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
+	0x2148, 0xa804, 0x900d, 0x1170, 0x2071, 0x19db, 0x703c, 0x9005,
+	0x1328, 0x2001, 0x1922, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904,
+	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200,
+	0x70be, 0x080c, 0x8087, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904, 0x6994, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6cc3, 0xd09c, 0x1198, 0x701c, 0x904d,
+	0x0180, 0x7010, 0x8001, 0x7012, 0x1108, 0x701a, 0xa800, 0x701e,
+	0x2900, 0x7822, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd09c,
+	0x0d68, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd0a4, 0x01b0,
+	0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900,
+	0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x8087, 0x782c, 0x9094,
+	0x0780, 0x190c, 0x6cc3, 0xd0a4, 0x1d60, 0x00ee, 0x2071, 0x19db,
+	0x703c, 0x9005, 0x1328, 0x2001, 0x1922, 0x2004, 0x8005, 0x703e,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016,
+	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
+	0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8087, 0x00ee, 0x0804,
+	0x694f, 0xa868, 0xd0fc, 0x1560, 0x0096, 0xa804, 0xa807, 0x0000,
+	0x904d, 0x190c, 0x0fe1, 0x009e, 0x0018, 0xa868, 0xd0fc, 0x1500,
+	0x00e6, 0x0026, 0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050, 0x2071,
+	0x190e, 0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x6acf, 0x782c,
+	0x908c, 0x0780, 0x190c, 0x6cc3, 0x8004, 0x8004, 0x8004, 0x9084,
+	0x0003, 0x0002, 0x69d9, 0x6acf, 0x69f4, 0x6a62, 0x080c, 0x0d65,
+	0x0005, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1120,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904,
+	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200,
+	0x70be, 0x080c, 0x8087, 0x0c60, 0x2071, 0x1800, 0x2900, 0x7822,
+	0xa804, 0x900d, 0x1904, 0x6a51, 0x7830, 0xd0dc, 0x1120, 0x00fe,
+	0x002e, 0x00ee, 0x0005, 0x7824, 0x00e6, 0x2071, 0x0040, 0x712c,
+	0xd19c, 0x1170, 0x2009, 0x182f, 0x210c, 0x918a, 0x0040, 0x0240,
+	0x7022, 0x2001, 0x1dc0, 0x200c, 0x8108, 0x2102, 0x00ee, 0x0058,
+	0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000,
+	0x70be, 0x080c, 0x8087, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3,
+	0xd0a4, 0x19c8, 0x0e04, 0x6a48, 0x7838, 0x7938, 0x910e, 0x1de0,
+	0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2001,
+	0x191f, 0x200c, 0xc184, 0x2102, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x11d6, 0x00fe, 0x002e, 0x00ee, 0x0005,
+	0x2001, 0x191f, 0x200c, 0xc185, 0x2102, 0x00fe, 0x002e, 0x00ee,
+	0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8087,
+	0x0804, 0x6a03, 0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c,
+	0x8087, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd0a4, 0x1d60,
+	0x00ee, 0x0e04, 0x6aa2, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6,
+	0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084,
+	0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x11d6, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd09c, 0x1170,
+	0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x11e0, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x7044, 0xc085, 0x7046, 0x0c58, 0x009e, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1120, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904,
+	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200,
+	0x70be, 0x080c, 0x8087, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904, 0x6b3c, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x6cc3, 0xd09c, 0x11b0, 0x701c, 0x904d,
+	0x0198, 0xa84c, 0x9005, 0x1180, 0x7010, 0x8001, 0x7012, 0x1108,
+	0x701a, 0xa800, 0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780,
+	0x190c, 0x6cc3, 0xd09c, 0x0d50, 0x782c, 0x9094, 0x0780, 0x190c,
+	0x6cc3, 0xd0a4, 0x05a8, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c,
+	0x8087, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd0a4, 0x1d60,
+	0x00ee, 0x0e04, 0x6b35, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6,
+	0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084,
+	0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x11d6, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7044, 0xc085, 0x7046,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016,
+	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
+	0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8087, 0x00ee, 0x0804,
+	0x6adf, 0x2071, 0x190e, 0xa803, 0x0000, 0x2908, 0x7010, 0x8000,
+	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
+	0x2148, 0xa804, 0x900d, 0x1128, 0x1e04, 0x6b7c, 0x002e, 0x00ee,
+	0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
 	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be,
-	0x080c, 0x8053, 0x00ee, 0x0804, 0x692b, 0xa868, 0xd0fc, 0x1560,
-	0x0096, 0xa804, 0xa807, 0x0000, 0x904d, 0x190c, 0x0fd4, 0x009e,
-	0x0018, 0xa868, 0xd0fc, 0x1500, 0x00e6, 0x0026, 0xa84f, 0x0000,
-	0x00f6, 0x2079, 0x0050, 0x2071, 0x1906, 0xa803, 0x0000, 0x7010,
-	0x9005, 0x1904, 0x6aab, 0x782c, 0x908c, 0x0780, 0x190c, 0x6c9f,
-	0x8004, 0x8004, 0x8004, 0x9084, 0x0003, 0x0002, 0x69b5, 0x6aab,
-	0x69d0, 0x6a3e, 0x080c, 0x0d65, 0x0005, 0x2071, 0x1800, 0x2900,
-	0x7822, 0xa804, 0x900d, 0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff,
-	0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8053, 0x0c60,
-	0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1904, 0x6a2d,
-	0x7830, 0xd0dc, 0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7824,
-	0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c, 0x1170, 0x2009, 0x182f,
-	0x210c, 0x918a, 0x0040, 0x0240, 0x7022, 0x2001, 0x1dc0, 0x200c,
-	0x8108, 0x2102, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802,
-	0x2900, 0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x8053, 0x782c,
-	0x9094, 0x0780, 0x190c, 0x6c9f, 0xd0a4, 0x19c8, 0x0e04, 0x6a24,
-	0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836,
-	0x6833, 0x0013, 0x00de, 0x2001, 0x1917, 0x200c, 0xc184, 0x2102,
-	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11c9,
-	0x00fe, 0x002e, 0x00ee, 0x0005, 0x2001, 0x1917, 0x200c, 0xc185,
-	0x2102, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148,
-	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc,
-	0x9200, 0x70be, 0x080c, 0x8053, 0x0804, 0x69df, 0x0096, 0x00e6,
-	0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e,
-	0x70bc, 0x8000, 0x70be, 0x080c, 0x8053, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6c9f, 0xd0a4, 0x1d60, 0x00ee, 0x0e04, 0x6a7e, 0x7838,
+	0x080c, 0x8087, 0x0e04, 0x6b66, 0x2071, 0x190e, 0x701c, 0x2048,
+	0xa84c, 0x900d, 0x0d18, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032,
+	0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001,
+	0x0089, 0x2004, 0xd084, 0x190c, 0x11d6, 0x2071, 0x190e, 0x080c,
+	0x6caf, 0x002e, 0x00ee, 0x0005, 0x2071, 0x190e, 0xa803, 0x0000,
+	0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110,
+	0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1118, 0x002e,
+	0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904,
+	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200,
+	0x70be, 0x080c, 0x8087, 0x002e, 0x00ee, 0x0005, 0x0006, 0xa87c,
+	0x0006, 0xa867, 0x0103, 0x20a9, 0x001c, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x001d, 0x20a0, 0x9006, 0x4004, 0x000e, 0x9084, 0x00ff,
+	0xa87e, 0x000e, 0xa87a, 0xa982, 0x0005, 0x2071, 0x190e, 0x7004,
+	0x0002, 0x6be7, 0x6be8, 0x6cae, 0x6be8, 0x0d65, 0x6cae, 0x0005,
+	0x2001, 0x1921, 0x2004, 0x0002, 0x6bf2, 0x6bf2, 0x6c47, 0x6c48,
+	0x6bf2, 0x6c48, 0x0126, 0x2091, 0x8000, 0x1e0c, 0x6cce, 0x701c,
+	0x904d, 0x01e0, 0xa84c, 0x9005, 0x01d8, 0x0e04, 0x6c16, 0xa94c,
+	0x2071, 0x0000, 0x7182, 0xa850, 0x7032, 0xa86c, 0x7086, 0x7036,
+	0xa870, 0x708a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x11d6, 0x2071, 0x190e, 0x080c, 0x6caf, 0x012e, 0x0470,
+	0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd09c,
+	0x2071, 0x190e, 0x1510, 0x2071, 0x190e, 0x700f, 0x0001, 0xa964,
+	0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f, 0x918c, 0x00ff,
+	0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069, 0x0050, 0x6822,
+	0x00de, 0x2071, 0x190e, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012,
+	0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005,
+	0x00d6, 0x2008, 0x2069, 0x19db, 0x683c, 0x9005, 0x0760, 0x0158,
+	0x9186, 0x0003, 0x0540, 0x2001, 0x1814, 0x2004, 0x2009, 0x1b25,
+	0x210c, 0x9102, 0x1500, 0x0126, 0x2091, 0x8000, 0x2069, 0x0050,
+	0x693c, 0x6838, 0x9106, 0x0190, 0x0e04, 0x6c7a, 0x2069, 0x0000,
+	0x6837, 0x8040, 0x6833, 0x0012, 0x6883, 0x8040, 0x2091, 0x4080,
+	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11d6, 0x2069, 0x19db,
+	0x683f, 0xffff, 0x012e, 0x00de, 0x0126, 0x2091, 0x8000, 0x1e0c,
+	0x6d34, 0x701c, 0x904d, 0x0540, 0x2001, 0x005b, 0x2004, 0x9094,
+	0x0780, 0x15c9, 0xd09c, 0x1500, 0x2071, 0x190e, 0x700f, 0x0001,
+	0xa964, 0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f, 0x918c,
+	0x00ff, 0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069, 0x0050,
+	0x6822, 0x00de, 0x701c, 0x2048, 0x7010, 0x8001, 0x7012, 0xa800,
+	0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x701c, 0x904d, 0x0160, 0x7010, 0x8001, 0x7012,
+	0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x080c, 0x1061,
+	0x0005, 0x012e, 0x0005, 0x2091, 0x8000, 0x0e04, 0x6cc5, 0x0006,
+	0x0016, 0x2001, 0x8004, 0x0006, 0x0804, 0x0d6e, 0x0096, 0x00f6,
+	0x2079, 0x0050, 0x7044, 0xd084, 0x01c0, 0xc084, 0x7046, 0x7838,
 	0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833,
-	0x0013, 0x00de, 0x7044, 0xc084, 0x7046, 0x2091, 0x4080, 0x2001,
-	0x0089, 0x2004, 0xd084, 0x190c, 0x11c9, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6c9f, 0xd09c, 0x1170, 0x009e, 0x2900, 0x7822, 0xa804,
-	0x900d, 0x11e0, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7044, 0xc085,
-	0x7046, 0x0c58, 0x009e, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018,
-	0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804,
-	0x900d, 0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800,
-	0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff,
-	0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8053, 0x00fe,
-	0x002e, 0x00ee, 0x0005, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018,
-	0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804,
-	0x900d, 0x1904, 0x6b18, 0x782c, 0x9094, 0x0780, 0x190c, 0x6c9f,
-	0xd09c, 0x11b0, 0x701c, 0x904d, 0x0198, 0xa84c, 0x9005, 0x1180,
-	0x7010, 0x8001, 0x7012, 0x1108, 0x701a, 0xa800, 0x701e, 0x2900,
-	0x7822, 0x782c, 0x9094, 0x0780, 0x190c, 0x6c9f, 0xd09c, 0x0d50,
-	0x782c, 0x9094, 0x0780, 0x190c, 0x6c9f, 0xd0a4, 0x05a8, 0x00e6,
-	0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e,
-	0x70bc, 0x8000, 0x70be, 0x080c, 0x8053, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6c9f, 0xd0a4, 0x1d60, 0x00ee, 0x0e04, 0x6b11, 0x7838,
-	0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833,
-	0x0013, 0x00de, 0x7044, 0xc084, 0x7046, 0x2091, 0x4080, 0x2001,
-	0x0089, 0x2004, 0xd084, 0x190c, 0x11c9, 0x00fe, 0x002e, 0x00ee,
-	0x0005, 0x7044, 0xc085, 0x7046, 0x00fe, 0x002e, 0x00ee, 0x0005,
-	0x00e6, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
-	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be,
-	0x080c, 0x8053, 0x00ee, 0x0804, 0x6abb, 0x2071, 0x1906, 0xa803,
-	0x0000, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a,
-	0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1128,
-	0x1e04, 0x6b58, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016,
-	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
-	0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8053, 0x0e04, 0x6b42,
-	0x2071, 0x1906, 0x701c, 0x2048, 0xa84c, 0x900d, 0x0d18, 0x2071,
-	0x0000, 0x7182, 0xa850, 0x7032, 0xa86c, 0x7086, 0x7036, 0xa870,
-	0x708a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
-	0x11c9, 0x2071, 0x1906, 0x080c, 0x6c8b, 0x002e, 0x00ee, 0x0005,
-	0x2071, 0x1906, 0xa803, 0x0000, 0x2908, 0x7010, 0x8000, 0x7012,
-	0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148,
-	0xa804, 0x900d, 0x1118, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800,
-	0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff,
-	0x1dc8, 0x702e, 0x70bc, 0x9200, 0x70be, 0x080c, 0x8053, 0x002e,
-	0x00ee, 0x0005, 0x0006, 0xa87c, 0x0006, 0xa867, 0x0103, 0x20a9,
-	0x001c, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001d, 0x20a0, 0x9006,
-	0x4004, 0x000e, 0x9084, 0x00ff, 0xa87e, 0x000e, 0xa87a, 0xa982,
-	0x0005, 0x2071, 0x1906, 0x7004, 0x0002, 0x6bc3, 0x6bc4, 0x6c8a,
-	0x6bc4, 0x0d65, 0x6c8a, 0x0005, 0x2001, 0x1919, 0x2004, 0x0002,
-	0x6bce, 0x6bce, 0x6c23, 0x6c24, 0x6bce, 0x6c24, 0x0126, 0x2091,
-	0x8000, 0x1e0c, 0x6caa, 0x701c, 0x904d, 0x01e0, 0xa84c, 0x9005,
-	0x01d8, 0x0e04, 0x6bf2, 0xa94c, 0x2071, 0x0000, 0x7182, 0xa850,
-	0x7032, 0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11c9, 0x2071, 0x1906,
-	0x080c, 0x6c8b, 0x012e, 0x0470, 0x2001, 0x005b, 0x2004, 0x9094,
-	0x0780, 0x190c, 0x6c9f, 0xd09c, 0x2071, 0x1906, 0x1510, 0x2071,
-	0x1906, 0x700f, 0x0001, 0xa964, 0x9184, 0x00ff, 0x9086, 0x0003,
-	0x1130, 0x810f, 0x918c, 0x00ff, 0x8101, 0x0108, 0x710e, 0x2900,
-	0x00d6, 0x2069, 0x0050, 0x6822, 0x00de, 0x2071, 0x1906, 0x701c,
-	0x2048, 0x7010, 0x8001, 0x7012, 0xa800, 0x701e, 0x9005, 0x1108,
-	0x701a, 0x012e, 0x0005, 0x0005, 0x00d6, 0x2008, 0x2069, 0x19d3,
-	0x683c, 0x9005, 0x0760, 0x0158, 0x9186, 0x0003, 0x0540, 0x2001,
-	0x1814, 0x2004, 0x2009, 0x1b1d, 0x210c, 0x9102, 0x1500, 0x0126,
-	0x2091, 0x8000, 0x2069, 0x0050, 0x693c, 0x6838, 0x9106, 0x0190,
-	0x0e04, 0x6c56, 0x2069, 0x0000, 0x6837, 0x8040, 0x6833, 0x0012,
-	0x6883, 0x8040, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
-	0x190c, 0x11c9, 0x2069, 0x19d3, 0x683f, 0xffff, 0x012e, 0x00de,
-	0x0126, 0x2091, 0x8000, 0x1e0c, 0x6d10, 0x701c, 0x904d, 0x0540,
-	0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x15c9, 0xd09c, 0x1500,
-	0x2071, 0x1906, 0x700f, 0x0001, 0xa964, 0x9184, 0x00ff, 0x9086,
-	0x0003, 0x1130, 0x810f, 0x918c, 0x00ff, 0x8101, 0x0108, 0x710e,
-	0x2900, 0x00d6, 0x2069, 0x0050, 0x6822, 0x00de, 0x701c, 0x2048,
-	0x7010, 0x8001, 0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a,
-	0x012e, 0x0005, 0x0005, 0x0126, 0x2091, 0x8000, 0x701c, 0x904d,
-	0x0160, 0x7010, 0x8001, 0x7012, 0xa800, 0x701e, 0x9005, 0x1108,
-	0x701a, 0x012e, 0x080c, 0x1054, 0x0005, 0x012e, 0x0005, 0x2091,
-	0x8000, 0x0e04, 0x6ca1, 0x0006, 0x0016, 0x2001, 0x8004, 0x0006,
-	0x0804, 0x0d6e, 0x0096, 0x00f6, 0x2079, 0x0050, 0x7044, 0xd084,
-	0x01c0, 0xc084, 0x7046, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6,
-	0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2091, 0x4080,
-	0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11c9, 0x00fe, 0x009e,
-	0x0005, 0x782c, 0x9094, 0x0780, 0x1991, 0xd0a4, 0x0db8, 0x00e6,
-	0x2071, 0x1800, 0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c,
-	0x1170, 0x2009, 0x182f, 0x210c, 0x918a, 0x0040, 0x0240, 0x7022,
-	0x2001, 0x1dc0, 0x200c, 0x8108, 0x2102, 0x00ee, 0x0058, 0x00ee,
-	0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be,
-	0x080c, 0x8053, 0x782c, 0x9094, 0x0780, 0x190c, 0x6c9f, 0xd0a4,
-	0x19c8, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
-	0x6836, 0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089,
-	0x2004, 0xd084, 0x190c, 0x11c9, 0x00ee, 0x00fe, 0x009e, 0x0005,
-	0x00f6, 0x2079, 0x0050, 0x7044, 0xd084, 0x01b8, 0xc084, 0x7046,
-	0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836,
-	0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
-	0xd084, 0x190c, 0x11c9, 0x00fe, 0x0005, 0x782c, 0x9094, 0x0780,
-	0x190c, 0x6c9f, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824,
-	0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70bc, 0x8000, 0x70be,
-	0x080c, 0x8053, 0x782c, 0x9094, 0x0780, 0x190c, 0x6c9f, 0xd0a4,
-	0x1d70, 0x00d6, 0x2069, 0x0050, 0x693c, 0x2069, 0x1919, 0x6808,
-	0x690a, 0x2069, 0x19d3, 0x9102, 0x1118, 0x683c, 0x9005, 0x1328,
-	0x2001, 0x191a, 0x200c, 0x810d, 0x693e, 0x00de, 0x00ee, 0x00fe,
-	0x0005, 0x7094, 0x908a, 0x0029, 0x1a0c, 0x0d65, 0x9082, 0x001d,
-	0x003b, 0x0026, 0x2011, 0x1e00, 0x080c, 0x288c, 0x002e, 0x0005,
-	0x6e3c, 0x6dc2, 0x6dde, 0x6e08, 0x6e2b, 0x6e6b, 0x6e7d, 0x6dde,
-	0x6e53, 0x6d7d, 0x6dab, 0x6d7c, 0x0005, 0x00d6, 0x2069, 0x0200,
-	0x6804, 0x9005, 0x1180, 0x6808, 0x9005, 0x1518, 0x7097, 0x0028,
-	0x2069, 0x195f, 0x2d04, 0x7002, 0x080c, 0x71d7, 0x6028, 0x9085,
-	0x0600, 0x602a, 0x00b0, 0x7097, 0x0028, 0x2069, 0x195f, 0x2d04,
-	0x7002, 0x6028, 0x9085, 0x0600, 0x602a, 0x00e6, 0x0036, 0x0046,
-	0x0056, 0x2071, 0x1a3b, 0x080c, 0x196c, 0x005e, 0x004e, 0x003e,
-	0x00ee, 0x00de, 0x0005, 0x00d6, 0x2069, 0x0200, 0x6804, 0x9005,
-	0x1178, 0x6808, 0x9005, 0x1160, 0x7097, 0x0028, 0x2069, 0x195f,
-	0x2d04, 0x7002, 0x080c, 0x7279, 0x6028, 0x9085, 0x0600, 0x602a,
-	0x00de, 0x0005, 0x0006, 0x2001, 0x0090, 0x080c, 0x2852, 0x000e,
-	0x6124, 0xd1e4, 0x1190, 0x080c, 0x6eee, 0xd1d4, 0x1160, 0xd1dc,
-	0x1138, 0xd1cc, 0x0150, 0x7097, 0x0020, 0x080c, 0x6eee, 0x0028,
-	0x7097, 0x001d, 0x0010, 0x7097, 0x001f, 0x0005, 0x2001, 0x0088,
-	0x080c, 0x2852, 0x6124, 0xd1cc, 0x11e8, 0xd1dc, 0x11c0, 0xd1e4,
-	0x1198, 0x9184, 0x1e00, 0x11d8, 0x080c, 0x1996, 0x60e3, 0x0001,
-	0x600c, 0xc0b4, 0x600e, 0x080c, 0x70c2, 0x2001, 0x0080, 0x080c,
-	0x2852, 0x7097, 0x0028, 0x0058, 0x7097, 0x001e, 0x0040, 0x7097,
-	0x001d, 0x0028, 0x7097, 0x0020, 0x0010, 0x7097, 0x001f, 0x0005,
-	0x080c, 0x1996, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c,
-	0x70c2, 0x2001, 0x0080, 0x080c, 0x2852, 0x6124, 0xd1d4, 0x1180,
-	0xd1dc, 0x1158, 0xd1e4, 0x1130, 0x9184, 0x1e00, 0x1158, 0x7097,
-	0x0028, 0x0040, 0x7097, 0x001e, 0x0028, 0x7097, 0x001d, 0x0010,
-	0x7097, 0x001f, 0x0005, 0x2001, 0x00a0, 0x080c, 0x2852, 0x6124,
-	0xd1dc, 0x1138, 0xd1e4, 0x0138, 0x080c, 0x1996, 0x7097, 0x001e,
-	0x0010, 0x7097, 0x001d, 0x0005, 0x080c, 0x6f77, 0x6124, 0xd1dc,
-	0x1188, 0x080c, 0x6eee, 0x0016, 0x080c, 0x1996, 0x001e, 0xd1d4,
-	0x1128, 0xd1e4, 0x0138, 0x7097, 0x001e, 0x0020, 0x7097, 0x001f,
-	0x080c, 0x6eee, 0x0005, 0x0006, 0x2001, 0x00a0, 0x080c, 0x2852,
-	0x000e, 0x6124, 0xd1d4, 0x1160, 0xd1cc, 0x1150, 0xd1dc, 0x1128,
-	0xd1e4, 0x0140, 0x7097, 0x001e, 0x0028, 0x7097, 0x001d, 0x0010,
-	0x7097, 0x0021, 0x0005, 0x080c, 0x6f77, 0x6124, 0xd1d4, 0x1150,
-	0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x7097, 0x001e, 0x0028, 0x7097,
-	0x001d, 0x0010, 0x7097, 0x001f, 0x0005, 0x0006, 0x2001, 0x0090,
-	0x080c, 0x2852, 0x000e, 0x6124, 0xd1d4, 0x1178, 0xd1cc, 0x1150,
-	0xd1dc, 0x1128, 0xd1e4, 0x0158, 0x7097, 0x001e, 0x0040, 0x7097,
-	0x001d, 0x0028, 0x7097, 0x0020, 0x0010, 0x7097, 0x001f, 0x0005,
-	0x0016, 0x00c6, 0x00d6, 0x00e6, 0x0126, 0x2061, 0x0100, 0x2069,
-	0x0140, 0x2071, 0x1800, 0x2091, 0x8000, 0x080c, 0x7096, 0x11f8,
-	0x2001, 0x180c, 0x200c, 0xd1b4, 0x01d0, 0xc1b4, 0x2102, 0x0026,
-	0x2011, 0x0200, 0x080c, 0x288c, 0x002e, 0x080c, 0x2838, 0x6024,
-	0xd0cc, 0x0148, 0x2001, 0x00a0, 0x080c, 0x2852, 0x080c, 0x7396,
-	0x080c, 0x5cd7, 0x0428, 0x6028, 0xc0cd, 0x602a, 0x0408, 0x080c,
-	0x70b0, 0x0150, 0x080c, 0x70a7, 0x1138, 0x2001, 0x0001, 0x080c,
-	0x23e2, 0x080c, 0x706a, 0x00a0, 0x080c, 0x6f74, 0x0178, 0x2001,
-	0x0001, 0x080c, 0x23e2, 0x7094, 0x9086, 0x001e, 0x0120, 0x7094,
-	0x9086, 0x0022, 0x1118, 0x7097, 0x0025, 0x0010, 0x7097, 0x0021,
-	0x012e, 0x00ee, 0x00de, 0x00ce, 0x001e, 0x0005, 0x0026, 0x2011,
-	0x6eff, 0x080c, 0x823e, 0x002e, 0x0016, 0x0026, 0x2009, 0x0064,
-	0x2011, 0x6eff, 0x080c, 0x8235, 0x002e, 0x001e, 0x0005, 0x00e6,
-	0x00f6, 0x0016, 0x080c, 0x8f9c, 0x2071, 0x1800, 0x080c, 0x6e98,
-	0x001e, 0x00fe, 0x00ee, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6,
-	0x00d6, 0x00e6, 0x00f6, 0x0126, 0x080c, 0x8f9c, 0x2061, 0x0100,
-	0x2069, 0x0140, 0x2071, 0x1800, 0x2091, 0x8000, 0x6028, 0xc09c,
-	0x602a, 0x080c, 0x98bb, 0x2011, 0x0003, 0x080c, 0x931c, 0x2011,
-	0x0002, 0x080c, 0x9326, 0x080c, 0x91e9, 0x080c, 0x81ea, 0x0036,
-	0x901e, 0x080c, 0x9269, 0x003e, 0x080c, 0x98d7, 0x60e3, 0x0000,
-	0x080c, 0xd60c, 0x080c, 0xd627, 0x2009, 0x0004, 0x080c, 0x283e,
-	0x080c, 0x2758, 0x2001, 0x1800, 0x2003, 0x0004, 0x2011, 0x0008,
-	0x080c, 0x288c, 0x2011, 0x6eff, 0x080c, 0x823e, 0x080c, 0x70b0,
-	0x0118, 0x9006, 0x080c, 0x2852, 0x080c, 0x0bab, 0x2001, 0x0001,
-	0x080c, 0x23e2, 0x012e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x003e,
-	0x002e, 0x001e, 0x0005, 0x0026, 0x00e6, 0x2011, 0x6f0c, 0x2071,
-	0x19d3, 0x701c, 0x9206, 0x1118, 0x7018, 0x9005, 0x0110, 0x9085,
-	0x0001, 0x00ee, 0x002e, 0x0005, 0x6020, 0xd09c, 0x0005, 0x6800,
-	0x9084, 0xfffe, 0x9086, 0x00c0, 0x01b8, 0x2001, 0x00c0, 0x080c,
-	0x2852, 0x0156, 0x20a9, 0x002d, 0x1d04, 0x6f84, 0x2091, 0x6000,
-	0x1f04, 0x6f84, 0x015e, 0x00d6, 0x2069, 0x1800, 0x6898, 0x8001,
-	0x0220, 0x0118, 0x689a, 0x00de, 0x0005, 0x689b, 0x0014, 0x68e8,
-	0xd0dc, 0x0dc8, 0x6800, 0x9086, 0x0001, 0x1da8, 0x080c, 0x824a,
-	0x0c90, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140,
-	0x2071, 0x1800, 0x080c, 0x73a5, 0x2001, 0x193d, 0x2003, 0x0000,
-	0x9006, 0x7096, 0x60e2, 0x6886, 0x080c, 0x24b1, 0x9006, 0x080c,
-	0x2852, 0x080c, 0x5b92, 0x0026, 0x2011, 0xffff, 0x080c, 0x288c,
-	0x002e, 0x602b, 0x182c, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6,
-	0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800,
-	0x2001, 0x194d, 0x200c, 0x9186, 0x0000, 0x0158, 0x9186, 0x0001,
-	0x0158, 0x9186, 0x0002, 0x0158, 0x9186, 0x0003, 0x0158, 0x0804,
-	0x705a, 0x7097, 0x0022, 0x0040, 0x7097, 0x0021, 0x0028, 0x7097,
-	0x0023, 0x0010, 0x7097, 0x0024, 0x60e3, 0x0000, 0x6887, 0x0001,
-	0x2001, 0x0001, 0x080c, 0x24b1, 0x080c, 0x98bb, 0x0026, 0x080c,
-	0x9b60, 0x002e, 0x080c, 0x98d7, 0x7000, 0x908e, 0x0004, 0x0118,
-	0x602b, 0x0028, 0x0010, 0x602b, 0x0020, 0x0156, 0x0126, 0x2091,
-	0x8000, 0x20a9, 0x0005, 0x6024, 0xd0ac, 0x0150, 0x012e, 0x015e,
-	0x080c, 0xbf61, 0x0118, 0x9006, 0x080c, 0x287c, 0x0804, 0x7066,
-	0x6800, 0x9084, 0x00a1, 0xc0bd, 0x6802, 0x080c, 0x2838, 0x6904,
-	0xd1d4, 0x1140, 0x2001, 0x0100, 0x080c, 0x2852, 0x1f04, 0x700b,
-	0x080c, 0x70ed, 0x012e, 0x015e, 0x080c, 0x70a7, 0x0170, 0x6044,
-	0x9005, 0x0130, 0x080c, 0x70ed, 0x9006, 0x8001, 0x1df0, 0x0028,
-	0x6804, 0xd0d4, 0x1110, 0x080c, 0x70ed, 0x080c, 0xbf61, 0x0118,
-	0x9006, 0x080c, 0x287c, 0x0016, 0x0026, 0x7000, 0x908e, 0x0004,
-	0x0130, 0x2009, 0x00c8, 0x2011, 0x6f0c, 0x080c, 0x81fc, 0x002e,
-	0x001e, 0x080c, 0x804a, 0x7034, 0xc085, 0x7036, 0x2001, 0x194d,
-	0x2003, 0x0004, 0x080c, 0x6d61, 0x080c, 0x70a7, 0x0138, 0x6804,
-	0xd0d4, 0x1120, 0xd0dc, 0x1100, 0x080c, 0x739b, 0x00ee, 0x00de,
-	0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069,
-	0x0140, 0x2071, 0x1800, 0x080c, 0x8061, 0x080c, 0x8053, 0x080c,
-	0x73a5, 0x2001, 0x193d, 0x2003, 0x0000, 0x9006, 0x7096, 0x60e2,
-	0x6886, 0x080c, 0x24b1, 0x9006, 0x080c, 0x2852, 0x6043, 0x0090,
-	0x6043, 0x0010, 0x0026, 0x2011, 0xffff, 0x080c, 0x288c, 0x002e,
-	0x602b, 0x182c, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x0006, 0x2001,
-	0x194c, 0x2004, 0x9086, 0xaaaa, 0x000e, 0x0005, 0x0006, 0x080c,
-	0x538c, 0x9084, 0x0030, 0x9086, 0x0000, 0x000e, 0x0005, 0x0006,
-	0x080c, 0x538c, 0x9084, 0x0030, 0x9086, 0x0030, 0x000e, 0x0005,
-	0x0006, 0x080c, 0x538c, 0x9084, 0x0030, 0x9086, 0x0010, 0x000e,
-	0x0005, 0x0006, 0x080c, 0x538c, 0x9084, 0x0030, 0x9086, 0x0020,
-	0x000e, 0x0005, 0x0036, 0x0016, 0x2001, 0x180c, 0x2004, 0x908c,
-	0x0013, 0x0180, 0x0020, 0x080c, 0x24d1, 0x900e, 0x0028, 0x080c,
-	0x665e, 0x1dc8, 0x2009, 0x0002, 0x2019, 0x0028, 0x080c, 0x2fd3,
-	0x9006, 0x0019, 0x001e, 0x003e, 0x0005, 0x00e6, 0x2071, 0x180c,
-	0x2e04, 0x0130, 0x080c, 0xbf5a, 0x1128, 0x9085, 0x0010, 0x0010,
-	0x9084, 0xffef, 0x2072, 0x00ee, 0x0005, 0x6050, 0x0006, 0x60ec,
-	0x0006, 0x600c, 0x0006, 0x6004, 0x0006, 0x6028, 0x0006, 0x602f,
+	0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x11d6, 0x00fe, 0x009e, 0x0005, 0x782c, 0x9094, 0x0780,
+	0x1991, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800, 0x7824, 0x00e6,
+	0x2071, 0x0040, 0x712c, 0xd19c, 0x1170, 0x2009, 0x182f, 0x210c,
+	0x918a, 0x0040, 0x0240, 0x7022, 0x2001, 0x1dc0, 0x200c, 0x8108,
+	0x2102, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900,
+	0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x8087, 0x782c, 0x9094,
+	0x0780, 0x190c, 0x6cc3, 0xd0a4, 0x19c8, 0x7838, 0x7938, 0x910e,
+	0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de,
+	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11d6,
+	0x00ee, 0x00fe, 0x009e, 0x0005, 0x00f6, 0x2079, 0x0050, 0x7044,
+	0xd084, 0x01b8, 0xc084, 0x7046, 0x7838, 0x7938, 0x910e, 0x1de0,
+	0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x11d6, 0x00fe,
+	0x0005, 0x782c, 0x9094, 0x0780, 0x190c, 0x6cc3, 0xd0a4, 0x0db8,
+	0x00e6, 0x2071, 0x1800, 0x7824, 0x2048, 0x702c, 0xa802, 0x2900,
+	0x702e, 0x70bc, 0x8000, 0x70be, 0x080c, 0x8087, 0x782c, 0x9094,
+	0x0780, 0x190c, 0x6cc3, 0xd0a4, 0x1d70, 0x00d6, 0x2069, 0x0050,
+	0x693c, 0x2069, 0x1921, 0x6808, 0x690a, 0x2069, 0x19db, 0x9102,
+	0x1118, 0x683c, 0x9005, 0x1328, 0x2001, 0x1922, 0x200c, 0x810d,
+	0x693e, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x7094, 0x908a, 0x0029,
+	0x1a0c, 0x0d65, 0x9082, 0x001d, 0x003b, 0x0026, 0x2011, 0x1e00,
+	0x080c, 0x28ac, 0x002e, 0x0005, 0x6e60, 0x6de6, 0x6e02, 0x6e2c,
+	0x6e4f, 0x6e8f, 0x6ea1, 0x6e02, 0x6e77, 0x6da1, 0x6dcf, 0x6da0,
+	0x0005, 0x00d6, 0x2069, 0x0200, 0x6804, 0x9005, 0x1180, 0x6808,
+	0x9005, 0x1518, 0x7097, 0x0028, 0x2069, 0x1967, 0x2d04, 0x7002,
+	0x080c, 0x71fa, 0x6028, 0x9085, 0x0600, 0x602a, 0x00b0, 0x7097,
+	0x0028, 0x2069, 0x1967, 0x2d04, 0x7002, 0x6028, 0x9085, 0x0600,
+	0x602a, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a43, 0x080c,
+	0x1989, 0x005e, 0x004e, 0x003e, 0x00ee, 0x00de, 0x0005, 0x00d6,
+	0x2069, 0x0200, 0x6804, 0x9005, 0x1178, 0x6808, 0x9005, 0x1160,
+	0x7097, 0x0028, 0x2069, 0x1967, 0x2d04, 0x7002, 0x080c, 0x729c,
+	0x6028, 0x9085, 0x0600, 0x602a, 0x00de, 0x0005, 0x0006, 0x2001,
+	0x0090, 0x080c, 0x2872, 0x000e, 0x6124, 0xd1e4, 0x1190, 0x080c,
+	0x6f12, 0xd1d4, 0x1160, 0xd1dc, 0x1138, 0xd1cc, 0x0150, 0x7097,
+	0x0020, 0x080c, 0x6f12, 0x0028, 0x7097, 0x001d, 0x0010, 0x7097,
+	0x001f, 0x0005, 0x2001, 0x0088, 0x080c, 0x2872, 0x6124, 0xd1cc,
+	0x11e8, 0xd1dc, 0x11c0, 0xd1e4, 0x1198, 0x9184, 0x1e00, 0x11d8,
+	0x080c, 0x19ae, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c,
+	0x70e6, 0x2001, 0x0080, 0x080c, 0x2872, 0x7097, 0x0028, 0x0058,
+	0x7097, 0x001e, 0x0040, 0x7097, 0x001d, 0x0028, 0x7097, 0x0020,
+	0x0010, 0x7097, 0x001f, 0x0005, 0x080c, 0x19ae, 0x60e3, 0x0001,
+	0x600c, 0xc0b4, 0x600e, 0x080c, 0x70e6, 0x2001, 0x0080, 0x080c,
+	0x2872, 0x6124, 0xd1d4, 0x1180, 0xd1dc, 0x1158, 0xd1e4, 0x1130,
+	0x9184, 0x1e00, 0x1158, 0x7097, 0x0028, 0x0040, 0x7097, 0x001e,
+	0x0028, 0x7097, 0x001d, 0x0010, 0x7097, 0x001f, 0x0005, 0x2001,
+	0x00a0, 0x080c, 0x2872, 0x6124, 0xd1dc, 0x1138, 0xd1e4, 0x0138,
+	0x080c, 0x19ae, 0x7097, 0x001e, 0x0010, 0x7097, 0x001d, 0x0005,
+	0x080c, 0x6f9b, 0x6124, 0xd1dc, 0x1188, 0x080c, 0x6f12, 0x0016,
+	0x080c, 0x19ae, 0x001e, 0xd1d4, 0x1128, 0xd1e4, 0x0138, 0x7097,
+	0x001e, 0x0020, 0x7097, 0x001f, 0x080c, 0x6f12, 0x0005, 0x0006,
+	0x2001, 0x00a0, 0x080c, 0x2872, 0x000e, 0x6124, 0xd1d4, 0x1160,
+	0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x7097, 0x001e,
+	0x0028, 0x7097, 0x001d, 0x0010, 0x7097, 0x0021, 0x0005, 0x080c,
+	0x6f9b, 0x6124, 0xd1d4, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140,
+	0x7097, 0x001e, 0x0028, 0x7097, 0x001d, 0x0010, 0x7097, 0x001f,
+	0x0005, 0x0006, 0x2001, 0x0090, 0x080c, 0x2872, 0x000e, 0x6124,
+	0xd1d4, 0x1178, 0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0158,
+	0x7097, 0x001e, 0x0040, 0x7097, 0x001d, 0x0028, 0x7097, 0x0020,
+	0x0010, 0x7097, 0x001f, 0x0005, 0x0016, 0x00c6, 0x00d6, 0x00e6,
+	0x0126, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x2091,
+	0x8000, 0x080c, 0x70ba, 0x11f8, 0x2001, 0x180c, 0x200c, 0xd1b4,
+	0x01d0, 0xc1b4, 0x2102, 0x0026, 0x2011, 0x0200, 0x080c, 0x28ac,
+	0x002e, 0x080c, 0x2858, 0x6024, 0xd0cc, 0x0148, 0x2001, 0x00a0,
+	0x080c, 0x2872, 0x080c, 0x73b9, 0x080c, 0x5cf7, 0x0428, 0x6028,
+	0xc0cd, 0x602a, 0x0408, 0x080c, 0x70d4, 0x0150, 0x080c, 0x70cb,
+	0x1138, 0x2001, 0x0001, 0x080c, 0x23fe, 0x080c, 0x708e, 0x00a0,
+	0x080c, 0x6f98, 0x0178, 0x2001, 0x0001, 0x080c, 0x23fe, 0x7094,
+	0x9086, 0x001e, 0x0120, 0x7094, 0x9086, 0x0022, 0x1118, 0x7097,
+	0x0025, 0x0010, 0x7097, 0x0021, 0x012e, 0x00ee, 0x00de, 0x00ce,
+	0x001e, 0x0005, 0x0026, 0x2011, 0x6f23, 0x080c, 0x8272, 0x002e,
+	0x0016, 0x0026, 0x2009, 0x0064, 0x2011, 0x6f23, 0x080c, 0x8269,
+	0x002e, 0x001e, 0x0005, 0x00e6, 0x00f6, 0x0016, 0x080c, 0x8fd0,
+	0x2071, 0x1800, 0x080c, 0x6ebc, 0x001e, 0x00fe, 0x00ee, 0x0005,
+	0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0126,
+	0x080c, 0x8fd0, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800,
+	0x2091, 0x8000, 0x6028, 0xc09c, 0x602a, 0x080c, 0x98c7, 0x2011,
+	0x0003, 0x080c, 0x9324, 0x2011, 0x0002, 0x080c, 0x932e, 0x080c,
+	0x921d, 0x080c, 0x821e, 0x0036, 0x901e, 0x080c, 0x929d, 0x003e,
+	0x080c, 0x98e3, 0x60e3, 0x0000, 0x080c, 0xd644, 0x080c, 0xd65f,
+	0x2009, 0x0004, 0x080c, 0x285e, 0x080c, 0x2774, 0x2001, 0x1800,
+	0x2003, 0x0004, 0x2011, 0x0008, 0x080c, 0x28ac, 0x2011, 0x6f23,
+	0x080c, 0x8272, 0x080c, 0x70d4, 0x0118, 0x9006, 0x080c, 0x2872,
+	0x080c, 0x0bab, 0x2001, 0x0001, 0x080c, 0x23fe, 0x012e, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x0005, 0x0026,
+	0x00e6, 0x2011, 0x6f30, 0x2071, 0x19db, 0x701c, 0x9206, 0x1118,
+	0x7018, 0x9005, 0x0110, 0x9085, 0x0001, 0x00ee, 0x002e, 0x0005,
+	0x6020, 0xd09c, 0x0005, 0x6800, 0x9084, 0xfffe, 0x9086, 0x00c0,
+	0x01b8, 0x2001, 0x00c0, 0x080c, 0x2872, 0x0156, 0x20a9, 0x002d,
+	0x1d04, 0x6fa8, 0x2091, 0x6000, 0x1f04, 0x6fa8, 0x015e, 0x00d6,
+	0x2069, 0x1800, 0x6898, 0x8001, 0x0220, 0x0118, 0x689a, 0x00de,
+	0x0005, 0x689b, 0x0014, 0x68e8, 0xd0dc, 0x0dc8, 0x6800, 0x9086,
+	0x0001, 0x1da8, 0x080c, 0x827e, 0x0c90, 0x00c6, 0x00d6, 0x00e6,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x73c8,
+	0x2001, 0x1945, 0x2003, 0x0000, 0x9006, 0x7096, 0x60e2, 0x6886,
+	0x080c, 0x24cd, 0x9006, 0x080c, 0x2872, 0x080c, 0x5bb2, 0x0026,
+	0x2011, 0xffff, 0x080c, 0x28ac, 0x002e, 0x602b, 0x182c, 0x00ee,
+	0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
+	0x2069, 0x0140, 0x2071, 0x1800, 0x2001, 0x1955, 0x200c, 0x9186,
+	0x0000, 0x0158, 0x9186, 0x0001, 0x0158, 0x9186, 0x0002, 0x0158,
+	0x9186, 0x0003, 0x0158, 0x0804, 0x707e, 0x7097, 0x0022, 0x0040,
+	0x7097, 0x0021, 0x0028, 0x7097, 0x0023, 0x0010, 0x7097, 0x0024,
+	0x60e3, 0x0000, 0x6887, 0x0001, 0x2001, 0x0001, 0x080c, 0x24cd,
+	0x080c, 0x98c7, 0x0026, 0x080c, 0x9b6c, 0x002e, 0x080c, 0x98e3,
+	0x7000, 0x908e, 0x0004, 0x0118, 0x602b, 0x0028, 0x0010, 0x602b,
+	0x0020, 0x0156, 0x0126, 0x2091, 0x8000, 0x20a9, 0x0005, 0x6024,
+	0xd0ac, 0x0150, 0x012e, 0x015e, 0x080c, 0xbf8f, 0x0118, 0x9006,
+	0x080c, 0x289c, 0x0804, 0x708a, 0x6800, 0x9084, 0x00a1, 0xc0bd,
+	0x6802, 0x080c, 0x2858, 0x6904, 0xd1d4, 0x1140, 0x2001, 0x0100,
+	0x080c, 0x2872, 0x1f04, 0x702f, 0x080c, 0x7111, 0x012e, 0x015e,
+	0x080c, 0x70cb, 0x0170, 0x6044, 0x9005, 0x0130, 0x080c, 0x7111,
+	0x9006, 0x8001, 0x1df0, 0x0028, 0x6804, 0xd0d4, 0x1110, 0x080c,
+	0x7111, 0x080c, 0xbf8f, 0x0118, 0x9006, 0x080c, 0x289c, 0x0016,
+	0x0026, 0x7000, 0x908e, 0x0004, 0x0130, 0x2009, 0x00c8, 0x2011,
+	0x6f30, 0x080c, 0x8230, 0x002e, 0x001e, 0x080c, 0x807e, 0x7034,
+	0xc085, 0x7036, 0x2001, 0x1955, 0x2003, 0x0004, 0x080c, 0x6d85,
+	0x080c, 0x70cb, 0x0138, 0x6804, 0xd0d4, 0x1120, 0xd0dc, 0x1100,
+	0x080c, 0x73be, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6,
+	0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x080c,
+	0x8095, 0x080c, 0x8087, 0x080c, 0x73c8, 0x2001, 0x1945, 0x2003,
+	0x0000, 0x9006, 0x7096, 0x60e2, 0x6886, 0x080c, 0x24cd, 0x9006,
+	0x080c, 0x2872, 0x6043, 0x0090, 0x6043, 0x0010, 0x0026, 0x2011,
+	0xffff, 0x080c, 0x28ac, 0x002e, 0x602b, 0x182c, 0x00ee, 0x00de,
+	0x00ce, 0x0005, 0x0006, 0x2001, 0x1954, 0x2004, 0x9086, 0xaaaa,
+	0x000e, 0x0005, 0x0006, 0x080c, 0x53ac, 0x9084, 0x0030, 0x9086,
+	0x0000, 0x000e, 0x0005, 0x0006, 0x080c, 0x53ac, 0x9084, 0x0030,
+	0x9086, 0x0030, 0x000e, 0x0005, 0x0006, 0x080c, 0x53ac, 0x9084,
+	0x0030, 0x9086, 0x0010, 0x000e, 0x0005, 0x0006, 0x080c, 0x53ac,
+	0x9084, 0x0030, 0x9086, 0x0020, 0x000e, 0x0005, 0x0036, 0x0016,
+	0x2001, 0x180c, 0x2004, 0x908c, 0x0013, 0x0180, 0x0020, 0x080c,
+	0x24ed, 0x900e, 0x0028, 0x080c, 0x6682, 0x1dc8, 0x2009, 0x0002,
+	0x2019, 0x0028, 0x080c, 0x2ff3, 0x9006, 0x0019, 0x001e, 0x003e,
+	0x0005, 0x00e6, 0x2071, 0x180c, 0x2e04, 0x0130, 0x080c, 0xbf88,
+	0x1128, 0x9085, 0x0010, 0x0010, 0x9084, 0xffef, 0x2072, 0x00ee,
+	0x0005, 0x6050, 0x0006, 0x60ec, 0x0006, 0x600c, 0x0006, 0x6004,
+	0x0006, 0x6028, 0x0006, 0x080c, 0x28cf, 0x080c, 0x2902, 0x602f,
 	0x0100, 0x602f, 0x0000, 0x602f, 0x0040, 0x602f, 0x0000, 0x20a9,
-	0x0002, 0x080c, 0x2819, 0x0026, 0x2011, 0x0040, 0x080c, 0x288c,
+	0x0002, 0x080c, 0x2839, 0x0026, 0x2011, 0x0040, 0x080c, 0x28ac,
 	0x002e, 0x000e, 0x602a, 0x000e, 0x6006, 0x000e, 0x600e, 0x000e,
 	0x60ee, 0x60e3, 0x0000, 0x6887, 0x0001, 0x2001, 0x0001, 0x080c,
-	0x24b1, 0x2001, 0x00a0, 0x0006, 0x080c, 0xbf61, 0x000e, 0x0130,
-	0x080c, 0x2870, 0x9006, 0x080c, 0x287c, 0x0010, 0x080c, 0x2852,
+	0x24cd, 0x2001, 0x00a0, 0x0006, 0x080c, 0xbf8f, 0x000e, 0x0130,
+	0x080c, 0x2890, 0x9006, 0x080c, 0x289c, 0x0010, 0x080c, 0x2872,
 	0x000e, 0x6052, 0x6050, 0x0006, 0xc0e5, 0x6052, 0x00f6, 0x2079,
-	0x0100, 0x080c, 0x27c9, 0x00fe, 0x000e, 0x6052, 0x0005, 0x0156,
-	0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
-	0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x9919, 0x0158, 0x2001,
-	0x0386, 0x2004, 0xd0b4, 0x1130, 0x2001, 0x0016, 0x080c, 0x98ac,
-	0x0804, 0x71c9, 0x2001, 0x180c, 0x200c, 0xc1c4, 0x2102, 0x6028,
-	0x9084, 0xe1ff, 0x602a, 0x2011, 0x0200, 0x080c, 0x288c, 0x2001,
-	0x0090, 0x080c, 0x2852, 0x20a9, 0x0366, 0x6024, 0xd0cc, 0x1558,
-	0x1d04, 0x7165, 0x2091, 0x6000, 0x1f04, 0x7165, 0x080c, 0x98bb,
-	0x2011, 0x0003, 0x080c, 0x931c, 0x2011, 0x0002, 0x080c, 0x9326,
-	0x080c, 0x91e9, 0x901e, 0x080c, 0x9269, 0x2001, 0x0386, 0x2003,
-	0x7000, 0x080c, 0x98d7, 0x2001, 0x00a0, 0x080c, 0x2852, 0x080c,
-	0x7396, 0x080c, 0x5cd7, 0x080c, 0xbf61, 0x0110, 0x080c, 0x0cd1,
-	0x9085, 0x0001, 0x04e0, 0x2001, 0x0386, 0x2004, 0xd0ac, 0x0110,
-	0x080c, 0x1996, 0x60e3, 0x0000, 0x2001, 0x0002, 0x080c, 0x24b1,
-	0x60e2, 0x2001, 0x0080, 0x080c, 0x2852, 0x20a9, 0x0366, 0x2011,
-	0x1e00, 0x080c, 0x288c, 0x2009, 0x1e00, 0x080c, 0x2838, 0x6024,
-	0x910c, 0x0140, 0x1d04, 0x71a7, 0x2091, 0x6000, 0x1f04, 0x71a7,
-	0x0804, 0x716e, 0x2001, 0x0386, 0x2003, 0x7000, 0x6028, 0x9085,
-	0x1e00, 0x602a, 0x70b0, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008,
-	0x6886, 0x080c, 0xbf61, 0x0110, 0x080c, 0x0cd1, 0x9006, 0x00ee,
-	0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156,
+	0x0100, 0x080c, 0x27e5, 0x00fe, 0x000e, 0x6052, 0x0005, 0x0156,
 	0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
-	0x2071, 0x1800, 0x7000, 0x9086, 0x0003, 0x1168, 0x2001, 0x020b,
-	0x2004, 0x9084, 0x5540, 0x9086, 0x5540, 0x1128, 0x2069, 0x1a46,
-	0x2d04, 0x8000, 0x206a, 0x2069, 0x0140, 0x6020, 0x9084, 0x00c0,
-	0x0120, 0x6884, 0x9005, 0x1904, 0x7240, 0x2001, 0x0088, 0x080c,
-	0x2852, 0x9006, 0x60e2, 0x6886, 0x080c, 0x24b1, 0x2069, 0x0200,
-	0x6804, 0x9005, 0x1118, 0x6808, 0x9005, 0x01d0, 0x6028, 0x9084,
-	0xfbff, 0x602a, 0x2011, 0x0400, 0x080c, 0x288c, 0x2069, 0x195f,
-	0x7000, 0x206a, 0x7097, 0x0026, 0x7003, 0x0001, 0x20a9, 0x0002,
-	0x1d04, 0x7220, 0x2091, 0x6000, 0x1f04, 0x7220, 0x0804, 0x7271,
-	0x2069, 0x0140, 0x20a9, 0x0384, 0x2011, 0x1e00, 0x080c, 0x288c,
-	0x2009, 0x1e00, 0x080c, 0x2838, 0x6024, 0x910c, 0x0528, 0x9084,
-	0x1a00, 0x1510, 0x1d04, 0x722c, 0x2091, 0x6000, 0x1f04, 0x722c,
-	0x080c, 0x98bb, 0x2011, 0x0003, 0x080c, 0x931c, 0x2011, 0x0002,
-	0x080c, 0x9326, 0x080c, 0x91e9, 0x901e, 0x080c, 0x9269, 0x080c,
-	0x98d7, 0x2001, 0x00a0, 0x080c, 0x2852, 0x080c, 0x7396, 0x080c,
-	0x5cd7, 0x9085, 0x0001, 0x00a8, 0x2001, 0x0080, 0x080c, 0x2852,
-	0x2069, 0x0140, 0x60e3, 0x0000, 0x70b0, 0x9005, 0x1118, 0x6887,
-	0x0001, 0x0008, 0x6886, 0x2001, 0x0002, 0x080c, 0x24b1, 0x60e2,
-	0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e,
-	0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6,
-	0x2061, 0x0100, 0x2071, 0x1800, 0x6020, 0x9084, 0x00c0, 0x01e8,
-	0x080c, 0x98bb, 0x2011, 0x0003, 0x080c, 0x931c, 0x2011, 0x0002,
-	0x080c, 0x9326, 0x080c, 0x91e9, 0x901e, 0x080c, 0x9269, 0x080c,
-	0x98d7, 0x2069, 0x0140, 0x2001, 0x00a0, 0x080c, 0x2852, 0x080c,
-	0x7396, 0x080c, 0x5cd7, 0x0804, 0x7313, 0x2001, 0x180c, 0x200c,
-	0xd1b4, 0x1160, 0xc1b5, 0x2102, 0x080c, 0x6ef4, 0x2069, 0x0140,
-	0x2001, 0x0080, 0x080c, 0x2852, 0x60e3, 0x0000, 0x2069, 0x0200,
-	0x6804, 0x9005, 0x1118, 0x6808, 0x9005, 0x0190, 0x6028, 0x9084,
-	0xfdff, 0x602a, 0x2011, 0x0200, 0x080c, 0x288c, 0x2069, 0x195f,
-	0x7000, 0x206a, 0x7097, 0x0027, 0x7003, 0x0001, 0x0804, 0x7313,
-	0x2011, 0x1e00, 0x080c, 0x288c, 0x2009, 0x1e00, 0x080c, 0x2838,
-	0x6024, 0x910c, 0x01c8, 0x9084, 0x1c00, 0x11b0, 0x1d04, 0x72d0,
-	0x0006, 0x0016, 0x00c6, 0x00d6, 0x00e6, 0x080c, 0x8092, 0x00ee,
-	0x00de, 0x00ce, 0x001e, 0x000e, 0x00e6, 0x2071, 0x19d3, 0x7018,
-	0x00ee, 0x9005, 0x19e8, 0x01f8, 0x0026, 0x2011, 0x6f0c, 0x080c,
-	0x8138, 0x2011, 0x6eff, 0x080c, 0x823e, 0x002e, 0x2069, 0x0140,
-	0x60e3, 0x0000, 0x70b0, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008,
-	0x6886, 0x2001, 0x0002, 0x080c, 0x24b1, 0x60e2, 0x2001, 0x180c,
-	0x200c, 0xc1b4, 0x2102, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e,
-	0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x0046,
-	0x00c6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x080c, 0xbf5a,
-	0x1904, 0x7380, 0x7130, 0xd184, 0x1170, 0x080c, 0x317a, 0x0138,
-	0xc18d, 0x7132, 0x2011, 0x1854, 0x2214, 0xd2ac, 0x1120, 0x7030,
-	0xd08c, 0x0904, 0x7380, 0x2011, 0x1854, 0x220c, 0x0438, 0x0016,
-	0x2019, 0x000e, 0x080c, 0xd1fc, 0x0156, 0x00b6, 0x20a9, 0x007f,
-	0x900e, 0x9186, 0x007e, 0x01a0, 0x9186, 0x0080, 0x0188, 0x080c,
-	0x626b, 0x1170, 0x2120, 0x9006, 0x0016, 0x2009, 0x000e, 0x080c,
-	0xd284, 0x2009, 0x0001, 0x2011, 0x0100, 0x080c, 0x83cd, 0x001e,
-	0x8108, 0x1f04, 0x7349, 0x00be, 0x015e, 0x001e, 0xd1ac, 0x1148,
-	0x0016, 0x2009, 0x0002, 0x2019, 0x0004, 0x080c, 0x2fd3, 0x001e,
-	0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x626b,
-	0x1110, 0x080c, 0x5cf1, 0x8108, 0x1f04, 0x7376, 0x00be, 0x015e,
-	0x080c, 0x1996, 0x080c, 0x98bb, 0x080c, 0x9b60, 0x080c, 0x98d7,
-	0x60e3, 0x0000, 0x080c, 0x5cd7, 0x080c, 0x6fc7, 0x00ee, 0x00ce,
-	0x004e, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x2001, 0x194d,
-	0x2003, 0x0001, 0x0005, 0x2001, 0x194d, 0x2003, 0x0000, 0x0005,
-	0x2001, 0x194c, 0x2003, 0xaaaa, 0x0005, 0x2001, 0x194c, 0x2003,
-	0x0000, 0x0005, 0x2071, 0x18f0, 0x7003, 0x0000, 0x7007, 0x0000,
-	0x080c, 0x103b, 0x090c, 0x0d65, 0xa8ab, 0xdcb0, 0x2900, 0x704e,
-	0x080c, 0x103b, 0x090c, 0x0d65, 0xa8ab, 0xdcb0, 0x2900, 0x7052,
-	0xa867, 0x0000, 0xa86b, 0x0001, 0xa89f, 0x0000, 0x0005, 0x00e6,
-	0x2071, 0x0040, 0x6848, 0x9005, 0x1118, 0x9085, 0x0001, 0x04b0,
-	0x6840, 0x9005, 0x0150, 0x04a1, 0x6a50, 0x9200, 0x7002, 0x6854,
-	0x9101, 0x7006, 0x9006, 0x7012, 0x7016, 0x6850, 0x7002, 0x6854,
-	0x7006, 0x6858, 0x700a, 0x685c, 0x700e, 0x6840, 0x9005, 0x1110,
-	0x7012, 0x7016, 0x6848, 0x701a, 0x701c, 0x9085, 0x0040, 0x701e,
-	0x2001, 0x0019, 0x7036, 0x702b, 0x0001, 0x2001, 0x0004, 0x200c,
-	0x918c, 0xfff7, 0x918d, 0x8000, 0x2102, 0x00d6, 0x2069, 0x18f0,
-	0x6807, 0x0001, 0x00de, 0x080c, 0x79a2, 0x9006, 0x00ee, 0x0005,
-	0x900e, 0x0156, 0x20a9, 0x0006, 0x8003, 0x818d, 0x1f04, 0x740c,
-	0x015e, 0x0005, 0x2079, 0x0040, 0x2071, 0x18f0, 0x7004, 0x0002,
-	0x7422, 0x7423, 0x746e, 0x74c9, 0x760a, 0x7420, 0x7420, 0x7634,
-	0x080c, 0x0d65, 0x0005, 0x2079, 0x0040, 0x2001, 0x1dc0, 0x2003,
-	0x0000, 0x782c, 0x908c, 0x0780, 0x190c, 0x7a2e, 0xd0a4, 0x0570,
-	0x2001, 0x1dc0, 0x2004, 0x9082, 0x0080, 0x1640, 0x1d04, 0x7440,
-	0x2001, 0x19d6, 0x200c, 0x8109, 0x0508, 0x2091, 0x6000, 0x2102,
+	0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x9925, 0x0158, 0x2001,
+	0x0386, 0x2004, 0xd0b4, 0x1130, 0x2001, 0x0016, 0x080c, 0x98b8,
+	0x0804, 0x71ec, 0x2001, 0x180c, 0x200c, 0xc1c4, 0x2102, 0x6028,
+	0x9084, 0xe1ff, 0x602a, 0x2011, 0x0200, 0x080c, 0x28ac, 0x2001,
+	0x0090, 0x080c, 0x2872, 0x20a9, 0x0366, 0x6024, 0xd0cc, 0x1558,
+	0x1d04, 0x718d, 0x2091, 0x6000, 0x1f04, 0x718d, 0x080c, 0x98c7,
+	0x2011, 0x0003, 0x080c, 0x9324, 0x2011, 0x0002, 0x080c, 0x932e,
+	0x080c, 0x921d, 0x901e, 0x080c, 0x929d, 0x2001, 0x0386, 0x2003,
+	0x7000, 0x080c, 0x98e3, 0x2001, 0x00a0, 0x080c, 0x2872, 0x080c,
+	0x73b9, 0x080c, 0x5cf7, 0x080c, 0xbf8f, 0x0110, 0x080c, 0x0cd1,
+	0x9085, 0x0001, 0x04b8, 0x080c, 0x19ae, 0x60e3, 0x0000, 0x2001,
+	0x0002, 0x080c, 0x24cd, 0x60e2, 0x2001, 0x0080, 0x080c, 0x2872,
+	0x20a9, 0x0366, 0x2011, 0x1e00, 0x080c, 0x28ac, 0x2009, 0x1e00,
+	0x080c, 0x2858, 0x6024, 0x910c, 0x0140, 0x1d04, 0x71ca, 0x2091,
+	0x6000, 0x1f04, 0x71ca, 0x0804, 0x7196, 0x2001, 0x0386, 0x2003,
+	0x7000, 0x6028, 0x9085, 0x1e00, 0x602a, 0x70b0, 0x9005, 0x1118,
+	0x6887, 0x0001, 0x0008, 0x6886, 0x080c, 0xbf8f, 0x0110, 0x080c,
+	0x0cd1, 0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e,
+	0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6,
+	0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x7000, 0x9086, 0x0003,
+	0x1168, 0x2001, 0x020b, 0x2004, 0x9084, 0x5540, 0x9086, 0x5540,
+	0x1128, 0x2069, 0x1a4e, 0x2d04, 0x8000, 0x206a, 0x2069, 0x0140,
+	0x6020, 0x9084, 0x00c0, 0x0120, 0x6884, 0x9005, 0x1904, 0x7263,
+	0x2001, 0x0088, 0x080c, 0x2872, 0x9006, 0x60e2, 0x6886, 0x080c,
+	0x24cd, 0x2069, 0x0200, 0x6804, 0x9005, 0x1118, 0x6808, 0x9005,
+	0x01d0, 0x6028, 0x9084, 0xfbff, 0x602a, 0x2011, 0x0400, 0x080c,
+	0x28ac, 0x2069, 0x1967, 0x7000, 0x206a, 0x7097, 0x0026, 0x7003,
+	0x0001, 0x20a9, 0x0002, 0x1d04, 0x7243, 0x2091, 0x6000, 0x1f04,
+	0x7243, 0x0804, 0x7294, 0x2069, 0x0140, 0x20a9, 0x0384, 0x2011,
+	0x1e00, 0x080c, 0x28ac, 0x2009, 0x1e00, 0x080c, 0x2858, 0x6024,
+	0x910c, 0x0528, 0x9084, 0x1a00, 0x1510, 0x1d04, 0x724f, 0x2091,
+	0x6000, 0x1f04, 0x724f, 0x080c, 0x98c7, 0x2011, 0x0003, 0x080c,
+	0x9324, 0x2011, 0x0002, 0x080c, 0x932e, 0x080c, 0x921d, 0x901e,
+	0x080c, 0x929d, 0x080c, 0x98e3, 0x2001, 0x00a0, 0x080c, 0x2872,
+	0x080c, 0x73b9, 0x080c, 0x5cf7, 0x9085, 0x0001, 0x00a8, 0x2001,
+	0x0080, 0x080c, 0x2872, 0x2069, 0x0140, 0x60e3, 0x0000, 0x70b0,
+	0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001, 0x0002,
+	0x080c, 0x24cd, 0x60e2, 0x9006, 0x00ee, 0x00de, 0x00ce, 0x003e,
+	0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036,
+	0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x6020,
+	0x9084, 0x00c0, 0x01e8, 0x080c, 0x98c7, 0x2011, 0x0003, 0x080c,
+	0x9324, 0x2011, 0x0002, 0x080c, 0x932e, 0x080c, 0x921d, 0x901e,
+	0x080c, 0x929d, 0x080c, 0x98e3, 0x2069, 0x0140, 0x2001, 0x00a0,
+	0x080c, 0x2872, 0x080c, 0x73b9, 0x080c, 0x5cf7, 0x0804, 0x7336,
+	0x2001, 0x180c, 0x200c, 0xd1b4, 0x1160, 0xc1b5, 0x2102, 0x080c,
+	0x6f18, 0x2069, 0x0140, 0x2001, 0x0080, 0x080c, 0x2872, 0x60e3,
+	0x0000, 0x2069, 0x0200, 0x6804, 0x9005, 0x1118, 0x6808, 0x9005,
+	0x0190, 0x6028, 0x9084, 0xfdff, 0x602a, 0x2011, 0x0200, 0x080c,
+	0x28ac, 0x2069, 0x1967, 0x7000, 0x206a, 0x7097, 0x0027, 0x7003,
+	0x0001, 0x0804, 0x7336, 0x2011, 0x1e00, 0x080c, 0x28ac, 0x2009,
+	0x1e00, 0x080c, 0x2858, 0x6024, 0x910c, 0x01c8, 0x9084, 0x1c00,
+	0x11b0, 0x1d04, 0x72f3, 0x0006, 0x0016, 0x00c6, 0x00d6, 0x00e6,
+	0x080c, 0x80c6, 0x00ee, 0x00de, 0x00ce, 0x001e, 0x000e, 0x00e6,
+	0x2071, 0x19db, 0x7070, 0x00ee, 0x9005, 0x19e8, 0x00f8, 0x0026,
+	0x2011, 0x6f30, 0x080c, 0x816c, 0x2011, 0x6f23, 0x080c, 0x8272,
+	0x002e, 0x2069, 0x0140, 0x60e3, 0x0000, 0x70b0, 0x9005, 0x1118,
+	0x6887, 0x0001, 0x0008, 0x6886, 0x2001, 0x0002, 0x080c, 0x24cd,
+	0x60e2, 0x2001, 0x180c, 0x200c, 0xc1b4, 0x2102, 0x00ee, 0x00de,
+	0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016,
+	0x0026, 0x0036, 0x0046, 0x00c6, 0x00e6, 0x2061, 0x0100, 0x2071,
+	0x1800, 0x080c, 0xbf88, 0x1904, 0x73a3, 0x7130, 0xd184, 0x1170,
+	0x080c, 0x319a, 0x0138, 0xc18d, 0x7132, 0x2011, 0x185c, 0x2214,
+	0xd2ac, 0x1120, 0x7030, 0xd08c, 0x0904, 0x73a3, 0x2011, 0x185c,
+	0x220c, 0x0438, 0x0016, 0x2019, 0x000e, 0x080c, 0xd234, 0x0156,
+	0x00b6, 0x20a9, 0x007f, 0x900e, 0x9186, 0x007e, 0x01a0, 0x9186,
+	0x0080, 0x0188, 0x080c, 0x628f, 0x1170, 0x2120, 0x9006, 0x0016,
+	0x2009, 0x000e, 0x080c, 0xd2bc, 0x2009, 0x0001, 0x2011, 0x0100,
+	0x080c, 0x8401, 0x001e, 0x8108, 0x1f04, 0x736c, 0x00be, 0x015e,
+	0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009, 0x0002, 0x2019, 0x0004,
+	0x080c, 0x2ff3, 0x001e, 0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f,
+	0x900e, 0x080c, 0x628f, 0x1110, 0x080c, 0x5d11, 0x8108, 0x1f04,
+	0x7399, 0x00be, 0x015e, 0x080c, 0x19ae, 0x080c, 0x98c7, 0x080c,
+	0x9b6c, 0x080c, 0x98e3, 0x60e3, 0x0000, 0x080c, 0x5cf7, 0x080c,
+	0x6feb, 0x00ee, 0x00ce, 0x004e, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x0005, 0x2001, 0x1955, 0x2003, 0x0001, 0x0005, 0x2001, 0x1955,
+	0x2003, 0x0000, 0x0005, 0x2001, 0x1954, 0x2003, 0xaaaa, 0x0005,
+	0x2001, 0x1954, 0x2003, 0x0000, 0x0005, 0x2071, 0x18f8, 0x7003,
+	0x0000, 0x7007, 0x0000, 0x080c, 0x1048, 0x090c, 0x0d65, 0xa8ab,
+	0xdcb0, 0x2900, 0x704e, 0x080c, 0x1048, 0x090c, 0x0d65, 0xa8ab,
+	0xdcb0, 0x2900, 0x7052, 0xa867, 0x0000, 0xa86b, 0x0001, 0xa89f,
+	0x0000, 0x0005, 0x00e6, 0x2071, 0x0040, 0x6848, 0x9005, 0x1118,
+	0x9085, 0x0001, 0x04b0, 0x6840, 0x9005, 0x0150, 0x04a1, 0x6a50,
+	0x9200, 0x7002, 0x6854, 0x9101, 0x7006, 0x9006, 0x7012, 0x7016,
+	0x6850, 0x7002, 0x6854, 0x7006, 0x6858, 0x700a, 0x685c, 0x700e,
+	0x6840, 0x9005, 0x1110, 0x7012, 0x7016, 0x6848, 0x701a, 0x701c,
+	0x9085, 0x0040, 0x701e, 0x2001, 0x0019, 0x7036, 0x702b, 0x0001,
+	0x2001, 0x0004, 0x200c, 0x918c, 0xfff7, 0x918d, 0x8000, 0x2102,
+	0x00d6, 0x2069, 0x18f8, 0x6807, 0x0001, 0x00de, 0x080c, 0x79c6,
+	0x9006, 0x00ee, 0x0005, 0x900e, 0x0156, 0x20a9, 0x0006, 0x8003,
+	0x818d, 0x1f04, 0x742f, 0x015e, 0x0005, 0x2079, 0x0040, 0x2071,
+	0x18f8, 0x7004, 0x0002, 0x7445, 0x7446, 0x7492, 0x74ed, 0x762e,
+	0x7443, 0x7443, 0x7658, 0x080c, 0x0d65, 0x0005, 0x2079, 0x0040,
+	0x2001, 0x1dc0, 0x2003, 0x0000, 0x782c, 0x908c, 0x0780, 0x190c,
+	0x7a52, 0xd0a4, 0x0578, 0x2001, 0x1dc0, 0x2004, 0x9082, 0x0080,
+	0x1648, 0x1d04, 0x7463, 0x2001, 0x19de, 0x200c, 0x8109, 0x0510,
+	0x2091, 0x6000, 0x2102, 0x7824, 0x2048, 0x9006, 0xa802, 0xa806,
+	0xa864, 0x9084, 0x00ff, 0x908a, 0x0040, 0x0610, 0x00c0, 0x2001,
+	0x1800, 0x200c, 0x9186, 0x0003, 0x1168, 0x7004, 0x0002, 0x7482,
+	0x744c, 0x7482, 0x7480, 0x7482, 0x7482, 0x7482, 0x7482, 0x7482,
+	0x080c, 0x74ed, 0x782c, 0xd09c, 0x090c, 0x79c6, 0x0005, 0x9082,
+	0x005a, 0x1218, 0x2100, 0x003b, 0x0c10, 0x080c, 0x7523, 0x0c90,
+	0x00e3, 0x08e8, 0x0005, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523,
+	0x7523, 0x7523, 0x7523, 0x7545, 0x7523, 0x7523, 0x7523, 0x7523,
+	0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523,
+	0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x752f,
+	0x7523, 0x772d, 0x7523, 0x7523, 0x7523, 0x7545, 0x7523, 0x752f,
+	0x776e, 0x77af, 0x77f6, 0x780a, 0x7523, 0x7523, 0x7545, 0x752f,
+	0x7523, 0x7523, 0x7602, 0x78b5, 0x78d0, 0x7523, 0x7545, 0x7523,
+	0x7523, 0x7523, 0x7523, 0x75f8, 0x78d0, 0x7523, 0x7523, 0x7523,
+	0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7559, 0x7523,
+	0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523,
+	0x79f6, 0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x756d, 0x7523,
+	0x7523, 0x7523, 0x7523, 0x7523, 0x7523, 0x2079, 0x0040, 0x7004,
+	0x9086, 0x0003, 0x1198, 0x782c, 0x080c, 0x79ef, 0xd0a4, 0x0170,
 	0x7824, 0x2048, 0x9006, 0xa802, 0xa806, 0xa864, 0x9084, 0x00ff,
-	0x908a, 0x0040, 0x0608, 0x00b8, 0x2001, 0x1800, 0x200c, 0x9186,
-	0x0003, 0x1160, 0x7104, 0x9186, 0x0004, 0x0140, 0x9186, 0x0007,
-	0x0128, 0x9186, 0x0003, 0x1968, 0x080c, 0x74c9, 0x782c, 0xd09c,
-	0x090c, 0x79a2, 0x0005, 0x9082, 0x005a, 0x1218, 0x2100, 0x003b,
-	0x0c18, 0x080c, 0x74ff, 0x0c90, 0x00e3, 0x08f0, 0x0005, 0x74ff,
-	0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x7521,
-	0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff,
-	0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff,
-	0x74ff, 0x74ff, 0x74ff, 0x750b, 0x74ff, 0x7709, 0x74ff, 0x74ff,
-	0x74ff, 0x7521, 0x74ff, 0x750b, 0x774a, 0x778b, 0x77d2, 0x77e6,
-	0x74ff, 0x74ff, 0x7521, 0x750b, 0x74ff, 0x74ff, 0x75de, 0x7891,
-	0x78ac, 0x74ff, 0x7521, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x75d4,
-	0x78ac, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff,
-	0x74ff, 0x74ff, 0x7535, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff,
-	0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x79d2, 0x74ff, 0x74ff, 0x74ff,
-	0x74ff, 0x74ff, 0x7549, 0x74ff, 0x74ff, 0x74ff, 0x74ff, 0x74ff,
-	0x74ff, 0x2079, 0x0040, 0x7004, 0x9086, 0x0003, 0x1198, 0x782c,
-	0x080c, 0x79cb, 0xd0a4, 0x0170, 0x7824, 0x2048, 0x9006, 0xa802,
-	0xa806, 0xa864, 0x9084, 0x00ff, 0x908a, 0x001a, 0x1210, 0x002b,
-	0x0c50, 0x00e9, 0x080c, 0x79a2, 0x0005, 0x74ff, 0x750b, 0x76f5,
-	0x74ff, 0x750b, 0x74ff, 0x750b, 0x750b, 0x74ff, 0x750b, 0x76f5,
-	0x750b, 0x750b, 0x750b, 0x750b, 0x750b, 0x74ff, 0x750b, 0x76f5,
-	0x74ff, 0x74ff, 0x750b, 0x74ff, 0x74ff, 0x74ff, 0x750b, 0x00e6,
-	0x2071, 0x18f0, 0x2009, 0x0400, 0x0071, 0x00ee, 0x0005, 0x2009,
-	0x1000, 0x0049, 0x0005, 0x2009, 0x2000, 0x0029, 0x0005, 0x2009,
-	0x0800, 0x0009, 0x0005, 0x7007, 0x0001, 0xa868, 0x9084, 0x00ff,
-	0x9105, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c, 0x6991, 0x012e,
-	0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0d08, 0x8001, 0x1120,
-	0x7007, 0x0001, 0x0804, 0x76b3, 0x7007, 0x0003, 0x7012, 0x2900,
-	0x7016, 0x701a, 0x704b, 0x76b3, 0x0005, 0xa864, 0x8007, 0x9084,
-	0x00ff, 0x0968, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x76ce,
-	0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x76ce,
-	0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x9086, 0x0001, 0x1904,
-	0x7507, 0x7007, 0x0001, 0x2009, 0x1833, 0x210c, 0x81ff, 0x1904,
-	0x75ab, 0xa994, 0x9186, 0x006f, 0x0188, 0x9186, 0x0074, 0x15b0,
-	0x0026, 0x2011, 0x0010, 0x080c, 0x668a, 0x002e, 0x0578, 0x0016,
-	0xa998, 0x080c, 0x66d4, 0x001e, 0x1548, 0x0400, 0x080c, 0x7096,
-	0x0140, 0xa897, 0x4005, 0xa89b, 0x0016, 0x2001, 0x0030, 0x900e,
-	0x0438, 0x0026, 0x2011, 0x8008, 0x080c, 0x668a, 0x002e, 0x01b0,
-	0x0016, 0x0026, 0x0036, 0xa998, 0xaaa0, 0xab9c, 0x918d, 0x8000,
-	0x080c, 0x66d4, 0x003e, 0x002e, 0x001e, 0x1140, 0xa897, 0x4005,
-	0xa89b, 0x4009, 0x2001, 0x0030, 0x900e, 0x0050, 0xa868, 0x9084,
-	0x00ff, 0xa86a, 0xa883, 0x0000, 0x080c, 0x5f02, 0x1108, 0x0005,
-	0x0126, 0x2091, 0x8000, 0xa867, 0x0139, 0xa87a, 0xa982, 0x080c,
-	0x6991, 0x012e, 0x0ca0, 0xa994, 0x9186, 0x0071, 0x0904, 0x7559,
-	0x9186, 0x0064, 0x0904, 0x7559, 0x9186, 0x007c, 0x0904, 0x7559,
-	0x9186, 0x0028, 0x0904, 0x7559, 0x9186, 0x0038, 0x0904, 0x7559,
-	0x9186, 0x0078, 0x0904, 0x7559, 0x9186, 0x005f, 0x0904, 0x7559,
-	0x9186, 0x0056, 0x0904, 0x7559, 0xa897, 0x4005, 0xa89b, 0x0001,
-	0x2001, 0x0030, 0x900e, 0x0860, 0xa87c, 0x9084, 0x00c0, 0x9086,
-	0x00c0, 0x1120, 0x7007, 0x0001, 0x0804, 0x78c3, 0x2900, 0x7016,
-	0x701a, 0x20a9, 0x0004, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0030,
-	0x2098, 0x7050, 0x2040, 0xa060, 0x20e8, 0xa05c, 0x9080, 0x0023,
-	0x20a0, 0x4003, 0xa888, 0x7012, 0x9082, 0x0401, 0x1a04, 0x750f,
-	0xaab4, 0x928a, 0x0002, 0x1a04, 0x750f, 0x82ff, 0x1138, 0xa8b8,
-	0xa9bc, 0x9105, 0x0118, 0x2001, 0x7671, 0x0018, 0x9280, 0x7667,
-	0x2005, 0x7056, 0x7010, 0x9015, 0x0904, 0x7652, 0x080c, 0x103b,
-	0x1118, 0x7007, 0x0004, 0x0005, 0x2900, 0x7022, 0x7054, 0x2060,
-	0xe000, 0xa866, 0x7050, 0x2040, 0xa95c, 0xe004, 0x9100, 0xa076,
-	0xa860, 0xa072, 0xe008, 0x920a, 0x1210, 0x900e, 0x2200, 0x7112,
-	0xe20c, 0x8003, 0x800b, 0x9296, 0x0004, 0x0108, 0x9108, 0xa17a,
-	0x810b, 0xa17e, 0x080c, 0x1117, 0xa06c, 0x908e, 0x0100, 0x0170,
-	0x9086, 0x0200, 0x0118, 0x7007, 0x0007, 0x0005, 0x7020, 0x2048,
-	0x080c, 0x1054, 0x7014, 0x2048, 0x0804, 0x750f, 0x7020, 0x2048,
-	0x7018, 0xa802, 0xa807, 0x0000, 0x2908, 0x2048, 0xa906, 0x711a,
-	0x0804, 0x760a, 0x7014, 0x2048, 0x7007, 0x0001, 0xa8b4, 0x9005,
-	0x1128, 0xa8b8, 0xa9bc, 0x9105, 0x0108, 0x00b9, 0xa864, 0x9084,
-	0x00ff, 0x9086, 0x001e, 0x0904, 0x78c3, 0x0804, 0x76b3, 0x7669,
-	0x766d, 0x0002, 0x001d, 0x0007, 0x0004, 0x000a, 0x001b, 0x0005,
-	0x0006, 0x000a, 0x001d, 0x0005, 0x0004, 0x0076, 0x0066, 0xafb8,
-	0xaebc, 0xa804, 0x2050, 0xb0c0, 0xb0e2, 0xb0bc, 0xb0de, 0xb0b8,
-	0xb0d2, 0xb0b4, 0xb0ce, 0xb6da, 0xb7d6, 0xb0b0, 0xb0ca, 0xb0ac,
-	0xb0c6, 0xb0a8, 0xb0ba, 0xb0a4, 0xb0b6, 0xb6c2, 0xb7be, 0xb0a0,
-	0xb0b2, 0xb09c, 0xb0ae, 0xb098, 0xb0a2, 0xb094, 0xb09e, 0xb6aa,
-	0xb7a6, 0xb090, 0xb09a, 0xb08c, 0xb096, 0xb088, 0xb08a, 0xb084,
-	0xb086, 0xb692, 0xb78e, 0xb080, 0xb082, 0xb07c, 0xb07e, 0xb078,
-	0xb072, 0xb074, 0xb06e, 0xb67a, 0xb776, 0xb004, 0x9055, 0x1958,
-	0x006e, 0x007e, 0x0005, 0x2009, 0x1833, 0x210c, 0x81ff, 0x1178,
-	0x080c, 0x5d51, 0x1108, 0x0005, 0x080c, 0x6ba2, 0x0126, 0x2091,
-	0x8000, 0x080c, 0xbb45, 0x080c, 0x6991, 0x012e, 0x0ca0, 0x080c,
-	0xbf5a, 0x1d70, 0x2001, 0x0028, 0x900e, 0x0c70, 0x2009, 0x1833,
-	0x210c, 0x81ff, 0x11d8, 0xa888, 0x9005, 0x01e0, 0xa883, 0x0000,
-	0xa87c, 0xd0f4, 0x0120, 0x080c, 0x5e64, 0x1138, 0x0005, 0x9006,
-	0xa87a, 0x080c, 0x5ddf, 0x1108, 0x0005, 0x0126, 0x2091, 0x8000,
-	0xa87a, 0xa982, 0x080c, 0x6991, 0x012e, 0x0cb0, 0x2001, 0x0028,
-	0x900e, 0x0c98, 0x2001, 0x0000, 0x0c80, 0x7018, 0xa802, 0x2908,
-	0x2048, 0xa906, 0x711a, 0x7010, 0x8001, 0x7012, 0x0118, 0x7007,
-	0x0003, 0x0030, 0x7014, 0x2048, 0x7007, 0x0001, 0x7048, 0x080f,
-	0x0005, 0x00b6, 0x7007, 0x0001, 0xa974, 0xa878, 0x9084, 0x00ff,
-	0x9096, 0x0004, 0x0540, 0x20a9, 0x0001, 0x9096, 0x0001, 0x0190,
-	0x900e, 0x20a9, 0x0800, 0x9096, 0x0002, 0x0160, 0x9005, 0x11d8,
-	0xa974, 0x080c, 0x626b, 0x11b8, 0x0066, 0xae80, 0x080c, 0x637b,
-	0x006e, 0x0088, 0x0046, 0x2011, 0x180c, 0x2224, 0xc484, 0x2412,
-	0x004e, 0x00c6, 0x080c, 0x626b, 0x1110, 0x080c, 0x654e, 0x8108,
-	0x1f04, 0x7732, 0x00ce, 0xa87c, 0xd084, 0x1120, 0x080c, 0x1054,
-	0x00be, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x6991, 0x012e,
-	0x00be, 0x0005, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x080c,
-	0x6662, 0x0580, 0x2061, 0x1a3e, 0x6100, 0xd184, 0x0178, 0xa888,
-	0x9084, 0x00ff, 0x1550, 0x6000, 0xd084, 0x0520, 0x6004, 0x9005,
-	0x1538, 0x6003, 0x0000, 0x600b, 0x0000, 0x00c8, 0x2011, 0x0001,
-	0xa890, 0x9005, 0x1110, 0x2001, 0x001e, 0x8000, 0x6016, 0xa888,
-	0x9084, 0x00ff, 0x0178, 0x6006, 0xa888, 0x8007, 0x9084, 0x00ff,
-	0x0148, 0x600a, 0xa888, 0x8000, 0x1108, 0xc28d, 0x6202, 0x012e,
-	0x0804, 0x798c, 0x012e, 0x0804, 0x7986, 0x012e, 0x0804, 0x7980,
-	0x012e, 0x0804, 0x7983, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001,
-	0x080c, 0x6662, 0x05e0, 0x2061, 0x1a3e, 0x6000, 0xd084, 0x05b8,
-	0x6204, 0x6308, 0xd08c, 0x1530, 0xac78, 0x9484, 0x0003, 0x0170,
-	0xa988, 0x918c, 0x00ff, 0x8001, 0x1120, 0x2100, 0x9210, 0x0620,
-	0x0028, 0x8001, 0x1508, 0x2100, 0x9212, 0x02f0, 0x9484, 0x000c,
-	0x0188, 0xa988, 0x810f, 0x918c, 0x00ff, 0x9082, 0x0004, 0x1120,
-	0x2100, 0x9318, 0x0288, 0x0030, 0x9082, 0x0004, 0x1168, 0x2100,
-	0x931a, 0x0250, 0xa890, 0x9005, 0x0110, 0x8000, 0x6016, 0x6206,
-	0x630a, 0x012e, 0x0804, 0x798c, 0x012e, 0x0804, 0x7989, 0x012e,
-	0x0804, 0x7986, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x2061,
-	0x1a3e, 0x6300, 0xd38c, 0x1120, 0x6308, 0x8318, 0x0220, 0x630a,
-	0x012e, 0x0804, 0x799a, 0x012e, 0x0804, 0x7989, 0x00b6, 0x0126,
-	0x00c6, 0x2091, 0x8000, 0x7007, 0x0001, 0xa87c, 0xd0ac, 0x0148,
-	0x00c6, 0x2061, 0x1a3e, 0x6000, 0x9084, 0xfcff, 0x6002, 0x00ce,
-	0x0440, 0xa888, 0x9005, 0x05d8, 0xa88c, 0x9065, 0x0598, 0x2001,
-	0x1833, 0x2004, 0x9005, 0x0118, 0x080c, 0x9c14, 0x0068, 0x6017,
-	0xf400, 0x6063, 0x0000, 0xa97c, 0xd1a4, 0x0110, 0xa980, 0x6162,
-	0x2009, 0x0041, 0x080c, 0x9c76, 0xa988, 0x918c, 0xff00, 0x9186,
-	0x2000, 0x1138, 0x0026, 0x900e, 0x2011, 0xfdff, 0x080c, 0x83cd,
-	0x002e, 0xa87c, 0xd0c4, 0x0148, 0x2061, 0x1a3e, 0x6000, 0xd08c,
-	0x1120, 0x6008, 0x8000, 0x0208, 0x600a, 0x00ce, 0x012e, 0x00be,
-	0x0804, 0x798c, 0x00ce, 0x012e, 0x00be, 0x0804, 0x7986, 0xa984,
-	0x9186, 0x002e, 0x0d30, 0x9186, 0x002d, 0x0d18, 0x9186, 0x0045,
-	0x0510, 0x9186, 0x002a, 0x1130, 0x2001, 0x180c, 0x200c, 0xc194,
-	0x2102, 0x08b8, 0x9186, 0x0020, 0x0158, 0x9186, 0x0029, 0x1d10,
-	0xa974, 0x080c, 0x626b, 0x1968, 0xb800, 0xc0e4, 0xb802, 0x0848,
-	0xa88c, 0x9065, 0x09b8, 0x6007, 0x0024, 0x2001, 0x1956, 0x2004,
-	0x601a, 0x0804, 0x7821, 0xa88c, 0x9065, 0x0960, 0x00e6, 0xa890,
-	0x9075, 0x2001, 0x1833, 0x2004, 0x9005, 0x0150, 0x080c, 0x9c14,
-	0x8eff, 0x0118, 0x2e60, 0x080c, 0x9c14, 0x00ee, 0x0804, 0x7821,
-	0x6024, 0xc0dc, 0xc0d5, 0x6026, 0x2e60, 0x6007, 0x003a, 0xa8a0,
-	0x9005, 0x0130, 0x6007, 0x003b, 0xa8a4, 0x602e, 0xa8a8, 0x6016,
-	0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84b3, 0x00ee, 0x0804,
-	0x7821, 0x2061, 0x1a3e, 0x6000, 0xd084, 0x0190, 0xd08c, 0x1904,
-	0x799a, 0x0126, 0x2091, 0x8000, 0x6204, 0x8210, 0x0220, 0x6206,
-	0x012e, 0x0804, 0x799a, 0x012e, 0xa883, 0x0016, 0x0804, 0x7993,
-	0xa883, 0x0007, 0x0804, 0x7993, 0xa864, 0x8007, 0x9084, 0x00ff,
-	0x0130, 0x8001, 0x1138, 0x7007, 0x0001, 0x0069, 0x0005, 0x080c,
-	0x7507, 0x0040, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a,
-	0x704b, 0x78c3, 0x0005, 0x00b6, 0x00e6, 0x0126, 0x2091, 0x8000,
-	0x903e, 0x2061, 0x1800, 0x61cc, 0x81ff, 0x1904, 0x7945, 0x6130,
-	0xd194, 0x1904, 0x796f, 0xa878, 0x2070, 0x9e82, 0x1ddc, 0x0a04,
-	0x7939, 0x6064, 0x9e02, 0x1a04, 0x7939, 0x7120, 0x9186, 0x0006,
-	0x1904, 0x792b, 0x7010, 0x905d, 0x0904, 0x7945, 0xb800, 0xd0e4,
-	0x1904, 0x7969, 0x2061, 0x1a3e, 0x6100, 0x9184, 0x0301, 0x9086,
-	0x0001, 0x15a0, 0x7024, 0xd0dc, 0x1904, 0x7972, 0xa883, 0x0000,
-	0xa803, 0x0000, 0x2908, 0x7014, 0x9005, 0x1198, 0x7116, 0xa87c,
-	0xd0f4, 0x1904, 0x7975, 0x080c, 0x5388, 0xd09c, 0x1118, 0xa87c,
-	0xc0cc, 0xa87e, 0x2e60, 0x080c, 0x82bd, 0x012e, 0x00ee, 0x00be,
-	0x0005, 0x2048, 0xa800, 0x9005, 0x1de0, 0xa902, 0x2148, 0xa87c,
-	0xd0f4, 0x1904, 0x7975, 0x012e, 0x00ee, 0x00be, 0x0005, 0x012e,
-	0x00ee, 0xa883, 0x0006, 0x00be, 0x0804, 0x7993, 0xd184, 0x0db8,
-	0xd1c4, 0x1190, 0x00a0, 0xa974, 0x080c, 0x626b, 0x15d0, 0xb800,
-	0xd0e4, 0x15b8, 0x7120, 0x9186, 0x0007, 0x1118, 0xa883, 0x0002,
-	0x0490, 0xa883, 0x0008, 0x0478, 0xa883, 0x000e, 0x0460, 0xa883,
-	0x0017, 0x0448, 0xa883, 0x0035, 0x0430, 0x080c, 0x538c, 0xd0fc,
-	0x01e8, 0xa878, 0x2070, 0x9e82, 0x1ddc, 0x02c0, 0x6064, 0x9e02,
-	0x12a8, 0x7120, 0x9186, 0x0006, 0x1188, 0x7010, 0x905d, 0x0170,
-	0xb800, 0xd0bc, 0x0158, 0x2039, 0x0001, 0x7000, 0x9086, 0x0007,
-	0x1904, 0x78cf, 0x7003, 0x0002, 0x0804, 0x78cf, 0xa883, 0x0028,
-	0x0010, 0xa883, 0x0029, 0x012e, 0x00ee, 0x00be, 0x0420, 0xa883,
-	0x002a, 0x0cc8, 0xa883, 0x0045, 0x0cb0, 0x2e60, 0x2019, 0x0002,
-	0x601b, 0x0014, 0x080c, 0xce09, 0x012e, 0x00ee, 0x00be, 0x0005,
-	0x2009, 0x003e, 0x0058, 0x2009, 0x0004, 0x0040, 0x2009, 0x0006,
-	0x0028, 0x2009, 0x0016, 0x0010, 0x2009, 0x0001, 0xa884, 0x9084,
-	0xff00, 0x9105, 0xa886, 0x0126, 0x2091, 0x8000, 0x080c, 0x6991,
-	0x012e, 0x0005, 0x080c, 0x1054, 0x0005, 0x00d6, 0x080c, 0x82b4,
-	0x00de, 0x0005, 0x00d6, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x0040, 0x702c, 0xd084, 0x01d8, 0x908c, 0x0780, 0x190c, 0x7a2e,
-	0xd09c, 0x11a8, 0x2071, 0x1800, 0x70bc, 0x90ea, 0x0040, 0x0278,
-	0x8001, 0x70be, 0x702c, 0x2048, 0xa800, 0x702e, 0x9006, 0xa802,
-	0xa806, 0x2071, 0x0040, 0x2900, 0x7022, 0x702c, 0x0c28, 0x012e,
-	0x00ee, 0x00de, 0x0005, 0x0006, 0x9084, 0x0780, 0x190c, 0x7a2e,
-	0x000e, 0x0005, 0x00d6, 0x00c6, 0x0036, 0x0026, 0x0016, 0x00b6,
-	0x7007, 0x0001, 0xaa74, 0x9282, 0x0004, 0x1a04, 0x7a1f, 0xa97c,
-	0x9188, 0x1000, 0x2104, 0x905d, 0xb804, 0xd284, 0x0140, 0x05e8,
-	0x8007, 0x9084, 0x00ff, 0x9084, 0x0006, 0x1108, 0x04b0, 0x2b10,
-	0x080c, 0x9b84, 0x1118, 0x080c, 0x9c49, 0x05a8, 0x6212, 0xa874,
-	0x0002, 0x79fd, 0x7a02, 0x7a05, 0x7a0b, 0x2019, 0x0002, 0x080c,
-	0xd1fc, 0x0060, 0x080c, 0xd18c, 0x0048, 0x2019, 0x0002, 0xa980,
-	0x080c, 0xd1ab, 0x0018, 0xa980, 0x080c, 0xd18c, 0x080c, 0x9bda,
-	0xa887, 0x0000, 0x0126, 0x2091, 0x8000, 0x080c, 0x6991, 0x012e,
-	0x00be, 0x001e, 0x002e, 0x003e, 0x00ce, 0x00de, 0x0005, 0xa887,
-	0x0006, 0x0c80, 0xa887, 0x0002, 0x0c68, 0xa887, 0x0005, 0x0c50,
-	0xa887, 0x0004, 0x0c38, 0xa887, 0x0007, 0x0c20, 0x2091, 0x8000,
-	0x0e04, 0x7a30, 0x0006, 0x0016, 0x2001, 0x8003, 0x0006, 0x0804,
-	0x0d6e, 0x2001, 0x1833, 0x2004, 0x9005, 0x0005, 0x0005, 0x00f6,
-	0x2079, 0x0300, 0x2001, 0x0200, 0x200c, 0xc1e5, 0xc1dc, 0x2102,
-	0x2009, 0x0218, 0x210c, 0xd1ec, 0x1120, 0x080c, 0x153a, 0x00fe,
-	0x0005, 0x2001, 0x020d, 0x2003, 0x0020, 0x781f, 0x0300, 0x00fe,
-	0x0005, 0x781c, 0xd08c, 0x0904, 0x7ab1, 0x68bc, 0x90aa, 0x0005,
-	0x0a04, 0x804a, 0x7d44, 0x7c40, 0xd59c, 0x190c, 0x0d65, 0x9584,
-	0x00f6, 0x1508, 0x9484, 0x7000, 0x0138, 0x908a, 0x2000, 0x1258,
-	0x9584, 0x0700, 0x8007, 0x04f0, 0x7000, 0x9084, 0xff00, 0x9086,
-	0x8100, 0x0db0, 0x00b0, 0x9484, 0x0fff, 0x1130, 0x7000, 0x9084,
-	0xff00, 0x9086, 0x8100, 0x11c0, 0x080c, 0xd5e4, 0x080c, 0x7f91,
-	0x7817, 0x0140, 0x00a8, 0x9584, 0x0076, 0x1118, 0x080c, 0x7fed,
-	0x19c8, 0xd5a4, 0x0148, 0x0046, 0x0056, 0x080c, 0x7b01, 0x080c,
-	0x1fc8, 0x005e, 0x004e, 0x0020, 0x080c, 0xd5e4, 0x7817, 0x0140,
-	0x080c, 0x7096, 0x0168, 0x2001, 0x0111, 0x2004, 0xd08c, 0x0140,
-	0x688f, 0x0000, 0x2001, 0x0110, 0x2003, 0x0008, 0x2003, 0x0000,
-	0x0489, 0x0005, 0x0002, 0x7abe, 0x7db3, 0x7abb, 0x7abb, 0x7abb,
-	0x7abb, 0x7abb, 0x7abb, 0x7817, 0x0140, 0x0005, 0x7000, 0x908c,
-	0xff00, 0x9194, 0xf000, 0x810f, 0x9484, 0x0fff, 0x688e, 0x9286,
-	0x2000, 0x1150, 0x6800, 0x9086, 0x0001, 0x1118, 0x080c, 0x53e9,
-	0x0070, 0x080c, 0x7b21, 0x0058, 0x9286, 0x3000, 0x1118, 0x080c,
-	0x7cf0, 0x0028, 0x9286, 0x8000, 0x1110, 0x080c, 0x7ec7, 0x7817,
-	0x0140, 0x0005, 0x2001, 0x1810, 0x2004, 0xd08c, 0x0178, 0x2001,
-	0x1800, 0x2004, 0x9086, 0x0003, 0x1148, 0x0026, 0x0036, 0x2011,
-	0x8048, 0x2518, 0x080c, 0x48da, 0x003e, 0x002e, 0x0005, 0x0036,
-	0x0046, 0x0056, 0x00f6, 0x2079, 0x0200, 0x2019, 0xfffe, 0x7c30,
-	0x0050, 0x0036, 0x0046, 0x0056, 0x00f6, 0x2079, 0x0200, 0x7d44,
-	0x7c40, 0x2019, 0xffff, 0x2001, 0x1810, 0x2004, 0xd08c, 0x0160,
-	0x2001, 0x1800, 0x2004, 0x9086, 0x0003, 0x1130, 0x0026, 0x2011,
-	0x8048, 0x080c, 0x48da, 0x002e, 0x00fe, 0x005e, 0x004e, 0x003e,
-	0x0005, 0x00b6, 0x00c6, 0x7010, 0x9084, 0xff00, 0x8007, 0x9096,
-	0x0001, 0x0120, 0x9096, 0x0023, 0x1904, 0x7cc1, 0x9186, 0x0023,
-	0x15c0, 0x080c, 0x7f5c, 0x0904, 0x7cc1, 0x6120, 0x9186, 0x0001,
-	0x0150, 0x9186, 0x0004, 0x0138, 0x9186, 0x0008, 0x0120, 0x9186,
-	0x000a, 0x1904, 0x7cc1, 0x7124, 0x610a, 0x7030, 0x908e, 0x0200,
-	0x1130, 0x2009, 0x0015, 0x080c, 0x9c76, 0x0804, 0x7cc1, 0x908e,
-	0x0214, 0x0118, 0x908e, 0x0210, 0x1130, 0x2009, 0x0015, 0x080c,
-	0x9c76, 0x0804, 0x7cc1, 0x908e, 0x0100, 0x1904, 0x7cc1, 0x7034,
-	0x9005, 0x1904, 0x7cc1, 0x2009, 0x0016, 0x080c, 0x9c76, 0x0804,
-	0x7cc1, 0x9186, 0x0022, 0x1904, 0x7cc1, 0x7030, 0x908e, 0x0300,
-	0x1580, 0x68d8, 0xd0a4, 0x0528, 0xc0b5, 0x68da, 0x7100, 0x918c,
-	0x00ff, 0x697a, 0x7004, 0x687e, 0x00f6, 0x2079, 0x0100, 0x79e6,
-	0x78ea, 0x0006, 0x9084, 0x00ff, 0x0016, 0x2008, 0x080c, 0x2486,
-	0x7932, 0x7936, 0x001e, 0x000e, 0x00fe, 0x080c, 0x243d, 0x695a,
-	0x703c, 0x00e6, 0x2071, 0x0140, 0x7086, 0x2071, 0x1800, 0x70b2,
-	0x00ee, 0x7034, 0x9005, 0x1904, 0x7cc1, 0x2009, 0x0017, 0x0804,
-	0x7c71, 0x908e, 0x0400, 0x1190, 0x7034, 0x9005, 0x1904, 0x7cc1,
-	0x080c, 0x7096, 0x0120, 0x2009, 0x001d, 0x0804, 0x7c71, 0x68d8,
-	0xc0a5, 0x68da, 0x2009, 0x0030, 0x0804, 0x7c71, 0x908e, 0x0500,
-	0x1140, 0x7034, 0x9005, 0x1904, 0x7cc1, 0x2009, 0x0018, 0x0804,
-	0x7c71, 0x908e, 0x2010, 0x1120, 0x2009, 0x0019, 0x0804, 0x7c71,
-	0x908e, 0x2110, 0x1120, 0x2009, 0x001a, 0x0804, 0x7c71, 0x908e,
-	0x5200, 0x1140, 0x7034, 0x9005, 0x1904, 0x7cc1, 0x2009, 0x001b,
-	0x0804, 0x7c71, 0x908e, 0x5000, 0x1140, 0x7034, 0x9005, 0x1904,
-	0x7cc1, 0x2009, 0x001c, 0x0804, 0x7c71, 0x908e, 0x1300, 0x1120,
-	0x2009, 0x0034, 0x0804, 0x7c71, 0x908e, 0x1200, 0x1140, 0x7034,
-	0x9005, 0x1904, 0x7cc1, 0x2009, 0x0024, 0x0804, 0x7c71, 0x908c,
-	0xff00, 0x918e, 0x2400, 0x1170, 0x2009, 0x002d, 0x2001, 0x1810,
-	0x2004, 0xd09c, 0x0904, 0x7c71, 0x080c, 0xc63d, 0x1904, 0x7cc1,
-	0x0804, 0x7c6f, 0x908c, 0xff00, 0x918e, 0x5300, 0x1120, 0x2009,
-	0x002a, 0x0804, 0x7c71, 0x908e, 0x0f00, 0x1120, 0x2009, 0x0020,
-	0x0804, 0x7c71, 0x908e, 0x6104, 0x1528, 0x2029, 0x0205, 0x2011,
-	0x026d, 0x8208, 0x2204, 0x9082, 0x0004, 0x8004, 0x8004, 0x20a8,
-	0x2011, 0x8015, 0x211c, 0x8108, 0x0046, 0x2124, 0x080c, 0x48da,
-	0x004e, 0x8108, 0x0f04, 0x7c3d, 0x9186, 0x0280, 0x1d88, 0x2504,
-	0x8000, 0x202a, 0x2009, 0x0260, 0x0c58, 0x202b, 0x0000, 0x2009,
-	0x0023, 0x0478, 0x908e, 0x6000, 0x1118, 0x2009, 0x003f, 0x0448,
-	0x908e, 0x7800, 0x1118, 0x2009, 0x0045, 0x0418, 0x908e, 0x1000,
-	0x1118, 0x2009, 0x004e, 0x00e8, 0x908e, 0x6300, 0x1118, 0x2009,
-	0x004a, 0x00b8, 0x908c, 0xff00, 0x918e, 0x5600, 0x1118, 0x2009,
-	0x004f, 0x0078, 0x908c, 0xff00, 0x918e, 0x5700, 0x1118, 0x2009,
-	0x0050, 0x0038, 0x2009, 0x001d, 0x6838, 0xd0d4, 0x0110, 0x2009,
-	0x004c, 0x0016, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c,
-	0x243d, 0x1904, 0x7cc4, 0x080c, 0x620b, 0x1904, 0x7cc4, 0xbe12,
-	0xbd16, 0x001e, 0x0016, 0x080c, 0x7096, 0x01c0, 0x68d8, 0xd08c,
-	0x1148, 0x7000, 0x9084, 0x00ff, 0x1188, 0x7004, 0x9084, 0xff00,
-	0x1168, 0x0040, 0x6878, 0x9606, 0x1148, 0x687c, 0x9506, 0x9084,
-	0xff00, 0x1120, 0x9584, 0x00ff, 0xb886, 0x0080, 0xb884, 0x9005,
-	0x1168, 0x9186, 0x0046, 0x1150, 0x6878, 0x9606, 0x1138, 0x687c,
-	0x9506, 0x9084, 0xff00, 0x1110, 0x001e, 0x0098, 0x080c, 0x9b84,
-	0x01a8, 0x2b08, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e,
-	0x9186, 0x004c, 0x1110, 0x6023, 0x000a, 0x0016, 0x001e, 0x080c,
-	0x9c76, 0x00ce, 0x00be, 0x0005, 0x001e, 0x0cd8, 0x2001, 0x180e,
-	0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x48da, 0x080c,
-	0x9c49, 0x0d90, 0x2b08, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a,
-	0x001e, 0x0016, 0x9186, 0x0017, 0x0118, 0x9186, 0x0030, 0x1128,
-	0x6007, 0x0009, 0x6017, 0x2900, 0x0020, 0x6007, 0x0051, 0x6017,
-	0x0000, 0x602f, 0x0009, 0x6003, 0x0001, 0x080c, 0x84ba, 0x08a0,
-	0x080c, 0x3144, 0x1140, 0x7010, 0x9084, 0xff00, 0x8007, 0x908e,
-	0x0008, 0x1108, 0x0009, 0x0005, 0x00b6, 0x00c6, 0x0046, 0x7000,
-	0x908c, 0xff00, 0x810f, 0x9186, 0x0033, 0x11e8, 0x080c, 0x7f5c,
-	0x0904, 0x7d4b, 0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1140,
-	0x7034, 0x9005, 0x15c0, 0x2009, 0x0015, 0x080c, 0x9c76, 0x0498,
-	0x908e, 0x0100, 0x1580, 0x7034, 0x9005, 0x1568, 0x2009, 0x0016,
-	0x080c, 0x9c76, 0x0440, 0x9186, 0x0032, 0x1528, 0x7030, 0x908e,
-	0x1400, 0x1508, 0x2009, 0x0038, 0x0016, 0x2011, 0x0263, 0x2204,
-	0x8211, 0x220c, 0x080c, 0x243d, 0x11a8, 0x080c, 0x620b, 0x1190,
-	0xbe12, 0xbd16, 0x080c, 0x9b84, 0x0168, 0x2b08, 0x6112, 0x080c,
-	0xbcdb, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x080c, 0x9c76,
-	0x0010, 0x00ce, 0x001e, 0x004e, 0x00ce, 0x00be, 0x0005, 0x00b6,
-	0x0046, 0x00e6, 0x00d6, 0x2028, 0x2130, 0x9696, 0x00ff, 0x11b8,
-	0x9592, 0xfffc, 0x02a0, 0x9596, 0xfffd, 0x1120, 0x2009, 0x007f,
-	0x0804, 0x7dad, 0x9596, 0xfffe, 0x1120, 0x2009, 0x007e, 0x0804,
-	0x7dad, 0x9596, 0xfffc, 0x1118, 0x2009, 0x0080, 0x04f0, 0x2011,
-	0x0000, 0x2019, 0x1836, 0x231c, 0xd3ac, 0x0130, 0x9026, 0x20a9,
-	0x0800, 0x2071, 0x1000, 0x0030, 0x2021, 0x0081, 0x20a9, 0x077f,
-	0x2071, 0x1081, 0x2e1c, 0x93dd, 0x0000, 0x1140, 0x82ff, 0x11d0,
-	0x9496, 0x00ff, 0x01b8, 0x2410, 0xc2fd, 0x00a0, 0xbf10, 0x2600,
-	0x9706, 0xb814, 0x1120, 0x9546, 0x1110, 0x2408, 0x00b0, 0x9745,
-	0x1148, 0x94c6, 0x007e, 0x0130, 0x94c6, 0x007f, 0x0118, 0x94c6,
-	0x0080, 0x1d20, 0x8420, 0x8e70, 0x1f04, 0x7d82, 0x82ff, 0x1118,
-	0x9085, 0x0001, 0x0018, 0xc2fc, 0x2208, 0x9006, 0x00de, 0x00ee,
-	0x004e, 0x00be, 0x0005, 0x7000, 0x908c, 0xff00, 0x810f, 0x9184,
-	0x000f, 0x0002, 0x7dca, 0x7dca, 0x7dca, 0x7f6e, 0x7dca, 0x7dcd,
-	0x7df2, 0x7e7b, 0x7dca, 0x7dca, 0x7dca, 0x7dca, 0x7dca, 0x7dca,
-	0x7dca, 0x7dca, 0x7817, 0x0140, 0x0005, 0x00b6, 0x7110, 0xd1bc,
-	0x01e8, 0x7120, 0x2160, 0x9c8c, 0x0003, 0x11c0, 0x9c8a, 0x1ddc,
-	0x02a8, 0x6864, 0x9c02, 0x1290, 0x7008, 0x9084, 0x00ff, 0x6110,
-	0x2158, 0xb910, 0x9106, 0x1150, 0x700c, 0xb914, 0x9106, 0x1130,
-	0x7124, 0x610a, 0x2009, 0x0046, 0x080c, 0x9c76, 0x7817, 0x0140,
-	0x00be, 0x0005, 0x00b6, 0x00c6, 0x9484, 0x0fff, 0x0904, 0x7e57,
-	0x7110, 0xd1bc, 0x1904, 0x7e57, 0x7108, 0x700c, 0x2028, 0x918c,
-	0x00ff, 0x2130, 0x9094, 0xff00, 0x15c8, 0x81ff, 0x15b8, 0x9080,
-	0x317f, 0x200d, 0x918c, 0xff00, 0x810f, 0x2001, 0x0080, 0x9106,
-	0x0904, 0x7e57, 0x9182, 0x0801, 0x1a04, 0x7e57, 0x9190, 0x1000,
-	0x2204, 0x905d, 0x05e0, 0xbe12, 0xbd16, 0xb800, 0xd0ec, 0x15b8,
-	0xba04, 0x9294, 0xff00, 0x9286, 0x0600, 0x1190, 0x080c, 0x9b84,
-	0x0598, 0x2b08, 0x7028, 0x6052, 0x702c, 0x604e, 0x6112, 0x6023,
-	0x0006, 0x7120, 0x610a, 0x7130, 0x615e, 0x080c, 0xc8a3, 0x00f8,
-	0x080c, 0x6666, 0x1138, 0xb807, 0x0606, 0x0c40, 0x190c, 0x7d4f,
-	0x11b0, 0x0880, 0x080c, 0x9b84, 0x2b08, 0x0188, 0x6112, 0x6023,
-	0x0004, 0x7120, 0x610a, 0x9286, 0x0400, 0x1118, 0x6007, 0x0005,
-	0x0010, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x84ba, 0x7817,
-	0x0140, 0x00ce, 0x00be, 0x0005, 0x2001, 0x180e, 0x2004, 0xd0ec,
-	0x0120, 0x2011, 0x8049, 0x080c, 0x48da, 0x080c, 0x9c49, 0x0d78,
-	0x2b08, 0x6112, 0x6023, 0x0006, 0x7120, 0x610a, 0x7130, 0x615e,
-	0x6017, 0xf300, 0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022,
-	0x080c, 0x84b3, 0x08e0, 0x00b6, 0x7110, 0xd1bc, 0x05d0, 0x7020,
-	0x2060, 0x9c84, 0x0003, 0x15a8, 0x9c82, 0x1ddc, 0x0690, 0x6864,
-	0x9c02, 0x1678, 0x9484, 0x0fff, 0x9082, 0x000c, 0x0650, 0x7008,
-	0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1510, 0x700c,
-	0xb914, 0x9106, 0x11f0, 0x7124, 0x610a, 0x601c, 0xd0fc, 0x11c8,
-	0x2001, 0x0271, 0x2004, 0x9005, 0x1180, 0x9484, 0x0fff, 0x9082,
-	0x000c, 0x0158, 0x0066, 0x2031, 0x0100, 0xa001, 0xa001, 0x8631,
-	0x1de0, 0x006e, 0x601c, 0xd0fc, 0x1120, 0x2009, 0x0045, 0x080c,
-	0x9c76, 0x7817, 0x0140, 0x00be, 0x0005, 0x6120, 0x9186, 0x0002,
-	0x0128, 0x9186, 0x0005, 0x0110, 0x9085, 0x0001, 0x0005, 0x080c,
-	0x3144, 0x1168, 0x7010, 0x9084, 0xff00, 0x8007, 0x9086, 0x0000,
-	0x1130, 0x9184, 0x000f, 0x908a, 0x0006, 0x1208, 0x000b, 0x0005,
-	0x7ede, 0x7edf, 0x7ede, 0x7ede, 0x7f3e, 0x7f4d, 0x0005, 0x00b6,
-	0x7110, 0xd1bc, 0x0120, 0x702c, 0xd084, 0x0904, 0x7f3c, 0x700c,
-	0x7108, 0x080c, 0x243d, 0x1904, 0x7f3c, 0x080c, 0x620b, 0x1904,
-	0x7f3c, 0xbe12, 0xbd16, 0x7110, 0xd1bc, 0x01d8, 0x080c, 0x6666,
-	0x0118, 0x9086, 0x0004, 0x1588, 0x00c6, 0x080c, 0x7f5c, 0x00ce,
-	0x05d8, 0x080c, 0x9b84, 0x2b08, 0x05b8, 0x6112, 0x080c, 0xbcdb,
-	0x6023, 0x0002, 0x7120, 0x610a, 0x2009, 0x0088, 0x080c, 0x9c76,
-	0x0458, 0x080c, 0x6666, 0x0148, 0x9086, 0x0004, 0x0130, 0x080c,
-	0x666e, 0x0118, 0x9086, 0x0004, 0x1180, 0x080c, 0x9b84, 0x2b08,
-	0x01d8, 0x6112, 0x080c, 0xbcdb, 0x6023, 0x0005, 0x7120, 0x610a,
-	0x2009, 0x0088, 0x080c, 0x9c76, 0x0078, 0x080c, 0x9b84, 0x2b08,
-	0x0158, 0x6112, 0x080c, 0xbcdb, 0x6023, 0x0004, 0x7120, 0x610a,
-	0x2009, 0x0001, 0x080c, 0x9c76, 0x00be, 0x0005, 0x7110, 0xd1bc,
-	0x0158, 0x00d1, 0x0148, 0x080c, 0x7ebd, 0x1130, 0x7124, 0x610a,
-	0x2009, 0x0089, 0x080c, 0x9c76, 0x0005, 0x7110, 0xd1bc, 0x0158,
-	0x0059, 0x0148, 0x080c, 0x7ebd, 0x1130, 0x7124, 0x610a, 0x2009,
-	0x008a, 0x080c, 0x9c76, 0x0005, 0x7020, 0x2060, 0x9c84, 0x0003,
-	0x1158, 0x9c82, 0x1ddc, 0x0240, 0x2001, 0x1819, 0x2004, 0x9c02,
-	0x1218, 0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8, 0x00b6, 0x7110,
-	0xd1bc, 0x11d8, 0x7024, 0x2060, 0x9c84, 0x0003, 0x11b0, 0x9c82,
-	0x1ddc, 0x0298, 0x6864, 0x9c02, 0x1280, 0x7008, 0x9084, 0x00ff,
-	0x6110, 0x2158, 0xb910, 0x9106, 0x1140, 0x700c, 0xb914, 0x9106,
-	0x1120, 0x2009, 0x0051, 0x080c, 0x9c76, 0x7817, 0x0140, 0x00be,
-	0x0005, 0x2031, 0x0105, 0x0069, 0x0005, 0x2031, 0x0206, 0x0049,
-	0x0005, 0x2031, 0x0207, 0x0029, 0x0005, 0x2031, 0x0213, 0x0009,
-	0x0005, 0x00c6, 0x0096, 0x00f6, 0x7000, 0x9084, 0xf000, 0x9086,
-	0xc000, 0x05c0, 0x080c, 0x9b84, 0x05a8, 0x0066, 0x00c6, 0x0046,
-	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x243d, 0x1590,
-	0x080c, 0x620b, 0x1578, 0xbe12, 0xbd16, 0x2b00, 0x004e, 0x00ce,
-	0x6012, 0x080c, 0xbcdb, 0x080c, 0x1022, 0x0500, 0x2900, 0x6062,
-	0x9006, 0xa802, 0xa866, 0xac6a, 0xa85c, 0x90f8, 0x001b, 0x20a9,
-	0x000e, 0xa860, 0x20e8, 0x20e1, 0x0000, 0x2fa0, 0x2e98, 0x4003,
-	0x006e, 0x6616, 0x6007, 0x003e, 0x6023, 0x0001, 0x6003, 0x0001,
-	0x080c, 0x84ba, 0x00fe, 0x009e, 0x00ce, 0x0005, 0x080c, 0x9bda,
-	0x006e, 0x0cc0, 0x004e, 0x00ce, 0x0cc8, 0x00c6, 0x7000, 0x908c,
-	0xff00, 0x9184, 0xf000, 0x810f, 0x9086, 0x2000, 0x1904, 0x8044,
-	0x9186, 0x0022, 0x15f0, 0x2001, 0x0111, 0x2004, 0x9005, 0x1904,
-	0x8046, 0x7030, 0x908e, 0x0400, 0x0904, 0x8046, 0x908e, 0x6000,
-	0x05e8, 0x908e, 0x5400, 0x05d0, 0x908e, 0x0300, 0x11d8, 0x2009,
-	0x1836, 0x210c, 0xd18c, 0x1590, 0xd1a4, 0x1580, 0x080c, 0x6624,
-	0x0558, 0x68ac, 0x9084, 0x00ff, 0x7100, 0x918c, 0x00ff, 0x9106,
-	0x1518, 0x687c, 0x69ac, 0x918c, 0xff00, 0x9105, 0x7104, 0x9106,
-	0x11d8, 0x00e0, 0x2009, 0x0103, 0x210c, 0xd1b4, 0x11a8, 0x908e,
-	0x5200, 0x09e8, 0x908e, 0x0500, 0x09d0, 0x908e, 0x5000, 0x09b8,
-	0x0058, 0x9186, 0x0023, 0x1140, 0x080c, 0x7f5c, 0x0128, 0x6004,
-	0x9086, 0x0002, 0x0118, 0x0000, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x00ce, 0x0005, 0x00f6, 0x2079, 0x0200, 0x7800, 0xc0e5, 0xc0cc,
-	0x7802, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x1800, 0x7834, 0xd084,
-	0x1130, 0x2079, 0x0200, 0x7800, 0x9085, 0x1200, 0x7802, 0x00fe,
-	0x0005, 0x00e6, 0x2071, 0x1800, 0x7034, 0xc084, 0x7036, 0x00ee,
-	0x0005, 0x2071, 0x19d3, 0x7003, 0x0003, 0x700f, 0x0361, 0x9006,
-	0x701a, 0x7072, 0x7012, 0x7017, 0x1ddc, 0x7007, 0x0000, 0x7026,
-	0x702b, 0x8fbc, 0x7032, 0x7037, 0x9039, 0x703f, 0xffff, 0x7042,
-	0x7047, 0x521f, 0x704a, 0x705b, 0x8205, 0x080c, 0x103b, 0x090c,
-	0x0d65, 0x2900, 0x703a, 0xa867, 0x0003, 0xa86f, 0x0100, 0xa8ab,
-	0xdcb0, 0x0005, 0x2071, 0x19d3, 0x1d04, 0x8127, 0x2091, 0x6000,
-	0x700c, 0x8001, 0x700e, 0x1560, 0x2001, 0x1875, 0x2004, 0xd0c4,
-	0x0158, 0x3a00, 0xd08c, 0x1140, 0x20d1, 0x0000, 0x20d1, 0x0001,
-	0x20d1, 0x0000, 0x080c, 0x0d65, 0x700f, 0x0361, 0x7007, 0x0001,
-	0x0126, 0x2091, 0x8000, 0x2069, 0x1800, 0x69e8, 0xd1e4, 0x1138,
-	0xd1dc, 0x1118, 0x080c, 0x8273, 0x0010, 0x080c, 0x824a, 0x7040,
-	0x900d, 0x0148, 0x8109, 0x7142, 0x1130, 0x7044, 0x080f, 0x0018,
-	0x0126, 0x2091, 0x8000, 0x7024, 0x900d, 0x0188, 0x7020, 0x8001,
-	0x7022, 0x1168, 0x7023, 0x0009, 0x8109, 0x7126, 0x9186, 0x03e8,
-	0x1110, 0x7028, 0x080f, 0x81ff, 0x1110, 0x7028, 0x080f, 0x7030,
-	0x900d, 0x0180, 0x702c, 0x8001, 0x702e, 0x1160, 0x702f, 0x0009,
-	0x8109, 0x7132, 0x0128, 0x9184, 0x007f, 0x090c, 0x90c1, 0x0010,
-	0x7034, 0x080f, 0x703c, 0x9005, 0x0118, 0x0310, 0x8001, 0x703e,
-	0x704c, 0x900d, 0x0168, 0x7048, 0x8001, 0x704a, 0x1148, 0x704b,
-	0x0009, 0x8109, 0x714e, 0x1120, 0x7150, 0x714e, 0x7058, 0x080f,
-	0x7018, 0x900d, 0x01d8, 0x0016, 0x7070, 0x900d, 0x0158, 0x706c,
-	0x8001, 0x706e, 0x1138, 0x706f, 0x0009, 0x8109, 0x7172, 0x1110,
-	0x7074, 0x080f, 0x001e, 0x7008, 0x8001, 0x700a, 0x1138, 0x700b,
-	0x0009, 0x8109, 0x711a, 0x1110, 0x701c, 0x080f, 0x012e, 0x7004,
-	0x0002, 0x814f, 0x8150, 0x817a, 0x00e6, 0x2071, 0x19d3, 0x7018,
-	0x9005, 0x1120, 0x711a, 0x721e, 0x700b, 0x0009, 0x00ee, 0x0005,
-	0x00e6, 0x0006, 0x2071, 0x19d3, 0x701c, 0x9206, 0x1120, 0x701a,
-	0x701e, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x00e6, 0x2071,
-	0x19d3, 0xb888, 0x9102, 0x0208, 0xb98a, 0x00ee, 0x0005, 0x0005,
-	0x00b6, 0x2031, 0x0010, 0x7110, 0x080c, 0x626b, 0x11a8, 0xb888,
-	0x8001, 0x0290, 0xb88a, 0x1180, 0x0126, 0x2091, 0x8000, 0x0066,
-	0xb8c0, 0x9005, 0x0138, 0x0026, 0xba3c, 0x0016, 0x080c, 0x6396,
-	0x001e, 0x002e, 0x006e, 0x012e, 0x8108, 0x9182, 0x0800, 0x1220,
-	0x8631, 0x0128, 0x7112, 0x0c00, 0x900e, 0x7007, 0x0002, 0x7112,
-	0x00be, 0x0005, 0x2031, 0x0010, 0x7014, 0x2060, 0x0126, 0x2091,
-	0x8000, 0x6048, 0x9005, 0x0128, 0x8001, 0x604a, 0x1110, 0x080c,
-	0xbb5c, 0x6018, 0x9005, 0x0904, 0x81cc, 0x00f6, 0x2079, 0x0300,
-	0x7918, 0xd1b4, 0x1904, 0x81df, 0x781b, 0x2020, 0xa001, 0x7918,
-	0xd1b4, 0x0120, 0x781b, 0x2000, 0x0804, 0x81df, 0x8001, 0x601a,
-	0x0106, 0x781b, 0x2000, 0xa001, 0x7918, 0xd1ac, 0x1dd0, 0x010e,
-	0x00fe, 0x1510, 0x6120, 0x9186, 0x0003, 0x0118, 0x9186, 0x0006,
-	0x11c8, 0x080c, 0xb842, 0x01b0, 0x6014, 0x2048, 0xa884, 0x908a,
-	0x199a, 0x0280, 0x9082, 0x1999, 0xa886, 0x908a, 0x199a, 0x0210,
-	0x2001, 0x1999, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0x080c,
-	0xbf8d, 0x0110, 0x080c, 0xb533, 0x012e, 0x9c88, 0x001c, 0x7116,
-	0x2001, 0x1819, 0x2004, 0x9102, 0x1228, 0x8631, 0x0138, 0x2160,
-	0x0804, 0x817e, 0x7017, 0x1ddc, 0x7007, 0x0000, 0x0005, 0x00fe,
-	0x0c58, 0x00e6, 0x2071, 0x19d3, 0x7027, 0x07d0, 0x7023, 0x0009,
-	0x00ee, 0x0005, 0x2001, 0x19dc, 0x2003, 0x0000, 0x0005, 0x00e6,
-	0x2071, 0x19d3, 0x7132, 0x702f, 0x0009, 0x00ee, 0x0005, 0x2011,
-	0x19df, 0x2013, 0x0000, 0x0005, 0x00e6, 0x2071, 0x19d3, 0x711a,
-	0x721e, 0x700b, 0x0009, 0x00ee, 0x0005, 0x0086, 0x0026, 0x7054,
-	0x8000, 0x7056, 0x2001, 0x19e1, 0x2044, 0xa06c, 0x9086, 0x0000,
-	0x0150, 0x7068, 0xa09a, 0x7064, 0xa096, 0x7060, 0xa092, 0x705c,
-	0xa08e, 0x080c, 0x1117, 0x002e, 0x008e, 0x0005, 0x0006, 0x0016,
-	0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0156,
-	0x080c, 0x8092, 0x015e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be,
-	0x00ae, 0x009e, 0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0x19d3,
-	0x7172, 0x7276, 0x706f, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006,
-	0x2071, 0x19d3, 0x7074, 0x9206, 0x1110, 0x7072, 0x7076, 0x000e,
-	0x00ee, 0x0005, 0x2069, 0x1800, 0x69e8, 0xd1e4, 0x1518, 0x0026,
-	0xd1ec, 0x0140, 0x6a50, 0x6870, 0x9202, 0x0288, 0x8117, 0x9294,
-	0x00c1, 0x0088, 0x9184, 0x0007, 0x01a0, 0x8109, 0x9184, 0x0007,
-	0x0110, 0x69ea, 0x0070, 0x8107, 0x9084, 0x0007, 0x910d, 0x8107,
-	0x9106, 0x9094, 0x00c1, 0x9184, 0xff3e, 0x9205, 0x68ea, 0x080c,
-	0x0eed, 0x002e, 0x0005, 0x69e4, 0x9184, 0x003f, 0x05b8, 0x8109,
-	0x9184, 0x003f, 0x01a8, 0x6a50, 0x6870, 0x9202, 0x0220, 0xd1bc,
-	0x0168, 0xc1bc, 0x0018, 0xd1bc, 0x1148, 0xc1bd, 0x2110, 0x00e6,
-	0x2071, 0x1800, 0x080c, 0x0f0f, 0x00ee, 0x0400, 0x69e6, 0x00f0,
-	0x0026, 0x8107, 0x9094, 0x0007, 0x0128, 0x8001, 0x8007, 0x9085,
-	0x0007, 0x0050, 0x2010, 0x8004, 0x8004, 0x8004, 0x9084, 0x0007,
-	0x9205, 0x8007, 0x9085, 0x0028, 0x9086, 0x0040, 0x2010, 0x00e6,
-	0x2071, 0x1800, 0x080c, 0x0f0f, 0x00ee, 0x002e, 0x0005, 0x00c6,
-	0x2061, 0x1a3e, 0x00ce, 0x0005, 0x9184, 0x000f, 0x8003, 0x8003,
-	0x8003, 0x9080, 0x1a3e, 0x2060, 0x0005, 0xa884, 0x908a, 0x199a,
-	0x1638, 0x9005, 0x1150, 0x00c6, 0x2061, 0x1a3e, 0x6014, 0x00ce,
-	0x9005, 0x1130, 0x2001, 0x001e, 0x0018, 0x908e, 0xffff, 0x01b0,
-	0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0xa87c, 0x908c, 0x00c0,
-	0x918e, 0x00c0, 0x0904, 0x8377, 0xd0b4, 0x1168, 0xd0bc, 0x1904,
-	0x8350, 0x2009, 0x0006, 0x080c, 0x83a4, 0x0005, 0x900e, 0x0c60,
-	0x2001, 0x1999, 0x08b0, 0xd0fc, 0x05e0, 0x908c, 0x2023, 0x1568,
-	0x87ff, 0x1558, 0xa9a8, 0x81ff, 0x1540, 0x6124, 0x918c, 0x0500,
-	0x1520, 0x6100, 0x918e, 0x0007, 0x1500, 0x2009, 0x1875, 0x210c,
-	0xd184, 0x11d8, 0x6003, 0x0003, 0x6007, 0x0043, 0x6047, 0xb035,
-	0x080c, 0x1ab2, 0xa87c, 0xc0dd, 0xa87e, 0x600f, 0x0000, 0x00f6,
-	0x2079, 0x0380, 0x7818, 0xd0bc, 0x1de8, 0x7833, 0x0013, 0x2c00,
-	0x7836, 0x781b, 0x8080, 0x00fe, 0x0005, 0x908c, 0x0003, 0x0120,
-	0x918e, 0x0003, 0x1904, 0x839e, 0x908c, 0x2020, 0x918e, 0x2020,
-	0x01a8, 0x6024, 0xd0d4, 0x11e8, 0x2009, 0x1875, 0x2104, 0xd084,
-	0x1138, 0x87ff, 0x1120, 0x2009, 0x0043, 0x0804, 0x9c76, 0x0005,
-	0x87ff, 0x1de8, 0x2009, 0x0042, 0x0804, 0x9c76, 0x6110, 0x00b6,
-	0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20, 0x6024, 0xc0cd, 0x6026,
-	0x0c00, 0xc0d4, 0x6026, 0xa890, 0x602e, 0xa88c, 0x6032, 0x08e0,
-	0xd0fc, 0x0160, 0x908c, 0x0003, 0x0120, 0x918e, 0x0003, 0x1904,
-	0x839e, 0x908c, 0x2020, 0x918e, 0x2020, 0x0170, 0x0076, 0x00f6,
-	0x2c78, 0x080c, 0x165c, 0x00fe, 0x007e, 0x87ff, 0x1120, 0x2009,
-	0x0042, 0x080c, 0x9c76, 0x0005, 0x6110, 0x00b6, 0x2158, 0xb900,
-	0x00be, 0xd1ac, 0x0d58, 0x6124, 0xc1cd, 0x6126, 0x0c38, 0xd0fc,
-	0x0188, 0x908c, 0x2020, 0x918e, 0x2020, 0x01a8, 0x9084, 0x0003,
-	0x908e, 0x0002, 0x0148, 0x87ff, 0x1120, 0x2009, 0x0041, 0x080c,
-	0x9c76, 0x0005, 0x00b9, 0x0ce8, 0x87ff, 0x1dd8, 0x2009, 0x0043,
-	0x080c, 0x9c76, 0x0cb0, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be,
-	0xd1ac, 0x0d20, 0x6124, 0xc1cd, 0x6126, 0x0c00, 0x2009, 0x0004,
-	0x0019, 0x0005, 0x2009, 0x0001, 0x0096, 0x080c, 0xb842, 0x0518,
-	0x6014, 0x2048, 0xa982, 0xa800, 0x6016, 0x9186, 0x0001, 0x1188,
-	0xa97c, 0x918c, 0x8100, 0x918e, 0x8100, 0x1158, 0x00c6, 0x2061,
-	0x1a3e, 0x6200, 0xd28c, 0x1120, 0x6204, 0x8210, 0x0208, 0x6206,
-	0x00ce, 0x080c, 0x67c6, 0x6014, 0x904d, 0x0076, 0x2039, 0x0000,
-	0x190c, 0x82bd, 0x007e, 0x009e, 0x0005, 0x0156, 0x00c6, 0x2061,
-	0x1a3e, 0x6000, 0x81ff, 0x0110, 0x9205, 0x0008, 0x9204, 0x6002,
-	0x00ce, 0x015e, 0x0005, 0x6800, 0xd08c, 0x1138, 0x6808, 0x9005,
-	0x0120, 0x8001, 0x680a, 0x9085, 0x0001, 0x0005, 0x0126, 0x2091,
-	0x8000, 0x0036, 0x0046, 0x20a9, 0x0010, 0x9006, 0x8004, 0x8086,
-	0x818e, 0x1208, 0x9200, 0x1f04, 0x83ef, 0x8086, 0x818e, 0x004e,
-	0x003e, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0076, 0x0156,
-	0x20a9, 0x0010, 0x9005, 0x01c8, 0x911a, 0x12b8, 0x8213, 0x818d,
-	0x0228, 0x911a, 0x1220, 0x1f04, 0x8406, 0x0028, 0x911a, 0x2308,
-	0x8210, 0x1f04, 0x8406, 0x0006, 0x3200, 0x9084, 0xefff, 0x2080,
-	0x000e, 0x015e, 0x007e, 0x012e, 0x0005, 0x0006, 0x3200, 0x9085,
-	0x1000, 0x0ca8, 0x0126, 0x2091, 0x2800, 0x2079, 0x19b7, 0x012e,
-	0x00d6, 0x2069, 0x19b7, 0x6803, 0x0005, 0x0156, 0x0146, 0x01d6,
-	0x20e9, 0x0000, 0x2069, 0x0200, 0x080c, 0x97e8, 0x04a9, 0x080c,
-	0x97d3, 0x0491, 0x080c, 0x97d6, 0x0479, 0x080c, 0x97d9, 0x0461,
-	0x080c, 0x97dc, 0x0449, 0x080c, 0x97df, 0x0431, 0x080c, 0x97e2,
-	0x0419, 0x080c, 0x97e5, 0x0401, 0x01de, 0x014e, 0x015e, 0x6857,
-	0x0000, 0x00f6, 0x2079, 0x0380, 0x00f9, 0x7807, 0x0003, 0x7803,
-	0x0000, 0x7803, 0x0001, 0x2069, 0x0004, 0x2d04, 0x9084, 0xfffe,
-	0x9085, 0x8000, 0x206a, 0x2069, 0x0100, 0x6828, 0x9084, 0xfffc,
-	0x682a, 0x00fe, 0x00de, 0x0005, 0x20a9, 0x0020, 0x20a1, 0x0240,
-	0x2001, 0x0000, 0x4004, 0x0005, 0x00c6, 0x7803, 0x0000, 0x9006,
-	0x7827, 0x0030, 0x782b, 0x0400, 0x7827, 0x0031, 0x782b, 0x1abe,
-	0x781f, 0xff00, 0x781b, 0xff00, 0x2061, 0x1ab3, 0x602f, 0x19b7,
-	0x6033, 0x1800, 0x6037, 0x19d3, 0x603b, 0x1d04, 0x603f, 0x1d14,
-	0x6042, 0x6047, 0x1a89, 0x00ce, 0x0005, 0x2001, 0x0382, 0x2004,
-	0x9084, 0x0007, 0x9086, 0x0001, 0x01b0, 0x00c6, 0x6146, 0x600f,
-	0x0000, 0x2c08, 0x2061, 0x19b7, 0x602c, 0x8000, 0x602e, 0x601c,
-	0x9005, 0x0130, 0x9080, 0x0003, 0x2102, 0x611e, 0x00ce, 0x0005,
-	0x6122, 0x611e, 0x0cd8, 0x6146, 0x2c08, 0x2001, 0x0012, 0x080c,
-	0x98ac, 0x0005, 0x0016, 0x2009, 0x8020, 0x6146, 0x2c08, 0x2001,
-	0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0001, 0x1128, 0x2001,
-	0x0019, 0x080c, 0x98ac, 0x0088, 0x00c6, 0x2061, 0x19b7, 0x602c,
-	0x8000, 0x602e, 0x600c, 0x9005, 0x0128, 0x9080, 0x0003, 0x2102,
-	0x610e, 0x0010, 0x6112, 0x610e, 0x00ce, 0x001e, 0x0005, 0x2001,
-	0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0001, 0x0198, 0x00c6,
-	0x6146, 0x600f, 0x0000, 0x2c08, 0x2061, 0x19b7, 0x6044, 0x9005,
-	0x0130, 0x9080, 0x0003, 0x2102, 0x6146, 0x00ce, 0x0005, 0x614a,
-	0x6146, 0x0cd8, 0x6146, 0x600f, 0x0000, 0x2c08, 0x2001, 0x0013,
-	0x080c, 0x98ac, 0x0005, 0x6044, 0xd0dc, 0x0110, 0x080c, 0x9485,
-	0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00b6, 0x0096, 0x0076,
-	0x0066, 0x0056, 0x0036, 0x0026, 0x0016, 0x0006, 0x0126, 0x902e,
-	0x2071, 0x19b7, 0x7648, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff,
-	0x0904, 0x8586, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x8581,
-	0x87ff, 0x0120, 0x605c, 0x9106, 0x1904, 0x8581, 0x704c, 0x9c06,
-	0x1178, 0x0036, 0x2019, 0x0001, 0x080c, 0x9269, 0x703f, 0x0000,
-	0x9006, 0x704e, 0x706a, 0x7052, 0x706e, 0x003e, 0x2029, 0x0001,
-	0x0811, 0x7048, 0x9c36, 0x1110, 0x660c, 0x764a, 0x7044, 0x9c36,
-	0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7046, 0x0010, 0x7047,
-	0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
-	0x2678, 0x600f, 0x0000, 0x080c, 0xb842, 0x01f0, 0x6014, 0x2048,
-	0x6020, 0x9086, 0x0003, 0x1588, 0x6004, 0x9086, 0x0040, 0x090c,
-	0x9485, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036,
-	0x0076, 0x080c, 0xbb45, 0x080c, 0xd52b, 0x080c, 0x6991, 0x007e,
-	0x003e, 0x001e, 0x080c, 0xba31, 0x080c, 0x9c14, 0x00ce, 0x0804,
-	0x851f, 0x2c78, 0x600c, 0x2060, 0x0804, 0x851f, 0x012e, 0x000e,
-	0x001e, 0x002e, 0x003e, 0x005e, 0x006e, 0x007e, 0x009e, 0x00be,
-	0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086, 0x0006,
-	0x1158, 0x0016, 0x0036, 0x0076, 0x080c, 0xd52b, 0x080c, 0xd22f,
-	0x007e, 0x003e, 0x001e, 0x08c0, 0x6020, 0x9086, 0x000a, 0x0918,
-	0x0804, 0x8564, 0x0006, 0x0066, 0x0096, 0x00c6, 0x00d6, 0x00f6,
-	0x9036, 0x0126, 0x2091, 0x8000, 0x2079, 0x19b7, 0x7848, 0x9065,
-	0x0904, 0x860e, 0x600c, 0x0006, 0x600f, 0x0000, 0x784c, 0x9c06,
-	0x11a0, 0x0036, 0x2019, 0x0001, 0x080c, 0x9269, 0x783f, 0x0000,
-	0x901e, 0x7b4e, 0x7b6a, 0x7b52, 0x7b6e, 0x003e, 0x000e, 0x9005,
-	0x1118, 0x600c, 0x600f, 0x0000, 0x0006, 0x00e6, 0x2f70, 0x080c,
-	0x8503, 0x00ee, 0x080c, 0xb842, 0x0548, 0x6014, 0x2048, 0x6020,
-	0x9086, 0x0003, 0x15a8, 0x3e08, 0x918e, 0x0002, 0x1188, 0x6010,
-	0x9005, 0x0170, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140,
-	0x6048, 0x9005, 0x11c0, 0x2001, 0x1958, 0x2004, 0x604a, 0x0098,
-	0x6004, 0x9086, 0x0040, 0x090c, 0x9485, 0xa867, 0x0103, 0xab7a,
-	0xa877, 0x0000, 0x080c, 0x6985, 0x080c, 0xba31, 0x6044, 0xc0fc,
-	0x6046, 0x080c, 0x9c14, 0x000e, 0x0804, 0x85b7, 0x7e4a, 0x7e46,
-	0x012e, 0x00fe, 0x00de, 0x00ce, 0x009e, 0x006e, 0x000e, 0x0005,
-	0x6020, 0x9086, 0x0006, 0x1118, 0x080c, 0xd22f, 0x0c38, 0x6020,
-	0x9086, 0x000a, 0x09e0, 0x08a0, 0x0016, 0x0026, 0x0086, 0x9046,
-	0x00a9, 0x080c, 0x8715, 0x008e, 0x002e, 0x001e, 0x0005, 0x00f6,
-	0x0126, 0x2079, 0x19b7, 0x2091, 0x8000, 0x080c, 0x875e, 0x080c,
-	0x87f2, 0x080c, 0x63f8, 0x012e, 0x00fe, 0x0005, 0x00b6, 0x0096,
-	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0016, 0x0006, 0x0126,
-	0x2091, 0x8000, 0x2071, 0x19b7, 0x7620, 0x2660, 0x2678, 0x8cff,
-	0x0904, 0x86da, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x86d5,
-	0x88ff, 0x0120, 0x605c, 0x9106, 0x1904, 0x86d5, 0x7030, 0x9c06,
-	0x1570, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508, 0x080c, 0x81ea,
-	0x080c, 0x8f9c, 0x68c3, 0x0000, 0x080c, 0x9485, 0x7033, 0x0000,
-	0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2852, 0x9006, 0x080c, 0x2852, 0x2069, 0x0100,
-	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x0040, 0x7008,
-	0xc0ad, 0x700a, 0x6003, 0x0009, 0x630a, 0x0804, 0x86d5, 0x7020,
-	0x9c36, 0x1110, 0x660c, 0x7622, 0x701c, 0x9c36, 0x1140, 0x2c00,
-	0x9f36, 0x0118, 0x2f00, 0x701e, 0x0010, 0x701f, 0x0000, 0x660c,
-	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
-	0x0000, 0x6044, 0xc0fc, 0x6046, 0x6014, 0x2048, 0x080c, 0xb842,
-	0x01e8, 0x6020, 0x9086, 0x0003, 0x1580, 0x080c, 0xba57, 0x1118,
-	0x080c, 0xa581, 0x0098, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000,
-	0x0016, 0x0036, 0x0086, 0x080c, 0xbb45, 0x080c, 0xd52b, 0x080c,
-	0x6991, 0x008e, 0x003e, 0x001e, 0x080c, 0xba31, 0x080c, 0x9c14,
-	0x080c, 0x935b, 0x00ce, 0x0804, 0x864f, 0x2c78, 0x600c, 0x2060,
-	0x0804, 0x864f, 0x012e, 0x000e, 0x001e, 0x006e, 0x00ce, 0x00de,
-	0x00ee, 0x00fe, 0x009e, 0x00be, 0x0005, 0x6020, 0x9086, 0x0006,
-	0x1158, 0x0016, 0x0036, 0x0086, 0x080c, 0xd52b, 0x080c, 0xd22f,
-	0x008e, 0x003e, 0x001e, 0x08d0, 0x080c, 0xa581, 0x6020, 0x9086,
-	0x0002, 0x1160, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0904,
-	0x86bb, 0x9086, 0x008b, 0x0904, 0x86bb, 0x0840, 0x6020, 0x9086,
-	0x0005, 0x1920, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x09c8,
-	0x9086, 0x008b, 0x09b0, 0x0804, 0x86ce, 0x0006, 0x00f6, 0x00e6,
-	0x0096, 0x00b6, 0x00c6, 0x0066, 0x0016, 0x0126, 0x2091, 0x8000,
-	0x9280, 0x1000, 0x2004, 0x905d, 0x2079, 0x19b7, 0x9036, 0x7828,
-	0x2060, 0x8cff, 0x0538, 0x6010, 0x9b06, 0x1500, 0x6043, 0xffff,
-	0x080c, 0x9a77, 0x01d8, 0x610c, 0x0016, 0x080c, 0x90f3, 0x6014,
-	0x2048, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036,
-	0x0086, 0x080c, 0xbb45, 0x080c, 0xd52b, 0x080c, 0x6991, 0x008e,
-	0x003e, 0x001e, 0x080c, 0x9c14, 0x00ce, 0x08d8, 0x2c30, 0x600c,
-	0x2060, 0x08b8, 0x080c, 0x6415, 0x012e, 0x001e, 0x006e, 0x00ce,
-	0x00be, 0x009e, 0x00ee, 0x00fe, 0x000e, 0x0005, 0x0096, 0x0006,
-	0x0066, 0x00c6, 0x00d6, 0x9036, 0x7820, 0x9065, 0x0904, 0x87c5,
-	0x600c, 0x0006, 0x6044, 0xc0fc, 0x6046, 0x600f, 0x0000, 0x7830,
-	0x9c06, 0x1588, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508, 0x080c,
-	0x81ea, 0x080c, 0x8f9c, 0x68c3, 0x0000, 0x080c, 0x9485, 0x7833,
-	0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
-	0x2001, 0x0100, 0x080c, 0x2852, 0x9006, 0x080c, 0x2852, 0x2069,
-	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x0058,
-	0x080c, 0x661c, 0x1538, 0x6003, 0x0009, 0x630a, 0x7808, 0xc0ad,
-	0x780a, 0x2c30, 0x00f8, 0x6014, 0x2048, 0x080c, 0xb840, 0x01b0,
-	0x6020, 0x9086, 0x0003, 0x1508, 0x080c, 0xba57, 0x1118, 0x080c,
-	0xa581, 0x0060, 0x080c, 0x661c, 0x1168, 0xa867, 0x0103, 0xab7a,
-	0xa877, 0x0000, 0x080c, 0x6991, 0x080c, 0xba31, 0x080c, 0x9c14,
-	0x080c, 0x935b, 0x000e, 0x0804, 0x8765, 0x7e22, 0x7e1e, 0x00de,
-	0x00ce, 0x006e, 0x000e, 0x009e, 0x0005, 0x6020, 0x9086, 0x0006,
-	0x1118, 0x080c, 0xd22f, 0x0c50, 0x080c, 0xa581, 0x6020, 0x9086,
-	0x0002, 0x1150, 0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0990,
-	0x9086, 0x008b, 0x0978, 0x08d0, 0x6020, 0x9086, 0x0005, 0x19b0,
-	0x6004, 0x0006, 0x9086, 0x0085, 0x000e, 0x0d18, 0x9086, 0x008b,
-	0x0d00, 0x0860, 0x0006, 0x0096, 0x00b6, 0x00c6, 0x0066, 0x9036,
-	0x7828, 0x9065, 0x0510, 0x6010, 0x2058, 0x600c, 0x0006, 0x3e08,
-	0x918e, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x11a8, 0x6043, 0xffff,
-	0x080c, 0x9a77, 0x0180, 0x610c, 0x080c, 0x90f3, 0x6014, 0x2048,
-	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6991, 0x080c,
-	0x9c14, 0x000e, 0x08f0, 0x2c30, 0x0ce0, 0x006e, 0x00ce, 0x00be,
-	0x009e, 0x000e, 0x0005, 0x00e6, 0x00d6, 0x0096, 0x0066, 0x080c,
-	0x5dd1, 0x11b0, 0x2071, 0x19b7, 0x7030, 0x9080, 0x0005, 0x2004,
-	0x904d, 0x0170, 0xa878, 0x9606, 0x1158, 0x2071, 0x19b7, 0x7030,
-	0x9035, 0x0130, 0x9080, 0x0005, 0x2004, 0x9906, 0x1108, 0x0029,
-	0x006e, 0x009e, 0x00de, 0x00ee, 0x0005, 0x00c6, 0x2660, 0x6043,
-	0xffff, 0x080c, 0x9a77, 0x0178, 0x080c, 0x90f3, 0x6014, 0x2048,
-	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0xbb45, 0x080c,
-	0x6991, 0x080c, 0x9c14, 0x00ce, 0x0005, 0x00b6, 0x00e6, 0x00c6,
-	0x080c, 0x98bb, 0x0106, 0x2071, 0x0101, 0x2e04, 0xc0c4, 0x2072,
-	0x6044, 0xd0fc, 0x1138, 0x010e, 0x090c, 0x98d7, 0x00ce, 0x00ee,
-	0x00be, 0x0005, 0x2071, 0x19b7, 0x7030, 0x9005, 0x0da0, 0x9c06,
-	0x190c, 0x0d65, 0x7036, 0x080c, 0x81ea, 0x7004, 0x9084, 0x0007,
-	0x0002, 0x888b, 0x888d, 0x8894, 0x889e, 0x88ac, 0x888b, 0x8899,
-	0x8889, 0x080c, 0x0d65, 0x0428, 0x0005, 0x080c, 0x9a62, 0x7007,
-	0x0000, 0x7033, 0x0000, 0x00e8, 0x0066, 0x9036, 0x080c, 0x90f3,
-	0x006e, 0x7007, 0x0000, 0x7033, 0x0000, 0x0098, 0x080c, 0x9a4d,
-	0x0140, 0x080c, 0x9a62, 0x0128, 0x0066, 0x9036, 0x080c, 0x90f3,
-	0x006e, 0x7033, 0x0000, 0x0028, 0x080c, 0x9a4d, 0x080c, 0x9485,
-	0x0000, 0x010e, 0x190c, 0x98d7, 0x00ce, 0x00ee, 0x00be, 0x0005,
-	0x00d6, 0x00c6, 0x080c, 0x98bb, 0x0106, 0x6044, 0xd0fc, 0x1130,
-	0x010e, 0x090c, 0x98d7, 0x00ce, 0x00de, 0x0005, 0x2069, 0x19b7,
-	0x684c, 0x9005, 0x0da8, 0x9c06, 0x190c, 0x0d65, 0x6852, 0x00e6,
-	0x2d70, 0x080c, 0x8503, 0x00ee, 0x080c, 0x81f7, 0x0016, 0x2009,
-	0x0040, 0x080c, 0x2063, 0x001e, 0x683c, 0x9084, 0x0003, 0x0002,
-	0x88e6, 0x88e7, 0x8905, 0x88e4, 0x080c, 0x0d65, 0x0460, 0x6868,
-	0x9086, 0x0001, 0x0190, 0x600c, 0x9015, 0x0160, 0x6a4a, 0x600f,
-	0x0000, 0x6044, 0xc0fc, 0x6046, 0x9006, 0x7042, 0x684e, 0x683f,
-	0x0000, 0x00c8, 0x684a, 0x6846, 0x0ca0, 0x686b, 0x0000, 0x6848,
-	0x9065, 0x0d78, 0x6003, 0x0002, 0x0c60, 0x9006, 0x686a, 0x6852,
-	0x686e, 0x600c, 0x9015, 0x0120, 0x6a4a, 0x600f, 0x0000, 0x0018,
-	0x684e, 0x684a, 0x6846, 0x684f, 0x0000, 0x010e, 0x190c, 0x98d7,
-	0x00ce, 0x00de, 0x0005, 0x0005, 0x6020, 0x9084, 0x000f, 0x000b,
-	0x0005, 0x8931, 0x8934, 0x8d8d, 0x8e1c, 0x8934, 0x8d8d, 0x8e1c,
-	0x8931, 0x8934, 0x8931, 0x8931, 0x8931, 0x8931, 0x8931, 0x8931,
-	0x8931, 0x080c, 0x885d, 0x0005, 0x00b6, 0x0156, 0x0136, 0x0146,
-	0x01c6, 0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2069, 0x0200,
-	0x2071, 0x0240, 0x6004, 0x908a, 0x0053, 0x1a0c, 0x0d65, 0x6110,
-	0x2158, 0xb984, 0x2c78, 0x2061, 0x0100, 0x619a, 0x908a, 0x0040,
-	0x1a04, 0x89a0, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de,
-	0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0x8b17, 0x8b52,
-	0x8b7b, 0x8c1e, 0x8c3f, 0x8c45, 0x8c52, 0x8c5a, 0x8c66, 0x8c6c,
-	0x8c7d, 0x8c6c, 0x8cd4, 0x8c5a, 0x8ce0, 0x8ce6, 0x8c66, 0x8ce6,
-	0x8cf2, 0x899e, 0x899e, 0x899e, 0x899e, 0x899e, 0x899e, 0x899e,
-	0x899e, 0x899e, 0x899e, 0x899e, 0x9114, 0x9137, 0x9148, 0x9168,
-	0x919a, 0x8c52, 0x899e, 0x8c52, 0x8c6c, 0x899e, 0x8b7b, 0x8c1e,
-	0x899e, 0x9583, 0x8c6c, 0x899e, 0x959f, 0x8c6c, 0x899e, 0x8c66,
-	0x8b11, 0x89c1, 0x899e, 0x95bb, 0x9628, 0x9708, 0x899e, 0x9715,
-	0x8c4f, 0x9740, 0x899e, 0x91a4, 0x974c, 0x899e, 0x080c, 0x0d65,
-	0x2100, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de, 0x01ce,
-	0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0x89bf, 0x89bf, 0x89bf,
-	0x89e8, 0x8a94, 0x8a9f, 0x89bf, 0x89bf, 0x89bf, 0x8ae6, 0x8af2,
-	0x8a03, 0x89bf, 0x8a1e, 0x8a52, 0x9acd, 0x9b12, 0x8c6c, 0x080c,
-	0x0d65, 0x00d6, 0x0096, 0x080c, 0x8d05, 0x7003, 0x2414, 0x7007,
-	0x0018, 0x700b, 0x0800, 0x7814, 0x2048, 0xa83c, 0x700e, 0xa850,
-	0x7022, 0xa854, 0x7026, 0x60c3, 0x0018, 0x080c, 0x8f6c, 0x009e,
-	0x00de, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x080c,
-	0x9b59, 0x1118, 0x9084, 0xff80, 0x0110, 0x9085, 0x0001, 0x0005,
-	0x00d6, 0x0096, 0x080c, 0x8d05, 0x7003, 0x0500, 0x7814, 0x2048,
-	0xa874, 0x700a, 0xa878, 0x700e, 0xa87c, 0x7012, 0xa880, 0x7016,
-	0xa884, 0x701a, 0xa888, 0x701e, 0x60c3, 0x0010, 0x080c, 0x8f6c,
-	0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x080c, 0x8d05, 0x7003,
-	0x0500, 0x7814, 0x2048, 0xa8cc, 0x700a, 0xa8d0, 0x700e, 0xa8d4,
-	0x7012, 0xa8d8, 0x7016, 0xa8dc, 0x701a, 0xa8e0, 0x701e, 0x60c3,
-	0x0010, 0x080c, 0x8f6c, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x8d05, 0x20e9, 0x0000, 0x2001,
-	0x1973, 0x2003, 0x0000, 0x7814, 0x2048, 0xa814, 0x8003, 0x60c2,
-	0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098,
-	0x2001, 0x1973, 0x0016, 0x200c, 0x2001, 0x0001, 0x080c, 0x2048,
-	0x080c, 0xc59f, 0x9006, 0x080c, 0x2048, 0x001e, 0xa804, 0x9005,
-	0x0110, 0x2048, 0x0c28, 0x04d9, 0x080c, 0x8f6c, 0x012e, 0x009e,
+	0x908a, 0x001a, 0x1210, 0x002b, 0x0c50, 0x00e9, 0x080c, 0x79c6,
+	0x0005, 0x7523, 0x752f, 0x7719, 0x7523, 0x752f, 0x7523, 0x752f,
+	0x752f, 0x7523, 0x752f, 0x7719, 0x752f, 0x752f, 0x752f, 0x752f,
+	0x752f, 0x7523, 0x752f, 0x7719, 0x7523, 0x7523, 0x752f, 0x7523,
+	0x7523, 0x7523, 0x752f, 0x00e6, 0x2071, 0x18f8, 0x2009, 0x0400,
+	0x0071, 0x00ee, 0x0005, 0x2009, 0x1000, 0x0049, 0x0005, 0x2009,
+	0x2000, 0x0029, 0x0005, 0x2009, 0x0800, 0x0009, 0x0005, 0x7007,
+	0x0001, 0xa868, 0x9084, 0x00ff, 0x9105, 0xa86a, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x69b5, 0x012e, 0x0005, 0xa864, 0x8007, 0x9084,
+	0x00ff, 0x0d08, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x76d7,
+	0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x76d7,
+	0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0968, 0x8001, 0x1120,
+	0x7007, 0x0001, 0x0804, 0x76f2, 0x7007, 0x0003, 0x7012, 0x2900,
+	0x7016, 0x701a, 0x704b, 0x76f2, 0x0005, 0xa864, 0x8007, 0x9084,
+	0x00ff, 0x9086, 0x0001, 0x1904, 0x752b, 0x7007, 0x0001, 0x2009,
+	0x1833, 0x210c, 0x81ff, 0x1904, 0x75cf, 0xa994, 0x9186, 0x006f,
+	0x0188, 0x9186, 0x0074, 0x15b0, 0x0026, 0x2011, 0x0010, 0x080c,
+	0x66ae, 0x002e, 0x0578, 0x0016, 0xa998, 0x080c, 0x66f8, 0x001e,
+	0x1548, 0x0400, 0x080c, 0x70ba, 0x0140, 0xa897, 0x4005, 0xa89b,
+	0x0016, 0x2001, 0x0030, 0x900e, 0x0438, 0x0026, 0x2011, 0x8008,
+	0x080c, 0x66ae, 0x002e, 0x01b0, 0x0016, 0x0026, 0x0036, 0xa998,
+	0xaaa0, 0xab9c, 0x918d, 0x8000, 0x080c, 0x66f8, 0x003e, 0x002e,
+	0x001e, 0x1140, 0xa897, 0x4005, 0xa89b, 0x4009, 0x2001, 0x0030,
+	0x900e, 0x0050, 0xa868, 0x9084, 0x00ff, 0xa86a, 0xa883, 0x0000,
+	0x080c, 0x5f22, 0x1108, 0x0005, 0x0126, 0x2091, 0x8000, 0xa867,
+	0x0139, 0xa87a, 0xa982, 0x080c, 0x69b5, 0x012e, 0x0ca0, 0xa994,
+	0x9186, 0x0071, 0x0904, 0x757d, 0x9186, 0x0064, 0x0904, 0x757d,
+	0x9186, 0x007c, 0x0904, 0x757d, 0x9186, 0x0028, 0x0904, 0x757d,
+	0x9186, 0x0038, 0x0904, 0x757d, 0x9186, 0x0078, 0x0904, 0x757d,
+	0x9186, 0x005f, 0x0904, 0x757d, 0x9186, 0x0056, 0x0904, 0x757d,
+	0xa897, 0x4005, 0xa89b, 0x0001, 0x2001, 0x0030, 0x900e, 0x0860,
+	0xa87c, 0x9084, 0x00c0, 0x9086, 0x00c0, 0x1120, 0x7007, 0x0001,
+	0x0804, 0x78e7, 0x2900, 0x7016, 0x701a, 0x20a9, 0x0004, 0xa860,
+	0x20e0, 0xa85c, 0x9080, 0x0030, 0x2098, 0x7050, 0x2040, 0xa060,
+	0x20e8, 0xa05c, 0x9080, 0x0023, 0x20a0, 0x4003, 0xa888, 0x7012,
+	0x9082, 0x0401, 0x1a04, 0x7533, 0xaab4, 0x928a, 0x0002, 0x1a04,
+	0x7533, 0x82ff, 0x1138, 0xa8b8, 0xa9bc, 0x9105, 0x0118, 0x2001,
+	0x7695, 0x0018, 0x9280, 0x768b, 0x2005, 0x7056, 0x7010, 0x9015,
+	0x0904, 0x7676, 0x080c, 0x1048, 0x1118, 0x7007, 0x0004, 0x0005,
+	0x2900, 0x7022, 0x7054, 0x2060, 0xe000, 0xa866, 0x7050, 0x2040,
+	0xa95c, 0xe004, 0x9100, 0xa076, 0xa860, 0xa072, 0xe008, 0x920a,
+	0x1210, 0x900e, 0x2200, 0x7112, 0xe20c, 0x8003, 0x800b, 0x9296,
+	0x0004, 0x0108, 0x9108, 0xa17a, 0x810b, 0xa17e, 0x080c, 0x1124,
+	0xa06c, 0x908e, 0x0100, 0x0170, 0x9086, 0x0200, 0x0118, 0x7007,
+	0x0007, 0x0005, 0x7020, 0x2048, 0x080c, 0x1061, 0x7014, 0x2048,
+	0x0804, 0x7533, 0x7020, 0x2048, 0x7018, 0xa802, 0xa807, 0x0000,
+	0x2908, 0x2048, 0xa906, 0x711a, 0x0804, 0x762e, 0x7014, 0x2048,
+	0x7007, 0x0001, 0xa8b4, 0x9005, 0x1128, 0xa8b8, 0xa9bc, 0x9105,
+	0x0108, 0x00b9, 0xa864, 0x9084, 0x00ff, 0x9086, 0x001e, 0x0904,
+	0x78e7, 0x0804, 0x76d7, 0x768d, 0x7691, 0x0002, 0x001d, 0x0007,
+	0x0004, 0x000a, 0x001b, 0x0005, 0x0006, 0x000a, 0x001d, 0x0005,
+	0x0004, 0x0076, 0x0066, 0xafb8, 0xaebc, 0xa804, 0x2050, 0xb0c0,
+	0xb0e2, 0xb0bc, 0xb0de, 0xb0b8, 0xb0d2, 0xb0b4, 0xb0ce, 0xb6da,
+	0xb7d6, 0xb0b0, 0xb0ca, 0xb0ac, 0xb0c6, 0xb0a8, 0xb0ba, 0xb0a4,
+	0xb0b6, 0xb6c2, 0xb7be, 0xb0a0, 0xb0b2, 0xb09c, 0xb0ae, 0xb098,
+	0xb0a2, 0xb094, 0xb09e, 0xb6aa, 0xb7a6, 0xb090, 0xb09a, 0xb08c,
+	0xb096, 0xb088, 0xb08a, 0xb084, 0xb086, 0xb692, 0xb78e, 0xb080,
+	0xb082, 0xb07c, 0xb07e, 0xb078, 0xb072, 0xb074, 0xb06e, 0xb67a,
+	0xb776, 0xb004, 0x9055, 0x1958, 0x006e, 0x007e, 0x0005, 0x2009,
+	0x1833, 0x210c, 0x81ff, 0x1178, 0x080c, 0x5d71, 0x1108, 0x0005,
+	0x080c, 0x6bc6, 0x0126, 0x2091, 0x8000, 0x080c, 0xbb73, 0x080c,
+	0x69b5, 0x012e, 0x0ca0, 0x080c, 0xbf88, 0x1d70, 0x2001, 0x0028,
+	0x900e, 0x0c70, 0x2009, 0x1833, 0x210c, 0x81ff, 0x11d8, 0xa888,
+	0x9005, 0x01e0, 0xa883, 0x0000, 0xa87c, 0xd0f4, 0x0120, 0x080c,
+	0x5e84, 0x1138, 0x0005, 0x9006, 0xa87a, 0x080c, 0x5dff, 0x1108,
+	0x0005, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982, 0x080c, 0x69b5,
+	0x012e, 0x0cb0, 0x2001, 0x0028, 0x900e, 0x0c98, 0x2001, 0x0000,
+	0x0c80, 0x7018, 0xa802, 0x2908, 0x2048, 0xa906, 0x711a, 0x7010,
+	0x8001, 0x7012, 0x0118, 0x7007, 0x0003, 0x0030, 0x7014, 0x2048,
+	0x7007, 0x0001, 0x7048, 0x080f, 0x0005, 0x00b6, 0x7007, 0x0001,
+	0xa974, 0xa878, 0x9084, 0x00ff, 0x9096, 0x0004, 0x0540, 0x20a9,
+	0x0001, 0x9096, 0x0001, 0x0190, 0x900e, 0x20a9, 0x0800, 0x9096,
+	0x0002, 0x0160, 0x9005, 0x11d8, 0xa974, 0x080c, 0x628f, 0x11b8,
+	0x0066, 0xae80, 0x080c, 0x639f, 0x006e, 0x0088, 0x0046, 0x2011,
+	0x180c, 0x2224, 0xc484, 0x2412, 0x004e, 0x00c6, 0x080c, 0x628f,
+	0x1110, 0x080c, 0x6572, 0x8108, 0x1f04, 0x7756, 0x00ce, 0xa87c,
+	0xd084, 0x1120, 0x080c, 0x1061, 0x00be, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x69b5, 0x012e, 0x00be, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x7007, 0x0001, 0x080c, 0x6686, 0x0580, 0x2061, 0x1a46,
+	0x6100, 0xd184, 0x0178, 0xa888, 0x9084, 0x00ff, 0x1550, 0x6000,
+	0xd084, 0x0520, 0x6004, 0x9005, 0x1538, 0x6003, 0x0000, 0x600b,
+	0x0000, 0x00c8, 0x2011, 0x0001, 0xa890, 0x9005, 0x1110, 0x2001,
+	0x001e, 0x8000, 0x6016, 0xa888, 0x9084, 0x00ff, 0x0178, 0x6006,
+	0xa888, 0x8007, 0x9084, 0x00ff, 0x0148, 0x600a, 0xa888, 0x8000,
+	0x1108, 0xc28d, 0x6202, 0x012e, 0x0804, 0x79b0, 0x012e, 0x0804,
+	0x79aa, 0x012e, 0x0804, 0x79a4, 0x012e, 0x0804, 0x79a7, 0x0126,
+	0x2091, 0x8000, 0x7007, 0x0001, 0x080c, 0x6686, 0x05e0, 0x2061,
+	0x1a46, 0x6000, 0xd084, 0x05b8, 0x6204, 0x6308, 0xd08c, 0x1530,
+	0xac78, 0x9484, 0x0003, 0x0170, 0xa988, 0x918c, 0x00ff, 0x8001,
+	0x1120, 0x2100, 0x9210, 0x0620, 0x0028, 0x8001, 0x1508, 0x2100,
+	0x9212, 0x02f0, 0x9484, 0x000c, 0x0188, 0xa988, 0x810f, 0x918c,
+	0x00ff, 0x9082, 0x0004, 0x1120, 0x2100, 0x9318, 0x0288, 0x0030,
+	0x9082, 0x0004, 0x1168, 0x2100, 0x931a, 0x0250, 0xa890, 0x9005,
+	0x0110, 0x8000, 0x6016, 0x6206, 0x630a, 0x012e, 0x0804, 0x79b0,
+	0x012e, 0x0804, 0x79ad, 0x012e, 0x0804, 0x79aa, 0x0126, 0x2091,
+	0x8000, 0x7007, 0x0001, 0x2061, 0x1a46, 0x6300, 0xd38c, 0x1120,
+	0x6308, 0x8318, 0x0220, 0x630a, 0x012e, 0x0804, 0x79be, 0x012e,
+	0x0804, 0x79ad, 0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x7007,
+	0x0001, 0xa87c, 0xd0ac, 0x0148, 0x00c6, 0x2061, 0x1a46, 0x6000,
+	0x9084, 0xfcff, 0x6002, 0x00ce, 0x0440, 0xa888, 0x9005, 0x05d8,
+	0xa88c, 0x9065, 0x0598, 0x2001, 0x1833, 0x2004, 0x9005, 0x0118,
+	0x080c, 0x9c20, 0x0068, 0x6017, 0xf400, 0x6063, 0x0000, 0xa97c,
+	0xd1a4, 0x0110, 0xa980, 0x6162, 0x2009, 0x0041, 0x080c, 0x9c82,
+	0xa988, 0x918c, 0xff00, 0x9186, 0x2000, 0x1138, 0x0026, 0x900e,
+	0x2011, 0xfdff, 0x080c, 0x8401, 0x002e, 0xa87c, 0xd0c4, 0x0148,
+	0x2061, 0x1a46, 0x6000, 0xd08c, 0x1120, 0x6008, 0x8000, 0x0208,
+	0x600a, 0x00ce, 0x012e, 0x00be, 0x0804, 0x79b0, 0x00ce, 0x012e,
+	0x00be, 0x0804, 0x79aa, 0xa984, 0x9186, 0x002e, 0x0d30, 0x9186,
+	0x002d, 0x0d18, 0x9186, 0x0045, 0x0510, 0x9186, 0x002a, 0x1130,
+	0x2001, 0x180c, 0x200c, 0xc194, 0x2102, 0x08b8, 0x9186, 0x0020,
+	0x0158, 0x9186, 0x0029, 0x1d10, 0xa974, 0x080c, 0x628f, 0x1968,
+	0xb800, 0xc0e4, 0xb802, 0x0848, 0xa88c, 0x9065, 0x09b8, 0x6007,
+	0x0024, 0x2001, 0x195e, 0x2004, 0x601a, 0x0804, 0x7845, 0xa88c,
+	0x9065, 0x0960, 0x00e6, 0xa890, 0x9075, 0x2001, 0x1833, 0x2004,
+	0x9005, 0x0150, 0x080c, 0x9c20, 0x8eff, 0x0118, 0x2e60, 0x080c,
+	0x9c20, 0x00ee, 0x0804, 0x7845, 0x6024, 0xc0dc, 0xc0d5, 0x6026,
+	0x2e60, 0x6007, 0x003a, 0xa8a0, 0x9005, 0x0130, 0x6007, 0x003b,
+	0xa8a4, 0x602e, 0xa8a8, 0x6016, 0x6003, 0x0001, 0x2009, 0x8020,
+	0x080c, 0x84e7, 0x00ee, 0x0804, 0x7845, 0x2061, 0x1a46, 0x6000,
+	0xd084, 0x0190, 0xd08c, 0x1904, 0x79be, 0x0126, 0x2091, 0x8000,
+	0x6204, 0x8210, 0x0220, 0x6206, 0x012e, 0x0804, 0x79be, 0x012e,
+	0xa883, 0x0016, 0x0804, 0x79b7, 0xa883, 0x0007, 0x0804, 0x79b7,
+	0xa864, 0x8007, 0x9084, 0x00ff, 0x0130, 0x8001, 0x1138, 0x7007,
+	0x0001, 0x0069, 0x0005, 0x080c, 0x752b, 0x0040, 0x7007, 0x0003,
+	0x7012, 0x2900, 0x7016, 0x701a, 0x704b, 0x78e7, 0x0005, 0x00b6,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x903e, 0x2061, 0x1800, 0x61cc,
+	0x81ff, 0x1904, 0x7969, 0x6130, 0xd194, 0x1904, 0x7993, 0xa878,
+	0x2070, 0x9e82, 0x1ddc, 0x0a04, 0x795d, 0x6064, 0x9e02, 0x1a04,
+	0x795d, 0x7120, 0x9186, 0x0006, 0x1904, 0x794f, 0x7010, 0x905d,
+	0x0904, 0x7969, 0xb800, 0xd0e4, 0x1904, 0x798d, 0x2061, 0x1a46,
+	0x6100, 0x9184, 0x0301, 0x9086, 0x0001, 0x15a0, 0x7024, 0xd0dc,
+	0x1904, 0x7996, 0xa883, 0x0000, 0xa803, 0x0000, 0x2908, 0x7014,
+	0x9005, 0x1198, 0x7116, 0xa87c, 0xd0f4, 0x1904, 0x7999, 0x080c,
+	0x53a8, 0xd09c, 0x1118, 0xa87c, 0xc0cc, 0xa87e, 0x2e60, 0x080c,
+	0x82f1, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2048, 0xa800, 0x9005,
+	0x1de0, 0xa902, 0x2148, 0xa87c, 0xd0f4, 0x1904, 0x7999, 0x012e,
+	0x00ee, 0x00be, 0x0005, 0x012e, 0x00ee, 0xa883, 0x0006, 0x00be,
+	0x0804, 0x79b7, 0xd184, 0x0db8, 0xd1c4, 0x1190, 0x00a0, 0xa974,
+	0x080c, 0x628f, 0x15d0, 0xb800, 0xd0e4, 0x15b8, 0x7120, 0x9186,
+	0x0007, 0x1118, 0xa883, 0x0002, 0x0490, 0xa883, 0x0008, 0x0478,
+	0xa883, 0x000e, 0x0460, 0xa883, 0x0017, 0x0448, 0xa883, 0x0035,
+	0x0430, 0x080c, 0x53ac, 0xd0fc, 0x01e8, 0xa878, 0x2070, 0x9e82,
+	0x1ddc, 0x02c0, 0x6064, 0x9e02, 0x12a8, 0x7120, 0x9186, 0x0006,
+	0x1188, 0x7010, 0x905d, 0x0170, 0xb800, 0xd0bc, 0x0158, 0x2039,
+	0x0001, 0x7000, 0x9086, 0x0007, 0x1904, 0x78f3, 0x7003, 0x0002,
+	0x0804, 0x78f3, 0xa883, 0x0028, 0x0010, 0xa883, 0x0029, 0x012e,
+	0x00ee, 0x00be, 0x0420, 0xa883, 0x002a, 0x0cc8, 0xa883, 0x0045,
+	0x0cb0, 0x2e60, 0x2019, 0x0002, 0x601b, 0x0014, 0x080c, 0xce41,
+	0x012e, 0x00ee, 0x00be, 0x0005, 0x2009, 0x003e, 0x0058, 0x2009,
+	0x0004, 0x0040, 0x2009, 0x0006, 0x0028, 0x2009, 0x0016, 0x0010,
+	0x2009, 0x0001, 0xa884, 0x9084, 0xff00, 0x9105, 0xa886, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x69b5, 0x012e, 0x0005, 0x080c, 0x1061,
+	0x0005, 0x00d6, 0x080c, 0x82e8, 0x00de, 0x0005, 0x00d6, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x0040, 0x702c, 0xd084, 0x01d8,
+	0x908c, 0x0780, 0x190c, 0x7a52, 0xd09c, 0x11a8, 0x2071, 0x1800,
+	0x70bc, 0x90ea, 0x0040, 0x0278, 0x8001, 0x70be, 0x702c, 0x2048,
+	0xa800, 0x702e, 0x9006, 0xa802, 0xa806, 0x2071, 0x0040, 0x2900,
+	0x7022, 0x702c, 0x0c28, 0x012e, 0x00ee, 0x00de, 0x0005, 0x0006,
+	0x9084, 0x0780, 0x190c, 0x7a52, 0x000e, 0x0005, 0x00d6, 0x00c6,
+	0x0036, 0x0026, 0x0016, 0x00b6, 0x7007, 0x0001, 0xaa74, 0x9282,
+	0x0004, 0x1a04, 0x7a43, 0xa97c, 0x9188, 0x1000, 0x2104, 0x905d,
+	0xb804, 0xd284, 0x0140, 0x05e8, 0x8007, 0x9084, 0x00ff, 0x9084,
+	0x0006, 0x1108, 0x04b0, 0x2b10, 0x080c, 0x9b90, 0x1118, 0x080c,
+	0x9c55, 0x05a8, 0x6212, 0xa874, 0x0002, 0x7a21, 0x7a26, 0x7a29,
+	0x7a2f, 0x2019, 0x0002, 0x080c, 0xd234, 0x0060, 0x080c, 0xd1c4,
+	0x0048, 0x2019, 0x0002, 0xa980, 0x080c, 0xd1e3, 0x0018, 0xa980,
+	0x080c, 0xd1c4, 0x080c, 0x9be6, 0xa887, 0x0000, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x69b5, 0x012e, 0x00be, 0x001e, 0x002e, 0x003e,
+	0x00ce, 0x00de, 0x0005, 0xa887, 0x0006, 0x0c80, 0xa887, 0x0002,
+	0x0c68, 0xa887, 0x0005, 0x0c50, 0xa887, 0x0004, 0x0c38, 0xa887,
+	0x0007, 0x0c20, 0x2091, 0x8000, 0x0e04, 0x7a54, 0x0006, 0x0016,
+	0x2001, 0x8003, 0x0006, 0x0804, 0x0d6e, 0x2001, 0x1833, 0x2004,
+	0x9005, 0x0005, 0x0005, 0x00f6, 0x2079, 0x0300, 0x2001, 0x0200,
+	0x200c, 0xc1e5, 0xc1dc, 0x2102, 0x2009, 0x0218, 0x210c, 0xd1ec,
+	0x1120, 0x080c, 0x1547, 0x00fe, 0x0005, 0x2001, 0x020d, 0x2003,
+	0x0020, 0x781f, 0x0300, 0x00fe, 0x0005, 0x781c, 0xd08c, 0x0904,
+	0x7ad5, 0x68bc, 0x90aa, 0x0005, 0x0a04, 0x807e, 0x7d44, 0x7c40,
+	0xd59c, 0x190c, 0x0d65, 0x9584, 0x00f6, 0x1508, 0x9484, 0x7000,
+	0x0138, 0x908a, 0x2000, 0x1258, 0x9584, 0x0700, 0x8007, 0x04f0,
+	0x7000, 0x9084, 0xff00, 0x9086, 0x8100, 0x0db0, 0x00b0, 0x9484,
+	0x0fff, 0x1130, 0x7000, 0x9084, 0xff00, 0x9086, 0x8100, 0x11c0,
+	0x080c, 0xd61c, 0x080c, 0x7fb5, 0x7817, 0x0140, 0x00a8, 0x9584,
+	0x0076, 0x1118, 0x080c, 0x8011, 0x19c8, 0xd5a4, 0x0148, 0x0046,
+	0x0056, 0x080c, 0x7b25, 0x080c, 0x1fe0, 0x005e, 0x004e, 0x0020,
+	0x080c, 0xd61c, 0x7817, 0x0140, 0x080c, 0x70ba, 0x0168, 0x2001,
+	0x0111, 0x2004, 0xd08c, 0x0140, 0x688f, 0x0000, 0x2001, 0x0110,
+	0x2003, 0x0008, 0x2003, 0x0000, 0x0489, 0x0005, 0x0002, 0x7ae2,
+	0x7dd7, 0x7adf, 0x7adf, 0x7adf, 0x7adf, 0x7adf, 0x7adf, 0x7817,
+	0x0140, 0x0005, 0x7000, 0x908c, 0xff00, 0x9194, 0xf000, 0x810f,
+	0x9484, 0x0fff, 0x688e, 0x9286, 0x2000, 0x1150, 0x6800, 0x9086,
+	0x0001, 0x1118, 0x080c, 0x5409, 0x0070, 0x080c, 0x7b45, 0x0058,
+	0x9286, 0x3000, 0x1118, 0x080c, 0x7d14, 0x0028, 0x9286, 0x8000,
+	0x1110, 0x080c, 0x7eeb, 0x7817, 0x0140, 0x0005, 0x2001, 0x1810,
+	0x2004, 0xd08c, 0x0178, 0x2001, 0x1800, 0x2004, 0x9086, 0x0003,
+	0x1148, 0x0026, 0x0036, 0x2011, 0x8048, 0x2518, 0x080c, 0x48fa,
+	0x003e, 0x002e, 0x0005, 0x0036, 0x0046, 0x0056, 0x00f6, 0x2079,
+	0x0200, 0x2019, 0xfffe, 0x7c30, 0x0050, 0x0036, 0x0046, 0x0056,
+	0x00f6, 0x2079, 0x0200, 0x7d44, 0x7c40, 0x2019, 0xffff, 0x2001,
+	0x1810, 0x2004, 0xd08c, 0x0160, 0x2001, 0x1800, 0x2004, 0x9086,
+	0x0003, 0x1130, 0x0026, 0x2011, 0x8048, 0x080c, 0x48fa, 0x002e,
+	0x00fe, 0x005e, 0x004e, 0x003e, 0x0005, 0x00b6, 0x00c6, 0x7010,
+	0x9084, 0xff00, 0x8007, 0x9096, 0x0001, 0x0120, 0x9096, 0x0023,
+	0x1904, 0x7ce5, 0x9186, 0x0023, 0x15c0, 0x080c, 0x7f80, 0x0904,
+	0x7ce5, 0x6120, 0x9186, 0x0001, 0x0150, 0x9186, 0x0004, 0x0138,
+	0x9186, 0x0008, 0x0120, 0x9186, 0x000a, 0x1904, 0x7ce5, 0x7124,
+	0x610a, 0x7030, 0x908e, 0x0200, 0x1130, 0x2009, 0x0015, 0x080c,
+	0x9c82, 0x0804, 0x7ce5, 0x908e, 0x0214, 0x0118, 0x908e, 0x0210,
+	0x1130, 0x2009, 0x0015, 0x080c, 0x9c82, 0x0804, 0x7ce5, 0x908e,
+	0x0100, 0x1904, 0x7ce5, 0x7034, 0x9005, 0x1904, 0x7ce5, 0x2009,
+	0x0016, 0x080c, 0x9c82, 0x0804, 0x7ce5, 0x9186, 0x0022, 0x1904,
+	0x7ce5, 0x7030, 0x908e, 0x0300, 0x1580, 0x68d8, 0xd0a4, 0x0528,
+	0xc0b5, 0x68da, 0x7100, 0x918c, 0x00ff, 0x697a, 0x7004, 0x687e,
+	0x00f6, 0x2079, 0x0100, 0x79e6, 0x78ea, 0x0006, 0x9084, 0x00ff,
+	0x0016, 0x2008, 0x080c, 0x24a2, 0x7932, 0x7936, 0x001e, 0x000e,
+	0x00fe, 0x080c, 0x2459, 0x695a, 0x703c, 0x00e6, 0x2071, 0x0140,
+	0x7086, 0x2071, 0x1800, 0x70b2, 0x00ee, 0x7034, 0x9005, 0x1904,
+	0x7ce5, 0x2009, 0x0017, 0x0804, 0x7c95, 0x908e, 0x0400, 0x1190,
+	0x7034, 0x9005, 0x1904, 0x7ce5, 0x080c, 0x70ba, 0x0120, 0x2009,
+	0x001d, 0x0804, 0x7c95, 0x68d8, 0xc0a5, 0x68da, 0x2009, 0x0030,
+	0x0804, 0x7c95, 0x908e, 0x0500, 0x1140, 0x7034, 0x9005, 0x1904,
+	0x7ce5, 0x2009, 0x0018, 0x0804, 0x7c95, 0x908e, 0x2010, 0x1120,
+	0x2009, 0x0019, 0x0804, 0x7c95, 0x908e, 0x2110, 0x1120, 0x2009,
+	0x001a, 0x0804, 0x7c95, 0x908e, 0x5200, 0x1140, 0x7034, 0x9005,
+	0x1904, 0x7ce5, 0x2009, 0x001b, 0x0804, 0x7c95, 0x908e, 0x5000,
+	0x1140, 0x7034, 0x9005, 0x1904, 0x7ce5, 0x2009, 0x001c, 0x0804,
+	0x7c95, 0x908e, 0x1300, 0x1120, 0x2009, 0x0034, 0x0804, 0x7c95,
+	0x908e, 0x1200, 0x1140, 0x7034, 0x9005, 0x1904, 0x7ce5, 0x2009,
+	0x0024, 0x0804, 0x7c95, 0x908c, 0xff00, 0x918e, 0x2400, 0x1170,
+	0x2009, 0x002d, 0x2001, 0x1810, 0x2004, 0xd09c, 0x0904, 0x7c95,
+	0x080c, 0xc66b, 0x1904, 0x7ce5, 0x0804, 0x7c93, 0x908c, 0xff00,
+	0x918e, 0x5300, 0x1120, 0x2009, 0x002a, 0x0804, 0x7c95, 0x908e,
+	0x0f00, 0x1120, 0x2009, 0x0020, 0x0804, 0x7c95, 0x908e, 0x6104,
+	0x1528, 0x2029, 0x0205, 0x2011, 0x026d, 0x8208, 0x2204, 0x9082,
+	0x0004, 0x8004, 0x8004, 0x20a8, 0x2011, 0x8015, 0x211c, 0x8108,
+	0x0046, 0x2124, 0x080c, 0x48fa, 0x004e, 0x8108, 0x0f04, 0x7c61,
+	0x9186, 0x0280, 0x1d88, 0x2504, 0x8000, 0x202a, 0x2009, 0x0260,
+	0x0c58, 0x202b, 0x0000, 0x2009, 0x0023, 0x0478, 0x908e, 0x6000,
+	0x1118, 0x2009, 0x003f, 0x0448, 0x908e, 0x7800, 0x1118, 0x2009,
+	0x0045, 0x0418, 0x908e, 0x1000, 0x1118, 0x2009, 0x004e, 0x00e8,
+	0x908e, 0x6300, 0x1118, 0x2009, 0x004a, 0x00b8, 0x908c, 0xff00,
+	0x918e, 0x5600, 0x1118, 0x2009, 0x004f, 0x0078, 0x908c, 0xff00,
+	0x918e, 0x5700, 0x1118, 0x2009, 0x0050, 0x0038, 0x2009, 0x001d,
+	0x6838, 0xd0d4, 0x0110, 0x2009, 0x004c, 0x0016, 0x2011, 0x0263,
+	0x2204, 0x8211, 0x220c, 0x080c, 0x2459, 0x1904, 0x7ce8, 0x080c,
+	0x622f, 0x1904, 0x7ce8, 0xbe12, 0xbd16, 0x001e, 0x0016, 0x080c,
+	0x70ba, 0x01c0, 0x68d8, 0xd08c, 0x1148, 0x7000, 0x9084, 0x00ff,
+	0x1188, 0x7004, 0x9084, 0xff00, 0x1168, 0x0040, 0x6878, 0x9606,
+	0x1148, 0x687c, 0x9506, 0x9084, 0xff00, 0x1120, 0x9584, 0x00ff,
+	0xb886, 0x0080, 0xb884, 0x9005, 0x1168, 0x9186, 0x0046, 0x1150,
+	0x6878, 0x9606, 0x1138, 0x687c, 0x9506, 0x9084, 0xff00, 0x1110,
+	0x001e, 0x0098, 0x080c, 0x9b90, 0x01a8, 0x2b08, 0x6112, 0x6023,
+	0x0004, 0x7120, 0x610a, 0x001e, 0x9186, 0x004c, 0x1110, 0x6023,
+	0x000a, 0x0016, 0x001e, 0x080c, 0x9c82, 0x00ce, 0x00be, 0x0005,
+	0x001e, 0x0cd8, 0x2001, 0x180e, 0x2004, 0xd0ec, 0x0120, 0x2011,
+	0x8049, 0x080c, 0x48fa, 0x080c, 0x9c55, 0x0d90, 0x2b08, 0x6112,
+	0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x0016, 0x9186, 0x0017,
+	0x0118, 0x9186, 0x0030, 0x1128, 0x6007, 0x0009, 0x6017, 0x2900,
+	0x0020, 0x6007, 0x0051, 0x6017, 0x0000, 0x602f, 0x0009, 0x6003,
+	0x0001, 0x080c, 0x84ee, 0x08a0, 0x080c, 0x3164, 0x1140, 0x7010,
+	0x9084, 0xff00, 0x8007, 0x908e, 0x0008, 0x1108, 0x0009, 0x0005,
+	0x00b6, 0x00c6, 0x0046, 0x7000, 0x908c, 0xff00, 0x810f, 0x9186,
+	0x0033, 0x11e8, 0x080c, 0x7f80, 0x0904, 0x7d6f, 0x7124, 0x610a,
+	0x7030, 0x908e, 0x0200, 0x1140, 0x7034, 0x9005, 0x15c0, 0x2009,
+	0x0015, 0x080c, 0x9c82, 0x0498, 0x908e, 0x0100, 0x1580, 0x7034,
+	0x9005, 0x1568, 0x2009, 0x0016, 0x080c, 0x9c82, 0x0440, 0x9186,
+	0x0032, 0x1528, 0x7030, 0x908e, 0x1400, 0x1508, 0x2009, 0x0038,
+	0x0016, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2459,
+	0x11a8, 0x080c, 0x622f, 0x1190, 0xbe12, 0xbd16, 0x080c, 0x9b90,
+	0x0168, 0x2b08, 0x6112, 0x080c, 0xbd09, 0x6023, 0x0004, 0x7120,
+	0x610a, 0x001e, 0x080c, 0x9c82, 0x0010, 0x00ce, 0x001e, 0x004e,
+	0x00ce, 0x00be, 0x0005, 0x00b6, 0x0046, 0x00e6, 0x00d6, 0x2028,
+	0x2130, 0x9696, 0x00ff, 0x11b8, 0x9592, 0xfffc, 0x02a0, 0x9596,
+	0xfffd, 0x1120, 0x2009, 0x007f, 0x0804, 0x7dd1, 0x9596, 0xfffe,
+	0x1120, 0x2009, 0x007e, 0x0804, 0x7dd1, 0x9596, 0xfffc, 0x1118,
+	0x2009, 0x0080, 0x04f0, 0x2011, 0x0000, 0x2019, 0x1836, 0x231c,
+	0xd3ac, 0x0130, 0x9026, 0x20a9, 0x0800, 0x2071, 0x1000, 0x0030,
+	0x2021, 0x0081, 0x20a9, 0x077f, 0x2071, 0x1081, 0x2e1c, 0x93dd,
+	0x0000, 0x1140, 0x82ff, 0x11d0, 0x9496, 0x00ff, 0x01b8, 0x2410,
+	0xc2fd, 0x00a0, 0xbf10, 0x2600, 0x9706, 0xb814, 0x1120, 0x9546,
+	0x1110, 0x2408, 0x00b0, 0x9745, 0x1148, 0x94c6, 0x007e, 0x0130,
+	0x94c6, 0x007f, 0x0118, 0x94c6, 0x0080, 0x1d20, 0x8420, 0x8e70,
+	0x1f04, 0x7da6, 0x82ff, 0x1118, 0x9085, 0x0001, 0x0018, 0xc2fc,
+	0x2208, 0x9006, 0x00de, 0x00ee, 0x004e, 0x00be, 0x0005, 0x7000,
+	0x908c, 0xff00, 0x810f, 0x9184, 0x000f, 0x0002, 0x7dee, 0x7dee,
+	0x7dee, 0x7f92, 0x7dee, 0x7df1, 0x7e16, 0x7e9f, 0x7dee, 0x7dee,
+	0x7dee, 0x7dee, 0x7dee, 0x7dee, 0x7dee, 0x7dee, 0x7817, 0x0140,
+	0x0005, 0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7120, 0x2160, 0x9c8c,
+	0x0003, 0x11c0, 0x9c8a, 0x1ddc, 0x02a8, 0x6864, 0x9c02, 0x1290,
+	0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1150,
+	0x700c, 0xb914, 0x9106, 0x1130, 0x7124, 0x610a, 0x2009, 0x0046,
+	0x080c, 0x9c82, 0x7817, 0x0140, 0x00be, 0x0005, 0x00b6, 0x00c6,
+	0x9484, 0x0fff, 0x0904, 0x7e7b, 0x7110, 0xd1bc, 0x1904, 0x7e7b,
+	0x7108, 0x700c, 0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00,
+	0x15c8, 0x81ff, 0x15b8, 0x9080, 0x319f, 0x200d, 0x918c, 0xff00,
+	0x810f, 0x2001, 0x0080, 0x9106, 0x0904, 0x7e7b, 0x9182, 0x0801,
+	0x1a04, 0x7e7b, 0x9190, 0x1000, 0x2204, 0x905d, 0x05e0, 0xbe12,
+	0xbd16, 0xb800, 0xd0ec, 0x15b8, 0xba04, 0x9294, 0xff00, 0x9286,
+	0x0600, 0x1190, 0x080c, 0x9b90, 0x0598, 0x2b08, 0x7028, 0x6052,
+	0x702c, 0x604e, 0x6112, 0x6023, 0x0006, 0x7120, 0x610a, 0x7130,
+	0x615e, 0x080c, 0xc8d2, 0x00f8, 0x080c, 0x668a, 0x1138, 0xb807,
+	0x0606, 0x0c40, 0x190c, 0x7d73, 0x11b0, 0x0880, 0x080c, 0x9b90,
+	0x2b08, 0x0188, 0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x9286,
+	0x0400, 0x1118, 0x6007, 0x0005, 0x0010, 0x6007, 0x0001, 0x6003,
+	0x0001, 0x080c, 0x84ee, 0x7817, 0x0140, 0x00ce, 0x00be, 0x0005,
+	0x2001, 0x180e, 0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c,
+	0x48fa, 0x080c, 0x9c55, 0x0d78, 0x2b08, 0x6112, 0x6023, 0x0006,
+	0x7120, 0x610a, 0x7130, 0x615e, 0x6017, 0xf300, 0x6003, 0x0001,
+	0x6007, 0x0041, 0x2009, 0xa022, 0x080c, 0x84e7, 0x08e0, 0x00b6,
+	0x7110, 0xd1bc, 0x05d0, 0x7020, 0x2060, 0x9c84, 0x0003, 0x15a8,
+	0x9c82, 0x1ddc, 0x0690, 0x6864, 0x9c02, 0x1678, 0x9484, 0x0fff,
+	0x9082, 0x000c, 0x0650, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158,
+	0xb910, 0x9106, 0x1510, 0x700c, 0xb914, 0x9106, 0x11f0, 0x7124,
+	0x610a, 0x601c, 0xd0fc, 0x11c8, 0x2001, 0x0271, 0x2004, 0x9005,
+	0x1180, 0x9484, 0x0fff, 0x9082, 0x000c, 0x0158, 0x0066, 0x2031,
+	0x0100, 0xa001, 0xa001, 0x8631, 0x1de0, 0x006e, 0x601c, 0xd0fc,
+	0x1120, 0x2009, 0x0045, 0x080c, 0x9c82, 0x7817, 0x0140, 0x00be,
+	0x0005, 0x6120, 0x9186, 0x0002, 0x0128, 0x9186, 0x0005, 0x0110,
+	0x9085, 0x0001, 0x0005, 0x080c, 0x3164, 0x1168, 0x7010, 0x9084,
+	0xff00, 0x8007, 0x9086, 0x0000, 0x1130, 0x9184, 0x000f, 0x908a,
+	0x0006, 0x1208, 0x000b, 0x0005, 0x7f02, 0x7f03, 0x7f02, 0x7f02,
+	0x7f62, 0x7f71, 0x0005, 0x00b6, 0x7110, 0xd1bc, 0x0120, 0x702c,
+	0xd084, 0x0904, 0x7f60, 0x700c, 0x7108, 0x080c, 0x2459, 0x1904,
+	0x7f60, 0x080c, 0x622f, 0x1904, 0x7f60, 0xbe12, 0xbd16, 0x7110,
+	0xd1bc, 0x01d8, 0x080c, 0x668a, 0x0118, 0x9086, 0x0004, 0x1588,
+	0x00c6, 0x080c, 0x7f80, 0x00ce, 0x05d8, 0x080c, 0x9b90, 0x2b08,
+	0x05b8, 0x6112, 0x080c, 0xbd09, 0x6023, 0x0002, 0x7120, 0x610a,
+	0x2009, 0x0088, 0x080c, 0x9c82, 0x0458, 0x080c, 0x668a, 0x0148,
+	0x9086, 0x0004, 0x0130, 0x080c, 0x6692, 0x0118, 0x9086, 0x0004,
+	0x1180, 0x080c, 0x9b90, 0x2b08, 0x01d8, 0x6112, 0x080c, 0xbd09,
+	0x6023, 0x0005, 0x7120, 0x610a, 0x2009, 0x0088, 0x080c, 0x9c82,
+	0x0078, 0x080c, 0x9b90, 0x2b08, 0x0158, 0x6112, 0x080c, 0xbd09,
+	0x6023, 0x0004, 0x7120, 0x610a, 0x2009, 0x0001, 0x080c, 0x9c82,
+	0x00be, 0x0005, 0x7110, 0xd1bc, 0x0158, 0x00d1, 0x0148, 0x080c,
+	0x7ee1, 0x1130, 0x7124, 0x610a, 0x2009, 0x0089, 0x080c, 0x9c82,
+	0x0005, 0x7110, 0xd1bc, 0x0158, 0x0059, 0x0148, 0x080c, 0x7ee1,
+	0x1130, 0x7124, 0x610a, 0x2009, 0x008a, 0x080c, 0x9c82, 0x0005,
+	0x7020, 0x2060, 0x9c84, 0x0003, 0x1158, 0x9c82, 0x1ddc, 0x0240,
+	0x2001, 0x1819, 0x2004, 0x9c02, 0x1218, 0x9085, 0x0001, 0x0005,
+	0x9006, 0x0ce8, 0x00b6, 0x7110, 0xd1bc, 0x11d8, 0x7024, 0x2060,
+	0x9c84, 0x0003, 0x11b0, 0x9c82, 0x1ddc, 0x0298, 0x6864, 0x9c02,
+	0x1280, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106,
+	0x1140, 0x700c, 0xb914, 0x9106, 0x1120, 0x2009, 0x0051, 0x080c,
+	0x9c82, 0x7817, 0x0140, 0x00be, 0x0005, 0x2031, 0x0105, 0x0069,
+	0x0005, 0x2031, 0x0206, 0x0049, 0x0005, 0x2031, 0x0207, 0x0029,
+	0x0005, 0x2031, 0x0213, 0x0009, 0x0005, 0x00c6, 0x0096, 0x00f6,
+	0x7000, 0x9084, 0xf000, 0x9086, 0xc000, 0x05c0, 0x080c, 0x9b90,
+	0x05a8, 0x0066, 0x00c6, 0x0046, 0x2011, 0x0263, 0x2204, 0x8211,
+	0x220c, 0x080c, 0x2459, 0x1590, 0x080c, 0x622f, 0x1578, 0xbe12,
+	0xbd16, 0x2b00, 0x004e, 0x00ce, 0x6012, 0x080c, 0xbd09, 0x080c,
+	0x102f, 0x0500, 0x2900, 0x6062, 0x9006, 0xa802, 0xa866, 0xac6a,
+	0xa85c, 0x90f8, 0x001b, 0x20a9, 0x000e, 0xa860, 0x20e8, 0x20e1,
+	0x0000, 0x2fa0, 0x2e98, 0x4003, 0x006e, 0x6616, 0x6007, 0x003e,
+	0x6023, 0x0001, 0x6003, 0x0001, 0x080c, 0x84ee, 0x00fe, 0x009e,
+	0x00ce, 0x0005, 0x080c, 0x9be6, 0x006e, 0x0cc0, 0x004e, 0x00ce,
+	0x0cc8, 0x00c6, 0x7000, 0x908c, 0xff00, 0x9184, 0xf000, 0x810f,
+	0x9086, 0x2000, 0x1904, 0x8068, 0x9186, 0x0022, 0x15f0, 0x2001,
+	0x0111, 0x2004, 0x9005, 0x1904, 0x806a, 0x7030, 0x908e, 0x0400,
+	0x0904, 0x806a, 0x908e, 0x6000, 0x05e8, 0x908e, 0x5400, 0x05d0,
+	0x908e, 0x0300, 0x11d8, 0x2009, 0x1836, 0x210c, 0xd18c, 0x1590,
+	0xd1a4, 0x1580, 0x080c, 0x6648, 0x0588, 0x68ac, 0x9084, 0x00ff,
+	0x7100, 0x918c, 0x00ff, 0x9106, 0x1518, 0x687c, 0x69ac, 0x918c,
+	0xff00, 0x9105, 0x7104, 0x9106, 0x11d8, 0x00e0, 0x2009, 0x0103,
+	0x210c, 0xd1b4, 0x11a8, 0x908e, 0x5200, 0x09e8, 0x908e, 0x0500,
+	0x09d0, 0x908e, 0x5000, 0x09b8, 0x0058, 0x9186, 0x0023, 0x1140,
+	0x080c, 0x7f80, 0x0128, 0x6004, 0x9086, 0x0002, 0x0118, 0x0000,
+	0x9006, 0x0010, 0x9085, 0x0001, 0x00ce, 0x0005, 0x7030, 0x908e,
+	0x0300, 0x0118, 0x908e, 0x5200, 0x1d98, 0x2001, 0x1836, 0x2004,
+	0x9084, 0x0009, 0x9086, 0x0008, 0x0d68, 0x0c50, 0x00f6, 0x2079,
+	0x0200, 0x7800, 0xc0e5, 0xc0cc, 0x7802, 0x00fe, 0x0005, 0x00f6,
+	0x2079, 0x1800, 0x7834, 0xd084, 0x1130, 0x2079, 0x0200, 0x7800,
+	0x9085, 0x1200, 0x7802, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x1800,
+	0x7034, 0xc084, 0x7036, 0x00ee, 0x0005, 0x2071, 0x19db, 0x7003,
+	0x0003, 0x700f, 0x0361, 0x9006, 0x701a, 0x7072, 0x7012, 0x7017,
+	0x1ddc, 0x7007, 0x0000, 0x7026, 0x702b, 0x8ff0, 0x7032, 0x7037,
+	0x906d, 0x703f, 0xffff, 0x7042, 0x7047, 0x523f, 0x704a, 0x705b,
+	0x8239, 0x080c, 0x1048, 0x090c, 0x0d65, 0x2900, 0x703a, 0xa867,
+	0x0003, 0xa86f, 0x0100, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x19db,
+	0x1d04, 0x815b, 0x2091, 0x6000, 0x700c, 0x8001, 0x700e, 0x1560,
+	0x2001, 0x187d, 0x2004, 0xd0c4, 0x0158, 0x3a00, 0xd08c, 0x1140,
+	0x20d1, 0x0000, 0x20d1, 0x0001, 0x20d1, 0x0000, 0x080c, 0x0d65,
+	0x700f, 0x0361, 0x7007, 0x0001, 0x0126, 0x2091, 0x8000, 0x2069,
+	0x1800, 0x69e8, 0xd1e4, 0x1138, 0xd1dc, 0x1118, 0x080c, 0x82a7,
+	0x0010, 0x080c, 0x827e, 0x7040, 0x900d, 0x0148, 0x8109, 0x7142,
+	0x1130, 0x7044, 0x080f, 0x0018, 0x0126, 0x2091, 0x8000, 0x7024,
+	0x900d, 0x0188, 0x7020, 0x8001, 0x7022, 0x1168, 0x7023, 0x0009,
+	0x8109, 0x7126, 0x9186, 0x03e8, 0x1110, 0x7028, 0x080f, 0x81ff,
+	0x1110, 0x7028, 0x080f, 0x7030, 0x900d, 0x0180, 0x702c, 0x8001,
+	0x702e, 0x1160, 0x702f, 0x0009, 0x8109, 0x7132, 0x0128, 0x9184,
+	0x007f, 0x090c, 0x90f5, 0x0010, 0x7034, 0x080f, 0x703c, 0x9005,
+	0x0118, 0x0310, 0x8001, 0x703e, 0x704c, 0x900d, 0x0168, 0x7048,
+	0x8001, 0x704a, 0x1148, 0x704b, 0x0009, 0x8109, 0x714e, 0x1120,
+	0x7150, 0x714e, 0x7058, 0x080f, 0x7018, 0x900d, 0x01d8, 0x0016,
+	0x7070, 0x900d, 0x0158, 0x706c, 0x8001, 0x706e, 0x1138, 0x706f,
+	0x0009, 0x8109, 0x7172, 0x1110, 0x7074, 0x080f, 0x001e, 0x7008,
+	0x8001, 0x700a, 0x1138, 0x700b, 0x0009, 0x8109, 0x711a, 0x1110,
+	0x701c, 0x080f, 0x012e, 0x7004, 0x0002, 0x8183, 0x8184, 0x81ae,
+	0x00e6, 0x2071, 0x19db, 0x7018, 0x9005, 0x1120, 0x711a, 0x721e,
+	0x700b, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0x19db,
+	0x701c, 0x9206, 0x1120, 0x701a, 0x701e, 0x7072, 0x7076, 0x000e,
+	0x00ee, 0x0005, 0x00e6, 0x2071, 0x19db, 0xb888, 0x9102, 0x0208,
+	0xb98a, 0x00ee, 0x0005, 0x0005, 0x00b6, 0x2031, 0x0010, 0x7110,
+	0x080c, 0x628f, 0x11a8, 0xb888, 0x8001, 0x0290, 0xb88a, 0x1180,
+	0x0126, 0x2091, 0x8000, 0x0066, 0xb8c0, 0x9005, 0x0138, 0x0026,
+	0xba3c, 0x0016, 0x080c, 0x63ba, 0x001e, 0x002e, 0x006e, 0x012e,
+	0x8108, 0x9182, 0x0800, 0x1220, 0x8631, 0x0128, 0x7112, 0x0c00,
+	0x900e, 0x7007, 0x0002, 0x7112, 0x00be, 0x0005, 0x2031, 0x0010,
+	0x7014, 0x2060, 0x0126, 0x2091, 0x8000, 0x6048, 0x9005, 0x0128,
+	0x8001, 0x604a, 0x1110, 0x080c, 0xbb8a, 0x6018, 0x9005, 0x0904,
+	0x8200, 0x00f6, 0x2079, 0x0300, 0x7918, 0xd1b4, 0x1904, 0x8213,
+	0x781b, 0x2020, 0xa001, 0x7918, 0xd1b4, 0x0120, 0x781b, 0x2000,
+	0x0804, 0x8213, 0x8001, 0x601a, 0x0106, 0x781b, 0x2000, 0xa001,
+	0x7918, 0xd1ac, 0x1dd0, 0x010e, 0x00fe, 0x1510, 0x6120, 0x9186,
+	0x0003, 0x0118, 0x9186, 0x0006, 0x11c8, 0x080c, 0xb870, 0x01b0,
+	0x6014, 0x2048, 0xa884, 0x908a, 0x199a, 0x0280, 0x9082, 0x1999,
+	0xa886, 0x908a, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x800b,
+	0x810b, 0x9108, 0x611a, 0x080c, 0xbfbb, 0x0110, 0x080c, 0xb551,
+	0x012e, 0x9c88, 0x001c, 0x7116, 0x2001, 0x1819, 0x2004, 0x9102,
+	0x1228, 0x8631, 0x0138, 0x2160, 0x0804, 0x81b2, 0x7017, 0x1ddc,
+	0x7007, 0x0000, 0x0005, 0x00fe, 0x0c58, 0x00e6, 0x2071, 0x19db,
+	0x7027, 0x07d0, 0x7023, 0x0009, 0x00ee, 0x0005, 0x2001, 0x19e4,
+	0x2003, 0x0000, 0x0005, 0x00e6, 0x2071, 0x19db, 0x7132, 0x702f,
+	0x0009, 0x00ee, 0x0005, 0x2011, 0x19e7, 0x2013, 0x0000, 0x0005,
+	0x00e6, 0x2071, 0x19db, 0x711a, 0x721e, 0x700b, 0x0009, 0x00ee,
+	0x0005, 0x0086, 0x0026, 0x7054, 0x8000, 0x7056, 0x2001, 0x19e9,
+	0x2044, 0xa06c, 0x9086, 0x0000, 0x0150, 0x7068, 0xa09a, 0x7064,
+	0xa096, 0x7060, 0xa092, 0x705c, 0xa08e, 0x080c, 0x1124, 0x002e,
+	0x008e, 0x0005, 0x0006, 0x0016, 0x0096, 0x00a6, 0x00b6, 0x00c6,
+	0x00d6, 0x00e6, 0x00f6, 0x0156, 0x080c, 0x80c6, 0x015e, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x001e, 0x000e,
+	0x0005, 0x00e6, 0x2071, 0x19db, 0x7172, 0x7276, 0x706f, 0x0009,
+	0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0x19db, 0x7074, 0x9206,
+	0x1110, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x2069, 0x1800,
+	0x69e8, 0xd1e4, 0x1518, 0x0026, 0xd1ec, 0x0140, 0x6a50, 0x6870,
+	0x9202, 0x0288, 0x8117, 0x9294, 0x00c1, 0x0088, 0x9184, 0x0007,
+	0x01a0, 0x8109, 0x9184, 0x0007, 0x0110, 0x69ea, 0x0070, 0x8107,
+	0x9084, 0x0007, 0x910d, 0x8107, 0x9106, 0x9094, 0x00c1, 0x9184,
+	0xff3e, 0x9205, 0x68ea, 0x080c, 0x0efa, 0x002e, 0x0005, 0x69e4,
+	0x9184, 0x003f, 0x05b8, 0x8109, 0x9184, 0x003f, 0x01a8, 0x6a50,
+	0x6870, 0x9202, 0x0220, 0xd1bc, 0x0168, 0xc1bc, 0x0018, 0xd1bc,
+	0x1148, 0xc1bd, 0x2110, 0x00e6, 0x2071, 0x1800, 0x080c, 0x0f1c,
+	0x00ee, 0x0400, 0x69e6, 0x00f0, 0x0026, 0x8107, 0x9094, 0x0007,
+	0x0128, 0x8001, 0x8007, 0x9085, 0x0007, 0x0050, 0x2010, 0x8004,
+	0x8004, 0x8004, 0x9084, 0x0007, 0x9205, 0x8007, 0x9085, 0x0028,
+	0x9086, 0x0040, 0x2010, 0x00e6, 0x2071, 0x1800, 0x080c, 0x0f1c,
+	0x00ee, 0x002e, 0x0005, 0x00c6, 0x2061, 0x1a46, 0x00ce, 0x0005,
+	0x9184, 0x000f, 0x8003, 0x8003, 0x8003, 0x9080, 0x1a46, 0x2060,
+	0x0005, 0xa884, 0x908a, 0x199a, 0x1638, 0x9005, 0x1150, 0x00c6,
+	0x2061, 0x1a46, 0x6014, 0x00ce, 0x9005, 0x1130, 0x2001, 0x001e,
+	0x0018, 0x908e, 0xffff, 0x01b0, 0x8003, 0x800b, 0x810b, 0x9108,
+	0x611a, 0xa87c, 0x908c, 0x00c0, 0x918e, 0x00c0, 0x0904, 0x83ab,
+	0xd0b4, 0x1168, 0xd0bc, 0x1904, 0x8384, 0x2009, 0x0006, 0x080c,
+	0x83d8, 0x0005, 0x900e, 0x0c60, 0x2001, 0x1999, 0x08b0, 0xd0fc,
+	0x05e0, 0x908c, 0x2023, 0x1568, 0x87ff, 0x1558, 0xa9a8, 0x81ff,
+	0x1540, 0x6124, 0x918c, 0x0500, 0x1520, 0x6100, 0x918e, 0x0007,
+	0x1500, 0x2009, 0x187d, 0x210c, 0xd184, 0x11d8, 0x6003, 0x0003,
+	0x6007, 0x0043, 0x6047, 0xb035, 0x080c, 0x1aca, 0xa87c, 0xc0dd,
+	0xa87e, 0x600f, 0x0000, 0x00f6, 0x2079, 0x0380, 0x7818, 0xd0bc,
+	0x1de8, 0x7833, 0x0013, 0x2c00, 0x7836, 0x781b, 0x8080, 0x00fe,
+	0x0005, 0x908c, 0x0003, 0x0120, 0x918e, 0x0003, 0x1904, 0x83d2,
+	0x908c, 0x2020, 0x918e, 0x2020, 0x01a8, 0x6024, 0xd0d4, 0x11e8,
+	0x2009, 0x187d, 0x2104, 0xd084, 0x1138, 0x87ff, 0x1120, 0x2009,
+	0x0043, 0x0804, 0x9c82, 0x0005, 0x87ff, 0x1de8, 0x2009, 0x0042,
+	0x0804, 0x9c82, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac,
+	0x0d20, 0x6024, 0xc0cd, 0x6026, 0x0c00, 0xc0d4, 0x6026, 0xa890,
+	0x602e, 0xa88c, 0x6032, 0x08e0, 0xd0fc, 0x0160, 0x908c, 0x0003,
+	0x0120, 0x918e, 0x0003, 0x1904, 0x83d2, 0x908c, 0x2020, 0x918e,
+	0x2020, 0x0170, 0x0076, 0x00f6, 0x2c78, 0x080c, 0x1669, 0x00fe,
+	0x007e, 0x87ff, 0x1120, 0x2009, 0x0042, 0x080c, 0x9c82, 0x0005,
+	0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d58, 0x6124,
+	0xc1cd, 0x6126, 0x0c38, 0xd0fc, 0x0188, 0x908c, 0x2020, 0x918e,
+	0x2020, 0x01a8, 0x9084, 0x0003, 0x908e, 0x0002, 0x0148, 0x87ff,
+	0x1120, 0x2009, 0x0041, 0x080c, 0x9c82, 0x0005, 0x00b9, 0x0ce8,
+	0x87ff, 0x1dd8, 0x2009, 0x0043, 0x080c, 0x9c82, 0x0cb0, 0x6110,
+	0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20, 0x6124, 0xc1cd,
+	0x6126, 0x0c00, 0x2009, 0x0004, 0x0019, 0x0005, 0x2009, 0x0001,
+	0x0096, 0x080c, 0xb870, 0x0518, 0x6014, 0x2048, 0xa982, 0xa800,
+	0x6016, 0x9186, 0x0001, 0x1188, 0xa97c, 0x918c, 0x8100, 0x918e,
+	0x8100, 0x1158, 0x00c6, 0x2061, 0x1a46, 0x6200, 0xd28c, 0x1120,
+	0x6204, 0x8210, 0x0208, 0x6206, 0x00ce, 0x080c, 0x67ea, 0x6014,
+	0x904d, 0x0076, 0x2039, 0x0000, 0x190c, 0x82f1, 0x007e, 0x009e,
+	0x0005, 0x0156, 0x00c6, 0x2061, 0x1a46, 0x6000, 0x81ff, 0x0110,
+	0x9205, 0x0008, 0x9204, 0x6002, 0x00ce, 0x015e, 0x0005, 0x6800,
+	0xd08c, 0x1138, 0x6808, 0x9005, 0x0120, 0x8001, 0x680a, 0x9085,
+	0x0001, 0x0005, 0x0126, 0x2091, 0x8000, 0x0036, 0x0046, 0x20a9,
+	0x0010, 0x9006, 0x8004, 0x8086, 0x818e, 0x1208, 0x9200, 0x1f04,
+	0x8423, 0x8086, 0x818e, 0x004e, 0x003e, 0x012e, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x0076, 0x0156, 0x20a9, 0x0010, 0x9005, 0x01c8,
+	0x911a, 0x12b8, 0x8213, 0x818d, 0x0228, 0x911a, 0x1220, 0x1f04,
+	0x843a, 0x0028, 0x911a, 0x2308, 0x8210, 0x1f04, 0x843a, 0x0006,
+	0x3200, 0x9084, 0xefff, 0x2080, 0x000e, 0x015e, 0x007e, 0x012e,
+	0x0005, 0x0006, 0x3200, 0x9085, 0x1000, 0x0ca8, 0x0126, 0x2091,
+	0x2800, 0x2079, 0x19bf, 0x012e, 0x00d6, 0x2069, 0x19bf, 0x6803,
+	0x0005, 0x0156, 0x0146, 0x01d6, 0x20e9, 0x0000, 0x2069, 0x0200,
+	0x080c, 0x97f4, 0x04a9, 0x080c, 0x97df, 0x0491, 0x080c, 0x97e2,
+	0x0479, 0x080c, 0x97e5, 0x0461, 0x080c, 0x97e8, 0x0449, 0x080c,
+	0x97eb, 0x0431, 0x080c, 0x97ee, 0x0419, 0x080c, 0x97f1, 0x0401,
+	0x01de, 0x014e, 0x015e, 0x6857, 0x0000, 0x00f6, 0x2079, 0x0380,
+	0x00f9, 0x7807, 0x0003, 0x7803, 0x0000, 0x7803, 0x0001, 0x2069,
+	0x0004, 0x2d04, 0x9084, 0xfffe, 0x9085, 0x8000, 0x206a, 0x2069,
+	0x0100, 0x6828, 0x9084, 0xfffc, 0x682a, 0x00fe, 0x00de, 0x0005,
+	0x20a9, 0x0020, 0x20a1, 0x0240, 0x2001, 0x0000, 0x4004, 0x0005,
+	0x00c6, 0x7803, 0x0000, 0x9006, 0x7827, 0x0030, 0x782b, 0x0400,
+	0x7827, 0x0031, 0x782b, 0x1ac6, 0x781f, 0xff00, 0x781b, 0xff00,
+	0x2061, 0x1abb, 0x602f, 0x19bf, 0x6033, 0x1800, 0x6037, 0x19db,
+	0x603b, 0x1d1c, 0x603f, 0x1d2c, 0x6042, 0x6047, 0x1a91, 0x00ce,
+	0x0005, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0001,
+	0x01b0, 0x00c6, 0x6146, 0x600f, 0x0000, 0x2c08, 0x2061, 0x19bf,
+	0x602c, 0x8000, 0x602e, 0x601c, 0x9005, 0x0130, 0x9080, 0x0003,
+	0x2102, 0x611e, 0x00ce, 0x0005, 0x6122, 0x611e, 0x0cd8, 0x6146,
+	0x2c08, 0x2001, 0x0012, 0x080c, 0x98b8, 0x0005, 0x0016, 0x2009,
+	0x8020, 0x6146, 0x2c08, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007,
+	0x9086, 0x0001, 0x1128, 0x2001, 0x0019, 0x080c, 0x98b8, 0x0088,
+	0x00c6, 0x2061, 0x19bf, 0x602c, 0x8000, 0x602e, 0x600c, 0x9005,
+	0x0128, 0x9080, 0x0003, 0x2102, 0x610e, 0x0010, 0x6112, 0x610e,
+	0x00ce, 0x001e, 0x0005, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007,
+	0x9086, 0x0001, 0x0198, 0x00c6, 0x6146, 0x600f, 0x0000, 0x2c08,
+	0x2061, 0x19bf, 0x6044, 0x9005, 0x0130, 0x9080, 0x0003, 0x2102,
+	0x6146, 0x00ce, 0x0005, 0x614a, 0x6146, 0x0cd8, 0x6146, 0x600f,
+	0x0000, 0x2c08, 0x2001, 0x0013, 0x080c, 0x98b8, 0x0005, 0x6044,
+	0xd0dc, 0x0110, 0x080c, 0x948d, 0x0005, 0x00f6, 0x00e6, 0x00d6,
+	0x00c6, 0x00b6, 0x0096, 0x0076, 0x0066, 0x0056, 0x0036, 0x0026,
+	0x0016, 0x0006, 0x0126, 0x902e, 0x2071, 0x19bf, 0x7648, 0x2660,
+	0x2678, 0x2091, 0x8000, 0x8cff, 0x0904, 0x85ba, 0x6010, 0x2058,
+	0xb8a0, 0x9206, 0x1904, 0x85b5, 0x87ff, 0x0120, 0x605c, 0x9106,
+	0x1904, 0x85b5, 0x704c, 0x9c06, 0x1178, 0x0036, 0x2019, 0x0001,
+	0x080c, 0x929d, 0x703f, 0x0000, 0x9006, 0x704e, 0x706a, 0x7052,
+	0x706e, 0x003e, 0x2029, 0x0001, 0x0811, 0x7048, 0x9c36, 0x1110,
+	0x660c, 0x764a, 0x7044, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118,
+	0x2f00, 0x7046, 0x0010, 0x7047, 0x0000, 0x660c, 0x0066, 0x2c00,
+	0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x080c,
+	0xb870, 0x01f0, 0x6014, 0x2048, 0x6020, 0x9086, 0x0003, 0x1588,
+	0x6004, 0x9086, 0x0040, 0x090c, 0x948d, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x0016, 0x0036, 0x0076, 0x080c, 0xbb73, 0x080c,
+	0xd563, 0x080c, 0x69b5, 0x007e, 0x003e, 0x001e, 0x080c, 0xba5f,
+	0x080c, 0x9c20, 0x00ce, 0x0804, 0x8553, 0x2c78, 0x600c, 0x2060,
+	0x0804, 0x8553, 0x012e, 0x000e, 0x001e, 0x002e, 0x003e, 0x005e,
+	0x006e, 0x007e, 0x009e, 0x00be, 0x00ce, 0x00de, 0x00ee, 0x00fe,
+	0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016, 0x0036, 0x0076,
+	0x080c, 0xd563, 0x080c, 0xd267, 0x007e, 0x003e, 0x001e, 0x08c0,
+	0x6020, 0x9086, 0x000a, 0x0918, 0x0804, 0x8598, 0x0006, 0x0066,
+	0x0096, 0x00c6, 0x00d6, 0x00f6, 0x9036, 0x0126, 0x2091, 0x8000,
+	0x2079, 0x19bf, 0x7848, 0x9065, 0x0904, 0x8642, 0x600c, 0x0006,
+	0x600f, 0x0000, 0x784c, 0x9c06, 0x11a0, 0x0036, 0x2019, 0x0001,
+	0x080c, 0x929d, 0x783f, 0x0000, 0x901e, 0x7b4e, 0x7b6a, 0x7b52,
+	0x7b6e, 0x003e, 0x000e, 0x9005, 0x1118, 0x600c, 0x600f, 0x0000,
+	0x0006, 0x00e6, 0x2f70, 0x080c, 0x8537, 0x00ee, 0x080c, 0xb870,
+	0x0548, 0x6014, 0x2048, 0x6020, 0x9086, 0x0003, 0x15a8, 0x3e08,
+	0x918e, 0x0002, 0x1188, 0x6010, 0x9005, 0x0170, 0x00b6, 0x2058,
+	0xb800, 0x00be, 0xd0bc, 0x0140, 0x6048, 0x9005, 0x11c0, 0x2001,
+	0x1960, 0x2004, 0x604a, 0x0098, 0x6004, 0x9086, 0x0040, 0x090c,
+	0x948d, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x69a9,
+	0x080c, 0xba5f, 0x6044, 0xc0fc, 0x6046, 0x080c, 0x9c20, 0x000e,
+	0x0804, 0x85eb, 0x7e4a, 0x7e46, 0x012e, 0x00fe, 0x00de, 0x00ce,
+	0x009e, 0x006e, 0x000e, 0x0005, 0x6020, 0x9086, 0x0006, 0x1118,
+	0x080c, 0xd267, 0x0c38, 0x6020, 0x9086, 0x000a, 0x09e0, 0x08a0,
+	0x0016, 0x0026, 0x0086, 0x9046, 0x00a9, 0x080c, 0x8749, 0x008e,
+	0x002e, 0x001e, 0x0005, 0x00f6, 0x0126, 0x2079, 0x19bf, 0x2091,
+	0x8000, 0x080c, 0x8792, 0x080c, 0x8826, 0x080c, 0x641c, 0x012e,
+	0x00fe, 0x0005, 0x00b6, 0x0096, 0x00f6, 0x00e6, 0x00d6, 0x00c6,
+	0x0066, 0x0016, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19bf,
+	0x7620, 0x2660, 0x2678, 0x8cff, 0x0904, 0x870e, 0x6010, 0x2058,
+	0xb8a0, 0x9206, 0x1904, 0x8709, 0x88ff, 0x0120, 0x605c, 0x9106,
+	0x1904, 0x8709, 0x7030, 0x9c06, 0x1570, 0x2069, 0x0100, 0x6820,
+	0xd0a4, 0x1508, 0x080c, 0x821e, 0x080c, 0x8fd0, 0x68c3, 0x0000,
+	0x080c, 0x948d, 0x7033, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04,
+	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2872, 0x9006,
+	0x080c, 0x2872, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
+	0x0001, 0x003e, 0x0040, 0x7008, 0xc0ad, 0x700a, 0x6003, 0x0009,
+	0x630a, 0x0804, 0x8709, 0x7020, 0x9c36, 0x1110, 0x660c, 0x7622,
+	0x701c, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x701e,
+	0x0010, 0x701f, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110,
+	0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x6044, 0xc0fc, 0x6046,
+	0x6014, 0x2048, 0x080c, 0xb870, 0x01e8, 0x6020, 0x9086, 0x0003,
+	0x1580, 0x080c, 0xba85, 0x1118, 0x080c, 0xa59c, 0x0098, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036, 0x0086, 0x080c,
+	0xbb73, 0x080c, 0xd563, 0x080c, 0x69b5, 0x008e, 0x003e, 0x001e,
+	0x080c, 0xba5f, 0x080c, 0x9c20, 0x080c, 0x9363, 0x00ce, 0x0804,
+	0x8683, 0x2c78, 0x600c, 0x2060, 0x0804, 0x8683, 0x012e, 0x000e,
+	0x001e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x009e, 0x00be,
+	0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016, 0x0036, 0x0086,
+	0x080c, 0xd563, 0x080c, 0xd267, 0x008e, 0x003e, 0x001e, 0x08d0,
+	0x080c, 0xa59c, 0x6020, 0x9086, 0x0002, 0x1160, 0x6004, 0x0006,
+	0x9086, 0x0085, 0x000e, 0x0904, 0x86ef, 0x9086, 0x008b, 0x0904,
+	0x86ef, 0x0840, 0x6020, 0x9086, 0x0005, 0x1920, 0x6004, 0x0006,
+	0x9086, 0x0085, 0x000e, 0x09c8, 0x9086, 0x008b, 0x09b0, 0x0804,
+	0x8702, 0x0006, 0x00f6, 0x00e6, 0x0096, 0x00b6, 0x00c6, 0x0066,
+	0x0016, 0x0126, 0x2091, 0x8000, 0x9280, 0x1000, 0x2004, 0x905d,
+	0x2079, 0x19bf, 0x9036, 0x7828, 0x2060, 0x8cff, 0x0538, 0x6010,
+	0x9b06, 0x1500, 0x6043, 0xffff, 0x080c, 0x9a83, 0x01d8, 0x610c,
+	0x0016, 0x080c, 0x9127, 0x6014, 0x2048, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x0016, 0x0036, 0x0086, 0x080c, 0xbb73, 0x080c,
+	0xd563, 0x080c, 0x69b5, 0x008e, 0x003e, 0x001e, 0x080c, 0x9c20,
+	0x00ce, 0x08d8, 0x2c30, 0x600c, 0x2060, 0x08b8, 0x080c, 0x6439,
+	0x012e, 0x001e, 0x006e, 0x00ce, 0x00be, 0x009e, 0x00ee, 0x00fe,
+	0x000e, 0x0005, 0x0096, 0x0006, 0x0066, 0x00c6, 0x00d6, 0x9036,
+	0x7820, 0x9065, 0x0904, 0x87f9, 0x600c, 0x0006, 0x6044, 0xc0fc,
+	0x6046, 0x600f, 0x0000, 0x7830, 0x9c06, 0x1588, 0x2069, 0x0100,
+	0x6820, 0xd0a4, 0x1508, 0x080c, 0x821e, 0x080c, 0x8fd0, 0x68c3,
+	0x0000, 0x080c, 0x948d, 0x7833, 0x0000, 0x0036, 0x2069, 0x0140,
+	0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2872,
+	0x9006, 0x080c, 0x2872, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
+	0x6827, 0x0001, 0x003e, 0x0058, 0x080c, 0x6640, 0x1538, 0x6003,
+	0x0009, 0x630a, 0x7808, 0xc0ad, 0x780a, 0x2c30, 0x00f8, 0x6014,
+	0x2048, 0x080c, 0xb86e, 0x01b0, 0x6020, 0x9086, 0x0003, 0x1508,
+	0x080c, 0xba85, 0x1118, 0x080c, 0xa59c, 0x0060, 0x080c, 0x6640,
+	0x1168, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x69b5,
+	0x080c, 0xba5f, 0x080c, 0x9c20, 0x080c, 0x9363, 0x000e, 0x0804,
+	0x8799, 0x7e22, 0x7e1e, 0x00de, 0x00ce, 0x006e, 0x000e, 0x009e,
+	0x0005, 0x6020, 0x9086, 0x0006, 0x1118, 0x080c, 0xd267, 0x0c50,
+	0x080c, 0xa59c, 0x6020, 0x9086, 0x0002, 0x1150, 0x6004, 0x0006,
+	0x9086, 0x0085, 0x000e, 0x0990, 0x9086, 0x008b, 0x0978, 0x08d0,
+	0x6020, 0x9086, 0x0005, 0x19b0, 0x6004, 0x0006, 0x9086, 0x0085,
+	0x000e, 0x0d18, 0x9086, 0x008b, 0x0d00, 0x0860, 0x0006, 0x0096,
+	0x00b6, 0x00c6, 0x0066, 0x9036, 0x7828, 0x9065, 0x0510, 0x6010,
+	0x2058, 0x600c, 0x0006, 0x3e08, 0x918e, 0x0002, 0x1118, 0xb800,
+	0xd0bc, 0x11a8, 0x6043, 0xffff, 0x080c, 0x9a83, 0x0180, 0x610c,
+	0x080c, 0x9127, 0x6014, 0x2048, 0xa867, 0x0103, 0xab7a, 0xa877,
+	0x0000, 0x080c, 0x69b5, 0x080c, 0x9c20, 0x000e, 0x08f0, 0x2c30,
+	0x0ce0, 0x006e, 0x00ce, 0x00be, 0x009e, 0x000e, 0x0005, 0x00e6,
+	0x00d6, 0x0096, 0x0066, 0x080c, 0x5df1, 0x11b0, 0x2071, 0x19bf,
+	0x7030, 0x9080, 0x0005, 0x2004, 0x904d, 0x0170, 0xa878, 0x9606,
+	0x1158, 0x2071, 0x19bf, 0x7030, 0x9035, 0x0130, 0x9080, 0x0005,
+	0x2004, 0x9906, 0x1108, 0x0029, 0x006e, 0x009e, 0x00de, 0x00ee,
+	0x0005, 0x00c6, 0x2660, 0x6043, 0xffff, 0x080c, 0x9a83, 0x0178,
+	0x080c, 0x9127, 0x6014, 0x2048, 0xa867, 0x0103, 0xab7a, 0xa877,
+	0x0000, 0x080c, 0xbb73, 0x080c, 0x69b5, 0x080c, 0x9c20, 0x00ce,
+	0x0005, 0x00b6, 0x00e6, 0x00c6, 0x080c, 0x98c7, 0x0106, 0x2071,
+	0x0101, 0x2e04, 0xc0c4, 0x2072, 0x6044, 0xd0fc, 0x1138, 0x010e,
+	0x090c, 0x98e3, 0x00ce, 0x00ee, 0x00be, 0x0005, 0x2071, 0x19bf,
+	0x7030, 0x9005, 0x0da0, 0x9c06, 0x190c, 0x0d65, 0x7036, 0x080c,
+	0x821e, 0x7004, 0x9084, 0x0007, 0x0002, 0x88bf, 0x88c1, 0x88c8,
+	0x88d2, 0x88e0, 0x88bf, 0x88cd, 0x88bd, 0x080c, 0x0d65, 0x0428,
+	0x0005, 0x080c, 0x9a6e, 0x7007, 0x0000, 0x7033, 0x0000, 0x00e8,
+	0x0066, 0x9036, 0x080c, 0x9127, 0x006e, 0x7007, 0x0000, 0x7033,
+	0x0000, 0x0098, 0x080c, 0x9a59, 0x0140, 0x080c, 0x9a6e, 0x0128,
+	0x0066, 0x9036, 0x080c, 0x9127, 0x006e, 0x7033, 0x0000, 0x0028,
+	0x080c, 0x9a59, 0x080c, 0x948d, 0x0000, 0x010e, 0x190c, 0x98e3,
+	0x00ce, 0x00ee, 0x00be, 0x0005, 0x00d6, 0x00c6, 0x080c, 0x98c7,
+	0x0106, 0x6044, 0xd0fc, 0x1130, 0x010e, 0x090c, 0x98e3, 0x00ce,
+	0x00de, 0x0005, 0x2069, 0x19bf, 0x684c, 0x9005, 0x0da8, 0x9c06,
+	0x190c, 0x0d65, 0x6852, 0x00e6, 0x2d70, 0x080c, 0x8537, 0x00ee,
+	0x080c, 0x822b, 0x0016, 0x2009, 0x0040, 0x080c, 0x207b, 0x001e,
+	0x683c, 0x9084, 0x0003, 0x0002, 0x891a, 0x891b, 0x8939, 0x8918,
+	0x080c, 0x0d65, 0x0460, 0x6868, 0x9086, 0x0001, 0x0190, 0x600c,
+	0x9015, 0x0160, 0x6a4a, 0x600f, 0x0000, 0x6044, 0xc0fc, 0x6046,
+	0x9006, 0x7042, 0x684e, 0x683f, 0x0000, 0x00c8, 0x684a, 0x6846,
+	0x0ca0, 0x686b, 0x0000, 0x6848, 0x9065, 0x0d78, 0x6003, 0x0002,
+	0x0c60, 0x9006, 0x686a, 0x6852, 0x686e, 0x600c, 0x9015, 0x0120,
+	0x6a4a, 0x600f, 0x0000, 0x0018, 0x684e, 0x684a, 0x6846, 0x684f,
+	0x0000, 0x010e, 0x190c, 0x98e3, 0x00ce, 0x00de, 0x0005, 0x0005,
+	0x6020, 0x9084, 0x000f, 0x000b, 0x0005, 0x8965, 0x8968, 0x8dc1,
+	0x8e50, 0x8968, 0x8dc1, 0x8e50, 0x8965, 0x8968, 0x8965, 0x8965,
+	0x8965, 0x8965, 0x8965, 0x8965, 0x8965, 0x080c, 0x8891, 0x0005,
+	0x00b6, 0x0156, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6,
+	0x00e6, 0x00f6, 0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a,
+	0x0053, 0x1a0c, 0x0d65, 0x6110, 0x2158, 0xb984, 0x2c78, 0x2061,
+	0x0100, 0x619a, 0x908a, 0x0040, 0x1a04, 0x89d4, 0x005b, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e,
+	0x00be, 0x0005, 0x8b4b, 0x8b86, 0x8baf, 0x8c52, 0x8c73, 0x8c79,
+	0x8c86, 0x8c8e, 0x8c9a, 0x8ca0, 0x8cb1, 0x8ca0, 0x8d08, 0x8c8e,
+	0x8d14, 0x8d1a, 0x8c9a, 0x8d1a, 0x8d26, 0x89d2, 0x89d2, 0x89d2,
+	0x89d2, 0x89d2, 0x89d2, 0x89d2, 0x89d2, 0x89d2, 0x89d2, 0x89d2,
+	0x9148, 0x916b, 0x917c, 0x919c, 0x91ce, 0x8c86, 0x89d2, 0x8c86,
+	0x8ca0, 0x89d2, 0x8baf, 0x8c52, 0x89d2, 0x958b, 0x8ca0, 0x89d2,
+	0x95a7, 0x8ca0, 0x89d2, 0x8c9a, 0x8b45, 0x89f5, 0x89d2, 0x95c3,
+	0x9630, 0x9714, 0x89d2, 0x9721, 0x8c83, 0x974c, 0x89d2, 0x91d8,
+	0x9758, 0x89d2, 0x080c, 0x0d65, 0x2100, 0x005b, 0x00fe, 0x00ee,
+	0x00de, 0x00ce, 0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x00be,
+	0x0005, 0x89f3, 0x89f3, 0x89f3, 0x8a1c, 0x8ac8, 0x8ad3, 0x89f3,
+	0x89f3, 0x89f3, 0x8b1a, 0x8b26, 0x8a37, 0x89f3, 0x8a52, 0x8a86,
+	0x9ad9, 0x9b1e, 0x8ca0, 0x080c, 0x0d65, 0x00d6, 0x0096, 0x080c,
+	0x8d39, 0x7003, 0x2414, 0x7007, 0x0018, 0x700b, 0x0800, 0x7814,
+	0x2048, 0xa83c, 0x700e, 0xa850, 0x7022, 0xa854, 0x7026, 0x60c3,
+	0x0018, 0x080c, 0x8fa0, 0x009e, 0x00de, 0x0005, 0x7810, 0x00b6,
+	0x2058, 0xb8a0, 0x00be, 0x080c, 0x9b65, 0x1118, 0x9084, 0xff80,
+	0x0110, 0x9085, 0x0001, 0x0005, 0x00d6, 0x0096, 0x080c, 0x8d39,
+	0x7003, 0x0500, 0x7814, 0x2048, 0xa874, 0x700a, 0xa878, 0x700e,
+	0xa87c, 0x7012, 0xa880, 0x7016, 0xa884, 0x701a, 0xa888, 0x701e,
+	0x60c3, 0x0010, 0x080c, 0x8fa0, 0x009e, 0x00de, 0x0005, 0x00d6,
+	0x0096, 0x080c, 0x8d39, 0x7003, 0x0500, 0x7814, 0x2048, 0xa8cc,
+	0x700a, 0xa8d0, 0x700e, 0xa8d4, 0x7012, 0xa8d8, 0x7016, 0xa8dc,
+	0x701a, 0xa8e0, 0x701e, 0x60c3, 0x0010, 0x080c, 0x8fa0, 0x009e,
 	0x00de, 0x0005, 0x00d6, 0x0096, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x8d50, 0x20e9, 0x0000, 0x2001, 0x1973, 0x2003, 0x0000, 0x7814,
-	0x2048, 0xa86f, 0x0200, 0xa873, 0x0000, 0xa814, 0x8003, 0x60c2,
-	0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098,
-	0x2001, 0x1973, 0x0016, 0x200c, 0x080c, 0xc59f, 0x001e, 0xa804,
-	0x9005, 0x0110, 0x2048, 0x0c60, 0x0051, 0x7814, 0x2048, 0x080c,
-	0x0fd4, 0x080c, 0x8f6c, 0x012e, 0x009e, 0x00de, 0x0005, 0x60c0,
-	0x8004, 0x9084, 0x0003, 0x9005, 0x0130, 0x9082, 0x0004, 0x20a3,
-	0x0000, 0x8000, 0x1de0, 0x0005, 0x080c, 0x8d05, 0x7003, 0x7800,
-	0x7808, 0x8007, 0x700a, 0x60c3, 0x0008, 0x0804, 0x8f6c, 0x00d6,
-	0x00e6, 0x080c, 0x8d50, 0x7814, 0x9084, 0xff00, 0x2073, 0x0200,
-	0x8e70, 0x8e70, 0x9095, 0x0010, 0x2272, 0x8e70, 0x2073, 0x0034,
-	0x8e70, 0x2069, 0x1805, 0x20a9, 0x0004, 0x2d76, 0x8d68, 0x8e70,
-	0x1f04, 0x8ab5, 0x2069, 0x1801, 0x20a9, 0x0004, 0x2d76, 0x8d68,
-	0x8e70, 0x1f04, 0x8abe, 0x2069, 0x1983, 0x9086, 0xdf00, 0x0110,
-	0x2069, 0x199d, 0x20a9, 0x001a, 0x9e86, 0x0260, 0x1148, 0x00c6,
-	0x2061, 0x0200, 0x6010, 0x8000, 0x6012, 0x00ce, 0x2071, 0x0240,
-	0x2d04, 0x8007, 0x2072, 0x8d68, 0x8e70, 0x1f04, 0x8acc, 0x60c3,
-	0x004c, 0x080c, 0x8f6c, 0x00ee, 0x00de, 0x0005, 0x080c, 0x8d05,
-	0x7003, 0x6300, 0x7007, 0x0028, 0x7808, 0x700e, 0x60c3, 0x0008,
-	0x0804, 0x8f6c, 0x00d6, 0x0026, 0x0016, 0x080c, 0x8d50, 0x7003,
-	0x0200, 0x7814, 0x700e, 0x00e6, 0x9ef0, 0x0004, 0x2009, 0x0001,
-	0x2011, 0x000c, 0x2073, 0x0800, 0x8e70, 0x2073, 0x0000, 0x00ee,
-	0x7206, 0x710a, 0x62c2, 0x080c, 0x8f6c, 0x001e, 0x002e, 0x00de,
-	0x0005, 0x2001, 0x1817, 0x2004, 0x609a, 0x0804, 0x8f6c, 0x080c,
-	0x8d05, 0x7003, 0x5200, 0x2069, 0x1853, 0x6804, 0xd084, 0x0130,
-	0x6828, 0x0016, 0x080c, 0x2470, 0x710e, 0x001e, 0x20a9, 0x0004,
-	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250,
-	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x0254, 0x4003,
-	0x080c, 0x9b59, 0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001,
-	0x181e, 0x2004, 0x7032, 0x2001, 0x181f, 0x2004, 0x7036, 0x0030,
-	0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x7036, 0x60c3, 0x001c,
-	0x0804, 0x8f6c, 0x080c, 0x8d05, 0x7003, 0x0500, 0x080c, 0x9b59,
-	0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181e, 0x2004,
-	0x700a, 0x2001, 0x181f, 0x2004, 0x700e, 0x0030, 0x2001, 0x1817,
-	0x2004, 0x9084, 0x00ff, 0x700e, 0x20a9, 0x0004, 0x20e1, 0x0001,
-	0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003, 0x60c3,
-	0x0010, 0x0804, 0x8f6c, 0x080c, 0x8d05, 0x9006, 0x080c, 0x6630,
-	0xb8a0, 0x9086, 0x007e, 0x1130, 0x7003, 0x0400, 0x620c, 0xc2b4,
-	0x620e, 0x0058, 0x7814, 0x0096, 0x904d, 0x0120, 0x9006, 0xa89a,
-	0xa8a6, 0xa8aa, 0x009e, 0x7003, 0x0300, 0xb8a0, 0x9086, 0x007e,
-	0x1904, 0x8be6, 0x00d6, 0x2069, 0x193c, 0x2001, 0x1836, 0x2004,
-	0xd0a4, 0x0178, 0x6800, 0x700a, 0x6808, 0x9084, 0x2000, 0x7012,
-	0x680c, 0x7016, 0x701f, 0x2710, 0x6818, 0x7022, 0x681c, 0x7026,
-	0x0080, 0x6800, 0x700a, 0x6804, 0x700e, 0x6808, 0x080c, 0x7096,
-	0x1118, 0x9084, 0x37ff, 0x0010, 0x9084, 0x3fff, 0x7012, 0x680c,
-	0x7016, 0x00de, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805,
-	0x20e9, 0x0000, 0x20a1, 0x0256, 0x4003, 0x20a9, 0x0004, 0x2099,
-	0x1801, 0x20a1, 0x025a, 0x4003, 0x00d6, 0x080c, 0x97d3, 0x2069,
-	0x1944, 0x2071, 0x024e, 0x6800, 0xc0dd, 0x7002, 0x080c, 0x538c,
-	0xd0e4, 0x0110, 0x680c, 0x700e, 0x00de, 0x04a0, 0x2001, 0x1836,
-	0x2004, 0xd0a4, 0x0168, 0x0016, 0x2009, 0x0002, 0x60e0, 0x9106,
-	0x0130, 0x2100, 0x60e3, 0x0000, 0x080c, 0x24b1, 0x61e2, 0x001e,
-	0x20e1, 0x0001, 0x2099, 0x193c, 0x20e9, 0x0000, 0x20a1, 0x024e,
-	0x20a9, 0x0008, 0x4003, 0x20a9, 0x0004, 0x2099, 0x1805, 0x20a1,
-	0x0256, 0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x025a,
-	0x4003, 0x080c, 0x97d3, 0x20a1, 0x024e, 0x20a9, 0x0008, 0x2099,
-	0x1944, 0x4003, 0x60c3, 0x0074, 0x0804, 0x8f6c, 0x080c, 0x8d05,
-	0x7003, 0x2010, 0x7007, 0x0014, 0x700b, 0x0800, 0x700f, 0x2000,
-	0x9006, 0x00f6, 0x2079, 0x1853, 0x7904, 0x00fe, 0xd1ac, 0x1110,
-	0x9085, 0x0020, 0x0010, 0x9085, 0x0010, 0x9085, 0x0002, 0x00d6,
-	0x0804, 0x8cb5, 0x7026, 0x60c3, 0x0014, 0x0804, 0x8f6c, 0x080c,
-	0x8d05, 0x7003, 0x5000, 0x0804, 0x8b95, 0x080c, 0x8d05, 0x7003,
-	0x2110, 0x7007, 0x0014, 0x60c3, 0x0014, 0x0804, 0x8f6c, 0x080c,
-	0x8d47, 0x0010, 0x080c, 0x8d50, 0x7003, 0x0200, 0x60c3, 0x0004,
-	0x0804, 0x8f6c, 0x080c, 0x8d50, 0x7003, 0x0100, 0x700b, 0x0003,
-	0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804, 0x8f6c, 0x080c, 0x8d50,
-	0x7003, 0x0200, 0x0804, 0x8b95, 0x080c, 0x8d50, 0x7003, 0x0100,
-	0x782c, 0x9005, 0x0110, 0x700a, 0x0010, 0x700b, 0x0003, 0x7814,
-	0x700e, 0x60c3, 0x0008, 0x0804, 0x8f6c, 0x00d6, 0x080c, 0x8d50,
-	0x7003, 0x0210, 0x7007, 0x0014, 0x700b, 0x0800, 0xb894, 0x9086,
-	0x0014, 0x1198, 0xb99c, 0x9184, 0x0030, 0x0190, 0xb998, 0x9184,
-	0xc000, 0x1140, 0xd1ec, 0x0118, 0x700f, 0x2100, 0x0058, 0x700f,
-	0x0100, 0x0040, 0x700f, 0x0400, 0x0028, 0x700f, 0x0700, 0x0010,
-	0x700f, 0x0800, 0x00f6, 0x2079, 0x1853, 0x7904, 0x00fe, 0xd1ac,
-	0x1110, 0x9085, 0x0020, 0x0010, 0x9085, 0x0010, 0x2009, 0x1875,
-	0x210c, 0xd184, 0x1110, 0x9085, 0x0002, 0x0026, 0x2009, 0x1873,
-	0x210c, 0xd1e4, 0x0150, 0xc0c5, 0xbac4, 0xd28c, 0x1108, 0xc0cd,
-	0x9094, 0x0030, 0x9296, 0x0010, 0x0140, 0xd1ec, 0x0130, 0x9094,
-	0x0030, 0x9296, 0x0010, 0x0108, 0xc0bd, 0x002e, 0x7026, 0x60c3,
-	0x0014, 0x00de, 0x0804, 0x8f6c, 0x080c, 0x8d50, 0x7003, 0x0210,
-	0x7007, 0x0014, 0x700f, 0x0100, 0x60c3, 0x0014, 0x0804, 0x8f6c,
-	0x080c, 0x8d50, 0x7003, 0x0200, 0x0804, 0x8b1b, 0x080c, 0x8d50,
+	0x8d39, 0x20e9, 0x0000, 0x2001, 0x197b, 0x2003, 0x0000, 0x7814,
+	0x2048, 0xa814, 0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0,
+	0xa85c, 0x9080, 0x001b, 0x2098, 0x2001, 0x197b, 0x0016, 0x200c,
+	0x2001, 0x0001, 0x080c, 0x2060, 0x080c, 0xc5cd, 0x9006, 0x080c,
+	0x2060, 0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c28, 0x04d9,
+	0x080c, 0x8fa0, 0x012e, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x8d84, 0x20e9, 0x0000, 0x2001,
+	0x197b, 0x2003, 0x0000, 0x7814, 0x2048, 0xa86f, 0x0200, 0xa873,
+	0x0000, 0xa814, 0x8003, 0x60c2, 0xa830, 0x20a8, 0xa860, 0x20e0,
+	0xa85c, 0x9080, 0x001b, 0x2098, 0x2001, 0x197b, 0x0016, 0x200c,
+	0x080c, 0xc5cd, 0x001e, 0xa804, 0x9005, 0x0110, 0x2048, 0x0c60,
+	0x0051, 0x7814, 0x2048, 0x080c, 0x0fe1, 0x080c, 0x8fa0, 0x012e,
+	0x009e, 0x00de, 0x0005, 0x60c0, 0x8004, 0x9084, 0x0003, 0x9005,
+	0x0130, 0x9082, 0x0004, 0x20a3, 0x0000, 0x8000, 0x1de0, 0x0005,
+	0x080c, 0x8d39, 0x7003, 0x7800, 0x7808, 0x8007, 0x700a, 0x60c3,
+	0x0008, 0x0804, 0x8fa0, 0x00d6, 0x00e6, 0x080c, 0x8d84, 0x7814,
+	0x9084, 0xff00, 0x2073, 0x0200, 0x8e70, 0x8e70, 0x9095, 0x0010,
+	0x2272, 0x8e70, 0x2073, 0x0034, 0x8e70, 0x2069, 0x1805, 0x20a9,
+	0x0004, 0x2d76, 0x8d68, 0x8e70, 0x1f04, 0x8ae9, 0x2069, 0x1801,
+	0x20a9, 0x0004, 0x2d76, 0x8d68, 0x8e70, 0x1f04, 0x8af2, 0x2069,
+	0x198b, 0x9086, 0xdf00, 0x0110, 0x2069, 0x19a5, 0x20a9, 0x001a,
+	0x9e86, 0x0260, 0x1148, 0x00c6, 0x2061, 0x0200, 0x6010, 0x8000,
+	0x6012, 0x00ce, 0x2071, 0x0240, 0x2d04, 0x8007, 0x2072, 0x8d68,
+	0x8e70, 0x1f04, 0x8b00, 0x60c3, 0x004c, 0x080c, 0x8fa0, 0x00ee,
+	0x00de, 0x0005, 0x080c, 0x8d39, 0x7003, 0x6300, 0x7007, 0x0028,
+	0x7808, 0x700e, 0x60c3, 0x0008, 0x0804, 0x8fa0, 0x00d6, 0x0026,
+	0x0016, 0x080c, 0x8d84, 0x7003, 0x0200, 0x7814, 0x700e, 0x00e6,
+	0x9ef0, 0x0004, 0x2009, 0x0001, 0x2011, 0x000c, 0x2073, 0x0800,
+	0x8e70, 0x2073, 0x0000, 0x00ee, 0x7206, 0x710a, 0x62c2, 0x080c,
+	0x8fa0, 0x001e, 0x002e, 0x00de, 0x0005, 0x2001, 0x1817, 0x2004,
+	0x609a, 0x0804, 0x8fa0, 0x080c, 0x8d39, 0x7003, 0x5200, 0x2069,
+	0x185b, 0x6804, 0xd084, 0x0130, 0x6828, 0x0016, 0x080c, 0x248c,
+	0x710e, 0x001e, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805,
+	0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003, 0x20a9, 0x0004, 0x2099,
+	0x1801, 0x20a1, 0x0254, 0x4003, 0x080c, 0x9b65, 0x1120, 0xb8a0,
+	0x9082, 0x007f, 0x0248, 0x2001, 0x181e, 0x2004, 0x7032, 0x2001,
+	0x181f, 0x2004, 0x7036, 0x0030, 0x2001, 0x1817, 0x2004, 0x9084,
+	0x00ff, 0x7036, 0x60c3, 0x001c, 0x0804, 0x8fa0, 0x080c, 0x8d39,
+	0x7003, 0x0500, 0x080c, 0x9b65, 0x1120, 0xb8a0, 0x9082, 0x007f,
+	0x0248, 0x2001, 0x181e, 0x2004, 0x700a, 0x2001, 0x181f, 0x2004,
+	0x700e, 0x0030, 0x2001, 0x1817, 0x2004, 0x9084, 0x00ff, 0x700e,
+	0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000,
+	0x20a1, 0x0250, 0x4003, 0x60c3, 0x0010, 0x0804, 0x8fa0, 0x080c,
+	0x8d39, 0x9006, 0x080c, 0x6654, 0xb8a0, 0x9086, 0x007e, 0x1130,
+	0x7003, 0x0400, 0x620c, 0xc2b4, 0x620e, 0x0058, 0x7814, 0x0096,
+	0x904d, 0x0120, 0x9006, 0xa89a, 0xa8a6, 0xa8aa, 0x009e, 0x7003,
+	0x0300, 0xb8a0, 0x9086, 0x007e, 0x1904, 0x8c1a, 0x00d6, 0x2069,
+	0x1944, 0x2001, 0x1836, 0x2004, 0xd0a4, 0x0178, 0x6800, 0x700a,
+	0x6808, 0x9084, 0x2000, 0x7012, 0x680c, 0x7016, 0x701f, 0x2710,
+	0x6818, 0x7022, 0x681c, 0x7026, 0x0080, 0x6800, 0x700a, 0x6804,
+	0x700e, 0x6808, 0x080c, 0x70ba, 0x1118, 0x9084, 0x37ff, 0x0010,
+	0x9084, 0x3fff, 0x7012, 0x680c, 0x7016, 0x00de, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256,
+	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003,
+	0x00d6, 0x080c, 0x97df, 0x2069, 0x194c, 0x2071, 0x024e, 0x6800,
+	0xc0dd, 0x7002, 0x080c, 0x53ac, 0xd0e4, 0x0110, 0x680c, 0x700e,
+	0x00de, 0x04a0, 0x2001, 0x1836, 0x2004, 0xd0a4, 0x0168, 0x0016,
+	0x2009, 0x0002, 0x60e0, 0x9106, 0x0130, 0x2100, 0x60e3, 0x0000,
+	0x080c, 0x24cd, 0x61e2, 0x001e, 0x20e1, 0x0001, 0x2099, 0x1944,
+	0x20e9, 0x0000, 0x20a1, 0x024e, 0x20a9, 0x0008, 0x4003, 0x20a9,
+	0x0004, 0x2099, 0x1805, 0x20a1, 0x0256, 0x4003, 0x20a9, 0x0004,
+	0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x080c, 0x97df, 0x20a1,
+	0x024e, 0x20a9, 0x0008, 0x2099, 0x194c, 0x4003, 0x60c3, 0x0074,
+	0x0804, 0x8fa0, 0x080c, 0x8d39, 0x7003, 0x2010, 0x7007, 0x0014,
+	0x700b, 0x0800, 0x700f, 0x2000, 0x9006, 0x00f6, 0x2079, 0x185b,
+	0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0x0010, 0x9085,
+	0x0010, 0x9085, 0x0002, 0x00d6, 0x0804, 0x8ce9, 0x7026, 0x60c3,
+	0x0014, 0x0804, 0x8fa0, 0x080c, 0x8d39, 0x7003, 0x5000, 0x0804,
+	0x8bc9, 0x080c, 0x8d39, 0x7003, 0x2110, 0x7007, 0x0014, 0x60c3,
+	0x0014, 0x0804, 0x8fa0, 0x080c, 0x8d7b, 0x0010, 0x080c, 0x8d84,
+	0x7003, 0x0200, 0x60c3, 0x0004, 0x0804, 0x8fa0, 0x080c, 0x8d84,
 	0x7003, 0x0100, 0x700b, 0x0003, 0x700f, 0x2a00, 0x60c3, 0x0008,
-	0x0804, 0x8f6c, 0x080c, 0x8d50, 0x7003, 0x0100, 0x700b, 0x000b,
-	0x60c3, 0x0008, 0x0804, 0x8f6c, 0x0026, 0x00d6, 0x0036, 0x0046,
-	0x2019, 0x3200, 0x2021, 0x0800, 0x0040, 0x0026, 0x00d6, 0x0036,
-	0x0046, 0x2019, 0x2200, 0x2021, 0x0100, 0x080c, 0x97e8, 0xb810,
-	0x9305, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6878, 0x700a,
-	0x687c, 0x700e, 0x9485, 0x0029, 0x7012, 0x004e, 0x003e, 0x00de,
-	0x080c, 0x8f60, 0x721a, 0x9f95, 0x0000, 0x7222, 0x7027, 0xffff,
-	0x2071, 0x024c, 0x002e, 0x0005, 0x0026, 0x080c, 0x97e8, 0x7003,
-	0x02ff, 0x7007, 0xfffc, 0x00d6, 0x2069, 0x1800, 0x6878, 0x700a,
-	0x687c, 0x700e, 0x00de, 0x7013, 0x2029, 0x0c10, 0x7003, 0x0100,
-	0x7007, 0x0000, 0x700b, 0xfc02, 0x700f, 0x0000, 0x0005, 0x0026,
-	0x00d6, 0x0036, 0x0046, 0x2019, 0x3300, 0x2021, 0x0800, 0x0040,
-	0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x2300, 0x2021, 0x0100,
-	0x080c, 0x97e8, 0xb810, 0x9305, 0x7002, 0xb814, 0x7006, 0x2069,
-	0x1800, 0xb810, 0x9005, 0x1140, 0xb814, 0x9005, 0x1128, 0x700b,
-	0x00ff, 0x700f, 0xfffe, 0x0020, 0x6878, 0x700a, 0x687c, 0x700e,
-	0x0000, 0x9485, 0x0098, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c,
-	0x8f60, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c,
-	0x002e, 0x0005, 0x080c, 0x8f60, 0x721a, 0x7a08, 0x7222, 0x7814,
-	0x7026, 0x2071, 0x024c, 0x002e, 0x0005, 0x00b6, 0x00c6, 0x00d6,
-	0x00e6, 0x00f6, 0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a,
-	0x0085, 0x0a0c, 0x0d65, 0x908a, 0x0092, 0x1a0c, 0x0d65, 0x6110,
-	0x2158, 0xb984, 0x2c78, 0x2061, 0x0100, 0x619a, 0x9082, 0x0085,
-	0x0033, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x8dbe,
-	0x8dcd, 0x8dd8, 0x8dbc, 0x8dbc, 0x8dbc, 0x8dbe, 0x8dbc, 0x8dbc,
-	0x8dbc, 0x8dbc, 0x8dbc, 0x8dbc, 0x080c, 0x0d65, 0x0411, 0x60c3,
-	0x0000, 0x0026, 0x080c, 0x27c1, 0x0228, 0x2011, 0x0101, 0x2204,
-	0xc0c5, 0x2012, 0x002e, 0x0804, 0x8f6c, 0x0431, 0x7808, 0x700a,
-	0x7814, 0x700e, 0x7017, 0xffff, 0x60c3, 0x000c, 0x0804, 0x8f6c,
-	0x0479, 0x7003, 0x0003, 0x7007, 0x0300, 0x60c3, 0x0004, 0x0804,
-	0x8f6c, 0x0026, 0x080c, 0x97e8, 0xb810, 0x9085, 0x8100, 0x7002,
-	0xb814, 0x7006, 0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e,
-	0x7013, 0x0009, 0x0804, 0x8d20, 0x0026, 0x080c, 0x97e8, 0xb810,
-	0x9085, 0x8400, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6878,
-	0x700a, 0x687c, 0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x8d82,
-	0x0026, 0x080c, 0x97e8, 0xb810, 0x9085, 0x8500, 0x7002, 0xb814,
+	0x0804, 0x8fa0, 0x080c, 0x8d84, 0x7003, 0x0200, 0x0804, 0x8bc9,
+	0x080c, 0x8d84, 0x7003, 0x0100, 0x782c, 0x9005, 0x0110, 0x700a,
+	0x0010, 0x700b, 0x0003, 0x7814, 0x700e, 0x60c3, 0x0008, 0x0804,
+	0x8fa0, 0x00d6, 0x080c, 0x8d84, 0x7003, 0x0210, 0x7007, 0x0014,
+	0x700b, 0x0800, 0xb894, 0x9086, 0x0014, 0x1198, 0xb99c, 0x9184,
+	0x0030, 0x0190, 0xb998, 0x9184, 0xc000, 0x1140, 0xd1ec, 0x0118,
+	0x700f, 0x2100, 0x0058, 0x700f, 0x0100, 0x0040, 0x700f, 0x0400,
+	0x0028, 0x700f, 0x0700, 0x0010, 0x700f, 0x0800, 0x00f6, 0x2079,
+	0x185b, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0x0010,
+	0x9085, 0x0010, 0x2009, 0x187d, 0x210c, 0xd184, 0x1110, 0x9085,
+	0x0002, 0x0026, 0x2009, 0x187b, 0x210c, 0xd1e4, 0x0150, 0xc0c5,
+	0xbac4, 0xd28c, 0x1108, 0xc0cd, 0x9094, 0x0030, 0x9296, 0x0010,
+	0x0140, 0xd1ec, 0x0130, 0x9094, 0x0030, 0x9296, 0x0010, 0x0108,
+	0xc0bd, 0x002e, 0x7026, 0x60c3, 0x0014, 0x00de, 0x0804, 0x8fa0,
+	0x080c, 0x8d84, 0x7003, 0x0210, 0x7007, 0x0014, 0x700f, 0x0100,
+	0x60c3, 0x0014, 0x0804, 0x8fa0, 0x080c, 0x8d84, 0x7003, 0x0200,
+	0x0804, 0x8b4f, 0x080c, 0x8d84, 0x7003, 0x0100, 0x700b, 0x0003,
+	0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804, 0x8fa0, 0x080c, 0x8d84,
+	0x7003, 0x0100, 0x700b, 0x000b, 0x60c3, 0x0008, 0x0804, 0x8fa0,
+	0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x3200, 0x2021, 0x0800,
+	0x0040, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019, 0x2200, 0x2021,
+	0x0100, 0x080c, 0x97f4, 0xb810, 0x9305, 0x7002, 0xb814, 0x7006,
+	0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x9485, 0x0029,
+	0x7012, 0x004e, 0x003e, 0x00de, 0x080c, 0x8f94, 0x721a, 0x9f95,
+	0x0000, 0x7222, 0x7027, 0xffff, 0x2071, 0x024c, 0x002e, 0x0005,
+	0x0026, 0x080c, 0x97f4, 0x7003, 0x02ff, 0x7007, 0xfffc, 0x00d6,
+	0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x00de, 0x7013,
+	0x2029, 0x0c10, 0x7003, 0x0100, 0x7007, 0x0000, 0x700b, 0xfc02,
+	0x700f, 0x0000, 0x0005, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019,
+	0x3300, 0x2021, 0x0800, 0x0040, 0x0026, 0x00d6, 0x0036, 0x0046,
+	0x2019, 0x2300, 0x2021, 0x0100, 0x080c, 0x97f4, 0xb810, 0x9305,
+	0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0xb810, 0x9005, 0x1140,
+	0xb814, 0x9005, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffe, 0x0020,
+	0x6878, 0x700a, 0x687c, 0x700e, 0x0000, 0x9485, 0x0098, 0x7012,
+	0x004e, 0x003e, 0x00de, 0x080c, 0x8f94, 0x721a, 0x7a08, 0x7222,
+	0x2f10, 0x7226, 0x2071, 0x024c, 0x002e, 0x0005, 0x080c, 0x8f94,
+	0x721a, 0x7a08, 0x7222, 0x7814, 0x7026, 0x2071, 0x024c, 0x002e,
+	0x0005, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2069, 0x0200,
+	0x2071, 0x0240, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0d65, 0x908a,
+	0x0092, 0x1a0c, 0x0d65, 0x6110, 0x2158, 0xb984, 0x2c78, 0x2061,
+	0x0100, 0x619a, 0x9082, 0x0085, 0x0033, 0x00fe, 0x00ee, 0x00de,
+	0x00ce, 0x00be, 0x0005, 0x8df2, 0x8e01, 0x8e0c, 0x8df0, 0x8df0,
+	0x8df0, 0x8df2, 0x8df0, 0x8df0, 0x8df0, 0x8df0, 0x8df0, 0x8df0,
+	0x080c, 0x0d65, 0x0411, 0x60c3, 0x0000, 0x0026, 0x080c, 0x27dd,
+	0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012, 0x002e, 0x0804,
+	0x8fa0, 0x0431, 0x7808, 0x700a, 0x7814, 0x700e, 0x7017, 0xffff,
+	0x60c3, 0x000c, 0x0804, 0x8fa0, 0x0479, 0x7003, 0x0003, 0x7007,
+	0x0300, 0x60c3, 0x0004, 0x0804, 0x8fa0, 0x0026, 0x080c, 0x97f4,
+	0xb810, 0x9085, 0x8100, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800,
+	0x6878, 0x700a, 0x687c, 0x700e, 0x7013, 0x0009, 0x0804, 0x8d54,
+	0x0026, 0x080c, 0x97f4, 0xb810, 0x9085, 0x8400, 0x7002, 0xb814,
 	0x7006, 0x2069, 0x1800, 0x6878, 0x700a, 0x687c, 0x700e, 0x2001,
-	0x0099, 0x7012, 0x0804, 0x8d82, 0x00b6, 0x00c6, 0x00d6, 0x00e6,
-	0x00f6, 0x2c78, 0x2069, 0x0200, 0x2071, 0x0240, 0x7804, 0x908a,
-	0x0040, 0x0a0c, 0x0d65, 0x908a, 0x0057, 0x1a0c, 0x0d65, 0x7910,
-	0x2158, 0xb984, 0x2061, 0x0100, 0x619a, 0x9082, 0x0040, 0x0033,
-	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x8e51, 0x8e51,
-	0x8e51, 0x8e77, 0x8e51, 0x8e51, 0x8e51, 0x8e51, 0x8e51, 0x8e51,
-	0x8e51, 0x9338, 0x9340, 0x9348, 0x9350, 0x8e51, 0x8e51, 0x8e51,
-	0x9330, 0x080c, 0x0d65, 0x6813, 0x0008, 0xba8c, 0x8210, 0xb8c4,
-	0xd084, 0x0128, 0x7a4e, 0x7b14, 0x7b52, 0x722e, 0x732a, 0x9294,
-	0x00ff, 0xba8e, 0x8217, 0x721a, 0xba10, 0x9295, 0x0600, 0x7202,
-	0xba14, 0x7206, 0x2069, 0x1800, 0x6a78, 0x720a, 0x6a7c, 0x720e,
-	0x7013, 0x0829, 0x2f10, 0x7222, 0x7027, 0xffff, 0x0005, 0x0016,
-	0x7814, 0x9084, 0x0700, 0x8007, 0x0013, 0x001e, 0x0005, 0x8e87,
-	0x8e87, 0x8e89, 0x8e87, 0x8e87, 0x8e87, 0x8ea3, 0x8e87, 0x080c,
-	0x0d65, 0x7914, 0x918c, 0x08ff, 0x918d, 0xf600, 0x7916, 0x2009,
-	0x0003, 0x00b9, 0x2069, 0x1853, 0x6804, 0xd0bc, 0x0130, 0x682c,
-	0x9084, 0x00ff, 0x8007, 0x7032, 0x0010, 0x7033, 0x3f00, 0x60c3,
-	0x0001, 0x0804, 0x8f6c, 0x2009, 0x0003, 0x0019, 0x7033, 0x7f00,
-	0x0cb0, 0x0016, 0x080c, 0x97e8, 0x001e, 0xb810, 0x9085, 0x0100,
-	0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6a78, 0x720a, 0x6a7c,
-	0x720e, 0x7013, 0x0888, 0x918d, 0x0008, 0x7116, 0x080c, 0x8f60,
-	0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x0005, 0x00b6, 0x0096,
-	0x00e6, 0x00d6, 0x00c6, 0x0056, 0x0046, 0x0036, 0x2061, 0x0100,
-	0x2071, 0x1800, 0x7810, 0x2058, 0xb8a0, 0x2028, 0xb910, 0xba14,
-	0x7378, 0x747c, 0x7820, 0x0002, 0x8eeb, 0x8eeb, 0x8eeb, 0x8eeb,
-	0x8eeb, 0x8eeb, 0x8eeb, 0x8eeb, 0x8eeb, 0x8eeb, 0x8eed, 0x8eeb,
-	0x8eeb, 0x8eeb, 0x8eeb, 0x080c, 0x0d65, 0xb884, 0x609e, 0x7814,
-	0x2048, 0xa87c, 0xd0fc, 0x0558, 0xaf90, 0x9784, 0xff00, 0x9105,
-	0x6062, 0x873f, 0x9784, 0xff00, 0x0006, 0x7814, 0x2048, 0xa878,
-	0xc0fc, 0x9005, 0x000e, 0x1160, 0xaf94, 0x87ff, 0x0198, 0x2039,
-	0x0098, 0x9705, 0x6072, 0x7808, 0x6082, 0x2f00, 0x6086, 0x0038,
-	0x9185, 0x2200, 0x6062, 0x6073, 0x0129, 0x6077, 0x0000, 0xb884,
-	0x609e, 0x0050, 0x2039, 0x0029, 0x9705, 0x6072, 0x0cc0, 0x9185,
-	0x0200, 0x6062, 0x6073, 0x2029, 0xa87c, 0xd0fc, 0x0118, 0xaf94,
-	0x87ff, 0x1120, 0x2f00, 0x6082, 0x7808, 0x6086, 0x6266, 0x636a,
-	0x646e, 0x6077, 0x0000, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e,
-	0x8007, 0x607a, 0x607f, 0x0000, 0xa848, 0x608a, 0xa844, 0x608e,
-	0xa838, 0x60c6, 0xa834, 0x60ca, 0xb86c, 0x60ce, 0x60af, 0x95d5,
-	0x60d7, 0x0000, 0x080c, 0x97c8, 0x2009, 0x07d0, 0x60c4, 0x9084,
-	0xfff0, 0x9005, 0x0110, 0x2009, 0x1b58, 0x080c, 0x81ef, 0x003e,
-	0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x009e, 0x00be, 0x0005,
-	0x7a40, 0x9294, 0x00ff, 0x8217, 0x0005, 0x00d6, 0x2069, 0x19b7,
-	0x686b, 0x0001, 0x00de, 0x0005, 0x60a3, 0x0056, 0x60a7, 0x9575,
-	0x00f1, 0x080c, 0x81e1, 0x0005, 0x0016, 0x2001, 0x180c, 0x200c,
-	0x9184, 0x0600, 0x9086, 0x0600, 0x0128, 0x0089, 0x080c, 0x81e1,
-	0x001e, 0x0005, 0xc1e5, 0x2001, 0x180c, 0x2102, 0x2001, 0x19b8,
-	0x2003, 0x0000, 0x2001, 0x19c3, 0x2003, 0x0000, 0x0c88, 0x0006,
-	0x0016, 0x0026, 0x2009, 0x1804, 0x2011, 0x0009, 0x080c, 0x289b,
-	0x002e, 0x001e, 0x000e, 0x0005, 0x0016, 0x00c6, 0x0006, 0x080c,
-	0x98bb, 0x0106, 0x2061, 0x0100, 0x61a4, 0x60a7, 0x95f5, 0x0016,
-	0x0026, 0x2009, 0x1804, 0x2011, 0x0008, 0x080c, 0x289b, 0x002e,
-	0x001e, 0x010e, 0x090c, 0x98d7, 0x000e, 0xa001, 0xa001, 0xa001,
-	0x61a6, 0x00ce, 0x001e, 0x0005, 0x00c6, 0x00d6, 0x0016, 0x0026,
-	0x2061, 0x0100, 0x2069, 0x0140, 0x080c, 0x7096, 0x1510, 0x2001,
-	0x19dc, 0x2004, 0x9005, 0x1904, 0x901b, 0x080c, 0x7137, 0x11a8,
-	0x2069, 0x0380, 0x6843, 0x0101, 0x6844, 0xd084, 0x1de8, 0x2061,
-	0x0100, 0x6020, 0xd0b4, 0x1120, 0x6024, 0xd084, 0x090c, 0x0d65,
-	0x6843, 0x0100, 0x080c, 0x81e1, 0x04b0, 0x00c6, 0x2061, 0x19b7,
-	0x00f0, 0x6904, 0x9194, 0x4000, 0x0598, 0x080c, 0x8f9c, 0x080c,
-	0x2862, 0x00c6, 0x2061, 0x19b7, 0x6134, 0x9192, 0x0008, 0x1278,
-	0x8108, 0x6136, 0x080c, 0x98bb, 0x6130, 0x080c, 0x98d7, 0x00ce,
-	0x81ff, 0x01c8, 0x080c, 0x81e1, 0x080c, 0x8f8f, 0x00a0, 0x080c,
-	0x98bb, 0x6130, 0x91e5, 0x0000, 0x0150, 0x080c, 0xd621, 0x080c,
-	0x81ea, 0x6003, 0x0001, 0x2009, 0x0014, 0x080c, 0x9c76, 0x080c,
-	0x98d7, 0x00ce, 0x0000, 0x002e, 0x001e, 0x00de, 0x00ce, 0x0005,
-	0x2001, 0x19dc, 0x2004, 0x9005, 0x1db0, 0x00c6, 0x2061, 0x19b7,
-	0x6134, 0x9192, 0x0003, 0x1ad8, 0x8108, 0x6136, 0x00ce, 0x080c,
-	0x81e1, 0x080c, 0x5b92, 0x2009, 0x1852, 0x2114, 0x8210, 0x220a,
-	0x0c10, 0x0096, 0x00c6, 0x00d6, 0x00e6, 0x0016, 0x0026, 0x080c,
-	0x81f7, 0x080c, 0x98bb, 0x2001, 0x0387, 0x2003, 0x0202, 0x2071,
-	0x19b7, 0x714c, 0x81ff, 0x0904, 0x90af, 0x2061, 0x0100, 0x2069,
-	0x0140, 0x080c, 0x7096, 0x11c0, 0x0036, 0x2019, 0x0002, 0x080c,
-	0x9269, 0x003e, 0x714c, 0x2160, 0x080c, 0xd621, 0x2009, 0x004a,
-	0x6003, 0x0003, 0x080c, 0x9c76, 0x2001, 0x0386, 0x2003, 0x5040,
-	0x080c, 0x7137, 0x0804, 0x90af, 0x6904, 0xd1f4, 0x0904, 0x90bc,
-	0x080c, 0x2862, 0x00c6, 0x704c, 0x9065, 0x090c, 0x0d65, 0x6020,
-	0x00ce, 0x9086, 0x0006, 0x1518, 0x61c8, 0x60c4, 0x9105, 0x11f8,
-	0x2009, 0x180c, 0x2104, 0xd0d4, 0x01d0, 0x6214, 0x9294, 0x1800,
-	0x1128, 0x6224, 0x9294, 0x0002, 0x1510, 0x0010, 0xc0d4, 0x200a,
-	0x6014, 0x9084, 0xe7fd, 0x9085, 0x0010, 0x6016, 0x704c, 0x2060,
-	0x080c, 0x88b8, 0x2009, 0x0049, 0x080c, 0x9c76, 0x0080, 0x0036,
-	0x2019, 0x0001, 0x080c, 0x9269, 0x003e, 0x714c, 0x2160, 0x080c,
-	0xd621, 0x2009, 0x004a, 0x6003, 0x0003, 0x080c, 0x9c76, 0x2001,
-	0x0387, 0x2003, 0x0200, 0x080c, 0x98d7, 0x002e, 0x001e, 0x00ee,
-	0x00de, 0x00ce, 0x009e, 0x0005, 0xd1ec, 0x1904, 0x9070, 0x0804,
-	0x9072, 0x0026, 0x00e6, 0x2071, 0x19b7, 0x706c, 0xd084, 0x01d0,
-	0xc084, 0x706e, 0x714c, 0x81ff, 0x01a8, 0x2071, 0x0100, 0x9188,
-	0x0008, 0x2114, 0x928e, 0x0006, 0x1138, 0x2009, 0x1984, 0x2011,
-	0x0012, 0x080c, 0x289b, 0x0030, 0x2009, 0x1984, 0x2011, 0x0016,
-	0x080c, 0x289b, 0x00ee, 0x002e, 0x0005, 0x9036, 0x2001, 0x19c1,
-	0x2004, 0x9005, 0x0128, 0x9c06, 0x0128, 0x2c30, 0x600c, 0x0cc8,
-	0x9085, 0x0001, 0x0005, 0x00f6, 0x2079, 0x19b7, 0x610c, 0x9006,
-	0x600e, 0x6044, 0xc0fc, 0x6046, 0x86ff, 0x1140, 0x7824, 0x9c06,
-	0x1118, 0x7826, 0x782a, 0x0050, 0x792a, 0x0040, 0x00c6, 0x2660,
-	0x610e, 0x00ce, 0x7824, 0x9c06, 0x1108, 0x7e26, 0x080c, 0x935b,
-	0x080c, 0xba31, 0x00fe, 0x0005, 0x080c, 0x8d05, 0x7003, 0x1200,
-	0x7838, 0x7012, 0x783c, 0x7016, 0x00c6, 0x7820, 0x9086, 0x0004,
-	0x1148, 0x7810, 0x9005, 0x0130, 0x00b6, 0x2058, 0xb810, 0xb914,
-	0x00be, 0x0020, 0x2061, 0x1800, 0x6078, 0x617c, 0x9084, 0x00ff,
-	0x700a, 0x710e, 0x00ce, 0x60c3, 0x002c, 0x0804, 0x8f6c, 0x080c,
-	0x8d05, 0x7003, 0x0f00, 0x7808, 0xd09c, 0x0128, 0xb810, 0x9084,
-	0x00ff, 0x700a, 0xb814, 0x700e, 0x60c3, 0x0008, 0x0804, 0x8f6c,
-	0x0156, 0x080c, 0x8d50, 0x7003, 0x0200, 0x2011, 0x1848, 0x63f0,
-	0x2312, 0x20a9, 0x0006, 0x2011, 0x1840, 0x2019, 0x1841, 0x9ef0,
-	0x0002, 0x2376, 0x8e70, 0x2276, 0x8e70, 0x9398, 0x0002, 0x9290,
-	0x0002, 0x1f04, 0x9159, 0x60c3, 0x001c, 0x015e, 0x0804, 0x8f6c,
-	0x0016, 0x0026, 0x080c, 0x8d2c, 0x080c, 0x8d3e, 0x9e80, 0x0004,
-	0x20e9, 0x0000, 0x20a0, 0x7814, 0x0096, 0x2048, 0xa800, 0x2048,
-	0xa860, 0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098, 0x009e, 0x7808,
-	0x9088, 0x0002, 0x21a8, 0x9192, 0x0010, 0x1250, 0x4003, 0x9080,
-	0x0004, 0x8003, 0x60c2, 0x080c, 0x8f6c, 0x002e, 0x001e, 0x0005,
-	0x20a9, 0x0010, 0x4003, 0x080c, 0x97d3, 0x20a1, 0x0240, 0x22a8,
-	0x4003, 0x0c68, 0x080c, 0x8d05, 0x7003, 0x6200, 0x7808, 0x700e,
-	0x60c3, 0x0008, 0x0804, 0x8f6c, 0x0016, 0x0026, 0x080c, 0x8d05,
-	0x20e9, 0x0000, 0x20a1, 0x024c, 0x7814, 0x0096, 0x2048, 0xa800,
-	0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0023, 0x2098, 0x009e,
-	0x7808, 0x9088, 0x0002, 0x21a8, 0x4003, 0x8003, 0x60c2, 0x080c,
-	0x8f6c, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00c6, 0x0006, 0x0126,
-	0x2091, 0x8000, 0x2071, 0x19b7, 0x7010, 0x2060, 0x8cff, 0x0188,
-	0x080c, 0xba57, 0x1110, 0x080c, 0xa581, 0x600c, 0x0006, 0x080c,
-	0xbcd3, 0x600f, 0x0000, 0x080c, 0x9bda, 0x080c, 0x935b, 0x00ce,
-	0x0c68, 0x2c00, 0x7012, 0x700e, 0x012e, 0x000e, 0x00ce, 0x00ee,
-	0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066,
-	0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001, 0x180c, 0x200c,
-	0x918c, 0xe7ff, 0x2102, 0x2069, 0x0100, 0x2079, 0x0140, 0x2071,
-	0x19b7, 0x7030, 0x2060, 0x8cff, 0x0548, 0x080c, 0x8f9c, 0x6ac0,
-	0x68c3, 0x0000, 0x080c, 0x81ea, 0x00c6, 0x2061, 0x0100, 0x080c,
-	0x97ec, 0x00ce, 0x20a9, 0x01f4, 0x04b1, 0x080c, 0x885d, 0x6044,
-	0xd0ac, 0x1128, 0x2001, 0x1958, 0x2004, 0x604a, 0x0020, 0x2009,
-	0x0013, 0x080c, 0x9c76, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce,
-	0x00de, 0x00ee, 0x00fe, 0x015e, 0x012e, 0x0005, 0x2001, 0x1800,
-	0x2004, 0x9096, 0x0001, 0x0d78, 0x9096, 0x0004, 0x0d60, 0x080c,
-	0x81ea, 0x6814, 0x9084, 0x0001, 0x0110, 0x68a7, 0x95f5, 0x6817,
-	0x0008, 0x68c3, 0x0000, 0x2011, 0x5b3c, 0x080c, 0x8138, 0x20a9,
-	0x01f4, 0x0009, 0x08c0, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004,
-	0x7804, 0x9084, 0x4000, 0x190c, 0x2862, 0x0090, 0xd084, 0x0118,
-	0x6827, 0x0001, 0x0010, 0x1f04, 0x924b, 0x7804, 0x9084, 0x1000,
-	0x0138, 0x2001, 0x0100, 0x080c, 0x2852, 0x9006, 0x080c, 0x2852,
-	0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066,
-	0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2001, 0x180c, 0x200c,
-	0x918c, 0xdbff, 0x2102, 0x2069, 0x0100, 0x2079, 0x0140, 0x2071,
-	0x0380, 0x701c, 0x0006, 0x701f, 0x0202, 0x2071, 0x19b7, 0x704c,
-	0x2060, 0x8cff, 0x0904, 0x930a, 0x9386, 0x0002, 0x1128, 0x6814,
-	0x9084, 0x0002, 0x0904, 0x930a, 0x68af, 0x95f5, 0x6817, 0x0010,
-	0x2009, 0x00fa, 0x8109, 0x1df0, 0x69c6, 0x68cb, 0x0008, 0x080c,
-	0x81f7, 0x080c, 0x1c87, 0x0046, 0x2009, 0x00a5, 0x080c, 0x0e3d,
-	0x2021, 0x0169, 0x2404, 0x9084, 0x000f, 0x9086, 0x0004, 0x11f8,
-	0x68af, 0x95f5, 0x68c6, 0x68cb, 0x0008, 0x00e6, 0x00f6, 0x2079,
-	0x0090, 0x2071, 0x19b7, 0x6814, 0x9084, 0x1984, 0x9085, 0x0012,
-	0x6816, 0x782b, 0x0008, 0x7057, 0x0000, 0x00fe, 0x00ee, 0x9386,
-	0x0002, 0x1128, 0x7884, 0x9005, 0x1110, 0x7887, 0x0001, 0x0016,
-	0x2009, 0x0040, 0x080c, 0x2063, 0x001e, 0x2009, 0x0000, 0x080c,
-	0x0e3d, 0x004e, 0x20a9, 0x03e8, 0x6824, 0xd094, 0x0140, 0x6827,
-	0x0004, 0x7804, 0x9084, 0x4000, 0x190c, 0x2862, 0x0090, 0xd08c,
-	0x0118, 0x6827, 0x0002, 0x0010, 0x1f04, 0x92dc, 0x7804, 0x9084,
-	0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2852, 0x9006, 0x080c,
-	0x2852, 0x6827, 0x4000, 0x6824, 0x83ff, 0x1160, 0x2009, 0x0049,
-	0x080c, 0x88b8, 0x6044, 0xd0ac, 0x1118, 0x6003, 0x0002, 0x0010,
-	0x080c, 0x9c76, 0x000e, 0x2071, 0x0380, 0xd08c, 0x1110, 0x701f,
+	0x0099, 0x7012, 0x0804, 0x8db6, 0x0026, 0x080c, 0x97f4, 0xb810,
+	0x9085, 0x8500, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6878,
+	0x700a, 0x687c, 0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x8db6,
+	0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2c78, 0x2069, 0x0200,
+	0x2071, 0x0240, 0x7804, 0x908a, 0x0040, 0x0a0c, 0x0d65, 0x908a,
+	0x0057, 0x1a0c, 0x0d65, 0x7910, 0x2158, 0xb984, 0x2061, 0x0100,
+	0x619a, 0x9082, 0x0040, 0x0033, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x00be, 0x0005, 0x8e85, 0x8e85, 0x8e85, 0x8eab, 0x8e85, 0x8e85,
+	0x8e85, 0x8e85, 0x8e85, 0x8e85, 0x8e85, 0x9340, 0x9348, 0x9350,
+	0x9358, 0x8e85, 0x8e85, 0x8e85, 0x9338, 0x080c, 0x0d65, 0x6813,
+	0x0008, 0xba8c, 0x8210, 0xb8c4, 0xd084, 0x0128, 0x7a4e, 0x7b14,
+	0x7b52, 0x722e, 0x732a, 0x9294, 0x00ff, 0xba8e, 0x8217, 0x721a,
+	0xba10, 0x9295, 0x0600, 0x7202, 0xba14, 0x7206, 0x2069, 0x1800,
+	0x6a78, 0x720a, 0x6a7c, 0x720e, 0x7013, 0x0829, 0x2f10, 0x7222,
+	0x7027, 0xffff, 0x0005, 0x0016, 0x7814, 0x9084, 0x0700, 0x8007,
+	0x0013, 0x001e, 0x0005, 0x8ebb, 0x8ebb, 0x8ebd, 0x8ebb, 0x8ebb,
+	0x8ebb, 0x8ed7, 0x8ebb, 0x080c, 0x0d65, 0x7914, 0x918c, 0x08ff,
+	0x918d, 0xf600, 0x7916, 0x2009, 0x0003, 0x00b9, 0x2069, 0x185b,
+	0x6804, 0xd0bc, 0x0130, 0x682c, 0x9084, 0x00ff, 0x8007, 0x7032,
+	0x0010, 0x7033, 0x3f00, 0x60c3, 0x0001, 0x0804, 0x8fa0, 0x2009,
+	0x0003, 0x0019, 0x7033, 0x7f00, 0x0cb0, 0x0016, 0x080c, 0x97f4,
+	0x001e, 0xb810, 0x9085, 0x0100, 0x7002, 0xb814, 0x7006, 0x2069,
+	0x1800, 0x6a78, 0x720a, 0x6a7c, 0x720e, 0x7013, 0x0888, 0x918d,
+	0x0008, 0x7116, 0x080c, 0x8f94, 0x721a, 0x7a08, 0x7222, 0x2f10,
+	0x7226, 0x0005, 0x00b6, 0x0096, 0x00e6, 0x00d6, 0x00c6, 0x0056,
+	0x0046, 0x0036, 0x2061, 0x0100, 0x2071, 0x1800, 0x7810, 0x2058,
+	0xb8a0, 0x2028, 0xb910, 0xba14, 0x7378, 0x747c, 0x7820, 0x0002,
+	0x8f1f, 0x8f1f, 0x8f1f, 0x8f1f, 0x8f1f, 0x8f1f, 0x8f1f, 0x8f1f,
+	0x8f1f, 0x8f1f, 0x8f21, 0x8f1f, 0x8f1f, 0x8f1f, 0x8f1f, 0x080c,
+	0x0d65, 0xb884, 0x609e, 0x7814, 0x2048, 0xa87c, 0xd0fc, 0x0558,
+	0xaf90, 0x9784, 0xff00, 0x9105, 0x6062, 0x873f, 0x9784, 0xff00,
+	0x0006, 0x7814, 0x2048, 0xa878, 0xc0fc, 0x9005, 0x000e, 0x1160,
+	0xaf94, 0x87ff, 0x0198, 0x2039, 0x0098, 0x9705, 0x6072, 0x7808,
+	0x6082, 0x2f00, 0x6086, 0x0038, 0x9185, 0x2200, 0x6062, 0x6073,
+	0x0129, 0x6077, 0x0000, 0xb884, 0x609e, 0x0050, 0x2039, 0x0029,
+	0x9705, 0x6072, 0x0cc0, 0x9185, 0x0200, 0x6062, 0x6073, 0x2029,
+	0xa87c, 0xd0fc, 0x0118, 0xaf94, 0x87ff, 0x1120, 0x2f00, 0x6082,
+	0x7808, 0x6086, 0x6266, 0x636a, 0x646e, 0x6077, 0x0000, 0xb88c,
+	0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000,
+	0xa848, 0x608a, 0xa844, 0x608e, 0xa838, 0x60c6, 0xa834, 0x60ca,
+	0xb86c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0x080c, 0x97d4,
+	0x2009, 0x07d0, 0x60c4, 0x9084, 0xfff0, 0x9005, 0x0110, 0x2009,
+	0x1b58, 0x080c, 0x8223, 0x003e, 0x004e, 0x005e, 0x00ce, 0x00de,
+	0x00ee, 0x009e, 0x00be, 0x0005, 0x7a40, 0x9294, 0x00ff, 0x8217,
+	0x0005, 0x00d6, 0x2069, 0x19bf, 0x686b, 0x0001, 0x00de, 0x0005,
+	0x60a3, 0x0056, 0x60a7, 0x9575, 0x00f1, 0x080c, 0x8215, 0x0005,
+	0x0016, 0x2001, 0x180c, 0x200c, 0x9184, 0x0600, 0x9086, 0x0600,
+	0x0128, 0x0089, 0x080c, 0x8215, 0x001e, 0x0005, 0xc1e5, 0x2001,
+	0x180c, 0x2102, 0x2001, 0x19c0, 0x2003, 0x0000, 0x2001, 0x19cb,
+	0x2003, 0x0000, 0x0c88, 0x0006, 0x0016, 0x0026, 0x2009, 0x1804,
+	0x2011, 0x0009, 0x080c, 0x28bb, 0x002e, 0x001e, 0x000e, 0x0005,
+	0x0016, 0x00c6, 0x0006, 0x080c, 0x98c7, 0x0106, 0x2061, 0x0100,
+	0x61a4, 0x60a7, 0x95f5, 0x0016, 0x0026, 0x2009, 0x1804, 0x2011,
+	0x0008, 0x080c, 0x28bb, 0x002e, 0x001e, 0x010e, 0x090c, 0x98e3,
+	0x000e, 0xa001, 0xa001, 0xa001, 0x61a6, 0x00ce, 0x001e, 0x0005,
+	0x00c6, 0x00d6, 0x0016, 0x0026, 0x2061, 0x0100, 0x2069, 0x0140,
+	0x080c, 0x70ba, 0x1510, 0x2001, 0x19e4, 0x2004, 0x9005, 0x1904,
+	0x904f, 0x080c, 0x715f, 0x11a8, 0x2069, 0x0380, 0x6843, 0x0101,
+	0x6844, 0xd084, 0x1de8, 0x2061, 0x0100, 0x6020, 0xd0b4, 0x1120,
+	0x6024, 0xd084, 0x090c, 0x0d65, 0x6843, 0x0100, 0x080c, 0x8215,
+	0x04b0, 0x00c6, 0x2061, 0x19bf, 0x00f0, 0x6904, 0x9194, 0x4000,
+	0x0598, 0x080c, 0x8fd0, 0x080c, 0x2882, 0x00c6, 0x2061, 0x19bf,
+	0x6134, 0x9192, 0x0008, 0x1278, 0x8108, 0x6136, 0x080c, 0x98c7,
+	0x6130, 0x080c, 0x98e3, 0x00ce, 0x81ff, 0x01c8, 0x080c, 0x8215,
+	0x080c, 0x8fc3, 0x00a0, 0x080c, 0x98c7, 0x6130, 0x91e5, 0x0000,
+	0x0150, 0x080c, 0xd659, 0x080c, 0x821e, 0x6003, 0x0001, 0x2009,
+	0x0014, 0x080c, 0x9c82, 0x080c, 0x98e3, 0x00ce, 0x0000, 0x002e,
+	0x001e, 0x00de, 0x00ce, 0x0005, 0x2001, 0x19e4, 0x2004, 0x9005,
+	0x1db0, 0x00c6, 0x2061, 0x19bf, 0x6134, 0x9192, 0x0003, 0x1ad8,
+	0x8108, 0x6136, 0x00ce, 0x080c, 0x8215, 0x080c, 0x5bb2, 0x2009,
+	0x185a, 0x2114, 0x8210, 0x220a, 0x0c10, 0x0096, 0x00c6, 0x00d6,
+	0x00e6, 0x0016, 0x0026, 0x080c, 0x822b, 0x080c, 0x98c7, 0x2001,
+	0x0387, 0x2003, 0x0202, 0x2071, 0x19bf, 0x714c, 0x81ff, 0x0904,
+	0x90e3, 0x2061, 0x0100, 0x2069, 0x0140, 0x080c, 0x70ba, 0x11c0,
+	0x0036, 0x2019, 0x0002, 0x080c, 0x929d, 0x003e, 0x714c, 0x2160,
+	0x080c, 0xd659, 0x2009, 0x004a, 0x6003, 0x0003, 0x080c, 0x9c82,
+	0x2001, 0x0386, 0x2003, 0x5040, 0x080c, 0x715f, 0x0804, 0x90e3,
+	0x6904, 0xd1f4, 0x0904, 0x90f0, 0x080c, 0x2882, 0x00c6, 0x704c,
+	0x9065, 0x090c, 0x0d65, 0x6020, 0x00ce, 0x9086, 0x0006, 0x1518,
+	0x61c8, 0x60c4, 0x9105, 0x11f8, 0x2009, 0x180c, 0x2104, 0xd0d4,
+	0x01d0, 0x6214, 0x9294, 0x1800, 0x1128, 0x6224, 0x9294, 0x0002,
+	0x1510, 0x0010, 0xc0d4, 0x200a, 0x6014, 0x9084, 0xe7fd, 0x9085,
+	0x0010, 0x6016, 0x704c, 0x2060, 0x080c, 0x88ec, 0x2009, 0x0049,
+	0x080c, 0x9c82, 0x0080, 0x0036, 0x2019, 0x0001, 0x080c, 0x929d,
+	0x003e, 0x714c, 0x2160, 0x080c, 0xd659, 0x2009, 0x004a, 0x6003,
+	0x0003, 0x080c, 0x9c82, 0x2001, 0x0387, 0x2003, 0x0200, 0x080c,
+	0x98e3, 0x002e, 0x001e, 0x00ee, 0x00de, 0x00ce, 0x009e, 0x0005,
+	0xd1ec, 0x1904, 0x90a4, 0x0804, 0x90a6, 0x0026, 0x00e6, 0x2071,
+	0x19bf, 0x706c, 0xd084, 0x01d0, 0xc084, 0x706e, 0x714c, 0x81ff,
+	0x01a8, 0x2071, 0x0100, 0x9188, 0x0008, 0x2114, 0x928e, 0x0006,
+	0x1138, 0x2009, 0x1984, 0x2011, 0x0012, 0x080c, 0x28bb, 0x0030,
+	0x2009, 0x1984, 0x2011, 0x0016, 0x080c, 0x28bb, 0x00ee, 0x002e,
+	0x0005, 0x9036, 0x2001, 0x19c9, 0x2004, 0x9005, 0x0128, 0x9c06,
+	0x0128, 0x2c30, 0x600c, 0x0cc8, 0x9085, 0x0001, 0x0005, 0x00f6,
+	0x2079, 0x19bf, 0x610c, 0x9006, 0x600e, 0x6044, 0xc0fc, 0x6046,
+	0x86ff, 0x1140, 0x7824, 0x9c06, 0x1118, 0x7826, 0x782a, 0x0050,
+	0x792a, 0x0040, 0x00c6, 0x2660, 0x610e, 0x00ce, 0x7824, 0x9c06,
+	0x1108, 0x7e26, 0x080c, 0x9363, 0x080c, 0xba5f, 0x00fe, 0x0005,
+	0x080c, 0x8d39, 0x7003, 0x1200, 0x7838, 0x7012, 0x783c, 0x7016,
+	0x00c6, 0x7820, 0x9086, 0x0004, 0x1148, 0x7810, 0x9005, 0x0130,
+	0x00b6, 0x2058, 0xb810, 0xb914, 0x00be, 0x0020, 0x2061, 0x1800,
+	0x6078, 0x617c, 0x9084, 0x00ff, 0x700a, 0x710e, 0x00ce, 0x60c3,
+	0x002c, 0x0804, 0x8fa0, 0x080c, 0x8d39, 0x7003, 0x0f00, 0x7808,
+	0xd09c, 0x0128, 0xb810, 0x9084, 0x00ff, 0x700a, 0xb814, 0x700e,
+	0x60c3, 0x0008, 0x0804, 0x8fa0, 0x0156, 0x080c, 0x8d84, 0x7003,
+	0x0200, 0x2011, 0x1848, 0x63f0, 0x2312, 0x20a9, 0x0006, 0x2011,
+	0x1840, 0x2019, 0x1841, 0x9ef0, 0x0002, 0x2376, 0x8e70, 0x2276,
+	0x8e70, 0x9398, 0x0002, 0x9290, 0x0002, 0x1f04, 0x918d, 0x60c3,
+	0x001c, 0x015e, 0x0804, 0x8fa0, 0x0016, 0x0026, 0x080c, 0x8d60,
+	0x080c, 0x8d72, 0x9e80, 0x0004, 0x20e9, 0x0000, 0x20a0, 0x7814,
+	0x0096, 0x2048, 0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c, 0x9080,
+	0x0021, 0x2098, 0x009e, 0x7808, 0x9088, 0x0002, 0x21a8, 0x9192,
+	0x0010, 0x1250, 0x4003, 0x9080, 0x0004, 0x8003, 0x60c2, 0x080c,
+	0x8fa0, 0x002e, 0x001e, 0x0005, 0x20a9, 0x0010, 0x4003, 0x080c,
+	0x97df, 0x20a1, 0x0240, 0x22a8, 0x4003, 0x0c68, 0x080c, 0x8d39,
+	0x7003, 0x6200, 0x7808, 0x700e, 0x60c3, 0x0008, 0x0804, 0x8fa0,
+	0x0016, 0x0026, 0x080c, 0x8d39, 0x20e9, 0x0000, 0x20a1, 0x024c,
+	0x7814, 0x0096, 0x2048, 0xa800, 0x2048, 0xa860, 0x20e0, 0xa85c,
+	0x9080, 0x0023, 0x2098, 0x009e, 0x7808, 0x9088, 0x0002, 0x21a8,
+	0x4003, 0x8003, 0x60c2, 0x080c, 0x8fa0, 0x002e, 0x001e, 0x0005,
+	0x00e6, 0x00c6, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19bf,
+	0x7010, 0x2060, 0x8cff, 0x0188, 0x080c, 0xba85, 0x1110, 0x080c,
+	0xa59c, 0x600c, 0x0006, 0x080c, 0xbd01, 0x600f, 0x0000, 0x080c,
+	0x9be6, 0x080c, 0x9363, 0x00ce, 0x0c68, 0x2c00, 0x7012, 0x700e,
+	0x012e, 0x000e, 0x00ce, 0x00ee, 0x0005, 0x0126, 0x0156, 0x00f6,
+	0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0026, 0x0016, 0x0006, 0x2091,
+	0x8000, 0x2001, 0x180c, 0x200c, 0x918c, 0xe7ff, 0x2102, 0x2069,
+	0x0100, 0x2079, 0x0140, 0x2071, 0x19bf, 0x7030, 0x2060, 0x8cff,
+	0x0548, 0x080c, 0x8fd0, 0x6ac0, 0x68c3, 0x0000, 0x080c, 0x821e,
+	0x00c6, 0x2061, 0x0100, 0x080c, 0x97f8, 0x00ce, 0x20a9, 0x01f4,
+	0x04b1, 0x080c, 0x8891, 0x6044, 0xd0ac, 0x1128, 0x2001, 0x1960,
+	0x2004, 0x604a, 0x0020, 0x2009, 0x0013, 0x080c, 0x9c82, 0x000e,
+	0x001e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x015e,
+	0x012e, 0x0005, 0x2001, 0x1800, 0x2004, 0x9096, 0x0001, 0x0d78,
+	0x9096, 0x0004, 0x0d60, 0x080c, 0x821e, 0x6814, 0x9084, 0x0001,
+	0x0110, 0x68a7, 0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000, 0x2011,
+	0x5b5c, 0x080c, 0x816c, 0x20a9, 0x01f4, 0x0009, 0x08c0, 0x6824,
+	0xd094, 0x0140, 0x6827, 0x0004, 0x7804, 0x9084, 0x4000, 0x190c,
+	0x2882, 0x0090, 0xd084, 0x0118, 0x6827, 0x0001, 0x0010, 0x1f04,
+	0x927f, 0x7804, 0x9084, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c,
+	0x2872, 0x9006, 0x080c, 0x2872, 0x0005, 0x0126, 0x0156, 0x00f6,
+	0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0026, 0x0016, 0x0006, 0x2091,
+	0x8000, 0x2001, 0x180c, 0x200c, 0x918c, 0xdbff, 0x2102, 0x2069,
+	0x0100, 0x2079, 0x0140, 0x2071, 0x0380, 0x701c, 0x0006, 0x701f,
+	0x0202, 0x2071, 0x19bf, 0x704c, 0x2060, 0x8cff, 0x0904, 0x9312,
+	0x9386, 0x0002, 0x1128, 0x6814, 0x9084, 0x0002, 0x0904, 0x9312,
+	0x68af, 0x95f5, 0x6817, 0x0010, 0x2009, 0x00fa, 0x8109, 0x1df0,
+	0x69c6, 0x68cb, 0x0008, 0x080c, 0x822b, 0x080c, 0x1c9f, 0x2001,
+	0x0032, 0x6920, 0xd1bc, 0x0130, 0x8001, 0x1dd8, 0x692c, 0x918d,
+	0x0008, 0x692e, 0x20a9, 0x03e8, 0x6824, 0xd094, 0x0140, 0x6827,
+	0x0004, 0x7804, 0x9084, 0x4000, 0x190c, 0x2882, 0x0090, 0xd08c,
+	0x0118, 0x6827, 0x0002, 0x0010, 0x1f04, 0x92e4, 0x7804, 0x9084,
+	0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2872, 0x9006, 0x080c,
+	0x2872, 0x6827, 0x4000, 0x6824, 0x83ff, 0x1160, 0x2009, 0x0049,
+	0x080c, 0x88ec, 0x6044, 0xd0ac, 0x1118, 0x6003, 0x0002, 0x0010,
+	0x080c, 0x9c82, 0x000e, 0x2071, 0x0380, 0xd08c, 0x1110, 0x701f,
 	0x0200, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee,
 	0x00fe, 0x015e, 0x012e, 0x0005, 0x00d6, 0x0126, 0x2091, 0x8000,
-	0x2069, 0x19b7, 0x6a06, 0x012e, 0x00de, 0x0005, 0x00d6, 0x0126,
-	0x2091, 0x8000, 0x2069, 0x19b7, 0x6a3e, 0x012e, 0x00de, 0x0005,
-	0x080c, 0x8e53, 0x785c, 0x7032, 0x7042, 0x7047, 0x1000, 0x00f8,
-	0x080c, 0x8e53, 0x785c, 0x7032, 0x7042, 0x7047, 0x4000, 0x00b8,
-	0x080c, 0x8e53, 0x785c, 0x7032, 0x7042, 0x7047, 0x2000, 0x0078,
-	0x080c, 0x8e53, 0x785c, 0x7032, 0x7042, 0x7047, 0x0400, 0x0038,
-	0x080c, 0x8e53, 0x785c, 0x7032, 0x7042, 0x7047, 0x0200, 0x60c3,
-	0x0020, 0x0804, 0x8f6c, 0x00e6, 0x2071, 0x19b7, 0x702c, 0x9005,
+	0x2069, 0x19bf, 0x6a06, 0x012e, 0x00de, 0x0005, 0x00d6, 0x0126,
+	0x2091, 0x8000, 0x2069, 0x19bf, 0x6a3e, 0x012e, 0x00de, 0x0005,
+	0x080c, 0x8e87, 0x785c, 0x7032, 0x7042, 0x7047, 0x1000, 0x00f8,
+	0x080c, 0x8e87, 0x785c, 0x7032, 0x7042, 0x7047, 0x4000, 0x00b8,
+	0x080c, 0x8e87, 0x785c, 0x7032, 0x7042, 0x7047, 0x2000, 0x0078,
+	0x080c, 0x8e87, 0x785c, 0x7032, 0x7042, 0x7047, 0x0400, 0x0038,
+	0x080c, 0x8e87, 0x785c, 0x7032, 0x7042, 0x7047, 0x0200, 0x60c3,
+	0x0020, 0x0804, 0x8fa0, 0x00e6, 0x2071, 0x19bf, 0x702c, 0x9005,
 	0x0110, 0x8001, 0x702e, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00d6,
 	0x00c6, 0x0076, 0x0066, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x19b7, 0x7620, 0x2660, 0x2678, 0x2039, 0x0001, 0x87ff, 0x0904,
-	0x9400, 0x8cff, 0x0904, 0x9400, 0x6020, 0x9086, 0x0006, 0x1904,
-	0x93fb, 0x88ff, 0x0138, 0x2800, 0x9c06, 0x1904, 0x93fb, 0x2039,
-	0x0000, 0x0050, 0x6010, 0x9b06, 0x1904, 0x93fb, 0x85ff, 0x0120,
-	0x605c, 0x9106, 0x1904, 0x93fb, 0x7030, 0x9c06, 0x15b0, 0x2069,
+	0x19bf, 0x7620, 0x2660, 0x2678, 0x2039, 0x0001, 0x87ff, 0x0904,
+	0x9408, 0x8cff, 0x0904, 0x9408, 0x6020, 0x9086, 0x0006, 0x1904,
+	0x9403, 0x88ff, 0x0138, 0x2800, 0x9c06, 0x1904, 0x9403, 0x2039,
+	0x0000, 0x0050, 0x6010, 0x9b06, 0x1904, 0x9403, 0x85ff, 0x0120,
+	0x605c, 0x9106, 0x1904, 0x9403, 0x7030, 0x9c06, 0x15b0, 0x2069,
 	0x0100, 0x68c0, 0x9005, 0x1160, 0x6824, 0xd084, 0x0148, 0x6827,
-	0x0001, 0x080c, 0x81ea, 0x080c, 0x9485, 0x7033, 0x0000, 0x0428,
-	0x080c, 0x81ea, 0x6820, 0xd0b4, 0x0110, 0x68a7, 0x95f5, 0x6817,
-	0x0008, 0x68c3, 0x0000, 0x080c, 0x9485, 0x7033, 0x0000, 0x0036,
+	0x0001, 0x080c, 0x821e, 0x080c, 0x948d, 0x7033, 0x0000, 0x0428,
+	0x080c, 0x821e, 0x6820, 0xd0b4, 0x0110, 0x68a7, 0x95f5, 0x6817,
+	0x0008, 0x68c3, 0x0000, 0x080c, 0x948d, 0x7033, 0x0000, 0x0036,
 	0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100,
-	0x080c, 0x2852, 0x9006, 0x080c, 0x2852, 0x2069, 0x0100, 0x6824,
+	0x080c, 0x2872, 0x9006, 0x080c, 0x2872, 0x2069, 0x0100, 0x6824,
 	0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x7020, 0x9c36, 0x1110,
 	0x660c, 0x7622, 0x701c, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118,
 	0x2f00, 0x701e, 0x0010, 0x701f, 0x0000, 0x660c, 0x0066, 0x2c00,
 	0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x89ff, 0x1168, 0x600f,
-	0x0000, 0x6014, 0x0096, 0x2048, 0x080c, 0xb840, 0x0110, 0x080c,
-	0xd22f, 0x009e, 0x080c, 0x9c14, 0x080c, 0x935b, 0x88ff, 0x1190,
-	0x00ce, 0x0804, 0x9376, 0x2c78, 0x600c, 0x2060, 0x0804, 0x9376,
+	0x0000, 0x6014, 0x0096, 0x2048, 0x080c, 0xb86e, 0x0110, 0x080c,
+	0xd267, 0x009e, 0x080c, 0x9c20, 0x080c, 0x9363, 0x88ff, 0x1190,
+	0x00ce, 0x0804, 0x937e, 0x2c78, 0x600c, 0x2060, 0x0804, 0x937e,
 	0x9006, 0x012e, 0x000e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee,
 	0x00fe, 0x0005, 0x601b, 0x0000, 0x00ce, 0x98c5, 0x0001, 0x0c88,
 	0x00f6, 0x00e6, 0x00d6, 0x0096, 0x00c6, 0x0066, 0x0026, 0x0006,
-	0x0126, 0x2091, 0x8000, 0x2071, 0x19b7, 0x7648, 0x2660, 0x2678,
-	0x8cff, 0x0904, 0x9474, 0x6020, 0x9086, 0x0006, 0x1904, 0x946f,
-	0x87ff, 0x0128, 0x2700, 0x9c06, 0x1904, 0x946f, 0x0040, 0x6010,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x19bf, 0x7648, 0x2660, 0x2678,
+	0x8cff, 0x0904, 0x947c, 0x6020, 0x9086, 0x0006, 0x1904, 0x9477,
+	0x87ff, 0x0128, 0x2700, 0x9c06, 0x1904, 0x9477, 0x0040, 0x6010,
 	0x9b06, 0x15e8, 0x85ff, 0x0118, 0x605c, 0x9106, 0x15c0, 0x704c,
-	0x9c06, 0x1168, 0x0036, 0x2019, 0x0001, 0x080c, 0x9269, 0x703f,
+	0x9c06, 0x1168, 0x0036, 0x2019, 0x0001, 0x080c, 0x929d, 0x703f,
 	0x0000, 0x9006, 0x704e, 0x706a, 0x7052, 0x706e, 0x003e, 0x7048,
 	0x9c36, 0x1110, 0x660c, 0x764a, 0x7044, 0x9c36, 0x1140, 0x2c00,
 	0x9f36, 0x0118, 0x2f00, 0x7046, 0x0010, 0x7047, 0x0000, 0x660c,
 	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
-	0x0000, 0x6014, 0x2048, 0x080c, 0xb840, 0x0110, 0x080c, 0xd22f,
-	0x080c, 0x9c14, 0x87ff, 0x1198, 0x00ce, 0x0804, 0x9420, 0x2c78,
-	0x600c, 0x2060, 0x0804, 0x9420, 0x9006, 0x012e, 0x000e, 0x002e,
+	0x0000, 0x6014, 0x2048, 0x080c, 0xb86e, 0x0110, 0x080c, 0xd267,
+	0x080c, 0x9c20, 0x87ff, 0x1198, 0x00ce, 0x0804, 0x9428, 0x2c78,
+	0x600c, 0x2060, 0x0804, 0x9428, 0x9006, 0x012e, 0x000e, 0x002e,
 	0x006e, 0x00ce, 0x009e, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b,
-	0x0000, 0x00ce, 0x97bd, 0x0001, 0x0c80, 0x00e6, 0x2071, 0x19b7,
+	0x0000, 0x00ce, 0x97bd, 0x0001, 0x0c80, 0x00e6, 0x2071, 0x19bf,
 	0x9006, 0x7032, 0x700a, 0x7004, 0x9086, 0x0003, 0x0158, 0x2001,
 	0x1800, 0x2004, 0x9086, 0x0002, 0x1118, 0x7007, 0x0005, 0x0010,
 	0x7007, 0x0000, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0066,
-	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19b7, 0x2c10,
+	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19bf, 0x2c10,
 	0x7648, 0x2660, 0x2678, 0x8cff, 0x0540, 0x2200, 0x9c06, 0x1508,
 	0x7048, 0x9c36, 0x1110, 0x660c, 0x764a, 0x7044, 0x9c36, 0x1140,
 	0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7046, 0x0010, 0x7047, 0x0000,
 	0x660c, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
-	0x0000, 0x6004, 0x9086, 0x0040, 0x090c, 0x885d, 0x9085, 0x0001,
+	0x0000, 0x6004, 0x9086, 0x0040, 0x090c, 0x8891, 0x9085, 0x0001,
 	0x0020, 0x2c78, 0x600c, 0x2060, 0x08b0, 0x012e, 0x000e, 0x002e,
 	0x006e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0096, 0x00f6, 0x00e6,
 	0x00d6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000,
-	0x2071, 0x19b7, 0x7610, 0x2660, 0x2678, 0x8cff, 0x0904, 0x9572,
-	0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x1904, 0x956d,
+	0x2071, 0x19bf, 0x7610, 0x2660, 0x2678, 0x8cff, 0x0904, 0x957a,
+	0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x1904, 0x9575,
 	0x7030, 0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0904,
-	0x9544, 0x080c, 0x8f9c, 0x68c3, 0x0000, 0x080c, 0x9485, 0x7033,
+	0x954c, 0x080c, 0x8fd0, 0x68c3, 0x0000, 0x080c, 0x948d, 0x7033,
 	0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
-	0x2001, 0x0100, 0x080c, 0x2852, 0x9006, 0x080c, 0x2852, 0x2069,
+	0x2001, 0x0100, 0x080c, 0x2872, 0x9006, 0x080c, 0x2872, 0x2069,
 	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x7010,
 	0x9c36, 0x1110, 0x660c, 0x7612, 0x700c, 0x9c36, 0x1140, 0x2c00,
 	0x9f36, 0x0118, 0x2f00, 0x700e, 0x0010, 0x700f, 0x0000, 0x660c,
 	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
-	0x0000, 0x080c, 0xba46, 0x1180, 0x080c, 0x303d, 0x080c, 0xba57,
-	0x1518, 0x080c, 0xa581, 0x0400, 0x080c, 0x9485, 0x6824, 0xd084,
-	0x09b0, 0x6827, 0x0001, 0x0898, 0x080c, 0xba57, 0x1118, 0x080c,
-	0xa581, 0x0090, 0x6014, 0x2048, 0x080c, 0xb840, 0x0168, 0x6020,
+	0x0000, 0x080c, 0xba74, 0x1180, 0x080c, 0x305d, 0x080c, 0xba85,
+	0x1518, 0x080c, 0xa59c, 0x0400, 0x080c, 0x948d, 0x6824, 0xd084,
+	0x09b0, 0x6827, 0x0001, 0x0898, 0x080c, 0xba85, 0x1118, 0x080c,
+	0xa59c, 0x0090, 0x6014, 0x2048, 0x080c, 0xb86e, 0x0168, 0x6020,
 	0x9086, 0x0003, 0x1508, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000,
-	0x080c, 0x6985, 0x080c, 0xba31, 0x080c, 0xbcd3, 0x080c, 0x9c14,
-	0x080c, 0x935b, 0x00ce, 0x0804, 0x94ed, 0x2c78, 0x600c, 0x2060,
-	0x0804, 0x94ed, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x00de,
+	0x080c, 0x69a9, 0x080c, 0xba5f, 0x080c, 0xbd01, 0x080c, 0x9c20,
+	0x080c, 0x9363, 0x00ce, 0x0804, 0x94f5, 0x2c78, 0x600c, 0x2060,
+	0x0804, 0x94f5, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x00de,
 	0x00ee, 0x00fe, 0x009e, 0x0005, 0x6020, 0x9086, 0x0006, 0x1d20,
-	0x080c, 0xd22f, 0x0c08, 0x00d6, 0x080c, 0x8d50, 0x7003, 0x0200,
-	0x7007, 0x0014, 0x60c3, 0x0014, 0x20e1, 0x0001, 0x2099, 0x1959,
+	0x080c, 0xd267, 0x0c08, 0x00d6, 0x080c, 0x8d84, 0x7003, 0x0200,
+	0x7007, 0x0014, 0x60c3, 0x0014, 0x20e1, 0x0001, 0x2099, 0x1961,
 	0x20e9, 0x0000, 0x20a1, 0x0250, 0x20a9, 0x0004, 0x4003, 0x7023,
-	0x0004, 0x7027, 0x7878, 0x080c, 0x8f6c, 0x00de, 0x0005, 0x080c,
-	0x8d50, 0x700b, 0x0800, 0x7814, 0x9084, 0xff00, 0x700e, 0x7814,
+	0x0004, 0x7027, 0x7878, 0x080c, 0x8fa0, 0x00de, 0x0005, 0x080c,
+	0x8d84, 0x700b, 0x0800, 0x7814, 0x9084, 0xff00, 0x700e, 0x7814,
 	0x9084, 0x00ff, 0x7022, 0x782c, 0x7026, 0x7860, 0x9084, 0x00ff,
 	0x9085, 0x0200, 0x7002, 0x7860, 0x9084, 0xff00, 0x8007, 0x7006,
-	0x60c2, 0x0804, 0x8f6c, 0x00b6, 0x00d6, 0x0016, 0x00d6, 0x2f68,
-	0x2009, 0x0035, 0x080c, 0xbed9, 0x00de, 0x1904, 0x9620, 0x080c,
-	0x8d05, 0x7003, 0x1300, 0x782c, 0x080c, 0x972b, 0x2068, 0x6820,
-	0x9086, 0x0003, 0x0560, 0x7810, 0x2058, 0xbaa0, 0x080c, 0x9b59,
+	0x60c2, 0x0804, 0x8fa0, 0x00b6, 0x00d6, 0x0016, 0x00d6, 0x2f68,
+	0x2009, 0x0035, 0x080c, 0xbf07, 0x00de, 0x1904, 0x9628, 0x080c,
+	0x8d39, 0x7003, 0x1300, 0x782c, 0x080c, 0x9737, 0x2068, 0x6820,
+	0x9086, 0x0003, 0x0560, 0x7810, 0x2058, 0xbaa0, 0x080c, 0x9b65,
 	0x11d8, 0x9286, 0x007e, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffe,
 	0x0498, 0x9286, 0x007f, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffd,
 	0x0458, 0x9284, 0xff80, 0x0180, 0x9286, 0x0080, 0x1128, 0x700b,
 	0x00ff, 0x700f, 0xfffc, 0x0400, 0x92d8, 0x1000, 0x2b5c, 0xb810,
 	0x700a, 0xb814, 0x700e, 0x00c0, 0xb884, 0x700e, 0x00a8, 0x080c,
-	0x9b59, 0x1130, 0x7810, 0x2058, 0xb8a0, 0x9082, 0x007e, 0x0250,
+	0x9b65, 0x1130, 0x7810, 0x2058, 0xb8a0, 0x9082, 0x007e, 0x0250,
 	0x00d6, 0x2069, 0x181e, 0x2d04, 0x700a, 0x8d68, 0x2d04, 0x700e,
 	0x00de, 0x0010, 0x6034, 0x700e, 0x7838, 0x7012, 0x783c, 0x7016,
-	0x60c3, 0x000c, 0x001e, 0x00de, 0x080c, 0x8f6c, 0x00be, 0x0005,
+	0x60c3, 0x000c, 0x001e, 0x00de, 0x080c, 0x8fa0, 0x00be, 0x0005,
 	0x781b, 0x0001, 0x7803, 0x0006, 0x001e, 0x00de, 0x00be, 0x0005,
 	0x792c, 0x9180, 0x0008, 0x200c, 0x9186, 0x0006, 0x01c0, 0x9186,
-	0x0003, 0x0904, 0x969e, 0x9186, 0x0005, 0x0904, 0x9686, 0x9186,
-	0x0004, 0x05f0, 0x9186, 0x0008, 0x0904, 0x968f, 0x7807, 0x0037,
-	0x782f, 0x0003, 0x7817, 0x1700, 0x080c, 0x9708, 0x0005, 0x080c,
-	0x96c9, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x6800,
-	0x6a44, 0xd2fc, 0x11f8, 0x0002, 0x9667, 0x9672, 0x9669, 0x9672,
-	0x966e, 0x9667, 0x9667, 0x9672, 0x9672, 0x9672, 0x9672, 0x9667,
-	0x9667, 0x9667, 0x9667, 0x9667, 0x9672, 0x9667, 0x9672, 0x080c,
+	0x0003, 0x0904, 0x96a7, 0x9186, 0x0005, 0x0904, 0x968f, 0x9186,
+	0x0004, 0x05f0, 0x9186, 0x0008, 0x0904, 0x9698, 0x7807, 0x0037,
+	0x782f, 0x0003, 0x7817, 0x1700, 0x080c, 0x9714, 0x0005, 0x080c,
+	0x96d5, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x6800,
+	0x6a44, 0xd2fc, 0x11f8, 0x0002, 0x966f, 0x967a, 0x9671, 0x967a,
+	0x9676, 0x966f, 0x966f, 0x967a, 0x967a, 0x967a, 0x967a, 0x966f,
+	0x966f, 0x966f, 0x966f, 0x966f, 0x967a, 0x966f, 0x967a, 0x080c,
 	0x0d65, 0x6824, 0xd0e4, 0x0110, 0xd0cc, 0x0110, 0x900e, 0x0010,
-	0x2009, 0x2000, 0x682c, 0x7022, 0x6830, 0x7026, 0x0804, 0x96c2,
-	0x080c, 0x96c9, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000,
-	0x6a00, 0x9286, 0x0002, 0x1108, 0x900e, 0x04e0, 0x080c, 0x96c9,
-	0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x0498, 0x04c9,
-	0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x9286, 0x0005,
-	0x0118, 0x9286, 0x0002, 0x1108, 0x900e, 0x0420, 0x0451, 0x00d6,
-	0x0026, 0x792c, 0x2168, 0x6814, 0x0096, 0x2048, 0xa9ac, 0xa834,
-	0x9112, 0xa9b0, 0xa838, 0x009e, 0x9103, 0x7022, 0x7226, 0x792c,
-	0x9180, 0x0011, 0x2004, 0xd0fc, 0x1148, 0x9180, 0x0000, 0x2004,
-	0x908e, 0x0002, 0x0130, 0x908e, 0x0004, 0x0118, 0x2009, 0x4000,
-	0x0008, 0x900e, 0x712a, 0x60c3, 0x0018, 0x002e, 0x00de, 0x0804,
-	0x8f6c, 0x00b6, 0x0036, 0x0046, 0x0056, 0x0066, 0x080c, 0x8d50,
-	0x9006, 0x7003, 0x0200, 0x7938, 0x710a, 0x793c, 0x710e, 0x7810,
-	0x2058, 0xb8a0, 0x080c, 0x9b59, 0x1118, 0x9092, 0x007e, 0x0268,
-	0x00d6, 0x2069, 0x181e, 0x2d2c, 0x8d68, 0x2d34, 0x90d8, 0x1000,
-	0x2b5c, 0xbb10, 0xbc14, 0x00de, 0x0028, 0x901e, 0xbc84, 0x2029,
-	0x0000, 0x6634, 0x782c, 0x9080, 0x0008, 0x2004, 0x9086, 0x0003,
-	0x1128, 0x7512, 0x7616, 0x731a, 0x741e, 0x0020, 0x7312, 0x7416,
-	0x751a, 0x761e, 0x006e, 0x005e, 0x004e, 0x003e, 0x00be, 0x0005,
-	0x080c, 0x8d50, 0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e,
-	0x700e, 0x60c3, 0x0008, 0x0804, 0x8f6c, 0x080c, 0x8cfc, 0x7003,
-	0x1400, 0x7838, 0x700a, 0x0079, 0x783c, 0x700e, 0x782c, 0x7012,
-	0x7830, 0x7016, 0x7834, 0x9084, 0x00ff, 0x8007, 0x701a, 0x60c3,
-	0x0010, 0x0804, 0x8f6c, 0x00e6, 0x2071, 0x0240, 0x0006, 0x00f6,
-	0x2078, 0x7810, 0x00b6, 0x2058, 0xb8c4, 0xd084, 0x0120, 0x7850,
-	0x702a, 0x784c, 0x702e, 0x00be, 0x00fe, 0x000e, 0x00ee, 0x0005,
-	0x080c, 0x8d47, 0x7003, 0x0100, 0x782c, 0x700a, 0x7814, 0x700e,
-	0x60c3, 0x0008, 0x0804, 0x8f6c, 0x00a9, 0x7914, 0x712a, 0x60c3,
-	0x0000, 0x60a7, 0x9575, 0x0026, 0x080c, 0x27c1, 0x0228, 0x2011,
-	0x0101, 0x2204, 0xc0c5, 0x2012, 0x002e, 0x080c, 0x8f8f, 0x080c,
-	0x81e1, 0x0005, 0x0036, 0x0096, 0x00d6, 0x00e6, 0x7860, 0x2048,
-	0xaa7c, 0x9296, 0x00c0, 0x9294, 0xfffd, 0xaa7e, 0xaa80, 0x9294,
-	0x0300, 0xaa82, 0xa96c, 0x9194, 0x00ff, 0xab74, 0x9384, 0x00ff,
-	0x908d, 0xc200, 0xa96e, 0x9384, 0xff00, 0x9215, 0xaa76, 0xa870,
-	0xaa78, 0xa87a, 0xaa72, 0x00d6, 0x2069, 0x0200, 0x080c, 0x97e8,
-	0x00de, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000a, 0xa860,
-	0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098, 0x4003, 0x60a3, 0x0035,
-	0xaa68, 0x9294, 0x7000, 0x9286, 0x3000, 0x0110, 0x60a3, 0x0037,
-	0x00ee, 0x00de, 0x009e, 0x003e, 0x0005, 0x900e, 0x7814, 0x0096,
-	0x2048, 0xa87c, 0xd0fc, 0x01c0, 0x9084, 0x0003, 0x11a8, 0x2001,
-	0x180c, 0x2004, 0xd0bc, 0x0180, 0x7824, 0xd0cc, 0x1168, 0xd0c4,
-	0x1158, 0xa8a8, 0x9005, 0x1140, 0x2001, 0x180c, 0x200c, 0xc1d5,
-	0x2102, 0x2009, 0x1982, 0x210c, 0x009e, 0x918d, 0x0092, 0x0010,
-	0x2009, 0x0096, 0x60ab, 0x0036, 0x0026, 0x2110, 0x900e, 0x080c,
-	0x289b, 0x002e, 0x0005, 0x2009, 0x0009, 0x00a0, 0x2009, 0x000a,
-	0x0088, 0x2009, 0x000b, 0x0070, 0x2009, 0x000c, 0x0058, 0x2009,
-	0x000d, 0x0040, 0x2009, 0x000e, 0x0028, 0x2009, 0x000f, 0x0010,
-	0x2009, 0x0008, 0x6912, 0x0005, 0x00d6, 0x9290, 0x0018, 0x8214,
-	0x20e9, 0x0000, 0x2069, 0x0200, 0x6813, 0x0000, 0x22a8, 0x9284,
-	0x00e0, 0x0128, 0x20a9, 0x0020, 0x9292, 0x0020, 0x0008, 0x9016,
-	0x20a1, 0x0240, 0x9006, 0x4004, 0x82ff, 0x0120, 0x6810, 0x8000,
-	0x6812, 0x0c60, 0x00de, 0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6,
-	0x00a6, 0x0096, 0x0066, 0x0126, 0x2091, 0x8000, 0x2071, 0x19b7,
-	0x7610, 0x2660, 0x2678, 0x8cff, 0x0904, 0x9898, 0x7030, 0x9c06,
-	0x1520, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0904, 0x986a, 0x080c,
-	0x8f9c, 0x68c3, 0x0000, 0x080c, 0x9485, 0x7033, 0x0000, 0x0036,
-	0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001, 0x0100,
-	0x080c, 0x2852, 0x9006, 0x080c, 0x2852, 0x2069, 0x0100, 0x6824,
-	0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x7010, 0x9c36, 0x1110,
-	0x660c, 0x7612, 0x700c, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118,
-	0x2f00, 0x700e, 0x0010, 0x700f, 0x0000, 0x660c, 0x0066, 0x2c00,
-	0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x080c,
-	0xba46, 0x1180, 0x080c, 0x303d, 0x080c, 0xba57, 0x1518, 0x080c,
-	0xa581, 0x0400, 0x080c, 0x9485, 0x6824, 0xd084, 0x09b0, 0x6827,
-	0x0001, 0x0898, 0x080c, 0xba57, 0x1118, 0x080c, 0xa581, 0x0090,
-	0x6014, 0x2048, 0x080c, 0xb840, 0x0168, 0x6020, 0x9086, 0x0003,
-	0x1520, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6991,
-	0x080c, 0xba31, 0x080c, 0xbcd3, 0x080c, 0x9c14, 0x080c, 0x935b,
-	0x00ce, 0x0804, 0x981b, 0x2c78, 0x600c, 0x2060, 0x0804, 0x981b,
-	0x7013, 0x0000, 0x700f, 0x0000, 0x012e, 0x006e, 0x009e, 0x00ae,
-	0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086, 0x0006,
-	0x1d08, 0x080c, 0xd22f, 0x08f0, 0x00f6, 0x0036, 0x2079, 0x0380,
-	0x7b18, 0xd3bc, 0x1de8, 0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080,
-	0x003e, 0x00fe, 0x0005, 0x0016, 0x2001, 0x0382, 0x2004, 0x9084,
-	0x0007, 0x9086, 0x0001, 0x1188, 0x2001, 0x0015, 0x0c29, 0x2009,
-	0x1000, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0003,
-	0x0120, 0x8109, 0x1db0, 0x080c, 0x0d65, 0x001e, 0x0005, 0x2001,
-	0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0003, 0x1120, 0x2001,
-	0x0380, 0x2003, 0x0001, 0x0005, 0x0156, 0x0016, 0x0026, 0x00e6,
-	0x900e, 0x2071, 0x19b7, 0x0469, 0x0106, 0x0190, 0x7004, 0x9086,
-	0x0003, 0x0148, 0x20a9, 0x1000, 0x6044, 0xd0fc, 0x01d8, 0x1f04,
-	0x98f4, 0x080c, 0x0d65, 0x080c, 0x98bb, 0x6044, 0xd0fc, 0x0190,
-	0x7030, 0x9c06, 0x1148, 0x080c, 0x885d, 0x6044, 0xd0dc, 0x0150,
-	0xc0dc, 0x6046, 0x700a, 0x7042, 0x704c, 0x9c06, 0x190c, 0x0d65,
-	0x080c, 0x88b8, 0x010e, 0x1919, 0x00ee, 0x002e, 0x001e, 0x015e,
-	0x0005, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0003,
-	0x0005, 0x0126, 0x2091, 0x2400, 0x7808, 0xd0a4, 0x190c, 0x0d5e,
-	0xd09c, 0x0128, 0x7820, 0x908c, 0xf000, 0x11b8, 0x0012, 0x012e,
-	0x0005, 0x9941, 0x997f, 0x99a6, 0x99d6, 0x99e6, 0x99f7, 0x9a06,
-	0x9a14, 0x9a25, 0x9a29, 0x9941, 0x9941, 0x9941, 0x9941, 0x9941,
-	0x9941, 0x080c, 0x0d65, 0x012e, 0x0005, 0x2060, 0x6044, 0xd0bc,
-	0x0140, 0xc0bc, 0x6046, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d65,
-	0x0012, 0x012e, 0x0005, 0x9966, 0x9968, 0x9966, 0x996e, 0x9966,
-	0x9966, 0x9966, 0x9966, 0x9966, 0x9968, 0x9966, 0x9968, 0x9966,
-	0x9968, 0x9966, 0x9966, 0x9966, 0x9968, 0x9966, 0x080c, 0x0d65,
-	0x2009, 0x0013, 0x080c, 0x9c76, 0x012e, 0x0005, 0x6014, 0x2048,
-	0xa87c, 0xd0dc, 0x0130, 0x080c, 0x83a2, 0x080c, 0x9bda, 0x012e,
-	0x0005, 0x2009, 0x0049, 0x080c, 0x9c76, 0x012e, 0x0005, 0x080c,
-	0x98bb, 0x2001, 0x19dc, 0x2003, 0x0000, 0x7030, 0x9065, 0x090c,
-	0x0d65, 0x7034, 0x9092, 0x00c8, 0x1258, 0x8000, 0x7036, 0x7004,
-	0x9086, 0x0003, 0x0110, 0x7007, 0x0000, 0x781f, 0x0808, 0x0040,
-	0x080c, 0xd621, 0x6003, 0x0001, 0x2009, 0x0014, 0x080c, 0x9c76,
-	0x781f, 0x0100, 0x080c, 0x98d7, 0x012e, 0x0005, 0x080c, 0x98bb,
-	0x714c, 0x81ff, 0x1128, 0x2011, 0x19df, 0x2013, 0x0000, 0x0400,
-	0x2061, 0x0100, 0x7150, 0x9192, 0x7530, 0x12b8, 0x8108, 0x7152,
-	0x714c, 0x9188, 0x0008, 0x210c, 0x918e, 0x0006, 0x1138, 0x6014,
-	0x9084, 0x1984, 0x9085, 0x0012, 0x6016, 0x0050, 0x6014, 0x9084,
-	0x1984, 0x9085, 0x0016, 0x6016, 0x0018, 0x706c, 0xc085, 0x706e,
-	0x781f, 0x0200, 0x080c, 0x98d7, 0x012e, 0x0005, 0x080c, 0x98bb,
-	0x714c, 0x2160, 0x6003, 0x0003, 0x2009, 0x004a, 0x080c, 0x9c76,
-	0x781f, 0x0200, 0x080c, 0x98d7, 0x012e, 0x0005, 0x7808, 0xd09c,
-	0x0de8, 0x7820, 0x2060, 0x6003, 0x0003, 0x080c, 0x98bb, 0x080c,
-	0x1c0f, 0x781f, 0x0400, 0x080c, 0x98d7, 0x012e, 0x0005, 0x7808,
-	0xd09c, 0x0de8, 0x7820, 0x2060, 0x080c, 0x98bb, 0x080c, 0x1c57,
-	0x781f, 0x0400, 0x080c, 0x98d7, 0x012e, 0x0005, 0x7030, 0x9065,
-	0x0148, 0x6044, 0xc0bc, 0x6046, 0x7104, 0x9186, 0x0003, 0x0110,
-	0x080c, 0x891c, 0x012e, 0x0005, 0x00f6, 0x703c, 0x9086, 0x0002,
-	0x0148, 0x704c, 0x907d, 0x0130, 0x7844, 0xc0bc, 0x7846, 0x080c,
-	0x8ec6, 0x0000, 0x00fe, 0x012e, 0x0005, 0x080c, 0x7137, 0x012e,
-	0x0005, 0x080c, 0x0d65, 0x0005, 0x00e6, 0x2071, 0x19b7, 0x6044,
-	0xc0bc, 0x6046, 0xd0fc, 0x01b8, 0x704c, 0x9c06, 0x1190, 0x2019,
-	0x0001, 0x080c, 0x9269, 0x704f, 0x0000, 0x2001, 0x0109, 0x2004,
-	0xd08c, 0x1138, 0x2001, 0x0108, 0x2004, 0xd0bc, 0x1110, 0x703f,
-	0x0000, 0x080c, 0x949c, 0x00ee, 0x0005, 0x0026, 0x7010, 0x9c06,
-	0x1178, 0x080c, 0x935b, 0x6044, 0xc0fc, 0x6046, 0x600c, 0x9015,
-	0x0120, 0x7212, 0x600f, 0x0000, 0x0010, 0x7212, 0x720e, 0x9006,
-	0x002e, 0x0005, 0x0026, 0x7020, 0x9c06, 0x1178, 0x080c, 0x935b,
-	0x6044, 0xc0fc, 0x6046, 0x600c, 0x9015, 0x0120, 0x7222, 0x600f,
-	0x0000, 0x0010, 0x7222, 0x721e, 0x9006, 0x002e, 0x0005, 0x00d6,
-	0x0036, 0x7830, 0x9c06, 0x1558, 0x2069, 0x0100, 0x68c0, 0x9005,
-	0x01f8, 0x080c, 0x81ea, 0x080c, 0x8f9c, 0x68c3, 0x0000, 0x080c,
-	0x9485, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
-	0x0100, 0x080c, 0x2852, 0x9006, 0x080c, 0x2852, 0x2069, 0x0100,
-	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x9085, 0x0001, 0x0038,
-	0x7808, 0xc0ad, 0x780a, 0x6003, 0x0009, 0x630a, 0x9006, 0x003e,
-	0x00de, 0x0005, 0x0016, 0x0026, 0x0036, 0x6100, 0x2019, 0x0100,
-	0x2001, 0x0382, 0x2004, 0xd09c, 0x0190, 0x00c6, 0x0126, 0x2091,
-	0x2800, 0x0016, 0x0036, 0x080c, 0x9921, 0x003e, 0x001e, 0x012e,
-	0x00ce, 0x6200, 0x2200, 0x9106, 0x0d58, 0x2200, 0x0010, 0x8319,
-	0x1d38, 0x003e, 0x002e, 0x001e, 0x0005, 0x00d6, 0x0156, 0x080c,
-	0x8d50, 0x7a14, 0x82ff, 0x0138, 0x7003, 0x0100, 0x700b, 0x0003,
-	0x60c3, 0x0008, 0x0490, 0x7003, 0x0200, 0x7007, 0x0000, 0x2069,
-	0x1800, 0x901e, 0x6800, 0x9086, 0x0004, 0x1110, 0xc38d, 0x0060,
-	0x080c, 0x7096, 0x1110, 0xc3ad, 0x0008, 0xc3a5, 0x6ad8, 0xd29c,
-	0x1110, 0xd2ac, 0x0108, 0xc39d, 0x730e, 0x2011, 0x1848, 0x63f0,
-	0x2312, 0x20a9, 0x0006, 0x2011, 0x1840, 0x2019, 0x1841, 0x2071,
-	0x0250, 0x2376, 0x8e70, 0x2276, 0x8e70, 0x9398, 0x0002, 0x9290,
-	0x0002, 0x1f04, 0x9b01, 0x60c3, 0x0020, 0x080c, 0x8f6c, 0x015e,
-	0x00de, 0x0005, 0x0156, 0x080c, 0x8d50, 0x7a14, 0x82ff, 0x0168,
-	0x9286, 0xffff, 0x0118, 0x9282, 0x000e, 0x1238, 0x7003, 0x0100,
-	0x700b, 0x0003, 0x60c3, 0x0008, 0x0488, 0x7003, 0x0200, 0x7007,
-	0x001c, 0x700f, 0x0001, 0x2011, 0x198d, 0x2204, 0x8007, 0x701a,
-	0x8210, 0x2204, 0x8007, 0x701e, 0x0421, 0x1120, 0xb8a0, 0x9082,
-	0x007f, 0x0248, 0x2001, 0x181e, 0x2004, 0x7022, 0x2001, 0x181f,
-	0x2004, 0x7026, 0x0030, 0x2001, 0x1817, 0x2004, 0x9084, 0x00ff,
-	0x7026, 0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9,
-	0x0000, 0x20a1, 0x0256, 0x4003, 0x60c3, 0x001c, 0x015e, 0x0804,
-	0x8f6c, 0x0006, 0x2001, 0x1836, 0x2004, 0xd0ac, 0x000e, 0x0005,
-	0x2011, 0x0003, 0x080c, 0x931c, 0x2011, 0x0002, 0x080c, 0x9326,
-	0x080c, 0x91e9, 0x0036, 0x901e, 0x080c, 0x9269, 0x003e, 0x0005,
-	0x2071, 0x1883, 0x7000, 0x9005, 0x0140, 0x2001, 0x0812, 0x2071,
-	0x1800, 0x7072, 0x7076, 0x7067, 0xffd4, 0x2071, 0x1800, 0x7070,
-	0x7052, 0x7057, 0x1ddc, 0x0005, 0x00e6, 0x0126, 0x2071, 0x1800,
-	0x2091, 0x8000, 0x7550, 0x9582, 0x0010, 0x0608, 0x7054, 0x2060,
-	0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0, 0x001c, 0x7064, 0x9c02,
-	0x1208, 0x0cb0, 0x2061, 0x1ddc, 0x0c98, 0x6003, 0x0008, 0x8529,
-	0x7552, 0x9ca8, 0x001c, 0x7064, 0x9502, 0x1230, 0x7556, 0x9085,
-	0x0001, 0x012e, 0x00ee, 0x0005, 0x7057, 0x1ddc, 0x0cc0, 0x9006,
-	0x0cc0, 0x00e6, 0x2071, 0x1800, 0x7550, 0x9582, 0x0010, 0x0600,
-	0x7054, 0x2060, 0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0, 0x001c,
-	0x7064, 0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1ddc, 0x0c98, 0x6003,
-	0x0008, 0x8529, 0x7552, 0x9ca8, 0x001c, 0x7064, 0x9502, 0x1228,
-	0x7556, 0x9085, 0x0001, 0x00ee, 0x0005, 0x7057, 0x1ddc, 0x0cc8,
-	0x9006, 0x0cc8, 0x9c82, 0x1ddc, 0x0a0c, 0x0d65, 0x2001, 0x1819,
-	0x2004, 0x9c02, 0x1a0c, 0x0d65, 0x9006, 0x6006, 0x600a, 0x600e,
-	0x6016, 0x601a, 0x6012, 0x6023, 0x0000, 0x6003, 0x0000, 0x601e,
-	0x605e, 0x6062, 0x6026, 0x602a, 0x602e, 0x6032, 0x6036, 0x603a,
-	0x603e, 0x604a, 0x6046, 0x6042, 0x2061, 0x1800, 0x6050, 0x8000,
-	0x6052, 0x0005, 0x9006, 0x600e, 0x6016, 0x601a, 0x6012, 0x6022,
-	0x6002, 0x601e, 0x605e, 0x6062, 0x604a, 0x6046, 0x2061, 0x1800,
-	0x6050, 0x8000, 0x6052, 0x0005, 0x0006, 0x6000, 0x9086, 0x0000,
-	0x01d0, 0x601c, 0xd084, 0x190c, 0x1921, 0x6023, 0x0007, 0x2001,
-	0x1956, 0x2004, 0x0006, 0x9082, 0x0051, 0x000e, 0x0208, 0x8004,
-	0x601a, 0x080c, 0xd4df, 0x604b, 0x0000, 0x6044, 0xd0fc, 0x1129,
-	0x9006, 0x6046, 0x6016, 0x000e, 0x0005, 0x080c, 0x98bb, 0x0106,
-	0x2001, 0x19ca, 0x2004, 0x9c06, 0x1130, 0x0036, 0x2019, 0x0001,
-	0x080c, 0x9269, 0x003e, 0x080c, 0x949c, 0x010e, 0x090c, 0x98d7,
-	0x0005, 0x00e6, 0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7550,
-	0x9582, 0x0001, 0x0608, 0x7054, 0x2060, 0x6000, 0x9086, 0x0000,
-	0x0148, 0x9ce0, 0x001c, 0x7064, 0x9c02, 0x1208, 0x0cb0, 0x2061,
-	0x1ddc, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7552, 0x9ca8, 0x001c,
-	0x7064, 0x9502, 0x1230, 0x7556, 0x9085, 0x0001, 0x012e, 0x00ee,
-	0x0005, 0x7057, 0x1ddc, 0x0cc0, 0x9006, 0x0cc0, 0x6020, 0x9084,
-	0x000f, 0x0002, 0x9c8a, 0x9c94, 0x9caf, 0x9cca, 0xbfb4, 0xbfd1,
-	0xbfec, 0x9c8a, 0x9c94, 0x9c8a, 0x9ce6, 0x9c8a, 0x9c8a, 0x9c8a,
-	0x9c8a, 0x9c8a, 0x9186, 0x0013, 0x1130, 0x6044, 0xd0fc, 0x0110,
-	0x080c, 0x885d, 0x0005, 0x0005, 0x0066, 0x6000, 0x90b2, 0x0016,
-	0x1a0c, 0x0d65, 0x0013, 0x006e, 0x0005, 0x9cad, 0xa3f6, 0xa5c8,
-	0x9cad, 0xa656, 0x9faf, 0x9cad, 0x9cad, 0xa378, 0xabfd, 0x9cad,
-	0x9cad, 0x9cad, 0x9cad, 0x9cad, 0x9cad, 0x080c, 0x0d65, 0x0066,
-	0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0d65, 0x0013, 0x006e, 0x0005,
-	0x9cc8, 0xb202, 0x9cc8, 0x9cc8, 0x9cc8, 0x9cc8, 0x9cc8, 0x9cc8,
-	0xb1a7, 0xb385, 0x9cc8, 0xb23f, 0xb2c3, 0xb23f, 0xb2c3, 0x9cc8,
-	0x080c, 0x0d65, 0x6000, 0x9082, 0x0016, 0x1a0c, 0x0d65, 0x6000,
-	0x0002, 0x9ce4, 0xac47, 0xacde, 0xae5e, 0xaecd, 0x9ce4, 0x9ce4,
-	0x9ce4, 0xac16, 0xb128, 0xb12b, 0x9ce4, 0x9ce4, 0x9ce4, 0x9ce4,
-	0xb15b, 0x9ce4, 0x9ce4, 0x9ce4, 0x080c, 0x0d65, 0x0066, 0x6000,
-	0x90b2, 0x0016, 0x1a0c, 0x0d65, 0x0013, 0x006e, 0x0005, 0x9cff,
-	0x9cff, 0x9d3d, 0x9ddc, 0x9e5c, 0x9cff, 0x9cff, 0x9cff, 0x9d01,
-	0x9cff, 0x9cff, 0x9cff, 0x9cff, 0x9cff, 0x9cff, 0x9cff, 0x080c,
-	0x0d65, 0x9186, 0x004c, 0x0560, 0x9186, 0x0003, 0x190c, 0x0d65,
-	0x0096, 0x601c, 0xc0ed, 0x601e, 0x6003, 0x0003, 0x6106, 0x6014,
-	0x2048, 0xa87c, 0x9084, 0xa000, 0xc0b5, 0xa87e, 0xa8ac, 0xa836,
-	0xa8b0, 0xa83a, 0x9006, 0xa846, 0xa84a, 0xa884, 0x9092, 0x199a,
-	0x0210, 0x2001, 0x1999, 0x8003, 0x8013, 0x8213, 0x9210, 0x621a,
-	0x009e, 0x080c, 0x1a71, 0x2009, 0x8030, 0x080c, 0x84fa, 0x0005,
-	0x6010, 0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x080c, 0x9e7e,
-	0x080c, 0xbf79, 0x6003, 0x0007, 0x0005, 0x00d6, 0x0096, 0x00f6,
-	0x2079, 0x1800, 0x7a8c, 0x6014, 0x2048, 0xa87c, 0xd0ec, 0x1110,
-	0x9290, 0x0018, 0xac78, 0xc4fc, 0x0046, 0xa8e0, 0x9005, 0x1140,
-	0xa8dc, 0x921a, 0x0140, 0x0220, 0xa87b, 0x0007, 0x2010, 0x0028,
-	0xa87b, 0x0015, 0x0010, 0xa87b, 0x0000, 0x8214, 0xa883, 0x0000,
-	0xaa02, 0x0006, 0x0016, 0x0026, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
-	0x2400, 0x9005, 0x1108, 0x009a, 0x2100, 0x9086, 0x0015, 0x1118,
-	0x2001, 0x0001, 0x0038, 0x2100, 0x9086, 0x0016, 0x0118, 0x2001,
-	0x0001, 0x002a, 0x94a4, 0x0007, 0x8423, 0x9405, 0x0002, 0x9da4,
-	0x9da4, 0x9d9f, 0x9da2, 0x9da4, 0x9d9c, 0x9d8f, 0x9d8f, 0x9d8f,
-	0x9d8f, 0x9d8f, 0x9d8f, 0x9d8f, 0x9d8f, 0x9d8f, 0x9d8f, 0x00fe,
-	0x00ee, 0x00de, 0x00ce, 0x002e, 0x001e, 0x000e, 0x004e, 0x00fe,
-	0x009e, 0x00de, 0x080c, 0x0d65, 0x080c, 0xa839, 0x0028, 0x080c,
-	0xa95c, 0x0010, 0x080c, 0xaa4b, 0x00fe, 0x00ee, 0x00de, 0x00ce,
-	0x002e, 0x001e, 0x2c00, 0xa896, 0x000e, 0x080c, 0x9f3c, 0x0530,
-	0xa804, 0xa80e, 0x00a6, 0x2050, 0xb100, 0x00ae, 0x8006, 0x8006,
-	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0xaacc,
-	0xabd0, 0xacd4, 0xadd8, 0x2031, 0x0000, 0x2041, 0x128b, 0x080c,
-	0xa0e7, 0x0160, 0x000e, 0x9005, 0x0120, 0x00fe, 0x009e, 0x00de,
-	0x0005, 0x00fe, 0x009e, 0x00de, 0x0804, 0x9bda, 0x2001, 0x002c,
-	0x900e, 0x080c, 0x9fa2, 0x0c70, 0x91b6, 0x0015, 0x0170, 0x91b6,
-	0x0016, 0x0158, 0x91b2, 0x0047, 0x0a0c, 0x0d65, 0x91b2, 0x0050,
-	0x1a0c, 0x0d65, 0x9182, 0x0047, 0x0042, 0x080c, 0x9aaa, 0x0120,
-	0x9086, 0x0002, 0x0904, 0x9d3d, 0x0005, 0x9dfe, 0x9dfe, 0x9e00,
-	0x9e32, 0x9dfe, 0x9dfe, 0x9dfe, 0x9dfe, 0x9e45, 0x080c, 0x0d65,
-	0x00d6, 0x0016, 0x0096, 0x6003, 0x0004, 0x6114, 0x2148, 0xa87c,
-	0xd0fc, 0x01c0, 0xa878, 0xc0fc, 0x9005, 0x1158, 0xa894, 0x9005,
-	0x0140, 0x2001, 0x0000, 0x900e, 0x080c, 0x9fa2, 0x080c, 0x9bda,
-	0x00a8, 0x6003, 0x0002, 0xa8a4, 0xa9a8, 0x9105, 0x1178, 0xa8ae,
-	0xa8b2, 0x0c78, 0xa87f, 0x0020, 0xa88c, 0xa88a, 0xa8a4, 0xa8ae,
-	0xa8a8, 0xa8b2, 0xa8c7, 0x0000, 0xa8cb, 0x0000, 0x009e, 0x001e,
-	0x00de, 0x0005, 0x080c, 0x88b8, 0x00d6, 0x0096, 0x6114, 0x2148,
-	0x080c, 0xb842, 0x0120, 0xa87b, 0x0006, 0x080c, 0x6991, 0x009e,
-	0x00de, 0x080c, 0x9bda, 0x0804, 0x891b, 0x080c, 0x88b8, 0x080c,
-	0x300e, 0x080c, 0xbf76, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c,
-	0xb842, 0x0120, 0xa87b, 0x0029, 0x080c, 0x6991, 0x009e, 0x00de,
-	0x080c, 0x9bda, 0x0804, 0x891b, 0x9182, 0x0047, 0x0002, 0x9e6c,
-	0x9e6e, 0x9e6c, 0x9e6c, 0x9e6c, 0x9e6c, 0x9e6c, 0x9e6c, 0x9e6c,
-	0x9e6c, 0x9e6c, 0x9e6c, 0x9e6e, 0x080c, 0x0d65, 0x00d6, 0x0096,
-	0x080c, 0x15a2, 0x6114, 0x2148, 0xa87b, 0x0000, 0xa883, 0x0000,
-	0x080c, 0x6991, 0x009e, 0x00de, 0x0804, 0x9bda, 0x0026, 0x0036,
-	0x0056, 0x0066, 0x0096, 0x00a6, 0x00f6, 0x0006, 0x080c, 0x1022,
-	0x000e, 0x090c, 0x0d65, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019,
-	0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104, 0xa87a, 0x2079, 0x1800,
-	0x798c, 0x9188, 0x0018, 0x918c, 0x0fff, 0xa972, 0xac76, 0x2950,
-	0x00a6, 0x2001, 0x0205, 0x2003, 0x0000, 0x901e, 0x2029, 0x0001,
-	0x9182, 0x0034, 0x1228, 0x2011, 0x001f, 0x080c, 0xb408, 0x04c0,
-	0x2130, 0x2009, 0x0034, 0x2011, 0x001f, 0x080c, 0xb408, 0x96b2,
-	0x0034, 0xb004, 0x904d, 0x0110, 0x080c, 0x0fd4, 0x080c, 0x1022,
-	0x01d0, 0x8528, 0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406,
-	0x968a, 0x003d, 0x1230, 0x2608, 0x2011, 0x001b, 0x080c, 0xb408,
-	0x00b8, 0x96b2, 0x003c, 0x2009, 0x003c, 0x2950, 0x2011, 0x001b,
-	0x080c, 0xb408, 0x0c18, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae,
-	0x852f, 0x95ad, 0x0050, 0xb566, 0xb070, 0xc0fd, 0xb072, 0x0048,
-	0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050,
-	0xb566, 0x2a48, 0xa804, 0xa807, 0x0000, 0x0006, 0x080c, 0x6991,
-	0x000e, 0x2048, 0x9005, 0x1db0, 0x00fe, 0x00ae, 0x009e, 0x006e,
-	0x005e, 0x003e, 0x002e, 0x0005, 0x00d6, 0x00f6, 0x0096, 0x0006,
-	0x080c, 0x1022, 0x000e, 0x090c, 0x0d65, 0xa960, 0x21e8, 0xa95c,
-	0x9188, 0x0019, 0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104, 0xaa66,
-	0xa87a, 0x2079, 0x1800, 0x798c, 0x810c, 0x9188, 0x000c, 0x9182,
-	0x001a, 0x0210, 0x2009, 0x001a, 0x21a8, 0x810b, 0xa972, 0xac76,
-	0x2e98, 0xa85c, 0x9080, 0x001f, 0x20a0, 0x2001, 0x0205, 0x200c,
-	0x918d, 0x0080, 0x2102, 0x4003, 0x2003, 0x0000, 0x080c, 0x6991,
-	0x009e, 0x00fe, 0x00de, 0x0005, 0x0016, 0x00d6, 0x00f6, 0x0096,
-	0x0016, 0x2001, 0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x001e,
-	0x2079, 0x0200, 0x2e98, 0xa87c, 0xd0ec, 0x0118, 0x9e80, 0x000c,
-	0x2098, 0x2021, 0x003e, 0x901e, 0x9282, 0x0020, 0x0218, 0x2011,
-	0x0020, 0x2018, 0x9486, 0x003e, 0x1170, 0x0096, 0x080c, 0x1022,
-	0x2900, 0x009e, 0x05c0, 0xa806, 0x2048, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x0002, 0x20a0, 0x3300, 0x908e, 0x0260, 0x0140, 0x2009,
-	0x0280, 0x9102, 0x920a, 0x0218, 0x2010, 0x2100, 0x9318, 0x2200,
-	0x9402, 0x1228, 0x2400, 0x9202, 0x2410, 0x9318, 0x9006, 0x2020,
-	0x22a8, 0xa800, 0x9200, 0xa802, 0x20e1, 0x0000, 0x4003, 0x83ff,
-	0x0180, 0x3300, 0x9086, 0x0280, 0x1130, 0x7814, 0x8000, 0x9085,
-	0x0080, 0x7816, 0x2e98, 0x2310, 0x84ff, 0x0904, 0x9f51, 0x0804,
-	0x9f53, 0x9085, 0x0001, 0x7817, 0x0000, 0x009e, 0x00fe, 0x00de,
-	0x001e, 0x0005, 0x00d6, 0x0036, 0x0096, 0x6314, 0x2348, 0xa87a,
-	0xa982, 0x080c, 0x6985, 0x009e, 0x003e, 0x00de, 0x0005, 0x91b6,
-	0x0015, 0x1118, 0x080c, 0x9bda, 0x0030, 0x91b6, 0x0016, 0x190c,
-	0x0d65, 0x080c, 0x9bda, 0x0005, 0x20a9, 0x000e, 0x20e1, 0x0000,
-	0x2e98, 0x6014, 0x0096, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x20a0,
-	0x009e, 0x4003, 0x0136, 0x9080, 0x001b, 0x20a0, 0x2011, 0x0006,
-	0x20a9, 0x0001, 0x3418, 0x8318, 0x23a0, 0x4003, 0x3318, 0x8318,
-	0x2398, 0x8211, 0x1db8, 0x2011, 0x0006, 0x013e, 0x20a0, 0x3318,
-	0x8318, 0x2398, 0x4003, 0x3418, 0x8318, 0x23a0, 0x8211, 0x1db8,
-	0x0096, 0x080c, 0xb842, 0x0130, 0x6014, 0x2048, 0xa807, 0x0000,
-	0xa867, 0x0103, 0x009e, 0x0804, 0x9bda, 0x0096, 0x00d6, 0x0036,
-	0x7330, 0x9386, 0x0200, 0x11a8, 0x6010, 0x00b6, 0x2058, 0xb8c7,
-	0x0000, 0x00be, 0x6014, 0x9005, 0x0130, 0x2048, 0xa807, 0x0000,
-	0xa867, 0x0103, 0xab32, 0x080c, 0x9bda, 0x003e, 0x00de, 0x009e,
-	0x0005, 0x0011, 0x1d48, 0x0cc8, 0x0006, 0x0016, 0x080c, 0xbf61,
-	0x0188, 0x6014, 0x9005, 0x1170, 0x600b, 0x0003, 0x601b, 0x0000,
-	0x604b, 0x0000, 0x2009, 0x0022, 0x080c, 0xa3ce, 0x9006, 0x001e,
-	0x000e, 0x0005, 0x9085, 0x0001, 0x0cd0, 0x0096, 0x0016, 0x20a9,
-	0x0014, 0x9e80, 0x000c, 0x20e1, 0x0000, 0x2098, 0x6014, 0x2048,
+	0x2009, 0x2000, 0x682c, 0x7022, 0x6830, 0x7026, 0x0804, 0x96ce,
+	0x080c, 0x96d5, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000,
+	0x6a00, 0x9286, 0x0002, 0x1108, 0x900e, 0x0804, 0x96ce, 0x080c,
+	0x96d5, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x04b0,
+	0x04e1, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x9286,
+	0x0005, 0x0118, 0x9286, 0x0002, 0x1108, 0x900e, 0x0438, 0x0469,
+	0x00d6, 0x0026, 0x792c, 0x2168, 0x6814, 0x6924, 0xc185, 0x6926,
+	0x0096, 0x2048, 0xa9ac, 0xa834, 0x9112, 0xa9b0, 0xa838, 0x009e,
+	0x9103, 0x7022, 0x7226, 0x792c, 0x9180, 0x0011, 0x2004, 0xd0fc,
+	0x1148, 0x9180, 0x0000, 0x2004, 0x908e, 0x0002, 0x0130, 0x908e,
+	0x0004, 0x0118, 0x2009, 0x4000, 0x0008, 0x900e, 0x712a, 0x60c3,
+	0x0018, 0x002e, 0x00de, 0x0804, 0x8fa0, 0x00b6, 0x0036, 0x0046,
+	0x0056, 0x0066, 0x080c, 0x8d84, 0x9006, 0x7003, 0x0200, 0x7938,
+	0x710a, 0x793c, 0x710e, 0x7810, 0x2058, 0xb8a0, 0x080c, 0x9b65,
+	0x1118, 0x9092, 0x007e, 0x0268, 0x00d6, 0x2069, 0x181e, 0x2d2c,
+	0x8d68, 0x2d34, 0x90d8, 0x1000, 0x2b5c, 0xbb10, 0xbc14, 0x00de,
+	0x0028, 0x901e, 0xbc84, 0x2029, 0x0000, 0x6634, 0x782c, 0x9080,
+	0x0008, 0x2004, 0x9086, 0x0003, 0x1128, 0x7512, 0x7616, 0x731a,
+	0x741e, 0x0020, 0x7312, 0x7416, 0x751a, 0x761e, 0x006e, 0x005e,
+	0x004e, 0x003e, 0x00be, 0x0005, 0x080c, 0x8d84, 0x7003, 0x0100,
+	0x782c, 0x700a, 0x7814, 0x700e, 0x700e, 0x60c3, 0x0008, 0x0804,
+	0x8fa0, 0x080c, 0x8d30, 0x7003, 0x1400, 0x7838, 0x700a, 0x0079,
+	0x783c, 0x700e, 0x782c, 0x7012, 0x7830, 0x7016, 0x7834, 0x9084,
+	0x00ff, 0x8007, 0x701a, 0x60c3, 0x0010, 0x0804, 0x8fa0, 0x00e6,
+	0x2071, 0x0240, 0x0006, 0x00f6, 0x2078, 0x7810, 0x00b6, 0x2058,
+	0xb8c4, 0xd084, 0x0120, 0x7850, 0x702a, 0x784c, 0x702e, 0x00be,
+	0x00fe, 0x000e, 0x00ee, 0x0005, 0x080c, 0x8d7b, 0x7003, 0x0100,
+	0x782c, 0x700a, 0x7814, 0x700e, 0x60c3, 0x0008, 0x0804, 0x8fa0,
+	0x00a9, 0x7914, 0x712a, 0x60c3, 0x0000, 0x60a7, 0x9575, 0x0026,
+	0x080c, 0x27dd, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012,
+	0x002e, 0x080c, 0x8fc3, 0x080c, 0x8215, 0x0005, 0x0036, 0x0096,
+	0x00d6, 0x00e6, 0x7860, 0x2048, 0xaa7c, 0x9296, 0x00c0, 0x9294,
+	0xfffd, 0xaa7e, 0xaa80, 0x9294, 0x0300, 0xaa82, 0xa96c, 0x9194,
+	0x00ff, 0xab74, 0x9384, 0x00ff, 0x908d, 0xc200, 0xa96e, 0x9384,
+	0xff00, 0x9215, 0xaa76, 0xa870, 0xaa78, 0xa87a, 0xaa72, 0x00d6,
+	0x2069, 0x0200, 0x080c, 0x97f4, 0x00de, 0x20e9, 0x0000, 0x20a1,
+	0x0240, 0x20a9, 0x000a, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b,
+	0x2098, 0x4003, 0x60a3, 0x0035, 0xaa68, 0x9294, 0x7000, 0x9286,
+	0x3000, 0x0110, 0x60a3, 0x0037, 0x00ee, 0x00de, 0x009e, 0x003e,
+	0x0005, 0x900e, 0x7814, 0x0096, 0x2048, 0xa87c, 0xd0fc, 0x01c0,
+	0x9084, 0x0003, 0x11a8, 0x2001, 0x180c, 0x2004, 0xd0bc, 0x0180,
+	0x7824, 0xd0cc, 0x1168, 0xd0c4, 0x1158, 0xa8a8, 0x9005, 0x1140,
+	0x2001, 0x180c, 0x200c, 0xc1d5, 0x2102, 0x2009, 0x198a, 0x210c,
+	0x009e, 0x918d, 0x0092, 0x0010, 0x2009, 0x0096, 0x60ab, 0x0036,
+	0x0026, 0x2110, 0x900e, 0x080c, 0x28bb, 0x002e, 0x0005, 0x2009,
+	0x0009, 0x00a0, 0x2009, 0x000a, 0x0088, 0x2009, 0x000b, 0x0070,
+	0x2009, 0x000c, 0x0058, 0x2009, 0x000d, 0x0040, 0x2009, 0x000e,
+	0x0028, 0x2009, 0x000f, 0x0010, 0x2009, 0x0008, 0x6912, 0x0005,
+	0x00d6, 0x9290, 0x0018, 0x8214, 0x20e9, 0x0000, 0x2069, 0x0200,
+	0x6813, 0x0000, 0x22a8, 0x9284, 0x00e0, 0x0128, 0x20a9, 0x0020,
+	0x9292, 0x0020, 0x0008, 0x9016, 0x20a1, 0x0240, 0x9006, 0x4004,
+	0x82ff, 0x0120, 0x6810, 0x8000, 0x6812, 0x0c60, 0x00de, 0x0005,
+	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00a6, 0x0096, 0x0066, 0x0126,
+	0x2091, 0x8000, 0x2071, 0x19bf, 0x7610, 0x2660, 0x2678, 0x8cff,
+	0x0904, 0x98a4, 0x7030, 0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0,
+	0x9005, 0x0904, 0x9876, 0x080c, 0x8fd0, 0x68c3, 0x0000, 0x080c,
+	0x948d, 0x7033, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384,
+	0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2872, 0x9006, 0x080c,
+	0x2872, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001,
+	0x003e, 0x7010, 0x9c36, 0x1110, 0x660c, 0x7612, 0x700c, 0x9c36,
+	0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700e, 0x0010, 0x700f,
+	0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
+	0x2678, 0x600f, 0x0000, 0x080c, 0xba74, 0x1180, 0x080c, 0x305d,
+	0x080c, 0xba85, 0x1518, 0x080c, 0xa59c, 0x0400, 0x080c, 0x948d,
+	0x6824, 0xd084, 0x09b0, 0x6827, 0x0001, 0x0898, 0x080c, 0xba85,
+	0x1118, 0x080c, 0xa59c, 0x0090, 0x6014, 0x2048, 0x080c, 0xb86e,
+	0x0168, 0x6020, 0x9086, 0x0003, 0x1520, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x080c, 0x69b5, 0x080c, 0xba5f, 0x080c, 0xbd01,
+	0x080c, 0x9c20, 0x080c, 0x9363, 0x00ce, 0x0804, 0x9827, 0x2c78,
+	0x600c, 0x2060, 0x0804, 0x9827, 0x7013, 0x0000, 0x700f, 0x0000,
+	0x012e, 0x006e, 0x009e, 0x00ae, 0x00ce, 0x00de, 0x00ee, 0x00fe,
+	0x0005, 0x6020, 0x9086, 0x0006, 0x1d08, 0x080c, 0xd267, 0x08f0,
+	0x00f6, 0x0036, 0x2079, 0x0380, 0x7b18, 0xd3bc, 0x1de8, 0x7832,
+	0x7936, 0x7a3a, 0x781b, 0x8080, 0x003e, 0x00fe, 0x0005, 0x0016,
+	0x2001, 0x0382, 0x2004, 0x9084, 0x0007, 0x9086, 0x0001, 0x1188,
+	0x2001, 0x0015, 0x0c29, 0x2009, 0x1000, 0x2001, 0x0382, 0x2004,
+	0x9084, 0x0007, 0x9086, 0x0003, 0x0120, 0x8109, 0x1db0, 0x080c,
+	0x0d65, 0x001e, 0x0005, 0x2001, 0x0382, 0x2004, 0x9084, 0x0007,
+	0x9086, 0x0003, 0x1120, 0x2001, 0x0380, 0x2003, 0x0001, 0x0005,
+	0x0156, 0x0016, 0x0026, 0x00e6, 0x900e, 0x2071, 0x19bf, 0x0469,
+	0x0106, 0x0190, 0x7004, 0x9086, 0x0003, 0x0148, 0x20a9, 0x1000,
+	0x6044, 0xd0fc, 0x01d8, 0x1f04, 0x9900, 0x080c, 0x0d65, 0x080c,
+	0x98c7, 0x6044, 0xd0fc, 0x0190, 0x7030, 0x9c06, 0x1148, 0x080c,
+	0x8891, 0x6044, 0xd0dc, 0x0150, 0xc0dc, 0x6046, 0x700a, 0x7042,
+	0x704c, 0x9c06, 0x190c, 0x0d65, 0x080c, 0x88ec, 0x010e, 0x1919,
+	0x00ee, 0x002e, 0x001e, 0x015e, 0x0005, 0x2001, 0x0382, 0x2004,
+	0x9084, 0x0007, 0x9086, 0x0003, 0x0005, 0x0126, 0x2091, 0x2400,
+	0x7808, 0xd0a4, 0x190c, 0x0d5e, 0xd09c, 0x0128, 0x7820, 0x908c,
+	0xf000, 0x11b8, 0x0012, 0x012e, 0x0005, 0x994d, 0x998b, 0x99b2,
+	0x99e2, 0x99f2, 0x9a03, 0x9a12, 0x9a20, 0x9a31, 0x9a35, 0x994d,
+	0x994d, 0x994d, 0x994d, 0x994d, 0x994d, 0x080c, 0x0d65, 0x012e,
+	0x0005, 0x2060, 0x6044, 0xd0bc, 0x0140, 0xc0bc, 0x6046, 0x6000,
+	0x908a, 0x0016, 0x1a0c, 0x0d65, 0x0012, 0x012e, 0x0005, 0x9972,
+	0x9974, 0x9972, 0x997a, 0x9972, 0x9972, 0x9972, 0x9972, 0x9972,
+	0x9974, 0x9972, 0x9974, 0x9972, 0x9974, 0x9972, 0x9972, 0x9972,
+	0x9974, 0x9972, 0x080c, 0x0d65, 0x2009, 0x0013, 0x080c, 0x9c82,
+	0x012e, 0x0005, 0x6014, 0x2048, 0xa87c, 0xd0dc, 0x0130, 0x080c,
+	0x83d6, 0x080c, 0x9be6, 0x012e, 0x0005, 0x2009, 0x0049, 0x080c,
+	0x9c82, 0x012e, 0x0005, 0x080c, 0x98c7, 0x2001, 0x19e4, 0x2003,
+	0x0000, 0x7030, 0x9065, 0x090c, 0x0d65, 0x7034, 0x9092, 0x00c8,
+	0x1258, 0x8000, 0x7036, 0x7004, 0x9086, 0x0003, 0x0110, 0x7007,
+	0x0000, 0x781f, 0x0808, 0x0040, 0x080c, 0xd659, 0x6003, 0x0001,
+	0x2009, 0x0014, 0x080c, 0x9c82, 0x781f, 0x0100, 0x080c, 0x98e3,
+	0x012e, 0x0005, 0x080c, 0x98c7, 0x714c, 0x81ff, 0x1128, 0x2011,
+	0x19e7, 0x2013, 0x0000, 0x0400, 0x2061, 0x0100, 0x7150, 0x9192,
+	0x7530, 0x12b8, 0x8108, 0x7152, 0x714c, 0x9188, 0x0008, 0x210c,
+	0x918e, 0x0006, 0x1138, 0x6014, 0x9084, 0x1984, 0x9085, 0x0012,
+	0x6016, 0x0050, 0x6014, 0x9084, 0x1984, 0x9085, 0x0016, 0x6016,
+	0x0018, 0x706c, 0xc085, 0x706e, 0x781f, 0x0200, 0x080c, 0x98e3,
+	0x012e, 0x0005, 0x080c, 0x98c7, 0x714c, 0x2160, 0x6003, 0x0003,
+	0x2009, 0x004a, 0x080c, 0x9c82, 0x781f, 0x0200, 0x080c, 0x98e3,
+	0x012e, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820, 0x2060, 0x6003,
+	0x0003, 0x080c, 0x98c7, 0x080c, 0x1c27, 0x781f, 0x0400, 0x080c,
+	0x98e3, 0x012e, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820, 0x2060,
+	0x080c, 0x98c7, 0x080c, 0x1c6f, 0x781f, 0x0400, 0x080c, 0x98e3,
+	0x012e, 0x0005, 0x7030, 0x9065, 0x0148, 0x6044, 0xc0bc, 0x6046,
+	0x7104, 0x9186, 0x0003, 0x0110, 0x080c, 0x8950, 0x012e, 0x0005,
+	0x00f6, 0x703c, 0x9086, 0x0002, 0x0148, 0x704c, 0x907d, 0x0130,
+	0x7844, 0xc0bc, 0x7846, 0x080c, 0x8efa, 0x0000, 0x00fe, 0x012e,
+	0x0005, 0x080c, 0x715f, 0x012e, 0x0005, 0x080c, 0x0d65, 0x0005,
+	0x00e6, 0x2071, 0x19bf, 0x6044, 0xc0bc, 0x6046, 0xd0fc, 0x01b8,
+	0x704c, 0x9c06, 0x1190, 0x2019, 0x0001, 0x080c, 0x929d, 0x704f,
+	0x0000, 0x2001, 0x0109, 0x2004, 0xd08c, 0x1138, 0x2001, 0x0108,
+	0x2004, 0xd0bc, 0x1110, 0x703f, 0x0000, 0x080c, 0x94a4, 0x00ee,
+	0x0005, 0x0026, 0x7010, 0x9c06, 0x1178, 0x080c, 0x9363, 0x6044,
+	0xc0fc, 0x6046, 0x600c, 0x9015, 0x0120, 0x7212, 0x600f, 0x0000,
+	0x0010, 0x7212, 0x720e, 0x9006, 0x002e, 0x0005, 0x0026, 0x7020,
+	0x9c06, 0x1178, 0x080c, 0x9363, 0x6044, 0xc0fc, 0x6046, 0x600c,
+	0x9015, 0x0120, 0x7222, 0x600f, 0x0000, 0x0010, 0x7222, 0x721e,
+	0x9006, 0x002e, 0x0005, 0x00d6, 0x0036, 0x7830, 0x9c06, 0x1558,
+	0x2069, 0x0100, 0x68c0, 0x9005, 0x01f8, 0x080c, 0x821e, 0x080c,
+	0x8fd0, 0x68c3, 0x0000, 0x080c, 0x948d, 0x2069, 0x0140, 0x6b04,
+	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2872, 0x9006,
+	0x080c, 0x2872, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
+	0x0001, 0x9085, 0x0001, 0x0038, 0x7808, 0xc0ad, 0x780a, 0x6003,
+	0x0009, 0x630a, 0x9006, 0x003e, 0x00de, 0x0005, 0x0016, 0x0026,
+	0x0036, 0x6100, 0x2019, 0x0100, 0x2001, 0x0382, 0x2004, 0xd09c,
+	0x0190, 0x00c6, 0x0126, 0x2091, 0x2800, 0x0016, 0x0036, 0x080c,
+	0x992d, 0x003e, 0x001e, 0x012e, 0x00ce, 0x6200, 0x2200, 0x9106,
+	0x0d58, 0x2200, 0x0010, 0x8319, 0x1d38, 0x003e, 0x002e, 0x001e,
+	0x0005, 0x00d6, 0x0156, 0x080c, 0x8d84, 0x7a14, 0x82ff, 0x0138,
+	0x7003, 0x0100, 0x700b, 0x0003, 0x60c3, 0x0008, 0x0490, 0x7003,
+	0x0200, 0x7007, 0x0000, 0x2069, 0x1800, 0x901e, 0x6800, 0x9086,
+	0x0004, 0x1110, 0xc38d, 0x0060, 0x080c, 0x70ba, 0x1110, 0xc3ad,
+	0x0008, 0xc3a5, 0x6ad8, 0xd29c, 0x1110, 0xd2ac, 0x0108, 0xc39d,
+	0x730e, 0x2011, 0x1848, 0x63f0, 0x2312, 0x20a9, 0x0006, 0x2011,
+	0x1840, 0x2019, 0x1841, 0x2071, 0x0250, 0x2376, 0x8e70, 0x2276,
+	0x8e70, 0x9398, 0x0002, 0x9290, 0x0002, 0x1f04, 0x9b0d, 0x60c3,
+	0x0020, 0x080c, 0x8fa0, 0x015e, 0x00de, 0x0005, 0x0156, 0x080c,
+	0x8d84, 0x7a14, 0x82ff, 0x0168, 0x9286, 0xffff, 0x0118, 0x9282,
+	0x000e, 0x1238, 0x7003, 0x0100, 0x700b, 0x0003, 0x60c3, 0x0008,
+	0x0488, 0x7003, 0x0200, 0x7007, 0x001c, 0x700f, 0x0001, 0x2011,
+	0x1995, 0x2204, 0x8007, 0x701a, 0x8210, 0x2204, 0x8007, 0x701e,
+	0x0421, 0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181e,
+	0x2004, 0x7022, 0x2001, 0x181f, 0x2004, 0x7026, 0x0030, 0x2001,
+	0x1817, 0x2004, 0x9084, 0x00ff, 0x7026, 0x20a9, 0x0004, 0x20e1,
+	0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256, 0x4003,
+	0x60c3, 0x001c, 0x015e, 0x0804, 0x8fa0, 0x0006, 0x2001, 0x1836,
+	0x2004, 0xd0ac, 0x000e, 0x0005, 0x2011, 0x0003, 0x080c, 0x9324,
+	0x2011, 0x0002, 0x080c, 0x932e, 0x080c, 0x921d, 0x0036, 0x901e,
+	0x080c, 0x929d, 0x003e, 0x0005, 0x2071, 0x188b, 0x7000, 0x9005,
+	0x0140, 0x2001, 0x0812, 0x2071, 0x1800, 0x7072, 0x7076, 0x7067,
+	0xffd4, 0x2071, 0x1800, 0x7070, 0x7052, 0x7057, 0x1ddc, 0x0005,
+	0x00e6, 0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x7550, 0x9582,
+	0x0010, 0x0608, 0x7054, 0x2060, 0x6000, 0x9086, 0x0000, 0x0148,
+	0x9ce0, 0x001c, 0x7064, 0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1ddc,
+	0x0c98, 0x6003, 0x0008, 0x8529, 0x7552, 0x9ca8, 0x001c, 0x7064,
+	0x9502, 0x1230, 0x7556, 0x9085, 0x0001, 0x012e, 0x00ee, 0x0005,
+	0x7057, 0x1ddc, 0x0cc0, 0x9006, 0x0cc0, 0x00e6, 0x2071, 0x1800,
+	0x7550, 0x9582, 0x0010, 0x0600, 0x7054, 0x2060, 0x6000, 0x9086,
+	0x0000, 0x0148, 0x9ce0, 0x001c, 0x7064, 0x9c02, 0x1208, 0x0cb0,
+	0x2061, 0x1ddc, 0x0c98, 0x6003, 0x0008, 0x8529, 0x7552, 0x9ca8,
+	0x001c, 0x7064, 0x9502, 0x1228, 0x7556, 0x9085, 0x0001, 0x00ee,
+	0x0005, 0x7057, 0x1ddc, 0x0cc8, 0x9006, 0x0cc8, 0x9c82, 0x1ddc,
+	0x0a0c, 0x0d65, 0x2001, 0x1819, 0x2004, 0x9c02, 0x1a0c, 0x0d65,
+	0x9006, 0x6006, 0x600a, 0x600e, 0x6016, 0x601a, 0x6012, 0x6023,
+	0x0000, 0x6003, 0x0000, 0x601e, 0x605e, 0x6062, 0x6026, 0x602a,
+	0x602e, 0x6032, 0x6036, 0x603a, 0x603e, 0x604a, 0x6046, 0x6042,
+	0x2061, 0x1800, 0x6050, 0x8000, 0x6052, 0x0005, 0x9006, 0x600e,
+	0x6016, 0x601a, 0x6012, 0x6022, 0x6002, 0x601e, 0x605e, 0x6062,
+	0x604a, 0x6046, 0x2061, 0x1800, 0x6050, 0x8000, 0x6052, 0x0005,
+	0x0006, 0x6000, 0x9086, 0x0000, 0x01d0, 0x601c, 0xd084, 0x190c,
+	0x193e, 0x6023, 0x0007, 0x2001, 0x195e, 0x2004, 0x0006, 0x9082,
+	0x0051, 0x000e, 0x0208, 0x8004, 0x601a, 0x080c, 0xd517, 0x604b,
+	0x0000, 0x6044, 0xd0fc, 0x1129, 0x9006, 0x6046, 0x6016, 0x000e,
+	0x0005, 0x080c, 0x98c7, 0x0106, 0x2001, 0x19d2, 0x2004, 0x9c06,
+	0x1130, 0x0036, 0x2019, 0x0001, 0x080c, 0x929d, 0x003e, 0x080c,
+	0x94a4, 0x010e, 0x090c, 0x98e3, 0x0005, 0x00e6, 0x0126, 0x2071,
+	0x1800, 0x2091, 0x8000, 0x7550, 0x9582, 0x0001, 0x0608, 0x7054,
+	0x2060, 0x6000, 0x9086, 0x0000, 0x0148, 0x9ce0, 0x001c, 0x7064,
+	0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1ddc, 0x0c98, 0x6003, 0x0008,
+	0x8529, 0x7552, 0x9ca8, 0x001c, 0x7064, 0x9502, 0x1230, 0x7556,
+	0x9085, 0x0001, 0x012e, 0x00ee, 0x0005, 0x7057, 0x1ddc, 0x0cc0,
+	0x9006, 0x0cc0, 0x6020, 0x9084, 0x000f, 0x0002, 0x9c96, 0x9ca0,
+	0x9cbb, 0x9cd6, 0xbfe2, 0xbfff, 0xc01a, 0x9c96, 0x9ca0, 0x9c96,
+	0x9cf2, 0x9c96, 0x9c96, 0x9c96, 0x9c96, 0x9c96, 0x9186, 0x0013,
+	0x1130, 0x6044, 0xd0fc, 0x0110, 0x080c, 0x8891, 0x0005, 0x0005,
+	0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0d65, 0x0013, 0x006e,
+	0x0005, 0x9cb9, 0xa40f, 0xa5e3, 0x9cb9, 0xa671, 0x9fbb, 0x9cb9,
+	0x9cb9, 0xa391, 0xac18, 0x9cb9, 0x9cb9, 0x9cb9, 0x9cb9, 0x9cb9,
+	0x9cb9, 0x080c, 0x0d65, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c,
+	0x0d65, 0x0013, 0x006e, 0x0005, 0x9cd4, 0xb220, 0x9cd4, 0x9cd4,
+	0x9cd4, 0x9cd4, 0x9cd4, 0x9cd4, 0xb1c2, 0xb3a3, 0x9cd4, 0xb25d,
+	0xb2e1, 0xb25d, 0xb2e1, 0x9cd4, 0x080c, 0x0d65, 0x6000, 0x9082,
+	0x0016, 0x1a0c, 0x0d65, 0x6000, 0x0002, 0x9cf0, 0xac62, 0xacf9,
+	0xae79, 0xaee8, 0x9cf0, 0x9cf0, 0x9cf0, 0xac31, 0xb143, 0xb146,
+	0x9cf0, 0x9cf0, 0x9cf0, 0x9cf0, 0xb176, 0x9cf0, 0x9cf0, 0x9cf0,
+	0x080c, 0x0d65, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0d65,
+	0x0013, 0x006e, 0x0005, 0x9d0b, 0x9d0b, 0x9d49, 0x9de8, 0x9e68,
+	0x9d0b, 0x9d0b, 0x9d0b, 0x9d0d, 0x9d0b, 0x9d0b, 0x9d0b, 0x9d0b,
+	0x9d0b, 0x9d0b, 0x9d0b, 0x080c, 0x0d65, 0x9186, 0x004c, 0x0560,
+	0x9186, 0x0003, 0x190c, 0x0d65, 0x0096, 0x601c, 0xc0ed, 0x601e,
+	0x6003, 0x0003, 0x6106, 0x6014, 0x2048, 0xa87c, 0x9084, 0xa000,
+	0xc0b5, 0xa87e, 0xa8ac, 0xa836, 0xa8b0, 0xa83a, 0x9006, 0xa846,
+	0xa84a, 0xa884, 0x9092, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003,
+	0x8013, 0x8213, 0x9210, 0x621a, 0x009e, 0x080c, 0x1a89, 0x2009,
+	0x8030, 0x080c, 0x852e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xbca0,
+	0x00be, 0x2c00, 0x080c, 0x9e8a, 0x080c, 0xbfa7, 0x6003, 0x0007,
+	0x0005, 0x00d6, 0x0096, 0x00f6, 0x2079, 0x1800, 0x7a8c, 0x6014,
+	0x2048, 0xa87c, 0xd0ec, 0x1110, 0x9290, 0x0018, 0xac78, 0xc4fc,
+	0x0046, 0xa8e0, 0x9005, 0x1140, 0xa8dc, 0x921a, 0x0140, 0x0220,
+	0xa87b, 0x0007, 0x2010, 0x0028, 0xa87b, 0x0015, 0x0010, 0xa87b,
+	0x0000, 0x8214, 0xa883, 0x0000, 0xaa02, 0x0006, 0x0016, 0x0026,
+	0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2400, 0x9005, 0x1108, 0x009a,
+	0x2100, 0x9086, 0x0015, 0x1118, 0x2001, 0x0001, 0x0038, 0x2100,
+	0x9086, 0x0016, 0x0118, 0x2001, 0x0001, 0x002a, 0x94a4, 0x0007,
+	0x8423, 0x9405, 0x0002, 0x9db0, 0x9db0, 0x9dab, 0x9dae, 0x9db0,
+	0x9da8, 0x9d9b, 0x9d9b, 0x9d9b, 0x9d9b, 0x9d9b, 0x9d9b, 0x9d9b,
+	0x9d9b, 0x9d9b, 0x9d9b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e,
+	0x001e, 0x000e, 0x004e, 0x00fe, 0x009e, 0x00de, 0x080c, 0x0d65,
+	0x080c, 0xa854, 0x0028, 0x080c, 0xa977, 0x0010, 0x080c, 0xaa66,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e, 0x001e, 0x2c00, 0xa896,
+	0x000e, 0x080c, 0x9f48, 0x0530, 0xa804, 0xa80e, 0x00a6, 0x2050,
+	0xb100, 0x00ae, 0x8006, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
+	0xffc0, 0x9080, 0x0002, 0xaacc, 0xabd0, 0xacd4, 0xadd8, 0x2031,
+	0x0000, 0x2041, 0x1298, 0x080c, 0xa0f3, 0x0160, 0x000e, 0x9005,
+	0x0120, 0x00fe, 0x009e, 0x00de, 0x0005, 0x00fe, 0x009e, 0x00de,
+	0x0804, 0x9be6, 0x2001, 0x002c, 0x900e, 0x080c, 0x9fae, 0x0c70,
+	0x91b6, 0x0015, 0x0170, 0x91b6, 0x0016, 0x0158, 0x91b2, 0x0047,
+	0x0a0c, 0x0d65, 0x91b2, 0x0050, 0x1a0c, 0x0d65, 0x9182, 0x0047,
+	0x0042, 0x080c, 0x9ab6, 0x0120, 0x9086, 0x0002, 0x0904, 0x9d49,
+	0x0005, 0x9e0a, 0x9e0a, 0x9e0c, 0x9e3e, 0x9e0a, 0x9e0a, 0x9e0a,
+	0x9e0a, 0x9e51, 0x080c, 0x0d65, 0x00d6, 0x0016, 0x0096, 0x6003,
+	0x0004, 0x6114, 0x2148, 0xa87c, 0xd0fc, 0x01c0, 0xa878, 0xc0fc,
+	0x9005, 0x1158, 0xa894, 0x9005, 0x0140, 0x2001, 0x0000, 0x900e,
+	0x080c, 0x9fae, 0x080c, 0x9be6, 0x00a8, 0x6003, 0x0002, 0xa8a4,
+	0xa9a8, 0x9105, 0x1178, 0xa8ae, 0xa8b2, 0x0c78, 0xa87f, 0x0020,
+	0xa88c, 0xa88a, 0xa8a4, 0xa8ae, 0xa8a8, 0xa8b2, 0xa8c7, 0x0000,
+	0xa8cb, 0x0000, 0x009e, 0x001e, 0x00de, 0x0005, 0x080c, 0x88ec,
+	0x00d6, 0x0096, 0x6114, 0x2148, 0x080c, 0xb870, 0x0120, 0xa87b,
+	0x0006, 0x080c, 0x69b5, 0x009e, 0x00de, 0x080c, 0x9be6, 0x0804,
+	0x894f, 0x080c, 0x88ec, 0x080c, 0x302e, 0x080c, 0xbfa4, 0x00d6,
+	0x0096, 0x6114, 0x2148, 0x080c, 0xb870, 0x0120, 0xa87b, 0x0029,
+	0x080c, 0x69b5, 0x009e, 0x00de, 0x080c, 0x9be6, 0x0804, 0x894f,
+	0x9182, 0x0047, 0x0002, 0x9e78, 0x9e7a, 0x9e78, 0x9e78, 0x9e78,
+	0x9e78, 0x9e78, 0x9e78, 0x9e78, 0x9e78, 0x9e78, 0x9e78, 0x9e7a,
+	0x080c, 0x0d65, 0x00d6, 0x0096, 0x080c, 0x15af, 0x6114, 0x2148,
+	0xa87b, 0x0000, 0xa883, 0x0000, 0x080c, 0x69b5, 0x009e, 0x00de,
+	0x0804, 0x9be6, 0x0026, 0x0036, 0x0056, 0x0066, 0x0096, 0x00a6,
+	0x00f6, 0x0006, 0x080c, 0x102f, 0x000e, 0x090c, 0x0d65, 0xa960,
+	0x21e8, 0xa95c, 0x9188, 0x0019, 0x21a0, 0x900e, 0x20a9, 0x0020,
+	0x4104, 0xa87a, 0x2079, 0x1800, 0x798c, 0x9188, 0x0018, 0x918c,
+	0x0fff, 0xa972, 0xac76, 0x2950, 0x00a6, 0x2001, 0x0205, 0x2003,
+	0x0000, 0x901e, 0x2029, 0x0001, 0x9182, 0x0034, 0x1228, 0x2011,
+	0x001f, 0x080c, 0xb426, 0x04c0, 0x2130, 0x2009, 0x0034, 0x2011,
+	0x001f, 0x080c, 0xb426, 0x96b2, 0x0034, 0xb004, 0x904d, 0x0110,
+	0x080c, 0x0fe1, 0x080c, 0x102f, 0x01d0, 0x8528, 0xa867, 0x0110,
+	0xa86b, 0x0000, 0x2920, 0xb406, 0x968a, 0x003d, 0x1230, 0x2608,
+	0x2011, 0x001b, 0x080c, 0xb426, 0x00b8, 0x96b2, 0x003c, 0x2009,
+	0x003c, 0x2950, 0x2011, 0x001b, 0x080c, 0xb426, 0x0c18, 0x2001,
+	0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566,
+	0xb070, 0xc0fd, 0xb072, 0x0048, 0x2001, 0x0205, 0x2003, 0x0000,
+	0x00ae, 0x852f, 0x95ad, 0x0050, 0xb566, 0x2a48, 0xa804, 0xa807,
+	0x0000, 0x0006, 0x080c, 0x69b5, 0x000e, 0x2048, 0x9005, 0x1db0,
+	0x00fe, 0x00ae, 0x009e, 0x006e, 0x005e, 0x003e, 0x002e, 0x0005,
+	0x00d6, 0x00f6, 0x0096, 0x0006, 0x080c, 0x102f, 0x000e, 0x090c,
+	0x0d65, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019, 0x21a0, 0x900e,
+	0x20a9, 0x0020, 0x4104, 0xaa66, 0xa87a, 0x2079, 0x1800, 0x798c,
+	0x810c, 0x9188, 0x000c, 0x9182, 0x001a, 0x0210, 0x2009, 0x001a,
+	0x21a8, 0x810b, 0xa972, 0xac76, 0x2e98, 0xa85c, 0x9080, 0x001f,
+	0x20a0, 0x2001, 0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x4003,
+	0x2003, 0x0000, 0x080c, 0x69b5, 0x009e, 0x00fe, 0x00de, 0x0005,
+	0x0016, 0x00d6, 0x00f6, 0x0096, 0x0016, 0x2001, 0x0205, 0x200c,
+	0x918d, 0x0080, 0x2102, 0x001e, 0x2079, 0x0200, 0x2e98, 0xa87c,
+	0xd0ec, 0x0118, 0x9e80, 0x000c, 0x2098, 0x2021, 0x003e, 0x901e,
+	0x9282, 0x0020, 0x0218, 0x2011, 0x0020, 0x2018, 0x9486, 0x003e,
+	0x1170, 0x0096, 0x080c, 0x102f, 0x2900, 0x009e, 0x05c0, 0xa806,
+	0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x3300,
+	0x908e, 0x0260, 0x0140, 0x2009, 0x0280, 0x9102, 0x920a, 0x0218,
+	0x2010, 0x2100, 0x9318, 0x2200, 0x9402, 0x1228, 0x2400, 0x9202,
+	0x2410, 0x9318, 0x9006, 0x2020, 0x22a8, 0xa800, 0x9200, 0xa802,
+	0x20e1, 0x0000, 0x4003, 0x83ff, 0x0180, 0x3300, 0x9086, 0x0280,
+	0x1130, 0x7814, 0x8000, 0x9085, 0x0080, 0x7816, 0x2e98, 0x2310,
+	0x84ff, 0x0904, 0x9f5d, 0x0804, 0x9f5f, 0x9085, 0x0001, 0x7817,
+	0x0000, 0x009e, 0x00fe, 0x00de, 0x001e, 0x0005, 0x00d6, 0x0036,
+	0x0096, 0x6314, 0x2348, 0xa87a, 0xa982, 0x080c, 0x69a9, 0x009e,
+	0x003e, 0x00de, 0x0005, 0x91b6, 0x0015, 0x1118, 0x080c, 0x9be6,
+	0x0030, 0x91b6, 0x0016, 0x190c, 0x0d65, 0x080c, 0x9be6, 0x0005,
+	0x20a9, 0x000e, 0x20e1, 0x0000, 0x2e98, 0x6014, 0x0096, 0x2048,
+	0xa860, 0x20e8, 0xa85c, 0x20a0, 0x009e, 0x4003, 0x0136, 0x9080,
+	0x001b, 0x20a0, 0x2011, 0x0006, 0x20a9, 0x0001, 0x3418, 0x8318,
+	0x23a0, 0x4003, 0x3318, 0x8318, 0x2398, 0x8211, 0x1db8, 0x2011,
+	0x0006, 0x013e, 0x20a0, 0x3318, 0x8318, 0x2398, 0x4003, 0x3418,
+	0x8318, 0x23a0, 0x8211, 0x1db8, 0x0096, 0x080c, 0xb870, 0x0130,
+	0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103, 0x009e, 0x0804,
+	0x9be6, 0x0096, 0x00d6, 0x0036, 0x7330, 0x9386, 0x0200, 0x11a8,
+	0x6010, 0x00b6, 0x2058, 0xb8c7, 0x0000, 0x00be, 0x6014, 0x9005,
+	0x0130, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103, 0xab32, 0x080c,
+	0x9be6, 0x003e, 0x00de, 0x009e, 0x0005, 0x0011, 0x1d48, 0x0cc8,
+	0x0006, 0x0016, 0x080c, 0xbf8f, 0x0188, 0x6014, 0x9005, 0x1170,
+	0x600b, 0x0003, 0x601b, 0x0000, 0x604b, 0x0000, 0x2009, 0x0022,
+	0x080c, 0xa3e7, 0x9006, 0x001e, 0x000e, 0x0005, 0x9085, 0x0001,
+	0x0cd0, 0x0096, 0x0016, 0x20a9, 0x0014, 0x9e80, 0x000c, 0x20e1,
+	0x0000, 0x2098, 0x6014, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0002, 0x20a0, 0x4003, 0x2001, 0x0205, 0x2003, 0x0001, 0x2099,
+	0x0260, 0x20a9, 0x0016, 0x4003, 0x20a9, 0x000a, 0xa804, 0x2048,
 	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x2001,
-	0x0205, 0x2003, 0x0001, 0x2099, 0x0260, 0x20a9, 0x0016, 0x4003,
-	0x20a9, 0x000a, 0xa804, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080,
-	0x0002, 0x20a0, 0x4003, 0x2001, 0x0205, 0x2003, 0x0002, 0x2099,
-	0x0260, 0x20a9, 0x0020, 0x4003, 0x2003, 0x0000, 0x6014, 0x2048,
-	0xa800, 0x2048, 0xa867, 0x0103, 0x080c, 0x9bda, 0x001e, 0x009e,
-	0x0005, 0x0096, 0x0016, 0x900e, 0x7030, 0x9086, 0x0100, 0x0140,
-	0x7038, 0x9084, 0x00ff, 0x800c, 0x703c, 0x9084, 0x00ff, 0x8004,
-	0x9080, 0x0004, 0x9108, 0x810b, 0x2011, 0x0002, 0x2019, 0x000c,
-	0x6014, 0x2048, 0x080c, 0xb408, 0x080c, 0xb842, 0x0140, 0x6014,
-	0x2048, 0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c,
-	0x9bda, 0x001e, 0x009e, 0x0005, 0x0016, 0x0096, 0x7030, 0x9086,
-	0x0100, 0x1118, 0x2009, 0x0004, 0x0010, 0x7034, 0x800c, 0x810b,
-	0x2011, 0x000c, 0x2019, 0x000c, 0x6014, 0x2048, 0xa804, 0x0096,
-	0x9005, 0x0108, 0x2048, 0x080c, 0xb408, 0x009e, 0x080c, 0xb842,
-	0x0148, 0xa804, 0x9005, 0x1158, 0xa807, 0x0000, 0xa864, 0xa8e2,
-	0xa867, 0x0103, 0x080c, 0x9bda, 0x009e, 0x001e, 0x0005, 0x0086,
-	0x2040, 0xa030, 0x8007, 0x9086, 0x0100, 0x1118, 0x080c, 0xa581,
-	0x00e0, 0xa034, 0x8007, 0x800c, 0x8806, 0x8006, 0x8007, 0x90bc,
-	0x003f, 0x9084, 0xffc0, 0x9080, 0x000c, 0xa87b, 0x0000, 0xa883,
-	0x0000, 0xa897, 0x4000, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031,
-	0x0000, 0x2041, 0x1271, 0x0019, 0x0d08, 0x008e, 0x0898, 0x0096,
-	0x0006, 0x080c, 0x1022, 0x000e, 0x01b0, 0xa8ab, 0x0dcb, 0xa876,
-	0x000e, 0xa8a2, 0x0006, 0xae6a, 0x2800, 0xa89e, 0xa97a, 0xaf72,
-	0xaa8e, 0xab92, 0xac96, 0xad9a, 0x0086, 0x2940, 0x080c, 0x1117,
-	0x008e, 0x9085, 0x0001, 0x009e, 0x0005, 0x00e6, 0x00d6, 0x0026,
-	0x7008, 0x9084, 0x00ff, 0x6210, 0x00b6, 0x2258, 0xba10, 0x00be,
-	0x9206, 0x1520, 0x700c, 0x6210, 0x00b6, 0x2258, 0xba14, 0x00be,
-	0x9206, 0x11e0, 0x604b, 0x0000, 0x2c68, 0x0016, 0x2009, 0x0035,
-	0x080c, 0xbed9, 0x001e, 0x1158, 0x622c, 0x2268, 0x2071, 0x026c,
-	0x6b20, 0x9386, 0x0003, 0x0130, 0x9386, 0x0006, 0x0128, 0x080c,
-	0x9bda, 0x0020, 0x0039, 0x0010, 0x080c, 0xa203, 0x002e, 0x00de,
-	0x00ee, 0x0005, 0x0096, 0x6814, 0x2048, 0x9186, 0x0015, 0x0904,
-	0xa1e2, 0x918e, 0x0016, 0x1904, 0xa201, 0x700c, 0x908c, 0xff00,
-	0x9186, 0x1700, 0x0120, 0x9186, 0x0300, 0x1904, 0xa1bc, 0x89ff,
-	0x1138, 0x6800, 0x9086, 0x000f, 0x0904, 0xa19e, 0x0804, 0xa1ff,
-	0x6808, 0x9086, 0xffff, 0x1904, 0xa1e4, 0xa87c, 0x9084, 0x0060,
-	0x9086, 0x0020, 0x1128, 0xa83c, 0xa940, 0x9105, 0x1904, 0xa1e4,
-	0x6824, 0xd0b4, 0x1904, 0xa1e4, 0x080c, 0xba31, 0x6864, 0xa882,
-	0xa87c, 0xc0dc, 0xc0f4, 0xc0d4, 0xa87e, 0x0026, 0x900e, 0x6a18,
-	0x2001, 0x000a, 0x080c, 0x83fb, 0xa884, 0x920a, 0x0208, 0x8011,
-	0xaa86, 0x82ff, 0x002e, 0x1138, 0x00c6, 0x2d60, 0x080c, 0xb55b,
-	0x00ce, 0x0804, 0xa1ff, 0x00c6, 0xa868, 0xd0fc, 0x1118, 0x080c,
-	0x5d51, 0x0010, 0x080c, 0x60f6, 0x00ce, 0x1904, 0xa1e4, 0x00c6,
-	0x2d60, 0x080c, 0x9bda, 0x00ce, 0x0804, 0xa1ff, 0x00c6, 0x080c,
-	0x9c49, 0x0198, 0x6017, 0x0000, 0x6810, 0x6012, 0x080c, 0xbcdb,
-	0x6023, 0x0003, 0x6904, 0x00c6, 0x2d60, 0x080c, 0x9bda, 0x00ce,
-	0x080c, 0x9c76, 0x00ce, 0x0804, 0xa1ff, 0x2001, 0x1958, 0x2004,
-	0x684a, 0x00ce, 0x0804, 0xa1ff, 0x7008, 0x9086, 0x000b, 0x11c8,
-	0x6010, 0x00b6, 0x2058, 0xb900, 0xc1bc, 0xb902, 0x00be, 0x00c6,
-	0x2d60, 0xa87b, 0x0003, 0x080c, 0xbf1b, 0x6007, 0x0085, 0x6003,
-	0x000b, 0x6023, 0x0002, 0x2009, 0x8020, 0x080c, 0x84b3, 0x00ce,
-	0x0430, 0x700c, 0x9086, 0x2a00, 0x1138, 0x2001, 0x1958, 0x2004,
-	0x684a, 0x00e8, 0x04c1, 0x00e8, 0x89ff, 0x090c, 0x0d65, 0x00c6,
-	0x00d6, 0x2d60, 0xa867, 0x0103, 0xa87b, 0x0003, 0x080c, 0x67a7,
-	0x080c, 0xba31, 0x080c, 0x9c14, 0x0026, 0x6010, 0x00b6, 0x2058,
-	0xba3c, 0x080c, 0x6396, 0x00be, 0x002e, 0x00de, 0x00ce, 0x080c,
-	0x9bda, 0x009e, 0x0005, 0x9186, 0x0015, 0x1128, 0x2001, 0x1958,
-	0x2004, 0x684a, 0x0068, 0x918e, 0x0016, 0x1160, 0x00c6, 0x2d00,
-	0x2060, 0x080c, 0xd4df, 0x080c, 0x83a2, 0x080c, 0x9bda, 0x00ce,
-	0x080c, 0x9bda, 0x0005, 0x0026, 0x0036, 0x0046, 0x7228, 0xacb0,
-	0xabac, 0xd2f4, 0x0130, 0x2001, 0x1958, 0x2004, 0x684a, 0x0804,
-	0xa27d, 0x00c6, 0x2d60, 0x080c, 0xb433, 0x00ce, 0x6804, 0x9086,
-	0x0050, 0x1168, 0x00c6, 0x2d00, 0x2060, 0x6003, 0x0001, 0x6007,
-	0x0050, 0x2009, 0x8023, 0x080c, 0x84b3, 0x00ce, 0x04f0, 0x6800,
-	0x9086, 0x000f, 0x01a8, 0x89ff, 0x090c, 0x0d65, 0x6800, 0x9086,
-	0x0004, 0x1190, 0xa87c, 0xd0ac, 0x0178, 0xa843, 0x0fff, 0xa83f,
-	0x0fff, 0xa880, 0xc0fc, 0xa882, 0x2001, 0x0001, 0x6832, 0x0400,
-	0x2001, 0x0007, 0x6832, 0x00e0, 0xa87c, 0xd0b4, 0x1150, 0xd0ac,
-	0x0db8, 0x6824, 0xd0f4, 0x1d48, 0xa838, 0xa934, 0x9105, 0x0d80,
-	0x0c20, 0xd2ec, 0x1d68, 0x7024, 0x9306, 0x1118, 0x7020, 0x9406,
-	0x0d38, 0x7020, 0x683e, 0x7024, 0x683a, 0x2001, 0x0005, 0x6832,
-	0x080c, 0xbbc5, 0x080c, 0x891b, 0x0010, 0x080c, 0x9bda, 0x004e,
-	0x003e, 0x002e, 0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084,
-	0x00ff, 0x6210, 0x00b6, 0x2258, 0xba10, 0x00be, 0x9206, 0x1904,
-	0xa2e8, 0x700c, 0x6210, 0x00b6, 0x2258, 0xba14, 0x00be, 0x9206,
-	0x1904, 0xa2e8, 0x6038, 0x2068, 0x6824, 0xc0dc, 0x6826, 0x6a20,
-	0x9286, 0x0007, 0x0904, 0xa2e8, 0x9286, 0x0002, 0x0904, 0xa2e8,
-	0x9286, 0x0000, 0x05e8, 0x6808, 0x633c, 0x9306, 0x15c8, 0x2071,
-	0x026c, 0x9186, 0x0015, 0x0570, 0x918e, 0x0016, 0x1100, 0x00c6,
-	0x6038, 0x2060, 0x6104, 0x9186, 0x004b, 0x01c0, 0x9186, 0x004c,
-	0x01a8, 0x9186, 0x004d, 0x0190, 0x9186, 0x004e, 0x0178, 0x9186,
-	0x0052, 0x0160, 0x6014, 0x0096, 0x2048, 0x080c, 0xb842, 0x090c,
-	0x0d65, 0xa87b, 0x0003, 0x009e, 0x080c, 0xbf1b, 0x6007, 0x0085,
-	0x6003, 0x000b, 0x6023, 0x0002, 0x2009, 0x8020, 0x080c, 0x84b3,
-	0x00ce, 0x0030, 0x6038, 0x2070, 0x2001, 0x1958, 0x2004, 0x704a,
-	0x080c, 0x9bda, 0x002e, 0x00de, 0x00ee, 0x0005, 0x00b6, 0x0096,
-	0x00f6, 0x6014, 0x2048, 0x6010, 0x2058, 0x91b6, 0x0015, 0x0130,
-	0xba08, 0xbb0c, 0xbc00, 0xc48c, 0xbc02, 0x0460, 0x0096, 0x0156,
-	0x0036, 0x0026, 0x2b48, 0x9e90, 0x0010, 0x2019, 0x000a, 0x20a9,
-	0x0004, 0x080c, 0xabd3, 0x002e, 0x003e, 0x015e, 0x009e, 0x1904,
-	0xa357, 0x0096, 0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90, 0x0014,
-	0x2019, 0x0006, 0x20a9, 0x0004, 0x080c, 0xabd3, 0x002e, 0x003e,
-	0x015e, 0x009e, 0x15a0, 0x7238, 0xba0a, 0x733c, 0xbb0e, 0xbc00,
-	0xc48d, 0xbc02, 0xa804, 0x9005, 0x1128, 0x00fe, 0x009e, 0x00be,
-	0x0804, 0x9fe8, 0x0096, 0x2048, 0xaa12, 0xab16, 0xac0a, 0x009e,
-	0x8006, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
-	0x0002, 0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031,
-	0x0000, 0x2041, 0x1271, 0x080c, 0xa0e7, 0x0130, 0x00fe, 0x009e,
-	0x080c, 0x9bda, 0x00be, 0x0005, 0x080c, 0xa581, 0x0cb8, 0x2b78,
-	0x00f6, 0x080c, 0x300e, 0x080c, 0xbf76, 0x00fe, 0x00c6, 0x080c,
-	0x9b84, 0x2f00, 0x6012, 0x6017, 0x0000, 0x6023, 0x0001, 0x6007,
-	0x0001, 0x6003, 0x0001, 0x2001, 0x0007, 0x080c, 0x61bc, 0x080c,
-	0x61e8, 0x080c, 0x84ba, 0x080c, 0x891b, 0x00ce, 0x0804, 0xa32a,
-	0x2100, 0x91b2, 0x0053, 0x1a0c, 0x0d65, 0x91b2, 0x0040, 0x1a04,
-	0xa3e0, 0x0002, 0xa3ce, 0xa3ce, 0xa3c4, 0xa3ce, 0xa3ce, 0xa3ce,
-	0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2,
-	0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2,
-	0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2,
-	0xa3c2, 0xa3ce, 0xa3c2, 0xa3ce, 0xa3ce, 0xa3c2, 0xa3c2, 0xa3c2,
-	0xa3c2, 0xa3c2, 0xa3c4, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2,
-	0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3ce, 0xa3ce, 0xa3c2, 0xa3c2,
-	0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3c2, 0xa3ce,
-	0xa3c2, 0xa3c2, 0x080c, 0x0d65, 0x0066, 0x00b6, 0x6610, 0x2658,
-	0xb8c4, 0xc08c, 0xb8c6, 0x00be, 0x006e, 0x0000, 0x6003, 0x0001,
-	0x6106, 0x9186, 0x0032, 0x0118, 0x080c, 0x84ba, 0x0010, 0x080c,
-	0x84b3, 0x0126, 0x2091, 0x8000, 0x080c, 0x891b, 0x012e, 0x0005,
-	0x2600, 0x0002, 0xa3f4, 0xa3f4, 0xa3f4, 0xa3ce, 0xa3ce, 0xa3f4,
-	0xa3f4, 0xa3f4, 0xa3f4, 0xa3ce, 0xa3f4, 0xa3ce, 0xa3f4, 0xa3ce,
-	0xa3f4, 0xa3f4, 0xa3f4, 0xa3f4, 0x080c, 0x0d65, 0x6004, 0x90b2,
-	0x0053, 0x1a0c, 0x0d65, 0x91b6, 0x0013, 0x0904, 0xa4cb, 0x91b6,
-	0x0027, 0x1904, 0xa477, 0x080c, 0x885d, 0x6004, 0x080c, 0xba46,
-	0x01b0, 0x080c, 0xba57, 0x01a8, 0x908e, 0x0021, 0x0904, 0xa474,
-	0x908e, 0x0022, 0x1130, 0x080c, 0xa014, 0x0904, 0xa470, 0x0804,
-	0xa471, 0x908e, 0x003d, 0x0904, 0xa474, 0x0804, 0xa46a, 0x080c,
-	0x303d, 0x2001, 0x0007, 0x080c, 0x61bc, 0x6010, 0x00b6, 0x2058,
-	0xb9a0, 0x00be, 0x080c, 0xa581, 0x9186, 0x007e, 0x1148, 0x2001,
-	0x1836, 0x2014, 0xc285, 0x080c, 0x7096, 0x1108, 0xc2ad, 0x2202,
-	0x080c, 0x98bb, 0x0036, 0x0026, 0x2019, 0x0028, 0x2110, 0x080c,
-	0xd53a, 0x002e, 0x003e, 0x0016, 0x0026, 0x0036, 0x2110, 0x2019,
-	0x0028, 0x080c, 0x8624, 0x0076, 0x903e, 0x080c, 0x8509, 0x6010,
-	0x00b6, 0x905d, 0x0100, 0x00be, 0x2c08, 0x080c, 0xcfd9, 0x007e,
-	0x003e, 0x002e, 0x001e, 0x080c, 0x98d7, 0x080c, 0xbf76, 0x0016,
-	0x080c, 0xbcd3, 0x080c, 0x9bda, 0x001e, 0x080c, 0x3116, 0x080c,
-	0x891b, 0x0030, 0x080c, 0xbcd3, 0x080c, 0x9bda, 0x080c, 0x891b,
-	0x0005, 0x080c, 0xa581, 0x0cb0, 0x080c, 0xa5bd, 0x0c98, 0x9186,
-	0x0015, 0x0118, 0x9186, 0x0016, 0x1140, 0x080c, 0x9aaa, 0x0d80,
-	0x9086, 0x0002, 0x0904, 0xa5c8, 0x0c58, 0x9186, 0x0014, 0x1d40,
-	0x080c, 0x885d, 0x6004, 0x908e, 0x0022, 0x1118, 0x080c, 0xa014,
-	0x09f8, 0x080c, 0x300e, 0x080c, 0xbf76, 0x080c, 0xba46, 0x1190,
-	0x080c, 0x303d, 0x6010, 0x00b6, 0x2058, 0xb9a0, 0x00be, 0x080c,
-	0xa581, 0x9186, 0x007e, 0x1128, 0x2001, 0x1836, 0x200c, 0xc185,
-	0x2102, 0x0800, 0x080c, 0xba57, 0x1120, 0x080c, 0xa581, 0x0804,
-	0xa46a, 0x6004, 0x908e, 0x0032, 0x1160, 0x00e6, 0x00f6, 0x2071,
-	0x1894, 0x2079, 0x0000, 0x080c, 0x33b0, 0x00fe, 0x00ee, 0x0804,
-	0xa46a, 0x6004, 0x908e, 0x0021, 0x0d40, 0x908e, 0x0022, 0x090c,
-	0xa581, 0x0804, 0xa46a, 0x90b2, 0x0040, 0x1a04, 0xa56a, 0x2008,
-	0x0002, 0xa513, 0xa514, 0xa517, 0xa51a, 0xa51d, 0xa520, 0xa511,
-	0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511,
-	0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511,
-	0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511, 0xa523,
-	0xa52c, 0xa511, 0xa52d, 0xa52c, 0xa511, 0xa511, 0xa511, 0xa511,
-	0xa511, 0xa52c, 0xa52c, 0xa511, 0xa511, 0xa511, 0xa511, 0xa511,
-	0xa511, 0xa511, 0xa511, 0xa555, 0xa52c, 0xa511, 0xa528, 0xa511,
-	0xa511, 0xa511, 0xa529, 0xa511, 0xa511, 0xa511, 0xa52c, 0xa550,
-	0xa511, 0x080c, 0x0d65, 0x00c0, 0x2001, 0x000b, 0x00e8, 0x2001,
-	0x0003, 0x00d0, 0x2001, 0x0005, 0x00b8, 0x2001, 0x0001, 0x00a0,
-	0x2001, 0x0009, 0x0088, 0x6003, 0x0005, 0x080c, 0x891b, 0x0058,
-	0x0018, 0x0010, 0x080c, 0x61bc, 0x04b8, 0x080c, 0xbf79, 0x6003,
-	0x0004, 0x080c, 0x891b, 0x0005, 0x080c, 0x61bc, 0x6003, 0x0002,
-	0x0036, 0x2019, 0x185e, 0x2304, 0x9084, 0xff00, 0x1120, 0x2001,
-	0x1956, 0x201c, 0x0040, 0x8007, 0x909a, 0x0004, 0x0ec0, 0x8003,
-	0x801b, 0x831b, 0x9318, 0x631a, 0x003e, 0x080c, 0x891b, 0x0c18,
-	0x080c, 0xbcd3, 0x080c, 0x9bda, 0x08f0, 0x00e6, 0x00f6, 0x2071,
-	0x1894, 0x2079, 0x0000, 0x080c, 0x33b0, 0x00fe, 0x00ee, 0x080c,
-	0x885d, 0x080c, 0x9bda, 0x0878, 0x6003, 0x0002, 0x080c, 0xbf79,
-	0x0804, 0x891b, 0x2600, 0x2008, 0x0002, 0xa57f, 0xa57f, 0xa57f,
-	0xa564, 0xa564, 0xa57f, 0xa57f, 0xa57f, 0xa57f, 0xa564, 0xa57f,
-	0xa564, 0xa57f, 0xa564, 0xa57f, 0xa57f, 0xa57f, 0xa57f, 0x080c,
-	0x0d65, 0x00e6, 0x0096, 0x0026, 0x0016, 0x080c, 0xb842, 0x0568,
-	0x6014, 0x2048, 0xa864, 0x9086, 0x0139, 0x11a8, 0xa894, 0x9086,
-	0x0056, 0x1148, 0x080c, 0x5129, 0x0130, 0x2001, 0x0000, 0x900e,
-	0x2011, 0x4000, 0x0028, 0x2001, 0x0030, 0x900e, 0x2011, 0x4005,
-	0x080c, 0xbe40, 0x0090, 0xa868, 0xd0fc, 0x0178, 0xa807, 0x0000,
-	0x0016, 0x6004, 0x908e, 0x0021, 0x0168, 0x908e, 0x003d, 0x0150,
-	0x001e, 0xa867, 0x0103, 0xa833, 0x0100, 0x001e, 0x002e, 0x009e,
-	0x00ee, 0x0005, 0x001e, 0x0009, 0x0cc0, 0x0096, 0x6014, 0x2048,
-	0xa800, 0x2048, 0xa867, 0x0103, 0xa823, 0x8001, 0x009e, 0x0005,
-	0x00b6, 0x6610, 0x2658, 0xb804, 0x9084, 0x00ff, 0x90b2, 0x000c,
-	0x1a0c, 0x0d65, 0x6604, 0x96b6, 0x004d, 0x1120, 0x080c, 0xbd5f,
-	0x0804, 0xa645, 0x6604, 0x96b6, 0x0043, 0x1120, 0x080c, 0xbda8,
-	0x0804, 0xa645, 0x6604, 0x96b6, 0x004b, 0x1120, 0x080c, 0xbdd4,
-	0x0804, 0xa645, 0x6604, 0x96b6, 0x0033, 0x1120, 0x080c, 0xbcf5,
-	0x0804, 0xa645, 0x6604, 0x96b6, 0x0028, 0x1120, 0x080c, 0xba95,
-	0x0804, 0xa645, 0x6604, 0x96b6, 0x0029, 0x1120, 0x080c, 0xbad6,
-	0x0804, 0xa645, 0x6604, 0x96b6, 0x001f, 0x1118, 0x080c, 0x9fbc,
-	0x04e0, 0x6604, 0x96b6, 0x0000, 0x1118, 0x080c, 0xa2ee, 0x04a8,
-	0x6604, 0x96b6, 0x0022, 0x1118, 0x080c, 0x9ff5, 0x0470, 0x6604,
-	0x96b6, 0x0035, 0x1118, 0x080c, 0xa105, 0x0438, 0x6604, 0x96b6,
-	0x0039, 0x1118, 0x080c, 0xa283, 0x0400, 0x6604, 0x96b6, 0x003d,
-	0x1118, 0x080c, 0xa02d, 0x00c8, 0x6604, 0x96b6, 0x0044, 0x1118,
-	0x080c, 0xa069, 0x0090, 0x6604, 0x96b6, 0x0049, 0x1118, 0x080c,
-	0xa094, 0x0058, 0x91b6, 0x0015, 0x1110, 0x0063, 0x0030, 0x91b6,
-	0x0016, 0x1128, 0x00be, 0x0804, 0xa905, 0x00be, 0x0005, 0x080c,
-	0x9c93, 0x0cd8, 0xa662, 0xa665, 0xa662, 0xa6a9, 0xa662, 0xa839,
-	0xa912, 0xa662, 0xa662, 0xa8df, 0xa662, 0xa8f3, 0x0096, 0x080c,
-	0x15a2, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103, 0x009e,
-	0x0804, 0x9bda, 0xa001, 0xa001, 0x0005, 0x00e6, 0x2071, 0x1800,
-	0x708c, 0x9086, 0x0074, 0x1540, 0x080c, 0xcfaa, 0x11b0, 0x6010,
-	0x00b6, 0x2058, 0x7030, 0xd08c, 0x0128, 0xb800, 0xd0bc, 0x0110,
-	0xc0c5, 0xb802, 0x00e9, 0x00be, 0x2001, 0x0006, 0x080c, 0x61bc,
-	0x080c, 0x303d, 0x080c, 0x9bda, 0x0088, 0x2001, 0x000a, 0x080c,
-	0x61bc, 0x080c, 0x303d, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c,
-	0x84ba, 0x080c, 0x891b, 0x0010, 0x080c, 0xa824, 0x00ee, 0x0005,
-	0x00d6, 0xb800, 0xd084, 0x0158, 0x9006, 0x080c, 0x61a8, 0x2069,
-	0x1853, 0x6804, 0x0020, 0x2001, 0x0006, 0x080c, 0x61e8, 0x00de,
-	0x0005, 0x00b6, 0x0096, 0x00d6, 0x2011, 0x1823, 0x2204, 0x9086,
-	0x0074, 0x1904, 0xa7fb, 0x6010, 0x2058, 0xbaa0, 0x9286, 0x007e,
-	0x1120, 0x080c, 0xaa56, 0x0804, 0xa760, 0x00d6, 0x080c, 0x7096,
-	0x0198, 0x0026, 0x2011, 0x0010, 0x080c, 0x668a, 0x002e, 0x05c8,
-	0x080c, 0x539c, 0x1540, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867,
-	0x0103, 0xa833, 0xdead, 0x00f8, 0x0026, 0x2011, 0x8008, 0x080c,
-	0x668a, 0x002e, 0x0530, 0x6014, 0x2048, 0xa864, 0x9084, 0x00ff,
-	0x9086, 0x0039, 0x1140, 0x2001, 0x0030, 0x900e, 0x2011, 0x4009,
-	0x080c, 0xbe40, 0x0040, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867,
-	0x0103, 0xa833, 0xdead, 0x6010, 0x2058, 0xb9a0, 0x0016, 0x080c,
-	0x303d, 0x080c, 0x9bda, 0x001e, 0x080c, 0x3116, 0x00de, 0x0804,
-	0xa7fe, 0x00de, 0x080c, 0xaa4b, 0x6010, 0x2058, 0xbaa0, 0x9286,
-	0x0080, 0x1510, 0x6014, 0x9005, 0x01a8, 0x2048, 0xa864, 0x9084,
-	0x00ff, 0x9086, 0x0039, 0x1140, 0x2001, 0x0000, 0x900e, 0x2011,
-	0x4000, 0x080c, 0xbe40, 0x0030, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xa833, 0x0200, 0x2001, 0x0006, 0x080c, 0x61bc, 0x080c, 0x303d,
-	0x080c, 0x9bda, 0x0804, 0xa7fe, 0x080c, 0xa80c, 0x6014, 0x9005,
-	0x0190, 0x2048, 0xa868, 0xd0f4, 0x01e8, 0xa864, 0x9084, 0x00ff,
-	0x9086, 0x0039, 0x1d08, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000,
-	0x080c, 0xbe40, 0x08f8, 0x080c, 0xa802, 0x0160, 0x9006, 0x080c,
-	0x61a8, 0x2001, 0x0004, 0x080c, 0x61e8, 0x2001, 0x0007, 0x080c,
-	0x61bc, 0x08a0, 0x2001, 0x0004, 0x080c, 0x61bc, 0x6003, 0x0001,
-	0x6007, 0x0003, 0x080c, 0x84ba, 0x080c, 0x891b, 0x0804, 0xa7fe,
-	0xb85c, 0xd0e4, 0x01d0, 0x080c, 0xbc6d, 0x080c, 0x7096, 0x0118,
-	0xd0dc, 0x1904, 0xa722, 0x2011, 0x1836, 0x2204, 0xc0ad, 0x2012,
-	0x2001, 0x0002, 0x00f6, 0x2079, 0x0100, 0x78e3, 0x0000, 0x080c,
-	0x24b1, 0x78e2, 0x00fe, 0x0804, 0xa722, 0x080c, 0xbcae, 0x2011,
-	0x1836, 0x2204, 0xc0a5, 0x2012, 0x0006, 0x080c, 0xd10f, 0x000e,
-	0x1904, 0xa722, 0xc0b5, 0x2012, 0x2001, 0x0006, 0x080c, 0x61bc,
-	0x9006, 0x080c, 0x61a8, 0x00c6, 0x2001, 0x180f, 0x2004, 0xd09c,
-	0x0520, 0x00f6, 0x2079, 0x0100, 0x00e6, 0x2071, 0x1800, 0x700c,
-	0x9084, 0x00ff, 0x78e6, 0x707a, 0x7010, 0x78ea, 0x707e, 0x908c,
-	0x00ff, 0x00ee, 0x780c, 0xc0b5, 0x780e, 0x00fe, 0x080c, 0x2486,
-	0x00f6, 0x2100, 0x900e, 0x080c, 0x243d, 0x795a, 0x00fe, 0x9186,
-	0x0081, 0x01d8, 0x2009, 0x0081, 0x00c8, 0x2009, 0x00ef, 0x00f6,
-	0x2079, 0x0100, 0x79ea, 0x7932, 0x7936, 0x780c, 0xc0b5, 0x780e,
-	0x00fe, 0x080c, 0x2486, 0x00f6, 0x2079, 0x1800, 0x797e, 0x2100,
-	0x900e, 0x080c, 0x243d, 0x795a, 0x00fe, 0x8108, 0x080c, 0x620b,
-	0x2b00, 0x00ce, 0x1904, 0xa722, 0x6012, 0x2009, 0x180f, 0x210c,
-	0xd19c, 0x0150, 0x2009, 0x027c, 0x210c, 0x918c, 0x00ff, 0xb912,
-	0x2009, 0x027d, 0x210c, 0xb916, 0x2001, 0x0002, 0x080c, 0x61bc,
-	0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x84ba,
-	0x080c, 0x891b, 0x0018, 0x080c, 0xa581, 0x0431, 0x00de, 0x009e,
-	0x00be, 0x0005, 0x2001, 0x1810, 0x2004, 0xd0a4, 0x0120, 0x2001,
-	0x1854, 0x2004, 0xd0ac, 0x0005, 0x00e6, 0x080c, 0xd593, 0x0190,
-	0x2071, 0x0260, 0x7108, 0x720c, 0x918c, 0x00ff, 0x1118, 0x9284,
-	0xff00, 0x0140, 0x6010, 0x2058, 0xb8a0, 0x9084, 0xff80, 0x1110,
-	0xb912, 0xba16, 0x00ee, 0x0005, 0x2030, 0x2001, 0x0007, 0x080c,
-	0x61bc, 0x080c, 0x539c, 0x1120, 0x2001, 0x0007, 0x080c, 0x61e8,
-	0x080c, 0x303d, 0x6020, 0x9086, 0x000a, 0x1108, 0x0005, 0x0804,
-	0x9bda, 0x00b6, 0x00e6, 0x0026, 0x0016, 0x2071, 0x1800, 0x708c,
-	0x9086, 0x0014, 0x1904, 0xa8d6, 0x00d6, 0x080c, 0x7096, 0x0198,
-	0x0026, 0x2011, 0x0010, 0x080c, 0x668a, 0x002e, 0x05c8, 0x080c,
-	0x539c, 0x1540, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xa833, 0xdead, 0x00f8, 0x0026, 0x2011, 0x8008, 0x080c, 0x668a,
-	0x002e, 0x0530, 0x6014, 0x2048, 0xa864, 0x9084, 0x00ff, 0x9086,
-	0x0039, 0x1140, 0x2001, 0x0030, 0x900e, 0x2011, 0x4009, 0x080c,
-	0xbe40, 0x0040, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867, 0x0103,
-	0xa833, 0xdead, 0x6010, 0x2058, 0xb9a0, 0x0016, 0x080c, 0x303d,
-	0x080c, 0x9bda, 0x001e, 0x080c, 0x3116, 0x00de, 0x0804, 0xa8da,
-	0x00de, 0x080c, 0x539c, 0x1170, 0x6014, 0x9005, 0x1158, 0x0036,
-	0x0046, 0x6010, 0x2058, 0xbba0, 0x2021, 0x0006, 0x080c, 0x4a77,
-	0x004e, 0x003e, 0x00d6, 0x6010, 0x2058, 0x080c, 0x6306, 0x080c,
-	0xa698, 0x00de, 0x080c, 0xab1c, 0x1588, 0x6010, 0x2058, 0xb890,
-	0x9005, 0x0560, 0x2001, 0x0006, 0x080c, 0x61bc, 0x0096, 0x6014,
-	0x904d, 0x01d0, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140,
-	0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xbe40, 0x0060,
-	0xa864, 0x9084, 0x00ff, 0x9086, 0x0029, 0x0130, 0xa807, 0x0000,
-	0xa867, 0x0103, 0xa833, 0x0200, 0x009e, 0x080c, 0x303d, 0x6020,
-	0x9086, 0x000a, 0x0138, 0x080c, 0x9bda, 0x0020, 0x080c, 0xa581,
-	0x080c, 0xa824, 0x001e, 0x002e, 0x00ee, 0x00be, 0x0005, 0x2011,
-	0x1823, 0x2204, 0x9086, 0x0014, 0x1160, 0x2001, 0x0002, 0x080c,
-	0x61bc, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x84ba, 0x0804,
-	0x891b, 0x0804, 0xa824, 0x2030, 0x2011, 0x1823, 0x2204, 0x9086,
-	0x0004, 0x1148, 0x96b6, 0x000b, 0x1120, 0x2001, 0x0007, 0x080c,
-	0x61bc, 0x0804, 0x9bda, 0x0804, 0xa824, 0x0002, 0xa662, 0xa91d,
-	0xa662, 0xa95c, 0xa662, 0xaa07, 0xa912, 0xa662, 0xa662, 0xaa1a,
-	0xa662, 0xaa2a, 0x6604, 0x9686, 0x0003, 0x0904, 0xa839, 0x96b6,
-	0x001e, 0x1110, 0x080c, 0x9bda, 0x0005, 0x00b6, 0x00d6, 0x00c6,
-	0x080c, 0xaa3a, 0x11a0, 0x9006, 0x080c, 0x61a8, 0x080c, 0x300e,
-	0x080c, 0xbf76, 0x2001, 0x0002, 0x080c, 0x61bc, 0x6003, 0x0001,
-	0x6007, 0x0002, 0x080c, 0x84ba, 0x080c, 0x891b, 0x0408, 0x2009,
-	0x026e, 0x2104, 0x9086, 0x0009, 0x1160, 0x6010, 0x2058, 0xb840,
-	0x9084, 0x00ff, 0x9005, 0x0170, 0x8001, 0xb842, 0x601b, 0x000a,
-	0x0078, 0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086, 0x1900,
-	0x1108, 0x08a0, 0x080c, 0x300e, 0x080c, 0xbf76, 0x080c, 0xa824,
-	0x00ce, 0x00de, 0x00be, 0x0005, 0x0096, 0x00b6, 0x0026, 0x9016,
-	0x080c, 0xaa48, 0x00d6, 0x2069, 0x194c, 0x2d04, 0x9005, 0x0168,
-	0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e, 0x1138, 0x2069, 0x181f,
-	0x2d04, 0x8000, 0x206a, 0x00de, 0x0010, 0x00de, 0x0088, 0x9006,
-	0x080c, 0x61a8, 0x2001, 0x0002, 0x080c, 0x61bc, 0x6003, 0x0001,
-	0x6007, 0x0002, 0x080c, 0x84ba, 0x080c, 0x891b, 0x0804, 0xa9d7,
-	0x080c, 0xb842, 0x01b0, 0x6014, 0x2048, 0xa864, 0x2010, 0x9086,
-	0x0139, 0x1138, 0x6007, 0x0016, 0x2001, 0x0002, 0x080c, 0xbe9a,
-	0x00b0, 0x6014, 0x2048, 0xa864, 0xd0fc, 0x0118, 0x2001, 0x0001,
-	0x0ca8, 0x2001, 0x180e, 0x2004, 0xd0dc, 0x0148, 0x6010, 0x2058,
-	0xb840, 0x9084, 0x00ff, 0x9005, 0x1110, 0x9006, 0x0c38, 0x080c,
-	0xa581, 0x2009, 0x026e, 0x2134, 0x96b4, 0x00ff, 0x9686, 0x0005,
-	0x0510, 0x9686, 0x000b, 0x01c8, 0x2009, 0x026f, 0x2104, 0x9084,
-	0xff00, 0x1118, 0x9686, 0x0009, 0x01b0, 0x9086, 0x1900, 0x1168,
-	0x9686, 0x0009, 0x0180, 0x2001, 0x0004, 0x080c, 0x61bc, 0x2001,
-	0x0028, 0x601a, 0x6007, 0x0052, 0x0010, 0x080c, 0xa824, 0x002e,
-	0x00be, 0x009e, 0x0005, 0x9286, 0x0139, 0x0160, 0x6014, 0x2048,
-	0x080c, 0xb842, 0x0140, 0xa864, 0x9086, 0x0139, 0x0118, 0xa868,
-	0xd0fc, 0x0108, 0x0c50, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff,
-	0x9005, 0x0138, 0x8001, 0xb842, 0x601b, 0x000a, 0x6007, 0x0016,
-	0x08f0, 0xb8a0, 0x9086, 0x007e, 0x1138, 0x00e6, 0x2071, 0x1800,
-	0x080c, 0x5c6a, 0x00ee, 0x0010, 0x080c, 0x300e, 0x0870, 0x080c,
-	0xaa48, 0x1160, 0x2001, 0x0004, 0x080c, 0x61bc, 0x6003, 0x0001,
-	0x6007, 0x0003, 0x080c, 0x84ba, 0x0804, 0x891b, 0x080c, 0xa581,
-	0x0804, 0xa824, 0x0469, 0x1160, 0x2001, 0x0008, 0x080c, 0x61bc,
-	0x6003, 0x0001, 0x6007, 0x0005, 0x080c, 0x84ba, 0x0804, 0x891b,
-	0x0804, 0xa824, 0x00e9, 0x1160, 0x2001, 0x000a, 0x080c, 0x61bc,
-	0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x84ba, 0x0804, 0x891b,
-	0x0804, 0xa824, 0x2009, 0x026e, 0x2104, 0x9086, 0x0003, 0x1138,
-	0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086, 0x2a00, 0x0005,
-	0x9085, 0x0001, 0x0005, 0x00b6, 0x00c6, 0x0016, 0x6110, 0x2158,
-	0x080c, 0x627a, 0x001e, 0x00ce, 0x00be, 0x0005, 0x00b6, 0x00f6,
-	0x00e6, 0x00d6, 0x0036, 0x0016, 0x6010, 0x2058, 0x2009, 0x1836,
-	0x2104, 0x9085, 0x0003, 0x200a, 0x080c, 0xaaee, 0x0560, 0x2009,
-	0x1836, 0x2104, 0xc0cd, 0x200a, 0x080c, 0x6662, 0x0158, 0x9006,
-	0x2020, 0x2009, 0x002a, 0x080c, 0xd284, 0x2001, 0x180c, 0x200c,
-	0xc195, 0x2102, 0x2019, 0x002a, 0x2009, 0x0001, 0x080c, 0x2fd3,
-	0x00e6, 0x2071, 0x1800, 0x080c, 0x2de9, 0x00ee, 0x00c6, 0x0156,
-	0x20a9, 0x0781, 0x2009, 0x007f, 0x080c, 0x3116, 0x8108, 0x1f04,
-	0xaa8c, 0x015e, 0x00ce, 0x080c, 0xaa4b, 0x2071, 0x0260, 0x2079,
-	0x0200, 0x7817, 0x0001, 0x2001, 0x1836, 0x200c, 0xc1c5, 0x7018,
-	0xd0fc, 0x0110, 0xd0dc, 0x0118, 0x7038, 0xd0dc, 0x1108, 0xc1c4,
-	0x7817, 0x0000, 0x2001, 0x1836, 0x2102, 0x2079, 0x0100, 0x2e04,
-	0x9084, 0x00ff, 0x2069, 0x181e, 0x206a, 0x78e6, 0x0006, 0x8e70,
-	0x2e04, 0x2069, 0x181f, 0x206a, 0x78ea, 0x7832, 0x7836, 0x2010,
-	0x9084, 0xff00, 0x001e, 0x9105, 0x2009, 0x182b, 0x200a, 0x2200,
-	0x9084, 0x00ff, 0x2008, 0x080c, 0x2486, 0x080c, 0x7096, 0x0170,
-	0x2071, 0x0260, 0x2069, 0x1952, 0x7048, 0x206a, 0x704c, 0x6806,
-	0x7050, 0x680a, 0x7054, 0x680e, 0x080c, 0xbc6d, 0x0040, 0x2001,
-	0x0006, 0x080c, 0x61bc, 0x080c, 0x303d, 0x080c, 0x9bda, 0x001e,
-	0x003e, 0x00de, 0x00ee, 0x00fe, 0x00be, 0x0005, 0x0096, 0x0026,
-	0x0036, 0x00e6, 0x0156, 0x2019, 0x182b, 0x231c, 0x83ff, 0x01f0,
-	0x2071, 0x0260, 0x7200, 0x9294, 0x00ff, 0x7004, 0x9084, 0xff00,
-	0x9205, 0x9306, 0x1198, 0x2011, 0x0276, 0x20a9, 0x0004, 0x2b48,
-	0x2019, 0x000a, 0x080c, 0xabd3, 0x1148, 0x2011, 0x027a, 0x20a9,
-	0x0004, 0x2019, 0x0006, 0x080c, 0xabd3, 0x1100, 0x015e, 0x00ee,
-	0x003e, 0x002e, 0x009e, 0x0005, 0x00e6, 0x2071, 0x0260, 0x7034,
-	0x9086, 0x0014, 0x11a8, 0x7038, 0x9086, 0x0800, 0x1188, 0x703c,
-	0xd0ec, 0x0160, 0x9084, 0x0f00, 0x9086, 0x0100, 0x1138, 0x7054,
-	0xd0a4, 0x1110, 0xd0ac, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x00ee, 0x0005, 0x00e6, 0x0096, 0x00c6, 0x0076, 0x0056, 0x0046,
-	0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2029, 0x19c3, 0x252c,
-	0x2021, 0x19ca, 0x2424, 0x2061, 0x1ddc, 0x2071, 0x1800, 0x7250,
-	0x7070, 0x9202, 0x1a04, 0xabab, 0x080c, 0xd2b5, 0x0904, 0xaba4,
-	0x6720, 0x9786, 0x0007, 0x0904, 0xaba4, 0x2500, 0x9c06, 0x0904,
-	0xaba4, 0x2400, 0x9c06, 0x0904, 0xaba4, 0x3e08, 0x9186, 0x0002,
-	0x1148, 0x6010, 0x9005, 0x0130, 0x00b6, 0x2058, 0xb800, 0x00be,
-	0xd0bc, 0x1590, 0x00c6, 0x6043, 0xffff, 0x6000, 0x9086, 0x0004,
-	0x1110, 0x080c, 0x1921, 0x9786, 0x000a, 0x0148, 0x080c, 0xba57,
-	0x1130, 0x00ce, 0x080c, 0xa581, 0x080c, 0x9c14, 0x00e8, 0x6014,
-	0x2048, 0x080c, 0xb842, 0x01a8, 0x9786, 0x0003, 0x1530, 0xa867,
-	0x0103, 0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c,
-	0x0fd4, 0x009e, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6985, 0x080c,
-	0xba31, 0x080c, 0x9c14, 0x00ce, 0x9ce0, 0x001c, 0x7064, 0x9c02,
-	0x1210, 0x0804, 0xab4f, 0x012e, 0x000e, 0x002e, 0x004e, 0x005e,
-	0x007e, 0x00ce, 0x009e, 0x00ee, 0x0005, 0x9786, 0x0006, 0x1118,
-	0x080c, 0xd22f, 0x0c30, 0x9786, 0x000a, 0x0998, 0x0880, 0x220c,
-	0x2304, 0x9106, 0x1130, 0x8210, 0x8318, 0x1f04, 0xabbf, 0x9006,
-	0x0005, 0x2304, 0x9102, 0x0218, 0x2001, 0x0001, 0x0008, 0x9006,
-	0x918d, 0x0001, 0x0005, 0x0136, 0x01c6, 0x0016, 0x8906, 0x8006,
-	0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0, 0x9300, 0x2098,
-	0x3518, 0x20a9, 0x0001, 0x220c, 0x4002, 0x910e, 0x1140, 0x8210,
-	0x8319, 0x1dc8, 0x9006, 0x001e, 0x01ce, 0x013e, 0x0005, 0x220c,
-	0x9102, 0x0218, 0x2001, 0x0001, 0x0010, 0x2001, 0x0000, 0x918d,
-	0x0001, 0x001e, 0x01ce, 0x013e, 0x0005, 0x6004, 0x908a, 0x0053,
-	0x1a0c, 0x0d65, 0x080c, 0xba46, 0x0120, 0x080c, 0xba57, 0x0158,
-	0x0028, 0x080c, 0x303d, 0x080c, 0xba57, 0x0128, 0x080c, 0x885d,
-	0x080c, 0x9bda, 0x0005, 0x080c, 0xa581, 0x0cc0, 0x9182, 0x0057,
-	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xac35, 0xac35,
-	0xac35, 0xac35, 0xac35, 0xac35, 0xac35, 0xac35, 0xac35, 0xac35,
-	0xac35, 0xac37, 0xac37, 0xac37, 0xac37, 0xac35, 0xac35, 0xac35,
-	0xac37, 0xac35, 0xac35, 0xac35, 0xac35, 0x080c, 0x0d65, 0x600b,
-	0xffff, 0x6003, 0x000f, 0x6106, 0x0126, 0x2091, 0x8000, 0x080c,
-	0xbf79, 0x2009, 0x8000, 0x080c, 0x84b3, 0x012e, 0x0005, 0x9186,
-	0x0013, 0x1128, 0x6004, 0x9082, 0x0040, 0x0804, 0xacbc, 0x9186,
-	0x0027, 0x1520, 0x080c, 0x885d, 0x080c, 0x300e, 0x080c, 0xbf76,
-	0x0096, 0x6114, 0x2148, 0x080c, 0xb842, 0x0198, 0x080c, 0xba57,
-	0x1118, 0x080c, 0xa581, 0x0068, 0xa867, 0x0103, 0xa87b, 0x0029,
-	0xa877, 0x0000, 0xa97c, 0xc1c5, 0xa97e, 0x080c, 0x6991, 0x080c,
-	0xba31, 0x009e, 0x080c, 0x9bda, 0x0804, 0x891b, 0x9186, 0x0014,
-	0x1120, 0x6004, 0x9082, 0x0040, 0x0018, 0x080c, 0x0d65, 0x0005,
-	0x0002, 0xac9a, 0xac98, 0xac98, 0xac98, 0xac98, 0xac98, 0xac98,
-	0xac98, 0xac98, 0xac98, 0xac98, 0xacb3, 0xacb3, 0xacb3, 0xacb3,
-	0xac98, 0xacb3, 0xac98, 0xacb3, 0xac98, 0xac98, 0xac98, 0xac98,
-	0x080c, 0x0d65, 0x080c, 0x885d, 0x0096, 0x6114, 0x2148, 0x080c,
-	0xb842, 0x0168, 0xa867, 0x0103, 0xa87b, 0x0006, 0xa877, 0x0000,
-	0xa880, 0xc0ec, 0xa882, 0x080c, 0x6991, 0x080c, 0xba31, 0x009e,
-	0x080c, 0x9bda, 0x0005, 0x080c, 0x885d, 0x080c, 0xba57, 0x090c,
-	0xa581, 0x080c, 0x9bda, 0x0005, 0x0002, 0xacd6, 0xacd4, 0xacd4,
-	0xacd4, 0xacd4, 0xacd4, 0xacd4, 0xacd4, 0xacd4, 0xacd4, 0xacd4,
-	0xacd8, 0xacd8, 0xacd8, 0xacd8, 0xacd4, 0xacda, 0xacd4, 0xacd8,
-	0xacd4, 0xacd4, 0xacd4, 0xacd4, 0x080c, 0x0d65, 0x080c, 0x0d65,
-	0x080c, 0x0d65, 0x080c, 0x9bda, 0x0804, 0x891b, 0x9182, 0x0057,
-	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xacfd, 0xacfd,
-	0xacfd, 0xacfd, 0xacfd, 0xad36, 0xae25, 0xacfd, 0xae31, 0xacfd,
-	0xacfd, 0xacfd, 0xacfd, 0xacfd, 0xacfd, 0xacfd, 0xacfd, 0xacfd,
-	0xacfd, 0xae31, 0xacff, 0xacfd, 0xae2f, 0x080c, 0x0d65, 0x00b6,
-	0x0096, 0x6114, 0x2148, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1508,
-	0xa87b, 0x0000, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87c, 0xd0ac,
-	0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xaeb6, 0x080c, 0x67a7,
-	0x6210, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0xb8c0,
-	0x9005, 0x0110, 0x080c, 0x6396, 0x080c, 0x9bda, 0x009e, 0x00be,
-	0x0005, 0xa87c, 0xd0ac, 0x09e0, 0xa838, 0xa934, 0x9105, 0x09c0,
-	0xa880, 0xd0bc, 0x19a8, 0x080c, 0xbb8c, 0x0c80, 0x00b6, 0x0096,
-	0x6114, 0x2148, 0x601c, 0xd0fc, 0x1110, 0x7644, 0x0008, 0x9036,
-	0x96b4, 0x0fff, 0x86ff, 0x1590, 0x6010, 0x2058, 0xb800, 0xd0bc,
-	0x1904, 0xae14, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0xa87c,
-	0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xaeb6, 0x080c,
-	0x67a7, 0x6210, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e,
-	0xb8c0, 0x9005, 0x0110, 0x080c, 0x6396, 0x601c, 0xd0fc, 0x1148,
-	0x7044, 0xd0e4, 0x1904, 0xadf8, 0x080c, 0x9bda, 0x009e, 0x00be,
-	0x0005, 0x2009, 0x0211, 0x210c, 0x080c, 0x0d65, 0x968c, 0x0c00,
-	0x0150, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xadfc, 0x7348,
-	0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0508,
-	0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x00e8, 0xd6dc, 0x01a0,
-	0xa87b, 0x0015, 0xa87c, 0xd0ac, 0x0170, 0xa938, 0xaa34, 0x2100,
-	0x9205, 0x0148, 0x7048, 0x9106, 0x1118, 0x704c, 0x9206, 0x0118,
-	0xa992, 0xaa8e, 0xc6dc, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007,
-	0x0010, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0x901e, 0xd6c4,
-	0x01d8, 0x9686, 0x0100, 0x1130, 0x7064, 0x9005, 0x1118, 0xc6c4,
-	0x0804, 0xad42, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009,
-	0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011,
-	0x0025, 0x080c, 0xb408, 0x003e, 0xd6cc, 0x0904, 0xad57, 0x7154,
-	0xa98a, 0x81ff, 0x0904, 0xad57, 0x9192, 0x0021, 0x1278, 0x8304,
-	0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xb408, 0x2011, 0x0205,
-	0x2013, 0x0000, 0x080c, 0xbf06, 0x0804, 0xad57, 0xa868, 0xd0fc,
-	0x0120, 0x2009, 0x0020, 0xa98a, 0x0c50, 0x00a6, 0x2950, 0x080c,
-	0xb3a7, 0x00ae, 0x080c, 0xbf06, 0x080c, 0xb3f8, 0x0804, 0xad59,
-	0x080c, 0xbb4f, 0x0804, 0xad6e, 0xa87c, 0xd0ac, 0x0904, 0xad7f,
-	0xa880, 0xd0bc, 0x1904, 0xad7f, 0x7348, 0xa838, 0x9306, 0x11c8,
-	0x734c, 0xa834, 0x931e, 0x0904, 0xad7f, 0xd6d4, 0x0190, 0xab38,
-	0x9305, 0x0904, 0xad7f, 0x0068, 0xa87c, 0xd0ac, 0x0904, 0xad4a,
-	0xa838, 0xa934, 0x9105, 0x0904, 0xad4a, 0xa880, 0xd0bc, 0x1904,
-	0xad4a, 0x080c, 0xbb8c, 0x0804, 0xad6e, 0x00f6, 0x2079, 0x026c,
-	0x7c04, 0x7b00, 0x7e0c, 0x7d08, 0x00fe, 0x0021, 0x0005, 0x0011,
-	0x0005, 0x0005, 0x0096, 0x6003, 0x0002, 0x6007, 0x0043, 0x6014,
-	0x2048, 0xa87c, 0xd0ac, 0x0128, 0x009e, 0x0005, 0x2130, 0x2228,
-	0x0058, 0x2400, 0xa9ac, 0x910a, 0x2300, 0xaab0, 0x9213, 0x2600,
-	0x9102, 0x2500, 0x9203, 0x0e90, 0xac46, 0xab4a, 0xae36, 0xad3a,
-	0x6044, 0xd0fc, 0x190c, 0x98e4, 0x604b, 0x0000, 0x080c, 0x1adf,
-	0x1118, 0x6144, 0x080c, 0x84df, 0x009e, 0x0005, 0x9182, 0x0057,
-	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xae7d, 0xae7d,
-	0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae7d,
-	0xae7f, 0xae7d, 0xae7d, 0xae7d, 0xae7d, 0xae90, 0xae7d, 0xae7d,
-	0xae7d, 0xae7d, 0xaeb4, 0xae7d, 0xae7d, 0x080c, 0x0d65, 0x6004,
-	0x9086, 0x0040, 0x1110, 0x080c, 0x885d, 0x2019, 0x0001, 0x080c,
-	0x9269, 0x6003, 0x0002, 0x080c, 0xbf7e, 0x080c, 0x88b8, 0x0005,
-	0x6004, 0x9086, 0x0040, 0x1110, 0x080c, 0x885d, 0x2019, 0x0001,
-	0x080c, 0x9269, 0x080c, 0x88b8, 0x080c, 0x300e, 0x080c, 0xbf76,
-	0x0096, 0x6114, 0x2148, 0x080c, 0xb842, 0x0150, 0xa867, 0x0103,
-	0xa87b, 0x0029, 0xa877, 0x0000, 0x080c, 0x6991, 0x080c, 0xba31,
-	0x009e, 0x080c, 0x9bda, 0x0005, 0x080c, 0x0d65, 0xa87b, 0x0015,
-	0xd1fc, 0x0180, 0xa87b, 0x0007, 0x8002, 0x8000, 0x810a, 0x9189,
-	0x0000, 0x0006, 0x0016, 0x2009, 0x1a47, 0x2104, 0x8000, 0x200a,
-	0x001e, 0x000e, 0xa992, 0xa88e, 0x0005, 0x9182, 0x0057, 0x1220,
-	0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xaeec, 0xaeec, 0xaeec,
-	0xaeec, 0xaeec, 0xaeee, 0xaeec, 0xaeec, 0xafab, 0xaeec, 0xaeec,
-	0xaeec, 0xaeec, 0xaeec, 0xaeec, 0xaeec, 0xaeec, 0xaeec, 0xaeec,
-	0xb0e9, 0xaeec, 0xb0f3, 0xaeec, 0x080c, 0x0d65, 0x601c, 0xd0bc,
-	0x0178, 0xd084, 0x0168, 0xd0f4, 0x0120, 0xc084, 0x601e, 0x0804,
-	0xacde, 0x6114, 0x0096, 0x2148, 0xa87c, 0xc0e5, 0xa87e, 0x009e,
-	0x0076, 0x00a6, 0x00e6, 0x0096, 0x2071, 0x0260, 0x6114, 0x2150,
-	0x601c, 0xd0fc, 0x1110, 0x7644, 0x0008, 0x9036, 0xb676, 0x96b4,
-	0x0fff, 0xb77c, 0xc7e5, 0xb77e, 0x6210, 0x00b6, 0x2258, 0xba3c,
-	0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x86ff, 0x0904, 0xafa4,
-	0x9694, 0xff00, 0x9284, 0x0c00, 0x0120, 0x7048, 0xb092, 0x704c,
-	0xb08e, 0x9284, 0x0300, 0x0904, 0xafa4, 0x9686, 0x0100, 0x1130,
-	0x7064, 0x9005, 0x1118, 0xc6c4, 0xb676, 0x0c38, 0x080c, 0x1022,
-	0x090c, 0x0d65, 0x2900, 0xb07a, 0xb77c, 0x97bd, 0x0200, 0xb77e,
-	0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c, 0xa86e, 0xb070, 0xa872,
-	0x7044, 0x9084, 0xf000, 0x9635, 0xae76, 0x968c, 0x0c00, 0x0120,
-	0x7348, 0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002,
-	0x0180, 0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x0060, 0xd6dc,
-	0x0118, 0xa87b, 0x0015, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007,
-	0x0010, 0xa87b, 0x0000, 0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886,
-	0x901e, 0xd6c4, 0x0190, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a,
-	0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018,
-	0x2011, 0x0025, 0x080c, 0xb408, 0x003e, 0xd6cc, 0x01e8, 0x7154,
-	0xa98a, 0x81ff, 0x01c8, 0x9192, 0x0021, 0x1260, 0x8304, 0x9098,
-	0x0018, 0x2011, 0x0029, 0x080c, 0xb408, 0x2011, 0x0205, 0x2013,
-	0x0000, 0x0050, 0xb068, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a,
-	0x0c68, 0x2950, 0x080c, 0xb3a7, 0x080c, 0x18ff, 0x009e, 0x00ee,
-	0x00ae, 0x007e, 0x0005, 0x2001, 0x1958, 0x2004, 0x604a, 0x0096,
-	0x6114, 0x2148, 0xa83c, 0xa940, 0x9105, 0x1118, 0xa87c, 0xc0dc,
-	0xa87e, 0x6003, 0x0002, 0x080c, 0xbf87, 0x0904, 0xb0e4, 0x604b,
-	0x0000, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1500,
-	0xd1cc, 0x0904, 0xb0a9, 0xa978, 0xa868, 0xd0fc, 0x0904, 0xb06a,
-	0x0016, 0xa87c, 0x0006, 0xa880, 0x0006, 0x00a6, 0x2150, 0xb174,
-	0x9184, 0x00ff, 0x90b6, 0x0002, 0x0904, 0xb038, 0x9086, 0x0028,
-	0x1904, 0xb024, 0xa87b, 0x001c, 0xb07b, 0x001c, 0x0804, 0xb040,
-	0x6024, 0xd0f4, 0x11d0, 0xa838, 0xaa34, 0x9205, 0x09c8, 0xa838,
-	0xaa90, 0x9206, 0x1120, 0xa88c, 0xaa34, 0x9206, 0x0988, 0x6024,
-	0xd0d4, 0x1148, 0xa9ac, 0xa834, 0x9102, 0x603a, 0xa9b0, 0xa838,
-	0x9103, 0x603e, 0x6024, 0xc0f5, 0x6026, 0x6010, 0x00b6, 0x2058,
-	0xb83c, 0x8000, 0xb83e, 0x00be, 0x601c, 0xc0fc, 0x601e, 0x9006,
-	0xa876, 0xa892, 0xa88e, 0xa87c, 0xc0e4, 0xa87e, 0xd0cc, 0x0140,
-	0xc0cc, 0xa87e, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fd4, 0x009e,
-	0x080c, 0xbb8c, 0x0804, 0xb0e4, 0xd1dc, 0x0158, 0xa87b, 0x0015,
-	0xb07b, 0x0015, 0x080c, 0xbe29, 0x0118, 0xb174, 0xc1dc, 0xb176,
-	0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b, 0x0007, 0x0040,
-	0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xaeb6,
-	0xa87c, 0xb07e, 0xa890, 0xb092, 0xa88c, 0xb08e, 0xa860, 0x20e8,
-	0xa85c, 0x9080, 0x0019, 0x20a0, 0x20a9, 0x0020, 0x8a06, 0x8006,
-	0x8007, 0x9094, 0x003f, 0x22e0, 0x9084, 0xffc0, 0x9080, 0x0019,
-	0x2098, 0x4003, 0x00ae, 0x000e, 0xa882, 0x000e, 0xa87e, 0x080c,
-	0xbf06, 0x001e, 0xa874, 0x0006, 0x2148, 0x080c, 0x0fd4, 0x001e,
-	0x0804, 0xb0d6, 0x0016, 0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff,
-	0x90b6, 0x0002, 0x01e0, 0x9086, 0x0028, 0x1128, 0xa87b, 0x001c,
-	0xb07b, 0x001c, 0x00e0, 0xd1dc, 0x0158, 0xa87b, 0x0015, 0xb07b,
-	0x0015, 0x080c, 0xbe29, 0x0118, 0xb174, 0xc1dc, 0xb176, 0x0078,
-	0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b, 0x0007, 0x0040, 0xa87c,
-	0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c, 0xaeb6, 0xa890,
-	0xb092, 0xa88c, 0xb08e, 0xa87c, 0xb07e, 0x00ae, 0x080c, 0x0fd4,
-	0x009e, 0x080c, 0xbf06, 0xa974, 0x0016, 0x080c, 0xb3f8, 0x001e,
-	0x0468, 0xa867, 0x0103, 0xa974, 0x9184, 0x00ff, 0x90b6, 0x0002,
-	0x01b0, 0x9086, 0x0028, 0x1118, 0xa87b, 0x001c, 0x00d0, 0xd1dc,
-	0x0148, 0xa87b, 0x0015, 0x080c, 0xbe29, 0x0118, 0xa974, 0xc1dc,
-	0xa976, 0x0078, 0xd1d4, 0x0118, 0xa87b, 0x0007, 0x0050, 0xa87b,
+	0x0205, 0x2003, 0x0002, 0x2099, 0x0260, 0x20a9, 0x0020, 0x4003,
+	0x2003, 0x0000, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103,
+	0x080c, 0x9be6, 0x001e, 0x009e, 0x0005, 0x0096, 0x0016, 0x900e,
+	0x7030, 0x9086, 0x0100, 0x0140, 0x7038, 0x9084, 0x00ff, 0x800c,
+	0x703c, 0x9084, 0x00ff, 0x8004, 0x9080, 0x0004, 0x9108, 0x810b,
+	0x2011, 0x0002, 0x2019, 0x000c, 0x6014, 0x2048, 0x080c, 0xb426,
+	0x080c, 0xb870, 0x0140, 0x6014, 0x2048, 0xa807, 0x0000, 0xa864,
+	0xa8e2, 0xa867, 0x0103, 0x080c, 0x9be6, 0x001e, 0x009e, 0x0005,
+	0x0016, 0x0096, 0x7030, 0x9086, 0x0100, 0x1118, 0x2009, 0x0004,
+	0x0010, 0x7034, 0x800c, 0x810b, 0x2011, 0x000c, 0x2019, 0x000c,
+	0x6014, 0x2048, 0xa804, 0x0096, 0x9005, 0x0108, 0x2048, 0x080c,
+	0xb426, 0x009e, 0x080c, 0xb870, 0x0148, 0xa804, 0x9005, 0x1158,
+	0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0x9be6,
+	0x009e, 0x001e, 0x0005, 0x0086, 0x2040, 0xa030, 0x8007, 0x9086,
+	0x0100, 0x1118, 0x080c, 0xa59c, 0x00e0, 0xa034, 0x8007, 0x800c,
+	0x8806, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
+	0x000c, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0xaaa0,
+	0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041, 0x127e, 0x0019,
+	0x0d08, 0x008e, 0x0898, 0x0096, 0x0006, 0x080c, 0x102f, 0x000e,
+	0x01b0, 0xa8ab, 0x0dcb, 0xa876, 0x000e, 0xa8a2, 0x0006, 0xae6a,
+	0x2800, 0xa89e, 0xa97a, 0xaf72, 0xaa8e, 0xab92, 0xac96, 0xad9a,
+	0x0086, 0x2940, 0x080c, 0x1124, 0x008e, 0x9085, 0x0001, 0x009e,
+	0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff, 0x6210,
+	0x00b6, 0x2258, 0xba10, 0x00be, 0x9206, 0x1520, 0x700c, 0x6210,
+	0x00b6, 0x2258, 0xba14, 0x00be, 0x9206, 0x11e0, 0x604b, 0x0000,
+	0x2c68, 0x0016, 0x2009, 0x0035, 0x080c, 0xbf07, 0x001e, 0x1158,
+	0x622c, 0x2268, 0x2071, 0x026c, 0x6b20, 0x9386, 0x0003, 0x0130,
+	0x9386, 0x0006, 0x0128, 0x080c, 0x9be6, 0x0020, 0x0039, 0x0010,
+	0x080c, 0xa21c, 0x002e, 0x00de, 0x00ee, 0x0005, 0x0096, 0x6814,
+	0x2048, 0x9186, 0x0015, 0x0904, 0xa1fb, 0x918e, 0x0016, 0x1904,
+	0xa21a, 0x700c, 0x908c, 0xff00, 0x9186, 0x1700, 0x0120, 0x9186,
+	0x0300, 0x1904, 0xa1d5, 0x89ff, 0x1138, 0x6800, 0x9086, 0x000f,
+	0x0904, 0xa1b7, 0x0804, 0xa218, 0x6808, 0x9086, 0xffff, 0x1904,
+	0xa1fd, 0xa87c, 0x9084, 0x0060, 0x9086, 0x0020, 0x1128, 0xa83c,
+	0xa940, 0x9105, 0x1904, 0xa1fd, 0x6824, 0xd084, 0x1904, 0xa1fd,
+	0xd0b4, 0x0158, 0x0016, 0x2001, 0x195e, 0x200c, 0x6018, 0x9102,
+	0x9082, 0x0005, 0x001e, 0x1a04, 0xa1fd, 0x080c, 0xba5f, 0x6864,
+	0xa882, 0xa87c, 0xc0dc, 0xc0f4, 0xc0d4, 0xa87e, 0x0026, 0x900e,
+	0x6a18, 0x2001, 0x000a, 0x080c, 0x842f, 0xa884, 0x920a, 0x0208,
+	0x8011, 0xaa86, 0x82ff, 0x002e, 0x1138, 0x00c6, 0x2d60, 0x080c,
+	0xb579, 0x00ce, 0x0804, 0xa218, 0x00c6, 0xa868, 0xd0fc, 0x1118,
+	0x080c, 0x5d71, 0x0010, 0x080c, 0x611a, 0x00ce, 0x1904, 0xa1fd,
+	0x00c6, 0x2d60, 0x080c, 0x9be6, 0x00ce, 0x0804, 0xa218, 0x00c6,
+	0x080c, 0x9c55, 0x0198, 0x6017, 0x0000, 0x6810, 0x6012, 0x080c,
+	0xbd09, 0x6023, 0x0003, 0x6904, 0x00c6, 0x2d60, 0x080c, 0x9be6,
+	0x00ce, 0x080c, 0x9c82, 0x00ce, 0x0804, 0xa218, 0x2001, 0x1960,
+	0x2004, 0x684a, 0x00ce, 0x0804, 0xa218, 0x7008, 0x9086, 0x000b,
+	0x11c8, 0x6010, 0x00b6, 0x2058, 0xb900, 0xc1bc, 0xb902, 0x00be,
+	0x00c6, 0x2d60, 0xa87b, 0x0003, 0x080c, 0xbf49, 0x6007, 0x0085,
+	0x6003, 0x000b, 0x6023, 0x0002, 0x2009, 0x8020, 0x080c, 0x84e7,
+	0x00ce, 0x0430, 0x700c, 0x9086, 0x2a00, 0x1138, 0x2001, 0x1960,
+	0x2004, 0x684a, 0x00e8, 0x04c1, 0x00e8, 0x89ff, 0x090c, 0x0d65,
+	0x00c6, 0x00d6, 0x2d60, 0xa867, 0x0103, 0xa87b, 0x0003, 0x080c,
+	0x67cb, 0x080c, 0xba5f, 0x080c, 0x9c20, 0x0026, 0x6010, 0x00b6,
+	0x2058, 0xba3c, 0x080c, 0x63ba, 0x00be, 0x002e, 0x00de, 0x00ce,
+	0x080c, 0x9be6, 0x009e, 0x0005, 0x9186, 0x0015, 0x1128, 0x2001,
+	0x1960, 0x2004, 0x684a, 0x0068, 0x918e, 0x0016, 0x1160, 0x00c6,
+	0x2d00, 0x2060, 0x080c, 0xd517, 0x080c, 0x83d6, 0x080c, 0x9be6,
+	0x00ce, 0x080c, 0x9be6, 0x0005, 0x0026, 0x0036, 0x0046, 0x7228,
+	0xacb0, 0xabac, 0xd2f4, 0x0130, 0x2001, 0x1960, 0x2004, 0x684a,
+	0x0804, 0xa296, 0x00c6, 0x2d60, 0x080c, 0xb451, 0x00ce, 0x6804,
+	0x9086, 0x0050, 0x1168, 0x00c6, 0x2d00, 0x2060, 0x6003, 0x0001,
+	0x6007, 0x0050, 0x2009, 0x8023, 0x080c, 0x84e7, 0x00ce, 0x04f0,
+	0x6800, 0x9086, 0x000f, 0x01a8, 0x89ff, 0x090c, 0x0d65, 0x6800,
+	0x9086, 0x0004, 0x1190, 0xa87c, 0xd0ac, 0x0178, 0xa843, 0x0fff,
+	0xa83f, 0x0fff, 0xa880, 0xc0fc, 0xa882, 0x2001, 0x0001, 0x6832,
+	0x0400, 0x2001, 0x0007, 0x6832, 0x00e0, 0xa87c, 0xd0b4, 0x1150,
+	0xd0ac, 0x0db8, 0x6824, 0xd0f4, 0x1d48, 0xa838, 0xa934, 0x9105,
+	0x0d80, 0x0c20, 0xd2ec, 0x1d68, 0x7024, 0x9306, 0x1118, 0x7020,
+	0x9406, 0x0d38, 0x7020, 0x683e, 0x7024, 0x683a, 0x2001, 0x0005,
+	0x6832, 0x080c, 0xbbf3, 0x080c, 0x894f, 0x0010, 0x080c, 0x9be6,
+	0x004e, 0x003e, 0x002e, 0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008,
+	0x9084, 0x00ff, 0x6210, 0x00b6, 0x2258, 0xba10, 0x00be, 0x9206,
+	0x1904, 0xa301, 0x700c, 0x6210, 0x00b6, 0x2258, 0xba14, 0x00be,
+	0x9206, 0x1904, 0xa301, 0x6038, 0x2068, 0x6824, 0xc0dc, 0x6826,
+	0x6a20, 0x9286, 0x0007, 0x0904, 0xa301, 0x9286, 0x0002, 0x0904,
+	0xa301, 0x9286, 0x0000, 0x05e8, 0x6808, 0x633c, 0x9306, 0x15c8,
+	0x2071, 0x026c, 0x9186, 0x0015, 0x0570, 0x918e, 0x0016, 0x1100,
+	0x00c6, 0x6038, 0x2060, 0x6104, 0x9186, 0x004b, 0x01c0, 0x9186,
+	0x004c, 0x01a8, 0x9186, 0x004d, 0x0190, 0x9186, 0x004e, 0x0178,
+	0x9186, 0x0052, 0x0160, 0x6014, 0x0096, 0x2048, 0x080c, 0xb870,
+	0x090c, 0x0d65, 0xa87b, 0x0003, 0x009e, 0x080c, 0xbf49, 0x6007,
+	0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2009, 0x8020, 0x080c,
+	0x84e7, 0x00ce, 0x0030, 0x6038, 0x2070, 0x2001, 0x1960, 0x2004,
+	0x704a, 0x080c, 0x9be6, 0x002e, 0x00de, 0x00ee, 0x0005, 0x00b6,
+	0x0096, 0x00f6, 0x6014, 0x2048, 0x6010, 0x2058, 0x91b6, 0x0015,
+	0x0130, 0xba08, 0xbb0c, 0xbc00, 0xc48c, 0xbc02, 0x0460, 0x0096,
+	0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90, 0x0010, 0x2019, 0x000a,
+	0x20a9, 0x0004, 0x080c, 0xabee, 0x002e, 0x003e, 0x015e, 0x009e,
+	0x1904, 0xa370, 0x0096, 0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90,
+	0x0014, 0x2019, 0x0006, 0x20a9, 0x0004, 0x080c, 0xabee, 0x002e,
+	0x003e, 0x015e, 0x009e, 0x15a0, 0x7238, 0xba0a, 0x733c, 0xbb0e,
+	0xbc00, 0xc48d, 0xbc02, 0xa804, 0x9005, 0x1128, 0x00fe, 0x009e,
+	0x00be, 0x0804, 0x9ff4, 0x0096, 0x2048, 0xaa12, 0xab16, 0xac0a,
+	0x009e, 0x8006, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
+	0x9080, 0x0002, 0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4,
+	0x2031, 0x0000, 0x2041, 0x127e, 0x080c, 0xa0f3, 0x0130, 0x00fe,
+	0x009e, 0x080c, 0x9be6, 0x00be, 0x0005, 0x080c, 0xa59c, 0x0cb8,
+	0x2b78, 0x00f6, 0x080c, 0x302e, 0x080c, 0xbfa4, 0x00fe, 0x00c6,
+	0x080c, 0x9b90, 0x2f00, 0x6012, 0x6017, 0x0000, 0x6023, 0x0001,
+	0x6007, 0x0001, 0x6003, 0x0001, 0x2001, 0x0007, 0x080c, 0x61e0,
+	0x080c, 0x620c, 0x080c, 0x84ee, 0x080c, 0x894f, 0x00ce, 0x0804,
+	0xa343, 0x2100, 0x91b2, 0x0053, 0x1a0c, 0x0d65, 0x91b2, 0x0040,
+	0x1a04, 0xa3f9, 0x0002, 0xa3e7, 0xa3e7, 0xa3dd, 0xa3e7, 0xa3e7,
+	0xa3e7, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db,
+	0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db,
+	0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db,
+	0xa3db, 0xa3db, 0xa3e7, 0xa3db, 0xa3e7, 0xa3e7, 0xa3db, 0xa3db,
+	0xa3db, 0xa3db, 0xa3db, 0xa3dd, 0xa3db, 0xa3db, 0xa3db, 0xa3db,
+	0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3e7, 0xa3e7, 0xa3db,
+	0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db, 0xa3db,
+	0xa3e7, 0xa3db, 0xa3db, 0x080c, 0x0d65, 0x0066, 0x00b6, 0x6610,
+	0x2658, 0xb8c4, 0xc08c, 0xb8c6, 0x00be, 0x006e, 0x0000, 0x6003,
+	0x0001, 0x6106, 0x9186, 0x0032, 0x0118, 0x080c, 0x84ee, 0x0010,
+	0x080c, 0x84e7, 0x0126, 0x2091, 0x8000, 0x080c, 0x894f, 0x012e,
+	0x0005, 0x2600, 0x0002, 0xa40d, 0xa40d, 0xa40d, 0xa3e7, 0xa3e7,
+	0xa40d, 0xa40d, 0xa40d, 0xa40d, 0xa3e7, 0xa40d, 0xa3e7, 0xa40d,
+	0xa3e7, 0xa40d, 0xa40d, 0xa40d, 0xa40d, 0x080c, 0x0d65, 0x6004,
+	0x90b2, 0x0053, 0x1a0c, 0x0d65, 0x91b6, 0x0013, 0x0904, 0xa4e4,
+	0x91b6, 0x0027, 0x1904, 0xa490, 0x080c, 0x8891, 0x6004, 0x080c,
+	0xba74, 0x01b0, 0x080c, 0xba85, 0x01a8, 0x908e, 0x0021, 0x0904,
+	0xa48d, 0x908e, 0x0022, 0x1130, 0x080c, 0xa020, 0x0904, 0xa489,
+	0x0804, 0xa48a, 0x908e, 0x003d, 0x0904, 0xa48d, 0x0804, 0xa483,
+	0x080c, 0x305d, 0x2001, 0x0007, 0x080c, 0x61e0, 0x6010, 0x00b6,
+	0x2058, 0xb9a0, 0x00be, 0x080c, 0xa59c, 0x9186, 0x007e, 0x1148,
+	0x2001, 0x1836, 0x2014, 0xc285, 0x080c, 0x70ba, 0x1108, 0xc2ad,
+	0x2202, 0x080c, 0x98c7, 0x0036, 0x0026, 0x2019, 0x0028, 0x2110,
+	0x080c, 0xd572, 0x002e, 0x003e, 0x0016, 0x0026, 0x0036, 0x2110,
+	0x2019, 0x0028, 0x080c, 0x8658, 0x0076, 0x903e, 0x080c, 0x853d,
+	0x6010, 0x00b6, 0x905d, 0x0100, 0x00be, 0x2c08, 0x080c, 0xd011,
+	0x007e, 0x003e, 0x002e, 0x001e, 0x080c, 0x98e3, 0x080c, 0xbfa4,
+	0x0016, 0x080c, 0xbd01, 0x080c, 0x9be6, 0x001e, 0x080c, 0x3136,
+	0x080c, 0x894f, 0x0030, 0x080c, 0xbd01, 0x080c, 0x9be6, 0x080c,
+	0x894f, 0x0005, 0x080c, 0xa59c, 0x0cb0, 0x080c, 0xa5d8, 0x0c98,
+	0x9186, 0x0015, 0x0118, 0x9186, 0x0016, 0x1140, 0x080c, 0x9ab6,
+	0x0d80, 0x9086, 0x0002, 0x0904, 0xa5e3, 0x0c58, 0x9186, 0x0014,
+	0x1d40, 0x080c, 0x8891, 0x6004, 0x908e, 0x0022, 0x1118, 0x080c,
+	0xa020, 0x09f8, 0x080c, 0x302e, 0x080c, 0xbfa4, 0x080c, 0xba74,
+	0x1190, 0x080c, 0x305d, 0x6010, 0x00b6, 0x2058, 0xb9a0, 0x00be,
+	0x080c, 0xa59c, 0x9186, 0x007e, 0x1128, 0x2001, 0x1836, 0x200c,
+	0xc185, 0x2102, 0x0800, 0x080c, 0xba85, 0x1120, 0x080c, 0xa59c,
+	0x0804, 0xa483, 0x6004, 0x908e, 0x0032, 0x1160, 0x00e6, 0x00f6,
+	0x2071, 0x189c, 0x2079, 0x0000, 0x080c, 0x33d0, 0x00fe, 0x00ee,
+	0x0804, 0xa483, 0x6004, 0x908e, 0x0021, 0x0d40, 0x908e, 0x0022,
+	0x090c, 0xa59c, 0x0804, 0xa483, 0x90b2, 0x0040, 0x1a04, 0xa585,
+	0x2008, 0x0002, 0xa52c, 0xa52d, 0xa530, 0xa533, 0xa536, 0xa539,
+	0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a,
+	0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a,
+	0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa52a,
+	0xa53c, 0xa547, 0xa52a, 0xa548, 0xa547, 0xa52a, 0xa52a, 0xa52a,
+	0xa52a, 0xa52a, 0xa547, 0xa547, 0xa52a, 0xa52a, 0xa52a, 0xa52a,
+	0xa52a, 0xa52a, 0xa52a, 0xa52a, 0xa570, 0xa547, 0xa52a, 0xa543,
+	0xa52a, 0xa52a, 0xa52a, 0xa544, 0xa52a, 0xa52a, 0xa52a, 0xa547,
+	0xa56b, 0xa52a, 0x080c, 0x0d65, 0x00d0, 0x2001, 0x000b, 0x00f8,
+	0x2001, 0x0003, 0x00e0, 0x2001, 0x0005, 0x00c8, 0x2001, 0x0001,
+	0x00b0, 0x2001, 0x0009, 0x0098, 0x6003, 0x0005, 0x080c, 0xbfa7,
+	0x080c, 0x894f, 0x0058, 0x0018, 0x0010, 0x080c, 0x61e0, 0x04b8,
+	0x080c, 0xbfa7, 0x6003, 0x0004, 0x080c, 0x894f, 0x0005, 0x080c,
+	0x61e0, 0x6003, 0x0002, 0x0036, 0x2019, 0x1866, 0x2304, 0x9084,
+	0xff00, 0x1120, 0x2001, 0x195e, 0x201c, 0x0040, 0x8007, 0x909a,
+	0x0004, 0x0ec0, 0x8003, 0x801b, 0x831b, 0x9318, 0x631a, 0x003e,
+	0x080c, 0x894f, 0x0c18, 0x080c, 0xbd01, 0x080c, 0x9be6, 0x08f0,
+	0x00e6, 0x00f6, 0x2071, 0x189c, 0x2079, 0x0000, 0x080c, 0x33d0,
+	0x00fe, 0x00ee, 0x080c, 0x8891, 0x080c, 0x9be6, 0x0878, 0x6003,
+	0x0002, 0x080c, 0xbfa7, 0x0804, 0x894f, 0x2600, 0x2008, 0x0002,
+	0xa59a, 0xa59a, 0xa59a, 0xa57f, 0xa57f, 0xa59a, 0xa59a, 0xa59a,
+	0xa59a, 0xa57f, 0xa59a, 0xa57f, 0xa59a, 0xa57f, 0xa59a, 0xa59a,
+	0xa59a, 0xa59a, 0x080c, 0x0d65, 0x00e6, 0x0096, 0x0026, 0x0016,
+	0x080c, 0xb870, 0x0568, 0x6014, 0x2048, 0xa864, 0x9086, 0x0139,
+	0x11a8, 0xa894, 0x9086, 0x0056, 0x1148, 0x080c, 0x5149, 0x0130,
+	0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x0028, 0x2001, 0x0030,
+	0x900e, 0x2011, 0x4005, 0x080c, 0xbe6e, 0x0090, 0xa868, 0xd0fc,
+	0x0178, 0xa807, 0x0000, 0x0016, 0x6004, 0x908e, 0x0021, 0x0168,
+	0x908e, 0x003d, 0x0150, 0x001e, 0xa867, 0x0103, 0xa833, 0x0100,
+	0x001e, 0x002e, 0x009e, 0x00ee, 0x0005, 0x001e, 0x0009, 0x0cc0,
+	0x0096, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103, 0xa823,
+	0x8001, 0x009e, 0x0005, 0x00b6, 0x6610, 0x2658, 0xb804, 0x9084,
+	0x00ff, 0x90b2, 0x000c, 0x1a0c, 0x0d65, 0x6604, 0x96b6, 0x004d,
+	0x1120, 0x080c, 0xbd8d, 0x0804, 0xa660, 0x6604, 0x96b6, 0x0043,
+	0x1120, 0x080c, 0xbdd6, 0x0804, 0xa660, 0x6604, 0x96b6, 0x004b,
+	0x1120, 0x080c, 0xbe02, 0x0804, 0xa660, 0x6604, 0x96b6, 0x0033,
+	0x1120, 0x080c, 0xbd23, 0x0804, 0xa660, 0x6604, 0x96b6, 0x0028,
+	0x1120, 0x080c, 0xbac3, 0x0804, 0xa660, 0x6604, 0x96b6, 0x0029,
+	0x1120, 0x080c, 0xbb04, 0x0804, 0xa660, 0x6604, 0x96b6, 0x001f,
+	0x1118, 0x080c, 0x9fc8, 0x04e0, 0x6604, 0x96b6, 0x0000, 0x1118,
+	0x080c, 0xa307, 0x04a8, 0x6604, 0x96b6, 0x0022, 0x1118, 0x080c,
+	0xa001, 0x0470, 0x6604, 0x96b6, 0x0035, 0x1118, 0x080c, 0xa111,
+	0x0438, 0x6604, 0x96b6, 0x0039, 0x1118, 0x080c, 0xa29c, 0x0400,
+	0x6604, 0x96b6, 0x003d, 0x1118, 0x080c, 0xa039, 0x00c8, 0x6604,
+	0x96b6, 0x0044, 0x1118, 0x080c, 0xa075, 0x0090, 0x6604, 0x96b6,
+	0x0049, 0x1118, 0x080c, 0xa0a0, 0x0058, 0x91b6, 0x0015, 0x1110,
+	0x0063, 0x0030, 0x91b6, 0x0016, 0x1128, 0x00be, 0x0804, 0xa920,
+	0x00be, 0x0005, 0x080c, 0x9c9f, 0x0cd8, 0xa67d, 0xa680, 0xa67d,
+	0xa6c4, 0xa67d, 0xa854, 0xa92d, 0xa67d, 0xa67d, 0xa8fa, 0xa67d,
+	0xa90e, 0x0096, 0x080c, 0x15af, 0x6014, 0x2048, 0xa800, 0x2048,
+	0xa867, 0x0103, 0x009e, 0x0804, 0x9be6, 0xa001, 0xa001, 0x0005,
+	0x00e6, 0x2071, 0x1800, 0x708c, 0x9086, 0x0074, 0x1540, 0x080c,
+	0xcfe2, 0x11b0, 0x6010, 0x00b6, 0x2058, 0x7030, 0xd08c, 0x0128,
+	0xb800, 0xd0bc, 0x0110, 0xc0c5, 0xb802, 0x00e9, 0x00be, 0x2001,
+	0x0006, 0x080c, 0x61e0, 0x080c, 0x305d, 0x080c, 0x9be6, 0x0088,
+	0x2001, 0x000a, 0x080c, 0x61e0, 0x080c, 0x305d, 0x6003, 0x0001,
+	0x6007, 0x0001, 0x080c, 0x84ee, 0x080c, 0x894f, 0x0010, 0x080c,
+	0xa83f, 0x00ee, 0x0005, 0x00d6, 0xb800, 0xd084, 0x0158, 0x9006,
+	0x080c, 0x61cc, 0x2069, 0x185b, 0x6804, 0x0020, 0x2001, 0x0006,
+	0x080c, 0x620c, 0x00de, 0x0005, 0x00b6, 0x0096, 0x00d6, 0x2011,
+	0x1823, 0x2204, 0x9086, 0x0074, 0x1904, 0xa816, 0x6010, 0x2058,
+	0xbaa0, 0x9286, 0x007e, 0x1120, 0x080c, 0xaa71, 0x0804, 0xa77b,
+	0x00d6, 0x080c, 0x70ba, 0x0198, 0x0026, 0x2011, 0x0010, 0x080c,
+	0x66ae, 0x002e, 0x05c8, 0x080c, 0x53bc, 0x1540, 0x6014, 0x2048,
+	0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0xdead, 0x00f8, 0x0026,
+	0x2011, 0x8008, 0x080c, 0x66ae, 0x002e, 0x0530, 0x6014, 0x2048,
+	0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140, 0x2001, 0x0030,
+	0x900e, 0x2011, 0x4009, 0x080c, 0xbe6e, 0x0040, 0x6014, 0x2048,
+	0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0xdead, 0x6010, 0x2058,
+	0xb9a0, 0x0016, 0x080c, 0x305d, 0x080c, 0x9be6, 0x001e, 0x080c,
+	0x3136, 0x00de, 0x0804, 0xa819, 0x00de, 0x080c, 0xaa66, 0x6010,
+	0x2058, 0xbaa0, 0x9286, 0x0080, 0x1510, 0x6014, 0x9005, 0x01a8,
+	0x2048, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1140, 0x2001,
+	0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xbe6e, 0x0030, 0xa807,
+	0x0000, 0xa867, 0x0103, 0xa833, 0x0200, 0x2001, 0x0006, 0x080c,
+	0x61e0, 0x080c, 0x305d, 0x080c, 0x9be6, 0x0804, 0xa819, 0x080c,
+	0xa827, 0x6014, 0x9005, 0x0190, 0x2048, 0xa868, 0xd0f4, 0x01e8,
+	0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x1d08, 0x2001, 0x0000,
+	0x900e, 0x2011, 0x4000, 0x080c, 0xbe6e, 0x08f8, 0x080c, 0xa81d,
+	0x0160, 0x9006, 0x080c, 0x61cc, 0x2001, 0x0004, 0x080c, 0x620c,
+	0x2001, 0x0007, 0x080c, 0x61e0, 0x08a0, 0x2001, 0x0004, 0x080c,
+	0x61e0, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c, 0x84ee, 0x080c,
+	0x894f, 0x0804, 0xa819, 0xb85c, 0xd0e4, 0x01d0, 0x080c, 0xbc9b,
+	0x080c, 0x70ba, 0x0118, 0xd0dc, 0x1904, 0xa73d, 0x2011, 0x1836,
+	0x2204, 0xc0ad, 0x2012, 0x2001, 0x0002, 0x00f6, 0x2079, 0x0100,
+	0x78e3, 0x0000, 0x080c, 0x24cd, 0x78e2, 0x00fe, 0x0804, 0xa73d,
+	0x080c, 0xbcdc, 0x2011, 0x1836, 0x2204, 0xc0a5, 0x2012, 0x0006,
+	0x080c, 0xd147, 0x000e, 0x1904, 0xa73d, 0xc0b5, 0x2012, 0x2001,
+	0x0006, 0x080c, 0x61e0, 0x9006, 0x080c, 0x61cc, 0x00c6, 0x2001,
+	0x180f, 0x2004, 0xd09c, 0x0520, 0x00f6, 0x2079, 0x0100, 0x00e6,
+	0x2071, 0x1800, 0x700c, 0x9084, 0x00ff, 0x78e6, 0x707a, 0x7010,
+	0x78ea, 0x707e, 0x908c, 0x00ff, 0x00ee, 0x780c, 0xc0b5, 0x780e,
+	0x00fe, 0x080c, 0x24a2, 0x00f6, 0x2100, 0x900e, 0x080c, 0x2459,
+	0x795a, 0x00fe, 0x9186, 0x0081, 0x01d8, 0x2009, 0x0081, 0x00c8,
+	0x2009, 0x00ef, 0x00f6, 0x2079, 0x0100, 0x79ea, 0x7932, 0x7936,
+	0x780c, 0xc0b5, 0x780e, 0x00fe, 0x080c, 0x24a2, 0x00f6, 0x2079,
+	0x1800, 0x797e, 0x2100, 0x900e, 0x080c, 0x2459, 0x795a, 0x00fe,
+	0x8108, 0x080c, 0x622f, 0x2b00, 0x00ce, 0x1904, 0xa73d, 0x6012,
+	0x2009, 0x180f, 0x210c, 0xd19c, 0x0150, 0x2009, 0x027c, 0x210c,
+	0x918c, 0x00ff, 0xb912, 0x2009, 0x027d, 0x210c, 0xb916, 0x2001,
+	0x0002, 0x080c, 0x61e0, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007,
+	0x0002, 0x080c, 0x84ee, 0x080c, 0x894f, 0x0018, 0x080c, 0xa59c,
+	0x0431, 0x00de, 0x009e, 0x00be, 0x0005, 0x2001, 0x1810, 0x2004,
+	0xd0a4, 0x0120, 0x2001, 0x185c, 0x2004, 0xd0ac, 0x0005, 0x00e6,
+	0x080c, 0xd5cb, 0x0190, 0x2071, 0x0260, 0x7108, 0x720c, 0x918c,
+	0x00ff, 0x1118, 0x9284, 0xff00, 0x0140, 0x6010, 0x2058, 0xb8a0,
+	0x9084, 0xff80, 0x1110, 0xb912, 0xba16, 0x00ee, 0x0005, 0x2030,
+	0x2001, 0x0007, 0x080c, 0x61e0, 0x080c, 0x53bc, 0x1120, 0x2001,
+	0x0007, 0x080c, 0x620c, 0x080c, 0x305d, 0x6020, 0x9086, 0x000a,
+	0x1108, 0x0005, 0x0804, 0x9be6, 0x00b6, 0x00e6, 0x0026, 0x0016,
+	0x2071, 0x1800, 0x708c, 0x9086, 0x0014, 0x1904, 0xa8f1, 0x00d6,
+	0x080c, 0x70ba, 0x0198, 0x0026, 0x2011, 0x0010, 0x080c, 0x66ae,
+	0x002e, 0x05c8, 0x080c, 0x53bc, 0x1540, 0x6014, 0x2048, 0xa807,
+	0x0000, 0xa867, 0x0103, 0xa833, 0xdead, 0x00f8, 0x0026, 0x2011,
+	0x8008, 0x080c, 0x66ae, 0x002e, 0x0530, 0x6014, 0x2048, 0xa864,
+	0x9084, 0x00ff, 0x9086, 0x0039, 0x1140, 0x2001, 0x0030, 0x900e,
+	0x2011, 0x4009, 0x080c, 0xbe6e, 0x0040, 0x6014, 0x2048, 0xa807,
+	0x0000, 0xa867, 0x0103, 0xa833, 0xdead, 0x6010, 0x2058, 0xb9a0,
+	0x0016, 0x080c, 0x305d, 0x080c, 0x9be6, 0x001e, 0x080c, 0x3136,
+	0x00de, 0x0804, 0xa8f5, 0x00de, 0x080c, 0x53bc, 0x1170, 0x6014,
+	0x9005, 0x1158, 0x0036, 0x0046, 0x6010, 0x2058, 0xbba0, 0x2021,
+	0x0006, 0x080c, 0x4a97, 0x004e, 0x003e, 0x00d6, 0x6010, 0x2058,
+	0x080c, 0x632a, 0x080c, 0xa6b3, 0x00de, 0x080c, 0xab37, 0x1588,
+	0x6010, 0x2058, 0xb890, 0x9005, 0x0560, 0x2001, 0x0006, 0x080c,
+	0x61e0, 0x0096, 0x6014, 0x904d, 0x01d0, 0xa864, 0x9084, 0x00ff,
+	0x9086, 0x0039, 0x1140, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000,
+	0x080c, 0xbe6e, 0x0060, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0029,
+	0x0130, 0xa807, 0x0000, 0xa867, 0x0103, 0xa833, 0x0200, 0x009e,
+	0x080c, 0x305d, 0x6020, 0x9086, 0x000a, 0x0138, 0x080c, 0x9be6,
+	0x0020, 0x080c, 0xa59c, 0x080c, 0xa83f, 0x001e, 0x002e, 0x00ee,
+	0x00be, 0x0005, 0x2011, 0x1823, 0x2204, 0x9086, 0x0014, 0x1160,
+	0x2001, 0x0002, 0x080c, 0x61e0, 0x6003, 0x0001, 0x6007, 0x0001,
+	0x080c, 0x84ee, 0x0804, 0x894f, 0x0804, 0xa83f, 0x2030, 0x2011,
+	0x1823, 0x2204, 0x9086, 0x0004, 0x1148, 0x96b6, 0x000b, 0x1120,
+	0x2001, 0x0007, 0x080c, 0x61e0, 0x0804, 0x9be6, 0x0804, 0xa83f,
+	0x0002, 0xa67d, 0xa938, 0xa67d, 0xa977, 0xa67d, 0xaa22, 0xa92d,
+	0xa67d, 0xa67d, 0xaa35, 0xa67d, 0xaa45, 0x6604, 0x9686, 0x0003,
+	0x0904, 0xa854, 0x96b6, 0x001e, 0x1110, 0x080c, 0x9be6, 0x0005,
+	0x00b6, 0x00d6, 0x00c6, 0x080c, 0xaa55, 0x11a0, 0x9006, 0x080c,
+	0x61cc, 0x080c, 0x302e, 0x080c, 0xbfa4, 0x2001, 0x0002, 0x080c,
+	0x61e0, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x84ee, 0x080c,
+	0x894f, 0x0408, 0x2009, 0x026e, 0x2104, 0x9086, 0x0009, 0x1160,
+	0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0170, 0x8001,
+	0xb842, 0x601b, 0x000a, 0x0078, 0x2009, 0x026f, 0x2104, 0x9084,
+	0xff00, 0x9086, 0x1900, 0x1108, 0x08a0, 0x080c, 0x302e, 0x080c,
+	0xbfa4, 0x080c, 0xa83f, 0x00ce, 0x00de, 0x00be, 0x0005, 0x0096,
+	0x00b6, 0x0026, 0x9016, 0x080c, 0xaa63, 0x00d6, 0x2069, 0x1954,
+	0x2d04, 0x9005, 0x0168, 0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e,
+	0x1138, 0x2069, 0x181f, 0x2d04, 0x8000, 0x206a, 0x00de, 0x0010,
+	0x00de, 0x0088, 0x9006, 0x080c, 0x61cc, 0x2001, 0x0002, 0x080c,
+	0x61e0, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x84ee, 0x080c,
+	0x894f, 0x0804, 0xa9f2, 0x080c, 0xb870, 0x01b0, 0x6014, 0x2048,
+	0xa864, 0x2010, 0x9086, 0x0139, 0x1138, 0x6007, 0x0016, 0x2001,
+	0x0002, 0x080c, 0xbec8, 0x00b0, 0x6014, 0x2048, 0xa864, 0xd0fc,
+	0x0118, 0x2001, 0x0001, 0x0ca8, 0x2001, 0x180e, 0x2004, 0xd0dc,
+	0x0148, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x1110,
+	0x9006, 0x0c38, 0x080c, 0xa59c, 0x2009, 0x026e, 0x2134, 0x96b4,
+	0x00ff, 0x9686, 0x0005, 0x0510, 0x9686, 0x000b, 0x01c8, 0x2009,
+	0x026f, 0x2104, 0x9084, 0xff00, 0x1118, 0x9686, 0x0009, 0x01b0,
+	0x9086, 0x1900, 0x1168, 0x9686, 0x0009, 0x0180, 0x2001, 0x0004,
+	0x080c, 0x61e0, 0x2001, 0x0028, 0x601a, 0x6007, 0x0052, 0x0010,
+	0x080c, 0xa83f, 0x002e, 0x00be, 0x009e, 0x0005, 0x9286, 0x0139,
+	0x0160, 0x6014, 0x2048, 0x080c, 0xb870, 0x0140, 0xa864, 0x9086,
+	0x0139, 0x0118, 0xa868, 0xd0fc, 0x0108, 0x0c50, 0x6010, 0x2058,
+	0xb840, 0x9084, 0x00ff, 0x9005, 0x0138, 0x8001, 0xb842, 0x601b,
+	0x000a, 0x6007, 0x0016, 0x08f0, 0xb8a0, 0x9086, 0x007e, 0x1138,
+	0x00e6, 0x2071, 0x1800, 0x080c, 0x5c8a, 0x00ee, 0x0010, 0x080c,
+	0x302e, 0x0870, 0x080c, 0xaa63, 0x1160, 0x2001, 0x0004, 0x080c,
+	0x61e0, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c, 0x84ee, 0x0804,
+	0x894f, 0x080c, 0xa59c, 0x0804, 0xa83f, 0x0469, 0x1160, 0x2001,
+	0x0008, 0x080c, 0x61e0, 0x6003, 0x0001, 0x6007, 0x0005, 0x080c,
+	0x84ee, 0x0804, 0x894f, 0x0804, 0xa83f, 0x00e9, 0x1160, 0x2001,
+	0x000a, 0x080c, 0x61e0, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c,
+	0x84ee, 0x0804, 0x894f, 0x0804, 0xa83f, 0x2009, 0x026e, 0x2104,
+	0x9086, 0x0003, 0x1138, 0x2009, 0x026f, 0x2104, 0x9084, 0xff00,
+	0x9086, 0x2a00, 0x0005, 0x9085, 0x0001, 0x0005, 0x00b6, 0x00c6,
+	0x0016, 0x6110, 0x2158, 0x080c, 0x629e, 0x001e, 0x00ce, 0x00be,
+	0x0005, 0x00b6, 0x00f6, 0x00e6, 0x00d6, 0x0036, 0x0016, 0x6010,
+	0x2058, 0x2009, 0x1836, 0x2104, 0x9085, 0x0003, 0x200a, 0x080c,
+	0xab09, 0x0560, 0x2009, 0x1836, 0x2104, 0xc0cd, 0x200a, 0x080c,
+	0x6686, 0x0158, 0x9006, 0x2020, 0x2009, 0x002a, 0x080c, 0xd2bc,
+	0x2001, 0x180c, 0x200c, 0xc195, 0x2102, 0x2019, 0x002a, 0x2009,
+	0x0001, 0x080c, 0x2ff3, 0x00e6, 0x2071, 0x1800, 0x080c, 0x2e09,
+	0x00ee, 0x00c6, 0x0156, 0x20a9, 0x0781, 0x2009, 0x007f, 0x080c,
+	0x3136, 0x8108, 0x1f04, 0xaaa7, 0x015e, 0x00ce, 0x080c, 0xaa66,
+	0x2071, 0x0260, 0x2079, 0x0200, 0x7817, 0x0001, 0x2001, 0x1836,
+	0x200c, 0xc1c5, 0x7018, 0xd0fc, 0x0110, 0xd0dc, 0x0118, 0x7038,
+	0xd0dc, 0x1108, 0xc1c4, 0x7817, 0x0000, 0x2001, 0x1836, 0x2102,
+	0x2079, 0x0100, 0x2e04, 0x9084, 0x00ff, 0x2069, 0x181e, 0x206a,
+	0x78e6, 0x0006, 0x8e70, 0x2e04, 0x2069, 0x181f, 0x206a, 0x78ea,
+	0x7832, 0x7836, 0x2010, 0x9084, 0xff00, 0x001e, 0x9105, 0x2009,
+	0x182b, 0x200a, 0x2200, 0x9084, 0x00ff, 0x2008, 0x080c, 0x24a2,
+	0x080c, 0x70ba, 0x0170, 0x2071, 0x0260, 0x2069, 0x195a, 0x7048,
+	0x206a, 0x704c, 0x6806, 0x7050, 0x680a, 0x7054, 0x680e, 0x080c,
+	0xbc9b, 0x0040, 0x2001, 0x0006, 0x080c, 0x61e0, 0x080c, 0x305d,
+	0x080c, 0x9be6, 0x001e, 0x003e, 0x00de, 0x00ee, 0x00fe, 0x00be,
+	0x0005, 0x0096, 0x0026, 0x0036, 0x00e6, 0x0156, 0x2019, 0x182b,
+	0x231c, 0x83ff, 0x01f0, 0x2071, 0x0260, 0x7200, 0x9294, 0x00ff,
+	0x7004, 0x9084, 0xff00, 0x9205, 0x9306, 0x1198, 0x2011, 0x0276,
+	0x20a9, 0x0004, 0x2b48, 0x2019, 0x000a, 0x080c, 0xabee, 0x1148,
+	0x2011, 0x027a, 0x20a9, 0x0004, 0x2019, 0x0006, 0x080c, 0xabee,
+	0x1100, 0x015e, 0x00ee, 0x003e, 0x002e, 0x009e, 0x0005, 0x00e6,
+	0x2071, 0x0260, 0x7034, 0x9086, 0x0014, 0x11a8, 0x7038, 0x9086,
+	0x0800, 0x1188, 0x703c, 0xd0ec, 0x0160, 0x9084, 0x0f00, 0x9086,
+	0x0100, 0x1138, 0x7054, 0xd0a4, 0x1110, 0xd0ac, 0x0110, 0x9006,
+	0x0010, 0x9085, 0x0001, 0x00ee, 0x0005, 0x00e6, 0x0096, 0x00c6,
+	0x0076, 0x0056, 0x0046, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000,
+	0x2029, 0x19cb, 0x252c, 0x2021, 0x19d2, 0x2424, 0x2061, 0x1ddc,
+	0x2071, 0x1800, 0x7250, 0x7070, 0x9202, 0x1a04, 0xabc6, 0x080c,
+	0xd2ed, 0x0904, 0xabbf, 0x6720, 0x9786, 0x0007, 0x0904, 0xabbf,
+	0x2500, 0x9c06, 0x0904, 0xabbf, 0x2400, 0x9c06, 0x0904, 0xabbf,
+	0x3e08, 0x9186, 0x0002, 0x1148, 0x6010, 0x9005, 0x0130, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x1590, 0x00c6, 0x6043, 0xffff,
+	0x6000, 0x9086, 0x0004, 0x1110, 0x080c, 0x193e, 0x9786, 0x000a,
+	0x0148, 0x080c, 0xba85, 0x1130, 0x00ce, 0x080c, 0xa59c, 0x080c,
+	0x9c20, 0x00e8, 0x6014, 0x2048, 0x080c, 0xb870, 0x01a8, 0x9786,
+	0x0003, 0x1530, 0xa867, 0x0103, 0xa87c, 0xd0cc, 0x0130, 0x0096,
+	0xa878, 0x2048, 0x080c, 0x0fe1, 0x009e, 0xab7a, 0xa877, 0x0000,
+	0x080c, 0x69a9, 0x080c, 0xba5f, 0x080c, 0x9c20, 0x00ce, 0x9ce0,
+	0x001c, 0x7064, 0x9c02, 0x1210, 0x0804, 0xab6a, 0x012e, 0x000e,
+	0x002e, 0x004e, 0x005e, 0x007e, 0x00ce, 0x009e, 0x00ee, 0x0005,
+	0x9786, 0x0006, 0x1118, 0x080c, 0xd267, 0x0c30, 0x9786, 0x000a,
+	0x0998, 0x0880, 0x220c, 0x2304, 0x9106, 0x1130, 0x8210, 0x8318,
+	0x1f04, 0xabda, 0x9006, 0x0005, 0x2304, 0x9102, 0x0218, 0x2001,
+	0x0001, 0x0008, 0x9006, 0x918d, 0x0001, 0x0005, 0x0136, 0x01c6,
+	0x0016, 0x8906, 0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084,
+	0xffc0, 0x9300, 0x2098, 0x3518, 0x20a9, 0x0001, 0x220c, 0x4002,
+	0x910e, 0x1140, 0x8210, 0x8319, 0x1dc8, 0x9006, 0x001e, 0x01ce,
+	0x013e, 0x0005, 0x220c, 0x9102, 0x0218, 0x2001, 0x0001, 0x0010,
+	0x2001, 0x0000, 0x918d, 0x0001, 0x001e, 0x01ce, 0x013e, 0x0005,
+	0x6004, 0x908a, 0x0053, 0x1a0c, 0x0d65, 0x080c, 0xba74, 0x0120,
+	0x080c, 0xba85, 0x0158, 0x0028, 0x080c, 0x305d, 0x080c, 0xba85,
+	0x0128, 0x080c, 0x8891, 0x080c, 0x9be6, 0x0005, 0x080c, 0xa59c,
+	0x0cc0, 0x9182, 0x0057, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a,
+	0x0005, 0xac50, 0xac50, 0xac50, 0xac50, 0xac50, 0xac50, 0xac50,
+	0xac50, 0xac50, 0xac50, 0xac50, 0xac52, 0xac52, 0xac52, 0xac52,
+	0xac50, 0xac50, 0xac50, 0xac52, 0xac50, 0xac50, 0xac50, 0xac50,
+	0x080c, 0x0d65, 0x600b, 0xffff, 0x6003, 0x000f, 0x6106, 0x0126,
+	0x2091, 0x8000, 0x080c, 0xbfa7, 0x2009, 0x8000, 0x080c, 0x84e7,
+	0x012e, 0x0005, 0x9186, 0x0013, 0x1128, 0x6004, 0x9082, 0x0040,
+	0x0804, 0xacd7, 0x9186, 0x0027, 0x1520, 0x080c, 0x8891, 0x080c,
+	0x302e, 0x080c, 0xbfa4, 0x0096, 0x6114, 0x2148, 0x080c, 0xb870,
+	0x0198, 0x080c, 0xba85, 0x1118, 0x080c, 0xa59c, 0x0068, 0xa867,
+	0x0103, 0xa87b, 0x0029, 0xa877, 0x0000, 0xa97c, 0xc1c5, 0xa97e,
+	0x080c, 0x69b5, 0x080c, 0xba5f, 0x009e, 0x080c, 0x9be6, 0x0804,
+	0x894f, 0x9186, 0x0014, 0x1120, 0x6004, 0x9082, 0x0040, 0x0018,
+	0x080c, 0x0d65, 0x0005, 0x0002, 0xacb5, 0xacb3, 0xacb3, 0xacb3,
+	0xacb3, 0xacb3, 0xacb3, 0xacb3, 0xacb3, 0xacb3, 0xacb3, 0xacce,
+	0xacce, 0xacce, 0xacce, 0xacb3, 0xacce, 0xacb3, 0xacce, 0xacb3,
+	0xacb3, 0xacb3, 0xacb3, 0x080c, 0x0d65, 0x080c, 0x8891, 0x0096,
+	0x6114, 0x2148, 0x080c, 0xb870, 0x0168, 0xa867, 0x0103, 0xa87b,
+	0x0006, 0xa877, 0x0000, 0xa880, 0xc0ec, 0xa882, 0x080c, 0x69b5,
+	0x080c, 0xba5f, 0x009e, 0x080c, 0x9be6, 0x0005, 0x080c, 0x8891,
+	0x080c, 0xba85, 0x090c, 0xa59c, 0x080c, 0x9be6, 0x0005, 0x0002,
+	0xacf1, 0xacef, 0xacef, 0xacef, 0xacef, 0xacef, 0xacef, 0xacef,
+	0xacef, 0xacef, 0xacef, 0xacf3, 0xacf3, 0xacf3, 0xacf3, 0xacef,
+	0xacf5, 0xacef, 0xacf3, 0xacef, 0xacef, 0xacef, 0xacef, 0x080c,
+	0x0d65, 0x080c, 0x0d65, 0x080c, 0x0d65, 0x080c, 0x9be6, 0x0804,
+	0x894f, 0x9182, 0x0057, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a,
+	0x0005, 0xad18, 0xad18, 0xad18, 0xad18, 0xad18, 0xad51, 0xae40,
+	0xad18, 0xae4c, 0xad18, 0xad18, 0xad18, 0xad18, 0xad18, 0xad18,
+	0xad18, 0xad18, 0xad18, 0xad18, 0xae4c, 0xad1a, 0xad18, 0xae4a,
+	0x080c, 0x0d65, 0x00b6, 0x0096, 0x6114, 0x2148, 0x6010, 0x2058,
+	0xb800, 0xd0bc, 0x1508, 0xa87b, 0x0000, 0xa867, 0x0103, 0xa877,
 	0x0000, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115, 0x190c,
-	0xaeb6, 0xa974, 0x0016, 0x080c, 0x67a7, 0x001e, 0x6010, 0x00b6,
-	0x2058, 0xb8c0, 0x0016, 0x9005, 0x190c, 0x6396, 0x001e, 0x00be,
-	0xd1e4, 0x1120, 0x080c, 0x9bda, 0x009e, 0x0005, 0x080c, 0xbb4f,
-	0x0cd8, 0x6114, 0x0096, 0x2148, 0xa97c, 0x080c, 0xbf87, 0x190c,
-	0x190d, 0x009e, 0x0005, 0x0096, 0x6114, 0x2148, 0xa83c, 0xa940,
-	0x9105, 0x01e8, 0xa877, 0x0000, 0xa87b, 0x0000, 0xa867, 0x0103,
-	0x00b6, 0x6010, 0x2058, 0xa834, 0xa938, 0x9115, 0x11a0, 0x080c,
-	0x67a7, 0xba3c, 0x8211, 0x0208, 0xba3e, 0xb8c0, 0x9005, 0x0110,
-	0x080c, 0x6396, 0x080c, 0x9bda, 0x00be, 0x009e, 0x0005, 0xa87c,
-	0xc0dc, 0xa87e, 0x08f8, 0xb800, 0xd0bc, 0x1120, 0xa834, 0x080c,
-	0xaeb6, 0x0c28, 0xa880, 0xd0bc, 0x1dc8, 0x080c, 0xbb8c, 0x0c60,
-	0x080c, 0x885d, 0x0010, 0x080c, 0x88b8, 0x601c, 0xd084, 0x0110,
-	0x080c, 0x1921, 0x080c, 0xb842, 0x01f0, 0x0096, 0x6114, 0x2148,
-	0x080c, 0xba57, 0x1118, 0x080c, 0xa581, 0x00a0, 0xa867, 0x0103,
-	0x2009, 0x180c, 0x210c, 0xd18c, 0x1198, 0xd184, 0x1170, 0x6108,
-	0xa97a, 0x918e, 0x0029, 0x1110, 0x080c, 0xd52b, 0xa877, 0x0000,
-	0x080c, 0x6991, 0x009e, 0x0804, 0x9c14, 0xa87b, 0x0004, 0x0cb0,
-	0xa87b, 0x0004, 0x0c98, 0x9182, 0x0057, 0x1220, 0x9182, 0x0040,
-	0x0208, 0x000a, 0x0005, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a,
-	0xb17c, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a,
-	0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb1a0,
-	0xb17a, 0xb17a, 0x080c, 0x0d65, 0x080c, 0x5390, 0x01f8, 0x6014,
-	0x7144, 0x918c, 0x0fff, 0x9016, 0xd1c4, 0x0118, 0x7264, 0x9294,
-	0x00ff, 0x0096, 0x904d, 0x0188, 0xa87b, 0x0000, 0xa864, 0x9086,
-	0x0139, 0x0128, 0xa867, 0x0103, 0xa976, 0xaa96, 0x0030, 0xa897,
-	0x4000, 0xa99a, 0xaa9e, 0x080c, 0x6991, 0x009e, 0x0804, 0x9bda,
-	0x080c, 0x5390, 0x0dd8, 0x6014, 0x900e, 0x9016, 0x0c10, 0x9182,
-	0x0085, 0x0002, 0xb1b9, 0xb1b7, 0xb1b7, 0xb1c5, 0xb1b7, 0xb1b7,
-	0xb1b7, 0xb1b7, 0xb1b7, 0xb1b7, 0xb1b7, 0xb1b7, 0xb1b7, 0x080c,
-	0x0d65, 0x6003, 0x0001, 0x6106, 0x0126, 0x2091, 0x8000, 0x2009,
-	0x8020, 0x080c, 0x84b3, 0x012e, 0x0005, 0x0026, 0x0056, 0x00d6,
-	0x00e6, 0x2071, 0x0260, 0x7224, 0x6216, 0x7220, 0x080c, 0xb830,
-	0x01a0, 0x2268, 0x6800, 0x9086, 0x0000, 0x0178, 0x6010, 0x6d10,
-	0x952e, 0x1158, 0x00c6, 0x2d60, 0x080c, 0xb433, 0x00ce, 0x0128,
-	0x6803, 0x0002, 0x6007, 0x0086, 0x0010, 0x6007, 0x0087, 0x6003,
-	0x0001, 0x2009, 0x8020, 0x080c, 0x84b3, 0x9280, 0x0004, 0x00b6,
-	0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140, 0x6824, 0xd0ec, 0x0128,
-	0x00c6, 0x2260, 0x080c, 0xbb8c, 0x00ce, 0x00ee, 0x00de, 0x005e,
-	0x002e, 0x0005, 0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085,
-	0x0a0c, 0x0d65, 0x908a, 0x0092, 0x1a0c, 0x0d65, 0x9082, 0x0085,
-	0x00e2, 0x9186, 0x0027, 0x0120, 0x9186, 0x0014, 0x190c, 0x0d65,
-	0x080c, 0x885d, 0x0096, 0x6014, 0x2048, 0x080c, 0xb842, 0x0140,
-	0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0029, 0x080c, 0x6991,
-	0x009e, 0x080c, 0x9c14, 0x0804, 0x891b, 0xb23a, 0xb23c, 0xb23c,
-	0xb23a, 0xb23a, 0xb23a, 0xb23a, 0xb23a, 0xb23a, 0xb23a, 0xb23a,
-	0xb23a, 0xb23a, 0x080c, 0x0d65, 0x080c, 0x9c14, 0x0005, 0x9186,
-	0x0013, 0x1130, 0x6004, 0x9082, 0x0085, 0x2008, 0x0804, 0xb28b,
-	0x9186, 0x0027, 0x1558, 0x080c, 0x885d, 0x080c, 0x300e, 0x080c,
-	0xbf76, 0x0096, 0x6014, 0x2048, 0x080c, 0xb842, 0x0150, 0xa867,
-	0x0103, 0xa877, 0x0000, 0xa87b, 0x0029, 0x080c, 0x6991, 0x080c,
-	0xba31, 0x009e, 0x080c, 0x9bda, 0x0005, 0x9186, 0x0089, 0x0118,
-	0x9186, 0x008a, 0x1140, 0x080c, 0x9aaa, 0x0128, 0x9086, 0x000c,
-	0x0904, 0xb2c3, 0x0000, 0x080c, 0x9c93, 0x0c70, 0x9186, 0x0014,
-	0x1d60, 0x080c, 0x885d, 0x0096, 0x6014, 0x2048, 0x080c, 0xb842,
-	0x0d00, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0006, 0xa880,
-	0xc0ec, 0xa882, 0x0890, 0x0002, 0xb29b, 0xb299, 0xb299, 0xb299,
-	0xb299, 0xb299, 0xb2af, 0xb299, 0xb299, 0xb299, 0xb299, 0xb299,
-	0xb299, 0x080c, 0x0d65, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186,
-	0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x2001, 0x1956, 0x0010,
-	0x2001, 0x1957, 0x2004, 0x601a, 0x6003, 0x000c, 0x0005, 0x6034,
-	0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035,
-	0x1118, 0x2001, 0x1956, 0x0010, 0x2001, 0x1957, 0x2004, 0x601a,
-	0x6003, 0x000e, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085,
-	0x0208, 0x0012, 0x0804, 0x9c93, 0xb2d9, 0xb2d9, 0xb2d9, 0xb2d9,
-	0xb2db, 0xb328, 0xb2d9, 0xb2d9, 0xb2d9, 0xb2d9, 0xb2d9, 0xb2d9,
-	0xb2d9, 0x080c, 0x0d65, 0x0096, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x0168, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186,
-	0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x009e, 0x0804, 0xb33c,
-	0x080c, 0xb842, 0x1118, 0x080c, 0xba31, 0x0068, 0x6014, 0x2048,
-	0x080c, 0xbf8d, 0x1110, 0x080c, 0xba31, 0xa867, 0x0103, 0x080c,
-	0xbf41, 0x080c, 0x6991, 0x00d6, 0x2c68, 0x080c, 0x9b84, 0x01d0,
-	0x6003, 0x0001, 0x6007, 0x001e, 0x600b, 0xffff, 0x2009, 0x026e,
-	0x210c, 0x613a, 0x2009, 0x026f, 0x210c, 0x613e, 0x6910, 0x6112,
-	0x080c, 0xbcdb, 0x695c, 0x615e, 0x6023, 0x0001, 0x2009, 0x8020,
-	0x080c, 0x84b3, 0x2d60, 0x00de, 0x080c, 0x9bda, 0x009e, 0x0005,
-	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x05a0, 0x6034,
-	0x908c, 0xff00, 0x810f, 0x9186, 0x0035, 0x0130, 0x9186, 0x001e,
-	0x0118, 0x9186, 0x0039, 0x1538, 0x00d6, 0x2c68, 0x080c, 0xbed9,
-	0x11f0, 0x080c, 0x9b84, 0x01d8, 0x6106, 0x6003, 0x0001, 0x6023,
-	0x0001, 0x6910, 0x6112, 0x692c, 0x612e, 0x6930, 0x6132, 0x6934,
-	0x918c, 0x00ff, 0x6136, 0x6938, 0x613a, 0x693c, 0x613e, 0x695c,
-	0x615e, 0x080c, 0xbcdb, 0x2009, 0x8020, 0x080c, 0x84b3, 0x2d60,
-	0x00de, 0x0804, 0x9bda, 0x0096, 0x6014, 0x2048, 0x080c, 0xb842,
-	0x01c8, 0xa867, 0x0103, 0xa880, 0xd0b4, 0x0128, 0xc0ec, 0xa882,
-	0xa87b, 0x0006, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002, 0x0020,
-	0xa87b, 0x0005, 0x080c, 0xbb4b, 0xa877, 0x0000, 0x080c, 0x6991,
-	0x080c, 0xba31, 0x009e, 0x0804, 0x9bda, 0x0016, 0x0096, 0x6014,
-	0x2048, 0x080c, 0xb842, 0x0140, 0xa867, 0x0103, 0xa87b, 0x0028,
-	0xa877, 0x0000, 0x080c, 0x6991, 0x009e, 0x001e, 0x9186, 0x0013,
-	0x0158, 0x9186, 0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c,
-	0x9c93, 0x0020, 0x080c, 0x885d, 0x080c, 0x9c14, 0x0005, 0x0056,
-	0x0066, 0x0096, 0x00a6, 0x2029, 0x0001, 0x9182, 0x0101, 0x1208,
-	0x0010, 0x2009, 0x0100, 0x2130, 0x8304, 0x9098, 0x0018, 0x2009,
-	0x0020, 0x2011, 0x0029, 0x080c, 0xb408, 0x96b2, 0x0020, 0xb004,
-	0x904d, 0x0110, 0x080c, 0x0fd4, 0x080c, 0x1022, 0x0520, 0x8528,
-	0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406, 0x968a, 0x003d,
-	0x1228, 0x2608, 0x2011, 0x001b, 0x0499, 0x00a8, 0x96b2, 0x003c,
-	0x2009, 0x003c, 0x2950, 0x2011, 0x001b, 0x0451, 0x0c28, 0x2001,
-	0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0003, 0xb566,
-	0x95ac, 0x0000, 0x0048, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae,
-	0x852f, 0x95ad, 0x0003, 0xb566, 0x009e, 0x006e, 0x005e, 0x0005,
-	0x00a6, 0x89ff, 0x0158, 0xa804, 0x9055, 0x0130, 0xa807, 0x0000,
-	0x080c, 0x6991, 0x2a48, 0x0cb8, 0x080c, 0x6991, 0x00ae, 0x0005,
-	0x00f6, 0x2079, 0x0200, 0x7814, 0x9085, 0x0080, 0x7816, 0xd184,
-	0x0108, 0x8108, 0x810c, 0x20a9, 0x0001, 0xa860, 0x20e8, 0xa85c,
-	0x9200, 0x20a0, 0x20e1, 0x0000, 0x2300, 0x9e00, 0x2098, 0x4003,
-	0x8318, 0x9386, 0x0020, 0x1148, 0x2018, 0x2300, 0x9e00, 0x2098,
-	0x7814, 0x8000, 0x9085, 0x0080, 0x7816, 0x8109, 0x1d80, 0x7817,
-	0x0000, 0x00fe, 0x0005, 0x0066, 0x0126, 0x2091, 0x8000, 0x2031,
-	0x0001, 0x6020, 0x9084, 0x000f, 0x0083, 0x012e, 0x006e, 0x0005,
-	0x0126, 0x2091, 0x8000, 0x0066, 0x2031, 0x0000, 0x6020, 0x9084,
-	0x000f, 0x001b, 0x006e, 0x012e, 0x0005, 0xb485, 0xb485, 0xb480,
-	0xb4a9, 0xb45d, 0xb480, 0xb45f, 0xb480, 0xb45d, 0xb45d, 0xb480,
-	0xb480, 0xb480, 0xb45d, 0xb45d, 0xb45d, 0x080c, 0x0d65, 0x6010,
-	0x9080, 0x0000, 0x2004, 0xd0bc, 0x190c, 0xb4a9, 0x0036, 0x6014,
-	0x0096, 0x2048, 0xa880, 0x009e, 0xd0cc, 0x0118, 0x2019, 0x000c,
-	0x0038, 0xd094, 0x0118, 0x2019, 0x000d, 0x0010, 0x2019, 0x0010,
-	0x080c, 0xce09, 0x6023, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005,
-	0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x0096, 0x86ff, 0x11e8,
-	0x6014, 0x2048, 0x080c, 0xb842, 0x01d0, 0x6043, 0xffff, 0xa864,
-	0x9086, 0x0139, 0x1128, 0xa87b, 0x0005, 0xa883, 0x0000, 0x0028,
-	0x900e, 0x2001, 0x0005, 0x080c, 0x6ba2, 0x080c, 0xbb4b, 0x080c,
-	0x6985, 0x080c, 0x9c14, 0x9085, 0x0001, 0x009e, 0x0005, 0x9006,
-	0x0ce0, 0x080c, 0x98bb, 0x080c, 0xbf9b, 0x6000, 0x908a, 0x0016,
-	0x1a0c, 0x0d65, 0x002b, 0x0106, 0x080c, 0x98d7, 0x010e, 0x0005,
-	0xb4c8, 0xb4f6, 0xb4ca, 0xb51d, 0xb4f1, 0xb4c8, 0xb480, 0xb485,
-	0xb485, 0xb480, 0xb480, 0xb480, 0xb480, 0xb480, 0xb480, 0xb480,
-	0x080c, 0x0d65, 0x86ff, 0x1510, 0x6020, 0x9086, 0x0006, 0x01f0,
-	0x0096, 0x6014, 0x2048, 0x080c, 0xb842, 0x0158, 0xa87c, 0xd0cc,
-	0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fd4, 0x009e, 0x080c,
-	0xbb4b, 0x009e, 0x080c, 0xbf1b, 0x6007, 0x0085, 0x6003, 0x000b,
-	0x6023, 0x0002, 0x2009, 0x8020, 0x080c, 0x8495, 0x9085, 0x0001,
-	0x0005, 0x0066, 0x080c, 0x1921, 0x006e, 0x08a0, 0x00e6, 0x2071,
-	0x19b7, 0x7030, 0x9c06, 0x1120, 0x080c, 0x91e9, 0x00ee, 0x0850,
-	0x6020, 0x9084, 0x000f, 0x9086, 0x0006, 0x1150, 0x0086, 0x0096,
-	0x2049, 0x0001, 0x2c40, 0x080c, 0x9365, 0x009e, 0x008e, 0x0040,
-	0x0066, 0x080c, 0x90e5, 0x190c, 0x0d65, 0x080c, 0x90f3, 0x006e,
-	0x00ee, 0x1904, 0xb4ca, 0x0804, 0xb480, 0x0036, 0x00e6, 0x2071,
-	0x19b7, 0x704c, 0x9c06, 0x1138, 0x901e, 0x080c, 0x9269, 0x00ee,
-	0x003e, 0x0804, 0xb4ca, 0x080c, 0x949c, 0x00ee, 0x003e, 0x1904,
-	0xb4ca, 0x0804, 0xb480, 0x00c6, 0x0066, 0x6020, 0x9084, 0x000f,
-	0x001b, 0x006e, 0x00ce, 0x0005, 0xb553, 0xb622, 0xb789, 0xb55b,
-	0x9c14, 0xb553, 0xcdfb, 0xbf83, 0xb622, 0xb54c, 0xb808, 0xb54c,
-	0xb54c, 0xb54c, 0xb54c, 0xb54c, 0x080c, 0x0d65, 0x080c, 0xba57,
-	0x1110, 0x080c, 0xa581, 0x0005, 0x080c, 0x885d, 0x0804, 0x9bda,
-	0x601b, 0x0001, 0x0005, 0x080c, 0xb842, 0x0130, 0x6014, 0x0096,
-	0x2048, 0x2c00, 0xa896, 0x009e, 0x080c, 0x98bb, 0x080c, 0xbf9b,
-	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d65, 0x0013, 0x0804, 0x98d7,
-	0xb580, 0xb582, 0xb5ac, 0xb5c0, 0xb5ed, 0xb580, 0xb553, 0xb553,
-	0xb553, 0xb5c7, 0xb5c7, 0xb580, 0xb580, 0xb580, 0xb580, 0xb5d1,
-	0x080c, 0x0d65, 0x00e6, 0x6014, 0x0096, 0x2048, 0xa880, 0xc0b5,
-	0xa882, 0x009e, 0x2071, 0x19b7, 0x7030, 0x9c06, 0x01d0, 0x0066,
-	0x080c, 0x90e5, 0x190c, 0x0d65, 0x080c, 0x90f3, 0x006e, 0x080c,
-	0xbf1b, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2001,
-	0x1957, 0x2004, 0x601a, 0x2009, 0x8020, 0x080c, 0x8495, 0x00ee,
-	0x0005, 0x601b, 0x0001, 0x0cd8, 0x0096, 0x6014, 0x2048, 0xa880,
-	0xc0b5, 0xa882, 0x009e, 0x080c, 0xbf1b, 0x6007, 0x0085, 0x6003,
-	0x000b, 0x6023, 0x0002, 0x2009, 0x8020, 0x080c, 0x8495, 0x0005,
-	0x080c, 0x98bb, 0x080c, 0x9a2c, 0x080c, 0x98d7, 0x0c28, 0x0096,
-	0x601b, 0x0001, 0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e,
-	0x0005, 0x080c, 0x5390, 0x01b8, 0x6014, 0x0096, 0x904d, 0x0190,
-	0xa864, 0xa867, 0x0103, 0xa87b, 0x0006, 0x9086, 0x0139, 0x1150,
-	0xa867, 0x0139, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa89b, 0x0004,
-	0x080c, 0x6991, 0x009e, 0x0804, 0x9bda, 0x6014, 0x0096, 0x904d,
-	0x0560, 0xa97c, 0xd1e4, 0x1158, 0x611c, 0xd1fc, 0x0530, 0x6110,
-	0x00b6, 0x2158, 0xb93c, 0x8109, 0x0208, 0xb93e, 0x00be, 0x080c,
-	0x98d7, 0x2001, 0x180f, 0x2004, 0xd0c4, 0x0110, 0x009e, 0x0005,
-	0xa884, 0x009e, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0x2001,
-	0x0037, 0x2c08, 0x080c, 0x15ab, 0x6000, 0x9086, 0x0004, 0x1120,
-	0x2009, 0x0048, 0x080c, 0x9c76, 0x0005, 0x009e, 0x080c, 0x1921,
-	0x0804, 0xb5ac, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d65, 0x000b,
-	0x0005, 0xb639, 0xb558, 0xb63b, 0xb639, 0xb63b, 0xb63b, 0xb554,
-	0xb639, 0xb54e, 0xb54e, 0xb639, 0xb639, 0xb639, 0xb639, 0xb639,
-	0xb639, 0x080c, 0x0d65, 0x6010, 0x00b6, 0x2058, 0xb804, 0x9084,
-	0x00ff, 0x00be, 0x908a, 0x000c, 0x1a0c, 0x0d65, 0x00b6, 0x0013,
-	0x00be, 0x0005, 0xb656, 0xb723, 0xb658, 0xb698, 0xb658, 0xb698,
-	0xb658, 0xb666, 0xb656, 0xb698, 0xb656, 0xb687, 0x080c, 0x0d65,
-	0x6004, 0x908e, 0x0016, 0x05c0, 0x908e, 0x0004, 0x05a8, 0x908e,
-	0x0002, 0x0590, 0x908e, 0x0052, 0x0904, 0xb71f, 0x6004, 0x080c,
-	0xba57, 0x0904, 0xb73c, 0x908e, 0x0004, 0x1110, 0x080c, 0x303d,
-	0x908e, 0x0021, 0x0904, 0xb740, 0x908e, 0x0022, 0x0904, 0xb784,
-	0x908e, 0x003d, 0x0904, 0xb740, 0x908e, 0x0039, 0x0904, 0xb744,
-	0x908e, 0x0035, 0x0904, 0xb744, 0x908e, 0x001e, 0x0178, 0x908e,
-	0x0001, 0x1140, 0x6010, 0x2058, 0xb804, 0x9084, 0x00ff, 0x9086,
-	0x0006, 0x0110, 0x080c, 0x300e, 0x080c, 0xa581, 0x0804, 0x9c14,
-	0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016, 0x0904, 0xb710, 0x9186,
-	0x0002, 0x1904, 0xb6e5, 0x2001, 0x1836, 0x2004, 0xd08c, 0x11c8,
-	0x080c, 0x7096, 0x11b0, 0x080c, 0xbf61, 0x0138, 0x080c, 0x70b9,
-	0x1120, 0x080c, 0x6fa1, 0x0804, 0xb76d, 0x2001, 0x194d, 0x2003,
-	0x0001, 0x2001, 0x1800, 0x2003, 0x0001, 0x080c, 0x6fc7, 0x0804,
-	0xb76d, 0x6010, 0x2058, 0x2001, 0x1836, 0x2004, 0xd0ac, 0x1904,
-	0xb76d, 0xb8a0, 0x9084, 0xff80, 0x1904, 0xb76d, 0xb840, 0x9084,
-	0x00ff, 0x9005, 0x0190, 0x8001, 0xb842, 0x6017, 0x0000, 0x6023,
-	0x0007, 0x601b, 0x0398, 0x604b, 0x0000, 0x080c, 0x9b84, 0x0128,
-	0x2b00, 0x6012, 0x6023, 0x0001, 0x0458, 0x00de, 0x00ce, 0x6004,
-	0x908e, 0x0002, 0x11a0, 0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e,
-	0x1170, 0x2009, 0x1836, 0x2104, 0xc085, 0x200a, 0x00e6, 0x2071,
-	0x1800, 0x080c, 0x5c6a, 0x00ee, 0x080c, 0xa581, 0x0030, 0x080c,
-	0xa581, 0x080c, 0x300e, 0x080c, 0xbf76, 0x00e6, 0x0126, 0x2091,
-	0x8000, 0x080c, 0x303d, 0x012e, 0x00ee, 0x080c, 0x9c14, 0x0005,
-	0x2001, 0x0002, 0x080c, 0x61bc, 0x6003, 0x0001, 0x6007, 0x0002,
-	0x080c, 0x84ba, 0x080c, 0x891b, 0x00de, 0x00ce, 0x0c80, 0x080c,
-	0x303d, 0x0804, 0xb694, 0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016,
-	0x0d38, 0x6010, 0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0904,
-	0xb6e5, 0x8001, 0xb842, 0x6003, 0x0001, 0x080c, 0x84ba, 0x080c,
-	0x891b, 0x00de, 0x00ce, 0x0898, 0x080c, 0xa581, 0x0804, 0xb696,
-	0x080c, 0xa5bd, 0x0804, 0xb696, 0x00d6, 0x2c68, 0x6104, 0x080c,
-	0xbed9, 0x00de, 0x0118, 0x080c, 0x9bda, 0x00f0, 0x6004, 0x8007,
-	0x6134, 0x918c, 0x00ff, 0x9105, 0x6036, 0x6007, 0x0085, 0x6003,
-	0x000b, 0x6023, 0x0002, 0x603c, 0x600a, 0x2001, 0x1957, 0x2004,
-	0x601a, 0x602c, 0x2c08, 0x2060, 0x6024, 0xc0b5, 0x6026, 0x2160,
-	0x2009, 0x8020, 0x080c, 0x84b3, 0x0005, 0x00de, 0x00ce, 0x080c,
-	0xa581, 0x080c, 0x300e, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x303d, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398, 0x604b,
-	0x0000, 0x012e, 0x00ee, 0x0005, 0x080c, 0xa014, 0x1904, 0xb73c,
-	0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d65, 0x0096, 0x00d6,
-	0x001b, 0x00de, 0x009e, 0x0005, 0xb7a4, 0xb7a4, 0xb7a4, 0xb7a4,
-	0xb7a4, 0xb7a4, 0xb7a4, 0xb7a4, 0xb7a4, 0xb553, 0xb7a4, 0xb558,
-	0xb7a6, 0xb558, 0xb7b3, 0xb7a4, 0x080c, 0x0d65, 0x6004, 0x9086,
-	0x008b, 0x0148, 0x6007, 0x008b, 0x6003, 0x000d, 0x2009, 0x8020,
-	0x080c, 0x84b3, 0x0005, 0x080c, 0xbf55, 0x0118, 0x080c, 0xbf68,
-	0x0010, 0x080c, 0xbf76, 0x080c, 0xba31, 0x080c, 0xb842, 0x0570,
-	0x080c, 0x300e, 0x080c, 0xb842, 0x0168, 0x6014, 0x2048, 0xa867,
-	0x0103, 0xa87b, 0x0006, 0xa877, 0x0000, 0xa880, 0xc0ed, 0xa882,
-	0x080c, 0x6991, 0x2c68, 0x080c, 0x9b84, 0x0150, 0x6810, 0x6012,
-	0x080c, 0xbcdb, 0x00c6, 0x2d60, 0x080c, 0x9c14, 0x00ce, 0x0008,
-	0x2d60, 0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003,
-	0x0001, 0x080c, 0x84ba, 0x080c, 0x891b, 0x00c8, 0x080c, 0xbf55,
-	0x0138, 0x6034, 0x9086, 0x4000, 0x1118, 0x080c, 0x300e, 0x08d0,
-	0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186,
-	0x0035, 0x1118, 0x080c, 0x300e, 0x0868, 0x080c, 0x9c14, 0x0005,
-	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d65, 0x0002, 0xb81e, 0xb81e,
-	0xb820, 0xb820, 0xb820, 0xb81e, 0xb81e, 0x9c14, 0xb81e, 0xb81e,
-	0xb81e, 0xb81e, 0xb81e, 0xb81e, 0xb81e, 0xb81e, 0x080c, 0x0d65,
-	0x080c, 0x98bb, 0x080c, 0x9a2c, 0x080c, 0x98d7, 0x6114, 0x0096,
-	0x2148, 0xa87b, 0x0006, 0x080c, 0x6991, 0x009e, 0x0804, 0x9bda,
-	0x9284, 0x0003, 0x1158, 0x9282, 0x1ddc, 0x0240, 0x2001, 0x1819,
-	0x2004, 0x9202, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8,
-	0x0096, 0x0028, 0x0096, 0x0006, 0x6014, 0x2048, 0x000e, 0x0006,
-	0x9984, 0xf000, 0x9086, 0xf000, 0x0110, 0x080c, 0x10cd, 0x000e,
-	0x009e, 0x0005, 0x00e6, 0x00c6, 0x0036, 0x0006, 0x0126, 0x2091,
-	0x8000, 0x2061, 0x1ddc, 0x2071, 0x1800, 0x7350, 0x7070, 0x9302,
-	0x1640, 0x6020, 0x9206, 0x11f8, 0x080c, 0xbf61, 0x0180, 0x9286,
-	0x0001, 0x1168, 0x6004, 0x9086, 0x0004, 0x1148, 0x080c, 0x300e,
-	0x080c, 0xbf76, 0x00c6, 0x080c, 0x9c14, 0x00ce, 0x0060, 0x080c,
-	0xbc4d, 0x0148, 0x080c, 0xba57, 0x1110, 0x080c, 0xa581, 0x00c6,
-	0x080c, 0x9bda, 0x00ce, 0x9ce0, 0x001c, 0x7064, 0x9c02, 0x1208,
-	0x08a0, 0x012e, 0x000e, 0x003e, 0x00ce, 0x00ee, 0x0005, 0x00e6,
-	0x00c6, 0x0016, 0x9188, 0x1000, 0x210c, 0x81ff, 0x0128, 0x2061,
-	0x1b01, 0x6112, 0x080c, 0x300e, 0x9006, 0x0010, 0x9085, 0x0001,
-	0x001e, 0x00ce, 0x00ee, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x9b84, 0x01b0, 0x665e, 0x2b00, 0x6012, 0x080c, 0x5390,
-	0x0118, 0x080c, 0xb973, 0x0168, 0x080c, 0xbcdb, 0x6023, 0x0003,
-	0x2009, 0x004b, 0x080c, 0x9c76, 0x9085, 0x0001, 0x012e, 0x00ce,
-	0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0xbaa0,
-	0x080c, 0x9c49, 0x0580, 0x605f, 0x0000, 0x2b00, 0x6012, 0x080c,
-	0xbcdb, 0x6023, 0x0003, 0x0016, 0x080c, 0x98bb, 0x080c, 0x8624,
-	0x0076, 0x903e, 0x080c, 0x8509, 0x2c08, 0x080c, 0xcfd9, 0x007e,
-	0x080c, 0x98d7, 0x001e, 0xd184, 0x0128, 0x080c, 0x9bda, 0x9085,
-	0x0001, 0x0070, 0x080c, 0x5390, 0x0128, 0xd18c, 0x1170, 0x080c,
-	0xb973, 0x0148, 0x2009, 0x004c, 0x080c, 0x9c76, 0x9085, 0x0001,
-	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2900, 0x6016, 0x0c90,
-	0x2009, 0x004d, 0x0010, 0x2009, 0x004e, 0x00f6, 0x00c6, 0x0046,
-	0x0016, 0x080c, 0x9b84, 0x2c78, 0x0590, 0x7e5e, 0x2b00, 0x7812,
-	0x7823, 0x0003, 0x2021, 0x0005, 0x080c, 0xb985, 0x9186, 0x004d,
-	0x0118, 0x9186, 0x004e, 0x0148, 0x2001, 0x1950, 0x200c, 0xd1fc,
-	0x0168, 0x2f60, 0x080c, 0x9bda, 0x00d0, 0x2001, 0x194f, 0x200c,
-	0xd1fc, 0x0120, 0x2f60, 0x080c, 0x9bda, 0x0088, 0x2f60, 0x080c,
-	0x5390, 0x0138, 0xd18c, 0x1118, 0x04f1, 0x0148, 0x0010, 0x2900,
-	0x7816, 0x001e, 0x0016, 0x080c, 0x9c76, 0x9085, 0x0001, 0x001e,
-	0x004e, 0x00ce, 0x00fe, 0x0005, 0x00f6, 0x00c6, 0x0046, 0x080c,
-	0x9b84, 0x2c78, 0x0508, 0x7e5e, 0x2b00, 0x7812, 0x7823, 0x0003,
-	0x0096, 0x2021, 0x0004, 0x0489, 0x009e, 0x2001, 0x194e, 0x200c,
-	0xd1fc, 0x0120, 0x2f60, 0x080c, 0x9bda, 0x0060, 0x2f60, 0x080c,
-	0x5390, 0x0120, 0xd18c, 0x1160, 0x0071, 0x0130, 0x2009, 0x0052,
-	0x080c, 0x9c76, 0x9085, 0x0001, 0x004e, 0x00ce, 0x00fe, 0x0005,
-	0x2900, 0x7816, 0x0c98, 0x00c6, 0x080c, 0x487a, 0x00ce, 0x1120,
-	0x080c, 0x9bda, 0x9006, 0x0005, 0xa867, 0x0000, 0xa86b, 0x8000,
-	0x2900, 0x6016, 0x9085, 0x0001, 0x0005, 0x0096, 0x0076, 0x0126,
-	0x2091, 0x8000, 0x080c, 0x98bb, 0x080c, 0x644d, 0x0158, 0x2001,
-	0xb98c, 0x0006, 0x900e, 0x2400, 0x080c, 0x6ba2, 0x080c, 0x6991,
-	0x000e, 0x0807, 0x2418, 0x080c, 0x8823, 0xbaa0, 0x0086, 0x2041,
-	0x0001, 0x2039, 0x0001, 0x2608, 0x080c, 0x863e, 0x008e, 0x080c,
-	0x8509, 0x2f08, 0x2648, 0x080c, 0xcfd9, 0xb93c, 0x81ff, 0x090c,
-	0x8715, 0x080c, 0x98d7, 0x012e, 0x007e, 0x009e, 0x0005, 0x00c6,
-	0x0126, 0x2091, 0x8000, 0x080c, 0x9b84, 0x0190, 0x660a, 0x2b08,
-	0x6112, 0x080c, 0xbcdb, 0x6023, 0x0001, 0x2900, 0x6016, 0x2009,
-	0x001f, 0x080c, 0x9c76, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005,
-	0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9c49,
-	0x01b8, 0x660a, 0x2b08, 0x6112, 0x080c, 0xbcdb, 0x6023, 0x0008,
-	0x2900, 0x6016, 0x00f6, 0x2c78, 0x080c, 0x165c, 0x00fe, 0x2009,
-	0x0021, 0x080c, 0x9c76, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005,
-	0x9006, 0x0cd8, 0x2009, 0x003d, 0x00c6, 0x0126, 0x0016, 0x2091,
-	0x8000, 0x080c, 0x9b84, 0x0198, 0x660a, 0x2b08, 0x6112, 0x080c,
-	0xbcdb, 0x6023, 0x0001, 0x2900, 0x6016, 0x001e, 0x0016, 0x080c,
-	0x9c76, 0x9085, 0x0001, 0x001e, 0x012e, 0x00ce, 0x0005, 0x9006,
-	0x0cd0, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9c49, 0x0188,
-	0x2b08, 0x6112, 0x080c, 0xbcdb, 0x6023, 0x0001, 0x2900, 0x6016,
-	0x2009, 0x0000, 0x080c, 0x9c76, 0x9085, 0x0001, 0x012e, 0x00ce,
-	0x0005, 0x9006, 0x0cd8, 0x2009, 0x0044, 0x0830, 0x2009, 0x0049,
-	0x0818, 0x0026, 0x00b6, 0x6210, 0x2258, 0xba3c, 0x82ff, 0x0118,
-	0x8211, 0xba3e, 0x1140, 0xb8c0, 0x9005, 0x0128, 0xb888, 0x9005,
-	0x1110, 0xb88b, 0x0001, 0x00be, 0x002e, 0x0005, 0x0006, 0x0016,
-	0x6004, 0x908e, 0x0002, 0x0140, 0x908e, 0x0003, 0x0128, 0x908e,
-	0x0004, 0x0110, 0x9085, 0x0001, 0x001e, 0x000e, 0x0005, 0x0006,
-	0x0086, 0x0096, 0x6020, 0x9086, 0x0004, 0x01a8, 0x6014, 0x904d,
-	0x080c, 0xb842, 0x0180, 0xa864, 0x9086, 0x0139, 0x0170, 0x6020,
-	0x90c6, 0x0003, 0x0140, 0x90c6, 0x0002, 0x0128, 0xa868, 0xd0fc,
-	0x0110, 0x9006, 0x0010, 0x9085, 0x0001, 0x009e, 0x008e, 0x000e,
-	0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9c49, 0x0198,
-	0x2b08, 0x6112, 0x080c, 0xbcdb, 0x6023, 0x0001, 0x2900, 0x6016,
-	0x080c, 0x300e, 0x2009, 0x0028, 0x080c, 0x9c76, 0x9085, 0x0001,
-	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x9186, 0x0015, 0x11a8,
-	0x2011, 0x1823, 0x2204, 0x9086, 0x0074, 0x1178, 0x00b6, 0x080c,
-	0xa80c, 0x00be, 0x080c, 0xaa4b, 0x6003, 0x0001, 0x6007, 0x0029,
-	0x080c, 0x84ba, 0x080c, 0x891b, 0x0078, 0x6014, 0x0096, 0x2048,
-	0xa868, 0x009e, 0xd0fc, 0x0148, 0x2001, 0x0001, 0x080c, 0xbe9a,
-	0x080c, 0xa581, 0x080c, 0x9bda, 0x0005, 0x0096, 0x6014, 0x904d,
-	0x090c, 0x0d65, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005,
-	0xa89b, 0x0004, 0xa867, 0x0139, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x6991, 0x012e, 0x009e, 0x080c, 0x9bda, 0x0c30, 0x0096, 0x9186,
-	0x0016, 0x1128, 0x2001, 0x0004, 0x080c, 0x61bc, 0x00e8, 0x9186,
-	0x0015, 0x1510, 0x2011, 0x1823, 0x2204, 0x9086, 0x0014, 0x11e0,
-	0x6010, 0x00b6, 0x2058, 0x080c, 0x6306, 0x00be, 0x080c, 0xab1c,
-	0x1198, 0x6010, 0x00b6, 0x2058, 0xb890, 0x00be, 0x9005, 0x0160,
-	0x2001, 0x0006, 0x080c, 0x61bc, 0x6014, 0x2048, 0xa868, 0xd0fc,
-	0x0170, 0x080c, 0x9fe8, 0x0048, 0x6014, 0x2048, 0xa868, 0xd0fc,
-	0x0528, 0x080c, 0xa581, 0x080c, 0x9bda, 0x009e, 0x0005, 0x6014,
-	0x6310, 0x2358, 0x904d, 0x090c, 0x0d65, 0xa87b, 0x0000, 0xa883,
-	0x0000, 0xa897, 0x4000, 0x900e, 0x080c, 0x655e, 0x1108, 0xc185,
-	0xb800, 0xd0bc, 0x0108, 0xc18d, 0xa99a, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x6991, 0x012e, 0x080c, 0x9bda, 0x08f8, 0x6014, 0x904d,
-	0x090c, 0x0d65, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005,
-	0xa89b, 0x0004, 0xa867, 0x0139, 0x0126, 0x2091, 0x8000, 0x080c,
-	0x6991, 0x012e, 0x080c, 0x9bda, 0x0840, 0xa878, 0x9086, 0x0005,
-	0x1108, 0x0009, 0x0005, 0xa880, 0xc0ad, 0xa882, 0x0005, 0x604b,
-	0x0000, 0x6017, 0x0000, 0x6003, 0x0001, 0x6007, 0x0050, 0x2009,
-	0x8023, 0x080c, 0x84b3, 0x0005, 0x00c6, 0x6010, 0x00b6, 0x2058,
-	0xb800, 0x00be, 0xd0bc, 0x0130, 0x0066, 0x6020, 0x9084, 0x000f,
-	0x001b, 0x006e, 0x00ce, 0x0005, 0xb553, 0xbb7e, 0xbb7e, 0xbb81,
-	0xd2d3, 0xd2ee, 0xd2f1, 0xb553, 0xb553, 0xb553, 0xb553, 0xb553,
-	0xb553, 0xb553, 0xb553, 0xb553, 0x080c, 0x0d65, 0xa001, 0xa001,
-	0x0005, 0x0096, 0x6014, 0x904d, 0x0118, 0xa87c, 0xd0e4, 0x1110,
-	0x009e, 0x0010, 0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800,
-	0x00be, 0xd0bc, 0x0550, 0x2001, 0x1833, 0x2004, 0x9005, 0x1540,
-	0x00f6, 0x2c78, 0x080c, 0x9b84, 0x0508, 0x7810, 0x6012, 0x080c,
-	0xbcdb, 0x7820, 0x9086, 0x0003, 0x0128, 0x7808, 0x603a, 0x2f00,
-	0x603e, 0x0020, 0x7808, 0x603e, 0x2f00, 0x603a, 0x602e, 0x6023,
-	0x0001, 0x6007, 0x0035, 0x6003, 0x0001, 0x795c, 0x615e, 0x2009,
-	0x8020, 0x080c, 0x84b3, 0x2f60, 0x00fe, 0x0005, 0x2f60, 0x00fe,
-	0x2001, 0x1958, 0x2004, 0x604a, 0x0005, 0x0016, 0x0096, 0x6814,
-	0x2048, 0x681c, 0xd0fc, 0xc0fc, 0x681e, 0xa87c, 0x1108, 0xd0e4,
-	0x0180, 0xc0e4, 0xa87e, 0xa877, 0x0000, 0xa893, 0x0000, 0xa88f,
-	0x0000, 0xd0cc, 0x0130, 0xc0cc, 0xa87e, 0xa878, 0x2048, 0x080c,
-	0x0fd4, 0x6830, 0x6036, 0x908e, 0x0001, 0x0148, 0x6803, 0x0002,
-	0x9086, 0x0005, 0x0170, 0x9006, 0x602e, 0x6032, 0x00d0, 0x681c,
-	0xc085, 0x681e, 0x6803, 0x0004, 0x6824, 0xc0f4, 0x9085, 0x0c00,
-	0x6826, 0x6814, 0x2048, 0xa8ac, 0x6938, 0x9102, 0xa8b0, 0x693c,
-	0x9103, 0x1e48, 0x683c, 0x602e, 0x6838, 0x9084, 0xfffc, 0x683a,
-	0x6032, 0x2d00, 0x603a, 0x6808, 0x603e, 0x6910, 0x6112, 0x695c,
-	0x615e, 0x6023, 0x0001, 0x6007, 0x0039, 0x6003, 0x0001, 0x2009,
-	0x8020, 0x080c, 0x84b3, 0x009e, 0x001e, 0x0005, 0x6024, 0xd0d4,
-	0x0510, 0xd0f4, 0x11f8, 0x6038, 0x940a, 0x603c, 0x9303, 0x0230,
-	0x9105, 0x0120, 0x6024, 0xc0d4, 0xc0f5, 0x0098, 0x643a, 0x633e,
-	0xac3e, 0xab42, 0x0046, 0x0036, 0x2400, 0xacac, 0x9402, 0xa836,
-	0x2300, 0xabb0, 0x9303, 0xa83a, 0x003e, 0x004e, 0x6024, 0xc0d4,
-	0x0000, 0x6026, 0x0005, 0xd0f4, 0x1138, 0xa83c, 0x603a, 0xa840,
-	0x603e, 0x6024, 0xc0f5, 0x6026, 0x0005, 0x0006, 0x0016, 0x6004,
-	0x908e, 0x0034, 0x01b8, 0x908e, 0x0035, 0x01a0, 0x908e, 0x0036,
-	0x0188, 0x908e, 0x0037, 0x0170, 0x908e, 0x0038, 0x0158, 0x908e,
-	0x0039, 0x0140, 0x908e, 0x003a, 0x0128, 0x908e, 0x003b, 0x0110,
-	0x9085, 0x0001, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x0026,
-	0x0036, 0x00e6, 0x2001, 0x1952, 0x200c, 0x8000, 0x2014, 0x2001,
-	0x0032, 0x080c, 0x83fb, 0x2001, 0x1956, 0x82ff, 0x1110, 0x2011,
-	0x0014, 0x2202, 0x2001, 0x1954, 0x200c, 0x8000, 0x2014, 0x2071,
-	0x193c, 0x711a, 0x721e, 0x2001, 0x0064, 0x080c, 0x83fb, 0x2001,
-	0x1957, 0x82ff, 0x1110, 0x2011, 0x0014, 0x2202, 0x2001, 0x1958,
-	0x9288, 0x000a, 0x2102, 0x2001, 0x0017, 0x080c, 0x98ac, 0x2001,
-	0x1a58, 0x2102, 0x2001, 0x0032, 0x080c, 0x15ab, 0x080c, 0x6647,
-	0x00ee, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016,
-	0x00e6, 0x2001, 0x1956, 0x2003, 0x0028, 0x2001, 0x1957, 0x2003,
-	0x0014, 0x2071, 0x193c, 0x701b, 0x0000, 0x701f, 0x07d0, 0x2001,
-	0x1958, 0x2009, 0x001e, 0x2102, 0x2001, 0x0017, 0x080c, 0x98ac,
-	0x2001, 0x1a58, 0x2102, 0x2001, 0x0032, 0x080c, 0x15ab, 0x00ee,
-	0x001e, 0x000e, 0x0005, 0x0096, 0x6060, 0x904d, 0x0110, 0x080c,
-	0x1054, 0x009e, 0x0005, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x9b84, 0x0180, 0x2b08, 0x6112, 0x0ca9, 0x6023, 0x0001,
-	0x2900, 0x6016, 0x2009, 0x0033, 0x080c, 0x9c76, 0x9085, 0x0001,
-	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x0096, 0x00e6, 0x00f6,
-	0x2071, 0x1800, 0x9186, 0x0015, 0x1500, 0x708c, 0x9086, 0x0018,
-	0x11e0, 0x6014, 0x2048, 0xaa3c, 0xd2e4, 0x1160, 0x2c78, 0x080c,
-	0x89da, 0x01d8, 0x7078, 0xaa50, 0x9206, 0x1160, 0x707c, 0xaa54,
-	0x9206, 0x1140, 0x6210, 0x00b6, 0x2258, 0xbaa0, 0x00be, 0x900e,
-	0x080c, 0x305d, 0x080c, 0x9fe8, 0x0020, 0x080c, 0xa581, 0x080c,
-	0x9bda, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x705c, 0xaa54, 0x9206,
-	0x0d48, 0x0c80, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9b84,
-	0x0188, 0x2b08, 0x6112, 0x080c, 0xbcdb, 0x6023, 0x0001, 0x2900,
-	0x6016, 0x2009, 0x004d, 0x080c, 0x9c76, 0x9085, 0x0001, 0x012e,
-	0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000,
-	0x0016, 0x080c, 0x9b84, 0x0180, 0x2b08, 0x6112, 0x080c, 0xbcdb,
-	0x6023, 0x0001, 0x2900, 0x6016, 0x001e, 0x080c, 0x9c76, 0x9085,
-	0x0001, 0x012e, 0x00ce, 0x0005, 0x001e, 0x9006, 0x0cd0, 0x0016,
-	0x0026, 0x0036, 0x0046, 0x0056, 0x0066, 0x0096, 0x00e6, 0x00f6,
-	0x2071, 0x1800, 0x9186, 0x0015, 0x1568, 0x718c, 0x6014, 0x2048,
-	0xa814, 0x8003, 0x9106, 0x1530, 0x20e1, 0x0000, 0x2001, 0x1970,
-	0x2003, 0x0000, 0x6014, 0x2048, 0xa830, 0x20a8, 0x8906, 0x8006,
-	0x8007, 0x9094, 0x003f, 0x22e8, 0x9084, 0xffc0, 0x9080, 0x001b,
-	0x20a0, 0x2001, 0x1970, 0x0016, 0x200c, 0x080c, 0xc553, 0x001e,
-	0xa804, 0x9005, 0x0110, 0x2048, 0x0c38, 0x6014, 0x2048, 0xa867,
-	0x0103, 0x0010, 0x080c, 0xa581, 0x080c, 0x9bda, 0x00fe, 0x00ee,
-	0x009e, 0x006e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005,
-	0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x11b8,
-	0x708c, 0x9086, 0x0004, 0x1198, 0x6014, 0x2048, 0x2c78, 0x080c,
-	0x89da, 0x01a8, 0x7078, 0xaa74, 0x9206, 0x1130, 0x707c, 0xaa78,
-	0x9206, 0x1110, 0x080c, 0x300e, 0x080c, 0x9fe8, 0x0020, 0x080c,
-	0xa581, 0x080c, 0x9bda, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x705c,
-	0xaa78, 0x9206, 0x0d78, 0x0c80, 0x0096, 0x00e6, 0x00f6, 0x2071,
-	0x1800, 0x9186, 0x0015, 0x1550, 0x708c, 0x9086, 0x0004, 0x1530,
-	0x6014, 0x2048, 0x2c78, 0x080c, 0x89da, 0x05f0, 0x7078, 0xaacc,
-	0x9206, 0x1180, 0x707c, 0xaad0, 0x9206, 0x1160, 0x080c, 0x300e,
-	0x0016, 0xa998, 0xaab0, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x5340,
-	0x001e, 0x0010, 0x080c, 0x5129, 0x080c, 0xb842, 0x0508, 0xa87b,
-	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x0080, 0x080c, 0xb842,
-	0x01b8, 0x6014, 0x2048, 0x080c, 0x5129, 0x1d70, 0xa87b, 0x0030,
-	0xa883, 0x0000, 0xa897, 0x4005, 0xa89b, 0x0004, 0x0126, 0x2091,
-	0x8000, 0xa867, 0x0139, 0x080c, 0x6991, 0x012e, 0x080c, 0x9bda,
-	0x00fe, 0x00ee, 0x009e, 0x0005, 0x705c, 0xaad0, 0x9206, 0x0930,
-	0x0888, 0x0016, 0x0026, 0xa87c, 0xd0ac, 0x0178, 0xa938, 0xaa34,
-	0x2100, 0x9205, 0x0150, 0xa890, 0x9106, 0x1118, 0xa88c, 0x9206,
-	0x0120, 0xa992, 0xaa8e, 0x9085, 0x0001, 0x002e, 0x001e, 0x0005,
-	0x00b6, 0x00d6, 0x0036, 0x080c, 0xb842, 0x0904, 0xbe96, 0x0096,
-	0x6314, 0x2348, 0xa87a, 0xa982, 0x929e, 0x4000, 0x1580, 0x6310,
-	0x00c6, 0x2358, 0x2009, 0x0000, 0xa868, 0xd0f4, 0x1140, 0x080c,
-	0x655e, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0xaa96,
-	0xa99a, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031,
-	0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098, 0x080c,
-	0x0f9f, 0x20a9, 0x0004, 0xa85c, 0x9080, 0x0035, 0x20a0, 0xb8b8,
-	0x9080, 0x000a, 0x2098, 0x080c, 0x0f9f, 0x00ce, 0x0090, 0xaa96,
-	0x3918, 0x9398, 0x0007, 0x231c, 0x6004, 0x9086, 0x0016, 0x0110,
-	0xa89b, 0x0004, 0xaba2, 0x6310, 0x2358, 0xb804, 0x9084, 0x00ff,
-	0xa89e, 0x080c, 0x6985, 0x6017, 0x0000, 0x009e, 0x003e, 0x00de,
-	0x00be, 0x0005, 0x0026, 0x0036, 0x0046, 0x00b6, 0x0096, 0x00f6,
-	0x6214, 0x2248, 0x6210, 0x2258, 0x2079, 0x0260, 0x9096, 0x0000,
-	0x11a0, 0xb814, 0x9084, 0x00ff, 0x900e, 0x080c, 0x243d, 0x2118,
-	0x831f, 0x939c, 0xff00, 0x7838, 0x9084, 0x00ff, 0x931d, 0x7c3c,
-	0x2011, 0x8018, 0x080c, 0x48da, 0x00a8, 0x9096, 0x0001, 0x1148,
-	0x89ff, 0x0180, 0xa89b, 0x000d, 0x7838, 0xa8a6, 0x783c, 0xa8aa,
-	0x0048, 0x9096, 0x0002, 0x1130, 0xa89b, 0x000d, 0x7838, 0xa8a6,
-	0x783c, 0xa8aa, 0x00fe, 0x009e, 0x00be, 0x004e, 0x003e, 0x002e,
-	0x0005, 0x00c6, 0x0026, 0x0016, 0x9186, 0x0035, 0x0110, 0x6a38,
-	0x0008, 0x6a2c, 0x080c, 0xb830, 0x01f0, 0x2260, 0x6120, 0x9186,
-	0x0003, 0x0118, 0x9186, 0x0006, 0x1190, 0x6838, 0x9206, 0x0140,
-	0x683c, 0x9206, 0x1160, 0x6108, 0x6838, 0x9106, 0x1140, 0x0020,
-	0x6008, 0x693c, 0x9106, 0x1118, 0x6010, 0x6910, 0x9106, 0x001e,
-	0x002e, 0x00ce, 0x0005, 0x9085, 0x0001, 0x0cc8, 0xa974, 0xd1cc,
-	0x0188, 0x918c, 0x00ff, 0x918e, 0x0002, 0x1160, 0xa9a8, 0x918c,
-	0x0f00, 0x810f, 0x918e, 0x0001, 0x1128, 0xa834, 0xa938, 0x9115,
-	0x190c, 0xaeb6, 0x0005, 0x0036, 0x2019, 0x0001, 0x0010, 0x0036,
-	0x901e, 0x0499, 0x01e0, 0x080c, 0xb842, 0x01c8, 0x080c, 0xba31,
-	0x6037, 0x4000, 0x6014, 0x6017, 0x0000, 0x0096, 0x2048, 0xa87c,
-	0x080c, 0xba57, 0x1118, 0x080c, 0xa581, 0x0040, 0xa867, 0x0103,
-	0xa877, 0x0000, 0x83ff, 0x1129, 0x080c, 0x6991, 0x009e, 0x003e,
-	0x0005, 0xa880, 0xd0b4, 0x0128, 0xa87b, 0x0006, 0xc0ec, 0xa882,
+	0xaed1, 0x080c, 0x67cb, 0x6210, 0x2258, 0xba3c, 0x82ff, 0x0110,
+	0x8211, 0xba3e, 0xb8c0, 0x9005, 0x0110, 0x080c, 0x63ba, 0x080c,
+	0x9be6, 0x009e, 0x00be, 0x0005, 0xa87c, 0xd0ac, 0x09e0, 0xa838,
+	0xa934, 0x9105, 0x09c0, 0xa880, 0xd0bc, 0x19a8, 0x080c, 0xbbba,
+	0x0c80, 0x00b6, 0x0096, 0x6114, 0x2148, 0x601c, 0xd0fc, 0x1110,
+	0x7644, 0x0008, 0x9036, 0x96b4, 0x0fff, 0x86ff, 0x1590, 0x6010,
+	0x2058, 0xb800, 0xd0bc, 0x1904, 0xae2f, 0xa87b, 0x0000, 0xa867,
+	0x0103, 0xae76, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115,
+	0x190c, 0xaed1, 0x080c, 0x67cb, 0x6210, 0x2258, 0xba3c, 0x82ff,
+	0x0110, 0x8211, 0xba3e, 0xb8c0, 0x9005, 0x0110, 0x080c, 0x63ba,
+	0x601c, 0xd0fc, 0x1148, 0x7044, 0xd0e4, 0x1904, 0xae13, 0x080c,
+	0x9be6, 0x009e, 0x00be, 0x0005, 0x2009, 0x0211, 0x210c, 0x080c,
+	0x0d65, 0x968c, 0x0c00, 0x0150, 0x6010, 0x2058, 0xb800, 0xd0bc,
+	0x1904, 0xae17, 0x7348, 0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff,
+	0x9186, 0x0002, 0x0508, 0x9186, 0x0028, 0x1118, 0xa87b, 0x001c,
+	0x00e8, 0xd6dc, 0x01a0, 0xa87b, 0x0015, 0xa87c, 0xd0ac, 0x0170,
+	0xa938, 0xaa34, 0x2100, 0x9205, 0x0148, 0x7048, 0x9106, 0x1118,
+	0x704c, 0x9206, 0x0118, 0xa992, 0xaa8e, 0xc6dc, 0x0038, 0xd6d4,
+	0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000, 0xa867, 0x0103,
+	0xae76, 0x901e, 0xd6c4, 0x01d8, 0x9686, 0x0100, 0x1130, 0x7064,
+	0x9005, 0x1118, 0xc6c4, 0x0804, 0xad5d, 0x735c, 0xab86, 0x83ff,
+	0x0170, 0x938a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308,
+	0x2019, 0x0018, 0x2011, 0x0025, 0x080c, 0xb426, 0x003e, 0xd6cc,
+	0x0904, 0xad72, 0x7154, 0xa98a, 0x81ff, 0x0904, 0xad72, 0x9192,
+	0x0021, 0x1278, 0x8304, 0x9098, 0x0018, 0x2011, 0x0029, 0x080c,
+	0xb426, 0x2011, 0x0205, 0x2013, 0x0000, 0x080c, 0xbf34, 0x0804,
+	0xad72, 0xa868, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c50,
+	0x00a6, 0x2950, 0x080c, 0xb3c5, 0x00ae, 0x080c, 0xbf34, 0x080c,
+	0xb416, 0x0804, 0xad74, 0x080c, 0xbb7d, 0x0804, 0xad89, 0xa87c,
+	0xd0ac, 0x0904, 0xad9a, 0xa880, 0xd0bc, 0x1904, 0xad9a, 0x7348,
+	0xa838, 0x9306, 0x11c8, 0x734c, 0xa834, 0x931e, 0x0904, 0xad9a,
+	0xd6d4, 0x0190, 0xab38, 0x9305, 0x0904, 0xad9a, 0x0068, 0xa87c,
+	0xd0ac, 0x0904, 0xad65, 0xa838, 0xa934, 0x9105, 0x0904, 0xad65,
+	0xa880, 0xd0bc, 0x1904, 0xad65, 0x080c, 0xbbba, 0x0804, 0xad89,
+	0x00f6, 0x2079, 0x026c, 0x7c04, 0x7b00, 0x7e0c, 0x7d08, 0x00fe,
+	0x0021, 0x0005, 0x0011, 0x0005, 0x0005, 0x0096, 0x6003, 0x0002,
+	0x6007, 0x0043, 0x6014, 0x2048, 0xa87c, 0xd0ac, 0x0128, 0x009e,
+	0x0005, 0x2130, 0x2228, 0x0058, 0x2400, 0xa9ac, 0x910a, 0x2300,
+	0xaab0, 0x9213, 0x2600, 0x9102, 0x2500, 0x9203, 0x0e90, 0xac46,
+	0xab4a, 0xae36, 0xad3a, 0x6044, 0xd0fc, 0x190c, 0x98f0, 0x604b,
+	0x0000, 0x080c, 0x1af7, 0x1118, 0x6144, 0x080c, 0x8513, 0x009e,
+	0x0005, 0x9182, 0x0057, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a,
+	0x0005, 0xae98, 0xae98, 0xae98, 0xae98, 0xae98, 0xae98, 0xae98,
+	0xae98, 0xae98, 0xae98, 0xae9a, 0xae98, 0xae98, 0xae98, 0xae98,
+	0xaeab, 0xae98, 0xae98, 0xae98, 0xae98, 0xaecf, 0xae98, 0xae98,
+	0x080c, 0x0d65, 0x6004, 0x9086, 0x0040, 0x1110, 0x080c, 0x8891,
+	0x2019, 0x0001, 0x080c, 0x929d, 0x6003, 0x0002, 0x080c, 0xbfac,
+	0x080c, 0x88ec, 0x0005, 0x6004, 0x9086, 0x0040, 0x1110, 0x080c,
+	0x8891, 0x2019, 0x0001, 0x080c, 0x929d, 0x080c, 0x88ec, 0x080c,
+	0x302e, 0x080c, 0xbfa4, 0x0096, 0x6114, 0x2148, 0x080c, 0xb870,
+	0x0150, 0xa867, 0x0103, 0xa87b, 0x0029, 0xa877, 0x0000, 0x080c,
+	0x69b5, 0x080c, 0xba5f, 0x009e, 0x080c, 0x9be6, 0x0005, 0x080c,
+	0x0d65, 0xa87b, 0x0015, 0xd1fc, 0x0180, 0xa87b, 0x0007, 0x8002,
+	0x8000, 0x810a, 0x9189, 0x0000, 0x0006, 0x0016, 0x2009, 0x1a4f,
+	0x2104, 0x8000, 0x200a, 0x001e, 0x000e, 0xa992, 0xa88e, 0x0005,
+	0x9182, 0x0057, 0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005,
+	0xaf07, 0xaf07, 0xaf07, 0xaf07, 0xaf07, 0xaf09, 0xaf07, 0xaf07,
+	0xafc6, 0xaf07, 0xaf07, 0xaf07, 0xaf07, 0xaf07, 0xaf07, 0xaf07,
+	0xaf07, 0xaf07, 0xaf07, 0xb104, 0xaf07, 0xb10e, 0xaf07, 0x080c,
+	0x0d65, 0x601c, 0xd0bc, 0x0178, 0xd084, 0x0168, 0xd0f4, 0x0120,
+	0xc084, 0x601e, 0x0804, 0xacf9, 0x6114, 0x0096, 0x2148, 0xa87c,
+	0xc0e5, 0xa87e, 0x009e, 0x0076, 0x00a6, 0x00e6, 0x0096, 0x2071,
+	0x0260, 0x6114, 0x2150, 0x601c, 0xd0fc, 0x1110, 0x7644, 0x0008,
+	0x9036, 0xb676, 0x96b4, 0x0fff, 0xb77c, 0xc7e5, 0xb77e, 0x6210,
+	0x00b6, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be,
+	0x86ff, 0x0904, 0xafbf, 0x9694, 0xff00, 0x9284, 0x0c00, 0x0120,
+	0x7048, 0xb092, 0x704c, 0xb08e, 0x9284, 0x0300, 0x0904, 0xafbf,
+	0x9686, 0x0100, 0x1130, 0x7064, 0x9005, 0x1118, 0xc6c4, 0xb676,
+	0x0c38, 0x080c, 0x102f, 0x090c, 0x0d65, 0x2900, 0xb07a, 0xb77c,
+	0x97bd, 0x0200, 0xb77e, 0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c,
+	0xa86e, 0xb070, 0xa872, 0x7044, 0x9084, 0xf000, 0x9635, 0xae76,
+	0x968c, 0x0c00, 0x0120, 0x7348, 0xab92, 0x734c, 0xab8e, 0x968c,
+	0x00ff, 0x9186, 0x0002, 0x0180, 0x9186, 0x0028, 0x1118, 0xa87b,
+	0x001c, 0x0060, 0xd6dc, 0x0118, 0xa87b, 0x0015, 0x0038, 0xd6d4,
+	0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000, 0xaf7e, 0xb080,
+	0xa882, 0xb084, 0xa886, 0x901e, 0xd6c4, 0x0190, 0x735c, 0xab86,
+	0x83ff, 0x0170, 0x938a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036,
+	0x2308, 0x2019, 0x0018, 0x2011, 0x0025, 0x080c, 0xb426, 0x003e,
+	0xd6cc, 0x01e8, 0x7154, 0xa98a, 0x81ff, 0x01c8, 0x9192, 0x0021,
+	0x1260, 0x8304, 0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xb426,
+	0x2011, 0x0205, 0x2013, 0x0000, 0x0050, 0xb068, 0xd0fc, 0x0120,
+	0x2009, 0x0020, 0xa98a, 0x0c68, 0x2950, 0x080c, 0xb3c5, 0x080c,
+	0x190c, 0x009e, 0x00ee, 0x00ae, 0x007e, 0x0005, 0x2001, 0x1960,
+	0x2004, 0x604a, 0x0096, 0x6114, 0x2148, 0xa83c, 0xa940, 0x9105,
+	0x1118, 0xa87c, 0xc0dc, 0xa87e, 0x6003, 0x0002, 0x080c, 0xbfb5,
+	0x0904, 0xb0ff, 0x604b, 0x0000, 0x6010, 0x00b6, 0x2058, 0xb800,
+	0x00be, 0xd0bc, 0x1500, 0xd1cc, 0x0904, 0xb0c4, 0xa978, 0xa868,
+	0xd0fc, 0x0904, 0xb085, 0x0016, 0xa87c, 0x0006, 0xa880, 0x0006,
+	0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x0904,
+	0xb053, 0x9086, 0x0028, 0x1904, 0xb03f, 0xa87b, 0x001c, 0xb07b,
+	0x001c, 0x0804, 0xb05b, 0x6024, 0xd0f4, 0x11d0, 0xa838, 0xaa34,
+	0x9205, 0x09c8, 0xa838, 0xaa90, 0x9206, 0x1120, 0xa88c, 0xaa34,
+	0x9206, 0x0988, 0x6024, 0xd0d4, 0x1148, 0xa9ac, 0xa834, 0x9102,
+	0x603a, 0xa9b0, 0xa838, 0x9103, 0x603e, 0x6024, 0xc0f5, 0x6026,
+	0x6010, 0x00b6, 0x2058, 0xb83c, 0x8000, 0xb83e, 0x00be, 0x601c,
+	0xc0fc, 0x601e, 0x9006, 0xa876, 0xa892, 0xa88e, 0xa87c, 0xc0e4,
+	0xa87e, 0xd0cc, 0x0140, 0xc0cc, 0xa87e, 0x0096, 0xa878, 0x2048,
+	0x080c, 0x0fe1, 0x009e, 0x080c, 0xbbba, 0x0804, 0xb0ff, 0xd1dc,
+	0x0158, 0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c, 0xbe57, 0x0118,
+	0xb174, 0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007,
+	0xb07b, 0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938,
+	0x9115, 0x190c, 0xaed1, 0xa87c, 0xb07e, 0xa890, 0xb092, 0xa88c,
+	0xb08e, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0019, 0x20a0, 0x20a9,
+	0x0020, 0x8a06, 0x8006, 0x8007, 0x9094, 0x003f, 0x22e0, 0x9084,
+	0xffc0, 0x9080, 0x0019, 0x2098, 0x4003, 0x00ae, 0x000e, 0xa882,
+	0x000e, 0xa87e, 0x080c, 0xbf34, 0x001e, 0xa874, 0x0006, 0x2148,
+	0x080c, 0x0fe1, 0x001e, 0x0804, 0xb0f1, 0x0016, 0x00a6, 0x2150,
+	0xb174, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x01e0, 0x9086, 0x0028,
+	0x1128, 0xa87b, 0x001c, 0xb07b, 0x001c, 0x00e0, 0xd1dc, 0x0158,
+	0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c, 0xbe57, 0x0118, 0xb174,
+	0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b,
+	0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115,
+	0x190c, 0xaed1, 0xa890, 0xb092, 0xa88c, 0xb08e, 0xa87c, 0xb07e,
+	0x00ae, 0x080c, 0x0fe1, 0x009e, 0x080c, 0xbf34, 0xa974, 0x0016,
+	0x080c, 0xb416, 0x001e, 0x0468, 0xa867, 0x0103, 0xa974, 0x9184,
+	0x00ff, 0x90b6, 0x0002, 0x01b0, 0x9086, 0x0028, 0x1118, 0xa87b,
+	0x001c, 0x00d0, 0xd1dc, 0x0148, 0xa87b, 0x0015, 0x080c, 0xbe57,
+	0x0118, 0xa974, 0xc1dc, 0xa976, 0x0078, 0xd1d4, 0x0118, 0xa87b,
+	0x0007, 0x0050, 0xa87b, 0x0000, 0xa87c, 0xd0ac, 0x0128, 0xa834,
+	0xa938, 0x9115, 0x190c, 0xaed1, 0xa974, 0x0016, 0x080c, 0x67cb,
+	0x001e, 0x6010, 0x00b6, 0x2058, 0xb8c0, 0x0016, 0x9005, 0x190c,
+	0x63ba, 0x001e, 0x00be, 0xd1e4, 0x1120, 0x080c, 0x9be6, 0x009e,
+	0x0005, 0x080c, 0xbb7d, 0x0cd8, 0x6114, 0x0096, 0x2148, 0xa97c,
+	0x080c, 0xbfb5, 0x190c, 0x192a, 0x009e, 0x0005, 0x0096, 0x6114,
+	0x2148, 0xa83c, 0xa940, 0x9105, 0x01e8, 0xa877, 0x0000, 0xa87b,
+	0x0000, 0xa867, 0x0103, 0x00b6, 0x6010, 0x2058, 0xa834, 0xa938,
+	0x9115, 0x11a0, 0x080c, 0x67cb, 0xba3c, 0x8211, 0x0208, 0xba3e,
+	0xb8c0, 0x9005, 0x0110, 0x080c, 0x63ba, 0x080c, 0x9be6, 0x00be,
+	0x009e, 0x0005, 0xa87c, 0xc0dc, 0xa87e, 0x08f8, 0xb800, 0xd0bc,
+	0x1120, 0xa834, 0x080c, 0xaed1, 0x0c28, 0xa880, 0xd0bc, 0x1dc8,
+	0x080c, 0xbbba, 0x0c60, 0x080c, 0x8891, 0x0010, 0x080c, 0x88ec,
+	0x601c, 0xd084, 0x0110, 0x080c, 0x193e, 0x080c, 0xb870, 0x01f0,
+	0x0096, 0x6114, 0x2148, 0x080c, 0xba85, 0x1118, 0x080c, 0xa59c,
+	0x00a0, 0xa867, 0x0103, 0x2009, 0x180c, 0x210c, 0xd18c, 0x1198,
+	0xd184, 0x1170, 0x6108, 0xa97a, 0x918e, 0x0029, 0x1110, 0x080c,
+	0xd563, 0xa877, 0x0000, 0x080c, 0x69b5, 0x009e, 0x0804, 0x9c20,
+	0xa87b, 0x0004, 0x0cb0, 0xa87b, 0x0004, 0x0c98, 0x9182, 0x0057,
+	0x1220, 0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xb195, 0xb195,
+	0xb195, 0xb195, 0xb195, 0xb197, 0xb195, 0xb195, 0xb195, 0xb195,
+	0xb195, 0xb195, 0xb195, 0xb195, 0xb195, 0xb195, 0xb195, 0xb195,
+	0xb195, 0xb195, 0xb1bb, 0xb195, 0xb195, 0x080c, 0x0d65, 0x080c,
+	0x53b0, 0x01f8, 0x6014, 0x7144, 0x918c, 0x0fff, 0x9016, 0xd1c4,
+	0x0118, 0x7264, 0x9294, 0x00ff, 0x0096, 0x904d, 0x0188, 0xa87b,
+	0x0000, 0xa864, 0x9086, 0x0139, 0x0128, 0xa867, 0x0103, 0xa976,
+	0xaa96, 0x0030, 0xa897, 0x4000, 0xa99a, 0xaa9e, 0x080c, 0x69b5,
+	0x009e, 0x0804, 0x9be6, 0x080c, 0x53b0, 0x0dd8, 0x6014, 0x900e,
+	0x9016, 0x0c10, 0x9182, 0x0085, 0x0002, 0xb1d4, 0xb1d2, 0xb1d2,
+	0xb1e0, 0xb1d2, 0xb1d2, 0xb1d2, 0xb1d2, 0xb1d2, 0xb1d2, 0xb1d2,
+	0xb1d2, 0xb1d2, 0x080c, 0x0d65, 0x6003, 0x0001, 0x6106, 0x0126,
+	0x2091, 0x8000, 0x2009, 0x8020, 0x080c, 0x84e7, 0x012e, 0x0005,
+	0x0026, 0x0056, 0x00d6, 0x00e6, 0x2071, 0x0260, 0x7224, 0x6216,
+	0x7220, 0x080c, 0xb85e, 0x01a0, 0x2268, 0x6800, 0x9086, 0x0000,
+	0x0178, 0x6010, 0x6d10, 0x952e, 0x1158, 0x00c6, 0x2d60, 0x080c,
+	0xb451, 0x00ce, 0x0128, 0x6803, 0x0002, 0x6007, 0x0086, 0x0010,
+	0x6007, 0x0087, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84e7,
+	0x7220, 0x080c, 0xb85e, 0x0178, 0x6810, 0x00b6, 0x2058, 0xb800,
+	0x00be, 0xd0bc, 0x0140, 0x6824, 0xd0ec, 0x0128, 0x00c6, 0x2d60,
+	0x080c, 0xbbba, 0x00ce, 0x00ee, 0x00de, 0x005e, 0x002e, 0x0005,
+	0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0d65,
+	0x908a, 0x0092, 0x1a0c, 0x0d65, 0x9082, 0x0085, 0x00e2, 0x9186,
+	0x0027, 0x0120, 0x9186, 0x0014, 0x190c, 0x0d65, 0x080c, 0x8891,
+	0x0096, 0x6014, 0x2048, 0x080c, 0xb870, 0x0140, 0xa867, 0x0103,
+	0xa877, 0x0000, 0xa87b, 0x0029, 0x080c, 0x69b5, 0x009e, 0x080c,
+	0x9c20, 0x0804, 0x894f, 0xb258, 0xb25a, 0xb25a, 0xb258, 0xb258,
+	0xb258, 0xb258, 0xb258, 0xb258, 0xb258, 0xb258, 0xb258, 0xb258,
+	0x080c, 0x0d65, 0x080c, 0x9c20, 0x0005, 0x9186, 0x0013, 0x1130,
+	0x6004, 0x9082, 0x0085, 0x2008, 0x0804, 0xb2a9, 0x9186, 0x0027,
+	0x1558, 0x080c, 0x8891, 0x080c, 0x302e, 0x080c, 0xbfa4, 0x0096,
+	0x6014, 0x2048, 0x080c, 0xb870, 0x0150, 0xa867, 0x0103, 0xa877,
+	0x0000, 0xa87b, 0x0029, 0x080c, 0x69b5, 0x080c, 0xba5f, 0x009e,
+	0x080c, 0x9be6, 0x0005, 0x9186, 0x0089, 0x0118, 0x9186, 0x008a,
+	0x1140, 0x080c, 0x9ab6, 0x0128, 0x9086, 0x000c, 0x0904, 0xb2e1,
+	0x0000, 0x080c, 0x9c9f, 0x0c70, 0x9186, 0x0014, 0x1d60, 0x080c,
+	0x8891, 0x0096, 0x6014, 0x2048, 0x080c, 0xb870, 0x0d00, 0xa867,
+	0x0103, 0xa877, 0x0000, 0xa87b, 0x0006, 0xa880, 0xc0ec, 0xa882,
+	0x0890, 0x0002, 0xb2b9, 0xb2b7, 0xb2b7, 0xb2b7, 0xb2b7, 0xb2b7,
+	0xb2cd, 0xb2b7, 0xb2b7, 0xb2b7, 0xb2b7, 0xb2b7, 0xb2b7, 0x080c,
+	0x0d65, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118,
+	0x9186, 0x0035, 0x1118, 0x2001, 0x195e, 0x0010, 0x2001, 0x195f,
+	0x2004, 0x601a, 0x6003, 0x000c, 0x0005, 0x6034, 0x908c, 0xff00,
+	0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x2001,
+	0x195e, 0x0010, 0x2001, 0x195f, 0x2004, 0x601a, 0x6003, 0x000e,
+	0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085, 0x0208, 0x0012,
+	0x0804, 0x9c9f, 0xb2f7, 0xb2f7, 0xb2f7, 0xb2f7, 0xb2f9, 0xb346,
+	0xb2f7, 0xb2f7, 0xb2f7, 0xb2f7, 0xb2f7, 0xb2f7, 0xb2f7, 0x080c,
+	0x0d65, 0x0096, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
+	0x0168, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0039, 0x0118,
+	0x9186, 0x0035, 0x1118, 0x009e, 0x0804, 0xb35a, 0x080c, 0xb870,
+	0x1118, 0x080c, 0xba5f, 0x0068, 0x6014, 0x2048, 0x080c, 0xbfbb,
+	0x1110, 0x080c, 0xba5f, 0xa867, 0x0103, 0x080c, 0xbf6f, 0x080c,
+	0x69b5, 0x00d6, 0x2c68, 0x080c, 0x9b90, 0x01d0, 0x6003, 0x0001,
+	0x6007, 0x001e, 0x600b, 0xffff, 0x2009, 0x026e, 0x210c, 0x613a,
+	0x2009, 0x026f, 0x210c, 0x613e, 0x6910, 0x6112, 0x080c, 0xbd09,
+	0x695c, 0x615e, 0x6023, 0x0001, 0x2009, 0x8020, 0x080c, 0x84e7,
+	0x2d60, 0x00de, 0x080c, 0x9be6, 0x009e, 0x0005, 0x6010, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x05a0, 0x6034, 0x908c, 0xff00,
+	0x810f, 0x9186, 0x0035, 0x0130, 0x9186, 0x001e, 0x0118, 0x9186,
+	0x0039, 0x1538, 0x00d6, 0x2c68, 0x080c, 0xbf07, 0x11f0, 0x080c,
+	0x9b90, 0x01d8, 0x6106, 0x6003, 0x0001, 0x6023, 0x0001, 0x6910,
+	0x6112, 0x692c, 0x612e, 0x6930, 0x6132, 0x6934, 0x918c, 0x00ff,
+	0x6136, 0x6938, 0x613a, 0x693c, 0x613e, 0x695c, 0x615e, 0x080c,
+	0xbd09, 0x2009, 0x8020, 0x080c, 0x84e7, 0x2d60, 0x00de, 0x0804,
+	0x9be6, 0x0096, 0x6014, 0x2048, 0x080c, 0xb870, 0x01c8, 0xa867,
+	0x0103, 0xa880, 0xd0b4, 0x0128, 0xc0ec, 0xa882, 0xa87b, 0x0006,
 	0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002, 0x0020, 0xa87b, 0x0005,
-	0x080c, 0xbb4b, 0xa877, 0x0000, 0x0005, 0x2001, 0x1810, 0x2004,
-	0xd0ec, 0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0f4, 0x000e,
-	0x0005, 0x0006, 0x2001, 0x1810, 0x2004, 0xd0e4, 0x000e, 0x0005,
-	0x0036, 0x0046, 0x6010, 0x00b6, 0x2058, 0xbba0, 0x00be, 0x2021,
-	0x0007, 0x080c, 0x4a77, 0x004e, 0x003e, 0x0005, 0x0c51, 0x1d81,
-	0x0005, 0x2001, 0x1956, 0x2004, 0x601a, 0x0005, 0x2001, 0x1958,
-	0x2004, 0x604a, 0x0005, 0x080c, 0x9bda, 0x0804, 0x891b, 0x611c,
-	0xd1fc, 0xa97c, 0x1108, 0xd1e4, 0x0005, 0x601c, 0xd0fc, 0xa87c,
-	0x1108, 0xd0e4, 0x0005, 0x601c, 0xd0fc, 0xc0fc, 0x601e, 0xa87c,
-	0x1108, 0xd0e4, 0x0005, 0x6044, 0xd0fc, 0x1138, 0xd0bc, 0x0198,
-	0xc0bc, 0x6046, 0x6003, 0x0002, 0x0070, 0xd0ac, 0x1160, 0xd0dc,
-	0x1128, 0x908c, 0x000f, 0x9186, 0x0005, 0x1118, 0x6003, 0x0003,
-	0x0010, 0x6003, 0x0001, 0x0005, 0x00b6, 0x0066, 0x6000, 0x90b2,
-	0x0016, 0x1a0c, 0x0d65, 0x001b, 0x006e, 0x00be, 0x0005, 0xbfcf,
-	0xc6ae, 0xc7fd, 0xbfcf, 0xbfcf, 0xbfcf, 0xbfcf, 0xbfcf, 0xc006,
-	0xc881, 0xbfcf, 0xbfcf, 0xbfcf, 0xbfcf, 0xbfcf, 0xbfcf, 0x080c,
-	0x0d65, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0d65, 0x0013,
-	0x006e, 0x0005, 0xbfea, 0xcd98, 0xbfea, 0xbfea, 0xbfea, 0xbfea,
-	0xbfea, 0xbfea, 0xcd47, 0xcdea, 0xbfea, 0xd40e, 0xd442, 0xd40e,
-	0xd442, 0xbfea, 0x080c, 0x0d65, 0x6000, 0x9082, 0x0016, 0x1a0c,
-	0x0d65, 0x6000, 0x000a, 0x0005, 0xc004, 0xca5d, 0xcb26, 0xcb48,
-	0xcbc3, 0xc004, 0xccbd, 0xcc4b, 0xc88b, 0xcd1f, 0xcd34, 0xc004,
-	0xc004, 0xc004, 0xc004, 0xc004, 0x080c, 0x0d65, 0x91b2, 0x0053,
-	0x1a0c, 0x0d65, 0x2100, 0x91b2, 0x0040, 0x1a04, 0xc451, 0x0002,
-	0xc050, 0xc242, 0xc050, 0xc050, 0xc050, 0xc24b, 0xc050, 0xc050,
-	0xc050, 0xc050, 0xc050, 0xc050, 0xc050, 0xc050, 0xc050, 0xc050,
-	0xc050, 0xc050, 0xc050, 0xc050, 0xc050, 0xc050, 0xc050, 0xc052,
-	0xc0b9, 0xc0c8, 0xc12c, 0xc157, 0xc1cf, 0xc22d, 0xc050, 0xc050,
-	0xc24e, 0xc050, 0xc050, 0xc263, 0xc270, 0xc050, 0xc050, 0xc050,
-	0xc050, 0xc050, 0xc2f3, 0xc050, 0xc050, 0xc307, 0xc050, 0xc050,
-	0xc2c2, 0xc050, 0xc050, 0xc050, 0xc31f, 0xc050, 0xc050, 0xc050,
-	0xc39c, 0xc050, 0xc050, 0xc050, 0xc050, 0xc050, 0xc050, 0xc419,
-	0x080c, 0x0d65, 0x080c, 0x6624, 0x1150, 0x2001, 0x1836, 0x2004,
-	0xd0cc, 0x1128, 0x9084, 0x0009, 0x9086, 0x0008, 0x1140, 0x6007,
-	0x0009, 0x602f, 0x0009, 0x6017, 0x0000, 0x0804, 0xc23b, 0x080c,
-	0x660d, 0x00e6, 0x00c6, 0x0036, 0x0026, 0x0016, 0x6210, 0x2258,
-	0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c, 0x98bb, 0x080c, 0x8624,
-	0x0076, 0x903e, 0x080c, 0x8509, 0x2c08, 0x080c, 0xcfd9, 0x007e,
-	0x001e, 0x080c, 0x98d7, 0x001e, 0x002e, 0x003e, 0x00ce, 0x00ee,
-	0x6610, 0x2658, 0x080c, 0x627a, 0xbe04, 0x9684, 0x00ff, 0x9082,
-	0x0006, 0x1268, 0x0016, 0x0026, 0x6210, 0x00b6, 0x2258, 0xbaa0,
-	0x00be, 0x2c08, 0x080c, 0xd5ba, 0x002e, 0x001e, 0x1178, 0x080c,
-	0xcf08, 0x1904, 0xc124, 0x080c, 0xcea4, 0x1120, 0x6007, 0x0008,
-	0x0804, 0xc23b, 0x6007, 0x0009, 0x0804, 0xc23b, 0x080c, 0xd10f,
-	0x0128, 0x080c, 0xcf08, 0x0d78, 0x0804, 0xc124, 0x6017, 0x1900,
-	0x0c88, 0x080c, 0x3144, 0x1904, 0xc44e, 0x6106, 0x080c, 0xce55,
-	0x6007, 0x0006, 0x0804, 0xc23b, 0x6007, 0x0007, 0x0804, 0xc23b,
-	0x080c, 0xd47e, 0x1904, 0xc44e, 0x080c, 0x3144, 0x1904, 0xc44e,
-	0x00d6, 0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006,
-	0x1220, 0x2001, 0x0001, 0x080c, 0x61a8, 0x96b4, 0xff00, 0x8637,
-	0x9686, 0x0006, 0x0188, 0x9686, 0x0004, 0x0170, 0xbe04, 0x96b4,
-	0x00ff, 0x9686, 0x0006, 0x0140, 0x9686, 0x0004, 0x0128, 0x9686,
-	0x0005, 0x0110, 0x00de, 0x0480, 0x00e6, 0x2071, 0x0260, 0x7034,
-	0x9084, 0x0003, 0x1140, 0x7034, 0x9082, 0x0014, 0x0220, 0x7030,
-	0x9084, 0x0003, 0x0130, 0x00ee, 0x6017, 0x0000, 0x602f, 0x0007,
-	0x00b0, 0x00ee, 0x080c, 0xcf6f, 0x1190, 0x9686, 0x0006, 0x1140,
-	0x0026, 0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x305d, 0x002e,
-	0x080c, 0x6306, 0x6007, 0x000a, 0x00de, 0x0804, 0xc23b, 0x6007,
-	0x000b, 0x00de, 0x0804, 0xc23b, 0x080c, 0x300e, 0x080c, 0xbf76,
-	0x6007, 0x0001, 0x0804, 0xc23b, 0x080c, 0xd47e, 0x1904, 0xc44e,
-	0x080c, 0x3144, 0x1904, 0xc44e, 0x2071, 0x0260, 0x7034, 0x90b4,
-	0x0003, 0x1948, 0x90b2, 0x0014, 0x0a30, 0x7030, 0x9084, 0x0003,
-	0x1910, 0x6610, 0x2658, 0xbe04, 0x9686, 0x0707, 0x09e8, 0x0026,
-	0x6210, 0x2258, 0xbaa0, 0x900e, 0x080c, 0x305d, 0x002e, 0x6007,
-	0x000c, 0x2001, 0x0001, 0x080c, 0xd59a, 0x0804, 0xc23b, 0x080c,
-	0x6624, 0x1140, 0x2001, 0x1836, 0x2004, 0x9084, 0x0009, 0x9086,
-	0x0008, 0x1110, 0x0804, 0xc05f, 0x080c, 0x660d, 0x6610, 0x2658,
-	0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006, 0x06c0, 0x1138, 0x0026,
-	0x2001, 0x0006, 0x080c, 0x61e8, 0x002e, 0x0050, 0x96b4, 0xff00,
-	0x8637, 0x9686, 0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xc124,
-	0x080c, 0xcf7c, 0x1120, 0x6007, 0x000e, 0x0804, 0xc23b, 0x0046,
-	0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x300e, 0x080c, 0xbf76,
-	0x004e, 0x0016, 0x9006, 0x2009, 0x1854, 0x210c, 0x0048, 0x2009,
-	0x0029, 0x080c, 0xd284, 0x6010, 0x2058, 0xb800, 0xc0e5, 0xb802,
-	0x001e, 0x004e, 0x6007, 0x0001, 0x0804, 0xc23b, 0x2001, 0x0001,
-	0x080c, 0x61a8, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004,
-	0x2019, 0x1805, 0x2011, 0x0270, 0x080c, 0xabbf, 0x003e, 0x002e,
-	0x001e, 0x015e, 0x9005, 0x0168, 0x96b4, 0xff00, 0x8637, 0x9682,
-	0x0004, 0x0a04, 0xc124, 0x9682, 0x0007, 0x0a04, 0xc180, 0x0804,
-	0xc124, 0x6017, 0x1900, 0x6007, 0x0009, 0x0804, 0xc23b, 0x080c,
-	0x6624, 0x1140, 0x2001, 0x1836, 0x2004, 0x9084, 0x0009, 0x9086,
-	0x0008, 0x1110, 0x0804, 0xc05f, 0x080c, 0x660d, 0x6610, 0x2658,
-	0xbe04, 0x9684, 0x00ff, 0x0006, 0x9086, 0x0001, 0x000e, 0x0170,
-	0x9082, 0x0006, 0x0690, 0x0150, 0x96b4, 0xff00, 0x8637, 0x9686,
-	0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xc124, 0x080c, 0xcfaa,
-	0x1130, 0x080c, 0xcea4, 0x1118, 0x6007, 0x0010, 0x04e0, 0x0046,
-	0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x300e, 0x080c, 0xbf76,
-	0x004e, 0x0016, 0x9006, 0x2009, 0x1854, 0x210c, 0x0048, 0x2009,
-	0x0029, 0x080c, 0xd284, 0x6010, 0x2058, 0xb800, 0xc0e5, 0xb802,
-	0x001e, 0x004e, 0x6007, 0x0001, 0x00f0, 0x080c, 0xd10f, 0x0140,
-	0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0980, 0x0804, 0xc124,
-	0x6017, 0x1900, 0x6007, 0x0009, 0x0070, 0x080c, 0x3144, 0x1904,
-	0xc44e, 0x080c, 0xd47e, 0x1904, 0xc44e, 0x080c, 0xc5ee, 0x1904,
-	0xc124, 0x6007, 0x0012, 0x6003, 0x0001, 0x080c, 0x84ba, 0x080c,
-	0x891b, 0x0005, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x84ba,
-	0x080c, 0x891b, 0x0cb0, 0x6007, 0x0005, 0x0c68, 0x080c, 0xd47e,
-	0x1904, 0xc44e, 0x080c, 0x3144, 0x1904, 0xc44e, 0x080c, 0xc5ee,
-	0x1904, 0xc124, 0x6007, 0x0020, 0x6003, 0x0001, 0x080c, 0x84ba,
-	0x080c, 0x891b, 0x0005, 0x080c, 0x3144, 0x1904, 0xc44e, 0x6007,
-	0x0023, 0x6003, 0x0001, 0x080c, 0x84ba, 0x080c, 0x891b, 0x0005,
-	0x080c, 0xd47e, 0x1904, 0xc44e, 0x080c, 0x3144, 0x1904, 0xc44e,
-	0x080c, 0xc5ee, 0x1904, 0xc124, 0x0016, 0x0026, 0x00e6, 0x2071,
-	0x0260, 0x7244, 0x9286, 0xffff, 0x0180, 0x2c08, 0x080c, 0xb830,
-	0x01b0, 0x2260, 0x7240, 0x6008, 0x9206, 0x1188, 0x6010, 0x9190,
-	0x0004, 0x2214, 0x9206, 0x01b8, 0x0050, 0x7240, 0x2c08, 0x9006,
-	0x080c, 0xd256, 0x1180, 0x7244, 0x9286, 0xffff, 0x01b0, 0x2160,
-	0x6007, 0x0026, 0x6017, 0x1700, 0x7214, 0x9296, 0xffff, 0x1180,
-	0x6007, 0x0025, 0x0068, 0x6020, 0x9086, 0x0007, 0x1d80, 0x6004,
-	0x9086, 0x0024, 0x1110, 0x080c, 0x9bda, 0x2160, 0x6007, 0x0025,
-	0x6003, 0x0001, 0x080c, 0x84ba, 0x080c, 0x891b, 0x00ee, 0x002e,
-	0x001e, 0x0005, 0x2001, 0x0001, 0x080c, 0x61a8, 0x0156, 0x0016,
-	0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x0276,
-	0x080c, 0xabbf, 0x003e, 0x002e, 0x001e, 0x015e, 0x0120, 0x6007,
-	0x0031, 0x0804, 0xc23b, 0x080c, 0xa824, 0x080c, 0x7096, 0x1190,
-	0x0006, 0x0026, 0x0036, 0x080c, 0x70b0, 0x1138, 0x080c, 0x7396,
-	0x080c, 0x5cd7, 0x080c, 0x6fc7, 0x0010, 0x080c, 0x706a, 0x003e,
-	0x002e, 0x000e, 0x0005, 0x080c, 0x3144, 0x1904, 0xc44e, 0x080c,
-	0xc5ee, 0x1904, 0xc124, 0x6106, 0x080c, 0xc60a, 0x1120, 0x6007,
-	0x002b, 0x0804, 0xc23b, 0x6007, 0x002c, 0x0804, 0xc23b, 0x080c,
-	0xd47e, 0x1904, 0xc44e, 0x080c, 0x3144, 0x1904, 0xc44e, 0x080c,
-	0xc5ee, 0x1904, 0xc124, 0x6106, 0x080c, 0xc60f, 0x1120, 0x6007,
-	0x002e, 0x0804, 0xc23b, 0x6007, 0x002f, 0x0804, 0xc23b, 0x080c,
-	0x3144, 0x1904, 0xc44e, 0x00e6, 0x00d6, 0x00c6, 0x6010, 0x2058,
-	0xb904, 0x9184, 0x00ff, 0x9086, 0x0006, 0x0158, 0x9184, 0xff00,
-	0x8007, 0x9086, 0x0006, 0x0128, 0x00ce, 0x00de, 0x00ee, 0x0804,
-	0xc242, 0x080c, 0x538c, 0xd0e4, 0x0904, 0xc399, 0x2071, 0x026c,
-	0x7010, 0x603a, 0x7014, 0x603e, 0x7108, 0x720c, 0x080c, 0x6662,
-	0x0140, 0x6010, 0x2058, 0xb810, 0x9106, 0x1118, 0xb814, 0x9206,
-	0x0510, 0x080c, 0x665e, 0x15b8, 0x2069, 0x1800, 0x687c, 0x9206,
-	0x1590, 0x6878, 0x9106, 0x1578, 0x7210, 0x080c, 0xb830, 0x0590,
-	0x080c, 0xc4d9, 0x0578, 0x080c, 0xd300, 0x0560, 0x622e, 0x6007,
-	0x0036, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84b3, 0x00ce,
-	0x00de, 0x00ee, 0x0005, 0x7214, 0x9286, 0xffff, 0x0150, 0x080c,
-	0xb830, 0x01c0, 0x9280, 0x0002, 0x2004, 0x7110, 0x9106, 0x1190,
-	0x08e0, 0x7210, 0x2c08, 0x9085, 0x0001, 0x080c, 0xd256, 0x2c10,
-	0x2160, 0x0140, 0x0890, 0x6007, 0x0037, 0x602f, 0x0009, 0x6017,
-	0x1500, 0x08b8, 0x6007, 0x0037, 0x602f, 0x0003, 0x6017, 0x1700,
-	0x0880, 0x6007, 0x0012, 0x0868, 0x080c, 0x3144, 0x1904, 0xc44e,
-	0x6010, 0x2058, 0xb804, 0x9084, 0xff00, 0x8007, 0x9086, 0x0006,
-	0x1904, 0xc242, 0x00e6, 0x00d6, 0x00c6, 0x080c, 0x538c, 0xd0e4,
-	0x0904, 0xc411, 0x2069, 0x1800, 0x2071, 0x026c, 0x7008, 0x603a,
-	0x720c, 0x623e, 0x9286, 0xffff, 0x1150, 0x7208, 0x00c6, 0x2c08,
-	0x9085, 0x0001, 0x080c, 0xd256, 0x2c10, 0x00ce, 0x05e8, 0x080c,
-	0xb830, 0x05d0, 0x7108, 0x9280, 0x0002, 0x2004, 0x9106, 0x15a0,
-	0x00c6, 0x0026, 0x2260, 0x080c, 0xb433, 0x002e, 0x00ce, 0x7118,
-	0x918c, 0xff00, 0x810f, 0x9186, 0x0001, 0x0178, 0x9186, 0x0005,
-	0x0118, 0x9186, 0x0007, 0x1198, 0x9280, 0x0005, 0x2004, 0x9005,
-	0x0170, 0x080c, 0xc4d9, 0x0904, 0xc392, 0x0056, 0x7510, 0x7614,
-	0x080c, 0xd319, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x6007,
-	0x003b, 0x602f, 0x0009, 0x6017, 0x2a00, 0x6003, 0x0001, 0x2009,
-	0x8020, 0x080c, 0x84b3, 0x0c78, 0x6007, 0x003b, 0x602f, 0x0003,
-	0x6017, 0x0300, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84b3,
-	0x0c10, 0x6007, 0x003b, 0x602f, 0x000b, 0x6017, 0x0000, 0x0804,
-	0xc369, 0x00e6, 0x0026, 0x080c, 0x6624, 0x0550, 0x080c, 0x660d,
-	0x080c, 0xd4f0, 0x1518, 0x2071, 0x1800, 0x70d8, 0x9085, 0x0003,
-	0x70da, 0x00f6, 0x2079, 0x0100, 0x72ac, 0x9284, 0x00ff, 0x707a,
-	0x78e6, 0x9284, 0xff00, 0x727c, 0x9205, 0x707e, 0x78ea, 0x00fe,
-	0x70e3, 0x0000, 0x080c, 0x6662, 0x0120, 0x2011, 0x19d9, 0x2013,
-	0x07d0, 0xd0ac, 0x1128, 0x080c, 0x2de9, 0x0010, 0x080c, 0xd522,
-	0x002e, 0x00ee, 0x080c, 0x9bda, 0x0804, 0xc241, 0x080c, 0x9bda,
-	0x0005, 0x2600, 0x0002, 0xc465, 0xc465, 0xc465, 0xc465, 0xc465,
-	0xc467, 0xc465, 0xc465, 0xc465, 0xc465, 0xc484, 0xc465, 0xc465,
-	0xc465, 0xc496, 0xc4a3, 0xc4d4, 0xc465, 0x080c, 0x0d65, 0x080c,
-	0xd47e, 0x1d20, 0x080c, 0x3144, 0x1d08, 0x080c, 0xc5ee, 0x1148,
-	0x7038, 0x6016, 0x6007, 0x0045, 0x6003, 0x0001, 0x080c, 0x84ba,
-	0x0005, 0x080c, 0x300e, 0x080c, 0xbf76, 0x6007, 0x0001, 0x6003,
-	0x0001, 0x080c, 0x84ba, 0x0005, 0x080c, 0xd47e, 0x1938, 0x080c,
-	0x3144, 0x1920, 0x080c, 0xc5ee, 0x1d60, 0x703c, 0x6016, 0x6007,
-	0x004a, 0x6003, 0x0001, 0x080c, 0x84ba, 0x0005, 0x080c, 0xc4f6,
-	0x0904, 0xc44e, 0x6007, 0x004e, 0x6003, 0x0001, 0x080c, 0x84ba,
-	0x080c, 0x891b, 0x0005, 0x6007, 0x004f, 0x6017, 0x0000, 0x7134,
-	0x918c, 0x00ff, 0x81ff, 0x0508, 0x9186, 0x0001, 0x1160, 0x7140,
-	0x2001, 0x198d, 0x2004, 0x9106, 0x11b0, 0x7144, 0x2001, 0x198e,
-	0x2004, 0x9106, 0x0190, 0x9186, 0x0002, 0x1168, 0x2011, 0x0276,
-	0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c,
-	0xabd3, 0x009e, 0x0110, 0x6017, 0x0001, 0x6003, 0x0001, 0x080c,
-	0x84ba, 0x080c, 0x891b, 0x0005, 0x6007, 0x0050, 0x703c, 0x6016,
-	0x0ca0, 0x0016, 0x00e6, 0x2071, 0x0260, 0x00b6, 0x00c6, 0x2260,
-	0x6010, 0x2058, 0xb8c4, 0xd084, 0x0150, 0x7128, 0x6050, 0x9106,
-	0x1120, 0x712c, 0x604c, 0x9106, 0x0110, 0x9006, 0x0010, 0x9085,
-	0x0001, 0x00ce, 0x00be, 0x00ee, 0x001e, 0x0005, 0x0016, 0x0096,
-	0x0086, 0x00e6, 0x01c6, 0x01d6, 0x0126, 0x2091, 0x8000, 0x2071,
-	0x1800, 0x708c, 0x908a, 0x00f9, 0x16e8, 0x20e1, 0x0000, 0x2001,
-	0x1970, 0x2003, 0x0000, 0x080c, 0x103b, 0x05a0, 0x2900, 0x6016,
-	0x708c, 0x8004, 0xa816, 0x908a, 0x001e, 0x02d0, 0xa833, 0x001e,
-	0x20a9, 0x001e, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0,
-	0x2001, 0x1970, 0x0016, 0x200c, 0x0471, 0x001e, 0x2940, 0x080c,
-	0x103b, 0x01c0, 0x2900, 0xa006, 0x2100, 0x81ff, 0x0180, 0x0c18,
-	0xa832, 0x20a8, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0,
-	0x2001, 0x1970, 0x0016, 0x200c, 0x00b1, 0x001e, 0x0000, 0x9085,
-	0x0001, 0x0048, 0x2071, 0x1800, 0x708f, 0x0000, 0x6014, 0x2048,
-	0x080c, 0x0fd4, 0x9006, 0x012e, 0x01de, 0x01ce, 0x00ee, 0x008e,
-	0x009e, 0x001e, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00c6,
-	0x918c, 0xffff, 0x11a8, 0x080c, 0x203c, 0x2099, 0x026c, 0x2001,
-	0x0014, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x00f8, 0x20a8,
-	0x4003, 0x22a8, 0x8108, 0x080c, 0x203c, 0x2099, 0x0260, 0x0ca8,
-	0x080c, 0x203c, 0x2061, 0x1970, 0x6004, 0x2098, 0x6008, 0x3518,
-	0x9312, 0x1218, 0x23a8, 0x4003, 0x0048, 0x20a8, 0x4003, 0x22a8,
-	0x8108, 0x080c, 0x203c, 0x2099, 0x0260, 0x0ca8, 0x2061, 0x1970,
-	0x2019, 0x0280, 0x3300, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001,
-	0x0260, 0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff,
-	0x620a, 0x00ce, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x0006,
-	0x0016, 0x0026, 0x0036, 0x00c6, 0x81ff, 0x11b8, 0x080c, 0x2054,
-	0x20a1, 0x024c, 0x2001, 0x0014, 0x3518, 0x9312, 0x1218, 0x23a8,
-	0x4003, 0x0418, 0x20a8, 0x4003, 0x82ff, 0x01f8, 0x22a8, 0x8108,
-	0x080c, 0x2054, 0x20a1, 0x0240, 0x0c98, 0x080c, 0x2054, 0x2061,
-	0x1973, 0x6004, 0x20a0, 0x6008, 0x3518, 0x9312, 0x1218, 0x23a8,
-	0x4003, 0x0058, 0x20a8, 0x4003, 0x82ff, 0x0138, 0x22a8, 0x8108,
-	0x080c, 0x2054, 0x20a1, 0x0240, 0x0c98, 0x2061, 0x1973, 0x2019,
-	0x0260, 0x3400, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0240,
-	0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a,
-	0x00ce, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x00b6, 0x0066,
-	0x6610, 0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006,
-	0x0170, 0x9686, 0x0004, 0x0158, 0xbe04, 0x96b4, 0x00ff, 0x9686,
-	0x0006, 0x0128, 0x9686, 0x0004, 0x0110, 0x9085, 0x0001, 0x006e,
-	0x00be, 0x0005, 0x00d6, 0x080c, 0xc684, 0x00de, 0x0005, 0x00d6,
-	0x080c, 0xc691, 0x1520, 0x680c, 0x908c, 0xff00, 0x6820, 0x9084,
-	0x00ff, 0x9115, 0x6216, 0x6824, 0x602e, 0xd1e4, 0x0130, 0x9006,
-	0x080c, 0xd59a, 0x2009, 0x0001, 0x0078, 0xd1ec, 0x0180, 0x6920,
-	0x918c, 0x00ff, 0x6824, 0x080c, 0x243d, 0x1148, 0x2001, 0x0001,
-	0x080c, 0xd59a, 0x2110, 0x900e, 0x080c, 0x305d, 0x0018, 0x9085,
-	0x0001, 0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00c6, 0x080c,
-	0x9c49, 0x0598, 0x0016, 0x0026, 0x00c6, 0x2011, 0x0263, 0x2204,
-	0x8211, 0x220c, 0x080c, 0x243d, 0x1568, 0x080c, 0x620b, 0x1550,
-	0xbe12, 0xbd16, 0x00ce, 0x002e, 0x001e, 0x2b00, 0x6012, 0x080c,
-	0xd47e, 0x11c8, 0x080c, 0x3144, 0x11b0, 0x080c, 0xc5ee, 0x0500,
-	0x2001, 0x0007, 0x080c, 0x61bc, 0x2001, 0x0007, 0x080c, 0x61e8,
-	0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001,
-	0x080c, 0x84ba, 0x0010, 0x080c, 0x9bda, 0x9085, 0x0001, 0x00ce,
-	0x00be, 0x0005, 0x080c, 0x9bda, 0x00ce, 0x002e, 0x001e, 0x0ca8,
-	0x080c, 0x9bda, 0x9006, 0x0c98, 0x2069, 0x026d, 0x6800, 0x9082,
-	0x0010, 0x1228, 0x6017, 0x0000, 0x9085, 0x0001, 0x0008, 0x9006,
-	0x0005, 0x6017, 0x0000, 0x2069, 0x026c, 0x6808, 0x9084, 0xff00,
-	0x9086, 0x0800, 0x1190, 0x6904, 0x9186, 0x0018, 0x0118, 0x9186,
-	0x0014, 0x1158, 0x810f, 0x6800, 0x9084, 0x00ff, 0x910d, 0x6162,
-	0x908e, 0x0014, 0x0110, 0x908e, 0x0010, 0x0005, 0x6004, 0x90b2,
-	0x0053, 0x1a0c, 0x0d65, 0x91b6, 0x0013, 0x1130, 0x2008, 0x91b2,
-	0x0040, 0x1a04, 0xc7d1, 0x0092, 0x91b6, 0x0027, 0x0120, 0x91b6,
-	0x0014, 0x190c, 0x0d65, 0x2001, 0x0007, 0x080c, 0x61e8, 0x080c,
-	0x885d, 0x080c, 0x9c14, 0x080c, 0x891b, 0x0005, 0xc70e, 0xc710,
-	0xc70e, 0xc70e, 0xc70e, 0xc710, 0xc71d, 0xc7ce, 0xc76d, 0xc7ce,
-	0xc77f, 0xc7ce, 0xc71d, 0xc7ce, 0xc7c6, 0xc7ce, 0xc7c6, 0xc7ce,
-	0xc7ce, 0xc70e, 0xc70e, 0xc70e, 0xc70e, 0xc70e, 0xc70e, 0xc70e,
-	0xc70e, 0xc70e, 0xc70e, 0xc70e, 0xc710, 0xc70e, 0xc7ce, 0xc70e,
-	0xc70e, 0xc7ce, 0xc70e, 0xc7cb, 0xc7ce, 0xc70e, 0xc70e, 0xc70e,
-	0xc70e, 0xc7ce, 0xc7ce, 0xc70e, 0xc7ce, 0xc7ce, 0xc70e, 0xc718,
-	0xc70e, 0xc70e, 0xc70e, 0xc70e, 0xc7ca, 0xc7ce, 0xc70e, 0xc70e,
-	0xc7ce, 0xc7ce, 0xc70e, 0xc70e, 0xc70e, 0xc70e, 0x080c, 0x0d65,
-	0x080c, 0xbf79, 0x6003, 0x0002, 0x080c, 0x891b, 0x0804, 0xc7d0,
-	0x9006, 0x080c, 0x61a8, 0x0804, 0xc7ce, 0x080c, 0x665e, 0x1904,
-	0xc7ce, 0x9006, 0x080c, 0x61a8, 0x6010, 0x2058, 0xb810, 0x9086,
-	0x00ff, 0x1140, 0x00f6, 0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6,
-	0x00fe, 0x0428, 0x6010, 0x2058, 0xb884, 0x9005, 0x1178, 0x080c,
-	0xbf61, 0x1904, 0xc7ce, 0x0036, 0x0046, 0xbba0, 0x2021, 0x0007,
-	0x080c, 0x4a77, 0x004e, 0x003e, 0x0804, 0xc7ce, 0x080c, 0x3175,
-	0x1904, 0xc7ce, 0x2001, 0x1800, 0x2004, 0x9086, 0x0002, 0x1138,
-	0x00f6, 0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6, 0x00fe, 0x2001,
-	0x0002, 0x080c, 0x61bc, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007,
-	0x0002, 0x080c, 0x84ba, 0x080c, 0x891b, 0x6110, 0x2158, 0x2009,
-	0x0001, 0x080c, 0x8146, 0x0804, 0xc7d0, 0x6610, 0x2658, 0xbe04,
-	0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0904, 0xc7ce, 0x9686,
-	0x0004, 0x0904, 0xc7ce, 0x2001, 0x0004, 0x0804, 0xc7cc, 0x2001,
-	0x1800, 0x2004, 0x9086, 0x0003, 0x1158, 0x0036, 0x0046, 0x6010,
-	0x2058, 0xbba0, 0x2021, 0x0006, 0x080c, 0x4a77, 0x004e, 0x003e,
-	0x2001, 0x0006, 0x080c, 0xc7ea, 0x6610, 0x2658, 0xbe04, 0x0066,
-	0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x006e, 0x0168, 0x2001,
-	0x0006, 0x080c, 0x61e8, 0x9284, 0x00ff, 0x908e, 0x0007, 0x1120,
-	0x2001, 0x0006, 0x080c, 0x61bc, 0x080c, 0x665e, 0x11f8, 0x2001,
-	0x1836, 0x2004, 0xd0a4, 0x01d0, 0xbe04, 0x96b4, 0x00ff, 0x9686,
-	0x0006, 0x01a0, 0x00f6, 0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6,
-	0x00fe, 0x0804, 0xc757, 0x2001, 0x0004, 0x0030, 0x2001, 0x0006,
-	0x0409, 0x0020, 0x0018, 0x0010, 0x080c, 0x61e8, 0x080c, 0x9bda,
-	0x0005, 0x2600, 0x0002, 0xc7e5, 0xc7e5, 0xc7e5, 0xc7e5, 0xc7e5,
-	0xc7e7, 0xc7e5, 0xc7e5, 0xc7e5, 0xc7e5, 0xc7e7, 0xc7e5, 0xc7e5,
-	0xc7e5, 0xc7e7, 0xc7e7, 0xc7e7, 0xc7e7, 0x080c, 0x0d65, 0x080c,
-	0x9bda, 0x0005, 0x0016, 0x00b6, 0x00d6, 0x6110, 0x2158, 0xb900,
-	0xd184, 0x0138, 0x080c, 0x61bc, 0x9006, 0x080c, 0x61a8, 0x080c,
-	0x303d, 0x00de, 0x00be, 0x001e, 0x0005, 0x6610, 0x2658, 0xb804,
-	0x9084, 0xff00, 0x8007, 0x90b2, 0x000c, 0x1a0c, 0x0d65, 0x91b6,
-	0x0015, 0x1110, 0x003b, 0x0028, 0x91b6, 0x0016, 0x190c, 0x0d65,
-	0x006b, 0x0005, 0xa662, 0xa662, 0xa662, 0xa662, 0xc87f, 0xa662,
-	0xc869, 0xc82a, 0xa662, 0xa662, 0xa662, 0xa662, 0xa662, 0xa662,
-	0xa662, 0xa662, 0xc87f, 0xa662, 0xc869, 0xc870, 0xa662, 0xa662,
-	0xa662, 0xa662, 0x00f6, 0x080c, 0x665e, 0x11d8, 0x080c, 0xbf61,
-	0x11c0, 0x6010, 0x905d, 0x01a8, 0xb884, 0x9005, 0x0190, 0x9006,
-	0x080c, 0x61a8, 0x2001, 0x0002, 0x080c, 0x61bc, 0x6023, 0x0001,
-	0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x84ba, 0x080c, 0x891b,
-	0x00f0, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x243d,
-	0x11b0, 0x080c, 0x626b, 0x0118, 0x080c, 0x9bda, 0x0080, 0xb810,
-	0x0006, 0xb814, 0x0006, 0xb884, 0x0006, 0x080c, 0x5cf1, 0x000e,
-	0xb886, 0x000e, 0xb816, 0x000e, 0xb812, 0x080c, 0x9bda, 0x00fe,
-	0x0005, 0x6604, 0x96b6, 0x001e, 0x1110, 0x080c, 0x9bda, 0x0005,
-	0x080c, 0xaa48, 0x1148, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c,
-	0x84ba, 0x080c, 0x891b, 0x0010, 0x080c, 0x9bda, 0x0005, 0x0804,
-	0x9bda, 0x6004, 0x908a, 0x0053, 0x1a0c, 0x0d65, 0x080c, 0x885d,
-	0x080c, 0x9c14, 0x0005, 0x9182, 0x0040, 0x0002, 0xc8a1, 0xc8a1,
-	0xc8a1, 0xc8a1, 0xc8a3, 0xc8a1, 0xc8a1, 0xc8a1, 0xc8a1, 0xc8a1,
-	0xc8a1, 0xc8a1, 0xc8a1, 0xc8a1, 0xc8a1, 0xc8a1, 0xc8a1, 0xc8a1,
-	0xc8a1, 0x080c, 0x0d65, 0x0096, 0x00b6, 0x00d6, 0x00e6, 0x00f6,
-	0x0046, 0x0026, 0x6210, 0x2258, 0xb8ac, 0x9005, 0x11b0, 0x6007,
-	0x0044, 0x2071, 0x0260, 0x7444, 0x94a4, 0xff00, 0x0904, 0xc90a,
-	0x080c, 0xd58e, 0x1170, 0x9486, 0x2000, 0x1158, 0x2009, 0x0001,
-	0x2011, 0x0200, 0x080c, 0x83cd, 0x0020, 0x9026, 0x080c, 0xd4c3,
-	0x0c30, 0x080c, 0x1022, 0x090c, 0x0d65, 0x6003, 0x0007, 0xa867,
-	0x010d, 0x9006, 0xa802, 0xa86a, 0xac8a, 0x2c00, 0xa88e, 0x6008,
-	0xa8e2, 0x6010, 0x2058, 0xb8a0, 0x7130, 0xa97a, 0x0016, 0xa876,
-	0xa87f, 0x0000, 0xa883, 0x0000, 0xa887, 0x0036, 0x080c, 0x6991,
-	0x001e, 0x080c, 0xd58e, 0x1904, 0xc96a, 0x9486, 0x2000, 0x1130,
-	0x2019, 0x0017, 0x080c, 0xd1fc, 0x0804, 0xc96a, 0x9486, 0x0200,
-	0x1120, 0x080c, 0xd18c, 0x0804, 0xc96a, 0x9486, 0x0400, 0x0120,
-	0x9486, 0x1000, 0x1904, 0xc96a, 0x2019, 0x0002, 0x080c, 0xd1ab,
-	0x0804, 0xc96a, 0x2069, 0x1a3e, 0x6a00, 0xd284, 0x0904, 0xc9d4,
-	0x9284, 0x0300, 0x1904, 0xc9cd, 0x6804, 0x9005, 0x0904, 0xc9b5,
-	0x2d78, 0x6003, 0x0007, 0x080c, 0x103b, 0x0904, 0xc976, 0x7800,
-	0xd08c, 0x1118, 0x7804, 0x8001, 0x7806, 0x6017, 0x0000, 0x2001,
-	0x180f, 0x2004, 0xd084, 0x1904, 0xc9d8, 0x9006, 0xa802, 0xa867,
-	0x0116, 0xa86a, 0x6008, 0xa8e2, 0x2c00, 0xa87a, 0x6010, 0x2058,
-	0xb8a0, 0x7130, 0xa9b6, 0xa876, 0xb928, 0xa9ba, 0xb92c, 0xa9be,
-	0xb930, 0xa9c2, 0xb934, 0xa9c6, 0xa883, 0x003d, 0x7044, 0x9084,
-	0x0003, 0x9080, 0xc972, 0x2005, 0xa87e, 0x20a9, 0x000a, 0x2001,
-	0x0270, 0xaa5c, 0x9290, 0x0021, 0x2009, 0x0205, 0x200b, 0x0080,
-	0x20e1, 0x0000, 0xab60, 0x23e8, 0x2098, 0x22a0, 0x4003, 0x200b,
-	0x0000, 0x2001, 0x027a, 0x200c, 0xa9b2, 0x8000, 0x200c, 0xa9ae,
-	0x080c, 0x6994, 0x002e, 0x004e, 0x00fe, 0x00ee, 0x00de, 0x00be,
-	0x009e, 0x0005, 0x0000, 0x0080, 0x0040, 0x0000, 0x2001, 0x1810,
-	0x2004, 0xd084, 0x0120, 0x080c, 0x1022, 0x1904, 0xc91f, 0x6017,
-	0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022, 0x080c,
-	0x84b3, 0x0c00, 0x2069, 0x0260, 0x6848, 0x9084, 0xff00, 0x9086,
-	0x1200, 0x1198, 0x686c, 0x9084, 0x00ff, 0x0016, 0x6114, 0x918c,
-	0xf700, 0x910d, 0x6116, 0x001e, 0x6003, 0x0001, 0x6007, 0x0043,
-	0x2009, 0xa025, 0x080c, 0x84b3, 0x0828, 0x6868, 0x602e, 0x686c,
-	0x6032, 0x6017, 0xf200, 0x6003, 0x0001, 0x6007, 0x0041, 0x2009,
-	0xa022, 0x080c, 0x84b3, 0x0804, 0xc96a, 0x2001, 0x180e, 0x2004,
-	0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x48da, 0x6017, 0xf300,
-	0x0010, 0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x2009,
-	0xa022, 0x080c, 0x84b3, 0x0804, 0xc96a, 0x6017, 0xf500, 0x0c98,
-	0x6017, 0xf600, 0x0804, 0xc98a, 0x6017, 0xf200, 0x0804, 0xc98a,
-	0xa867, 0x0146, 0xa86b, 0x0000, 0x6008, 0xa886, 0x2c00, 0xa87a,
-	0x7044, 0x9084, 0x0003, 0x9080, 0xc972, 0x2005, 0xa87e, 0x2928,
-	0x6010, 0x2058, 0xb8a0, 0xa876, 0xb828, 0xa88a, 0xb82c, 0xa88e,
-	0xb830, 0xa892, 0xb834, 0xa896, 0xa883, 0x003d, 0x2009, 0x0205,
-	0x2104, 0x9085, 0x0080, 0x200a, 0x20e1, 0x0000, 0x2011, 0x0210,
-	0x2214, 0x9294, 0x0fff, 0xaaa2, 0x9282, 0x0111, 0x1a0c, 0x0d65,
-	0x8210, 0x821c, 0x2001, 0x026c, 0x2098, 0xa860, 0x20e8, 0xa85c,
-	0x9080, 0x0029, 0x20a0, 0x2011, 0xca54, 0x2041, 0x0001, 0x223d,
-	0x9784, 0x00ff, 0x9322, 0x1208, 0x2300, 0x20a8, 0x4003, 0x931a,
-	0x0530, 0x8210, 0xd7fc, 0x1130, 0x8d68, 0x2d0a, 0x2001, 0x0260,
-	0x2098, 0x0c68, 0x2950, 0x080c, 0x103b, 0x0170, 0x2900, 0xb002,
-	0xa867, 0x0147, 0xa86b, 0x0000, 0xa860, 0x20e8, 0xa85c, 0x9080,
-	0x001b, 0x20a0, 0x8840, 0x08d8, 0x2548, 0xa800, 0x902d, 0x0118,
-	0x080c, 0x1054, 0x0cc8, 0x080c, 0x1054, 0x0804, 0xc976, 0x2548,
-	0x8847, 0x9885, 0x0046, 0xa866, 0x2009, 0x0205, 0x200b, 0x0000,
-	0x080c, 0xd22f, 0x0804, 0xc96a, 0x8010, 0x0004, 0x801a, 0x0006,
-	0x8018, 0x0008, 0x8016, 0x000a, 0x8014, 0x9186, 0x0013, 0x1160,
-	0x6004, 0x908a, 0x0057, 0x1a0c, 0x0d65, 0x9082, 0x0040, 0x0a0c,
-	0x0d65, 0x2008, 0x0804, 0xcadf, 0x9186, 0x0051, 0x0108, 0x0040,
-	0x080c, 0x9aaa, 0x01e8, 0x9086, 0x0002, 0x0904, 0xcb26, 0x00c0,
-	0x9186, 0x0027, 0x0180, 0x9186, 0x0048, 0x0128, 0x9186, 0x0014,
-	0x0150, 0x190c, 0x0d65, 0x080c, 0x9aaa, 0x0150, 0x9086, 0x0004,
-	0x0904, 0xcbc3, 0x0028, 0x6004, 0x9082, 0x0040, 0x2008, 0x001a,
-	0x080c, 0x9c93, 0x0005, 0xcaa6, 0xcaa8, 0xcaa8, 0xcacf, 0xcaa6,
-	0xcaa6, 0xcaa6, 0xcaa6, 0xcaa6, 0xcaa6, 0xcaa6, 0xcaa6, 0xcaa6,
-	0xcaa6, 0xcaa6, 0xcaa6, 0xcaa6, 0xcaa6, 0xcaa6, 0x080c, 0x0d65,
-	0x080c, 0x885d, 0x080c, 0x891b, 0x0036, 0x0096, 0x6014, 0x904d,
-	0x01d8, 0x080c, 0xb842, 0x01c0, 0x6003, 0x0002, 0x6010, 0x00b6,
+	0x080c, 0xbb79, 0xa877, 0x0000, 0x080c, 0x69b5, 0x080c, 0xba5f,
+	0x009e, 0x0804, 0x9be6, 0x0016, 0x0096, 0x6014, 0x2048, 0x080c,
+	0xb870, 0x0140, 0xa867, 0x0103, 0xa87b, 0x0028, 0xa877, 0x0000,
+	0x080c, 0x69b5, 0x009e, 0x001e, 0x9186, 0x0013, 0x0158, 0x9186,
+	0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c, 0x9c9f, 0x0020,
+	0x080c, 0x8891, 0x080c, 0x9c20, 0x0005, 0x0056, 0x0066, 0x0096,
+	0x00a6, 0x2029, 0x0001, 0x9182, 0x0101, 0x1208, 0x0010, 0x2009,
+	0x0100, 0x2130, 0x8304, 0x9098, 0x0018, 0x2009, 0x0020, 0x2011,
+	0x0029, 0x080c, 0xb426, 0x96b2, 0x0020, 0xb004, 0x904d, 0x0110,
+	0x080c, 0x0fe1, 0x080c, 0x102f, 0x0520, 0x8528, 0xa867, 0x0110,
+	0xa86b, 0x0000, 0x2920, 0xb406, 0x968a, 0x003d, 0x1228, 0x2608,
+	0x2011, 0x001b, 0x0499, 0x00a8, 0x96b2, 0x003c, 0x2009, 0x003c,
+	0x2950, 0x2011, 0x001b, 0x0451, 0x0c28, 0x2001, 0x0205, 0x2003,
+	0x0000, 0x00ae, 0x852f, 0x95ad, 0x0003, 0xb566, 0x95ac, 0x0000,
+	0x0048, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad,
+	0x0003, 0xb566, 0x009e, 0x006e, 0x005e, 0x0005, 0x00a6, 0x89ff,
+	0x0158, 0xa804, 0x9055, 0x0130, 0xa807, 0x0000, 0x080c, 0x69b5,
+	0x2a48, 0x0cb8, 0x080c, 0x69b5, 0x00ae, 0x0005, 0x00f6, 0x2079,
+	0x0200, 0x7814, 0x9085, 0x0080, 0x7816, 0xd184, 0x0108, 0x8108,
+	0x810c, 0x20a9, 0x0001, 0xa860, 0x20e8, 0xa85c, 0x9200, 0x20a0,
+	0x20e1, 0x0000, 0x2300, 0x9e00, 0x2098, 0x4003, 0x8318, 0x9386,
+	0x0020, 0x1148, 0x2018, 0x2300, 0x9e00, 0x2098, 0x7814, 0x8000,
+	0x9085, 0x0080, 0x7816, 0x8109, 0x1d80, 0x7817, 0x0000, 0x00fe,
+	0x0005, 0x0066, 0x0126, 0x2091, 0x8000, 0x2031, 0x0001, 0x6020,
+	0x9084, 0x000f, 0x0083, 0x012e, 0x006e, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x0066, 0x2031, 0x0000, 0x6020, 0x9084, 0x000f, 0x001b,
+	0x006e, 0x012e, 0x0005, 0xb4a3, 0xb4a3, 0xb49e, 0xb4c7, 0xb47b,
+	0xb49e, 0xb47d, 0xb49e, 0xb47b, 0xb47b, 0xb49e, 0xb49e, 0xb49e,
+	0xb47b, 0xb47b, 0xb47b, 0x080c, 0x0d65, 0x6010, 0x9080, 0x0000,
+	0x2004, 0xd0bc, 0x190c, 0xb4c7, 0x0036, 0x6014, 0x0096, 0x2048,
+	0xa880, 0x009e, 0xd0cc, 0x0118, 0x2019, 0x000c, 0x0038, 0xd094,
+	0x0118, 0x2019, 0x000d, 0x0010, 0x2019, 0x0010, 0x080c, 0xce41,
+	0x6023, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x9006, 0x0005,
+	0x9085, 0x0001, 0x0005, 0x0096, 0x86ff, 0x11e8, 0x6014, 0x2048,
+	0x080c, 0xb870, 0x01d0, 0x6043, 0xffff, 0xa864, 0x9086, 0x0139,
+	0x1128, 0xa87b, 0x0005, 0xa883, 0x0000, 0x0028, 0x900e, 0x2001,
+	0x0005, 0x080c, 0x6bc6, 0x080c, 0xbb79, 0x080c, 0x69a9, 0x080c,
+	0x9c20, 0x9085, 0x0001, 0x009e, 0x0005, 0x9006, 0x0ce0, 0x080c,
+	0x98c7, 0x080c, 0xbfc9, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d65,
+	0x002b, 0x0106, 0x080c, 0x98e3, 0x010e, 0x0005, 0xb4e6, 0xb514,
+	0xb4e8, 0xb53b, 0xb50f, 0xb4e6, 0xb49e, 0xb4a3, 0xb4a3, 0xb49e,
+	0xb49e, 0xb49e, 0xb49e, 0xb49e, 0xb49e, 0xb49e, 0x080c, 0x0d65,
+	0x86ff, 0x1510, 0x6020, 0x9086, 0x0006, 0x01f0, 0x0096, 0x6014,
+	0x2048, 0x080c, 0xb870, 0x0158, 0xa87c, 0xd0cc, 0x0130, 0x0096,
+	0xa878, 0x2048, 0x080c, 0x0fe1, 0x009e, 0x080c, 0xbb79, 0x009e,
+	0x080c, 0xbf49, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002,
+	0x2009, 0x8020, 0x080c, 0x84c9, 0x9085, 0x0001, 0x0005, 0x0066,
+	0x080c, 0x193e, 0x006e, 0x08a0, 0x00e6, 0x2071, 0x19bf, 0x7030,
+	0x9c06, 0x1120, 0x080c, 0x921d, 0x00ee, 0x0850, 0x6020, 0x9084,
+	0x000f, 0x9086, 0x0006, 0x1150, 0x0086, 0x0096, 0x2049, 0x0001,
+	0x2c40, 0x080c, 0x936d, 0x009e, 0x008e, 0x0040, 0x0066, 0x080c,
+	0x9119, 0x190c, 0x0d65, 0x080c, 0x9127, 0x006e, 0x00ee, 0x1904,
+	0xb4e8, 0x0804, 0xb49e, 0x0036, 0x00e6, 0x2071, 0x19bf, 0x704c,
+	0x9c06, 0x1138, 0x901e, 0x080c, 0x929d, 0x00ee, 0x003e, 0x0804,
+	0xb4e8, 0x080c, 0x94a4, 0x00ee, 0x003e, 0x1904, 0xb4e8, 0x0804,
+	0xb49e, 0x00c6, 0x0066, 0x6020, 0x9084, 0x000f, 0x001b, 0x006e,
+	0x00ce, 0x0005, 0xb571, 0xb640, 0xb7aa, 0xb579, 0x9c20, 0xb571,
+	0xce33, 0xbfb1, 0xb640, 0xb56a, 0xb836, 0xb56a, 0xb56a, 0xb56a,
+	0xb56a, 0xb56a, 0x080c, 0x0d65, 0x080c, 0xba85, 0x1110, 0x080c,
+	0xa59c, 0x0005, 0x080c, 0x8891, 0x0804, 0x9be6, 0x601b, 0x0001,
+	0x0005, 0x080c, 0xb870, 0x0130, 0x6014, 0x0096, 0x2048, 0x2c00,
+	0xa896, 0x009e, 0x080c, 0x98c7, 0x080c, 0xbfc9, 0x6000, 0x908a,
+	0x0016, 0x1a0c, 0x0d65, 0x0013, 0x0804, 0x98e3, 0xb59e, 0xb5a0,
+	0xb5ca, 0xb5de, 0xb60b, 0xb59e, 0xb571, 0xb571, 0xb571, 0xb5e5,
+	0xb5e5, 0xb59e, 0xb59e, 0xb59e, 0xb59e, 0xb5ef, 0x080c, 0x0d65,
+	0x00e6, 0x6014, 0x0096, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e,
+	0x2071, 0x19bf, 0x7030, 0x9c06, 0x01d0, 0x0066, 0x080c, 0x9119,
+	0x190c, 0x0d65, 0x080c, 0x9127, 0x006e, 0x080c, 0xbf49, 0x6007,
+	0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x2001, 0x195f, 0x2004,
+	0x601a, 0x2009, 0x8020, 0x080c, 0x84c9, 0x00ee, 0x0005, 0x601b,
+	0x0001, 0x0cd8, 0x0096, 0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882,
+	0x009e, 0x080c, 0xbf49, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
+	0x0002, 0x2009, 0x8020, 0x080c, 0x84c9, 0x0005, 0x080c, 0x98c7,
+	0x080c, 0x9a38, 0x080c, 0x98e3, 0x0c28, 0x0096, 0x601b, 0x0001,
+	0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e, 0x0005, 0x080c,
+	0x53b0, 0x01b8, 0x6014, 0x0096, 0x904d, 0x0190, 0xa864, 0xa867,
+	0x0103, 0xa87b, 0x0006, 0x9086, 0x0139, 0x1150, 0xa867, 0x0139,
+	0xa87b, 0x0030, 0xa897, 0x4005, 0xa89b, 0x0004, 0x080c, 0x69b5,
+	0x009e, 0x0804, 0x9be6, 0x6014, 0x0096, 0x904d, 0x0560, 0xa97c,
+	0xd1e4, 0x1158, 0x611c, 0xd1fc, 0x0530, 0x6110, 0x00b6, 0x2158,
+	0xb93c, 0x8109, 0x0208, 0xb93e, 0x00be, 0x080c, 0x98e3, 0x2001,
+	0x180f, 0x2004, 0xd0c4, 0x0110, 0x009e, 0x0005, 0xa884, 0x009e,
+	0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0x2001, 0x0037, 0x2c08,
+	0x080c, 0x15b8, 0x6000, 0x9086, 0x0004, 0x1120, 0x2009, 0x0048,
+	0x080c, 0x9c82, 0x0005, 0x009e, 0x080c, 0x193e, 0x0804, 0xb5ca,
+	0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d65, 0x000b, 0x0005, 0xb657,
+	0xb576, 0xb659, 0xb657, 0xb659, 0xb659, 0xb572, 0xb657, 0xb56c,
+	0xb56c, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0xb657, 0x080c,
+	0x0d65, 0x6010, 0x00b6, 0x2058, 0xb804, 0x9084, 0x00ff, 0x00be,
+	0x908a, 0x000c, 0x1a0c, 0x0d65, 0x00b6, 0x0013, 0x00be, 0x0005,
+	0xb674, 0xb741, 0xb676, 0xb6b6, 0xb676, 0xb6b6, 0xb676, 0xb684,
+	0xb674, 0xb6b6, 0xb674, 0xb6a5, 0x080c, 0x0d65, 0x6004, 0x908e,
+	0x0016, 0x05c0, 0x908e, 0x0004, 0x05a8, 0x908e, 0x0002, 0x0590,
+	0x908e, 0x0052, 0x0904, 0xb73d, 0x6004, 0x080c, 0xba85, 0x0904,
+	0xb75a, 0x908e, 0x0004, 0x1110, 0x080c, 0x305d, 0x908e, 0x0021,
+	0x0904, 0xb75e, 0x908e, 0x0022, 0x0904, 0xb7a5, 0x908e, 0x003d,
+	0x0904, 0xb75e, 0x908e, 0x0039, 0x0904, 0xb762, 0x908e, 0x0035,
+	0x0904, 0xb762, 0x908e, 0x001e, 0x0178, 0x908e, 0x0001, 0x1140,
+	0x6010, 0x2058, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x0110,
+	0x080c, 0x302e, 0x080c, 0xa59c, 0x0804, 0x9c20, 0x00c6, 0x00d6,
+	0x6104, 0x9186, 0x0016, 0x0904, 0xb72e, 0x9186, 0x0002, 0x1904,
+	0xb703, 0x2001, 0x1836, 0x2004, 0xd08c, 0x11c8, 0x080c, 0x70ba,
+	0x11b0, 0x080c, 0xbf8f, 0x0138, 0x080c, 0x70dd, 0x1120, 0x080c,
+	0x6fc5, 0x0804, 0xb78e, 0x2001, 0x1955, 0x2003, 0x0001, 0x2001,
+	0x1800, 0x2003, 0x0001, 0x080c, 0x6feb, 0x0804, 0xb78e, 0x6010,
+	0x2058, 0x2001, 0x1836, 0x2004, 0xd0ac, 0x1904, 0xb78e, 0xb8a0,
+	0x9084, 0xff80, 0x1904, 0xb78e, 0xb840, 0x9084, 0x00ff, 0x9005,
+	0x0190, 0x8001, 0xb842, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b,
+	0x0398, 0x604b, 0x0000, 0x080c, 0x9b90, 0x0128, 0x2b00, 0x6012,
+	0x6023, 0x0001, 0x0458, 0x00de, 0x00ce, 0x6004, 0x908e, 0x0002,
+	0x11a0, 0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e, 0x1170, 0x2009,
+	0x1836, 0x2104, 0xc085, 0x200a, 0x00e6, 0x2071, 0x1800, 0x080c,
+	0x5c8a, 0x00ee, 0x080c, 0xa59c, 0x0030, 0x080c, 0xa59c, 0x080c,
+	0x302e, 0x080c, 0xbfa4, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x305d, 0x012e, 0x00ee, 0x080c, 0x9c20, 0x0005, 0x2001, 0x0002,
+	0x080c, 0x61e0, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x84ee,
+	0x080c, 0x894f, 0x00de, 0x00ce, 0x0c80, 0x080c, 0x305d, 0x0804,
+	0xb6b2, 0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016, 0x0d38, 0x6010,
+	0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0904, 0xb703, 0x8001,
+	0xb842, 0x6003, 0x0001, 0x080c, 0x84ee, 0x080c, 0x894f, 0x00de,
+	0x00ce, 0x0898, 0x080c, 0xa59c, 0x0804, 0xb6b4, 0x080c, 0xa5d8,
+	0x0804, 0xb6b4, 0x00d6, 0x2c68, 0x6104, 0x080c, 0xbf07, 0x00de,
+	0x0118, 0x080c, 0x9be6, 0x0408, 0x6004, 0x8007, 0x6134, 0x918c,
+	0x00ff, 0x9105, 0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
+	0x0002, 0x603c, 0x600a, 0x2001, 0x195f, 0x2004, 0x601a, 0x602c,
+	0x2c08, 0x2060, 0x6024, 0xd0b4, 0x0108, 0xc085, 0xc0b5, 0x6026,
+	0x2160, 0x2009, 0x8020, 0x080c, 0x84e7, 0x0005, 0x00de, 0x00ce,
+	0x080c, 0xa59c, 0x080c, 0x302e, 0x00e6, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x305d, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398,
+	0x604b, 0x0000, 0x012e, 0x00ee, 0x0005, 0x080c, 0xa020, 0x1904,
+	0xb75a, 0x0005, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0d65, 0x0096,
+	0x00d6, 0x001b, 0x00de, 0x009e, 0x0005, 0xb7c5, 0xb7c5, 0xb7c5,
+	0xb7c5, 0xb7c5, 0xb7c5, 0xb7c5, 0xb7c5, 0xb7c5, 0xb571, 0xb7c5,
+	0xb576, 0xb7c7, 0xb576, 0xb7e1, 0xb7c5, 0x080c, 0x0d65, 0x6004,
+	0x9086, 0x008b, 0x01b0, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186,
+	0x0035, 0x1130, 0x602c, 0x9080, 0x0009, 0x200c, 0xc185, 0x2102,
+	0x6007, 0x008b, 0x6003, 0x000d, 0x2009, 0x8020, 0x080c, 0x84e7,
+	0x0005, 0x080c, 0xbf83, 0x0118, 0x080c, 0xbf96, 0x0010, 0x080c,
+	0xbfa4, 0x080c, 0xba5f, 0x080c, 0xb870, 0x0570, 0x080c, 0x302e,
+	0x080c, 0xb870, 0x0168, 0x6014, 0x2048, 0xa867, 0x0103, 0xa87b,
+	0x0006, 0xa877, 0x0000, 0xa880, 0xc0ed, 0xa882, 0x080c, 0x69b5,
+	0x2c68, 0x080c, 0x9b90, 0x0150, 0x6810, 0x6012, 0x080c, 0xbd09,
+	0x00c6, 0x2d60, 0x080c, 0x9c20, 0x00ce, 0x0008, 0x2d60, 0x6017,
+	0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x84ee, 0x080c, 0x894f, 0x00c8, 0x080c, 0xbf83, 0x0138, 0x6034,
+	0x9086, 0x4000, 0x1118, 0x080c, 0x302e, 0x08d0, 0x6034, 0x908c,
+	0xff00, 0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118,
+	0x080c, 0x302e, 0x0868, 0x080c, 0x9c20, 0x0005, 0x6000, 0x908a,
+	0x0016, 0x1a0c, 0x0d65, 0x0002, 0xb84c, 0xb84c, 0xb84e, 0xb84e,
+	0xb84e, 0xb84c, 0xb84c, 0x9c20, 0xb84c, 0xb84c, 0xb84c, 0xb84c,
+	0xb84c, 0xb84c, 0xb84c, 0xb84c, 0x080c, 0x0d65, 0x080c, 0x98c7,
+	0x080c, 0x9a38, 0x080c, 0x98e3, 0x6114, 0x0096, 0x2148, 0xa87b,
+	0x0006, 0x080c, 0x69b5, 0x009e, 0x0804, 0x9be6, 0x9284, 0x0003,
+	0x1158, 0x9282, 0x1ddc, 0x0240, 0x2001, 0x1819, 0x2004, 0x9202,
+	0x1218, 0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8, 0x0096, 0x0028,
+	0x0096, 0x0006, 0x6014, 0x2048, 0x000e, 0x0006, 0x9984, 0xf000,
+	0x9086, 0xf000, 0x0110, 0x080c, 0x10da, 0x000e, 0x009e, 0x0005,
+	0x00e6, 0x00c6, 0x0036, 0x0006, 0x0126, 0x2091, 0x8000, 0x2061,
+	0x1ddc, 0x2071, 0x1800, 0x7350, 0x7070, 0x9302, 0x1640, 0x6020,
+	0x9206, 0x11f8, 0x080c, 0xbf8f, 0x0180, 0x9286, 0x0001, 0x1168,
+	0x6004, 0x9086, 0x0004, 0x1148, 0x080c, 0x302e, 0x080c, 0xbfa4,
+	0x00c6, 0x080c, 0x9c20, 0x00ce, 0x0060, 0x080c, 0xbc7b, 0x0148,
+	0x080c, 0xba85, 0x1110, 0x080c, 0xa59c, 0x00c6, 0x080c, 0x9be6,
+	0x00ce, 0x9ce0, 0x001c, 0x7064, 0x9c02, 0x1208, 0x08a0, 0x012e,
+	0x000e, 0x003e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x00c6, 0x0016,
+	0x9188, 0x1000, 0x210c, 0x81ff, 0x0128, 0x2061, 0x1b09, 0x6112,
+	0x080c, 0x302e, 0x9006, 0x0010, 0x9085, 0x0001, 0x001e, 0x00ce,
+	0x00ee, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9b90,
+	0x01b0, 0x665e, 0x2b00, 0x6012, 0x080c, 0x53b0, 0x0118, 0x080c,
+	0xb9a1, 0x0168, 0x080c, 0xbd09, 0x6023, 0x0003, 0x2009, 0x004b,
+	0x080c, 0x9c82, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006,
+	0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0xbaa0, 0x080c, 0x9c55,
+	0x0580, 0x605f, 0x0000, 0x2b00, 0x6012, 0x080c, 0xbd09, 0x6023,
+	0x0003, 0x0016, 0x080c, 0x98c7, 0x080c, 0x8658, 0x0076, 0x903e,
+	0x080c, 0x853d, 0x2c08, 0x080c, 0xd011, 0x007e, 0x080c, 0x98e3,
+	0x001e, 0xd184, 0x0128, 0x080c, 0x9be6, 0x9085, 0x0001, 0x0070,
+	0x080c, 0x53b0, 0x0128, 0xd18c, 0x1170, 0x080c, 0xb9a1, 0x0148,
+	0x2009, 0x004c, 0x080c, 0x9c82, 0x9085, 0x0001, 0x012e, 0x00ce,
+	0x0005, 0x9006, 0x0cd8, 0x2900, 0x6016, 0x0c90, 0x2009, 0x004d,
+	0x0010, 0x2009, 0x004e, 0x00f6, 0x00c6, 0x0046, 0x0016, 0x080c,
+	0x9b90, 0x2c78, 0x0590, 0x7e5e, 0x2b00, 0x7812, 0x7823, 0x0003,
+	0x2021, 0x0005, 0x080c, 0xb9b3, 0x9186, 0x004d, 0x0118, 0x9186,
+	0x004e, 0x0148, 0x2001, 0x1958, 0x200c, 0xd1fc, 0x0168, 0x2f60,
+	0x080c, 0x9be6, 0x00d0, 0x2001, 0x1957, 0x200c, 0xd1fc, 0x0120,
+	0x2f60, 0x080c, 0x9be6, 0x0088, 0x2f60, 0x080c, 0x53b0, 0x0138,
+	0xd18c, 0x1118, 0x04f1, 0x0148, 0x0010, 0x2900, 0x7816, 0x001e,
+	0x0016, 0x080c, 0x9c82, 0x9085, 0x0001, 0x001e, 0x004e, 0x00ce,
+	0x00fe, 0x0005, 0x00f6, 0x00c6, 0x0046, 0x080c, 0x9b90, 0x2c78,
+	0x0508, 0x7e5e, 0x2b00, 0x7812, 0x7823, 0x0003, 0x0096, 0x2021,
+	0x0004, 0x0489, 0x009e, 0x2001, 0x1956, 0x200c, 0xd1fc, 0x0120,
+	0x2f60, 0x080c, 0x9be6, 0x0060, 0x2f60, 0x080c, 0x53b0, 0x0120,
+	0xd18c, 0x1160, 0x0071, 0x0130, 0x2009, 0x0052, 0x080c, 0x9c82,
+	0x9085, 0x0001, 0x004e, 0x00ce, 0x00fe, 0x0005, 0x2900, 0x7816,
+	0x0c98, 0x00c6, 0x080c, 0x489a, 0x00ce, 0x1120, 0x080c, 0x9be6,
+	0x9006, 0x0005, 0xa867, 0x0000, 0xa86b, 0x8000, 0x2900, 0x6016,
+	0x9085, 0x0001, 0x0005, 0x0096, 0x0076, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x98c7, 0x080c, 0x6471, 0x0158, 0x2001, 0xb9ba, 0x0006,
+	0x900e, 0x2400, 0x080c, 0x6bc6, 0x080c, 0x69b5, 0x000e, 0x0807,
+	0x2418, 0x080c, 0x8857, 0xbaa0, 0x0086, 0x2041, 0x0001, 0x2039,
+	0x0001, 0x2608, 0x080c, 0x8672, 0x008e, 0x080c, 0x853d, 0x2f08,
+	0x2648, 0x080c, 0xd011, 0xb93c, 0x81ff, 0x090c, 0x8749, 0x080c,
+	0x98e3, 0x012e, 0x007e, 0x009e, 0x0005, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x9b90, 0x0190, 0x660a, 0x2b08, 0x6112, 0x080c,
+	0xbd09, 0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x001f, 0x080c,
+	0x9c82, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8,
+	0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9c55, 0x01b8, 0x660a,
+	0x2b08, 0x6112, 0x080c, 0xbd09, 0x6023, 0x0008, 0x2900, 0x6016,
+	0x00f6, 0x2c78, 0x080c, 0x1669, 0x00fe, 0x2009, 0x0021, 0x080c,
+	0x9c82, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8,
+	0x2009, 0x003d, 0x00c6, 0x0126, 0x0016, 0x2091, 0x8000, 0x080c,
+	0x9b90, 0x0198, 0x660a, 0x2b08, 0x6112, 0x080c, 0xbd09, 0x6023,
+	0x0001, 0x2900, 0x6016, 0x001e, 0x0016, 0x080c, 0x9c82, 0x9085,
+	0x0001, 0x001e, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd0, 0x00c6,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x9c55, 0x0188, 0x2b08, 0x6112,
+	0x080c, 0xbd09, 0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x0000,
+	0x080c, 0x9c82, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006,
+	0x0cd8, 0x2009, 0x0044, 0x0830, 0x2009, 0x0049, 0x0818, 0x0026,
+	0x00b6, 0x6210, 0x2258, 0xba3c, 0x82ff, 0x0118, 0x8211, 0xba3e,
+	0x1140, 0xb8c0, 0x9005, 0x0128, 0xb888, 0x9005, 0x1110, 0xb88b,
+	0x0001, 0x00be, 0x002e, 0x0005, 0x0006, 0x0016, 0x6004, 0x908e,
+	0x0002, 0x0140, 0x908e, 0x0003, 0x0128, 0x908e, 0x0004, 0x0110,
+	0x9085, 0x0001, 0x001e, 0x000e, 0x0005, 0x0006, 0x0086, 0x0096,
+	0x6020, 0x9086, 0x0004, 0x01a8, 0x6014, 0x904d, 0x080c, 0xb870,
+	0x0180, 0xa864, 0x9086, 0x0139, 0x0170, 0x6020, 0x90c6, 0x0003,
+	0x0140, 0x90c6, 0x0002, 0x0128, 0xa868, 0xd0fc, 0x0110, 0x9006,
+	0x0010, 0x9085, 0x0001, 0x009e, 0x008e, 0x000e, 0x0005, 0x00c6,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x9c55, 0x0198, 0x2b08, 0x6112,
+	0x080c, 0xbd09, 0x6023, 0x0001, 0x2900, 0x6016, 0x080c, 0x302e,
+	0x2009, 0x0028, 0x080c, 0x9c82, 0x9085, 0x0001, 0x012e, 0x00ce,
+	0x0005, 0x9006, 0x0cd8, 0x9186, 0x0015, 0x11a8, 0x2011, 0x1823,
+	0x2204, 0x9086, 0x0074, 0x1178, 0x00b6, 0x080c, 0xa827, 0x00be,
+	0x080c, 0xaa66, 0x6003, 0x0001, 0x6007, 0x0029, 0x080c, 0x84ee,
+	0x080c, 0x894f, 0x0078, 0x6014, 0x0096, 0x2048, 0xa868, 0x009e,
+	0xd0fc, 0x0148, 0x2001, 0x0001, 0x080c, 0xbec8, 0x080c, 0xa59c,
+	0x080c, 0x9be6, 0x0005, 0x0096, 0x6014, 0x904d, 0x090c, 0x0d65,
+	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005, 0xa89b, 0x0004,
+	0xa867, 0x0139, 0x0126, 0x2091, 0x8000, 0x080c, 0x69b5, 0x012e,
+	0x009e, 0x080c, 0x9be6, 0x0c30, 0x0096, 0x9186, 0x0016, 0x1128,
+	0x2001, 0x0004, 0x080c, 0x61e0, 0x00e8, 0x9186, 0x0015, 0x1510,
+	0x2011, 0x1823, 0x2204, 0x9086, 0x0014, 0x11e0, 0x6010, 0x00b6,
+	0x2058, 0x080c, 0x632a, 0x00be, 0x080c, 0xab37, 0x1198, 0x6010,
+	0x00b6, 0x2058, 0xb890, 0x00be, 0x9005, 0x0160, 0x2001, 0x0006,
+	0x080c, 0x61e0, 0x6014, 0x2048, 0xa868, 0xd0fc, 0x0170, 0x080c,
+	0x9ff4, 0x0048, 0x6014, 0x2048, 0xa868, 0xd0fc, 0x0528, 0x080c,
+	0xa59c, 0x080c, 0x9be6, 0x009e, 0x0005, 0x6014, 0x6310, 0x2358,
+	0x904d, 0x090c, 0x0d65, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897,
+	0x4000, 0x900e, 0x080c, 0x6582, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0xa99a, 0x0126, 0x2091, 0x8000, 0x080c, 0x69b5,
+	0x012e, 0x080c, 0x9be6, 0x08f8, 0x6014, 0x904d, 0x090c, 0x0d65,
+	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005, 0xa89b, 0x0004,
+	0xa867, 0x0139, 0x0126, 0x2091, 0x8000, 0x080c, 0x69b5, 0x012e,
+	0x080c, 0x9be6, 0x0840, 0xa878, 0x9086, 0x0005, 0x1108, 0x0009,
+	0x0005, 0xa880, 0xc0ad, 0xa882, 0x0005, 0x604b, 0x0000, 0x6017,
+	0x0000, 0x6003, 0x0001, 0x6007, 0x0050, 0x2009, 0x8023, 0x080c,
+	0x84e7, 0x0005, 0x00c6, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x0130, 0x0066, 0x6020, 0x9084, 0x000f, 0x001b, 0x006e,
+	0x00ce, 0x0005, 0xb571, 0xbbac, 0xbbac, 0xbbaf, 0xd30b, 0xd326,
+	0xd329, 0xb571, 0xb571, 0xb571, 0xb571, 0xb571, 0xb571, 0xb571,
+	0xb571, 0xb571, 0x080c, 0x0d65, 0xa001, 0xa001, 0x0005, 0x0096,
+	0x6014, 0x904d, 0x0118, 0xa87c, 0xd0e4, 0x1110, 0x009e, 0x0010,
+	0x009e, 0x0005, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc,
+	0x0550, 0x2001, 0x1833, 0x2004, 0x9005, 0x1540, 0x00f6, 0x2c78,
+	0x080c, 0x9b90, 0x0508, 0x7810, 0x6012, 0x080c, 0xbd09, 0x7820,
+	0x9086, 0x0003, 0x0128, 0x7808, 0x603a, 0x2f00, 0x603e, 0x0020,
+	0x7808, 0x603e, 0x2f00, 0x603a, 0x602e, 0x6023, 0x0001, 0x6007,
+	0x0035, 0x6003, 0x0001, 0x795c, 0x615e, 0x2009, 0x8020, 0x080c,
+	0x84e7, 0x2f60, 0x00fe, 0x0005, 0x2f60, 0x00fe, 0x2001, 0x1960,
+	0x2004, 0x604a, 0x0005, 0x0016, 0x0096, 0x6814, 0x2048, 0x681c,
+	0xd0fc, 0xc0fc, 0x681e, 0xa87c, 0x1108, 0xd0e4, 0x0180, 0xc0e4,
+	0xa87e, 0xa877, 0x0000, 0xa893, 0x0000, 0xa88f, 0x0000, 0xd0cc,
+	0x0130, 0xc0cc, 0xa87e, 0xa878, 0x2048, 0x080c, 0x0fe1, 0x6830,
+	0x6036, 0x908e, 0x0001, 0x0148, 0x6803, 0x0002, 0x9086, 0x0005,
+	0x0170, 0x9006, 0x602e, 0x6032, 0x00d0, 0x681c, 0xc085, 0x681e,
+	0x6803, 0x0004, 0x6824, 0xc0f4, 0x9085, 0x0c00, 0x6826, 0x6814,
+	0x2048, 0xa8ac, 0x6938, 0x9102, 0xa8b0, 0x693c, 0x9103, 0x1e48,
+	0x683c, 0x602e, 0x6838, 0x9084, 0xfffc, 0x683a, 0x6032, 0x2d00,
+	0x603a, 0x6808, 0x603e, 0x6910, 0x6112, 0x695c, 0x615e, 0x6023,
+	0x0001, 0x6007, 0x0039, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c,
+	0x84e7, 0x009e, 0x001e, 0x0005, 0x6024, 0xd0d4, 0x0510, 0xd0f4,
+	0x11f8, 0x6038, 0x940a, 0x603c, 0x9303, 0x0230, 0x9105, 0x0120,
+	0x6024, 0xc0d4, 0xc0f5, 0x0098, 0x643a, 0x633e, 0xac3e, 0xab42,
+	0x0046, 0x0036, 0x2400, 0xacac, 0x9402, 0xa836, 0x2300, 0xabb0,
+	0x9303, 0xa83a, 0x003e, 0x004e, 0x6024, 0xc0d4, 0x0000, 0x6026,
+	0x0005, 0xd0f4, 0x1138, 0xa83c, 0x603a, 0xa840, 0x603e, 0x6024,
+	0xc0f5, 0x6026, 0x0005, 0x0006, 0x0016, 0x6004, 0x908e, 0x0034,
+	0x01b8, 0x908e, 0x0035, 0x01a0, 0x908e, 0x0036, 0x0188, 0x908e,
+	0x0037, 0x0170, 0x908e, 0x0038, 0x0158, 0x908e, 0x0039, 0x0140,
+	0x908e, 0x003a, 0x0128, 0x908e, 0x003b, 0x0110, 0x9085, 0x0001,
+	0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00e6,
+	0x2001, 0x195a, 0x200c, 0x8000, 0x2014, 0x2001, 0x0032, 0x080c,
+	0x842f, 0x2001, 0x195e, 0x82ff, 0x1110, 0x2011, 0x0014, 0x2202,
+	0x2001, 0x195c, 0x200c, 0x8000, 0x2014, 0x2071, 0x1944, 0x711a,
+	0x721e, 0x2001, 0x0064, 0x080c, 0x842f, 0x2001, 0x195f, 0x82ff,
+	0x1110, 0x2011, 0x0014, 0x2202, 0x2001, 0x1960, 0x9288, 0x000a,
+	0x2102, 0x2001, 0x0017, 0x080c, 0x98b8, 0x2001, 0x1a60, 0x2102,
+	0x2001, 0x0032, 0x080c, 0x15b8, 0x080c, 0x666b, 0x00ee, 0x003e,
+	0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x00e6, 0x2001,
+	0x195e, 0x2003, 0x0028, 0x2001, 0x195f, 0x2003, 0x0014, 0x2071,
+	0x1944, 0x701b, 0x0000, 0x701f, 0x07d0, 0x2001, 0x1960, 0x2009,
+	0x001e, 0x2102, 0x2001, 0x0017, 0x080c, 0x98b8, 0x2001, 0x1a60,
+	0x2102, 0x2001, 0x0032, 0x080c, 0x15b8, 0x00ee, 0x001e, 0x000e,
+	0x0005, 0x0096, 0x6060, 0x904d, 0x0110, 0x080c, 0x1061, 0x009e,
+	0x0005, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9b90,
+	0x0180, 0x2b08, 0x6112, 0x0ca9, 0x6023, 0x0001, 0x2900, 0x6016,
+	0x2009, 0x0033, 0x080c, 0x9c82, 0x9085, 0x0001, 0x012e, 0x00ce,
+	0x0005, 0x9006, 0x0cd8, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800,
+	0x9186, 0x0015, 0x1500, 0x708c, 0x9086, 0x0018, 0x11e0, 0x6014,
+	0x2048, 0xaa3c, 0xd2e4, 0x1160, 0x2c78, 0x080c, 0x8a0e, 0x01d8,
+	0x7078, 0xaa50, 0x9206, 0x1160, 0x707c, 0xaa54, 0x9206, 0x1140,
+	0x6210, 0x00b6, 0x2258, 0xbaa0, 0x00be, 0x900e, 0x080c, 0x307d,
+	0x080c, 0x9ff4, 0x0020, 0x080c, 0xa59c, 0x080c, 0x9be6, 0x00fe,
+	0x00ee, 0x009e, 0x0005, 0x705c, 0xaa54, 0x9206, 0x0d48, 0x0c80,
+	0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9b90, 0x0188, 0x2b08,
+	0x6112, 0x080c, 0xbd09, 0x6023, 0x0001, 0x2900, 0x6016, 0x2009,
+	0x004d, 0x080c, 0x9c82, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005,
+	0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0x0016, 0x080c,
+	0x9b90, 0x0180, 0x2b08, 0x6112, 0x080c, 0xbd09, 0x6023, 0x0001,
+	0x2900, 0x6016, 0x001e, 0x080c, 0x9c82, 0x9085, 0x0001, 0x012e,
+	0x00ce, 0x0005, 0x001e, 0x9006, 0x0cd0, 0x0016, 0x0026, 0x0036,
+	0x0046, 0x0056, 0x0066, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800,
+	0x9186, 0x0015, 0x1568, 0x718c, 0x6014, 0x2048, 0xa814, 0x8003,
+	0x9106, 0x1530, 0x20e1, 0x0000, 0x2001, 0x1978, 0x2003, 0x0000,
+	0x6014, 0x2048, 0xa830, 0x20a8, 0x8906, 0x8006, 0x8007, 0x9094,
+	0x003f, 0x22e8, 0x9084, 0xffc0, 0x9080, 0x001b, 0x20a0, 0x2001,
+	0x1978, 0x0016, 0x200c, 0x080c, 0xc581, 0x001e, 0xa804, 0x9005,
+	0x0110, 0x2048, 0x0c38, 0x6014, 0x2048, 0xa867, 0x0103, 0x0010,
+	0x080c, 0xa59c, 0x080c, 0x9be6, 0x00fe, 0x00ee, 0x009e, 0x006e,
+	0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005, 0x0096, 0x00e6,
+	0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x11b8, 0x708c, 0x9086,
+	0x0004, 0x1198, 0x6014, 0x2048, 0x2c78, 0x080c, 0x8a0e, 0x01a8,
+	0x7078, 0xaa74, 0x9206, 0x1130, 0x707c, 0xaa78, 0x9206, 0x1110,
+	0x080c, 0x302e, 0x080c, 0x9ff4, 0x0020, 0x080c, 0xa59c, 0x080c,
+	0x9be6, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x705c, 0xaa78, 0x9206,
+	0x0d78, 0x0c80, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186,
+	0x0015, 0x1550, 0x708c, 0x9086, 0x0004, 0x1530, 0x6014, 0x2048,
+	0x2c78, 0x080c, 0x8a0e, 0x05f0, 0x7078, 0xaacc, 0x9206, 0x1180,
+	0x707c, 0xaad0, 0x9206, 0x1160, 0x080c, 0x302e, 0x0016, 0xa998,
+	0xaab0, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x5360, 0x001e, 0x0010,
+	0x080c, 0x5149, 0x080c, 0xb870, 0x0508, 0xa87b, 0x0000, 0xa883,
+	0x0000, 0xa897, 0x4000, 0x0080, 0x080c, 0xb870, 0x01b8, 0x6014,
+	0x2048, 0x080c, 0x5149, 0x1d70, 0xa87b, 0x0030, 0xa883, 0x0000,
+	0xa897, 0x4005, 0xa89b, 0x0004, 0x0126, 0x2091, 0x8000, 0xa867,
+	0x0139, 0x080c, 0x69b5, 0x012e, 0x080c, 0x9be6, 0x00fe, 0x00ee,
+	0x009e, 0x0005, 0x705c, 0xaad0, 0x9206, 0x0930, 0x0888, 0x0016,
+	0x0026, 0xa87c, 0xd0ac, 0x0178, 0xa938, 0xaa34, 0x2100, 0x9205,
+	0x0150, 0xa890, 0x9106, 0x1118, 0xa88c, 0x9206, 0x0120, 0xa992,
+	0xaa8e, 0x9085, 0x0001, 0x002e, 0x001e, 0x0005, 0x00b6, 0x00d6,
+	0x0036, 0x080c, 0xb870, 0x0904, 0xbec4, 0x0096, 0x6314, 0x2348,
+	0xa87a, 0xa982, 0x929e, 0x4000, 0x1580, 0x6310, 0x00c6, 0x2358,
+	0x2009, 0x0000, 0xa868, 0xd0f4, 0x1140, 0x080c, 0x6582, 0x1108,
+	0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0xaa96, 0xa99a, 0x20a9,
+	0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031, 0x20a0, 0xb8b4,
+	0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098, 0x080c, 0x0fac, 0x20a9,
+	0x0004, 0xa85c, 0x9080, 0x0035, 0x20a0, 0xb8b8, 0x9080, 0x000a,
+	0x2098, 0x080c, 0x0fac, 0x00ce, 0x0090, 0xaa96, 0x3918, 0x9398,
+	0x0007, 0x231c, 0x6004, 0x9086, 0x0016, 0x0110, 0xa89b, 0x0004,
+	0xaba2, 0x6310, 0x2358, 0xb804, 0x9084, 0x00ff, 0xa89e, 0x080c,
+	0x69a9, 0x6017, 0x0000, 0x009e, 0x003e, 0x00de, 0x00be, 0x0005,
+	0x0026, 0x0036, 0x0046, 0x00b6, 0x0096, 0x00f6, 0x6214, 0x2248,
+	0x6210, 0x2258, 0x2079, 0x0260, 0x9096, 0x0000, 0x11a0, 0xb814,
+	0x9084, 0x00ff, 0x900e, 0x080c, 0x2459, 0x2118, 0x831f, 0x939c,
+	0xff00, 0x7838, 0x9084, 0x00ff, 0x931d, 0x7c3c, 0x2011, 0x8018,
+	0x080c, 0x48fa, 0x00a8, 0x9096, 0x0001, 0x1148, 0x89ff, 0x0180,
+	0xa89b, 0x000d, 0x7838, 0xa8a6, 0x783c, 0xa8aa, 0x0048, 0x9096,
+	0x0002, 0x1130, 0xa89b, 0x000d, 0x7838, 0xa8a6, 0x783c, 0xa8aa,
+	0x00fe, 0x009e, 0x00be, 0x004e, 0x003e, 0x002e, 0x0005, 0x00c6,
+	0x0026, 0x0016, 0x9186, 0x0035, 0x0110, 0x6a38, 0x0008, 0x6a2c,
+	0x080c, 0xb85e, 0x01f0, 0x2260, 0x6120, 0x9186, 0x0003, 0x0118,
+	0x9186, 0x0006, 0x1190, 0x6838, 0x9206, 0x0140, 0x683c, 0x9206,
+	0x1160, 0x6108, 0x6838, 0x9106, 0x1140, 0x0020, 0x6008, 0x693c,
+	0x9106, 0x1118, 0x6010, 0x6910, 0x9106, 0x001e, 0x002e, 0x00ce,
+	0x0005, 0x9085, 0x0001, 0x0cc8, 0xa974, 0xd1cc, 0x0188, 0x918c,
+	0x00ff, 0x918e, 0x0002, 0x1160, 0xa9a8, 0x918c, 0x0f00, 0x810f,
+	0x918e, 0x0001, 0x1128, 0xa834, 0xa938, 0x9115, 0x190c, 0xaed1,
+	0x0005, 0x0036, 0x2019, 0x0001, 0x0010, 0x0036, 0x901e, 0x0499,
+	0x01e0, 0x080c, 0xb870, 0x01c8, 0x080c, 0xba5f, 0x6037, 0x4000,
+	0x6014, 0x6017, 0x0000, 0x0096, 0x2048, 0xa87c, 0x080c, 0xba85,
+	0x1118, 0x080c, 0xa59c, 0x0040, 0xa867, 0x0103, 0xa877, 0x0000,
+	0x83ff, 0x1129, 0x080c, 0x69b5, 0x009e, 0x003e, 0x0005, 0xa880,
+	0xd0b4, 0x0128, 0xa87b, 0x0006, 0xc0ec, 0xa882, 0x0048, 0xd0bc,
+	0x0118, 0xa87b, 0x0002, 0x0020, 0xa87b, 0x0005, 0x080c, 0xbb79,
+	0xa877, 0x0000, 0x0005, 0x2001, 0x1810, 0x2004, 0xd0ec, 0x0005,
+	0x0006, 0x2001, 0x1810, 0x2004, 0xd0f4, 0x000e, 0x0005, 0x0006,
+	0x2001, 0x1810, 0x2004, 0xd0e4, 0x000e, 0x0005, 0x0036, 0x0046,
+	0x6010, 0x00b6, 0x2058, 0xbba0, 0x00be, 0x2021, 0x0007, 0x080c,
+	0x4a97, 0x004e, 0x003e, 0x0005, 0x0c51, 0x1d81, 0x0005, 0x2001,
+	0x195e, 0x2004, 0x601a, 0x0005, 0x2001, 0x1960, 0x2004, 0x604a,
+	0x0005, 0x080c, 0x9be6, 0x0804, 0x894f, 0x611c, 0xd1fc, 0xa97c,
+	0x1108, 0xd1e4, 0x0005, 0x601c, 0xd0fc, 0xa87c, 0x1108, 0xd0e4,
+	0x0005, 0x601c, 0xd0fc, 0xc0fc, 0x601e, 0xa87c, 0x1108, 0xd0e4,
+	0x0005, 0x6044, 0xd0fc, 0x1138, 0xd0bc, 0x0198, 0xc0bc, 0x6046,
+	0x6003, 0x0002, 0x0070, 0xd0ac, 0x1160, 0xd0dc, 0x1128, 0x908c,
+	0x000f, 0x9186, 0x0005, 0x1118, 0x6003, 0x0003, 0x0010, 0x6003,
+	0x0001, 0x0005, 0x00b6, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c,
+	0x0d65, 0x001b, 0x006e, 0x00be, 0x0005, 0xbffd, 0xc6dc, 0xc82b,
+	0xbffd, 0xbffd, 0xbffd, 0xbffd, 0xbffd, 0xc034, 0xc8af, 0xbffd,
+	0xbffd, 0xbffd, 0xbffd, 0xbffd, 0xbffd, 0x080c, 0x0d65, 0x0066,
+	0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0d65, 0x0013, 0x006e, 0x0005,
+	0xc018, 0xcdd0, 0xc018, 0xc018, 0xc018, 0xc018, 0xc018, 0xc018,
+	0xcd7f, 0xce22, 0xc018, 0xd446, 0xd47a, 0xd446, 0xd47a, 0xc018,
+	0x080c, 0x0d65, 0x6000, 0x9082, 0x0016, 0x1a0c, 0x0d65, 0x6000,
+	0x000a, 0x0005, 0xc032, 0xca8c, 0xcb57, 0xcb7a, 0xcbf6, 0xc032,
+	0xccf1, 0xcc7e, 0xc8b9, 0xcd57, 0xcd6c, 0xc032, 0xc032, 0xc032,
+	0xc032, 0xc032, 0x080c, 0x0d65, 0x91b2, 0x0053, 0x1a0c, 0x0d65,
+	0x2100, 0x91b2, 0x0040, 0x1a04, 0xc47f, 0x0002, 0xc07e, 0xc270,
+	0xc07e, 0xc07e, 0xc07e, 0xc279, 0xc07e, 0xc07e, 0xc07e, 0xc07e,
+	0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc07e,
+	0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc080, 0xc0e7, 0xc0f6,
+	0xc15a, 0xc185, 0xc1fd, 0xc25b, 0xc07e, 0xc07e, 0xc27c, 0xc07e,
+	0xc07e, 0xc291, 0xc29e, 0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc07e,
+	0xc321, 0xc07e, 0xc07e, 0xc335, 0xc07e, 0xc07e, 0xc2f0, 0xc07e,
+	0xc07e, 0xc07e, 0xc34d, 0xc07e, 0xc07e, 0xc07e, 0xc3ca, 0xc07e,
+	0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc07e, 0xc447, 0x080c, 0x0d65,
+	0x080c, 0x6648, 0x1150, 0x2001, 0x1836, 0x2004, 0xd0cc, 0x1128,
+	0x9084, 0x0009, 0x9086, 0x0008, 0x1140, 0x6007, 0x0009, 0x602f,
+	0x0009, 0x6017, 0x0000, 0x0804, 0xc269, 0x080c, 0x6631, 0x00e6,
+	0x00c6, 0x0036, 0x0026, 0x0016, 0x6210, 0x2258, 0xbaa0, 0x0026,
+	0x2019, 0x0029, 0x080c, 0x98c7, 0x080c, 0x8658, 0x0076, 0x903e,
+	0x080c, 0x853d, 0x2c08, 0x080c, 0xd011, 0x007e, 0x001e, 0x080c,
+	0x98e3, 0x001e, 0x002e, 0x003e, 0x00ce, 0x00ee, 0x6610, 0x2658,
+	0x080c, 0x629e, 0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006, 0x1268,
+	0x0016, 0x0026, 0x6210, 0x00b6, 0x2258, 0xbaa0, 0x00be, 0x2c08,
+	0x080c, 0xd5f2, 0x002e, 0x001e, 0x1178, 0x080c, 0xcf40, 0x1904,
+	0xc152, 0x080c, 0xcedc, 0x1120, 0x6007, 0x0008, 0x0804, 0xc269,
+	0x6007, 0x0009, 0x0804, 0xc269, 0x080c, 0xd147, 0x0128, 0x080c,
+	0xcf40, 0x0d78, 0x0804, 0xc152, 0x6017, 0x1900, 0x0c88, 0x080c,
+	0x3164, 0x1904, 0xc47c, 0x6106, 0x080c, 0xce8d, 0x6007, 0x0006,
+	0x0804, 0xc269, 0x6007, 0x0007, 0x0804, 0xc269, 0x080c, 0xd4b6,
+	0x1904, 0xc47c, 0x080c, 0x3164, 0x1904, 0xc47c, 0x00d6, 0x6610,
+	0x2658, 0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006, 0x1220, 0x2001,
+	0x0001, 0x080c, 0x61cc, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006,
+	0x0188, 0x9686, 0x0004, 0x0170, 0xbe04, 0x96b4, 0x00ff, 0x9686,
+	0x0006, 0x0140, 0x9686, 0x0004, 0x0128, 0x9686, 0x0005, 0x0110,
+	0x00de, 0x0480, 0x00e6, 0x2071, 0x0260, 0x7034, 0x9084, 0x0003,
+	0x1140, 0x7034, 0x9082, 0x0014, 0x0220, 0x7030, 0x9084, 0x0003,
+	0x0130, 0x00ee, 0x6017, 0x0000, 0x602f, 0x0007, 0x00b0, 0x00ee,
+	0x080c, 0xcfa7, 0x1190, 0x9686, 0x0006, 0x1140, 0x0026, 0x6210,
+	0x2258, 0xbaa0, 0x900e, 0x080c, 0x307d, 0x002e, 0x080c, 0x632a,
+	0x6007, 0x000a, 0x00de, 0x0804, 0xc269, 0x6007, 0x000b, 0x00de,
+	0x0804, 0xc269, 0x080c, 0x302e, 0x080c, 0xbfa4, 0x6007, 0x0001,
+	0x0804, 0xc269, 0x080c, 0xd4b6, 0x1904, 0xc47c, 0x080c, 0x3164,
+	0x1904, 0xc47c, 0x2071, 0x0260, 0x7034, 0x90b4, 0x0003, 0x1948,
+	0x90b2, 0x0014, 0x0a30, 0x7030, 0x9084, 0x0003, 0x1910, 0x6610,
+	0x2658, 0xbe04, 0x9686, 0x0707, 0x09e8, 0x0026, 0x6210, 0x2258,
+	0xbaa0, 0x900e, 0x080c, 0x307d, 0x002e, 0x6007, 0x000c, 0x2001,
+	0x0001, 0x080c, 0xd5d2, 0x0804, 0xc269, 0x080c, 0x6648, 0x1140,
+	0x2001, 0x1836, 0x2004, 0x9084, 0x0009, 0x9086, 0x0008, 0x1110,
+	0x0804, 0xc08d, 0x080c, 0x6631, 0x6610, 0x2658, 0xbe04, 0x9684,
+	0x00ff, 0x9082, 0x0006, 0x06c0, 0x1138, 0x0026, 0x2001, 0x0006,
+	0x080c, 0x620c, 0x002e, 0x0050, 0x96b4, 0xff00, 0x8637, 0x9686,
+	0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xc152, 0x080c, 0xcfb4,
+	0x1120, 0x6007, 0x000e, 0x0804, 0xc269, 0x0046, 0x6410, 0x2458,
+	0xbca0, 0x0046, 0x080c, 0x302e, 0x080c, 0xbfa4, 0x004e, 0x0016,
+	0x9006, 0x2009, 0x185c, 0x210c, 0x0048, 0x2009, 0x0029, 0x080c,
+	0xd2bc, 0x6010, 0x2058, 0xb800, 0xc0e5, 0xb802, 0x001e, 0x004e,
+	0x6007, 0x0001, 0x0804, 0xc269, 0x2001, 0x0001, 0x080c, 0x61cc,
+	0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805,
+	0x2011, 0x0270, 0x080c, 0xabda, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x9005, 0x0168, 0x96b4, 0xff00, 0x8637, 0x9682, 0x0004, 0x0a04,
+	0xc152, 0x9682, 0x0007, 0x0a04, 0xc1ae, 0x0804, 0xc152, 0x6017,
+	0x1900, 0x6007, 0x0009, 0x0804, 0xc269, 0x080c, 0x6648, 0x1140,
+	0x2001, 0x1836, 0x2004, 0x9084, 0x0009, 0x9086, 0x0008, 0x1110,
+	0x0804, 0xc08d, 0x080c, 0x6631, 0x6610, 0x2658, 0xbe04, 0x9684,
+	0x00ff, 0x0006, 0x9086, 0x0001, 0x000e, 0x0170, 0x9082, 0x0006,
+	0x0690, 0x0150, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0004, 0x0120,
+	0x9686, 0x0006, 0x1904, 0xc152, 0x080c, 0xcfe2, 0x1130, 0x080c,
+	0xcedc, 0x1118, 0x6007, 0x0010, 0x04e0, 0x0046, 0x6410, 0x2458,
+	0xbca0, 0x0046, 0x080c, 0x302e, 0x080c, 0xbfa4, 0x004e, 0x0016,
+	0x9006, 0x2009, 0x185c, 0x210c, 0x0048, 0x2009, 0x0029, 0x080c,
+	0xd2bc, 0x6010, 0x2058, 0xb800, 0xc0e5, 0xb802, 0x001e, 0x004e,
+	0x6007, 0x0001, 0x00f0, 0x080c, 0xd147, 0x0140, 0x96b4, 0xff00,
+	0x8637, 0x9686, 0x0006, 0x0980, 0x0804, 0xc152, 0x6017, 0x1900,
+	0x6007, 0x0009, 0x0070, 0x080c, 0x3164, 0x1904, 0xc47c, 0x080c,
+	0xd4b6, 0x1904, 0xc47c, 0x080c, 0xc61c, 0x1904, 0xc152, 0x6007,
+	0x0012, 0x6003, 0x0001, 0x080c, 0x84ee, 0x080c, 0x894f, 0x0005,
+	0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x84ee, 0x080c, 0x894f,
+	0x0cb0, 0x6007, 0x0005, 0x0c68, 0x080c, 0xd4b6, 0x1904, 0xc47c,
+	0x080c, 0x3164, 0x1904, 0xc47c, 0x080c, 0xc61c, 0x1904, 0xc152,
+	0x6007, 0x0020, 0x6003, 0x0001, 0x080c, 0x84ee, 0x080c, 0x894f,
+	0x0005, 0x080c, 0x3164, 0x1904, 0xc47c, 0x6007, 0x0023, 0x6003,
+	0x0001, 0x080c, 0x84ee, 0x080c, 0x894f, 0x0005, 0x080c, 0xd4b6,
+	0x1904, 0xc47c, 0x080c, 0x3164, 0x1904, 0xc47c, 0x080c, 0xc61c,
+	0x1904, 0xc152, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260, 0x7244,
+	0x9286, 0xffff, 0x0180, 0x2c08, 0x080c, 0xb85e, 0x01b0, 0x2260,
+	0x7240, 0x6008, 0x9206, 0x1188, 0x6010, 0x9190, 0x0004, 0x2214,
+	0x9206, 0x01b8, 0x0050, 0x7240, 0x2c08, 0x9006, 0x080c, 0xd28e,
+	0x1180, 0x7244, 0x9286, 0xffff, 0x01b0, 0x2160, 0x6007, 0x0026,
+	0x6017, 0x1700, 0x7214, 0x9296, 0xffff, 0x1180, 0x6007, 0x0025,
+	0x0068, 0x6020, 0x9086, 0x0007, 0x1d80, 0x6004, 0x9086, 0x0024,
+	0x1110, 0x080c, 0x9be6, 0x2160, 0x6007, 0x0025, 0x6003, 0x0001,
+	0x080c, 0x84ee, 0x080c, 0x894f, 0x00ee, 0x002e, 0x001e, 0x0005,
+	0x2001, 0x0001, 0x080c, 0x61cc, 0x0156, 0x0016, 0x0026, 0x0036,
+	0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x0276, 0x080c, 0xabda,
+	0x003e, 0x002e, 0x001e, 0x015e, 0x0120, 0x6007, 0x0031, 0x0804,
+	0xc269, 0x080c, 0xa83f, 0x080c, 0x70ba, 0x1190, 0x0006, 0x0026,
+	0x0036, 0x080c, 0x70d4, 0x1138, 0x080c, 0x73b9, 0x080c, 0x5cf7,
+	0x080c, 0x6feb, 0x0010, 0x080c, 0x708e, 0x003e, 0x002e, 0x000e,
+	0x0005, 0x080c, 0x3164, 0x1904, 0xc47c, 0x080c, 0xc61c, 0x1904,
+	0xc152, 0x6106, 0x080c, 0xc638, 0x1120, 0x6007, 0x002b, 0x0804,
+	0xc269, 0x6007, 0x002c, 0x0804, 0xc269, 0x080c, 0xd4b6, 0x1904,
+	0xc47c, 0x080c, 0x3164, 0x1904, 0xc47c, 0x080c, 0xc61c, 0x1904,
+	0xc152, 0x6106, 0x080c, 0xc63d, 0x1120, 0x6007, 0x002e, 0x0804,
+	0xc269, 0x6007, 0x002f, 0x0804, 0xc269, 0x080c, 0x3164, 0x1904,
+	0xc47c, 0x00e6, 0x00d6, 0x00c6, 0x6010, 0x2058, 0xb904, 0x9184,
+	0x00ff, 0x9086, 0x0006, 0x0158, 0x9184, 0xff00, 0x8007, 0x9086,
+	0x0006, 0x0128, 0x00ce, 0x00de, 0x00ee, 0x0804, 0xc270, 0x080c,
+	0x53ac, 0xd0e4, 0x0904, 0xc3c7, 0x2071, 0x026c, 0x7010, 0x603a,
+	0x7014, 0x603e, 0x7108, 0x720c, 0x080c, 0x6686, 0x0140, 0x6010,
+	0x2058, 0xb810, 0x9106, 0x1118, 0xb814, 0x9206, 0x0510, 0x080c,
+	0x6682, 0x15b8, 0x2069, 0x1800, 0x687c, 0x9206, 0x1590, 0x6878,
+	0x9106, 0x1578, 0x7210, 0x080c, 0xb85e, 0x0590, 0x080c, 0xc507,
+	0x0578, 0x080c, 0xd338, 0x0560, 0x622e, 0x6007, 0x0036, 0x6003,
+	0x0001, 0x2009, 0x8020, 0x080c, 0x84e7, 0x00ce, 0x00de, 0x00ee,
+	0x0005, 0x7214, 0x9286, 0xffff, 0x0150, 0x080c, 0xb85e, 0x01c0,
+	0x9280, 0x0002, 0x2004, 0x7110, 0x9106, 0x1190, 0x08e0, 0x7210,
+	0x2c08, 0x9085, 0x0001, 0x080c, 0xd28e, 0x2c10, 0x2160, 0x0140,
+	0x0890, 0x6007, 0x0037, 0x602f, 0x0009, 0x6017, 0x1500, 0x08b8,
+	0x6007, 0x0037, 0x602f, 0x0003, 0x6017, 0x1700, 0x0880, 0x6007,
+	0x0012, 0x0868, 0x080c, 0x3164, 0x1904, 0xc47c, 0x6010, 0x2058,
+	0xb804, 0x9084, 0xff00, 0x8007, 0x9086, 0x0006, 0x1904, 0xc270,
+	0x00e6, 0x00d6, 0x00c6, 0x080c, 0x53ac, 0xd0e4, 0x0904, 0xc43f,
+	0x2069, 0x1800, 0x2071, 0x026c, 0x7008, 0x603a, 0x720c, 0x623e,
+	0x9286, 0xffff, 0x1150, 0x7208, 0x00c6, 0x2c08, 0x9085, 0x0001,
+	0x080c, 0xd28e, 0x2c10, 0x00ce, 0x05e8, 0x080c, 0xb85e, 0x05d0,
+	0x7108, 0x9280, 0x0002, 0x2004, 0x9106, 0x15a0, 0x00c6, 0x0026,
+	0x2260, 0x080c, 0xb451, 0x002e, 0x00ce, 0x7118, 0x918c, 0xff00,
+	0x810f, 0x9186, 0x0001, 0x0178, 0x9186, 0x0005, 0x0118, 0x9186,
+	0x0007, 0x1198, 0x9280, 0x0005, 0x2004, 0x9005, 0x0170, 0x080c,
+	0xc507, 0x0904, 0xc3c0, 0x0056, 0x7510, 0x7614, 0x080c, 0xd351,
+	0x005e, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x6007, 0x003b, 0x602f,
+	0x0009, 0x6017, 0x2a00, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c,
+	0x84e7, 0x0c78, 0x6007, 0x003b, 0x602f, 0x0003, 0x6017, 0x0300,
+	0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84e7, 0x0c10, 0x6007,
+	0x003b, 0x602f, 0x000b, 0x6017, 0x0000, 0x0804, 0xc397, 0x00e6,
+	0x0026, 0x080c, 0x6648, 0x0550, 0x080c, 0x6631, 0x080c, 0xd528,
+	0x1518, 0x2071, 0x1800, 0x70d8, 0x9085, 0x0003, 0x70da, 0x00f6,
+	0x2079, 0x0100, 0x72ac, 0x9284, 0x00ff, 0x707a, 0x78e6, 0x9284,
+	0xff00, 0x727c, 0x9205, 0x707e, 0x78ea, 0x00fe, 0x70e3, 0x0000,
+	0x080c, 0x6686, 0x0120, 0x2011, 0x19e1, 0x2013, 0x07d0, 0xd0ac,
+	0x1128, 0x080c, 0x2e09, 0x0010, 0x080c, 0xd55a, 0x002e, 0x00ee,
+	0x080c, 0x9be6, 0x0804, 0xc26f, 0x080c, 0x9be6, 0x0005, 0x2600,
+	0x0002, 0xc493, 0xc493, 0xc493, 0xc493, 0xc493, 0xc495, 0xc493,
+	0xc493, 0xc493, 0xc493, 0xc4b2, 0xc493, 0xc493, 0xc493, 0xc4c4,
+	0xc4d1, 0xc502, 0xc493, 0x080c, 0x0d65, 0x080c, 0xd4b6, 0x1d20,
+	0x080c, 0x3164, 0x1d08, 0x080c, 0xc61c, 0x1148, 0x7038, 0x6016,
+	0x6007, 0x0045, 0x6003, 0x0001, 0x080c, 0x84ee, 0x0005, 0x080c,
+	0x302e, 0x080c, 0xbfa4, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x84ee, 0x0005, 0x080c, 0xd4b6, 0x1938, 0x080c, 0x3164, 0x1920,
+	0x080c, 0xc61c, 0x1d60, 0x703c, 0x6016, 0x6007, 0x004a, 0x6003,
+	0x0001, 0x080c, 0x84ee, 0x0005, 0x080c, 0xc524, 0x0904, 0xc47c,
+	0x6007, 0x004e, 0x6003, 0x0001, 0x080c, 0x84ee, 0x080c, 0x894f,
+	0x0005, 0x6007, 0x004f, 0x6017, 0x0000, 0x7134, 0x918c, 0x00ff,
+	0x81ff, 0x0508, 0x9186, 0x0001, 0x1160, 0x7140, 0x2001, 0x1995,
+	0x2004, 0x9106, 0x11b0, 0x7144, 0x2001, 0x1996, 0x2004, 0x9106,
+	0x0190, 0x9186, 0x0002, 0x1168, 0x2011, 0x0276, 0x20a9, 0x0004,
+	0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xabee, 0x009e,
+	0x0110, 0x6017, 0x0001, 0x6003, 0x0001, 0x080c, 0x84ee, 0x080c,
+	0x894f, 0x0005, 0x6007, 0x0050, 0x703c, 0x6016, 0x0ca0, 0x0016,
+	0x00e6, 0x2071, 0x0260, 0x00b6, 0x00c6, 0x2260, 0x6010, 0x2058,
+	0xb8c4, 0xd084, 0x0150, 0x7128, 0x6050, 0x9106, 0x1120, 0x712c,
+	0x604c, 0x9106, 0x0110, 0x9006, 0x0010, 0x9085, 0x0001, 0x00ce,
+	0x00be, 0x00ee, 0x001e, 0x0005, 0x0016, 0x0096, 0x0086, 0x00e6,
+	0x01c6, 0x01d6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x708c,
+	0x908a, 0x00f9, 0x16e8, 0x20e1, 0x0000, 0x2001, 0x1978, 0x2003,
+	0x0000, 0x080c, 0x1048, 0x05a0, 0x2900, 0x6016, 0x708c, 0x8004,
+	0xa816, 0x908a, 0x001e, 0x02d0, 0xa833, 0x001e, 0x20a9, 0x001e,
+	0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0, 0x2001, 0x1978,
+	0x0016, 0x200c, 0x0471, 0x001e, 0x2940, 0x080c, 0x1048, 0x01c0,
+	0x2900, 0xa006, 0x2100, 0x81ff, 0x0180, 0x0c18, 0xa832, 0x20a8,
+	0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0, 0x2001, 0x1978,
+	0x0016, 0x200c, 0x00b1, 0x001e, 0x0000, 0x9085, 0x0001, 0x0048,
+	0x2071, 0x1800, 0x708f, 0x0000, 0x6014, 0x2048, 0x080c, 0x0fe1,
+	0x9006, 0x012e, 0x01de, 0x01ce, 0x00ee, 0x008e, 0x009e, 0x001e,
+	0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00c6, 0x918c, 0xffff,
+	0x11a8, 0x080c, 0x2054, 0x2099, 0x026c, 0x2001, 0x0014, 0x3518,
+	0x9312, 0x1218, 0x23a8, 0x4003, 0x00f8, 0x20a8, 0x4003, 0x22a8,
+	0x8108, 0x080c, 0x2054, 0x2099, 0x0260, 0x0ca8, 0x080c, 0x2054,
+	0x2061, 0x1978, 0x6004, 0x2098, 0x6008, 0x3518, 0x9312, 0x1218,
+	0x23a8, 0x4003, 0x0048, 0x20a8, 0x4003, 0x22a8, 0x8108, 0x080c,
+	0x2054, 0x2099, 0x0260, 0x0ca8, 0x2061, 0x1978, 0x2019, 0x0280,
+	0x3300, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0260, 0x6006,
+	0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a, 0x00ce,
+	0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x0026,
+	0x0036, 0x00c6, 0x81ff, 0x11b8, 0x080c, 0x206c, 0x20a1, 0x024c,
+	0x2001, 0x0014, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x0418,
+	0x20a8, 0x4003, 0x82ff, 0x01f8, 0x22a8, 0x8108, 0x080c, 0x206c,
+	0x20a1, 0x0240, 0x0c98, 0x080c, 0x206c, 0x2061, 0x197b, 0x6004,
+	0x20a0, 0x6008, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x0058,
+	0x20a8, 0x4003, 0x82ff, 0x0138, 0x22a8, 0x8108, 0x080c, 0x206c,
+	0x20a1, 0x0240, 0x0c98, 0x2061, 0x197b, 0x2019, 0x0260, 0x3400,
+	0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0240, 0x6006, 0x8108,
+	0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a, 0x00ce, 0x003e,
+	0x002e, 0x001e, 0x000e, 0x0005, 0x00b6, 0x0066, 0x6610, 0x2658,
+	0xbe04, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0170, 0x9686,
+	0x0004, 0x0158, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006, 0x0128,
+	0x9686, 0x0004, 0x0110, 0x9085, 0x0001, 0x006e, 0x00be, 0x0005,
+	0x00d6, 0x080c, 0xc6b2, 0x00de, 0x0005, 0x00d6, 0x080c, 0xc6bf,
+	0x1520, 0x680c, 0x908c, 0xff00, 0x6820, 0x9084, 0x00ff, 0x9115,
+	0x6216, 0x6824, 0x602e, 0xd1e4, 0x0130, 0x9006, 0x080c, 0xd5d2,
+	0x2009, 0x0001, 0x0078, 0xd1ec, 0x0180, 0x6920, 0x918c, 0x00ff,
+	0x6824, 0x080c, 0x2459, 0x1148, 0x2001, 0x0001, 0x080c, 0xd5d2,
+	0x2110, 0x900e, 0x080c, 0x307d, 0x0018, 0x9085, 0x0001, 0x0008,
+	0x9006, 0x00de, 0x0005, 0x00b6, 0x00c6, 0x080c, 0x9c55, 0x0598,
+	0x0016, 0x0026, 0x00c6, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c,
+	0x080c, 0x2459, 0x1568, 0x080c, 0x622f, 0x1550, 0xbe12, 0xbd16,
+	0x00ce, 0x002e, 0x001e, 0x2b00, 0x6012, 0x080c, 0xd4b6, 0x11c8,
+	0x080c, 0x3164, 0x11b0, 0x080c, 0xc61c, 0x0500, 0x2001, 0x0007,
+	0x080c, 0x61e0, 0x2001, 0x0007, 0x080c, 0x620c, 0x6017, 0x0000,
+	0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x84ee,
+	0x0010, 0x080c, 0x9be6, 0x9085, 0x0001, 0x00ce, 0x00be, 0x0005,
+	0x080c, 0x9be6, 0x00ce, 0x002e, 0x001e, 0x0ca8, 0x080c, 0x9be6,
+	0x9006, 0x0c98, 0x2069, 0x026d, 0x6800, 0x9082, 0x0010, 0x1228,
+	0x6017, 0x0000, 0x9085, 0x0001, 0x0008, 0x9006, 0x0005, 0x6017,
+	0x0000, 0x2069, 0x026c, 0x6808, 0x9084, 0xff00, 0x9086, 0x0800,
+	0x1190, 0x6904, 0x9186, 0x0018, 0x0118, 0x9186, 0x0014, 0x1158,
+	0x810f, 0x6800, 0x9084, 0x00ff, 0x910d, 0x6162, 0x908e, 0x0014,
+	0x0110, 0x908e, 0x0010, 0x0005, 0x6004, 0x90b2, 0x0053, 0x1a0c,
+	0x0d65, 0x91b6, 0x0013, 0x1130, 0x2008, 0x91b2, 0x0040, 0x1a04,
+	0xc7ff, 0x0092, 0x91b6, 0x0027, 0x0120, 0x91b6, 0x0014, 0x190c,
+	0x0d65, 0x2001, 0x0007, 0x080c, 0x620c, 0x080c, 0x8891, 0x080c,
+	0x9c20, 0x080c, 0x894f, 0x0005, 0xc73c, 0xc73e, 0xc73c, 0xc73c,
+	0xc73c, 0xc73e, 0xc74b, 0xc7fc, 0xc79b, 0xc7fc, 0xc7ad, 0xc7fc,
+	0xc74b, 0xc7fc, 0xc7f4, 0xc7fc, 0xc7f4, 0xc7fc, 0xc7fc, 0xc73c,
+	0xc73c, 0xc73c, 0xc73c, 0xc73c, 0xc73c, 0xc73c, 0xc73c, 0xc73c,
+	0xc73c, 0xc73c, 0xc73e, 0xc73c, 0xc7fc, 0xc73c, 0xc73c, 0xc7fc,
+	0xc73c, 0xc7f9, 0xc7fc, 0xc73c, 0xc73c, 0xc73c, 0xc73c, 0xc7fc,
+	0xc7fc, 0xc73c, 0xc7fc, 0xc7fc, 0xc73c, 0xc746, 0xc73c, 0xc73c,
+	0xc73c, 0xc73c, 0xc7f8, 0xc7fc, 0xc73c, 0xc73c, 0xc7fc, 0xc7fc,
+	0xc73c, 0xc73c, 0xc73c, 0xc73c, 0x080c, 0x0d65, 0x080c, 0xbfa7,
+	0x6003, 0x0002, 0x080c, 0x894f, 0x0804, 0xc7fe, 0x9006, 0x080c,
+	0x61cc, 0x0804, 0xc7fc, 0x080c, 0x6682, 0x1904, 0xc7fc, 0x9006,
+	0x080c, 0x61cc, 0x6010, 0x2058, 0xb810, 0x9086, 0x00ff, 0x1140,
+	0x00f6, 0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6, 0x00fe, 0x0428,
+	0x6010, 0x2058, 0xb884, 0x9005, 0x1178, 0x080c, 0xbf8f, 0x1904,
+	0xc7fc, 0x0036, 0x0046, 0xbba0, 0x2021, 0x0007, 0x080c, 0x4a97,
+	0x004e, 0x003e, 0x0804, 0xc7fc, 0x080c, 0x3195, 0x1904, 0xc7fc,
+	0x2001, 0x1800, 0x2004, 0x9086, 0x0002, 0x1138, 0x00f6, 0x2079,
+	0x1800, 0x78a4, 0x8000, 0x78a6, 0x00fe, 0x2001, 0x0002, 0x080c,
+	0x61e0, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c,
+	0x84ee, 0x080c, 0x894f, 0x6110, 0x2158, 0x2009, 0x0001, 0x080c,
+	0x817a, 0x0804, 0xc7fe, 0x6610, 0x2658, 0xbe04, 0x96b4, 0xff00,
+	0x8637, 0x9686, 0x0006, 0x0904, 0xc7fc, 0x9686, 0x0004, 0x0904,
+	0xc7fc, 0x2001, 0x0004, 0x0804, 0xc7fa, 0x2001, 0x1800, 0x2004,
+	0x9086, 0x0003, 0x1158, 0x0036, 0x0046, 0x6010, 0x2058, 0xbba0,
+	0x2021, 0x0006, 0x080c, 0x4a97, 0x004e, 0x003e, 0x2001, 0x0006,
+	0x080c, 0xc818, 0x6610, 0x2658, 0xbe04, 0x0066, 0x96b4, 0xff00,
+	0x8637, 0x9686, 0x0006, 0x006e, 0x0168, 0x2001, 0x0006, 0x080c,
+	0x620c, 0x9284, 0x00ff, 0x908e, 0x0007, 0x1120, 0x2001, 0x0006,
+	0x080c, 0x61e0, 0x080c, 0x6682, 0x11f8, 0x2001, 0x1836, 0x2004,
+	0xd0a4, 0x01d0, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006, 0x01a0,
+	0x00f6, 0x2079, 0x1800, 0x78a4, 0x8000, 0x78a6, 0x00fe, 0x0804,
+	0xc785, 0x2001, 0x0004, 0x0030, 0x2001, 0x0006, 0x0409, 0x0020,
+	0x0018, 0x0010, 0x080c, 0x620c, 0x080c, 0x9be6, 0x0005, 0x2600,
+	0x0002, 0xc813, 0xc813, 0xc813, 0xc813, 0xc813, 0xc815, 0xc813,
+	0xc813, 0xc813, 0xc813, 0xc815, 0xc813, 0xc813, 0xc813, 0xc815,
+	0xc815, 0xc815, 0xc815, 0x080c, 0x0d65, 0x080c, 0x9be6, 0x0005,
+	0x0016, 0x00b6, 0x00d6, 0x6110, 0x2158, 0xb900, 0xd184, 0x0138,
+	0x080c, 0x61e0, 0x9006, 0x080c, 0x61cc, 0x080c, 0x305d, 0x00de,
+	0x00be, 0x001e, 0x0005, 0x6610, 0x2658, 0xb804, 0x9084, 0xff00,
+	0x8007, 0x90b2, 0x000c, 0x1a0c, 0x0d65, 0x91b6, 0x0015, 0x1110,
+	0x003b, 0x0028, 0x91b6, 0x0016, 0x190c, 0x0d65, 0x006b, 0x0005,
+	0xa67d, 0xa67d, 0xa67d, 0xa67d, 0xc8ad, 0xa67d, 0xc897, 0xc858,
+	0xa67d, 0xa67d, 0xa67d, 0xa67d, 0xa67d, 0xa67d, 0xa67d, 0xa67d,
+	0xc8ad, 0xa67d, 0xc897, 0xc89e, 0xa67d, 0xa67d, 0xa67d, 0xa67d,
+	0x00f6, 0x080c, 0x6682, 0x11d8, 0x080c, 0xbf8f, 0x11c0, 0x6010,
+	0x905d, 0x01a8, 0xb884, 0x9005, 0x0190, 0x9006, 0x080c, 0x61cc,
+	0x2001, 0x0002, 0x080c, 0x61e0, 0x6023, 0x0001, 0x6003, 0x0001,
+	0x6007, 0x0002, 0x080c, 0x84ee, 0x080c, 0x894f, 0x00f0, 0x2011,
+	0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2459, 0x11b0, 0x080c,
+	0x628f, 0x0118, 0x080c, 0x9be6, 0x0080, 0xb810, 0x0006, 0xb814,
+	0x0006, 0xb884, 0x0006, 0x080c, 0x5d11, 0x000e, 0xb886, 0x000e,
+	0xb816, 0x000e, 0xb812, 0x080c, 0x9be6, 0x00fe, 0x0005, 0x6604,
+	0x96b6, 0x001e, 0x1110, 0x080c, 0x9be6, 0x0005, 0x080c, 0xaa63,
+	0x1148, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x84ee, 0x080c,
+	0x894f, 0x0010, 0x080c, 0x9be6, 0x0005, 0x0804, 0x9be6, 0x6004,
+	0x908a, 0x0053, 0x1a0c, 0x0d65, 0x080c, 0x8891, 0x080c, 0x9c20,
+	0x0005, 0x9182, 0x0040, 0x0002, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0,
+	0xc8d2, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0,
+	0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0, 0xc8d0,
+	0x080c, 0x0d65, 0x0096, 0x00b6, 0x00d6, 0x00e6, 0x00f6, 0x0046,
+	0x0026, 0x6210, 0x2258, 0xb8ac, 0x9005, 0x11b0, 0x6007, 0x0044,
+	0x2071, 0x0260, 0x7444, 0x94a4, 0xff00, 0x0904, 0xc939, 0x080c,
+	0xd5c6, 0x1170, 0x9486, 0x2000, 0x1158, 0x2009, 0x0001, 0x2011,
+	0x0200, 0x080c, 0x8401, 0x0020, 0x9026, 0x080c, 0xd4fb, 0x0c30,
+	0x080c, 0x102f, 0x090c, 0x0d65, 0x6003, 0x0007, 0xa867, 0x010d,
+	0x9006, 0xa802, 0xa86a, 0xac8a, 0x2c00, 0xa88e, 0x6008, 0xa8e2,
+	0x6010, 0x2058, 0xb8a0, 0x7130, 0xa97a, 0x0016, 0xa876, 0xa87f,
+	0x0000, 0xa883, 0x0000, 0xa887, 0x0036, 0x080c, 0x69b5, 0x001e,
+	0x080c, 0xd5c6, 0x1904, 0xc999, 0x9486, 0x2000, 0x1130, 0x2019,
+	0x0017, 0x080c, 0xd234, 0x0804, 0xc999, 0x9486, 0x0200, 0x1120,
+	0x080c, 0xd1c4, 0x0804, 0xc999, 0x9486, 0x0400, 0x0120, 0x9486,
+	0x1000, 0x1904, 0xc999, 0x2019, 0x0002, 0x080c, 0xd1e3, 0x0804,
+	0xc999, 0x2069, 0x1a46, 0x6a00, 0xd284, 0x0904, 0xca03, 0x9284,
+	0x0300, 0x1904, 0xc9fc, 0x6804, 0x9005, 0x0904, 0xc9e4, 0x2d78,
+	0x6003, 0x0007, 0x080c, 0x1048, 0x0904, 0xc9a5, 0x7800, 0xd08c,
+	0x1118, 0x7804, 0x8001, 0x7806, 0x6017, 0x0000, 0x2001, 0x180f,
+	0x2004, 0xd084, 0x1904, 0xca07, 0x9006, 0xa802, 0xa867, 0x0116,
+	0xa86a, 0x6008, 0xa8e2, 0x2c00, 0xa87a, 0x6010, 0x2058, 0xb8a0,
+	0x7130, 0xa9b6, 0xa876, 0xb928, 0xa9ba, 0xb92c, 0xa9be, 0xb930,
+	0xa9c2, 0xb934, 0xa9c6, 0xa883, 0x003d, 0x7044, 0x9084, 0x0003,
+	0x9080, 0xc9a1, 0x2005, 0xa87e, 0x20a9, 0x000a, 0x2001, 0x0270,
+	0xaa5c, 0x9290, 0x0021, 0x2009, 0x0205, 0x200b, 0x0080, 0x20e1,
+	0x0000, 0xab60, 0x23e8, 0x2098, 0x22a0, 0x4003, 0x200b, 0x0000,
+	0x2001, 0x027a, 0x200c, 0xa9b2, 0x8000, 0x200c, 0xa9ae, 0x080c,
+	0x69b8, 0x002e, 0x004e, 0x00fe, 0x00ee, 0x00de, 0x00be, 0x009e,
+	0x0005, 0x0000, 0x0080, 0x0040, 0x0000, 0x2001, 0x1810, 0x2004,
+	0xd084, 0x0120, 0x080c, 0x102f, 0x1904, 0xc94e, 0x6017, 0xf100,
+	0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022, 0x080c, 0x84e7,
+	0x0c00, 0x2069, 0x0260, 0x6848, 0x9084, 0xff00, 0x9086, 0x1200,
+	0x1198, 0x686c, 0x9084, 0x00ff, 0x0016, 0x6114, 0x918c, 0xf700,
+	0x910d, 0x6116, 0x001e, 0x6003, 0x0001, 0x6007, 0x0043, 0x2009,
+	0xa025, 0x080c, 0x84e7, 0x0828, 0x6868, 0x602e, 0x686c, 0x6032,
+	0x6017, 0xf200, 0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022,
+	0x080c, 0x84e7, 0x0804, 0xc999, 0x2001, 0x180e, 0x2004, 0xd0ec,
+	0x0120, 0x2011, 0x8049, 0x080c, 0x48fa, 0x6017, 0xf300, 0x0010,
+	0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x2009, 0xa022,
+	0x080c, 0x84e7, 0x0804, 0xc999, 0x6017, 0xf500, 0x0c98, 0x6017,
+	0xf600, 0x0804, 0xc9b9, 0x6017, 0xf200, 0x0804, 0xc9b9, 0xa867,
+	0x0146, 0xa86b, 0x0000, 0x6008, 0xa886, 0x2c00, 0xa87a, 0x7044,
+	0x9084, 0x0003, 0x9080, 0xc9a1, 0x2005, 0xa87e, 0x2928, 0x6010,
+	0x2058, 0xb8a0, 0xa876, 0xb828, 0xa88a, 0xb82c, 0xa88e, 0xb830,
+	0xa892, 0xb834, 0xa896, 0xa883, 0x003d, 0x2009, 0x0205, 0x2104,
+	0x9085, 0x0080, 0x200a, 0x20e1, 0x0000, 0x2011, 0x0210, 0x2214,
+	0x9294, 0x0fff, 0xaaa2, 0x9282, 0x0111, 0x1a0c, 0x0d65, 0x8210,
+	0x821c, 0x2001, 0x026c, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0029, 0x20a0, 0x2011, 0xca83, 0x2041, 0x0001, 0x223d, 0x9784,
+	0x00ff, 0x9322, 0x1208, 0x2300, 0x20a8, 0x4003, 0x931a, 0x0530,
+	0x8210, 0xd7fc, 0x1130, 0x8d68, 0x2d0a, 0x2001, 0x0260, 0x2098,
+	0x0c68, 0x2950, 0x080c, 0x1048, 0x0170, 0x2900, 0xb002, 0xa867,
+	0x0147, 0xa86b, 0x0000, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b,
+	0x20a0, 0x8840, 0x08d8, 0x2548, 0xa800, 0x902d, 0x0118, 0x080c,
+	0x1061, 0x0cc8, 0x080c, 0x1061, 0x0804, 0xc9a5, 0x2548, 0x8847,
+	0x9885, 0x0046, 0xa866, 0x2009, 0x0205, 0x200b, 0x0000, 0x080c,
+	0xd267, 0x0804, 0xc999, 0x8010, 0x0004, 0x801a, 0x0006, 0x8018,
+	0x0008, 0x8016, 0x000a, 0x8014, 0x9186, 0x0013, 0x1160, 0x6004,
+	0x908a, 0x0057, 0x1a0c, 0x0d65, 0x9082, 0x0040, 0x0a0c, 0x0d65,
+	0x2008, 0x0804, 0xcb0f, 0x9186, 0x0051, 0x0108, 0x0040, 0x080c,
+	0x9ab6, 0x01e8, 0x9086, 0x0002, 0x0904, 0xcb57, 0x00c0, 0x9186,
+	0x0027, 0x0180, 0x9186, 0x0048, 0x0128, 0x9186, 0x0014, 0x0150,
+	0x190c, 0x0d65, 0x080c, 0x9ab6, 0x0150, 0x9086, 0x0004, 0x0904,
+	0xcbf6, 0x0028, 0x6004, 0x9082, 0x0040, 0x2008, 0x001a, 0x080c,
+	0x9c9f, 0x0005, 0xcad6, 0xcad8, 0xcad8, 0xcaff, 0xcad6, 0xcad6,
+	0xcad6, 0xcad6, 0xcad6, 0xcad6, 0xcad6, 0xcad6, 0xcad6, 0xcad6,
+	0xcad6, 0xcad6, 0xcad6, 0xcad6, 0xcad6, 0xcad6, 0x080c, 0x0d65,
+	0x080c, 0x8891, 0x080c, 0x894f, 0x0036, 0x0096, 0x6014, 0x904d,
+	0x01d8, 0x080c, 0xb870, 0x01c0, 0x6003, 0x0002, 0x6010, 0x00b6,
 	0x2058, 0xb800, 0x00be, 0xd0bc, 0x1178, 0x2019, 0x0004, 0x080c,
-	0xd22f, 0x6017, 0x0000, 0x6018, 0x9005, 0x1120, 0x2001, 0x1957,
+	0xd267, 0x6017, 0x0000, 0x6018, 0x9005, 0x1120, 0x2001, 0x195f,
 	0x2004, 0x601a, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x0096,
-	0x080c, 0x885d, 0x080c, 0x891b, 0x080c, 0xb842, 0x0120, 0x6014,
-	0x2048, 0x080c, 0x1054, 0x080c, 0x9c14, 0x009e, 0x0005, 0x0002,
-	0xcaf3, 0xcb08, 0xcaf5, 0xcb1d, 0xcaf3, 0xcaf3, 0xcaf3, 0xcaf3,
-	0xcaf3, 0xcaf3, 0xcaf3, 0xcaf3, 0xcaf3, 0xcaf3, 0xcaf3, 0xcaf3,
-	0xcaf3, 0xcaf3, 0xcaf3, 0x080c, 0x0d65, 0x0096, 0x6014, 0x2048,
-	0xa87c, 0xd0b4, 0x0138, 0x6003, 0x0007, 0x2009, 0x0043, 0x080c,
-	0x9c76, 0x0010, 0x6003, 0x0004, 0x080c, 0x891b, 0x009e, 0x0005,
-	0x080c, 0xb842, 0x0138, 0x6114, 0x0096, 0x2148, 0xa97c, 0x009e,
-	0xd1ec, 0x1138, 0x080c, 0x83a2, 0x080c, 0x9bda, 0x080c, 0x891b,
-	0x0005, 0x080c, 0xd487, 0x0db0, 0x0cc8, 0x6003, 0x0001, 0x6007,
-	0x0041, 0x2009, 0xa022, 0x080c, 0x84b3, 0x0005, 0x9182, 0x0040,
-	0x0002, 0xcb3c, 0xcb3e, 0xcb3c, 0xcb3c, 0xcb3c, 0xcb3c, 0xcb3c,
-	0xcb3c, 0xcb3c, 0xcb3c, 0xcb3c, 0xcb3c, 0xcb3c, 0xcb3c, 0xcb3c,
-	0xcb3c, 0xcb3c, 0xcb3f, 0xcb3c, 0x080c, 0x0d65, 0x0005, 0x00d6,
-	0x080c, 0x83a2, 0x00de, 0x080c, 0xd4df, 0x080c, 0x9bda, 0x0005,
-	0x9182, 0x0040, 0x0002, 0xcb5e, 0xcb5e, 0xcb5e, 0xcb5e, 0xcb5e,
-	0xcb5e, 0xcb5e, 0xcb5e, 0xcb5e, 0xcb60, 0xcb8b, 0xcb5e, 0xcb5e,
-	0xcb5e, 0xcb5e, 0xcb8b, 0xcb5e, 0xcb5e, 0xcb5e, 0x080c, 0x0d65,
-	0x6014, 0x0096, 0x2048, 0xa87c, 0xd0fc, 0x0168, 0x908c, 0x0003,
-	0x918e, 0x0002, 0x0180, 0x6144, 0xd1e4, 0x1168, 0x2009, 0x0041,
-	0x009e, 0x0804, 0xcc4b, 0x6003, 0x0007, 0x601b, 0x0000, 0x080c,
-	0x83a2, 0x009e, 0x0005, 0x6014, 0x2048, 0xa97c, 0xd1ec, 0x1130,
-	0x080c, 0x83a2, 0x080c, 0x9bda, 0x009e, 0x0005, 0x080c, 0xd487,
-	0x0db8, 0x009e, 0x0005, 0x2001, 0x180c, 0x200c, 0xc1d4, 0x2102,
-	0x0036, 0x080c, 0x88b8, 0x080c, 0x891b, 0x6014, 0x0096, 0x2048,
-	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0188, 0xa87c,
-	0x9084, 0x0003, 0x9086, 0x0002, 0x0140, 0xa8ac, 0x6330, 0x931a,
-	0x6332, 0xa8b0, 0x632c, 0x931b, 0x632e, 0x6003, 0x0002, 0x0080,
-	0x2019, 0x0004, 0x080c, 0xd22f, 0x6018, 0x9005, 0x1128, 0x2001,
-	0x1957, 0x2004, 0x8003, 0x601a, 0x6017, 0x0000, 0x6003, 0x0007,
-	0x009e, 0x003e, 0x0005, 0x9182, 0x0040, 0x0002, 0xcbda, 0xcbda,
-	0xcbda, 0xcbda, 0xcbda, 0xcbda, 0xcbda, 0xcbda, 0xcbdc, 0xcbda,
-	0xcbda, 0xcbda, 0xcbda, 0xcbda, 0xcbda, 0xcbda, 0xcbda, 0xcbda,
-	0xcbda, 0xcc27, 0x080c, 0x0d65, 0x6014, 0x0096, 0x2048, 0xa834,
-	0xaa38, 0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1bc, 0x1190,
-	0x920d, 0x1518, 0xa87c, 0xd0fc, 0x0128, 0x2009, 0x0041, 0x009e,
-	0x0804, 0xcc4b, 0x6003, 0x0007, 0x601b, 0x0000, 0x080c, 0x83a2,
-	0x009e, 0x0005, 0x6124, 0xd1f4, 0x1d58, 0x0006, 0x0046, 0xacac,
-	0x9422, 0xa9b0, 0x2200, 0x910b, 0x6030, 0x9420, 0x6432, 0x602c,
-	0x9109, 0x612e, 0x004e, 0x000e, 0x08d8, 0x6110, 0x00b6, 0x2158,
-	0xb900, 0x00be, 0xd1bc, 0x1178, 0x2009, 0x180e, 0x210c, 0xd19c,
-	0x0118, 0x6003, 0x0007, 0x0010, 0x6003, 0x0006, 0x00e9, 0x080c,
-	0x83a4, 0x009e, 0x0005, 0x6003, 0x0002, 0x009e, 0x0005, 0x6024,
-	0xd0f4, 0x0128, 0x080c, 0x15a2, 0x1904, 0xcbdc, 0x0005, 0x6014,
-	0x0096, 0x2048, 0xa834, 0xa938, 0x009e, 0x9105, 0x1120, 0x080c,
-	0x15a2, 0x1904, 0xcbdc, 0x0005, 0xd2fc, 0x0140, 0x8002, 0x8000,
-	0x8212, 0x9291, 0x0000, 0x2009, 0x0009, 0x0010, 0x2009, 0x0015,
-	0xaa9a, 0xa896, 0x0005, 0x9182, 0x0040, 0x0208, 0x0062, 0x9186,
-	0x0013, 0x0120, 0x9186, 0x0014, 0x190c, 0x0d65, 0x6024, 0xd0dc,
-	0x090c, 0x0d65, 0x0005, 0xcc6e, 0xcc7a, 0xcc86, 0xcc92, 0xcc6e,
-	0xcc6e, 0xcc6e, 0xcc6e, 0xcc75, 0xcc70, 0xcc70, 0xcc6e, 0xcc6e,
-	0xcc6e, 0xcc6e, 0xcc70, 0xcc6e, 0xcc70, 0xcc6e, 0x080c, 0x0d65,
-	0x6024, 0xd0dc, 0x090c, 0x0d65, 0x0005, 0x6014, 0x9005, 0x190c,
-	0x0d65, 0x0005, 0x6003, 0x0001, 0x6106, 0x0126, 0x2091, 0x8000,
-	0x2009, 0xa022, 0x080c, 0x8495, 0x012e, 0x0005, 0x6003, 0x0004,
-	0x6106, 0x0126, 0x2091, 0x8000, 0x2009, 0xa001, 0x080c, 0x84b3,
-	0x012e, 0x0005, 0x6003, 0x0003, 0x6106, 0x080c, 0x1ab2, 0x0126,
-	0x2091, 0x8000, 0x6014, 0x0096, 0x2048, 0xa87c, 0xd0fc, 0x0188,
-	0x9084, 0x0003, 0x9086, 0x0002, 0x01a0, 0x6024, 0xd0cc, 0x1148,
-	0xd0c4, 0x1138, 0xa8a8, 0x9005, 0x1120, 0x6144, 0x918d, 0xb035,
-	0x0018, 0x6144, 0x918d, 0xa035, 0x009e, 0x080c, 0x84fa, 0x012e,
-	0x0005, 0x6144, 0x918d, 0xa032, 0x0cb8, 0x0126, 0x2091, 0x8000,
-	0x0036, 0x0096, 0x9182, 0x0040, 0x0023, 0x009e, 0x003e, 0x012e,
-	0x0005, 0xccd9, 0xccdb, 0xccf0, 0xcd0a, 0xccd9, 0xccd9, 0xccd9,
-	0xccd9, 0xccd9, 0xccd9, 0xccd9, 0xccd9, 0xccd9, 0xccd9, 0xccd9,
-	0xccd9, 0x080c, 0x0d65, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0510,
+	0x080c, 0x8891, 0x080c, 0x894f, 0x080c, 0xb870, 0x0120, 0x6014,
+	0x2048, 0x080c, 0x1061, 0x080c, 0x9c20, 0x009e, 0x0005, 0x0002,
+	0xcb24, 0xcb39, 0xcb26, 0xcb4e, 0xcb24, 0xcb24, 0xcb24, 0xcb24,
+	0xcb24, 0xcb24, 0xcb24, 0xcb24, 0xcb24, 0xcb24, 0xcb24, 0xcb24,
+	0xcb24, 0xcb24, 0xcb24, 0xcb24, 0x080c, 0x0d65, 0x0096, 0x6014,
+	0x2048, 0xa87c, 0xd0b4, 0x0138, 0x6003, 0x0007, 0x2009, 0x0043,
+	0x080c, 0x9c82, 0x0010, 0x6003, 0x0004, 0x080c, 0x894f, 0x009e,
+	0x0005, 0x080c, 0xb870, 0x0138, 0x6114, 0x0096, 0x2148, 0xa97c,
+	0x009e, 0xd1ec, 0x1138, 0x080c, 0x83d6, 0x080c, 0x9be6, 0x080c,
+	0x894f, 0x0005, 0x080c, 0xd4bf, 0x0db0, 0x0cc8, 0x6003, 0x0001,
+	0x6007, 0x0041, 0x2009, 0xa022, 0x080c, 0x84e7, 0x0005, 0x9182,
+	0x0040, 0x0002, 0xcb6e, 0xcb70, 0xcb6e, 0xcb6e, 0xcb6e, 0xcb6e,
+	0xcb6e, 0xcb6e, 0xcb6e, 0xcb6e, 0xcb6e, 0xcb6e, 0xcb6e, 0xcb6e,
+	0xcb6e, 0xcb6e, 0xcb6e, 0xcb71, 0xcb6e, 0xcb6e, 0x080c, 0x0d65,
+	0x0005, 0x00d6, 0x080c, 0x83d6, 0x00de, 0x080c, 0xd517, 0x080c,
+	0x9be6, 0x0005, 0x9182, 0x0040, 0x0002, 0xcb91, 0xcb91, 0xcb91,
+	0xcb91, 0xcb91, 0xcb91, 0xcb91, 0xcb91, 0xcb91, 0xcb93, 0xcbbe,
+	0xcb91, 0xcb91, 0xcb91, 0xcb91, 0xcbbe, 0xcb91, 0xcb91, 0xcb91,
+	0xcb91, 0x080c, 0x0d65, 0x6014, 0x0096, 0x2048, 0xa87c, 0xd0fc,
+	0x0168, 0x908c, 0x0003, 0x918e, 0x0002, 0x0180, 0x6144, 0xd1e4,
+	0x1168, 0x2009, 0x0041, 0x009e, 0x0804, 0xcc7e, 0x6003, 0x0007,
+	0x601b, 0x0000, 0x080c, 0x83d6, 0x009e, 0x0005, 0x6014, 0x2048,
+	0xa97c, 0xd1ec, 0x1130, 0x080c, 0x83d6, 0x080c, 0x9be6, 0x009e,
+	0x0005, 0x080c, 0xd4bf, 0x0db8, 0x009e, 0x0005, 0x2001, 0x180c,
+	0x200c, 0xc1d4, 0x2102, 0x0036, 0x080c, 0x88ec, 0x080c, 0x894f,
+	0x6014, 0x0096, 0x2048, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x0188, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x0140,
+	0xa8ac, 0x6330, 0x931a, 0x6332, 0xa8b0, 0x632c, 0x931b, 0x632e,
+	0x6003, 0x0002, 0x0080, 0x2019, 0x0004, 0x080c, 0xd267, 0x6018,
+	0x9005, 0x1128, 0x2001, 0x195f, 0x2004, 0x8003, 0x601a, 0x6017,
+	0x0000, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x9182, 0x0040,
+	0x0002, 0xcc0d, 0xcc0d, 0xcc0d, 0xcc0d, 0xcc0d, 0xcc0d, 0xcc0d,
+	0xcc0d, 0xcc0f, 0xcc0d, 0xcc0d, 0xcc0d, 0xcc0d, 0xcc0d, 0xcc0d,
+	0xcc0d, 0xcc0d, 0xcc0d, 0xcc0d, 0xcc5a, 0x080c, 0x0d65, 0x6014,
+	0x0096, 0x2048, 0xa834, 0xaa38, 0x6110, 0x00b6, 0x2158, 0xb900,
+	0x00be, 0xd1bc, 0x1190, 0x920d, 0x1518, 0xa87c, 0xd0fc, 0x0128,
+	0x2009, 0x0041, 0x009e, 0x0804, 0xcc7e, 0x6003, 0x0007, 0x601b,
+	0x0000, 0x080c, 0x83d6, 0x009e, 0x0005, 0x6124, 0xd1f4, 0x1d58,
+	0x0006, 0x0046, 0xacac, 0x9422, 0xa9b0, 0x2200, 0x910b, 0x6030,
+	0x9420, 0x6432, 0x602c, 0x9109, 0x612e, 0x004e, 0x000e, 0x08d8,
+	0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1bc, 0x1178, 0x2009,
+	0x180e, 0x210c, 0xd19c, 0x0118, 0x6003, 0x0007, 0x0010, 0x6003,
+	0x0006, 0x00e9, 0x080c, 0x83d8, 0x009e, 0x0005, 0x6003, 0x0002,
+	0x009e, 0x0005, 0x6024, 0xd0f4, 0x0128, 0x080c, 0x15af, 0x1904,
+	0xcc0f, 0x0005, 0x6014, 0x0096, 0x2048, 0xa834, 0xa938, 0x009e,
+	0x9105, 0x1120, 0x080c, 0x15af, 0x1904, 0xcc0f, 0x0005, 0xd2fc,
+	0x0140, 0x8002, 0x8000, 0x8212, 0x9291, 0x0000, 0x2009, 0x0009,
+	0x0010, 0x2009, 0x0015, 0xaa9a, 0xa896, 0x0005, 0x9182, 0x0040,
+	0x0208, 0x0062, 0x9186, 0x0013, 0x0120, 0x9186, 0x0014, 0x190c,
+	0x0d65, 0x6024, 0xd0dc, 0x090c, 0x0d65, 0x0005, 0xcca2, 0xccae,
+	0xccba, 0xccc6, 0xcca2, 0xcca2, 0xcca2, 0xcca2, 0xcca9, 0xcca4,
+	0xcca4, 0xcca2, 0xcca2, 0xcca2, 0xcca2, 0xcca4, 0xcca2, 0xcca4,
+	0xcca2, 0xcca9, 0x080c, 0x0d65, 0x6024, 0xd0dc, 0x090c, 0x0d65,
+	0x0005, 0x6014, 0x9005, 0x190c, 0x0d65, 0x0005, 0x6003, 0x0001,
+	0x6106, 0x0126, 0x2091, 0x8000, 0x2009, 0xa022, 0x080c, 0x84c9,
+	0x012e, 0x0005, 0x6003, 0x0004, 0x6106, 0x0126, 0x2091, 0x8000,
+	0x2009, 0xa001, 0x080c, 0x84e7, 0x012e, 0x0005, 0x6003, 0x0003,
+	0x6106, 0x080c, 0x1aca, 0x0126, 0x2091, 0x8000, 0x6014, 0x0096,
+	0x2048, 0xa87c, 0xd0fc, 0x0188, 0x9084, 0x0003, 0x9086, 0x0002,
+	0x01a0, 0x6024, 0xd0cc, 0x1148, 0xd0c4, 0x1138, 0xa8a8, 0x9005,
+	0x1120, 0x6144, 0x918d, 0xb035, 0x0018, 0x6144, 0x918d, 0xa035,
+	0x009e, 0x080c, 0x852e, 0x012e, 0x0005, 0x6144, 0x918d, 0xa032,
+	0x0cb8, 0x0126, 0x2091, 0x8000, 0x0036, 0x0096, 0x9182, 0x0040,
+	0x0023, 0x009e, 0x003e, 0x012e, 0x0005, 0xcd11, 0xcd13, 0xcd28,
+	0xcd42, 0xcd11, 0xcd11, 0xcd11, 0xcd11, 0xcd11, 0xcd11, 0xcd11,
+	0xcd11, 0xcd11, 0xcd11, 0xcd11, 0xcd11, 0xcd11, 0xcd11, 0xcd11,
+	0xcd11, 0x080c, 0x0d65, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0510,
 	0x909c, 0x0003, 0x939e, 0x0003, 0x01e8, 0x6003, 0x0001, 0x6106,
-	0x0126, 0x2091, 0x8000, 0x2009, 0xa022, 0x080c, 0x84b3, 0x0470,
+	0x0126, 0x2091, 0x8000, 0x2009, 0xa022, 0x080c, 0x84e7, 0x0470,
 	0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0168, 0x909c, 0x0003, 0x939e,
 	0x0003, 0x0140, 0x6003, 0x0001, 0x6106, 0x2009, 0xa001, 0x080c,
-	0x84b3, 0x00e0, 0x901e, 0x6316, 0x631a, 0x2019, 0x0004, 0x080c,
-	0xd22f, 0x00a0, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0d98, 0x909c,
+	0x84e7, 0x00e0, 0x901e, 0x6316, 0x631a, 0x2019, 0x0004, 0x080c,
+	0xd267, 0x00a0, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x0d98, 0x909c,
 	0x0003, 0x939e, 0x0003, 0x0d70, 0x6003, 0x0003, 0x6106, 0x080c,
-	0x1ab2, 0x6144, 0x918d, 0xa035, 0x080c, 0x84fa, 0x0005, 0x080c,
-	0x885d, 0x6114, 0x81ff, 0x0158, 0x0096, 0x2148, 0x080c, 0xd52b,
-	0x0036, 0x2019, 0x0029, 0x080c, 0xd22f, 0x003e, 0x009e, 0x080c,
-	0x9c14, 0x080c, 0x891b, 0x0005, 0x080c, 0x88b8, 0x6114, 0x81ff,
-	0x0158, 0x0096, 0x2148, 0x080c, 0xd52b, 0x0036, 0x2019, 0x0029,
-	0x080c, 0xd22f, 0x003e, 0x009e, 0x080c, 0x9c14, 0x0005, 0x9182,
-	0x0085, 0x0002, 0xcd59, 0xcd57, 0xcd57, 0xcd65, 0xcd57, 0xcd57,
-	0xcd57, 0xcd57, 0xcd57, 0xcd57, 0xcd57, 0xcd57, 0xcd57, 0x080c,
+	0x1aca, 0x6144, 0x918d, 0xa035, 0x080c, 0x852e, 0x0005, 0x080c,
+	0x8891, 0x6114, 0x81ff, 0x0158, 0x0096, 0x2148, 0x080c, 0xd563,
+	0x0036, 0x2019, 0x0029, 0x080c, 0xd267, 0x003e, 0x009e, 0x080c,
+	0x9c20, 0x080c, 0x894f, 0x0005, 0x080c, 0x88ec, 0x6114, 0x81ff,
+	0x0158, 0x0096, 0x2148, 0x080c, 0xd563, 0x0036, 0x2019, 0x0029,
+	0x080c, 0xd267, 0x003e, 0x009e, 0x080c, 0x9c20, 0x0005, 0x9182,
+	0x0085, 0x0002, 0xcd91, 0xcd8f, 0xcd8f, 0xcd9d, 0xcd8f, 0xcd8f,
+	0xcd8f, 0xcd8f, 0xcd8f, 0xcd8f, 0xcd8f, 0xcd8f, 0xcd8f, 0x080c,
 	0x0d65, 0x6003, 0x000b, 0x6106, 0x0126, 0x2091, 0x8000, 0x2009,
-	0x8020, 0x080c, 0x84b3, 0x012e, 0x0005, 0x0026, 0x00e6, 0x080c,
-	0xd47e, 0x0118, 0x080c, 0x9bda, 0x0440, 0x2071, 0x0260, 0x7224,
+	0x8020, 0x080c, 0x84e7, 0x012e, 0x0005, 0x0026, 0x00e6, 0x080c,
+	0xd4b6, 0x0118, 0x080c, 0x9be6, 0x0440, 0x2071, 0x0260, 0x7224,
 	0x6216, 0x2001, 0x180e, 0x2004, 0xd0e4, 0x0150, 0x6010, 0x00b6,
-	0x2058, 0xbca0, 0x00be, 0x2c00, 0x2011, 0x014e, 0x080c, 0x9f04,
-	0x7220, 0x080c, 0xd0c5, 0x0118, 0x6007, 0x0086, 0x0040, 0x6007,
+	0x2058, 0xbca0, 0x00be, 0x2c00, 0x2011, 0x014e, 0x080c, 0x9f10,
+	0x7220, 0x080c, 0xd0fd, 0x0118, 0x6007, 0x0086, 0x0040, 0x6007,
 	0x0087, 0x7224, 0x9296, 0xffff, 0x1110, 0x6007, 0x0086, 0x6003,
-	0x0001, 0x2009, 0x8020, 0x080c, 0x84b3, 0x00ee, 0x002e, 0x0005,
+	0x0001, 0x2009, 0x8020, 0x080c, 0x84e7, 0x00ee, 0x002e, 0x0005,
 	0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0d65,
 	0x908a, 0x0092, 0x1a0c, 0x0d65, 0x9082, 0x0085, 0x00a2, 0x9186,
-	0x0027, 0x0130, 0x9186, 0x0014, 0x0118, 0x080c, 0x9c93, 0x0050,
-	0x2001, 0x0007, 0x080c, 0x61e8, 0x080c, 0x885d, 0x080c, 0x9c14,
-	0x080c, 0x891b, 0x0005, 0xcdc8, 0xcdca, 0xcdca, 0xcdc8, 0xcdc8,
-	0xcdc8, 0xcdc8, 0xcdc8, 0xcdc8, 0xcdc8, 0xcdc8, 0xcdc8, 0xcdc8,
-	0x080c, 0x0d65, 0x080c, 0x9c14, 0x080c, 0x891b, 0x0005, 0x9182,
+	0x0027, 0x0130, 0x9186, 0x0014, 0x0118, 0x080c, 0x9c9f, 0x0050,
+	0x2001, 0x0007, 0x080c, 0x620c, 0x080c, 0x8891, 0x080c, 0x9c20,
+	0x080c, 0x894f, 0x0005, 0xce00, 0xce02, 0xce02, 0xce00, 0xce00,
+	0xce00, 0xce00, 0xce00, 0xce00, 0xce00, 0xce00, 0xce00, 0xce00,
+	0x080c, 0x0d65, 0x080c, 0x9c20, 0x080c, 0x894f, 0x0005, 0x9182,
 	0x0085, 0x0a0c, 0x0d65, 0x9182, 0x0092, 0x1a0c, 0x0d65, 0x9182,
-	0x0085, 0x0002, 0xcde7, 0xcde7, 0xcde7, 0xcde9, 0xcde7, 0xcde7,
-	0xcde7, 0xcde7, 0xcde7, 0xcde7, 0xcde7, 0xcde7, 0xcde7, 0x080c,
+	0x0085, 0x0002, 0xce1f, 0xce1f, 0xce1f, 0xce21, 0xce1f, 0xce1f,
+	0xce1f, 0xce1f, 0xce1f, 0xce1f, 0xce1f, 0xce1f, 0xce1f, 0x080c,
 	0x0d65, 0x0005, 0x9186, 0x0013, 0x0148, 0x9186, 0x0014, 0x0130,
-	0x9186, 0x0027, 0x0118, 0x080c, 0x9c93, 0x0020, 0x080c, 0x885d,
-	0x080c, 0x9c14, 0x0005, 0x0036, 0x080c, 0xd4df, 0x604b, 0x0000,
+	0x9186, 0x0027, 0x0118, 0x080c, 0x9c9f, 0x0020, 0x080c, 0x8891,
+	0x080c, 0x9c20, 0x0005, 0x0036, 0x080c, 0xd517, 0x604b, 0x0000,
 	0x2019, 0x000b, 0x0031, 0x6023, 0x0006, 0x6003, 0x0007, 0x003e,
 	0x0005, 0x0126, 0x0036, 0x2091, 0x8000, 0x2001, 0x0382, 0x2004,
-	0x9084, 0x0007, 0x0006, 0x9086, 0x0003, 0x0110, 0x080c, 0x98bb,
-	0x0086, 0x2c40, 0x0096, 0x904e, 0x080c, 0x9365, 0x009e, 0x008e,
-	0x1558, 0x0076, 0x2c38, 0x080c, 0x9410, 0x007e, 0x1528, 0x6000,
+	0x9084, 0x0007, 0x0006, 0x9086, 0x0003, 0x0110, 0x080c, 0x98c7,
+	0x0086, 0x2c40, 0x0096, 0x904e, 0x080c, 0x936d, 0x009e, 0x008e,
+	0x1558, 0x0076, 0x2c38, 0x080c, 0x9418, 0x007e, 0x1528, 0x6000,
 	0x9086, 0x0000, 0x0508, 0x6020, 0x9086, 0x0007, 0x01e8, 0x0096,
-	0x601c, 0xd084, 0x0140, 0x080c, 0xd4df, 0x080c, 0xbf79, 0x080c,
-	0x1921, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c, 0xb842, 0x0110,
-	0x080c, 0xd22f, 0x009e, 0x9006, 0x6046, 0x6016, 0x080c, 0xd4df,
-	0x6023, 0x0007, 0x080c, 0xbf79, 0x000e, 0x9086, 0x0003, 0x0110,
-	0x080c, 0x98d7, 0x003e, 0x012e, 0x0005, 0x00f6, 0x00c6, 0x00b6,
-	0x0036, 0x0156, 0x2079, 0x0260, 0x7938, 0x783c, 0x080c, 0x243d,
-	0x15e8, 0x0016, 0x00c6, 0x080c, 0x626b, 0x15b0, 0x001e, 0x00c6,
-	0x2160, 0x080c, 0xbf76, 0x00ce, 0x002e, 0x0026, 0x0016, 0x080c,
-	0x98bb, 0x2019, 0x0029, 0x080c, 0x94dd, 0x080c, 0x8624, 0x0076,
-	0x903e, 0x080c, 0x8509, 0x007e, 0x001e, 0x0076, 0x903e, 0x080c,
-	0xcfd9, 0x007e, 0x080c, 0x98d7, 0x0026, 0xba04, 0x9294, 0xff00,
+	0x601c, 0xd084, 0x0140, 0x080c, 0xd517, 0x080c, 0xbfa7, 0x080c,
+	0x193e, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c, 0xb870, 0x0110,
+	0x080c, 0xd267, 0x009e, 0x9006, 0x6046, 0x6016, 0x080c, 0xd517,
+	0x6023, 0x0007, 0x080c, 0xbfa7, 0x000e, 0x9086, 0x0003, 0x0110,
+	0x080c, 0x98e3, 0x003e, 0x012e, 0x0005, 0x00f6, 0x00c6, 0x00b6,
+	0x0036, 0x0156, 0x2079, 0x0260, 0x7938, 0x783c, 0x080c, 0x2459,
+	0x15e8, 0x0016, 0x00c6, 0x080c, 0x628f, 0x15b0, 0x001e, 0x00c6,
+	0x2160, 0x080c, 0xbfa4, 0x00ce, 0x002e, 0x0026, 0x0016, 0x080c,
+	0x98c7, 0x2019, 0x0029, 0x080c, 0x94e5, 0x080c, 0x8658, 0x0076,
+	0x903e, 0x080c, 0x853d, 0x007e, 0x001e, 0x0076, 0x903e, 0x080c,
+	0xd011, 0x007e, 0x080c, 0x98e3, 0x0026, 0xba04, 0x9294, 0xff00,
 	0x8217, 0x9286, 0x0006, 0x0118, 0x9286, 0x0004, 0x1118, 0xbaa0,
-	0x080c, 0x30d8, 0x002e, 0xbc84, 0x001e, 0x080c, 0x5cf1, 0xbe12,
+	0x080c, 0x30f8, 0x002e, 0xbc84, 0x001e, 0x080c, 0x5d11, 0xbe12,
 	0xbd16, 0xbc86, 0x9006, 0x0010, 0x00ce, 0x001e, 0x015e, 0x003e,
 	0x00be, 0x00ce, 0x00fe, 0x0005, 0x00c6, 0x00d6, 0x00b6, 0x0016,
-	0x2009, 0x1823, 0x2104, 0x9086, 0x0074, 0x1904, 0xcefd, 0x2069,
+	0x2009, 0x1823, 0x2104, 0x9086, 0x0074, 0x1904, 0xcf35, 0x2069,
 	0x0260, 0x6944, 0x9182, 0x0100, 0x06e0, 0x6940, 0x9184, 0x8000,
-	0x0904, 0xcefa, 0x2001, 0x194c, 0x2004, 0x9005, 0x1140, 0x6010,
+	0x0904, 0xcf32, 0x2001, 0x1954, 0x2004, 0x9005, 0x1140, 0x6010,
 	0x2058, 0xb884, 0x9005, 0x0118, 0x9184, 0x0800, 0x0598, 0x6948,
-	0x918a, 0x0001, 0x0648, 0x080c, 0xd593, 0x0118, 0x6978, 0xd1fc,
+	0x918a, 0x0001, 0x0648, 0x080c, 0xd5cb, 0x0118, 0x6978, 0xd1fc,
 	0x11b8, 0x2009, 0x0205, 0x200b, 0x0001, 0x693c, 0x81ff, 0x1198,
 	0x6944, 0x9182, 0x0100, 0x02a8, 0x6940, 0x81ff, 0x1178, 0x6948,
 	0x918a, 0x0001, 0x0288, 0x6950, 0x918a, 0x0001, 0x0298, 0x00d0,
@@ -6422,225 +6429,225 @@
 	0x00c6, 0x00b6, 0x0026, 0x0036, 0x0156, 0x6210, 0x2258, 0xbb04,
 	0x9394, 0x00ff, 0x9286, 0x0006, 0x0180, 0x9286, 0x0004, 0x0168,
 	0x9394, 0xff00, 0x8217, 0x9286, 0x0006, 0x0138, 0x9286, 0x0004,
-	0x0120, 0x080c, 0x627a, 0x0804, 0xcf68, 0x2011, 0x0276, 0x20a9,
-	0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xabd3, 0x009e,
+	0x0120, 0x080c, 0x629e, 0x0804, 0xcfa0, 0x2011, 0x0276, 0x20a9,
+	0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xabee, 0x009e,
 	0x15c0, 0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019,
-	0x0006, 0x080c, 0xabd3, 0x009e, 0x1560, 0x0046, 0x0016, 0xbaa0,
-	0x2220, 0x9006, 0x2009, 0x1854, 0x210c, 0x0038, 0x2009, 0x0029,
-	0x080c, 0xd284, 0xb800, 0xc0e5, 0xb802, 0x080c, 0x98bb, 0x2019,
-	0x0029, 0x080c, 0x8624, 0x0076, 0x2039, 0x0000, 0x080c, 0x8509,
-	0x2c08, 0x080c, 0xcfd9, 0x007e, 0x080c, 0x98d7, 0x2001, 0x0007,
-	0x080c, 0x61e8, 0x2001, 0x0007, 0x080c, 0x61bc, 0x001e, 0x004e,
+	0x0006, 0x080c, 0xabee, 0x009e, 0x1560, 0x0046, 0x0016, 0xbaa0,
+	0x2220, 0x9006, 0x2009, 0x185c, 0x210c, 0x0038, 0x2009, 0x0029,
+	0x080c, 0xd2bc, 0xb800, 0xc0e5, 0xb802, 0x080c, 0x98c7, 0x2019,
+	0x0029, 0x080c, 0x8658, 0x0076, 0x2039, 0x0000, 0x080c, 0x853d,
+	0x2c08, 0x080c, 0xd011, 0x007e, 0x080c, 0x98e3, 0x2001, 0x0007,
+	0x080c, 0x620c, 0x2001, 0x0007, 0x080c, 0x61e0, 0x001e, 0x004e,
 	0x9006, 0x015e, 0x003e, 0x002e, 0x00be, 0x00ce, 0x0005, 0x00d6,
 	0x2069, 0x026e, 0x6800, 0x9086, 0x0800, 0x0118, 0x6017, 0x0000,
 	0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00f6, 0x0016, 0x0026,
-	0x0036, 0x0156, 0x2079, 0x026c, 0x7930, 0x7834, 0x080c, 0x243d,
-	0x11d0, 0x080c, 0x626b, 0x11b8, 0x2011, 0x0270, 0x20a9, 0x0004,
-	0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xabd3, 0x009e, 0x1158,
+	0x0036, 0x0156, 0x2079, 0x026c, 0x7930, 0x7834, 0x080c, 0x2459,
+	0x11d0, 0x080c, 0x628f, 0x11b8, 0x2011, 0x0270, 0x20a9, 0x0004,
+	0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xabee, 0x009e, 0x1158,
 	0x2011, 0x0274, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x0006,
-	0x080c, 0xabd3, 0x009e, 0x015e, 0x003e, 0x002e, 0x001e, 0x00fe,
+	0x080c, 0xabee, 0x009e, 0x015e, 0x003e, 0x002e, 0x001e, 0x00fe,
 	0x00be, 0x0005, 0x00b6, 0x0006, 0x0016, 0x0026, 0x0036, 0x0156,
-	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x243d, 0x11d0,
-	0x080c, 0x626b, 0x11b8, 0x2011, 0x0276, 0x20a9, 0x0004, 0x0096,
-	0x2b48, 0x2019, 0x000a, 0x080c, 0xabd3, 0x009e, 0x1158, 0x2011,
+	0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x2459, 0x11d0,
+	0x080c, 0x628f, 0x11b8, 0x2011, 0x0276, 0x20a9, 0x0004, 0x0096,
+	0x2b48, 0x2019, 0x000a, 0x080c, 0xabee, 0x009e, 0x1158, 0x2011,
 	0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x0006, 0x080c,
-	0xabd3, 0x009e, 0x015e, 0x003e, 0x002e, 0x001e, 0x000e, 0x00be,
+	0xabee, 0x009e, 0x015e, 0x003e, 0x002e, 0x001e, 0x000e, 0x00be,
 	0x0005, 0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066, 0x0056, 0x0046,
-	0x0026, 0x0126, 0x2091, 0x8000, 0x080c, 0x9919, 0x0106, 0x190c,
-	0x98bb, 0x2740, 0x2029, 0x19c3, 0x252c, 0x2021, 0x19ca, 0x2424,
+	0x0026, 0x0126, 0x2091, 0x8000, 0x080c, 0x9925, 0x0106, 0x190c,
+	0x98c7, 0x2740, 0x2029, 0x19cb, 0x252c, 0x2021, 0x19d2, 0x2424,
 	0x2061, 0x1ddc, 0x2071, 0x1800, 0x7650, 0x7070, 0x81ff, 0x0150,
-	0x0006, 0x9186, 0x1b01, 0x000e, 0x0128, 0x8001, 0x9602, 0x1a04,
-	0xd07a, 0x0018, 0x9606, 0x0904, 0xd07a, 0x2100, 0x9c06, 0x0904,
-	0xd071, 0x080c, 0xd2c5, 0x1904, 0xd071, 0x080c, 0xd5b0, 0x0904,
-	0xd071, 0x080c, 0xd2b5, 0x0904, 0xd071, 0x6720, 0x9786, 0x0001,
-	0x1148, 0x080c, 0x3175, 0x0904, 0xd099, 0x6004, 0x9086, 0x0000,
-	0x1904, 0xd099, 0x9786, 0x0004, 0x0904, 0xd099, 0x9786, 0x0007,
-	0x0904, 0xd071, 0x2500, 0x9c06, 0x0904, 0xd071, 0x2400, 0x9c06,
-	0x0904, 0xd071, 0x88ff, 0x0118, 0x605c, 0x9906, 0x15d0, 0x0096,
+	0x0006, 0x9186, 0x1b09, 0x000e, 0x0128, 0x8001, 0x9602, 0x1a04,
+	0xd0b2, 0x0018, 0x9606, 0x0904, 0xd0b2, 0x2100, 0x9c06, 0x0904,
+	0xd0a9, 0x080c, 0xd2fd, 0x1904, 0xd0a9, 0x080c, 0xd5e8, 0x0904,
+	0xd0a9, 0x080c, 0xd2ed, 0x0904, 0xd0a9, 0x6720, 0x9786, 0x0001,
+	0x1148, 0x080c, 0x3195, 0x0904, 0xd0d1, 0x6004, 0x9086, 0x0000,
+	0x1904, 0xd0d1, 0x9786, 0x0004, 0x0904, 0xd0d1, 0x9786, 0x0007,
+	0x0904, 0xd0a9, 0x2500, 0x9c06, 0x0904, 0xd0a9, 0x2400, 0x9c06,
+	0x0904, 0xd0a9, 0x88ff, 0x0118, 0x605c, 0x9906, 0x15d0, 0x0096,
 	0x6043, 0xffff, 0x6000, 0x9086, 0x0004, 0x1120, 0x0016, 0x080c,
-	0x1921, 0x001e, 0x9786, 0x000a, 0x0148, 0x080c, 0xba57, 0x1130,
-	0x080c, 0xa581, 0x009e, 0x080c, 0x9c14, 0x0418, 0x6014, 0x2048,
-	0x080c, 0xb842, 0x01d8, 0x9786, 0x0003, 0x1588, 0xa867, 0x0103,
-	0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fd4,
-	0x009e, 0xab7a, 0xa877, 0x0000, 0x080c, 0xd52b, 0x0016, 0x080c,
-	0xbb45, 0x080c, 0x6985, 0x001e, 0x080c, 0xba31, 0x009e, 0x080c,
-	0x9c14, 0x9ce0, 0x001c, 0x2001, 0x1819, 0x2004, 0x9c02, 0x1210,
-	0x0804, 0xcff2, 0x010e, 0x190c, 0x98d7, 0x012e, 0x002e, 0x004e,
+	0x193e, 0x001e, 0x9786, 0x000a, 0x0148, 0x080c, 0xba85, 0x1130,
+	0x080c, 0xa59c, 0x009e, 0x080c, 0x9c20, 0x0418, 0x6014, 0x2048,
+	0x080c, 0xb870, 0x01d8, 0x9786, 0x0003, 0x1588, 0xa867, 0x0103,
+	0xa87c, 0xd0cc, 0x0130, 0x0096, 0xa878, 0x2048, 0x080c, 0x0fe1,
+	0x009e, 0xab7a, 0xa877, 0x0000, 0x080c, 0xd563, 0x0016, 0x080c,
+	0xbb73, 0x080c, 0x69a9, 0x001e, 0x080c, 0xba5f, 0x009e, 0x080c,
+	0x9c20, 0x9ce0, 0x001c, 0x2001, 0x1819, 0x2004, 0x9c02, 0x1210,
+	0x0804, 0xd02a, 0x010e, 0x190c, 0x98e3, 0x012e, 0x002e, 0x004e,
 	0x005e, 0x006e, 0x007e, 0x008e, 0x00ce, 0x00ee, 0x0005, 0x9786,
-	0x0006, 0x1150, 0x9386, 0x0005, 0x0128, 0x080c, 0xd52b, 0x080c,
-	0xd22f, 0x08e0, 0x009e, 0x08e8, 0x9786, 0x000a, 0x0908, 0x0804,
-	0xd056, 0x81ff, 0x09b0, 0x9180, 0x0001, 0x2004, 0x9086, 0x0018,
+	0x0006, 0x1150, 0x9386, 0x0005, 0x0128, 0x080c, 0xd563, 0x080c,
+	0xd267, 0x08e0, 0x009e, 0x08e8, 0x9786, 0x000a, 0x0908, 0x0804,
+	0xd08e, 0x81ff, 0x09b0, 0x9180, 0x0001, 0x2004, 0x9086, 0x0018,
 	0x0130, 0x9180, 0x0001, 0x2004, 0x9086, 0x002d, 0x1950, 0x6000,
-	0x9086, 0x0002, 0x1930, 0x080c, 0xba46, 0x0130, 0x080c, 0xba57,
-	0x1900, 0x080c, 0xa581, 0x0038, 0x080c, 0x303d, 0x080c, 0xba57,
-	0x1110, 0x080c, 0xa581, 0x080c, 0x9c14, 0x0804, 0xd071, 0xa864,
+	0x9086, 0x0002, 0x1930, 0x080c, 0xba74, 0x0130, 0x080c, 0xba85,
+	0x1900, 0x080c, 0xa59c, 0x0038, 0x080c, 0x305d, 0x080c, 0xba85,
+	0x1110, 0x080c, 0xa59c, 0x080c, 0x9c20, 0x0804, 0xd0a9, 0xa864,
 	0x9084, 0x00ff, 0x9086, 0x0039, 0x0005, 0x00c6, 0x00e6, 0x0016,
-	0x2c08, 0x2170, 0x9006, 0x080c, 0xd256, 0x001e, 0x0120, 0x6020,
-	0x9084, 0x000f, 0x001b, 0x00ee, 0x00ce, 0x0005, 0xd0e4, 0xd0e4,
-	0xd0e4, 0xd0e4, 0xd0e4, 0xd0e4, 0xd0e6, 0xd0e4, 0xd0e4, 0xd0e4,
-	0xd0e4, 0x9c14, 0x9c14, 0xd0e4, 0x9006, 0x0005, 0x0036, 0x0046,
+	0x2c08, 0x2170, 0x9006, 0x080c, 0xd28e, 0x001e, 0x0120, 0x6020,
+	0x9084, 0x000f, 0x001b, 0x00ee, 0x00ce, 0x0005, 0xd11c, 0xd11c,
+	0xd11c, 0xd11c, 0xd11c, 0xd11c, 0xd11e, 0xd11c, 0xd11c, 0xd11c,
+	0xd11c, 0x9c20, 0x9c20, 0xd11c, 0x9006, 0x0005, 0x0036, 0x0046,
 	0x0016, 0x7010, 0x00b6, 0x2058, 0xbca0, 0x00be, 0x2c00, 0x2009,
-	0x0020, 0x080c, 0xd284, 0x001e, 0x004e, 0x2019, 0x0002, 0x080c,
-	0xce09, 0x003e, 0x9085, 0x0001, 0x0005, 0x0096, 0x080c, 0xb842,
-	0x0140, 0x6014, 0x904d, 0x080c, 0xb440, 0x687b, 0x0005, 0x080c,
-	0x6991, 0x009e, 0x080c, 0x9c14, 0x9085, 0x0001, 0x0005, 0x2001,
-	0x0001, 0x080c, 0x61a8, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9,
-	0x0004, 0x2019, 0x1805, 0x2011, 0x0276, 0x080c, 0xabbf, 0x003e,
+	0x0020, 0x080c, 0xd2bc, 0x001e, 0x004e, 0x2019, 0x0002, 0x080c,
+	0xce41, 0x003e, 0x9085, 0x0001, 0x0005, 0x0096, 0x080c, 0xb870,
+	0x0140, 0x6014, 0x904d, 0x080c, 0xb45e, 0x687b, 0x0005, 0x080c,
+	0x69b5, 0x009e, 0x080c, 0x9c20, 0x9085, 0x0001, 0x0005, 0x2001,
+	0x0001, 0x080c, 0x61cc, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9,
+	0x0004, 0x2019, 0x1805, 0x2011, 0x0276, 0x080c, 0xabda, 0x003e,
 	0x002e, 0x001e, 0x015e, 0x9005, 0x0005, 0x00f6, 0x00e6, 0x00c6,
 	0x0086, 0x0076, 0x0066, 0x00b6, 0x0126, 0x2091, 0x8000, 0x2740,
-	0x2061, 0x1ddc, 0x2079, 0x0001, 0x8fff, 0x0904, 0xd17f, 0x2071,
-	0x1800, 0x7650, 0x7070, 0x8001, 0x9602, 0x1a04, 0xd17f, 0x88ff,
-	0x0120, 0x2800, 0x9c06, 0x1590, 0x2078, 0x080c, 0xd2b5, 0x0570,
+	0x2061, 0x1ddc, 0x2079, 0x0001, 0x8fff, 0x0904, 0xd1b7, 0x2071,
+	0x1800, 0x7650, 0x7070, 0x8001, 0x9602, 0x1a04, 0xd1b7, 0x88ff,
+	0x0120, 0x2800, 0x9c06, 0x1590, 0x2078, 0x080c, 0xd2ed, 0x0570,
 	0x2400, 0x9c06, 0x0558, 0x6720, 0x9786, 0x0006, 0x1538, 0x9786,
 	0x0007, 0x0520, 0x88ff, 0x1140, 0x6010, 0x9b06, 0x11f8, 0x85ff,
 	0x0118, 0x605c, 0x9106, 0x11d0, 0x0096, 0x601c, 0xd084, 0x0140,
-	0x080c, 0xd4df, 0x080c, 0xbf79, 0x080c, 0x1921, 0x6023, 0x0007,
-	0x6014, 0x2048, 0x080c, 0xb842, 0x0120, 0x0046, 0x080c, 0xd22f,
-	0x004e, 0x009e, 0x080c, 0x9c14, 0x88ff, 0x1198, 0x9ce0, 0x001c,
-	0x2001, 0x1819, 0x2004, 0x9c02, 0x1210, 0x0804, 0xd134, 0x9006,
+	0x080c, 0xd517, 0x080c, 0xbfa7, 0x080c, 0x193e, 0x6023, 0x0007,
+	0x6014, 0x2048, 0x080c, 0xb870, 0x0120, 0x0046, 0x080c, 0xd267,
+	0x004e, 0x009e, 0x080c, 0x9c20, 0x88ff, 0x1198, 0x9ce0, 0x001c,
+	0x2001, 0x1819, 0x2004, 0x9c02, 0x1210, 0x0804, 0xd16c, 0x9006,
 	0x012e, 0x00be, 0x006e, 0x007e, 0x008e, 0x00ce, 0x00ee, 0x00fe,
-	0x0005, 0x98c5, 0x0001, 0x0ca0, 0x080c, 0x98bb, 0x00b6, 0x0076,
+	0x0005, 0x98c5, 0x0001, 0x0ca0, 0x080c, 0x98c7, 0x00b6, 0x0076,
 	0x0056, 0x0086, 0x9046, 0x2029, 0x0001, 0x2c20, 0x2019, 0x0002,
-	0x6210, 0x2258, 0x0096, 0x904e, 0x080c, 0x9365, 0x009e, 0x008e,
-	0x903e, 0x080c, 0x9410, 0x080c, 0xd125, 0x005e, 0x007e, 0x00be,
-	0x080c, 0x98d7, 0x0005, 0x080c, 0x98bb, 0x00b6, 0x0046, 0x0056,
+	0x6210, 0x2258, 0x0096, 0x904e, 0x080c, 0x936d, 0x009e, 0x008e,
+	0x903e, 0x080c, 0x9418, 0x080c, 0xd15d, 0x005e, 0x007e, 0x00be,
+	0x080c, 0x98e3, 0x0005, 0x080c, 0x98c7, 0x00b6, 0x0046, 0x0056,
 	0x0076, 0x00c6, 0x0156, 0x2c20, 0x2128, 0x20a9, 0x007f, 0x900e,
-	0x0016, 0x0036, 0x080c, 0x626b, 0x1190, 0x0056, 0x0086, 0x9046,
-	0x2508, 0x2029, 0x0001, 0x0096, 0x904e, 0x080c, 0x9365, 0x009e,
-	0x008e, 0x903e, 0x080c, 0x9410, 0x080c, 0xd125, 0x005e, 0x003e,
-	0x001e, 0x8108, 0x1f04, 0xd1b8, 0x015e, 0x00ce, 0x007e, 0x005e,
-	0x004e, 0x00be, 0x080c, 0x98d7, 0x0005, 0x080c, 0x98bb, 0x00b6,
+	0x0016, 0x0036, 0x080c, 0x628f, 0x1190, 0x0056, 0x0086, 0x9046,
+	0x2508, 0x2029, 0x0001, 0x0096, 0x904e, 0x080c, 0x936d, 0x009e,
+	0x008e, 0x903e, 0x080c, 0x9418, 0x080c, 0xd15d, 0x005e, 0x003e,
+	0x001e, 0x8108, 0x1f04, 0xd1f0, 0x015e, 0x00ce, 0x007e, 0x005e,
+	0x004e, 0x00be, 0x080c, 0x98e3, 0x0005, 0x080c, 0x98c7, 0x00b6,
 	0x0076, 0x0056, 0x6210, 0x2258, 0x0086, 0x9046, 0x2029, 0x0001,
-	0x2019, 0x0048, 0x0096, 0x904e, 0x080c, 0x9365, 0x009e, 0x008e,
-	0x903e, 0x080c, 0x9410, 0x2c20, 0x080c, 0xd125, 0x005e, 0x007e,
-	0x00be, 0x080c, 0x98d7, 0x0005, 0x080c, 0x98bb, 0x00b6, 0x0046,
+	0x2019, 0x0048, 0x0096, 0x904e, 0x080c, 0x936d, 0x009e, 0x008e,
+	0x903e, 0x080c, 0x9418, 0x2c20, 0x080c, 0xd15d, 0x005e, 0x007e,
+	0x00be, 0x080c, 0x98e3, 0x0005, 0x080c, 0x98c7, 0x00b6, 0x0046,
 	0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20, 0x20a9, 0x0800, 0x900e,
-	0x0016, 0x0036, 0x080c, 0x626b, 0x11a0, 0x0086, 0x9046, 0x2828,
-	0x0046, 0x2021, 0x0001, 0x080c, 0xd4c3, 0x004e, 0x0096, 0x904e,
-	0x080c, 0x9365, 0x009e, 0x008e, 0x903e, 0x080c, 0x9410, 0x080c,
-	0xd125, 0x003e, 0x001e, 0x8108, 0x1f04, 0xd208, 0x015e, 0x00ce,
-	0x007e, 0x005e, 0x004e, 0x00be, 0x080c, 0x98d7, 0x0005, 0x0016,
-	0x00f6, 0x080c, 0xb840, 0x0198, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x0016, 0x0036, 0x080c, 0x628f, 0x11a0, 0x0086, 0x9046, 0x2828,
+	0x0046, 0x2021, 0x0001, 0x080c, 0xd4fb, 0x004e, 0x0096, 0x904e,
+	0x080c, 0x936d, 0x009e, 0x008e, 0x903e, 0x080c, 0x9418, 0x080c,
+	0xd15d, 0x003e, 0x001e, 0x8108, 0x1f04, 0xd240, 0x015e, 0x00ce,
+	0x007e, 0x005e, 0x004e, 0x00be, 0x080c, 0x98e3, 0x0005, 0x0016,
+	0x00f6, 0x080c, 0xb86e, 0x0198, 0xa864, 0x9084, 0x00ff, 0x9086,
 	0x0046, 0x0180, 0xa800, 0x907d, 0x0138, 0xa803, 0x0000, 0xab82,
-	0x080c, 0x6991, 0x2f48, 0x0cb0, 0xab82, 0x080c, 0x6991, 0x00fe,
+	0x080c, 0x69b5, 0x2f48, 0x0cb0, 0xab82, 0x080c, 0x69b5, 0x00fe,
 	0x001e, 0x0005, 0xa800, 0x907d, 0x0130, 0xa803, 0x0000, 0x080c,
-	0x6991, 0x2f48, 0x0cb8, 0x080c, 0x6991, 0x0c88, 0x00e6, 0x0046,
+	0x69b5, 0x2f48, 0x0cb8, 0x080c, 0x69b5, 0x0c88, 0x00e6, 0x0046,
 	0x0036, 0x2061, 0x1ddc, 0x9005, 0x1138, 0x2071, 0x1800, 0x7450,
 	0x7070, 0x8001, 0x9402, 0x12d8, 0x2100, 0x9c06, 0x0168, 0x6000,
 	0x9086, 0x0000, 0x0148, 0x6008, 0x9206, 0x1130, 0x6010, 0x91a0,
 	0x0004, 0x2424, 0x9406, 0x0140, 0x9ce0, 0x001c, 0x2001, 0x1819,
 	0x2004, 0x9c02, 0x1220, 0x0c40, 0x9085, 0x0001, 0x0008, 0x9006,
-	0x003e, 0x004e, 0x00ee, 0x0005, 0x0096, 0x0006, 0x080c, 0x1022,
+	0x003e, 0x004e, 0x00ee, 0x0005, 0x0096, 0x0006, 0x080c, 0x102f,
 	0x000e, 0x090c, 0x0d65, 0xaae2, 0xa867, 0x010d, 0xa88e, 0x0026,
-	0x2010, 0x080c, 0xb830, 0x2001, 0x0000, 0x0120, 0x2200, 0x9080,
+	0x2010, 0x080c, 0xb85e, 0x2001, 0x0000, 0x0120, 0x2200, 0x9080,
 	0x0017, 0x2004, 0x002e, 0xa87a, 0x9186, 0x0020, 0x0110, 0xa8e3,
-	0xffff, 0xa986, 0xac76, 0xa87f, 0x0000, 0x2001, 0x195e, 0x2004,
+	0xffff, 0xa986, 0xac76, 0xa87f, 0x0000, 0x2001, 0x1966, 0x2004,
 	0xa882, 0x9006, 0xa802, 0xa86a, 0xa88a, 0x0126, 0x2091, 0x8000,
-	0x080c, 0x6991, 0x012e, 0x009e, 0x0005, 0x6700, 0x9786, 0x0000,
+	0x080c, 0x69b5, 0x012e, 0x009e, 0x0005, 0x6700, 0x9786, 0x0000,
 	0x0158, 0x9786, 0x0001, 0x0140, 0x9786, 0x000a, 0x0128, 0x9786,
 	0x0009, 0x0110, 0x9085, 0x0001, 0x0005, 0x00e6, 0x6010, 0x9075,
 	0x0138, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x00ee, 0x0005,
 	0x9085, 0x0001, 0x0cd8, 0x0016, 0x6004, 0x908e, 0x001e, 0x11a0,
 	0x8007, 0x6134, 0x918c, 0x00ff, 0x9105, 0x6036, 0x6007, 0x0085,
-	0x6003, 0x000b, 0x6023, 0x0005, 0x2001, 0x1957, 0x2004, 0x601a,
-	0x2009, 0x8020, 0x080c, 0x84b3, 0x001e, 0x0005, 0xa001, 0xa001,
-	0x0005, 0x6024, 0xd0e4, 0x0158, 0xd0cc, 0x0118, 0x080c, 0xbb8c,
-	0x0030, 0x080c, 0xd4df, 0x080c, 0x83a2, 0x080c, 0x9bda, 0x0005,
-	0x9280, 0x0008, 0x2004, 0x9084, 0x000f, 0x0002, 0xd314, 0xd314,
-	0xd314, 0xd316, 0xd314, 0xd316, 0xd316, 0xd314, 0xd316, 0xd314,
-	0xd314, 0xd314, 0xd314, 0xd314, 0x9006, 0x0005, 0x9085, 0x0001,
-	0x0005, 0x9280, 0x0008, 0x2004, 0x9084, 0x000f, 0x0002, 0xd32d,
-	0xd32d, 0xd32d, 0xd32d, 0xd32d, 0xd32d, 0xd33a, 0xd32d, 0xd32d,
-	0xd32d, 0xd32d, 0xd32d, 0xd32d, 0xd32d, 0x6007, 0x003b, 0x602f,
+	0x6003, 0x000b, 0x6023, 0x0005, 0x2001, 0x195f, 0x2004, 0x601a,
+	0x2009, 0x8020, 0x080c, 0x84e7, 0x001e, 0x0005, 0xa001, 0xa001,
+	0x0005, 0x6024, 0xd0e4, 0x0158, 0xd0cc, 0x0118, 0x080c, 0xbbba,
+	0x0030, 0x080c, 0xd517, 0x080c, 0x83d6, 0x080c, 0x9be6, 0x0005,
+	0x9280, 0x0008, 0x2004, 0x9084, 0x000f, 0x0002, 0xd34c, 0xd34c,
+	0xd34c, 0xd34e, 0xd34c, 0xd34e, 0xd34e, 0xd34c, 0xd34e, 0xd34c,
+	0xd34c, 0xd34c, 0xd34c, 0xd34c, 0x9006, 0x0005, 0x9085, 0x0001,
+	0x0005, 0x9280, 0x0008, 0x2004, 0x9084, 0x000f, 0x0002, 0xd365,
+	0xd365, 0xd365, 0xd365, 0xd365, 0xd365, 0xd372, 0xd365, 0xd365,
+	0xd365, 0xd365, 0xd365, 0xd365, 0xd365, 0x6007, 0x003b, 0x602f,
 	0x0009, 0x6017, 0x2a00, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c,
-	0x84b3, 0x0005, 0x0096, 0x00c6, 0x2260, 0x080c, 0xd4df, 0x604b,
+	0x84e7, 0x0005, 0x0096, 0x00c6, 0x2260, 0x080c, 0xd517, 0x604b,
 	0x0000, 0x6024, 0xc0f4, 0xc0e4, 0x6026, 0x603b, 0x0000, 0x00ce,
-	0x00d6, 0x2268, 0x9186, 0x0007, 0x1904, 0xd393, 0x6814, 0x9005,
+	0x00d6, 0x2268, 0x9186, 0x0007, 0x1904, 0xd3cb, 0x6814, 0x9005,
 	0x0138, 0x2048, 0xa87c, 0xd0fc, 0x1118, 0x00de, 0x009e, 0x08a8,
-	0x6007, 0x003a, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84b3,
-	0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002, 0x1904, 0xd40a, 0x6014,
+	0x6007, 0x003a, 0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84e7,
+	0x00c6, 0x2d60, 0x6100, 0x9186, 0x0002, 0x1904, 0xd442, 0x6014,
 	0x9005, 0x1138, 0x6000, 0x9086, 0x0007, 0x190c, 0x0d65, 0x0804,
-	0xd40a, 0x2048, 0x080c, 0xb842, 0x1130, 0x0028, 0x2048, 0xa800,
+	0xd442, 0x2048, 0x080c, 0xb870, 0x1130, 0x0028, 0x2048, 0xa800,
 	0x9005, 0x1de0, 0x2900, 0x2048, 0xa87c, 0x9084, 0x0003, 0x9086,
 	0x0002, 0x1168, 0xa87c, 0xc0dc, 0xc0f4, 0xa87e, 0xa880, 0xc0fc,
-	0xa882, 0x2009, 0x0043, 0x080c, 0xcc4b, 0x0804, 0xd40a, 0x2009,
-	0x0041, 0x0804, 0xd404, 0x9186, 0x0005, 0x15a0, 0x6814, 0x2048,
-	0xa87c, 0xd0bc, 0x1120, 0x00de, 0x009e, 0x0804, 0xd32d, 0xd0b4,
-	0x0128, 0xd0fc, 0x090c, 0x0d65, 0x0804, 0xd34e, 0x6007, 0x003a,
-	0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84b3, 0x00c6, 0x2d60,
-	0x6100, 0x9186, 0x0002, 0x0120, 0x9186, 0x0004, 0x1904, 0xd40a,
+	0xa882, 0x2009, 0x0043, 0x080c, 0xcc7e, 0x0804, 0xd442, 0x2009,
+	0x0041, 0x0804, 0xd43c, 0x9186, 0x0005, 0x15a0, 0x6814, 0x2048,
+	0xa87c, 0xd0bc, 0x1120, 0x00de, 0x009e, 0x0804, 0xd365, 0xd0b4,
+	0x0128, 0xd0fc, 0x090c, 0x0d65, 0x0804, 0xd386, 0x6007, 0x003a,
+	0x6003, 0x0001, 0x2009, 0x8020, 0x080c, 0x84e7, 0x00c6, 0x2d60,
+	0x6100, 0x9186, 0x0002, 0x0120, 0x9186, 0x0004, 0x1904, 0xd442,
 	0x6814, 0x2048, 0xa97c, 0xc1f4, 0xc1dc, 0xa97e, 0xa980, 0xc1fc,
-	0xc1bc, 0xa982, 0x00f6, 0x2c78, 0x080c, 0x165c, 0x00fe, 0x2009,
-	0x0042, 0x04d0, 0x0036, 0x080c, 0x1022, 0x090c, 0x0d65, 0xa867,
+	0xc1bc, 0xa982, 0x00f6, 0x2c78, 0x080c, 0x1669, 0x00fe, 0x2009,
+	0x0042, 0x04d0, 0x0036, 0x080c, 0x102f, 0x090c, 0x0d65, 0xa867,
 	0x010d, 0x9006, 0xa802, 0xa86a, 0xa88a, 0x2d18, 0xab8e, 0xa887,
 	0x0045, 0x2c00, 0xa892, 0x6038, 0xa8a2, 0x2360, 0x6024, 0xc0dd,
 	0x6026, 0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x2004, 0x635c,
 	0xab7a, 0xa876, 0x9006, 0xa87e, 0xa882, 0xad9a, 0xae96, 0xa89f,
-	0x0001, 0x080c, 0x6991, 0x2019, 0x0045, 0x6008, 0x2068, 0x080c,
-	0xce09, 0x2d00, 0x600a, 0x6023, 0x0006, 0x6003, 0x0007, 0x901e,
+	0x0001, 0x080c, 0x69b5, 0x2019, 0x0045, 0x6008, 0x2068, 0x080c,
+	0xce41, 0x2d00, 0x600a, 0x6023, 0x0006, 0x6003, 0x0007, 0x901e,
 	0x631a, 0x634a, 0x003e, 0x0038, 0x604b, 0x0000, 0x6003, 0x0007,
-	0x080c, 0xcc4b, 0x00ce, 0x00de, 0x009e, 0x0005, 0x9186, 0x0013,
+	0x080c, 0xcc7e, 0x00ce, 0x00de, 0x009e, 0x0005, 0x9186, 0x0013,
 	0x1128, 0x6004, 0x9082, 0x0085, 0x2008, 0x00c2, 0x9186, 0x0027,
-	0x1178, 0x080c, 0x885d, 0x0036, 0x0096, 0x6014, 0x2048, 0x2019,
-	0x0004, 0x080c, 0xd22f, 0x009e, 0x003e, 0x080c, 0x891b, 0x0005,
-	0x9186, 0x0014, 0x0d70, 0x080c, 0x9c93, 0x0005, 0xd43d, 0xd43b,
-	0xd43b, 0xd43b, 0xd43b, 0xd43b, 0xd43d, 0xd43b, 0xd43b, 0xd43b,
-	0xd43b, 0xd43b, 0xd43b, 0x080c, 0x0d65, 0x6003, 0x000c, 0x080c,
-	0x891b, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085, 0x0208,
-	0x001a, 0x080c, 0x9c93, 0x0005, 0xd459, 0xd459, 0xd459, 0xd459,
-	0xd45b, 0xd47b, 0xd459, 0xd459, 0xd459, 0xd459, 0xd459, 0xd459,
-	0xd459, 0x080c, 0x0d65, 0x00d6, 0x2c68, 0x080c, 0x9b84, 0x01b0,
+	0x1178, 0x080c, 0x8891, 0x0036, 0x0096, 0x6014, 0x2048, 0x2019,
+	0x0004, 0x080c, 0xd267, 0x009e, 0x003e, 0x080c, 0x894f, 0x0005,
+	0x9186, 0x0014, 0x0d70, 0x080c, 0x9c9f, 0x0005, 0xd475, 0xd473,
+	0xd473, 0xd473, 0xd473, 0xd473, 0xd475, 0xd473, 0xd473, 0xd473,
+	0xd473, 0xd473, 0xd473, 0x080c, 0x0d65, 0x6003, 0x000c, 0x080c,
+	0x894f, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085, 0x0208,
+	0x001a, 0x080c, 0x9c9f, 0x0005, 0xd491, 0xd491, 0xd491, 0xd491,
+	0xd493, 0xd4b3, 0xd491, 0xd491, 0xd491, 0xd491, 0xd491, 0xd491,
+	0xd491, 0x080c, 0x0d65, 0x00d6, 0x2c68, 0x080c, 0x9b90, 0x01b0,
 	0x6003, 0x0001, 0x6007, 0x001e, 0x2009, 0x026e, 0x210c, 0x613a,
 	0x2009, 0x026f, 0x210c, 0x613e, 0x600b, 0xffff, 0x6910, 0x6112,
-	0x6023, 0x0004, 0x2009, 0x8020, 0x080c, 0x84b3, 0x2d60, 0x080c,
-	0x9bda, 0x00de, 0x0005, 0x080c, 0x9bda, 0x0005, 0x00e6, 0x6010,
+	0x6023, 0x0004, 0x2009, 0x8020, 0x080c, 0x84e7, 0x2d60, 0x080c,
+	0x9be6, 0x00de, 0x0005, 0x080c, 0x9be6, 0x0005, 0x00e6, 0x6010,
 	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ec, 0x00ee, 0x0005, 0x2009,
-	0x1873, 0x210c, 0xd1ec, 0x05b0, 0x6003, 0x0002, 0x6024, 0xc0e5,
-	0x6026, 0xd0cc, 0x0150, 0x2001, 0x1958, 0x2004, 0x604a, 0x2009,
-	0x1873, 0x210c, 0xd1f4, 0x1520, 0x00a0, 0x2009, 0x1873, 0x210c,
+	0x187b, 0x210c, 0xd1ec, 0x05b0, 0x6003, 0x0002, 0x6024, 0xc0e5,
+	0x6026, 0xd0cc, 0x0150, 0x2001, 0x1960, 0x2004, 0x604a, 0x2009,
+	0x187b, 0x210c, 0xd1f4, 0x1520, 0x00a0, 0x2009, 0x187b, 0x210c,
 	0xd1f4, 0x0128, 0x6024, 0xc0e4, 0x6026, 0x9006, 0x00d8, 0x2001,
-	0x1958, 0x200c, 0x2001, 0x1956, 0x2004, 0x9100, 0x9080, 0x000a,
+	0x1960, 0x200c, 0x2001, 0x195e, 0x2004, 0x9100, 0x9080, 0x000a,
 	0x604a, 0x6010, 0x00b6, 0x2058, 0xb8ac, 0x00be, 0x0008, 0x2104,
 	0x9005, 0x0118, 0x9088, 0x0003, 0x0cd0, 0x2c0a, 0x600f, 0x0000,
 	0x9085, 0x0001, 0x0005, 0x0016, 0x00c6, 0x00e6, 0x615c, 0xb8ac,
 	0x2060, 0x8cff, 0x0180, 0x84ff, 0x1118, 0x605c, 0x9106, 0x1138,
-	0x600c, 0x2072, 0x080c, 0x83a2, 0x080c, 0x9bda, 0x0010, 0x9cf0,
+	0x600c, 0x2072, 0x080c, 0x83d6, 0x080c, 0x9be6, 0x0010, 0x9cf0,
 	0x0003, 0x2e64, 0x0c70, 0x00ee, 0x00ce, 0x001e, 0x0005, 0x00d6,
 	0x00b6, 0x6010, 0x2058, 0xb8ac, 0x2068, 0x9005, 0x0130, 0x9c06,
 	0x0110, 0x680c, 0x0cd0, 0x600c, 0x680e, 0x00be, 0x00de, 0x0005,
 	0x0026, 0x0036, 0x0156, 0x2011, 0x182b, 0x2204, 0x9084, 0x00ff,
 	0x2019, 0x026e, 0x2334, 0x9636, 0x1508, 0x8318, 0x2334, 0x2204,
 	0x9084, 0xff00, 0x9636, 0x11d0, 0x2011, 0x0270, 0x20a9, 0x0004,
-	0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xabd3, 0x009e,
+	0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xabee, 0x009e,
 	0x1168, 0x2011, 0x0274, 0x20a9, 0x0004, 0x6010, 0x0096, 0x2048,
-	0x2019, 0x0006, 0x080c, 0xabd3, 0x009e, 0x1100, 0x015e, 0x003e,
-	0x002e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5c6a, 0x080c,
-	0x2de9, 0x00ee, 0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800,
+	0x2019, 0x0006, 0x080c, 0xabee, 0x009e, 0x1100, 0x015e, 0x003e,
+	0x002e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c, 0x5c8a, 0x080c,
+	0x2e09, 0x00ee, 0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058, 0xb800,
 	0x00be, 0xd0fc, 0x0108, 0x0011, 0x00ee, 0x0005, 0xa880, 0xc0e5,
 	0xa882, 0x0005, 0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066, 0x0056,
-	0x0046, 0x0026, 0x0016, 0x0126, 0x2091, 0x8000, 0x2029, 0x19c3,
-	0x252c, 0x2021, 0x19ca, 0x2424, 0x2061, 0x1ddc, 0x2071, 0x1800,
+	0x0046, 0x0026, 0x0016, 0x0126, 0x2091, 0x8000, 0x2029, 0x19cb,
+	0x252c, 0x2021, 0x19d2, 0x2424, 0x2061, 0x1ddc, 0x2071, 0x1800,
 	0x7650, 0x7070, 0x9606, 0x0578, 0x6720, 0x9786, 0x0001, 0x0118,
 	0x9786, 0x0008, 0x1500, 0x2500, 0x9c06, 0x01e8, 0x2400, 0x9c06,
-	0x01d0, 0x080c, 0xd2b5, 0x01b8, 0x080c, 0xd2c5, 0x11a0, 0x6000,
-	0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x1921, 0x001e, 0x080c,
-	0xba46, 0x1110, 0x080c, 0x303d, 0x080c, 0xba57, 0x1110, 0x080c,
-	0xa581, 0x080c, 0x9c14, 0x9ce0, 0x001c, 0x2001, 0x1819, 0x2004,
+	0x01d0, 0x080c, 0xd2ed, 0x01b8, 0x080c, 0xd2fd, 0x11a0, 0x6000,
+	0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x193e, 0x001e, 0x080c,
+	0xba74, 0x1110, 0x080c, 0x305d, 0x080c, 0xba85, 0x1110, 0x080c,
+	0xa59c, 0x080c, 0x9c20, 0x9ce0, 0x001c, 0x2001, 0x1819, 0x2004,
 	0x9c02, 0x1208, 0x0858, 0x012e, 0x001e, 0x002e, 0x004e, 0x005e,
 	0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x2001, 0x1810,
 	0x2004, 0xd0dc, 0x0005, 0x0006, 0x2001, 0x1836, 0x2004, 0xd09c,
-	0x000e, 0x0005, 0x0006, 0x0036, 0x0046, 0x080c, 0xbf61, 0x0168,
+	0x000e, 0x0005, 0x0006, 0x0036, 0x0046, 0x080c, 0xbf8f, 0x0168,
 	0x2019, 0xffff, 0x9005, 0x0128, 0x6010, 0x00b6, 0x2058, 0xbba0,
-	0x00be, 0x2021, 0x0004, 0x080c, 0x4a77, 0x004e, 0x003e, 0x000e,
-	0x6004, 0x9086, 0x0001, 0x1128, 0x080c, 0x94dd, 0x080c, 0x9c14,
+	0x00be, 0x2021, 0x0004, 0x080c, 0x4a97, 0x004e, 0x003e, 0x000e,
+	0x6004, 0x9086, 0x0001, 0x1128, 0x080c, 0x94e5, 0x080c, 0x9c20,
 	0x9006, 0x0005, 0x00e6, 0x00c6, 0x00b6, 0x0046, 0x2061, 0x1ddc,
 	0x2071, 0x1800, 0x7450, 0x7070, 0x8001, 0x9402, 0x12b8, 0x2100,
 	0x9c06, 0x0148, 0x6000, 0x9086, 0x0000, 0x0128, 0x6010, 0x2058,
 	0xb8a0, 0x9206, 0x0140, 0x9ce0, 0x001c, 0x2001, 0x1819, 0x2004,
 	0x9c02, 0x1220, 0x0c60, 0x9085, 0x0001, 0x0008, 0x9006, 0x004e,
 	0x00be, 0x00ce, 0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6, 0x0016,
-	0x2091, 0x8000, 0x2071, 0x1840, 0xd5a4, 0x0118, 0x7034, 0x8000,
-	0x7036, 0xd5b4, 0x0118, 0x7030, 0x8000, 0x7032, 0xd5ac, 0x0178,
+	0x2091, 0x8000, 0x2071, 0x1840, 0xd5a4, 0x0118, 0x7054, 0x8000,
+	0x7056, 0xd5b4, 0x0118, 0x7050, 0x8000, 0x7052, 0xd5ac, 0x0178,
 	0x2500, 0x9084, 0x0007, 0x908e, 0x0003, 0x0148, 0x908e, 0x0004,
 	0x0130, 0x908e, 0x0005, 0x0118, 0x2071, 0x184a, 0x0089, 0x001e,
 	0x00ee, 0x000e, 0x012e, 0x0005, 0x0126, 0x0006, 0x00e6, 0x2091,
@@ -6648,15 +6655,15 @@
 	0x2e04, 0x8000, 0x2072, 0x1220, 0x8e70, 0x2e04, 0x8000, 0x2072,
 	0x0005, 0x00e6, 0x2071, 0x1840, 0x0c99, 0x00ee, 0x0005, 0x00e6,
 	0x2071, 0x1844, 0x0c69, 0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6,
-	0x2091, 0x8000, 0x2071, 0x1840, 0x7044, 0x8000, 0x7046, 0x00ee,
+	0x2091, 0x8000, 0x2071, 0x1840, 0x7064, 0x8000, 0x7066, 0x00ee,
 	0x000e, 0x012e, 0x0005, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010,
 	0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000,
-	0x2000, 0x4000, 0x8000, 0x9407
+	0x2000, 0x4000, 0x8000, 0x8c0a
 };
 #ifdef UNIQUE_FW_NAME
-unsigned short fw2322flx_length01 = 0xce4c;
+unsigned short fw2322flx_length01 = 0xce84;
 #else
-unsigned short risc_code_length01 = 0xce4c;
+unsigned short risc_code_length01 = 0xce84;
 #endif
 
 /*
@@ -7054,7 +7061,7 @@
 	0x0000, 0x0002, 0x0002, 0x1f43, 0x000b, 0x1256, 0x0001, 0xff88,
 	0x0000, 0x0002, 0x0013, 0x0258, 0x0001, 0xff88, 0x0000, 0x0004,
 	0x0000, 0xff31, 0x0015, 0x0033, 0x0000, 0xb011, 0x001b, 0x825b,
-	0x0000, 0xb0ff, 0x0011, 0x16a0, 0x0000, 0xff16, 0x000b, 0x24e2,
+	0x0000, 0xb0ff, 0x0011, 0x16a0, 0x0000, 0xff16, 0x001b, 0x2262,
 	0x0002, 0xb100, 0x0003, 0x0263, 0x0010, 0xb1ff, 0x0001, 0x17a0,
 	0x0010, 0xff17, 0x0003, 0x0221, 0x0000, 0x16ff, 0x0001, 0x18a0,
 	0x0010, 0xff00, 0x001b, 0x226d, 0x0002, 0x1700, 0x0013, 0x12c0,
@@ -7421,6 +7428,6 @@
 	0x000b, 0x880c, 0x0012, 0x1027, 0x0010, 0xffb2, 0x0011, 0x1388,
 	0x0010, 0x0011, 0x0000, 0xff31, 0x0015, 0x0033, 0x0010, 0xb20a,
 	0x000b, 0x8814, 0x0015, 0x00b8, 0x0000, 0x0007, 0x0013, 0x4817,
-	0x0000, 0xb838, 0x0017, 0x4000, 0xa5a5, 0x1ab5
+	0x0000, 0xb838, 0x0017, 0x4000, 0xa595, 0x1d35
 };
 unsigned short xseqflx_code_length01 = 0x1036;
diff -Nru a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
--- a/drivers/scsi/qla2xxx/qla_dbg.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/qla2xxx/qla_dbg.c	2004-12-24 13:37:19 -08:00
@@ -36,13 +36,12 @@
 	uint16_t	mb0, mb2;
 
 	uint32_t	stat;
-	device_reg_t	*reg;
-	uint16_t	*dmp_reg;
+	device_reg_t __iomem *reg = ha->iobase;
+	uint16_t __iomem *dmp_reg;
 	unsigned long	flags;
 	struct qla2300_fw_dump	*fw;
 	uint32_t	dump_size, data_ram_cnt;
 
-	reg = ha->iobase;
 	risc_address = data_ram_cnt = 0;
 	mb0 = mb2 = 0;
 	flags = 0;
@@ -86,89 +85,90 @@
 				rval = QLA_FUNCTION_TIMEOUT;
 		}
 	} else {
+		RD_REG_WORD(&reg->hccr);		/* PCI Posting. */
 		udelay(10);
 	}
 
 	if (rval == QLA_SUCCESS) {
-		dmp_reg = (uint16_t *)(reg + 0);
+		dmp_reg = (uint16_t __iomem *)(reg + 0);
 		for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++) 
 			fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x10);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x10);
 		for (cnt = 0; cnt < sizeof(fw->risc_host_reg) / 2; cnt++) 
 			fw->risc_host_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x40);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x40);
 		for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) 
 			fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x40);
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->resp_dma_reg) / 2; cnt++) 
 			fw->resp_dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x50);
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++) 
 			fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x00);
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0xA0);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xA0);
 		for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++) 
 			fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2000); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++) 
 			fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2200); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++) 
 			fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2400); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++) 
 			fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2600); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++) 
 			fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2800); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++) 
 			fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2A00); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++) 
 			fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2C00); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++) 
 			fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2E00); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++) 
 			fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x10); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++) 
 			fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x20); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++) 
 			fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x30); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++) 
 			fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
@@ -221,6 +221,7 @@
 					WRT_REG_WORD(&reg->semaphore, 0);
 					WRT_REG_WORD(&reg->hccr,
 					    HCCR_CLR_RISC_INT);
+					RD_REG_WORD(&reg->hccr);
 					break;
 				} else if (stat == 0x10 || stat == 0x11) {
 					set_bit(MBX_INTERRUPT,
@@ -231,11 +232,13 @@
 
 					WRT_REG_WORD(&reg->hccr,
 					    HCCR_CLR_RISC_INT);
+					RD_REG_WORD(&reg->hccr);
 					break;
 				}
 
 				/* clear this intr; it wasn't a mailbox intr */
 				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+				RD_REG_WORD(&reg->hccr);
 			}
 			udelay(5);
 		}
@@ -277,6 +280,7 @@
 					WRT_REG_WORD(&reg->semaphore, 0);
 					WRT_REG_WORD(&reg->hccr,
 					    HCCR_CLR_RISC_INT);
+					RD_REG_WORD(&reg->hccr);
 					break;
 				} else if (stat == 0x10 || stat == 0x11) {
 					set_bit(MBX_INTERRUPT,
@@ -287,11 +291,13 @@
 
 					WRT_REG_WORD(&reg->hccr,
 					    HCCR_CLR_RISC_INT);
+					RD_REG_WORD(&reg->hccr);
 					break;
 				}
 
 				/* clear this intr; it wasn't a mailbox intr */
 				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+				RD_REG_WORD(&reg->hccr);
 			}
 			udelay(5);
 		}
@@ -334,6 +340,7 @@
 					WRT_REG_WORD(&reg->semaphore, 0);
 					WRT_REG_WORD(&reg->hccr,
 					    HCCR_CLR_RISC_INT);
+					RD_REG_WORD(&reg->hccr);
 					break;
 				} else if (stat == 0x10 || stat == 0x11) {
 					set_bit(MBX_INTERRUPT,
@@ -344,11 +351,13 @@
 
 					WRT_REG_WORD(&reg->hccr,
 					    HCCR_CLR_RISC_INT);
+					RD_REG_WORD(&reg->hccr);
 					break;
 				}
 
 				/* clear this intr; it wasn't a mailbox intr */
 				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+				RD_REG_WORD(&reg->hccr);
 			}
 			udelay(5);
 		}
@@ -578,13 +587,11 @@
 	uint32_t	cnt, timer;
 	uint16_t	risc_address;
 	uint16_t	mb0, mb2;
-
-	device_reg_t	*reg;
-	uint16_t	*dmp_reg;
+	device_reg_t __iomem *reg = ha->iobase;
+	uint16_t __iomem *dmp_reg;
 	unsigned long	flags;
 	struct qla2100_fw_dump	*fw;
 
-	reg = ha->iobase;
 	risc_address = 0;
 	mb0 = mb2 = 0;
 	flags = 0;
@@ -624,79 +631,79 @@
 			rval = QLA_FUNCTION_TIMEOUT;
 	}
 	if (rval == QLA_SUCCESS) {
-		dmp_reg = (uint16_t *)(reg + 0);
+		dmp_reg = (uint16_t __iomem *)(reg + 0);
 		for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++) 
 			fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x10);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x10);
 		for (cnt = 0; cnt < ha->mbx_count; cnt++) {
 			if (cnt == 8) {
-				dmp_reg = (uint16_t *)((uint8_t *)reg + 0xe0);
+				dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xe0);
 			}
 			fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++);
 		}
 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x20);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x20);
 		for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++) 
 			fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x00);
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0xA0);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xA0);
 		for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++) 
 			fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2000); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++) 
 			fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2100); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++) 
 			fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2200); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++) 
 			fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2300); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++) 
 			fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2400); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++) 
 			fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2500); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++) 
 			fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2600); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++) 
 			fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->pcr, 0x2700); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++) 
 			fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x10); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++) 
 			fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x20); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++) 
 			fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
 		WRT_REG_WORD(&reg->ctrl_status, 0x30); 
-		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
 		for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++) 
 			fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++);
 
@@ -731,6 +738,7 @@
 				WRT_REG_WORD(&reg->mctr, 0xf1);
 			else
 				WRT_REG_WORD(&reg->mctr, 0xf2);
+			RD_REG_WORD(&reg->mctr);	/* PCI Posting. */
 
 			/* Release RISC. */
 			WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
@@ -761,9 +769,11 @@
 					WRT_REG_WORD(&reg->semaphore, 0);
 					WRT_REG_WORD(&reg->hccr,
 					    HCCR_CLR_RISC_INT);
+					RD_REG_WORD(&reg->hccr);
 					break;
 				}
 				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+				RD_REG_WORD(&reg->hccr);
 			}
 			udelay(5);
 		}
@@ -974,9 +984,7 @@
 void 
 qla2x00_dump_regs(scsi_qla_host_t *ha) 
 {
-	device_reg_t	*reg;
-
-	reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	printk("Mailbox registers:\n");
 	printk("scsi(%ld): mbox 0 0x%04x \n",
diff -Nru a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
--- a/drivers/scsi/qla2xxx/qla_def.h	2004-12-24 13:36:59 -08:00
+++ b/drivers/scsi/qla2xxx/qla_def.h	2004-12-24 13:36:59 -08:00
@@ -26,8 +26,10 @@
 #include <linux/module.h>
 #include <linux/list.h>
 #include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/dmapool.h>
 #include <linux/mempool.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
@@ -232,6 +234,7 @@
 /* ISP request and response entry counts (37-65535) */
 #define REQUEST_ENTRY_CNT_2100		128	/* Number of request entries. */
 #define REQUEST_ENTRY_CNT_2200		2048	/* Number of request entries. */
+#define REQUEST_ENTRY_CNT_2XXX_EXT_MEM	4096	/* Number of request entries. */
 #define RESPONSE_ENTRY_CNT_2100		64	/* Number of response entries.*/
 #define RESPONSE_ENTRY_CNT_2300		512	/* Number of response entries.*/
 
@@ -2028,6 +2031,16 @@
 	struct qla_fw_info *fw_info;
 };
 
+/* Return data from MBC_GET_ID_LIST call. */
+struct gid_list_info {
+	uint8_t	al_pa;
+	uint8_t	area;
+	uint8_t	domain;		
+	uint8_t	loop_id_2100;	/* ISP2100/ISP2200 -- 4 bytes. */
+	uint16_t loop_id;	/* ISP23XX         -- 6 bytes. */
+};
+#define GID_LIST_SIZE (sizeof(struct gid_list_info) * MAX_FIBRE_DEVICES)
+
 /*
  * Linux Host Adapter structure
  */
@@ -2113,11 +2126,9 @@
 
 	spinlock_t		hardware_lock ____cacheline_aligned;
 
-	device_reg_t	*iobase;		/* Base I/O address */
+	device_reg_t __iomem *iobase;		/* Base I/O address */
 	unsigned long	pio_address;
 	unsigned long	pio_length;
-	void *		mmio_address;
-	unsigned long	mmio_length;
 #define MIN_IOBASE_LEN		0x100
 
 	/* ISP ring lock, rings, and indexes */
@@ -2239,8 +2250,6 @@
 
 	struct io_descriptor	io_descriptors[MAX_IO_DESCRIPTORS];
 	uint16_t		iodesc_signature;
-	port_database_t		*iodesc_pd;
-	dma_addr_t		iodesc_pd_dma;
 
 	/* OS target queue pointers. */
 	os_tgt_t		*otgt[MAX_FIBRE_DEVICES];
@@ -2275,10 +2284,22 @@
 	uint32_t        timer_active;
 	struct timer_list        timer;
 
-	/* Firmware Initialization Control Block data */
-	dma_addr_t	init_cb_dma;         /* Physical address. */
+	dma_addr_t	gid_list_dma;
+	struct gid_list_info *gid_list;
+
+	dma_addr_t	rlc_rsp_dma;
+	rpt_lun_cmd_rsp_t *rlc_rsp;
+
+	/* Small DMA pool allocations -- maximum 256 bytes in length. */ 
+#define DMA_POOL_SIZE	256
+	struct dma_pool *s_dma_pool;
+
+	dma_addr_t	init_cb_dma;
 	init_cb_t       *init_cb;
-  
+
+	dma_addr_t	iodesc_pd_dma;
+	port_database_t *iodesc_pd;
+
 	/* These are used by mailbox operations. */
 	volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
 
diff -Nru a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
--- a/drivers/scsi/qla2xxx/qla_gbl.h	2004-12-24 13:37:33 -08:00
+++ b/drivers/scsi/qla2xxx/qla_gbl.h	2004-12-24 13:37:33 -08:00
@@ -246,7 +246,8 @@
 /*
  * Global Function Prototypes in qla_isr.c source file.
  */
-extern irqreturn_t qla2x00_intr_handler(int, void *, struct pt_regs *);
+extern irqreturn_t qla2100_intr_handler(int, void *, struct pt_regs *);
+extern irqreturn_t qla2300_intr_handler(int, void *, struct pt_regs *);
 extern void qla2x00_process_response_queue(struct scsi_qla_host *);
 
 /*
diff -Nru a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
--- a/drivers/scsi/qla2xxx/qla_init.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/qla2xxx/qla_init.c	2004-12-24 13:37:19 -08:00
@@ -37,6 +37,7 @@
 static int qla2x00_isp_firmware(scsi_qla_host_t *);
 static void qla2x00_reset_chip(scsi_qla_host_t *);
 static int qla2x00_chip_diag(scsi_qla_host_t *);
+static void qla2x00_resize_request_q(scsi_qla_host_t *);
 static int qla2x00_setup_chip(scsi_qla_host_t *);
 static void qla2x00_init_response_q_entries(scsi_qla_host_t *);
 static int qla2x00_init_rings(scsi_qla_host_t *);
@@ -50,8 +51,7 @@
 static void qla2x00_lun_discovery(scsi_qla_host_t *, fc_port_t *);
 static int qla2x00_rpt_lun_discovery(scsi_qla_host_t *, fc_port_t *,
     inq_cmd_rsp_t *, dma_addr_t);
-static int qla2x00_report_lun(scsi_qla_host_t *, fc_port_t *,
-    rpt_lun_cmd_rsp_t *, dma_addr_t);
+static int qla2x00_report_lun(scsi_qla_host_t *, fc_port_t *);
 static fc_lun_t *qla2x00_cfg_lun(scsi_qla_host_t *, fc_port_t *, uint16_t,
     inq_cmd_rsp_t *, dma_addr_t);
 static fc_lun_t * qla2x00_add_lun(fc_port_t *, uint16_t);
@@ -217,7 +217,9 @@
 					rval = QLA_FUNCTION_FAILED;
 				if (ha->mem_err)
 					restart_risc = 1;
-			}
+			} else if (ha->device_flags & DFLG_NO_CABLE)
+				/* If no cable, then all is good. */
+				rval = QLA_SUCCESS;
 		}
 	} while (restart_risc && retry--);
 
@@ -306,6 +308,7 @@
 
 			/* Select FPM registers. */
 			WRT_REG_WORD(&ha->iobase->ctrl_status, 0x20);
+			RD_REG_WORD(&ha->iobase->ctrl_status);
 
 			/* Get the fb rev level */
 			ha->fb_rev = RD_FB_CMD_REG(ha, ha->iobase);
@@ -315,6 +318,7 @@
 
 			/* Deselect FPM registers. */
 			WRT_REG_WORD(&ha->iobase->ctrl_status, 0x0);
+			RD_REG_WORD(&ha->iobase->ctrl_status);
 
 			/* Release RISC module. */
 			WRT_REG_WORD(&ha->iobase->hccr, HCCR_RELEASE_RISC);
@@ -381,7 +385,7 @@
 qla2x00_reset_chip(scsi_qla_host_t *ha) 
 {
 	unsigned long   flags = 0;
-	device_reg_t	*reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	uint32_t	cnt;
 	unsigned long	mbx_flags = 0;
 	uint16_t	cmd;
@@ -408,25 +412,32 @@
 				udelay(100);
 			}
 		} else {
+			RD_REG_WORD(&reg->hccr);	/* PCI Posting. */
 			udelay(10);
 		}
 
 		/* Select FPM registers. */
 		WRT_REG_WORD(&reg->ctrl_status, 0x20);
+		RD_REG_WORD(&reg->ctrl_status);		/* PCI Posting. */
 
 		/* FPM Soft Reset. */
 		WRT_REG_WORD(&reg->fpm_diag_config, 0x100);
+		RD_REG_WORD(&reg->fpm_diag_config);	/* PCI Posting. */
 
 		/* Toggle Fpm Reset. */
-		if (!IS_QLA2200(ha))
+		if (!IS_QLA2200(ha)) {
 			WRT_REG_WORD(&reg->fpm_diag_config, 0x0);
+			RD_REG_WORD(&reg->fpm_diag_config); /* PCI Posting. */
+		}
 
 		/* Select frame buffer registers. */
 		WRT_REG_WORD(&reg->ctrl_status, 0x10);
+		RD_REG_WORD(&reg->ctrl_status);		/* PCI Posting. */
 
 		/* Reset frame buffer FIFOs. */
 		if (IS_QLA2200(ha)) {
 			WRT_FB_CMD_REG(ha, reg, 0xa000);
+			RD_FB_CMD_REG(ha, reg);		/* PCI Posting. */
 		} else {
 			WRT_FB_CMD_REG(ha, reg, 0x00fc);
 
@@ -440,12 +451,15 @@
 
 		/* Select RISC module registers. */
 		WRT_REG_WORD(&reg->ctrl_status, 0);
+		RD_REG_WORD(&reg->ctrl_status);		/* PCI Posting. */
 
 		/* Reset RISC processor. */
 		WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
+		RD_REG_WORD(&reg->hccr);		/* PCI Posting. */
 
 		/* Release RISC processor. */
 		WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
+		RD_REG_WORD(&reg->hccr);		/* PCI Posting. */
 	}
 
 	WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
@@ -478,7 +492,7 @@
 
 	/* Release RISC processor. */
 	WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
-	RD_REG_WORD(&reg->hccr);		/* PCI Posting. */
+	RD_REG_WORD(&reg->hccr);			/* PCI Posting. */
 
 	if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) {
 		for (cnt = 0; cnt < 30000; cnt++) {
@@ -507,8 +521,10 @@
 	pci_write_config_word(ha->pdev, PCI_COMMAND, cmd);
 
 	/* Disable RISC pause on FPM parity error. */
-	if (!IS_QLA2100(ha))
+	if (!IS_QLA2100(ha)) {
 		WRT_REG_WORD(&reg->hccr, HCCR_DISABLE_PARITY_PAUSE);
+		RD_REG_WORD(&reg->hccr);		/* PCI Posting. */
+	}
 
 	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 }
@@ -523,7 +539,7 @@
 qla2x00_chip_diag(scsi_qla_host_t *ha)
 {
 	int		rval;
-	device_reg_t	*reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	unsigned long	flags = 0;
 	uint16_t	data;
 	uint32_t	cnt;
@@ -539,6 +555,7 @@
 
 	/* Reset ISP chip. */
 	WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
+
 	/*
 	 * We need to have a delay here since the card will not respond while
 	 * in reset causing an MCA on some architectures.
@@ -638,6 +655,59 @@
 }
 
 /**
+ * qla2x00_resize_request_q() - Resize request queue given available ISP memory.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+static void
+qla2x00_resize_request_q(scsi_qla_host_t *ha)
+{
+	int rval;
+	uint16_t fw_iocb_cnt = 0;
+	uint16_t request_q_length = REQUEST_ENTRY_CNT_2XXX_EXT_MEM;
+	dma_addr_t request_dma;
+	request_t *request_ring;
+
+	/* Valid only on recent ISPs. */
+	if (IS_QLA2100(ha) || IS_QLA2200(ha))
+		return;
+
+	/* Retrieve IOCB counts available to the firmware. */
+	rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt);
+	if (rval)
+		return;
+	/* No point in continuing if current settings are sufficient. */
+	if (fw_iocb_cnt < 1024)
+		return;
+	if (ha->request_q_length >= request_q_length)
+		return;
+
+	/* Attempt to claim larger area for request queue. */
+	request_ring = dma_alloc_coherent(&ha->pdev->dev,
+	    (request_q_length + 1) * sizeof(request_t), &request_dma,
+	    GFP_KERNEL);
+	if (request_ring == NULL)
+		return;
+
+	/* Resize successful, report extensions. */
+	qla_printk(KERN_INFO, ha, "Extended memory detected (%d KB)...\n",
+	    (ha->fw_memory_size + 1) / 1024);
+	qla_printk(KERN_INFO, ha, "Resizing request queue depth "
+	    "(%d -> %d)...\n", ha->request_q_length, request_q_length);
+
+	/* Clear old allocations. */
+	dma_free_coherent(&ha->pdev->dev,
+	    (ha->request_q_length + 1) * sizeof(request_t), ha->request_ring,
+	    ha->request_dma);
+
+	/* Begin using larger queue. */
+	ha->request_q_length = request_q_length;
+	ha->request_ring = request_ring;
+	ha->request_dma = request_dma;
+}
+
+/**
  * qla2x00_setup_chip() - Load and start RISC firmware.
  * @ha: HA context
  *
@@ -734,9 +804,9 @@
 				    &ha->fw_minor_version,
 				    &ha->fw_subminor_version,
 				    &ha->fw_attributes, &ha->fw_memory_size);
+				qla2x00_resize_request_q(ha);
 			}
-		}
-		else {
+		} else {
 			DEBUG2(printk(KERN_INFO
 			    "scsi(%ld): ISP Firmware failed checksum.\n",
 			    ha->host_no));
@@ -835,7 +905,7 @@
 	int	rval;
 	unsigned long flags = 0;
 	int cnt;
-	device_reg_t *reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	spin_lock_irqsave(&ha->hardware_lock, flags);
 
@@ -856,6 +926,16 @@
 	ha->response_ring_ptr = ha->response_ring;
 	ha->rsp_ring_index    = 0;
 
+	/* Setup ring parameters in initialization control block. */
+	ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0);
+	ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0);
+	ha->init_cb->request_q_length = cpu_to_le16(ha->request_q_length);
+	ha->init_cb->response_q_length = cpu_to_le16(ha->response_q_length);
+	ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma));
+	ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma));
+	ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma));
+	ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma));
+
 	/* Initialize response queue entries */
 	qla2x00_init_response_q_entries(ha);
 
@@ -863,7 +943,7 @@
  	WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0);
  	WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0);
  	WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0);
-	RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg));
+	RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg));		/* PCI Posting. */
 
 	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
@@ -967,8 +1047,7 @@
 			break;
 
 		/* Delay for a while */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ / 2);
+		msleep(500);
 
 		DEBUG3(printk("scsi(%ld): fw_state=%x curr time=%lx.\n",
 		    ha->host_no, fw_state, jiffies));
@@ -1113,14 +1192,11 @@
 	init_cb_t *icb   = ha->init_cb;
 	nvram_t *nv    = (nvram_t *)ha->request_ring;
 	uint16_t  *wptr  = (uint16_t *)ha->request_ring;
-	device_reg_t *reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	uint8_t  timer_mode;
 
 	rval = QLA_SUCCESS;
 
-	if (ha->flags.init_done)
-		return (rval);
-
 	/* Determine NVRAM starting address. */
 	ha->nvram_base = 0;
 	if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha))
@@ -1403,18 +1479,6 @@
 		ha->binding_type = BIND_BY_PORT_NAME;
 	}
 
-	/*
-	 * Setup ring parameters in initialization control block
-	 */
-	icb->request_q_outpointer = __constant_cpu_to_le16(0);
-	icb->response_q_inpointer = __constant_cpu_to_le16(0);
-	icb->request_q_length = cpu_to_le16(ha->request_q_length);
-	icb->response_q_length = cpu_to_le16(ha->response_q_length);
-	icb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma));
-	icb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma));
-	icb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma));
-	icb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma));
-
 	icb->lun_enables = __constant_cpu_to_le16(0);
 	icb->command_resource_count = 0;
 	icb->immediate_notify_resource_count = 0;
@@ -1638,50 +1702,28 @@
 
 	uint16_t	index;
 	uint16_t	entries;
-	struct dev_id {
-		uint8_t	al_pa;
-		uint8_t	area;
-		uint8_t	domain;		
-		uint8_t	loop_id_2100;	/* ISP2100/ISP2200 -- 4 bytes. */
-		uint16_t loop_id;	/* ISP23XX         -- 6 bytes. */
-	} *id_list;
-#define MAX_ID_LIST_SIZE (sizeof(struct dev_id) * MAX_FIBRE_DEVICES)
-	dma_addr_t	id_list_dma;
 	char		*id_iter;
 	uint16_t	loop_id;
 	uint8_t		domain, area, al_pa;
 
 	found_devs = 0;
 	new_fcport = NULL;
-
 	entries = MAX_FIBRE_DEVICES;
-	id_list = pci_alloc_consistent(ha->pdev, MAX_ID_LIST_SIZE,
-	    &id_list_dma);
-	if (id_list == NULL) {
-		DEBUG2(printk("scsi(%ld): Failed to allocate memory, No local "
-		    "loop\n", ha->host_no));
-
-		qla_printk(KERN_WARNING, ha,
-		    "Memory Allocation failed - port_list");
-
-		ha->mem_err++;
-		return (QLA_MEMORY_ALLOC_FAILED);
-	}
-	memset(id_list, 0, MAX_ID_LIST_SIZE);
 
 	DEBUG3(printk("scsi(%ld): Getting FCAL position map\n", ha->host_no));
 	DEBUG3(qla2x00_get_fcal_position_map(ha, NULL));
 
 	/* Get list of logged in devices. */
-	rval = qla2x00_get_id_list(ha, id_list, id_list_dma, &entries);
-	if (rval != QLA_SUCCESS) {
+	memset(ha->gid_list, 0, GID_LIST_SIZE);
+	rval = qla2x00_get_id_list(ha, ha->gid_list, ha->gid_list_dma,
+	    &entries);
+	if (rval != QLA_SUCCESS)
 		goto cleanup_allocation;
-	}
 
 	DEBUG3(printk("scsi(%ld): Entries in ID list (%d)\n",
 	    ha->host_no, entries));
-	DEBUG3(qla2x00_dump_buffer((uint8_t *)id_list,
-	    entries * sizeof(struct dev_id)));
+	DEBUG3(qla2x00_dump_buffer((uint8_t *)ha->gid_list,
+	    entries * sizeof(struct gid_list_info)));
 
 	/* Allocate temporary fcport for any new fcports discovered. */
 	new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
@@ -1709,18 +1751,18 @@
 	}
 
 	/* Add devices to port list. */
-	id_iter = (char *)id_list;
+	id_iter = (char *)ha->gid_list;
 	for (index = 0; index < entries; index++) {
-		domain = ((struct dev_id *)id_iter)->domain;
-		area = ((struct dev_id *)id_iter)->area;
-		al_pa = ((struct dev_id *)id_iter)->al_pa;
+		domain = ((struct gid_list_info *)id_iter)->domain;
+		area = ((struct gid_list_info *)id_iter)->area;
+		al_pa = ((struct gid_list_info *)id_iter)->al_pa;
 		if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
-			loop_id =
-			    (uint16_t)((struct dev_id *)id_iter)->loop_id_2100;
+			loop_id = (uint16_t)
+			    ((struct gid_list_info *)id_iter)->loop_id_2100;
 			id_iter += 4;
 		} else {
-			loop_id =
-			    le16_to_cpu(((struct dev_id *)id_iter)->loop_id);
+			loop_id = le16_to_cpu(
+			    ((struct gid_list_info *)id_iter)->loop_id);
 			id_iter += 6;
 		}
 
@@ -1791,8 +1833,6 @@
 	}
 
 cleanup_allocation:
-	pci_free_consistent(ha->pdev, MAX_ID_LIST_SIZE, id_list, id_list_dma);
-
 	if (new_fcport)
 		kfree(new_fcport);
 
@@ -1900,7 +1940,7 @@
 	dma_addr_t	inq_dma;
 	uint16_t	lun;
 
-	inq = pci_alloc_consistent(ha->pdev, sizeof(inq_cmd_rsp_t), &inq_dma);
+	inq = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &inq_dma);
 	if (inq == NULL) {
 		qla_printk(KERN_WARNING, ha,
 		    "Memory Allocation failed - INQ\n");
@@ -1916,7 +1956,7 @@
 		}
 	}
 
-	pci_free_consistent(ha->pdev, sizeof(inq_cmd_rsp_t), inq, inq_dma);
+	dma_pool_free(ha->s_dma_pool, inq, inq_dma);
 }
 
 /*
@@ -1940,8 +1980,6 @@
 	int			rval;
 	uint32_t		len, cnt;
 	uint16_t		lun;
-	rpt_lun_cmd_rsp_t	*rlc;
-	dma_addr_t		rlc_dma;
 
 	/* Assume a failed status */
 	rval = QLA_FUNCTION_FAILED;
@@ -1950,30 +1988,19 @@
 	if ((fcport->flags & FCF_RLC_SUPPORT) == 0)
 		return (rval);
 
-	rlc = pci_alloc_consistent(ha->pdev, sizeof(rpt_lun_cmd_rsp_t),
-	    &rlc_dma);
-	if (rlc == NULL) {
-		qla_printk(KERN_WARNING, ha,
-			"Memory Allocation failed - RLC");
-		return QLA_MEMORY_ALLOC_FAILED;
-	}
-
-	rval = qla2x00_report_lun(ha, fcport, rlc, rlc_dma);
-	if (rval != QLA_SUCCESS) {
-		pci_free_consistent(ha->pdev, sizeof(rpt_lun_cmd_rsp_t), rlc,
-		    rlc_dma);
+	rval = qla2x00_report_lun(ha, fcport);
+	if (rval != QLA_SUCCESS)
 		return (rval);
-	}
 
 	/* Always add a fc_lun_t structure for lun 0 -- mid-layer requirement */
 	qla2x00_add_lun(fcport, 0);
 
 	/* Configure LUN list. */
-	len = be32_to_cpu(rlc->list.hdr.len);
+	len = be32_to_cpu(ha->rlc_rsp->list.hdr.len);
 	len /= 8;
 	for (cnt = 0; cnt < len; cnt++) {
-		lun = CHAR_TO_SHORT(rlc->list.lst[cnt].lsb,
-		    rlc->list.lst[cnt].msb.b);
+		lun = CHAR_TO_SHORT(ha->rlc_rsp->list.lst[cnt].lsb,
+		    ha->rlc_rsp->list.lst[cnt].msb.b);
 
 		DEBUG3(printk("scsi(%ld): RLC lun = (%d)\n", ha->host_no, lun));
 
@@ -1984,8 +2011,6 @@
 	}
 	atomic_set(&fcport->state, FCS_ONLINE);
 
-	pci_free_consistent(ha->pdev, sizeof(rpt_lun_cmd_rsp_t), rlc, rlc_dma);
-
 	return (rval);
 }
 
@@ -1996,8 +2021,6 @@
  * Input:
  *	ha:		adapter state pointer.
  *	fcport:		FC port structure pointer.
- *	mem:		pointer to dma memory object for report LUN IOCB
- *			packet.
  *
  * Returns:
  *	qla2x00 local function return status code.
@@ -2006,15 +2029,18 @@
  *	Kernel context.
  */
 static int
-qla2x00_report_lun(scsi_qla_host_t *ha,
-    fc_port_t *fcport, rpt_lun_cmd_rsp_t *rlc, dma_addr_t rlc_dma)
+qla2x00_report_lun(scsi_qla_host_t *ha, fc_port_t *fcport)
 {
 	int rval;
 	uint16_t retries;
 	uint16_t comp_status;
 	uint16_t scsi_status;
+	rpt_lun_cmd_rsp_t *rlc;
+	dma_addr_t rlc_dma;
 
 	rval = QLA_FUNCTION_FAILED;
+	rlc = ha->rlc_rsp;
+	rlc_dma = ha->rlc_rsp_dma;
 
 	for (retries = 3; retries; retries--) {
 		memset(rlc, 0, sizeof(rpt_lun_cmd_rsp_t));
@@ -4245,7 +4271,7 @@
 qla2x00_restart_isp(scsi_qla_host_t *ha)
 {
 	uint8_t		status = 0;
-	device_reg_t	*reg;
+	device_reg_t __iomem *reg = ha->iobase;
 	unsigned long	flags = 0;
 	uint32_t wait_time;
 
@@ -4259,9 +4285,13 @@
 			}
 
 			reg = ha->iobase;
+
 			spin_lock_irqsave(&ha->hardware_lock, flags);
+
 			/* Disable SRAM, Instruction RAM and GP RAM parity. */
 			WRT_REG_WORD(&reg->hccr, (HCCR_ENABLE_PARITY + 0x0));
+			RD_REG_WORD(&reg->hccr);	/* PCI Posting. */
+
 			spin_unlock_irqrestore(&ha->hardware_lock, flags);
 	
 			status = qla2x00_setup_chip(ha);
@@ -4277,6 +4307,7 @@
  				/* SRAM, Instruction RAM and GP RAM parity */
  				WRT_REG_WORD(&reg->hccr,
  				    (HCCR_ENABLE_PARITY + 0x7));
+			RD_REG_WORD(&reg->hccr);	/* PCI Posting. */
 
 			spin_unlock_irqrestore(&ha->hardware_lock, flags);
 		}
@@ -4325,13 +4356,16 @@
 qla2x00_reset_adapter(scsi_qla_host_t *ha)
 {
 	unsigned long flags = 0;
-	device_reg_t *reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	ha->flags.online = 0;
 	qla2x00_disable_intrs(ha);
+
 	/* Reset RISC processor. */
 	spin_lock_irqsave(&ha->hardware_lock, flags);
 	WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
+	RD_REG_WORD(&reg->hccr);			/* PCI Posting. */
 	WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
+	RD_REG_WORD(&reg->hccr);			/* PCI Posting. */
 	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 }
diff -Nru a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
--- a/drivers/scsi/qla2xxx/qla_inline.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/qla2xxx/qla_inline.h	2004-12-24 13:37:00 -08:00
@@ -18,7 +18,7 @@
  */
 
 
-static __inline__ uint16_t qla2x00_debounce_register(volatile uint16_t *);
+static __inline__ uint16_t qla2x00_debounce_register(volatile uint16_t __iomem *);
 /*
  * qla2x00_debounce_register
  *      Debounce register.
@@ -30,7 +30,7 @@
  *      register value.
  */
 static __inline__ uint16_t
-qla2x00_debounce_register(volatile uint16_t *addr) 
+qla2x00_debounce_register(volatile uint16_t __iomem *addr) 
 {
 	volatile uint16_t first;
 	volatile uint16_t second;
@@ -117,7 +117,10 @@
 static inline void 
 qla2x00_poll(scsi_qla_host_t *ha)
 {
-	qla2x00_intr_handler(0, ha, NULL);
+	if (IS_QLA2100(ha) || IS_QLA2200(ha))
+		qla2100_intr_handler(0, ha, NULL);
+	else
+		qla2300_intr_handler(0, ha, NULL);
 }
 
 
@@ -128,10 +131,9 @@
 qla2x00_enable_intrs(scsi_qla_host_t *ha)
 {
 	unsigned long flags = 0;
-	device_reg_t *reg;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	spin_lock_irqsave(&ha->hardware_lock, flags);
-	reg = ha->iobase;
 	ha->interrupts_on = 1;
 	/* enable risc and host interrupts */
 	WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
@@ -144,10 +146,9 @@
 qla2x00_disable_intrs(scsi_qla_host_t *ha)
 {
 	unsigned long flags = 0;
-	device_reg_t *reg;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	spin_lock_irqsave(&ha->hardware_lock, flags);
-	reg = ha->iobase;
 	ha->interrupts_on = 0;
 	/* disable risc and host interrupts */
 	WRT_REG_WORD(&reg->ictrl, 0);
diff -Nru a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
--- a/drivers/scsi/qla2xxx/qla_iocb.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/qla2xxx/qla_iocb.c	2004-12-24 13:37:00 -08:00
@@ -338,15 +338,15 @@
 	uint16_t	cnt;
 	uint16_t	req_cnt;
 	uint16_t	tot_dsds;
-	device_reg_t	*reg;
+	device_reg_t __iomem *reg;
 	char		tag[2];
 
 	/* Setup device pointers. */
 	ret = 0;
 	fclun = sp->lun_queue->fclun;
 	ha = fclun->fcport->ha;
-	cmd = sp->cmd;
 	reg = ha->iobase;
+	cmd = sp->cmd;
 
 	/* Send marker if required */
 	if (ha->marker_needed != 0) {
@@ -418,12 +418,9 @@
 	cmd_pkt->lun = cpu_to_le16(fclun->lun);
 
 	/* Update tagged queuing modifier */
+	cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG);
 	if (scsi_populate_tag_msg(cmd, tag)) {
 		switch (tag[0]) {
-		case MSG_SIMPLE_TAG:
-			cmd_pkt->control_flags =
-			    __constant_cpu_to_le16(CF_SIMPLE_TAG);
-			break;
 		case MSG_HEAD_TAG:
 			cmd_pkt->control_flags =
 			    __constant_cpu_to_le16(CF_HEAD_TAG);
@@ -550,7 +547,7 @@
 request_t *
 qla2x00_req_pkt(scsi_qla_host_t *ha)
 {
-	device_reg_t	*reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	request_t	*pkt = NULL;
 	uint16_t	cnt;
 	uint32_t	*dword_ptr;
@@ -619,7 +616,7 @@
 request_t *
 qla2x00_ms_req_pkt(scsi_qla_host_t *ha, srb_t  *sp)
 {
-	device_reg_t	*reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	request_t	*pkt = NULL;
 	uint16_t	cnt, i, index;
 	uint32_t	*dword_ptr;
@@ -709,7 +706,7 @@
 void
 qla2x00_isp_cmd(scsi_qla_host_t *ha)
 {
-	device_reg_t *reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	DEBUG5(printk("%s(): IOCB data:\n", __func__));
 	DEBUG5(qla2x00_dump_buffer(
diff -Nru a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
--- a/drivers/scsi/qla2xxx/qla_isr.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/qla2xxx/qla_isr.c	2004-12-24 13:37:43 -08:00
@@ -30,7 +30,7 @@
 static int qla2x00_check_sense(struct scsi_cmnd *cp, os_lun_t *);
 
 /**
- * qla2x00_intr_handler() - Process interrupts for the ISP.
+ * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
  * @irq:
  * @dev_id: SCSI driver HA context
  * @regs:
@@ -40,20 +40,14 @@
  * Returns handled flag.
  */
 irqreturn_t
-qla2x00_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
+qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	scsi_qla_host_t	*ha;
-	device_reg_t	*reg;
+	device_reg_t __iomem *reg;
+	int		status;
+	unsigned long	flags;
+	unsigned long	iter;
 	uint32_t	mbx;
-	int		status = 0;
-	unsigned long	flags = 0;
-	unsigned long	mbx_flags = 0;
-	unsigned long	intr_iter;
-	uint32_t	stat;
-	uint16_t	hccr;
-
-	/* Don't loop forever, interrupt are OFF */
-	intr_iter = 50; 
 
 	ha = (scsi_qla_host_t *) dev_id;
 	if (!ha) {
@@ -63,107 +57,40 @@
 	}
 
 	reg = ha->iobase;
+	status = 0;
 
 	spin_lock_irqsave(&ha->hardware_lock, flags);
-
-	for (;;) {
-		/* Relax CPU! */
-		if (!(intr_iter--))
+	for (iter = 50; iter--; ) {
+		if ((RD_REG_WORD(&reg->istatus) & ISR_RISC_INT) == 0)
 			break;
 
-		if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
-			if ((RD_REG_WORD(&reg->istatus) & ISR_RISC_INT) == 0)
-				break;
-
-			if (RD_REG_WORD(&reg->semaphore) & BIT_0) {
-				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
-				RD_REG_WORD(&reg->hccr);
-
-				/* Get mailbox data. */
-				mbx = RD_MAILBOX_REG(ha, reg, 0);
-				if (mbx > 0x3fff && mbx < 0x8000) {
-					qla2x00_mbx_completion(ha,
-					    (uint16_t)mbx);
-					status |= MBX_INTERRUPT;
-				} else if (mbx > 0x7fff && mbx < 0xc000) {
-					qla2x00_async_event(ha, mbx);
-				} else {
-					/*EMPTY*/
-					DEBUG2(printk("scsi(%ld): Unrecognized "
-					    "interrupt type (%d)\n",
-					    ha->host_no, mbx));
-				}
-				/* Release mailbox registers. */
-				WRT_REG_WORD(&reg->semaphore, 0);
-				/* Workaround for ISP2100 chip. */
-				if (IS_QLA2100(ha))
-					RD_REG_WORD(&reg->semaphore);
-			} else {
-				qla2x00_process_response_queue(ha);
-	
-				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
-				RD_REG_WORD(&reg->hccr);
-			}
-		} else /* IS_QLA23XX(ha) */ {
-			stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
-			if (stat & HSR_RISC_PAUSED) {
-				hccr = RD_REG_WORD(&reg->hccr);
-				if (hccr & (BIT_15 | BIT_13 | BIT_11 | BIT_8))
-					qla_printk(KERN_INFO, ha,
-					    "Parity error -- HCCR=%x.\n", hccr);
-				else
-					qla_printk(KERN_INFO, ha,
-					    "RISC paused -- HCCR=%x\n", hccr);
-
-				/*
-				 * Issue a "HARD" reset in order for the RISC
-				 * interrupt bit to be cleared.  Schedule a big
-				 * hammmer to get out of the RISC PAUSED state.
-				 */
-				WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
-				RD_REG_WORD(&reg->hccr);
-				set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
-				break;
-			} else if ((stat & HSR_RISC_INT) == 0)
-				break;
+		if (RD_REG_WORD(&reg->semaphore) & BIT_0) {
+			WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+			RD_REG_WORD(&reg->hccr);
 
-			mbx = MSW(stat);
-			switch (stat & 0xff) {
-			case 0x13:
-				qla2x00_process_response_queue(ha);
-				break;
-			case 0x1:
-			case 0x2:
-			case 0x10:
-			case 0x11:
+			/* Get mailbox data. */
+			mbx = RD_MAILBOX_REG(ha, reg, 0);
+			if (mbx > 0x3fff && mbx < 0x8000) {
 				qla2x00_mbx_completion(ha, (uint16_t)mbx);
 				status |= MBX_INTERRUPT;
-
-				/* Release mailbox registers. */
-				WRT_REG_WORD(&reg->semaphore, 0);
-				break;
-			case 0x12:
-				qla2x00_async_event(ha, mbx);
-				break;
-			case 0x15:
-				mbx = mbx << 16 | MBA_CMPLT_1_16BIT;
-				qla2x00_async_event(ha, mbx);
-				break;
-			case 0x16:
-				mbx = mbx << 16 | MBA_SCSI_COMPLETION;
+			} else if (mbx > 0x7fff && mbx < 0xc000) {
 				qla2x00_async_event(ha, mbx);
-				break;
-			default:
+			} else {
+				/*EMPTY*/
 				DEBUG2(printk("scsi(%ld): Unrecognized "
 				    "interrupt type (%d)\n",
-				    ha->host_no, stat & 0xff));
-				break;
+				    ha->host_no, mbx));
 			}
+			/* Release mailbox registers. */
+			WRT_REG_WORD(&reg->semaphore, 0);
+			RD_REG_WORD(&reg->semaphore);
+		} else {
+			qla2x00_process_response_queue(ha);
+
 			WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
-			RD_REG_WORD_RELAXED(&reg->hccr);
+			RD_REG_WORD(&reg->hccr);
 		}
 	}
-
 	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
 	qla2x00_next(ha);
@@ -172,48 +99,130 @@
 
 	if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
 	    (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
+		spin_lock_irqsave(&ha->mbx_reg_lock, flags);
 
-		/* There was a mailbox completion */
-		DEBUG3(printk("%s(%ld): Going to get mbx reg lock.\n",
-		    __func__, ha->host_no));
+		set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+		up(&ha->mbx_intr_sem);
 
-		spin_lock_irqsave(&ha->mbx_reg_lock, mbx_flags);
+		spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
+	}
 
-		if (ha->mcp == NULL) {
-			DEBUG3(printk("%s(%ld): Error mbx pointer.\n",
-			    __func__, ha->host_no));
-		} else {
-			DEBUG3(printk("%s(%ld): Going to set mbx intr flags. "
-			    "cmd=%x.\n",
-			    __func__, ha->host_no, ha->mcp->mb[0]));
-		}
-		set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+	if (!list_empty(&ha->done_queue))
+		qla2x00_done(ha);
 
-		DEBUG3(printk("%s(%ld): Going to wake up mbx function for "
-		    "completion.\n",
-		    __func__, ha->host_no));
+	return (IRQ_HANDLED);
+}
 
-		up(&ha->mbx_intr_sem);
+/**
+ * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
+ * @irq:
+ * @dev_id: SCSI driver HA context
+ * @regs:
+ *
+ * Called by system whenever the host adapter generates an interrupt.
+ *
+ * Returns handled flag.
+ */
+irqreturn_t
+qla2300_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+	scsi_qla_host_t	*ha;
+	device_reg_t __iomem *reg;
+	int		status;
+	unsigned long	flags;
+	unsigned long	iter;
+	uint32_t	stat;
+	uint32_t	mbx;
+	uint16_t	hccr;
 
-		DEBUG3(printk("%s(%ld): Going to release mbx reg lock.\n",
-		    __func__, ha->host_no));
+	ha = (scsi_qla_host_t *) dev_id;
+	if (!ha) {
+		printk(KERN_INFO
+		    "%s(): NULL host pointer\n", __func__);
+		return (IRQ_NONE);
+	}
+
+	reg = ha->iobase;
+	status = 0;
 
-		spin_unlock_irqrestore(&ha->mbx_reg_lock, mbx_flags);
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	for (iter = 50; iter--; ) {
+		stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
+		if (stat & HSR_RISC_PAUSED) {
+			hccr = RD_REG_WORD(&reg->hccr);
+			if (hccr & (BIT_15 | BIT_13 | BIT_11 | BIT_8))
+				qla_printk(KERN_INFO, ha,
+				    "Parity error -- HCCR=%x.\n", hccr);
+			else
+				qla_printk(KERN_INFO, ha,
+				    "RISC paused -- HCCR=%x\n", hccr);
+
+			/*
+			 * Issue a "HARD" reset in order for the RISC
+			 * interrupt bit to be cleared.  Schedule a big
+			 * hammmer to get out of the RISC PAUSED state.
+			 */
+			WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
+			RD_REG_WORD(&reg->hccr);
+			set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+			break;
+		} else if ((stat & HSR_RISC_INT) == 0)
+			break;
+
+		mbx = MSW(stat);
+		switch (stat & 0xff) {
+		case 0x13:
+			qla2x00_process_response_queue(ha);
+			break;
+		case 0x1:
+		case 0x2:
+		case 0x10:
+		case 0x11:
+			qla2x00_mbx_completion(ha, (uint16_t)mbx);
+			status |= MBX_INTERRUPT;
+
+			/* Release mailbox registers. */
+			WRT_REG_WORD(&reg->semaphore, 0);
+			break;
+		case 0x12:
+			qla2x00_async_event(ha, mbx);
+			break;
+		case 0x15:
+			mbx = mbx << 16 | MBA_CMPLT_1_16BIT;
+			qla2x00_async_event(ha, mbx);
+			break;
+		case 0x16:
+			mbx = mbx << 16 | MBA_SCSI_COMPLETION;
+			qla2x00_async_event(ha, mbx);
+			break;
+		default:
+			DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
+			    "(%d)\n",
+			    ha->host_no, stat & 0xff));
+			break;
+		}
+		WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+		RD_REG_WORD_RELAXED(&reg->hccr);
 	}
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
-	if (!list_empty(&ha->done_queue))
-		qla2x00_done(ha);
+	qla2x00_next(ha);
+	ha->last_irq_cpu = smp_processor_id();
+	ha->total_isr_cnt++;
+
+	if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
+	    (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
+		spin_lock_irqsave(&ha->mbx_reg_lock, flags);
 
-	/* Wakeup the DPC routine */
-	if ((!ha->flags.mbox_busy &&
-	    (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) ||
-		test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) ||
-		test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))) &&
-		    ha->dpc_wait && !ha->dpc_active) {
+		set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+		up(&ha->mbx_intr_sem);
 
-		up(ha->dpc_wait);
+		spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
 	}
 
+	if (!list_empty(&ha->done_queue))
+		qla2x00_done(ha);
+
 	return (IRQ_HANDLED);
 }
 
@@ -226,17 +235,17 @@
 qla2x00_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0)
 {
 	uint16_t	cnt;
-	uint16_t	*wptr;
-	device_reg_t	*reg = ha->iobase;
+	uint16_t __iomem *wptr;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	/* Load return mailbox registers. */
 	ha->flags.mbox_int = 1;
 	ha->mailbox_out[0] = mb0;
-	wptr = (uint16_t *)MAILBOX_REG(ha, reg, 1);
+	wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 1);
 
 	for (cnt = 1; cnt < ha->mbx_count; cnt++) {
 		if (IS_QLA2200(ha) && cnt == 8) 
-			wptr = (uint16_t *)MAILBOX_REG(ha, reg, 8);
+			wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8);
 		if (cnt == 4 || cnt == 5)
 			ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr);
 		else
@@ -268,7 +277,7 @@
 	uint16_t	handle_cnt;
 	uint16_t	cnt;
 	uint32_t	handles[5];
-	device_reg_t	*reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	uint32_t	rscn_entry, host_pid;
 	uint8_t		rscn_queue_index;
 
@@ -574,7 +583,7 @@
 		}
 
 		/*
-		 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET
+		 * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET
 		 * event etc. earlier indicating loop is down) then process
 		 * it.  Otherwise ignore it and Wait for RSCN to come in.
 		 */
@@ -715,7 +724,7 @@
 void
 qla2x00_process_response_queue(struct scsi_qla_host *ha)
 {
-	device_reg_t	*reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	sts_entry_t	*pkt;
 	uint16_t        handle_cnt;
 	uint16_t        cnt;
@@ -969,7 +978,7 @@
 		    sizeof(cp->sense_buffer))
 			sense_sz = le16_to_cpu(pkt->req_sense_length);
 		else
-			sense_sz = sizeof(cp->sense_buffer) - 1;
+			sense_sz = sizeof(cp->sense_buffer);
 
 		CMD_ACTUAL_SNSLEN(cp) = sense_sz;
 		sp->request_sense_length = sense_sz;
@@ -1039,7 +1048,7 @@
 			    sizeof(cp->sense_buffer))
 				sense_sz = le16_to_cpu(pkt->req_sense_length);
 			else
-				sense_sz = sizeof(cp->sense_buffer) - 1;
+				sense_sz = sizeof(cp->sense_buffer);
 
 			CMD_ACTUAL_SNSLEN(cp) = sense_sz;
 			sp->request_sense_length = sense_sz;
diff -Nru a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
--- a/drivers/scsi/qla2xxx/qla_mbx.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/scsi/qla2xxx/qla_mbx.c	2004-12-24 13:36:49 -08:00
@@ -58,12 +58,13 @@
 {
 	int		rval;
 	unsigned long    flags = 0;
-	device_reg_t     *reg       = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	struct timer_list	tmp_intr_timer;
 	uint8_t		abort_active = test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
 	uint8_t		io_lock_on = ha->flags.init_done;
 	uint16_t	command;
-	uint16_t	*iptr, *optr;
+	uint16_t	*iptr;
+	uint16_t __iomem *optr;
 	uint32_t	cnt;
 	uint32_t	mboxes;
 	unsigned long	mbx_flags = 0;
@@ -101,7 +102,7 @@
 	spin_lock_irqsave(&ha->hardware_lock, flags);
 
 	/* Load mailbox registers. */
-	optr = (uint16_t *)MAILBOX_REG(ha, reg, 0);
+	optr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 0);
 
 	iptr = mcp->mb;
 	command = mcp->mb[0];
@@ -109,7 +110,7 @@
 
 	for (cnt = 0; cnt < ha->mbx_count; cnt++) {
 		if (IS_QLA2200(ha) && cnt == 8)
-			optr = (uint16_t *)MAILBOX_REG(ha, reg, 8);
+			optr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8);
 		if (mboxes & BIT_0)
 			WRT_REG_WORD(optr, *iptr);
 
@@ -209,6 +210,7 @@
 
 	/* Check whether we timed out */
 	if (ha->flags.mbox_int) {
+		uint16_t *iptr2;
 
 		DEBUG3_11(printk("qla2x00_mailbox_cmd: cmd %x completed.\n",
 		    command);)
@@ -223,15 +225,15 @@
 		}
 
 		/* Load return mailbox registers. */
-		optr = mcp->mb;
+		iptr2 = mcp->mb;
 		iptr = (uint16_t *)&ha->mailbox_out[0];
 		mboxes = mcp->in_mb;
 		for (cnt = 0; cnt < ha->mbx_count; cnt++) {
 			if (mboxes & BIT_0)
-				*optr = *iptr;
+				*iptr2 = *iptr;
 
 			mboxes >>= 1;
-			optr++;
+			iptr2++;
 			iptr++;
 		}
 	} else {
@@ -1403,7 +1405,7 @@
 	DEBUG11(printk("qla2x00_get_port_database(%ld): entered.\n",
 	    ha->host_no);)
 
-	pd = pci_alloc_consistent(ha->pdev, PORT_DATABASE_SIZE, &pd_dma);
+	pd = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &pd_dma);
 	if (pd  == NULL) {
 		DEBUG2_3_11(printk("qla2x00_get_port_database(%ld): **** "
 		    "Mem Alloc Failed ****", ha->host_no);)
@@ -1464,7 +1466,7 @@
 		fcport->port_type = FCT_TARGET;
 
 gpd_error_out:
-	pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE, pd, pd_dma);
+	dma_pool_free(ha->s_dma_pool, pd, pd_dma);
 
 	if (rval != QLA_SUCCESS) {
 		/*EMPTY*/
@@ -1617,14 +1619,12 @@
 	mbx_cmd_t mc;
 	mbx_cmd_t *mcp = &mc;
 	link_stat_t *stat_buf;
-	dma_addr_t phys_address = 0;
-
+	dma_addr_t stat_buf_dma;
 
 	DEBUG11(printk("qla2x00_get_link_status(%ld): entered.\n",
 	    ha->host_no);)
 
-	stat_buf = pci_alloc_consistent(ha->pdev, sizeof(link_stat_t),
-	    &phys_address);
+	stat_buf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &stat_buf_dma);
 	if (stat_buf == NULL) {
 		DEBUG2_3_11(printk("qla2x00_get_link_status(%ld): Failed to "
 		    "allocate memory.\n", ha->host_no));
@@ -1641,10 +1641,10 @@
 	} else {
 		mcp->mb[1] = loop_id << 8;
 	}
-	mcp->mb[2] = MSW(phys_address);
-	mcp->mb[3] = LSW(phys_address);
-	mcp->mb[6] = MSW(MSD(phys_address));
-	mcp->mb[7] = LSW(MSD(phys_address));
+	mcp->mb[2] = MSW(stat_buf_dma);
+	mcp->mb[3] = LSW(stat_buf_dma);
+	mcp->mb[6] = MSW(MSD(stat_buf_dma));
+	mcp->mb[7] = LSW(MSD(stat_buf_dma));
 
 	mcp->in_mb = MBX_0;
 	mcp->tov = 30;
@@ -1688,8 +1688,7 @@
 		rval = BIT_1;
 	}
 
-	pci_free_consistent(ha->pdev, sizeof(link_stat_t), stat_buf,
-	    phys_address);
+	dma_pool_free(ha->s_dma_pool, stat_buf, stat_buf_dma);
 
 	return rval;
 }
@@ -2409,7 +2408,7 @@
 	char *pmap;
 	dma_addr_t pmap_dma;
 
-	pmap = pci_alloc_consistent(ha->pdev, FCAL_MAP_SIZE, &pmap_dma);
+	pmap = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &pmap_dma);
 	if (pmap  == NULL) {
 		DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",
 		    __func__, ha->host_no));
@@ -2438,7 +2437,7 @@
 		if (pos_map)
 			memcpy(pos_map, pmap, FCAL_MAP_SIZE);
 	}
-	pci_free_consistent(ha->pdev, FCAL_MAP_SIZE, pmap, pmap_dma);
+	dma_pool_free(ha->s_dma_pool, pmap, pmap_dma);
 
 	if (rval != QLA_SUCCESS) {
 		DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
diff -Nru a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
--- a/drivers/scsi/qla2xxx/qla_os.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/scsi/qla2xxx/qla_os.c	2004-12-24 13:37:30 -08:00
@@ -21,6 +21,7 @@
 #include <linux/moduleparam.h>
 #include <linux/vmalloc.h>
 #include <linux/smp_lock.h>
+#include <linux/delay.h>
 
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsicam.h>
@@ -235,67 +236,6 @@
 static __inline__ void
 qla2x00_delete_from_done_queue(scsi_qla_host_t *, srb_t *); 
 
-/**************************************************************************
-* sp_put
-*
-* Description:
-*   Decrement reference count and call the callback if we're the last
-*   owner of the specified sp. Will get the host_lock before calling
-*   the callback.
-*
-* Input:
-*   ha - pointer to the scsi_qla_host_t where the callback is to occur.
-*   sp - pointer to srb_t structure to use.
-*
-* Returns:
-*
-**************************************************************************/
-static inline void
-sp_put(struct scsi_qla_host * ha, srb_t *sp)
-{
-        if (atomic_read(&sp->ref_count) == 0) {
-		qla_printk(KERN_INFO, ha,
-			"%s(): **** SP->ref_count not zero\n",
-			__func__);
-                DEBUG2(BUG();)
-
-                return;
-	}
-
-        if (!atomic_dec_and_test(&sp->ref_count)) {
-                return;
-        }
-
-        qla2x00_callback(ha, sp->cmd);
-}
-
-/**************************************************************************
-* sp_get
-*
-* Description:
-*   Increment reference count of the specified sp.
-*
-* Input:
-*   sp - pointer to srb_t structure to use.
-*
-* Returns:
-*
-**************************************************************************/
-static inline void
-sp_get(struct scsi_qla_host * ha, srb_t *sp)
-{
-        atomic_inc(&sp->ref_count);
-
-        if (atomic_read(&sp->ref_count) > 2) {
-		qla_printk(KERN_INFO, ha,
-			"%s(): **** SP->ref_count greater than two\n",
-			__func__);
-                DEBUG2(BUG();)
-
-		return;
-	}
-}
-
 /*
 * qla2x00_callback
 *      Returns the completed SCSI command to LINUX.
@@ -366,6 +306,67 @@
 	(*(cmd)->scsi_done)(cmd);
 }
 
+/**************************************************************************
+* sp_put
+*
+* Description:
+*   Decrement reference count and call the callback if we're the last
+*   owner of the specified sp. Will get the host_lock before calling
+*   the callback.
+*
+* Input:
+*   ha - pointer to the scsi_qla_host_t where the callback is to occur.
+*   sp - pointer to srb_t structure to use.
+*
+* Returns:
+*
+**************************************************************************/
+static inline void
+sp_put(struct scsi_qla_host * ha, srb_t *sp)
+{
+        if (atomic_read(&sp->ref_count) == 0) {
+		qla_printk(KERN_INFO, ha,
+			"%s(): **** SP->ref_count not zero\n",
+			__func__);
+                DEBUG2(BUG();)
+
+                return;
+	}
+
+        if (!atomic_dec_and_test(&sp->ref_count)) {
+                return;
+        }
+
+        qla2x00_callback(ha, sp->cmd);
+}
+
+/**************************************************************************
+* sp_get
+*
+* Description:
+*   Increment reference count of the specified sp.
+*
+* Input:
+*   sp - pointer to srb_t structure to use.
+*
+* Returns:
+*
+**************************************************************************/
+static inline void
+sp_get(struct scsi_qla_host * ha, srb_t *sp)
+{
+        atomic_inc(&sp->ref_count);
+
+        if (atomic_read(&sp->ref_count) > 2) {
+		qla_printk(KERN_INFO, ha,
+			"%s(): **** SP->ref_count greater than two\n",
+			__func__);
+                DEBUG2(BUG();)
+
+		return;
+	}
+}
+
 static inline void 
 qla2x00_delete_from_done_queue(scsi_qla_host_t *dest_ha, srb_t *sp) 
 {
@@ -753,7 +754,7 @@
 	cmd->host_scribble = (unsigned char *)handle;
 
 	/* Bookkeeping information */
-	sp->r_start = jiffies;       /* time the request was recieved */
+	sp->r_start = jiffies;       /* time the request was received */
 	sp->u_start = 0;
 
 	/* Setup device queue pointers. */
@@ -844,11 +845,9 @@
 		was_empty = add_to_pending_queue(ha, sp);
 
 	if ((IS_QLA2100(ha) || IS_QLA2200(ha)) && ha->flags.online) {
-		unsigned long flags;
-		device_reg_t *reg;
-		reg = ha->iobase;
-		
 		if (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) {
+			unsigned long flags;
+
 			spin_lock_irqsave(&ha->hardware_lock, flags);	
 			qla2x00_process_response_queue(ha);
 			spin_unlock_irqrestore(&ha->hardware_lock, flags);
@@ -969,8 +968,7 @@
 	    test_bit(ISP_ABORT_RETRY, &ha->dpc_flags) ||
 	    ha->dpc_active) && time_before(jiffies, wait_online)) {
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ);
+		msleep(1000);
 	}
 	if (ha->flags.online) 
 		return_status = QLA_SUCCESS; 
@@ -1011,8 +1009,7 @@
 	    atomic_read(&ha->loop_state) == LOOP_DOWN) ||
 	    test_bit(CFG_ACTIVE, &ha->cfg_flags) ||
 	    atomic_read(&ha->loop_state) != LOOP_READY) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ);
+		msleep(1000);
 		if (time_after_eq(jiffies, loop_timeout)) {
 			return_status = QLA_FUNCTION_FAILED;
 			break;
@@ -1583,14 +1580,10 @@
 	if (rval == FAILED)
 		goto out;
 
-	/*
-	 * Blocking Call. It goes to sleep waiting for cmd to get to done q
-	 *
-	 * XXX(hch): really?  We're under host_lock here..
-	 */
 	/* Waiting for our command in done_queue to be returned to OS.*/
-	if (!qla2x00_eh_wait_for_pending_commands(ha))
-		rval = FAILED;
+	if (cmd->device->host->eh_active)
+		if (!qla2x00_eh_wait_for_pending_commands(ha))
+			rval = FAILED;
 
  out:
 	qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
@@ -1819,28 +1812,27 @@
 	 * assist in setting the proper dma mask.
 	 */
 	if (sizeof(dma_addr_t) > 4) {
-		/* Update our PCI device dma_mask for full 64 bits */
-		if (pci_set_dma_mask(ha->pdev, 0xffffffffffffffffULL) == 0) {
+		if (pci_set_dma_mask(ha->pdev, DMA_64BIT_MASK) == 0) {
 			ha->flags.enable_64bit_addressing = 1;
 			ha->calc_request_entries = qla2x00_calc_iocbs_64;
 			ha->build_scsi_iocbs = qla2x00_build_scsi_iocbs_64;
 
 			if (pci_set_consistent_dma_mask(ha->pdev,
-			    0xffffffffffffffffULL)) {
+			    DMA_64BIT_MASK)) {
 				qla_printk(KERN_DEBUG, ha, 
 				    "Failed to set 64 bit PCI consistent mask; "
 				    "using 32 bit.\n");
 				pci_set_consistent_dma_mask(ha->pdev,
-				    0xffffffffULL);
+				    DMA_32BIT_MASK);
 			}
 		} else {
 			qla_printk(KERN_DEBUG, ha,
 			    "Failed to set 64 bit PCI DMA mask, falling back "
 			    "to 32 bit MASK.\n");
-			pci_set_dma_mask(ha->pdev, 0xffffffff);
+			pci_set_dma_mask(ha->pdev, DMA_32BIT_MASK);
 		}
 	} else {
-		pci_set_dma_mask(ha->pdev, 0xffffffff);
+		pci_set_dma_mask(ha->pdev, DMA_32BIT_MASK);
 	}
 }
 
@@ -1896,15 +1888,13 @@
 
 	ha->pio_address = pio;
 	ha->pio_length = pio_len;
-	ha->mmio_address = ioremap(mmio, MIN_IOBASE_LEN);
-	if (!ha->mmio_address) {
+	ha->iobase = ioremap(mmio, MIN_IOBASE_LEN);
+	if (!ha->iobase) {
 		qla_printk(KERN_ERR, ha,
 		    "cannot remap MMIO (%s), aborting\n", ha->pdev->slot_name);
 
 		goto iospace_error_exit;
 	}
-	ha->mmio_length = mmio_len;
-	ha->iobase = (device_reg_t *) ha->mmio_address;
 
 	return (0);
 
@@ -1918,7 +1908,7 @@
 int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
 {
 	int	ret;
-	device_reg_t *reg;
+	device_reg_t __iomem *reg;
 	struct Scsi_Host *host;
 	scsi_qla_host_t *ha;
 	unsigned long	flags = 0;
@@ -1934,7 +1924,7 @@
 	if (host == NULL) {
 		printk(KERN_WARNING
 		    "qla2xxx: Couldn't allocate host from scsi layer!\n");
-		return -1;
+		goto probe_disable_device;
 	}
 
 	/* Clear our data area */
@@ -2068,8 +2058,13 @@
 	host->unique_id = ha->instance;
 	host->max_id = ha->max_targets;
 
-	if (request_irq(host->irq, qla2x00_intr_handler, SA_INTERRUPT|SA_SHIRQ,
-	    ha->brd_info->drv_name, ha)) {
+	if (IS_QLA2100(ha) || IS_QLA2200(ha))
+		ret = request_irq(host->irq, qla2100_intr_handler,
+		    SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
+	else
+		ret = request_irq(host->irq, qla2300_intr_handler,
+		    SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
+	if (ret != 0) {
 		qla_printk(KERN_WARNING, ha,
 		    "Failed to reserve interrupt %d already in use.\n",
 		    host->irq);
@@ -2120,8 +2115,7 @@
 
 		qla2x00_check_fabric_devices(ha);
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	}
 
 	pci_set_drvdata(pdev, ha);
@@ -2158,6 +2152,9 @@
 
 	scsi_host_put(host);
 
+probe_disable_device:
+	pci_disable_device(pdev);
+
 	return -1;
 }
 EXPORT_SYMBOL_GPL(qla2x00_probe_one);
@@ -2224,12 +2221,11 @@
 		free_irq(ha->pdev->irq, ha);
 
 	/* release io space registers  */
+	if (ha->iobase)
+		iounmap(ha->iobase);
 	pci_release_regions(ha->pdev);
 
-#if MEMORY_MAPPED_IO
-	if (ha->mmio_address)
-		iounmap(ha->mmio_address);
-#endif
+	pci_disable_device(ha->pdev);
 }
 
 
@@ -2815,6 +2811,7 @@
 static uint8_t
 qla2x00_mem_alloc(scsi_qla_host_t *ha)
 {
+	char	name[16];
 	uint8_t   status = 1;
 	int	retry= 10;
 
@@ -2825,57 +2822,105 @@
 		 * bug where available mem is not allocated until after a
 		 * little delay and a retry.
 		 */
-		ha->request_ring = pci_alloc_consistent(ha->pdev,
-		    ((ha->request_q_length + 1) * (sizeof(request_t))),
-		    &ha->request_dma);
+		ha->request_ring = dma_alloc_coherent(&ha->pdev->dev,
+		    (ha->request_q_length + 1) * sizeof(request_t),
+		    &ha->request_dma, GFP_KERNEL);
 		if (ha->request_ring == NULL) {
 			qla_printk(KERN_WARNING, ha,
 			    "Memory Allocation failed - request_ring\n");
 
 			qla2x00_mem_free(ha);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/10);
+			msleep(100);
 
 			continue;
 		}
 
-		ha->response_ring = pci_alloc_consistent(ha->pdev,
-		    ((ha->response_q_length + 1) * (sizeof(response_t))),
-		    &ha->response_dma);
+		ha->response_ring = dma_alloc_coherent(&ha->pdev->dev,
+		    (ha->response_q_length + 1) * sizeof(response_t),
+		    &ha->response_dma, GFP_KERNEL);
 		if (ha->response_ring == NULL) {
 			qla_printk(KERN_WARNING, ha,
 			    "Memory Allocation failed - response_ring\n");
 
 			qla2x00_mem_free(ha);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/10);
+			msleep(100);
+
+			continue;
+		}
+
+		ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, GID_LIST_SIZE,
+		    &ha->gid_list_dma, GFP_KERNEL);
+		if (ha->gid_list == NULL) {
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - gid_list\n");
+
+			qla2x00_mem_free(ha);
+			msleep(100);
+
+			continue;
+		}
+
+		ha->rlc_rsp = dma_alloc_coherent(&ha->pdev->dev,
+		    sizeof(rpt_lun_cmd_rsp_t), &ha->rlc_rsp_dma, GFP_KERNEL);
+		if (ha->rlc_rsp == NULL) {
+			qla_printk(KERN_WARNING, ha,
+				"Memory Allocation failed - rlc");
+
+			qla2x00_mem_free(ha);
+			msleep(100);
+
+			continue;
+		}
+
+		snprintf(name, sizeof(name), "qla2xxx_%ld", ha->host_no);
+		ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev,
+		    DMA_POOL_SIZE, 8, 0);
+		if (ha->s_dma_pool == NULL) {
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - s_dma_pool\n");
+
+			qla2x00_mem_free(ha);
+			msleep(100);
 
 			continue;
 		}
 
 		/* get consistent memory allocated for init control block */
-		ha->init_cb = pci_alloc_consistent(ha->pdev,
-		    sizeof(init_cb_t), &ha->init_cb_dma);
+		ha->init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
+		    &ha->init_cb_dma);
 		if (ha->init_cb == NULL) {
 			qla_printk(KERN_WARNING, ha,
 			    "Memory Allocation failed - init_cb\n");
 
 			qla2x00_mem_free(ha);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/10);
+			msleep(100);
 
 			continue;
 		}
 		memset(ha->init_cb, 0, sizeof(init_cb_t));
 
+		/* Get consistent memory allocated for Get Port Database cmd */
+		ha->iodesc_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
+		    &ha->iodesc_pd_dma);
+		if (ha->iodesc_pd == NULL) {
+			/* error */
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - iodesc_pd\n");
+
+			qla2x00_mem_free(ha);
+			msleep(100);
+
+			continue;
+		}
+		memset(ha->iodesc_pd, 0, PORT_DATABASE_SIZE);
+
 		/* Allocate ioctl related memory. */
 		if (qla2x00_alloc_ioctl_mem(ha)) {
 			qla_printk(KERN_WARNING, ha,
 			    "Memory Allocation failed - ioctl_mem\n");
 
 			qla2x00_mem_free(ha);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/10);
+			msleep(100);
 
 			continue;
 		}
@@ -2886,8 +2931,7 @@
 			    "qla2x00_allocate_sp_pool()\n");
 
 			qla2x00_mem_free(ha);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/10);
+			msleep(100);
 
 			continue;
 		}
@@ -2895,32 +2939,31 @@
 		/* Allocate memory for SNS commands */
 		if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
 			/* Get consistent memory allocated for SNS commands */
-			ha->sns_cmd = pci_alloc_consistent(ha->pdev,
-			    sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma);
+			ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev,
+			    sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma,
+			    GFP_KERNEL);
 			if (ha->sns_cmd == NULL) {
 				/* error */
 				qla_printk(KERN_WARNING, ha,
 				    "Memory Allocation failed - sns_cmd\n");
 
 				qla2x00_mem_free(ha);
-				set_current_state(TASK_UNINTERRUPTIBLE);
-				schedule_timeout(HZ/10);
+				msleep(100);
 
 				continue;
 			}
 			memset(ha->sns_cmd, 0, sizeof(struct sns_cmd_pkt));
 		} else {
 			/* Get consistent memory allocated for MS IOCB */
-			ha->ms_iocb = pci_alloc_consistent(ha->pdev,
-			    sizeof(ms_iocb_entry_t), &ha->ms_iocb_dma);
+			ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
+			    &ha->ms_iocb_dma);
 			if (ha->ms_iocb == NULL) {
 				/* error */
 				qla_printk(KERN_WARNING, ha,
 				    "Memory Allocation failed - ms_iocb\n");
 
 				qla2x00_mem_free(ha);
-				set_current_state(TASK_UNINTERRUPTIBLE);
-				schedule_timeout(HZ/10);
+				msleep(100);
 
 				continue;
 			}
@@ -2930,38 +2973,22 @@
 			 * Get consistent memory allocated for CT SNS
 			 * commands
 			 */
-			ha->ct_sns = pci_alloc_consistent(ha->pdev,
-			    sizeof(struct ct_sns_pkt), &ha->ct_sns_dma);
+			ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev,
+			    sizeof(struct ct_sns_pkt), &ha->ct_sns_dma,
+			    GFP_KERNEL);
 			if (ha->ct_sns == NULL) {
 				/* error */
 				qla_printk(KERN_WARNING, ha,
 				    "Memory Allocation failed - ct_sns\n");
 
 				qla2x00_mem_free(ha);
-				set_current_state(TASK_UNINTERRUPTIBLE);
-				schedule_timeout(HZ/10);
+				msleep(100);
 
 				continue;
 			}
 			memset(ha->ct_sns, 0, sizeof(struct ct_sns_pkt));
 		}
 
-		/* Get consistent memory allocated for Get Port Database cmd */
-		ha->iodesc_pd = pci_alloc_consistent(ha->pdev,
-		    PORT_DATABASE_SIZE, &ha->iodesc_pd_dma);
-		if (ha->iodesc_pd == NULL) {
-			/* error */
-			qla_printk(KERN_WARNING, ha,
-			    "Memory Allocation failed - iodesc_pd\n");
-
-			qla2x00_mem_free(ha);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/10);
-
-			continue;
-		}
-		memset(ha->iodesc_pd, 0, PORT_DATABASE_SIZE);
-
 		/* Done all allocations without any error. */
 		status = 0;
 
@@ -3016,52 +3043,67 @@
 	/* free sp pool */
 	qla2x00_free_sp_pool(ha);
 
-	if (ha->iodesc_pd) {
-		pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE,
-		    ha->iodesc_pd, ha->iodesc_pd_dma);
-	}
-
-	if (ha->sns_cmd) {
-		pci_free_consistent(ha->pdev,
-		    sizeof(struct sns_cmd_pkt), ha->sns_cmd, ha->sns_cmd_dma);
-	}
-
-	if (ha->ct_sns) {
-		pci_free_consistent(ha->pdev,
-		    sizeof(struct ct_sns_pkt), ha->ct_sns, ha->ct_sns_dma);
-	}
-	if (ha->ms_iocb) {
-		pci_free_consistent(ha->pdev,
-		    sizeof(ms_iocb_entry_t), ha->ms_iocb, ha->ms_iocb_dma);
-	}
-
-	if (ha->init_cb) {
-		pci_free_consistent(ha->pdev,
-		    sizeof(init_cb_t), ha->init_cb, ha->init_cb_dma);
-	}
+	if (ha->sns_cmd)
+		dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
+		    ha->sns_cmd, ha->sns_cmd_dma);
+
+	if (ha->ct_sns)
+		dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
+		    ha->ct_sns, ha->ct_sns_dma);
+
+	if (ha->ms_iocb)
+		dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
+
+	if (ha->iodesc_pd)
+		dma_pool_free(ha->s_dma_pool, ha->iodesc_pd, ha->iodesc_pd_dma);
+
+	if (ha->init_cb)
+		dma_pool_free(ha->s_dma_pool, ha->init_cb, ha->init_cb_dma);
+
+	if (ha->s_dma_pool)
+		dma_pool_destroy(ha->s_dma_pool);
+
+	if (ha->rlc_rsp)
+		dma_free_coherent(&ha->pdev->dev,
+		    sizeof(rpt_lun_cmd_rsp_t), ha->rlc_rsp,
+		    ha->rlc_rsp_dma);
+
+	if (ha->gid_list)
+		dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
+		    ha->gid_list_dma);
+
+	if (ha->response_ring)
+		dma_free_coherent(&ha->pdev->dev,
+		    (ha->response_q_length + 1) * sizeof(response_t),
+		    ha->response_ring, ha->response_dma);
 
-	if (ha->request_ring) {
-		pci_free_consistent(ha->pdev,
-		    ((ha->request_q_length + 1) * (sizeof(request_t))),
+	if (ha->request_ring)
+		dma_free_coherent(&ha->pdev->dev,
+		    (ha->request_q_length + 1) * sizeof(request_t),
 		    ha->request_ring, ha->request_dma);
-	}
 
-	if (ha->response_ring) {
-		pci_free_consistent(ha->pdev,
-		    ((ha->response_q_length + 1) * (sizeof(response_t))),
-		    ha->response_ring, ha->response_dma);
-	}
-
-	ha->iodesc_pd = NULL;
-	ha->iodesc_pd_dma = 0;
+	ha->sns_cmd = NULL;
+	ha->sns_cmd_dma = 0;
 	ha->ct_sns = NULL;
+	ha->ct_sns_dma = 0;
 	ha->ms_iocb = NULL;
-
+	ha->ms_iocb_dma = 0;
+	ha->iodesc_pd = NULL;
+	ha->iodesc_pd_dma = 0;
 	ha->init_cb = NULL;
-	ha->request_ring = NULL;
-	ha->request_dma = 0;
+	ha->init_cb_dma = 0;
+
+	ha->s_dma_pool = NULL;
+
+	ha->rlc_rsp = NULL;
+	ha->rlc_rsp_dma = 0;
+	ha->gid_list = NULL;
+	ha->gid_list_dma = 0;
+
 	ha->response_ring = NULL;
 	ha->response_dma = 0;
+	ha->request_ring = NULL;
+	ha->request_dma = 0;
 
 	list_for_each_safe(fcpl, fcptemp, &ha->fcports) {
 		fcport = list_entry(fcpl, fc_port_t, list);
@@ -3080,16 +3122,15 @@
 	}
 	INIT_LIST_HEAD(&ha->fcports);
 
-	if (ha->fw_dump) {
+	if (ha->fw_dump)
 		free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
-		ha->fw_dump = NULL;
-	}
 
-	if (ha->fw_dump_buffer) {
+	if (ha->fw_dump_buffer)
 		vfree(ha->fw_dump_buffer);
-		ha->fw_dump_reading = 0;
-		ha->fw_dump_buffer = NULL;
-	}
+
+	ha->fw_dump = NULL;
+	ha->fw_dump_reading = 0;
+	ha->fw_dump_buffer = NULL;
 }
 
 /*
@@ -3187,9 +3228,6 @@
 		if (ha->dpc_should_die)
 			break;
 
-		if (!list_empty(&ha->done_queue))
-			qla2x00_done(ha);
-
 		DEBUG3(printk("qla2x00: DPC handler waking up\n"));
 
 		/* Initialization not yet finished. Don't do anything yet. */
@@ -3200,6 +3238,9 @@
 
 		ha->dpc_active = 1;
 
+		if (!list_empty(&ha->done_queue))
+			qla2x00_done(ha);
+
 		/* Process commands in retry queue */
 		if (test_and_clear_bit(PORT_RESTART_NEEDED, &ha->dpc_flags)) {
 			DEBUG(printk("scsi(%ld): DPC checking retry_q. "
@@ -4403,61 +4444,64 @@
 }
 
 static void
-qla2xxx_get_port_id(struct scsi_device *sdev)
+qla2xxx_get_port_id(struct scsi_target *starget)
 {
-	scsi_qla_host_t *ha = to_qla_host(sdev->host);
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	scsi_qla_host_t *ha = to_qla_host(shost);
 	struct fc_port *fc;
 
 	list_for_each_entry(fc, &ha->fcports, list) {
-		if (fc->os_target_id == sdev->id) {
-			fc_port_id(sdev) = fc->d_id.b.domain << 16 |
+		if (fc->os_target_id == starget->id) {
+			fc_starget_port_id(starget) = fc->d_id.b.domain << 16 |
 				fc->d_id.b.area << 8 | 
 				fc->d_id.b.al_pa;
 			return;
 		}
 	}
-	fc_port_id(sdev) = -1;
+	fc_starget_port_id(starget) = -1;
 }
 
 static void
-qla2xxx_get_port_name(struct scsi_device *sdev)
+qla2xxx_get_port_name(struct scsi_target *starget)
 {
-	scsi_qla_host_t *ha = to_qla_host(sdev->host);
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	scsi_qla_host_t *ha = to_qla_host(shost);
 	struct fc_port *fc;
 
 	list_for_each_entry(fc, &ha->fcports, list) {
-		if (fc->os_target_id == sdev->id) {
-			fc_port_name(sdev) =
+		if (fc->os_target_id == starget->id) {
+			fc_starget_port_name(starget) =
 				__be64_to_cpu(*(uint64_t *)fc->port_name);
 			return;
 		}
 	}
-	fc_port_name(sdev) = -1;
+	fc_starget_port_name(starget) = -1;
 }
 
 static void
-qla2xxx_get_node_name(struct scsi_device *sdev)
+qla2xxx_get_node_name(struct scsi_target *starget)
 {
-	scsi_qla_host_t *ha = to_qla_host(sdev->host);
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	scsi_qla_host_t *ha = to_qla_host(shost);
 	struct fc_port *fc;
 
 	list_for_each_entry(fc, &ha->fcports, list) {
-		if (fc->os_target_id == sdev->id) {
-			fc_node_name(sdev) =
+		if (fc->os_target_id == starget->id) {
+			fc_starget_node_name(starget) =
 				__be64_to_cpu(*(uint64_t *)fc->node_name);
 			return;
 		}
 	}
-	fc_node_name(sdev) = -1;
+	fc_starget_node_name(starget) = -1;
 }
 
 static struct fc_function_template qla2xxx_transport_functions = {
-	.get_port_id = qla2xxx_get_port_id,
-	.show_port_id = 1,
-	.get_port_name = qla2xxx_get_port_name,
-	.show_port_name = 1,
-	.get_node_name = qla2xxx_get_node_name,
-	.show_node_name = 1,
+	.get_starget_port_id = qla2xxx_get_port_id,
+	.show_starget_port_id = 1,
+	.get_starget_port_name = qla2xxx_get_port_name,
+	.show_starget_port_name = 1,
+	.get_starget_node_name = qla2xxx_get_node_name,
+	.show_starget_node_name = 1,
 };
 
 /**
diff -Nru a/drivers/scsi/qla2xxx/qla_rscn.c b/drivers/scsi/qla2xxx/qla_rscn.c
--- a/drivers/scsi/qla2xxx/qla_rscn.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/qla2xxx/qla_rscn.c	2004-12-24 13:36:47 -08:00
@@ -47,8 +47,6 @@
 /* Local Prototypes. */
 static inline uint32_t qla2x00_to_handle(uint16_t, uint16_t, uint16_t);
 static inline uint16_t qla2x00_handle_to_idx(uint32_t);
-static inline uint16_t qla2x00_handle_to_iter(uint32_t);
-static inline uint16_t qla2x00_handle_to_type(uint32_t);
 static inline uint32_t qla2x00_iodesc_to_handle(struct io_descriptor *);
 static inline struct io_descriptor *qla2x00_handle_to_iodesc(scsi_qla_host_t *,
     uint32_t);
@@ -130,30 +128,6 @@
 }
 
 /**
- * qla2x00_handle_to_type() - Retrive the descriptor type for a given handle.
- * @handle: descriptor handle
- *
- * Returns the descriptor type specified by the @handle.
- */
-static inline uint16_t
-qla2x00_handle_to_type(uint32_t handle)
-{
-	return ((uint16_t)(((handle) >> HDL_TYPE_SHIFT) & HDL_TYPE_MASK));
-}
-
-/**
- * qla2x00_handle_to_iter() - Retrive the rolling signature for a given handle.
- * @handle: descriptor handle
- *
- * Returns the signature specified by the @handle.
- */
-static inline uint16_t
-qla2x00_handle_to_iter(uint32_t handle)
-{
-	return ((uint16_t)(((handle) >> HDL_ITER_SHIFT) & HDL_ITER_MASK));
-}
-
-/**
  * qla2x00_iodesc_to_handle() - Convert an IO descriptor to a unique handle.
  * @iodesc: io descriptor
  *
@@ -242,6 +216,20 @@
 }
 
 /**
+ * qla2x00_remove_iodesc_timer() - Remove an active timer from an IO descriptor.
+ * @iodesc: io descriptor
+ */
+static inline void
+qla2x00_remove_iodesc_timer(struct io_descriptor *iodesc)
+{
+	if (iodesc->timer.function != NULL) {
+		del_timer_sync(&iodesc->timer);
+		iodesc->timer.data = (unsigned long) NULL;
+		iodesc->timer.function = NULL;
+	}
+}
+
+/**
  * qla2x00_init_io_descriptors() - Initialize the pool of IO descriptors.
  * @ha: HA context
  */
@@ -311,20 +299,6 @@
 	add_timer(&iodesc->timer);
 }
 
-/**
- * qla2x00_remove_iodesc_timer() - Remove an active timer from an IO descriptor.
- * @iodesc: io descriptor
- */
-static inline void
-qla2x00_remove_iodesc_timer(struct io_descriptor *iodesc)
-{
-	if (iodesc->timer.function != NULL) {
-		del_timer_sync(&iodesc->timer);
-		iodesc->timer.data = (unsigned long) NULL;
-		iodesc->timer.function = NULL;
-	}
-}
-
 /** 
  * IO descriptor support routines.
  **/
@@ -374,10 +348,9 @@
 qla2x00_get_mbx_iocb_entry(scsi_qla_host_t *ha, uint32_t handle)
 {
 	uint16_t cnt;
-	device_reg_t *reg;
+	device_reg_t __iomem *reg = ha->iobase;
 	struct mbx_entry *mbxentry;
 
-	reg = ha->iobase;
 	mbxentry = NULL;
 
 	if (ha->req_q_cnt < 3) {
diff -Nru a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
--- a/drivers/scsi/qla2xxx/qla_sup.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/qla2xxx/qla_sup.c	2004-12-24 13:36:18 -08:00
@@ -39,9 +39,7 @@
 qla2x00_lock_nvram_access(scsi_qla_host_t *ha)
 {
 	uint16_t data;
-	device_reg_t *reg;
-
-	reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha)) {
 		data = RD_REG_WORD(&reg->nvram);
@@ -52,12 +50,14 @@
 
 		/* Lock resource */
 		WRT_REG_WORD(&reg->u.isp2300.host_semaphore, 0x1);
+		RD_REG_WORD(&reg->u.isp2300.host_semaphore);
 		udelay(5);
 		data = RD_REG_WORD(&reg->u.isp2300.host_semaphore);
 		while ((data & BIT_0) == 0) {
 			/* Lock failed */
 			udelay(100);
 			WRT_REG_WORD(&reg->u.isp2300.host_semaphore, 0x1);
+			RD_REG_WORD(&reg->u.isp2300.host_semaphore);
 			udelay(5);
 			data = RD_REG_WORD(&reg->u.isp2300.host_semaphore);
 		}
@@ -71,12 +71,12 @@
 void
 qla2x00_unlock_nvram_access(scsi_qla_host_t *ha)
 {
-	device_reg_t *reg;
-
-	reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
-	if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha))
+	if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha)) {
 		WRT_REG_WORD(&reg->u.isp2300.host_semaphore, 0);
+		RD_REG_WORD(&reg->u.isp2300.host_semaphore);
+	}
 }
 
 /**
@@ -112,7 +112,7 @@
 	int count;
 	uint16_t word;
 	uint32_t nv_cmd;
-	device_reg_t *reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	qla2x00_nv_write(ha, NVR_DATA_OUT);
 	qla2x00_nv_write(ha, 0);
@@ -197,7 +197,7 @@
 qla2x00_nvram_request(scsi_qla_host_t *ha, uint32_t nv_cmd)
 {
 	uint8_t		cnt;
-	device_reg_t	*reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 	uint16_t	data = 0;
 	uint16_t	reg_data;
 
@@ -239,7 +239,7 @@
 void
 qla2x00_nv_deselect(scsi_qla_host_t *ha)
 {
-	device_reg_t *reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	WRT_REG_WORD(&reg->nvram, NVR_DESELECT);
 	NVRAM_DELAY();
@@ -254,7 +254,7 @@
 void
 qla2x00_nv_write(scsi_qla_host_t *ha, uint16_t data)
 {
-	device_reg_t *reg = ha->iobase;
+	device_reg_t __iomem *reg = ha->iobase;
 
 	WRT_REG_WORD(&reg->nvram, data | NVR_SELECT);
 	NVRAM_DELAY();
diff -Nru a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
--- a/drivers/scsi/qla2xxx/qla_version.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/qla2xxx/qla_version.h	2004-12-24 13:36:48 -08:00
@@ -19,9 +19,9 @@
 /*
  * Driver version 
  */
-#define QLA2XXX_VERSION      "8.00.00b15-k"
+#define QLA2XXX_VERSION      "8.00.00b21-k"
 
 #define QLA_DRIVER_MAJOR_VER	8
 #define QLA_DRIVER_MINOR_VER	0
 #define QLA_DRIVER_PATCH_VER	0
-#define QLA_DRIVER_BETA_VER	15
+#define QLA_DRIVER_BETA_VER	21
diff -Nru a/drivers/scsi/qlogicfc.c b/drivers/scsi/qlogicfc.c
--- a/drivers/scsi/qlogicfc.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/scsi/qlogicfc.c	2004-12-24 13:37:03 -08:00
@@ -815,9 +815,11 @@
 	   some time before recognizing it is attached to a fabric */
 
 #if ISP2x00_FABRIC
-	for (wait_time = jiffies + 5 * HZ; time_before(jiffies, wait_time);) {
-		barrier();
-		cpu_relax();
+	if (hosts) {
+		for (wait_time = jiffies + 5 * HZ; time_before(jiffies, wait_time);) {
+			barrier();
+			cpu_relax();
+		}
 	}
 #endif
 
diff -Nru a/drivers/scsi/qlogicfc_asm.c b/drivers/scsi/qlogicfc_asm.c
--- a/drivers/scsi/qlogicfc_asm.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/scsi/qlogicfc_asm.c	2004-12-24 13:36:17 -08:00
@@ -19,10 +19,10 @@
  *	Firmware Version 1.19.16 (10:36 Nov 02, 2000)
  */
 
-unsigned short risc_code_addr01 = 0x1000 ;
+static unsigned short risc_code_addr01 = 0x1000 ;
 
-unsigned short risc_code_length2100 = 0x9260;
-unsigned short risc_code2100[] = {
+static unsigned short risc_code_length2100 = 0x9260;
+static unsigned short risc_code2100[] = {
 	0x0078, 0x102d, 0x0000, 0x9260, 0x0000, 0x0001, 0x0013, 0x0010,
 	0x0017, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2031, 0x3939,
 	0x3920, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
@@ -4729,8 +4729,8 @@
  *	Firmware Version 2.01.27 (11:07 Dec 18, 2000)
  */
 
-unsigned short risc_code_length2200 = 0x9cbf;
-unsigned short risc_code2200[] = { 
+static unsigned short risc_code_length2200 = 0x9cbf;
+static unsigned short risc_code2200[] = { 
 	0x0470, 0x0000, 0x0000, 0x9cbf, 0x0000, 0x0002, 0x0001, 0x001b,
 	0x0017, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2031, 0x3939,
 	0x3920, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
diff -Nru a/drivers/scsi/qlogicisp.c b/drivers/scsi/qlogicisp.c
--- a/drivers/scsi/qlogicisp.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/scsi/qlogicisp.c	2004-12-24 13:37:30 -08:00
@@ -564,7 +564,7 @@
 };
 
 struct isp1020_hostdata {
-	u_long	memaddr;
+	void __iomem *memaddr;
 	u_char	revision;
 	struct	host_param host_param;
 	struct	dev_param dev_param[MAX_TARGETS];
@@ -714,7 +714,7 @@
 		continue;
 
 	fail_uninit:
-		iounmap((void *)hostdata->memaddr);
+		iounmap(hostdata->memaddr);
 		release_region(host->io_port, 0xff);
 	fail_and_unregister:
 		if (hostdata->res_cpu)
@@ -747,7 +747,7 @@
 	isp_outw(0x0, host, PCI_INTF_CTL);
 	free_irq(host->irq, host);
 
-	iounmap((void *)hostdata->memaddr);
+	iounmap(hostdata->memaddr);
 
 	release_region(host->io_port, 0xff);
 
@@ -769,7 +769,7 @@
 		"QLogic ISP1020 SCSI on PCI bus %02x device %02x irq %d %s base 0x%lx",
 		hostdata->pci_dev->bus->number, hostdata->pci_dev->devfn, host->irq,
 		(hostdata->memaddr ? "MEM" : "I/O"),
-		(hostdata->memaddr ? hostdata->memaddr : host->io_port));
+		(hostdata->memaddr ? (unsigned long)hostdata->memaddr : host->io_port));
 
 	LEAVE("isp1020_info");
 
@@ -1410,18 +1410,17 @@
 
  	if ((command & PCI_COMMAND_MEMORY) &&
  	    ((mem_flags & 1) == 0)) {
- 		mem_base = (u_long) ioremap(mem_base, PAGE_SIZE);
-		if (!mem_base) {
+ 		hostdata->memaddr = ioremap(mem_base, PAGE_SIZE);
+		if (!hostdata->memaddr) {
  			printk("qlogicisp : i/o remapping failed.\n");
 			goto out_release;
 		}
- 		hostdata->memaddr = mem_base;
  	} else {
 		if (command & PCI_COMMAND_IO && (io_flags & 3) != 1) {
 			printk("qlogicisp : i/o mapping is disabled\n");
 			goto out_release;
  		}
- 		hostdata->memaddr = 0; /* zero to signify no i/o mapping */
+ 		hostdata->memaddr = NULL; /* zero to signify no i/o mapping */
  		mem_base = 0;
 	}
 
@@ -1470,7 +1469,7 @@
 	return 0;
 
 out_unmap:
-	iounmap((void *)hostdata->memaddr);
+	iounmap(hostdata->memaddr);
 out_release:
 	release_region(sh->io_port, 0xff);
 	return 1;
diff -Nru a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
--- a/drivers/scsi/sata_nv.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/scsi/sata_nv.c	2004-12-24 13:36:30 -08:00
@@ -44,7 +44,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME			"sata_nv"
-#define DRV_VERSION			"0.03"
+#define DRV_VERSION			"0.5"
 
 #define NV_PORTS			2
 #define NV_PIO_MASK			0x1f
@@ -218,10 +218,18 @@
 	.host_stop		= nv_host_stop,
 };
 
+/* FIXME: The hardware provides the necessary SATA PHY controls
+ * to support ATA_FLAG_SATA_RESET.  However, it is currently
+ * necessary to disable that flag, to solve misdetection problems.
+ * See http://bugme.osdl.org/show_bug.cgi?id=3352 for more info.
+ *
+ * This problem really needs to be investigated further.  But in the
+ * meantime, we avoid ATA_FLAG_SATA_RESET to get people working.
+ */
 static struct ata_port_info nv_port_info = {
 	.sht		= &nv_sht,
 	.host_flags	= ATA_FLAG_SATA |
-			  ATA_FLAG_SATA_RESET |
+			  /* ATA_FLAG_SATA_RESET | */
 			  ATA_FLAG_SRST |
 			  ATA_FLAG_NO_LEGACY,
 	.pio_mask	= NV_PIO_MASK,
@@ -234,6 +242,7 @@
 MODULE_DESCRIPTION("low-level driver for NVIDIA nForce SATA controller");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, nv_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
 irqreturn_t nv_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
 {
@@ -311,7 +320,7 @@
 	static int printed_version = 0;
 	struct nv_host *host;
 	struct ata_port_info *ppi;
-	struct ata_probe_ent *probe_ent = NULL;
+	struct ata_probe_ent *probe_ent;
 	int rc;
 
 	if (!printed_version++)
@@ -319,11 +328,11 @@
 
 	rc = pci_enable_device(pdev);
 	if (rc)
-		return rc;
+		goto err_out;
 
 	rc = pci_request_regions(pdev, DRV_NAME);
 	if (rc)
-		goto err_out;
+		goto err_out_disable;
 
 	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
 	if (rc)
@@ -332,18 +341,16 @@
 	if (rc)
 		goto err_out_regions;
 
+	rc = -ENOMEM;
+
 	ppi = &nv_port_info;
 	probe_ent = ata_pci_init_native_mode(pdev, &ppi);
-	if (!probe_ent) {
-		rc = -ENOMEM;
+	if (!probe_ent)
 		goto err_out_regions;
-	}
 
 	host = kmalloc(sizeof(struct nv_host), GFP_KERNEL);
-	if (!host) {
-		rc = -ENOMEM;
+	if (!host)
 		goto err_out_free_ent;
-	}
 
 	host->host_desc = &nv_device_tbl[ent->driver_data];
 
@@ -354,8 +361,10 @@
 
 		probe_ent->mmio_base = ioremap(pci_resource_start(pdev, 5),
 				pci_resource_len(pdev, 5));
-		if (probe_ent->mmio_base == NULL)
-			goto err_out_iounmap;
+		if (probe_ent->mmio_base == NULL) {
+			rc = -EIO;
+			goto err_out_free_host;
+		}
 
 		base = (unsigned long)probe_ent->mmio_base;
 
@@ -373,14 +382,14 @@
 
 	pci_set_master(pdev);
 
-	// Enable hotplug event interrupts.
-	if (host->host_desc->enable_hotplug)
-		host->host_desc->enable_hotplug(probe_ent);
-
 	rc = ata_device_add(probe_ent);
 	if (rc != NV_PORTS)
 		goto err_out_iounmap;
 
+	// Enable hotplug event interrupts.
+	if (host->host_desc->enable_hotplug)
+		host->host_desc->enable_hotplug(probe_ent);
+
 	kfree(probe_ent);
 
 	return 0;
@@ -388,15 +397,15 @@
 err_out_iounmap:
 	if (host->host_desc->host_flags & NV_HOST_FLAGS_SCR_MMIO)
 		iounmap(probe_ent->mmio_base);
-
+err_out_free_host:
+	kfree(host);
 err_out_free_ent:
 	kfree(probe_ent);
-
 err_out_regions:
 	pci_release_regions(pdev);
-
-err_out:
+err_out_disable:
 	pci_disable_device(pdev);
+err_out:
 	return rc;
 }
 
@@ -454,12 +463,13 @@
 
 static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent)
 {
+	struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
 	u8 intr_mask;
 	u8 regval;
 
-	pci_read_config_byte(probe_ent->pdev, NV_MCP_SATA_CFG_20, &regval);
+	pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
 	regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
-	pci_write_config_byte(probe_ent->pdev, NV_MCP_SATA_CFG_20, regval);
+	pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
 
 	writeb(NV_INT_STATUS_HOTPLUG, probe_ent->mmio_base + NV_INT_STATUS_CK804);
 
@@ -471,6 +481,7 @@
 
 static void nv_disable_hotplug_ck804(struct ata_host_set *host_set)
 {
+	struct pci_dev *pdev = to_pci_dev(host_set->dev);
 	u8 intr_mask;
 	u8 regval;
 
@@ -480,9 +491,9 @@
 
 	writeb(intr_mask, host_set->mmio_base + NV_INT_ENABLE_CK804);
 
-	pci_read_config_byte(host_set->pdev, NV_MCP_SATA_CFG_20, &regval);
+	pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
 	regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
-	pci_write_config_byte(host_set->pdev, NV_MCP_SATA_CFG_20, regval);
+	pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
 }
 
 static void nv_check_hotplug_ck804(struct ata_host_set *host_set)
diff -Nru a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
--- a/drivers/scsi/sata_promise.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/scsi/sata_promise.c	2004-12-24 13:37:02 -08:00
@@ -40,7 +40,7 @@
 #include "sata_promise.h"
 
 #define DRV_NAME	"sata_promise"
-#define DRV_VERSION	"1.00"
+#define DRV_VERSION	"1.01"
 
 
 enum {
@@ -73,7 +73,7 @@
 
 static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg);
 static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
-static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
+static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
 static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
 static void pdc_eng_timeout(struct ata_port *ap);
 static int pdc_port_start(struct ata_port *ap);
@@ -85,7 +85,7 @@
 static void pdc_irq_clear(struct ata_port *ap);
 static int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
 
-static Scsi_Host_Template pdc_sata_sht = {
+static Scsi_Host_Template pdc_ata_sht = {
 	.module			= THIS_MODULE,
 	.name			= DRV_NAME,
 	.ioctl			= ata_scsi_ioctl,
@@ -104,7 +104,7 @@
 	.bios_param		= ata_std_bios_param,
 };
 
-static struct ata_port_operations pdc_sata_ops = {
+static struct ata_port_operations pdc_ata_ops = {
 	.port_disable		= ata_port_disable,
 	.tf_load		= pdc_tf_load_mmio,
 	.tf_read		= ata_tf_read,
@@ -126,28 +126,28 @@
 static struct ata_port_info pdc_port_info[] = {
 	/* board_2037x */
 	{
-		.sht		= &pdc_sata_sht,
+		.sht		= &pdc_ata_sht,
 		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
 				  ATA_FLAG_SRST | ATA_FLAG_MMIO,
 		.pio_mask	= 0x1f, /* pio0-4 */
 		.mwdma_mask	= 0x07, /* mwdma0-2 */
 		.udma_mask	= 0x7f, /* udma0-6 ; FIXME */
-		.port_ops	= &pdc_sata_ops,
+		.port_ops	= &pdc_ata_ops,
 	},
 
 	/* board_20319 */
 	{
-		.sht		= &pdc_sata_sht,
+		.sht		= &pdc_ata_sht,
 		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
 				  ATA_FLAG_SRST | ATA_FLAG_MMIO,
 		.pio_mask	= 0x1f, /* pio0-4 */
 		.mwdma_mask	= 0x07, /* mwdma0-2 */
 		.udma_mask	= 0x7f, /* udma0-6 ; FIXME */
-		.port_ops	= &pdc_sata_ops,
+		.port_ops	= &pdc_ata_ops,
 	},
 };
 
-static struct pci_device_id pdc_sata_pci_tbl[] = {
+static struct pci_device_id pdc_ata_pci_tbl[] = {
 	{ PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
 	  board_2037x },
 	{ PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
@@ -164,17 +164,17 @@
 };
 
 
-static struct pci_driver pdc_sata_pci_driver = {
+static struct pci_driver pdc_ata_pci_driver = {
 	.name			= DRV_NAME,
-	.id_table		= pdc_sata_pci_tbl,
-	.probe			= pdc_sata_init_one,
+	.id_table		= pdc_ata_pci_tbl,
+	.probe			= pdc_ata_init_one,
 	.remove			= ata_pci_remove_one,
 };
 
 
 static int pdc_port_start(struct ata_port *ap)
 {
-	struct pci_dev *pdev = ap->host_set->pdev;
+	struct device *dev = ap->host_set->dev;
 	struct pdc_port_priv *pp;
 	int rc;
 
@@ -189,7 +189,7 @@
 	}
 	memset(pp, 0, sizeof(*pp));
 
-	pp->pkt = pci_alloc_consistent(pdev, 128, &pp->pkt_dma);
+	pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
 	if (!pp->pkt) {
 		rc = -ENOMEM;
 		goto err_out_kfree;
@@ -209,11 +209,11 @@
 
 static void pdc_port_stop(struct ata_port *ap)
 {
-	struct pci_dev *pdev = ap->host_set->pdev;
+	struct device *dev = ap->host_set->dev;
 	struct pdc_port_priv *pp = ap->private_data;
 
 	ap->private_data = NULL;
-	pci_free_consistent(pdev, 128, pp->pkt, pp->pkt_dma);
+	dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma);
 	kfree(pp);
 	ata_port_stop(ap);
 }
@@ -481,7 +481,7 @@
 }
 
 
-static void pdc_sata_setup_port(struct ata_ioports *port, unsigned long base)
+static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base)
 {
 	port->cmd_addr		= base;
 	port->data_addr		= base;
@@ -539,7 +539,7 @@
 	writel(tmp, mmio + PDC_SLEW_CTL);
 }
 
-static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
+static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	static int printed_version;
 	struct ata_probe_ent *probe_ent = NULL;
@@ -577,7 +577,7 @@
 	}
 
 	memset(probe_ent, 0, sizeof(*probe_ent));
-	probe_ent->pdev = pdev;
+	probe_ent->dev = pci_dev_to_dev(pdev);
 	INIT_LIST_HEAD(&probe_ent->node);
 
 	mmio_base = ioremap(pci_resource_start(pdev, 3),
@@ -599,8 +599,8 @@
        	probe_ent->irq_flags = SA_SHIRQ;
 	probe_ent->mmio_base = mmio_base;
 
-	pdc_sata_setup_port(&probe_ent->port[0], base + 0x200);
-	pdc_sata_setup_port(&probe_ent->port[1], base + 0x280);
+	pdc_ata_setup_port(&probe_ent->port[0], base + 0x200);
+	pdc_ata_setup_port(&probe_ent->port[1], base + 0x280);
 
 	probe_ent->port[0].scr_addr = base + 0x400;
 	probe_ent->port[1].scr_addr = base + 0x500;
@@ -610,8 +610,8 @@
 	case board_20319:
        		probe_ent->n_ports = 4;
 
-		pdc_sata_setup_port(&probe_ent->port[2], base + 0x300);
-		pdc_sata_setup_port(&probe_ent->port[3], base + 0x380);
+		pdc_ata_setup_port(&probe_ent->port[2], base + 0x300);
+		pdc_ata_setup_port(&probe_ent->port[3], base + 0x380);
 
 		probe_ent->port[2].scr_addr = base + 0x600;
 		probe_ent->port[3].scr_addr = base + 0x700;
@@ -645,22 +645,23 @@
 }
 
 
-static int __init pdc_sata_init(void)
+static int __init pdc_ata_init(void)
 {
-	return pci_module_init(&pdc_sata_pci_driver);
+	return pci_module_init(&pdc_ata_pci_driver);
 }
 
 
-static void __exit pdc_sata_exit(void)
+static void __exit pdc_ata_exit(void)
 {
-	pci_unregister_driver(&pdc_sata_pci_driver);
+	pci_unregister_driver(&pdc_ata_pci_driver);
 }
 
 
 MODULE_AUTHOR("Jeff Garzik");
 MODULE_DESCRIPTION("Promise SATA TX2/TX4 low-level driver");
 MODULE_LICENSE("GPL");
-MODULE_DEVICE_TABLE(pci, pdc_sata_pci_tbl);
+MODULE_DEVICE_TABLE(pci, pdc_ata_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
-module_init(pdc_sata_init);
-module_exit(pdc_sata_exit);
+module_init(pdc_ata_init);
+module_exit(pdc_ata_exit);
diff -Nru a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
--- a/drivers/scsi/sata_sil.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/sata_sil.c	2004-12-24 13:36:16 -08:00
@@ -38,7 +38,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME	"sata_sil"
-#define DRV_VERSION	"0.54"
+#define DRV_VERSION	"0.8"
 
 enum {
 	sil_3112		= 0,
@@ -87,6 +87,7 @@
 	{ "ST380023AS",		SIL_QUIRK_MOD15WRITE },
 	{ "ST3120023AS",	SIL_QUIRK_MOD15WRITE },
 	{ "ST3160023AS",	SIL_QUIRK_MOD15WRITE },
+	{ "ST3120026AS",	SIL_QUIRK_MOD15WRITE },
 	{ "ST340014ASL",	SIL_QUIRK_MOD15WRITE },
 	{ "ST360014ASL",	SIL_QUIRK_MOD15WRITE },
 	{ "ST380011ASL",	SIL_QUIRK_MOD15WRITE },
@@ -189,6 +190,7 @@
 MODULE_DESCRIPTION("low-level driver for Silicon Image SATA controller");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, sil_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
 static void sil_post_set_mode (struct ata_port *ap)
 {
@@ -287,7 +289,7 @@
 	const char *s;
 	unsigned int len;
 
-	ata_dev_id_string(dev, model_num, ATA_ID_PROD_OFS,
+	ata_dev_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
 			  sizeof(model_num));
 	s = &model_num[0];
 	len = strnlen(s, sizeof(model_num));
@@ -362,7 +364,7 @@
 
 	memset(probe_ent, 0, sizeof(*probe_ent));
 	INIT_LIST_HEAD(&probe_ent->node);
-	probe_ent->pdev = pdev;
+	probe_ent->dev = pci_dev_to_dev(pdev);
 	probe_ent->port_ops = sil_port_info[ent->driver_data].port_ops;
 	probe_ent->sht = sil_port_info[ent->driver_data].sht;
 	probe_ent->n_ports = (ent->driver_data == sil_3114) ? 4 : 2;
diff -Nru a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
--- a/drivers/scsi/sata_sis.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/scsi/sata_sis.c	2004-12-24 13:36:55 -08:00
@@ -38,7 +38,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME	"sata_sis"
-#define DRV_VERSION	"0.10"
+#define DRV_VERSION	"0.5"
 
 enum {
 	sis_180			= 0,
@@ -128,6 +128,7 @@
 MODULE_DESCRIPTION("low-level driver for Silicon Integratad Systems SATA controller");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, sis_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
 static unsigned int get_scr_cfg_addr(unsigned int port_no, unsigned int sc_reg)
 {
@@ -140,22 +141,24 @@
 
 static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
 {
+	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, sc_reg);
 	u32 val;
 
 	if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */
 		return 0xffffffff;
-	pci_read_config_dword(ap->host_set->pdev, cfg_addr, &val);
+	pci_read_config_dword(pdev, cfg_addr, &val);
 	return val;
 }
 
 static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val)
 {
+	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, scr);
 
 	if (scr == SCR_ERROR) /* doesn't exist in PCI cfg space */
 		return;
-	pci_write_config_dword(ap->host_set->pdev, cfg_addr, val);
+	pci_write_config_dword(pdev, cfg_addr, val);
 }
 
 static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg)
diff -Nru a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
--- a/drivers/scsi/sata_svw.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/sata_svw.c	2004-12-24 13:37:00 -08:00
@@ -49,7 +49,7 @@
 #endif /* CONFIG_PPC_OF */
 
 #define DRV_NAME	"sata_svw"
-#define DRV_VERSION	"1.04"
+#define DRV_VERSION	"1.05"
 
 /* Taskfile registers offsets */
 #define K2_SATA_TF_CMD_OFFSET		0x00
@@ -245,7 +245,7 @@
 		return 0;
 
 	/* Find the OF node for the PCI device proper */
-	np = pci_device_to_OF_node(ap->host_set->pdev);
+	np = pci_device_to_OF_node(to_pci_dev(ap->host_set->dev));
 	if (np == NULL)
 		return 0;
 
@@ -376,7 +376,7 @@
 	}
 
 	memset(probe_ent, 0, sizeof(*probe_ent));
-	probe_ent->pdev = pdev;
+	probe_ent->dev = pci_dev_to_dev(pdev);
 	INIT_LIST_HEAD(&probe_ent->node);
 
 	mmio_base = ioremap(pci_resource_start(pdev, 5),
@@ -470,6 +470,7 @@
 MODULE_DESCRIPTION("low-level driver for K2 SATA controller");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, k2_sata_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
 module_init(k2_sata_init);
 module_exit(k2_sata_exit);
diff -Nru a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
--- a/drivers/scsi/sata_sx4.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/sata_sx4.c	2004-12-24 13:36:16 -08:00
@@ -40,7 +40,7 @@
 #include "sata_promise.h"
 
 #define DRV_NAME	"sata_sx4"
-#define DRV_VERSION	"0.50"
+#define DRV_VERSION	"0.7"
 
 
 enum {
@@ -248,7 +248,7 @@
 
 static int pdc_port_start(struct ata_port *ap)
 {
-	struct pci_dev *pdev = ap->host_set->pdev;
+	struct device *dev = ap->host_set->dev;
 	struct pdc_port_priv *pp;
 	int rc;
 
@@ -263,7 +263,7 @@
 	}
 	memset(pp, 0, sizeof(*pp));
 
-	pp->pkt = pci_alloc_consistent(pdev, 128, &pp->pkt_dma);
+	pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
 	if (!pp->pkt) {
 		rc = -ENOMEM;
 		goto err_out_kfree;
@@ -283,11 +283,11 @@
 
 static void pdc_port_stop(struct ata_port *ap)
 {
-	struct pci_dev *pdev = ap->host_set->pdev;
+	struct device *dev = ap->host_set->dev;
 	struct pdc_port_priv *pp = ap->private_data;
 
 	ap->private_data = NULL;
-	pci_free_consistent(pdev, 128, pp->pkt, pp->pkt_dma);
+	dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma);
 	kfree(pp);
 	ata_port_stop(ap);
 }
@@ -1190,8 +1190,7 @@
 	   		error = 0;
 	   		break;     
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((i * 100) * HZ / 1000 + 1);
+		msleep(i*100);
    	}
    	return error;
 }
@@ -1224,8 +1223,7 @@
 	readl(mmio + PDC_TIME_CONTROL);
 
 	/* Wait 3 seconds */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(3 * HZ);
+	msleep(3000);
 
 	/* 
 	   When timer is enabled, counter is decreased every internal
@@ -1399,7 +1397,7 @@
 	}
 
 	memset(probe_ent, 0, sizeof(*probe_ent));
-	probe_ent->pdev = pdev;
+	probe_ent->dev = pci_dev_to_dev(pdev);
 	INIT_LIST_HEAD(&probe_ent->node);
 
 	mmio_base = ioremap(pci_resource_start(pdev, 3),
@@ -1494,6 +1492,7 @@
 MODULE_DESCRIPTION("Promise SATA low-level driver");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, pdc_sata_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
 module_init(pdc_sata_init);
 module_exit(pdc_sata_exit);
diff -Nru a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/scsi/sata_uli.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,285 @@
+/*
+ *  sata_uli.c - ULi Electronics SATA
+ *
+ *  The contents of this file are subject to the Open
+ *  Software License version 1.1 that can be found at
+ *  http://www.opensource.org/licenses/osl-1.1.txt and is included herein
+ *  by reference.
+ *
+ *  Alternatively, the contents of this file may be used under the terms
+ *  of the GNU General Public License version 2 (the "GPL") as distributed
+ *  in the kernel source COPYING file, in which case the provisions of
+ *  the GPL are applicable instead of the above.  If you wish to allow
+ *  the use of your version of this file only under the terms of the
+ *  GPL and not to allow others to use your version of this file under
+ *  the OSL, indicate your decision by deleting the provisions above and
+ *  replace them with the notice and other provisions required by the GPL.
+ *  If you do not delete the provisions above, a recipient may use your
+ *  version of this file under either the OSL or the GPL.
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include "scsi.h"
+#include <scsi/scsi_host.h>
+#include <linux/libata.h>
+
+#define DRV_NAME	"sata_uli"
+#define DRV_VERSION	"0.2"
+
+enum {
+	uli_5289		= 0,
+	uli_5287		= 1,
+
+	/* PCI configuration registers */
+	ULI_SCR_BASE		= 0x90, /* sata0 phy SCR registers */
+	ULI_SATA1_OFS		= 0x10, /* offset from sata0->sata1 phy regs */
+
+};
+
+static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
+static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg);
+static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
+
+static struct pci_device_id uli_pci_tbl[] = {
+	{ PCI_VENDOR_ID_AL, 0x5289, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5289 },
+	{ PCI_VENDOR_ID_AL, 0x5287, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5287 },
+	{ }	/* terminate list */
+};
+
+
+static struct pci_driver uli_pci_driver = {
+	.name			= DRV_NAME,
+	.id_table		= uli_pci_tbl,
+	.probe			= uli_init_one,
+	.remove			= ata_pci_remove_one,
+};
+
+static Scsi_Host_Template uli_sht = {
+	.module			= THIS_MODULE,
+	.name			= DRV_NAME,
+	.ioctl			= ata_scsi_ioctl,
+	.queuecommand		= ata_scsi_queuecmd,
+	.eh_strategy_handler	= ata_scsi_error,
+	.can_queue		= ATA_DEF_QUEUE,
+	.this_id		= ATA_SHT_THIS_ID,
+	.sg_tablesize		= LIBATA_MAX_PRD,
+	.max_sectors		= ATA_MAX_SECTORS,
+	.cmd_per_lun		= ATA_SHT_CMD_PER_LUN,
+	.emulated		= ATA_SHT_EMULATED,
+	.use_clustering		= ATA_SHT_USE_CLUSTERING,
+	.proc_name		= DRV_NAME,
+	.dma_boundary		= ATA_DMA_BOUNDARY,
+	.slave_configure	= ata_scsi_slave_config,
+	.bios_param		= ata_std_bios_param,
+};
+
+static struct ata_port_operations uli_ops = {
+	.port_disable		= ata_port_disable,
+
+	.tf_load		= ata_tf_load,
+	.tf_read		= ata_tf_read,
+	.check_status		= ata_check_status,
+	.exec_command		= ata_exec_command,
+	.dev_select		= ata_std_dev_select,
+
+	.phy_reset		= sata_phy_reset,
+
+	.bmdma_setup            = ata_bmdma_setup,
+	.bmdma_start            = ata_bmdma_start,
+	.qc_prep		= ata_qc_prep,
+	.qc_issue		= ata_qc_issue_prot,
+
+	.eng_timeout		= ata_eng_timeout,
+
+	.irq_handler		= ata_interrupt,
+	.irq_clear		= ata_bmdma_irq_clear,
+
+	.scr_read		= uli_scr_read,
+	.scr_write		= uli_scr_write,
+
+	.port_start		= ata_port_start,
+	.port_stop		= ata_port_stop,
+};
+
+static struct ata_port_info uli_port_info = {
+	.sht            = &uli_sht,
+	.host_flags     = ATA_FLAG_SATA | ATA_FLAG_SATA_RESET |
+			  ATA_FLAG_NO_LEGACY,
+	.pio_mask       = 0x03,		//support pio mode 4 (FIXME)
+	.udma_mask      = 0x7f,		//support udma mode 6
+	.port_ops       = &uli_ops,
+};
+
+
+MODULE_AUTHOR("Peer Chen");
+MODULE_DESCRIPTION("low-level driver for ULi Electronics SATA controller");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(pci, uli_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
+
+static unsigned int get_scr_cfg_addr(unsigned int port_no, unsigned int sc_reg)
+{
+	unsigned int addr = ULI_SCR_BASE + (4 * sc_reg);
+
+	switch (port_no) {
+	case 0:
+		break;
+	case 1:
+		addr += ULI_SATA1_OFS;
+		break;
+	case 2:
+		addr += ULI_SATA1_OFS*4;
+		break;
+	case 3:
+		addr += ULI_SATA1_OFS*5;
+		break;
+	default:
+		BUG();
+		break;
+	}
+	return addr;
+}
+
+static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
+{
+	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
+	unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, sc_reg);
+	u32 val;
+
+	pci_read_config_dword(pdev, cfg_addr, &val);
+	return val;
+}
+
+static void uli_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val)
+{
+	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
+	unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, scr);
+
+	pci_write_config_dword(pdev, cfg_addr, val);
+}
+
+static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg)
+{
+	if (sc_reg > SCR_CONTROL)
+		return 0xffffffffU;
+
+	return uli_scr_cfg_read(ap, sc_reg);
+}
+
+static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
+{
+	if (sc_reg > SCR_CONTROL)	//SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0
+		return;
+
+	uli_scr_cfg_write(ap, sc_reg, val);
+}
+
+/* move to PCI layer, integrate w/ MSI stuff */
+static void pci_enable_intx(struct pci_dev *pdev)
+{
+	u16 pci_command;
+
+	pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
+	if (pci_command & PCI_COMMAND_INTX_DISABLE) {
+		pci_command &= ~PCI_COMMAND_INTX_DISABLE;
+		pci_write_config_word(pdev, PCI_COMMAND, pci_command);
+	}
+}
+
+static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	struct ata_probe_ent *probe_ent;
+	struct ata_port_info *ppi;
+	int rc;
+	unsigned int board_idx = (unsigned int) ent->driver_data;
+
+	rc = pci_enable_device(pdev);
+	if (rc)
+		return rc;
+
+	rc = pci_request_regions(pdev, DRV_NAME);
+	if (rc)
+		goto err_out;
+
+	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
+	if (rc)
+		goto err_out_regions;
+	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	if (rc)
+		goto err_out_regions;
+
+	ppi = &uli_port_info;
+	probe_ent = ata_pci_init_native_mode(pdev, &ppi);
+	if (!probe_ent) {
+		rc = -ENOMEM;
+		goto err_out_regions;
+	}
+
+	switch (board_idx) {
+	case uli_5287:
+       		probe_ent->n_ports = 4;
+
+       		probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8;
+		probe_ent->port[2].altstatus_addr =
+		probe_ent->port[2].ctl_addr =
+			(pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4;
+		probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16;
+
+		probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8;
+		probe_ent->port[3].altstatus_addr =
+		probe_ent->port[3].ctl_addr =
+			(pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4;
+		probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24;
+
+		ata_std_ports(&probe_ent->port[2]);
+		ata_std_ports(&probe_ent->port[3]);
+		break;
+
+	case uli_5289:
+		/* do nothing; ata_pci_init_native_mode did it all */
+		break;
+
+	default:
+		BUG();
+		break;
+	}
+
+	pci_set_master(pdev);
+	pci_enable_intx(pdev);
+
+	/* FIXME: check ata_device_add return value */
+	ata_device_add(probe_ent);
+	kfree(probe_ent);
+
+	return 0;
+
+err_out_regions:
+	pci_release_regions(pdev);
+
+err_out:
+	pci_disable_device(pdev);
+	return rc;
+
+}
+
+static int __init uli_init(void)
+{
+	return pci_module_init(&uli_pci_driver);
+}
+
+static void __exit uli_exit(void)
+{
+	pci_unregister_driver(&uli_pci_driver);
+}
+
+
+module_init(uli_init);
+module_exit(uli_exit);
diff -Nru a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
--- a/drivers/scsi/sata_via.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/scsi/sata_via.c	2004-12-24 13:36:19 -08:00
@@ -38,7 +38,7 @@
 #include <asm/io.h>
 
 #define DRV_NAME	"sata_via"
-#define DRV_VERSION	"0.20"
+#define DRV_VERSION	"1.0"
 
 enum {
 	via_sata		= 0,
@@ -138,6 +138,7 @@
 MODULE_DESCRIPTION("SCSI low-level driver for VIA SATA controllers");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, svia_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
 static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
diff -Nru a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
--- a/drivers/scsi/sata_vsc.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/scsi/sata_vsc.c	2004-12-24 13:36:56 -08:00
@@ -26,7 +26,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME	"sata_vsc"
-#define DRV_VERSION	"0.01"
+#define DRV_VERSION	"1.0"
 
 /* Interrupt register offsets (from chip base address) */
 #define VSC_SATA_INT_STAT_OFFSET	0x00
@@ -293,7 +293,7 @@
 		goto err_out_regions;
 	}
 	memset(probe_ent, 0, sizeof(*probe_ent));
-	probe_ent->pdev = pdev;
+	probe_ent->dev = pci_dev_to_dev(pdev);
 	INIT_LIST_HEAD(&probe_ent->node);
 
 	mmio_base = ioremap(pci_resource_start(pdev, 0),
@@ -333,6 +333,14 @@
 
 	pci_set_master(pdev);
 
+	/* 
+	 * Config offset 0x98 is "Extended Control and Status Register 0"
+	 * Default value is (1 << 28).  All bits except bit 28 are reserved in
+	 * DPA mode.  If bit 28 is set, LED 0 reflects all ports' activity.
+	 * If bit 28 is clear, each port has its own LED.
+	 */
+	pci_write_config_dword(pdev, 0x98, 0);
+
 	/* FIXME: check ata_device_add return value */
 	ata_device_add(probe_ent);
 	kfree(probe_ent);
@@ -385,6 +393,7 @@
 MODULE_DESCRIPTION("low-level driver for Vitesse VSC7174 SATA controller");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, vsc_sata_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
 
 module_init(vsc_sata_init);
 module_exit(vsc_sata_exit);
diff -Nru a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
--- a/drivers/scsi/scsi.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/scsi/scsi.c	2004-12-24 13:36:55 -08:00
@@ -244,7 +244,13 @@
  */
 struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int gfp_mask)
 {
-	struct scsi_cmnd *cmd = __scsi_get_command(dev->host, gfp_mask);
+	struct scsi_cmnd *cmd;
+
+	/* Bail if we can't get a reference to the device */
+	if (!get_device(&dev->sdev_gendev))
+		return NULL;
+
+	cmd = __scsi_get_command(dev->host, gfp_mask);
 
 	if (likely(cmd != NULL)) {
 		unsigned long flags;
@@ -258,7 +264,8 @@
 		spin_lock_irqsave(&dev->list_lock, flags);
 		list_add_tail(&cmd->list, &dev->cmd_list);
 		spin_unlock_irqrestore(&dev->list_lock, flags);
-	}
+	} else
+		put_device(&dev->sdev_gendev);
 
 	return cmd;
 }				
@@ -276,7 +283,8 @@
  */
 void scsi_put_command(struct scsi_cmnd *cmd)
 {
-	struct Scsi_Host *shost = cmd->device->host;
+	struct scsi_device *sdev = cmd->device;
+	struct Scsi_Host *shost = sdev->host;
 	unsigned long flags;
 	
 	/* serious error if the command hasn't come from a device list */
@@ -294,6 +302,8 @@
 
 	if (likely(cmd != NULL))
 		kmem_cache_free(shost->cmd_pool->slab, cmd);
+
+	put_device(&sdev->sdev_gendev);
 }
 
 /*
@@ -518,6 +528,26 @@
 		/* return 0 (because the command has been processed) */
 		goto out;
 	}
+
+	/* Check to see if the scsi lld put this device into state SDEV_BLOCK. */
+	if (unlikely(cmd->device->sdev_state == SDEV_BLOCK)) {
+		/* 
+		 * in SDEV_BLOCK, the command is just put back on the device
+		 * queue.  The suspend state has already blocked the queue so
+		 * future requests should not occur until the device 
+		 * transitions out of the suspend state.
+		 */
+		scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY);
+
+		SCSI_LOG_MLQUEUE(3, printk("queuecommand : device blocked \n"));
+
+		/*
+		 * NOTE: rtn is still zero here because we don't need the
+		 * queue to be plugged on return (it's already stopped)
+		 */
+		goto out;
+	}
+
 	/* Assign a unique nonzero serial_number. */
 	/* XXX(hch): this is racy */
 	if (++serial_number == 0)
@@ -1033,6 +1063,7 @@
 		/* skip devices that we can't get a reference to */
 		if (!scsi_device_get(next))
 			break;
+		next = NULL;
 		list = list->next;
 	}
 	spin_unlock_irqrestore(shost->host_lock, flags);
@@ -1103,8 +1134,8 @@
 
 /**
  * scsi_device_cancel - cancel outstanding IO to this device
- * @sdev:	pointer to struct scsi_device
- * @data:	pointer to cancel value.
+ * @sdev:	Pointer to struct scsi_device
+ * @recovery:	Boolean instructing function to recover device or not.
  *
  **/
 int scsi_device_cancel(struct scsi_device *sdev, int recovery)
diff -Nru a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
--- a/drivers/scsi/scsi_debug.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/scsi_debug.c	2004-12-24 13:37:00 -08:00
@@ -55,8 +55,8 @@
 #include "scsi_logging.h"
 #include "scsi_debug.h"
 
-#define SCSI_DEBUG_VERSION "1.73"
-static const char * scsi_debug_version_date = "20040518";
+#define SCSI_DEBUG_VERSION "1.74"
+static const char * scsi_debug_version_date = "20040829";
 
 /* Additional Sense Code (ASC) used */
 #define NO_ADDED_SENSE 0x0
@@ -82,8 +82,9 @@
 #define DEF_EVERY_NTH   0
 #define DEF_NUM_PARTS   0
 #define DEF_OPTS   0
-#define DEF_SCSI_LEVEL   3
+#define DEF_SCSI_LEVEL   4    /* SPC-2 */
 #define DEF_PTYPE   0
+#define DEF_D_SENSE   0
 
 /* bit mask values for scsi_debug_opts */
 #define SCSI_DEBUG_OPT_NOISE   1
@@ -114,6 +115,7 @@
 static int scsi_debug_opts = DEF_OPTS;
 static int scsi_debug_scsi_level = DEF_SCSI_LEVEL;
 static int scsi_debug_ptype = DEF_PTYPE; /* SCSI peripheral type (0==disk) */
+static int scsi_debug_dsense = DEF_D_SENSE;
 
 static int scsi_debug_cmnd_count = 0;
 
@@ -277,7 +279,7 @@
 int scsi_debug_queuecommand(struct scsi_cmnd * SCpnt, done_funct_t done)
 {
 	unsigned char *cmd = (unsigned char *) SCpnt->cmnd;
-	int block, upper_blk, num;
+	int block, upper_blk, num, k;
 	unsigned char *buff;
 	int errsts = 0;
 	int target = SCpnt->device->id;
@@ -305,7 +307,12 @@
 		bufflen = SDEBUG_SENSE_LEN;
 	}
 
-
+	if ((SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) && cmd) {
+		printk(KERN_INFO "scsi_debug: cmd ");
+		for (k = 0, num = SCpnt->cmd_len; k < num; ++k)
+			printk("%02x ", (int)cmd[k]);
+		printk("\n");
+	}
         if(target == sdebug_driver_template.this_id) {
 		printk(KERN_INFO "scsi_debug: initiator's id used as "
 		       "target!\n");
@@ -331,14 +338,10 @@
         }
 
 	switch (*cmd) {
-	case INQUIRY:     /* mandatory */
+	case INQUIRY:     /* mandatory, ignore unit attention */
 		errsts = resp_inquiry(cmd, target, buff, bufflen, devip);
 		break;
-	case REQUEST_SENSE:	/* mandatory */
-		/* Since this driver indicates autosense by placing the
-		 * sense buffer in the scsi_cmnd structure in the response
-		 * (when SAM_STAT_CHECK_CONDITION is set), the mid level
-		 * shouldn't need to call REQUEST_SENSE */
+	case REQUEST_SENSE:	/* mandatory, ignore unit attention */
 		if (devip) {
 			sbuff = devip->sense_buff;
 			memcpy(buff, sbuff, (bufflen < SDEBUG_SENSE_LEN) ?
@@ -349,20 +352,24 @@
 			buff[0] = 0x70;
 		}
 		break;
+	case REZERO_UNIT:	/* actually this is REWIND for SSC */
 	case START_STOP:
 		errsts = check_reset(SCpnt, devip);
+		memset(buff, 0, bufflen);
 		break;
 	case ALLOW_MEDIUM_REMOVAL:
 		if ((errsts = check_reset(SCpnt, devip)))
 			break;
 		if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
-			printk("\tMedium removal %s\n",
-			       cmd[4] ? "inhibited" : "enabled");
+			printk(KERN_INFO "scsi_debug: Medium removal %s\n",
+			        cmd[4] ? "inhibited" : "enabled");
 		break;
 	case SEND_DIAGNOSTIC:     /* mandatory */
+		errsts = check_reset(SCpnt, devip);
 		memset(buff, 0, bufflen);
 		break;
 	case TEST_UNIT_READY:     /* mandatory */
+		errsts = check_reset(SCpnt, devip);
 		memset(buff, 0, bufflen);
 		break;
         case RESERVE:
@@ -429,7 +436,7 @@
 			errsts = check_condition_result;
 		}
 		break;
-	case REPORT_LUNS:
+	case REPORT_LUNS:	/* mandatory, ignore unit attention */
 		errsts = resp_report_luns(cmd, buff, bufflen, devip);
 		break;
 	case WRITE_16:
@@ -469,14 +476,20 @@
 		break;
 	case MODE_SENSE:
 	case MODE_SENSE_10:
+		if ((errsts = check_reset(SCpnt, devip)))
+			break;
 		errsts = resp_mode_sense(cmd, target, buff, bufflen, devip);
 		break;
 	case SYNCHRONIZE_CACHE:
+		errsts = check_reset(SCpnt, devip);
 		memset(buff, 0, bufflen);
 		break;
 	default:
+		if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
+			printk(KERN_INFO "scsi_debug: Opcode: 0x%x not "
+			       "supported\n", *cmd);
 		if ((errsts = check_reset(SCpnt, devip)))
-			break;
+			break;	/* Unit attention takes precedence */
 		mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_OPCODE, 0, 18);
 		errsts = check_condition_result;
 		break;
@@ -496,6 +509,9 @@
 static int check_reset(struct scsi_cmnd * SCpnt, struct sdebug_dev_info * devip)
 {
 	if (devip->reset) {
+		if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
+			printk(KERN_INFO "scsi_debug: Reporting Unit "
+			       "attention: power on reset\n");
 		devip->reset = 0;
 		mk_sense_buffer(devip, UNIT_ATTENTION, POWERON_RESET, 0, 18);
 		return check_condition_result;
@@ -503,7 +519,7 @@
 	return 0;
 }
 
-#define SDEBUG_LONG_INQ_SZ 58
+#define SDEBUG_LONG_INQ_SZ 96
 #define SDEBUG_MAX_INQ_ARR_SZ 128
 
 static const char * vendor_id = "Linux   ";
@@ -593,11 +609,21 @@
 	/* drops through here for a standard inquiry */
 	arr[1] = DEV_REMOVEABLE(target) ? 0x80 : 0;	/* Removable disk */
 	arr[2] = scsi_debug_scsi_level;
+	arr[3] = 2;    /* response_data_format==2 */
 	arr[4] = SDEBUG_LONG_INQ_SZ - 5;
+	arr[6] = 0x1; /* claim: ADDR16 */
 	arr[7] = 0x3a; /* claim: WBUS16, SYNC, LINKED + CMDQUE */
 	memcpy(&arr[8], vendor_id, 8);
 	memcpy(&arr[16], product_id, 16);
 	memcpy(&arr[32], product_rev, 4);
+	/* version descriptors (2 bytes each) follow */
+	arr[58] = 0x0; arr[59] = 0x40; /* SAM-2 */
+	arr[60] = 0x2; arr[61] = 0x60; /* SPC-2 */
+	if (scsi_debug_ptype == 0) {
+	    arr[62] = 0x1; arr[63] = 0x80; /* SBC */
+	} else if (scsi_debug_ptype == 1) {
+	    arr[62] = 0x2; arr[63] = 0x00; /* SSC */
+	}
 	memcpy(buff, arr, min_len);
 	return 0;
 }
@@ -660,6 +686,8 @@
 	unsigned char ctrl_m_pg[] = {0xa, 10, 2, 0, 0, 0, 0, 0,
 				     0, 0, 0x2, 0x4b};
 
+	if (scsi_debug_dsense)
+		ctrl_m_pg[2] |= 0x4;
 	memcpy(p, ctrl_m_pg, sizeof(ctrl_m_pg));
 	if (1 == pcontrol)
 		memset(p + 2, 0, sizeof(ctrl_m_pg) - 2);
@@ -683,7 +711,7 @@
 			   struct sdebug_dev_info * devip)
 {
 	unsigned char dbd;
-	int pcontrol, pcode;
+	int pcontrol, pcode, subpcode;
 	unsigned char dev_spec;
 	int alloc_len, msense_6, offset, len;
 	unsigned char * ap;
@@ -695,11 +723,9 @@
 	dbd = cmd[1] & 0x8;
 	pcontrol = (cmd[2] & 0xc0) >> 6;
 	pcode = cmd[2] & 0x3f;
+	subpcode = cmd[3];
 	msense_6 = (MODE_SENSE == cmd[0]);
 	alloc_len = msense_6 ? cmd[4] : ((cmd[7] << 8) | cmd[8]);
-	/* printk(KERN_INFO "msense: dbd=%d pcontrol=%d pcode=%d "
-		"msense_6=%d alloc_len=%d\n", dbd, pcontrol, pcode, "
-		"msense_6, alloc_len); */
 	if (bufflen < alloc_len)
 		printk(KERN_INFO "scsi_debug: mode_sense: bufflen=%d "
 		       "< alloc_length=%d\n", bufflen, alloc_len);
@@ -720,6 +746,11 @@
 	}
 	ap = arr + offset;
 
+	if (0 != subpcode) { /* TODO: Control Extension page */
+		mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB,
+			       	0, 18);
+		return check_condition_result;
+	}
 	switch (pcode) {
 	case 0x1:	/* Read-Write error recovery page, direct access */
 		len = resp_err_recov_pg(ap, pcontrol, target);
@@ -1023,13 +1054,23 @@
 
 	sbuff = devip->sense_buff;
 	memset(sbuff, 0, SDEBUG_SENSE_LEN);
-	if (inbandLen > SDEBUG_SENSE_LEN)
-		inbandLen = SDEBUG_SENSE_LEN;
-	sbuff[0] = 0x70;
-	sbuff[2] = key;
-	sbuff[7] = (inbandLen > 7) ? (inbandLen - 8) : 0;
-	sbuff[12] = asc;
-	sbuff[13] = asq;
+	if (scsi_debug_dsense) {
+		sbuff[0] = 0x72;  /* descriptor, current */
+		sbuff[1] = key;
+		sbuff[2] = asc;
+		sbuff[3] = asq;
+	} else {
+		if (inbandLen > SDEBUG_SENSE_LEN)
+			inbandLen = SDEBUG_SENSE_LEN;
+		sbuff[0] = 0x70;  /* fixed, current */
+		sbuff[2] = key;
+		sbuff[7] = (inbandLen > 7) ? (inbandLen - 8) : 0;
+		sbuff[12] = asc;
+		sbuff[13] = asq;
+	}
+	if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
+		printk(KERN_INFO "scsi_debug:    [sense_key,asc,ascq]: "
+		      "[0x%x,0x%x,0x%x]\n", key, asc, asq);
 }
 
 static int scsi_debug_abort(struct scsi_cmnd * SCpnt)
@@ -1230,17 +1271,11 @@
 			 struct sdebug_dev_info * devip,
 			 done_funct_t done, int scsi_result, int delta_jiff)
 {
-	int k, num;
-
 	if ((SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) && cmnd) {
-		printk(KERN_INFO "scsi_debug: cmd ");
-		for (k = 0, num = cmnd->cmd_len; k < num; ++k)
-			printk("%02x ", (int)cmnd->cmnd[k]);
-		printk("\n");
 		if (scsi_result) {
 			struct scsi_device * sdp = cmnd->device;
 
-			printk(KERN_INFO "scsi_debug: ... <%u %u %u %u> "
+			printk(KERN_INFO "scsi_debug:    <%u %u %u %u> "
 			       "non-zero result=0x%x\n", sdp->host->host_no,
 			       sdp->channel, sdp->id, sdp->lun, scsi_result);
 		}
@@ -1296,6 +1331,7 @@
 module_param_named(add_host, scsi_debug_add_host, int, 0); /* perm=0644 */
 module_param_named(delay, scsi_debug_delay, int, 0); /* perm=0644 */
 module_param_named(dev_size_mb, scsi_debug_dev_size_mb, int, 0);
+module_param_named(dsense, scsi_debug_dsense, int, 0);
 module_param_named(every_nth, scsi_debug_every_nth, int, 0);
 module_param_named(max_luns, scsi_debug_max_luns, int, 0);
 module_param_named(num_parts, scsi_debug_num_parts, int, 0);
@@ -1312,13 +1348,14 @@
 MODULE_PARM_DESC(add_host, "0..127 hosts allowed(def=1)");
 MODULE_PARM_DESC(delay, "# of jiffies to delay response(def=1)");
 MODULE_PARM_DESC(dev_size_mb, "size in MB of ram shared by devs");
+MODULE_PARM_DESC(dsense, "use descriptor sense format(def: fixed)");
 MODULE_PARM_DESC(every_nth, "timeout every nth command(def=100)");
 MODULE_PARM_DESC(max_luns, "number of SCSI LUNs per target to simulate");
 MODULE_PARM_DESC(num_parts, "number of partitions(def=0)");
 MODULE_PARM_DESC(num_tgts, "number of SCSI targets per host to simulate");
 MODULE_PARM_DESC(opts, "1->noise, 2->medium_error, 4->...");
 MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])");
-MODULE_PARM_DESC(scsi_level, "SCSI level to simulate");
+MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=4[SPC-2])");
 
 
 static char sdebug_info[256];
@@ -1451,6 +1488,24 @@
 	return -EINVAL;
 }
 DRIVER_ATTR(ptype, S_IRUGO | S_IWUSR, sdebug_ptype_show, sdebug_ptype_store);
+
+static ssize_t sdebug_dsense_show(struct device_driver * ddp, char * buf)
+{
+        return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dsense);
+}
+static ssize_t sdebug_dsense_store(struct device_driver * ddp,
+				  const char * buf, size_t count)
+{
+        int n;
+
+	if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) {
+		scsi_debug_dsense = n;
+		return count;
+	}
+	return -EINVAL;
+}
+DRIVER_ATTR(dsense, S_IRUGO | S_IWUSR, sdebug_dsense_show,
+	    sdebug_dsense_store);
 
 static ssize_t sdebug_num_tgts_show(struct device_driver * ddp, char * buf)
 {
diff -Nru a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
--- a/drivers/scsi/scsi_devinfo.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/scsi_devinfo.c	2004-12-24 13:36:47 -08:00
@@ -83,6 +83,7 @@
 	{"SONY", "CD-ROM CDU-55S", "1.0i", BLIST_NOLUN},
 	{"SONY", "CD-ROM CDU-561", "1.7x", BLIST_NOLUN},
 	{"SONY", "CD-ROM CDU-8012", NULL, BLIST_NOLUN},
+	{"SONY", "SDT-5000", "3.17", BLIST_SELECT_NO_ATN},
 	{"TANDBERG", "TDC 3600", "U07", BLIST_NOLUN},	/* locks up */
 	{"TEAC", "CD-R55S", "1.0H", BLIST_NOLUN},	/* locks up */
 	/*
@@ -115,13 +116,15 @@
 
 	/*
 	 * Other types of devices that have special flags.
+	 * Note that all USB devices should have the BLIST_INQUIRY_36 flag.
 	 */
+	{"3PARdata", "VV", NULL, BLIST_REPORTLUN2},
 	{"ADAPTEC", "AACRAID", NULL, BLIST_FORCELUN},
 	{"ADAPTEC", "Adaptec 5400S", NULL, BLIST_FORCELUN},
 	{"AFT PRO", "-IX CF", "0.0>", BLIST_FORCELUN},
-	{"BELKIN", "USB 2 HS-CF", "1.95",  BLIST_FORCELUN},
+	{"BELKIN", "USB 2 HS-CF", "1.95",  BLIST_FORCELUN | BLIST_INQUIRY_36},
 	{"CANON", "IPUBJD", NULL, BLIST_SPARSELUN},
-	{"CBOX3", "USB Storage-SMC", "300A", BLIST_FORCELUN},
+	{"CBOX3", "USB Storage-SMC", "300A", BLIST_FORCELUN | BLIST_INQUIRY_36},
 	{"CMD", "CRA-7280", NULL, BLIST_SPARSELUN},	/* CMD RAID Controller */
 	{"CNSI", "G7324", NULL, BLIST_SPARSELUN},	/* Chaparral G7324 RAID */
 	{"CNSi", "G8324", NULL, BLIST_SPARSELUN},	/* Chaparral G8324 RAID */
@@ -142,9 +145,9 @@
 	{"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN},
 	{"EMULEX", "MD21/S2     ESDI", NULL, BLIST_SINGLELUN},
 	{"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{"Generic", "USB SD Reader", "1.00", BLIST_FORCELUN},
-	{"Generic", "USB Storage-SMC", "0180", BLIST_FORCELUN},
-	{"Generic", "USB Storage-SMC", "0207", BLIST_FORCELUN},
+	{"Generic", "USB SD Reader", "1.00", BLIST_FORCELUN | BLIST_INQUIRY_36},
+	{"Generic", "USB Storage-SMC", "0180", BLIST_FORCELUN | BLIST_INQUIRY_36},
+	{"Generic", "USB Storage-SMC", "0207", BLIST_FORCELUN | BLIST_INQUIRY_36},
 	{"HITACHI", "DF400", "*", BLIST_SPARSELUN},
 	{"HITACHI", "DF500", "*", BLIST_SPARSELUN},
 	{"HITACHI", "DF600", "*", BLIST_SPARSELUN},
@@ -153,6 +156,7 @@
 	{"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
 	{"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
 	{"HP", "C1557A", NULL, BLIST_FORCELUN},
+	{"HP", "C3323-300", "4269", BLIST_NOTQ},
 	{"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN},
 	{"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
 	{"iomega", "jaz 1GB", "J.86", BLIST_NOTQ | BLIST_NOLUN},
@@ -179,10 +183,13 @@
 	{"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
 	{"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
 	{"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN},
+	{"SEAGATE", "ST34555N", "0930", BLIST_NOTQ},	/* Chokes on tagged INQUIRY */
+	{"SEAGATE", "ST3390N", "9546", BLIST_NOTQ},
 	{"SGI", "RAID3", "*", BLIST_SPARSELUN},
 	{"SGI", "RAID5", "*", BLIST_SPARSELUN},
 	{"SGI", "TP9100", "*", BLIST_REPORTLUN2},
-	{"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN},
+	{"SGI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
+	{"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36},
 	{"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN},
 	{"SONY", "TSL", NULL, BLIST_FORCELUN},		/* DDS3 & DDS4 autoloaders */
 	{"SUN", "T300", "*", BLIST_SPARSELUN},
@@ -190,7 +197,10 @@
 	{"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN},
 	{"TOSHIBA", "CDROM", NULL, BLIST_ISROM},
 	{"TOSHIBA", "CD-ROM", NULL, BLIST_ISROM},
-	{"USB2.0", "SMARTMEDIA/XD", NULL, BLIST_FORCELUN},
+	{"USB2.0", "SMARTMEDIA/XD", NULL, BLIST_FORCELUN | BLIST_INQUIRY_36},
+	{"WangDAT", "Model 2600", "01.7", BLIST_SELECT_NO_ATN},
+	{"WangDAT", "Model 3200", "02.2", BLIST_SELECT_NO_ATN},
+	{"WangDAT", "Model 1300", "02.4", BLIST_SELECT_NO_ATN},
 	{"XYRATEX", "RS", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
 	{"Zzyzx", "RocketStor 500S", NULL, BLIST_SPARSELUN},
 	{"Zzyzx", "RocketStor 2000", NULL, BLIST_SPARSELUN},
@@ -510,7 +520,7 @@
  * 	Add command line @dev_list entries, then add
  * 	scsi_static_device_list entries to the scsi device info list.
  **/
-int scsi_init_devinfo(void)
+int __init scsi_init_devinfo(void)
 {
 #ifdef CONFIG_SCSI_PROC_FS
 	struct proc_dir_entry *p;
diff -Nru a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
--- a/drivers/scsi/scsi_error.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/scsi_error.c	2004-12-24 13:36:16 -08:00
@@ -1843,3 +1843,79 @@
 	scsi_next_command(scmd);
 	return rtn;
 }
+
+/**
+ * scsi_normalize_sense - normalize main elements from either fixed or
+ *			descriptor sense data format into a common format.
+ *
+ * @sense_buffer:	byte array containing sense data returned by device
+ * @sb_len:		number of valid bytes in sense_buffer
+ * @sshdr:		pointer to instance of structure that common
+ *			elements are written to.
+ *
+ * Notes:
+ *	The "main elements" from sense data are: response_code, sense_key,
+ *	asc, ascq and additional_length (only for descriptor format).
+ *
+ *	Typically this function can be called after a device has
+ *	responded to a SCSI command with the CHECK_CONDITION status.
+ *
+ * Return value:
+ *	1 if valid sense data information found, else 0;
+ **/
+int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
+                         struct scsi_sense_hdr *sshdr)
+{
+	if (!sense_buffer || !sb_len || (sense_buffer[0] & 0x70) != 0x70)
+		return 0;
+
+	memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
+
+	sshdr->response_code = (sense_buffer[0] & 0x7f);
+	if (sshdr->response_code >= 0x72) {
+		/*
+		 * descriptor format
+		 */
+		if (sb_len > 1)
+			sshdr->sense_key = (sense_buffer[1] & 0xf);
+		if (sb_len > 2)
+			sshdr->asc = sense_buffer[2];
+		if (sb_len > 3)
+			sshdr->ascq = sense_buffer[3];
+		if (sb_len > 7)
+			sshdr->additional_length = sense_buffer[7];
+	} else {
+		/* 
+		 * fixed format
+		 */
+		if (sb_len > 2)
+			sshdr->sense_key = (sense_buffer[2] & 0xf);
+		if (sb_len > 7) {
+			sb_len = (sb_len < (sense_buffer[7] + 8)) ?
+					 sb_len : (sense_buffer[7] + 8);
+			if (sb_len > 12)
+				sshdr->asc = sense_buffer[12];
+			if (sb_len > 13)
+				sshdr->ascq = sense_buffer[13];
+		}
+	}
+
+	return 1;
+}
+EXPORT_SYMBOL(scsi_normalize_sense);
+
+int scsi_request_normalize_sense(struct scsi_request *sreq,
+				 struct scsi_sense_hdr *sshdr)
+{
+	return scsi_normalize_sense(sreq->sr_sense_buffer,
+			sizeof(sreq->sr_sense_buffer), sshdr);
+}
+EXPORT_SYMBOL(scsi_request_normalize_sense);
+
+int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
+				 struct scsi_sense_hdr *sshdr)
+{
+	return scsi_normalize_sense(cmd->sense_buffer,
+			sizeof(cmd->sense_buffer), sshdr);
+}
+EXPORT_SYMBOL(scsi_command_normalize_sense);
diff -Nru a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
--- a/drivers/scsi/scsi_ioctl.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/scsi/scsi_ioctl.c	2004-12-24 13:37:29 -08:00
@@ -20,6 +20,7 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_ioctl.h>
 #include <scsi/scsi_request.h>
+#include <scsi/sg.h>
 
 #include "scsi_logging.h"
 
@@ -456,3 +457,51 @@
 	}
 	return -EINVAL;
 }
+
+/*
+ * the scsi_nonblock_ioctl() function is designed for ioctls which may
+ * be executed even if the device is in recovery.
+ */
+int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd,
+			    void __user *arg, struct file *filp)
+{
+	int val, result;
+
+	/* The first set of iocts may be executed even if we're doing
+	 * error processing, as long as the device was opened
+	 * non-blocking */
+	if (filp && filp->f_flags & O_NONBLOCK) {
+		if (test_bit(SHOST_RECOVERY,
+			     &sdev->host->shost_state))
+			return -ENODEV;
+	} else if (!scsi_block_when_processing_errors(sdev))
+		return -ENODEV;
+
+	switch (cmd) {
+	case SG_SCSI_RESET:
+		result = get_user(val, (int __user *)arg);
+		if (result)
+			return result;
+		if (val == SG_SCSI_RESET_NOTHING)
+			return 0;
+		switch (val) {
+		case SG_SCSI_RESET_DEVICE:
+			val = SCSI_TRY_RESET_DEVICE;
+			break;
+		case SG_SCSI_RESET_BUS:
+			val = SCSI_TRY_RESET_BUS;
+			break;
+		case SG_SCSI_RESET_HOST:
+			val = SCSI_TRY_RESET_HOST;
+			break;
+		default:
+			return -EINVAL;
+		}
+		if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
+			return -EACCES;
+		return (scsi_reset_provider(sdev, val) ==
+			SUCCESS) ? 0 : -EIO;
+	}
+	return -ENODEV;
+}
+EXPORT_SYMBOL(scsi_nonblockable_ioctl);
diff -Nru a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
--- a/drivers/scsi/scsi_lib.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/scsi/scsi_lib.c	2004-12-24 13:36:49 -08:00
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/delay.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_dbg.h>
@@ -365,7 +366,7 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(shost->host_lock, flags);
-	current_sdev->sdev_target->starget_sdev_user = NULL;
+	scsi_target(current_sdev)->starget_sdev_user = NULL;
 	spin_unlock_irqrestore(shost->host_lock, flags);
 
 	/*
@@ -377,7 +378,7 @@
 	blk_run_queue(current_sdev->request_queue);
 
 	spin_lock_irqsave(shost->host_lock, flags);
-	if (current_sdev->sdev_target->starget_sdev_user)
+	if (scsi_target(current_sdev)->starget_sdev_user)
 		goto out;
 	list_for_each_entry_safe(sdev, tmp, &current_sdev->same_target_siblings,
 			same_target_siblings) {
@@ -692,6 +693,7 @@
 	request_queue_t *q = cmd->device->request_queue;
 	struct request *req = cmd->request;
 	int clear_errors = 1;
+	struct scsi_sense_hdr sshdr;
 
 	/*
 	 * Free up any indirection buffers we allocated for DMA purposes. 
@@ -711,11 +713,13 @@
 	}
 
 	if (blk_pc_request(req)) { /* SG_IO ioctl from block level */
-		req->errors = (driver_byte(result) & DRIVER_SENSE) ?
-			      (CHECK_CONDITION << 1) : (result & 0xff);
+		req->errors = result;
 		if (result) {
 			clear_errors = 0;
-			if (cmd->sense_buffer[0] & 0x70) {
+			if (scsi_command_normalize_sense(cmd, &sshdr)) {
+				/*
+				 * SG_IO wants to know about deferred errors
+				 */
 				int len = 8 + cmd->sense_buffer[7];
 
 				if (len > SCSI_SENSE_BUFFERSIZE)
@@ -724,7 +728,7 @@
 				req->sense_len = len;
 			}
 		} else
-			req->data_len -= cmd->bufflen;
+			req->data_len = cmd->resid;
 	}
 
 	/*
@@ -774,17 +778,17 @@
 	 * can choose a block to remap, etc.
 	 */
 	if (driver_byte(result) != 0) {
-		if ((cmd->sense_buffer[0] & 0x7f) == 0x70) {
+		if (scsi_command_normalize_sense(cmd, &sshdr) &&
+				!scsi_sense_is_deferred(&sshdr)) {
 			/*
 			 * If the device is in the process of becoming ready,
 			 * retry.
 			 */
-			if (cmd->sense_buffer[12] == 0x04 &&
-			    cmd->sense_buffer[13] == 0x01) {
+			if (sshdr.asc == 0x04 && sshdr.ascq == 0x01) {
 				scsi_requeue_command(q, cmd);
 				return;
 			}
-			if ((cmd->sense_buffer[2] & 0xf) == UNIT_ATTENTION) {
+			if (sshdr.sense_key == UNIT_ATTENTION) {
 				if (cmd->device->removable) {
 					/* detected disc change.  set a bit 
 					 * and quietly refuse further access.
@@ -813,7 +817,11 @@
 		 * failed, we may have read past the end of the disk.
 		 */
 
-		switch (cmd->sense_buffer[2]) {
+		/*
+		 * XXX: Following is probably broken since deferred errors
+		 *	fall through [dpg 20040827]
+		 */
+		switch (sshdr.sense_key) {
 		case ILLEGAL_REQUEST:
 			if (cmd->device->use_10_for_rw &&
 			    (cmd->cmnd[0] == READ_10 ||
@@ -835,8 +843,6 @@
 			       req->rq_disk ? req->rq_disk->disk_name : "");
 			cmd = scsi_end_request(cmd, 0, this_count, 1);
 			return;
-			break;
-		case MEDIUM_ERROR:
 		case VOLUME_OVERFLOW:
 			printk("scsi%d: ERROR on channel %d, id %d, lun %d, CDB: ",
 			       cmd->device->host->host_no, (int) cmd->device->channel,
@@ -1024,7 +1030,8 @@
 	} else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) {
 
 		if(unlikely(specials_only)) {
-			if(specials_only == SDEV_QUIESCE)
+			if(specials_only == SDEV_QUIESCE ||
+					specials_only == SDEV_BLOCK)
 				return BLKPREP_DEFER;
 			
 			printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to device being removed\n",
@@ -1247,10 +1254,10 @@
 		if (!scsi_host_queue_ready(q, shost, sdev))
 			goto not_ready;
 		if (sdev->single_lun) {
-			if (sdev->sdev_target->starget_sdev_user &&
-			    sdev->sdev_target->starget_sdev_user != sdev)
+			if (scsi_target(sdev)->starget_sdev_user &&
+			    scsi_target(sdev)->starget_sdev_user != sdev)
 				goto not_ready;
-			sdev->sdev_target->starget_sdev_user = sdev;
+			scsi_target(sdev)->starget_sdev_user = sdev;
 		}
 		shost->host_busy++;
 
@@ -1320,19 +1327,22 @@
 u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
 {
 	struct device *host_dev;
+	u64 bounce_limit = 0xffffffff;
 
 	if (shost->unchecked_isa_dma)
 		return BLK_BOUNCE_ISA;
-
-	host_dev = scsi_get_device(shost);
-	if (PCI_DMA_BUS_IS_PHYS && host_dev && host_dev->dma_mask)
-		return *host_dev->dma_mask;
-
 	/*
 	 * Platforms with virtual-DMA translation
 	 * hardware have no practical limit.
 	 */
-	return BLK_BOUNCE_ANY;
+	if (!PCI_DMA_BUS_IS_PHYS)
+		return BLK_BOUNCE_ANY;
+
+	host_dev = scsi_get_device(shost);
+	if (host_dev && host_dev->dma_mask)
+		bounce_limit = *host_dev->dma_mask;
+
+	return bounce_limit;
 }
 
 struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
@@ -1496,8 +1506,7 @@
 	}
 
 	sreq->sr_cmd_len = 0;
-	sreq->sr_sense_buffer[0] = 0;
-	sreq->sr_sense_buffer[2] = 0;
+	memset(sreq->sr_sense_buffer, 0, sizeof(sreq->sr_sense_buffer));
 	sreq->sr_data_direction = DMA_FROM_DEVICE;
 
 	memset(buffer, 0, len);
@@ -1508,14 +1517,21 @@
 	 * ILLEGAL REQUEST sense return identifies the actual command
 	 * byte as the problem.  MODE_SENSE commands can return
 	 * ILLEGAL REQUEST if the code page isn't supported */
-	if (use_10_for_ms && ! scsi_status_is_good(sreq->sr_result) &&
-	    (driver_byte(sreq->sr_result) & DRIVER_SENSE) &&
-	    sreq->sr_sense_buffer[2] == ILLEGAL_REQUEST &&
-	    (sreq->sr_sense_buffer[4] & 0x40) == 0x40 &&
-	    sreq->sr_sense_buffer[5] == 0 &&
-	    sreq->sr_sense_buffer[6] == 0 ) {
-		sreq->sr_device->use_10_for_ms = 0;
-		goto retry;
+
+	if (use_10_for_ms && !scsi_status_is_good(sreq->sr_result) &&
+	    (driver_byte(sreq->sr_result) & DRIVER_SENSE)) {
+		struct scsi_sense_hdr sshdr;
+
+		if (scsi_request_normalize_sense(sreq, &sshdr)) {
+			if ((sshdr.sense_key == ILLEGAL_REQUEST) &&
+			    (sshdr.asc == 0x20) && (sshdr.ascq == 0)) {
+				/* 
+				 * Invalid command operation code
+				 */
+				sreq->sr_device->use_10_for_ms = 0;
+				goto retry;
+			}
+		}
 	}
 
 	if(scsi_status_is_good(sreq->sr_result)) {
@@ -1585,11 +1601,12 @@
 	if (!sreq)
 		return -ENOMEM;
 
-		sreq->sr_data_direction = DMA_NONE;
-        scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
+	sreq->sr_data_direction = DMA_NONE;
+	scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
 
 	if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) &&
-	    (sreq->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION &&
+	    ((sreq->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION ||
+	     (sreq->sr_sense_buffer[2] & 0x0f) == NOT_READY) &&
 	    sdev->removable) {
 		sdev->changed = 1;
 		sreq->sr_result = 0;
@@ -1629,6 +1646,7 @@
 		case SDEV_CREATED:
 		case SDEV_OFFLINE:
 		case SDEV_QUIESCE:
+		case SDEV_BLOCK:
 			break;
 		default:
 			goto illegal;
@@ -1656,11 +1674,22 @@
 		}
 		break;
 
+	case SDEV_BLOCK:
+		switch (oldstate) {
+		case SDEV_CREATED:
+		case SDEV_RUNNING:
+			break;
+		default:
+			goto illegal;
+		}
+		break;
+
 	case SDEV_CANCEL:
 		switch (oldstate) {
 		case SDEV_CREATED:
 		case SDEV_RUNNING:
 		case SDEV_OFFLINE:
+		case SDEV_BLOCK:
 			break;
 		default:
 			goto illegal;
@@ -1714,7 +1743,7 @@
 
 	scsi_run_queue(sdev->request_queue);
 	while (sdev->device_busy) {
-		schedule_timeout(HZ/5);
+		msleep_interruptible(200);
 		scsi_run_queue(sdev->request_queue);
 	}
 	return 0;
@@ -1739,3 +1768,111 @@
 }
 EXPORT_SYMBOL(scsi_device_resume);
 
+static int
+device_quiesce_fn(struct device *dev, void *data)
+{
+	scsi_device_quiesce(to_scsi_device(dev));
+	return 0;
+}
+
+void
+scsi_target_quiesce(struct scsi_target *starget)
+{
+	device_for_each_child(&starget->dev, NULL, device_quiesce_fn);
+}
+EXPORT_SYMBOL(scsi_target_quiesce);
+
+static int
+device_resume_fn(struct device *dev, void *data)
+{
+	scsi_device_resume(to_scsi_device(dev));
+	return 0;
+}
+
+void
+scsi_target_resume(struct scsi_target *starget)
+{
+	device_for_each_child(&starget->dev, NULL, device_resume_fn);
+}
+EXPORT_SYMBOL(scsi_target_resume);
+
+/**
+ * scsi_internal_device_block - internal function to put a device
+ *				temporarily into the SDEV_BLOCK state
+ * @sdev:	device to block
+ *
+ * Block request made by scsi lld's to temporarily stop all
+ * scsi commands on the specified device.  Called from interrupt
+ * or normal process context.
+ *
+ * Returns zero if successful or error if not
+ *
+ * Notes:       
+ *	This routine transitions the device to the SDEV_BLOCK state
+ *	(which must be a legal transition).  When the device is in this
+ *	state, all commands are deferred until the scsi lld reenables
+ *	the device with scsi_device_unblock or device_block_tmo fires.
+ *	This routine assumes the host_lock is held on entry.
+ **/
+int
+scsi_internal_device_block(struct scsi_device *sdev)
+{
+	request_queue_t *q = sdev->request_queue;
+	unsigned long flags;
+	int err = 0;
+
+	err = scsi_device_set_state(sdev, SDEV_BLOCK);
+	if (err)
+		return err;
+
+	/* 
+	 * The device has transitioned to SDEV_BLOCK.  Stop the
+	 * block layer from calling the midlayer with this device's
+	 * request queue. 
+	 */
+	spin_lock_irqsave(q->queue_lock, flags);
+	blk_stop_queue(q);
+	spin_unlock_irqrestore(q->queue_lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(scsi_internal_device_block);
+ 
+/**
+ * scsi_internal_device_unblock - resume a device after a block request
+ * @sdev:	device to resume
+ *
+ * Called by scsi lld's or the midlayer to restart the device queue
+ * for the previously suspended scsi device.  Called from interrupt or
+ * normal process context.
+ *
+ * Returns zero if successful or error if not.
+ *
+ * Notes:       
+ *	This routine transitions the device to the SDEV_RUNNING state
+ *	(which must be a legal transition) allowing the midlayer to
+ *	goose the queue for this device.  This routine assumes the 
+ *	host_lock is held upon entry.
+ **/
+int
+scsi_internal_device_unblock(struct scsi_device *sdev)
+{
+	request_queue_t *q = sdev->request_queue; 
+	int err;
+	unsigned long flags;
+	
+	/* 
+	 * Try to transition the scsi device to SDEV_RUNNING
+	 * and goose the device queue if successful.  
+	 */
+	err = scsi_device_set_state(sdev, SDEV_RUNNING);
+	if (err)
+		return err;
+
+	spin_lock_irqsave(q->queue_lock, flags);
+	blk_start_queue(q);
+	spin_unlock_irqrestore(q->queue_lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(scsi_internal_device_unblock);
diff -Nru a/drivers/scsi/scsi_module.c b/drivers/scsi/scsi_module.c
--- a/drivers/scsi/scsi_module.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/scsi_module.c	2004-12-24 13:36:31 -08:00
@@ -11,7 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 
 
diff -Nru a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
--- a/drivers/scsi/scsi_priv.h	2004-12-24 13:37:02 -08:00
+++ b/drivers/scsi/scsi_priv.h	2004-12-24 13:37:02 -08:00
@@ -58,16 +58,6 @@
  */
 #define SCAN_WILD_CARD	~0
 
-/*
- * scsi_target: representation of a scsi target, for now, this is only
- * used for single_lun devices. If no one has active IO to the target,
- * starget_sdev_user is NULL, else it points to the active sdev.
- */
-struct scsi_target {
-	struct scsi_device	*starget_sdev_user;
-	unsigned int		starget_refcnt;
-};
-
 /* hosts.c */
 extern int scsi_init_hosts(void);
 extern void scsi_exit_hosts(void);
@@ -96,7 +86,7 @@
 /* scsi_devinfo.c */
 extern int scsi_get_device_flags(struct scsi_device *sdev,
 				 unsigned char *vendor, unsigned char *model);
-extern int scsi_init_devinfo(void);
+extern int __init scsi_init_devinfo(void);
 extern void scsi_exit_devinfo(void);
 
 /* scsi_error.c */
@@ -156,9 +146,20 @@
 extern int scsi_sysfs_add_host(struct Scsi_Host *);
 extern int scsi_sysfs_register(void);
 extern void scsi_sysfs_unregister(void);
+extern int scsi_sysfs_device_initialize(struct scsi_device *);
+extern int scsi_sysfs_target_initialize(struct scsi_device *);
 extern struct scsi_transport_template blank_transport_template;
 
 extern struct class sdev_class;
 extern struct bus_type scsi_bus_type;
+
+/* 
+ * internal scsi timeout functions: for use by mid-layer and transport
+ * classes.
+ */
+
+#define SCSI_DEVICE_BLOCK_MAX_TIMEOUT	(HZ*60)
+extern int scsi_internal_device_block(struct scsi_device *sdev);
+extern int scsi_internal_device_unblock(struct scsi_device *sdev);
 
 #endif /* _SCSI_PRIV_H */
diff -Nru a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/scsi_scan.c	2004-12-24 13:37:18 -08:00
@@ -202,10 +202,12 @@
 static struct scsi_device *scsi_alloc_sdev(struct Scsi_Host *shost,
 	       	uint channel, uint id, uint lun, void *hostdata)
 {
-	struct scsi_device *sdev, *device;
+	struct scsi_device *sdev;
 	unsigned long flags;
+	int display_failure_msg = 1, ret;
 
-	sdev = kmalloc(sizeof(*sdev) + shost->transportt->size, GFP_ATOMIC);
+	sdev = kmalloc(sizeof(*sdev) + shost->transportt->device_size,
+		       GFP_ATOMIC);
 	if (!sdev)
 		goto out;
 
@@ -252,71 +254,39 @@
 	scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
 
 	if (shost->hostt->slave_alloc) {
-		if (shost->hostt->slave_alloc(sdev))
+		ret = shost->hostt->slave_alloc(sdev);
+		if (ret) {
+			/*
+			 * if LLDD reports slave not present, don't clutter
+			 * console with alloc failure messages
+			 */
+			if (ret == -ENXIO)
+				display_failure_msg = 0;
 			goto out_free_queue;
+		}
 	}
 
-	if (shost->transportt->setup) {
-		if (shost->transportt->setup(sdev))
+	if (shost->transportt->device_setup) {
+		if (shost->transportt->device_setup(sdev))
 			goto out_cleanup_slave;
 	}
 
-	if (get_device(&sdev->host->shost_gendev)) {
+	if (scsi_sysfs_device_initialize(sdev) != 0)
+		goto out_cleanup_slave;
 
-		device_initialize(&sdev->sdev_gendev);
-		sdev->sdev_gendev.parent = &sdev->host->shost_gendev;
-		sdev->sdev_gendev.bus = &scsi_bus_type;
-		sdev->sdev_gendev.release = scsi_device_dev_release;
-		sprintf(sdev->sdev_gendev.bus_id,"%d:%d:%d:%d",
-			sdev->host->host_no, sdev->channel, sdev->id,
-			sdev->lun);
-
-		class_device_initialize(&sdev->sdev_classdev);
-		sdev->sdev_classdev.dev = &sdev->sdev_gendev;
-		sdev->sdev_classdev.class = &sdev_class;
-		snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE,
-			 "%d:%d:%d:%d", sdev->host->host_no,
-			 sdev->channel, sdev->id, sdev->lun);
-
-		class_device_initialize(&sdev->transport_classdev);
-		sdev->transport_classdev.dev = &sdev->sdev_gendev;
-		sdev->transport_classdev.class = sdev->host->transportt->class;
-		snprintf(sdev->transport_classdev.class_id, BUS_ID_SIZE,
-			 "%d:%d:%d:%d", sdev->host->host_no,
-			 sdev->channel, sdev->id, sdev->lun);
-	} else
-		goto out_cleanup_transport;
-
-	/*
-	 * If there are any same target siblings, add this to the
-	 * sibling list
-	 */
-	spin_lock_irqsave(shost->host_lock, flags);
-	list_for_each_entry(device, &shost->__devices, siblings) {
-		if (device->id == sdev->id &&
-		    device->channel == sdev->channel) {
-			list_add_tail(&sdev->same_target_siblings,
-				      &device->same_target_siblings);
-			sdev->scsi_level = device->scsi_level;
-			break;
-		}
-	}
 
-	/*
-	 * If there wasn't another lun already configured at this
-	 * target, then default this device to SCSI_2 until we
-	 * know better
-	 */
-	if (!sdev->scsi_level)
-		sdev->scsi_level = SCSI_2;
+	/* NOTE: this target initialisation code depends critically on
+	 * lun scanning being sequential. */
+	if (scsi_sysfs_target_initialize(sdev))
+		goto out_remove_siblings;
 
-	list_add_tail(&sdev->siblings, &shost->__devices);
-	spin_unlock_irqrestore(shost->host_lock, flags);
 	return sdev;
 
-out_cleanup_transport:
-	if (shost->transportt->cleanup)
-		shost->transportt->cleanup(sdev);
+out_remove_siblings:
+	spin_lock_irqsave(shost->host_lock, flags);
+	list_del(&sdev->siblings);
+	list_del(&sdev->same_target_siblings);
+	spin_unlock_irqrestore(shost->host_lock, flags);
 out_cleanup_slave:
 	if (shost->hostt->slave_destroy)
 		shost->hostt->slave_destroy(sdev);
@@ -325,7 +295,8 @@
 out_free_dev:
 	kfree(sdev);
 out:
-	printk(ALLOC_FAILURE_MSG, __FUNCTION__);
+	if (display_failure_msg)
+		printk(ALLOC_FAILURE_MSG, __FUNCTION__);
 	return NULL;
 }
 
@@ -348,104 +319,113 @@
 {
 	struct scsi_device *sdev = sreq->sr_device;	/* a bit ugly */
 	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
-	int possible_inq_resp_len;
-	int count = 0;
+	int first_inquiry_len, try_inquiry_len, next_inquiry_len;
+	int response_len = 0;
+	int pass, count;
 
 	*bflags = 0;
- repeat_inquiry:
-	SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY to host %d"
-			" channel %d id %d lun %d\n", sdev->host->host_no,
-			sdev->channel, sdev->id, sdev->lun));
-
-	memset(scsi_cmd, 0, 6);
-	scsi_cmd[0] = INQUIRY;
-	scsi_cmd[4] = 36;	/* issue conservative alloc_length */
-	sreq->sr_cmd_len = 0;
-	sreq->sr_data_direction = DMA_FROM_DEVICE;
 
-	memset(inq_result, 0, 36);
-	scsi_wait_req(sreq, (void *) scsi_cmd, (void *) inq_result, 36,
-		      HZ/2 + HZ*scsi_inq_timeout, 3);
-
-	SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: 1st INQUIRY %s with"
-			" code 0x%x\n", sreq->sr_result ?
-			"failed" : "successful", sreq->sr_result));
-	++count;
+	/* Perform up to 3 passes.  The first pass uses a conservative
+	 * transfer length of 36 unless sdev->inquiry_len specifies a
+	 * different value. */
+	first_inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;
+	try_inquiry_len = first_inquiry_len;
+	pass = 1;
+
+ next_pass:
+	SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY pass %d "
+			"to host %d channel %d id %d lun %d, length %d\n",
+			pass, sdev->host->host_no, sdev->channel,
+			sdev->id, sdev->lun, try_inquiry_len));
+
+	/* Each pass gets up to three chances to ignore Unit Attention */
+	for (count = 0; count < 3; ++count) {
+		memset(scsi_cmd, 0, 6);
+		scsi_cmd[0] = INQUIRY;
+		scsi_cmd[4] = (unsigned char) try_inquiry_len;
+		sreq->sr_cmd_len = 0;
+		sreq->sr_data_direction = DMA_FROM_DEVICE;
+
+		memset(inq_result, 0, try_inquiry_len);
+		scsi_wait_req(sreq, (void *) scsi_cmd, (void *) inq_result,
+				try_inquiry_len,
+				HZ/2 + HZ*scsi_inq_timeout, 3);
+
+		SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY %s "
+				"with code 0x%x\n",
+				sreq->sr_result ? "failed" : "successful",
+				sreq->sr_result));
+
+		if (sreq->sr_result) {
 
-	if (sreq->sr_result) {
-		if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) != 0 &&
-		    (sreq->sr_sense_buffer[2] & 0xf) == UNIT_ATTENTION &&
-		    (sreq->sr_sense_buffer[12] == 0x28 ||
-		     sreq->sr_sense_buffer[12] == 0x29) &&
-		    sreq->sr_sense_buffer[13] == 0) {
 			/* not-ready to ready transition or power-on - good */
 			/* dpg: bogus? INQUIRY never returns UNIT_ATTENTION */
-			/* Supposedly, but many buggy devices do so anyway */
-			if (count < 3)
-				goto repeat_inquiry;
+			/* Supposedly, but many buggy devices do so anyway. */
+			if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) &&
+					(sreq->sr_sense_buffer[2] & 0xf) ==
+						UNIT_ATTENTION &&
+					(sreq->sr_sense_buffer[12] == 0x28 ||
+					 sreq->sr_sense_buffer[12] == 0x29) &&
+					sreq->sr_sense_buffer[13] == 0)
+				continue;
 		}
-		/*
-		 * assume no peripheral if any other sort of error
-		 */
-		return;
+		break;
 	}
 
-	/*
-	 * Get any flags for this device.
-	 *
-	 * XXX add a bflags to Scsi_Device, and replace the corresponding
-	 * bit fields in Scsi_Device, so bflags need not be passed as an
-	 * argument.
-	 */
-	*bflags |= scsi_get_device_flags(sdev, &inq_result[8], &inq_result[16]);
-
-	possible_inq_resp_len = (unsigned char) inq_result[4] + 5;
-	if (BLIST_INQUIRY_36 & *bflags)
-		possible_inq_resp_len = 36;
-	else if (BLIST_INQUIRY_58 & *bflags)
-		possible_inq_resp_len = 58;
-	else if (possible_inq_resp_len > 255)
-		possible_inq_resp_len = 36;	/* sanity */
+	if (sreq->sr_result == 0) {
+		response_len = (unsigned char) inq_result[4] + 5;
+		if (response_len > 255)
+			response_len = first_inquiry_len;	/* sanity */
 
-	if (possible_inq_resp_len > 36) {	/* do additional INQUIRY */
-		memset(scsi_cmd, 0, 6);
-		scsi_cmd[0] = INQUIRY;
-		scsi_cmd[4] = (unsigned char) possible_inq_resp_len;
-		sreq->sr_cmd_len = 0;
-		sreq->sr_data_direction = DMA_FROM_DEVICE;
 		/*
-		 * re-zero inq_result just to be safe.
+		 * Get any flags for this device.
+		 *
+		 * XXX add a bflags to Scsi_Device, and replace the
+		 * corresponding bit fields in Scsi_Device, so bflags
+		 * need not be passed as an argument.
 		 */
-		memset(inq_result, 0, possible_inq_resp_len);
-		scsi_wait_req(sreq, (void *) scsi_cmd,
-			      (void *) inq_result,
-			      possible_inq_resp_len, (1+scsi_inq_timeout)*(HZ/2), 3);
-		SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: 2nd INQUIRY"
-				" %s with code 0x%x\n", sreq->sr_result ?
-				"failed" : "successful", sreq->sr_result));
-		if (sreq->sr_result) {
-			/* if the longer inquiry has failed, flag the device
-			 * as only accepting 36 byte inquiries and retry the
-			 * 36 byte inquiry */
-			printk(KERN_INFO "scsi scan: %d byte inquiry failed"
-			       " with code %d.  Consider BLIST_INQUIRY_36 for"
-			       " this device\n", possible_inq_resp_len,
-			       sreq->sr_result);
-			*bflags = BLIST_INQUIRY_36;
-			goto repeat_inquiry;
+		*bflags = scsi_get_device_flags(sdev, &inq_result[8],
+				&inq_result[16]);
+
+		/* When the first pass succeeds we gain information about
+		 * what larger transfer lengths might work. */
+		if (pass == 1) {
+			if (BLIST_INQUIRY_36 & *bflags)
+				next_inquiry_len = 36;
+			else if (BLIST_INQUIRY_58 & *bflags)
+				next_inquiry_len = 58;
+			else if (sdev->inquiry_len)
+				next_inquiry_len = sdev->inquiry_len;
+			else
+				next_inquiry_len = response_len;
+
+			/* If more data is available perform the second pass */
+			if (next_inquiry_len > try_inquiry_len) {
+				try_inquiry_len = next_inquiry_len;
+				pass = 2;
+				goto next_pass;
+			}
 		}
 
-		/*
-		 * The INQUIRY can change, this means the length can change.
-		 */
-		possible_inq_resp_len = (unsigned char) inq_result[4] + 5;
-		if (BLIST_INQUIRY_58 & *bflags)
-			possible_inq_resp_len = 58;
-		else if (possible_inq_resp_len > 255)
-			possible_inq_resp_len = 36;	/* sanity */
+	} else if (pass == 2) {
+		printk(KERN_INFO "scsi scan: %d byte inquiry failed.  "
+				"Consider BLIST_INQUIRY_36 for this device\n",
+				try_inquiry_len);
+
+		/* If this pass failed, the third pass goes back and transfers
+		 * the same amount as we successfully got in the first pass. */
+		try_inquiry_len = first_inquiry_len;
+		pass = 3;
+		goto next_pass;
 	}
 
-	sdev->inquiry_len = possible_inq_resp_len;
+	/* If the last transfer attempt got an error, assume the
+	 * peripheral doesn't exist or is dead. */
+	if (sreq->sr_result)
+		return;
+
+	/* Don't report any more data than the device says is valid */
+	sdev->inquiry_len = min(try_inquiry_len, response_len);
 
 	/*
 	 * XXX Abort if the response length is less than 36? If less than
@@ -500,10 +480,6 @@
  **/
 static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
 {
-	struct scsi_device *sdev_sibling;
-	struct scsi_target *starget;
-	unsigned long flags;
-
 	/*
 	 * XXX do not save the inquiry, since it can change underneath us,
 	 * save just vendor/model/rev.
@@ -533,7 +509,8 @@
 		 */
 		inq_result[0] = TYPE_ROM;
 		inq_result[1] |= 0x80;	/* removable */
-	}
+	} else if (*bflags & BLIST_NO_ULD_ATTACH)
+		sdev->no_uld_attach = 1;
 
 	switch (sdev->type = (inq_result[0] & 0x1f)) {
 	case TYPE_TAPE:
@@ -606,46 +583,22 @@
 		sdev->borken = 0;
 
 	/*
+	 * Apparently some really broken devices (contrary to the SCSI
+	 * standards) need to be selected without asserting ATN
+	 */
+	if (*bflags & BLIST_SELECT_NO_ATN)
+		sdev->select_no_atn = 1;
+
+	/*
 	 * Some devices may not want to have a start command automatically
 	 * issued when a device is added.
 	 */
 	if (*bflags & BLIST_NOSTARTONADD)
 		sdev->no_start_on_add = 1;
 
-	/*
-	 * If we need to allow I/O to only one of the luns attached to
-	 * this target id at a time set single_lun, and allocate or modify
-	 * sdev_target.
-	 */
-	if (*bflags & BLIST_SINGLELUN) {
+	if (*bflags & BLIST_SINGLELUN)
 		sdev->single_lun = 1;
-		spin_lock_irqsave(sdev->host->host_lock, flags);
-		starget = NULL;
-		/*
-		 * Search for an existing target for this sdev.
-		 */
-		list_for_each_entry(sdev_sibling, &sdev->same_target_siblings,
-				    same_target_siblings) {
-			if (sdev_sibling->sdev_target != NULL) {
-				starget = sdev_sibling->sdev_target;
-				break;
-			}
-		}
-		if (!starget) {
-			starget = kmalloc(sizeof(*starget), GFP_ATOMIC);
-			if (!starget) {
-				printk(ALLOC_FAILURE_MSG, __FUNCTION__);
-				spin_unlock_irqrestore(sdev->host->host_lock,
-						       flags);
-				return SCSI_SCAN_NO_RESPONSE;
-			}
-			starget->starget_refcnt = 0;
-			starget->starget_sdev_user = NULL;
-		}
-		starget->starget_refcnt++;
-		sdev->sdev_target = starget;
-		spin_unlock_irqrestore(sdev->host->host_lock, flags);
-	}
+
 
 	sdev->use_10_for_rw = 1;
 
@@ -668,7 +621,10 @@
 	if (*bflags & BLIST_NOT_LOCKABLE)
 		sdev->lockable = 0;
 
-	if(sdev->host->hostt->slave_configure)
+	if (sdev->host->transportt->device_configure)
+		sdev->host->transportt->device_configure(sdev);
+
+	if (sdev->host->hostt->slave_configure)
 		sdev->host->hostt->slave_configure(sdev);
 
 	/*
@@ -785,8 +741,6 @@
 	} else {
 		if (sdev->host->hostt->slave_destroy)
 			sdev->host->hostt->slave_destroy(sdev);
-		if (sdev->host->transportt->cleanup)
-			sdev->host->transportt->cleanup(sdev);
 		put_device(&sdev->sdev_gendev);
 	}
  out:
@@ -1345,7 +1299,5 @@
 
 	if (sdev->host->hostt->slave_destroy)
 		sdev->host->hostt->slave_destroy(sdev);
-	if (sdev->host->transportt->cleanup)
-		sdev->host->transportt->cleanup(sdev);
 	put_device(&sdev->sdev_gendev);
 }
diff -Nru a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/scsi/scsi_sysfs.c	2004-12-24 13:36:30 -08:00
@@ -30,6 +30,7 @@
 	{ SDEV_DEL, "deleted" },
 	{ SDEV_QUIESCE, "quiesce" },
 	{ SDEV_OFFLINE,	"offline" },
+	{ SDEV_BLOCK,	"blocked" },
 };
 
 const char *scsi_device_state_name(enum scsi_device_state state)
@@ -153,25 +154,36 @@
 	struct scsi_device *sdev;
 	struct device *parent;
 	unsigned long flags;
+	int delete;
 
 	parent = dev->parent;
 	sdev = to_scsi_device(dev);
 
 	spin_lock_irqsave(sdev->host->host_lock, flags);
+	/* If we're the last LUN on the target, destroy the target */
+	delete = list_empty(&sdev->same_target_siblings);
 	list_del(&sdev->siblings);
 	list_del(&sdev->same_target_siblings);
 	list_del(&sdev->starved_entry);
-	if (sdev->single_lun && --sdev->sdev_target->starget_refcnt == 0)
-		kfree(sdev->sdev_target);
 	spin_unlock_irqrestore(sdev->host->host_lock, flags);
 
+	if (delete) {
+		struct scsi_target *starget = to_scsi_target(parent);
+		if (!starget->create) {
+			device_del(parent);
+			if (starget->transport_classdev.class)
+				class_device_unregister(&starget->transport_classdev);
+		}
+		put_device(parent);
+	}
 	if (sdev->request_queue)
 		scsi_free_queue(sdev->request_queue);
 
 	kfree(sdev->inquiry);
 	kfree(sdev);
 
-	put_device(parent);
+	if (parent)
+		put_device(parent);
 }
 
 struct class sdev_class = {
@@ -183,6 +195,8 @@
 static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
 {
 	struct scsi_device *sdp = to_scsi_device(dev);
+	if (sdp->no_uld_attach)
+		return 0;
 	return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
 }
 
@@ -430,6 +444,14 @@
 	return device_create_file(dev, attr);
 }
 
+static void scsi_target_dev_release(struct device *dev)
+{
+	struct scsi_target *starget = to_scsi_target(dev);
+	struct device *parent = dev->parent;
+	kfree(starget);
+	put_device(parent);
+}
+
 /**
  * scsi_sysfs_add_sdev - add scsi device to sysfs
  * @sdev:	scsi_device to add
@@ -440,13 +462,55 @@
 int scsi_sysfs_add_sdev(struct scsi_device *sdev)
 {
 	struct class_device_attribute **attrs;
-	int error, i;
+	struct scsi_target *starget = sdev->sdev_target;
+	struct Scsi_Host *shost = sdev->host;
+	int error, i, create;
+	unsigned long flags;
+
+	spin_lock_irqsave(shost->host_lock, flags);
+	create = starget->create;
+	starget->create = 0;
+	spin_unlock_irqrestore(shost->host_lock, flags);
+
+	if (create) {
+		error = device_add(&starget->dev);
+		if (error) {
+			printk(KERN_ERR "Target device_add failed\n");
+			return error;
+		}
+		if (starget->transport_classdev.class) {
+			int i;
+			struct class_device_attribute **attrs =
+				sdev->host->transportt->target_attrs;
+
+			error = class_device_add(&starget->transport_classdev);
+			if (error) {
+				dev_printk(KERN_ERR, &starget->dev,
+					   "Target transport add failed\n");
+				return error;
+			}
+
+			/* take a reference for the transport_classdev; this
+			 * is released by the transport_class .release */
+			get_device(&starget->dev);
+			for (i = 0; attrs[i]; i++) {
+				error = class_device_create_file(&starget->transport_classdev,
+								 attrs[i]);
+				if (error) {
+					dev_printk(KERN_ERR, &starget->dev,
+						   "Target transport attr add failed\n");
+					return error;
+				}
+			}
+		}
+	}
 
 	if ((error = scsi_device_set_state(sdev, SDEV_RUNNING)) != 0)
 		return error;
 
 	error = device_add(&sdev->sdev_gendev);
 	if (error) {
+		put_device(sdev->sdev_gendev.parent);
 		printk(KERN_INFO "error 1\n");
 		return error;
 	}
@@ -459,7 +523,6 @@
 	/* take a reference for the sdev_classdev; this is
 	 * released by the sdev_class .release */
 	get_device(&sdev->sdev_gendev);
-
 	if (sdev->transport_classdev.class) {
 		error = class_device_add(&sdev->transport_classdev);
 		if (error)
@@ -494,7 +557,7 @@
 	}
 
  	if (sdev->transport_classdev.class) {
- 		attrs = sdev->host->transportt->attrs;
+ 		attrs = sdev->host->transportt->device_attrs;
  		for (i = 0; attrs[i]; i++) {
  			error = class_device_create_file(&sdev->transport_classdev,
  							 attrs[i]);
@@ -538,8 +601,6 @@
 	scsi_device_set_state(sdev, SDEV_DEL);
 	if (sdev->host->hostt->slave_destroy)
 		sdev->host->hostt->slave_destroy(sdev);
-	if (sdev->host->transportt->cleanup)
-		sdev->host->transportt->cleanup(sdev);
 	put_device(&sdev->sdev_gendev);
 
 out:
@@ -626,6 +687,121 @@
 		}
 	}
 
+	class_device_initialize(&shost->transport_classdev);
+	shost->transport_classdev.class = shost->transportt->host_class;
+	shost->transport_classdev.dev = &shost->shost_gendev;
+	snprintf(shost->transport_classdev.class_id, BUS_ID_SIZE,
+		 "host%d", shost->host_no);
+
+	if (shost->transport_classdev.class) {
+		struct class_device_attribute **attrs =
+			shost->transportt->host_attrs;
+		error = class_device_add(&shost->transport_classdev);
+		if (error)
+			return error;
+		/* take a reference for the transport_classdev; this
+		 * is released by the transport_class .release */
+		get_device(&shost->shost_gendev);
+		for (i = 0; attrs[i]; i++) {
+ 			error = class_device_create_file(&shost->transport_classdev,
+ 							 attrs[i]);
+ 			if (error)
+				return error;
+ 		}
+ 	}
+
+	return 0;
+}
+
+int scsi_sysfs_device_initialize(struct scsi_device *sdev)
+{
+	device_initialize(&sdev->sdev_gendev);
+	sdev->sdev_gendev.bus = &scsi_bus_type;
+	sdev->sdev_gendev.release = scsi_device_dev_release;
+	sprintf(sdev->sdev_gendev.bus_id,"%d:%d:%d:%d",
+		sdev->host->host_no, sdev->channel, sdev->id,
+		sdev->lun);
+	
+	class_device_initialize(&sdev->sdev_classdev);
+	sdev->sdev_classdev.dev = &sdev->sdev_gendev;
+	sdev->sdev_classdev.class = &sdev_class;
+	snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE,
+		 "%d:%d:%d:%d", sdev->host->host_no,
+		 sdev->channel, sdev->id, sdev->lun);
+
+	class_device_initialize(&sdev->transport_classdev);
+	sdev->transport_classdev.dev = &sdev->sdev_gendev;
+	sdev->transport_classdev.class = sdev->host->transportt->device_class;
+	snprintf(sdev->transport_classdev.class_id, BUS_ID_SIZE,
+		 "%d:%d:%d:%d", sdev->host->host_no,
+		 sdev->channel, sdev->id, sdev->lun);
+	return 0;
+}
+
+int scsi_sysfs_target_initialize(struct scsi_device *sdev)
+{
+	struct scsi_target *starget = NULL;
+	struct Scsi_Host *shost = sdev->host;
+	struct scsi_device *device;
+	struct device *dev = NULL;
+	unsigned long flags;
+	int create = 0;
+
+	spin_lock_irqsave(shost->host_lock, flags);
+	/*
+	 * Search for an existing target for this sdev.
+	 */
+	list_for_each_entry(device, &shost->__devices, siblings) {
+		if (device->id == sdev->id &&
+		    device->channel == sdev->channel) {
+			list_add_tail(&sdev->same_target_siblings,
+				      &device->same_target_siblings);
+			sdev->scsi_level = device->scsi_level;
+			starget = device->sdev_target;
+			break;
+		}
+	}
+			
+	if (!starget) {
+		const int size = sizeof(*starget) +
+			shost->transportt->target_size;
+		starget = kmalloc(size, GFP_ATOMIC);
+		if (!starget) {
+			printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
+			spin_unlock_irqrestore(shost->host_lock,
+					       flags);
+			return -ENOMEM;
+		}
+		memset(starget, 0, size);
+		dev = &starget->dev;
+		device_initialize(dev);
+		dev->parent = get_device(&shost->shost_gendev);
+		dev->release = scsi_target_dev_release;
+		sprintf(dev->bus_id, "target%d:%d:%d",
+			shost->host_no, sdev->channel, sdev->id);
+		class_device_initialize(&starget->transport_classdev);
+		starget->transport_classdev.dev = &starget->dev;
+		starget->transport_classdev.class = shost->transportt->target_class;
+		snprintf(starget->transport_classdev.class_id, BUS_ID_SIZE,
+			 "target%d:%d:%d",
+			 shost->host_no, sdev->channel, sdev->id);
+		starget->id = sdev->id;
+		starget->channel = sdev->channel;
+		create = starget->create = 1;
+		/*
+		 * If there wasn't another lun already configured at
+		 * this target, then default this device to SCSI_2
+		 * until we know better
+		 */
+		sdev->scsi_level = SCSI_2;
+	}
+	get_device(&starget->dev);
+	sdev->sdev_gendev.parent = &starget->dev;
+	sdev->sdev_target = starget;
+	list_add_tail(&sdev->siblings, &shost->__devices);
+	spin_unlock_irqrestore(shost->host_lock, flags);
+	if (create && shost->transportt->target_setup)
+		shost->transportt->target_setup(starget);
 	return 0;
 }
 
diff -Nru a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
--- a/drivers/scsi/scsi_transport_fc.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/scsi_transport_fc.c	2004-12-24 13:36:18 -08:00
@@ -23,23 +23,31 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_transport_fc.h>
+#include "scsi_priv.h"
 
 #define FC_PRINTK(x, l, f, a...)	printk(l "scsi(%d:%d:%d:%d): " f, (x)->host->host_no, (x)->channel, (x)->id, (x)->lun , ##a)
 
 static void transport_class_release(struct class_device *class_dev);
+static void host_class_release(struct class_device *class_dev);
 
-#define FC_NUM_ATTRS 	3	/* increase this if you add attributes */
-#define FC_OTHER_ATTRS 	0	/* increase this if you add "always on"
-				 * attributes */
+#define FC_STARGET_NUM_ATTRS 	4	/* increase this if you add attributes */
+#define FC_STARGET_OTHER_ATTRS 	0	/* increase this if you add "always on"
+					 * attributes */
+#define FC_HOST_NUM_ATTRS	1
 
 struct fc_internal {
 	struct scsi_transport_template t;
 	struct fc_function_template *f;
 	/* The actual attributes */
-	struct class_device_attribute private_attrs[FC_NUM_ATTRS];
+	struct class_device_attribute private_starget_attrs[
+						FC_STARGET_NUM_ATTRS];
 	/* The array of null terminated pointers to attributes
 	 * needed by scsi_sysfs.c */
-	struct class_device_attribute *attrs[FC_NUM_ATTRS + FC_OTHER_ATTRS + 1];
+	struct class_device_attribute *starget_attrs[
+			FC_STARGET_NUM_ATTRS + FC_STARGET_OTHER_ATTRS + 1];
+
+	struct class_device_attribute private_host_attrs[FC_HOST_NUM_ATTRS];
+	struct class_device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1];
 };
 
 #define to_fc_internal(tmpl)	container_of(tmpl, struct fc_internal, t)
@@ -49,101 +57,211 @@
 	.release = transport_class_release,
 };
 
+struct class fc_host_class = {
+	.name = "fc_host",
+	.release = host_class_release,
+};
+
 static __init int fc_transport_init(void)
 {
+	int error = class_register(&fc_host_class);
+	if (error)
+		return error;
 	return class_register(&fc_transport_class);
 }
 
 static void __exit fc_transport_exit(void)
 {
 	class_unregister(&fc_transport_class);
+	class_unregister(&fc_host_class);
 }
 
-static int fc_setup_transport_attrs(struct scsi_device *sdev)
+static int fc_setup_starget_transport_attrs(struct scsi_target *starget)
 {
-	/* I'm not sure what values are invalid.  We should pick some invalid
-	 * values for the defaults */
-	fc_node_name(sdev) = -1;
-	fc_port_name(sdev) = -1;
-	fc_port_id(sdev) = -1;
+	/* 
+	 * Set default values easily detected by the midlayer as
+	 * failure cases.  The scsi lldd is responsible for initializing
+	 * all transport attributes to valid values per target.
+	 */
+	fc_starget_node_name(starget) = -1;
+	fc_starget_port_name(starget) = -1;
+	fc_starget_port_id(starget) = -1;
+	fc_starget_dev_loss_tmo(starget) = -1;
+	init_timer(&fc_starget_dev_loss_timer(starget));
+	return 0;
+}
 
+static int fc_setup_host_transport_attrs(struct Scsi_Host *shost)
+{
+	/* 
+	 * Set default values easily detected by the midlayer as
+	 * failure cases.  The scsi lldd is responsible for initializing
+	 * all transport attributes to valid values per host.
+	 */
+	fc_host_link_down_tmo(shost) = -1;
+	init_timer(&fc_host_link_down_timer(shost));
 	return 0;
 }
 
 static void transport_class_release(struct class_device *class_dev)
 {
-	struct scsi_device *sdev = transport_class_to_sdev(class_dev);
-	put_device(&sdev->sdev_gendev);
+	struct scsi_target *starget = transport_class_to_starget(class_dev);
+	put_device(&starget->dev);
 }
 
-#define fc_transport_show_function(field, format_string, cast)		\
-									\
+static void host_class_release(struct class_device *class_dev)
+{
+	struct Scsi_Host *shost = transport_class_to_shost(class_dev);
+	put_device(&shost->shost_gendev);
+}
+
+
+/*
+ * Remote Port Attribute Management
+ */
+
+#define fc_starget_show_function(field, format_string, cast)		\
 static ssize_t								\
-show_fc_transport_##field (struct class_device *cdev, char *buf)	\
+show_fc_starget_##field (struct class_device *cdev, char *buf)		\
 {									\
-	struct scsi_device *sdev = transport_class_to_sdev(cdev);	\
-	struct fc_transport_attrs *tp;					\
-	struct fc_internal *i = to_fc_internal(sdev->host->transportt);	\
-	tp = (struct fc_transport_attrs *)&sdev->transport_data;	\
-	if (i->f->get_##field)						\
-		i->f->get_##field(sdev);				\
+	struct scsi_target *starget = transport_class_to_starget(cdev);	\
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
+	struct fc_starget_attrs *tp;					\
+	struct fc_internal *i = to_fc_internal(shost->transportt);	\
+	tp = (struct fc_starget_attrs *)&starget->starget_data;		\
+	if (i->f->get_starget_##field)					\
+		i->f->get_starget_##field(starget);			\
 	return snprintf(buf, 20, format_string, cast tp->field);	\
 }
 
-#define fc_transport_store_function(field, format_string)		\
+#define fc_starget_store_function(field, format_string)			\
 static ssize_t								\
-store_fc_transport_##field(struct class_device *cdev, const char *buf,	\
+store_fc_starget_##field(struct class_device *cdev, const char *buf,	\
 			   size_t count)				\
 {									\
 	int val;							\
-	struct scsi_device *sdev = transport_class_to_sdev(cdev);	\
-	struct fc_internal *i = to_fc_internal(sdev->host->transportt);	\
+	struct scsi_target *starget = transport_class_to_starget(cdev);	\
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
+	struct fc_internal *i = to_fc_internal(shost->transportt);	\
 									\
 	val = simple_strtoul(buf, NULL, 0);				\
-	i->f->set_##field(sdev, val);					\
+	i->f->set_starget_##field(starget, val);			\
 	return count;							\
 }
 
-#define fc_transport_rd_attr(field, format_string)			\
-	fc_transport_show_function(field, format_string, )		\
+#define fc_starget_rd_attr(field, format_string)			\
+	fc_starget_show_function(field, format_string, )		\
+static CLASS_DEVICE_ATTR(field, S_IRUGO,				\
+			 show_fc_starget_##field, NULL)
+
+#define fc_starget_rd_attr_cast(field, format_string, cast)		\
+	fc_starget_show_function(field, format_string, (cast))		\
 static CLASS_DEVICE_ATTR(field, S_IRUGO,				\
-			 show_fc_transport_##field, NULL)
+			  show_fc_starget_##field, NULL)
 
-#define fc_transport_rd_attr_cast(field, format_string, cast)		\
-	fc_transport_show_function(field, format_string, (cast))	\
-static CLASS_DEVICE_ATTR( field, S_IRUGO,				\
-			  show_fc_transport_##field, NULL)
-
-#define fc_transport_rw_attr(field, format_string)			\
-	fc_transport_show_function(field, format_string, )		\
-	fc_transport_store_function(field, format_string)		\
+#define fc_starget_rw_attr(field, format_string)			\
+	fc_starget_show_function(field, format_string, )		\
+	fc_starget_store_function(field, format_string)			\
 static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR,			\
-			show_fc_transport_##field,			\
-			store_fc_transport_##field)
+			show_fc_starget_##field,			\
+			store_fc_starget_##field)
 
-/* the FiberChannel Tranport Attributes: */
-fc_transport_rd_attr_cast(node_name, "0x%llx\n", unsigned long long);
-fc_transport_rd_attr_cast(port_name, "0x%llx\n", unsigned long long);
-fc_transport_rd_attr(port_id, "0x%06x\n");
-
-#define SETUP_ATTRIBUTE_RD(field)				\
-	i->private_attrs[count] = class_device_attr_##field;	\
-	i->private_attrs[count].attr.mode = S_IRUGO;		\
-	i->private_attrs[count].store = NULL;			\
-	i->attrs[count] = &i->private_attrs[count];		\
-	if (i->f->show_##field)					\
+#define SETUP_STARGET_ATTRIBUTE_RD(field)				\
+	i->private_starget_attrs[count] = class_device_attr_##field;	\
+	i->private_starget_attrs[count].attr.mode = S_IRUGO;		\
+	i->private_starget_attrs[count].store = NULL;			\
+	i->starget_attrs[count] = &i->private_starget_attrs[count];	\
+	if (i->f->show_starget_##field)					\
 		count++
 
-#define SETUP_ATTRIBUTE_RW(field)				\
-	i->private_attrs[count] = class_device_attr_##field;	\
-	if (!i->f->set_##field) {				\
-		i->private_attrs[count].attr.mode = S_IRUGO;	\
-		i->private_attrs[count].store = NULL;		\
-	}							\
-	i->attrs[count] = &i->private_attrs[count];		\
-	if (i->f->show_##field)					\
+#define SETUP_STARGET_ATTRIBUTE_RW(field)				\
+	i->private_starget_attrs[count] = class_device_attr_##field;	\
+	if (!i->f->set_starget_##field) {				\
+		i->private_starget_attrs[count].attr.mode = S_IRUGO;	\
+		i->private_starget_attrs[count].store = NULL;		\
+	}								\
+	i->starget_attrs[count] = &i->private_starget_attrs[count];	\
+	if (i->f->show_starget_##field)					\
 		count++
 
+/* The FC Tranport Remote Port (Target) Attributes: */
+fc_starget_rd_attr_cast(node_name, "0x%llx\n", unsigned long long);
+fc_starget_rd_attr_cast(port_name, "0x%llx\n", unsigned long long);
+fc_starget_rd_attr(port_id, "0x%06x\n");
+fc_starget_rw_attr(dev_loss_tmo, "%d\n");
+
+
+/*
+ * Host Attribute Management
+ */
+
+#define fc_host_show_function(field, format_string, cast)		\
+static ssize_t								\
+show_fc_host_##field (struct class_device *cdev, char *buf)		\
+{									\
+	struct Scsi_Host *shost = transport_class_to_shost(cdev);	\
+	struct fc_host_attrs *tp;					\
+	struct fc_internal *i = to_fc_internal(shost->transportt);	\
+	tp = (struct fc_host_attrs *)shost->shost_data;		\
+	if (i->f->get_host_##field)					\
+		i->f->get_host_##field(shost);				\
+	return snprintf(buf, 20, format_string, cast tp->field);	\
+}
+
+#define fc_host_store_function(field, format_string)			\
+static ssize_t								\
+store_fc_host_##field(struct class_device *cdev, const char *buf,	\
+			   size_t count)				\
+{									\
+	int val;							\
+	struct Scsi_Host *shost = transport_class_to_shost(cdev);	\
+	struct fc_internal *i = to_fc_internal(shost->transportt);	\
+									\
+	val = simple_strtoul(buf, NULL, 0);				\
+	i->f->set_host_##field(shost, val);				\
+	return count;							\
+}
+
+#define fc_host_rd_attr(field, format_string)				\
+	fc_host_show_function(field, format_string, )			\
+static CLASS_DEVICE_ATTR(host_##field, S_IRUGO,				\
+			 show_fc_host_##field, NULL)
+
+#define fc_host_rd_attr_cast(field, format_string, cast)		\
+	fc_host_show_function(field, format_string, (cast))		\
+static CLASS_DEVICE_ATTR(host_##field, S_IRUGO,				\
+			  show_fc_host_##field, NULL)
+
+#define fc_host_rw_attr(field, format_string)				\
+	fc_host_show_function(field, format_string, )			\
+	fc_host_store_function(field, format_string)			\
+static CLASS_DEVICE_ATTR(host_##field, S_IRUGO | S_IWUSR,		\
+			show_fc_host_##field,				\
+			store_fc_host_##field)
+
+#define SETUP_HOST_ATTRIBUTE_RD(field)					\
+	i->private_host_attrs[count] = class_device_attr_host_##field;	\
+	i->private_host_attrs[count].attr.mode = S_IRUGO;		\
+	i->private_host_attrs[count].store = NULL;			\
+	i->host_attrs[count] = &i->private_host_attrs[count];		\
+	if (i->f->show_host_##field)					\
+		count++
+
+#define SETUP_HOST_ATTRIBUTE_RW(field)					\
+	i->private_host_attrs[count] = class_device_attr_host_##field;	\
+	if (!i->f->set_host_##field) {					\
+		i->private_host_attrs[count].attr.mode = S_IRUGO;	\
+		i->private_host_attrs[count].store = NULL;		\
+	}								\
+	i->host_attrs[count] = &i->private_host_attrs[count];		\
+	if (i->f->show_host_##field)					\
+		count++
+
+/* The FC Tranport Host Attributes: */
+fc_host_rw_attr(link_down_tmo, "%d\n");
+
+
+
 struct scsi_transport_template *
 fc_attach_transport(struct fc_function_template *ft)
 {
@@ -156,21 +274,43 @@
 
 	memset(i, 0, sizeof(struct fc_internal));
 
-	i->t.attrs = &i->attrs[0];
-	i->t.class = &fc_transport_class;
-	i->t.setup = &fc_setup_transport_attrs;
-	i->t.size = sizeof(struct fc_transport_attrs);
+	i->t.target_attrs = &i->starget_attrs[0];
+	i->t.target_class = &fc_transport_class;
+	i->t.target_setup = &fc_setup_starget_transport_attrs;
+	i->t.target_size = sizeof(struct fc_starget_attrs);
+
+	i->t.host_attrs = &i->host_attrs[0];
+	i->t.host_class = &fc_host_class;
+	i->t.host_setup = &fc_setup_host_transport_attrs;
+	i->t.host_size = sizeof(struct fc_host_attrs);
 	i->f = ft;
 
-	SETUP_ATTRIBUTE_RD(port_id);
-	SETUP_ATTRIBUTE_RD(port_name);
-	SETUP_ATTRIBUTE_RD(node_name);
+	
+	/*
+	 * setup remote port (target) attributes
+	 */
+	SETUP_STARGET_ATTRIBUTE_RD(port_id);
+	SETUP_STARGET_ATTRIBUTE_RD(port_name);
+	SETUP_STARGET_ATTRIBUTE_RD(node_name);
+	SETUP_STARGET_ATTRIBUTE_RW(dev_loss_tmo);
 
-	BUG_ON(count > FC_NUM_ATTRS);
+	BUG_ON(count > FC_STARGET_NUM_ATTRS);
 
 	/* Setup the always-on attributes here */
 
-	i->attrs[count] = NULL;
+	i->starget_attrs[count] = NULL;
+
+
+	/* setup host attributes */
+	count=0;
+	SETUP_HOST_ATTRIBUTE_RW(link_down_tmo);
+
+	BUG_ON(count > FC_HOST_NUM_ATTRS);
+
+	/* Setup the always-on attributes here */
+
+	i->host_attrs[count] = NULL;
+
 
 	return &i->t;
 }
@@ -184,6 +324,204 @@
 }
 EXPORT_SYMBOL(fc_release_transport);
 
+
+
+/**
+ * fc_device_block - called by target functions to block a scsi device
+ * @dev:	scsi device
+ * @data:	unused
+ **/
+static int fc_device_block(struct device *dev, void *data)
+{
+	scsi_internal_device_block(to_scsi_device(dev));
+	return 0;
+}
+
+/**
+ * fc_device_unblock - called by target functions to unblock a scsi device
+ * @dev:	scsi device
+ * @data:	unused
+ **/
+static int fc_device_unblock(struct device *dev, void *data)
+{
+	scsi_internal_device_unblock(to_scsi_device(dev));
+	return 0;
+}
+
+/**
+ * fc_timeout_blocked_tgt - Timeout handler for blocked scsi targets
+ *			 that fail to recover in the alloted time.
+ * @data:	scsi target that failed to reappear in the alloted time.
+ **/
+static void fc_timeout_blocked_tgt(unsigned long data)
+{
+	struct scsi_target *starget = (struct scsi_target *)data;
+
+	dev_printk(KERN_ERR, &starget->dev, 
+		"blocked target time out: target resuming\n");
+
+	/* 
+	 * set the device going again ... if the scsi lld didn't
+	 * unblock this device, then IO errors will probably
+	 * result if the host still isn't ready.
+	 */
+	device_for_each_child(&starget->dev, NULL, fc_device_unblock);
+}
+
+/**
+ * fc_target_block - block a target by temporarily putting all its scsi devices
+ *		into the SDEV_BLOCK state.
+ * @starget:	scsi target managed by this fc scsi lldd.
+ *
+ * scsi lldd's with a FC transport call this routine to temporarily stop all
+ * scsi commands to all devices managed by this scsi target.  Called 
+ * from interrupt or normal process context.
+ *
+ * Returns zero if successful or error if not
+ *
+ * Notes:       
+ *	The timeout and timer types are extracted from the fc transport 
+ *	attributes from the caller's target pointer.  This routine assumes no
+ *	locks are held on entry.
+ **/
+int
+fc_target_block(struct scsi_target *starget)
+{
+	int timeout = fc_starget_dev_loss_tmo(starget);
+	struct timer_list *timer = &fc_starget_dev_loss_timer(starget);
+
+	if (timeout < 0 || timeout > SCSI_DEVICE_BLOCK_MAX_TIMEOUT)
+		return -EINVAL;
+
+	device_for_each_child(&starget->dev, NULL, fc_device_block);
+
+	/* The scsi lld blocks this target for the timeout period only. */
+	timer->data = (unsigned long)starget;
+	timer->expires = jiffies + timeout * HZ;
+	timer->function = fc_timeout_blocked_tgt;
+	add_timer(timer);
+
+	return 0;
+}
+EXPORT_SYMBOL(fc_target_block);
+
+/**
+ * fc_target_unblock - unblock a target following a fc_target_block request.
+ * @starget:	scsi target managed by this fc scsi lldd.	
+ *
+ * scsi lld's with a FC transport call this routine to restart IO to all 
+ * devices associated with the caller's scsi target following a fc_target_block
+ * request.  Called from interrupt or normal process context.
+ *
+ * Notes:       
+ *	This routine assumes no locks are held on entry.
+ **/
+void
+fc_target_unblock(struct scsi_target *starget)
+{
+	/* 
+	 * Stop the target timer first. Take no action on the del_timer
+	 * failure as the state machine state change will validate the
+	 * transaction. 
+	 */
+	del_timer_sync(&fc_starget_dev_loss_timer(starget));
+
+	device_for_each_child(&starget->dev, NULL, fc_device_unblock);
+}
+EXPORT_SYMBOL(fc_target_unblock);
+
+/**
+ * fc_timeout_blocked_host - Timeout handler for blocked scsi hosts
+ *			 that fail to recover in the alloted time.
+ * @data:	scsi host that failed to recover its devices in the alloted
+ *		time.
+ **/
+static void fc_timeout_blocked_host(unsigned long data)
+{
+	struct Scsi_Host *shost = (struct Scsi_Host *)data;
+	struct scsi_device *sdev;
+
+	dev_printk(KERN_ERR, &shost->shost_gendev, 
+		"blocked host time out: host resuming\n");
+
+	shost_for_each_device(sdev, shost) {
+		/* 
+		 * set the device going again ... if the scsi lld didn't
+		 * unblock this device, then IO errors will probably
+		 * result if the host still isn't ready.
+		 */
+		scsi_internal_device_unblock(sdev);
+	}
+}
+
+/**
+ * fc_host_block - block all scsi devices managed by the calling host temporarily 
+ *		by putting each device in the SDEV_BLOCK state.
+ * @shost:	scsi host pointer that contains all scsi device siblings.
+ *
+ * scsi lld's with a FC transport call this routine to temporarily stop all
+ * scsi commands to all devices managed by this host.  Called 
+ * from interrupt or normal process context.
+ *
+ * Returns zero if successful or error if not
+ *
+ * Notes:
+ *	The timeout and timer types are extracted from the fc transport 
+ *	attributes from the caller's host pointer.  This routine assumes no
+ *	locks are held on entry.
+ **/
+int
+fc_host_block(struct Scsi_Host *shost)
+{
+	struct scsi_device *sdev;
+	int timeout = fc_host_link_down_tmo(shost);
+	struct timer_list *timer = &fc_host_link_down_timer(shost);
+
+	if (timeout < 0 || timeout > SCSI_DEVICE_BLOCK_MAX_TIMEOUT)
+		return -EINVAL;
+
+	shost_for_each_device(sdev, shost) {
+		scsi_internal_device_block(sdev);
+	}
+
+	/* The scsi lld blocks this host for the timeout period only. */
+	timer->data = (unsigned long)shost;
+	timer->expires = jiffies + timeout * HZ;
+	timer->function = fc_timeout_blocked_host;
+	add_timer(timer);
+
+	return 0;
+}
+EXPORT_SYMBOL(fc_host_block);
+
+/**
+ * fc_host_unblock - unblock all devices managed by this host following a 
+ *		fc_host_block request.
+ * @shost:	scsi host containing all scsi device siblings to unblock.
+ *
+ * scsi lld's with a FC transport call this routine to restart IO to all scsi
+ * devices managed by the specified scsi host following an fc_host_block 
+ * request.  Called from interrupt or normal process context.
+ *
+ * Notes:       
+ *	This routine assumes no locks are held on entry.
+ **/
+void
+fc_host_unblock(struct Scsi_Host *shost)
+{
+	struct scsi_device *sdev;
+
+	/* 
+	 * Stop the host timer first. Take no action on the del_timer
+	 * failure as the state machine state change will validate the
+	 * transaction.
+	 */
+	del_timer_sync(&fc_host_link_down_timer(shost));
+	shost_for_each_device(sdev, shost) {
+		scsi_internal_device_unblock(sdev);
+	}
+}
+EXPORT_SYMBOL(fc_host_unblock);
 
 MODULE_AUTHOR("Martin Hicks");
 MODULE_DESCRIPTION("FC Transport Attributes");
diff -Nru a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
--- a/drivers/scsi/scsi_transport_spi.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/scsi/scsi_transport_spi.c	2004-12-24 13:36:49 -08:00
@@ -27,25 +27,28 @@
 #include <asm/scatterlist.h>
 #include <asm/io.h>
 #include <scsi/scsi.h>
+#include "scsi_priv.h"
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_request.h>
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_transport_spi.h>
 
-#define SPI_PRINTK(x, l, f, a...)	printk(l "scsi(%d:%d:%d:%d): " f, (x)->host->host_no, (x)->channel, (x)->id, (x)->lun , ##a)
+#define SPI_PRINTK(x, l, f, a...)	dev_printk(l, &(x)->dev, f , ##a)
 
 static void transport_class_release(struct class_device *class_dev);
+static void host_class_release(struct class_device *class_dev);
 
 #define SPI_NUM_ATTRS 10	/* increase this if you add attributes */
 #define SPI_OTHER_ATTRS 1	/* Increase this if you add "always
 				 * on" attributes */
+#define SPI_HOST_ATTRS	1
 
 #define SPI_MAX_ECHO_BUFFER_SIZE	4096
 
 /* Private data accessors (keep these out of the header file) */
-#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->transport_data)->dv_pending)
-#define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->transport_data)->dv_sem)
+#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
+#define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem)
 
 struct spi_internal {
 	struct scsi_transport_template t;
@@ -55,6 +58,8 @@
 	/* The array of null terminated pointers to attributes 
 	 * needed by scsi_sysfs.c */
 	struct class_device_attribute *attrs[SPI_NUM_ATTRS + SPI_OTHER_ATTRS + 1];
+	struct class_device_attribute private_host_attrs[SPI_HOST_ATTRS];
+	struct class_device_attribute *host_attrs[SPI_HOST_ATTRS + 1];
 };
 
 #define to_spi_internal(tmpl)	container_of(tmpl, struct spi_internal, t)
@@ -80,43 +85,117 @@
  * by 4 */
 #define SPI_STATIC_PPR	0x0c
 
+static struct {
+	enum spi_signal_type	value;
+	char			*name;
+} signal_types[] = {
+	{ SPI_SIGNAL_UNKNOWN, "unknown" },
+	{ SPI_SIGNAL_SE, "SE" },
+	{ SPI_SIGNAL_LVD, "LVD" },
+	{ SPI_SIGNAL_HVD, "HVD" },
+};
+
+static inline const char *spi_signal_to_string(enum spi_signal_type type)
+{
+	int i;
+
+	for (i = 0; i < sizeof(signal_types)/sizeof(signal_types[0]); i++) {
+		if (type == signal_types[i].value)
+			return signal_types[i].name;
+	}
+	return NULL;
+}
+static inline enum spi_signal_type spi_signal_to_value(const char *name)
+{
+	int i, len;
+
+	for (i = 0; i < sizeof(signal_types)/sizeof(signal_types[0]); i++) {
+		len =  strlen(signal_types[i].name);
+		if (strncmp(name, signal_types[i].name, len) == 0 &&
+		    (name[len] == '\n' || name[len] == '\0'))
+			return signal_types[i].value;
+	}
+	return SPI_SIGNAL_UNKNOWN;
+}
+
+
 struct class spi_transport_class = {
 	.name = "spi_transport",
 	.release = transport_class_release,
 };
 
+struct class spi_host_class = {
+	.name = "spi_host",
+	.release = host_class_release,
+};
+
 static __init int spi_transport_init(void)
 {
+	int error = class_register(&spi_host_class);
+	if (error)
+		return error;
 	return class_register(&spi_transport_class);
 }
 
 static void __exit spi_transport_exit(void)
 {
 	class_unregister(&spi_transport_class);
+	class_unregister(&spi_host_class);
+}
+
+static int spi_setup_host_attrs(struct Scsi_Host *shost)
+{
+	spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
+
+	return 0;
+}
+
+static int spi_configure_device(struct scsi_device *sdev)
+{
+	struct scsi_target *starget = sdev->sdev_target;
+
+	/* Populate the target capability fields with the values
+	 * gleaned from the device inquiry */
+
+	spi_support_sync(starget) = scsi_device_sync(sdev);
+	spi_support_wide(starget) = scsi_device_wide(sdev);
+	spi_support_dt(starget) = scsi_device_dt(sdev);
+	spi_support_dt_only(starget) = scsi_device_dt_only(sdev);
+	spi_support_ius(starget) = scsi_device_ius(sdev);
+	spi_support_qas(starget) = scsi_device_qas(sdev);
+
+	return 0;
 }
 
-static int spi_setup_transport_attrs(struct scsi_device *sdev)
+static int spi_setup_transport_attrs(struct scsi_target *starget)
 {
-	spi_period(sdev) = -1;	/* illegal value */
-	spi_offset(sdev) = 0;	/* async */
-	spi_width(sdev) = 0;	/* narrow */
-	spi_iu(sdev) = 0;	/* no IU */
-	spi_dt(sdev) = 0;	/* ST */
-	spi_qas(sdev) = 0;
-	spi_wr_flow(sdev) = 0;
-	spi_rd_strm(sdev) = 0;
-	spi_rti(sdev) = 0;
-	spi_pcomp_en(sdev) = 0;
-	spi_dv_pending(sdev) = 0;
-	init_MUTEX(&spi_dv_sem(sdev));
+	spi_period(starget) = -1;	/* illegal value */
+	spi_offset(starget) = 0;	/* async */
+	spi_width(starget) = 0;	/* narrow */
+	spi_iu(starget) = 0;	/* no IU */
+	spi_dt(starget) = 0;	/* ST */
+	spi_qas(starget) = 0;
+	spi_wr_flow(starget) = 0;
+	spi_rd_strm(starget) = 0;
+	spi_rti(starget) = 0;
+	spi_pcomp_en(starget) = 0;
+	spi_dv_pending(starget) = 0;
+	spi_initial_dv(starget) = 0;
+	init_MUTEX(&spi_dv_sem(starget));
 
 	return 0;
 }
 
 static void transport_class_release(struct class_device *class_dev)
 {
-	struct scsi_device *sdev = transport_class_to_sdev(class_dev);
-	put_device(&sdev->sdev_gendev);
+	struct scsi_target *starget = transport_class_to_starget(class_dev);
+	put_device(&starget->dev);
+}
+
+static void host_class_release(struct class_device *class_dev)
+{
+	struct Scsi_Host *shost = transport_class_to_shost(class_dev);
+	put_device(&shost->shost_gendev);
 }
 
 #define spi_transport_show_function(field, format_string)		\
@@ -124,12 +203,13 @@
 static ssize_t								\
 show_spi_transport_##field(struct class_device *cdev, char *buf)	\
 {									\
-	struct scsi_device *sdev = transport_class_to_sdev(cdev);	\
+	struct scsi_target *starget = transport_class_to_starget(cdev);	\
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
 	struct spi_transport_attrs *tp;					\
-	struct spi_internal *i = to_spi_internal(sdev->host->transportt); \
-	tp = (struct spi_transport_attrs *)&sdev->transport_data;	\
+	struct spi_internal *i = to_spi_internal(shost->transportt);	\
+	tp = (struct spi_transport_attrs *)&starget->starget_data;	\
 	if (i->f->get_##field)						\
-		i->f->get_##field(sdev);				\
+		i->f->get_##field(starget);				\
 	return snprintf(buf, 20, format_string, tp->field);		\
 }
 
@@ -139,11 +219,12 @@
 			    size_t count)				\
 {									\
 	int val;							\
-	struct scsi_device *sdev = transport_class_to_sdev(cdev);	\
-	struct spi_internal *i = to_spi_internal(sdev->host->transportt); \
+	struct scsi_target *starget = transport_class_to_starget(cdev);	\
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
+	struct spi_internal *i = to_spi_internal(shost->transportt);	\
 									\
 	val = simple_strtoul(buf, NULL, 0);				\
-	i->f->set_##field(sdev, val);					\
+	i->f->set_##field(starget, val);				\
 	return count;							\
 }
 
@@ -168,8 +249,13 @@
 static ssize_t
 store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count)
 {
-	struct scsi_device *sdev = transport_class_to_sdev(cdev);
+	struct scsi_target *starget = transport_class_to_starget(cdev);
 
+	/* FIXME: we're relying on an awful lot of device internals
+	 * here.  We really need a function to get the first available
+	 * child */
+	struct device *dev = container_of(starget->dev.children.next, struct device, node);
+	struct scsi_device *sdev = to_scsi_device(dev);
 	spi_dv_device(sdev);
 	return count;
 }
@@ -180,15 +266,16 @@
 static ssize_t show_spi_transport_period(struct class_device *cdev, char *buf)
 
 {
-	struct scsi_device *sdev = transport_class_to_sdev(cdev);
+	struct scsi_target *starget = transport_class_to_starget(cdev);
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
 	struct spi_transport_attrs *tp;
 	const char *str;
-	struct spi_internal *i = to_spi_internal(sdev->host->transportt);
+	struct spi_internal *i = to_spi_internal(shost->transportt);
 
-	tp = (struct spi_transport_attrs *)&sdev->transport_data;
+	tp = (struct spi_transport_attrs *)&starget->starget_data;
 
 	if (i->f->get_period)
-		i->f->get_period(sdev);
+		i->f->get_period(starget);
 
 	switch(tp->period) {
 
@@ -212,8 +299,9 @@
 store_spi_transport_period(struct class_device *cdev, const char *buf,
 			    size_t count)
 {
-	struct scsi_device *sdev = transport_class_to_sdev(cdev);
-	struct spi_internal *i = to_spi_internal(sdev->host->transportt);
+	struct scsi_target *starget = transport_class_to_starget(cdev);
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct spi_internal *i = to_spi_internal(shost->transportt);
 	int j, period = -1;
 
 	for (j = 0; j < SPI_STATIC_PPR; j++) {
@@ -246,7 +334,7 @@
 	if (period > 0xff)
 		period = 0xff;
 
-	i->f->set_period(sdev, period);
+	i->f->set_period(starget, period);
 
 	return count;
 }
@@ -255,9 +343,35 @@
 			 show_spi_transport_period,
 			 store_spi_transport_period);
 
+static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf)
+{
+	struct Scsi_Host *shost = transport_class_to_shost(cdev);
+	struct spi_internal *i = to_spi_internal(shost->transportt);
+
+	if (i->f->get_signalling)
+		i->f->get_signalling(shost);
+
+	return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost)));
+}
+static ssize_t store_spi_host_signalling(struct class_device *cdev,
+					 const char *buf, size_t count)
+{
+	struct Scsi_Host *shost = transport_class_to_shost(cdev);
+	struct spi_internal *i = to_spi_internal(shost->transportt);
+	enum spi_signal_type type = spi_signal_to_value(buf);
+
+	if (type != SPI_SIGNAL_UNKNOWN)
+		i->f->set_signalling(shost, type);
+
+	return count;
+}
+static CLASS_DEVICE_ATTR(signalling, S_IRUGO | S_IWUSR,
+			 show_spi_host_signalling,
+			 store_spi_host_signalling);
+
 #define DV_SET(x, y)			\
 	if(i->f->set_##x)		\
-		i->f->set_##x(sdev, y)
+		i->f->set_##x(sdev->sdev_target, y)
 
 #define DV_LOOPS	3
 #define DV_TIMEOUT	(10*HZ)
@@ -325,7 +439,7 @@
 			      DV_TIMEOUT, DV_RETRIES);
 		if(sreq->sr_result || !scsi_device_online(sdev)) {
 			scsi_device_set_state(sdev, SDEV_QUIESCE);
-			SPI_PRINTK(sdev, KERN_ERR, "Write Buffer failure %x\n", sreq->sr_result);
+			SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", sreq->sr_result);
 			return 0;
 		}
 
@@ -401,8 +515,8 @@
 
 		/* OK, retrain, fallback */
 		if (i->f->get_period)
-			i->f->get_period(sdev);
-		newperiod = spi_period(sdev);
+			i->f->get_period(sdev->sdev_target);
+		newperiod = spi_period(sdev->sdev_target);
 		period = newperiod > period ? newperiod : period;
 		if (period < 0x0d)
 			period++;
@@ -411,11 +525,11 @@
 
 		if (unlikely(period > 0xff || period == prevperiod)) {
 			/* Total failure; set to async and return */
-			SPI_PRINTK(sdev, KERN_ERR, "Domain Validation Failure, dropping back to Asynchronous\n");
+			SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation Failure, dropping back to Asynchronous\n");
 			DV_SET(offset, 0);
 			return 0;
 		}
-		SPI_PRINTK(sdev, KERN_ERR, "Domain Validation detected failure, dropping back\n");
+		SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation detected failure, dropping back\n");
 		DV_SET(period, period);
 		prevperiod = period;
 	}
@@ -486,20 +600,20 @@
 	DV_SET(width, 0);
 	
 	if (!spi_dv_device_compare_inquiry(sreq, buffer, buffer, DV_LOOPS)) {
-		SPI_PRINTK(sdev, KERN_ERR, "Domain Validation Initial Inquiry Failed\n");
+		SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation Initial Inquiry Failed\n");
 		/* FIXME: should probably offline the device here? */
 		return;
 	}
 
 	/* test width */
 	if (i->f->set_width && sdev->wdtr) {
-		i->f->set_width(sdev, 1);
+		i->f->set_width(sdev->sdev_target, 1);
 
 		if (!spi_dv_device_compare_inquiry(sreq, buffer,
 						   buffer + len,
 						   DV_LOOPS)) {
-			SPI_PRINTK(sdev, KERN_ERR, "Wide Transfers Fail\n");
-			i->f->set_width(sdev, 0);
+			SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Wide Transfers Fail\n");
+			i->f->set_width(sdev->sdev_target, 0);
 		}
 	}
 
@@ -520,12 +634,16 @@
 	/* OK, now we have our initial speed set by the read only inquiry
 	 * test, now try an echo buffer test (if the device allows it) */
 
-	if ((len = spi_dv_device_get_echo_buffer(sreq, buffer)) == 0) {
-		SPI_PRINTK(sdev, KERN_INFO, "Domain Validation skipping write tests\n");
+	len = 0;
+	if (sdev->ppr)
+		len = spi_dv_device_get_echo_buffer(sreq, buffer);
+
+	if (len == 0) {
+		SPI_PRINTK(sdev->sdev_target, KERN_INFO, "Domain Validation skipping write tests\n");
 		return;
 	}
 	if (len > SPI_MAX_ECHO_BUFFER_SIZE) {
-		SPI_PRINTK(sdev, KERN_WARNING, "Echo buffer size %d is too big, trimming to %d\n", len, SPI_MAX_ECHO_BUFFER_SIZE);
+		SPI_PRINTK(sdev->sdev_target, KERN_WARNING, "Echo buffer size %d is too big, trimming to %d\n", len, SPI_MAX_ECHO_BUFFER_SIZE);
 		len = SPI_MAX_ECHO_BUFFER_SIZE;
 	}
 
@@ -547,6 +665,7 @@
 spi_dv_device(struct scsi_device *sdev)
 {
 	struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL);
+	struct scsi_target *starget = sdev->sdev_target;
 	u8 *buffer;
 	const int len = SPI_MAX_ECHO_BUFFER_SIZE*2;
 
@@ -563,22 +682,28 @@
 
 	memset(buffer, 0, len);
 
+	/* We need to verify that the actual device will quiesce; the
+	 * later target quiesce is just a nice to have */
 	if (unlikely(scsi_device_quiesce(sdev)))
 		goto out_free;
 
-	spi_dv_pending(sdev) = 1;
-	down(&spi_dv_sem(sdev));
+	scsi_target_quiesce(starget);
+
+	spi_dv_pending(starget) = 1;
+	down(&spi_dv_sem(starget));
 
-	SPI_PRINTK(sdev, KERN_INFO, "Beginning Domain Validation\n");
+	SPI_PRINTK(starget, KERN_INFO, "Beginning Domain Validation\n");
 
 	spi_dv_device_internal(sreq, buffer);
 
-	SPI_PRINTK(sdev, KERN_INFO, "Ending Domain Validation\n");
+	SPI_PRINTK(starget, KERN_INFO, "Ending Domain Validation\n");
+
+	up(&spi_dv_sem(starget));
+	spi_dv_pending(starget) = 0;
 
-	up(&spi_dv_sem(sdev));
-	spi_dv_pending(sdev) = 0;
+	scsi_target_resume(starget);
 
-	scsi_device_resume(sdev);
+	spi_initial_dv(starget) = 1;
 
  out_free:
 	kfree(buffer);
@@ -602,7 +727,7 @@
 
 	kfree(wqw);
 	spi_dv_device(sdev);
-	spi_dv_pending(sdev) = 0;
+	spi_dv_pending(sdev->sdev_target) = 0;
 	scsi_device_put(sdev);
 }
 
@@ -625,15 +750,15 @@
 	if (unlikely(!wqw))
 		return;
 
-	if (unlikely(spi_dv_pending(sdev))) {
+	if (unlikely(spi_dv_pending(sdev->sdev_target))) {
 		kfree(wqw);
 		return;
 	}
 	/* Set pending early (dv_device doesn't check it, only sets it) */
-	spi_dv_pending(sdev) = 1;
+	spi_dv_pending(sdev->sdev_target) = 1;
 	if (unlikely(scsi_device_get(sdev))) {
 		kfree(wqw);
-		spi_dv_pending(sdev) = 0;
+		spi_dv_pending(sdev->sdev_target) = 0;
 		return;
 	}
 
@@ -654,6 +779,15 @@
 	if (i->f->show_##field)						\
 		count++
 
+#define SETUP_HOST_ATTRIBUTE(field)					\
+	i->private_host_attrs[count] = class_device_attr_##field;	\
+	if (!i->f->set_##field) {					\
+		i->private_host_attrs[count].attr.mode = S_IRUGO;	\
+		i->private_host_attrs[count].store = NULL;		\
+	}								\
+	i->host_attrs[count] = &i->private_host_attrs[count];		\
+	count++
+
 struct scsi_transport_template *
 spi_attach_transport(struct spi_function_template *ft)
 {
@@ -666,10 +800,15 @@
 	memset(i, 0, sizeof(struct spi_internal));
 
 
-	i->t.attrs = &i->attrs[0];
-	i->t.class = &spi_transport_class;
-	i->t.setup = &spi_setup_transport_attrs;
-	i->t.size = sizeof(struct spi_transport_attrs);
+	i->t.target_attrs = &i->attrs[0];
+	i->t.target_class = &spi_transport_class;
+	i->t.target_setup = &spi_setup_transport_attrs;
+	i->t.device_configure = &spi_configure_device;
+	i->t.target_size = sizeof(struct spi_transport_attrs);
+	i->t.host_attrs = &i->host_attrs[0];
+	i->t.host_class = &spi_host_class;
+	i->t.host_setup = &spi_setup_host_attrs;
+	i->t.host_size = sizeof(struct spi_host_attrs);
 	i->f = ft;
 
 	SETUP_ATTRIBUTE(period);
@@ -690,6 +829,13 @@
 	i->attrs[count++] = &class_device_attr_revalidate;
 
 	i->attrs[count] = NULL;
+
+	count = 0;
+	SETUP_HOST_ATTRIBUTE(signalling);
+
+	BUG_ON(count > SPI_HOST_ATTRS);
+
+	i->host_attrs[count] = NULL;
 
 	return &i->t;
 }
diff -Nru a/drivers/scsi/scsicam.c b/drivers/scsi/scsicam.c
--- a/drivers/scsi/scsicam.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/scsicam.c	2004-12-24 13:37:43 -08:00
@@ -29,10 +29,11 @@
 	unsigned char *res = kmalloc(66, GFP_KERNEL);
 	if (res) {
 		struct block_device *bdev = dev->bd_contains;
-		struct buffer_head *bh = __bread(bdev, 0, block_size(bdev));
-		if (bh) {
-			memcpy(res, bh->b_data + 0x1be, 66);
-			brelse(bh);
+		Sector sect;
+		void *data = read_dev_sector(bdev, 0, &sect);
+		if (data) {
+			memcpy(res, data + 0x1be, 66);
+			put_dev_sector(sect);
 		} else {
 			kfree(res);
 			res = NULL;
diff -Nru a/drivers/scsi/scsiiom.c b/drivers/scsi/scsiiom.c
--- a/drivers/scsi/scsiiom.c	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1654 +0,0 @@
-/***********************************************************************
- *	FILE NAME : SCSIIOM.C					       *
- *	     BY   : C.L. Huang,    ching@tekram.com.tw		       *
- *	Description: Device Driver for Tekram DC-390 (T) PCI SCSI      *
- *		     Bus Master Host Adapter			       *
- ***********************************************************************/
-/* $Id: scsiiom.c,v 2.55.2.17 2000/12/20 00:39:37 garloff Exp $ */
-static void __inline__
-dc390_freetag (struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
-{
-	if (pSRB->TagNumber < 255) {
-		pDCB->TagMask &= ~(1 << pSRB->TagNumber);   /* free tag mask */
-		pSRB->TagNumber = 255;
-	}
-}
-
-
-static u8
-dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB )
-{
-    u8 cmd; u8  disc_allowed, try_sync_nego;
-
-    pSRB->ScsiPhase = SCSI_NOP0;
-
-    if (pACB->Connected)
-    {
-	// Should not happen normally
-	printk (KERN_WARNING "DC390: Can't select when connected! (%08x,%02x)\n",
-		pSRB->SRBState, pSRB->SRBFlag);
-	pSRB->SRBState = SRB_READY;
-	pACB->SelConn++;
-	return 1;
-    }
-    if (time_before (jiffies, pACB->pScsiHost->last_reset))
-    {
-	DEBUG0(printk ("DC390: We were just reset and don't accept commands yet!\n"));
-	return 1;
-    }
-    /* KG: Moved pci mapping here */
-    dc390_pci_map(pSRB);
-    /* TODO: error handling */
-    DC390_write8 (Scsi_Dest_ID, pDCB->TargetID);
-    DC390_write8 (Sync_Period, pDCB->SyncPeriod);
-    DC390_write8 (Sync_Offset, pDCB->SyncOffset);
-    DC390_write8 (CtrlReg1, pDCB->CtrlR1);
-    DC390_write8 (CtrlReg3, pDCB->CtrlR3);
-    DC390_write8 (CtrlReg4, pDCB->CtrlR4);
-    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);		/* Flush FIFO */
-    DEBUG1(printk (KERN_INFO "DC390: Start SCSI command: %02x (Sync:%02x)\n",\
-	    pSRB->pcmd->cmnd[0], pDCB->SyncMode));
-    disc_allowed = pDCB->DevMode & EN_DISCONNECT_;
-    try_sync_nego = 0;
-    /* Don't disconnect on AUTO_REQSENSE, cause it might be an
-     * Contingent Allegiance Condition (6.6), where no tags should be used.
-     * All other have to be allowed to disconnect to prevent Incorrect 
-     * Initiator Connection (6.8.2/6.5.2) */
-    /* Changed KG, 99/06/06 */
-    if( /*(((pSRB->pcmd->cmnd[0] == INQUIRY) || (pSRB->pcmd->cmnd[0] == REQUEST_SENSE) ||
-	 * (pSRB->pcmd->cmnd[0] == TEST_UNIT_READY)) && pACB->scan_devices)
-		||*/ (pSRB->SRBFlag & AUTO_REQSENSE) ) 
-      disc_allowed = 0;
-    if ( (pDCB->SyncMode & SYNC_ENABLE) && (pDCB->TargetLUN == 0) && (pDCB->Inquiry7 & 0x10) &&
-	( ( ( (pSRB->pcmd->cmnd[0] == REQUEST_SENSE) || (pSRB->SRBFlag & AUTO_REQSENSE) )
-	  && !(pDCB->SyncMode & SYNC_NEGO_DONE) ) || (pSRB->pcmd->cmnd[0] == INQUIRY) ) )
-      try_sync_nego = 1;
-
-    pSRB->MsgCnt = 0; cmd = SEL_W_ATN;
-    DC390_write8 (ScsiFifo, IDENTIFY(disc_allowed, pDCB->TargetLUN));
-    /* Change 99/05/31: Don't use tags when not disconnecting (BUSY) */
-    if ((pDCB->SyncMode & EN_TAG_QUEUEING) && disc_allowed)
-      {
-	u8 tag_no = 0;
-	while ((1 << tag_no) & pDCB->TagMask) tag_no++;
-	if (tag_no >= sizeof (pDCB->TagMask)*8 || tag_no >= pDCB->MaxCommand) { 
-		printk (KERN_WARNING "DC390: Out of tags for Dev. %02x %02x\n", pDCB->TargetID, pDCB->TargetLUN); 
-		return 1;
-		//goto no_tag;
-	}
-	DC390_write8 (ScsiFifo, SIMPLE_QUEUE_TAG);
-	pDCB->TagMask |= (1 << tag_no); pSRB->TagNumber = tag_no;
-	DC390_write8 (ScsiFifo, tag_no);
-	DEBUG1(printk (KERN_DEBUG "DC390: Select w/DisCn for Cmd %li (SRB %p), Using Tag %02x\n", pSRB->pcmd->pid, pSRB, tag_no));
-	cmd = SEL_W_ATN3;
-      }
-    else	/* No TagQ */
-      {
-//      no_tag:
-	DEBUG1(printk (KERN_DEBUG "DC390: Select w%s/DisCn for Cmd %li (SRB %p), No TagQ\n", (disc_allowed?"":"o"), pSRB->pcmd->pid, pSRB));
-      }
-
-    pSRB->SRBState = SRB_START_;
-
-    if (try_sync_nego)
-      { 
-	u8 Sync_Off = pDCB->SyncOffset;
-        DEBUG0(printk (KERN_INFO "DC390: NEW Sync Nego code triggered (%i %i)\n", pDCB->TargetID, pDCB->TargetLUN));
-	pSRB->MsgOutBuf[0] = EXTENDED_MESSAGE;
-	pSRB->MsgOutBuf[1] = 3;
-	pSRB->MsgOutBuf[2] = EXTENDED_SDTR;
-	pSRB->MsgOutBuf[3] = pDCB->NegoPeriod;
-	if (!(Sync_Off & 0x0f)) Sync_Off = SYNC_NEGO_OFFSET;
-	pSRB->MsgOutBuf[4] = Sync_Off;
-	pSRB->MsgCnt = 5;
-	//pSRB->SRBState = SRB_MSGOUT_;
-	pSRB->SRBState |= DO_SYNC_NEGO;
-	cmd = SEL_W_ATN_STOP;
-      }
-
-    /* Command is written in CommandPhase, if SEL_W_ATN_STOP ... */
-    if (cmd != SEL_W_ATN_STOP)
-      {
-	if( pSRB->SRBFlag & AUTO_REQSENSE )
-	  {
-	    DC390_write8 (ScsiFifo, REQUEST_SENSE);
-	    DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5);
-	    DC390_write8 (ScsiFifo, 0);
-	    DC390_write8 (ScsiFifo, 0);
-	    DC390_write8 (ScsiFifo, sizeof(pSRB->pcmd->sense_buffer));
-	    DC390_write8 (ScsiFifo, 0);
-	    DEBUG1(printk (KERN_DEBUG "DC390: AutoReqSense !\n"));
-	  }
-	else	/* write cmnd to bus */ 
-	  {
-	    u8 *ptr; u8 i;
-	    ptr = (u8 *) pSRB->pcmd->cmnd;
-	    for (i=0; i<pSRB->pcmd->cmd_len; i++)
-	      DC390_write8 (ScsiFifo, *(ptr++));
-	  }
-      }
-    DEBUG0(if (pACB->pActiveDCB)	\
-	   printk (KERN_WARNING "DC390: ActiveDCB != 0\n"));
-    DEBUG0(if (pDCB->pActiveSRB)	\
-	   printk (KERN_WARNING "DC390: ActiveSRB != 0\n"));
-    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-    if (DC390_read8 (Scsi_Status) & INTERRUPT)
-    {
-	dc390_freetag (pDCB, pSRB);
-	DEBUG0(printk ("DC390: Interrupt during Start SCSI (pid %li, target %02i-%02i)\n",
-		pSRB->pcmd->pid, pSRB->pcmd->device->id, pSRB->pcmd->device->lun));
-	pSRB->SRBState = SRB_READY;
-	//DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-	pACB->SelLost++;
-	return 1;
-    }
-    DC390_write8 (ScsiCmd, cmd);
-    pACB->pActiveDCB = pDCB; pDCB->pActiveSRB = pSRB;
-    pACB->Connected = 1;
-    pSRB->ScsiPhase = SCSI_NOP1;
-    return 0;
-}
-
-//#define DMA_INT EN_DMA_INT /*| EN_PAGE_INT*/
-#define DMA_INT 0
-
-#if DMA_INT
-/* This is similar to AM53C974.c ... */
-static u8 
-dc390_dma_intr (struct dc390_acb* pACB)
-{
-  struct dc390_srb* pSRB;
-  u8 dstate;
-  DEBUG0(u16 pstate; struct pci_dev *pdev = pACB->pdev);
-  
-  DEBUG0(pci_read_config_word(pdev, PCI_STATUS, &pstate));
-  DEBUG0(if (pstate & (PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY))\
-	{ printk(KERN_WARNING "DC390: PCI state = %04x!\n", pstate); \
-	  pci_write_config_word(pdev, PCI_STATUS, (PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY));});
-
-  dstate = DC390_read8 (DMA_Status); 
-
-  if (! pACB->pActiveDCB || ! pACB->pActiveDCB->pActiveSRB) return dstate;
-  else pSRB  = pACB->pActiveDCB->pActiveSRB;
-  
-  if (dstate & (DMA_XFER_ABORT | DMA_XFER_ERROR | POWER_DOWN | PCI_MS_ABORT))
-    {
-	printk (KERN_ERR "DC390: DMA error (%02x)!\n", dstate);
-	return dstate;
-    }
-  if (dstate & DMA_XFER_DONE)
-    {
-	u32 residual, xferCnt; int ctr = 6000000;
-	if (! (DC390_read8 (DMA_Cmd) & READ_DIRECTION))
-	  {
-	    do
-	      {
-		DEBUG1(printk (KERN_DEBUG "DC390: read residual bytes ... \n"));
-		dstate = DC390_read8 (DMA_Status);
-		residual = DC390_read8 (CtcReg_Low) | DC390_read8 (CtcReg_Mid) << 8 |
-		  DC390_read8 (CtcReg_High) << 16;
-		residual += DC390_read8 (Current_Fifo) & 0x1f;
-	      } while (residual && ! (dstate & SCSI_INTERRUPT) && --ctr);
-	    if (!ctr) printk (KERN_CRIT "DC390: dma_intr: DMA aborted unfinished: %06x bytes remain!!\n", DC390_read32 (DMA_Wk_ByteCntr));
-	    /* residual =  ... */
-	  }
-	else
-	    residual = 0;
-	
-	/* ??? */
-	
-	xferCnt = pSRB->SGToBeXferLen - residual;
-	pSRB->SGBusAddr += xferCnt;
-	pSRB->TotalXferredLen += xferCnt;
-	pSRB->SGToBeXferLen = residual;
-# ifdef DC390_DEBUG0
-	printk (KERN_INFO "DC390: DMA: residual = %i, xfer = %i\n", 
-		(unsigned int)residual, (unsigned int)xferCnt);
-# endif
-	
-	DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-    }
-  dc390_laststatus &= ~0xff000000; dc390_laststatus |= dstate << 24;
-  return dstate;
-}
-#endif
-
-
-static void __inline__
-dc390_InvalidCmd(struct dc390_acb* pACB)
-{
-	if (pACB->pActiveDCB->pActiveSRB->SRBState & (SRB_START_ | SRB_MSGOUT))
-		DC390_write8(ScsiCmd, CLEAR_FIFO_CMD);
-}
-
-
-static irqreturn_t __inline__
-DC390_Interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-    struct dc390_acb *pACB, *pACB2;
-    struct dc390_dcb *pDCB;
-    struct dc390_srb *pSRB;
-    u8  sstatus=0;
-    u8  phase;
-    void   (*stateV)( struct dc390_acb*, struct dc390_srb*, u8 *);
-    u8  istate, istatus;
-#if DMA_INT
-    u8  dstatus;
-#endif
-
-    pACB = (struct dc390_acb*)dev_id;
-    for (pACB2 = dc390_pACB_start; (pACB2 && pACB2 != pACB); pACB2 = pACB2->pNextACB);
-    if (!pACB2)
-    {
-	printk ("DC390: IRQ called with foreign dev_id %p!\n", pACB);
-	return IRQ_NONE;
-    }
-    
-    sstatus = DC390_read8 (Scsi_Status);
-    if( !(sstatus & INTERRUPT) )
-	return IRQ_NONE;
-
-    DEBUG1(printk (KERN_DEBUG "sstatus=%02x,", sstatus));
-
-#if DMA_INT
-    spin_lock_irq(pACB->pScsiHost->host_lock);
-    dstatus = dc390_dma_intr (pACB);
-    spin_unlock_irq(pACB->pScsiHost->host_lock);
-
-    DEBUG1(printk (KERN_DEBUG "dstatus=%02x,", dstatus));
-    if (! (dstatus & SCSI_INTERRUPT))
-      {
-	DEBUG0(printk (KERN_WARNING "DC390 Int w/o SCSI actions (only DMA?)\n"));
-	return IRQ_NONE;
-      }
-#else
-    //DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | EN_INT_ON_PCI_ABORT);
-    //dstatus = DC390_read8 (DMA_Status);
-    //DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT);
-#endif
-
-    spin_lock_irq(pACB->pScsiHost->host_lock);
-
-    istate = DC390_read8 (Intern_State);
-    istatus = DC390_read8 (INT_Status); /* This clears Scsi_Status, Intern_State and INT_Status ! */
-
-    DEBUG1(printk (KERN_INFO "Istatus(Res,Inv,Dis,Serv,Succ,ReS,SelA,Sel)=%02x,",istatus));
-    dc390_laststatus &= ~0x00ffffff;
-    dc390_laststatus |= /* dstatus<<24 | */ sstatus<<16 | istate<<8 | istatus;
-
-    if (sstatus & ILLEGAL_OP_ERR)
-    {
-	printk ("DC390: Illegal Operation detected (%08x)!\n", dc390_laststatus);
-	dc390_dumpinfo (pACB, pACB->pActiveDCB, pACB->pActiveDCB->pActiveSRB);
-    }
-	
-    else if (istatus &  INVALID_CMD)
-    {
-	printk ("DC390: Invalid Command detected (%08x)!\n", dc390_laststatus);
-	dc390_InvalidCmd( pACB );
-	goto unlock;
-    }
-
-    if (istatus &  SCSI_RESET)
-    {
-	dc390_ScsiRstDetect( pACB );
-	goto unlock;
-    }
-
-    if (istatus &  DISCONNECTED)
-    {
-	dc390_Disconnect( pACB );
-	goto unlock;
-    }
-
-    if (istatus &  RESELECTED)
-    {
-	dc390_Reselect( pACB );
-	goto unlock;
-    }
-
-    else if (istatus & (SELECTED | SEL_ATTENTION))
-    {
-	printk (KERN_ERR "DC390: Target mode not supported!\n");
-	goto unlock;
-    }
-
-    if (istatus & (SUCCESSFUL_OP|SERVICE_REQUEST) )
-    {
-	pDCB = pACB->pActiveDCB;
-	if (!pDCB)
-	{
-		printk (KERN_ERR "DC390: Suc. op/ Serv. req: pActiveDCB = 0!\n");
-		goto unlock;
-	}
-	pSRB = pDCB->pActiveSRB;
-	if( pDCB->DCBFlag & ABORT_DEV_ )
-	  dc390_EnableMsgOut_Abort (pACB, pSRB);
-
-	phase = pSRB->ScsiPhase;
-	DEBUG1(printk (KERN_INFO "DC390: [%i]%s(0) (%02x)\n", phase, dc390_p0_str[phase], sstatus));
-	stateV = (void *) dc390_phase0[phase];
-	( *stateV )( pACB, pSRB, &sstatus );
-
-	pSRB->ScsiPhase = sstatus & 7;
-	phase = (u8) sstatus & 7;
-	DEBUG1(printk (KERN_INFO "DC390: [%i]%s(1) (%02x)\n", phase, dc390_p1_str[phase], sstatus));
-	stateV = (void *) dc390_phase1[phase];
-	( *stateV )( pACB, pSRB, &sstatus );
-    }
-
- unlock:
-    spin_unlock_irq(pACB->pScsiHost->host_lock);
-    return IRQ_HANDLED;
-}
-
-static irqreturn_t do_DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs)
-{
-    irqreturn_t ret;
-    DEBUG1(printk (KERN_INFO "DC390: Irq (%i) caught: ", irq));
-    /* Locking is done in DC390_Interrupt */
-    ret = DC390_Interrupt(irq, dev_id, regs);
-    DEBUG1(printk (".. IRQ returned\n"));
-    return ret;
-}
-
-static void
-dc390_DataOut_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    u8   sstatus;
-    struct scatterlist *psgl;
-    u32    ResidCnt, xferCnt;
-    u8   dstate = 0;
-
-    sstatus = *psstatus;
-
-    if( !(pSRB->SRBState & SRB_XFERPAD) )
-    {
-	if( sstatus & (PARITY_ERR | ILLEGAL_OP_ERR) )
-	    pSRB->SRBStatus |= PARITY_ERROR;
-
-	if( sstatus & COUNT_2_ZERO )
-	{
-	    unsigned long timeout = jiffies + HZ;
-
-	    /* Function called from the ISR with the host_lock held and interrupts disabled */
-	    if (pSRB->SGToBeXferLen)
-		while (time_before(jiffies, timeout) && !((dstate = DC390_read8 (DMA_Status)) & DMA_XFER_DONE)) {
-		    spin_unlock_irq(pACB->pScsiHost->host_lock);
-		    udelay(50);
-		    spin_lock_irq(pACB->pScsiHost->host_lock);
-		}
-	    if (!time_before(jiffies, timeout))
-		printk (KERN_CRIT "DC390: Deadlock in DataOut_0: DMA aborted unfinished: %06x bytes remain!!\n",
-			DC390_read32 (DMA_Wk_ByteCntr));
-	    dc390_laststatus &= ~0xff000000;
-	    dc390_laststatus |= dstate << 24;
-	    pSRB->TotalXferredLen += pSRB->SGToBeXferLen;
-	    pSRB->SGIndex++;
-	    if( pSRB->SGIndex < pSRB->SGcount )
-	    {
-		pSRB->pSegmentList++;
-		psgl = pSRB->pSegmentList;
-
-		pSRB->SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
-		pSRB->SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
-	    }
-	    else
-		pSRB->SGToBeXferLen = 0;
-	}
-	else
-	{
-	    ResidCnt  = (u32) DC390_read8 (Current_Fifo) & 0x1f;
-	    ResidCnt |= (u32) DC390_read8 (CtcReg_High) << 16;
-	    ResidCnt |= (u32) DC390_read8 (CtcReg_Mid) << 8; 
-	    ResidCnt += (u32) DC390_read8 (CtcReg_Low);
-
-	    xferCnt = pSRB->SGToBeXferLen - ResidCnt;
-	    pSRB->SGBusAddr += xferCnt;
-	    pSRB->TotalXferredLen += xferCnt;
-	    pSRB->SGToBeXferLen = ResidCnt;
-	}
-    }
-    if ((*psstatus & 7) != SCSI_DATA_OUT)
-    {
-	    DC390_write8 (DMA_Cmd, WRITE_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
-	    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    }	    
-}
-
-static void
-dc390_DataIn_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    u8   sstatus, residual, bval;
-    struct scatterlist *psgl;
-    u32    ResidCnt, i;
-    unsigned long   xferCnt;
-    u8      *ptr;
-
-    sstatus = *psstatus;
-
-    if( !(pSRB->SRBState & SRB_XFERPAD) )
-    {
-	if( sstatus & (PARITY_ERR | ILLEGAL_OP_ERR))
-	    pSRB->SRBStatus |= PARITY_ERROR;
-
-	if( sstatus & COUNT_2_ZERO )
-	{
-	    int dstate = 0;
-	    unsigned long timeout = jiffies + HZ;
-
-	    /* Function called from the ISR with the host_lock held and interrupts disabled */
-	    if (pSRB->SGToBeXferLen)
-		while (time_before(jiffies, timeout) && !((dstate = DC390_read8 (DMA_Status)) & DMA_XFER_DONE)) {
-		    spin_unlock_irq(pACB->pScsiHost->host_lock);
-		    udelay(50);
-		    spin_lock_irq(pACB->pScsiHost->host_lock);
-		}
-	    if (!time_before(jiffies, timeout)) {
-		printk (KERN_CRIT "DC390: Deadlock in DataIn_0: DMA aborted unfinished: %06x bytes remain!!\n",
-			DC390_read32 (DMA_Wk_ByteCntr));
-		printk (KERN_CRIT "DC390: DataIn_0: DMA State: %i\n", dstate);
-	    }
-	    dc390_laststatus &= ~0xff000000;
-	    dc390_laststatus |= dstate << 24;
-	    DEBUG1(ResidCnt = ((unsigned long) DC390_read8 (CtcReg_High) << 16)	\
-		+ ((unsigned long) DC390_read8 (CtcReg_Mid) << 8)		\
-		+ ((unsigned long) DC390_read8 (CtcReg_Low)));
-	    DEBUG1(printk (KERN_DEBUG "Count_2_Zero (ResidCnt=%i,ToBeXfer=%li),", ResidCnt, pSRB->SGToBeXferLen));
-
-	    DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
-
-	    pSRB->TotalXferredLen += pSRB->SGToBeXferLen;
-	    pSRB->SGIndex++;
-	    if( pSRB->SGIndex < pSRB->SGcount )
-	    {
-		pSRB->pSegmentList++;
-		psgl = pSRB->pSegmentList;
-
-		pSRB->SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
-		pSRB->SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
-	    }
-	    else
-		pSRB->SGToBeXferLen = 0;
-	}
-	else	/* phase changed */
-	{
-	    residual = 0;
-	    bval = DC390_read8 (Current_Fifo);
-	    while( bval & 0x1f )
-	    {
-		DEBUG1(printk (KERN_DEBUG "Check for residuals,"));
-		if( (bval & 0x1f) == 1 )
-		{
-		    for(i=0; i < 0x100; i++)
-		    {
-			bval = DC390_read8 (Current_Fifo);
-			if( !(bval & 0x1f) )
-			    goto din_1;
-			else if( i == 0x0ff )
-			{
-			    residual = 1;   /* ;1 residual byte */
-			    goto din_1;
-			}
-		    }
-		}
-		else
-		    bval = DC390_read8 (Current_Fifo);
-	    }
-din_1:
-	    DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_BLAST_CMD);
-	    for (i = 0xa000; i; i--)
-	    {
-		bval = DC390_read8 (DMA_Status);
-		if (bval & BLAST_COMPLETE)
-		    break;
-	    }
-	    /* It seems a DMA Blast abort isn't that bad ... */
-	    if (!i) printk (KERN_ERR "DC390: DMA Blast aborted unfinished!\n");
-	    //DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
-	    dc390_laststatus &= ~0xff000000; dc390_laststatus |= bval << 24;
-
-	    DEBUG1(printk (KERN_DEBUG "Blast: Read %i times DMA_Status %02x", 0xa000-i, bval));
-	    ResidCnt = (u32) DC390_read8 (CtcReg_High);
-	    ResidCnt <<= 8;
-	    ResidCnt |= (u32) DC390_read8 (CtcReg_Mid);
-	    ResidCnt <<= 8;
-	    ResidCnt |= (u32) DC390_read8 (CtcReg_Low);
-
-	    xferCnt = pSRB->SGToBeXferLen - ResidCnt;
-	    pSRB->SGBusAddr += xferCnt;
-	    pSRB->TotalXferredLen += xferCnt;
-	    pSRB->SGToBeXferLen = ResidCnt;
-
-	    if( residual )
-	    {
-		bval = DC390_read8 (ScsiFifo);	    /* get one residual byte */
-		ptr = (u8 *) bus_to_virt( pSRB->SGBusAddr );
-		*ptr = bval;
-		pSRB->SGBusAddr++; xferCnt++;
-		pSRB->TotalXferredLen++;
-		pSRB->SGToBeXferLen--;
-	    }
-	    DEBUG1(printk (KERN_DEBUG "Xfered: %li, Total: %li, Remaining: %li\n", xferCnt,\
-			   pSRB->TotalXferredLen, pSRB->SGToBeXferLen));
-
-	}
-    }
-    if ((*psstatus & 7) != SCSI_DATA_IN)
-    {
-	    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-	    DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
-    }
-}
-
-static void
-dc390_Command_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-}
-
-static void
-dc390_Status_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-
-    pSRB->TargetStatus = DC390_read8 (ScsiFifo);
-    //udelay (1);
-    pSRB->EndMessage = DC390_read8 (ScsiFifo);	/* get message */
-
-    *psstatus = SCSI_NOP0;
-    pSRB->SRBState = SRB_COMPLETED;
-    DC390_write8 (ScsiCmd, MSG_ACCEPTED_CMD);
-}
-
-static void
-dc390_MsgOut_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    if( pSRB->SRBState & (SRB_UNEXPECT_RESEL+SRB_ABORT_SENT) )
-	*psstatus = SCSI_NOP0;
-    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-}
-
-
-static void __inline__
-dc390_reprog (struct dc390_acb* pACB, struct dc390_dcb* pDCB)
-{
-  DC390_write8 (Sync_Period, pDCB->SyncPeriod);
-  DC390_write8 (Sync_Offset, pDCB->SyncOffset);
-  DC390_write8 (CtrlReg3, pDCB->CtrlR3);
-  DC390_write8 (CtrlReg4, pDCB->CtrlR4);
-  dc390_SetXferRate (pACB, pDCB);
-}
-
-
-#ifdef DC390_DEBUG0
-static void
-dc390_printMsg (u8 *MsgBuf, u8 len)
-{
-  int i;
-  printk (" %02x", MsgBuf[0]);
-  for (i = 1; i < len; i++)
-    printk (" %02x", MsgBuf[i]);
-  printk ("\n");
-}
-#endif
-
-#define DC390_ENABLE_MSGOUT DC390_write8 (ScsiCmd, SET_ATN_CMD)
-
-/* reject_msg */
-static void __inline__
-dc390_MsgIn_reject (struct dc390_acb* pACB, struct dc390_srb* pSRB)
-{
-  pSRB->MsgOutBuf[0] = MESSAGE_REJECT;
-  pSRB->MsgCnt = 1; DC390_ENABLE_MSGOUT;
-  DEBUG0 (printk (KERN_INFO "DC390: Reject message\n"));
-}
-
-/* abort command */
-static void
-dc390_EnableMsgOut_Abort ( struct dc390_acb* pACB, struct dc390_srb* pSRB )
-{
-    pSRB->MsgOutBuf[0] = ABORT; 
-    pSRB->MsgCnt = 1; DC390_ENABLE_MSGOUT;
-    pSRB->pSRBDCB->DCBFlag &= ~ABORT_DEV_;
-}
-
-static struct dc390_srb*
-dc390_MsgIn_QTag (struct dc390_acb* pACB, struct dc390_dcb* pDCB, u8 tag)
-{
-  struct dc390_srb* lastSRB = pDCB->pGoingLast;
-  struct dc390_srb* pSRB = pDCB->pGoingSRB;
-
-  if (pSRB)
-    {
-      for( ;pSRB ; )
-	{
-	  if (pSRB->TagNumber == tag) break;
-	  if (pSRB == lastSRB) goto mingx0;
-	  pSRB = pSRB->pNextSRB;
-	}
-
-      if( pDCB->DCBFlag & ABORT_DEV_ )
-	{
-	  pSRB->SRBState = SRB_ABORT_SENT;
-	  dc390_EnableMsgOut_Abort( pACB, pSRB );
-	}
-
-      if( !(pSRB->SRBState & SRB_DISCONNECT) )
-	goto  mingx0;
-
-      pDCB->pActiveSRB = pSRB;
-      pSRB->SRBState = SRB_DATA_XFER;
-    }
-  else
-    {
-    mingx0:
-      pSRB = pACB->pTmpSRB;
-      pSRB->SRBState = SRB_UNEXPECT_RESEL;
-      pDCB->pActiveSRB = pSRB;
-      pSRB->MsgOutBuf[0] = ABORT_TAG;
-      pSRB->MsgCnt = 1; DC390_ENABLE_MSGOUT;
-    }
-  return pSRB;
-}
-
-
-/* set async transfer mode */
-static void 
-dc390_MsgIn_set_async (struct dc390_acb* pACB, struct dc390_srb* pSRB)
-{
-  struct dc390_dcb* pDCB = pSRB->pSRBDCB;
-  if (!(pSRB->SRBState & DO_SYNC_NEGO)) 
-    printk (KERN_INFO "DC390: Target %i initiates Non-Sync?\n", pDCB->TargetID);
-  pSRB->SRBState &= ~DO_SYNC_NEGO;
-  pDCB->SyncMode &= ~(SYNC_ENABLE+SYNC_NEGO_DONE);
-  pDCB->SyncPeriod = 0;
-  pDCB->SyncOffset = 0;
-  //pDCB->NegoPeriod = 50; /* 200ns <=> 5 MHz */
-  pDCB->CtrlR3 = FAST_CLK;	/* fast clock / normal scsi */
-  pDCB->CtrlR4 &= 0x3f;
-  pDCB->CtrlR4 |= pACB->glitch_cfg;	/* glitch eater */
-  dc390_reprog (pACB, pDCB);
-}
-
-/* set sync transfer mode */
-static void
-dc390_MsgIn_set_sync (struct dc390_acb* pACB, struct dc390_srb* pSRB)
-{
-  u8 bval;
-  u16 wval, wval1;
-  struct dc390_dcb* pDCB = pSRB->pSRBDCB;
-  u8 oldsyncperiod = pDCB->SyncPeriod;
-  u8 oldsyncoffset = pDCB->SyncOffset;
-  
-  if (!(pSRB->SRBState & DO_SYNC_NEGO))
-    {
-      printk (KERN_INFO "DC390: Target %i initiates Sync: %ins %i ... answer ...\n", 
-	      pDCB->TargetID, pSRB->MsgInBuf[3]<<2, pSRB->MsgInBuf[4]);
-
-      /* reject */
-      //dc390_MsgIn_reject (pACB, pSRB);
-      //return dc390_MsgIn_set_async (pACB, pSRB);
-
-      /* Reply with corrected SDTR Message */
-      if (pSRB->MsgInBuf[4] > 15)
-	{ 
-	  printk (KERN_INFO "DC390: Lower Sync Offset to 15\n");
-	  pSRB->MsgInBuf[4] = 15;
-	}
-      if (pSRB->MsgInBuf[3] < pDCB->NegoPeriod)
-	{
-	  printk (KERN_INFO "DC390: Set sync nego period to %ins\n", pDCB->NegoPeriod << 2);
-	  pSRB->MsgInBuf[3] = pDCB->NegoPeriod;
-	}
-      memcpy (pSRB->MsgOutBuf, pSRB->MsgInBuf, 5);
-      pSRB->MsgCnt = 5;
-      DC390_ENABLE_MSGOUT;
-    }
-
-  pSRB->SRBState &= ~DO_SYNC_NEGO;
-  pDCB->SyncMode |= SYNC_ENABLE+SYNC_NEGO_DONE;
-  pDCB->SyncOffset &= 0x0f0;
-  pDCB->SyncOffset |= pSRB->MsgInBuf[4];
-  pDCB->NegoPeriod = pSRB->MsgInBuf[3];
-
-  wval = (u16) pSRB->MsgInBuf[3];
-  wval = wval << 2; wval -= 3; wval1 = wval / 25;	/* compute speed */
-  if( (wval1 * 25) != wval) wval1++;
-  bval = FAST_CLK+FAST_SCSI;	/* fast clock / fast scsi */
-
-  pDCB->CtrlR4 &= 0x3f;		/* Glitch eater: 12ns less than normal */
-  if (pACB->glitch_cfg != NS_TO_GLITCH(0))
-    pDCB->CtrlR4 |= NS_TO_GLITCH(((GLITCH_TO_NS(pACB->glitch_cfg)) - 1));
-  else
-    pDCB->CtrlR4 |= NS_TO_GLITCH(0);
-  if (wval1 < 4) pDCB->CtrlR4 |= NS_TO_GLITCH(0); /* Ultra */
-
-  if (wval1 >= 8)
-    {
-      wval1--;	/* Timing computation differs by 1 from FAST_SCSI */
-      bval = FAST_CLK;		/* fast clock / normal scsi */
-      pDCB->CtrlR4 |= pACB->glitch_cfg; 	/* glitch eater */
-    }
-
-  pDCB->CtrlR3 = bval;
-  pDCB->SyncPeriod = (u8)wval1;
-  
-  if ((oldsyncperiod != wval1 || oldsyncoffset != pDCB->SyncOffset) && pDCB->TargetLUN == 0)
-    {
-      if (! (bval & FAST_SCSI)) wval1++;
-      printk (KERN_INFO "DC390: Target %i: Sync transfer %i.%1i MHz, Offset %i\n", pDCB->TargetID, 
-	      40/wval1, ((40%wval1)*10+wval1/2)/wval1, pDCB->SyncOffset & 0x0f);
-    }
-  
-  dc390_reprog (pACB, pDCB);
-}
-
-
-/* handle RESTORE_PTR */
-/* I presume, this command is already mapped, so, have to remap. */
-static void 
-dc390_restore_ptr (struct dc390_acb* pACB, struct dc390_srb* pSRB)
-{
-    struct scsi_cmnd *pcmd = pSRB->pcmd;
-    struct scatterlist *psgl;
-    pSRB->TotalXferredLen = 0;
-    pSRB->SGIndex = 0;
-    if (pcmd->use_sg) {
-	pSRB->pSegmentList = (struct scatterlist *)pcmd->request_buffer;
-	psgl = pSRB->pSegmentList;
-	//dc390_pci_sync(pSRB);
-
-	while (pSRB->TotalXferredLen + (unsigned long) sg_dma_len(psgl) < pSRB->Saved_Ptr)
-	{
-	    pSRB->TotalXferredLen += (unsigned long) sg_dma_len(psgl);
-	    pSRB->SGIndex++;
-	    if( pSRB->SGIndex < pSRB->SGcount )
-	    {
-		pSRB->pSegmentList++;
-		psgl = pSRB->pSegmentList;
-		pSRB->SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
-		pSRB->SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
-	    }
-	    else
-		pSRB->SGToBeXferLen = 0;
-	}
-	pSRB->SGToBeXferLen -= (pSRB->Saved_Ptr - pSRB->TotalXferredLen);
-	pSRB->SGBusAddr += (pSRB->Saved_Ptr - pSRB->TotalXferredLen);
-	printk (KERN_INFO "DC390: Pointer restored. Segment %i, Total %li, Bus %08lx\n",
-		pSRB->SGIndex, pSRB->Saved_Ptr, pSRB->SGBusAddr);
-
-    } else if(pcmd->request_buffer) {
-	//dc390_pci_sync(pSRB);
-
-	sg_dma_len(&pSRB->Segmentx) = pcmd->request_bufflen - pSRB->Saved_Ptr;
-	pSRB->SGcount = 1;
-	pSRB->pSegmentList = (struct scatterlist *) &pSRB->Segmentx;
-    } else {
-	 pSRB->SGcount = 0;
-	 printk (KERN_INFO "DC390: RESTORE_PTR message for Transfer without Scatter-Gather ??\n");
-    }
-
-  pSRB->TotalXferredLen = pSRB->Saved_Ptr;
-}
-
-
-/* According to the docs, the AM53C974 reads the message and 
- * generates a Successful Operation IRQ before asserting ACK for
- * the last byte (how does it know whether it's the last ?) */
-/* The old code handled it in another way, indicating, that on
- * every message byte an IRQ is generated and every byte has to
- * be manually ACKed. Hmmm ?  (KG, 98/11/28) */
-/* The old implementation was correct. Sigh! */
-
-/* Check if the message is complete */
-static u8 __inline__
-dc390_MsgIn_complete (u8 *msgbuf, u32 len)
-{ 
-  if (*msgbuf == EXTENDED_MESSAGE)
-  {
-	if (len < 2) return 0;
-	if (len < msgbuf[1] + 2) return 0;
-  }
-  else if (*msgbuf >= 0x20 && *msgbuf <= 0x2f) // two byte messages
-	if (len < 2) return 0;
-  return 1;
-}
-
-
-
-/* read and eval received messages */
-static void
-dc390_MsgIn_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    struct dc390_dcb*   pDCB = pACB->pActiveDCB;
-
-    /* Read the msg */
-
-    pSRB->MsgInBuf[pACB->MsgLen++] = DC390_read8 (ScsiFifo);
-    //pSRB->SRBState = 0;
-
-    /* Msg complete ? */
-    if (dc390_MsgIn_complete (pSRB->MsgInBuf, pACB->MsgLen))
-      {
-	DEBUG0 (printk (KERN_INFO "DC390: MsgIn:"); dc390_printMsg (pSRB->MsgInBuf, pACB->MsgLen));
-	/* Now eval the msg */
-	switch (pSRB->MsgInBuf[0]) 
-	  {
-	  case DISCONNECT: 
-	    pSRB->SRBState = SRB_DISCONNECT; break;
-	    
-	  case SIMPLE_QUEUE_TAG:
-	  case HEAD_OF_QUEUE_TAG:
-	  case ORDERED_QUEUE_TAG:
-	    pSRB = dc390_MsgIn_QTag (pACB, pDCB, pSRB->MsgInBuf[1]);
-	    break;
-	    
-	  case MESSAGE_REJECT: 
-	    DC390_write8 (ScsiCmd, RESET_ATN_CMD);
-	    pDCB->NegoPeriod = 50; /* 200ns <=> 5 MHz */
-	    if( pSRB->SRBState & DO_SYNC_NEGO)
-	      dc390_MsgIn_set_async (pACB, pSRB);
-	    break;
-	    
-	  case EXTENDED_MESSAGE:
-	    /* reject every extended msg but SDTR */
-	    if (pSRB->MsgInBuf[1] != 3 || pSRB->MsgInBuf[2] != EXTENDED_SDTR)
-	      dc390_MsgIn_reject (pACB, pSRB);
-	    else
-	      {
-		if (pSRB->MsgInBuf[3] == 0 || pSRB->MsgInBuf[4] == 0)
-		  dc390_MsgIn_set_async (pACB, pSRB);
-		else
-		  dc390_MsgIn_set_sync (pACB, pSRB);
-	      }
-	    
-	    // nothing has to be done
-	  case COMMAND_COMPLETE: break;
-	    
-	    // SAVE POINTER may be ignored as we have the struct dc390_srb* associated with the
-	    // scsi command. Thanks, Gerard, for pointing it out.
-	  case SAVE_POINTERS: 
-	    pSRB->Saved_Ptr = pSRB->TotalXferredLen;
-	    break;
-	    // The device might want to restart transfer with a RESTORE
-	  case RESTORE_POINTERS:
-	    DEBUG0(printk ("DC390: RESTORE POINTER message received ... try to handle\n"));
-	    dc390_restore_ptr (pACB, pSRB);
-	    break;
-
-	    // reject unknown messages
-	  default: dc390_MsgIn_reject (pACB, pSRB);
-	  }
-	
-	/* Clear counter and MsgIn state */
-	pSRB->SRBState &= ~SRB_MSGIN;
-	pACB->MsgLen = 0;
-      }
-
-    *psstatus = SCSI_NOP0;
-    DC390_write8 (ScsiCmd, MSG_ACCEPTED_CMD);
-    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-}
-
-
-static void
-dc390_DataIO_Comm( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 ioDir)
-{
-    struct scatterlist *psgl;
-    unsigned long  lval;
-    struct dc390_dcb*   pDCB = pACB->pActiveDCB;
-
-    if (pSRB == pACB->pTmpSRB)
-    {
-	if (pDCB)
-		printk(KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (%02i-%i)\n", pDCB->TargetID, pDCB->TargetLUN);
-	else
-		printk(KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (DCB 0!)\n");
-
-	/* Try to recover - some broken disks react badly to tagged INQUIRY */
-	if (pDCB && pACB->scan_devices && pDCB->GoingSRBCnt == 1) {
-		pSRB = pDCB->pGoingSRB;
-		pDCB->pActiveSRB = pSRB;
-	} else {
-		pSRB->pSRBDCB = pDCB;
-		dc390_EnableMsgOut_Abort(pACB, pSRB);
-		if (pDCB)
-			pDCB->DCBFlag |= ABORT_DEV;
-		return;
-	}
-    }
-
-    if( pSRB->SGIndex < pSRB->SGcount )
-    {
-	DC390_write8 (DMA_Cmd, DMA_IDLE_CMD | ioDir /* | DMA_INT */);
-	if( !pSRB->SGToBeXferLen )
-	{
-	    psgl = pSRB->pSegmentList;
-	    pSRB->SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
-	    pSRB->SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
-	    DEBUG1(printk (KERN_DEBUG " DC390: Next SG segment."));
-	}
-	lval = pSRB->SGToBeXferLen;
-	DEBUG1(printk (KERN_DEBUG " DC390: Start transfer: %li bytes (address %08lx)\n", lval, pSRB->SGBusAddr));
-	DC390_write8 (CtcReg_Low, (u8) lval);
-	lval >>= 8;
-	DC390_write8 (CtcReg_Mid, (u8) lval);
-	lval >>= 8;
-	DC390_write8 (CtcReg_High, (u8) lval);
-
-	DC390_write32 (DMA_XferCnt, pSRB->SGToBeXferLen);
-	DC390_write32 (DMA_XferAddr, pSRB->SGBusAddr);
-
-	//DC390_write8 (DMA_Cmd, DMA_IDLE_CMD | ioDir); /* | DMA_INT; */
-	pSRB->SRBState = SRB_DATA_XFER;
-
-	DC390_write8 (ScsiCmd, DMA_COMMAND+INFO_XFER_CMD);
-
-	DC390_write8 (DMA_Cmd, DMA_START_CMD | ioDir | DMA_INT);
-	//DEBUG1(DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | EN_INT_ON_PCI_ABORT));
-	//DEBUG1(printk (KERN_DEBUG "DC390: DMA_Status: %02x\n", DC390_read8 (DMA_Status)));
-	//DEBUG1(DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT));
-    }
-    else    /* xfer pad */
-    {
-	if( pSRB->SGcount )
-	{
-	    pSRB->AdaptStatus = H_OVER_UNDER_RUN;
-	    pSRB->SRBStatus |= OVER_RUN;
-	    DEBUG0(printk (KERN_WARNING " DC390: Overrun -"));
-	}
-	DEBUG0(printk (KERN_WARNING " Clear transfer pad \n"));
-	DC390_write8 (CtcReg_Low, 0);
-	DC390_write8 (CtcReg_Mid, 0);
-	DC390_write8 (CtcReg_High, 0);
-
-	pSRB->SRBState |= SRB_XFERPAD;
-	DC390_write8 (ScsiCmd, DMA_COMMAND+XFER_PAD_BYTE);
-/*
-	DC390_write8 (DMA_Cmd, DMA_IDLE_CMD | ioDir); // | DMA_INT;
-	DC390_write8 (DMA_Cmd, DMA_START_CMD | ioDir | DMA_INT);
-*/
-    }
-}
-
-
-static void
-dc390_DataOutPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    dc390_DataIO_Comm (pACB, pSRB, WRITE_DIRECTION);
-}
-
-static void
-dc390_DataInPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    dc390_DataIO_Comm (pACB, pSRB, READ_DIRECTION);
-}
-
-static void
-dc390_CommandPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    struct dc390_dcb*   pDCB;
-    u8  i, cnt;
-    u8     *ptr;
-
-    DC390_write8 (ScsiCmd, RESET_ATN_CMD);
-    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    if( !(pSRB->SRBFlag & AUTO_REQSENSE) )
-    {
-	cnt = (u8) pSRB->pcmd->cmd_len;
-	ptr = (u8 *) pSRB->pcmd->cmnd;
-	for(i=0; i < cnt; i++)
-	    DC390_write8 (ScsiFifo, *(ptr++));
-    }
-    else
-    {
-	u8 bval = 0;
-	DC390_write8 (ScsiFifo, REQUEST_SENSE);
-	pDCB = pACB->pActiveDCB;
-	DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5);
-	DC390_write8 (ScsiFifo, bval);
-	DC390_write8 (ScsiFifo, bval);
-	DC390_write8 (ScsiFifo, sizeof(pSRB->pcmd->sense_buffer));
-	DC390_write8 (ScsiFifo, bval);
-	DEBUG0(printk(KERN_DEBUG "DC390: AutoReqSense (CmndPhase)!\n"));
-    }
-    pSRB->SRBState = SRB_COMMAND;
-    DC390_write8 (ScsiCmd, INFO_XFER_CMD);
-}
-
-static void
-dc390_StatusPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    pSRB->SRBState = SRB_STATUS;
-    DC390_write8 (ScsiCmd, INITIATOR_CMD_CMPLTE);
-    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-}
-
-static void
-dc390_MsgOutPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    u8   bval, i, cnt;
-    u8     *ptr;
-    struct dc390_dcb*    pDCB;
-
-    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    pDCB = pACB->pActiveDCB;
-    if( !(pSRB->SRBState & SRB_MSGOUT) )
-    {
-	cnt = pSRB->MsgCnt;
-	if( cnt )
-	{
-	    ptr = (u8 *) pSRB->MsgOutBuf;
-	    for(i=0; i < cnt; i++)
-		DC390_write8 (ScsiFifo, *(ptr++));
-	    pSRB->MsgCnt = 0;
-	    if( (pDCB->DCBFlag & ABORT_DEV_) &&
-		(pSRB->MsgOutBuf[0] == ABORT) )
-		pSRB->SRBState = SRB_ABORT_SENT;
-	}
-	else
-	{
-	    bval = ABORT;	/* ??? MSG_NOP */
-	    if( (pSRB->pcmd->cmnd[0] == INQUIRY ) ||
-		(pSRB->pcmd->cmnd[0] == REQUEST_SENSE) ||
-		(pSRB->SRBFlag & AUTO_REQSENSE) )
-	    {
-		if( pDCB->SyncMode & SYNC_ENABLE )
-		    goto  mop1;
-	    }
-	    DC390_write8 (ScsiFifo, bval);
-	}
-	DC390_write8 (ScsiCmd, INFO_XFER_CMD);
-    }
-    else
-    {
-mop1:
-        printk (KERN_ERR "DC390: OLD Sync Nego code triggered! (%i %i)\n", pDCB->TargetID, pDCB->TargetLUN);
-	DC390_write8 (ScsiFifo, EXTENDED_MESSAGE);
-	DC390_write8 (ScsiFifo, 3);	/*    ;length of extended msg */
-	DC390_write8 (ScsiFifo, EXTENDED_SDTR);	/*    ; sync nego */
-	DC390_write8 (ScsiFifo, pDCB->NegoPeriod);
-	if (pDCB->SyncOffset & 0x0f)
-		    DC390_write8 (ScsiFifo, pDCB->SyncOffset);
-	else
-		    DC390_write8 (ScsiFifo, SYNC_NEGO_OFFSET);		    
-	pSRB->SRBState |= DO_SYNC_NEGO;
-	DC390_write8 (ScsiCmd, INFO_XFER_CMD);
-    }
-}
-
-static void
-dc390_MsgInPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    if( !(pSRB->SRBState & SRB_MSGIN) )
-    {
-	pSRB->SRBState &= ~SRB_DISCONNECT;
-	pSRB->SRBState |= SRB_MSGIN;
-    }
-    DC390_write8 (ScsiCmd, INFO_XFER_CMD);
-    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-}
-
-static void
-dc390_Nop_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-}
-
-static void
-dc390_Nop_1( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
-{
-}
-
-
-static void
-dc390_SetXferRate( struct dc390_acb* pACB, struct dc390_dcb* pDCB )
-{
-    u8  bval, i, cnt;
-    struct dc390_dcb*   ptr;
-
-    if( !(pDCB->TargetLUN) )
-    {
-	if( !pACB->scan_devices )
-	{
-	    ptr = pACB->pLinkDCB;
-	    cnt = pACB->DCBCnt;
-	    bval = pDCB->TargetID;
-	    for(i=0; i<cnt; i++)
-	    {
-		if( ptr->TargetID == bval )
-		{
-		    ptr->SyncPeriod = pDCB->SyncPeriod;
-		    ptr->SyncOffset = pDCB->SyncOffset;
-		    ptr->CtrlR3 = pDCB->CtrlR3;
-		    ptr->CtrlR4 = pDCB->CtrlR4;
-		    ptr->SyncMode = pDCB->SyncMode;
-		}
-		ptr = ptr->pNextDCB;
-	    }
-	}
-    }
-    return;
-}
-
-
-static void
-dc390_Disconnect( struct dc390_acb* pACB )
-{
-    struct dc390_dcb *pDCB;
-    struct dc390_srb *pSRB, *psrb;
-    u8  i, cnt;
-
-    DEBUG0(printk(KERN_INFO "DISC,"));
-
-    if (!pACB->Connected) printk(KERN_ERR "DC390: Disconnect not-connected bus?\n");
-    pACB->Connected = 0;
-    pDCB = pACB->pActiveDCB;
-    if (!pDCB)
-     {
-	DEBUG0(printk(KERN_ERR "ACB:%p->ActiveDCB:%p IOPort:%04x IRQ:%02x !\n",\
-	       pACB, pDCB, pACB->IOPortBase, pACB->IRQLevel));
-	mdelay(400);
-	DC390_read8 (INT_Status);	/* Reset Pending INT */
-	DC390_write8 (ScsiCmd, EN_SEL_RESEL);
-	return;
-     }
-    DC390_write8 (ScsiCmd, EN_SEL_RESEL);
-    pSRB = pDCB->pActiveSRB;
-    pACB->pActiveDCB = NULL;
-    pSRB->ScsiPhase = SCSI_NOP0;
-    if( pSRB->SRBState & SRB_UNEXPECT_RESEL )
-    {
-	pSRB->SRBState = 0;
-	dc390_Waiting_process ( pACB );
-    }
-    else if( pSRB->SRBState & SRB_ABORT_SENT )
-    {
-	pDCB->TagMask = 0;
-	pDCB->DCBFlag = 0;
-	cnt = pDCB->GoingSRBCnt;
-	pDCB->GoingSRBCnt = 0;
-	pSRB = pDCB->pGoingSRB;
-	for( i=0; i < cnt; i++)
-	{
-	    psrb = pSRB->pNextSRB;
-	    dc390_Free_insert (pACB, pSRB);
-	    pSRB = psrb;
-	}
-	pDCB->pGoingSRB = NULL;
-	dc390_Waiting_process (pACB);
-    }
-    else
-    {
-	if( (pSRB->SRBState & (SRB_START_+SRB_MSGOUT)) ||
-	   !(pSRB->SRBState & (SRB_DISCONNECT+SRB_COMPLETED)) )
-	{	/* Selection time out */
-	    if( !(1/*pACB->scan_devices*/) )
-	    {
-		pSRB->SRBState = SRB_READY;
-		dc390_freetag (pDCB, pSRB);
-		dc390_Going_to_Waiting (pDCB, pSRB);
-		dc390_waiting_timer (pACB, HZ/5);
-	    }
-	    else
-	    {
-		pSRB->TargetStatus = SCSI_STAT_SEL_TIMEOUT;
-		goto  disc1;
-	    }
-	}
-	else if( pSRB->SRBState & SRB_DISCONNECT )
-	{
-	    dc390_Waiting_process ( pACB );
-	}
-	else if( pSRB->SRBState & SRB_COMPLETED )
-	{
-disc1:
-	    dc390_freetag (pDCB, pSRB);
-	    pDCB->pActiveSRB = NULL;
-	    pSRB->SRBState = SRB_FREE;
-	    dc390_SRBdone( pACB, pDCB, pSRB);
-	}
-    }
-    pACB->MsgLen = 0;
-}
-
-
-static void
-dc390_Reselect( struct dc390_acb* pACB )
-{
-    struct dc390_dcb*   pDCB;
-    struct dc390_srb*   pSRB;
-    u8  id, lun;
-
-    DEBUG0(printk(KERN_INFO "RSEL,"));
-    pACB->Connected = 1;
-    pDCB = pACB->pActiveDCB;
-    if( pDCB )
-    {	/* Arbitration lost but Reselection won */
-	DEBUG0(printk ("DC390: (ActiveDCB != 0: Arb. lost but resel. won)!\n"));
-	pSRB = pDCB->pActiveSRB;
-	if( !( pACB->scan_devices ) )
-	{
-	    pSRB->SRBState = SRB_READY;
-	    dc390_freetag (pDCB, pSRB);
-	    dc390_Going_to_Waiting ( pDCB, pSRB);
-	    dc390_waiting_timer (pACB, HZ/5);
-	}
-    }
-    /* Get ID */
-    lun = DC390_read8 (ScsiFifo);
-    DEBUG0(printk ("Dev %02x,", lun));
-    if (!(lun & (1 << pACB->pScsiHost->this_id)))
-      printk (KERN_ERR "DC390: Reselection must select host adapter: %02x!\n", lun);
-    else
-      lun ^= 1 << pACB->pScsiHost->this_id; /* Mask AdapterID */
-    id = 0; while (lun >>= 1) id++;
-    /* Get LUN */
-    lun = DC390_read8 (ScsiFifo);
-    if (!(lun & IDENTIFY_BASE)) printk (KERN_ERR "DC390: Resel: Expect identify message!\n");
-    lun &= 7;
-    DEBUG0(printk ("(%02i-%i),", id, lun));
-    pDCB = dc390_findDCB (pACB, id, lun);
-    if (!pDCB)
-    {
-	printk (KERN_ERR "DC390: Reselect from non existing device (%02i-%i)\n",
-		    id, lun);
-	return;
-    }
-    pACB->pActiveDCB = pDCB;
-    /* TagQ: We expect a message soon, so never mind the exact SRB */
-    if( pDCB->SyncMode & EN_TAG_QUEUEING )
-    {
-	pSRB = pACB->pTmpSRB;
-	pDCB->pActiveSRB = pSRB;
-    }
-    else
-    {
-	pSRB = pDCB->pActiveSRB;
-	if( !pSRB || !(pSRB->SRBState & SRB_DISCONNECT) )
-	{
-	    pSRB= pACB->pTmpSRB;
-	    pSRB->SRBState = SRB_UNEXPECT_RESEL;
-	    printk (KERN_ERR "DC390: Reselect without outstanding cmnd (%02i-%i)\n",
-		    id, lun);
-	    pDCB->pActiveSRB = pSRB;
-	    dc390_EnableMsgOut_Abort ( pACB, pSRB );
-	}
-	else
-	{
-	    if( pDCB->DCBFlag & ABORT_DEV_ )
-	    {
-		pSRB->SRBState = SRB_ABORT_SENT;
-		printk (KERN_INFO "DC390: Reselect: Abort (%02i-%i)\n",
-			id, lun);
-		dc390_EnableMsgOut_Abort( pACB, pSRB );
-	    }
-	    else
-		pSRB->SRBState = SRB_DATA_XFER;
-	}
-    }
-
-    DEBUG1(printk (KERN_DEBUG "Resel SRB(%p): TagNum (%02x)\n", pSRB, pSRB->TagNumber));
-    pSRB->ScsiPhase = SCSI_NOP0;
-    DC390_write8 (Scsi_Dest_ID, pDCB->TargetID);
-    DC390_write8 (Sync_Period, pDCB->SyncPeriod);
-    DC390_write8 (Sync_Offset, pDCB->SyncOffset);
-    DC390_write8 (CtrlReg1, pDCB->CtrlR1);
-    DC390_write8 (CtrlReg3, pDCB->CtrlR3);
-    DC390_write8 (CtrlReg4, pDCB->CtrlR4);	/* ; Glitch eater */
-    DC390_write8 (ScsiCmd, MSG_ACCEPTED_CMD);	/* ;to release the /ACK signal */
-}
-
-static u8 __inline__
-dc390_tagq_blacklist (char* name)
-{
-   u8 i;
-   for(i=0; i<BADDEVCNT; i++)
-     if (memcmp (name, dc390_baddevname1[i], 28) == 0)
-	return 1;
-   return 0;
-}
-   
-
-static void 
-dc390_disc_tagq_set (struct dc390_dcb* pDCB, PSCSI_INQDATA ptr)
-{
-   /* Check for SCSI format (ANSI and Response data format) */
-   if ( (ptr->Vers & 0x07) >= 2 || (ptr->RDF & 0x0F) == 2 )
-   {
-	if ( (ptr->Flags & SCSI_INQ_CMDQUEUE) &&
-	    (pDCB->DevMode & TAG_QUEUEING_) &&
-	    /* ((pDCB->DevType == TYPE_DISK) 
-		|| (pDCB->DevType == TYPE_MOD)) &&*/
-	    !dc390_tagq_blacklist (((char*)ptr)+8) )
-	  {
-	     if (pDCB->MaxCommand ==1) pDCB->MaxCommand = pDCB->pDCBACB->TagMaxNum;
-	     pDCB->SyncMode |= EN_TAG_QUEUEING /* | EN_ATN_STOP */;
-	     //pDCB->TagMask = 0;
-	  }
-	else
-	     pDCB->MaxCommand = 1;
-     }
-}
-
-
-static void 
-dc390_add_dev (struct dc390_acb* pACB, struct dc390_dcb* pDCB, PSCSI_INQDATA ptr)
-{
-   u8 bval1 = ptr->DevType & SCSI_DEVTYPE;
-   pDCB->DevType = bval1;
-   /* if (bval1 == TYPE_DISK || bval1 == TYPE_MOD) */
-	dc390_disc_tagq_set (pDCB, ptr);
-}
-
-
-static void __inline__
-dc390_RequestSense(struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
-{
-	struct scsi_cmnd *pcmd;
-
-	pcmd = pSRB->pcmd;
-
-	REMOVABLEDEBUG(printk(KERN_INFO "DC390: RequestSense(Cmd %02x, Id %02x, LUN %02x)\n",\
-			      pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN));
-
-	pSRB->SRBFlag |= AUTO_REQSENSE;
-	pSRB->SavedSGCount = pcmd->use_sg;
-	pSRB->SavedTotXLen = pSRB->TotalXferredLen;
-	pSRB->AdaptStatus = 0;
-	pSRB->TargetStatus = 0; /* CHECK_CONDITION<<1; */
-
-	/* We are called from SRBdone, original PCI mapping has been removed
-	 * already, new one is set up from StartSCSI */
-	pSRB->SGIndex = 0;
-
-	pSRB->TotalXferredLen = 0;
-	pSRB->SGToBeXferLen = 0;
-	if (dc390_StartSCSI(pACB, pDCB, pSRB)) {
-		dc390_Going_to_Waiting(pDCB, pSRB);
-		dc390_waiting_timer(pACB, HZ/5);
-	}
-}
-
-
-static void
-dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB )
-{
-    u8  bval, status, i;
-    struct scsi_cmnd *pcmd;
-    PSCSI_INQDATA  ptr;
-    struct scatterlist *ptr2;
-    unsigned long  swlval;
-
-    pcmd = pSRB->pcmd;
-    /* KG: Moved pci_unmap here */
-    dc390_pci_unmap(pSRB);
-
-    status = pSRB->TargetStatus;
-    if (pcmd->use_sg) {
-	    ptr2 = (struct scatterlist *) (pcmd->request_buffer);
-	    ptr = (PSCSI_INQDATA) (page_address(ptr2->page) + ptr2->offset);
-    } else
-	    ptr = (PSCSI_INQDATA) (pcmd->request_buffer);
-	
-    DEBUG0(printk (" SRBdone (%02x,%08x), SRB %p, pid %li\n", status, pcmd->result,\
-		pSRB, pcmd->pid));
-    if(pSRB->SRBFlag & AUTO_REQSENSE)
-    {	/* Last command was a Request Sense */
-	pSRB->SRBFlag &= ~AUTO_REQSENSE;
-	pSRB->AdaptStatus = 0;
-	pSRB->TargetStatus = CHECK_CONDITION << 1;
-
-	//pcmd->result = MK_RES(DRIVER_SENSE,DID_OK,0,status);
-	if (status == (CHECK_CONDITION << 1))
-	{
-	    pcmd->result = MK_RES_LNX(0,DID_BAD_TARGET,0,/*CHECK_CONDITION*/0);
-	    goto ckc_e;
-	}
-	if(pSRB->RetryCnt == 0)
-	{
-	    //(u32)(pSRB->pcmd->cmnd[0]) = pSRB->Segment0[0];
-	    pSRB->TotalXferredLen = pSRB->SavedTotXLen;
-	    if( (pSRB->TotalXferredLen) &&
-		(pSRB->TotalXferredLen >= pcmd->underflow) )
-		  SET_RES_DID(pcmd->result,DID_OK)
-	    else
-		  pcmd->result = MK_RES_LNX(DRIVER_SENSE,DID_OK,0,CHECK_CONDITION);
-		  REMOVABLEDEBUG(printk(KERN_INFO "Cmd=%02x,Result=%08x,XferL=%08x\n",pSRB->pcmd->cmnd[0],\
-			(u32) pcmd->result, (u32) pSRB->TotalXferredLen));
-	    goto ckc_e;
-	}
-	else /* Retry */
-	{
-	    pSRB->RetryCnt--;
-	    pSRB->AdaptStatus = 0;
-	    pSRB->TargetStatus = 0;
-	    /* Don't retry on TEST_UNIT_READY */
-	    if( pSRB->pcmd->cmnd[0] == TEST_UNIT_READY /* || pSRB->pcmd->cmnd[0] == START_STOP */)
-	    {
-		pcmd->result = MK_RES_LNX(DRIVER_SENSE,DID_OK,0,CHECK_CONDITION);
-		REMOVABLEDEBUG(printk(KERN_INFO "Cmd=%02x, Result=%08x, XferL=%08x\n",pSRB->pcmd->cmnd[0],\
-		       (u32) pcmd->result, (u32) pSRB->TotalXferredLen));
-		goto ckc_e;
-	    }
-	    SET_RES_DRV(pcmd->result,DRIVER_SENSE);
-	    pcmd->use_sg	 = pSRB->SavedSGCount;
-	    //pSRB->ScsiCmdLen	 = (u8) (pSRB->Segment1[0] >> 8);
-	    DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
-	    pSRB->SGIndex = 0;
-	    pSRB->TotalXferredLen = 0;
-	    pSRB->SGToBeXferLen = 0;
-
-	    if( dc390_StartSCSI( pACB, pDCB, pSRB ) ) {
-		dc390_Going_to_Waiting ( pDCB, pSRB );
-		dc390_waiting_timer (pACB, HZ/5);
-	    }
-	    return;
-	}
-    }
-    if( status )
-    {
-	if( status_byte(status) == CHECK_CONDITION )
-	{
-	    REMOVABLEDEBUG(printk (KERN_INFO "DC390: Check_Condition (Cmd %02x, Id %02x, LUN %02x)\n",\
-		    pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN));
-	    if( (pSRB->SGIndex < pSRB->SGcount) && (pSRB->SGcount) && (pSRB->SGToBeXferLen) )
-	    {
-		bval = pSRB->SGcount;
-		swlval = 0;
-		ptr2 = pSRB->pSegmentList;
-		for( i=pSRB->SGIndex; i < bval; i++)
-		{
-		    swlval += sg_dma_len(ptr2);
-		    ptr2++;
-		}
-		REMOVABLEDEBUG(printk(KERN_INFO "XferredLen=%08x,NotXferLen=%08x\n",\
-			(u32) pSRB->TotalXferredLen, (u32) swlval));
-	    }
-	    dc390_RequestSense( pACB, pDCB, pSRB );
-	    return;
-	}
-	else if( status_byte(status) == QUEUE_FULL )
-	{
-	    bval = (u8) pDCB->GoingSRBCnt;
-	    bval--;
-	    pDCB->MaxCommand = bval;
-	    dc390_freetag (pDCB, pSRB);
-	    dc390_Going_to_Waiting ( pDCB, pSRB );
-	    dc390_waiting_timer (pACB, HZ/5);
-	    pSRB->AdaptStatus = 0;
-	    pSRB->TargetStatus = 0;
-	    return;
-	}
-	else if(status == SCSI_STAT_SEL_TIMEOUT)
-	{
-	    pSRB->AdaptStatus = H_SEL_TIMEOUT;
-	    pSRB->TargetStatus = 0;
-	    pcmd->result = MK_RES(0,DID_NO_CONNECT,0,0);
-	    /* Devices are removed below ... */
-	}
-	else if (status_byte(status) == BUSY && 
-		 (pcmd->cmnd[0] == TEST_UNIT_READY || pcmd->cmnd[0] == INQUIRY) &&
-		 pACB->scan_devices)
-	{
-	    pSRB->AdaptStatus = 0;
-	    pSRB->TargetStatus = status;
-	    pcmd->result = MK_RES(0,0,pSRB->EndMessage,/*status*/0);
-	}
-	else
-	{   /* Another error */
-	    pSRB->AdaptStatus = 0;
-	    if( pSRB->RetryCnt )
-	    {	/* Retry */
-		//printk ("DC390: retry\n");
-		pSRB->RetryCnt--;
-		pSRB->TargetStatus = 0;
-		pSRB->SGIndex = 0;
-		pSRB->TotalXferredLen = 0;
-		pSRB->SGToBeXferLen = 0;
-		if( dc390_StartSCSI( pACB, pDCB, pSRB ) ) {
-		    dc390_Going_to_Waiting ( pDCB, pSRB );
-		    dc390_waiting_timer (pACB, HZ/5);
-		}
-      		return;
-	    }
-	    else
-	    {	/* Report error */
-	      //pcmd->result = MK_RES(0, DID_ERROR, pSRB->EndMessage, status);
-	      SET_RES_DID(pcmd->result,DID_ERROR);
-	      SET_RES_MSG(pcmd->result,pSRB->EndMessage);
-	      SET_RES_TARGET(pcmd->result,status);
-	    }
-	}
-    }
-    else
-    {	/*  Target status == 0 */
-	status = pSRB->AdaptStatus;
-	if(status & H_OVER_UNDER_RUN)
-	{
-	    pSRB->TargetStatus = 0;
-	    SET_RES_DID(pcmd->result,DID_OK);
-	    SET_RES_MSG(pcmd->result,pSRB->EndMessage);
-	}
-	else if( pSRB->SRBStatus & PARITY_ERROR)
-	{
-	    //pcmd->result = MK_RES(0,DID_PARITY,pSRB->EndMessage,0);
-	    SET_RES_DID(pcmd->result,DID_PARITY);
-	    SET_RES_MSG(pcmd->result,pSRB->EndMessage);
-	}
-	else		       /* No error */
-	{
-	    pSRB->AdaptStatus = 0;
-	    pSRB->TargetStatus = 0;
-	    SET_RES_DID(pcmd->result,DID_OK);
-	}
-    }
-    if ((pcmd->result & RES_DID) == 0 &&
-	pcmd->cmnd[0] == INQUIRY && 
-	pcmd->cmnd[2] == 0 &&
-	pcmd->request_bufflen >= 8 &&
-	ptr &&
-	(ptr->Vers & 0x07) >= 2)
-	    pDCB->Inquiry7 = ptr->Flags;
-
-ckc_e:
-    if( pcmd->cmnd[0] == INQUIRY && 
-	(pcmd->result == (DID_OK << 16) || status_byte(pcmd->result) & CHECK_CONDITION) )
-     {
-	if ((ptr->DevType & SCSI_DEVTYPE) != TYPE_NODEV)
-	  {
-	     /* device found: add */ 
-	     dc390_add_dev (pACB, pDCB, ptr);
-	  }
-     }
-
-    pcmd->resid = pcmd->request_bufflen - pSRB->TotalXferredLen;
-
-    dc390_Going_remove (pDCB, pSRB);
-    /* Add to free list */
-    dc390_Free_insert (pACB, pSRB);
-
-    DEBUG0(printk (KERN_DEBUG "DC390: SRBdone: done pid %li\n", pcmd->pid));
-    pcmd->scsi_done (pcmd);
-
-    dc390_Waiting_process (pACB);
-    return;
-}
-
-
-/* Remove all SRBs from Going list and inform midlevel */
-static void
-dc390_DoingSRB_Done(struct dc390_acb* pACB, struct scsi_cmnd *cmd)
-{
-    struct dc390_dcb *pDCB, *pdcb;
-    struct dc390_srb *psrb, *psrb2;
-    u8  i;
-    struct scsi_cmnd *pcmd;
-
-    pDCB = pACB->pLinkDCB;
-    pdcb = pDCB;
-    if (! pdcb) return;
-    do
-    {
-	psrb = pdcb->pGoingSRB;
-	for( i=0; i<pdcb->GoingSRBCnt; i++)
-	{
-	    psrb2 = psrb->pNextSRB;
-	    pcmd = psrb->pcmd;
-	    dc390_Free_insert (pACB, psrb);
-	    psrb  = psrb2;
-	}
-	pdcb->GoingSRBCnt = 0;
-	pdcb->pGoingSRB = NULL;
-	pdcb->TagMask = 0;
-	pdcb = pdcb->pNextDCB;
-    } while( pdcb != pDCB );
-}
-
-
-static void
-dc390_ResetSCSIBus( struct dc390_acb* pACB )
-{
-    //DC390_write8 (ScsiCmd, RST_DEVICE_CMD);
-    //udelay (250);
-    //DC390_write8 (ScsiCmd, NOP_CMD);
-
-    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-    DC390_write8 (ScsiCmd, RST_SCSI_BUS_CMD);
-    pACB->Connected = 0;
-
-    return;
-}
-
-static void
-dc390_ScsiRstDetect( struct dc390_acb* pACB )
-{
-    printk ("DC390: Rst_Detect: laststat = %08x\n", dc390_laststatus);
-    //DEBUG0(printk(KERN_INFO "RST_DETECT,"));
-
-    if (timer_pending (&pACB->Waiting_Timer)) del_timer (&pACB->Waiting_Timer);
-    DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-    /* Unlock before ? */
-    /* delay half a second */
-    udelay (1000);
-    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    pACB->pScsiHost->last_reset = jiffies + 5*HZ/2
-		    + HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY];
-    pACB->Connected = 0;
-
-    if( pACB->ACBFlag & RESET_DEV )
-	pACB->ACBFlag |= RESET_DONE;
-    else
-    {   /* Reset was issued by sb else */
-	pACB->ACBFlag |= RESET_DETECT;
-
-	dc390_ResetDevParam( pACB );
-	dc390_DoingSRB_Done( pACB, NULL );
-	//dc390_RecoverSRB( pACB );
-	pACB->pActiveDCB = NULL;
-	pACB->ACBFlag = 0;
-	dc390_Waiting_process( pACB );
-    }
-    return;
-}
diff -Nru a/drivers/scsi/sd.c b/drivers/scsi/sd.c
--- a/drivers/scsi/sd.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/scsi/sd.c	2004-12-24 13:37:04 -08:00
@@ -48,6 +48,7 @@
 #include <linux/blkdev.h>
 #include <linux/blkpg.h>
 #include <linux/kref.h>
+#include <linux/delay.h>
 #include <asm/uaccess.h>
 
 #include <scsi/scsi.h>
@@ -197,8 +198,8 @@
 static void scsi_disk_put(struct scsi_disk *sdkp)
 {
 	down(&sd_ref_sem);
-	scsi_device_put(sdkp->device);
 	kref_put(&sdkp->kref, scsi_disk_release);
+	scsi_device_put(sdkp->device);
 	up(&sd_ref_sem);
 }
 
@@ -573,8 +574,9 @@
 	 * may try and take the device offline, in which case all further
 	 * access to the device is prohibited.
 	 */
-	if (!scsi_block_when_processing_errors(sdp))
-		return -ENODEV;
+	error = scsi_nonblockable_ioctl(sdp, cmd, p, filp);
+	if (!scsi_block_when_processing_errors(sdp) || !error)
+		return error;
 
 	if (cmd == HDIO_GETGEO) {
 		if (!arg)
@@ -943,7 +945,6 @@
 		 * Issue command to spin up drive when not ready
 		 */
 		} else if (SRpnt->sr_sense_buffer[2] == NOT_READY) {
-			unsigned long time1;
 			if (!spintime) {
 				printk(KERN_NOTICE "%s: Spinning up disk...",
 				       diskname);
@@ -962,12 +963,8 @@
 				spintime_value = jiffies;
 			}
 			spintime = 1;
-			time1 = HZ;
 			/* Wait 1 second for next try */
-			do {
-				current->state = TASK_UNINTERRUPTIBLE;
-				time1 = schedule_timeout(time1);
-			} while(time1);
+			msleep(1000);
 			printk(".");
 		} else {
 			/* we don't understand the sense code, so it's
@@ -1107,6 +1104,11 @@
 			(buffer[9] << 16) | (buffer[10] << 8) | buffer[11];
 	}	
 
+	/* Some devices return the total number of sectors, not the
+	 * highest sector number.  Make the necessary adjustment. */
+	if (sdp->fix_capacity)
+		--sdkp->capacity;
+
 got_data:
 	if (sector_size == 0) {
 		sector_size = 512;
@@ -1128,6 +1130,13 @@
 		 * For this reason, we leave the thing in the table.
 		 */
 		sdkp->capacity = 0;
+		/*
+		 * set a bogus sector size so the normal read/write
+		 * logic in the block layer will eventually refuse any
+		 * request on this device without tripping over power
+		 * of two sector size assumptions
+		 */
+		sector_size = 512;
 	}
 	{
 		/*
diff -Nru a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c
--- a/drivers/scsi/seagate.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/seagate.c	2004-12-24 13:36:48 -08:00
@@ -237,13 +237,13 @@
 					   calculate memory mapped register
 					   location.  */
 
-static unsigned long st0x_cr_sr;	/* control register write, status
+static void __iomem *st0x_cr_sr;	/* control register write, status
 					   register read.  256 bytes in
 					   length.
 					   Read is status of SCSI BUS, as per 
 					   STAT masks.  */
 
-static unsigned long st0x_dr;	/* data register, read write 256
+static void __iomem *st0x_dr;	/* data register, read write 256
 				   bytes in length.  */
 
 static volatile int st0x_aborted = 0;	/* set when we are aborted, ie by a
@@ -254,17 +254,17 @@
 						   boards */
 static int irq = IRQ;
 
-MODULE_PARM (base_address, "i");
-MODULE_PARM (controller_type, "b");
-MODULE_PARM (irq, "i");
+module_param(base_address, uint, 0);
+module_param(controller_type, byte, 0);
+module_param(irq, int, 0);
 MODULE_LICENSE("GPL");
 
 
 #define retcode(result) (((result) << 16) | (message << 8) | status)
-#define STATUS ((u8) isa_readb(st0x_cr_sr))
-#define DATA ((u8) isa_readb(st0x_dr))
-#define WRITE_CONTROL(d) { isa_writeb((d), st0x_cr_sr); }
-#define WRITE_DATA(d) { isa_writeb((d), st0x_dr); }
+#define STATUS ((u8) readb(st0x_cr_sr))
+#define DATA ((u8) readb(st0x_dr))
+#define WRITE_CONTROL(d) { writeb((d), st0x_cr_sr); }
+#define WRITE_DATA(d) { writeb((d), st0x_dr); }
 
 #ifndef OVERRIDE
 static unsigned int seagate_bases[] = {
@@ -420,6 +420,7 @@
 {
 	struct Scsi_Host *instance;
 	int i, j;
+	unsigned long cr, dr;
 
 	tpnt->proc_name = "seagate";
 /*
@@ -454,12 +455,18 @@
  * space for the on-board RAM instead.
  */
 
-		for (i = 0; i < (sizeof (seagate_bases) / sizeof (unsigned int)); ++i)
-			for (j = 0; !base_address && j < NUM_SIGNATURES; ++j)
-				if (isa_check_signature(seagate_bases[i] + signatures[j].offset, signatures[j].signature, signatures[j].length)) {
+		for (i = 0; i < (sizeof (seagate_bases) / sizeof (unsigned int)); ++i) {
+			void __iomem *p = ioremap(seagate_bases[i], 0x2000);
+			if (!p)
+				continue;
+			for (j = 0; j < NUM_SIGNATURES; ++j)
+				if (check_signature(p + signatures[j].offset, signatures[j].signature, signatures[j].length)) {
 					base_address = seagate_bases[i];
 					controller_type = signatures[j].type;
+					break;
 				}
+			iounmap(p);
+		}
 #endif				/* OVERRIDE */
 	}
 	/* (! controller_type) */
@@ -471,11 +478,13 @@
 		return 0;
 	}
 
-	st0x_cr_sr = base_address + (controller_type == SEAGATE ? 0x1a00 : 0x1c00);
-	st0x_dr = st0x_cr_sr + 0x200;
+	cr = base_address + (controller_type == SEAGATE ? 0x1a00 : 0x1c00);
+	dr = cr + 0x200;
+	st0x_cr_sr = ioremap(cr, 0x100);
+	st0x_dr = ioremap(dr, 0x100);
 
 	DANY("%s detected. Base address = %x, cr = %x, dr = %x\n",
-	      tpnt->name, base_address, st0x_cr_sr, st0x_dr);
+	      tpnt->name, base_address, cr, dr);
 
 	/*
 	 *	At all times, we will use IRQ 5.  Should also check for IRQ3
@@ -1140,7 +1149,7 @@
 #endif
 						 "loop 1b;"
 				      /* output */ :
-				      /* input */ :"D" (phys_to_virt (st0x_dr)),
+				      /* input */ :"D" (st0x_dr),
 						 "S"
 						 (data),
 						 "c" (SCint->transfersize)
@@ -1148,19 +1157,7 @@
 				      :	 "eax", "ecx",
 						 "esi");
 #else				/* SEAGATE_USE_ASM */
-					{
-#ifdef FAST32
-						unsigned int *iop = phys_to_virt (st0x_dr);
-						const unsigned int *dp =(unsigned int *) data;
-						int xferlen = transfersize >> 2;
-#else
-						unsigned char *iop = phys_to_virt (st0x_dr);
-						const unsigned char *dp = data;
-						int xferlen = transfersize;
-#endif
-						for (; xferlen; --xferlen)
-							*iop = *dp++;
-					}
+					memcpy_toio(st0x_dr, data, transfersize);
 #endif				/* SEAGATE_USE_ASM */
 /* SJT: End */
 					len -= transfersize;
@@ -1212,10 +1209,8 @@
 							"=D" (__dummy_2)
 /* input */
 				      :		"0" (data), "1" (len),
-							"2" (phys_to_virt
-							     (st0x_cr_sr)),
-							"3" (phys_to_virt
-							     (st0x_dr))
+							"2" (st0x_cr_sr),
+							"3" (st0x_dr)
 /* clobbered */
 				      :		"eax");
 #else				/* SEAGATE_USE_ASM */
@@ -1292,7 +1287,7 @@
 #endif
 						 "loop 1b\n\t"
 				      /* output */ :
-				      /* input */ :"S" (phys_to_virt (st0x_dr)),
+				      /* input */ :"S" (st0x_dr),
 						 "D"
 						 (data),
 						 "c" (SCint->transfersize)
@@ -1300,22 +1295,7 @@
 				      :	 "eax", "ecx",
 						 "edi");
 #else				/* SEAGATE_USE_ASM */
-					{
-#ifdef FAST32
-						const unsigned int *iop =
-						    phys_to_virt (st0x_dr);
-						unsigned int *dp =
-						    (unsigned int *) data;
-						int xferlen = len >> 2;
-#else
-						const unsigned char *iop =
-						    phys_to_virt (st0x_dr);
-						unsigned char *dp = data;
-						int xferlen = len;
-#endif
-						for (; xferlen; --xferlen)
-							*dp++ = *iop;
-					}
+					memcpy_fromio(data, st0x_dr, len);
 #endif				/* SEAGATE_USE_ASM */
 /* SJT: End */
 					len -= transfersize;
@@ -1381,10 +1361,8 @@
 							"=b" (__dummy_4)
 /* input */
 				      :		"0" (data), "1" (len),
-							"2" (phys_to_virt
-							     (st0x_cr_sr)),
-							"3" (phys_to_virt
-							     (st0x_dr))
+							"2" (st0x_cr_sr),
+							"3" (st0x_dr)
 /* clobbered */
 				      :		"eax");
 #else				/* SEAGATE_USE_ASM */
diff -Nru a/drivers/scsi/sg.c b/drivers/scsi/sg.c
--- a/drivers/scsi/sg.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/scsi/sg.c	2004-12-24 13:36:48 -08:00
@@ -563,6 +563,20 @@
 	hp->usr_ptr = NULL;
 	if (__copy_from_user(cmnd, buf, cmd_size))
 		return -EFAULT;
+	/*
+	 * SG_DXFER_TO_FROM_DEV is functionally equivalent to SG_DXFER_FROM_DEV,
+	 * but is is possible that the app intended SG_DXFER_TO_DEV, because there
+	 * is a non-zero input_size, so emit a warning.
+	 */
+	if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV)
+		if (printk_ratelimit())
+			printk(KERN_WARNING
+			       "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
+			       "guessing data in;\n" KERN_WARNING "   "
+			       "program %s not setting count and/or reply_len properly\n",
+			       old_hdr.reply_len - (int)SZ_SG_HEADER,
+			       input_size, (unsigned int) cmnd[0],
+			       current->comm);
 	k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
 	return (k < 0) ? k : count;
 }
@@ -576,6 +590,7 @@
 	sg_io_hdr_t *hp;
 	unsigned char cmnd[sizeof (dummy_cmdp->sr_cmnd)];
 	int timeout;
+	unsigned long ul_timeout;
 
 	if (count < SZ_SG_IO_HDR)
 		return -EINVAL;
@@ -610,7 +625,8 @@
 			return -EBUSY;	/* reserve buffer already being used */
 		}
 	}
-	timeout = msecs_to_jiffies(srp->header.timeout);
+	ul_timeout = msecs_to_jiffies(srp->header.timeout);
+	timeout = (ul_timeout < INT_MAX) ? ul_timeout : INT_MAX;
 	if ((!hp->cmdp) || (hp->cmd_len < 6) || (hp->cmd_len > sizeof (cmnd))) {
 		sg_remove_request(sfp, srp);
 		return -EMSGSIZE;
@@ -719,6 +735,18 @@
 }
 
 static int
+sg_srp_done(Sg_request *srp, Sg_fd *sfp)
+{
+	unsigned long iflags;
+	int done;
+
+	read_lock_irqsave(&sfp->rq_list_lock, iflags);
+	done = srp->done;
+	read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
+	return done;
+}
+
+static int
 sg_ioctl(struct inode *inode, struct file *filp,
 	 unsigned int cmd_in, unsigned long arg)
 {
@@ -757,7 +785,7 @@
 			while (1) {
 				result = 0;	/* following macro to beat race condition */
 				__wait_event_interruptible(sfp->read_wait,
-					(sdp->detached || sfp->closed || srp->done),
+					(sdp->detached || sfp->closed || sg_srp_done(srp, sfp)),
 							   result);
 				if (sdp->detached)
 					return -ENODEV;
@@ -768,7 +796,9 @@
 				srp->orphan = 1;
 				return result;	/* -ERESTARTSYS because signal hit process */
 			}
+			write_lock_irqsave(&sfp->rq_list_lock, iflags);
 			srp->done = 2;
+			write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
 			result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp);
 			return (result < 0) ? result : 0;
 		}
@@ -1211,6 +1241,7 @@
 	Sg_device *sdp = NULL;
 	Sg_fd *sfp;
 	Sg_request *srp = NULL;
+	unsigned long iflags;
 
 	if (SCpnt && (SRpnt = SCpnt->sc_request))
 		srp = (Sg_request *) SRpnt->upper_private_data;
@@ -1299,8 +1330,10 @@
 	if (sfp && srp) {
 		/* Now wake up any sg_read() that is waiting for this packet. */
 		kill_fasync(&sfp->async_qp, SIGPOLL, POLL_IN);
+		write_lock_irqsave(&sfp->rq_list_lock, iflags);
 		srp->done = 1;
 		wake_up_interruptible(&sfp->read_wait);
+		write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
 	}
 }
 
@@ -1494,7 +1527,7 @@
 				tsfp = sfp->nextfp;
 				for (srp = sfp->headrp; srp; srp = tsrp) {
 					tsrp = srp->nextrp;
-					if (sfp->closed || (0 == srp->done))
+					if (sfp->closed || (0 == sg_srp_done(srp, sfp)))
 						sg_finish_rem_req(srp);
 				}
 				if (sfp->closed) {
@@ -2407,7 +2440,7 @@
 		return NULL;
 	memset(sfp, 0, sizeof (Sg_fd));
 	init_waitqueue_head(&sfp->read_wait);
-	sfp->rq_list_lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&sfp->rq_list_lock);
 
 	sfp->timeout = SG_DEFAULT_TIMEOUT;
 	sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER;
@@ -2476,7 +2509,7 @@
 
 	for (srp = sfp->headrp; srp; srp = tsrp) {
 		tsrp = srp->nextrp;
-		if (srp->done)
+		if (sg_srp_done(srp, sfp))
 			sg_finish_rem_req(srp);
 		else
 			++dirty;
diff -Nru a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c
--- a/drivers/scsi/sim710.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/sim710.c	2004-12-24 13:37:18 -08:00
@@ -36,6 +36,9 @@
 #include <linux/eisa.h>
 #include <linux/interrupt.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
 
 #include "53c700.h"
 
@@ -124,28 +127,16 @@
 	NCR_700_set_io_mapped(hostdata);
 
 	/* and register the chip */
-	if((host = NCR_700_detect(&sim710_driver_template, hostdata)) == NULL) {
+	if((host = NCR_700_detect(&sim710_driver_template, hostdata, dev, irq,
+				  scsi_id)) == NULL) {
 		printk(KERN_ERR "sim710: No host detected; card configuration problem?\n");
 		goto out_release;
 	}
 
-	host->irq = irq;
-	host->this_id = scsi_id;
-
-	if(request_irq(irq, NCR_700_intr, SA_SHIRQ, "sim710", host)) {
-		printk(KERN_ERR "sim710: irq problem with %d, detaching\n",
-		       irq);
-		goto out_unregister;
-	}
-
-	scsi_add_host(host, dev); /* XXX handle failure */
 	scsi_scan_host(host);
-	hostdata->dev = dev;
 
 	return 0;
 
- out_unregister:
-	scsi_host_put(host);
  out_release:
 	release_region(host->base, 64);
  out_free:
diff -Nru a/drivers/scsi/sr.c b/drivers/scsi/sr.c
--- a/drivers/scsi/sr.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/sr.c	2004-12-24 13:37:43 -08:00
@@ -156,8 +156,8 @@
 static inline void scsi_cd_put(struct scsi_cd *cd)
 {
 	down(&sr_ref_sem);
-	scsi_device_put(cd->device);
 	kref_put(&cd->kref, sr_kref_release);
+	scsi_device_put(cd->device);
 	up(&sr_ref_sem);
 }
 
@@ -377,6 +377,7 @@
 			return 0;
 		SCpnt->cmnd[0] = WRITE_10;
 		SCpnt->sc_data_direction = DMA_TO_DEVICE;
+ 	 	cd->cdi.media_written = 1;
 	} else if (rq_data_dir(SCpnt->request) == READ) {
 		SCpnt->cmnd[0] = READ_10;
 		SCpnt->sc_data_direction = DMA_FROM_DEVICE;
@@ -875,10 +876,10 @@
 		cd->cdi.mask |= CDC_CLOSE_TRAY; */
 
 	/*
-	 * if DVD-RAM of MRW-W, we are randomly writeable
+	 * if DVD-RAM, MRW-W or CD-RW, we are randomly writable
 	 */
-	if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM)) !=
-			(CDC_DVD_RAM | CDC_MRW_W | CDC_RAM)) {
+	if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) !=
+			(CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) {
 		cd->device->writeable = 1;
 	}
 
diff -Nru a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
--- a/drivers/scsi/sr_ioctl.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/scsi/sr_ioctl.c	2004-12-24 13:37:01 -08:00
@@ -549,5 +549,17 @@
 		 unsigned int cmd, unsigned long arg)
 {
 	Scsi_CD *cd = cdi->handle;
+	int ret;
+	
+	ret = scsi_nonblockable_ioctl(cd->device, cmd,
+				      (void __user *)arg, NULL);
+	/*
+	 * ENODEV means that we didn't recognise the ioctl, or that we
+	 * cannot execute it in the current device state.  In either
+	 * case fall through to scsi_ioctl, which will return ENDOEV again
+	 * if it doesn't recognise the ioctl
+	 */
+	if (ret != -ENODEV)
+		return ret;
 	return scsi_ioctl(cd->device, cmd, (void __user *)arg);
 }
diff -Nru a/drivers/scsi/st.c b/drivers/scsi/st.c
--- a/drivers/scsi/st.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/st.c	2004-12-24 13:37:00 -08:00
@@ -17,7 +17,7 @@
    Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
  */
 
-static char *verstr = "20040403";
+static char *verstr = "20041025";
 
 #include <linux/module.h>
 
@@ -40,6 +40,16 @@
 #include <asm/dma.h>
 #include <asm/system.h>
 
+#include <scsi/scsi.h>
+#include <scsi/scsi_dbg.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_driver.h>
+#include <scsi/scsi_eh.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_ioctl.h>
+#include <scsi/scsi_request.h>
+
+
 /* The driver prints some debugging information on the console if DEBUG
    is defined and non-zero. */
 #define DEBUG 0
@@ -56,13 +66,6 @@
 #define DEBC(a)
 #endif
 
-
-#include "scsi.h"
-#include <scsi/scsi_host.h>
-
-#include <scsi/scsi_driver.h>
-#include <scsi/scsi_ioctl.h>
-
 #define ST_KILOBYTE 1024
 
 #include "st_options.h"
@@ -71,8 +74,8 @@
 static int buffer_kbs;
 static int max_sg_segs;
 static int try_direct_io = TRY_DIRECT_IO;
-static int try_rdio = TRUE;
-static int try_wdio = TRUE;
+static int try_rdio = 1;
+static int try_wdio = 1;
 
 static int st_dev_max;
 static int st_nr_dev;
@@ -169,17 +172,17 @@
 static int st_fixed_buffer_size = ST_FIXED_BUFFER_SIZE;
 static int st_max_sg_segs = ST_MAX_SG;
 
-static Scsi_Tape **scsi_tapes = NULL;
+static struct scsi_tape **scsi_tapes = NULL;
 
 static int modes_defined;
 
-static ST_buffer *new_tape_buffer(int, int, int);
-static int enlarge_buffer(ST_buffer *, int, int);
-static void normalize_buffer(ST_buffer *);
-static int append_to_buffer(const char __user *, ST_buffer *, int);
-static int from_buffer(ST_buffer *, char __user *, int);
-static void move_buffer_data(ST_buffer *, int);
-static void buf_to_sg(ST_buffer *, unsigned int);
+static struct st_buffer *new_tape_buffer(int, int, int);
+static int enlarge_buffer(struct st_buffer *, int, int);
+static void normalize_buffer(struct st_buffer *);
+static int append_to_buffer(const char __user *, struct st_buffer *, int);
+static int from_buffer(struct st_buffer *, char __user *, int);
+static void move_buffer_data(struct st_buffer *, int);
+static void buf_to_sg(struct st_buffer *, unsigned int);
 
 static int st_map_user_pages(struct scatterlist *, const unsigned int, 
 			     unsigned long, size_t, int, unsigned long);
@@ -193,7 +196,7 @@
 
 static void do_create_driverfs_files(void);
 static void do_remove_driverfs_files(void);
-static void do_create_class_files(Scsi_Tape *, int, int);
+static void do_create_class_files(struct scsi_tape *, int, int);
 
 static struct scsi_driver st_template = {
 	.owner			= THIS_MODULE,
@@ -205,12 +208,12 @@
 	.init_command		= st_init_command,
 };
 
-static int st_compression(Scsi_Tape *, int);
+static int st_compression(struct scsi_tape *, int);
 
-static int find_partition(Scsi_Tape *);
-static int switch_partition(Scsi_Tape *);
+static int find_partition(struct scsi_tape *);
+static int switch_partition(struct scsi_tape *);
 
-static int st_int_ioctl(Scsi_Tape *, unsigned int, unsigned long);
+static int st_int_ioctl(struct scsi_tape *, unsigned int, unsigned long);
 
 
 #include "osst_detect.h"
@@ -237,7 +240,7 @@
 
 /* If the device signature is on the list of incompatible drives, the
    function returns a pointer to the name of the correct driver (if known) */
-static char * st_incompatible(Scsi_Device* SDp)
+static char * st_incompatible(struct scsi_device* SDp)
 {
 	struct st_reject_data *rp;
 
@@ -254,13 +257,13 @@
 }
 
 
-static inline char *tape_name(Scsi_Tape *tape)
+static inline char *tape_name(struct scsi_tape *tape)
 {
 	return tape->disk->disk_name;
 }
 
 /* Convert the result to success code */
-static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
+static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt)
 {
 	int result = SRpnt->sr_result;
 	unsigned char *sense = SRpnt->sr_sense_buffer, scode;
@@ -287,7 +290,7 @@
 		       SRpnt->sr_cmnd[3], SRpnt->sr_cmnd[4], SRpnt->sr_cmnd[5],
 		       SRpnt->sr_bufflen);
 		if (driver_byte(result) & DRIVER_SENSE)
-			print_req_sense("st", SRpnt);
+			scsi_print_req_sense("st", SRpnt);
 	} else ) /* end DEB */
 		if (!(driver_byte(result) & DRIVER_SENSE) ||
 		    ((sense[0] & 0x70) == 0x70 &&
@@ -300,7 +303,7 @@
 		     SRpnt->sr_cmnd[0] != TEST_UNIT_READY)) {	/* Abnormal conditions for tape */
 		if (driver_byte(result) & DRIVER_SENSE) {
 			printk(KERN_WARNING "%s: Error with sense data: ", name);
-			print_req_sense("st", SRpnt);
+			scsi_print_req_sense("st", SRpnt);
 		} else
 			printk(KERN_WARNING
 			       "%s: Error %x (sugg. bt 0x%x, driver bt 0x%x, host bt 0x%x).\n",
@@ -351,11 +354,11 @@
 
 
 /* Wakeup from interrupt */
-static void st_sleep_done(Scsi_Cmnd * SCpnt)
+static void st_sleep_done(struct scsi_cmnd * SCpnt)
 {
 	int remainder;
-	Scsi_Tape *STp = container_of(SCpnt->request->rq_disk->private_data,
-				    Scsi_Tape, driver);
+	struct scsi_tape *STp = container_of(SCpnt->request->rq_disk->private_data,
+					     struct scsi_tape, driver);
 
 	if ((STp->buffer)->writing &&
 	    (SCpnt->sense_buffer[0] & 0x70) == 0x70 &&
@@ -385,9 +388,9 @@
 /* Do the scsi command. Waits until command performed if do_wait is true.
    Otherwise write_behind_check() is used to check that the command
    has finished. */
-static Scsi_Request *
- st_do_scsi(Scsi_Request * SRpnt, Scsi_Tape * STp, unsigned char *cmd, int bytes,
-	    int direction, int timeout, int retries, int do_wait)
+static struct scsi_request *
+st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd,
+	   int bytes, int direction, int timeout, int retries, int do_wait)
 {
 	unsigned char *bp;
 
@@ -432,10 +435,10 @@
 
 
 /* Handle the write-behind checking (downs the semaphore) */
-static void write_behind_check(Scsi_Tape * STp)
+static void write_behind_check(struct scsi_tape * STp)
 {
-	ST_buffer *STbuffer;
-	ST_partstat *STps;
+	struct st_buffer *STbuffer;
+	struct st_partstat *STps;
 
 	STbuffer = STp->buffer;
 
@@ -468,9 +471,9 @@
 
 /* Step over EOF if it has been inadvertently crossed (ioctl not used because
    it messes up the block number). */
-static int cross_eof(Scsi_Tape * STp, int forward)
+static int cross_eof(struct scsi_tape * STp, int forward)
 {
-	Scsi_Request *SRpnt;
+	struct scsi_request *SRpnt;
 	unsigned char cmd[MAX_COMMAND_SIZE];
 
 	cmd[0] = SPACE;
@@ -485,8 +488,8 @@
         DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n",
 		   tape_name(STp), forward ? "forward" : "backward"));
 
-	SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE,
-			   STp->device->timeout, MAX_RETRIES, TRUE);
+	SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
+			   STp->device->timeout, MAX_RETRIES, 1);
 	if (!SRpnt)
 		return (STp->buffer)->syscall_result;
 
@@ -502,13 +505,13 @@
 
 
 /* Flush the write buffer (never need to write if variable blocksize). */
-static int flush_write_buffer(Scsi_Tape * STp)
+static int flush_write_buffer(struct scsi_tape * STp)
 {
 	int offset, transfer, blks;
 	int result;
 	unsigned char cmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt;
-	ST_partstat *STps;
+	struct scsi_request *SRpnt;
+	struct st_partstat *STps;
 
 	if ((STp->buffer)->writing) {
 		write_behind_check(STp);
@@ -543,8 +546,8 @@
 		cmd[3] = blks >> 8;
 		cmd[4] = blks;
 
-		SRpnt = st_do_scsi(NULL, STp, cmd, transfer, SCSI_DATA_WRITE,
-				   STp->device->timeout, MAX_WRITE_RETRIES, TRUE);
+		SRpnt = st_do_scsi(NULL, STp, cmd, transfer, DMA_TO_DEVICE,
+				   STp->device->timeout, MAX_WRITE_RETRIES, 1);
 		if (!SRpnt)
 			return (STp->buffer)->syscall_result;
 
@@ -577,11 +580,11 @@
 
 /* Flush the tape buffer. The tape will be positioned correctly unless
    seek_next is true. */
-static int flush_buffer(Scsi_Tape *STp, int seek_next)
+static int flush_buffer(struct scsi_tape *STp, int seek_next)
 {
 	int backspace, result;
-	ST_buffer *STbuffer;
-	ST_partstat *STps;
+	struct st_buffer *STbuffer;
+	struct st_partstat *STps;
 
 	STbuffer = STp->buffer;
 
@@ -610,7 +613,7 @@
 	result = 0;
 	if (!seek_next) {
 		if (STps->eof == ST_FM_HIT) {
-			result = cross_eof(STp, FALSE);	/* Back over the EOF hit */
+			result = cross_eof(STp, 0);	/* Back over the EOF hit */
 			if (!result)
 				STps->eof = ST_NOEOF;
 			else {
@@ -632,9 +635,9 @@
 }
 
 /* Set the mode parameters */
-static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm)
+static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm)
 {
-	int set_it = FALSE;
+	int set_it = 0;
 	unsigned long arg;
 	char *name = tape_name(STp);
 
@@ -642,7 +645,7 @@
 	    STm->default_density >= 0 &&
 	    STm->default_density != STp->density) {
 		arg = STm->default_density;
-		set_it = TRUE;
+		set_it = 1;
 	} else
 		arg = STp->density;
 	arg <<= MT_ST_DENSITY_SHIFT;
@@ -650,7 +653,7 @@
 	    STm->default_blksize >= 0 &&
 	    STm->default_blksize != STp->block_size) {
 		arg |= STm->default_blksize;
-		set_it = TRUE;
+		set_it = 1;
 	} else
 		arg |= STp->block_size;
 	if (set_it &&
@@ -665,8 +668,8 @@
 }
 
 
-/* Lock or unlock the drive door. Don't use when Scsi_Request allocated. */
-static int do_door_lock(Scsi_Tape * STp, int do_lock)
+/* Lock or unlock the drive door. Don't use when scsi_request allocated. */
+static int do_door_lock(struct scsi_tape * STp, int do_lock)
 {
 	int retval, cmd;
 	DEB(char *name = tape_name(STp);)
@@ -687,10 +690,10 @@
 
 
 /* Set the internal state after reset */
-static void reset_state(Scsi_Tape *STp)
+static void reset_state(struct scsi_tape *STp)
 {
 	int i;
-	ST_partstat *STps;
+	struct st_partstat *STps;
 
 	STp->pos_unknown = 0;
 	for (i = 0; i < ST_NBR_PARTITIONS; i++) {
@@ -698,7 +701,7 @@
 		STps->rw = ST_IDLE;
 		STps->eof = ST_NOEOF;
 		STps->at_sm = 0;
-		STps->last_block_valid = FALSE;
+		STps->last_block_valid = 0;
 		STps->drv_block = -1;
 		STps->drv_file = -1;
 	}
@@ -719,20 +722,20 @@
 
 #define MAX_ATTENTIONS    10
 
-static int test_ready(Scsi_Tape *STp, int do_wait)
+static int test_ready(struct scsi_tape *STp, int do_wait)
 {
 	int attentions, waits, max_wait, scode;
-	int retval = CHKRES_READY, new_session = FALSE;
+	int retval = CHKRES_READY, new_session = 0;
 	unsigned char cmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt = NULL;
+	struct scsi_request *SRpnt = NULL;
 
 	max_wait = do_wait ? ST_BLOCK_SECONDS : 0;
 
 	for (attentions=waits=0; ; ) {
 		memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
 		cmd[0] = TEST_UNIT_READY;
-		SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, SCSI_DATA_NONE,
-				   STp->long_timeout, MAX_READY_RETRIES, TRUE);
+		SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
+				   STp->long_timeout, MAX_READY_RETRIES, 1);
 
 		if (!SRpnt) {
 			retval = (STp->buffer)->syscall_result;
@@ -744,7 +747,7 @@
 			scode = (SRpnt->sr_sense_buffer[2] & 0x0f);
 
 			if (scode == UNIT_ATTENTION) { /* New media? */
-				new_session = TRUE;
+				new_session = 1;
 				if (attentions < MAX_ATTENTIONS) {
 					attentions++;
 					continue;
@@ -794,14 +797,14 @@
    0     drive ready
    1     drive not ready (possibly no tape)
 */
-static int check_tape(Scsi_Tape *STp, struct file *filp)
+static int check_tape(struct scsi_tape *STp, struct file *filp)
 {
-	int i, retval, new_session = FALSE, do_wait;
+	int i, retval, new_session = 0, do_wait;
 	unsigned char cmd[MAX_COMMAND_SIZE], saved_cleaning;
 	unsigned short st_flags = filp->f_flags;
-	Scsi_Request *SRpnt = NULL;
-	ST_mode *STm;
-	ST_partstat *STps;
+	struct scsi_request *SRpnt = NULL;
+	struct st_modedef *STm;
+	struct st_partstat *STps;
 	char *name = tape_name(STp);
 	struct inode *inode = filp->f_dentry->d_inode;
 	int mode = TAPE_MODE(inode);
@@ -811,7 +814,7 @@
 	if (mode != STp->current_mode) {
                 DEBC(printk(ST_DEB_MSG "%s: Mode change from %d to %d.\n",
 			       name, STp->current_mode, mode));
-		new_session = TRUE;
+		new_session = 1;
 		STp->current_mode = mode;
 	}
 	STm = &(STp->modes[STp->current_mode]);
@@ -836,11 +839,11 @@
 			STps->rw = ST_IDLE;
 			STps->eof = ST_NOEOF;
 			STps->at_sm = 0;
-			STps->last_block_valid = FALSE;
+			STps->last_block_valid = 0;
 			STps->drv_block = 0;
 			STps->drv_file = 0;
 		}
-		new_session = TRUE;
+		new_session = 1;
 	}
 	else {
 		STp->cleaning_req |= saved_cleaning;
@@ -867,8 +870,8 @@
 		memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
 		cmd[0] = READ_BLOCK_LIMITS;
 
-		SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, SCSI_DATA_READ, STp->device->timeout,
-				   MAX_READY_RETRIES, TRUE);
+		SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE,
+				   STp->device->timeout, MAX_READY_RETRIES, 1);
 		if (!SRpnt) {
 			retval = (STp->buffer)->syscall_result;
 			goto err_out;
@@ -894,8 +897,8 @@
 	cmd[0] = MODE_SENSE;
 	cmd[4] = 12;
 
-	SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, SCSI_DATA_READ, STp->device->timeout,
-			   MAX_READY_RETRIES, TRUE);
+	SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, DMA_FROM_DEVICE,
+			STp->device->timeout, MAX_READY_RETRIES, 1);
 	if (!SRpnt) {
 		retval = (STp->buffer)->syscall_result;
 		goto err_out;
@@ -928,7 +931,7 @@
 	}
 	scsi_release_request(SRpnt);
 	SRpnt = NULL;
-        STp->inited = TRUE;
+        STp->inited = 1;
 
 	if (STp->block_size > 0)
 		(STp->buffer)->buffer_blocks =
@@ -970,8 +973,8 @@
 	}
 
 	if (new_session) {	/* Change the drive parameters for the new mode */
-		STp->density_changed = STp->blksize_changed = FALSE;
-		STp->compression_changed = FALSE;
+		STp->density_changed = STp->blksize_changed = 0;
+		STp->compression_changed = 0;
 		if (!(STm->defaults_for_writes) &&
 		    (retval = set_mode_densblk(STp, STm)) < 0)
 		    goto err_out;
@@ -996,8 +999,8 @@
 static int st_open(struct inode *inode, struct file *filp)
 {
 	int i, retval = (-EIO);
-	Scsi_Tape *STp;
-	ST_partstat *STps;
+	struct scsi_tape *STp;
+	struct st_partstat *STps;
 	int dev = TAPE_NR(inode);
 	char *name;
 
@@ -1076,10 +1079,10 @@
 {
 	int result = 0, result2;
 	unsigned char cmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt;
-	Scsi_Tape *STp = filp->private_data;
-	ST_mode *STm = &(STp->modes[STp->current_mode]);
-	ST_partstat *STps = &(STp->ps[STp->partition]);
+	struct scsi_request *SRpnt;
+	struct scsi_tape *STp = filp->private_data;
+	struct st_modedef *STm = &(STp->modes[STp->current_mode]);
+	struct st_partstat *STps = &(STp->ps[STp->partition]);
 	char *name = tape_name(STp);
 
 	if (file_count(filp) > 1)
@@ -1106,8 +1109,8 @@
 
 	if (STps->rw == ST_WRITING && !STp->pos_unknown) {
 
-                DEBC(printk(ST_DEB_MSG "%s: File length %ld bytes.\n",
-                            name, (long) (filp->f_pos));
+                DEBC(printk(ST_DEB_MSG "%s: File length %lld bytes.\n",
+                            name, (long long)filp->f_pos);
                      printk(ST_DEB_MSG "%s: Async write waits %d, finished %d.\n",
                             name, STp->nbr_waits, STp->nbr_finished);
 		)
@@ -1116,8 +1119,8 @@
 		cmd[0] = WRITE_FILEMARKS;
 		cmd[4] = 1 + STp->two_fm;
 
-		SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE,
-				   STp->device->timeout, MAX_WRITE_RETRIES, TRUE);
+		SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
+				   STp->device->timeout, MAX_WRITE_RETRIES, 1);
 		if (!SRpnt) {
 			result = (STp->buffer)->syscall_result;
 			goto out;
@@ -1143,7 +1146,7 @@
 				STps->drv_file++;
 			STps->drv_block = 0;
 			if (STp->two_fm)
-				cross_eof(STp, FALSE);
+				cross_eof(STp, 0);
 			STps->eof = ST_FM;
 		}
 
@@ -1155,7 +1158,7 @@
 			if (STp->can_bsr)
 				result = flush_buffer(STp, 0);
 			else if (STps->eof == ST_FM_HIT) {
-				result = cross_eof(STp, FALSE);
+				result = cross_eof(STp, 0);
 				if (result) {
 					if (STps->drv_file >= 0)
 						STps->drv_file++;
@@ -1165,7 +1168,7 @@
 					STps->eof = ST_NOEOF;
 			}
 		} else if ((STps->eof == ST_NOEOF &&
-			    !(result = cross_eof(STp, TRUE))) ||
+			    !(result = cross_eof(STp, 1))) ||
 			   STps->eof == ST_FM_HIT) {
 			if (STps->drv_file >= 0)
 				STps->drv_file++;
@@ -1189,7 +1192,7 @@
 static int st_release(struct inode *inode, struct file *filp)
 {
 	int result = 0;
-	Scsi_Tape *STp = filp->private_data;
+	struct scsi_tape *STp = filp->private_data;
 
 	if (STp->door_locked == ST_LOCKED_AUTO)
 		do_door_lock(STp, 0);
@@ -1204,7 +1207,7 @@
 }
 
 /* The checks common to both reading and writing */
-static ssize_t rw_checks(Scsi_Tape *STp, struct file *filp, size_t count)
+static ssize_t rw_checks(struct scsi_tape *STp, struct file *filp, size_t count)
 {
 	ssize_t retval = 0;
 
@@ -1271,10 +1274,11 @@
 }
 
 
-static int setup_buffering(Scsi_Tape *STp, const char __user *buf, size_t count, int is_read)
+static int setup_buffering(struct scsi_tape *STp, const char __user *buf,
+			   size_t count, int is_read)
 {
 	int i, bufsize, retval = 0;
-	ST_buffer *STbp = STp->buffer;
+	struct st_buffer *STbp = STp->buffer;
 
 	if (is_read)
 		i = STp->try_dio && try_rdio;
@@ -1290,7 +1294,7 @@
 			STbp->buffer_bytes = 0;   /* can be used as transfer counter */
 		}
 		else
-			STbp->do_dio = FALSE;  /* fall back to buffering with any error */
+			STbp->do_dio = 0;  /* fall back to buffering with any error */
 		STbp->sg_segs = STbp->do_dio;
 		STbp->frp_sg_current = 0;
 		DEB(
@@ -1303,7 +1307,7 @@
 		     }
 		)
 	} else
-		STbp->do_dio = FALSE;
+		STbp->do_dio = 0;
 	DEB( STp->nbr_requests++; )
 
 	if (!STbp->do_dio) {
@@ -1329,13 +1333,13 @@
 
 
 /* Can be called more than once after each setup_buffer() */
-static void release_buffering(Scsi_Tape *STp)
+static void release_buffering(struct scsi_tape *STp)
 {
-	ST_buffer *STbp;
+	struct st_buffer *STbp;
 
 	STbp = STp->buffer;
 	if (STbp->do_dio) {
-		sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, FALSE);
+		sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, 0);
 		STbp->do_dio = 0;
 	}
 }
@@ -1352,11 +1356,11 @@
 	int async_write;
 	unsigned char cmd[MAX_COMMAND_SIZE];
 	const char __user *b_point;
-	Scsi_Request *SRpnt = NULL;
-	Scsi_Tape *STp = filp->private_data;
-	ST_mode *STm;
-	ST_partstat *STps;
-	ST_buffer *STbp;
+	struct scsi_request *SRpnt = NULL;
+	struct scsi_tape *STp = filp->private_data;
+	struct st_modedef *STm;
+	struct st_partstat *STps;
+	struct st_buffer *STbp;
 	char *name = tape_name(STp);
 
 	if (down_interruptible(&STp->lock))
@@ -1438,7 +1442,7 @@
 		goto out;
 	}
 
-	retval = setup_buffering(STp, buf, count, FALSE);
+	retval = setup_buffering(STp, buf, count, 0);
 	if (retval)
 		goto out;
 
@@ -1482,7 +1486,7 @@
 		if (STp->block_size != 0 && STm->do_buffer_writes &&
 		    !(STp->try_dio && try_wdio) && STps->eof < ST_EOM_OK &&
 		    STbp->buffer_bytes < STbp->buffer_size) {
-			STp->dirty = TRUE;
+			STp->dirty = 1;
 			/* Don't write a buffer that is not full enough. */
 			if (!async_write && count == 0)
 				break;
@@ -1503,7 +1507,7 @@
 		cmd[3] = blks >> 8;
 		cmd[4] = blks;
 
-		SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, SCSI_DATA_WRITE,
+		SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, DMA_TO_DEVICE,
 				   STp->device->timeout, MAX_WRITE_RETRIES, !async_write);
 		if (!SRpnt) {
 			retval = STbp->syscall_result;
@@ -1559,7 +1563,7 @@
 					if (!retry_eot && (SRpnt->sr_sense_buffer[0] & 1) == 0 &&
 					    (scode == NO_SENSE || scode == RECOVERED_ERROR)) {
 						move_buffer_data(STp->buffer, transfer - undone);
-						retry_eot = TRUE;
+						retry_eot = 1;
 						if (STps->drv_block >= 0) {
 							STps->drv_block += (transfer - undone) /
 								STp->block_size;
@@ -1630,14 +1634,15 @@
 
    Does release user buffer mapping if it is set.
 */
-static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
+static long read_tape(struct scsi_tape *STp, long count,
+		      struct scsi_request ** aSRpnt)
 {
 	int transfer, blks, bytes;
 	unsigned char cmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt;
-	ST_mode *STm;
-	ST_partstat *STps;
-	ST_buffer *STbp;
+	struct scsi_request *SRpnt;
+	struct st_modedef *STm;
+	struct st_partstat *STps;
+	struct st_buffer *STbp;
 	int retval = 0;
 	char *name = tape_name(STp);
 
@@ -1673,8 +1678,8 @@
 	cmd[4] = blks;
 
 	SRpnt = *aSRpnt;
-	SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, SCSI_DATA_READ,
-			   STp->device->timeout, MAX_RETRIES, TRUE);
+	SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE,
+			   STp->device->timeout, MAX_RETRIES, 1);
 	release_buffering(STp);
 	*aSRpnt = SRpnt;
 	if (!SRpnt)
@@ -1818,11 +1823,11 @@
 	ssize_t retval = 0;
 	ssize_t i, transfer;
 	int special, do_dio = 0;
-	Scsi_Request *SRpnt = NULL;
-	Scsi_Tape *STp = filp->private_data;
-	ST_mode *STm;
-	ST_partstat *STps;
-	ST_buffer *STbp = STp->buffer;
+	struct scsi_request *SRpnt = NULL;
+	struct scsi_tape *STp = filp->private_data;
+	struct st_modedef *STm;
+	struct st_partstat *STps;
+	struct st_buffer *STbp = STp->buffer;
 	DEB( char *name = tape_name(STp); )
 
 	if (down_interruptible(&STp->lock))
@@ -1852,7 +1857,7 @@
 		       STps->eof, STbp->buffer_bytes);
         ) /* end DEB */
 
-	retval = setup_buffering(STp, buf, count, TRUE);
+	retval = setup_buffering(STp, buf, count, 1);
 	if (retval)
 		goto out;
 	do_dio = STbp->do_dio;
@@ -1960,7 +1965,7 @@
 
 DEB(
 /* Set the driver options */
-static void st_log_options(Scsi_Tape * STp, ST_mode * STm, char *name)
+static void st_log_options(struct scsi_tape * STp, struct st_modedef * STm, char *name)
 {
 	if (debugging) {
 		printk(KERN_INFO
@@ -1983,20 +1988,20 @@
 	)
 
 
-static int st_set_options(Scsi_Tape *STp, long options)
+static int st_set_options(struct scsi_tape *STp, long options)
 {
 	int value;
 	long code;
-	ST_mode *STm;
+	struct st_modedef *STm;
 	char *name = tape_name(STp);
 	struct cdev *cd0, *cd1;
 
 	STm = &(STp->modes[STp->current_mode]);
 	if (!STm->defined) {
 		cd0 = STm->cdevs[0]; cd1 = STm->cdevs[1];
-		memcpy(STm, &(STp->modes[0]), sizeof(ST_mode));
+		memcpy(STm, &(STp->modes[0]), sizeof(struct st_modedef));
 		STm->cdevs[0] = cd0; STm->cdevs[1] = cd1;
-		modes_defined = TRUE;
+		modes_defined = 1;
                 DEBC(printk(ST_DEB_MSG
                             "%s: Initialized mode %d definition from mode 0\n",
                             name, STp->current_mode));
@@ -2065,7 +2070,7 @@
 			DEBC( printk(KERN_INFO "%s: Default block size set to %d bytes.\n",
 			       name, STm->default_blksize));
 			if (STp->ready == ST_READY) {
-				STp->blksize_changed = FALSE;
+				STp->blksize_changed = 0;
 				set_mode_densblk(STp, STm);
 			}
 		}
@@ -2104,7 +2109,7 @@
 				DEBC( printk(KERN_INFO "%s: Density default set to %x\n",
 				       name, STm->default_density));
 				if (STp->ready == ST_READY) {
-					STp->density_changed = FALSE;
+					STp->density_changed = 0;
 					set_mode_densblk(STp, STm);
 				}
 			}
@@ -2137,7 +2142,7 @@
 					DEBC( printk(KERN_INFO "%s: Compression default set to %x\n",
 					       name, (value & 1)));
 					if (STp->ready == ST_READY) {
-						STp->compression_changed = FALSE;
+						STp->compression_changed = 0;
 						st_compression(STp, (STm->default_compression == ST_YES));
 					}
 				}
@@ -2171,10 +2176,10 @@
 /* Read a mode page into the tape buffer. The block descriptors are included
    if incl_block_descs is true. The page control is ored to the page number
    parameter, if necessary. */
-static int read_mode_page(Scsi_Tape *STp, int page, int omit_block_descs)
+static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
 {
 	unsigned char cmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt = NULL;
+	struct scsi_request *SRpnt = NULL;
 
 	memset(cmd, 0, MAX_COMMAND_SIZE);
 	cmd[0] = MODE_SENSE;
@@ -2183,8 +2188,8 @@
 	cmd[2] = page;
 	cmd[4] = 255;
 
-	SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], SCSI_DATA_READ,
-			   STp->device->timeout, 0, TRUE);
+	SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_FROM_DEVICE,
+			   STp->device->timeout, 0, 1);
 	if (SRpnt == NULL)
 		return (STp->buffer)->syscall_result;
 
@@ -2196,11 +2201,11 @@
 
 /* Send the mode page in the tape buffer to the drive. Assumes that the mode data
    in the buffer is correctly formatted. The long timeout is used if slow is non-zero. */
-static int write_mode_page(Scsi_Tape *STp, int page, int slow)
+static int write_mode_page(struct scsi_tape *STp, int page, int slow)
 {
 	int pgo;
 	unsigned char cmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt = NULL;
+	struct scsi_request *SRpnt = NULL;
 
 	memset(cmd, 0, MAX_COMMAND_SIZE);
 	cmd[0] = MODE_SELECT;
@@ -2214,8 +2219,8 @@
 	(STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP;
 	(STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR;
 
-	SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], SCSI_DATA_WRITE,
-			   (slow ? STp->long_timeout : STp->device->timeout), 0, TRUE);
+	SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_TO_DEVICE,
+			   (slow ? STp->long_timeout : STp->device->timeout), 0, 1);
 	if (SRpnt == NULL)
 		return (STp->buffer)->syscall_result;
 
@@ -2242,7 +2247,7 @@
    work without this (suggestion from Michael Schaefer <Michael.Schaefer@dlr.de>).
    Including block descriptors should not cause any harm to other drives. */
 
-static int st_compression(Scsi_Tape * STp, int state)
+static int st_compression(struct scsi_tape * STp, int state)
 {
 	int retval;
 	int mpoffs;  /* Offset to mode page start */
@@ -2253,7 +2258,7 @@
 		return (-EIO);
 
 	/* Read the current page contents */
-	retval = read_mode_page(STp, COMPRESSION_PAGE, FALSE);
+	retval = read_mode_page(STp, COMPRESSION_PAGE, 0);
 	if (retval) {
                 DEBC(printk(ST_DEB_MSG "%s: Compression mode page not supported.\n",
                             name));
@@ -2282,7 +2287,7 @@
 			b_data[mpoffs + CP_OFF_C_ALGO] = 0; /* no compression */
 	}
 
-	retval = write_mode_page(STp, COMPRESSION_PAGE, FALSE);
+	retval = write_mode_page(STp, COMPRESSION_PAGE, 0);
 	if (retval) {
                 DEBC(printk(ST_DEB_MSG "%s: Compression change failed.\n", name));
 		return (-EIO);
@@ -2290,19 +2295,19 @@
         DEBC(printk(ST_DEB_MSG "%s: Compression state changed to %d.\n",
 		       name, state));
 
-	STp->compression_changed = TRUE;
+	STp->compression_changed = 1;
 	return 0;
 }
 
 
 /* Process the load and unload commands (does unload if the load code is zero) */
-static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code)
+static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_code)
 {
 	int retval = (-EIO), timeout;
 	DEB( char *name = tape_name(STp); )
 	unsigned char cmd[MAX_COMMAND_SIZE];
-	ST_partstat *STps;
-	Scsi_Request *SRpnt;
+	struct st_partstat *STps;
+	struct scsi_request *SRpnt;
 
 	if (STp->ready != ST_READY && !load_code) {
 		if (STp->ready == ST_NO_TAPE)
@@ -2339,8 +2344,8 @@
 		printk(ST_DEB_MSG "%s: Loading tape.\n", name);
 		);
 
-	SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE,
-			   timeout, MAX_RETRIES, TRUE);
+	SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
+			   timeout, MAX_RETRIES, 1);
 	if (!SRpnt)
 		return (STp->buffer)->syscall_result;
 
@@ -2370,17 +2375,17 @@
 
 
 /* Internal ioctl function */
-static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
+static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned long arg)
 {
 	int timeout;
 	long ltmp;
 	int ioctl_result;
-	int chg_eof = TRUE;
+	int chg_eof = 1;
 	unsigned char cmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt;
-	ST_partstat *STps;
+	struct scsi_request *SRpnt;
+	struct st_partstat *STps;
 	int fileno, blkno, at_sm, undone;
-	int datalen = 0, direction = SCSI_DATA_NONE;
+	int datalen = 0, direction = DMA_NONE;
 	char *name = tape_name(STp);
 
 	WARN_ON(STp->buffer->do_dio != 0);
@@ -2399,7 +2404,7 @@
 	memset(cmd, 0, MAX_COMMAND_SIZE);
 	switch (cmd_in) {
 	case MTFSFM:
-		chg_eof = FALSE;	/* Changed from the FSF after this */
+		chg_eof = 0;	/* Changed from the FSF after this */
 	case MTFSF:
 		cmd[0] = SPACE;
 		cmd[1] = 0x01;	/* Space FileMarks */
@@ -2414,7 +2419,7 @@
 		at_sm &= (arg == 0);
 		break;
 	case MTBSFM:
-		chg_eof = FALSE;	/* Changed from the FSF after this */
+		chg_eof = 0;	/* Changed from the FSF after this */
 	case MTBSF:
 		cmd[0] = SPACE;
 		cmd[1] = 0x01;	/* Space FileMarks */
@@ -2583,7 +2588,7 @@
 	case MTSETDENSITY:	/* Set tape density */
 	case MTSETDRVBUFFER:	/* Set drive buffering */
 	case SET_DENS_AND_BLK:	/* Set density and block size */
-		chg_eof = FALSE;
+		chg_eof = 0;
 		if (STp->dirty || (STp->buffer)->buffer_bytes != 0)
 			return (-EIO);	/* Not allowed if data in buffer */
 		if ((cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) &&
@@ -2598,7 +2603,7 @@
 		if ((STp->use_pf & USE_PF))
 			cmd[1] = MODE_SELECT_PAGE_FORMAT;
 		cmd[4] = datalen = 12;
-		direction = SCSI_DATA_WRITE;
+		direction = DMA_TO_DEVICE;
 
 		memset((STp->buffer)->b_data, 0, 12);
 		if (cmd_in == MTSETDRVBUFFER)
@@ -2609,7 +2614,7 @@
 		(STp->buffer)->b_data[3] = 8;	/* block descriptor length */
 		if (cmd_in == MTSETDENSITY) {
 			(STp->buffer)->b_data[4] = arg;
-			STp->density_changed = TRUE;	/* At least we tried ;-) */
+			STp->density_changed = 1;	/* At least we tried ;-) */
 		} else if (cmd_in == SET_DENS_AND_BLK)
 			(STp->buffer)->b_data[4] = arg >> 24;
 		else
@@ -2617,7 +2622,7 @@
 		if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) {
 			ltmp = arg & MT_ST_BLKSIZE_MASK;
 			if (cmd_in == MTSETBLK)
-				STp->blksize_changed = TRUE; /* At least we tried ;-) */
+				STp->blksize_changed = 1; /* At least we tried ;-) */
 		} else
 			ltmp = STp->block_size;
 		(STp->buffer)->b_data[9] = (ltmp >> 16);
@@ -2646,7 +2651,7 @@
 	}
 
 	SRpnt = st_do_scsi(NULL, STp, cmd, datalen, direction,
-			   timeout, MAX_RETRIES, TRUE);
+			   timeout, MAX_RETRIES, 1);
 	if (!SRpnt)
 		return (STp->buffer)->syscall_result;
 
@@ -2784,12 +2789,12 @@
 /* Get the tape position. If bt == 2, arg points into a kernel space mt_loc
    structure. */
 
-static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition,
+static int get_location(struct scsi_tape *STp, unsigned int *block, int *partition,
 			int logical)
 {
 	int result;
 	unsigned char scmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt;
+	struct scsi_request *SRpnt;
 	DEB( char *name = tape_name(STp); )
 
 	if (STp->ready != ST_READY)
@@ -2804,8 +2809,8 @@
 		if (!logical && !STp->scsi2_logical)
 			scmd[1] = 1;
 	}
-	SRpnt = st_do_scsi(NULL, STp, scmd, 20, SCSI_DATA_READ, STp->device->timeout,
-			   MAX_READY_RETRIES, TRUE);
+	SRpnt = st_do_scsi(NULL, STp, scmd, 20, DMA_FROM_DEVICE,
+			STp->device->timeout, MAX_READY_RETRIES, 1);
 	if (!SRpnt)
 		return (STp->buffer)->syscall_result;
 
@@ -2844,15 +2849,15 @@
 
 /* Set the tape block and partition. Negative partition means that only the
    block should be set in vendor specific way. */
-static int set_location(Scsi_Tape *STp, unsigned int block, int partition,
+static int set_location(struct scsi_tape *STp, unsigned int block, int partition,
 			int logical)
 {
-	ST_partstat *STps;
+	struct st_partstat *STps;
 	int result, p;
 	unsigned int blk;
 	int timeout;
 	unsigned char scmd[MAX_COMMAND_SIZE];
-	Scsi_Request *SRpnt;
+	struct scsi_request *SRpnt;
 	DEB( char *name = tape_name(STp); )
 
 	if (STp->ready != ST_READY)
@@ -2871,9 +2876,9 @@
 		return (-EINVAL);
 	if (partition != STp->partition) {
 		if (get_location(STp, &blk, &p, 1))
-			STps->last_block_valid = FALSE;
+			STps->last_block_valid = 0;
 		else {
-			STps->last_block_valid = TRUE;
+			STps->last_block_valid = 1;
 			STps->last_block_visited = blk;
                         DEBC(printk(ST_DEB_MSG
                                     "%s: Visited block %d for partition %d saved.\n",
@@ -2909,8 +2914,8 @@
 		timeout = STp->device->timeout;
 	}
 
-	SRpnt = st_do_scsi(NULL, STp, scmd, 0, SCSI_DATA_NONE,
-			   timeout, MAX_READY_RETRIES, TRUE);
+	SRpnt = st_do_scsi(NULL, STp, scmd, 0, DMA_NONE,
+			   timeout, MAX_READY_RETRIES, 1);
 	if (!SRpnt)
 		return (STp->buffer)->syscall_result;
 
@@ -2947,7 +2952,7 @@
 
 /* Find the current partition number for the drive status. Called from open and
    returns either partition number of negative error code. */
-static int find_partition(Scsi_Tape *STp)
+static int find_partition(struct scsi_tape *STp)
 {
 	int i, partition;
 	unsigned int block;
@@ -2961,9 +2966,9 @@
 
 
 /* Change the partition if necessary */
-static int switch_partition(Scsi_Tape *STp)
+static int switch_partition(struct scsi_tape *STp)
 {
-	ST_partstat *STps;
+	struct st_partstat *STps;
 
 	if (STp->partition == STp->new_partition)
 		return 0;
@@ -2989,7 +2994,7 @@
 
 /* Get the number of partitions on the tape. As a side effect reads the
    mode page into the tape buffer. */
-static int nbr_partitions(Scsi_Tape *STp)
+static int nbr_partitions(struct scsi_tape *STp)
 {
 	int result;
 	DEB( char *name = tape_name(STp); )
@@ -2997,7 +3002,7 @@
 	if (STp->ready != ST_READY)
 		return (-EIO);
 
-	result = read_mode_page(STp, PART_PAGE, TRUE);
+	result = read_mode_page(STp, PART_PAGE, 1);
 
 	if (result) {
                 DEBC(printk(ST_DEB_MSG "%s: Can't read medium partition page.\n",
@@ -3032,14 +3037,14 @@
    is acceptable also to some other old drives and enforced if the first partition
    size field is used for the first additional partition size.
  */
-static int partition_tape(Scsi_Tape *STp, int size)
+static int partition_tape(struct scsi_tape *STp, int size)
 {
 	char *name = tape_name(STp);
 	int result;
 	int pgo, psd_cnt, psdo;
 	unsigned char *bp;
 
-	result = read_mode_page(STp, PART_PAGE, FALSE);
+	result = read_mode_page(STp, PART_PAGE, 0);
 	if (result) {
 		DEBC(printk(ST_DEB_MSG "%s: Can't read partition mode page.\n", name));
 		return result;
@@ -3082,7 +3087,7 @@
 	bp[pgo + PP_OFF_RESERVED] = 0;
 	bp[pgo + PP_OFF_FLAGS] = PP_BIT_IDP | PP_MSK_PSUM_MB;
 
-	result = write_mode_page(STp, PART_PAGE, TRUE);
+	result = write_mode_page(STp, PART_PAGE, 1);
 	if (result) {
 		printk(KERN_INFO "%s: Partitioning of tape failed.\n", name);
 		result = (-EIO);
@@ -3100,9 +3105,9 @@
 	int i, cmd_nr, cmd_type, bt;
 	int retval = 0;
 	unsigned int blk;
-	Scsi_Tape *STp = file->private_data;
-	ST_mode *STm;
-	ST_partstat *STps;
+	struct scsi_tape *STp = file->private_data;
+	struct st_modedef *STm;
+	struct st_partstat *STps;
 	char *name = tape_name(STp);
 	void __user *p = (void __user *)arg;
 
@@ -3125,10 +3130,11 @@
 	 * may try and take the device offline, in which case all further
 	 * access to the device is prohibited.
 	 */
-	if (!scsi_block_when_processing_errors(STp->device)) {
-		retval = (-ENXIO);
+	retval = scsi_nonblockable_ioctl(STp->device, cmd_in, p, file);
+	if (!scsi_block_when_processing_errors(STp->device) || retval != -ENODEV)
 		goto out;
-	}
+	retval = 0;
+
 	cmd_type = _IOC_TYPE(cmd_in);
 	cmd_nr = _IOC_NR(cmd_in);
 
@@ -3259,7 +3265,7 @@
 			for (i = 0; i < ST_NBR_PARTITIONS; i++) {
 				STp->ps[i].rw = ST_IDLE;
 				STp->ps[i].at_sm = 0;
-				STp->ps[i].last_block_valid = FALSE;
+				STp->ps[i].last_block_valid = 0;
 			}
 			STp->partition = STp->new_partition = 0;
 			STp->nbr_partitions = 1;	/* Bad guess ?-) */
@@ -3308,7 +3314,7 @@
 		goto out;
 	}
 
-	if ((i = flush_buffer(STp, FALSE)) < 0) {
+	if ((i = flush_buffer(STp, 0)) < 0) {
 		retval = i;
 		goto out;
 	}
@@ -3423,18 +3429,18 @@
 
 /* Try to allocate a new tape buffer. Calling function must not hold
    dev_arr_lock. */
-static ST_buffer *
+static struct st_buffer *
  new_tape_buffer(int from_initialization, int need_dma, int max_sg)
 {
 	int i, priority, got = 0, segs = 0;
-	ST_buffer *tb;
+	struct st_buffer *tb;
 
 	if (from_initialization)
 		priority = GFP_ATOMIC;
 	else
 		priority = GFP_KERNEL;
 
-	i = sizeof(ST_buffer) + (max_sg - 1) * sizeof(struct scatterlist) +
+	i = sizeof(struct st_buffer) + (max_sg - 1) * sizeof(struct scatterlist) +
 		max_sg * sizeof(struct st_buf_fragment);
 	tb = kmalloc(i, priority);
 	if (!tb) {
@@ -3448,7 +3454,7 @@
 		tb->b_data = page_address(tb->sg[0].page);
 	tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg);
 
-	tb->in_use = TRUE;
+	tb->in_use = 1;
 	tb->dma = need_dma;
 	tb->buffer_size = got;
 
@@ -3457,12 +3463,12 @@
 
 
 /* Try to allocate enough space in the tape buffer */
-static int enlarge_buffer(ST_buffer * STbuffer, int new_size, int need_dma)
+static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma)
 {
 	int segs, nbr, max_segs, b_size, priority, order, got;
 
 	if (new_size <= STbuffer->buffer_size)
-		return TRUE;
+		return 1;
 
 	if (STbuffer->buffer_size <= PAGE_SIZE)
 		normalize_buffer(STbuffer);  /* Avoid extra segment */
@@ -3470,7 +3476,7 @@
 	max_segs = STbuffer->use_sg;
 	nbr = max_segs - STbuffer->frp_segs;
 	if (nbr <= 0)
-		return FALSE;
+		return 0;
 
 	priority = GFP_KERNEL | __GFP_NOWARN;
 	if (need_dma)
@@ -3491,7 +3497,7 @@
 			}
 			DEB(STbuffer->buffer_size = got);
 			normalize_buffer(STbuffer);
-			return FALSE;
+			return 0;
 		}
 		STbuffer->frp[segs].length = b_size;
 		STbuffer->frp_segs += 1;
@@ -3501,12 +3507,12 @@
 	}
 	STbuffer->b_data = page_address(STbuffer->frp[0].page);
 
-	return TRUE;
+	return 1;
 }
 
 
 /* Release the extra buffer */
-static void normalize_buffer(ST_buffer * STbuffer)
+static void normalize_buffer(struct st_buffer * STbuffer)
 {
 	int i, order;
 
@@ -3522,7 +3528,7 @@
 
 /* Move data from the user buffer to the tape buffer. Returns zero (success) or
    negative error code. */
-static int append_to_buffer(const char __user *ubp, ST_buffer * st_bp, int do_count)
+static int append_to_buffer(const char __user *ubp, struct st_buffer * st_bp, int do_count)
 {
 	int i, cnt, res, offset;
 
@@ -3553,7 +3559,7 @@
 
 /* Move data from the tape buffer to the user buffer. Returns zero (success) or
    negative error code. */
-static int from_buffer(ST_buffer * st_bp, char __user *ubp, int do_count)
+static int from_buffer(struct st_buffer * st_bp, char __user *ubp, int do_count)
 {
 	int i, cnt, res, offset;
 
@@ -3584,7 +3590,7 @@
 
 
 /* Move data towards start of buffer */
-static void move_buffer_data(ST_buffer * st_bp, int offset)
+static void move_buffer_data(struct st_buffer * st_bp, int offset)
 {
 	int src_seg, dst_seg, src_offset = 0, dst_offset;
 	int count, total;
@@ -3622,7 +3628,7 @@
 
 
 /* Fill the s/g list up to the length required for this transfer */
-static void buf_to_sg(ST_buffer *STbp, unsigned int length)
+static void buf_to_sg(struct st_buffer *STbp, unsigned int length)
 {
 	int i;
 	unsigned int count;
@@ -3720,10 +3726,10 @@
 	struct scsi_device *SDp = to_scsi_device(dev);
 	struct gendisk *disk = NULL;
 	struct cdev *cdev = NULL;
-	Scsi_Tape *tpnt = NULL;
-	ST_mode *STm;
-	ST_partstat *STps;
-	ST_buffer *buffer;
+	struct scsi_tape *tpnt = NULL;
+	struct st_modedef *STm;
+	struct st_partstat *STps;
+	struct st_buffer *buffer;
 	int i, j, mode, dev_num, error;
 	char *stp;
 	u64 bounce_limit;
@@ -3741,9 +3747,10 @@
 	i = SDp->host->sg_tablesize;
 	if (st_max_sg_segs < i)
 		i = st_max_sg_segs;
-	buffer = new_tape_buffer(TRUE, (SDp->host)->unchecked_isa_dma, i);
+	buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i);
 	if (buffer == NULL) {
-		printk(KERN_ERR "st: Can't allocate new tape buffer. Device not attached.\n");
+		printk(KERN_ERR
+		       "st: Can't allocate new tape buffer. Device not attached.\n");
 		goto out;
 	}
 
@@ -3755,7 +3762,7 @@
 
 	write_lock(&st_dev_arr_lock);
 	if (st_nr_dev >= st_dev_max) {
-		Scsi_Tape **tmp_da;
+		struct scsi_tape **tmp_da;
 		int tmp_dev_max;
 
 		tmp_dev_max = max(st_nr_dev * 2, 8);
@@ -3768,17 +3775,17 @@
 			goto out_put_disk;
 		}
 
-		tmp_da = kmalloc(tmp_dev_max * sizeof(Scsi_Tape *), GFP_ATOMIC);
+		tmp_da = kmalloc(tmp_dev_max * sizeof(struct scsi_tape *), GFP_ATOMIC);
 		if (tmp_da == NULL) {
 			write_unlock(&st_dev_arr_lock);
 			printk(KERN_ERR "st: Can't extend device array.\n");
 			goto out_put_disk;
 		}
 
-		memset(tmp_da, 0, tmp_dev_max * sizeof(Scsi_Tape *));
+		memset(tmp_da, 0, tmp_dev_max * sizeof(struct scsi_tape *));
 		if (scsi_tapes != NULL) {
 			memcpy(tmp_da, scsi_tapes,
-			       st_dev_max * sizeof(Scsi_Tape *));
+			       st_dev_max * sizeof(struct scsi_tape *));
 			kfree(scsi_tapes);
 		}
 		scsi_tapes = tmp_da;
@@ -3792,13 +3799,13 @@
 	if (i >= st_dev_max)
 		panic("scsi_devices corrupt (st)");
 
-	tpnt = kmalloc(sizeof(Scsi_Tape), GFP_ATOMIC);
+	tpnt = kmalloc(sizeof(struct scsi_tape), GFP_ATOMIC);
 	if (tpnt == NULL) {
 		write_unlock(&st_dev_arr_lock);
 		printk(KERN_ERR "st: Can't allocate device descriptor.\n");
 		goto out_put_disk;
 	}
-	memset(tpnt, 0, sizeof(Scsi_Tape));
+	memset(tpnt, 0, sizeof(struct scsi_tape));
 	tpnt->disk = disk;
 	sprintf(disk->disk_name, "st%d", i);
 	disk->private_data = &tpnt->driver;
@@ -3844,7 +3851,7 @@
 
 	for (i = 0; i < ST_NBR_MODES; i++) {
 		STm = &(tpnt->modes[i]);
-		STm->defined = FALSE;
+		STm->defined = 0;
 		STm->sysv = ST_SYSV;
 		STm->defaults_for_writes = 0;
 		STm->do_async_writes = ST_ASYNC_WRITES;
@@ -3860,16 +3867,16 @@
 		STps->rw = ST_IDLE;
 		STps->eof = ST_NOEOF;
 		STps->at_sm = 0;
-		STps->last_block_valid = FALSE;
+		STps->last_block_valid = 0;
 		STps->drv_block = (-1);
 		STps->drv_file = (-1);
 	}
 
 	tpnt->current_mode = 0;
-	tpnt->modes[0].defined = TRUE;
+	tpnt->modes[0].defined = 1;
 
 	tpnt->density_changed = tpnt->compression_changed =
-	    tpnt->blksize_changed = FALSE;
+	    tpnt->blksize_changed = 0;
 	init_MUTEX(&tpnt->lock);
 
 	st_nr_dev++;
@@ -3961,8 +3968,8 @@
 
 static int st_remove(struct device *dev)
 {
-	Scsi_Device *SDp = to_scsi_device(dev);
-	Scsi_Tape *tpnt;
+	struct scsi_device *SDp = to_scsi_device(dev);
+	struct scsi_tape *tpnt;
 	int i, j, mode;
 
 	write_lock(&st_dev_arr_lock);
@@ -4136,7 +4143,7 @@
 /* The sysfs simple class interface */
 static ssize_t st_defined_show(struct class_device *class_dev, char *buf)
 {
-	ST_mode *STm = (ST_mode *)class_get_devdata(class_dev);
+	struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
 	ssize_t l = 0;
 
 	l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined);
@@ -4147,7 +4154,7 @@
 
 static ssize_t st_defblk_show(struct class_device *class_dev, char *buf)
 {
-	ST_mode *STm = (ST_mode *)class_get_devdata(class_dev);
+	struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
 	ssize_t l = 0;
 
 	l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize);
@@ -4158,7 +4165,7 @@
 
 static ssize_t st_defdensity_show(struct class_device *class_dev, char *buf)
 {
-	ST_mode *STm = (ST_mode *)class_get_devdata(class_dev);
+	struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
 	ssize_t l = 0;
 	char *fmt;
 
@@ -4171,7 +4178,7 @@
 
 static ssize_t st_defcompression_show(struct class_device *class_dev, char *buf)
 {
-	ST_mode *STm = (ST_mode *)class_get_devdata(class_dev);
+	struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
 	ssize_t l = 0;
 
 	l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1);
@@ -4180,7 +4187,7 @@
 
 CLASS_DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL);
 
-static void do_create_class_files(Scsi_Tape *STp, int dev_num, int mode)
+static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
 {
 	int i, rew, error;
 	char name[10];
@@ -4253,7 +4260,7 @@
 	return nr_pages;
 
  out_unmap:
-	sgl_unmap_user_pages(sgl, nr_pages, FALSE);
+	sgl_unmap_user_pages(sgl, nr_pages, 0);
 	return 0;
 }
 
diff -Nru a/drivers/scsi/st.h b/drivers/scsi/st.h
--- a/drivers/scsi/st.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/st.h	2004-12-24 13:37:18 -08:00
@@ -2,13 +2,11 @@
 #ifndef _ST_H
 #define _ST_H
 
-#ifndef _SCSI_H
-#include "scsi.h"
-#endif
 #include <linux/completion.h>
 
+
 /* The tape buffer descriptor. */
-typedef struct {
+struct st_buffer {
 	unsigned char in_use;
 	unsigned char dma;	/* DMA-able buffer */
 	unsigned char do_dio;   /* direct i/o set up? */
@@ -19,7 +17,7 @@
 	int writing;
 	int midlevel_result;
 	int syscall_result;
-	Scsi_Request *last_SRpnt;
+	struct scsi_request *last_SRpnt;
 	unsigned char *b_data;
 	unsigned short use_sg;	/* zero or max number of s/g segments for this adapter */
 	unsigned short sg_segs;		/* number of segments in s/g list */
@@ -28,7 +26,7 @@
 	unsigned int frp_sg_current;	/* driver buffer length currently in s/g list */
 	struct st_buf_fragment *frp;	/* the allocated buffer fragment list */
 	struct scatterlist sg[1];	/* MUST BE last item */
-} ST_buffer;
+};
 
 /* The tape buffer fragment descriptor */
 struct st_buf_fragment {
@@ -37,7 +35,7 @@
 };
 
 /* The tape mode definition */
-typedef struct {
+struct st_modedef {
 	unsigned char defined;
 	unsigned char sysv;	/* SYS V semantics? */
 	unsigned char do_async_writes;
@@ -48,7 +46,7 @@
 	short default_density;	/* Forced density, -1 = no value */
 	int default_blksize;	/* Forced blocksize, -1 = no value */
 	struct cdev *cdevs[2];  /* Auto-rewind and non-rewind devices */
-} ST_mode;
+};
 
 /* Number of modes can be changed by changing ST_NBR_MODE_BITS. The maximum
    number of modes is 16 (ST_NBR_MODE_BITS 4) */
@@ -61,7 +59,7 @@
 #define ST_MAX_TAPE_ENTRIES  (ST_MAX_TAPES << (ST_NBR_MODE_BITS + 1))
 
 /* The status related to each partition */
-typedef struct {
+struct st_partstat {
 	unsigned char rw;
 	unsigned char eof;
 	unsigned char at_sm;
@@ -69,17 +67,17 @@
 	u32 last_block_visited;
 	int drv_block;		/* The block where the drive head is */
 	int drv_file;
-} ST_partstat;
+};
 
 #define ST_NBR_PARTITIONS 4
 
 /* The tape drive descriptor */
-typedef struct {
+struct scsi_tape {
 	struct scsi_driver *driver;
-	Scsi_Device *device;
+	struct scsi_device *device;
 	struct semaphore lock;	/* For serialization */
 	struct completion wait;	/* For SCSI commands */
-	ST_buffer *buffer;
+	struct st_buffer *buffer;
 
 	/* Drive characteristics */
 	unsigned char omit_blklims;
@@ -105,14 +103,14 @@
 	unsigned long max_pfn;	/* the maximum page number reachable by the HBA */
 
 	/* Mode characteristics */
-	ST_mode modes[ST_NBR_MODES];
+	struct st_modedef modes[ST_NBR_MODES];
 	int current_mode;
 
 	/* Status variables */
 	int partition;
 	int new_partition;
 	int nbr_partitions;	/* zero until partition support enabled */
-	ST_partstat ps[ST_NBR_PARTITIONS];
+	struct st_partstat ps[ST_NBR_PARTITIONS];
 	unsigned char dirty;
 	unsigned char ready;
 	unsigned char write_prot;
@@ -146,7 +144,7 @@
 	unsigned char last_sense[16];
 #endif
 	struct gendisk *disk;
-} Scsi_Tape;
+};
 
 /* Bit masks for use_pf */
 #define USE_PF      1
diff -Nru a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c
--- a/drivers/scsi/sun3_scsi.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/sun3_scsi.c	2004-12-24 13:36:18 -08:00
@@ -107,17 +107,17 @@
 static inline void sun3scsi_write(int reg, int value);
 
 static int setup_can_queue = -1;
-MODULE_PARM(setup_can_queue, "i");
+module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;
-MODULE_PARM(setup_cmd_per_lun, "i");
+module_param(setup_cmd_per_lun, int, 0);
 static int setup_sg_tablesize = -1;
-MODULE_PARM(setup_sg_tablesize, "i");
+module_param(setup_sg_tablesize, int, 0);
 #ifdef SUPPORT_TAGS
 static int setup_use_tagged_queuing = -1;
-MODULE_PARM(setup_use_tagged_queuing, "i");
+module_param(setup_use_tagged_queuing, int, 0);
 #endif
 static int setup_hostid = -1;
-MODULE_PARM(setup_hostid, "i");
+module_param(setup_hostid, int, 0);
 
 static Scsi_Cmnd *sun3_dma_setup_done = NULL;
 
diff -Nru a/drivers/scsi/sun3_scsi_vme.c b/drivers/scsi/sun3_scsi_vme.c
--- a/drivers/scsi/sun3_scsi_vme.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/sun3_scsi_vme.c	2004-12-24 13:37:43 -08:00
@@ -72,17 +72,17 @@
 static inline void sun3scsi_write(int reg, int value);
 
 static int setup_can_queue = -1;
-MODULE_PARM(setup_can_queue, "i");
+module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;
-MODULE_PARM(setup_cmd_per_lun, "i");
+module_param(setup_cmd_per_lun, int, 0);
 static int setup_sg_tablesize = -1;
-MODULE_PARM(setup_sg_tablesize, "i");
+module_param(setup_sg_tablesize, int, 0);
 #ifdef SUPPORT_TAGS
 static int setup_use_tagged_queuing = -1;
-MODULE_PARM(setup_use_tagged_queuing, "i");
+module_param(setup_use_tagged_queuing, int, 0);
 #endif
 static int setup_hostid = -1;
-MODULE_PARM(setup_hostid, "i");
+module_param(setup_hostid, int, 0);
 
 static Scsi_Cmnd *sun3_dma_setup_done = NULL;
 
diff -Nru a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
--- a/drivers/scsi/sun3x_esp.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/scsi/sun3x_esp.c	2004-12-24 13:37:02 -08:00
@@ -370,7 +370,7 @@
 }
 
 static Scsi_Host_Template driver_template = {
-	.proc_name		= "esp",
+	.proc_name		= "sun3x_esp",
 	.proc_info		= &esp_proc_info,
 	.name			= "Sun ESP 100/100a/200",
 	.detect			= sun3x_esp_detect,
diff -Nru a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c
--- a/drivers/scsi/sym53c416.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/scsi/sym53c416.c	2004-12-24 13:36:18 -08:00
@@ -852,10 +852,10 @@
 MODULE_AUTHOR("Lieven Willems");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(sym53c416, "1-2i");
-MODULE_PARM(sym53c416_1, "1-2i");
-MODULE_PARM(sym53c416_2, "1-2i");
-MODULE_PARM(sym53c416_3, "1-2i");
+module_param_array(sym53c416, uint, NULL, 0);
+module_param_array(sym53c416_1, uint, NULL, 0);
+module_param_array(sym53c416_2, uint, NULL, 0);
+module_param_array(sym53c416_3, uint, NULL, 0);
 
 #endif
 
diff -Nru a/drivers/scsi/sym53c8xx_2/sym53c8xx.h b/drivers/scsi/sym53c8xx_2/sym53c8xx.h
--- a/drivers/scsi/sym53c8xx_2/sym53c8xx.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym53c8xx.h	2004-12-24 13:37:31 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef SYM53C8XX_H
@@ -81,7 +68,6 @@
  */
 #if 1
 #define	SYM_LINUX_PROC_INFO_SUPPORT
-#define SYM_LINUX_BOOT_COMMAND_LINE_SUPPORT
 #define SYM_LINUX_USER_COMMAND_SUPPORT
 #define SYM_LINUX_USER_INFO_SUPPORT
 #define SYM_LINUX_DEBUG_CONTROL_SUPPORT
@@ -142,9 +128,7 @@
 	u_char	scsi_bus_check;
 	u_char	host_id;
 
-	u_char	reverse_probe;
 	u_char	verbose;
-	u_short	debug;
 	u_char	settle_delay;
 	u_char	use_nvram;
 	u_long	excludes[8];
@@ -158,6 +142,7 @@
 #define SYM_SETUP_IRQ_MODE		sym_driver_setup.irq_mode
 #define SYM_SETUP_SCSI_BUS_CHECK	sym_driver_setup.scsi_bus_check
 #define SYM_SETUP_HOST_ID		sym_driver_setup.host_id
+#define boot_verbose			sym_driver_setup.verbose
 
 /* Always enable parity. */
 #define SYM_SETUP_PCI_PARITY		1
@@ -176,54 +161,13 @@
 	.irq_mode	= 0,					\
 	.scsi_bus_check	= 1,					\
 	.host_id	= 7,					\
-	.reverse_probe	= 0,					\
 	.verbose	= 0,					\
-	.debug		= 0,					\
 	.settle_delay	= 3,					\
 	.use_nvram	= 1,					\
 }
 
-/*
- *  Boot fail safe setup.
- *
- *  Override initial setup from boot command line:
- *    sym53c8xx=safe:y
- */
-#define SYM_LINUX_DRIVER_SAFE_SETUP {				\
-	.max_tag	= 0,					\
-	.burst_order	= 0,					\
-	.scsi_led	= 0,					\
-	.scsi_diff	= 1,					\
-	.irq_mode	= 0,					\
-	.scsi_bus_check	= 2,					\
-	.host_id	= 7,					\
-	.reverse_probe	= 0,					\
-	.verbose	= 2,					\
-	.debug		= 0,					\
-	.settle_delay	= 10,					\
-	.use_nvram	= 1,					\
-}
-
-/*
- *  This structure is initialized from linux config options.
- *  It can be overridden at boot-up by the boot command line.
- */
-#ifdef SYM_GLUE_C
-struct sym_driver_setup
-	sym_driver_setup = SYM_LINUX_DRIVER_SETUP;
-#ifdef SYM_LINUX_DEBUG_CONTROL_SUPPORT
-u_int	sym_debug_flags = 0;
-#endif
-#else
 extern struct sym_driver_setup sym_driver_setup;
-#ifdef SYM_LINUX_DEBUG_CONTROL_SUPPORT
-extern u_int sym_debug_flags;
-#endif
-#endif /* SYM_GLUE_C */
-
-#ifdef SYM_LINUX_DEBUG_CONTROL_SUPPORT
+extern unsigned int sym_debug_flags;
 #define DEBUG_FLAGS	sym_debug_flags
-#endif
-#define boot_verbose	sym_driver_setup.verbose
 
 #endif /* SYM53C8XX_H */
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_conf.h b/drivers/scsi/sym53c8xx_2/sym_conf.h
--- a/drivers/scsi/sym53c8xx_2/sym_conf.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_conf.h	2004-12-24 13:37:18 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef SYM_CONF_H
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_defs.h b/drivers/scsi/sym53c8xx_2/sym_defs.h
--- a/drivers/scsi/sym53c8xx_2/sym_defs.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_defs.h	2004-12-24 13:36:47 -08:00
@@ -22,64 +22,46 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef SYM_DEFS_H
 #define SYM_DEFS_H
 
-#define SYM_VERSION "2.1.18j"
+#define SYM_VERSION "2.1.18m"
 #define SYM_DRIVER_NAME	"sym-" SYM_VERSION
 
 /*
- *  Vendor.
- */
-#define PCI_VENDOR_NCR		0x1000
-
-/*
  *  PCI device identifier of SYMBIOS chips.
  */
-#define PCI_ID_SYM53C810	1
-#define PCI_ID_SYM53C810AP	5
-#define PCI_ID_SYM53C815	4
-#define PCI_ID_SYM53C820	2
-#define PCI_ID_SYM53C825	3
-#define PCI_ID_SYM53C860	6
-#define PCI_ID_SYM53C875	0xf
-#define PCI_ID_SYM53C875_2	0x8f
-#define PCI_ID_SYM53C885	0xd
-#define PCI_ID_SYM53C895	0xc
-#define PCI_ID_SYM53C896	0xb
-#define PCI_ID_SYM53C895A	0x12
-#define PCI_ID_SYM53C875A	0x13
-#define PCI_ID_LSI53C1010_33	0x20
-#define PCI_ID_LSI53C1010_66	0x21
-#define PCI_ID_LSI53C1510D	0xa
+#define PCI_ID_SYM53C810	PCI_DEVICE_ID_NCR_53C810
+#define PCI_ID_SYM53C810AP	PCI_DEVICE_ID_LSI_53C810AP
+#define PCI_ID_SYM53C815	PCI_DEVICE_ID_NCR_53C815
+#define PCI_ID_SYM53C820	PCI_DEVICE_ID_NCR_53C820
+#define PCI_ID_SYM53C825	PCI_DEVICE_ID_NCR_53C825
+#define PCI_ID_SYM53C860	PCI_DEVICE_ID_NCR_53C860
+#define PCI_ID_SYM53C875	PCI_DEVICE_ID_NCR_53C875
+#define PCI_ID_SYM53C875_2	PCI_DEVICE_ID_NCR_53C875J
+#define PCI_ID_SYM53C885	PCI_DEVICE_ID_NCR_53C885
+#define PCI_ID_SYM53C895	PCI_DEVICE_ID_NCR_53C895
+#define PCI_ID_SYM53C896	PCI_DEVICE_ID_NCR_53C896
+#define PCI_ID_SYM53C895A	PCI_DEVICE_ID_LSI_53C895A
+#define PCI_ID_SYM53C875A	PCI_DEVICE_ID_LSI_53C875A
+#define PCI_ID_LSI53C1010_33	PCI_DEVICE_ID_LSI_53C1010_33
+#define PCI_ID_LSI53C1010_66	PCI_DEVICE_ID_LSI_53C1010_66
+#define PCI_ID_LSI53C1510D	PCI_DEVICE_ID_LSI_53C1510
 
 /*
  *	SYM53C8XX device features descriptor.
@@ -776,33 +758,32 @@
  *	Messages
  */
 
-#define	M_COMPLETE	(0x00)
-#define	M_EXTENDED	(0x01)
-#define	M_SAVE_DP	(0x02)
-#define	M_RESTORE_DP	(0x03)
-#define	M_DISCONNECT	(0x04)
-#define	M_ID_ERROR	(0x05)
-#define	M_ABORT		(0x06)
-#define	M_REJECT	(0x07)
-#define	M_NOOP		(0x08)
-#define	M_PARITY	(0x09)
-#define	M_LCOMPLETE	(0x0a)
-#define	M_FCOMPLETE	(0x0b)
-#define	M_RESET		(0x0c)
+#define	M_COMPLETE	COMMAND_COMPLETE
+#define	M_EXTENDED	EXTENDED_MESSAGE
+#define	M_SAVE_DP	SAVE_POINTERS
+#define	M_RESTORE_DP	RESTORE_POINTERS
+#define	M_DISCONNECT	DISCONNECT
+#define	M_ID_ERROR	INITIATOR_ERROR
+#define	M_ABORT		ABORT
+#define	M_REJECT	MESSAGE_REJECT
+#define	M_NOOP		NOP
+#define	M_PARITY	MSG_PARITY_ERROR
+#define	M_LCOMPLETE	LINKED_CMD_COMPLETE
+#define	M_FCOMPLETE	LINKED_FLG_CMD_COMPLETE
+#define	M_RESET		BUS_DEVICE_RESET
 #define	M_ABORT_TAG	(0x0d)
 #define	M_CLEAR_QUEUE	(0x0e)
-#define	M_INIT_REC	(0x0f)
-#define	M_REL_REC	(0x10)
+#define	M_INIT_REC	INITIATE_RECOVERY
+#define	M_REL_REC	RELEASE_RECOVERY
 #define	M_TERMINATE	(0x11)
-#define	M_SIMPLE_TAG	(0x20)
-#define	M_HEAD_TAG	(0x21)
-#define	M_ORDERED_TAG	(0x22)
+#define	M_SIMPLE_TAG	SIMPLE_QUEUE_TAG
+#define	M_HEAD_TAG	HEAD_OF_QUEUE_TAG
+#define	M_ORDERED_TAG	ORDERED_QUEUE_TAG
 #define	M_IGN_RESIDUE	(0x23)
-#define	M_IDENTIFY   	(0x80)
 
-#define	M_X_MODIFY_DP	(0x00)
-#define	M_X_SYNC_REQ	(0x01)
-#define	M_X_WIDE_REQ	(0x03)
+#define	M_X_MODIFY_DP	EXTENDED_MODIFY_DATA_POINTER
+#define	M_X_SYNC_REQ	EXTENDED_SDTR
+#define	M_X_WIDE_REQ	EXTENDED_WDTR
 #define	M_X_PPR_REQ	(0x04)
 
 /*
@@ -817,15 +798,15 @@
  *	Status
  */
 
-#define	S_GOOD		(0x00)
-#define	S_CHECK_COND	(0x02)
-#define	S_COND_MET	(0x04)
-#define	S_BUSY		(0x08)
-#define	S_INT		(0x10)
-#define	S_INT_COND_MET	(0x14)
-#define	S_CONFLICT	(0x18)
-#define	S_TERMINATED	(0x20)
-#define	S_QUEUE_FULL	(0x28)
+#define	S_GOOD		SAM_STAT_GOOD
+#define	S_CHECK_COND	SAM_STAT_CHECK_CONDITION
+#define	S_COND_MET	SAM_STAT_CONDITION_MET
+#define	S_BUSY		SAM_STAT_BUSY
+#define	S_INT		SAM_STAT_INTERMEDIATE
+#define	S_INT_COND_MET	SAM_STAT_INTERMEDIATE_CONDITION_MET
+#define	S_CONFLICT	SAM_STAT_RESERVATION_CONFLICT
+#define	S_TERMINATED	SAM_STAT_COMMAND_TERMINATED
+#define	S_QUEUE_FULL	SAM_STAT_TASK_SET_FULL
 #define	S_ILLEGAL	(0xff)
 
 #endif /* defined SYM_DEFS_H */
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c
--- a/drivers/scsi/sym53c8xx_2/sym_fw.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.c	2004-12-24 13:37:30 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifdef __FreeBSD__
@@ -411,7 +398,6 @@
 		if (opcode == 0) {
 			printf ("%s: ERROR0 IN SCRIPT at %d.\n",
 				sym_name(np), (int) (cur-start));
-			MDELAY (10000);
 			++cur;
 			continue;
 		};
@@ -455,7 +441,6 @@
 			if ((tmp1 ^ tmp2) & 3) {
 				printf ("%s: ERROR1 IN SCRIPT at %d.\n",
 					sym_name(np), (int) (cur-start));
-				MDELAY (10000);
 			}
 			/*
 			 *  If PREFETCH feature not enabled, remove 
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_fw.h b/drivers/scsi/sym53c8xx_2/sym_fw.h
--- a/drivers/scsi/sym53c8xx_2/sym_fw.h	2004-12-24 13:36:56 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.h	2004-12-24 13:36:56 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef	SYM_FW_H
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_fw1.h b/drivers/scsi/sym53c8xx_2/sym_fw1.h
--- a/drivers/scsi/sym53c8xx_2/sym_fw1.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_fw1.h	2004-12-24 13:37:18 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 /*
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_fw2.h b/drivers/scsi/sym53c8xx_2/sym_fw2.h
--- a/drivers/scsi/sym53c8xx_2/sym_fw2.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_fw2.h	2004-12-24 13:37:19 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 /*
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c	2004-12-24 13:37:43 -08:00
@@ -3,6 +3,7 @@
  * of PCI-SCSI IO processors.
  *
  * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
+ * Copyright (c) 2003-2004  Matthew Wilcox <matthew@wil.cx>
  *
  * This driver is derived from the Linux sym53c8xx driver.
  * Copyright (C) 1998-2000  Gerard Roudier
@@ -22,39 +23,25 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#define SYM_GLUE_C
-
 #include <linux/ctype.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/spinlock.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_tcq.h>
@@ -68,6 +55,77 @@
 #define NAME53C		"sym53c"
 #define NAME53C8XX	"sym53c8xx"
 
+struct sym_driver_setup sym_driver_setup = SYM_LINUX_DRIVER_SETUP;
+unsigned int sym_debug_flags = 0;
+
+static char *excl_string;
+static char *safe_string;
+module_param_named(cmd_per_lun, sym_driver_setup.max_tag, ushort, 0);
+module_param_string(tag_ctrl, sym_driver_setup.tag_ctrl, 100, 0);
+module_param_named(burst, sym_driver_setup.burst_order, byte, 0);
+module_param_named(led, sym_driver_setup.scsi_led, byte, 0);
+module_param_named(diff, sym_driver_setup.scsi_diff, byte, 0);
+module_param_named(irqm, sym_driver_setup.irq_mode, byte, 0);
+module_param_named(buschk, sym_driver_setup.scsi_bus_check, byte, 0);
+module_param_named(hostid, sym_driver_setup.host_id, byte, 0);
+module_param_named(verb, sym_driver_setup.verbose, byte, 0);
+module_param_named(debug, sym_debug_flags, uint, 0);
+module_param_named(settle, sym_driver_setup.settle_delay, byte, 0);
+module_param_named(nvram, sym_driver_setup.use_nvram, byte, 0);
+module_param_named(excl, excl_string, charp, 0);
+module_param_named(safe, safe_string, charp, 0);
+
+MODULE_PARM_DESC(cmd_per_lun, "The maximum number of tags to use by default");
+MODULE_PARM_DESC(tag_ctrl, "More detailed control over tags per LUN");
+MODULE_PARM_DESC(burst, "Maximum burst.  0 to disable, 255 to read from registers");
+MODULE_PARM_DESC(led, "Set to 1 to enable LED support");
+MODULE_PARM_DESC(diff, "0 for no differential mode, 1 for BIOS, 2 for always, 3 for not GPIO3");
+MODULE_PARM_DESC(irqm, "0 for open drain, 1 to leave alone, 2 for totem pole");
+MODULE_PARM_DESC(buschk, "0 to not check, 1 for detach on error, 2 for warn on error");
+MODULE_PARM_DESC(hostid, "The SCSI ID to use for the host adapters");
+MODULE_PARM_DESC(verb, "0 for minimal verbosity, 1 for normal, 2 for excessive");
+MODULE_PARM_DESC(debug, "Set bits to enable debugging");
+MODULE_PARM_DESC(settle, "Settle delay in seconds.  Default 3");
+MODULE_PARM_DESC(nvram, "Option currently not used");
+MODULE_PARM_DESC(excl, "List ioport addresses here to prevent controllers from being attached");
+MODULE_PARM_DESC(safe, "Set other settings to a \"safe mode\"");
+
+MODULE_LICENSE("GPL");
+MODULE_VERSION(SYM_VERSION);
+MODULE_AUTHOR("Matthew Wilcox <matthew@wil.cx>");
+MODULE_DESCRIPTION("NCR, Symbios and LSI 8xx and 1010 PCI SCSI adapters");
+
+static void sym2_setup_params(void)
+{
+	char *p = excl_string;
+	int xi = 0;
+
+	while (p && (xi < 8)) {
+		char *next_p;
+		int val = (int) simple_strtoul(p, &next_p, 0);
+		sym_driver_setup.excludes[xi++] = val;
+		p = next_p;
+	}
+
+	if (safe_string) {
+		if (*safe_string == 'y') {
+			sym_driver_setup.max_tag = 0;
+			sym_driver_setup.burst_order = 0;
+			sym_driver_setup.scsi_led = 0;
+			sym_driver_setup.scsi_diff = 1;
+			sym_driver_setup.irq_mode = 0;
+			sym_driver_setup.scsi_bus_check = 2;
+			sym_driver_setup.host_id = 7;
+			sym_driver_setup.verbose = 2;
+			sym_driver_setup.settle_delay = 10;
+			sym_driver_setup.use_nvram = 1;
+		} else if (*safe_string != 'n') {
+			printk(KERN_WARNING NAME53C8XX "Ignoring parameter %s"
+					" passed to safe option", safe_string);
+		}
+	}
+}
+
 static int __devinit
 pci_get_base_address(struct pci_dev *pdev, int index, u_long *base)
 {
@@ -147,7 +205,7 @@
  *  It is allocated on the eh thread stack.
  */
 struct sym_eh_wait {
-	struct semaphore sem;
+	struct completion done;
 	struct timer_list timer;
 	void (*old_done)(struct scsi_cmnd *);
 	int to_do;
@@ -158,7 +216,6 @@
  *  Driver private area in the SCSI command structure.
  */
 struct sym_ucmd {		/* Override the SCSI pointer structure */
-	SYM_QUEHEAD link_cmdq;	/* Must stay at offset ZERO */
 	dma_addr_t data_mapping;
 	u_char	data_mapped;
 	struct sym_eh_wait *eh_wait;
@@ -224,7 +281,6 @@
  */
 void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *ccb)
 {
-	sym_remque(&SYM_UCMD_PTR(ccb)->link_cmdq);
 	unmap_scsi_data(np, ccb);
 	ccb->scsi_done(ccb);
 }
@@ -573,7 +629,6 @@
 	switch (cp->cdb_buf[0]) {
 	case 0x0A: case 0x2A: case 0xAA:
 		panic("XXXXXXXXXXXXX WRITE NOT YET ALLOWED XXXXXXXXXXXXXX\n");
-		MDELAY(10000);
 		break;
 	default:
 		break;
@@ -661,31 +716,6 @@
 	}
 }
 
-
-/*
- *  Requeue awaiting commands.
- */
-static void sym_requeue_awaiting_cmds(struct sym_hcb *np)
-{
-	struct sym_ucmd *ucp;
-	SYM_QUEHEAD tmp_cmdq;
-	int sts;
-
-	sym_que_move(&np->s.wait_cmdq, &tmp_cmdq);
-
-	while ((ucp = (struct sym_ucmd *) sym_remque_head(&tmp_cmdq)) != 0) {
-		struct scsi_cmnd *cmd;
-
-		sym_insque_tail(&ucp->link_cmdq, &np->s.busy_cmdq);
-		cmd = SYM_SCMD_PTR(ucp);
-		sts = sym_queue_command(np, cmd);
-		if (sts) {
-			sym_remque(&ucp->link_cmdq);
-			sym_insque_head(&ucp->link_cmdq, &np->s.wait_cmdq);
-		}
-	}
-}
-
 /*
  * queuecommand method.  Entered with the host adapter lock held and
  * interrupts disabled.
@@ -713,18 +743,12 @@
 		}
 	}
 
-	if (np->s.settle_time_valid || !sym_que_empty(&np->s.wait_cmdq)) {
-		sym_insque_tail(&ucp->link_cmdq, &np->s.wait_cmdq);
-		goto out;
-	}
+	if (np->s.settle_time_valid)
+		return SCSI_MLQUEUE_HOST_BUSY;
 
-	sym_insque_tail(&ucp->link_cmdq, &np->s.busy_cmdq);
 	sts = sym_queue_command(np, cmd);
-	if (sts) {
-		sym_remque(&ucp->link_cmdq);
-		sym_insque_tail(&ucp->link_cmdq, &np->s.wait_cmdq);
-	}
-out:
+	if (sts)
+		return SCSI_MLQUEUE_HOST_BUSY;
 	return 0;
 }
 
@@ -739,15 +763,7 @@
 	if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("[");
 
 	spin_lock_irqsave(np->s.host->host_lock, flags);
-
 	sym_interrupt(np);
-
-	/*
-	 * push queue walk-through to tasklet
-	 */
-	if (!sym_que_empty(&np->s.wait_cmdq) && !np->s.settle_time_valid)
-		sym_requeue_awaiting_cmds(np);
-
 	spin_unlock_irqrestore(np->s.host->host_lock, flags);
 
 	if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("]\n");
@@ -764,12 +780,7 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(np->s.host->host_lock, flags);
-
 	sym_timer(np);
-
-	if (!sym_que_empty(&np->s.wait_cmdq) && !np->s.settle_time_valid)
-		sym_requeue_awaiting_cmds(np);
-
 	spin_unlock_irqrestore(np->s.host->host_lock, flags);
 }
 
@@ -811,7 +822,7 @@
 
 	/* Wake up the eh thread if it wants to sleep */
 	if (ep->to_do == SYM_EH_DO_WAIT)
-		up(&ep->sem);
+		complete(&ep->done);
 }
 
 /*
@@ -847,14 +858,6 @@
 		goto prepare;
 #endif
 
-	/* This one is not queued to the core driver -> to complete here */ 
-	FOR_EACH_QUEUED_ELEMENT(&np->s.wait_cmdq, qp) {
-		if (SYM_SCMD_PTR(qp) == cmd) {
-			to_do = SYM_EH_DO_COMPLETE;
-			goto prepare;
-		}
-	}
-
 	/* This one is queued in some place -> to wait for completion */
 	FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
 		struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb, link_ccbq);
@@ -871,7 +874,7 @@
 	case SYM_EH_DO_IGNORE:
 		break;
 	case SYM_EH_DO_WAIT:
-		init_MUTEX_LOCKED(&ep->sem);
+		init_completion(&ep->done);
 		/* fall through */
 	case SYM_EH_DO_COMPLETE:
 		ep->old_done = cmd->scsi_done;
@@ -922,7 +925,7 @@
 		ep->timed_out = 1;	/* Be pessimistic for once :) */
 		add_timer(&ep->timer);
 		spin_unlock_irq(np->s.host->host_lock);
-		down(&ep->sem);
+		wait_for_completion(&ep->done);
 		spin_lock_irq(np->s.host->host_lock);
 		if (ep->timed_out)
 			sts = -2;
@@ -986,7 +989,6 @@
 	}
 }
 
-#ifdef	SYM_LINUX_BOOT_COMMAND_LINE_SUPPORT
 /*
  *  Linux select queue depths function
  */
@@ -1039,9 +1041,6 @@
 	}
 	return DEF_DEPTH;
 }
-#else
-#define device_queue_depth(np, t, l)	(sym_driver_setup.max_tag)
-#endif	/* SYM_LINUX_BOOT_COMMAND_LINE_SUPPORT */
 
 /*
  * Linux entry point for device queue sizing.
@@ -1096,7 +1095,8 @@
 	lp->s.scdev_depth = depth_to_use;
 	sym_tune_dev_queuing(np, device->id, device->lun, reqtags);
 
-	spi_dv_device(device);
+	if (!spi_initial_dv(device->sdev_target))
+		spi_dv_device(device);
 
 	return 0;
 }
@@ -1176,7 +1176,7 @@
 				if (uc->data <= 9 && np->minsync_dt) {
 					if (uc->data < np->minsync_dt)
 						uc->data = np->minsync_dt;
-					tp->tinfo.goal.options = PPR_OPT_DT;
+					tp->tinfo.goal.options = PPR_OPT_MASK;
 					tp->tinfo.goal.width   = 1;
 					tp->tinfo.goal.period = uc->data;
 					tp->tinfo.goal.offset = np->maxoffs_dt;
@@ -1744,12 +1744,6 @@
 		goto reset_failed;
 
 	/*
-	 *  Initialize some queue headers.
-	 */
-	sym_que_init(&np->s.wait_cmdq);
-	sym_que_init(&np->s.busy_cmdq);
-
-	/*
 	 *  Start the SCRIPTS.
 	 */
 	sym_start_up (np, 1);
@@ -1840,178 +1834,14 @@
 }
 #endif	/* SYM_CONF_NVRAM_SUPPORT */
 
-/*
- *  Driver setup from the boot command line
- */
-#ifdef	SYM_LINUX_BOOT_COMMAND_LINE_SUPPORT
-
-static struct sym_driver_setup
-	sym_driver_safe_setup __initdata = SYM_LINUX_DRIVER_SAFE_SETUP;
-#ifdef	MODULE
-char *sym53c8xx;	/* command line passed by insmod */
-MODULE_PARM(sym53c8xx, "s");
-#endif
-
-#define OPT_MAX_TAG		1
-#define OPT_BURST_ORDER		2
-#define OPT_SCSI_LED		3
-#define OPT_SCSI_DIFF		4
-#define OPT_IRQ_MODE		5
-#define OPT_SCSI_BUS_CHECK	6
-#define	OPT_HOST_ID		7
-#define OPT_REVERSE_PROBE	8
-#define OPT_VERBOSE		9
-#define OPT_DEBUG		10
-#define OPT_SETTLE_DELAY	11
-#define OPT_USE_NVRAM		12
-#define OPT_EXCLUDE		13
-#define OPT_SAFE_SETUP		14
-
-static char setup_token[] __initdata =
-	"tags:"		"burst:"
-	"led:"		"diff:"
-	"irqm:"		"buschk:"
-	"hostid:"	"revprob:"
-	"verb:"		"debug:"
-	"settle:"	"nvram:"
-	"excl:"		"safe:"
-	;
-
-#ifdef MODULE
-#define	ARG_SEP	' '
-#else
-#define	ARG_SEP	','
-#endif
-
-static int __init get_setup_token(char *p)
-{
-	char *cur = setup_token;
-	char *pc;
-	int i = 0;
-
-	while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
-		++pc;
-		++i;
-		if (!strncmp(p, cur, pc - cur))
-			return i;
-		cur = pc;
-	}
-	return 0;
-}
-#endif	/* SYM_LINUX_BOOT_COMMAND_LINE_SUPPORT */
-
-int __init sym53c8xx_setup(char *str)
-{
-#ifdef	SYM_LINUX_BOOT_COMMAND_LINE_SUPPORT
-	char *cur = str;
-	char *pc, *pv;
-	unsigned long val;
-	unsigned int i,  c;
-	int xi = 0;
-
-	while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
-		char *pe;
-
-		val = 0;
-		pv = pc;
-		c = *++pv;
-
-		if	(c == 'n')
-			val = 0;
-		else if	(c == 'y')
-			val = 1;
-		else
-			val = (int) simple_strtoul(pv, &pe, 0);
-
-		switch (get_setup_token(cur)) {
-		case OPT_MAX_TAG:
-			sym_driver_setup.max_tag = val;
-			if (!(pe && *pe == '/'))
-				break;
-			i = 0;
-			while (*pe && *pe != ARG_SEP && 
-				i < sizeof(sym_driver_setup.tag_ctrl)-1) {
-				sym_driver_setup.tag_ctrl[i++] = *pe++;
-			}
-			sym_driver_setup.tag_ctrl[i] = '\0';
-			break;
-		case OPT_SAFE_SETUP:
-			memcpy(&sym_driver_setup, &sym_driver_safe_setup,
-				sizeof(sym_driver_setup));
-			break;
-		case OPT_EXCLUDE:
-			if (xi < 8)
-				sym_driver_setup.excludes[xi++] = val;
-			break;
-
-#define __SIMPLE_OPTION(NAME, name) \
-		case OPT_ ## NAME :		\
-			sym_driver_setup.name = val;\
-			break;
-
-		__SIMPLE_OPTION(BURST_ORDER, burst_order)
-		__SIMPLE_OPTION(SCSI_LED, scsi_led)
-		__SIMPLE_OPTION(SCSI_DIFF, scsi_diff)
-		__SIMPLE_OPTION(IRQ_MODE, irq_mode)
-		__SIMPLE_OPTION(SCSI_BUS_CHECK, scsi_bus_check)
-		__SIMPLE_OPTION(HOST_ID, host_id)
-		__SIMPLE_OPTION(REVERSE_PROBE, reverse_probe)
-		__SIMPLE_OPTION(VERBOSE, verbose)
-		__SIMPLE_OPTION(DEBUG, debug)
-		__SIMPLE_OPTION(SETTLE_DELAY, settle_delay)
-		__SIMPLE_OPTION(USE_NVRAM, use_nvram)
-
-#undef __SIMPLE_OPTION
-
-		default:
-			printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur);
-			break;
-		}
-
-		if ((cur = strchr(cur, ARG_SEP)) != NULL)
-			++cur;
-	}
-#endif	/* SYM_LINUX_BOOT_COMMAND_LINE_SUPPORT */
-	return 1;
-}
-
-#ifndef MODULE
-__setup("sym53c8xx=", sym53c8xx_setup);
-#endif
-
-/*
- *  Read and check the PCI configuration for any detected NCR 
- *  boards and save data for attaching after all boards have 
- *  been detected.
- */
-static int __devinit
-sym53c8xx_pci_init(struct pci_dev *pdev, struct sym_device *device)
+static int __devinit sym_check_supported(struct sym_device *device)
 {
 	struct sym_pci_chip *chip;
-	u_long base, base_2; 
-	u_long base_c, base_2_c, io_port; 
-	int i;
-	u_short device_id, status_reg;
+	struct pci_dev *pdev = device->pdev;
 	u_char revision;
-
-	/* Choose some short name for this device */
-	sprintf(device->s.inst_name, "sym.%d.%d.%d", pdev->bus->number,
-			PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
-
-	device_id = pdev->device;
-
-	io_port = pdev->resource[0].start;
-
-	base_c = pdev->resource[1].start;
-	i = pci_get_base_address(pdev, 1, &base);
-
-	base_2_c = pdev->resource[i].start;
-	pci_get_base_address(pdev, i, &base_2);
-
-	base	&= PCI_BASE_ADDRESS_MEM_MASK;
-	base_2	&= PCI_BASE_ADDRESS_MEM_MASK;
-
-	pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
+	unsigned long io_port = device->s.io_port;
+	unsigned long base = device->s.base;
+	int i;
 
 	/*
 	 *  If user excluded this chip, do not initialize it.
@@ -2019,20 +1849,11 @@
 	if (io_port) {
 		for (i = 0 ; i < 8 ; i++) {
 			if (sym_driver_setup.excludes[i] == io_port)
-				return -1;
+				return -ENODEV;
 		}
 	}
 
 	/*
-	 *  Check if the chip is supported.
-	 */
-	chip = sym_lookup_pci_chip_table(device_id, revision);
-	if (!chip) {
-		printf_info("%s: device not supported\n", sym_name(device));
-		return -1;
-	}
-
-	/*
 	 *  Check if the chip has been assigned resources we need.
 	 *  XXX: can this still happen with Linux 2.6's PCI layer?
 	 */
@@ -2040,66 +1861,84 @@
 	if (!io_port) {
 		printf_info("%s: IO base address disabled.\n",
 			    sym_name(device));
-		return -1;
+		return -ENODEV;
 	}
 #else
 	if (!base) {
 		printf_info("%s: MMIO base address disabled.\n",
 			    sym_name(device));
-		return -1;
+		return -ENODEV;
 	}
 #endif
 
 	/*
-	 *  Ignore Symbios chips controlled by various RAID controllers.
-	 *  These controllers set value 0x52414944 at RAM end - 16.
+	 * Check if the chip is supported.  Then copy the chip description
+	 * to our device structure so we can make it match the actual device
+	 * and options.
 	 */
-#if defined(__i386__)
-	if (base_2_c) {
-		unsigned int ram_size, ram_val;
-		void *ram_ptr;
-
-		if (chip->features & FE_RAM8K)
-			ram_size = 8192;
-		else
-			ram_size = 4096;
-
-		ram_ptr = ioremap(base_2_c, ram_size);
-		if (ram_ptr) {
-			ram_val = readl_raw(ram_ptr + ram_size - 16);
-			iounmap(ram_ptr);
-			if (ram_val == 0x52414944) {
-				printf_info("%s: not initializing, "
-					    "driven by RAID controller.\n",
-					    sym_name(device));
-				return -1;
-			}
-		}
+	pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
+	chip = sym_lookup_pci_chip_table(pdev->device, revision);
+	if (!chip) {
+		printf_info("%s: device not supported\n", sym_name(device));
+		return -ENODEV;
 	}
-#endif /* i386 and PCI MEMORY accessible */
-
-	/*
-	 *  Copy the chip description to our device structure, 
-	 *  so we can make it match the actual device and options.
-	 */
 	memcpy(&device->chip, chip, sizeof(device->chip));
 	device->chip.revision_id = revision;
 
+	return 0;
+}
+
+/*
+ * Ignore Symbios chips controlled by various RAID controllers.
+ * These controllers set value 0x52414944 at RAM end - 16.
+ */
+static int __devinit sym_check_raid(struct sym_device *device)
+{
+	unsigned long base_2_c = device->s.base_2_c;
+	unsigned int ram_size, ram_val;
+	void __iomem *ram_ptr;
+
+	if (!base_2_c)
+		return 0;
+
+	if (device->chip.features & FE_RAM8K)
+		ram_size = 8192;
+	else
+		ram_size = 4096;
+
+	ram_ptr = ioremap(base_2_c, ram_size);
+	if (!ram_ptr)
+		return 0;
+
+	ram_val = readl(ram_ptr + ram_size - 16);
+	iounmap(ram_ptr);
+	if (ram_val != 0x52414944)
+		return 0;
+
+	printf_info("%s: not initializing, driven by RAID controller.\n",
+		    sym_name(device));
+	return -ENODEV;
+}
+
+static int __devinit sym_set_workarounds(struct sym_device *device)
+{
+	struct sym_pci_chip *chip = &device->chip;
+	struct pci_dev *pdev = device->pdev;
+	u_short status_reg;
+
 	/*
-	 *  Some features are required to be enabled in order to 
-	 *  work around some chip problems. :) ;)
 	 *  (ITEM 12 of a DEL about the 896 I haven't yet).
 	 *  We must ensure the chip will use WRITE AND INVALIDATE.
 	 *  The revision number limit is for now arbitrary.
 	 */
-	if (device_id == PCI_DEVICE_ID_NCR_53C896 && revision < 0x4) {
+	if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && chip->revision_id < 0x4) {
 		chip->features	|= (FE_WRIE | FE_CLSE);
 	}
 
 	/* If the chip can do Memory Write Invalidate, enable it */
 	if (chip->features & FE_WRIE) {
 		if (pci_set_mwi(pdev))
-			return -1;
+			return -ENODEV;
 	}
 
 	/*
@@ -2125,21 +1964,40 @@
 		}
 	}
 
- 	/*
-	 *  Initialise device structure with items required by sym_attach.
-	 */
-	device->pdev		= pdev;
-	device->s.base		= base;
-	device->s.base_2	= base_2;
-	device->s.base_c	= base_c;
-	device->s.base_2_c	= base_2_c;
-	device->s.io_port	= io_port;
-	device->s.irq		= pdev->irq;
-
 	return 0;
 }
 
 /*
+ *  Read and check the PCI configuration for any detected NCR 
+ *  boards and save data for attaching after all boards have 
+ *  been detected.
+ */
+static void __devinit
+sym_init_device(struct pci_dev *pdev, struct sym_device *device)
+{
+	unsigned long base, base_2; 
+	int i;
+
+	device->host_id = SYM_SETUP_HOST_ID;
+	device->pdev = pdev;
+	device->s.irq = pdev->irq;
+
+	/* Choose some short name for this device */
+	sprintf(device->s.inst_name, "sym.%d.%d.%d", pdev->bus->number,
+			PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
+
+	device->s.io_port = pdev->resource[0].start;
+
+	device->s.base_c = pdev->resource[1].start;
+	i = pci_get_base_address(pdev, 1, &base);
+	device->s.base = base & PCI_BASE_ADDRESS_MEM_MASK;
+
+	device->s.base_2_c = pdev->resource[i].start;
+	pci_get_base_address(pdev, i, &base_2);
+	device->s.base_2 = base_2 & PCI_BASE_ADDRESS_MEM_MASK;
+}
+
+/*
  * The NCR PQS and PDS cards are constructed as a DEC bridge
  * behind which sits a proprietary NCR memory controller and
  * either four or two 53c875s as separate devices.  We can tell
@@ -2155,9 +2013,9 @@
 void sym_config_pqs(struct pci_dev *pdev, struct sym_device *sym_dev)
 {
 	int slot;
+	u8 tmp;
 
 	for (slot = 0; slot < 256; slot++) {
-		u8 tmp;
 		struct pci_dev *memc = pci_get_slot(pdev->bus, slot);
 
 		if (!memc || memc->vendor != 0x101a || memc->device == 0x0009) {
@@ -2165,28 +2023,26 @@
 			continue;
 		}
 
-		/*
-		 * We set these bits in the memory controller once per 875.
-		 * This isn't a problem in practice.
-		 */
-
 		/* bit 1: allow individual 875 configuration */
 		pci_read_config_byte(memc, 0x44, &tmp);
-		tmp |= 0x2;
-		pci_write_config_byte(memc, 0x44, tmp);
+		if ((tmp & 0x2) == 0) {
+			tmp |= 0x2;
+			pci_write_config_byte(memc, 0x44, tmp);
+		}
 
 		/* bit 2: drive individual 875 interrupts to the bus */
 		pci_read_config_byte(memc, 0x45, &tmp);
-		tmp |= 0x4;
-		pci_write_config_byte(memc, 0x45, tmp);
-
-		pci_read_config_byte(pdev, 0x84, &tmp);
-		sym_dev->host_id = tmp;
+		if ((tmp & 0x4) == 0) {
+			tmp |= 0x4;
+			pci_write_config_byte(memc, 0x45, tmp);
+		}
 
 		pci_dev_put(memc);
-
 		break;
 	}
+
+	pci_read_config_byte(pdev, 0x84, &tmp);
+	sym_dev->host_id = tmp;
 }
 
 /*
@@ -2215,9 +2071,6 @@
 	return 1;
 }
 
-MODULE_LICENSE("Dual BSD/GPL");
-MODULE_VERSION(SYM_VERSION);
-
 /*
  * Driver host template.
  */
@@ -2252,15 +2105,21 @@
 	memset(&nvram, 0, sizeof(nvram));
 
 	if (pci_enable_device(pdev))
-		return -ENODEV;
+		goto leave;
 
 	pci_set_master(pdev);
 
 	if (pci_request_regions(pdev, NAME53C8XX))
 		goto disable;
 
-	sym_dev.host_id = SYM_SETUP_HOST_ID;
-	if (sym53c8xx_pci_init(pdev, &sym_dev))
+	sym_init_device(pdev, &sym_dev);
+	if (sym_check_supported(&sym_dev))
+		goto free;
+
+	if (sym_check_raid(&sym_dev))
+		goto leave;	/* Don't disable the device */
+
+	if (sym_set_workarounds(&sym_dev))
 		goto free;
 
 	sym_config_pqs(pdev, &sym_dev);
@@ -2285,6 +2144,7 @@
 	pci_release_regions(pdev);
  disable:
 	pci_disable_device(pdev);
+ leave:
 	return -ENODEV;
 }
 
@@ -2304,35 +2164,61 @@
 	attach_count--;
 }
 
-static void sym2_get_offset(struct scsi_device *sdev)
+static void sym2_get_signalling(struct Scsi_Host *shost)
 {
-	struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
-	struct sym_tcb *tp = &np->target[sdev->id];
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	enum spi_signal_type type;
 
-	spi_offset(sdev) = tp->tinfo.curr.offset;
+	switch (np->scsi_mode) {
+	case SMODE_SE:
+		type =  SPI_SIGNAL_SE;
+		break;
+	case SMODE_LVD:
+		type = SPI_SIGNAL_LVD;
+		break;
+	case SMODE_HVD:
+		type = SPI_SIGNAL_HVD;
+		break;
+	default:
+		type = SPI_SIGNAL_UNKNOWN;
+		break;
+	}
+	spi_signalling(shost) = type;
 }
 
-static void sym2_set_offset(struct scsi_device *sdev, int offset)
+static void sym2_get_offset(struct scsi_target *starget)
 {
-	struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
-	struct sym_tcb *tp = &np->target[sdev->id];
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
+
+	spi_offset(starget) = tp->tinfo.curr.offset;
+}
+
+static void sym2_set_offset(struct scsi_target *starget, int offset)
+{
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
 
 	tp->tinfo.goal.offset = offset;
 }
 
 
-static void sym2_get_period(struct scsi_device *sdev)
+static void sym2_get_period(struct scsi_target *starget)
 {
-	struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
-	struct sym_tcb *tp = &np->target[sdev->id];
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
 
-	spi_period(sdev) = tp->tinfo.curr.period;
+	spi_period(starget) = tp->tinfo.curr.period;
 }
 
-static void sym2_set_period(struct scsi_device *sdev, int period)
+static void sym2_set_period(struct scsi_target *starget, int period)
 {
-	struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
-	struct sym_tcb *tp = &np->target[sdev->id];
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
 
 	/* have to have DT for these transfers */
 	if (period <= np->minsync)
@@ -2341,45 +2227,93 @@
 	tp->tinfo.goal.period = period;
 }
 
-static void sym2_get_width(struct scsi_device *sdev)
+static void sym2_get_width(struct scsi_target *starget)
 {
-	struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
-	struct sym_tcb *tp = &np->target[sdev->id];
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
 
-	spi_width(sdev) = tp->tinfo.curr.width ? 1 : 0;
+	spi_width(starget) = tp->tinfo.curr.width ? 1 : 0;
 }
 
-static void sym2_set_width(struct scsi_device *sdev, int width)
+static void sym2_set_width(struct scsi_target *starget, int width)
 {
-	struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
-	struct sym_tcb *tp = &np->target[sdev->id];
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
 
-	/* It is illegal to have DT set on narrow transfers */
+	/* It is illegal to have DT set on narrow transfers.  If DT is
+	 * clear, we must also clear IU and QAS.  */
 	if (width == 0)
-		tp->tinfo.goal.options &= ~PPR_OPT_DT;
+		tp->tinfo.goal.options &= ~PPR_OPT_MASK;
 
 	tp->tinfo.goal.width = width;
 }
 
-static void sym2_get_dt(struct scsi_device *sdev)
+static void sym2_get_dt(struct scsi_target *starget)
 {
-	struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
-	struct sym_tcb *tp = &np->target[sdev->id];
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
 
-	spi_dt(sdev) = (tp->tinfo.curr.options & PPR_OPT_DT) ? 1 : 0;
+	spi_dt(starget) = (tp->tinfo.curr.options & PPR_OPT_DT) ? 1 : 0;
 }
 
-static void sym2_set_dt(struct scsi_device *sdev, int dt)
+static void sym2_set_dt(struct scsi_target *starget, int dt)
 {
-	struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
-	struct sym_tcb *tp = &np->target[sdev->id];
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
 
+	/* We must clear QAS and IU if DT is clear */
 	if (dt)
 		tp->tinfo.goal.options |= PPR_OPT_DT;
 	else
-		tp->tinfo.goal.options &= ~PPR_OPT_DT;
+		tp->tinfo.goal.options &= ~PPR_OPT_MASK;
+}
+
+static void sym2_get_iu(struct scsi_target *starget)
+{
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
+
+	spi_iu(starget) = (tp->tinfo.curr.options & PPR_OPT_IU) ? 1 : 0;
+}
+
+static void sym2_set_iu(struct scsi_target *starget, int iu)
+{
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
+
+	if (iu)
+		tp->tinfo.goal.options |= PPR_OPT_IU | PPR_OPT_DT;
+	else
+		tp->tinfo.goal.options &= ~PPR_OPT_IU;
 }
-	
+
+static void sym2_get_qas(struct scsi_target *starget)
+{
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
+
+	spi_qas(starget) = (tp->tinfo.curr.options & PPR_OPT_QAS) ? 1 : 0;
+}
+
+static void sym2_set_qas(struct scsi_target *starget, int qas)
+{
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_hcb *np = ((struct host_data *)shost->hostdata)->ncb;
+	struct sym_tcb *tp = &np->target[starget->id];
+
+	if (qas)
+		tp->tinfo.goal.options |= PPR_OPT_QAS | PPR_OPT_DT;
+	else
+		tp->tinfo.goal.options &= ~PPR_OPT_QAS;
+}
+
 
 static struct spi_function_template sym2_transport_functions = {
 	.set_offset	= sym2_set_offset,
@@ -2394,6 +2328,13 @@
 	.get_dt		= sym2_get_dt,
 	.set_dt		= sym2_set_dt,
 	.show_dt	= 1,
+	.get_iu		= sym2_get_iu,
+	.set_iu		= sym2_set_iu,
+	.show_iu	= 1,
+	.get_qas	= sym2_get_qas,
+	.set_qas	= sym2_set_qas,
+	.show_qas	= 1,
+	.get_signalling	= sym2_get_signalling,
 };
 
 static struct pci_device_id sym2_id_table[] __devinitdata = {
@@ -2445,12 +2386,17 @@
 
 static int __init sym2_init(void)
 {
+	int error;
+
+	sym2_setup_params();
 	sym2_transport_template = spi_attach_transport(&sym2_transport_functions);
 	if (!sym2_transport_template)
 		return -ENODEV;
 
-	pci_register_driver(&sym2_driver);
-	return 0;
+	error = pci_module_init(&sym2_driver);
+	if (error)
+		spi_release_transport(sym2_transport_template);
+	return error;
 }
 
 static void __exit sym2_exit(void)
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h
--- a/drivers/scsi/sym53c8xx_2/sym_glue.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.h	2004-12-24 13:37:31 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef SYM_GLUE_H
@@ -89,7 +76,6 @@
 
 #define SYM_OPT_HANDLE_DIR_UNKNOWN
 #define SYM_OPT_HANDLE_DEVICE_QUEUEING
-#define SYM_OPT_NVRAM_PRE_READ
 #define SYM_OPT_LIMIT_COMMAND_REORDERING
 #define	SYM_OPT_ANNOUNCE_TRANSFER_RATE
 
@@ -107,10 +93,9 @@
 #define	printf(args...)		printk(args)
 
 /*
- *  Insert a delay in micro-seconds and milli-seconds.
+ *  Insert a delay in micro-seconds
  */
 #define sym_udelay(us)	udelay(us)
-#define sym_mdelay(ms)	mdelay(ms)
 
 /*
  *  A 'read barrier' flushes any data that have been prefetched 
@@ -395,9 +380,6 @@
 	u_long		io_port;	/* IO port address cookie	*/
 	u_short		io_ws;		/* IO window size		*/
 	int		irq;		/* IRQ number			*/
-
-	SYM_QUEHEAD	wait_cmdq;	/* Awaiting SCSI commands	*/
-	SYM_QUEHEAD	busy_cmdq;	/* Enqueued SCSI commands	*/
 
 	struct timer_list timer;	/* Timer handler link header	*/
 	u_long		lasttime;
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c	2004-12-24 13:36:16 -08:00
@@ -3,6 +3,7 @@
  * of PCI-SCSI IO processors.
  *
  * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
+ * Copyright (c) 2003-2004  Matthew Wilcox <matthew@wil.cx>
  *
  * This driver is derived from the Linux sym53c8xx driver.
  * Copyright (C) 1998-2000  Gerard Roudier
@@ -22,32 +23,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "sym_glue.h"
 #include "sym_nvram.h"
@@ -299,7 +287,6 @@
 	}
 out:
 	OUTB (nc_scntl1, 0);
-	/* MDELAY(100); */
 	return retv;
 }
 
@@ -1516,6 +1503,7 @@
 		if (st->period > np->maxsync_dt)
 			st->period = np->maxsync_dt;
 	} else {
+		st->options &= ~PPR_OPT_MASK;
 		if (st->offset > np->maxoffs)
 			st->offset = np->maxoffs;
 		if (st->period < np->minsync)
@@ -1523,7 +1511,7 @@
 		if (st->period > np->maxsync)
 			st->period = np->maxsync;
 	}
-}		
+}
 
 /*
  *  Prepare the next negotiation message if needed.
@@ -1588,7 +1576,7 @@
 		msgptr[msglen++] = 0;
 		msgptr[msglen++] = tp->tinfo.goal.offset;
 		msgptr[msglen++] = tp->tinfo.goal.width;
-		msgptr[msglen++] = tp->tinfo.goal.options & PPR_OPT_DT;
+		msgptr[msglen++] = tp->tinfo.goal.options & PPR_OPT_MASK;
 		break;
 	};
 
@@ -1955,7 +1943,7 @@
 	if (np->features & (FE_ULTRA2|FE_ULTRA3)) {
 		OUTONW (nc_sien, SBMC);
 		if (reason == 0) {
-			MDELAY(100);
+			mdelay(100);
 			INW (nc_sist);
 		}
 		np->scsi_mode = INB (nc_stest4) & SMODE;
@@ -2022,7 +2010,7 @@
 /*
  *  Switch trans mode for current job and it's target.
  */
-static void sym_settrans(hcb_p np, int target, u_char dt, u_char ofs,
+static void sym_settrans(hcb_p np, int target, u_char opts, u_char ofs,
 			 u_char per, u_char wide, u_char div, u_char fak)
 {
 	SYM_QUEHEAD *qp;
@@ -2073,7 +2061,7 @@
 	 */
 	if (np->features & FE_C10) {
 		uval = uval & ~(U3EN|AIPCKEN);
-		if (dt)	{
+		if (opts)	{
 			assert(np->features & FE_U3EN);
 			uval |= U3EN;
 		}
@@ -2176,17 +2164,17 @@
  *  Let everything be aware of the changes.
  */
 static void 
-sym_setpprot(hcb_p np, int target, u_char dt, u_char ofs,
+sym_setpprot(hcb_p np, int target, u_char opts, u_char ofs,
              u_char per, u_char wide, u_char div, u_char fak)
 {
 	tcb_p tp = &np->target[target];
 
-	sym_settrans(np, target, dt, ofs, per, wide, div, fak);
+	sym_settrans(np, target, opts, ofs, per, wide, div, fak);
 
 	tp->tinfo.goal.width	= tp->tinfo.curr.width  = wide;
 	tp->tinfo.goal.period	= tp->tinfo.curr.period = per;
 	tp->tinfo.goal.offset	= tp->tinfo.curr.offset = ofs;
-	tp->tinfo.goal.options	= tp->tinfo.curr.options = dt;
+	tp->tinfo.goal.options	= tp->tinfo.curr.options = opts;
 
 	sym_xpt_async_nego_ppr(np, target);
 }
@@ -2747,7 +2735,7 @@
 		if	(dsp == SCRIPTA_BA (np, send_ident)) {
 			if (cp->tag != NO_TAG && olen - rest <= 3) {
 				cp->host_status = HS_BUSY;
-				np->msgout[0] = M_IDENTIFY | cp->lun;
+				np->msgout[0] = IDENTIFY(0, cp->lun);
 				nxtdsp = SCRIPTB_BA (np, ident_break_atn);
 			}
 			else
@@ -3176,10 +3164,7 @@
 		 *  requesting sense data.
 		 */
 
-		/*
-		 *  identify message
-		 */
-		cp->scsi_smsg2[0] = M_IDENTIFY | cp->lun;
+		cp->scsi_smsg2[0] = IDENTIFY(0, cp->lun);
 		msglen = 1;
 
 		/*
@@ -3538,8 +3523,8 @@
 		 */
 		if (lun != -1) {
 			lcb_p lp = sym_lp(np, tp, lun);
-			lp->to_clear = 0; /* We donnot expect to fail here */
-			np->abrt_msg[0] = M_IDENTIFY | lun;
+			lp->to_clear = 0; /* We don't expect to fail here */
+			np->abrt_msg[0] = IDENTIFY(0, lun);
 			np->abrt_msg[1] = M_ABORT;
 			np->abrt_tbl.size = 2;
 			break;
@@ -3580,7 +3565,7 @@
 		 *  We have some task to abort.
 		 *  Set the IDENTIFY(lun)
 		 */
-		np->abrt_msg[0] = M_IDENTIFY | cp->lun;
+		np->abrt_msg[0] = IDENTIFY(0, cp->lun);
 
 		/*
 		 *  If we want to abort an untagged command, we 
@@ -3591,8 +3576,7 @@
 		if (cp->tag == NO_TAG) {
 			np->abrt_msg[1] = M_ABORT;
 			np->abrt_tbl.size = 2;
-		}
-		else {
+		} else {
 			np->abrt_msg[1] = cp->scsi_smsg[1];
 			np->abrt_msg[2] = cp->scsi_smsg[2];
 			np->abrt_msg[3] = M_ABORT_TAG;
@@ -4152,20 +4136,17 @@
 sym_ppr_nego_check(hcb_p np, int req, int target)
 {
 	tcb_p tp = &np->target[target];
-	u_char	chg, ofs, per, fak, dt, div, wide;
+	unsigned char fak, div;
+	int dt, chg = 0;
+
+	unsigned char per = np->msgin[3];
+	unsigned char ofs = np->msgin[5];
+	unsigned char wide = np->msgin[6];
+	unsigned char opts = np->msgin[7] & PPR_OPT_MASK;
 
 	if (DEBUG_FLAGS & DEBUG_NEGO) {
 		sym_print_nego_msg(np, target, "ppr msgin", np->msgin);
-	};
-
-	/*
-	 *  Get requested values.
-	 */
-	chg  = 0;
-	per  = np->msgin[3];
-	ofs  = np->msgin[5];
-	wide = np->msgin[6];
-	dt   = np->msgin[7] & PPR_OPT_DT;
+	}
 
 	/*
 	 *  Check values against our limits.
@@ -4175,29 +4156,30 @@
 		wide = np->maxwide;
 	}
 	if (!wide || !(np->features & FE_ULTRA3))
-		dt &= ~PPR_OPT_DT;
+		opts = 0;
 
 	if (!(np->features & FE_U3EN))	/* Broken U3EN bit not supported */
-		dt &= ~PPR_OPT_DT;
+		opts = 0;
 
-	if (dt != (np->msgin[7] & PPR_OPT_MASK)) chg = 1;
+	if (opts != (np->msgin[7] & PPR_OPT_MASK))
+		chg = 1;
+
+	dt = opts & PPR_OPT_DT;
 
 	if (ofs) {
-		if (dt) {
-			if (ofs > np->maxoffs_dt)
-				{chg = 1; ofs = np->maxoffs_dt;}
+		unsigned char maxoffs = dt ? np->maxoffs_dt : np->maxoffs;
+		if (ofs > maxoffs) {
+			chg = 1;
+			ofs = maxoffs;
 		}
-		else if (ofs > np->maxoffs)
-			{chg = 1; ofs = np->maxoffs;}
 	}
 
 	if (ofs) {
-		if (dt) {
-			if (per < np->minsync_dt)
-				{chg = 1; per = np->minsync_dt;}
+		unsigned char minsync = dt ? np->minsync_dt : np->minsync;
+		if (per < np->minsync_dt) {
+			chg = 1;
+			per = minsync;
 		}
-		else if (per < np->minsync)
-			{chg = 1; per = np->minsync;}
 	}
 
 	/*
@@ -4217,7 +4199,7 @@
 	/*
 	 *  Apply new values.
 	 */
-	sym_setpprot (np, target, dt, ofs, per, wide, div, fak);
+	sym_setpprot(np, target, opts, ofs, per, wide, div, fak);
 
 	/*
 	 *  It was an answer. We are done.
@@ -4235,7 +4217,7 @@
 	np->msgout[4] = 0;
 	np->msgout[5] = ofs;
 	np->msgout[6] = wide;
-	np->msgout[7] = dt;
+	np->msgout[7] = opts;
 
 	if (DEBUG_FLAGS & DEBUG_NEGO) {
 		sym_print_nego_msg(np, target, "ppr msgout", np->msgout);
@@ -4251,7 +4233,7 @@
 	 *  If it is a device response that should result in  
 	 *  ST, we may want to try a legacy negotiation later.
 	 */
-	if (!req && !dt) {
+	if (!req && !opts) {
 		tp->tinfo.goal.options = 0;
 		tp->tinfo.goal.width   = wide;
 		tp->tinfo.goal.period  = per;
@@ -5284,8 +5266,9 @@
 {
 	tcb_p	tp;
 	lcb_p	lp;
-	u_char	idmsg, *msgptr;
+	u_char	*msgptr;
 	u_int   msglen;
+	int can_disconnect;
 
 	/*
 	 *  Keep track of the IO in our CCB.
@@ -5293,25 +5276,21 @@
 	cp->cam_ccb = (cam_ccb_p) csio;
 
 	/*
-	 *  Retreive the target descriptor.
+	 *  Retrieve the target descriptor.
 	 */
 	tp = &np->target[cp->target];
 
 	/*
-	 *  Retreive the lun descriptor.
+	 *  Retrieve the lun descriptor.
 	 */
 	lp = sym_lp(np, tp, cp->lun);
 
-	/*
-	 *  Build the IDENTIFY message.
-	 */
-	idmsg = M_IDENTIFY | cp->lun;
-	if (cp->tag != NO_TAG || (lp && (lp->curr_flags & SYM_DISC_ENABLED)))
-		idmsg |= 0x40;
+	can_disconnect = (cp->tag != NO_TAG) ||
+		(lp && (lp->curr_flags & SYM_DISC_ENABLED));
 
 	msgptr = cp->scsi_smsg;
 	msglen = 0;
-	msgptr[msglen++] = idmsg;
+	msgptr[msglen++] = IDENTIFY(can_disconnect, cp->lun);
 
 	/*
 	 *  Build the tag message if present.
@@ -5518,7 +5497,6 @@
 		printf ("CCB=%lx STAT=%x/%x/%x DEV=%d/%d\n", (unsigned long)cp,
 			cp->host_status, cp->ssss_status, cp->host_flags,
 			cp->target, cp->lun);
-		MDELAY(100);
 	}
 
 	/*
@@ -5746,15 +5724,8 @@
 /*
  *  Soft-attach the controller.
  */
-#ifdef SYM_OPT_NVRAM_PRE_READ
 int sym_hcb_attach(hcb_p np, struct sym_fw *fw, struct sym_nvram *nvram)
-#else
-int sym_hcb_attach(hcb_p np, struct sym_fw *fw)
-#endif
 {
-#ifndef SYM_OPT_NVRAM_PRE_READ
-	struct sym_nvram nvram_buf, *nvram = &nvram_buf;
-#endif
 	int i;
 
 	/*
@@ -5779,13 +5750,6 @@
 	 *  if the chip is currently active.
 	 */
 	sym_chip_reset (np);
-
-	/*
-	 *  Try to read the user set-up.
-	 */
-#ifndef SYM_OPT_NVRAM_PRE_READ
-	(void) sym_read_nvram(np, nvram);
-#endif
 
 	/*
 	 *  Prepare controller and devices settings, according 
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h	2004-12-24 13:36:47 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef SYM_HIPD_H
@@ -1121,12 +1108,7 @@
 int sym_abort_ccb(hcb_p np, ccb_p cp, int timed_out);
 int sym_reset_scsi_target(hcb_p np, int target);
 void sym_hcb_free(hcb_p np);
-
-#ifdef SYM_OPT_NVRAM_PRE_READ
 int sym_hcb_attach(hcb_p np, struct sym_fw *fw, struct sym_nvram *nvram);
-#else
-int sym_hcb_attach(hcb_p np, struct sym_fw *fw);
-#endif
 
 /*
  *  Optionnaly, the driver may handle IO timeouts.
@@ -1350,7 +1332,6 @@
 #define PRINT_ADDR	sym_print_addr
 #define PRINT_TARGET	sym_print_target
 #define PRINT_LUN	sym_print_lun
-#define MDELAY		sym_mdelay
 #define UDELAY		sym_udelay
 
 #endif /* SYM_HIPD_H */
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_malloc.c b/drivers/scsi/sym53c8xx_2/sym_malloc.c
--- a/drivers/scsi/sym53c8xx_2/sym_malloc.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_malloc.c	2004-12-24 13:37:18 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifdef __FreeBSD__
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_misc.c b/drivers/scsi/sym53c8xx_2/sym_misc.c
--- a/drivers/scsi/sym53c8xx_2/sym_misc.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_misc.c	2004-12-24 13:37:19 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifdef __FreeBSD__
@@ -203,10 +190,12 @@
 			mb10 = (f10 + period/2) / period;
 		}
 		printf_info (
-		    "%s:%d: %s %sSCSI %d.%d MB/s %s (%d.%d ns, offset %d)\n",
+		    "%s:%d: %s %sSCSI %d.%d MB/s %s%s%s (%d.%d ns, offset %d)\n",
 		    sym_name(np), target, scsi, __tcurr.width? "WIDE " : "",
 		    mb10/10, mb10%10,
 		    (__tcurr.options & PPR_OPT_DT) ? "DT" : "ST",
+		    (__tcurr.options & PPR_OPT_IU) ? " IU" : "",
+		    (__tcurr.options & PPR_OPT_QAS) ? " QAS" : "",
 		    period/10, period%10, __tcurr.offset);
 	}
 	else
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_misc.h b/drivers/scsi/sym53c8xx_2/sym_misc.h
--- a/drivers/scsi/sym53c8xx_2/sym_misc.h	2004-12-24 13:37:32 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_misc.h	2004-12-24 13:37:32 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef SYM_MISC_H
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_nvram.c b/drivers/scsi/sym53c8xx_2/sym_nvram.c
--- a/drivers/scsi/sym53c8xx_2/sym_nvram.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_nvram.c	2004-12-24 13:37:00 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sym_glue.h"
diff -Nru a/drivers/scsi/sym53c8xx_2/sym_nvram.h b/drivers/scsi/sym53c8xx_2/sym_nvram.h
--- a/drivers/scsi/sym53c8xx_2/sym_nvram.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/sym53c8xx_2/sym_nvram.h	2004-12-24 13:37:19 -08:00
@@ -22,32 +22,19 @@
  *
  *-----------------------------------------------------------------------------
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * 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.
  *
- * Where this Software is combined with software released under the terms of 
- * the GNU Public License ("GPL") and the terms of the GPL would require the 
- * combined work to also be released under the terms of the GPL, the terms
- * and conditions of this License will apply in addition to those of the
- * GPL with the exception of any terms or conditions of this License that
- * conflict with, or are expressly prohibited by, the GPL.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef SYM_NVRAM_H
diff -Nru a/drivers/scsi/sym53c8xx_comm.h b/drivers/scsi/sym53c8xx_comm.h
--- a/drivers/scsi/sym53c8xx_comm.h	2004-12-24 13:36:56 -08:00
+++ b/drivers/scsi/sym53c8xx_comm.h	2004-12-24 13:36:56 -08:00
@@ -54,57 +54,6 @@
 *******************************************************************************
 */
 
-/*
-**	This file contains definitions and code that the 
-**	sym53c8xx and ncr53c8xx drivers should share.
-**	The sharing will be achieved in a further version  
-**	of the driver bundle. For now, only the ncr53c8xx 
-**	driver includes this file.
-*/
-
-/*==========================================================
-**
-**	Hmmm... What complex some PCI-HOST bridges actually 
-**	are, despite the fact that the PCI specifications 
-**	are looking so smart and simple! ;-)
-**
-**==========================================================
-*/
-
-/*==========================================================
-**
-**	Miscallaneous defines.
-**
-**==========================================================
-*/
-
-#define u_char		unsigned char
-#define u_long		unsigned long
-
-#ifndef bzero
-#define bzero(d, n)	memset((d), 0, (n))
-#endif
- 
-/*==========================================================
-**
-**	assert ()
-**
-**==========================================================
-**
-**	modified copy from 386bsd:/usr/include/sys/assert.h
-**
-**----------------------------------------------------------
-*/
-
-#define	assert(expression) { \
-	if (!(expression)) { \
-		(void)panic( \
-			"assertion \"%s\" failed: file \"%s\", line %d\n", \
-			#expression, \
-			__FILE__, __LINE__); \
-	} \
-}
-
 /*==========================================================
 **
 **	Debugging tags
@@ -137,170 +86,22 @@
 	#define DEBUG_FLAGS	SCSI_NCR_DEBUG_FLAGS
 #endif
 
-/*==========================================================
-**
-**	A la VMS/CAM-3 queue management.
-**	Implemented from linux list management.
-**
-**==========================================================
-*/
-
-typedef struct xpt_quehead {
-	struct xpt_quehead *flink;	/* Forward  pointer */
-	struct xpt_quehead *blink;	/* Backward pointer */
-} XPT_QUEHEAD;
-
-#define xpt_que_init(ptr) do { \
-	(ptr)->flink = (ptr); (ptr)->blink = (ptr); \
-} while (0)
-
-static inline void __xpt_que_add(struct xpt_quehead * new,
-	struct xpt_quehead * blink,
-	struct xpt_quehead * flink)
-{
-	flink->blink	= new;
-	new->flink	= flink;
-	new->blink	= blink;
-	blink->flink	= new;
-}
-
-static inline void __xpt_que_del(struct xpt_quehead * blink,
-	struct xpt_quehead * flink)
+static inline struct list_head *ncr_list_pop(struct list_head *head)
 {
-	flink->blink = blink;
-	blink->flink = flink;
-}
-
-static inline int xpt_que_empty(struct xpt_quehead *head)
-{
-	return head->flink == head;
-}
+	if (!list_empty(head)) {
+		struct list_head *elem = head->next;
 
-static inline void xpt_que_splice(struct xpt_quehead *list,
-	struct xpt_quehead *head)
-{
-	struct xpt_quehead *first = list->flink;
-
-	if (first != list) {
-		struct xpt_quehead *last = list->blink;
-		struct xpt_quehead *at   = head->flink;
-
-		first->blink = head;
-		head->flink  = first;
-
-		last->flink = at;
-		at->blink   = last;
+		list_del(elem);
+		return elem;
 	}
-}
-
-#define xpt_que_entry(ptr, type, member) \
-	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
-
-
-#define xpt_insque(new, pos)		__xpt_que_add(new, pos, (pos)->flink)
 
-#define xpt_remque(el)			__xpt_que_del((el)->blink, (el)->flink)
-
-#define xpt_insque_head(new, head)	__xpt_que_add(new, head, (head)->flink)
-
-static inline struct xpt_quehead *xpt_remque_head(struct xpt_quehead *head)
-{
-	struct xpt_quehead *elem = head->flink;
-
-	if (elem != head)
-		__xpt_que_del(head, elem->flink);
-	else
-		elem = NULL;
-	return elem;
-}
-
-#define xpt_insque_tail(new, head)	__xpt_que_add(new, (head)->blink, head)
-
-static inline struct xpt_quehead *xpt_remque_tail(struct xpt_quehead *head)
-{
-	struct xpt_quehead *elem = head->blink;
-
-	if (elem != head)
-		__xpt_que_del(elem->blink, head);
-	else
-		elem = 0;
-	return elem;
+	return NULL;
 }
 
-
-/*==========================================================
-**
-**	SMP threading.
-**
-**	Assuming that SMP systems are generally high end 
-**	systems and may use several SCSI adapters, we are 
-**	using one lock per controller instead of some global 
-**	one. For the moment (linux-2.1.95), driver's entry 
-**	points are called with the 'io_request_lock' lock 
-**	held, so:
-**	- We are uselessly loosing a couple of micro-seconds 
-**	  to lock the controller data structure.
-**	- But the driver is not broken by design for SMP and 
-**	  so can be more resistant to bugs or bad changes in 
-**	  the IO sub-system code.
-**	- A small advantage could be that the interrupt code 
-**	  is grained as wished (e.g.: by controller).
-**
-**==========================================================
-*/
-
-spinlock_t DRIVER_SMP_LOCK = SPIN_LOCK_UNLOCKED;
-#define	NCR_LOCK_DRIVER(flags)     spin_lock_irqsave(&DRIVER_SMP_LOCK, flags)
-#define	NCR_UNLOCK_DRIVER(flags)   \
-		spin_unlock_irqrestore(&DRIVER_SMP_LOCK, flags)
-
-#define NCR_INIT_LOCK_NCB(np)      spin_lock_init(&np->smp_lock)
-#define	NCR_LOCK_NCB(np, flags)    spin_lock_irqsave(&np->smp_lock, flags)
-#define	NCR_UNLOCK_NCB(np, flags)  spin_unlock_irqrestore(&np->smp_lock, flags)
-
-#define	NCR_LOCK_SCSI_DONE(host, flags) \
-		spin_lock_irqsave((host)->host_lock, flags)
-#define	NCR_UNLOCK_SCSI_DONE(host, flags) \
-		spin_unlock_irqrestore(((host)->host_lock), flags)
-
-/*==========================================================
-**
-**	Memory mapped IO
-**
-**	Since linux-2.1, we must use ioremap() to map the io 
-**	memory space and iounmap() to unmap it. This allows 
-**	portability. Linux 1.3.X and 2.0.X allow to remap 
-**	physical pages addresses greater than the highest 
-**	physical memory address to kernel virtual pages with 
-**	vremap() / vfree(). That was not portable but worked 
-**	with i386 architecture.
-**
-**==========================================================
-*/
-
 #ifdef __sparc__
 #include <asm/irq.h>
 #endif
 
-#define memcpy_to_pci(a, b, c)	memcpy_toio((a), (b), (c))
-
-/*==========================================================
-**
-**	Insert a delay in micro-seconds and milli-seconds.
-**
-**	Under Linux, udelay() is restricted to delay < 
-**	1 milli-second. In fact, it generally works for up 
-**	to 1 second delay. Since 2.1.105, the mdelay() function 
-**	is provided for delays in milli-seconds.
-**	Under 2.0 kernels, udelay() is an inline function 
-**	that is very inaccurate on Pentium processors.
-**
-**==========================================================
-*/
-
-#define UDELAY udelay
-#define MDELAY mdelay
-
 /*==========================================================
 **
 **	Simple power of two buddy-like allocator.
@@ -319,8 +120,6 @@
 **==========================================================
 */
 
-#define __GetFreePages(flags, order) __get_free_pages(flags, order)
-
 #define MEMO_SHIFT	4	/* 16 bytes minimum memory chunk */
 #if PAGE_SIZE >= 8192
 #define MEMO_PAGE_ORDER	0	/* 1 PAGE  maximum */
@@ -356,10 +155,6 @@
 	m_bush_t bush;
 	m_addr_t (*getp)(struct m_pool *);
 	void (*freep)(struct m_pool *, m_addr_t);
-#define M_GETP()		mp->getp(mp)
-#define M_FREEP(p)		mp->freep(mp, p)
-#define GetPages()		__GetFreePages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER)
-#define FreePages(p)		free_pages(p, MEMO_PAGE_ORDER)
 	int nump;
 	m_vtob_s *(vtob[VTOB_HASH_SIZE]);
 	struct m_pool *next;
@@ -385,7 +180,7 @@
 	j = i;
 	while (!h[j].next) {
 		if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
-			h[j].next = (m_link_s *) M_GETP();
+			h[j].next = (m_link_s *)mp->getp(mp);
 			if (h[j].next)
 				h[j].next->next = NULL;
 			break;
@@ -434,7 +229,7 @@
 	while (1) {
 #ifdef MEMO_FREE_UNUSED
 		if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
-			M_FREEP(a);
+			mp->freep(mp, a);
 			break;
 		}
 #endif
@@ -455,6 +250,8 @@
 	}
 }
 
+static spinlock_t ncr53c8xx_lock = SPIN_LOCK_UNLOCKED;
+
 static void *__m_calloc2(m_pool_s *mp, int size, char *name, int uflags)
 {
 	void *p;
@@ -465,7 +262,7 @@
 		printk ("new %-10s[%4d] @%p.\n", name, size, p);
 
 	if (p)
-		bzero(p, size);
+		memset(p, 0, size);
 	else if (uflags & MEMO_WARN)
 		printk (NAME53C8XX ": failed to allocate %s[%d]\n", name, size);
 
@@ -491,7 +288,7 @@
 
 static m_addr_t ___mp0_getp(m_pool_s *mp)
 {
-	m_addr_t m = GetPages();
+	m_addr_t m = __get_free_pages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER);
 	if (m)
 		++mp->nump;
 	return m;
@@ -499,7 +296,7 @@
 
 static void ___mp0_freep(m_pool_s *mp, m_addr_t m)
 {
-	FreePages(m);
+	free_pages(m, MEMO_PAGE_ORDER);
 	--mp->nump;
 }
 
@@ -569,7 +366,7 @@
 	m_pool_s *mp;
 	mp = __m_calloc(&mp0, sizeof(*mp), "MPOOL");
 	if (mp) {
-		bzero(mp, sizeof(*mp));
+		memset(mp, 0, sizeof(*mp));
 		mp->bush = bush;
 		mp->getp = ___dma_getp;
 		mp->freep = ___dma_freep;
@@ -597,7 +394,7 @@
 	struct m_pool *mp;
 	void *m = NULL;
 
-	NCR_LOCK_DRIVER(flags);
+	spin_lock_irqsave(&ncr53c8xx_lock, flags);
 	mp = ___get_dma_pool(bush);
 	if (!mp)
 		mp = ___cre_dma_pool(bush);
@@ -605,7 +402,7 @@
 		m = __m_calloc(mp, size, name);
 	if (mp && !mp->nump)
 		___del_dma_pool(mp);
-	NCR_UNLOCK_DRIVER(flags);
+	spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
 
 	return m;
 }
@@ -615,13 +412,13 @@
 	u_long flags;
 	struct m_pool *mp;
 
-	NCR_LOCK_DRIVER(flags);
+	spin_lock_irqsave(&ncr53c8xx_lock, flags);
 	mp = ___get_dma_pool(bush);
 	if (mp)
 		__m_free(mp, m, size, name);
 	if (mp && !mp->nump)
 		___del_dma_pool(mp);
-	NCR_UNLOCK_DRIVER(flags);
+	spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
 }
 
 static m_addr_t __vtobus(m_bush_t bush, void *m)
@@ -632,14 +429,14 @@
 	m_vtob_s *vp = NULL;
 	m_addr_t a = ((m_addr_t) m) & ~MEMO_CLUSTER_MASK;
 
-	NCR_LOCK_DRIVER(flags);
+	spin_lock_irqsave(&ncr53c8xx_lock, flags);
 	mp = ___get_dma_pool(bush);
 	if (mp) {
 		vp = mp->vtob[hc];
 		while (vp && (m_addr_t) vp->vaddr != a)
 			vp = vp->next;
 	}
-	NCR_UNLOCK_DRIVER(flags);
+	spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
 	return vp ? vp->baddr + (((m_addr_t) m) - a) : 0;
 }
 
@@ -658,100 +455,59 @@
 #define __data_mapped	SCp.phase
 #define __data_mapping	SCp.have_data_in
 
-static void __unmap_scsi_data(struct device *dev, Scsi_Cmnd *cmd)
+static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd)
 {
-	enum dma_data_direction dma_dir = 
-		(enum dma_data_direction)scsi_to_pci_dma_dir(cmd->sc_data_direction);
-
 	switch(cmd->__data_mapped) {
 	case 2:
-		dma_unmap_sg(dev, cmd->buffer, cmd->use_sg, dma_dir);
+		dma_unmap_sg(dev, cmd->buffer, cmd->use_sg,
+				cmd->sc_data_direction);
 		break;
 	case 1:
 		dma_unmap_single(dev, cmd->__data_mapping,
-				 cmd->request_bufflen, dma_dir);
+				 cmd->request_bufflen,
+				 cmd->sc_data_direction);
 		break;
 	}
 	cmd->__data_mapped = 0;
 }
 
-static u_long __map_scsi_single_data(struct device *dev, Scsi_Cmnd *cmd)
+static u_long __map_scsi_single_data(struct device *dev, struct scsi_cmnd *cmd)
 {
 	dma_addr_t mapping;
-	enum dma_data_direction dma_dir = 
-		(enum dma_data_direction)scsi_to_pci_dma_dir(cmd->sc_data_direction);
-
 
 	if (cmd->request_bufflen == 0)
 		return 0;
 
 	mapping = dma_map_single(dev, cmd->request_buffer,
-				 cmd->request_bufflen, dma_dir);
+				 cmd->request_bufflen,
+				 cmd->sc_data_direction);
 	cmd->__data_mapped = 1;
 	cmd->__data_mapping = mapping;
 
 	return mapping;
 }
 
-static int __map_scsi_sg_data(struct device *dev, Scsi_Cmnd *cmd)
+static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
 {
 	int use_sg;
-	enum dma_data_direction dma_dir = 
-		(enum dma_data_direction)scsi_to_pci_dma_dir(cmd->sc_data_direction);
 
 	if (cmd->use_sg == 0)
 		return 0;
 
-	use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg, dma_dir);
+	use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg,
+			cmd->sc_data_direction);
 	cmd->__data_mapped = 2;
 	cmd->__data_mapping = use_sg;
 
 	return use_sg;
 }
 
-static void __sync_scsi_data_for_cpu(struct device *dev, Scsi_Cmnd *cmd)
-{
-	enum dma_data_direction dma_dir = 
-		(enum dma_data_direction)scsi_to_pci_dma_dir(cmd->sc_data_direction);
-
-	switch(cmd->__data_mapped) {
-	case 2:
-		dma_sync_sg_for_cpu(dev, cmd->buffer, cmd->use_sg, dma_dir);
-		break;
-	case 1:
-		dma_sync_single_for_cpu(dev, cmd->__data_mapping,
-					cmd->request_bufflen, dma_dir);
-		break;
-	}
-}
-
-static void __sync_scsi_data_for_device(struct device *dev, Scsi_Cmnd *cmd)
-{
-	enum dma_data_direction dma_dir =
-		(enum dma_data_direction)scsi_to_pci_dma_dir(cmd->sc_data_direction);
-
-	switch(cmd->__data_mapped) {
-	case 2:
-		dma_sync_sg_for_device(dev, cmd->buffer, cmd->use_sg, dma_dir);
-		break;
-	case 1:
-		dma_sync_single_for_device(dev, cmd->__data_mapping,
-					   cmd->request_bufflen, dma_dir);
-		break;
-	}
-}
-
-#define scsi_sg_dma_address(sc)		sg_dma_address(sc)
-#define scsi_sg_dma_len(sc)		sg_dma_len(sc)
-
 #define unmap_scsi_data(np, cmd)	__unmap_scsi_data(np->dev, cmd)
 #define map_scsi_single_data(np, cmd)	__map_scsi_single_data(np->dev, cmd)
 #define map_scsi_sg_data(np, cmd)	__map_scsi_sg_data(np->dev, cmd)
 #define sync_scsi_data_for_cpu(np, cmd)	__sync_scsi_data_for_cpu(np->dev, cmd)
 #define sync_scsi_data_for_device(np, cmd) __sync_scsi_data_for_device(np->dev, cmd)
 
-#define scsi_data_direction(cmd)	(cmd->sc_data_direction)
-
 /*==========================================================
 **
 **	Driver setup.
@@ -773,58 +529,6 @@
 #define initverbose (driver_setup.verbose)
 #define bootverbose (np->verbose)
 
-
-/*===================================================================
-**
-**	Utility routines that protperly return data through /proc FS.
-**
-**===================================================================
-*/
-#ifdef SCSI_NCR_USER_INFO_SUPPORT
-
-struct info_str
-{
-	char *buffer;
-	int length;
-	int offset;
-	int pos;
-};
-
-static void copy_mem_info(struct info_str *info, char *data, int len)
-{
-	if (info->pos + len > info->length)
-		len = info->length - info->pos;
-
-	if (info->pos + len < info->offset) {
-		info->pos += len;
-		return;
-	}
-	if (info->pos < info->offset) {
-		data += (info->offset - info->pos);
-		len  -= (info->offset - info->pos);
-	}
-
-	if (len > 0) {
-		memcpy(info->buffer + info->pos, data, len);
-		info->pos += len;
-	}
-}
-
-static int copy_info(struct info_str *info, char *fmt, ...)
-{
-	va_list args;
-	char buf[81];
-	int len;
-
-	va_start(args, fmt);
-	len = vsprintf(buf, fmt, args);
-	va_end(args);
-
-	copy_mem_info(info, buf, len);
-	return len;
-}
-
-#endif
 
 /*===================================================================
 **
diff -Nru a/drivers/scsi/sym53c8xx_defs.h b/drivers/scsi/sym53c8xx_defs.h
--- a/drivers/scsi/sym53c8xx_defs.h	2004-12-24 13:37:44 -08:00
+++ b/drivers/scsi/sym53c8xx_defs.h	2004-12-24 13:37:44 -08:00
@@ -66,19 +66,12 @@
 
 #include <linux/config.h>
 
-/* These options are not tunable from 'make config' */
-#define	SCSI_NCR_PROC_INFO_SUPPORT
-
 /*
 **	If you want a driver as small as possible, donnot define the 
 **	following options.
 */
 #define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
 #define SCSI_NCR_DEBUG_INFO_SUPPORT
-#ifdef	SCSI_NCR_PROC_INFO_SUPPORT
-#	define	SCSI_NCR_USER_COMMAND_SUPPORT
-#	define	SCSI_NCR_USER_INFO_SUPPORT
-#endif
 
 /*
 **	To disable integrity checking, do not define the 
@@ -422,42 +415,42 @@
  *  MEMORY mapped IO input / output
  */
 
-#define INB_OFF(o)		readb_raw((char *)np->reg + ncr_offb(o))
-#define OUTB_OFF(o, val)	writeb_raw((val), (char *)np->reg + ncr_offb(o))
+#define INB_OFF(o)		readb_raw((char __iomem *)np->reg + ncr_offb(o))
+#define OUTB_OFF(o, val)	writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o))
 
 #if	defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
 
-#define INW_OFF(o)		readw_l2b((char *)np->reg + ncr_offw(o))
-#define INL_OFF(o)		readl_l2b((char *)np->reg + (o))
+#define INW_OFF(o)		readw_l2b((char __iomem *)np->reg + ncr_offw(o))
+#define INL_OFF(o)		readl_l2b((char __iomem *)np->reg + (o))
 
-#define OUTW_OFF(o, val)	writew_b2l((val), (char *)np->reg + ncr_offw(o))
-#define OUTL_OFF(o, val)	writel_b2l((val), (char *)np->reg + (o))
+#define OUTW_OFF(o, val)	writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o))
+#define OUTL_OFF(o, val)	writel_b2l((val), (char __iomem *)np->reg + (o))
 
 #elif	defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
 
-#define INW_OFF(o)		readw_b2l((char *)np->reg + ncr_offw(o))
-#define INL_OFF(o)		readl_b2l((char *)np->reg + (o))
+#define INW_OFF(o)		readw_b2l((char __iomem *)np->reg + ncr_offw(o))
+#define INL_OFF(o)		readl_b2l((char __iomem *)np->reg + (o))
 
-#define OUTW_OFF(o, val)	writew_l2b((val), (char *)np->reg + ncr_offw(o))
-#define OUTL_OFF(o, val)	writel_l2b((val), (char *)np->reg + (o))
+#define OUTW_OFF(o, val)	writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o))
+#define OUTL_OFF(o, val)	writel_l2b((val), (char __iomem *)np->reg + (o))
 
 #else
 
 #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
 /* Only 8 or 32 bit transfers allowed */
-#define INW_OFF(o)		(readb((char *)np->reg + ncr_offw(o)) << 8 | readb((char *)np->reg + ncr_offw(o) + 1))
+#define INW_OFF(o)		(readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1))
 #else
-#define INW_OFF(o)		readw_raw((char *)np->reg + ncr_offw(o))
+#define INW_OFF(o)		readw_raw((char __iomem *)np->reg + ncr_offw(o))
 #endif
-#define INL_OFF(o)		readl_raw((char *)np->reg + (o))
+#define INL_OFF(o)		readl_raw((char __iomem *)np->reg + (o))
 
 #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
 /* Only 8 or 32 bit transfers allowed */
-#define OUTW_OFF(o, val)	do { writeb((char)((val) >> 8), (char *)np->reg + ncr_offw(o)); writeb((char)(val), (char *)np->reg + ncr_offw(o) + 1); } while (0)
+#define OUTW_OFF(o, val)	do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0)
 #else
-#define OUTW_OFF(o, val)	writew_raw((val), (char *)np->reg + ncr_offw(o))
+#define OUTW_OFF(o, val)	writew_raw((val), (char __iomem *)np->reg + ncr_offw(o))
 #endif
-#define OUTL_OFF(o, val)	writel_raw((val), (char *)np->reg + (o))
+#define OUTL_OFF(o, val)	writel_raw((val), (char __iomem *)np->reg + (o))
 
 #endif
 
diff -Nru a/drivers/scsi/t128.c b/drivers/scsi/t128.c
--- a/drivers/scsi/t128.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/t128.c	2004-12-24 13:37:19 -08:00
@@ -199,6 +199,7 @@
     static int current_override = 0, current_base = 0;
     struct Scsi_Host *instance;
     unsigned long base;
+    void __iomem *p;
     int sig, count;
 
     tpnt->proc_name = "t128";
@@ -206,26 +207,34 @@
 
     for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
 	base = 0;
+	p = NULL;
 
-	if (overrides[current_override].address)
+	if (overrides[current_override].address) {
 	    base = overrides[current_override].address;
-	else 
+	    p = ioremap(bases[current_base].address, 0x2000);
+	    if (!p)
+		base = 0;
+	} else 
 	    for (; !base && (current_base < NO_BASES); ++current_base) {
 #if (TDEBUG & TDEBUG_INIT)
     printk("scsi-t128 : probing address %08x\n", bases[current_base].address);
 #endif
+		if (bases[current_base].noauto)
+			continue;
+		p = ioremap(bases[current_base].address, 0x2000);
+		if (!p)
+			continue;
 		for (sig = 0; sig < NO_SIGNATURES; ++sig) 
-		    if (!bases[current_base].noauto && 
-			isa_check_signature(bases[current_base].address +
-					signatures[sig].offset,
+		    if (check_signature(p + signatures[sig].offset,
 					signatures[sig].string,
 					strlen(signatures[sig].string))) {
 			base = bases[current_base].address;
 #if (TDEBUG & TDEBUG_INIT)
 			printk("scsi-t128 : detected board.\n");
 #endif
-			break;
+			goto found;
 		    }
+		iounmap(p);
 	    }
 
 #if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
@@ -235,11 +244,13 @@
 	if (!base)
 	    break;
 
+found:
 	instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
 	if(instance == NULL)
 		break;
 		
 	instance->base = base;
+	((struct NCR5380_hostdata *)instance->hostdata)->base = p;
 
 	NCR5380_init(instance, 0);
 
@@ -282,12 +293,15 @@
 
 static int t128_release(struct Scsi_Host *shost)
 {
+	NCR5380_local_declare();
+	NCR5380_setup(shost);
 	if (shost->irq)
 		free_irq(shost->irq, NULL);
 	NCR5380_exit(shost);
 	if (shost->io_port && shost->n_io_port)
 		release_region(shost->io_port, shost->n_io_port);
 	scsi_unregister(shost);
+	iounmap(base);
 	return 0;
 }
 
@@ -335,28 +349,30 @@
 
 static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
     int len) {
-    unsigned long reg = instance->base + T_DATA_REG_OFFSET;
+    NCR5380_local_declare();
+    void __iomem *reg;
     unsigned char *d = dst;
     register int i = len;
 
+    NCR5380_setup(instance);
+    reg = base + T_DATA_REG_OFFSET;
 
 #if 0
     for (; i; --i) {
-	while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
+	while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
 #else
-    while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
+    while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
     for (; i; --i) {
 #endif
-	*d++ = isa_readb(reg);
+	*d++ = readb(reg);
     }
 
-    if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
+    if (readb(base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
 	unsigned char tmp;
-	unsigned long foo;
-	foo = instance->base + T_CONTROL_REG_OFFSET;
-	tmp = isa_readb(foo);
-	isa_writeb(tmp | T_CR_CT, foo);
-	isa_writeb(tmp, foo);
+	void __iomem *foo = base + T_CONTROL_REG_OFFSET;
+	tmp = readb(foo);
+	writeb(tmp | T_CR_CT, foo);
+	writeb(tmp, foo);
 	printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
 	    instance->host_no);
 	return -1;
@@ -379,27 +395,30 @@
 
 static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
     int len) {
-    unsigned long reg = instance->base + T_DATA_REG_OFFSET;
+    NCR5380_local_declare();
+    void __iomem *reg;
     unsigned char *s = src;
     register int i = len;
 
+    NCR5380_setup(instance);
+    reg = base + T_DATA_REG_OFFSET;
+
 #if 0
     for (; i; --i) {
-	while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
+	while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
 #else
-    while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
+    while (!(readb(base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
     for (; i; --i) {
 #endif
-	isa_writeb(*s++, reg);
+	writeb(*s++, reg);
     }
 
-    if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
+    if (readb(base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
 	unsigned char tmp;
-	unsigned long foo;
-	foo = instance->base + T_CONTROL_REG_OFFSET;
-	tmp = isa_readb(foo);
-	isa_writeb(tmp | T_CR_CT, foo);
-	isa_writeb(tmp, foo);
+	void __iomem *foo = base + T_CONTROL_REG_OFFSET;
+	tmp = readb(foo);
+	writeb(tmp | T_CR_CT, foo);
+	writeb(tmp, foo);
 	printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
 	    instance->host_no);
 	return -1;
diff -Nru a/drivers/scsi/t128.h b/drivers/scsi/t128.h
--- a/drivers/scsi/t128.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/scsi/t128.h	2004-12-24 13:36:31 -08:00
@@ -111,28 +111,28 @@
 #ifndef HOSTS_C
 
 #define NCR5380_implementation_fields \
-    unsigned long base
+    void __iomem *base
 
 #define NCR5380_local_declare() \
-    unsigned long base
+    void __iomem *base
 
 #define NCR5380_setup(instance) \
-    base = (instance)->base
+    base = ((struct NCR5380_hostdata *)(instance->hostdata))->base
 
 #define T128_address(reg) (base + T_5380_OFFSET + ((reg) * 0x20))
 
 #if !(TDEBUG & TDEBUG_TRANSFER) 
-#define NCR5380_read(reg) isa_readb(T128_address(reg))
-#define NCR5380_write(reg, value) isa_writeb((value),(T128_address(reg)))
+#define NCR5380_read(reg) readb(T128_address(reg))
+#define NCR5380_write(reg, value) writeb((value),(T128_address(reg)))
 #else
 #define NCR5380_read(reg)						\
     (((unsigned char) printk("scsi%d : read register %d at address %08x\n"\
-    , instance->hostno, (reg), T128_address(reg))), isa_readb(T128_address(reg)))
+    , instance->hostno, (reg), T128_address(reg))), readb(T128_address(reg)))
 
 #define NCR5380_write(reg, value) {					\
     printk("scsi%d : write %02x to register %d at address %08x\n", 	\
 	    instance->hostno, (value), (reg), T128_address(reg));	\
-    isa_writeb((value), (T128_address(reg)));				\
+    writeb((value), (T128_address(reg)));				\
 }
 #endif
 
diff -Nru a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
--- a/drivers/scsi/tmscsim.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/scsi/tmscsim.c	2004-12-24 13:37:43 -08:00
@@ -179,9 +179,6 @@
  *				suggested by CH.			*
  ***********************************************************************/
 
-/* Uncomment SA_INTERRUPT, if the driver refuses to share its IRQ with other devices */
-#define DC390_IRQ SA_SHIRQ /* | SA_INTERRUPT */
-
 /* DEBUG options */
 //#define DC390_DEBUG0
 //#define DC390_DEBUG1
@@ -245,6 +242,7 @@
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsicam.h>
+#include <scsi/scsi_tcq.h>
 
 
 #define DC390_BANNER "Tekram DC390/AM53C974"
@@ -252,21 +250,9 @@
 
 #define PCI_DEVICE_ID_AMD53C974 	PCI_DEVICE_ID_AMD_SCSI
 
-
- static struct pci_device_id tmscsim_pci_tbl[] = {
-	{
-		.vendor		= PCI_VENDOR_ID_AMD,
-		.device		= PCI_DEVICE_ID_AMD53C974,
-		.subvendor	= PCI_ANY_ID,
-		.subdevice	= PCI_ANY_ID,
-	},
-	{ }		/* Terminating entry */
-};
-MODULE_DEVICE_TABLE(pci, tmscsim_pci_tbl);
-
 #include "tmscsim.h"
 
-static u8 dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB );
+
 static void dc390_DataOut_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus);
 static void dc390_DataIn_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus);
 static void dc390_Command_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus);
@@ -286,25 +272,18 @@
 static void dc390_Disconnect( struct dc390_acb* pACB );
 static void dc390_Reselect( struct dc390_acb* pACB );
 static void dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB );
-static void dc390_DoingSRB_Done( struct dc390_acb* pACB, struct scsi_cmnd * cmd);
 static void dc390_ScsiRstDetect( struct dc390_acb* pACB );
-static void dc390_ResetSCSIBus( struct dc390_acb* pACB );
 static void dc390_EnableMsgOut_Abort(struct dc390_acb*, struct dc390_srb*);
-static irqreturn_t do_DC390_Interrupt( int, void *, struct pt_regs *);
+static void dc390_dumpinfo(struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB);
+static void dc390_ResetDevParam(struct dc390_acb* pACB);
 
-static int    dc390_initAdapter(struct Scsi_Host *psh, unsigned long io_port, u8 Irq, u8 index );
-static void   dc390_updateDCB (struct dc390_acb* pACB, struct dc390_dcb* pDCB);
-
-static struct dc390_acb*	dc390_pACB_start= NULL;
-static struct dc390_acb*	dc390_pACB_current = NULL;
 static u32	dc390_laststatus = 0;
 static u8	dc390_adapterCnt = 0;
 
 /* Startup values, to be overriden on the commandline */
 static int tmscsim[] = {-2, -2, -2, -2, -2, -2};
-static int tmscsim_paramnum = ARRAY_SIZE(tmscsim);
 
-module_param_array(tmscsim, int, tmscsim_paramnum, 0);
+module_param_array(tmscsim, int, NULL, 0);
 MODULE_PARM_DESC(tmscsim, "Host SCSI ID, Speed (0=10MHz), Device Flags, Adapter Flags, Max Tags (log2(tags)-1), DelayReset (s)");
 MODULE_AUTHOR("C.L. Huang / Kurt Garloff");
 MODULE_DESCRIPTION("SCSI host adapter driver for Tekram DC390 and other AMD53C974A based PCI SCSI adapters");
@@ -361,243 +340,11 @@
        };
 #endif   
 
-/* Devices erroneously pretending to be able to do TagQ */
-static u8  dc390_baddevname1[2][28] ={
-       "SEAGATE ST3390N         9546",
-       "HP      C3323-300       4269"};
-#define BADDEVCNT	2
-
-static char*  dc390_adapname = "DC390";
 static u8  dc390_eepromBuf[MAX_ADAPTER_NUM][EE_LEN];
 static u8  dc390_clock_period1[] = {4, 5, 6, 7, 8, 10, 13, 20};
 static u8  dc390_clock_speed[] = {100,80,67,57,50, 40, 31, 20};
 
 /***********************************************************************
- * Functions for access to DC390 EEPROM
- * and some to emulate it
- *
- **********************************************************************/
-
-
-static void __devinit dc390_EnDisableCE(u8 mode, struct pci_dev *pdev, u8 *regval)
-{
-    u8 bval;
-
-    bval = 0;
-    if(mode == ENABLE_CE)
-	*regval = 0xc0;
-    else
-	*regval = 0x80;
-    pci_write_config_byte(pdev, *regval, bval);
-    if(mode == DISABLE_CE)
-        pci_write_config_byte(pdev, *regval, bval);
-    udelay(160);
-}
-
-
-/* Override EEprom values with explicitly set values */
-static void __devinit dc390_EEprom_Override (u8 index)
-{
-    u8 *ptr = (u8 *) dc390_eepromBuf[index];
-    u8 id;
-    
-    /* Adapter Settings */
-    if (tmscsim[0] != -2)
-	ptr[EE_ADAPT_SCSI_ID] = (u8)tmscsim[0];	/* Adapter ID */
-    if (tmscsim[3] != -2)
-	ptr[EE_MODE2] = (u8)tmscsim[3];
-    if (tmscsim[5] != -2)
-	ptr[EE_DELAY] = tmscsim[5];			/* Reset delay */
-    if (tmscsim[4] != -2)
-	ptr[EE_TAG_CMD_NUM] = (u8)tmscsim[4];	/* Tagged Cmds */
-    
-    /* Device Settings */
-    for (id = 0; id < MAX_SCSI_ID; id++)
-    {
-	if (tmscsim[2] != -2)
-		ptr[id<<2] = (u8)tmscsim[2];		/* EE_MODE1 */
-	if (tmscsim[1] != -2)
-		ptr[(id<<2) + 1] = (u8)tmscsim[1];	/* EE_Speed */
-    }
-}
-
-/* Handle "-1" case */
-static void __devinit dc390_check_for_safe_settings (void)
-{
-	if (tmscsim[0] == -1 || tmscsim[0] > 15) /* modules-2.0.0 passes -1 as string */
-	{
-		tmscsim[0] = 7; tmscsim[1] = 4;
-		tmscsim[2] = 0x09; tmscsim[3] = 0x0f;
-		tmscsim[4] = 2; tmscsim[5] = 10;
-		printk (KERN_INFO "DC390: Using safe settings.\n");
-	}
-}
-
-
-static int __initdata tmscsim_def[] = {7, 0 /* 10MHz */,
-		PARITY_CHK_ | SEND_START_ | EN_DISCONNECT_
-		| SYNC_NEGO_ | TAG_QUEUEING_,
-		MORE2_DRV | GREATER_1G | RST_SCSI_BUS | ACTIVE_NEGATION
-		/* | NO_SEEK */
-# ifdef CONFIG_SCSI_MULTI_LUN
-		| LUN_CHECK
-# endif
-		, 3 /* 16 Tags per LUN */, 1 /* s delay after Reset */ };
-
-/* Copy defaults over set values where missing */
-static void __devinit dc390_fill_with_defaults (void)
-{
-	int i;
-	PARSEDEBUG(printk(KERN_INFO "DC390: setup %08x %08x %08x %08x %08x %08x\n", tmscsim[0],\
-			  tmscsim[1], tmscsim[2], tmscsim[3], tmscsim[4], tmscsim[5]));
-	for (i = 0; i < 6; i++)
-	{
-		if (tmscsim[i] < 0 || tmscsim[i] > 255)
-			tmscsim[i] = tmscsim_def[i];
-	}
-	/* Sanity checks */
-	if (tmscsim[0] >   7) tmscsim[0] =   7;
-	if (tmscsim[1] >   7) tmscsim[1] =   4;
-	if (tmscsim[4] >   5) tmscsim[4] =   4;
-	if (tmscsim[5] > 180) tmscsim[5] = 180;
-}
-
-#ifndef MODULE
-/* Override defaults on cmdline:
- * tmscsim: AdaptID, MaxSpeed (Index), DevMode (Bitmapped), AdaptMode (Bitmapped)
- */
-static int __init dc390_setup (char *str)
-{	
-	int ints[8];
-	int i, im;
-	(void)get_options (str, ARRAY_SIZE(ints), ints);
-	im = ints[0];
-	if (im > 6)
-	{
-		printk (KERN_NOTICE "DC390: ignore extra params!\n");
-		im = 6;
-	}
-	for (i = 0; i < im; i++)
-		tmscsim[i] = ints[i+1];
-	/* dc390_checkparams (); */
-	return 1;
-}
-
-__setup("tmscsim=", dc390_setup);
-#endif
-
-static void __devinit dc390_EEpromOutDI(struct pci_dev *pdev, u8 *regval, u8 Carry)
-{
-    u8 bval;
-
-    bval = 0;
-    if(Carry)
-    {
-	bval = 0x40;
-	*regval = 0x80;
-	pci_write_config_byte(pdev, *regval, bval);
-    }
-    udelay(160);
-    bval |= 0x80;
-    pci_write_config_byte(pdev, *regval, bval);
-    udelay(160);
-    bval = 0;
-    pci_write_config_byte(pdev, *regval, bval);
-    udelay(160);
-}
-
-
-static u8 __devinit dc390_EEpromInDO(struct pci_dev *pdev)
-{
-    u8 bval;
-
-    pci_write_config_byte(pdev, 0x80, 0x80);
-    udelay(160);
-    pci_write_config_byte(pdev, 0x80, 0x40);
-    udelay(160);
-    pci_read_config_byte(pdev, 0x00, &bval);
-    if(bval == 0x22)
-	return(1);
-    else
-	return(0);
-}
-
-
-static u16 __devinit dc390_EEpromGetData1(struct pci_dev *pdev)
-{
-    u8 i;
-    u8 carryFlag;
-    u16 wval;
-
-    wval = 0;
-    for(i=0; i<16; i++)
-    {
-	wval <<= 1;
-	carryFlag = dc390_EEpromInDO(pdev);
-	wval |= carryFlag;
-    }
-    return(wval);
-}
-
-
-static void __devinit dc390_Prepare(struct pci_dev *pdev, u8 *regval, u8 EEpromCmd)
-{
-    u8 i,j;
-    u8 carryFlag;
-
-    carryFlag = 1;
-    j = 0x80;
-    for(i=0; i<9; i++)
-    {
-	dc390_EEpromOutDI(pdev, regval, carryFlag);
-	carryFlag = (EEpromCmd & j) ? 1 : 0;
-	j >>= 1;
-    }
-}
-
-
-static void __devinit dc390_ReadEEprom(struct pci_dev *pdev, u16 *ptr)
-{
-    u8   regval,cmd;
-    u8   i;
-
-    cmd = EEPROM_READ;
-    for(i=0; i<0x40; i++)
-    {
-	dc390_EnDisableCE(ENABLE_CE, pdev, &regval);
-	dc390_Prepare(pdev, &regval, cmd++);
-	*ptr++ = dc390_EEpromGetData1(pdev);
-	dc390_EnDisableCE(DISABLE_CE, pdev, &regval);
-    }
-}
-
-
-static void __devinit dc390_interpret_delay (u8 index)
-{
-    char interpd [] = {1,3,5,10,16,30,60,120};
-    dc390_eepromBuf[index][EE_DELAY] = interpd [dc390_eepromBuf[index][EE_DELAY]];
-}
-
-static u8 __devinit dc390_CheckEEpromCheckSum(struct pci_dev *pdev, u8 index)
-{
-    u8  i;
-    char  EEbuf[128];
-    u16 wval, *ptr = (u16 *)EEbuf;
-
-    dc390_ReadEEprom(pdev, ptr);
-    memcpy (dc390_eepromBuf[index], EEbuf, EE_ADAPT_SCSI_ID);
-    memcpy (&dc390_eepromBuf[index][EE_ADAPT_SCSI_ID], 
-	    &EEbuf[REAL_EE_ADAPT_SCSI_ID], EE_LEN - EE_ADAPT_SCSI_ID);
-    dc390_interpret_delay (index);
-    
-    wval = 0;
-    for(i=0; i<0x40; i++, ptr++)
-	wval += *ptr;
-    return (wval == 0x1234 ? 0 : 1);
-}
-
-
-/***********************************************************************
  * Functions for the management of the internal structures 
  * (DCBs, SRBs, Queueing)
  *
@@ -616,36 +363,6 @@
    return pDCB;
 }
 
-/* Queueing philosphy:
- * There are a couple of lists:
- * - Query: Contains the Scsi Commands not yet turned into SRBs (per ACB)
- *   (Note: For new EH, it is unnecessary!)
- * - Waiting: Contains a list of SRBs not yet sent (per DCB)
- * - Free: List of free SRB slots
- * 
- * If there are no waiting commands for the DCB, the new one is sent to the bus
- * otherwise the oldest one is taken from the Waiting list and the new one is 
- * queued to the Waiting List
- * 
- * Lists are managed using two pointers and eventually a counter
- */
-
-/* Return next free SRB */
-static __inline__ struct dc390_srb* dc390_Free_get ( struct dc390_acb* pACB )
-{
-    struct dc390_srb*   pSRB;
-
-    pSRB = pACB->pFreeSRB;
-    DEBUG0(printk ("DC390: Get Free SRB %p\n", pSRB));
-    if( pSRB )
-    {
-	pACB->pFreeSRB = pSRB->pNextSRB;
-	pSRB->pNextSRB = NULL;
-    }
-
-    return( pSRB );
-}
-
 /* Insert SRB oin top of free list */
 static __inline__ void dc390_Free_insert (struct dc390_acb* pACB, struct dc390_srb* pSRB)
 {
@@ -654,34 +371,6 @@
     pACB->pFreeSRB = pSRB;
 }
 
-
-/* Inserts a SRB to the top of the Waiting list */
-static __inline__ void dc390_Waiting_insert ( struct dc390_dcb* pDCB, struct dc390_srb* pSRB )
-{
-    DEBUG0(printk ("DC390: Insert pSRB %p cmd %li to Waiting\n", pSRB, pSRB->pcmd->pid));
-    pSRB->pNextSRB = pDCB->pWaitingSRB;
-    if (!pDCB->pWaitingSRB)
-	pDCB->pWaitLast = pSRB;
-    pDCB->pWaitingSRB = pSRB;
-    pDCB->WaitSRBCnt++;
-}
-
-
-/* Queue SRB to waiting list */
-static __inline__ void dc390_Waiting_append ( struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
-{
-	DEBUG0(printk ("DC390: Append pSRB %p cmd %li to Waiting\n", pSRB, pSRB->pcmd->pid));
-    if( pDCB->pWaitingSRB )
-	pDCB->pWaitLast->pNextSRB = pSRB;
-    else
-	pDCB->pWaitingSRB = pSRB;
-
-    pDCB->pWaitLast = pSRB;
-    pSRB->pNextSRB = NULL;
-    pDCB->WaitSRBCnt++;
-    pDCB->pDCBACB->CmdInQ++;
-}
-
 static __inline__ void dc390_Going_append (struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
 {
     pDCB->GoingSRBCnt++;
@@ -716,132 +405,6 @@
    pDCB->GoingSRBCnt--;
 }
 
-/* Moves SRB from Going list to the top of Waiting list */
-static void dc390_Going_to_Waiting ( struct dc390_dcb* pDCB, struct dc390_srb* pSRB )
-{
-    DEBUG0(printk(KERN_INFO "DC390: Going_to_Waiting (SRB %p) pid = %li\n", pSRB, pSRB->pcmd->pid));
-    /* Remove SRB from Going */
-    dc390_Going_remove (pDCB, pSRB);
-    /* Insert on top of Waiting */
-    dc390_Waiting_insert (pDCB, pSRB);
-    /* Tag Mask must be freed elsewhere ! (KG, 99/06/18) */
-}
-
-/* Moves first SRB from Waiting list to Going list */
-static __inline__ void dc390_Waiting_to_Going ( struct dc390_dcb* pDCB, struct dc390_srb* pSRB )
-{	
-	/* Remove from waiting list */
-	DEBUG0(printk("DC390: Remove SRB %p from head of Waiting\n", pSRB));
-	pDCB->pWaitingSRB = pSRB->pNextSRB;
-	if( !pDCB->pWaitingSRB ) pDCB->pWaitLast = NULL;
-	pDCB->WaitSRBCnt--;
-	dc390_Going_append (pDCB, pSRB);
-}
-
-static void DC390_waiting_timed_out (unsigned long ptr);
-/* Sets the timer to wake us up */
-static void dc390_waiting_timer (struct dc390_acb* pACB, unsigned long to)
-{
-	if (timer_pending (&pACB->Waiting_Timer)) return;
-	init_timer (&pACB->Waiting_Timer);
-	pACB->Waiting_Timer.function = DC390_waiting_timed_out;
-	pACB->Waiting_Timer.data = (unsigned long)pACB;
-	if (time_before (jiffies + to, pACB->pScsiHost->last_reset))
-		pACB->Waiting_Timer.expires = pACB->pScsiHost->last_reset + 1;
-	else
-		pACB->Waiting_Timer.expires = jiffies + to + 1;
-	add_timer (&pACB->Waiting_Timer);
-}
-
-
-/* Send the next command from the waiting list to the bus */
-static void dc390_Waiting_process ( struct dc390_acb* pACB )
-{
-    struct dc390_dcb *ptr, *ptr1;
-    struct dc390_srb *pSRB;
-
-    if( (pACB->pActiveDCB) || (pACB->ACBFlag & (RESET_DETECT+RESET_DONE+RESET_DEV) ) )
-	return;
-    if (timer_pending (&pACB->Waiting_Timer)) del_timer (&pACB->Waiting_Timer);
-    ptr = pACB->pDCBRunRobin;
-    if( !ptr )
-      {
-	ptr = pACB->pLinkDCB;
-	pACB->pDCBRunRobin = ptr;
-      }
-    ptr1 = ptr;
-    if (!ptr1) return;
-    do 
-      {
-	pACB->pDCBRunRobin = ptr1->pNextDCB;
-	if( !( pSRB = ptr1->pWaitingSRB ) ||
-	    ( ptr1->MaxCommand <= ptr1->GoingSRBCnt ))
-	  ptr1 = ptr1->pNextDCB;
-	else
-	  {
-	    /* Try to send to the bus */
-	    if( !dc390_StartSCSI(pACB, ptr1, pSRB) )
-	      dc390_Waiting_to_Going (ptr1, pSRB);
-	    else
-	      dc390_waiting_timer (pACB, HZ/5);
-	    break;
-	  }
-      } while (ptr1 != ptr);
-    return;
-}
-
-/* Wake up waiting queue */
-static void DC390_waiting_timed_out (unsigned long ptr)
-{
-	struct dc390_acb* pACB = (struct dc390_acb*)ptr;
-	unsigned long iflags;
-	DEBUG0(printk ("DC390: Debug: Waiting queue woken up by timer!\n"));
-	spin_lock_irqsave(pACB->pScsiHost->host_lock, iflags);
-	dc390_Waiting_process (pACB);
-	spin_unlock_irqrestore(pACB->pScsiHost->host_lock, iflags);
-}
-
-/***********************************************************************
- * Function: static void dc390_SendSRB (struct dc390_acb* pACB, struct dc390_srb* pSRB)
- *
- * Purpose: Send SCSI Request Block (pSRB) to adapter (pACB)
- *
- ***********************************************************************/
-
-static void dc390_SendSRB( struct dc390_acb* pACB, struct dc390_srb* pSRB )
-{
-    struct dc390_dcb*   pDCB;
-
-    pDCB = pSRB->pSRBDCB;
-    if( (pDCB->MaxCommand <= pDCB->GoingSRBCnt) || (pACB->pActiveDCB) ||
-	(pACB->ACBFlag & (RESET_DETECT+RESET_DONE+RESET_DEV)) )
-    {
-	dc390_Waiting_append (pDCB, pSRB);
-	dc390_Waiting_process (pACB);
-	return;
-    }
-
-#if 0
-    if( pDCB->pWaitingSRB )
-    {
-	dc390_Waiting_append (pDCB, pSRB);
-/*	pSRB = GetWaitingSRB(pDCB); */	/* non-existent */
-	pSRB = pDCB->pWaitingSRB;
-	/* Remove from waiting list */
-	pDCB->pWaitingSRB = pSRB->pNextSRB;
-	pSRB->pNextSRB = NULL;
-	if (!pDCB->pWaitingSRB) pDCB->pWaitLast = NULL;
-    }
-#endif
-	
-    if (!dc390_StartSCSI(pACB, pDCB, pSRB))
-	dc390_Going_append (pDCB, pSRB);
-    else {
-	dc390_Waiting_insert (pDCB, pSRB);
-	dc390_waiting_timer (pACB, HZ/5);
-    }
-}
-
 static struct scatterlist* dc390_sg_build_single(struct scatterlist *sg, void *addr, unsigned int length)
 {
 	memset(sg, 0, sizeof(struct scatterlist));
@@ -917,86 +480,1550 @@
 	}
 }
 
+static void __inline__
+dc390_freetag (struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
+{
+	if (pSRB->TagNumber != SCSI_NO_TAG) {
+		pDCB->TagMask &= ~(1 << pSRB->TagNumber);   /* free tag mask */
+		pSRB->TagNumber = SCSI_NO_TAG;
+	}
+}
 
-/***********************************************************************
- * Function: static void dc390_BuildSRB (Scsi_Cmd *pcmd, struct dc390_dcb* pDCB, 
- * 					 struct dc390_srb* pSRB)
- *
- * Purpose: Prepare SRB for being sent to Device DCB w/ command *pcmd
- *
- ***********************************************************************/
 
-static void dc390_BuildSRB (struct scsi_cmnd *pcmd, struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
+static int
+dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB )
 {
-    pSRB->pSRBDCB = pDCB;
-    pSRB->pcmd = pcmd;
-    
-    pSRB->SGIndex = 0;
-    pSRB->AdaptStatus = 0;
-    pSRB->TargetStatus = 0;
-    pSRB->MsgCnt = 0;
-    if( pDCB->DevType != TYPE_TAPE )
-	pSRB->RetryCnt = 1;
+    struct scsi_cmnd *scmd = pSRB->pcmd;
+    struct scsi_device *sdev = scmd->device;
+    u8 cmd, disc_allowed, try_sync_nego;
+    char tag[2];
+
+    pSRB->ScsiPhase = SCSI_NOP0;
+
+    if (pACB->Connected)
+    {
+	// Should not happen normally
+	printk (KERN_WARNING "DC390: Can't select when connected! (%08x,%02x)\n",
+		pSRB->SRBState, pSRB->SRBFlag);
+	pSRB->SRBState = SRB_READY;
+	pACB->SelConn++;
+	return 1;
+    }
+    if (time_before (jiffies, pACB->pScsiHost->last_reset))
+    {
+	DEBUG0(printk ("DC390: We were just reset and don't accept commands yet!\n"));
+	return 1;
+    }
+    /* KG: Moved pci mapping here */
+    dc390_pci_map(pSRB);
+    /* TODO: error handling */
+    DC390_write8 (Scsi_Dest_ID, pDCB->TargetID);
+    DC390_write8 (Sync_Period, pDCB->SyncPeriod);
+    DC390_write8 (Sync_Offset, pDCB->SyncOffset);
+    DC390_write8 (CtrlReg1, pDCB->CtrlR1);
+    DC390_write8 (CtrlReg3, pDCB->CtrlR3);
+    DC390_write8 (CtrlReg4, pDCB->CtrlR4);
+    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);		/* Flush FIFO */
+    DEBUG1(printk (KERN_INFO "DC390: Start SCSI command: %02x (Sync:%02x)\n",\
+            scmd->cmnd[0], pDCB->SyncMode));
+
+    /* Don't disconnect on AUTO_REQSENSE, cause it might be an
+     * Contingent Allegiance Condition (6.6), where no tags should be used.
+     * All other have to be allowed to disconnect to prevent Incorrect 
+     * Initiator Connection (6.8.2/6.5.2) */
+    /* Changed KG, 99/06/06 */
+    if (! (pSRB->SRBFlag & AUTO_REQSENSE))
+	disc_allowed = pDCB->DevMode & EN_DISCONNECT_;
     else
-	pSRB->RetryCnt = 0;
-    pSRB->SRBStatus = 0;
-    pSRB->SRBFlag = 0;
-    pSRB->SRBState = 0;
+	disc_allowed = 0;
+
+    if ((pDCB->SyncMode & SYNC_ENABLE) && pDCB->TargetLUN == 0 && sdev->sdtr &&
+	(((scmd->cmnd[0] == REQUEST_SENSE || (pSRB->SRBFlag & AUTO_REQSENSE)) &&
+	  !(pDCB->SyncMode & SYNC_NEGO_DONE)) || scmd->cmnd[0] == INQUIRY))
+      try_sync_nego = 1;
+    else
+      try_sync_nego = 0;
+
+    pSRB->MsgCnt = 0;
+    cmd = SEL_W_ATN;
+    DC390_write8 (ScsiFifo, IDENTIFY(disc_allowed, pDCB->TargetLUN));
+    /* Change 99/05/31: Don't use tags when not disconnecting (BUSY) */
+    if ((pDCB->SyncMode & EN_TAG_QUEUEING) && disc_allowed && scsi_populate_tag_msg(scmd, tag)) {
+	DC390_write8(ScsiFifo, tag[0]);
+	pDCB->TagMask |= 1 << tag[1];
+	pSRB->TagNumber = tag[1];
+	DC390_write8(ScsiFifo, tag[1]);
+	DEBUG1(printk(KERN_INFO "DC390: Select w/DisCn for Cmd %li (SRB %p), block tag %02x\n", scmd->pid, pSRB, tag[1]));
+	cmd = SEL_W_ATN3;
+    } else {
+	/* No TagQ */
+//no_tag:
+	DEBUG1(printk(KERN_INFO "DC390: Select w%s/DisCn for Cmd %li (SRB %p), No TagQ\n", disc_allowed ? "" : "o", scmd->pid, pSRB));
+    }
+
+    pSRB->SRBState = SRB_START_;
+
+    if (try_sync_nego)
+      { 
+	u8 Sync_Off = pDCB->SyncOffset;
+        DEBUG0(printk (KERN_INFO "DC390: NEW Sync Nego code triggered (%i %i)\n", pDCB->TargetID, pDCB->TargetLUN));
+	pSRB->MsgOutBuf[0] = EXTENDED_MESSAGE;
+	pSRB->MsgOutBuf[1] = 3;
+	pSRB->MsgOutBuf[2] = EXTENDED_SDTR;
+	pSRB->MsgOutBuf[3] = pDCB->NegoPeriod;
+	if (!(Sync_Off & 0x0f)) Sync_Off = SYNC_NEGO_OFFSET;
+	pSRB->MsgOutBuf[4] = Sync_Off;
+	pSRB->MsgCnt = 5;
+	//pSRB->SRBState = SRB_MSGOUT_;
+	pSRB->SRBState |= DO_SYNC_NEGO;
+	cmd = SEL_W_ATN_STOP;
+      }
+
+    /* Command is written in CommandPhase, if SEL_W_ATN_STOP ... */
+    if (cmd != SEL_W_ATN_STOP)
+      {
+	if( pSRB->SRBFlag & AUTO_REQSENSE )
+	  {
+	    DC390_write8 (ScsiFifo, REQUEST_SENSE);
+	    DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5);
+	    DC390_write8 (ScsiFifo, 0);
+	    DC390_write8 (ScsiFifo, 0);
+	    DC390_write8 (ScsiFifo, sizeof(scmd->sense_buffer));
+	    DC390_write8 (ScsiFifo, 0);
+	    DEBUG1(printk (KERN_DEBUG "DC390: AutoReqSense !\n"));
+	  }
+	else	/* write cmnd to bus */ 
+	  {
+	    u8 *ptr; u8 i;
+	    ptr = (u8 *)scmd->cmnd;
+	    for (i = 0; i < scmd->cmd_len; i++)
+	      DC390_write8 (ScsiFifo, *(ptr++));
+	  }
+      }
+    DEBUG0(if (pACB->pActiveDCB)	\
+	   printk (KERN_WARNING "DC390: ActiveDCB != 0\n"));
+    DEBUG0(if (pDCB->pActiveSRB)	\
+	   printk (KERN_WARNING "DC390: ActiveSRB != 0\n"));
+    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
+    if (DC390_read8 (Scsi_Status) & INTERRUPT)
+    {
+	dc390_freetag (pDCB, pSRB);
+	DEBUG0(printk ("DC390: Interrupt during Start SCSI (pid %li, target %02i-%02i)\n",
+		scmd->pid, scmd->device->id, scmd->device->lun));
+	pSRB->SRBState = SRB_READY;
+	//DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+	pACB->SelLost++;
+	return 1;
+    }
+    DC390_write8 (ScsiCmd, cmd);
+    pACB->pActiveDCB = pDCB;
+    pDCB->pActiveSRB = pSRB;
+    pACB->Connected = 1;
+    pSRB->ScsiPhase = SCSI_NOP1;
+    return 0;
+}
+
+//#define DMA_INT EN_DMA_INT /*| EN_PAGE_INT*/
+#define DMA_INT 0
+
+#if DMA_INT
+/* This is similar to AM53C974.c ... */
+static u8 
+dc390_dma_intr (struct dc390_acb* pACB)
+{
+  struct dc390_srb* pSRB;
+  u8 dstate;
+  DEBUG0(u16 pstate; struct pci_dev *pdev = pACB->pdev);
+  
+  DEBUG0(pci_read_config_word(pdev, PCI_STATUS, &pstate));
+  DEBUG0(if (pstate & (PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY))\
+	{ printk(KERN_WARNING "DC390: PCI state = %04x!\n", pstate); \
+	  pci_write_config_word(pdev, PCI_STATUS, (PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY));});
+
+  dstate = DC390_read8 (DMA_Status); 
+
+  if (! pACB->pActiveDCB || ! pACB->pActiveDCB->pActiveSRB) return dstate;
+  else pSRB  = pACB->pActiveDCB->pActiveSRB;
+  
+  if (dstate & (DMA_XFER_ABORT | DMA_XFER_ERROR | POWER_DOWN | PCI_MS_ABORT))
+    {
+	printk (KERN_ERR "DC390: DMA error (%02x)!\n", dstate);
+	return dstate;
+    }
+  if (dstate & DMA_XFER_DONE)
+    {
+	u32 residual, xferCnt; int ctr = 6000000;
+	if (! (DC390_read8 (DMA_Cmd) & READ_DIRECTION))
+	  {
+	    do
+	      {
+		DEBUG1(printk (KERN_DEBUG "DC390: read residual bytes ... \n"));
+		dstate = DC390_read8 (DMA_Status);
+		residual = DC390_read8 (CtcReg_Low) | DC390_read8 (CtcReg_Mid) << 8 |
+		  DC390_read8 (CtcReg_High) << 16;
+		residual += DC390_read8 (Current_Fifo) & 0x1f;
+	      } while (residual && ! (dstate & SCSI_INTERRUPT) && --ctr);
+	    if (!ctr) printk (KERN_CRIT "DC390: dma_intr: DMA aborted unfinished: %06x bytes remain!!\n", DC390_read32 (DMA_Wk_ByteCntr));
+	    /* residual =  ... */
+	  }
+	else
+	    residual = 0;
+	
+	/* ??? */
+	
+	xferCnt = pSRB->SGToBeXferLen - residual;
+	pSRB->SGBusAddr += xferCnt;
+	pSRB->TotalXferredLen += xferCnt;
+	pSRB->SGToBeXferLen = residual;
+# ifdef DC390_DEBUG0
+	printk (KERN_INFO "DC390: DMA: residual = %i, xfer = %i\n", 
+		(unsigned int)residual, (unsigned int)xferCnt);
+# endif
+	
+	DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
+    }
+  dc390_laststatus &= ~0xff000000; dc390_laststatus |= dstate << 24;
+  return dstate;
+}
+#endif
+
+
+static void __inline__
+dc390_InvalidCmd(struct dc390_acb* pACB)
+{
+	if (pACB->pActiveDCB->pActiveSRB->SRBState & (SRB_START_ | SRB_MSGOUT))
+		DC390_write8(ScsiCmd, CLEAR_FIFO_CMD);
+}
+
+
+static irqreturn_t __inline__
+DC390_Interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+    struct dc390_acb *pACB = (struct dc390_acb*)dev_id;
+    struct dc390_dcb *pDCB;
+    struct dc390_srb *pSRB;
+    u8  sstatus=0;
+    u8  phase;
+    void   (*stateV)( struct dc390_acb*, struct dc390_srb*, u8 *);
+    u8  istate, istatus;
+#if DMA_INT
+    u8  dstatus;
+#endif
+
+    sstatus = DC390_read8 (Scsi_Status);
+    if( !(sstatus & INTERRUPT) )
+	return IRQ_NONE;
+
+    DEBUG1(printk (KERN_DEBUG "sstatus=%02x,", sstatus));
+
+#if DMA_INT
+    spin_lock_irq(pACB->pScsiHost->host_lock);
+    dstatus = dc390_dma_intr (pACB);
+    spin_unlock_irq(pACB->pScsiHost->host_lock);
+
+    DEBUG1(printk (KERN_DEBUG "dstatus=%02x,", dstatus));
+    if (! (dstatus & SCSI_INTERRUPT))
+      {
+	DEBUG0(printk (KERN_WARNING "DC390 Int w/o SCSI actions (only DMA?)\n"));
+	return IRQ_NONE;
+      }
+#else
+    //DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | EN_INT_ON_PCI_ABORT);
+    //dstatus = DC390_read8 (DMA_Status);
+    //DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT);
+#endif
+
+    spin_lock_irq(pACB->pScsiHost->host_lock);
+
+    istate = DC390_read8 (Intern_State);
+    istatus = DC390_read8 (INT_Status); /* This clears Scsi_Status, Intern_State and INT_Status ! */
+
+    DEBUG1(printk (KERN_INFO "Istatus(Res,Inv,Dis,Serv,Succ,ReS,SelA,Sel)=%02x,",istatus));
+    dc390_laststatus &= ~0x00ffffff;
+    dc390_laststatus |= /* dstatus<<24 | */ sstatus<<16 | istate<<8 | istatus;
+
+    if (sstatus & ILLEGAL_OP_ERR)
+    {
+	printk ("DC390: Illegal Operation detected (%08x)!\n", dc390_laststatus);
+	dc390_dumpinfo (pACB, pACB->pActiveDCB, pACB->pActiveDCB->pActiveSRB);
+    }
+	
+    else if (istatus &  INVALID_CMD)
+    {
+	printk ("DC390: Invalid Command detected (%08x)!\n", dc390_laststatus);
+	dc390_InvalidCmd( pACB );
+	goto unlock;
+    }
+
+    if (istatus &  SCSI_RESET)
+    {
+	dc390_ScsiRstDetect( pACB );
+	goto unlock;
+    }
+
+    if (istatus &  DISCONNECTED)
+    {
+	dc390_Disconnect( pACB );
+	goto unlock;
+    }
+
+    if (istatus &  RESELECTED)
+    {
+	dc390_Reselect( pACB );
+	goto unlock;
+    }
+
+    else if (istatus & (SELECTED | SEL_ATTENTION))
+    {
+	printk (KERN_ERR "DC390: Target mode not supported!\n");
+	goto unlock;
+    }
+
+    if (istatus & (SUCCESSFUL_OP|SERVICE_REQUEST) )
+    {
+	pDCB = pACB->pActiveDCB;
+	if (!pDCB)
+	{
+		printk (KERN_ERR "DC390: Suc. op/ Serv. req: pActiveDCB = 0!\n");
+		goto unlock;
+	}
+	pSRB = pDCB->pActiveSRB;
+	if( pDCB->DCBFlag & ABORT_DEV_ )
+	  dc390_EnableMsgOut_Abort (pACB, pSRB);
+
+	phase = pSRB->ScsiPhase;
+	DEBUG1(printk (KERN_INFO "DC390: [%i]%s(0) (%02x)\n", phase, dc390_p0_str[phase], sstatus));
+	stateV = (void *) dc390_phase0[phase];
+	( *stateV )( pACB, pSRB, &sstatus );
+
+	pSRB->ScsiPhase = sstatus & 7;
+	phase = (u8) sstatus & 7;
+	DEBUG1(printk (KERN_INFO "DC390: [%i]%s(1) (%02x)\n", phase, dc390_p1_str[phase], sstatus));
+	stateV = (void *) dc390_phase1[phase];
+	( *stateV )( pACB, pSRB, &sstatus );
+    }
+
+ unlock:
+    spin_unlock_irq(pACB->pScsiHost->host_lock);
+    return IRQ_HANDLED;
+}
+
+static irqreturn_t do_DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs)
+{
+    irqreturn_t ret;
+    DEBUG1(printk (KERN_INFO "DC390: Irq (%i) caught: ", irq));
+    /* Locking is done in DC390_Interrupt */
+    ret = DC390_Interrupt(irq, dev_id, regs);
+    DEBUG1(printk (".. IRQ returned\n"));
+    return ret;
+}
+
+static void
+dc390_DataOut_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    u8   sstatus;
+    struct scatterlist *psgl;
+    u32    ResidCnt, xferCnt;
+    u8   dstate = 0;
+
+    sstatus = *psstatus;
+
+    if( !(pSRB->SRBState & SRB_XFERPAD) )
+    {
+	if( sstatus & (PARITY_ERR | ILLEGAL_OP_ERR) )
+	    pSRB->SRBStatus |= PARITY_ERROR;
+
+	if( sstatus & COUNT_2_ZERO )
+	{
+	    unsigned long timeout = jiffies + HZ;
+
+	    /* Function called from the ISR with the host_lock held and interrupts disabled */
+	    if (pSRB->SGToBeXferLen)
+		while (time_before(jiffies, timeout) && !((dstate = DC390_read8 (DMA_Status)) & DMA_XFER_DONE)) {
+		    spin_unlock_irq(pACB->pScsiHost->host_lock);
+		    udelay(50);
+		    spin_lock_irq(pACB->pScsiHost->host_lock);
+		}
+	    if (!time_before(jiffies, timeout))
+		printk (KERN_CRIT "DC390: Deadlock in DataOut_0: DMA aborted unfinished: %06x bytes remain!!\n",
+			DC390_read32 (DMA_Wk_ByteCntr));
+	    dc390_laststatus &= ~0xff000000;
+	    dc390_laststatus |= dstate << 24;
+	    pSRB->TotalXferredLen += pSRB->SGToBeXferLen;
+	    pSRB->SGIndex++;
+	    if( pSRB->SGIndex < pSRB->SGcount )
+	    {
+		pSRB->pSegmentList++;
+		psgl = pSRB->pSegmentList;
+
+		pSRB->SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
+		pSRB->SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
+	    }
+	    else
+		pSRB->SGToBeXferLen = 0;
+	}
+	else
+	{
+	    ResidCnt  = (u32) DC390_read8 (Current_Fifo) & 0x1f;
+	    ResidCnt |= (u32) DC390_read8 (CtcReg_High) << 16;
+	    ResidCnt |= (u32) DC390_read8 (CtcReg_Mid) << 8; 
+	    ResidCnt += (u32) DC390_read8 (CtcReg_Low);
+
+	    xferCnt = pSRB->SGToBeXferLen - ResidCnt;
+	    pSRB->SGBusAddr += xferCnt;
+	    pSRB->TotalXferredLen += xferCnt;
+	    pSRB->SGToBeXferLen = ResidCnt;
+	}
+    }
+    if ((*psstatus & 7) != SCSI_DATA_OUT)
+    {
+	    DC390_write8 (DMA_Cmd, WRITE_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
+	    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+    }	    
+}
+
+static void
+dc390_DataIn_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    u8   sstatus, residual, bval;
+    struct scatterlist *psgl;
+    u32    ResidCnt, i;
+    unsigned long   xferCnt;
+    u8      *ptr;
+
+    sstatus = *psstatus;
+
+    if( !(pSRB->SRBState & SRB_XFERPAD) )
+    {
+	if( sstatus & (PARITY_ERR | ILLEGAL_OP_ERR))
+	    pSRB->SRBStatus |= PARITY_ERROR;
+
+	if( sstatus & COUNT_2_ZERO )
+	{
+	    int dstate = 0;
+	    unsigned long timeout = jiffies + HZ;
+
+	    /* Function called from the ISR with the host_lock held and interrupts disabled */
+	    if (pSRB->SGToBeXferLen)
+		while (time_before(jiffies, timeout) && !((dstate = DC390_read8 (DMA_Status)) & DMA_XFER_DONE)) {
+		    spin_unlock_irq(pACB->pScsiHost->host_lock);
+		    udelay(50);
+		    spin_lock_irq(pACB->pScsiHost->host_lock);
+		}
+	    if (!time_before(jiffies, timeout)) {
+		printk (KERN_CRIT "DC390: Deadlock in DataIn_0: DMA aborted unfinished: %06x bytes remain!!\n",
+			DC390_read32 (DMA_Wk_ByteCntr));
+		printk (KERN_CRIT "DC390: DataIn_0: DMA State: %i\n", dstate);
+	    }
+	    dc390_laststatus &= ~0xff000000;
+	    dc390_laststatus |= dstate << 24;
+	    DEBUG1(ResidCnt = ((unsigned long) DC390_read8 (CtcReg_High) << 16)	\
+		+ ((unsigned long) DC390_read8 (CtcReg_Mid) << 8)		\
+		+ ((unsigned long) DC390_read8 (CtcReg_Low)));
+	    DEBUG1(printk (KERN_DEBUG "Count_2_Zero (ResidCnt=%i,ToBeXfer=%li),", ResidCnt, pSRB->SGToBeXferLen));
+
+	    DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
+
+	    pSRB->TotalXferredLen += pSRB->SGToBeXferLen;
+	    pSRB->SGIndex++;
+	    if( pSRB->SGIndex < pSRB->SGcount )
+	    {
+		pSRB->pSegmentList++;
+		psgl = pSRB->pSegmentList;
+
+		pSRB->SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
+		pSRB->SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
+	    }
+	    else
+		pSRB->SGToBeXferLen = 0;
+	}
+	else	/* phase changed */
+	{
+	    residual = 0;
+	    bval = DC390_read8 (Current_Fifo);
+	    while( bval & 0x1f )
+	    {
+		DEBUG1(printk (KERN_DEBUG "Check for residuals,"));
+		if( (bval & 0x1f) == 1 )
+		{
+		    for(i=0; i < 0x100; i++)
+		    {
+			bval = DC390_read8 (Current_Fifo);
+			if( !(bval & 0x1f) )
+			    goto din_1;
+			else if( i == 0x0ff )
+			{
+			    residual = 1;   /* ;1 residual byte */
+			    goto din_1;
+			}
+		    }
+		}
+		else
+		    bval = DC390_read8 (Current_Fifo);
+	    }
+din_1:
+	    DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_BLAST_CMD);
+	    for (i = 0xa000; i; i--)
+	    {
+		bval = DC390_read8 (DMA_Status);
+		if (bval & BLAST_COMPLETE)
+		    break;
+	    }
+	    /* It seems a DMA Blast abort isn't that bad ... */
+	    if (!i) printk (KERN_ERR "DC390: DMA Blast aborted unfinished!\n");
+	    //DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
+	    dc390_laststatus &= ~0xff000000; dc390_laststatus |= bval << 24;
+
+	    DEBUG1(printk (KERN_DEBUG "Blast: Read %i times DMA_Status %02x", 0xa000-i, bval));
+	    ResidCnt = (u32) DC390_read8 (CtcReg_High);
+	    ResidCnt <<= 8;
+	    ResidCnt |= (u32) DC390_read8 (CtcReg_Mid);
+	    ResidCnt <<= 8;
+	    ResidCnt |= (u32) DC390_read8 (CtcReg_Low);
+
+	    xferCnt = pSRB->SGToBeXferLen - ResidCnt;
+	    pSRB->SGBusAddr += xferCnt;
+	    pSRB->TotalXferredLen += xferCnt;
+	    pSRB->SGToBeXferLen = ResidCnt;
+
+	    if( residual )
+	    {
+		bval = DC390_read8 (ScsiFifo);	    /* get one residual byte */
+		ptr = (u8 *) bus_to_virt( pSRB->SGBusAddr );
+		*ptr = bval;
+		pSRB->SGBusAddr++; xferCnt++;
+		pSRB->TotalXferredLen++;
+		pSRB->SGToBeXferLen--;
+	    }
+	    DEBUG1(printk (KERN_DEBUG "Xfered: %li, Total: %li, Remaining: %li\n", xferCnt,\
+			   pSRB->TotalXferredLen, pSRB->SGToBeXferLen));
+
+	}
+    }
+    if ((*psstatus & 7) != SCSI_DATA_IN)
+    {
+	    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+	    DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
+    }
+}
+
+static void
+dc390_Command_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+}
+
+static void
+dc390_Status_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+
+    pSRB->TargetStatus = DC390_read8 (ScsiFifo);
+    //udelay (1);
+    pSRB->EndMessage = DC390_read8 (ScsiFifo);	/* get message */
+
+    *psstatus = SCSI_NOP0;
+    pSRB->SRBState = SRB_COMPLETED;
+    DC390_write8 (ScsiCmd, MSG_ACCEPTED_CMD);
+}
+
+static void
+dc390_MsgOut_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    if( pSRB->SRBState & (SRB_UNEXPECT_RESEL+SRB_ABORT_SENT) )
+	*psstatus = SCSI_NOP0;
+    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
+}
+
+
+static void __inline__
+dc390_reprog (struct dc390_acb* pACB, struct dc390_dcb* pDCB)
+{
+  DC390_write8 (Sync_Period, pDCB->SyncPeriod);
+  DC390_write8 (Sync_Offset, pDCB->SyncOffset);
+  DC390_write8 (CtrlReg3, pDCB->CtrlR3);
+  DC390_write8 (CtrlReg4, pDCB->CtrlR4);
+  dc390_SetXferRate (pACB, pDCB);
+}
+
+
+#ifdef DC390_DEBUG0
+static void
+dc390_printMsg (u8 *MsgBuf, u8 len)
+{
+  int i;
+  printk (" %02x", MsgBuf[0]);
+  for (i = 1; i < len; i++)
+    printk (" %02x", MsgBuf[i]);
+  printk ("\n");
+}
+#endif
+
+#define DC390_ENABLE_MSGOUT DC390_write8 (ScsiCmd, SET_ATN_CMD)
+
+/* reject_msg */
+static void __inline__
+dc390_MsgIn_reject (struct dc390_acb* pACB, struct dc390_srb* pSRB)
+{
+  pSRB->MsgOutBuf[0] = MESSAGE_REJECT;
+  pSRB->MsgCnt = 1;
+  DC390_ENABLE_MSGOUT;
+  DEBUG0 (printk (KERN_INFO "DC390: Reject message\n"));
+}
+
+/* abort command */
+static void
+dc390_EnableMsgOut_Abort ( struct dc390_acb* pACB, struct dc390_srb* pSRB )
+{
+    pSRB->MsgOutBuf[0] = ABORT; 
+    pSRB->MsgCnt = 1; DC390_ENABLE_MSGOUT;
+    pSRB->pSRBDCB->DCBFlag &= ~ABORT_DEV_;
+}
+
+static struct dc390_srb*
+dc390_MsgIn_QTag (struct dc390_acb* pACB, struct dc390_dcb* pDCB, s8 tag)
+{
+  struct dc390_srb* pSRB = pDCB->pGoingSRB;
+
+  if (pSRB)
+    {
+	struct scsi_cmnd *scmd = scsi_find_tag(pSRB->pcmd->device, tag);
+	pSRB = (struct dc390_srb *)scmd->host_scribble;
+
+	if (pDCB->DCBFlag & ABORT_DEV_)
+	{
+	  pSRB->SRBState = SRB_ABORT_SENT;
+	  dc390_EnableMsgOut_Abort( pACB, pSRB );
+	}
+
+	if (!(pSRB->SRBState & SRB_DISCONNECT))
+		goto mingx0;
+
+	pDCB->pActiveSRB = pSRB;
+	pSRB->SRBState = SRB_DATA_XFER;
+    }
+  else
+    {
+    mingx0:
+      pSRB = pACB->pTmpSRB;
+      pSRB->SRBState = SRB_UNEXPECT_RESEL;
+      pDCB->pActiveSRB = pSRB;
+      pSRB->MsgOutBuf[0] = ABORT_TAG;
+      pSRB->MsgCnt = 1; DC390_ENABLE_MSGOUT;
+    }
+  return pSRB;
+}
+
+
+/* set async transfer mode */
+static void 
+dc390_MsgIn_set_async (struct dc390_acb* pACB, struct dc390_srb* pSRB)
+{
+  struct dc390_dcb* pDCB = pSRB->pSRBDCB;
+  if (!(pSRB->SRBState & DO_SYNC_NEGO)) 
+    printk (KERN_INFO "DC390: Target %i initiates Non-Sync?\n", pDCB->TargetID);
+  pSRB->SRBState &= ~DO_SYNC_NEGO;
+  pDCB->SyncMode &= ~(SYNC_ENABLE+SYNC_NEGO_DONE);
+  pDCB->SyncPeriod = 0;
+  pDCB->SyncOffset = 0;
+  //pDCB->NegoPeriod = 50; /* 200ns <=> 5 MHz */
+  pDCB->CtrlR3 = FAST_CLK;	/* fast clock / normal scsi */
+  pDCB->CtrlR4 &= 0x3f;
+  pDCB->CtrlR4 |= pACB->glitch_cfg;	/* glitch eater */
+  dc390_reprog (pACB, pDCB);
+}
+
+/* set sync transfer mode */
+static void
+dc390_MsgIn_set_sync (struct dc390_acb* pACB, struct dc390_srb* pSRB)
+{
+  u8 bval;
+  u16 wval, wval1;
+  struct dc390_dcb* pDCB = pSRB->pSRBDCB;
+  u8 oldsyncperiod = pDCB->SyncPeriod;
+  u8 oldsyncoffset = pDCB->SyncOffset;
+  
+  if (!(pSRB->SRBState & DO_SYNC_NEGO))
+    {
+      printk (KERN_INFO "DC390: Target %i initiates Sync: %ins %i ... answer ...\n", 
+	      pDCB->TargetID, pSRB->MsgInBuf[3]<<2, pSRB->MsgInBuf[4]);
+
+      /* reject */
+      //dc390_MsgIn_reject (pACB, pSRB);
+      //return dc390_MsgIn_set_async (pACB, pSRB);
+
+      /* Reply with corrected SDTR Message */
+      if (pSRB->MsgInBuf[4] > 15)
+	{ 
+	  printk (KERN_INFO "DC390: Lower Sync Offset to 15\n");
+	  pSRB->MsgInBuf[4] = 15;
+	}
+      if (pSRB->MsgInBuf[3] < pDCB->NegoPeriod)
+	{
+	  printk (KERN_INFO "DC390: Set sync nego period to %ins\n", pDCB->NegoPeriod << 2);
+	  pSRB->MsgInBuf[3] = pDCB->NegoPeriod;
+	}
+      memcpy (pSRB->MsgOutBuf, pSRB->MsgInBuf, 5);
+      pSRB->MsgCnt = 5;
+      DC390_ENABLE_MSGOUT;
+    }
+
+  pSRB->SRBState &= ~DO_SYNC_NEGO;
+  pDCB->SyncMode |= SYNC_ENABLE+SYNC_NEGO_DONE;
+  pDCB->SyncOffset &= 0x0f0;
+  pDCB->SyncOffset |= pSRB->MsgInBuf[4];
+  pDCB->NegoPeriod = pSRB->MsgInBuf[3];
+
+  wval = (u16) pSRB->MsgInBuf[3];
+  wval = wval << 2; wval -= 3; wval1 = wval / 25;	/* compute speed */
+  if( (wval1 * 25) != wval) wval1++;
+  bval = FAST_CLK+FAST_SCSI;	/* fast clock / fast scsi */
+
+  pDCB->CtrlR4 &= 0x3f;		/* Glitch eater: 12ns less than normal */
+  if (pACB->glitch_cfg != NS_TO_GLITCH(0))
+    pDCB->CtrlR4 |= NS_TO_GLITCH(((GLITCH_TO_NS(pACB->glitch_cfg)) - 1));
+  else
+    pDCB->CtrlR4 |= NS_TO_GLITCH(0);
+  if (wval1 < 4) pDCB->CtrlR4 |= NS_TO_GLITCH(0); /* Ultra */
+
+  if (wval1 >= 8)
+    {
+      wval1--;	/* Timing computation differs by 1 from FAST_SCSI */
+      bval = FAST_CLK;		/* fast clock / normal scsi */
+      pDCB->CtrlR4 |= pACB->glitch_cfg; 	/* glitch eater */
+    }
+
+  pDCB->CtrlR3 = bval;
+  pDCB->SyncPeriod = (u8)wval1;
+  
+  if ((oldsyncperiod != wval1 || oldsyncoffset != pDCB->SyncOffset) && pDCB->TargetLUN == 0)
+    {
+      if (! (bval & FAST_SCSI)) wval1++;
+      printk (KERN_INFO "DC390: Target %i: Sync transfer %i.%1i MHz, Offset %i\n", pDCB->TargetID, 
+	      40/wval1, ((40%wval1)*10+wval1/2)/wval1, pDCB->SyncOffset & 0x0f);
+    }
+  
+  dc390_reprog (pACB, pDCB);
+}
+
+
+/* handle RESTORE_PTR */
+/* I presume, this command is already mapped, so, have to remap. */
+static void 
+dc390_restore_ptr (struct dc390_acb* pACB, struct dc390_srb* pSRB)
+{
+    struct scsi_cmnd *pcmd = pSRB->pcmd;
+    struct scatterlist *psgl;
     pSRB->TotalXferredLen = 0;
-    pSRB->SGBusAddr = 0;
-    pSRB->SGToBeXferLen = 0;
-    pSRB->ScsiPhase = 0;
-    pSRB->EndMessage = 0;
-    pSRB->TagNumber = 255;
-    /* KG: deferred PCI mapping to dc390_StartSCSI */
+    pSRB->SGIndex = 0;
+    if (pcmd->use_sg) {
+	pSRB->pSegmentList = (struct scatterlist *)pcmd->request_buffer;
+	psgl = pSRB->pSegmentList;
+	//dc390_pci_sync(pSRB);
+
+	while (pSRB->TotalXferredLen + (unsigned long) sg_dma_len(psgl) < pSRB->Saved_Ptr)
+	{
+	    pSRB->TotalXferredLen += (unsigned long) sg_dma_len(psgl);
+	    pSRB->SGIndex++;
+	    if( pSRB->SGIndex < pSRB->SGcount )
+	    {
+		pSRB->pSegmentList++;
+		psgl = pSRB->pSegmentList;
+		pSRB->SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
+		pSRB->SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
+	    }
+	    else
+		pSRB->SGToBeXferLen = 0;
+	}
+	pSRB->SGToBeXferLen -= (pSRB->Saved_Ptr - pSRB->TotalXferredLen);
+	pSRB->SGBusAddr += (pSRB->Saved_Ptr - pSRB->TotalXferredLen);
+	printk (KERN_INFO "DC390: Pointer restored. Segment %i, Total %li, Bus %08lx\n",
+		pSRB->SGIndex, pSRB->Saved_Ptr, pSRB->SGBusAddr);
+
+    } else if(pcmd->request_buffer) {
+	//dc390_pci_sync(pSRB);
+
+	sg_dma_len(&pSRB->Segmentx) = pcmd->request_bufflen - pSRB->Saved_Ptr;
+	pSRB->SGcount = 1;
+	pSRB->pSegmentList = (struct scatterlist *) &pSRB->Segmentx;
+    } else {
+	 pSRB->SGcount = 0;
+	 printk (KERN_INFO "DC390: RESTORE_PTR message for Transfer without Scatter-Gather ??\n");
+    }
+
+  pSRB->TotalXferredLen = pSRB->Saved_Ptr;
 }
 
-/***********************************************************************
- * Function : static int DC390_queue_command (struct scsi_cmnd *cmd,
- *					       void (*done)(struct scsi_cmnd *))
- *
- * Purpose : enqueues a SCSI command
- *
- * Inputs : cmd - SCSI command, done - callback function called on 
- *	    completion, with a pointer to the command descriptor.
- *
- * Returns : (depending on kernel version)
- * 2.0.x: always return 0
- * 2.1.x: old model: (use_new_eh_code == 0): like 2.0.x
- *	  TO BE DONE:
- *	  new model: return 0 if successful, or must not be re-queued
- *		     return 1 if command cannot be queued (queue full)
- *		     command will be inserted in midlevel queue then ...
- *
- ***********************************************************************/
 
-static int DC390_queue_command(struct scsi_cmnd *cmd,
-		void (* done)(struct scsi_cmnd *))
+/* According to the docs, the AM53C974 reads the message and 
+ * generates a Successful Operation IRQ before asserting ACK for
+ * the last byte (how does it know whether it's the last ?) */
+/* The old code handled it in another way, indicating, that on
+ * every message byte an IRQ is generated and every byte has to
+ * be manually ACKed. Hmmm ?  (KG, 98/11/28) */
+/* The old implementation was correct. Sigh! */
+
+/* Check if the message is complete */
+static u8 __inline__
+dc390_MsgIn_complete (u8 *msgbuf, u32 len)
+{ 
+  if (*msgbuf == EXTENDED_MESSAGE)
+  {
+	if (len < 2) return 0;
+	if (len < msgbuf[1] + 2) return 0;
+  }
+  else if (*msgbuf >= 0x20 && *msgbuf <= 0x2f) // two byte messages
+	if (len < 2) return 0;
+  return 1;
+}
+
+
+
+/* read and eval received messages */
+static void
+dc390_MsgIn_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    struct dc390_dcb*   pDCB = pACB->pActiveDCB;
+
+    /* Read the msg */
+
+    pSRB->MsgInBuf[pACB->MsgLen++] = DC390_read8 (ScsiFifo);
+    //pSRB->SRBState = 0;
+
+    /* Msg complete ? */
+    if (dc390_MsgIn_complete (pSRB->MsgInBuf, pACB->MsgLen))
+      {
+	DEBUG0 (printk (KERN_INFO "DC390: MsgIn:"); dc390_printMsg (pSRB->MsgInBuf, pACB->MsgLen));
+	/* Now eval the msg */
+	switch (pSRB->MsgInBuf[0]) 
+	  {
+	  case DISCONNECT: 
+	    pSRB->SRBState = SRB_DISCONNECT; break;
+	    
+	  case SIMPLE_QUEUE_TAG:
+	  case HEAD_OF_QUEUE_TAG:
+	  case ORDERED_QUEUE_TAG:
+	    pSRB = dc390_MsgIn_QTag (pACB, pDCB, pSRB->MsgInBuf[1]);
+	    break;
+	    
+	  case MESSAGE_REJECT: 
+	    DC390_write8 (ScsiCmd, RESET_ATN_CMD);
+	    pDCB->NegoPeriod = 50; /* 200ns <=> 5 MHz */
+	    if( pSRB->SRBState & DO_SYNC_NEGO)
+	      dc390_MsgIn_set_async (pACB, pSRB);
+	    break;
+	    
+	  case EXTENDED_MESSAGE:
+	    /* reject every extended msg but SDTR */
+	    if (pSRB->MsgInBuf[1] != 3 || pSRB->MsgInBuf[2] != EXTENDED_SDTR)
+	      dc390_MsgIn_reject (pACB, pSRB);
+	    else
+	      {
+		if (pSRB->MsgInBuf[3] == 0 || pSRB->MsgInBuf[4] == 0)
+		  dc390_MsgIn_set_async (pACB, pSRB);
+		else
+		  dc390_MsgIn_set_sync (pACB, pSRB);
+	      }
+	    
+	    // nothing has to be done
+	  case COMMAND_COMPLETE: break;
+	    
+	    // SAVE POINTER may be ignored as we have the struct dc390_srb* associated with the
+	    // scsi command. Thanks, Gerard, for pointing it out.
+	  case SAVE_POINTERS: 
+	    pSRB->Saved_Ptr = pSRB->TotalXferredLen;
+	    break;
+	    // The device might want to restart transfer with a RESTORE
+	  case RESTORE_POINTERS:
+	    DEBUG0(printk ("DC390: RESTORE POINTER message received ... try to handle\n"));
+	    dc390_restore_ptr (pACB, pSRB);
+	    break;
+
+	    // reject unknown messages
+	  default: dc390_MsgIn_reject (pACB, pSRB);
+	  }
+	
+	/* Clear counter and MsgIn state */
+	pSRB->SRBState &= ~SRB_MSGIN;
+	pACB->MsgLen = 0;
+      }
+
+    *psstatus = SCSI_NOP0;
+    DC390_write8 (ScsiCmd, MSG_ACCEPTED_CMD);
+    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
+}
+
+
+static void
+dc390_DataIO_Comm( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 ioDir)
 {
-    struct dc390_dcb*   pDCB = (struct dc390_dcb*) cmd->device->hostdata;
+    struct scatterlist *psgl;
+    unsigned long  lval;
+    struct dc390_dcb*   pDCB = pACB->pActiveDCB;
+
+    if (pSRB == pACB->pTmpSRB)
+    {
+	if (pDCB)
+		printk(KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (%02i-%i)\n", pDCB->TargetID, pDCB->TargetLUN);
+	else
+		printk(KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (DCB 0!)\n");
+
+	/* Try to recover - some broken disks react badly to tagged INQUIRY */
+	if (pDCB && pACB->scan_devices && pDCB->GoingSRBCnt == 1) {
+		pSRB = pDCB->pGoingSRB;
+		pDCB->pActiveSRB = pSRB;
+	} else {
+		pSRB->pSRBDCB = pDCB;
+		dc390_EnableMsgOut_Abort(pACB, pSRB);
+		if (pDCB)
+			pDCB->DCBFlag |= ABORT_DEV;
+		return;
+	}
+    }
+
+    if( pSRB->SGIndex < pSRB->SGcount )
+    {
+	DC390_write8 (DMA_Cmd, DMA_IDLE_CMD | ioDir /* | DMA_INT */);
+	if( !pSRB->SGToBeXferLen )
+	{
+	    psgl = pSRB->pSegmentList;
+	    pSRB->SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
+	    pSRB->SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
+	    DEBUG1(printk (KERN_DEBUG " DC390: Next SG segment."));
+	}
+	lval = pSRB->SGToBeXferLen;
+	DEBUG1(printk (KERN_DEBUG " DC390: Start transfer: %li bytes (address %08lx)\n", lval, pSRB->SGBusAddr));
+	DC390_write8 (CtcReg_Low, (u8) lval);
+	lval >>= 8;
+	DC390_write8 (CtcReg_Mid, (u8) lval);
+	lval >>= 8;
+	DC390_write8 (CtcReg_High, (u8) lval);
+
+	DC390_write32 (DMA_XferCnt, pSRB->SGToBeXferLen);
+	DC390_write32 (DMA_XferAddr, pSRB->SGBusAddr);
+
+	//DC390_write8 (DMA_Cmd, DMA_IDLE_CMD | ioDir); /* | DMA_INT; */
+	pSRB->SRBState = SRB_DATA_XFER;
+
+	DC390_write8 (ScsiCmd, DMA_COMMAND+INFO_XFER_CMD);
+
+	DC390_write8 (DMA_Cmd, DMA_START_CMD | ioDir | DMA_INT);
+	//DEBUG1(DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | EN_INT_ON_PCI_ABORT));
+	//DEBUG1(printk (KERN_DEBUG "DC390: DMA_Status: %02x\n", DC390_read8 (DMA_Status)));
+	//DEBUG1(DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT));
+    }
+    else    /* xfer pad */
+    {
+	if( pSRB->SGcount )
+	{
+	    pSRB->AdaptStatus = H_OVER_UNDER_RUN;
+	    pSRB->SRBStatus |= OVER_RUN;
+	    DEBUG0(printk (KERN_WARNING " DC390: Overrun -"));
+	}
+	DEBUG0(printk (KERN_WARNING " Clear transfer pad \n"));
+	DC390_write8 (CtcReg_Low, 0);
+	DC390_write8 (CtcReg_Mid, 0);
+	DC390_write8 (CtcReg_High, 0);
+
+	pSRB->SRBState |= SRB_XFERPAD;
+	DC390_write8 (ScsiCmd, DMA_COMMAND+XFER_PAD_BYTE);
+/*
+	DC390_write8 (DMA_Cmd, DMA_IDLE_CMD | ioDir); // | DMA_INT;
+	DC390_write8 (DMA_Cmd, DMA_START_CMD | ioDir | DMA_INT);
+*/
+    }
+}
+
+
+static void
+dc390_DataOutPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    dc390_DataIO_Comm (pACB, pSRB, WRITE_DIRECTION);
+}
+
+static void
+dc390_DataInPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    dc390_DataIO_Comm (pACB, pSRB, READ_DIRECTION);
+}
+
+static void
+dc390_CommandPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    struct dc390_dcb*   pDCB;
+    u8  i, cnt;
+    u8     *ptr;
+
+    DC390_write8 (ScsiCmd, RESET_ATN_CMD);
+    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+    if( !(pSRB->SRBFlag & AUTO_REQSENSE) )
+    {
+	cnt = (u8) pSRB->pcmd->cmd_len;
+	ptr = (u8 *) pSRB->pcmd->cmnd;
+	for(i=0; i < cnt; i++)
+	    DC390_write8 (ScsiFifo, *(ptr++));
+    }
+    else
+    {
+	DC390_write8 (ScsiFifo, REQUEST_SENSE);
+	pDCB = pACB->pActiveDCB;
+	DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5);
+	DC390_write8 (ScsiFifo, 0);
+	DC390_write8 (ScsiFifo, 0);
+	DC390_write8 (ScsiFifo, sizeof(pSRB->pcmd->sense_buffer));
+	DC390_write8 (ScsiFifo, 0);
+	DEBUG0(printk(KERN_DEBUG "DC390: AutoReqSense (CmndPhase)!\n"));
+    }
+    pSRB->SRBState = SRB_COMMAND;
+    DC390_write8 (ScsiCmd, INFO_XFER_CMD);
+}
+
+static void
+dc390_StatusPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+    pSRB->SRBState = SRB_STATUS;
+    DC390_write8 (ScsiCmd, INITIATOR_CMD_CMPLTE);
+    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
+}
+
+static void
+dc390_MsgOutPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    u8   bval, i, cnt;
+    u8     *ptr;
+    struct dc390_dcb*    pDCB;
+
+    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+    pDCB = pACB->pActiveDCB;
+    if( !(pSRB->SRBState & SRB_MSGOUT) )
+    {
+	cnt = pSRB->MsgCnt;
+	if( cnt )
+	{
+	    ptr = (u8 *) pSRB->MsgOutBuf;
+	    for(i=0; i < cnt; i++)
+		DC390_write8 (ScsiFifo, *(ptr++));
+	    pSRB->MsgCnt = 0;
+	    if( (pDCB->DCBFlag & ABORT_DEV_) &&
+		(pSRB->MsgOutBuf[0] == ABORT) )
+		pSRB->SRBState = SRB_ABORT_SENT;
+	}
+	else
+	{
+	    bval = ABORT;	/* ??? MSG_NOP */
+	    if( (pSRB->pcmd->cmnd[0] == INQUIRY ) ||
+		(pSRB->pcmd->cmnd[0] == REQUEST_SENSE) ||
+		(pSRB->SRBFlag & AUTO_REQSENSE) )
+	    {
+		if( pDCB->SyncMode & SYNC_ENABLE )
+		    goto  mop1;
+	    }
+	    DC390_write8 (ScsiFifo, bval);
+	}
+	DC390_write8 (ScsiCmd, INFO_XFER_CMD);
+    }
+    else
+    {
+mop1:
+        printk (KERN_ERR "DC390: OLD Sync Nego code triggered! (%i %i)\n", pDCB->TargetID, pDCB->TargetLUN);
+	DC390_write8 (ScsiFifo, EXTENDED_MESSAGE);
+	DC390_write8 (ScsiFifo, 3);	/*    ;length of extended msg */
+	DC390_write8 (ScsiFifo, EXTENDED_SDTR);	/*    ; sync nego */
+	DC390_write8 (ScsiFifo, pDCB->NegoPeriod);
+	if (pDCB->SyncOffset & 0x0f)
+		    DC390_write8 (ScsiFifo, pDCB->SyncOffset);
+	else
+		    DC390_write8 (ScsiFifo, SYNC_NEGO_OFFSET);		    
+	pSRB->SRBState |= DO_SYNC_NEGO;
+	DC390_write8 (ScsiCmd, INFO_XFER_CMD);
+    }
+}
+
+static void
+dc390_MsgInPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+    if( !(pSRB->SRBState & SRB_MSGIN) )
+    {
+	pSRB->SRBState &= ~SRB_DISCONNECT;
+	pSRB->SRBState |= SRB_MSGIN;
+    }
+    DC390_write8 (ScsiCmd, INFO_XFER_CMD);
+    //DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
+}
+
+static void
+dc390_Nop_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+}
+
+static void
+dc390_Nop_1( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+{
+}
+
+
+static void
+dc390_SetXferRate( struct dc390_acb* pACB, struct dc390_dcb* pDCB )
+{
+    u8  bval, i, cnt;
+    struct dc390_dcb*   ptr;
+
+    if( !(pDCB->TargetLUN) )
+    {
+	if( !pACB->scan_devices )
+	{
+	    ptr = pACB->pLinkDCB;
+	    cnt = pACB->DCBCnt;
+	    bval = pDCB->TargetID;
+	    for(i=0; i<cnt; i++)
+	    {
+		if( ptr->TargetID == bval )
+		{
+		    ptr->SyncPeriod = pDCB->SyncPeriod;
+		    ptr->SyncOffset = pDCB->SyncOffset;
+		    ptr->CtrlR3 = pDCB->CtrlR3;
+		    ptr->CtrlR4 = pDCB->CtrlR4;
+		    ptr->SyncMode = pDCB->SyncMode;
+		}
+		ptr = ptr->pNextDCB;
+	    }
+	}
+    }
+    return;
+}
+
+
+static void
+dc390_Disconnect( struct dc390_acb* pACB )
+{
+    struct dc390_dcb *pDCB;
+    struct dc390_srb *pSRB, *psrb;
+    u8  i, cnt;
+
+    DEBUG0(printk(KERN_INFO "DISC,"));
+
+    if (!pACB->Connected) printk(KERN_ERR "DC390: Disconnect not-connected bus?\n");
+    pACB->Connected = 0;
+    pDCB = pACB->pActiveDCB;
+    if (!pDCB)
+     {
+	DEBUG0(printk(KERN_ERR "ACB:%p->ActiveDCB:%p IOPort:%04x IRQ:%02x !\n",\
+	       pACB, pDCB, pACB->IOPortBase, pACB->IRQLevel));
+	mdelay(400);
+	DC390_read8 (INT_Status);	/* Reset Pending INT */
+	DC390_write8 (ScsiCmd, EN_SEL_RESEL);
+	return;
+     }
+    DC390_write8 (ScsiCmd, EN_SEL_RESEL);
+    pSRB = pDCB->pActiveSRB;
+    pACB->pActiveDCB = NULL;
+    pSRB->ScsiPhase = SCSI_NOP0;
+    if( pSRB->SRBState & SRB_UNEXPECT_RESEL )
+	pSRB->SRBState = 0;
+    else if( pSRB->SRBState & SRB_ABORT_SENT )
+    {
+	pDCB->TagMask = 0;
+	pDCB->DCBFlag = 0;
+	cnt = pDCB->GoingSRBCnt;
+	pDCB->GoingSRBCnt = 0;
+	pSRB = pDCB->pGoingSRB;
+	for( i=0; i < cnt; i++)
+	{
+	    psrb = pSRB->pNextSRB;
+	    dc390_Free_insert (pACB, pSRB);
+	    pSRB = psrb;
+	}
+	pDCB->pGoingSRB = NULL;
+    }
+    else
+    {
+	if( (pSRB->SRBState & (SRB_START_+SRB_MSGOUT)) ||
+	   !(pSRB->SRBState & (SRB_DISCONNECT+SRB_COMPLETED)) )
+	{	/* Selection time out */
+		pSRB->TargetStatus = SCSI_STAT_SEL_TIMEOUT;
+		goto  disc1;
+	}
+	else if (!(pSRB->SRBState & SRB_DISCONNECT) && (pSRB->SRBState & SRB_COMPLETED))
+	{
+disc1:
+	    dc390_freetag (pDCB, pSRB);
+	    pDCB->pActiveSRB = NULL;
+	    pSRB->SRBState = SRB_FREE;
+	    dc390_SRBdone( pACB, pDCB, pSRB);
+	}
+    }
+    pACB->MsgLen = 0;
+}
+
+
+static void
+dc390_Reselect( struct dc390_acb* pACB )
+{
+    struct dc390_dcb*   pDCB;
     struct dc390_srb*   pSRB;
-    struct dc390_acb*   pACB = (struct dc390_acb*) cmd->device->host->hostdata;
+    u8  id, lun;
+
+    DEBUG0(printk(KERN_INFO "RSEL,"));
+    pACB->Connected = 1;
+    pDCB = pACB->pActiveDCB;
+    if( pDCB )
+    {	/* Arbitration lost but Reselection won */
+	DEBUG0(printk ("DC390: (ActiveDCB != 0: Arb. lost but resel. won)!\n"));
+	pSRB = pDCB->pActiveSRB;
+	if( !( pACB->scan_devices ) )
+	{
+	    struct scsi_cmnd *pcmd = pSRB->pcmd;
+	    pcmd->resid = pcmd->request_bufflen;
+	    SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
+	    dc390_Going_remove(pDCB, pSRB);
+	    dc390_Free_insert(pACB, pSRB);
+	    pcmd->scsi_done (pcmd);
+	    DEBUG0(printk(KERN_DEBUG"DC390: Return SRB %p to free\n", pSRB));
+	}
+    }
+    /* Get ID */
+    lun = DC390_read8 (ScsiFifo);
+    DEBUG0(printk ("Dev %02x,", lun));
+    if (!(lun & (1 << pACB->pScsiHost->this_id)))
+      printk (KERN_ERR "DC390: Reselection must select host adapter: %02x!\n", lun);
+    else
+      lun ^= 1 << pACB->pScsiHost->this_id; /* Mask AdapterID */
+    id = 0; while (lun >>= 1) id++;
+    /* Get LUN */
+    lun = DC390_read8 (ScsiFifo);
+    if (!(lun & IDENTIFY_BASE)) printk (KERN_ERR "DC390: Resel: Expect identify message!\n");
+    lun &= 7;
+    DEBUG0(printk ("(%02i-%i),", id, lun));
+    pDCB = dc390_findDCB (pACB, id, lun);
+    if (!pDCB)
+    {
+	printk (KERN_ERR "DC390: Reselect from non existing device (%02i-%i)\n",
+		    id, lun);
+	return;
+    }
+    pACB->pActiveDCB = pDCB;
+    /* TagQ: We expect a message soon, so never mind the exact SRB */
+    if( pDCB->SyncMode & EN_TAG_QUEUEING )
+    {
+	pSRB = pACB->pTmpSRB;
+	pDCB->pActiveSRB = pSRB;
+    }
+    else
+    {
+	pSRB = pDCB->pActiveSRB;
+	if( !pSRB || !(pSRB->SRBState & SRB_DISCONNECT) )
+	{
+	    pSRB= pACB->pTmpSRB;
+	    pSRB->SRBState = SRB_UNEXPECT_RESEL;
+	    printk (KERN_ERR "DC390: Reselect without outstanding cmnd (%02i-%i)\n",
+		    id, lun);
+	    pDCB->pActiveSRB = pSRB;
+	    dc390_EnableMsgOut_Abort ( pACB, pSRB );
+	}
+	else
+	{
+	    if( pDCB->DCBFlag & ABORT_DEV_ )
+	    {
+		pSRB->SRBState = SRB_ABORT_SENT;
+		printk (KERN_INFO "DC390: Reselect: Abort (%02i-%i)\n",
+			id, lun);
+		dc390_EnableMsgOut_Abort( pACB, pSRB );
+	    }
+	    else
+		pSRB->SRBState = SRB_DATA_XFER;
+	}
+    }
+
+    DEBUG1(printk (KERN_DEBUG "Resel SRB(%p): TagNum (%02x)\n", pSRB, pSRB->TagNumber));
+    pSRB->ScsiPhase = SCSI_NOP0;
+    DC390_write8 (Scsi_Dest_ID, pDCB->TargetID);
+    DC390_write8 (Sync_Period, pDCB->SyncPeriod);
+    DC390_write8 (Sync_Offset, pDCB->SyncOffset);
+    DC390_write8 (CtrlReg1, pDCB->CtrlR1);
+    DC390_write8 (CtrlReg3, pDCB->CtrlR3);
+    DC390_write8 (CtrlReg4, pDCB->CtrlR4);	/* ; Glitch eater */
+    DC390_write8 (ScsiCmd, MSG_ACCEPTED_CMD);	/* ;to release the /ACK signal */
+}
+
+static int __inline__
+dc390_RequestSense(struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
+{
+	struct scsi_cmnd *pcmd;
+
+	pcmd = pSRB->pcmd;
+
+	REMOVABLEDEBUG(printk(KERN_INFO "DC390: RequestSense(Cmd %02x, Id %02x, LUN %02x)\n",\
+			      pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN));
+
+	pSRB->SRBFlag |= AUTO_REQSENSE;
+	pSRB->SavedSGCount = pcmd->use_sg;
+	pSRB->SavedTotXLen = pSRB->TotalXferredLen;
+	pSRB->AdaptStatus = 0;
+	pSRB->TargetStatus = 0; /* CHECK_CONDITION<<1; */
+
+	/* We are called from SRBdone, original PCI mapping has been removed
+	 * already, new one is set up from StartSCSI */
+	pSRB->SGIndex = 0;
+
+	pSRB->TotalXferredLen = 0;
+	pSRB->SGToBeXferLen = 0;
+	return dc390_StartSCSI(pACB, pDCB, pSRB);
+}
+
+
+static void
+dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB )
+{
+    u8 status;
+    struct scsi_cmnd *pcmd;
+
+    pcmd = pSRB->pcmd;
+    /* KG: Moved pci_unmap here */
+    dc390_pci_unmap(pSRB);
+
+    status = pSRB->TargetStatus;
+
+    DEBUG0(printk (" SRBdone (%02x,%08x), SRB %p, pid %li\n", status, pcmd->result,\
+		pSRB, pcmd->pid));
+    if(pSRB->SRBFlag & AUTO_REQSENSE)
+    {	/* Last command was a Request Sense */
+	pSRB->SRBFlag &= ~AUTO_REQSENSE;
+	pSRB->AdaptStatus = 0;
+	pSRB->TargetStatus = CHECK_CONDITION << 1;
+
+	//pcmd->result = MK_RES(DRIVER_SENSE,DID_OK,0,status);
+	if (status == (CHECK_CONDITION << 1))
+	    pcmd->result = MK_RES_LNX(0, DID_BAD_TARGET, 0, /*CHECK_CONDITION*/0);
+	else /* Retry */
+	{
+	    if( pSRB->pcmd->cmnd[0] == TEST_UNIT_READY /* || pSRB->pcmd->cmnd[0] == START_STOP */)
+	    {
+		/* Don't retry on TEST_UNIT_READY */
+		pcmd->result = MK_RES_LNX(DRIVER_SENSE,DID_OK,0,CHECK_CONDITION);
+		REMOVABLEDEBUG(printk(KERN_INFO "Cmd=%02x, Result=%08x, XferL=%08x\n",pSRB->pcmd->cmnd[0],\
+		       (u32) pcmd->result, (u32) pSRB->TotalXferredLen));
+	    } else {
+		SET_RES_DRV(pcmd->result, DRIVER_SENSE);
+		pcmd->use_sg = pSRB->SavedSGCount;
+		//pSRB->ScsiCmdLen	 = (u8) (pSRB->Segment1[0] >> 8);
+		DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
+		pSRB->TotalXferredLen = 0;
+		SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
+	    }
+	}
+	goto cmd_done;
+    }
+    if( status )
+    {
+	if( status_byte(status) == CHECK_CONDITION )
+	{
+	    if (dc390_RequestSense(pACB, pDCB, pSRB)) {
+		SET_RES_DID(pcmd->result, DID_ERROR);
+		goto cmd_done;
+	    }
+	    return;
+	}
+	else if( status_byte(status) == QUEUE_FULL )
+	{
+	    scsi_track_queue_full(pcmd->device, pDCB->GoingSRBCnt - 1);
+	    pcmd->use_sg = pSRB->SavedSGCount;
+	    DEBUG0 (printk ("DC390: RETRY pid %li (%02x), target %02i-%02i\n", pcmd->pid, pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
+	    pSRB->TotalXferredLen = 0;
+	    SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
+	}
+	else if(status == SCSI_STAT_SEL_TIMEOUT)
+	{
+	    pSRB->AdaptStatus = H_SEL_TIMEOUT;
+	    pSRB->TargetStatus = 0;
+	    pcmd->result = MK_RES(0,DID_NO_CONNECT,0,0);
+	    /* Devices are removed below ... */
+	}
+	else if (status_byte(status) == BUSY && 
+		 (pcmd->cmnd[0] == TEST_UNIT_READY || pcmd->cmnd[0] == INQUIRY) &&
+		 pACB->scan_devices)
+	{
+	    pSRB->AdaptStatus = 0;
+	    pSRB->TargetStatus = status;
+	    pcmd->result = MK_RES(0,0,pSRB->EndMessage,/*status*/0);
+	}
+	else
+	{   /* Another error */
+	    pSRB->TotalXferredLen = 0;
+	    SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
+	    goto cmd_done;
+	}
+    }
+    else
+    {	/*  Target status == 0 */
+	status = pSRB->AdaptStatus;
+	if(status & H_OVER_UNDER_RUN)
+	{
+	    pSRB->TargetStatus = 0;
+	    SET_RES_DID(pcmd->result,DID_OK);
+	    SET_RES_MSG(pcmd->result,pSRB->EndMessage);
+	}
+	else if( pSRB->SRBStatus & PARITY_ERROR)
+	{
+	    //pcmd->result = MK_RES(0,DID_PARITY,pSRB->EndMessage,0);
+	    SET_RES_DID(pcmd->result,DID_PARITY);
+	    SET_RES_MSG(pcmd->result,pSRB->EndMessage);
+	}
+	else		       /* No error */
+	{
+	    pSRB->AdaptStatus = 0;
+	    pSRB->TargetStatus = 0;
+	    SET_RES_DID(pcmd->result,DID_OK);
+	}
+    }
+
+cmd_done:
+    pcmd->resid = pcmd->request_bufflen - pSRB->TotalXferredLen;
+
+    dc390_Going_remove (pDCB, pSRB);
+    /* Add to free list */
+    dc390_Free_insert (pACB, pSRB);
+
+    DEBUG0(printk (KERN_DEBUG "DC390: SRBdone: done pid %li\n", pcmd->pid));
+    pcmd->scsi_done (pcmd);
+
+    return;
+}
+
+
+/* Remove all SRBs from Going list and inform midlevel */
+static void
+dc390_DoingSRB_Done(struct dc390_acb* pACB, struct scsi_cmnd *cmd)
+{
+    struct dc390_dcb *pDCB, *pdcb;
+    struct dc390_srb *psrb, *psrb2;
+    int i;
+    struct scsi_cmnd *pcmd;
+
+    pDCB = pACB->pLinkDCB;
+    pdcb = pDCB;
+    if (! pdcb) return;
+    do
+    {
+	psrb = pdcb->pGoingSRB;
+	for (i = 0; i < pdcb->GoingSRBCnt; i++)
+	{
+	    psrb2 = psrb->pNextSRB;
+	    pcmd = psrb->pcmd;
+	    dc390_Free_insert (pACB, psrb);
+	    psrb  = psrb2;
+	}
+	pdcb->GoingSRBCnt = 0;
+	pdcb->pGoingSRB = NULL;
+	pdcb->TagMask = 0;
+	pdcb = pdcb->pNextDCB;
+    } while( pdcb != pDCB );
+}
+
+
+static void
+dc390_ResetSCSIBus( struct dc390_acb* pACB )
+{
+    //DC390_write8 (ScsiCmd, RST_DEVICE_CMD);
+    //udelay (250);
+    //DC390_write8 (ScsiCmd, NOP_CMD);
+
+    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+    DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
+    DC390_write8 (ScsiCmd, RST_SCSI_BUS_CMD);
+    pACB->Connected = 0;
+
+    return;
+}
+
+static void
+dc390_ScsiRstDetect( struct dc390_acb* pACB )
+{
+    printk ("DC390: Rst_Detect: laststat = %08x\n", dc390_laststatus);
+    //DEBUG0(printk(KERN_INFO "RST_DETECT,"));
+
+    DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
+    /* Unlock before ? */
+    /* delay half a second */
+    udelay (1000);
+    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
+    pACB->pScsiHost->last_reset = jiffies + 5*HZ/2
+		    + HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY];
+    pACB->Connected = 0;
+
+    if( pACB->ACBFlag & RESET_DEV )
+	pACB->ACBFlag |= RESET_DONE;
+    else
+    {   /* Reset was issued by sb else */
+	pACB->ACBFlag |= RESET_DETECT;
+
+	dc390_ResetDevParam( pACB );
+	dc390_DoingSRB_Done( pACB, NULL);
+	//dc390_RecoverSRB( pACB );
+	pACB->pActiveDCB = NULL;
+	pACB->ACBFlag = 0;
+    }
+    return;
+}
+
+static int DC390_queuecommand(struct scsi_cmnd *cmd,
+		void (*done)(struct scsi_cmnd *))
+{
+	struct scsi_device *sdev = cmd->device;
+	struct dc390_acb *acb = (struct dc390_acb *)sdev->host->hostdata;
+	struct dc390_dcb *dcb = sdev->hostdata;
+	struct dc390_srb *srb;
+
+	if (sdev->queue_depth <= dcb->GoingSRBCnt)
+		goto device_busy;
+	if (acb->pActiveDCB)
+		goto host_busy;
+	if (acb->ACBFlag & (RESET_DETECT|RESET_DONE|RESET_DEV))
+		goto host_busy;
+
+	srb = acb->pFreeSRB;
+	if (unlikely(srb == NULL))
+		goto host_busy;
+
+	cmd->scsi_done = done;
+	cmd->result = 0;
+	acb->Cmds++;
+
+	acb->pFreeSRB = srb->pNextSRB;
+	srb->pNextSRB = NULL;
+
+	srb->pSRBDCB = dcb;
+	srb->pcmd = cmd;
+	cmd->host_scribble = (char *)srb;
+    
+	srb->SGIndex = 0;
+	srb->AdaptStatus = 0;
+	srb->TargetStatus = 0;
+	srb->MsgCnt = 0;
+
+	srb->SRBStatus = 0;
+	srb->SRBFlag = 0;
+	srb->SRBState = 0;
+	srb->TotalXferredLen = 0;
+	srb->SGBusAddr = 0;
+	srb->SGToBeXferLen = 0;
+	srb->ScsiPhase = 0;
+	srb->EndMessage = 0;
+	srb->TagNumber = SCSI_NO_TAG;
+
+	if (dc390_StartSCSI(acb, dcb, srb)) {
+		dc390_Free_insert(acb, srb);
+		goto host_busy;
+	}
+
+	dc390_Going_append(dcb, srb);
 
-    pACB->Cmds++;
-    cmd->scsi_done = done;
-    cmd->result = 0;
-
-    pSRB = dc390_Free_get(pACB);
-    if (!pSRB)
-	    goto requeue;
-
-    dc390_BuildSRB(cmd, pDCB, pSRB);
-    if (pDCB->pWaitingSRB) {
-	    dc390_Waiting_append(pDCB, pSRB);
-	    dc390_Waiting_process(pACB);
-    } else
-	    dc390_SendSRB(pACB, pSRB);
+	return 0;
 
-    DEBUG1(printk (KERN_DEBUG " ... command (pid %li) queued successfully.\n", cmd->pid));
-    return(0);
+ host_busy:
+	return SCSI_MLQUEUE_HOST_BUSY;
 
- requeue:
-    return 1;
+ device_busy:
+	return SCSI_MLQUEUE_DEVICE_BUSY;
 }
 
 static void dc390_dumpinfo (struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
@@ -1049,45 +2076,14 @@
 {
 	struct dc390_acb *pACB = (struct dc390_acb*) cmd->device->host->hostdata;
 	struct dc390_dcb *pDCB = (struct dc390_dcb*) cmd->device->hostdata;
-	struct dc390_srb *pSRB, *psrb;
 
 	printk("DC390: Abort command (pid %li, Device %02i-%02i)\n",
 	       cmd->pid, cmd->device->id, cmd->device->lun);
 
-	pSRB = pDCB->pWaitingSRB;
-	if (!pSRB)
-		goto on_going;
-
-	/* Now scan Waiting queue */
-	if (pSRB->pcmd != cmd) {
-		psrb = pSRB;
-		if (!(psrb->pNextSRB))
-			goto on_going;
-
-		while (psrb->pNextSRB->pcmd != cmd) {
-			psrb = psrb->pNextSRB;
-			if (!(psrb->pNextSRB) || psrb == pSRB)
-				goto on_going;
-		}
-
-		pSRB = psrb->pNextSRB;
-		psrb->pNextSRB = pSRB->pNextSRB;
-		if (pSRB == pDCB->pWaitLast)
-			pDCB->pWaitLast = psrb;
-	} else
-		pDCB->pWaitingSRB = pSRB->pNextSRB;
-
-	dc390_Free_insert(pACB, pSRB);
-	pDCB->WaitSRBCnt--;
-	INIT_LIST_HEAD((struct list_head*)&cmd->SCp);
-
-	return SUCCESS;
-
-on_going:
 	/* abort() is too stupid for already sent commands at the moment. 
 	 * If it's called we are in trouble anyway, so let's dump some info 
 	 * into the syslog at least. (KG, 98/08/20,99/06/20) */
-	dc390_dumpinfo(pACB, pDCB, pSRB);
+	dc390_dumpinfo(pACB, pDCB, NULL);
 
 	pDCB->DCBFlag |= ABORT_DEV_;
 	printk(KERN_INFO "DC390: Aborted pid %li\n", cmd->pid);
@@ -1124,8 +2120,6 @@
 	struct dc390_acb*    pACB = (struct dc390_acb*) cmd->device->host->hostdata;
 	u8   bval;
 
-	del_timer (&pACB->Waiting_Timer);
-
 	bval = DC390_read8(CtrlReg1) | DIS_INT_ON_SCSI_RST;
 	DC390_write8(CtrlReg1, bval);	/* disable IRQ on bus reset */
 
@@ -1148,231 +2142,9 @@
 	bval = DC390_read8(CtrlReg1) & ~DIS_INT_ON_SCSI_RST;
 	DC390_write8(CtrlReg1, bval);	/* re-enable interrupt */
 
-	dc390_Waiting_process(pACB);
-
 	return SUCCESS;
 }
 
-#include "scsiiom.c"
-
-/***********************************************************************
- * Function : static void dc390_updateDCB()
- *
- * Purpose :  Set the configuration dependent DCB parameters
- ***********************************************************************/
-
-static void dc390_updateDCB (struct dc390_acb* pACB, struct dc390_dcb* pDCB)
-{
-  pDCB->SyncMode &= EN_TAG_QUEUEING | SYNC_NEGO_DONE /*| EN_ATN_STOP*/;
-  if (pDCB->DevMode & TAG_QUEUEING_) {
-	//if (pDCB->SyncMode & EN_TAG_QUEUEING) pDCB->MaxCommand = pACB->TagMaxNum;
-  } else {
-	pDCB->SyncMode &= ~EN_TAG_QUEUEING;
-	pDCB->MaxCommand = 1;
-  }
-
-  if( pDCB->DevMode & SYNC_NEGO_ )
-	pDCB->SyncMode |= SYNC_ENABLE;
-  else {
-	pDCB->SyncMode &= ~(SYNC_NEGO_DONE | SYNC_ENABLE);
-	pDCB->SyncOffset &= ~0x0f;
-  }
-
-  //if (! (pDCB->DevMode & EN_DISCONNECT_)) pDCB->SyncMode &= ~EN_ATN_STOP; 
-
-  pDCB->CtrlR1 = pACB->pScsiHost->this_id;
-  if( pDCB->DevMode & PARITY_CHK_ )
-	pDCB->CtrlR1 |= PARITY_ERR_REPO;
-}  
-
-/***********************************************************************
- * Function : static void dc390_initSRB()
- *
- * Purpose :  initialize the internal structures for a given SRB
- *
- * Inputs : psrb - pointer to this scsi request block structure
- ***********************************************************************/
-
-static void __inline__ dc390_initSRB( struct dc390_srb* psrb )
-{
-  /* psrb->PhysSRB = virt_to_phys( psrb ); */
-}
-
-
-static void dc390_linkSRB( struct dc390_acb* pACB )
-{
-    u32   count, i;
-
-    count = pACB->SRBCount;
-    for( i=0; i<count; i++)
-    {
-	if( i != count-1 )
-	    pACB->SRB_array[i].pNextSRB = &pACB->SRB_array[i+1];
-	else
-	    pACB->SRB_array[i].pNextSRB = NULL;
-	dc390_initSRB( &pACB->SRB_array[i] );
-    }
-}
-
-
-/***********************************************************************
- * Function : static void dc390_initACB ()
- *
- * Purpose :  initialize the internal structures for a given SCSI host
- *
- * Inputs : psh - pointer to this host adapter's structure
- *	    io_port, Irq, index: Resources and adapter index
- ***********************************************************************/
-
-static void __devinit dc390_initACB (struct Scsi_Host *psh, unsigned long io_port, u8 Irq, u8 index)
-{
-    struct dc390_acb*    pACB;
-
-    psh->can_queue = MAX_CMD_QUEUE;
-    psh->cmd_per_lun = MAX_CMD_PER_LUN;
-    psh->this_id = (int) dc390_eepromBuf[index][EE_ADAPT_SCSI_ID];
-    psh->io_port = io_port;
-    psh->n_io_port = 0x80;
-    psh->irq = Irq;
-    psh->base = io_port;
-    psh->unique_id = io_port;
-    psh->dma_channel = -1;
-    psh->last_reset = jiffies;
-	
-    pACB = (struct dc390_acb*) psh->hostdata;
-
-    pACB->pScsiHost = psh;
-    pACB->IOPortBase = (u16) io_port;
-    pACB->IRQLevel = Irq;
-
-    DEBUG0(printk (KERN_INFO "DC390: Adapter index %i, ID %i, IO 0x%08x, IRQ 0x%02x\n",	\
-		   index, psh->this_id, (int)io_port, Irq));
-   
-    psh->max_id = 8;
-
-    if( psh->max_id - 1 == dc390_eepromBuf[index][EE_ADAPT_SCSI_ID] )
-	psh->max_id--;
-    psh->max_lun = 1;
-    if( dc390_eepromBuf[index][EE_MODE2] & LUN_CHECK )
-	psh->max_lun = 8;
-
-    pACB->pLinkDCB = NULL;
-    pACB->pDCBRunRobin = NULL;
-    pACB->pActiveDCB = NULL;
-    pACB->pFreeSRB = pACB->SRB_array;
-    pACB->SRBCount = MAX_SRB_CNT;
-    pACB->AdapterIndex = index;
-    pACB->status = 0;
-    pACB->DCBCnt = 0;
-    pACB->TagMaxNum = 2 << dc390_eepromBuf[index][EE_TAG_CMD_NUM];
-    pACB->ACBFlag = 0;
-    pACB->scan_devices = 1;
-    pACB->MsgLen = 0;
-    pACB->Ignore_IRQ = 0;
-    pACB->Gmode2 = dc390_eepromBuf[index][EE_MODE2];
-    dc390_linkSRB( pACB );
-    pACB->pTmpSRB = &pACB->TmpSRB;
-    dc390_initSRB( pACB->pTmpSRB );
-    pACB->sel_timeout = SEL_TIMEOUT;
-    pACB->glitch_cfg = EATER_25NS;
-    pACB->Cmds = pACB->CmdInQ = pACB->CmdOutOfSRB = 0;
-    pACB->SelLost = pACB->SelConn = 0;
-    init_timer (&pACB->Waiting_Timer);
-}
-
-
-/***********************************************************************
- * Function : static int dc390_initAdapter ()
- *
- * Purpose :  initialize the SCSI chip ctrl registers
- *
- * Inputs : psh - pointer to this host adapter's structure
- *	    io_port, Irq, index: Resources
- *
- * Outputs: 0 on success, -1 on error
- ***********************************************************************/
-
-static int __devinit dc390_initAdapter (struct Scsi_Host *psh, unsigned long io_port, u8 Irq, u8 index)
-{
-    struct dc390_acb *pACB, *pACB2;
-    u8  dstate;
-    int    i;
-    
-    pACB = (struct dc390_acb*) psh->hostdata;
-
-    if (request_region (io_port, psh->n_io_port, "tmscsim") == NULL) {
-	printk(KERN_ERR "DC390: register IO ports error!\n");
-	return( -1 );
-    }
-
-    DC390_read8_ (INT_Status, io_port);		/* Reset Pending INT */
-
-    if( (i = request_irq(Irq, do_DC390_Interrupt, DC390_IRQ, "tmscsim", pACB) ))
-      {
-	printk(KERN_ERR "DC390: register IRQ error!\n");
-	release_region (io_port, psh->n_io_port);
-	return( -1 );
-      }
-
-    if( !dc390_pACB_start )
-      {
-	pACB2 = NULL;
-	dc390_pACB_start = pACB;
-	dc390_pACB_current = pACB;
-	pACB->pNextACB = NULL;
-      }
-    else
-      {
-	pACB2 = dc390_pACB_current;
-	dc390_pACB_current->pNextACB = pACB;
-	dc390_pACB_current = pACB;
-	pACB->pNextACB = NULL;
-      }
-
-    DC390_write8 (CtrlReg1, DIS_INT_ON_SCSI_RST | psh->this_id);	/* Disable SCSI bus reset interrupt */
-
-    if (pACB->Gmode2 & RST_SCSI_BUS)
-    {
-	dc390_ResetSCSIBus( pACB );
-	udelay (1000);
-	pACB->pScsiHost->last_reset = jiffies + HZ/2
-		    + HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY];
-	/*
-	for( i=0; i<(500 + 1000*dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY]); i++ )
-		udelay(1000);
-	 */
-    }
-    pACB->ACBFlag = 0;
-    DC390_read8 (INT_Status);				/* Reset Pending INT */
-    
-    DC390_write8 (Scsi_TimeOut, SEL_TIMEOUT);		/* 250ms selection timeout */
-    DC390_write8 (Clk_Factor, CLK_FREQ_40MHZ);		/* Conversion factor = 0 , 40MHz clock */
-    DC390_write8 (ScsiCmd, NOP_CMD);			/* NOP cmd - clear command register */
-    DC390_write8 (CtrlReg2, EN_FEATURE+EN_SCSI2_CMD);	/* Enable Feature and SCSI-2 */
-    DC390_write8 (CtrlReg3, FAST_CLK);			/* fast clock */
-    DC390_write8 (CtrlReg4, pACB->glitch_cfg |			/* glitch eater */
-		(dc390_eepromBuf[index][EE_MODE2] & ACTIVE_NEGATION) ? NEGATE_REQACKDATA : 0);	/* Negation */
-    DC390_write8 (CtcReg_High, 0);			/* Clear Transfer Count High: ID */
-    DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-    DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-    DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT);
-    dstate = DC390_read8 (DMA_Status);
-    DC390_write8 (DMA_Status, dstate);	/* clear */
-
-    return(0);
-}
-
-
-static void __devinit dc390_set_pci_cfg (struct pci_dev *pdev)
-{
-	u16 cmd;
-
-	pci_read_config_word(pdev, PCI_COMMAND, &cmd);
-	cmd |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_IO;
-	pci_write_config_word(pdev, PCI_COMMAND, cmd);
-	pci_write_config_word(pdev, PCI_STATUS, (PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY));
-}
-
 /**
  * dc390_slave_alloc - Called by the scsi mid layer to tell us about a new
  * scsi device that we need to deal with.
@@ -1404,7 +2176,6 @@
 	pDCB->pDCBACB = pACB;
 	pDCB->TargetID = id;
 	pDCB->TargetLUN = lun;
-	pDCB->MaxCommand = 1;
 
 	/*
 	 * Some values are for all LUNs: Copy them 
@@ -1412,14 +2183,13 @@
 	 */
 	if (lun && (pDCB2 = dc390_findDCB(pACB, id, 0))) {
 		pDCB->DevMode = pDCB2->DevMode;
-		pDCB->SyncMode = pDCB2->SyncMode;
+		pDCB->SyncMode = pDCB2->SyncMode & SYNC_NEGO_DONE;
 		pDCB->SyncPeriod = pDCB2->SyncPeriod;
 		pDCB->SyncOffset = pDCB2->SyncOffset;
 		pDCB->NegoPeriod = pDCB2->NegoPeriod;
       
 		pDCB->CtrlR3 = pDCB2->CtrlR3;
 		pDCB->CtrlR4 = pDCB2->CtrlR4;
-		pDCB->Inquiry7 = pDCB2->Inquiry7;
 	} else {
 		u8 index = pACB->AdapterIndex;
 		PEEprom prom = (PEEprom) &dc390_eepromBuf[index][id << 2];
@@ -1433,7 +2203,16 @@
 			pDCB->CtrlR4 |= NEGATE_REQACKDATA | NEGATE_REQACK;
 	}
 
-	dc390_updateDCB(pACB, pDCB);
+	if (pDCB->DevMode & SYNC_NEGO_)
+		pDCB->SyncMode |= SYNC_ENABLE;
+	else {
+		pDCB->SyncMode = 0;
+		pDCB->SyncOffset &= ~0x0f;
+	}
+
+	pDCB->CtrlR1 = pACB->pScsiHost->this_id;
+	if (pDCB->DevMode & PARITY_CHK_)
+		pDCB->CtrlR1 |= PARITY_ERR_REPO;
 
 	pACB->scan_devices = 1;
 	scsi_device->hostdata = pDCB;
@@ -1481,10 +2260,17 @@
 	pACB->DCBCnt--;
 }
 
-static int dc390_slave_configure(struct scsi_device *scsi_device)
+static int dc390_slave_configure(struct scsi_device *sdev)
 {
-	struct dc390_acb* pACB = (struct dc390_acb*) scsi_device->host->hostdata;
-	pACB->scan_devices = 0;
+	struct dc390_acb *acb = (struct dc390_acb *)sdev->host->hostdata;
+	struct dc390_dcb *dcb = (struct dc390_dcb *)sdev->hostdata;
+
+	acb->scan_devices = 0;
+	if (sdev->tagged_supported && (dcb->DevMode & TAG_QUEUEING_)) {
+		dcb->SyncMode |= EN_TAG_QUEUEING;
+		scsi_activate_tcq(sdev, acb->TagMaxNum);
+	}
+
 	return 0;
 }
 
@@ -1495,87 +2281,326 @@
 	.slave_alloc		= dc390_slave_alloc,
 	.slave_configure	= dc390_slave_configure,
 	.slave_destroy		= dc390_slave_destroy,
-	.queuecommand		= DC390_queue_command,
+	.queuecommand		= DC390_queuecommand,
 	.eh_abort_handler	= DC390_abort,
 	.eh_bus_reset_handler	= DC390_bus_reset,
-	.can_queue		= 42,
+	.can_queue		= 1,
 	.this_id		= 7,
 	.sg_tablesize		= SG_ALL,
-	.cmd_per_lun		= 16,
+	.cmd_per_lun		= 1,
 	.use_clustering		= DISABLE_CLUSTERING,
 };
 
-static int __devinit dc390_init_one(struct pci_dev *dev,
-				    const struct pci_device_id *id)
+/***********************************************************************
+ * Functions for access to DC390 EEPROM
+ * and some to emulate it
+ *
+ **********************************************************************/
+
+static void __devinit dc390_eeprom_prepare_read(struct pci_dev *pdev, u8 cmd)
 {
-	struct Scsi_Host *scsi_host;
-	unsigned long io_port;
-	u8 irq;
-	struct dc390_acb*  pACB;
-	int ret = -ENOMEM;
+	u8 carryFlag = 1, j = 0x80, bval;
+	int i;
 
-	if (pci_enable_device(dev))
-		return -ENODEV;
+	for (i = 0; i < 9; i++) {
+		if (carryFlag) {
+			pci_write_config_byte(pdev, 0x80, 0x40);
+			bval = 0xc0;
+		} else
+			bval = 0x80;
+
+		udelay(160);
+		pci_write_config_byte(pdev, 0x80, bval);
+		udelay(160);
+		pci_write_config_byte(pdev, 0x80, 0);
+		udelay(160);
 
-	io_port = pci_resource_start(dev, 0);
-	irq = dev->irq;
+		carryFlag = (cmd & j) ? 1 : 0;
+		j >>= 1;
+	}
+}
 
-	/* allocate scsi host information (includes out adapter) */
-	scsi_host = scsi_host_alloc(&driver_template, sizeof(struct dc390_acb));
-	if (!scsi_host)
-		goto nomem;
+static u16 __devinit dc390_eeprom_get_data(struct pci_dev *pdev)
+{
+	int i;
+	u16 wval = 0;
+	u8 bval;
 
-	pACB = (struct dc390_acb*) scsi_host->hostdata;
+	for (i = 0; i < 16; i++) {
+		wval <<= 1;
 
-	if (dc390_CheckEEpromCheckSum (dev, dc390_adapterCnt)) {
+		pci_write_config_byte(pdev, 0x80, 0x80);
+		udelay(160);
+		pci_write_config_byte(pdev, 0x80, 0x40);
+		udelay(160);
+		pci_read_config_byte(pdev, 0x00, &bval);
+
+		if (bval == 0x22)
+			wval |= 1;
+	}
+
+	return wval;
+}
+
+static void __devinit dc390_read_eeprom(struct pci_dev *pdev, u16 *ptr)
+{
+	u8 cmd = EEPROM_READ, i;
+
+	for (i = 0; i < 0x40; i++) {
+		pci_write_config_byte(pdev, 0xc0, 0);
+		udelay(160);
+
+		dc390_eeprom_prepare_read(pdev, cmd++);
+		*ptr++ = dc390_eeprom_get_data(pdev);
+
+		pci_write_config_byte(pdev, 0x80, 0);
+		pci_write_config_byte(pdev, 0x80, 0);
+		udelay(160);
+	}
+}
+
+/* Override EEprom values with explicitly set values */
+static void __devinit dc390_eeprom_override(u8 index)
+{
+	u8 *ptr = (u8 *) dc390_eepromBuf[index], id;
+
+	/* Adapter Settings */
+	if (tmscsim[0] != -2)
+		ptr[EE_ADAPT_SCSI_ID] = (u8)tmscsim[0];	/* Adapter ID */
+	if (tmscsim[3] != -2)
+		ptr[EE_MODE2] = (u8)tmscsim[3];
+	if (tmscsim[5] != -2)
+		ptr[EE_DELAY] = tmscsim[5];		/* Reset delay */
+	if (tmscsim[4] != -2)
+		ptr[EE_TAG_CMD_NUM] = (u8)tmscsim[4];	/* Tagged Cmds */
+
+	/* Device Settings */
+	for (id = 0; id < MAX_SCSI_ID; id++) {
+		if (tmscsim[2] != -2)
+			ptr[id << 2] = (u8)tmscsim[2];		/* EE_MODE1 */
+		if (tmscsim[1] != -2)
+			ptr[(id << 2) + 1] = (u8)tmscsim[1];	/* EE_Speed */
+	}
+}
+
+static int __devinitdata tmscsim_def[] = {
+	7,
+	0 /* 10MHz */,
+	PARITY_CHK_ | SEND_START_ | EN_DISCONNECT_ | SYNC_NEGO_ | TAG_QUEUEING_,
+	MORE2_DRV | GREATER_1G | RST_SCSI_BUS | ACTIVE_NEGATION | LUN_CHECK,
+	3 /* 16 Tags per LUN */,
+	1 /* s delay after Reset */,
+};
+
+/* Copy defaults over set values where missing */
+static void __devinit dc390_fill_with_defaults (void)
+{
+	int i;
+
+	for (i = 0; i < 6; i++) {
+		if (tmscsim[i] < 0 || tmscsim[i] > 255)
+			tmscsim[i] = tmscsim_def[i];
+	}
+
+	/* Sanity checks */
+	if (tmscsim[0] > 7)
+		tmscsim[0] = 7;
+	if (tmscsim[1] > 7)
+		tmscsim[1] = 4;
+	if (tmscsim[4] > 5)
+		tmscsim[4] = 4;
+	if (tmscsim[5] > 180)
+		tmscsim[5] = 180;
+}
+
+static void __devinit dc390_check_eeprom(struct pci_dev *pdev, u8 index)
+{
+	u8 interpd[] = {1, 3, 5, 10, 16, 30, 60, 120};
+	u8 EEbuf[128];
+	u16 *ptr = (u16 *)EEbuf, wval = 0;
+	int i;
+
+	dc390_read_eeprom(pdev, ptr);
+	memcpy(dc390_eepromBuf[index], EEbuf, EE_ADAPT_SCSI_ID);
+	memcpy(&dc390_eepromBuf[index][EE_ADAPT_SCSI_ID], 
+	       &EEbuf[REAL_EE_ADAPT_SCSI_ID], EE_LEN - EE_ADAPT_SCSI_ID);
+
+	dc390_eepromBuf[index][EE_DELAY] = interpd[dc390_eepromBuf[index][EE_DELAY]];
+
+	for (i = 0; i < 0x40; i++, ptr++)
+		wval += *ptr;
+
+	/* no Tekram EEprom found */
+	if (wval != 0x1234) {
 		int speed;
-		dc390_adapname = "AM53C974";
+
 		printk(KERN_INFO "DC390_init: No EEPROM found! Trying default settings ...\n");
-		dc390_check_for_safe_settings();
+
+		/*
+		 * XXX(hch): bogus, because we might have tekram and
+		 *           non-tekram hbas in a single machine.
+		 */
 		dc390_fill_with_defaults();
-		dc390_EEprom_Override(dc390_adapterCnt);
+
 		speed = dc390_clock_speed[tmscsim[1]];
-		printk(KERN_INFO "DC390: Used defaults: AdaptID=%i, SpeedIdx=%i (%i.%i MHz),"
-		       " DevMode=0x%02x, AdaptMode=0x%02x, TaggedCmnds=%i (%i), DelayReset=%is\n", 
-		       tmscsim[0], tmscsim[1], speed/10, speed%10,
+		printk(KERN_INFO "DC390: Used defaults: AdaptID=%i, SpeedIdx=%i (%i.%i MHz), "
+		       "DevMode=0x%02x, AdaptMode=0x%02x, TaggedCmnds=%i (%i), DelayReset=%is\n", 
+		       tmscsim[0], tmscsim[1], speed / 10, speed % 10,
 		       (u8)tmscsim[2], (u8)tmscsim[3], tmscsim[4], 2 << (tmscsim[4]), tmscsim[5]);
-	} else {
-		dc390_check_for_safe_settings();
-		dc390_EEprom_Override(dc390_adapterCnt);
+	}
+}
+
+static void __devinit dc390_init_hw(struct dc390_acb *pACB, u8 index)
+{
+	struct Scsi_Host *shost = pACB->pScsiHost;
+	u8 dstate;
+
+	/* Disable SCSI bus reset interrupt */
+	DC390_write8(CtrlReg1, DIS_INT_ON_SCSI_RST | shost->this_id);
+
+	if (pACB->Gmode2 & RST_SCSI_BUS) {
+		dc390_ResetSCSIBus(pACB);
+		udelay(1000);
+		shost->last_reset = jiffies + HZ/2 +
+			HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY];
 	}
 
-	DEBUG0(printk(KERN_INFO "DC390: pSH = %8x, Index %02i\n", (u32) scsi_host, dc390_adapterCnt));
+	pACB->ACBFlag = 0;
 
-	dc390_initACB(scsi_host, io_port, irq, dc390_adapterCnt);
+	/* Reset Pending INT */
+	DC390_read8(INT_Status);
+	
+	/* 250ms selection timeout */
+	DC390_write8(Scsi_TimeOut, SEL_TIMEOUT);
+	
+	/* Conversion factor = 0 , 40MHz clock */
+	DC390_write8(Clk_Factor, CLK_FREQ_40MHZ);
+	
+	/* NOP cmd - clear command register */
+	DC390_write8(ScsiCmd, NOP_CMD);
+	
+	/* Enable Feature and SCSI-2 */
+	DC390_write8(CtrlReg2, EN_FEATURE+EN_SCSI2_CMD);
+	
+	/* Fast clock */
+	DC390_write8(CtrlReg3, FAST_CLK);
 
-	pACB->pdev = dev;
+	/* Negation */
+	DC390_write8(CtrlReg4, pACB->glitch_cfg | /* glitch eater */
+		(dc390_eepromBuf[index][EE_MODE2] & ACTIVE_NEGATION) ?
+		 NEGATE_REQACKDATA : 0);
+	
+	/* Clear Transfer Count High: ID */
+	DC390_write8(CtcReg_High, 0);
+	DC390_write8(DMA_Cmd, DMA_IDLE_CMD);
+	DC390_write8(ScsiCmd, CLEAR_FIFO_CMD);
+	DC390_write32(DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT);
 
-	if (dc390_initAdapter(scsi_host, io_port, irq, dc390_adapterCnt)) {
-		scsi_unregister(scsi_host);
-		ret = -EBUSY;
-		goto busy;
+	dstate = DC390_read8(DMA_Status);
+	DC390_write8(DMA_Status, dstate);
+}
+
+static int __devinit dc390_probe_one(struct pci_dev *pdev,
+				    const struct pci_device_id *id)
+{
+	struct dc390_acb *pACB;
+	struct Scsi_Host *shost;
+	unsigned long io_port;
+	int error = -ENODEV, i;
+
+	if (pci_enable_device(pdev))
+		goto out;
+
+	pci_set_master(pdev);
+
+	error = -ENOMEM;
+	shost = scsi_host_alloc(&driver_template, sizeof(struct dc390_acb));
+	if (!shost)
+		goto out_disable_device;
+
+	pACB = (struct dc390_acb *)shost->hostdata;
+	memset(pACB, 0, sizeof(struct dc390_acb));
+
+	dc390_check_eeprom(pdev, dc390_adapterCnt);
+	dc390_eeprom_override(dc390_adapterCnt);
+
+	io_port = pci_resource_start(pdev, 0);
+
+	shost->this_id = dc390_eepromBuf[dc390_adapterCnt][EE_ADAPT_SCSI_ID];
+	shost->io_port = io_port;
+	shost->n_io_port = 0x80;
+	shost->irq = pdev->irq;
+	shost->base = io_port;
+	shost->unique_id = io_port;
+	shost->last_reset = jiffies;
+	
+	pACB->pScsiHost = shost;
+	pACB->IOPortBase = (u16) io_port;
+	pACB->IRQLevel = pdev->irq;
+	
+	shost->max_id = 8;
+
+	if (shost->max_id - 1 ==
+	    dc390_eepromBuf[dc390_adapterCnt][EE_ADAPT_SCSI_ID])
+		shost->max_id--;
+
+	if (dc390_eepromBuf[dc390_adapterCnt][EE_MODE2] & LUN_CHECK)
+		shost->max_lun = 8;
+	else
+		shost->max_lun = 1;
+
+	pACB->pFreeSRB = pACB->SRB_array;
+	pACB->SRBCount = MAX_SRB_CNT;
+	pACB->AdapterIndex = dc390_adapterCnt;
+	pACB->TagMaxNum =
+		2 << dc390_eepromBuf[dc390_adapterCnt][EE_TAG_CMD_NUM];
+	pACB->Gmode2 = dc390_eepromBuf[dc390_adapterCnt][EE_MODE2];
+
+	for (i = 0; i < pACB->SRBCount-1; i++)
+		pACB->SRB_array[i].pNextSRB = &pACB->SRB_array[i+1];
+	pACB->SRB_array[pACB->SRBCount-1].pNextSRB = NULL;
+	pACB->pTmpSRB = &pACB->TmpSRB;
+
+	pACB->sel_timeout = SEL_TIMEOUT;
+	pACB->glitch_cfg = EATER_25NS;
+	pACB->pdev = pdev;
+
+	if (!request_region(io_port, shost->n_io_port, "tmscsim")) {
+		printk(KERN_ERR "DC390: register IO ports error!\n");
+		goto out_host_put;
 	}
 
-	pci_set_master(dev);
-	dc390_set_pci_cfg(dev);
-	dc390_adapterCnt++;
+	/* Reset Pending INT */
+	DC390_read8_(INT_Status, io_port);
 
-	/* get the scsi mid level to scan for new devices on the bus */
-	if (scsi_add_host(scsi_host, &dev->dev)) {
-		ret = -ENODEV;
-		goto nodev;
+	if (request_irq(pdev->irq, do_DC390_Interrupt, SA_SHIRQ,
+				"tmscsim", pACB)) {
+		printk(KERN_ERR "DC390: register IRQ error!\n");
+		goto out_release_region;
 	}
-	pci_set_drvdata(dev, scsi_host);
-	scsi_scan_host(scsi_host);
 
+	dc390_init_hw(pACB, dc390_adapterCnt);
+	
+	dc390_adapterCnt++;
+
+	pci_set_drvdata(pdev, shost);
+
+	error = scsi_add_host(shost, &pdev->dev);
+	if (error)
+		goto out_free_irq;
+	scsi_scan_host(shost);
 	return 0;
 
-nodev:
-busy:
-	scsi_host_put(scsi_host);
-nomem:
-	pci_disable_device(dev);
-	return ret;
+ out_free_irq:
+	free_irq(pdev->irq, pACB);
+ out_release_region:
+	release_region(io_port, shost->n_io_port);
+ out_host_put:
+	scsi_host_put(shost);
+ out_disable_device:
+	pci_disable_device(pdev);
+ out:
+	return error;
 }
 
 /**
@@ -1600,8 +2625,6 @@
 		dc390_ResetSCSIBus(pACB);
 	spin_unlock_irqrestore(scsi_host->host_lock, iflags);
 
-	del_timer_sync(&pACB->Waiting_Timer);
-
 	free_irq(scsi_host->irq, pACB);
 	release_region(scsi_host->io_port, scsi_host->n_io_port);
 
@@ -1610,15 +2633,32 @@
 	pci_set_drvdata(dev, NULL);
 }
 
+static struct pci_device_id tmscsim_pci_tbl[] = {
+	{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD53C974,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(pci, tmscsim_pci_tbl);
+
 static struct pci_driver dc390_driver = {
 	.name           = "tmscsim",
 	.id_table       = tmscsim_pci_tbl,
-	.probe          = dc390_init_one,
+	.probe          = dc390_probe_one,
 	.remove         = __devexit_p(dc390_remove_one),
 };
 
 static int __init dc390_module_init(void)
 {
+	if (tmscsim[0] == -1 || tmscsim[0] > 15) {
+		tmscsim[0] = 7;
+		tmscsim[1] = 4;
+		tmscsim[2] = PARITY_CHK_ | TAG_QUEUEING_;
+		tmscsim[3] = MORE2_DRV | GREATER_1G | RST_SCSI_BUS | ACTIVE_NEGATION;
+		tmscsim[4] = 2;
+		tmscsim[5] = 10;
+		printk (KERN_INFO "DC390: Using safe settings.\n");
+	}
+
 	return pci_module_init(&dc390_driver);
 }
 
@@ -1629,3 +2669,25 @@
 
 module_init(dc390_module_init);
 module_exit(dc390_module_exit);
+
+#ifndef MODULE
+static int __init dc390_setup (char *str)
+{	
+	int ints[8],i, im;
+
+	get_options(str, ARRAY_SIZE(ints), ints);
+	im = ints[0];
+
+	if (im > 6) {
+		printk (KERN_NOTICE "DC390: ignore extra params!\n");
+		im = 6;
+	}
+
+	for (i = 0; i < im; i++)
+		tmscsim[i] = ints[i+1];
+	/* dc390_checkparams (); */
+	return 1;
+}
+
+__setup("tmscsim=", dc390_setup);
+#endif
diff -Nru a/drivers/scsi/tmscsim.h b/drivers/scsi/tmscsim.h
--- a/drivers/scsi/tmscsim.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/scsi/tmscsim.h	2004-12-24 13:37:19 -08:00
@@ -15,10 +15,8 @@
 
 #define MAX_ADAPTER_NUM 	4
 #define MAX_SG_LIST_BUF 	16	/* Not used */
-#define MAX_CMD_PER_LUN 	32
-#define MAX_CMD_QUEUE		MAX_CMD_PER_LUN+MAX_CMD_PER_LUN/2+1	
 #define MAX_SCSI_ID		8
-#define MAX_SRB_CNT		MAX_CMD_QUEUE+1	/* Max number of started commands */
+#define MAX_SRB_CNT		50	/* Max number of started commands */
 
 #define SEL_TIMEOUT		153	/* 250 ms selection timeout (@ 40 MHz) */
 
@@ -44,17 +42,15 @@
 struct scsi_cmnd	*pcmd;
 struct scatterlist	*pSegmentList;
 
-/* 0x10: */
 struct scatterlist Segmentx;	/* make a one entry of S/G list table */
 
-/* 0x1c: */
 unsigned long	SGBusAddr;	/*;a segment starting address as seen by AM53C974A*/
 unsigned long	SGToBeXferLen;	/*; to be xfer length */
 unsigned long	TotalXferredLen;
 unsigned long	SavedTotXLen;
+unsigned long	Saved_Ptr;
 u32		SRBState;
 
-/* 0x30: */
 u8		SRBStatus;
 u8		SRBFlag;	/*; b0-AutoReqSense,b6-Read,b7-write */
 				/*; b4-settimeout,b5-Residual valid */
@@ -62,24 +58,18 @@
 u8		TargetStatus;
 
 u8		ScsiPhase;
-u8		TagNumber;
+s8		TagNumber;
 u8		SGIndex;
 u8		SGcount;
 
-/* 0x38: */
 u8		MsgCnt;
 u8		EndMessage;
-u8		RetryCnt;
 u8		SavedSGCount;			
 
-unsigned long	Saved_Ptr;
-
-/* 0x40: */
 u8		MsgInBuf[6];
 u8		MsgOutBuf[6];
 
 //u8		IORBFlag;	/*;81h-Reset, 2-retry */
-/* 0x4c: */
 };
 
 
@@ -93,20 +83,12 @@
 struct dc390_dcb	*pNextDCB;
 struct dc390_acb	*pDCBACB;
 
-/* 0x08: */
 /* Queued SRBs */
-struct dc390_srb	*pWaitingSRB;
-struct dc390_srb	*pWaitLast;
 struct dc390_srb	*pGoingSRB;
 struct dc390_srb	*pGoingLast;
 struct dc390_srb	*pActiveSRB;
-u8		WaitSRBCnt;	/* Not used */
 u8		GoingSRBCnt;
 
-u8		DevType;
-u8		MaxCommand;
-
-/* 0x20: */
 u32		TagMask;
 
 u8		TargetID;	/*; SCSI Target ID  (SCSI Only) */
@@ -117,18 +99,11 @@
 u8		CtrlR1;
 u8		CtrlR3;
 u8		CtrlR4;
-u8		Inquiry7;
 
-/* 0x2c: */
 u8		SyncMode;	/*; 0:async mode */
 u8		NegoPeriod;	/*;for nego. */
 u8		SyncPeriod;	/*;for reg. */
 u8		SyncOffset;	/*;for reg. and nego.(low nibble) */
-
-/* 0x30:*/
-//u8		InqDataBuf[8];
-//u8		CapacityBuf[8];
-///* 0x40: */
 };
 
 
@@ -140,7 +115,6 @@
 struct dc390_acb
 {
 struct Scsi_Host *pScsiHost;
-struct dc390_acb	*pNextACB;
 u16		IOPortBase;
 u8		IRQLevel;
 u8		status;
@@ -182,8 +156,6 @@
 u32		SelConn;
 u32		CmdInQ;
 u32		CmdOutOfSRB;
-	
-struct timer_list	Waiting_Timer;
 
 struct dc390_srb	TmpSRB;
 struct dc390_srb	SRB_array[MAX_SRB_CNT]; 	/* 50 SRBs */
@@ -310,11 +282,11 @@
 #define MK_RES(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt))
 #define MK_RES_LNX(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1)
 
-#define SET_RES_TARGET(who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); }
-#define SET_RES_TARGET_LNX(who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; }
-#define SET_RES_MSG(who,msg) { who &= ~RES_ENDMSG; who |= (int)(msg) << 8; }
-#define SET_RES_DID(who,did) { who &= ~RES_DID; who |= (int)(did) << 16; }
-#define SET_RES_DRV(who,drv) { who &= ~RES_DRV; who |= (int)(drv) << 24; }
+#define SET_RES_TARGET(who, tgt) do { who &= ~RES_TARGET; who |= (int)(tgt); } while (0)
+#define SET_RES_TARGET_LNX(who, tgt) do { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; } while (0)
+#define SET_RES_MSG(who, msg) do { who &= ~RES_ENDMSG; who |= (int)(msg) << 8; } while (0)
+#define SET_RES_DID(who, did) do { who &= ~RES_DID; who |= (int)(did) << 16; } while (0)
+#define SET_RES_DRV(who, drv) do { who &= ~RES_DRV; who |= (int)(drv) << 24; } while (0)
 
 /*;---Sync_Mode */
 #define SYNC_DISABLE	0
@@ -346,64 +318,6 @@
 typedef struct {
 	dma_addr_t		saved_dma_handle;
 } dc390_cmd_scp_t;
-
-/*
-**  Inquiry Data format
-*/
-
-typedef struct	_SCSIInqData { /* INQUIRY */
-
-	u8	 DevType;		/* Periph Qualifier & Periph Dev Type*/
-	u8	 RMB_TypeMod;		/* rem media bit & Dev Type Modifier */
-	u8	 Vers;			/* ISO, ECMA, & ANSI versions	     */
-	u8	 RDF;			/* AEN, TRMIOP, & response data format*/
-	u8	 AddLen;		/* length of additional data	     */
-	u8	 Res1;			/* reserved			     */
-	u8	 Res2;			/* reserved			     */
-	u8	 Flags; 		/* RelADr,Wbus32,Wbus16,Sync,etc.    */
-	u8	 VendorID[8];		/* Vendor Identification	     */
-	u8	 ProductID[16]; 	/* Product Identification	     */
-	u8	 ProductRev[4]; 	/* Product Revision		     */
-
-
-} SCSI_INQDATA, *PSCSI_INQDATA;
-
-
-/*  Inquiry byte 0 masks */
-
-
-#define SCSI_DEVTYPE	    0x1F      /* Peripheral Device Type 	    */
-#define SCSI_PERIPHQUAL     0xE0      /* Peripheral Qualifier		    */
-#define TYPE_NODEV	    SCSI_DEVTYPE    /* Unknown or no device type    */
-
-
-/*  Inquiry byte 1 mask */
-
-#define SCSI_REMOVABLE_MEDIA  0x80    /* Removable Media bit (1=removable)  */
-
-
-/*  Peripheral Device Type definitions */
-/*  see include/scsi/scsi.h for the rest */
-
-#ifndef TYPE_PRINTER
-# define TYPE_PRINTER		 0x02	   /* Printer device		   */
-#endif
-#ifndef TYPE_COMM
-# define TYPE_COMM		 0x09	   /* Communications device	   */
-#endif
-
-/*
-** Inquiry flag definitions (Inq data byte 7)
-*/
-
-#define SCSI_INQ_RELADR       0x80    /* device supports relative addressing*/
-#define SCSI_INQ_WBUS32       0x40    /* device supports 32 bit data xfers  */
-#define SCSI_INQ_WBUS16       0x20    /* device supports 16 bit data xfers  */
-#define SCSI_INQ_SYNC	      0x10    /* device supports synchronous xfer   */
-#define SCSI_INQ_LINKED       0x08    /* device supports linked commands    */
-#define SCSI_INQ_CMDQUEUE     0x02    /* device supports command queueing   */
-#define SCSI_INQ_SFTRE	      0x01    /* device supports soft resets */
-
 
 /*
 ;==========================================================
diff -Nru a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
--- a/drivers/scsi/u14-34f.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/scsi/u14-34f.c	2004-12-24 13:36:33 -08:00
@@ -421,22 +421,26 @@
 #include <linux/init.h>
 #include <linux/ctype.h>
 #include <linux/spinlock.h>
-#include <scsi/scsicam.h>
-#include "scsi.h"
-#include <scsi/scsi_host.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
 
-static int u14_34f_detect(Scsi_Host_Template *);
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/scsicam.h>
+
+static int u14_34f_detect(struct scsi_host_template *);
 static int u14_34f_release(struct Scsi_Host *);
-static int u14_34f_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
-static int u14_34f_eh_abort(Scsi_Cmnd *);
-static int u14_34f_eh_host_reset(Scsi_Cmnd *);
+static int u14_34f_queuecommand(struct scsi_cmnd *, void (*done)(struct scsi_cmnd *));
+static int u14_34f_eh_abort(struct scsi_cmnd *);
+static int u14_34f_eh_host_reset(struct scsi_cmnd *);
 static int u14_34f_bios_param(struct scsi_device *, struct block_device *,
                               sector_t, int *);
-static int u14_34f_slave_configure(Scsi_Device *);
+static int u14_34f_slave_configure(struct scsi_device *);
 
-static Scsi_Host_Template driver_template = {
+static struct scsi_host_template driver_template = {
                 .name                    = "UltraStor 14F/34F rev. 8.10.00 ",
                 .detect                  = u14_34f_detect,
                 .release                 = u14_34f_release,
@@ -575,7 +579,7 @@
    unsigned int sense_addr PACKED;
 
    /* Additional fields begin here. */
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
    unsigned int cpp_index;              /* cp index */
 
    /* All the cp structure is zero filled by queuecommand except the
@@ -634,7 +638,7 @@
 #define DEV2H(x) le32_to_cpu(x)
 
 static irqreturn_t do_interrupt_handler(int, void *, struct pt_regs *);
-static void flush_dev(Scsi_Device *, unsigned long, unsigned int, unsigned int);
+static void flush_dev(struct scsi_device *, unsigned long, unsigned int, unsigned int);
 static int do_trace = FALSE;
 static int setup_done = FALSE;
 static int link_statistics;
@@ -682,7 +686,7 @@
 
 #endif
 
-static int u14_34f_slave_configure(Scsi_Device *dev) {
+static int u14_34f_slave_configure(struct scsi_device *dev) {
    int j, tqd, utqd;
    char *tag_suffix, *link_suffix;
    struct Scsi_Host *host = dev->host;
@@ -794,7 +798,7 @@
 }
 
 static int port_detect \
-      (unsigned long port_base, unsigned int j, Scsi_Host_Template *tpnt) {
+      (unsigned long port_base, unsigned int j, struct scsi_host_template *tpnt) {
    unsigned char irq, dma_channel, subversion, i;
    unsigned char in_byte;
    char *bus_type, dma_name[16];
@@ -1080,7 +1084,7 @@
    return 1;
 }
 
-static int u14_34f_detect(Scsi_Host_Template *tpnt) {
+static int u14_34f_detect(struct scsi_host_template *tpnt) {
    unsigned int j = 0, k;
 
    tpnt->proc_name = "u14-34f";
@@ -1113,10 +1117,10 @@
    unsigned int k, count, pci_dir;
    struct scatterlist *sgpnt;
    struct mscp *cpp;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
-   pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction);
+   pci_dir = SCpnt->sc_data_direction;
 
    if (SCpnt->sense_buffer)
       cpp->sense_addr = H2DEV(pci_map_single(HD(j)->pdev, SCpnt->sense_buffer,
@@ -1156,10 +1160,10 @@
 static void unmap_dma(unsigned int i, unsigned int j) {
    unsigned int pci_dir;
    struct mscp *cpp;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
-   pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction);
+   pci_dir = SCpnt->sc_data_direction;
 
    if (DEV2H(cpp->sense_addr))
       pci_unmap_single(HD(j)->pdev, DEV2H(cpp->sense_addr),
@@ -1178,10 +1182,10 @@
 static void sync_dma(unsigned int i, unsigned int j) {
    unsigned int pci_dir;
    struct mscp *cpp;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
-   pci_dir = scsi_to_pci_dma_dir(SCpnt->sc_data_direction);
+   pci_dir = SCpnt->sc_data_direction;
 
    if (DEV2H(cpp->sense_addr))
       pci_dma_sync_single_for_cpu(HD(j)->pdev, DEV2H(cpp->sense_addr),
@@ -1214,24 +1218,24 @@
       };
 
    struct mscp *cpp;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    cpp = &HD(j)->cp[i]; SCpnt = cpp->SCpnt;
 
-   if (SCpnt->sc_data_direction == SCSI_DATA_READ) {
+   if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
       cpp->xdir = DTD_IN;
       return;
       }
-   else if (SCpnt->sc_data_direction == SCSI_DATA_WRITE) {
+   else if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
       cpp->xdir = DTD_OUT;
       return;
       }
-   else if (SCpnt->sc_data_direction == SCSI_DATA_NONE) {
+   else if (SCpnt->sc_data_direction == DMA_NONE) {
       cpp->xdir = DTD_NONE;
       return;
       }
 
-   if (SCpnt->sc_data_direction != SCSI_DATA_UNKNOWN)
+   if (SCpnt->sc_data_direction != DMA_BIDIRECTIONAL)
       panic("%s: qcomm, invalid SCpnt->sc_data_direction.\n", BN(j));
 
    cpp->xdir = DTD_IN;
@@ -1251,7 +1255,7 @@
 
 }
 
-static int u14_34f_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) {
+static int u14_34f_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) {
    unsigned int i, j, k;
    struct mscp *cpp;
 
@@ -1332,7 +1336,7 @@
    return 0;
 }
 
-static int u14_34f_eh_abort(Scsi_Cmnd *SCarg) {
+static int u14_34f_eh_abort(struct scsi_cmnd *SCarg) {
    unsigned int i, j;
 
    j = ((struct hostdata *) SCarg->device->host->hostdata)->board_number;
@@ -1406,10 +1410,10 @@
    panic("%s: abort, mbox %d, invalid cp_stat.\n", BN(j), i);
 }
 
-static int u14_34f_eh_host_reset(Scsi_Cmnd *SCarg) {
+static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) {
    unsigned int i, j, time, k, c, limit = 0;
    int arg_done = FALSE;
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
 
    j = ((struct hostdata *) SCarg->device->host->hostdata)->board_number;
    printk("%s: reset, enter, target %d.%d:%d, pid %ld.\n",
@@ -1589,7 +1593,7 @@
 
 static int reorder(unsigned int j, unsigned long cursec,
                  unsigned int ihdlr, unsigned int il[], unsigned int n_ready) {
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
    struct mscp *cpp;
    unsigned int k, n;
    unsigned int rev = FALSE, s = TRUE, r = TRUE;
@@ -1685,9 +1689,9 @@
    return overlap;
 }
 
-static void flush_dev(Scsi_Device *dev, unsigned long cursec, unsigned int j,
+static void flush_dev(struct scsi_device *dev, unsigned long cursec, unsigned int j,
                       unsigned int ihdlr) {
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
    struct mscp *cpp;
    unsigned int k, n, n_ready = 0, il[MAX_MAILBOXES];
 
@@ -1725,7 +1729,7 @@
 }
 
 static irqreturn_t ihdlr(int irq, unsigned int j) {
-   Scsi_Cmnd *SCpnt;
+   struct scsi_cmnd *SCpnt;
    unsigned int i, k, c, status, tstatus, reg, ret;
    struct mscp *spp, *cpp;
 
diff -Nru a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c
--- a/drivers/scsi/ultrastor.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/scsi/ultrastor.c	2004-12-24 13:36:55 -08:00
@@ -137,9 +137,9 @@
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
 #include <linux/stat.h>
+#include <linux/bitops.h>
 
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/system.h>
 #include <asm/dma.h>
 
diff -Nru a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
--- a/drivers/scsi/wd33c93.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/scsi/wd33c93.c	2004-12-24 13:37:01 -08:00
@@ -154,7 +154,7 @@
 static char *setup_args[] = { "", "", "", "", "", "", "", "", "" };
 
 static char *setup_strings;
-MODULE_PARM(setup_strings, "s");
+module_param(setup_strings, charp, 0);
 
 static void wd33c93_execute(struct Scsi_Host *instance);
 
diff -Nru a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
--- a/drivers/scsi/wd7000.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/scsi/wd7000.c	2004-12-24 13:37:30 -08:00
@@ -589,7 +589,7 @@
 
 #ifdef MODULE
 static char *wd7000;
-MODULE_PARM(wd7000, "s");
+module_param(wd7000, charp, 0);
 #endif
 
 /*
@@ -1429,16 +1429,16 @@
 						break;
 
 				if (i == pass) {
-					void *biosaddr = ioremap(wd7000_biosaddr[biosaddr_ptr] + signatures[sig_ptr].ofs,
+					void __iomem *biosaddr = ioremap(wd7000_biosaddr[biosaddr_ptr] + signatures[sig_ptr].ofs,
 								 signatures[sig_ptr].len);
-					short bios_match = 0;
+					short bios_match = 1;
 
 					if (biosaddr)
-						bios_match = memcmp((char *) biosaddr, signatures[sig_ptr].sig, signatures[sig_ptr].len);
+						bios_match = check_signature(biosaddr, signatures[sig_ptr].sig, signatures[sig_ptr].len);
 
 					iounmap(biosaddr);
 
-					if (!bios_match)
+					if (bios_match)
 						goto bios_matched;
 				}
 			}
@@ -1473,8 +1473,7 @@
 			 * ASC reset...
 			 */
 			outb(ASC_RES, iobase + ASC_CONTROL);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ / 100);
+			msleep(10);
 			outb(0, iobase + ASC_CONTROL);
 
 			if (WAIT(iobase + ASC_STAT, ASC_STATMASK, CMD_RDY, 0)) {
diff -Nru a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c
--- a/drivers/scsi/zalon.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/scsi/zalon.c	2004-12-24 13:37:01 -08:00
@@ -190,7 +190,12 @@
 
 static int __init zalon7xx_init(void)
 {
-	return register_parisc_driver(&zalon_driver);
+	int ret = ncr53c8xx_init();
+	if (!ret)
+		ret = register_parisc_driver(&zalon_driver);
+	if (ret)
+		ncr53c8xx_exit();
+	return ret;
 }
 
 static void __exit zalon7xx_exit(void)
diff -Nru a/drivers/serial/21285.c b/drivers/serial/21285.c
--- a/drivers/serial/21285.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/serial/21285.c	2004-12-24 13:37:04 -08:00
@@ -13,12 +13,14 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/console.h>
+#include <linux/device.h>
+#include <linux/tty_flip.h>
 #include <linux/serial_core.h>
 #include <linux/serial.h>
-#include <linux/device.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
+#include <asm/mach-types.h>
 #include <asm/hardware/dec21285.h>
 #include <asm/hardware.h>
 
@@ -90,22 +92,21 @@
 {
 	struct uart_port *port = dev_id;
 	struct tty_struct *tty = port->info->tty;
-	unsigned int status, ch, rxs, max_count = 256;
+	unsigned int status, ch, flag, rxs, max_count = 256;
 
 	status = *CSR_UARTFLG;
 	while (!(status & 0x10) && max_count--) {
 		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-			tty->flip.work.func((void *)tty);
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-				printk(KERN_WARNING "TTY_DONT_FLIP set\n");
-				goto out;
-			}
+			if (tty->low_latency)
+				tty_flip_buffer_push(tty);
+			/*
+			 * If this failed then we will throw away the
+			 * bytes but must do so to clear interrupts
+			 */
 		}
 
 		ch = *CSR_UARTDR;
-
-		*tty->flip.char_buf_ptr = ch;
-		*tty->flip.flag_buf_ptr = TTY_NORMAL;
+		flag = TTY_NORMAL;
 		port->icount.rx++;
 
 		rxs = *CSR_RXSTAT | RXSTAT_DUMMY_READ;
@@ -120,15 +121,13 @@
 			rxs &= port->read_status_mask;
 
 			if (rxs & RXSTAT_PARITY)
-				*tty->flip.flag_buf_ptr = TTY_PARITY;
+				flag = TTY_PARITY;
 			else if (rxs & RXSTAT_FRAME)
-				*tty->flip.flag_buf_ptr = TTY_FRAME;
+				flag = TTY_FRAME;
 		}
 
 		if ((rxs & port->ignore_status_mask) == 0) {
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, ch, flag);
 		}
 		if ((rxs & RXSTAT_OVERRUN) &&
 		    tty->flip.count < TTY_FLIPBUF_SIZE) {
@@ -137,9 +136,7 @@
 			 * immediately, and doesn't affect the current
 			 * character.
 			 */
-			*tty->flip.char_buf_ptr++ = 0;
-			*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
 		}
 		status = *CSR_UARTFLG;
 	}
diff -Nru a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
--- a/drivers/serial/68328serial.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/serial/68328serial.c	2004-12-24 13:37:29 -08:00
@@ -34,12 +34,13 @@
 #include <linux/keyboard.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/segment.h>
-#include <asm/bitops.h>
 #include <asm/delay.h>
 #include <asm/uaccess.h>
 
@@ -757,7 +758,7 @@
 
 extern void console_printn(const char * b, int count);
 
-static int rs_write(struct tty_struct * tty, int from_user,
+static int rs_write(struct tty_struct * tty,
 		    const unsigned char *buf, int count)
 {
 	int	c, total = 0;
@@ -779,15 +780,7 @@
 		if (c <= 0)
 			break;
 
-		if (from_user) {
-			down(&tmp_buf_sem);
-			copy_from_user(tmp_buf, buf, c);
-			c = min_t(int, c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-				       SERIAL_XMIT_SIZE - info->xmit_head));
-			memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
-			up(&tmp_buf_sem);
-		} else
-			memcpy(info->xmit_buf + info->xmit_head, buf, c);
+		memcpy(info->xmit_buf + info->xmit_head, buf, c);
 		info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
 		info->xmit_cnt += c;
 		restore_flags(flags);
@@ -1005,7 +998,7 @@
         unsigned long flags;
         if (!info->port)
                 return;
-        current->state = TASK_INTERRUPTIBLE;
+        set_current_state(TASK_INTERRUPTIBLE);
         save_flags(flags);
         cli();
 #ifdef USE_INTS	
@@ -1197,8 +1190,7 @@
 #endif	
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
diff -Nru a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c
--- a/drivers/serial/68360serial.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/serial/68360serial.c	2004-12-24 13:37:29 -08:00
@@ -1047,7 +1047,7 @@
 
 }
 
-static int rs_360_write(struct tty_struct * tty, int from_user,
+static int rs_360_write(struct tty_struct * tty,
 		    const unsigned char *buf, int count)
 {
 	int	c, ret = 0;
@@ -1079,16 +1079,8 @@
 			break;
 		}
 
-		if (from_user) {
-			if (copy_from_user((void *)bdp->buf, buf, c)) {
-				if (!ret)
-					ret = -EFAULT;
-				break;
-			}
-		} else {
-			/* memcpy(__va(bdp->buf), buf, c); */
-			memcpy((void *)bdp->buf, buf, c);
-		}
+		/* memcpy(__va(bdp->buf), buf, c); */
+		memcpy((void *)bdp->buf, buf, c);
 
 		bdp->length = c;
 		bdp->status |= BD_SC_READY;
@@ -1404,7 +1396,7 @@
  */
 static void send_break(ser_info_t *info, int duration)
 {
-	current->state = TASK_INTERRUPTIBLE;
+	set_current_state(TASK_INTERRUPTIBLE);
 #ifdef SERIAL_DEBUG_SEND_BREAK
 	printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
 #endif
@@ -1715,8 +1707,7 @@
 	info->tty = 0;
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -1769,9 +1760,8 @@
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
 		printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
 #endif
-		current->state = TASK_INTERRUPTIBLE;
 /*		current->counter = 0;	 make us low-priority */
-		schedule_timeout(char_time);
+		msleep_interruptible(jiffies_to_msecs(char_time));
 		if (signal_pending(current))
 			break;
 		if (timeout && ((orig_jiffies + timeout) < jiffies))
diff -Nru a/drivers/serial/8250.c b/drivers/serial/8250.c
--- a/drivers/serial/8250.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/serial/8250.c	2004-12-24 13:36:17 -08:00
@@ -20,27 +20,29 @@
  *  membase is an 'ioremapped' cookie.
  */
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
-#include <linux/serial_reg.h>
-#include <linux/serial.h>
-#include <linux/serialP.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_reg.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
+#include <linux/serial_8250.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
 #include "8250.h"
 
 /*
@@ -157,23 +159,109 @@
 /*
  * Here we define the default xmit fifo size used for each type of UART.
  */
-static const struct serial8250_config uart_config[PORT_MAX_8250+1] = {
-	{ "unknown",	1,	1,	0 },
-	{ "8250",	1,	1,	0 },
-	{ "16450",	1,	1,	0 },
-	{ "16550",	1,	1,	0 },
-	{ "16550A",	16,	16,	UART_CAP_FIFO },
-	{ "Cirrus",	1, 	1,	0 },
-	{ "ST16650",	1,	1,	UART_CAP_FIFO | UART_CAP_SLEEP | UART_CAP_EFR },
-	{ "ST16650V2",	32,	16,	UART_CAP_FIFO | UART_CAP_SLEEP | UART_CAP_EFR },
-	{ "TI16750",	64,	64,	UART_CAP_FIFO | UART_CAP_SLEEP },
-	{ "Startech",	1,	1,	0 },
-	{ "16C950/954",	128,	128,	UART_CAP_FIFO },
-	{ "ST16654",	64,	32,	UART_CAP_FIFO | UART_CAP_SLEEP | UART_CAP_EFR },
-	{ "XR16850",	128,	128,	UART_CAP_FIFO | UART_CAP_SLEEP | UART_CAP_EFR },
-	{ "RSA",	2048,	2048,	UART_CAP_FIFO },
-	{ "NS16550A",	16,	16,	UART_CAP_FIFO | UART_NATSEMI },
-	{ "XScale",	32,	32,	UART_CAP_FIFO },
+static const struct serial8250_config uart_config[] = {
+	[PORT_UNKNOWN] = {
+		.name		= "unknown",
+		.fifo_size	= 1,
+		.tx_loadsz	= 1,
+	},
+	[PORT_8250] = {
+		.name		= "8250",
+		.fifo_size	= 1,
+		.tx_loadsz	= 1,
+	},
+	[PORT_16450] = {
+		.name		= "16450",
+		.fifo_size	= 1,
+		.tx_loadsz	= 1,
+	},
+	[PORT_16550] = {
+		.name		= "16550",
+		.fifo_size	= 1,
+		.tx_loadsz	= 1,
+	},
+	[PORT_16550A] = {
+		.name		= "16550A",
+		.fifo_size	= 16,
+		.tx_loadsz	= 16,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+		.flags		= UART_CAP_FIFO,
+	},
+	[PORT_CIRRUS] = {
+		.name		= "Cirrus",
+		.fifo_size	= 1,
+		.tx_loadsz	= 1,
+	},
+	[PORT_16650] = {
+		.name		= "ST16650",
+		.fifo_size	= 1,
+		.tx_loadsz	= 1,
+		.flags		= UART_CAP_FIFO | UART_CAP_EFR | UART_CAP_SLEEP,
+	},
+	[PORT_16650V2] = {
+		.name		= "ST16650V2",
+		.fifo_size	= 32,
+		.tx_loadsz	= 16,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01 |
+				  UART_FCR_T_TRIG_00,
+		.flags		= UART_CAP_FIFO | UART_CAP_EFR | UART_CAP_SLEEP,
+	},
+	[PORT_16750] = {
+		.name		= "TI16750",
+		.fifo_size	= 64,
+		.tx_loadsz	= 64,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10 |
+				  UART_FCR7_64BYTE,
+		.flags		= UART_CAP_FIFO | UART_CAP_SLEEP | UART_CAP_AFE,
+	},
+	[PORT_STARTECH] = {
+		.name		= "Startech",
+		.fifo_size	= 1,
+		.tx_loadsz	= 1,
+	},
+	[PORT_16C950] = {
+		.name		= "16C950/954",
+		.fifo_size	= 128,
+		.tx_loadsz	= 128,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+		.flags		= UART_CAP_FIFO,
+	},
+	[PORT_16654] = {
+		.name		= "ST16654",
+		.fifo_size	= 64,
+		.tx_loadsz	= 32,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01 |
+				  UART_FCR_T_TRIG_10,
+		.flags		= UART_CAP_FIFO | UART_CAP_EFR | UART_CAP_SLEEP,
+	},
+	[PORT_16850] = {
+		.name		= "XR16850",
+		.fifo_size	= 128,
+		.tx_loadsz	= 128,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+		.flags		= UART_CAP_FIFO | UART_CAP_EFR | UART_CAP_SLEEP,
+	},
+	[PORT_RSA] = {
+		.name		= "RSA",
+		.fifo_size	= 2048,
+		.tx_loadsz	= 2048,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_11,
+		.flags		= UART_CAP_FIFO,
+	},
+	[PORT_NS16550A] = {
+		.name		= "NS16550A",
+		.fifo_size	= 16,
+		.tx_loadsz	= 16,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+		.flags		= UART_CAP_FIFO | UART_NATSEMI,
+	},
+	[PORT_XSCALE] = {
+		.name		= "XScale",
+		.fifo_size	= 32,
+		.tx_loadsz	= 32,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+		.flags		= UART_CAP_FIFO,
+	},
 };
 
 static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset)
@@ -405,6 +493,11 @@
 	unsigned char id1, id2, id3, rev, saved_dll, saved_dlm;
 
 	/*
+	 * Everything with an EFR has SLEEP
+	 */
+	up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP;
+
+	/*
 	 * First we check to see if it's an Oxford Semiconductor UART.
 	 *
 	 * If we have to do this here because some non-National
@@ -514,6 +607,7 @@
 	unsigned char status1, status2;
 
 	up->port.type = PORT_16550A;
+	up->capabilities |= UART_CAP_FIFO;
 
 	/*
 	 * Check for presence of the EFR when DLAB is set.
@@ -525,6 +619,7 @@
 		if (serial_in(up, UART_EFR) != 0) {
 			DEBUG_AUTOCONF("EFRv1 ");
 			up->port.type = PORT_16650;
+			up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP;
 		} else {
 			DEBUG_AUTOCONF("Motorola 8xxx DUART ");
 		}
@@ -577,6 +672,7 @@
 #endif
 
 			up->port.type = PORT_NS16550A;
+			up->capabilities |= UART_NATSEMI;
 			return;
 		}
 	}
@@ -600,6 +696,7 @@
 
 	if (status1 == 6 && status2 == 7) {
 		up->port.type = PORT_16750;
+		up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP;
 		return;
 	}
 }
@@ -630,6 +727,8 @@
 	spin_lock_irqsave(&up->port.lock, flags);
 //	save_flags(flags); cli();
 
+	up->capabilities = 0;
+
 	if (!(up->port.flags & UPF_BUGGY_UART)) {
 		/*
 		 * Do a simple existence test first; if we fail this,
@@ -740,6 +839,13 @@
 #endif
 	serial_outp(up, UART_LCR, save_lcr);
 
+	if (up->capabilities != uart_config[up->port.type].flags) {
+		printk(KERN_WARNING
+		       "ttyS%d: detected caps %08x should be %08x\n",
+			up->port.line, up->capabilities,
+			uart_config[up->port.type].flags);
+	}
+
 	up->port.fifosize = uart_config[up->port.type].fifo_size;
 	up->capabilities = uart_config[up->port.type].flags;
 	up->tx_loadsz = uart_config[up->port.type].tx_loadsz;
@@ -822,6 +928,12 @@
 		up->ier &= ~UART_IER_THRI;
 		serial_out(up, UART_IER, up->ier);
 	}
+
+	/*
+	 * We only do this from uart_stop - if we run out of
+	 * characters to send, we don't want to prevent the
+	 * FIFO from emptying.
+	 */
 	if (up->port.type == PORT_16C950 && tty_stop) {
 		up->acr |= UART_ACR_TXDIS;
 		serial_icr_write(up, UART_ACR, up->acr);
@@ -866,27 +978,40 @@
 receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs)
 {
 	struct tty_struct *tty = up->port.info->tty;
-	unsigned char ch;
+	unsigned char ch, lsr = *status;
 	int max_count = 256;
+	char flag;
 
 	do {
+		/* The following is not allowed by the tty layer and
+		   unsafe. It should be fixed ASAP */
 		if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
-			tty->flip.work.func((void *)tty);
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-				return; // if TTY_DONT_FLIP is set
+			if(tty->low_latency)
+				tty_flip_buffer_push(tty);
+			/* If this failed then we will throw away the
+			   bytes but must do so to clear interrupts */
 		}
 		ch = serial_inp(up, UART_RX);
-		*tty->flip.char_buf_ptr = ch;
-		*tty->flip.flag_buf_ptr = TTY_NORMAL;
+		flag = TTY_NORMAL;
 		up->port.icount.rx++;
 
-		if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE |
-				       UART_LSR_FE | UART_LSR_OE))) {
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+		/*
+		 * Recover the break flag from console xmit
+		 */
+		if (up->port.line == up->port.cons->index) {
+			lsr |= up->lsr_break_flag;
+			up->lsr_break_flag = 0;
+		}
+#endif
+
+		if (unlikely(lsr & (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);
+			if (lsr & UART_LSR_BI) {
+				lsr &= ~(UART_LSR_FE | UART_LSR_PE);
 				up->port.icount.brk++;
 				/*
 				 * We do the SysRQ and SAK checking
@@ -896,56 +1021,45 @@
 				 */
 				if (uart_handle_break(&up->port))
 					goto ignore_char;
-			} else if (*status & UART_LSR_PE)
+			} else if (lsr & UART_LSR_PE)
 				up->port.icount.parity++;
-			else if (*status & UART_LSR_FE)
+			else if (lsr & UART_LSR_FE)
 				up->port.icount.frame++;
-			if (*status & UART_LSR_OE)
+			if (lsr & UART_LSR_OE)
 				up->port.icount.overrun++;
 
 			/*
 			 * Mask off conditions which should be ingored.
 			 */
-			*status &= up->port.read_status_mask;
+			lsr &= up->port.read_status_mask;
 
-#ifdef CONFIG_SERIAL_8250_CONSOLE
-			if (up->port.line == up->port.cons->index) {
-				/* Recover the break flag from console xmit */
-				*status |= up->lsr_break_flag;
-				up->lsr_break_flag = 0;
-			}
-#endif
-			if (*status & UART_LSR_BI) {
+			if (lsr & UART_LSR_BI) {
 				DEBUG_INTR("handling break....");
-				*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;
+				flag = TTY_BREAK;
+			} else if (lsr & UART_LSR_PE)
+				flag = TTY_PARITY;
+			else if (lsr & UART_LSR_FE)
+				flag = TTY_FRAME;
 		}
 		if (uart_handle_sysrq_char(&up->port, ch, regs))
 			goto ignore_char;
-		if ((*status & up->port.ignore_status_mask) == 0) {
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
+		if ((lsr & up->port.ignore_status_mask) == 0) {
+			tty_insert_flip_char(tty, ch, flag);
 		}
-		if ((*status & UART_LSR_OE) &&
+		if ((lsr & UART_LSR_OE) &&
 		    tty->flip.count < TTY_FLIPBUF_SIZE) {
 			/*
 			 * Overrun is special, since it's reported
 			 * immediately, and doesn't affect the current
 			 * character.
 			 */
-			*tty->flip.flag_buf_ptr = TTY_OVERRUN;
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
 		}
 	ignore_char:
-		*status = serial_inp(up, UART_LSR);
-	} while ((*status & UART_LSR_DR) && (max_count-- > 0));
+		lsr = serial_inp(up, UART_LSR);
+	} while ((lsr & UART_LSR_DR) && (max_count-- > 0));
 	tty_flip_buffer_push(tty);
+	*status = lsr;
 }
 
 static _INLINE_ void transmit_chars(struct uart_8250_port *up)
@@ -1038,7 +1152,7 @@
 {
 	struct irq_info *i = dev_id;
 	struct list_head *l, *end = NULL;
-	int pass_counter = 0;
+	int pass_counter = 0, handled = 0;
 
 	DEBUG_INTR("serial8250_interrupt(%d)...", irq);
 
@@ -1057,6 +1171,8 @@
 			serial8250_handle_port(up, regs);
 			spin_unlock(&up->port.lock);
 
+			handled = 1;
+
 			end = NULL;
 		} else if (end == NULL)
 			end = l;
@@ -1074,8 +1190,8 @@
 	spin_unlock(&i->lock);
 
 	DEBUG_INTR("end.\n");
-	/* FIXME! Was it really ours? */
-	return IRQ_HANDLED;
+
+	return IRQ_RETVAL(handled);
 }
 
 /*
@@ -1493,25 +1609,22 @@
 	if (up->capabilities & UART_CAP_FIFO && up->port.fifosize > 1) {
 		if (baud < 2400)
 			fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
-#ifdef CONFIG_SERIAL_8250_RSA
-		else if (up->port.type == PORT_RSA)
-			fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_14;
-#endif
 		else
-			fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8;
+			fcr = uart_config[up->port.type].fcr;
 	}
 
 	/*
-	 * TI16C750: hardware flow control and 64 byte FIFOs. When AFE is
-	 * enabled, RTS will be deasserted when the receive FIFO contains
-	 * more characters than the trigger, or the MCR RTS bit is cleared.
+	 * MCR-based auto flow control.  When AFE is enabled, RTS will be
+	 * deasserted when the receive FIFO contains more characters than
+	 * the trigger, or the MCR RTS bit is cleared.  In the case where
+	 * the remote UART is not using CTS auto flow control, we must
+	 * have sufficient FIFO entries for the latency of the remote
+	 * UART to respond.  IOW, at least 32 bytes of FIFO.
 	 */
-	if (up->port.type == PORT_16750) {
+	if (up->capabilities & UART_CAP_AFE && up->port.fifosize >= 32) {
 		up->mcr &= ~UART_MCR_AFE;
 		if (termios->c_cflag & CRTSCTS)
 			up->mcr |= UART_MCR_AFE;
-
-		fcr |= UART_FCR7_64BYTE;
 	}
 
 	/*
@@ -1565,9 +1678,17 @@
 	serial_out(up, UART_IER, up->ier);
 
 	if (up->capabilities & UART_CAP_EFR) {
+		unsigned char efr = 0;
+		/*
+		 * TI16C752/Startech hardware flow control.  FIXME:
+		 * - TI16C752 requires control thresholds to be set.
+		 * - UART_MCR_RTS is ineffective if auto-RTS mode is enabled.
+		 */
+		if (termios->c_cflag & CRTSCTS)
+			efr |= UART_EFR_CTS;
+
 		serial_outp(up, UART_LCR, 0xBF);
-		serial_outp(up, UART_EFR,
-			    termios->c_cflag & CRTSCTS ? UART_EFR_CTS :0);
+		serial_outp(up, UART_EFR, efr);
 	}
 
 	if (up->capabilities & UART_NATSEMI) {
@@ -1613,147 +1734,130 @@
 }
 
 /*
- * Resource handling.  This is complicated by the fact that resources
- * depend on the port type.  Maybe we should be claiming the standard
- * 8250 ports, and then trying to get other resources as necessary?
+ * Resource handling.
  */
-static int
-serial8250_request_std_resource(struct uart_8250_port *up, struct resource **res)
+static int serial8250_request_std_resource(struct uart_8250_port *up)
 {
 	unsigned int size = 8 << up->port.regshift;
 	int ret = 0;
 
 	switch (up->port.iotype) {
 	case UPIO_MEM:
-		if (up->port.mapbase) {
-			*res = request_mem_region(up->port.mapbase, size, "serial");
-			if (!*res)
-				ret = -EBUSY;
+		if (!up->port.mapbase)
+			break;
+
+		if (!request_mem_region(up->port.mapbase, size, "serial")) {
+			ret = -EBUSY;
+			break;
+		}
+
+		if (up->port.flags & UPF_IOREMAP) {
+			up->port.membase = ioremap(up->port.mapbase, size);
+			if (!up->port.membase) {
+				release_mem_region(up->port.mapbase, size);
+				ret = -ENOMEM;
+			}
 		}
 		break;
 
 	case UPIO_HUB6:
 	case UPIO_PORT:
-		*res = request_region(up->port.iobase, size, "serial");
-		if (!*res)
+		if (!request_region(up->port.iobase, size, "serial"))
 			ret = -EBUSY;
 		break;
 	}
 	return ret;
 }
 
-static int
-serial8250_request_rsa_resource(struct uart_8250_port *up, struct resource **res)
+static void serial8250_release_std_resource(struct uart_8250_port *up)
 {
 	unsigned int size = 8 << up->port.regshift;
-	unsigned long start;
-	int ret = 0;
 
 	switch (up->port.iotype) {
 	case UPIO_MEM:
-		if (up->port.mapbase) {
-			start = up->port.mapbase;
-			start += UART_RSA_BASE << up->port.regshift;
-			*res = request_mem_region(start, size, "serial-rsa");
-			if (!*res)
-				ret = -EBUSY;
+		if (!up->port.mapbase)
+			break;
+
+		if (up->port.flags & UPF_IOREMAP) {
+			iounmap(up->port.membase);
+			up->port.membase = NULL;
 		}
+
+		release_mem_region(up->port.mapbase, size);
 		break;
 
 	case UPIO_HUB6:
 	case UPIO_PORT:
-		start = up->port.iobase;
-		start += UART_RSA_BASE << up->port.regshift;
-		*res = request_region(start, size, "serial-rsa");
-		if (!*res)
-			ret = -EBUSY;
+		release_region(up->port.iobase, size);
 		break;
 	}
-
-	return ret;
 }
 
-static void serial8250_release_port(struct uart_port *port)
+static int serial8250_request_rsa_resource(struct uart_8250_port *up)
 {
-	struct uart_8250_port *up = (struct uart_8250_port *)port;
-	unsigned long start, offset = 0, size = 0;
-
-	if (up->port.type == PORT_RSA) {
-		offset = UART_RSA_BASE << up->port.regshift;
-		size = 8;
-	}
-
-	size <<= up->port.regshift;
+	unsigned long start = UART_RSA_BASE << up->port.regshift;
+	unsigned int size = 8 << up->port.regshift;
+	int ret = 0;
 
 	switch (up->port.iotype) {
 	case UPIO_MEM:
-		if (up->port.mapbase) {
-			/*
-			 * Unmap the area.
-			 */
-			iounmap(up->port.membase);
-			up->port.membase = NULL;
-
-			start = up->port.mapbase;
-
-			if (size)
-				release_mem_region(start + offset, size);
-			release_mem_region(start, 8 << up->port.regshift);
-		}
+		ret = -EINVAL;
 		break;
 
 	case UPIO_HUB6:
 	case UPIO_PORT:
-		start = up->port.iobase;
+		start += up->port.iobase;
+		if (!request_region(start, size, "serial-rsa"))
+			ret = -EBUSY;
+		break;
+	}
+
+	return ret;
+}
+
+static void serial8250_release_rsa_resource(struct uart_8250_port *up)
+{
+	unsigned long offset = UART_RSA_BASE << up->port.regshift;
+	unsigned int size = 8 << up->port.regshift;
 
-		if (size)
-			release_region(start + offset, size);
-		release_region(start + offset, 8 << up->port.regshift);
+	switch (up->port.iotype) {
+	case UPIO_MEM:
 		break;
 
-	default:
+	case UPIO_HUB6:
+	case UPIO_PORT:
+		release_region(up->port.iobase + offset, size);
 		break;
 	}
 }
 
+static void serial8250_release_port(struct uart_port *port)
+{
+	struct uart_8250_port *up = (struct uart_8250_port *)port;
+
+	serial8250_release_std_resource(up);
+	if (up->port.type == PORT_RSA)
+		serial8250_release_rsa_resource(up);
+}
+
 static int serial8250_request_port(struct uart_port *port)
 {
 	struct uart_8250_port *up = (struct uart_8250_port *)port;
-	struct resource *res = NULL, *res_rsa = NULL;
 	int ret = 0;
 
-	if (up->port.type == PORT_RSA) {
-		ret = serial8250_request_rsa_resource(up, &res_rsa);
+	ret = serial8250_request_std_resource(up);
+	if (ret == 0 && up->port.type == PORT_RSA) {
+		ret = serial8250_request_rsa_resource(up);
 		if (ret < 0)
-			return ret;
+			serial8250_release_std_resource(up);
 	}
 
-	ret = serial8250_request_std_resource(up, &res);
-
-	/*
-	 * If we have a mapbase, then request that as well.
-	 */
-	if (ret == 0 && up->port.flags & UPF_IOREMAP) {
-		int size = res->end - res->start + 1;
-
-		up->port.membase = ioremap(up->port.mapbase, size);
-		if (!up->port.membase)
-			ret = -ENOMEM;
-	}
-
-	if (ret < 0) {
-		if (res_rsa)
-			release_resource(res_rsa);
-		if (res)
-			release_resource(res);
-	}
 	return ret;
 }
 
 static void serial8250_config_port(struct uart_port *port, int flags)
 {
 	struct uart_8250_port *up = (struct uart_8250_port *)port;
-	struct resource *res_std = NULL, *res_rsa = NULL;
 	int probeflags = PROBE_ANY;
 	int ret;
 
@@ -1769,11 +1873,11 @@
 	 * Find the region that we can probe for.  This in turn
 	 * tells us whether we can probe for the type of port.
 	 */
-	ret = serial8250_request_std_resource(up, &res_std);
+	ret = serial8250_request_std_resource(up);
 	if (ret < 0)
 		return;
 
-	ret = serial8250_request_rsa_resource(up, &res_rsa);
+	ret = serial8250_request_rsa_resource(up);
 	if (ret < 0)
 		probeflags &= ~PROBE_RSA;
 
@@ -1782,14 +1886,10 @@
 	if (up->port.type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ)
 		autoconfig_irq(up);
 
-	/*
-	 * If the port wasn't an RSA port, release the resource.
-	 */
-	if (up->port.type != PORT_RSA && res_rsa)
-		release_resource(res_rsa);
-
-	if (up->port.type == PORT_UNKNOWN && res_std)
-		release_resource(res_std);
+	if (up->port.type != PORT_RSA && probeflags & PROBE_RSA)
+		serial8250_release_rsa_resource(up);
+	if (up->port.type == PORT_UNKNOWN)
+		serial8250_release_std_resource(up);
 }
 
 static int
@@ -1797,7 +1897,7 @@
 {
 	if (ser->irq >= NR_IRQS || ser->irq < 0 ||
 	    ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
-	    ser->type > PORT_MAX_8250 || ser->type == PORT_CIRRUS ||
+	    ser->type >= ARRAY_SIZE(uart_config) || ser->type == PORT_CIRRUS ||
 	    ser->type == PORT_STARTECH)
 		return -EINVAL;
 	return 0;
@@ -1845,6 +1945,24 @@
 		return;
 	first = 0;
 
+	for (i = 0; i < UART_NR; i++) {
+		struct uart_8250_port *up = &serial8250_ports[i];
+
+		up->port.line = i;
+		spin_lock_init(&up->port.lock);
+
+		init_timer(&up->timer);
+		up->timer.function = serial8250_timeout;
+
+		/*
+		 * ALPHA_KLUDGE_MCR needs to be killed.
+		 */
+		up->mcr_mask = ~ALPHA_KLUDGE_MCR;
+		up->mcr_force = ALPHA_KLUDGE_MCR;
+
+		up->port.ops = &serial8250_pops;
+	}
+
 	for (i = 0, up = serial8250_ports; i < ARRAY_SIZE(old_serial_port);
 	     i++, up++) {
 		up->port.iobase   = old_serial_port[i].port;
@@ -1855,13 +1973,13 @@
 		up->port.membase  = old_serial_port[i].iomem_base;
 		up->port.iotype   = old_serial_port[i].io_type;
 		up->port.regshift = old_serial_port[i].iomem_reg_shift;
-		up->port.ops      = &serial8250_pops;
 		if (share_irqs)
 			up->port.flags |= UPF_SHARE_IRQ;
 	}
 }
 
-static void __init serial8250_register_ports(struct uart_driver *drv)
+static void __init
+serial8250_register_ports(struct uart_driver *drv, struct device *dev)
 {
 	int i;
 
@@ -1870,17 +1988,7 @@
 	for (i = 0; i < UART_NR; i++) {
 		struct uart_8250_port *up = &serial8250_ports[i];
 
-		up->port.line = i;
-		up->port.ops = &serial8250_pops;
-		init_timer(&up->timer);
-		up->timer.function = serial8250_timeout;
-
-		/*
-		 * ALPHA_KLUDGE_MCR needs to be killed.
-		 */
-		up->mcr_mask = ~ALPHA_KLUDGE_MCR;
-		up->mcr_force = ALPHA_KLUDGE_MCR;
-
+		up->port.dev = dev;
 		uart_add_one_port(drv, &up->port);
 	}
 }
@@ -1965,7 +2073,7 @@
 	serial_out(up, UART_IER, ier);
 }
 
-static int __init serial8250_console_setup(struct console *co, char *options)
+static int serial8250_console_setup(struct console *co, char *options)
 {
 	struct uart_port *port;
 	int baud = 9600;
@@ -1981,14 +2089,9 @@
 	if (co->index >= UART_NR)
 		co->index = 0;
 	port = &serial8250_ports[co->index].port;
-	if (!port->ops)
+	if (!port->iobase && !port->membase)
 		return -ENODEV;
 
-	/*
-	 * Temporary fix.
-	 */
-	spin_lock_init(&port->lock);
-
 	if (options)
 		uart_parse_options(options, &baud, &parity, &bits, &flow);
 
@@ -2022,6 +2125,41 @@
 }
 late_initcall(serial8250_late_console_init);
 
+static int __init find_port(struct uart_port *p)
+{
+	int line;
+	struct uart_port *port;
+
+	for (line = 0; line < UART_NR; line++) {
+		port = &serial8250_ports[line].port;
+		if (p->iotype == port->iotype &&
+		    p->iobase == port->iobase &&
+		    p->membase == port->membase)
+			return line;
+	}
+	return -ENODEV;
+}
+
+int __init serial8250_start_console(struct uart_port *port, char *options)
+{
+	int line;
+
+	line = find_port(port);
+	if (line < 0)
+		return -ENODEV;
+
+	add_preferred_console("ttyS", line, options);
+	printk("Adding console on ttyS%d at %s 0x%lx (options '%s')\n",
+		line, port->iotype == UPIO_MEM ? "MMIO" : "I/O port",
+		port->iotype == UPIO_MEM ? (unsigned long) port->mapbase :
+		    (unsigned long) port->iobase, options);
+	if (!(serial8250_console.flags & CON_ENABLED)) {
+		serial8250_console.flags &= ~CON_PRINTBUFFER;
+		register_console(&serial8250_console);
+	}
+	return line;
+}
+
 #define SERIAL8250_CONSOLE	&serial8250_console
 #else
 #define SERIAL8250_CONSOLE	NULL
@@ -2038,120 +2176,267 @@
 	.cons			= SERIAL8250_CONSOLE,
 };
 
-/*
- * register_serial and unregister_serial allows for 16x50 serial ports to be
- * configured at run-time, to support PCMCIA modems.
+int __init early_serial_setup(struct uart_port *port)
+{
+	if (port->line >= ARRAY_SIZE(serial8250_ports))
+		return -ENODEV;
+
+	serial8250_isa_init_ports();
+	serial8250_ports[port->line].port	= *port;
+	serial8250_ports[port->line].port.ops	= &serial8250_pops;
+	return 0;
+}
+
+/**
+ *	serial8250_suspend_port - suspend one serial port
+ *	@line:  serial line number
+ *      @level: the level of port suspension, as per uart_suspend_port
+ *
+ *	Suspend one serial port.
+ */
+void serial8250_suspend_port(int line)
+{
+	uart_suspend_port(&serial8250_reg, &serial8250_ports[line].port);
+}
+
+/**
+ *	serial8250_resume_port - resume one serial port
+ *	@line:  serial line number
+ *      @level: the level of port resumption, as per uart_resume_port
+ *
+ *	Resume one serial port.
  */
+void serial8250_resume_port(int line)
+{
+	uart_resume_port(&serial8250_reg, &serial8250_ports[line].port);
+}
 
-static int __register_serial(struct serial_struct *req, int line)
+/*
+ * Register a set of serial devices attached to a platform device.  The
+ * list is terminated with a zero flags entry, which means we expect
+ * all entries to have at least UPF_BOOT_AUTOCONF set.
+ */
+static int __devinit serial8250_probe(struct device *dev)
 {
+	struct plat_serial8250_port *p = dev->platform_data;
 	struct uart_port port;
 
-	port.iobase   = req->port;
-	port.membase  = req->iomem_base;
-	port.irq      = req->irq;
-	port.uartclk  = req->baud_base * 16;
-	port.fifosize = req->xmit_fifo_size;
-	port.regshift = req->iomem_reg_shift;
-	port.iotype   = req->io_type;
-	port.flags    = req->flags | UPF_BOOT_AUTOCONF;
-	port.mapbase  = req->iomap_base;
-	port.line     = line;
+	memset(&port, 0, sizeof(struct uart_port));
 
-	if (share_irqs)
-		port.flags |= UPF_SHARE_IRQ;
+	for (; p && p->flags != 0; p++) {
+		port.iobase	= p->iobase;
+		port.membase	= p->membase;
+		port.irq	= p->irq;
+		port.uartclk	= p->uartclk;
+		port.regshift	= p->regshift;
+		port.iotype	= p->iotype;
+		port.flags	= p->flags;
+		port.mapbase	= p->mapbase;
+		port.dev	= dev;
+		if (share_irqs)
+			port.flags |= UPF_SHARE_IRQ;
+		serial8250_register_port(&port);
+	}
+	return 0;
+}
 
-	if (HIGH_BITS_OFFSET)
-		port.iobase |= (long) req->port_high << HIGH_BITS_OFFSET;
+/*
+ * Remove serial ports registered against a platform device.
+ */
+static int __devexit serial8250_remove(struct device *dev)
+{
+	int i;
 
-	/*
-	 * If a clock rate wasn't specified by the low level
-	 * driver, then default to the standard clock rate.
-	 */
-	if (port.uartclk == 0)
-		port.uartclk = BASE_BAUD * 16;
+	for (i = 0; i < UART_NR; i++) {
+		struct uart_8250_port *up = &serial8250_ports[i];
 
-	return uart_register_port(&serial8250_reg, &port);
+		if (up->port.dev == dev)
+			serial8250_unregister_port(i);
+	}
+	return 0;
 }
 
-/**
- *	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 necessary 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)
+static int serial8250_suspend(struct device *dev, u32 state, u32 level)
 {
-	return __register_serial(req, -1);
+	int i;
+
+	if (level != SUSPEND_DISABLE)
+		return 0;
+
+	for (i = 0; i < UART_NR; i++) {
+		struct uart_8250_port *up = &serial8250_ports[i];
+
+		if (up->port.type != PORT_UNKNOWN && up->port.dev == dev)
+			uart_suspend_port(&serial8250_reg, &up->port);
+	}
+
+	return 0;
 }
 
-int __init early_serial_setup(struct uart_port *port)
+static int serial8250_resume(struct device *dev, u32 level)
 {
-	if (port->line >= ARRAY_SIZE(serial8250_ports))
-		return -ENODEV;
+	int i;
+
+	if (level != RESUME_ENABLE)
+		return 0;
+
+	for (i = 0; i < UART_NR; i++) {
+		struct uart_8250_port *up = &serial8250_ports[i];
+
+		if (up->port.type != PORT_UNKNOWN && up->port.dev == dev)
+			uart_resume_port(&serial8250_reg, &up->port);
+	}
 
-	serial8250_isa_init_ports();
-	serial8250_ports[port->line].port	= *port;
-	serial8250_ports[port->line].port.ops	= &serial8250_pops;
 	return 0;
 }
 
-/**
- *	unregister_serial - remove a 16x50 serial port at runtime
- *	@line: serial line number
- *
- *	Remove one serial port.  This may be called from interrupt
- *	context.
+static struct device_driver serial8250_isa_driver = {
+	.name		= "serial8250",
+	.bus		= &platform_bus_type,
+	.probe		= serial8250_probe,
+	.remove		= __devexit_p(serial8250_remove),
+	.suspend	= serial8250_suspend,
+	.resume		= serial8250_resume,
+};
+
+/*
+ * This "device" covers _all_ ISA 8250-compatible serial devices listed
+ * in the table in include/asm/serial.h
  */
-void unregister_serial(int line)
-{
-	uart_unregister_port(&serial8250_reg, line);
-}
+static struct platform_device *serial8250_isa_devs;
+
+/*
+ * serial8250_register_port and serial8250_unregister_port allows for
+ * 16x50 serial ports to be configured at run-time, to support PCMCIA
+ * modems and PCI multiport cards.
+ */
+static DECLARE_MUTEX(serial_sem);
 
 /*
- * This is for ISAPNP only.
+ *	Are the two ports equivalent?
  */
-void serial8250_get_irq_map(unsigned int *map)
+static int uart_match_port(struct uart_port *port1, struct uart_port *port2)
 {
-	int i;
+	if (port1->iotype != port2->iotype)
+		return 0;
 
-	for (i = 0; i < UART_NR; i++) {
-		if (serial8250_ports[i].port.type != PORT_UNKNOWN &&
-		    serial8250_ports[i].port.irq < 16)
-			*map |= 1 << serial8250_ports[i].port.irq;
+	switch (port1->iotype) {
+	case UPIO_PORT:
+		return (port1->iobase == port2->iobase);
+	case UPIO_HUB6:
+		return (port1->iobase == port2->iobase) &&
+		       (port1->hub6   == port2->hub6);
+	case UPIO_MEM:
+		return (port1->membase == port2->membase);
 	}
+	return 0;
+}
+
+static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port)
+{
+	int i;
+
+	/*
+	 * First, find a port entry which matches.
+	 */
+	for (i = 0; i < UART_NR; i++)
+		if (uart_match_port(&serial8250_ports[i].port, port))
+			return &serial8250_ports[i];
+
+	/*
+	 * We didn't find a matching entry, so look for the first
+	 * free entry.  We look for one which hasn't been previously
+	 * used (indicated by zero iobase).
+	 */
+	for (i = 0; i < UART_NR; i++)
+		if (serial8250_ports[i].port.type == PORT_UNKNOWN &&
+		    serial8250_ports[i].port.iobase == 0)
+			return &serial8250_ports[i];
+
+	/*
+	 * That also failed.  Last resort is to find any entry which
+	 * doesn't have a real port associated with it.
+	 */
+	for (i = 0; i < UART_NR; i++)
+		if (serial8250_ports[i].port.type == PORT_UNKNOWN)
+			return &serial8250_ports[i];
+
+	return NULL;
 }
 
 /**
- *	serial8250_suspend_port - suspend one serial port
- *	@line:  serial line number
- *      @level: the level of port suspension, as per uart_suspend_port
+ *	serial8250_register_port - register a serial port
+ *	@port: serial port template
  *
- *	Suspend one serial port.
+ *	Configure the serial port specified by the request. If the
+ *	port exists and is in use, it is hung up and unregistered
+ *	first.
+ *
+ *	The port is then probed and if necessary 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.
  */
-void serial8250_suspend_port(int line)
+int serial8250_register_port(struct uart_port *port)
 {
-	uart_suspend_port(&serial8250_reg, &serial8250_ports[line].port);
+	struct uart_8250_port *uart;
+	int ret = -ENOSPC;
+
+	if (port->uartclk == 0)
+		return -EINVAL;
+
+	down(&serial_sem);
+
+	uart = serial8250_find_match_or_unused(port);
+	if (uart) {
+		uart_remove_one_port(&serial8250_reg, &uart->port);
+
+		uart->port.iobase   = port->iobase;
+		uart->port.membase  = port->membase;
+		uart->port.irq      = port->irq;
+		uart->port.uartclk  = port->uartclk;
+		uart->port.fifosize = port->fifosize;
+		uart->port.regshift = port->regshift;
+		uart->port.iotype   = port->iotype;
+		uart->port.flags    = port->flags | UPF_BOOT_AUTOCONF;
+		uart->port.mapbase  = port->mapbase;
+		if (port->dev)
+			uart->port.dev = port->dev;
+
+		ret = uart_add_one_port(&serial8250_reg, &uart->port);
+		if (ret == 0)
+			ret = uart->port.line;
+	}
+	up(&serial_sem);
+
+	return ret;
 }
+EXPORT_SYMBOL(serial8250_register_port);
 
 /**
- *	serial8250_resume_port - resume one serial port
- *	@line:  serial line number
- *      @level: the level of port resumption, as per uart_resume_port
+ *	serial8250_unregister_port - remove a 16x50 serial port at runtime
+ *	@line: serial line number
  *
- *	Resume one serial port.
+ *	Remove one serial port.  This may not be called from interrupt
+ *	context.  We hand the port back to the our control.
  */
-void serial8250_resume_port(int line)
+void serial8250_unregister_port(int line)
 {
-	uart_resume_port(&serial8250_reg, &serial8250_ports[line].port);
+	struct uart_8250_port *uart = &serial8250_ports[line];
+
+	down(&serial_sem);
+	uart_remove_one_port(&serial8250_reg, &uart->port);
+	if (serial8250_isa_devs) {
+		uart->port.flags &= ~UPF_BOOT_AUTOCONF;
+		uart->port.type = PORT_UNKNOWN;
+		uart->port.dev = &serial8250_isa_devs->dev;
+		uart_add_one_port(&serial8250_reg, &uart->port);
+	} else {
+		uart->port.dev = NULL;
+	}
+	up(&serial_sem);
 }
+EXPORT_SYMBOL(serial8250_unregister_port);
 
 static int __init serial8250_init(void)
 {
@@ -2165,18 +2450,42 @@
 		spin_lock_init(&irq_lists[i].lock);
 
 	ret = uart_register_driver(&serial8250_reg);
-	if (ret >= 0)
-		serial8250_register_ports(&serial8250_reg);
+	if (ret)
+		goto out;
 
+	serial8250_isa_devs = platform_device_register_simple("serial8250",
+							      -1, NULL, 0);
+	if (IS_ERR(serial8250_isa_devs)) {
+		ret = PTR_ERR(serial8250_isa_devs);
+		goto unreg;
+	}
+
+	serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev);
+
+	ret = driver_register(&serial8250_isa_driver);
+	if (ret == 0)
+		goto out;
+
+	platform_device_unregister(serial8250_isa_devs);
+ unreg:
+	uart_unregister_driver(&serial8250_reg);
+ out:
 	return ret;
 }
 
 static void __exit serial8250_exit(void)
 {
-	int i;
+	struct platform_device *isa_dev = serial8250_isa_devs;
 
-	for (i = 0; i < UART_NR; i++)
-		uart_remove_one_port(&serial8250_reg, &serial8250_ports[i].port);
+	/*
+	 * This tells serial8250_unregister_port() not to re-register
+	 * the ports (thereby making serial8250_isa_driver permanently
+	 * in use.)
+	 */
+	serial8250_isa_devs = NULL;
+
+	driver_unregister(&serial8250_isa_driver);
+	platform_device_unregister(isa_dev);
 
 	uart_unregister_driver(&serial8250_reg);
 }
@@ -2184,9 +2493,6 @@
 module_init(serial8250_init);
 module_exit(serial8250_exit);
 
-EXPORT_SYMBOL(register_serial);
-EXPORT_SYMBOL(unregister_serial);
-EXPORT_SYMBOL(serial8250_get_irq_map);
 EXPORT_SYMBOL(serial8250_suspend_port);
 EXPORT_SYMBOL(serial8250_resume_port);
 
@@ -2198,7 +2504,80 @@
 	" (unsafe)");
 
 #ifdef CONFIG_SERIAL_8250_RSA
-module_param_array(probe_rsa, ulong, probe_rsa_count, 0444);
+module_param_array(probe_rsa, ulong, &probe_rsa_count, 0444);
 MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA");
 #endif
 MODULE_ALIAS_CHARDEV_MAJOR(TTY_MAJOR);
+
+/**
+ *	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 necessary 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)
+{
+	struct uart_port port;
+
+	port.iobase   = req->port;
+	port.membase  = req->iomem_base;
+	port.irq      = req->irq;
+	port.uartclk  = req->baud_base * 16;
+	port.fifosize = req->xmit_fifo_size;
+	port.regshift = req->iomem_reg_shift;
+	port.iotype   = req->io_type;
+	port.flags    = req->flags | UPF_BOOT_AUTOCONF;
+	port.mapbase  = req->iomap_base;
+	port.dev      = NULL;
+
+	if (share_irqs)
+		port.flags |= UPF_SHARE_IRQ;
+
+	if (HIGH_BITS_OFFSET)
+		port.iobase |= (long) req->port_high << HIGH_BITS_OFFSET;
+
+	/*
+	 * If a clock rate wasn't specified by the low level driver, then
+	 * default to the standard clock rate.  This should be 115200 (*16)
+	 * and should not depend on the architecture's BASE_BAUD definition.
+	 * However, since this API will be deprecated, it's probably a
+	 * better idea to convert the drivers to use the new API
+	 * (serial8250_register_port and serial8250_unregister_port).
+	 */
+	if (port.uartclk == 0) {
+		printk(KERN_WARNING
+		       "Serial: registering port at [%08x,%08lx,%p] irq %d with zero baud_base\n",
+		       port.iobase, port.mapbase, port.membase, port.irq);
+		printk(KERN_WARNING "Serial: see %s:%d for more information\n",
+		       __FILE__, __LINE__);
+		dump_stack();
+
+		/*
+		 * Fix it up for now, but this is only a temporary measure.
+		 */
+		port.uartclk = BASE_BAUD * 16;
+	}
+
+	return serial8250_register_port(&port);
+}
+EXPORT_SYMBOL(register_serial);
+
+/**
+ *	unregister_serial - remove a 16x50 serial port at runtime
+ *	@line: serial line number
+ *
+ *	Remove one serial port.  This may not be called from interrupt
+ *	context.  We hand the port back to our local PM control.
+ */
+void unregister_serial(int line)
+{
+	serial8250_unregister_port(line);
+}
+EXPORT_SYMBOL(unregister_serial);
diff -Nru a/drivers/serial/8250.h b/drivers/serial/8250.h
--- a/drivers/serial/8250.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/serial/8250.h	2004-12-24 13:36:16 -08:00
@@ -17,7 +17,8 @@
 
 #include <linux/config.h>
 
-void serial8250_get_irq_map(unsigned int *map);
+int serial8250_register_port(struct uart_port *);
+void serial8250_unregister_port(int line);
 void serial8250_suspend_port(int line);
 void serial8250_resume_port(int line);
 
@@ -38,14 +39,16 @@
  */
 struct serial8250_config {
 	const char	*name;
-	unsigned int	fifo_size;
-	unsigned int	tx_loadsz;
+	unsigned short	fifo_size;
+	unsigned short	tx_loadsz;
+	unsigned char	fcr;
 	unsigned int	flags;
 };
 
 #define UART_CAP_FIFO	(1 << 8)	/* UART has FIFO */
 #define UART_CAP_EFR	(1 << 9)	/* UART has EFR */
 #define UART_CAP_SLEEP	(1 << 10)	/* UART has IER sleep */
+#define UART_CAP_AFE	(1 << 11)	/* MCR-based hw flow control */
 
 #undef SERIAL_DEBUG_PCI
 
@@ -68,4 +71,15 @@
 #define SERIAL8250_SHARE_IRQS 1
 #else
 #define SERIAL8250_SHARE_IRQS 0
+#endif
+
+#if defined(__alpha__) && !defined(CONFIG_PCI)
+/*
+ * Digital did something really horribly wrong with the OUT1 and OUT2
+ * lines on at least some ALPHA's.  The failure mode is that if either
+ * is cleared, the machine locks up with endless interrupts.
+ */
+#define ALPHA_KLUDGE_MCR  (UART_MCR_OUT2 | UART_MCR_OUT1)
+#else
+#define ALPHA_KLUDGE_MCR 0
 #endif
diff -Nru a/drivers/serial/8250_acorn.c b/drivers/serial/8250_acorn.c
--- a/drivers/serial/8250_acorn.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/serial/8250_acorn.c	2004-12-24 13:37:18 -08:00
@@ -11,7 +11,6 @@
 #include <linux/types.h>
 #include <linux/tty.h>
 #include <linux/serial_core.h>
-#include <linux/serial.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
@@ -22,11 +21,13 @@
 #include <asm/ecard.h>
 #include <asm/string.h>
 
+#include "8250.h"
+
 #define MAX_PORTS	3
 
 struct serial_card_type {
 	unsigned int	num_ports;
-	unsigned int	baud_base;
+	unsigned int	uartclk;
 	unsigned int	type;
 	unsigned int	offset[MAX_PORTS];
 };
@@ -36,31 +37,15 @@
 	int		ports[MAX_PORTS];
 };
 
-static inline int
-serial_register_onedev(unsigned long baddr, void *vaddr, int irq, unsigned int baud_base)
-{
-	struct serial_struct req;
-
-	memset(&req, 0, sizeof(req));
-	req.irq			= irq;
-	req.flags		= UPF_AUTOPROBE | UPF_SHARE_IRQ;
-	req.baud_base		= baud_base;
-	req.io_type		= UPIO_MEM;
-	req.iomem_base		= vaddr;
-	req.iomem_reg_shift	= 2;
-	req.iomap_base		= baddr;
-
-	return register_serial(&req);
-}
-
 static int __devinit
 serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
 {
 	struct serial_card_info *info;
 	struct serial_card_type *type = id->data;
+	struct uart_port port;
 	unsigned long bus_addr;
-	unsigned char *virt_addr;
-	unsigned int port;
+	unsigned char __iomem *virt_addr;
+	unsigned int i;
 
 	info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL);
 	if (!info)
@@ -69,21 +54,28 @@
 	memset(info, 0, sizeof(struct serial_card_info));
 	info->num_ports = type->num_ports;
 
-	ecard_set_drvdata(ec, info);
-
-	bus_addr = ec->resource[type->type].start;
-	virt_addr = ioremap(bus_addr, ec->resource[type->type].end - bus_addr + 1);
+	bus_addr = ecard_resource_start(ec, type->type);
+	virt_addr = ioremap(bus_addr, ecard_resource_len(ec, type->type));
 	if (!virt_addr) {
 		kfree(info);
 		return -ENOMEM;
 	}
 
-	for (port = 0; port < info->num_ports; port ++) {
-		unsigned long baddr = bus_addr + type->offset[port];
-		unsigned char *vaddr = virt_addr + type->offset[port];
+	ecard_set_drvdata(ec, info);
+
+	memset(&port, 0, sizeof(struct uart_port));
+	port.irq	= ec->irq;
+	port.flags	= UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
+	port.uartclk	= type->uartclk;
+	port.iotype	= UPIO_MEM;
+	port.regshift	= 2;
+	port.dev	= &ec->dev;
+
+	for (i = 0; i < info->num_ports; i ++) {
+		port.membase = virt_addr + type->offset[i];
+		port.mapbase = bus_addr + type->offset[i];
 
-		info->ports[port] = serial_register_onedev(baddr, vaddr,
-						ec->irq, type->baud_base);
+		info->ports[i] = serial8250_register_port(&port);
 	}
 
 	return 0;
@@ -98,21 +90,21 @@
 
 	for (i = 0; i < info->num_ports; i++)
 		if (info->ports[i] > 0)
-			unregister_serial(info->ports[i]);
+			serial8250_unregister_port(info->ports[i]);
 
 	kfree(info);
 }
 
 static struct serial_card_type atomwide_type = {
 	.num_ports	= 3,
-	.baud_base	= 7372800 / 16,
+	.uartclk	= 7372800,
 	.type		= ECARD_RES_IOCSLOW,
 	.offset		= { 0x2800, 0x2400, 0x2000 },
 };
 
 static struct serial_card_type serport_type = {
 	.num_ports	= 2,
-	.baud_base	= 3686400 / 16,
+	.uartclk	= 3686400,
 	.type		= ECARD_RES_IOCSLOW,
 	.offset		= { 0x2000, 0x2020 },
 };
@@ -128,7 +120,7 @@
 	.remove 	= __devexit_p(serial_card_remove),
 	.id_table	= serial_cids,
 	.drv = {
-		.name		= "8250_acorn",
+		.name	= "8250_acorn",
 	},
 };
 
diff -Nru a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c
--- a/drivers/serial/8250_acpi.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/serial/8250_acpi.c	2004-12-24 13:37:29 -08:00
@@ -12,81 +12,71 @@
 #include <linux/acpi.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
 #include <linux/serial_core.h>
 
 #include <acpi/acpi_bus.h>
 
 #include <asm/io.h>
-#include <asm/serial.h>
+
+#include "8250.h"
 
 struct serial_private {
 	int	line;
-	void	*iomem_base;
 };
 
-static acpi_status acpi_serial_mmio(struct serial_struct *req,
+static acpi_status acpi_serial_mmio(struct uart_port *port,
 				    struct acpi_resource_address64 *addr)
 {
-	unsigned long size;
-
-	size = addr->max_address_range - addr->min_address_range + 1;
-	req->iomap_base = addr->min_address_range;
-	req->iomem_base = ioremap(req->iomap_base, size);
-	if (!req->iomem_base) {
-		printk(KERN_ERR "%s: couldn't ioremap 0x%lx-0x%lx\n",
-			__FUNCTION__, req->iomap_base, req->iomap_base + size);
-		return AE_ERROR;
-	}
-	req->io_type = SERIAL_IO_MEM;
+	port->mapbase = addr->min_address_range;
+	port->iotype = UPIO_MEM;
+	port->flags |= UPF_IOREMAP;
 	return AE_OK;
 }
 
-static acpi_status acpi_serial_port(struct serial_struct *req,
+static acpi_status acpi_serial_port(struct uart_port *port,
 				    struct acpi_resource_io *io)
 {
 	if (io->range_length) {
-		req->port = io->min_base_address;
-		req->io_type = SERIAL_IO_PORT;
+		port->iobase = io->min_base_address;
+		port->iotype = UPIO_PORT;
 	} else
 		printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__);
 	return AE_OK;
 }
 
-static acpi_status acpi_serial_ext_irq(struct serial_struct *req,
+static acpi_status acpi_serial_ext_irq(struct uart_port *port,
 				       struct acpi_resource_ext_irq *ext_irq)
 {
 	if (ext_irq->number_of_interrupts > 0)
-		req->irq = acpi_register_gsi(ext_irq->interrupts[0],
-	                  ext_irq->edge_level, ext_irq->active_high_low);
+		port->irq = acpi_register_gsi(ext_irq->interrupts[0],
+	                   ext_irq->edge_level, ext_irq->active_high_low);
 	return AE_OK;
 }
 
-static acpi_status acpi_serial_irq(struct serial_struct *req,
+static acpi_status acpi_serial_irq(struct uart_port *port,
 				   struct acpi_resource_irq *irq)
 {
 	if (irq->number_of_interrupts > 0)
-		req->irq = acpi_register_gsi(irq->interrupts[0],
-	                  irq->edge_level, irq->active_high_low);
+		port->irq = acpi_register_gsi(irq->interrupts[0],
+	                   irq->edge_level, irq->active_high_low);
 	return AE_OK;
 }
 
 static acpi_status acpi_serial_resource(struct acpi_resource *res, void *data)
 {
-	struct serial_struct *serial_req = (struct serial_struct *) data;
+	struct uart_port *port = (struct uart_port *) data;
 	struct acpi_resource_address64 addr;
 	acpi_status status;
 
 	status = acpi_resource_to_address64(res, &addr);
 	if (ACPI_SUCCESS(status))
-		return acpi_serial_mmio(serial_req, &addr);
+		return acpi_serial_mmio(port, &addr);
 	else if (res->id == ACPI_RSTYPE_IO)
-		return acpi_serial_port(serial_req, &res->data.io);
+		return acpi_serial_port(port, &res->data.io);
 	else if (res->id == ACPI_RSTYPE_EXT_IRQ)
-		return acpi_serial_ext_irq(serial_req, &res->data.extended_irq);
+		return acpi_serial_ext_irq(port, &res->data.extended_irq);
 	else if (res->id == ACPI_RSTYPE_IRQ)
-		return acpi_serial_irq(serial_req, &res->data.irq);
+		return acpi_serial_irq(port, &res->data.irq);
 	return AE_OK;
 }
 
@@ -94,10 +84,13 @@
 {
 	struct serial_private *priv;
 	acpi_status status;
-	struct serial_struct serial_req;
+	struct uart_port port;
 	int result;
 
-	memset(&serial_req, 0, sizeof(serial_req));
+	memset(&port, 0, sizeof(struct uart_port));
+
+	port.uartclk = 1843200;
+	port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
 
 	priv = kmalloc(sizeof(struct serial_private), GFP_KERNEL);
 	if (!priv) {
@@ -107,25 +100,20 @@
 	memset(priv, 0, sizeof(*priv));
 
 	status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
-				     acpi_serial_resource, &serial_req);
+				     acpi_serial_resource, &port);
 	if (ACPI_FAILURE(status)) {
 		result = -ENODEV;
 		goto fail;
 	}
 
-	if (serial_req.iomem_base)
-		priv->iomem_base = serial_req.iomem_base;
-	else if (!serial_req.port) {
+	if (!port.mapbase && !port.iobase) {
 		printk(KERN_ERR "%s: no iomem or port address in %s _CRS\n",
 			__FUNCTION__, device->pnp.bus_id);
 		result = -ENODEV;
 		goto fail;
 	}
 
-	serial_req.baud_base = BASE_BAUD;
-	serial_req.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
-
-	priv->line = register_serial(&serial_req);
+	priv->line = serial8250_register_port(&port);
 	if (priv->line < 0) {
 		printk(KERN_WARNING "Couldn't register serial port %s: %d\n",
 			device->pnp.bus_id, priv->line);
@@ -137,8 +125,6 @@
 	return 0;
 
 fail:
-	if (serial_req.iomem_base)
-		iounmap(serial_req.iomem_base);
 	kfree(priv);
 
 	return result;
@@ -152,9 +138,7 @@
 		return -EINVAL;
 
 	priv = acpi_driver_data(device);
-	unregister_serial(priv->line);
-	if (priv->iomem_base)
-		iounmap(priv->iomem_base);
+	serial8250_unregister_port(priv->line);
 	kfree(priv);
 
 	return 0;
diff -Nru a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/serial/8250_early.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,255 @@
+/*
+ * Early serial console for 8250/16550 devices
+ *
+ * (c) Copyright 2004 Hewlett-Packard Development Company, L.P.
+ *	Bjorn Helgaas <bjorn.helgaas@hp.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.
+ *
+ * Based on the 8250.c serial driver, Copyright (C) 2001 Russell King,
+ * and on early_printk.c by Andi Kleen.
+ *
+ * This is for use before the serial driver has initialized, in
+ * particular, before the UARTs have been discovered and named.
+ * Instead of specifying the console device as, e.g., "ttyS0",
+ * we locate the device directly by its MMIO or I/O port address.
+ *
+ * The user can specify the device directly, e.g.,
+ *	console=uart,io,0x3f8,9600n8
+ *	console=uart,mmio,0xff5e0000,115200n8
+ * or platform code can call early_uart_console_init() to set
+ * the early UART device.
+ *
+ * After the normal serial driver starts, we try to locate the
+ * matching ttyS device and start a console there.
+ */
+
+#include <linux/tty.h>
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/serial_core.h>
+#include <linux/serial_reg.h>
+#include <linux/serial.h>
+#include <asm/io.h>
+#include <asm/serial.h>
+
+struct early_uart_device {
+	struct uart_port port;
+	char options[16];		/* e.g., 115200n8 */
+	unsigned int baud;
+};
+
+static struct early_uart_device early_device __initdata;
+static int early_uart_registered __initdata;
+
+static unsigned int __init serial_in(struct uart_port *port, int offset)
+{
+	if (port->iotype == UPIO_MEM)
+		return readb(port->membase + offset);
+	else
+		return inb(port->iobase + offset);
+}
+
+static void __init serial_out(struct uart_port *port, int offset, int value)
+{
+	if (port->iotype == UPIO_MEM)
+		writeb(value, port->membase + offset);
+	else
+		outb(value, port->iobase + offset);
+}
+
+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
+
+static void __init wait_for_xmitr(struct uart_port *port)
+{
+	unsigned int status;
+
+	for (;;) {
+		status = serial_in(port, UART_LSR);
+		if ((status & BOTH_EMPTY) == BOTH_EMPTY)
+			return;
+		cpu_relax();
+	}
+}
+
+static void __init putc(struct uart_port *port, unsigned char c)
+{
+	wait_for_xmitr(port);
+	serial_out(port, UART_TX, c);
+}
+
+static void __init early_uart_write(struct console *console, const char *s, unsigned int count)
+{
+	struct uart_port *port = &early_device.port;
+	unsigned int ier;
+
+	/* Save the IER and disable interrupts */
+	ier = serial_in(port, UART_IER);
+	serial_out(port, UART_IER, 0);
+
+	while (*s && count-- > 0) {
+		putc(port, *s);
+		if (*s == '\n')
+			putc(port, '\r');
+		s++;
+	}
+
+	/* Wait for transmitter to become empty and restore the IER */
+	wait_for_xmitr(port);
+	serial_out(port, UART_IER, ier);
+}
+
+static unsigned int __init probe_baud(struct uart_port *port)
+{
+	unsigned char lcr, dll, dlm;
+	unsigned int quot;
+
+	lcr = serial_in(port, UART_LCR);
+	serial_out(port, UART_LCR, lcr | UART_LCR_DLAB);
+	dll = serial_in(port, UART_DLL);
+	dlm = serial_in(port, UART_DLM);
+	serial_out(port, UART_LCR, lcr);
+
+	quot = (dlm << 8) | dll;
+	return (port->uartclk / 16) / quot;
+}
+
+static void __init init_port(struct early_uart_device *device)
+{
+	struct uart_port *port = &device->port;
+	unsigned int divisor;
+	unsigned char c;
+
+	serial_out(port, UART_LCR, 0x3);	/* 8n1 */
+	serial_out(port, UART_IER, 0);		/* no interrupt */
+	serial_out(port, UART_FCR, 0);		/* no fifo */
+	serial_out(port, UART_MCR, 0x3);	/* DTR + RTS */
+
+	divisor = port->uartclk / (16 * device->baud);
+	c = serial_in(port, UART_LCR);
+	serial_out(port, UART_LCR, c | UART_LCR_DLAB);
+	serial_out(port, UART_DLL, divisor & 0xff);
+	serial_out(port, UART_DLM, (divisor >> 8) & 0xff);
+	serial_out(port, UART_LCR, c & ~UART_LCR_DLAB);
+}
+
+static int __init parse_options(struct early_uart_device *device, char *options)
+{
+	struct uart_port *port = &device->port;
+	int mapsize = 64;
+	int mmio, length;
+
+	if (!options)
+		return -ENODEV;
+
+	port->uartclk = BASE_BAUD * 16;
+	if (!strncmp(options, "mmio,", 5)) {
+		port->iotype = UPIO_MEM;
+		port->mapbase = simple_strtoul(options + 5, &options, 0);
+		port->membase = ioremap(port->mapbase, mapsize);
+		if (!port->membase) {
+			printk(KERN_ERR "%s: Couldn't ioremap 0x%lx\n",
+				__FUNCTION__, port->mapbase);
+			return -ENOMEM;
+		}
+		mmio = 1;
+	} else if (!strncmp(options, "io,", 3)) {
+		port->iotype = UPIO_PORT;
+		port->iobase = simple_strtoul(options + 3, &options, 0);
+		mmio = 0;
+	} else
+		return -EINVAL;
+
+	if ((options = strchr(options, ','))) {
+		options++;
+		device->baud = simple_strtoul(options, 0, 0);
+		length = min(strcspn(options, " "), sizeof(device->options));
+		strncpy(device->options, options, length);
+	} else {
+		device->baud = probe_baud(port);
+		snprintf(device->options, sizeof(device->options), "%u",
+			device->baud);
+	}
+
+	printk(KERN_INFO "Early serial console at %s 0x%lx (options '%s')\n",
+		mmio ? "MMIO" : "I/O port",
+		mmio ? port->mapbase : (unsigned long) port->iobase,
+		device->options);
+	return 0;
+}
+
+static int __init early_uart_setup(struct console *console, char *options)
+{
+	struct early_uart_device *device = &early_device;
+	int err;
+
+	if (device->port.membase || device->port.iobase)
+		return 0;
+
+	if ((err = parse_options(device, options)) < 0)
+		return err;
+
+	init_port(device);
+	return 0;
+}
+
+static struct console early_uart_console __initdata = {
+	.name	= "uart",
+	.write	= early_uart_write,
+	.setup	= early_uart_setup,
+	.flags	= CON_PRINTBUFFER,
+	.index	= -1,
+};
+
+static int __init early_uart_console_init(void)
+{
+	if (!early_uart_registered) {
+		register_console(&early_uart_console);
+		early_uart_registered = 1;
+	}
+	return 0;
+}
+console_initcall(early_uart_console_init);
+
+int __init early_serial_console_init(char *cmdline)
+{
+	char *options;
+	int err;
+
+	options = strstr(cmdline, "console=uart,");
+	if (!options)
+		return -ENODEV;
+
+	options = strchr(cmdline, ',') + 1;
+	if ((err = early_uart_setup(NULL, options)) < 0)
+		return err;
+	return early_uart_console_init();
+}
+
+static int __init early_uart_console_switch(void)
+{
+	struct early_uart_device *device = &early_device;
+	struct uart_port *port = &device->port;
+	int mmio, line;
+
+	if (!(early_uart_console.flags & CON_ENABLED))
+		return 0;
+
+	/* Try to start the normal driver on a matching line.  */
+	mmio = (port->iotype == UPIO_MEM);
+	line = serial8250_start_console(port, device->options);
+	if (line < 0)
+		printk("No ttyS device at %s 0x%lx for console\n",
+			mmio ? "MMIO" : "I/O port",
+			mmio ? port->mapbase :
+			    (unsigned long) port->iobase);
+
+	unregister_console(&early_uart_console);
+	if (mmio)
+		iounmap(port->membase);
+
+	return 0;
+}
+late_initcall(early_uart_console_switch);
diff -Nru a/drivers/serial/8250_gsc.c b/drivers/serial/8250_gsc.c
--- a/drivers/serial/8250_gsc.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/serial/8250_gsc.c	2004-12-24 13:37:03 -08:00
@@ -14,7 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
-#include <linux/serial.h>
+#include <linux/serial_core.h>
 #include <linux/signal.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -22,37 +22,18 @@
 #include <asm/hardware.h>
 #include <asm/parisc-device.h>
 #include <asm/io.h>
-#include <asm/serial.h>
+#include <asm/serial.h> /* for LASI_BASE_BAUD */
 
-static void setup_parisc_serial(struct serial_struct *serial,
-		unsigned long address, int irq, int line)
-{
-	memset(serial, 0, sizeof(struct serial_struct));
-
-	/* autoconfig() sets state->type.  This sets info->type */
-	serial->type = PORT_16550A;
-
-	serial->line = line;
-	serial->iomap_base = address;
-	serial->iomem_base = ioremap(address, 0x8);
-
-	serial->irq = irq;
-	serial->io_type = SERIAL_IO_MEM;	/* define access method */
-	serial->flags = 0;
-	serial->xmit_fifo_size = 16;
-	serial->custom_divisor = 0;
-	serial->baud_base = LASI_BASE_BAUD;
-}
+#include "8250.h"
 
 static int __init 
 serial_init_chip(struct parisc_device *dev)
 {
 	static int serial_line_nr;
+	struct uart_port port;
 	unsigned long address;
 	int err;
 
-	struct serial_struct *serial;
-
 	if (!dev->irq) {
 		/* We find some unattached serial ports by walking native
 		 * busses.  These should be silently ignored.  Otherwise,
@@ -66,21 +47,23 @@
 		return -ENODEV;
 	}
 
-	serial = kmalloc(sizeof(*serial), GFP_KERNEL);
-	if (!serial)
-		return -ENOMEM;
-
 	address = dev->hpa;
 	if (dev->id.sversion != 0x8d) {
 		address += 0x800;
 	}
 
-	setup_parisc_serial(serial, address, dev->irq, serial_line_nr++);
-	err = register_serial(serial);
+	memset(&port, 0, sizeof(struct uart_port));
+	port.mapbase = address;
+	port.irq = dev->irq;
+	port.iotype = UPIO_MEM;
+	port.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
+	port.uartclk = LASI_BASE_BAUD * 16;
+	port.dev = &dev->dev;
+
+	err = serial8250_register_port(&port);
 	if (err < 0) {
-		printk(KERN_WARNING "register_serial returned error %d\n", err);
-		kfree(serial);
-		return -ENODEV;
+		printk(KERN_WARNING "serial8250_register_port returned error %d\n", err);
+		return err;
 	}
 
 	return 0;
diff -Nru a/drivers/serial/8250_hp300.c b/drivers/serial/8250_hp300.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/serial/8250_hp300.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,329 @@
+/*
+ * Driver for the 98626/98644/internal serial interface on hp300/hp400
+ * (based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs)
+ *
+ * Ported from 2.2 and modified to use the normal 8250 driver
+ * by Kars de Jong <jongk@linux-m68k.org>, May 2004.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/tty.h>
+#include <linux/serial.h>
+#include <linux/serialP.h>
+#include <linux/serial_core.h>
+#include <linux/delay.h>
+#include <linux/dio.h>
+#include <linux/console.h>
+#include <asm/io.h>
+
+#if !defined(CONFIG_HPDCA) && !defined(CONFIG_HPAPCI)
+#warning CONFIG_8250 defined but neither CONFIG_HPDCA nor CONFIG_HPAPCI defined, are you sure?
+#endif
+
+#ifdef CONFIG_HPAPCI
+struct hp300_port
+{
+	struct hp300_port *next;	/* next port */
+	int line;			/* line (tty) number */
+};
+
+static struct hp300_port *hp300_ports;
+#endif
+
+#ifdef CONFIG_HPDCA
+
+static int __devinit hpdca_init_one(struct dio_dev *d,
+                                const struct dio_device_id *ent);
+static void __devexit hpdca_remove_one(struct dio_dev *d);
+
+static struct dio_device_id hpdca_dio_tbl[] = {
+	{ DIO_ID_DCA0 },
+	{ DIO_ID_DCA0REM },
+	{ DIO_ID_DCA1 },
+	{ DIO_ID_DCA1REM },
+	{ 0 }
+};
+
+static struct dio_driver hpdca_driver = {
+	.name      = "hpdca",
+	.id_table  = hpdca_dio_tbl,
+	.probe     = hpdca_init_one,
+	.remove    = __devexit_p(hpdca_remove_one),
+};
+
+#endif
+
+extern int hp300_uart_scode;
+
+/* Offset to UART registers from base of DCA */
+#define UART_OFFSET	17
+
+#define DCA_ID		0x01	/* ID (read), reset (write) */
+#define DCA_IC		0x03	/* Interrupt control        */
+
+/* Interrupt control */
+#define DCA_IC_IE	0x80	/* Master interrupt enable  */
+
+#define HPDCA_BAUD_BASE 153600
+
+/* Base address of the Frodo part */
+#define FRODO_BASE	(0x41c000)
+
+/*
+ * Where we find the 8250-like APCI ports, and how far apart they are.
+ */
+#define FRODO_APCIBASE		0x0
+#define FRODO_APCISPACE		0x20
+#define FRODO_APCI_OFFSET(x)	(FRODO_APCIBASE + ((x) * FRODO_APCISPACE))
+
+#define HPAPCI_BAUD_BASE 500400
+
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+/*
+ * Parse the bootinfo to find descriptions for headless console and 
+ * debug serial ports and register them with the 8250 driver.
+ * This function should be called before serial_console_init() is called
+ * to make sure the serial console will be available for use. IA-64 kernel
+ * calls this function from setup_arch() after the EFI and ACPI tables have
+ * been parsed.
+ */
+int __init hp300_setup_serial_console(void)
+{
+	int scode;
+	struct uart_port port;
+
+	memset(&port, 0, sizeof(port));
+
+	if (hp300_uart_scode < 0 || hp300_uart_scode > DIO_SCMAX)
+		return 0;
+
+	if (DIO_SCINHOLE(hp300_uart_scode))
+		return 0;
+
+	scode = hp300_uart_scode;
+
+	/* Memory mapped I/O */
+	port.iotype = UPIO_MEM;
+	port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
+	port.type = PORT_UNKNOWN;
+
+	/* Check for APCI console */
+	if (scode == 256) {
+#ifdef CONFIG_HPAPCI
+		printk(KERN_INFO "Serial console is HP APCI 1\n");
+
+		port.uartclk = HPAPCI_BAUD_BASE * 16;
+		port.mapbase = (FRODO_BASE + FRODO_APCI_OFFSET(1));
+		port.membase = (char *)(port.mapbase + DIO_VIRADDRBASE);
+		port.regshift = 2;
+		add_preferred_console("ttyS", port.line, "9600n8");
+#else
+		printk(KERN_WARNING "Serial console is APCI but support is disabled (CONFIG_HPAPCI)!\n");
+		return 0;
+#endif
+	}
+	else {
+#ifdef CONFIG_HPDCA
+		unsigned long pa = dio_scodetophysaddr(scode);
+		if (!pa) {
+			return 0;
+		}
+
+		printk(KERN_INFO "Serial console is HP DCA at select code %d\n", scode);
+
+		port.uartclk = HPDCA_BAUD_BASE * 16;
+		port.mapbase = (pa + UART_OFFSET);
+		port.membase = (char *)(port.mapbase + DIO_VIRADDRBASE);
+		port.regshift = 1;
+		port.irq = DIO_IPL(pa + DIO_VIRADDRBASE);
+
+		/* Enable board-interrupts */
+		out_8(pa + DIO_VIRADDRBASE + DCA_IC, DCA_IC_IE);
+
+		if (DIO_ID(pa + DIO_VIRADDRBASE) & 0x80) {
+			add_preferred_console("ttyS", port.line, "9600n8");
+		}
+#else
+		printk(KERN_WARNING "Serial console is DCA but support is disabled (CONFIG_HPDCA)!\n");
+		return 0;
+#endif
+	}
+
+	if (early_serial_setup(&port) < 0) {
+		printk(KERN_WARNING "hp300_setup_serial_console(): early_serial_setup() failed.\n");
+	}
+
+	return 0;
+}
+#endif /* CONFIG_SERIAL_8250_CONSOLE */
+
+#ifdef CONFIG_HPDCA
+static int __devinit hpdca_init_one(struct dio_dev *d,
+                                const struct dio_device_id *ent)
+{
+	struct serial_struct serial_req;
+	int line;
+
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+	if (hp300_uart_scode == d->scode) {
+		/* Already got it. */
+		return 0;
+	}
+#endif
+	memset(&serial_req, 0, sizeof(struct serial_struct));
+
+	/* Memory mapped I/O */
+	serial_req.io_type = SERIAL_IO_MEM;
+	serial_req.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
+	serial_req.irq = d->ipl;
+	serial_req.baud_base = HPDCA_BAUD_BASE;
+	serial_req.iomap_base = (d->resource.start + UART_OFFSET);
+	serial_req.iomem_base = (char *)(serial_req.iomap_base + DIO_VIRADDRBASE);
+	serial_req.iomem_reg_shift = 1;
+	line = register_serial(&serial_req);
+
+	if (line < 0) {
+		printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d"
+		       " irq %d failed\n", d->scode, serial_req.irq);
+		return -ENOMEM;
+	}
+
+	/* Enable board-interrupts */
+	out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, DCA_IC_IE);
+	dio_set_drvdata(d, (void *)line);
+
+	/* Reset the DCA */
+	out_8(d->resource.start + DIO_VIRADDRBASE + DCA_ID, 0xff);
+	udelay(100);
+
+	return 0;
+}
+#endif
+
+static int __init hp300_8250_init(void)
+{
+	static int called = 0;
+	int num_ports;
+#ifdef CONFIG_HPAPCI
+	int line;
+	unsigned long base;
+	struct serial_struct serial_req;
+	struct hp300_port *port;
+	int i;
+#endif
+	if (called)
+		return -ENODEV;
+	called = 1;
+
+	if (!MACH_IS_HP300)
+		return -ENODEV;
+
+	num_ports = 0;
+
+#ifdef CONFIG_HPDCA
+	if (dio_module_init(&hpdca_driver) == 0)
+		num_ports++;
+#endif
+#ifdef CONFIG_HPAPCI
+	if (hp300_model < HP_400) {
+		if (!num_ports)
+			return -ENODEV;
+		return 0;
+	}
+	/* These models have the Frodo chip.
+	 * Port 0 is reserved for the Apollo Domain keyboard.
+	 * Port 1 is either the console or the DCA.
+	 */
+	for (i = 1; i < 4; i++) {
+		/* Port 1 is the console on a 425e, on other machines it's mapped to
+		 * DCA.
+		 */
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+		if (i == 1) {
+			continue;
+		}
+#endif
+
+		/* Create new serial device */
+		port = kmalloc(sizeof(struct hp300_port), GFP_KERNEL);
+		if (!port)
+			return -ENOMEM;
+
+		memset(&serial_req, 0, sizeof(struct serial_struct));
+
+		base = (FRODO_BASE + FRODO_APCI_OFFSET(i));
+
+		/* Memory mapped I/O */
+		serial_req.io_type = SERIAL_IO_MEM;
+		serial_req.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
+		/* XXX - no interrupt support yet */
+		serial_req.irq = 0;
+		serial_req.baud_base = HPAPCI_BAUD_BASE;
+		serial_req.iomap_base = base;
+		serial_req.iomem_base = (char *)(serial_req.iomap_base + DIO_VIRADDRBASE);
+		serial_req.iomem_reg_shift = 2;
+
+		line = register_serial(&serial_req);
+
+		if (line < 0) {
+			printk(KERN_NOTICE "8250_hp300: register_serial() APCI %d"
+			       " irq %d failed\n", i, serial_req.irq);
+			kfree(port);
+			continue;
+		}
+
+		port->line = line;
+		port->next = hp300_ports;
+		hp300_ports = port;
+
+		num_ports++;
+	}
+#endif
+
+	/* Any boards found? */
+	if (!num_ports)
+		return -ENODEV;
+
+	return 0;
+}
+
+#ifdef CONFIG_HPDCA
+static void __devexit hpdca_remove_one(struct dio_dev *d)
+{
+	int line;
+
+	line = (int) dio_get_drvdata(d);
+	if (d->resource.start) {
+		/* Disable board-interrupts */
+		out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, 0);
+	}
+	unregister_serial(line);
+}
+#endif
+
+static void __exit hp300_8250_exit(void)
+{
+#ifdef CONFIG_HPAPCI
+	struct hp300_port *port, *to_free;
+
+	for (port = hp300_ports; port; ) {
+		unregister_serial(port->line);
+		to_free = port;
+		port = port->next;
+		kfree(to_free);
+	}
+
+	hp300_ports = NULL;
+#endif
+#ifdef CONFIG_HPDCA
+	dio_unregister_driver(&hpdca_driver);
+#endif
+}
+
+module_init(hp300_8250_init);
+module_exit(hp300_8250_exit);
+MODULE_DESCRIPTION("HP DCA/APCI serial driver");
+MODULE_AUTHOR("Kars de Jong <jongk@linux-m68k.org>");
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
--- a/drivers/serial/8250_pci.c	2004-12-24 13:37:17 -08:00
+++ b/drivers/serial/8250_pci.c	2004-12-24 13:37:17 -08:00
@@ -22,11 +22,10 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/tty.h>
-#include <linux/serial.h>
 #include <linux/serial_core.h>
 #include <linux/8250_pci.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
 #include <asm/io.h>
 
@@ -75,7 +74,7 @@
 	u32	subdevice;
 	int	(*init)(struct pci_dev *dev);
 	int	(*setup)(struct pci_dev *dev, struct pci_board *board,
-			 struct serial_struct *req, int idx);
+			 struct uart_port *port, int idx);
 	void	(*exit)(struct pci_dev *dev);
 };
 
@@ -100,34 +99,32 @@
 }
 
 static int
-setup_port(struct pci_dev *dev, struct serial_struct *req,
+setup_port(struct pci_dev *dev, struct uart_port *port,
 	   int bar, int offset, int regshift)
 {
 	struct serial_private *priv = pci_get_drvdata(dev);
-	unsigned long port, len;
+	unsigned long base, len;
 
 	if (bar >= PCI_NUM_BAR_RESOURCES)
 		return -EINVAL;
 
 	if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) {
-		port = pci_resource_start(dev, bar);
+		base = pci_resource_start(dev, bar);
 		len =  pci_resource_len(dev, bar);
 
 		if (!priv->remapped_bar[bar])
-			priv->remapped_bar[bar] = ioremap(port, len);
+			priv->remapped_bar[bar] = ioremap(base, len);
 		if (!priv->remapped_bar[bar])
 			return -ENOMEM;
 
-		req->io_type = UPIO_MEM;
-		req->iomap_base = port + offset;
-		req->iomem_base = priv->remapped_bar[bar] + offset;
-		req->iomem_reg_shift = regshift;
+		port->iotype = UPIO_MEM;
+		port->mapbase = base + offset;
+		port->membase = priv->remapped_bar[bar] + offset;
+		port->regshift = regshift;
 	} else {
-		port = pci_resource_start(dev, bar) + offset;
-		req->io_type = UPIO_PORT;
-		req->port = port;
-		if (HIGH_BITS_OFFSET)
-			req->port_high = port >> HIGH_BITS_OFFSET;
+		base = pci_resource_start(dev, bar) + offset;
+		port->iotype = UPIO_PORT;
+		port->iobase = base;
 	}
 	return 0;
 }
@@ -138,7 +135,7 @@
  */
 static int
 afavlab_setup(struct pci_dev *dev, struct pci_board *board,
-	      struct serial_struct *req, int idx)
+	      struct uart_port *port, int idx)
 {
 	unsigned int bar, offset = board->first_offset;
 	
@@ -150,7 +147,7 @@
 		offset += (idx - 4) * board->uart_offset;
 	}
 
-	return setup_port(dev, req, bar, offset, board->reg_shift);
+	return setup_port(dev, port, bar, offset, board->reg_shift);
 }
 
 /*
@@ -191,7 +188,7 @@
  */
 static int
 pci_hp_diva_setup(struct pci_dev *dev, struct pci_board *board,
-	      struct serial_struct *req, int idx)
+	      struct uart_port *port, int idx)
 {
 	unsigned int offset = board->first_offset;
 	unsigned int bar = FL_GET_BASE(board->flags);
@@ -213,7 +210,7 @@
 
 	offset += idx * board->uart_offset;
 
-	return setup_port(dev, req, bar, offset, board->reg_shift);
+	return setup_port(dev, port, bar, offset, board->reg_shift);
 }
 
 /*
@@ -286,7 +283,7 @@
 
 static void __devexit pci_plx9050_exit(struct pci_dev *dev)
 {
-	u8 *p;
+	u8 __iomem *p;
 
 	if ((pci_resource_flags(dev, 0) & IORESOURCE_MEM) == 0)
 		return;
@@ -309,7 +306,7 @@
 /* SBS Technologies Inc. PMC-OCTPRO and P-OCTAL cards */
 static int
 sbs_setup(struct pci_dev *dev, struct pci_board *board,
-		struct serial_struct *req, int idx)
+		struct uart_port *port, int idx)
 {
 	unsigned int bar, offset = board->first_offset;
 
@@ -324,7 +321,7 @@
 	} else /* we have only 8 ports on PMC-OCTALPRO */
 		return 1;
 
-	return setup_port(dev, req, bar, offset, board->reg_shift);
+	return setup_port(dev, port, bar, offset, board->reg_shift);
 }
 
 /*
@@ -339,7 +336,7 @@
 
 static int __devinit sbs_init(struct pci_dev *dev)
 {
-	u8 * p;
+	u8 __iomem *p;
 
 	p = ioremap(pci_resource_start(dev, 0),pci_resource_len(dev,0));
 
@@ -363,7 +360,7 @@
 
 static void __devexit sbs_exit(struct pci_dev *dev)
 {
-	u8 * p;
+	u8 __iomem *p;
 
 	p = ioremap(pci_resource_start(dev, 0),pci_resource_len(dev,0));
 	if (p != NULL) {
@@ -522,7 +519,7 @@
  */
 static int
 pci_timedia_setup(struct pci_dev *dev, struct pci_board *board,
-		  struct serial_struct *req, int idx)
+		  struct uart_port *port, int idx)
 {
 	unsigned int bar = 0, offset = board->first_offset;
 
@@ -547,7 +544,7 @@
 		bar = idx - 2;
 	}
 
-	return setup_port(dev, req, bar, offset, board->reg_shift);
+	return setup_port(dev, port, bar, offset, board->reg_shift);
 }
 
 /*
@@ -555,7 +552,7 @@
  */
 static int
 titan_400l_800l_setup(struct pci_dev *dev, struct pci_board *board,
-		      struct serial_struct *req, int idx)
+		      struct uart_port *port, int idx)
 {
 	unsigned int bar, offset = board->first_offset;
 
@@ -571,7 +568,7 @@
 		offset = (idx - 2) * board->uart_offset;
 	}
 
-	return setup_port(dev, req, bar, offset, board->reg_shift);
+	return setup_port(dev, port, bar, offset, board->reg_shift);
 }
 
 static int __devinit pci_xircom_init(struct pci_dev *dev)
@@ -582,7 +579,7 @@
 
 static int
 pci_default_setup(struct pci_dev *dev, struct pci_board *board,
-		  struct serial_struct *req, int idx)
+		  struct uart_port *port, int idx)
 {
 	unsigned int bar, offset = board->first_offset, maxnr;
 
@@ -598,7 +595,7 @@
 	if (board->flags & FL_REGION_SZ_CAP && idx >= maxnr)
 		return 1;
 			
-	return setup_port(dev, req, bar, offset, board->reg_shift);
+	return setup_port(dev, port, bar, offset, board->reg_shift);
 }
 
 /* This should be in linux/pci_ids.h */
@@ -1029,6 +1026,7 @@
 
 	pbn_b1_bt_2_921600,
 
+	pbn_b1_1_1382400,
 	pbn_b1_2_1382400,
 	pbn_b1_4_1382400,
 	pbn_b1_8_1382400,
@@ -1256,6 +1254,12 @@
 		.uart_offset	= 8,
 	},
 
+	[pbn_b1_1_1382400] = {
+		.flags		= FL_BASE1,
+		.num_ports	= 1,
+		.base_baud	= 1382400,
+		.uart_offset	= 8,
+	},
 	[pbn_b1_2_1382400] = {
 		.flags		= FL_BASE1,
 		.num_ports	= 2,
@@ -1610,7 +1614,6 @@
 	struct serial_private *priv;
 	struct pci_board *board, tmp;
 	struct pci_serial_quirk *quirk;
-	struct serial_struct serial_req;
 	int rc, nr_ports, i;
 
 	if (ent->driver_data >= ARRAY_SIZE(pci_boards)) {
@@ -1690,19 +1693,22 @@
 	pci_set_drvdata(dev, priv);
 
 	for (i = 0; i < nr_ports; i++) {
-		memset(&serial_req, 0, sizeof(serial_req));
-		serial_req.flags = UPF_SKIP_TEST | UPF_AUTOPROBE |
-				   UPF_SHARE_IRQ;
-		serial_req.baud_base = board->base_baud;
-		serial_req.irq = get_pci_irq(dev, board, i);
-		if (quirk->setup(dev, board, &serial_req, i))
+		struct uart_port serial_port;
+		memset(&serial_port, 0, sizeof(struct uart_port));
+
+		serial_port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF |
+				    UPF_SHARE_IRQ;
+		serial_port.uartclk = board->base_baud * 16;
+		serial_port.irq = get_pci_irq(dev, board, i);
+		serial_port.dev = &dev->dev;
+		if (quirk->setup(dev, board, &serial_port, i))
 			break;
 #ifdef SERIAL_DEBUG_PCI
 		printk("Setup PCI port: port %x, irq %d, type %d\n",
-		       serial_req.port, serial_req.irq, serial_req.io_type);
+		       serial_port.iobase, serial_port.irq, serial_port.iotype);
 #endif
 		
-		priv->line[i] = register_serial(&serial_req);
+		priv->line[i] = serial8250_register_port(&serial_port);
 		if (priv->line[i] < 0) {
 			printk(KERN_WARNING "Couldn't register serial port %s: %d\n", pci_name(dev), priv->line[i]);
 			break;
@@ -1732,7 +1738,7 @@
 		int i;
 
 		for (i = 0; i < priv->nr; i++)
-			unregister_serial(priv->line[i]);
+			serial8250_unregister_port(priv->line[i]);
 
 		for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) {
 			if (priv->remapped_bar[i])
@@ -2108,6 +2114,20 @@
 	{	PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_PORT_650,
 		PCI_ANY_ID, PCI_ANY_ID, 0, 0,
 		pbn_b0_bt_1_460800 },
+
+	/*
+	 * Dell Remote Access Card 4 - Tim_T_Murphy@Dell.com
+	 */
+	{	PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DELL_RAC4,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+		pbn_b1_1_1382400 },
+
+	/*
+	 * Dell Remote Access Card III - Tim_T_Murphy@Dell.com
+	 */
+	{	PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DELL_RACIII,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+		pbn_b1_1_1382400 },
 
 	/*
 	 * RAStel 2 port modem, gerg@moreton.com.au
diff -Nru a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
--- a/drivers/serial/8250_pnp.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/serial/8250_pnp.c	2004-12-24 13:36:17 -08:00
@@ -21,14 +21,10 @@
 #include <linux/pnp.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/serialP.h>
 #include <linux/serial_core.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
-#include <asm/serial.h>
 
 #include "8250.h"
 
@@ -49,7 +45,7 @@
 	/* Actiontec ISA PNP 56K X2 Fax Modem */
 	{	"AEI1240",		0	},
 	/* Rockwell 56K ACF II Fax+Data+Voice Modem */
-	{	"AKY1021",		SPCI_FL_NO_SHIRQ	},
+	{	"AKY1021",		0 /*SPCI_FL_NO_SHIRQ*/	},
 	/* AZT3005 PnP SOUND DEVICE */
 	{	"AZT4001",		0	},
 	/* Best Data Products Inc. Smart One 336F PnP Modem */
@@ -293,6 +289,8 @@
 	{	"USR0006",		0	},
 	/* U.S. Robotics 33.6K Voice EXT PnP */
 	{	"USR0007",		0	},
+	/* U.S. Robotics Courier V.Everything INT PnP */
+	{	"USR0009",		0	},
 	/* U.S. Robotics 33.6K Voice INT PnP */
 	{	"USR2002",		0	},
 	/* U.S. Robotics 56K Voice INT PnP */
@@ -396,26 +394,29 @@
 static int __devinit
 serial_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id)
 {
-	struct serial_struct serial_req;
+	struct uart_port port;
 	int ret, line, flags = dev_id->driver_data;
+
 	if (flags & UNKNOWN_DEV) {
 		ret = serial_pnp_guess_board(dev, &flags);
 		if (ret < 0)
 			return ret;
 	}
-	memset(&serial_req, 0, sizeof(serial_req));
-	serial_req.irq = pnp_irq(dev,0);
-	serial_req.port = pnp_port_start(dev, 0);
-	if (HIGH_BITS_OFFSET)
-		serial_req.port = pnp_port_start(dev, 0) >> HIGH_BITS_OFFSET;
+
+	memset(&port, 0, sizeof(struct uart_port));
+	port.irq = pnp_irq(dev,0);
+	port.iobase = pnp_port_start(dev, 0);
+
 #ifdef SERIAL_DEBUG_PNP
 	printk("Setup PNP port: port %x, irq %d, type %d\n",
-	       serial_req.port, serial_req.irq, serial_req.io_type);
+	       port.iobase, port.irq, port.iotype);
 #endif
 
-	serial_req.flags = UPF_SKIP_TEST | UPF_AUTOPROBE;
-	serial_req.baud_base = 115200;
-	line = register_serial(&serial_req);
+	port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
+	port.uartclk = 1843200;
+	port.dev = &dev->dev;
+
+	line = serial8250_register_port(&port);
 
 	if (line >= 0)
 		pnp_set_drvdata(dev, (void *)(line + 1));
@@ -427,7 +428,7 @@
 {
 	int line = (int)pnp_get_drvdata(dev);
 	if (line)
-		unregister_serial(line - 1);
+		serial8250_unregister_port(line - 1);
 }
 
 static struct pnp_driver serial_pnp_driver = {
diff -Nru a/drivers/serial/Kconfig b/drivers/serial/Kconfig
--- a/drivers/serial/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/drivers/serial/Kconfig	2004-12-24 13:37:19 -08:00
@@ -10,7 +10,7 @@
 # The new 8250/16550 serial drivers
 config SERIAL_8250
 	tristate "8250/16550 and compatible serial support"
-	depends on (BROKEN || !SPARC64)
+	depends on (BROKEN || !(SPARC64 || SPARC32))
 	select SERIAL_CORE
 	---help---
 	  This selects whether you want to include the driver for the standard
@@ -386,6 +386,29 @@
 	  your boot loader (lilo or loadlin) about how to pass options to the
 	  kernel at boot time.)
 
+config SERIAL_IMX
+	bool "IMX serial port support"
+	depends on ARM && ARCH_IMX
+	select SERIAL_CORE
+	help
+	  If you have a machine based on a Motorola IMX CPU you
+	  can enable its onboard serial port by enabling this option.
+
+config SERIAL_IMX_CONSOLE
+	bool "Console on IMX serial port"
+	depends on SERIAL_IMX
+	select SERIAL_CORE_CONSOLE
+	help
+	  If you have enabled the serial port on the Motorola IMX
+	  CPU you can make it the console by answering Y to this option.
+
+	  Even if you say Y here, the currently visible virtual console
+	  (/dev/tty0) will still be used as the system console by default, but
+	  you can alter that using a kernel command line option such as
+	  "console=ttySA0". (Try "man bootparam" or see the documentation of
+	  your boot loader (lilo or loadlin) about how to pass options to the
+	  kernel at boot time.)
+
 config SERIAL_SUNCORE
 	bool
 	depends on SPARC32 || SPARC64
@@ -726,5 +749,34 @@
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called icom.
+
+config SERIAL_M32R_SIO
+	bool "M32R SIO I/F"
+	depends on M32R
+	default y
+	select SERIAL_CORE
+	help
+	  Say Y here if you want to use the M32R serial controller.
+
+config SERIAL_M32R_SIO_CONSOLE
+	bool "use SIO console"
+	depends on SERIAL_M32R_SIO=y
+	select SERIAL_CORE_CONSOLE
+	help
+	  Say Y here if you want to support a serial console.
+
+	  If you use an M3T-M32700UT or an OPSPUT platform,
+	  please say also y for SERIAL_M32R_PLDSIO.
+
+config SERIAL_M32R_PLDSIO
+	bool "M32R SIO I/F on a PLD"
+	depends on SERIAL_M32R_SIO=y
+	default n
+	help
+	  Say Y here if you want to use the M32R serial controller
+	  on a PLD (Programmable Logic Device).
+
+	  If you use an M3T-M32700UT or an OPSPUT platform,
+	  please say Y.
 
 endmenu
diff -Nru a/drivers/serial/Makefile b/drivers/serial/Makefile
--- a/drivers/serial/Makefile	2004-12-24 13:36:49 -08:00
+++ b/drivers/serial/Makefile	2004-12-24 13:36:49 -08:00
@@ -9,12 +9,14 @@
 serial-8250-$(CONFIG_GSC) += 8250_gsc.o
 serial-8250-$(CONFIG_PCI) += 8250_pci.o
 serial-8250-$(CONFIG_PNP) += 8250_pnp.o
+serial-8250-$(CONFIG_HP300) += 8250_hp300.o
 
 obj-$(CONFIG_SERIAL_CORE) += serial_core.o
 obj-$(CONFIG_SERIAL_21285) += 21285.o
 obj-$(CONFIG_SERIAL_8250) += 8250.o $(serial-8250-y)
 obj-$(CONFIG_SERIAL_8250_CS) += serial_cs.o
 obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o
+obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
 obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
 obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
 obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
@@ -40,4 +42,8 @@
 obj-$(CONFIG_SERIAL_BAST_SIO) += bast_sio.o
 obj-$(CONFIG_SERIAL_SGI_L1_CONSOLE) += sn_console.o
 obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
+obj-$(CONFIG_SERIAL_IMX) += imx.o
 obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
+obj-$(CONFIG_SERIAL_ICOM) += icom.o
+obj-$(CONFIG_SERIAL_M32R_SIO) += m32r_sio.o
+obj-$(CONFIG_ETRAX_SERIAL) += crisv10.o
\ No newline at end of file
diff -Nru a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
--- a/drivers/serial/amba-pl010.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/serial/amba-pl010.c	2004-12-24 13:36:18 -08:00
@@ -32,25 +32,25 @@
  * and hooked into this driver.
  */
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_AMBA_PL010_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
-#include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
 #include <linux/device.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/hardware/amba.h>
-
-#if defined(CONFIG_SERIAL_AMBA_PL010_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
 #include <asm/hardware/amba_serial.h>
 
 #define UART_NR		2
@@ -149,22 +149,22 @@
 #endif
 {
 	struct tty_struct *tty = port->info->tty;
-	unsigned int status, ch, rsr, max_count = 256;
+	unsigned int status, ch, flag, rsr, max_count = 256;
 
 	status = UART_GET_FR(port);
 	while (UART_RX_DATA(status) && max_count--) {
 		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-			tty->flip.work.func((void *)tty);
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-				printk(KERN_WARNING "TTY_DONT_FLIP set\n");
-				return;
-			}
+			if (tty->low_latency)
+				tty_flip_buffer_push(tty);
+			/*
+			 * If this failed then we will throw away the
+			 * bytes but must do so to clear interrupts.
+			 */
 		}
 
 		ch = UART_GET_CHAR(port);
+		flag = TTY_NORMAL;
 
-		*tty->flip.char_buf_ptr = ch;
-		*tty->flip.flag_buf_ptr = TTY_NORMAL;
 		port->icount.rx++;
 
 		/*
@@ -188,20 +188,18 @@
 			rsr &= port->read_status_mask;
 
 			if (rsr & UART01x_RSR_BE)
-				*tty->flip.flag_buf_ptr = TTY_BREAK;
+				flag = TTY_BREAK;
 			else if (rsr & UART01x_RSR_PE)
-				*tty->flip.flag_buf_ptr = TTY_PARITY;
+				flag = TTY_PARITY;
 			else if (rsr & UART01x_RSR_FE)
-				*tty->flip.flag_buf_ptr = TTY_FRAME;
+				flag = TTY_FRAME;
 		}
 
 		if (uart_handle_sysrq_char(port, ch, regs))
 			goto ignore_char;
 
 		if ((rsr & port->ignore_status_mask) == 0) {
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, ch, flag);
 		}
 		if ((rsr & UART01x_RSR_OE) &&
 		    tty->flip.count < TTY_FLIPBUF_SIZE) {
@@ -210,9 +208,7 @@
 			 * immediately, and doesn't affect the current
 			 * character
 			 */
-			*tty->flip.char_buf_ptr++ = 0;
-			*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
 		}
 	ignore_char:
 		status = UART_GET_FR(port);
@@ -713,6 +709,24 @@
 	.index		= -1,
 	.data		= &amba_reg,
 };
+
+static int __init amba_console_init(void)
+{
+	/*
+	 * All port initializations are done statically
+	 */
+	register_console(&amba_console);
+	return 0;
+}
+console_initcall(amba_console_init);
+
+static int __init amba_late_console_init(void)
+{
+	if (!(amba_console.flags & CON_ENABLED))
+		register_console(&amba_console);
+	return 0;
+}
+late_initcall(amba_late_console_init);
 
 #define AMBA_CONSOLE	&amba_console
 #else
diff -Nru a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
--- a/drivers/serial/amba-pl011.c	2004-12-24 13:37:34 -08:00
+++ b/drivers/serial/amba-pl011.c	2004-12-24 13:37:34 -08:00
@@ -32,26 +32,26 @@
  * and hooked into this driver.
  */
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
-#include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
 #include <linux/device.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/hardware/amba.h>
 #include <asm/hardware/clock.h>
-
-#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
 #include <asm/hardware/amba_serial.h>
 
 #define UART_NR			14
@@ -115,22 +115,21 @@
 #endif
 {
 	struct tty_struct *tty = uap->port.info->tty;
-	unsigned int status, ch, rsr, max_count = 256;
+	unsigned int status, ch, flag, rsr, max_count = 256;
 
 	status = readw(uap->port.membase + UART01x_FR);
 	while ((status & UART01x_FR_RXFE) == 0 && max_count--) {
 		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-			tty->flip.work.func((void *)tty);
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-				printk(KERN_WARNING "TTY_DONT_FLIP set\n");
-				return;
-			}
+			if (tty->low_latency)
+				tty_flip_buffer_push(tty);
+			/*
+			 * If this failed then we will throw away the
+			 * bytes but must do so to clear interrupts
+			 */
 		}
 
 		ch = readw(uap->port.membase + UART01x_DR);
-
-		*tty->flip.char_buf_ptr = ch;
-		*tty->flip.flag_buf_ptr = TTY_NORMAL;
+		flag = TTY_NORMAL;
 		uap->port.icount.rx++;
 
 		/*
@@ -154,20 +153,18 @@
 			rsr &= uap->port.read_status_mask;
 
 			if (rsr & UART01x_RSR_BE)
-				*tty->flip.flag_buf_ptr = TTY_BREAK;
+				flag = TTY_BREAK;
 			else if (rsr & UART01x_RSR_PE)
-				*tty->flip.flag_buf_ptr = TTY_PARITY;
+				flag = TTY_PARITY;
 			else if (rsr & UART01x_RSR_FE)
-				*tty->flip.flag_buf_ptr = TTY_FRAME;
+				flag = TTY_FRAME;
 		}
 
 		if (uart_handle_sysrq_char(&uap->port, ch, regs))
 			goto ignore_char;
 
 		if ((rsr & uap->port.ignore_status_mask) == 0) {
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, ch, flag);
 		}
 		if ((rsr & UART01x_RSR_OE) &&
 		    tty->flip.count < TTY_FLIPBUF_SIZE) {
@@ -176,9 +173,7 @@
 			 * immediately, and doesn't affect the current
 			 * character
 			 */
-			*tty->flip.char_buf_ptr++ = 0;
-			*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
 		}
 	ignore_char:
 		status = readw(uap->port.membase + UART01x_FR);
@@ -745,7 +740,7 @@
 static int pl011_probe(struct amba_device *dev, void *id)
 {
 	struct uart_amba_port *uap;
-	void *base;
+	void __iomem *base;
 	int i, ret;
 
 	for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
diff -Nru a/drivers/serial/au1x00_uart.c b/drivers/serial/au1x00_uart.c
--- a/drivers/serial/au1x00_uart.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/serial/au1x00_uart.c	2004-12-24 13:36:18 -08:00
@@ -1313,20 +1313,6 @@
 	uart_unregister_port(&serial8250_reg, line);
 }
 
-/*
- * This is for ISAPNP only.
- */
-void serial8250_get_irq_map(unsigned int *map)
-{
-	int i;
-
-	for (i = 0; i < UART_NR; i++) {
-		if (serial8250_ports[i].port.type != PORT_UNKNOWN &&
-		    serial8250_ports[i].port.irq < 16)
-			*map |= 1 << serial8250_ports[i].port.irq;
-	}
-}
-
 /**
  *	serial8250_suspend_port - suspend one serial port
  *	@line:  serial line number
@@ -1382,7 +1368,6 @@
 
 EXPORT_SYMBOL(register_serial);
 EXPORT_SYMBOL(unregister_serial);
-EXPORT_SYMBOL(serial8250_get_irq_map);
 EXPORT_SYMBOL(serial8250_suspend_port);
 EXPORT_SYMBOL(serial8250_resume_port);
 
diff -Nru a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
--- a/drivers/serial/clps711x.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/serial/clps711x.c	2004-12-24 13:36:32 -08:00
@@ -26,26 +26,26 @@
  *
  */
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
-#include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
 #include <linux/spinlock.h>
 #include <linux/device.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
 
 #include <asm/hardware.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-
-#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
 #include <asm/hardware/clps7111.h>
 
 #define UART_NR		2
@@ -123,9 +123,7 @@
 			goto ignore_char;
 
 	error_return:
-		*tty->flip.flag_buf_ptr++ = flg;
-		*tty->flip.char_buf_ptr++ = ch;
-		tty->flip.count++;
+		tty_insert_flip_char(tty, ch, flg);
 	ignore_char:
 		status = clps_readl(SYSFLG(port));
 	}
@@ -158,11 +156,7 @@
 		 * CHECK: does overrun affect the current character?
 		 * ASSUMPTION: it does not.
 		 */
-		*tty->flip.flag_buf_ptr++ = flg;
-		*tty->flip.char_buf_ptr++ = ch;
-		tty->flip.count++;
-		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-			goto ignore_char;
+		tty_insert_flip_char(tty, ch, flg);
 		ch = 0;
 		flg = TTY_OVERRUN;
 	}
diff -Nru a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
--- a/drivers/serial/cpm_uart/cpm_uart.h	2004-12-24 13:37:29 -08:00
+++ b/drivers/serial/cpm_uart/cpm_uart.h	2004-12-24 13:37:29 -08:00
@@ -17,13 +17,8 @@
 #include "cpm_uart_cpm1.h"
 #endif
 
-#ifndef CONFIG_SERIAL_8250
-#define SERIAL_CPM_MAJOR	TTY_MAJOR
-#define SERIAL_CPM_MINOR	64
-#else
 #define SERIAL_CPM_MAJOR	204
-#define SERIAL_CPM_MINOR	42
-#endif
+#define SERIAL_CPM_MINOR	46
 
 #define IS_SMC(pinfo) 		(pinfo->flags & FLAG_SMC)
 #define IS_DISCARDING(pinfo)	(pinfo->flags & FLAG_DISCARDING)
@@ -70,6 +65,8 @@
 	/* helpers */
 	int			 baud;
 	int			 bits;
+	/* Keep track of 'odd' SMC2 wirings */
+	int			is_portb;
 };
 
 extern int cpm_uart_port_map[UART_NR];
diff -Nru a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
--- a/drivers/serial/cpm_uart/cpm_uart_core.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c	2004-12-24 13:37:19 -08:00
@@ -743,6 +743,18 @@
 	pinfo->smcup->smc_rbase = (u_char *)pinfo->rx_bd_base - DPRAM_BASE;
 	pinfo->smcup->smc_tbase = (u_char *)pinfo->tx_bd_base - DPRAM_BASE;
 
+/*
+ *  In case SMC1 is being relocated...
+ */
+#if defined (CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
+	up->smc_rbptr = pinfo->smcup->smc_rbase;
+	up->smc_tbptr = pinfo->smcup->smc_tbase;
+	up->smc_rstate = 0;
+	up->smc_tstate = 0;
+	up->smc_brkcr = 1;              /* number of break chars */
+	up->smc_brkec = 0;
+#endif
+
 	/* Set up the uart parameters in the
 	 * parameter ram.
 	 */
@@ -872,6 +884,9 @@
 		.rx_nrfifos = RX_NUM_FIFO, 
 		.rx_fifosize = RX_BUF_SIZE,
 		.set_lineif = smc2_lineif,
+#ifdef CONFIG_SERIAL_CPM_ALT_SMC2
+		.is_portb = 1,
+#endif
 	},
 	[UART_SCC1] = {
 		.port = {
diff -Nru a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c	2004-12-24 13:36:48 -08:00
@@ -82,10 +82,17 @@
 void smc1_lineif(struct uart_cpm_port *pinfo)
 {
 	volatile cpm8xx_t *cp = cpmp;
+	unsigned int iobits = 0x000000c0;
 
-	cp->cp_pbpar |= 0x000000c0;
-	cp->cp_pbdir &= ~0x000000c0;
-	cp->cp_pbodr &= ~0x000000c0;
+	if (!pinfo->is_portb) {
+		cp->cp_pbpar |= iobits;
+		cp->cp_pbdir &= ~iobits;
+		cp->cp_pbodr &= ~iobits;
+	} else {
+		((immap_t *)IMAP_ADDR)->im_ioport.iop_papar |= iobits;
+		((immap_t *)IMAP_ADDR)->im_ioport.iop_padir &= ~iobits;
+		((immap_t *)IMAP_ADDR)->im_ioport.iop_paodr &= ~iobits;
+	}
 
 	pinfo->brg = 1;
 }
@@ -194,8 +201,16 @@
 	cpm_uart_nr = 0;
 #ifdef CONFIG_SERIAL_CPM_SMC1
 	cpm_uart_ports[UART_SMC1].smcp = &cpmp->cp_smc[0];
+/*
+ *  Is SMC1 being relocated?
+ */
+# ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
+	cpm_uart_ports[UART_SMC1].smcup =
+	    (smc_uart_t *) & cpmp->cp_dparam[0x3C0];
+# else
 	cpm_uart_ports[UART_SMC1].smcup =
 	    (smc_uart_t *) & cpmp->cp_dparam[PROFF_SMC1];
+# endif
 	cpm_uart_ports[UART_SMC1].port.mapbase =
 	    (unsigned long)&cpmp->cp_smc[0];
 	cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
diff -Nru a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/serial/crisv10.c	2004-12-24 13:37:01 -08:00
@@ -0,0 +1,5061 @@
+/* $Id: serial.c,v 1.25 2004/09/29 10:33:49 starvik Exp $
+ *
+ * Serial port driver for the ETRAX 100LX chip
+ *
+ *    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003  Axis Communications AB
+ *
+ *    Many, many authors. Based once upon a time on serial.c for 16x50.
+ *
+ * $Log: serial.c,v $
+ * Revision 1.25  2004/09/29 10:33:49  starvik
+ * Resolved a dealock when printing debug from kernel.
+ *
+ * Revision 1.24  2004/08/27 23:25:59  johana
+ * rs_set_termios() must call change_speed() if c_iflag has changed or
+ * automatic XOFF handling will be enabled and transmitter will stop
+ * if 0x13 is received.
+ *
+ * Revision 1.23  2004/08/24 06:57:13  starvik
+ * More whitespace cleanup
+ *
+ * Revision 1.22  2004/08/24 06:12:20  starvik
+ * Whitespace cleanup
+ *
+ * Revision 1.20  2004/05/24 12:00:20  starvik
+ * Big merge of stuff from Linux 2.4 (e.g. manual mode for the serial port).
+ *
+ * Revision 1.19  2004/05/17 13:12:15  starvik
+ * Kernel console hook
+ * Big merge from Linux 2.4 still pending.
+ *
+ * Revision 1.18  2003/10/28 07:18:30  starvik
+ * Compiles with debug info
+ *
+ * Revision 1.17  2003/07/04 08:27:37  starvik
+ * Merge of Linux 2.5.74
+ *
+ * Revision 1.16  2003/06/13 10:05:19  johana
+ * Help the user to avoid trouble by:
+ * Forcing mixed mode for status/control lines if not all pins are used.
+ *
+ * Revision 1.15  2003/06/13 09:43:01  johana
+ * Merged in the following changes from os/linux/arch/cris/drivers/serial.c
+ * + some minor changes to reduce diff.
+ *
+ * Revision 1.49  2003/05/30 11:31:54  johana
+ * Merged in change-branch--serial9bit that adds CMSPAR support for sticky
+ * parity (mark/space)
+ *
+ * Revision 1.48  2003/05/30 11:03:57  johana
+ * Implemented rs_send_xchar() by disabling the DMA and writing manually.
+ * Added e100_disable_txdma_channel() and e100_enable_txdma_channel().
+ * Fixed rs_throttle() and rs_unthrottle() to properly call rs_send_xchar
+ * instead of setting info->x_char and check the CRTSCTS flag before
+ * controlling the rts pin.
+ *
+ * Revision 1.14  2003/04/09 08:12:44  pkj
+ * Corrected typo changes made upstream.
+ *
+ * Revision 1.13  2003/04/09 05:20:47  starvik
+ * Merge of Linux 2.5.67
+ *
+ * Revision 1.11  2003/01/22 06:48:37  starvik
+ * Fixed warnings issued by GCC 3.2.1
+ *
+ * Revision 1.9  2002/12/13 09:07:47  starvik
+ * Alert user that RX_TIMEOUT_TICKS==0 doesn't work
+ *
+ * Revision 1.8  2002/12/11 13:13:57  starvik
+ * Added arch/ to v10 specific includes
+ * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
+ *
+ * Revision 1.7  2002/12/06 07:13:57  starvik
+ * Corrected work queue stuff
+ * Removed CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST
+ *
+ * Revision 1.6  2002/11/21 07:17:46  starvik
+ * Change static inline to extern inline where otherwise outlined with gcc-3.2
+ *
+ * Revision 1.5  2002/11/14 15:59:49  starvik
+ * Linux 2.5 port of the latest serial driver from 2.4. The work queue stuff
+ * probably doesn't work yet.
+ *
+ * Revision 1.42  2002/11/05 09:08:47  johana
+ * Better implementation of rs_stop() and rs_start() that uses the XOFF
+ * register to start/stop transmission.
+ * change_speed() also initilises XOFF register correctly so that
+ * auto_xoff is enabled when IXON flag is set by user.
+ * This gives fast XOFF response times.
+ *
+ * Revision 1.41  2002/11/04 18:40:57  johana
+ * Implemented rs_stop() and rs_start().
+ * Simple tests using hwtestserial indicates that this should be enough
+ * to make it work.
+ *
+ * Revision 1.40  2002/10/14 05:33:18  starvik
+ * RS-485 uses fast timers even if SERIAL_FAST_TIMER is disabled
+ *
+ * Revision 1.39  2002/09/30 21:00:57  johana
+ * Support for CONFIG_ETRAX_SERx_DTR_RI_DSR_CD_MIXED where the status and
+ * control pins can be mixed between PA and PB.
+ * If no serial port uses MIXED old solution is used
+ * (saves a few bytes and cycles).
+ * control_pins struct uses masks instead of bit numbers.
+ * Corrected dummy values and polarity in line_info() so
+ * /proc/tty/driver/serial is now correct.
+ * (the E100_xxx_GET() macros is really active low - perhaps not obvious)
+ *
+ * Revision 1.38  2002/08/23 11:01:36  starvik
+ * Check that serial port is enabled in all interrupt handlers to avoid
+ * restarts of DMA channels not assigned to serial ports
+ *
+ * Revision 1.37  2002/08/13 13:02:37  bjornw
+ * Removed some warnings because of unused code
+ *
+ * Revision 1.36  2002/08/08 12:50:01  starvik
+ * Serial interrupt is shared with synchronous serial port driver
+ *
+ * Revision 1.35  2002/06/03 10:40:49  starvik
+ * Increased RS-485 RTS toggle timer to 2 characters
+ *
+ * Revision 1.34  2002/05/28 18:59:36  johana
+ * Whitespace and comment fixing to be more like etrax100ser.c 1.71.
+ *
+ * Revision 1.33  2002/05/28 17:55:43  johana
+ * RS-485 uses FAST_TIMER if enabled, and starts a short (one char time)
+ * timer from tranismit_chars (interrupt context).
+ * The timer toggles RTS in interrupt context when expired giving minimum
+ * latencies.
+ *
+ * Revision 1.32  2002/05/22 13:58:00  johana
+ * Renamed rs_write() to raw_write() and made it inline.
+ * New rs_write() handles RS-485 if configured and enabled
+ * (moved code from e100_write_rs485()).
+ * RS-485 ioctl's uses copy_from_user() instead of verify_area().
+ *
+ * Revision 1.31  2002/04/22 11:20:03  johana
+ * Updated copyright years.
+ *
+ * Revision 1.30  2002/04/22 09:39:12  johana
+ * RS-485 support compiles.
+ *
+ * Revision 1.29  2002/01/14 16:10:01  pkj
+ * Allocate the receive buffers dynamically. The static 4kB buffer was
+ * too small for the peaks. This means that we can get rid of the extra
+ * buffer and the copying to it. It also means we require less memory
+ * under normal operations, but can use more when needed (there is a
+ * cap at 64kB for safety reasons). If there is no memory available
+ * we panic(), and die a horrible death...
+ *
+ * Revision 1.28  2001/12/18 15:04:53  johana
+ * Cleaned up write_rs485() - now it works correctly without padding extra
+ * char.
+ * Added sane default initialisation of rs485.
+ * Added #ifdef around dummy variables.
+ *
+ * Revision 1.27  2001/11/29 17:00:41  pkj
+ * 2kB seems to be too small a buffer when using 921600 bps,
+ * so increase it to 4kB (this was already done for the elinux
+ * version of the serial driver).
+ *
+ * Revision 1.26  2001/11/19 14:20:41  pkj
+ * Minor changes to comments and unused code.
+ *
+ * Revision 1.25  2001/11/12 20:03:43  pkj
+ * Fixed compiler warnings.
+ *
+ * Revision 1.24  2001/11/12 15:10:05  pkj
+ * Total redesign of the receiving part of the serial driver.
+ * Uses eight chained descriptors to write to a 4kB buffer.
+ * This data is then serialised into a 2kB buffer. From there it
+ * is copied into the TTY's flip buffers when they become available.
+ * A lot of copying, and the sizes of the buffers might need to be
+ * tweaked, but all in all it should work better than the previous
+ * version, without the need to modify the TTY code in any way.
+ * Also note that erroneous bytes are now correctly marked in the
+ * flag buffers (instead of always marking the first byte).
+ *
+ * Revision 1.23  2001/10/30 17:53:26  pkj
+ * * Set info->uses_dma to 0 when a port is closed.
+ * * Mark the timer1 interrupt as a fast one (SA_INTERRUPT).
+ * * Call start_flush_timer() in start_receive() if
+ *   CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST is defined.
+ *
+ * Revision 1.22  2001/10/30 17:44:03  pkj
+ * Use %lu for received and transmitted counters in line_info().
+ *
+ * Revision 1.21  2001/10/30 17:40:34  pkj
+ * Clean-up. The only change to functionality is that
+ * CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS(=5) is used instead of
+ * MAX_FLUSH_TIME(=8).
+ *
+ * Revision 1.20  2001/10/30 15:24:49  johana
+ * Added char_time stuff from 2.0 driver.
+ *
+ * Revision 1.19  2001/10/30 15:23:03  johana
+ * Merged with 1.13.2 branch + fixed indentation
+ * and changed CONFIG_ETRAX100_XYS to CONFIG_ETRAX_XYZ
+ *
+ * Revision 1.18  2001/09/24 09:27:22  pkj
+ * Completed ext_baud_table[] in cflag_to_baud() and cflag_to_etrax_baud().
+ *
+ * Revision 1.17  2001/08/24 11:32:49  ronny
+ * More fixes for the CONFIG_ETRAX_SERIAL_PORT0 define.
+ *
+ * Revision 1.16  2001/08/24 07:56:22  ronny
+ * Added config ifdefs around ser0 irq requests.
+ *
+ * Revision 1.15  2001/08/16 09:10:31  bjarne
+ * serial.c - corrected the initialization of rs_table, the wrong defines
+ *            where used.
+ *            Corrected a test in timed_flush_handler.
+ *            Changed configured to enabled.
+ * serial.h - Changed configured to enabled.
+ *
+ * Revision 1.14  2001/08/15 07:31:23  bjarne
+ * Introduced two new members to the e100_serial struct.
+ * configured - Will be set to 1 if the port has been configured in .config
+ * uses_dma   - Should be set to 1 if the port uses DMA. Currently it is set
+ *              to 1
+ *              when a port is opened. This is used to limit the DMA interrupt
+ *              routines to only manipulate DMA channels actually used by the
+ *              serial driver.
+ *
+ * Revision 1.13.2.2  2001/10/17 13:57:13  starvik
+ * Receiver was broken by the break fixes
+ *
+ * Revision 1.13.2.1  2001/07/20 13:57:39  ronny
+ * Merge with new stuff from etrax100ser.c. Works but haven't checked stuff
+ * like break handling.
+ *
+ * Revision 1.13  2001/05/09 12:40:31  johana
+ * Use DMA_NBR and IRQ_NBR defines from dma.h and irq.h
+ *
+ * Revision 1.12  2001/04/19 12:23:07  bjornw
+ * CONFIG_RS485 -> CONFIG_ETRAX_RS485
+ *
+ * Revision 1.11  2001/04/05 14:29:48  markusl
+ * Updated according to review remarks i.e.
+ * -Use correct types in port structure to avoid compiler warnings
+ * -Try to use IO_* macros whenever possible
+ * -Open should never return -EBUSY
+ *
+ * Revision 1.10  2001/03/05 13:14:07  bjornw
+ * Another spelling fix
+ *
+ * Revision 1.9  2001/02/23 13:46:38  bjornw
+ * Spellling check
+ *
+ * Revision 1.8  2001/01/23 14:56:35  markusl
+ * Made use of ser1 optional
+ * Needed by USB
+ *
+ * Revision 1.7  2001/01/19 16:14:48  perf
+ * Added kernel options for serial ports 234.
+ * Changed option names from CONFIG_ETRAX100_XYZ to CONFIG_ETRAX_XYZ.
+ *
+ * Revision 1.6  2000/11/22 16:36:09  bjornw
+ * Please marketing by using the correct case when spelling Etrax.
+ *
+ * Revision 1.5  2000/11/21 16:43:37  bjornw
+ * Fixed so it compiles under CONFIG_SVINTO_SIM
+ *
+ * Revision 1.4  2000/11/15 17:34:12  bjornw
+ * Added a timeout timer for flushing input channels. The interrupt-based
+ * fast flush system should be easy to merge with this later (works the same
+ * way, only with an irq instead of a system timer_list)
+ *
+ * Revision 1.3  2000/11/13 17:19:57  bjornw
+ * * Incredibly, this almost complete rewrite of serial.c worked (at least
+ *   for output) the first time.
+ *
+ *   Items worth noticing:
+ *
+ *      No Etrax100 port 1 workarounds (does only compile on 2.4 anyway now)
+ *      RS485 is not ported (why can't it be done in userspace as on x86 ?)
+ *      Statistics done through async_icount - if any more stats are needed,
+ *      that's the place to put them or in an arch-dep version of it.
+ *      timeout_interrupt and the other fast timeout stuff not ported yet
+ *      There be dragons in this 3k+ line driver
+ *
+ * Revision 1.2  2000/11/10 16:50:28  bjornw
+ * First shot at a 2.4 port, does not compile totally yet
+ *
+ * Revision 1.1  2000/11/10 16:47:32  bjornw
+ * Added verbatim copy of rev 1.49 etrax100ser.c from elinux
+ *
+ * Revision 1.49  2000/10/30 15:47:14  tobiasa
+ * Changed version number.
+ *
+ * Revision 1.48  2000/10/25 11:02:43  johana
+ * Changed %ul to %lu in printf's
+ *
+ * Revision 1.47  2000/10/18 15:06:53  pkj
+ * Compile correctly with CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST and
+ * CONFIG_ETRAX_SERIAL_PROC_ENTRY together.
+ * Some clean-up of the /proc/serial file.
+ *
+ * Revision 1.46  2000/10/16 12:59:40  johana
+ * Added CONFIG_ETRAX_SERIAL_PROC_ENTRY for statistics and debug info.
+ *
+ * Revision 1.45  2000/10/13 17:10:59  pkj
+ * Do not flush DMAs while flipping TTY buffers.
+ *
+ * Revision 1.44  2000/10/13 16:34:29  pkj
+ * Added a delay in ser_interrupt() for 2.3ms when an error is detected.
+ * We do not know why this delay is required yet, but without it the
+ * irmaflash program does not work (this was the program that needed
+ * the ser_interrupt() to be needed in the first place). This should not
+ * affect normal use of the serial ports.
+ *
+ * Revision 1.43  2000/10/13 16:30:44  pkj
+ * New version of the fast flush of serial buffers code. This time
+ * it is localized to the serial driver and uses a fast timer to
+ * do the work.
+ *
+ * Revision 1.42  2000/10/13 14:54:26  bennyo
+ * Fix for switching RTS when using rs485
+ *
+ * Revision 1.41  2000/10/12 11:43:44  pkj
+ * Cleaned up a number of comments.
+ *
+ * Revision 1.40  2000/10/10 11:58:39  johana
+ * Made RS485 support generic for all ports.
+ * Toggle rts in interrupt if no delay wanted.
+ * WARNING: No true transmitter empty check??
+ * Set d_wait bit when sending data so interrupt is delayed until
+ * fifo flushed. (Fix tcdrain() problem)
+ *
+ * Revision 1.39  2000/10/04 16:08:02  bjornw
+ * * Use virt_to_phys etc. for DMA addresses
+ * * Removed CONFIG_FLUSH_DMA_FAST hacks
+ * * Indentation fix
+ *
+ * Revision 1.38  2000/10/02 12:27:10  mattias
+ * * added variable used when using fast flush on serial dma.
+ *   (CONFIG_FLUSH_DMA_FAST)
+ *
+ * Revision 1.37  2000/09/27 09:44:24  pkj
+ * Uncomment definition of SERIAL_HANDLE_EARLY_ERRORS.
+ *
+ * Revision 1.36  2000/09/20 13:12:52  johana
+ * Support for CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS:
+ *   Number of timer ticks between flush of receive fifo (1 tick = 10ms).
+ *   Try 0-3 for low latency applications. Approx 5 for high load
+ *   applications (e.g. PPP). Maybe this should be more adaptive some day...
+ *
+ * Revision 1.35  2000/09/20 10:36:08  johana
+ * Typo in get_lsr_info()
+ *
+ * Revision 1.34  2000/09/20 10:29:59  johana
+ * Let rs_chars_in_buffer() check fifo content as well.
+ * get_lsr_info() might work now (not tested).
+ * Easier to change the port to debug.
+ *
+ * Revision 1.33  2000/09/13 07:52:11  torbjore
+ * Support RS485
+ *
+ * Revision 1.32  2000/08/31 14:45:37  bjornw
+ * After sending a break we need to reset the transmit DMA channel
+ *
+ * Revision 1.31  2000/06/21 12:13:29  johana
+ * Fixed wait for all chars sent when closing port.
+ * (Used to always take 1 second!)
+ * Added shadows for directions of status/ctrl signals.
+ *
+ * Revision 1.30  2000/05/29 16:27:55  bjornw
+ * Simulator ifdef moved a bit
+ *
+ * Revision 1.29  2000/05/09 09:40:30  mattias
+ * * Added description of dma registers used in timeout_interrupt
+ * * Removed old code
+ *
+ * Revision 1.28  2000/05/08 16:38:58  mattias
+ * * Bugfix for flushing fifo in timeout_interrupt
+ *   Problem occurs when bluetooth stack waits for a small number of bytes
+ *   containing an event acknowledging free buffers in bluetooth HW
+ *   As before, data was stuck in fifo until more data came on uart and
+ *   flushed it up to the stack.
+ *
+ * Revision 1.27  2000/05/02 09:52:28  jonasd
+ * Added fix for peculiar etrax behaviour when eop is forced on an empty
+ * fifo. This is used when flashing the IRMA chip. Disabled by default.
+ *
+ * Revision 1.26  2000/03/29 15:32:02  bjornw
+ * 2.0.34 updates
+ *
+ * Revision 1.25  2000/02/16 16:59:36  bjornw
+ * * Receive DMA directly into the flip-buffer, eliminating an intermediary
+ *   receive buffer and a memcpy. Will avoid some overruns.
+ * * Error message on debug port if an overrun or flip buffer overrun occurs.
+ * * Just use the first byte in the flag flip buffer for errors.
+ * * Check for timeout on the serial ports only each 5/100 s, not 1/100.
+ *
+ * Revision 1.24  2000/02/09 18:02:28  bjornw
+ * * Clear serial errors (overrun, framing, parity) correctly. Before, the
+ *   receiver would get stuck if an error occurred and we did not restart
+ *   the input DMA.
+ * * Cosmetics (indentation, some code made into inlines)
+ * * Some more debug options
+ * * Actually shut down the serial port (DMA irq, DMA reset, receiver stop)
+ *   when the last open is closed. Corresponding fixes in startup().
+ * * rs_close() "tx FIFO wait" code moved into right place, bug & -> && fixed
+ *   and make a special case out of port 1 (R_DMA_CHx_STATUS is broken for that)
+ * * e100_disable_rx/enable_rx just disables/enables the receiver, not RTS
+ *
+ * Revision 1.23  2000/01/24 17:46:19  johana
+ * Wait for flush of DMA/FIFO when closing port.
+ *
+ * Revision 1.22  2000/01/20 18:10:23  johana
+ * Added TIOCMGET ioctl to return modem status.
+ * Implemented modem status/control that works with the extra signals
+ * (DTR, DSR, RI,CD) as well.
+ * 3 different modes supported:
+ * ser0 on PB (Bundy), ser1 on PB (Lisa) and ser2 on PA (Bundy)
+ * Fixed DEF_TX value that caused the serial transmitter pin (txd) to go to 0 when
+ * closing the last filehandle, NASTY!.
+ * Added break generation, not tested though!
+ * Use SA_SHIRQ when request_irq() for ser2 and ser3 (shared with) par0 and par1.
+ * You can't use them at the same time (yet..), but you can hopefully switch
+ * between ser2/par0, ser3/par1 with the same kernel config.
+ * Replaced some magic constants with defines
+ *
+ *
+ */
+
+static char *serial_version = "$Revision: 1.25 $";
+
+#include <linux/config.h>
+#include <linux/version.h>
+
+#include <linux/types.h>
+#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/mm.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <linux/kernel.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <asm/segment.h>
+#include <asm/bitops.h>
+#include <linux/delay.h>
+
+#include <asm/arch/svinto.h>
+
+/* non-arch dependent serial structures are in linux/serial.h */
+#include <linux/serial.h>
+/* while we keep our own stuff (struct e100_serial) in a local .h file */
+#include "serial.h"
+#include <asm/fasttimer.h>
+
+#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
+#ifndef CONFIG_ETRAX_FAST_TIMER
+#error "Enable FAST_TIMER to use SERIAL_FAST_TIMER"
+#endif
+#endif
+
+#if defined(CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS) && \
+           (CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS == 0)
+#error "RX_TIMEOUT_TICKS == 0 not allowed, use 1"
+#endif
+
+#if defined(CONFIG_ETRAX_RS485_ON_PA) && defined(CONFIG_ETRAX_RS485_ON_PORT_G)
+#error "Disable either CONFIG_ETRAX_RS485_ON_PA or CONFIG_ETRAX_RS485_ON_PORT_G"
+#endif
+
+/*
+ * All of the compatibilty code so we can compile serial.c against
+ * older kernels is hidden in serial_compat.h
+ */
+#if defined(LOCAL_HEADERS)
+#include "serial_compat.h"
+#endif
+
+#define _INLINE_ inline
+
+struct tty_driver *serial_driver;
+
+/* serial subtype definitions */
+#ifndef SERIAL_TYPE_NORMAL
+#define SERIAL_TYPE_NORMAL	1
+#endif
+
+/* number of characters left in xmit buffer before we ask for more */
+#define WAKEUP_CHARS 256
+
+//#define SERIAL_DEBUG_INTR
+//#define SERIAL_DEBUG_OPEN
+//#define SERIAL_DEBUG_FLOW
+//#define SERIAL_DEBUG_DATA
+//#define SERIAL_DEBUG_THROTTLE
+//#define SERIAL_DEBUG_IO  /* Debug for Extra control and status pins */
+//#define SERIAL_DEBUG_LINE 0 /* What serport we want to debug */
+
+/* Enable this to use serial interrupts to handle when you
+   expect the first received event on the serial port to
+   be an error, break or similar. Used to be able to flash IRMA
+   from eLinux */
+#define SERIAL_HANDLE_EARLY_ERRORS
+
+/* Defined and used in n_tty.c, but we need it here as well */
+#define TTY_THRESHOLD_THROTTLE 128
+
+/* Due to buffersizes and threshold values, our SERIAL_DESCR_BUF_SIZE
+ * must not be to high or flow control won't work if we leave it to the tty
+ * layer so we have our own throttling in flush_to_flip
+ * TTY_FLIPBUF_SIZE=512,
+ * TTY_THRESHOLD_THROTTLE/UNTHROTTLE=128
+ * BUF_SIZE can't be > 128
+ */
+/* Currently 16 descriptors x 128 bytes = 2048 bytes */
+#define SERIAL_DESCR_BUF_SIZE 256
+
+#define SERIAL_PRESCALE_BASE 3125000 /* 3.125MHz */
+#define DEF_BAUD_BASE SERIAL_PRESCALE_BASE
+
+/* We don't want to load the system with massive fast timer interrupt
+ * on high baudrates so limit it to 250 us (4kHz) */
+#define MIN_FLUSH_TIME_USEC 250
+
+/* Add an x here to log a lot of timer stuff */
+#define TIMERD(x)
+/* Debug details of interrupt handling */
+#define DINTR1(x)  /* irq on/off, errors */
+#define DINTR2(x)    /* tx and rx */
+/* Debug flip buffer stuff */
+#define DFLIP(x)
+/* Debug flow control and overview of data flow */
+#define DFLOW(x)
+#define DBAUD(x)
+#define DLOG_INT_TRIG(x)
+
+//#define DEBUG_LOG_INCLUDED
+#ifndef DEBUG_LOG_INCLUDED
+#define DEBUG_LOG(line, string, value)
+#else
+struct debug_log_info
+{
+	unsigned long time;
+	unsigned long timer_data;
+//  int line;
+	const char *string;
+	int value;
+};
+#define DEBUG_LOG_SIZE 4096
+
+struct debug_log_info debug_log[DEBUG_LOG_SIZE];
+int debug_log_pos = 0;
+
+#define DEBUG_LOG(_line, _string, _value) do { \
+  if ((_line) == SERIAL_DEBUG_LINE) {\
+    debug_log_func(_line, _string, _value); \
+  }\
+}while(0)
+
+void debug_log_func(int line, const char *string, int value)
+{
+	if (debug_log_pos < DEBUG_LOG_SIZE) {
+		debug_log[debug_log_pos].time = jiffies;
+		debug_log[debug_log_pos].timer_data = *R_TIMER_DATA;
+//    debug_log[debug_log_pos].line = line;
+		debug_log[debug_log_pos].string = string;
+		debug_log[debug_log_pos].value = value;
+		debug_log_pos++;
+	}
+	/*printk(string, value);*/
+}
+#endif
+
+#ifndef CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS
+/* Default number of timer ticks before flushing rx fifo
+ * When using "little data, low latency applications: use 0
+ * When using "much data applications (PPP)" use ~5
+ */
+#define CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS 5
+#endif
+
+unsigned long timer_data_to_ns(unsigned long timer_data);
+
+static void change_speed(struct e100_serial *info);
+static void rs_throttle(struct tty_struct * tty);
+static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
+static int rs_write(struct tty_struct * tty, int from_user,
+                    const unsigned char *buf, int count);
+extern _INLINE_ int rs_raw_write(struct tty_struct * tty, int from_user,
+                            const unsigned char *buf, int count);
+#ifdef CONFIG_ETRAX_RS485
+static int e100_write_rs485(struct tty_struct * tty, int from_user,
+                            const unsigned char *buf, int count);
+#endif
+static int get_lsr_info(struct e100_serial * info, unsigned int *value);
+
+
+#define DEF_BAUD 115200   /* 115.2 kbit/s */
+#define STD_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
+#define DEF_RX 0x20  /* or SERIAL_CTRL_W >> 8 */
+/* Default value of tx_ctrl register: has txd(bit 7)=1 (idle) as default */
+#define DEF_TX 0x80  /* or SERIAL_CTRL_B */
+
+/* offsets from R_SERIALx_CTRL */
+
+#define REG_DATA 0
+#define REG_DATA_STATUS32 0 /* this is the 32 bit register R_SERIALx_READ */
+#define REG_TR_DATA 0
+#define REG_STATUS 1
+#define REG_TR_CTRL 1
+#define REG_REC_CTRL 2
+#define REG_BAUD 3
+#define REG_XOFF 4  /* this is a 32 bit register */
+
+/* The bitfields are the same for all serial ports */
+#define SER_RXD_MASK         IO_MASK(R_SERIAL0_STATUS, rxd)
+#define SER_DATA_AVAIL_MASK  IO_MASK(R_SERIAL0_STATUS, data_avail)
+#define SER_FRAMING_ERR_MASK IO_MASK(R_SERIAL0_STATUS, framing_err)
+#define SER_PAR_ERR_MASK     IO_MASK(R_SERIAL0_STATUS, par_err)
+#define SER_OVERRUN_MASK     IO_MASK(R_SERIAL0_STATUS, overrun)
+
+#define SER_ERROR_MASK (SER_OVERRUN_MASK | SER_PAR_ERR_MASK | SER_FRAMING_ERR_MASK)
+
+/* Values for info->errorcode */
+#define ERRCODE_SET_BREAK    (TTY_BREAK)
+#define ERRCODE_INSERT        0x100
+#define ERRCODE_INSERT_BREAK (ERRCODE_INSERT | TTY_BREAK)
+
+#define FORCE_EOP(info)  *R_SET_EOP = 1U << info->iseteop;
+
+/*
+ * General note regarding the use of IO_* macros in this file:
+ *
+ * We will use the bits defined for DMA channel 6 when using various
+ * IO_* macros (e.g. IO_STATE, IO_MASK, IO_EXTRACT) and _assume_ they are
+ * the same for all channels (which of course they are).
+ *
+ * We will also use the bits defined for serial port 0 when writing commands
+ * to the different ports, as these bits too are the same for all ports.
+ */
+
+
+/* Mask for the irqs possibly enabled in R_IRQ_MASK1_RD etc. */
+static const unsigned long e100_ser_int_mask = 0
+#ifdef CONFIG_ETRAX_SERIAL_PORT0
+| IO_MASK(R_IRQ_MASK1_RD, ser0_data) | IO_MASK(R_IRQ_MASK1_RD, ser0_ready)
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT1
+| IO_MASK(R_IRQ_MASK1_RD, ser1_data) | IO_MASK(R_IRQ_MASK1_RD, ser1_ready)
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT2
+| IO_MASK(R_IRQ_MASK1_RD, ser2_data) | IO_MASK(R_IRQ_MASK1_RD, ser2_ready)
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT3
+| IO_MASK(R_IRQ_MASK1_RD, ser3_data) | IO_MASK(R_IRQ_MASK1_RD, ser3_ready)
+#endif
+;
+unsigned long r_alt_ser_baudrate_shadow = 0;
+
+/* this is the data for the four serial ports in the etrax100 */
+/*  DMA2(ser2), DMA4(ser3), DMA6(ser0) or DMA8(ser1) */
+/* R_DMA_CHx_CLR_INTR, R_DMA_CHx_FIRST, R_DMA_CHx_CMD */
+
+static struct e100_serial rs_table[] = {
+	{ .baud        = DEF_BAUD,
+	  .port        = (unsigned char *)R_SERIAL0_CTRL,
+	  .irq         = 1U << 12, /* uses DMA 6 and 7 */
+	  .oclrintradr = R_DMA_CH6_CLR_INTR,
+	  .ofirstadr   = R_DMA_CH6_FIRST,
+	  .ocmdadr     = R_DMA_CH6_CMD,
+	  .ostatusadr  = R_DMA_CH6_STATUS,
+	  .iclrintradr = R_DMA_CH7_CLR_INTR,
+	  .ifirstadr   = R_DMA_CH7_FIRST,
+	  .icmdadr     = R_DMA_CH7_CMD,
+	  .idescradr   = R_DMA_CH7_DESCR,
+	  .flags       = STD_FLAGS,
+	  .rx_ctrl     = DEF_RX,
+	  .tx_ctrl     = DEF_TX,
+	  .iseteop     = 2,
+#ifdef CONFIG_ETRAX_SERIAL_PORT0
+          .enabled  = 1,
+#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA6_OUT
+	  .dma_out_enabled = 1,
+#else
+	  .dma_out_enabled = 0,
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA7_IN
+	  .dma_in_enabled = 1,
+#else
+	  .dma_in_enabled = 0
+#endif
+#else
+          .enabled  = 0,
+	  .dma_out_enabled = 0,
+	  .dma_in_enabled = 0
+#endif
+
+},  /* ttyS0 */
+#ifndef CONFIG_SVINTO_SIM
+	{ .baud        = DEF_BAUD,
+	  .port        = (unsigned char *)R_SERIAL1_CTRL,
+	  .irq         = 1U << 16, /* uses DMA 8 and 9 */
+	  .oclrintradr = R_DMA_CH8_CLR_INTR,
+	  .ofirstadr   = R_DMA_CH8_FIRST,
+	  .ocmdadr     = R_DMA_CH8_CMD,
+	  .ostatusadr  = R_DMA_CH8_STATUS,
+	  .iclrintradr = R_DMA_CH9_CLR_INTR,
+	  .ifirstadr   = R_DMA_CH9_FIRST,
+	  .icmdadr     = R_DMA_CH9_CMD,
+	  .idescradr   = R_DMA_CH9_DESCR,
+	  .flags       = STD_FLAGS,
+	  .rx_ctrl     = DEF_RX,
+	  .tx_ctrl     = DEF_TX,
+	  .iseteop     = 3,
+#ifdef CONFIG_ETRAX_SERIAL_PORT1
+          .enabled  = 1,
+#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA8_OUT
+	  .dma_out_enabled = 1,
+#else
+	  .dma_out_enabled = 0,
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA9_IN
+	  .dma_in_enabled = 1,
+#else
+	  .dma_in_enabled = 0
+#endif
+#else
+          .enabled  = 0,
+	  .dma_out_enabled = 0,
+	  .dma_in_enabled = 0
+#endif
+},  /* ttyS1 */
+
+	{ .baud        = DEF_BAUD,
+	  .port        = (unsigned char *)R_SERIAL2_CTRL,
+	  .irq         = 1U << 4,  /* uses DMA 2 and 3 */
+	  .oclrintradr = R_DMA_CH2_CLR_INTR,
+	  .ofirstadr   = R_DMA_CH2_FIRST,
+	  .ocmdadr     = R_DMA_CH2_CMD,
+	  .ostatusadr  = R_DMA_CH2_STATUS,
+	  .iclrintradr = R_DMA_CH3_CLR_INTR,
+	  .ifirstadr   = R_DMA_CH3_FIRST,
+	  .icmdadr     = R_DMA_CH3_CMD,
+	  .idescradr   = R_DMA_CH3_DESCR,
+	  .flags       = STD_FLAGS,
+	  .rx_ctrl     = DEF_RX,
+	  .tx_ctrl     = DEF_TX,
+	  .iseteop     = 0,
+#ifdef CONFIG_ETRAX_SERIAL_PORT2
+          .enabled  = 1,
+#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA2_OUT
+	  .dma_out_enabled = 1,
+#else
+	  .dma_out_enabled = 0,
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA3_IN
+	  .dma_in_enabled = 1,
+#else
+	  .dma_in_enabled = 0
+#endif
+#else
+          .enabled  = 0,
+	  .dma_out_enabled = 0,
+	  .dma_in_enabled = 0
+#endif
+ },  /* ttyS2 */
+
+	{ .baud        = DEF_BAUD,
+	  .port        = (unsigned char *)R_SERIAL3_CTRL,
+	  .irq         = 1U << 8,  /* uses DMA 4 and 5 */
+	  .oclrintradr = R_DMA_CH4_CLR_INTR,
+	  .ofirstadr   = R_DMA_CH4_FIRST,
+	  .ocmdadr     = R_DMA_CH4_CMD,
+	  .ostatusadr  = R_DMA_CH4_STATUS,
+	  .iclrintradr = R_DMA_CH5_CLR_INTR,
+	  .ifirstadr   = R_DMA_CH5_FIRST,
+	  .icmdadr     = R_DMA_CH5_CMD,
+	  .idescradr   = R_DMA_CH5_DESCR,
+	  .flags       = STD_FLAGS,
+	  .rx_ctrl     = DEF_RX,
+	  .tx_ctrl     = DEF_TX,
+	  .iseteop     = 1,
+#ifdef CONFIG_ETRAX_SERIAL_PORT3
+          .enabled  = 1,
+#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA4_OUT
+	  .dma_out_enabled = 1,
+#else
+	  .dma_out_enabled = 0,
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA5_IN
+	  .dma_in_enabled = 1,
+#else
+	  .dma_in_enabled = 0
+#endif
+#else
+          .enabled  = 0,
+	  .dma_out_enabled = 0,
+	  .dma_in_enabled = 0
+#endif
+ }   /* ttyS3 */
+#endif
+};
+
+
+#define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial))
+
+static struct termios *serial_termios[NR_PORTS];
+static struct termios *serial_termios_locked[NR_PORTS];
+#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
+static struct fast_timer fast_timers[NR_PORTS];
+#endif
+
+#ifdef CONFIG_ETRAX_SERIAL_PROC_ENTRY
+#define PROCSTAT(x) x
+struct ser_statistics_type {
+	int overrun_cnt;
+	int early_errors_cnt;
+	int ser_ints_ok_cnt;
+	int errors_cnt;
+	unsigned long int processing_flip;
+	unsigned long processing_flip_still_room;
+	unsigned long int timeout_flush_cnt;
+	int rx_dma_ints;
+	int tx_dma_ints;
+	int rx_tot;
+	int tx_tot;
+};
+
+static struct ser_statistics_type ser_stat[NR_PORTS];
+
+#else
+
+#define PROCSTAT(x)
+
+#endif /* CONFIG_ETRAX_SERIAL_PROC_ENTRY */
+
+/* RS-485 */
+#if defined(CONFIG_ETRAX_RS485)
+#ifdef CONFIG_ETRAX_FAST_TIMER
+static struct fast_timer fast_timers_rs485[NR_PORTS];
+#endif
+#if defined(CONFIG_ETRAX_RS485_ON_PA)
+static int rs485_pa_bit = CONFIG_ETRAX_RS485_ON_PA_BIT;
+#endif
+#if defined(CONFIG_ETRAX_RS485_ON_PORT_G)
+static int rs485_port_g_bit = CONFIG_ETRAX_RS485_ON_PORT_G_BIT;
+#endif
+#endif
+
+/* Info and macros needed for each ports extra control/status signals. */
+#define E100_STRUCT_PORT(line, pinname) \
+ ((CONFIG_ETRAX_SER##line##_##pinname##_ON_PA_BIT >= 0)? \
+		(R_PORT_PA_DATA): ( \
+ (CONFIG_ETRAX_SER##line##_##pinname##_ON_PB_BIT >= 0)? \
+		(R_PORT_PB_DATA):&dummy_ser[line]))
+
+#define E100_STRUCT_SHADOW(line, pinname) \
+ ((CONFIG_ETRAX_SER##line##_##pinname##_ON_PA_BIT >= 0)? \
+		(&port_pa_data_shadow): ( \
+ (CONFIG_ETRAX_SER##line##_##pinname##_ON_PB_BIT >= 0)? \
+		(&port_pb_data_shadow):&dummy_ser[line]))
+#define E100_STRUCT_MASK(line, pinname) \
+ ((CONFIG_ETRAX_SER##line##_##pinname##_ON_PA_BIT >= 0)? \
+		(1<<CONFIG_ETRAX_SER##line##_##pinname##_ON_PA_BIT): ( \
+ (CONFIG_ETRAX_SER##line##_##pinname##_ON_PB_BIT >= 0)? \
+		(1<<CONFIG_ETRAX_SER##line##_##pinname##_ON_PB_BIT):DUMMY_##pinname##_MASK))
+
+#define DUMMY_DTR_MASK 1
+#define DUMMY_RI_MASK  2
+#define DUMMY_DSR_MASK 4
+#define DUMMY_CD_MASK  8
+static unsigned char dummy_ser[NR_PORTS] = {0xFF, 0xFF, 0xFF,0xFF};
+
+/* If not all status pins are used or disabled, use mixed mode */
+#ifdef CONFIG_ETRAX_SERIAL_PORT0
+
+#define SER0_PA_BITSUM (CONFIG_ETRAX_SER0_DTR_ON_PA_BIT+CONFIG_ETRAX_SER0_RI_ON_PA_BIT+CONFIG_ETRAX_SER0_DSR_ON_PA_BIT+CONFIG_ETRAX_SER0_CD_ON_PA_BIT)
+
+#if SER0_PA_BITSUM != -4
+#  if CONFIG_ETRAX_SER0_DTR_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#   endif
+# if CONFIG_ETRAX_SER0_RI_ON_PA_BIT == -1
+#   ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
+#     define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
+#   endif
+#  endif
+#  if CONFIG_ETRAX_SER0_DSR_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#  if CONFIG_ETRAX_SER0_CD_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#endif
+
+#define SER0_PB_BITSUM (CONFIG_ETRAX_SER0_DTR_ON_PB_BIT+CONFIG_ETRAX_SER0_RI_ON_PB_BIT+CONFIG_ETRAX_SER0_DSR_ON_PB_BIT+CONFIG_ETRAX_SER0_CD_ON_PB_BIT)
+
+#if SER0_PB_BITSUM != -4
+#  if CONFIG_ETRAX_SER0_DTR_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#   endif
+# if CONFIG_ETRAX_SER0_RI_ON_PB_BIT == -1
+#   ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
+#     define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
+#   endif
+#  endif
+#  if CONFIG_ETRAX_SER0_DSR_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#  if CONFIG_ETRAX_SER0_CD_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#endif
+
+#endif /* PORT0 */
+
+
+#ifdef CONFIG_ETRAX_SERIAL_PORT1
+
+#define SER1_PA_BITSUM (CONFIG_ETRAX_SER1_DTR_ON_PA_BIT+CONFIG_ETRAX_SER1_RI_ON_PA_BIT+CONFIG_ETRAX_SER1_DSR_ON_PA_BIT+CONFIG_ETRAX_SER1_CD_ON_PA_BIT)
+
+#if SER1_PA_BITSUM != -4
+#  if CONFIG_ETRAX_SER1_DTR_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#   endif
+# if CONFIG_ETRAX_SER1_RI_ON_PA_BIT == -1
+#   ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
+#     define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
+#   endif
+#  endif
+#  if CONFIG_ETRAX_SER1_DSR_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#  if CONFIG_ETRAX_SER1_CD_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#endif
+
+#define SER1_PB_BITSUM (CONFIG_ETRAX_SER1_DTR_ON_PB_BIT+CONFIG_ETRAX_SER1_RI_ON_PB_BIT+CONFIG_ETRAX_SER1_DSR_ON_PB_BIT+CONFIG_ETRAX_SER1_CD_ON_PB_BIT)
+
+#if SER1_PB_BITSUM != -4
+#  if CONFIG_ETRAX_SER1_DTR_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#   endif
+# if CONFIG_ETRAX_SER1_RI_ON_PB_BIT == -1
+#   ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
+#     define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
+#   endif
+#  endif
+#  if CONFIG_ETRAX_SER1_DSR_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#  if CONFIG_ETRAX_SER1_CD_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#endif
+
+#endif /* PORT1 */
+
+#ifdef CONFIG_ETRAX_SERIAL_PORT2
+
+#define SER2_PA_BITSUM (CONFIG_ETRAX_SER2_DTR_ON_PA_BIT+CONFIG_ETRAX_SER2_RI_ON_PA_BIT+CONFIG_ETRAX_SER2_DSR_ON_PA_BIT+CONFIG_ETRAX_SER2_CD_ON_PA_BIT)
+
+#if SER2_PA_BITSUM != -4
+#  if CONFIG_ETRAX_SER2_DTR_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#   endif
+# if CONFIG_ETRAX_SER2_RI_ON_PA_BIT == -1
+#   ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
+#     define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
+#   endif
+#  endif
+#  if CONFIG_ETRAX_SER2_DSR_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#  if CONFIG_ETRAX_SER2_CD_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#endif
+
+#define SER2_PB_BITSUM (CONFIG_ETRAX_SER2_DTR_ON_PB_BIT+CONFIG_ETRAX_SER2_RI_ON_PB_BIT+CONFIG_ETRAX_SER2_DSR_ON_PB_BIT+CONFIG_ETRAX_SER2_CD_ON_PB_BIT)
+
+#if SER2_PB_BITSUM != -4
+#  if CONFIG_ETRAX_SER2_DTR_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#   endif
+# if CONFIG_ETRAX_SER2_RI_ON_PB_BIT == -1
+#   ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
+#     define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
+#   endif
+#  endif
+#  if CONFIG_ETRAX_SER2_DSR_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#  if CONFIG_ETRAX_SER2_CD_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#endif
+
+#endif /* PORT2 */
+
+#ifdef CONFIG_ETRAX_SERIAL_PORT3
+
+#define SER3_PA_BITSUM (CONFIG_ETRAX_SER3_DTR_ON_PA_BIT+CONFIG_ETRAX_SER3_RI_ON_PA_BIT+CONFIG_ETRAX_SER3_DSR_ON_PA_BIT+CONFIG_ETRAX_SER3_CD_ON_PA_BIT)
+
+#if SER3_PA_BITSUM != -4
+#  if CONFIG_ETRAX_SER3_DTR_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#   endif
+# if CONFIG_ETRAX_SER3_RI_ON_PA_BIT == -1
+#   ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
+#     define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
+#   endif
+#  endif
+#  if CONFIG_ETRAX_SER3_DSR_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#  if CONFIG_ETRAX_SER3_CD_ON_PA_BIT == -1
+#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#endif
+
+#define SER3_PB_BITSUM (CONFIG_ETRAX_SER3_DTR_ON_PB_BIT+CONFIG_ETRAX_SER3_RI_ON_PB_BIT+CONFIG_ETRAX_SER3_DSR_ON_PB_BIT+CONFIG_ETRAX_SER3_CD_ON_PB_BIT)
+
+#if SER3_PB_BITSUM != -4
+#  if CONFIG_ETRAX_SER3_DTR_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#   endif
+# if CONFIG_ETRAX_SER3_RI_ON_PB_BIT == -1
+#   ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
+#     define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
+#   endif
+#  endif
+#  if CONFIG_ETRAX_SER3_DSR_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#  if CONFIG_ETRAX_SER3_CD_ON_PB_BIT == -1
+#    ifndef CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED
+#      define CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED 1
+#    endif
+#  endif
+#endif
+
+#endif /* PORT3 */
+
+
+#if defined(CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_MIXED) || \
+    defined(CONFIG_ETRAX_SER1_DTR_RI_DSR_CD_MIXED) || \
+    defined(CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_MIXED) || \
+    defined(CONFIG_ETRAX_SER3_DTR_RI_DSR_CD_MIXED)
+#define CONFIG_ETRAX_SERX_DTR_RI_DSR_CD_MIXED
+#endif
+
+#ifdef CONFIG_ETRAX_SERX_DTR_RI_DSR_CD_MIXED
+/* The pins can be mixed on PA and PB */
+#define CONTROL_PINS_PORT_NOT_USED(line) \
+  &dummy_ser[line], &dummy_ser[line], \
+  &dummy_ser[line], &dummy_ser[line], \
+  &dummy_ser[line], &dummy_ser[line], \
+  &dummy_ser[line], &dummy_ser[line], \
+  DUMMY_DTR_MASK, DUMMY_RI_MASK, DUMMY_DSR_MASK, DUMMY_CD_MASK
+
+
+struct control_pins
+{
+	volatile unsigned char *dtr_port;
+	unsigned char          *dtr_shadow;
+	volatile unsigned char *ri_port;
+	unsigned char          *ri_shadow;
+	volatile unsigned char *dsr_port;
+	unsigned char          *dsr_shadow;
+	volatile unsigned char *cd_port;
+	unsigned char          *cd_shadow;
+
+	unsigned char dtr_mask;
+	unsigned char ri_mask;
+	unsigned char dsr_mask;
+	unsigned char cd_mask;
+};
+
+static const struct control_pins e100_modem_pins[NR_PORTS] =
+{
+	/* Ser 0 */
+	{
+#ifdef CONFIG_ETRAX_SERIAL_PORT0
+	E100_STRUCT_PORT(0,DTR), E100_STRUCT_SHADOW(0,DTR),
+	E100_STRUCT_PORT(0,RI),  E100_STRUCT_SHADOW(0,RI),
+	E100_STRUCT_PORT(0,DSR), E100_STRUCT_SHADOW(0,DSR),
+	E100_STRUCT_PORT(0,CD),  E100_STRUCT_SHADOW(0,CD),
+	E100_STRUCT_MASK(0,DTR),
+	E100_STRUCT_MASK(0,RI),
+	E100_STRUCT_MASK(0,DSR),
+	E100_STRUCT_MASK(0,CD)
+#else
+	CONTROL_PINS_PORT_NOT_USED(0)
+#endif
+	},
+
+	/* Ser 1 */
+	{
+#ifdef CONFIG_ETRAX_SERIAL_PORT1
+	E100_STRUCT_PORT(1,DTR), E100_STRUCT_SHADOW(1,DTR),
+	E100_STRUCT_PORT(1,RI),  E100_STRUCT_SHADOW(1,RI),
+	E100_STRUCT_PORT(1,DSR), E100_STRUCT_SHADOW(1,DSR),
+	E100_STRUCT_PORT(1,CD),  E100_STRUCT_SHADOW(1,CD),
+	E100_STRUCT_MASK(1,DTR),
+	E100_STRUCT_MASK(1,RI),
+	E100_STRUCT_MASK(1,DSR),
+	E100_STRUCT_MASK(1,CD)
+#else
+	CONTROL_PINS_PORT_NOT_USED(1)
+#endif
+	},
+
+	/* Ser 2 */
+	{
+#ifdef CONFIG_ETRAX_SERIAL_PORT2
+	E100_STRUCT_PORT(2,DTR), E100_STRUCT_SHADOW(2,DTR),
+	E100_STRUCT_PORT(2,RI),  E100_STRUCT_SHADOW(2,RI),
+	E100_STRUCT_PORT(2,DSR), E100_STRUCT_SHADOW(2,DSR),
+	E100_STRUCT_PORT(2,CD),  E100_STRUCT_SHADOW(2,CD),
+	E100_STRUCT_MASK(2,DTR),
+	E100_STRUCT_MASK(2,RI),
+	E100_STRUCT_MASK(2,DSR),
+	E100_STRUCT_MASK(2,CD)
+#else
+	CONTROL_PINS_PORT_NOT_USED(2)
+#endif
+	},
+
+	/* Ser 3 */
+	{
+#ifdef CONFIG_ETRAX_SERIAL_PORT3
+	E100_STRUCT_PORT(3,DTR), E100_STRUCT_SHADOW(3,DTR),
+	E100_STRUCT_PORT(3,RI),  E100_STRUCT_SHADOW(3,RI),
+	E100_STRUCT_PORT(3,DSR), E100_STRUCT_SHADOW(3,DSR),
+	E100_STRUCT_PORT(3,CD),  E100_STRUCT_SHADOW(3,CD),
+	E100_STRUCT_MASK(3,DTR),
+	E100_STRUCT_MASK(3,RI),
+	E100_STRUCT_MASK(3,DSR),
+	E100_STRUCT_MASK(3,CD)
+#else
+	CONTROL_PINS_PORT_NOT_USED(3)
+#endif
+	}
+};
+#else  /* CONFIG_ETRAX_SERX_DTR_RI_DSR_CD_MIXED */
+
+/* All pins are on either PA or PB for each serial port */
+#define CONTROL_PINS_PORT_NOT_USED(line) \
+  &dummy_ser[line], &dummy_ser[line], \
+  DUMMY_DTR_MASK, DUMMY_RI_MASK, DUMMY_DSR_MASK, DUMMY_CD_MASK
+
+
+struct control_pins
+{
+	volatile unsigned char *port;
+	unsigned char          *shadow;
+
+	unsigned char dtr_mask;
+	unsigned char ri_mask;
+	unsigned char dsr_mask;
+	unsigned char cd_mask;
+};
+
+#define dtr_port port
+#define dtr_shadow shadow
+#define ri_port port
+#define ri_shadow shadow
+#define dsr_port port
+#define dsr_shadow shadow
+#define cd_port port
+#define cd_shadow shadow
+
+static const struct control_pins e100_modem_pins[NR_PORTS] =
+{
+	/* Ser 0 */
+	{
+#ifdef CONFIG_ETRAX_SERIAL_PORT0
+	E100_STRUCT_PORT(0,DTR), E100_STRUCT_SHADOW(0,DTR),
+	E100_STRUCT_MASK(0,DTR),
+	E100_STRUCT_MASK(0,RI),
+	E100_STRUCT_MASK(0,DSR),
+	E100_STRUCT_MASK(0,CD)
+#else
+	CONTROL_PINS_PORT_NOT_USED(0)
+#endif
+	},
+
+	/* Ser 1 */
+	{
+#ifdef CONFIG_ETRAX_SERIAL_PORT1
+	E100_STRUCT_PORT(1,DTR), E100_STRUCT_SHADOW(1,DTR),
+	E100_STRUCT_MASK(1,DTR),
+	E100_STRUCT_MASK(1,RI),
+	E100_STRUCT_MASK(1,DSR),
+	E100_STRUCT_MASK(1,CD)
+#else
+	CONTROL_PINS_PORT_NOT_USED(1)
+#endif
+	},
+
+	/* Ser 2 */
+	{
+#ifdef CONFIG_ETRAX_SERIAL_PORT2
+	E100_STRUCT_PORT(2,DTR), E100_STRUCT_SHADOW(2,DTR),
+	E100_STRUCT_MASK(2,DTR),
+	E100_STRUCT_MASK(2,RI),
+	E100_STRUCT_MASK(2,DSR),
+	E100_STRUCT_MASK(2,CD)
+#else
+	CONTROL_PINS_PORT_NOT_USED(2)
+#endif
+	},
+
+	/* Ser 3 */
+	{
+#ifdef CONFIG_ETRAX_SERIAL_PORT3
+	E100_STRUCT_PORT(3,DTR), E100_STRUCT_SHADOW(3,DTR),
+	E100_STRUCT_MASK(3,DTR),
+	E100_STRUCT_MASK(3,RI),
+	E100_STRUCT_MASK(3,DSR),
+	E100_STRUCT_MASK(3,CD)
+#else
+	CONTROL_PINS_PORT_NOT_USED(3)
+#endif
+	}
+};
+#endif /* !CONFIG_ETRAX_SERX_DTR_RI_DSR_CD_MIXED */
+
+#define E100_RTS_MASK 0x20
+#define E100_CTS_MASK 0x40
+
+/* All serial port signals are active low:
+ * active   = 0 -> 3.3V to RS-232 driver -> -12V on RS-232 level
+ * inactive = 1 -> 0V   to RS-232 driver -> +12V on RS-232 level
+ *
+ * These macros returns the pin value: 0=0V, >=1 = 3.3V on ETRAX chip
+ */
+
+/* Output */
+#define E100_RTS_GET(info) ((info)->rx_ctrl & E100_RTS_MASK)
+/* Input */
+#define E100_CTS_GET(info) ((info)->port[REG_STATUS] & E100_CTS_MASK)
+
+/* These are typically PA or PB and 0 means 0V, 1 means 3.3V */
+/* Is an output */
+#define E100_DTR_GET(info) ((*e100_modem_pins[(info)->line].dtr_shadow) & e100_modem_pins[(info)->line].dtr_mask)
+
+/* Normally inputs */
+#define E100_RI_GET(info) ((*e100_modem_pins[(info)->line].ri_port) & e100_modem_pins[(info)->line].ri_mask)
+#define E100_CD_GET(info) ((*e100_modem_pins[(info)->line].cd_port) & e100_modem_pins[(info)->line].cd_mask)
+
+/* Input */
+#define E100_DSR_GET(info) ((*e100_modem_pins[(info)->line].dsr_port) & e100_modem_pins[(info)->line].dsr_mask)
+
+
+/*
+ * tmp_buf is used as a temporary buffer by serial_write.  We need to
+ * lock it in case the memcpy_fromfs 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
+
+/* Calculate the chartime depending on baudrate, numbor of bits etc. */
+static void update_char_time(struct e100_serial * info)
+{
+	tcflag_t cflags = info->tty->termios->c_cflag;
+	int bits;
+
+	/* calc. number of bits / data byte */
+	/* databits + startbit and 1 stopbit */
+	if ((cflags & CSIZE) == CS7)
+		bits = 9;
+	else
+		bits = 10;
+
+	if (cflags & CSTOPB)     /* 2 stopbits ? */
+		bits++;
+
+	if (cflags & PARENB)     /* parity bit ? */
+		bits++;
+
+	/* calc timeout */
+	info->char_time_usec = ((bits * 1000000) / info->baud) + 1;
+	info->flush_time_usec = 4*info->char_time_usec;
+	if (info->flush_time_usec < MIN_FLUSH_TIME_USEC)
+		info->flush_time_usec = MIN_FLUSH_TIME_USEC;
+
+}
+
+/*
+ * This function maps from the Bxxxx defines in asm/termbits.h into real
+ * baud rates.
+ */
+
+static int
+cflag_to_baud(unsigned int cflag)
+{
+	static int baud_table[] = {
+		0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
+		4800, 9600, 19200, 38400 };
+
+	static int ext_baud_table[] = {
+		0, 57600, 115200, 230400, 460800, 921600, 1843200, 6250000,
+                0, 0, 0, 0, 0, 0, 0, 0 };
+
+	if (cflag & CBAUDEX)
+		return ext_baud_table[(cflag & CBAUD) & ~CBAUDEX];
+	else
+		return baud_table[cflag & CBAUD];
+}
+
+/* and this maps to an etrax100 hardware baud constant */
+
+static unsigned char
+cflag_to_etrax_baud(unsigned int cflag)
+{
+	char retval;
+
+	static char baud_table[] = {
+		-1, -1, -1, -1, -1, -1, -1, 0, 1, 2, -1, 3, 4, 5, 6, 7 };
+
+	static char ext_baud_table[] = {
+		-1, 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1 };
+
+	if (cflag & CBAUDEX)
+		retval = ext_baud_table[(cflag & CBAUD) & ~CBAUDEX];
+	else
+		retval = baud_table[cflag & CBAUD];
+
+	if (retval < 0) {
+		printk(KERN_WARNING "serdriver tried setting invalid baud rate, flags %x.\n", cflag);
+		retval = 5; /* choose default 9600 instead */
+	}
+
+	return retval | (retval << 4); /* choose same for both TX and RX */
+}
+
+
+/* Various static support functions */
+
+/* Functions to set or clear DTR/RTS on the requested line */
+/* It is complicated by the fact that RTS is a serial port register, while
+ * DTR might not be implemented in the HW at all, and if it is, it can be on
+ * any general port.
+ */
+
+
+static inline void
+e100_dtr(struct e100_serial *info, int set)
+{
+#ifndef CONFIG_SVINTO_SIM
+	unsigned char mask = e100_modem_pins[info->line].dtr_mask;
+
+#ifdef SERIAL_DEBUG_IO
+	printk("ser%i dtr %i mask: 0x%02X\n", info->line, set, mask);
+	printk("ser%i shadow before 0x%02X get: %i\n",
+	       info->line, *e100_modem_pins[info->line].dtr_shadow,
+	       E100_DTR_GET(info));
+#endif
+	/* DTR is active low */
+	{
+		unsigned long flags;
+
+		save_flags(flags);
+		cli();
+		*e100_modem_pins[info->line].dtr_shadow &= ~mask;
+		*e100_modem_pins[info->line].dtr_shadow |= (set ? 0 : mask);
+		*e100_modem_pins[info->line].dtr_port = *e100_modem_pins[info->line].dtr_shadow;
+		restore_flags(flags);
+	}
+
+#ifdef SERIAL_DEBUG_IO
+	printk("ser%i shadow after 0x%02X get: %i\n",
+	       info->line, *e100_modem_pins[info->line].dtr_shadow,
+	       E100_DTR_GET(info));
+#endif
+#endif
+}
+
+/* set = 0 means 3.3V on the pin, bitvalue: 0=active, 1=inactive
+ *                                          0=0V    , 1=3.3V
+ */
+static inline void
+e100_rts(struct e100_serial *info, int set)
+{
+#ifndef CONFIG_SVINTO_SIM
+	unsigned long flags;
+	save_flags(flags);
+	cli();
+	info->rx_ctrl &= ~E100_RTS_MASK;
+	info->rx_ctrl |= (set ? 0 : E100_RTS_MASK);  /* RTS is active low */
+	info->port[REG_REC_CTRL] = info->rx_ctrl;
+	restore_flags(flags);
+#ifdef SERIAL_DEBUG_IO
+	printk("ser%i rts %i\n", info->line, set);
+#endif
+#endif
+}
+
+
+/* If this behaves as a modem, RI and CD is an output */
+static inline void
+e100_ri_out(struct e100_serial *info, int set)
+{
+#ifndef CONFIG_SVINTO_SIM
+	/* RI is active low */
+	{
+		unsigned char mask = e100_modem_pins[info->line].ri_mask;
+		unsigned long flags;
+
+		save_flags(flags);
+		cli();
+		*e100_modem_pins[info->line].ri_shadow &= ~mask;
+		*e100_modem_pins[info->line].ri_shadow |= (set ? 0 : mask);
+		*e100_modem_pins[info->line].ri_port = *e100_modem_pins[info->line].ri_shadow;
+		restore_flags(flags);
+	}
+#endif
+}
+static inline void
+e100_cd_out(struct e100_serial *info, int set)
+{
+#ifndef CONFIG_SVINTO_SIM
+	/* CD is active low */
+	{
+		unsigned char mask = e100_modem_pins[info->line].cd_mask;
+		unsigned long flags;
+
+		save_flags(flags);
+		cli();
+		*e100_modem_pins[info->line].cd_shadow &= ~mask;
+		*e100_modem_pins[info->line].cd_shadow |= (set ? 0 : mask);
+		*e100_modem_pins[info->line].cd_port = *e100_modem_pins[info->line].cd_shadow;
+		restore_flags(flags);
+	}
+#endif
+}
+
+static inline void
+e100_disable_rx(struct e100_serial *info)
+{
+#ifndef CONFIG_SVINTO_SIM
+	/* disable the receiver */
+	info->port[REG_REC_CTRL] =
+		(info->rx_ctrl &= ~IO_MASK(R_SERIAL0_REC_CTRL, rec_enable));
+#endif
+}
+
+static inline void
+e100_enable_rx(struct e100_serial *info)
+{
+#ifndef CONFIG_SVINTO_SIM
+	/* enable the receiver */
+	info->port[REG_REC_CTRL] =
+		(info->rx_ctrl |= IO_MASK(R_SERIAL0_REC_CTRL, rec_enable));
+#endif
+}
+
+/* the rx DMA uses both the dma_descr and the dma_eop interrupts */
+
+static inline void
+e100_disable_rxdma_irq(struct e100_serial *info)
+{
+#ifdef SERIAL_DEBUG_INTR
+	printk("rxdma_irq(%d): 0\n",info->line);
+#endif
+	DINTR1(DEBUG_LOG(info->line,"IRQ disable_rxdma_irq %i\n", info->line));
+	*R_IRQ_MASK2_CLR = (info->irq << 2) | (info->irq << 3);
+}
+
+static inline void
+e100_enable_rxdma_irq(struct e100_serial *info)
+{
+#ifdef SERIAL_DEBUG_INTR
+	printk("rxdma_irq(%d): 1\n",info->line);
+#endif
+	DINTR1(DEBUG_LOG(info->line,"IRQ enable_rxdma_irq %i\n", info->line));
+	*R_IRQ_MASK2_SET = (info->irq << 2) | (info->irq << 3);
+}
+
+/* the tx DMA uses only dma_descr interrupt */
+
+static _INLINE_ void
+e100_disable_txdma_irq(struct e100_serial *info)
+{
+#ifdef SERIAL_DEBUG_INTR
+	printk("txdma_irq(%d): 0\n",info->line);
+#endif
+	DINTR1(DEBUG_LOG(info->line,"IRQ disable_txdma_irq %i\n", info->line));
+	*R_IRQ_MASK2_CLR = info->irq;
+}
+
+static _INLINE_ void
+e100_enable_txdma_irq(struct e100_serial *info)
+{
+#ifdef SERIAL_DEBUG_INTR
+	printk("txdma_irq(%d): 1\n",info->line);
+#endif
+	DINTR1(DEBUG_LOG(info->line,"IRQ enable_txdma_irq %i\n", info->line));
+	*R_IRQ_MASK2_SET = info->irq;
+}
+
+static _INLINE_ void
+e100_disable_txdma_channel(struct e100_serial *info)
+{
+	unsigned long flags;
+
+	/* Disable output DMA channel for the serial port in question
+	 * ( set to something other then serialX)
+	 */
+	save_flags(flags);
+	cli();
+	DFLOW(DEBUG_LOG(info->line, "disable_txdma_channel %i\n", info->line));
+	if (info->line == 0) {
+		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma6)) ==
+		    IO_STATE(R_GEN_CONFIG, dma6, serial0)) {
+			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma6);
+			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma6, unused);
+		}
+	} else if (info->line == 1) {
+		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma8)) ==
+		    IO_STATE(R_GEN_CONFIG, dma8, serial1)) {
+			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma8);
+			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma8, usb);
+		}
+	} else if (info->line == 2) {
+		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma2)) ==
+		    IO_STATE(R_GEN_CONFIG, dma2, serial2)) {
+			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma2);
+			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma2, par0);
+		}
+	} else if (info->line == 3) {
+		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma4)) ==
+		    IO_STATE(R_GEN_CONFIG, dma4, serial3)) {
+			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma4);
+			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma4, par1);
+		}
+	}
+	*R_GEN_CONFIG = genconfig_shadow;
+	restore_flags(flags);
+}
+
+
+static _INLINE_ void
+e100_enable_txdma_channel(struct e100_serial *info)
+{
+	unsigned long flags;
+
+	save_flags(flags);
+	cli();
+	DFLOW(DEBUG_LOG(info->line, "enable_txdma_channel %i\n", info->line));
+	/* Enable output DMA channel for the serial port in question */
+	if (info->line == 0) {
+		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma6);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma6, serial0);
+	} else if (info->line == 1) {
+		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma8);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma8, serial1);
+	} else if (info->line == 2) {
+		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma2);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma2, serial2);
+	} else if (info->line == 3) {
+		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma4);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma4, serial3);
+	}
+	*R_GEN_CONFIG = genconfig_shadow;
+	restore_flags(flags);
+}
+
+static _INLINE_ void
+e100_disable_rxdma_channel(struct e100_serial *info)
+{
+	unsigned long flags;
+
+	/* Disable input DMA channel for the serial port in question
+	 * ( set to something other then serialX)
+	 */
+	save_flags(flags);
+	cli();
+	if (info->line == 0) {
+		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma7)) ==
+		    IO_STATE(R_GEN_CONFIG, dma7, serial0)) {
+			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma7);
+			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma7, unused);
+		}
+	} else if (info->line == 1) {
+		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma9)) ==
+		    IO_STATE(R_GEN_CONFIG, dma9, serial1)) {
+			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma9);
+			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma9, usb);
+		}
+	} else if (info->line == 2) {
+		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma3)) ==
+		    IO_STATE(R_GEN_CONFIG, dma3, serial2)) {
+			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma3);
+			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma3, par0);
+		}
+	} else if (info->line == 3) {
+		if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma5)) ==
+		    IO_STATE(R_GEN_CONFIG, dma5, serial3)) {
+			genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma5);
+			genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma5, par1);
+		}
+	}
+	*R_GEN_CONFIG = genconfig_shadow;
+	restore_flags(flags);
+}
+
+
+static _INLINE_ void
+e100_enable_rxdma_channel(struct e100_serial *info)
+{
+	unsigned long flags;
+
+	save_flags(flags);
+	cli();
+	/* Enable input DMA channel for the serial port in question */
+	if (info->line == 0) {
+		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma7);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma7, serial0);
+	} else if (info->line == 1) {
+		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma9);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma9, serial1);
+	} else if (info->line == 2) {
+		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma3);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma3, serial2);
+	} else if (info->line == 3) {
+		genconfig_shadow &=  ~IO_MASK(R_GEN_CONFIG, dma5);
+		genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma5, serial3);
+	}
+	*R_GEN_CONFIG = genconfig_shadow;
+	restore_flags(flags);
+}
+
+#ifdef SERIAL_HANDLE_EARLY_ERRORS
+/* in order to detect and fix errors on the first byte
+   we have to use the serial interrupts as well. */
+
+static inline void
+e100_disable_serial_data_irq(struct e100_serial *info)
+{
+#ifdef SERIAL_DEBUG_INTR
+	printk("ser_irq(%d): 0\n",info->line);
+#endif
+	DINTR1(DEBUG_LOG(info->line,"IRQ disable data_irq %i\n", info->line));
+	*R_IRQ_MASK1_CLR = (1U << (8+2*info->line));
+}
+
+static inline void
+e100_enable_serial_data_irq(struct e100_serial *info)
+{
+#ifdef SERIAL_DEBUG_INTR
+	printk("ser_irq(%d): 1\n",info->line);
+	printk("**** %d = %d\n",
+	       (8+2*info->line),
+	       (1U << (8+2*info->line)));
+#endif
+	DINTR1(DEBUG_LOG(info->line,"IRQ enable data_irq %i\n", info->line));
+	*R_IRQ_MASK1_SET = (1U << (8+2*info->line));
+}
+#endif
+
+static inline void
+e100_disable_serial_tx_ready_irq(struct e100_serial *info)
+{
+#ifdef SERIAL_DEBUG_INTR
+	printk("ser_tx_irq(%d): 0\n",info->line);
+#endif
+	DINTR1(DEBUG_LOG(info->line,"IRQ disable ready_irq %i\n", info->line));
+	*R_IRQ_MASK1_CLR = (1U << (8+1+2*info->line));
+}
+
+static inline void
+e100_enable_serial_tx_ready_irq(struct e100_serial *info)
+{
+#ifdef SERIAL_DEBUG_INTR
+	printk("ser_tx_irq(%d): 1\n",info->line);
+	printk("**** %d = %d\n",
+	       (8+1+2*info->line),
+	       (1U << (8+1+2*info->line)));
+#endif
+	DINTR2(DEBUG_LOG(info->line,"IRQ enable ready_irq %i\n", info->line));
+	*R_IRQ_MASK1_SET = (1U << (8+1+2*info->line));
+}
+
+static inline void e100_enable_rx_irq(struct e100_serial *info)
+{
+	if (info->uses_dma_in)
+		e100_enable_rxdma_irq(info);
+	else
+		e100_enable_serial_data_irq(info);
+}
+static inline void e100_disable_rx_irq(struct e100_serial *info)
+{
+	if (info->uses_dma_in)
+		e100_disable_rxdma_irq(info);
+	else
+		e100_disable_serial_data_irq(info);
+}
+
+#if defined(CONFIG_ETRAX_RS485)
+/* Enable RS-485 mode on selected port. This is UGLY. */
+static int
+e100_enable_rs485(struct tty_struct *tty,struct rs485_control *r)
+{
+	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
+
+#if defined(CONFIG_ETRAX_RS485_ON_PA)
+	*R_PORT_PA_DATA = port_pa_data_shadow |= (1 << rs485_pa_bit);
+#endif
+#if defined(CONFIG_ETRAX_RS485_ON_PORT_G)
+	REG_SHADOW_SET(R_PORT_G_DATA,  port_g_data_shadow,
+		       rs485_port_g_bit, 1);
+#endif
+#if defined(CONFIG_ETRAX_RS485_LTC1387)
+	REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
+		       CONFIG_ETRAX_RS485_LTC1387_DXEN_PORT_G_BIT, 1);
+	REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
+		       CONFIG_ETRAX_RS485_LTC1387_RXEN_PORT_G_BIT, 1);
+#endif
+
+	info->rs485.rts_on_send = 0x01 & r->rts_on_send;
+	info->rs485.rts_after_sent = 0x01 & r->rts_after_sent;
+	if (r->delay_rts_before_send >= 1000)
+		info->rs485.delay_rts_before_send = 1000;
+	else
+		info->rs485.delay_rts_before_send = r->delay_rts_before_send;
+	info->rs485.enabled = r->enabled;
+/*	printk("rts: on send = %i, after = %i, enabled = %i",
+		    info->rs485.rts_on_send,
+		    info->rs485.rts_after_sent,
+		    info->rs485.enabled
+	);
+*/
+	return 0;
+}
+
+static int
+e100_write_rs485(struct tty_struct *tty, int from_user,
+                 const unsigned char *buf, int count)
+{
+	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
+	int old_enabled = info->rs485.enabled;
+
+	/* rs485 is always implicitly enabled if we're using the ioctl()
+	 * but it doesn't have to be set in the rs485_control
+	 * (to be backward compatible with old apps)
+	 * So we store, set and restore it.
+	 */
+	info->rs485.enabled = 1;
+	/* rs_write now deals with RS485 if enabled */
+	count = rs_write(tty, from_user, buf, count);
+	info->rs485.enabled = old_enabled;
+	return count;
+}
+
+#ifdef CONFIG_ETRAX_FAST_TIMER
+/* Timer function to toggle RTS when using FAST_TIMER */
+static void rs485_toggle_rts_timer_function(unsigned long data)
+{
+	struct e100_serial *info = (struct e100_serial *)data;
+
+	fast_timers_rs485[info->line].function = NULL;
+	e100_rts(info, info->rs485.rts_after_sent);
+#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
+	e100_enable_rx(info);
+	e100_enable_rx_irq(info);
+#endif
+}
+#endif
+#endif /* CONFIG_ETRAX_RS485 */
+
+/*
+ * ------------------------------------------------------------
+ * rs_stop() and rs_start()
+ *
+ * This routines are called before setting or resetting tty->stopped.
+ * They enable or disable transmitter using the XOFF registers, as necessary.
+ * ------------------------------------------------------------
+ */
+
+static void
+rs_stop(struct tty_struct *tty)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+	if (info) {
+		unsigned long flags;
+		unsigned long xoff;
+
+		save_flags(flags); cli();
+		DFLOW(DEBUG_LOG(info->line, "XOFF rs_stop xmit %i\n",
+				CIRC_CNT(info->xmit.head,
+					 info->xmit.tail,SERIAL_XMIT_SIZE)));
+
+		xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->tty));
+		xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, stop);
+		if (tty->termios->c_iflag & IXON ) {
+			xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
+		}
+
+		*((unsigned long *)&info->port[REG_XOFF]) = xoff;
+		restore_flags(flags);
+	}
+}
+
+static void
+rs_start(struct tty_struct *tty)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+	if (info) {
+		unsigned long flags;
+		unsigned long xoff;
+
+		save_flags(flags); cli();
+		DFLOW(DEBUG_LOG(info->line, "XOFF rs_start xmit %i\n",
+				CIRC_CNT(info->xmit.head,
+					 info->xmit.tail,SERIAL_XMIT_SIZE)));
+		xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(tty));
+		xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
+		if (tty->termios->c_iflag & IXON ) {
+			xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
+		}
+
+		*((unsigned long *)&info->port[REG_XOFF]) = xoff;
+		if (!info->uses_dma_out &&
+		    info->xmit.head != info->xmit.tail && info->xmit.buf)
+			e100_enable_serial_tx_ready_irq(info);
+
+		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 e100_serial *info,
+				    int event)
+{
+	if (info->event & (1 << event))
+		return;
+	info->event |= 1 << event;
+	schedule_work(&info->work);
+}
+
+/* The output DMA channel is free - use it to send as many chars as possible
+ * NOTES:
+ *   We don't pay attention to info->x_char, which means if the TTY wants to
+ *   use XON/XOFF it will set info->x_char but we won't send any X char!
+ *
+ *   To implement this, we'd just start a DMA send of 1 byte pointing at a
+ *   buffer containing the X char, and skip updating xmit. We'd also have to
+ *   check if the last sent char was the X char when we enter this function
+ *   the next time, to avoid updating xmit with the sent X value.
+ */
+
+static void
+transmit_chars_dma(struct e100_serial *info)
+{
+	unsigned int c, sentl;
+	struct etrax_dma_descr *descr;
+
+#ifdef CONFIG_SVINTO_SIM
+	/* This will output too little if tail is not 0 always since
+	 * we don't reloop to send the other part. Anyway this SHOULD be a
+	 * no-op - transmit_chars_dma would never really be called during sim
+	 * since rs_write does not write into the xmit buffer then.
+	 */
+	if (info->xmit.tail)
+		printk("Error in serial.c:transmit_chars-dma(), tail!=0\n");
+	if (info->xmit.head != info->xmit.tail) {
+		SIMCOUT(info->xmit.buf + info->xmit.tail,
+			CIRC_CNT(info->xmit.head,
+				 info->xmit.tail,
+				 SERIAL_XMIT_SIZE));
+		info->xmit.head = info->xmit.tail;  /* move back head */
+		info->tr_running = 0;
+	}
+	return;
+#endif
+	/* acknowledge both dma_descr and dma_eop irq in R_DMA_CHx_CLR_INTR */
+	*info->oclrintradr =
+		IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
+		IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
+
+#ifdef SERIAL_DEBUG_INTR
+	if (info->line == SERIAL_DEBUG_LINE)
+		printk("tc\n");
+#endif
+	if (!info->tr_running) {
+		/* weirdo... we shouldn't get here! */
+		printk(KERN_WARNING "Achtung: transmit_chars_dma with !tr_running\n");
+		return;
+	}
+
+	descr = &info->tr_descr;
+
+	/* first get the amount of bytes sent during the last DMA transfer,
+	   and update xmit accordingly */
+
+	/* if the stop bit was not set, all data has been sent */
+	if (!(descr->status & d_stop)) {
+		sentl = descr->sw_len;
+	} else
+		/* otherwise we find the amount of data sent here */
+		sentl = descr->hw_len;
+
+	DFLOW(DEBUG_LOG(info->line, "TX %i done\n", sentl));
+
+	/* update stats */
+	info->icount.tx += sentl;
+
+	/* update xmit buffer */
+	info->xmit.tail = (info->xmit.tail + sentl) & (SERIAL_XMIT_SIZE - 1);
+
+	/* if there is only a few chars left in the buf, wake up the blocked
+	   write if any */
+	if (CIRC_CNT(info->xmit.head,
+		     info->xmit.tail,
+		     SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
+		rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
+
+	/* find out the largest amount of consecutive bytes we want to send now */
+
+	c = CIRC_CNT_TO_END(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
+
+	/* Don't send all in one DMA transfer - divide it so we wake up
+	 * application before all is sent
+	 */
+
+	if (c >= 4*WAKEUP_CHARS)
+		c = c/2;
+
+	if (c <= 0) {
+		/* our job here is done, don't schedule any new DMA transfer */
+		info->tr_running = 0;
+
+#if defined(CONFIG_ETRAX_RS485) && defined(CONFIG_ETRAX_FAST_TIMER)
+		if (info->rs485.enabled) {
+			/* Set a short timer to toggle RTS */
+			start_one_shot_timer(&fast_timers_rs485[info->line],
+			                     rs485_toggle_rts_timer_function,
+			                     (unsigned long)info,
+			                     info->char_time_usec*2,
+			                     "RS-485");
+		}
+#endif /* RS485 */
+		return;
+	}
+
+	/* ok we can schedule a dma send of c chars starting at info->xmit.tail */
+	/* set up the descriptor correctly for output */
+	DFLOW(DEBUG_LOG(info->line, "TX %i\n", c));
+	descr->ctrl = d_int | d_eol | d_wait; /* Wait needed for tty_wait_until_sent() */
+	descr->sw_len = c;
+	descr->buf = virt_to_phys(info->xmit.buf + info->xmit.tail);
+	descr->status = 0;
+
+	*info->ofirstadr = virt_to_phys(descr); /* write to R_DMAx_FIRST */
+	*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, start);
+
+	/* DMA is now running (hopefully) */
+} /* transmit_chars_dma */
+
+static void
+start_transmit(struct e100_serial *info)
+{
+#if 0
+	if (info->line == SERIAL_DEBUG_LINE)
+		printk("x\n");
+#endif
+
+	info->tr_descr.sw_len = 0;
+	info->tr_descr.hw_len = 0;
+	info->tr_descr.status = 0;
+	info->tr_running = 1;
+	if (info->uses_dma_out)
+		transmit_chars_dma(info);
+	else
+		e100_enable_serial_tx_ready_irq(info);
+} /* start_transmit */
+
+#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
+static int serial_fast_timer_started = 0;
+static int serial_fast_timer_expired = 0;
+static void flush_timeout_function(unsigned long data);
+#define START_FLUSH_FAST_TIMER_TIME(info, string, usec) {\
+  unsigned long timer_flags; \
+  save_flags(timer_flags); \
+  cli(); \
+  if (fast_timers[info->line].function == NULL) { \
+    serial_fast_timer_started++; \
+    TIMERD(DEBUG_LOG(info->line, "start_timer %i ", info->line)); \
+    TIMERD(DEBUG_LOG(info->line, "num started: %i\n", serial_fast_timer_started)); \
+    start_one_shot_timer(&fast_timers[info->line], \
+                         flush_timeout_function, \
+                         (unsigned long)info, \
+                         (usec), \
+                         string); \
+  } \
+  else { \
+    TIMERD(DEBUG_LOG(info->line, "timer %i already running\n", info->line)); \
+  } \
+  restore_flags(timer_flags); \
+}
+#define START_FLUSH_FAST_TIMER(info, string) START_FLUSH_FAST_TIMER_TIME(info, string, info->flush_time_usec)
+
+#else
+#define START_FLUSH_FAST_TIMER_TIME(info, string, usec)
+#define START_FLUSH_FAST_TIMER(info, string)
+#endif
+
+static struct etrax_recv_buffer *
+alloc_recv_buffer(unsigned int size)
+{
+	struct etrax_recv_buffer *buffer;
+
+	if (!(buffer = kmalloc(sizeof *buffer + size, GFP_ATOMIC)))
+		return NULL;
+
+	buffer->next = NULL;
+	buffer->length = 0;
+	buffer->error = TTY_NORMAL;
+
+	return buffer;
+}
+
+static void
+append_recv_buffer(struct e100_serial *info, struct etrax_recv_buffer *buffer)
+{
+	unsigned long flags;
+
+	save_flags(flags);
+	cli();
+
+	if (!info->first_recv_buffer)
+		info->first_recv_buffer = buffer;
+	else
+		info->last_recv_buffer->next = buffer;
+
+	info->last_recv_buffer = buffer;
+
+	info->recv_cnt += buffer->length;
+	if (info->recv_cnt > info->max_recv_cnt)
+		info->max_recv_cnt = info->recv_cnt;
+
+	restore_flags(flags);
+}
+
+static int
+add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char flag)
+{
+	struct etrax_recv_buffer *buffer;
+	if (info->uses_dma_in) {
+		if (!(buffer = alloc_recv_buffer(4)))
+			return 0;
+
+		buffer->length = 1;
+		buffer->error = flag;
+		buffer->buffer[0] = data;
+
+		append_recv_buffer(info, buffer);
+
+		info->icount.rx++;
+	} else {
+		struct tty_struct *tty = info->tty;
+		*tty->flip.char_buf_ptr = data;
+		*tty->flip.flag_buf_ptr = flag;
+		tty->flip.flag_buf_ptr++;
+		tty->flip.char_buf_ptr++;
+		tty->flip.count++;
+		info->icount.rx++;
+	}
+
+	return 1;
+}
+
+extern _INLINE_ unsigned int
+handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsigned int recvl)
+{
+	struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer;
+
+	if (info->recv_cnt + recvl > 65536) {
+		printk(KERN_CRIT
+		       "%s: Too much pending incoming serial data! Dropping %u bytes.\n", __FUNCTION__, recvl);
+		return 0;
+	}
+
+	buffer->length = recvl;
+
+	if (info->errorcode == ERRCODE_SET_BREAK)
+		buffer->error = TTY_BREAK;
+	info->errorcode = 0;
+
+	append_recv_buffer(info, buffer);
+
+	if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE)))
+		panic("%s: Failed to allocate memory for receive buffer!\n", __FUNCTION__);
+
+	descr->buf = virt_to_phys(buffer->buffer);
+
+	return recvl;
+}
+
+static _INLINE_ unsigned int
+handle_all_descr_data(struct e100_serial *info)
+{
+	struct etrax_dma_descr *descr;
+	unsigned int recvl;
+	unsigned int ret = 0;
+
+	while (1)
+	{
+		descr = &info->rec_descr[info->cur_rec_descr];
+
+		if (descr == phys_to_virt(*info->idescradr))
+			break;
+
+		if (++info->cur_rec_descr == SERIAL_RECV_DESCRIPTORS)
+			info->cur_rec_descr = 0;
+
+		/* find out how many bytes were read */
+
+		/* if the eop bit was not set, all data has been received */
+		if (!(descr->status & d_eop)) {
+			recvl = descr->sw_len;
+		} else {
+			/* otherwise we find the amount of data received here */
+			recvl = descr->hw_len;
+		}
+
+		/* Reset the status information */
+		descr->status = 0;
+
+		DFLOW(  DEBUG_LOG(info->line, "RX %lu\n", recvl);
+			if (info->tty->stopped) {
+				unsigned char *buf = phys_to_virt(descr->buf);
+				DEBUG_LOG(info->line, "rx 0x%02X\n", buf[0]);
+				DEBUG_LOG(info->line, "rx 0x%02X\n", buf[1]);
+				DEBUG_LOG(info->line, "rx 0x%02X\n", buf[2]);
+			}
+			);
+
+		/* update stats */
+		info->icount.rx += recvl;
+
+		ret += handle_descr_data(info, descr, recvl);
+	}
+
+	return ret;
+}
+
+static _INLINE_ void
+receive_chars_dma(struct e100_serial *info)
+{
+	struct tty_struct *tty;
+	unsigned char rstat;
+
+#ifdef CONFIG_SVINTO_SIM
+	/* No receive in the simulator.  Will probably be when the rest of
+	 * the serial interface works, and this piece will just be removed.
+	 */
+	return;
+#endif
+
+	/* Acknowledge both dma_descr and dma_eop irq in R_DMA_CHx_CLR_INTR */
+	*info->iclrintradr =
+		IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
+		IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
+
+	tty = info->tty;
+	if (!tty) /* Something wrong... */
+		return;
+
+#ifdef SERIAL_HANDLE_EARLY_ERRORS
+	if (info->uses_dma_in)
+		e100_enable_serial_data_irq(info);
+#endif
+
+	if (info->errorcode == ERRCODE_INSERT_BREAK)
+		add_char_and_flag(info, '\0', TTY_BREAK);
+
+	handle_all_descr_data(info);
+
+	/* Read the status register to detect errors */
+	rstat = info->port[REG_STATUS];
+	if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
+		DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat));
+	}
+
+	if (rstat & SER_ERROR_MASK) {
+		/* If we got an error, we must reset it by reading the
+		 * data_in field
+		 */
+		unsigned char data = info->port[REG_DATA];
+
+		PROCSTAT(ser_stat[info->line].errors_cnt++);
+		DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n",
+			  ((rstat & SER_ERROR_MASK) << 8) | data);
+
+		if (rstat & SER_PAR_ERR_MASK)
+			add_char_and_flag(info, data, TTY_PARITY);
+		else if (rstat & SER_OVERRUN_MASK)
+			add_char_and_flag(info, data, TTY_OVERRUN);
+		else if (rstat & SER_FRAMING_ERR_MASK)
+			add_char_and_flag(info, data, TTY_FRAME);
+	}
+
+	START_FLUSH_FAST_TIMER(info, "receive_chars");
+
+	/* Restart the receiving DMA */
+	*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart);
+}
+
+static _INLINE_ int
+start_recv_dma(struct e100_serial *info)
+{
+	struct etrax_dma_descr *descr = info->rec_descr;
+	struct etrax_recv_buffer *buffer;
+        int i;
+
+	/* Set up the receiving descriptors */
+	for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++) {
+		if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE)))
+			panic("%s: Failed to allocate memory for receive buffer!\n", __FUNCTION__);
+
+		descr[i].ctrl = d_int;
+		descr[i].buf = virt_to_phys(buffer->buffer);
+		descr[i].sw_len = SERIAL_DESCR_BUF_SIZE;
+		descr[i].hw_len = 0;
+		descr[i].status = 0;
+		descr[i].next = virt_to_phys(&descr[i+1]);
+	}
+
+	/* Link the last descriptor to the first */
+	descr[i-1].next = virt_to_phys(&descr[0]);
+
+	/* Start with the first descriptor in the list */
+	info->cur_rec_descr = 0;
+
+	/* Start the DMA */
+	*info->ifirstadr = virt_to_phys(&descr[info->cur_rec_descr]);
+	*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, start);
+
+	/* Input DMA should be running now */
+	return 1;
+}
+
+static void
+start_receive(struct e100_serial *info)
+{
+#ifdef CONFIG_SVINTO_SIM
+	/* No receive in the simulator.  Will probably be when the rest of
+	 * the serial interface works, and this piece will just be removed.
+	 */
+	return;
+#endif
+	info->tty->flip.count = 0;
+	if (info->uses_dma_in) {
+		/* reset the input dma channel to be sure it works */
+
+		*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
+		while (IO_EXTRACT(R_DMA_CH6_CMD, cmd, *info->icmdadr) ==
+		       IO_STATE_VALUE(R_DMA_CH6_CMD, cmd, reset));
+
+		start_recv_dma(info);
+	}
+}
+
+
+static _INLINE_ void
+status_handle(struct e100_serial *info, unsigned short status)
+{
+}
+
+/* the bits in the MASK2 register are laid out like this:
+   DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR
+   where I is the input channel and O is the output channel for the port.
+   info->irq is the bit number for the DMAO_DESCR so to check the others we
+   shift info->irq to the left.
+*/
+
+/* dma output channel interrupt handler
+   this interrupt is called from DMA2(ser2), DMA4(ser3), DMA6(ser0) or
+   DMA8(ser1) when they have finished a descriptor with the intr flag set.
+*/
+
+static irqreturn_t
+tr_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+{
+	struct e100_serial *info;
+	unsigned long ireg;
+	int i;
+	int handled = 0;
+
+#ifdef CONFIG_SVINTO_SIM
+	/* No receive in the simulator.  Will probably be when the rest of
+	 * the serial interface works, and this piece will just be removed.
+	 */
+	{
+		const char *s = "What? tr_interrupt in simulator??\n";
+		SIMCOUT(s,strlen(s));
+	}
+	return IRQ_HANDLED;
+#endif
+
+	/* find out the line that caused this irq and get it from rs_table */
+
+	ireg = *R_IRQ_MASK2_RD;  /* get the active irq bits for the dma channels */
+
+	for (i = 0; i < NR_PORTS; i++) {
+		info = rs_table + i;
+		if (!info->enabled || !info->uses_dma_out)
+			continue;
+		/* check for dma_descr (don't need to check for dma_eop in output dma for serial */
+		if (ireg & info->irq) {
+			handled = 1;
+			/* we can send a new dma bunch. make it so. */
+			DINTR2(DEBUG_LOG(info->line, "tr_interrupt %i\n", i));
+			/* Read jiffies_usec first,
+			 * we want this time to be as late as possible
+			 */
+ 			PROCSTAT(ser_stat[info->line].tx_dma_ints++);
+			info->last_tx_active_usec = GET_JIFFIES_USEC();
+			info->last_tx_active = jiffies;
+			transmit_chars_dma(info);
+		}
+
+		/* FIXME: here we should really check for a change in the
+		   status lines and if so call status_handle(info) */
+	}
+	return IRQ_RETVAL(handled);
+} /* tr_interrupt */
+
+/* dma input channel interrupt handler */
+
+static irqreturn_t
+rec_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+{
+	struct e100_serial *info;
+	unsigned long ireg;
+	int i;
+	int handled = 0;
+
+#ifdef CONFIG_SVINTO_SIM
+	/* No receive in the simulator.  Will probably be when the rest of
+	 * the serial interface works, and this piece will just be removed.
+	 */
+	{
+		const char *s = "What? rec_interrupt in simulator??\n";
+		SIMCOUT(s,strlen(s));
+	}
+	return IRQ_HANDLED;
+#endif
+
+	/* find out the line that caused this irq and get it from rs_table */
+
+	ireg = *R_IRQ_MASK2_RD;  /* get the active irq bits for the dma channels */
+
+	for (i = 0; i < NR_PORTS; i++) {
+		info = rs_table + i;
+		if (!info->enabled || !info->uses_dma_in)
+			continue;
+		/* check for both dma_eop and dma_descr for the input dma channel */
+		if (ireg & ((info->irq << 2) | (info->irq << 3))) {
+			handled = 1;
+			/* we have received something */
+			receive_chars_dma(info);
+		}
+
+		/* FIXME: here we should really check for a change in the
+		   status lines and if so call status_handle(info) */
+	}
+	return IRQ_RETVAL(handled);
+} /* rec_interrupt */
+
+static _INLINE_ int
+force_eop_if_needed(struct e100_serial *info)
+{
+	/* We check data_avail bit to determine if data has
+	 * arrived since last time
+	 */
+	unsigned char rstat = info->port[REG_STATUS];
+
+	/* error or datavail? */
+	if (rstat & SER_ERROR_MASK) {
+		/* Some error has occurred. If there has been valid data, an
+		 * EOP interrupt will be made automatically. If no data, the
+		 * normal ser_interrupt should be enabled and handle it.
+		 * So do nothing!
+		 */
+		DEBUG_LOG(info->line, "timeout err: rstat 0x%03X\n",
+		          rstat | (info->line << 8));
+		return 0;
+	}
+
+	if (rstat & SER_DATA_AVAIL_MASK) {
+		/* Ok data, no error, count it */
+		TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n",
+		          rstat | (info->line << 8)));
+		/* Read data to clear status flags */
+		(void)info->port[REG_DATA];
+
+		info->forced_eop = 0;
+		START_FLUSH_FAST_TIMER(info, "magic");
+		return 0;
+	}
+
+	/* hit the timeout, force an EOP for the input
+	 * dma channel if we haven't already
+	 */
+	if (!info->forced_eop) {
+		info->forced_eop = 1;
+		PROCSTAT(ser_stat[info->line].timeout_flush_cnt++);
+		TIMERD(DEBUG_LOG(info->line, "timeout EOP %i\n", info->line));
+		FORCE_EOP(info);
+	}
+
+	return 1;
+}
+
+extern _INLINE_ void
+flush_to_flip_buffer(struct e100_serial *info)
+{
+	struct tty_struct *tty;
+	struct etrax_recv_buffer *buffer;
+	unsigned int length;
+	unsigned long flags;
+	int max_flip_size;
+
+	if (!info->first_recv_buffer)
+		return;
+
+	save_flags(flags);
+	cli();
+
+	if (!(tty = info->tty)) {
+		restore_flags(flags);
+		return;
+	}
+
+	length = tty->flip.count;
+	/* Don't flip more than the ldisc has room for.
+	 * The return value from ldisc.receive_room(tty) - might not be up to
+	 * date, the previous flip of up to TTY_FLIPBUF_SIZE might be on the
+	 * processed and not accounted for yet.
+	 * Since we use DMA, 1 SERIAL_DESCR_BUF_SIZE could be on the way.
+	 * Lets buffer data here and let flow control take care of it.
+	 * Since we normally flip large chunks, the ldisc don't react
+	 * with throttle until too late if we flip to much.
+	 */
+	max_flip_size = tty->ldisc.receive_room(tty);
+	if (max_flip_size < 0)
+		max_flip_size = 0;
+	if (max_flip_size <= (TTY_FLIPBUF_SIZE +         /* Maybe not accounted for */
+			      length + info->recv_cnt +  /* We have this queued */
+			      2*SERIAL_DESCR_BUF_SIZE +    /* This could be on the way */
+			      TTY_THRESHOLD_THROTTLE)) { /* Some slack */
+		/* check TTY_THROTTLED first so it indicates our state */
+		if (!test_and_set_bit(TTY_THROTTLED, &tty->flags)) {
+			DFLOW(DEBUG_LOG(info->line,"flush_to_flip throttles room %lu\n", max_flip_size));
+			rs_throttle(tty);
+		}
+#if 0
+		else if (max_flip_size <= (TTY_FLIPBUF_SIZE +         /* Maybe not accounted for */
+					   length + info->recv_cnt +  /* We have this queued */
+					   SERIAL_DESCR_BUF_SIZE +    /* This could be on the way */
+					   TTY_THRESHOLD_THROTTLE)) { /* Some slack */
+			DFLOW(DEBUG_LOG(info->line,"flush_to_flip throttles again! %lu\n", max_flip_size));
+			rs_throttle(tty);
+		}
+#endif
+	}
+
+	if (max_flip_size > TTY_FLIPBUF_SIZE)
+		max_flip_size = TTY_FLIPBUF_SIZE;
+
+	while ((buffer = info->first_recv_buffer) && length < max_flip_size) {
+		unsigned int count = buffer->length;
+
+		if (length + count > max_flip_size)
+			count = max_flip_size - length;
+
+		memcpy(tty->flip.char_buf_ptr + length, buffer->buffer, count);
+		memset(tty->flip.flag_buf_ptr + length, TTY_NORMAL, count);
+		tty->flip.flag_buf_ptr[length] = buffer->error;
+
+		length += count;
+		info->recv_cnt -= count;
+		DFLIP(DEBUG_LOG(info->line,"flip: %i\n", length));
+
+		if (count == buffer->length) {
+			info->first_recv_buffer = buffer->next;
+			kfree(buffer);
+		} else {
+			buffer->length -= count;
+			memmove(buffer->buffer, buffer->buffer + count, buffer->length);
+			buffer->error = TTY_NORMAL;
+		}
+	}
+
+	if (!info->first_recv_buffer)
+		info->last_recv_buffer = NULL;
+
+	tty->flip.count = length;
+	DFLIP(if (tty->ldisc.chars_in_buffer(tty) > 3500) {
+		DEBUG_LOG(info->line, "ldisc %lu\n",
+			  tty->ldisc.chars_in_buffer(tty));
+		DEBUG_LOG(info->line, "flip.count %lu\n",
+			  tty->flip.count);
+	      }
+	      );
+	restore_flags(flags);
+
+	DFLIP(
+	  if (1) {
+
+		  if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
+			  DEBUG_LOG(info->line, "*** TTY_DONT_FLIP set flip.count %i ***\n", tty->flip.count);
+			  DEBUG_LOG(info->line, "*** recv_cnt %i\n", info->recv_cnt);
+		  } else {
+		  }
+		  DEBUG_LOG(info->line, "*** rxtot %i\n", info->icount.rx);
+		  DEBUG_LOG(info->line, "ldisc %lu\n", tty->ldisc.chars_in_buffer(tty));
+		  DEBUG_LOG(info->line, "room  %lu\n", tty->ldisc.receive_room(tty));
+	  }
+
+	);
+
+	/* this includes a check for low-latency */
+	tty_flip_buffer_push(tty);
+}
+
+static _INLINE_ void
+check_flush_timeout(struct e100_serial *info)
+{
+	/* Flip what we've got (if we can) */
+	flush_to_flip_buffer(info);
+
+	/* We might need to flip later, but not to fast
+	 * since the system is busy processing input... */
+	if (info->first_recv_buffer)
+		START_FLUSH_FAST_TIMER_TIME(info, "flip", 2000);
+
+	/* Force eop last, since data might have come while we're processing
+	 * and if we started the slow timer above, we won't start a fast
+	 * below.
+	 */
+	force_eop_if_needed(info);
+}
+
+#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
+static void flush_timeout_function(unsigned long data)
+{
+	struct e100_serial *info = (struct e100_serial *)data;
+
+	fast_timers[info->line].function = NULL;
+	serial_fast_timer_expired++;
+	TIMERD(DEBUG_LOG(info->line, "flush_timout %i ", info->line));
+	TIMERD(DEBUG_LOG(info->line, "num expired: %i\n", serial_fast_timer_expired));
+	check_flush_timeout(info);
+}
+
+#else
+
+/* dma fifo/buffer timeout handler
+   forces an end-of-packet for the dma input channel if no chars
+   have been received for CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS/100 s.
+*/
+
+static struct timer_list flush_timer;
+
+static void
+timed_flush_handler(unsigned long ptr)
+{
+	struct e100_serial *info;
+	int i;
+
+#ifdef CONFIG_SVINTO_SIM
+	return;
+#endif
+
+	for (i = 0; i < NR_PORTS; i++) {
+		info = rs_table + i;
+		if (info->uses_dma_in)
+			check_flush_timeout(info);
+	}
+
+	/* restart flush timer */
+	mod_timer(&flush_timer, jiffies + CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS);
+}
+#endif
+
+#ifdef SERIAL_HANDLE_EARLY_ERRORS
+
+/* If there is an error (ie break) when the DMA is running and
+ * there are no bytes in the fifo the DMA is stopped and we get no
+ * eop interrupt. Thus we have to monitor the first bytes on a DMA
+ * transfer, and if it is without error we can turn the serial
+ * interrupts off.
+ */
+
+/*
+BREAK handling on ETRAX 100:
+ETRAX will generate interrupt although there is no stop bit between the
+characters.
+
+Depending on how long the break sequence is, the end of the breaksequence
+will look differently:
+| indicates start/end of a character.
+
+B= Break character (0x00) with framing error.
+E= Error byte with parity error received after B characters.
+F= "Faked" valid byte received immediately after B characters.
+V= Valid byte
+
+1.
+    B          BL         ___________________________ V
+.._|__________|__________|                           |valid data |
+
+Multiple frame errors with data == 0x00 (B),
+the timing matches up "perfectly" so no extra ending char is detected.
+The RXD pin is 1 in the last interrupt, in that case
+we set info->errorcode = ERRCODE_INSERT_BREAK, but we can't really
+know if another byte will come and this really is case 2. below
+(e.g F=0xFF or 0xFE)
+If RXD pin is 0 we can expect another character (see 2. below).
+
+
+2.
+
+    B          B          E or F__________________..__ V
+.._|__________|__________|______    |                 |valid data
+                          "valid" or
+                          parity error
+
+Multiple frame errors with data == 0x00 (B),
+but the part of the break trigs is interpreted as a start bit (and possibly
+some 0 bits followed by a number of 1 bits and a stop bit).
+Depending on parity settings etc. this last character can be either
+a fake "valid" char (F) or have a parity error (E).
+
+If the character is valid it will be put in the buffer,
+we set info->errorcode = ERRCODE_SET_BREAK so the receive interrupt
+will set the flags so the tty will handle it,
+if it's an error byte it will not be put in the buffer
+and we set info->errorcode = ERRCODE_INSERT_BREAK.
+
+To distinguish a V byte in 1. from an F byte in 2. we keep a timestamp
+of the last faulty char (B) and compares it with the current time:
+If the time elapsed time is less then 2*char_time_usec we will assume
+it's a faked F char and not a Valid char and set
+info->errorcode = ERRCODE_SET_BREAK.
+
+Flaws in the above solution:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+We use the timer to distinguish a F character from a V character,
+if a V character is to close after the break we might make the wrong decision.
+
+TODO: The break will be delayed until an F or V character is received.
+
+*/
+
+extern _INLINE_
+struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
+{
+	unsigned long data_read;
+	struct tty_struct *tty = info->tty;
+
+	if (!tty) {
+		printk("!NO TTY!\n");
+		return info;
+	}
+	if (tty->flip.count >= TTY_FLIPBUF_SIZE - TTY_THRESHOLD_THROTTLE) {
+		/* check TTY_THROTTLED first so it indicates our state */
+		if (!test_and_set_bit(TTY_THROTTLED, &tty->flags)) {
+			DFLOW(DEBUG_LOG(info->line, "rs_throttle flip.count: %i\n", tty->flip.count));
+			rs_throttle(tty);
+		}
+	}
+	if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+		DEBUG_LOG(info->line, "force FLIP! %i\n", tty->flip.count);
+		tty->flip.work.func((void *) tty);
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+			DEBUG_LOG(info->line, "FLIP FULL! %i\n", tty->flip.count);
+			return info;		/* if TTY_DONT_FLIP is set */
+		}
+	}
+	/* Read data and status at the same time */
+	data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]);
+more_data:
+	if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) {
+		DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
+	}
+	DINTR2(DEBUG_LOG(info->line, "ser_rx   %c\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read)));
+
+	if (data_read & ( IO_MASK(R_SERIAL0_READ, framing_err) |
+			  IO_MASK(R_SERIAL0_READ, par_err) |
+			  IO_MASK(R_SERIAL0_READ, overrun) )) {
+		/* An error */
+		info->last_rx_active_usec = GET_JIFFIES_USEC();
+		info->last_rx_active = jiffies;
+		DINTR1(DEBUG_LOG(info->line, "ser_rx err stat_data %04X\n", data_read));
+		DLOG_INT_TRIG(
+		if (!log_int_trig1_pos) {
+			log_int_trig1_pos = log_int_pos;
+			log_int(rdpc(), 0, 0);
+		}
+		);
+
+
+		if ( ((data_read & IO_MASK(R_SERIAL0_READ, data_in)) == 0) &&
+		     (data_read & IO_MASK(R_SERIAL0_READ, framing_err)) ) {
+			/* Most likely a break, but we get interrupts over and
+			 * over again.
+			 */
+
+			if (!info->break_detected_cnt) {
+				DEBUG_LOG(info->line, "#BRK start\n", 0);
+			}
+			if (data_read & IO_MASK(R_SERIAL0_READ, rxd)) {
+				/* The RX pin is high now, so the break
+				 * must be over, but....
+				 * we can't really know if we will get another
+				 * last byte ending the break or not.
+				 * And we don't know if the byte (if any) will
+				 * have an error or look valid.
+				 */
+				DEBUG_LOG(info->line, "# BL BRK\n", 0);
+				info->errorcode = ERRCODE_INSERT_BREAK;
+			}
+			info->break_detected_cnt++;
+		} else {
+			/* The error does not look like a break, but could be
+			 * the end of one
+			 */
+			if (info->break_detected_cnt) {
+				DEBUG_LOG(info->line, "EBRK %i\n", info->break_detected_cnt);
+				info->errorcode = ERRCODE_INSERT_BREAK;
+			} else {
+				if (info->errorcode == ERRCODE_INSERT_BREAK) {
+					info->icount.brk++;
+					*tty->flip.char_buf_ptr = 0;
+					*tty->flip.flag_buf_ptr = TTY_BREAK;
+					tty->flip.flag_buf_ptr++;
+					tty->flip.char_buf_ptr++;
+					tty->flip.count++;
+					info->icount.rx++;
+				}
+				*tty->flip.char_buf_ptr = IO_EXTRACT(R_SERIAL0_READ, data_in, data_read);
+
+				if (data_read & IO_MASK(R_SERIAL0_READ, par_err)) {
+					info->icount.parity++;
+					*tty->flip.flag_buf_ptr = TTY_PARITY;
+				} else if (data_read & IO_MASK(R_SERIAL0_READ, overrun)) {
+					info->icount.overrun++;
+					*tty->flip.flag_buf_ptr = TTY_OVERRUN;
+				} else if (data_read & IO_MASK(R_SERIAL0_READ, framing_err)) {
+					info->icount.frame++;
+					*tty->flip.flag_buf_ptr = TTY_FRAME;
+				}
+				info->errorcode = 0;
+			}
+			info->break_detected_cnt = 0;
+		}
+	} else if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) {
+		/* No error */
+		DLOG_INT_TRIG(
+		if (!log_int_trig1_pos) {
+			if (log_int_pos >= log_int_size) {
+				log_int_pos = 0;
+			}
+			log_int_trig0_pos = log_int_pos;
+			log_int(rdpc(), 0, 0);
+		}
+		);
+		*tty->flip.char_buf_ptr = IO_EXTRACT(R_SERIAL0_READ, data_in, data_read);
+		*tty->flip.flag_buf_ptr = 0;
+	} else {
+		DEBUG_LOG(info->line, "ser_rx int but no data_avail  %08lX\n", data_read);
+	}
+
+
+	tty->flip.flag_buf_ptr++;
+	tty->flip.char_buf_ptr++;
+	tty->flip.count++;
+	info->icount.rx++;
+	data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]);
+	if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) {
+		DEBUG_LOG(info->line, "ser_rx   %c in loop\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read));
+		goto more_data;
+	}
+
+	tty_flip_buffer_push(info->tty);
+	return info;
+}
+
+extern _INLINE_
+struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
+{
+	unsigned char rstat;
+
+#ifdef SERIAL_DEBUG_INTR
+	printk("Interrupt from serport %d\n", i);
+#endif
+/*	DEBUG_LOG(info->line, "ser_interrupt stat %03X\n", rstat | (i << 8)); */
+	if (!info->uses_dma_in) {
+		return handle_ser_rx_interrupt_no_dma(info);
+	}
+	/* DMA is used */
+	rstat = info->port[REG_STATUS];
+	if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
+		DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
+	}
+
+	if (rstat & SER_ERROR_MASK) {
+		unsigned char data;
+
+		info->last_rx_active_usec = GET_JIFFIES_USEC();
+		info->last_rx_active = jiffies;
+		/* If we got an error, we must reset it by reading the
+		 * data_in field
+		 */
+		data = info->port[REG_DATA];
+		DINTR1(DEBUG_LOG(info->line, "ser_rx!  %c\n", data));
+		DINTR1(DEBUG_LOG(info->line, "ser_rx err stat %02X\n", rstat));
+		if (!data && (rstat & SER_FRAMING_ERR_MASK)) {
+			/* Most likely a break, but we get interrupts over and
+			 * over again.
+			 */
+
+			if (!info->break_detected_cnt) {
+				DEBUG_LOG(info->line, "#BRK start\n", 0);
+			}
+			if (rstat & SER_RXD_MASK) {
+				/* The RX pin is high now, so the break
+				 * must be over, but....
+				 * we can't really know if we will get another
+				 * last byte ending the break or not.
+				 * And we don't know if the byte (if any) will
+				 * have an error or look valid.
+				 */
+				DEBUG_LOG(info->line, "# BL BRK\n", 0);
+				info->errorcode = ERRCODE_INSERT_BREAK;
+			}
+			info->break_detected_cnt++;
+		} else {
+			/* The error does not look like a break, but could be
+			 * the end of one
+			 */
+			if (info->break_detected_cnt) {
+				DEBUG_LOG(info->line, "EBRK %i\n", info->break_detected_cnt);
+				info->errorcode = ERRCODE_INSERT_BREAK;
+			} else {
+				if (info->errorcode == ERRCODE_INSERT_BREAK) {
+					info->icount.brk++;
+					add_char_and_flag(info, '\0', TTY_BREAK);
+				}
+
+				if (rstat & SER_PAR_ERR_MASK) {
+					info->icount.parity++;
+					add_char_and_flag(info, data, TTY_PARITY);
+				} else if (rstat & SER_OVERRUN_MASK) {
+					info->icount.overrun++;
+					add_char_and_flag(info, data, TTY_OVERRUN);
+				} else if (rstat & SER_FRAMING_ERR_MASK) {
+					info->icount.frame++;
+					add_char_and_flag(info, data, TTY_FRAME);
+				}
+
+				info->errorcode = 0;
+			}
+			info->break_detected_cnt = 0;
+			DEBUG_LOG(info->line, "#iERR s d %04X\n",
+			          ((rstat & SER_ERROR_MASK) << 8) | data);
+		}
+		PROCSTAT(ser_stat[info->line].early_errors_cnt++);
+	} else { /* It was a valid byte, now let the DMA do the rest */
+		unsigned long curr_time_u = GET_JIFFIES_USEC();
+		unsigned long curr_time = jiffies;
+
+		if (info->break_detected_cnt) {
+			/* Detect if this character is a new valid char or the
+			 * last char in a break sequence: If LSBits are 0 and
+			 * MSBits are high AND the time is close to the
+			 * previous interrupt we should discard it.
+			 */
+			long elapsed_usec =
+			  (curr_time - info->last_rx_active) * (1000000/HZ) +
+			  curr_time_u - info->last_rx_active_usec;
+			if (elapsed_usec < 2*info->char_time_usec) {
+				DEBUG_LOG(info->line, "FBRK %i\n", info->line);
+				/* Report as BREAK (error) and let
+				 * receive_chars_dma() handle it
+				 */
+				info->errorcode = ERRCODE_SET_BREAK;
+			} else {
+				DEBUG_LOG(info->line, "Not end of BRK (V)%i\n", info->line);
+			}
+			DEBUG_LOG(info->line, "num brk %i\n", info->break_detected_cnt);
+		}
+
+#ifdef SERIAL_DEBUG_INTR
+		printk("** OK, disabling ser_interrupts\n");
+#endif
+		e100_disable_serial_data_irq(info);
+		DINTR2(DEBUG_LOG(info->line, "ser_rx OK %d\n", info->line));
+		info->break_detected_cnt = 0;
+
+		PROCSTAT(ser_stat[info->line].ser_ints_ok_cnt++);
+	}
+	/* Restarting the DMA never hurts */
+	*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart);
+	START_FLUSH_FAST_TIMER(info, "ser_int");
+	return info;
+} /* handle_ser_rx_interrupt */
+
+extern _INLINE_ void handle_ser_tx_interrupt(struct e100_serial *info)
+{
+	unsigned long flags;
+
+	if (info->x_char) {
+		unsigned char rstat;
+		DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char));
+		save_flags(flags); cli();
+		rstat = info->port[REG_STATUS];
+		DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
+
+		info->port[REG_TR_DATA] = info->x_char;
+		info->icount.tx++;
+		info->x_char = 0;
+		/* We must enable since it is disabled in ser_interrupt */
+		e100_enable_serial_tx_ready_irq(info);
+		restore_flags(flags);
+		return;
+	}
+	if (info->uses_dma_out) {
+		unsigned char rstat;
+		int i;
+		/* We only use normal tx interrupt when sending x_char */
+		DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0));
+		save_flags(flags); cli();
+		rstat = info->port[REG_STATUS];
+		DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
+		e100_disable_serial_tx_ready_irq(info);
+		if (info->tty->stopped)
+			rs_stop(info->tty);
+		/* Enable the DMA channel and tell it to continue */
+		e100_enable_txdma_channel(info);
+		/* Wait 12 cycles before doing the DMA command */
+		for(i = 6;  i > 0; i--)
+			nop();
+
+		*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, continue);
+		restore_flags(flags);
+		return;
+	}
+	/* Normal char-by-char interrupt */
+	if (info->xmit.head == info->xmit.tail
+	    || info->tty->stopped
+	    || info->tty->hw_stopped) {
+		DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n", info->tty->stopped));
+		e100_disable_serial_tx_ready_irq(info);
+		info->tr_running = 0;
+		return;
+	}
+	DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail]));
+	/* Send a byte, rs485 timing is critical so turn of ints */
+	save_flags(flags); cli();
+	info->port[REG_TR_DATA] = info->xmit.buf[info->xmit.tail];
+	info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1);
+	info->icount.tx++;
+	if (info->xmit.head == info->xmit.tail) {
+#if defined(CONFIG_ETRAX_RS485) && defined(CONFIG_ETRAX_FAST_TIMER)
+		if (info->rs485.enabled) {
+			/* Set a short timer to toggle RTS */
+			start_one_shot_timer(&fast_timers_rs485[info->line],
+			                     rs485_toggle_rts_timer_function,
+			                     (unsigned long)info,
+			                     info->char_time_usec*2,
+			                     "RS-485");
+		}
+#endif /* RS485 */
+		info->last_tx_active_usec = GET_JIFFIES_USEC();
+		info->last_tx_active = jiffies;
+		e100_disable_serial_tx_ready_irq(info);
+		info->tr_running = 0;
+		DFLOW(DEBUG_LOG(info->line, "tx_int: stop2\n", 0));
+	} else {
+		/* We must enable since it is disabled in ser_interrupt */
+		e100_enable_serial_tx_ready_irq(info);
+	}
+	restore_flags(flags);
+
+	if (CIRC_CNT(info->xmit.head,
+		     info->xmit.tail,
+		     SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
+		rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
+
+} /* handle_ser_tx_interrupt */
+
+/* result of time measurements:
+ * RX duration 54-60 us when doing something, otherwise 6-9 us
+ * ser_int duration: just sending: 8-15 us normally, up to 73 us
+ */
+static irqreturn_t
+ser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	static volatile int tx_started = 0;
+	struct e100_serial *info;
+	int i;
+	unsigned long flags;
+	unsigned long irq_mask1_rd;
+	unsigned long data_mask = (1 << (8+2*0)); /* ser0 data_avail */
+	int handled = 0;
+	static volatile unsigned long reentered_ready_mask = 0;
+
+	save_flags(flags); cli();
+	irq_mask1_rd = *R_IRQ_MASK1_RD;
+	/* First handle all rx interrupts with ints disabled */
+	info = rs_table;
+	irq_mask1_rd &= e100_ser_int_mask;
+	for (i = 0; i < NR_PORTS; i++) {
+		/* Which line caused the data irq? */
+		if (irq_mask1_rd & data_mask) {
+			handled = 1;
+			handle_ser_rx_interrupt(info);
+		}
+		info += 1;
+		data_mask <<= 2;
+	}
+	/* Handle tx interrupts with interrupts enabled so we
+	 * can take care of new data interrupts while transmitting
+	 * We protect the tx part with the tx_started flag.
+	 * We disable the tr_ready interrupts we are about to handle and
+	 * unblock the serial interrupt so new serial interrupts may come.
+	 *
+	 * If we get a new interrupt:
+	 *  - it migth be due to synchronous serial ports.
+	 *  - serial irq will be blocked by general irq handler.
+	 *  - async data will be handled above (sync will be ignored).
+	 *  - tx_started flag will prevent us from trying to send again and
+	 *    we will exit fast - no need to unblock serial irq.
+	 *  - Next (sync) serial interrupt handler will be runned with
+	 *    disabled interrupt due to restore_flags() at end of function,
+	 *    so sync handler will not be preempted or reentered.
+	 */
+	if (!tx_started) {
+		unsigned long ready_mask;
+		unsigned long
+		tx_started = 1;
+		/* Only the tr_ready interrupts left */
+		irq_mask1_rd &= (IO_MASK(R_IRQ_MASK1_RD, ser0_ready) |
+				 IO_MASK(R_IRQ_MASK1_RD, ser1_ready) |
+				 IO_MASK(R_IRQ_MASK1_RD, ser2_ready) |
+				 IO_MASK(R_IRQ_MASK1_RD, ser3_ready));
+		while (irq_mask1_rd) {
+			/* Disable those we are about to handle */
+			*R_IRQ_MASK1_CLR = irq_mask1_rd;
+			/* Unblock the serial interrupt */
+			*R_VECT_MASK_SET = IO_STATE(R_VECT_MASK_SET, serial, set);
+
+			sti();
+			ready_mask = (1 << (8+1+2*0)); /* ser0 tr_ready */
+			info = rs_table;
+			for (i = 0; i < NR_PORTS; i++) {
+				/* Which line caused the ready irq? */
+				if (irq_mask1_rd & ready_mask) {
+					handled = 1;
+					handle_ser_tx_interrupt(info);
+				}
+				info += 1;
+				ready_mask <<= 2;
+			}
+			/* handle_ser_tx_interrupt enables tr_ready interrupts */
+			cli();
+			/* Handle reentered TX interrupt */
+			irq_mask1_rd = reentered_ready_mask;
+		}
+		cli();
+		tx_started = 0;
+	} else {
+		unsigned long ready_mask;
+		ready_mask = irq_mask1_rd & (IO_MASK(R_IRQ_MASK1_RD, ser0_ready) |
+					     IO_MASK(R_IRQ_MASK1_RD, ser1_ready) |
+					     IO_MASK(R_IRQ_MASK1_RD, ser2_ready) |
+					     IO_MASK(R_IRQ_MASK1_RD, ser3_ready));
+		if (ready_mask) {
+			reentered_ready_mask |= ready_mask;
+			/* Disable those we are about to handle */
+			*R_IRQ_MASK1_CLR = ready_mask;
+			DFLOW(DEBUG_LOG(SERIAL_DEBUG_LINE, "ser_int reentered with TX %X\n", ready_mask));
+		}
+	}
+
+	restore_flags(flags);
+	return IRQ_RETVAL(handled);
+} /* ser_interrupt */
+#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_softint(void *private_)
+{
+	struct e100_serial	*info = (struct e100_serial *) 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);
+	}
+}
+
+static int
+startup(struct e100_serial * info)
+{
+	unsigned long flags;
+	unsigned long xmit_page;
+	int i;
+
+	xmit_page = get_zeroed_page(GFP_KERNEL);
+	if (!xmit_page)
+		return -ENOMEM;
+
+	save_flags(flags);
+	cli();
+
+	/* if it was already initialized, skip this */
+
+	if (info->flags & ASYNC_INITIALIZED) {
+		restore_flags(flags);
+		free_page(xmit_page);
+		return 0;
+	}
+
+	if (info->xmit.buf)
+		free_page(xmit_page);
+	else
+		info->xmit.buf = (unsigned char *) xmit_page;
+
+#ifdef SERIAL_DEBUG_OPEN
+	printk("starting up ttyS%d (xmit_buf 0x%p)...\n", info->line, info->xmit.buf);
+#endif
+
+#ifdef CONFIG_SVINTO_SIM
+	/* Bits and pieces collected from below.  Better to have them
+	   in one ifdef:ed clause than to mix in a lot of ifdefs,
+	   right? */
+	if (info->tty)
+		clear_bit(TTY_IO_ERROR, &info->tty->flags);
+
+	info->xmit.head = info->xmit.tail = 0;
+	info->first_recv_buffer = info->last_recv_buffer = NULL;
+	info->recv_cnt = info->max_recv_cnt = 0;
+
+	for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++)
+		info->rec_descr[i].buf = NULL;
+
+	/* No real action in the simulator, but may set info important
+	   to ioctl. */
+	change_speed(info);
+#else
+
+	/*
+	 * Clear the FIFO buffers and disable them
+	 * (they will be reenabled in change_speed())
+	 */
+
+	/*
+	 * Reset the DMA channels and make sure their interrupts are cleared
+	 */
+
+	if (info->dma_in_enabled) {
+		info->uses_dma_in = 1;
+		e100_enable_rxdma_channel(info);
+
+		*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
+
+		/* Wait until reset cycle is complete */
+		while (IO_EXTRACT(R_DMA_CH6_CMD, cmd, *info->icmdadr) ==
+		       IO_STATE_VALUE(R_DMA_CH6_CMD, cmd, reset));
+
+		/* Make sure the irqs are cleared */
+		*info->iclrintradr =
+			IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
+			IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
+	} else {
+		e100_disable_rxdma_channel(info);
+	}
+
+	if (info->dma_out_enabled) {
+		info->uses_dma_out = 1;
+		e100_enable_txdma_channel(info);
+		*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
+
+		while (IO_EXTRACT(R_DMA_CH6_CMD, cmd, *info->ocmdadr) ==
+		       IO_STATE_VALUE(R_DMA_CH6_CMD, cmd, reset));
+
+		/* Make sure the irqs are cleared */
+		*info->oclrintradr =
+			IO_STATE(R_DMA_CH6_CLR_INTR, clr_descr, do) |
+			IO_STATE(R_DMA_CH6_CLR_INTR, clr_eop, do);
+	} else {
+		e100_disable_txdma_channel(info);
+	}
+
+	if (info->tty)
+		clear_bit(TTY_IO_ERROR, &info->tty->flags);
+
+	info->xmit.head = info->xmit.tail = 0;
+	info->first_recv_buffer = info->last_recv_buffer = NULL;
+	info->recv_cnt = info->max_recv_cnt = 0;
+
+	for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++)
+		info->rec_descr[i].buf = 0;
+
+	/*
+	 * and set the speed and other flags of the serial port
+	 * this will start the rx/tx as well
+	 */
+#ifdef SERIAL_HANDLE_EARLY_ERRORS
+	e100_enable_serial_data_irq(info);
+#endif
+	change_speed(info);
+
+	/* dummy read to reset any serial errors */
+
+	(void)info->port[REG_DATA];
+
+	/* enable the interrupts */
+	if (info->uses_dma_out)
+		e100_enable_txdma_irq(info);
+
+	e100_enable_rx_irq(info);
+
+	info->tr_running = 0; /* to be sure we don't lock up the transmitter */
+
+	/* setup the dma input descriptor and start dma */
+
+	start_receive(info);
+
+	/* for safety, make sure the descriptors last result is 0 bytes written */
+
+	info->tr_descr.sw_len = 0;
+	info->tr_descr.hw_len = 0;
+	info->tr_descr.status = 0;
+
+	/* enable RTS/DTR last */
+
+	e100_rts(info, 1);
+	e100_dtr(info, 1);
+
+#endif /* CONFIG_SVINTO_SIM */
+
+	info->flags |= ASYNC_INITIALIZED;
+
+	restore_flags(flags);
+	return 0;
+}
+
+/*
+ * 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 e100_serial * info)
+{
+	unsigned long flags;
+	struct etrax_dma_descr *descr = info->rec_descr;
+	struct etrax_recv_buffer *buffer;
+	int i;
+
+#ifndef CONFIG_SVINTO_SIM
+	/* shut down the transmitter and receiver */
+	DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line));
+	e100_disable_rx(info);
+	info->port[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40);
+
+	/* disable interrupts, reset dma channels */
+	if (info->uses_dma_in) {
+		e100_disable_rxdma_irq(info);
+		*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
+		info->uses_dma_in = 0;
+	} else {
+		e100_disable_serial_data_irq(info);
+	}
+
+	if (info->uses_dma_out) {
+		e100_disable_txdma_irq(info);
+		info->tr_running = 0;
+		*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, reset);
+		info->uses_dma_out = 0;
+	} else {
+		e100_disable_serial_tx_ready_irq(info);
+		info->tr_running = 0;
+	}
+
+#endif /* CONFIG_SVINTO_SIM */
+
+	if (!(info->flags & ASYNC_INITIALIZED))
+		return;
+
+#ifdef SERIAL_DEBUG_OPEN
+	printk("Shutting down serial port %d (irq %d)....\n", info->line,
+	       info->irq);
+#endif
+
+	save_flags(flags);
+	cli(); /* Disable interrupts */
+
+	if (info->xmit.buf) {
+		free_page((unsigned long)info->xmit.buf);
+		info->xmit.buf = NULL;
+	}
+
+	for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++)
+		if (descr[i].buf) {
+			buffer = phys_to_virt(descr[i].buf) - sizeof *buffer;
+			kfree(buffer);
+			descr[i].buf = 0;
+		}
+
+	if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
+		/* hang up DTR and RTS if HUPCL is enabled */
+		e100_dtr(info, 0);
+		e100_rts(info, 0); /* could check CRTSCTS before doing this */
+	}
+
+	if (info->tty)
+		set_bit(TTY_IO_ERROR, &info->tty->flags);
+
+	info->flags &= ~ASYNC_INITIALIZED;
+	restore_flags(flags);
+}
+
+
+/* change baud rate and other assorted parameters */
+
+static void
+change_speed(struct e100_serial *info)
+{
+	unsigned int cflag;
+	unsigned long xoff;
+	unsigned long flags;
+	/* first some safety checks */
+
+	if (!info->tty || !info->tty->termios)
+		return;
+	if (!info->port)
+		return;
+
+	cflag = info->tty->termios->c_cflag;
+
+	/* possibly, the tx/rx should be disabled first to do this safely */
+
+	/* change baud-rate and write it to the hardware */
+	if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) {
+		/* Special baudrate */
+		u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */
+		unsigned long alt_source =
+				IO_STATE(R_ALT_SER_BAUDRATE, ser0_rec, normal) |
+				IO_STATE(R_ALT_SER_BAUDRATE, ser0_tr, normal);
+		/* R_ALT_SER_BAUDRATE selects the source */
+		DBAUD(printk("Custom baudrate: baud_base/divisor %lu/%i\n",
+		       (unsigned long)info->baud_base, info->custom_divisor));
+		if (info->baud_base == SERIAL_PRESCALE_BASE) {
+			/* 0, 2-65535 (0=65536) */
+			u16 divisor = info->custom_divisor;
+			/* R_SERIAL_PRESCALE (upper 16 bits of R_CLOCK_PRESCALE) */
+			/* baudrate is 3.125MHz/custom_divisor */
+			alt_source =
+				IO_STATE(R_ALT_SER_BAUDRATE, ser0_rec, prescale) |
+				IO_STATE(R_ALT_SER_BAUDRATE, ser0_tr, prescale);
+			alt_source = 0x11;
+			DBAUD(printk("Writing SERIAL_PRESCALE: divisor %i\n", divisor));
+			*R_SERIAL_PRESCALE = divisor;
+			info->baud = SERIAL_PRESCALE_BASE/divisor;
+		}
+#ifdef CONFIG_ETRAX_EXTERN_PB6CLK_ENABLED
+		else if ((info->baud_base==CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8 &&
+			  info->custom_divisor == 1) ||
+			 (info->baud_base==CONFIG_ETRAX_EXTERN_PB6CLK_FREQ &&
+			  info->custom_divisor == 8)) {
+				/* ext_clk selected */
+				alt_source =
+					IO_STATE(R_ALT_SER_BAUDRATE, ser0_rec, extern) |
+					IO_STATE(R_ALT_SER_BAUDRATE, ser0_tr, extern);
+				DBAUD(printk("using external baudrate: %lu\n", CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8));
+				info->baud = CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8;
+			}
+		}
+#endif
+		else
+		{
+			/* Bad baudbase, we don't support using timer0
+			 * for baudrate.
+			 */
+			printk(KERN_WARNING "Bad baud_base/custom_divisor: %lu/%i\n",
+			       (unsigned long)info->baud_base, info->custom_divisor);
+		}
+		r_alt_ser_baudrate_shadow &= ~mask;
+		r_alt_ser_baudrate_shadow |= (alt_source << (info->line*8));
+		*R_ALT_SER_BAUDRATE = r_alt_ser_baudrate_shadow;
+	} else {
+		/* Normal baudrate */
+		/* Make sure we use normal baudrate */
+		u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */
+		unsigned long alt_source =
+			IO_STATE(R_ALT_SER_BAUDRATE, ser0_rec, normal) |
+			IO_STATE(R_ALT_SER_BAUDRATE, ser0_tr, normal);
+		r_alt_ser_baudrate_shadow &= ~mask;
+		r_alt_ser_baudrate_shadow |= (alt_source << (info->line*8));
+#ifndef CONFIG_SVINTO_SIM
+		*R_ALT_SER_BAUDRATE = r_alt_ser_baudrate_shadow;
+#endif /* CONFIG_SVINTO_SIM */
+
+		info->baud = cflag_to_baud(cflag);
+#ifndef CONFIG_SVINTO_SIM
+		info->port[REG_BAUD] = cflag_to_etrax_baud(cflag);
+#endif /* CONFIG_SVINTO_SIM */
+	}
+
+#ifndef CONFIG_SVINTO_SIM
+	/* start with default settings and then fill in changes */
+	save_flags(flags);
+	cli();
+	/* 8 bit, no/even parity */
+	info->rx_ctrl &= ~(IO_MASK(R_SERIAL0_REC_CTRL, rec_bitnr) |
+			   IO_MASK(R_SERIAL0_REC_CTRL, rec_par_en) |
+			   IO_MASK(R_SERIAL0_REC_CTRL, rec_par));
+
+	/* 8 bit, no/even parity, 1 stop bit, no cts */
+	info->tx_ctrl &= ~(IO_MASK(R_SERIAL0_TR_CTRL, tr_bitnr) |
+			   IO_MASK(R_SERIAL0_TR_CTRL, tr_par_en) |
+			   IO_MASK(R_SERIAL0_TR_CTRL, tr_par) |
+			   IO_MASK(R_SERIAL0_TR_CTRL, stop_bits) |
+			   IO_MASK(R_SERIAL0_TR_CTRL, auto_cts));
+
+	if ((cflag & CSIZE) == CS7) {
+		/* set 7 bit mode */
+		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_bitnr, tr_7bit);
+		info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_bitnr, rec_7bit);
+	}
+
+	if (cflag & CSTOPB) {
+		/* set 2 stop bit mode */
+		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, stop_bits, two_bits);
+	}
+
+	if (cflag & PARENB) {
+		/* enable parity */
+		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_par_en, enable);
+		info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_par_en, enable);
+	}
+
+	if (cflag & CMSPAR) {
+		/* enable stick parity, PARODD mean Mark which matches ETRAX */
+		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_stick_par, stick);
+		info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_stick_par, stick);
+	}
+	if (cflag & PARODD) {
+		/* set odd parity (or Mark if CMSPAR) */
+		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_par, odd);
+		info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_par, odd);
+	}
+
+	if (cflag & CRTSCTS) {
+		/* enable automatic CTS handling */
+		DFLOW(DEBUG_LOG(info->line, "FLOW auto_cts enabled\n", 0));
+		info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, auto_cts, active);
+	}
+
+	/* make sure the tx and rx are enabled */
+
+	info->tx_ctrl |= IO_STATE(R_SERIAL0_TR_CTRL, tr_enable, enable);
+	info->rx_ctrl |= IO_STATE(R_SERIAL0_REC_CTRL, rec_enable, enable);
+
+	/* actually write the control regs to the hardware */
+
+	info->port[REG_TR_CTRL] = info->tx_ctrl;
+	info->port[REG_REC_CTRL] = info->rx_ctrl;
+	xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->tty));
+	xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
+	if (info->tty->termios->c_iflag & IXON ) {
+		DFLOW(DEBUG_LOG(info->line, "FLOW XOFF enabled 0x%02X\n", STOP_CHAR(info->tty)));
+		xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
+	}
+
+	*((unsigned long *)&info->port[REG_XOFF]) = xoff;
+	restore_flags(flags);
+#endif /* !CONFIG_SVINTO_SIM */
+
+	update_char_time(info);
+
+} /* change_speed */
+
+/* start transmitting chars NOW */
+
+static void
+rs_flush_chars(struct tty_struct *tty)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+	unsigned long flags;
+
+	if (info->tr_running ||
+	    info->xmit.head == info->xmit.tail ||
+	    tty->stopped ||
+	    tty->hw_stopped ||
+	    !info->xmit.buf)
+		return;
+
+#ifdef SERIAL_DEBUG_FLOW
+	printk("rs_flush_chars\n");
+#endif
+
+	/* this protection might not exactly be necessary here */
+
+	save_flags(flags);
+	cli();
+	start_transmit(info);
+	restore_flags(flags);
+}
+
+extern _INLINE_ int
+rs_raw_write(struct tty_struct * tty, int from_user,
+	  const unsigned char *buf, int count)
+{
+	int	c, ret = 0;
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+	unsigned long flags;
+
+	/* first some sanity checks */
+
+	if (!tty || !info->xmit.buf || !tmp_buf)
+		return 0;
+
+#ifdef SERIAL_DEBUG_DATA
+	if (info->line == SERIAL_DEBUG_LINE)
+		printk("rs_raw_write (%d), status %d\n",
+		       count, info->port[REG_STATUS]);
+#endif
+
+#ifdef CONFIG_SVINTO_SIM
+	/* Really simple.  The output is here and now. */
+	SIMCOUT(buf, count);
+	return count;
+#endif
+	save_flags(flags);
+	DFLOW(DEBUG_LOG(info->line, "write count %i ", count));
+	DFLOW(DEBUG_LOG(info->line, "ldisc %i\n", tty->ldisc.chars_in_buffer(tty)));
+
+
+	/* the cli/restore_flags pairs below are needed because the
+	 * DMA interrupt handler moves the info->xmit values. the memcpy
+	 * needs to be in the critical region unfortunately, because we
+	 * need to read xmit values, memcpy, write xmit values in one
+	 * atomic operation... this could perhaps be avoided by more clever
+	 * design.
+	 */
+	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 (count) {
+			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);
+	}
+
+	/* enable transmitter if not running, unless the tty is stopped
+	 * this does not need IRQ protection since if tr_running == 0
+	 * the IRQ's are not running anyway for this port.
+	 */
+	DFLOW(DEBUG_LOG(info->line, "write ret %i\n", ret));
+
+	if (info->xmit.head != info->xmit.tail &&
+	    !tty->stopped &&
+	    !tty->hw_stopped &&
+	    !info->tr_running) {
+		start_transmit(info);
+	}
+
+	return ret;
+} /* raw_raw_write() */
+
+static int
+rs_write(struct tty_struct * tty, int from_user,
+	 const unsigned char *buf, int count)
+{
+#if defined(CONFIG_ETRAX_RS485)
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+
+	if (info->rs485.enabled)
+	{
+		/* If we are in RS-485 mode, we need to toggle RTS and disable
+		 * the receiver before initiating a DMA transfer
+		 */
+#ifdef CONFIG_ETRAX_FAST_TIMER
+		/* Abort any started timer */
+		fast_timers_rs485[info->line].function = NULL;
+		del_fast_timer(&fast_timers_rs485[info->line]);
+#endif
+		e100_rts(info, info->rs485.rts_on_send);
+#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
+		e100_disable_rx(info);
+		e100_enable_rx_irq(info);
+#endif
+
+		if (info->rs485.delay_rts_before_send > 0) {
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout((info->rs485.delay_rts_before_send * HZ)/1000);
+		}
+	}
+#endif /* CONFIG_ETRAX_RS485 */
+
+	count = rs_raw_write(tty, from_user, buf, count);
+
+#if defined(CONFIG_ETRAX_RS485)
+	if (info->rs485.enabled)
+	{
+		unsigned int val;
+		/* If we are in RS-485 mode the following has to be done:
+		 * wait until DMA is ready
+		 * wait on transmit shift register
+		 * toggle RTS
+		 * enable the receiver
+		 */
+
+		/* Sleep until all sent */
+		tty_wait_until_sent(tty, 0);
+#ifdef CONFIG_ETRAX_FAST_TIMER
+		/* Now sleep a little more so that shift register is empty */
+		schedule_usleep(info->char_time_usec * 2);
+#endif
+		/* wait on transmit shift register */
+		do{
+			get_lsr_info(info, &val);
+		}while (!(val & TIOCSER_TEMT));
+
+		e100_rts(info, info->rs485.rts_after_sent);
+
+#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
+		e100_enable_rx(info);
+		e100_enable_rxdma_irq(info);
+#endif
+	}
+#endif /* CONFIG_ETRAX_RS485 */
+
+	return count;
+} /* rs_write */
+
+
+/* how much space is available in the xmit buffer? */
+
+static int
+rs_write_room(struct tty_struct *tty)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+
+	return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
+}
+
+/* How many chars are in the xmit buffer?
+ * This does not include any chars in the transmitter FIFO.
+ * Use wait_until_sent for waiting for FIFO drain.
+ */
+
+static int
+rs_chars_in_buffer(struct tty_struct *tty)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+
+	return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
+}
+
+/* discard everything in the xmit buffer */
+
+static void
+rs_flush_buffer(struct tty_struct *tty)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+	unsigned long flags;
+
+	save_flags(flags);
+	cli();
+	info->xmit.head = info->xmit.tail = 0;
+	restore_flags(flags);
+
+	wake_up_interruptible(&tty->write_wait);
+
+	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
+ *
+ * Since we use DMA we don't check for info->x_char in transmit_chars_dma(),
+ * but we do it in handle_ser_tx_interrupt().
+ * We disable DMA channel and enable tx ready interrupt and write the
+ * character when possible.
+ */
+static void rs_send_xchar(struct tty_struct *tty, char ch)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+	unsigned long flags;
+	save_flags(flags); cli();
+	if (info->uses_dma_out) {
+		/* Put the DMA on hold and disable the channel */
+		*info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, hold);
+		while (IO_EXTRACT(R_DMA_CH6_CMD, cmd, *info->ocmdadr) !=
+		       IO_STATE_VALUE(R_DMA_CH6_CMD, cmd, hold));
+		e100_disable_txdma_channel(info);
+	}
+
+	/* Must make sure transmitter is not stopped before we can transmit */
+	if (tty->stopped)
+		rs_start(tty);
+
+	/* Enable manual transmit interrupt and send from there */
+	DFLOW(DEBUG_LOG(info->line, "rs_send_xchar 0x%02X\n", ch));
+	info->x_char = ch;
+	e100_enable_serial_tx_ready_irq(info);
+	restore_flags(flags);
+}
+
+/*
+ * ------------------------------------------------------------
+ * 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 e100_serial *info = (struct e100_serial *)tty->driver_data;
+#ifdef SERIAL_DEBUG_THROTTLE
+	char	buf[64];
+
+	printk("throttle %s: %lu....\n", tty_name(tty, buf),
+	       (unsigned long)tty->ldisc.chars_in_buffer(tty));
+#endif
+	DFLOW(DEBUG_LOG(info->line,"rs_throttle %lu\n", tty->ldisc.chars_in_buffer(tty)));
+
+	/* Do RTS before XOFF since XOFF might take some time */
+	if (tty->termios->c_cflag & CRTSCTS) {
+		/* Turn off RTS line */
+		e100_rts(info, 0);
+	}
+	if (I_IXOFF(tty))
+		rs_send_xchar(tty, STOP_CHAR(tty));
+
+}
+
+static void
+rs_unthrottle(struct tty_struct * tty)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+#ifdef SERIAL_DEBUG_THROTTLE
+	char	buf[64];
+
+	printk("unthrottle %s: %lu....\n", tty_name(tty, buf),
+	       (unsigned long)tty->ldisc.chars_in_buffer(tty));
+#endif
+	DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc %d\n", tty->ldisc.chars_in_buffer(tty)));
+	DFLOW(DEBUG_LOG(info->line,"rs_unthrottle flip.count: %i\n", tty->flip.count));
+	/* Do RTS before XOFF since XOFF might take some time */
+	if (tty->termios->c_cflag & CRTSCTS) {
+		/* Assert RTS line  */
+		e100_rts(info, 1);
+	}
+
+	if (I_IXOFF(tty)) {
+		if (info->x_char)
+			info->x_char = 0;
+		else
+			rs_send_xchar(tty, START_CHAR(tty));
+	}
+
+}
+
+/*
+ * ------------------------------------------------------------
+ * rs_ioctl() and friends
+ * ------------------------------------------------------------
+ */
+
+static int
+get_serial_info(struct e100_serial * info,
+		struct serial_struct * retinfo)
+{
+	struct serial_struct tmp;
+
+	/* this is all probably wrong, there are a lot of fields
+	 * here that we don't have in e100_serial and maybe we
+	 * should set them to something else than 0.
+	 */
+
+	if (!retinfo)
+		return -EFAULT;
+	memset(&tmp, 0, sizeof(tmp));
+	tmp.type = info->type;
+	tmp.line = info->line;
+	tmp.port = (int)info->port;
+	tmp.irq = info->irq;
+	tmp.flags = info->flags;
+	tmp.baud_base = info->baud_base;
+	tmp.close_delay = info->close_delay;
+	tmp.closing_wait = info->closing_wait;
+	tmp.custom_divisor = info->custom_divisor;
+	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
+		return -EFAULT;
+	return 0;
+}
+
+static int
+set_serial_info(struct e100_serial *info,
+		struct serial_struct *new_info)
+{
+	struct serial_struct new_serial;
+	struct e100_serial old_info;
+	int retval = 0;
+
+	if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
+		return -EFAULT;
+
+	old_info = *info;
+
+	if (!capable(CAP_SYS_ADMIN)) {
+		if ((new_serial.type != info->type) ||
+		    (new_serial.close_delay != info->close_delay) ||
+		    ((new_serial.flags & ~ASYNC_USR_MASK) !=
+		     (info->flags & ~ASYNC_USR_MASK)))
+			return -EPERM;
+		info->flags = ((info->flags & ~ASYNC_USR_MASK) |
+			       (new_serial.flags & ASYNC_USR_MASK));
+		goto check_and_exit;
+	}
+
+	if (info->count > 1)
+		return -EBUSY;
+
+	/*
+	 * 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->flags = ((info->flags & ~ASYNC_FLAGS) |
+		       (new_serial.flags & ASYNC_FLAGS));
+	info->custom_divisor = new_serial.custom_divisor;
+	info->type = new_serial.type;
+	info->close_delay = new_serial.close_delay;
+	info->closing_wait = new_serial.closing_wait;
+	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+
+ check_and_exit:
+	if (info->flags & ASYNC_INITIALIZED) {
+		change_speed(info);
+	} 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 e100_serial * info, unsigned int *value)
+{
+	unsigned int result = TIOCSER_TEMT;
+#ifndef CONFIG_SVINTO_SIM
+	unsigned long curr_time = jiffies;
+	unsigned long curr_time_usec = GET_JIFFIES_USEC();
+	unsigned long elapsed_usec =
+		(curr_time - info->last_tx_active) * 1000000/HZ +
+		curr_time_usec - info->last_tx_active_usec;
+
+	if (info->xmit.head != info->xmit.tail ||
+	    elapsed_usec < 2*info->char_time_usec) {
+		result = 0;
+	}
+#endif
+
+	if (copy_to_user(value, &result, sizeof(int)))
+		return -EFAULT;
+	return 0;
+}
+
+#ifdef SERIAL_DEBUG_IO
+struct state_str
+{
+	int state;
+	const char *str;
+};
+
+const struct state_str control_state_str[] = {
+	{TIOCM_DTR, "DTR" },
+	{TIOCM_RTS, "RTS"},
+	{TIOCM_ST, "ST?" },
+	{TIOCM_SR, "SR?" },
+	{TIOCM_CTS, "CTS" },
+	{TIOCM_CD, "CD" },
+	{TIOCM_RI, "RI" },
+	{TIOCM_DSR, "DSR" },
+	{0, NULL }
+};
+
+char *get_control_state_str(int MLines, char *s)
+{
+	int i = 0;
+
+	s[0]='\0';
+	while (control_state_str[i].str != NULL) {
+		if (MLines & control_state_str[i].state) {
+			if (s[0] != '\0') {
+				strcat(s, ", ");
+			}
+			strcat(s, control_state_str[i].str);
+		}
+		i++;
+	}
+	return s;
+}
+#endif
+
+static int
+get_modem_info(struct e100_serial * info, unsigned int *value)
+{
+	unsigned int result;
+	/* Polarity isn't verified */
+#if 0 /*def SERIAL_DEBUG_IO  */
+
+	printk("get_modem_info: RTS: %i DTR: %i CD: %i RI: %i DSR: %i CTS: %i\n",
+	       E100_RTS_GET(info),
+	       E100_DTR_GET(info),
+	       E100_CD_GET(info),
+	       E100_RI_GET(info),
+	       E100_DSR_GET(info),
+	       E100_CTS_GET(info));
+#endif
+
+	result =
+		(!E100_RTS_GET(info) ? TIOCM_RTS : 0)
+		| (!E100_DTR_GET(info) ? TIOCM_DTR : 0)
+		| (!E100_RI_GET(info) ? TIOCM_RNG : 0)
+		| (!E100_DSR_GET(info) ? TIOCM_DSR : 0)
+		| (!E100_CD_GET(info) ? TIOCM_CAR : 0)
+		| (!E100_CTS_GET(info) ? TIOCM_CTS : 0);
+
+#ifdef SERIAL_DEBUG_IO
+	printk("e100ser: modem state: %i 0x%08X\n", result, result);
+	{
+		char s[100];
+
+		get_control_state_str(result, s);
+		printk("state: %s\n", s);
+	}
+#endif
+	if (copy_to_user(value, &result, sizeof(int)))
+		return -EFAULT;
+	return 0;
+}
+
+
+static int
+set_modem_info(struct e100_serial * info, unsigned int cmd,
+	       unsigned int *value)
+{
+	unsigned int arg;
+
+	if (copy_from_user(&arg, value, sizeof(int)))
+		return -EFAULT;
+
+	switch (cmd) {
+	case TIOCMBIS:
+		if (arg & TIOCM_RTS) {
+			e100_rts(info, 1);
+		}
+		if (arg & TIOCM_DTR) {
+			e100_dtr(info, 1);
+		}
+		/* Handle FEMALE behaviour */
+		if (arg & TIOCM_RI) {
+			e100_ri_out(info, 1);
+		}
+		if (arg & TIOCM_CD) {
+			e100_cd_out(info, 1);
+		}
+		break;
+	case TIOCMBIC:
+		if (arg & TIOCM_RTS) {
+			e100_rts(info, 0);
+		}
+		if (arg & TIOCM_DTR) {
+			e100_dtr(info, 0);
+		}
+		/* Handle FEMALE behaviour */
+		if (arg & TIOCM_RI) {
+			e100_ri_out(info, 0);
+		}
+		if (arg & TIOCM_CD) {
+			e100_cd_out(info, 0);
+		}
+		break;
+	case TIOCMSET:
+		e100_rts(info, arg & TIOCM_RTS);
+		e100_dtr(info, arg & TIOCM_DTR);
+		/* Handle FEMALE behaviour */
+		e100_ri_out(info, arg & TIOCM_RI);
+		e100_cd_out(info, arg & TIOCM_CD);
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+
+static void
+rs_break(struct tty_struct *tty, int break_state)
+{
+	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
+	unsigned long flags;
+
+	if (!info->port)
+		return;
+
+	save_flags(flags);
+	cli();
+	if (break_state == -1) {
+		/* Go to manual mode and set the txd pin to 0 */
+		info->tx_ctrl &= 0x3F; /* Clear bit 7 (txd) and 6 (tr_enable) */
+	} else {
+		info->tx_ctrl |= (0x80 | 0x40); /* Set bit 7 (txd) and 6 (tr_enable) */
+	}
+	info->port[REG_TR_CTRL] = info->tx_ctrl;
+	restore_flags(flags);
+}
+
+static int
+rs_ioctl(struct tty_struct *tty, struct file * file,
+	 unsigned int cmd, unsigned long arg)
+{
+	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
+
+	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 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 TIOCSERGETLSR: /* Get line status register */
+			return get_lsr_info(info, (unsigned int *) arg);
+
+		case TIOCSERGSTRUCT:
+			if (copy_to_user((struct e100_serial *) arg,
+					 info, sizeof(struct e100_serial)))
+				return -EFAULT;
+			return 0;
+
+#if defined(CONFIG_ETRAX_RS485)
+		case TIOCSERSETRS485:
+		{
+			struct rs485_control rs485ctrl;
+			if (copy_from_user(&rs485ctrl, (struct rs485_control*)arg, sizeof(rs485ctrl)))
+				return -EFAULT;
+
+			return e100_enable_rs485(tty, &rs485ctrl);
+		}
+
+		case TIOCSERWRRS485:
+		{
+			struct rs485_write rs485wr;
+			if (copy_from_user(&rs485wr, (struct rs485_write*)arg, sizeof(rs485wr)))
+				return -EFAULT;
+
+			return e100_write_rs485(tty, 1, rs485wr.outc, rs485wr.outc_size);
+		}
+#endif
+
+		default:
+			return -ENOIOCTLCMD;
+	}
+	return 0;
+}
+
+static void
+rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+{
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+
+	if (tty->termios->c_cflag == old_termios->c_cflag &&
+	    tty->termios->c_iflag == old_termios->c_iflag)
+		return;
+
+	change_speed(info);
+
+	/* Handle turning off CRTSCTS */
+	if ((old_termios->c_cflag & CRTSCTS) &&
+	    !(tty->termios->c_cflag & CRTSCTS)) {
+		tty->hw_stopped = 0;
+		rs_start(tty);
+	}
+
+}
+
+/* In debugport.c - register a console write function that uses the normal
+ * serial driver
+ */
+typedef int (*debugport_write_function)(int i, const char *buf, unsigned int len);
+
+extern debugport_write_function debug_write_function;
+
+static int rs_debug_write_function(int i, const char *buf, unsigned int len)
+{
+	int cnt;
+	int written = 0;
+        struct tty_struct *tty;
+        static int recurse_cnt = 0;
+
+        tty = rs_table[i].tty;
+        if (tty)  {
+		unsigned long flags;
+		if (recurse_cnt > 5) /* We skip this debug output */
+			return 1;
+
+		local_irq_save(flags);
+		recurse_cnt++;
+		local_irq_restore(flags);
+                do {
+                        cnt = rs_write(tty, 0, buf + written, len);
+                        if (cnt >= 0) {
+				written += cnt;
+                                buf += cnt;
+                                len -= cnt;
+                        } else
+                                len = cnt;
+                } while(len > 0);
+		local_irq_save(flags);
+		recurse_cnt--;
+		local_irq_restore(flags);
+                return 1;
+        }
+        return 0;
+}
+
+/*
+ * ------------------------------------------------------------
+ * 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
+ * S 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 e100_serial * info = (struct e100_serial *)tty->driver_data;
+	unsigned long flags;
+
+	if (!info)
+		return;
+
+	/* interrupts are disabled for this entire function */
+
+	save_flags(flags);
+	cli();
+
+	if (tty_hung_up_p(filp)) {
+		restore_flags(flags);
+		return;
+	}
+
+#ifdef SERIAL_DEBUG_OPEN
+	printk("[%d] rs_close ttyS%d, count = %d\n", current->pid,
+	       info->line, info->count);
+#endif
+	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(KERN_CRIT
+		       "rs_close: bad serial port count; tty->count is 1, "
+		       "info->count is %d\n", info->count);
+		info->count = 1;
+	}
+	if (--info->count < 0) {
+		printk(KERN_CRIT "rs_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 |= ASYNC_CLOSING;
+	/*
+	 * Save the termios structure, since this port may have
+	 * separate termios for callout and dialin.
+	 */
+	if (info->flags & ASYNC_NORMAL_ACTIVE)
+		info->normal_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 serial receiver and the DMA receive interrupt.
+	 */
+#ifdef SERIAL_HANDLE_EARLY_ERRORS
+	e100_disable_serial_data_irq(info);
+#endif
+
+#ifndef CONFIG_SVINTO_SIM
+	e100_disable_rx(info);
+	e100_disable_rx_irq(info);
+
+	if (info->flags & ASYNC_INITIALIZED) {
+		/*
+		 * Before we drop DTR, make sure the UART transmitter
+		 * has completely drained; this is especially
+		 * important as we have a transmit FIFO!
+		 */
+		rs_wait_until_sent(tty, HZ);
+	}
+#endif
+
+	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_CLOSING);
+	wake_up_interruptible(&info->close_wait);
+	restore_flags(flags);
+
+	/* port closed */
+
+#if defined(CONFIG_ETRAX_RS485)
+	if (info->rs485.enabled) {
+		info->rs485.enabled = 0;
+#if defined(CONFIG_ETRAX_RS485_ON_PA)
+		*R_PORT_PA_DATA = port_pa_data_shadow &= ~(1 << rs485_pa_bit);
+#endif
+#if defined(CONFIG_ETRAX_RS485_ON_PORT_G)
+		REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
+			       rs485_port_g_bit, 0);
+#endif
+#if defined(CONFIG_ETRAX_RS485_LTC1387)
+		REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
+			       CONFIG_ETRAX_RS485_LTC1387_DXEN_PORT_G_BIT, 0);
+		REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow,
+			       CONFIG_ETRAX_RS485_LTC1387_RXEN_PORT_G_BIT, 0);
+#endif
+	}
+#endif
+}
+
+/*
+ * rs_wait_until_sent() --- wait until the transmitter is empty
+ */
+static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+	unsigned long orig_jiffies;
+	struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+	unsigned long curr_time = jiffies;
+	unsigned long curr_time_usec = GET_JIFFIES_USEC();
+	long elapsed_usec =
+		(curr_time - info->last_tx_active) * (1000000/HZ) +
+		curr_time_usec - info->last_tx_active_usec;
+
+	/*
+	 * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO
+	 * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k)
+	 */
+	orig_jiffies = jiffies;
+	while (info->xmit.head != info->xmit.tail || /* More in send queue */
+	       (*info->ostatusadr & 0x007f) ||  /* more in FIFO */
+	       (elapsed_usec < 2*info->char_time_usec)) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(1);
+		if (signal_pending(current))
+			break;
+		if (timeout && time_after(jiffies, orig_jiffies + timeout))
+			break;
+		curr_time = jiffies;
+		curr_time_usec = GET_JIFFIES_USEC();
+		elapsed_usec =
+			(curr_time - info->last_tx_active) * (1000000/HZ) +
+			curr_time_usec - info->last_tx_active_usec;
+	}
+	set_current_state(TASK_RUNNING);
+}
+
+/*
+ * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
+ */
+void
+rs_hangup(struct tty_struct *tty)
+{
+	struct e100_serial * info = (struct e100_serial *)tty->driver_data;
+
+	rs_flush_buffer(tty);
+	shutdown(info);
+	info->event = 0;
+	info->count = 0;
+	info->flags &= ~ASYNC_NORMAL_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 e100_serial *info)
+{
+	DECLARE_WAITQUEUE(wait, current);
+	unsigned long	flags;
+	int		retval;
+	int		do_clocal = 0, extra_count = 0;
+
+	/*
+	 * 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
+		if (info->flags & ASYNC_HUP_NOTIFY)
+			return -EAGAIN;
+		else
+			return -ERESTARTSYS;
+#else
+		return -EAGAIN;
+#endif
+	}
+
+	/*
+	 * 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))) {
+		info->flags |= ASYNC_NORMAL_ACTIVE;
+		return 0;
+	}
+
+	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
+	 * 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",
+	       info->line, info->count);
+#endif
+	save_flags(flags);
+	cli();
+	if (!tty_hung_up_p(filp)) {
+		extra_count++;
+		info->count--;
+	}
+	restore_flags(flags);
+	info->blocked_open++;
+	while (1) {
+		save_flags(flags);
+		cli();
+		/* assert RTS and DTR */
+		e100_rts(info, 1);
+		e100_dtr(info, 1);
+		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_CLOSING) && do_clocal)
+			/* && (do_clocal || DCD_IS_ASSERTED) */
+			break;
+		if (signal_pending(current)) {
+			retval = -ERESTARTSYS;
+			break;
+		}
+#ifdef SERIAL_DEBUG_OPEN
+		printk("block_til_ready blocking: ttyS%d, count = %d\n",
+		       info->line, info->count);
+#endif
+		schedule();
+	}
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&info->open_wait, &wait);
+	if (extra_count)
+		info->count++;
+	info->blocked_open--;
+#ifdef SERIAL_DEBUG_OPEN
+	printk("block_til_ready after blocking: ttyS%d, count = %d\n",
+	       info->line, info->count);
+#endif
+	if (retval)
+		return retval;
+	info->flags |= ASYNC_NORMAL_ACTIVE;
+	return 0;
+}
+
+/*
+ * This routine is called whenever a serial port is opened.
+ * It performs the serial-specific initialization for the tty structure.
+ */
+static int
+rs_open(struct tty_struct *tty, struct file * filp)
+{
+	struct e100_serial	*info;
+	int 			retval, line;
+	unsigned long           page;
+
+	/* find which port we want to open */
+
+	line = tty->index;
+
+	if (line < 0 || line >= NR_PORTS)
+		return -ENODEV;
+
+	/* find the corresponding e100_serial struct in the table */
+	info = rs_table + line;
+
+	/* don't allow the opening of ports that are not enabled in the HW config */
+	if (!info->enabled)
+		return -ENODEV;
+
+#ifdef SERIAL_DEBUG_OPEN
+        printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name,
+ 	       info->count);
+#endif
+
+	info->count++;
+	tty->driver_data = info;
+	info->tty = tty;
+
+	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+
+	if (!tmp_buf) {
+		page = get_zeroed_page(GFP_KERNEL);
+		if (!page) {
+			return -ENOMEM;
+		}
+		if (tmp_buf)
+			free_page(page);
+		else
+			tmp_buf = (unsigned char *) page;
+	}
+
+	/*
+	 * If the port is in 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);
+#ifdef SERIAL_DO_RESTART
+		return ((info->flags & ASYNC_HUP_NOTIFY) ?
+			-EAGAIN : -ERESTARTSYS);
+#else
+		return -EAGAIN;
+#endif
+	}
+
+	/*
+	 * Start up the serial port
+	 */
+
+	retval = startup(info);
+	if (retval)
+		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
+		return retval;
+	}
+
+	if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
+		*tty->termios = info->normal_termios;
+		change_speed(info);
+	}
+
+#ifdef SERIAL_DEBUG_OPEN
+	printk("rs_open ttyS%d successful...\n", info->line);
+#endif
+	DLOG_INT_TRIG( log_int_pos = 0);
+
+	DFLIP(	if (info->line == SERIAL_DEBUG_LINE) {
+			info->icount.rx = 0;
+		} );
+
+	return 0;
+}
+
+/*
+ * /proc fs routines....
+ */
+
+extern _INLINE_ int line_info(char *buf, struct e100_serial *info)
+{
+	char	stat_buf[30];
+	int	ret;
+	unsigned long tmp;
+
+	ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d",
+		      info->line, (unsigned long)info->port, info->irq);
+
+	if (!info->port || (info->type == PORT_UNKNOWN)) {
+		ret += sprintf(buf+ret, "\n");
+		return ret;
+	}
+
+	stat_buf[0] = 0;
+	stat_buf[1] = 0;
+	if (!E100_RTS_GET(info))
+		strcat(stat_buf, "|RTS");
+	if (!E100_CTS_GET(info))
+		strcat(stat_buf, "|CTS");
+	if (!E100_DTR_GET(info))
+		strcat(stat_buf, "|DTR");
+	if (!E100_DSR_GET(info))
+		strcat(stat_buf, "|DSR");
+	if (!E100_CD_GET(info))
+		strcat(stat_buf, "|CD");
+	if (!E100_RI_GET(info))
+		strcat(stat_buf, "|RI");
+
+	ret += sprintf(buf+ret, " baud:%d", info->baud);
+
+	ret += sprintf(buf+ret, " tx:%lu rx:%lu",
+		       (unsigned long)info->icount.tx,
+		       (unsigned long)info->icount.rx);
+	tmp = CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
+	if (tmp) {
+		ret += sprintf(buf+ret, " tx_pend:%lu/%lu",
+			       (unsigned long)tmp,
+			       (unsigned long)SERIAL_XMIT_SIZE);
+	}
+
+	ret += sprintf(buf+ret, " rx_pend:%lu/%lu",
+		       (unsigned long)info->recv_cnt,
+		       (unsigned long)info->max_recv_cnt);
+
+#if 1
+	if (info->tty) {
+
+		if (info->tty->stopped)
+			ret += sprintf(buf+ret, " stopped:%i",
+				       (int)info->tty->stopped);
+		if (info->tty->hw_stopped)
+			ret += sprintf(buf+ret, " hw_stopped:%i",
+				       (int)info->tty->hw_stopped);
+	}
+
+	{
+		unsigned char rstat = info->port[REG_STATUS];
+		if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) )
+			ret += sprintf(buf+ret, " xoff_detect:1");
+	}
+
+#endif
+
+
+
+
+	if (info->icount.frame)
+		ret += sprintf(buf+ret, " fe:%lu",
+			       (unsigned long)info->icount.frame);
+
+	if (info->icount.parity)
+		ret += sprintf(buf+ret, " pe:%lu",
+			       (unsigned long)info->icount.parity);
+
+	if (info->icount.brk)
+		ret += sprintf(buf+ret, " brk:%lu",
+			       (unsigned long)info->icount.brk);
+
+	if (info->icount.overrun)
+		ret += sprintf(buf+ret, " oe:%lu",
+			       (unsigned long)info->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\n",
+		       serial_version);
+	for (i = 0; i < NR_PORTS && len < 4000; i++) {
+		if (!rs_table[i].enabled)
+			continue;
+		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;
+		}
+	}
+#ifdef DEBUG_LOG_INCLUDED
+	for (i = 0; i < debug_log_pos; i++) {
+		len += sprintf(page + len, "%-4i %lu.%lu ", i, debug_log[i].time, timer_data_to_ns(debug_log[i].timer_data));
+		len += sprintf(page + len, debug_log[i].string, debug_log[i].value);
+		if (len+begin > off+count)
+			goto done;
+		if (len+begin < off) {
+			begin += len;
+			len = 0;
+		}
+	}
+	len += sprintf(page + len, "debug_log %i/%i  %li bytes\n",
+		       i, DEBUG_LOG_SIZE, begin+len);
+	debug_log_pos = 0;
+#endif
+
+	*eof = 1;
+done:
+	if (off >= len+begin)
+		return 0;
+	*start = page + (off-begin);
+	return ((count < begin+len-off) ? count : begin+len-off);
+}
+
+/* Finally, routines used to initialize the serial driver. */
+
+static void
+show_serial_version(void)
+{
+	printk(KERN_INFO
+	       "ETRAX 100LX serial-driver %s, (c) 2000-2004 Axis Communications AB\r\n",
+	       &serial_version[11]); /* "$Revision: x.yy" */
+}
+
+/* rs_init inits the driver at boot (using the module_init chain) */
+
+static struct tty_operations rs_ops = {
+	.open = rs_open,
+	.close = rs_close,
+	.write = rs_write,
+	.flush_chars = rs_flush_chars,
+	.write_room = rs_write_room,
+	.chars_in_buffer = rs_chars_in_buffer,
+	.flush_buffer = rs_flush_buffer,
+	.ioctl = rs_ioctl,
+	.throttle = rs_throttle,
+        .unthrottle = rs_unthrottle,
+	.set_termios = rs_set_termios,
+	.stop = rs_stop,
+	.start = rs_start,
+	.hangup = rs_hangup,
+	.break_ctl = rs_break,
+	.send_xchar = rs_send_xchar,
+	.wait_until_sent = rs_wait_until_sent,
+	.read_proc = rs_read_proc,
+};
+
+static int __init
+rs_init(void)
+{
+	int i;
+	struct e100_serial *info;
+	struct tty_driver *driver = alloc_tty_driver(NR_PORTS);
+
+	if (!driver)
+		return -ENOMEM;
+
+	show_serial_version();
+
+	/* Setup the timed flush handler system */
+
+#if !defined(CONFIG_ETRAX_SERIAL_FAST_TIMER)
+	init_timer(&flush_timer);
+	flush_timer.function = timed_flush_handler;
+	mod_timer(&flush_timer, jiffies + CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS);
+#endif
+
+	/* Initialize the tty_driver structure */
+
+	driver->driver_name = "serial";
+	driver->name = "ttyS";
+	driver->major = TTY_MAJOR;
+	driver->minor_start = 64;
+	driver->type = TTY_DRIVER_TYPE_SERIAL;
+	driver->subtype = SERIAL_TYPE_NORMAL;
+	driver->init_termios = tty_std_termios;
+	driver->init_termios.c_cflag =
+		B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */
+	driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
+	driver->termios = serial_termios;
+	driver->termios_locked = serial_termios_locked;
+
+	tty_set_operations(driver, &rs_ops);
+        serial_driver = driver;
+	if (tty_register_driver(driver))
+		panic("Couldn't register serial driver\n");
+	/* do some initializing for the separate ports */
+
+	for (i = 0, info = rs_table; i < NR_PORTS; i++,info++) {
+		info->uses_dma_in = 0;
+		info->uses_dma_out = 0;
+		info->line = i;
+		info->tty = 0;
+		info->type = PORT_ETRAX;
+		info->tr_running = 0;
+		info->forced_eop = 0;
+		info->baud_base = DEF_BAUD_BASE;
+		info->custom_divisor = 0;
+		info->flags = 0;
+		info->close_delay = 5*HZ/10;
+		info->closing_wait = 30*HZ;
+		info->x_char = 0;
+		info->event = 0;
+		info->count = 0;
+		info->blocked_open = 0;
+		info->normal_termios = driver->init_termios;
+		init_waitqueue_head(&info->open_wait);
+		init_waitqueue_head(&info->close_wait);
+		info->xmit.buf = NULL;
+		info->xmit.tail = info->xmit.head = 0;
+		info->first_recv_buffer = info->last_recv_buffer = NULL;
+		info->recv_cnt = info->max_recv_cnt = 0;
+		info->last_tx_active_usec = 0;
+		info->last_tx_active = 0;
+
+#if defined(CONFIG_ETRAX_RS485)
+		/* Set sane defaults */
+		info->rs485.rts_on_send = 0;
+		info->rs485.rts_after_sent = 1;
+		info->rs485.delay_rts_before_send = 0;
+		info->rs485.enabled = 0;
+#endif
+		INIT_WORK(&info->work, do_softint, info);
+
+		if (info->enabled) {
+			printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n",
+			       serial_driver->name, info->line, (unsigned int)info->port);
+		}
+	}
+#ifdef CONFIG_ETRAX_FAST_TIMER
+#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
+	memset(fast_timers, 0, sizeof(fast_timers));
+#endif
+#ifdef CONFIG_ETRAX_RS485
+	memset(fast_timers_rs485, 0, sizeof(fast_timers_rs485));
+#endif
+	fast_timer_init();
+#endif
+
+#ifndef CONFIG_SVINTO_SIM
+	/* Not needed in simulator.  May only complicate stuff. */
+	/* hook the irq's for DMA channel 6 and 7, serial output and input, and some more... */
+
+	if (request_irq(SERIAL_IRQ_NBR, ser_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial ", NULL))
+		panic("irq8");
+
+#ifdef CONFIG_ETRAX_SERIAL_PORT0
+#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA6_OUT
+	if (request_irq(SER0_DMA_TX_IRQ_NBR, tr_interrupt, SA_INTERRUPT, "serial 0 dma tr", NULL))
+		panic("irq22");
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA7_IN
+	if (request_irq(SER0_DMA_RX_IRQ_NBR, rec_interrupt, SA_INTERRUPT, "serial 0 dma rec", NULL))
+		panic("irq23");
+#endif
+#endif
+
+#ifdef CONFIG_ETRAX_SERIAL_PORT1
+#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA8_OUT
+	if (request_irq(SER1_DMA_TX_IRQ_NBR, tr_interrupt, SA_INTERRUPT, "serial 1 dma tr", NULL))
+		panic("irq24");
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA9_IN
+	if (request_irq(SER1_DMA_RX_IRQ_NBR, rec_interrupt, SA_INTERRUPT, "serial 1 dma rec", NULL))
+		panic("irq25");
+#endif
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT2
+	/* DMA Shared with par0 (and SCSI0 and ATA) */
+#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA2_OUT
+	if (request_irq(SER2_DMA_TX_IRQ_NBR, tr_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial 2 dma tr", NULL))
+		panic("irq18");
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA3_IN
+	if (request_irq(SER2_DMA_RX_IRQ_NBR, rec_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial 2 dma rec", NULL))
+		panic("irq19");
+#endif
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT3
+	/* DMA Shared with par1 (and SCSI1 and Extern DMA 0) */
+#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA4_OUT
+	if (request_irq(SER3_DMA_TX_IRQ_NBR, tr_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial 3 dma tr", NULL))
+		panic("irq20");
+#endif
+#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA5_IN
+	if (request_irq(SER3_DMA_RX_IRQ_NBR, rec_interrupt, SA_SHIRQ | SA_INTERRUPT, "serial 3 dma rec", NULL))
+		panic("irq21");
+#endif
+#endif
+
+#ifdef CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST
+	if (request_irq(TIMER1_IRQ_NBR, timeout_interrupt, SA_SHIRQ | SA_INTERRUPT,
+		       "fast serial dma timeout", NULL)) {
+		printk(KERN_CRIT "err: timer1 irq\n");
+	}
+#endif
+#endif /* CONFIG_SVINTO_SIM */
+	debug_write_function = rs_debug_write_function;
+	return 0;
+}
+
+/* this makes sure that rs_init is called during kernel boot */
+
+module_init(rs_init);
+
+/*
+ * register_serial and unregister_serial allows for serial ports to be
+ * configured at run-time, to support PCMCIA modems.
+ */
+int
+register_serial(struct serial_struct *req)
+{
+	return -1;
+}
+
+void unregister_serial(int line)
+{
+}
diff -Nru a/drivers/serial/crisv10.h b/drivers/serial/crisv10.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/serial/crisv10.h	2004-12-24 13:37:19 -08:00
@@ -0,0 +1,137 @@
+/*
+ * serial.h: Arch-dep definitions for the Etrax100 serial driver.
+ *
+ * Copyright (C) 1998, 1999, 2000 Axis Communications AB
+ */
+
+#ifndef _ETRAX_SERIAL_H
+#define _ETRAX_SERIAL_H
+
+#include <linux/config.h>
+#include <linux/circ_buf.h>
+#include <asm/termios.h>
+
+/* Software state per channel */
+
+#ifdef __KERNEL__
+/*
+ * This is our internal structure for each serial port's state.
+ *
+ * Many fields are paralleled by the structure used by the serial_struct
+ * structure.
+ *
+ * For definitions of the flags field, see tty.h
+ */
+
+#define SERIAL_RECV_DESCRIPTORS 8
+
+struct etrax_recv_buffer {
+	struct etrax_recv_buffer *next;
+	unsigned short length;
+	unsigned char error;
+	unsigned char pad;
+
+	unsigned char buffer[0];
+};
+
+struct e100_serial {
+	int			baud;
+	volatile u8		*port; /* R_SERIALx_CTRL */
+	u32			irq;  /* bitnr in R_IRQ_MASK2 for dmaX_descr */
+
+	/* Output registers */
+	volatile u8		*oclrintradr; /* adr to R_DMA_CHx_CLR_INTR */
+	volatile u32		*ofirstadr;   /* adr to R_DMA_CHx_FIRST */
+	volatile u8		*ocmdadr;     /* adr to R_DMA_CHx_CMD */
+	const volatile u8	*ostatusadr;  /* adr to R_DMA_CHx_STATUS */
+
+	/* Input registers */
+	volatile u8		*iclrintradr; /* adr to R_DMA_CHx_CLR_INTR */
+	volatile u32		*ifirstadr;   /* adr to R_DMA_CHx_FIRST */
+	volatile u8		*icmdadr;     /* adr to R_DMA_CHx_CMD */
+	volatile u32		*idescradr;   /* adr to R_DMA_CHx_DESCR */
+
+	int			flags;	/* defined in tty.h */
+
+	u8			rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */
+	u8			tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */
+	u8			iseteop; /* bit number for R_SET_EOP for the input dma */
+	int			enabled; /* Set to 1 if the port is enabled in HW config */
+
+	u8		dma_out_enabled:1; /* Set to 1 if DMA should be used */
+	u8		dma_in_enabled:1;  /* Set to 1 if DMA should be used */
+
+	/* end of fields defined in rs_table[] in .c-file */
+	u8		uses_dma_in;  /* Set to 1 if DMA is used */
+	u8		uses_dma_out; /* Set to 1 if DMA is used */
+	u8		forced_eop;   /* a fifo eop has been forced */
+	int			baud_base;     /* For special baudrates */
+	int			custom_divisor; /* For special baudrates */
+	struct etrax_dma_descr	tr_descr;
+	struct etrax_dma_descr	rec_descr[SERIAL_RECV_DESCRIPTORS];
+	int			cur_rec_descr;
+
+	volatile int		tr_running; /* 1 if output is running */
+
+	struct tty_struct	*tty;
+	int			read_status_mask;
+	int			ignore_status_mask;
+	int			x_char;	/* xon/xoff character */
+	int			close_delay;
+	unsigned short		closing_wait;
+	unsigned short		closing_wait2;
+	unsigned long		event;
+	unsigned long		last_active;
+	int			line;
+	int			type;  /* PORT_ETRAX */
+	int			count;	    /* # of fd on device */
+	int			blocked_open; /* # of blocked opens */
+	struct circ_buf		xmit;
+	struct etrax_recv_buffer *first_recv_buffer;
+	struct etrax_recv_buffer *last_recv_buffer;
+	unsigned int		recv_cnt;
+	unsigned int		max_recv_cnt;
+
+	struct work_struct	work;
+	struct async_icount	icount;   /* error-statistics etc.*/
+	struct termios		normal_termios;
+	struct termios		callout_termios;
+#ifdef DECLARE_WAITQUEUE
+	wait_queue_head_t	open_wait;
+	wait_queue_head_t	close_wait;
+#else
+	struct wait_queue	*open_wait;
+	struct wait_queue	*close_wait;
+#endif
+
+	unsigned long		char_time_usec;       /* The time for 1 char, in usecs */
+	unsigned long		flush_time_usec;      /* How often we should flush */
+	unsigned long		last_tx_active_usec;  /* Last tx usec in the jiffies */
+	unsigned long		last_tx_active;       /* Last tx time in jiffies */
+	unsigned long		last_rx_active_usec;  /* Last rx usec in the jiffies */
+	unsigned long		last_rx_active;       /* Last rx time in jiffies */
+
+	int			break_detected_cnt;
+	int			errorcode;
+
+#ifdef CONFIG_ETRAX_RS485
+	struct rs485_control	rs485;  /* RS-485 support */
+#endif
+};
+
+/* this PORT is not in the standard serial.h. it's not actually used for
+ * anything since we only have one type of async serial-port anyway in this
+ * system.
+ */
+
+#define PORT_ETRAX 1
+
+/*
+ * Events are used to schedule things to happen at timer-interrupt
+ * time, instead of at rs interrupt time.
+ */
+#define RS_EVENT_WRITE_WAKEUP	0
+
+#endif /* __KERNEL__ */
+
+#endif /* !_ETRAX_SERIAL_H */
diff -Nru a/drivers/serial/dz.c b/drivers/serial/dz.c
--- a/drivers/serial/dz.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/serial/dz.c	2004-12-24 13:37:00 -08:00
@@ -28,12 +28,13 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/console.h>
-#include <linux/serial.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
 #include <linux/serial_core.h>
+#include <linux/serial.h>
 
 #include <asm/bootinfo.h>
 #include <asm/dec/interrupts.h>
@@ -186,7 +187,7 @@
 	struct uart_icount *icount;
 	int ignore = 0;
 	unsigned short status, tmp;
-	unsigned char ch;
+	unsigned char ch, flag;
 
 	/* this code is going to be a problem...
 	   the call to tty_flip_buffer is going to need
@@ -201,6 +202,7 @@
 
 
 		ch = UCHAR(status);	/* grab the char */
+		flag = TTY_NORMAL;
 
 #if 0
 		if (info->is_console) {
@@ -217,8 +219,6 @@
 		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 */
@@ -243,12 +243,12 @@
 			tmp = status & dport->port.read_status_mask;
 
 			if (tmp & DZ_PERR) {
-				*tty->flip.flag_buf_ptr = TTY_PARITY;
+				flag = TTY_PARITY;
 #ifdef DEBUG_DZ
 				debug_console("PERR\n", 5);
 #endif
 			} else if (tmp & DZ_FERR) {
-				*tty->flip.flag_buf_ptr = TTY_FRAME;
+				flag = TTY_FRAME;
 #ifdef DEBUG_DZ
 				debug_console("FERR\n", 5);
 #endif
@@ -257,17 +257,12 @@
 #ifdef DEBUG_DZ
 				debug_console("OERR\n", 5);
 #endif
-				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_insert_flip_char(tty, ch, flag);
+				ch = 0;
+				flag = TTY_OVERRUN;
 			}
 		}
-		tty->flip.flag_buf_ptr++;
-		tty->flip.char_buf_ptr++;
-		tty->flip.count++;
+		tty_insert_flip_char(tty, ch, flag);
 	      ignore_char:
 	} while (status & DZ_DVAL);
 
diff -Nru a/drivers/serial/icom.c b/drivers/serial/icom.c
--- a/drivers/serial/icom.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/serial/icom.c	2004-12-24 13:36:31 -08:00
@@ -54,13 +54,13 @@
 #include <linux/spinlock.h>
 #include <linux/kobject.h>
 #include <linux/firmware.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/segment.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 
 #include "icom.h"
 
@@ -139,12 +139,6 @@
 #else
 static inline void trace(struct icom_port *icom_port, char *trace_pt, unsigned long trace_data) {};
 #endif
-
-static void msleep(unsigned long msecs)
-{
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(MSECS_TO_JIFFIES(msecs));
-}
 
 static void free_port_memory(struct icom_port *icom_port)
 {
diff -Nru a/drivers/serial/imx.c b/drivers/serial/imx.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/serial/imx.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,902 @@
+/*
+ *  linux/drivers/serial/imx.c
+ *
+ *  Driver for Motorola IMX serial ports
+ *
+ *  Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ *  Author: Sascha Hauer <sascha@saschahauer.de>
+ *  Copyright (C) 2004 Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+#include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_IMX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+#include <linux/device.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
+
+/* We've been assigned a range on the "Low-density serial ports" major */
+#define SERIAL_IMX_MAJOR	204
+#define MINOR_START		41
+
+#define NR_PORTS		2
+
+#define IMX_ISR_PASS_LIMIT	256
+
+/*
+ * This is the size of our serial port register set.
+ */
+#define UART_PORT_SIZE	0x100
+
+/*
+ * This determines how often we check the modem status signals
+ * for any change.  They generally aren't connected to an IRQ
+ * so we have to poll them.  We also check immediately before
+ * filling the TX fifo incase CTS has been dropped.
+ */
+#define MCTRL_TIMEOUT	(250*HZ/1000)
+
+#define DRIVER_NAME "IMX-uart"
+
+struct imx_port {
+	struct uart_port	port;
+	struct timer_list	timer;
+	unsigned int		old_status;
+	int txirq,rxirq;
+};
+
+/*
+ * Handle any change of modem status signal since we were last called.
+ */
+static void imx_mctrl_check(struct imx_port *sport)
+{
+	unsigned int status, changed;
+
+	status = sport->port.ops->get_mctrl(&sport->port);
+	changed = status ^ sport->old_status;
+
+	if (changed == 0)
+		return;
+
+	sport->old_status = status;
+
+	if (changed & TIOCM_RI)
+		sport->port.icount.rng++;
+	if (changed & TIOCM_DSR)
+		sport->port.icount.dsr++;
+	if (changed & TIOCM_CAR)
+		uart_handle_dcd_change(&sport->port, status & TIOCM_CAR);
+	if (changed & TIOCM_CTS)
+		uart_handle_cts_change(&sport->port, status & TIOCM_CTS);
+
+	wake_up_interruptible(&sport->port.info->delta_msr_wait);
+}
+
+/*
+ * This is our per-port timeout handler, for checking the
+ * modem status signals.
+ */
+static void imx_timeout(unsigned long data)
+{
+	struct imx_port *sport = (struct imx_port *)data;
+	unsigned long flags;
+
+	if (sport->port.info) {
+		spin_lock_irqsave(&sport->port.lock, flags);
+		imx_mctrl_check(sport);
+		spin_unlock_irqrestore(&sport->port.lock, flags);
+
+		mod_timer(&sport->timer, jiffies + MCTRL_TIMEOUT);
+	}
+}
+
+/*
+ * interrupts disabled on entry
+ */
+static void imx_stop_tx(struct uart_port *port, unsigned int tty_stop)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+	UCR1((u32)sport->port.membase) &= ~UCR1_TXMPTYEN;
+}
+
+/*
+ * interrupts disabled on entry
+ */
+static void imx_stop_rx(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+	UCR2((u32)sport->port.membase) &= ~UCR2_RXEN;
+}
+
+/*
+ * Set the modem control timer to fire immediately.
+ */
+static void imx_enable_ms(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	mod_timer(&sport->timer, jiffies);
+}
+
+static inline void imx_transmit_buffer(struct imx_port *sport)
+{
+	struct circ_buf *xmit = &sport->port.info->xmit;
+
+	do {
+		/* send xmit->buf[xmit->tail]
+		 * out the port here */
+		URTX0((u32)sport->port.membase) = xmit->buf[xmit->tail];
+		xmit->tail = (xmit->tail + 1) &
+		         (UART_XMIT_SIZE - 1);
+		sport->port.icount.tx++;
+		if (uart_circ_empty(xmit))
+			break;
+	} while (!(UTS((u32)sport->port.membase) & UTS_TXFULL));
+
+	if (uart_circ_empty(xmit))
+		imx_stop_tx(&sport->port, 0);
+}
+
+/*
+ * interrupts disabled on entry
+ */
+static void imx_start_tx(struct uart_port *port, unsigned int tty_start)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	UCR1((u32)sport->port.membase) |= UCR1_TXMPTYEN;
+
+	if(UTS((u32)sport->port.membase) & UTS_TXEMPTY)
+		imx_transmit_buffer(sport);
+}
+
+static irqreturn_t imx_txint(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct imx_port *sport = (struct imx_port *)dev_id;
+	struct circ_buf *xmit = &sport->port.info->xmit;
+	unsigned long flags;
+
+	spin_lock_irqsave(&sport->port.lock,flags);
+	if (sport->port.x_char)
+	{
+		/* Send next char */
+		URTX0((u32)sport->port.membase) = sport->port.x_char;
+		goto out;
+	}
+
+	if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) {
+		imx_stop_tx(&sport->port, 0);
+		goto out;
+	}
+
+	imx_transmit_buffer(sport);
+
+	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+		uart_write_wakeup(&sport->port);
+
+out:
+	spin_unlock_irqrestore(&sport->port.lock,flags);
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t imx_rxint(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct imx_port *sport = dev_id;
+	unsigned int rx,flg,ignored = 0;
+	struct tty_struct *tty = sport->port.info->tty;
+	unsigned long flags;
+
+	rx = URXD0((u32)sport->port.membase);
+	spin_lock_irqsave(&sport->port.lock,flags);
+
+	do {
+		flg = TTY_NORMAL;
+		sport->port.icount.rx++;
+
+		if( USR2((u32)sport->port.membase) & USR2_BRCD ) {
+			USR2((u32)sport->port.membase) |= USR2_BRCD;
+			if(uart_handle_break(&sport->port))
+				goto ignore_char;
+		}
+
+		if (uart_handle_sysrq_char
+		            (&sport->port, (unsigned char)rx, regs))
+			goto ignore_char;
+
+		if( rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) )
+			goto handle_error;
+
+	error_return:
+		tty_insert_flip_char(tty, rx, flg);
+
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+			goto out;
+
+	ignore_char:
+		rx = URXD0((u32)sport->port.membase);
+	} while(rx & URXD_CHARRDY);
+
+out:
+	spin_unlock_irqrestore(&sport->port.lock,flags);
+	tty_flip_buffer_push(tty);
+	return IRQ_HANDLED;
+
+handle_error:
+	if (rx & URXD_PRERR)
+		sport->port.icount.parity++;
+	else if (rx & URXD_FRMERR)
+		sport->port.icount.frame++;
+	if (rx & URXD_OVRRUN)
+		sport->port.icount.overrun++;
+
+	if (rx & sport->port.ignore_status_mask) {
+		if (++ignored > 100)
+			goto out;
+		goto ignore_char;
+	}
+
+	rx &= sport->port.read_status_mask;
+
+	if (rx & URXD_PRERR)
+		flg = TTY_PARITY;
+	else if (rx & URXD_FRMERR)
+		flg = TTY_FRAME;
+	if (rx & URXD_OVRRUN)
+		flg = TTY_OVERRUN;
+
+#ifdef SUPPORT_SYSRQ
+	sport->port.sysrq = 0;
+#endif
+	goto error_return;
+}
+
+/*
+ * Return TIOCSER_TEMT when transmitter is not busy.
+ */
+static unsigned int imx_tx_empty(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	return USR2((u32)sport->port.membase) & USR2_TXDC ?  TIOCSER_TEMT : 0;
+}
+
+static unsigned int imx_get_mctrl(struct uart_port *port)
+{
+	return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+}
+
+static void imx_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+}
+
+/*
+ * Interrupts always disabled.
+ */
+static void imx_break_ctl(struct uart_port *port, int break_state)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+	unsigned long flags;
+
+	spin_lock_irqsave(&sport->port.lock, flags);
+
+	if ( break_state != 0 )
+		UCR1((u32)sport->port.membase) |= UCR1_SNDBRK;
+	else
+		UCR1((u32)sport->port.membase) &= ~UCR1_SNDBRK;
+
+	spin_unlock_irqrestore(&sport->port.lock, flags);
+}
+
+#define TXTL 2 /* reset default */
+#define RXTL 1 /* reset default */
+
+static int imx_startup(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+	int retval;
+	unsigned int val;
+	unsigned long flags;
+
+	/* set receiver / transmitter trigger level. We assume
+	 * that RFDIV has been set by the arch setup or by the bootloader.
+	 */
+	val = (UFCR((u32)sport->port.membase) & UFCR_RFDIV)  | TXTL<<10 | RXTL;
+	UFCR((u32)sport->port.membase) = val;
+
+	/* disable the DREN bit (Data Ready interrupt enable) before
+	 * requesting IRQs
+	 */
+	UCR4((u32)sport->port.membase) &= ~UCR4_DREN;
+
+	/*
+	 * Allocate the IRQ
+	 */
+	retval = request_irq(sport->rxirq, imx_rxint, 0,
+			     DRIVER_NAME, sport);
+	if (retval) goto error_out2;
+
+	retval = request_irq(sport->txirq, imx_txint, 0,
+			     "imx-uart", sport);
+	if (retval) goto error_out1;
+
+	/*
+	 * Finally, clear and enable interrupts
+	 */
+
+	UCR1((u32)sport->port.membase) |=
+	                 (UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_UARTEN);
+
+	UCR2((u32)sport->port.membase) |= (UCR2_RXEN | UCR2_TXEN);
+	/*
+	 * Enable modem status interrupts
+	 */
+	spin_lock_irqsave(&sport->port.lock,flags);
+	imx_enable_ms(&sport->port);
+	spin_unlock_irqrestore(&sport->port.lock,flags);
+
+	return 0;
+
+error_out1:
+	free_irq(sport->rxirq, sport);
+error_out2:
+	free_irq(sport->txirq, sport);
+	return retval;
+}
+
+static void imx_shutdown(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	/*
+	 * Stop our timer.
+	 */
+	del_timer_sync(&sport->timer);
+
+	/*
+	 * Free the interrupts
+	 */
+	free_irq(sport->txirq, sport);
+	free_irq(sport->rxirq, sport);
+
+	/*
+	 * Disable all interrupts, port and break condition.
+	 */
+
+	UCR1((u32)sport->port.membase) &=
+	                 ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_UARTEN);
+}
+
+static void
+imx_set_termios(struct uart_port *port, struct termios *termios,
+		   struct termios *old)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+	unsigned long flags;
+	unsigned int ucr2, old_ucr1, old_txrxen, baud, quot;
+	unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
+
+	/*
+	 * If we don't support modem control lines, don't allow
+	 * these to be set.
+	 */
+	if (0) {
+		termios->c_cflag &= ~(HUPCL | CRTSCTS | CMSPAR);
+		termios->c_cflag |= CLOCAL;
+	}
+
+	/*
+	 * We only support CS7 and CS8.
+	 */
+	while ((termios->c_cflag & CSIZE) != CS7 &&
+	       (termios->c_cflag & CSIZE) != CS8) {
+		termios->c_cflag &= ~CSIZE;
+		termios->c_cflag |= old_csize;
+		old_csize = CS8;
+	}
+
+	if ((termios->c_cflag & CSIZE) == CS8)
+		ucr2 = UCR2_WS | UCR2_SRST | UCR2_IRTS;
+	else
+		ucr2 = UCR2_SRST | UCR2_IRTS;
+
+	if (termios->c_cflag & CSTOPB)
+		ucr2 |= UCR2_STPB;
+	if (termios->c_cflag & PARENB) {
+		ucr2 |= UCR2_PREN;
+		if (!(termios->c_cflag & PARODD))
+			ucr2 |= UCR2_PROE;
+	}
+
+	/*
+	 * Ask the core to calculate the divisor for us.
+	 */
+	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
+	quot = uart_get_divisor(port, baud);
+
+	spin_lock_irqsave(&sport->port.lock, flags);
+
+	sport->port.read_status_mask = 0;
+	if (termios->c_iflag & INPCK)
+		sport->port.read_status_mask |= (URXD_FRMERR | URXD_PRERR);
+	if (termios->c_iflag & (BRKINT | PARMRK))
+		sport->port.read_status_mask |= URXD_BRK;
+
+	/*
+	 * Characters to ignore
+	 */
+	sport->port.ignore_status_mask = 0;
+	if (termios->c_iflag & IGNPAR)
+		sport->port.ignore_status_mask |= URXD_PRERR;
+	if (termios->c_iflag & IGNBRK) {
+		sport->port.ignore_status_mask |= URXD_BRK;
+		/*
+		 * If we're ignoring parity and break indicators,
+		 * ignore overruns too (for real raw support).
+		 */
+		if (termios->c_iflag & IGNPAR)
+			sport->port.ignore_status_mask |= URXD_OVRRUN;
+	}
+
+	del_timer_sync(&sport->timer);
+
+	/*
+	 * Update the per-port timeout.
+	 */
+	uart_update_timeout(port, termios->c_cflag, baud);
+
+	/*
+	 * disable interrupts and drain transmitter
+	 */
+	old_ucr1 = UCR1((u32)sport->port.membase);
+	UCR1((u32)sport->port.membase) &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN);
+
+	while ( !(USR2((u32)sport->port.membase) & USR2_TXDC))
+		barrier();
+
+	/* then, disable everything */
+	old_txrxen = UCR2((u32)sport->port.membase) & ( UCR2_TXEN | UCR2_RXEN );
+	UCR2((u32)sport->port.membase) &= ~( UCR2_TXEN | UCR2_RXEN);
+
+	/* set the parity, stop bits and data size */
+	UCR2((u32)sport->port.membase) = ucr2;
+
+	/* set the baud rate. We assume uartclk = 16 MHz
+	 *
+	 * baud * 16   UBIR - 1
+	 * --------- = --------
+	 *  uartclk    UBMR - 1
+	 */
+	UBIR((u32)sport->port.membase) = (baud / 100) - 1;
+	UBMR((u32)sport->port.membase) = 10000 - 1;
+
+	UCR1((u32)sport->port.membase) = old_ucr1;
+	UCR2((u32)sport->port.membase) |= old_txrxen;
+
+	if (UART_ENABLE_MS(&sport->port, termios->c_cflag))
+		imx_enable_ms(&sport->port);
+
+	spin_unlock_irqrestore(&sport->port.lock, flags);
+}
+
+static const char *imx_type(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	return sport->port.type == PORT_IMX ? "IMX" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'.
+ */
+static void imx_release_port(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	release_mem_region(sport->port.mapbase, UART_PORT_SIZE);
+}
+
+/*
+ * Request the memory region(s) being used by 'port'.
+ */
+static int imx_request_port(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	return request_mem_region(sport->port.mapbase, UART_PORT_SIZE,
+			"imx-uart") != NULL ? 0 : -EBUSY;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void imx_config_port(struct uart_port *port, int flags)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	if (flags & UART_CONFIG_TYPE &&
+	    imx_request_port(&sport->port) == 0)
+		sport->port.type = PORT_IMX;
+}
+
+/*
+ * Verify the new serial_struct (for TIOCSSERIAL).
+ * The only change we allow are to the flags and type, and
+ * even then only between PORT_IMX and PORT_UNKNOWN
+ */
+static int
+imx_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+	int ret = 0;
+
+	if (ser->type != PORT_UNKNOWN && ser->type != PORT_IMX)
+		ret = -EINVAL;
+	if (sport->port.irq != ser->irq)
+		ret = -EINVAL;
+	if (ser->io_type != UPIO_MEM)
+		ret = -EINVAL;
+	if (sport->port.uartclk / 16 != ser->baud_base)
+		ret = -EINVAL;
+	if ((void *)sport->port.mapbase != ser->iomem_base)
+		ret = -EINVAL;
+	if (sport->port.iobase != ser->port)
+		ret = -EINVAL;
+	if (ser->hub6 != 0)
+		ret = -EINVAL;
+	return ret;
+}
+
+static struct uart_ops imx_pops = {
+	.tx_empty	= imx_tx_empty,
+	.set_mctrl	= imx_set_mctrl,
+	.get_mctrl	= imx_get_mctrl,
+	.stop_tx	= imx_stop_tx,
+	.start_tx	= imx_start_tx,
+	.stop_rx	= imx_stop_rx,
+	.enable_ms	= imx_enable_ms,
+	.break_ctl	= imx_break_ctl,
+	.startup	= imx_startup,
+	.shutdown	= imx_shutdown,
+	.set_termios	= imx_set_termios,
+	.type		= imx_type,
+	.release_port	= imx_release_port,
+	.request_port	= imx_request_port,
+	.config_port	= imx_config_port,
+	.verify_port	= imx_verify_port,
+};
+
+static struct imx_port imx_ports[] = {
+	{
+	.txirq  = UART1_MINT_TX,
+	.rxirq  = UART1_MINT_RX,
+	.port	= {
+		.type		= PORT_IMX,
+		.iotype		= SERIAL_IO_MEM,
+		.membase	= (void *)IMX_UART1_BASE,
+		.mapbase	= IMX_UART1_BASE, /* FIXME */
+		.irq		= UART1_MINT_RX,
+		.uartclk	= 16000000,
+		.fifosize	= 8,
+		.flags		= ASYNC_BOOT_AUTOCONF,
+		.ops		= &imx_pops,
+		.line		= 0,
+	},
+	}, {
+	.txirq  = UART2_MINT_TX,
+	.rxirq  = UART2_MINT_RX,
+	.port	= {
+		.type		= PORT_IMX,
+		.iotype		= SERIAL_IO_MEM,
+		.membase	= (void *)IMX_UART2_BASE,
+		.mapbase	= IMX_UART2_BASE, /* FIXME */
+		.irq		= UART2_MINT_RX,
+		.uartclk	= 16000000,
+		.fifosize	= 8,
+		.flags		= ASYNC_BOOT_AUTOCONF,
+		.ops		= &imx_pops,
+		.line		= 1,
+	},
+	}
+};
+
+/*
+ * Setup the IMX serial ports.
+ * Note also that we support "console=ttySMXx" where "x" is either 0 or 1.
+ * Which serial port this ends up being depends on the machine you're
+ * running this kernel on.  I'm not convinced that this is a good idea,
+ * but that's the way it traditionally works.
+ *
+ */
+static void __init imx_init_ports(void)
+{
+	static int first = 1;
+	int i;
+
+	if (!first)
+		return;
+	first = 0;
+
+	for (i = 0; i < ARRAY_SIZE(imx_ports); i++) {
+		init_timer(&imx_ports[i].timer);
+		imx_ports[i].timer.function = imx_timeout;
+		imx_ports[i].timer.data     = (unsigned long)&imx_ports[i];
+	}
+
+	imx_gpio_mode(PC9_PF_UART1_CTS);
+	imx_gpio_mode(PC10_PF_UART1_RTS);
+	imx_gpio_mode(PC11_PF_UART1_TXD);
+	imx_gpio_mode(PC12_PF_UART1_RXD);
+	imx_gpio_mode(PB28_PF_UART2_CTS);
+	imx_gpio_mode(PB29_PF_UART2_RTS);
+
+	imx_gpio_mode(PB30_PF_UART2_TXD);
+	imx_gpio_mode(PB31_PF_UART2_RXD);
+
+#if 0 /* We don't need these, on the mx1 the _modem_ side of the uart
+       * is implemented.
+       */
+	imx_gpio_mode(PD7_AF_UART2_DTR);
+	imx_gpio_mode(PD8_AF_UART2_DCD);
+	imx_gpio_mode(PD9_AF_UART2_RI);
+	imx_gpio_mode(PD10_AF_UART2_DSR);
+#endif
+
+
+}
+
+#ifdef CONFIG_SERIAL_IMX_CONSOLE
+
+/*
+ * Interrupts are disabled on entering
+ */
+static void
+imx_console_write(struct console *co, const char *s, unsigned int count)
+{
+	struct imx_port *sport = &imx_ports[co->index];
+	unsigned int old_ucr1, old_ucr2, i;
+
+	/*
+	 *	First, save UCR1/2 and then disable interrupts
+	 */
+	old_ucr1 = UCR1((u32)sport->port.membase);
+	old_ucr2 = UCR2((u32)sport->port.membase);
+
+	UCR1((u32)sport->port.membase) =
+	                   (old_ucr1 | UCR1_UARTCLKEN | UCR1_UARTEN)
+	                   & ~(UCR1_TXMPTYEN | UCR1_RRDYEN);
+	UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN;
+
+	/*
+	 *	Now, do each character
+	 */
+	for (i = 0; i < count; i++) {
+
+		while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
+			barrier();
+
+		URTX0((u32)sport->port.membase) = s[i];
+
+		if (s[i] == '\n') {
+			while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
+				barrier();
+			URTX0((u32)sport->port.membase) = '\r';
+		}
+	}
+
+	/*
+	 *	Finally, wait for transmitter to become empty
+	 *	and restore UCR1/2
+	 */
+	while (!(USR2((u32)sport->port.membase) & USR2_TXDC));
+
+	UCR1((u32)sport->port.membase) = old_ucr1;
+	UCR2((u32)sport->port.membase) = old_ucr2;
+}
+
+/*
+ * If the port was already initialised (eg, by a boot loader),
+ * try to determine the current setup.
+ */
+static void __init
+imx_console_get_options(struct imx_port *sport, int *baud,
+			   int *parity, int *bits)
+{
+	if ( UCR1((u32)sport->port.membase) | UCR1_UARTEN ) {
+		/* ok, the port was enabled */
+		unsigned int ucr2, ubir,ubmr, uartclk;
+
+		ucr2 = UCR2((u32)sport->port.membase);
+
+		*parity = 'n';
+		if (ucr2 & UCR2_PREN) {
+			if (ucr2 & UCR2_PROE)
+				*parity = 'o';
+			else
+				*parity = 'e';
+		}
+
+		if (ucr2 & UCR2_WS)
+			*bits = 8;
+		else
+			*bits = 7;
+
+		ubir = UBIR((u32)sport->port.membase) & 0xffff;
+		ubmr = UBMR((u32)sport->port.membase) & 0xffff;
+		uartclk = sport->port.uartclk;
+
+		*baud = ((uartclk/16) * (ubir + 1)) / (ubmr + 1);
+	}
+}
+
+static int __init
+imx_console_setup(struct console *co, char *options)
+{
+	struct imx_port *sport;
+	int baud = 9600;
+	int bits = 8;
+	int parity = 'n';
+	int flow = 'n';
+
+	/*
+	 * Check whether an invalid uart number has been specified, and
+	 * if so, search for the first available port that does have
+	 * console support.
+	 */
+	if (co->index == -1 || co->index >= ARRAY_SIZE(imx_ports))
+		co->index = 0;
+	sport = &imx_ports[co->index];
+
+	if (options)
+		uart_parse_options(options, &baud, &parity, &bits, &flow);
+	else
+		imx_console_get_options(sport, &baud, &parity, &bits);
+
+	return uart_set_options(&sport->port, co, baud, parity, bits, flow);
+}
+
+extern struct uart_driver imx_reg;
+static struct console imx_console = {
+	.name		= "ttySMX",
+	.write		= imx_console_write,
+	.device		= uart_console_device,
+	.setup		= imx_console_setup,
+	.flags		= CON_PRINTBUFFER,
+	.index		= -1,
+	.data		= &imx_reg,
+};
+
+static int __init imx_rs_console_init(void)
+{
+	imx_init_ports();
+	register_console(&imx_console);
+	return 0;
+}
+console_initcall(imx_rs_console_init);
+
+#define IMX_CONSOLE	&imx_console
+#else
+#define IMX_CONSOLE	NULL
+#endif
+
+static struct uart_driver imx_reg = {
+	.owner          = THIS_MODULE,
+	.driver_name    = DRIVER_NAME,
+	.dev_name       = "ttySMX",
+	.devfs_name	= "ttsmx/",
+	.major          = SERIAL_IMX_MAJOR,
+	.minor          = MINOR_START,
+	.nr             = ARRAY_SIZE(imx_ports),
+	.cons           = IMX_CONSOLE,
+};
+
+static int serial_imx_suspend(struct device *_dev, u32 state, u32 level)
+{
+        struct imx_port *sport = dev_get_drvdata(_dev);
+
+        if (sport && level == SUSPEND_DISABLE)
+                uart_suspend_port(&imx_reg, &sport->port);
+
+        return 0;
+}
+
+static int serial_imx_resume(struct device *_dev, u32 level)
+{
+        struct imx_port *sport = dev_get_drvdata(_dev);
+
+        if (sport && level == RESUME_ENABLE)
+                uart_resume_port(&imx_reg, &sport->port);
+
+        return 0;
+}
+
+static int serial_imx_probe(struct device *_dev)
+{
+	struct platform_device *dev = to_platform_device(_dev);
+
+	imx_ports[dev->id].port.dev = _dev;
+	uart_add_one_port(&imx_reg, &imx_ports[dev->id].port);
+	dev_set_drvdata(_dev, &imx_ports[dev->id]);
+	return 0;
+}
+
+static int serial_imx_remove(struct device *_dev)
+{
+	struct imx_port *sport = dev_get_drvdata(_dev);
+
+	dev_set_drvdata(_dev, NULL);
+
+	if (sport)
+		uart_remove_one_port(&imx_reg, &sport->port);
+
+	return 0;
+}
+
+static struct device_driver serial_imx_driver = {
+        .name           = "imx-uart",
+        .bus            = &platform_bus_type,
+        .probe          = serial_imx_probe,
+        .remove         = serial_imx_remove,
+
+	.suspend	= serial_imx_suspend,
+	.resume		= serial_imx_resume,
+};
+
+static int __init imx_serial_init(void)
+{
+	int ret;
+
+	printk(KERN_INFO "Serial: IMX driver\n");
+
+	imx_init_ports();
+
+	ret = uart_register_driver(&imx_reg);
+	if (ret)
+		return ret;
+
+	ret = driver_register(&serial_imx_driver);
+	if (ret != 0)
+		uart_unregister_driver(&imx_reg);
+
+	return 0;
+}
+
+static void __exit imx_serial_exit(void)
+{
+	uart_unregister_driver(&imx_reg);
+}
+
+module_init(imx_serial_init);
+module_exit(imx_serial_exit);
+
+MODULE_AUTHOR("Sascha Hauer");
+MODULE_DESCRIPTION("IMX generic serial port driver");
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/serial/m32r_sio.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1373 @@
+/*
+ *  m32r_sio.c
+ *
+ *  Driver for M32R serial ports
+ *
+ *  Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *  Based on drivers/serial/8250.c.
+ *
+ *  Copyright (C) 2001  Russell King.
+ *  Copyright (C) 2004  Hirokazu Takata <takata at linux-m32r.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.
+ */
+
+/*
+ * A note about mapbase / membase
+ *
+ *  mapbase is the physical address of the IO port.  Currently, we don't
+ *  support this very well, and it may well be dropped from this driver
+ *  in future.  As such, mapbase should be NULL.
+ *
+ *  membase is an 'ioremapped' cookie.  This is compatible with the old
+ *  serial.c driver, and is currently the preferred form.
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/tty.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+#include <linux/serial.h>
+#include <linux/serialP.h>
+#include <linux/delay.h>
+
+#include <asm/m32r.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+
+#if defined(CONFIG_SERIAL_M32R_SIO_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#define PORT_SIO	1
+#define PORT_MAX_SIO	1
+#define BAUD_RATE	115200
+
+#include <linux/serial_core.h>
+#include "m32r_sio.h"
+#include "m32r_sio_reg.h"
+
+/*
+ * Configuration:
+ *   share_irqs - whether we pass SA_SHIRQ to request_irq().  This option
+ *                is unsafe when used on edge-triggered interrupts.
+ */
+unsigned int share_irqs_sio = M32R_SIO_SHARE_IRQS;
+
+/*
+ * Debugging.
+ */
+#if 0
+#define DEBUG_AUTOCONF(fmt...)	printk(fmt)
+#else
+#define DEBUG_AUTOCONF(fmt...)	do { } while (0)
+#endif
+
+#if 0
+#define DEBUG_INTR(fmt...)	printk(fmt)
+#else
+#define DEBUG_INTR(fmt...)	do { } while (0)
+#endif
+
+#define PASS_LIMIT	256
+
+/*
+ * We default to IRQ0 for the "no irq" hack.   Some
+ * machine types want others as well - they're free
+ * to redefine this in their header file.
+ */
+#define is_real_interrupt(irq)	((irq) != 0)
+
+/*
+ * This converts from our new CONFIG_ symbols to the symbols
+ * that asm/serial.h expects.  You _NEED_ to comment out the
+ * linux/config.h include contained inside asm/serial.h for
+ * this to work.
+ */
+#undef CONFIG_SERIAL_MANY_PORTS
+#undef CONFIG_SERIAL_DETECT_IRQ
+#undef CONFIG_SERIAL_MULTIPORT
+#undef CONFIG_HUB6
+
+#ifdef CONFIG_SERIAL_M32R_SIO_DETECT_IRQ
+#define CONFIG_SERIAL_DETECT_IRQ 1
+#endif
+#ifdef CONFIG_SERIAL_M32R_SIO_MULTIPORT
+#define CONFIG_SERIAL_MULTIPORT 1
+#endif
+#ifdef CONFIG_SERIAL_M32R_SIO_MANY_PORTS
+#define CONFIG_SERIAL_MANY_PORTS 1
+#endif
+
+/*
+ * HUB6 is always on.  This will be removed once the header
+ * files have been cleaned.
+ */
+#define CONFIG_HUB6 1
+
+#include <asm/serial.h>
+
+#ifdef CONFIG_SERIAL_M32R_PLDSIO
+static struct old_serial_port old_serial_port[] = {
+	{ 0, BASE_BAUD, ((unsigned long)PLD_ESIO0CR), PLD_IRQ_SIO0_RCV, STD_COM_FLAGS },
+};
+#else
+static struct old_serial_port old_serial_port[] = {
+	{ 0, BASE_BAUD, M32R_SIO_OFFSET, M32R_IRQ_SIO0_R, STD_COM_FLAGS },
+};
+#endif
+
+#define UART_NR	ARRAY_SIZE(old_serial_port)
+
+struct uart_sio_port {
+	struct uart_port	port;
+	struct timer_list	timer;		/* "no irq" timer */
+	struct list_head	list;		/* ports on this IRQ */
+	unsigned short		rev;
+	unsigned char		acr;
+	unsigned char		ier;
+	unsigned char		lcr;
+	unsigned char		mcr_mask;	/* mask of user bits */
+	unsigned char		mcr_force;	/* mask of forced bits */
+	unsigned char		lsr_break_flag;
+
+	/*
+	 * We provide a per-port pm hook.
+	 */
+	void			(*pm)(struct uart_port *port,
+				      unsigned int state, unsigned int old);
+};
+
+struct irq_info {
+	spinlock_t		lock;
+	struct list_head	*head;
+};
+
+static struct irq_info irq_lists[NR_IRQS];
+
+/*
+ * Here we define the default xmit fifo size used for each type of UART.
+ */
+static const struct serial_uart_config uart_config[PORT_MAX_SIO+1] = {
+	{ "unknown",	1,	0 },
+	{ "M32RSIO",	1,	0 }
+};
+
+#ifdef CONFIG_SERIAL_M32R_PLDSIO
+
+#define __sio_in(x) inw((unsigned long)(x))
+#define __sio_out(v,x) outw((v),(unsigned long)(x))
+
+static inline void sio_set_baud_rate(unsigned long baud)
+{
+	unsigned short sbaud;
+	sbaud = (boot_cpu_data.bus_clock / (baud * 4))-1;
+	__sio_out(sbaud, PLD_ESIO0BAUR);
+}
+
+static void sio_reset(void)
+{
+	unsigned short tmp;
+
+	tmp = __sio_in(PLD_ESIO0RXB);
+	tmp = __sio_in(PLD_ESIO0RXB);
+	tmp = __sio_in(PLD_ESIO0CR);
+	sio_set_baud_rate(BAUD_RATE);
+	__sio_out(0x0300, PLD_ESIO0CR);
+	__sio_out(0x0003, PLD_ESIO0CR);
+}
+
+static void sio_init(void)
+{
+	unsigned short tmp;
+
+	tmp = __sio_in(PLD_ESIO0RXB);
+	tmp = __sio_in(PLD_ESIO0RXB);
+	tmp = __sio_in(PLD_ESIO0CR);
+	__sio_out(0x0300, PLD_ESIO0CR);
+	__sio_out(0x0003, PLD_ESIO0CR);
+}
+
+static void sio_error(int *status)
+{
+	printk("SIO0 error[%04x]\n", *status);
+	do {
+		sio_init();
+	} while ((*status = __sio_in(PLD_ESIO0CR)) != 3);
+}
+
+#else /* not CONFIG_SERIAL_M32R_PLDSIO */
+
+#define __sio_in(x) inl(x)
+#define __sio_out(v,x) outl((v),(x))
+
+static inline void sio_set_baud_rate(unsigned long baud)
+{
+	unsigned long i, j;
+
+	i = boot_cpu_data.bus_clock / (baud * 16);
+	j = (boot_cpu_data.bus_clock - (i * baud * 16)) / baud;
+	i -= 1;
+	j = (j + 1) >> 1;
+
+	__sio_out(i, M32R_SIO0_BAUR_PORTL);
+	__sio_out(j, M32R_SIO0_RBAUR_PORTL);
+}
+
+static void sio_reset(void)
+{
+	__sio_out(0x00000300, M32R_SIO0_CR_PORTL);	/* init status */
+	__sio_out(0x00000800, M32R_SIO0_MOD1_PORTL);	/* 8bit        */
+	__sio_out(0x00000080, M32R_SIO0_MOD0_PORTL);	/* 1stop non   */
+	sio_set_baud_rate(BAUD_RATE);
+	__sio_out(0x00000000, M32R_SIO0_TRCR_PORTL);
+	__sio_out(0x00000003, M32R_SIO0_CR_PORTL);	/* RXCEN */
+}
+
+static void sio_init(void)
+{
+	unsigned int tmp;
+
+	tmp = __sio_in(M32R_SIO0_RXB_PORTL);
+	tmp = __sio_in(M32R_SIO0_RXB_PORTL);
+	tmp = __sio_in(M32R_SIO0_STS_PORTL);
+	__sio_out(0x00000003, M32R_SIO0_CR_PORTL);
+}
+
+static void sio_error(int *status)
+{
+	printk("SIO0 error[%04x]\n", *status);
+	do {
+		sio_init();
+	} while ((*status = __sio_in(M32R_SIO0_CR_PORTL)) != 3);
+}
+
+#endif /* CONFIG_SERIAL_M32R_PLDSIO */
+
+static _INLINE_ unsigned int sio_in(struct uart_sio_port *up, int offset)
+{
+	return __sio_in(up->port.iobase + offset);
+}
+
+static _INLINE_ void sio_out(struct uart_sio_port *up, int offset, int value)
+{
+	__sio_out(value, up->port.iobase + offset);
+}
+
+static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset)
+{
+	if (!offset)
+		return 0;
+
+	return __sio_in(offset);
+}
+
+static _INLINE_ void
+serial_out(struct uart_sio_port *up, int offset, int value)
+{
+	if (!offset)
+		return;
+
+	__sio_out(value, offset);
+}
+
+static void m32r_sio_stop_tx(struct uart_port *port, unsigned int tty_stop)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+	if (up->ier & UART_IER_THRI) {
+		up->ier &= ~UART_IER_THRI;
+		serial_out(up, UART_IER, up->ier);
+	}
+}
+
+static void m32r_sio_start_tx(struct uart_port *port, unsigned int tty_start)
+{
+#ifdef CONFIG_SERIAL_M32R_PLDSIO
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+	struct circ_buf *xmit = &up->port.info->xmit;
+
+	if (!(up->ier & UART_IER_THRI)) {
+		up->ier |= UART_IER_THRI;
+		serial_out(up, UART_IER, up->ier);
+		serial_out(up, UART_TX, xmit->buf[xmit->tail]);
+		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+		up->port.icount.tx++;
+	}
+	while((serial_in(up, UART_LSR) & UART_EMPTY) != UART_EMPTY);
+#else
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+	if (!(up->ier & UART_IER_THRI)) {
+		up->ier |= UART_IER_THRI;
+		serial_out(up, UART_IER, up->ier);
+	}
+#endif
+}
+
+static void m32r_sio_stop_rx(struct uart_port *port)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+	up->ier &= ~UART_IER_RLSI;
+	up->port.read_status_mask &= ~UART_LSR_DR;
+	serial_out(up, UART_IER, up->ier);
+}
+
+static void m32r_sio_enable_ms(struct uart_port *port)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+	up->ier |= UART_IER_MSI;
+	serial_out(up, UART_IER, up->ier);
+}
+
+static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status,
+	struct pt_regs *regs)
+{
+	struct tty_struct *tty = up->port.info->tty;
+	unsigned char ch;
+	int max_count = 256;
+
+	do {
+		if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
+			tty->flip.work.func((void *)tty);
+			if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+				return; // if TTY_DONT_FLIP is set
+		}
+		ch = sio_in(up, SIORXB);
+		*tty->flip.char_buf_ptr = ch;
+		*tty->flip.flag_buf_ptr = TTY_NORMAL;
+		up->port.icount.rx++;
+
+		if (unlikely(*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);
+				up->port.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 (uart_handle_break(&up->port))
+					goto ignore_char;
+			} else if (*status & UART_LSR_PE)
+				up->port.icount.parity++;
+			else if (*status & UART_LSR_FE)
+				up->port.icount.frame++;
+			if (*status & UART_LSR_OE)
+				up->port.icount.overrun++;
+
+			/*
+			 * Mask off conditions which should be ingored.
+			 */
+			*status &= up->port.read_status_mask;
+
+			if (up->port.line == up->port.cons->index) {
+				/* Recover the break flag from console xmit */
+				*status |= up->lsr_break_flag;
+				up->lsr_break_flag = 0;
+			}
+
+			if (*status & UART_LSR_BI) {
+				DEBUG_INTR("handling break....");
+				*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 (uart_handle_sysrq_char(&up->port, ch, regs))
+			goto ignore_char;
+		if ((*status & up->port.ignore_status_mask) == 0) {
+			tty->flip.flag_buf_ptr++;
+			tty->flip.char_buf_ptr++;
+			tty->flip.count++;
+		}
+		if ((*status & UART_LSR_OE) &&
+		    tty->flip.count < TTY_FLIPBUF_SIZE) {
+			/*
+			 * Overrun is special, since it's reported
+			 * immediately, and doesn't affect the current
+			 * character.
+			 */
+			*tty->flip.flag_buf_ptr = TTY_OVERRUN;
+			tty->flip.flag_buf_ptr++;
+			tty->flip.char_buf_ptr++;
+			tty->flip.count++;
+		}
+	ignore_char:
+		*status = serial_in(up, UART_LSR);
+	} while ((*status & UART_LSR_DR) && (max_count-- > 0));
+	tty_flip_buffer_push(tty);
+}
+
+static _INLINE_ void transmit_chars(struct uart_sio_port *up)
+{
+	struct circ_buf *xmit = &up->port.info->xmit;
+	int count;
+
+	if (up->port.x_char) {
+#ifndef CONFIG_SERIAL_M32R_PLDSIO	/* XXX */
+		serial_out(up, UART_TX, up->port.x_char);
+#endif
+		up->port.icount.tx++;
+		up->port.x_char = 0;
+		return;
+	}
+	if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
+		m32r_sio_stop_tx(&up->port, 0);
+		return;
+	}
+
+	count = up->port.fifosize;
+	do {
+		serial_out(up, UART_TX, xmit->buf[xmit->tail]);
+		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+		up->port.icount.tx++;
+		if (uart_circ_empty(xmit))
+			break;
+		while (!serial_in(up, UART_LSR) & UART_LSR_THRE);
+
+	} while (--count > 0);
+
+	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+		uart_write_wakeup(&up->port);
+
+	DEBUG_INTR("THRE...");
+
+	if (uart_circ_empty(xmit))
+		m32r_sio_stop_tx(&up->port, 0);
+}
+
+/*
+ * This handles the interrupt from one port.
+ */
+static inline void m32r_sio_handle_port(struct uart_sio_port *up,
+	unsigned int status, struct pt_regs *regs)
+{
+	DEBUG_INTR("status = %x...", status);
+
+	if (status & 0x04)
+		receive_chars(up, &status, regs);
+	// check_modem_status(up);
+	if (status & 0x01)
+		transmit_chars(up);
+}
+
+/*
+ * This is the serial driver's interrupt routine.
+ *
+ * Arjan thinks the old way was overly complex, so it got simplified.
+ * Alan disagrees, saying that need the complexity to handle the weird
+ * nature of ISA shared interrupts.  (This is a special exception.)
+ *
+ * In order to handle ISA shared interrupts properly, we need to check
+ * that all ports have been serviced, and therefore the ISA interrupt
+ * line has been de-asserted.
+ *
+ * This means we need to loop through all ports. checking that they
+ * don't have an interrupt pending.
+ */
+static irqreturn_t m32r_sio_interrupt(int irq, void *dev_id,
+	struct pt_regs *regs)
+{
+	struct irq_info *i = dev_id;
+	struct list_head *l, *end = NULL;
+	int pass_counter = 0;
+
+	DEBUG_INTR("m32r_sio_interrupt(%d)...", irq);
+
+#ifdef CONFIG_SERIAL_M32R_PLDSIO
+//	if (irq == PLD_IRQ_SIO0_SND)
+//		irq = PLD_IRQ_SIO0_RCV;
+#else
+	if (irq == M32R_IRQ_SIO0_S)
+		irq = M32R_IRQ_SIO0_R;
+#endif
+
+	spin_lock(&i->lock);
+
+	l = i->head;
+	do {
+		struct uart_sio_port *up;
+		unsigned int sts;
+
+		up = list_entry(l, struct uart_sio_port, list);
+
+		sts = sio_in(up, SIOSTS);
+		if (sts & 0x5) {
+			spin_lock(&up->port.lock);
+			m32r_sio_handle_port(up, sts, regs);
+			spin_unlock(&up->port.lock);
+
+			end = NULL;
+		} else if (end == NULL)
+			end = l;
+
+		l = l->next;
+
+		if (l == i->head && pass_counter++ > PASS_LIMIT) {
+			if (sts & 0xe0)
+				sio_error(&sts);
+			break;
+		}
+	} while (l != end);
+
+	spin_unlock(&i->lock);
+
+	DEBUG_INTR("end.\n");
+
+	return IRQ_HANDLED;
+}
+
+/*
+ * To support ISA shared interrupts, we need to have one interrupt
+ * handler that ensures that the IRQ line has been deasserted
+ * before returning.  Failing to do this will result in the IRQ
+ * line being stuck active, and, since ISA irqs are edge triggered,
+ * no more IRQs will be seen.
+ */
+static void serial_do_unlink(struct irq_info *i, struct uart_sio_port *up)
+{
+	spin_lock_irq(&i->lock);
+
+	if (!list_empty(i->head)) {
+		if (i->head == &up->list)
+			i->head = i->head->next;
+		list_del(&up->list);
+	} else {
+		BUG_ON(i->head != &up->list);
+		i->head = NULL;
+	}
+
+	spin_unlock_irq(&i->lock);
+}
+
+static int serial_link_irq_chain(struct uart_sio_port *up)
+{
+	struct irq_info *i = irq_lists + up->port.irq;
+	int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? SA_SHIRQ : 0;
+
+	spin_lock_irq(&i->lock);
+
+	if (i->head) {
+		list_add(&up->list, i->head);
+		spin_unlock_irq(&i->lock);
+
+		ret = 0;
+	} else {
+		INIT_LIST_HEAD(&up->list);
+		i->head = &up->list;
+		spin_unlock_irq(&i->lock);
+
+		ret = request_irq(up->port.irq, m32r_sio_interrupt,
+				  irq_flags, "SIO0-RX", i);
+		ret |= request_irq(up->port.irq + 1, m32r_sio_interrupt,
+				  irq_flags, "SIO0-TX", i);
+		if (ret < 0)
+			serial_do_unlink(i, up);
+	}
+
+	return ret;
+}
+
+static void serial_unlink_irq_chain(struct uart_sio_port *up)
+{
+	struct irq_info *i = irq_lists + up->port.irq;
+
+	BUG_ON(i->head == NULL);
+
+	if (list_empty(i->head)) {
+		free_irq(up->port.irq, i);
+		free_irq(up->port.irq + 1, i);
+	}
+
+	serial_do_unlink(i, up);
+}
+
+/*
+ * This function is used to handle ports that do not have an
+ * interrupt.  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 m32r_sio_timeout(unsigned long data)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)data;
+	unsigned int timeout;
+	unsigned int sts;
+
+	sts = sio_in(up, SIOSTS);
+	if (sts & 0x5) {
+		spin_lock(&up->port.lock);
+		m32r_sio_handle_port(up, sts, NULL);
+		spin_unlock(&up->port.lock);
+	}
+
+	timeout = up->port.timeout;
+	timeout = timeout > 6 ? (timeout / 2 - 2) : 1;
+	mod_timer(&up->timer, jiffies + timeout);
+}
+
+static unsigned int m32r_sio_tx_empty(struct uart_port *port)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+	unsigned long flags;
+	unsigned int ret;
+
+	spin_lock_irqsave(&up->port.lock, flags);
+	ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0;
+	spin_unlock_irqrestore(&up->port.lock, flags);
+
+	return ret;
+}
+
+static unsigned int m32r_sio_get_mctrl(struct uart_port *port)
+{
+	return 0;
+}
+
+static void m32r_sio_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+
+}
+
+static void m32r_sio_break_ctl(struct uart_port *port, int break_state)
+{
+
+}
+
+static int m32r_sio_startup(struct uart_port *port)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+	int retval;
+
+	sio_init();
+
+	/*
+	 * If the "interrupt" for this port doesn't correspond with any
+	 * hardware interrupt, we use a timer-based system.  The original
+	 * driver used to do this with IRQ0.
+	 */
+	if (!is_real_interrupt(up->port.irq)) {
+		unsigned int timeout = up->port.timeout;
+
+		timeout = timeout > 6 ? (timeout / 2 - 2) : 1;
+
+		up->timer.data = (unsigned long)up;
+		mod_timer(&up->timer, jiffies + timeout);
+	} else {
+		retval = serial_link_irq_chain(up);
+		if (retval)
+			return retval;
+	}
+
+	/*
+	 * Finally, enable interrupts.  Note: Modem status interrupts
+	 * are set via set_termios(), which will be occurring imminently
+	 * anyway, so we don't enable them here.
+	 * - M32R_SIO: 0x0c
+	 * - M32R_PLDSIO: 0x04
+	 */
+	up->ier = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI;
+	sio_out(up, SIOTRCR, up->ier);
+
+	/*
+	 * And clear the interrupt registers again for luck.
+	 */
+	sio_reset();
+
+	return 0;
+}
+
+static void m32r_sio_shutdown(struct uart_port *port)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+	/*
+	 * Disable interrupts from this port
+	 */
+	up->ier = 0;
+	sio_out(up, SIOTRCR, 0);
+
+	/*
+	 * Disable break condition and FIFOs
+	 */
+
+	sio_init();
+
+	if (!is_real_interrupt(up->port.irq))
+		del_timer_sync(&up->timer);
+	else
+		serial_unlink_irq_chain(up);
+}
+
+static unsigned int m32r_sio_get_divisor(struct uart_port *port,
+	unsigned int baud)
+{
+	return uart_get_divisor(port, baud);
+}
+
+static void m32r_sio_set_termios(struct uart_port *port,
+	struct termios *termios, struct termios *old)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+	unsigned char cval = 0;
+	unsigned long flags;
+	unsigned int baud, quot;
+
+	switch (termios->c_cflag & CSIZE) {
+	case CS5:
+		cval = 0x00;
+		break;
+	case CS6:
+		cval = 0x01;
+		break;
+	case CS7:
+		cval = 0x02;
+		break;
+	default:
+	case CS8:
+		cval = 0x03;
+		break;
+	}
+
+	if (termios->c_cflag & CSTOPB)
+		cval |= 0x04;
+	if (termios->c_cflag & PARENB)
+		cval |= UART_LCR_PARITY;
+	if (!(termios->c_cflag & PARODD))
+		cval |= UART_LCR_EPAR;
+#ifdef CMSPAR
+	if (termios->c_cflag & CMSPAR)
+		cval |= UART_LCR_SPAR;
+#endif
+
+	/*
+	 * Ask the core to calculate the divisor for us.
+	 */
+#ifdef CONFIG_SERIAL_M32R_PLDSIO
+	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/4);
+#else
+	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
+#endif
+	quot = m32r_sio_get_divisor(port, baud);
+
+	/*
+	 * Ok, we're now changing the port state.  Do it with
+	 * interrupts disabled.
+	 */
+	spin_lock_irqsave(&up->port.lock, flags);
+
+	sio_set_baud_rate(baud);
+
+	/*
+	 * Update the per-port timeout.
+	 */
+	uart_update_timeout(port, termios->c_cflag, baud);
+
+	up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
+	if (termios->c_iflag & INPCK)
+		up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
+	if (termios->c_iflag & (BRKINT | PARMRK))
+		up->port.read_status_mask |= UART_LSR_BI;
+
+	/*
+	 * Characteres to ignore
+	 */
+	up->port.ignore_status_mask = 0;
+	if (termios->c_iflag & IGNPAR)
+		up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
+	if (termios->c_iflag & IGNBRK) {
+		up->port.ignore_status_mask |= UART_LSR_BI;
+		/*
+		 * If we're ignoring parity and break indicators,
+		 * ignore overruns too (for real raw support).
+		 */
+		if (termios->c_iflag & IGNPAR)
+			up->port.ignore_status_mask |= UART_LSR_OE;
+	}
+
+	/*
+	 * ignore all characters if CREAD is not set
+	 */
+	if ((termios->c_cflag & CREAD) == 0)
+		up->port.ignore_status_mask |= UART_LSR_DR;
+
+	/*
+	 * CTS flow control flag and modem status interrupts
+	 */
+	up->ier &= ~UART_IER_MSI;
+	if (UART_ENABLE_MS(&up->port, termios->c_cflag))
+		up->ier |= UART_IER_MSI;
+
+	serial_out(up, UART_IER, up->ier);
+
+	up->lcr = cval;					/* Save LCR */
+	spin_unlock_irqrestore(&up->port.lock, flags);
+}
+
+static void m32r_sio_pm(struct uart_port *port, unsigned int state,
+	unsigned int oldstate)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+	if (up->pm)
+		up->pm(port, state, oldstate);
+}
+
+/*
+ * Resource handling.  This is complicated by the fact that resources
+ * depend on the port type.  Maybe we should be claiming the standard
+ * 8250 ports, and then trying to get other resources as necessary?
+ */
+static int
+m32r_sio_request_std_resource(struct uart_sio_port *up, struct resource **res)
+{
+	unsigned int size = 8 << up->port.regshift;
+#ifndef CONFIG_SERIAL_M32R_PLDSIO
+	unsigned long start;
+#endif
+	int ret = 0;
+
+	switch (up->port.iotype) {
+	case SERIAL_IO_MEM:
+		if (up->port.mapbase) {
+#ifdef CONFIG_SERIAL_M32R_PLDSIO
+			*res = request_mem_region(up->port.mapbase, size, "serial");
+#else
+			start = up->port.mapbase;
+			start += UART_RSA_BASE << up->port.regshift;
+			*res = request_mem_region(start, size, "serial");
+#endif
+			if (!*res)
+				ret = -EBUSY;
+		}
+		break;
+
+	case SERIAL_IO_HUB6:
+	case SERIAL_IO_PORT:
+		*res = request_region(up->port.iobase, size, "serial");
+		if (!*res)
+			ret = -EBUSY;
+		break;
+	}
+	return ret;
+}
+
+static int
+m32r_sio_request_rsa_resource(struct uart_sio_port *up, struct resource **res)
+{
+	unsigned int size = 8 << up->port.regshift;
+	unsigned long start;
+	int ret = 0;
+
+	switch (up->port.iotype) {
+	case SERIAL_IO_MEM:
+		if (up->port.mapbase) {
+			start = up->port.mapbase;
+			start += UART_RSA_BASE << up->port.regshift;
+#ifdef CONFIG_SERIAL_M32R_PLDSIO
+			*res = request_mem_region(start, size, "serial-rsa");
+#else
+			*res = request_mem_region(up->port.mapbase, size, "serial-rsa");
+#endif
+			if (!*res)
+				ret = -EBUSY;
+		}
+		break;
+
+	case SERIAL_IO_HUB6:
+	case SERIAL_IO_PORT:
+		start = up->port.iobase;
+		start += UART_RSA_BASE << up->port.regshift;
+		*res = request_region(up->port.iobase, size, "serial-rsa");
+		if (!*res)
+			ret = -EBUSY;
+		break;
+	}
+
+	return ret;
+}
+
+static void m32r_sio_release_port(struct uart_port *port)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+	unsigned long start, offset = 0, size = 0;
+
+	if (up->port.type == PORT_RSA) {
+		offset = UART_RSA_BASE << up->port.regshift;
+		size = 8;
+	}
+
+	size <<= up->port.regshift;
+
+	switch (up->port.iotype) {
+	case SERIAL_IO_MEM:
+		if (up->port.mapbase) {
+			/*
+			 * Unmap the area.
+			 */
+			iounmap(up->port.membase);
+			up->port.membase = NULL;
+
+			start = up->port.mapbase;
+
+			if (size)
+				release_mem_region(start + offset, size);
+			release_mem_region(start, 8 << up->port.regshift);
+		}
+		break;
+
+	case SERIAL_IO_HUB6:
+	case SERIAL_IO_PORT:
+		start = up->port.iobase;
+
+		if (size)
+			release_region(start + offset, size);
+		release_region(start + offset, 8 << up->port.regshift);
+		break;
+
+	default:
+		break;
+	}
+}
+
+static int m32r_sio_request_port(struct uart_port *port)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+	struct resource *res = NULL, *res_rsa = NULL;
+	int ret = 0;
+
+	if (up->port.type == PORT_RSA){
+		ret = m32r_sio_request_rsa_resource(up, &res_rsa);
+		if (ret < 0)
+			return ret;
+	}
+	ret = m32r_sio_request_std_resource(up, &res);
+
+	/*
+	 * If we have a mapbase, then request that as well.
+	 */
+	if (ret == 0 && up->port.flags & UPF_IOREMAP) {
+		int size = res->end - res->start + 1;
+
+		up->port.membase = ioremap(up->port.mapbase, size);
+		if (!up->port.membase)
+			ret = -ENOMEM;
+	}
+
+	if (ret < 0) {
+		if (res_rsa)
+			release_resource(res_rsa);
+		if (res)
+			release_resource(res);
+	}
+	return ret;
+}
+
+static void m32r_sio_config_port(struct uart_port *port, int flags)
+{
+	struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+	spin_lock_irqsave(&up->port.lock, flags);
+
+	up->port.type = PORT_SIO;
+	up->port.fifosize = uart_config[up->port.type].dfl_xmit_fifo_size;
+
+	spin_unlock_irqrestore(&up->port.lock, flags);
+}
+
+static int
+m32r_sio_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+	if (ser->irq >= NR_IRQS || ser->irq < 0 ||
+	    ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
+	    ser->type > PORT_MAX_SIO || ser->type == PORT_CIRRUS ||
+	    ser->type == PORT_STARTECH)
+		return -EINVAL;
+	return 0;
+}
+
+static const char *
+m32r_sio_type(struct uart_port *port)
+{
+	int type = port->type;
+
+	if (type >= ARRAY_SIZE(uart_config))
+		type = 0;
+	return uart_config[type].name;
+}
+
+static struct uart_ops m32r_sio_pops = {
+	.tx_empty	= m32r_sio_tx_empty,
+	.set_mctrl	= m32r_sio_set_mctrl,
+	.get_mctrl	= m32r_sio_get_mctrl,
+	.stop_tx	= m32r_sio_stop_tx,
+	.start_tx	= m32r_sio_start_tx,
+	.stop_rx	= m32r_sio_stop_rx,
+	.enable_ms	= m32r_sio_enable_ms,
+	.break_ctl	= m32r_sio_break_ctl,
+	.startup	= m32r_sio_startup,
+	.shutdown	= m32r_sio_shutdown,
+	.set_termios	= m32r_sio_set_termios,
+	.pm		= m32r_sio_pm,
+	.type		= m32r_sio_type,
+	.release_port	= m32r_sio_release_port,
+	.request_port	= m32r_sio_request_port,
+	.config_port	= m32r_sio_config_port,
+	.verify_port	= m32r_sio_verify_port,
+};
+
+static struct uart_sio_port m32r_sio_ports[UART_NR];
+
+static void __init m32r_sio_isa_init_ports(void)
+{
+	struct uart_sio_port *up;
+	static int first = 1;
+	int i;
+
+	if (!first)
+		return;
+	first = 0;
+
+	for (i = 0, up = m32r_sio_ports; i < ARRAY_SIZE(old_serial_port);
+	     i++, up++) {
+		up->port.iobase   = old_serial_port[i].port;
+		up->port.irq      = irq_canonicalize(old_serial_port[i].irq);
+		up->port.uartclk  = old_serial_port[i].baud_base * 16;
+		up->port.flags    = old_serial_port[i].flags;
+		up->port.hub6     = old_serial_port[i].hub6;
+		up->port.membase  = old_serial_port[i].iomem_base;
+		up->port.iotype   = old_serial_port[i].io_type;
+		up->port.regshift = old_serial_port[i].iomem_reg_shift;
+		up->port.ops      = &m32r_sio_pops;
+		if (share_irqs_sio)
+			up->port.flags |= UPF_SHARE_IRQ;
+	}
+}
+
+static void __init m32r_sio_register_ports(struct uart_driver *drv)
+{
+	int i;
+
+	m32r_sio_isa_init_ports();
+
+	for (i = 0; i < UART_NR; i++) {
+		struct uart_sio_port *up = &m32r_sio_ports[i];
+
+		up->port.line = i;
+		up->port.ops = &m32r_sio_pops;
+		init_timer(&up->timer);
+		up->timer.function = m32r_sio_timeout;
+
+		/*
+		 * ALPHA_KLUDGE_MCR needs to be killed.
+		 */
+		up->mcr_mask = ~ALPHA_KLUDGE_MCR;
+		up->mcr_force = ALPHA_KLUDGE_MCR;
+
+		uart_add_one_port(drv, &up->port);
+	}
+}
+
+#ifdef CONFIG_SERIAL_M32R_SIO_CONSOLE
+
+/*
+ *	Wait for transmitter & holding register to empty
+ */
+static inline void wait_for_xmitr(struct uart_sio_port *up)
+{
+	unsigned int status, tmout = 10000;
+
+	/* Wait up to 10ms for the character(s) to be sent. */
+	do {
+		status = sio_in(up, SIOSTS);
+
+		if (--tmout == 0)
+			break;
+		udelay(1);
+	} while ((status & UART_EMPTY) != UART_EMPTY);
+
+	/* Wait up to 1s for flow control if necessary */
+	if (up->port.flags & UPF_CONS_FLOW) {
+		tmout = 1000000;
+		while (--tmout)
+			udelay(1);
+	}
+}
+
+/*
+ *	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 m32r_sio_console_write(struct console *co, const char *s,
+	unsigned int count)
+{
+	struct uart_sio_port *up = &m32r_sio_ports[co->index];
+	unsigned int ier;
+	int i;
+
+	/*
+	 *	First save the UER then disable the interrupts
+	 */
+	ier = sio_in(up, SIOTRCR);
+	sio_out(up, SIOTRCR, 0);
+
+	/*
+	 *	Now, do each character
+	 */
+	for (i = 0; i < count; i++, s++) {
+		wait_for_xmitr(up);
+
+		/*
+		 *	Send the character out.
+		 *	If a LF, also do CR...
+		 */
+		sio_out(up, SIOTXB, *s);
+
+		if (*s == 10) {
+			wait_for_xmitr(up);
+			sio_out(up, SIOTXB, 13);
+		}
+	}
+
+	/*
+	 *	Finally, wait for transmitter to become empty
+	 *	and restore the IER
+	 */
+	wait_for_xmitr(up);
+	sio_out(up, SIOTRCR, ier);
+}
+
+static int __init m32r_sio_console_setup(struct console *co, char *options)
+{
+	struct uart_port *port;
+	int baud = 9600;
+	int bits = 8;
+	int parity = 'n';
+	int flow = 'n';
+
+	/*
+	 * Check whether an invalid uart number has been specified, and
+	 * if so, search for the first available port that does have
+	 * console support.
+	 */
+	if (co->index >= UART_NR)
+		co->index = 0;
+	port = &m32r_sio_ports[co->index].port;
+
+	/*
+	 * Temporary fix.
+	 */
+	spin_lock_init(&port->lock);
+
+	if (options)
+		uart_parse_options(options, &baud, &parity, &bits, &flow);
+
+	return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+extern struct uart_driver m32r_sio_reg;
+static struct console m32r_sio_console = {
+	.name		= "ttyS",
+	.write		= m32r_sio_console_write,
+	.device		= uart_console_device,
+	.setup		= m32r_sio_console_setup,
+	.flags		= CON_PRINTBUFFER,
+	.index		= -1,
+	.data		= &m32r_sio_reg,
+};
+
+static int __init m32r_sio_console_init(void)
+{
+	sio_reset();
+	sio_init();
+	m32r_sio_isa_init_ports();
+	register_console(&m32r_sio_console);
+	return 0;
+}
+console_initcall(m32r_sio_console_init);
+
+#define M32R_SIO_CONSOLE	&m32r_sio_console
+#else
+#define M32R_SIO_CONSOLE	NULL
+#endif
+
+static struct uart_driver m32r_sio_reg = {
+	.owner			= THIS_MODULE,
+	.driver_name		= "sio",
+	.devfs_name		= "tts/",
+	.dev_name		= "ttyS",
+	.major			= TTY_MAJOR,
+	.minor			= 64,
+	.nr			= UART_NR,
+	.cons			= M32R_SIO_CONSOLE,
+};
+
+/*
+ * register_serial and unregister_serial allows for 16x50 serial ports to be
+ * configured at run-time, to support PCMCIA modems.
+ */
+
+static int __register_m32r_sio(struct serial_struct *req, int line)
+{
+	struct uart_port port;
+
+	port.iobase   = req->port;
+	port.membase  = req->iomem_base;
+	port.irq      = req->irq;
+	port.uartclk  = req->baud_base * 16;
+	port.fifosize = req->xmit_fifo_size;
+	port.regshift = req->iomem_reg_shift;
+	port.iotype   = req->io_type;
+	port.flags    = req->flags | UPF_BOOT_AUTOCONF;
+	port.mapbase  = req->iomap_base;
+	port.line     = line;
+
+	if (share_irqs_sio)
+		port.flags |= UPF_SHARE_IRQ;
+
+	if (HIGH_BITS_OFFSET)
+		port.iobase |= (long) req->port_high << HIGH_BITS_OFFSET;
+
+	/*
+	 * If a clock rate wasn't specified by the low level
+	 * driver, then default to the standard clock rate.
+	 */
+	if (port.uartclk == 0)
+		port.uartclk = BASE_BAUD * 16;
+
+	return uart_register_port(&m32r_sio_reg, &port);
+}
+
+/**
+ *	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 necessary 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_m32r_sio(struct serial_struct *req)
+{
+	return __register_m32r_sio(req, -1);
+}
+
+int __init early_m32r_sio_setup(struct uart_port *port)
+{
+	m32r_sio_isa_init_ports();
+ 	m32r_sio_ports[port->line].port = *port;
+	m32r_sio_ports[port->line].port.ops = &m32r_sio_pops;
+
+	return 0;
+}
+
+/**
+ *	unregister_serial - remove a 16x50 serial port at runtime
+ *	@line: serial line number
+ *
+ *	Remove one serial port.  This may be called from interrupt
+ *	context.
+ */
+void unregister_m32r_sio(int line)
+{
+	uart_unregister_port(&m32r_sio_reg, line);
+}
+
+/*
+ * This is for ISAPNP only.
+ */
+void m32r_sio_get_irq_map(unsigned int *map)
+{
+	int i;
+
+	for (i = 0; i < UART_NR; i++) {
+		if (m32r_sio_ports[i].port.type != PORT_UNKNOWN &&
+		    m32r_sio_ports[i].port.irq < 16)
+			*map |= 1 << m32r_sio_ports[i].port.irq;
+	}
+}
+
+/**
+ *	m32r_sio_suspend_port - suspend one serial port
+ *	@line: serial line number
+ *
+ *	Suspend one serial port.
+ */
+void m32r_sio_suspend_port(int line)
+{
+	uart_suspend_port(&m32r_sio_reg, &m32r_sio_ports[line].port);
+}
+
+/**
+ *	m32r_sio_resume_port - resume one serial port
+ *	@line: serial line number
+ *
+ *	Resume one serial port.
+ */
+void m32r_sio_resume_port(int line)
+{
+	uart_resume_port(&m32r_sio_reg, &m32r_sio_ports[line].port);
+}
+
+static int __init m32r_sio_init(void)
+{
+	int ret, i;
+
+	printk(KERN_INFO "Serial: M32R SIO driver $Revision: 1.9 $ "
+		"IRQ sharing %sabled\n", share_irqs_sio ? "en" : "dis");
+
+	for (i = 0; i < NR_IRQS; i++)
+		spin_lock_init(&irq_lists[i].lock);
+
+	ret = uart_register_driver(&m32r_sio_reg);
+	if (ret >= 0)
+		m32r_sio_register_ports(&m32r_sio_reg);
+
+	return ret;
+}
+
+static void __exit m32r_sio_exit(void)
+{
+	int i;
+
+	for (i = 0; i < UART_NR; i++)
+		uart_remove_one_port(&m32r_sio_reg, &m32r_sio_ports[i].port);
+
+	uart_unregister_driver(&m32r_sio_reg);
+}
+
+module_init(m32r_sio_init);
+module_exit(m32r_sio_exit);
+
+EXPORT_SYMBOL(register_m32r_sio);
+EXPORT_SYMBOL(unregister_m32r_sio);
+EXPORT_SYMBOL(m32r_sio_get_irq_map);
+EXPORT_SYMBOL(m32r_sio_suspend_port);
+EXPORT_SYMBOL(m32r_sio_resume_port);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Generic M32R SIO serial driver $Revision: 1.9 $");
+
+module_param(share_irqs_sio, bool, 0400);
+MODULE_PARM_DESC(share_irqs_sio, "Share IRQs with other non-M32R SIO devices"
+	" (unsafe)");
diff -Nru a/drivers/serial/m32r_sio.h b/drivers/serial/m32r_sio.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/serial/m32r_sio.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,56 @@
+/*
+ *  m32r_sio.h
+ *
+ *  Driver for M32R serial ports
+ *
+ *  Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *  Based on drivers/serial/8250.h.
+ *
+ *  Copyright (C) 2001  Russell King.
+ *  Copyright (C) 2004  Hirokazu Takata <takata at linux-m32r.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>
+
+struct m32r_sio_probe {
+	struct module	*owner;
+	int		(*pci_init_one)(struct pci_dev *dev);
+	void		(*pci_remove_one)(struct pci_dev *dev);
+	void		(*pnp_init)(void);
+};
+
+int m32r_sio_register_probe(struct m32r_sio_probe *probe);
+void m32r_sio_unregister_probe(struct m32r_sio_probe *probe);
+void m32r_sio_get_irq_map(unsigned int *map);
+void m32r_sio_suspend_port(int line);
+void m32r_sio_resume_port(int line);
+
+struct old_serial_port {
+	unsigned int uart;
+	unsigned int baud_base;
+	unsigned int port;
+	unsigned int irq;
+	unsigned int flags;
+	unsigned char hub6;
+	unsigned char io_type;
+	unsigned char *iomem_base;
+	unsigned short iomem_reg_shift;
+};
+
+#define _INLINE_ inline
+
+#define PROBE_RSA	(1 << 0)
+#define PROBE_ANY	(~0)
+
+#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
+
+#ifdef CONFIG_SERIAL_SIO_SHARE_IRQ
+#define M32R_SIO_SHARE_IRQS 1
+#else
+#define M32R_SIO_SHARE_IRQS 0
+#endif
diff -Nru a/drivers/serial/m32r_sio_reg.h b/drivers/serial/m32r_sio_reg.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/serial/m32r_sio_reg.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,343 @@
+/*
+ * m32r_sio_reg.h
+ *
+ * Copyright (C) 1992, 1994 by Theodore Ts'o.
+ * Copyright (C) 2004  Hirokazu Takata <takata at linux-m32r.org>
+ *
+ * Redistribution of this file is permitted under the terms of the GNU
+ * Public License (GPL)
+ *
+ * These are the UART port assignments, expressed as offsets from the base
+ * register.  These assignments should hold for any serial port based on
+ * a 8250, 16450, or 16550(A).
+ */
+
+#ifndef _M32R_SIO_REG_H
+#define _M32R_SIO_REG_H
+
+#include <linux/config.h>
+
+#ifdef CONFIG_SERIAL_M32R_PLDSIO
+
+#define SIOCR		0x000
+#define SIOMOD0		0x002
+#define SIOMOD1		0x004
+#define SIOSTS		0x006
+#define SIOTRCR		0x008
+#define SIOBAUR		0x00a
+// #define SIORBAUR	0x018
+#define SIOTXB		0x00c
+#define SIORXB		0x00e
+
+#define UART_RX		((unsigned long) PLD_ESIO0RXB)
+				/* In:  Receive buffer (DLAB=0) */
+#define UART_TX		((unsigned long) PLD_ESIO0TXB)
+				/* Out: Transmit buffer (DLAB=0) */
+#define UART_DLL	0	/* Out: Divisor Latch Low (DLAB=1) */
+#define UART_TRG	0	/* (LCR=BF) FCTR bit 7 selects Rx or Tx
+				 * In: Fifo count
+				 * Out: Fifo custom trigger levels
+				 * XR16C85x only */
+
+#define UART_DLM	0	/* Out: Divisor Latch High (DLAB=1) */
+#define UART_IER	((unsigned long) PLD_ESIO0INTCR)
+				/* Out: Interrupt Enable Register */
+#define UART_FCTR	0	/* (LCR=BF) Feature Control Register
+				 * XR16C85x only */
+
+#define UART_IIR	0	/* In:  Interrupt ID Register */
+#define UART_FCR	0	/* Out: FIFO Control Register */
+#define UART_EFR	0	/* I/O: Extended Features Register */
+				/* (DLAB=1, 16C660 only) */
+
+#define UART_LCR	0	/* Out: Line Control Register */
+#define UART_MCR	0	/* Out: Modem Control Register */
+#define UART_LSR	((unsigned long) PLD_ESIO0STS)
+				/* In:  Line Status Register */
+#define UART_MSR	0	/* In:  Modem Status Register */
+#define UART_SCR	0	/* I/O: Scratch Register */
+#define UART_EMSR	0	/* (LCR=BF) Extended Mode Select Register
+				 * FCTR bit 6 selects SCR or EMSR
+				 * XR16c85x only */
+
+#else /* not CONFIG_SERIAL_M32R_PLDSIO */
+
+#define SIOCR		0x000
+#define SIOMOD0		0x004
+#define SIOMOD1		0x008
+#define SIOSTS		0x00c
+#define SIOTRCR		0x010
+#define SIOBAUR		0x014
+#define SIORBAUR	0x018
+#define SIOTXB		0x01c
+#define SIORXB		0x020
+
+#define UART_RX		M32R_SIO0_RXB_PORTL	/* In:  Receive buffer (DLAB=0) */
+#define UART_TX		M32R_SIO0_TXB_PORTL	/* Out: Transmit buffer (DLAB=0) */
+#define UART_DLL	0	/* Out: Divisor Latch Low (DLAB=1) */
+#define UART_TRG	0	/* (LCR=BF) FCTR bit 7 selects Rx or Tx
+				 * In: Fifo count
+				 * Out: Fifo custom trigger levels
+				 * XR16C85x only */
+
+#define UART_DLM	0	/* Out: Divisor Latch High (DLAB=1) */
+#define UART_IER	M32R_SIO0_TRCR_PORTL	/* Out: Interrupt Enable Register */
+#define UART_FCTR	0	/* (LCR=BF) Feature Control Register
+				 * XR16C85x only */
+
+#define UART_IIR	0	/* In:  Interrupt ID Register */
+#define UART_FCR	0	/* Out: FIFO Control Register */
+#define UART_EFR	0	/* I/O: Extended Features Register */
+				/* (DLAB=1, 16C660 only) */
+
+#define UART_LCR	0	/* Out: Line Control Register */
+#define UART_MCR	0	/* Out: Modem Control Register */
+#define UART_LSR	M32R_SIO0_STS_PORTL	/* In:  Line Status Register */
+#define UART_MSR	0	/* In:  Modem Status Register */
+#define UART_SCR	0	/* I/O: Scratch Register */
+#define UART_EMSR	0	/* (LCR=BF) Extended Mode Select Register
+				 * FCTR bit 6 selects SCR or EMSR
+				 * XR16c85x only */
+
+#endif /* CONFIG_SERIAL_M32R_PLDSIO */
+
+#define UART_EMPTY	(UART_LSR_TEMT | UART_LSR_THRE)
+
+/*
+ * These are the definitions for the FIFO Control Register
+ * (16650 only)
+ */
+#define UART_FCR_ENABLE_FIFO	0x01 /* Enable the FIFO */
+#define UART_FCR_CLEAR_RCVR	0x02 /* Clear the RCVR FIFO */
+#define UART_FCR_CLEAR_XMIT	0x04 /* Clear the XMIT FIFO */
+#define UART_FCR_DMA_SELECT	0x08 /* For DMA applications */
+#define UART_FCR_TRIGGER_MASK	0xC0 /* Mask for the FIFO trigger range */
+#define UART_FCR_TRIGGER_1	0x00 /* Mask for trigger set at 1 */
+#define UART_FCR_TRIGGER_4	0x40 /* Mask for trigger set at 4 */
+#define UART_FCR_TRIGGER_8	0x80 /* Mask for trigger set at 8 */
+#define UART_FCR_TRIGGER_14	0xC0 /* Mask for trigger set at 14 */
+/* 16650 redefinitions */
+#define UART_FCR6_R_TRIGGER_8	0x00 /* Mask for receive trigger set at 1 */
+#define UART_FCR6_R_TRIGGER_16	0x40 /* Mask for receive trigger set at 4 */
+#define UART_FCR6_R_TRIGGER_24  0x80 /* Mask for receive trigger set at 8 */
+#define UART_FCR6_R_TRIGGER_28	0xC0 /* Mask for receive trigger set at 14 */
+#define UART_FCR6_T_TRIGGER_16	0x00 /* Mask for transmit trigger set at 16 */
+#define UART_FCR6_T_TRIGGER_8	0x10 /* Mask for transmit trigger set at 8 */
+#define UART_FCR6_T_TRIGGER_24  0x20 /* Mask for transmit trigger set at 24 */
+#define UART_FCR6_T_TRIGGER_30	0x30 /* Mask for transmit trigger set at 30 */
+/* TI 16750 definitions */
+#define UART_FCR7_64BYTE	0x20 /* Go into 64 byte mode */
+
+/*
+ * These are the definitions for the Line Control Register
+ *
+ * Note: if the word length is 5 bits (UART_LCR_WLEN5), then setting
+ * UART_LCR_STOP will select 1.5 stop bits, not 2 stop bits.
+ */
+#define UART_LCR_DLAB	0x80	/* Divisor latch access bit */
+#define UART_LCR_SBC	0x40	/* Set break control */
+#define UART_LCR_SPAR	0x20	/* Stick parity (?) */
+#define UART_LCR_EPAR	0x10	/* Even parity select */
+#define UART_LCR_PARITY	0x08	/* Parity Enable */
+#define UART_LCR_STOP	0x04	/* Stop bits: 0=1 stop bit, 1= 2 stop bits */
+#define UART_LCR_WLEN5  0x00	/* Wordlength: 5 bits */
+#define UART_LCR_WLEN6  0x01	/* Wordlength: 6 bits */
+#define UART_LCR_WLEN7  0x02	/* Wordlength: 7 bits */
+#define UART_LCR_WLEN8  0x03	/* Wordlength: 8 bits */
+
+/*
+ * These are the definitions for the Line Status Register
+ */
+#define UART_LSR_TEMT	0x02	/* Transmitter empty */
+#define UART_LSR_THRE	0x01	/* Transmit-hold-register empty */
+#define UART_LSR_BI	0x00	/* Break interrupt indicator */
+#define UART_LSR_FE	0x80	/* Frame error indicator */
+#define UART_LSR_PE	0x40	/* Parity error indicator */
+#define UART_LSR_OE	0x20	/* Overrun error indicator */
+#define UART_LSR_DR	0x04	/* Receiver data ready */
+
+/*
+ * These are the definitions for the Interrupt Identification Register
+ */
+#define UART_IIR_NO_INT	0x01	/* No interrupts pending */
+#define UART_IIR_ID	0x06	/* Mask for the interrupt ID */
+
+#define UART_IIR_MSI	0x00	/* Modem status interrupt */
+#define UART_IIR_THRI	0x02	/* Transmitter holding register empty */
+#define UART_IIR_RDI	0x04	/* Receiver data interrupt */
+#define UART_IIR_RLSI	0x06	/* Receiver line status interrupt */
+
+/*
+ * These are the definitions for the Interrupt Enable Register
+ */
+#define UART_IER_MSI	0x00	/* Enable Modem status interrupt */
+#define UART_IER_RLSI	0x08	/* Enable receiver line status interrupt */
+#define UART_IER_THRI	0x03	/* Enable Transmitter holding register int. */
+#define UART_IER_RDI	0x04	/* Enable receiver data interrupt */
+/*
+ * Sleep mode for ST16650 and TI16750.
+ * Note that for 16650, EFR-bit 4 must be selected as well.
+ */
+#define UART_IERX_SLEEP  0x10	/* Enable sleep mode */
+
+/*
+ * These are the definitions for the Modem Control Register
+ */
+#define UART_MCR_LOOP	0x10	/* Enable loopback test mode */
+#define UART_MCR_OUT2	0x08	/* Out2 complement */
+#define UART_MCR_OUT1	0x04	/* Out1 complement */
+#define UART_MCR_RTS	0x02	/* RTS complement */
+#define UART_MCR_DTR	0x01	/* DTR complement */
+
+/*
+ * These are the definitions for the Modem Status Register
+ */
+#define UART_MSR_DCD	0x80	/* Data Carrier Detect */
+#define UART_MSR_RI	0x40	/* Ring Indicator */
+#define UART_MSR_DSR	0x20	/* Data Set Ready */
+#define UART_MSR_CTS	0x10	/* Clear to Send */
+#define UART_MSR_DDCD	0x08	/* Delta DCD */
+#define UART_MSR_TERI	0x04	/* Trailing edge ring indicator */
+#define UART_MSR_DDSR	0x02	/* Delta DSR */
+#define UART_MSR_DCTS	0x01	/* Delta CTS */
+#define UART_MSR_ANY_DELTA 0x0F	/* Any of the delta bits! */
+
+/*
+ * These are the definitions for the Extended Features Register
+ * (StarTech 16C660 only, when DLAB=1)
+ */
+#define UART_EFR_CTS	0x80	/* CTS flow control */
+#define UART_EFR_RTS	0x40	/* RTS flow control */
+#define UART_EFR_SCD	0x20	/* Special character detect */
+#define UART_EFR_ECB	0x10	/* Enhanced control bit */
+/*
+ * the low four bits control software flow control
+ */
+
+/*
+ * These register definitions are for the 16C950
+ */
+#define UART_ASR	0x01	/* Additional Status Register */
+#define UART_RFL	0x03	/* Receiver FIFO level */
+#define UART_TFL 	0x04	/* Transmitter FIFO level */
+#define UART_ICR	0x05	/* Index Control Register */
+
+/* The 16950 ICR registers */
+#define UART_ACR	0x00	/* Additional Control Register */
+#define UART_CPR	0x01	/* Clock Prescalar Register */
+#define UART_TCR	0x02	/* Times Clock Register */
+#define UART_CKS	0x03	/* Clock Select Register */
+#define UART_TTL	0x04	/* Transmitter Interrupt Trigger Level */
+#define UART_RTL	0x05	/* Receiver Interrupt Trigger Level */
+#define UART_FCL	0x06	/* Flow Control Level Lower */
+#define UART_FCH	0x07	/* Flow Control Level Higher */
+#define UART_ID1	0x08	/* ID #1 */
+#define UART_ID2	0x09	/* ID #2 */
+#define UART_ID3	0x0A	/* ID #3 */
+#define UART_REV	0x0B	/* Revision */
+#define UART_CSR	0x0C	/* Channel Software Reset */
+#define UART_NMR	0x0D	/* Nine-bit Mode Register */
+#define UART_CTR	0xFF
+
+/*
+ * The 16C950 Additional Control Reigster
+ */
+#define UART_ACR_RXDIS	0x01	/* Receiver disable */
+#define UART_ACR_TXDIS	0x02	/* Receiver disable */
+#define UART_ACR_DSRFC	0x04	/* DSR Flow Control */
+#define UART_ACR_TLENB	0x20	/* 950 trigger levels enable */
+#define UART_ACR_ICRRD	0x40	/* ICR Read enable */
+#define UART_ACR_ASREN	0x80	/* Additional status enable */
+
+/*
+ * These are the definitions for the Feature Control Register
+ * (XR16C85x only, when LCR=bf; doubles with the Interrupt Enable
+ * Register, UART register #1)
+ */
+#define UART_FCTR_RTS_NODELAY	0x00  /* RTS flow control delay */
+#define UART_FCTR_RTS_4DELAY	0x01
+#define UART_FCTR_RTS_6DELAY	0x02
+#define UART_FCTR_RTS_8DELAY	0x03
+#define UART_FCTR_IRDA	0x04  /* IrDa data encode select */
+#define UART_FCTR_TX_INT	0x08  /* Tx interrupt type select */
+#define UART_FCTR_TRGA	0x00  /* Tx/Rx 550 trigger table select */
+#define UART_FCTR_TRGB	0x10  /* Tx/Rx 650 trigger table select */
+#define UART_FCTR_TRGC	0x20  /* Tx/Rx 654 trigger table select */
+#define UART_FCTR_TRGD	0x30  /* Tx/Rx 850 programmable trigger select */
+#define UART_FCTR_SCR_SWAP	0x40  /* Scratch pad register swap */
+#define UART_FCTR_RX	0x00  /* Programmable trigger mode select */
+#define UART_FCTR_TX	0x80  /* Programmable trigger mode select */
+
+/*
+ * These are the definitions for the Enhanced Mode Select Register
+ * (XR16C85x only, when LCR=bf and FCTR bit 6=1; doubles with the
+ * Scratch register, UART register #7)
+ */
+#define UART_EMSR_FIFO_COUNT	0x01  /* Rx/Tx select */
+#define UART_EMSR_ALT_COUNT	0x02  /* Alternating count select */
+
+/*
+ * These are the definitions for the Programmable Trigger
+ * Register (XR16C85x only, when LCR=bf; doubles with the UART RX/TX
+ * register, UART register #0)
+ */
+#define UART_TRG_1	0x01
+#define UART_TRG_4	0x04
+#define UART_TRG_8	0x08
+#define UART_TRG_16	0x10
+#define UART_TRG_32	0x20
+#define UART_TRG_64	0x40
+#define UART_TRG_96	0x60
+#define UART_TRG_120	0x78
+#define UART_TRG_128	0x80
+
+/*
+ * These definitions are for the RSA-DV II/S card, from
+ *
+ * Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
+ */
+
+#define UART_RSA_BASE (-8)
+
+#define UART_RSA_MSR ((UART_RSA_BASE) + 0) /* I/O: Mode Select Register */
+
+#define UART_RSA_MSR_SWAP (1 << 0) /* Swap low/high 8 bytes in I/O port addr */
+#define UART_RSA_MSR_FIFO (1 << 2) /* Enable the external FIFO */
+#define UART_RSA_MSR_FLOW (1 << 3) /* Enable the auto RTS/CTS flow control */
+#define UART_RSA_MSR_ITYP (1 << 4) /* Level (1) / Edge triger (0) */
+
+#define UART_RSA_IER ((UART_RSA_BASE) + 1) /* I/O: Interrupt Enable Register */
+
+#define UART_RSA_IER_Rx_FIFO_H (1 << 0) /* Enable Rx FIFO half full int. */
+#define UART_RSA_IER_Tx_FIFO_H (1 << 1) /* Enable Tx FIFO half full int. */
+#define UART_RSA_IER_Tx_FIFO_E (1 << 2) /* Enable Tx FIFO empty int. */
+#define UART_RSA_IER_Rx_TOUT (1 << 3) /* Enable char receive timeout int */
+#define UART_RSA_IER_TIMER (1 << 4) /* Enable timer interrupt */
+
+#define UART_RSA_SRR ((UART_RSA_BASE) + 2) /* IN: Status Read Register */
+
+#define UART_RSA_SRR_Tx_FIFO_NEMP (1 << 0) /* Tx FIFO is not empty (1) */
+#define UART_RSA_SRR_Tx_FIFO_NHFL (1 << 1) /* Tx FIFO is not half full (1) */
+#define UART_RSA_SRR_Tx_FIFO_NFUL (1 << 2) /* Tx FIFO is not full (1) */
+#define UART_RSA_SRR_Rx_FIFO_NEMP (1 << 3) /* Rx FIFO is not empty (1) */
+#define UART_RSA_SRR_Rx_FIFO_NHFL (1 << 4) /* Rx FIFO is not half full (1) */
+#define UART_RSA_SRR_Rx_FIFO_NFUL (1 << 5) /* Rx FIFO is not full (1) */
+#define UART_RSA_SRR_Rx_TOUT (1 << 6) /* Character reception timeout occurred (1) */
+#define UART_RSA_SRR_TIMER (1 << 7) /* Timer interrupt occurred */
+
+#define UART_RSA_FRR ((UART_RSA_BASE) + 2) /* OUT: FIFO Reset Register */
+
+#define UART_RSA_TIVSR ((UART_RSA_BASE) + 3) /* I/O: Timer Interval Value Set Register */
+
+#define UART_RSA_TCR ((UART_RSA_BASE) + 4) /* OUT: Timer Control Register */
+
+#define UART_RSA_TCR_SWITCH (1 << 0) /* Timer on */
+
+/*
+ * The RSA DSV/II board has two fixed clock frequencies.  One is the
+ * standard rate, and the other is 8 times faster.
+ */
+#define SERIAL_RSA_BAUD_BASE (921600)
+#define SERIAL_RSA_BAUD_BASE_LO (SERIAL_RSA_BAUD_BASE / 8)
+
+#endif /* _M32R_SIO_REG_H */
diff -Nru a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
--- a/drivers/serial/mcfserial.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/serial/mcfserial.c	2004-12-24 13:36:48 -08:00
@@ -34,13 +34,14 @@
 #include <linux/serialP.h>
 #include <linux/console.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/segment.h>
 #include <asm/semaphore.h>
-#include <asm/bitops.h>
 #include <asm/delay.h>
 #include <asm/coldfire.h>
 #include <asm/mcfsim.h>
@@ -735,7 +736,7 @@
 	local_irq_restore(flags);
 }
 
-static int mcfrs_write(struct tty_struct * tty, int from_user,
+static int mcfrs_write(struct tty_struct * tty,
 		    const unsigned char *buf, int count)
 {
 	volatile unsigned char	*uartp;
@@ -744,8 +745,8 @@
 	int			c, total = 0;
 
 #if 0
-	printk("%s(%d): mcfrs_write(tty=%x,from_user=%d,buf=%x,count=%d)\n",
-		__FILE__, __LINE__, (int)tty, from_user, (int)buf, count);
+	printk("%s(%d): mcfrs_write(tty=%x,buf=%x,count=%d)\n",
+		__FILE__, __LINE__, (int)tty, (int)buf, count);
 #endif
 
 	if (serial_paranoia_check(info, tty->name, "mcfrs_write"))
@@ -764,19 +765,7 @@
 		if (c <= 0)
 			break;
 
-		if (from_user) {
-			down(&mcfrs_tmp_buf_sem);
-			if (copy_from_user(mcfrs_tmp_buf, buf, c))
-				return -EFAULT;
-
-			local_irq_disable();
-			c = min(c, (int) min(((int)SERIAL_XMIT_SIZE) - info->xmit_cnt - 1,
-				       ((int)SERIAL_XMIT_SIZE) - info->xmit_head));
-			local_irq_restore(flags);
-			memcpy(info->xmit_buf + info->xmit_head, mcfrs_tmp_buf, c);
-			up(&mcfrs_tmp_buf_sem);
-		} else
-			memcpy(info->xmit_buf + info->xmit_head, buf, c);
+		memcpy(info->xmit_buf + info->xmit_head, buf, c);
 
 		local_irq_disable();
 		info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
@@ -990,7 +979,7 @@
 
 	if (!info->addr)
 		return;
-	current->state = TASK_INTERRUPTIBLE;
+	set_current_state(TASK_INTERRUPTIBLE);
 	uartp = info->addr;
 
 	local_irq_save(flags);
@@ -1242,8 +1231,7 @@
 #endif	
 	if (info->blocked_open) {
 		if (info->close_delay) {
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(info->close_delay);
+			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -1308,8 +1296,7 @@
 			fifo_cnt++;
 		if (fifo_cnt == 0)
 			break;
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(char_time);
+		msleep_interruptible(jiffies_to_msecs(char_time));
 		if (signal_pending(current))
 			break;
 		if (timeout && time_after(jiffies, orig_jiffies + timeout))
diff -Nru a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
--- a/drivers/serial/pmac_zilog.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/serial/pmac_zilog.c	2004-12-24 13:36:17 -08:00
@@ -29,6 +29,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * 2004-08-06 Harald Welte <laforge@gnumonks.org>
+ *	- Enable BREAK interrupt
+ *	- Add support for sysreq
+ *
  * TODO:   - Add DMA support
  *         - Defer port shutdown to a few seconds after close
  *         - maybe put something right into uap->clk_divisor
@@ -36,6 +40,7 @@
 
 #undef DEBUG
 #undef DEBUG_HARD
+#undef USE_CTRL_O_SYSRQ
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -53,17 +58,22 @@
 #include <linux/slab.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
+#include <linux/bitops.h>
+#include <linux/sysrq.h>
 #include <asm/sections.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/prom.h>
-#include <asm/bitops.h>
 #include <asm/machdep.h>
 #include <asm/pmac_feature.h>
 #include <asm/dbdma.h>
 #include <asm/macio.h>
 #include <asm/semaphore.h>
 
+#if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/serial.h>
 #include <linux/serial_core.h>
 
@@ -259,8 +269,27 @@
 		}
 
 		ch &= uap->parity_mask;
-		if (ch == 0 && uap->prev_status & BRK_ABRT)
-			r1 |= BRK_ABRT;
+		if (ch == 0 && uap->flags & PMACZILOG_FLAG_BREAK) {
+			uap->flags &= ~PMACZILOG_FLAG_BREAK;
+		}
+
+#if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_SERIAL_CORE_CONSOLE)
+#ifdef USE_CTRL_O_SYSRQ
+		/* Handle the SysRq ^O Hack */
+		if (ch == '\x0f') {
+			uap->port.sysrq = jiffies + HZ*5;
+			goto next_char;
+		}
+#endif /* USE_CTRL_O_SYSRQ */
+		if (uap->port.sysrq) {
+			int swallow;
+			spin_unlock(&uap->port.lock);
+			swallow = uart_handle_sysrq_char(&uap->port, ch, regs);
+			spin_lock(&uap->port.lock);
+			if (swallow)
+				goto next_char;
+ 		}
+#endif /* CONFIG_MAGIC_SYSRQ && CONFIG_SERIAL_CORE_CONSOLE */
 
 		/* A real serial line, record the character and status.  */
 		if (drop)
@@ -276,10 +305,8 @@
 				pmz_debug("pmz: got break !\n");
 				r1 &= ~(PAR_ERR | CRC_ERR);
 				uap->port.icount.brk++;
-				if (uart_handle_break(&uap->port)) {
-					pmz_debug("pmz: do handle break !\n");
+				if (uart_handle_break(&uap->port))
 					goto next_char;
-				}
 			}
 			else if (r1 & PAR_ERR)
 				uap->port.icount.parity++;
@@ -295,10 +322,6 @@
 			else if (r1 & CRC_ERR)
 				*tty->flip.flag_buf_ptr = TTY_FRAME;
 		}
-		if (uart_handle_sysrq_char(&uap->port, ch, regs)) {
-			pmz_debug("pmz: sysrq swallowed the char\n");
-			goto next_char;
-		}
 
 		if (uap->port.ignore_status_mask == 0xff ||
 		    (r1 & uap->port.ignore_status_mask) == 0) {
@@ -364,6 +387,9 @@
 		wake_up_interruptible(&uap->port.info->delta_msr_wait);
 	}
 
+	if (status & BRK_ABRT)
+		uap->flags |= PMACZILOG_FLAG_BREAK;
+
 	uap->prev_status = status;
 }
 
@@ -872,8 +898,8 @@
 	uap->curregs[R13] = 0;
 	uap->curregs[R14] = BRENAB;
 
-	/* Clear handshaking */
-	uap->curregs[R15] = 0;
+	/* Clear handshaking, enable BREAK interrupts */
+	uap->curregs[R15] = BRKIE;
 
 	/* Master interrupt enable */
 	uap->curregs[R9] |= NV | MIE;
@@ -949,8 +975,7 @@
 	 */
 	if (pwr_delay != 0) {
 		pmz_debug("pmz: delaying %d ms\n", pwr_delay);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((pwr_delay * HZ)/1000);
+		msleep(pwr_delay);
 	}
 
 	/* IrDA reset is done now */
@@ -1309,6 +1334,8 @@
 		/* Load registers to the chip */
 		pmz_maybe_update_regs(uap);
 	}
+	uart_update_timeout(port, termios->c_cflag, baud);
+
 	pmz_debug("pmz: set_termios() done.\n");
 }
 
@@ -1412,7 +1439,7 @@
 	uap->port.mapbase = np->addrs[0].address;
 	uap->port.membase = ioremap(uap->port.mapbase, 0x1000);
       
-	uap->control_reg = (volatile u8 *)uap->port.membase;
+	uap->control_reg = uap->port.membase;
 	uap->data_reg = uap->control_reg + 0x10;
 	
 	/*
@@ -1423,16 +1450,14 @@
 		uap->flags |= PMACZILOG_FLAG_HAS_DMA;
 #endif	
 	if (ZS_HAS_DMA(uap)) {
-		uap->tx_dma_regs = (volatile struct dbdma_regs *)
-			ioremap(np->addrs[np->n_addrs - 2].address, 0x1000);
+		uap->tx_dma_regs = ioremap(np->addrs[np->n_addrs - 2].address, 0x1000);
 		if (uap->tx_dma_regs == NULL) {	
 			uap->flags &= ~PMACZILOG_FLAG_HAS_DMA;
 			goto no_dma;
 		}
-		uap->rx_dma_regs = (volatile struct dbdma_regs *)
-			ioremap(np->addrs[np->n_addrs - 1].address, 0x1000);
+		uap->rx_dma_regs = ioremap(np->addrs[np->n_addrs - 1].address, 0x1000);
 		if (uap->rx_dma_regs == NULL) {	
-			iounmap((void *)uap->tx_dma_regs);
+			iounmap(uap->tx_dma_regs);
 			uap->tx_dma_regs = NULL;
 			uap->flags &= ~PMACZILOG_FLAG_HAS_DMA;
 			goto no_dma;
@@ -1509,9 +1534,9 @@
 	struct device_node *np;
 
 	np = uap->node;
-	iounmap((void *)uap->rx_dma_regs);
-	iounmap((void *)uap->tx_dma_regs);
-	iounmap((void *)uap->control_reg);
+	iounmap(uap->rx_dma_regs);
+	iounmap(uap->tx_dma_regs);
+	iounmap(uap->control_reg);
 	uap->node = NULL;
 	of_node_put(np);
 	memset(uap, 0, sizeof(struct uart_pmac_port));
@@ -1576,7 +1601,7 @@
 		return 0;
 	}
 
-	if (pm_state == mdev->ofdev.dev.power_state || pm_state < 2)
+	if (pm_state == mdev->ofdev.dev.power.power_state || pm_state < 2)
 		return 0;
 
 	pmz_debug("suspend, switching to state %d\n", pm_state);
@@ -1620,7 +1645,7 @@
 
 	pmz_debug("suspend, switching complete\n");
 
-	mdev->ofdev.dev.power_state = pm_state;
+	mdev->ofdev.dev.power.power_state = pm_state;
 
 	return 0;
 }
@@ -1636,7 +1661,7 @@
 	if (uap == NULL)
 		return 0;
 
-	if (mdev->ofdev.dev.power_state == 0)
+	if (mdev->ofdev.dev.power.power_state == 0)
 		return 0;
 	
 	pmz_debug("resume, switching to state 0\n");
@@ -1684,13 +1709,12 @@
 	 */
 	if (pwr_delay != 0) {
 		pmz_debug("pmz: delaying %d ms\n", pwr_delay);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((pwr_delay * HZ)/1000);
+		msleep(pwr_delay);
 	}
 
 	pmz_debug("resume, switching complete\n");
 
-	mdev->ofdev.dev.power_state = 0;
+	mdev->ofdev.dev.power.power_state = 0;
 
 	return 0;
 }
diff -Nru a/drivers/serial/pmac_zilog.h b/drivers/serial/pmac_zilog.h
--- a/drivers/serial/pmac_zilog.h	2004-12-24 13:36:56 -08:00
+++ b/drivers/serial/pmac_zilog.h	2004-12-24 13:36:56 -08:00
@@ -47,17 +47,18 @@
 #define PMACZILOG_FLAG_IS_OPEN		0x00002000
 #define PMACZILOG_FLAG_IS_IRQ_ON	0x00004000
 #define PMACZILOG_FLAG_IS_EXTCLK	0x00008000
+#define PMACZILOG_FLAG_BREAK		0x00010000
 
 	unsigned char			parity_mask;
 	unsigned char			prev_status;
 
-	volatile u8			*control_reg;
-	volatile u8			*data_reg;
+	volatile u8			__iomem *control_reg;
+	volatile u8			__iomem *data_reg;
 
 	unsigned int			tx_dma_irq;
 	unsigned int			rx_dma_irq;
-	volatile struct dbdma_regs	*tx_dma_regs;
-	volatile struct dbdma_regs	*rx_dma_regs;
+	volatile struct dbdma_regs	__iomem *tx_dma_regs;
+	volatile struct dbdma_regs	__iomem *rx_dma_regs;
 
 	struct termios			termios_cache;
 };
diff -Nru a/drivers/serial/pxa.c b/drivers/serial/pxa.c
--- a/drivers/serial/pxa.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/serial/pxa.c	2004-12-24 13:37:19 -08:00
@@ -25,8 +25,12 @@
  */
 
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_PXA_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/console.h>
@@ -36,18 +40,15 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
 
 #include <asm/io.h>
 #include <asm/hardware.h>
 #include <asm/irq.h>
 #include <asm/arch/pxa-regs.h>
 
-#if defined(CONFIG_SERIAL_PXA_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
 
 struct uart_pxa_port {
 	struct uart_port        port;
@@ -102,25 +103,20 @@
 receive_chars(struct uart_pxa_port *up, int *status, struct pt_regs *regs)
 {
 	struct tty_struct *tty = up->port.info->tty;
-	unsigned char ch;
+	unsigned int ch, flag;
 	int max_count = 256;
 
 	do {
 		if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
+			if (tty->low_latency)
+				tty_flip_buffer_push(tty);
 			/*
-			 * FIXME: Deadlock can happen here if we're a
-			 * low-latency port.  We're holding the per-port
-			 * spinlock, and we call flush_to_ldisc->
-			 * n_tty_receive_buf->n_tty_receive_char->
-			 * opost->uart_put_char.
+			 * If this failed then we will throw away the
+			 * bytes but must do so to clear interrupts
 			 */
-			tty->flip.work.func((void *)tty);
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-				return; // if TTY_DONT_FLIP is set
 		}
 		ch = serial_in(up, UART_RX);
-		*tty->flip.char_buf_ptr = ch;
-		*tty->flip.flag_buf_ptr = TTY_NORMAL;
+		flag = TTY_NORMAL;
 		up->port.icount.rx++;
 
 		if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE |
@@ -159,18 +155,16 @@
 			}
 #endif
 			if (*status & UART_LSR_BI) {
-				*tty->flip.flag_buf_ptr = TTY_BREAK;
+				flag = TTY_BREAK;
 			} else if (*status & UART_LSR_PE)
-				*tty->flip.flag_buf_ptr = TTY_PARITY;
+				flag = TTY_PARITY;
 			else if (*status & UART_LSR_FE)
-				*tty->flip.flag_buf_ptr = TTY_FRAME;
+				flag = TTY_FRAME;
 		}
 		if (uart_handle_sysrq_char(&up->port, ch, regs))
 			goto ignore_char;
 		if ((*status & up->port.ignore_status_mask) == 0) {
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, ch, flag);
 		}
 		if ((*status & UART_LSR_OE) &&
 		    tty->flip.count < TTY_FLIPBUF_SIZE) {
@@ -179,10 +173,7 @@
 			 * immediately, and doesn't affect the current
 			 * character.
 			 */
-			*tty->flip.flag_buf_ptr = TTY_OVERRUN;
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
 		}
 	ignore_char:
 		*status = serial_in(up, UART_LSR);
diff -Nru a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
--- a/drivers/serial/s3c2410.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/serial/s3c2410.c	2004-12-24 13:36:49 -08:00
@@ -1,7 +1,7 @@
 /*
- * linux/drivers/char/s3c2410.c
+ * linux/drivers/serial/s3c2410.c
  *
- * Driver for onboard UARTs on the Samsung S3C2410
+ * Driver for onboard UARTs on the Samsung S3C24XX
  *
  * Based on drivers/char/serial.c and drivers/char/21285.c
  *
@@ -9,54 +9,153 @@
  *
  * Changelog:
  *
- */
+ * 22-Jul-2004  BJD  Finished off device rewrite
+ *
+ * 21-Jul-2004  BJD  Thanks to <herbet@13thfloor.at> for pointing out
+ *                   problems with baud rate and loss of IR settings. Update
+ *                   to add configuration via platform_device structure
+ *
+ * 28-Sep-2004  BJD  Re-write for the following items
+ *		     - S3C2410 and S3C2440 serial support
+ *		     - Power Management support
+ *		     - Fix console via IrDA devices
+ *		     - SysReq (Herbert Pötzl)
+ *		     - Break character handling (Herbert Pötzl)
+ *		     - spin-lock initialisation (Dimitry Andric)
+ *		     - added clock control
+ *		     - updated init code to use platform_device info
+*/
+
+/* Hote on 2410 error handling
+ *
+ * The s3c2410 manual has a love/hate affair with the contents of the
+ * UERSTAT register in the UART blocks, and keeps marking some of the
+ * error bits as reserved. Having checked with the s3c2410x01,
+ * it copes with BREAKs properly, so I am happy to ignore the RESERVED
+ * feature from the latter versions of the manual.
+ *
+ * If it becomes aparrent that latter versions of the 2410 remove these
+ * bits, then action will have to be taken to differentiate the versions
+ * and change the policy on BREAK
+ *
+ * BJD, 04-Nov-2004
+*/
+
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_S3C2410_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/device.h>
 #include <linux/init.h>
+#include <linux/sysrq.h>
 #include <linux/console.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
 #include <linux/serial_core.h>
 #include <linux/serial.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 
 #include <asm/hardware.h>
+#include <asm/hardware/clock.h>
+
 #include <asm/arch/regs-serial.h>
+#include <asm/arch/regs-gpio.h>
+
+#include <asm/mach-types.h>
+
+/* structures */
+
+struct s3c24xx_uart_info {
+	char			*name;
+	unsigned int		type;
+	unsigned int		fifosize;
+	unsigned long		rx_fifomask;
+	unsigned long		rx_fifoshift;
+	unsigned long		rx_fifofull;
+	unsigned long		tx_fifomask;
+	unsigned long		tx_fifoshift;
+	unsigned long		tx_fifofull;
+
+	/* clock source control */
+
+	int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
+	int (*set_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
+};
+
+struct s3c24xx_uart_port {
+	unsigned char			rx_claimed;
+	unsigned char			tx_claimed;
+
+	struct s3c24xx_uart_info	*info;
+	struct s3c24xx_uart_clksrc	*clksrc;
+	struct clk			*clk;
+	struct clk			*baudclk;
+	struct uart_port		port;
+};
+
+
+/* configuration defines */
 
 #if 0
-#include <asm/debug-ll.h>
-#define dbg(x...) llprintk(x)
+#if 1
+/* send debug to the low-level output routines */
+
+extern void printascii(const char *);
+
+static void
+s3c24xx_serial_dbg(const char *fmt, ...)
+{
+	va_list va;
+	char buff[256];
+
+	va_start(va, fmt);
+	vsprintf(buff, fmt, va);
+	va_end(va);
+
+	printascii(buff);
+}
+
+#define dbg(x...) s3c24xx_serial_dbg(x)
+
 #else
-#define dbg(x...)
+#define dbg(x...) printk(KERN_DEBUG "s3c24xx: ");
 #endif
+#else /* no debug */
+#define dbg(x...) do {} while(0)
+#endif
+
+/* UART name and device definitions */
 
-#define SERIAL_S3C2410_NAME	"ttySAC"
-#define SERIAL_S3C2410_MAJOR	204
-#define SERIAL_S3C2410_MINOR	64
+#define S3C24XX_SERIAL_NAME	"ttySAC"
+#define S3C24XX_SERIAL_DEVFS    "tts/"
+#define S3C24XX_SERIAL_MAJOR	204
+#define S3C24XX_SERIAL_MINOR	64
+
+
+/* conversion functions */
+
+#define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev)
+#define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data)
 
 /* we can support 3 uarts, but not always use them */
 
 #define NR_PORTS (3)
 
-static const char serial_s3c2410_name[] = "Samsung S3C2410 UART";
-
 /* port irq numbers */
 
 #define TX_IRQ(port) ((port)->irq + 1)
 #define RX_IRQ(port) ((port)->irq)
 
-#define tx_enabled(port) ((port)->unused[0])
-#define rx_enabled(port) ((port)->unused[1])
-
-/* flag to ignore all characters comming in */
-#define RXSTAT_DUMMY_READ (0x10000000)
-
-/* access functions */
+/* register access controls */
 
-#define portaddr(port, reg) ((void *)((port)->membase + (reg)))
+#define portaddr(port, reg) ((port)->membase + (reg))
 
 #define rd_regb(port, reg) (__raw_readb(portaddr(port, reg)))
 #define rd_regl(port, reg) (__raw_readl(portaddr(port, reg)))
@@ -67,107 +166,234 @@
 #define wr_regl(port, reg, val) \
   do { __raw_writel(val, portaddr(port, reg)); } while(0)
 
+/* macros to change one thing to another */
+
+#define tx_enabled(port) ((port)->unused[0])
+#define rx_enabled(port) ((port)->unused[1])
+
+/* flag to ignore all characters comming in */
+#define RXSTAT_DUMMY_READ (0x10000000)
+
+static inline struct s3c24xx_uart_port *to_ourport(struct uart_port *port)
+{
+	return container_of(port, struct s3c24xx_uart_port, port);
+}
+
+/* translate a port to the device name */
 
+static inline char *s3c24xx_serial_portname(struct uart_port *port)
+{
+	return to_platform_device(port->dev)->name;
+}
+
+static int s3c24xx_serial_txempty_nofifo(struct uart_port *port)
+{
+	return (rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE);
+}
 
+static void s3c24xx_serial_rx_enable(struct uart_port *port)
+{
+	unsigned long flags;
+	unsigned int ucon, ufcon;
+	int count = 10000;
 
-/* code */
+	spin_lock_irqsave(&port->lock, flags);
+
+	while (--count && !s3c24xx_serial_txempty_nofifo(port))
+		udelay(100);
+
+	ufcon = rd_regl(port, S3C2410_UFCON);
+	ufcon |= S3C2410_UFCON_RESETRX;
+	wr_regl(port, S3C2410_UFCON, ufcon);
+
+	ucon = rd_regl(port, S3C2410_UCON);
+	ucon |= S3C2410_UCON_RXIRQMODE;
+	wr_regl(port, S3C2410_UCON, ucon);
+
+	rx_enabled(port) = 1;
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void s3c24xx_serial_rx_disable(struct uart_port *port)
+{
+	unsigned long flags;
+	unsigned int ucon;
+
+	spin_lock_irqsave(&port->lock, flags);
+
+	ucon = rd_regl(port, S3C2410_UCON);
+	ucon &= ~S3C2410_UCON_RXIRQMODE;
+	wr_regl(port, S3C2410_UCON, ucon);
+
+	rx_enabled(port) = 0;
+	spin_unlock_irqrestore(&port->lock, flags);
+}
 
 static void
-serial_s3c2410_stop_tx(struct uart_port *port, unsigned int tty_stop)
+s3c24xx_serial_stop_tx(struct uart_port *port, unsigned int tty_stop)
 {
 	if (tx_enabled(port)) {
 		disable_irq(TX_IRQ(port));
 		tx_enabled(port) = 0;
+		if (port->flags & UPF_CONS_FLOW)
+			s3c24xx_serial_rx_enable(port);
 	}
 }
 
 static void
-serial_s3c2410_start_tx(struct uart_port *port, unsigned int tty_start)
+s3c24xx_serial_start_tx(struct uart_port *port, unsigned int tty_start)
 {
 	if (!tx_enabled(port)) {
+		if (port->flags & UPF_CONS_FLOW)
+			s3c24xx_serial_rx_disable(port);
+
 		enable_irq(TX_IRQ(port));
 		tx_enabled(port) = 1;
 	}
 }
 
-static void serial_s3c2410_stop_rx(struct uart_port *port)
+
+static void s3c24xx_serial_stop_rx(struct uart_port *port)
 {
 	if (rx_enabled(port)) {
-		dbg("serial_s3c2410_stop_rx: port=%p\n", port);
+		dbg("s3c24xx_serial_stop_rx: port=%p\n", port);
 		disable_irq(RX_IRQ(port));
 		rx_enabled(port) = 0;
 	}
 }
 
-static void serial_s3c2410_enable_ms(struct uart_port *port)
+static void s3c24xx_serial_enable_ms(struct uart_port *port)
+{
+}
+
+static inline struct s3c24xx_uart_info *s3c24xx_port_to_info(struct uart_port *port)
+{
+	return to_ourport(port)->info;
+}
+
+static inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg(struct uart_port *port)
+{
+	if (port->dev == NULL)
+		return NULL;
+
+	return (struct s3c2410_uartcfg *)port->dev->platform_data;
+}
+
+static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport,
+				     unsigned long ufstat)
 {
+	struct s3c24xx_uart_info *info = ourport->info;
+
+	if (ufstat & info->rx_fifofull)
+		return info->fifosize;
+
+	return (ufstat & info->rx_fifomask) >> info->rx_fifoshift;
 }
 
+
 /* ? - where has parity gone?? */
 #define S3C2410_UERSTAT_PARITY (0x1000)
 
 static irqreturn_t
-serial_s3c2410_rx_chars(int irq, void *dev_id, struct pt_regs *regs)
+s3c24xx_serial_rx_chars(int irq, void *dev_id, struct pt_regs *regs)
 {
-	struct uart_port *port = dev_id;
+	struct s3c24xx_uart_port *ourport = dev_id;
+	struct uart_port *port = &ourport->port;
 	struct tty_struct *tty = port->info->tty;
-	unsigned int ufcon, ch, rxs, ufstat;
-	int max_count = 256;
+	unsigned int ufcon, ch, flag, ufstat, uerstat;
+	int max_count = 64;
 
 	while (max_count-- > 0) {
 		ufcon = rd_regl(port, S3C2410_UFCON);
 		ufstat = rd_regl(port, S3C2410_UFSTAT);
 
-		if (S3C2410_UFCON_RXC(ufstat) == 0)
+		if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0)
 			break;
 
 		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-			tty->flip.work.func((void *)tty);
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-				printk(KERN_WARNING "TTY_DONT_FLIP set\n");
-				goto out;
-			}
+			if (tty->low_latency)
+				tty_flip_buffer_push(tty);
+
+			/*
+			 * If this failed then we will throw away the
+			 * bytes but must do so to clear interrupts
+			 */
 		}
 
+		uerstat = rd_regl(port, S3C2410_UERSTAT);
 		ch = rd_regb(port, S3C2410_URXH);
 
-		*tty->flip.char_buf_ptr = ch;
-		*tty->flip.flag_buf_ptr = TTY_NORMAL;
+		if (port->flags & UPF_CONS_FLOW) {
+			int txe = s3c24xx_serial_txempty_nofifo(port);
+
+			if (rx_enabled(port)) {
+				if (!txe) {
+					rx_enabled(port) = 0;
+					continue;
+				}
+			} else {
+				if (txe) {
+					ufcon |= S3C2410_UFCON_RESETRX;
+					wr_regl(port, S3C2410_UFCON, ufcon);
+					rx_enabled(port) = 1;
+					goto out;
+				}
+				continue;
+			}
+		}
+
+		/* insert the character into the buffer */
+
+		flag = TTY_NORMAL;
 		port->icount.rx++;
 
-		rxs = rd_regb(port, S3C2410_UERSTAT) | RXSTAT_DUMMY_READ;
+		if (uerstat & S3C2410_UERSTAT_ANY) {
+			dbg("rxerr: port ch=0x%02x, rxs=0x%08x\n",
+			    ch, uerstat);
+
+			/* check for break */
+			if (uerstat & S3C2410_UERSTAT_BREAK) {
+				dbg("break!\n");
+				port->icount.brk++;
+				if (uart_handle_break(port))
+				    goto ignore_char;
+			}
 
-		if (rxs & S3C2410_UERSTAT_ANY) {
-			if (rxs & S3C2410_UERSTAT_FRAME)
+			if (uerstat & S3C2410_UERSTAT_FRAME)
 				port->icount.frame++;
-			if (rxs & S3C2410_UERSTAT_OVERRUN)
+			if (uerstat & S3C2410_UERSTAT_OVERRUN)
 				port->icount.overrun++;
 
-			rxs &= port->read_status_mask;
+			uerstat &= port->read_status_mask;
 
-			if (rxs & S3C2410_UERSTAT_PARITY)
-				*tty->flip.flag_buf_ptr = TTY_PARITY;
-			else if (rxs & ( S3C2410_UERSTAT_FRAME | S3C2410_UERSTAT_OVERRUN))
-				*tty->flip.flag_buf_ptr = TTY_FRAME;
+			if (uerstat & S3C2410_UERSTAT_BREAK)
+				flag = TTY_BREAK;
+			else if (uerstat & S3C2410_UERSTAT_PARITY)
+				flag = TTY_PARITY;
+			else if (uerstat & ( S3C2410_UERSTAT_FRAME | S3C2410_UERSTAT_OVERRUN))
+				flag = TTY_FRAME;
 		}
 
-		if ((rxs & port->ignore_status_mask) == 0) {
-			tty->flip.flag_buf_ptr++;
-			tty->flip.char_buf_ptr++;
-			tty->flip.count++;
+		if (uart_handle_sysrq_char(port, ch, regs))
+			goto ignore_char;
+
+		if ((uerstat & port->ignore_status_mask) == 0) {
+			tty_insert_flip_char(tty, ch, flag);
 		}
 
-		if ((rxs & S3C2410_UERSTAT_OVERRUN) &&
+		if ((uerstat & S3C2410_UERSTAT_OVERRUN) &&
 		    tty->flip.count < TTY_FLIPBUF_SIZE) {
 			/*
 			 * Overrun is special, since it's reported
 			 * immediately, and doesn't affect the current
 			 * character.
 			 */
-			*tty->flip.char_buf_ptr++ = 0;
-			*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
-			tty->flip.count++;
+
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
 		}
+
+	ignore_char:
+		continue;
 	}
 	tty_flip_buffer_push(tty);
 
@@ -175,10 +401,10 @@
 	return IRQ_HANDLED;
 }
 
-static irqreturn_t
-serial_s3c2410_tx_chars(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id, struct pt_regs *regs)
 {
-	struct uart_port *port = (struct uart_port *)dev_id;
+	struct s3c24xx_uart_port *ourport = id;
+	struct uart_port *port = &ourport->port;
 	struct circ_buf *xmit = &port->info->xmit;
 	int count = 256;
 
@@ -194,14 +420,14 @@
 	*/
 
 	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-		serial_s3c2410_stop_tx(port, 0);
+		s3c24xx_serial_stop_tx(port, 0);
 		goto out;
 	}
 
 	/* try and drain the buffer... */
 
 	while (!uart_circ_empty(xmit) && count-- > 0) {
-		if (rd_regl(port, S3C2410_UFSTAT) & S3C2410_UFSTAT_TXFULL)
+		if (rd_regl(port, S3C2410_UFSTAT) & ourport->info->tx_fifofull)
 			break;
 
 		wr_regb(port, S3C2410_UTXH, xmit->buf[xmit->tail]);
@@ -213,22 +439,31 @@
 		uart_write_wakeup(port);
 
 	if (uart_circ_empty(xmit))
-		serial_s3c2410_stop_tx(port, 0);
+		s3c24xx_serial_stop_tx(port, 0);
 
  out:
 	return IRQ_HANDLED;
 }
 
-static unsigned int
-serial_s3c2410_tx_empty(struct uart_port *port)
+static unsigned int s3c24xx_serial_tx_empty(struct uart_port *port)
 {
-	unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
-	return (S3C2410_UFCON_TXC(ufcon) != 0) ? 0 : TIOCSER_TEMT;
+	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+	unsigned long ufstat = rd_regl(port, S3C2410_UFSTAT);
+	unsigned long ufcon = rd_regl(port, S3C2410_UFCON);
+
+	if (ufcon & S3C2410_UFCON_FIFOMODE) {
+		if ((ufstat & info->tx_fifomask) != 0 ||
+		    (ufstat & info->tx_fifofull))
+			return 0;
+
+		return 1;
+	}
+
+	return s3c24xx_serial_txempty_nofifo(port);
 }
 
 /* no modem control lines */
-static unsigned int
-serial_s3c2410_get_mctrl(struct uart_port *port)
+static unsigned int s3c24xx_serial_get_mctrl(struct uart_port *port)
 {
 	unsigned int umstat = rd_regb(port,S3C2410_UMSTAT);
 
@@ -238,13 +473,12 @@
 		return TIOCM_CAR | TIOCM_DSR;
 }
 
-static void
-serial_s3c2410_set_mctrl(struct uart_port *port, unsigned int mctrl)
+static void s3c24xx_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
 	/* todo - possibly remove AFC and do manual CTS */
 }
 
-static void serial_s3c2410_break_ctl(struct uart_port *port, int break_state)
+static void s3c24xx_serial_break_ctl(struct uart_port *port, int break_state)
 {
 	unsigned long flags;
 	unsigned int ucon;
@@ -263,46 +497,250 @@
 	spin_unlock_irqrestore(&port->lock, flags);
 }
 
-static int serial_s3c2410_startup(struct uart_port *port)
+static void s3c24xx_serial_shutdown(struct uart_port *port)
 {
+	struct s3c24xx_uart_port *ourport = to_ourport(port);
+
+	if (ourport->tx_claimed) {
+		free_irq(TX_IRQ(port), ourport);
+		tx_enabled(port) = 0;
+		ourport->tx_claimed = 0;
+	}
+
+	if (ourport->rx_claimed) {
+		free_irq(RX_IRQ(port), ourport);
+		ourport->rx_claimed = 0;
+		rx_enabled(port) = 0;
+	}
+}
+
+
+static int s3c24xx_serial_startup(struct uart_port *port)
+{
+	struct s3c24xx_uart_port *ourport = to_ourport(port);
+	unsigned long flags;
 	int ret;
 
-	tx_enabled(port) = 1;
-	rx_enabled(port) = 1;
+	dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
+	    port->mapbase, port->membase);
 
-	dbg("serial_s3c2410_startup: port=%p (%p)\n",
-	    port, port->mapbase);
+	local_irq_save(flags);
+
+	rx_enabled(port) = 1;
 
-	ret = request_irq(RX_IRQ(port), serial_s3c2410_rx_chars, 0,
-			  serial_s3c2410_name, port);
+	ret = request_irq(RX_IRQ(port),
+			  s3c24xx_serial_rx_chars, 0,
+			  s3c24xx_serial_portname(port), ourport);
 
-	if (ret != 0)
+	if (ret != 0) {
+		printk(KERN_ERR "cannot get irq %d\n", RX_IRQ(port));
 		return ret;
+	}
+
+	ourport->rx_claimed = 1;
+
+	dbg("requesting tx irq...\n");
+
+	tx_enabled(port) = 1;
 
-	ret = request_irq(TX_IRQ(port), serial_s3c2410_tx_chars, 0,
-			  serial_s3c2410_name, port);
+	ret = request_irq(TX_IRQ(port),
+			  s3c24xx_serial_tx_chars, 0,
+			  s3c24xx_serial_portname(port), ourport);
 
 	if (ret) {
-		free_irq(RX_IRQ(port), port);
-		return ret;
+		printk(KERN_ERR "cannot get irq %d\n", TX_IRQ(port));
+		goto err;
 	}
 
+	ourport->tx_claimed = 1;
+
+	dbg("s3c24xx_serial_startup ok\n");
+
 	/* the port reset code should have done the correct
 	 * register setup for the port controls */
 
+	local_irq_restore(flags);
+	return ret;
+
+ err:
+	s3c24xx_serial_shutdown(port);
+	local_irq_restore(flags);
 	return ret;
 }
 
-static void serial_s3c2410_shutdown(struct uart_port *port)
+/* power power management control */
+
+static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level,
+			      unsigned int old)
 {
-	free_irq(TX_IRQ(port), port);
-	free_irq(RX_IRQ(port), port);
+	struct s3c24xx_uart_port *ourport = to_ourport(port);
+
+	switch (level) {
+	case 3:
+		if (!IS_ERR(ourport->baudclk) && ourport->baudclk != NULL)
+			clk_disable(ourport->baudclk);
+
+		clk_disable(ourport->clk);
+		break;
+
+	case 0:
+		clk_enable(ourport->clk);
+
+		if (!IS_ERR(ourport->baudclk) && ourport->baudclk != NULL)
+			clk_enable(ourport->baudclk);
+
+		break;
+	default:
+		printk(KERN_ERR "s3c24xx_serial: unknown pm %d\n", level);
+	}
 }
 
-static void
-serial_s3c2410_set_termios(struct uart_port *port, struct termios *termios,
-			   struct termios *old)
+/* baud rate calculation
+ *
+ * The UARTs on the S3C2410/S3C2440 can take their clocks from a number
+ * of different sources, including the peripheral clock ("pclk") and an
+ * external clock ("uclk"). The S3C2440 also adds the core clock ("fclk")
+ * with a programmable extra divisor.
+ *
+ * The following code goes through the clock sources, and calculates the
+ * baud clocks (and the resultant actual baud rates) and then tries to
+ * pick the closest one and select that.
+ *
+ * NOTES:
+ *	1) there is no current code to properly select/deselect FCLK on
+ *	   the s3c2440, so only specify FCLK or non-FCLK in the clock
+ *	   sources for the UART
+ *
+*/
+
+
+#define MAX_CLKS (8)
+
+static struct s3c24xx_uart_clksrc tmp_clksrc = {
+	.name		= "pclk",
+	.min_baud	= 0,
+	.max_baud	= 0,
+	.divisor	= 1,
+};
+
+static inline int
+s3c24xx_serial_getsource(struct uart_port *port, struct s3c24xx_uart_clksrc *c)
+{
+	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+
+	return (info->get_clksrc)(port, c);
+}
+
+static inline int
+s3c24xx_serial_setsource(struct uart_port *port, struct s3c24xx_uart_clksrc *c)
+{
+	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+
+	return (info->set_clksrc)(port, c);
+}
+
+struct baud_calc {
+	struct s3c24xx_uart_clksrc	*clksrc;
+	unsigned int			 calc;
+	unsigned int			 quot;
+	struct clk			*src;
+};
+
+static int s3c24xx_serial_calcbaud(struct baud_calc *calc,
+				   struct uart_port *port,
+				   struct s3c24xx_uart_clksrc *clksrc,
+				   unsigned int baud)
+{
+	unsigned long rate;
+
+	calc->src = clk_get(port->dev, clksrc->name);
+	if (calc->src == NULL || IS_ERR(calc->src))
+		return 0;
+
+	rate = clk_get_rate(calc->src);
+
+	calc->clksrc = clksrc;
+	calc->quot = (rate + (8 * baud)) / (16 * baud);
+	calc->calc = (rate / (calc->quot * 16));
+
+	calc->quot--;
+	return 1;
+}
+
+static unsigned int s3c24xx_serial_getclk(struct uart_port *port,
+					  struct s3c24xx_uart_clksrc **clksrc,
+					  struct clk **clk,
+					  unsigned int baud)
+{
+	struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
+	struct s3c24xx_uart_clksrc *clkp;
+	struct baud_calc res[MAX_CLKS];
+	struct baud_calc *resptr, *best, *sptr;
+	int i;
+
+	clkp = cfg->clocks;
+	best = NULL;
+
+	if (cfg->clocks_size < 2) {
+		if (cfg->clocks_size == 0)
+			clkp = &tmp_clksrc;
+
+		s3c24xx_serial_calcbaud(res, port, clkp, baud);
+		best = res;
+		resptr = best + 1;
+	} else {
+		resptr = res;
+
+		for (i = 0; i < cfg->clocks_size; i++, clkp++) {
+			if (s3c24xx_serial_calcbaud(resptr, port, clkp, baud))
+				resptr++;
+		}
+	}
+
+	/* ok, we now need to select the best clock we found */
+
+	if (!best) {
+		unsigned int deviation = (1<<30)|((1<<30)-1);
+		int calc_deviation;
+
+		for (sptr = res; sptr < resptr; sptr++) {
+			printk(KERN_DEBUG
+			       "found clk %p (%s) quot %d, calc %d\n",
+			       sptr->clksrc, sptr->clksrc->name,
+			       sptr->quot, sptr->calc);
+
+			calc_deviation = baud - sptr->calc;
+			if (calc_deviation < 0)
+				calc_deviation = -calc_deviation;
+
+			if (calc_deviation < deviation) {
+				best = sptr;
+				deviation = calc_deviation;
+			}
+		}
+
+		printk(KERN_DEBUG "best %p (deviation %d)\n", best, deviation);
+	}
+
+	printk(KERN_DEBUG "selected clock %p (%s) quot %d, calc %d\n",
+	       best->clksrc, best->clksrc->name, best->quot, best->calc);
+
+	/* store results to pass back */
+
+	*clksrc = best->clksrc;
+	*clk    = best->src;
+
+	return best->quot;
+}
+
+static void s3c24xx_serial_set_termios(struct uart_port *port,
+				       struct termios *termios,
+				       struct termios *old)
 {
+	struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
+	struct s3c24xx_uart_port *ourport = to_ourport(port);
+	struct s3c24xx_uart_clksrc *clksrc;
+	struct clk *clk;
 	unsigned long flags;
 	unsigned int baud, quot;
 	unsigned int ulcon;
@@ -314,15 +752,33 @@
 	termios->c_cflag |= CLOCAL;
 
 	/*
-	 * We don't support BREAK character recognition.
-	 */
-	termios->c_iflag &= ~(IGNBRK | BRKINT);
-
-	/*
 	 * Ask the core to calculate the divisor for us.
 	 */
-	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
-	quot = uart_get_divisor(port, baud);
+
+	baud = uart_get_baud_rate(port, termios, old, 0, 115200*8);
+
+	if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST)
+		quot = port->custom_divisor;
+	else
+		quot = s3c24xx_serial_getclk(port, &clksrc, &clk, baud);
+
+	/* check to see if we need  to change clock source */
+
+	if (ourport->clksrc != clksrc || ourport->baudclk != clk) {
+		s3c24xx_serial_setsource(port, clksrc);
+
+		if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) {
+			clk_disable(ourport->baudclk);
+			clk_unuse(ourport->baudclk);
+			ourport->baudclk  = NULL;
+		}
+
+		clk_use(clk);
+		clk_enable(clk);
+
+		ourport->clksrc = clksrc;
+		ourport->baudclk = clk;
+	}
 
 	switch (termios->c_cflag & CSIZE) {
 	case CS5:
@@ -344,6 +800,9 @@
 		break;
 	}
 
+	/* preserve original lcon IR settings */
+	ulcon |= (cfg->ulcon & S3C2410_LCON_IRM);
+
 	if (termios->c_cflag & CSTOPB)
 		ulcon |= S3C2410_LCON_STOPB;
 
@@ -356,18 +815,12 @@
 		ulcon |= S3C2410_LCON_PNONE;
 	}
 
-	/*
-	if (port->fifosize)
-	enable_fifo()
-	*/
-
 	spin_lock_irqsave(&port->lock, flags);
 
-	dbg("setting ulcon to %08x\n", ulcon);
-	//dbg("<flushing output from serial>\n");
+	dbg("setting ulcon to %08x, brddiv to %d\n", ulcon, quot);
 
-	/* set the ulcon register */
 	wr_regl(port, S3C2410_ULCON, ulcon);
+	wr_regl(port, S3C2410_UBRDIV, quot);
 
 	dbg("uart: ulcon = 0x%08x, ucon = 0x%08x, ufcon = 0x%08x\n",
 	    rd_regl(port, S3C2410_ULCON),
@@ -404,113 +857,151 @@
 	spin_unlock_irqrestore(&port->lock, flags);
 }
 
-static const char *serial_s3c2410_type(struct uart_port *port)
+static const char *s3c24xx_serial_type(struct uart_port *port)
 {
-	return port->type == PORT_S3C2410 ? "S3C2410" : NULL;
+	switch (port->type) {
+	case PORT_S3C2410:
+		return "S3C2410";
+	case PORT_S3C2440:
+		return "S3C2440";
+	default:
+		return NULL;
+	}
 }
 
 #define MAP_SIZE (0x100)
 
-static void
-serial_s3c2410_release_port(struct uart_port *port)
+static void s3c24xx_serial_release_port(struct uart_port *port)
 {
 	release_mem_region(port->mapbase, MAP_SIZE);
 }
 
-static int
-serial_s3c2410_request_port(struct uart_port *port)
+static int s3c24xx_serial_request_port(struct uart_port *port)
 {
-	return request_mem_region(port->mapbase, MAP_SIZE, serial_s3c2410_name)
-		!= NULL ? 0 : -EBUSY;
+	char *name = s3c24xx_serial_portname(port);
+	return request_mem_region(port->mapbase, MAP_SIZE, name) ? 0 : -EBUSY;
 }
 
-static void
-serial_s3c2410_config_port(struct uart_port *port, int flags)
+static void s3c24xx_serial_config_port(struct uart_port *port, int flags)
 {
+	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+
 	if (flags & UART_CONFIG_TYPE &&
-	    serial_s3c2410_request_port(port) == 0)
-		port->type = PORT_S3C2410;
+	    s3c24xx_serial_request_port(port) == 0)
+		port->type = info->type;
 }
 
 /*
  * verify the new serial_struct (for TIOCSSERIAL).
  */
 static int
-serial_s3c2410_verify_port(struct uart_port *port, struct serial_struct *ser)
+s3c24xx_serial_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
-	int ret = 0;
+	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 
-	if (ser->type != PORT_UNKNOWN && ser->type != PORT_S3C2410)
-		ret = -EINVAL;
+	if (ser->type != PORT_UNKNOWN && ser->type != info->type)
+		return -EINVAL;
 
-	return ret;
+	return 0;
 }
 
-static struct uart_ops serial_s3c2410_ops = {
-	.tx_empty	= serial_s3c2410_tx_empty,
-	.get_mctrl	= serial_s3c2410_get_mctrl,
-	.set_mctrl	= serial_s3c2410_set_mctrl,
-	.stop_tx	= serial_s3c2410_stop_tx,
-	.start_tx	= serial_s3c2410_start_tx,
-	.stop_rx	= serial_s3c2410_stop_rx,
-	.enable_ms	= serial_s3c2410_enable_ms,
-	.break_ctl	= serial_s3c2410_break_ctl,
-	.startup	= serial_s3c2410_startup,
-	.shutdown	= serial_s3c2410_shutdown,
-	.set_termios	= serial_s3c2410_set_termios,
-	.type		= serial_s3c2410_type,
-	.release_port	= serial_s3c2410_release_port,
-	.request_port	= serial_s3c2410_request_port,
-	.config_port	= serial_s3c2410_config_port,
-	.verify_port	= serial_s3c2410_verify_port,
-};
-
-static struct uart_port serial_s3c2410_ports[NR_PORTS] = {
-	{
-		.membase	= 0,
-		.mapbase	= 0,
-		.iotype		= UPIO_MEM,
-		.irq		= IRQ_S3CUART_RX0,
-		.uartclk	= 0,
-		.fifosize	= 16,
-		.ops		= &serial_s3c2410_ops,
-		.flags		= UPF_BOOT_AUTOCONF,
-		.line		= 0,
+
+#ifdef CONFIG_SERIAL_S3C2410_CONSOLE
+
+static struct console s3c24xx_serial_console;
+
+#define S3C24XX_SERIAL_CONSOLE &s3c24xx_serial_console
+#else
+#define S3C24XX_SERIAL_CONSOLE NULL
+#endif
+
+static struct uart_ops s3c24xx_serial_ops = {
+	.pm		= s3c24xx_serial_pm,
+	.tx_empty	= s3c24xx_serial_tx_empty,
+	.get_mctrl	= s3c24xx_serial_get_mctrl,
+	.set_mctrl	= s3c24xx_serial_set_mctrl,
+	.stop_tx	= s3c24xx_serial_stop_tx,
+	.start_tx	= s3c24xx_serial_start_tx,
+	.stop_rx	= s3c24xx_serial_stop_rx,
+	.enable_ms	= s3c24xx_serial_enable_ms,
+	.break_ctl	= s3c24xx_serial_break_ctl,
+	.startup	= s3c24xx_serial_startup,
+	.shutdown	= s3c24xx_serial_shutdown,
+	.set_termios	= s3c24xx_serial_set_termios,
+	.type		= s3c24xx_serial_type,
+	.release_port	= s3c24xx_serial_release_port,
+	.request_port	= s3c24xx_serial_request_port,
+	.config_port	= s3c24xx_serial_config_port,
+	.verify_port	= s3c24xx_serial_verify_port,
+};
+
+
+static struct uart_driver s3c24xx_uart_drv = {
+	.owner		= THIS_MODULE,
+	.dev_name	= "s3c2410_serial",
+	.nr		= 3,
+	.cons		= S3C24XX_SERIAL_CONSOLE,
+	.driver_name	= S3C24XX_SERIAL_NAME,
+	.devfs_name	= S3C24XX_SERIAL_DEVFS,
+	.major		= S3C24XX_SERIAL_MAJOR,
+	.minor		= S3C24XX_SERIAL_MINOR,
+};
+
+static struct s3c24xx_uart_port s3c24xx_serial_ports[NR_PORTS] = {
+	[0] = {
+		.port = {
+			.lock		= SPIN_LOCK_UNLOCKED,
+			.membase	= 0,
+			.mapbase	= 0,
+			.iotype		= UPIO_MEM,
+			.irq		= IRQ_S3CUART_RX0,
+			.uartclk	= 0,
+			.fifosize	= 16,
+			.ops		= &s3c24xx_serial_ops,
+			.flags		= UPF_BOOT_AUTOCONF,
+			.line		= 0,
+		}
+	},
+	[1] = {
+		.port = {
+			.lock		= SPIN_LOCK_UNLOCKED,
+			.membase	= 0,
+			.mapbase	= 0,
+			.iotype		= UPIO_MEM,
+			.irq		= IRQ_S3CUART_RX1,
+			.uartclk	= 0,
+			.fifosize	= 16,
+			.ops		= &s3c24xx_serial_ops,
+			.flags		= UPF_BOOT_AUTOCONF,
+			.line		= 1,
+		}
 	},
-	{
-		.membase	= 0,
-		.mapbase	= 0,
-		.iotype		= UPIO_MEM,
-		.irq		= IRQ_S3CUART_RX1,
-		.uartclk	= 0,
-		.fifosize	= 16,
-		.ops		= &serial_s3c2410_ops,
-		.flags		= UPF_BOOT_AUTOCONF,
-		.line		= 1,
-	}
 #if NR_PORTS > 2
-	,
-	{
-		.membase	= 0,
-		.mapbase	= 0,
-		.iotype		= UPIO_MEM,
-		.irq		= IRQ_S3CUART_RX2,
-		.uartclk	= 0,
-		.fifosize	= 16,
-		.ops		= &serial_s3c2410_ops,
-		.flags		= UPF_BOOT_AUTOCONF,
-		.line		= 2,
+
+	[2] = {
+		.port = {
+			.lock		= SPIN_LOCK_UNLOCKED,
+			.membase	= 0,
+			.mapbase	= 0,
+			.iotype		= UPIO_MEM,
+			.irq		= IRQ_S3CUART_RX2,
+			.uartclk	= 0,
+			.fifosize	= 16,
+			.ops		= &s3c24xx_serial_ops,
+			.flags		= UPF_BOOT_AUTOCONF,
+			.line		= 2,
+		}
 	}
 #endif
 };
 
-static int
-serial_s3c2410_resetport(struct uart_port *port,
-			 struct s3c2410_uartcfg *cfg)
+
+static int s3c24xx_serial_resetport(struct uart_port *port,
+				    struct s3c2410_uartcfg *cfg)
 {
 	/* ensure registers are setup */
 
-	dbg("serial_s3c2410_resetport: port=%p (%08x), cfg=%p\n",
+	dbg("s3c24xx_serial_resetport: port=%p (%08lx), cfg=%p\n",
 	    port, port->mapbase, cfg);
 
 	wr_regl(port, S3C2410_UCON,  cfg->ucon);
@@ -524,105 +1015,431 @@
 	return 0;
 }
 
-/* serial_s3c2410_init_ports
+/* s3c24xx_serial_init_port
  *
- * initialise the serial ports from the machine provided initialisation
- * data.
-*/
+ * initialise a single serial port from the platform device given
+ */
 
-static int serial_s3c2410_init_ports(void)
+static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
+				    struct s3c24xx_uart_info *info,
+				    struct platform_device *platdev)
 {
-	struct uart_port *ptr = serial_s3c2410_ports;
-	struct s3c2410_uartcfg *cfg = s3c2410_uartcfgs;
-	static int inited = 0;
-	int i;
+	struct uart_port *port = &ourport->port;
+	struct s3c2410_uartcfg *cfg;
+	struct resource *res;
+
+	dbg("s3c24xx_serial_init_port: port=%p, platdev=%p\n", port, platdev);
 
-	if (inited)
+	if (platdev == NULL)
+		return -ENODEV;
+
+	cfg = s3c24xx_dev_to_cfg(&platdev->dev);
+
+	if (port->mapbase != 0)
 		return 0;
-	inited = 1;
 
-	dbg("serial_s3c2410_init_ports: initialising ports...\n");
+	if (cfg->hwport > 3)
+		return -EINVAL;
 
-	for (i = 0; i < NR_PORTS; i++, ptr++, cfg++) {
+	/* setup info for port */
+	port->dev	= &platdev->dev;
+	ourport->info	= info;
 
-		if (cfg->hwport > 3)
-			continue;
+	/* copy the info in from provided structure */
+	ourport->port.fifosize = info->fifosize;
 
-		dbg("serial_s3c2410_init_ports: port %d (hw %d)...\n",
-		    i, cfg->hwport);
+	dbg("s3c24xx_serial_init_port: %p (hw %d)...\n", port, cfg->hwport);
 
-		if (cfg->clock != NULL)
-			ptr->uartclk = *cfg->clock;
+	port->uartclk = 1;
 
-		switch (cfg->hwport) {
-		case 0:
-			ptr->mapbase = S3C2410_PA_UART0;
-			ptr->membase = (char *)S3C2410_VA_UART0;
-			ptr->irq     = IRQ_S3CUART_RX0;
-			break;
+	if (cfg->uart_flags & UPF_CONS_FLOW) {
+		dbg("s3c24xx_serial_init_port: enabling flow control\n");
+		port->flags |= UPF_CONS_FLOW;
+	}
 
-		case 1:
-			ptr->mapbase = S3C2410_PA_UART1;
-			ptr->membase = (char *)S3C2410_VA_UART1;
-			ptr->irq     = IRQ_S3CUART_RX1;
-			break;
+	/* sort our the physical and virtual addresses for each UART */
 
-		case 2:
-			ptr->mapbase = S3C2410_PA_UART2;
-			ptr->membase = (char *)S3C2410_VA_UART2;
-			ptr->irq     = IRQ_S3CUART_RX2;
-			break;
-		}
+	res = platform_get_resource(platdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		printk(KERN_ERR "failed to find memory resource for uart\n");
+		return -EINVAL;
+	}
+
+	dbg("resource %p (%lx..%lx)\n", res, res->start, res->end);
+
+	port->mapbase	= res->start;
+	port->membase	= (void __iomem *)(res->start - S3C2410_PA_UART);
+	port->membase  += S3C2410_VA_UART;
+	port->irq	= platform_get_irq(platdev, 0);
+
+	ourport->clk	= clk_get(&platdev->dev, "uart");
+
+	if (ourport->clk != NULL && !IS_ERR(ourport->clk))
+		clk_use(ourport->clk);
+
+	dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n",
+	    port->mapbase, port->membase, port->irq, port->uartclk);
+
+	/* reset the fifos (and setup the uart) */
+	s3c24xx_serial_resetport(port, cfg);
+	return 0;
+}
+
+/* Device driver serial port probe */
 
-		if (ptr->mapbase == 0)
-			continue;
+static int probe_index = 0;
+
+int s3c24xx_serial_probe(struct device *_dev,
+			 struct s3c24xx_uart_info *info)
+{
+	struct s3c24xx_uart_port *ourport;
+	struct platform_device *dev = to_platform_device(_dev);
+	int ret;
+
+	dbg("s3c24xx_serial_probe(%p, %p) %d\n", _dev, info, probe_index);
+
+	ourport = &s3c24xx_serial_ports[probe_index];
+	probe_index++;
+
+	dbg("%s: initialising port %p...\n", __FUNCTION__, ourport);
+
+	ret = s3c24xx_serial_init_port(ourport, info, dev);
+	if (ret < 0)
+		goto probe_err;
+
+	dbg("%s: adding port\n", __FUNCTION__);
+	uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
+	dev_set_drvdata(_dev, &ourport->port);
+
+	return 0;
+
+ probe_err:
+	return ret;
+}
+
+int s3c24xx_serial_remove(struct device *_dev)
+{
+	struct uart_port *port = s3c24xx_dev_to_port(_dev);
 
-		/* reset the fifos (and setup the uart */
-		serial_s3c2410_resetport(ptr, cfg);
+	if (port)
+		uart_remove_one_port(&s3c24xx_uart_drv, port);
+
+	return 0;
+}
+
+/* UART power management code */
+
+#ifdef CONFIG_PM
+
+int s3c24xx_serial_suspend(struct device *dev, u32 state, u32 level)
+{
+	struct uart_port *port = s3c24xx_dev_to_port(dev);
+
+	if (port && level == SUSPEND_DISABLE)
+		uart_suspend_port(&s3c24xx_uart_drv, port);
+
+	return 0;
+}
+
+int s3c24xx_serial_resume(struct device *dev, u32 level)
+{
+	struct uart_port *port = s3c24xx_dev_to_port(dev);
+	struct s3c24xx_uart_port *ourport = to_ourport(port);
+
+	if (port && level == RESUME_ENABLE) {
+		clk_enable(ourport->clk);
+		s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port));
+		clk_disable(ourport->clk);
+
+		uart_resume_port(&s3c24xx_uart_drv, port);
 	}
 
 	return 0;
 }
 
+#else
+#define s3c24xx_serial_suspend NULL
+#define s3c24xx_serial_resume  NULL
+#endif
+
+int s3c24xx_serial_init(struct device_driver *drv,
+			struct s3c24xx_uart_info *info)
+{
+	dbg("s3c24xx_serial_init(%p,%p)\n", drv, info);
+	return driver_register(drv);
+}
+
+
+/* now comes the code to initialise either the s3c2410 or s3c2440 serial
+ * port information
+*/
+
+/* cpu specific variations on the serial port support */
+
+#ifdef CONFIG_CPU_S3C2410
+
+static int s3c2410_serial_setsource(struct uart_port *port,
+				    struct s3c24xx_uart_clksrc *clk)
+{
+	unsigned long ucon = rd_regl(port, S3C2410_UCON);
+
+	if (strcmp(clk->name, "uclk") == 0)
+		ucon |= S3C2410_UCON_UCLK;
+	else
+		ucon &= ~S3C2410_UCON_UCLK;
+
+	wr_regl(port, S3C2410_UCON, ucon);
+	return 0;
+}
+
+static int s3c2410_serial_getsource(struct uart_port *port,
+				    struct s3c24xx_uart_clksrc *clk)
+{
+	unsigned long ucon = rd_regl(port, S3C2410_UCON);
+
+	clk->divisor = 1;
+	clk->name = (ucon & S3C2410_UCON_UCLK) ? "uclk" : "pclk";
+
+	return 0;
+}
+
+static struct s3c24xx_uart_info s3c2410_uart_inf = {
+	.name		= "Samsung S3C2410 UART",
+	.type		= PORT_S3C2410,
+	.fifosize	= 16,
+	.rx_fifomask	= S3C2410_UFSTAT_RXMASK,
+	.rx_fifoshift	= S3C2410_UFSTAT_RXSHIFT,
+	.rx_fifofull	= S3C2410_UFSTAT_RXFULL,
+	.tx_fifofull	= S3C2410_UFSTAT_TXFULL,
+	.tx_fifomask	= S3C2410_UFSTAT_TXMASK,
+	.tx_fifoshift	= S3C2410_UFSTAT_TXSHIFT,
+	.get_clksrc	= s3c2410_serial_getsource,
+	.set_clksrc	= s3c2410_serial_setsource,
+};
+
+/* device management */
+
+static int s3c2410_serial_probe(struct device *dev)
+{
+	return s3c24xx_serial_probe(dev, &s3c2410_uart_inf);
+}
+
+static struct device_driver s3c2410_serial_drv = {
+	.name		= "s3c2410-uart",
+	.bus		= &platform_bus_type,
+	.probe		= s3c2410_serial_probe,
+	.remove		= s3c24xx_serial_remove,
+	.suspend	= s3c24xx_serial_suspend,
+	.resume		= s3c24xx_serial_resume,
+};
+
+static inline int s3c2410_serial_init(void)
+{
+	return s3c24xx_serial_init(&s3c2410_serial_drv, &s3c2410_uart_inf);
+}
+
+static inline void s3c2410_serial_exit(void)
+{
+	driver_unregister(&s3c2410_serial_drv);
+}
+
+#define s3c2410_uart_inf_at &s3c2410_uart_inf
+#else
+
+static inline int s3c2410_serial_init(void)
+{
+	return 0;
+}
+
+static inline void s3c2410_serial_exit(void)
+{
+}
+
+#define s3c2410_uart_inf_at NULL
+
+#endif /* CONFIG_CPU_S3C2410 */
+
+#ifdef CONFIG_CPU_S3C2440
+
+static int s3c2440_serial_setsource(struct uart_port *port,
+				     struct s3c24xx_uart_clksrc *clk)
+{
+	unsigned long ucon = rd_regl(port, S3C2410_UCON);
+
+	// todo - proper fclk<>nonfclk switch //
+
+	ucon &= ~S3C2440_UCON_CLKMASK;
+
+	if (strcmp(clk->name, "uclk") == 0)
+		ucon |= S3C2440_UCON_UCLK;
+	else if (strcmp(clk->name, "pclk") == 0)
+		ucon |= S3C2440_UCON_PCLK;
+	else if (strcmp(clk->name, "fclk") == 0)
+		ucon |= S3C2440_UCON_FCLK;
+	else {
+		printk(KERN_ERR "unknown clock source %s\n", clk->name);
+		return -EINVAL;
+	}
+
+	wr_regl(port, S3C2410_UCON, ucon);
+	return 0;
+}
+
+
+static int s3c2440_serial_getsource(struct uart_port *port,
+				    struct s3c24xx_uart_clksrc *clk)
+{
+	unsigned long ucon = rd_regl(port, S3C2410_UCON);
+
+	switch (ucon & S3C2440_UCON_CLKMASK) {
+	case S3C2440_UCON_UCLK:
+		clk->divisor = 1;
+		clk->name = "uclk";
+		break;
+
+	case S3C2440_UCON_PCLK:
+	case S3C2440_UCON_PCLK2:
+		clk->divisor = 1;
+		clk->name = "pclk";
+		break;
+
+	case S3C2440_UCON_FCLK:
+		clk->divisor = 7; /* todo - work out divisor */
+		clk->name = "fclk";
+		break;
+	}
+
+	return 0;
+}
+
+
+static struct s3c24xx_uart_info s3c2440_uart_inf = {
+	.name		= "Samsung S3C2440 UART",
+	.type		= PORT_S3C2440,
+	.fifosize	= 64,
+	.rx_fifomask	= S3C2440_UFSTAT_RXMASK,
+	.rx_fifoshift	= S3C2440_UFSTAT_RXSHIFT,
+	.rx_fifofull	= S3C2440_UFSTAT_RXFULL,
+	.tx_fifofull	= S3C2440_UFSTAT_TXFULL,
+	.tx_fifomask	= S3C2440_UFSTAT_TXMASK,
+	.tx_fifoshift	= S3C2440_UFSTAT_TXSHIFT,
+	.get_clksrc	= s3c2440_serial_getsource,
+	.set_clksrc	= s3c2440_serial_setsource
+};
+
+/* device management */
+
+static int s3c2440_serial_probe(struct device *dev)
+{
+	dbg("s3c2440_serial_probe: dev=%p\n", dev);
+	return s3c24xx_serial_probe(dev, &s3c2440_uart_inf);
+}
+
+static struct device_driver s3c2440_serial_drv = {
+	.name		= "s3c2440-uart",
+	.bus		= &platform_bus_type,
+	.probe		= s3c2440_serial_probe,
+	.remove		= s3c24xx_serial_remove,
+	.suspend	= s3c24xx_serial_suspend,
+	.resume		= s3c24xx_serial_resume,
+};
+
+
+static inline int s3c2440_serial_init(void)
+{
+	return s3c24xx_serial_init(&s3c2440_serial_drv, &s3c2440_uart_inf);
+}
+
+static inline void s3c2440_serial_exit(void)
+{
+	driver_unregister(&s3c2440_serial_drv);
+}
+
+#define s3c2440_uart_inf_at &s3c2440_uart_inf
+#else
+
+static inline int s3c2440_serial_init(void)
+{
+	return 0;
+}
+
+static inline void s3c2440_serial_exit(void)
+{
+}
+
+#define s3c2440_uart_inf_at NULL
+#endif /* CONFIG_CPU_S3C2440 */
+
+/* module initialisation code */
+
+static int __init s3c24xx_serial_modinit(void)
+{
+	int ret;
+
+	ret = uart_register_driver(&s3c24xx_uart_drv);
+	if (ret < 0) {
+		printk(KERN_ERR "failed to register UART driver\n");
+		return -1;
+	}
+
+	s3c2410_serial_init();
+	s3c2440_serial_init();
+
+	return 0;
+}
+
+static void __exit s3c24xx_serial_modexit(void)
+{
+	s3c2410_serial_exit();
+	s3c2440_serial_exit();
+
+	uart_unregister_driver(&s3c24xx_uart_drv);
+}
+
+
+module_init(s3c24xx_serial_modinit);
+module_exit(s3c24xx_serial_modexit);
+
+/* Console code */
+
 #ifdef CONFIG_SERIAL_S3C2410_CONSOLE
 
 static struct uart_port *cons_uart;
 
 static int
-serial_s3c2410_console_txrdy(struct uart_port *port, unsigned int ufcon)
+s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon)
 {
+	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 	unsigned long ufstat, utrstat;
 
 	if (ufcon & S3C2410_UFCON_FIFOMODE) {
 		/* fifo mode - check ammount of data in fifo registers... */
 
 		ufstat = rd_regl(port, S3C2410_UFSTAT);
-
-		return S3C2410_UFCON_TXC(ufstat) < 12;
+		return (ufstat & info->tx_fifofull) ? 0 : 1;
 	}
 
 	/* in non-fifo mode, we go and use the tx buffer empty */
 
 	utrstat = rd_regl(port, S3C2410_UTRSTAT);
-
-	return (utrstat & S3C2410_UTRSTAT_TXFE) ? 1 : 0;
+	return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0;
 }
 
 static void
-serial_s3c2410_console_write(struct console *co, const char *s,
+s3c24xx_serial_console_write(struct console *co, const char *s,
 			     unsigned int count)
 {
 	int i;
 	unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
 
 	for (i = 0; i < count; i++) {
-		while (!serial_s3c2410_console_txrdy(cons_uart, ufcon))
+		while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon))
 			barrier();
 
 		wr_regb(cons_uart, S3C2410_UTXH, s[i]);
 
 		if (s[i] == '\n') {
-			while (!serial_s3c2410_console_txrdy(cons_uart, ufcon))
+			while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon))
 				barrier();
 
 			wr_regb(cons_uart, S3C2410_UTXH, '\r');
@@ -631,17 +1448,21 @@
 }
 
 static void __init
-serial_s3c2410_get_options(struct uart_port *port, int *baud,
+s3c24xx_serial_get_options(struct uart_port *port, int *baud,
 			   int *parity, int *bits)
 {
-
-	unsigned int ulcon, ucon, ubrdiv;
+	struct s3c24xx_uart_clksrc clksrc;
+	struct clk *clk;
+	unsigned int ulcon;
+	unsigned int ucon;
+	unsigned int ubrdiv;
+	unsigned long rate;
 
 	ulcon  = rd_regl(port, S3C2410_ULCON);
 	ucon   = rd_regl(port, S3C2410_UCON);
 	ubrdiv = rd_regl(port, S3C2410_UBRDIV);
 
-	dbg("serial_s3c2410_get_options: port=%p\n"
+	dbg("s3c24xx_serial_get_options: port=%p\n"
 	    "registers: ulcon=%08x, ucon=%08x, ubdriv=%08x\n",
 	    port, ulcon, ucon, ubrdiv);
 
@@ -673,21 +1494,53 @@
 			*parity = 'o';
 			break;
 
-		default:
 		case S3C2410_LCON_PNONE:
+		default:
 			*parity = 'n';
 		}
 
 		/* now calculate the baud rate */
 
-		*baud = port->uartclk / ( 16 * (ubrdiv + 1));
+		s3c24xx_serial_getsource(port, &clksrc);
+
+		clk = clk_get(port->dev, clksrc.name);
+		if (!IS_ERR(clk) && clk != NULL)
+			rate = clk_get_rate(clk);
+		else
+			rate = 1;
+
+
+		*baud = rate / ( 16 * (ubrdiv + 1));
 		dbg("calculated baud %d\n", *baud);
 	}
 
 }
 
+/* s3c24xx_serial_init_ports
+ *
+ * initialise the serial ports from the machine provided initialisation
+ * data.
+*/
+
+static int s3c24xx_serial_init_ports(struct s3c24xx_uart_info *info)
+{
+	struct s3c24xx_uart_port *ptr = s3c24xx_serial_ports;
+	struct platform_device **platdev_ptr;
+	int i;
+
+	dbg("s3c24xx_serial_init_ports: initialising ports...\n");
+
+	platdev_ptr = s3c24xx_uart_devs;
+
+	for (i = 0; i < NR_PORTS; i++, ptr++, platdev_ptr++) {
+		s3c24xx_serial_init_port(ptr, info, *platdev_ptr);
+	}
+
+	return 0;
+}
+
 static int __init
-serial_s3c2410_console_setup(struct console *co, char *options)
+s3c24xx_serial_console_setup(struct console *co, char *options)
 {
 	struct uart_port *port;
 	int baud = 9600;
@@ -695,23 +1548,26 @@
 	int parity = 'n';
 	int flow = 'n';
 
+	dbg("s3c24xx_serial_console_setup: co=%p (%d), %s\n",
+	    co, co->index, options);
+
 	/* is this a valid port */
 
 	if (co->index == -1 || co->index >= NR_PORTS)
 		co->index = 0;
 
-	port = &serial_s3c2410_ports[co->index];
+	port = &s3c24xx_serial_ports[co->index].port;
 
 	/* is the port configured? */
 
 	if (port->mapbase == 0x0) {
 		co->index = 0;
-		port = &serial_s3c2410_ports[co->index];
+		port = &s3c24xx_serial_ports[co->index].port;
 	}
 
 	cons_uart = port;
 
-	dbg("serial_s3c2410_console_setup: port=%p (%d)\n", port, co->index);
+	dbg("s3c24xx_serial_console_setup: port=%p (%d)\n", port, co->index);
 
 	/*
 	 * Check whether an invalid uart number has been specified, and
@@ -721,138 +1577,68 @@
 	if (options)
 		uart_parse_options(options, &baud, &parity, &bits, &flow);
 	else
-		serial_s3c2410_get_options(port, &baud, &parity, &bits);
+		s3c24xx_serial_get_options(port, &baud, &parity, &bits);
+
+	dbg("s3c24xx_serial_console_setup: baud %d\n", baud);
 
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
-static struct uart_driver s3c2410_uart_drv;
+/* s3c24xx_serial_initconsole
+ *
+ * initialise the console from one of the uart drivers
+*/
 
-static struct console serial_s3c2410_console =
+static struct console s3c24xx_serial_console =
 {
-	.name		= SERIAL_S3C2410_NAME,
-	.write		= serial_s3c2410_console_write,
+	.name		= S3C24XX_SERIAL_NAME,
 	.device		= uart_console_device,
-	.setup		= serial_s3c2410_console_setup,
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
-	.data		= &s3c2410_uart_drv,
-};
-
-static int __init s3c2410_console_init(void)
-{
-	dbg("s3c2410_console_init:\n");
-
-	serial_s3c2410_init_ports();
-	register_console(&serial_s3c2410_console);
-	return 0;
-}
-console_initcall(s3c2410_console_init);
-
-#define SERIAL_S3C2410_CONSOLE	&serial_s3c2410_console
-#else
-#define SERIAL_S3C2410_CONSOLE	NULL
-#endif
-
-static struct uart_driver s3c2410_uart_drv = {
-	.owner			= THIS_MODULE,
-	.driver_name		= SERIAL_S3C2410_NAME,
-	.dev_name		= SERIAL_S3C2410_NAME,
-	.major			= SERIAL_S3C2410_MAJOR,
-	.minor			= SERIAL_S3C2410_MINOR,
-	.nr			= 3,
-	.cons			= SERIAL_S3C2410_CONSOLE,
-};
-
-/* device driver */
-
-static int s3c2410_serial_probe(struct device *_dev);
-static int s3c2410_serial_remove(struct device *_dev);
-
-static struct device_driver s3c2410_serial_drv = {
-	.name		= "s3c2410-uart",
-	.bus		= &platform_bus_type,
-	.probe		= s3c2410_serial_probe,
-	.remove		= s3c2410_serial_remove,
-	.suspend	= NULL,
-	.resume		= NULL,
+	.write		= s3c24xx_serial_console_write,
+	.setup		= s3c24xx_serial_console_setup
 };
 
-#define s3c2410_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev)
 
-static int s3c2410_serial_probe(struct device *_dev)
+static int s3c24xx_serial_initconsole(void)
 {
-	struct platform_device *dev = to_platform_device(_dev);
-	struct resource *res = dev->resource;
-	int i;
-
-	dbg("s3c2410_serial_probe: dev=%p, _dev=%p, res=%p\n", _dev, dev, res);
-
-	for (i = 0; i < dev->num_resources; i++, res++)
-		if (res->flags & IORESOURCE_MEM)
-			break;
+	struct s3c24xx_uart_info *info;
+	struct platform_device *dev = s3c24xx_uart_devs[0];
 
-	if (i < dev->num_resources) {
-		struct uart_port *ptr = serial_s3c2410_ports;
+	dbg("s3c24xx_serial_initconsole\n");
 
-		for (i = 0; i < NR_PORTS; i++, ptr++) {
-			dbg("s3c2410_serial_probe: ptr=%p (%08x, %08x)\n",
-			    ptr, ptr->mapbase, ptr->membase);
+	/* select driver based on the cpu */
 
-			if (ptr->mapbase != res->start)
-				continue;
-
-			dbg("s3c2410_serial_probe: got device %p: port=%p\n",
-			    _dev, ptr);
-
-			uart_add_one_port(&s3c2410_uart_drv, ptr);
-			dev_set_drvdata(_dev, ptr);
-			break;
-		}
+	if (dev == NULL) {
+		printk(KERN_ERR "s3c24xx: no devices for console init\n");
+		return 0;
 	}
 
-	return 0;
-}
+	if (strcmp(dev->name, "s3c2410-uart") == 0) {
+		info = s3c2410_uart_inf_at;
+	} else if (strcmp(dev->name, "s3c2440-uart") == 0) {
+		info = s3c2440_uart_inf_at;
+	} else {
+		printk(KERN_ERR "s3c24xx: no driver for %s\n", dev->name);
+		return 0;
+	}
 
-static int s3c2410_serial_remove(struct device *_dev)
-{
-	struct uart_port *port = s3c2410_dev_to_port(_dev);
+	if (info == NULL) {
+		printk(KERN_ERR "s3c24xx: no driver for console\n");
+		return 0;
+	}
 
-	if (port)
-		uart_remove_one_port(&s3c2410_uart_drv, port);
+	s3c24xx_serial_console.data = &s3c24xx_uart_drv;
+	s3c24xx_serial_init_ports(info);
 
+	register_console(&s3c24xx_serial_console);
 	return 0;
 }
 
+console_initcall(s3c24xx_serial_initconsole);
 
-
-static int __init serial_s3c2410_init(void)
-{
-	int ret;
-
-	printk(KERN_INFO "S3C2410X Serial, (c) 2003 Simtec Electronics\n");
-
-	ret = uart_register_driver(&s3c2410_uart_drv);
-	if (ret != 0)
-		return ret;
-
-	ret = driver_register(&s3c2410_serial_drv);
-	if (ret) {
-		uart_unregister_driver(&s3c2410_uart_drv);
-	}
-
-	return ret;
-}
-
-static void __exit serial_s3c2410_exit(void)
-{
-	driver_unregister(&s3c2410_serial_drv);
-	uart_unregister_driver(&s3c2410_uart_drv);
-}
-
-module_init(serial_s3c2410_init);
-module_exit(serial_s3c2410_exit);
+#endif /* CONFIG_SERIAL_S3C2410_CONSOLE */
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
-MODULE_DESCRIPTION("Samsung S3C2410X (S3C2410) Serial driver");
+MODULE_DESCRIPTION("Samsung S3C2410/S3C2440 Serial port driver");
diff -Nru a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
--- a/drivers/serial/sa1100.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/serial/sa1100.c	2004-12-24 13:36:18 -08:00
@@ -25,26 +25,27 @@
  *
  */
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
-#include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
 #include <linux/device.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/hardware.h>
 #include <asm/mach/serial_sa1100.h>
 
-#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
 /* We've been assigned a range on the "Low-density serial ports" major */
 #define SERIAL_SA1100_MAJOR	204
 #define MINOR_START		5
@@ -220,9 +221,7 @@
 			goto ignore_char;
 
 	error_return:
-		*tty->flip.flag_buf_ptr++ = flg;
-		*tty->flip.char_buf_ptr++ = ch;
-		tty->flip.count++;
+		tty_insert_flip_char(tty, ch, flg);
 	ignore_char:
 		status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
 			 UTSR0_TO_SM(UART_GET_UTSR0(sport));
@@ -257,11 +256,7 @@
 		 * overrun does *not* affect the character
 		 * we read from the FIFO
 		 */
-		*tty->flip.flag_buf_ptr++ = flg;
-		*tty->flip.char_buf_ptr++ = ch;
-		tty->flip.count++;
-		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-			goto ignore_char;
+		tty_insert_flip_char(tty, ch, flg);
 		ch = 0;
 		flg = TTY_OVERRUN;
 	}
diff -Nru a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
--- a/drivers/serial/serial_core.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/serial/serial_core.c	2004-12-24 13:36:31 -08:00
@@ -32,6 +32,7 @@
 #include <linux/smp_lock.h>
 #include <linux/device.h>
 #include <linux/serial.h> /* for serial_state and serial_icounter_struct */
+#include <linux/delay.h>
 
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -162,8 +163,6 @@
 			return -ENOMEM;
 
 		info->xmit.buf = (unsigned char *) page;
-		info->tmpbuf = info->xmit.buf + UART_XMIT_SIZE;
-		init_MUTEX(&info->tmpbuf_sem);
 		uart_circ_clear(&info->xmit);
 	}
 
@@ -238,7 +237,6 @@
 	if (info->xmit.buf) {
 		free_page((unsigned long)info->xmit.buf);
 		info->xmit.buf = NULL;
-		info->tmpbuf = NULL;
 	}
 
 	/*
@@ -450,53 +448,30 @@
 	spin_unlock_irqrestore(&port->lock, flags);
 }
 
-static inline int
-__uart_user_write(struct uart_port *port, struct circ_buf *circ,
-		  const unsigned char __user *buf, int count)
+static void uart_put_char(struct tty_struct *tty, unsigned char ch)
 {
-	unsigned long flags;
-	int c, ret = 0;
-
-	if (down_interruptible(&port->info->tmpbuf_sem))
-		return -EINTR;
-
-	while (1) {
-		int c1;
-		c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
-		if (count < c)
-			c = count;
-		if (c <= 0)
-			break;
+	struct uart_state *state = tty->driver_data;
 
-		c -= copy_from_user(port->info->tmpbuf, buf, c);
-		if (!c) {
-			if (!ret)
-				ret = -EFAULT;
-			break;
-		}
-		spin_lock_irqsave(&port->lock, flags);
-		c1 = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
-		if (c1 < c)
-			c = c1;
-		memcpy(circ->buf + circ->head, port->info->tmpbuf, c);
-		circ->head = (circ->head + c) & (UART_XMIT_SIZE - 1);
-		spin_unlock_irqrestore(&port->lock, flags);
-		buf += c;
-		count -= c;
-		ret += c;
-	}
-	up(&port->info->tmpbuf_sem);
+	__uart_put_char(state->port, &state->info->xmit, ch);
+}
 
-	return ret;
+static void uart_flush_chars(struct tty_struct *tty)
+{
+	uart_start(tty);
 }
 
-static inline int
-__uart_kern_write(struct uart_port *port, struct circ_buf *circ,
-		  const unsigned char *buf, int count)
+static int
+uart_write(struct tty_struct *tty, const unsigned char * buf, int count)
 {
+	struct uart_state *state = tty->driver_data;
+	struct uart_port *port = state->port;
+	struct circ_buf *circ = &state->info->xmit;
 	unsigned long flags;
 	int c, ret = 0;
 
+	if (!circ->buf)
+		return 0;
+
 	spin_lock_irqsave(&port->lock, flags);
 	while (1) {
 		c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
@@ -512,38 +487,6 @@
 	}
 	spin_unlock_irqrestore(&port->lock, flags);
 
-	return ret;
-}
-
-static void uart_put_char(struct tty_struct *tty, unsigned char ch)
-{
-	struct uart_state *state = tty->driver_data;
-
-	__uart_put_char(state->port, &state->info->xmit, ch);
-}
-
-static void uart_flush_chars(struct tty_struct *tty)
-{
-	uart_start(tty);
-}
-
-static int
-uart_write(struct tty_struct *tty, int from_user, const unsigned char * buf,
-	   int count)
-{
-	struct uart_state *state = tty->driver_data;
-	int ret;
-
-	if (!state->info->xmit.buf)
-		return 0;
-
-	if (from_user)
-		ret = __uart_user_write(state->port, &state->info->xmit,
-				(const unsigned char __user *)buf, count);
-	else
-		ret = __uart_kern_write(state->port, &state->info->xmit,
-					buf, count);
-
 	uart_start(tty);
 	return ret;
 }
@@ -641,8 +584,10 @@
 	tmp.flags	    = port->flags;
 	tmp.xmit_fifo_size  = port->fifosize;
 	tmp.baud_base	    = port->uartclk / 16;
-	tmp.close_delay	    = state->close_delay;
-	tmp.closing_wait    = state->closing_wait;
+	tmp.close_delay	    = state->close_delay / 10;
+	tmp.closing_wait    = state->closing_wait == USF_CLOSING_WAIT_NONE ?
+				ASYNC_CLOSING_WAIT_NONE :
+			        state->closing_wait / 10;
 	tmp.custom_divisor  = port->custom_divisor;
 	tmp.hub6	    = port->hub6;
 	tmp.io_type         = port->iotype;
@@ -660,8 +605,8 @@
 	struct serial_struct new_serial;
 	struct uart_port *port = state->port;
 	unsigned long new_port;
-	unsigned int change_irq, change_port, old_flags;
-	unsigned int old_custom_divisor;
+	unsigned int change_irq, change_port, old_flags, closing_wait;
+	unsigned int old_custom_divisor, close_delay;
 	int retval = 0;
 
 	if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
@@ -672,6 +617,9 @@
 		new_port += (unsigned long) new_serial.port_high << HIGH_BITS_OFFSET;
 
 	new_serial.irq = irq_canonicalize(new_serial.irq);
+	close_delay = new_serial.close_delay * 10;
+	closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
+			USF_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
 
 	/*
 	 * This semaphore protects state->count.  It is also
@@ -703,8 +651,8 @@
 		retval = -EPERM;
 		if (change_irq || change_port ||
 		    (new_serial.baud_base != port->uartclk / 16) ||
-		    (new_serial.close_delay != state->close_delay) ||
-		    (new_serial.closing_wait != state->closing_wait) ||
+		    (close_delay != state->close_delay) ||
+		    (closing_wait != state->closing_wait) ||
 		    (new_serial.xmit_fifo_size != port->fifosize) ||
 		    (((new_serial.flags ^ old_flags) & ~UPF_USR_MASK) != 0))
 			goto exit;
@@ -808,8 +756,8 @@
 	port->flags            = (port->flags & ~UPF_CHANGE_MASK) |
 				 (new_serial.flags & UPF_CHANGE_MASK);
 	port->custom_divisor   = new_serial.custom_divisor;
-	state->close_delay     = new_serial.close_delay * HZ / 100;
-	state->closing_wait    = new_serial.closing_wait * HZ / 100;
+	state->close_delay     = close_delay;
+	state->closing_wait    = closing_wait;
 	port->fifosize         = new_serial.xmit_fifo_size;
 	if (state->info->tty)
 		state->info->tty->low_latency =
@@ -1248,7 +1196,7 @@
 	tty->closing = 1;
 
 	if (state->closing_wait != USF_CLOSING_WAIT_NONE)
-		tty_wait_until_sent(tty, state->closing_wait);
+		tty_wait_until_sent(tty, msecs_to_jiffies(state->closing_wait));
 
 	/*
 	 * At this point, we stop accepting input.  To do this, we
@@ -1276,10 +1224,8 @@
 	state->info->tty = NULL;
 
 	if (state->info->blocked_open) {
-		if (state->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(state->close_delay);
-		}
+		if (state->close_delay)
+			msleep_interruptible(state->close_delay);
 	} else if (!uart_console(port)) {
 		uart_change_pm(state, 3);
 	}
@@ -1343,8 +1289,7 @@
 	 * we wait.
 	 */
 	while (!port->ops->tx_empty(port)) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(char_time);
+		msleep_interruptible(jiffies_to_msecs(char_time));
 		if (signal_pending(current))
 			break;
 		if (time_after(jiffies, expire))
@@ -1901,10 +1846,8 @@
 		 * Wait for the transmitter to empty.
 		 */
 		while (!ops->tx_empty(port)) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(10*HZ/1000);
+			msleep(10);
 		}
-		set_current_state(TASK_RUNNING);
 
 		ops->shutdown(port);
 	}
@@ -2143,8 +2086,8 @@
 	for (i = 0; i < drv->nr; i++) {
 		struct uart_state *state = drv->state + i;
 
-		state->close_delay     = 5 * HZ / 10;
-		state->closing_wait    = 30 * HZ;
+		state->close_delay     = 500;	/* .5 seconds */
+		state->closing_wait    = 30000;	/* 30 seconds */
 
 		init_MUTEX(&state->sem);
 	}
@@ -2224,6 +2167,15 @@
 	 * setserial to be used to alter this ports parameters.
 	 */
 	tty_register_device(drv->tty_driver, port->line, port->dev);
+
+	/*
+	 * If this driver supports console, and it hasn't been
+	 * successfully registered yet, try to re-register it.
+	 * It may be that the port was not available.
+	 */
+	if (port->type != PORT_UNKNOWN &&
+	    port->cons && !(port->cons->flags & CON_ENABLED))
+		register_console(port->cons);
 
  out:
 	up(&port_sem);
diff -Nru a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
--- a/drivers/serial/serial_cs.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/serial/serial_cs.c	2004-12-24 13:36:49 -08:00
@@ -40,8 +40,6 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
 #include <linux/serial_core.h>
 #include <linux/major.h>
 #include <asm/io.h>
@@ -59,7 +57,7 @@
 
 #ifdef PCMCIA_DEBUG
 static int pc_debug = PCMCIA_DEBUG;
-MODULE_PARM(pc_debug, "i");
+module_param(pc_debug, int, 0644);
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 static char *version = "serial_cs.c 1.134 2002/05/04 05:48:53 (David Hinds)";
 #else
@@ -81,7 +79,7 @@
 static int buggy_uart;
 
 module_param(irq_mask, uint, 0444);
-module_param_array(irq_list, int, irq_list_count, 0444);
+module_param_array(irq_list, int, &irq_list_count, 0444);
 module_param(do_sound, int, 0444);
 module_param(buggy_uart, int, 0444);
 
@@ -148,7 +146,7 @@
 	 */
 	if (info->link.state & DEV_CONFIG) {
 		for (i = 0; i < info->ndev; i++)
-			unregister_serial(info->line[i]);
+			serial8250_unregister_port(info->line[i]);
 
 		info->link.dev = NULL;
 
@@ -304,21 +302,22 @@
 
 /*====================================================================*/
 
-static int setup_serial(struct serial_info * info, ioaddr_t port, int irq)
+static int setup_serial(struct serial_info * info, ioaddr_t iobase, int irq)
 {
-	struct serial_struct serial;
+	struct uart_port port;
 	int line;
 
-	memset(&serial, 0, sizeof (serial));
-	serial.port = port;
-	serial.irq = irq;
-	serial.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ;
+	memset(&port, 0, sizeof (struct uart_port));
+	port.iobase = iobase;
+	port.irq = irq;
+	port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ;
+	port.uartclk = 1843200;
 	if (buggy_uart)
-		serial.flags |= UPF_BUGGY_UART;
-	line = register_serial(&serial);
+		port.flags |= UPF_BUGGY_UART;
+	line = serial8250_register_port(&port);
 	if (line < 0) {
-		printk(KERN_NOTICE "serial_cs: register_serial() at 0x%04lx,"
-		       " irq %d failed\n", (u_long) serial.port, serial.irq);
+		printk(KERN_NOTICE "serial_cs: serial8250_register_port() at "
+		       "0x%04lx, irq %d failed\n", (u_long)iobase, irq);
 		return -EINVAL;
 	}
 
diff -Nru a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
--- a/drivers/serial/serial_lh7a40x.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/serial/serial_lh7a40x.c	2004-12-24 13:37:03 -08:00
@@ -28,25 +28,24 @@
  */
 
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_LH7A40X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
-#include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#if defined(CONFIG_SERIAL_LH7A40X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
-#include <asm/arch/serial.h>
-
 #define DEV_MAJOR	204
 #define DEV_MINOR	16
 #define DEV_NR		3
@@ -60,6 +59,15 @@
 
 #define UART_REG_SIZE	32
 
+#define UART_R_DATA	(0x00)
+#define UART_R_FCON	(0x04)
+#define UART_R_BRCON	(0x08)
+#define UART_R_CON	(0x0c)
+#define UART_R_STATUS	(0x10)
+#define UART_R_RAWISR	(0x14)
+#define UART_R_INTEN	(0x18)
+#define UART_R_ISR	(0x1c)
+
 #define UARTEN		(0x01)		/* UART enable */
 #define SIRDIS		(0x02)		/* Serial IR disable (UART1 only) */
 
@@ -138,21 +146,20 @@
 {
 	struct tty_struct* tty = port->info->tty;
 	int cbRxMax = 256;	/* (Gross) limit on receive */
-	unsigned int data;	/* Received data and status */
+	unsigned int data, flag;/* Received data and status */
 
 	while (!(UR (port, UART_R_STATUS) & nRxRdy) && --cbRxMax) {
 		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-			tty->flip.work.func((void*)tty);
-			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-				printk(KERN_WARNING "TTY_DONT_FLIP set\n");
-				return;
-			}
+			if (tty->low_latency)
+				tty_flip_buffer_push(tty);
+			/*
+			 * If this failed then we will throw away the
+			 * bytes but must do so to clear interrupts
+			 */
 		}
 
 		data = UR (port, UART_R_DATA);
-
-		*tty->flip.char_buf_ptr = (unsigned char) data;
-		*tty->flip.flag_buf_ptr = TTY_NORMAL;
+		flag = TTY_NORMAL;
 		++port->icount.rx;
 
 		if (data & RxError) {	/* Quick check, short-circuit */
@@ -173,20 +180,18 @@
 			data &= port->read_status_mask | 0xff;
 
 			if (data & RxBreak)
-				*tty->flip.flag_buf_ptr = TTY_BREAK;
+				flag = TTY_BREAK;
 			else if (data & RxParityError)
-				*tty->flip.flag_buf_ptr = TTY_PARITY;
+				flag = TTY_PARITY;
 			else if (data & RxFramingError)
-				*tty->flip.flag_buf_ptr = TTY_FRAME;
+				flag = TTY_FRAME;
 		}
 
 		if (uart_handle_sysrq_char (port, (unsigned char) data, regs))
 			continue;
 
 		if ((data & port->ignore_status_mask) == 0) {
-			++tty->flip.flag_buf_ptr;
-			++tty->flip.char_buf_ptr;
-			++tty->flip.count;
+			tty_insert_flip_char(tty, data, flag);
 		}
 		if ((data & RxOverrunError)
 		    && tty->flip.count < TTY_FLIPBUF_SIZE) {
@@ -195,9 +200,7 @@
 			 * immediately, and doesn't affect the current
 			 * character
 			 */
-			*tty->flip.char_buf_ptr++ = 0;
-			*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
-			++tty->flip.count;
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
 		}
 	}
 	tty_flip_buffer_push (tty);
diff -Nru a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
--- a/drivers/serial/sh-sci.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/serial/sh-sci.c	2004-12-24 13:37:19 -08:00
@@ -3,7 +3,7 @@
  *
  * SuperH on-chip serial module support.  (SCI with no FIFO / with FIFO)
  *
- *  Copyright (C) 2002, 2003  Paul Mundt
+ *  Copyright (C) 2002, 2003, 2004  Paul Mundt
  *
  * based off of the old drivers/char/sh-sci.c by:
  *
@@ -18,7 +18,8 @@
  * for more details.
  */
 
-#define DEBUG
+#undef DEBUG
+
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
@@ -40,6 +41,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/console.h>
+#include <linux/bitops.h>
 
 #ifdef CONFIG_CPU_FREQ
 #include <linux/notifier.h>
@@ -50,7 +52,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 
 #include <linux/generic_serial.h>
 
@@ -332,7 +333,7 @@
 
 #if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
 #if defined(CONFIG_CPU_SH3)
-/* For SH7707, SH7709, SH7709A, SH7729, SH7300*/
+/* For SH7705, SH7707, SH7709, SH7709A, SH7729, SH7300*/
 static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
 {
 	unsigned int fcr_val = 0;
@@ -798,7 +799,7 @@
 	if ((phase == CPUFREQ_POSTCHANGE) ||
 	    (phase == CPUFREQ_RESUMECHANGE)){
 		for (i = 0; i < SCI_NPORTS; i++) {
-			struct uart_port *port = &sci_ports[i];
+			struct uart_port *port = &sci_ports[i].port;
 
 			/*
 			 * Update the uartclk per-port if frequency has
@@ -1139,6 +1140,35 @@
 		.irqs		= SCI_IRQS,
 		.init_pins	= sci_init_pins_sci,
 	},
+#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
+	{
+		.port	= {
+			.membase	= (void *)SCIF0,
+			.mapbase	= SCIF0,
+			.iotype		= SERIAL_IO_MEM,
+			.irq		= 55,
+			.ops		= &sci_uart_ops,
+			.flags		= ASYNC_BOOT_AUTOCONF,
+			.line		= 0,
+		},
+		.type		= PORT_SCIF,
+		.irqs		= SH3_IRDA_IRQS,
+		.init_pins	= sci_init_pins_scif,
+	},
+	{
+		.port	= {
+			.membase	= (void *)SCIF2,
+			.mapbase	= SCIF2,
+			.iotype		= SERIAL_IO_MEM,
+			.irq		= 59,
+			.ops		= &sci_uart_ops,
+			.flags		= ASYNC_BOOT_AUTOCONF,
+			.line		= 1,
+		},
+		.type		= PORT_SCIF,
+		.irqs		= SH3_SCIF_IRQS,
+		.init_pins	= sci_init_pins_scif,
+	}
 #elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
 	{
 		.port	= {
@@ -1197,6 +1227,21 @@
 		.irqs		= SH7300_SCIF0_IRQS,
 		.init_pins	= sci_init_pins_scif,
 	},
+#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
+	{
+		.port	= {
+			.membase	= (void *)0xffe00000,
+			.mapbase	= 0xffe00000,
+			.iotype		= SERIAL_IO_MEM,
+			.irq		= 25,
+			.ops		= &sci_uart_ops,
+			.flags		= ASYNC_BOOT_AUTOCONF,
+			.line		= 0,
+		},
+		.type		= PORT_SCIF,
+		.irqs		= SH73180_SCIF_IRQS,
+		.init_pins	= sci_init_pins_scif,
+	},
 #elif defined(CONFIG_SH_RTS7751R2D)
 	{
 		.port	= {
@@ -1284,6 +1329,21 @@
 		.irqs		= SH7760_SCIF2_IRQS,
 		.init_pins	= sci_init_pins_scif,
 	},
+#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
+	{
+		.port	= {
+			.membase	= (void *)0xffe80000,
+			.mapbase	= 0xffe80000,
+			.iotype		= SERIAL_IO_MEM,
+			.irq		= 43,
+			.ops		= &sci_uart_ops,
+			.flags		= ASYNC_BOOT_AUTOCONF,
+			.line		= 0,
+		},
+		.type		= PORT_SCIF,
+		.irqs		= SH4_SCIF_IRQS,
+		.init_pins	= sci_init_pins_scif,
+	},
 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
 	{
 		.port	= {
@@ -1551,7 +1611,7 @@
 /* Register the KGDB console so we get messages (d'oh!) */
 static int __init kgdb_console_init(void)
 {
-        register_console(&kgdb_console);
+	register_console(&kgdb_console);
 	return 0;
 }
 
diff -Nru a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
--- a/drivers/serial/sh-sci.h	2004-12-24 13:36:32 -08:00
+++ b/drivers/serial/sh-sci.h	2004-12-24 13:36:32 -08:00
@@ -38,6 +38,7 @@
 #define SH7760_SCIF1_IRQS { 72, 73, 75, 74 }
 #define SH7760_SCIF2_IRQS { 76, 77, 79, 78 }
 #define SH7300_SCIF0_IRQS {80,  80,  80,  80 }
+#define SH73180_SCIF_IRQS {80,  81,  83,  82 }
 #define H8300H_SCI_IRQS0 {52, 53, 54,   0 }
 #define H8300H_SCI_IRQS1 {56, 57, 58,   0 }
 #define H8300H_SCI_IRQS2 {60, 61, 62,   0 }
@@ -57,6 +58,21 @@
 # define SCPDR  0xA4000136 /* 8  bit SCI and SCIF */
 # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
 # define SCI_AND_SCIF
+#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
+# define SCIF0		0xA4400000
+# define SCIF2		0xA4410000
+# define SCSMR_Ir 	0xA44A0000
+# define IRDA_SCIF 	SCIF0
+# define SCI_NPORTS 2
+# define SCPCR 0xA4000116
+# define SCPDR 0xA4000136
+
+/* Set the clock source,
+ * SCIF2 (0xA4410000) -> External clock, SCK pin used as clock input
+ * SCIF0 (0xA4400000) -> Internal clock, SCK pin as serial clock output
+ */
+# define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0
+# define SCIF_ONLY
 #elif defined(CONFIG_SH_RTS7751R2D)
 # define SCI_NPORTS 1
 # define SCSPTR1 0xffe0001c /* 8  bit SCI */
@@ -87,6 +103,19 @@
 # define SCPDR  0xA4050136        /* 16 bit SCIF */
 # define SCSCR_INIT(port)  0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
 # define SCIF_ONLY
+#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
+# define SCI_NPORTS 1
+# define SCPDR  0xA4050138        /* 16 bit SCIF */
+# define SCSPTR2 SCPDR
+# define SCIF_ORER 0x0001   /* overrun error bit */
+# define SCSCR_INIT(port)  0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */
+# define SCIF_ONLY
+#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
+# define SCI_NPORTS 1
+# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
+# define SCIF_ORER 0x0001   /* overrun error bit */
+# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
+# define SCIF_ONLY
 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
 # define SCI_NPORTS 2
 # define SCSPTR1 0xffe00020 /* 16 bit SCIF */
@@ -152,16 +181,16 @@
 #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
 
 /* SCxSR SCIF */
-#define SCIF_ER    0x0080 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_TEND  0x0040 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_TDFE  0x0020 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_BRK   0x0010 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_FER   0x0008 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_PER   0x0004 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_RDF   0x0002 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_DR    0x0001 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
+#define SCIF_ER    0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
+#define SCIF_TEND  0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
+#define SCIF_TDFE  0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
+#define SCIF_BRK   0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
+#define SCIF_FER   0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
+#define SCIF_PER   0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
+#define SCIF_RDF   0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
+#define SCIF_DR    0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
 
-#if defined(CONFIG_CPU_SUBTYPE_SH7300)
+#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
 #define SCIF_ORER    0x0200
 #define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
 #define SCIF_RFDC_MASK 0x007f
@@ -190,7 +219,7 @@
 # define SCxSR_ERRORS(port)		SCIF_ERRORS
 # define SCxSR_RDxF(port)               SCIF_RDF
 # define SCxSR_TDxE(port)               SCIF_TDFE
-#if defined(CONFIG_CPU_SUBTYPE_SH7300)
+#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
 # define SCxSR_ORER(port)		SCIF_ORER
 #else
 # define SCxSR_ORER(port)		0x0000
@@ -198,12 +227,13 @@
 # define SCxSR_FER(port)		SCIF_FER
 # define SCxSR_PER(port)		SCIF_PER
 # define SCxSR_BRK(port)		SCIF_BRK
-#if defined(CONFIG_CPU_SUBTYPE_SH7300)
+#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
 # define SCxSR_RDxF_CLEAR(port)         (sci_in(port,SCxSR)&0xfffc)
 # define SCxSR_ERROR_CLEAR(port)        (sci_in(port,SCxSR)&0xfd73)
 # define SCxSR_TDxE_CLEAR(port)         (sci_in(port,SCxSR)&0xffdf)
 # define SCxSR_BREAK_CLEAR(port)        (sci_in(port,SCxSR)&0xffe3)
 #else
+/* SH7705 can also use this, clearing is same between 7705 and 7709 and 7300 */
 # define SCxSR_RDxF_CLEAR(port)		0x00fc
 # define SCxSR_ERROR_CLEAR(port)	0x0073
 # define SCxSR_TDxE_CLEAR(port)		0x00df
@@ -307,7 +337,7 @@
   }
 
 #ifdef CONFIG_CPU_SH3
-#if defined(CONFIG_CPU_SUBTYPE_SH7300)
+#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
 #define SCIF_FNS(name, scif_offset, scif_size) \
   CPU_SCIF_FNS(name, scif_offset, scif_size)
 #else
@@ -333,7 +363,7 @@
   CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
 #endif
 
-#if defined(CONFIG_CPU_SUBTYPE_SH7300)
+#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
 SCIF_FNS(SCSMR,  0x00, 16)
 SCIF_FNS(SCBRR,  0x04,  8)
 SCIF_FNS(SCSCR,  0x08, 16)
@@ -422,7 +452,18 @@
 		return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
 	return 1;
 }
-#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
+#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
+static inline int sci_rxd_in(struct uart_port *port)
+{
+	if (port->mapbase == SCIF0)
+		return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
+	if (port->mapbase == SCIF2)
+		return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
+	return 1;
+}
+#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
+      defined(CONFIG_CPU_SUBTYPE_SH7751) || \
+      defined(CONFIG_CPU_SUBTYPE_SH4_202)
 static inline int sci_rxd_in(struct uart_port *port)
 {
 #ifndef SCIF_ONLY
@@ -452,6 +493,11 @@
                 return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCIF0 */
         return 1;
 }
+#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
+static inline int sci_rxd_in(struct uart_port *port)
+{
+	return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCIF0 */
+}
 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
 static inline int sci_rxd_in(struct uart_port *port)
 {
@@ -510,6 +556,8 @@
 
 #if defined(CONFIG_CPU_SUBTYPE_SH7300)
 #define SCBRR_VALUE(bps) ((PCLK+16*bps)/(16*bps)-1)
+#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
+#define SCBRR_VALUE(bps) (((PCLK*2)+16*bps)/(32*bps)-1)
 #elif !defined(__H8300H__) && !defined(__H8300S__)
 #define SCBRR_VALUE(bps) ((PCLK+16*bps)/(32*bps)-1)
 #else
diff -Nru a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
--- a/drivers/serial/sn_console.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/serial/sn_console.c	2004-12-24 13:36:48 -08:00
@@ -52,7 +52,6 @@
 
 #include <asm/io.h>
 #include <asm/sn/simulator.h>
-#include <asm/sn/sn2/sn_private.h>
 #include <asm/sn/sn_sal.h>
 
 /* number of characters we can transmit to the SAL console at a time */
@@ -71,12 +70,12 @@
 
 /* To use dynamic numbers only and not use the assigned major and minor,
  * define the following.. */
-/* #define USE_DYNAMIC_MINOR 1 */ /* use dynamic minor number */
-#define USE_DYNAMIC_MINOR 0 /* Don't rely on misc_register dynamic minor */
+				  /* #define USE_DYNAMIC_MINOR 1 *//* use dynamic minor number */
+#define USE_DYNAMIC_MINOR 0	/* Don't rely on misc_register dynamic minor */
 
 /* Device name we're using */
 #define DEVICE_NAME "ttySG"
-#define DEVICE_NAME_DYNAMIC "ttySG0"  /* need full name for misc_register */
+#define DEVICE_NAME_DYNAMIC "ttySG0"	/* need full name for misc_register */
 /* The major/minor we are using, ignored for USE_DYNAMIC_MINOR */
 #define DEVICE_MAJOR 204
 #define DEVICE_MINOR 40
@@ -107,9 +106,8 @@
 static struct sn_cons_port sal_console_port;
 
 /* Only used if USE_DYNAMIC_MINOR is set to 1 */
-static struct miscdevice misc; /* used with misc_register for dynamic */
+static struct miscdevice misc;	/* used with misc_register for dynamic */
 
-extern u64 master_node_bedrock_address;
 extern void early_sn_setup(void);
 
 #undef DEBUG
@@ -125,9 +123,6 @@
 static int snt_hw_puts_buffered(const char *, int);
 static int snt_poll_getc(void);
 static int snt_poll_input_pending(void);
-static int snt_sim_puts(const char *, int);
-static int snt_sim_getc(void);
-static int snt_sim_input_pending(void);
 static int snt_intr_getc(void);
 static int snt_intr_input_pending(void);
 static void sn_transmit_chars(struct sn_cons_port *, int);
@@ -141,14 +136,6 @@
 	.sal_input_pending = snt_poll_input_pending
 };
 
-/* A table for the simulator */
-static struct sn_sal_ops sim_ops = {
-	.sal_puts_raw = snt_sim_puts,
-	.sal_puts = snt_sim_puts,
-	.sal_getc = snt_sim_getc,
-	.sal_input_pending = snt_sim_input_pending
-};
-
 /* A table for interrupts enabled */
 static struct sn_sal_ops intr_ops = {
 	.sal_puts_raw = snt_hw_puts_raw,
@@ -169,15 +156,13 @@
  * output is buffered and sent to the SAL asynchronously (either by
  * timer callback or by UART interrupt) */
 
-
 /* routines for running the console in polling mode */
 
 /**
  * snt_poll_getc - Get a character from the console in polling mode
  *
  */
-static int
-snt_poll_getc(void)
+static int snt_poll_getc(void)
 {
 	int ch;
 
@@ -189,8 +174,7 @@
  * snt_poll_input_pending - Check if any input is waiting - polling mode.
  *
  */
-static int
-snt_poll_input_pending(void)
+static int snt_poll_input_pending(void)
 {
 	int status, input;
 
@@ -198,64 +182,13 @@
 	return !status && input;
 }
 
-/* routines for running the console on the simulator */
-
-/**
- * snt_sim_puts - send to the console, used in simulator mode
- * @str: String to send
- * @count: length of string
- *
- */
-static int
-snt_sim_puts(const char *str, int count)
-{
-	int counter = count;
-
-#ifdef FLAG_DIRECT_CONSOLE_WRITES
-	/* This is an easy way to pre-pend the output to know whether the output
-	 * was done via sal or directly */
-	writeb('[', master_node_bedrock_address + (UART_TX << 3));
-	writeb('+', master_node_bedrock_address + (UART_TX << 3));
-	writeb(']', master_node_bedrock_address + (UART_TX << 3));
-	writeb(' ', master_node_bedrock_address + (UART_TX << 3));
-#endif				/* FLAG_DIRECT_CONSOLE_WRITES */
-	while (counter > 0) {
-		writeb(*str, master_node_bedrock_address + (UART_TX << 3));
-		counter--;
-		str++;
-	}
-	return count;
-}
-
-/**
- * snt_sim_getc - Get character from console in simulator mode
- *
- */
-static int
-snt_sim_getc(void)
-{
-	return readb(master_node_bedrock_address + (UART_RX << 3));
-}
-
-/**
- * snt_sim_input_pending - Check if there is input pending in simulator mode
- *
- */
-static int
-snt_sim_input_pending(void)
-{
-	return readb(master_node_bedrock_address +
-		     (UART_LSR << 3)) & UART_LSR_DR;
-}
-
 /* routines for an interrupt driven console (normal) */
 
 /**
  * snt_intr_getc - Get a character from the console, interrupt mode
  *
  */
-static int
-snt_intr_getc(void)
+static int snt_intr_getc(void)
 {
 	return ia64_sn_console_readc();
 }
@@ -264,8 +197,7 @@
  * snt_intr_input_pending - Check if input is pending, interrupt mode
  *
  */
-static int
-snt_intr_input_pending(void)
+static int snt_intr_input_pending(void)
 {
 	return ia64_sn_console_intr_status() & SAL_CONSOLE_INTR_RECV;
 }
@@ -278,8 +210,7 @@
  * @len: Length
  *
  */
-static int
-snt_hw_puts_raw(const char *s, int len)
+static int snt_hw_puts_raw(const char *s, int len)
 {
 	/* this will call the PROM and not return until this is done */
 	return ia64_sn_console_putb(s, len);
@@ -291,8 +222,7 @@
  * @len: Length
  *
  */
-static int
-snt_hw_puts_buffered(const char *s, int len)
+static int snt_hw_puts_buffered(const char *s, int len)
 {
 	/* queue data to the PROM */
 	return ia64_sn_console_xmit_chars((char *)s, len);
@@ -310,8 +240,7 @@
  * @port: Port to operate with (we ignore since we only have one port)
  *
  */
-static const char *
-snp_type(struct uart_port *port)
+static const char *snp_type(struct uart_port *port)
 {
 	return ("SGI SN L1");
 }
@@ -321,8 +250,7 @@
  * @port: Port to operate on (we ignore since we only have one port)
  *
  */
-static unsigned int
-snp_tx_empty(struct uart_port *port)
+static unsigned int snp_tx_empty(struct uart_port *port)
 {
 	return 1;
 }
@@ -333,8 +261,7 @@
  * @tty_stop: Set to 1 if called via uart_stop
  *
  */
-static void
-snp_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void snp_stop_tx(struct uart_port *port, unsigned int tty_stop)
 {
 }
 
@@ -343,8 +270,7 @@
  * @port: Port to operate on - we ignore - no-op function
  *
  */
-static void
-snp_release_port(struct uart_port *port)
+static void snp_release_port(struct uart_port *port)
 {
 }
 
@@ -353,8 +279,7 @@
  * @port: Port to operate on - we ignore - no-op function
  *
  */
-static void
-snp_enable_ms(struct uart_port *port)
+static void snp_enable_ms(struct uart_port *port)
 {
 }
 
@@ -363,8 +288,7 @@
  * @port: Port to shut down - we ignore
  *
  */
-static void
-snp_shutdown(struct uart_port *port)
+static void snp_shutdown(struct uart_port *port)
 {
 }
 
@@ -374,8 +298,7 @@
  * @mctrl: Lines to set/unset - we ignore
  *
  */
-static void
-snp_set_mctrl(struct uart_port *port, unsigned int mctrl)
+static void snp_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
 }
 
@@ -384,8 +307,7 @@
  * @port: port to operate on - we only have one port so we ignore this
  *
  */
-static unsigned int
-snp_get_mctrl(struct uart_port *port)
+static unsigned int snp_get_mctrl(struct uart_port *port)
 {
 	return TIOCM_CAR | TIOCM_RNG | TIOCM_DSR | TIOCM_CTS;
 }
@@ -395,8 +317,7 @@
  * @port: Port to operate on - we ignore
  *
  */
-static void
-snp_stop_rx(struct uart_port *port)
+static void snp_stop_rx(struct uart_port *port)
 {
 }
 
@@ -406,11 +327,11 @@
  * @tty_stop: Set to 1 if called via uart_start
  *
  */
-static void
-snp_start_tx(struct uart_port *port, unsigned int tty_stop)
+static void snp_start_tx(struct uart_port *port, unsigned int tty_stop)
 {
 	if (sal_console_port.sc_ops->sal_wakeup_transmit)
-		sal_console_port.sc_ops->sal_wakeup_transmit(&sal_console_port, TRANSMIT_BUFFERED);
+		sal_console_port.sc_ops->sal_wakeup_transmit(&sal_console_port,
+							     TRANSMIT_BUFFERED);
 
 }
 
@@ -420,8 +341,7 @@
  * @break_state: Break state
  *
  */
-static void
-snp_break_ctl(struct uart_port *port, int break_state)
+static void snp_break_ctl(struct uart_port *port, int break_state)
 {
 }
 
@@ -430,8 +350,7 @@
  * @port: Port to operate on
  *
  */
-static int
-snp_startup(struct uart_port *port)
+static int snp_startup(struct uart_port *port)
 {
 	return 0;
 }
@@ -454,8 +373,7 @@
  * @port: port to operate on
  *
  */
-static int
-snp_request_port(struct uart_port *port)
+static int snp_request_port(struct uart_port *port)
 {
 	return 0;
 }
@@ -466,8 +384,7 @@
  * @flags: flags used for port setup
  *
  */
-static void
-snp_config_port(struct uart_port *port, int flags)
+static void snp_config_port(struct uart_port *port, int flags)
 {
 }
 
@@ -505,22 +422,17 @@
  * itself may be broken.
  *
  */
-static int
-sn_debug_printf(const char *fmt, ...)
+static int sn_debug_printf(const char *fmt, ...)
 {
 	static char printk_buf[1024];
 	int printed_len;
 	va_list args;
 
 	va_start(args, fmt);
-	printed_len = vsnprintf(printk_buf, sizeof (printk_buf), fmt, args);
+	printed_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
 
 	if (!sal_console_port.sc_ops) {
-		if (IS_RUNNING_ON_SIMULATOR())
-			sal_console_port.sc_ops = &sim_ops;
-		else
-			sal_console_port.sc_ops = &poll_ops;
-
+		sal_console_port.sc_ops = &poll_ops;
 		early_sn_setup();
 	}
 	sal_console_port.sc_ops->sal_puts_raw(printk_buf, printed_len);
@@ -528,13 +440,12 @@
 	va_end(args);
 	return printed_len;
 }
-#endif	/* DEBUG */
+#endif				/* DEBUG */
 
 /*
  * Interrupt handling routines.
  */
 
-
 /**
  * sn_receive_chars - Grab characters, pass them to tty layer
  * @port: Port to operate on
@@ -635,8 +546,7 @@
  * ignore them until we register with the serial core stuffs.
  *
  */
-static void
-sn_transmit_chars(struct sn_cons_port *port, int raw)
+static void sn_transmit_chars(struct sn_cons_port *port, int raw)
 {
 	int xmit_count, tail, head, loops, ii;
 	int result;
@@ -651,8 +561,7 @@
 	if (port->sc_port.info) {
 		/* We're initilized, using serial core infrastructure */
 		xmit = &port->sc_port.info->xmit;
-	}
-	else {
+	} else {
 		/* Probably sn_sal_switch_to_asynch has been run but serial core isn't
 		 * initilized yet.  Just return.  Writes are going through
 		 * sn_sal_console_write (due to register_console) at this time.
@@ -704,7 +613,7 @@
 		uart_write_wakeup(&port->sc_port);
 
 	if (uart_circ_empty(xmit))
-		snp_stop_tx(&port->sc_port, 0); /* no-op for us */
+		snp_stop_tx(&port->sc_port, 0);	/* no-op for us */
 }
 
 /**
@@ -714,10 +623,9 @@
  * @regs: Saved registers, used by sn_receive_chars for uart_handle_sysrq_char
  *
  */
-static irqreturn_t
-sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	struct sn_cons_port *port = (struct sn_cons_port *) dev_id;
+	struct sn_cons_port *port = (struct sn_cons_port *)dev_id;
 	unsigned long flags;
 	int status = ia64_sn_console_intr_status();
 
@@ -742,8 +650,7 @@
  * returns the console irq if interrupt is successfully registered, else 0
  *
  */
-static int
-sn_sal_connect_interrupt(struct sn_cons_port *port)
+static int sn_sal_connect_interrupt(struct sn_cons_port *port)
 {
 	if (request_irq(SGI_UART_VECTOR, sn_sal_interrupt,
 			SA_INTERRUPT | SA_SHIRQ,
@@ -764,10 +671,9 @@
  * Obviously not used in interrupt mode
  *
  */
-static void
-sn_sal_timer_poll(unsigned long data)
+static void sn_sal_timer_poll(unsigned long data)
 {
-	struct sn_cons_port *port = (struct sn_cons_port *) data;
+	struct sn_cons_port *port = (struct sn_cons_port *)data;
 	unsigned long flags;
 
 	if (!port)
@@ -797,8 +703,7 @@
  * if we didn't already come through here via sn_sal_serial_console_init.
  *
  */
-static void __init
-sn_sal_switch_to_asynch(struct sn_cons_port *port)
+static void __init sn_sal_switch_to_asynch(struct sn_cons_port *port)
 {
 	unsigned long flags;
 
@@ -813,12 +718,8 @@
 	spin_lock_irqsave(&port->sc_port.lock, flags);
 
 	/* early_printk invocation may have done this for us */
-	if (!port->sc_ops) {
-		if (IS_RUNNING_ON_SIMULATOR())
-			port->sc_ops = &sim_ops;
-		else
-			port->sc_ops = &poll_ops;
-	}
+	if (!port->sc_ops)
+		port->sc_ops = &poll_ops;
 
 	/* we can't turn on the console interrupt (as request_irq
 	 * calls kmalloc, which isn't set up yet), so we rely on a
@@ -827,7 +728,7 @@
 	 */
 	init_timer(&port->sc_timer);
 	port->sc_timer.function = sn_sal_timer_poll;
-	port->sc_timer.data = (unsigned long) port;
+	port->sc_timer.data = (unsigned long)port;
 
 	if (IS_RUNNING_ON_SIMULATOR())
 		port->sc_interrupt_timeout = 6;
@@ -854,8 +755,7 @@
  * We attempt to switch to interrupt mode here by calling
  * sn_sal_connect_interrupt.  If that works out, we enable receive interrupts.
  */
-static void __init
-sn_sal_switch_to_interrupts(struct sn_cons_port *port)
+static void __init sn_sal_switch_to_interrupts(struct sn_cons_port *port)
 {
 	int irq;
 	unsigned long flags;
@@ -893,7 +793,7 @@
 	.write = sn_sal_console_write,
 	.device = uart_console_device,
 	.setup = sn_sal_console_setup,
-	.index = -1, /* unspecified */
+	.index = -1,		/* unspecified */
 	.data = &sal_console_uart,
 };
 
@@ -903,9 +803,9 @@
 	.owner = THIS_MODULE,
 	.driver_name = "sn_console",
 	.dev_name = DEVICE_NAME,
-	.major = 0, /* major/minor set at registration time per USE_DYNAMIC_MINOR */
+	.major = 0,		/* major/minor set at registration time per USE_DYNAMIC_MINOR */
 	.minor = 0,
-	.nr = 1,	/* one port */
+	.nr = 1,		/* one port */
 	.cons = SAL_CONSOLE,
 };
 
@@ -918,8 +818,7 @@
  * core and try to enable interrupt driven mode.
  *
  */
-static int __init
-sn_sal_module_init(void)
+static int __init sn_sal_module_init(void)
 {
 	int retval;
 
@@ -933,23 +832,24 @@
 		misc.name = DEVICE_NAME_DYNAMIC;
 		retval = misc_register(&misc);
 		if (retval != 0) {
-			printk("Failed to register console device using misc_register.\n");
+			printk
+			    ("Failed to register console device using misc_register.\n");
 			return -ENODEV;
 		}
 		sal_console_uart.major = MISC_MAJOR;
 		sal_console_uart.minor = misc.minor;
-	}
-	else {
+	} else {
 		sal_console_uart.major = DEVICE_MAJOR;
 		sal_console_uart.minor = DEVICE_MINOR;
 	}
 
 	/* We register the driver and the port before switching to interrupts
-    * or async above so the proper uart structures are populated */
+	 * or async above so the proper uart structures are populated */
 
 	if (uart_register_driver(&sal_console_uart) < 0) {
-		printk("ERROR sn_sal_module_init failed uart_register_driver, line %d\n",
-		  __LINE__);
+		printk
+		    ("ERROR sn_sal_module_init failed uart_register_driver, line %d\n",
+		     __LINE__);
 		return -ENODEV;
 	}
 
@@ -985,8 +885,7 @@
  * sn_sal_module_exit - When we're unloaded, remove the driver/port
  *
  */
-static void __exit
-sn_sal_module_exit(void)
+static void __exit sn_sal_module_exit(void)
 {
 	del_timer_sync(&sal_console_port.sc_timer);
 	uart_remove_one_port(&sal_console_uart, &sal_console_port.sc_port);
@@ -1008,7 +907,8 @@
  *
  */
 
-static void puts_raw_fixed(int (*puts_raw) (const char *s, int len), const char *s, int count)
+static void puts_raw_fixed(int (*puts_raw) (const char *s, int len),
+			   const char *s, int count)
 {
 	const char *s1;
 
@@ -1056,7 +956,7 @@
 	if (port->sc_port.info) {
 
 		/* somebody really wants this output, might be an
-	 	* oops, kdb, panic, etc.  make sure they get it. */
+		 * oops, kdb, panic, etc.  make sure they get it. */
 #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
 		if (spin_is_locked(&port->sc_port.lock)) {
 			int lhead = port->sc_port.info->xmit.head;
@@ -1064,29 +964,39 @@
 			int counter, got_lock = 0;
 
 			/*
-		 	 * We attempt to determine if someone has died with the
-		 	 * lock. We wait ~20 secs after the head and tail ptrs
-		 	 * stop moving and assume the lock holder is not functional
-		 	 * and plow ahead. If the lock is freed within the time out
-		 	 * period we re-get the lock and go ahead normally. We also
-		 	 * remember if we have plowed ahead so that we don't have
+			 * We attempt to determine if someone has died with the
+			 * lock. We wait ~20 secs after the head and tail ptrs
+			 * stop moving and assume the lock holder is not functional
+			 * and plow ahead. If the lock is freed within the time out
+			 * period we re-get the lock and go ahead normally. We also
+			 * remember if we have plowed ahead so that we don't have
 			 * to wait out the time out period again - the asumption
-		 	 * is that we will time out again.
-		 	 */
+			 * is that we will time out again.
+			 */
 
 			for (counter = 0; counter < 150; mdelay(125), counter++) {
-				if (!spin_is_locked(&port->sc_port.lock) || stole_lock) {
+				if (!spin_is_locked(&port->sc_port.lock)
+				    || stole_lock) {
 					if (!stole_lock) {
-						spin_lock_irqsave(&port->sc_port.lock, flags);
+						spin_lock_irqsave(&port->
+								  sc_port.lock,
+								  flags);
 						got_lock = 1;
 					}
 					break;
-				}
-				else {
+				} else {
 					/* still locked */
-					if ((lhead != port->sc_port.info->xmit.head) || (ltail != port->sc_port.info->xmit.tail)) {
-						lhead = port->sc_port.info->xmit.head;
-						ltail = port->sc_port.info->xmit.tail;
+					if ((lhead !=
+					     port->sc_port.info->xmit.head)
+					    || (ltail !=
+						port->sc_port.info->xmit.
+						tail)) {
+						lhead =
+						    port->sc_port.info->xmit.
+						    head;
+						ltail =
+						    port->sc_port.info->xmit.
+						    tail;
 						counter = 0;
 					}
 				}
@@ -1094,16 +1004,15 @@
 			/* flush anything in the serial core xmit buffer, raw */
 			sn_transmit_chars(port, 1);
 			if (got_lock) {
-				spin_unlock_irqrestore(&port->sc_port.lock, flags);
+				spin_unlock_irqrestore(&port->sc_port.lock,
+						       flags);
 				stole_lock = 0;
-			}
-			else {
+			} else {
 				/* fell thru */
 				stole_lock = 1;
 			}
 			puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
-		}
-		else {
+		} else {
 			stole_lock = 0;
 #endif
 			spin_lock_irqsave(&port->sc_port.lock, flags);
@@ -1134,8 +1043,7 @@
  * here so providing it is easier.
  *
  */
-static int __init
-sn_sal_console_setup(struct console *co, char *options)
+static int __init sn_sal_console_setup(struct console *co, char *options)
 {
 	return 0;
 }
@@ -1163,7 +1071,7 @@
 	.name = "sn_sal",
 	.write = sn_sal_console_write_early,
 	.flags = CON_PRINTBUFFER,
-	.index  = -1,
+	.index = -1,
 };
 
 /**
@@ -1175,24 +1083,18 @@
  * sn_sal_serial_console_init is called, this console is unregistered
  * and a new one registered.
  */
-int __init
-sn_serial_console_early_setup(void)
+int __init sn_serial_console_early_setup(void)
 {
 	if (!ia64_platform_is("sn2"))
 		return -1;
 
-	if (IS_RUNNING_ON_SIMULATOR())
-		sal_console_port.sc_ops = &sim_ops;
-	else
-		sal_console_port.sc_ops = &poll_ops;
-
-	early_sn_setup(); /* Find SAL entry points */
+	sal_console_port.sc_ops = &poll_ops;
+	early_sn_setup();	/* Find SAL entry points */
 	register_console(&sal_console_early);
 
 	return 0;
 }
 
-
 /**
  * sn_sal_serial_console_init - Early console output - set up for register
  *
@@ -1205,12 +1107,11 @@
  * it here doesn't hurt anything.
  *
  */
-static int __init
-sn_sal_serial_console_init(void)
+static int __init sn_sal_serial_console_init(void)
 {
 	if (ia64_platform_is("sn2")) {
 		sn_sal_switch_to_asynch(&sal_console_port);
-		DPRINTF ("sn_sal_serial_console_init : register console\n");
+		DPRINTF("sn_sal_serial_console_init : register console\n");
 		register_console(&sal_console);
 		unregister_console(&sal_console_early);
 	}
diff -Nru a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
--- a/drivers/serial/sunsab.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/serial/sunsab.c	2004-12-24 13:36:47 -08:00
@@ -51,7 +51,7 @@
 
 struct uart_sunsab_port {
 	struct uart_port		port;		/* Generic UART port	*/
-	union sab82532_async_regs	*regs;		/* Chip registers	*/
+	union sab82532_async_regs	__iomem *regs;	/* Chip registers	*/
 	unsigned long			irqflags;	/* IRQ state flags	*/
 	int				dsr;		/* Current DSR state	*/
 	unsigned int			cec_timeout;	/* Chip poll timeout... */
@@ -143,6 +143,11 @@
 		writeb(SAB82532_CMDR_RMC, &up->regs->w.cmdr);
 	}
 
+	/* Count may be zero for BRK, so we check for it here */
+	if ((stat->sreg.isr1 & SAB82532_ISR1_BRK) &&
+	    (up->port.line == up->port.cons->index))
+		saw_console_brk = 1;
+
 	for (i = 0; i < count; i++) {
 		unsigned char ch = buf[i];
 
@@ -172,8 +177,6 @@
 				stat->sreg.isr0 &= ~(SAB82532_ISR0_PERR |
 						     SAB82532_ISR0_FERR);
 				up->port.icount.brk++;
-				if (up->port.line == up->port.cons->index)
-					saw_console_brk = 1;
 				/*
 				 * We do the SysRQ and SAK checking
 				 * here because otherwise the break
@@ -325,8 +328,9 @@
 
 	tty = NULL;
 	if (status.stat) {
-		if (status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
-					SAB82532_ISR0_RFO | SAB82532_ISR0_RPF))
+		if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
+					 SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) ||
+		    (status.sreg.isr1 & SAB82532_ISR1_BRK))
 			tty = receive_chars(up, &status, regs);
 		if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) ||
 		    (status.sreg.isr1 & SAB82532_ISR1_CSC))
@@ -352,8 +356,10 @@
 
 	tty = NULL;
 	if (status.stat) {
-		if (status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
-					SAB82532_ISR0_RFO | SAB82532_ISR0_RPF))
+		if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
+					 SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) ||
+		    (status.sreg.isr1 & SAB82532_ISR1_BRK))
+
 			tty = receive_chars(up, &status, regs);
 		if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) ||
 		    (status.sreg.isr1 & (SAB82532_ISR1_BRK | SAB82532_ISR1_CSC)))
@@ -1125,13 +1131,13 @@
 
 	sunserial_current_minor += num_channels;
 	
+	sunsab_console_init();
+
 	for (i = 0; i < num_channels; i++) {
 		struct uart_sunsab_port *up = &sunsab_ports[i];
 
 		uart_add_one_port(&sunsab_reg, &up->port);
 	}
-
-	sunsab_console_init();
 
 	return 0;
 }
diff -Nru a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
--- a/drivers/serial/sunsu.c	2004-12-24 13:36:30 -08:00
+++ b/drivers/serial/sunsu.c	2004-12-24 13:36:30 -08:00
@@ -95,7 +95,6 @@
 	enum su_type		su_type;
 	unsigned int		type_probed;	/* XXX Stupid */
 	int			port_node;
-	unsigned int		irq;
 
 #ifdef CONFIG_SERIO
 	struct serio		*serio;
@@ -684,14 +683,14 @@
 	}
 
 	if (up->su_type != SU_PORT_PORT) {
-		retval = request_irq(up->irq, sunsu_kbd_ms_interrupt,
+		retval = request_irq(up->port.irq, sunsu_kbd_ms_interrupt,
 				     SA_SHIRQ, su_typev[up->su_type], up);
 	} else {
-		retval = request_irq(up->irq, sunsu_serial_interrupt,
+		retval = request_irq(up->port.irq, sunsu_serial_interrupt,
 				     SA_SHIRQ, su_typev[up->su_type], up);
 	}
 	if (retval) {
-		printk("su: Cannot register IRQ %d\n", up->irq);
+		printk("su: Cannot register IRQ %d\n", up->port.irq);
 		return retval;
 	}
 
@@ -779,7 +778,7 @@
 	 */
 	(void) serial_in(up, UART_RX);
 
-	free_irq(up->irq, up);
+	free_irq(up->port.irq, up);
 }
 
 static void
@@ -1078,7 +1077,7 @@
 				 * This is correct on both architectures.
 				 */
 				up->port.mapbase = dev->resource[0].start;
-				up->irq = dev->irqs[0];
+				up->port.irq = dev->irqs[0];
 				goto ebus_done;
 			}
 		}
@@ -1091,7 +1090,7 @@
 				/* Same on sparc64. Cool architecure... */
 				up->port.membase = (char *) isa_dev->resource.start;
 				up->port.mapbase = isa_dev->resource.start;
-				up->irq = isa_dev->irq;
+				up->port.irq = isa_dev->irq;
 				goto ebus_done;
 			}
 		}
@@ -1133,7 +1132,7 @@
 	/*
 	 * There is no intr property on MrCoffee, so hardwire it.
 	 */
-	up->irq = IRQ_4M(13);
+	up->port.irq = IRQ_4M(13);
 #endif
 
 ebus_done:
@@ -1303,7 +1302,7 @@
 
 	printk(KERN_INFO "su%d at 0x%p (irq = %s) is a %s\n",
 	       channel,
-	       up->port.membase, __irq_itoa(up->irq),
+	       up->port.membase, __irq_itoa(up->port.irq),
 	       sunsu_type(&up->port));
 
 #ifdef CONFIG_SERIO
@@ -1533,6 +1532,7 @@
 	if (ret < 0)
 		return ret;
 
+	sunsu_serial_console_init();
 	for (i = 0; i < UART_NR; i++) {
 		struct uart_sunsu_port *up = &sunsu_ports[i];
 
@@ -1705,7 +1705,6 @@
 	 * Console must be initiated after the generic initialization.
 	 */
        	sunsu_serial_init();
-	sunsu_serial_console_init();
 
 	return 0;
 }
diff -Nru a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
--- a/drivers/serial/sunzilog.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/serial/sunzilog.c	2004-12-24 13:37:30 -08:00
@@ -112,7 +112,7 @@
 #endif
 };
 
-#define ZILOG_CHANNEL_FROM_PORT(PORT)	((struct zilog_channel *)((PORT)->membase))
+#define ZILOG_CHANNEL_FROM_PORT(PORT)	((struct zilog_channel __iomem *)((PORT)->membase))
 #define UART_ZILOG(PORT)		((struct uart_sunzilog_port *)(PORT))
 
 #define ZS_IS_KEYB(UP)	((UP)->flags & SUNZILOG_FLAG_CONS_KEYB)
@@ -133,7 +133,7 @@
  * The port lock must be held and local IRQs must be disabled
  * when {read,write}_zsreg is invoked.
  */
-static unsigned char read_zsreg(struct zilog_channel *channel,
+static unsigned char read_zsreg(struct zilog_channel __iomem *channel,
 				unsigned char reg)
 {
 	unsigned char retval;
@@ -146,7 +146,7 @@
 	return retval;
 }
 
-static void write_zsreg(struct zilog_channel *channel,
+static void write_zsreg(struct zilog_channel __iomem *channel,
 			unsigned char reg, unsigned char value)
 {
 	sbus_writeb(reg, &channel->control);
@@ -155,7 +155,7 @@
 	ZSDELAY();
 }
 
-static void sunzilog_clear_fifo(struct zilog_channel *channel)
+static void sunzilog_clear_fifo(struct zilog_channel __iomem *channel)
 {
 	int i;
 
@@ -182,7 +182,7 @@
 /* This function must only be called when the TX is not busy.  The UART
  * port lock must be held and local interrupts disabled.
  */
-static void __load_zsregs(struct zilog_channel *channel, unsigned char *regs)
+static void __load_zsregs(struct zilog_channel __iomem *channel, unsigned char *regs)
 {
 	int i;
 
@@ -258,7 +258,7 @@
  * The UART port lock must be held and local interrupts disabled.
  */
 static void sunzilog_maybe_update_regs(struct uart_sunzilog_port *up,
-				       struct zilog_channel *channel)
+				       struct zilog_channel __iomem *channel)
 {
 	if (!ZS_REGS_HELD(up)) {
 		if (ZS_TX_ACTIVE(up)) {
@@ -315,7 +315,7 @@
 
 static struct tty_struct *
 sunzilog_receive_chars(struct uart_sunzilog_port *up,
-		       struct zilog_channel *channel,
+		       struct zilog_channel __iomem *channel,
 		       struct pt_regs *regs)
 {
 	struct tty_struct *tty;
@@ -419,7 +419,7 @@
 }
 
 static void sunzilog_status_handle(struct uart_sunzilog_port *up,
-				   struct zilog_channel *channel,
+				   struct zilog_channel __iomem *channel,
 				   struct pt_regs *regs)
 {
 	unsigned char status;
@@ -471,7 +471,7 @@
 }
 
 static void sunzilog_transmit_chars(struct uart_sunzilog_port *up,
-				    struct zilog_channel *channel)
+				    struct zilog_channel __iomem *channel)
 {
 	struct circ_buf *xmit;
 
@@ -548,7 +548,7 @@
 	struct uart_sunzilog_port *up = dev_id;
 
 	while (up) {
-		struct zilog_channel *channel
+		struct zilog_channel __iomem *channel
 			= ZILOG_CHANNEL_FROM_PORT(&up->port);
 		struct tty_struct *tty;
 		unsigned char r3;
@@ -609,7 +609,7 @@
  */
 static __inline__ unsigned char sunzilog_read_channel_status(struct uart_port *port)
 {
-	struct zilog_channel *channel;
+	struct zilog_channel __iomem *channel;
 	unsigned long flags;
 	unsigned char status;
 
@@ -662,7 +662,7 @@
 static void sunzilog_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
 	struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
-	struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
+	struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
 	unsigned char set_bits, clear_bits;
 
 	set_bits = clear_bits = 0;
@@ -694,7 +694,7 @@
 static void sunzilog_start_tx(struct uart_port *port, unsigned int tty_start)
 {
 	struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
-	struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
+	struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
 	unsigned char status;
 
 	up->flags |= SUNZILOG_FLAG_TX_ACTIVE;
@@ -736,7 +736,7 @@
 static void sunzilog_stop_rx(struct uart_port *port)
 {
 	struct uart_sunzilog_port *up = UART_ZILOG(port);
-	struct zilog_channel *channel;
+	struct zilog_channel __iomem *channel;
 
 	if (ZS_IS_CONS(up))
 		return;
@@ -752,7 +752,7 @@
 static void sunzilog_enable_ms(struct uart_port *port)
 {
 	struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
-	struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
+	struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
 	unsigned char new_reg;
 
 	new_reg = up->curregs[R15] | (DCDIE | SYNCIE | CTSIE);
@@ -768,7 +768,7 @@
 static void sunzilog_break_ctl(struct uart_port *port, int break_state)
 {
 	struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
-	struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
+	struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
 	unsigned char set_bits, clear_bits, new_reg;
 	unsigned long flags;
 
@@ -794,7 +794,7 @@
 
 static void __sunzilog_startup(struct uart_sunzilog_port *up)
 {
-	struct zilog_channel *channel;
+	struct zilog_channel __iomem *channel;
 
 	channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
 	up->prev_status = sbus_readb(&channel->control);
@@ -849,7 +849,7 @@
 static void sunzilog_shutdown(struct uart_port *port)
 {
 	struct uart_sunzilog_port *up = UART_ZILOG(port);
-	struct zilog_channel *channel;
+	struct zilog_channel __iomem *channel;
 	unsigned long flags;
 
 	if (ZS_IS_CONS(up))
@@ -974,6 +974,8 @@
 
 	sunzilog_maybe_update_regs(up, ZILOG_CHANNEL_FROM_PORT(port));
 
+	uart_update_timeout(port, termios->c_cflag, baud);
+
 	spin_unlock_irqrestore(&up->port.lock, flags);
 }
 
@@ -1025,7 +1027,7 @@
 };
 
 static struct uart_sunzilog_port *sunzilog_port_table;
-static struct zilog_layout **sunzilog_chip_regs;
+static struct zilog_layout __iomem **sunzilog_chip_regs;
 
 static struct uart_sunzilog_port *sunzilog_irq_chain;
 static int zilog_irq = -1;
@@ -1051,10 +1053,10 @@
 
 static void __init sunzilog_alloc_tables(void)
 {
-	sunzilog_port_table = (struct uart_sunzilog_port *)
+	sunzilog_port_table = 
 		alloc_one_table(NUM_CHANNELS * sizeof(struct uart_sunzilog_port));
-	sunzilog_chip_regs = (struct zilog_layout **)
-		alloc_one_table(NUM_SUNZILOG * sizeof(struct zilog_layout *));
+	sunzilog_chip_regs = 
+		alloc_one_table(NUM_SUNZILOG * sizeof(struct zilog_layout __iomem *));
 
 	if (sunzilog_port_table == NULL || sunzilog_chip_regs == NULL) {
 		prom_printf("SunZilog: Cannot allocate tables.\n");
@@ -1067,7 +1069,7 @@
 /* We used to attempt to use the address property of the Zilog device node
  * but that totally is not necessary on sparc64.
  */
-static struct zilog_layout * __init get_zs_sun4u(int chip, int zsnode)
+static struct zilog_layout __iomem * __init get_zs_sun4u(int chip, int zsnode)
 {
 	unsigned long mapped_addr;
 	unsigned int sun4u_ino;
@@ -1131,7 +1133,7 @@
 		}
 	}
 
-	return (struct zilog_layout *) mapped_addr;
+	return (struct zilog_layout __iomem *) mapped_addr;
 }
 #else /* CONFIG_SPARC64 */
 
@@ -1139,10 +1141,10 @@
  * XXX The sun4d case is utterly screwed: it tries to re-walk the tree
  * (for the 3rd time) in order to find bootbus and cpu. Streamline it.
  */
-static struct zilog_layout * __init get_zs_sun4cmd(int chip, int node)
+static struct zilog_layout __iomem * __init get_zs_sun4cmd(int chip, int node)
 {
 	struct linux_prom_irqs irq_info[2];
-	unsigned long mapped_addr = 0;
+	void __iomem *mapped_addr = NULL;
 	int zsnode, cpunode, bbnode;
 	struct linux_prom_registers zsreg[4];
 	struct resource res;
@@ -1228,12 +1230,12 @@
 		prom_halt();
 	}
 
-	return (struct zilog_layout *) mapped_addr;
+	return (struct zilog_layout __iomem *) mapped_addr;
 }
 #endif /* !(CONFIG_SPARC64) */
 
 /* Get the address of the registers for SunZilog instance CHIP.  */
-static struct zilog_layout * __init get_zs(int chip, int node)
+static struct zilog_layout __iomem * __init get_zs(int chip, int node)
 {
 	if (chip < 0 || chip >= NUM_SUNZILOG) {
 		prom_printf("SunZilog: Illegal chip number %d in get_zs.\n", chip);
@@ -1259,7 +1261,7 @@
 		zilog_irq = 12;
 		res.end = (res.start + (8 - 1));
 		res.flags = IORESOURCE_IO;
-		return (struct zilog_layout *) sbus_ioremap(&res, 0, 8, "SunZilog");
+		return sbus_ioremap(&res, 0, 8, "SunZilog");
 	}
 
 	return get_zs_sun4cmd(chip, node);
@@ -1268,7 +1270,7 @@
 
 #define ZS_PUT_CHAR_MAX_DELAY	2000	/* 10 ms */
 
-static void sunzilog_put_char(struct zilog_channel *channel, unsigned char ch)
+static void sunzilog_put_char(struct zilog_channel __iomem *channel, unsigned char ch)
 {
 	int loops = ZS_PUT_CHAR_MAX_DELAY;
 
@@ -1483,7 +1485,7 @@
 static void __init sunzilog_prepare(void)
 {
 	struct uart_sunzilog_port *up;
-	struct zilog_layout *rp;
+	struct zilog_layout __iomem *rp;
 	int channel, chip;
 
 	/*
@@ -1499,8 +1501,8 @@
 
 	for (chip = 0; chip < NUM_SUNZILOG; chip++) {
 		rp = sunzilog_chip_regs[chip];
-		up[(chip * 2) + 0].port.membase = (char *) &rp->channelA;
-		up[(chip * 2) + 1].port.membase = (char *) &rp->channelB;
+		up[(chip * 2) + 0].port.membase = (void __iomem *)&rp->channelA;
+		up[(chip * 2) + 1].port.membase = (void __iomem *)&rp->channelB;
 
 		/* Channel A */
 		up[(chip * 2) + 0].port.iotype = SERIAL_IO_MEM;
@@ -1590,7 +1592,7 @@
 
 	for (i = 0; i < NUM_CHANNELS; i++) {
 		struct uart_sunzilog_port *up = &sunzilog_port_table[i];
-		struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
+		struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
 		unsigned long flags;
 		int baud, brg;
 
@@ -1634,7 +1636,7 @@
 	}
 }
 
-static struct zilog_layout * __init get_zs(int chip, int node);
+static struct zilog_layout __iomem * __init get_zs(int chip, int node);
 
 static void __init sunzilog_scan_probe(struct zs_probe_scan *t, int node)
 {
@@ -1688,6 +1690,7 @@
 
 	ret = uart_register_driver(&sunzilog_reg);
 	if (ret == 0) {
+		sunzilog_console_init();
 		for (i = 0; i < NUM_CHANNELS; i++) {
 			struct uart_sunzilog_port *up = &sunzilog_port_table[i];
 
@@ -1736,7 +1739,6 @@
 	sunzilog_alloc_tables();
 
 	sunzilog_ports_init();
-	sunzilog_console_init();
 
 	return 0;
 }
diff -Nru a/drivers/serial/uart00.c b/drivers/serial/uart00.c
--- a/drivers/serial/uart00.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/serial/uart00.c	2004-12-24 13:36:48 -08:00
@@ -27,23 +27,25 @@
  *
  */
 #include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_UART00_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
-#include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
+#include <linux/serial.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/sizes.h>
 
-#if defined(CONFIG_SERIAL_UART00_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
 #include <asm/arch/excalibur.h>
 #define UART00_TYPE (volatile unsigned int*)
 #include <asm/arch/uart00.h>
@@ -132,9 +134,8 @@
 			goto ignore_char;
 
 	error_return:
-		*tty->flip.flag_buf_ptr++ = flg;
-		*tty->flip.char_buf_ptr++ = ch;
-		tty->flip.count++;
+		tty_insert_flip_char(tty, ch, flg);
+
 	ignore_char:
 		status = UART_GET_RSR(port);
 	}
@@ -174,11 +175,7 @@
 		 * CHECK: does overrun affect the current character?
 		 * ASSUMPTION: it does not.
 		 */
-		*tty->flip.flag_buf_ptr++ = flg;
-		*tty->flip.char_buf_ptr++ = ch;
-		tty->flip.count++;
-		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-			goto ignore_char;
+		tty_insert_flip_char(tty, ch, flg);
 		ch = 0;
 		flg = TTY_OVERRUN;
 	}
diff -Nru a/drivers/tc/zs.c b/drivers/tc/zs.c
--- a/drivers/tc/zs.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/tc/zs.c	2004-12-24 13:37:18 -08:00
@@ -55,6 +55,7 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
+#include <linux/bitops.h>
 #ifdef CONFIG_SERIAL_CONSOLE
 #include <linux/console.h>
 #endif
@@ -63,7 +64,6 @@
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/wbflush.h>
 #include <asm/bootinfo.h>
@@ -927,7 +927,7 @@
 	restore_flags(flags);
 }
 
-static int rs_write(struct tty_struct * tty, int from_user,
+static int rs_write(struct tty_struct * tty,
 		    const unsigned char *buf, int count)
 {
 	int	c, total = 0;
@@ -948,15 +948,7 @@
 		if (c <= 0)
 			break;
 
-		if (from_user) {
-			down(&tmp_buf_sem);
-			copy_from_user(tmp_buf, buf, c);
-			c = min_t(int, c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-					      SERIAL_XMIT_SIZE - info->xmit_head));
-			memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
-			up(&tmp_buf_sem);
-		} else
-			memcpy(info->xmit_buf + info->xmit_head, buf, c);
+		memcpy(info->xmit_buf + info->xmit_head, buf, c);
 		info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
 		info->xmit_cnt += c;
 		restore_flags(flags);
diff -Nru a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
--- a/drivers/telephony/ixj_pcmcia.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/telephony/ixj_pcmcia.c	2004-12-24 13:37:19 -08:00
@@ -23,7 +23,7 @@
  
 #ifdef PCMCIA_DEBUG
 static int pc_debug = PCMCIA_DEBUG;
-MODULE_PARM(pc_debug, "i");
+module_param(pc_debug, int, 0644);
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 #else
 #define DEBUG(n, args...)
diff -Nru a/drivers/usb/Kconfig b/drivers/usb/Kconfig
--- a/drivers/usb/Kconfig	2004-12-24 13:36:19 -08:00
+++ b/drivers/usb/Kconfig	2004-12-24 13:36:19 -08:00
@@ -7,7 +7,7 @@
 # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
 config USB
 	tristate "Support for Host-side USB"
-	depends on PCI || SA1111 || ARCH_OMAP1510 || ARCH_OMAP1610 || ARCH_LH7A404
+	depends on USB_ARCH_HAS_HCD
 	---help---
 	  Universal Serial Bus (USB) is a specification for a serial bus
 	  subsystem which offers higher speeds and more features than the
@@ -90,6 +90,8 @@
 source "drivers/usb/serial/Kconfig"
 
 source "drivers/usb/misc/Kconfig"
+
+source "drivers/usb/atm/Kconfig"
 
 source "drivers/usb/gadget/Kconfig"
 
diff -Nru a/drivers/usb/Makefile b/drivers/usb/Makefile
--- a/drivers/usb/Makefile	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/Makefile	2004-12-24 13:37:29 -08:00
@@ -10,6 +10,7 @@
 obj-$(CONFIG_USB_OHCI_HCD)	+= host/
 obj-$(CONFIG_USB_UHCI_HCD)	+= host/
 obj-$(CONFIG_USB_SL811HS)	+= host/
+obj-$(CONFIG_ETRAX_USB_HOST)	+= host/
 
 obj-$(CONFIG_USB_ACM)		+= class/
 obj-$(CONFIG_USB_AUDIO)		+= class/
@@ -37,6 +38,7 @@
 obj-$(CONFIG_USB_OV511)		+= media/
 obj-$(CONFIG_USB_PWC)		+= media/
 obj-$(CONFIG_USB_SE401)		+= media/
+obj-$(CONFIG_USB_SN9C102)	+= media/
 obj-$(CONFIG_USB_STV680)	+= media/
 obj-$(CONFIG_USB_VICAM)		+= media/
 obj-$(CONFIG_USB_W9968CF)	+= media/
@@ -62,8 +64,10 @@
 obj-$(CONFIG_USB_LED)		+= misc/
 obj-$(CONFIG_USB_LEGOTOWER)	+= misc/
 obj-$(CONFIG_USB_RIO500)	+= misc/
-obj-$(CONFIG_USB_SPEEDTOUCH)	+= misc/
 obj-$(CONFIG_USB_TEST)		+= misc/
 obj-$(CONFIG_USB_TIGL)		+= misc/
 obj-$(CONFIG_USB_USS720)	+= misc/
 obj-$(CONFIG_USB_PHIDGETSERVO)	+= misc/
+
+obj-$(CONFIG_USB_ATM)		+= atm/
+obj-$(CONFIG_USB_SPEEDTOUCH)	+= atm/
diff -Nru a/drivers/usb/atm/Kconfig b/drivers/usb/atm/Kconfig
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/atm/Kconfig	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,30 @@
+#
+# USB ATM driver configuration
+#
+comment "USB ATM/DSL drivers"
+	depends on USB
+
+config USB_ATM
+	tristate "Generic USB ATM/DSL core I/O support"
+	depends on USB && ATM
+	select CRC32
+	default n
+	help
+	  This provides a library which is used for packet I/O by USB DSL
+	  modems, such as the SpeedTouch driver below. 
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called usb_atm.
+
+config USB_SPEEDTOUCH
+	tristate "Alcatel Speedtouch USB support"
+	depends on USB && ATM
+	select USB_ATM
+	help
+	  Say Y here if you have an Alcatel SpeedTouch USB or SpeedTouch 330
+	  modem.  In order to use your modem you will need to install the 
+	  two parts of the firmware, extracted by the user space tools; see
+	  <http://www.linux-usb.org/SpeedTouch/> for details.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called speedtch.
diff -Nru a/drivers/usb/atm/Makefile b/drivers/usb/atm/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/atm/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,7 @@
+#
+# Makefile for the rest of the USB drivers
+# (the ones that don't fit into any other categories)
+#
+
+obj-$(CONFIG_USB_ATM)		+= usb_atm.o
+obj-$(CONFIG_USB_SPEEDTOUCH)	+= speedtch.o
diff -Nru a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/atm/speedtch.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,866 @@
+/******************************************************************************
+ *  speedtch.c  -  Alcatel SpeedTouch USB xDSL modem driver
+ *
+ *  Copyright (C) 2001, Alcatel
+ *  Copyright (C) 2003, Duncan Sands
+ *  Copyright (C) 2004, David Woodhouse
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ *
+ *  You should have received a copy of the GNU General Public License along with
+ *  this program; if not, write to the Free Software Foundation, Inc., 59
+ *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ ******************************************************************************/
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/gfp.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/slab.h>
+#include <linux/wait.h>
+#include <linux/list.h>
+#include <asm/processor.h>
+#include <asm/uaccess.h>
+#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
+#include <linux/atm.h>
+#include <linux/atmdev.h>
+#include <linux/crc32.h>
+#include <linux/init.h>
+#include <linux/firmware.h>
+
+#include "usb_atm.h"
+
+/*
+#define DEBUG
+#define VERBOSE_DEBUG
+*/
+
+#if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
+#	define DEBUG
+#endif
+
+#include <linux/usb.h>
+
+#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
+#	define USE_FW_LOADER
+#endif
+
+#ifdef VERBOSE_DEBUG
+static int udsl_print_packet(const unsigned char *data, int len);
+#define PACKETDEBUG(arg...)	udsl_print_packet (arg)
+#define vdbg(arg...)		dbg (arg)
+#else
+#define PACKETDEBUG(arg...)
+#define vdbg(arg...)
+#endif
+
+#define DRIVER_AUTHOR	"Johan Verrept, Duncan Sands <duncan.sands@free.fr>"
+#define DRIVER_VERSION	"1.8"
+#define DRIVER_DESC	"Alcatel SpeedTouch USB driver version " DRIVER_VERSION
+
+static const char speedtch_driver_name[] = "speedtch";
+
+#define SPEEDTOUCH_VENDORID		0x06b9
+#define SPEEDTOUCH_PRODUCTID		0x4061
+
+/* Timeout in jiffies */
+#define CTRL_TIMEOUT (2*HZ)
+#define DATA_TIMEOUT (2*HZ)
+
+#define OFFSET_7  0		/* size 1 */
+#define OFFSET_b  1		/* size 8 */
+#define OFFSET_d  9		/* size 4 */
+#define OFFSET_e 13		/* size 1 */
+#define OFFSET_f 14		/* size 1 */
+#define TOTAL    15
+
+#define SIZE_7 1
+#define SIZE_b 8
+#define SIZE_d 4
+#define SIZE_e 1
+#define SIZE_f 1
+
+static int dl_512_first = 0;
+static int sw_buffering = 0;
+
+module_param(dl_512_first, bool, 0444);
+MODULE_PARM_DESC(dl_512_first, "Read 512 bytes before sending firmware");
+
+module_param(sw_buffering, uint, 0444);
+MODULE_PARM_DESC(sw_buffering, "Enable software buffering");
+
+#define UDSL_IOCTL_LINE_UP		1
+#define UDSL_IOCTL_LINE_DOWN		2
+
+#define SPEEDTCH_ENDPOINT_INT		0x81
+#define SPEEDTCH_ENDPOINT_DATA		0x07
+#define SPEEDTCH_ENDPOINT_FIRMWARE	0x05
+
+#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) )
+
+static struct usb_device_id speedtch_usb_ids[] = {
+	{USB_DEVICE(SPEEDTOUCH_VENDORID, SPEEDTOUCH_PRODUCTID)},
+	{}
+};
+
+MODULE_DEVICE_TABLE(usb, speedtch_usb_ids);
+
+struct speedtch_instance_data {
+	struct udsl_instance_data u;
+
+	/* Status */
+	struct urb *int_urb;
+	unsigned char int_data[16];
+	struct work_struct poll_work;
+	struct timer_list poll_timer;
+};
+/* USB */
+
+static int speedtch_usb_probe(struct usb_interface *intf,
+			      const struct usb_device_id *id);
+static void speedtch_usb_disconnect(struct usb_interface *intf);
+static int speedtch_usb_ioctl(struct usb_interface *intf, unsigned int code,
+			      void *user_data);
+static void speedtch_handle_int(struct urb *urb, struct pt_regs *regs);
+static void speedtch_poll_status(struct speedtch_instance_data *instance);
+
+static struct usb_driver speedtch_usb_driver = {
+	.owner		= THIS_MODULE,
+	.name		= speedtch_driver_name,
+	.probe		= speedtch_usb_probe,
+	.disconnect	= speedtch_usb_disconnect,
+	.ioctl		= speedtch_usb_ioctl,
+	.id_table	= speedtch_usb_ids,
+};
+
+/***************
+**  firmware  **
+***************/
+
+static void speedtch_got_firmware(struct speedtch_instance_data *instance,
+				  int got_it)
+{
+	int err;
+	struct usb_interface *intf;
+
+	down(&instance->u.serialize);	/* vs self, speedtch_firmware_start */
+	if (instance->u.status == UDSL_LOADED_FIRMWARE)
+		goto out;
+	if (!got_it) {
+		instance->u.status = UDSL_NO_FIRMWARE;
+		goto out;
+	}
+	if ((err = usb_set_interface(instance->u.usb_dev, 1, 1)) < 0) {
+		dbg("speedtch_got_firmware: usb_set_interface returned %d!", err);
+		instance->u.status = UDSL_NO_FIRMWARE;
+		goto out;
+	}
+
+	/* Set up interrupt endpoint */
+	intf = usb_ifnum_to_if(instance->u.usb_dev, 0);
+	if (intf && !usb_driver_claim_interface(&speedtch_usb_driver, intf, NULL)) {
+
+		instance->int_urb = usb_alloc_urb(0, GFP_KERNEL);
+		if (instance->int_urb) {
+
+			usb_fill_int_urb(instance->int_urb, instance->u.usb_dev,
+					 usb_rcvintpipe(instance->u.usb_dev, SPEEDTCH_ENDPOINT_INT),
+					 instance->int_data,
+					 sizeof(instance->int_data),
+					 speedtch_handle_int, instance, 50);
+			err = usb_submit_urb(instance->int_urb, GFP_KERNEL);
+			if (err) {
+				/* Doesn't matter; we'll poll anyway */
+				dbg("speedtch_got_firmware: Submission of interrupt URB failed %d", err);
+				usb_free_urb(instance->int_urb);
+				instance->int_urb = NULL;
+				usb_driver_release_interface(&speedtch_usb_driver, intf);
+			}
+		}
+	}
+	/* Start status polling */
+	mod_timer(&instance->poll_timer, jiffies + (1 * HZ));
+
+	instance->u.status = UDSL_LOADED_FIRMWARE;
+	tasklet_schedule(&instance->u.receive_tasklet);
+ out:
+	up(&instance->u.serialize);
+	wake_up_interruptible(&instance->u.firmware_waiters);
+}
+
+static int speedtch_set_swbuff(struct speedtch_instance_data *instance,
+			       int state)
+{
+	struct usb_device *dev = instance->u.usb_dev;
+	int ret;
+
+	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+			      0x32, 0x40, state ? 0x01 : 0x00,
+			      0x00, NULL, 0, 100);
+	if (ret < 0) {
+		printk("Warning: %sabling SW buffering: usb_control_msg returned %d\n",
+		     state ? "En" : "Dis", ret);
+		return ret;
+	}
+
+	dbg("speedtch_set_swbuff: %sbled SW buffering", state ? "En" : "Dis");
+	return 0;
+}
+
+static void speedtch_test_sequence(struct speedtch_instance_data *instance)
+{
+	struct usb_device *dev = instance->u.usb_dev;
+	unsigned char buf[10];
+	int ret;
+
+	/* URB 147 */
+	buf[0] = 0x1c;
+	buf[1] = 0x50;
+	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+			      0x01, 0x40, 0x0b, 0x00, buf, 2, 100);
+	if (ret < 0)
+		printk(KERN_WARNING "%s failed on URB147: %d\n", __func__, ret);
+
+	/* URB 148 */
+	buf[0] = 0x32;
+	buf[1] = 0x00;
+	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+			      0x01, 0x40, 0x02, 0x00, buf, 2, 100);
+	if (ret < 0)
+		printk(KERN_WARNING "%s failed on URB148: %d\n", __func__, ret);
+
+	/* URB 149 */
+	buf[0] = 0x01;
+	buf[1] = 0x00;
+	buf[2] = 0x01;
+	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+			      0x01, 0x40, 0x03, 0x00, buf, 3, 100);
+	if (ret < 0)
+		printk(KERN_WARNING "%s failed on URB149: %d\n", __func__, ret);
+
+	/* URB 150 */
+	buf[0] = 0x01;
+	buf[1] = 0x00;
+	buf[2] = 0x01;
+	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+			      0x01, 0x40, 0x04, 0x00, buf, 3, 100);
+	if (ret < 0)
+		printk(KERN_WARNING "%s failed on URB150: %d\n", __func__, ret);
+}
+
+static int speedtch_start_synchro(struct speedtch_instance_data *instance)
+{
+	struct usb_device *dev = instance->u.usb_dev;
+	unsigned char buf[2];
+	int ret;
+
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+			      0x12, 0xc0, 0x04, 0x00,
+			      buf, sizeof(buf), CTRL_TIMEOUT);
+	if (ret < 0) {
+		printk(KERN_WARNING "SpeedTouch: Failed to start ADSL synchronisation: %d\n", ret);
+		return ret;
+	}
+
+	dbg("speedtch_start_synchro: modem prodded. %d Bytes returned: %02x %02x", ret, buf[0], buf[1]);
+	return 0;
+}
+
+static void speedtch_handle_int(struct urb *urb, struct pt_regs *regs)
+{
+	struct speedtch_instance_data *instance = urb->context;
+	unsigned int count = urb->actual_length;
+	int ret;
+
+	/* The magic interrupt for "up state" */
+	const static unsigned char up_int[6]   = { 0xa1, 0x00, 0x01, 0x00, 0x00, 0x00 };
+	/* The magic interrupt for "down state" */
+	const static unsigned char down_int[6] = { 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		/* this urb is terminated; clean up */
+		dbg("%s - urb shutting down with status: %d", __func__, urb->status);
+		return;
+	default:
+		dbg("%s - nonzero urb status received: %d", __func__, urb->status);
+		goto exit;
+	}
+
+	if (count < 6) {
+		dbg("%s - int packet too short", __func__);
+		goto exit;
+	}
+
+	if (!memcmp(up_int, instance->int_data, 6)) {
+		del_timer(&instance->poll_timer);
+		printk(KERN_NOTICE "DSL line goes up\n");
+	} else if (!memcmp(down_int, instance->int_data, 6)) {
+		printk(KERN_NOTICE "DSL line goes down\n");
+	} else {
+		int i;
+
+		printk(KERN_DEBUG "Unknown interrupt packet of %d bytes:", count);
+		for (i = 0; i < count; i++)
+			printk(" %02x", instance->int_data[i]);
+		printk("\n");
+	}
+	schedule_work(&instance->poll_work);
+
+ exit:
+	rmb();
+	if (!instance->int_urb)
+		return;
+
+	ret = usb_submit_urb(urb, GFP_ATOMIC);
+	if (ret)
+		err("%s - usb_submit_urb failed with result %d", __func__, ret);
+}
+
+static int speedtch_get_status(struct speedtch_instance_data *instance,
+			       unsigned char *buf)
+{
+	struct usb_device *dev = instance->u.usb_dev;
+	int ret;
+
+	memset(buf, 0, TOTAL);
+
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+			      0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7,
+			      CTRL_TIMEOUT);
+	if (ret < 0) {
+		dbg("MSG 7 failed");
+		return ret;
+	}
+
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+			      0x12, 0xc0, 0x0b, 0x00, buf + OFFSET_b, SIZE_b,
+			      CTRL_TIMEOUT);
+	if (ret < 0) {
+		dbg("MSG B failed");
+		return ret;
+	}
+
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+			      0x12, 0xc0, 0x0d, 0x00, buf + OFFSET_d, SIZE_d,
+			      CTRL_TIMEOUT);
+	if (ret < 0) {
+		dbg("MSG D failed");
+		return ret;
+	}
+
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+			      0x01, 0xc0, 0x0e, 0x00, buf + OFFSET_e, SIZE_e,
+			      CTRL_TIMEOUT);
+	if (ret < 0) {
+		dbg("MSG E failed");
+		return ret;
+	}
+
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+			      0x01, 0xc0, 0x0f, 0x00, buf + OFFSET_f, SIZE_f,
+			      CTRL_TIMEOUT);
+	if (ret < 0) {
+		dbg("MSG F failed");
+		return ret;
+	}
+
+	return 0;
+}
+
+static void speedtch_poll_status(struct speedtch_instance_data *instance)
+{
+	unsigned char buf[TOTAL];
+	int ret;
+
+	ret = speedtch_get_status(instance, buf);
+	if (ret) {
+		printk(KERN_WARNING
+		       "SpeedTouch: Error %d fetching device status\n", ret);
+		return;
+	}
+
+	dbg("Line state %02x", buf[OFFSET_7]);
+
+	switch (buf[OFFSET_7]) {
+	case 0:
+		if (instance->u.atm_dev->signal != ATM_PHY_SIG_LOST) {
+			instance->u.atm_dev->signal = ATM_PHY_SIG_LOST;
+			printk(KERN_NOTICE "ADSL line is down\n");
+		}
+		break;
+
+	case 0x08:
+		if (instance->u.atm_dev->signal != ATM_PHY_SIG_UNKNOWN) {
+			instance->u.atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
+			printk(KERN_NOTICE "ADSL line is blocked?\n");
+		}
+		break;
+
+	case 0x10:
+		if (instance->u.atm_dev->signal != ATM_PHY_SIG_LOST) {
+			instance->u.atm_dev->signal = ATM_PHY_SIG_LOST;
+			printk(KERN_NOTICE "ADSL line is synchronising\n");
+		}
+		break;
+
+	case 0x20:
+		if (instance->u.atm_dev->signal != ATM_PHY_SIG_FOUND) {
+			int down_speed = buf[OFFSET_b] | (buf[OFFSET_b + 1] << 8)
+				| (buf[OFFSET_b + 2] << 16) | (buf[OFFSET_b + 3] << 24);
+			int up_speed = buf[OFFSET_b + 4] | (buf[OFFSET_b + 5] << 8)
+				| (buf[OFFSET_b + 6] << 16) | (buf[OFFSET_b + 7] << 24);
+
+			if (!(down_speed & 0x0000ffff) &&
+			    !(up_speed & 0x0000ffff)) {
+				down_speed >>= 16;
+				up_speed >>= 16;
+			}
+			instance->u.atm_dev->link_rate = down_speed * 1000 / 424;
+			instance->u.atm_dev->signal = ATM_PHY_SIG_FOUND;
+
+			printk(KERN_NOTICE
+			       "ADSL line is up (%d Kib/s down | %d Kib/s up)\n",
+			       down_speed, up_speed);
+		}
+		break;
+
+	default:
+		if (instance->u.atm_dev->signal != ATM_PHY_SIG_UNKNOWN) {
+			instance->u.atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
+			printk(KERN_NOTICE "Unknown line state %02x\n", buf[OFFSET_7]);
+		}
+		break;
+	}
+}
+
+static void speedtch_timer_poll(unsigned long data)
+{
+	struct speedtch_instance_data *instance = (void *)data;
+
+	schedule_work(&instance->poll_work);
+	mod_timer(&instance->poll_timer, jiffies + (5 * HZ));
+}
+
+#ifdef USE_FW_LOADER
+static void speedtch_upload_firmware(struct speedtch_instance_data *instance,
+				     const struct firmware *fw1,
+				     const struct firmware *fw2)
+{
+	unsigned char *buffer;
+	struct usb_device *usb_dev = instance->u.usb_dev;
+	struct usb_interface *intf;
+	int actual_length, ret;
+	int offset;
+
+	dbg("speedtch_upload_firmware");
+
+	if (!(intf = usb_ifnum_to_if(usb_dev, 2))) {
+		dbg("speedtch_upload_firmware: interface not found!");
+		goto fail;
+	}
+
+	if (!(buffer = (unsigned char *)__get_free_page(GFP_KERNEL))) {
+		dbg("speedtch_upload_firmware: no memory for buffer!");
+		goto fail;
+	}
+
+	/* A user-space firmware loader may already have claimed interface #2 */
+	if ((ret =
+	     usb_driver_claim_interface(&speedtch_usb_driver, intf, NULL)) < 0) {
+		dbg("speedtch_upload_firmware: interface in use (%d)!", ret);
+		goto fail_free;
+	}
+
+	/* URB 7 */
+	if (dl_512_first) {	/* some modems need a read before writing the firmware */
+		ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, SPEEDTCH_ENDPOINT_FIRMWARE),
+				   buffer, 0x200, &actual_length, 2 * HZ);
+
+		if (ret < 0 && ret != -ETIMEDOUT)
+			dbg("speedtch_upload_firmware: read BLOCK0 from modem failed (%d)!", ret);
+		else
+			dbg("speedtch_upload_firmware: BLOCK0 downloaded (%d bytes)", ret);
+	}
+
+	/* URB 8 : both leds are static green */
+	for (offset = 0; offset < fw1->size; offset += PAGE_SIZE) {
+		int thislen = min_t(int, PAGE_SIZE, fw1->size - offset);
+		memcpy(buffer, fw1->data + offset, thislen);
+
+		ret = usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, SPEEDTCH_ENDPOINT_FIRMWARE),
+				   buffer, thislen, &actual_length, DATA_TIMEOUT);
+
+		if (ret < 0) {
+			dbg("speedtch_upload_firmware: write BLOCK1 to modem failed (%d)!", ret);
+			goto fail_release;
+		}
+		dbg("speedtch_upload_firmware: BLOCK1 uploaded (%d bytes)", fw1->size);
+	}
+
+	/* USB led blinking green, ADSL led off */
+
+	/* URB 11 */
+	ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, SPEEDTCH_ENDPOINT_FIRMWARE),
+			   buffer, 0x200, &actual_length, DATA_TIMEOUT);
+
+	if (ret < 0) {
+		dbg("speedtch_upload_firmware: read BLOCK2 from modem failed (%d)!", ret);
+		goto fail_release;
+	}
+	dbg("speedtch_upload_firmware: BLOCK2 downloaded (%d bytes)", actual_length);
+
+	/* URBs 12 to 139 - USB led blinking green, ADSL led off */
+	for (offset = 0; offset < fw2->size; offset += PAGE_SIZE) {
+		int thislen = min_t(int, PAGE_SIZE, fw2->size - offset);
+		memcpy(buffer, fw2->data + offset, thislen);
+
+		ret = usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, SPEEDTCH_ENDPOINT_FIRMWARE),
+				   buffer, thislen, &actual_length, DATA_TIMEOUT);
+
+		if (ret < 0) {
+			dbg("speedtch_upload_firmware: write BLOCK3 to modem failed (%d)!", ret);
+			goto fail_release;
+		}
+	}
+	dbg("speedtch_upload_firmware: BLOCK3 uploaded (%d bytes)", fw2->size);
+
+	/* USB led static green, ADSL led static red */
+
+	/* URB 142 */
+	ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, SPEEDTCH_ENDPOINT_FIRMWARE),
+			   buffer, 0x200, &actual_length, DATA_TIMEOUT);
+
+	if (ret < 0) {
+		dbg("speedtch_upload_firmware: read BLOCK4 from modem failed (%d)!", ret);
+		goto fail_release;
+	}
+
+	/* success */
+	dbg("speedtch_upload_firmware: BLOCK4 downloaded (%d bytes)", actual_length);
+
+	/* Delay to allow firmware to start up. We can do this here
+	   because we're in our own kernel thread anyway. */
+	msleep(1000);
+
+	/* Enable software buffering, if requested */
+	if (sw_buffering)
+		speedtch_set_swbuff(instance, 1);
+
+	/* Magic spell; don't ask us what this does */
+	speedtch_test_sequence(instance);
+
+	/* Start modem synchronisation */
+	if (speedtch_start_synchro(instance))
+		dbg("speedtch_start_synchro: failed");
+
+	speedtch_got_firmware(instance, 1);
+
+	free_page((unsigned long)buffer);
+	return;
+
+ fail_release:
+	/* Only release interface #2 if uploading failed; we don't release it
+	   we succeeded.  This prevents the userspace tools from trying to load
+	   the firmware themselves */
+	usb_driver_release_interface(&speedtch_usb_driver, intf);
+ fail_free:
+	free_page((unsigned long)buffer);
+ fail:
+	speedtch_got_firmware(instance, 0);
+}
+
+static int speedtch_find_firmware(struct speedtch_instance_data
+				  *instance, int phase,
+				  const struct firmware **fw_p)
+{
+	char buf[24];
+	const u16 bcdDevice = instance->u.usb_dev->descriptor.bcdDevice;
+	const u8 major_revision = bcdDevice >> 8;
+	const u8 minor_revision = bcdDevice & 0xff;
+
+	sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision);
+	dbg("speedtch_find_firmware: looking for %s", buf);
+
+	if (request_firmware(fw_p, buf, &instance->u.usb_dev->dev)) {
+		sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision);
+		dbg("speedtch_find_firmware: looking for %s", buf);
+
+		if (request_firmware(fw_p, buf, &instance->u.usb_dev->dev)) {
+			sprintf(buf, "speedtch-%d.bin", phase);
+			dbg("speedtch_find_firmware: looking for %s", buf);
+
+			if (request_firmware(fw_p, buf, &instance->u.usb_dev->dev)) {
+				dev_warn(&instance->u.usb_dev->dev, "no stage %d firmware found!", phase);
+				return -ENOENT;
+			}
+		}
+	}
+
+	dev_info(&instance->u.usb_dev->dev, "found stage %d firmware %s\n", phase, buf);
+
+	return 0;
+}
+
+static int speedtch_load_firmware(void *arg)
+{
+	const struct firmware *fw1, *fw2;
+	struct speedtch_instance_data *instance = arg;
+
+	BUG_ON(!instance);
+
+	daemonize("firmware/speedtch");
+
+	if (!speedtch_find_firmware(instance, 1, &fw1)) {
+		if (!speedtch_find_firmware(instance, 2, &fw2)) {
+			speedtch_upload_firmware(instance, fw1, fw2);
+			release_firmware(fw2);
+		}
+		release_firmware(fw1);
+	}
+
+	/* In case we failed, set state back to NO_FIRMWARE so that
+	   another later attempt may work. Otherwise, we never actually
+	   manage to recover if, for example, the firmware is on /usr and
+	   we look for it too early. */
+	speedtch_got_firmware(instance, 0);
+
+	module_put(THIS_MODULE);
+	udsl_put_instance(&instance->u);
+	return 0;
+}
+#endif /* USE_FW_LOADER */
+
+static void speedtch_firmware_start(struct speedtch_instance_data *instance)
+{
+#ifdef USE_FW_LOADER
+	int ret;
+#endif
+
+	dbg("speedtch_firmware_start");
+
+	down(&instance->u.serialize);	/* vs self, speedtch_got_firmware */
+
+	if (instance->u.status >= UDSL_LOADING_FIRMWARE) {
+		up(&instance->u.serialize);
+		return;
+	}
+
+	instance->u.status = UDSL_LOADING_FIRMWARE;
+	up(&instance->u.serialize);
+
+#ifdef USE_FW_LOADER
+	udsl_get_instance(&instance->u);
+	try_module_get(THIS_MODULE);
+
+	ret = kernel_thread(speedtch_load_firmware, instance,
+			    CLONE_FS | CLONE_FILES);
+
+	if (ret >= 0)
+		return;		/* OK */
+
+	dbg("speedtch_firmware_start: kernel_thread failed (%d)!", ret);
+
+	module_put(THIS_MODULE);
+	udsl_put_instance(&instance->u);
+	/* Just pretend it never happened... hope modem_run happens */
+#endif				/* USE_FW_LOADER */
+
+	speedtch_got_firmware(instance, 0);
+}
+
+static int speedtch_firmware_wait(struct udsl_instance_data *instance)
+{
+	speedtch_firmware_start((void *)instance);
+
+	if (wait_event_interruptible(instance->firmware_waiters, instance->status != UDSL_LOADING_FIRMWARE) < 0)
+		return -ERESTARTSYS;
+
+	return (instance->status == UDSL_LOADED_FIRMWARE) ? 0 : -EAGAIN;
+}
+
+/**********
+**  USB  **
+**********/
+
+static int speedtch_usb_ioctl(struct usb_interface *intf, unsigned int code,
+			      void *user_data)
+{
+	struct speedtch_instance_data *instance = usb_get_intfdata(intf);
+
+	dbg("speedtch_usb_ioctl entered");
+
+	if (!instance) {
+		dbg("speedtch_usb_ioctl: NULL instance!");
+		return -ENODEV;
+	}
+
+	switch (code) {
+	case UDSL_IOCTL_LINE_UP:
+		instance->u.atm_dev->signal = ATM_PHY_SIG_FOUND;
+		speedtch_got_firmware(instance, 1);
+		return (instance->u.status == UDSL_LOADED_FIRMWARE) ? 0 : -EIO;
+	case UDSL_IOCTL_LINE_DOWN:
+		instance->u.atm_dev->signal = ATM_PHY_SIG_LOST;
+		return 0;
+	default:
+		return -ENOTTY;
+	}
+}
+
+static int speedtch_usb_probe(struct usb_interface *intf,
+			      const struct usb_device_id *id)
+{
+	struct usb_device *dev = interface_to_usbdev(intf);
+	int ifnum = intf->altsetting->desc.bInterfaceNumber;
+	struct speedtch_instance_data *instance;
+	unsigned char mac_str[13];
+	int ret, i;
+	char buf7[SIZE_7];
+
+	dbg("speedtch_usb_probe: trying device with vendor=0x%x, product=0x%x, ifnum %d", dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum);
+
+	if ((dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) ||
+	    (dev->descriptor.idVendor != SPEEDTOUCH_VENDORID) ||
+	    (dev->descriptor.idProduct != SPEEDTOUCH_PRODUCTID) || (ifnum != 1))
+		return -ENODEV;
+
+	dbg("speedtch_usb_probe: device accepted");
+
+	/* instance init */
+	instance = kmalloc(sizeof(*instance), GFP_KERNEL);
+	if (!instance) {
+		dbg("speedtch_usb_probe: no memory for instance data!");
+		return -ENOMEM;
+	}
+
+	memset(instance, 0, sizeof(struct speedtch_instance_data));
+
+	if ((ret = usb_set_interface(dev, 0, 0)) < 0)
+		goto fail;
+
+	if ((ret = usb_set_interface(dev, 2, 0)) < 0)
+		goto fail;
+
+	instance->u.data_endpoint = SPEEDTCH_ENDPOINT_DATA;
+	instance->u.firmware_wait = speedtch_firmware_wait;
+	instance->u.driver_name = speedtch_driver_name;
+
+	ret = udsl_instance_setup(dev, &instance->u);
+	if (ret)
+		goto fail;
+
+	init_timer(&instance->poll_timer);
+	instance->poll_timer.function = speedtch_timer_poll;
+	instance->poll_timer.data = (unsigned long)instance;
+
+	INIT_WORK(&instance->poll_work, (void *)speedtch_poll_status, instance);
+
+	/* set MAC address, it is stored in the serial number */
+	memset(instance->u.atm_dev->esi, 0, sizeof(instance->u.atm_dev->esi));
+	if (usb_string(dev, dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) {
+		for (i = 0; i < 6; i++)
+			instance->u.atm_dev->esi[i] =
+				(hex2int(mac_str[i * 2]) * 16) + (hex2int(mac_str[i * 2 + 1]));
+	}
+
+	/* First check whether the modem already seems to be alive */
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+			      0x12, 0xc0, 0x07, 0x00, buf7, SIZE_7, HZ / 2);
+
+	if (ret == SIZE_7) {
+		dbg("firmware appears to be already loaded");
+		speedtch_got_firmware(instance, 1);
+		speedtch_poll_status(instance);
+	} else {
+		speedtch_firmware_start(instance);
+	}
+
+	usb_set_intfdata(intf, instance);
+
+	return 0;
+
+ fail:
+	kfree(instance);
+
+	return -ENOMEM;
+}
+
+static void speedtch_usb_disconnect(struct usb_interface *intf)
+{
+	struct speedtch_instance_data *instance = usb_get_intfdata(intf);
+
+	dbg("speedtch_usb_disconnect entered");
+
+	if (!instance) {
+		dbg("speedtch_usb_disconnect: NULL instance!");
+		return;
+	}
+
+/*QQ need to handle disconnects on interface #2 while uploading firmware */
+/*QQ and what about interface #1? */
+
+	if (instance->int_urb) {
+		struct urb *int_urb = instance->int_urb;
+		instance->int_urb = NULL;
+		wmb();
+		usb_unlink_urb(int_urb);
+		usb_free_urb(int_urb);
+	}
+
+	instance->int_data[0] = 1;
+	del_timer_sync(&instance->poll_timer);
+	wmb();
+	flush_scheduled_work();
+
+	udsl_instance_disconnect(&instance->u);
+
+	/* clean up */
+	usb_set_intfdata(intf, NULL);
+	udsl_put_instance(&instance->u);
+}
+
+/***********
+**  init  **
+***********/
+
+static int __init speedtch_usb_init(void)
+{
+	dbg("speedtch_usb_init: driver version " DRIVER_VERSION);
+
+	return usb_register(&speedtch_usb_driver);
+}
+
+static void __exit speedtch_usb_cleanup(void)
+{
+	dbg("speedtch_usb_cleanup entered");
+
+	usb_deregister(&speedtch_usb_driver);
+}
+
+module_init(speedtch_usb_init);
+module_exit(speedtch_usb_cleanup);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRIVER_VERSION);
diff -Nru a/drivers/usb/atm/usb_atm.c b/drivers/usb/atm/usb_atm.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/atm/usb_atm.c	2004-12-24 13:37:32 -08:00
@@ -0,0 +1,1205 @@
+/******************************************************************************
+ *  usb_atm.c - Generic USB xDSL driver core
+ *
+ *  Copyright (C) 2001, Alcatel
+ *  Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
+ *  Copyright (C) 2004, David Woodhouse
+ *
+ *  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.
+ *
+ ******************************************************************************/
+
+/*
+ *  Written by Johan Verrept, maintained by Duncan Sands (duncan.sands@free.fr)
+ *
+ *  1.7+:	- See the check-in logs
+ *
+ *  1.6:	- No longer opens a connection if the firmware is not loaded
+ *  		- Added support for the speedtouch 330
+ *  		- Removed the limit on the number of devices
+ *  		- Module now autoloads on device plugin
+ *  		- Merged relevant parts of sarlib
+ *  		- Replaced the kernel thread with a tasklet
+ *  		- New packet transmission code
+ *  		- Changed proc file contents
+ *  		- Fixed all known SMP races
+ *  		- Many fixes and cleanups
+ *  		- Various fixes by Oliver Neukum (oliver@neukum.name)
+ *
+ *  1.5A:	- Version for inclusion in 2.5 series kernel
+ *		- Modifications by Richard Purdie (rpurdie@rpsys.net)
+ *		- made compatible with kernel 2.5.6 onwards by changing
+ *		udsl_usb_send_data_context->urb to a pointer and adding code
+ *		to alloc and free it
+ *		- remove_wait_queue() added to udsl_atm_processqueue_thread()
+ *
+ *  1.5:	- fixed memory leak when atmsar_decode_aal5 returned NULL.
+ *		(reported by stephen.robinson@zen.co.uk)
+ *
+ *  1.4:	- changed the spin_lock() under interrupt to spin_lock_irqsave()
+ *		- unlink all active send urbs of a vcc that is being closed.
+ *
+ *  1.3.1:	- added the version number
+ *
+ *  1.3:	- Added multiple send urb support
+ *		- fixed memory leak and vcc->tx_inuse starvation bug
+ *		  when not enough memory left in vcc.
+ *
+ *  1.2:	- Fixed race condition in udsl_usb_send_data()
+ *  1.1:	- Turned off packet debugging
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/slab.h>
+#include <linux/wait.h>
+#include <linux/list.h>
+#include <asm/uaccess.h>
+#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
+#include <linux/atm.h>
+#include <linux/atmdev.h>
+#include <linux/crc32.h>
+#include <linux/init.h>
+#include <linux/firmware.h>
+
+#include "usb_atm.h"
+
+/*
+#define DEBUG
+#define VERBOSE_DEBUG
+*/
+
+#if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
+#	define DEBUG
+#endif
+
+#include <linux/usb.h>
+
+#ifdef DEBUG
+#define UDSL_ASSERT(x)	BUG_ON(!(x))
+#else
+#define UDSL_ASSERT(x)	do { if (!(x)) warn("failed assertion '" #x "' at line %d", __LINE__); } while(0)
+#endif
+
+#ifdef VERBOSE_DEBUG
+static int udsl_print_packet(const unsigned char *data, int len);
+#define PACKETDEBUG(arg...)	udsl_print_packet (arg)
+#define vdbg(arg...)		dbg (arg)
+#else
+#define PACKETDEBUG(arg...)
+#define vdbg(arg...)
+#endif
+
+#define DRIVER_AUTHOR	"Johan Verrept, Duncan Sands <duncan.sands@free.fr>"
+#define DRIVER_VERSION	"1.8"
+#define DRIVER_DESC	"Generic USB ATM/DSL I/O, version " DRIVER_VERSION
+
+static unsigned int num_rcv_urbs = UDSL_DEFAULT_RCV_URBS;
+static unsigned int num_snd_urbs = UDSL_DEFAULT_SND_URBS;
+static unsigned int num_rcv_bufs = UDSL_DEFAULT_RCV_BUFS;
+static unsigned int num_snd_bufs = UDSL_DEFAULT_SND_BUFS;
+static unsigned int rcv_buf_size = UDSL_DEFAULT_RCV_BUF_SIZE;
+static unsigned int snd_buf_size = UDSL_DEFAULT_SND_BUF_SIZE;
+
+module_param(num_rcv_urbs, uint, 0444);
+MODULE_PARM_DESC(num_rcv_urbs,
+		 "Number of urbs used for reception (range: 0-"
+		 __MODULE_STRING(UDSL_MAX_RCV_URBS) ", default: "
+		 __MODULE_STRING(UDSL_DEFAULT_RCV_URBS) ")");
+
+module_param(num_snd_urbs, uint, 0444);
+MODULE_PARM_DESC(num_snd_urbs,
+		 "Number of urbs used for transmission (range: 0-"
+		 __MODULE_STRING(UDSL_MAX_SND_URBS) ", default: "
+		 __MODULE_STRING(UDSL_DEFAULT_SND_URBS) ")");
+
+module_param(num_rcv_bufs, uint, 0444);
+MODULE_PARM_DESC(num_rcv_bufs,
+		 "Number of buffers used for reception (range: 0-"
+		 __MODULE_STRING(UDSL_MAX_RCV_BUFS) ", default: "
+		 __MODULE_STRING(UDSL_DEFAULT_RCV_BUFS) ")");
+
+module_param(num_snd_bufs, uint, 0444);
+MODULE_PARM_DESC(num_snd_bufs,
+		 "Number of buffers used for transmission (range: 0-"
+		 __MODULE_STRING(UDSL_MAX_SND_BUFS) ", default: "
+		 __MODULE_STRING(UDSL_DEFAULT_SND_BUFS) ")");
+
+module_param(rcv_buf_size, uint, 0444);
+MODULE_PARM_DESC(rcv_buf_size,
+		 "Size of the buffers used for reception (range: 0-"
+		 __MODULE_STRING(UDSL_MAX_RCV_BUF_SIZE) ", default: "
+		 __MODULE_STRING(UDSL_DEFAULT_RCV_BUF_SIZE) ")");
+
+module_param(snd_buf_size, uint, 0444);
+MODULE_PARM_DESC(snd_buf_size,
+		 "Size of the buffers used for transmission (range: 0-"
+		 __MODULE_STRING(UDSL_MAX_SND_BUF_SIZE) ", default: "
+		 __MODULE_STRING(UDSL_DEFAULT_SND_BUF_SIZE) ")");
+
+/* ATM */
+
+static void udsl_atm_dev_close(struct atm_dev *dev);
+static int udsl_atm_open(struct atm_vcc *vcc);
+static void udsl_atm_close(struct atm_vcc *vcc);
+static int udsl_atm_ioctl(struct atm_dev *dev, unsigned int cmd, void __user * arg);
+static int udsl_atm_send(struct atm_vcc *vcc, struct sk_buff *skb);
+static int udsl_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page);
+
+static struct atmdev_ops udsl_atm_devops = {
+	.dev_close	= udsl_atm_dev_close,
+	.open		= udsl_atm_open,
+	.close		= udsl_atm_close,
+	.ioctl		= udsl_atm_ioctl,
+	.send		= udsl_atm_send,
+	.proc_read	= udsl_atm_proc_read,
+	.owner		= THIS_MODULE,
+};
+
+/***********
+**  misc  **
+***********/
+
+static inline void udsl_pop(struct atm_vcc *vcc, struct sk_buff *skb)
+{
+	if (vcc->pop)
+		vcc->pop(vcc, skb);
+	else
+		dev_kfree_skb(skb);
+}
+
+/*************
+**  decode  **
+*************/
+
+static inline struct udsl_vcc_data *udsl_find_vcc(struct udsl_instance_data *instance,
+						  short vpi, int vci)
+{
+	struct udsl_vcc_data *vcc;
+
+	list_for_each_entry(vcc, &instance->vcc_list, list)
+		if ((vcc->vci == vci) && (vcc->vpi == vpi))
+			return vcc;
+	return NULL;
+}
+
+static void udsl_extract_cells(struct udsl_instance_data *instance,
+			       unsigned char *source, unsigned int howmany)
+{
+	struct udsl_vcc_data *cached_vcc = NULL;
+	struct atm_vcc *vcc;
+	struct sk_buff *sarb;
+	struct udsl_vcc_data *vcc_data;
+	int cached_vci = 0;
+	unsigned int i;
+	int pti;
+	int vci;
+	short cached_vpi = 0;
+	short vpi;
+
+	for (i = 0; i < howmany;
+	     i++, source += ATM_CELL_SIZE + instance->rcv_padding) {
+		vpi = ((source[0] & 0x0f) << 4) | (source[1] >> 4);
+		vci = ((source[1] & 0x0f) << 12) | (source[2] << 4) | (source[3] >> 4);
+		pti = (source[3] & 0x2) != 0;
+
+		vdbg("udsl_extract_cells: vpi %hd, vci %d, pti %d", vpi, vci, pti);
+
+		if (cached_vcc && (vci == cached_vci) && (vpi == cached_vpi))
+			vcc_data = cached_vcc;
+		else if ((vcc_data = udsl_find_vcc(instance, vpi, vci))) {
+			cached_vcc = vcc_data;
+			cached_vpi = vpi;
+			cached_vci = vci;
+		} else {
+			dbg("udsl_extract_cells: unknown vpi/vci (%hd/%d)!", vpi, vci);
+			continue;
+		}
+
+		vcc = vcc_data->vcc;
+		sarb = vcc_data->sarb;
+
+		if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) {
+			dbg("udsl_extract_cells: buffer overrun (sarb->len %u, vcc: 0x%p)!", sarb->len, vcc);
+			/* discard cells already received */
+			skb_trim(sarb, 0);
+		}
+
+		memcpy(sarb->tail, source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD);
+		__skb_put(sarb, ATM_CELL_PAYLOAD);
+
+		if (pti) {
+			struct sk_buff *skb;
+			unsigned int length;
+			unsigned int pdu_length;
+
+			length = (source[ATM_CELL_SIZE - 6] << 8) + source[ATM_CELL_SIZE - 5];
+
+			/* guard against overflow */
+			if (length > ATM_MAX_AAL5_PDU) {
+				dbg("udsl_extract_cells: bogus length %u (vcc: 0x%p)!", length, vcc);
+				atomic_inc(&vcc->stats->rx_err);
+				goto out;
+			}
+
+			pdu_length = UDSL_NUM_CELLS(length) * ATM_CELL_PAYLOAD;
+
+			if (sarb->len < pdu_length) {
+				dbg("udsl_extract_cells: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!", pdu_length, sarb->len, vcc);
+				atomic_inc(&vcc->stats->rx_err);
+				goto out;
+			}
+
+			if (crc32_be(~0, sarb->tail - pdu_length, pdu_length) != 0xc704dd7b) {
+				dbg("udsl_extract_cells: packet failed crc check (vcc: 0x%p)!", vcc);
+				atomic_inc(&vcc->stats->rx_err);
+				goto out;
+			}
+
+			vdbg("udsl_extract_cells: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", length, pdu_length, vcc);
+
+			if (!(skb = dev_alloc_skb(length))) {
+				dbg("udsl_extract_cells: no memory for skb (length: %u)!", length);
+				atomic_inc(&vcc->stats->rx_drop);
+				goto out;
+			}
+
+			vdbg("udsl_extract_cells: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", skb, skb->truesize);
+
+			if (!atm_charge(vcc, skb->truesize)) {
+				dbg("udsl_extract_cells: failed atm_charge (skb->truesize: %u)!", skb->truesize);
+				dev_kfree_skb(skb);
+				goto out;	/* atm_charge increments rx_drop */
+			}
+
+			memcpy(skb->data, sarb->tail - pdu_length, length);
+			__skb_put(skb, length);
+
+			vdbg("udsl_extract_cells: sending skb 0x%p, skb->len %u, skb->truesize %u", skb, skb->len, skb->truesize);
+
+			PACKETDEBUG(skb->data, skb->len);
+
+			vcc->push(vcc, skb);
+
+			atomic_inc(&vcc->stats->rx);
+		out:
+			skb_trim(sarb, 0);
+		}
+	}
+}
+
+/*************
+**  encode  **
+*************/
+
+static inline void udsl_fill_cell_header(unsigned char *target, struct atm_vcc *vcc)
+{
+	target[0] = vcc->vpi >> 4;
+	target[1] = (vcc->vpi << 4) | (vcc->vci >> 12);
+	target[2] = vcc->vci >> 4;
+	target[3] = vcc->vci << 4;
+	target[4] = 0xec;
+}
+
+static const unsigned char zeros[ATM_CELL_PAYLOAD];
+
+static void udsl_groom_skb(struct atm_vcc *vcc, struct sk_buff *skb)
+{
+	struct udsl_control *ctrl = UDSL_SKB(skb);
+	unsigned int zero_padding;
+	u32 crc;
+
+	ctrl->atm_data.vcc = vcc;
+
+	ctrl->num_cells = UDSL_NUM_CELLS(skb->len);
+	ctrl->num_entire = skb->len / ATM_CELL_PAYLOAD;
+
+	zero_padding = ctrl->num_cells * ATM_CELL_PAYLOAD - skb->len - ATM_AAL5_TRAILER;
+
+	if (ctrl->num_entire + 1 < ctrl->num_cells)
+		ctrl->pdu_padding = zero_padding - (ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER);
+	else
+		ctrl->pdu_padding = zero_padding;
+
+	ctrl->aal5_trailer[0] = 0;	/* UU = 0 */
+	ctrl->aal5_trailer[1] = 0;	/* CPI = 0 */
+	ctrl->aal5_trailer[2] = skb->len >> 8;
+	ctrl->aal5_trailer[3] = skb->len;
+
+	crc = crc32_be(~0, skb->data, skb->len);
+	crc = crc32_be(crc, zeros, zero_padding);
+	crc = crc32_be(crc, ctrl->aal5_trailer, 4);
+	crc = ~crc;
+
+	ctrl->aal5_trailer[4] = crc >> 24;
+	ctrl->aal5_trailer[5] = crc >> 16;
+	ctrl->aal5_trailer[6] = crc >> 8;
+	ctrl->aal5_trailer[7] = crc;
+}
+
+static unsigned int udsl_write_cells(struct udsl_instance_data *instance,
+				     unsigned int howmany, struct sk_buff *skb,
+				     unsigned char **target_p)
+{
+	struct udsl_control *ctrl = UDSL_SKB(skb);
+	unsigned char *target = *target_p;
+	unsigned int nc, ne, i;
+
+	vdbg("udsl_write_cells: howmany=%u, skb->len=%d, num_cells=%u, num_entire=%u, pdu_padding=%u", howmany, skb->len, ctrl->num_cells, ctrl->num_entire, ctrl->pdu_padding);
+
+	nc = ctrl->num_cells;
+	ne = min(howmany, ctrl->num_entire);
+
+	for (i = 0; i < ne; i++) {
+		udsl_fill_cell_header(target, ctrl->atm_data.vcc);
+		target += ATM_CELL_HEADER;
+		memcpy(target, skb->data, ATM_CELL_PAYLOAD);
+		target += ATM_CELL_PAYLOAD;
+		if (instance->snd_padding) {
+			memset(target, 0, instance->snd_padding);
+			target += instance->snd_padding;
+		}
+		__skb_pull(skb, ATM_CELL_PAYLOAD);
+	}
+
+	ctrl->num_entire -= ne;
+
+	if (!(ctrl->num_cells -= ne) || !(howmany -= ne))
+		goto out;
+
+	udsl_fill_cell_header(target, ctrl->atm_data.vcc);
+	target += ATM_CELL_HEADER;
+	memcpy(target, skb->data, skb->len);
+	target += skb->len;
+	__skb_pull(skb, skb->len);
+	memset(target, 0, ctrl->pdu_padding);
+	target += ctrl->pdu_padding;
+
+	if (--ctrl->num_cells) {
+		if (!--howmany) {
+			ctrl->pdu_padding = ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER;
+			goto out;
+		}
+
+		if (instance->snd_padding) {
+			memset(target, 0, instance->snd_padding);
+			target += instance->snd_padding;
+		}
+		udsl_fill_cell_header(target, ctrl->atm_data.vcc);
+		target += ATM_CELL_HEADER;
+		memset(target, 0, ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER);
+		target += ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER;
+
+		--ctrl->num_cells;
+		UDSL_ASSERT(!ctrl->num_cells);
+	}
+
+	memcpy(target, ctrl->aal5_trailer, ATM_AAL5_TRAILER);
+	target += ATM_AAL5_TRAILER;
+	/* set pti bit in last cell */
+	*(target + 3 - ATM_CELL_SIZE) |= 0x2;
+	if (instance->snd_padding) {
+		memset(target, 0, instance->snd_padding);
+		target += instance->snd_padding;
+	}
+ out:
+	*target_p = target;
+	return nc - ctrl->num_cells;
+}
+
+/**************
+**  receive  **
+**************/
+
+static void udsl_complete_receive(struct urb *urb, struct pt_regs *regs)
+{
+	struct udsl_receive_buffer *buf;
+	struct udsl_instance_data *instance;
+	struct udsl_receiver *rcv;
+	unsigned long flags;
+
+	if (!urb || !(rcv = urb->context)) {
+		dbg("udsl_complete_receive: bad urb!");
+		return;
+	}
+
+	instance = rcv->instance;
+	buf = rcv->buffer;
+
+	buf->filled_cells = urb->actual_length / (ATM_CELL_SIZE + instance->rcv_padding);
+
+	vdbg("udsl_complete_receive: urb 0x%p, status %d, actual_length %d, filled_cells %u, rcv 0x%p, buf 0x%p", urb, urb->status, urb->actual_length, buf->filled_cells, rcv, buf);
+
+	UDSL_ASSERT(buf->filled_cells <= rcv_buf_size);
+
+	/* may not be in_interrupt() */
+	spin_lock_irqsave(&instance->receive_lock, flags);
+	list_add(&rcv->list, &instance->spare_receivers);
+	list_add_tail(&buf->list, &instance->filled_receive_buffers);
+	if (likely(!urb->status))
+		tasklet_schedule(&instance->receive_tasklet);
+	spin_unlock_irqrestore(&instance->receive_lock, flags);
+}
+
+static void udsl_process_receive(unsigned long data)
+{
+	struct udsl_receive_buffer *buf;
+	struct udsl_instance_data *instance = (struct udsl_instance_data *)data;
+	struct udsl_receiver *rcv;
+	int err;
+
+ made_progress:
+	while (!list_empty(&instance->spare_receive_buffers)) {
+		spin_lock_irq(&instance->receive_lock);
+		if (list_empty(&instance->spare_receivers)) {
+			spin_unlock_irq(&instance->receive_lock);
+			break;
+		}
+		rcv = list_entry(instance->spare_receivers.next,
+				 struct udsl_receiver, list);
+		list_del(&rcv->list);
+		spin_unlock_irq(&instance->receive_lock);
+
+		buf = list_entry(instance->spare_receive_buffers.next,
+				 struct udsl_receive_buffer, list);
+		list_del(&buf->list);
+
+		rcv->buffer = buf;
+
+		usb_fill_bulk_urb(rcv->urb, instance->usb_dev,
+				  usb_rcvbulkpipe(instance->usb_dev, instance->data_endpoint),
+				  buf->base,
+				  rcv_buf_size * (ATM_CELL_SIZE + instance->rcv_padding),
+				  udsl_complete_receive, rcv);
+
+		vdbg("udsl_process_receive: sending urb 0x%p, rcv 0x%p, buf 0x%p",
+		     rcv->urb, rcv, buf);
+
+		if ((err = usb_submit_urb(rcv->urb, GFP_ATOMIC)) < 0) {
+			dbg("udsl_process_receive: urb submission failed (%d)!", err);
+			list_add(&buf->list, &instance->spare_receive_buffers);
+			spin_lock_irq(&instance->receive_lock);
+			list_add(&rcv->list, &instance->spare_receivers);
+			spin_unlock_irq(&instance->receive_lock);
+			break;
+		}
+	}
+
+	spin_lock_irq(&instance->receive_lock);
+	if (list_empty(&instance->filled_receive_buffers)) {
+		spin_unlock_irq(&instance->receive_lock);
+		return;		/* done - no more buffers */
+	}
+	buf = list_entry(instance->filled_receive_buffers.next,
+			 struct udsl_receive_buffer, list);
+	list_del(&buf->list);
+	spin_unlock_irq(&instance->receive_lock);
+
+	vdbg("udsl_process_receive: processing buf 0x%p", buf);
+	udsl_extract_cells(instance, buf->base, buf->filled_cells);
+	list_add(&buf->list, &instance->spare_receive_buffers);
+	goto made_progress;
+}
+
+/***********
+**  send  **
+***********/
+
+static void udsl_complete_send(struct urb *urb, struct pt_regs *regs)
+{
+	struct udsl_instance_data *instance;
+	struct udsl_sender *snd;
+	unsigned long flags;
+
+	if (!urb || !(snd = urb->context) || !(instance = snd->instance)) {
+		dbg("udsl_complete_send: bad urb!");
+		return;
+	}
+
+	vdbg("udsl_complete_send: urb 0x%p, status %d, snd 0x%p, buf 0x%p", urb,
+	     urb->status, snd, snd->buffer);
+
+	/* may not be in_interrupt() */
+	spin_lock_irqsave(&instance->send_lock, flags);
+	list_add(&snd->list, &instance->spare_senders);
+	list_add(&snd->buffer->list, &instance->spare_send_buffers);
+	tasklet_schedule(&instance->send_tasklet);
+	spin_unlock_irqrestore(&instance->send_lock, flags);
+}
+
+static void udsl_process_send(unsigned long data)
+{
+	struct udsl_send_buffer *buf;
+	struct udsl_instance_data *instance = (struct udsl_instance_data *)data;
+	struct sk_buff *skb;
+	struct udsl_sender *snd;
+	int err;
+	unsigned int num_written;
+
+ made_progress:
+	spin_lock_irq(&instance->send_lock);
+	while (!list_empty(&instance->spare_senders)) {
+		if (!list_empty(&instance->filled_send_buffers)) {
+			buf = list_entry(instance->filled_send_buffers.next,
+					 struct udsl_send_buffer, list);
+			list_del(&buf->list);
+		} else if ((buf = instance->current_buffer)) {
+			instance->current_buffer = NULL;
+		} else		/* all buffers empty */
+			break;
+
+		snd = list_entry(instance->spare_senders.next,
+				 struct udsl_sender, list);
+		list_del(&snd->list);
+		spin_unlock_irq(&instance->send_lock);
+
+		snd->buffer = buf;
+		usb_fill_bulk_urb(snd->urb, instance->usb_dev,
+				  usb_sndbulkpipe(instance->usb_dev, instance->data_endpoint),
+				  buf->base,
+				  (snd_buf_size - buf->free_cells) * (ATM_CELL_SIZE + instance->snd_padding),
+				  udsl_complete_send, snd);
+
+		vdbg("udsl_process_send: submitting urb 0x%p (%d cells), snd 0x%p, buf 0x%p",
+		     snd->urb, snd_buf_size - buf->free_cells, snd, buf);
+
+		if ((err = usb_submit_urb(snd->urb, GFP_ATOMIC)) < 0) {
+			dbg("udsl_process_send: urb submission failed (%d)!", err);
+			spin_lock_irq(&instance->send_lock);
+			list_add(&snd->list, &instance->spare_senders);
+			spin_unlock_irq(&instance->send_lock);
+			list_add(&buf->list, &instance->filled_send_buffers);
+			return;	/* bail out */
+		}
+
+		spin_lock_irq(&instance->send_lock);
+	}			/* while */
+	spin_unlock_irq(&instance->send_lock);
+
+	if (!instance->current_skb)
+		instance->current_skb = skb_dequeue(&instance->sndqueue);
+	if (!instance->current_skb)
+		return;		/* done - no more skbs */
+
+	skb = instance->current_skb;
+
+	if (!(buf = instance->current_buffer)) {
+		spin_lock_irq(&instance->send_lock);
+		if (list_empty(&instance->spare_send_buffers)) {
+			instance->current_buffer = NULL;
+			spin_unlock_irq(&instance->send_lock);
+			return;	/* done - no more buffers */
+		}
+		buf = list_entry(instance->spare_send_buffers.next,
+			       struct udsl_send_buffer, list);
+		list_del(&buf->list);
+		spin_unlock_irq(&instance->send_lock);
+
+		buf->free_start = buf->base;
+		buf->free_cells = snd_buf_size;
+
+		instance->current_buffer = buf;
+	}
+
+	num_written = udsl_write_cells(instance, buf->free_cells, skb, &buf->free_start);
+
+	vdbg("udsl_process_send: wrote %u cells from skb 0x%p to buffer 0x%p",
+	     num_written, skb, buf);
+
+	if (!(buf->free_cells -= num_written)) {
+		list_add_tail(&buf->list, &instance->filled_send_buffers);
+		instance->current_buffer = NULL;
+	}
+
+	vdbg("udsl_process_send: buffer contains %d cells, %d left",
+	     snd_buf_size - buf->free_cells, buf->free_cells);
+
+	if (!UDSL_SKB(skb)->num_cells) {
+		struct atm_vcc *vcc = UDSL_SKB(skb)->atm_data.vcc;
+
+		udsl_pop(vcc, skb);
+		instance->current_skb = NULL;
+
+		atomic_inc(&vcc->stats->tx);
+	}
+
+	goto made_progress;
+}
+
+static void udsl_cancel_send(struct udsl_instance_data *instance,
+			     struct atm_vcc *vcc)
+{
+	struct sk_buff *skb, *n;
+
+	dbg("udsl_cancel_send entered");
+	spin_lock_irq(&instance->sndqueue.lock);
+	for (skb = instance->sndqueue.next, n = skb->next;
+	     skb != (struct sk_buff *)&instance->sndqueue;
+	     skb = n, n = skb->next)
+		if (UDSL_SKB(skb)->atm_data.vcc == vcc) {
+			dbg("udsl_cancel_send: popping skb 0x%p", skb);
+			__skb_unlink(skb, &instance->sndqueue);
+			udsl_pop(vcc, skb);
+		}
+	spin_unlock_irq(&instance->sndqueue.lock);
+
+	tasklet_disable(&instance->send_tasklet);
+	if ((skb = instance->current_skb) && (UDSL_SKB(skb)->atm_data.vcc == vcc)) {
+		dbg("udsl_cancel_send: popping current skb (0x%p)", skb);
+		instance->current_skb = NULL;
+		udsl_pop(vcc, skb);
+	}
+	tasklet_enable(&instance->send_tasklet);
+	dbg("udsl_cancel_send done");
+}
+
+static int udsl_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
+{
+	struct udsl_instance_data *instance = vcc->dev->dev_data;
+	int err;
+
+	vdbg("udsl_atm_send called (skb 0x%p, len %u)", skb, skb->len);
+
+	if (!instance) {
+		dbg("udsl_atm_send: NULL data!");
+		err = -ENODEV;
+		goto fail;
+	}
+
+	if (vcc->qos.aal != ATM_AAL5) {
+		dbg("udsl_atm_send: unsupported ATM type %d!", vcc->qos.aal);
+		err = -EINVAL;
+		goto fail;
+	}
+
+	if (skb->len > ATM_MAX_AAL5_PDU) {
+		dbg("udsl_atm_send: packet too long (%d vs %d)!", skb->len,
+		    ATM_MAX_AAL5_PDU);
+		err = -EINVAL;
+		goto fail;
+	}
+
+	PACKETDEBUG(skb->data, skb->len);
+
+	udsl_groom_skb(vcc, skb);
+	skb_queue_tail(&instance->sndqueue, skb);
+	tasklet_schedule(&instance->send_tasklet);
+
+	return 0;
+
+ fail:
+	udsl_pop(vcc, skb);
+	return err;
+}
+
+/********************
+**  bean counting  **
+********************/
+
+static void udsl_destroy_instance(struct kref *kref)
+{
+	struct udsl_instance_data *instance =
+	    container_of(kref, struct udsl_instance_data, refcount);
+
+	tasklet_kill(&instance->receive_tasklet);
+	tasklet_kill(&instance->send_tasklet);
+	usb_put_dev(instance->usb_dev);
+	kfree(instance);
+}
+
+void udsl_get_instance(struct udsl_instance_data *instance)
+{
+	kref_get(&instance->refcount);
+}
+
+void udsl_put_instance(struct udsl_instance_data *instance)
+{
+	kref_put(&instance->refcount, udsl_destroy_instance);
+}
+
+/**********
+**  ATM  **
+**********/
+
+static void udsl_atm_dev_close(struct atm_dev *dev)
+{
+	struct udsl_instance_data *instance = dev->dev_data;
+
+	dev->dev_data = NULL;
+	udsl_put_instance(instance);
+}
+
+static int udsl_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page)
+{
+	struct udsl_instance_data *instance = atm_dev->dev_data;
+	int left = *pos;
+
+	if (!instance) {
+		dbg("udsl_atm_proc_read: NULL instance!");
+		return -ENODEV;
+	}
+
+	if (!left--)
+		return sprintf(page, "%s\n", instance->description);
+
+	if (!left--)
+		return sprintf(page, "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
+			       atm_dev->esi[0], atm_dev->esi[1],
+			       atm_dev->esi[2], atm_dev->esi[3],
+			       atm_dev->esi[4], atm_dev->esi[5]);
+
+	if (!left--)
+		return sprintf(page,
+			       "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
+			       atomic_read(&atm_dev->stats.aal5.tx),
+			       atomic_read(&atm_dev->stats.aal5.tx_err),
+			       atomic_read(&atm_dev->stats.aal5.rx),
+			       atomic_read(&atm_dev->stats.aal5.rx_err),
+			       atomic_read(&atm_dev->stats.aal5.rx_drop));
+
+	if (!left--) {
+		switch (atm_dev->signal) {
+		case ATM_PHY_SIG_FOUND:
+			sprintf(page, "Line up");
+			break;
+		case ATM_PHY_SIG_LOST:
+			sprintf(page, "Line down");
+			break;
+		default:
+			sprintf(page, "Line state unknown");
+			break;
+		}
+
+		if (instance->usb_dev->state == USB_STATE_NOTATTACHED)
+			strcat(page, ", disconnected\n");
+		else {
+			if (instance->status == UDSL_LOADED_FIRMWARE)
+				strcat(page, ", firmware loaded\n");
+			else if (instance->status == UDSL_LOADING_FIRMWARE)
+				strcat(page, ", firmware loading\n");
+			else
+				strcat(page, ", no firmware\n");
+		}
+
+		return strlen(page);
+	}
+
+	return 0;
+}
+
+static int udsl_atm_open(struct atm_vcc *vcc)
+{
+	struct udsl_instance_data *instance = vcc->dev->dev_data;
+	struct udsl_vcc_data *new;
+	unsigned int max_pdu;
+	int vci = vcc->vci;
+	short vpi = vcc->vpi;
+	int err;
+
+	dbg("udsl_atm_open: vpi %hd, vci %d", vpi, vci);
+
+	if (!instance) {
+		dbg("udsl_atm_open: NULL data!");
+		return -ENODEV;
+	}
+
+	/* only support AAL5 */
+	if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0)
+	    || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
+		dbg("udsl_atm_open: unsupported ATM type %d!", vcc->qos.aal);
+		return -EINVAL;
+	}
+
+	if (instance->firmware_wait &&
+	    (err = instance->firmware_wait(instance)) < 0) {
+		dbg("udsl_atm_open: firmware not loaded (%d)!", err);
+		return err;
+	}
+
+	down(&instance->serialize);	/* vs self, udsl_atm_close */
+
+	if (udsl_find_vcc(instance, vpi, vci)) {
+		dbg("udsl_atm_open: %hd/%d already in use!", vpi, vci);
+		up(&instance->serialize);
+		return -EADDRINUSE;
+	}
+
+	if (!(new = kmalloc(sizeof(struct udsl_vcc_data), GFP_KERNEL))) {
+		dbg("udsl_atm_open: no memory for vcc_data!");
+		up(&instance->serialize);
+		return -ENOMEM;
+	}
+
+	memset(new, 0, sizeof(struct udsl_vcc_data));
+	new->vcc = vcc;
+	new->vpi = vpi;
+	new->vci = vci;
+
+	/* udsl_extract_cells requires at least one cell */
+	max_pdu = max(1, UDSL_NUM_CELLS(vcc->qos.rxtp.max_sdu)) * ATM_CELL_PAYLOAD;
+	if (!(new->sarb = alloc_skb(max_pdu, GFP_KERNEL))) {
+		dbg("udsl_atm_open: no memory for SAR buffer!");
+		kfree(new);
+		up(&instance->serialize);
+		return -ENOMEM;
+	}
+
+	vcc->dev_data = new;
+
+	tasklet_disable(&instance->receive_tasklet);
+	list_add(&new->list, &instance->vcc_list);
+	tasklet_enable(&instance->receive_tasklet);
+
+	set_bit(ATM_VF_ADDR, &vcc->flags);
+	set_bit(ATM_VF_PARTIAL, &vcc->flags);
+	set_bit(ATM_VF_READY, &vcc->flags);
+
+	up(&instance->serialize);
+
+	tasklet_schedule(&instance->receive_tasklet);
+
+	dbg("udsl_atm_open: allocated vcc data 0x%p (max_pdu: %u)", new, max_pdu);
+
+	return 0;
+}
+
+static void udsl_atm_close(struct atm_vcc *vcc)
+{
+	struct udsl_instance_data *instance = vcc->dev->dev_data;
+	struct udsl_vcc_data *vcc_data = vcc->dev_data;
+
+	dbg("udsl_atm_close called");
+
+	if (!instance || !vcc_data) {
+		dbg("udsl_atm_close: NULL data!");
+		return;
+	}
+
+	dbg("udsl_atm_close: deallocating vcc 0x%p with vpi %d vci %d",
+	    vcc_data, vcc_data->vpi, vcc_data->vci);
+
+	udsl_cancel_send(instance, vcc);
+
+	down(&instance->serialize);	/* vs self, udsl_atm_open */
+
+	tasklet_disable(&instance->receive_tasklet);
+	list_del(&vcc_data->list);
+	tasklet_enable(&instance->receive_tasklet);
+
+	kfree_skb(vcc_data->sarb);
+	vcc_data->sarb = NULL;
+
+	kfree(vcc_data);
+	vcc->dev_data = NULL;
+
+	vcc->vpi = ATM_VPI_UNSPEC;
+	vcc->vci = ATM_VCI_UNSPEC;
+	clear_bit(ATM_VF_READY, &vcc->flags);
+	clear_bit(ATM_VF_PARTIAL, &vcc->flags);
+	clear_bit(ATM_VF_ADDR, &vcc->flags);
+
+	up(&instance->serialize);
+
+	dbg("udsl_atm_close successful");
+}
+
+static int udsl_atm_ioctl(struct atm_dev *dev, unsigned int cmd,
+			  void __user * arg)
+{
+	switch (cmd) {
+	case ATM_QUERYLOOP:
+		return put_user(ATM_LM_NONE, (int __user *)arg) ? -EFAULT : 0;
+	default:
+		return -ENOIOCTLCMD;
+	}
+}
+
+/**********
+**  USB  **
+**********/
+
+int udsl_instance_setup(struct usb_device *dev,
+			struct udsl_instance_data *instance)
+{
+	char *buf;
+	int i, length;
+
+	kref_init(&instance->refcount);	/* one for USB */
+	udsl_get_instance(instance);	/* one for ATM */
+
+	init_MUTEX(&instance->serialize);
+
+	instance->usb_dev = dev;
+
+	INIT_LIST_HEAD(&instance->vcc_list);
+
+	instance->status = UDSL_NO_FIRMWARE;
+	init_waitqueue_head(&instance->firmware_waiters);
+
+	spin_lock_init(&instance->receive_lock);
+	INIT_LIST_HEAD(&instance->spare_receivers);
+	INIT_LIST_HEAD(&instance->filled_receive_buffers);
+
+	tasklet_init(&instance->receive_tasklet, udsl_process_receive, (unsigned long)instance);
+	INIT_LIST_HEAD(&instance->spare_receive_buffers);
+
+	skb_queue_head_init(&instance->sndqueue);
+
+	spin_lock_init(&instance->send_lock);
+	INIT_LIST_HEAD(&instance->spare_senders);
+	INIT_LIST_HEAD(&instance->spare_send_buffers);
+
+	tasklet_init(&instance->send_tasklet, udsl_process_send,
+		     (unsigned long)instance);
+	INIT_LIST_HEAD(&instance->filled_send_buffers);
+
+	/* receive init */
+	for (i = 0; i < num_rcv_urbs; i++) {
+		struct udsl_receiver *rcv = &(instance->receivers[i]);
+
+		if (!(rcv->urb = usb_alloc_urb(0, GFP_KERNEL))) {
+			dbg("udsl_usb_probe: no memory for receive urb %d!", i);
+			goto fail;
+		}
+
+		rcv->instance = instance;
+
+		list_add(&rcv->list, &instance->spare_receivers);
+	}
+
+	for (i = 0; i < num_rcv_bufs; i++) {
+		struct udsl_receive_buffer *buf =
+		    &(instance->receive_buffers[i]);
+
+		buf->base = kmalloc(rcv_buf_size * (ATM_CELL_SIZE + instance->rcv_padding),
+				    GFP_KERNEL);
+		if (!buf->base) {
+			dbg("udsl_usb_probe: no memory for receive buffer %d!", i);
+			goto fail;
+		}
+
+		list_add(&buf->list, &instance->spare_receive_buffers);
+	}
+
+	/* send init */
+	for (i = 0; i < num_snd_urbs; i++) {
+		struct udsl_sender *snd = &(instance->senders[i]);
+
+		if (!(snd->urb = usb_alloc_urb(0, GFP_KERNEL))) {
+			dbg("udsl_usb_probe: no memory for send urb %d!", i);
+			goto fail;
+		}
+
+		snd->instance = instance;
+
+		list_add(&snd->list, &instance->spare_senders);
+	}
+
+	for (i = 0; i < num_snd_bufs; i++) {
+		struct udsl_send_buffer *buf = &(instance->send_buffers[i]);
+
+		buf->base = kmalloc(snd_buf_size * (ATM_CELL_SIZE + instance->snd_padding),
+				    GFP_KERNEL);
+		if (!buf->base) {
+			dbg("udsl_usb_probe: no memory for send buffer %d!", i);
+			goto fail;
+		}
+
+		list_add(&buf->list, &instance->spare_send_buffers);
+	}
+
+	/* ATM init */
+	instance->atm_dev = atm_dev_register(instance->driver_name,
+					     &udsl_atm_devops, -1, NULL);
+	if (!instance->atm_dev) {
+		dbg("udsl_usb_probe: failed to register ATM device!");
+		goto fail;
+	}
+
+	instance->atm_dev->ci_range.vpi_bits = ATM_CI_MAX;
+	instance->atm_dev->ci_range.vci_bits = ATM_CI_MAX;
+	instance->atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
+
+	/* temp init ATM device, set to 128kbit */
+	instance->atm_dev->link_rate = 128 * 1000 / 424;
+
+	/* device description */
+	buf = instance->description;
+	length = sizeof(instance->description);
+
+	if ((i = usb_string(dev, dev->descriptor.iProduct, buf, length)) < 0)
+		goto finish;
+
+	buf += i;
+	length -= i;
+
+	i = scnprintf(buf, length, " (");
+	buf += i;
+	length -= i;
+
+	if (length <= 0 || (i = usb_make_path(dev, buf, length)) < 0)
+		goto finish;
+
+	buf += i;
+	length -= i;
+
+	snprintf(buf, length, ")");
+
+ finish:
+	/* ready for ATM callbacks */
+	wmb();
+	instance->atm_dev->dev_data = instance;
+
+	usb_get_dev(dev);
+
+	return 0;
+
+ fail:
+	for (i = 0; i < num_snd_bufs; i++)
+		kfree(instance->send_buffers[i].base);
+
+	for (i = 0; i < num_snd_urbs; i++)
+		usb_free_urb(instance->senders[i].urb);
+
+	for (i = 0; i < num_rcv_bufs; i++)
+		kfree(instance->receive_buffers[i].base);
+
+	for (i = 0; i < num_rcv_urbs; i++)
+		usb_free_urb(instance->receivers[i].urb);
+
+	return -ENOMEM;
+}
+
+void udsl_instance_disconnect(struct udsl_instance_data *instance)
+{
+	int i;
+
+	dbg("udsl_instance_disconnect entered");
+
+	if (!instance) {
+		dbg("udsl_instance_disconnect: NULL instance!");
+		return;
+	}
+
+	/* receive finalize */
+	tasklet_disable(&instance->receive_tasklet);
+
+	for (i = 0; i < num_rcv_urbs; i++)
+		usb_kill_urb(instance->receivers[i].urb);
+
+	/* no need to take the spinlock */
+	INIT_LIST_HEAD(&instance->filled_receive_buffers);
+	INIT_LIST_HEAD(&instance->spare_receive_buffers);
+
+	tasklet_enable(&instance->receive_tasklet);
+
+	for (i = 0; i < num_rcv_urbs; i++)
+		usb_free_urb(instance->receivers[i].urb);
+
+	for (i = 0; i < num_rcv_bufs; i++)
+		kfree(instance->receive_buffers[i].base);
+
+	/* send finalize */
+	tasklet_disable(&instance->send_tasklet);
+
+	for (i = 0; i < num_snd_urbs; i++)
+		usb_kill_urb(instance->senders[i].urb);
+
+	/* no need to take the spinlock */
+	INIT_LIST_HEAD(&instance->spare_senders);
+	INIT_LIST_HEAD(&instance->spare_send_buffers);
+	instance->current_buffer = NULL;
+
+	tasklet_enable(&instance->send_tasklet);
+
+	for (i = 0; i < num_snd_urbs; i++)
+		usb_free_urb(instance->senders[i].urb);
+
+	for (i = 0; i < num_snd_bufs; i++)
+		kfree(instance->send_buffers[i].base);
+
+	/* ATM finalize */
+	shutdown_atm_dev(instance->atm_dev);
+}
+
+EXPORT_SYMBOL_GPL(udsl_get_instance);
+EXPORT_SYMBOL_GPL(udsl_put_instance);
+EXPORT_SYMBOL_GPL(udsl_instance_setup);
+EXPORT_SYMBOL_GPL(udsl_instance_disconnect);
+
+/***********
+**  init  **
+***********/
+
+static int __init udsl_usb_init(void)
+{
+	dbg("udsl_usb_init: driver version " DRIVER_VERSION);
+
+	if (sizeof(struct udsl_control) > sizeof(((struct sk_buff *) 0)->cb)) {
+		printk(KERN_ERR __FILE__ ": unusable with this kernel!\n");
+		return -EIO;
+	}
+
+	if ((num_rcv_urbs > UDSL_MAX_RCV_URBS)
+	    || (num_snd_urbs > UDSL_MAX_SND_URBS)
+	    || (num_rcv_bufs > UDSL_MAX_RCV_BUFS)
+	    || (num_snd_bufs > UDSL_MAX_SND_BUFS)
+	    || (rcv_buf_size > UDSL_MAX_RCV_BUF_SIZE)
+	    || (snd_buf_size > UDSL_MAX_SND_BUF_SIZE))
+		return -EINVAL;
+
+	return 0;
+}
+
+static void __exit udsl_usb_exit(void)
+{
+}
+
+module_init(udsl_usb_init);
+module_exit(udsl_usb_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRIVER_VERSION);
+
+/************
+**  debug  **
+************/
+
+#ifdef VERBOSE_DEBUG
+static int udsl_print_packet(const unsigned char *data, int len)
+{
+	unsigned char buffer[256];
+	int i = 0, j = 0;
+
+	for (i = 0; i < len;) {
+		buffer[0] = '\0';
+		sprintf(buffer, "%.3d :", i);
+		for (j = 0; (j < 16) && (i < len); j++, i++) {
+			sprintf(buffer, "%s %2.2x", buffer, data[i]);
+		}
+		dbg("%s", buffer);
+	}
+	return i;
+}
+#endif
diff -Nru a/drivers/usb/atm/usb_atm.h b/drivers/usb/atm/usb_atm.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/atm/usb_atm.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,159 @@
+/******************************************************************************
+ *  usb_atm.h - Generic USB xDSL driver core
+ *
+ *  Copyright (C) 2001, Alcatel
+ *  Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
+ *  Copyright (C) 2004, David Woodhouse
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ *
+ *  You should have received a copy of the GNU General Public License along with
+ *  this program; if not, write to the Free Software Foundation, Inc., 59
+ *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ ******************************************************************************/
+
+#include <linux/list.h>
+#include <linux/usb.h>
+#include <linux/kref.h>
+#include <linux/atm.h>
+#include <linux/atmdev.h>
+#include <asm/semaphore.h>
+
+#define UDSL_MAX_RCV_URBS		4
+#define UDSL_MAX_SND_URBS		4
+#define UDSL_MAX_RCV_BUFS		8
+#define UDSL_MAX_SND_BUFS		8
+#define UDSL_MAX_RCV_BUF_SIZE		1024	/* ATM cells */
+#define UDSL_MAX_SND_BUF_SIZE		1024	/* ATM cells */
+#define UDSL_DEFAULT_RCV_URBS		2
+#define UDSL_DEFAULT_SND_URBS		2
+#define UDSL_DEFAULT_RCV_BUFS		4
+#define UDSL_DEFAULT_SND_BUFS		4
+#define UDSL_DEFAULT_RCV_BUF_SIZE	64	/* ATM cells */
+#define UDSL_DEFAULT_SND_BUF_SIZE	64	/* ATM cells */
+
+#define ATM_CELL_HEADER			(ATM_CELL_SIZE - ATM_CELL_PAYLOAD)
+#define UDSL_NUM_CELLS(x)		(((x) + ATM_AAL5_TRAILER + ATM_CELL_PAYLOAD - 1) / ATM_CELL_PAYLOAD)
+
+/* receive */
+
+struct udsl_receive_buffer {
+	struct list_head list;
+	unsigned char *base;
+	unsigned int filled_cells;
+};
+
+struct udsl_receiver {
+	struct list_head list;
+	struct udsl_receive_buffer *buffer;
+	struct urb *urb;
+	struct udsl_instance_data *instance;
+};
+
+struct udsl_vcc_data {
+	/* vpi/vci lookup */
+	struct list_head list;
+	short vpi;
+	int vci;
+	struct atm_vcc *vcc;
+
+	/* raw cell reassembly */
+	struct sk_buff *sarb;
+};
+
+/* send */
+
+struct udsl_send_buffer {
+	struct list_head list;
+	unsigned char *base;
+	unsigned char *free_start;
+	unsigned int free_cells;
+};
+
+struct udsl_sender {
+	struct list_head list;
+	struct udsl_send_buffer *buffer;
+	struct urb *urb;
+	struct udsl_instance_data *instance;
+};
+
+struct udsl_control {
+	struct atm_skb_data atm_data;
+	unsigned int num_cells;
+	unsigned int num_entire;
+	unsigned int pdu_padding;
+	unsigned char aal5_trailer[ATM_AAL5_TRAILER];
+};
+
+#define UDSL_SKB(x)		((struct udsl_control *)(x)->cb)
+
+/* main driver data */
+
+enum udsl_status {
+	UDSL_NO_FIRMWARE,
+	UDSL_LOADING_FIRMWARE,
+	UDSL_LOADED_FIRMWARE
+};
+
+struct udsl_instance_data {
+	struct kref refcount;
+	struct semaphore serialize;
+
+	/* USB device part */
+	struct usb_device *usb_dev;
+	char description[64];
+	int data_endpoint;
+	int snd_padding;
+	int rcv_padding;
+	const char *driver_name;
+
+	/* ATM device part */
+	struct atm_dev *atm_dev;
+	struct list_head vcc_list;
+
+	/* firmware */
+	int (*firmware_wait) (struct udsl_instance_data *);
+	enum udsl_status status;
+	wait_queue_head_t firmware_waiters;
+
+	/* receive */
+	struct udsl_receiver receivers[UDSL_MAX_RCV_URBS];
+	struct udsl_receive_buffer receive_buffers[UDSL_MAX_RCV_BUFS];
+
+	spinlock_t receive_lock;
+	struct list_head spare_receivers;
+	struct list_head filled_receive_buffers;
+
+	struct tasklet_struct receive_tasklet;
+	struct list_head spare_receive_buffers;
+
+	/* send */
+	struct udsl_sender senders[UDSL_MAX_SND_URBS];
+	struct udsl_send_buffer send_buffers[UDSL_MAX_SND_BUFS];
+
+	struct sk_buff_head sndqueue;
+
+	spinlock_t send_lock;
+	struct list_head spare_senders;
+	struct list_head spare_send_buffers;
+
+	struct tasklet_struct send_tasklet;
+	struct sk_buff *current_skb;			/* being emptied */
+	struct udsl_send_buffer *current_buffer;	/* being filled */
+	struct list_head filled_send_buffers;
+};
+
+extern int udsl_instance_setup(struct usb_device *dev,
+			       struct udsl_instance_data *instance);
+extern void udsl_instance_disconnect(struct udsl_instance_data *instance);
+extern void udsl_get_instance(struct udsl_instance_data *instance);
+extern void udsl_put_instance(struct udsl_instance_data *instance);
diff -Nru a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig
--- a/drivers/usb/class/Kconfig	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/class/Kconfig	2004-12-24 13:36:17 -08:00
@@ -9,7 +9,8 @@
 	depends on USB && SOUND
 	help
 	  Say Y here if you want to connect USB audio equipment such as
-	  speakers to your computer's USB port.
+	  speakers to your computer's USB port. You only need this if you use
+	  the OSS sound driver; ALSA has its own option for usb audio support.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called audio.
diff -Nru a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
--- a/drivers/usb/class/audio.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/class/audio.c	2004-12-24 13:37:29 -08:00
@@ -509,7 +509,10 @@
 			return -EINVAL;
 	db->mapped = 1;
 	for(nr = 0; nr < size; nr++) {
-		if (remap_page_range(vma, start, virt_to_phys(db->sgbuf[nr]), PAGE_SIZE, prot))
+		unsigned long pfn;
+
+		pfn = virt_to_phys(db->sgbuf[nr]) >> PAGE_SHIFT;
+		if (remap_pfn_range(vma, start, pfn, PAGE_SIZE, prot))
 			return -EAGAIN;
 		start += PAGE_SIZE;
 	}
@@ -635,13 +638,13 @@
 		spin_unlock_irqrestore(&as->lock, flags);
 		if (notkilled && signal_pending(current)) {
 			if (i & FLG_URB0RUNNING)
-				usb_unlink_urb(u->durb[0].urb);
+				usb_kill_urb(u->durb[0].urb);
 			if (i & FLG_URB1RUNNING)
-				usb_unlink_urb(u->durb[1].urb);
+				usb_kill_urb(u->durb[1].urb);
 			if (i & FLG_SYNC0RUNNING)
-				usb_unlink_urb(u->surb[0].urb);
+				usb_kill_urb(u->surb[0].urb);
 			if (i & FLG_SYNC1RUNNING)
-				usb_unlink_urb(u->surb[1].urb);
+				usb_kill_urb(u->surb[1].urb);
 			notkilled = 0;
 		}
 	}
@@ -1114,13 +1117,13 @@
 		spin_unlock_irqrestore(&as->lock, flags);
 		if (notkilled && signal_pending(current)) {
 			if (i & FLG_URB0RUNNING)
-				usb_unlink_urb(u->durb[0].urb);
+				usb_kill_urb(u->durb[0].urb);
 			if (i & FLG_URB1RUNNING)
-				usb_unlink_urb(u->durb[1].urb);
+				usb_kill_urb(u->durb[1].urb);
 			if (i & FLG_SYNC0RUNNING)
-				usb_unlink_urb(u->surb[0].urb);
+				usb_kill_urb(u->surb[0].urb);
 			if (i & FLG_SYNC1RUNNING)
-				usb_unlink_urb(u->surb[1].urb);
+				usb_kill_urb(u->surb[1].urb);
 			notkilled = 0;
 		}
 	}
@@ -1949,15 +1952,12 @@
 static int usb_audio_open_mixdev(struct inode *inode, struct file *file)
 {
 	unsigned int minor = iminor(inode);
-	struct list_head *devs, *mdevs;
 	struct usb_mixerdev *ms;
 	struct usb_audio_state *s;
 
 	down(&open_sem);
-	list_for_each(devs, &audiodevs) {
-		s = list_entry(devs, struct usb_audio_state, audiodev);
-		list_for_each(mdevs, &s->mixerlist) {
-			ms = list_entry(mdevs, struct usb_mixerdev, list);
+	list_for_each_entry(s, &audiodevs, audiodev) {
+		list_for_each_entry(ms, &s->mixerlist, list) {
 			if (ms->dev_mixer == minor)
 				goto mixer_found;
 		}
@@ -2634,16 +2634,13 @@
 {
 	unsigned int minor = iminor(inode);
 	DECLARE_WAITQUEUE(wait, current);
-	struct list_head *devs, *adevs;
 	struct usb_audiodev *as;
 	struct usb_audio_state *s;
 
 	for (;;) {
 		down(&open_sem);
-		list_for_each(devs, &audiodevs) {
-			s = list_entry(devs, struct usb_audio_state, audiodev);
-			list_for_each(adevs, &s->audiolist) {
-				as = list_entry(adevs, struct usb_audiodev, list);
+		list_for_each_entry(s, &audiodevs, audiodev) {
+			list_for_each_entry(as, &s->audiolist, list) {
 				if (!((as->dev_audio ^ minor) & ~0xf))
 					goto device_found;
 			}
@@ -3122,12 +3119,18 @@
 {
 	struct usb_device *dev = state->s->usbdev;
 	struct mixerchannel *ch;
-	unsigned char buf[2];
+	unsigned char *buf;
 	__s16 v1;
 	unsigned int v2, v3;
 
 	if (!state->nrmixch || state->nrmixch > SOUND_MIXER_NRDEVICES)
 		return;
+	buf = kmalloc(sizeof(*buf) * 2, GFP_KERNEL);
+	if (!buf) {
+		printk(KERN_ERR "prepmixch: out of memory\n") ;
+		return;
+	}
+
 	ch = &state->mixch[state->nrmixch-1];
 	switch (ch->selector) {
 	case 0:  /* mixer unit request */
@@ -3239,13 +3242,16 @@
 	default:
 		goto err;
 	}
-	return;
 
+ freebuf:
+	kfree(buf);
+	return;
  err:
 	printk(KERN_ERR "usbaudio: mixer request device %u if %u unit %u ch %u selector %u failed\n", 
 	       dev->devnum, state->ctrlif, ch->unitid, ch->chnum, ch->selector);
 	if (state->nrmixch)
 		state->nrmixch--;
+	goto freebuf;
 }
 
 
@@ -3809,7 +3815,6 @@
 static void usb_audio_disconnect(struct usb_interface *intf)
 {
 	struct usb_audio_state *s = usb_get_intfdata (intf);
-	struct list_head *list;
 	struct usb_audiodev *as;
 	struct usb_mixerdev *ms;
 
@@ -3831,8 +3836,7 @@
 	usb_set_intfdata (intf, NULL);
 
 	/* deregister all audio and mixer devices, so no new processes can open this device */
-	list_for_each(list, &s->audiolist) {
-		as = list_entry(list, struct usb_audiodev, list);
+	list_for_each_entry(as, &s->audiolist, list) {
 		usbin_disc(as);
 		usbout_disc(as);
 		wake_up(&as->usbin.dma.wait);
@@ -3843,8 +3847,7 @@
 		}
 		as->dev_audio = -1;
 	}
-	list_for_each(list, &s->mixerlist) {
-		ms = list_entry(list, struct usb_mixerdev, list);
+	list_for_each_entry(ms, &s->mixerlist, list) {
 		if (ms->dev_mixer >= 0) {
 			unregister_sound_mixer(ms->dev_mixer);
 			printk(KERN_INFO "usbaudio: unregister mixer 14,%d\n", ms->dev_mixer);
diff -Nru a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c
--- a/drivers/usb/class/bluetty.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/usb/class/bluetty.c	2004-12-24 13:37:04 -08:00
@@ -207,7 +207,7 @@
 /* local function prototypes */
 static int  bluetooth_open		(struct tty_struct *tty, struct file *filp);
 static void bluetooth_close		(struct tty_struct *tty, struct file *filp);
-static int  bluetooth_write		(struct tty_struct *tty, int from_user, const unsigned char *buf, int count);
+static int  bluetooth_write		(struct tty_struct *tty, const unsigned char *buf, int count);
 static int  bluetooth_write_room	(struct tty_struct *tty);
 static int  bluetooth_chars_in_buffer	(struct tty_struct *tty);
 static void bluetooth_throttle		(struct tty_struct *tty);
@@ -426,14 +426,14 @@
 		bluetooth->open_count = 0;
 
 		/* shutdown any in-flight urbs that we know about */
-		usb_unlink_urb (bluetooth->read_urb);
-		usb_unlink_urb (bluetooth->interrupt_in_urb);
+		usb_kill_urb (bluetooth->read_urb);
+		usb_kill_urb (bluetooth->interrupt_in_urb);
 	}
 	up(&bluetooth->lock);
 }
 
 
-static int bluetooth_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count)
+static int bluetooth_write (struct tty_struct * tty, const unsigned char *buf, int count)
 {
 	struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
 	struct urb *urb = NULL;
@@ -471,21 +471,7 @@
 	printk ("\n");
 #endif
 
-	if (from_user) {
-		temp_buffer = kmalloc (count, GFP_KERNEL);
-		if (temp_buffer == NULL) {
-			err ("%s - out of memory.", __FUNCTION__);
-			retval = -ENOMEM;
-			goto exit;
-		}
-		if (copy_from_user (temp_buffer, (void __user *)buf, count)) {
-			retval = -EFAULT;
-			goto exit;
-		}
-		current_buffer = temp_buffer;
-	} else {
-		current_buffer = buf;
-	}
+	current_buffer = buf;
 
 	switch (*current_buffer) {
 		/* First byte indicates the type of packet */
@@ -705,7 +691,7 @@
 	}
 
 	if ((bluetooth->read_urb) && (bluetooth->read_urb->actual_length))
-		usb_unlink_urb(bluetooth->read_urb);
+		usb_kill_urb(bluetooth->read_urb);
 }
 #endif
 
@@ -1179,14 +1165,14 @@
 		bluetooth->open_count = 0;
 
 		if (bluetooth->read_urb) {
-			usb_unlink_urb (bluetooth->read_urb);
+			usb_kill_urb (bluetooth->read_urb);
 			usb_free_urb (bluetooth->read_urb);
 		}
 		if (bluetooth->bulk_in_buffer)
 			kfree (bluetooth->bulk_in_buffer);
 
 		if (bluetooth->interrupt_in_urb) {
-			usb_unlink_urb (bluetooth->interrupt_in_urb);
+			usb_kill_urb (bluetooth->interrupt_in_urb);
 			usb_free_urb (bluetooth->interrupt_in_urb);
 		}
 		if (bluetooth->interrupt_in_buffer)
@@ -1196,7 +1182,7 @@
 
 		for (i = 0; i < NUM_CONTROL_URBS; ++i) {
 			if (bluetooth->control_urb_pool[i]) {
-				usb_unlink_urb (bluetooth->control_urb_pool[i]);
+				usb_kill_urb (bluetooth->control_urb_pool[i]);
 				if (bluetooth->control_urb_pool[i]->transfer_buffer)
 					kfree (bluetooth->control_urb_pool[i]->transfer_buffer);
 				usb_free_urb (bluetooth->control_urb_pool[i]);
diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
--- a/drivers/usb/class/cdc-acm.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/usb/class/cdc-acm.c	2004-12-24 13:37:00 -08:00
@@ -301,9 +301,9 @@
 	return 0;
 
 full_bailout:
-	usb_unlink_urb(acm->readurb);
+	usb_kill_urb(acm->readurb);
 bail_out_and_unlink:
-	usb_unlink_urb(acm->ctrlurb);
+	usb_kill_urb(acm->ctrlurb);
 bail_out:
 	up(&open_sem);
 	return -EIO;
@@ -320,9 +320,9 @@
 	if (!--acm->used) {
 		if (acm->dev) {
 			acm_set_control(acm, acm->ctrlout = 0);
-			usb_unlink_urb(acm->ctrlurb);
-			usb_unlink_urb(acm->writeurb);
-			usb_unlink_urb(acm->readurb);
+			usb_kill_urb(acm->ctrlurb);
+			usb_kill_urb(acm->writeurb);
+			usb_kill_urb(acm->readurb);
 		} else {
 			tty_unregister_device(acm_tty_driver, acm->minor);
 			acm_table[acm->minor] = NULL;
@@ -335,11 +335,11 @@
 	up(&open_sem);
 }
 
-static int acm_tty_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
+static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	struct acm *acm = tty->driver_data;
 	int stat;
-	dbg("Entering acm_tty_write to write %d bytes from %s space,\n", count, from_user ? "user" : "kernel");
+	dbg("Entering acm_tty_write to write %d bytes,\n", count);
 
 	if (!ACM_READY(acm))
 		return -EINVAL;
@@ -350,19 +350,15 @@
 
 	count = (count > acm->writesize) ? acm->writesize : count;
 
-	dbg("Get %d bytes from %s space...", count, from_user ? "user" : "kernel");
-	if (from_user) {
-		if (copy_from_user(acm->write_buffer, (void __user *)buf, count))
-			return -EFAULT;
-	} else
-		memcpy(acm->write_buffer, buf, count);
+	dbg("Get %d bytes...", count);
+	memcpy(acm->write_buffer, buf, count);
 	dbg("  Successfully copied.\n");
 
 	acm->writeurb->transfer_buffer_length = count;
 	acm->writeurb->dev = acm->dev;
 
 	acm->ready_for_write = 0;
-	stat = usb_submit_urb(acm->writeurb, from_user ? GFP_KERNEL : GFP_ATOMIC);
+	stat = usb_submit_urb(acm->writeurb, GFP_ATOMIC);
 	if (stat < 0) {
 		dbg("usb_submit_urb(write bulk) failed");
 		acm->ready_for_write = 1;
@@ -542,6 +538,17 @@
 		return -EINVAL;
 	}
 
+	if (!buflen) {
+		if (intf->cur_altsetting->endpoint->extralen && intf->cur_altsetting->endpoint->extra) {
+			dev_dbg(&intf->dev,"Seeking extra descriptors on endpoint");
+			buflen = intf->cur_altsetting->endpoint->extralen;
+			buffer = intf->cur_altsetting->endpoint->extra;
+		} else {
+			err("Zero length descriptor references");
+			return -EINVAL;
+		}
+	}
+
 	while (buflen > 0) {
 		if (buffer [1] != USB_DT_CS_INTERFACE) {
 			err("skipping garbage");
@@ -558,6 +565,8 @@
 				break;
 			case CDC_COUNTRY_TYPE: /* maybe somehow export */
 				break; /* for now we ignore it */
+			case CDC_HEADER_TYPE: /* maybe check version */ 
+				break; /* for now we ignore it */ 
 			case CDC_AC_MANAGEMENT_TYPE:
 				ac_management_function = buffer[3];
 				break;
@@ -569,7 +578,7 @@
 				break;
 				
 			default:
-				err("Ignoring extra header");
+				err("Ignoring extra header, type %d, length %d", buffer[2], buffer[0]);
 				break;
 			}
 next_desc:
@@ -637,7 +646,7 @@
 	dbg("interfaces are valid");
 	for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++);
 
-	if (acm_table[minor]) {
+	if (minor == ACM_TTY_MINORS) {
 		err("no more free acm devices");
 		return -ENODEV;
 	}
@@ -762,9 +771,9 @@
 	acm->dev = NULL;
 	usb_set_intfdata (intf, NULL);
 
-	usb_unlink_urb(acm->ctrlurb);
-	usb_unlink_urb(acm->readurb);
-	usb_unlink_urb(acm->writeurb);
+	usb_kill_urb(acm->ctrlurb);
+	usb_kill_urb(acm->readurb);
+	usb_kill_urb(acm->writeurb);
 
 	flush_scheduled_work(); /* wait for acm_softint */
 
diff -Nru a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
--- a/drivers/usb/class/cdc-acm.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/usb/class/cdc-acm.h	2004-12-24 13:37:31 -08:00
@@ -117,6 +117,7 @@
 } __attribute__ ((packed));
 
 /* class specific descriptor types */
+#define CDC_HEADER_TYPE			0x00
 #define CDC_CALL_MANAGEMENT_TYPE	0x01
 #define CDC_AC_MANAGEMENT_TYPE		0x02
 #define CDC_UNION_TYPE			0x06
diff -Nru a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c
--- a/drivers/usb/class/usb-midi.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/class/usb-midi.c	2004-12-24 13:36:17 -08:00
@@ -805,7 +805,6 @@
 {
 	int minor = iminor(inode);
 	DECLARE_WAITQUEUE(wait, current);
-	struct list_head      *devs, *mdevs;
 	struct usb_midi_state *s;
 	struct usb_mididev    *m;
 	unsigned long flags;
@@ -817,10 +816,8 @@
 
 	for(;;) {
 		down(&open_sem);
-		list_for_each(devs, &mididevs) {
-			s = list_entry(devs, struct usb_midi_state, mididev);
-			list_for_each(mdevs, &s->midiDevList) {
-				m = list_entry(mdevs, struct usb_mididev, list);
+		list_for_each_entry(s, &mididevs, mididev) {
+			list_for_each_entry(m, &s->midiDevList, list) {
 				if ( !((m->dev_midi ^ minor) & ~0xf) )
 					goto device_found;
 			}
@@ -939,7 +936,7 @@
 
 	if ( m->open_mode & FMODE_WRITE ) {
 		m->open_mode &= ~FMODE_WRITE;
-		usb_unlink_urb( m->mout.ep->urb );
+		usb_kill_urb( m->mout.ep->urb );
 	}
 
 	if ( m->open_mode & FMODE_READ ) {
@@ -951,7 +948,7 @@
 		if ( m->min.ep->readers == 0 &&
                      m->min.ep->urbSubmitted ) {
 			m->min.ep->urbSubmitted = 0;
-			usb_unlink_urb(m->min.ep->urb);
+			usb_kill_urb(m->min.ep->urb);
 		}
 	        spin_unlock_irqrestore( &m->min.ep->lock, flagsep );
 	}
@@ -1042,7 +1039,7 @@
 
 static int remove_midi_in_endpoint( struct midi_in_endpoint *min )
 {
-	usb_unlink_urb( min->urb );
+	usb_kill_urb( min->urb );
 	usb_free_urb( min->urb );
 	kfree( min->recvBuf );
 	kfree( min );
@@ -1102,7 +1099,7 @@
 
 static int remove_midi_out_endpoint( struct midi_out_endpoint *mout )
 {
-	usb_unlink_urb( mout->urb );
+	usb_kill_urb( mout->urb );
 	usb_free_urb( mout->urb );
 	kfree( mout->buf );
 	kfree( mout );
@@ -1994,7 +1991,6 @@
 static void usb_midi_disconnect(struct usb_interface *intf)
 {
 	struct usb_midi_state *s = usb_get_intfdata (intf);
-	struct list_head      *list;
 	struct usb_mididev    *m;
 
 	if ( !s )
@@ -2012,8 +2008,7 @@
 	s->usbdev = NULL;
 	usb_set_intfdata (intf, NULL);
 
-	list_for_each(list, &s->midiDevList) {
-		m = list_entry(list, struct usb_mididev, list);
+	list_for_each_entry(m, &s->midiDevList, list) {
 		wake_up(&(m->min.ep->wait));
 		wake_up(&(m->mout.ep->wait));
 		if ( m->dev_midi >= 0 ) {
diff -Nru a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
--- a/drivers/usb/class/usblp.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/usb/class/usblp.c	2004-12-24 13:36:19 -08:00
@@ -222,6 +222,7 @@
 
 /* forward reference to make our lives easier */
 static struct usb_driver usblp_driver;
+static DECLARE_MUTEX(usblp_sem);	/* locks the existence of usblp's */
 
 /*
  * Functions for usblp control messages.
@@ -343,7 +344,7 @@
 	if (minor < 0)
 		return -ENODEV;
 
-	lock_kernel();
+	down (&usblp_sem);
 
 	retval = -ENODEV;
 	intf = usb_find_interface(&usblp_driver, minor);
@@ -389,7 +390,7 @@
 		}
 	}
 out:
-	unlock_kernel();
+	up (&usblp_sem);
 	return retval;
 }
 
@@ -406,22 +407,22 @@
 
 static void usblp_unlink_urbs(struct usblp *usblp)
 {
-	usb_unlink_urb(usblp->writeurb);
+	usb_kill_urb(usblp->writeurb);
 	if (usblp->bidir)
-		usb_unlink_urb(usblp->readurb);
+		usb_kill_urb(usblp->readurb);
 }
 
 static int usblp_release(struct inode *inode, struct file *file)
 {
 	struct usblp *usblp = file->private_data;
 
-	down (&usblp->sem);
+	down (&usblp_sem);
 	usblp->used = 0;
 	if (usblp->present) {
 		usblp_unlink_urbs(usblp);
-		up(&usblp->sem);
 	} else 		/* finish cleanup from disconnect */
 		usblp_cleanup (usblp);
+	up (&usblp_sem);
 	return 0;
 }
 
@@ -1149,8 +1150,8 @@
 		BUG ();
 	}
 
+	down (&usblp_sem);
 	down (&usblp->sem);
-	lock_kernel();
 	usblp->present = 0;
 	usb_set_intfdata (intf, NULL);
 
@@ -1159,12 +1160,11 @@
 			usblp->writebuf, usblp->writeurb->transfer_dma);
 	usb_buffer_free (usblp->dev, USBLP_BUF_SIZE,
 			usblp->readbuf, usblp->readurb->transfer_dma);
+	up (&usblp->sem);
 
 	if (!usblp->used)
 		usblp_cleanup (usblp);
-	else 	/* cleanup later, on release */
-		up (&usblp->sem);
-	unlock_kernel();
+	up (&usblp_sem);
 }
 
 static struct usb_device_id usblp_ids [] = {
diff -Nru a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
--- a/drivers/usb/core/devices.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/core/devices.c	2004-12-24 13:37:29 -08:00
@@ -149,7 +149,7 @@
 
 /*****************************************************************/
 
-void usbdevfs_conn_disc_event(void)
+void usbfs_conn_disc_event(void)
 {
 	conndiscevcnt++;
 	wake_up(&deviceconndiscwq);
@@ -451,7 +451,7 @@
  * nbytes - the maximum number of bytes to write
  * skip_bytes - the number of bytes to skip before writing anything
  * file_offset - the offset into the devices file on completion
- * The caller must own the usbdev->serialize semaphore.
+ * The caller must own the device lock.
  */
 static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *skip_bytes, loff_t *file_offset,
 				struct usb_device *usbdev, struct usb_bus *bus, int level, int index, int count)
@@ -569,7 +569,6 @@
 
 static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 {
-	struct list_head *buslist;
 	struct usb_bus *bus;
 	ssize_t ret, total_written = 0;
 	loff_t skip_bytes = *ppos;
@@ -581,18 +580,15 @@
 	if (!access_ok(VERIFY_WRITE, buf, nbytes))
 		return -EFAULT;
 
-	/* enumerate busses */
 	down (&usb_bus_list_lock);
-	list_for_each(buslist, &usb_bus_list) {
-		/* print devices for this bus */
-		bus = list_entry(buslist, struct usb_bus, bus_list);
-
+	/* print devices for all busses */
+	list_for_each_entry(bus, &usb_bus_list, bus_list) {
 		/* recurse through all children of the root hub */
 		if (!bus->root_hub)
 			continue;
-		down(&bus->root_hub->serialize);
+		usb_lock_device(bus->root_hub);
 		ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0);
-		up(&bus->root_hub->serialize);
+		usb_unlock_device(bus->root_hub);
 		if (ret < 0) {
 			up(&usb_bus_list_lock);
 			return ret;
@@ -682,7 +678,7 @@
 	return ret;
 }
 
-struct file_operations usbdevfs_devices_fops = {
+struct file_operations usbfs_devices_fops = {
 	.llseek =	usb_device_lseek,
 	.read =		usb_device_read,
 	.poll =		usb_device_poll,
diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
--- a/drivers/usb/core/devio.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/usb/core/devio.c	2004-12-24 13:36:49 -08:00
@@ -21,7 +21,7 @@
  *
  *  $Id: devio.c,v 1.7 2000/02/01 17:28:48 fliegl Exp $
  *
- *  This file implements the usbdevfs/x/y files, where
+ *  This file implements the usbfs/x/y files, where
  *  x is the bus number and y the device number.
  *
  *  It allows user space programs/"drivers" to communicate directly
@@ -113,7 +113,7 @@
 	int i;
 
 	pos = *ppos;
-	down(&dev->serialize);
+	usb_lock_device(dev);
 	if (!connected(dev)) {
 		ret = -ENODEV;
 		goto err;
@@ -175,7 +175,7 @@
 	}
 
 err:
-	up(&dev->serialize);
+	usb_unlock_device(dev);
 	return ret;
 }
 
@@ -286,9 +286,10 @@
 	while (!list_empty(list)) {
 		as = list_entry(list->next, struct async, asynclist);
 		list_del_init(&as->asynclist);
+
+		/* drop the spinlock so the completion handler can run */
 		spin_unlock_irqrestore(&ps->lock, flags);
-                /* usb_unlink_urb calls the completion handler with status == -ENOENT */
-		usb_unlink_urb(as->urb);
+		usb_kill_urb(as->urb);
 		spin_lock_irqsave(&ps->lock, flags);
 	}
 	spin_unlock_irqrestore(&ps->lock, flags);
@@ -353,7 +354,7 @@
 	destroy_async_on_interface(ps, ifnum);
 }
 
-struct usb_driver usbdevfs_driver = {
+struct usb_driver usbfs_driver = {
 	.owner =	THIS_MODULE,
 	.name =		"usbfs",
 	.probe =	driver_probe,
@@ -378,7 +379,7 @@
 	if (!intf)
 		err = -ENOENT;
 	else
-		err = usb_driver_claim_interface(&usbdevfs_driver, intf, ps);
+		err = usb_driver_claim_interface(&usbfs_driver, intf, ps);
 	up_write(&usb_bus_type.subsys.rwsem);
 	if (err == 0)
 		set_bit(ifnum, &ps->ifclaimed);
@@ -401,7 +402,7 @@
 	if (!intf)
 		err = -ENOENT;
 	else if (test_and_clear_bit(ifnum, &ps->ifclaimed)) {
-		usb_driver_release_interface(&usbdevfs_driver, intf);
+		usb_driver_release_interface(&usbfs_driver, intf);
 		err = 0;
 	}
 	up_write(&usb_bus_type.subsys.rwsem);
@@ -410,6 +411,8 @@
 
 static int checkintf(struct dev_state *ps, unsigned int ifnum)
 {
+	if (ps->dev->state != USB_STATE_CONFIGURED)
+		return -EHOSTUNREACH;
 	if (ifnum >= 8*sizeof(ps->ifclaimed))
 		return -EINVAL;
 	if (test_bit(ifnum, &ps->ifclaimed))
@@ -449,6 +452,8 @@
 {
 	int ret = 0;
 
+	if (ps->dev->state != USB_STATE_CONFIGURED)
+		return -EHOSTUNREACH;
 	if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype))
 		return 0;
 
@@ -516,16 +521,15 @@
 	struct usb_device *dev = ps->dev;
 	unsigned int ifnum;
 
-	down(&dev->serialize);
+	usb_lock_device(dev);
 	list_del_init(&ps->list);
-
-	if (connected(dev)) {
-		for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); ifnum++)
-			if (test_bit(ifnum, &ps->ifclaimed))
-				releaseintf(ps, ifnum);
-		destroy_all_async(ps);
+	for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed);
+			ifnum++) {
+		if (test_bit(ifnum, &ps->ifclaimed))
+			releaseintf(ps, ifnum);
 	}
-	up(&dev->serialize);
+	destroy_all_async(ps);
+	usb_unlock_device(dev);
 	usb_put_dev(dev);
 	ps->dev = NULL;
 	kfree(ps);
@@ -557,10 +561,10 @@
 		snoop(&dev->dev, "control read: bRequest=%02x bRrequestType=%02x wValue=%04x wIndex=%04x\n", 
 			ctrl.bRequest, ctrl.bRequestType, ctrl.wValue, ctrl.wIndex);
 
-		up(&dev->serialize);
+		usb_unlock_device(dev);
 		i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType,
 				       ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo);
-		down(&dev->serialize);
+		usb_lock_device(dev);
 		if ((i > 0) && ctrl.wLength) {
 			if (usbfs_snoop) {
 				dev_info(&dev->dev, "control read: data ");
@@ -588,13 +592,13 @@
 				printk ("%02x ", (unsigned char)(tbuf)[j]);
 			printk("\n");
 		}
-		up(&dev->serialize);
+		usb_unlock_device(dev);
 		i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType,
 				       ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo);
-		down(&dev->serialize);
+		usb_lock_device(dev);
 	}
 	free_page((unsigned long)tbuf);
-	if (i<0) {
+	if (i<0 && i != -EPIPE) {
 		dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL "
 			   "failed cmd %s rqt %u rq %u len %u ret %d\n",
 			   current->comm, ctrl.bRequestType, ctrl.bRequest,
@@ -635,9 +639,9 @@
 			kfree(tbuf);
 			return -EINVAL;
 		}
-		up(&dev->serialize);
+		usb_unlock_device(dev);
 		i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
-		down(&dev->serialize);
+		usb_lock_device(dev);
 		if (!i && len2) {
 			if (copy_to_user(bulk.data, tbuf, len2)) {
 				kfree(tbuf);
@@ -651,9 +655,9 @@
 				return -EFAULT;
 			}
 		}
-		up(&dev->serialize);
+		usb_unlock_device(dev);
 		i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
-		down(&dev->serialize);
+		usb_lock_device(dev);
 	}
 	kfree(tbuf);
 	if (i < 0) {
@@ -734,7 +738,7 @@
 
 static int proc_resetdevice(struct dev_state *ps)
 {
-	return __usb_reset_device(ps->dev);
+	return usb_reset_device(ps->dev);
 
 }
 
@@ -976,7 +980,7 @@
 	as = async_getpending(ps, arg);
 	if (!as)
 		return -EINVAL;
-	usb_unlink_urb(as->urb);
+	usb_kill_urb(as->urb);
 	return 0;
 }
 
@@ -1018,15 +1022,15 @@
 	int ret;
 
 	add_wait_queue(&ps->wait, &wait);
-	while (connected(dev)) {
+	for (;;) {
 		__set_current_state(TASK_INTERRUPTIBLE);
 		if ((as = async_getcompleted(ps)))
 			break;
 		if (signal_pending(current))
 			break;
-		up(&dev->serialize);
+		usb_unlock_device(dev);
 		schedule();
-		down(&dev->serialize);
+		usb_lock_device(dev);
 	}
 	remove_wait_queue(&ps->wait, &wait);
 	set_current_state(TASK_RUNNING);
@@ -1130,7 +1134,7 @@
 	}
 
 	if (ps->dev->state != USB_STATE_CONFIGURED)
-		retval = -ENODEV;
+		retval = -EHOSTUNREACH;
 	else if (!(intf = usb_ifnum_to_if (ps->dev, ctrl.ifno)))
                retval = -EINVAL;
 	else switch (ctrl.ioctl_code) {
@@ -1149,7 +1153,11 @@
 
 	/* let kernel drivers try to (re)bind to the interface */
 	case USBDEVFS_CONNECT:
+		usb_unlock_device(ps->dev);
+		usb_lock_all_devices();
 		bus_rescan_devices(intf->dev.bus);
+		usb_unlock_all_devices();
+		usb_lock_device(ps->dev);
 		break;
 
 	/* talk directly to the interface's driver */
@@ -1192,9 +1200,9 @@
 
 	if (!(file->f_mode & FMODE_WRITE))
 		return -EPERM;
-	down(&dev->serialize);
+	usb_lock_device(dev);
 	if (!connected(dev)) {
-		up(&dev->serialize);
+		usb_unlock_device(dev);
 		return -ENODEV;
 	}
 
@@ -1294,7 +1302,7 @@
 		ret = proc_ioctl(ps, p);
 		break;
 	}
-	up(&dev->serialize);
+	usb_unlock_device(dev);
 	if (ret >= 0)
 		inode->i_atime = CURRENT_TIME;
 	return ret;
@@ -1314,7 +1322,7 @@
 	return mask;
 }
 
-struct file_operations usbdevfs_device_file_operations = {
+struct file_operations usbfs_device_file_operations = {
 	.llseek =	usbdev_lseek,
 	.read =		usbdev_read,
 	.poll =		usbdev_poll,
diff -Nru a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
--- a/drivers/usb/core/hcd-pci.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/usb/core/hcd-pci.c	2004-12-24 13:36:49 -08:00
@@ -38,14 +38,6 @@
 
 /*-------------------------------------------------------------------------*/
 
-static void hcd_pci_release(struct usb_bus *bus)
-{
-	struct usb_hcd *hcd = bus->hcpriv;
-
-	if (hcd)
-		hcd->driver->hcd_free(hcd);
-}
-
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */
 
@@ -78,12 +70,15 @@
 
 	if (pci_enable_device (dev) < 0)
 		return -ENODEV;
+	dev->current_state = 0;
+	dev->dev.power.power_state = 0;
 	
         if (!dev->irq) {
         	dev_err (&dev->dev,
 			"Found HC with no IRQ.  Check BIOS/PCI %s setup!\n",
 			pci_name(dev));
-   	        return -ENODEV;
+   	        retval = -ENODEV;
+		goto done;
         }
 	
 	if (driver->flags & HCD_MEMORY) {	// EHCI, OHCI
@@ -92,7 +87,8 @@
 		len = pci_resource_len (dev, 0);
 		if (!request_mem_region (resource, len, driver->description)) {
 			dev_dbg (&dev->dev, "controller already in use\n");
-			return -EBUSY;
+			retval = -EBUSY;
+			goto done;
 		}
 		base = ioremap_nocache (resource, len);
 		if (base == NULL) {
@@ -102,7 +98,7 @@
 			release_mem_region (resource, len);
 			dev_err (&dev->dev, "init %s fail, %d\n",
 				pci_name(dev), retval);
-			return retval;
+			goto done;
 		}
 
 	} else { 				// UHCI
@@ -119,7 +115,8 @@
 		}
 		if (region == PCI_ROM_RESOURCE) {
 			dev_dbg (&dev->dev, "no i/o regions available\n");
-			return -EBUSY;
+			retval = -EBUSY;
+			goto done;
 		}
 		base = (void __iomem *) resource;
 	}
@@ -139,7 +136,7 @@
 			release_region (resource, len);
 			dev_err (&dev->dev, "init %s fail, %d\n",
 				pci_name(dev), retval);
-			return retval;
+			goto done;
 		}
 	}
 	// hcd zeroed everything
@@ -160,7 +157,7 @@
 
 	if ((retval = hcd_buffer_create (hcd)) != 0) {
 clean_3:
-		driver->hcd_free (hcd);
+		kfree (hcd);
 		goto clean_2;
 	}
 
@@ -188,14 +185,14 @@
 	}
 	hcd->irq = dev->irq;
 
-	dev_info (hcd->self.controller, "irq %s, %s %p\n", bufp,
+	dev_info (hcd->self.controller, "irq %s, %s 0x%lx\n", bufp,
 		(driver->flags & HCD_MEMORY) ? "pci mem" : "io base",
-		base);
+		resource);
 
 	usb_bus_init (&hcd->self);
 	hcd->self.op = &usb_hcd_operations;
+	hcd->self.release = &usb_hcd_release;
 	hcd->self.hcpriv = (void *) hcd;
-	hcd->self.release = &hcd_pci_release;
 	init_timer (&hcd->rh_timer);
 
 	INIT_LIST_HEAD (&hcd->dev_list);
@@ -207,6 +204,9 @@
 		usb_hcd_pci_remove (dev);
 	}
 
+done:
+	if (retval != 0)
+		pci_disable_device (dev);
 	return retval;
 } 
 EXPORT_SYMBOL (usb_hcd_pci_probe);
@@ -260,12 +260,26 @@
 	}
 
 	usb_deregister_bus (&hcd->self);
+
+	pci_disable_device(dev);
 }
 EXPORT_SYMBOL (usb_hcd_pci_remove);
 
 
 #ifdef	CONFIG_PM
 
+static char __attribute_used__ *pci_state(u32 state)
+{
+	switch (state) {
+	case 0:		return "D0";
+	case 1:		return "D1";
+	case 2:		return "D2";
+	case 3:		return "D3hot";
+	case 4:		return "D3cold";
+	}
+	return NULL;
+}
+
 /**
  * usb_hcd_pci_suspend - power management suspend of a PCI-based HCD
  * @dev: USB Host Controller being suspended
@@ -286,45 +300,82 @@
 	 * PM-sensitive HCDs may already have done this.
 	 */
 	has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM);
-	if (has_pci_pm)
-		dev_dbg(hcd->self.controller, "suspend D%d --> D%d\n",
-			dev->current_state, state);
+	if (state > 4)
+		state = 4;
 
 	switch (hcd->state) {
-	case USB_STATE_HALT:
-		dev_dbg (hcd->self.controller, "halted; hcd not suspended\n");
-		break;
-	case HCD_STATE_SUSPENDED:
-		dev_dbg (hcd->self.controller, "hcd already suspended\n");
-		break;
-	default:
+
+	/* entry if root hub wasn't yet suspended ... from sysfs,
+	 * without autosuspend, or if USB_SUSPEND isn't configured.
+	 */
+	case USB_STATE_RUNNING:
+		hcd->state = USB_STATE_QUIESCING;
 		retval = hcd->driver->suspend (hcd, state);
-		if (retval)
+		if (retval) {
 			dev_dbg (hcd->self.controller, 
 					"suspend fail, retval %d\n",
 					retval);
-		else {
-			hcd->state = HCD_STATE_SUSPENDED;
-			pci_save_state (dev, hcd->pci_state);
+			break;
+		}
+		hcd->state = HCD_STATE_SUSPENDED;
+		/* FALLTHROUGH */
+
+	/* entry with CONFIG_USB_SUSPEND, or hcds that autosuspend: the
+	 * controller and/or root hub will already have been suspended,
+	 * but it won't be ready for a PCI resume call.
+	 *
+	 * FIXME only CONFIG_USB_SUSPEND guarantees hub_suspend() will
+	 * have been called, otherwise root hub timers still run ...
+	 */
+	case HCD_STATE_SUSPENDED:
+		if (state <= dev->current_state)
+			break;
+
+		/* no DMA or IRQs except in D0 */
+		if (!dev->current_state) {
+			pci_save_state (dev);
+			pci_disable_device (dev);
+			free_irq (hcd->irq, hcd);
+		}
+
+		if (!has_pci_pm) {
+			dev_dbg (hcd->self.controller, "--> PCI D0/legacy\n");
+			break;
+		}
+
+		/* POLICY: ignore D1/D2/D3hot differences;
+		 * we know D3hot will always work.
+		 */
+		retval = pci_set_power_state (dev, state);
+		if (retval < 0 && state < 3) {
+			retval = pci_set_power_state (dev, 3);
+			if (retval == 0)
+				state = 3;
+		}
+		if (retval == 0) {
+			dev_dbg (hcd->self.controller, "--> PCI %s\n",
+					pci_state(dev->current_state));
 #ifdef	CONFIG_USB_SUSPEND
 			pci_enable_wake (dev, state, hcd->remote_wakeup);
 			pci_enable_wake (dev, 4, hcd->remote_wakeup);
 #endif
-			/* no DMA or IRQs except in D0 */
-			pci_disable_device (dev);
-			free_irq (hcd->irq, hcd);
-			
-			if (has_pci_pm)
-				retval = pci_set_power_state (dev, state);
-			dev->dev.power.power_state = state;
-			if (retval < 0) {
-				dev_dbg (&dev->dev,
-						"PCI suspend fail, %d\n",
-						retval);
-				(void) usb_hcd_pci_resume (dev);
-			}
+		} else if (retval < 0) {
+			dev_dbg (&dev->dev, "PCI %s suspend fail, %d\n",
+					pci_state(state), retval);
+			(void) usb_hcd_pci_resume (dev);
+			break;
 		}
+		break;
+	default:
+		dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n",
+			hcd->state);
+		retval = -EINVAL;
+		break;
 	}
+
+	/* update power_state **ONLY** to make sysfs happier */
+	if (retval == 0)
+		dev->dev.power.power_state = state;
 	return retval;
 }
 EXPORT_SYMBOL (usb_hcd_pci_suspend);
@@ -342,16 +393,18 @@
 	int			has_pci_pm;
 
 	hcd = pci_get_drvdata(dev);
-	has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM);
-	if (has_pci_pm)
-		dev_dbg(hcd->self.controller, "resume from state D%d\n",
-				dev->current_state);
-
 	if (hcd->state != HCD_STATE_SUSPENDED) {
 		dev_dbg (hcd->self.controller, 
 				"can't resume, not suspended!\n");
-		return -EL3HLT;
+		return 0;
 	}
+	has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM);
+
+	/* D3cold resume isn't usually reported this way... */
+	dev_dbg(hcd->self.controller, "resume from PCI %s%s\n",
+			pci_state(dev->current_state),
+			has_pci_pm ? "" : " (legacy)");
+
 	hcd->state = USB_STATE_RESUMING;
 
 	if (has_pci_pm)
@@ -364,8 +417,8 @@
 			"can't restore IRQ after resume!\n");
 		return retval;
 	}
-	pci_set_master (dev);
-	pci_restore_state (dev, hcd->pci_state);
+	hcd->saw_irq = 0;
+	pci_restore_state (dev);
 #ifdef	CONFIG_USB_SUSPEND
 	pci_enable_wake (dev, dev->current_state, 0);
 	pci_enable_wake (dev, 4, 0);
diff -Nru a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
--- a/drivers/usb/core/hcd.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/usb/core/hcd.c	2004-12-24 13:36:59 -08:00
@@ -435,8 +435,6 @@
 		/* non-generic request */
 		if (HCD_IS_SUSPENDED (hcd->state))
 			urb->status = -EAGAIN;
-		else if (!HCD_IS_RUNNING (hcd->state))
-			urb->status = -ENODEV;
 		else
 			urb->status = hcd->driver->hub_control (hcd,
 				typeReq, wValue, wIndex,
@@ -445,13 +443,16 @@
 error:
 		/* "protocol stall" on error */
 		urb->status = -EPIPE;
-		dev_dbg (hcd->self.controller, "unsupported hub control message (maxchild %d)\n",
-				urb->dev->maxchild);
 	}
 	if (urb->status) {
 		urb->actual_length = 0;
-		dev_dbg (hcd->self.controller, "CTRL: TypeReq=0x%x val=0x%x idx=0x%x len=%d ==> %d\n",
-			typeReq, wValue, wIndex, wLength, urb->status);
+		if (urb->status != -EPIPE) {
+			dev_dbg (hcd->self.controller,
+				"CTRL: TypeReq=0x%x val=0x%x "
+				"idx=0x%x len=%d ==> %d\n",
+				typeReq, wValue, wIndex,
+				wLength, urb->status);
+		}
 	}
 	if (bufp) {
 		if (urb->transfer_buffer_length < len)
@@ -478,6 +479,11 @@
 /*
  * Root Hub interrupt transfers are synthesized with a timer.
  * Completions are called in_interrupt() but not in_irq().
+ *
+ * Note: some root hubs (including common UHCI based designs) can't
+ * correctly issue port change IRQs.  They're the ones that _need_ a
+ * timer; most other root hubs don't.  Some systems could save a
+ * lot of battery power by eliminating these root hub timer IRQs.
  */
 
 static void rh_report_status (unsigned long ptr);
@@ -487,10 +493,7 @@
 	int	len = 1 + (urb->dev->maxchild / 8);
 
 	/* rh_timer protected by hcd_data_lock */
-	if (hcd->rh_timer.data
-			|| urb->status != -EINPROGRESS
-			|| urb->transfer_buffer_length < len
-			|| !HCD_IS_RUNNING (hcd->state)) {
+	if (hcd->rh_timer.data || urb->transfer_buffer_length < len) {
 		dev_dbg (hcd->self.controller,
 				"not queuing rh status urb, stat %d\n",
 				urb->status);
@@ -529,19 +532,19 @@
 		return;
 	}
 
-	if (!HCD_IS_SUSPENDED (hcd->state))
-		length = hcd->driver->hub_status_data (
-					hcd, urb->transfer_buffer);
-
 	/* complete the status urb, or retrigger the timer */
 	spin_lock (&hcd_data_lock);
-	if (length > 0) {
-		hcd->rh_timer.data = 0;
-		urb->actual_length = length;
-		urb->status = 0;
-		urb->hcpriv = NULL;
-	} else
-		mod_timer (&hcd->rh_timer, jiffies + HZ/4);
+	if (urb->dev->state == USB_STATE_CONFIGURED) {
+		length = hcd->driver->hub_status_data (
+					hcd, urb->transfer_buffer);
+		if (length > 0) {
+			hcd->rh_timer.data = 0;
+			urb->actual_length = length;
+			urb->status = 0;
+			urb->hcpriv = NULL;
+		} else
+			mod_timer (&hcd->rh_timer, jiffies + HZ/4);
+	}
 	spin_unlock (&hcd_data_lock);
 	spin_unlock (&urb->lock);
 
@@ -572,18 +575,34 @@
 
 /*-------------------------------------------------------------------------*/
 
-int usb_rh_status_dequeue (struct usb_hcd *hcd, struct urb *urb)
+static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
 {
 	unsigned long	flags;
 
 	/* note:  always a synchronous unlink */
-	del_timer_sync (&hcd->rh_timer);
-	hcd->rh_timer.data = 0;
+	if ((unsigned long) urb == hcd->rh_timer.data) {
+		del_timer_sync (&hcd->rh_timer);
+		hcd->rh_timer.data = 0;
+
+		local_irq_save (flags);
+		urb->hcpriv = NULL;
+		usb_hcd_giveback_urb (hcd, urb, NULL);
+		local_irq_restore (flags);
+
+	} else if (usb_pipeendpoint(urb->pipe) == 0) {
+		spin_lock_irq(&urb->lock);	/* from usb_kill_urb */
+		++urb->reject;
+		spin_unlock_irq(&urb->lock);
+
+		wait_event(usb_kill_urb_queue,
+				atomic_read(&urb->use_count) == 0);
+
+		spin_lock_irq(&urb->lock);
+		--urb->reject;
+		spin_unlock_irq(&urb->lock);
+	} else
+		return -EINVAL;
 
-	local_irq_save (flags);
-	urb->hcpriv = NULL;
-	usb_hcd_giveback_urb (hcd, urb, NULL);
-	local_irq_restore (flags);
 	return 0;
 }
 
@@ -798,9 +817,9 @@
 		return (retval < 0) ? retval : -EMSGSIZE;
 	}
 
-	down (&usb_dev->serialize);
+	usb_lock_device (usb_dev);
 	retval = usb_new_device (usb_dev);
-	up (&usb_dev->serialize);
+	usb_unlock_device (usb_dev);
 	if (retval) {
 		usb_dev->bus->root_hub = NULL;
 		dev_err (parent_dev, "can't register root hub for %s, %d\n",
@@ -1086,13 +1105,17 @@
 	spin_lock_irqsave (&hcd_data_lock, flags);
 	if (unlikely (urb->reject))
 		status = -EPERM;
-	else if (HCD_IS_RUNNING (hcd->state) &&
-			hcd->state != USB_STATE_QUIESCING) {
+	else switch (hcd->state) {
+	case USB_STATE_RUNNING:
+	case USB_STATE_RESUMING:
 		usb_get_dev (urb->dev);
 		list_add_tail (&urb->urb_list, &dev->urb_list);
 		status = 0;
-	} else
+		break;
+	default:
 		status = -ESHUTDOWN;
+		break;
+	}
 	spin_unlock_irqrestore (&hcd_data_lock, flags);
 	if (status) {
 		INIT_LIST_HEAD (&urb->urb_list);
@@ -1175,8 +1198,8 @@
 {
 	int		value;
 
-	if (urb == (struct urb *) hcd->rh_timer.data)
-		value = usb_rh_status_dequeue (hcd, urb);
+	if (urb->dev == hcd->self.root_hub)
+		value = usb_rh_urb_dequeue (hcd, urb);
 	else {
 
 		/* The only reason an HCD might fail this call is if
@@ -1264,7 +1287,7 @@
 	 * never get completion IRQs ... maybe even the ones we need to
 	 * finish unlinking the initial failed usb_set_address().
 	 */
-	if (!hcd->saw_irq) {
+	if (!hcd->saw_irq && hcd->self.root_hub != urb->dev) {
 		dev_warn (hcd->self.controller, "Unlink after no-IRQ?  "
 			"Different ACPI or APIC settings may help."
 			"\n");
@@ -1573,13 +1596,12 @@
 	struct usb_hcd		*hcd = __hcd;
 	int			start = hcd->state;
 
-	if (unlikely (hcd->state == USB_STATE_HALT))	/* irq sharing? */
+	if (start == USB_STATE_HALT)
 		return IRQ_NONE;
-
-	hcd->saw_irq = 1;
 	if (hcd->driver->irq (hcd, r) == IRQ_NONE)
 		return IRQ_NONE;
 
+	hcd->saw_irq = 1;
 	if (hcd->state != start && hcd->state == USB_STATE_HALT)
 		usb_hc_died (hcd);
 	return IRQ_HANDLED;
@@ -1588,22 +1610,6 @@
 
 /*-------------------------------------------------------------------------*/
 
-static void hcd_panic (void *_hcd)
-{
-	struct usb_hcd		*hcd = _hcd;
-	struct usb_device	*hub = hcd->self.root_hub;
-	unsigned		i;
-
-	/* hc's root hub is removed later removed in hcd->stop() */
-	down (&hub->serialize);
-	usb_set_device_state(hub, USB_STATE_NOTATTACHED);
-	for (i = 0; i < hub->maxchild; i++) {
-		if (hub->children [i])
-			usb_disconnect (&hub->children [i]);
-	}
-	up (&hub->serialize);
-}
-
 /**
  * usb_hc_died - report abnormal shutdown of a host controller (bus glue)
  * @hcd: pointer to the HCD representing the controller
@@ -1616,9 +1622,19 @@
 {
 	dev_err (hcd->self.controller, "HC died; cleaning up\n");
 
-	/* clean up old urbs and devices; needs a task context */
-	INIT_WORK (&hcd->work, hcd_panic, hcd);
-	(void) schedule_work (&hcd->work);
+	/* make khubd clean up old urbs and devices */
+	usb_set_device_state(hcd->self.root_hub, USB_STATE_NOTATTACHED);
+	mod_timer(&hcd->rh_timer, jiffies);
 }
 EXPORT_SYMBOL (usb_hc_died);
 
+/*-------------------------------------------------------------------------*/
+
+void usb_hcd_release(struct usb_bus *bus)
+{
+	struct usb_hcd *hcd;
+
+	hcd = container_of (bus, struct usb_hcd, self);
+	kfree(hcd);
+}
+EXPORT_SYMBOL (usb_hcd_release);
diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
--- a/drivers/usb/core/hcd.h	2004-12-24 13:36:34 -08:00
+++ b/drivers/usb/core/hcd.h	2004-12-24 13:36:34 -08:00
@@ -67,7 +67,6 @@
 
 	struct timer_list	rh_timer;	/* drives root hub */
 	struct list_head	dev_list;	/* devices on this bus */
-	struct work_struct	work;
 
 	/*
 	 * hardware info/state
@@ -81,7 +80,6 @@
 
 #ifdef	CONFIG_PCI
 	int			region;		/* pci region for regs */
-	u32			pci_state [16];	/* for PM state save */
 #endif
 
 #define HCD_BUFFER_POOLS	4
@@ -193,8 +191,13 @@
 	int	(*get_frame_number) (struct usb_hcd *hcd);
 
 	/* memory lifecycle */
+	/* Note: The absence of hcd_free reflects a temporary situation;
+	 * in the near future hcd_alloc will disappear as well and all
+	 * allocations/deallocations will be handled by usbcore.  For the
+	 * moment, drivers are required to return a pointer that the core
+	 * can pass to kfree, i.e., the struct usb_hcd must be the _first_
+	 * member of a larger driver-specific structure. */
 	struct usb_hcd	*(*hcd_alloc) (void);
-	void		(*hcd_free) (struct usb_hcd *hcd);
 
 	/* manage i/o requests, device state */
 	int	(*urb_enqueue) (struct usb_hcd *hcd, struct urb *urb,
@@ -217,7 +220,6 @@
 
 extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs);
 extern void usb_bus_init (struct usb_bus *bus);
-extern int usb_rh_status_dequeue (struct usb_hcd *hcd, struct urb *urb);
 
 #ifdef CONFIG_PCI
 struct pci_dev;
@@ -362,6 +364,11 @@
 
 	return usb_register_root_hub (usb_dev, hcd->self.controller);
 }
+
+extern void usb_hcd_release (struct usb_bus *);
+
+extern void usb_set_device_state(struct usb_device *udev,
+		enum usb_device_state new_state);
 
 /*-------------------------------------------------------------------------*/
 
diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/core/hub.c	2004-12-24 13:36:48 -08:00
@@ -36,15 +36,18 @@
 #include "hcd.h"
 #include "hub.h"
 
-/* Protect struct usb_device state and children members */
+/* Protect struct usb_device->state and ->children members
+ * Note: Both are also protected by ->serialize, except that ->state can
+ * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
 static spinlock_t device_state_lock = SPIN_LOCK_UNLOCKED;
 
-/* Wakes up khubd */
+/* khubd's worklist and its lock */
 static spinlock_t hub_event_lock = SPIN_LOCK_UNLOCKED;
-
 static LIST_HEAD(hub_event_list);	/* List of hubs needing servicing */
 
+/* Wakes up khubd */
 static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
+
 static pid_t khubd_pid = 0;			/* PID of khubd */
 static DECLARE_COMPLETION(khubd_exited);
 
@@ -53,6 +56,31 @@
 module_param (blinkenlights, bool, S_IRUGO);
 MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs");
 
+/*
+ * As of 2.6.10 we introduce a new USB device initialization scheme which
+ * closely resembles the way Windows works.  Hopefully it will be compatible
+ * with a wider range of devices than the old scheme.  However some previously
+ * working devices may start giving rise to "device not accepting address"
+ * errors; if that happens the user can try the old scheme by adjusting the
+ * following module parameters.
+ *
+ * For maximum flexibility there are two boolean parameters to control the
+ * hub driver's behavior.  On the first initialization attempt, if the
+ * "old_scheme_first" parameter is set then the old scheme will be used,
+ * otherwise the new scheme is used.  If that fails and "use_both_schemes"
+ * is set, then the driver will make another attempt, using the other scheme.
+ */
+static int old_scheme_first = 0;
+module_param(old_scheme_first, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(old_scheme_first,
+		 "start with the old device initialization scheme");
+
+static int use_both_schemes = 0;
+module_param(use_both_schemes, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(use_both_schemes,
+		"try the other device initialization scheme if the "
+		"first one fails");
+
 
 #ifdef	DEBUG
 static inline char *portspeed (int portstatus)
@@ -75,9 +103,17 @@
 /* USB 2.0 spec Section 11.24.4.5 */
 static int get_hub_descriptor(struct usb_device *hdev, void *data, int size)
 {
-	return usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
-		USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
-		USB_DT_HUB << 8, 0, data, size, HZ * USB_CTRL_GET_TIMEOUT);
+	int i, ret;
+
+	for (i = 0; i < 3; i++) {
+		ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
+			USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
+			USB_DT_HUB << 8, 0, data, size,
+			HZ * USB_CTRL_GET_TIMEOUT);
+		if (ret >= (USB_DT_HUB_NONVAR_SIZE + 2))
+			return ret;
+	}
+	return -EINVAL;
 }
 
 /*
@@ -226,6 +262,19 @@
 		data, sizeof(*data), HZ * USB_CTRL_GET_TIMEOUT);
 }
 
+static void kick_khubd(struct usb_hub *hub)
+{
+	unsigned long	flags;
+
+	spin_lock_irqsave(&hub_event_lock, flags);
+	if (list_empty(&hub->event_list)) {
+		list_add_tail(&hub->event_list, &hub_event_list);
+		wake_up(&khubd_wait);
+	}
+	spin_unlock_irqrestore(&hub_event_lock, flags);
+}
+
+
 /* completion function, fires on port status changes and various faults */
 static void hub_irq(struct urb *urb, struct pt_regs *regs)
 {
@@ -261,12 +310,7 @@
 	hub->nerrors = 0;
 
 	/* Something happened, let khubd figure it out */
-	spin_lock(&hub_event_lock);
-	if (list_empty(&hub->event_list)) {
-		list_add_tail(&hub->event_list, &hub_event_list);
-		wake_up(&khubd_wait);
-	}
-	spin_unlock(&hub_event_lock);
+	kick_khubd(hub);
 
 resubmit:
 	if (hub->quiescing)
@@ -384,6 +428,33 @@
 	msleep(hub->descriptor->bPwrOn2PwrGood * 2);
 }
 
+static void hub_quiesce(struct usb_hub *hub)
+{
+	/* stop khubd and related activity */
+	hub->quiescing = 1;
+	usb_kill_urb(hub->urb);
+	if (hub->has_indicators)
+		cancel_delayed_work(&hub->leds);
+	if (hub->has_indicators || hub->tt.hub)
+		flush_scheduled_work();
+}
+
+static void hub_activate(struct usb_hub *hub)
+{
+	int	status;
+
+	hub->quiescing = 0;
+	status = usb_submit_urb(hub->urb, GFP_NOIO);
+	if (status < 0)
+		dev_err(&hub->intf->dev, "activate --> %d\n", status);
+	if (hub->has_indicators && blinkenlights)
+		schedule_delayed_work(&hub->leds, LED_CYCLE_PERIOD);
+
+	/* scan all ports ASAP */
+	hub->event_bits[0] = ~0;
+	kick_khubd(hub);
+}
+
 static int hub_hub_status(struct usb_hub *hub,
 		u16 *status, u16 *change)
 {
@@ -579,7 +650,7 @@
 		dev_dbg(hub_dev, "%sover-current condition exists\n",
 			(hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");
 
-	/* Start the interrupt endpoint */
+	/* set up the interrupt endpoint */
 	pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress);
 	maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe));
 
@@ -597,24 +668,14 @@
 		hub, endpoint->bInterval);
 	hub->urb->transfer_dma = hub->buffer_dma;
 	hub->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-	ret = usb_submit_urb(hub->urb, GFP_KERNEL);
-	if (ret) {
-		message = "couldn't submit status urb";
-		goto fail;
-	}
-
-	/* Wake up khubd */
-	wake_up(&khubd_wait);
 
-	/* maybe start cycling the hub leds */
-	if (hub->has_indicators && blinkenlights) {
-		set_port_led(hdev, 1, HUB_LED_GREEN);
+	/* maybe cycle the hub leds */
+	if (hub->has_indicators && blinkenlights)
 		hub->indicator [0] = INDICATOR_CYCLE;
-		schedule_delayed_work(&hub->leds, LED_CYCLE_PERIOD);
-	}
 
 	hub_power_on(hub);
-
+	hub->change_bits[0] = ~0;
+	hub_activate(hub);
 	return 0;
 
 fail:
@@ -626,33 +687,6 @@
 
 static unsigned highspeed_hubs;
 
-static void hub_quiesce(struct usb_hub *hub)
-{
-	/* stop khubd and related activity */
-	hub->quiescing = 1;
-	usb_kill_urb(hub->urb);
-	if (hub->has_indicators)
-		cancel_delayed_work(&hub->leds);
-	if (hub->has_indicators || hub->tt.hub)
-		flush_scheduled_work();
-}
-
-#ifdef	CONFIG_USB_SUSPEND
-
-static void hub_reactivate(struct usb_hub *hub)
-{
-	int	status;
-
-	hub->quiescing = 0;
-	status = usb_submit_urb(hub->urb, GFP_NOIO);
-	if (status < 0)
-		dev_err(&hub->intf->dev, "reactivate --> %d\n", status);
-	if (hub->has_indicators && blinkenlights)
-		schedule_delayed_work(&hub->leds, LED_CYCLE_PERIOD);
-}
-
-#endif
-
 static void hub_disconnect(struct usb_interface *intf)
 {
 	struct usb_hub *hub = usb_get_intfdata (intf);
@@ -794,68 +828,29 @@
 	}
 }
 
-/* caller has locked the hub and must own the device lock */
-static int hub_reset(struct usb_hub *hub)
+/* caller has locked the hub device */
+static void hub_pre_reset(struct usb_device *hdev)
 {
-	struct usb_device *hdev = hub->hdev;
+	struct usb_hub *hub = usb_get_intfdata(hdev->actconfig->interface[0]);
 	int i;
 
-	/* Disconnect any attached devices */
-	for (i = 0; i < hub->descriptor->bNbrPorts; i++) {
+	for (i = 0; i < hdev->maxchild; ++i) {
 		if (hdev->children[i])
 			usb_disconnect(&hdev->children[i]);
 	}
-
-	/* Attempt to reset the hub */
-	if (hub->urb)
-		usb_kill_urb(hub->urb);
-	else
-		return -1;
-
-	if (__usb_reset_device(hdev))
-		return -1;
-
-	hub->urb->dev = hdev;                                                    
-	if (usb_submit_urb(hub->urb, GFP_KERNEL))
-		return -1;
-
-	hub_power_on(hub);
-
-	return 0;
+	hub_quiesce(hub);
 }
 
-/* caller has locked the hub */
-/* FIXME!  This routine should be subsumed into hub_reset */
-static void hub_start_disconnect(struct usb_device *hdev)
+/* caller has locked the hub device */
+static void hub_post_reset(struct usb_device *hdev)
 {
-	struct usb_device *parent = hdev->parent;
-	int i;
-
-	/* Find the device pointer to disconnect */
-	if (parent) {
-		for (i = 0; i < parent->maxchild; i++) {
-			if (parent->children[i] == hdev) {
-				usb_disconnect(&parent->children[i]);
-				return;
-			}
-		}
-	}
+	struct usb_hub *hub = usb_get_intfdata(hdev->actconfig->interface[0]);
 
-	dev_err(&hdev->dev, "cannot disconnect hub!\n");
+	hub_activate(hub);
+	hub_power_on(hub);
 }
 
 
-static void recursively_mark_NOTATTACHED(struct usb_device *udev)
-{
-	int i;
-
-	for (i = 0; i < udev->maxchild; ++i) {
-		if (udev->children[i])
-			recursively_mark_NOTATTACHED(udev->children[i]);
-	}
-	udev->state = USB_STATE_NOTATTACHED;
-}
-
 /* grab device/port lock, returning index of that port (zero based).
  * protects the upstream link used by this device from concurrent
  * tree operations like suspend, resume, reset, and disconnect, which
@@ -872,21 +867,16 @@
 	/* root hub is always the first lock in the series */
 	hdev = udev->parent;
 	if (!hdev) {
-		down(&udev->serialize);
+		usb_lock_device(udev);
 		return 0;
 	}
 
 	/* on the path from root to us, lock everything from
 	 * top down, dropping parent locks when not needed
-	 *
-	 * NOTE: if disconnect were to ignore the locking, we'd need
-	 * to get extra refcounts to everything since hdev->children
-	 * and udev->parent could be invalidated while we work...
 	 */
 	t = locktree(hdev);
 	if (t < 0)
 		return t;
-	spin_lock_irq(&device_state_lock);
 	for (t = 0; t < hdev->maxchild; t++) {
 		if (hdev->children[t] == udev) {
 			/* everything is fail-fast once disconnect
@@ -898,33 +888,45 @@
 			/* when everyone grabs locks top->bottom,
 			 * non-overlapping work may be concurrent
 			 */
-			spin_unlock_irq(&device_state_lock);
 			down(&udev->serialize);
 			up(&hdev->serialize);
 			return t;
 		}
 	}
-	spin_unlock_irq(&device_state_lock);
-	up(&hdev->serialize);
+	usb_unlock_device(hdev);
 	return -ENODEV;
 }
 
+static void recursively_mark_NOTATTACHED(struct usb_device *udev)
+{
+	int i;
+
+	for (i = 0; i < udev->maxchild; ++i) {
+		if (udev->children[i])
+			recursively_mark_NOTATTACHED(udev->children[i]);
+	}
+	udev->state = USB_STATE_NOTATTACHED;
+}
+
 /**
- * usb_set_device_state - change a device's current state (usbcore-internal)
+ * usb_set_device_state - change a device's current state (usbcore, hcds)
  * @udev: pointer to device whose state should be changed
  * @new_state: new state value to be stored
  *
- * udev->state is _not_ protected by the device lock.  This
+ * udev->state is _not_ fully protected by the device lock.  Although
+ * most transitions are made only while holding the lock, the state can
+ * can change to USB_STATE_NOTATTACHED at almost any time.  This
  * is so that devices can be marked as disconnected as soon as possible,
- * without having to wait for the semaphore to be released.  Instead,
- * changes to the state must be protected by the device_state_lock spinlock.
+ * without having to wait for any semaphores to be released.  As a result,
+ * all changes to any device's state must be protected by the
+ * device_state_lock spinlock.
  *
  * Once a device has been added to the device tree, all changes to its state
  * should be made using this routine.  The state should _not_ be set directly.
  *
  * If udev->state is already USB_STATE_NOTATTACHED then no change is made.
  * Otherwise udev->state is set to new_state, and if new_state is
- * USB_STATE_NOTATTACHED then all of udev's descendant's states are also set
+ * USB_STATE_NOTATTACHED then all of udev's descendants' states are also set
  * to USB_STATE_NOTATTACHED.
  */
 void usb_set_device_state(struct usb_device *udev,
@@ -941,6 +943,7 @@
 		recursively_mark_NOTATTACHED(udev);
 	spin_unlock_irqrestore(&device_state_lock, flags);
 }
+EXPORT_SYMBOL(usb_set_device_state);
 
 
 static void choose_address(struct usb_device *udev)
@@ -974,11 +977,12 @@
 
 /**
  * usb_disconnect - disconnect a device (usbcore-internal)
- * @pdev: pointer to device being disconnected, into a locked hub
+ * @pdev: pointer to device being disconnected
  * Context: !in_interrupt ()
  *
- * Something got disconnected. Get rid of it, and all of its children.
- * If *pdev is a normal device then the parent hub should be locked.
+ * Something got disconnected. Get rid of it and all of its children.
+ *
+ * If *pdev is a normal device then the parent hub must already be locked.
  * If *pdev is a root hub then this routine will acquire the
  * usb_bus_list_lock on behalf of the caller.
  *
@@ -1004,9 +1008,11 @@
 	usb_set_device_state(udev, USB_STATE_NOTATTACHED);
 
 	/* lock the bus list on behalf of HCDs unregistering their root hubs */
-	if (!udev->parent)
+	if (!udev->parent) {
 		down(&usb_bus_list_lock);
-	down(&udev->serialize);
+		usb_lock_device(udev);
+	} else
+		down(&udev->serialize);
 
 	dev_info (&udev->dev, "USB disconnect, address %d\n", udev->devnum);
 
@@ -1031,14 +1037,16 @@
 	usbfs_remove_device(udev);
 	usb_remove_sysfs_dev_files(udev);
 
-	/* Avoid races with recursively_mark_NOTATTACHED() and locktree() */
+	/* Avoid races with recursively_mark_NOTATTACHED() */
 	spin_lock_irq(&device_state_lock);
 	*pdev = NULL;
 	spin_unlock_irq(&device_state_lock);
 
-	up(&udev->serialize);
-	if (!udev->parent)
+	if (!udev->parent) {
+		usb_unlock_device(udev);
 		up(&usb_bus_list_lock);
+	} else
+		up(&udev->serialize);
 
 	device_unregister(&udev->dev);
 }
@@ -1061,11 +1069,19 @@
 					->altsetting->desc;
 			if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC)
 				continue;
-			/* COMM/2/all is CDC ACM, except 0xff is MSFT RNDIS */
+			/* COMM/2/all is CDC ACM, except 0xff is MSFT RNDIS.
+			 * MSFT needs this to be the first config; never use
+			 * it as the default unless Linux has host-side RNDIS.
+			 * A second config would ideally be CDC-Ethernet, but
+			 * may instead be the "vendor specific" CDC subset
+			 * long used by ARM Linux for sa1100 or pxa255.
+			 */
 			if (desc->bInterfaceClass == USB_CLASS_COMM
 					&& desc->bInterfaceSubClass == 2
-					&& desc->bInterfaceProtocol == 0xff)
+					&& desc->bInterfaceProtocol == 0xff) {
+				c = udev->config[1].desc.bConfigurationValue;
 				continue;
+			}
 			c = udev->config[i].desc.bConfigurationValue;
 			break;
 		}
@@ -1283,7 +1299,8 @@
 #define PORT_RESET_TRIES	5
 #define SET_ADDRESS_TRIES	2
 #define GET_DESCRIPTOR_TRIES	2
-#define SET_CONFIG_TRIES	2
+#define SET_CONFIG_TRIES	(2 * (use_both_schemes + 1))
+#define USE_NEW_SCHEME(i)	((i) / 2 == old_scheme_first)
 
 #define HUB_ROOT_RESET_TIME	50	/* times are in msec */
 #define HUB_SHORT_RESET_TIME	10
@@ -1356,7 +1373,10 @@
 			status = hub_port_wait_reset(hdev, port, udev, delay);
 
 		/* return on disconnect or reset */
-		if (status == -ENOTCONN || status == 0) {
+		switch (status) {
+		case 0:
+		case -ENOTCONN:
+		case -ENODEV:
 			clear_port_feature(hdev,
 				port + 1, USB_PORT_FEAT_C_RESET);
 			/* FIXME need disconnect() for NOTATTACHED device */
@@ -1384,7 +1404,6 @@
 	int ret;
 
 	if (hdev->children[port]) {
-		/* FIXME need disconnect() for NOTATTACHED device */
 		usb_set_device_state(hdev->children[port],
 				USB_STATE_NOTATTACHED);
 	}
@@ -1396,6 +1415,33 @@
 	return ret;
 }
 
+/*
+ * Disable a port and mark a logical connnect-change event, so that some
+ * time later khubd will disconnect() any existing usb_device on the port
+ * and will re-enumerate if there actually is a device attached.
+ */
+static void hub_port_logical_disconnect(struct usb_device *hdev, int port)
+{
+	struct usb_hub *hub;
+
+	dev_dbg(hubdev(hdev), "logical disconnect on port %d\n", port + 1);
+	hub_port_disable(hdev, port);
+
+	/* FIXME let caller ask to power down the port:
+	 *  - some devices won't enumerate without a VBUS power cycle
+	 *  - SRP saves power that way
+	 *  - usb_suspend_device(dev,PM_SUSPEND_DISK)
+	 * That's easy if this hub can switch power per-port, and
+	 * khubd reactivates the port later (timer, SRP, etc).
+	 * Powerdown must be optional, because of reset/DFU.
+	 */
+
+	hub = usb_get_intfdata(hdev->actconfig->interface[0]);
+	set_bit(port, hub->change_bits);
+ 	kick_khubd(hub);
+}
+
+
 #ifdef	CONFIG_USB_SUSPEND
 
 /*
@@ -1413,8 +1459,8 @@
 	int			status;
 	struct usb_device	*udev;
 
-	udev = hdev->children[port - 1];
-	// dev_dbg(hubdev(hdev), "suspend port %d\n", port);
+	udev = hdev->children[port];
+	// dev_dbg(hubdev(hdev), "suspend port %d\n", port + 1);
 
 	/* enable remote wakeup when appropriate; this lets the device
 	 * wake up the upstream hub (including maybe the root hub).
@@ -1439,11 +1485,11 @@
 	}
 
 	/* see 7.1.7.6 */
-	status = set_port_feature(hdev, port, USB_PORT_FEAT_SUSPEND);
+	status = set_port_feature(hdev, port + 1, USB_PORT_FEAT_SUSPEND);
 	if (status) {
 		dev_dbg(hubdev(hdev),
 			"can't suspend port %d, status %d\n",
-			port, status);
+			port + 1, status);
 		/* paranoia:  "should not happen" */
 		(void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
@@ -1473,20 +1519,16 @@
  * Linux (2.6) currently has NO mechanisms to initiate that:  no khubd
  * timer, no SRP, no requests through sysfs.
  */
-static int __usb_suspend_device (struct usb_device *udev, int port, u32 state)
+int __usb_suspend_device (struct usb_device *udev, int port, u32 state)
 {
 	int	status;
 
+	/* caller owns the udev device lock */
 	if (port < 0)
 		return port;
 
-	/* NOTE:  udev->serialize released on all real returns! */
-
-	if (state <= udev->dev.power.power_state
-			|| state < PM_SUSPEND_MEM
-			|| udev->state == USB_STATE_SUSPENDED
+	if (udev->state == USB_STATE_SUSPENDED
 			|| udev->state == USB_STATE_NOTATTACHED) {
-		up(&udev->serialize);
 		return 0;
 	}
 
@@ -1549,7 +1591,6 @@
 	 */
 	if (state > PM_SUSPEND_MEM) {
 		dev_warn(&udev->dev, "no poweroff yet, suspending instead\n");
-		state = PM_SUSPEND_MEM;
 	}
 
 	/* "global suspend" of the HC-to-USB interface (root hub), or
@@ -1557,18 +1598,19 @@
 	 */
 	if (!udev->parent) {
 		struct usb_bus	*bus = udev->bus;
-		if (bus && bus->op->hub_suspend)
+		if (bus && bus->op->hub_suspend) {
 			status = bus->op->hub_suspend (bus);
-		else
+			if (status == 0)
+				usb_set_device_state(udev,
+						USB_STATE_SUSPENDED);
+		} else
 			status = -EOPNOTSUPP;
 	} else
-		status = hub_port_suspend(udev->parent, port + 1);
+		status = hub_port_suspend(udev->parent, port);
 
-	if (status == 0)
-		udev->dev.power.power_state = state;
-	up(&udev->serialize);
 	return status;
 }
+EXPORT_SYMBOL(__usb_suspend_device);
 
 /**
  * usb_suspend_device - suspend a usb device
@@ -1590,7 +1632,15 @@
  */
 int usb_suspend_device(struct usb_device *udev, u32 state)
 {
-	return __usb_suspend_device(udev, locktree(udev), state);
+	int	port, status;
+
+	port = locktree(udev);
+	if (port < 0)
+		return port;
+
+	status = __usb_suspend_device(udev, port, state);
+	usb_unlock_device(udev);
+	return status;
 }
 
 /*
@@ -1603,9 +1653,8 @@
 	int	status;
 	u16	devstatus;
 
-	/* caller owns udev->serialize */
+	/* caller owns the udev device lock */
 	dev_dbg(&udev->dev, "usb resume\n");
-	udev->dev.power.power_state = PM_SUSPEND_ON;
 
 	/* usb ch9 identifies four variants of SUSPENDED, based on what
 	 * state the device resumes to.  Linux currently won't see the
@@ -1687,15 +1736,15 @@
 	int			status;
 	struct usb_device	*udev;
 
-	udev = hdev->children[port - 1];
-	// dev_dbg(hubdev(hdev), "resume port %d\n", port);
+	udev = hdev->children[port];
+	// dev_dbg(hubdev(hdev), "resume port %d\n", port + 1);
 
 	/* see 7.1.7.7; affects power usage, but not budgeting */
-	status = clear_port_feature(hdev, port, USB_PORT_FEAT_SUSPEND);
+	status = clear_port_feature(hdev, port + 1, USB_PORT_FEAT_SUSPEND);
 	if (status) {
 		dev_dbg(&hdev->actconfig->interface[0]->dev,
 			"can't resume port %d, status %d\n",
-			port, status);
+			port + 1, status);
 	} else {
 		u16		devstatus;
 		u16		portchange;
@@ -1713,7 +1762,7 @@
 		 * sequence.
 		 */
 		devstatus = portchange = 0;
-		status = hub_port_status(hdev, port - 1,
+		status = hub_port_status(hdev, port,
 				&devstatus, &portchange);
 		if (status < 0
 				|| (devstatus & LIVE_FLAGS) != LIVE_FLAGS
@@ -1721,7 +1770,7 @@
 				) {
 			dev_dbg(&hdev->actconfig->interface[0]->dev,
 				"port %d status %04x.%04x after resume, %d\n",
-				port, portchange, devstatus, status);
+				port + 1, portchange, devstatus, status);
 		} else {
 			/* TRSMRCY = 10 msec */
 			msleep(10);
@@ -1729,7 +1778,7 @@
 		}
 	}
 	if (status < 0)
-		status = hub_port_disable(hdev, port);
+		hub_port_logical_disconnect(hdev, port);
 
 	return status;
 }
@@ -1762,32 +1811,36 @@
 	 */
 	if (!udev->parent) {
 		struct usb_bus	*bus = udev->bus;
-		if (bus && bus->op->hub_resume)
+		if (bus && bus->op->hub_resume) {
 			status = bus->op->hub_resume (bus);
-		else
+		} else
 			status = -EOPNOTSUPP;
 		if (status == 0) {
 			/* TRSMRCY = 10 msec */
 			msleep(10);
-			status = hub_resume (bus->root_hub
+			usb_set_device_state (udev, USB_STATE_CONFIGURED);
+			status = hub_resume (udev
 					->actconfig->interface[0]);
 		}
 	} else if (udev->state == USB_STATE_SUSPENDED) {
-		status = hub_port_resume(udev->parent, port + 1);
+		// NOTE this fails if parent is also suspended...
+		status = hub_port_resume(udev->parent, port);
 	} else {
 		status = 0;
-		udev->dev.power.power_state = PM_SUSPEND_ON;
 	}
 	if (status < 0) {
 		dev_dbg(&udev->dev, "can't resume, status %d\n",
 			status);
 	}
 
-	up(&udev->serialize);
+	usb_unlock_device(udev);
 
 	/* rebind drivers that had no suspend() */
-	bus_rescan_devices(&usb_bus_type);
-
+	if (status == 0) {
+		usb_lock_all_devices();
+		bus_rescan_devices(&usb_bus_type);
+		usb_unlock_all_devices();
+	}
 	return status;
 }
 
@@ -1828,6 +1881,7 @@
 			continue;
 		down(&udev->serialize);
 		status = __usb_suspend_device(udev, port, state);
+		up(&udev->serialize);
 		if (status < 0)
 			dev_dbg(&intf->dev, "suspend port %d --> %d\n",
 				port, status);
@@ -1844,6 +1898,9 @@
 	unsigned		port;
 	int			status;
 
+	if (intf->dev.power.power_state == PM_SUSPEND_ON)
+		return 0;
+
 	for (port = 0; port < hdev->maxchild; port++) {
 		struct usb_device	*udev;
 		u16			portstat, portchange;
@@ -1862,24 +1919,24 @@
 				continue;
 		}
 
-		if (!udev)
+		if (!udev || status < 0)
 			continue;
 		down (&udev->serialize);
 		if (portstat & USB_PORT_STAT_SUSPEND)
-			status = hub_port_resume(hdev, port + 1);
+			status = hub_port_resume(hdev, port);
 		else {
 			status = finish_port_resume(udev);
-			if (status < 0)
-				status = hub_port_disable(hdev, port);
-			if (status < 0)
+			if (status < 0) {
 				dev_dbg(&intf->dev, "resume port %d --> %d\n",
-					port, status);
+					port + 1, status);
+				hub_port_logical_disconnect(hdev, port);
+			}
 		}
 		up(&udev->serialize);
 	}
 	intf->dev.power.power_state = PM_SUSPEND_ON;
 
-	hub_reactivate(hub);
+	hub_activate(hub);
 	return 0;
 }
 
@@ -1967,20 +2024,30 @@
 	return portstatus;
 }
 
+#define usb_sndaddr0pipe()	(PIPE_CONTROL << 30)
+#define usb_rcvaddr0pipe()	((PIPE_CONTROL << 30) | USB_DIR_IN)
+
 static int hub_set_address(struct usb_device *udev)
 {
 	int retval;
 
 	if (udev->devnum == 0)
 		return -EINVAL;
-	if (udev->state != USB_STATE_DEFAULT &&
-			udev->state != USB_STATE_ADDRESS)
+	if (udev->state == USB_STATE_ADDRESS)
+		return 0;
+	if (udev->state != USB_STATE_DEFAULT)
 		return -EINVAL;
-	retval = usb_control_msg(udev, (PIPE_CONTROL << 30) /* Address 0 */,
+	retval = usb_control_msg(udev, usb_sndaddr0pipe(),
 		USB_REQ_SET_ADDRESS, 0, udev->devnum, 0,
 		NULL, 0, HZ * USB_CTRL_SET_TIMEOUT);
-	if (retval == 0)
+	if (retval == 0) {
+		int m = udev->epmaxpacketin[0];
+
 		usb_set_device_state(udev, USB_STATE_ADDRESS);
+		usb_disable_endpoint(udev, 0 + USB_DIR_IN);
+		usb_disable_endpoint(udev, 0 + USB_DIR_OUT);
+		udev->epmaxpacketin[0] = udev->epmaxpacketout[0] = m;
+	}
 	return retval;
 }
 
@@ -1994,7 +2061,8 @@
  * pointers, it's not necessary to lock the device.
  */
 static int
-hub_port_init (struct usb_device *hdev, struct usb_device *udev, int port)
+hub_port_init (struct usb_device *hdev, struct usb_device *udev, int port,
+		int retry_counter)
 {
 	static DECLARE_MUTEX(usb_address0_sem);
 
@@ -2011,10 +2079,6 @@
 			hdev->bus->b_hnp_enable = 0;
 	}
 
-	retval = clear_port_feature(hdev, port, USB_PORT_FEAT_SUSPEND);
-	if (retval < 0 && retval != -EPIPE)
-		dev_dbg(&udev->dev, "can't clear suspend; %d\n", retval);
-
 	/* Some low speed devices have problems with the quick delay, so */
 	/*  be a bit pessimistic with those devices. RHbug #23670 */
 	if (oldspeed == USB_SPEED_LOW)
@@ -2033,6 +2097,7 @@
 		dev_dbg(&udev->dev, "device reset changed speed!\n");
 		goto fail;
 	}
+	oldspeed = udev->speed;
   
 	/* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
 	 * it's fixed size except for full speed devices.
@@ -2042,22 +2107,22 @@
 		i = 64;
 		break;
 	case USB_SPEED_FULL:		/* 8, 16, 32, or 64 */
-		/* to determine the ep0 maxpacket size, read the first 8
-		 * bytes from the device descriptor to get bMaxPacketSize0;
-		 * then correct our initial (small) guess.
+		/* to determine the ep0 maxpacket size, try to read
+		 * the device descriptor to get bMaxPacketSize0 and
+		 * then correct our initial guess.
 		 */
-		// FALLTHROUGH
+		i = 64;
+		break;
 	case USB_SPEED_LOW:		/* fixed at 8 */
 		i = 8;
 		break;
 	default:
 		goto fail;
 	}
-	udev->epmaxpacketin [0] = i;
-	udev->epmaxpacketout[0] = i;
+	udev->epmaxpacketin[0] = udev->epmaxpacketout[0] = i;
  
 	dev_info (&udev->dev,
-			"%s %s speed USB device using address %d\n",
+			"%s %s speed USB device using %s and address %d\n",
 			(udev->config) ? "reset" : "new",
 			({ char *speed; switch (udev->speed) {
 			case USB_SPEED_LOW:	speed = "low";	break;
@@ -2065,6 +2130,7 @@
 			case USB_SPEED_HIGH:	speed = "high";	break;
 			default: 		speed = "?";	break;
 			}; speed;}),
+			udev->bus->controller->driver->name,
 			udev->devnum);
 
 	/* Set up TT records, if needed  */
@@ -2085,11 +2151,59 @@
 	 * this area, and this is how Linux has done it for ages.
 	 * Change it cautiously.
 	 *
-	 * NOTE:  Windows gets the descriptor first, seemingly to help
-	 * work around device bugs like "can't use addresses with bit 3
-	 * set in certain configurations".  Yes, really.
-	 */
-	for (i = 0; i < GET_DESCRIPTOR_TRIES; ++i) {
+	 * NOTE:  If USE_NEW_SCHEME() is true we will start by issuing
+	 * a 64-byte GET_DESCRIPTOR request.  This is what Windows does,
+	 * so it may help with some non-standards-compliant devices.
+	 * Otherwise we start with SET_ADDRESS and then try to read the
+	 * first 8 bytes of the device descriptor to get the ep0 maxpacket
+	 * value.
+	 */
+	for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) {
+		if (USE_NEW_SCHEME(retry_counter)) {
+			struct usb_device_descriptor *buf;
+
+#define GET_DESCRIPTOR_BUFSIZE	64
+			buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO);
+			if (!buf) {
+				retval = -ENOMEM;
+				continue;
+			}
+			buf->bMaxPacketSize0 = 0;
+
+			/* Use a short timeout the first time through,
+			 * so that recalcitrant full-speed devices with
+			 * 8- or 16-byte ep0-maxpackets won't slow things
+			 * down tremendously by NAKing the unexpectedly
+			 * early status stage.
+			 */
+			j = usb_control_msg(udev, usb_rcvaddr0pipe(),
+					USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
+					USB_DT_DEVICE << 8, 0,
+					buf, GET_DESCRIPTOR_BUFSIZE,
+					(i ? HZ * USB_CTRL_GET_TIMEOUT : HZ));
+			udev->descriptor.bMaxPacketSize0 =
+					buf->bMaxPacketSize0;
+			kfree(buf);
+
+			retval = hub_port_reset(hdev, port, udev, delay);
+			if (retval < 0)		/* error or disconnect */
+				goto fail;
+			if (oldspeed != udev->speed) {
+				dev_dbg(&udev->dev,
+					"device reset changed speed!\n");
+				retval = -ENODEV;
+				goto fail;
+			}
+			if (udev->descriptor.bMaxPacketSize0 == 0) {
+				dev_err(&udev->dev, "device descriptor "
+						"read/%s, error %d\n",
+						"64", j);
+				retval = -EMSGSIZE;
+				continue;
+			}
+#undef GET_DESCRIPTOR_BUFSIZE
+		}
+
 		for (j = 0; j < SET_ADDRESS_TRIES; ++j) {
 			retval = hub_set_address(udev);
 			if (retval >= 0)
@@ -2108,25 +2222,31 @@
 		 *  - read ep0 maxpacket even for high and low speed,
   		 */
 		msleep(10);
+		if (USE_NEW_SCHEME(retry_counter))
+			break;
+
 		retval = usb_get_device_descriptor(udev, 8);
-		if (retval >= 8)
+		if (retval < 8) {
+			dev_err(&udev->dev, "device descriptor "
+					"read/%s, error %d\n",
+					"8", retval);
+			if (retval >= 0)
+				retval = -EMSGSIZE;
+		} else {
+			retval = 0;
 			break;
-		msleep(100);
+		}
 	}
-	if (retval != 8) {
-		dev_err(&udev->dev, "device descriptor read/%s, error %d\n",
-				"8", retval);
-		if (retval >= 0)
-			retval = -EMSGSIZE;
+	if (retval)
 		goto fail;
-	}
-	if (udev->speed == USB_SPEED_FULL
-			&& (udev->epmaxpacketin [0]
-				!= udev->descriptor.bMaxPacketSize0)) {
+
+	/* Should we verify that the value is valid? */
+	i = udev->descriptor.bMaxPacketSize0;
+	if (udev->epmaxpacketin[0] != i) {
+		dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
 		usb_disable_endpoint(udev, 0 + USB_DIR_IN);
 		usb_disable_endpoint(udev, 0 + USB_DIR_OUT);
-		udev->epmaxpacketin [0] = udev->descriptor.bMaxPacketSize0;
-		udev->epmaxpacketout[0] = udev->descriptor.bMaxPacketSize0;
+		udev->epmaxpacketin[0] = udev->epmaxpacketout[0] = i;
 	}
   
 	retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
@@ -2272,6 +2392,15 @@
 		return;
 	}
 
+#ifdef  CONFIG_USB_SUSPEND
+	/* If something is connected, but the port is suspended, wake it up.. */
+	if (portstatus & USB_PORT_STAT_SUSPEND) {
+		status = hub_port_resume(hdev, port);
+		if (status < 0)
+			dev_dbg(hub_dev, "can't clear suspend on port %d; %d\n", port+1, status);
+	}
+#endif
+
 	for (i = 0; i < SET_CONFIG_TRIES; i++) {
 		struct usb_device *udev;
 
@@ -2296,7 +2425,7 @@
 		}
 
 		/* reset and get descriptor */
-		status = hub_port_init(hdev, udev, port);
+		status = hub_port_init(hdev, udev, port, i);
 		if (status < 0)
 			goto loop;
 
@@ -2429,6 +2558,14 @@
 		usb_get_dev(hdev);
 		spin_unlock_irq(&hub_event_lock);
 
+		dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
+				hdev->state, hub->descriptor
+					? hub->descriptor->bNbrPorts
+					: 0,
+				/* NOTE: expects max 15 ports... */
+				(u16) hub->change_bits[0],
+				(u16) hub->event_bits[0]);
+
 		/* Lock the device, then check to see if we were
 		 * disconnected while waiting for the lock to succeed. */
 		if (locktree(hdev) < 0)
@@ -2443,10 +2580,10 @@
 			dev_dbg (hub_dev, "resetting for error %d\n",
 				hub->error);
 
-			if (hub_reset(hub)) {
+			ret = usb_reset_device(hdev);
+			if (ret) {
 				dev_dbg (hub_dev,
-					"can't reset; disconnecting\n");
-				hub_start_disconnect(hdev);
+					"error resetting hub: %d\n", ret);
 				goto loop;
 			}
 
@@ -2502,15 +2639,17 @@
 			if (portchange & USB_PORT_STAT_C_SUSPEND) {
 				clear_port_feature(hdev, i + 1,
 					USB_PORT_FEAT_C_SUSPEND);
-				if (hdev->children[i])
+				if (hdev->children[i]) {
 					ret = remote_wakeup(hdev->children[i]);
-				else
+					if (ret < 0)
+						connect_change = 1;
+				} else {
 					ret = -ENODEV;
+					hub_port_disable(hdev, i);
+				}
 				dev_dbg (hub_dev,
 					"resume on port %d, status %d\n",
 					i + 1, ret);
-				if (ret < 0)
-					ret = hub_port_disable(hdev, i);
 			}
 			
 			if (portchange & USB_PORT_STAT_C_OVERCURRENT) {
@@ -2554,7 +2693,7 @@
 		}
 
 loop:
-		up(&hdev->serialize);
+		usb_unlock_device(hdev);
 		usb_put_dev(hdev);
 
         } /* end while (1) */
@@ -2707,13 +2846,15 @@
  *
  * The caller must own the device lock.  For example, it's safe to use
  * this from a driver probe() routine after downloading new firmware.
+ * For calls that might not occur during probe(), drivers should lock
+ * the device using usb_lock_device_for_reset().
  */
-int __usb_reset_device(struct usb_device *udev)
+int usb_reset_device(struct usb_device *udev)
 {
 	struct usb_device *parent = udev->parent;
 	struct usb_device_descriptor descriptor = udev->descriptor;
-	int i, ret, port = -1;
-	struct usb_hub *hub;
+	int i, ret = 0, port = -1;
+	int udev_is_a_hub = 0;
 
 	if (udev->state == USB_STATE_NOTATTACHED ||
 			udev->state == USB_STATE_SUSPENDED) {
@@ -2722,13 +2863,9 @@
 		return -EINVAL;
 	}
 
-	/* FIXME: This should be legal for regular hubs.  Root hubs may
-	 * have special requirements. */
-	if (udev->maxchild) {
-		/* this requires hub- or hcd-specific logic;
-		 * see hub_reset() and OHCI hc_restart()
-		 */
-		dev_dbg(&udev->dev, "%s for hub!\n", __FUNCTION__);
+	if (!parent) {
+		/* this requires hcd-specific logic; see OHCI hc_restart() */
+		dev_dbg(&udev->dev, "%s for root hub!\n", __FUNCTION__);
 		return -EISDIR;
 	}
 
@@ -2744,7 +2881,24 @@
 		return -ENOENT;
 	}
 
-	ret = hub_port_init(parent, udev, port);
+	/* If we're resetting an active hub, take some special actions */
+	if (udev->actconfig &&
+			udev->actconfig->interface[0]->dev.driver ==
+			&hub_driver.driver) {
+		udev_is_a_hub = 1;
+		hub_pre_reset(udev);
+	}
+
+	for (i = 0; i < SET_CONFIG_TRIES; ++i) {
+
+		/* ep0 maxpacket size may change; let the HCD know about it.
+		 * Other endpoints will be handled by re-enumeration. */
+		usb_disable_endpoint(udev, 0 + USB_DIR_IN);
+		usb_disable_endpoint(udev, 0 + USB_DIR_OUT);
+		ret = hub_port_init(parent, udev, port, i);
+		if (ret >= 0)
+			break;
+	}
 	if (ret < 0)
 		goto re_enumerate;
  
@@ -2757,7 +2911,7 @@
   	}
   
 	if (!udev->actconfig)
-		return 0;
+		goto done;
 
 	ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 			USB_REQ_SET_CONFIGURATION, 0,
@@ -2791,32 +2945,12 @@
 		}
 	}
 
+done:
+	if (udev_is_a_hub)
+		hub_post_reset(udev);
 	return 0;
  
 re_enumerate:
-	hub_port_disable(parent, port);
-
-	hub = usb_get_intfdata(parent->actconfig->interface[0]);
-	set_bit(port, hub->change_bits);
-
-	spin_lock_irq(&hub_event_lock);
-	if (list_empty(&hub->event_list)) {
-		list_add_tail(&hub->event_list, &hub_event_list);
-		wake_up(&khubd_wait);
-	}
-	spin_unlock_irq(&hub_event_lock);
-
+	hub_port_logical_disconnect(parent, port);
 	return -ENODEV;
-}
-EXPORT_SYMBOL(__usb_reset_device);
-
-int usb_reset_device(struct usb_device *udev)
-{
-	int r;
-	
-	down(&udev->serialize);
-	r = __usb_reset_device(udev);
-	up(&udev->serialize);
-
-	return r;
 }
diff -Nru a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
--- a/drivers/usb/core/inode.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/core/inode.c	2004-12-24 13:36:18 -08:00
@@ -4,7 +4,7 @@
  *	inode.c  --  Inode/Dentry functions for the USB device file system.
  *
  *	Copyright (C) 2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
- *	Copyright (C) 2001,2002 Greg Kroah-Hartman (greg@kroah.com)
+ *	Copyright (C) 2001,2002,2004 Greg Kroah-Hartman (greg@kroah.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
@@ -40,17 +40,15 @@
 #include <linux/smp_lock.h>
 #include <linux/parser.h>
 #include <asm/byteorder.h>
+#include "usb.h"
 
 static struct super_operations usbfs_ops;
 static struct file_operations default_file_operations;
 static struct inode_operations usbfs_dir_inode_operations;
-static struct vfsmount *usbdevfs_mount;
 static struct vfsmount *usbfs_mount;
-static int usbdevfs_mount_count;	/* = 0 */
 static int usbfs_mount_count;	/* = 0 */
 static int ignore_mount = 0;
 
-static struct dentry *devices_usbdevfs_dentry;
 static struct dentry *devices_usbfs_dentry;
 static int num_buses;	/* = 0 */
 
@@ -240,9 +238,6 @@
 	if (usbfs_mount && usbfs_mount->mnt_sb)
 		update_sb(usbfs_mount->mnt_sb);
 
-	if (usbdevfs_mount && usbdevfs_mount->mnt_sb)
-		update_sb(usbdevfs_mount->mnt_sb);
-
 	return 0;
 }
 
@@ -561,28 +556,12 @@
 
 /* --------------------------------------------------------------------- */
 
-
-
-/*
- * The usbdevfs name is now deprecated (as of 2.5.1).
- * It will be removed when the 2.7.x development cycle is started.
- * You have been warned :)
- */
-static struct file_system_type usbdevice_fs_type;
-
 static struct super_block *usb_get_sb(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data)
 {
 	return get_sb_single(fs_type, flags, data, usbfs_fill_super);
 }
 
-static struct file_system_type usbdevice_fs_type = {
-	.owner =	THIS_MODULE,
-	.name =		"usbdevfs",
-	.get_sb =	usb_get_sb,
-	.kill_sb =	kill_litter_super,
-};
-
 static struct file_system_type usb_fs_type = {
 	.owner =	THIS_MODULE,
 	.name =		"usbfs",
@@ -603,16 +582,10 @@
 	ignore_mount = 1;
 
 	/* create the devices special file */
-	retval = simple_pin_fs("usbdevfs", &usbdevfs_mount, &usbdevfs_mount_count);
-	if (retval) {
-		err ("Unable to get usbdevfs mount");
-		goto exit;
-	}
-
 	retval = simple_pin_fs("usbfs", &usbfs_mount, &usbfs_mount_count);
 	if (retval) {
 		err ("Unable to get usbfs mount");
-		goto error_clean_usbdevfs_mount;
+		goto exit;
 	}
 
 	ignore_mount = 0;
@@ -620,7 +593,7 @@
 	parent = usbfs_mount->mnt_sb->s_root;
 	devices_usbfs_dentry = fs_create_file ("devices",
 					       listmode | S_IFREG, parent,
-					       NULL, &usbdevfs_devices_fops,
+					       NULL, &usbfs_devices_fops,
 					       listuid, listgid);
 	if (devices_usbfs_dentry == NULL) {
 		err ("Unable to create devices usbfs file");
@@ -628,42 +601,19 @@
 		goto error_clean_mounts;
 	}
 
-	parent = usbdevfs_mount->mnt_sb->s_root;
-	devices_usbdevfs_dentry = fs_create_file ("devices",
-						  listmode | S_IFREG, parent,
-						  NULL, &usbdevfs_devices_fops,
-						  listuid, listgid);
-	if (devices_usbdevfs_dentry == NULL) {
-		err ("Unable to create devices usbfs file");
-		retval = -ENODEV;
-		goto error_remove_file;
-	}
-
 	goto exit;
 	
-error_remove_file:
-	fs_remove_file (devices_usbfs_dentry);
-	devices_usbfs_dentry = NULL;
-
 error_clean_mounts:
 	simple_release_fs(&usbfs_mount, &usbfs_mount_count);
-
-error_clean_usbdevfs_mount:
-	simple_release_fs(&usbdevfs_mount, &usbdevfs_mount_count);
-
 exit:
 	return retval;
 }
 
 static void remove_special_files (void)
 {
-	if (devices_usbdevfs_dentry)
-		fs_remove_file (devices_usbdevfs_dentry);
 	if (devices_usbfs_dentry)
 		fs_remove_file (devices_usbfs_dentry);
-	devices_usbdevfs_dentry = NULL;
 	devices_usbfs_dentry = NULL;
-	simple_release_fs(&usbdevfs_mount, &usbdevfs_mount_count);
 	simple_release_fs(&usbfs_mount, &usbfs_mount_count);
 }
 
@@ -671,11 +621,6 @@
 {
 	struct inode *inode;
 
-	if (devices_usbdevfs_dentry) {
-		inode = devices_usbdevfs_dentry->d_inode;
-		if (inode)
-			inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-	}
 	if (devices_usbfs_dentry) {
 		inode = devices_usbfs_dentry->d_inode;
 		if (inode)
@@ -707,29 +652,16 @@
 		return;
 	}
 
-	parent = usbdevfs_mount->mnt_sb->s_root;
-	bus->usbdevfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent,
-					       bus, NULL, busuid, busgid);
-	if (bus->usbdevfs_dentry == NULL) {
-		err ("error creating usbdevfs bus entry");
-		return;
-	}
-
 	usbfs_update_special();
-	usbdevfs_conn_disc_event();
+	usbfs_conn_disc_event();
 }
 
-
 void usbfs_remove_bus(struct usb_bus *bus)
 {
 	if (bus->usbfs_dentry) {
 		fs_remove_file (bus->usbfs_dentry);
 		bus->usbfs_dentry = NULL;
 	}
-	if (bus->usbdevfs_dentry) {
-		fs_remove_file (bus->usbdevfs_dentry);
-		bus->usbdevfs_dentry = NULL;
-	}
 
 	--num_buses;
 	if (num_buses <= 0) {
@@ -738,7 +670,7 @@
 	}
 
 	usbfs_update_special();
-	usbdevfs_conn_disc_event();
+	usbfs_conn_disc_event();
 }
 
 void usbfs_add_device(struct usb_device *dev)
@@ -750,20 +682,12 @@
 	sprintf (name, "%03d", dev->devnum);
 	dev->usbfs_dentry = fs_create_file (name, devmode | S_IFREG,
 					    dev->bus->usbfs_dentry, dev,
-					    &usbdevfs_device_file_operations,
+					    &usbfs_device_file_operations,
 					    devuid, devgid);
 	if (dev->usbfs_dentry == NULL) {
 		err ("error creating usbfs device entry");
 		return;
 	}
-	dev->usbdevfs_dentry = fs_create_file (name, devmode | S_IFREG,
-					       dev->bus->usbdevfs_dentry, dev,
-					       &usbdevfs_device_file_operations,
-					       devuid, devgid);
-	if (dev->usbdevfs_dentry == NULL) {
-		err ("error creating usbdevfs device entry");
-		return;
-	}
 
 	/* Set the size of the device's file to be
 	 * equal to the size of the device descriptors. */
@@ -771,15 +695,13 @@
 	for (i = 0; i < dev->descriptor.bNumConfigurations; ++i) {
 		struct usb_config_descriptor *config =
 			(struct usb_config_descriptor *)dev->rawdescriptors[i];
-		i_size += le16_to_cpu (config->wTotalLength);
+		i_size += le16_to_cpu ((__force __le16)config->wTotalLength);
 	}
 	if (dev->usbfs_dentry->d_inode)
 		dev->usbfs_dentry->d_inode->i_size = i_size;
-	if (dev->usbdevfs_dentry->d_inode)
-		dev->usbdevfs_dentry->d_inode->i_size = i_size;
 
 	usbfs_update_special();
-	usbdevfs_conn_disc_event();
+	usbfs_conn_disc_event();
 }
 
 void usbfs_remove_device(struct usb_device *dev)
@@ -791,12 +713,9 @@
 		fs_remove_file (dev->usbfs_dentry);
 		dev->usbfs_dentry = NULL;
 	}
-	if (dev->usbdevfs_dentry) {
-		fs_remove_file (dev->usbdevfs_dentry);
-		dev->usbdevfs_dentry = NULL;
-	}
 	while (!list_empty(&dev->filelist)) {
 		ds = list_entry(dev->filelist.next, struct dev_state, list);
+		wake_up_all(&ds->wait);
 		list_del_init(&ds->list);
 		if (ds->discsignr) {
 			sinfo.si_signo = SIGPIPE;
@@ -807,51 +726,38 @@
 		}
 	}
 	usbfs_update_special();
-	usbdevfs_conn_disc_event();
+	usbfs_conn_disc_event();
 }
 
 /* --------------------------------------------------------------------- */
 
-#ifdef CONFIG_PROC_FS		
 static struct proc_dir_entry *usbdir = NULL;
-#endif	
 
 int __init usbfs_init(void)
 {
 	int retval;
 
-	retval = usb_register(&usbdevfs_driver);
+	retval = usb_register(&usbfs_driver);
 	if (retval)
 		return retval;
 
 	retval = register_filesystem(&usb_fs_type);
 	if (retval) {
-		usb_deregister(&usbdevfs_driver);
-		return retval;
-	}
-	retval = register_filesystem(&usbdevice_fs_type);
-	if (retval) {
-		unregister_filesystem(&usb_fs_type);
-		usb_deregister(&usbdevfs_driver);
+		usb_deregister(&usbfs_driver);
 		return retval;
 	}
 
-#ifdef CONFIG_PROC_FS		
-	/* create mount point for usbdevfs */
+	/* create mount point for usbfs */
 	usbdir = proc_mkdir("usb", proc_bus);
-#endif	
 
 	return 0;
 }
 
 void usbfs_cleanup(void)
 {
-	usb_deregister(&usbdevfs_driver);
+	usb_deregister(&usbfs_driver);
 	unregister_filesystem(&usb_fs_type);
-	unregister_filesystem(&usbdevice_fs_type);
-#ifdef CONFIG_PROC_FS	
 	if (usbdir)
 		remove_proc_entry("usb", proc_bus);
-#endif
 }
 
diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c
--- a/drivers/usb/core/message.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/usb/core/message.c	2004-12-24 13:36:31 -08:00
@@ -17,6 +17,8 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/timer.h>
+#include <linux/ctype.h>
+#include <linux/device.h>
 #include <asm/byteorder.h>
 
 #include "hcd.h"	/* for usbcore internals */
@@ -32,10 +34,6 @@
 {
 	struct urb	*urb = (struct urb *) data;
 
-	dev_warn(&urb->dev->dev, "%s timeout on ep%d%s\n",
-		usb_pipecontrol(urb->pipe) ? "control" : "bulk",
-		usb_pipeendpoint(urb->pipe),
-		usb_pipein(urb->pipe) ? "in" : "out");
 	usb_unlink_urb(urb);
 }
 
@@ -66,8 +64,14 @@
 		wait_for_completion(&done);
 		status = urb->status;
 		/* note:  HCDs return ETIMEDOUT for other reasons too */
-		if (status == -ECONNRESET)
+		if (status == -ECONNRESET) {
+			dev_warn(&urb->dev->dev,
+				"%s timed out on ep%d%s\n",
+				current->comm,
+				usb_pipeendpoint(urb->pipe),
+				usb_pipein(urb->pipe) ? "in" : "out");
 			status = -ETIMEDOUT;
+		}
 		if (timeout > 0)
 			del_timer_sync(&timer);
 	}
@@ -239,14 +243,16 @@
 		// BUG ();
 	}
 
-	if (urb->status && urb->status != -ECONNRESET) {
+	if (io->status == 0 && urb->status && urb->status != -ECONNRESET) {
 		int		i, found, status;
 
 		io->status = urb->status;
 
 		/* the previous urbs, and this one, completed already.
 		 * unlink pending urbs so they won't rx/tx bad data.
+		 * careful: unlink can sometimes be synchronous...
 		 */
+		spin_unlock (&io->lock);
 		for (i = 0, found = 0; i < io->entries; i++) {
 			if (!io->urbs [i] || !io->urbs [i]->dev)
 				continue;
@@ -259,6 +265,7 @@
 			} else if (urb == io->urbs [i])
 				found = 1;
 		}
+		spin_lock (&io->lock);
 	}
 	urb->dev = NULL;
 
@@ -520,6 +527,7 @@
 		int	i;
 
 		io->status = -ECONNRESET;
+		spin_unlock (&io->lock);
 		for (i = 0; i < io->entries; i++) {
 			int	retval;
 
@@ -530,6 +538,7 @@
 				dev_warn (&io->dev->dev, "%s, unlink --> %d\n",
 					__FUNCTION__, retval);
 		}
+		spin_lock (&io->lock);
 	}
 	spin_unlock_irqrestore (&io->lock, flags);
 }
@@ -547,8 +556,7 @@
  *
  * Gets a USB descriptor.  Convenience functions exist to simplify
  * getting some types of descriptors.  Use
- * usb_get_device_descriptor() for USB_DT_DEVICE (not exported),
- * and usb_get_string() or usb_string() for USB_DT_STRING.
+ * usb_get_string() or usb_string() for USB_DT_STRING.
  * Device (USB_DT_DEVICE) and configuration descriptors (USB_DT_CONFIG)
  * are part of the device structure.
  * In addition to a number of USB-standard descriptors, some
@@ -623,6 +631,20 @@
 	return result;
 }
 
+static void usb_try_string_workarounds(unsigned char *buf, int *length)
+{
+	int newlength, oldlength = *length;
+
+	for (newlength = 2; newlength + 1 < oldlength; newlength += 2)
+		if (!isprint(buf[newlength]) || buf[newlength + 1])
+			break;
+
+	if (newlength > 2) {
+		buf[0] = newlength;
+		*length = newlength;
+	}
+}
+
 static int usb_string_sub(struct usb_device *dev, unsigned int langid,
 		unsigned int index, unsigned char *buf)
 {
@@ -634,19 +656,26 @@
 
 	/* If that failed try to read the descriptor length, then
 	 * ask for just that many bytes */
-	if (rc < 0) {
+	if (rc < 2) {
 		rc = usb_get_string(dev, langid, index, buf, 2);
 		if (rc == 2)
 			rc = usb_get_string(dev, langid, index, buf, buf[0]);
 	}
 
-	if (rc >= 0) {
+	if (rc >= 2) {
+		if (!buf[0] && !buf[1])
+			usb_try_string_workarounds(buf, &rc);
+
 		/* There might be extra junk at the end of the descriptor */
 		if (buf[0] < rc)
 			rc = buf[0];
-		if (rc < 2)
-			rc = -EINVAL;
+
+		rc = rc - (rc & 1); /* force a multiple of two */
 	}
+
+	if (rc < 2)
+		rc = (rc < 0 ? rc : -EINVAL);
+
 	return rc;
 }
 
@@ -680,6 +709,8 @@
 	int err;
 	unsigned int u, idx;
 
+	if (dev->state == USB_STATE_SUSPENDED)
+		return -EHOSTUNREACH;
 	if (size <= 0 || !buf || !index)
 		return -EINVAL;
 	buf[0] = 0;
@@ -724,13 +755,16 @@
 	buf[idx] = 0;
 	err = idx;
 
+	if (tbuf[1] != USB_DT_STRING)
+		dev_dbg(&dev->dev, "wrong descriptor type %02x for string %d (\"%s\")\n", tbuf[1], index, buf);
+
  errout:
 	kfree(tbuf);
 	return err;
 }
 
-/**
- * usb_get_device_descriptor - (re)reads the device descriptor
+/*
+ * usb_get_device_descriptor - (re)reads the device descriptor (usbcore)
  * @dev: the device whose device descriptor is being updated
  * @size: how much of the descriptor to read
  * Context: !in_interrupt ()
@@ -797,9 +831,19 @@
  */
 int usb_get_status(struct usb_device *dev, int type, int target, void *data)
 {
-	return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-		USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, data, 2,
-		HZ * USB_CTRL_GET_TIMEOUT);
+	int ret;
+	u16 *status = kmalloc(sizeof(*status), GFP_KERNEL);
+
+	if (!status)
+		return -ENOMEM;
+
+	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+		USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, status,
+		sizeof(*status), HZ * USB_CTRL_GET_TIMEOUT);
+
+	*(u16 *)data = *status;
+	kfree(status);
+	return ret;
 }
 
 /**
@@ -1132,6 +1176,8 @@
  * use usb_set_interface() on the interfaces it claims.  Resetting the whole
  * configuration would affect other drivers' interfaces.
  *
+ * The caller must own the device lock.
+ *
  * Returns zero on success, else a negative error code.
  */
 int usb_reset_configuration(struct usb_device *dev)
@@ -1142,9 +1188,9 @@
 	if (dev->state == USB_STATE_SUSPENDED)
 		return -EHOSTUNREACH;
 
-	/* caller must own dev->serialize (config won't change)
-	 * and the usb bus readlock (so driver bindings are stable);
-	 * so calls during probe() are fine
+	/* caller must have locked the device and must own
+	 * the usb bus readlock (so driver bindings are stable);
+	 * calls during probe() are fine
 	 */
 
 	for (i = 1; i < 16; ++i) {
@@ -1199,7 +1245,7 @@
  * usb_set_configuration - Makes a particular device setting be current
  * @dev: the device whose configuration is being updated
  * @configuration: the configuration being chosen.
- * Context: !in_interrupt(), caller holds dev->serialize
+ * Context: !in_interrupt(), caller owns the device lock
  *
  * This is used to enable non-default device modes.  Not all devices
  * use this kind of configurability; many devices only have one
@@ -1220,8 +1266,8 @@
  * usb_set_interface().
  *
  * This call is synchronous. The calling context must be able to sleep,
- * and must not hold the driver model lock for USB; usb device driver
- * probe() methods may not use this routine.
+ * must own the device lock, and must not hold the driver model's USB
+ * bus rwsem; usb device driver probe() methods cannot use this routine.
  *
  * Returns zero on success, or else the status code returned by the
  * underlying call that failed.  On succesful completion, each interface
@@ -1235,8 +1281,6 @@
 	struct usb_host_config *cp = NULL;
 	struct usb_interface **new_interfaces = NULL;
 	int n, nintf;
-
-	/* dev->serialize guards all config changes */
 
 	for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
 		if (dev->config[i].desc.bConfigurationValue == configuration) {
diff -Nru a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
--- a/drivers/usb/core/sysfs.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/usb/core/sysfs.c	2004-12-24 13:36:31 -08:00
@@ -27,11 +27,13 @@
 static ssize_t  show_##field (struct device *dev, char *buf)		\
 {									\
 	struct usb_device *udev;					\
+	struct usb_host_config *actconfig;				\
 									\
 	udev = to_usb_device (dev);					\
-	if (udev->actconfig)						\
+	actconfig = udev->actconfig;					\
+	if (actconfig)							\
 		return sprintf (buf, format_string,			\
-				udev->actconfig->desc.field * multiplier);	\
+				actconfig->desc.field * multiplier);	\
 	else								\
 		return 0;						\
 }									\
@@ -44,6 +46,28 @@
 usb_actconfig_attr (bmAttributes, 1, "%2x\n")
 usb_actconfig_attr (bMaxPower, 2, "%3dmA\n")
 
+#define usb_actconfig_str(name, field)					\
+static ssize_t  show_##name(struct device *dev, char *buf)		\
+{									\
+	struct usb_device *udev;					\
+	struct usb_host_config *actconfig;				\
+	int len;							\
+									\
+	udev = to_usb_device (dev);					\
+	actconfig = udev->actconfig;					\
+	if (!actconfig)							\
+		return 0;						\
+	len = usb_string(udev, actconfig->desc.field, buf, PAGE_SIZE);	\
+	if (len < 0)							\
+		return 0;						\
+	buf[len] = '\n';						\
+	buf[len+1] = 0;							\
+	return len+1;							\
+}									\
+static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
+
+usb_actconfig_str (configuration, iConfiguration)
+
 /* configuration value is always present, and r/w */
 usb_actconfig_show(bConfigurationValue, 1, "%u\n");
 
@@ -55,9 +79,9 @@
 
 	if (sscanf (buf, "%u", &config) != 1 || config > 255)
 		return -EINVAL;
-	down(&udev->serialize);
+	usb_lock_device(udev);
 	value = usb_set_configuration (udev, config);
-	up(&udev->serialize);
+	usb_unlock_device(udev);
 	return (value < 0) ? value : count;
 }
 
@@ -198,6 +222,7 @@
 		device_create_file (dev, &dev_attr_product);
 	if (udev->descriptor.iSerialNumber)
 		device_create_file (dev, &dev_attr_serial);
+	device_create_file (dev, &dev_attr_configuration);
 }
 
 void usb_remove_sysfs_dev_files (struct usb_device *udev)
@@ -212,6 +237,7 @@
 		device_remove_file(dev, &dev_attr_product);
 	if (udev->descriptor.iSerialNumber)
 		device_remove_file(dev, &dev_attr_serial);
+	device_remove_file (dev, &dev_attr_configuration);
 }
 
 /* Interface fields */
@@ -231,7 +257,26 @@
 usb_intf_attr (bInterfaceClass, "%02x\n")
 usb_intf_attr (bInterfaceSubClass, "%02x\n")
 usb_intf_attr (bInterfaceProtocol, "%02x\n")
-usb_intf_attr (iInterface, "%02x\n")
+
+#define usb_intf_str(name, field)					\
+static ssize_t  show_##name(struct device *dev, char *buf)		\
+{									\
+	struct usb_interface *intf;					\
+	struct usb_device *udev;					\
+	int len;							\
+									\
+	intf = to_usb_interface (dev);					\
+	udev = interface_to_usbdev (intf);				\
+	len = usb_string(udev, intf->cur_altsetting->desc.field, buf, PAGE_SIZE);\
+	if (len < 0)							\
+		return 0;						\
+	buf[len] = '\n';						\
+	buf[len+1] = 0;							\
+	return len+1;							\
+}									\
+static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
+
+usb_intf_str (interface, iInterface);
 
 static struct attribute *intf_attrs[] = {
 	&dev_attr_bInterfaceNumber.attr,
@@ -240,7 +285,6 @@
 	&dev_attr_bInterfaceClass.attr,
 	&dev_attr_bInterfaceSubClass.attr,
 	&dev_attr_bInterfaceProtocol.attr,
-	&dev_attr_iInterface.attr,
 	NULL,
 };
 static struct attribute_group intf_attr_grp = {
@@ -250,9 +294,17 @@
 void usb_create_sysfs_intf_files (struct usb_interface *intf)
 {
 	sysfs_create_group(&intf->dev.kobj, &intf_attr_grp);
+
+	if (intf->cur_altsetting->desc.iInterface)
+		device_create_file(&intf->dev, &dev_attr_interface);
+		
 }
 
 void usb_remove_sysfs_intf_files (struct usb_interface *intf)
 {
 	sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp);
+
+	if (intf->cur_altsetting->desc.iInterface)
+		device_remove_file(&intf->dev, &dev_attr_interface);
+
 }
diff -Nru a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
--- a/drivers/usb/core/urb.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/usb/core/urb.c	2004-12-24 13:37:00 -08:00
@@ -264,11 +264,10 @@
 
 	max = usb_maxpacket (dev, pipe, is_out);
 	if (max <= 0) {
-		dbg ("%s: bogus endpoint %d-%s on usb-%s-%s (bad maxpacket %d)",
-			__FUNCTION__,
-			usb_pipeendpoint (pipe), is_out ? "OUT" : "IN",
-			dev->bus->bus_name, dev->devpath,
-			max);
+		dev_dbg(&dev->dev,
+			"bogus endpoint ep%d%s in %s (bad maxpacket %d)",
+			usb_pipeendpoint (pipe), is_out ? "out" : "in",
+			__FUNCTION__, max);
 		return -EMSGSIZE;
 	}
 
@@ -451,6 +450,13 @@
 	if (!urb)
 		return -EINVAL;
 	if (!(urb->transfer_flags & URB_ASYNC_UNLINK)) {
+#ifdef CONFIG_DEBUG_KERNEL
+		if (printk_ratelimit()) {
+			printk(KERN_NOTICE "usb_unlink_urb() is deprecated for "
+				"synchronous unlinks.  Use usb_kill_urb() instead.\n");
+			WARN_ON(1);
+		}
+#endif
 		usb_kill_urb(urb);
 		return 0;
 	}
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/usb/core/usb.c	2004-12-24 13:36:55 -08:00
@@ -39,6 +39,7 @@
 #include <linux/spinlock.h>
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
+#include <linux/rwsem.h>
 #include <linux/usb.h>
 
 #include <asm/io.h>
@@ -62,6 +63,9 @@
 int nousb;		/* Disable USB when built into kernel image */
 			/* Not honored on modular build */
 
+DECLARE_RWSEM(usb_all_devices_rwsem);
+EXPORT_SYMBOL(usb_all_devices_rwsem);
+
 
 static int generic_probe (struct device *dev)
 {
@@ -73,6 +77,7 @@
 }
 
 static struct device_driver usb_generic_driver = {
+	.owner = THIS_MODULE,
 	.name =	"usb",
 	.bus = &usb_bus_type,
 	.probe = generic_probe,
@@ -93,13 +98,17 @@
 
 	if (!driver->probe)
 		return error;
+	/* FIXME we'd much prefer to just resume it ... */
 	if (interface_to_usbdev(intf)->state == USB_STATE_SUSPENDED)
 		return -EHOSTUNREACH;
 
 	id = usb_match_id (intf, driver->id_table);
 	if (id) {
 		dev_dbg (dev, "%s - got id\n", __FUNCTION__);
+		intf->condition = USB_INTERFACE_BINDING;
 		error = driver->probe (intf, id);
+		intf->condition = error ? USB_INTERFACE_UNBOUND :
+				USB_INTERFACE_BOUND;
 	}
 
 	return error;
@@ -111,6 +120,8 @@
 	struct usb_interface *intf = to_usb_interface(dev);
 	struct usb_driver *driver = to_usb_driver(intf->dev.driver);
 
+	intf->condition = USB_INTERFACE_UNBINDING;
+
 	/* release all urbs for this interface */
 	usb_disable_interface(interface_to_usbdev(intf), intf);
 
@@ -122,6 +133,7 @@
 			intf->altsetting[0].desc.bInterfaceNumber,
 			0);
 	usb_set_intfdata(intf, NULL);
+	intf->condition = USB_INTERFACE_UNBOUND;
 
 	return 0;
 }
@@ -150,8 +162,11 @@
 	new_driver->driver.bus = &usb_bus_type;
 	new_driver->driver.probe = usb_probe_interface;
 	new_driver->driver.remove = usb_unbind_interface;
+	new_driver->driver.owner = new_driver->owner;
 
+	usb_lock_all_devices();
 	retval = driver_register(&new_driver->driver);
+	usb_unlock_all_devices();
 
 	if (!retval) {
 		pr_info("%s: registered new driver %s\n",
@@ -180,7 +195,9 @@
 {
 	pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name);
 
+	usb_lock_all_devices();
 	driver_unregister (&driver->driver);
+	usb_unlock_all_devices();
 
 	usbfs_update_special();
 }
@@ -202,7 +219,7 @@
  * alternate settings available for this interfaces.
  *
  * Don't call this function unless you are bound to one of the interfaces
- * on this device or you own the dev->serialize semaphore!
+ * on this device or you have locked the device!
  */
 struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
 {
@@ -235,7 +252,7 @@
  * drivers avoid such mistakes.
  *
  * Don't call this function unless you are bound to the intf interface
- * or you own the device's ->serialize semaphore!
+ * or you have locked the device!
  */
 struct usb_host_interface *usb_altnum_to_altsetting(struct usb_interface *intf,
 		unsigned int altnum)
@@ -303,11 +320,12 @@
  * way to bind to an interface is to return the private data from
  * the driver's probe() method.
  *
- * Callers must own the driver model's usb bus writelock.  So driver
- * probe() entries don't need extra locking, but other call contexts
- * may need to explicitly claim that lock.
+ * Callers must own the device lock and the driver model's usb_bus_type.subsys
+ * writelock.  So driver probe() entries don't need extra locking,
+ * but other call contexts may need to explicitly claim those locks.
  */
-int usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface *iface, void* priv)
+int usb_driver_claim_interface(struct usb_driver *driver,
+				struct usb_interface *iface, void* priv)
 {
 	struct device *dev = &iface->dev;
 
@@ -316,6 +334,7 @@
 
 	dev->driver = &driver->driver;
 	usb_set_intfdata(iface, priv);
+	iface->condition = USB_INTERFACE_BOUND;
 
 	/* if interface was already added, bind now; else let
 	 * the future device_add() bind it, bypassing probe()
@@ -336,8 +355,8 @@
  * also causes the driver disconnect() method to be called.
  *
  * This call is synchronous, and may not be used in an interrupt context.
- * Callers must own the usb_device serialize semaphore and the driver model's
- * usb bus writelock.  So driver disconnect() entries don't need extra locking,
+ * Callers must own the device lock and the driver model's usb_bus_type.subsys
+ * writelock.  So driver disconnect() entries don't need extra locking,
  * but other call contexts may need to explicitly claim those locks.
  */
 void usb_driver_release_interface(struct usb_driver *driver,
@@ -355,6 +374,7 @@
 
 	dev->driver = NULL;
 	usb_set_intfdata(iface, NULL);
+	iface->condition = USB_INTERFACE_UNBOUND;
 }
 
 /**
@@ -532,9 +552,7 @@
 		return 0;
 
 	intf = to_usb_interface(dev);
-
 	usb_drv = to_usb_driver(drv);
-	id = usb_drv->id_table;
 	
 	id = usb_match_id (intf, usb_drv->id_table);
 	if (id)
@@ -564,7 +582,6 @@
 {
 	struct usb_interface *intf;
 	struct usb_device *usb_dev;
-	char *scratch;
 	int i = 0;
 	int length = 0;
 
@@ -591,8 +608,6 @@
 		return -ENODEV;
 	}
 
-	scratch = buffer;
-
 #ifdef	CONFIG_USB_DEVICEFS
 	/* If this is available, userspace programs can directly read
 	 * all the device descriptors we don't tell them about.  Or
@@ -600,37 +615,30 @@
 	 *
 	 * FIXME reduce hardwired intelligence here
 	 */
-	envp [i++] = scratch;
-	length += snprintf (scratch, buffer_size - length,
-			    "DEVICE=/proc/bus/usb/%03d/%03d",
-			    usb_dev->bus->busnum, usb_dev->devnum);
-	if ((buffer_size - length <= 0) || (i >= num_envp))
+	if (add_hotplug_env_var(envp, num_envp, &i,
+				buffer, buffer_size, &length,
+				"DEVICE=/proc/bus/usb/%03d/%03d",
+				usb_dev->bus->busnum, usb_dev->devnum))
 		return -ENOMEM;
-	++length;
-	scratch += length;
 #endif
 
 	/* per-device configurations are common */
-	envp [i++] = scratch;
-	length += snprintf (scratch, buffer_size - length, "PRODUCT=%x/%x/%x",
-			    usb_dev->descriptor.idVendor,
-			    usb_dev->descriptor.idProduct,
-			    usb_dev->descriptor.bcdDevice);
-	if ((buffer_size - length <= 0) || (i >= num_envp))
+	if (add_hotplug_env_var(envp, num_envp, &i,
+				buffer, buffer_size, &length,
+				"PRODUCT=%x/%x/%x",
+				usb_dev->descriptor.idVendor,
+				usb_dev->descriptor.idProduct,
+				usb_dev->descriptor.bcdDevice))
 		return -ENOMEM;
-	++length;
-	scratch += length;
 
 	/* class-based driver binding models */
-	envp [i++] = scratch;
-	length += snprintf (scratch, buffer_size - length, "TYPE=%d/%d/%d",
-			    usb_dev->descriptor.bDeviceClass,
-			    usb_dev->descriptor.bDeviceSubClass,
-			    usb_dev->descriptor.bDeviceProtocol);
-	if ((buffer_size - length <= 0) || (i >= num_envp))
+	if (add_hotplug_env_var(envp, num_envp, &i,
+				buffer, buffer_size, &length,
+				"TYPE=%d/%d/%d",
+				usb_dev->descriptor.bDeviceClass,
+				usb_dev->descriptor.bDeviceSubClass,
+				usb_dev->descriptor.bDeviceProtocol))
 		return -ENOMEM;
-	++length;
-	scratch += length;
 
 	if (usb_dev->descriptor.bDeviceClass == 0) {
 		struct usb_host_interface *alt = intf->cur_altsetting;
@@ -639,19 +647,16 @@
 		 * agents are called for all interfaces, and can use
 		 * $DEVPATH/bInterfaceNumber if necessary.
 		 */
-		envp [i++] = scratch;
-		length += snprintf (scratch, buffer_size - length,
-			    "INTERFACE=%d/%d/%d",
-			    alt->desc.bInterfaceClass,
-			    alt->desc.bInterfaceSubClass,
-			    alt->desc.bInterfaceProtocol);
-		if ((buffer_size - length <= 0) || (i >= num_envp))
+		if (add_hotplug_env_var(envp, num_envp, &i,
+					buffer, buffer_size, &length,
+					"INTERFACE=%d/%d/%d",
+					alt->desc.bInterfaceClass,
+					alt->desc.bInterfaceSubClass,
+					alt->desc.bInterfaceProtocol))
 			return -ENOMEM;
-		++length;
-		scratch += length;
-
 	}
-	envp[i++] = NULL;
+
+	envp[i] = NULL;
 
 	return 0;
 }
@@ -759,7 +764,11 @@
 	init_MUTEX(&dev->serialize);
 
 	if (dev->bus->op->allocate)
-		dev->bus->op->allocate(dev);
+		if (dev->bus->op->allocate(dev)) {
+			usb_bus_put(bus);
+			kfree(dev);
+			return NULL;
+		}
 
 	return dev;
 }
@@ -830,6 +839,160 @@
 		put_device(&intf->dev);
 }
 
+
+/*			USB device locking
+ *
+ * Although locking USB devices should be straightforward, it is
+ * complicated by the way the driver-model core works.  When a new USB
+ * driver is registered or unregistered, the core will automatically
+ * probe or disconnect all matching interfaces on all USB devices while
+ * holding the USB subsystem writelock.  There's no good way for us to
+ * tell which devices will be used or to lock them beforehand; our only
+ * option is to effectively lock all the USB devices.
+ *
+ * We do that by using a private rw-semaphore, usb_all_devices_rwsem.
+ * When locking an individual device you must first acquire the rwsem's
+ * readlock.  When a driver is registered or unregistered the writelock
+ * must be held.  These actions are encapsulated in the subroutines
+ * below, so all a driver needs to do is call usb_lock_device() and
+ * usb_unlock_device().
+ *
+ * Complications arise when several devices are to be locked at the same
+ * time.  Only hub-aware drivers that are part of usbcore ever have to
+ * do this; nobody else needs to worry about it.  The problem is that
+ * usb_lock_device() must not be called to lock a second device since it
+ * would acquire the rwsem's readlock reentrantly, leading to deadlock if
+ * another thread was waiting for the writelock.  The solution is simple:
+ *
+ *	When locking more than one device, call usb_lock_device()
+ *	to lock the first one.  Lock the others by calling
+ *	down(&udev->serialize) directly.
+ *
+ *	When unlocking multiple devices, use up(&udev->serialize)
+ *	to unlock all but the last one.  Unlock the last one by
+ *	calling usb_unlock_device().
+ *
+ *	When locking both a device and its parent, always lock the
+ *	the parent first.
+ */
+
+/**
+ * usb_lock_device - acquire the lock for a usb device structure
+ * @udev: device that's being locked
+ *
+ * Use this routine when you don't hold any other device locks;
+ * to acquire nested inner locks call down(&udev->serialize) directly.
+ * This is necessary for proper interaction with usb_lock_all_devices().
+ */
+void usb_lock_device(struct usb_device *udev)
+{
+	down_read(&usb_all_devices_rwsem);
+	down(&udev->serialize);
+}
+
+/**
+ * usb_trylock_device - attempt to acquire the lock for a usb device structure
+ * @udev: device that's being locked
+ *
+ * Don't use this routine if you already hold a device lock;
+ * use down_trylock(&udev->serialize) instead.
+ * This is necessary for proper interaction with usb_lock_all_devices().
+ *
+ * Returns 1 if successful, 0 if contention.
+ */
+int usb_trylock_device(struct usb_device *udev)
+{
+	if (!down_read_trylock(&usb_all_devices_rwsem))
+		return 0;
+	if (down_trylock(&udev->serialize)) {
+		up_read(&usb_all_devices_rwsem);
+		return 0;
+	}
+	return 1;
+}
+
+/**
+ * usb_lock_device_for_reset - cautiously acquire the lock for a
+ *	usb device structure
+ * @udev: device that's being locked
+ * @iface: interface bound to the driver making the request (optional)
+ *
+ * Attempts to acquire the device lock, but fails if the device is
+ * NOTATTACHED or SUSPENDED, or if iface is specified and the interface
+ * is neither BINDING nor BOUND.  Rather than sleeping to wait for the
+ * lock, the routine polls repeatedly.  This is to prevent deadlock with
+ * disconnect; in some drivers (such as usb-storage) the disconnect()
+ * callback will block waiting for a device reset to complete.
+ *
+ * Returns a negative error code for failure, otherwise 1 or 0 to indicate
+ * that the device will or will not have to be unlocked.  (0 can be
+ * returned when an interface is given and is BINDING, because in that
+ * case the driver already owns the device lock.)
+ */
+int usb_lock_device_for_reset(struct usb_device *udev,
+		struct usb_interface *iface)
+{
+	if (udev->state == USB_STATE_NOTATTACHED)
+		return -ENODEV;
+	if (udev->state == USB_STATE_SUSPENDED)
+		return -EHOSTUNREACH;
+	if (iface) {
+		switch (iface->condition) {
+		  case USB_INTERFACE_BINDING:
+			return 0;
+		  case USB_INTERFACE_BOUND:
+			break;
+		  default:
+			return -EINTR;
+		}
+	}
+
+	while (!usb_trylock_device(udev)) {
+		msleep(15);
+		if (udev->state == USB_STATE_NOTATTACHED)
+			return -ENODEV;
+		if (udev->state == USB_STATE_SUSPENDED)
+			return -EHOSTUNREACH;
+		if (iface && iface->condition != USB_INTERFACE_BOUND)
+			return -EINTR;
+	}
+	return 1;
+}
+
+/**
+ * usb_unlock_device - release the lock for a usb device structure
+ * @udev: device that's being unlocked
+ *
+ * Use this routine when releasing the only device lock you hold;
+ * to release inner nested locks call up(&udev->serialize) directly.
+ * This is necessary for proper interaction with usb_lock_all_devices().
+ */
+void usb_unlock_device(struct usb_device *udev)
+{
+	up(&udev->serialize);
+	up_read(&usb_all_devices_rwsem);
+}
+
+/**
+ * usb_lock_all_devices - acquire the lock for all usb device structures
+ *
+ * This is necessary when registering a new driver or probing a bus,
+ * since the driver-model core may try to use any usb_device.
+ */
+void usb_lock_all_devices(void)
+{
+	down_write(&usb_all_devices_rwsem);
+}
+
+/**
+ * usb_unlock_all_devices - release the lock for all usb device structures
+ */
+void usb_unlock_all_devices(void)
+{
+	up_write(&usb_all_devices_rwsem);
+}
+
+
 static struct usb_device *match_device(struct usb_device *dev,
 				       u16 vendor_id, u16 product_id)
 {
@@ -851,8 +1014,10 @@
 	/* look through all of the children of this device */
 	for (child = 0; child < dev->maxchild; ++child) {
 		if (dev->children[child]) {
+			down(&dev->children[child]->serialize);
 			ret_dev = match_device(dev->children[child],
 					       vendor_id, product_id);
+			up(&dev->children[child]->serialize);
 			if (ret_dev)
 				goto exit;
 		}
@@ -887,7 +1052,9 @@
 		bus = container_of(buslist, struct usb_bus, bus_list);
 		if (!bus->root_hub)
 			continue;
+		usb_lock_device(bus->root_hub);
 		dev = match_device(bus->root_hub, vendor_id, product_id);
+		usb_unlock_device(bus->root_hub);
 		if (dev)
 			goto exit;
 	}
@@ -1238,6 +1405,10 @@
 	intf = to_usb_interface(dev);
 	driver = to_usb_driver(dev->driver);
 
+	/* there's only one USB suspend state */
+	if (intf->dev.power.power_state)
+		return 0;
+
 	if (driver->suspend)
 		return driver->suspend(intf, state);
 	return 0;
@@ -1372,6 +1543,11 @@
 EXPORT_SYMBOL(usb_put_dev);
 EXPORT_SYMBOL(usb_get_dev);
 EXPORT_SYMBOL(usb_hub_tt_clear_buffer);
+
+EXPORT_SYMBOL(usb_lock_device);
+EXPORT_SYMBOL(usb_trylock_device);
+EXPORT_SYMBOL(usb_lock_device_for_reset);
+EXPORT_SYMBOL(usb_unlock_device);
 
 EXPORT_SYMBOL(usb_driver_claim_interface);
 EXPORT_SYMBOL(usb_driver_release_interface);
diff -Nru a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
--- a/drivers/usb/core/usb.h	2004-12-24 13:36:30 -08:00
+++ b/drivers/usb/core/usb.h	2004-12-24 13:36:30 -08:00
@@ -22,8 +22,29 @@
 		unsigned int size);
 extern int usb_set_configuration(struct usb_device *dev, int configuration);
 
-extern void usb_set_device_state(struct usb_device *udev,
-		enum usb_device_state new_state);
+extern void usb_lock_all_devices(void);
+extern void usb_unlock_all_devices(void);
 
 /* for labeling diagnostics */
 extern const char *usbcore_name;
+
+/* usbfs stuff */
+extern struct usb_driver usbfs_driver;
+extern struct file_operations usbfs_devices_fops;
+extern struct file_operations usbfs_device_file_operations;
+extern void usbfs_conn_disc_event(void);
+
+struct dev_state {
+	struct list_head list;      /* state list */
+	struct usb_device *dev;
+	struct file *file;
+	spinlock_t lock;            /* protects the async urb lists */
+	struct list_head async_pending;
+	struct list_head async_completed;
+	wait_queue_head_t wait;     /* wake up if a request completed */
+	unsigned int discsignr;
+	struct task_struct *disctask;
+	void __user *disccontext;
+	unsigned long ifclaimed;
+};
+
diff -Nru a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
--- a/drivers/usb/gadget/Kconfig	2004-12-24 13:36:33 -08:00
+++ b/drivers/usb/gadget/Kconfig	2004-12-24 13:36:33 -08:00
@@ -39,6 +39,17 @@
 	   If in doubt, say "N" and don't enable these drivers; most people
 	   don't have this kind of hardware (except maybe inside Linux PDAs).
 
+config USB_GADGET_DEBUG_FILES
+	boolean "Debugging information files"
+	depends on USB_GADGET && PROC_FS
+	help
+	   Some of the drivers in the "gadget" framework can expose
+	   debugging information in files such as /proc/driver/udc
+	   (for a peripheral controller).  The information in these
+	   files may help when you're troubleshooting or bringing up a
+	   driver on a new board.   Enable these files by choosing "Y"
+	   here.  If in doubt, or to conserve kernel memory, say "N".
+
 #
 # USB Peripheral Controller Support
 #
@@ -205,10 +216,6 @@
 	   later, when two dual-role devices talk to each other.
 
 	   Select this only if your OMAP board has a Mini-AB connector.
-
-config USB_OMAP_PROC
-	boolean "/proc/driver/udc file"
-	depends on USB_GADGET_OMAP
 
 endchoice
 
diff -Nru a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
--- a/drivers/usb/gadget/Makefile	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/gadget/Makefile	2004-12-24 13:36:18 -08:00
@@ -13,7 +13,7 @@
 #
 g_zero-objs			:= zero.o usbstring.o config.o epautoconf.o
 g_ether-objs			:= ether.o usbstring.o config.o epautoconf.o
-g_serial-objs			:= serial.o usbstring.o epautoconf.o
+g_serial-objs			:= serial.o usbstring.o config.o epautoconf.o
 gadgetfs-objs			:= inode.o
 g_file_storage-objs		:= file_storage.o usbstring.o config.o \
 					epautoconf.o
diff -Nru a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
--- a/drivers/usb/gadget/dummy_hcd.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/gadget/dummy_hcd.c	2004-12-24 13:36:17 -08:00
@@ -65,7 +65,7 @@
 
 
 #define DRIVER_DESC	"USB Host+Gadget Emulator"
-#define DRIVER_VERSION	"14 Mar 2004"
+#define DRIVER_VERSION	"29 Oct 2004"
 
 static const char	driver_name [] = "dummy_hcd";
 static const char	driver_desc [] = "USB Host+Gadget Emulator";
@@ -95,6 +95,17 @@
 	struct usb_request		req;
 };
 
+static inline struct dummy_ep *usb_ep_to_dummy_ep (struct usb_ep *_ep)
+{
+	return container_of (_ep, struct dummy_ep, ep);
+}
+
+static inline struct dummy_request *usb_request_to_dummy_request
+		(struct usb_request *_req)
+{
+	return container_of (_req, struct dummy_request, req);
+}
+
 /*-------------------------------------------------------------------------*/
 
 /*
@@ -133,6 +144,7 @@
 #define FIFO_SIZE		64
 
 struct dummy {
+	struct usb_hcd			hcd;		/* must come first! */
 	spinlock_t			lock;
 
 	/*
@@ -149,37 +161,49 @@
 	/*
 	 * MASTER/HOST side support
 	 */
-	struct usb_hcd			hcd;
-	struct platform_device		pdev;
 	struct timer_list		timer;
 	u32				port_status;
-	int				started;
-	struct completion		released;
+	unsigned			started:1;
 	unsigned			resuming:1;
 	unsigned long			re_timeout;
 
 	struct usb_device		*udev;
 };
 
-static struct dummy	*the_controller;
+static inline struct dummy *hcd_to_dummy (struct usb_hcd *hcd)
+{
+	return container_of(hcd, struct dummy, hcd);
+}
+
+static inline struct device *dummy_dev (struct dummy *dum)
+{
+	return dum->hcd.self.controller;
+}
 
 static inline struct dummy *ep_to_dummy (struct dummy_ep *ep)
 {
 	return container_of (ep->gadget, struct dummy, gadget);
 }
 
+static inline struct dummy *gadget_to_dummy (struct usb_gadget *gadget)
+{
+	return container_of (gadget, struct dummy, gadget);
+}
+
 static inline struct dummy *gadget_dev_to_dummy (struct device *dev)
 {
 	return container_of (dev, struct dummy, gadget.dev);
 }
 
+static struct dummy			*the_controller;
+
+/*-------------------------------------------------------------------------*/
+
 /*
  * This "hardware" may look a bit odd in diagnostics since it's got both
  * host and device sides; and it binds different drivers to each side.
  */
-#define hardware	(&the_controller->pdev.dev)
-
-/*-------------------------------------------------------------------------*/
+static struct platform_device		the_pdev;
 
 static struct device_driver dummy_driver = {
 	.name		= (char *) driver_name,
@@ -195,8 +219,8 @@
  * drivers would do real i/o using dma, fifos, irqs, timers, etc.
  */
 
-#define is_enabled() \
-	(the_controller->port_status & USB_PORT_STAT_ENABLE)
+#define is_enabled(dum) \
+	(dum->port_status & USB_PORT_STAT_ENABLE)
 
 static int
 dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
@@ -206,10 +230,12 @@
 	unsigned		max;
 	int			retval;
 
-	ep = container_of (_ep, struct dummy_ep, ep);
+	ep = usb_ep_to_dummy_ep (_ep);
 	if (!_ep || !desc || ep->desc || _ep->name == ep0name
 			|| desc->bDescriptorType != USB_DT_ENDPOINT)
-	if (!the_controller->driver || !is_enabled ())
+		return -EINVAL;
+	dum = ep_to_dummy (ep);
+	if (!dum->driver || !is_enabled (dum))
 		return -ESHUTDOWN;
 	max = desc->wMaxPacketSize & 0x3ff;
 
@@ -221,7 +247,6 @@
 	 * have some extra sanity checks.  (there could be more though,
 	 * especially for "ep9out" style fixed function ones.)
 	 */
-	dum = container_of (ep->gadget, struct dummy, gadget);
 	retval = -EINVAL;
 	switch (desc->bmAttributes & 0x03) {
 	case USB_ENDPOINT_XFER_BULK:
@@ -290,7 +315,7 @@
 	_ep->maxpacket = max;
 	ep->desc = desc;
 
-	dev_dbg (hardware, "enabled %s (ep%d%s-%s) maxpacket %d\n",
+	dev_dbg (dummy_dev(dum), "enabled %s (ep%d%s-%s) maxpacket %d\n",
 		_ep->name,
 		desc->bEndpointAddress & 0x0f,
 		(desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out",
@@ -334,7 +359,7 @@
 	unsigned long		flags;
 	int			retval;
 
-	ep = container_of (_ep, struct dummy_ep, ep);
+	ep = usb_ep_to_dummy_ep (_ep);
 	if (!_ep || !ep->desc || _ep->name == ep0name)
 		return -EINVAL;
 	dum = ep_to_dummy (ep);
@@ -345,7 +370,7 @@
 	nuke (dum, ep);
 	spin_unlock_irqrestore (&dum->lock, flags);
 
-	dev_dbg (hardware, "disabled %s\n", _ep->name);
+	dev_dbg (dummy_dev(dum), "disabled %s\n", _ep->name);
 	return retval;
 }
 
@@ -355,9 +380,9 @@
 	struct dummy_ep		*ep;
 	struct dummy_request	*req;
 
-	ep = container_of (_ep, struct dummy_ep, ep);
 	if (!_ep)
 		return 0;
+	ep = usb_ep_to_dummy_ep (_ep);
 
 	req = kmalloc (sizeof *req, mem_flags);
 	if (!req)
@@ -373,11 +398,11 @@
 	struct dummy_ep		*ep;
 	struct dummy_request	*req;
 
-	ep = container_of (_ep, struct dummy_ep, ep);
+	ep = usb_ep_to_dummy_ep (_ep);
 	if (!ep || !_req || (!ep->desc && _ep->name != ep0name))
 		return;
 
-	req = container_of (_req, struct dummy_request, req);
+	req = usb_request_to_dummy_request (_req);
 	WARN_ON (!list_empty (&req->queue));
 	kfree (req);
 }
@@ -389,9 +414,14 @@
 	dma_addr_t *dma,
 	int mem_flags
 ) {
-	char *retval;
+	char			*retval;
+	struct dummy_ep		*ep;
+	struct dummy		*dum;
+
+	ep = usb_ep_to_dummy_ep (_ep);
+	dum = ep_to_dummy (ep);
 
-	if (!the_controller->driver)
+	if (!dum->driver)
 		return 0;
 	retval = kmalloc (bytes, mem_flags);
 	*dma = (dma_addr_t) retval;
@@ -412,9 +442,6 @@
 static void
 fifo_complete (struct usb_ep *ep, struct usb_request *req)
 {
-#if 0
-	dev_dbg (hardware, "fifo_complete: %d\n", req->status);
-#endif
 }
 
 static int
@@ -425,21 +452,20 @@
 	struct dummy		*dum;
 	unsigned long		flags;
 
-	req = container_of (_req, struct dummy_request, req);
+	req = usb_request_to_dummy_request (_req);
 	if (!_req || !list_empty (&req->queue) || !_req->complete)
 		return -EINVAL;
 
-	ep = container_of (_ep, struct dummy_ep, ep);
+	ep = usb_ep_to_dummy_ep (_ep);
 	if (!_ep || (!ep->desc && _ep->name != ep0name))
 		return -EINVAL;
 
-	if (!the_controller->driver || !is_enabled ())
+	dum = ep_to_dummy (ep);
+	if (!dum->driver || !is_enabled (dum))
 		return -ESHUTDOWN;
 
-	dum = container_of (ep->gadget, struct dummy, gadget);
-
 #if 0
-	dev_dbg (hardware, "ep %p queue req %p to %s, len %d buf %p\n",
+	dev_dbg (dummy_dev(dum), "ep %p queue req %p to %s, len %d buf %p\n",
 			ep, _req, _ep->name, _req->length, _req->buf);
 #endif
 
@@ -482,13 +508,13 @@
 	unsigned long		flags;
 	struct dummy_request	*req = 0;
 
-	if (!the_controller->driver)
-		return -ESHUTDOWN;
-
 	if (!_ep || !_req)
 		return retval;
-	ep = container_of (_ep, struct dummy_ep, ep);
-	dum = container_of (ep->gadget, struct dummy, gadget);
+	ep = usb_ep_to_dummy_ep (_ep);
+	dum = ep_to_dummy (ep);
+
+	if (!dum->driver)
+		return -ESHUTDOWN;
 
 	spin_lock_irqsave (&dum->lock, flags);
 	list_for_each_entry (req, &ep->queue, queue) {
@@ -502,9 +528,9 @@
 	spin_unlock_irqrestore (&dum->lock, flags);
 
 	if (retval == 0) {
-		dev_dbg (hardware, "dequeued req %p from %s, len %d buf %p\n",
+		dev_dbg (dummy_dev(dum),
+				"dequeued req %p from %s, len %d buf %p\n",
 				req, _ep->name, _req->length, _req->buf);
-
 		_req->complete (_ep, _req);
 	}
 	return retval;
@@ -514,12 +540,14 @@
 dummy_set_halt (struct usb_ep *_ep, int value)
 {
 	struct dummy_ep		*ep;
+	struct dummy		*dum;
 
 	if (!_ep)
 		return -EINVAL;
-	if (!the_controller->driver)
+	ep = usb_ep_to_dummy_ep (_ep);
+	dum = ep_to_dummy (ep);
+	if (!dum->driver)
 		return -ESHUTDOWN;
-	ep = container_of (_ep, struct dummy_ep, ep);
 	if (!value)
 		ep->halted = 0;
 	else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) &&
@@ -563,7 +591,7 @@
 {
 	struct dummy	*dum;
 
-	dum = container_of (_gadget, struct dummy, gadget);
+	dum = gadget_to_dummy (_gadget);
 	if ((dum->devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) == 0
 			|| !(dum->port_status & (1 << USB_PORT_FEAT_SUSPEND)))
 		return -EINVAL;
@@ -578,7 +606,7 @@
 {
 	struct dummy	*dum;
 
-	dum = container_of (_gadget, struct dummy, gadget);
+	dum = gadget_to_dummy (_gadget);
 	if (value)
 		dum->devstatus |= (1 << USB_DEVICE_SELF_POWERED);
 	else
@@ -625,17 +653,11 @@
 static void
 dummy_udc_release (struct device *dev)
 {
-	struct dummy	*dum = gadget_dev_to_dummy (dev);
-
-	complete (&dum->released);
 }
 
 static void
-dummy_hc_release (struct device *dev)
+dummy_pdev_release (struct device *dev)
 {
-	struct dummy	*dum = dev_get_drvdata (dev);
-
-	complete (&dum->released);
 }
 
 static int
@@ -644,7 +666,7 @@
 	int		rc;
 
 	strcpy (dum->gadget.dev.bus_id, "udc");
-	dum->gadget.dev.parent = &dum->pdev.dev;
+	dum->gadget.dev.parent = dummy_dev(dum);
 	dum->gadget.dev.release = dummy_udc_release;
 
 	rc = device_register (&dum->gadget.dev);
@@ -657,9 +679,7 @@
 dummy_unregister_udc (struct dummy *dum)
 {
 	device_remove_file (&dum->gadget.dev, &dev_attr_function);
-	init_completion (&dum->released);
 	device_unregister (&dum->gadget.dev);
-	wait_for_completion (&dum->released);
 }
 
 int
@@ -711,7 +731,8 @@
 
 	dum->driver = driver;
 	dum->gadget.dev.driver = &driver->driver;
-	dev_dbg (hardware, "binding gadget driver '%s'\n", driver->driver.name);
+	dev_dbg (dummy_dev(dum), "binding gadget driver '%s'\n",
+			driver->driver.name);
 	if ((retval = driver->bind (&dum->gadget)) != 0) {
 		dum->driver = 0;
 		dum->gadget.dev.driver = 0;
@@ -719,7 +740,7 @@
 	}
 
 	// FIXME: Check these calls for errors and re-order
-	driver->driver.bus = dum->pdev.dev.bus;
+	driver->driver.bus = dum->gadget.dev.parent->bus;
 	driver_register (&driver->driver);
 
 	device_bind_driver (&dum->gadget.dev);
@@ -765,12 +786,13 @@
 	if (!driver || driver != dum->driver)
 		return -EINVAL;
 
-	dev_dbg (hardware, "unregister gadget driver '%s'\n",
+	dev_dbg (dummy_dev(dum), "unregister gadget driver '%s'\n",
 			driver->driver.name);
 
 	spin_lock_irqsave (&dum->lock, flags);
 	stop_activity (dum, driver);
-	dum->port_status &= ~USB_PORT_STAT_CONNECTION;
+	dum->port_status &= ~(USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE |
+			USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED);
 	dum->port_status |= (1 << USB_PORT_FEAT_C_CONNECTION);
 	spin_unlock_irqrestore (&dum->lock, flags);
 
@@ -815,17 +837,17 @@
 	struct dummy	*dum;
 	unsigned long	flags;
 
-	/* patch to usb_sg_init() is in 2.5.60 */
-	BUG_ON (!urb->transfer_buffer && urb->transfer_buffer_length);
+	if (!urb->transfer_buffer && urb->transfer_buffer_length)
+		return -EINVAL;
 
-	dum = container_of (hcd, struct dummy, hcd);
+	dum = hcd_to_dummy (hcd);
 	spin_lock_irqsave (&dum->lock, flags);
 
 	if (!dum->udev) {
 		dum->udev = urb->dev;
 		usb_get_dev (dum->udev);
 	} else if (unlikely (dum->udev != urb->dev))
-		dev_err (hardware, "usb_device address has changed!\n");
+		dev_err (dummy_dev(dum), "usb_device address has changed!\n");
 
 	urb->hcpriv = dum;
 	if (usb_pipetype (urb->pipe) == PIPE_CONTROL)
@@ -1051,7 +1073,7 @@
 		total = 512/*bytes*/ * 13/*packets*/ * 8/*uframes*/;
 		break;
 	default:
-		dev_err (hardware, "bogus device speed\n");
+		dev_err (dummy_dev(dum), "bogus device speed\n");
 		return;
 	}
 
@@ -1061,7 +1083,8 @@
 	spin_lock_irqsave (&dum->lock, flags);
 
 	if (!dum->udev) {
-		dev_err (hardware, "timer fired with no URBs pending?\n");
+		dev_err (dummy_dev(dum),
+				"timer fired with no URBs pending?\n");
 		spin_unlock_irqrestore (&dum->lock, flags);
 		return;
 	}
@@ -1102,10 +1125,10 @@
 		ep = find_endpoint(dum, address);
 		if (!ep) {
 			/* set_configuration() disagreement */
-			dev_err (hardware,
+			dev_dbg (dummy_dev(dum),
 				"no ep configured for urb %p\n",
 				urb);
-			maybe_set_status (urb, -ETIMEDOUT);
+			maybe_set_status (urb, -EPROTO);
 			goto return_urb;
 		}
 
@@ -1118,7 +1141,7 @@
 		}
 		if (ep->halted && !ep->setup_stage) {
 			/* NOTE: must not be iso! */
-			dev_dbg (hardware, "ep %s halted, urb %p\n",
+			dev_dbg (dummy_dev(dum), "ep %s halted, urb %p\n",
 					ep->ep.name, urb);
 			maybe_set_status (urb, -EPIPE);
 			goto return_urb;
@@ -1144,7 +1167,8 @@
 			list_for_each_entry (req, &ep->queue, queue) {
 				list_del_init (&req->queue);
 				req->req.status = -EOVERFLOW;
-				dev_dbg (hardware, "stale req = %p\n", req);
+				dev_dbg (dummy_dev(dum), "stale req = %p\n",
+						req);
 
 				spin_unlock (&dum->lock);
 				req->req.complete (&ep->ep, &req->req);
@@ -1166,7 +1190,7 @@
 					break;
 				dum->address = setup.wValue;
 				maybe_set_status (urb, 0);
-				dev_dbg (hardware, "set_address = %d\n",
+				dev_dbg (dummy_dev(dum), "set_address = %d\n",
 						setup.wValue);
 				value = 0;
 				break;
@@ -1282,7 +1306,7 @@
 
 			if (value < 0) {
 				if (value != -EOPNOTSUPP)
-					dev_dbg (hardware,
+					dev_dbg (dummy_dev(dum),
 						"setup --> %d\n",
 						value);
 				maybe_set_status (urb, -EPIPE);
@@ -1362,14 +1386,14 @@
 	unsigned long		flags;
 	int			retval;
 
-	dum = container_of (hcd, struct dummy, hcd);
+	dum = hcd_to_dummy (hcd);
 
 	spin_lock_irqsave (&dum->lock, flags);
 	if (!(dum->port_status & PORT_C_MASK))
 		retval = 0;
 	else {
 		*buf = (1 << 1);
-		dev_dbg (hardware, "port status 0x%08x has changes\n",
+		dev_dbg (dummy_dev(dum), "port status 0x%08x has changes\n",
 			dum->port_status);
 		retval = 1;
 	}
@@ -1401,7 +1425,7 @@
 	int		retval = 0;
 	unsigned long	flags;
 
-	dum = container_of (hcd, struct dummy, hcd);
+	dum = hcd_to_dummy (hcd);
 	spin_lock_irqsave (&dum->lock, flags);
 	switch (typeReq) {
 	case ClearHubFeature:
@@ -1409,9 +1433,12 @@
 	case ClearPortFeature:
 		switch (wValue) {
 		case USB_PORT_FEAT_SUSPEND:
-			/* 20msec resume signaling */
-			dum->resuming = 1;
-			dum->re_timeout = jiffies + ((HZ * 20)/1000);
+			if (dum->port_status & (1 << USB_PORT_FEAT_SUSPEND)) {
+				/* 20msec resume signaling */
+				dum->resuming = 1;
+				dum->re_timeout = jiffies +
+							msecs_to_jiffies(20);
+			}
 			break;
 		case USB_PORT_FEAT_POWER:
 			dum->port_status = 0;
@@ -1440,7 +1467,7 @@
 			dum->port_status &= ~(1 << USB_PORT_FEAT_SUSPEND);
 			dum->resuming = 0;
 			dum->re_timeout = 0;
-			if (dum->driver->resume) {
+			if (dum->driver && dum->driver->resume) {
 				spin_unlock (&dum->lock);
 				dum->driver->resume (&dum->gadget);
 				spin_lock (&dum->lock);
@@ -1481,11 +1508,15 @@
 	case SetPortFeature:
 		switch (wValue) {
 		case USB_PORT_FEAT_SUSPEND:
-			dum->port_status |= (1 << USB_PORT_FEAT_SUSPEND);
-			if (dum->driver->suspend) {
-				spin_unlock (&dum->lock);
-				dum->driver->suspend (&dum->gadget);
-				spin_lock (&dum->lock);
+			if ((dum->port_status & (1 << USB_PORT_FEAT_SUSPEND))
+					== 0) {
+				dum->port_status |=
+						(1 << USB_PORT_FEAT_SUSPEND);
+				if (dum->driver && dum->driver->suspend) {
+					spin_unlock (&dum->lock);
+					dum->driver->suspend (&dum->gadget);
+					spin_lock (&dum->lock);
+				}
 			}
 			break;
 		case USB_PORT_FEAT_RESET:
@@ -1495,14 +1526,15 @@
 						| USB_PORT_STAT_LOW_SPEED
 						| USB_PORT_STAT_HIGH_SPEED);
 				if (dum->driver) {
-					dev_dbg (hardware, "disconnect\n");
+					dev_dbg (dummy_dev(dum),
+							"disconnect\n");
 					stop_activity (dum, dum->driver);
 				}
 
 				/* FIXME test that code path! */
 			}
 			/* 50msec reset signaling */
-			dum->re_timeout = jiffies + ((HZ * 50)/1000);
+			dum->re_timeout = jiffies + msecs_to_jiffies(50);
 			/* FALLTHROUGH */
 		default:
 			dum->port_status |= (1 << wValue);
@@ -1510,7 +1542,7 @@
 		break;
 
 	default:
-		dev_dbg (hardware,
+		dev_dbg (dummy_dev(dum),
 			"hub control req%04x v%04x i%04x l%d\n",
 			typeReq, wValue, wIndex, wLength);
 
@@ -1530,20 +1562,12 @@
 
 	dum = kmalloc (sizeof *dum, SLAB_KERNEL);
 	if (dum == NULL)
-		return 0;
+		return NULL;
+	the_controller = dum;
 	memset (dum, 0, sizeof *dum);
 	return &dum->hcd;
 }
 
-static void dummy_free (struct usb_hcd *hcd)
-{
-	struct dummy		*dum;
-
-	dum = container_of (hcd, struct dummy, hcd);
-	WARN_ON (dum->driver != 0);
-	kfree (dum);
-}
-
 /*-------------------------------------------------------------------------*/
 
 static inline ssize_t
@@ -1575,7 +1599,8 @@
 static ssize_t
 show_urbs (struct device *dev, char *buf)
 {
-	struct dummy		*dum = dev_get_drvdata(dev);
+	struct usb_hcd		*hcd = dev_get_drvdata (dev);
+	struct dummy		*dum = hcd_to_dummy (hcd);
 	struct urb		*urb;
 	size_t			size = 0;
 	unsigned long		flags;
@@ -1598,17 +1623,13 @@
 }
 static DEVICE_ATTR (urbs, S_IRUGO, show_urbs, NULL);
 
-
-static const struct hc_driver dummy_hcd;
-
 static int dummy_start (struct usb_hcd *hcd)
 {
 	struct dummy		*dum;
-	struct usb_bus		*bus;
 	struct usb_device	*root;
 	int			retval;
 
-	dum = container_of (hcd, struct dummy, hcd);
+	dum = hcd_to_dummy (hcd);
 
 	/*
 	 * MASTER side init ... we emulate a root hub that'll only ever
@@ -1617,121 +1638,56 @@
 	 */
 	spin_lock_init (&dum->lock);
 
-	retval = driver_register (&dummy_driver);
-	if (retval < 0)
-		return retval;
-
-	dum->pdev.name = "hc";
-	dum->pdev.dev.driver = &dummy_driver;
-	dev_set_drvdata(&dum->pdev.dev, dum);
-	dum->pdev.dev.release = dummy_hc_release;
-	retval = platform_device_register (&dum->pdev);
-	if (retval < 0) {
-		driver_unregister (&dummy_driver);
-		return retval;
-	}
-	dev_info (&dum->pdev.dev, "%s, driver " DRIVER_VERSION "\n",
-			driver_desc);
-
-	hcd->self.controller = &dum->pdev.dev;
-
-	/* FIXME 'urbs' should be a per-device thing, maybe in usbcore */
-	device_create_file (hcd->self.controller, &dev_attr_urbs);
-
 	init_timer (&dum->timer);
 	dum->timer.function = dummy_timer;
 	dum->timer.data = (unsigned long) dum;
 
-	/* root hub will appear as another device */
-	dum->hcd.driver = (struct hc_driver *) &dummy_hcd;
-	dum->hcd.description = dummy_hcd.description;
-	dum->hcd.product_desc = "Dummy host controller";
-
-	bus = hcd_to_bus (&dum->hcd);
-	bus->bus_name = dum->pdev.dev.bus_id;
-	usb_bus_init (bus);
-	bus->op = &usb_hcd_operations;
-	bus->hcpriv = &dum->hcd;
-
-	/* FIXME don't require the pci-based buffer/alloc impls;
-	 * the "generic dma" implementation still requires them,
-	 * it's not very generic yet.
-	 */
-	if ((retval = hcd_buffer_create (&dum->hcd)) != 0) {
-clean0:
-		init_completion (&dum->released);
-		platform_device_unregister (&dum->pdev);
-		wait_for_completion (&dum->released);
-		driver_unregister (&dummy_driver);
-		return retval;
-	}
-
-	INIT_LIST_HEAD (&hcd->dev_list);
-	usb_register_bus (bus);
-
-	root = usb_alloc_dev (0, bus, 0);
-	if (!root) {
-		retval = -ENOMEM;
-clean1:
-		hcd_buffer_destroy (&dum->hcd);
-		usb_deregister_bus (bus);
-		goto clean0;
-	}
+	root = usb_alloc_dev (0, &hcd->self, 0);
+	if (!root)
+		return -ENOMEM;
 
 	/* root hub enters addressed state... */
-	dum->hcd.state = USB_STATE_RUNNING;
+	hcd->state = USB_STATE_RUNNING;
 	root->speed = USB_SPEED_HIGH;
 
 	/* ...then configured, so khubd sees us. */
-	if ((retval = hcd_register_root (root, &dum->hcd)) != 0) {
+	if ((retval = hcd_register_root (root, hcd)) != 0) {
 		usb_put_dev (root);
-clean2:
-		dum->hcd.state = USB_STATE_QUIESCING;
-		goto clean1;
+clean:
+		hcd->state = USB_STATE_QUIESCING;
+		return retval;
 	}
 
 	/* only show a low-power port: just 8mA */
 	hub_set_power_budget (root, 8);
 
-	dum->started = 1;
-
 	if ((retval = dummy_register_udc (dum)) != 0) {
-		dum->started = 0;
-		usb_disconnect (&bus->root_hub);
-		goto clean2;
+		usb_disconnect (&hcd->self.root_hub);
+		goto clean;
 	}
+
+	/* FIXME 'urbs' should be a per-device thing, maybe in usbcore */
+	device_create_file (dummy_dev(dum), &dev_attr_urbs);
+
+	dum->started = 1;
 	return 0;
 }
 
 static void dummy_stop (struct usb_hcd *hcd)
 {
 	struct dummy		*dum;
-	struct usb_bus		*bus;
 
-	dum = container_of (hcd, struct dummy, hcd);
+	dum = hcd_to_dummy (hcd);
 	if (!dum->started)
 		return;
 	dum->started = 0;
 
+	device_remove_file (dummy_dev(dum), &dev_attr_urbs);
+
 	usb_gadget_unregister_driver (dum->driver);
 	dummy_unregister_udc (dum);
 
-	bus = hcd_to_bus (&dum->hcd);
-	hcd->state = USB_STATE_QUIESCING;
-	dev_dbg (hardware, "remove root hub\n");
-	usb_disconnect (&bus->root_hub);
-
-	hcd_buffer_destroy (&dum->hcd);
-	usb_deregister_bus (bus);
-
-	dev_info (hardware, "stopped\n");
-
-	device_remove_file (hcd->self.controller, &dev_attr_urbs);
-	init_completion (&dum->released);
-	platform_device_unregister (&dum->pdev);
-	wait_for_completion (&dum->released);
-
-	driver_unregister (&dummy_driver);
+	dev_info (dummy_dev(dum), "stopped\n");
 }
 
 /*-------------------------------------------------------------------------*/
@@ -1749,7 +1705,6 @@
 	.stop =			dummy_stop,
 
 	.hcd_alloc = 		dummy_alloc,
-	.hcd_free = 		dummy_free,
 
 	.urb_enqueue = 		dummy_urb_enqueue,
 	.urb_dequeue = 		dummy_urb_dequeue,
@@ -1760,34 +1715,128 @@
 	.hub_control = 		dummy_hub_control,
 };
 
-/*-------------------------------------------------------------------------*/
+static void dummy_remove (struct device *dev);
 
-static int __init init (void)
+static int dummy_probe (struct device *dev)
 {
 	struct usb_hcd		*hcd;
-	int			value;
+	struct dummy		*dum;
+	int			retval;
 
-	if (usb_disabled ())
-		return -ENODEV;
-	if ((hcd = dummy_alloc ()) == 0)
+	dev_info (dev, "%s, driver " DRIVER_VERSION "\n", driver_desc);
+
+	hcd = dummy_alloc ();
+	if (hcd == NULL) {
+		dev_dbg (dev, "hcd_alloc failed\n");
 		return -ENOMEM;
+	}
+
+	dev_set_drvdata (dev, hcd);
+	dum = hcd_to_dummy (hcd);
 
-	the_controller = container_of (hcd, struct dummy, hcd);
-	value = dummy_start (hcd);
+	hcd->driver = (struct hc_driver *) &dummy_hcd;
+	hcd->description = dummy_hcd.description;
+	hcd->self.controller = dev;
 
-	if (value != 0) {
-		dummy_free (hcd);
-		the_controller = 0;
+	/* FIXME don't require the pci-based buffer/alloc impls;
+	 * the "generic dma" implementation still requires them,
+	 * it's not very generic yet.
+	 */
+	retval = hcd_buffer_create (hcd);
+	if (retval != 0) {
+		dev_dbg (dev, "pool alloc failed\n");
+		goto err1;
 	}
-	return value;
+
+	usb_bus_init (&hcd->self);
+	hcd->self.op = &usb_hcd_operations;
+	hcd->self.release = &usb_hcd_release;
+	hcd->self.hcpriv = hcd;
+	hcd->self.bus_name = dev->bus_id;
+	hcd->product_desc = "Dummy host controller";
+
+	INIT_LIST_HEAD (&hcd->dev_list);
+
+	usb_register_bus (&hcd->self);
+
+	if ((retval = dummy_start (hcd)) < 0) 
+		dummy_remove (dev);
+	return retval;
+
+err1:
+	kfree (hcd);
+	dev_set_drvdata (dev, NULL);
+	return retval;
+}
+
+static void dummy_remove (struct device *dev)
+{
+	struct usb_hcd		*hcd;
+	struct dummy		*dum;
+
+	hcd = dev_get_drvdata (dev);
+	dum = hcd_to_dummy (hcd);
+
+	hcd->state = USB_STATE_QUIESCING;
+
+	dev_dbg (dev, "roothub graceful disconnect\n");
+	usb_disconnect (&hcd->self.root_hub);
+
+	hcd->driver->stop (hcd);
+	hcd->state = USB_STATE_HALT;
+
+	hcd_buffer_destroy (hcd);
+
+	dev_set_drvdata (dev, NULL);
+	usb_deregister_bus (&hcd->self);
+	the_controller = NULL;
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int dummy_pdev_detect (void)
+{
+	int			retval;
+
+	retval = driver_register (&dummy_driver);
+	if (retval < 0)
+		return retval;
+
+	the_pdev.name = "hc";
+	the_pdev.dev.driver = &dummy_driver;
+	the_pdev.dev.release = dummy_pdev_release;
+
+	retval = platform_device_register (&the_pdev);
+	if (retval < 0)
+		driver_unregister (&dummy_driver);
+	return retval;
+}
+
+static void dummy_pdev_remove (void)
+{
+	platform_device_unregister (&the_pdev);
+	driver_unregister (&dummy_driver);
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int __init init (void)
+{
+	int	retval;
+
+	if (usb_disabled ())
+		return -ENODEV;
+	if ((retval = dummy_pdev_detect ()) != 0)
+		return retval;
+	if ((retval = dummy_probe (&the_pdev.dev)) != 0)
+		dummy_pdev_remove ();
+	return retval;
 }
 module_init (init);
 
 static void __exit cleanup (void)
 {
-	dummy_stop (&the_controller->hcd);
-	dummy_free (&the_controller->hcd);
-	the_controller = 0;
+	dummy_remove (&the_pdev.dev);
+	dummy_pdev_remove ();
 }
 module_exit (cleanup);
-
diff -Nru a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
--- a/drivers/usb/gadget/ether.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/gadget/ether.c	2004-12-24 13:37:29 -08:00
@@ -84,7 +84,7 @@
  */
 
 #define DRIVER_DESC		"Ethernet Gadget"
-#define DRIVER_VERSION		"St Patrick's Day 2004"
+#define DRIVER_VERSION		"Equinox 2004"
 
 static const char shortname [] = "ether";
 static const char driver_desc [] = DRIVER_DESC;
@@ -223,6 +223,10 @@
 #define	DEV_CONFIG_CDC
 #endif
 
+#ifdef CONFIG_USB_GADGET_LH7A40X
+#define DEV_CONFIG_CDC
+#endif
+
 #ifdef CONFIG_USB_GADGET_MQ11XX
 #define	DEV_CONFIG_CDC
 #endif
@@ -231,6 +235,14 @@
 #define	DEV_CONFIG_CDC
 #endif
 
+#ifdef CONFIG_USB_GADGET_N9604
+#define	DEV_CONFIG_CDC
+#endif
+
+#ifdef CONFIG_USB_GADGET_PXA27X
+#define DEV_CONFIG_CDC
+#endif
+
 
 /* For CDC-incapable hardware, choose the simple cdc subset.
  * Anything that talks bulk (without notable bugs) can do this.
@@ -243,10 +255,6 @@
 #define	DEV_CONFIG_SUBSET
 #endif
 
-#ifdef CONFIG_USB_GADGET_LH7A40X
-#define DEV_CONFIG_CDC
-#endif
-
 #ifdef CONFIG_USB_GADGET_SA1100
 /* use non-CDC for backwards compatibility */
 #define	DEV_CONFIG_SUBSET
@@ -387,7 +395,7 @@
 	.bConfigurationValue =	DEV_CONFIG_VALUE,
 	.iConfiguration =	STRING_CDC,
 	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-	.bMaxPower =		1,
+	.bMaxPower =		50,
 };
 
 #ifdef	CONFIG_USB_ETH_RNDIS
@@ -401,7 +409,7 @@
 	.bConfigurationValue =  DEV_RNDIS_CONFIG_VALUE,
 	.iConfiguration =       STRING_RNDIS,
 	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-	.bMaxPower =            1,
+	.bMaxPower =            50,
 };
 #endif
 
@@ -852,7 +860,7 @@
 
 /* descriptors that are built on-demand */
 
-static char				manufacturer [40];
+static char				manufacturer [50];
 static char				product_desc [40] = DRIVER_DESC;
 
 #ifdef	DEV_CONFIG_CDC
@@ -1198,13 +1206,20 @@
 		result = -EINVAL;
 		/* FALL THROUGH */
 	case 0:
-		return result;
+		break;
 	}
 
-	if (result)
-		eth_reset_config (dev);
-	else {
+	if (result) {
+		if (number)
+			eth_reset_config (dev);
+		usb_gadget_vbus_draw(dev->gadget,
+				dev->gadget->is_otg ? 8 : 100);
+	} else {
 		char *speed;
+		unsigned power;
+
+		power = 2 * eth_config.bMaxPower;
+		usb_gadget_vbus_draw(dev->gadget, power);
 
 		switch (gadget->speed) {
 		case USB_SPEED_FULL:	speed = "full"; break;
@@ -1215,8 +1230,8 @@
 		}
 
 		dev->config = number;
-		INFO (dev, "%s speed config #%d: %s, using %s\n",
-				speed, number, driver_desc,
+		INFO (dev, "%s speed config #%d: %d mA, %s, using %s\n",
+				speed, number, power, driver_desc,
 				dev->rndis
 					? "RNDIS"
 					: (dev->cdc
@@ -1375,8 +1390,9 @@
 static void rndis_response_complete (struct usb_ep *ep, struct usb_request *req)
 {
 	if (req->status || req->actual != req->length)
-		DEBUG (dev, "rndis response complete --> %d, %d/%d\n",
-		       req->status, req->actual, req->length);
+		DEBUG ((struct eth_dev *) ep->driver_data,
+			"rndis response complete --> %d, %d/%d\n",
+			req->status, req->actual, req->length);
 
 	/* done sending after CDC_GET_ENCAPSULATED_RESPONSE */
 }
@@ -1670,7 +1686,7 @@
 
 static int eth_change_mtu (struct net_device *net, int new_mtu)
 {
-	struct eth_dev	*dev = (struct eth_dev *) net->priv;
+	struct eth_dev	*dev = netdev_priv(net);
 
 	// FIXME if rndis, don't change while link's live
 
@@ -1685,58 +1701,29 @@
 
 static struct net_device_stats *eth_get_stats (struct net_device *net)
 {
-	return &((struct eth_dev *) net->priv)->stats;
+	return &((struct eth_dev *)netdev_priv(net))->stats;
 }
 
-static int eth_ethtool_ioctl (struct net_device *net, void __user *useraddr)
+static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p)
 {
-	struct eth_dev	*dev = (struct eth_dev *) net->priv;
-	u32		cmd;
-
-	if (get_user (cmd, (u32 __user *)useraddr))
-		return -EFAULT;
-	switch (cmd) {
-
-	case ETHTOOL_GDRVINFO: {	/* get driver info */
-		struct ethtool_drvinfo		info;
-
-		memset (&info, 0, sizeof info);
-		info.cmd = ETHTOOL_GDRVINFO;
-		strlcpy (info.driver, shortname, sizeof info.driver);
-		strlcpy (info.version, DRIVER_VERSION, sizeof info.version);
-		strlcpy (info.fw_version, dev->gadget->name,
-			sizeof info.fw_version);
-		strlcpy (info.bus_info, dev->gadget->dev.bus_id,
-			sizeof info.bus_info);
-		if (copy_to_user (useraddr, &info, sizeof (info)))
-			return -EFAULT;
-		return 0;
-		}
-
-	case ETHTOOL_GLINK: {		/* get link status */
-		struct ethtool_value	edata = { ETHTOOL_GLINK };
-
-		edata.data = (dev->gadget->speed != USB_SPEED_UNKNOWN);
-		if (copy_to_user (useraddr, &edata, sizeof (edata)))
-			return -EFAULT;
-		return 0;
-		}
-
-	}
-	/* Note that the ethtool user space code requires EOPNOTSUPP */
-	return -EOPNOTSUPP;
+	struct eth_dev	*dev = netdev_priv(net);
+	strlcpy(p->driver, shortname, sizeof p->driver);
+	strlcpy(p->version, DRIVER_VERSION, sizeof p->version);
+	strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version);
+	strlcpy (p->bus_info, dev->gadget->dev.bus_id, sizeof p->bus_info);
 }
 
-static int eth_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
+static u32 eth_get_link(struct net_device *net)
 {
-	switch (cmd) {
-	case SIOCETHTOOL:
-		return eth_ethtool_ioctl(net, rq->ifr_data);
-	default:
-		return -EOPNOTSUPP;
-	}
+	struct eth_dev	*dev = netdev_priv(net);
+	return dev->gadget->speed != USB_SPEED_UNKNOWN;
 }
 
+static struct ethtool_ops ops = {
+	.get_drvinfo = eth_get_drvinfo,
+	.get_link = eth_get_link
+};
+
 static void defer_kevent (struct eth_dev *dev, int flag)
 {
 	if (test_and_set_bit (flag, &dev->todo))
@@ -1997,7 +1984,7 @@
 
 static int eth_start_xmit (struct sk_buff *skb, struct net_device *net)
 {
-	struct eth_dev		*dev = (struct eth_dev *) net->priv;
+	struct eth_dev		*dev = netdev_priv(net);
 	int			length = skb->len;
 	int			retval;
 	struct usb_request	*req = NULL;
@@ -2098,11 +2085,13 @@
 	}
 }
 
-static void rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req)
+static void
+rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req)
 {
 	if (req->status || req->actual != req->length)
-		DEBUG (dev, "rndis control ack complete --> %d, %d/%d\n",
-		       req->status, req->actual, req->length);
+		DEBUG ((struct eth_dev *) ep->driver_data,
+			"rndis control ack complete --> %d, %d/%d\n",
+			req->status, req->actual, req->length);
 
 	usb_ep_free_buffer(ep, req->buf, req->dma, 8);
 	usb_ep_free_request(ep, req);
@@ -2110,7 +2099,7 @@
 
 static int rndis_control_ack (struct net_device *net)
 {
-	struct eth_dev          *dev = (struct eth_dev *) net->priv;
+	struct eth_dev          *dev = netdev_priv(net);
 	u32                     length;
 	struct usb_request      *resp;
 	
@@ -2177,7 +2166,7 @@
 
 static int eth_open (struct net_device *net)
 {
-	struct eth_dev		*dev = (struct eth_dev *) net->priv;
+	struct eth_dev		*dev = netdev_priv(net);
 
 	DEBUG (dev, "%s\n", __FUNCTION__);
 	if (netif_carrier_ok (dev->net))
@@ -2187,7 +2176,7 @@
 
 static int eth_stop (struct net_device *net)
 {
-	struct eth_dev		*dev = (struct eth_dev *) net->priv;
+	struct eth_dev		*dev = netdev_priv(net);
 
 	VDEBUG (dev, "%s\n", __FUNCTION__);
 	netif_stop_queue (net);
@@ -2198,7 +2187,7 @@
 		);
 
 	/* ensure there are no more active requests */
-	if (dev->gadget->speed != USB_SPEED_UNKNOWN) {
+	if (dev->config) {
 		usb_ep_disable (dev->in_ep);
 		usb_ep_disable (dev->out_ep);
 		if (netif_carrier_ok (dev->net)) {
@@ -2334,6 +2323,10 @@
 		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0208);
 	} else if (gadget_is_lh7a40x(gadget)) {
 		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0209);
+	} else if (gadget_is_n9604(gadget)) {
+		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210);
+	} else if (gadget_is_pxa27x(gadget)) {
+		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211);
 	} else {
 		/* can't assume CDC works.  don't want to default to
 		 * anything less functional on CDC-capable hardware,
@@ -2466,15 +2459,17 @@
 	if (gadget->is_otg) {
 		otg_descriptor.bmAttributes |= USB_OTG_HNP,
 		eth_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+		eth_config.bMaxPower = 4;
 #ifdef	CONFIG_USB_ETH_RNDIS
 		rndis_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+		rndis_config.bMaxPower = 4;
 #endif
 	}
 
  	net = alloc_etherdev (sizeof *dev);
  	if (!net)
 		return status;
-	dev = net->priv;
+	dev = netdev_priv(net);
 	spin_lock_init (&dev->lock);
 	INIT_WORK (&dev->work, eth_work, dev);
 	INIT_LIST_HEAD (&dev->tx_reqs);
@@ -2518,7 +2513,7 @@
 	net->stop = eth_stop;
 	// watchdog_timeo, tx_timeout ...
 	// set_multicast_list
-	net->do_ioctl = eth_ioctl;
+	SET_ETHTOOL_OPS(net, &ops);
 
 	/* preallocate control response and buffer */
 	dev->req = usb_ep_alloc_request (gadget->ep0, GFP_KERNEL);
diff -Nru a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
--- a/drivers/usb/gadget/file_storage.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/gadget/file_storage.c	2004-12-24 13:37:29 -08:00
@@ -217,6 +217,7 @@
 #include <linux/compiler.h>
 #include <linux/completion.h>
 #include <linux/dcache.h>
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/fcntl.h>
 #include <linux/file.h>
@@ -234,6 +235,7 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
+#include <linux/suspend.h>
 #include <linux/uts.h>
 #include <linux/version.h>
 #include <linux/wait.h>
@@ -248,7 +250,7 @@
 
 #define DRIVER_DESC		"File-backed Storage Gadget"
 #define DRIVER_NAME		"g_file_storage"
-#define DRIVER_VERSION		"28 July 2004"
+#define DRIVER_VERSION		"20 October 2004"
 
 static const char longname[] = DRIVER_DESC;
 static const char shortname[] = DRIVER_NAME;
@@ -367,10 +369,10 @@
 	};
 
 
-module_param_array(file, charp, mod_data.num_filenames, S_IRUGO);
+module_param_array(file, charp, &mod_data.num_filenames, S_IRUGO);
 MODULE_PARM_DESC(file, "names of backing files or devices");
 
-module_param_array(ro, bool, mod_data.num_ros, S_IRUGO);
+module_param_array(ro, bool, &mod_data.num_ros, S_IRUGO);
 MODULE_PARM_DESC(ro, "true to force read-only");
 
 module_param_named(luns, mod_data.nluns, uint, S_IRUGO);
@@ -428,9 +430,9 @@
 
 /* Command Block Wrapper */
 struct bulk_cb_wrap {
-	u32	Signature;		// Contains 'USBC'
+	__le32	Signature;		// Contains 'USBC'
 	u32	Tag;			// Unique per command id
-	u32	DataTransferLength;	// Size of the data
+	__le32	DataTransferLength;	// Size of the data
 	u8	Flags;			// Direction in bit 7
 	u8	Lun;			// LUN (normally 0)
 	u8	Length;			// Of the CDB, <= MAX_COMMAND_SIZE
@@ -443,9 +445,9 @@
 
 /* Command Status Wrapper */
 struct bulk_cs_wrap {
-	u32	Signature;		// Should = 'USBS'
+	__le32	Signature;		// Should = 'USBS'
 	u32	Tag;			// Same as original command
-	u32	Residue;		// Amount not transferred
+	__le32	Residue;		// Amount not transferred
 	u8	Status;			// See below
 };
 
@@ -866,6 +868,14 @@
 	.bMaxPower =		1,	// self-powered
 };
 
+static struct usb_otg_descriptor
+otg_desc = {
+	.bLength =		sizeof(otg_desc),
+	.bDescriptorType =	USB_DT_OTG,
+
+	.bmAttributes =		USB_OTG_SRP,
+};
+
 /* There is only one interface. */
 
 static struct usb_interface_descriptor
@@ -914,12 +924,14 @@
 };
 
 static const struct usb_descriptor_header *fs_function[] = {
+	(struct usb_descriptor_header *) &otg_desc,
 	(struct usb_descriptor_header *) &intf_desc,
 	(struct usb_descriptor_header *) &fs_bulk_in_desc,
 	(struct usb_descriptor_header *) &fs_bulk_out_desc,
 	(struct usb_descriptor_header *) &fs_intr_in_desc,
 	NULL,
 };
+#define FS_FUNCTION_PRE_EP_ENTRIES	2
 
 
 #ifdef	CONFIG_USB_GADGET_DUALSPEED
@@ -976,12 +988,14 @@
 };
 
 static const struct usb_descriptor_header *hs_function[] = {
+	(struct usb_descriptor_header *) &otg_desc,
 	(struct usb_descriptor_header *) &intf_desc,
 	(struct usb_descriptor_header *) &hs_bulk_in_desc,
 	(struct usb_descriptor_header *) &hs_bulk_out_desc,
 	(struct usb_descriptor_header *) &hs_intr_in_desc,
 	NULL,
 };
+#define HS_FUNCTION_PRE_EP_ENTRIES	2
 
 /* Maxpacket and other transfer characteristics vary by speed. */
 #define ep_desc(g,fs,hs)	(((g)->speed==USB_SPEED_HIGH) ? (hs) : (fs))
@@ -996,7 +1010,7 @@
 
 /* The CBI specification limits the serial string to 12 uppercase hexadecimal
  * characters. */
-static char				manufacturer[40];
+static char				manufacturer[50];
 static char				serial[13];
 
 /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */
@@ -1018,9 +1032,12 @@
  * and with code managing interfaces and their altsettings.  They must
  * also handle different speeds and other-speed requests.
  */
-static int populate_config_buf(enum usb_device_speed speed,
+static int populate_config_buf(struct usb_gadget *gadget,
 		u8 *buf, u8 type, unsigned index)
 {
+#ifdef CONFIG_USB_GADGET_DUALSPEED
+	enum usb_device_speed			speed = gadget->speed;
+#endif
 	int					len;
 	const struct usb_descriptor_header	**function;
 
@@ -1036,6 +1053,10 @@
 #endif
 		function = fs_function;
 
+	/* for now, don't advertise srp-only devices */
+	if (!gadget->is_otg)
+		function++;
+
 	len = usb_gadget_config_buf(&config_desc, buf, EP0_BUFSIZE, function);
 	((struct usb_config_descriptor *) buf)->bDescriptorType = type;
 	return len;
@@ -1366,7 +1387,7 @@
 #ifdef CONFIG_USB_GADGET_DUALSPEED
 		get_config:
 #endif
-			value = populate_config_buf(fsg->gadget->speed,
+			value = populate_config_buf(fsg->gadget,
 					req->buf,
 					ctrl->wValue >> 8,
 					ctrl->wValue & 0xff);
@@ -1523,6 +1544,8 @@
 	rc = wait_event_interruptible(fsg->thread_wqh,
 			fsg->thread_wakeup_needed);
 	fsg->thread_wakeup_needed = 0;
+	if (current->flags & PF_FREEZE)
+		refrigerator(PF_FREEZE);
 	return (rc ? -EINTR : 0);
 }
 
@@ -2280,8 +2303,7 @@
 		}
 
 		/* Wait for a short time and then try again */
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (schedule_timeout(HZ / 10) != 0)
+		if (msleep_interruptible(100) != 0)
 			return -EINTR;
 		rc = usb_ep_set_halt(fsg->bulk_in);
 	}
@@ -3557,7 +3579,7 @@
 }
 
 
-ssize_t store_ro(struct device *dev, const char *buf, size_t count)
+static ssize_t store_ro(struct device *dev, const char *buf, size_t count)
 {
 	ssize_t		rc = count;
 	struct lun	*curlun = dev_to_lun(dev);
@@ -3581,7 +3603,7 @@
 	return rc;
 }
 
-ssize_t store_file(struct device *dev, const char *buf, size_t count)
+static ssize_t store_file(struct device *dev, const char *buf, size_t count)
 {
 	struct lun	*curlun = dev_to_lun(dev);
 	struct fsg_dev	*fsg = (struct fsg_dev *) dev_get_drvdata(dev);
@@ -3697,28 +3719,32 @@
 
 	if (mod_data.release == 0xffff) {	// Parameter wasn't set
 		if (gadget_is_net2280(fsg->gadget))
-			mod_data.release = __constant_cpu_to_le16(0x0301);
+			mod_data.release = 0x0301;
 		else if (gadget_is_dummy(fsg->gadget))
-			mod_data.release = __constant_cpu_to_le16(0x0302);
+			mod_data.release = 0x0302;
 		else if (gadget_is_pxa(fsg->gadget))
-			mod_data.release = __constant_cpu_to_le16(0x0303);
+			mod_data.release = 0x0303;
 		else if (gadget_is_sh(fsg->gadget))
-			mod_data.release = __constant_cpu_to_le16(0x0304);
+			mod_data.release = 0x0304;
 
 		/* The sa1100 controller is not supported */
 
 		else if (gadget_is_goku(fsg->gadget))
-			mod_data.release = __constant_cpu_to_le16(0x0306);
+			mod_data.release = 0x0306;
 		else if (gadget_is_mq11xx(fsg->gadget))
-			mod_data.release = __constant_cpu_to_le16(0x0307);
+			mod_data.release = 0x0307;
 		else if (gadget_is_omap(fsg->gadget))
-			mod_data.release = __constant_cpu_to_le16(0x0308);
-		else if (gadget_is_lh7a40x(gadget))
-			mod_data.release = __constant_cpu_to_le16 (0x0309);
+			mod_data.release = 0x0308;
+		else if (gadget_is_lh7a40x(fsg->gadget))
+			mod_data.release = 0x0309;
+		else if (gadget_is_n9604(fsg->gadget))
+			mod_data.release = 0x0310;
+		else if (gadget_is_pxa27x(fsg->gadget))
+			mod_data.release = 0x0311;
 		else {
 			WARN(fsg, "controller '%s' not recognized\n",
 				fsg->gadget->name);
-			mod_data.release = __constant_cpu_to_le16(0x0399);
+			mod_data.release = 0x0399;
 		}
 	}
 
@@ -3882,10 +3908,10 @@
 	intf_desc.bNumEndpoints = i;
 	intf_desc.bInterfaceSubClass = mod_data.protocol_type;
 	intf_desc.bInterfaceProtocol = mod_data.transport_type;
-	fs_function[i+1] = NULL;
+	fs_function[i + FS_FUNCTION_PRE_EP_ENTRIES] = NULL;
 
 #ifdef CONFIG_USB_GADGET_DUALSPEED
-	hs_function[i+1] = NULL;
+	hs_function[i + HS_FUNCTION_PRE_EP_ENTRIES] = NULL;
 
 	/* Assume ep0 uses the same maxpacket value for both speeds */
 	dev_qualifier.bMaxPacketSize0 = fsg->ep0->maxpacket;
@@ -3895,6 +3921,11 @@
 	hs_bulk_out_desc.bEndpointAddress = fs_bulk_out_desc.bEndpointAddress;
 	hs_intr_in_desc.bEndpointAddress = fs_intr_in_desc.bEndpointAddress;
 #endif
+
+	if (gadget->is_otg) {
+		otg_desc.bmAttributes |= USB_OTG_HNP,
+		config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+	}
 
 	rc = -ENOMEM;
 
diff -Nru a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
--- a/drivers/usb/gadget/gadget_chips.h	2004-12-24 13:36:16 -08:00
+++ b/drivers/usb/gadget/gadget_chips.h	2004-12-24 13:36:16 -08:00
@@ -62,6 +62,18 @@
 #define	gadget_is_omap(g)	0
 #endif
 
+#ifdef CONFIG_USB_GADGET_N9604
+#define	gadget_is_n9604(g)	!strcmp("n9604_udc", (g)->name)
+#else
+#define	gadget_is_n9604(g)	0
+#endif
+
+#ifdef CONFIG_USB_GADGET_PXA27X
+#define	gadget_is_pxa27x(g)	!strcmp("pxa27x_udc", (g)->name)
+#else
+#define	gadget_is_pxa27x(g)	0
+#endif
+
 // CONFIG_USB_GADGET_AT91RM9200
 // CONFIG_USB_GADGET_SX2
 // CONFIG_USB_GADGET_AU1X00
diff -Nru a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
--- a/drivers/usb/gadget/goku_udc.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/gadget/goku_udc.c	2004-12-24 13:36:18 -08:00
@@ -90,7 +90,7 @@
 static void nuke(struct goku_ep *, int status);
 
 static inline void
-command(struct goku_udc_regs *regs, int command, unsigned epnum)
+command(struct goku_udc_regs __iomem *regs, int command, unsigned epnum)
 {
 	writel(COMMAND_EP(epnum) | command, &regs->Command);
 	udelay(300);
@@ -161,8 +161,8 @@
 
 	/* ep1 and ep2 can do double buffering and/or dma */
 	if (ep->num < 3) {
-		struct goku_udc_regs	*regs = ep->dev->regs;
-		u32			tmp;
+		struct goku_udc_regs __iomem	*regs = ep->dev->regs;
+		u32				tmp;
 
 		/* double buffer except (for now) with pio in */
 		tmp = ((ep->dma || !ep->is_in)
@@ -191,7 +191,7 @@
 	return 0;
 }
 
-static void ep_reset(struct goku_udc_regs *regs, struct goku_ep *ep)
+static void ep_reset(struct goku_udc_regs __iomem *regs, struct goku_ep *ep)
 {
 	struct goku_udc		*dev = ep->dev;
 
@@ -209,16 +209,16 @@
 		writel(dev->int_enable, &regs->int_enable);
 		readl(&regs->int_enable);
 		if (ep->num < 3) {
-			struct goku_udc_regs	*regs = ep->dev->regs;
-			u32			tmp;
+			struct goku_udc_regs __iomem	*r = ep->dev->regs;
+			u32				tmp;
 
-			tmp = readl(&regs->EPxSingle);
+			tmp = readl(&r->EPxSingle);
 			tmp &= ~(0x11 << ep->num);
-			writel(tmp, &regs->EPxSingle);
+			writel(tmp, &r->EPxSingle);
 
-			tmp = readl(&regs->EPxBCS);
+			tmp = readl(&r->EPxBCS);
 			tmp &= ~(0x11 << ep->num);
-			writel(tmp, &regs->EPxBCS);
+			writel(tmp, &r->EPxBCS);
 		}
 		/* reset dma in case we're still using it */
 		if (ep->dma) {
@@ -237,7 +237,7 @@
 	}
 
 	ep->ep.maxpacket = MAX_FIFO_SIZE;
-	ep->desc = 0;
+	ep->desc = NULL;
 	ep->stopped = 1;
 	ep->irqs = 0;
 	ep->dma = 0;
@@ -274,10 +274,10 @@
 	struct goku_request	*req;
 
 	if (!_ep)
-		return 0;
+		return NULL;
 	req = kmalloc(sizeof *req, gfp_flags);
 	if (!req)
-		return 0;
+		return NULL;
 
 	memset(req, 0, sizeof *req);
 	req->req.dma = DMA_ADDR_INVALID;
@@ -334,7 +334,7 @@
 
 	ep = container_of(_ep, struct goku_ep, ep);
 	if (!_ep)
-		return 0;
+		return NULL;
 	*dma = DMA_ADDR_INVALID;
 
 #if	defined(USE_KMALLOC)
@@ -413,7 +413,7 @@
 /*-------------------------------------------------------------------------*/
 
 static inline int
-write_packet(u32 *fifo, u8 *buf, struct goku_request *req, unsigned max)
+write_packet(u32 __iomem *fifo, u8 *buf, struct goku_request *req, unsigned max)
 {
 	unsigned	length, count;
 
@@ -488,10 +488,10 @@
 
 static int read_fifo(struct goku_ep *ep, struct goku_request *req)
 {
-	struct goku_udc_regs	*regs;
-	u32			size, set;
-	u8			*buf;
-	unsigned		bufferspace, is_short, dbuff;
+	struct goku_udc_regs __iomem	*regs;
+	u32				size, set;
+	u8				*buf;
+	unsigned			bufferspace, is_short, dbuff;
 
 	regs = ep->dev->regs;
 top:
@@ -581,7 +581,8 @@
 }
 
 static inline void
-pio_irq_enable(struct goku_udc *dev, struct goku_udc_regs *regs, int epnum)
+pio_irq_enable(struct goku_udc *dev,
+		struct goku_udc_regs __iomem *regs, int epnum)
 {
 	dev->int_enable |= INT_EPxDATASET (epnum);
 	writel(dev->int_enable, &regs->int_enable);
@@ -589,7 +590,8 @@
 }
 
 static inline void
-pio_irq_disable(struct goku_udc *dev, struct goku_udc_regs *regs, int epnum)
+pio_irq_disable(struct goku_udc *dev,
+		struct goku_udc_regs __iomem *regs, int epnum)
 {
 	dev->int_enable &= ~INT_EPxDATASET (epnum);
 	writel(dev->int_enable, &regs->int_enable);
@@ -613,10 +615,10 @@
 // return:  0 = q running, 1 = q stopped, negative = errno
 static int start_dma(struct goku_ep *ep, struct goku_request *req)
 {
-	struct goku_udc_regs	*regs = ep->dev->regs;
-	u32			master;
-	u32			start = req->req.dma;
-	u32			end = start + req->req.length - 1;
+	struct goku_udc_regs __iomem	*regs = ep->dev->regs;
+	u32				master;
+	u32				start = req->req.dma;
+	u32				end = start + req->req.length - 1;
 
 	master = readl(&regs->dma_master) & MST_RW_BITS;
 
@@ -668,9 +670,9 @@
 
 static void dma_advance(struct goku_udc *dev, struct goku_ep *ep)
 {
-	struct goku_request	*req;
-	struct goku_udc_regs	*regs = ep->dev->regs;
-	u32			master;
+	struct goku_request		*req;
+	struct goku_udc_regs __iomem	*regs = ep->dev->regs;
+	u32				master;
 
 	master = readl(&regs->dma_master);
 
@@ -716,9 +718,9 @@
 
 static void abort_dma(struct goku_ep *ep, int status)
 {
-	struct goku_udc_regs	*regs = ep->dev->regs;
-	struct goku_request	*req;
-	u32			curr, master;
+	struct goku_udc_regs __iomem	*regs = ep->dev->regs;
+	struct goku_request		*req;
+	u32				curr, master;
 
 	/* NAK future host requests, hoping the implicit delay lets the
 	 * dma engine finish reading (or writing) its latest packet and
@@ -848,7 +850,7 @@
 		if (unlikely(status != 0)) {
 			if (status > 0)
 				status = 0;
-			req = 0;
+			req = NULL;
 		}
 
 	} /* else pio or dma irq handler advances the queue. */
@@ -927,7 +929,7 @@
 	} else if (!list_empty(&req->queue))
 		done(ep, req, -ECONNRESET);
 	else
-		req = 0;
+		req = NULL;
 	spin_unlock_irqrestore(&dev->lock, flags);
 
 	return req ? 0 : -EOPNOTSUPP;
@@ -984,7 +986,8 @@
 		retval = -EAGAIN;
 	else if (ep->is_in && value
 			/* data in (either) packet buffer? */
-			&& (ep->dev->regs->DataSet & DATASET_AB(ep->num)))
+			&& (readl(&ep->dev->regs->DataSet)
+					& DATASET_AB(ep->num)))
 		retval = -EAGAIN;
 	else if (!value)
 		goku_clear_halt(ep);
@@ -1000,9 +1003,9 @@
 
 static int goku_fifo_status(struct usb_ep *_ep)
 {
-	struct goku_ep		*ep;
-	struct goku_udc_regs	*regs;
-	u32			size;
+	struct goku_ep			*ep;
+	struct goku_udc_regs __iomem	*regs;
+	u32				size;
 
 	if (!_ep)
 		return -ENODEV;
@@ -1022,9 +1025,9 @@
 
 static void goku_fifo_flush(struct usb_ep *_ep)
 {
-	struct goku_ep		*ep;
-	struct goku_udc_regs	*regs;
-	u32			size;
+	struct goku_ep			*ep;
+	struct goku_udc_regs __iomem	*regs;
+	u32				size;
 
 	if (!_ep)
 		return;
@@ -1092,13 +1095,7 @@
 		return "(dma IN)";
 }
 
-/* if we're trying to save space, don't bother with this proc file */
-
-#if defined(CONFIG_PROC_FS) && !defined(CONFIG_EMBEDDED)
-#  define	UDC_PROC_FILE
-#endif
-
-#ifdef UDC_PROC_FILE
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 
 static const char proc_node_name [] = "driver/udc";
 
@@ -1147,14 +1144,14 @@
 udc_proc_read(char *buffer, char **start, off_t off, int count,
 		int *eof, void *_dev)
 {
-	char			*buf = buffer;
-	struct goku_udc		*dev = _dev;
-	struct goku_udc_regs	*regs = dev->regs;
-	char			*next = buf;
-	unsigned		size = count;
-	unsigned long		flags;
-	int			i, t, is_usb_connected;
-	u32			tmp;
+	char				*buf = buffer;
+	struct goku_udc			*dev = _dev;
+	struct goku_udc_regs __iomem	*regs = dev->regs;
+	char				*next = buf;
+	unsigned			size = count;
+	unsigned long			flags;
+	int				i, t, is_usb_connected;
+	u32				tmp;
 
 	if (off != 0)
 		return 0;
@@ -1312,7 +1309,7 @@
 	return count - size;
 }
 
-#endif	/* UDC_PROC_FILE */
+#endif	/* CONFIG_USB_GADGET_DEBUG_FILES */
 
 /*-------------------------------------------------------------------------*/
 
@@ -1342,17 +1339,17 @@
 		ep->dev = dev;
 		INIT_LIST_HEAD (&ep->queue);
 
-		ep_reset(0, ep);
+		ep_reset(NULL, ep);
 	}
 
-	dev->ep[0].reg_mode = 0;
+	dev->ep[0].reg_mode = NULL;
 	dev->ep[0].ep.maxpacket = MAX_EP0_SIZE;
 	list_del_init (&dev->ep[0].ep.ep_list);
 }
 
 static void udc_reset(struct goku_udc *dev)
 {
-	struct goku_udc_regs	*regs = dev->regs;
+	struct goku_udc_regs __iomem	*regs = dev->regs;
 
 	writel(0, &regs->power_detect);
 	writel(0, &regs->int_enable);
@@ -1369,8 +1366,8 @@
 
 static void ep0_start(struct goku_udc *dev)
 {
-	struct goku_udc_regs	*regs = dev->regs;
-	unsigned		i;
+	struct goku_udc_regs __iomem	*regs = dev->regs;
+	unsigned			i;
 
 	VDBG(dev, "%s\n", __FUNCTION__);
 
@@ -1447,15 +1444,15 @@
 		return -EBUSY;
 
 	/* hook up the driver */
-	driver->driver.bus = 0;
+	driver->driver.bus = NULL;
 	dev->driver = driver;
 	dev->gadget.dev.driver = &driver->driver;
 	retval = driver->bind(&dev->gadget);
 	if (retval) {
 		DBG(dev, "bind to driver %s --> error %d\n",
 				driver->driver.name, retval);
-		dev->driver = 0;
-		dev->gadget.dev.driver = 0;
+		dev->driver = NULL;
+		dev->gadget.dev.driver = NULL;
 		return retval;
 	}
 
@@ -1477,7 +1474,7 @@
 	DBG (dev, "%s\n", __FUNCTION__);
 
 	if (dev->gadget.speed == USB_SPEED_UNKNOWN)
-		driver = 0;
+		driver = NULL;
 
 	/* disconnect gadget driver after quiesceing hw and the driver */
 	udc_reset (dev);
@@ -1504,7 +1501,7 @@
 		return -EINVAL;
 
 	spin_lock_irqsave(&dev->lock, flags);
-	dev->driver = 0;
+	dev->driver = NULL;
 	stop_activity(dev, driver);
 	spin_unlock_irqrestore(&dev->lock, flags);
 
@@ -1520,9 +1517,9 @@
 
 static void ep0_setup(struct goku_udc *dev)
 {
-	struct goku_udc_regs	*regs = dev->regs;
-	struct usb_ctrlrequest	ctrl;
-	int			tmp;
+	struct goku_udc_regs __iomem	*regs = dev->regs;
+	struct usb_ctrlrequest		ctrl;
+	int				tmp;
 
 	/* read SETUP packet and enter DATA stage */
 	ctrl.bRequestType = readl(&regs->bRequestType);
@@ -1629,11 +1626,11 @@
 
 static irqreturn_t goku_irq(int irq, void *_dev, struct pt_regs *r)
 {
-	struct goku_udc		*dev = _dev;
-	struct goku_udc_regs	*regs = dev->regs;
-	struct goku_ep		*ep;
-	u32			stat, handled = 0;
-	unsigned		i, rescans = 5;
+	struct goku_udc			*dev = _dev;
+	struct goku_udc_regs __iomem	*regs = dev->regs;
+	struct goku_ep			*ep;
+	u32				stat, handled = 0;
+	unsigned			i, rescans = 5;
 
 	spin_lock(&dev->lock);
 
@@ -1651,7 +1648,7 @@
 			stat = 0;
 			handled = 1;
 			// FIXME have a neater way to prevent re-enumeration
-			dev->driver = 0;
+			dev->driver = NULL;
 			goto done;
 		}
 		if (stat & INT_PWRDETECT) {
@@ -1815,7 +1812,7 @@
 		usb_gadget_unregister_driver(dev->driver);
 	}
 
-#ifdef	UDC_PROC_FILE
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 	remove_proc_entry(proc_node_name, NULL);
 #endif
 	if (dev->regs)
@@ -1831,9 +1828,9 @@
 		pci_disable_device(pdev);
 	device_unregister(&dev->gadget.dev);
 
-	pci_set_drvdata(pdev, 0);
-	dev->regs = 0;
-	the_controller = 0;
+	pci_set_drvdata(pdev, NULL);
+	dev->regs = NULL;
+	the_controller = NULL;
 
 	INFO(dev, "unbind\n");
 }
@@ -1844,9 +1841,9 @@
 
 static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-	struct goku_udc		*dev = 0;
+	struct goku_udc		*dev = NULL;
 	unsigned long		resource, len;
-	void			*base = 0;
+	void __iomem		*base = NULL;
 	int			retval;
 	char			buf [8], *bufp;
 
@@ -1906,7 +1903,7 @@
 		retval = -EFAULT;
 		goto done;
 	}
-	dev->regs = (struct goku_udc_regs *) base;
+	dev->regs = (struct goku_udc_regs __iomem *) base;
 
 	pci_set_drvdata(pdev, dev);
 	INFO(dev, "%s\n", driver_desc);
@@ -1933,7 +1930,7 @@
 		pci_set_master(pdev);
 
 
-#ifdef	UDC_PROC_FILE
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 	create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev);
 #endif
 
@@ -1976,7 +1973,7 @@
 
 static int __init init (void)
 {
-	return pci_module_init (&goku_pci_driver);
+	return pci_register_driver (&goku_pci_driver);
 }
 module_init (init);
 
diff -Nru a/drivers/usb/gadget/goku_udc.h b/drivers/usb/gadget/goku_udc.h
--- a/drivers/usb/gadget/goku_udc.h	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/gadget/goku_udc.h	2004-12-24 13:36:48 -08:00
@@ -216,9 +216,9 @@
 	struct list_head			queue;
 	const struct usb_endpoint_descriptor	*desc;
 
-	u32					*reg_fifo;
-	u32					*reg_mode;
-	u32					*reg_status;
+	u32 __iomem				*reg_fifo;
+	u32 __iomem				*reg_mode;
+	u32 __iomem				*reg_status;
 };
 
 struct goku_request {
@@ -253,7 +253,7 @@
 
 	/* pci state used to access those endpoints */
 	struct pci_dev			*pdev;
-	struct goku_udc_regs		*regs;
+	struct goku_udc_regs __iomem	*regs;
 	u32				int_enable;
 
 	/* statistics... */
diff -Nru a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
--- a/drivers/usb/gadget/inode.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/usb/gadget/inode.c	2004-12-24 13:37:03 -08:00
@@ -1981,12 +1981,8 @@
 {
 	struct dentry	*dentry;
 	struct inode	*inode;
-	struct qstr	qname;
 
-	qname.name = name;
-	qname.len = strlen (name);
-	qname.hash = full_name_hash (qname.name, qname.len);
-	dentry = d_alloc (sb->s_root, &qname);
+	dentry = d_alloc_name(sb->s_root, name);
 	if (!dentry)
 		return NULL;
 
diff -Nru a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
--- a/drivers/usb/gadget/lh7a40x_udc.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/gadget/lh7a40x_udc.c	2004-12-24 13:37:29 -08:00
@@ -54,7 +54,6 @@
 /*
   Local definintions.
 */
-#define UDC_PROC_FILE
 
 #ifndef NO_STATES
 static char *state_names[] = {
@@ -192,7 +191,7 @@
  */
 #define is_usb_connected() 		get_portc_pdr(2)
 
-#ifdef UDC_PROC_FILE
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 
 static const char proc_node_name[] = "driver/udc";
 
@@ -248,12 +247,12 @@
 #define create_proc_files() 	create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev)
 #define remove_proc_files() 	remove_proc_entry(proc_node_name, NULL)
 
-#else				/* !UDC_PROC_FILE */
+#else	/* !CONFIG_USB_GADGET_DEBUG_FILES */
 
 #define create_proc_files() do {} while (0)
 #define remove_proc_files() do {} while (0)
 
-#endif				/* UDC_PROC_FILE */
+#endif	/* CONFIG_USB_GADGET_DEBUG_FILES */
 
 /*
  * 	udc_disable - disable USB device controller
diff -Nru a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
--- a/drivers/usb/gadget/net2280.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/gadget/net2280.c	2004-12-24 13:36:17 -08:00
@@ -76,7 +76,6 @@
 #define	EP_DONTUSE		13	/* nonzero */
 
 #define USE_RDK_LEDS		/* GPIO pins control three LEDs */
-#define USE_SYSFS_DEBUG_FILES
 
 
 static const char driver_name [] = "net2280";
@@ -117,7 +116,7 @@
 
 #define	DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out")
 
-#if defined(USE_SYSFS_DEBUG_FILES) || defined (DEBUG)
+#if defined(CONFIG_USB_GADGET_DEBUG_FILES) || defined (DEBUG)
 static char *type_string (u8 bmAttributes)
 {
 	switch ((bmAttributes) & USB_ENDPOINT_XFERTYPE_MASK) {
@@ -718,7 +717,7 @@
 		dmacount |= (1 << DMA_DONE_INTERRUPT_ENABLE);
 
 	/* td->dmadesc = previously set by caller */
-	td->dmaaddr = cpu_to_le32p (&req->req.dma);
+	td->dmaaddr = cpu_to_le32 (req->req.dma);
 
 	/* 2280 may be polling VALID_BIT through ep->dma->dmadesc */
 	wmb ();
@@ -1450,7 +1449,12 @@
 
 /*-------------------------------------------------------------------------*/
 
-#ifdef	USE_SYSFS_DEBUG_FILES
+#ifdef	CONFIG_USB_GADGET_DEBUG_FILES
+
+/* FIXME move these into procfs, and use seq_file.
+ * Sysfs _still_ doesn't behave for arbitrarily sized files,
+ * and also doesn't help products using this with 2.4 kernels.
+ */
 
 /* "function" sysfs attribute */
 static ssize_t
@@ -1703,8 +1707,10 @@
 				td = req->td;
 				t = scnprintf (next, size, "\t    td %08x "
 					" count %08x buf %08x desc %08x\n",
-					req->td_dma, td->dmacount,
-					td->dmaaddr, td->dmadesc);
+					(u32) req->td_dma,
+					le32_to_cpu (td->dmacount),
+					le32_to_cpu (td->dmaaddr),
+					le32_to_cpu (td->dmadesc));
 				if (t <= 0 || t > size)
 					goto done;
 				size -= t;
@@ -2841,6 +2847,7 @@
 	dev->got_irq = 1;
 
 	/* DMA setup */
+	/* NOTE:  we know only the 32 LSBs of dma addresses may be nonzero */
 	dev->requests = pci_pool_create ("requests", pdev,
 		sizeof (struct net2280_dma),
 		0 /* no alignment requirements */,
@@ -2936,7 +2943,7 @@
 {
 	if (!use_dma)
 		use_dma_chaining = 0;
-	return pci_module_init (&net2280_pci_driver);
+	return pci_register_driver (&net2280_pci_driver);
 }
 module_init (init);
 
diff -Nru a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
--- a/drivers/usb/gadget/net2280.h	2004-12-24 13:37:03 -08:00
+++ b/drivers/usb/gadget/net2280.h	2004-12-24 13:37:03 -08:00
@@ -495,10 +495,10 @@
  * use struct net2280_dma_regs bitfields
  */
 struct net2280_dma {
-	u32		dmacount;
-	u32		dmaaddr;		/* the buffer */
-	u32		dmadesc;		/* next dma descriptor */
-	u32		_reserved;
+	__le32		dmacount;
+	__le32		dmaaddr;		/* the buffer */
+	__le32		dmadesc;		/* next dma descriptor */
+	__le32		_reserved;
 } __attribute__ ((aligned (16)));
 
 /*-------------------------------------------------------------------------*/
diff -Nru a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
--- a/drivers/usb/gadget/omap_udc.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/usb/gadget/omap_udc.c	2004-12-24 13:36:31 -08:00
@@ -59,15 +59,14 @@
 
 #undef	USB_TRACE
 
-/* OUT-dma seems to be behaving */
+/* bulk DMA seems to be behaving for both IN and OUT */
 #define	USE_DMA
 
 /* ISO too */
 #define	USE_ISO
 
-
 #define	DRIVER_DESC	"OMAP UDC driver"
-#define	DRIVER_VERSION	"24 August 2004"
+#define	DRIVER_VERSION	"4 October 2004"
 
 #define	DMA_ADDR_INVALID	(~(dma_addr_t)0)
 
@@ -104,7 +103,6 @@
 module_param (fifo_mode, uint, 0);
 MODULE_PARM_DESC (fifo_mode, "endpoint setup (0 == default)");
 
-
 #ifdef	USE_DMA
 static unsigned use_dma = 1;
 
@@ -224,18 +222,17 @@
 		list_add(&ep->iso, &udc->iso);
 
 	/* maybe assign a DMA channel to this endpoint */
-	if (use_dma && desc->bmAttributes == USB_ENDPOINT_XFER_BULK
-			&& !(ep->bEndpointAddress & USB_DIR_IN))
-			/* FIXME ISO can dma, but prefers first channel.
-			 * IN can dma, but lacks debugging.
-			 */
+	if (use_dma && desc->bmAttributes == USB_ENDPOINT_XFER_BULK)
+		/* FIXME ISO can dma, but prefers first channel */
 		dma_channel_claim(ep, 0);
 
 	/* PIO OUT may RX packets */
 	if (desc->bmAttributes != USB_ENDPOINT_XFER_ISOC
 			&& !ep->has_dma
-			&& !(ep->bEndpointAddress & USB_DIR_IN))
+			&& !(ep->bEndpointAddress & USB_DIR_IN)) {
 		UDC_CTRL_REG = UDC_SET_FIFO_EN;
+		ep->ackwait = 1 + ep->double_buf;
+	}
 
 	spin_unlock_irqrestore(&udc->lock, flags);
 	VDBG("%s enabled\n", _ep->name);
@@ -262,6 +259,7 @@
 	ep->has_dma = 0;
 	UDC_CTRL_REG = UDC_SET_HALT;
 	list_del_init(&ep->iso);
+	del_timer(&ep->timer);
 
 	spin_unlock_irqrestore(&ep->udc->lock, flags);
 
@@ -498,17 +496,22 @@
 		u16	ep_stat = UDC_STAT_FLG_REG;
 
 		is_last = 0;
-		if (ep_stat & FIFO_UNREADABLE)
+		if (ep_stat & FIFO_EMPTY) {
+			if (!ep->double_buf)
+				break;
+			ep->fnf = 1;
+		}
+		if (ep_stat & UDC_EP_HALTED)
 			break;
 
-		if (ep_stat & (UDC_NON_ISO_FIFO_FULL|UDC_ISO_FIFO_FULL))
+		if (ep_stat & FIFO_FULL)
 			avail = ep->ep.maxpacket;
-		else 
+		else  {
 			avail = UDC_RXFSTAT_REG;
+			ep->fnf = ep->double_buf;
+		}
 		count = read_packet(buf, req, avail);
 
-		// FIXME double buffered PIO OUT wasn't behaving...
-
 		/* partial packet reads may not be errors */
 		if (count < ep->ep.maxpacket) {
 			is_last = 1;
@@ -526,26 +529,56 @@
 
 		if (!ep->bEndpointAddress)
 			break;
-		if (!ep->double_buf) {
-			UDC_CTRL_REG = UDC_SET_FIFO_EN;
-			if (!is_last)
-				break;
-		}
-
-		if (is_last) {
+		if (is_last)
 			done(ep, req, 0);
-			if (list_empty(&ep->queue) || !ep->double_buf)
-				break;
-			req = container_of(ep->queue.next,
-					struct omap_req, queue);
-			is_last = 0;
-		}
+		break;
 	}
 	return is_last;
 }
 
 /*-------------------------------------------------------------------------*/
 
+static u16 dma_src_len(struct omap_ep *ep, dma_addr_t start)
+{
+	dma_addr_t	end;
+
+	/* IN-DMA needs this on fault/cancel paths, so 15xx misreports
+	 * the last transfer's bytecount by more than a FIFO's worth.
+	 */
+	if (cpu_is_omap15xx())
+		return 0;
+
+	end = omap_readw(OMAP_DMA_CSAC(ep->lch));
+	if (end == ep->dma_counter)
+		return 0;
+
+	end |= start & (0xffff << 16);
+	if (end < start)
+		end += 0x10000;
+	return end - start;
+}
+
+#define DMA_DEST_LAST(x) (cpu_is_omap15xx() \
+		? OMAP_DMA_CSAC(x) /* really: CPC */ \
+		: OMAP_DMA_CDAC(x))
+
+static u16 dma_dest_len(struct omap_ep *ep, dma_addr_t start)
+{
+	dma_addr_t	end;
+
+	end = omap_readw(DMA_DEST_LAST(ep->lch));
+	if (end == ep->dma_counter)
+		return 0;
+
+	end |= start & (0xffff << 16);
+	if (cpu_is_omap15xx())
+		end++;
+	if (end < start)
+		end += 0x10000;
+	return end - start;
+}
+
+
 /* Each USB transfer request using DMA maps to one or more DMA transfers.
  * When DMA completion isn't request completion, the UDC continues with
  * the next DMA transfer for that USB transfer.
@@ -555,26 +588,29 @@
 {
 	u16		txdma_ctrl;
 	unsigned	length = req->req.length - req->req.actual;
+	const int	sync_mode = cpu_is_omap15xx()
+				? OMAP_DMA_SYNC_FRAME
+				: OMAP_DMA_SYNC_ELEMENT;
 
 	/* measure length in either bytes or packets */
-	if (length <= (UDC_TXN_TSC + 1)) {
+	if ((cpu_is_omap16xx() && length <= (UDC_TXN_TSC + 1))
+			|| (cpu_is_omap15xx() && length < ep->maxpacket)) {
 		txdma_ctrl = UDC_TXN_EOT | length;
 		omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8,
-				length, 1, OMAP_DMA_SYNC_ELEMENT);
+				length, 1, sync_mode);
 	} else {
-		length = max(length / ep->maxpacket,
+		length = min(length / ep->maxpacket,
 				(unsigned) UDC_TXN_TSC + 1);
  		txdma_ctrl = length;
 		omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8,
-				ep->ep.maxpacket, length,
-				OMAP_DMA_SYNC_ELEMENT);
+				ep->ep.maxpacket, length, sync_mode);
 		length *= ep->maxpacket;
 	}
-
 	omap_set_dma_src_params(ep->lch, OMAP_DMA_PORT_EMIFF,
 		OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual);
 
 	omap_start_dma(ep->lch);
+	ep->dma_counter = omap_readw(OMAP_DMA_CSAC(ep->lch));
 	UDC_DMA_IRQ_EN_REG |= UDC_TX_DONE_IE(ep->dma_channel);
 	UDC_TXDMA_REG(ep->dma_channel) = UDC_TXN_START | txdma_ctrl;
 	req->dma_bytes = length;
@@ -592,14 +628,9 @@
 				&& req->dma_bytes != 0
 				&& (req->req.actual % ep->maxpacket) == 0)
 			return;
-	} else {
-		u32	last;
-
-		// FIXME this surely isn't #bytes transferred
-		last = (omap_readw(OMAP_DMA_CSSA_U(ep->lch)) << 16)
-				| omap_readw(OMAP_DMA_CSSA_L(ep->lch));
-		req->req.actual = last - req->req.dma;
-	}
+	} else
+		req->req.actual += dma_src_len(ep, req->req.dma
+							+ req->req.actual);
 
 	/* tx completion */
 	omap_stop_dma(ep->lch);
@@ -624,6 +655,7 @@
 			OMAP_DMA_SYNC_ELEMENT);
 	omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF,
 		OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual);
+	ep->dma_counter = omap_readw(DMA_DEST_LAST(ep->lch));
 
 	UDC_RXDMA_REG(ep->dma_channel) = UDC_RXN_STOP | (packets - 1);
 	UDC_DMA_IRQ_EN_REG |= UDC_RX_EOT_IE(ep->dma_channel);
@@ -638,15 +670,13 @@
 {
 	u16	count;
 
-	/* FIXME must be a better way to see how much dma
-	 * happened, even when it never got going...
-	 */
-	count = omap_readw(OMAP_DMA_CDAC(ep->lch));
-	count -= 0xffff & (req->req.dma + req->req.actual);
+	if (status == 0)
+		ep->dma_counter = (u16) (req->req.dma + req->req.actual);
+	count = dma_dest_len(ep, req->req.dma + req->req.actual);
 	count += req->req.actual;
 	if (count <= req->req.length)
 		req->req.actual = count;
-	
+
 	if (count != req->dma_bytes || status)
 		omap_stop_dma(ep->lch);
 
@@ -705,7 +735,9 @@
 
 	if (irq_src & UDC_RXN_CNT) {
 		ep = &udc->ep[UDC_DMA_RX_SRC(dman_stat)];
-		DBG("%s, RX_CNT irq?\n", ep->ep.name);
+		ep->irqs++;
+		/* omap15xx does this unasked... */
+		VDBG("%s, RX_CNT irq?\n", ep->ep.name);
 		UDC_IRQ_SRC_REG = UDC_RXN_CNT;
 	}
 }
@@ -778,7 +810,8 @@
 		omap_disable_dma_irq(ep->lch, OMAP_DMA_BLOCK_IRQ);
 
 		/* channel type P: hw synch (fifo) */
-		omap_writew(2, OMAP_DMA_LCH_CTRL(ep->lch));
+		if (!cpu_is_omap15xx())
+			omap_writew(2, OMAP_DMA_LCH_CTRL(ep->lch));
 	}
 
 just_restart:
@@ -803,6 +836,10 @@
 			use_ep(ep, UDC_EP_SEL);
 			(is_in ? write_fifo : read_fifo)(ep, req);
 			deselect_ep();
+			if (!is_in) {
+				UDC_CTRL_REG = UDC_SET_FIFO_EN;
+				ep->ackwait = 1 + ep->double_buf;
+			}
 			/* IN: 6 wait states before it'll tx */
 		}
 	}
@@ -833,24 +870,21 @@
 		UDC_TXDMA_CFG_REG &= ~mask;
 
 		if (req) {
-			if (active)
-				udelay(50);
 			finish_in_dma(ep, req, -ECONNRESET);
-			if (UDC_TXDMA_CFG_REG & mask)
-				WARN("%s, SPIN abort TX dma\n", ep->ep.name);
-		}
 
-		/* host may empty the fifo (or not...) */
+			/* clear FIFO; hosts probably won't empty it */
+			use_ep(ep, UDC_EP_SEL);
+			UDC_CTRL_REG = UDC_CLR_EP;
+			deselect_ep();
+		}
 		while (UDC_TXDMA_CFG_REG & mask)
 			udelay(10);
-
 	} else {
 		UDC_RXDMA_CFG_REG &= ~mask;
 
 		/* dma empties the fifo */
-		while (active && (UDC_RXDMA_CFG_REG & mask))
+		while (UDC_RXDMA_CFG_REG & mask)
 			udelay(10);
-		omap_stop_dma(ep->lch);
 		if (req)
 			finish_out_dma(ep, req, -ECONNRESET);
 	}
@@ -997,6 +1031,10 @@
 			if ((is_in ? write_fifo : read_fifo)(ep, req) == 1)
 				req = 0;
 			deselect_ep();
+			if (!is_in) {
+				UDC_CTRL_REG = UDC_SET_FIFO_EN;
+				ep->ackwait = 1 + ep->double_buf;
+			}
 			/* IN: 6 wait states before it'll tx */
 		}
 	}
@@ -1034,7 +1072,7 @@
 	if (use_dma && ep->dma_channel && ep->queue.next == &req->queue) {
 		int channel = ep->dma_channel;
 
-		/* releasing the dma completion cancels the request,
+		/* releasing the channel cancels the request,
 		 * reclaiming the channel restarts the queue
 		 */
 		dma_channel_release(ep);
@@ -1104,8 +1142,10 @@
 			use_ep(ep, 0);
 			UDC_CTRL_REG = UDC_RESET_EP;
 			ep->ackwait = 0;
-			if (!(ep->bEndpointAddress & USB_DIR_IN))
+			if (!(ep->bEndpointAddress & USB_DIR_IN)) {
 				UDC_CTRL_REG = UDC_SET_FIFO_EN;
+				ep->ackwait = 1 + ep->double_buf;
+			}
 		}
 	}
 done:
@@ -1200,7 +1240,8 @@
 {
 	UDC_SYSCON1_REG |= UDC_PULLUP_EN;
 #ifndef CONFIG_USB_OTG
-	OTG_CTRL_REG |= OTG_BSESSVLD;
+	if (!cpu_is_omap15xx())
+		OTG_CTRL_REG |= OTG_BSESSVLD;
 #endif
 	UDC_IRQ_EN_REG = UDC_DS_CHG_IE;
 }
@@ -1208,7 +1249,8 @@
 static void pullup_disable(struct omap_udc *udc)
 {
 #ifndef CONFIG_USB_OTG
-	OTG_CTRL_REG &= ~OTG_BSESSVLD;
+	if (!cpu_is_omap15xx())
+		OTG_CTRL_REG &= ~OTG_BSESSVLD;
 #endif
 	UDC_IRQ_EN_REG = UDC_DS_CHG_IE;
 	UDC_SYSCON1_REG &= ~UDC_PULLUP_EN;
@@ -1216,7 +1258,7 @@
 
 /*
  * Called by whatever detects VBUS sessions:  external transceiver
- * driver, or maybe GPIO0 VBUS IRQ.
+ * driver, or maybe GPIO0 VBUS IRQ.  May request 48 MHz clock.
  */
 static int omap_vbus_session(struct usb_gadget *gadget, int is_active)
 {
@@ -1227,6 +1269,13 @@
 	spin_lock_irqsave(&udc->lock, flags);
 	VDBG("VBUS %s\n", is_active ? "on" : "off");
 	udc->vbus_active = (is_active != 0);
+	if (cpu_is_omap15xx()) {
+		/* "software" detect, ignored if !VBUS_MODE_1510 */
+		if (is_active)
+			FUNC_MUX_CTRL_0_REG |= VBUS_CTRL_1510;
+		else
+			FUNC_MUX_CTRL_0_REG &= ~VBUS_CTRL_1510;
+	}
 	if (can_pullup(udc))
 		pullup_enable(udc);
 	else
@@ -1340,8 +1389,15 @@
 	/* Clear any pending requests and then scrub any rx/tx state
 	 * before starting to handle the SETUP request.
 	 */
-	if (irq_src & UDC_SETUP)
+	if (irq_src & UDC_SETUP) {
+		u16	ack = irq_src & (UDC_EP0_TX|UDC_EP0_RX);
+
 		nuke(ep0, 0);
+		if (ack) {
+			UDC_IRQ_SRC_REG = ack;
+			irq_src = UDC_SETUP;
+		}
+	}
 
 	/* IN/OUT packets mean we're in the DATA or STATUS stage.  
 	 * This driver uses only uses protocol stalls (ep0 never halts),
@@ -1506,8 +1562,10 @@
 				use_ep(ep, 0);
 				UDC_CTRL_REG = UDC_RESET_EP;
 				ep->ackwait = 0;
-				if (!(ep->bEndpointAddress & USB_DIR_IN))
+				if (!(ep->bEndpointAddress & USB_DIR_IN)) {
 					UDC_CTRL_REG = UDC_SET_FIFO_EN;
+					ep->ackwait = 1 + ep->double_buf;
+				}
 			}
 			VDBG("%s halt cleared by host\n", ep->name);
 			goto ep0out_status_stage;
@@ -1688,7 +1746,7 @@
 		}
 		change &= ~UDC_SUS;
 	}
-	if (change & OTG_FLAGS) {
+	if (!cpu_is_omap15xx() && (change & OTG_FLAGS)) {
 		update_otg(udc);
 		change &= ~OTG_FLAGS;
 	}
@@ -1741,6 +1799,39 @@
 	return status;
 }
 
+/* workaround for seemingly-lost IRQs for RX ACKs... */
+#define PIO_OUT_TIMEOUT	(jiffies + HZ/3)
+#define HALF_FULL(f)	(!((f)&(UDC_NON_ISO_FIFO_FULL|UDC_NON_ISO_FIFO_EMPTY)))
+
+static void pio_out_timer(unsigned long _ep)
+{
+	struct omap_ep	*ep = (void *) _ep;
+	unsigned long	flags;
+	u16		stat_flg;
+
+	spin_lock_irqsave(&ep->udc->lock, flags);
+	if (!list_empty(&ep->queue) && ep->ackwait) {
+		use_ep(ep, 0);
+		stat_flg = UDC_STAT_FLG_REG;
+
+		if ((stat_flg & UDC_ACK) && (!(stat_flg & UDC_FIFO_EN)
+				|| (ep->double_buf && HALF_FULL(stat_flg)))) {
+			struct omap_req	*req;
+
+			VDBG("%s: lose, %04x\n", ep->ep.name, stat_flg);
+			req = container_of(ep->queue.next,
+					struct omap_req, queue);
+			UDC_EP_NUM_REG = ep->bEndpointAddress | UDC_EP_SEL;
+			(void) read_fifo(ep, req);
+			UDC_EP_NUM_REG = ep->bEndpointAddress;
+			UDC_CTRL_REG = UDC_SET_FIFO_EN;
+			ep->ackwait = 1 + ep->double_buf;
+		}
+	}
+	mod_timer(&ep->timer, PIO_OUT_TIMEOUT);
+	spin_unlock_irqrestore(&ep->udc->lock, flags);
+}
+
 static irqreturn_t
 omap_udc_pio_irq(int irq, void *_dev, struct pt_regs *r)
 {
@@ -1764,38 +1855,56 @@
 		ep = &udc->ep[epnum];
 		ep->irqs++;
 
-		if (!list_empty(&ep->queue)) {
-			UDC_EP_NUM_REG = epnum | UDC_EP_SEL;
-			if ((UDC_STAT_FLG_REG & UDC_ACK)) {
+		UDC_EP_NUM_REG = epnum | UDC_EP_SEL;
+		ep->fnf = 0;
+		if ((UDC_STAT_FLG_REG & UDC_ACK)) {
+			ep->ackwait--;
+			if (!list_empty(&ep->queue)) {
 				int stat;
 				req = container_of(ep->queue.next,
 						struct omap_req, queue);
 				stat = read_fifo(ep, req);
-				// FIXME double buffered PIO OUT should work
+				if (!ep->double_buf)
+					ep->fnf = 1;
 			}
-			UDC_EP_NUM_REG = epnum;
 		}
+		/* min 6 clock delay before clearing EP_SEL ... */
+		epn_stat = UDC_EPN_STAT_REG;
+		epn_stat = UDC_EPN_STAT_REG;
+		UDC_EP_NUM_REG = epnum;
+
+		/* enabling fifo _after_ clearing ACK, contrary to docs,
+		 * reduces lossage; timer still needed though (sigh).
+		 */
+		if (ep->fnf) {
+			UDC_CTRL_REG = UDC_SET_FIFO_EN;
+			ep->ackwait = 1 + ep->double_buf;
+		}
+		mod_timer(&ep->timer, PIO_OUT_TIMEOUT);
 	}
 
 	/* then IN transfers */
-	if (irq_src & UDC_EPN_TX) {
+	else if (irq_src & UDC_EPN_TX) {
 		epnum = epn_stat & 0x0f;
 		UDC_IRQ_SRC_REG = UDC_EPN_TX;
 		status = IRQ_HANDLED;
 		ep = &udc->ep[16 + epnum];
 		ep->irqs++;
-		ep->ackwait = 0;
 
-		if (!list_empty(&ep->queue)) {
-			UDC_EP_NUM_REG = epnum | UDC_EP_DIR | UDC_EP_SEL;
-			if ((UDC_STAT_FLG_REG & UDC_ACK)) {
+		UDC_EP_NUM_REG = epnum | UDC_EP_DIR | UDC_EP_SEL;
+		if ((UDC_STAT_FLG_REG & UDC_ACK)) {
+			ep->ackwait = 0;
+			if (!list_empty(&ep->queue)) {
 				req = container_of(ep->queue.next,
 						struct omap_req, queue);
 				(void) write_fifo(ep, req);
 			}
-			UDC_EP_NUM_REG = epnum | UDC_EP_DIR;
-			/* 6 wait states before it'll tx */
 		}
+		/* min 6 clock delay before clearing EP_SEL ... */
+		epn_stat = UDC_EPN_STAT_REG;
+		epn_stat = UDC_EPN_STAT_REG;
+		UDC_EP_NUM_REG = epnum | UDC_EP_DIR;
+		/* then 6 clocks before it'd tx */
 	}
 
 	spin_unlock_irqrestore(&udc->lock, flags);
@@ -1937,6 +2046,9 @@
 			pullup_disable (udc);
 	}
 
+	if (machine_is_omap_innovator())
+		omap_vbus_session(&udc->gadget, 1);
+
 done:
 	return status;
 }
@@ -1952,6 +2064,9 @@
 	if (!driver || driver != udc->driver)
 		return -EINVAL;
 
+	if (machine_is_omap_innovator())
+		omap_vbus_session(&udc->gadget, 0);
+
 	if (udc->transceiver)
 		(void) otg_set_peripheral(udc->transceiver, 0);
 	else
@@ -1974,7 +2089,7 @@
 
 /*-------------------------------------------------------------------------*/
 
-#ifdef CONFIG_USB_OMAP_PROC
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 
 #include <linux/seq_file.h>
 
@@ -2000,8 +2115,16 @@
 
 	stat_flg = UDC_STAT_FLG_REG;
 	seq_printf(s,
-		"\n%s %sirqs %ld stat %04x " EIGHTBITS FOURBITS "%s\n",
-		ep->name, buf, ep->irqs, stat_flg,
+		"\n%s %s%s%sirqs %ld stat %04x " EIGHTBITS FOURBITS "%s\n",
+		ep->name, buf,
+		ep->double_buf ? "dbuf " : "",
+		({char *s; switch(ep->ackwait){
+		case 0: s = ""; break;
+		case 1: s = "(ackw) "; break;
+		case 2: s = "(ackw2) "; break;
+		default: s = "(?) "; break;
+		} s;}),
+		ep->irqs, stat_flg,
 		(stat_flg & UDC_NO_RXPACKET) ? "no_rxpacket " : "",
 		(stat_flg & UDC_MISS_IN) ? "miss_in " : "",
 		(stat_flg & UDC_DATA_FLUSH) ? "data_flush " : "",
@@ -2019,10 +2142,19 @@
 	if (list_empty (&ep->queue))
 		seq_printf(s, "\t(queue empty)\n");
 	else
-		list_for_each_entry (req, &ep->queue, queue)
+		list_for_each_entry (req, &ep->queue, queue) {
+			unsigned	length = req->req.actual;
+
+			if (use_dma && buf[0]) {
+				length += ((ep->bEndpointAddress & USB_DIR_IN)
+						? dma_src_len : dma_dest_len)
+					(ep, req->req.dma + length);
+				buf[0] = 0;
+			}
 			seq_printf(s, "\treq %p len %d/%d buf %p\n",
-					&req->req, req->req.actual,
+					&req->req, length,
 					req->req.length, req->req.buf);
+		}
 }
 
 static char *trx_mode(unsigned m)
@@ -2036,34 +2168,14 @@
 	}
 }
 
-static int proc_udc_show(struct seq_file *s, void *_)
+static int proc_otg_show(struct seq_file *s)
 {
 	u32		tmp;
-	struct omap_ep	*ep;
-	unsigned long	flags;
-
-	spin_lock_irqsave(&udc->lock, flags);
-
-	seq_printf(s, "%s, version: " DRIVER_VERSION
-#ifdef	USE_ISO
-		" (iso)"
-#endif
-		"%s\n",
-		driver_desc,
-		use_dma ?  " (dma)" : "");
 
-	tmp = UDC_REV_REG & 0xff; 
-	seq_printf(s,
-		"UDC rev %d.%d, OTG rev %d.%d, fifo mode %d, gadget %s\n"
-		"hmc %d, transceiver %08x %s\n",
+	tmp = OTG_REV_REG;
+	seq_printf(s, "OTG rev %d.%d, transceiver_ctrl %08x\n",
 		tmp >> 4, tmp & 0xf,
-		OTG_REV_REG >> 4, OTG_REV_REG & 0xf,
-		fifo_mode,
-		udc->driver ? udc->driver->driver.name : "(none)",
-		HMC, USB_TRANSCEIVER_CTRL_REG,
-		udc->transceiver ? udc->transceiver->label : "");
-
-	/* OTG controller registers */
+		USB_TRANSCEIVER_CTRL_REG);
 	tmp = OTG_SYSCON_1_REG;
 	seq_printf(s, "otg_syscon1 %08x usb2 %s, usb1 %s, usb0 %s,"
 			FOURBITS "\n", tmp,
@@ -2117,6 +2229,41 @@
 	seq_printf(s, "otg_outctrl %04x" "\n", tmp);
 	tmp = OTG_TEST_REG;
 	seq_printf(s, "otg_test    %04x" "\n", tmp);
+}
+
+static int proc_udc_show(struct seq_file *s, void *_)
+{
+	u32		tmp;
+	struct omap_ep	*ep;
+	unsigned long	flags;
+
+	spin_lock_irqsave(&udc->lock, flags);
+
+	seq_printf(s, "%s, version: " DRIVER_VERSION
+#ifdef	USE_ISO
+		" (iso)"
+#endif
+		"%s\n",
+		driver_desc,
+		use_dma ?  " (dma)" : "");
+
+	tmp = UDC_REV_REG & 0xff; 
+	seq_printf(s,
+		"UDC rev %d.%d, fifo mode %d, gadget %s\n"
+		"hmc %d, transceiver %s\n",
+		tmp >> 4, tmp & 0xf,
+		fifo_mode,
+		udc->driver ? udc->driver->driver.name : "(none)",
+		HMC,
+		udc->transceiver ? udc->transceiver->label : "(none)");
+	seq_printf(s, "ULPD control %04x req %04x status %04x\n",
+		__REG16(ULPD_CLOCK_CTRL),
+		__REG16(ULPD_SOFT_REQ),
+		__REG16(ULPD_STATUS_REQ));
+
+	/* OTG controller registers */
+	if (!cpu_is_omap15xx())
+		proc_otg_show(s);
 
 	tmp = UDC_SYSCON1_REG;
 	seq_printf(s, "\nsyscon1     %04x" EIGHTBITS "\n", tmp,
@@ -2292,10 +2439,10 @@
 		epn_rxtx |= UDC_EPN_RX_ISO;
 		dbuf = 1;
 	} else {
-		/* pio-out could potentially double-buffer,
-		 * as can (should!) DMA-IN
+		/* double-buffering "not supported" on 15xx,
+		 * and ignored for PIO-IN on 16xx
 		 */
-		if (!use_dma || (addr & USB_DIR_IN))
+		if (!use_dma || cpu_is_omap15xx())
 			dbuf = 0;
 
 		switch (maxp) {
@@ -2307,6 +2454,9 @@
 		}
 		if (dbuf && addr)
 			epn_rxtx |= UDC_EPN_RX_DB;
+		init_timer(&ep->timer);
+		ep->timer.function = pio_out_timer;
+		ep->timer.data = (unsigned long) ep;
 	}
 	if (addr)
 		epn_rxtx |= UDC_EPN_RX_VALID;
@@ -2496,41 +2646,63 @@
 		return -EBUSY;
 	}
 
-	INFO("OMAP UDC rev %d.%d, OTG rev %d.%d, %s receptacle\n",
+	INFO("OMAP UDC rev %d.%d%s\n",
 		UDC_REV_REG >> 4, UDC_REV_REG & 0xf,
-		OTG_REV_REG >> 4, OTG_REV_REG & 0xf,
-		config->otg ? "Mini-AB" : "B/Mini-B");
+		config->otg ? ", Mini-AB" : "");
 
 	/* use the mode given to us by board init code */
-	hmc = HMC;
-	switch (hmc) {
-	case 3:
-	case 11:
-	case 19:
-	case 25:
-		xceiv = otg_get_transceiver();
-		if (!xceiv) {
-			DBG("external transceiver not registered!\n");
-			goto cleanup0;
+	if (cpu_is_omap15xx()) {
+		hmc = HMC_1510;
+		type = "(unknown)";
+
+		if (machine_is_omap_innovator()) {
+			/* just set up software VBUS detect, and then
+			 * later rig it so we always report VBUS.
+			 * FIXME without really sensing VBUS, we can't
+			 * know when to turn PULLUP_EN on/off; and that
+			 * means we always "need" the 48MHz clock.
+			 */
+			u32 tmp = FUNC_MUX_CTRL_0_REG;
+
+			FUNC_MUX_CTRL_0_REG &= ~VBUS_CTRL_1510;
+			tmp |= VBUS_MODE_1510;
+			tmp &= ~VBUS_CTRL_1510;
+			FUNC_MUX_CTRL_0_REG = tmp;
 		}
-		type = xceiv->label;
-		break;
-	case 0:			/* POWERUP DEFAULT == 0 */
-	case 4:
-	case 12:
-	case 20:
-		type = "INTEGRATED";
-		break;
-	case 21:			/* internal loopback */
-		type = "(loopback)";
-		break;
-	case 14:			/* transceiverless */
-		type = "(none)";
-		break;
+	} else {
+		hmc = HMC_1610;
+		switch (hmc) {
+		case 3:
+		case 11:
+		case 16:
+		case 19:
+		case 25:
+			xceiv = otg_get_transceiver();
+			if (!xceiv) {
+				DBG("external transceiver not registered!\n");
+				if (config->otg)
+					goto cleanup0;
+				type = "(unknown external)";
+			} else
+				type = xceiv->label;
+			break;
+		case 0:			/* POWERUP DEFAULT == 0 */
+		case 4:
+		case 12:
+		case 20:
+			type = "INTEGRATED";
+			break;
+		case 21:			/* internal loopback */
+			type = "(loopback)";
+			break;
+		case 14:			/* transceiverless */
+			type = "(none)";
+			break;
 
-	default:
-		ERR("unrecognized UDC HMC mode %d\n", hmc);
-		return -ENODEV;
+		default:
+			ERR("unrecognized UDC HMC mode %d\n", hmc);
+			return -ENODEV;
+		}
 	}
 	INFO("hmc mode %d, transceiver %s\n", hmc, type);
 
@@ -2542,7 +2714,9 @@
 	xceiv = 0;
 	// "udc" is now valid
 	pullup_disable(udc);
+#if	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
 	udc->gadget.is_otg = (config->otg != 0);
+#endif
 
 	/* USB general purpose IRQ:  ep0, state changes, dma, etc */
 	status = request_irq(odev->resource[1].start, omap_udc_irq,
@@ -2671,14 +2845,11 @@
 
 static int __init udc_init(void)
 {
-	/* should work on many OMAP systems with at most minor changes,
-	 * but the 1510 doesn't have an OTG controller.
-	 */
-	if (cpu_is_omap1510()) {
-		DBG("no OMAP1510 support yet\n");
-		return -ENODEV;
-	}
-	INFO("%s, version: " DRIVER_VERSION "%s\n", driver_desc,
+	INFO("%s, version: " DRIVER_VERSION
+#ifdef	USE_ISO
+		" (iso)"
+#endif
+		"%s\n", driver_desc,
 		use_dma ?  " (dma)" : "");
 	return driver_register(&udc_driver);
 }
diff -Nru a/drivers/usb/gadget/omap_udc.h b/drivers/usb/gadget/omap_udc.h
--- a/drivers/usb/gadget/omap_udc.h	2004-12-24 13:36:34 -08:00
+++ b/drivers/usb/gadget/omap_udc.h	2004-12-24 13:36:34 -08:00
@@ -146,11 +146,14 @@
 	u8				bmAttributes;
 	unsigned			double_buf:1;
 	unsigned			stopped:1;
-	unsigned			ackwait:1;
+	unsigned			fnf:1;
 	unsigned			has_dma:1;
+	u8				ackwait;
 	u8				dma_channel;
+	u16				dma_counter;
 	int				lch;
 	struct omap_udc			*udc;
+	struct timer_list		timer;
 };
 
 struct omap_udc {
@@ -168,7 +171,6 @@
 	unsigned			ep0_set_config:1;
 	unsigned			ep0_reset_config:1;
 	unsigned			ep0_setup:1;
-	unsigned			hmc:6;
 
 	struct completion		*done;
 };
@@ -193,7 +195,14 @@
 
 /*-------------------------------------------------------------------------*/
 
-// #define	HMC_1510	((MOD_CONF_CTRL_0_REG >> 1) & 0x3f)
+#define	MOD_CONF_CTRL_0_REG	__REG32(MOD_CONF_CTRL_0)
+#define	VBUS_W2FC_1510		(1 << 17)	/* 0 gpio0, 1 dvdd2 pin */
+
+#define	FUNC_MUX_CTRL_0_REG	__REG32(FUNC_MUX_CTRL_0)
+#define	VBUS_CTRL_1510		(1 << 19)	/* 1 connected (software) */
+#define	VBUS_MODE_1510		(1 << 18)	/* 0 hardware, 1 software */
+
+#define	HMC_1510	((MOD_CONF_CTRL_0_REG >> 1) & 0x3f)
 #define	HMC_1610	(OTG_SYSCON_2_REG & 0x3f)
-#define	HMC		 HMC_1610
+#define	HMC		(cpu_is_omap15xx() ? HMC_1510 : HMC_1610)
 
diff -Nru a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
--- a/drivers/usb/gadget/pxa2xx_udc.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/usb/gadget/pxa2xx_udc.c	2004-12-24 13:37:00 -08:00
@@ -92,10 +92,6 @@
 // #define	USE_OUT_DMA
 // #define	DISABLE_TEST_MODE
 
-#ifdef CONFIG_PROC_FS
-#define	UDC_PROC_FILE
-#endif
-
 #ifdef CONFIG_ARCH_IXP4XX
 #undef USE_DMA
 
@@ -109,12 +105,6 @@
 #include "pxa2xx_udc.h"
 
 
-#ifdef CONFIG_EMBEDDED
-/* few strings, and little code to use them */
-#undef	DEBUG
-#undef	UDC_PROC_FILE
-#endif
-
 #ifdef	USE_DMA
 static int use_dma = 1;
 module_param(use_dma, bool, 0);
@@ -1212,7 +1202,7 @@
 
 /*-------------------------------------------------------------------------*/
 
-#ifdef UDC_PROC_FILE
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 
 static const char proc_node_name [] = "driver/udc";
 
@@ -1368,11 +1358,12 @@
 #define remove_proc_files() \
 	remove_proc_entry(proc_node_name, NULL)
 
-#else	/* !UDC_PROC_FILE */
+#else	/* !CONFIG_USB_GADGET_DEBUG_FILES */
+
 #define create_proc_files() do {} while (0)
 #define remove_proc_files() do {} while (0)
 
-#endif	/* UDC_PROC_FILE */
+#endif	/* CONFIG_USB_GADGET_DEBUG_FILES */
 
 /* "function" sysfs attribute */
 static ssize_t
diff -Nru a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
--- a/drivers/usb/gadget/rndis.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/gadget/rndis.c	2004-12-24 13:36:17 -08:00
@@ -70,8 +70,6 @@
 
 #define RNDIS_MAX_CONFIGS	1
 
-static struct proc_dir_entry *rndis_connect_dir;
-static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
 
 static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS];
 
@@ -123,7 +121,7 @@
 		DEBUG("%s: OID_GEN_HARDWARE_STATUS\n", __FUNCTION__);
 		length = 4;
 		/* Bogus question! 
-		 * Hardware must be ready to recieve high level protocols.
+		 * Hardware must be ready to receive high level protocols.
 		 * BTW: 
 		 * reddite ergo quae sunt Caesaris Caesari
 		 * et quae sunt Dei Deo!
@@ -1275,7 +1273,9 @@
 	return 0;
 }
 
-int rndis_proc_read (char *page, char **start, off_t off, int count, int *eof, 
+#ifdef	CONFIG_USB_GADGET_DEBUG_FILES
+
+static int rndis_proc_read (char *page, char **start, off_t off, int count, int *eof, 
 		     void *data)
 {
 	char *out = page;
@@ -1320,7 +1320,7 @@
 	return len;
 }
 
-int rndis_proc_write (struct file *file, const char __user *buffer, 
+static int rndis_proc_write (struct file *file, const char __user *buffer, 
 		      unsigned long count, void *data)
 {
 	rndis_params *p = data;
@@ -1365,43 +1365,40 @@
 	return count;
 }
 
+#define	NAME_TEMPLATE	"driver/rndis-%03d"
+
+static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
+
+#endif	/* CONFIG_USB_GADGET_DEBUG_FILES */
+
+
 int __init rndis_init (void)
 {
 	u8 i;
-	char name [4];
 
-	/* FIXME this should probably be /proc/driver/rndis,
-	 * and only if debugging is enabled
-	 */
-	
-	if (!(rndis_connect_dir =  proc_mkdir ("rndis", NULL))) {
-		printk (KERN_ERR "%s: couldn't create /proc/rndis entry", 
-			__FUNCTION__);
-		return -EIO;
-	}
-	
 	for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
-		sprintf (name, "%03d", i);
+#ifdef	CONFIG_USB_GADGET_DEBUG_FILES
+		char name [20];
+
+		sprintf (name, NAME_TEMPLATE, i);
 		if (!(rndis_connect_state [i]
-				= create_proc_entry (name, 0660,
-						rndis_connect_dir))) 
+				= create_proc_entry (name, 0660, NULL))) 
 		{
 			DEBUG ("%s :remove entries", __FUNCTION__);
-			for (i--; i > 0; i--) {
-				sprintf (name, "%03d", i);
-				remove_proc_entry (name, rndis_connect_dir);
+			while (i) {
+				sprintf (name, NAME_TEMPLATE, --i);
+				remove_proc_entry (name, NULL);
 			}
 			DEBUG ("\n");
-			
-			remove_proc_entry ("000", rndis_connect_dir);
-			remove_proc_entry ("rndis", NULL);
 			return -EIO;
 		}
+
 		rndis_connect_state [i]->nlink = 1;
 		rndis_connect_state [i]->write_proc = rndis_proc_write;
 		rndis_connect_state [i]->read_proc = rndis_proc_read;
 		rndis_connect_state [i]->data = (void *)
 				(rndis_per_dev_params + i);
+#endif
 		rndis_per_dev_params [i].confignr = i;
 		rndis_per_dev_params [i].used = 0;
 		rndis_per_dev_params [i].state = RNDIS_UNINITIALIZED;
@@ -1415,14 +1412,14 @@
 
 void rndis_exit (void)
 {
+#ifdef	CONFIG_USB_GADGET_DEBUG_FILES
 	u8 i;
-	char name [4];
+	char name [20];
 	
 	for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
-		sprintf (name, "%03d", i);
-		remove_proc_entry (name, rndis_connect_dir);
+		sprintf (name, NAME_TEMPLATE, i);
+		remove_proc_entry (name, NULL);
 	}
-	remove_proc_entry ("rndis", NULL);
-	return;
+#endif
 }
 
diff -Nru a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
--- a/drivers/usb/gadget/serial.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/gadget/serial.c	2004-12-24 13:37:18 -08:00
@@ -123,10 +123,84 @@
 })
 
 
+/* CDC-ACM Defines and Structures */
+
+#define USB_CDC_SUBCLASS_ACM			2
+
+#define USB_CDC_CTRL_PROTO_NONE			0
+#define USB_CDC_CTRL_PROTO_AT			1
+#define USB_CDC_CTRL_PROTO_VENDOR		0xff
+
+#define USB_CDC_SUBTYPE_HEADER			0
+#define USB_CDC_SUBTYPE_CALL_MGMT		1
+#define USB_CDC_SUBTYPE_ACM			2
+#define USB_CDC_SUBTYPE_UNION			6
+
+#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT		0x01
+#define USB_CDC_CALL_MGMT_CAP_DATA_INTF		0x02
+
+#define USB_CDC_REQ_SET_LINE_CODING		0x20
+#define USB_CDC_REQ_GET_LINE_CODING		0x21
+#define USB_CDC_REQ_SET_CONTROL_LINE_STATE	0x22
+
+#define USB_CDC_1_STOP_BITS			0
+#define USB_CDC_1_5_STOP_BITS			1
+#define USB_CDC_2_STOP_BITS			2
+
+#define USB_CDC_NO_PARITY			0
+#define USB_CDC_ODD_PARITY			1
+#define USB_CDC_EVEN_PARITY			2
+#define USB_CDC_MARK_PARITY			3
+#define USB_CDC_SPACE_PARITY			4
+
+/* Header Functional Descriptor from CDC spec 5.2.3.1 */
+struct usb_cdc_header_desc {
+	u8	bLength;
+	u8	bDescriptorType;
+	u8	bDescriptorSubType;
+	u16	bcdCDC;
+} __attribute__ ((packed));
+
+/* Call Management Descriptor from CDC spec 5.2.3.3 */
+struct usb_cdc_call_mgmt_desc {
+	u8  bLength;
+	u8  bDescriptorType;
+	u8  bDescriptorSubType;
+	u8  bmCapabilities;
+	u8  bDataInterface;
+} __attribute__ ((packed));
+
+/* Abstract Control Management Descriptor from CDC spec 5.2.3.4 */
+struct usb_cdc_acm_desc {
+	u8  bLength;
+	u8  bDescriptorType;
+	u8  bDescriptorSubType;
+	u8  bmCapabilities;
+} __attribute__ ((packed));
+
+/* Union Functional Descriptor from CDC spec 5.2.3.8 */
+struct usb_cdc_union_desc {
+	u8	bLength;
+	u8	bDescriptorType;
+	u8	bDescriptorSubType;
+	u8	bMasterInterface0;
+	u8	bSlaveInterface0;
+	/* ... and there could be other slave interfaces */
+} __attribute__ ((packed));
+
+/* Line Coding Structure from CDC spec 6.2.13 */
+struct usb_cdc_line_coding {
+	u32 dwDTERate;
+	u8 bCharFormat;
+	u8 bParityType;
+	u8 bDataBits;
+} __attribute__ ((packed));
+
+
 /* Defines */
 
-#define GS_VERSION_STR			"v1.0"
-#define GS_VERSION_NUM			0x0100
+#define GS_VERSION_STR			"v2.0"
+#define GS_VERSION_NUM			0x0200
 
 #define GS_LONG_NAME			"Gadget Serial"
 #define GS_SHORT_NAME			"g_serial"
@@ -138,13 +212,13 @@
 
 #define GS_NUM_CONFIGS			1
 #define GS_NO_CONFIG_ID			0
-#define GS_BULK_CONFIG_ID		2
-
-#define GS_NUM_INTERFACES		1
-#define GS_INTERFACE_ID			0
-#define GS_ALT_INTERFACE_ID		0
+#define GS_BULK_CONFIG_ID		1
+#define GS_ACM_CONFIG_ID		2
 
-#define GS_NUM_ENDPOINTS		2
+#define GS_MAX_NUM_INTERFACES		2
+#define GS_BULK_INTERFACE_ID		0
+#define GS_CONTROL_INTERFACE_ID		0
+#define GS_DATA_INTERFACE_ID		1
 
 #define GS_MAX_DESC_LEN			256
 
@@ -156,9 +230,23 @@
 
 #define GS_CLOSE_TIMEOUT		15
 
+#define GS_DEFAULT_USE_ACM		0
+
+#define GS_DEFAULT_DTE_RATE		9600
+#define GS_DEFAULT_DATA_BITS		8
+#define GS_DEFAULT_PARITY		USB_CDC_NO_PARITY
+#define GS_DEFAULT_CHAR_FORMAT		USB_CDC_1_STOP_BITS
+
+/* select highspeed/fullspeed, hiding highspeed if not configured */
+#ifdef CONFIG_USB_GADGET_DUALSPEED
+#define GS_SPEED_SELECT(is_hs,hs,fs) ((is_hs) ? (hs) : (fs))
+#else
+#define GS_SPEED_SELECT(is_hs,hs,fs) (fs)
+#endif /* CONFIG_USB_GADGET_DUALSPEED */
+
 /* debug settings */
-#if G_SERIAL_DEBUG
-static int debug = G_SERIAL_DEBUG;
+#ifdef GS_DEBUG
+static int debug = 1;
 
 #define gs_debug(format, arg...) \
 	do { if (debug) printk(KERN_DEBUG format, ## arg); } while(0)
@@ -172,17 +260,19 @@
 #define gs_debug_level(level, format, arg...) \
 	do { } while(0)
 
-#endif /* G_SERIAL_DEBUG */
-
-
+#endif /* GS_DEBUG */
 
 /* Thanks to NetChip Technologies for donating this product ID.
  *
  * DO NOT REUSE THESE IDs with a protocol-incompatible driver!!  Ever!!
  * Instead:  allocate your own, using normal USB-IF procedures.
  */
-#define GS_VENDOR_ID	0x0525		/* NetChip */
-#define GS_PRODUCT_ID	0xa4a6		/* Linux-USB Serial Gadget */
+#define GS_VENDOR_ID			0x0525	/* NetChip */
+#define GS_PRODUCT_ID			0xa4a6	/* Linux-USB Serial Gadget */
+#define GS_CDC_PRODUCT_ID		0xa4a7	/* ... as CDC-ACM */
+
+#define GS_LOG2_NOTIFY_INTERVAL		5	/* 1 << 5 == 32 msec */
+#define GS_NOTIFY_MAXPACKET		8
 
 
 /* Structures */
@@ -213,6 +303,7 @@
 	int			port_in_use;	/* open/close in progress */
 	wait_queue_head_t	port_write_wait;/* waiting to write */
 	struct gs_buf		*port_write_buf;
+	struct usb_cdc_line_coding	port_line_coding;
 };
 
 /* the device structure holds info for the USB device */
@@ -220,8 +311,15 @@
 	struct usb_gadget	*dev_gadget;	/* gadget device pointer */
 	spinlock_t		dev_lock;	/* lock for set/reset config */
 	int			dev_config;	/* configuration number */
+	struct usb_ep		*dev_notify_ep;	/* address of notify endpoint */
 	struct usb_ep		*dev_in_ep;	/* address of in endpoint */
 	struct usb_ep		*dev_out_ep;	/* address of out endpoint */
+	struct usb_endpoint_descriptor		/* desciptor of notify ep */
+				*dev_notify_ep_desc;
+	struct usb_endpoint_descriptor		/* descriptor of in endpoint */
+				*dev_in_ep_desc;
+	struct usb_endpoint_descriptor		/* descriptor of out endpoint */
+				*dev_out_ep_desc;
 	struct usb_request	*dev_ctrl_req;	/* control request */
 	struct list_head	dev_req_list;	/* list of write requests */
 	int			dev_sched_port;	/* round robin port scheduled */
@@ -238,7 +336,7 @@
 /* tty driver */
 static int gs_open(struct tty_struct *tty, struct file *file);
 static void gs_close(struct tty_struct *tty, struct file *file);
-static int gs_write(struct tty_struct *tty, int from_user,
+static int gs_write(struct tty_struct *tty, 
 	const unsigned char *buf, int count);
 static void gs_put_char(struct tty_struct *tty, unsigned char ch);
 static void gs_flush_chars(struct tty_struct *tty);
@@ -264,12 +362,16 @@
 static void gs_unbind(struct usb_gadget *gadget);
 static int gs_setup(struct usb_gadget *gadget,
 	const struct usb_ctrlrequest *ctrl);
+static int gs_setup_standard(struct usb_gadget *gadget,
+	const struct usb_ctrlrequest *ctrl);
+static int gs_setup_class(struct usb_gadget *gadget,
+	const struct usb_ctrlrequest *ctrl);
 static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req);
 static void gs_disconnect(struct usb_gadget *gadget);
 static int gs_set_config(struct gs_dev *dev, unsigned config);
 static void gs_reset_config(struct gs_dev *dev);
-static int gs_build_config_desc(u8 *buf, enum usb_device_speed speed,
-		u8 type, unsigned int index);
+static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed,
+		u8 type, unsigned int index, int is_otg);
 
 static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len,
 	int kmalloc_flags);
@@ -303,6 +405,7 @@
 
 static const char *EP_IN_NAME;
 static const char *EP_OUT_NAME;
+static const char *EP_NOTIFY_NAME;
 
 static struct semaphore	gs_open_close_sem[GS_NUM_PORTS];
 
@@ -311,8 +414,8 @@
 
 static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE;
 
-static unsigned char gs_tmp_buf[GS_TMP_BUF_SIZE];
-static struct semaphore	gs_tmp_buf_sem;
+static unsigned int use_acm = GS_DEFAULT_USE_ACM;
+
 
 /* tty driver struct */
 static struct tty_operations gs_tty_ops = {
@@ -337,7 +440,7 @@
 	.speed =		USB_SPEED_HIGH,
 #else
 	.speed =		USB_SPEED_FULL,
-#endif
+#endif /* CONFIG_USB_GADGET_DUALSPEED */
 	.function =		GS_LONG_NAME,
 	.bind =			gs_bind,
 	.unbind =		gs_unbind,
@@ -357,15 +460,21 @@
 #define GS_MANUFACTURER_STR_ID	1
 #define GS_PRODUCT_STR_ID	2
 #define GS_SERIAL_STR_ID	3
-#define GS_CONFIG_STR_ID	4
+#define GS_BULK_CONFIG_STR_ID	4
+#define GS_ACM_CONFIG_STR_ID	5
+#define GS_CONTROL_STR_ID	6
+#define GS_DATA_STR_ID		7
 
-/* static strings, in iso 8859/1 */
-static char manufacturer[40];
+/* static strings, in UTF-8 */
+static char manufacturer[50];
 static struct usb_string gs_strings[] = {
 	{ GS_MANUFACTURER_STR_ID, manufacturer },
 	{ GS_PRODUCT_STR_ID, GS_LONG_NAME },
 	{ GS_SERIAL_STR_ID, "0" },
-	{ GS_CONFIG_STR_ID, "Bulk" },
+	{ GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" },
+	{ GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" },
+	{ GS_CONTROL_STR_ID, "Gadget Serial Control" },
+	{ GS_DATA_STR_ID, "Gadget Serial Data" },
 	{  } /* end of list */
 };
 
@@ -378,7 +487,8 @@
 	.bLength =		USB_DT_DEVICE_SIZE,
 	.bDescriptorType =	USB_DT_DEVICE,
 	.bcdUSB =		__constant_cpu_to_le16(0x0200),
-	.bDeviceClass =		USB_CLASS_VENDOR_SPEC,
+	.bDeviceSubClass =	0,
+	.bDeviceProtocol =	0,
 	.idVendor =		__constant_cpu_to_le16(GS_VENDOR_ID),
 	.idProduct =		__constant_cpu_to_le16(GS_PRODUCT_ID),
 	.iManufacturer =	GS_MANUFACTURER_STR_ID,
@@ -387,23 +497,104 @@
 	.bNumConfigurations =	GS_NUM_CONFIGS,
 };
 
-static const struct usb_config_descriptor gs_config_desc = {
+static struct usb_otg_descriptor gs_otg_descriptor = {
+	.bLength =		sizeof(gs_otg_descriptor),
+	.bDescriptorType =	USB_DT_OTG,
+	.bmAttributes =		USB_OTG_SRP,
+};
+
+static struct usb_config_descriptor gs_bulk_config_desc = {
 	.bLength =		USB_DT_CONFIG_SIZE,
 	.bDescriptorType =	USB_DT_CONFIG,
-	/* .wTotalLength set by gs_build_config_desc */
-	.bNumInterfaces =	GS_NUM_INTERFACES,
+	/* .wTotalLength computed dynamically */
+	.bNumInterfaces =	1,
 	.bConfigurationValue =	GS_BULK_CONFIG_ID,
-	.iConfiguration =	GS_CONFIG_STR_ID,
+	.iConfiguration =	GS_BULK_CONFIG_STR_ID,
 	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
 	.bMaxPower =		1,
 };
 
-static const struct usb_interface_descriptor gs_interface_desc = {
+static struct usb_config_descriptor gs_acm_config_desc = {
+	.bLength =		USB_DT_CONFIG_SIZE,
+	.bDescriptorType =	USB_DT_CONFIG,
+	/* .wTotalLength computed dynamically */
+	.bNumInterfaces =	2,
+	.bConfigurationValue =	GS_ACM_CONFIG_ID,
+	.iConfiguration =	GS_ACM_CONFIG_STR_ID,
+	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
+	.bMaxPower =		1,
+};
+
+static const struct usb_interface_descriptor gs_bulk_interface_desc = {
+	.bLength =		USB_DT_INTERFACE_SIZE,
+	.bDescriptorType =	USB_DT_INTERFACE,
+	.bInterfaceNumber =	GS_BULK_INTERFACE_ID,
+	.bNumEndpoints =	2,
+	.bInterfaceClass =	USB_CLASS_CDC_DATA,
+	.bInterfaceSubClass =	0,
+	.bInterfaceProtocol =	0,
+	.iInterface =		GS_DATA_STR_ID,
+};
+
+static const struct usb_interface_descriptor gs_control_interface_desc = {
 	.bLength =		USB_DT_INTERFACE_SIZE,
 	.bDescriptorType =	USB_DT_INTERFACE,
-	.bNumEndpoints =	GS_NUM_ENDPOINTS,
-	.bInterfaceClass =	USB_CLASS_VENDOR_SPEC,
-	.iInterface =		GS_CONFIG_STR_ID,
+	.bInterfaceNumber =	GS_CONTROL_INTERFACE_ID,
+	.bNumEndpoints =	1,
+	.bInterfaceClass =	USB_CLASS_COMM,
+	.bInterfaceSubClass =	USB_CDC_SUBCLASS_ACM,
+	.bInterfaceProtocol =	USB_CDC_CTRL_PROTO_AT,
+	.iInterface =		GS_CONTROL_STR_ID,
+};
+
+static const struct usb_interface_descriptor gs_data_interface_desc = {
+	.bLength =		USB_DT_INTERFACE_SIZE,
+	.bDescriptorType =	USB_DT_INTERFACE,
+	.bInterfaceNumber =	GS_DATA_INTERFACE_ID,
+	.bNumEndpoints =	2,
+	.bInterfaceClass =	USB_CLASS_CDC_DATA,
+	.bInterfaceSubClass =	0,
+	.bInterfaceProtocol =	0,
+	.iInterface =		GS_DATA_STR_ID,
+};
+
+static const struct usb_cdc_header_desc gs_header_desc = {
+	.bLength =		sizeof(gs_header_desc),
+	.bDescriptorType =	USB_DT_CS_INTERFACE,
+	.bDescriptorSubType =	USB_CDC_SUBTYPE_HEADER,
+	.bcdCDC =		__constant_cpu_to_le16(0x0110),
+};
+
+static const struct usb_cdc_call_mgmt_desc gs_call_mgmt_descriptor = {
+	.bLength =  		sizeof(gs_call_mgmt_descriptor),
+	.bDescriptorType = 	USB_DT_CS_INTERFACE,
+	.bDescriptorSubType = 	USB_CDC_SUBTYPE_CALL_MGMT,
+	.bmCapabilities = 	0,
+	.bDataInterface = 	1,	/* index of data interface */
+};
+
+static struct usb_cdc_acm_desc gs_acm_descriptor = {
+	.bLength =  		sizeof(gs_acm_descriptor),
+	.bDescriptorType = 	USB_DT_CS_INTERFACE,
+	.bDescriptorSubType = 	USB_CDC_SUBTYPE_ACM,
+	.bmCapabilities = 	0,
+};
+
+static const struct usb_cdc_union_desc gs_union_desc = {
+	.bLength =		sizeof(gs_union_desc),
+	.bDescriptorType =	USB_DT_CS_INTERFACE,
+	.bDescriptorSubType =	USB_CDC_SUBTYPE_UNION,
+	.bMasterInterface0 =	0,	/* index of control interface */
+	.bSlaveInterface0 =	1,	/* index of data interface */
+};
+ 
+static struct usb_endpoint_descriptor gs_fullspeed_notify_desc = {
+	.bLength =		USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType =	USB_DT_ENDPOINT,
+	.bEndpointAddress =	USB_DIR_IN,
+	.bmAttributes =		USB_ENDPOINT_XFER_INT,
+	.wMaxPacketSize =	__constant_cpu_to_le16(GS_NOTIFY_MAXPACKET),
+	.bInterval =		1 << GS_LOG2_NOTIFY_INTERVAL,
 };
 
 static struct usb_endpoint_descriptor gs_fullspeed_in_desc = {
@@ -420,6 +611,38 @@
 	.bmAttributes =		USB_ENDPOINT_XFER_BULK,
 };
 
+static const struct usb_descriptor_header *gs_bulk_fullspeed_function[] = {
+	(struct usb_descriptor_header *) &gs_otg_descriptor,
+	(struct usb_descriptor_header *) &gs_bulk_interface_desc,
+	(struct usb_descriptor_header *) &gs_fullspeed_in_desc,
+	(struct usb_descriptor_header *) &gs_fullspeed_out_desc,
+	NULL,
+};
+
+static const struct usb_descriptor_header *gs_acm_fullspeed_function[] = {
+	(struct usb_descriptor_header *) &gs_otg_descriptor,
+	(struct usb_descriptor_header *) &gs_control_interface_desc,
+	(struct usb_descriptor_header *) &gs_header_desc,
+	(struct usb_descriptor_header *) &gs_call_mgmt_descriptor,
+	(struct usb_descriptor_header *) &gs_acm_descriptor,
+	(struct usb_descriptor_header *) &gs_union_desc,
+	(struct usb_descriptor_header *) &gs_fullspeed_notify_desc,
+	(struct usb_descriptor_header *) &gs_data_interface_desc,
+	(struct usb_descriptor_header *) &gs_fullspeed_in_desc,
+	(struct usb_descriptor_header *) &gs_fullspeed_out_desc,
+	NULL,
+};
+
+#ifdef CONFIG_USB_GADGET_DUALSPEED
+static struct usb_endpoint_descriptor gs_highspeed_notify_desc = {
+	.bLength =		USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType =	USB_DT_ENDPOINT,
+	.bEndpointAddress =	USB_DIR_IN,
+	.bmAttributes =		USB_ENDPOINT_XFER_INT,
+	.wMaxPacketSize =	__constant_cpu_to_le16(GS_NOTIFY_MAXPACKET),
+	.bInterval =		GS_LOG2_NOTIFY_INTERVAL+4,
+};
+
 static struct usb_endpoint_descriptor gs_highspeed_in_desc = {
 	.bLength =		USB_DT_ENDPOINT_SIZE,
 	.bDescriptorType =	USB_DT_ENDPOINT,
@@ -434,16 +657,37 @@
 	.wMaxPacketSize =	__constant_cpu_to_le16(512),
 };
 
-#ifdef CONFIG_USB_GADGET_DUALSPEED
 static struct usb_qualifier_descriptor gs_qualifier_desc = {
 	.bLength =		sizeof(struct usb_qualifier_descriptor),
 	.bDescriptorType =	USB_DT_DEVICE_QUALIFIER,
 	.bcdUSB =		__constant_cpu_to_le16 (0x0200),
-	.bDeviceClass =		USB_CLASS_VENDOR_SPEC,
 	/* assumes ep0 uses the same value for both speeds ... */
 	.bNumConfigurations =	GS_NUM_CONFIGS,
 };
-#endif
+
+static const struct usb_descriptor_header *gs_bulk_highspeed_function[] = {
+	(struct usb_descriptor_header *) &gs_otg_descriptor,
+	(struct usb_descriptor_header *) &gs_bulk_interface_desc,
+	(struct usb_descriptor_header *) &gs_highspeed_in_desc,
+	(struct usb_descriptor_header *) &gs_highspeed_out_desc,
+	NULL,
+};
+
+static const struct usb_descriptor_header *gs_acm_highspeed_function[] = {
+	(struct usb_descriptor_header *) &gs_otg_descriptor,
+	(struct usb_descriptor_header *) &gs_control_interface_desc,
+	(struct usb_descriptor_header *) &gs_header_desc,
+	(struct usb_descriptor_header *) &gs_call_mgmt_descriptor,
+	(struct usb_descriptor_header *) &gs_acm_descriptor,
+	(struct usb_descriptor_header *) &gs_union_desc,
+	(struct usb_descriptor_header *) &gs_highspeed_notify_desc,
+	(struct usb_descriptor_header *) &gs_data_interface_desc,
+	(struct usb_descriptor_header *) &gs_highspeed_in_desc,
+	(struct usb_descriptor_header *) &gs_highspeed_out_desc,
+	NULL,
+};
+
+#endif /* CONFIG_USB_GADGET_DUALSPEED */
 
 
 /* Module */
@@ -451,20 +695,23 @@
 MODULE_AUTHOR("Al Borchers");
 MODULE_LICENSE("GPL");
 
-#if G_SERIAL_DEBUG
-module_param(debug, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on, larger values for more messages");
+#ifdef GS_DEBUG
+module_param(debug, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on");
 #endif
 
-module_param(read_q_size, int, 0);
+module_param(read_q_size, uint, S_IRUGO);
 MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32");
 
-module_param(write_q_size, int, 0);
+module_param(write_q_size, uint, S_IRUGO);
 MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32");
 
-module_param(write_buf_size, int, 0);
+module_param(write_buf_size, uint, S_IRUGO);
 MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192");
 
+module_param(use_acm, uint, S_IRUGO);
+MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no");
+
 module_init(gs_module_init);
 module_exit(gs_module_exit);
 
@@ -503,8 +750,6 @@
 	for (i=0; i < GS_NUM_PORTS; i++)
 		sema_init(&gs_open_close_sem[i], 1);
 
-	sema_init(&gs_tmp_buf_sem, 1);
-
 	retval = tty_register_driver(gs_tty_driver);
 	if (retval) {
 		usb_gadget_unregister_driver(&gs_gadget_driver);
@@ -544,13 +789,12 @@
 	struct gs_dev *dev;
 	struct gs_buf *buf;
 	struct semaphore *sem;
+	int ret;
 
 	port_num = tty->index;
 
 	gs_debug("gs_open: (%d,%p,%p)\n", port_num, tty, file);
 
-	tty->driver_data = NULL;
-
 	if (port_num < 0 || port_num >= GS_NUM_PORTS) {
 		printk(KERN_ERR "gs_open: (%d,%p,%p) invalid port number\n",
 			port_num, tty, file);
@@ -579,9 +823,8 @@
 		printk(KERN_ERR
 			"gs_open: (%d,%p,%p) device is not connected\n",
 			port_num, tty, file);
-		spin_unlock_irqrestore(&dev->dev_lock, flags);
-		up(sem);
-		return -ENODEV;
+		ret = -ENODEV;
+		goto exit_unlock_dev;
 	}
 
 	port = dev->dev_port[port_num];
@@ -589,9 +832,8 @@
 	if (port == NULL) {
 		printk(KERN_ERR "gs_open: (%d,%p,%p) NULL port pointer\n",
 			port_num, tty, file);
-		spin_unlock_irqrestore(&dev->dev_lock, flags);
-		up(sem);
-		return -ENODEV;
+		ret = -ENODEV;
+		goto exit_unlock_dev;
 	}
 
 	spin_lock(&port->port_lock);
@@ -600,20 +842,20 @@
 	if (port->port_dev == NULL) {
 		printk(KERN_ERR "gs_open: (%d,%p,%p) port disconnected (1)\n",
 			port_num, tty, file);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		up(sem);
-		return -EIO;
+		ret = -EIO;
+		goto exit_unlock_port;
 	}
 
 	if (port->port_open_count > 0) {
 		++port->port_open_count;
-		spin_unlock_irqrestore(&port->port_lock, flags);
 		gs_debug("gs_open: (%d,%p,%p) already open\n",
 			port_num, tty, file);
-		up(sem);
-		return 0;
+		ret = 0;
+		goto exit_unlock_port;
 	}
 
+	tty->driver_data = NULL;
+
 	/* mark port as in use, we can drop port lock and sleep if necessary */
 	port->port_in_use = 1;
 
@@ -629,18 +871,16 @@
 				"gs_open: (%d,%p,%p) port disconnected (2)\n",
 				port_num, tty, file);
 			port->port_in_use = 0;
-			spin_unlock_irqrestore(&port->port_lock, flags);
-			up(sem);
-			return -EIO;
+			ret = -EIO;
+			goto exit_unlock_port;
 		}
 
 		if ((port->port_write_buf=buf) == NULL) {
 			printk(KERN_ERR "gs_open: (%d,%p,%p) cannot allocate port write buffer\n",
 				port_num, tty, file);
 			port->port_in_use = 0;
-			spin_unlock_irqrestore(&port->port_lock, flags);
-			up(sem);
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto exit_unlock_port;
 		}
 
 	}
@@ -652,9 +892,8 @@
 		printk(KERN_ERR "gs_open: (%d,%p,%p) port disconnected (3)\n",
 			port_num, tty, file);
 		port->port_in_use = 0;
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		up(sem);
-		return -EIO;
+		ret = -EIO;
+		goto exit_unlock_port;
 	}
 
 	tty->driver_data = port;
@@ -662,12 +901,20 @@
 	port->port_open_count = 1;
 	port->port_in_use = 0;
 
+	gs_debug("gs_open: (%d,%p,%p) completed\n", port_num, tty, file);
+
+	ret = 0;
+
+exit_unlock_port:
 	spin_unlock_irqrestore(&port->port_lock, flags);
 	up(sem);
+	return ret;
 
-	gs_debug("gs_open: (%d,%p,%p) completed\n", port_num, tty, file);
+exit_unlock_dev:
+	spin_unlock_irqrestore(&dev->dev_lock, flags);
+	up(sem);
+	return ret;
 
-	return 0;
 }
 
 /*
@@ -695,24 +942,18 @@
 		printk(KERN_ERR
 			"gs_close: (%d,%p,%p) port is already closed\n",
 			port->port_num, tty, file);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		up(sem);
-		return;
+		goto exit;
 	}
 
-	if (port->port_open_count > 0) {
+	if (port->port_open_count > 1) {
 		--port->port_open_count;
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		up(sem);
-		return;
+		goto exit;
 	}
 
 	/* free disconnected port on final close */
 	if (port->port_dev == NULL) {
 		kfree(port);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		up(sem);
-		return;
+		goto exit;
 	}
 
 	/* mark port as closed but in use, we can drop port lock */
@@ -733,9 +974,7 @@
 	/* (might have happened during the above sleep) */
 	if (port->port_dev == NULL) {
 		kfree(port);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		up(sem);
-		return;
+		goto exit;
 	}
 
 	gs_buf_clear(port->port_write_buf);
@@ -744,20 +983,22 @@
 	port->port_tty = NULL;
 	port->port_in_use = 0;
 
-	spin_unlock_irqrestore(&port->port_lock, flags);
-	up(sem);
-
 	gs_debug("gs_close: (%d,%p,%p) completed\n",
 		port->port_num, tty, file);
+
+exit:
+	spin_unlock_irqrestore(&port->port_lock, flags);
+	up(sem);
 }
 
 /*
  * gs_write
  */
-static int gs_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
+static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	unsigned long flags;
 	struct gs_port *port = tty->driver_data;
+	int ret;
 
 	if (port == NULL) {
 		printk(KERN_ERR "gs_write: NULL port pointer\n");
@@ -770,54 +1011,36 @@
 	if (count == 0)
 		return 0;
 
-	/* copy from user into tmp buffer, get tmp_buf semaphore */
-	if (from_user) {
-		if (count > GS_TMP_BUF_SIZE)
-			count = GS_TMP_BUF_SIZE;
-		down(&gs_tmp_buf_sem);
-		if (copy_from_user(gs_tmp_buf, buf, count) != 0) {
-			up(&gs_tmp_buf_sem);
-			printk(KERN_ERR
-			"gs_write: (%d,%p) cannot copy from user space\n",
-				port->port_num, tty);
-			return -EFAULT;
-		}
-		buf = gs_tmp_buf;
-	}
-
 	spin_lock_irqsave(&port->port_lock, flags);
 
 	if (port->port_dev == NULL) {
 		printk(KERN_ERR "gs_write: (%d,%p) port is not connected\n",
 			port->port_num, tty);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		if (from_user)
-			up(&gs_tmp_buf_sem);
-		return -EIO;
+		ret = -EIO;
+		goto exit;
 	}
 
 	if (port->port_open_count == 0) {
 		printk(KERN_ERR "gs_write: (%d,%p) port is closed\n",
 			port->port_num, tty);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		if (from_user)
-			up(&gs_tmp_buf_sem);
-		return -EBADF;
+		ret = -EBADF;
+		goto exit;
 	}
 
 	count = gs_buf_put(port->port_write_buf, buf, count);
 
 	spin_unlock_irqrestore(&port->port_lock, flags);
 
-	if (from_user)
-		up(&gs_tmp_buf_sem);
-
 	gs_send(gs_device);
 
 	gs_debug("gs_write: (%d,%p) wrote %d bytes\n", port->port_num, tty,
 		count);
 
 	return count;
+
+exit:
+	spin_unlock_irqrestore(&port->port_lock, flags);
+	return ret;
 }
 
 /*
@@ -840,19 +1063,18 @@
 	if (port->port_dev == NULL) {
 		printk(KERN_ERR "gs_put_char: (%d,%p) port is not connected\n",
 			port->port_num, tty);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		return;
+		goto exit;
 	}
 
 	if (port->port_open_count == 0) {
 		printk(KERN_ERR "gs_put_char: (%d,%p) port is closed\n",
 			port->port_num, tty);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		return;
+		goto exit;
 	}
 
 	gs_buf_put(port->port_write_buf, &ch, 1);
 
+exit:
 	spin_unlock_irqrestore(&port->port_lock, flags);
 }
 
@@ -877,20 +1099,23 @@
 		printk(KERN_ERR
 			"gs_flush_chars: (%d,%p) port is not connected\n",
 			port->port_num, tty);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		return;
+		goto exit;
 	}
 
 	if (port->port_open_count == 0) {
 		printk(KERN_ERR "gs_flush_chars: (%d,%p) port is closed\n",
 			port->port_num, tty);
-		spin_unlock_irqrestore(&port->port_lock, flags);
-		return;
+		goto exit;
 	}
 
 	spin_unlock_irqrestore(&port->port_lock, flags);
 
 	gs_send(gs_device);
+
+	return;
+
+exit:
+	spin_unlock_irqrestore(&port->port_lock, flags);
 }
 
 /*
@@ -1087,17 +1312,16 @@
 	if (len < size)
 		size = len;
 
-	if (size == 0) {
-		spin_unlock(&port->port_lock);
-		return 0;
-	}
+	if (size == 0)
+		goto exit;
 
 	size = gs_buf_get(port->port_write_buf, packet, size);
 
-	wake_up_interruptible(&port->port_tty->write_wait);
+	if (port->port_tty)
+		wake_up_interruptible(&port->port_tty->write_wait);
 
+exit:
 	spin_unlock(&port->port_lock);
-
 	return size;
 }
 
@@ -1118,6 +1342,7 @@
 {
 	unsigned int len;
 	struct gs_port *port;
+	int ret;
 
 	/* TEMPORARY -- only port 0 is supported right now */
 	port = dev->dev_port[0];
@@ -1130,18 +1355,25 @@
 
 	spin_lock(&port->port_lock);
 
+	if (port->port_open_count == 0) {
+		printk(KERN_ERR "gs_recv_packet: port=%d, port is closed\n",
+			port->port_num);
+		ret = -EIO;
+		goto exit;
+	}
+
 	if (port->port_tty == NULL) {
 		printk(KERN_ERR "gs_recv_packet: port=%d, NULL tty pointer\n",
 			port->port_num);
-		spin_unlock(&port->port_lock);
-		return -EIO;
+		ret = -EIO;
+		goto exit;
 	}
 
 	if (port->port_tty->magic != TTY_MAGIC) {
 		printk(KERN_ERR "gs_recv_packet: port=%d, bad tty magic\n",
 			port->port_num);
-		spin_unlock(&port->port_lock);
-		return -EIO;
+		ret = -EIO;
+		goto exit;
 	}
 
 	len = (unsigned int)(TTY_FLIPBUF_SIZE - port->port_tty->flip.count);
@@ -1156,9 +1388,11 @@
 		wake_up_interruptible(&port->port_tty->read_wait);
 	}
 
-	spin_unlock(&port->port_lock);
+	ret = 0;
 
-	return 0;
+exit:
+	spin_unlock(&port->port_lock);
+	return ret;
 }
 
 /*
@@ -1263,21 +1497,7 @@
 	struct usb_ep *ep;
 	struct gs_dev *dev;
 
-	usb_ep_autoconfig_reset(gadget);
-
-	ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc);
-	if (!ep)
-		goto autoconf_fail;
-	EP_IN_NAME = ep->name;
-	ep->driver_data = ep;	/* claim the endpoint */
-
-	ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc);
-	if (!ep)
-		goto autoconf_fail;
-	EP_OUT_NAME = ep->name;
-	ep->driver_data = ep;	/* claim the endpoint */
-
-	/* device specific bcdDevice value in device descriptor */
+	/* device specific */
 	if (gadget_is_net2280(gadget)) {
 		gs_device_desc.bcdDevice =
 			__constant_cpu_to_le16(GS_VERSION_NUM|0x0001);
@@ -1287,9 +1507,13 @@
 	} else if (gadget_is_sh(gadget)) {
 		gs_device_desc.bcdDevice =
 			__constant_cpu_to_le16(GS_VERSION_NUM|0x0003);
+		/* sh doesn't support multiple interfaces or configs */
+		use_acm = 0;
 	} else if (gadget_is_sa1100(gadget)) {
 		gs_device_desc.bcdDevice =
 			__constant_cpu_to_le16(GS_VERSION_NUM|0x0004);
+		/* sa1100 doesn't support necessary endpoints */
+		use_acm = 0;
 	} else if (gadget_is_goku(gadget)) {
 		gs_device_desc.bcdDevice =
 			__constant_cpu_to_le16(GS_VERSION_NUM|0x0005);
@@ -1302,6 +1526,12 @@
 	} else if (gadget_is_lh7a40x(gadget)) {
 		gs_device_desc.bcdDevice =
 			__constant_cpu_to_le16(GS_VERSION_NUM|0x0008);
+	} else if (gadget_is_n9604(gadget)) {
+		gs_device_desc.bcdDevice =
+			__constant_cpu_to_le16(GS_VERSION_NUM|0x0009);
+	} else if (gadget_is_pxa27x(gadget)) {
+		gs_device_desc.bcdDevice =
+			__constant_cpu_to_le16(GS_VERSION_NUM|0x0011);
 	} else {
 		printk(KERN_WARNING "gs_bind: controller '%s' not recognized\n",
 			gadget->name);
@@ -1310,11 +1540,44 @@
 			__constant_cpu_to_le16(GS_VERSION_NUM|0x0099);
 	}
 
+	usb_ep_autoconfig_reset(gadget);
+
+	ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc);
+	if (!ep)
+		goto autoconf_fail;
+	EP_IN_NAME = ep->name;
+	ep->driver_data = ep;	/* claim the endpoint */
+
+	ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc);
+	if (!ep)
+		goto autoconf_fail;
+	EP_OUT_NAME = ep->name;
+	ep->driver_data = ep;	/* claim the endpoint */
+
+	if (use_acm) {
+		ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc);
+		if (!ep) {
+			printk(KERN_ERR "gs_bind: cannot run ACM on %s\n", gadget->name);
+			goto autoconf_fail;
+		}
+		gs_device_desc.idProduct = __constant_cpu_to_le16(
+						GS_CDC_PRODUCT_ID),
+		EP_NOTIFY_NAME = ep->name;
+		ep->driver_data = ep;	/* claim the endpoint */
+	}
+
+	gs_device_desc.bDeviceClass = use_acm
+		? USB_CLASS_COMM : USB_CLASS_VENDOR_SPEC;
 	gs_device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
+
 #ifdef CONFIG_USB_GADGET_DUALSPEED
+	gs_qualifier_desc.bDeviceClass = use_acm
+		? USB_CLASS_COMM : USB_CLASS_VENDOR_SPEC;
 	/* assume ep0 uses the same packet size for both speeds */
 	gs_qualifier_desc.bMaxPacketSize0 = gs_device_desc.bMaxPacketSize0;
 	/* assume endpoints are dual-speed */
+	gs_highspeed_notify_desc.bEndpointAddress =
+		gs_fullspeed_notify_desc.bEndpointAddress;
 	gs_highspeed_in_desc.bEndpointAddress =
 		gs_fullspeed_in_desc.bEndpointAddress;
 	gs_highspeed_out_desc.bEndpointAddress =
@@ -1323,11 +1586,17 @@
 
 	usb_gadget_set_selfpowered(gadget);
 
+	if (gadget->is_otg) {
+		gs_otg_descriptor.bmAttributes |= USB_OTG_HNP,
+		gs_bulk_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+		gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+	}
+
 	gs_device = dev = kmalloc(sizeof(struct gs_dev), GFP_KERNEL);
 	if (dev == NULL)
 		return -ENOMEM;
 
-	snprintf (manufacturer, sizeof(manufacturer),
+	snprintf(manufacturer, sizeof(manufacturer),
 		UTS_SYSNAME " " UTS_RELEASE " with %s", gadget->name);
 
 	memset(dev, 0, sizeof(struct gs_dev));
@@ -1377,8 +1646,10 @@
 
 	/* read/write requests already freed, only control request remains */
 	if (dev != NULL) {
-		if (dev->dev_ctrl_req != NULL)
+		if (dev->dev_ctrl_req != NULL) {
 			gs_free_req(gadget->ep0, dev->dev_ctrl_req);
+			dev->dev_ctrl_req = NULL;
+		}
 		gs_free_ports(dev);
 		kfree(dev);
 		set_gadget_data(gadget, NULL);
@@ -1397,10 +1668,51 @@
  * Returns the size of the data sent to the host, or a negative
  * error number.
  */
-static int gs_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
+static int gs_setup(struct usb_gadget *gadget,
+	const struct usb_ctrlrequest *ctrl)
+{
+	int ret = -EOPNOTSUPP;
+	struct gs_dev *dev = get_gadget_data(gadget);
+	struct usb_request *req = dev->dev_ctrl_req;
+
+	switch (ctrl->bRequestType & USB_TYPE_MASK) {
+	case USB_TYPE_STANDARD:
+		ret = gs_setup_standard(gadget,ctrl);
+		break;
+
+	case USB_TYPE_CLASS:
+		ret = gs_setup_class(gadget,ctrl);
+		break;
+
+	default:
+		printk(KERN_ERR "gs_setup: unknown request, type=%02x, request=%02x, value=%04x, index=%04x, length=%d\n",
+			ctrl->bRequestType, ctrl->bRequest, ctrl->wValue,
+			ctrl->wIndex, ctrl->wLength);
+		break;
+	}
+
+	/* respond with data transfer before status phase? */
+	if (ret >= 0) {
+		req->length = ret;
+		req->zero = ret < ctrl->wLength
+				&& (ret % gadget->ep0->maxpacket) == 0;
+		ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
+		if (ret < 0) {
+			printk(KERN_ERR "gs_setup: cannot queue response, ret=%d\n",
+				ret);
+			req->status = 0;
+			gs_setup_complete(gadget->ep0, req);
+		}
+	}
+
+	/* device either stalls (ret < 0) or reports success */
+	return ret;
+}
+
+static int gs_setup_standard(struct usb_gadget *gadget,
+	const struct usb_ctrlrequest *ctrl)
 {
 	int ret = -EOPNOTSUPP;
-	unsigned int sv_config;
 	struct gs_dev *dev = get_gadget_data(gadget);
 	struct usb_request *req = dev->dev_ctrl_req;
 
@@ -1426,10 +1738,14 @@
 			break;
 
 		case USB_DT_OTHER_SPEED_CONFIG:
+			if (!gadget->is_dualspeed)
+				break;
+			/* fall through */
 #endif /* CONFIG_USB_GADGET_DUALSPEED */
 		case USB_DT_CONFIG:
-			ret = gs_build_config_desc(req->buf, gadget->speed,
-				ctrl->wValue >> 8, ctrl->wValue & 0xff);
+			ret = gs_build_config_buf(req->buf, gadget->speed,
+				ctrl->wValue >> 8, ctrl->wValue & 0xff,
+				gadget->is_otg);
 			if (ret >= 0)
 				ret = min(ctrl->wLength, (u16)ret);
 			break;
@@ -1460,59 +1776,106 @@
 		break;
 
 	case USB_REQ_SET_INTERFACE:
-		if (ctrl->bRequestType != USB_RECIP_INTERFACE)
+		if (ctrl->bRequestType != USB_RECIP_INTERFACE
+		|| !dev->dev_config || ctrl->wIndex >= GS_MAX_NUM_INTERFACES)
 			break;
-		spin_lock(&dev->dev_lock);
 		if (dev->dev_config == GS_BULK_CONFIG_ID
-		&& ctrl->wIndex == GS_INTERFACE_ID
-		&& ctrl->wValue == GS_ALT_INTERFACE_ID) {
-			sv_config = dev->dev_config;
-			/* since there is only one interface, setting the */
-			/* interface is equivalent to setting the config */
-			gs_reset_config(dev);
-			gs_set_config(dev, sv_config);
-			ret = 0;
+		&& ctrl->wIndex != GS_BULK_INTERFACE_ID)
+			break;
+		/* no alternate interface settings */
+		if (ctrl->wValue != 0)
+			break;
+		spin_lock(&dev->dev_lock);
+		/* PXA hardware partially handles SET_INTERFACE;
+		 * we need to kluge around that interference.  */
+		if (gadget_is_pxa(gadget)) {
+			ret = gs_set_config(dev, use_acm ?
+				GS_ACM_CONFIG_ID : GS_BULK_CONFIG_ID);
+			goto set_interface_done;
+		}
+		if (dev->dev_config != GS_BULK_CONFIG_ID
+		&& ctrl->wIndex == GS_CONTROL_INTERFACE_ID) {
+			if (dev->dev_notify_ep) {
+				usb_ep_disable(dev->dev_notify_ep);
+				usb_ep_enable(dev->dev_notify_ep, dev->dev_notify_ep_desc);
+			}
+		} else {
+			usb_ep_disable(dev->dev_in_ep);
+			usb_ep_disable(dev->dev_out_ep);
+			usb_ep_enable(dev->dev_in_ep, dev->dev_in_ep_desc);
+			usb_ep_enable(dev->dev_out_ep, dev->dev_out_ep_desc);
 		}
+		ret = 0;
+set_interface_done:
 		spin_unlock(&dev->dev_lock);
 		break;
 
 	case USB_REQ_GET_INTERFACE:
-		if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))
+		if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)
+		|| dev->dev_config == GS_NO_CONFIG_ID)
 			break;
-		if (dev->dev_config == GS_NO_CONFIG_ID)
-			break;
-		if (ctrl->wIndex != GS_INTERFACE_ID) {
+		if (ctrl->wIndex >= GS_MAX_NUM_INTERFACES
+		|| (dev->dev_config == GS_BULK_CONFIG_ID
+		&& ctrl->wIndex != GS_BULK_INTERFACE_ID)) {
 			ret = -EDOM;
 			break;
 		}
-		*(u8 *)req->buf = GS_ALT_INTERFACE_ID;
+		/* no alternate interface settings */
+		*(u8 *)req->buf = 0;
 		ret = min(ctrl->wLength, (u16)1);
 		break;
 
 	default:
-		printk(KERN_ERR "gs_setup: unknown request, type=%02x, request=%02x, value=%04x, index=%04x, length=%d\n",
+		printk(KERN_ERR "gs_setup: unknown standard request, type=%02x, request=%02x, value=%04x, index=%04x, length=%d\n",
 			ctrl->bRequestType, ctrl->bRequest, ctrl->wValue,
 			ctrl->wIndex, ctrl->wLength);
 		break;
-
 	}
 
-	/* respond with data transfer before status phase? */
-	if (ret >= 0) {
-		req->length = ret;
-		req->zero = ret < ctrl->wLength
-				&& (ret % gadget->ep0->maxpacket) == 0;
-		ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
-		if (ret < 0) {
-			printk(KERN_ERR
-				"gs_setup: cannot queue response, ret=%d\n",
-				ret);
-			req->status = 0;
-			gs_setup_complete(gadget->ep0, req);
+	return ret;
+}
+
+static int gs_setup_class(struct usb_gadget *gadget,
+	const struct usb_ctrlrequest *ctrl)
+{
+	int ret = -EOPNOTSUPP;
+	struct gs_dev *dev = get_gadget_data(gadget);
+	struct gs_port *port = dev->dev_port[0];	/* ACM only has one port */
+	struct usb_request *req = dev->dev_ctrl_req;
+
+	switch (ctrl->bRequest) {
+	case USB_CDC_REQ_SET_LINE_CODING:
+		ret = min(ctrl->wLength,
+			(u16)sizeof(struct usb_cdc_line_coding));
+		if (port) {
+			spin_lock(&port->port_lock);
+			memcpy(&port->port_line_coding, req->buf, ret);
+			spin_unlock(&port->port_lock);
 		}
+		break;
+
+	case USB_CDC_REQ_GET_LINE_CODING:
+		port = dev->dev_port[0];	/* ACM only has one port */
+		ret = min(ctrl->wLength,
+			(u16)sizeof(struct usb_cdc_line_coding));
+		if (port) {
+			spin_lock(&port->port_lock);
+			memcpy(req->buf, &port->port_line_coding, ret);
+			spin_unlock(&port->port_lock);
+		}
+		break;
+
+	case USB_CDC_REQ_SET_CONTROL_LINE_STATE:
+		ret = 0;
+		break;
+
+	default:
+		printk(KERN_ERR "gs_setup: unknown class request, type=%02x, request=%02x, value=%04x, index=%04x, length=%d\n",
+			ctrl->bRequestType, ctrl->bRequest, ctrl->wValue,
+			ctrl->wIndex, ctrl->wLength);
+		break;
 	}
 
-	/* device either stalls (ret < 0) or reports success */
 	return ret;
 }
 
@@ -1571,6 +1934,7 @@
 	int ret = 0;
 	struct usb_gadget *gadget = dev->dev_gadget;
 	struct usb_ep *ep;
+	struct usb_endpoint_descriptor *ep_desc;
 	struct usb_request *req;
 	struct gs_req_entry *req_entry;
 
@@ -1584,55 +1948,90 @@
 
 	gs_reset_config(dev);
 
-	if (config == GS_NO_CONFIG_ID)
+	switch (config) {
+	case GS_NO_CONFIG_ID:
 		return 0;
-
-	if (config != GS_BULK_CONFIG_ID)
+	case GS_BULK_CONFIG_ID:
+		if (use_acm)
+			return -EINVAL;
+		/* device specific optimizations */
+		if (gadget_is_net2280(gadget))
+			net2280_set_fifo_mode(gadget, 1);
+		break;
+	case GS_ACM_CONFIG_ID:
+		if (!use_acm)
+			return -EINVAL;
+		/* device specific optimizations */
+		if (gadget_is_net2280(gadget))
+			net2280_set_fifo_mode(gadget, 1);
+		break;
+	default:
 		return -EINVAL;
+	}
 
-	/* device specific optimizations */
-	if (gadget_is_net2280(gadget))
-		net2280_set_fifo_mode(gadget, 1);
+	dev->dev_config = config;
 
 	gadget_for_each_ep(ep, gadget) {
 
-		if (strcmp(ep->name, EP_IN_NAME) == 0) {
-			ret = usb_ep_enable(ep,
-				gadget->speed == USB_SPEED_HIGH ?
- 				&gs_highspeed_in_desc : &gs_fullspeed_in_desc);
+		if (EP_NOTIFY_NAME
+		&& strcmp(ep->name, EP_NOTIFY_NAME) == 0) {
+			ep_desc = GS_SPEED_SELECT(
+				gadget->speed == USB_SPEED_HIGH,
+				&gs_highspeed_notify_desc,
+				&gs_fullspeed_notify_desc);
+			ret = usb_ep_enable(ep,ep_desc);
+			if (ret == 0) {
+				ep->driver_data = dev;
+				dev->dev_notify_ep = ep;
+				dev->dev_notify_ep_desc = ep_desc;
+			} else {
+				printk(KERN_ERR "gs_set_config: cannot enable notify endpoint %s, ret=%d\n",
+					ep->name, ret);
+				goto exit_reset_config;
+			}
+		}
+
+		else if (strcmp(ep->name, EP_IN_NAME) == 0) {
+			ep_desc = GS_SPEED_SELECT(
+				gadget->speed == USB_SPEED_HIGH,
+ 				&gs_highspeed_in_desc,
+				&gs_fullspeed_in_desc);
+			ret = usb_ep_enable(ep,ep_desc);
 			if (ret == 0) {
 				ep->driver_data = dev;
 				dev->dev_in_ep = ep;
+				dev->dev_in_ep_desc = ep_desc;
 			} else {
 				printk(KERN_ERR "gs_set_config: cannot enable in endpoint %s, ret=%d\n",
 					ep->name, ret);
-				gs_reset_config(dev);
-				return ret;
+				goto exit_reset_config;
 			}
 		}
 
 		else if (strcmp(ep->name, EP_OUT_NAME) == 0) {
-			ret = usb_ep_enable(ep,
-				gadget->speed == USB_SPEED_HIGH ?
-				&gs_highspeed_out_desc :
+			ep_desc = GS_SPEED_SELECT(
+				gadget->speed == USB_SPEED_HIGH,
+				&gs_highspeed_out_desc,
 				&gs_fullspeed_out_desc);
+			ret = usb_ep_enable(ep,ep_desc);
 			if (ret == 0) {
 				ep->driver_data = dev;
 				dev->dev_out_ep = ep;
+				dev->dev_out_ep_desc = ep_desc;
 			} else {
 				printk(KERN_ERR "gs_set_config: cannot enable out endpoint %s, ret=%d\n",
 					ep->name, ret);
-				gs_reset_config(dev);
-				return ret;
+				goto exit_reset_config;
 			}
 		}
 
 	}
 
-	if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL) {
-		gs_reset_config(dev);
+	if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL
+	|| (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) {
 		printk(KERN_ERR "gs_set_config: cannot find endpoints\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto exit_reset_config;
 	}
 
 	/* allocate and queue read requests */
@@ -1645,10 +2044,9 @@
 					ret);
 			}
 		} else {
-			gs_reset_config(dev);
-			printk(KERN_ERR
-			"gs_set_config: cannot allocate read requests\n");
-			return -ENOMEM;
+			printk(KERN_ERR "gs_set_config: cannot allocate read requests\n");
+			ret = -ENOMEM;
+			goto exit_reset_config;
 		}
 	}
 
@@ -1659,20 +2057,22 @@
 			req_entry->re_req->complete = gs_write_complete;
 			list_add(&req_entry->re_entry, &dev->dev_req_list);
 		} else {
-			gs_reset_config(dev);
-			printk(KERN_ERR
-			"gs_set_config: cannot allocate write requests\n");
-			return -ENOMEM;
+			printk(KERN_ERR "gs_set_config: cannot allocate write requests\n");
+			ret = -ENOMEM;
+			goto exit_reset_config;
 		}
 	}
 
-	dev->dev_config = config;
-
-	printk(KERN_INFO "gs_set_config: %s configured for %s speed\n",
+	printk(KERN_INFO "gs_set_config: %s configured, %s speed %s config\n",
 		GS_LONG_NAME,
-		gadget->speed == USB_SPEED_HIGH ? "high" : "full");
+		gadget->speed == USB_SPEED_HIGH ? "high" : "full",
+		config == GS_BULK_CONFIG_ID ? "BULK" : "CDC-ACM");
 
 	return 0;
+
+exit_reset_config:
+	gs_reset_config(dev);
+	return ret;
 }
 
 /*
@@ -1709,6 +2109,10 @@
 
 	/* disable endpoints, forcing completion of pending i/o; */
 	/* completion handlers free their requests in this case */
+	if (dev->dev_notify_ep) {
+		usb_ep_disable(dev->dev_notify_ep);
+		dev->dev_notify_ep = NULL;
+	}
 	if (dev->dev_in_ep) {
 		usb_ep_disable(dev->dev_in_ep);
 		dev->dev_in_ep = NULL;
@@ -1720,41 +2124,48 @@
 }
 
 /*
- * gs_build_config_desc
+ * gs_build_config_buf
  *
- * Builds a config descriptor in the given buffer and returns the
+ * Builds the config descriptors in the given buffer and returns the
  * length, or a negative error number.
  */
-static int gs_build_config_desc(u8 *buf, enum usb_device_speed speed, u8 type, unsigned int index)
+static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed,
+	u8 type, unsigned int index, int is_otg)
 {
+	int len;
 	int high_speed;
-	int len = USB_DT_CONFIG_SIZE + USB_DT_INTERFACE_SIZE
-				+ GS_NUM_ENDPOINTS * USB_DT_ENDPOINT_SIZE;
+	const struct usb_config_descriptor *config_desc;
+	const struct usb_descriptor_header **function;
 
-	/* only one config */
-	if (index != 0)
+	if (index >= gs_device_desc.bNumConfigurations)
 		return -EINVAL;
 
-	memcpy(buf, &gs_config_desc, USB_DT_CONFIG_SIZE);
-	((struct usb_config_descriptor *)buf)->bDescriptorType = type;
-	((struct usb_config_descriptor *)buf)->wTotalLength = __constant_cpu_to_le16(len);
-	buf += USB_DT_CONFIG_SIZE;
-
-	memcpy(buf, &gs_interface_desc, USB_DT_INTERFACE_SIZE);
-	buf += USB_DT_INTERFACE_SIZE;
-
 	/* other speed switches high and full speed */
 	high_speed = (speed == USB_SPEED_HIGH);
 	if (type == USB_DT_OTHER_SPEED_CONFIG)
 		high_speed = !high_speed;
 
-	memcpy(buf,
-		high_speed ? &gs_highspeed_in_desc : &gs_fullspeed_in_desc,
-		USB_DT_ENDPOINT_SIZE);
-	buf += USB_DT_ENDPOINT_SIZE;
-	memcpy(buf,
-		high_speed ? &gs_highspeed_out_desc : &gs_fullspeed_out_desc,
-		USB_DT_ENDPOINT_SIZE);
+	if (use_acm) {
+		config_desc = &gs_acm_config_desc;
+		function = GS_SPEED_SELECT(high_speed,
+			gs_acm_highspeed_function,
+			gs_acm_fullspeed_function);
+	} else {
+		config_desc = &gs_bulk_config_desc;
+		function = GS_SPEED_SELECT(high_speed,
+			gs_bulk_highspeed_function,
+			gs_bulk_fullspeed_function);
+	}
+
+	/* for now, don't advertise srp-only devices */
+	if (!is_otg)
+		function++;
+
+	len = usb_gadget_config_buf(config_desc, buf, GS_MAX_DESC_LEN, function);
+	if (len < 0)
+		return len;
+
+	((struct usb_config_descriptor *)buf)->bDescriptorType = type;
 
 	return len;
 }
@@ -1776,8 +2187,7 @@
 
 	if (req != NULL) {
 		req->length = len;
-		req->buf = usb_ep_alloc_buffer(ep, len, &req->dma,
-			kmalloc_flags);
+		req->buf = kmalloc(len, kmalloc_flags);
 		if (req->buf == NULL) {
 			usb_ep_free_request(ep, req);
 			return NULL;
@@ -1795,9 +2205,7 @@
 static void gs_free_req(struct usb_ep *ep, struct usb_request *req)
 {
 	if (ep != NULL && req != NULL) {
-		if (req->buf != NULL)
-			usb_ep_free_buffer(ep, req->buf, req->dma,
-				req->length);
+		kfree(req->buf);
 		usb_ep_free_request(ep, req);
 	}
 }
@@ -1864,6 +2272,10 @@
 		memset(port, 0, sizeof(struct gs_port));
 		port->port_dev = dev;
 		port->port_num = i;
+		port->port_line_coding.dwDTERate = GS_DEFAULT_DTE_RATE;
+		port->port_line_coding.bCharFormat = GS_DEFAULT_CHAR_FORMAT;
+		port->port_line_coding.bParityType = GS_DEFAULT_PARITY;
+		port->port_line_coding.bDataBits = GS_DEFAULT_DATA_BITS;
 		spin_lock_init(&port->port_lock);
 		init_waitqueue_head(&port->port_write_wait);
 
@@ -1906,8 +2318,10 @@
 			if (port->port_open_count > 0 || port->port_in_use) {
 				port->port_dev = NULL;
 				wake_up_interruptible(&port->port_write_wait);
-				wake_up_interruptible(&port->port_tty->read_wait);
-				wake_up_interruptible(&port->port_tty->write_wait);
+				if (port->port_tty) {
+					wake_up_interruptible(&port->port_tty->read_wait);
+					wake_up_interruptible(&port->port_tty->write_wait);
+				}
 			} else {
 				kfree(port);
 			}
diff -Nru a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
--- a/drivers/usb/gadget/zero.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/gadget/zero.c	2004-12-24 13:36:48 -08:00
@@ -396,7 +396,7 @@
 
 #endif	/* !CONFIG_USB_GADGET_DUALSPEED */
 
-static char				manufacturer [40];
+static char				manufacturer [50];
 static char				serial [40];
 
 /* static strings, in UTF-8 */
@@ -1188,6 +1188,10 @@
 		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0208);
 	} else if (gadget_is_lh7a40x(gadget)) {
 		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0209);
+	} else if (gadget_is_n9604(gadget)) {
+		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210);
+	} else if (gadget_is_pxa27x(gadget)) {
+		device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211);
 	} else {
 		/* gadget zero is so simple (for now, no altsettings) that
 		 * it SHOULD NOT have problems with bulk-capable hardware.
diff -Nru a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
--- a/drivers/usb/host/Kconfig	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/host/Kconfig	2004-12-24 13:37:29 -08:00
@@ -1,3 +1,21 @@
+# Host-side USB depends on having a host controller
+# NOTE:  dummy_hcd is always an option, but it's ignored here ...
+# NOTE:  SL-811 option should be board-specific ...
+config USB_ARCH_HAS_HCD
+	boolean
+	default y if USB_ARCH_HAS_OHCI
+	default y if ARM				# SL-811
+	default PCI
+
+# many non-PCI hcds implement OHCI
+config USB_ARCH_HAS_OHCI
+	boolean
+	default y if SA1111
+	default y if ARCH_OMAP
+	default y if ARCH_LH7A404
+	default y if PXA27x
+	default PCI
+
 #
 # USB Host Controller Drivers
 #
@@ -6,7 +24,7 @@
 
 config USB_EHCI_HCD
 	tristate "EHCI HCD (USB 2.0) support"
-	depends on USB
+	depends on USB && PCI
 	---help---
 	  The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0
 	  "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware.
@@ -51,8 +69,8 @@
 
 config USB_OHCI_HCD
 	tristate "OHCI HCD support"
-	depends on USB
-	select ISP1301_OMAP if MACH_OMAP_H2
+	depends on USB && USB_ARCH_HAS_OHCI
+	select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
 	---help---
 	  The Open Host Controller Interface (OHCI) is a standard for accessing
 	  USB 1.1 host controller hardware.  It does more in hardware than Intel's
@@ -68,7 +86,7 @@
 
 config USB_UHCI_HCD
 	tristate "UHCI HCD (most Intel and VIA) support"
-	depends on USB
+	depends on USB && PCI
 	---help---
 	  The Universal Host Controller Interface is a standard by Intel for
 	  accessing the USB hardware in the PC (which is also called the USB
@@ -82,14 +100,16 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called uhci-hcd.
 
-config USB_SL811HS
-	tristate "SL811HS support"
-	depends on ARM && USB
+config USB_SL811_HCD
+	tristate "SL811HS HCD support"
+	depends on USB
+	default N
 	help
-	  Say Y here if you have a SL811HS USB host controller in your system.
-
-	  If you do not know what this is, please say N.
+	  The SL811HS is a single-port USB controller that supports either
+	  host side or peripheral side roles.  Enable this option if your
+	  board has this chip, and you want to use it as a host controller. 
+	  If unsure, say N.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called hc_sl811.
+	  module will be called sl811-hcd.
 
diff -Nru a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
--- a/drivers/usb/host/Makefile	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/host/Makefile	2004-12-24 13:37:29 -08:00
@@ -6,5 +6,5 @@
 obj-$(CONFIG_USB_EHCI_HCD)	+= ehci-hcd.o
 obj-$(CONFIG_USB_OHCI_HCD)	+= ohci-hcd.o
 obj-$(CONFIG_USB_UHCI_HCD)	+= uhci-hcd.o
-
-obj-$(CONFIG_USB_SL811HS)	+= hc_sl811.o
+obj-$(CONFIG_USB_SL811_HCD)	+= sl811-hcd.o
+obj-$(CONFIG_ETRAX_ARCH_V10)	+= hc_crisv10.o
diff -Nru a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
--- a/drivers/usb/host/ehci-dbg.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/host/ehci-dbg.c	2004-12-24 13:37:18 -08:00
@@ -185,7 +185,7 @@
 }
 
 static int __attribute__((__unused__))
-dbg_status_buf (char *buf, unsigned len, char *label, u32 status)
+dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
 {
 	return scnprintf (buf, len,
 		"%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
@@ -204,7 +204,7 @@
 }
 
 static int __attribute__((__unused__))
-dbg_intr_buf (char *buf, unsigned len, char *label, u32 enable)
+dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
 {
 	return scnprintf (buf, len,
 		"%s%sintrenable %02x%s%s%s%s%s%s",
@@ -221,7 +221,8 @@
 static const char *const fls_strings [] =
     { "1024", "512", "256", "??" };
 
-static int dbg_command_buf (char *buf, unsigned len, char *label, u32 command)
+static int
+dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
 {
 	return scnprintf (buf, len,
 		"%s%scommand %06x %s=%d ithresh=%d%s%s%s%s period=%s%s %s",
@@ -240,7 +241,7 @@
 }
 
 static int
-dbg_port_buf (char *buf, unsigned len, char *label, int port, u32 status)
+dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
 {
 	char	*sig;
 
@@ -276,19 +277,19 @@
 {}
 
 static inline int __attribute__((__unused__))
-dbg_status_buf (char *buf, unsigned len, char *label, u32 status)
+dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
 { return 0; }
 
 static inline int __attribute__((__unused__))
-dbg_command_buf (char *buf, unsigned len, char *label, u32 command)
+dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
 { return 0; }
 
 static inline int __attribute__((__unused__))
-dbg_intr_buf (char *buf, unsigned len, char *label, u32 enable)
+dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
 { return 0; }
 
 static inline int __attribute__((__unused__))
-dbg_port_buf (char *buf, unsigned len, char *label, int port, u32 status)
+dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
 { return 0; }
 
 #endif	/* DEBUG */
diff -Nru a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
--- a/drivers/usb/host/ehci-hcd.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/usb/host/ehci-hcd.c	2004-12-24 13:37:01 -08:00
@@ -97,7 +97,7 @@
  * 2001-June	Works with usb-storage and NEC EHCI on 2.4
  */
 
-#define DRIVER_VERSION "2004-May-10"
+#define DRIVER_VERSION "26 Oct 2004"
 #define DRIVER_AUTHOR "David Brownell"
 #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"
 
@@ -155,7 +155,7 @@
  * before driver shutdown. But it also seems to be caused by bugs in cardbus
  * bridge shutdown:  shutting down the bridge before the devices using it.
  */
-static int handshake (u32 __iomem *ptr, u32 mask, u32 done, int usec)
+static int handshake (void __iomem *ptr, u32 mask, u32 done, int usec)
 {
 	u32	result;
 
@@ -172,13 +172,6 @@
 	return -ETIMEDOUT;
 }
 
-/*
- * hc states include: unknown, halted, ready, running
- * transitional states are messy just now
- * trying to avoid "running" unless urbs are active
- * a "ready" hc can be finishing prefetched work
- */
-
 /* force HC to halt state from unknown (EHCI spec section 2.3) */
 static int ehci_halt (struct ehci_hcd *ehci)
 {
@@ -207,7 +200,7 @@
 }
 
 /* idle the controller (from running) */
-static void ehci_ready (struct ehci_hcd *ehci)
+static void ehci_quiesce (struct ehci_hcd *ehci)
 {
 	u32	temp;
 
@@ -217,11 +210,8 @@
 #endif
 
 	/* wait for any schedule enables/disables to take effect */
-	temp = 0;
-	if (ehci->async->qh_next.qh)
-		temp = STS_ASS;
-	if (ehci->next_uframe != -1)
-		temp |= STS_PSS;
+	temp = readl (&ehci->regs->command) << 10;
+	temp &= STS_ASS | STS_PSS;
 	if (handshake (&ehci->regs->status, STS_ASS | STS_PSS,
 				temp, 16 * 125) != 0) {
 		ehci->hcd.state = USB_STATE_HALT;
@@ -341,16 +331,24 @@
 	spin_lock_init (&ehci->lock);
 
 	ehci->caps = hcd->regs;
-	ehci->regs = (hcd->regs + 
-				HC_LENGTH (readl (&ehci->caps->hc_capbase)));
+	ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase));
 	dbg_hcs_params (ehci, "reset");
 	dbg_hcc_params (ehci, "reset");
 
 #ifdef	CONFIG_PCI
 	/* EHCI 0.96 and later may have "extended capabilities" */
-	if (hcd->self.controller->bus == &pci_bus_type)
+	if (hcd->self.controller->bus == &pci_bus_type) {
+		struct pci_dev	*pdev = to_pci_dev(ehci->hcd.self.controller);
+
+		/* AMD8111 EHCI doesn't work, according to AMD errata */
+		if ((pdev->vendor == PCI_VENDOR_ID_AMD)
+				&& (pdev->device == 0x7463)) {
+			ehci_info (ehci, "ignoring AMD8111 (errata)\n");
+			return -EIO;
+		}
+
 		temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
-	else
+	} else
 		temp = 0;
 	while (temp && count--) {
 		u32		cap;
@@ -363,10 +361,6 @@
 			if (bios_handoff (ehci, temp, cap) != 0)
 				return -EOPNOTSUPP;
 			break;
-		case 0x0a:		/* appendix C */
-			ehci_dbg (ehci, "debug registers, BAR %d offset %d\n",
-				(cap >> 29) & 0x07, (cap >> 16) & 0x0fff);
-			break;
 		case 0:			/* illegal reserved capability */
 			ehci_warn (ehci, "illegal capability!\n");
 			cap = 0;
@@ -385,6 +379,14 @@
 	/* cache this readonly data; minimize PCI reads */
 	ehci->hcs_params = readl (&ehci->caps->hcs_params);
 
+	/* at least the Genesys GL880S needs fixup here */
+	temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
+	temp &= 0x0f;
+	if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) {
+		temp |= (ehci->hcs_params & ~0xf);
+		ehci->hcs_params = temp;
+	}
+
 	/* force HC to halt state */
 	return ehci_halt (ehci);
 }
@@ -398,17 +400,22 @@
 	int			retval;
 	u32			hcc_params;
 	u8                      sbrn = 0;
+	int			first;
 
-	init_timer (&ehci->watchdog);
-	ehci->watchdog.function = ehci_watchdog;
-	ehci->watchdog.data = (unsigned long) ehci;
+	/* skip some things on restart paths */
+	first = (ehci->watchdog.data == 0);
+	if (first) {
+		init_timer (&ehci->watchdog);
+		ehci->watchdog.function = ehci_watchdog;
+		ehci->watchdog.data = (unsigned long) ehci;
+	}
 
 	/*
 	 * hw default: 1K periodic list heads, one per frame.
 	 * periodic_size can shrink by USBCMD update if hcc_params allows.
 	 */
 	ehci->periodic_size = DEFAULT_I_TDPS;
-	if ((retval = ehci_mem_init (ehci, GFP_KERNEL)) < 0)
+	if (first && (retval = ehci_mem_init (ehci, GFP_KERNEL)) < 0)
 		return retval;
 
 	/* controllers may cache some of the periodic schedule ... */
@@ -419,6 +426,7 @@
 		ehci->i_thresh = 2 + HCC_ISOC_THRES (hcc_params);
 
 	ehci->reclaim = NULL;
+	ehci->reclaim_ready = 0;
 	ehci->next_uframe = -1;
 
 	/* controller state:  unknown --> reset */
@@ -465,13 +473,15 @@
 	 * its dummy is used in hw_alt_next of many tds, to prevent the qh
 	 * from automatically advancing to the next td after short reads.
 	 */
-	ehci->async->qh_next.qh = NULL;
-	ehci->async->hw_next = QH_NEXT (ehci->async->qh_dma);
-	ehci->async->hw_info1 = cpu_to_le32 (QH_HEAD);
-	ehci->async->hw_token = cpu_to_le32 (QTD_STS_HALT);
-	ehci->async->hw_qtd_next = EHCI_LIST_END;
-	ehci->async->qh_state = QH_STATE_LINKED;
-	ehci->async->hw_alt_next = QTD_NEXT (ehci->async->dummy->qtd_dma);
+	if (first) {
+		ehci->async->qh_next.qh = NULL;
+		ehci->async->hw_next = QH_NEXT (ehci->async->qh_dma);
+		ehci->async->hw_info1 = cpu_to_le32 (QH_HEAD);
+		ehci->async->hw_token = cpu_to_le32 (QTD_STS_HALT);
+		ehci->async->hw_qtd_next = EHCI_LIST_END;
+		ehci->async->qh_state = QH_STATE_LINKED;
+		ehci->async->hw_alt_next = QTD_NEXT (ehci->async->dummy->qtd_dma);
+	}
 	writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next);
 
 	/*
@@ -523,12 +533,14 @@
 
 	/* wire up the root hub */
 	bus = hcd_to_bus (hcd);
-	udev = usb_alloc_dev (NULL, bus, 0);
+	udev = first ? usb_alloc_dev (NULL, bus, 0) : bus->root_hub;
 	if (!udev) {
 done2:
 		ehci_mem_cleanup (ehci);
 		return -ENOMEM;
 	}
+	udev->speed = USB_SPEED_HIGH;
+	udev->state = first ? USB_STATE_ATTACHED : USB_STATE_CONFIGURED;
 
 	/*
 	 * Start, enabling full USB 2.0 functionality ... usb 1.1 devices
@@ -536,8 +548,10 @@
 	 * involved with the root hub.  (Except where one is integrated,
 	 * and there's no companion controller unless maybe for USB OTG.)
 	 */
-	ehci->reboot_notifier.notifier_call = ehci_reboot;
-	register_reboot_notifier (&ehci->reboot_notifier);
+	if (first) {
+		ehci->reboot_notifier.notifier_call = ehci_reboot;
+		register_reboot_notifier (&ehci->reboot_notifier);
+	}
 
 	ehci->hcd.state = USB_STATE_RUNNING;
 	writel (FLAG_CF, &ehci->regs->configured_flag);
@@ -545,21 +559,23 @@
 
 	temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
 	ehci_info (ehci,
-		"USB %x.%x enabled, EHCI %x.%02x, driver %s\n",
+		"USB %x.%x %s, EHCI %x.%02x, driver %s\n",
 		((sbrn & 0xf0)>>4), (sbrn & 0x0f),
+		first ? "initialized" : "restarted",
 		temp >> 8, temp & 0xff, DRIVER_VERSION);
 
 	/*
 	 * From here on, khubd concurrently accesses the root
 	 * hub; drivers will be talking to enumerated devices.
+	 * (On restart paths, khubd already knows about the root
+	 * hub and could find work as soon as we wrote FLAG_CF.)
 	 *
 	 * Before this point the HC was idle/ready.  After, khubd
 	 * and device drivers may start it running.
 	 */
-	udev->speed = USB_SPEED_HIGH;
-	if (hcd_register_root (udev, hcd) != 0) {
+	if (first && hcd_register_root (udev, hcd) != 0) {
 		if (hcd->state == USB_STATE_RUNNING)
-			ehci_ready (ehci);
+			ehci_quiesce (ehci);
 		ehci_reset (ehci);
 		usb_put_dev (udev); 
 		retval = -ENODEV;
@@ -568,7 +584,8 @@
 
 	writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */
 
-	create_debug_files (ehci);
+	if (first)
+		create_debug_files (ehci);
 
 	return 0;
 }
@@ -582,24 +599,23 @@
 
 	ehci_dbg (ehci, "stop\n");
 
-	/* no more interrupts ... */
-	if (hcd->state == USB_STATE_RUNNING)
-		ehci_ready (ehci);
-	if (in_interrupt ()) {		/* must not happen!! */
-		ehci_err (ehci, "stopped in_interrupt!\n");
-		return;
-	}
-	del_timer_sync (&ehci->watchdog);
-
 	/* Turn off port power on all root hub ports. */
 	rh_ports = HCS_N_PORTS (ehci->hcs_params);
-	for (port = 1; port <= rh_ports; port++) {
-		ehci_hub_control(hcd, ClearPortFeature, USB_PORT_FEAT_POWER,
+	for (port = 1; port <= rh_ports; port++)
+		(void) ehci_hub_control(hcd,
+			ClearPortFeature, USB_PORT_FEAT_POWER,
 			port, NULL, 0);
-	}
+
+	/* no more interrupts ... */
+	del_timer_sync (&ehci->watchdog);
+
+	spin_lock_irq(&ehci->lock);
+	if (HCD_IS_RUNNING (ehci->hcd.state))
+		ehci_quiesce (ehci);
 
 	ehci_reset (ehci);
 	writel (0, &ehci->regs->intr_enable);
+	spin_unlock_irq(&ehci->lock);
 
 	/* let companion controllers work when we aren't */
 	writel (0, &ehci->regs->configured_flag);
@@ -637,7 +653,8 @@
 
 /* suspend/resume, section 4.3 */
 
-/* These routines rely on PCI to handle powerdown and wakeup, and
+/* These routines rely on the bus (pci, platform, etc)
+ * to handle powerdown and wakeup, and currently also on
  * transceivers that don't need any software attention to set up
  * the right sort of wakeup.  
  */
@@ -646,17 +663,19 @@
 {
 	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
 
-	while (time_before (jiffies, ehci->next_statechange))
+	if (time_before (jiffies, ehci->next_statechange))
 		msleep (100);
 
 #ifdef	CONFIG_USB_SUSPEND
 	(void) usb_suspend_device (hcd->self.root_hub, state);
 #else
-	/* FIXME lock root hub */
+	usb_lock_device (hcd->self.root_hub);
 	(void) ehci_hub_suspend (hcd);
+	usb_unlock_device (hcd->self.root_hub);
 #endif
 
 	// save (PCI) FLADJ in case of Vaux power loss
+	// ... we'd only use it to handle clock skew
 
 	return 0;
 }
@@ -664,21 +683,67 @@
 static int ehci_resume (struct usb_hcd *hcd)
 {
 	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
-	int			retval;
+	unsigned		port;
+	struct usb_device	*root = hcd->self.root_hub;
+	int			retval = -EINVAL;
+	int			powerup = 0;
 
 	// maybe restore (PCI) FLADJ
 
-	while (time_before (jiffies, ehci->next_statechange))
+	if (time_before (jiffies, ehci->next_statechange))
 		msleep (100);
 
-#ifdef	CONFIG_USB_SUSPEND
-	retval = usb_resume_device (hcd->self.root_hub);
-#else
-	/* FIXME lock root hub */
-	retval = ehci_hub_resume (hcd);
-#endif
-	if (retval == 0)
-		hcd->self.controller->power.power_state = 0;
+	/* If any port is suspended, we know we can/must resume the HC. */
+	for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) {
+		u32	status;
+		port--;
+		status = readl (&ehci->regs->port_status [port]);
+		if (status & PORT_SUSPEND) {
+			down (&hcd->self.root_hub->serialize);
+			retval = ehci_hub_resume (hcd);
+			up (&hcd->self.root_hub->serialize);
+			break;
+		}
+		if ((status & PORT_POWER) == 0)
+			powerup = 1;
+		if (!root->children [port])
+			continue;
+		dbg_port (ehci, __FUNCTION__, port + 1, status);
+		usb_set_device_state (root->children[port],
+					USB_STATE_NOTATTACHED);
+	}
+
+	/* Else reset, to cope with power loss or flush-to-storage
+	 * style "resume" having activated BIOS during reboot.
+	 */
+	if (port == 0) {
+		(void) ehci_halt (ehci);
+		(void) ehci_reset (ehci);
+		(void) ehci_hc_reset (hcd);
+
+		/* emptying the schedule aborts any urbs */
+		spin_lock_irq (&ehci->lock);
+		if (ehci->reclaim)
+			ehci->reclaim_ready = 1;
+		ehci_work (ehci, NULL);
+		spin_unlock_irq (&ehci->lock);
+
+		/* restart; khubd will disconnect devices */
+		retval = ehci_start (hcd);
+
+		/* here we "know" root ports should always stay powered;
+		 * but some controllers may lost all power.
+		 */
+		if (powerup) {
+			ehci_dbg (ehci, "...powerup ports...\n");
+			for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
+				(void) ehci_hub_control(hcd,
+					SetPortFeature, USB_PORT_FEAT_POWER,
+						port--, NULL, 0);
+			msleep(20);
+		}
+	}
+
 	return retval;
 }
 
@@ -712,7 +777,8 @@
 	 * misplace IRQs, and should let us run completely without IRQs.
 	 * such lossage has been observed on both VT6202 and VT8235. 
 	 */
-	if ((ehci->async->qh_next.ptr != 0) || (ehci->periodic_sched != 0))
+	if (HCD_IS_RUNNING (ehci->hcd.state) && (ehci->async->qh_next.ptr != 0
+			|| ehci->periodic_sched != 0))
 		timer_action (ehci, TIMER_IO_WATCHDOG);
 }
 
@@ -858,6 +924,30 @@
 	}
 }
 
+static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
+{
+	/* if we need to use IAA and it's busy, defer */
+	if (qh->qh_state == QH_STATE_LINKED
+			&& ehci->reclaim
+			&& HCD_IS_RUNNING (ehci->hcd.state)) {
+		struct ehci_qh		*last;
+
+		for (last = ehci->reclaim;
+				last->reclaim;
+				last = last->reclaim)
+			continue;
+		qh->qh_state = QH_STATE_UNLINK_WAIT;
+		last->reclaim = qh;
+
+	/* bypass IAA if the hc can't care */
+	} else if (!HCD_IS_RUNNING (ehci->hcd.state) && ehci->reclaim)
+		end_unlink_async (ehci, NULL);
+
+	/* something else might have unlinked the qh by now */
+	if (qh->qh_state == QH_STATE_LINKED)
+		start_unlink_async (ehci, qh);
+}
+
 /* remove from hardware lists
  * completions normally happen asynchronously
  */
@@ -876,28 +966,7 @@
 		qh = (struct ehci_qh *) urb->hcpriv;
 		if (!qh)
 			break;
-
-		/* if we need to use IAA and it's busy, defer */
-		if (qh->qh_state == QH_STATE_LINKED
-				&& ehci->reclaim
-				&& HCD_IS_RUNNING (ehci->hcd.state)
-				) {
-			struct ehci_qh		*last;
-
-			for (last = ehci->reclaim;
-					last->reclaim;
-					last = last->reclaim)
-				continue;
-			qh->qh_state = QH_STATE_UNLINK_WAIT;
-			last->reclaim = qh;
-
-		/* bypass IAA if the hc can't care */
-		} else if (!HCD_IS_RUNNING (ehci->hcd.state) && ehci->reclaim)
-			end_unlink_async (ehci, NULL);
-
-		/* something else might have unlinked the qh by now */
-		if (qh->qh_state == QH_STATE_LINKED)
-			start_unlink_async (ehci, qh);
+		unlink_async (ehci, qh);
 		break;
 
 	case PIPE_INTERRUPT:
@@ -950,7 +1019,7 @@
 	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
 	int			epnum;
 	unsigned long		flags;
-	struct ehci_qh		*qh;
+	struct ehci_qh		*qh, *tmp;
 
 	/* ASSERT:  any requests/urbs are being unlinked */
 	/* ASSERT:  nobody can be submitting urbs for this any more */
@@ -976,6 +1045,16 @@
 	if (!HCD_IS_RUNNING (ehci->hcd.state))
 		qh->qh_state = QH_STATE_IDLE;
 	switch (qh->qh_state) {
+	case QH_STATE_LINKED:
+		for (tmp = ehci->async->qh_next.qh;
+				tmp && tmp != qh;
+				tmp = tmp->qh_next.qh)
+			continue;
+		/* periodic qh self-unlinks on empty */
+		if (!tmp)
+			goto nogood;
+		unlink_async (ehci, qh);
+		/* FALL THROUGH */
 	case QH_STATE_UNLINK:		/* wait for hw to finish? */
 idle_timeout:
 		spin_unlock_irqrestore (&ehci->lock, flags);
@@ -989,6 +1068,7 @@
 		}
 		/* else FALL THROUGH */
 	default:
+nogood:
 		/* caller was supposed to have unlinked any requests;
 		 * that's not our job.  just leak this memory.
 		 */
@@ -1029,7 +1109,6 @@
 	 * memory lifecycle (except per-request)
 	 */
 	.hcd_alloc =		ehci_hcd_alloc,
-	.hcd_free =		ehci_hcd_free,
 
 	/*
 	 * managing i/o requests and associated device resources
@@ -1101,7 +1180,7 @@
 		sizeof (struct ehci_qh), sizeof (struct ehci_qtd),
 		sizeof (struct ehci_itd), sizeof (struct ehci_sitd));
 
-	return pci_module_init (&ehci_pci_driver);
+	return pci_register_driver (&ehci_pci_driver);
 }
 module_init (init);
 
diff -Nru a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
--- a/drivers/usb/host/ehci-hub.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/host/ehci-hub.c	2004-12-24 13:37:29 -08:00
@@ -33,22 +33,29 @@
 static int ehci_hub_suspend (struct usb_hcd *hcd)
 {
 	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
-	struct usb_device	*root = hcd_to_bus (&ehci->hcd)->root_hub;
 	int			port;
-	int			status = 0;
 
-	if (root->dev.power.power_state != 0)
-		return 0;
 	if (time_before (jiffies, ehci->next_statechange))
-		return -EAGAIN;
+		msleep(5);
 
 	port = HCS_N_PORTS (ehci->hcs_params);
 	spin_lock_irq (&ehci->lock);
 
+	/* stop schedules, clean any completed work */
+	if (HCD_IS_RUNNING(hcd->state)) {
+		ehci_quiesce (ehci);
+		ehci->hcd.state = USB_STATE_QUIESCING;
+	}
+	ehci->command = readl (&ehci->regs->command);
+	if (ehci->reclaim)
+		ehci->reclaim_ready = 1;
+	ehci_work(ehci, NULL);
+
 	/* suspend any active/unsuspended ports, maybe allow wakeup */
 	while (port--) {
-		u32	t1 = readl (&ehci->regs->port_status [port]);
-		u32	t2 = t1;
+		u32 __iomem	*reg = &ehci->regs->port_status [port];
+		u32		t1 = readl (reg);
+		u32		t2 = t1;
 
 		if ((t1 & PORT_PE) && !(t1 & PORT_OWNER))
 			t2 |= PORT_SUSPEND;
@@ -60,48 +67,45 @@
 		if (t1 != t2) {
 			ehci_vdbg (ehci, "port %d, %08x -> %08x\n",
 				port + 1, t1, t2);
-			writel (t2, &ehci->regs->port_status [port]);
+			writel (t2, reg);
 		}
 	}
 
-	/* stop schedules, then turn off HC and clean any completed work */
-	if (hcd->state == USB_STATE_RUNNING)
-		ehci_ready (ehci);
-	ehci->command = readl (&ehci->regs->command);
-	writel (ehci->command & ~CMD_RUN, &ehci->regs->command);
-	if (ehci->reclaim)
-		ehci->reclaim_ready = 1;
-	ehci_work(ehci, NULL);
-	(void) handshake (&ehci->regs->status, STS_HALT, STS_HALT, 2000);
+	/* turn off now-idle HC */
+	ehci_halt (ehci);
+	ehci->hcd.state = HCD_STATE_SUSPENDED;
 
-	root->dev.power.power_state = 3;
 	ehci->next_statechange = jiffies + msecs_to_jiffies(10);
 	spin_unlock_irq (&ehci->lock);
-	return status;
+	return 0;
 }
 
 
-/* caller owns root->serialize, and should reset/reinit on error */
+/* caller has locked the root hub, and should reset/reinit on error */
 static int ehci_hub_resume (struct usb_hcd *hcd)
 {
 	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
-	struct usb_device	*root = hcd_to_bus (&ehci->hcd)->root_hub;
 	u32			temp;
 	int			i;
+	int			intr_enable;
 
-	if (!root->dev.power.power_state)
-		return 0;
 	if (time_before (jiffies, ehci->next_statechange))
-		return -EAGAIN;
+		msleep(5);
+	spin_lock_irq (&ehci->lock);
 
 	/* re-init operational registers in case we lost power */
 	if (readl (&ehci->regs->intr_enable) == 0) {
-		writel (INTR_MASK, &ehci->regs->intr_enable);
+ 		/* at least some APM implementations will try to deliver
+		 * IRQs right away, so delay them until we're ready.
+ 		 */
+ 		intr_enable = 1;
 		writel (0, &ehci->regs->segment);
 		writel (ehci->periodic_dma, &ehci->regs->frame_list);
 		writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next);
-		/* FIXME will this work even (pci) vAUX was lost? */
-	}
+	} else
+		intr_enable = 0;
+	ehci_dbg(ehci, "resume root hub%s\n",
+			intr_enable ? " after power loss" : "");
 
 	/* restore CMD_RUN, framelist size, and irq threshold */
 	writel (ehci->command, &ehci->regs->command);
@@ -118,7 +122,7 @@
 		writel (temp, &ehci->regs->port_status [i]);
 	}
 	i = HCS_N_PORTS (ehci->hcs_params);
-	msleep (20);
+	mdelay (20);
 	while (i--) {
 		temp = readl (&ehci->regs->port_status [i]);
 		if ((temp & PORT_SUSPEND) == 0)
@@ -135,12 +139,19 @@
 		temp |= CMD_ASE;
 	if (ehci->periodic_sched)
 		temp |= CMD_PSE;
-	if (temp)
-		writel (ehci->command | temp, &ehci->regs->command);
+	if (temp) {
+		ehci->command |= temp;
+		writel (ehci->command, &ehci->regs->command);
+	}
 
-	root->dev.power.power_state = 0;
 	ehci->next_statechange = jiffies + msecs_to_jiffies(5);
 	ehci->hcd.state = USB_STATE_RUNNING;
+
+	/* Now we can safely re-enable irqs */
+	if (intr_enable)
+		writel (INTR_MASK, &ehci->regs->intr_enable);
+
+	spin_unlock_irq (&ehci->lock);
 	return 0;
 }
 
@@ -200,6 +211,10 @@
 	int		ports, i, retval = 1;
 	unsigned long	flags;
 
+	/* if !USB_SUSPEND, root hub timers won't get shut down ... */
+	if (!HCD_IS_RUNNING(ehci->hcd.state))
+		return 0;
+
 	/* init status to no-changes */
 	buf [0] = 0;
 	ports = HCS_N_PORTS (ehci->hcs_params);
@@ -236,6 +251,7 @@
 			status = STS_PCD;
 		}
 	}
+	/* FIXME autosuspend idle root hubs */
 	spin_unlock_irqrestore (&ehci->lock, flags);
 	return status ? retval : 0;
 }
@@ -265,9 +281,12 @@
 	temp = 0x0008;			/* per-port overcurrent reporting */
 	if (HCS_PPC (ehci->hcs_params))
 		temp |= 0x0001;		/* per-port power control */
+#if 0
+// re-enable when we support USB_PORT_FEAT_INDICATOR below.
 	if (HCS_INDICATOR (ehci->hcs_params))
 		temp |= 0x0080;		/* per-port indicators (LEDs) */
-	desc->wHubCharacteristics = cpu_to_le16 (temp);
+#endif
+	desc->wHubCharacteristics = (__force __u16)cpu_to_le16 (temp);
 }
 
 /*-------------------------------------------------------------------------*/
diff -Nru a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
--- a/drivers/usb/host/ehci-mem.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/host/ehci-mem.c	2004-12-24 13:37:19 -08:00
@@ -50,11 +50,6 @@
 	return NULL;
 }
 
-static void ehci_hcd_free (struct usb_hcd *hcd)
-{
-	kfree (hcd_to_ehci (hcd));
-}
-
 /*-------------------------------------------------------------------------*/
 
 /* Allocate the key transfer structures from the previously allocated pool */
diff -Nru a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
--- a/drivers/usb/host/ehci-q.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/host/ehci-q.c	2004-12-24 13:37:18 -08:00
@@ -83,19 +83,59 @@
 
 /*-------------------------------------------------------------------------*/
 
-/* update halted (but potentially linked) qh */
-
 static inline void
 qh_update (struct ehci_hcd *ehci, struct ehci_qh *qh, struct ehci_qtd *qtd)
 {
+	/* writes to an active overlay are unsafe */
+	BUG_ON(qh->qh_state != QH_STATE_IDLE);
+
 	qh->hw_qtd_next = QTD_NEXT (qtd->qtd_dma);
 	qh->hw_alt_next = EHCI_LIST_END;
 
+	/* Except for control endpoints, we make hardware maintain data
+	 * toggle (like OHCI) ... here (re)initialize the toggle in the QH,
+	 * and set the pseudo-toggle in udev. Only usb_clear_halt() will
+	 * ever clear it.
+	 */
+	if (!(qh->hw_info1 & cpu_to_le32(1 << 14))) {
+		unsigned	is_out, epnum;
+
+		is_out = !(qtd->hw_token & cpu_to_le32(1 << 8));
+		epnum = (le32_to_cpup(&qh->hw_info1) >> 8) & 0x0f;
+		if (unlikely (!usb_gettoggle (qh->dev, epnum, is_out))) {
+			qh->hw_token &= ~__constant_cpu_to_le32 (QTD_TOGGLE);
+			usb_settoggle (qh->dev, epnum, is_out, 1);
+		}
+	}
+
 	/* HC must see latest qtd and qh data before we clear ACTIVE+HALT */
 	wmb ();
 	qh->hw_token &= __constant_cpu_to_le32 (QTD_TOGGLE | QTD_STS_PING);
 }
 
+/* if it weren't for a common silicon quirk (writing the dummy into the qh
+ * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
+ * recovery (including urb dequeue) would need software changes to a QH...
+ */
+static void
+qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
+{
+	struct ehci_qtd *qtd;
+
+	if (list_empty (&qh->qtd_list))
+		qtd = qh->dummy;
+	else {
+		qtd = list_entry (qh->qtd_list.next,
+				struct ehci_qtd, qtd_list);
+		/* first qtd may already be partially processed */
+		if (cpu_to_le32 (qtd->qtd_dma) == qh->hw_current)
+			qtd = NULL;
+	}
+
+	if (qtd)
+		qh_update (ehci, qh, qtd);
+}
+
 /*-------------------------------------------------------------------------*/
 
 static void qtd_copy_status (
@@ -175,6 +215,8 @@
 
 static void
 ehci_urb_done (struct ehci_hcd *ehci, struct urb *urb, struct pt_regs *regs)
+__releases(ehci->lock)
+__acquires(ehci->lock)
 {
 	if (likely (urb->hcpriv != 0)) {
 		struct ehci_qh	*qh = (struct ehci_qh *) urb->hcpriv;
@@ -224,6 +266,11 @@
 	spin_lock (&ehci->lock);
 }
 
+static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh);
+
+static void intr_deschedule (struct ehci_hcd *ehci,
+				struct ehci_qh *qh, int wait);
+static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh);
 
 /*
  * Process and free completed qtds for a qh, returning URBs to drivers.
@@ -307,6 +354,9 @@
 		} else {
 			stopped = 1;
 
+			if (unlikely (!HCD_IS_RUNNING (ehci->hcd.state)))
+				urb->status = -ESHUTDOWN;
+
 			/* ignore active urbs unless some previous qtd
 			 * for the urb faulted (including short read) or
 			 * its urb was canceled.  we may patch qh or qtds.
@@ -364,21 +414,27 @@
 	/* restore original state; caller must unlink or relink */
 	qh->qh_state = state;
 
-	/* update qh after fault cleanup */
-	if (unlikely (stopped != 0)
-			/* some EHCI 0.95 impls will overlay dummy qtds */ 
-			|| qh->hw_qtd_next == EHCI_LIST_END) {
-		if (list_empty (&qh->qtd_list))
-			end = qh->dummy;
-		else {
-			end = list_entry (qh->qtd_list.next,
-					struct ehci_qtd, qtd_list);
-			/* first qtd may already be partially processed */
-			if (cpu_to_le32 (end->qtd_dma) == qh->hw_current)
-				end = NULL;
+	/* be sure the hardware's done with the qh before refreshing
+	 * it after fault cleanup, or recovering from silicon wrongly
+	 * overlaying the dummy qtd (which reduces DMA chatter).
+	 */
+	if (stopped != 0 || qh->hw_qtd_next == EHCI_LIST_END) {
+		switch (state) {
+		case QH_STATE_IDLE:
+			qh_refresh(ehci, qh);
+			break;
+		case QH_STATE_LINKED:
+			/* should be rare for periodic transfers,
+			 * except maybe high bandwidth ...
+			 */
+			if (qh->period) {
+				intr_deschedule (ehci, qh, 1);
+				(void) qh_schedule (ehci, qh);
+			} else
+				start_unlink_async (ehci, qh);
+			break;
+		/* otherwise, unlink already started */
 		}
-		if (end)
-			qh_update (ehci, qh, end);
 	}
 
 	return count;
@@ -552,21 +608,6 @@
 
 /*-------------------------------------------------------------------------*/
 
-/*
- * Hardware maintains data toggle (like OHCI) ... here we (re)initialize
- * the hardware data toggle in the QH, and set the pseudo-toggle in udev
- * so we can see if usb_clear_halt() was called.  NOP for control, since
- * we set up qh->hw_info1 to always use the QTD toggle bits. 
- */
-static inline void
-clear_toggle (struct usb_device *udev, int ep, int is_out, struct ehci_qh *qh)
-{
-	vdbg ("clear toggle, dev %d ep 0x%x-%s",
-		udev->devnum, ep, is_out ? "out" : "in");
-	qh->hw_token &= ~__constant_cpu_to_le32 (QTD_TOGGLE);
-	usb_settoggle (udev, ep, is_out, 1);
-}
-
 // Would be best to create all qh's from config descriptors,
 // when each interface/altsetting is established.  Unlink
 // any previous qh and cancel its urbs first; endpoints are
@@ -646,11 +687,11 @@
 
 			qh->period = urb->interval;
 		}
-
-		/* support for tt scheduling */
-		qh->dev = usb_get_dev (urb->dev);
 	}
 
+	/* support for tt scheduling, and access to toggles */
+	qh->dev = usb_get_dev (urb->dev);
+
 	/* using TT? */
 	switch (urb->dev->speed) {
 	case USB_SPEED_LOW:
@@ -710,8 +751,8 @@
 	qh->qh_state = QH_STATE_IDLE;
 	qh->hw_info1 = cpu_to_le32 (info1);
 	qh->hw_info2 = cpu_to_le32 (info2);
-	qh_update (ehci, qh, qh->dummy);
 	usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1);
+	qh_refresh (ehci, qh);
 	return qh;
 }
 
@@ -740,7 +781,9 @@
 		}
 	}
 
-	qh->hw_token &= ~HALT_BIT;
+	/* clear halt and/or toggle; and maybe recover from silicon quirk */
+	if (qh->qh_state == QH_STATE_IDLE)
+		qh_refresh (ehci, qh);
 
 	/* splice right after start */
 	qh->qh_next = head->qh_next;
@@ -815,27 +858,8 @@
                                 qh->hw_info1 &= ~QH_ADDR_MASK;
 		}
 
-		/* usb_clear_halt() means qh data toggle gets reset */
-		if (unlikely (!usb_gettoggle (urb->dev,
-					(epnum & 0x0f), !(epnum & 0x10)))
-				&& !usb_pipecontrol (urb->pipe)) {
-			/* "never happens": drivers do stall cleanup right */
-			if (qh->qh_state != QH_STATE_IDLE
-					&& !list_empty (&qh->qtd_list)
-					&& qh->qh_state != QH_STATE_COMPLETING)
-				ehci_warn (ehci, "clear toggle dev%d "
-						"ep%d%s: not idle\n",
-						usb_pipedevice (urb->pipe),
-						epnum & 0x0f,
-						usb_pipein (urb->pipe)
-							? "in" : "out");
-			/* else we know this overlay write is safe */
-			clear_toggle (urb->dev,
-				epnum & 0x0f, !(epnum & 0x10), qh);
-		}
-
 		/* just one way to queue requests: swap with the dummy qtd.
-		 * only hc or qh_completions() usually modify the overlay.
+		 * only hc or qh_refresh() ever modify the overlay.
 		 */
 		if (likely (qtd != 0)) {
 			struct ehci_qtd		*dummy;
@@ -930,8 +954,6 @@
 /*-------------------------------------------------------------------------*/
 
 /* the async qh for the qtds being reclaimed are now unlinked from the HC */
-
-static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh);
 
 static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs)
 {
diff -Nru a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
--- a/drivers/usb/host/ehci-sched.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/usb/host/ehci-sched.c	2004-12-24 13:36:33 -08:00
@@ -325,7 +325,7 @@
 		status = disable_periodic (ehci);
 	else {
 		status = 0;
-		vdbg ("periodic schedule still enabled");
+		ehci_vdbg (ehci, "periodic schedule still enabled\n");
 	}
 
 	/*
@@ -342,7 +342,7 @@
 			 * the race is very short.  then if qh also isn't
 			 * rescheduled soon, it won't matter.  otherwise...
 			 */
-			vdbg ("intr_deschedule...");
+			ehci_vdbg (ehci, "intr_deschedule...\n");
 		}
 	} else
 		qh->hw_next = EHCI_LIST_END;
@@ -353,8 +353,8 @@
 	hcd_to_bus (&ehci->hcd)->bandwidth_allocated -= 
 		(qh->usecs + qh->c_usecs) / qh->period;
 
-	dbg ("descheduled qh %p, period = %d frame = %d count = %d, urbs = %d",
-		qh, qh->period, frame,
+	ehci_dbg (ehci, "descheduled qh%d/%p frame=%d count=%d, urbs=%d\n",
+		qh->period, qh, frame,
 		atomic_read (&qh->kref.refcount), ehci->periodic_sched);
 }
 
@@ -450,6 +450,7 @@
 	__le32		c_mask;
 	unsigned	frame;		/* 0..(qh->period - 1), or NO_FRAME */
 
+	qh_refresh(ehci, qh);
 	qh->hw_next = EHCI_LIST_END;
 	frame = qh->start;
 
@@ -486,13 +487,14 @@
 		qh->hw_info2 &= ~__constant_cpu_to_le32(0xffff);
 		qh->hw_info2 |= cpu_to_le32 (1 << uframe) | c_mask;
 	} else
-		dbg ("reused previous qh %p schedule", qh);
+		ehci_dbg (ehci, "reused qh %p schedule\n", qh);
 
 	/* stuff into the periodic schedule */
 	qh->qh_state = QH_STATE_LINKED;
-	dbg ("scheduled qh %p usecs %d/%d period %d.0 starting %d.%d (gap %d)",
-		qh, qh->usecs, qh->c_usecs,
-		qh->period, frame, uframe, qh->gap_uf);
+	ehci_dbg(ehci,
+		"scheduled qh%d/%p usecs %d/%d starting %d.%d (gap %d)\n",
+		qh->period, qh, qh->usecs, qh->c_usecs,
+		frame, uframe, qh->gap_uf);
 	do {
 		if (unlikely (ehci->pshadow [frame].ptr != 0)) {
 
@@ -907,6 +909,7 @@
 
 		if (unlikely (0 == itd)) {
 			iso_sched_free (stream, sched);
+			spin_unlock_irqrestore (&ehci->lock, flags);
 			return -ENOMEM;
 		}
 		memset (itd, 0, sizeof *itd);
@@ -1835,7 +1838,9 @@
 		while (q.ptr != 0) {
 			unsigned		uf;
 			union ehci_shadow	temp;
+			int			live;
 
+			live = HCD_IS_RUNNING (ehci->hcd.state);
 			switch (type) {
 			case Q_TYPE_QH:
 				/* handle any completions */
@@ -1860,7 +1865,7 @@
 			case Q_TYPE_ITD:
 				/* skip itds for later in the frame */
 				rmb ();
-				for (uf = uframes; uf < 8; uf++) {
+				for (uf = live ? uframes : 8; uf < 8; uf++) {
 					if (0 == (q.itd->hw_transaction [uf]
 							& ITD_ACTIVE))
 						continue;
@@ -1884,7 +1889,8 @@
 				q = *q_p;
 				break;
 			case Q_TYPE_SITD:
-				if (q.sitd->hw_results & SITD_ACTIVE) {
+				if ((q.sitd->hw_results & SITD_ACTIVE)
+						&& live) {
 					q_p = &q.sitd->sitd_next;
 					hw_p = &q.sitd->hw_next;
 					type = Q_NEXT_TYPE (q.sitd->hw_next);
diff -Nru a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
--- a/drivers/usb/host/ehci.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/host/ehci.h	2004-12-24 13:37:18 -08:00
@@ -47,6 +47,13 @@
 #define	EHCI_MAX_ROOT_PORTS	15		/* see HCS_N_PORTS */
 
 struct ehci_hcd {			/* one per controller */
+
+	/* glue to PCI and HCD framework */
+	struct usb_hcd		hcd;		/* must come first! */
+	struct ehci_caps __iomem *caps;
+	struct ehci_regs __iomem *regs;
+	__u32			hcs_params;	/* cached register copy */
+
 	spinlock_t		lock;
 
 	/* async schedule support */
@@ -68,12 +75,6 @@
 
 	/* per root hub port */
 	unsigned long		reset_done [EHCI_MAX_ROOT_PORTS];
-
-	/* glue to PCI and HCD framework */
-	struct usb_hcd		hcd;
-	struct ehci_caps __iomem *caps;
-	struct ehci_regs __iomem *regs;
-	__u32			hcs_params;	/* cached register copy */
 
 	/* per-HC memory pools (could be per-bus, but ...) */
 	struct dma_pool		*qh_pool;	/* qh per active urb */
diff -Nru a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/host/hc_crisv10.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,4574 @@
+/*
+ * usb-host.c: ETRAX 100LX USB Host Controller Driver (HCD)
+ *
+ * Copyright (c) 2002, 2003 Axis Communications AB.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/unistd.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/version.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/dma.h>
+#include <asm/system.h>
+#include <asm/arch/svinto.h>
+
+#include <linux/usb.h>
+/* Ugly include because we don't live with the other host drivers. */
+#include <../drivers/usb/core/hcd.h>
+#include <../drivers/usb/core/usb.h>
+
+#include "hc_crisv10.h"
+
+#define ETRAX_USB_HC_IRQ USB_HC_IRQ_NBR
+#define ETRAX_USB_RX_IRQ USB_DMA_RX_IRQ_NBR
+#define ETRAX_USB_TX_IRQ USB_DMA_TX_IRQ_NBR
+
+static const char *usb_hcd_version = "$Revision: 1.2 $";
+
+#undef KERN_DEBUG
+#define KERN_DEBUG ""
+
+
+#undef USB_DEBUG_RH
+#undef USB_DEBUG_EPID
+#undef USB_DEBUG_SB
+#undef USB_DEBUG_DESC
+#undef USB_DEBUG_URB
+#undef USB_DEBUG_TRACE
+#undef USB_DEBUG_BULK
+#undef USB_DEBUG_CTRL
+#undef USB_DEBUG_INTR
+#undef USB_DEBUG_ISOC
+
+#ifdef USB_DEBUG_RH
+#define dbg_rh(format, arg...) printk(KERN_DEBUG __FILE__ ": (RH) " format "\n" , ## arg)
+#else
+#define dbg_rh(format, arg...) do {} while (0)
+#endif
+
+#ifdef USB_DEBUG_EPID
+#define dbg_epid(format, arg...) printk(KERN_DEBUG __FILE__ ": (EPID) " format "\n" , ## arg)
+#else
+#define dbg_epid(format, arg...) do {} while (0)
+#endif
+
+#ifdef USB_DEBUG_SB
+#define dbg_sb(format, arg...) printk(KERN_DEBUG __FILE__ ": (SB) " format "\n" , ## arg)
+#else
+#define dbg_sb(format, arg...) do {} while (0)
+#endif
+
+#ifdef USB_DEBUG_CTRL
+#define dbg_ctrl(format, arg...) printk(KERN_DEBUG __FILE__ ": (CTRL) " format "\n" , ## arg)
+#else
+#define dbg_ctrl(format, arg...) do {} while (0)
+#endif
+
+#ifdef USB_DEBUG_BULK
+#define dbg_bulk(format, arg...) printk(KERN_DEBUG __FILE__ ": (BULK) " format "\n" , ## arg)
+#else
+#define dbg_bulk(format, arg...) do {} while (0)
+#endif
+
+#ifdef USB_DEBUG_INTR
+#define dbg_intr(format, arg...) printk(KERN_DEBUG __FILE__ ": (INTR) " format "\n" , ## arg)
+#else
+#define dbg_intr(format, arg...) do {} while (0)
+#endif
+
+#ifdef USB_DEBUG_ISOC
+#define dbg_isoc(format, arg...) printk(KERN_DEBUG __FILE__ ": (ISOC) " format "\n" , ## arg)
+#else
+#define dbg_isoc(format, arg...) do {} while (0)
+#endif
+
+#ifdef USB_DEBUG_TRACE
+#define DBFENTER (printk(": Entering: %s\n", __FUNCTION__))
+#define DBFEXIT  (printk(": Exiting:  %s\n", __FUNCTION__))
+#else
+#define DBFENTER do {} while (0)
+#define DBFEXIT  do {} while (0)
+#endif
+
+#define usb_pipeslow(pipe)	(((pipe) >> 26) & 1)
+
+/*-------------------------------------------------------------------
+ Virtual Root Hub
+ -------------------------------------------------------------------*/
+
+static __u8 root_hub_dev_des[] =
+{
+	0x12,  /*  __u8  bLength; */
+	0x01,  /*  __u8  bDescriptorType; Device */
+	0x00,  /*  __u16 bcdUSB; v1.0 */
+	0x01,
+	0x09,  /*  __u8  bDeviceClass; HUB_CLASSCODE */
+	0x00,  /*  __u8  bDeviceSubClass; */
+	0x00,  /*  __u8  bDeviceProtocol; */
+	0x08,  /*  __u8  bMaxPacketSize0; 8 Bytes */
+	0x00,  /*  __u16 idVendor; */
+	0x00,
+	0x00,  /*  __u16 idProduct; */
+	0x00,
+	0x00,  /*  __u16 bcdDevice; */
+	0x00,
+	0x00,  /*  __u8  iManufacturer; */
+	0x02,  /*  __u8  iProduct; */
+	0x01,  /*  __u8  iSerialNumber; */
+	0x01   /*  __u8  bNumConfigurations; */
+};
+
+/* Configuration descriptor */
+static __u8 root_hub_config_des[] =
+{
+	0x09,  /*  __u8  bLength; */
+	0x02,  /*  __u8  bDescriptorType; Configuration */
+	0x19,  /*  __u16 wTotalLength; */
+	0x00,
+	0x01,  /*  __u8  bNumInterfaces; */
+	0x01,  /*  __u8  bConfigurationValue; */
+	0x00,  /*  __u8  iConfiguration; */
+	0x40,  /*  __u8  bmAttributes; Bit 7: Bus-powered */
+	0x00,  /*  __u8  MaxPower; */
+
+     /* interface */
+	0x09,  /*  __u8  if_bLength; */
+	0x04,  /*  __u8  if_bDescriptorType; Interface */
+	0x00,  /*  __u8  if_bInterfaceNumber; */
+	0x00,  /*  __u8  if_bAlternateSetting; */
+	0x01,  /*  __u8  if_bNumEndpoints; */
+	0x09,  /*  __u8  if_bInterfaceClass; HUB_CLASSCODE */
+	0x00,  /*  __u8  if_bInterfaceSubClass; */
+	0x00,  /*  __u8  if_bInterfaceProtocol; */
+	0x00,  /*  __u8  if_iInterface; */
+
+     /* endpoint */
+	0x07,  /*  __u8  ep_bLength; */
+	0x05,  /*  __u8  ep_bDescriptorType; Endpoint */
+	0x81,  /*  __u8  ep_bEndpointAddress; IN Endpoint 1 */
+	0x03,  /*  __u8  ep_bmAttributes; Interrupt */
+	0x08,  /*  __u16 ep_wMaxPacketSize; 8 Bytes */
+	0x00,
+	0xff   /*  __u8  ep_bInterval; 255 ms */
+};
+
+static __u8 root_hub_hub_des[] =
+{
+	0x09,  /*  __u8  bLength; */
+	0x29,  /*  __u8  bDescriptorType; Hub-descriptor */
+	0x02,  /*  __u8  bNbrPorts; */
+	0x00,  /* __u16  wHubCharacteristics; */
+	0x00,
+	0x01,  /*  __u8  bPwrOn2pwrGood; 2ms */
+	0x00,  /*  __u8  bHubContrCurrent; 0 mA */
+	0x00,  /*  __u8  DeviceRemovable; *** 7 Ports max *** */
+	0xff   /*  __u8  PortPwrCtrlMask; *** 7 ports max *** */
+};
+
+static struct timer_list bulk_start_timer = TIMER_INITIALIZER(NULL, 0, 0);
+static struct timer_list bulk_eot_timer = TIMER_INITIALIZER(NULL, 0, 0);
+
+/* We want the start timer to expire before the eot timer, because the former might start
+   traffic, thus making it unnecessary for the latter to time out. */
+#define BULK_START_TIMER_INTERVAL (HZ/10) /* 100 ms */
+#define BULK_EOT_TIMER_INTERVAL (HZ/10+2) /* 120 ms */
+
+#define OK(x) len = (x); dbg_rh("OK(%d): line: %d", x, __LINE__); break
+#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \
+{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);}
+
+#define SLAB_FLAG     (in_interrupt() ? SLAB_ATOMIC : SLAB_KERNEL)
+#define KMALLOC_FLAG  (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
+
+/* Most helpful debugging aid */
+#define assert(expr) ((void) ((expr) ? 0 : (err("assert failed at line %d",__LINE__))))
+
+/* Alternative assert define which stops after a failed assert. */
+/*
+#define assert(expr)                                      \
+{                                                         \
+        if (!(expr)) {                                    \
+                err("assert failed at line %d",__LINE__); \
+                while (1);                                \
+        }                                                 \
+}
+*/
+
+
+/* FIXME: Should RX_BUF_SIZE be a config option, or maybe we should adjust it dynamically?
+   To adjust it dynamically we would have to get an interrupt when we reach the end
+   of the rx descriptor list, or when we get close to the end, and then allocate more
+   descriptors. */
+
+#define NBR_OF_RX_DESC     512
+#define RX_DESC_BUF_SIZE   1024
+#define RX_BUF_SIZE        (NBR_OF_RX_DESC * RX_DESC_BUF_SIZE)
+
+/* The number of epids is, among other things, used for pre-allocating
+   ctrl, bulk and isoc EP descriptors (one for each epid).
+   Assumed to be > 1 when initiating the DMA lists. */
+#define NBR_OF_EPIDS       32
+
+/* Support interrupt traffic intervals up to 128 ms. */
+#define MAX_INTR_INTERVAL 128
+
+/* If periodic traffic (intr or isoc) is to be used, then one entry in the EP table
+   must be "invalid". By this we mean that we shouldn't care about epid attentions
+   for this epid, or at least handle them differently from epid attentions for "valid"
+   epids. This define determines which one to use (don't change it). */
+#define INVALID_EPID     31
+/* A special epid for the bulk dummys. */
+#define DUMMY_EPID       30
+
+/* This is just a software cache for the valid entries in R_USB_EPT_DATA. */
+static __u32 epid_usage_bitmask;
+
+/* A bitfield to keep information on in/out traffic is needed to uniquely identify
+   an endpoint on a device, since the most significant bit which indicates traffic
+   direction is lacking in the ep_id field (ETRAX epids can handle both in and
+   out traffic on endpoints that are otherwise identical). The USB framework, however,
+   relies on them to be handled separately.  For example, bulk IN and OUT urbs cannot
+   be queued in the same list, since they would block each other. */
+static __u32 epid_out_traffic;
+
+/* DMA IN cache bug. Align the DMA IN buffers to 32 bytes, i.e. a cache line.
+   Since RX_DESC_BUF_SIZE is 1024 is a multiple of 32, all rx buffers will be cache aligned. */
+static volatile unsigned char RxBuf[RX_BUF_SIZE] __attribute__ ((aligned (32)));
+static volatile USB_IN_Desc_t RxDescList[NBR_OF_RX_DESC] __attribute__ ((aligned (4)));
+
+/* Pointers into RxDescList. */
+static volatile USB_IN_Desc_t *myNextRxDesc;
+static volatile USB_IN_Desc_t *myLastRxDesc;
+static volatile USB_IN_Desc_t *myPrevRxDesc;
+
+/* EP descriptors must be 32-bit aligned. */
+static volatile USB_EP_Desc_t TxCtrlEPList[NBR_OF_EPIDS] __attribute__ ((aligned (4)));
+static volatile USB_EP_Desc_t TxBulkEPList[NBR_OF_EPIDS] __attribute__ ((aligned (4)));
+/* After each enabled bulk EP (IN or OUT) we put two disabled EP descriptors with the eol flag set,
+   causing the DMA to stop the DMA channel. The first of these two has the intr flag set, which
+   gives us a dma8_sub0_descr interrupt. When we receive this, we advance the DMA one step in the
+   EP list and then restart the bulk channel, thus forcing a switch between bulk EP descriptors
+   in each frame. */
+static volatile USB_EP_Desc_t TxBulkDummyEPList[NBR_OF_EPIDS][2] __attribute__ ((aligned (4)));
+
+static volatile USB_EP_Desc_t TxIsocEPList[NBR_OF_EPIDS] __attribute__ ((aligned (4)));
+static volatile USB_SB_Desc_t TxIsocSB_zout __attribute__ ((aligned (4)));
+
+static volatile USB_EP_Desc_t TxIntrEPList[MAX_INTR_INTERVAL] __attribute__ ((aligned (4)));
+static volatile USB_SB_Desc_t TxIntrSB_zout __attribute__ ((aligned (4)));
+
+/* A zout transfer makes a memory access at the address of its buf pointer, which means that setting
+   this buf pointer to 0 will cause an access to the flash. In addition to this, setting sw_len to 0
+   results in a 16/32 bytes (depending on DMA burst size) transfer. Instead, we set it to 1, and point
+   it to this buffer. */
+static int zout_buffer[4] __attribute__ ((aligned (4)));
+
+/* Cache for allocating new EP and SB descriptors. */
+static kmem_cache_t *usb_desc_cache;
+
+/* Cache for the registers allocated in the top half. */
+static kmem_cache_t *top_half_reg_cache;
+
+/* Cache for the data allocated in the isoc descr top half. */
+static kmem_cache_t *isoc_compl_cache;
+
+static struct usb_bus *etrax_usb_bus;
+
+/* This is a circular (double-linked) list of the active urbs for each epid.
+   The head is never removed, and new urbs are linked onto the list as
+   urb_entry_t elements. Don't reference urb_list directly; use the wrapper
+   functions instead. Note that working with these lists might require spinlock
+   protection. */
+static struct list_head urb_list[NBR_OF_EPIDS];
+
+/* Read about the need and usage of this lock in submit_ctrl_urb. */
+static spinlock_t urb_list_lock;
+
+/* Used when unlinking asynchronously. */
+static struct list_head urb_unlink_list;
+
+/* for returning string descriptors in UTF-16LE */
+static int ascii2utf (char *ascii, __u8 *utf, int utfmax)
+{
+	int retval;
+
+	for (retval = 0; *ascii && utfmax > 1; utfmax -= 2, retval += 2) {
+		*utf++ = *ascii++ & 0x7f;
+		*utf++ = 0;
+	}
+	return retval;
+}
+
+static int usb_root_hub_string (int id, int serial, char *type, __u8 *data, int len)
+{
+	char buf [30];
+
+	// assert (len > (2 * (sizeof (buf) + 1)));
+	// assert (strlen (type) <= 8);
+
+	// language ids
+	if (id == 0) {
+		*data++ = 4; *data++ = 3;	/* 4 bytes data */
+		*data++ = 0; *data++ = 0;	/* some language id */
+		return 4;
+
+	// serial number
+	} else if (id == 1) {
+		sprintf (buf, "%x", serial);
+
+	// product description
+	} else if (id == 2) {
+		sprintf (buf, "USB %s Root Hub", type);
+
+	// id 3 == vendor description
+
+	// unsupported IDs --> "stall"
+	} else
+	    return 0;
+
+	data [0] = 2 + ascii2utf (buf, data + 2, len - 2);
+	data [1] = 3;
+	return data [0];
+}
+
+/* Wrappers around the list functions (include/linux/list.h). */
+
+static inline int urb_list_empty(int epid)
+{
+	return list_empty(&urb_list[epid]);
+}
+
+/* Returns first urb for this epid, or NULL if list is empty. */
+static inline struct urb *urb_list_first(int epid)
+{
+	struct urb *first_urb = 0;
+
+	if (!urb_list_empty(epid)) {
+		/* Get the first urb (i.e. head->next). */
+		urb_entry_t *urb_entry = list_entry((&urb_list[epid])->next, urb_entry_t, list);
+		first_urb = urb_entry->urb;
+	}
+	return first_urb;
+}
+
+/* Adds an urb_entry last in the list for this epid. */
+static inline void urb_list_add(struct urb *urb, int epid)
+{
+	urb_entry_t *urb_entry = (urb_entry_t *)kmalloc(sizeof(urb_entry_t), KMALLOC_FLAG);
+	assert(urb_entry);
+
+	urb_entry->urb = urb;
+	list_add_tail(&urb_entry->list, &urb_list[epid]);
+}
+
+/* Search through the list for an element that contains this urb. (The list
+   is expected to be short and the one we are about to delete will often be
+   the first in the list.) */
+static inline urb_entry_t *__urb_list_entry(struct urb *urb, int epid)
+{
+	struct list_head *entry;
+	struct list_head *tmp;
+	urb_entry_t *urb_entry;
+
+	list_for_each_safe(entry, tmp, &urb_list[epid]) {
+		urb_entry = list_entry(entry, urb_entry_t, list);
+		assert(urb_entry);
+		assert(urb_entry->urb);
+
+		if (urb_entry->urb == urb) {
+			return urb_entry;
+		}
+	}
+	return 0;
+}
+
+/* Delete an urb from the list. */
+static inline void urb_list_del(struct urb *urb, int epid)
+{
+	urb_entry_t *urb_entry = __urb_list_entry(urb, epid);
+	assert(urb_entry);
+
+	/* Delete entry and free. */
+	list_del(&urb_entry->list);
+	kfree(urb_entry);
+}
+
+/* Move an urb to the end of the list. */
+static inline void urb_list_move_last(struct urb *urb, int epid)
+{
+	urb_entry_t *urb_entry = __urb_list_entry(urb, epid);
+	assert(urb_entry);
+
+	list_del(&urb_entry->list);
+	list_add_tail(&urb_entry->list, &urb_list[epid]);
+}
+
+/* Get the next urb in the list. */
+static inline struct urb *urb_list_next(struct urb *urb, int epid)
+{
+	urb_entry_t *urb_entry = __urb_list_entry(urb, epid);
+
+	assert(urb_entry);
+
+	if (urb_entry->list.next != &urb_list[epid]) {
+		struct list_head *elem = urb_entry->list.next;
+		urb_entry = list_entry(elem, urb_entry_t, list);
+		return urb_entry->urb;
+	} else {
+		return NULL;
+	}
+}
+
+
+
+/* For debug purposes only. */
+static inline void urb_list_dump(int epid)
+{
+	struct list_head *entry;
+	struct list_head *tmp;
+	urb_entry_t *urb_entry;
+	int i = 0;
+
+	info("Dumping urb list for epid %d", epid);
+
+	list_for_each_safe(entry, tmp, &urb_list[epid]) {
+		urb_entry = list_entry(entry, urb_entry_t, list);
+		info("   entry %d, urb = 0x%lx", i, (unsigned long)urb_entry->urb);
+	}
+}
+
+static void init_rx_buffers(void);
+static int etrax_rh_unlink_urb(struct urb *urb);
+static void etrax_rh_send_irq(struct urb *urb);
+static void etrax_rh_init_int_timer(struct urb *urb);
+static void etrax_rh_int_timer_do(unsigned long ptr);
+
+static int etrax_usb_setup_epid(struct urb *urb);
+static int etrax_usb_lookup_epid(struct urb *urb);
+static int etrax_usb_allocate_epid(void);
+static void etrax_usb_free_epid(int epid);
+
+static int etrax_remove_from_sb_list(struct urb *urb);
+
+static void* etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size, int mem_flags, dma_addr_t *dma);
+static void etrax_usb_buffer_free(struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma);
+
+static void etrax_usb_add_to_bulk_sb_list(struct urb *urb, int epid);
+static void etrax_usb_add_to_ctrl_sb_list(struct urb *urb, int epid);
+static void etrax_usb_add_to_intr_sb_list(struct urb *urb, int epid);
+static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid);
+
+static int etrax_usb_submit_bulk_urb(struct urb *urb);
+static int etrax_usb_submit_ctrl_urb(struct urb *urb);
+static int etrax_usb_submit_intr_urb(struct urb *urb);
+static int etrax_usb_submit_isoc_urb(struct urb *urb);
+
+static int etrax_usb_submit_urb(struct urb *urb, int mem_flags);
+static int etrax_usb_unlink_urb(struct urb *urb, int status);
+static int etrax_usb_get_frame_number(struct usb_device *usb_dev);
+static int etrax_usb_allocate_dev(struct usb_device *usb_dev);
+static int etrax_usb_deallocate_dev(struct usb_device *usb_dev);
+
+static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc, struct pt_regs *regs);
+static irqreturn_t etrax_usb_rx_interrupt(int irq, void *vhc, struct pt_regs *regs);
+static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc, struct pt_regs *regs);
+static void etrax_usb_hc_interrupt_bottom_half(void *data);
+
+static void etrax_usb_isoc_descr_interrupt_bottom_half(void *data);
+
+
+/* The following is a list of interrupt handlers for the host controller interrupts we use.
+   They are called from etrax_usb_hc_interrupt_bottom_half. */
+static void etrax_usb_hc_isoc_eof_interrupt(void);
+static void etrax_usb_hc_bulk_eot_interrupt(int timer_induced);
+static void etrax_usb_hc_epid_attn_interrupt(usb_interrupt_registers_t *reg);
+static void etrax_usb_hc_port_status_interrupt(usb_interrupt_registers_t *reg);
+static void etrax_usb_hc_ctl_status_interrupt(usb_interrupt_registers_t *reg);
+
+static int etrax_rh_submit_urb (struct urb *urb);
+
+/* Forward declaration needed because they are used in the rx interrupt routine. */
+static void etrax_usb_complete_urb(struct urb *urb, int status);
+static void etrax_usb_complete_bulk_urb(struct urb *urb, int status);
+static void etrax_usb_complete_ctrl_urb(struct urb *urb, int status);
+static void etrax_usb_complete_intr_urb(struct urb *urb, int status);
+static void etrax_usb_complete_isoc_urb(struct urb *urb, int status);
+
+static int etrax_usb_hc_init(void);
+static void etrax_usb_hc_cleanup(void);
+
+static struct usb_operations etrax_usb_device_operations =
+{
+	.allocate = etrax_usb_allocate_dev,
+	.deallocate = etrax_usb_deallocate_dev,
+	.get_frame_number = etrax_usb_get_frame_number,
+	.submit_urb = etrax_usb_submit_urb,
+	.unlink_urb = etrax_usb_unlink_urb,
+        .buffer_alloc = etrax_usb_buffer_alloc,
+        .buffer_free = etrax_usb_buffer_free
+};
+
+/* Note that these functions are always available in their "__" variants, for use in
+   error situations. The "__" missing variants are controlled by the USB_DEBUG_DESC/
+   USB_DEBUG_URB macros. */
+static void __dump_urb(struct urb* purb)
+{
+	printk("\nurb                  :0x%08lx\n", (unsigned long)purb);
+	printk("dev                   :0x%08lx\n", (unsigned long)purb->dev);
+	printk("pipe                  :0x%08x\n", purb->pipe);
+	printk("status                :%d\n", purb->status);
+	printk("transfer_flags        :0x%08x\n", purb->transfer_flags);
+	printk("transfer_buffer       :0x%08lx\n", (unsigned long)purb->transfer_buffer);
+	printk("transfer_buffer_length:%d\n", purb->transfer_buffer_length);
+	printk("actual_length         :%d\n", purb->actual_length);
+	printk("setup_packet          :0x%08lx\n", (unsigned long)purb->setup_packet);
+	printk("start_frame           :%d\n", purb->start_frame);
+	printk("number_of_packets     :%d\n", purb->number_of_packets);
+	printk("interval              :%d\n", purb->interval);
+	printk("error_count           :%d\n", purb->error_count);
+	printk("context               :0x%08lx\n", (unsigned long)purb->context);
+	printk("complete              :0x%08lx\n\n", (unsigned long)purb->complete);
+}
+
+static void __dump_in_desc(volatile USB_IN_Desc_t *in)
+{
+	printk("\nUSB_IN_Desc at 0x%08lx\n", (unsigned long)in);
+	printk("  sw_len  : 0x%04x (%d)\n", in->sw_len, in->sw_len);
+	printk("  command : 0x%04x\n", in->command);
+	printk("  next    : 0x%08lx\n", in->next);
+	printk("  buf     : 0x%08lx\n", in->buf);
+	printk("  hw_len  : 0x%04x (%d)\n", in->hw_len, in->hw_len);
+	printk("  status  : 0x%04x\n\n", in->status);
+}
+
+static void __dump_sb_desc(volatile USB_SB_Desc_t *sb)
+{
+	char tt = (sb->command & 0x30) >> 4;
+	char *tt_string;
+
+	switch (tt) {
+	case 0:
+		tt_string = "zout";
+		break;
+	case 1:
+		tt_string = "in";
+		break;
+	case 2:
+		tt_string = "out";
+		break;
+	case 3:
+		tt_string = "setup";
+		break;
+	default:
+		tt_string = "unknown (weird)";
+	}
+
+	printk("\n   USB_SB_Desc at 0x%08lx\n", (unsigned long)sb);
+	printk("     command : 0x%04x\n", sb->command);
+	printk("        rem     : %d\n", (sb->command & 0x3f00) >> 8);
+	printk("        full    : %d\n", (sb->command & 0x40) >> 6);
+	printk("        tt      : %d (%s)\n", tt, tt_string);
+	printk("        intr    : %d\n", (sb->command & 0x8) >> 3);
+	printk("        eot     : %d\n", (sb->command & 0x2) >> 1);
+	printk("        eol     : %d\n", sb->command & 0x1);
+	printk("     sw_len  : 0x%04x (%d)\n", sb->sw_len, sb->sw_len);
+	printk("     next    : 0x%08lx\n", sb->next);
+	printk("     buf     : 0x%08lx\n\n", sb->buf);
+}
+
+
+static void __dump_ep_desc(volatile USB_EP_Desc_t *ep)
+{
+	printk("\nUSB_EP_Desc at 0x%08lx\n", (unsigned long)ep);
+	printk("  command : 0x%04x\n", ep->command);
+	printk("     ep_id   : %d\n", (ep->command & 0x1f00) >> 8);
+	printk("     enable  : %d\n", (ep->command & 0x10) >> 4);
+	printk("     intr    : %d\n", (ep->command & 0x8) >> 3);
+	printk("     eof     : %d\n", (ep->command & 0x2) >> 1);
+	printk("     eol     : %d\n", ep->command & 0x1);
+	printk("  hw_len  : 0x%04x (%d)\n", ep->hw_len, ep->hw_len);
+	printk("  next    : 0x%08lx\n", ep->next);
+	printk("  sub     : 0x%08lx\n\n", ep->sub);
+}
+
+static inline void __dump_ep_list(int pipe_type)
+{
+	volatile USB_EP_Desc_t *ep;
+	volatile USB_EP_Desc_t *first_ep;
+	volatile USB_SB_Desc_t *sb;
+
+	switch (pipe_type)
+	{
+	case PIPE_BULK:
+		first_ep = &TxBulkEPList[0];
+		break;
+	case PIPE_CONTROL:
+		first_ep = &TxCtrlEPList[0];
+		break;
+	case PIPE_INTERRUPT:
+		first_ep = &TxIntrEPList[0];
+		break;
+	case PIPE_ISOCHRONOUS:
+		first_ep = &TxIsocEPList[0];
+		break;
+	default:
+		warn("Cannot dump unknown traffic type");
+		return;
+	}
+	ep = first_ep;
+
+	printk("\n\nDumping EP list...\n\n");
+
+	do {
+		__dump_ep_desc(ep);
+		/* Cannot phys_to_virt on 0 as it turns into 80000000, which is != 0. */
+		sb = ep->sub ? phys_to_virt(ep->sub) : 0;
+		while (sb) {
+			__dump_sb_desc(sb);
+			sb = sb->next ? phys_to_virt(sb->next) : 0;
+		}
+		ep = (volatile USB_EP_Desc_t *)(phys_to_virt(ep->next));
+
+	} while (ep != first_ep);
+}
+
+static inline void __dump_ept_data(int epid)
+{
+	unsigned long flags;
+	__u32 r_usb_ept_data;
+
+	if (epid < 0 || epid > 31) {
+		printk("Cannot dump ept data for invalid epid %d\n", epid);
+		return;
+	}
+
+	save_flags(flags);
+	cli();
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+	nop();
+	r_usb_ept_data = *R_USB_EPT_DATA;
+	restore_flags(flags);
+
+	printk("\nR_USB_EPT_DATA = 0x%x for epid %d :\n", r_usb_ept_data, epid);
+	if (r_usb_ept_data == 0) {
+		/* No need for more detailed printing. */
+		return;
+	}
+	printk("  valid           : %d\n", (r_usb_ept_data & 0x80000000) >> 31);
+	printk("  hold            : %d\n", (r_usb_ept_data & 0x40000000) >> 30);
+	printk("  error_count_in  : %d\n", (r_usb_ept_data & 0x30000000) >> 28);
+	printk("  t_in            : %d\n", (r_usb_ept_data & 0x08000000) >> 27);
+	printk("  low_speed       : %d\n", (r_usb_ept_data & 0x04000000) >> 26);
+	printk("  port            : %d\n", (r_usb_ept_data & 0x03000000) >> 24);
+	printk("  error_code      : %d\n", (r_usb_ept_data & 0x00c00000) >> 22);
+	printk("  t_out           : %d\n", (r_usb_ept_data & 0x00200000) >> 21);
+	printk("  error_count_out : %d\n", (r_usb_ept_data & 0x00180000) >> 19);
+	printk("  max_len         : %d\n", (r_usb_ept_data & 0x0003f800) >> 11);
+	printk("  ep              : %d\n", (r_usb_ept_data & 0x00000780) >> 7);
+	printk("  dev             : %d\n", (r_usb_ept_data & 0x0000003f));
+}
+
+static inline void __dump_ept_data_list(void)
+{
+	int i;
+
+	printk("Dumping the whole R_USB_EPT_DATA list\n");
+
+	for (i = 0; i < 32; i++) {
+		__dump_ept_data(i);
+	}
+}
+#ifdef USB_DEBUG_DESC
+#define dump_in_desc(...) __dump_in_desc(...)
+#define dump_sb_desc(...) __dump_sb_desc(...)
+#define dump_ep_desc(...) __dump_ep_desc(...)
+#else
+#define dump_in_desc(...) do {} while (0)
+#define dump_sb_desc(...) do {} while (0)
+#define dump_ep_desc(...) do {} while (0)
+#endif
+
+#ifdef USB_DEBUG_URB
+#define dump_urb(x)     __dump_urb(x)
+#else
+#define dump_urb(x)     do {} while (0)
+#endif
+
+static void init_rx_buffers(void)
+{
+	int i;
+
+	DBFENTER;
+
+	for (i = 0; i < (NBR_OF_RX_DESC - 1); i++) {
+		RxDescList[i].sw_len = RX_DESC_BUF_SIZE;
+		RxDescList[i].command = 0;
+		RxDescList[i].next = virt_to_phys(&RxDescList[i + 1]);
+		RxDescList[i].buf = virt_to_phys(RxBuf + (i * RX_DESC_BUF_SIZE));
+		RxDescList[i].hw_len = 0;
+		RxDescList[i].status = 0;
+
+		/* DMA IN cache bug. (struct etrax_dma_descr has the same layout as USB_IN_Desc
+		   for the relevant fields.) */
+		prepare_rx_descriptor((struct etrax_dma_descr*)&RxDescList[i]);
+
+	}
+
+	RxDescList[i].sw_len = RX_DESC_BUF_SIZE;
+	RxDescList[i].command = IO_STATE(USB_IN_command, eol, yes);
+	RxDescList[i].next = virt_to_phys(&RxDescList[0]);
+	RxDescList[i].buf = virt_to_phys(RxBuf + (i * RX_DESC_BUF_SIZE));
+	RxDescList[i].hw_len = 0;
+	RxDescList[i].status = 0;
+
+	myNextRxDesc = &RxDescList[0];
+	myLastRxDesc = &RxDescList[NBR_OF_RX_DESC - 1];
+	myPrevRxDesc = &RxDescList[NBR_OF_RX_DESC - 1];
+
+	*R_DMA_CH9_FIRST = virt_to_phys(myNextRxDesc);
+	*R_DMA_CH9_CMD = IO_STATE(R_DMA_CH9_CMD, cmd, start);
+
+	DBFEXIT;
+}
+
+static void init_tx_bulk_ep(void)
+{
+	int i;
+
+	DBFENTER;
+
+	for (i = 0; i < (NBR_OF_EPIDS - 1); i++) {
+		CHECK_ALIGN(&TxBulkEPList[i]);
+		TxBulkEPList[i].hw_len = 0;
+		TxBulkEPList[i].command = IO_FIELD(USB_EP_command, epid, i);
+		TxBulkEPList[i].sub = 0;
+		TxBulkEPList[i].next = virt_to_phys(&TxBulkEPList[i + 1]);
+
+		/* Initiate two EPs, disabled and with the eol flag set. No need for any
+		   preserved epid. */
+
+		/* The first one has the intr flag set so we get an interrupt when the DMA
+		   channel is about to become disabled. */
+		CHECK_ALIGN(&TxBulkDummyEPList[i][0]);
+		TxBulkDummyEPList[i][0].hw_len = 0;
+		TxBulkDummyEPList[i][0].command = (IO_FIELD(USB_EP_command, epid, DUMMY_EPID) |
+						   IO_STATE(USB_EP_command, eol, yes) |
+						   IO_STATE(USB_EP_command, intr, yes));
+		TxBulkDummyEPList[i][0].sub = 0;
+		TxBulkDummyEPList[i][0].next = virt_to_phys(&TxBulkDummyEPList[i][1]);
+
+		/* The second one. */
+		CHECK_ALIGN(&TxBulkDummyEPList[i][1]);
+		TxBulkDummyEPList[i][1].hw_len = 0;
+		TxBulkDummyEPList[i][1].command = (IO_FIELD(USB_EP_command, epid, DUMMY_EPID) |
+						   IO_STATE(USB_EP_command, eol, yes));
+		TxBulkDummyEPList[i][1].sub = 0;
+		/* The last dummy's next pointer is the same as the current EP's next pointer. */
+		TxBulkDummyEPList[i][1].next = virt_to_phys(&TxBulkEPList[i + 1]);
+	}
+
+	/* Configure the last one. */
+	CHECK_ALIGN(&TxBulkEPList[i]);
+	TxBulkEPList[i].hw_len = 0;
+	TxBulkEPList[i].command = (IO_STATE(USB_EP_command, eol, yes) |
+				   IO_FIELD(USB_EP_command, epid, i));
+	TxBulkEPList[i].sub = 0;
+	TxBulkEPList[i].next = virt_to_phys(&TxBulkEPList[0]);
+
+	/* No need configuring dummy EPs for the last one as it will never be used for
+	   bulk traffic (i == INVALD_EPID at this point). */
+
+	/* Set up to start on the last EP so we will enable it when inserting traffic
+	   for the first time (imitating the situation where the DMA has stopped
+	   because there was no more traffic). */
+	*R_DMA_CH8_SUB0_EP = virt_to_phys(&TxBulkEPList[i]);
+	/* No point in starting the bulk channel yet.
+	 *R_DMA_CH8_SUB0_CMD = IO_STATE(R_DMA_CH8_SUB0_CMD, cmd, start); */
+	DBFEXIT;
+}
+
+static void init_tx_ctrl_ep(void)
+{
+	int i;
+
+	DBFENTER;
+
+	for (i = 0; i < (NBR_OF_EPIDS - 1); i++) {
+		CHECK_ALIGN(&TxCtrlEPList[i]);
+		TxCtrlEPList[i].hw_len = 0;
+		TxCtrlEPList[i].command = IO_FIELD(USB_EP_command, epid, i);
+		TxCtrlEPList[i].sub = 0;
+		TxCtrlEPList[i].next = virt_to_phys(&TxCtrlEPList[i + 1]);
+	}
+
+	CHECK_ALIGN(&TxCtrlEPList[i]);
+	TxCtrlEPList[i].hw_len = 0;
+	TxCtrlEPList[i].command = (IO_STATE(USB_EP_command, eol, yes) |
+				   IO_FIELD(USB_EP_command, epid, i));
+
+	TxCtrlEPList[i].sub = 0;
+	TxCtrlEPList[i].next = virt_to_phys(&TxCtrlEPList[0]);
+
+	*R_DMA_CH8_SUB1_EP = virt_to_phys(&TxCtrlEPList[0]);
+	*R_DMA_CH8_SUB1_CMD = IO_STATE(R_DMA_CH8_SUB1_CMD, cmd, start);
+
+	DBFEXIT;
+}
+
+
+static void init_tx_intr_ep(void)
+{
+	int i;
+
+	DBFENTER;
+
+	/* Read comment at zout_buffer declaration for an explanation to this. */
+	TxIntrSB_zout.sw_len = 1;
+	TxIntrSB_zout.next = 0;
+	TxIntrSB_zout.buf = virt_to_phys(&zout_buffer[0]);
+	TxIntrSB_zout.command = (IO_FIELD(USB_SB_command, rem, 0) |
+				 IO_STATE(USB_SB_command, tt, zout) |
+				 IO_STATE(USB_SB_command, full, yes) |
+				 IO_STATE(USB_SB_command, eot, yes) |
+				 IO_STATE(USB_SB_command, eol, yes));
+
+	for (i = 0; i < (MAX_INTR_INTERVAL - 1); i++) {
+		CHECK_ALIGN(&TxIntrEPList[i]);
+		TxIntrEPList[i].hw_len = 0;
+		TxIntrEPList[i].command =
+			(IO_STATE(USB_EP_command, eof, yes) |
+			 IO_STATE(USB_EP_command, enable, yes) |
+			 IO_FIELD(USB_EP_command, epid, INVALID_EPID));
+		TxIntrEPList[i].sub = virt_to_phys(&TxIntrSB_zout);
+		TxIntrEPList[i].next = virt_to_phys(&TxIntrEPList[i + 1]);
+	}
+
+	CHECK_ALIGN(&TxIntrEPList[i]);
+	TxIntrEPList[i].hw_len = 0;
+	TxIntrEPList[i].command =
+		(IO_STATE(USB_EP_command, eof, yes) |
+		 IO_STATE(USB_EP_command, eol, yes) |
+		 IO_STATE(USB_EP_command, enable, yes) |
+		 IO_FIELD(USB_EP_command, epid, INVALID_EPID));
+	TxIntrEPList[i].sub = virt_to_phys(&TxIntrSB_zout);
+	TxIntrEPList[i].next = virt_to_phys(&TxIntrEPList[0]);
+
+	*R_DMA_CH8_SUB2_EP = virt_to_phys(&TxIntrEPList[0]);
+	*R_DMA_CH8_SUB2_CMD = IO_STATE(R_DMA_CH8_SUB2_CMD, cmd, start);
+	DBFEXIT;
+}
+
+static void init_tx_isoc_ep(void)
+{
+	int i;
+
+	DBFENTER;
+
+	/* Read comment at zout_buffer declaration for an explanation to this. */
+	TxIsocSB_zout.sw_len = 1;
+	TxIsocSB_zout.next = 0;
+	TxIsocSB_zout.buf = virt_to_phys(&zout_buffer[0]);
+	TxIsocSB_zout.command = (IO_FIELD(USB_SB_command, rem, 0) |
+				 IO_STATE(USB_SB_command, tt, zout) |
+				 IO_STATE(USB_SB_command, full, yes) |
+				 IO_STATE(USB_SB_command, eot, yes) |
+				 IO_STATE(USB_SB_command, eol, yes));
+
+	/* The last isochronous EP descriptor is a dummy. */
+
+	for (i = 0; i < (NBR_OF_EPIDS - 1); i++) {
+		CHECK_ALIGN(&TxIsocEPList[i]);
+		TxIsocEPList[i].hw_len = 0;
+		TxIsocEPList[i].command = IO_FIELD(USB_EP_command, epid, i);
+		TxIsocEPList[i].sub = 0;
+		TxIsocEPList[i].next = virt_to_phys(&TxIsocEPList[i + 1]);
+	}
+
+	CHECK_ALIGN(&TxIsocEPList[i]);
+	TxIsocEPList[i].hw_len = 0;
+
+	/* Must enable the last EP descr to get eof interrupt. */
+	TxIsocEPList[i].command = (IO_STATE(USB_EP_command, enable, yes) |
+				   IO_STATE(USB_EP_command, eof, yes) |
+				   IO_STATE(USB_EP_command, eol, yes) |
+				   IO_FIELD(USB_EP_command, epid, INVALID_EPID));
+	TxIsocEPList[i].sub = virt_to_phys(&TxIsocSB_zout);
+	TxIsocEPList[i].next = virt_to_phys(&TxIsocEPList[0]);
+
+	*R_DMA_CH8_SUB3_EP = virt_to_phys(&TxIsocEPList[0]);
+	*R_DMA_CH8_SUB3_CMD = IO_STATE(R_DMA_CH8_SUB3_CMD, cmd, start);
+
+	DBFEXIT;
+}
+
+static void etrax_usb_unlink_intr_urb(struct urb *urb)
+{
+	volatile USB_EP_Desc_t *first_ep;  /* First EP in the list. */
+	volatile USB_EP_Desc_t *curr_ep;   /* Current EP, the iterator. */
+	volatile USB_EP_Desc_t *next_ep;   /* The EP after current. */
+	volatile USB_EP_Desc_t *unlink_ep; /* The one we should remove from the list. */
+
+	int epid;
+
+	/* Read 8.8.4 in Designer's Reference, "Removing an EP Descriptor from the List". */
+
+	DBFENTER;
+
+	epid = ((etrax_urb_priv_t *)urb->hcpriv)->epid;
+
+	first_ep = &TxIntrEPList[0];
+	curr_ep = first_ep;
+
+
+	/* Note that this loop removes all EP descriptors with this epid. This assumes
+	   that all EP descriptors belong to the one and only urb for this epid. */
+
+	do {
+		next_ep = (USB_EP_Desc_t *)phys_to_virt(curr_ep->next);
+
+		if (IO_EXTRACT(USB_EP_command, epid, next_ep->command) == epid) {
+
+			dbg_intr("Found EP to unlink for epid %d", epid);
+
+			/* This is the one we should unlink. */
+			unlink_ep = next_ep;
+
+			/* Actually unlink the EP from the DMA list. */
+			curr_ep->next = unlink_ep->next;
+
+			/* Wait until the DMA is no longer at this descriptor. */
+			while (*R_DMA_CH8_SUB2_EP == virt_to_phys(unlink_ep));
+
+			/* Now we are free to remove it and its SB descriptor.
+			   Note that it is assumed here that there is only one sb in the
+			   sb list for this ep. */
+			kmem_cache_free(usb_desc_cache, phys_to_virt(unlink_ep->sub));
+			kmem_cache_free(usb_desc_cache, (USB_EP_Desc_t *)unlink_ep);
+		}
+
+		curr_ep = phys_to_virt(curr_ep->next);
+
+	} while (curr_ep != first_ep);
+        urb->hcpriv = NULL;
+}
+
+void etrax_usb_do_intr_recover(int epid)
+{
+	USB_EP_Desc_t *first_ep, *tmp_ep;
+
+	DBFENTER;
+
+	first_ep = (USB_EP_Desc_t *)phys_to_virt(*R_DMA_CH8_SUB2_EP);
+	tmp_ep = first_ep;
+
+	/* What this does is simply to walk the list of interrupt
+	   ep descriptors and enable those that are disabled. */
+
+	do {
+		if (IO_EXTRACT(USB_EP_command, epid, tmp_ep->command) == epid &&
+		    !(tmp_ep->command & IO_MASK(USB_EP_command, enable))) {
+			tmp_ep->command |= IO_STATE(USB_EP_command, enable, yes);
+		}
+
+		tmp_ep = (USB_EP_Desc_t *)phys_to_virt(tmp_ep->next);
+
+	} while (tmp_ep != first_ep);
+
+
+	DBFEXIT;
+}
+
+static int etrax_rh_unlink_urb (struct urb *urb)
+{
+	etrax_hc_t *hc;
+
+	DBFENTER;
+
+	hc = urb->dev->bus->hcpriv;
+
+	if (hc->rh.urb == urb) {
+		hc->rh.send = 0;
+		del_timer(&hc->rh.rh_int_timer);
+	}
+
+	DBFEXIT;
+	return 0;
+}
+
+static void etrax_rh_send_irq(struct urb *urb)
+{
+	__u16 data = 0;
+	etrax_hc_t *hc = urb->dev->bus->hcpriv;
+	DBFENTER;
+
+/*
+  dbg_rh("R_USB_FM_NUMBER   : 0x%08X", *R_USB_FM_NUMBER);
+  dbg_rh("R_USB_FM_REMAINING: 0x%08X", *R_USB_FM_REMAINING);
+*/
+
+	data |= (hc->rh.wPortChange_1) ? (1 << 1) : 0;
+	data |= (hc->rh.wPortChange_2) ? (1 << 2) : 0;
+
+	*((__u16 *)urb->transfer_buffer) = cpu_to_le16(data);
+	/* FIXME: Why is actual_length set to 1 when data is 2 bytes?
+	   Since only 1 byte is used, why not declare data as __u8? */
+	urb->actual_length = 1;
+	urb->status = 0;
+
+	if (hc->rh.send && urb->complete) {
+		dbg_rh("wPortChange_1: 0x%04X", hc->rh.wPortChange_1);
+		dbg_rh("wPortChange_2: 0x%04X", hc->rh.wPortChange_2);
+
+		urb->complete(urb, NULL);
+	}
+
+	DBFEXIT;
+}
+
+static void etrax_rh_init_int_timer(struct urb *urb)
+{
+	etrax_hc_t *hc;
+
+	DBFENTER;
+
+	hc = urb->dev->bus->hcpriv;
+	hc->rh.interval = urb->interval;
+	init_timer(&hc->rh.rh_int_timer);
+	hc->rh.rh_int_timer.function = etrax_rh_int_timer_do;
+	hc->rh.rh_int_timer.data = (unsigned long)urb;
+	/* FIXME: Is the jiffies resolution enough? All intervals < 10 ms will be mapped
+	   to 0, and the rest to the nearest lower 10 ms. */
+	hc->rh.rh_int_timer.expires = jiffies + ((HZ * hc->rh.interval) / 1000);
+	add_timer(&hc->rh.rh_int_timer);
+
+	DBFEXIT;
+}
+
+static void etrax_rh_int_timer_do(unsigned long ptr)
+{
+	struct urb *urb;
+	etrax_hc_t *hc;
+
+	DBFENTER;
+
+	urb = (struct urb*)ptr;
+	hc = urb->dev->bus->hcpriv;
+
+	if (hc->rh.send) {
+		etrax_rh_send_irq(urb);
+	}
+
+	DBFEXIT;
+}
+
+static int etrax_usb_setup_epid(struct urb *urb)
+{
+	int epid;
+	char devnum, endpoint, out_traffic, slow;
+	int maxlen;
+	unsigned long flags;
+
+	DBFENTER;
+
+	epid = etrax_usb_lookup_epid(urb);
+	if ((epid != -1)){
+		/* An epid that fits this urb has been found. */
+		DBFEXIT;
+		return epid;
+	}
+
+	/* We must find and initiate a new epid for this urb. */
+	epid = etrax_usb_allocate_epid();
+
+	if (epid == -1) {
+		/* Failed to allocate a new epid. */
+		DBFEXIT;
+		return epid;
+	}
+
+	/* We now have a new epid to use. Initiate it. */
+	set_bit(epid, (void *)&epid_usage_bitmask);
+
+	devnum = usb_pipedevice(urb->pipe);
+	endpoint = usb_pipeendpoint(urb->pipe);
+	slow = usb_pipeslow(urb->pipe);
+	maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
+	if (usb_pipetype(urb->pipe) == PIPE_CONTROL) {
+		/* We want both IN and OUT control traffic to be put on the same EP/SB list. */
+		out_traffic = 1;
+	} else {
+		out_traffic = usb_pipeout(urb->pipe);
+	}
+
+	save_flags(flags);
+	cli();
+
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+	nop();
+
+	if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+		*R_USB_EPT_DATA_ISO = IO_STATE(R_USB_EPT_DATA_ISO, valid, yes) |
+			/* FIXME: Change any to the actual port? */
+			IO_STATE(R_USB_EPT_DATA_ISO, port, any) |
+			IO_FIELD(R_USB_EPT_DATA_ISO, max_len, maxlen) |
+			IO_FIELD(R_USB_EPT_DATA_ISO, ep, endpoint) |
+			IO_FIELD(R_USB_EPT_DATA_ISO, dev, devnum);
+	} else {
+		*R_USB_EPT_DATA = IO_STATE(R_USB_EPT_DATA, valid, yes) |
+			IO_FIELD(R_USB_EPT_DATA, low_speed, slow) |
+			/* FIXME: Change any to the actual port? */
+			IO_STATE(R_USB_EPT_DATA, port, any) |
+			IO_FIELD(R_USB_EPT_DATA, max_len, maxlen) |
+			IO_FIELD(R_USB_EPT_DATA, ep, endpoint) |
+			IO_FIELD(R_USB_EPT_DATA, dev, devnum);
+	}
+
+	restore_flags(flags);
+
+	if (out_traffic) {
+		set_bit(epid, (void *)&epid_out_traffic);
+	} else {
+		clear_bit(epid, (void *)&epid_out_traffic);
+	}
+
+	dbg_epid("Setting up epid %d with devnum %d, endpoint %d and max_len %d (%s)",
+		 epid, devnum, endpoint, maxlen, out_traffic ? "OUT" : "IN");
+
+	DBFEXIT;
+	return epid;
+}
+
+static void etrax_usb_free_epid(int epid)
+{
+	unsigned long flags;
+
+	DBFENTER;
+
+	if (!test_bit(epid, (void *)&epid_usage_bitmask)) {
+		warn("Trying to free unused epid %d", epid);
+		DBFEXIT;
+		return;
+	}
+
+	save_flags(flags);
+	cli();
+
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+	nop();
+	while (*R_USB_EPT_DATA & IO_MASK(R_USB_EPT_DATA, hold));
+	/* This will, among other things, set the valid field to 0. */
+	*R_USB_EPT_DATA = 0;
+	restore_flags(flags);
+
+	clear_bit(epid, (void *)&epid_usage_bitmask);
+
+
+	dbg_epid("Freed epid %d", epid);
+
+	DBFEXIT;
+}
+
+static int etrax_usb_lookup_epid(struct urb *urb)
+{
+	int i;
+	__u32 data;
+	char devnum, endpoint, slow, out_traffic;
+	int maxlen;
+	unsigned long flags;
+
+	DBFENTER;
+
+	devnum = usb_pipedevice(urb->pipe);
+	endpoint = usb_pipeendpoint(urb->pipe);
+	slow = usb_pipeslow(urb->pipe);
+	maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
+	if (usb_pipetype(urb->pipe) == PIPE_CONTROL) {
+		/* We want both IN and OUT control traffic to be put on the same EP/SB list. */
+		out_traffic = 1;
+	} else {
+		out_traffic = usb_pipeout(urb->pipe);
+	}
+
+	/* Step through att epids. */
+	for (i = 0; i < NBR_OF_EPIDS; i++) {
+		if (test_bit(i, (void *)&epid_usage_bitmask) &&
+		    test_bit(i, (void *)&epid_out_traffic) == out_traffic) {
+
+			save_flags(flags);
+			cli();
+			*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, i);
+			nop();
+
+			if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+				data = *R_USB_EPT_DATA_ISO;
+				restore_flags(flags);
+
+				if ((IO_MASK(R_USB_EPT_DATA_ISO, valid) & data) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA_ISO, dev, data) == devnum) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA_ISO, ep, data) == endpoint) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA_ISO, max_len, data) == maxlen)) {
+					dbg_epid("Found epid %d for devnum %d, endpoint %d (%s)",
+						 i, devnum, endpoint, out_traffic ? "OUT" : "IN");
+					DBFEXIT;
+					return i;
+				}
+			} else {
+				data = *R_USB_EPT_DATA;
+				restore_flags(flags);
+
+				if ((IO_MASK(R_USB_EPT_DATA, valid) & data) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA, dev, data) == devnum) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA, ep, data) == endpoint) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA, low_speed, data) == slow) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA, max_len, data) == maxlen)) {
+					dbg_epid("Found epid %d for devnum %d, endpoint %d (%s)",
+						 i, devnum, endpoint, out_traffic ? "OUT" : "IN");
+					DBFEXIT;
+					return i;
+				}
+			}
+		}
+	}
+
+	DBFEXIT;
+	return -1;
+}
+
+static int etrax_usb_allocate_epid(void)
+{
+	int i;
+
+	DBFENTER;
+
+	for (i = 0; i < NBR_OF_EPIDS; i++) {
+		if (!test_bit(i, (void *)&epid_usage_bitmask)) {
+			dbg_epid("Found free epid %d", i);
+			DBFEXIT;
+			return i;
+		}
+	}
+
+	dbg_epid("Found no free epids");
+	DBFEXIT;
+	return -1;
+}
+
+static int etrax_usb_submit_urb(struct urb *urb, int mem_flags)
+{
+	etrax_hc_t *hc;
+	int ret = -EINVAL;
+
+	DBFENTER;
+
+	if (!urb->dev || !urb->dev->bus) {
+		return -ENODEV;
+	}
+	if (usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)) <= 0) {
+		info("Submit urb to pipe with maxpacketlen 0, pipe 0x%X\n", urb->pipe);
+		return -EMSGSIZE;
+	}
+
+	if (urb->timeout) {
+		/* FIXME. */
+		warn("urb->timeout specified, ignoring.");
+	}
+
+	hc = (etrax_hc_t*)urb->dev->bus->hcpriv;
+
+	if (usb_pipedevice(urb->pipe) == hc->rh.devnum) {
+		/* This request is for the Virtual Root Hub. */
+		ret = etrax_rh_submit_urb(urb);
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_BULK) {
+
+		ret = etrax_usb_submit_bulk_urb(urb);
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_CONTROL) {
+
+		ret = etrax_usb_submit_ctrl_urb(urb);
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
+		int bustime;
+
+		if (urb->bandwidth == 0) {
+			bustime = usb_check_bandwidth(urb->dev, urb);
+			if (bustime < 0) {
+				ret = bustime;
+			} else {
+				ret = etrax_usb_submit_intr_urb(urb);
+				if (ret == 0)
+					usb_claim_bandwidth(urb->dev, urb, bustime, 0);
+			}
+		} else {
+			/* Bandwidth already set. */
+			ret = etrax_usb_submit_intr_urb(urb);
+		}
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+		int bustime;
+
+		if (urb->bandwidth == 0) {
+			bustime = usb_check_bandwidth(urb->dev, urb);
+			if (bustime < 0) {
+				ret = bustime;
+			} else {
+				ret = etrax_usb_submit_isoc_urb(urb);
+				if (ret == 0)
+					usb_claim_bandwidth(urb->dev, urb, bustime, 0);
+			}
+		} else {
+			/* Bandwidth already set. */
+			ret = etrax_usb_submit_isoc_urb(urb);
+		}
+	}
+
+	DBFEXIT;
+
+        if (ret != 0)
+          printk("Submit URB error %d\n", ret);
+
+	return ret;
+}
+
+static int etrax_usb_unlink_urb(struct urb *urb, int status)
+{
+	etrax_hc_t *hc;
+	etrax_urb_priv_t *urb_priv;
+	int epid;
+	unsigned int flags;
+
+	DBFENTER;
+
+	if (!urb) {
+		return -EINVAL;
+	}
+
+	/* Disable interrupts here since a descriptor interrupt for the isoc epid
+	   will modify the sb list.  This could possibly be done more granular, but
+	   unlink_urb should not be used frequently anyway.
+	*/
+
+	save_flags(flags);
+	cli();
+
+	if (!urb->dev || !urb->dev->bus) {
+		restore_flags(flags);
+		return -ENODEV;
+	}
+	if (!urb->hcpriv) {
+		/* This happens if a device driver calls unlink on an urb that
+		   was never submitted (lazy driver) or if the urb was completed
+		   while unlink was being called. */
+		restore_flags(flags);
+		return 0;
+	}
+	if (urb->transfer_flags & URB_ASYNC_UNLINK) {
+		/* FIXME. */
+		/* If URB_ASYNC_UNLINK is set:
+		   unlink
+		   move to a separate urb list
+		   call complete at next sof with ECONNRESET
+
+		   If not:
+		   wait 1 ms
+		   unlink
+		   call complete with ENOENT
+		*/
+		warn("URB_ASYNC_UNLINK set, ignoring.");
+	}
+
+	/* One might think that urb->status = -EINPROGRESS would be a requirement for unlinking,
+	   but that doesn't work for interrupt and isochronous traffic since they are completed
+	   repeatedly, and urb->status is set then. That may in itself be a bug though. */
+
+	hc = urb->dev->bus->hcpriv;
+	urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+	epid = urb_priv->epid;
+
+	/* Set the urb status (synchronous unlink). */
+	urb->status = -ENOENT;
+	urb_priv->urb_state = UNLINK;
+
+	if (usb_pipedevice(urb->pipe) == hc->rh.devnum) {
+		int ret;
+		ret = etrax_rh_unlink_urb(urb);
+		DBFEXIT;
+		restore_flags(flags);
+		return ret;
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_BULK) {
+
+		dbg_bulk("Unlink of bulk urb (0x%lx)", (unsigned long)urb);
+
+		if (TxBulkEPList[epid].command & IO_MASK(USB_EP_command, enable)) {
+			/* The EP was enabled, disable it and wait. */
+			TxBulkEPList[epid].command &= ~IO_MASK(USB_EP_command, enable);
+
+			/* Ah, the luxury of busy-wait. */
+			while (*R_DMA_CH8_SUB0_EP == virt_to_phys(&TxBulkEPList[epid]));
+		}
+		/* Kicking dummy list out of the party. */
+		TxBulkEPList[epid].next = virt_to_phys(&TxBulkEPList[(epid + 1) % NBR_OF_EPIDS]);
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_CONTROL) {
+
+		dbg_ctrl("Unlink of ctrl urb (0x%lx)", (unsigned long)urb);
+
+		if (TxCtrlEPList[epid].command & IO_MASK(USB_EP_command, enable)) {
+			/* The EP was enabled, disable it and wait. */
+			TxCtrlEPList[epid].command &= ~IO_MASK(USB_EP_command, enable);
+
+			/* Ah, the luxury of busy-wait. */
+			while (*R_DMA_CH8_SUB1_EP == virt_to_phys(&TxCtrlEPList[epid]));
+		}
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
+
+		dbg_intr("Unlink of intr urb (0x%lx)", (unsigned long)urb);
+
+		/* Separate function because it's a tad more complicated. */
+		etrax_usb_unlink_intr_urb(urb);
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+
+		dbg_isoc("Unlink of isoc urb (0x%lx)", (unsigned long)urb);
+
+		if (TxIsocEPList[epid].command & IO_MASK(USB_EP_command, enable)) {
+			/* The EP was enabled, disable it and wait. */
+			TxIsocEPList[epid].command &= ~IO_MASK(USB_EP_command, enable);
+
+			/* Ah, the luxury of busy-wait. */
+			while (*R_DMA_CH8_SUB3_EP == virt_to_phys(&TxIsocEPList[epid]));
+		}
+	}
+
+	/* Note that we need to remove the urb from the urb list *before* removing its SB
+	   descriptors. (This means that the isoc eof handler might get a null urb when we
+	   are unlinking the last urb.) */
+
+	if (usb_pipetype(urb->pipe) == PIPE_BULK) {
+
+		urb_list_del(urb, epid);
+		TxBulkEPList[epid].sub = 0;
+		etrax_remove_from_sb_list(urb);
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_CONTROL) {
+
+		urb_list_del(urb, epid);
+		TxCtrlEPList[epid].sub = 0;
+		etrax_remove_from_sb_list(urb);
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
+
+		urb_list_del(urb, epid);
+		/* Sanity check (should never happen). */
+		assert(urb_list_empty(epid));
+
+		/* Release allocated bandwidth. */
+		usb_release_bandwidth(urb->dev, urb, 0);
+
+	} else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+
+		if (usb_pipeout(urb->pipe)) {
+
+			USB_SB_Desc_t *iter_sb, *prev_sb, *next_sb;
+
+			if (__urb_list_entry(urb, epid)) {
+
+				urb_list_del(urb, epid);
+				iter_sb = TxIsocEPList[epid].sub ? phys_to_virt(TxIsocEPList[epid].sub) : 0;
+				prev_sb = 0;
+				while (iter_sb && (iter_sb != urb_priv->first_sb)) {
+					prev_sb = iter_sb;
+					iter_sb = iter_sb->next ? phys_to_virt(iter_sb->next) : 0;
+				}
+
+				if (iter_sb == 0) {
+					/* Unlink of the URB currently being transmitted. */
+					prev_sb = 0;
+					iter_sb = TxIsocEPList[epid].sub ? phys_to_virt(TxIsocEPList[epid].sub) : 0;
+				}
+
+				while (iter_sb && (iter_sb != urb_priv->last_sb)) {
+					iter_sb = iter_sb->next ? phys_to_virt(iter_sb->next) : 0;
+				}
+				if (iter_sb) {
+					next_sb = iter_sb->next ? phys_to_virt(iter_sb->next) : 0;
+				} else {
+					/* This should only happen if the DMA has completed
+					   processing the SB list for this EP while interrupts
+					   are disabled. */
+					dbg_isoc("Isoc urb not found, already sent?");
+					next_sb = 0;
+				}
+				if (prev_sb) {
+					prev_sb->next = next_sb ? virt_to_phys(next_sb) : 0;
+				} else {
+					TxIsocEPList[epid].sub = next_sb ? virt_to_phys(next_sb) : 0;
+				}
+
+				etrax_remove_from_sb_list(urb);
+				if (urb_list_empty(epid)) {
+					TxIsocEPList[epid].sub = 0;
+					dbg_isoc("Last isoc out urb epid %d", epid);
+				} else if (next_sb || prev_sb) {
+					dbg_isoc("Re-enable isoc out epid %d", epid);
+
+					TxIsocEPList[epid].hw_len = 0;
+					TxIsocEPList[epid].command |= IO_STATE(USB_EP_command, enable, yes);
+				} else {
+					TxIsocEPList[epid].sub = 0;
+					dbg_isoc("URB list non-empty and no SB list, EP disabled");
+				}
+			} else {
+				dbg_isoc("Urb 0x%p not found, completed already?", urb);
+			}
+		} else {
+
+			urb_list_del(urb, epid);
+
+			/* For in traffic there is only one SB descriptor for each EP even
+			   though there may be several urbs (all urbs point at the same SB). */
+			if (urb_list_empty(epid)) {
+				/* No more urbs, remove the SB. */
+				TxIsocEPList[epid].sub = 0;
+				etrax_remove_from_sb_list(urb);
+			} else {
+				TxIsocEPList[epid].hw_len = 0;
+				TxIsocEPList[epid].command |= IO_STATE(USB_EP_command, enable, yes);
+			}
+		}
+		/* Release allocated bandwidth. */
+		usb_release_bandwidth(urb->dev, urb, 1);
+	}
+	/* Free the epid if urb list is empty. */
+	if (urb_list_empty(epid)) {
+		etrax_usb_free_epid(epid);
+	}
+	restore_flags(flags);
+
+	/* Must be done before calling completion handler. */
+	kfree(urb_priv);
+	urb->hcpriv = 0;
+
+	if (urb->complete) {
+		urb->complete(urb, NULL);
+	}
+
+	DBFEXIT;
+	return 0;
+}
+
+static int etrax_usb_get_frame_number(struct usb_device *usb_dev)
+{
+	DBFENTER;
+	DBFEXIT;
+	return (*R_USB_FM_NUMBER & 0x7ff);
+}
+
+static int etrax_usb_allocate_dev(struct usb_device *usb_dev)
+{
+	DBFENTER;
+	DBFEXIT;
+	return 0;
+}
+
+static int etrax_usb_deallocate_dev(struct usb_device *usb_dev)
+{
+	DBFENTER;
+	DBFEXIT;
+	return 0;
+}
+
+static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc, struct pt_regs *regs)
+{
+	DBFENTER;
+
+	/* This interrupt handler could be used when unlinking EP descriptors. */
+
+	if (*R_IRQ_READ2 & IO_MASK(R_IRQ_READ2, dma8_sub0_descr)) {
+		USB_EP_Desc_t *ep;
+
+		//dbg_bulk("dma8_sub0_descr (BULK) intr.");
+
+		/* It should be safe clearing the interrupt here, since we don't expect to get a new
+		   one until we restart the bulk channel. */
+		*R_DMA_CH8_SUB0_CLR_INTR = IO_STATE(R_DMA_CH8_SUB0_CLR_INTR, clr_descr, do);
+
+		/* Wait while the DMA is running (though we don't expect it to be). */
+		while (*R_DMA_CH8_SUB0_CMD & IO_MASK(R_DMA_CH8_SUB0_CMD, cmd));
+
+		/* Advance the DMA to the next EP descriptor. */
+		ep = (USB_EP_Desc_t *)phys_to_virt(*R_DMA_CH8_SUB0_EP);
+
+		//dbg_bulk("descr intr: DMA is at 0x%lx", (unsigned long)ep);
+
+		/* ep->next is already a physical address; no need for a virt_to_phys. */
+		*R_DMA_CH8_SUB0_EP = ep->next;
+
+		/* Start the DMA bulk channel again. */
+		*R_DMA_CH8_SUB0_CMD = IO_STATE(R_DMA_CH8_SUB0_CMD, cmd, start);
+	}
+	if (*R_IRQ_READ2 & IO_MASK(R_IRQ_READ2, dma8_sub1_descr)) {
+		struct urb *urb;
+		int epid;
+		etrax_urb_priv_t *urb_priv;
+		unsigned long int flags;
+
+		dbg_ctrl("dma8_sub1_descr (CTRL) intr.");
+		*R_DMA_CH8_SUB1_CLR_INTR = IO_STATE(R_DMA_CH8_SUB1_CLR_INTR, clr_descr, do);
+
+		/* The complete callback gets called so we cli. */
+		save_flags(flags);
+		cli();
+
+		for (epid = 0; epid < NBR_OF_EPIDS - 1; epid++) {
+			if ((TxCtrlEPList[epid].sub == 0) ||
+			    (epid == DUMMY_EPID) ||
+			    (epid == INVALID_EPID)) {
+				/* Nothing here to see. */
+				continue;
+			}
+
+			/* Get the first urb (if any). */
+			urb = urb_list_first(epid);
+
+			if (urb) {
+
+				/* Sanity check. */
+				assert(usb_pipetype(urb->pipe) == PIPE_CONTROL);
+
+				urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+				assert(urb_priv);
+
+				if (urb_priv->urb_state == WAITING_FOR_DESCR_INTR) {
+					assert(!(TxCtrlEPList[urb_priv->epid].command & IO_MASK(USB_EP_command, enable)));
+
+					etrax_usb_complete_urb(urb, 0);
+				}
+			}
+		}
+		restore_flags(flags);
+	}
+	if (*R_IRQ_READ2 & IO_MASK(R_IRQ_READ2, dma8_sub2_descr)) {
+		dbg_intr("dma8_sub2_descr (INTR) intr.");
+		*R_DMA_CH8_SUB2_CLR_INTR = IO_STATE(R_DMA_CH8_SUB2_CLR_INTR, clr_descr, do);
+	}
+	if (*R_IRQ_READ2 & IO_MASK(R_IRQ_READ2, dma8_sub3_descr)) {
+		struct urb *urb;
+		int epid;
+		int epid_done;
+		etrax_urb_priv_t *urb_priv;
+		USB_SB_Desc_t *sb_desc;
+
+		usb_isoc_complete_data_t *comp_data = NULL;
+
+		/* One or more isoc out transfers are done. */
+		dbg_isoc("dma8_sub3_descr (ISOC) intr.");
+
+		/* For each isoc out EP search for the first sb_desc with the intr flag
+		   set.  This descriptor must be the last packet from an URB.  Then
+		   traverse the URB list for the EP until the URB with urb_priv->last_sb
+		   matching the intr-marked sb_desc is found.  All URBs before this have
+		   been sent.
+		*/
+
+		for (epid = 0; epid < NBR_OF_EPIDS - 1; epid++) {
+			/* Skip past epids with no SB lists, epids used for in traffic,
+			   and special (dummy, invalid) epids. */
+			if ((TxIsocEPList[epid].sub == 0) ||
+			    (test_bit(epid, (void *)&epid_out_traffic) == 0) ||
+			    (epid == DUMMY_EPID) ||
+			    (epid == INVALID_EPID)) {
+				/* Nothing here to see. */
+				continue;
+			}
+			sb_desc = phys_to_virt(TxIsocEPList[epid].sub);
+
+			/* Find the last descriptor of the currently active URB for this ep.
+			   This is the first descriptor in the sub list marked for a descriptor
+			   interrupt. */
+			while (sb_desc && !IO_EXTRACT(USB_SB_command, intr, sb_desc->command)) {
+				sb_desc = sb_desc->next ? phys_to_virt(sb_desc->next) : 0;
+			}
+			assert(sb_desc);
+
+			dbg_isoc("Check epid %d, sub 0x%p, SB 0x%p",
+				 epid,
+				 phys_to_virt(TxIsocEPList[epid].sub),
+				 sb_desc);
+
+			epid_done = 0;
+
+			/* Get the first urb (if any). */
+			urb = urb_list_first(epid);
+			assert(urb);
+
+			while (urb && !epid_done) {
+
+				/* Sanity check. */
+				assert(usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS);
+
+				if (!usb_pipeout(urb->pipe)) {
+					/* descr interrupts are generated only for out pipes. */
+					epid_done = 1;
+					continue;
+				}
+
+				urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+				assert(urb_priv);
+
+				if (sb_desc != urb_priv->last_sb) {
+
+					/* This urb has been sent. */
+					dbg_isoc("out URB 0x%p sent", urb);
+
+					urb_priv->urb_state = TRANSFER_DONE;
+
+				} else if ((sb_desc == urb_priv->last_sb) &&
+					   !(TxIsocEPList[epid].command & IO_MASK(USB_EP_command, enable))) {
+
+					assert((sb_desc->command & IO_MASK(USB_SB_command, eol)) == IO_STATE(USB_SB_command, eol, yes));
+					assert(sb_desc->next == 0);
+
+					dbg_isoc("out URB 0x%p last in list, epid disabled", urb);
+					TxIsocEPList[epid].sub = 0;
+					TxIsocEPList[epid].hw_len = 0;
+					urb_priv->urb_state = TRANSFER_DONE;
+
+					epid_done = 1;
+
+				} else {
+					epid_done = 1;
+				}
+				if (!epid_done) {
+					urb = urb_list_next(urb, epid);
+				}
+			}
+
+		}
+
+		*R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do);
+
+		comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, SLAB_ATOMIC);
+		assert(comp_data != NULL);
+
+                INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data);
+                schedule_work(&comp_data->usb_bh);
+	}
+
+	DBFEXIT;
+        return IRQ_HANDLED;
+}
+
+static void etrax_usb_isoc_descr_interrupt_bottom_half(void *data)
+{
+	usb_isoc_complete_data_t *comp_data = (usb_isoc_complete_data_t*)data;
+
+	struct urb *urb;
+	int epid;
+	int epid_done;
+	etrax_urb_priv_t *urb_priv;
+
+	DBFENTER;
+
+	dbg_isoc("dma8_sub3_descr (ISOC) bottom half.");
+
+	for (epid = 0; epid < NBR_OF_EPIDS - 1; epid++) {
+		unsigned long flags;
+
+		save_flags(flags);
+		cli();
+
+		epid_done = 0;
+
+		/* The descriptor interrupt handler has marked all transmitted isoch. out
+		   URBs with TRANSFER_DONE.  Now we traverse all epids and for all that
+ 		   have isoch. out traffic traverse its URB list and complete the
+		   transmitted URB.
+		*/
+
+		while (!epid_done) {
+
+			/* Get the first urb (if any). */
+			urb = urb_list_first(epid);
+			if (urb == 0) {
+				epid_done = 1;
+				continue;
+			}
+
+			if (usb_pipetype(urb->pipe) != PIPE_ISOCHRONOUS) {
+					epid_done = 1;
+					continue;
+			}
+
+			if (!usb_pipeout(urb->pipe)) {
+				/* descr interrupts are generated only for out pipes. */
+				epid_done = 1;
+				continue;
+			}
+
+			dbg_isoc("Check epid %d, SB 0x%p", epid, (char*)TxIsocEPList[epid].sub);
+
+			urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+			assert(urb_priv);
+
+			if (urb_priv->urb_state == TRANSFER_DONE) {
+				int i;
+				struct usb_iso_packet_descriptor *packet;
+
+				/* This urb has been sent. */
+				dbg_isoc("Completing isoc out URB 0x%p", urb);
+
+				for (i = 0; i < urb->number_of_packets; i++) {
+					packet = &urb->iso_frame_desc[i];
+					packet->status = 0;
+					packet->actual_length = packet->length;
+				}
+
+				etrax_usb_complete_isoc_urb(urb, 0);
+
+				if (urb_list_empty(epid)) {
+					etrax_usb_free_epid(epid);
+					epid_done = 1;
+				}
+			} else {
+				epid_done = 1;
+			}
+		}
+		restore_flags(flags);
+
+	}
+	kmem_cache_free(isoc_compl_cache, comp_data);
+
+	DBFEXIT;
+}
+
+
+
+static irqreturn_t etrax_usb_rx_interrupt(int irq, void *vhc, struct pt_regs *regs)
+{
+	struct urb *urb;
+	etrax_urb_priv_t *urb_priv;
+	int epid = 0;
+	unsigned long flags;
+
+	/* Isoc diagnostics. */
+	static int curr_fm = 0;
+	static int prev_fm = 0;
+
+	DBFENTER;
+
+	/* Clear this interrupt. */
+	*R_DMA_CH9_CLR_INTR = IO_STATE(R_DMA_CH9_CLR_INTR, clr_eop, do);
+
+	/* Note that this while loop assumes that all packets span only
+	   one rx descriptor. */
+
+	/* The reason we cli here is that we call the driver's callback functions. */
+	save_flags(flags);
+	cli();
+
+	while (myNextRxDesc->status & IO_MASK(USB_IN_status, eop)) {
+
+		epid = IO_EXTRACT(USB_IN_status, epid, myNextRxDesc->status);
+		urb = urb_list_first(epid);
+
+		//printk("eop for epid %d, first urb 0x%lx\n", epid, (unsigned long)urb);
+
+		if (!urb) {
+			err("No urb for epid %d in rx interrupt", epid);
+			__dump_ept_data(epid);
+			goto skip_out;
+		}
+
+		/* Note that we cannot indescriminately assert(usb_pipein(urb->pipe)) since
+		   ctrl pipes are not. */
+
+		if (myNextRxDesc->status & IO_MASK(USB_IN_status, error)) {
+			__u32 r_usb_ept_data;
+			int no_error = 0;
+
+			assert(test_bit(epid, (void *)&epid_usage_bitmask));
+
+			*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+			nop();
+			if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+				r_usb_ept_data = *R_USB_EPT_DATA_ISO;
+
+				if ((r_usb_ept_data & IO_MASK(R_USB_EPT_DATA_ISO, valid)) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA_ISO, error_code, r_usb_ept_data) == 0) &&
+				    (myNextRxDesc->status & IO_MASK(USB_IN_status, nodata))) {
+					/* Not an error, just a failure to receive an expected iso
+					   in packet in this frame.  This is not documented
+					   in the designers reference.
+					*/
+					no_error++;
+				} else {
+					warn("R_USB_EPT_DATA_ISO for epid %d = 0x%x", epid, r_usb_ept_data);
+				}
+			} else {
+				r_usb_ept_data = *R_USB_EPT_DATA;
+				warn("R_USB_EPT_DATA for epid %d = 0x%x", epid, r_usb_ept_data);
+			}
+
+			if (!no_error){
+				warn("error in rx desc->status, epid %d, first urb = 0x%lx",
+				     epid, (unsigned long)urb);
+				__dump_in_desc(myNextRxDesc);
+
+				warn("R_USB_STATUS = 0x%x", *R_USB_STATUS);
+
+				/* Check that ept was disabled when error occurred. */
+				switch (usb_pipetype(urb->pipe)) {
+				case PIPE_BULK:
+					assert(!(TxBulkEPList[epid].command & IO_MASK(USB_EP_command, enable)));
+					break;
+				case PIPE_CONTROL:
+					assert(!(TxCtrlEPList[epid].command & IO_MASK(USB_EP_command, enable)));
+					break;
+				case PIPE_INTERRUPT:
+					assert(!(TxIntrEPList[epid].command & IO_MASK(USB_EP_command, enable)));
+					break;
+				case PIPE_ISOCHRONOUS:
+					assert(!(TxIsocEPList[epid].command & IO_MASK(USB_EP_command, enable)));
+					break;
+				default:
+					warn("etrax_usb_rx_interrupt: bad pipetype %d in urb 0x%p",
+					     usb_pipetype(urb->pipe),
+					     urb);
+				}
+				etrax_usb_complete_urb(urb, -EPROTO);
+				goto skip_out;
+			}
+		}
+
+		urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+		assert(urb_priv);
+
+		if ((usb_pipetype(urb->pipe) == PIPE_BULK) ||
+		    (usb_pipetype(urb->pipe) == PIPE_CONTROL) ||
+		    (usb_pipetype(urb->pipe) == PIPE_INTERRUPT)) {
+
+			if (myNextRxDesc->status & IO_MASK(USB_IN_status, nodata)) {
+				/* We get nodata for empty data transactions, and the rx descriptor's
+				   hw_len field is not valid in that case. No data to copy in other
+				   words. */
+			} else {
+				/* Make sure the data fits in the buffer. */
+				assert(urb_priv->rx_offset + myNextRxDesc->hw_len
+				       <= urb->transfer_buffer_length);
+
+				memcpy(urb->transfer_buffer + urb_priv->rx_offset,
+				       phys_to_virt(myNextRxDesc->buf), myNextRxDesc->hw_len);
+				urb_priv->rx_offset += myNextRxDesc->hw_len;
+			}
+
+			if (myNextRxDesc->status & IO_MASK(USB_IN_status, eot)) {
+				if ((usb_pipetype(urb->pipe) == PIPE_CONTROL) &&
+				    ((TxCtrlEPList[urb_priv->epid].command & IO_MASK(USB_EP_command, enable)) ==
+				     IO_STATE(USB_EP_command, enable, yes))) {
+					/* The EP is still enabled, so the OUT packet used to ack
+					   the in data is probably not processed yet.  If the EP
+					   sub pointer has not moved beyond urb_priv->last_sb mark
+					   it for a descriptor interrupt and complete the urb in
+					   the descriptor interrupt handler.
+					*/
+					USB_SB_Desc_t *sub = TxCtrlEPList[urb_priv->epid].sub ? phys_to_virt(TxCtrlEPList[urb_priv->epid].sub) : 0;
+
+					while ((sub != NULL) && (sub != urb_priv->last_sb)) {
+						sub = sub->next ? phys_to_virt(sub->next) : 0;
+					}
+					if (sub != NULL) {
+						/* The urb has not been fully processed. */
+						urb_priv->urb_state = WAITING_FOR_DESCR_INTR;
+					} else {
+						warn("(CTRL) epid enabled and urb (0x%p) processed, ep->sub=0x%p", urb, (char*)TxCtrlEPList[urb_priv->epid].sub);
+						etrax_usb_complete_urb(urb, 0);
+					}
+				} else {
+					etrax_usb_complete_urb(urb, 0);
+				}
+			}
+
+		} else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+
+			struct usb_iso_packet_descriptor *packet;
+
+			if (urb_priv->urb_state == UNLINK) {
+				info("Ignoring rx data for urb being unlinked.");
+				goto skip_out;
+			} else if (urb_priv->urb_state == NOT_STARTED) {
+				info("What? Got rx data for urb that isn't started?");
+				goto skip_out;
+			}
+
+			packet = &urb->iso_frame_desc[urb_priv->isoc_packet_counter];
+			packet->status = 0;
+
+			if (myNextRxDesc->status & IO_MASK(USB_IN_status, nodata)) {
+				/* We get nodata for empty data transactions, and the rx descriptor's
+				   hw_len field is not valid in that case. We copy 0 bytes however to
+				   stay in synch. */
+				packet->actual_length = 0;
+			} else {
+				packet->actual_length = myNextRxDesc->hw_len;
+				/* Make sure the data fits in the buffer. */
+				assert(packet->actual_length <= packet->length);
+				memcpy(urb->transfer_buffer + packet->offset,
+				       phys_to_virt(myNextRxDesc->buf), packet->actual_length);
+			}
+
+			/* Increment the packet counter. */
+			urb_priv->isoc_packet_counter++;
+
+			/* Note that we don't care about the eot field in the rx descriptor's status.
+			   It will always be set for isoc traffic. */
+			if (urb->number_of_packets == urb_priv->isoc_packet_counter) {
+
+				/* Out-of-synch diagnostics. */
+				curr_fm = (*R_USB_FM_NUMBER & 0x7ff);
+				if (((prev_fm + urb_priv->isoc_packet_counter) % (0x7ff + 1)) != curr_fm) {
+					/* This test is wrong, if there is more than one isoc
+					   in endpoint active it will always calculate wrong
+					   since prev_fm is shared by all endpoints.
+
+					   FIXME Make this check per URB using urb->start_frame.
+					*/
+					dbg_isoc("Out of synch? Previous frame = %d, current frame = %d",
+						 prev_fm, curr_fm);
+
+				}
+				prev_fm = curr_fm;
+
+				/* Complete the urb with status OK. */
+				etrax_usb_complete_isoc_urb(urb, 0);
+			}
+		}
+
+	skip_out:
+
+		/* DMA IN cache bug. Flush the DMA IN buffer from the cache. (struct etrax_dma_descr
+		   has the same layout as USB_IN_Desc for the relevant fields.) */
+		prepare_rx_descriptor((struct etrax_dma_descr*)myNextRxDesc);
+
+		myPrevRxDesc = myNextRxDesc;
+		myPrevRxDesc->command |= IO_MASK(USB_IN_command, eol);
+		myLastRxDesc->command &= ~IO_MASK(USB_IN_command, eol);
+		myLastRxDesc = myPrevRxDesc;
+
+		myNextRxDesc->status = 0;
+		myNextRxDesc = phys_to_virt(myNextRxDesc->next);
+	}
+
+	restore_flags(flags);
+
+	DBFEXIT;
+
+        return IRQ_HANDLED;
+}
+
+
+/* This function will unlink the SB descriptors associated with this urb. */
+static int etrax_remove_from_sb_list(struct urb *urb)
+{
+	USB_SB_Desc_t *next_sb, *first_sb, *last_sb;
+	etrax_urb_priv_t *urb_priv;
+	int i = 0;
+
+	DBFENTER;
+
+	urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+	assert(urb_priv);
+
+	/* Just a sanity check. Since we don't fiddle with the DMA list the EP descriptor
+	   doesn't really need to be disabled, it's just that we expect it to be. */
+	if (usb_pipetype(urb->pipe) == PIPE_BULK) {
+		assert(!(TxBulkEPList[urb_priv->epid].command & IO_MASK(USB_EP_command, enable)));
+	} else if (usb_pipetype(urb->pipe) == PIPE_CONTROL) {
+		assert(!(TxCtrlEPList[urb_priv->epid].command & IO_MASK(USB_EP_command, enable)));
+	}
+
+	first_sb = urb_priv->first_sb;
+	last_sb = urb_priv->last_sb;
+
+	assert(first_sb);
+	assert(last_sb);
+
+	while (first_sb != last_sb) {
+		next_sb = (USB_SB_Desc_t *)phys_to_virt(first_sb->next);
+		kmem_cache_free(usb_desc_cache, first_sb);
+		first_sb = next_sb;
+		i++;
+	}
+	kmem_cache_free(usb_desc_cache, last_sb);
+	i++;
+	dbg_sb("%d SB descriptors freed", i);
+	/* Compare i with urb->number_of_packets for Isoc traffic.
+	   Should be same when calling unlink_urb */
+
+	DBFEXIT;
+
+	return i;
+}
+
+static int etrax_usb_submit_bulk_urb(struct urb *urb)
+{
+	int epid;
+	int empty;
+	unsigned long flags;
+	etrax_urb_priv_t *urb_priv;
+
+	DBFENTER;
+
+	/* Epid allocation, empty check and list add must be protected.
+	   Read about this in etrax_usb_submit_ctrl_urb. */
+
+	spin_lock_irqsave(&urb_list_lock, flags);
+	epid = etrax_usb_setup_epid(urb);
+	if (epid == -1) {
+		DBFEXIT;
+		spin_unlock_irqrestore(&urb_list_lock, flags);
+		return -ENOMEM;
+	}
+	empty = urb_list_empty(epid);
+	urb_list_add(urb, epid);
+	spin_unlock_irqrestore(&urb_list_lock, flags);
+
+	dbg_bulk("Adding bulk %s urb 0x%lx to %s list, epid %d",
+		 usb_pipein(urb->pipe) ? "IN" : "OUT", (unsigned long)urb, empty ? "empty" : "", epid);
+
+	/* Mark the urb as being in progress. */
+	urb->status = -EINPROGRESS;
+
+	/* Setup the hcpriv data. */
+	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	assert(urb_priv != NULL);
+	/* This sets rx_offset to 0. */
+	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
+	urb_priv->urb_state = NOT_STARTED;
+	urb->hcpriv = urb_priv;
+
+	if (empty) {
+		etrax_usb_add_to_bulk_sb_list(urb, epid);
+	}
+
+	DBFEXIT;
+
+	return 0;
+}
+
+static void etrax_usb_add_to_bulk_sb_list(struct urb *urb, int epid)
+{
+	USB_SB_Desc_t *sb_desc;
+	etrax_urb_priv_t *urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+	unsigned long flags;
+	char maxlen;
+
+	DBFENTER;
+
+	dbg_bulk("etrax_usb_add_to_bulk_sb_list, urb 0x%lx", (unsigned long)urb);
+
+	maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
+
+	sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_FLAG);
+	assert(sb_desc != NULL);
+	memset(sb_desc, 0, sizeof(USB_SB_Desc_t));
+
+
+	if (usb_pipeout(urb->pipe)) {
+
+		dbg_bulk("Grabbing bulk OUT, urb 0x%lx, epid %d", (unsigned long)urb, epid);
+
+		/* This is probably a sanity check of the bulk transaction length
+		   not being larger than 64 kB. */
+		if (urb->transfer_buffer_length > 0xffff) {
+			panic("urb->transfer_buffer_length > 0xffff");
+		}
+
+		sb_desc->sw_len = urb->transfer_buffer_length;
+
+		/* The rem field is don't care if it's not a full-length transfer, so setting
+		   it shouldn't hurt. Also, rem isn't used for OUT traffic. */
+		sb_desc->command = (IO_FIELD(USB_SB_command, rem, 0) |
+				    IO_STATE(USB_SB_command, tt, out) |
+				    IO_STATE(USB_SB_command, eot, yes) |
+				    IO_STATE(USB_SB_command, eol, yes));
+
+		/* The full field is set to yes, even if we don't actually check that this is
+		   a full-length transfer (i.e., that transfer_buffer_length % maxlen = 0).
+		   Setting full prevents the USB controller from sending an empty packet in
+		   that case.  However, if URB_ZERO_PACKET was set we want that. */
+		if (!(urb->transfer_flags & URB_ZERO_PACKET)) {
+			sb_desc->command |= IO_STATE(USB_SB_command, full, yes);
+		}
+
+		sb_desc->buf = virt_to_phys(urb->transfer_buffer);
+		sb_desc->next = 0;
+
+	} else if (usb_pipein(urb->pipe)) {
+
+		dbg_bulk("Grabbing bulk IN, urb 0x%lx, epid %d", (unsigned long)urb, epid);
+
+		sb_desc->sw_len = urb->transfer_buffer_length ?
+			(urb->transfer_buffer_length - 1) / maxlen + 1 : 0;
+
+		/* The rem field is don't care if it's not a full-length transfer, so setting
+		   it shouldn't hurt. */
+		sb_desc->command =
+			(IO_FIELD(USB_SB_command, rem,
+				  urb->transfer_buffer_length % maxlen) |
+			 IO_STATE(USB_SB_command, tt, in) |
+			 IO_STATE(USB_SB_command, eot, yes) |
+			 IO_STATE(USB_SB_command, eol, yes));
+
+		sb_desc->buf = 0;
+		sb_desc->next = 0;
+	}
+
+	urb_priv->first_sb = sb_desc;
+	urb_priv->last_sb = sb_desc;
+	urb_priv->epid = epid;
+
+	urb->hcpriv = urb_priv;
+
+	/* Reset toggle bits and reset error count. */
+	save_flags(flags);
+	cli();
+
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+	nop();
+
+	/* FIXME: Is this a special case since the hold field is checked,
+	   or should we check hold in a lot of other cases as well? */
+	if (*R_USB_EPT_DATA & IO_MASK(R_USB_EPT_DATA, hold)) {
+		panic("Hold was set in %s", __FUNCTION__);
+	}
+
+	/* Reset error counters (regardless of which direction this traffic is). */
+	*R_USB_EPT_DATA &=
+		~(IO_MASK(R_USB_EPT_DATA, error_count_in) |
+		  IO_MASK(R_USB_EPT_DATA, error_count_out));
+
+	/* Software must preset the toggle bits. */
+	if (usb_pipeout(urb->pipe)) {
+		char toggle =
+			usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe));
+		*R_USB_EPT_DATA &= ~IO_MASK(R_USB_EPT_DATA, t_out);
+		*R_USB_EPT_DATA |= IO_FIELD(R_USB_EPT_DATA, t_out, toggle);
+	} else {
+		char toggle =
+			usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe));
+		*R_USB_EPT_DATA &= ~IO_MASK(R_USB_EPT_DATA, t_in);
+		*R_USB_EPT_DATA |= IO_FIELD(R_USB_EPT_DATA, t_in, toggle);
+	}
+
+	/* Assert that the EP descriptor is disabled. */
+	assert(!(TxBulkEPList[epid].command & IO_MASK(USB_EP_command, enable)));
+
+	/* The reason we set the EP's sub pointer directly instead of
+	   walking the SB list and linking it last in the list is that we only
+	   have one active urb at a time (the rest are queued). */
+
+	/* Note that we cannot have interrupts running when we have set the SB descriptor
+	   but the EP is not yet enabled.  If a bulk eot happens for another EP, we will
+	   find this EP disabled and with a SB != 0, which will make us think that it's done. */
+	TxBulkEPList[epid].sub = virt_to_phys(sb_desc);
+	TxBulkEPList[epid].hw_len = 0;
+	/* Note that we don't have to fill in the ep_id field since this
+	   was done when we allocated the EP descriptors in init_tx_bulk_ep. */
+
+	/* Check if the dummy list is already with us (if several urbs were queued). */
+	if (TxBulkEPList[epid].next != virt_to_phys(&TxBulkDummyEPList[epid][0])) {
+
+		dbg_bulk("Inviting dummy list to the party for urb 0x%lx, epid %d",
+			 (unsigned long)urb, epid);
+
+		/* The last EP in the dummy list already has its next pointer set to
+		   TxBulkEPList[epid].next. */
+
+		/* We don't need to check if the DMA is at this EP or not before changing the
+		   next pointer, since we will do it in one 32-bit write (EP descriptors are
+		   32-bit aligned). */
+		TxBulkEPList[epid].next = virt_to_phys(&TxBulkDummyEPList[epid][0]);
+	}
+	/* Enable the EP descr. */
+	dbg_bulk("Enabling bulk EP for urb 0x%lx, epid %d", (unsigned long)urb, epid);
+	TxBulkEPList[epid].command |= IO_STATE(USB_EP_command, enable, yes);
+
+	/* Everything is set up, safe to enable interrupts again. */
+	restore_flags(flags);
+
+	/* If the DMA bulk channel isn't running, we need to restart it if it
+	   has stopped at the last EP descriptor (DMA stopped because there was
+	   no more traffic) or if it has stopped at a dummy EP with the intr flag
+	   set (DMA stopped because we were too slow in inserting new traffic). */
+	if (!(*R_DMA_CH8_SUB0_CMD & IO_MASK(R_DMA_CH8_SUB0_CMD, cmd))) {
+
+		USB_EP_Desc_t *ep;
+		ep = (USB_EP_Desc_t *)phys_to_virt(*R_DMA_CH8_SUB0_EP);
+		dbg_bulk("DMA channel not running in add");
+		dbg_bulk("DMA is at 0x%lx", (unsigned long)ep);
+
+		if (*R_DMA_CH8_SUB0_EP == virt_to_phys(&TxBulkEPList[NBR_OF_EPIDS - 1]) ||
+		    (ep->command & 0x8) >> 3) {
+			*R_DMA_CH8_SUB0_CMD = IO_STATE(R_DMA_CH8_SUB0_CMD, cmd, start);
+			/* Update/restart the bulk start timer since we just started the channel. */
+			mod_timer(&bulk_start_timer, jiffies + BULK_START_TIMER_INTERVAL);
+			/* Update/restart the bulk eot timer since we just inserted traffic. */
+			mod_timer(&bulk_eot_timer, jiffies + BULK_EOT_TIMER_INTERVAL);
+		}
+	}
+
+	DBFEXIT;
+}
+
+static void etrax_usb_complete_bulk_urb(struct urb *urb, int status)
+{
+	etrax_urb_priv_t *urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+	int epid = urb_priv->epid;
+	unsigned long flags;
+
+	DBFENTER;
+
+	if (status)
+		warn("Completing bulk urb with status %d.", status);
+
+	dbg_bulk("Completing bulk urb 0x%lx for epid %d", (unsigned long)urb, epid);
+
+	/* Update the urb list. */
+	urb_list_del(urb, epid);
+
+	/* For an IN pipe, we always set the actual length, regardless of whether there was
+	   an error or not (which means the device driver can use the data if it wants to). */
+	if (usb_pipein(urb->pipe)) {
+		urb->actual_length = urb_priv->rx_offset;
+	} else {
+		/* Set actual_length for OUT urbs also; the USB mass storage driver seems
+		   to want that. We wouldn't know of any partial writes if there was an error. */
+		if (status == 0) {
+			urb->actual_length = urb->transfer_buffer_length;
+		} else {
+			urb->actual_length = 0;
+		}
+	}
+
+	/* FIXME: Is there something of the things below we shouldn't do if there was an error?
+	   Like, maybe we shouldn't toggle the toggle bits, or maybe we shouldn't insert more traffic. */
+
+	save_flags(flags);
+	cli();
+
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+	nop();
+
+	/* We need to fiddle with the toggle bits because the hardware doesn't do it for us. */
+	if (usb_pipeout(urb->pipe)) {
+		char toggle =
+			IO_EXTRACT(R_USB_EPT_DATA, t_out, *R_USB_EPT_DATA);
+		usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
+			      usb_pipeout(urb->pipe), toggle);
+	} else {
+		char toggle =
+			IO_EXTRACT(R_USB_EPT_DATA, t_in, *R_USB_EPT_DATA);
+		usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
+			      usb_pipeout(urb->pipe), toggle);
+	}
+	restore_flags(flags);
+
+	/* Remember to free the SBs. */
+	etrax_remove_from_sb_list(urb);
+	kfree(urb_priv);
+	urb->hcpriv = 0;
+
+	/* If there are any more urb's in the list we'd better start sending */
+	if (!urb_list_empty(epid)) {
+
+		struct urb *new_urb;
+
+		/* Get the first urb. */
+		new_urb = urb_list_first(epid);
+		assert(new_urb);
+
+		dbg_bulk("More bulk for epid %d", epid);
+
+		etrax_usb_add_to_bulk_sb_list(new_urb, epid);
+	}
+
+	urb->status = status;
+
+	/* We let any non-zero status from the layer above have precedence. */
+	if (status == 0) {
+		/* URB_SHORT_NOT_OK means that short reads (shorter than the endpoint's max length)
+		   is to be treated as an error. */
+		if (urb->transfer_flags & URB_SHORT_NOT_OK) {
+			if (usb_pipein(urb->pipe) &&
+			    (urb->actual_length !=
+			     usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)))) {
+				urb->status = -EREMOTEIO;
+			}
+		}
+	}
+
+	if (urb->complete) {
+		urb->complete(urb, NULL);
+	}
+
+	if (urb_list_empty(epid)) {
+		/* This means that this EP is now free, deconfigure it. */
+		etrax_usb_free_epid(epid);
+
+		/* No more traffic; time to clean up.
+		   Must set sub pointer to 0, since we look at the sub pointer when handling
+		   the bulk eot interrupt. */
+
+		dbg_bulk("No bulk for epid %d", epid);
+
+		TxBulkEPList[epid].sub = 0;
+
+		/* Unlink the dummy list. */
+
+		dbg_bulk("Kicking dummy list out of party for urb 0x%lx, epid %d",
+			 (unsigned long)urb, epid);
+
+		/* No need to wait for the DMA before changing the next pointer.
+		   The modulo NBR_OF_EPIDS isn't actually necessary, since we will never use
+		   the last one (INVALID_EPID) for actual traffic. */
+		TxBulkEPList[epid].next =
+			virt_to_phys(&TxBulkEPList[(epid + 1) % NBR_OF_EPIDS]);
+	}
+
+	DBFEXIT;
+}
+
+static int etrax_usb_submit_ctrl_urb(struct urb *urb)
+{
+	int epid;
+	int empty;
+	unsigned long flags;
+	etrax_urb_priv_t *urb_priv;
+
+	DBFENTER;
+
+	/* FIXME: Return -ENXIO if there is already a queued urb for this endpoint? */
+
+	/* Epid allocation, empty check and list add must be protected.
+
+	   Epid allocation because if we find an existing epid for this endpoint an urb might be
+	   completed (emptying the list) before we add the new urb to the list, causing the epid
+	   to be de-allocated. We would then start the transfer with an invalid epid -> epid attn.
+
+	   Empty check and add because otherwise we might conclude that the list is not empty,
+	   after which it becomes empty before we add the new urb to the list, causing us not to
+	   insert the new traffic into the SB list. */
+
+	spin_lock_irqsave(&urb_list_lock, flags);
+	epid = etrax_usb_setup_epid(urb);
+	if (epid == -1) {
+		spin_unlock_irqrestore(&urb_list_lock, flags);
+		DBFEXIT;
+		return -ENOMEM;
+	}
+	empty = urb_list_empty(epid);
+	urb_list_add(urb, epid);
+	spin_unlock_irqrestore(&urb_list_lock, flags);
+
+	dbg_ctrl("Adding ctrl urb 0x%lx to %s list, epid %d",
+		 (unsigned long)urb, empty ? "empty" : "", epid);
+
+	/* Mark the urb as being in progress. */
+	urb->status = -EINPROGRESS;
+
+	/* Setup the hcpriv data. */
+	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	assert(urb_priv != NULL);
+	/* This sets rx_offset to 0. */
+	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
+	urb_priv->urb_state = NOT_STARTED;
+	urb->hcpriv = urb_priv;
+
+	if (empty) {
+		etrax_usb_add_to_ctrl_sb_list(urb, epid);
+	}
+
+	DBFEXIT;
+
+	return 0;
+}
+
+static void etrax_usb_add_to_ctrl_sb_list(struct urb *urb, int epid)
+{
+	USB_SB_Desc_t *sb_desc_setup;
+	USB_SB_Desc_t *sb_desc_data;
+	USB_SB_Desc_t *sb_desc_status;
+
+	etrax_urb_priv_t *urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+
+	unsigned long flags;
+	char maxlen;
+
+	DBFENTER;
+
+	maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
+
+	sb_desc_setup = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_FLAG);
+	assert(sb_desc_setup != NULL);
+	sb_desc_status = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_FLAG);
+	assert(sb_desc_status != NULL);
+
+	/* Initialize the mandatory setup SB descriptor (used only in control transfers) */
+	sb_desc_setup->sw_len = 8;
+	sb_desc_setup->command = (IO_FIELD(USB_SB_command, rem, 0) |
+				  IO_STATE(USB_SB_command, tt, setup) |
+				  IO_STATE(USB_SB_command, full, yes) |
+				  IO_STATE(USB_SB_command, eot, yes));
+
+	sb_desc_setup->buf = virt_to_phys(urb->setup_packet);
+
+	if (usb_pipeout(urb->pipe)) {
+		dbg_ctrl("Transfer for epid %d is OUT", epid);
+
+		/* If this Control OUT transfer has an optional data stage we add an OUT token
+		   before the mandatory IN (status) token, hence the reordered SB list */
+
+		sb_desc_setup->next = virt_to_phys(sb_desc_status);
+		if (urb->transfer_buffer) {
+
+			dbg_ctrl("This OUT transfer has an extra data stage");
+
+			sb_desc_data = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_FLAG);
+			assert(sb_desc_data != NULL);
+
+			sb_desc_setup->next = virt_to_phys(sb_desc_data);
+
+			sb_desc_data->sw_len = urb->transfer_buffer_length;
+			sb_desc_data->command = (IO_STATE(USB_SB_command, tt, out) |
+						 IO_STATE(USB_SB_command, full, yes) |
+						 IO_STATE(USB_SB_command, eot, yes));
+			sb_desc_data->buf = virt_to_phys(urb->transfer_buffer);
+			sb_desc_data->next = virt_to_phys(sb_desc_status);
+		}
+
+		sb_desc_status->sw_len = 1;
+		sb_desc_status->command = (IO_FIELD(USB_SB_command, rem, 0) |
+					   IO_STATE(USB_SB_command, tt, in) |
+					   IO_STATE(USB_SB_command, eot, yes) |
+					   IO_STATE(USB_SB_command, intr, yes) |
+					   IO_STATE(USB_SB_command, eol, yes));
+
+		sb_desc_status->buf = 0;
+		sb_desc_status->next = 0;
+
+	} else if (usb_pipein(urb->pipe)) {
+
+		dbg_ctrl("Transfer for epid %d is IN", epid);
+		dbg_ctrl("transfer_buffer_length = %d", urb->transfer_buffer_length);
+		dbg_ctrl("rem is calculated to %d", urb->transfer_buffer_length % maxlen);
+
+		sb_desc_data = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_FLAG);
+		assert(sb_desc_data != NULL);
+
+		sb_desc_setup->next = virt_to_phys(sb_desc_data);
+
+		sb_desc_data->sw_len = urb->transfer_buffer_length ?
+			(urb->transfer_buffer_length - 1) / maxlen + 1 : 0;
+		dbg_ctrl("sw_len got %d", sb_desc_data->sw_len);
+
+		sb_desc_data->command =
+			(IO_FIELD(USB_SB_command, rem,
+				  urb->transfer_buffer_length % maxlen) |
+			 IO_STATE(USB_SB_command, tt, in) |
+			 IO_STATE(USB_SB_command, eot, yes));
+
+		sb_desc_data->buf = 0;
+		sb_desc_data->next = virt_to_phys(sb_desc_status);
+
+		/* Read comment at zout_buffer declaration for an explanation to this. */
+		sb_desc_status->sw_len = 1;
+		sb_desc_status->command = (IO_FIELD(USB_SB_command, rem, 0) |
+					   IO_STATE(USB_SB_command, tt, zout) |
+					   IO_STATE(USB_SB_command, full, yes) |
+					   IO_STATE(USB_SB_command, eot, yes) |
+					   IO_STATE(USB_SB_command, intr, yes) |
+					   IO_STATE(USB_SB_command, eol, yes));
+
+		sb_desc_status->buf = virt_to_phys(&zout_buffer[0]);
+		sb_desc_status->next = 0;
+	}
+
+	urb_priv->first_sb = sb_desc_setup;
+	urb_priv->last_sb = sb_desc_status;
+	urb_priv->epid = epid;
+
+	urb_priv->urb_state = STARTED;
+
+	/* Reset toggle bits and reset error count, remember to di and ei */
+	/* Warning: it is possible that this locking doesn't work with bottom-halves */
+
+	save_flags(flags);
+	cli();
+
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+	nop();
+	if (*R_USB_EPT_DATA & IO_MASK(R_USB_EPT_DATA, hold)) {
+		panic("Hold was set in %s", __FUNCTION__);
+	}
+
+
+	/* FIXME: Compare with etrax_usb_add_to_bulk_sb_list where the toggle bits
+	   are set to a specific value. Why the difference? Read "Transfer and Toggle Bits
+	   in Designer's Reference, p. 8 - 11. */
+	*R_USB_EPT_DATA &=
+		~(IO_MASK(R_USB_EPT_DATA, error_count_in) |
+		  IO_MASK(R_USB_EPT_DATA, error_count_out) |
+		  IO_MASK(R_USB_EPT_DATA, t_in) |
+		  IO_MASK(R_USB_EPT_DATA, t_out));
+
+	/* Since we use the rx interrupt to complete ctrl urbs, we can enable interrupts now
+	   (i.e. we don't check the sub pointer on an eot interrupt like we do for bulk traffic). */
+	restore_flags(flags);
+
+	/* Assert that the EP descriptor is disabled. */
+	assert(!(TxCtrlEPList[epid].command & IO_MASK(USB_EP_command, enable)));
+
+	/* Set up and enable the EP descriptor. */
+	TxCtrlEPList[epid].sub = virt_to_phys(sb_desc_setup);
+	TxCtrlEPList[epid].hw_len = 0;
+	TxCtrlEPList[epid].command |= IO_STATE(USB_EP_command, enable, yes);
+
+	/* We start the DMA sub channel without checking if it's running or not, because:
+	   1) If it's already running, issuing the start command is a nop.
+	   2) We avoid a test-and-set race condition. */
+	*R_DMA_CH8_SUB1_CMD = IO_STATE(R_DMA_CH8_SUB1_CMD, cmd, start);
+
+	DBFEXIT;
+}
+
+static void etrax_usb_complete_ctrl_urb(struct urb *urb, int status)
+{
+	etrax_urb_priv_t *urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+	int epid = urb_priv->epid;
+
+	DBFENTER;
+
+	if (status)
+		warn("Completing ctrl urb with status %d.", status);
+
+	dbg_ctrl("Completing ctrl epid %d, urb 0x%lx", epid, (unsigned long)urb);
+
+	/* Remove this urb from the list. */
+	urb_list_del(urb, epid);
+
+	/* For an IN pipe, we always set the actual length, regardless of whether there was
+	   an error or not (which means the device driver can use the data if it wants to). */
+	if (usb_pipein(urb->pipe)) {
+		urb->actual_length = urb_priv->rx_offset;
+	}
+
+	/* FIXME: Is there something of the things below we shouldn't do if there was an error?
+	   Like, maybe we shouldn't insert more traffic. */
+
+	/* Remember to free the SBs. */
+	etrax_remove_from_sb_list(urb);
+	kfree(urb_priv);
+	urb->hcpriv = 0;
+
+	/* If there are any more urbs in the list we'd better start sending. */
+	if (!urb_list_empty(epid)) {
+		struct urb *new_urb;
+
+		/* Get the first urb. */
+		new_urb = urb_list_first(epid);
+		assert(new_urb);
+
+		dbg_ctrl("More ctrl for epid %d, first urb = 0x%lx", epid, (unsigned long)new_urb);
+
+		etrax_usb_add_to_ctrl_sb_list(new_urb, epid);
+	}
+
+	urb->status = status;
+
+	/* We let any non-zero status from the layer above have precedence. */
+	if (status == 0) {
+		/* URB_SHORT_NOT_OK means that short reads (shorter than the endpoint's max length)
+		   is to be treated as an error. */
+		if (urb->transfer_flags & URB_SHORT_NOT_OK) {
+			if (usb_pipein(urb->pipe) &&
+			    (urb->actual_length !=
+			     usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)))) {
+				urb->status = -EREMOTEIO;
+			}
+		}
+	}
+
+	if (urb->complete) {
+		urb->complete(urb, NULL);
+	}
+
+	if (urb_list_empty(epid)) {
+		/* No more traffic. Time to clean up. */
+		etrax_usb_free_epid(epid);
+		/* Must set sub pointer to 0. */
+		dbg_ctrl("No ctrl for epid %d", epid);
+		TxCtrlEPList[epid].sub = 0;
+	}
+
+	DBFEXIT;
+}
+
+static int etrax_usb_submit_intr_urb(struct urb *urb)
+{
+
+	int epid;
+
+	DBFENTER;
+
+	if (usb_pipeout(urb->pipe)) {
+		/* Unsupported transfer type.
+		   We don't support interrupt out traffic. (If we do, we can't support
+		   intervals for neither in or out traffic, but are forced to schedule all
+		   interrupt traffic in one frame.) */
+		return -EINVAL;
+	}
+
+	epid = etrax_usb_setup_epid(urb);
+	if (epid == -1) {
+		DBFEXIT;
+		return -ENOMEM;
+	}
+
+	if (!urb_list_empty(epid)) {
+		/* There is already a queued urb for this endpoint. */
+		etrax_usb_free_epid(epid);
+		return -ENXIO;
+	}
+
+	urb->status = -EINPROGRESS;
+
+	dbg_intr("Add intr urb 0x%lx, to list, epid %d", (unsigned long)urb, epid);
+
+	urb_list_add(urb, epid);
+	etrax_usb_add_to_intr_sb_list(urb, epid);
+
+	return 0;
+
+	DBFEXIT;
+}
+
+static void etrax_usb_add_to_intr_sb_list(struct urb *urb, int epid)
+{
+
+	volatile USB_EP_Desc_t *tmp_ep;
+	volatile USB_EP_Desc_t *first_ep;
+
+	char maxlen;
+	int interval;
+	int i;
+
+	etrax_urb_priv_t *urb_priv;
+
+	DBFENTER;
+
+	maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
+	interval = urb->interval;
+
+	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	assert(urb_priv != NULL);
+	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
+	urb->hcpriv = urb_priv;
+
+	first_ep = &TxIntrEPList[0];
+
+	/* Round of the interval to 2^n, it is obvious that this code favours
+	   smaller numbers, but that is actually a good thing */
+	/* FIXME: The "rounding error" for larger intervals will be quite
+	   large. For in traffic this shouldn't be a problem since it will only
+	   mean that we "poll" more often. */
+	for (i = 0; interval; i++) {
+		interval = interval >> 1;
+	}
+	interval = 1 << (i - 1);
+
+	dbg_intr("Interval rounded to %d", interval);
+
+	tmp_ep = first_ep;
+	i = 0;
+	do {
+		if (tmp_ep->command & IO_MASK(USB_EP_command, eof)) {
+			if ((i % interval) == 0) {
+				/* Insert the traffic ep after tmp_ep */
+				USB_EP_Desc_t *ep_desc;
+				USB_SB_Desc_t *sb_desc;
+
+				dbg_intr("Inserting EP for epid %d", epid);
+
+				ep_desc = (USB_EP_Desc_t *)
+					kmem_cache_alloc(usb_desc_cache, SLAB_FLAG);
+				sb_desc = (USB_SB_Desc_t *)
+					kmem_cache_alloc(usb_desc_cache, SLAB_FLAG);
+				assert(ep_desc != NULL);
+				CHECK_ALIGN(ep_desc);
+				assert(sb_desc != NULL);
+
+				ep_desc->sub = virt_to_phys(sb_desc);
+				ep_desc->hw_len = 0;
+				ep_desc->command = (IO_FIELD(USB_EP_command, epid, epid) |
+						    IO_STATE(USB_EP_command, enable, yes));
+
+
+				/* Round upwards the number of packets of size maxlen
+				   that this SB descriptor should receive. */
+				sb_desc->sw_len = urb->transfer_buffer_length ?
+					(urb->transfer_buffer_length - 1) / maxlen + 1 : 0;
+				sb_desc->next = 0;
+				sb_desc->buf = 0;
+				sb_desc->command =
+					(IO_FIELD(USB_SB_command, rem, urb->transfer_buffer_length % maxlen) |
+					 IO_STATE(USB_SB_command, tt, in) |
+					 IO_STATE(USB_SB_command, eot, yes) |
+					 IO_STATE(USB_SB_command, eol, yes));
+
+				ep_desc->next = tmp_ep->next;
+				tmp_ep->next = virt_to_phys(ep_desc);
+			}
+			i++;
+		}
+		tmp_ep = (USB_EP_Desc_t *)phys_to_virt(tmp_ep->next);
+	} while (tmp_ep != first_ep);
+
+
+	/* Note that first_sb/last_sb doesn't apply to interrupt traffic. */
+	urb_priv->epid = epid;
+
+	/* We start the DMA sub channel without checking if it's running or not, because:
+	   1) If it's already running, issuing the start command is a nop.
+	   2) We avoid a test-and-set race condition. */
+	*R_DMA_CH8_SUB2_CMD = IO_STATE(R_DMA_CH8_SUB2_CMD, cmd, start);
+
+	DBFEXIT;
+}
+
+
+
+static void etrax_usb_complete_intr_urb(struct urb *urb, int status)
+{
+	etrax_urb_priv_t *urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+	int epid = urb_priv->epid;
+
+	DBFENTER;
+
+	if (status)
+		warn("Completing intr urb with status %d.", status);
+
+	dbg_intr("Completing intr epid %d, urb 0x%lx", epid, (unsigned long)urb);
+
+	urb->status = status;
+	urb->actual_length = urb_priv->rx_offset;
+
+	dbg_intr("interrupt urb->actual_length = %d", urb->actual_length);
+
+	/* We let any non-zero status from the layer above have precedence. */
+	if (status == 0) {
+		/* URB_SHORT_NOT_OK means that short reads (shorter than the endpoint's max length)
+		   is to be treated as an error. */
+		if (urb->transfer_flags & URB_SHORT_NOT_OK) {
+			if (urb->actual_length !=
+			    usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe))) {
+				urb->status = -EREMOTEIO;
+			}
+		}
+	}
+
+	/* The driver will resubmit the URB so we need to remove it first */
+        etrax_usb_unlink_urb(urb, 0);
+	if (urb->complete) {
+		urb->complete(urb, NULL);
+	}
+
+	DBFEXIT;
+}
+
+
+static int etrax_usb_submit_isoc_urb(struct urb *urb)
+{
+	int epid;
+	unsigned long flags;
+
+	DBFENTER;
+
+	dbg_isoc("Submitting isoc urb = 0x%lx", (unsigned long)urb);
+
+	/* Epid allocation, empty check and list add must be protected.
+	   Read about this in etrax_usb_submit_ctrl_urb. */
+
+	spin_lock_irqsave(&urb_list_lock, flags);
+	/* Is there an active epid for this urb ? */
+	epid = etrax_usb_setup_epid(urb);
+	if (epid == -1) {
+		DBFEXIT;
+		spin_unlock_irqrestore(&urb_list_lock, flags);
+		return -ENOMEM;
+	}
+
+	/* Ok, now we got valid endpoint, lets insert some traffic */
+
+	urb->status = -EINPROGRESS;
+
+	/* Find the last urb in the URB_List and add this urb after that one.
+	   Also add the traffic, that is do an etrax_usb_add_to_isoc_sb_list.  This
+	   is important to make this in "real time" since isochronous traffic is
+	   time sensitive. */
+
+	dbg_isoc("Adding isoc urb to (possibly empty) list");
+	urb_list_add(urb, epid);
+	etrax_usb_add_to_isoc_sb_list(urb, epid);
+	spin_unlock_irqrestore(&urb_list_lock, flags);
+
+	DBFEXIT;
+
+	return 0;
+}
+
+static void etrax_usb_check_error_isoc_ep(const int epid)
+{
+	unsigned long int flags;
+	int error_code;
+	__u32 r_usb_ept_data;
+
+	/* We can't read R_USB_EPID_ATTN here since it would clear the iso_eof,
+	   bulk_eot and epid_attn interrupts.  So we just check the status of
+	   the epid without testing if for it in R_USB_EPID_ATTN. */
+
+
+	save_flags(flags);
+	cli();
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+	nop();
+	/* Note that although there are separate R_USB_EPT_DATA and R_USB_EPT_DATA_ISO
+	   registers, they are located at the same address and are of the same size.
+	   In other words, this read should be ok for isoc also. */
+	r_usb_ept_data = *R_USB_EPT_DATA;
+	restore_flags(flags);
+
+	error_code = IO_EXTRACT(R_USB_EPT_DATA_ISO, error_code, r_usb_ept_data);
+
+	if (r_usb_ept_data & IO_MASK(R_USB_EPT_DATA, hold)) {
+		warn("Hold was set for epid %d.", epid);
+		return;
+	}
+
+	if (error_code == IO_STATE_VALUE(R_USB_EPT_DATA_ISO, error_code, no_error)) {
+
+		/* This indicates that the SB list of the ept was completed before
+		   new data was appended to it.  This is not an error, but indicates
+		   large system or USB load and could possibly cause trouble for
+		   very timing sensitive USB device drivers so we log it.
+		*/
+		info("Isoc. epid %d disabled with no error", epid);
+		return;
+
+	} else if (error_code == IO_STATE_VALUE(R_USB_EPT_DATA_ISO, error_code, stall)) {
+		/* Not really a protocol error, just says that the endpoint gave
+		   a stall response. Note that error_code cannot be stall for isoc. */
+		panic("Isoc traffic cannot stall");
+
+	} else if (error_code == IO_STATE_VALUE(R_USB_EPT_DATA_ISO, error_code, bus_error)) {
+		/* Two devices responded to a transaction request. Must be resolved
+		   by software. FIXME: Reset ports? */
+		panic("Bus error for epid %d."
+		      " Two devices responded to transaction request",
+		      epid);
+
+	} else if (error_code == IO_STATE_VALUE(R_USB_EPT_DATA, error_code, buffer_error)) {
+		/* DMA overrun or underrun. */
+		warn("Buffer overrun/underrun for epid %d. DMA too busy?", epid);
+
+		/* It seems that error_code = buffer_error in
+		   R_USB_EPT_DATA/R_USB_EPT_DATA_ISO and ourun = yes in R_USB_STATUS
+		   are the same error. */
+	}
+}
+
+
+static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
+{
+
+	int i = 0;
+
+	etrax_urb_priv_t *urb_priv;
+	USB_SB_Desc_t *prev_sb_desc,  *next_sb_desc, *temp_sb_desc;
+
+	DBFENTER;
+
+	prev_sb_desc = next_sb_desc = temp_sb_desc = NULL;
+
+	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC);
+	assert(urb_priv != NULL);
+	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
+
+	urb->hcpriv = urb_priv;
+	urb_priv->epid = epid;
+
+	if (usb_pipeout(urb->pipe)) {
+
+		if (urb->number_of_packets == 0) panic("etrax_usb_add_to_isoc_sb_list 0 packets\n");
+
+		dbg_isoc("Transfer for epid %d is OUT", epid);
+		dbg_isoc("%d packets in URB", urb->number_of_packets);
+
+		/* Create one SB descriptor for each packet and link them together. */
+		for (i = 0; i < urb->number_of_packets; i++) {
+			if (!urb->iso_frame_desc[i].length)
+				continue;
+
+			next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC);
+			assert(next_sb_desc != NULL);
+
+			if (urb->iso_frame_desc[i].length > 0) {
+
+				next_sb_desc->command = (IO_STATE(USB_SB_command, tt, out) |
+							 IO_STATE(USB_SB_command, eot, yes));
+
+				next_sb_desc->sw_len = urb->iso_frame_desc[i].length;
+				next_sb_desc->buf = virt_to_phys((char*)urb->transfer_buffer + urb->iso_frame_desc[i].offset);
+
+				/* Check if full length transfer. */
+				if (urb->iso_frame_desc[i].length ==
+				    usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe))) {
+					next_sb_desc->command |= IO_STATE(USB_SB_command, full, yes);
+				}
+			} else {
+				dbg_isoc("zero len packet");
+				next_sb_desc->command = (IO_FIELD(USB_SB_command, rem, 0) |
+							 IO_STATE(USB_SB_command, tt, zout) |
+							 IO_STATE(USB_SB_command, eot, yes) |
+							 IO_STATE(USB_SB_command, full, yes));
+
+				next_sb_desc->sw_len = 1;
+				next_sb_desc->buf = virt_to_phys(&zout_buffer[0]);
+			}
+
+			/* First SB descriptor that belongs to this urb */
+			if (i == 0)
+				urb_priv->first_sb = next_sb_desc;
+			else
+				prev_sb_desc->next = virt_to_phys(next_sb_desc);
+
+			prev_sb_desc = next_sb_desc;
+		}
+
+		next_sb_desc->command |= (IO_STATE(USB_SB_command, intr, yes) |
+					  IO_STATE(USB_SB_command, eol, yes));
+		next_sb_desc->next = 0;
+		urb_priv->last_sb = next_sb_desc;
+
+	} else if (usb_pipein(urb->pipe)) {
+
+		dbg_isoc("Transfer for epid %d is IN", epid);
+		dbg_isoc("transfer_buffer_length = %d", urb->transfer_buffer_length);
+		dbg_isoc("rem is calculated to %d", urb->iso_frame_desc[urb->number_of_packets - 1].length);
+
+		/* Note that in descriptors for periodic traffic are not consumed. This means that
+		   the USB controller never propagates in the SB list. In other words, if there already
+		   is an SB descriptor in the list for this EP we don't have to do anything. */
+		if (TxIsocEPList[epid].sub == 0) {
+			dbg_isoc("Isoc traffic not already running, allocating SB");
+
+			next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC);
+			assert(next_sb_desc != NULL);
+
+			next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) |
+						 IO_STATE(USB_SB_command, eot, yes) |
+						 IO_STATE(USB_SB_command, eol, yes));
+
+			next_sb_desc->next = 0;
+			next_sb_desc->sw_len = 1; /* Actual number of packets is not relevant
+						     for periodic in traffic as long as it is more
+						     than zero.  Set to 1 always. */
+			next_sb_desc->buf = 0;
+
+			/* The rem field is don't care for isoc traffic, so we don't set it. */
+
+			/* Only one SB descriptor that belongs to this urb. */
+			urb_priv->first_sb = next_sb_desc;
+			urb_priv->last_sb = next_sb_desc;
+
+		} else {
+
+			dbg_isoc("Isoc traffic already running, just setting first/last_sb");
+
+			/* Each EP for isoc in will have only one SB descriptor, setup when submitting the
+			   already active urb. Note that even though we may have several first_sb/last_sb
+			   pointing at the same SB descriptor, they are freed only once (when the list has
+			   become empty). */
+			urb_priv->first_sb = phys_to_virt(TxIsocEPList[epid].sub);
+			urb_priv->last_sb = phys_to_virt(TxIsocEPList[epid].sub);
+			return;
+		}
+
+	}
+
+	/* Find the spot to insert this urb and add it. */
+	if (TxIsocEPList[epid].sub == 0) {
+		/* First SB descriptor inserted in this list (in or out). */
+		dbg_isoc("Inserting SB desc first in list");
+		TxIsocEPList[epid].hw_len = 0;
+		TxIsocEPList[epid].sub = virt_to_phys(urb_priv->first_sb);
+
+	} else {
+		/* Isochronous traffic is already running, insert new traffic last (only out). */
+		dbg_isoc("Inserting SB desc last in list");
+		temp_sb_desc = phys_to_virt(TxIsocEPList[epid].sub);
+		while ((temp_sb_desc->command & IO_MASK(USB_SB_command, eol)) !=
+		       IO_STATE(USB_SB_command, eol, yes)) {
+			assert(temp_sb_desc->next);
+			temp_sb_desc = phys_to_virt(temp_sb_desc->next);
+		}
+		dbg_isoc("Appending list on desc 0x%p", temp_sb_desc);
+
+		/* Next pointer must be set before eol is removed. */
+		temp_sb_desc->next = virt_to_phys(urb_priv->first_sb);
+		/* Clear the previous end of list flag since there is a new in the
+		   added SB descriptor list. */
+		temp_sb_desc->command &= ~IO_MASK(USB_SB_command, eol);
+
+		if (!(TxIsocEPList[epid].command & IO_MASK(USB_EP_command, enable))) {
+			/* 8.8.5 in Designer's Reference says we should check for and correct
+			   any errors in the EP here.  That should not be necessary if epid_attn
+			   is handled correctly, so we assume all is ok. */
+			dbg_isoc("EP disabled");
+			etrax_usb_check_error_isoc_ep(epid);
+
+			/* The SB list was exhausted. */
+			if (virt_to_phys(urb_priv->last_sb) != TxIsocEPList[epid].sub) {
+				/* The new sublist did not get processed before the EP was
+				   disabled.  Setup the EP again. */
+				dbg_isoc("Set EP sub to new list");
+				TxIsocEPList[epid].hw_len = 0;
+				TxIsocEPList[epid].sub = virt_to_phys(urb_priv->first_sb);
+			}
+		}
+	}
+
+	if (urb->transfer_flags & URB_ISO_ASAP) {
+		/* The isoc transfer should be started as soon as possible. The start_frame
+		   field is a return value if URB_ISO_ASAP was set. Comparing R_USB_FM_NUMBER
+		   with a USB Chief trace shows that the first isoc IN token is sent 2 frames
+		   later. I'm not sure how this affects usage of the start_frame field by the
+		   device driver, or how it affects things when USB_ISO_ASAP is not set, so
+		   therefore there's no compensation for the 2 frame "lag" here. */
+		urb->start_frame = (*R_USB_FM_NUMBER & 0x7ff);
+		TxIsocEPList[epid].command |= IO_STATE(USB_EP_command, enable, yes);
+		urb_priv->urb_state = STARTED;
+		dbg_isoc("URB_ISO_ASAP set, urb->start_frame set to %d", urb->start_frame);
+	} else {
+		/* Not started yet. */
+		urb_priv->urb_state = NOT_STARTED;
+		dbg_isoc("urb_priv->urb_state set to NOT_STARTED");
+	}
+
+       /* We start the DMA sub channel without checking if it's running or not, because:
+	  1) If it's already running, issuing the start command is a nop.
+	  2) We avoid a test-and-set race condition. */
+	*R_DMA_CH8_SUB3_CMD = IO_STATE(R_DMA_CH8_SUB3_CMD, cmd, start);
+
+	DBFEXIT;
+}
+
+static void etrax_usb_complete_isoc_urb(struct urb *urb, int status)
+{
+	etrax_urb_priv_t *urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+	int epid = urb_priv->epid;
+	int auto_resubmit = 0;
+
+	DBFENTER;
+	dbg_isoc("complete urb 0x%p, status %d", urb, status);
+
+	if (status)
+		warn("Completing isoc urb with status %d.", status);
+
+	if (usb_pipein(urb->pipe)) {
+		int i;
+
+		/* Make that all isoc packets have status and length set before
+		   completing the urb. */
+		for (i = urb_priv->isoc_packet_counter; i < urb->number_of_packets; i++) {
+			urb->iso_frame_desc[i].actual_length = 0;
+			urb->iso_frame_desc[i].status = -EPROTO;
+		}
+
+		urb_list_del(urb, epid);
+
+		if (!list_empty(&urb_list[epid])) {
+			((etrax_urb_priv_t *)(urb_list_first(epid)->hcpriv))->urb_state = STARTED;
+		} else {
+			unsigned long int flags;
+			if (TxIsocEPList[epid].command & IO_MASK(USB_EP_command, enable)) {
+				/* The EP was enabled, disable it and wait. */
+				TxIsocEPList[epid].command &= ~IO_MASK(USB_EP_command, enable);
+
+				/* Ah, the luxury of busy-wait. */
+				while (*R_DMA_CH8_SUB3_EP == virt_to_phys(&TxIsocEPList[epid]));
+			}
+
+			etrax_remove_from_sb_list(urb);
+			TxIsocEPList[epid].sub = 0;
+			TxIsocEPList[epid].hw_len = 0;
+
+			save_flags(flags);
+			cli();
+			etrax_usb_free_epid(epid);
+			restore_flags(flags);
+		}
+
+		urb->hcpriv = 0;
+		kfree(urb_priv);
+
+		/* Release allocated bandwidth. */
+		usb_release_bandwidth(urb->dev, urb, 0);
+	} else if (usb_pipeout(urb->pipe)) {
+		int freed_descr;
+
+		dbg_isoc("Isoc out urb complete 0x%p", urb);
+
+		/* Update the urb list. */
+		urb_list_del(urb, epid);
+
+		freed_descr = etrax_remove_from_sb_list(urb);
+		dbg_isoc("freed %d descriptors of %d packets", freed_descr, urb->number_of_packets);
+		assert(freed_descr == urb->number_of_packets);
+		urb->hcpriv = 0;
+		kfree(urb_priv);
+
+		/* Release allocated bandwidth. */
+		usb_release_bandwidth(urb->dev, urb, 0);
+	}
+
+	urb->status = status;
+	if (urb->complete) {
+		urb->complete(urb, NULL);
+	}
+
+	if (auto_resubmit) {
+		/* Check that urb was not unlinked by the complete callback. */
+		if (__urb_list_entry(urb, epid)) {
+			/* Move this one down the list. */
+			urb_list_move_last(urb, epid);
+
+			/* Mark the now first urb as started (may already be). */
+			((etrax_urb_priv_t *)(urb_list_first(epid)->hcpriv))->urb_state = STARTED;
+
+			/* Must set this to 0 since this urb is still active after
+			   completion. */
+			urb_priv->isoc_packet_counter = 0;
+		} else {
+			warn("(ISOC) automatic resubmit urb 0x%p removed by complete.", urb);
+		}
+	}
+
+	DBFEXIT;
+}
+
+static void etrax_usb_complete_urb(struct urb *urb, int status)
+{
+	switch (usb_pipetype(urb->pipe)) {
+	case PIPE_BULK:
+		etrax_usb_complete_bulk_urb(urb, status);
+		break;
+	case PIPE_CONTROL:
+		etrax_usb_complete_ctrl_urb(urb, status);
+		break;
+	case PIPE_INTERRUPT:
+		etrax_usb_complete_intr_urb(urb, status);
+		break;
+	case PIPE_ISOCHRONOUS:
+		etrax_usb_complete_isoc_urb(urb, status);
+		break;
+	default:
+		err("Unknown pipetype");
+	}
+}
+
+
+
+static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc, struct pt_regs *regs)
+{
+	usb_interrupt_registers_t *reg;
+	unsigned long flags;
+	__u32 irq_mask;
+	__u8 status;
+	__u32 epid_attn;
+	__u16 port_status_1;
+	__u16 port_status_2;
+	__u32 fm_number;
+
+	DBFENTER;
+
+	/* Read critical registers into local variables, do kmalloc afterwards. */
+	save_flags(flags);
+	cli();
+
+	irq_mask = *R_USB_IRQ_MASK_READ;
+	/* Reading R_USB_STATUS clears the ctl_status interrupt. Note that R_USB_STATUS
+	   must be read before R_USB_EPID_ATTN since reading the latter clears the
+	   ourun and perror fields of R_USB_STATUS. */
+	status = *R_USB_STATUS;
+
+	/* Reading R_USB_EPID_ATTN clears the iso_eof, bulk_eot and epid_attn interrupts. */
+	epid_attn = *R_USB_EPID_ATTN;
+
+	/* Reading R_USB_RH_PORT_STATUS_1 and R_USB_RH_PORT_STATUS_2 clears the
+	   port_status interrupt. */
+	port_status_1 = *R_USB_RH_PORT_STATUS_1;
+	port_status_2 = *R_USB_RH_PORT_STATUS_2;
+
+	/* Reading R_USB_FM_NUMBER clears the sof interrupt. */
+	/* Note: the lower 11 bits contain the actual frame number, sent with each sof. */
+	fm_number = *R_USB_FM_NUMBER;
+
+	restore_flags(flags);
+
+	reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, SLAB_ATOMIC);
+
+	assert(reg != NULL);
+
+	reg->hc = (etrax_hc_t *)vhc;
+
+	/* Now put register values into kmalloc'd area. */
+	reg->r_usb_irq_mask_read = irq_mask;
+	reg->r_usb_status = status;
+	reg->r_usb_epid_attn = epid_attn;
+	reg->r_usb_rh_port_status_1 = port_status_1;
+	reg->r_usb_rh_port_status_2 = port_status_2;
+	reg->r_usb_fm_number = fm_number;
+
+        INIT_WORK(&reg->usb_bh, etrax_usb_hc_interrupt_bottom_half, reg);
+        schedule_work(&reg->usb_bh);
+
+	DBFEXIT;
+
+        return IRQ_HANDLED;
+}
+
+static void etrax_usb_hc_interrupt_bottom_half(void *data)
+{
+	usb_interrupt_registers_t *reg = (usb_interrupt_registers_t *)data;
+	__u32 irq_mask = reg->r_usb_irq_mask_read;
+
+	DBFENTER;
+
+	/* Interrupts are handled in order of priority. */
+	if (irq_mask & IO_MASK(R_USB_IRQ_MASK_READ, epid_attn)) {
+		etrax_usb_hc_epid_attn_interrupt(reg);
+	}
+	if (irq_mask & IO_MASK(R_USB_IRQ_MASK_READ, port_status)) {
+		etrax_usb_hc_port_status_interrupt(reg);
+	}
+	if (irq_mask & IO_MASK(R_USB_IRQ_MASK_READ, ctl_status)) {
+		etrax_usb_hc_ctl_status_interrupt(reg);
+	}
+	if (irq_mask & IO_MASK(R_USB_IRQ_MASK_READ, iso_eof)) {
+		etrax_usb_hc_isoc_eof_interrupt();
+	}
+	if (irq_mask & IO_MASK(R_USB_IRQ_MASK_READ, bulk_eot)) {
+		/* Update/restart the bulk start timer since obviously the channel is running. */
+		mod_timer(&bulk_start_timer, jiffies + BULK_START_TIMER_INTERVAL);
+		/* Update/restart the bulk eot timer since we just received an bulk eot interrupt. */
+		mod_timer(&bulk_eot_timer, jiffies + BULK_EOT_TIMER_INTERVAL);
+
+		etrax_usb_hc_bulk_eot_interrupt(0);
+	}
+
+	kmem_cache_free(top_half_reg_cache, reg);
+
+	DBFEXIT;
+}
+
+
+void etrax_usb_hc_isoc_eof_interrupt(void)
+{
+	struct urb *urb;
+	etrax_urb_priv_t *urb_priv;
+	int epid;
+	unsigned long flags;
+
+	DBFENTER;
+
+	/* Do not check the invalid epid (it has a valid sub pointer). */
+	for (epid = 0; epid < NBR_OF_EPIDS - 1; epid++) {
+
+		/* Do not check the invalid epid (it has a valid sub pointer). */
+		if ((epid == DUMMY_EPID) || (epid == INVALID_EPID))
+			continue;
+
+		/* Disable interrupts to block the isoc out descriptor interrupt handler
+		   from being called while the isoc EPID list is being checked.
+		*/
+		save_flags(flags);
+		cli();
+
+		if (TxIsocEPList[epid].sub == 0) {
+			/* Nothing here to see. */
+			restore_flags(flags);
+			continue;
+		}
+
+		/* Get the first urb (if any). */
+		urb = urb_list_first(epid);
+		if (urb == 0) {
+			warn("Ignoring NULL urb");
+			restore_flags(flags);
+			continue;
+		}
+		if (usb_pipein(urb->pipe)) {
+
+			/* Sanity check. */
+			assert(usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS);
+
+			urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+			assert(urb_priv);
+
+			if (urb_priv->urb_state == NOT_STARTED) {
+
+				/* If ASAP is not set and urb->start_frame is the current frame,
+				   start the transfer. */
+				if (!(urb->transfer_flags & URB_ISO_ASAP) &&
+				    (urb->start_frame == (*R_USB_FM_NUMBER & 0x7ff))) {
+
+					dbg_isoc("Enabling isoc IN EP descr for epid %d", epid);
+					TxIsocEPList[epid].command |= IO_STATE(USB_EP_command, enable, yes);
+
+					/* This urb is now active. */
+					urb_priv->urb_state = STARTED;
+					continue;
+				}
+			}
+		}
+		restore_flags(flags);
+	}
+
+	DBFEXIT;
+
+}
+
+void etrax_usb_hc_bulk_eot_interrupt(int timer_induced)
+{
+ 	int epid;
+
+	/* The technique is to run one urb at a time, wait for the eot interrupt at which
+	   point the EP descriptor has been disabled. */
+
+	DBFENTER;
+	dbg_bulk("bulk eot%s", timer_induced ? ", called by timer" : "");
+
+	for (epid = 0; epid < NBR_OF_EPIDS; epid++) {
+
+		if (!(TxBulkEPList[epid].command & IO_MASK(USB_EP_command, enable)) &&
+		    (TxBulkEPList[epid].sub != 0)) {
+
+			struct urb *urb;
+			etrax_urb_priv_t *urb_priv;
+			unsigned long flags;
+			__u32 r_usb_ept_data;
+
+			/* Found a disabled EP descriptor which has a non-null sub pointer.
+			   Verify that this ctrl EP descriptor got disabled no errors.
+			   FIXME: Necessary to check error_code? */
+			dbg_bulk("for epid %d?", epid);
+
+			/* Get the first urb. */
+			urb = urb_list_first(epid);
+
+			/* FIXME: Could this happen for valid reasons? Why did it disappear? Because of
+			   wrong unlinking? */
+			if (!urb) {
+				warn("NULL urb for epid %d", epid);
+				continue;
+			}
+
+			assert(urb);
+			urb_priv = (etrax_urb_priv_t *)urb->hcpriv;
+			assert(urb_priv);
+
+			/* Sanity checks. */
+			assert(usb_pipetype(urb->pipe) == PIPE_BULK);
+			if (phys_to_virt(TxBulkEPList[epid].sub) != urb_priv->last_sb) {
+				err("bulk endpoint got disabled before reaching last sb");
+			}
+
+			/* For bulk IN traffic, there seems to be a race condition between
+			   between the bulk eot and eop interrupts, or rather an uncertainty regarding
+			   the order in which they happen. Normally we expect the eop interrupt from
+			   DMA channel 9 to happen before the eot interrupt.
+
+			   Therefore, we complete the bulk IN urb in the rx interrupt handler instead. */
+
+			if (usb_pipein(urb->pipe)) {
+				dbg_bulk("in urb, continuing");
+				continue;
+			}
+
+			save_flags(flags);
+			cli();
+			*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+			nop();
+			r_usb_ept_data = *R_USB_EPT_DATA;
+			restore_flags(flags);
+
+			if (IO_EXTRACT(R_USB_EPT_DATA, error_code, r_usb_ept_data) ==
+			    IO_STATE_VALUE(R_USB_EPT_DATA, error_code, no_error)) {
+				/* This means that the endpoint has no error, is disabled
+				   and had inserted traffic, i.e. transfer successfully completed. */
+				etrax_usb_complete_bulk_urb(urb, 0);
+			} else {
+				/* Shouldn't happen. We expect errors to be caught by epid attention. */
+				err("Found disabled bulk EP desc, error_code != no_error");
+			}
+		}
+	}
+
+	/* Normally, we should find (at least) one disabled EP descriptor with a valid sub pointer.
+	   However, because of the uncertainty in the deliverance of the eop/eot interrupts, we may
+	   not.  Also, we might find two disabled EPs when handling an eot interrupt, and then find
+	   none the next time. */
+
+	DBFEXIT;
+
+}
+
+void etrax_usb_hc_epid_attn_interrupt(usb_interrupt_registers_t *reg)
+{
+	/* This function handles the epid attention interrupt.  There are a variety of reasons
+	   for this interrupt to happen (Designer's Reference, p. 8 - 22 for the details):
+
+	   invalid ep_id  - Invalid epid in an EP (EP disabled).
+	   stall	  - Not strictly an error condition (EP disabled).
+	   3rd error      - Three successive transaction errors  (EP disabled).
+	   buffer ourun   - Buffer overrun or underrun (EP disabled).
+	   past eof1      - Intr or isoc transaction proceeds past EOF1.
+	   near eof       - Intr or isoc transaction would not fit inside the frame.
+	   zout transfer  - If zout transfer for a bulk endpoint (EP disabled).
+	   setup transfer - If setup transfer for a non-ctrl endpoint (EP disabled). */
+
+	int epid;
+
+
+	DBFENTER;
+
+	assert(reg != NULL);
+
+	/* Note that we loop through all epids. We still want to catch errors for
+	   the invalid one, even though we might handle them differently. */
+	for (epid = 0; epid < NBR_OF_EPIDS; epid++) {
+
+		if (test_bit(epid, (void *)&reg->r_usb_epid_attn)) {
+
+			struct urb *urb;
+			__u32 r_usb_ept_data;
+			unsigned long flags;
+			int error_code;
+
+			save_flags(flags);
+			cli();
+			*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, epid);
+			nop();
+			/* Note that although there are separate R_USB_EPT_DATA and R_USB_EPT_DATA_ISO
+			   registers, they are located at the same address and are of the same size.
+			   In other words, this read should be ok for isoc also. */
+			r_usb_ept_data = *R_USB_EPT_DATA;
+			restore_flags(flags);
+
+			/* First some sanity checks. */
+			if (epid == INVALID_EPID) {
+				/* FIXME: What if it became disabled? Could seriously hurt interrupt
+				   traffic. (Use do_intr_recover.) */
+				warn("Got epid_attn for INVALID_EPID (%d).", epid);
+				err("R_USB_EPT_DATA = 0x%x", r_usb_ept_data);
+				err("R_USB_STATUS = 0x%x", reg->r_usb_status);
+				continue;
+			} else 	if (epid == DUMMY_EPID) {
+				/* We definitely don't care about these ones. Besides, they are
+				   always disabled, so any possible disabling caused by the
+				   epid attention interrupt is irrelevant. */
+				warn("Got epid_attn for DUMMY_EPID (%d).", epid);
+				continue;
+			}
+
+			/* Get the first urb in the urb list for this epid. We blatantly assume
+			   that only the first urb could have caused the epid attention.
+			   (For bulk and ctrl, only one urb is active at any one time. For intr
+			   and isoc we remove them once they are completed.) */
+			urb = urb_list_first(epid);
+
+			if (urb == NULL) {
+				err("Got epid_attn for epid %i with no urb.", epid);
+				err("R_USB_EPT_DATA = 0x%x", r_usb_ept_data);
+				err("R_USB_STATUS = 0x%x", reg->r_usb_status);
+				continue;
+			}
+
+			switch (usb_pipetype(urb->pipe)) {
+			case PIPE_BULK:
+				warn("Got epid attn for bulk endpoint, epid %d", epid);
+				break;
+			case PIPE_CONTROL:
+				warn("Got epid attn for control endpoint, epid %d", epid);
+				break;
+			case PIPE_INTERRUPT:
+				warn("Got epid attn for interrupt endpoint, epid %d", epid);
+				break;
+			case PIPE_ISOCHRONOUS:
+				warn("Got epid attn for isochronous endpoint, epid %d", epid);
+				break;
+			}
+
+			if (usb_pipetype(urb->pipe) != PIPE_ISOCHRONOUS) {
+				if (r_usb_ept_data & IO_MASK(R_USB_EPT_DATA, hold)) {
+					warn("Hold was set for epid %d.", epid);
+					continue;
+				}
+			}
+
+			/* Even though error_code occupies bits 22 - 23 in both R_USB_EPT_DATA and
+			   R_USB_EPT_DATA_ISOC, we separate them here so we don't forget in other places. */
+			if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+				error_code = IO_EXTRACT(R_USB_EPT_DATA_ISO, error_code, r_usb_ept_data);
+			} else {
+				error_code = IO_EXTRACT(R_USB_EPT_DATA, error_code, r_usb_ept_data);
+			}
+
+			/* Using IO_STATE_VALUE on R_USB_EPT_DATA should be ok for isoc also. */
+			if (error_code == IO_STATE_VALUE(R_USB_EPT_DATA, error_code, no_error)) {
+
+				/* Isoc traffic doesn't have error_count_in/error_count_out. */
+				if ((usb_pipetype(urb->pipe) != PIPE_ISOCHRONOUS) &&
+				    (IO_EXTRACT(R_USB_EPT_DATA, error_count_in, r_usb_ept_data) == 3 ||
+				     IO_EXTRACT(R_USB_EPT_DATA, error_count_out, r_usb_ept_data) == 3)) {
+					/* 3rd error. */
+					warn("3rd error for epid %i", epid);
+					etrax_usb_complete_urb(urb, -EPROTO);
+
+				} else if (reg->r_usb_status & IO_MASK(R_USB_STATUS, perror)) {
+
+					warn("Perror for epid %d", epid);
+
+					if (!(r_usb_ept_data & IO_MASK(R_USB_EPT_DATA, valid))) {
+						/* invalid ep_id */
+						panic("Perror because of invalid epid."
+						      " Deconfigured too early?");
+					} else {
+						/* past eof1, near eof, zout transfer, setup transfer */
+
+						/* Dump the urb and the relevant EP descriptor list. */
+
+						__dump_urb(urb);
+						__dump_ept_data(epid);
+						__dump_ep_list(usb_pipetype(urb->pipe));
+
+						panic("Something wrong with DMA descriptor contents."
+						      " Too much traffic inserted?");
+					}
+				} else if (reg->r_usb_status & IO_MASK(R_USB_STATUS, ourun)) {
+					/* buffer ourun */
+					panic("Buffer overrun/underrun for epid %d. DMA too busy?", epid);
+				}
+
+			} else if (error_code == IO_STATE_VALUE(R_USB_EPT_DATA, error_code, stall)) {
+				/* Not really a protocol error, just says that the endpoint gave
+				   a stall response. Note that error_code cannot be stall for isoc. */
+				if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+					panic("Isoc traffic cannot stall");
+				}
+
+				warn("Stall for epid %d", epid);
+				etrax_usb_complete_urb(urb, -EPIPE);
+
+			} else if (error_code == IO_STATE_VALUE(R_USB_EPT_DATA, error_code, bus_error)) {
+				/* Two devices responded to a transaction request. Must be resolved
+				   by software. FIXME: Reset ports? */
+				panic("Bus error for epid %d."
+				      " Two devices responded to transaction request",
+				      epid);
+
+			} else if (error_code == IO_STATE_VALUE(R_USB_EPT_DATA, error_code, buffer_error)) {
+				/* DMA overrun or underrun. */
+				warn("Buffer overrun/underrun for epid %d. DMA too busy?", epid);
+
+				/* It seems that error_code = buffer_error in
+				   R_USB_EPT_DATA/R_USB_EPT_DATA_ISO and ourun = yes in R_USB_STATUS
+				   are the same error. */
+				etrax_usb_complete_urb(urb, -EPROTO);
+			}
+		}
+	}
+
+	DBFEXIT;
+
+}
+
+void etrax_usb_bulk_start_timer_func(unsigned long dummy)
+{
+
+	/* We might enable an EP descriptor behind the current DMA position when it's about
+	   to decide that there are no more bulk traffic and it should stop the bulk channel.
+	   Therefore we periodically check if the bulk channel is stopped and there is an
+	   enabled bulk EP descriptor, in which case we start the bulk channel. */
+	dbg_bulk("bulk_start_timer timed out.");
+
+	if (!(*R_DMA_CH8_SUB0_CMD & IO_MASK(R_DMA_CH8_SUB0_CMD, cmd))) {
+		int epid;
+
+		dbg_bulk("Bulk DMA channel not running.");
+
+		for (epid = 0; epid < NBR_OF_EPIDS; epid++) {
+			if (TxBulkEPList[epid].command & IO_MASK(USB_EP_command, enable)) {
+				dbg_bulk("Found enabled EP for epid %d, starting bulk channel.\n",
+					 epid);
+				*R_DMA_CH8_SUB0_CMD = IO_STATE(R_DMA_CH8_SUB0_CMD, cmd, start);
+
+				/* Restart the bulk eot timer since we just started the bulk channel. */
+				mod_timer(&bulk_eot_timer, jiffies + BULK_EOT_TIMER_INTERVAL);
+
+				/* No need to search any further. */
+				break;
+			}
+		}
+	} else {
+		dbg_bulk("Bulk DMA channel running.");
+	}
+}
+
+void etrax_usb_hc_port_status_interrupt(usb_interrupt_registers_t *reg)
+{
+	etrax_hc_t *hc = reg->hc;
+	__u16 r_usb_rh_port_status_1 = reg->r_usb_rh_port_status_1;
+	__u16 r_usb_rh_port_status_2 = reg->r_usb_rh_port_status_2;
+
+	DBFENTER;
+
+	/* The Etrax RH does not include a wPortChange register, so this has to be handled in software
+	   (by saving the old port status value for comparison when the port status interrupt happens).
+	   See section 11.16.2.6.2 in the USB 1.1 spec for details. */
+
+	dbg_rh("hc->rh.prev_wPortStatus_1 = 0x%x", hc->rh.prev_wPortStatus_1);
+	dbg_rh("hc->rh.prev_wPortStatus_2 = 0x%x", hc->rh.prev_wPortStatus_2);
+	dbg_rh("r_usb_rh_port_status_1 = 0x%x", r_usb_rh_port_status_1);
+	dbg_rh("r_usb_rh_port_status_2 = 0x%x", r_usb_rh_port_status_2);
+
+	/* C_PORT_CONNECTION is set on any transition. */
+	hc->rh.wPortChange_1 |=
+		((r_usb_rh_port_status_1 & (1 << RH_PORT_CONNECTION)) !=
+		 (hc->rh.prev_wPortStatus_1 & (1 << RH_PORT_CONNECTION))) ?
+		(1 << RH_PORT_CONNECTION) : 0;
+
+	hc->rh.wPortChange_2 |=
+		((r_usb_rh_port_status_2 & (1 << RH_PORT_CONNECTION)) !=
+		 (hc->rh.prev_wPortStatus_2 & (1 << RH_PORT_CONNECTION))) ?
+		(1 << RH_PORT_CONNECTION) : 0;
+
+	/* C_PORT_ENABLE is _only_ set on a one to zero transition, i.e. when
+	   the port is disabled, not when it's enabled. */
+	hc->rh.wPortChange_1 |=
+		((hc->rh.prev_wPortStatus_1 & (1 << RH_PORT_ENABLE))
+		 && !(r_usb_rh_port_status_1 & (1 << RH_PORT_ENABLE))) ?
+		(1 << RH_PORT_ENABLE) : 0;
+
+	hc->rh.wPortChange_2 |=
+		((hc->rh.prev_wPortStatus_2 & (1 << RH_PORT_ENABLE))
+		 && !(r_usb_rh_port_status_2 & (1 << RH_PORT_ENABLE))) ?
+		(1 << RH_PORT_ENABLE) : 0;
+
+	/* C_PORT_SUSPEND is set to one when the device has transitioned out
+	   of the suspended state, i.e. when suspend goes from one to zero. */
+	hc->rh.wPortChange_1 |=
+		((hc->rh.prev_wPortStatus_1 & (1 << RH_PORT_SUSPEND))
+		 && !(r_usb_rh_port_status_1 & (1 << RH_PORT_SUSPEND))) ?
+		(1 << RH_PORT_SUSPEND) : 0;
+
+	hc->rh.wPortChange_2 |=
+		((hc->rh.prev_wPortStatus_2 & (1 << RH_PORT_SUSPEND))
+		 && !(r_usb_rh_port_status_2 & (1 << RH_PORT_SUSPEND))) ?
+		(1 << RH_PORT_SUSPEND) : 0;
+
+
+	/* C_PORT_RESET is set when reset processing on this port is complete. */
+	hc->rh.wPortChange_1 |=
+		((hc->rh.prev_wPortStatus_1 & (1 << RH_PORT_RESET))
+		 && !(r_usb_rh_port_status_1 & (1 << RH_PORT_RESET))) ?
+		(1 << RH_PORT_RESET) : 0;
+
+	hc->rh.wPortChange_2 |=
+		((hc->rh.prev_wPortStatus_2 & (1 << RH_PORT_RESET))
+		 && !(r_usb_rh_port_status_2 & (1 << RH_PORT_RESET))) ?
+		(1 << RH_PORT_RESET) : 0;
+
+	/* Save the new values for next port status change. */
+	hc->rh.prev_wPortStatus_1 = r_usb_rh_port_status_1;
+	hc->rh.prev_wPortStatus_2 = r_usb_rh_port_status_2;
+
+	dbg_rh("hc->rh.wPortChange_1 set to 0x%x", hc->rh.wPortChange_1);
+	dbg_rh("hc->rh.wPortChange_2 set to 0x%x", hc->rh.wPortChange_2);
+
+	DBFEXIT;
+
+}
+
+void etrax_usb_hc_ctl_status_interrupt(usb_interrupt_registers_t *reg)
+{
+	DBFENTER;
+
+	/* FIXME: What should we do if we get ourun or perror? Dump the EP and SB
+	   list for the corresponding epid? */
+	if (reg->r_usb_status & IO_MASK(R_USB_STATUS, ourun)) {
+		panic("USB controller got ourun.");
+	}
+	if (reg->r_usb_status & IO_MASK(R_USB_STATUS, perror)) {
+
+		/* Before, etrax_usb_do_intr_recover was called on this epid if it was
+		   an interrupt pipe. I don't see how re-enabling all EP descriptors
+		   will help if there was a programming error. */
+		panic("USB controller got perror.");
+	}
+
+	if (reg->r_usb_status & IO_MASK(R_USB_STATUS, device_mode)) {
+		/* We should never operate in device mode. */
+		panic("USB controller in device mode.");
+	}
+
+	/* These if-statements could probably be nested. */
+	if (reg->r_usb_status & IO_MASK(R_USB_STATUS, host_mode)) {
+		info("USB controller in host mode.");
+	}
+	if (reg->r_usb_status & IO_MASK(R_USB_STATUS, started)) {
+		info("USB controller started.");
+	}
+	if (reg->r_usb_status & IO_MASK(R_USB_STATUS, running)) {
+		info("USB controller running.");
+	}
+
+	DBFEXIT;
+
+}
+
+
+static int etrax_rh_submit_urb(struct urb *urb)
+{
+	struct usb_device *usb_dev = urb->dev;
+	etrax_hc_t *hc = usb_dev->bus->hcpriv;
+	unsigned int pipe = urb->pipe;
+	struct usb_ctrlrequest *cmd = (struct usb_ctrlrequest *) urb->setup_packet;
+	void *data = urb->transfer_buffer;
+	int leni = urb->transfer_buffer_length;
+	int len = 0;
+	int stat = 0;
+
+	__u16 bmRType_bReq;
+	__u16 wValue;
+	__u16 wIndex;
+	__u16 wLength;
+
+	DBFENTER;
+
+	/* FIXME: What is this interrupt urb that is sent to the root hub? */
+	if (usb_pipetype (pipe) == PIPE_INTERRUPT) {
+		dbg_rh("Root-Hub submit IRQ: every %d ms", urb->interval);
+		hc->rh.urb = urb;
+		hc->rh.send = 1;
+		/* FIXME: We could probably remove this line since it's done
+		   in etrax_rh_init_int_timer. (Don't remove it from
+		   etrax_rh_init_int_timer though.) */
+		hc->rh.interval = urb->interval;
+		etrax_rh_init_int_timer(urb);
+		DBFEXIT;
+
+		return 0;
+	}
+
+	bmRType_bReq = cmd->bRequestType | (cmd->bRequest << 8);
+	wValue = le16_to_cpu(cmd->wValue);
+	wIndex = le16_to_cpu(cmd->wIndex);
+	wLength = le16_to_cpu(cmd->wLength);
+
+	dbg_rh("bmRType_bReq : 0x%04x (%d)", bmRType_bReq, bmRType_bReq);
+	dbg_rh("wValue       : 0x%04x (%d)", wValue, wValue);
+	dbg_rh("wIndex       : 0x%04x (%d)", wIndex, wIndex);
+	dbg_rh("wLength      : 0x%04x (%d)", wLength, wLength);
+
+	switch (bmRType_bReq) {
+
+		/* Request Destination:
+		   without flags: Device,
+		   RH_INTERFACE: interface,
+		   RH_ENDPOINT: endpoint,
+		   RH_CLASS means HUB here,
+		   RH_OTHER | RH_CLASS  almost ever means HUB_PORT here
+		 */
+
+	case RH_GET_STATUS:
+		*(__u16 *) data = cpu_to_le16 (1);
+		OK (2);
+
+	case RH_GET_STATUS | RH_INTERFACE:
+		*(__u16 *) data = cpu_to_le16 (0);
+		OK (2);
+
+	case RH_GET_STATUS | RH_ENDPOINT:
+		*(__u16 *) data = cpu_to_le16 (0);
+		OK (2);
+
+	case RH_GET_STATUS | RH_CLASS:
+		*(__u32 *) data = cpu_to_le32 (0);
+		OK (4);		/* hub power ** */
+
+	case RH_GET_STATUS | RH_OTHER | RH_CLASS:
+		if (wIndex == 1) {
+			*((__u16*)data) = cpu_to_le16(hc->rh.prev_wPortStatus_1);
+			*((__u16*)data + 1) = cpu_to_le16(hc->rh.wPortChange_1);
+		} else if (wIndex == 2) {
+			*((__u16*)data) = cpu_to_le16(hc->rh.prev_wPortStatus_2);
+			*((__u16*)data + 1) = cpu_to_le16(hc->rh.wPortChange_2);
+		} else {
+			dbg_rh("RH_GET_STATUS whith invalid wIndex!");
+			OK(0);
+		}
+
+		OK(4);
+
+	case RH_CLEAR_FEATURE | RH_ENDPOINT:
+		switch (wValue) {
+		case (RH_ENDPOINT_STALL):
+			OK (0);
+		}
+		break;
+
+	case RH_CLEAR_FEATURE | RH_CLASS:
+		switch (wValue) {
+		case (RH_C_HUB_OVER_CURRENT):
+			OK (0);	/* hub power over current ** */
+		}
+		break;
+
+	case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
+		switch (wValue) {
+		case (RH_PORT_ENABLE):
+			if (wIndex == 1) {
+
+				dbg_rh("trying to do disable port 1");
+
+				*R_USB_PORT1_DISABLE = IO_STATE(R_USB_PORT1_DISABLE, disable, yes);
+
+				while (hc->rh.prev_wPortStatus_1 &
+				       IO_STATE(R_USB_RH_PORT_STATUS_1, enabled, yes));
+				*R_USB_PORT1_DISABLE = IO_STATE(R_USB_PORT1_DISABLE, disable, no);
+				dbg_rh("Port 1 is disabled");
+
+			} else if (wIndex == 2) {
+
+				dbg_rh("trying to do disable port 2");
+
+				*R_USB_PORT2_DISABLE = IO_STATE(R_USB_PORT2_DISABLE, disable, yes);
+
+				while (hc->rh.prev_wPortStatus_2 &
+				       IO_STATE(R_USB_RH_PORT_STATUS_2, enabled, yes));
+				*R_USB_PORT2_DISABLE = IO_STATE(R_USB_PORT2_DISABLE, disable, no);
+				dbg_rh("Port 2 is disabled");
+
+			} else {
+				dbg_rh("RH_CLEAR_FEATURE->RH_PORT_ENABLE "
+				       "with invalid wIndex == %d!", wIndex);
+			}
+
+			OK (0);
+		case (RH_PORT_SUSPEND):
+			/* Opposite to suspend should be resume, so we'll do a resume. */
+			/* FIXME: USB 1.1, 11.16.2.2 says:
+			   "Clearing the PORT_SUSPEND feature causes a host-initiated resume
+			   on the specified port. If the port is not in the Suspended state,
+			   the hub should treat this request as a functional no-operation."
+			   Shouldn't we check if the port is in a suspended state before
+			   resuming? */
+
+			/* Make sure the controller isn't busy. */
+			while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+			if (wIndex == 1) {
+				*R_USB_COMMAND =
+					IO_STATE(R_USB_COMMAND, port_sel, port1) |
+					IO_STATE(R_USB_COMMAND, port_cmd, resume) |
+					IO_STATE(R_USB_COMMAND, ctrl_cmd, nop);
+			} else if (wIndex == 2) {
+				*R_USB_COMMAND =
+					IO_STATE(R_USB_COMMAND, port_sel, port2) |
+					IO_STATE(R_USB_COMMAND, port_cmd, resume) |
+					IO_STATE(R_USB_COMMAND, ctrl_cmd, nop);
+			} else {
+				dbg_rh("RH_CLEAR_FEATURE->RH_PORT_SUSPEND "
+				       "with invalid wIndex == %d!", wIndex);
+			}
+
+			OK (0);
+		case (RH_PORT_POWER):
+			OK (0);	/* port power ** */
+		case (RH_C_PORT_CONNECTION):
+			if (wIndex == 1) {
+				hc->rh.wPortChange_1 &= ~(1 << RH_PORT_CONNECTION);
+			} else if (wIndex == 2) {
+				hc->rh.wPortChange_2 &= ~(1 << RH_PORT_CONNECTION);
+			} else {
+				dbg_rh("RH_CLEAR_FEATURE->RH_C_PORT_CONNECTION "
+				       "with invalid wIndex == %d!", wIndex);
+			}
+
+			OK (0);
+		case (RH_C_PORT_ENABLE):
+			if (wIndex == 1) {
+				hc->rh.wPortChange_1 &= ~(1 << RH_PORT_ENABLE);
+			} else if (wIndex == 2) {
+				hc->rh.wPortChange_2 &= ~(1 << RH_PORT_ENABLE);
+			} else {
+				dbg_rh("RH_CLEAR_FEATURE->RH_C_PORT_ENABLE "
+				       "with invalid wIndex == %d!", wIndex);
+			}
+			OK (0);
+		case (RH_C_PORT_SUSPEND):
+/*** WR_RH_PORTSTAT(RH_PS_PSSC); */
+			OK (0);
+		case (RH_C_PORT_OVER_CURRENT):
+			OK (0);	/* port power over current ** */
+		case (RH_C_PORT_RESET):
+			if (wIndex == 1) {
+				hc->rh.wPortChange_1 &= ~(1 << RH_PORT_RESET);
+			} else if (wIndex == 2) {
+				hc->rh.wPortChange_2 &= ~(1 << RH_PORT_RESET);
+			} else {
+				dbg_rh("RH_CLEAR_FEATURE->RH_C_PORT_RESET "
+				       "with invalid index == %d!", wIndex);
+			}
+
+			OK (0);
+
+		}
+		break;
+
+	case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
+		switch (wValue) {
+		case (RH_PORT_SUSPEND):
+
+			/* Make sure the controller isn't busy. */
+			while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+			if (wIndex == 1) {
+				*R_USB_COMMAND =
+					IO_STATE(R_USB_COMMAND, port_sel, port1) |
+					IO_STATE(R_USB_COMMAND, port_cmd, suspend) |
+					IO_STATE(R_USB_COMMAND, ctrl_cmd, nop);
+			} else if (wIndex == 2) {
+				*R_USB_COMMAND =
+					IO_STATE(R_USB_COMMAND, port_sel, port2) |
+					IO_STATE(R_USB_COMMAND, port_cmd, suspend) |
+					IO_STATE(R_USB_COMMAND, ctrl_cmd, nop);
+			} else {
+				dbg_rh("RH_SET_FEATURE->RH_PORT_SUSPEND "
+				       "with invalid wIndex == %d!", wIndex);
+			}
+
+			OK (0);
+		case (RH_PORT_RESET):
+			if (wIndex == 1) {
+
+			port_1_reset:
+				dbg_rh("Doing reset of port 1");
+
+				/* Make sure the controller isn't busy. */
+				while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+				*R_USB_COMMAND =
+					IO_STATE(R_USB_COMMAND, port_sel, port1) |
+					IO_STATE(R_USB_COMMAND, port_cmd, reset) |
+					IO_STATE(R_USB_COMMAND, ctrl_cmd, nop);
+
+				/* We must wait at least 10 ms for the device to recover.
+				   15 ms should be enough. */
+				udelay(15000);
+
+				/* Wait for reset bit to go low (should be done by now). */
+				while (hc->rh.prev_wPortStatus_1 &
+				       IO_STATE(R_USB_RH_PORT_STATUS_1, reset, yes));
+
+				/* If the port status is
+				   1) connected and enabled then there is a device and everything is fine
+				   2) neither connected nor enabled then there is no device, also fine
+				   3) connected and not enabled then we try again
+				   (Yes, there are other port status combinations besides these.) */
+
+				if ((hc->rh.prev_wPortStatus_1 &
+				     IO_STATE(R_USB_RH_PORT_STATUS_1, connected, yes)) &&
+				    (hc->rh.prev_wPortStatus_1 &
+				     IO_STATE(R_USB_RH_PORT_STATUS_1, enabled, no))) {
+					dbg_rh("Connected device on port 1, but port not enabled?"
+					       " Trying reset again.");
+					goto port_2_reset;
+				}
+
+				/* Diagnostic printouts. */
+				if ((hc->rh.prev_wPortStatus_1 &
+				     IO_STATE(R_USB_RH_PORT_STATUS_1, connected, no)) &&
+				    (hc->rh.prev_wPortStatus_1 &
+				     IO_STATE(R_USB_RH_PORT_STATUS_1, enabled, no))) {
+					dbg_rh("No connected device on port 1");
+				} else if ((hc->rh.prev_wPortStatus_1 &
+					    IO_STATE(R_USB_RH_PORT_STATUS_1, connected, yes)) &&
+					   (hc->rh.prev_wPortStatus_1 &
+					    IO_STATE(R_USB_RH_PORT_STATUS_1, enabled, yes))) {
+					dbg_rh("Connected device on port 1, port 1 enabled");
+				}
+
+			} else if (wIndex == 2) {
+
+			port_2_reset:
+				dbg_rh("Doing reset of port 2");
+
+				/* Make sure the controller isn't busy. */
+				while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+				/* Issue the reset command. */
+				*R_USB_COMMAND =
+					IO_STATE(R_USB_COMMAND, port_sel, port2) |
+					IO_STATE(R_USB_COMMAND, port_cmd, reset) |
+					IO_STATE(R_USB_COMMAND, ctrl_cmd, nop);
+
+				/* We must wait at least 10 ms for the device to recover.
+				   15 ms should be enough. */
+				udelay(15000);
+
+				/* Wait for reset bit to go low (should be done by now). */
+				while (hc->rh.prev_wPortStatus_2 &
+				       IO_STATE(R_USB_RH_PORT_STATUS_2, reset, yes));
+
+				/* If the port status is
+				   1) connected and enabled then there is a device and everything is fine
+				   2) neither connected nor enabled then there is no device, also fine
+				   3) connected and not enabled then we try again
+				   (Yes, there are other port status combinations besides these.) */
+
+				if ((hc->rh.prev_wPortStatus_2 &
+				     IO_STATE(R_USB_RH_PORT_STATUS_2, connected, yes)) &&
+				    (hc->rh.prev_wPortStatus_2 &
+				     IO_STATE(R_USB_RH_PORT_STATUS_2, enabled, no))) {
+					dbg_rh("Connected device on port 2, but port not enabled?"
+					       " Trying reset again.");
+					goto port_2_reset;
+				}
+
+				/* Diagnostic printouts. */
+				if ((hc->rh.prev_wPortStatus_2 &
+				     IO_STATE(R_USB_RH_PORT_STATUS_2, connected, no)) &&
+				    (hc->rh.prev_wPortStatus_2 &
+				     IO_STATE(R_USB_RH_PORT_STATUS_2, enabled, no))) {
+					dbg_rh("No connected device on port 2");
+				} else if ((hc->rh.prev_wPortStatus_2 &
+					    IO_STATE(R_USB_RH_PORT_STATUS_2, connected, yes)) &&
+					   (hc->rh.prev_wPortStatus_2 &
+					    IO_STATE(R_USB_RH_PORT_STATUS_2, enabled, yes))) {
+					dbg_rh("Connected device on port 2, port 2 enabled");
+				}
+
+			} else {
+				dbg_rh("RH_SET_FEATURE->RH_PORT_RESET with invalid wIndex = %d", wIndex);
+			}
+
+			/* Make sure the controller isn't busy. */
+			while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+			/* If all enabled ports were disabled the host controller goes down into
+			   started mode, so we need to bring it back into the running state.
+			   (This is safe even if it's already in the running state.) */
+			*R_USB_COMMAND =
+				IO_STATE(R_USB_COMMAND, port_sel, nop) |
+				IO_STATE(R_USB_COMMAND, port_cmd, reset) |
+				IO_STATE(R_USB_COMMAND, ctrl_cmd, host_run);
+
+			dbg_rh("...Done");
+			OK(0);
+
+		case (RH_PORT_POWER):
+			OK (0);	/* port power ** */
+		case (RH_PORT_ENABLE):
+			/* There is no port enable command in the host controller, so if the
+			   port is already enabled, we do nothing. If not, we reset the port
+			   (with an ugly goto). */
+
+			if (wIndex == 1) {
+				if (hc->rh.prev_wPortStatus_1 &
+				    IO_STATE(R_USB_RH_PORT_STATUS_1, enabled, no)) {
+					goto port_1_reset;
+				}
+			} else if (wIndex == 2) {
+				if (hc->rh.prev_wPortStatus_2 &
+				    IO_STATE(R_USB_RH_PORT_STATUS_2, enabled, no)) {
+					goto port_2_reset;
+				}
+			} else {
+				dbg_rh("RH_SET_FEATURE->RH_GET_STATUS with invalid wIndex = %d", wIndex);
+			}
+			OK (0);
+		}
+		break;
+
+	case RH_SET_ADDRESS:
+		hc->rh.devnum = wValue;
+		dbg_rh("RH address set to: %d", hc->rh.devnum);
+		OK (0);
+
+	case RH_GET_DESCRIPTOR:
+		switch ((wValue & 0xff00) >> 8) {
+		case (0x01):	/* device descriptor */
+			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_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 */
+			len = usb_root_hub_string (wValue & 0xff,
+						   0xff, "ETRAX 100LX",
+						   data, wLength);
+			if (len > 0) {
+				OK(min(leni, len));
+			} else {
+				stat = -EPIPE;
+			}
+
+		}
+		break;
+
+	case RH_GET_DESCRIPTOR | RH_CLASS:
+		root_hub_hub_des[2] = hc->rh.numports;
+		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);
+
+	case RH_GET_CONFIGURATION:
+		*(__u8 *) data = 0x01;
+		OK (1);
+
+	case RH_SET_CONFIGURATION:
+		OK (0);
+
+	default:
+		stat = -EPIPE;
+	}
+
+	urb->actual_length = len;
+	urb->status = stat;
+	urb->dev = NULL;
+	if (urb->complete) {
+		urb->complete(urb, NULL);
+	}
+	DBFEXIT;
+
+	return 0;
+}
+
+static void
+etrax_usb_bulk_eot_timer_func(unsigned long dummy)
+{
+	/* Because of a race condition in the top half, we might miss a bulk eot.
+	   This timer "simulates" a bulk eot if we don't get one for a while, hopefully
+	   correcting the situation. */
+	dbg_bulk("bulk_eot_timer timed out.");
+	etrax_usb_hc_bulk_eot_interrupt(1);
+}
+
+static void*
+etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size, int mem_flags, dma_addr_t *dma)
+{
+  return kmalloc(size, mem_flags);
+}
+
+static void
+etrax_usb_buffer_free(struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma)
+{
+  kfree(addr);
+}
+
+
+static struct device fake_device;
+
+static int __init etrax_usb_hc_init(void)
+{
+	static etrax_hc_t *hc;
+	struct usb_bus *bus;
+	struct usb_device *usb_rh;
+	int i;
+
+	DBFENTER;
+
+	info("ETRAX 100LX USB-HCD %s (c) 2001-2003 Axis Communications AB\n", usb_hcd_version);
+
+ 	hc = kmalloc(sizeof(etrax_hc_t), GFP_KERNEL);
+	assert(hc != NULL);
+
+	/* We use kmem_cache_* to make sure that all DMA desc. are dword aligned */
+	/* Note that we specify sizeof(USB_EP_Desc_t) as the size, but also allocate
+	   SB descriptors from this cache. This is ok since sizeof(USB_EP_Desc_t) ==
+	   sizeof(USB_SB_Desc_t). */
+
+	usb_desc_cache = kmem_cache_create("usb_desc_cache", sizeof(USB_EP_Desc_t), 0,
+					   SLAB_HWCACHE_ALIGN, 0, 0);
+	assert(usb_desc_cache != NULL);
+
+	top_half_reg_cache = kmem_cache_create("top_half_reg_cache",
+					       sizeof(usb_interrupt_registers_t),
+					       0, SLAB_HWCACHE_ALIGN, 0, 0);
+	assert(top_half_reg_cache != NULL);
+
+	isoc_compl_cache = kmem_cache_create("isoc_compl_cache",
+						sizeof(usb_isoc_complete_data_t),
+						0, SLAB_HWCACHE_ALIGN, 0, 0);
+	assert(isoc_compl_cache != NULL);
+
+	etrax_usb_bus = bus = usb_alloc_bus(&etrax_usb_device_operations);
+	hc->bus = bus;
+	bus->bus_name="ETRAX 100LX";
+	bus->hcpriv = hc;
+
+	/* Initalize RH to the default address.
+	   And make sure that we have no status change indication */
+	hc->rh.numports = 2;  /* The RH has two ports */
+	hc->rh.devnum = 1;
+	hc->rh.wPortChange_1 = 0;
+	hc->rh.wPortChange_2 = 0;
+
+	/* Also initate the previous values to zero */
+	hc->rh.prev_wPortStatus_1 = 0;
+	hc->rh.prev_wPortStatus_2 = 0;
+
+	/* Initialize the intr-traffic flags */
+	/* FIXME: This isn't used. (Besides, the error field isn't initialized.) */
+	hc->intr.sleeping = 0;
+	hc->intr.wq = NULL;
+
+	epid_usage_bitmask = 0;
+	epid_out_traffic = 0;
+
+	/* Mark the invalid epid as being used. */
+	set_bit(INVALID_EPID, (void *)&epid_usage_bitmask);
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, INVALID_EPID);
+	nop();
+	/* The valid bit should still be set ('invalid' is in our world; not the hardware's). */
+	*R_USB_EPT_DATA = (IO_STATE(R_USB_EPT_DATA, valid, yes) |
+			   IO_FIELD(R_USB_EPT_DATA, max_len, 1));
+
+	/* Mark the dummy epid as being used. */
+	set_bit(DUMMY_EPID, (void *)&epid_usage_bitmask);
+	*R_USB_EPT_INDEX = IO_FIELD(R_USB_EPT_INDEX, value, DUMMY_EPID);
+	nop();
+	*R_USB_EPT_DATA = (IO_STATE(R_USB_EPT_DATA, valid, no) |
+			   IO_FIELD(R_USB_EPT_DATA, max_len, 1));
+
+	/* Initialize the urb list by initiating a head for each list. */
+	for (i = 0; i < NBR_OF_EPIDS; i++) {
+		INIT_LIST_HEAD(&urb_list[i]);
+	}
+	spin_lock_init(&urb_list_lock);
+
+	INIT_LIST_HEAD(&urb_unlink_list);
+
+
+	/* Initiate the bulk start timer. */
+	init_timer(&bulk_start_timer);
+	bulk_start_timer.expires = jiffies + BULK_START_TIMER_INTERVAL;
+	bulk_start_timer.function = etrax_usb_bulk_start_timer_func;
+	add_timer(&bulk_start_timer);
+
+
+	/* Initiate the bulk eot timer. */
+	init_timer(&bulk_eot_timer);
+	bulk_eot_timer.expires = jiffies + BULK_EOT_TIMER_INTERVAL;
+	bulk_eot_timer.function = etrax_usb_bulk_eot_timer_func;
+	add_timer(&bulk_eot_timer);
+
+	/* Set up the data structures for USB traffic. Note that this must be done before
+	   any interrupt that relies on sane DMA list occurrs. */
+	init_rx_buffers();
+	init_tx_bulk_ep();
+	init_tx_ctrl_ep();
+	init_tx_intr_ep();
+	init_tx_isoc_ep();
+
+        device_initialize(&fake_device);
+        kobject_set_name(&fake_device.kobj, "etrax_usb");
+        kobject_add(&fake_device.kobj);
+        hc->bus->controller = &fake_device;
+	usb_register_bus(hc->bus);
+
+	*R_IRQ_MASK2_SET =
+		/* Note that these interrupts are not used. */
+		IO_STATE(R_IRQ_MASK2_SET, dma8_sub0_descr, set) |
+		/* Sub channel 1 (ctrl) descr. interrupts are used. */
+		IO_STATE(R_IRQ_MASK2_SET, dma8_sub1_descr, set) |
+		IO_STATE(R_IRQ_MASK2_SET, dma8_sub2_descr, set) |
+		/* Sub channel 3 (isoc) descr. interrupts are used. */
+		IO_STATE(R_IRQ_MASK2_SET, dma8_sub3_descr, set);
+
+	/* Note that the dma9_descr interrupt is not used. */
+	*R_IRQ_MASK2_SET =
+		IO_STATE(R_IRQ_MASK2_SET, dma9_eop, set) |
+		IO_STATE(R_IRQ_MASK2_SET, dma9_descr, set);
+
+	/* FIXME: Enable iso_eof only when isoc traffic is running. */
+	*R_USB_IRQ_MASK_SET =
+		IO_STATE(R_USB_IRQ_MASK_SET, iso_eof, set) |
+		IO_STATE(R_USB_IRQ_MASK_SET, bulk_eot, set) |
+		IO_STATE(R_USB_IRQ_MASK_SET, epid_attn, set) |
+		IO_STATE(R_USB_IRQ_MASK_SET, port_status, set) |
+		IO_STATE(R_USB_IRQ_MASK_SET, ctl_status, set);
+
+
+	if (request_irq(ETRAX_USB_HC_IRQ, etrax_usb_hc_interrupt_top_half, 0,
+			"ETRAX 100LX built-in USB (HC)", hc)) {
+		err("Could not allocate IRQ %d for USB", ETRAX_USB_HC_IRQ);
+		etrax_usb_hc_cleanup();
+		DBFEXIT;
+		return -1;
+	}
+
+	if (request_irq(ETRAX_USB_RX_IRQ, etrax_usb_rx_interrupt, 0,
+			"ETRAX 100LX built-in USB (Rx)", hc)) {
+		err("Could not allocate IRQ %d for USB", ETRAX_USB_RX_IRQ);
+		etrax_usb_hc_cleanup();
+		DBFEXIT;
+		return -1;
+	}
+
+	if (request_irq(ETRAX_USB_TX_IRQ, etrax_usb_tx_interrupt, 0,
+			"ETRAX 100LX built-in USB (Tx)", hc)) {
+		err("Could not allocate IRQ %d for USB", ETRAX_USB_TX_IRQ);
+		etrax_usb_hc_cleanup();
+		DBFEXIT;
+		return -1;
+	}
+
+	/* R_USB_COMMAND:
+	   USB commands in host mode. The fields in this register should all be
+	   written to in one write. Do not read-modify-write one field at a time. A
+	   write to this register will trigger events in the USB controller and an
+	   incomplete command may lead to unpredictable results, and in worst case
+	   even to a deadlock in the controller.
+	   (Note however that the busy field is read-only, so no need to write to it.) */
+
+	/* Check the busy bit before writing to R_USB_COMMAND. */
+
+	while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+	/* Reset the USB interface. */
+	*R_USB_COMMAND =
+		IO_STATE(R_USB_COMMAND, port_sel, nop) |
+		IO_STATE(R_USB_COMMAND, port_cmd, reset) |
+		IO_STATE(R_USB_COMMAND, ctrl_cmd, reset);
+
+	/* Designer's Reference, p. 8 - 10 says we should Initate R_USB_FM_PSTART to 0x2A30 (10800),
+	   to guarantee that control traffic gets 10% of the bandwidth, and periodic transfer may
+	   allocate the rest (90%). This doesn't work though. Read on for a lenghty explanation.
+
+	   While there is a difference between rev. 2 and rev. 3 of the ETRAX 100LX regarding the NAK
+	   behaviour, it doesn't solve this problem. What happens is that a control transfer will not
+	   be interrupted in its data stage when PSTART happens (the point at which periodic traffic
+	   is started). Thus, if PSTART is set to 10800 and its IN or OUT token is NAKed until just before
+	   PSTART happens, it will continue the IN/OUT transfer as long as it's ACKed. After it's done,
+	   there may be too little time left for an isochronous transfer, causing an epid attention
+	   interrupt due to perror. The work-around for this is to let the control transfers run at the
+	   end of the frame instead of at the beginning, and will be interrupted just fine if it doesn't
+	   fit into the frame. However, since there will *always* be a control transfer at the beginning
+	   of the frame, regardless of what we set PSTART to, that transfer might be a 64-byte transfer
+	   which consumes up to 15% of the frame, leaving only 85% for periodic traffic. The solution to
+	   this would be to 'dummy allocate' 5% of the frame with the usb_claim_bandwidth function to make
+	   sure that the periodic transfers that are inserted will always fit in the frame.
+
+	   The idea was suggested that a control transfer could be split up into several 8 byte transfers,
+	   so that it would be interrupted by PSTART, but since this can't be done for an IN transfer this
+	   hasn't been implemented.
+
+	   The value 11960 is chosen to be just after the SOF token, with a couple of bit times extra
+	   for possible bit stuffing. */
+
+	*R_USB_FM_PSTART = IO_FIELD(R_USB_FM_PSTART, value, 11960);
+
+#ifdef CONFIG_ETRAX_USB_HOST_PORT1
+	*R_USB_PORT1_DISABLE = IO_STATE(R_USB_PORT1_DISABLE, disable, no);
+#endif
+
+#ifdef CONFIG_ETRAX_USB_HOST_PORT2
+	*R_USB_PORT2_DISABLE = IO_STATE(R_USB_PORT2_DISABLE, disable, no);
+#endif
+
+	while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+	/* Configure the USB interface as a host controller. */
+	*R_USB_COMMAND =
+		IO_STATE(R_USB_COMMAND, port_sel, nop) |
+		IO_STATE(R_USB_COMMAND, port_cmd, reset) |
+		IO_STATE(R_USB_COMMAND, ctrl_cmd, host_config);
+
+	/* Note: Do not reset any ports here. Await the port status interrupts, to have a controlled
+	   sequence of resetting the ports. If we reset both ports now, and there are devices
+	   on both ports, we will get a bus error because both devices will answer the set address
+	   request. */
+
+	while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+	/* Start processing of USB traffic. */
+	*R_USB_COMMAND =
+		IO_STATE(R_USB_COMMAND, port_sel, nop) |
+		IO_STATE(R_USB_COMMAND, port_cmd, reset) |
+		IO_STATE(R_USB_COMMAND, ctrl_cmd, host_run);
+
+	while (*R_USB_COMMAND & IO_MASK(R_USB_COMMAND, busy));
+
+	usb_rh = usb_alloc_dev(NULL, hc->bus, 0);
+	hc->bus->root_hub = usb_rh;
+        usb_rh->state = USB_STATE_ADDRESS;
+        usb_rh->speed = USB_SPEED_FULL;
+        usb_rh->devnum = 1;
+        hc->bus->devnum_next = 2;
+        usb_rh->epmaxpacketin[0] = usb_rh->epmaxpacketout[0] = 64;
+        usb_get_device_descriptor(usb_rh, USB_DT_DEVICE_SIZE);
+	usb_new_device(usb_rh);
+
+	DBFEXIT;
+
+	return 0;
+}
+
+static void etrax_usb_hc_cleanup(void)
+{
+	DBFENTER;
+
+	free_irq(ETRAX_USB_HC_IRQ, NULL);
+	free_irq(ETRAX_USB_RX_IRQ, NULL);
+	free_irq(ETRAX_USB_TX_IRQ, NULL);
+
+	usb_deregister_bus(etrax_usb_bus);
+
+	/* FIXME: call kmem_cache_destroy here? */
+
+	DBFEXIT;
+}
+
+module_init(etrax_usb_hc_init);
+module_exit(etrax_usb_hc_cleanup);
diff -Nru a/drivers/usb/host/hc_crisv10.h b/drivers/usb/host/hc_crisv10.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/host/hc_crisv10.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,289 @@
+#ifndef __LINUX_ETRAX_USB_H
+#define __LINUX_ETRAX_USB_H
+
+#include <linux/types.h>
+#include <linux/list.h>
+
+typedef struct USB_IN_Desc {
+	volatile __u16 sw_len;
+	volatile __u16 command;
+	volatile unsigned long next;
+	volatile unsigned long buf;
+	volatile __u16 hw_len;
+	volatile __u16 status;
+} USB_IN_Desc_t;
+
+typedef struct USB_SB_Desc {
+	volatile __u16 sw_len;
+	volatile __u16 command;
+	volatile unsigned long next;
+	volatile unsigned long buf;
+	__u32 dummy;
+} USB_SB_Desc_t;
+
+typedef struct USB_EP_Desc {
+	volatile __u16 hw_len;
+	volatile __u16 command;
+	volatile unsigned long sub;
+	volatile unsigned long next;
+	__u32 dummy;
+} USB_EP_Desc_t;
+
+struct virt_root_hub {
+	int devnum;
+	void *urb;
+	void *int_addr;
+	int send;
+	int interval;
+	int numports;
+	struct timer_list rh_int_timer;
+	volatile __u16 wPortChange_1;
+	volatile __u16 wPortChange_2;
+	volatile __u16 prev_wPortStatus_1;
+	volatile __u16 prev_wPortStatus_2;
+};
+
+struct etrax_usb_intr_traffic {
+	int sleeping;
+	int error;
+	struct wait_queue *wq;
+};
+
+typedef struct etrax_usb_hc {
+	struct usb_bus *bus;
+	struct virt_root_hub rh;
+	struct etrax_usb_intr_traffic intr;
+} etrax_hc_t;
+
+typedef enum {
+	STARTED,
+	NOT_STARTED,
+	UNLINK,
+	TRANSFER_DONE,
+	WAITING_FOR_DESCR_INTR
+} etrax_usb_urb_state_t;
+
+
+
+typedef struct etrax_usb_urb_priv {
+	/* The first_sb field is used for freeing all SB descriptors belonging
+	   to an urb. The corresponding ep descriptor's sub pointer cannot be
+	   used for this since the DMA advances the sub pointer as it processes
+	   the sb list. */
+	USB_SB_Desc_t *first_sb;
+	/* The last_sb field referes to the last SB descriptor that belongs to
+	   this urb. This is important to know so we can free the SB descriptors
+	   that ranges between first_sb and last_sb. */
+	USB_SB_Desc_t *last_sb;
+
+	/* The rx_offset field is used in ctrl and bulk traffic to keep track
+	   of the offset in the urb's transfer_buffer where incoming data should be
+	   copied to. */
+	__u32 rx_offset;
+
+	/* Counter used in isochronous transfers to keep track of the
+	   number of packets received/transmitted.  */
+	__u32 isoc_packet_counter;
+
+	/* This field is used to pass information about the urb's current state between
+	   the various interrupt handlers (thus marked volatile). */
+	volatile etrax_usb_urb_state_t urb_state;
+
+	/* Connection between the submitted urb and ETRAX epid number */
+	__u8 epid;
+
+	/* The rx_data_list field is used for periodic traffic, to hold
+	   received data for later processing in the the complete_urb functions,
+	   where the data us copied to the urb's transfer_buffer. Basically, we
+	   use this intermediate storage because we don't know when it's safe to
+	   reuse the transfer_buffer (FIXME?). */
+	struct list_head rx_data_list;
+} etrax_urb_priv_t;
+
+/* This struct is for passing data from the top half to the bottom half. */
+typedef struct usb_interrupt_registers
+{
+	etrax_hc_t *hc;
+	__u32 r_usb_epid_attn;
+	__u8 r_usb_status;
+	__u16 r_usb_rh_port_status_1;
+	__u16 r_usb_rh_port_status_2;
+	__u32 r_usb_irq_mask_read;
+	__u32 r_usb_fm_number;
+	struct work_struct usb_bh;
+} usb_interrupt_registers_t;
+
+/* This struct is for passing data from the isoc top half to the isoc bottom half. */
+typedef struct usb_isoc_complete_data
+{
+	struct urb *urb;
+	struct work_struct usb_bh;
+} usb_isoc_complete_data_t;
+
+/* This struct holds data we get from the rx descriptors for DMA channel 9
+   for periodic traffic (intr and isoc). */
+typedef struct rx_data
+{
+	void *data;
+	int length;
+	struct list_head list;
+} rx_data_t;
+
+typedef struct urb_entry
+{
+	struct urb *urb;
+	struct list_head list;
+} urb_entry_t;
+
+/* ---------------------------------------------------------------------------
+   Virtual Root HUB
+   ------------------------------------------------------------------------- */
+/* destination of request */
+#define RH_INTERFACE               0x01
+#define RH_ENDPOINT                0x02
+#define RH_OTHER                   0x03
+
+#define RH_CLASS                   0x20
+#define RH_VENDOR                  0x40
+
+/* Requests: bRequest << 8 | bmRequestType */
+#define RH_GET_STATUS           0x0080
+#define RH_CLEAR_FEATURE        0x0100
+#define RH_SET_FEATURE          0x0300
+#define RH_SET_ADDRESS		0x0500
+#define RH_GET_DESCRIPTOR	0x0680
+#define RH_SET_DESCRIPTOR       0x0700
+#define RH_GET_CONFIGURATION	0x0880
+#define RH_SET_CONFIGURATION	0x0900
+#define RH_GET_STATE            0x0280
+#define RH_GET_INTERFACE        0x0A80
+#define RH_SET_INTERFACE        0x0B00
+#define RH_SYNC_FRAME           0x0C80
+/* Our Vendor Specific Request */
+#define RH_SET_EP               0x2000
+
+
+/* Hub port features */
+#define RH_PORT_CONNECTION         0x00
+#define RH_PORT_ENABLE             0x01
+#define RH_PORT_SUSPEND            0x02
+#define RH_PORT_OVER_CURRENT       0x03
+#define RH_PORT_RESET              0x04
+#define RH_PORT_POWER              0x08
+#define RH_PORT_LOW_SPEED          0x09
+#define RH_C_PORT_CONNECTION       0x10
+#define RH_C_PORT_ENABLE           0x11
+#define RH_C_PORT_SUSPEND          0x12
+#define RH_C_PORT_OVER_CURRENT     0x13
+#define RH_C_PORT_RESET            0x14
+
+/* Hub features */
+#define RH_C_HUB_LOCAL_POWER       0x00
+#define RH_C_HUB_OVER_CURRENT      0x01
+
+#define RH_DEVICE_REMOTE_WAKEUP    0x00
+#define RH_ENDPOINT_STALL          0x01
+
+/* Our Vendor Specific feature */
+#define RH_REMOVE_EP               0x00
+
+
+#define RH_ACK                     0x01
+#define RH_REQ_ERR                 -1
+#define RH_NACK                    0x00
+
+/* Field definitions for */
+
+#define USB_IN_command__eol__BITNR      0 /* command macros */
+#define USB_IN_command__eol__WIDTH      1
+#define USB_IN_command__eol__no         0
+#define USB_IN_command__eol__yes        1
+
+#define USB_IN_command__intr__BITNR     3
+#define USB_IN_command__intr__WIDTH     1
+#define USB_IN_command__intr__no        0
+#define USB_IN_command__intr__yes       1
+
+#define USB_IN_status__eop__BITNR       1 /* status macros. */
+#define USB_IN_status__eop__WIDTH       1
+#define USB_IN_status__eop__no          0
+#define USB_IN_status__eop__yes         1
+
+#define USB_IN_status__eot__BITNR       5
+#define USB_IN_status__eot__WIDTH       1
+#define USB_IN_status__eot__no          0
+#define USB_IN_status__eot__yes         1
+
+#define USB_IN_status__error__BITNR     6
+#define USB_IN_status__error__WIDTH     1
+#define USB_IN_status__error__no        0
+#define USB_IN_status__error__yes       1
+
+#define USB_IN_status__nodata__BITNR    7
+#define USB_IN_status__nodata__WIDTH    1
+#define USB_IN_status__nodata__no       0
+#define USB_IN_status__nodata__yes      1
+
+#define USB_IN_status__epid__BITNR      8
+#define USB_IN_status__epid__WIDTH      5
+
+#define USB_EP_command__eol__BITNR      0
+#define USB_EP_command__eol__WIDTH      1
+#define USB_EP_command__eol__no         0
+#define USB_EP_command__eol__yes        1
+
+#define USB_EP_command__eof__BITNR      1
+#define USB_EP_command__eof__WIDTH      1
+#define USB_EP_command__eof__no         0
+#define USB_EP_command__eof__yes        1
+
+#define USB_EP_command__intr__BITNR     3
+#define USB_EP_command__intr__WIDTH     1
+#define USB_EP_command__intr__no        0
+#define USB_EP_command__intr__yes       1
+
+#define USB_EP_command__enable__BITNR   4
+#define USB_EP_command__enable__WIDTH   1
+#define USB_EP_command__enable__no      0
+#define USB_EP_command__enable__yes     1
+
+#define USB_EP_command__hw_valid__BITNR 5
+#define USB_EP_command__hw_valid__WIDTH 1
+#define USB_EP_command__hw_valid__no    0
+#define USB_EP_command__hw_valid__yes   1
+
+#define USB_EP_command__epid__BITNR     8
+#define USB_EP_command__epid__WIDTH     5
+
+#define USB_SB_command__eol__BITNR      0 /* command macros. */
+#define USB_SB_command__eol__WIDTH      1
+#define USB_SB_command__eol__no         0
+#define USB_SB_command__eol__yes        1
+
+#define USB_SB_command__eot__BITNR      1
+#define USB_SB_command__eot__WIDTH      1
+#define USB_SB_command__eot__no         0
+#define USB_SB_command__eot__yes        1
+
+#define USB_SB_command__intr__BITNR     3
+#define USB_SB_command__intr__WIDTH     1
+#define USB_SB_command__intr__no        0
+#define USB_SB_command__intr__yes       1
+
+#define USB_SB_command__tt__BITNR       4
+#define USB_SB_command__tt__WIDTH       2
+#define USB_SB_command__tt__zout        0
+#define USB_SB_command__tt__in          1
+#define USB_SB_command__tt__out         2
+#define USB_SB_command__tt__setup       3
+
+
+#define USB_SB_command__rem__BITNR      8
+#define USB_SB_command__rem__WIDTH      6
+
+#define USB_SB_command__full__BITNR     6
+#define USB_SB_command__full__WIDTH     1
+#define USB_SB_command__full__no        0
+#define USB_SB_command__full__yes       1
+
+#endif
diff -Nru a/drivers/usb/host/hc_simple.c b/drivers/usb/host/hc_simple.c
--- a/drivers/usb/host/hc_simple.c	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1039 +0,0 @@
-/*-------------------------------------------------------------------------*/
-/*-------------------------------------------------------------------------*
- * simple generic USB HCD frontend Version 0.9.5 (10/28/2001)
- * for embedded HCs (SL811HS)
- * 
- * USB URB handling, hci_ hcs_
- * URB queueing, qu_
- * Transfer scheduling, sh_
- * 
- *
- *-------------------------------------------------------------------------*
- * 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
- *
- *-------------------------------------------------------------------------*/
-
-/* main lock for urb access */
-static spinlock_t usb_urb_lock = SPIN_LOCK_UNLOCKED;
-
-/*-------------------------------------------------------------------------*/
-/*-------------------------------------------------------------------------*/
-/* URB HCD API function layer
- * * * */
-
-/***************************************************************************
- * Function Name : hcs_urb_queue
- *
- * This function initializes the urb status and length before queueing the 
- * urb. 
- *
- * Input:  hci = data structure for the host controller
- *         urb = USB request block data structure 
- *
- * Return: 0 
- **************************************************************************/
-static inline int hcs_urb_queue (hci_t * hci, struct urb * urb)
-{
-	int i;
-
-	DBGFUNC ("enter hcs_urb_queue\n");
-	if (usb_pipeisoc (urb->pipe)) {
-		DBGVERBOSE ("hcs_urb_queue: isoc pipe\n");
-		for (i = 0; i < urb->number_of_packets; i++) {
-			urb->iso_frame_desc[i].actual_length = 0;
-			urb->iso_frame_desc[i].status = -EXDEV;
-		}
-
-		/* urb->next hack : 1 .. resub, 0 .. single shot */
-		/* urb->interval = urb->next ? 1 : 0; */
-	}
-
-	urb->status = -EINPROGRESS;
-	urb->actual_length = 0;
-	urb->error_count = 0;
-
-	if (usb_pipecontrol (urb->pipe))
-		hc_flush_data_cache (hci, urb->setup_packet, 8);
-	if (usb_pipeout (urb->pipe))
-		hc_flush_data_cache (hci, urb->transfer_buffer,
-				     urb->transfer_buffer_length);
-
-	qu_queue_urb (hci, urb);
-
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : hcs_return_urb
- *
- * This function the return path of URB back to the USB core. It calls the
- * the urb complete function if exist, and also handles the resubmition of
- * interrupt URBs.
- *
- * Input:  hci = data structure for the host controller
- *         urb = USB request block data structure 
- *         resub_ok = resubmit flag: 1 = submit urb again, 0 = not submit 
- *
- * Return: 0 
- **************************************************************************/
-static int hcs_return_urb (hci_t * hci, struct urb * urb, int resub_ok)
-{
-	struct usb_device *dev = urb->dev;
-	int resubmit = 0;
-
-	DBGFUNC ("enter hcs_return_urb, urb pointer = 0x%x, "
-		 "transferbuffer point = 0x%x, "
-		 " setup packet pointer = 0x%x, context pointer = 0x%x \n",
-		 (__u32 *) urb, (__u32 *) urb->transfer_buffer,
-		 (__u32 *) urb->setup_packet, (__u32 *) urb->context);
-	if (urb_debug)
-		urb_print (urb, "RET", usb_pipeout (urb->pipe));
-
-	resubmit = urb->interval && resub_ok;
-
-	urb->dev = urb->hcpriv = NULL;
-
-	if (urb->complete) {
-		urb->complete (urb, NULL);	/* call complete */
-	}
-
-	if (resubmit) {
-		/* requeue the URB */
-		urb->dev = dev;
-		hcs_urb_queue (hci, urb);
-	} else {
-		usb_put_urb(urb);
-	}
-
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : hci_submit_urb
- *
- * This function is called by the USB core API when an URB is available to
- * process.  This function does the following
- *
- * 1) Check the validity of the URB
- * 2) Parse the device number from the URB
- * 3) Pass the URB to the root hub routine if its intended for the hub, else
- *    queue the urb for the attached device. 
- *
- * Input: urb = USB request block data structure 
- *
- * Return: 0 if success or error code 
- **************************************************************************/
-static int hci_submit_urb (struct urb * urb, int mem_flags)
-{
-	hci_t *hci;
-	unsigned int pipe = urb->pipe;
-	unsigned long flags;
-	int ret;
-
-	DBGFUNC ("enter hci_submit_urb, pipe = 0x%x\n", urb->pipe);
-	if (!urb->dev || !urb->dev->bus || urb->hcpriv)
-		return -EINVAL;
-
-	hci = (hci_t *) urb->dev->bus->hcpriv;
-
-	/* a request to the virtual root hub */
-	if (usb_pipedevice (pipe) == hci->rh.devnum) {
-		if (urb_debug > 1)
-			urb_print (urb, "SUB-RH", usb_pipein (pipe));
-
-		return rh_submit_urb (urb);
-	}
-
-	/* increment urb's reference count, we now control it. */
-	urb = usb_get_urb (urb);
-
-	/* queue the URB to its endpoint-queue */
-	spin_lock_irqsave (&usb_urb_lock, flags);
-	ret = hcs_urb_queue (hci, urb);
-	if (ret != 0) {
-		/* error on return */
-		DBGERR ("hci_submit_urb: return err, ret = 0x%x, urb->status = 0x%x\n",
-			ret, urb->status);
-		usb_put_urb (urb);
-	}
-
-	spin_unlock_irqrestore (&usb_urb_lock, flags);
-
-	return ret;
-
-}
-
-/***************************************************************************
- * Function Name : hci_unlink_urb
- *
- * This function mark the URB to unlink
- *
- * Input: urb = USB request block data structure 
- *
- * Return: 0 if success or error code 
- **************************************************************************/
-static int hci_unlink_urb (struct urb * urb, int status)
-{
-	unsigned long flags;
-	hci_t *hci;
-	DECLARE_WAITQUEUE (wait, current);
-	void *comp = NULL;
-
-	DBGFUNC ("enter hci_unlink_urb\n");
-
-	if (!urb)		/* just to be sure */
-		return -EINVAL;
-
-	if (!urb->dev || !urb->dev->bus)
-		return -ENODEV;
-
-	hci = (hci_t *) urb->dev->bus->hcpriv;
-
-	/* a request to the virtual root hub */
-	if (usb_pipedevice (urb->pipe) == hci->rh.devnum) {
-		return rh_unlink_urb (urb);
-	}
-
-	if (urb_debug)
-		urb_print (urb, "UNLINK", 1);
-
-	spin_lock_irqsave (&usb_urb_lock, flags);
-
-	if (!list_empty (&urb->urb_list) && urb->status == -EINPROGRESS) {
-		/* URB active? */
-
-		/* asynchronous with callback */
-		/* relink the urb to the del list */
-		list_move (&urb->urb_list, &hci->del_list);
-		urb->status = status;
-		spin_unlock_irqrestore (&usb_urb_lock, flags);
-	} else {
-		/* hcd does not own URB but we keep the driver happy anyway */
-		spin_unlock_irqrestore (&usb_urb_lock, flags);
-
-		if (urb->complete) {
-			urb->status = status;
-			urb->actual_length = 0;
-			urb->complete (urb, NULL);
-			if (urb->reject)
-				wake_up (&usb_kill_urb_queue);
-		}
-	}
-
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : hci_alloc_dev
- *
- * This function allocates private data space for the usb device and 
- * initialize the endpoint descriptor heads.
- *
- * Input: usb_dev = pointer to the usb device 
- *
- * Return: 0 if success or error code 
- **************************************************************************/
-static int hci_alloc_dev (struct usb_device *usb_dev)
-{
-	struct hci_device *dev;
-	int i;
-
-	DBGFUNC ("enter hci_alloc_dev\n");
-	dev = kmalloc (sizeof (*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	memset (dev, 0, sizeof (*dev));
-
-	for (i = 0; i < 32; i++) {
-		INIT_LIST_HEAD (&(dev->ed[i].urb_queue));
-		dev->ed[i].pipe_head = NULL;
-	}
-
-	usb_dev->hcpriv = dev;
-
-	DBGVERBOSE ("USB HC dev alloc %d bytes\n", sizeof (*dev));
-
-	return 0;
-
-}
-
-/***************************************************************************
- * Function Name : hci_free_dev
- *
- * This function de-allocates private data space for the usb devic
- *
- * Input: usb_dev = pointer to the usb device 
- *
- * Return: 0  
- **************************************************************************/
-static int hci_free_dev (struct usb_device *usb_dev)
-{
-	DBGFUNC ("enter hci_free_dev\n");
-
-	if (usb_dev->hcpriv)
-		kfree (usb_dev->hcpriv);
-
-	usb_dev->hcpriv = NULL;
-
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : hci_get_current_frame_number
- *
- * This function get the current USB frame number
- *
- * Input: usb_dev = pointer to the usb device 
- *
- * Return: frame number  
- **************************************************************************/
-static int hci_get_current_frame_number (struct usb_device *usb_dev)
-{
-	hci_t *hci = usb_dev->bus->hcpriv;
-	DBGFUNC ("enter hci_get_current_frame_number, frame = 0x%x \r\n",
-		 hci->frame_number);
-
-	return (hci->frame_number);
-}
-
-/***************************************************************************
- * List of all io-functions 
- **************************************************************************/
-
-static struct usb_operations hci_device_operations = {
-	.allocate =		hci_alloc_dev,
-	.deallocate =		hci_free_dev,
-	.get_frame_number =	hci_get_current_frame_number,
-	.submit_urb =		hci_submit_urb,
-	.unlink_urb =		hci_unlink_urb,
-};
-
-/***************************************************************************
- * URB queueing:
- * 
- * For each type of transfer (INTR, BULK, ISO, CTRL) there is a list of 
- * active URBs.
- * (hci->intr_list, hci->bulk_list, hci->iso_list, hci->ctrl_list)
- * For every endpoint the head URB of the queued URBs is linked to one of 
- * those lists.
- * 
- * The rest of the queued URBs of an endpoint are linked into a 
- * private URB list for each endpoint. (hci_dev->ed [endpoint_io].urb_queue)
- * hci_dev->ed [endpoint_io].pipe_head .. points to the head URB which is 
- * in one of the active URB lists.
- * 
- * The index of an endpoint consists of its number and its direction.
- * 
- * The state of an intr and iso URB is 0. 
- * For ctrl URBs the states are US_CTRL_SETUP, US_CTRL_DATA, US_CTRL_ACK
- * Bulk URBs states are US_BULK and US_BULK0 (with 0-len packet)
- * 
- **************************************************************************/
-
-/***************************************************************************
- * Function Name : qu_urb_timeout
- *
- * This function is called when the URB timeout. The function unlinks the 
- * URB. 
- *
- * Input: lurb: URB 
- *
- * Return: none  
- **************************************************************************/
-#ifdef HC_URB_TIMEOUT
-static void qu_urb_timeout (unsigned long lurb)
-{
-	struct urb *urb = (struct urb *) lurb;
-
-	DBGFUNC ("enter qu_urb_timeout\n");
-	hci_unlink_urb (urb);
-}
-#endif
-
-/***************************************************************************
- * Function Name : qu_pipeindex
- *
- * This function gets the index of the pipe.   
- *
- * Input: pipe: the urb pipe 
- *
- * Return: index  
- **************************************************************************/
-static inline int qu_pipeindex (__u32 pipe)
-{
-	DBGFUNC ("enter qu_pipeindex\n");
-	return (usb_pipeendpoint (pipe) << 1) | (usb_pipecontrol (pipe) ? 0 : usb_pipeout (pipe));
-}
-
-/***************************************************************************
- * Function Name : qu_seturbstate
- *
- * This function set the state of the URB.  
- * 
- * control pipe: 3 states -- Setup, data, status
- * interrupt and bulk pipe: 1 state -- data    
- *
- * Input: urb = USB request block data structure 
- *        state = the urb state
- *
- * Return: none  
- **************************************************************************/
-static inline void qu_seturbstate (struct urb * urb, int state)
-{
-	DBGFUNC ("enter qu_seturbstate\n");
-	urb->pipe &= ~0x1f;
-	urb->pipe |= state & 0x1f;
-}
-
-/***************************************************************************
- * Function Name : qu_urbstate
- *
- * This function get the current state of the URB.  
- * 
- * Input: urb = USB request block data structure 
- *
- * Return: none  
- **************************************************************************/
-static inline int qu_urbstate (struct urb * urb)
-{
-
-	DBGFUNC ("enter qu_urbstate\n");
-
-	return urb->pipe & 0x1f;
-}
-
-/***************************************************************************
- * Function Name : qu_queue_active_urb
- *
- * This function adds the urb to the appropriate active urb list and set
- * the urb state.
- * 
- * There are four active lists: isochoronous list, interrupt list, 
- * control list, and bulk list.
- * 
- * Input: hci = data structure for the host controller 
- *        urb = USB request block data structure 
- *        ed = endpoint descriptor
- *
- * Return: none  
- **************************************************************************/
-static inline void qu_queue_active_urb (hci_t * hci, struct urb * urb, epd_t * ed)
-{
-	int urb_state = 0;
-	DBGFUNC ("enter qu_queue_active_urb\n");
-	switch (usb_pipetype (urb->pipe)) {
-	case PIPE_CONTROL:
-		list_add (&urb->urb_list, &hci->ctrl_list);
-		urb_state = US_CTRL_SETUP;
-		break;
-
-	case PIPE_BULK:
-		list_add (&urb->urb_list, &hci->bulk_list);
-		if ((urb->transfer_flags & URB_ZERO_PACKET)
-		    && urb->transfer_buffer_length > 0
-		    &&
-		    ((urb->transfer_buffer_length %
-		      usb_maxpacket (urb->dev, urb->pipe,
-				     usb_pipeout (urb->pipe))) == 0)) {
-			urb_state = US_BULK0;
-		}
-		break;
-
-	case PIPE_INTERRUPT:
-		urb->start_frame = hci->frame_number;
-		list_add (&urb->urb_list, &hci->intr_list);
-		break;
-
-	case PIPE_ISOCHRONOUS:
-		list_add (&urb->urb_list, &hci->iso_list);
-		break;
-	}
-
-#ifdef HC_URB_TIMEOUT
-	if (urb->timeout) {
-		ed->timeout.data = (unsigned long) urb;
-		ed->timeout.expires = urb->timeout + jiffies;
-		ed->timeout.function = qu_urb_timeout;
-		add_timer (&ed->timeout);
-	}
-#endif
-
-	qu_seturbstate (urb, urb_state);
-}
-
-/***************************************************************************
- * Function Name : qu_queue_urb
- *
- * This function adds the urb to the endpoint descriptor list 
- * 
- * Input: hci = data structure for the host controller 
- *        urb = USB request block data structure 
- *
- * Return: none  
- **************************************************************************/
-static int qu_queue_urb (hci_t * hci, struct urb * urb)
-{
-	struct hci_device *hci_dev = usb_to_hci (urb->dev);
-	epd_t *ed = &hci_dev->ed[qu_pipeindex (urb->pipe)];
-
-	DBGFUNC ("Enter qu_queue_urb\n");
-
-	/* for ISOC transfers calculate start frame index */
-
-	if (usb_pipeisoc (urb->pipe) && urb->transfer_flags & URB_ISO_ASAP) {
-		urb->start_frame = ((ed->pipe_head) ? (ed->last_iso + 1) : hci_get_current_frame_number (urb-> dev) + 1) & 0xffff;
-	}
-
-	if (ed->pipe_head) {
-		__list_add (&urb->urb_list, ed->urb_queue.prev,
-			    &(ed->urb_queue));
-	} else {
-		ed->pipe_head = urb;
-		qu_queue_active_urb (hci, urb, ed);
-		if (++hci->active_urbs == 1)
-			hc_start_int (hci);
-	}
-
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : qu_next_urb
- *
- * This function removes the URB from the queue and add the next URB to 
- * active list. 
- * 
- * Input: hci = data structure for the host controller 
- *        urb = USB request block data structure 
- *        resub_ok = resubmit flag
- *
- * Return: pointer to the next urb  
- **************************************************************************/
-static struct urb *qu_next_urb (hci_t * hci, struct urb * urb, int resub_ok)
-{
-	struct hci_device *hci_dev = usb_to_hci (urb->dev);
-	epd_t *ed = &hci_dev->ed[qu_pipeindex (urb->pipe)];
-
-	DBGFUNC ("enter qu_next_urb\n");
-	list_del_init(&urb->urb_list);
-
-	if (ed->pipe_head == urb) {
-#ifdef HC_URB_TIMEOUT
-		if (urb->timeout)
-			del_timer (&ed->timeout);
-#endif
-
-		if (!--hci->active_urbs)
-			hc_stop_int (hci);
-
-		if (!list_empty (&ed->urb_queue)) {
-			urb = list_entry (ed->urb_queue.next, struct urb, urb_list);
-			list_del_init (&urb->urb_list);
-			ed->pipe_head = urb;
-			qu_queue_active_urb (hci, urb, ed);
-		} else {
-			ed->pipe_head = NULL;
-			urb = NULL;
-		}
-	}
-	return urb;
-}
-
-/***************************************************************************
- * Function Name : qu_return_urb
- *
- * This function is part of the return path.   
- * 
- * Input: hci = data structure for the host controller 
- *        urb = USB request block data structure 
- *        resub_ok = resubmit flag
- *
- * Return: pointer to the next urb  
- **************************************************************************/
-static struct urb *qu_return_urb (hci_t * hci, struct urb * urb, int resub_ok)
-{
-	struct urb *next_urb;
-
-	DBGFUNC ("enter qu_return_rub\n");
-	next_urb = qu_next_urb (hci, urb, resub_ok);
-	hcs_return_urb (hci, urb, resub_ok);
-	return next_urb;
-}
-
-/***************************************************************************
- * Function Name : sh_scan_iso_urb_list
- *
- * This function goes through the isochronous urb list and schedule the 
- * the transfer.   
- *
- * Note: This function has not tested yet
- * 
- * Input: hci = data structure for the host controller 
- *        list_lh = pointer to the isochronous list 
- *        frame_number = the frame number 
- *
- * Return: 0 = unsuccessful; 1 = successful  
- **************************************************************************/
-static int sh_scan_iso_urb_list (hci_t * hci, struct list_head *list_lh,
-				 int frame_number)
-{
-	struct list_head *lh = list_lh->next;
-	struct urb *urb;
-
-	DBGFUNC ("enter sh_scan_iso_urb_list\n");
-	hci->td_array->len = 0;
-
-	while (lh != list_lh) {
-		urb = list_entry (lh, struct urb, urb_list);
-		lh = lh->next;
-		if (((frame_number - urb->start_frame) & 0x7ff) <
-		    urb->number_of_packets) {
-			if (!sh_add_packet (hci, urb)) {
-				return 0;
-			} else {
-				if (((frame_number -
-				      urb->start_frame) & 0x7ff) > 0x400) {
-					if (qu_urbstate (urb) > 0)
-						urb = qu_return_urb (hci, urb, 1);
-					else
-						urb = qu_next_urb (hci, urb, 1);
-
-					if (lh == list_lh && urb)
-						lh = &urb->urb_list;
-				}
-			}
-		}
-	}
-	return 1;
-}
-
-/***************************************************************************
- * Function Name : sh_scan_urb_list
- *
- * This function goes through the urb list and schedule the 
- * the transaction.   
- * 
- * Input: hci = data structure for the host controller 
- *        list_lh = pointer to the isochronous list 
- *
- * Return: 0 = unsuccessful; 1 = successful  
- **************************************************************************/
-static int sh_scan_urb_list (hci_t * hci, struct list_head *list_lh)
-{
-	struct list_head *lh = NULL;
-	struct urb *urb;
-
-	if (list_lh == NULL) {
-		DBGERR ("sh_scan_urb_list: error, list_lh == NULL\n");
-	}
-
-	DBGFUNC ("enter sh_scan_urb_list: frame# \n");
-
-	list_for_each (lh, list_lh) {
-		urb = list_entry (lh, struct urb, urb_list);
-		if (urb == NULL)
-			return 1;
-		if (!usb_pipeint (urb->pipe)
-		    || (((hci->frame_number - urb->start_frame)
-			 & 0x7ff) >= urb->interval)) {
-			DBGVERBOSE ("sh_scan_urb_list !INT: %d fr_no: %d int: %d pint: %d\n",
-				    urb->start_frame, hci->frame_number, urb->interval,
-				    usb_pipeint (urb->pipe));
-			if (!sh_add_packet (hci, urb)) {
-				return 0;
-			} else {
-				DBGVERBOSE ("INT: start: %d fr_no: %d int: %d pint: %d\n",
-					    urb->start_frame, hci->frame_number,
-					    urb->interval, usb_pipeint (urb->pipe));
-				urb->start_frame = hci->frame_number;
-				return 0;
-
-			}
-		}
-	}
-	return 1;
-}
-
-/***************************************************************************
- * Function Name : sh_shedule_trans
- *
- * This function schedule the USB transaction.
- * This function will process the endpoint in the following order: 
- * interrupt, control, and bulk.    
- * 
- * Input: hci = data structure for the host controller 
- *        isSOF = flag indicate if Start Of Frame has occurred 
- *
- * Return: 0   
- **************************************************************************/
-static int sh_schedule_trans (hci_t * hci, int isSOF)
-{
-	int units_left = 1;
-	struct list_head *lh;
-
-	if (hci == NULL) {
-		DBGERR ("sh_schedule_trans: hci == NULL\n");
-		return 0;
-	}
-	if (hci->td_array == NULL) {
-		DBGERR ("sh_schedule_trans: hci->td_array == NULL\n");
-		return 0;
-	}
-
-	if (hci->td_array->len != 0) {
-		DBGERR ("ERROR: schedule, hci->td_array->len = 0x%x, s/b: 0\n",
-			hci->td_array->len);
-	}
-
-	/* schedule the next available interrupt transfer or the next
-	 * stage of the interrupt transfer */
-
-	if (hci->td_array->len == 0 && !list_empty (&hci->intr_list)) {
-		units_left = sh_scan_urb_list (hci, &hci->intr_list);
-	}
-
-	/* schedule the next available control transfer or the next
-	 * stage of the control transfer */
-
-	if (hci->td_array->len == 0 && !list_empty (&hci->ctrl_list) && units_left > 0) {
-		units_left = sh_scan_urb_list (hci, &hci->ctrl_list);
-	}
-
-	/* schedule the next available bulk transfer or the next
-	 * stage of the bulk transfer */
-
-	if (hci->td_array->len == 0 && !list_empty (&hci->bulk_list) && units_left > 0) {
-		sh_scan_urb_list (hci, &hci->bulk_list);
-
-		/* be fair to each BULK URB (move list head around) 
-		 * only when the new SOF happens */
-
-		lh = hci->bulk_list.next;
-		list_move (&hci->bulk_list, lh);
-	}
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : sh_add_packet
- *
- * This function forms the packet and transmit the packet. This function
- * will handle all endpoint type: isochoronus, interrupt, control, and 
- * bulk.
- * 
- * Input: hci = data structure for the host controller 
- *        urb = USB request block data structure 
- *
- * Return: 0 = unsucessful; 1 = successful   
- **************************************************************************/
-static int sh_add_packet (hci_t * hci, struct urb * urb)
-{
-	__u8 *data = NULL;
-	int len = 0;
-	int toggle = 0;
-	int maxps = usb_maxpacket (urb->dev, urb->pipe, usb_pipeout (urb->pipe));
-	int endpoint = usb_pipeendpoint (urb->pipe);
-	int address = usb_pipedevice (urb->pipe);
-	int slow = (((urb->pipe) >> 26) & 1);
-	int out = usb_pipeout (urb->pipe);
-	int pid = 0;
-	int ret;
-	int i = 0;
-	int iso = 0;
-
-	DBGFUNC ("enter sh_add_packet\n");
-	if (maxps == 0)
-		maxps = 8;
-
-	/* calculate len, toggle bit and add the transaction */
-	switch (usb_pipetype (urb->pipe)) {
-	case PIPE_ISOCHRONOUS:
-		pid = out ? PID_OUT : PID_IN;
-		iso = 1;
-		i = hci->frame_number - urb->start_frame;
-		data = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
-		len = urb->iso_frame_desc[i].length;
-		break;
-
-	case PIPE_BULK:	/* BULK and BULK0 */
-	case PIPE_INTERRUPT:
-		pid = out ? PID_OUT : PID_IN;
-		len = urb->transfer_buffer_length - urb->actual_length;
-		data = urb->transfer_buffer + urb->actual_length;
-		toggle = usb_gettoggle (urb->dev, endpoint, out);
-		break;
-
-	case PIPE_CONTROL:
-		switch (qu_urbstate (urb)) {
-		case US_CTRL_SETUP:
-			len = 8;
-			pid = PID_SETUP;
-			data = urb->setup_packet;
-			toggle = 0;
-			break;
-
-		case US_CTRL_DATA:
-			if (!hci->last_packet_nak) {
-				/* The last packet received is not a nak:
-				 * reset the nak count
-				 */
-
-				hci->nakCnt = 0;
-			}
-			if (urb->transfer_buffer_length != 0) {
-				pid = out ? PID_OUT : PID_IN;
-				len = urb->transfer_buffer_length - urb->actual_length;
-				data = urb->transfer_buffer + urb->actual_length;
-				toggle = (urb->actual_length & maxps) ? 0 : 1;
-				usb_settoggle (urb->dev,
-					       usb_pipeendpoint (urb->pipe),
-					       usb_pipeout (urb->pipe), toggle);
-				break;
-			} else {
-				/* correct state and fall through */
-				qu_seturbstate (urb, US_CTRL_ACK);
-			}
-
-		case US_CTRL_ACK:
-			len = 0;
-
-			/* reply in opposite direction */
-			pid = !out ? PID_OUT : PID_IN;
-			toggle = 1;
-			usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe),
-				       usb_pipeout (urb->pipe), toggle);
-			break;
-		}
-	}
-
-	ret =
-	    hc_add_trans (hci, len, data, toggle, maxps, slow, endpoint,
-			  address, pid, iso, qu_urbstate (urb));
-
-	DBGVERBOSE ("transfer_pa: addr:%d ep:%d pid:%x tog:%x iso:%x sl:%x "
-		    "max:%d\n len:%d ret:%d data:%p left:%d\n",
-		    address, endpoint, pid, toggle, iso, slow,
-		    maxps, len, ret, data, hci->hp.units_left);
-
-	if (ret >= 0) {
-		hci->td_array->td[hci->td_array->len].urb = urb;
-		hci->td_array->td[hci->td_array->len].len = ret;
-		hci->td_array->td[hci->td_array->len].iso_index = i;
-		hci->td_array->len++;
-		hci->active_trans = 1;
-		return 1;
-	}
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : cc_to_error
- *
- * This function maps the SL811HS hardware error code to the linux USB error
- * code.
- * 
- * Input: cc = hardware error code 
- *
- * Return: USB error code   
- **************************************************************************/
-static int cc_to_error (int cc)
-{
-	int errCode = 0;
-	if (cc & SL11H_STATMASK_ERROR) {
-		errCode |= -EILSEQ;
-	} else if (cc & SL11H_STATMASK_OVF) {
-		errCode |= -EOVERFLOW;
-	} else if (cc & SL11H_STATMASK_STALL) {
-		errCode |= -EPIPE;
-	}
-	return errCode;
-}
-
-/***************************************************************************
- * Function Name : sh_done_list
- *
- * This function process the packet when it has done finish transfer.
- * 
- * 1) It handles hardware error
- * 2) It updates the URB state
- * 3) If the USB transaction is complete, it start the return stack path.
- * 
- * Input: hci = data structure for the host controller 
- *        isExcessNak = flag tells if there excess NAK condition occurred 
- *
- * Return:  urb_state or -1 if the transaction has complete   
- **************************************************************************/
-static int sh_done_list (hci_t * hci, int *isExcessNak)
-{
-	int actbytes = 0;
-	int active = 0;
-	void *data = NULL;
-	int cc;
-	int maxps;
-	int toggle;
-	struct urb *urb;
-	int urb_state = 0;
-	int ret = 1;		/* -1 parse abbort, 1 parse ok, 0 last element */
-	int trans = 0;
-	int len;
-	int iso_index = 0;
-	int out;
-	int pid = 0;
-	int debugLen = 0;
-
-	*isExcessNak = 0;
-
-	DBGFUNC ("enter sh_done_list: td_array->len = 0x%x\n",
-		 hci->td_array->len);
-
-	debugLen = hci->td_array->len;
-	if (debugLen > 1)
-		DBGERR ("sh_done_list: td_array->len = 0x%x > 1\n",
-			hci->td_array->len);
-
-	for (trans = 0; ret && trans < hci->td_array->len && trans < MAX_TRANS;
-	     trans++) {
-		urb = hci->td_array->td[trans].urb;
-		len = hci->td_array->td[trans].len;
-		out = usb_pipeout (urb->pipe);
-
-		if (usb_pipeisoc (urb->pipe)) {
-			iso_index = hci->td_array->td[trans].iso_index;
-			data = urb->transfer_buffer + urb->iso_frame_desc[iso_index].offset;
-			toggle = 0;
-		} else {
-			data = urb->transfer_buffer + urb->actual_length;
-			toggle = usb_gettoggle (urb->dev,
-						usb_pipeendpoint (urb->pipe),
-						usb_pipeout (urb->pipe));
-
-		}
-		urb_state = qu_urbstate (urb);
-		pid = out ? PID_OUT : PID_IN;
-		ret = hc_parse_trans (hci, &actbytes, data, &cc, &toggle, len,
-				      pid, urb_state);
-		maxps = usb_maxpacket (urb->dev, urb->pipe, usb_pipeout (urb->pipe));
-
-		if (maxps == 0)
-			maxps = 8;
-
-		active = (urb_state != US_CTRL_SETUP) && (actbytes && !(actbytes & (maxps - 1)));
-
-		/* If the transfer is not bulk in, then it is necessary to get all
-		 * data specify by the urb->transfer_len.
-		 */
-
-		if (!(usb_pipebulk (urb->pipe) && usb_pipein (urb->pipe)))
-			active = active && (urb->transfer_buffer_length != urb->actual_length + actbytes);
-
-		if (urb->transfer_buffer_length == urb->actual_length + actbytes)
-			active = 0;
-
-		if ((cc &
-		     (SL11H_STATMASK_ERROR | SL11H_STATMASK_TMOUT |
-		      SL11H_STATMASK_OVF | SL11H_STATMASK_STALL))
-		    && !(cc & SL11H_STATMASK_NAK)) {
-			if (++urb->error_count > 3) {
-				DBGERR ("done_list: excessive error: errcount = 0x%x, cc = 0x%x\n",
-					urb->error_count, cc);
-				urb_state = 0;
-				active = 0;
-			} else {
-				DBGERR ("done_list: packet err, cc = 0x%x, "
-					" urb->length = 0x%x, actual_len = 0x%x,"
-					" urb_state =0x%x\n",
-					cc, urb->transfer_buffer_length,
-					urb->actual_length, urb_state);
-//			if (cc & SL11H_STATMASK_STALL) {
-				/* The USB function is STALLED on a control pipe (0), 
-				 * then it needs to send the SETUP command again to 
-				 * clear the STALL condition
-				 */
-
-//				if (usb_pipeendpoint (urb->pipe) == 0) {
-//					urb_state = 2;  
-//					active = 0;
-//				}
-//			} else   
-				active = 1;
-			}
-		} else {
-			if (cc & SL11H_STATMASK_NAK) {
-				if (hci->nakCnt < 0x10000) {
-					hci->nakCnt++;
-					hci->last_packet_nak = 1;
-					active = 1;
-					*isExcessNak = 0;
-				} else {
-					DBGERR ("done_list: nak count exceed limit\n");
-					active = 0;
-					*isExcessNak = 1;
-					hci->nakCnt = 0;
-				}
-			} else {
-				hci->nakCnt = 0;
-				hci->last_packet_nak = 0;
-			}
-
-			if (urb_state != US_CTRL_SETUP) {
-				/* no error */
-				urb->actual_length += actbytes;
-				usb_settoggle (urb->dev,
-					       usb_pipeendpoint (urb->pipe),
-					       usb_pipeout (urb->pipe), toggle);
-			}
-			if (usb_pipeisoc (urb->pipe)) {
-				urb->iso_frame_desc[iso_index].actual_length = actbytes;
-				urb->iso_frame_desc[iso_index].status = cc_to_error (cc);
-				active = (iso_index < urb->number_of_packets);
-			}
-		}
-		if (!active) {
-			if (!urb_state) {
-				urb->status = cc_to_error (cc);
-				if (urb->status) {
-					DBGERR ("error on received packet: urb->status = 0x%x\n",
-						urb->status);
-				}
-				hci->td_array->len = 0;
-				qu_return_urb (hci, urb, 1);
-				return -1;
-			} else {
-				/* We do not want to decrement the urb_state if exceeded nak,
-				 * because we need to finish the data stage of the control 
-				 * packet 
-				 */
-
-				if (!(*isExcessNak))
-					urb_state--;
-				qu_seturbstate (urb, urb_state);
-			}
-		}
-	}
-
-	if (urb_state < 0)
-		DBGERR ("ERROR: done_list, urb_state = %d, suppose > 0\n",
-			urb_state);
-	if (debugLen != hci->td_array->len) {
-		DBGERR ("ERROR: done_list, debugLen!= td_array->len,"
-			"debugLen = 0x%x, hci->td_array->len = 0x%x\n",
-			debugLen, hci->td_array->len);
-	}
-
-	hci->td_array->len = 0;
-
-	return urb_state;
-}
diff -Nru a/drivers/usb/host/hc_simple.h b/drivers/usb/host/hc_simple.h
--- a/drivers/usb/host/hc_simple.h	2004-12-24 13:37:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,231 +0,0 @@
-/*-------------------------------------------------------------------------*/
-/* list of all controllers using this driver 
- * */
-
-static LIST_HEAD (hci_hcd_list);
-
-/* URB states (urb_state) */
-/* isoc, interrupt single state */
-
-/* bulk transfer main state and 0-length packet */
-#define US_BULK		0
-#define US_BULK0	1
-/* three setup states */
-#define US_CTRL_SETUP	2
-#define US_CTRL_DATA	1
-#define US_CTRL_ACK	0
-
-/*-------------------------------------------------------------------------*/
-/* HC private part of a device descriptor
- * */
-
-#define NUM_EDS 32
-
-typedef struct epd {
-	struct urb *pipe_head;
-	struct list_head urb_queue;
-//	int urb_state;
-	struct timer_list timeout;
-	int last_iso;		/* timestamp of last queued ISOC transfer */
-
-} epd_t;
-
-struct hci_device {
-	epd_t ed[NUM_EDS];
-};
-
-/*-------------------------------------------------------------------------*/
-/* Virtual Root HUB 
- */
-
-#define usb_to_hci(usb)	((struct hci_device *)(usb)->hcpriv)
-
-struct virt_root_hub {
-	int devnum;		/* Address of Root Hub endpoint */
-	void *urb;		/* interrupt URB of root hub */
-	int send;		/* active flag */
-	int interval;		/* interval of roothub interrupt transfers */
-	struct timer_list rh_int_timer;	/* interval timer for rh interrupt EP */
-};
-
-#if 1
-/* USB HUB CONSTANTS (not OHCI-specific; see hub.h and USB spec) */
-
-/* destination of request */
-#define RH_INTERFACE		0x01
-#define RH_ENDPOINT		0x02
-#define RH_OTHER		0x03
-
-#define RH_CLASS		0x20
-#define RH_VENDOR		0x40
-
-/* Requests: bRequest << 8 | bmRequestType */
-#define RH_GET_STATUS		0x0080
-#define RH_CLEAR_FEATURE	0x0100
-#define RH_SET_FEATURE		0x0300
-#define RH_SET_ADDRESS		0x0500
-#define RH_GET_DESCRIPTOR	0x0680
-#define RH_SET_DESCRIPTOR	0x0700
-#define RH_GET_CONFIGURATION	0x0880
-#define RH_SET_CONFIGURATION	0x0900
-#define RH_GET_STATE		0x0280
-#define RH_GET_INTERFACE	0x0A80
-#define RH_SET_INTERFACE	0x0B00
-#define RH_SYNC_FRAME		0x0C80
-/* Our Vendor Specific Request */
-#define RH_SET_EP		0x2000
-
-/* Hub port features */
-#define RH_PORT_CONNECTION	0x00
-#define RH_PORT_ENABLE		0x01
-#define RH_PORT_SUSPEND		0x02
-#define RH_PORT_OVER_CURRENT	0x03
-#define RH_PORT_RESET		0x04
-#define RH_PORT_POWER		0x08
-#define RH_PORT_LOW_SPEED	0x09
-
-#define RH_C_PORT_CONNECTION	0x10
-#define RH_C_PORT_ENABLE	0x11
-#define RH_C_PORT_SUSPEND	0x12
-#define RH_C_PORT_OVER_CURRENT	0x13
-#define RH_C_PORT_RESET		0x14
-
-/* Hub features */
-#define RH_C_HUB_LOCAL_POWER	0x00
-#define RH_C_HUB_OVER_CURRENT	0x01
-
-#define RH_DEVICE_REMOTE_WAKEUP	0x00
-#define RH_ENDPOINT_STALL	0x01
-
-#endif
-
-/*-------------------------------------------------------------------------*/
-/* struct for each HC 
- */
-
-#define MAX_TRANS	32
-
-typedef struct td {
-	struct urb *urb;
-	__u16 len;
-	__u16 iso_index;
-} td_t;
-
-typedef struct td_array {
-	int len;
-	td_t td[MAX_TRANS];
-} td_array_t;
-
-typedef struct hci {
-	struct virt_root_hub rh;	/* roothub */
-	wait_queue_head_t waitq;	/* deletion of URBs and devices needs a waitqueue */
-	int active;			/* HC is operating */
-
-	struct list_head ctrl_list;	/* set of ctrl endpoints */
-	struct list_head bulk_list;	/* set of bulk endpoints */
-	struct list_head iso_list;	/* set of isoc endpoints */
-	struct list_head intr_list;	/* ordered (tree) set of int endpoints */
-	struct list_head del_list;	/* set of entpoints to be deleted */
-
-	td_array_t *td_array;
-	td_array_t a_td_array;
-	td_array_t i_td_array[2];
-
-	struct list_head hci_hcd_list;	/* list of all hci_hcd */
-	struct usb_bus *bus;		/* our bus */
-
-//	int trans;			/* number of transactions pending */
-	int active_urbs;
-	int active_trans;
-	int frame_number;		/* frame number */
-	hcipriv_t hp;			/* individual part of hc type */
-	int nakCnt;
-	int last_packet_nak;
-
-} hci_t;
-
-/*-------------------------------------------------------------------------*/
-/* condition (error) CC codes and mapping OHCI like
- */
-
-#define TD_CC_NOERROR		0x00
-#define TD_CC_CRC		0x01
-#define TD_CC_BITSTUFFING	0x02
-#define TD_CC_DATATOGGLEM	0x03
-#define TD_CC_STALL		0x04
-#define TD_DEVNOTRESP		0x05
-#define TD_PIDCHECKFAIL		0x06
-#define TD_UNEXPECTEDPID	0x07
-#define TD_DATAOVERRUN		0x08
-#define TD_DATAUNDERRUN		0x09
-#define TD_BUFFEROVERRUN	0x0C
-#define TD_BUFFERUNDERRUN	0x0D
-#define TD_NOTACCESSED		0x0F
-
-
-/* urb interface functions */
-static int hci_get_current_frame_number (struct usb_device *usb_dev);
-static int hci_unlink_urb (struct urb * urb);
-
-static int qu_queue_urb (hci_t * hci, struct urb * urb);
-
-/* root hub */
-static int rh_init_int_timer (struct urb * urb);
-static int rh_submit_urb (struct urb * urb);
-static int rh_unlink_urb (struct urb * urb);
-
-/* schedule functions */
-static int sh_add_packet (hci_t * hci, struct urb * urb);
-
-/* hc specific functions */
-static inline void hc_flush_data_cache (hci_t * hci, void *data, int len);
-static inline int hc_parse_trans (hci_t * hci, int *actbytes, __u8 * data,
-				  int *cc, int *toggle, int length, int pid,
-				  int urb_state);
-static inline int hc_add_trans (hci_t * hci, int len, void *data, int toggle,
-				int maxps, int slow, int endpoint, int address,
-				int pid, int format, int urb_state);
-
-static void hc_start_int (hci_t * hci);
-static void hc_stop_int (hci_t * hci);
-static void SL811Write (hci_t * hci, char offset, char data);
-
-/* debug| print the main components of an URB     
- * small: 0) header + data packets 1) just header */
-
-static void urb_print (struct urb * urb, char *str, int small)
-{
-	unsigned int pipe = urb->pipe;
-	int i, len;
-
-	if (!urb->dev || !urb->dev->bus) {
-		dbg ("%s URB: no dev", str);
-		return;
-	}
-
-	printk ("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,flags:%4x,len:%d/%d,stat:%d(%x)\n",
-		str, hci_get_current_frame_number (urb->dev),
-		usb_pipedevice (pipe), usb_pipeendpoint (pipe),
-		usb_pipeout (pipe) ? 'O' : 'I',
-		usb_pipetype (pipe) < 2 ? (usb_pipeint (pipe) ? "INTR" : "ISOC")
-		: (usb_pipecontrol (pipe) ? "CTRL" : "BULK"), urb->transfer_flags,
-		urb->actual_length, urb->transfer_buffer_length, urb->status,
-		urb->status);
-	if (!small) {
-		if (usb_pipecontrol (pipe)) {
-			printk (__FILE__ ": cmd(8):");
-			for (i = 0; i < 8; i++)
-				printk (" %02x", ((__u8 *) urb->setup_packet)[i]);
-			printk ("\n");
-		}
-		if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) {
-			printk (__FILE__ ": data(%d/%d):", urb->actual_length,
-				urb->transfer_buffer_length);
-			len = usb_pipeout (pipe) ? urb-> transfer_buffer_length : urb->actual_length;
-			for (i = 0; i < 2096 && i < len; i++)
-				printk (" %02x", ((__u8 *) urb->transfer_buffer)[i]);
-			printk ("%s stat:%d\n", i < len ? "..." : "",
-				urb->status);
-		}
-	}
-}
diff -Nru a/drivers/usb/host/hc_sl811.c b/drivers/usb/host/hc_sl811.c
--- a/drivers/usb/host/hc_sl811.c	2004-12-24 13:37:04 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1361 +0,0 @@
-/*-------------------------------------------------------------------------*/
-/*-------------------------------------------------------------------------*
- * SL811HS USB HCD for Linux Version 0.1 (10/28/2001)
- * 
- * requires (includes) hc_simple.[hc] simple generic HCD frontend
- *  
- * COPYRIGHT(C) 2001 by CYPRESS SEMICONDUCTOR 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *-------------------------------------------------------------------------*/
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/smp_lock.h>
-#include <linux/list.h>
-#include <linux/ioport.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#include <linux/usb.h>
-#include "../core/hcd.h"
-
-#undef HC_URB_TIMEOUT
-#undef HC_SWITCH_INT
-#undef HC_ENABLE_ISOC
-
-#define SL811_DEBUG_ERR
-
-#ifdef SL811_DEBUG_ERR
-#define DBGERR(fmt, args...) printk(fmt,## args)
-#else
-#define DBGERR(fmt, args...)
-#endif
-
-#ifdef SL811_DEBUG
-#define DBG(fmt, args...) printk(fmt,## args)
-#else
-#define DBG(fmt, args...)
-#endif
-
-#ifdef SL811_DEBUG_FUNC
-#define DBGFUNC(fmt, args...) printk(fmt,## args)
-#else
-#define DBGFUNC(fmt, args...)
-#endif
-
-#ifdef SL811_DEBUG_DATA
-#define DBGDATAR(fmt, args...) printk(fmt,## args)
-#define DBGDATAW(fmt, args...) printk(fmt,## args)
-#else
-#define DBGDATAR(fmt, args...)
-#define DBGDATAW(fmt, args...)
-#endif
-
-#ifdef SL811_DEBUG_VERBOSE
-#define DBGVERBOSE(fmt, args...) printk(fmt,## args)
-#else
-#define DBGVERBOSE(fmt, args...)
-#endif
-
-#define TRUE 1
-#define FALSE 0
-
-#define HC_SWITCH_INT
-#include "hc_sl811.h"
-#include "hc_simple.h"
-
-static int urb_debug = 0;
-
-#include "hc_simple.c"
-#include "hc_sl811_rh.c"
-
-/* The base_addr, data_reg_addr, and irq number are board specific.
- * The current values are design to run on the Accelent SA1110 IDP
- * NOTE: values need to modify for different development boards 
- */
-
-static int base_addr = 0xd3800000;
-static int data_reg_addr = 0xd3810000;
-static int irq = 34;
-
-/* forware declaration */
-
-int SL11StartXaction (hci_t * hci, __u8 addr, __u8 epaddr, int pid, int len,
-		      int toggle, int slow, int urb_state);
-
-static int sofWaitCnt = 0;
-
-module_param(urb_debug, int, 0);
-MODULE_PARM_DESC (urb_debug, "debug urb messages, default is 0 (no)");
-
-module_param(base_addr, int, 0);
-MODULE_PARM_DESC (base_addr, "sl811 base address 0xd3800000");
-module_param(data_reg_addr, int, 0);
-MODULE_PARM_DESC (data_reg_addr, "sl811 data register address 0xd3810000");
-module_param(irq, int, 0);
-MODULE_PARM_DESC (irq, "IRQ 34 (default)");
-
-static int hc_reset (hci_t * hci);
-
-/***************************************************************************
- * Function Name : SL811Read
- *
- * Read a byte of data from the SL811H/SL11H
- *
- * Input:  hci = data structure for the host controller
- *         offset = address of SL811/SL11H register or memory
- *
- * Return: data 
- **************************************************************************/
-char SL811Read (hci_t * hci, char offset)
-{
-	hcipriv_t *hp = &hci->hp;
-	char data;
-	writeb (offset, hp->hcport);
-	wmb ();
-	data = readb (hp->hcport2);
-	rmb ();
-	return (data);
-}
-
-/***************************************************************************
- * Function Name : SL811Write
- *
- * Write a byte of data to the SL811H/SL11H
- *
- * Input:  hci = data structure for the host controller
- *         offset = address of SL811/SL11H register or memory
- *         data  = the data going to write to SL811H
- *
- * Return: none 
- **************************************************************************/
-void SL811Write (hci_t * hci, char offset, char data)
-{
-	hcipriv_t *hp = &hci->hp;
-	writeb (offset, hp->hcport);
-	writeb (data, hp->hcport2);
-	wmb ();
-}
-
-/***************************************************************************
- * Function Name : SL811BufRead
- *
- * Read consecutive bytes of data from the SL811H/SL11H buffer
- *
- * Input:  hci = data structure for the host controller
- *         offset = SL811/SL11H register offset
- *         buf = the buffer where the data will store
- *         size = number of bytes to read
- *
- * Return: none 
- **************************************************************************/
-void SL811BufRead (hci_t * hci, short offset, char *buf, short size)
-{
-	hcipriv_t *hp = &hci->hp;
-	if (size <= 0)
-		return;
-	writeb ((char) offset, hp->hcport);
-	wmb ();
-	DBGDATAR ("SL811BufRead: offset = 0x%x, data = ", offset);
-	while (size--) {
-		*buf++ = (char) readb (hp->hcport2);
-		DBGDATAR ("0x%x ", *(buf - 1));
-		rmb ();
-	}
-	DBGDATAR ("\n");
-}
-
-/***************************************************************************
- * Function Name : SL811BufWrite
- *
- * Write consecutive bytes of data to the SL811H/SL11H buffer
- *
- * Input:  hci = data structure for the host controller
- *         offset = SL811/SL11H register offset
- *         buf = the data buffer 
- *         size = number of bytes to write
- *
- * Return: none 
- **************************************************************************/
-void SL811BufWrite (hci_t * hci, short offset, char *buf, short size)
-{
-	hcipriv_t *hp = &hci->hp;
-	if (size <= 0)
-		return;
-	writeb ((char) offset, hp->hcport);
-	wmb ();
-	DBGDATAW ("SL811BufWrite: offset = 0x%x, data = ", offset);
-	while (size--) {
-		DBGDATAW ("0x%x ", *buf);
-		writeb (*buf, hp->hcport2);
-		wmb ();
-		buf++;
-	}
-	DBGDATAW ("\n");
-}
-
-/***************************************************************************
- * Function Name : regTest
- *
- * This routine test the Read/Write functionality of SL811HS registers  
- *
- * 1) Store original register value into a buffer
- * 2) Write to registers with a RAMP pattern. (10, 11, 12, ..., 255)
- * 3) Read from register
- * 4) Compare the written value with the read value and make sure they are 
- *    equivalent
- * 5) Restore the original register value 
- *
- * Input:  hci = data structure for the host controller
- *   
- *
- * Return: TRUE = passed; FALSE = failed 
- **************************************************************************/
-int regTest (hci_t * hci)
-{
-	int i, data, result = TRUE;
-	char buf[256];
-
-	DBGFUNC ("Enter regTest\n");
-	for (i = 0x10; i < 256; i++) {
-		/* save the original buffer */
-		buf[i] = (char) SL811Read (hci, i);
-
-		/* Write the new data to the buffer */
-		SL811Write (hci, i, i);
-	}
-
-	/* compare the written data */
-	for (i = 0x10; i < 256; i++) {
-		data = SL811Read (hci, i);
-		if (data != i) {
-			DBGERR ("Pattern test failed!! value = 0x%x, s/b 0x%x\n",
-				data, i);
-			result = FALSE;
-		}
-	}
-
-	/* restore the data */
-	for (i = 0x10; i < 256; i++) {
-		SL811Write (hci, i, buf[i]);
-	}
-
-	return (result);
-}
-
-/***************************************************************************
- * Function Name : regShow
- *
- * Display all SL811HS register values
- *
- * Input:  hci = data structure for the host controller
- *
- * Return: none 
- **************************************************************************/
-void regShow (hci_t * hci)
-{
-	int i;
-	for (i = 0; i < 256; i++) {
-		printk ("offset %d: 0x%x\n", i, SL811Read (hci, i));
-	}
-}
-
-/************************************************************************
- * Function Name : USBReset
- *  
- * This function resets SL811HS controller and detects the speed of
- * the connecting device				  
- *
- * Input:  hci = data structure for the host controller
- *                
- * Return: 0 = no device attached; 1 = USB device attached
- *                
- ***********************************************************************/
-static int USBReset (hci_t * hci)
-{
-	int status;
-	hcipriv_t *hp = &hci->hp;
-
-	DBGFUNC ("enter USBReset\n");
-
-	SL811Write (hci, SL11H_CTLREG2, 0xae);
-
-	// setup master and full speed
-
-	SL811Write (hci, SL11H_CTLREG1, 0x08);	// reset USB
-	mdelay (20);		// 20ms                             
-	SL811Write (hci, SL11H_CTLREG1, 0);	// remove SE0        
-
-	for (status = 0; status < 100; status++)
-		SL811Write (hci, SL11H_INTSTATREG, 0xff);	// clear all interrupt bits
-
-	status = SL811Read (hci, SL11H_INTSTATREG);
-
-	if (status & 0x40)	// Check if device is removed
-	{
-		DBG ("USBReset: Device removed\n");
-		SL811Write (hci, SL11H_INTENBLREG,
-			    SL11H_INTMASK_XFERDONE | SL11H_INTMASK_SOFINTR |
-			    SL11H_INTMASK_INSRMV);
-		hp->RHportStatus->portStatus &=
-		    ~(PORT_CONNECT_STAT | PORT_ENABLE_STAT);
-
-		return 0;
-	}
-
-	SL811Write (hci, SL11H_BUFLNTHREG_B, 0);	//zero lenth
-	SL811Write (hci, SL11H_PIDEPREG_B, 0x50);	//send SOF to EP0       
-	SL811Write (hci, SL11H_DEVADDRREG_B, 0x01);	//address0
-	SL811Write (hci, SL11H_SOFLOWREG, 0xe0);
-
-	if (!(status & 0x80)) {
-		/* slow speed device connect directly to root-hub */
-
-		DBG ("USBReset: low speed Device attached\n");
-		SL811Write (hci, SL11H_CTLREG1, 0x8);
-		mdelay (20);
-		SL811Write (hci, SL11H_SOFTMRREG, 0xee);
-		SL811Write (hci, SL11H_CTLREG1, 0x21);
-
-		/* start the SOF or EOP */
-
-		SL811Write (hci, SL11H_HOSTCTLREG_B, 0x01);
-		hp->RHportStatus->portStatus |=
-		    (PORT_CONNECT_STAT | PORT_LOW_SPEED_DEV_ATTACH_STAT);
-
-		/* clear all interrupt bits */
-
-		for (status = 0; status < 20; status++)
-			SL811Write (hci, SL11H_INTSTATREG, 0xff);
-	} else {
-		/* full speed device connect directly to root hub */
-
-		DBG ("USBReset: full speed Device attached\n");
-		SL811Write (hci, SL11H_CTLREG1, 0x8);
-		mdelay (20);
-		SL811Write (hci, SL11H_SOFTMRREG, 0xae);
-		SL811Write (hci, SL11H_CTLREG1, 0x01);
-
-		/* start the SOF or EOP */
-
-		SL811Write (hci, SL11H_HOSTCTLREG_B, 0x01);
-		hp->RHportStatus->portStatus |= (PORT_CONNECT_STAT);
-		hp->RHportStatus->portStatus &= ~PORT_LOW_SPEED_DEV_ATTACH_STAT;
-
-		/* clear all interrupt bits */
-
-		SL811Write (hci, SL11H_INTSTATREG, 0xff);
-
-	}
-
-	/* enable all interrupts */
-	SL811Write (hci, SL11H_INTENBLREG,
-		    SL11H_INTMASK_XFERDONE | SL11H_INTMASK_SOFINTR |
-		    SL11H_INTMASK_INSRMV);
-
-	return 1;
-}
-
-/*-------------------------------------------------------------------------*/
-/* tl functions */
-static inline void hc_mark_last_trans (hci_t * hci)
-{
-	hcipriv_t *hp = &hci->hp;
-	__u8 *ptd = hp->tl;
-
-	dbg ("enter hc_mark_last_trans\n");
-	if (ptd == NULL) {
-		printk ("hc_mark_last_trans: ptd = null\n");
-		return;
-	}
-	if (hp->xferPktLen > 0)
-		*(ptd + hp->tl_last) |= (1 << 3);
-}
-
-static inline void hc_flush_data_cache (hci_t * hci, void *data, int len)
-{
-}
-
-/************************************************************************
- * Function Name : hc_add_trans
- *  
- * This function sets up the SL811HS register and transmit the USB packets.
- * 
- * 1) Determine if enough time within the current frame to send the packet
- * 2) Load the data into the SL811HS register
- * 3) Set the appropriate command to the register and trigger the transmit
- *
- * Input:  hci = data structure for the host controller
- *         len = data length
- *         data = transmitting data
- *         toggle = USB toggle bit, either 0 or 1
- *         maxps = maximum packet size for this endpoint
- *         slow = speed of the device
- *         endpoint = endpoint number
- *         address = USB address of the device
- *         pid = packet ID
- *         format = 
- *         urb_state = the current stage of USB transaction
- *       
- * Return: 0 = no time left to schedule the transfer
- *         1 = success 
- *                
- ***********************************************************************/
-static inline int hc_add_trans (hci_t * hci, int len, void *data, int toggle,
-				int maxps, int slow, int endpoint, int address,
-				int pid, int format, int urb_state)
-{
-	hcipriv_t *hp = &hci->hp;
-	__u16 speed;
-	int ii, jj, kk;
-
-	DBGFUNC ("enter hc_addr_trans: len =0x%x, toggle:0x%x, endpoing:0x%x,"
-		 " addr:0x%x, pid:0x%x,format:0x%x\n", len, toggle, endpoint,
-		 i address, pid, format);
-
-	if (len > maxps) {
-		len = maxps;
-	}
-
-	speed = hp->RHportStatus->portStatus;
-	if (speed & PORT_LOW_SPEED_DEV_ATTACH_STAT) {
-//      ii = (8*7*8 + 6*3) * len + 800; 
-		ii = 8 * 8 * len + 1024;
-	} else {
-		if (slow) {
-//          ii = (8*7*8 + 6*3) * len + 800; 
-			ii = 8 * 8 * len + 2048;
-		} else
-//          ii = (8*7 + 6*3)*len + 110;
-			ii = 8 * len + 256;
-	}
-
-	ii += 2 * 10 * len;
-
-	jj = SL811Read (hci, SL11H_SOFTMRREG);
-	kk = (jj & 0xFF) * 64 - ii;
-
-	if (kk < 0) {
-		DBGVERBOSE
-		    ("hc_add_trans: no bandwidth for schedule, ii = 0x%x,"
-		     "jj = 0x%x, len =0x%x, active_trans = 0x%x\n", ii, jj, len,
-		     hci->active_trans);
-		return (-1);
-	}
-
-	if (pid != PID_IN) {
-		/* Load data into hc */
-
-		SL811BufWrite (hci, SL11H_DATA_START, (__u8 *) data, len);
-	}
-
-	/* transmit */
-
-	SL11StartXaction (hci, (__u8) address, (__u8) endpoint, (__u8) pid, len,
-			  toggle, slow, urb_state);
-
-	return len;
-}
-
-/************************************************************************
- * Function Name : hc_parse_trans
- *  
- * This function checks the status of the transmitted or received packet
- * and copy the data from the SL811HS register into a buffer.
- *
- * 1) Check the status of the packet 
- * 2) If successful, and IN packet then copy the data from the SL811HS register
- *    into a buffer
- *
- * Input:  hci = data structure for the host controller
- *         actbytes = pointer to actual number of bytes
- *         data = data buffer
- *         cc = packet status
- *         length = the urb transmit length
- *         pid = packet ID
- *         urb_state = the current stage of USB transaction
- *       
- * Return: 0 
- ***********************************************************************/
-static inline int hc_parse_trans (hci_t * hci, int *actbytes, __u8 * data,
-				  int *cc, int *toggle, int length, int pid,
-				  int urb_state)
-{
-	__u8 addr;
-	__u8 len;
-
-	DBGFUNC ("enter hc_parse_trans\n");
-
-	/* get packet status; convert ack rcvd to ack-not-rcvd */
-
-	*cc = (int) SL811Read (hci, SL11H_PKTSTATREG);
-
-	if (*cc &
-	    (SL11H_STATMASK_ERROR | SL11H_STATMASK_TMOUT | SL11H_STATMASK_OVF |
-	     SL11H_STATMASK_NAK | SL11H_STATMASK_STALL)) {
-		if (*cc & SL11H_STATMASK_OVF)
-			DBGERR ("parse trans: error recv ack, cc = 0x%x, TX_BASE_Len = "
-				"0x%x, TX_count=0x%x\n", *cc,
-				SL811Read (hci, SL11H_BUFLNTHREG),
-				SL811Read (hci, SL11H_XFERCNTREG));
-
-	} else {
-		DBGVERBOSE ("parse trans: recv ack, cc = 0x%x, len = 0x%x, \n",
-			    *cc, length);
-
-		/* Successful data */
-		if ((pid == PID_IN) && (urb_state != US_CTRL_SETUP)) {
-
-			/* Find the base address */
-			addr = SL811Read (hci, SL11H_BUFADDRREG);
-
-			/* Find the Transmit Length */
-			len = SL811Read (hci, SL11H_BUFLNTHREG);
-
-			/* The actual data length = xmit length reg - xfer count reg */
-			*actbytes = len - SL811Read (hci, SL11H_XFERCNTREG);
-
-			if ((data != NULL) && (*actbytes > 0)) {
-				SL811BufRead (hci, addr, data, *actbytes);
-
-			} else if ((data == NULL) && (*actbytes <= 0)) {
-				DBGERR ("hc_parse_trans: data = NULL or actbyte = 0x%x\n",
-					*actbytes);
-				return 0;
-			}
-		} else if (pid == PID_OUT) {
-			*actbytes = length;
-		} else {
-			// printk ("ERR:parse_trans, pid != IN or OUT, pid = 0x%x\n", pid);
-		}
-		*toggle = !*toggle;
-	}
-
-	return 0;
-}
-
-/************************************************************************
- * Function Name : hc_start_int
- *  
- * This function enables SL811HS interrupts
- *
- * Input:  hci = data structure for the host controller
- *       
- * Return: none 
- ***********************************************************************/
-static void hc_start_int (hci_t * hci)
-{
-#ifdef HC_SWITCH_INT
-	int mask =
-	    SL11H_INTMASK_XFERDONE | SL11H_INTMASK_SOFINTR |
-	    SL11H_INTMASK_INSRMV | SL11H_INTMASK_USBRESET;
-	SL811Write (hci, IntEna, mask);
-#endif
-}
-
-/************************************************************************
- * Function Name : hc_stop_int
- *  
- * This function disables SL811HS interrupts
- *
- * Input:  hci = data structure for the host controller
- *       
- * Return: none 
- ***********************************************************************/
-static void hc_stop_int (hci_t * hci)
-{
-#ifdef HC_SWITCH_INT
-	SL811Write (hci, SL11H_INTSTATREG, 0xff);
-//  SL811Write(hci, SL11H_INTENBLREG, SL11H_INTMASK_INSRMV);
-
-#endif
-}
-
-/************************************************************************
- * Function Name : handleInsRmvIntr
- *  
- * This function handles the insertion or removal of device on  SL811HS. 
- * It resets the controller and updates the port status
- *
- * Input:  hci = data structure for the host controller
- *       
- * Return: none 
- ***********************************************************************/
-void handleInsRmvIntr (hci_t * hci)
-{
-	hcipriv_t *hp = &hci->hp;
-
-	USBReset (hci);
-
-	/* Changes in connection status */
-
-	hp->RHportStatus->portChange |= PORT_CONNECT_CHANGE;
-
-	/* Port Enable or Disable */
-
-	if (hp->RHportStatus->portStatus & PORT_CONNECT_STAT) {
-		/* device is connected to the port:
-		 *    1) Enable port 
-		 *    2) Resume ?? 
-		 */
-//               hp->RHportStatus->portChange |= PORT_ENABLE_CHANGE;
-
-		/* Over Current is not supported by the SL811 HW ?? */
-
-		/* How about the Port Power ?? */
-
-	} else {
-		/* Device has disconnect:
-		 *    1) Disable port
-		 */
-
-		hp->RHportStatus->portStatus &= ~(PORT_ENABLE_STAT);
-		hp->RHportStatus->portChange |= PORT_ENABLE_CHANGE;
-
-	}
-}
-
-/*****************************************************************
- *
- * Function Name: SL11StartXaction
- *  
- * This functions load the registers with appropriate value and 
- * transmit the packet.				  
- *
- * Input:  hci = data structure for the host controller
- *         addr = USB address of the device
- *         epaddr = endpoint number
- *         pid = packet ID
- *         len = data length
- *         toggle = USB toggle bit, either 0 or 1
- *         slow = speed of the device
- *         urb_state = the current stage of USB transaction
- *
- * Return: 0 = error; 1 = successful
- *                
- *****************************************************************/
-int SL11StartXaction (hci_t * hci, __u8 addr, __u8 epaddr, int pid, int len,
-		      int toggle, int slow, int urb_state)
-{
-
-	hcipriv_t *hp = &hci->hp;
-	__u8 cmd = 0;
-	__u8 setup_data[4];
-	__u16 speed;
-
-	speed = hp->RHportStatus->portStatus;
-	if (!(speed & PORT_LOW_SPEED_DEV_ATTACH_STAT) && slow) {
-		cmd |= SL11H_HCTLMASK_PREAMBLE;
-	}
-	switch (pid) {
-	case PID_SETUP:
-		cmd &= SL11H_HCTLMASK_PREAMBLE;
-		cmd |=
-		    (SL11H_HCTLMASK_ARM | SL11H_HCTLMASK_ENBLEP |
-		     SL11H_HCTLMASK_WRITE);
-		break;
-
-	case PID_OUT:
-		cmd &= (SL11H_HCTLMASK_SEQ | SL11H_HCTLMASK_PREAMBLE);
-		cmd |=
-		    (SL11H_HCTLMASK_ARM | SL11H_HCTLMASK_ENBLEP |
-		     SL11H_HCTLMASK_WRITE);
-		if (toggle) {
-			cmd |= SL11H_HCTLMASK_SEQ;
-		}
-		break;
-
-	case PID_IN:
-		cmd &= (SL11H_HCTLMASK_SEQ | SL11H_HCTLMASK_PREAMBLE);
-		cmd |= (SL11H_HCTLMASK_ARM | SL11H_HCTLMASK_ENBLEP);
-		break;
-
-	default:
-		DBGERR ("ERR: SL11StartXaction: unknow pid = 0x%x\n", pid);
-		return 0;
-	}
-	setup_data[0] = SL11H_DATA_START;
-	setup_data[1] = len;
-	setup_data[2] = (((pid & 0x0F) << 4) | (epaddr & 0xF));
-	setup_data[3] = addr & 0x7F;
-
-	SL811BufWrite (hci, SL11H_BUFADDRREG, (__u8 *) & setup_data[0], 4);
-
-	SL811Write (hci, SL11H_HOSTCTLREG, cmd);
-
-#if 0
-	/* The SL811 has a hardware flaw when hub devices sends out
-	 * SE0 between packets. It has been found in a TI chipset and
-	 * cypress hub chipset. It causes the SL811 to hang
-	 * The workaround is to re-issue the preample again.
-	 */
-
-	if ((cmd & SL11H_HCTLMASK_PREAMBLE)) {
-		SL811Write (hci, SL11H_PIDEPREG_B, 0xc0);
-		SL811Write (hci, SL11H_HOSTCTLREG_B, 0x1);	// send the premable
-	}
-#endif
-	return 1;
-}
-
-/*****************************************************************
- *
- * Function Name: hc_interrupt
- *
- * Interrupt service routine. 
- *
- * 1) determine the causes of interrupt
- * 2) clears all interrupts
- * 3) calls appropriate function to service the interrupt
- *
- * Input:  irq = interrupt line associated with the controller 
- *         hci = data structure for the host controller
- *         r = holds the snapshot of the processor's context before 
- *             the processor entered interrupt code. (not used here) 
- *
- * Return value  : None.
- *                
- *****************************************************************/
-static void hc_interrupt (int irq, void *__hci, struct pt_regs *r)
-{
-	char ii;
-	hci_t *hci = __hci;
-	int isExcessNak = 0;
-	int urb_state = 0;
-	char tmpIrq = 0;
-
-	/* Get value from interrupt status register */
-
-	ii = SL811Read (hci, SL11H_INTSTATREG);
-
-	if (ii & SL11H_INTMASK_INSRMV) {
-		/* Device insertion or removal detected for the USB port */
-
-		SL811Write (hci, SL11H_INTENBLREG, 0);
-		SL811Write (hci, SL11H_CTLREG1, 0);
-		mdelay (100);	// wait for device stable 
-		handleInsRmvIntr (hci);
-		return;
-	}
-
-	/* Clear all interrupts */
-
-	SL811Write (hci, SL11H_INTSTATREG, 0xff);
-
-	if (ii & SL11H_INTMASK_XFERDONE) {
-		/* USB Done interrupt occurred */
-
-		urb_state = sh_done_list (hci, &isExcessNak);
-#ifdef WARNING
-		if (hci->td_array->len > 0)
-			printk ("WARNING: IRQ, td_array->len = 0x%x, s/b:0\n",
-				hci->td_array->len);
-#endif
-		if (hci->td_array->len == 0 && !isExcessNak
-		    && !(ii & SL11H_INTMASK_SOFINTR) && (urb_state == 0)) {
-			if (urb_state == 0) {
-				/* All urb_state has not been finished yet! 
-				 * continue with the current urb transaction 
-				 */
-
-				if (hci->last_packet_nak == 0) {
-					if (!usb_pipecontrol
-					    (hci->td_array->td[0].urb->pipe))
-						sh_add_packet (hci, hci->td_array-> td[0].urb);
-				}
-			} else {
-				/* The last transaction has completed:
-				 * schedule the next transaction 
-				 */
-
-				sh_schedule_trans (hci, 0);
-			}
-		}
-		SL811Write (hci, SL11H_INTSTATREG, 0xff);
-		return;
-	}
-
-	if (ii & SL11H_INTMASK_SOFINTR) {
-		hci->frame_number = (hci->frame_number + 1) % 2048;
-		if (hci->td_array->len == 0)
-			sh_schedule_trans (hci, 1);
-		else {
-			if (sofWaitCnt++ > 100) {
-				/* The last transaction has not completed.
-				 * Need to retire the current td, and let
-				 * it transmit again later on.
-				 * (THIS NEEDS TO BE WORK ON MORE, IT SHOULD NEVER 
-				 *  GET TO THIS POINT)
-				 */
-
-				DBGERR ("SOF interrupt: td_array->len = 0x%x, s/b: 0\n",
-					hci->td_array->len);
-				urb_print (hci->td_array->td[hci->td_array->len - 1].urb,
-					   "INTERRUPT", 0);
-				sh_done_list (hci, &isExcessNak);
-				SL811Write (hci, SL11H_INTSTATREG, 0xff);
-				hci->td_array->len = 0;
-				sofWaitCnt = 0;
-			}
-		}
-		tmpIrq = SL811Read (hci, SL11H_INTSTATREG) & SL811Read (hci, SL11H_INTENBLREG);
-		if (tmpIrq) {
-			DBG ("IRQ occurred while service SOF: irq = 0x%x\n",
-			     tmpIrq);
-
-			/* If we receive a DONE IRQ after schedule, need to 
-			 * handle DONE IRQ again 
-			 */
-
-			if (tmpIrq & SL11H_INTMASK_XFERDONE) {
-				DBGERR ("IRQ occurred while service SOF: irq = 0x%x\n",
-					tmpIrq);
-				urb_state = sh_done_list (hci, &isExcessNak);
-			}
-			SL811Write (hci, SL11H_INTSTATREG, 0xff);
-		}
-	} else {
-		DBG ("SL811 ISR: unknown, int = 0x%x \n", ii);
-	}
-
-	SL811Write (hci, SL11H_INTSTATREG, 0xff);
-	return;
-}
-
-/*****************************************************************
- *
- * Function Name: hc_reset
- *
- * This function does register test and resets the SL811HS 
- * controller.
- *
- * Input:  hci = data structure for the host controller
- *
- * Return value  : 0
- *                
- *****************************************************************/
-static int hc_reset (hci_t * hci)
-{
-	int attachFlag = 0;
-
-	DBGFUNC ("Enter hc_reset\n");
-	regTest (hci);
-	attachFlag = USBReset (hci);
-	if (attachFlag) {
-		setPortChange (hci, PORT_CONNECT_CHANGE);
-	}
-	return (0);
-}
-
-/*****************************************************************
- *
- * Function Name: hc_alloc_trans_buffer
- *
- * This function allocates all transfer buffer  
- *
- * Input:  hci = data structure for the host controller
- *
- * Return value  : 0
- *                
- *****************************************************************/
-static int hc_alloc_trans_buffer (hci_t * hci)
-{
-	hcipriv_t *hp = &hci->hp;
-	int maxlen;
-
-	hp->itl0_len = 0;
-	hp->itl1_len = 0;
-	hp->atl_len = 0;
-
-	hp->itl_buffer_len = 1024;
-	hp->atl_buffer_len = 4096 - 2 * hp->itl_buffer_len;	/* 2048 */
-
-	maxlen = (hp->itl_buffer_len > hp->atl_buffer_len) ? hp->itl_buffer_len : hp->atl_buffer_len;
-
-	hp->tl = kmalloc (maxlen, GFP_KERNEL);
-
-	if (!hp->tl)
-		return -ENOMEM;
-
-	memset (hp->tl, 0, maxlen);
-	return 0;
-}
-
-/*****************************************************************
- *
- * Function Name: getPortStatusAndChange
- *
- * This function gets the ports status from SL811 and format it 
- * to a USB request format
- *
- * Input:  hci = data structure for the host controller
- *
- * Return value  : port status and change
- *                
- *****************************************************************/
-static __u32 getPortStatusAndChange (hci_t * hci)
-{
-	hcipriv_t *hp = &hci->hp;
-	__u32 portstatus;
-
-	DBGFUNC ("enter getPorStatusAndChange\n");
-
-	portstatus = hp->RHportStatus->portChange << 16 | hp->RHportStatus->portStatus;
-
-	return (portstatus);
-}
-
-/*****************************************************************
- *
- * Function Name: setPortChange
- *
- * This function set the bit position of portChange.
- *
- * Input:  hci = data structure for the host controller
- *         bitPos = the bit position
- *
- * Return value  : none 
- *                
- *****************************************************************/
-static void setPortChange (hci_t * hci, __u16 bitPos)
-{
-	hcipriv_t *hp = &hci->hp;
-
-	switch (bitPos) {
-	case PORT_CONNECT_STAT:
-		hp->RHportStatus->portChange |= bitPos;
-		break;
-
-	case PORT_ENABLE_STAT:
-		hp->RHportStatus->portChange |= bitPos;
-		break;
-
-	case PORT_RESET_STAT:
-		hp->RHportStatus->portChange |= bitPos;
-		break;
-
-	case PORT_POWER_STAT:
-		hp->RHportStatus->portChange |= bitPos;
-		break;
-
-	case PORT_SUSPEND_STAT:
-		hp->RHportStatus->portChange |= bitPos;
-		break;
-
-	case PORT_OVER_CURRENT_STAT:
-		hp->RHportStatus->portChange |= bitPos;
-		break;
-	}
-}
-
-/*****************************************************************
- *
- * Function Name: clrPortChange
- *
- * This function clear the bit position of portChange.
- *
- * Input:  hci = data structure for the host controller
- *         bitPos = the bit position
- *
- * Return value  : none 
- *                
- *****************************************************************/
-static void clrPortChange (hci_t * hci, __u16 bitPos)
-{
-	hcipriv_t *hp = &hci->hp;
-	switch (bitPos) {
-	case PORT_CONNECT_CHANGE:
-		hp->RHportStatus->portChange &= ~bitPos;
-		break;
-
-	case PORT_ENABLE_CHANGE:
-		hp->RHportStatus->portChange &= ~bitPos;
-		break;
-
-	case PORT_RESET_CHANGE:
-		hp->RHportStatus->portChange &= ~bitPos;
-		break;
-
-	case PORT_SUSPEND_CHANGE:
-		hp->RHportStatus->portChange &= ~bitPos;
-		break;
-
-	case PORT_OVER_CURRENT_CHANGE:
-		hp->RHportStatus->portChange &= ~bitPos;
-		break;
-	}
-}
-
-/*****************************************************************
- *
- * Function Name: clrPortStatus
- *
- * This function clear the bit position of portStatus.
- *
- * Input:  hci = data structure for the host controller
- *         bitPos = the bit position
- *
- * Return value  : none 
- *                
- *****************************************************************/
-static void clrPortStatus (hci_t * hci, __u16 bitPos)
-{
-	hcipriv_t *hp = &hci->hp;
-	switch (bitPos) {
-	case PORT_ENABLE_STAT:
-		hp->RHportStatus->portStatus &= ~bitPos;
-		break;
-
-	case PORT_RESET_STAT:
-		hp->RHportStatus->portStatus &= ~bitPos;
-		break;
-
-	case PORT_POWER_STAT:
-		hp->RHportStatus->portStatus &= ~bitPos;
-		break;
-
-	case PORT_SUSPEND_STAT:
-		hp->RHportStatus->portStatus &= ~bitPos;
-		break;
-	}
-}
-
-/*****************************************************************
- *
- * Function Name: setPortStatus
- *
- * This function set the bit position of portStatus.
- *
- * Input:  hci = data structure for the host controller
- *         bitPos = the bit position
- *
- * Return value  : none 
- *                
- *****************************************************************/
-static void setPortStatus (hci_t * hci, __u16 bitPos)
-{
-	hcipriv_t *hp = &hci->hp;
-	switch (bitPos) {
-	case PORT_ENABLE_STAT:
-		hp->RHportStatus->portStatus |= bitPos;
-		break;
-
-	case PORT_RESET_STAT:
-		hp->RHportStatus->portStatus |= bitPos;
-		break;
-
-	case PORT_POWER_STAT:
-		hp->RHportStatus->portStatus |= bitPos;
-		break;
-
-	case PORT_SUSPEND_STAT:
-		hp->RHportStatus->portStatus |= bitPos;
-		break;
-	}
-}
-
-/*****************************************************************
- *
- * Function Name: hc_start
- *
- * This function starts the root hub functionality. 
- *
- * Input:  hci = data structure for the host controller
- *
- * Return value  : 0 
- *                
- *****************************************************************/
-static int hc_start (hci_t * hci)
-{
-	DBGFUNC ("Enter hc_start\n");
-
-	rh_connect_rh (hci);
-
-	return 0;
-}
-
-/*****************************************************************
- *
- * Function Name: hc_alloc_hci
- *
- * This function allocates all data structure and store in the 
- * private data structure. 
- *
- * Input:  hci = data structure for the host controller
- *
- * Return value  : 0 
- *                
- *****************************************************************/
-static hci_t *__devinit hc_alloc_hci (void)
-{
-	hci_t *hci;
-	hcipriv_t *hp;
-	portstat_t *ps;
-	struct usb_bus *bus;
-
-	DBGFUNC ("Enter hc_alloc_hci\n");
-	hci = (hci_t *) kmalloc (sizeof (hci_t), GFP_KERNEL);
-	if (!hci)
-		return NULL;
-
-	memset (hci, 0, sizeof (hci_t));
-
-	hp = &hci->hp;
-
-	hp->irq = -1;
-	hp->hcport = -1;
-
-	/* setup root hub port status */
-
-	ps = (portstat_t *) kmalloc (sizeof (portstat_t), GFP_KERNEL);
-
-	if (!ps)
-		return NULL;
-	ps->portStatus = PORT_STAT_DEFAULT;
-	ps->portChange = PORT_CHANGE_DEFAULT;
-	hp->RHportStatus = ps;
-
-	hci->nakCnt = 0;
-	hci->last_packet_nak = 0;
-
-	hci->a_td_array.len = 0;
-	hci->i_td_array[0].len = 0;
-	hci->i_td_array[1].len = 0;
-	hci->td_array = &hci->a_td_array;
-	hci->active_urbs = 0;
-	hci->active_trans = 0;
-	INIT_LIST_HEAD (&hci->hci_hcd_list);
-	list_add (&hci->hci_hcd_list, &hci_hcd_list);
-	init_waitqueue_head (&hci->waitq);
-
-	INIT_LIST_HEAD (&hci->ctrl_list);
-	INIT_LIST_HEAD (&hci->bulk_list);
-	INIT_LIST_HEAD (&hci->iso_list);
-	INIT_LIST_HEAD (&hci->intr_list);
-	INIT_LIST_HEAD (&hci->del_list);
-
-	bus = usb_alloc_bus (&hci_device_operations);
-	if (!bus) {
-		kfree (hci);
-		kfree (ps);
-		return NULL;
-	}
-
-	hci->bus = bus;
-	bus->hcpriv = (void *) hci;
-
-	return hci;
-}
-
-/*****************************************************************
- *
- * Function Name: hc_release_hci
- *
- * This function De-allocate all resources  
- *
- * Input:  hci = data structure for the host controller
- *
- * Return value  : 0 
- *                
- *****************************************************************/
-static void hc_release_hci (hci_t * hci)
-{
-	hcipriv_t *hp = &hci->hp;
-
-	DBGFUNC ("Enter hc_release_hci\n");
-
-	/* disconnect all devices */
-	if (hci->bus->root_hub)
-		usb_disconnect (&hci->bus->root_hub);
-
-	hc_reset (hci);
-
-	if (hp->tl)
-		kfree (hp->tl);
-
-	if (hp->hcport > 0) {
-		release_region (hp->hcport, 2);
-		hp->hcport = 0;
-	}
-
-	if (hp->irq >= 0) {
-		free_irq (hp->irq, hci);
-		hp->irq = -1;
-	}
-
-	usb_deregister_bus (hci->bus);
-	usb_put_bus (hci->bus);
-
-	list_del_init (&hci->hci_hcd_list);
-
-	kfree (hci);
-}
-
-/*****************************************************************
- *
- * Function Name: init_irq
- *
- * This function is board specific.  It sets up the interrupt to 
- * be an edge trigger and trigger on the rising edge  
- *
- * Input: none 
- *
- * Return value  : none 
- *                
- *****************************************************************/
-void init_irq (void)
-{
-	GPDR &= ~(1 << 13);
-	set_GPIO_IRQ_edge (1 << 13, GPIO_RISING_EDGE);
-}
-
-/*****************************************************************
- *
- * Function Name: hc_found_hci
- *
- * This function request IO memory regions, request IRQ, and
- * allocate all other resources. 
- *
- * Input: addr = first IO address
- *        addr2 = second IO address
- *        irq = interrupt number 
- *
- * Return: 0 = success or error condition 
- *                
- *****************************************************************/
-static int __devinit hc_found_hci (int addr, int addr2, int irq)
-{
-	hci_t *hci;
-	hcipriv_t *hp;
-
-	DBGFUNC ("Enter hc_found_hci\n");
-	hci = hc_alloc_hci ();
-	if (!hci) {
-		return -ENOMEM;
-	}
-
-	init_irq ();
-	hp = &hci->hp;
-
-	if (!request_region (addr, 256, "SL811 USB HOST")) {
-		DBGERR ("request address %d failed", addr);
-		hc_release_hci (hci);
-		return -EBUSY;
-	}
-	hp->hcport = addr;
-	if (!hp->hcport) {
-		DBGERR ("Error mapping SL811 Memory 0x%x", hp->hcport);
-	}
-
-	if (!request_region (addr2, 256, "SL811 USB HOST")) {
-		DBGERR ("request address %d failed", addr2);
-		hc_release_hci (hci);
-		return -EBUSY;
-	}
-	hp->hcport2 = addr2;
-	if (!hp->hcport2) {
-		DBGERR ("Error mapping SL811 Memory 0x%x", hp->hcport2);
-	}
-
-	if (hc_alloc_trans_buffer (hci)) {
-		hc_release_hci (hci);
-		return -ENOMEM;
-	}
-
-	usb_register_bus (hci->bus);
-
-	if (request_irq (irq, hc_interrupt, 0, "SL811", hci) != 0) {
-		DBGERR ("request interrupt %d failed", irq);
-		hc_release_hci (hci);
-		return -EBUSY;
-	}
-	hp->irq = irq;
-
-	printk (KERN_INFO __FILE__ ": USB SL811 at %x, addr2 = %x, IRQ %d\n",
-		addr, addr2, irq);
-	hc_reset (hci);
-
-	if (hc_start (hci) < 0) {
-		DBGERR ("can't start usb-%x", addr);
-		hc_release_hci (hci);
-		return -EBUSY;
-	}
-
-	return 0;
-}
-
-/*****************************************************************
- *
- * Function Name: hci_hcd_init
- *
- * This is an init function, and it is the first function being called
- *
- * Input: none 
- *
- * Return: 0 = success or error condition 
- *                
- *****************************************************************/
-static int __init hci_hcd_init (void)
-{
-	int ret;
-
-	DBGFUNC ("Enter hci_hcd_init\n");
-	if (usb_disabled())
-		return -ENODEV;
-
-	ret = hc_found_hci (base_addr, data_reg_addr, irq);
-
-	return ret;
-}
-
-/*****************************************************************
- *
- * Function Name: hci_hcd_cleanup
- *
- * This is a cleanup function, and it is called when module is 
- * unloaded. 
- *
- * Input: none 
- *
- * Return: none 
- *                
- *****************************************************************/
-static void __exit hci_hcd_cleanup (void)
-{
-	struct list_head *hci_l;
-	hci_t *hci;
-
-	DBGFUNC ("Enter hci_hcd_cleanup\n");
-	for (hci_l = hci_hcd_list.next; hci_l != &hci_hcd_list;) {
-		hci = list_entry (hci_l, hci_t, hci_hcd_list);
-		hci_l = hci_l->next;
-		hc_release_hci (hci);
-	}
-}
-
-module_init (hci_hcd_init);
-module_exit (hci_hcd_cleanup);
-
-MODULE_AUTHOR ("Pei Liu <pbl@cypress.com>");
-MODULE_DESCRIPTION ("USB SL811HS Host Controller Driver");
diff -Nru a/drivers/usb/host/hc_sl811.h b/drivers/usb/host/hc_sl811.h
--- a/drivers/usb/host/hc_sl811.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,385 +0,0 @@
-/*
- * SL811HS HCD (Host Controller Driver) for USB.
- * 
- * COPYRIGHT (C) by CYPRESS SEMICONDUCTOR INC 
- * 
- *
- */
-
-#define GET_FRAME_NUMBER(hci)	READ_REG32 (hci, HcFmNumber)
-
-/*
- * Maximum number of root hub ports
- */
-#define MAX_ROOT_PORTS		15	/* maximum OHCI root hub ports */
-
-/* control and status registers */
-#define HcRevision		0x00
-#define HcControl		0x01
-#define HcCommandStatus		0x02
-#define HcInterruptStatus	0x03
-#define HcInterruptEnable	0x04
-#define HcInterruptDisable	0x05
-#define HcFmInterval		0x0D
-#define HcFmRemaining		0x0E
-#define HcFmNumber		0x0F
-#define HcLSThreshold		0x11
-#define HcRhDescriptorA		0x12
-#define HcRhDescriptorB		0x13
-#define HcRhStatus		0x14
-#define HcRhPortStatus		0x15
-
-#define HcHardwareConfiguration 0x20
-#define HcDMAConfiguration	0x21
-#define HcTransferCounter	0x22
-#define HcuPInterrupt		0x24
-#define HcuPInterruptEnable	0x25
-#define HcChipID		0x27
-#define HcScratch		0x28
-#define HcSoftwareReset		0x29
-#define HcITLBufferLength	0x2A
-#define HcATLBufferLength	0x2B
-#define HcBufferStatus		0x2C
-#define HcReadBackITL0Length	0x2D
-#define HcReadBackITL1Length	0x2E
-#define HcITLBufferPort		0x40
-#define HcATLBufferPort		0x41
-
-/* OHCI CONTROL AND STATUS REGISTER MASKS */
-
-/*
- * HcControl (control) register masks
- */
-#define OHCI_CTRL_HCFS		(3 << 6)	/* BUS state mask */
-#define OHCI_CTRL_RWC		(1 << 9)	/* remote wakeup connected */
-#define OHCI_CTRL_RWE		(1 << 10)	/* remote wakeup enable */
-
-/* pre-shifted values for HCFS */
-#define OHCI_USB_RESET		(0 << 6)
-#define OHCI_USB_RESUME		(1 << 6)
-#define OHCI_USB_OPER		(2 << 6)
-#define OHCI_USB_SUSPEND	(3 << 6)
-
-/*
- * HcCommandStatus (cmdstatus) register masks
- */
-#define OHCI_HCR	(1 << 0)	/* host controller reset */
-#define OHCI_SO		(3 << 16)	/* scheduling overrun count */
-
-/*
- * masks used with interrupt registers:
- * HcInterruptStatus (intrstatus)
- * HcInterruptEnable (intrenable)
- * HcInterruptDisable (intrdisable)
- */
-#define OHCI_INTR_SO	(1 << 0)	/* scheduling overrun */
-
-#define OHCI_INTR_SF	(1 << 2)	/* start frame */
-#define OHCI_INTR_RD	(1 << 3)	/* resume detect */
-#define OHCI_INTR_UE	(1 << 4)	/* unrecoverable error */
-#define OHCI_INTR_FNO	(1 << 5)	/* frame number overflow */
-#define OHCI_INTR_RHSC	(1 << 6)	/* root hub status change */
-#define OHCI_INTR_ATD	(1 << 7)	/* scheduling overrun */
-
-#define OHCI_INTR_MIE	(1 << 31)	/* master interrupt enable */
-
-/*
- * HcHardwareConfiguration
- */
-#define InterruptPinEnable	(1 << 0)
-#define InterruptPinTrigger	(1 << 1)
-#define InterruptOutputPolarity	(1 << 2)
-#define DataBusWidth16		(1 << 3)
-#define DREQOutputPolarity	(1 << 5)
-#define DACKInputPolarity	(1 << 6)
-#define EOTInputPolarity	(1 << 7)
-#define DACKMode		(1 << 8)
-#define AnalogOCEnable		(1 << 10)
-#define SuspendClkNotStop	(1 << 11)
-#define DownstreamPort15KRSel	(1 << 12)
-
-/* 
- * HcDMAConfiguration
- */
-#define DMAReadWriteSelect 	(1 << 0)
-#define ITL_ATL_DataSelect	(1 << 1)
-#define DMACounterSelect	(1 << 2)
-#define DMAEnable		(1 << 4)
-#define BurstLen_1		0
-#define BurstLen_4		(1 << 5)
-#define BurstLen_8		(2 << 5)
-
-/*
- * HcuPInterrupt
- */
-#define SOFITLInt		(1 << 0)
-#define ATLInt			(1 << 1)
-#define AllEOTInterrupt		(1 << 2)
-#define OPR_Reg			(1 << 4)
-#define HCSuspended		(1 << 5)
-#define ClkReady		(1 << 6)
-
-/*
- * HcBufferStatus
- */
-#define ITL0BufferFull		(1 << 0)
-#define ITL1BufferFull		(1 << 1)
-#define ATLBufferFull		(1 << 2)
-#define ITL0BufferDone		(1 << 3)
-#define ITL1BufferDone		(1 << 4)
-#define ATLBufferDone		(1 << 5)
-
-/* OHCI ROOT HUB REGISTER MASKS */
-
-/* roothub.portstatus [i] bits */
-#define RH_PS_CCS            0x00000001	/* current connect status */
-#define RH_PS_PES            0x00000002	/* port enable status */
-#define RH_PS_PSS            0x00000004	/* port suspend status */
-#define RH_PS_POCI           0x00000008	/* port over current indicator */
-#define RH_PS_PRS            0x00000010	/* port reset status */
-#define RH_PS_PPS            0x00000100	/* port power status */
-#define RH_PS_LSDA           0x00000200	/* low speed device attached */
-#define RH_PS_CSC            0x00010000	/* connect status change */
-#define RH_PS_PESC           0x00020000	/* port enable status change */
-#define RH_PS_PSSC           0x00040000	/* port suspend status change */
-#define RH_PS_OCIC           0x00080000	/* over current indicator change */
-#define RH_PS_PRSC           0x00100000	/* port reset status change */
-
-/* roothub.status bits */
-#define RH_HS_LPS		0x00000001	/* local power status */
-#define RH_HS_OCI		0x00000002	/* over current indicator */
-#define RH_HS_DRWE		0x00008000	/* device remote wakeup enable */
-#define RH_HS_LPSC		0x00010000	/* local power status change */
-#define RH_HS_OCIC		0x00020000	/* over current indicator change */
-#define RH_HS_CRWE		0x80000000	/* clear remote wakeup enable */
-
-/* roothub.b masks */
-#define RH_B_DR			0x0000ffff	/* device removable flags */
-#define RH_B_PPCM		0xffff0000	/* port power control mask */
-
-/* roothub.a masks */
-#define	RH_A_NDP		(0xff << 0)	/* number of downstream ports */
-#define	RH_A_PSM		(1 << 8)	/* power switching mode */
-#define	RH_A_NPS		(1 << 9)	/* no power switching */
-#define	RH_A_DT			(1 << 10)	/* device type (mbz) */
-#define	RH_A_OCPM		(1 << 11)	/* over current protection mode */
-#define	RH_A_NOCP		(1 << 12)	/* no over current protection */
-#define	RH_A_POTPGT		(0xff << 24)	/* power on to power good time */
-
-#define URB_DEL 1
-
-#define PORT_STAT_DEFAULT		0x0100
-#define PORT_CONNECT_STAT  		0x1
-#define PORT_ENABLE_STAT		0x2
-#define PORT_SUSPEND_STAT		0x4
-#define PORT_OVER_CURRENT_STAT		0x8
-#define PORT_RESET_STAT			0x10
-#define PORT_POWER_STAT			0x100
-#define PORT_LOW_SPEED_DEV_ATTACH_STAT	0x200
-
-#define PORT_CHANGE_DEFAULT		0x0
-#define PORT_CONNECT_CHANGE		0x1
-#define PORT_ENABLE_CHANGE		0x2
-#define PORT_SUSPEND_CHANGE		0x4
-#define PORT_OVER_CURRENT_CHANGE	0x8
-#define PORT_RESET_CHANGE		0x10
-
-/* Port Status Request info */
-
-typedef struct portstat {
-	__u16 portChange;
-	__u16 portStatus;
-} portstat_t;
-
-typedef struct hcipriv {
-	int irq;
-	int disabled;		/* e.g. got a UE, we're hung */
-	atomic_t resume_count;	/* defending against multiple resumes */
-	struct ohci_regs *regs;	/* OHCI controller's memory */
-	int hcport;		/* I/O base address */
-	int hcport2;		/* I/O data reg addr */
-
-	struct portstat *RHportStatus;	/* root hub port status */
-
-	int intrstatus;
-	__u32 hc_control;	/* copy of the hc control reg */
-
-	int frame;
-
-	__u8 *tl;
-	int xferPktLen;
-	int atl_len;
-	int atl_buffer_len;
-	int itl0_len;
-	int itl1_len;
-	int itl_buffer_len;
-	int itl_index;
-	int tl_last;
-	int units_left;
-
-} hcipriv_t;
-struct hci;
-
-#define cClt        0		// Control
-#define cISO        1		// ISO
-#define cBULK       2		// BULK
-#define cInt        3		// Interrupt
-#define ISO_BIT     0x10
-
-/*-------------------------------------------------------------------------
- * EP0 use for configuration and Vendor Specific command interface
- *------------------------------------------------------------------------*/
-#define cMemStart       0x10
-#define EP0Buf          0x40	/* SL11H/SL811H memory start at 0x40 */
-#define EP0Len          0x40	/* Length of config buffer EP0Buf */
-#define EP1Buf          0x60
-#define EP1Len          0x40
-
-/*-------------------------------------------------------------------------
- * SL11H/SL811H memory from 80h-ffh use as ping-pong buffer.
- *------------------------------------------------------------------------*/
-#define uBufA           0x80	/* buffer A address for DATA0 */
-#define uBufB           0xc0	/* buffer B address for DATA1 */
-#define uXferLen        0x40	/* xfer length */
-#define sMemSize        0xc0	/* Total SL11 memory size */
-#define cMemEnd         256
-
-/*-------------------------------------------------------------------------
- * SL811H Register Control memory map
- * --Note: 
- *      --SL11H only has one control register set from 0x00-0x04
- *      --SL811H has two control register set from 0x00-0x04 and 0x08-0x0c
- *------------------------------------------------------------------------*/
-
-#define EP0Control      0x00
-#define EP0Address      0x01
-#define EP0XferLen      0x02
-#define EP0Status       0x03
-#define EP0Counter      0x04
-
-#define EP1Control      0x08
-#define EP1Address      0x09
-#define EP1XferLen      0x0a
-#define EP1Status       0x0b
-#define EP1Counter      0x0c
-
-#define CtrlReg         0x05
-#define IntEna          0x06
-			 // 0x07 is reserved
-#define IntStatus       0x0d
-#define cDATASet        0x0e
-#define cSOFcnt         0x0f
-#define IntMask         0x57	/* Reset|DMA|EP0|EP2|EP1 for IntEna */
-#define HostMask        0x47	/* Host request command  for IntStatus */
-#define ReadMask        0xd7	/* Read mask interrupt   for IntStatus */
-
-/*-------------------------------------------------------------------------
- * Standard Chapter 9 definition
- *-------------------------------------------------------------------------
- */
-#define GET_STATUS      0x00
-#define CLEAR_FEATURE   0x01
-#define SET_FEATURE     0x03
-#define SET_ADDRESS     0x05
-#define GET_DESCRIPTOR  0x06
-#define SET_DESCRIPTOR  0x07
-#define GET_CONFIG      0x08
-#define SET_CONFIG      0x09
-#define GET_INTERFACE   0x0a
-#define SET_INTERFACE   0x0b
-#define SYNCH_FRAME     0x0c
-
-#define DEVICE          0x01
-#define CONFIGURATION   0x02
-#define STRING          0x03
-#define INTERFACE       0x04
-#define ENDPOINT        0x05
-
-/*-------------------------------------------------------------------------
- * SL11H/SL811H definition
- *-------------------------------------------------------------------------
- */
-#define DATA0_WR	0x07	// (Arm+Enable+tranmist to Host+DATA0)
-#define DATA1_WR	0x47	// (Arm+Enable+tranmist to Host on DATA1)
-#define ZDATA0_WR	0x05	// (Arm+Transaction Ignored+tranmist to Host+DATA0)
-#define ZDATA1_WR	0x45	// (Arm+Transaction Ignored+tranmist to Host+DATA1)
-#define DATA0_RD	0x03	// (Arm+Enable+received from Host+DATA0)
-#define DATA1_RD	0x43	// (Arm+Enable+received from Host+DATA1)
-
-#define PID_SETUP	0x2d	// USB Specification 1.1 Standard Definition
-#define PID_SOF		0xA5
-#define PID_IN		0x69
-#define PID_OUT		0xe1
-
-#define MAX_RETRY	0xffff
-#define TIMEOUT		5		/* 2 mseconds */
-
-#define SL11H_HOSTCTLREG	0
-#define SL11H_BUFADDRREG	1
-#define SL11H_BUFLNTHREG	2
-#define SL11H_PKTSTATREG	3	/* read */
-#define SL11H_PIDEPREG		3	/* write */
-#define SL11H_XFERCNTREG	4	/* read */
-#define SL11H_DEVADDRREG	4	/* write */
-#define SL11H_CTLREG1		5
-#define SL11H_INTENBLREG	6
-
-#define SL11H_HOSTCTLREG_B	8
-#define SL11H_BUFADDRREG_B	9
-#define SL11H_BUFLNTHREG_B	0x0A
-#define SL11H_PKTSTATREG_B	0x0B	/* read */
-#define SL11H_PIDEPREG_B	0x0B	/* write */
-#define SL11H_XFERCNTREG_B	0x0C	/* read */
-#define SL11H_DEVADDRREG_B	0x0C	/* write */
-
-#define SL11H_INTSTATREG	0x0D	/* write clears bitwise */
-#define SL11H_HWREVREG		0x0E	/* read */
-#define SL11H_SOFLOWREG		0x0E	/* write */
-#define SL11H_SOFTMRREG		0x0F	/* read */
-#define SL11H_CTLREG2		0x0F	/* write */
-#define SL11H_DATA_START	0x10
-
-/* Host control register bits (addr 0) */
-#define SL11H_HCTLMASK_ARM	1
-#define SL11H_HCTLMASK_ENBLEP	2
-#define SL11H_HCTLMASK_WRITE	4
-#define SL11H_HCTLMASK_ISOCH	0x10
-#define SL11H_HCTLMASK_AFTERSOF	0x20
-#define SL11H_HCTLMASK_SEQ	0x40
-#define SL11H_HCTLMASK_PREAMBLE	0x80
-
-/* Packet status register bits (addr 3) */
-#define SL11H_STATMASK_ACK	1
-#define SL11H_STATMASK_ERROR	2
-#define SL11H_STATMASK_TMOUT	4
-#define SL11H_STATMASK_SEQ	8
-#define SL11H_STATMASK_SETUP	0x10
-#define SL11H_STATMASK_OVF	0x20
-#define SL11H_STATMASK_NAK	0x40
-#define SL11H_STATMASK_STALL	0x80
-
-/* Control register 1 bits (addr 5) */
-#define SL11H_CTL1MASK_DSBLSOF	1
-#define SL11H_CTL1MASK_NOTXEOF2	4
-#define SL11H_CTL1MASK_DSTATE	0x18
-#define SL11H_CTL1MASK_NSPD	0x20
-#define SL11H_CTL1MASK_SUSPEND	0x40
-#define SL11H_CTL1MASK_CLK12	0x80
-
-#define SL11H_CTL1VAL_RESET	8
-
-/* Interrupt enable (addr 6) and interrupt status register bits (addr 0xD) */
-#define SL11H_INTMASK_XFERDONE	1
-#define SL11H_INTMASK_SOFINTR	0x10
-#define SL11H_INTMASK_INSRMV	0x20
-#define SL11H_INTMASK_USBRESET	0x40
-#define SL11H_INTMASK_DSTATE	0x80	/* only in status reg */
-
-/* HW rev and SOF lo register bits (addr 0xE) */
-#define SL11H_HWRMASK_HWREV	0xF0
-
-/* SOF counter and control reg 2 (addr 0xF) */
-#define SL11H_CTL2MASK_SOFHI	0x3F
-#define SL11H_CTL2MASK_DSWAP	0x40
-#define SL11H_CTL2MASK_HOSTMODE	0xae
-
diff -Nru a/drivers/usb/host/hc_sl811_rh.c b/drivers/usb/host/hc_sl811_rh.c
--- a/drivers/usb/host/hc_sl811_rh.c	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,583 +0,0 @@
-
-/*-------------------------------------------------------------------------*/
-/*-------------------------------------------------------------------------*
- * SL811HS virtual root hub
- *  
- * based on usb-ohci.c by R. Weissgaerber et al.
- *-------------------------------------------------------------------------*
- * 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
- *
- *-------------------------------------------------------------------------*/
-
-/* FIXME:  reuse the root hub framework in usbcore, shrinking this code.  */
-
-#ifdef DEBUG
-#undef DEBUG
-#endif
-static __u32 getPortStatusAndChange (hci_t * hci);
-static void setPortStatus (hci_t * hci, __u16 bitPos);
-static void setPortChange (hci_t * hci, __u16 bitPos);
-static void clrPortStatus (hci_t * hci, __u16 bitPos);
-static void clrPortChange (hci_t * hci, __u16 bitPos);
-static int USBReset (hci_t * hci);
-static int cc_to_error (int cc);
-
-/*-------------------------------------------------------------------------*
- * Virtual Root Hub 
- *-------------------------------------------------------------------------*/
-
-/* Device descriptor */
-static __u8 root_hub_dev_des[] = {
-	0x12,			/*  __u8  bLength; */
-	0x01,			/*  __u8  bDescriptorType; Device */
-	0x10,			/*  __u16 bcdUSB; v1.1 */
-	0x01,
-	0x09,			/*  __u8  bDeviceClass; HUB_CLASSCODE */
-	0x00,			/*  __u8  bDeviceSubClass; */
-	0x00,			/*  __u8  bDeviceProtocol; */
-	0x08,			/*  __u8  bMaxPacketSize0; 8 Bytes */
-	0x00,			/*  __u16 idVendor; */
-	0x00,
-	0x00,			/*  __u16 idProduct; */
-	0x00,
-	0x00,			/*  __u16 bcdDevice; */
-	0x00,
-	0x00,			/*  __u8  iManufacturer; */
-	0x02,			/*  __u8  iProduct; */
-	0x01,			/*  __u8  iSerialNumber; */
-	0x01			/*  __u8  bNumConfigurations; */
-};
-
-/* Configuration descriptor */
-static __u8 root_hub_config_des[] = {
-	0x09,			/*  __u8  bLength; */
-	0x02,			/*  __u8  bDescriptorType; Configuration */
-	0x19,			/*  __u16 wTotalLength; */
-	0x00,
-	0x01,			/*  __u8  bNumInterfaces; */
-	0x01,			/*  __u8  bConfigurationValue; */
-	0x00,			/*  __u8  iConfiguration; */
-	0x40,			/*  __u8  bmAttributes; 
-				   Bit 7: Bus-powered, 6: Self-powered, 5 Remote-wakwup, 
-				   4..0: resvd */
-	0x00,			/*  __u8  MaxPower; */
-
-	/* interface */
-	0x09,			/*  __u8  if_bLength; */
-	0x04,			/*  __u8  if_bDescriptorType; Interface */
-	0x00,			/*  __u8  if_bInterfaceNumber; */
-	0x00,			/*  __u8  if_bAlternateSetting; */
-	0x01,			/*  __u8  if_bNumEndpoints; */
-	0x09,			/*  __u8  if_bInterfaceClass; HUB_CLASSCODE */
-	0x00,			/*  __u8  if_bInterfaceSubClass; */
-	0x00,			/*  __u8  if_bInterfaceProtocol; */
-	0x00,			/*  __u8  if_iInterface; */
-
-	/* endpoint */
-	0x07,			/*  __u8  ep_bLength; */
-	0x05,			/*  __u8  ep_bDescriptorType; Endpoint */
-	0x81,			/*  __u8  ep_bEndpointAddress; IN Endpoint 1 */
-	0x03,			/*  __u8  ep_bmAttributes; Interrupt */
-	0x02,			/*  __u16 ep_wMaxPacketSize; ((MAX_ROOT_PORTS + 1) / 8 */
-	0x00,
-	0xff			/*  __u8  ep_bInterval; 255 ms */
-};
-
-/* Hub class-specific descriptor is constructed dynamically */
-
-/***************************************************************************
- * Function Name : rh_send_irq
- * 
- * This function examine the port change in the virtual root hub.
- * 
- * Note: This function assumes only one port exist in the root hub.
- *
- * Input:  hci = data structure for the host controller
- *         rh_data = The pointer to port change data
- *         rh_len = length of the data in bytes
- *
- * Return: length of data  
- **************************************************************************/
-static int rh_send_irq (hci_t * hci, void *rh_data, int rh_len)
-{
-	int num_ports;
-	int i;
-	int ret;
-	int len;
-	__u8 data[8];
-
-	DBGFUNC ("enter rh_send_irq: \n");
-
-	/* Assuming the root hub has one port.  This value need to change if
-	 * there are more than one port for the root hub
-	 */
-
-	num_ports = 1;
-
-	/* The root hub status is not implemented, it basically has two fields:
-	 *     -- Local Power Status
-	 *     -- Over Current Indicator
-	 *     -- Local Power Change
-	 *     -- Over Current Indicator
-	 *
-	 * Right now, It is assume the power is good and no changes 
-	 */
-
-	*(__u8 *) data = 0;
-
-	ret = *(__u8 *) data;
-
-	/* Has the port status change within the root hub: It checks for
-	 *      -- Port Connect Status change
-	 *      -- Port Enable Change
-	 */
-
-	for (i = 0; i < num_ports; i++) {
-		*(__u8 *) (data + (i + 1) / 8) |=
-		    (((getPortStatusAndChange (hci) >> 16) & (PORT_CONNECT_STAT | PORT_ENABLE_STAT)) ? 1 : 0) << ((i + 1) % 8);
-		ret += *(__u8 *) (data + (i + 1) / 8);
-
-		/* After the port change is read, it should be reset so the next time 
-		 * is it doesn't trigger a change again */
-
-	}
-	len = i / 8 + 1;
-
-	if (ret > 0) {
-		memcpy (rh_data, data, min (len, min (rh_len, (int)sizeof (data))));
-		return len;
-	}
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : rh_int_timer_do
- * 
- * This function is called when the timer expires.  It gets the the port 
- * change data and pass along to the upper protocol.
- * 
- * Note:  The virtual root hub interrupt pipe are polled by the timer
- *        every "interval" ms
- *
- * Input:  ptr = ptr to the urb
- *
- * Return: none  
- **************************************************************************/
-static void rh_int_timer_do (unsigned long ptr)
-{
-	int len;
-	struct urb *urb = (struct urb *) ptr;
-	hci_t *hci = urb->dev->bus->hcpriv;
-
-	DBGFUNC ("enter rh_int_timer_do\n");
-
-	if (hci->rh.send) {
-		len = rh_send_irq (hci, urb->transfer_buffer,
-				   urb->transfer_buffer_length);
-		if (len > 0) {
-			urb->actual_length = len;
-			if (urb_debug == 2)
-				urb_print (urb, "RET-t(rh)",
-					   usb_pipeout (urb->pipe));
-
-			if (urb->complete) {
-				urb->complete (urb, NULL);
-			}
-		}
-	}
-
-	/* re-activate the timer */
-	rh_init_int_timer (urb);
-}
-
-/***************************************************************************
- * Function Name : rh_init_int_timer
- * 
- * This function creates a timer that act as interrupt pipe in the
- * virtual hub.   
- * 
- * Note:  The virtual root hub's interrupt pipe are polled by the timer
- *        every "interval" ms
- *
- * Input: urb = USB request block 
- *
- * Return: 0  
- **************************************************************************/
-static int rh_init_int_timer (struct urb * urb)
-{
-	hci_t *hci = urb->dev->bus->hcpriv;
-	hci->rh.interval = urb->interval;
-
-	init_timer (&hci->rh.rh_int_timer);
-	hci->rh.rh_int_timer.function = rh_int_timer_do;
-	hci->rh.rh_int_timer.data = (unsigned long) urb;
-	hci->rh.rh_int_timer.expires = jiffies + (HZ * (urb->interval < 30 ? 30 : urb->interval)) / 1000;
-	add_timer (&hci->rh.rh_int_timer);
-
-	return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* for returning string descriptors in UTF-16LE */
-static int ascii2utf (char *ascii, __u8 *utf, int utfmax)
-{
-	int retval;
-
-	for (retval = 0; *ascii && utfmax > 1; utfmax -= 2, retval += 2) {
-		*utf++ = *ascii++ & 0x7f;
-		*utf++ = 0;
-	}
-	return retval;
-}
-
-static int root_hub_string (int id, int serial, char *type, __u8 *data, int len)
-{
-	char buf [30];
-
-	// assert (len > (2 * (sizeof (buf) + 1)));
-	// assert (strlen (type) <= 8);
-
-	// language ids
-	if (id == 0) {
-		*data++ = 4; *data++ = 3;	/* 4 bytes data */
-		*data++ = 0; *data++ = 0;	/* some language id */
-		return 4;
-
-	// serial number
-	} else if (id == 1) {
-		sprintf (buf, "%x", serial);
-
-	// product description
-	} else if (id == 2) {
-		sprintf (buf, "USB %s Root Hub", type);
-
-	// id 3 == vendor description
-
-	// unsupported IDs --> "stall"
-	} else
-	    return 0;
-
-	data [0] = 2 + ascii2utf (buf, data + 2, len - 2);
-	data [1] = 3;
-	return data [0];
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* helper macro */
-#define OK(x) 			len = (x); break
-
-/***************************************************************************
- * Function Name : rh_submit_urb
- * 
- * This function handles all USB request to the the virtual root hub
- * 
- * Input: urb = USB request block 
- *
- * Return: 0  
- **************************************************************************/
-static int rh_submit_urb (struct urb * urb)
-{
-	struct usb_device *usb_dev = urb->dev;
-	hci_t *hci = usb_dev->bus->hcpriv;
-	unsigned int pipe = urb->pipe;
-	struct usb_ctrlrequest *cmd = (struct usb_ctrlrequest *) urb->setup_packet;
-	void *data = urb->transfer_buffer;
-	int leni = urb->transfer_buffer_length;
-	int len = 0;
-	int status = TD_CC_NOERROR;
-	__u32 datab[4];
-	__u8 *data_buf = (__u8 *) datab;
-
-	__u16 bmRType_bReq;
-	__u16 wValue;
-	__u16 wIndex;
-	__u16 wLength;
-
-	DBGFUNC ("enter rh_submit_urb\n");
-	if (usb_pipeint (pipe)) {
-		hci->rh.urb = urb;
-		hci->rh.send = 1;
-		hci->rh.interval = urb->interval;
-		rh_init_int_timer (urb);
-		urb->status = cc_to_error (TD_CC_NOERROR);
-
-		return 0;
-	}
-
-	bmRType_bReq = cmd->bRequestType | (cmd->bRequest << 8);
-	wValue = le16_to_cpu (cmd->wValue);
-	wIndex = le16_to_cpu (cmd->wIndex);
-	wLength = le16_to_cpu (cmd->wLength);
-
-	DBG ("rh_submit_urb, req = %d(%x) len=%d",
-	     bmRType_bReq, bmRType_bReq, wLength);
-
-	switch (bmRType_bReq) {
-		/* Request Destination:
-		   without flags: Device, 
-		   RH_INTERFACE: interface, 
-		   RH_ENDPOINT: endpoint,
-		   RH_CLASS means HUB here, 
-		   RH_OTHER | RH_CLASS  almost ever means HUB_PORT here 
-		 */
-
-	case RH_GET_STATUS:
-		*(__u16 *) data_buf = cpu_to_le16 (1);
-		OK (2);
-
-	case RH_GET_STATUS | RH_INTERFACE:
-		*(__u16 *) data_buf = cpu_to_le16 (0);
-		OK (2);
-
-	case RH_GET_STATUS | RH_ENDPOINT:
-		*(__u16 *) data_buf = cpu_to_le16 (0);
-		OK (2);
-
-	case RH_GET_STATUS | RH_CLASS:
-		*(__u32 *) data_buf = cpu_to_le32 (0);
-		OK (4);
-
-	case RH_GET_STATUS | RH_OTHER | RH_CLASS:
-		*(__u32 *) data_buf =
-		    cpu_to_le32 (getPortStatusAndChange (hci));
-		OK (4);
-
-	case RH_CLEAR_FEATURE | RH_ENDPOINT:
-		switch (wValue) {
-		case (RH_ENDPOINT_STALL):
-			OK (0);
-		}
-		break;
-
-	case RH_CLEAR_FEATURE | RH_CLASS:
-		switch (wValue) {
-		case RH_C_HUB_LOCAL_POWER:
-			OK (0);
-
-		case (RH_C_HUB_OVER_CURRENT):
-			/* Over Current Not Implemented */
-			OK (0);
-		}
-		break;
-
-	case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
-		switch (wValue) {
-		case (RH_PORT_ENABLE):
-			clrPortStatus (hci, PORT_ENABLE_STAT);
-			OK (0);
-
-		case (RH_PORT_SUSPEND):
-			clrPortStatus (hci, PORT_SUSPEND_STAT);
-			OK (0);
-
-		case (RH_PORT_POWER):
-			clrPortStatus (hci, PORT_POWER_STAT);
-			OK (0);
-
-		case (RH_C_PORT_CONNECTION):
-			clrPortChange (hci, PORT_CONNECT_STAT);
-			OK (0);
-
-		case (RH_C_PORT_ENABLE):
-			clrPortChange (hci, PORT_ENABLE_STAT);
-			OK (0);
-
-		case (RH_C_PORT_SUSPEND):
-			clrPortChange (hci, PORT_SUSPEND_STAT);
-			OK (0);
-
-		case (RH_C_PORT_OVER_CURRENT):
-			clrPortChange (hci, PORT_OVER_CURRENT_STAT);
-			OK (0);
-
-		case (RH_C_PORT_RESET):
-			clrPortChange (hci, PORT_RESET_STAT);
-			OK (0);
-		}
-		break;
-
-	case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
-		switch (wValue) {
-		case (RH_PORT_SUSPEND):
-			setPortStatus (hci, PORT_SUSPEND_STAT);
-			OK (0);
-
-		case (RH_PORT_RESET):
-			setPortStatus (hci, PORT_RESET_STAT);
-			// USBReset(hci);
-			clrPortChange (hci,
-				       PORT_CONNECT_CHANGE | PORT_ENABLE_CHANGE
-				       | PORT_SUSPEND_CHANGE |
-				       PORT_OVER_CURRENT_CHANGE);
-			setPortChange (hci, PORT_RESET_CHANGE);
-			clrPortStatus (hci, PORT_RESET_STAT);
-			setPortStatus (hci, PORT_ENABLE_STAT);
-
-			OK (0);
-
-		case (RH_PORT_POWER):
-			setPortStatus (hci, PORT_POWER_STAT);
-			OK (0);
-
-		case (RH_PORT_ENABLE):
-			setPortStatus (hci, PORT_ENABLE_STAT);
-			OK (0);
-		}
-		break;
-
-	case RH_SET_ADDRESS:
-		hci->rh.devnum = wValue;
-		OK (0);
-
-	case RH_GET_DESCRIPTOR:
-		DBGVERBOSE ("rh_submit_urb: RH_GET_DESCRIPTOR, wValue = 0x%x\n", wValue);
-		switch ((wValue & 0xff00) >> 8) {
-		case (0x01):	/* device descriptor */
-			len = min (leni, min ((__u16)sizeof (root_hub_dev_des), wLength));
-			data_buf = root_hub_dev_des;
-			OK (len);
-
-		case (0x02):	/* configuration descriptor */
-			len = min (leni, min ((__u16)sizeof (root_hub_config_des), wLength));
-			data_buf = root_hub_config_des;
-			OK (len);
-
-		case (0x03):	/* string descriptors */
-			len = root_hub_string (wValue & 0xff, (int) (long) 0,
-						   "SL811HS", data, wLength);
-			if (len > 0) {
-				data_buf = data;
-				OK (min (leni, len));
-			}
-
-		default:
-			status = SL11H_STATMASK_STALL;
-		}
-		break;
-
-	case RH_GET_DESCRIPTOR | RH_CLASS:
-		data_buf[0] = 9;	// min length;
-		data_buf[1] = 0x29;
-		data_buf[2] = 1;	// # of downstream port
-		data_buf[3] = 0;
-		datab[1] = 0;
-		data_buf[5] = 50;	// 100 ms for port reset
-		data_buf[7] = 0xfc;	// which port is attachable
-		if (data_buf[2] < 7) {
-			data_buf[8] = 0xff;
-		} else {
-		}
-
-		len = min (leni, min ((__u16)data_buf[0], wLength));
-		OK (len);
-
-	case RH_GET_CONFIGURATION:
-		*(__u8 *) data_buf = 0x01;
-		OK (1);
-
-	case RH_SET_CONFIGURATION:
-		OK (0);
-
-	default:
-		DBGERR ("unsupported root hub command");
-		status = SL11H_STATMASK_STALL;
-	}
-
-	len = min (len, leni);
-	if (data != data_buf)
-		memcpy (data, data_buf, len);
-	urb->actual_length = len;
-	urb->status = cc_to_error (status);
-
-	urb->hcpriv = NULL;
-	urb->dev = NULL;
-	if (urb->complete) {
-		urb->complete (urb, NULL);
-	}
-
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : rh_unlink_urb
- * 
- * This function unlinks the URB 
- * 
- * Input: urb = USB request block 
- *
- * Return: 0  
- **************************************************************************/
-static int rh_unlink_urb (struct urb * urb)
-{
-	hci_t *hci = urb->dev->bus->hcpriv;
-
-	DBGFUNC ("enter rh_unlink_urb\n");
-	if (hci->rh.urb == urb) {
-		hci->rh.send = 0;
-		del_timer (&hci->rh.rh_int_timer);
-		hci->rh.urb = NULL;
-
-		urb->hcpriv = NULL;
-		usb_put_dev (urb->dev);
-		urb->dev = NULL;
-		if (urb->transfer_flags & URB_ASYNC_UNLINK) {
-			urb->status = -ECONNRESET;
-			if (urb->complete) {
-				urb->complete (urb, NULL);
-			}
-		} else
-			urb->status = -ENOENT;
-	}
-	return 0;
-}
-
-/***************************************************************************
- * Function Name : rh_connect_rh
- * 
- * This function connect the virtual root hub to the USB stack 
- * 
- * Input: urb = USB request block 
- *
- * Return: 0  
- **************************************************************************/
-static int rh_connect_rh (hci_t * hci)
-{
-	struct usb_device *usb_dev;
-	int retval;
-
-	hci->rh.devnum = 0;
-	usb_dev = usb_alloc_dev (NULL, hci->bus, 0);
-	if (!usb_dev)
-		return -ENOMEM;
-
-	usb_dev->devnum = 1;
-	usb_dev->bus->devnum_next = usb_dev->devnum + 1;
-	set_bit (usb_dev->devnum, usb_dev->bus->devmap.devicemap);
-
-	down (&usb_bus_list_lock);
-	hci->bus->root_hub = usb_dev;
-	retval = usb_new_device (usb_dev);
-	if (retval != 0)
-		hci->bus->root_hub = NULL;
-	up (&usb_bus_list_lock);
-	if (retval != 0) {
-		usb_put_dev (usb_dev);
-		return -ENODEV;
-	}
-
-	return 0;
-}
diff -Nru a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
--- a/drivers/usb/host/ohci-dbg.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/host/ohci-dbg.c	2004-12-24 13:37:18 -08:00
@@ -134,13 +134,13 @@
 	struct ohci_regs __iomem *regs = controller->regs;
 	u32			temp;
 
-	temp = ohci_readl (&regs->revision) & 0xff;
+	temp = ohci_readl (controller, &regs->revision) & 0xff;
 	ohci_dbg_sw (controller, next, size,
 		"OHCI %d.%d, %s legacy support registers\n",
 		0x03 & (temp >> 4), (temp & 0x0f),
 		(temp & 0x10) ? "with" : "NO");
 
-	temp = ohci_readl (&regs->control);
+	temp = ohci_readl (controller, &regs->control);
 	ohci_dbg_sw (controller, next, size,
 		"control 0x%03x%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n",
 		temp,
@@ -155,7 +155,7 @@
 		temp & OHCI_CTRL_CBSR
 		);
 
-	temp = ohci_readl (&regs->cmdstatus);
+	temp = ohci_readl (controller, &regs->cmdstatus);
 	ohci_dbg_sw (controller, next, size,
 		"cmdstatus 0x%05x SOC=%d%s%s%s%s\n", temp,
 		(temp & OHCI_SOC) >> 16,
@@ -166,26 +166,33 @@
 		);
 
 	ohci_dump_intr_mask (controller, "intrstatus",
-			ohci_readl (&regs->intrstatus), next, size);
+			ohci_readl (controller, &regs->intrstatus),
+			next, size);
 	ohci_dump_intr_mask (controller, "intrenable",
-			ohci_readl (&regs->intrenable), next, size);
+			ohci_readl (controller, &regs->intrenable),
+			next, size);
 	// intrdisable always same as intrenable
 
 	maybe_print_eds (controller, "ed_periodcurrent",
-			ohci_readl (&regs->ed_periodcurrent), next, size);
+			ohci_readl (controller, &regs->ed_periodcurrent),
+			next, size);
 
 	maybe_print_eds (controller, "ed_controlhead",
-			ohci_readl (&regs->ed_controlhead), next, size);
+			ohci_readl (controller, &regs->ed_controlhead),
+			next, size);
 	maybe_print_eds (controller, "ed_controlcurrent",
-			ohci_readl (&regs->ed_controlcurrent), next, size);
+			ohci_readl (controller, &regs->ed_controlcurrent),
+			next, size);
 
 	maybe_print_eds (controller, "ed_bulkhead",
-			ohci_readl (&regs->ed_bulkhead), next, size);
+			ohci_readl (controller, &regs->ed_bulkhead),
+			next, size);
 	maybe_print_eds (controller, "ed_bulkcurrent",
-			ohci_readl (&regs->ed_bulkcurrent), next, size);
+			ohci_readl (controller, &regs->ed_bulkcurrent),
+			next, size);
 
 	maybe_print_eds (controller, "donehead",
-			ohci_readl (&regs->donehead), next, size);
+			ohci_readl (controller, &regs->donehead), next, size);
 }
 
 #define dbg_port_sw(hc,num,value,next,size) \
@@ -269,7 +276,7 @@
 	ohci_dump_status (controller, NULL, NULL);
 	if (controller->hcca)
 		ohci_dbg (controller,
-			"hcca frame #%04x\n", OHCI_FRAME_NO(controller->hcca));
+			"hcca frame #%04x\n", ohci_frame_no(controller));
 	ohci_dump_roothub (controller, 1, NULL, NULL);
 }
 
@@ -279,13 +286,13 @@
 static void ohci_dump_td (const struct ohci_hcd *ohci, const char *label,
 		const struct td *td)
 {
-	u32	tmp = le32_to_cpup (&td->hwINFO);
+	u32	tmp = hc32_to_cpup (ohci, &td->hwINFO);
 
 	ohci_dbg (ohci, "%s td %p%s; urb %p index %d; hw next td %08x\n",
 		label, td,
 		(tmp & TD_DONE) ? " (DONE)" : "",
 		td->urb, td->index,
-		le32_to_cpup (&td->hwNextTD));
+		hc32_to_cpup (ohci, &td->hwNextTD));
 	if ((tmp & TD_ISO) == 0) {
 		const char	*toggle, *pid;
 		u32	cbp, be;
@@ -306,8 +313,8 @@
 			TD_CC_GET(tmp), /* EC, */ toggle,
 			(tmp & TD_DI) >> 21, pid,
 			(tmp & TD_R) ? "R" : "");
-		cbp = le32_to_cpup (&td->hwCBP);
-		be = le32_to_cpup (&td->hwBE);
+		cbp = hc32_to_cpup (ohci, &td->hwCBP);
+		be = hc32_to_cpup (ohci, &td->hwBE);
 		ohci_dbg (ohci, "     cbp %08x be %08x (len %d)\n", cbp, be,
 			cbp ? (be + 1 - cbp) : 0);
 	} else {
@@ -318,10 +325,10 @@
 			(tmp & TD_DI) >> 21,
 			tmp & 0x0000ffff);
 		ohci_dbg (ohci, "  bp0 %08x be %08x\n",
-			le32_to_cpup (&td->hwCBP) & ~0x0fff,
-			le32_to_cpup (&td->hwBE));
+			hc32_to_cpup (ohci, &td->hwCBP) & ~0x0fff,
+			hc32_to_cpup (ohci, &td->hwBE));
 		for (i = 0; i < MAXPSW; i++) {
-			u16	psw = le16_to_cpup (&td->hwPSW [i]);
+			u16	psw = hc16_to_cpup (ohci, &td->hwPSW [i]);
 			int	cc = (psw >> 12) & 0x0f;
 			ohci_dbg (ohci, "    psw [%d] = %2x, CC=%x %s=%d\n", i,
 				psw, cc,
@@ -336,33 +343,34 @@
 ohci_dump_ed (const struct ohci_hcd *ohci, const char *label,
 		const struct ed *ed, int verbose)
 {
-	__le32	tmp = ed->hwINFO;
+	u32	tmp = hc32_to_cpu (ohci, ed->hwINFO);
 	char	*type = "";
 
 	ohci_dbg (ohci, "%s, ed %p state 0x%x type %s; next ed %08x\n",
 		label,
 		ed, ed->state, edstring (ed->type),
-		le32_to_cpup (&ed->hwNextED));
+		hc32_to_cpup (ohci, &ed->hwNextED));
 	switch (tmp & (ED_IN|ED_OUT)) {
 	case ED_OUT: type = "-OUT"; break;
 	case ED_IN: type = "-IN"; break;
 	/* else from TDs ... control */
 	}
 	ohci_dbg (ohci,
-		"  info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", le32_to_cpu (tmp),
-		0x03ff & (le32_to_cpu (tmp) >> 16),
+		"  info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", tmp,
+		0x03ff & (tmp >> 16),
 		(tmp & ED_DEQUEUE) ? " DQ" : "",
 		(tmp & ED_ISO) ? " ISO" : "",
 		(tmp & ED_SKIP) ? " SKIP" : "",
 		(tmp & ED_LOWSPEED) ? " LOW" : "",
-		0x000f & (le32_to_cpu (tmp) >> 7),
+		0x000f & (tmp >> 7),
 		type,
-		0x007f & le32_to_cpu (tmp));
+		0x007f & tmp);
+	tmp = hc32_to_cpup (ohci, &ed->hwHeadP);
 	ohci_dbg (ohci, "  tds: head %08x %s%s tail %08x%s\n",
-		le32_to_cpup (&ed->hwHeadP),
-		(ed->hwHeadP & ED_C) ? data1 : data0,
-		(ed->hwHeadP & ED_H) ? " HALT" : "",
-		le32_to_cpup (&ed->hwTailP),
+		tmp,
+		(tmp & ED_C) ? data1 : data0,
+		(tmp & ED_H) ? " HALT" : "",
+		hc32_to_cpup (ohci, &ed->hwTailP),
 		verbose ? "" : " (not listing)");
 	if (verbose) {
 		struct list_head	*tmp;
@@ -394,13 +402,6 @@
 
 #else
 
-static inline struct ohci_hcd *dev_to_ohci (struct device *dev)
-{
-	struct usb_hcd	*hcd = dev_get_drvdata (dev);
-
-	return hcd_to_ohci (hcd);
-}
-
 static ssize_t
 show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
 {
@@ -415,23 +416,23 @@
 
 	/* dump a snapshot of the bulk or control schedule */
 	while (ed) {
-		__le32			info = ed->hwINFO;
-		u32			scratch = le32_to_cpup (&ed->hwINFO);
-		struct list_head	*entry;
-		struct td		*td;
+		u32		info = hc32_to_cpu (ohci, ed->hwINFO);
+		u32		headp = hc32_to_cpu (ohci, ed->hwHeadP);
+		struct list_head *entry;
+		struct td	*td;
 
 		temp = scnprintf (buf, size,
 			"ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
 			ed,
 			(info & ED_LOWSPEED) ? 'l' : 'f',
-			scratch & 0x7f,
-			(scratch >> 7) & 0xf,
+			info & 0x7f,
+			(info >> 7) & 0xf,
 			(info & ED_IN) ? "in" : "out",
-			0x03ff & (scratch >> 16),
-			scratch,
+			0x03ff & (info >> 16),
+			info,
 			(info & ED_SKIP) ? " s" : "",
-			(ed->hwHeadP & ED_H) ? " H" : "",
-			(ed->hwHeadP & ED_C) ? data1 : data0);
+			(headp & ED_H) ? " H" : "",
+			(headp & ED_C) ? data1 : data0);
 		size -= temp;
 		buf += temp;
 
@@ -439,21 +440,21 @@
 			u32		cbp, be;
 
 			td = list_entry (entry, struct td, td_list);
-			scratch = le32_to_cpup (&td->hwINFO);
-			cbp = le32_to_cpup (&td->hwCBP);
-			be = le32_to_cpup (&td->hwBE);
+			info = hc32_to_cpup (ohci, &td->hwINFO);
+			cbp = hc32_to_cpup (ohci, &td->hwCBP);
+			be = hc32_to_cpup (ohci, &td->hwBE);
 			temp = scnprintf (buf, size,
 					"\n\ttd %p %s %d cc=%x urb %p (%08x)",
 					td,
 					({ char *pid;
-					switch (scratch & TD_DP) {
+					switch (info & TD_DP) {
 					case TD_DP_SETUP: pid = "setup"; break;
 					case TD_DP_IN: pid = "in"; break;
 					case TD_DP_OUT: pid = "out"; break;
 					default: pid = "(?)"; break;
 					 } pid;}),
 					cbp ? (be + 1 - cbp) : 0,
-					TD_CC_GET (scratch), td->urb, scratch);
+					TD_CC_GET (info), td->urb, info);
 			size -= temp;
 			buf += temp;
 		}
@@ -541,8 +542,7 @@
 
 			/* show more info the first time around */
 			if (temp == seen_count) {
-				__le32	info = ed->hwINFO;
-				u32	scratch = le32_to_cpup (&ed->hwINFO);
+				u32	info = hc32_to_cpu (ohci, ed->hwINFO);
 				struct list_head	*entry;
 				unsigned		qlen = 0;
 
@@ -554,15 +554,17 @@
 					" (%cs dev%d ep%d%s-%s qlen %u"
 					" max %d %08x%s%s)",
 					(info & ED_LOWSPEED) ? 'l' : 'f',
-					scratch & 0x7f,
-					(scratch >> 7) & 0xf,
+					info & 0x7f,
+					(info >> 7) & 0xf,
 					(info & ED_IN) ? "in" : "out",
 					(info & ED_ISO) ? "iso" : "int",
 					qlen,
-					0x03ff & (scratch >> 16),
-					scratch,
+					0x03ff & (info >> 16),
+					info,
 					(info & ED_SKIP) ? " K" : "",
-					(ed->hwHeadP & ED_H) ? " H" : "");
+					(ed->hwHeadP &
+						cpu_to_hc32(ohci, ED_H)) ?
+ 							" H" : "");
 				size -= temp;
 				next += temp;
 
@@ -634,31 +636,31 @@
 	/* hcca */
 	if (ohci->hcca)
 		ohci_dbg_sw (ohci, &next, &size,
-			"hcca frame 0x%04x\n", OHCI_FRAME_NO(ohci->hcca));
+			"hcca frame 0x%04x\n", ohci_frame_no(ohci));
 
 	/* other registers mostly affect frame timings */
-	rdata = ohci_readl (&regs->fminterval);
+	rdata = ohci_readl (ohci, &regs->fminterval);
 	temp = scnprintf (next, size,
 			"fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n",
-			rdata, (rdata >> 31) ? " FIT" : "",
+			rdata, (rdata >> 31) ? "FIT " : "",
 			(rdata >> 16) & 0xefff, rdata & 0xffff);
 	size -= temp;
 	next += temp;
 
-	rdata = ohci_readl (&regs->fmremaining);
+	rdata = ohci_readl (ohci, &regs->fmremaining);
 	temp = scnprintf (next, size, "fmremaining 0x%08x %sFR=0x%04x\n",
-			rdata, (rdata >> 31) ? " FRT" : "",
+			rdata, (rdata >> 31) ? "FRT " : "",
 			rdata & 0x3fff);
 	size -= temp;
 	next += temp;
 
-	rdata = ohci_readl (&regs->periodicstart);
+	rdata = ohci_readl (ohci, &regs->periodicstart);
 	temp = scnprintf (next, size, "periodicstart 0x%04x\n",
 			rdata & 0x3fff);
 	size -= temp;
 	next += temp;
 
-	rdata = ohci_readl (&regs->lsthresh);
+	rdata = ohci_readl (ohci, &regs->lsthresh);
 	temp = scnprintf (next, size, "lsthresh 0x%04x\n",
 			rdata & 0x3fff);
 	size -= temp;
diff -Nru a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
--- a/drivers/usb/host/ohci-hcd.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/host/ohci-hcd.c	2004-12-24 13:36:18 -08:00
@@ -2,7 +2,7 @@
  * OHCI HCD (Host Controller Driver) for USB.
  *
  * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
- * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
+ * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
  * 
  * [ Initialisation is based on Linus'  ]
  * [ uhci code and gregs ohci fragments ]
@@ -109,7 +109,7 @@
 #include <asm/byteorder.h>
 
 
-#define DRIVER_VERSION "2004 Feb 02"
+#define DRIVER_VERSION "2004 Nov 08"
 #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell"
 #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver"
 
@@ -122,12 +122,26 @@
 #define	OHCI_INTR_INIT \
 	(OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_WDH)
 
+#ifdef __hppa__
+/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
+#define	IR_DISABLE
+#endif
+
+#ifdef CONFIG_ARCH_OMAP
+/* OMAP doesn't support IR (no SMM; not needed) */
+#define	IR_DISABLE
+#endif
+
 /*-------------------------------------------------------------------------*/
 
 static const char	hcd_name [] = "ohci_hcd";
 
 #include "ohci.h"
 
+static void ohci_dump (struct ohci_hcd *ohci, int verbose);
+static int ohci_init (struct ohci_hcd *ohci);
+static void ohci_stop (struct usb_hcd *hcd);
+
 #include "ohci-hub.c"
 #include "ohci-dbg.c"
 #include "ohci-mem.c"
@@ -139,6 +153,11 @@
 module_param (power_switching, bool, 0);
 MODULE_PARM_DESC (power_switching, "true (not default) to switch port power");
 
+/* Some boards leave IR set wrongly, since they fail BIOS/SMM handshakes */
+static int no_handshake = 0;
+module_param (no_handshake, bool, 0);
+MODULE_PARM_DESC (no_handshake, "true (not default) disables BIOS handshake");
+
 /*-------------------------------------------------------------------------*/
 
 /*
@@ -241,7 +260,7 @@
 		if (retval < 0)
 			goto fail0;
 		if (ed->type == PIPE_ISOCHRONOUS) {
-			u16	frame = OHCI_FRAME_NO(ohci->hcca);
+			u16	frame = ohci_frame_no(ohci);
 
 			/* delay a few frames before the first TD */
 			frame += max_t (u16, 8, ed->interval);
@@ -384,34 +403,35 @@
 {
 	struct ohci_hcd		*ohci = hcd_to_ohci (hcd);
 
-	return OHCI_FRAME_NO(ohci->hcca);
+	return ohci_frame_no(ohci);
+}
+
+static void ohci_usb_reset (struct ohci_hcd *ohci)
+{
+	ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
+	ohci->hc_control &= OHCI_CTRL_RWC;
+	ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
 }
 
 /*-------------------------------------------------------------------------*
  * HC functions
  *-------------------------------------------------------------------------*/
 
-/* reset the HC and BUS */
+/* init memory, and kick BIOS/SMM off */
 
-static int hc_reset (struct ohci_hcd *ohci)
+static int ohci_init (struct ohci_hcd *ohci)
 {
 	u32 temp;
+	int ret;
 
-	/* boot firmware should have set this up (5.1.1.3.1) */
-	if (!ohci->fminterval) {
-		temp = ohci_readl (&ohci->regs->fminterval);
-		if (temp & 0x3fff0000)
-			ohci->fminterval = temp;
-		else
-			ohci->fminterval = DEFAULT_FMINTERVAL;
-		/* also: power/overcurrent flags in roothub.a */
-	}
+	disable (ohci);
+	ohci->regs = ohci->hcd.regs;
+	ohci->next_statechange = jiffies;
 
-	/* SMM owns the HC?  not for long!
-	 * On PA-RISC, PDC can leave IR set incorrectly; ignore it there.
-	 */
-#ifndef __hppa__
-	if (ohci_readl (&ohci->regs->control) & OHCI_CTRL_IR) {
+#ifndef IR_DISABLE
+	/* SMM owns the HC?  not for long! */
+	if (!no_handshake && ohci_readl (ohci,
+					&ohci->regs->control) & OHCI_CTRL_IR) {
 		ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n");
 
 		/* this timeout is arbitrary.  we make it long, so systems
@@ -420,50 +440,123 @@
 		 */
 		temp = 500;	/* arbitrary: five seconds */
 
-		writel (OHCI_INTR_OC, &ohci->regs->intrenable);
-		writel (OHCI_OCR, &ohci->regs->cmdstatus);
-		while (ohci_readl (&ohci->regs->control) & OHCI_CTRL_IR) {
+		ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable);
+		ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus);
+		while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) {
 			msleep (10);
 			if (--temp == 0) {
 				ohci_err (ohci, "USB HC TakeOver failed!\n");
-				return -1;
+				return -EBUSY;
 			}
 		}
+		ohci_usb_reset (ohci);
 	}
 #endif
 
 	/* Disable HC interrupts */
-	writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
+	ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
+	// flush the writes
+	(void) ohci_readl (ohci, &ohci->regs->control);
 
-	ohci_dbg (ohci, "reset, control = 0x%x\n",
-		  ohci_readl (&ohci->regs->control));
+	if (ohci->hcca)
+		return 0;
 
-  	/* Reset USB (needed by some controllers); RemoteWakeupConnected
+	ohci->hcca = dma_alloc_coherent (ohci->hcd.self.controller,
+			sizeof *ohci->hcca, &ohci->hcca_dma, 0);
+	if (!ohci->hcca)
+		return -ENOMEM;
+
+	if ((ret = ohci_mem_init (ohci)) < 0)
+		ohci_stop (&ohci->hcd);
+
+	return ret;
+
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* Start an OHCI controller, set the BUS operational
+ * resets USB and controller
+ * enable interrupts 
+ * connect the virtual root hub
+ */
+static int ohci_run (struct ohci_hcd *ohci)
+{
+  	u32			mask, temp;
+  	struct usb_device	*udev;
+  	struct usb_bus		*bus;
+	int			first = ohci->fminterval == 0;
+
+	disable (ohci);
+
+	/* boot firmware should have set this up (5.1.1.3.1) */
+	if (first) {
+
+		temp = ohci_readl (ohci, &ohci->regs->fminterval);
+		ohci->fminterval = temp & 0x3fff;
+		if (ohci->fminterval != FI)
+			ohci_dbg (ohci, "fminterval delta %d\n",
+				ohci->fminterval - FI);
+		ohci->fminterval |= FSMP (ohci->fminterval) << 16;
+		/* also: power/overcurrent flags in roothub.a */
+	}
+
+  	/* Reset USB nearly "by the book".  RemoteWakeupConnected
 	 * saved if boot firmware (BIOS/SMM/...) told us it's connected
 	 * (for OHCI integrated on mainboard, it normally is)
 	 */
-	ohci->hc_control = ohci_readl (&ohci->regs->control);
-	ohci->hc_control &= OHCI_CTRL_RWC;	/* hcfs 0 = RESET */
-	if (ohci->hc_control)
+	ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
+	ohci_dbg (ohci, "resetting from state '%s', control = 0x%x\n",
+			hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS),
+			ohci->hc_control);
+
+	if (ohci->hc_control & OHCI_CTRL_RWC
+			&& !(ohci->flags & OHCI_QUIRK_AMD756))
 		ohci->hcd.can_wakeup = 1;
-	writel (ohci->hc_control, &ohci->regs->control);
+
+	switch (ohci->hc_control & OHCI_CTRL_HCFS) {
+	case OHCI_USB_OPER:
+		temp = 0;
+		break;
+	case OHCI_USB_SUSPEND:
+	case OHCI_USB_RESUME:
+		ohci->hc_control &= OHCI_CTRL_RWC;
+		ohci->hc_control |= OHCI_USB_RESUME;
+		temp = 10 /* msec wait */;
+		break;
+	// case OHCI_USB_RESET:
+	default:
+		ohci->hc_control &= OHCI_CTRL_RWC;
+		ohci->hc_control |= OHCI_USB_RESET;
+		temp = 50 /* msec wait */;
+		break;
+	}
+	ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+	// flush the writes
+	(void) ohci_readl (ohci, &ohci->regs->control);
+	msleep(temp);
 	if (power_switching) {
 		unsigned ports = roothub_a (ohci) & RH_A_NDP; 
 
 		/* power down each port */
 		for (temp = 0; temp < ports; temp++)
-			writel (RH_PS_LSDA,
+			ohci_writel (ohci, RH_PS_LSDA,
 				&ohci->regs->roothub.portstatus [temp]);
 	}
-	// flush those pci writes
-	(void) ohci_readl (&ohci->regs->control);
-	msleep (50);
+	// flush those writes
+	(void) ohci_readl (ohci, &ohci->regs->control);
+	memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
+
+	/* 2msec timelimit here means no irqs/preempt */
+	spin_lock_irq (&ohci->lock);
 
+retry:
 	/* HC Reset requires max 10 us delay */
-	writel (OHCI_HCR,  &ohci->regs->cmdstatus);
+	ohci_writel (ohci, OHCI_HCR,  &ohci->regs->cmdstatus);
 	temp = 30;	/* ... allow extra time */
-	while ((ohci_readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
+	while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
 		if (--temp == 0) {
+			spin_unlock_irq (&ohci->lock);
 			ohci_err (ohci, "USB HC reset timed out!\n");
 			return -1;
 		}
@@ -476,102 +569,103 @@
 	 * ... but some hardware won't init fmInterval "by the book"
 	 * (SiS, OPTi ...), so reset again instead.  SiS doesn't need
 	 * this if we write fmInterval after we're OPERATIONAL.
+	 * Unclear about ALi, ServerWorks, and others ... this could
+	 * easily be a longstanding bug in chip init on Linux.
 	 */
-	writel (ohci->hc_control, &ohci->regs->control);
-	// flush those pci writes
-	(void) ohci_readl (&ohci->regs->control);
-
-	return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* Start an OHCI controller, set the BUS operational
- * enable interrupts 
- * connect the virtual root hub
- */
-static int hc_start (struct ohci_hcd *ohci)
-{
-  	u32			mask, tmp;
-  	struct usb_device	*udev;
-  	struct usb_bus		*bus;
-
-	disable (ohci);
+	if (ohci->flags & OHCI_QUIRK_INITRESET) {
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+		// flush those writes
+		(void) ohci_readl (ohci, &ohci->regs->control);
+	}
+	ohci_writel (ohci, ohci->fminterval, &ohci->regs->fminterval);
 
 	/* Tell the controller where the control and bulk lists are
 	 * The lists are empty now. */
-	writel (0, &ohci->regs->ed_controlhead);
-	writel (0, &ohci->regs->ed_bulkhead);
+	ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
+	ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
 
 	/* a reset clears this */
-	writel ((u32) ohci->hcca_dma, &ohci->regs->hcca);
+	ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
 
 	periodic_reinit (ohci);
 
 	/* some OHCI implementations are finicky about how they init.
 	 * bogus values here mean not even enumeration could work.
 	 */
-	if ((ohci_readl (&ohci->regs->fminterval) & 0x3fff0000) == 0
-			|| !ohci_readl (&ohci->regs->periodicstart)) {
-		ohci_err (ohci, "init err\n");
+	if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0
+			|| !ohci_readl (ohci, &ohci->regs->periodicstart)) {
+		if (!(ohci->flags & OHCI_QUIRK_INITRESET)) {
+			ohci->flags |= OHCI_QUIRK_INITRESET;
+			ohci_dbg (ohci, "enabling initreset quirk\n");
+			goto retry;
+		}
+		spin_unlock_irq (&ohci->lock);
+		ohci_err (ohci, "init err (%08x %04x)\n",
+			ohci_readl (ohci, &ohci->regs->fminterval),
+			ohci_readl (ohci, &ohci->regs->periodicstart));
 		return -EOVERFLOW;
 	}
 
  	/* start controller operations */
 	ohci->hc_control &= OHCI_CTRL_RWC;
  	ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
- 	writel (ohci->hc_control, &ohci->regs->control);
+ 	ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
 	ohci->hcd.state = USB_STATE_RUNNING;
 
 	/* wake on ConnectStatusChange, matching external hubs */
-	writel (RH_HS_DRWE, &ohci->regs->roothub.status);
+	ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status);
 
 	/* Choose the interrupts we care about now, others later on demand */
 	mask = OHCI_INTR_INIT;
-	writel (mask, &ohci->regs->intrstatus);
-	writel (mask, &ohci->regs->intrenable);
+	ohci_writel (ohci, mask, &ohci->regs->intrstatus);
+	ohci_writel (ohci, mask, &ohci->regs->intrenable);
 
 	/* handle root hub init quirks ... */
-	tmp = roothub_a (ohci);
-	tmp &= ~(RH_A_PSM | RH_A_OCPM);
+	temp = roothub_a (ohci);
+	temp &= ~(RH_A_PSM | RH_A_OCPM);
 	if (ohci->flags & OHCI_QUIRK_SUPERIO) {
 		/* NSC 87560 and maybe others */
-		tmp |= RH_A_NOCP;
-		tmp &= ~(RH_A_POTPGT | RH_A_NPS);
+		temp |= RH_A_NOCP;
+		temp &= ~(RH_A_POTPGT | RH_A_NPS);
 	} else if (power_switching) {
 		/* act like most external hubs:  use per-port power
 		 * switching and overcurrent reporting.
 		 */
-		tmp &= ~(RH_A_NPS | RH_A_NOCP);
-		tmp |= RH_A_PSM | RH_A_OCPM;
+		temp &= ~(RH_A_NPS | RH_A_NOCP);
+		temp |= RH_A_PSM | RH_A_OCPM;
 	} else {
 		/* hub power always on; required for AMD-756 and some
 		 * Mac platforms.  ganged overcurrent reporting, if any.
 		 */
-		tmp |= RH_A_NPS;
+		temp |= RH_A_NPS;
 	}
-	writel (tmp, &ohci->regs->roothub.a);
-	writel (RH_HS_LPSC, &ohci->regs->roothub.status);
-	writel (power_switching ? RH_B_PPCM : 0, &ohci->regs->roothub.b);
-	// flush those pci writes
-	(void) ohci_readl (&ohci->regs->control);
+	ohci_writel (ohci, temp, &ohci->regs->roothub.a);
+	ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
+	ohci_writel (ohci, power_switching ? RH_B_PPCM : 0,
+						&ohci->regs->roothub.b);
+	// flush those writes
+	(void) ohci_readl (ohci, &ohci->regs->control);
+
+	spin_unlock_irq (&ohci->lock);
 
 	// POTPGT delay is bits 24-31, in 2 ms units.
 	mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
 	bus = hcd_to_bus (&ohci->hcd);
+	ohci->hcd.state = USB_STATE_RUNNING;
+
+	ohci_dump (ohci, 1);
 
-	if (bus->root_hub) {
-		ohci->hcd.state = USB_STATE_RUNNING;
+	udev = hcd_to_bus (&ohci->hcd)->root_hub;
+	if (udev) {
 		return 0;
 	}
  
 	/* connect the virtual root hub */
 	udev = usb_alloc_dev (NULL, bus, 0);
-	ohci->hcd.state = USB_STATE_RUNNING;
 	if (!udev) {
 		disable (ohci);
 		ohci->hc_control &= ~OHCI_CTRL_HCFS;
-		writel (ohci->hc_control, &ohci->regs->control);
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
 		return -ENOMEM;
 	}
 
@@ -580,10 +674,13 @@
 		usb_put_dev (udev);
 		disable (ohci);
 		ohci->hc_control &= ~OHCI_CTRL_HCFS;
-		writel (ohci->hc_control, &ohci->regs->control);
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
 		return -ENODEV;
 	}
+	if (ohci->power_budget)
+		hub_set_power_budget(udev, ohci->power_budget);
 
+	create_debug_files (ohci);
 	return 0;
 }
 
@@ -600,17 +697,18 @@
 	/* we can eliminate a (slow) ohci_readl()
 	   if _only_ WDH caused this irq */
 	if ((ohci->hcca->done_head != 0)
-			&& ! (le32_to_cpup (&ohci->hcca->done_head) & 0x01)) {
+			&& ! (hc32_to_cpup (ohci, &ohci->hcca->done_head)
+				& 0x01)) {
 		ints =  OHCI_INTR_WDH;
 
 	/* cardbus/... hardware gone before remove() */
-	} else if ((ints = ohci_readl (&regs->intrstatus)) == ~(u32)0) {
+	} else if ((ints = ohci_readl (ohci, &regs->intrstatus)) == ~(u32)0) {
 		disable (ohci);
 		ohci_dbg (ohci, "device removed!\n");
 		return IRQ_HANDLED;
 
 	/* interrupt for some other device? */
-	} else if ((ints &= ohci_readl (&regs->intrenable)) == 0) {
+	} else if ((ints &= ohci_readl (ohci, &regs->intrenable)) == 0) {
 		return IRQ_NONE;
 	} 
 
@@ -620,7 +718,7 @@
 		// e.g. due to PCI Master/Target Abort
 
 		ohci_dump (ohci, 1);
-		hc_reset (ohci);
+		ohci_usb_reset (ohci);
 	}
 
 	if (ints & OHCI_INTR_RD) {
@@ -630,12 +728,12 @@
 
 	if (ints & OHCI_INTR_WDH) {
 		if (HCD_IS_RUNNING(hcd->state))
-			writel (OHCI_INTR_WDH, &regs->intrdisable);	
+			ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrdisable);	
 		spin_lock (&ohci->lock);
 		dl_done_list (ohci, ptregs);
 		spin_unlock (&ohci->lock);
 		if (HCD_IS_RUNNING(hcd->state))
-			writel (OHCI_INTR_WDH, &regs->intrenable); 
+			ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable); 
 	}
   
 	/* could track INTR_SO to reduce available PCI/... bandwidth */
@@ -645,18 +743,17 @@
 	 */
 	spin_lock (&ohci->lock);
 	if (ohci->ed_rm_list)
-		finish_unlinks (ohci, OHCI_FRAME_NO(ohci->hcca),
-				ptregs);
+		finish_unlinks (ohci, ohci_frame_no(ohci), ptregs);
 	if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list
 			&& HCD_IS_RUNNING(ohci->hcd.state))
-		writel (OHCI_INTR_SF, &regs->intrdisable);	
+		ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);	
 	spin_unlock (&ohci->lock);
 
 	if (HCD_IS_RUNNING(ohci->hcd.state)) {
-		writel (ints, &regs->intrstatus);
-		writel (OHCI_INTR_MIE, &regs->intrenable);	
-		// flush those pci writes
-		(void) ohci_readl (&ohci->regs->control);
+		ohci_writel (ohci, ints, &regs->intrstatus);
+		ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);	
+		// flush those writes
+		(void) ohci_readl (ohci, &ohci->regs->control);
 	}
 
 	return IRQ_HANDLED;
@@ -674,10 +771,9 @@
 	ohci_dump (ohci, 1);
 
 	flush_scheduled_work();
-	if (HCD_IS_RUNNING(ohci->hcd.state))
-		hc_reset (ohci);
-	else
-		writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
+
+	ohci_usb_reset (ohci);
+	ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
 	
 	remove_debug_files (ohci);
 	ohci_mem_cleanup (ohci);
@@ -696,23 +792,12 @@
 
 #if	defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM)
 
-static void mark_children_gone (struct usb_device *dev)
-{
-	unsigned i;
-
-	for (i = 0; i < dev->maxchild; i++) {
-		if (dev->children [i] == 0)
-			continue;
-		dev->children [i]->state = USB_STATE_NOTATTACHED;
-		mark_children_gone (dev->children [i]);
-	}
-}
-
-static int hc_restart (struct ohci_hcd *ohci)
+static int ohci_restart (struct ohci_hcd *ohci)
 {
 	int temp;
 	int i;
 	struct urb_priv *priv;
+	struct usb_device *root = ohci->hcd.self.root_hub;
 
 	/* mark any devices gone, so they do nothing till khubd disconnects.
 	 * recycle any "live" eds/tds (and urbs) right away.
@@ -721,7 +806,11 @@
 	 */ 
 	spin_lock_irq(&ohci->lock);
 	disable (ohci);
-	mark_children_gone (ohci->hcd.self.root_hub);
+	for (i = 0; i < root->maxchild; i++) {
+		if (root->children [i])
+			usb_set_device_state (root->children[i],
+				USB_STATE_NOTATTACHED);
+	}
 	if (!list_empty (&ohci->pending))
 		ohci_dbg(ohci, "abort schedule...\n");
 	list_for_each_entry (priv, &ohci->pending, pending) {
@@ -731,7 +820,7 @@
 		switch (ed->state) {
 		case ED_OPER:
 			ed->state = ED_UNLINK;
-			ed->hwINFO |= ED_DEQUEUE;
+			ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE);
 			ed_deschedule (ohci, ed);
 
 			ed->ed_next = ohci->ed_rm_list;
@@ -765,7 +854,7 @@
 	ohci->ed_controltail = NULL;
 	ohci->ed_bulktail    = NULL;
 
-	if ((temp = hc_reset (ohci)) < 0 || (temp = hc_start (ohci)) < 0) {
+	if ((temp = ohci_run (ohci)) < 0) {
 		ohci_err (ohci, "can't restart, %d\n", temp);
 		return temp;
 	} else {
@@ -775,12 +864,9 @@
 		 */
 		i = roothub_a (ohci) & RH_A_NDP;
 		while (i--)
-			writel (RH_PS_PSS,
+			ohci_writel (ohci, RH_PS_PSS,
 				&ohci->regs->roothub.portstatus [temp]);
-		ohci->hcd.self.root_hub->dev.power.power_state = 0;
-		ohci->hcd.state = USB_STATE_RUNNING;
 		ohci_dbg (ohci, "restart complete\n");
-		ohci_dump (ohci, 1);
 	}
 	return 0;
 }
@@ -810,10 +896,25 @@
 #include "ohci-lh7a404.c"
 #endif
 
+#ifdef CONFIG_PXA27x
+#include "ohci-pxa27x.c"
+#endif
+
 #if !(defined(CONFIG_PCI) \
       || defined(CONFIG_SA1111) \
       || defined(CONFIG_ARCH_OMAP) \
       || defined (CONFIG_ARCH_LH7A404) \
+      || defined (CONFIG_PXA27x) \
 	)
 #error "missing bus glue for ohci-hcd"
+#endif
+
+#if	!defined(HAVE_HNP) && defined(CONFIG_USB_OTG)
+
+#warning non-OTG configuration, too many HCDs
+
+static void start_hnp(struct ohci_hcd *ohci)
+{
+	/* "can't happen" */
+}
 #endif
diff -Nru a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
--- a/drivers/usb/host/ohci-hub.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/host/ohci-hub.c	2004-12-24 13:36:18 -08:00
@@ -2,7 +2,7 @@
  * OHCI HCD (Host Controller Driver) for USB.
  * 
  * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
- * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
+ * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
  * 
  * This file is licenced under GPL
  */
@@ -11,34 +11,8 @@
 
 /*
  * OHCI Root Hub ... the nonsharable stuff
- *
- * Registers don't need cpu_to_le32, that happens transparently
  */
 
-/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
- * The erratum (#4) description is incorrect.  AMD's workaround waits
- * till some bits (mostly reserved) are clear; ok for all revs.
- */
-#define read_roothub(hc, register, mask) ({ \
-	u32 temp = ohci_readl (&hc->regs->roothub.register); \
-	if (temp == -1) \
-		disable (hc); \
-	else if (hc->flags & OHCI_QUIRK_AMD756) \
-		while (temp & mask) \
-			temp = ohci_readl (&hc->regs->roothub.register); \
-	temp; })
-
-static u32 roothub_a (struct ohci_hcd *hc)
-	{ return read_roothub (hc, a, 0xfc0fe000); }
-static inline u32 roothub_b (struct ohci_hcd *hc)
-	{ return ohci_readl (&hc->regs->roothub.b); }
-static inline u32 roothub_status (struct ohci_hcd *hc)
-	{ return ohci_readl (&hc->regs->roothub.status); }
-static u32 roothub_portstatus (struct ohci_hcd *hc, int i)
-	{ return read_roothub (hc, portstatus [i], 0xffe0fce0); }
-
-/*-------------------------------------------------------------------------*/
-
 #define dbg_port(hc,label,num,value) \
 	ohci_dbg (hc, \
 		"%s roothub.portstatus [%d] " \
@@ -69,36 +43,32 @@
 
 static void dl_done_list (struct ohci_hcd *, struct pt_regs *);
 static void finish_unlinks (struct ohci_hcd *, u16 , struct pt_regs *);
+static int ohci_restart (struct ohci_hcd *ohci);
 
 static int ohci_hub_suspend (struct usb_hcd *hcd)
 {
 	struct ohci_hcd		*ohci = hcd_to_ohci (hcd);
-	struct usb_device	*root = hcd_to_bus (&ohci->hcd)->root_hub;
 	int			status = 0;
+	unsigned long		flags;
 
-	if (root->dev.power.power_state != 0)
-		return 0;
-	if (time_before (jiffies, ohci->next_statechange))
-		return -EAGAIN;
-
-	spin_lock_irq (&ohci->lock);
+	spin_lock_irqsave (&ohci->lock, flags);
 
-	ohci->hc_control = ohci_readl (&ohci->regs->control);
+	ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
 	switch (ohci->hc_control & OHCI_CTRL_HCFS) {
 	case OHCI_USB_RESUME:
 		ohci_dbg (ohci, "resume/suspend?\n");
 		ohci->hc_control &= ~OHCI_CTRL_HCFS;
 		ohci->hc_control |= OHCI_USB_RESET;
-		writel (ohci->hc_control, &ohci->regs->control);
-		(void) ohci_readl (&ohci->regs->control);
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+		(void) ohci_readl (ohci, &ohci->regs->control);
 		/* FALL THROUGH */
 	case OHCI_USB_RESET:
 		status = -EBUSY;
 		ohci_dbg (ohci, "needs reinit!\n");
 		goto done;
 	case OHCI_USB_SUSPEND:
-		ohci_dbg (ohci, "already suspended?\n");
-		goto succeed;
+		ohci_dbg (ohci, "already suspended\n");
+		goto done;
 	}
 	ohci_dbg (ohci, "suspend root hub\n");
 
@@ -108,9 +78,9 @@
 		int		limit;
 
 		ohci->hc_control &= ~OHCI_SCHED_ENABLES;
-		writel (ohci->hc_control, &ohci->regs->control);
-		ohci->hc_control = ohci_readl (&ohci->regs->control);
-		writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+		ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
+		ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus);
 
 		/* sched disables take effect on the next frame,
 		 * then the last WDH could take 6+ msec
@@ -120,15 +90,17 @@
 		while (limit > 0) {
 			udelay (250);
 			limit =- 250;
-			if (ohci_readl (&ohci->regs->intrstatus) & OHCI_INTR_SF)
+			if (ohci_readl (ohci, &ohci->regs->intrstatus)
+					& OHCI_INTR_SF)
 				break;
 		}
 		dl_done_list (ohci, NULL);
 		mdelay (7);
 	}
 	dl_done_list (ohci, NULL);
-	finish_unlinks (ohci, OHCI_FRAME_NO(ohci->hcca), NULL);
-	writel (ohci_readl (&ohci->regs->intrstatus), &ohci->regs->intrstatus);
+	finish_unlinks (ohci, ohci_frame_no(ohci), NULL);
+	ohci_writel (ohci, ohci_readl (ohci, &ohci->regs->intrstatus),
+			&ohci->regs->intrstatus);
 
 	/* maybe resume can wake root hub */
 	if (ohci->hcd.remote_wakeup)
@@ -139,19 +111,16 @@
 	/* Suspend hub */
 	ohci->hc_control &= ~OHCI_CTRL_HCFS;
 	ohci->hc_control |= OHCI_USB_SUSPEND;
-	writel (ohci->hc_control, &ohci->regs->control);
-	(void) ohci_readl (&ohci->regs->control);
+	ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+	(void) ohci_readl (ohci, &ohci->regs->control);
 
 	/* no resumes until devices finish suspending */
 	ohci->next_statechange = jiffies + msecs_to_jiffies (5);
 
-succeed:
-	/* it's not USB_STATE_SUSPENDED unless access to this
-	 * hub from the non-usb side (PCI, SOC, etc) stopped 
-	 */
-	root->dev.power.power_state = 3;
 done:
-	spin_unlock_irq (&ohci->lock);
+	if (status == 0)
+		ohci->hcd.state = HCD_STATE_SUSPENDED;
+	spin_unlock_irqrestore (&ohci->lock, flags);
 	return status;
 }
 
@@ -163,29 +132,36 @@
 	return ed;
 }
 
-static int hc_restart (struct ohci_hcd *ohci);
-
-/* caller owns root->serialize */
+/* caller has locked the root hub */
 static int ohci_hub_resume (struct usb_hcd *hcd)
 {
 	struct ohci_hcd		*ohci = hcd_to_ohci (hcd);
-	struct usb_device	*root = hcd_to_bus (&ohci->hcd)->root_hub;
 	u32			temp, enables;
 	int			status = -EINPROGRESS;
 
-	if (!root->dev.power.power_state)
-		return 0;
 	if (time_before (jiffies, ohci->next_statechange))
-		return -EAGAIN;
+		msleep(5);
 
 	spin_lock_irq (&ohci->lock);
-	ohci->hc_control = ohci_readl (&ohci->regs->control);
-	switch (ohci->hc_control & OHCI_CTRL_HCFS) {
+	ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
+
+	if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
+		/* this can happen after suspend-to-disk */
+		if (hcd->state == USB_STATE_RESUMING) {
+			ohci_dbg (ohci, "BIOS/SMM active, control %03x\n",
+					ohci->hc_control);
+			status = -EBUSY;
+		/* this happens when pmcore resumes HC then root */
+		} else {
+			ohci_dbg (ohci, "duplicate resume\n");
+			status = 0;
+		}
+	} else switch (ohci->hc_control & OHCI_CTRL_HCFS) {
 	case OHCI_USB_SUSPEND:
 		ohci->hc_control &= ~(OHCI_CTRL_HCFS|OHCI_SCHED_ENABLES);
 		ohci->hc_control |= OHCI_USB_RESUME;
-		writel (ohci->hc_control, &ohci->regs->control);
-		(void) ohci_readl (&ohci->regs->control);
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+		(void) ohci_readl (ohci, &ohci->regs->control);
 		ohci_dbg (ohci, "resume root hub\n");
 		break;
 	case OHCI_USB_RESUME:
@@ -194,7 +170,6 @@
 		break;
 	case OHCI_USB_OPER:
 		ohci_dbg (ohci, "odd resume\n");
-		root->dev.power.power_state = 0;
 		status = 0;
 		break;
 	default:		/* RESET, we lost power */
@@ -202,27 +177,31 @@
 		status = -EBUSY;
 	}
 	spin_unlock_irq (&ohci->lock);
-	if (status == -EBUSY)
-		return hc_restart (ohci);
+	if (status == -EBUSY) {
+		(void) ohci_init (ohci);
+		return ohci_restart (ohci);
+	}
 	if (status != -EINPROGRESS)
 		return status;
 
 	temp = roothub_a (ohci) & RH_A_NDP;
 	enables = 0;
 	while (temp--) {
-		u32 stat = ohci_readl (&ohci->regs->roothub.portstatus [temp]);
+		u32 stat = ohci_readl (ohci,
+				       &ohci->regs->roothub.portstatus [temp]);
 
 		/* force global, not selective, resume */
 		if (!(stat & RH_PS_PSS))
 			continue;
-		writel (RH_PS_POCI, &ohci->regs->roothub.portstatus [temp]);
+		ohci_writel (ohci, RH_PS_POCI,
+				&ohci->regs->roothub.portstatus [temp]);
 	}
 
 	/* Some controllers (lucent) need extra-long delays */
 	ohci->hcd.state = USB_STATE_RESUMING;
 	mdelay (20 /* usb 11.5.1.10 */ + 15);
 
-	temp = ohci_readl (&ohci->regs->control);
+	temp = ohci_readl (ohci, &ohci->regs->control);
 	temp &= OHCI_CTRL_HCFS;
 	if (temp != OHCI_USB_RESUME) {
 		ohci_err (ohci, "controller won't resume\n");
@@ -230,36 +209,36 @@
 	}
 
 	/* disable old schedule state, reinit from scratch */
-	writel (0, &ohci->regs->ed_controlhead);
-	writel (0, &ohci->regs->ed_controlcurrent);
-	writel (0, &ohci->regs->ed_bulkhead);
-	writel (0, &ohci->regs->ed_bulkcurrent);
-	writel (0, &ohci->regs->ed_periodcurrent);
-	writel ((u32) ohci->hcca_dma, &ohci->regs->hcca);
+	ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
+	ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent);
+	ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
+	ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent);
+	ohci_writel (ohci, 0, &ohci->regs->ed_periodcurrent);
+	ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
 
 	periodic_reinit (ohci);
 
 	/* interrupts might have been disabled */
-	writel (OHCI_INTR_INIT, &ohci->regs->intrenable);
+	ohci_writel (ohci, OHCI_INTR_INIT, &ohci->regs->intrenable);
 	if (ohci->ed_rm_list)
-		writel (OHCI_INTR_SF, &ohci->regs->intrenable);
-	writel (ohci_readl (&ohci->regs->intrstatus), &ohci->regs->intrstatus);
+		ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable);
+	ohci_writel (ohci, ohci_readl (ohci, &ohci->regs->intrstatus),
+			&ohci->regs->intrstatus);
 
 	/* Then re-enable operations */
-	writel (OHCI_USB_OPER, &ohci->regs->control);
-	(void) ohci_readl (&ohci->regs->control);
+	ohci_writel (ohci, OHCI_USB_OPER, &ohci->regs->control);
+	(void) ohci_readl (ohci, &ohci->regs->control);
 	msleep (3);
 
 	temp = OHCI_CONTROL_INIT | OHCI_USB_OPER;
 	if (ohci->hcd.can_wakeup)
 		temp |= OHCI_CTRL_RWC;
 	ohci->hc_control = temp;
-	writel (temp, &ohci->regs->control);
-	(void) ohci_readl (&ohci->regs->control);
+	ohci_writel (ohci, temp, &ohci->regs->control);
+	(void) ohci_readl (ohci, &ohci->regs->control);
 
 	/* TRSMRCY */
 	msleep (10);
-	root->dev.power.power_state = 0;
 
 	/* keep it alive for ~5x suspend + resume costs */
 	ohci->next_statechange = jiffies + msecs_to_jiffies (250);
@@ -269,13 +248,14 @@
 	temp = 0;
 	if (!ohci->ed_rm_list) {
 		if (ohci->ed_controltail) {
-			writel (find_head (ohci->ed_controltail)->dma,
-				&ohci->regs->ed_controlhead);
+			ohci_writel (ohci,
+					find_head (ohci->ed_controltail)->dma,
+					&ohci->regs->ed_controlhead);
 			enables |= OHCI_CTRL_CLE;
 			temp |= OHCI_CLF;
 		}
 		if (ohci->ed_bulktail) {
-			writel (find_head (ohci->ed_bulktail)->dma,
+			ohci_writel (ohci, find_head (ohci->ed_bulktail)->dma,
 				&ohci->regs->ed_bulkhead);
 			enables |= OHCI_CTRL_BLE;
 			temp |= OHCI_BLF;
@@ -287,10 +267,10 @@
 	if (enables) {
 		ohci_dbg (ohci, "restarting schedules ... %08x\n", enables);
 		ohci->hc_control |= enables;
-		writel (ohci->hc_control, &ohci->regs->control);
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
 		if (temp)
-			writel (status, &ohci->regs->cmdstatus);
-		(void) ohci_readl (&ohci->regs->control);
+			ohci_writel (ohci, temp, &ohci->regs->cmdstatus);
+		(void) ohci_readl (ohci, &ohci->regs->control);
 	}
 
 	ohci->hcd.state = USB_STATE_RUNNING;
@@ -301,9 +281,9 @@
 {
 	struct usb_hcd	*hcd = _hcd;
 
-	down (&hcd->self.root_hub->serialize);
+	usb_lock_device (hcd->self.root_hub);
 	(void) ohci_hub_resume (hcd);
-	up (&hcd->self.root_hub->serialize);
+	usb_unlock_device (hcd->self.root_hub);
 }
 
 #else
@@ -325,16 +305,26 @@
 {
 	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);
 	int		ports, i, changed = 0, length = 1;
-	int		can_suspend = 1;
+	int		can_suspend = hcd->can_wakeup;
+	unsigned long	flags;
+
+	spin_lock_irqsave (&ohci->lock, flags);
+
+	/* handle autosuspended root:  finish resuming before
+	 * letting khubd or root hub timer see state changes.
+	 */
+	if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER
+			|| !HCD_IS_RUNNING(ohci->hcd.state)) {
+		can_suspend = 0;
+		goto done;
+	}
 
 	ports = roothub_a (ohci) & RH_A_NDP; 
 	if (ports > MAX_ROOT_PORTS) {
-		if (!HCD_IS_RUNNING(ohci->hcd.state))
-			return -ESHUTDOWN;
-		ohci_err (ohci, "bogus NDP=%d, rereads as NDP=%d\n",
-			ports, ohci_readl (&ohci->regs->roothub.a) & RH_A_NDP);
+		ohci_err (ohci, "bogus NDP=%d, rereads as NDP=%d\n", ports,
+			  ohci_readl (ohci, &ohci->regs->roothub.a) & RH_A_NDP);
 		/* retry later; "should not happen" */
-		return 0;
+		goto done;
 	}
 
 	/* init status */
@@ -370,10 +360,13 @@
 			continue;
 		can_suspend = 0;
 	}
+done:
+	spin_unlock_irqrestore (&ohci->lock, flags);
 
 #ifdef CONFIG_PM
 	/* save power by suspending idle root hubs;
 	 * INTR_RD wakes us when there's work
+	 * NOTE: if we can do this, we don't need a root hub timer!
 	 */
 	if (can_suspend
 			&& !changed
@@ -381,12 +374,13 @@
 			&& ((OHCI_CTRL_HCFS | OHCI_SCHED_ENABLES)
 					& ohci->hc_control)
 				== OHCI_USB_OPER
-			&& down_trylock (&hcd->self.root_hub->serialize) == 0
+			&& time_after (jiffies, ohci->next_statechange)
+			&& usb_trylock_device (hcd->self.root_hub)
 			) {
 		ohci_vdbg (ohci, "autosuspend\n");
 		(void) ohci_hub_suspend (&ohci->hcd);
 		ohci->hcd.state = USB_STATE_RUNNING;
-		up (&hcd->self.root_hub->serialize);
+		usb_unlock_device (hcd->self.root_hub);
 	}
 #endif
 
@@ -421,7 +415,7 @@
 	    temp |= 0x0010;
 	else if (rh & RH_A_OCPM)	/* per-port overcurrent reporting? */
 	    temp |= 0x0008;
-	desc->wHubCharacteristics = cpu_to_le16 (temp);
+	desc->wHubCharacteristics = (__force __u16)cpu_to_hc16(ohci, temp);
 
 	/* two bitmaps:  ports removable, and usb 1.0 legacy PortPwrCtrlMask */
 	rh = roothub_b (ohci);
@@ -447,12 +441,12 @@
 	port--;
 
 	/* start port reset before HNP protocol times out */
-	status = ohci_readl(&ohci->regs->roothub.portstatus [port]);
+	status = ohci_readl(ohci, &ohci->regs->roothub.portstatus [port]);
 	if (!(status & RH_PS_CCS))
 		return -ENODEV;
 
 	/* khubd will finish the reset later */
-	writel(RH_PS_PRS, &ohci->regs->roothub.portstatus [port]);
+	ohci_writel(ohci, RH_PS_PRS, &ohci->regs->roothub.portstatus [port]);
 	return 0;
 }
 
@@ -481,15 +475,15 @@
 /* this timer value might be vendor-specific ... */
 #define	PORT_RESET_HW_MSEC	10
 
-/* wrap-aware logic stolen from <linux/jiffies.h> */
-#define tick_before(t1,t2) ((((s16)(t1))-((s16)(t2))) < 0)
+/* wrap-aware logic morphed from <linux/jiffies.h> */
+#define tick_before(t1,t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0)
 
 /* called from some task, normally khubd */
 static inline void root_port_reset (struct ohci_hcd *ohci, unsigned port)
 {
-	u32 __iomem *portstat = &ohci->regs->roothub.portstatus [port];
+	__hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port];
 	u32	temp;
-	u16	now = readl(&ohci->regs->fmnumber);
+	u16	now = ohci_readl(ohci, &ohci->regs->fmnumber);
 	u16	reset_done = now + PORT_RESET_MSEC;
 
 	/* build a "continuous enough" reset signal, with up to
@@ -499,7 +493,7 @@
 	do {
 		/* spin until any current reset finishes */
 		for (;;) {
-			temp = ohci_readl (portstat);
+			temp = ohci_readl (ohci, portstat);
 			if (!(temp & RH_PS_PRS))
 				break;
 			udelay (500);
@@ -508,12 +502,12 @@
 		if (!(temp & RH_PS_CCS))
 			break;
 		if (temp & RH_PS_PRSC)
-			writel (RH_PS_PRSC, portstat);
+			ohci_writel (ohci, RH_PS_PRSC, portstat);
 
 		/* start the next reset, sleep till it's probably done */
-		writel (RH_PS_PRS, portstat);
+		ohci_writel (ohci, RH_PS_PRS, portstat);
 		msleep(PORT_RESET_HW_MSEC);
-		now = readl(&ohci->regs->fmnumber);
+		now = ohci_readl(ohci, &ohci->regs->fmnumber);
 	} while (tick_before(now, reset_done));
 	/* caller synchronizes using PRSC */
 }
@@ -535,7 +529,8 @@
 	case ClearHubFeature:
 		switch (wValue) {
 		case C_HUB_OVER_CURRENT:
-			writel (RH_HS_OCIC, &ohci->regs->roothub.status);
+			ohci_writel (ohci, RH_HS_OCIC,
+					&ohci->regs->roothub.status);
 		case C_HUB_LOCAL_POWER:
 			break;
 		default:
@@ -578,8 +573,9 @@
 		default:
 			goto error;
 		}
-		writel (temp, &ohci->regs->roothub.portstatus [wIndex]);
-		// ohci_readl (&ohci->regs->roothub.portstatus [wIndex]);
+		ohci_writel (ohci, temp,
+				&ohci->regs->roothub.portstatus [wIndex]);
+		// ohci_readl (ohci, &ohci->regs->roothub.portstatus [wIndex]);
 		break;
 	case GetHubDescriptor:
 		ohci_hub_descriptor (ohci, (struct usb_hub_descriptor *) buf);
@@ -622,11 +618,11 @@
 				start_hnp(ohci);
 			else
 #endif
-			writel (RH_PS_PSS,
+			ohci_writel (ohci, RH_PS_PSS,
 				&ohci->regs->roothub.portstatus [wIndex]);
 			break;
 		case USB_PORT_FEAT_POWER:
-			writel (RH_PS_PPS,
+			ohci_writel (ohci, RH_PS_PPS,
 				&ohci->regs->roothub.portstatus [wIndex]);
 			break;
 		case USB_PORT_FEAT_RESET:
diff -Nru a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
--- a/drivers/usb/host/ohci-lh7a404.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/host/ohci-lh7a404.c	2004-12-24 13:37:19 -08:00
@@ -146,6 +146,7 @@
 
 	usb_bus_init (&hcd->self);
 	hcd->self.op = &usb_hcd_operations;
+	hcd->self.release = &usb_hcd_release;
 	hcd->self.hcpriv = (void *) hcd;
 	hcd->self.bus_name = "lh7a404";
 	hcd->product_desc = "LH7A404 OHCI";
@@ -165,9 +166,8 @@
 
  err2:
 	hcd_buffer_destroy (hcd);
-	if (hcd)
-		driver->hcd_free(hcd);
  err1:
+	kfree(hcd);
 	lh7a404_stop_hc(dev);
 	release_mem_region(dev->resource[0].start,
 				dev->resource[0].end
@@ -191,8 +191,6 @@
  */
 void usb_hcd_lh7a404_remove (struct usb_hcd *hcd, struct platform_device *dev)
 {
-	void *base;
-
 	pr_debug ("remove: %s, state %x", hcd->self.bus_name, hcd->state);
 
 	if (in_interrupt ())
@@ -211,9 +209,6 @@
 
 	usb_deregister_bus (&hcd->self);
 
-	base = hcd->regs;
-	hcd->driver->hcd_free (hcd);
-
 	lh7a404_stop_hc(dev);
 	release_mem_region(dev->resource[0].start,
 			   dev->resource[0].end
@@ -229,38 +224,14 @@
 	int		ret;
 
 	ohci_dbg (ohci, "ohci_lh7a404_start, ohci:%p", ohci);
-			
-	ohci->hcca = dma_alloc_coherent (hcd->self.controller,
-			sizeof *ohci->hcca, &ohci->hcca_dma, 0);
-	if (!ohci->hcca)
-		return -ENOMEM;
-
-	ohci_dbg (ohci, "ohci_lh7a404_start, ohci->hcca:%p",
-			ohci->hcca);
-
-	memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
-
-	if ((ret = ohci_mem_init (ohci)) < 0) {
-		ohci_stop (hcd);
+	if ((ret = ohci_init(ohci)) < 0)
 		return ret;
-	}
-	ohci->regs = hcd->regs;
-
-	if (hc_reset (ohci) < 0) {
-		ohci_stop (hcd);
-		return -ENODEV;
-	}
 
-	if (hc_start (ohci) < 0) {
+	if ((ret = ohci_run (ohci)) < 0) {
 		err ("can't start %s", ohci->hcd.self.bus_name);
 		ohci_stop (hcd);
-		return -EBUSY;
+		return ret;
 	}
-	create_debug_files (ohci);
-
-#ifdef	DEBUG
-	ohci_dump (ohci, 1);
-#endif /*DEBUG*/
 	return 0;
 }
 
@@ -289,7 +260,6 @@
 	 * memory lifecycle (except per-request)
 	 */
 	.hcd_alloc =		ohci_hcd_alloc,
-	.hcd_free =		ohci_hcd_free,
 
 	/*
 	 * managing i/o requests and associated device resources
diff -Nru a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
--- a/drivers/usb/host/ohci-mem.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/usb/host/ohci-mem.c	2004-12-24 13:37:01 -08:00
@@ -40,11 +40,6 @@
 	return NULL;
 }
 
-static void ohci_hcd_free (struct usb_hcd *hcd)
-{
-	kfree (hcd_to_ohci (hcd));
-}
-
 /*-------------------------------------------------------------------------*/
 
 static int ohci_mem_init (struct ohci_hcd *ohci)
@@ -104,7 +99,7 @@
 	if (td) {
 		/* in case hc fetches it, make it look dead */
 		memset (td, 0, sizeof *td);
-		td->hwNextTD = cpu_to_le32 (dma);
+		td->hwNextTD = cpu_to_hc32 (hc, dma);
 		td->td_dma = dma;
 		/* hashed in td_fill */
 	}
@@ -120,7 +115,7 @@
 		prev = &(*prev)->td_hash;
 	if (*prev)
 		*prev = td->td_hash;
-	else if ((td->hwINFO & TD_DONE) != 0)
+	else if ((td->hwINFO & cpu_to_hc32(hc, TD_DONE)) != 0)
 		ohci_dbg (hc, "no hash for td %p\n", td);
 	dma_pool_free (hc->td_cache, td, td->td_dma);
 }
diff -Nru a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
--- a/drivers/usb/host/ohci-omap.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/usb/host/ohci-omap.c	2004-12-24 13:37:01 -08:00
@@ -42,21 +42,7 @@
 static int omap_ohci_clock_power(int on)
 {
 	if (on) {
-		if (cpu_is_omap1510()) {
-			/* Use DPLL, not APLL */
-			omap_writel(omap_readl(ULPD_APLL_CTRL) & ~APLL_NDPLL_SWITCH,
-			       ULPD_APLL_CTRL);
-
-			/* Enable DPLL */
-			omap_writel(omap_readl(ULPD_DPLL_CTRL) | DPLL_PLL_ENABLE,
-			       ULPD_DPLL_CTRL);
-
-			/* Software request for USB 48MHz clock */
-			omap_writel(omap_readl(ULPD_SOFT_REQ) | SOFT_REQ_REG_REQ,
-			       ULPD_SOFT_REQ);
-
-			while (!(omap_readl(ULPD_DPLL_CTRL) & DPLL_LOCK));
-		}
+		/* for 1510, 48MHz DPLL is set up in usb init */
 
 		if (cpu_is_omap16xx()) {
 			/* Enable OHCI */
@@ -98,14 +84,16 @@
 {
 	if (on) {
 		if (machine_is_omap_innovator() && cpu_is_omap1510())
-			fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) | 0x20, 
+			fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL)
+				| ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), 
 			       INNOVATOR_FPGA_CAM_USB_CONTROL);
 		else if (machine_is_omap_osk()) {
 			/* FIXME: GPIO1 -> 1 on the TPS65010 I2C chip */
 		}
 	} else {
 		if (machine_is_omap_innovator() && cpu_is_omap1510())
-			fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) & ~0x20, 
+			fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL)
+				& ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), 
 			       INNOVATOR_FPGA_CAM_USB_CONTROL);
 		else if (machine_is_omap_osk()) {
 			/* FIXME: GPIO1 -> 0 on the TPS65010 I2C chip */
@@ -322,7 +310,7 @@
 
 	retval = omap_start_hc(ohci, pdev);
 	if (retval < 0)
-		goto err2;
+		goto err1;
 
 	retval = hcd_buffer_create (hcd);
 	if (retval != 0) {
@@ -342,6 +330,7 @@
 
 	usb_bus_init (&hcd->self);
 	hcd->self.op = &usb_hcd_operations;
+	hcd->self.release = &usb_hcd_release;
 	hcd->self.hcpriv = (void *) hcd;
 	hcd->self.bus_name = pdev->dev.bus_id;
 	hcd->product_desc = "OMAP OHCI";
@@ -359,9 +348,8 @@
 
  err2:
 	hcd_buffer_destroy (hcd);
-	if (hcd)
-		driver->hcd_free(hcd);
  err1:
+	kfree(hcd);
 	omap_stop_hc(pdev);
 
 	release_mem_region(pdev->resource[0].start, 
@@ -387,8 +375,6 @@
  */
 void usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev)
 {
-	void *base;
-
 	dev_info(&pdev->dev, "remove: state %x\n", hcd->state);
 
 	if (in_interrupt ())
@@ -410,9 +396,6 @@
 
 	usb_deregister_bus (&hcd->self);
 
-	base = hcd->regs;
-	hcd->driver->hcd_free (hcd);
-
 	omap_stop_hc(pdev);
 
 	release_mem_region(pdev->resource[0].start, 
@@ -428,40 +411,18 @@
 	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);
 	int		ret;
 
-	config = hcd->self.controller->platform_data;
-	ohci->hcca = dma_alloc_coherent (hcd->self.controller,
-			sizeof *ohci->hcca, &ohci->hcca_dma, 0);
-	if (!ohci->hcca)
-		return -ENOMEM;
-
-        memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
-	if ((ret = ohci_mem_init (ohci)) < 0) {
-		ohci_stop (hcd);
+	if ((ret = ohci_init(ohci)) < 0)
 		return ret;
-	}
-	ohci->regs = hcd->regs;
 
+	config = hcd->self.controller->platform_data;
 	if (config->otg || config->rwc)
 		writel(OHCI_CTRL_RWC, &ohci->regs->control);
 
-	if (hc_reset (ohci) < 0) {
-		ohci_stop (hcd);
-		return -ENODEV;
-	}
-
-	if (hc_start (ohci) < 0) {
+	if ((ret = ohci_run (ohci)) < 0) {
 		err ("can't start %s", ohci->hcd.self.bus_name);
 		ohci_stop (hcd);
-		return -EBUSY;
+		return ret;
 	}
-	if (ohci->power_budget)
-		hub_set_power_budget(ohci->hcd.self.root_hub,
-					ohci->power_budget);
-	create_debug_files (ohci);
-
-#ifdef	DEBUG
-	ohci_dump (ohci, 1);
-#endif
 	return 0;
 }
 
@@ -486,7 +447,6 @@
 	 * memory lifecycle (except per-request)
 	 */
 	.hcd_alloc =		ohci_hcd_alloc,
-	.hcd_free =		ohci_hcd_free,
 
 	/*
 	 * managing i/o requests and associated device resources
diff -Nru a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
--- a/drivers/usb/host/ohci-pci.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/usb/host/ohci-pci.c	2004-12-24 13:37:03 -08:00
@@ -35,9 +35,7 @@
 {
 	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);
 
-	ohci->regs = hcd->regs;
-	ohci->next_statechange = jiffies;
-	return hc_reset (ohci);
+	return ohci_init (ohci);
 }
 
 static int __devinit
@@ -46,11 +44,6 @@
 	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);
 	int		ret;
 
-	ohci->hcca = dma_alloc_coherent (hcd->self.controller,
-			sizeof *ohci->hcca, &ohci->hcca_dma, 0);
-	if (!ohci->hcca)
-		return -ENOMEM;
-
 	if(hcd->self.controller && hcd->self.controller->bus == &pci_bus_type) {
 		struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
 
@@ -61,6 +54,7 @@
 				&& pdev->device == 0x740c) {
 			ohci->flags = OHCI_QUIRK_AMD756;
 			ohci_info (ohci, "AMD756 erratum 4 workaround\n");
+			// also somewhat erratum 10 (suspend/resume issues)
 		}
 
 		/* FIXME for some of the early AMD 760 southbridges, OHCI
@@ -92,25 +86,16 @@
 				ohci_info (ohci, "Using NSC SuperIO setup\n");
 			}
 		}
-	
-	}
-
-        memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
-	if ((ret = ohci_mem_init (ohci)) < 0) {
-		ohci_stop (hcd);
-		return ret;
 	}
 
-	if (hc_start (ohci) < 0) {
+	/* NOTE: there may have already been a first reset, to
+	 * keep bios/smm irqs from making trouble
+	 */
+	if ((ret = ohci_run (ohci)) < 0) {
 		ohci_err (ohci, "can't start\n");
 		ohci_stop (hcd);
-		return -EBUSY;
+		return ret;
 	}
-	create_debug_files (ohci);
-
-#ifdef	DEBUG
-	ohci_dump (ohci, 1);
-#endif
 	return 0;
 }
 
@@ -121,25 +106,22 @@
 	struct ohci_hcd		*ohci = hcd_to_ohci (hcd);
 
 	/* suspend root hub, hoping it keeps power during suspend */
-	while (time_before (jiffies, ohci->next_statechange))
+	if (time_before (jiffies, ohci->next_statechange))
 		msleep (100);
 
 #ifdef	CONFIG_USB_SUSPEND
 	(void) usb_suspend_device (hcd->self.root_hub, state);
 #else
-	down (&hcd->self.root_hub->serialize);
+	usb_lock_device (hcd->self.root_hub);
 	(void) ohci_hub_suspend (hcd);
-	up (&hcd->self.root_hub->serialize);
+	usb_unlock_device (hcd->self.root_hub);
 #endif
 
 	/* let things settle down a bit */
 	msleep (100);
 	
 #ifdef CONFIG_PMAC_PBOOK
-	if (_machine == _MACH_Pmac)
-		disable_irq ((to_pci_dev(hcd->self.controller))->irq);
-
-	{
+	if (_machine == _MACH_Pmac) {
 	   	struct device_node	*of_node;
  
 		/* Disable USB PAD & cell clock */
@@ -147,7 +129,7 @@
 		if (of_node)
 			pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0);
 	}
-#endif
+#endif /* CONFIG_PMAC_PBOOK */
 	return 0;
 }
 
@@ -158,7 +140,7 @@
 	int			retval = 0;
 
 #ifdef CONFIG_PMAC_PBOOK
-	{
+	if (_machine == _MACH_Pmac) {
 		struct device_node *of_node;
 
 		/* Re-enable USB PAD & cell clock */
@@ -166,27 +148,20 @@
 		if (of_node)
 			pmac_call_feature (PMAC_FTR_USB_ENABLE, of_node, 0, 1);
 	}
-#endif
+#endif /* CONFIG_PMAC_PBOOK */
 
 	/* resume root hub */
-	while (time_before (jiffies, ohci->next_statechange))
+	if (time_before (jiffies, ohci->next_statechange))
 		msleep (100);
 #ifdef	CONFIG_USB_SUSPEND
 	/* get extra cleanup even if remote wakeup isn't in use */
 	retval = usb_resume_device (hcd->self.root_hub);
 #else
-	down (&hcd->self.root_hub->serialize);
+	usb_lock_device (hcd->self.root_hub);
 	retval = ohci_hub_resume (hcd);
-	up (&hcd->self.root_hub->serialize);
+	usb_unlock_device (hcd->self.root_hub);
 #endif
 
-	if (retval == 0) {
-		hcd->self.controller->power.power_state = 0;
-#ifdef CONFIG_PMAC_PBOOK
-		if (_machine == _MACH_Pmac)
-			enable_irq (to_pci_dev(hcd->self.controller)->irq);
-#endif
-	}
 	return retval;
 }
 
@@ -219,7 +194,6 @@
 	 * memory lifecycle (except per-request)
 	 */
 	.hcd_alloc =		ohci_hcd_alloc,
-	.hcd_free =		ohci_hcd_free,
 
 	/*
 	 * managing i/o requests and associated device resources
@@ -279,7 +253,7 @@
 
 	pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
 		sizeof (struct ed), sizeof (struct td));
-	return pci_module_init (&ohci_pci_driver);
+	return pci_register_driver (&ohci_pci_driver);
 }
 module_init (ohci_hcd_pci_init);
 
diff -Nru a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/host/ohci-pxa27x.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,455 @@
+/*
+ * OHCI HCD (Host Controller Driver) for USB.
+ *
+ * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
+ * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
+ * (C) Copyright 2002 Hewlett-Packard Company
+ *
+ * Bus Glue for pxa27x
+ *
+ * Written by Christopher Hoover <ch@hpl.hp.com>
+ * Based on fragments of previous driver by Russell King et al.
+ *
+ * Modified for LH7A404 from ohci-sa1111.c
+ *  by Durgesh Pattamatta <pattamattad@sharpsec.com>
+ *
+ * Modified for pxa27x from ohci-lh7a404.c
+ *  by Nick Bane <nick@cecomputing.co.uk> 26-8-2004
+ *
+ * This file is licenced under the GPL.
+ */
+
+#include <linux/device.h>
+#include <asm/mach-types.h>
+#include <asm/hardware.h>
+#include <asm/arch/pxa-regs.h>
+
+
+#define PMM_NPS_MODE           1
+#define PMM_GLOBAL_MODE        2
+#define PMM_PERPORT_MODE       3
+
+#define PXA_UHC_MAX_PORTNUM    3
+
+#define UHCRHPS(x)              __REG2( 0x4C000050, (x)<<2 )
+
+static int pxa27x_ohci_pmm_state;
+
+/*
+  PMM_NPS_MODE -- PMM Non-power switching mode
+      Ports are powered continuously.
+
+  PMM_GLOBAL_MODE -- PMM global switching mode
+      All ports are powered at the same time.
+
+  PMM_PERPORT_MODE -- PMM per port switching mode
+      Ports are powered individually.
+ */
+static int pxa27x_ohci_select_pmm( int mode )
+{
+	pxa27x_ohci_pmm_state = mode;
+
+	switch ( mode ) {
+	case PMM_NPS_MODE:
+		UHCRHDA |= RH_A_NPS;
+		break; 
+	case PMM_GLOBAL_MODE:
+		UHCRHDA &= ~(RH_A_NPS & RH_A_PSM);
+		break;
+	case PMM_PERPORT_MODE:
+		UHCRHDA &= ~(RH_A_NPS);
+		UHCRHDA |= RH_A_PSM;
+
+		/* Set port power control mask bits, only 3 ports. */
+		UHCRHDB |= (0x7<<17);
+		break;
+	default:
+		printk( KERN_ERR
+			"Invalid mode %d, set to non-power switch mode.\n", 
+			mode );
+
+		pxa27x_ohci_pmm_state = PMM_NPS_MODE;
+		UHCRHDA |= RH_A_NPS;
+	}
+
+	return 0;
+}
+
+/*
+  If you select PMM_PERPORT_MODE, you should set the port power
+ */
+static int pxa27x_ohci_set_port_power( int port )
+{
+	if ( (pxa27x_ohci_pmm_state==PMM_PERPORT_MODE)
+	     && (port>0) && (port<PXA_UHC_MAX_PORTNUM) ) {
+		UHCRHPS(port) |= 0x100;
+		return 0;
+	}
+	return -1;
+}
+
+/*
+  If you select PMM_PERPORT_MODE, you should set the port power
+ */
+static int pxa27x_ohci_clear_port_power( int port )
+{
+	if ( (pxa27x_ohci_pmm_state==PMM_PERPORT_MODE) 
+	     && (port>0) && (port<PXA_UHC_MAX_PORTNUM) ) {
+		UHCRHPS(port) |= 0x200;
+		return 0;
+	}
+	 
+	return -1;
+}
+
+extern int usb_disabled(void);
+
+/*-------------------------------------------------------------------------*/
+
+static void pxa27x_start_hc(struct platform_device *dev)
+{
+	pxa_set_cken(CKEN10_USBHOST, 1);
+
+	UHCHR |= UHCHR_FHR;
+	udelay(11);
+	UHCHR &= ~UHCHR_FHR;
+
+	UHCHR |= UHCHR_FSBIR;
+	while (UHCHR & UHCHR_FSBIR)
+		cpu_relax();
+
+	/* This could be properly abstracted away through the
+	   device data the day more machines are supported and
+	   their differences can be figured out correctly. */
+	if (machine_is_mainstone()) {
+		/* setup Port1 GPIO pin. */
+		pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN);	/* USBHPWR1 */
+		pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT);	/* USBHPEN1 */
+
+		/* Set the Power Control Polarity Low and Power Sense
+		   Polarity Low to active low. Supply power to USB ports. */
+		UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
+			~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
+	}
+
+	UHCHR &= ~UHCHR_SSE;
+
+	UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE);
+}
+
+static void pxa27x_stop_hc(struct platform_device *dev)
+{
+	UHCHR |= UHCHR_FHR;
+	udelay(11);
+	UHCHR &= ~UHCHR_FHR;
+
+	UHCCOMS |= 1;
+	udelay(10);
+
+	pxa_set_cken(CKEN10_USBHOST, 0);
+}
+
+
+/*-------------------------------------------------------------------------*/
+
+void usb_hcd_pxa27x_remove (struct usb_hcd *, struct platform_device *);
+
+/* configure so an HC device and id are always provided */
+/* always called with process context; sleeping is OK */
+
+
+/**
+ * usb_hcd_pxa27x_probe - initialize pxa27x-based HCDs
+ * Context: !in_interrupt()
+ *
+ * Allocates basic resources for this USB host controller, and
+ * then invokes the start() method for the HCD associated with it
+ * through the hotplug entry's driver_data.
+ *
+ */
+int usb_hcd_pxa27x_probe (const struct hc_driver *driver,
+			  struct usb_hcd **hcd_out,
+			  struct platform_device *dev)
+{
+	int retval;
+	struct usb_hcd *hcd = 0;
+
+	unsigned int *addr = NULL;
+
+	if (!request_mem_region(dev->resource[0].start,
+				dev->resource[0].end
+				- dev->resource[0].start + 1, hcd_name)) {
+		pr_debug("request_mem_region failed");
+		return -EBUSY;
+	}
+
+	pxa27x_start_hc(dev);
+
+	/* Select Power Management Mode */
+	pxa27x_ohci_select_pmm( PMM_PERPORT_MODE );
+
+	/* If choosing PMM_PERPORT_MODE, we should set the port power before we use it. */
+	if (pxa27x_ohci_set_port_power(1) < 0)
+		printk(KERN_ERR "Setting port 1 power failed.\n");
+
+	if (pxa27x_ohci_clear_port_power(2) < 0)
+		printk(KERN_ERR "Setting port 2 power failed.\n");
+
+	if (pxa27x_ohci_clear_port_power(3) < 0)
+		printk(KERN_ERR "Setting port 3 power failed.\n");
+
+	addr = ioremap(dev->resource[0].start,
+		       dev->resource[0].end - dev->resource[0].start + 1);
+	if (!addr) {
+		pr_debug("ioremap failed");
+		retval = -ENOMEM;
+		goto err1;
+	}
+
+	hcd = driver->hcd_alloc ();
+	if (hcd == NULL){
+		pr_debug ("hcd_alloc failed");
+		retval = -ENOMEM;
+		goto err1;
+	}
+
+	if(dev->resource[1].flags != IORESOURCE_IRQ){
+		pr_debug ("resource[1] is not IORESOURCE_IRQ");
+		retval = -ENOMEM;
+		goto err1;
+	}
+
+	hcd->driver = (struct hc_driver *) driver;
+	hcd->description = driver->description;
+	hcd->irq = dev->resource[1].start;
+	hcd->regs = addr;
+	hcd->self.controller = &dev->dev;
+
+	retval = hcd_buffer_create (hcd);
+	if (retval != 0) {
+		pr_debug ("pool alloc fail");
+		goto err1;
+	}
+
+	retval = request_irq (hcd->irq, usb_hcd_irq, SA_INTERRUPT,
+			      hcd->description, hcd);
+	if (retval != 0) {
+		pr_debug("request_irq(%d) failed with retval %d\n",hcd->irq,retval);
+		retval = -EBUSY;
+		goto err2;
+	}
+
+	pr_debug ("%s (pxa27x) at 0x%p, irq %d",
+	     hcd->description, hcd->regs, hcd->irq);
+
+	usb_bus_init (&hcd->self);
+	hcd->self.op = &usb_hcd_operations;
+	hcd->self.release = &usb_hcd_release;
+	hcd->self.hcpriv = (void *) hcd;
+	hcd->self.bus_name = "pxa27x";
+	hcd->product_desc = "PXA27x OHCI";
+
+	INIT_LIST_HEAD (&hcd->dev_list);
+
+	usb_register_bus (&hcd->self);
+
+	if ((retval = driver->start (hcd)) < 0) {
+		usb_hcd_pxa27x_remove(hcd, dev);
+		return retval;
+	}
+
+	*hcd_out = hcd;
+	return 0;
+
+ err2:
+	hcd_buffer_destroy (hcd);
+ err1:
+	kfree(hcd);
+	pxa27x_stop_hc(dev);
+	release_mem_region(dev->resource[0].start,
+				dev->resource[0].end
+			   - dev->resource[0].start + 1);
+	return retval;
+}
+
+
+/* may be called without controller electrically present */
+/* may be called with controller, bus, and devices active */
+
+/**
+ * usb_hcd_pxa27x_remove - shutdown processing for pxa27x-based HCDs
+ * @dev: USB Host Controller being removed
+ * Context: !in_interrupt()
+ *
+ * Reverses the effect of usb_hcd_pxa27x_probe(), first invoking
+ * the HCD's stop() method.  It is always called from a thread
+ * context, normally "rmmod", "apmd", or something similar.
+ *
+ */
+void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *dev)
+{
+	pr_debug ("remove: %s, state %x", hcd->self.bus_name, hcd->state);
+
+	if (in_interrupt ())
+		BUG ();
+
+	hcd->state = USB_STATE_QUIESCING;
+
+	pr_debug ("%s: roothub graceful disconnect", hcd->self.bus_name);
+	usb_disconnect (&hcd->self.root_hub);
+
+	hcd->driver->stop (hcd);
+	hcd->state = USB_STATE_HALT;
+
+	free_irq (hcd->irq, hcd);
+	hcd_buffer_destroy (hcd);
+
+	usb_deregister_bus (&hcd->self);
+
+	pxa27x_stop_hc(dev);
+	release_mem_region(dev->resource[0].start,
+			   dev->resource[0].end - dev->resource[0].start + 1);
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int __devinit
+ohci_pxa27x_start (struct usb_hcd *hcd)
+{
+	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);
+	int		ret;
+
+	ohci_dbg (ohci, "ohci_pxa27x_start, ohci:%p", ohci);
+
+	if ((ret = ohci_init(ohci)) < 0)
+		return ret;
+
+	if ((ret = ohci_run (ohci)) < 0) {
+		err ("can't start %s", ohci->hcd.self.bus_name);
+		ohci_stop (hcd);
+		return ret;
+	}
+
+	return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+static const struct hc_driver ohci_pxa27x_hc_driver = {
+	.description =		hcd_name,
+
+	/*
+	 * generic hardware linkage
+	 */
+	.irq =			ohci_irq,
+	.flags =		HCD_USB11,
+
+	/*
+	 * basic lifecycle operations
+	 */
+	.start =		ohci_pxa27x_start,
+	.stop =			ohci_stop,
+
+	/*
+	 * memory lifecycle (except per-request)
+	 */
+	.hcd_alloc =		ohci_hcd_alloc,
+
+	/*
+	 * managing i/o requests and associated device resources
+	 */
+	.urb_enqueue =		ohci_urb_enqueue,
+	.urb_dequeue =		ohci_urb_dequeue,
+	.endpoint_disable =	ohci_endpoint_disable,
+
+	/*
+	 * scheduling support
+	 */
+	.get_frame_number =	ohci_get_frame,
+
+	/*
+	 * root hub support
+	 */
+	.hub_status_data =	ohci_hub_status_data,
+	.hub_control =		ohci_hub_control,
+#ifdef  CONFIG_USB_SUSPEND
+	.hub_suspend =		ohci_hub_suspend,
+	.hub_resume =		ohci_hub_resume,
+#endif
+};
+
+/*-------------------------------------------------------------------------*/
+
+static int ohci_hcd_pxa27x_drv_probe(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct usb_hcd *hcd = NULL;
+	int ret;
+
+	pr_debug ("In ohci_hcd_pxa27x_drv_probe");
+
+	if (usb_disabled())
+		return -ENODEV;
+
+	ret = usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, &hcd, pdev);
+
+	if (ret == 0)
+		dev_set_drvdata(dev, hcd);
+
+	return ret;
+}
+
+static int ohci_hcd_pxa27x_drv_remove(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct usb_hcd *hcd = dev_get_drvdata(dev);
+
+	usb_hcd_pxa27x_remove(hcd, pdev);
+	dev_set_drvdata(dev, NULL);
+	return 0;
+}
+
+static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, u32 state, u32 level)
+{
+//	struct platform_device *pdev = to_platform_device(dev);
+//	struct usb_hcd *hcd = dev_get_drvdata(dev);
+	printk("%s: not implemented yet\n", __FUNCTION__);
+
+	return 0;
+}
+
+static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 state)
+{
+//	struct platform_device *pdev = to_platform_device(dev);
+//	struct usb_hcd *hcd = dev_get_drvdata(dev);
+	printk("%s: not implemented yet\n", __FUNCTION__);
+
+	return 0;
+}
+
+
+static struct device_driver ohci_hcd_pxa27x_driver = {
+	.name		= "pxa27x-ohci",
+	.bus		= &platform_bus_type,
+	.probe		= ohci_hcd_pxa27x_drv_probe,
+	.remove		= ohci_hcd_pxa27x_drv_remove,
+	.suspend	= ohci_hcd_pxa27x_drv_suspend, 
+	.resume		= ohci_hcd_pxa27x_drv_resume, 
+};
+
+static int __init ohci_hcd_pxa27x_init (void)
+{
+	pr_debug (DRIVER_INFO " (pxa27x)");
+	pr_debug ("block sizes: ed %d td %d\n",
+		sizeof (struct ed), sizeof (struct td));
+
+	return driver_register(&ohci_hcd_pxa27x_driver);
+}
+
+static void __exit ohci_hcd_pxa27x_cleanup (void)
+{
+	driver_unregister(&ohci_hcd_pxa27x_driver);
+}
+
+module_init (ohci_hcd_pxa27x_init);
+module_exit (ohci_hcd_pxa27x_cleanup);
diff -Nru a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
--- a/drivers/usb/host/ohci-q.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/host/ohci-q.c	2004-12-24 13:37:19 -08:00
@@ -35,6 +35,8 @@
  */
 static void
 finish_urb (struct ohci_hcd *ohci, struct urb *urb, struct pt_regs *regs)
+__releases(ohci->lock)
+__acquires(ohci->lock)
 {
 	// ASSERT (urb->hcpriv != 0);
 
@@ -78,7 +80,7 @@
 	if (hcd_to_bus (&ohci->hcd)->bandwidth_isoc_reqs == 0
 			&& hcd_to_bus (&ohci->hcd)->bandwidth_int_reqs == 0) {
 		ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_IE);
-		writel (ohci->hc_control, &ohci->regs->control);
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
 	}
 }
 
@@ -131,12 +133,12 @@
 	unsigned	i;
 
 	ohci_vdbg (ohci, "link %sed %p branch %d [%dus.], interval %d\n",
-		(ed->hwINFO & ED_ISO) ? "iso " : "",
+		(ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "",
 		ed, ed->branch, ed->load, ed->interval);
 
 	for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
 		struct ed	**prev = &ohci->periodic [i];
-		__le32		*prev_p = &ohci->hcca->int_table [i];
+		__hc32		*prev_p = &ohci->hcca->int_table [i];
 		struct ed	*here = *prev;
 
 		/* sorting each branch by period (slow before fast)
@@ -156,7 +158,7 @@
 				ed->hwNextED = *prev_p;
 			wmb ();
 			*prev = ed;
-			*prev_p = cpu_to_le32(ed->dma);
+			*prev_p = cpu_to_hc32(ohci, ed->dma);
 			wmb();
 		}
 		ohci->load [i] += ed->load;
@@ -193,17 +195,20 @@
 	case PIPE_CONTROL:
 		if (ohci->ed_controltail == NULL) {
 			WARN_ON (ohci->hc_control & OHCI_CTRL_CLE);
-			writel (ed->dma, &ohci->regs->ed_controlhead);
+			ohci_writel (ohci, ed->dma,
+					&ohci->regs->ed_controlhead);
 		} else {
 			ohci->ed_controltail->ed_next = ed;
-			ohci->ed_controltail->hwNextED = cpu_to_le32 (ed->dma);
+			ohci->ed_controltail->hwNextED = cpu_to_hc32 (ohci,
+								ed->dma);
 		}
 		ed->ed_prev = ohci->ed_controltail;
 		if (!ohci->ed_controltail && !ohci->ed_rm_list) {
 			wmb();
 			ohci->hc_control |= OHCI_CTRL_CLE;
-			writel (0, &ohci->regs->ed_controlcurrent);
-			writel (ohci->hc_control, &ohci->regs->control);
+			ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent);
+			ohci_writel (ohci, ohci->hc_control,
+					&ohci->regs->control);
 		}
 		ohci->ed_controltail = ed;
 		break;
@@ -211,17 +216,19 @@
 	case PIPE_BULK:
 		if (ohci->ed_bulktail == NULL) {
 			WARN_ON (ohci->hc_control & OHCI_CTRL_BLE);
-			writel (ed->dma, &ohci->regs->ed_bulkhead);
+			ohci_writel (ohci, ed->dma, &ohci->regs->ed_bulkhead);
 		} else {
 			ohci->ed_bulktail->ed_next = ed;
-			ohci->ed_bulktail->hwNextED = cpu_to_le32 (ed->dma);
+			ohci->ed_bulktail->hwNextED = cpu_to_hc32 (ohci,
+								ed->dma);
 		}
 		ed->ed_prev = ohci->ed_bulktail;
 		if (!ohci->ed_bulktail && !ohci->ed_rm_list) {
 			wmb();
 			ohci->hc_control |= OHCI_CTRL_BLE;
-			writel (0, &ohci->regs->ed_bulkcurrent);
-			writel (ohci->hc_control, &ohci->regs->control);
+			ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent);
+			ohci_writel (ohci, ohci->hc_control,
+					&ohci->regs->control);
 		}
 		ohci->ed_bulktail = ed;
 		break;
@@ -257,7 +264,7 @@
 	for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
 		struct ed	*temp;
 		struct ed	**prev = &ohci->periodic [i];
-		__le32		*prev_p = &ohci->hcca->int_table [i];
+		__hc32		*prev_p = &ohci->hcca->int_table [i];
 
 		while (*prev && (temp = *prev) != ed) {
 			prev_p = &temp->hwNextED;
@@ -272,7 +279,7 @@
 	hcd_to_bus (&ohci->hcd)->bandwidth_allocated -= ed->load / ed->interval;
 
 	ohci_vdbg (ohci, "unlink %sed %p branch %d [%dus.], interval %d\n",
-		(ed->hwINFO & ED_ISO) ? "iso " : "",
+		(ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "",
 		ed, ed->branch, ed->load, ed->interval);
 }
 
@@ -300,7 +307,7 @@
  */
 static void ed_deschedule (struct ohci_hcd *ohci, struct ed *ed) 
 {
-	ed->hwINFO |= ED_SKIP;
+	ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP);
 	wmb ();
 	ed->state = ED_UNLINK;
 
@@ -320,10 +327,12 @@
 		if (ed->ed_prev == NULL) {
 			if (!ed->hwNextED) {
 				ohci->hc_control &= ~OHCI_CTRL_CLE;
-				writel (ohci->hc_control, &ohci->regs->control);
+				ohci_writel (ohci, ohci->hc_control,
+						&ohci->regs->control);
 				// a ohci_readl() later syncs CLE with the HC
 			} else
-				writel (le32_to_cpup (&ed->hwNextED),
+				ohci_writel (ohci,
+					hc32_to_cpup (ohci, &ed->hwNextED),
 					&ohci->regs->ed_controlhead);
 		} else {
 			ed->ed_prev->ed_next = ed->ed_next;
@@ -344,10 +353,12 @@
 		if (ed->ed_prev == NULL) {
 			if (!ed->hwNextED) {
 				ohci->hc_control &= ~OHCI_CTRL_BLE;
-				writel (ohci->hc_control, &ohci->regs->control);
+				ohci_writel (ohci, ohci->hc_control,
+						&ohci->regs->control);
 				// a ohci_readl() later syncs BLE with the HC
 			} else
-				writel (le32_to_cpup (&ed->hwNextED),
+				ohci_writel (ohci,
+					hc32_to_cpup (ohci, &ed->hwNextED),
 					&ohci->regs->ed_bulkhead);
 		} else {
 			ed->ed_prev->ed_next = ed->ed_next;
@@ -416,7 +427,7 @@
 			goto done;
 		}
 		ed->dummy = td;
-		ed->hwTailP = cpu_to_le32 (td->td_dma);
+		ed->hwTailP = cpu_to_hc32 (ohci, td->td_dma);
 		ed->hwHeadP = ed->hwTailP;	/* ED_C, ED_H zeroed */
 		ed->state = ED_IDLE;
 		ed->type = type;
@@ -427,21 +438,19 @@
 	 */
   	if (ed->state == ED_IDLE) {
 		u32	info;
-		__le32	hw_info;
 
 		info = usb_pipedevice (pipe);
 		info |= (ep >> 1) << 7;
 		info |= usb_maxpacket (udev, pipe, is_out) << 16;
-		hw_info = cpu_to_le32 (info);
 		if (udev->speed == USB_SPEED_LOW)
-			hw_info |= ED_LOWSPEED;
+			info |= ED_LOWSPEED;
 		/* only control transfers store pids in tds */
 		if (type != PIPE_CONTROL) {
-			hw_info |= is_out ? ED_OUT : ED_IN;
+			info |= is_out ? ED_OUT : ED_IN;
 			if (type != PIPE_BULK) {
 				/* periodic transfers... */
 				if (type == PIPE_ISOCHRONOUS)
-					hw_info |= ED_ISO;
+					info |= ED_ISO;
 				else if (interval > 32)	/* iso can be bigger */
 					interval = 32;
 				ed->interval = interval;
@@ -452,7 +461,7 @@
 						/ 1000;
 			}
 		}
-		ed->hwINFO = hw_info;
+		ed->hwINFO = cpu_to_hc32(ohci, info);
 	}
 
 done:
@@ -470,7 +479,7 @@
  */
 static void start_ed_unlink (struct ohci_hcd *ohci, struct ed *ed)
 {    
-	ed->hwINFO |= ED_DEQUEUE;
+	ed->hwINFO |= cpu_to_hc32 (ohci, ED_DEQUEUE);
 	ed_deschedule (ohci, ed);
 
 	/* rm_list is just singly linked, for simplicity */
@@ -479,17 +488,17 @@
 	ohci->ed_rm_list = ed;
 
 	/* enable SOF interrupt */
-	writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
-	writel (OHCI_INTR_SF, &ohci->regs->intrenable);
+	ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus);
+	ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable);
 	// flush those writes, and get latest HCCA contents
-	(void) ohci_readl (&ohci->regs->control);
+	(void) ohci_readl (ohci, &ohci->regs->control);
 
 	/* SF interrupt might get delayed; record the frame counter value that
 	 * indicates when the HC isn't looking at it, so concurrent unlinks
 	 * behave.  frame_no wraps every 2^16 msec, and changes right before
 	 * SF is triggered.
 	 */
-	ed->tick = OHCI_FRAME_NO(ohci->hcca) + 1;
+	ed->tick = ohci_frame_no(ohci) + 1;
 
 }
 
@@ -541,19 +550,19 @@
 	if (!len)
 		data = 0;
 
-	td->hwINFO = cpu_to_le32 (info);
+	td->hwINFO = cpu_to_hc32 (ohci, info);
 	if (is_iso) {
-		td->hwCBP = cpu_to_le32 (data & 0xFFFFF000);
-		td->hwPSW [0] = cpu_to_le16 ((data & 0x0FFF) | 0xE000);
+		td->hwCBP = cpu_to_hc32 (ohci, data & 0xFFFFF000);
+		td->hwPSW [0] = cpu_to_hc16 (ohci, (data & 0x0FFF) | 0xE000);
 		td->ed->last_iso = info & 0xffff;
 	} else {
-		td->hwCBP = cpu_to_le32 (data); 
+		td->hwCBP = cpu_to_hc32 (ohci, data); 
 	}			
 	if (data)
-		td->hwBE = cpu_to_le32 (data + len - 1);
+		td->hwBE = cpu_to_hc32 (ohci, data + len - 1);
 	else
 		td->hwBE = 0;
-	td->hwNextTD = cpu_to_le32 (td_pt->td_dma);
+	td->hwNextTD = cpu_to_hc32 (ohci, td_pt->td_dma);
 
 	/* append to queue */
 	list_add_tail (&td->td_list, &td->ed->td_list);
@@ -594,7 +603,7 @@
   	if (!usb_gettoggle (urb->dev, usb_pipeendpoint (urb->pipe), is_out)) {
 		usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe),
 			is_out, 1);
-		urb_priv->ed->hwHeadP &= ~ED_C;
+		urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C);
 	}
 
 	urb_priv->td_cnt = 0;
@@ -643,7 +652,7 @@
 		/* maybe kickstart bulk list */
 		if (urb_priv->ed->type == PIPE_BULK) {
 			wmb ();
-			writel (OHCI_BLF, &ohci->regs->cmdstatus);
+			ohci_writel (ohci, OHCI_BLF, &ohci->regs->cmdstatus);
 		}
 		break;
 
@@ -665,7 +674,7 @@
 		td_fill (ohci, info, data, 0, urb, cnt++);
 		/* maybe kickstart control list */
 		wmb ();
-		writel (OHCI_CLF, &ohci->regs->cmdstatus);
+		ohci_writel (ohci, OHCI_CLF, &ohci->regs->cmdstatus);
 		break;
 
 	/* ISO has no retransmit, so no toggle; and it uses special TDs.
@@ -694,7 +703,7 @@
 	if (periodic) {
 		wmb ();
 		ohci->hc_control |= OHCI_CTRL_PLE|OHCI_CTRL_IE;
-		writel (ohci->hc_control, &ohci->regs->control);
+		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
 	}
 
 	// ASSERT (urb_priv->length == cnt);
@@ -709,14 +718,14 @@
  */
 static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td)
 {
-	u32	tdINFO = le32_to_cpup (&td->hwINFO);
+	u32	tdINFO = hc32_to_cpup (ohci, &td->hwINFO);
 	int	cc = 0;
 
 	list_del (&td->td_list);
 
 	/* ISO ... drivers see per-TD length/status */
   	if (tdINFO & TD_ISO) {
- 		u16	tdPSW = le16_to_cpu (td->hwPSW [0]);
+ 		u16	tdPSW = hc16_to_cpu (ohci, td->hwPSW [0]);
 		int	dlen = 0;
 
 		/* NOTE:  assumes FC in tdINFO == 0 (and MAXPSW == 1) */
@@ -748,7 +757,7 @@
 	 */
 	} else {
 		int	type = usb_pipetype (urb->pipe);
-		u32	tdBE = le32_to_cpup (&td->hwBE);
+		u32	tdBE = hc32_to_cpup (ohci, &td->hwBE);
 
   		cc = TD_CC_GET (tdINFO);
 
@@ -769,7 +778,7 @@
 				urb->actual_length += tdBE - td->data_dma + 1;
 			else
 				urb->actual_length +=
-					  le32_to_cpup (&td->hwCBP)
+					  hc32_to_cpup (ohci, &td->hwCBP)
 					- td->data_dma;
 		}
 
@@ -790,14 +799,14 @@
   	struct urb		*urb = td->urb;
 	struct ed		*ed = td->ed;
 	struct list_head	*tmp = td->td_list.next;
-	__le32			toggle = ed->hwHeadP & ED_C;
+	__hc32			toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C);
 
 	/* clear ed halt; this is the td that caused it, but keep it inactive
 	 * until its urb->complete() has a chance to clean up.
 	 */
-	ed->hwINFO |= ED_SKIP;
+	ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP);
 	wmb ();
-	ed->hwHeadP &= ~ED_H; 
+	ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H); 
 
 	/* put any later tds from this urb onto the donelist, after 'td',
 	 * order won't matter here: no errors, and nothing was transferred.
@@ -805,7 +814,7 @@
 	 */
 	while (tmp != &ed->td_list) {
 		struct td	*next;
-		__le32		info;
+		__hc32		info;
 
 		next = list_entry (tmp, struct td, td_list);
 		tmp = next->td_list.next;
@@ -821,8 +830,8 @@
 		 * and clear ED_SKIP.
 		 */
 		info = next->hwINFO;
-		info |= cpu_to_le32 (TD_DONE);
-		info &= ~cpu_to_le32 (TD_CC);
+		info |= cpu_to_hc32 (ohci, TD_DONE);
+		info &= ~cpu_to_hc32 (ohci, TD_CC);
 		next->hwINFO = info;
 
 		next->next_dl_td = rev;	
@@ -850,7 +859,7 @@
 			urb, urb->dev->devpath,
 			usb_pipeendpoint (urb->pipe),
 			usb_pipein (urb->pipe) ? "in" : "out",
-			le32_to_cpu (td->hwINFO),
+			hc32_to_cpu (ohci, td->hwINFO),
 			cc, cc_to_error [cc]);
 	}
 
@@ -866,7 +875,7 @@
 	struct td	*td_rev = NULL;
 	struct td	*td = NULL;
 
-	td_dma = le32_to_cpup (&ohci->hcca->done_head);
+	td_dma = hc32_to_cpup (ohci, &ohci->hcca->done_head);
 	ohci->hcca->done_head = 0;
 	wmb();
 
@@ -882,19 +891,20 @@
 			break;
 		}
 
-		td->hwINFO |= cpu_to_le32 (TD_DONE);
-		cc = TD_CC_GET (le32_to_cpup (&td->hwINFO));
+		td->hwINFO |= cpu_to_hc32 (ohci, TD_DONE);
+		cc = TD_CC_GET (hc32_to_cpup (ohci, &td->hwINFO));
 
 		/* Non-iso endpoints can halt on error; un-halt,
 		 * and dequeue any other TDs from this urb.
 		 * No other TD could have caused the halt.
 		 */
-		if (cc != TD_CC_NOERROR && (td->ed->hwHeadP & ED_H))
+		if (cc != TD_CC_NOERROR
+				&& (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H)))
 			td_rev = ed_halted (ohci, td, cc, td_rev);
 
 		td->next_dl_td = td_rev;	
 		td_rev = td;
-		td_dma = le32_to_cpup (&td->hwNextTD);
+		td_dma = hc32_to_cpup (ohci, &td->hwNextTD);
 	}	
 	return td_rev;
 }
@@ -911,7 +921,7 @@
 	for (last = &ohci->ed_rm_list, ed = *last; ed != NULL; ed = *last) {
 		struct list_head	*entry, *tmp;
 		int			completed, modified;
-		__le32			*prev;
+		__hc32			*prev;
 
 		/* only take off EDs that the HC isn't using, accounting for
 		 * frame counter wraps and EDs with partially retired TDs
@@ -929,7 +939,8 @@
 
 				td = list_entry (ed->td_list.next, struct td,
 							td_list);
-				head = le32_to_cpu (ed->hwHeadP) & TD_MASK;
+				head = hc32_to_cpu (ohci, ed->hwHeadP) &
+								TD_MASK;
 
 				/* INTR_WDH may need to clean up first */
 				if (td->td_dma != head)
@@ -960,7 +971,7 @@
 			struct td	*td;
 			struct urb	*urb;
 			urb_priv_t	*urb_priv;
-			__le32		savebits;
+			__hc32		savebits;
 
 			td = list_entry (entry, struct td, td_list);
 			urb = td->urb;
@@ -972,7 +983,7 @@
 			}
 
 			/* patch pointer hc uses */
-			savebits = *prev & ~cpu_to_le32 (TD_MASK);
+			savebits = *prev & ~cpu_to_hc32 (ohci, TD_MASK);
 			*prev = td->hwNextTD | savebits;
 
 			/* HC may have partly processed this TD */
@@ -990,10 +1001,10 @@
 
 		/* ED's now officially unlinked, hc doesn't see */
 		ed->state = ED_IDLE;
-		ed->hwHeadP &= ~ED_H;
+		ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H);
 		ed->hwNextED = 0;
 		wmb ();
-		ed->hwINFO &= ~(ED_SKIP | ED_DEQUEUE);
+		ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP | ED_DEQUEUE);
 
 		/* but if there's work queued, reschedule */
 		if (!list_empty (&ed->td_list)) {
@@ -1015,24 +1026,27 @@
 			command |= OHCI_CLF;
 			if (!(ohci->hc_control & OHCI_CTRL_CLE)) {
 				control |= OHCI_CTRL_CLE;
-				writel (0, &ohci->regs->ed_controlcurrent);
+				ohci_writel (ohci, 0,
+					&ohci->regs->ed_controlcurrent);
 			}
 		}
 		if (ohci->ed_bulktail) {
 			command |= OHCI_BLF;
 			if (!(ohci->hc_control & OHCI_CTRL_BLE)) {
 				control |= OHCI_CTRL_BLE;
-				writel (0, &ohci->regs->ed_bulkcurrent);
+				ohci_writel (ohci, 0,
+					&ohci->regs->ed_bulkcurrent);
 			}
 		}
 		
 		/* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */
 		if (control) {
 			ohci->hc_control |= control;
- 			writel (ohci->hc_control, &ohci->regs->control);   
+ 			ohci_writel (ohci, ohci->hc_control,
+					&ohci->regs->control);   
  		}
 		if (command)
-			writel (command, &ohci->regs->cmdstatus);   
+			ohci_writel (ohci, command, &ohci->regs->cmdstatus);   
  	}
 }
 
@@ -1072,18 +1086,19 @@
 				start_ed_unlink (ohci, ed);
 
 		/* ... reenabling halted EDs only after fault cleanup */
-		} else if ((ed->hwINFO & (ED_SKIP | ED_DEQUEUE)) == ED_SKIP) {
+		} else if ((ed->hwINFO & cpu_to_hc32 (ohci, ED_SKIP | ED_DEQUEUE))
+					== cpu_to_hc32 (ohci, ED_SKIP)) {
 			td = list_entry (ed->td_list.next, struct td, td_list);
-			if (!(td->hwINFO & TD_DONE)) {
-				ed->hwINFO &= ~ED_SKIP;
+ 			if (!(td->hwINFO & cpu_to_hc32 (ohci, TD_DONE))) {
+				ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP);
 				/* ... hc may need waking-up */
 				switch (ed->type) {
 				case PIPE_CONTROL:
-					writel (OHCI_CLF,
+					ohci_writel (ohci, OHCI_CLF,
 						&ohci->regs->cmdstatus);   
 					break;
 				case PIPE_BULK:
-					writel (OHCI_BLF,
+					ohci_writel (ohci, OHCI_BLF,
 						&ohci->regs->cmdstatus);   
 					break;
 				}
diff -Nru a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
--- a/drivers/usb/host/ohci-sa1111.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/usb/host/ohci-sa1111.c	2004-12-24 13:36:55 -08:00
@@ -194,6 +194,7 @@
 
 	usb_bus_init (&hcd->self);
 	hcd->self.op = &usb_hcd_operations;
+	hcd->self.release = &usb_hcd_release;
 	hcd->self.hcpriv = (void *) hcd;
 	hcd->self.bus_name = "sa1111";
 	hcd->product_desc = "SA-1111 OHCI";
@@ -213,9 +214,8 @@
 
  err2:
 	hcd_buffer_destroy (hcd);
-	if (hcd)
-		driver->hcd_free(hcd);
  err1:
+	kfree(hcd);
 	sa1111_stop_hc(dev);
 	release_mem_region(dev->res.start, dev->res.end - dev->res.start + 1);
 	return retval;
@@ -237,8 +237,6 @@
  */
 void usb_hcd_sa1111_remove (struct usb_hcd *hcd, struct sa1111_dev *dev)
 {
-	void *base;
-
 	info ("remove: %s, state %x", hcd->self.bus_name, hcd->state);
 
 	if (in_interrupt ())
@@ -257,9 +255,6 @@
 
 	usb_deregister_bus (&hcd->self);
 
-	base = hcd->regs;
-	hcd->driver->hcd_free (hcd);
-
 	sa1111_stop_hc(dev);
 	release_mem_region(dev->res.start, dev->res.end - dev->res.start + 1);
 }
@@ -272,33 +267,14 @@
 	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);
 	int		ret;
 
-	ohci->hcca = dma_alloc_coherent (hcd->self.controller,
-			sizeof *ohci->hcca, &ohci->hcca_dma, 0);
-	if (!ohci->hcca)
-		return -ENOMEM;
-        
-	memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
-	if ((ret = ohci_mem_init (ohci)) < 0) {
-		ohci_stop (hcd);
+	if ((ret = ohci_init(ohci)) < 0)
 		return ret;
-	}
-	ohci->regs = hcd->regs;
-
-	if (hc_reset (ohci) < 0) {
-		ohci_stop (hcd);
-		return -ENODEV;
-	}
 
-	if (hc_start (ohci) < 0) {
+	if ((ret = ohci_run (ohci)) < 0) {
 		err ("can't start %s", ohci->hcd.self.bus_name);
 		ohci_stop (hcd);
-		return -EBUSY;
+		return ret;
 	}
-	create_debug_files (ohci);
-
-#ifdef	DEBUG
-	ohci_dump (ohci, 1);
-#endif
 	return 0;
 }
 
@@ -327,7 +303,6 @@
 	 * memory lifecycle (except per-request)
 	 */
 	.hcd_alloc =		ohci_hcd_alloc,
-	.hcd_free =		ohci_hcd_free,
 
 	/*
 	 * managing i/o requests and associated device resources
diff -Nru a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
--- a/drivers/usb/host/ohci.h	2004-12-24 13:37:32 -08:00
+++ b/drivers/usb/host/ohci.h	2004-12-24 13:37:32 -08:00
@@ -6,6 +6,14 @@
  * 
  * This file is licenced under the GPL.
  */
+
+/*
+ * __hc32 and __hc16 are "Host Controller" types, they may be equivalent to
+ * __leXX (normally) or __beXX (given OHCI_BIG_ENDIAN), depending on the
+ * host controller implementation.
+ */
+typedef __u32 __bitwise __hc32;
+typedef __u16 __bitwise __hc16;
  
 /*
  * OHCI Endpoint Descriptor (ED) ... holds TD queue
@@ -15,21 +23,21 @@
  * both EHCI and UHCI call similar structures a "QH".
  */
 struct ed {
-	/* first fields are hardware-specified, le32 */
-	__le32			hwINFO;       	/* endpoint config bitmap */
+	/* first fields are hardware-specified */
+	__hc32			hwINFO;       	/* endpoint config bitmap */
 	/* info bits defined by hcd */
-#define ED_DEQUEUE	__constant_cpu_to_le32(1 << 27)
+#define ED_DEQUEUE	(1 << 27)
 	/* info bits defined by the hardware */
-#define ED_ISO		__constant_cpu_to_le32(1 << 15)
-#define ED_SKIP		__constant_cpu_to_le32(1 << 14)
-#define ED_LOWSPEED	__constant_cpu_to_le32(1 << 13)
-#define ED_OUT		__constant_cpu_to_le32(0x01 << 11)
-#define ED_IN		__constant_cpu_to_le32(0x02 << 11)
-	__le32			hwTailP;	/* tail of TD list */
-	__le32			hwHeadP;	/* head of TD list (hc r/w) */
-#define ED_C		__constant_cpu_to_le32(0x02)	/* toggle carry */
-#define ED_H		__constant_cpu_to_le32(0x01)	/* halted */
-	__le32			hwNextED;	/* next ED in list */
+#define ED_ISO		(1 << 15)
+#define ED_SKIP		(1 << 14)
+#define ED_LOWSPEED	(1 << 13)
+#define ED_OUT		(0x01 << 11)
+#define ED_IN		(0x02 << 11)
+	__hc32			hwTailP;	/* tail of TD list */
+	__hc32			hwHeadP;	/* head of TD list (hc r/w) */
+#define ED_C		(0x02)			/* toggle carry */
+#define ED_H		(0x01)			/* halted */
+	__hc32			hwNextED;	/* next ED in list */
 
 	/* rest are purely for the driver's use */
 	dma_addr_t		dma;		/* addr of ED */
@@ -42,7 +50,6 @@
 
 	/* create --> IDLE --> OPER --> ... --> IDLE --> destroy
 	 * usually:  OPER --> UNLINK --> (IDLE | OPER) --> ...
-	 * some special cases :  OPER --> IDLE ...
 	 */
 	u8			state;		/* ED_{IDLE,UNLINK,OPER} */
 #define ED_IDLE 	0x00		/* NOT linked to HC */
@@ -70,8 +77,8 @@
  * and 4.3.2 (iso)
  */
 struct td {
-	/* first fields are hardware-specified, le32 */
-	__le32		hwINFO;		/* transfer info bitmask */
+	/* first fields are hardware-specified */
+	__hc32		hwINFO;		/* transfer info bitmask */
 
 	/* hwINFO bits for both general and iso tds: */
 #define TD_CC       0xf0000000			/* condition code */
@@ -100,13 +107,13 @@
 
 	/* (no hwINFO #defines yet for iso tds) */
 
-  	__le32		hwCBP;		/* Current Buffer Pointer (or 0) */
-  	__le32		hwNextTD;	/* Next TD Pointer */
-  	__le32		hwBE;		/* Memory Buffer End Pointer */
+  	__hc32		hwCBP;		/* Current Buffer Pointer (or 0) */
+  	__hc32		hwNextTD;	/* Next TD Pointer */
+  	__hc32		hwBE;		/* Memory Buffer End Pointer */
 
 	/* PSW is only for ISO */
 #define MAXPSW 1		/* hardware allows 8 */
-  	__le16		hwPSW [MAXPSW];
+  	__hc16		hwPSW [MAXPSW];
 
 	/* rest are purely for the driver's use */
   	__u8		index;
@@ -171,20 +178,20 @@
  */
 struct ohci_hcca {
 #define NUM_INTS 32
-	__le32	int_table [NUM_INTS];	/* periodic schedule */
+	__hc32	int_table [NUM_INTS];	/* periodic schedule */
 
 	/* 
 	 * OHCI defines u16 frame_no, followed by u16 zero pad.
 	 * Since some processors can't do 16 bit bus accesses,
 	 * portable access must be a 32 bit byteswapped access.
 	 */
-	__le32	frame_no;		/* current frame number */
-#define OHCI_FRAME_NO(hccap) ((u16)le32_to_cpup(&(hccap)->frame_no))
-	__le32	done_head;		/* info returned for an interrupt */
+	__hc32	frame_no;		/* current frame number */
+	__hc32	done_head;		/* info returned for an interrupt */
 	u8	reserved_for_hc [116];
 	u8	what [4];		/* spec only identifies 252 bytes :) */
 } __attribute__ ((aligned(256)));
 
+#define ohci_frame_no(ohci) ((u16)hc32_to_cpup(ohci,&(ohci)->hcca->frame_no))
   
 /*
  * This is the structure of the OHCI controller's memory mapped I/O region.
@@ -193,36 +200,36 @@
  */
 struct ohci_regs {
 	/* control and status registers (section 7.1) */
-	__u32	revision;
-	__u32	control;
-	__u32	cmdstatus;
-	__u32	intrstatus;
-	__u32	intrenable;
-	__u32	intrdisable;
+	__hc32	revision;
+	__hc32	control;
+	__hc32	cmdstatus;
+	__hc32	intrstatus;
+	__hc32	intrenable;
+	__hc32	intrdisable;
 
 	/* memory pointers (section 7.2) */
-	__u32	hcca;
-	__u32	ed_periodcurrent;
-	__u32	ed_controlhead;
-	__u32	ed_controlcurrent;
-	__u32	ed_bulkhead;
-	__u32	ed_bulkcurrent;
-	__u32	donehead;
+	__hc32	hcca;
+	__hc32	ed_periodcurrent;
+	__hc32	ed_controlhead;
+	__hc32	ed_controlcurrent;
+	__hc32	ed_bulkhead;
+	__hc32	ed_bulkcurrent;
+	__hc32	donehead;
 
 	/* frame counters (section 7.3) */
-	__u32	fminterval;
-	__u32	fmremaining;
-	__u32	fmnumber;
-	__u32	periodicstart;
-	__u32	lsthresh;
+	__hc32	fminterval;
+	__hc32	fmremaining;
+	__hc32	fmnumber;
+	__hc32	periodicstart;
+	__hc32	lsthresh;
 
 	/* Root hub ports (section 7.4) */
 	struct	ohci_roothub_regs {
-		__u32	a;
-		__u32	b;
-		__u32	status;
+		__hc32	a;
+		__hc32	b;
+		__hc32	status;
 #define MAX_ROOT_PORTS	15	/* maximum OHCI root hub ports (RH_A_NDP) */
-		__u32	portstatus [MAX_ROOT_PORTS];
+		__hc32	portstatus [MAX_ROOT_PORTS];
 	} roothub;
 
 	/* and optional "legacy support" registers (appendix B) at 0x0100 */
@@ -338,6 +345,11 @@
  */
 
 struct ohci_hcd {
+	/*
+	 * framework state
+	 */
+	struct usb_hcd		hcd;		/* must come first! */
+
 	spinlock_t		lock;
 
 	/*
@@ -387,36 +399,16 @@
 	unsigned long		flags;		/* for HC bugs */
 #define	OHCI_QUIRK_AMD756	0x01			/* erratum #4 */
 #define	OHCI_QUIRK_SUPERIO	0x02			/* natsemi */
+#define	OHCI_QUIRK_INITRESET	0x04			/* SiS, OPTi, ... */
+#define	OHCI_BIG_ENDIAN		0x08			/* big endian HC */
 	// there are also chip quirks/bugs in init logic
 
-	/*
-	 * framework state
-	 */
-	struct usb_hcd		hcd;
 };
 
 #define hcd_to_ohci(hcd_ptr) container_of(hcd_ptr, struct ohci_hcd, hcd)
 
 /*-------------------------------------------------------------------------*/
 
-static inline void disable (struct ohci_hcd *ohci)
-{
-	ohci->hcd.state = USB_STATE_HALT;
-}
-
-#define	FI			0x2edf		/* 12000 bits per frame (-1) */
-#define	DEFAULT_FMINTERVAL 	((((6 * (FI - 210)) / 7) << 16) | FI)
-#define LSTHRESH		0x628		/* lowspeed bit threshold */
-
-static inline void periodic_reinit (struct ohci_hcd *ohci)
-{
-	writel (ohci->fminterval, &ohci->regs->fminterval);
-	writel (((9 * FI) / 10) & 0x3fff, &ohci->regs->periodicstart);
-	writel (LSTHRESH, &ohci->regs->lsthresh);
-}
-
-/*-------------------------------------------------------------------------*/
-
 #ifndef DEBUG
 #define STUB_DEBUG_FILES
 #endif	/* DEBUG */
@@ -436,22 +428,164 @@
 #	define ohci_vdbg(ohci, fmt, args...) do { } while (0)
 #endif
 
+/*-------------------------------------------------------------------------*/
+
+/*
+ * While most USB host controllers implement their registers and
+ * in-memory communication descriptors in little-endian format,
+ * a minority (notably the IBM STB04XXX and the Motorola MPC5200
+ * processors) implement them in big endian format.
+ *
+ * This attempts to support either format at compile time without a
+ * runtime penalty, or both formats with the additional overhead
+ * of checking a flag bit.
+ */
+
+#ifdef CONFIG_USB_OHCI_BIG_ENDIAN
+
+#ifdef CONFIG_USB_OHCI_LITTLE_ENDIAN
+#define big_endian(ohci)	(ohci->flags & OHCI_BIG_ENDIAN) /* either */
+#else
+#define big_endian(ohci)	1		/* only big endian */
+#endif
+
+/*
+ * Big-endian read/write functions are arch-specific.
+ * Other arches can be added if/when they're needed.
+ */
+#if defined(CONFIG_PPC)
+#define readl_be(addr)		in_be32((__force unsigned *)addr)
+#define writel_be(val, addr)	out_be32((__force unsigned *)addr, val)
+#endif
+
+static inline unsigned int ohci_readl (const struct ohci_hcd *ohci,
+							__hc32 __iomem * regs)
+{
+	return big_endian(ohci) ? readl_be (regs) : readl ((__force u32 *)regs);
+}
+
+static inline void ohci_writel (const struct ohci_hcd *ohci,
+				const unsigned int val, __hc32 __iomem *regs)
+{
+	big_endian(ohci) ? writel_be (val, regs) :
+			   writel (val, (__force u32 *)regs);
+}
+
+#else	/* !CONFIG_USB_OHCI_BIG_ENDIAN */
+
+#define big_endian(ohci)	0		/* only little endian */
+
 #ifdef CONFIG_ARCH_LH7A404
 	/* Marc Singer: at the time this code was written, the LH7A404
 	 * had a problem reading the USB host registers.  This
 	 * implementation of the ohci_readl function performs the read
 	 * twice as a work-around.
 	 */
-static inline unsigned int ohci_readl (void* regs)
+static inline unsigned int
+ohci_readl (const struct ohci_hcd *ohci, const __hc32 *regs)
 {
-	*(volatile unsigned int*) regs;
-	return *(volatile unsigned int*) regs;
+	*(volatile __force unsigned int*) regs;
+	return *(volatile __force unsigned int*) regs;
 }
 #else
 	/* Standard version of ohci_readl uses standard, platform
 	 * specific implementation. */
-static inline unsigned int ohci_readl (void __iomem * regs)
+static inline unsigned int
+ohci_readl (const struct ohci_hcd *ohci, __hc32 __iomem * regs)
 {
-	return readl (regs);
+	return readl(regs);
 }
 #endif
+
+static inline void ohci_writel (const struct ohci_hcd *ohci,
+				const unsigned int val, __hc32 __iomem *regs)
+{
+	writel (val, regs);
+}
+
+#endif	/* !CONFIG_USB_OHCI_BIG_ENDIAN */
+
+/*-------------------------------------------------------------------------*/
+
+/* cpu to ohci */
+static inline __hc16 cpu_to_hc16 (const struct ohci_hcd *ohci, const u16 x)
+{
+	return big_endian(ohci) ? (__force __hc16)cpu_to_be16(x) : (__force __hc16)cpu_to_le16(x);
+}
+
+static inline __hc16 cpu_to_hc16p (const struct ohci_hcd *ohci, const u16 *x)
+{
+	return big_endian(ohci) ? cpu_to_be16p(x) : cpu_to_le16p(x);
+}
+
+static inline __hc32 cpu_to_hc32 (const struct ohci_hcd *ohci, const u32 x)
+{
+	return big_endian(ohci) ? (__force __hc32)cpu_to_be32(x) : (__force __hc32)cpu_to_le32(x);
+}
+
+static inline __hc32 cpu_to_hc32p (const struct ohci_hcd *ohci, const u32 *x)
+{
+	return big_endian(ohci) ? cpu_to_be32p(x) : cpu_to_le32p(x);
+}
+
+/* ohci to cpu */
+static inline u16 hc16_to_cpu (const struct ohci_hcd *ohci, const __hc16 x)
+{
+	return big_endian(ohci) ? be16_to_cpu((__force __be16)x) : le16_to_cpu((__force __le16)x);
+}
+
+static inline u16 hc16_to_cpup (const struct ohci_hcd *ohci, const __hc16 *x)
+{
+	return big_endian(ohci) ? be16_to_cpup((__force __be16 *)x) : le16_to_cpup((__force __le16 *)x);
+}
+
+static inline u32 hc32_to_cpu (const struct ohci_hcd *ohci, const __hc32 x)
+{
+	return big_endian(ohci) ? be32_to_cpu((__force __be32)x) : le32_to_cpu((__force __le32)x);
+}
+
+static inline u32 hc32_to_cpup (const struct ohci_hcd *ohci, const __hc32 *x)
+{
+	return big_endian(ohci) ? be32_to_cpup((__force __be32 *)x) : le32_to_cpup((__force __le32 *)x);
+}
+
+/*-------------------------------------------------------------------------*/
+
+static inline void disable (struct ohci_hcd *ohci)
+{
+	ohci->hcd.state = USB_STATE_HALT;
+}
+
+#define	FI			0x2edf		/* 12000 bits per frame (-1) */
+#define	FSMP(fi) 		(0x7fff & ((6 * ((fi) - 210)) / 7))
+#define LSTHRESH		0x628		/* lowspeed bit threshold */
+
+static inline void periodic_reinit (struct ohci_hcd *ohci)
+{
+	u32	fi = ohci->fminterval & 0x0ffff;
+
+	ohci_writel (ohci, ((9 * fi) / 10) & 0x3fff,
+						&ohci->regs->periodicstart);
+}
+
+/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
+ * The erratum (#4) description is incorrect.  AMD's workaround waits
+ * till some bits (mostly reserved) are clear; ok for all revs.
+ */
+#define read_roothub(hc, register, mask) ({ \
+	u32 temp = ohci_readl (hc, &hc->regs->roothub.register); \
+	if (temp == -1) \
+		disable (hc); \
+	else if (hc->flags & OHCI_QUIRK_AMD756) \
+		while (temp & mask) \
+			temp = ohci_readl (hc, &hc->regs->roothub.register); \
+	temp; })
+
+static u32 roothub_a (struct ohci_hcd *hc)
+	{ return read_roothub (hc, a, 0xfc0fe000); }
+static inline u32 roothub_b (struct ohci_hcd *hc)
+	{ return ohci_readl (hc, &hc->regs->roothub.b); }
+static inline u32 roothub_status (struct ohci_hcd *hc)
+	{ return ohci_readl (hc, &hc->regs->roothub.status); }
+static u32 roothub_portstatus (struct ohci_hcd *hc, int i)
+	{ return read_roothub (hc, portstatus [i], 0xffe0fce0); }
diff -Nru a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/host/sl811-hcd.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1905 @@
+/*
+ * SL811HS HCD (Host Controller Driver) for USB.
+ *
+ * Copyright (C) 2004 Psion Teklogix (for NetBook PRO)
+ * Copyright (C) 2004 David Brownell
+ * 
+ * Periodic scheduling is based on Roman's OHCI code
+ * 	Copyright (C) 1999 Roman Weissgaerber
+ *
+ * The SL811HS controller handles host side USB (like the SL11H, but with
+ * another register set and SOF generation) as well as peripheral side USB
+ * (like the SL811S).  This driver version doesn't implement the Gadget API
+ * for the peripheral role; or OTG (that'd need much external circuitry).
+ *
+ * For documentation, see the SL811HS spec and the "SL811HS Embedded Host"
+ * document (providing significant pieces missing from that spec); plus
+ * the SL811S spec if you want peripheral side info.
+ */ 
+
+/*
+ * Status:  Passed basic stress testing, works with hubs, mice, keyboards,
+ * and usb-storage.
+ *
+ * TODO:
+ * - usb suspend/resume triggered by sl811 (with USB_SUSPEND)
+ * - various issues noted in the code
+ * - performance work; use both register banks; ...
+ * - use urb->iso_frame_desc[] with ISO transfers
+ */
+
+#undef	VERBOSE
+#undef	PACKET_TRACE
+
+#include <linux/config.h>
+
+#ifdef CONFIG_USB_DEBUG
+#	define DEBUG
+#else
+#	undef DEBUG
+#endif
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/smp_lock.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/timer.h>
+#include <linux/list.h>
+#include <linux/interrupt.h>
+#include <linux/usb.h>
+#include <linux/usb_sl811.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <asm/byteorder.h>
+
+#include "../core/hcd.h"
+#include "sl811.h"
+
+
+MODULE_DESCRIPTION("SL811HS USB Host Controller Driver");
+MODULE_LICENSE("GPL");
+
+#define DRIVER_VERSION	"06 Dec 2004"
+
+
+#ifndef DEBUG
+#	define	STUB_DEBUG_FILE
+#endif
+
+/* for now, use only one transfer register bank */
+#undef	USE_B
+
+/* this doesn't understand urb->iso_frame_desc[], but if you had a driver
+ * that just queued one ISO frame per URB then iso transfers "should" work
+ * using the normal urb status fields.
+ */
+#define	DISABLE_ISO
+
+// #define	QUIRK2
+#define	QUIRK3
+
+static const char hcd_name[] = "sl811-hcd";
+
+/*-------------------------------------------------------------------------*/
+
+static irqreturn_t sl811h_irq(int irq, void *_sl811, struct pt_regs *regs);
+
+static void port_power(struct sl811 *sl811, int is_on)
+{
+	/* hub is inactive unless the port is powered */
+	if (is_on) {
+		if (sl811->port1 & (1 << USB_PORT_FEAT_POWER))
+			return;
+
+		sl811->port1 = (1 << USB_PORT_FEAT_POWER);
+		sl811->irq_enable = SL11H_INTMASK_INSRMV;
+		sl811->hcd.self.controller->power.power_state = PM_SUSPEND_ON;
+	} else {
+		sl811->port1 = 0;
+		sl811->irq_enable = 0;
+		sl811->hcd.state = USB_STATE_HALT;
+		sl811->hcd.self.controller->power.power_state = PM_SUSPEND_DISK;
+	}
+	sl811->ctrl1 = 0;
+	sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
+	sl811_write(sl811, SL11H_IRQ_STATUS, ~0);
+
+	if (sl811->board && sl811->board->port_power) {
+		/* switch VBUS, at 500mA unless hub power budget gets set */
+		DBG("power %s\n", is_on ? "on" : "off");
+		sl811->board->port_power(sl811->hcd.self.controller, is_on);
+	}
+
+	/* reset as thoroughly as we can */
+	if (sl811->board && sl811->board->reset)
+		sl811->board->reset(sl811->hcd.self.controller);
+
+	sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
+	sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
+	sl811_write(sl811, SL811HS_CTLREG2, SL811HS_CTL2_INIT);
+	sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
+
+	// if !is_on, put into lowpower mode now
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* This is a PIO-only HCD.  Queueing appends URBs to the endpoint's queue,
+ * and may start I/O.  Endpoint queues are scanned during completion irq
+ * handlers (one per packet: ACK, NAK, faults, etc) and urb cancelation.
+ *
+ * Using an external DMA engine to copy a packet at a time could work,
+ * though setup/teardown costs may be too big to make it worthwhile.
+ */
+
+/* SETUP starts a new control request.  Devices are not allowed to
+ * STALL or NAK these; they must cancel any pending control requests.
+ */
+static void setup_packet(
+	struct sl811		*sl811,
+	struct sl811h_ep	*ep,
+	struct urb		*urb,
+	u8			bank,
+	u8			control
+)
+{
+	u8			addr;
+	u8			len;
+	void __iomem		*data_reg;
+
+	addr = SL811HS_PACKET_BUF(bank == 0);
+	len = sizeof(struct usb_ctrlrequest);
+	data_reg = sl811->data_reg;
+	sl811_write_buf(sl811, addr, urb->setup_packet, len);
+
+	/* autoincrementing */
+	sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
+	writeb(len, data_reg);
+	writeb(SL_SETUP /* | ep->epnum */, data_reg);
+	writeb(usb_pipedevice(urb->pipe), data_reg);
+
+	/* always OUT/data0 */ ;
+	sl811_write(sl811, bank + SL11H_HOSTCTLREG,
+			control | SL11H_HCTLMASK_OUT);
+	ep->length = 0;
+	PACKET("SETUP qh%p\n", ep);
+}
+
+/* STATUS finishes control requests, often after IN or OUT data packets */
+static void status_packet(
+	struct sl811		*sl811,
+	struct sl811h_ep	*ep,
+	struct urb		*urb,
+	u8			bank,
+	u8			control
+)
+{
+	int			do_out;
+	void __iomem		*data_reg;
+
+	do_out = urb->transfer_buffer_length && usb_pipein(urb->pipe);
+	data_reg = sl811->data_reg;
+
+	/* autoincrementing */
+	sl811_write(sl811, bank + SL11H_BUFADDRREG, 0);
+	writeb(0, data_reg);
+	writeb((do_out ? SL_OUT : SL_IN) /* | ep->epnum */, data_reg);
+	writeb(usb_pipedevice(urb->pipe), data_reg);
+
+	/* always data1; sometimes IN */
+	control |= SL11H_HCTLMASK_TOGGLE;
+	if (do_out)
+		control |= SL11H_HCTLMASK_OUT;
+	sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
+	ep->length = 0;
+	PACKET("STATUS%s/%s qh%p\n", ep->nak_count ? "/retry" : "",
+			do_out ? "out" : "in", ep);
+}
+
+/* IN packets can be used with any type of endpoint. here we just
+ * start the transfer, data from the peripheral may arrive later.
+ * urb->iso_frame_desc is currently ignored here...
+ */
+static void in_packet(
+	struct sl811		*sl811,
+	struct sl811h_ep	*ep,
+	struct urb		*urb,
+	u8			bank,
+	u8			control
+)
+{
+	u8			addr;
+	u8			len;
+	void __iomem		*data_reg;
+
+	/* avoid losing data on overflow */
+	len = ep->maxpacket;
+	addr = SL811HS_PACKET_BUF(bank == 0);
+	if (!(control & SL11H_HCTLMASK_ISOCH)
+			&& usb_gettoggle(urb->dev, ep->epnum, 0))
+		control |= SL11H_HCTLMASK_TOGGLE;
+	data_reg = sl811->data_reg;
+
+	/* autoincrementing */
+	sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
+	writeb(len, data_reg);
+	writeb(SL_IN | ep->epnum, data_reg);
+	writeb(usb_pipedevice(urb->pipe), data_reg);
+
+	sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
+	ep->length = min((int)len,
+			urb->transfer_buffer_length - urb->actual_length);
+	PACKET("IN%s/%d qh%p len%d\n", ep->nak_count ? "/retry" : "",
+			!!usb_gettoggle(urb->dev, ep->epnum, 0), ep, len);
+}
+
+/* OUT packets can be used with any type of endpoint.
+ * urb->iso_frame_desc is currently ignored here...
+ */
+static void out_packet(
+	struct sl811		*sl811,
+	struct sl811h_ep	*ep,
+	struct urb		*urb,
+	u8			bank,
+	u8			control
+)
+{
+	void			*buf;
+	u8			addr;
+	u8			len;
+	void __iomem		*data_reg;
+
+	buf = urb->transfer_buffer + urb->actual_length;
+	prefetch(buf);
+
+	len = min((int)ep->maxpacket,
+			urb->transfer_buffer_length - urb->actual_length);
+
+	if (!(control & SL11H_HCTLMASK_ISOCH)
+			&& usb_gettoggle(urb->dev, ep->epnum, 1))
+		control |= SL11H_HCTLMASK_TOGGLE;
+	addr = SL811HS_PACKET_BUF(bank == 0);
+	data_reg = sl811->data_reg;
+
+	sl811_write_buf(sl811, addr, buf, len);
+
+	/* autoincrementing */
+	sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
+	writeb(len, data_reg);
+	writeb(SL_OUT | ep->epnum, data_reg);
+	writeb(usb_pipedevice(urb->pipe), data_reg);
+
+	sl811_write(sl811, bank + SL11H_HOSTCTLREG,
+			control | SL11H_HCTLMASK_OUT);
+	ep->length = len;
+	PACKET("OUT%s/%d qh%p len%d\n", ep->nak_count ? "/retry" : "",
+			!!usb_gettoggle(urb->dev, ep->epnum, 1), ep, len);
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* caller updates on-chip enables later */
+
+static inline void sofirq_on(struct sl811 *sl811)
+{
+	if (sl811->irq_enable & SL11H_INTMASK_SOFINTR)
+		return;
+	VDBG("sof irq on\n");
+	sl811->irq_enable |= SL11H_INTMASK_SOFINTR;
+}
+
+static inline void sofirq_off(struct sl811 *sl811)
+{
+	if (!(sl811->irq_enable & SL11H_INTMASK_SOFINTR))
+		return;
+	VDBG("sof irq off\n");
+	sl811->irq_enable &= ~SL11H_INTMASK_SOFINTR;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* pick the next endpoint for a transaction, and issue it.
+ * frames start with periodic transfers (after whatever is pending
+ * from the previous frame), and the rest of the time is async
+ * transfers, scheduled round-robin.
+ */
+static struct sl811h_ep	*start(struct sl811 *sl811, u8 bank)
+{
+	struct sl811h_ep	*ep;
+	struct sl811h_req	*req;
+	struct urb		*urb;
+	int			fclock;
+	u8			control;
+
+	/* use endpoint at schedule head */
+	if (sl811->next_periodic) {
+		ep = sl811->next_periodic;
+		sl811->next_periodic = ep->next;
+	} else {
+		if (sl811->next_async)
+			ep = sl811->next_async;
+		else if (!list_empty(&sl811->async))
+			ep = container_of(sl811->async.next,
+					struct sl811h_ep, schedule);
+		else {
+			/* could set up the first fullspeed periodic
+			 * transfer for the next frame ...
+			 */
+			return NULL;
+		}
+
+#ifdef USE_B
+		if ((bank && sl811->active_b == ep) || sl811->active_a == ep)
+			return NULL;
+#endif
+
+		if (ep->schedule.next == &sl811->async)
+			sl811->next_async = NULL;
+		else
+			sl811->next_async = container_of(ep->schedule.next,
+					struct sl811h_ep, schedule);
+	}
+
+	if (unlikely(list_empty(&ep->queue))) {
+		DBG("empty %p queue?\n", ep);
+		return NULL;
+	}
+
+	req = container_of(ep->queue.next, struct sl811h_req, queue);
+	urb = req->urb;
+	control = ep->defctrl;
+
+	/* if this frame doesn't have enough time left to transfer this
+	 * packet, wait till the next frame.  too-simple algorithm...
+	 */
+	fclock = sl811_read(sl811, SL11H_SOFTMRREG) << 6;
+	fclock -= 100;		/* setup takes not much time */
+	if (urb->dev->speed == USB_SPEED_LOW) {
+		if (control & SL11H_HCTLMASK_PREAMBLE) {
+			/* also note erratum 1: some hubs won't work */
+			fclock -= 800;
+		}
+		fclock -= ep->maxpacket << 8;
+
+		/* erratum 2: AFTERSOF only works for fullspeed */
+		if (fclock < 0) {
+			if (ep->period)
+				sl811->stat_overrun++;
+			sofirq_on(sl811);
+			return NULL;
+		}
+	} else {
+		fclock -= 12000 / 19;	/* 19 64byte packets/msec */
+		if (fclock < 0) {
+			if (ep->period)
+				sl811->stat_overrun++;
+			control |= SL11H_HCTLMASK_AFTERSOF;
+
+		/* throttle bulk/control irq noise */
+		} else if (ep->nak_count)
+			control |= SL11H_HCTLMASK_AFTERSOF;
+	}
+
+
+	switch (ep->nextpid) {
+	case USB_PID_IN:
+		in_packet(sl811, ep, urb, bank, control);
+		break;
+	case USB_PID_OUT:
+		out_packet(sl811, ep, urb, bank, control);
+		break;
+	case USB_PID_SETUP:
+		setup_packet(sl811, ep, urb, bank, control);
+		break;
+	case USB_PID_ACK:		/* for control status */
+		status_packet(sl811, ep, urb, bank, control);
+		break;
+	default:
+		DBG("bad ep%p pid %02x\n", ep, ep->nextpid);
+		ep = NULL;
+	}
+	return ep;
+}
+
+#define MIN_JIFFIES	((msecs_to_jiffies(2) > 1) ? msecs_to_jiffies(2) : 2)
+
+static inline void start_transfer(struct sl811 *sl811)
+{
+	if (sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND))
+		return;
+	if (sl811->active_a == NULL) {
+		sl811->active_a = start(sl811, SL811_EP_A(SL811_HOST_BUF));
+		if (sl811->active_a != NULL)
+			sl811->jiffies_a = jiffies + MIN_JIFFIES;
+	}
+#ifdef USE_B
+	if (sl811->active_b == NULL) {
+		sl811->active_b = start(sl811, SL811_EP_B(SL811_HOST_BUF));
+		if (sl811->active_b != NULL)
+			sl811->jiffies_b = jiffies + MIN_JIFFIES;
+	}
+#endif
+}
+
+static void finish_request(
+	struct sl811		*sl811,
+	struct sl811h_ep	*ep,
+	struct sl811h_req	*req,
+	struct pt_regs		*regs,
+	int			status
+) __releases(sl811->lock) __acquires(sl811->lock)
+{
+	unsigned		i;
+	struct urb		*urb = req->urb;
+
+	list_del(&req->queue);
+	kfree(req);
+	urb->hcpriv = NULL;
+
+	if (usb_pipecontrol(urb->pipe))
+		ep->nextpid = USB_PID_SETUP;
+
+	spin_lock(&urb->lock);
+	if (urb->status == -EINPROGRESS)
+		urb->status = status;
+	spin_unlock(&urb->lock);
+
+	spin_unlock(&sl811->lock);
+	usb_hcd_giveback_urb(&sl811->hcd, urb, regs);
+	spin_lock(&sl811->lock);
+
+	/* leave active endpoints in the schedule */
+	if (!list_empty(&ep->queue))
+		return;
+
+	/* async deschedule? */
+	if (!list_empty(&ep->schedule)) {
+		list_del_init(&ep->schedule);
+		if (ep == sl811->next_async)
+			sl811->next_async = NULL;
+		return;
+	}
+
+	/* periodic deschedule */
+	DBG("deschedule qh%d/%p branch %d\n", ep->period, ep, ep->branch);
+	for (i = ep->branch; i < PERIODIC_SIZE; i += ep->period) {
+		struct sl811h_ep	*temp;
+		struct sl811h_ep	**prev = &sl811->periodic[i];
+
+		while (*prev && ((temp = *prev) != ep))
+			prev = &temp->next;
+		if (*prev)
+			*prev = ep->next;
+		sl811->load[i] -= ep->load;
+	}	
+	ep->branch = PERIODIC_SIZE;
+	sl811->periodic_count--;
+	hcd_to_bus(&sl811->hcd)->bandwidth_allocated
+		-= ep->load / ep->period;
+	if (ep == sl811->next_periodic)
+		sl811->next_periodic = ep->next;
+
+	/* we might turn SOFs back on again for the async schedule */
+	if (sl811->periodic_count == 0)
+		sofirq_off(sl811);
+}
+
+static void
+done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank, struct pt_regs *regs)
+{
+	u8			status;
+	struct sl811h_req	*req;
+	struct urb		*urb;
+	int			urbstat = -EINPROGRESS;
+
+	if (unlikely(!ep))
+		return;
+
+	status = sl811_read(sl811, bank + SL11H_PKTSTATREG);
+
+	req = container_of(ep->queue.next, struct sl811h_req, queue);
+	urb = req->urb;
+
+	/* we can safely ignore NAKs */
+	if (status & SL11H_STATMASK_NAK) {
+		// PACKET("...NAK_%02x qh%p\n", bank, ep);
+		if (!ep->period)
+			ep->nak_count++;
+		ep->error_count = 0;
+
+	/* ACK advances transfer, toggle, and maybe queue */
+	} else if (status & SL11H_STATMASK_ACK) {
+		struct usb_device	*udev = urb->dev;
+		int			len;
+		unsigned char		*buf;
+
+		/* urb->iso_frame_desc is currently ignored here... */
+
+		ep->nak_count = ep->error_count = 0;
+		switch (ep->nextpid) {
+		case USB_PID_OUT:
+			// PACKET("...ACK/out_%02x qh%p\n", bank, ep);
+			urb->actual_length += ep->length;
+			usb_dotoggle(udev, ep->epnum, 1);
+			if (urb->actual_length
+					== urb->transfer_buffer_length) {
+				if (usb_pipecontrol(urb->pipe))
+					ep->nextpid = USB_PID_ACK;
+
+				/* some bulk protocols terminate OUT transfers
+				 * by a short packet, using ZLPs not padding.
+				 */
+				else if (ep->length < ep->maxpacket
+						|| !(urb->transfer_flags
+							& URB_ZERO_PACKET))
+					urbstat = 0;
+			}
+			break;
+		case USB_PID_IN:
+			// PACKET("...ACK/in_%02x qh%p\n", bank, ep);
+			buf = urb->transfer_buffer + urb->actual_length;
+			prefetchw(buf);
+			len = ep->maxpacket - sl811_read(sl811,
+						bank + SL11H_XFERCNTREG);
+			if (len > ep->length) {
+				len = ep->length;
+				urb->status = -EOVERFLOW;
+			}
+			urb->actual_length += len;
+			sl811_read_buf(sl811, SL811HS_PACKET_BUF(bank == 0),
+					buf, len);
+			usb_dotoggle(udev, ep->epnum, 0);
+			if (urb->actual_length == urb->transfer_buffer_length)
+				urbstat = 0;
+			else if (len < ep->maxpacket) {
+				if (urb->transfer_flags & URB_SHORT_NOT_OK)
+					urbstat = -EREMOTEIO;
+				else
+					urbstat = 0;
+			}
+			if (usb_pipecontrol(urb->pipe)
+					&& (urbstat == -EREMOTEIO
+						|| urbstat == 0)) {
+
+				/* NOTE if the status stage STALLs (why?),
+				 * this reports the wrong urb status.
+				 */
+				spin_lock(&urb->lock);
+				if (urb->status == -EINPROGRESS)
+					urb->status = urbstat;
+				spin_unlock(&urb->lock);
+
+				req = NULL;
+				ep->nextpid = USB_PID_ACK;
+			}
+			break;
+		case USB_PID_SETUP:
+			// PACKET("...ACK/setup_%02x qh%p\n", bank, ep);
+			if (urb->transfer_buffer_length == urb->actual_length)
+				ep->nextpid = USB_PID_ACK;
+			else if (usb_pipeout(urb->pipe)) {
+				usb_settoggle(udev, 0, 1, 1);
+				ep->nextpid = USB_PID_OUT;
+			} else {
+				usb_settoggle(udev, 0, 0, 1);
+				ep->nextpid = USB_PID_IN;
+			}
+			break;
+		case USB_PID_ACK:
+			// PACKET("...ACK/status_%02x qh%p\n", bank, ep);
+			urbstat = 0;
+			break;
+		}
+
+	/* STALL stops all transfers */
+	} else if (status & SL11H_STATMASK_STALL) {
+		PACKET("...STALL_%02x qh%p\n", bank, ep);
+		ep->nak_count = ep->error_count = 0;
+		urbstat = -EPIPE;
+
+	/* error? retry, until "3 strikes" */
+	} else if (++ep->error_count >= 3) {
+		if (status & SL11H_STATMASK_TMOUT)
+			urbstat = -ETIMEDOUT;
+		else if (status & SL11H_STATMASK_OVF)
+			urbstat = -EOVERFLOW;
+		else
+			urbstat = -EPROTO;
+		ep->error_count = 0;
+		PACKET("...3STRIKES_%02x %02x qh%p stat %d\n",
+				bank, status, ep, urbstat);
+	}
+
+	if ((urbstat != -EINPROGRESS || urb->status != -EINPROGRESS)
+			&& req)
+		finish_request(sl811, ep, req, regs, urbstat);
+}
+
+static inline u8 checkdone(struct sl811 *sl811)
+{
+	u8	ctl;
+	u8	irqstat = 0;
+
+	if (sl811->active_a && time_before_eq(sl811->jiffies_a, jiffies)) {
+		ctl = sl811_read(sl811, SL811_EP_A(SL11H_HOSTCTLREG));
+		if (ctl & SL11H_HCTLMASK_ARM)
+			sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
+		DBG("%s DONE_A: ctrl %02x sts %02x\n",
+			(ctl & SL11H_HCTLMASK_ARM) ? "timeout" : "lost",
+			ctl,
+			sl811_read(sl811, SL811_EP_A(SL11H_PKTSTATREG)));
+		irqstat |= SL11H_INTMASK_DONE_A;
+	}
+#ifdef	USE_B
+	if (sl811->active_b && time_before_eq(sl811->jiffies_b, jiffies)) {
+		ctl = sl811_read(sl811, SL811_EP_B(SL11H_HOSTCTLREG));
+		if (ctl & SL11H_HCTLMASK_ARM)
+			sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
+		DBG("%s DONE_B: ctrl %02x sts %02x\n", ctl,
+			(ctl & SL11H_HCTLMASK_ARM) ? "timeout" : "lost",
+			ctl,
+			sl811_read(sl811, SL811_EP_B(SL11H_PKTSTATREG)));
+		irqstat |= SL11H_INTMASK_DONE_A;
+	}
+#endif
+	return irqstat;
+}
+
+static irqreturn_t sl811h_irq(int irq, void *_sl811, struct pt_regs *regs)
+{
+	struct sl811	*sl811 = _sl811;
+	u8		irqstat;
+	irqreturn_t	ret = IRQ_NONE;
+	unsigned	retries = 5;
+
+	spin_lock(&sl811->lock);
+
+retry:
+	irqstat = sl811_read(sl811, SL11H_IRQ_STATUS) & ~SL11H_INTMASK_DP;
+	if (irqstat) {
+		sl811_write(sl811, SL11H_IRQ_STATUS, irqstat);
+		irqstat &= sl811->irq_enable;
+	}
+
+#ifdef	QUIRK2
+	/* this may no longer be necessary ... */
+	if (irqstat == 0 && ret == IRQ_NONE) {
+		irqstat = checkdone(sl811);
+		if (irqstat && irq != ~0)
+			sl811->stat_lost++;
+	}
+#endif
+
+	/* USB packets, not necessarily handled in the order they're
+	 * issued ... that's fine if they're different endpoints.
+	 */
+	if (irqstat & SL11H_INTMASK_DONE_A) {
+		done(sl811, sl811->active_a, SL811_EP_A(SL811_HOST_BUF), regs);
+		sl811->active_a = NULL;
+		sl811->stat_a++;
+	}
+#ifdef USE_B
+	if (irqstat & SL11H_INTMASK_DONE_B) {
+		done(sl811, sl811->active_b, SL811_EP_B(SL811_HOST_BUF), regs);
+		sl811->active_b = NULL;
+		sl811->stat_b++;
+	}
+#endif
+	if (irqstat & SL11H_INTMASK_SOFINTR) {
+		unsigned index;
+
+		index = sl811->frame++ % (PERIODIC_SIZE - 1);
+		sl811->stat_sof++;
+
+		/* be graceful about almost-inevitable periodic schedule
+		 * overruns:  continue the previous frame's transfers iff
+		 * this one has nothing scheduled.
+		 */
+		if (sl811->next_periodic) {
+			// ERR("overrun to slot %d\n", index);
+			sl811->stat_overrun++;
+		}
+		if (sl811->periodic[index])
+			sl811->next_periodic = sl811->periodic[index];
+	}
+
+	/* khubd manages debouncing and wakeup */
+	if (irqstat & SL11H_INTMASK_INSRMV) {
+		sl811->stat_insrmv++;
+
+		/* most stats are reset for each VBUS session */
+		sl811->stat_wake = 0;
+		sl811->stat_sof = 0;
+		sl811->stat_a = 0;
+		sl811->stat_b = 0;
+		sl811->stat_lost = 0;
+
+		sl811->ctrl1 = 0;
+		sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
+
+		sl811->irq_enable = SL11H_INTMASK_INSRMV;
+		sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
+
+		/* usbcore nukes other pending transactions on disconnect */
+		if (sl811->active_a) {
+			sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
+			finish_request(sl811, sl811->active_a,
+				container_of(sl811->active_a->queue.next,
+					struct sl811h_req, queue),
+				NULL, -ESHUTDOWN);
+			sl811->active_a = NULL;
+		}
+#ifdef	USE_B
+		if (sl811->active_b) {
+			sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
+			finish_request(sl811, sl811->active_b,
+				container_of(sl811->active_b->queue.next,
+					struct sl811h_req, queue),
+				NULL, -ESHUTDOWN);
+			sl811->active_b = NULL;
+		}
+#endif
+
+		/* port status seems wierd until after reset, so
+		 * force the reset and make khubd clean up later.
+		 */
+		sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION)
+				| (1 << USB_PORT_FEAT_CONNECTION);
+
+	} else if (irqstat & SL11H_INTMASK_RD) {
+		if (sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND)) {
+			DBG("wakeup\n");
+			sl811->port1 |= 1 << USB_PORT_FEAT_C_SUSPEND;
+			sl811->stat_wake++;
+		} else
+			irqstat &= ~SL11H_INTMASK_RD;
+	}
+
+	if (irqstat) {
+		if (sl811->port1 & (1 << USB_PORT_FEAT_ENABLE))
+			start_transfer(sl811);
+		ret = IRQ_HANDLED;
+		sl811->hcd.saw_irq = 1;
+		if (retries--)
+			goto retry;
+	}
+
+	if (sl811->periodic_count == 0 && list_empty(&sl811->async)) 
+		sofirq_off(sl811);
+	sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
+
+	spin_unlock(&sl811->lock);
+
+	return ret;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* usb 1.1 says max 90% of a frame is available for periodic transfers.
+ * this driver doesn't promise that much since it's got to handle an
+ * IRQ per packet; irq handling latencies also use up that time.
+ */
+#define	MAX_PERIODIC_LOAD	500	/* out of 1000 usec */
+
+static int balance(struct sl811 *sl811, u16 period, u16 load)
+{
+	int	i, branch = -ENOSPC;
+
+	/* search for the least loaded schedule branch of that period
+	 * which has enough bandwidth left unreserved.
+	 */
+	for (i = 0; i < period ; i++) {
+		if (branch < 0 || sl811->load[branch] > sl811->load[i]) {
+			int	j;
+
+			for (j = i; j < PERIODIC_SIZE; j += period) {
+				if ((sl811->load[j] + load)
+						> MAX_PERIODIC_LOAD)
+					break;
+			}
+			if (j < PERIODIC_SIZE)
+				continue;
+			branch = i; 
+		}
+	}
+	return branch;
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int sl811h_urb_enqueue(
+	struct usb_hcd	*hcd,
+	struct urb	*urb,
+	int		mem_flags
+) {
+	struct sl811		*sl811 = hcd_to_sl811(hcd);
+	struct usb_device	*udev = urb->dev;
+	struct hcd_dev		*hdev = (struct hcd_dev *) udev->hcpriv;
+	unsigned int		pipe = urb->pipe;
+	int			is_out = !usb_pipein(pipe);
+	int			type = usb_pipetype(pipe);
+	int			epnum = usb_pipeendpoint(pipe);
+	struct sl811h_ep	*ep = NULL;
+	struct sl811h_req	*req;
+	unsigned long		flags;
+	int			i;
+	int			retval = 0;
+
+#ifdef	DISABLE_ISO
+	if (type == PIPE_ISOCHRONOUS)
+		return -ENOSPC;
+#endif
+
+	/* avoid all allocations within spinlocks: request or endpoint */
+	urb->hcpriv = req = kmalloc(sizeof *req, mem_flags);
+	if (!req)
+		return -ENOMEM;
+	req->urb = urb;
+
+	i = epnum << 1;
+	if (i && is_out)
+		i |= 1;
+	if (!hdev->ep[i])
+		ep = kcalloc(1, sizeof *ep, mem_flags);
+
+	spin_lock_irqsave(&sl811->lock, flags);
+
+	/* don't submit to a dead or disabled port */
+	if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE))
+			|| !HCD_IS_RUNNING(sl811->hcd.state)) {
+		retval = -ENODEV;
+		goto fail;
+	}
+
+	if (hdev->ep[i]) {
+		kfree(ep);
+		ep = hdev->ep[i];
+	} else if (!ep) {
+		retval = -ENOMEM;
+		goto fail;
+
+	} else {
+		INIT_LIST_HEAD(&ep->queue);
+		INIT_LIST_HEAD(&ep->schedule);
+		ep->udev = usb_get_dev(udev);
+		ep->epnum = epnum;
+		ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out);
+		ep->defctrl = SL11H_HCTLMASK_ARM | SL11H_HCTLMASK_ENABLE;
+		usb_settoggle(udev, epnum, is_out, 0);
+
+		if (type == PIPE_CONTROL)
+			ep->nextpid = USB_PID_SETUP;
+		else if (is_out)
+			ep->nextpid = USB_PID_OUT;
+		else
+			ep->nextpid = USB_PID_IN;
+
+		if (ep->maxpacket > H_MAXPACKET) {
+			/* iso packets up to 240 bytes could work... */
+			DBG("dev %d ep%d maxpacket %d\n",
+				udev->devnum, epnum, ep->maxpacket);
+			retval = -EINVAL;
+			goto fail;
+		}
+
+		if (udev->speed == USB_SPEED_LOW) {
+			/* send preamble for external hub? */
+			if (!(sl811->ctrl1 & SL11H_CTL1MASK_LSPD))
+				ep->defctrl |= SL11H_HCTLMASK_PREAMBLE;
+		}
+		switch (type) {
+		case PIPE_ISOCHRONOUS:
+		case PIPE_INTERRUPT:
+			if (urb->interval > PERIODIC_SIZE)
+				urb->interval = PERIODIC_SIZE;
+			ep->period = urb->interval;
+			ep->branch = PERIODIC_SIZE;
+			if (type == PIPE_ISOCHRONOUS)
+				ep->defctrl |= SL11H_HCTLMASK_ISOCH;
+			ep->load = usb_calc_bus_time(udev->speed, !is_out,
+				(type == PIPE_ISOCHRONOUS),
+				usb_maxpacket(udev, pipe, is_out))
+					/ 1000;
+			break;
+		}
+
+		hdev->ep[i] = ep;
+	}
+
+	/* maybe put endpoint into schedule */
+	switch (type) {
+	case PIPE_CONTROL:
+	case PIPE_BULK:
+		if (list_empty(&ep->schedule))
+			list_add_tail(&ep->schedule, &sl811->async);
+		break;
+	case PIPE_ISOCHRONOUS:
+	case PIPE_INTERRUPT:
+		urb->interval = ep->period;
+		if (ep->branch < PERIODIC_SIZE)
+			break;
+
+		retval = balance(sl811, ep->period, ep->load);
+		if (retval < 0)
+			goto fail;
+		ep->branch = retval;
+		retval = 0;
+		urb->start_frame = (sl811->frame & (PERIODIC_SIZE - 1))
+					+ ep->branch;
+
+		/* sort each schedule branch by period (slow before fast)
+		 * to share the faster parts of the tree without needing
+		 * dummy/placeholder nodes
+		 */
+		DBG("schedule qh%d/%p branch %d\n", ep->period, ep, ep->branch);
+		for (i = ep->branch; i < PERIODIC_SIZE; i += ep->period) {
+			struct sl811h_ep	**prev = &sl811->periodic[i];
+			struct sl811h_ep	*here = *prev;
+
+			while (here && ep != here) {
+				if (ep->period > here->period)
+					break;
+				prev = &here->next;
+				here = *prev;
+			}
+			if (ep != here) {
+				ep->next = here;
+				*prev = ep;
+			}
+			sl811->load[i] += ep->load;
+		}
+		sl811->periodic_count++;
+		hcd_to_bus(&sl811->hcd)->bandwidth_allocated
+				+= ep->load / ep->period;
+		sofirq_on(sl811);
+	}
+
+	/* in case of unlink-during-submit */
+	spin_lock(&urb->lock);
+	if (urb->status != -EINPROGRESS) {
+		spin_unlock(&urb->lock);
+		finish_request(sl811, ep, req, NULL, 0);
+		req = NULL;
+		retval = 0;
+		goto fail;
+	}
+	list_add_tail(&req->queue, &ep->queue);
+	spin_unlock(&urb->lock);
+
+	start_transfer(sl811);
+	sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
+fail:
+	spin_unlock_irqrestore(&sl811->lock, flags);
+	if (retval)
+		kfree(req);
+	return retval;
+}
+
+static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
+{
+	struct sl811		*sl811 = hcd_to_sl811(hcd);
+	struct usb_device	*udev = urb->dev;
+	struct hcd_dev		*hdev = (struct hcd_dev *) udev->hcpriv;
+	unsigned int		pipe = urb->pipe;
+	int			is_out = !usb_pipein(pipe);
+	unsigned long		flags;
+	unsigned		i;
+	struct sl811h_ep	*ep;
+	struct sl811h_req	*req = urb->hcpriv;
+	int			retval = 0;
+
+	i = usb_pipeendpoint(pipe) << 1;
+	if (i && is_out)
+		i |= 1;
+
+	spin_lock_irqsave(&sl811->lock, flags);
+	ep = hdev->ep[i];
+	if (ep) {
+		/* finish right away if this urb can't be active ...
+		 * note that some drivers wrongly expect delays
+		 */
+		if (ep->queue.next != &req->queue) {
+			/* not front of queue?  never active */
+
+		/* for active transfers, we expect an IRQ */
+		} else if (sl811->active_a == ep) {
+			if (time_before_eq(sl811->jiffies_a, jiffies)) {
+				/* happens a lot with lowspeed?? */
+				DBG("giveup on DONE_A: ctrl %02x sts %02x\n",
+					sl811_read(sl811,
+						SL811_EP_A(SL11H_HOSTCTLREG)),
+					sl811_read(sl811,
+						SL811_EP_A(SL11H_PKTSTATREG)));
+				sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG),
+						0);
+				sl811->active_a = NULL;
+			} else
+				req = NULL;
+#ifdef	USE_B
+		} else if (sl811->active_b == ep) {
+			if (time_before_eq(sl811->jiffies_a, jiffies)) {
+				/* happens a lot with lowspeed?? */
+				DBG("giveup on DONE_B: ctrl %02x sts %02x\n",
+					sl811_read(sl811,
+						SL811_EP_B(SL11H_HOSTCTLREG)),
+					sl811_read(sl811,
+						SL811_EP_B(SL11H_PKTSTATREG)));
+				sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG),
+						0);
+				sl811->active_b = NULL;
+			} else
+				req = NULL;
+#endif
+		} else {
+			/* front of queue for inactive endpoint */
+		}
+
+		if (req)
+			finish_request(sl811, ep, req, NULL, 0);
+		else
+			VDBG("dequeue, urb %p active %s; wait4irq\n", urb,
+				(sl811->active_a == ep) ? "A" : "B");
+	} else
+		retval = -EINVAL;
+	spin_unlock_irqrestore(&sl811->lock, flags);
+	return retval;
+}
+
+static void
+sl811h_endpoint_disable(struct usb_hcd *hcd, struct hcd_dev *hdev, int epnum)
+{
+	struct sl811		*sl811 = hcd_to_sl811(hcd);
+	struct sl811h_ep	*ep;
+	unsigned long		flags;
+	int			i;
+
+	i = (epnum & 0xf) << 1;
+	if (epnum && !(epnum & USB_DIR_IN))
+		i |= 1;
+
+	spin_lock_irqsave(&sl811->lock, flags);
+	ep = hdev->ep[i];
+	hdev->ep[i] = NULL;
+	spin_unlock_irqrestore(&sl811->lock, flags);
+
+	if (ep) {
+		/* assume we'd just wait for the irq */
+		if (!list_empty(&ep->queue))
+			msleep(3);
+		if (!list_empty(&ep->queue))
+			WARN("ep %p not empty?\n", ep);
+
+		usb_put_dev(ep->udev);
+		kfree(ep);
+	}
+	return;
+}
+
+static int
+sl811h_get_frame(struct usb_hcd *hcd)
+{
+	struct sl811 *sl811 = hcd_to_sl811(hcd);
+
+	/* wrong except while periodic transfers are scheduled;
+	 * never matches the on-the-wire frame;
+	 * subject to overruns.
+	 */
+	return sl811->frame;
+}
+
+
+/*-------------------------------------------------------------------------*/
+
+/* the virtual root hub timer IRQ checks for hub status */
+static int
+sl811h_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+	struct sl811 *sl811 = hcd_to_sl811(hcd);
+#ifdef	QUIRK3
+	unsigned long flags;
+
+	/* non-SMP HACK: use root hub timer as i/o watchdog
+	 * this seems essential when SOF IRQs aren't in use...
+	 */
+	local_irq_save(flags);
+	if (!timer_pending(&sl811->timer)) {
+		if (sl811h_irq(~0, sl811, NULL) != IRQ_NONE)
+			sl811->stat_lost++;
+	}
+	local_irq_restore(flags);
+#endif
+
+	if (!(sl811->port1 & (0xffff << 16)))
+		return 0;
+
+	/* tell khubd port 1 changed */
+	*buf = (1 << 1);
+	return 1;
+}
+
+static void
+sl811h_hub_descriptor (
+	struct sl811			*sl811,
+	struct usb_hub_descriptor	*desc
+) {
+	u16		temp = 0;
+
+	desc->bDescriptorType = 0x29;
+	desc->bHubContrCurrent = 0;
+
+	desc->bNbrPorts = 1;
+	desc->bDescLength = 9;
+
+	/* per-port power switching (gang of one!), or none */
+	desc->bPwrOn2PwrGood = 0;
+	if (sl811->board && sl811->board->port_power) {
+		desc->bPwrOn2PwrGood = sl811->board->potpg;
+		if (!desc->bPwrOn2PwrGood)
+			desc->bPwrOn2PwrGood = 10;
+		temp = 0x0001;
+	} else
+		temp = 0x0002;
+
+	/* no overcurrent errors detection/handling */
+	temp |= 0x0010;
+
+	desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp);
+
+	/* two bitmaps:  ports removable, and legacy PortPwrCtrlMask */
+	desc->bitmap[0] = 1 << 1;
+	desc->bitmap[1] = ~0;
+}
+
+static void
+sl811h_timer(unsigned long _sl811)
+{
+	struct sl811 	*sl811 = (void *) _sl811;
+	unsigned long	flags;
+	u8		irqstat;
+	u8		signaling = sl811->ctrl1 & SL11H_CTL1MASK_FORCE;
+	const u32	mask = (1 << USB_PORT_FEAT_CONNECTION)
+				| (1 << USB_PORT_FEAT_ENABLE)
+				| (1 << USB_PORT_FEAT_LOWSPEED);
+
+	spin_lock_irqsave(&sl811->lock, flags);
+
+	/* stop special signaling */
+	sl811->ctrl1 &= ~SL11H_CTL1MASK_FORCE;
+	sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
+	udelay(3);
+
+	irqstat = sl811_read(sl811, SL11H_IRQ_STATUS);
+
+	switch (signaling) {
+	case SL11H_CTL1MASK_SE0:
+		DBG("end reset\n");
+		sl811->port1 = (1 << USB_PORT_FEAT_C_RESET)
+				| (1 << USB_PORT_FEAT_POWER);
+		sl811->ctrl1 = 0;
+		/* don't wrongly ack RD */
+		if (irqstat & SL11H_INTMASK_INSRMV)
+			irqstat &= ~SL11H_INTMASK_RD;
+		break;
+	case SL11H_CTL1MASK_K:
+		DBG("end resume\n");
+		sl811->port1 &= ~(1 << USB_PORT_FEAT_SUSPEND);
+		break;
+	default:
+		DBG("odd timer signaling: %02x\n", signaling);
+		break;
+	}
+	sl811_write(sl811, SL11H_IRQ_STATUS, irqstat);
+
+	if (irqstat & SL11H_INTMASK_RD) {
+		/* usbcore nukes all pending transactions on disconnect */
+		if (sl811->port1 & (1 << USB_PORT_FEAT_CONNECTION))
+			sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION)
+					| (1 << USB_PORT_FEAT_C_ENABLE);
+		sl811->port1 &= ~mask;
+		sl811->irq_enable = SL11H_INTMASK_INSRMV;
+	} else {
+		sl811->port1 |= mask;
+		if (irqstat & SL11H_INTMASK_DP)
+			sl811->port1 &= ~(1 << USB_PORT_FEAT_LOWSPEED);
+		sl811->irq_enable = SL11H_INTMASK_INSRMV | SL11H_INTMASK_RD;
+	}
+
+	if (sl811->port1 & (1 << USB_PORT_FEAT_CONNECTION)) {
+		u8	ctrl2 = SL811HS_CTL2_INIT;
+
+		sl811->irq_enable |= SL11H_INTMASK_DONE_A;
+#ifdef USE_B
+		sl811->irq_enable |= SL11H_INTMASK_DONE_B;
+#endif
+		if (sl811->port1 & (1 << USB_PORT_FEAT_LOWSPEED)) {
+			sl811->ctrl1 |= SL11H_CTL1MASK_LSPD;
+			ctrl2 |= SL811HS_CTL2MASK_DSWAP;
+		}
+
+		/* start SOFs flowing, kickstarting with A registers */
+		sl811->ctrl1 |= SL11H_CTL1MASK_SOF_ENA;
+		sl811_write(sl811, SL11H_SOFLOWREG, 0xe0);
+		sl811_write(sl811, SL811HS_CTLREG2, ctrl2);
+
+		/* autoincrementing */
+		sl811_write(sl811, SL811_EP_A(SL11H_BUFLNTHREG), 0);
+		writeb(SL_SOF, sl811->data_reg);
+		writeb(0, sl811->data_reg);
+		sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG),
+				SL11H_HCTLMASK_ARM);
+
+		/* khubd provides debounce delay */
+	} else {
+		sl811->ctrl1 = 0;
+	}
+	sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
+
+	/* reenable irqs */
+	sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
+	spin_unlock_irqrestore(&sl811->lock, flags);
+}
+
+static int
+sl811h_hub_control(
+	struct usb_hcd	*hcd,
+	u16		typeReq,
+	u16		wValue,
+	u16		wIndex,
+	char		*buf,
+	u16		wLength
+) {
+	struct sl811	*sl811 = hcd_to_sl811(hcd);
+	int		retval = 0;
+	unsigned long	flags;
+
+	spin_lock_irqsave(&sl811->lock, flags);
+
+	switch (typeReq) {
+	case ClearHubFeature:
+	case SetHubFeature:
+		switch (wValue) {
+		case C_HUB_OVER_CURRENT:
+		case C_HUB_LOCAL_POWER:
+			break;
+		default:
+			goto error;
+		}
+		break;
+	case ClearPortFeature:
+		if (wIndex != 1 || wLength != 0)
+			goto error;
+
+		switch (wValue) {
+		case USB_PORT_FEAT_ENABLE:
+			sl811->port1 &= (1 << USB_PORT_FEAT_POWER);
+			sl811->ctrl1 = 0;
+			sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
+			sl811->irq_enable = SL11H_INTMASK_INSRMV;
+			sl811_write(sl811, SL11H_IRQ_ENABLE,
+						sl811->irq_enable);
+			break;
+		case USB_PORT_FEAT_SUSPEND:
+			if (!(sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND)))
+				break;
+
+			/* 20 msec of resume/K signaling, other irqs blocked */
+			DBG("start resume...\n");
+			sl811->irq_enable = 0;
+			sl811_write(sl811, SL11H_IRQ_ENABLE,
+						sl811->irq_enable);
+			sl811->ctrl1 |= SL11H_CTL1MASK_K;
+			sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
+
+			mod_timer(&sl811->timer, jiffies
+					+ msecs_to_jiffies(20));
+			break;
+		case USB_PORT_FEAT_POWER:
+			port_power(sl811, 0);
+			break;
+		case USB_PORT_FEAT_C_ENABLE:
+		case USB_PORT_FEAT_C_SUSPEND:
+		case USB_PORT_FEAT_C_CONNECTION:
+		case USB_PORT_FEAT_C_OVER_CURRENT:
+		case USB_PORT_FEAT_C_RESET:
+			break;
+		default:
+			goto error;
+		}
+		sl811->port1 &= ~(1 << wValue);
+		break;
+	case GetHubDescriptor:
+		sl811h_hub_descriptor(sl811, (struct usb_hub_descriptor *) buf);
+		break;
+	case GetHubStatus:
+		*(__le32 *) buf = cpu_to_le32(0);
+		break;
+	case GetPortStatus:
+		if (wIndex != 1)
+			goto error;
+		*(__le32 *) buf = cpu_to_le32(sl811->port1);
+
+#ifndef	VERBOSE
+	if (*(u16*)(buf+2))	/* only if wPortChange is interesting */
+#endif
+		DBG("GetPortStatus %08x\n", sl811->port1);
+		break;
+	case SetPortFeature:
+		if (wIndex != 1 || wLength != 0)
+			goto error;
+		switch (wValue) {
+		case USB_PORT_FEAT_SUSPEND:
+			if (sl811->port1 & (1 << USB_PORT_FEAT_RESET))
+				goto error;
+			if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE)))
+				goto error;
+
+			DBG("suspend...\n");
+			sl811->ctrl1 &= ~SL11H_CTL1MASK_SOF_ENA;
+			sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
+			break;
+		case USB_PORT_FEAT_POWER:
+			port_power(sl811, 1);
+			break;
+		case USB_PORT_FEAT_RESET:
+			if (sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND))
+				goto error;
+			if (!(sl811->port1 & (1 << USB_PORT_FEAT_POWER)))
+				break;
+
+			/* 50 msec of reset/SE0 signaling, irqs blocked */
+			sl811->irq_enable = 0;
+			sl811_write(sl811, SL11H_IRQ_ENABLE,
+						sl811->irq_enable);
+			sl811->ctrl1 = SL11H_CTL1MASK_SE0;
+			sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
+			sl811->port1 |= (1 << USB_PORT_FEAT_RESET);
+			mod_timer(&sl811->timer, jiffies
+					+ msecs_to_jiffies(50));
+			break;
+		default:
+			goto error;
+		}
+		sl811->port1 |= 1 << wValue;
+		break;
+
+	default:
+error:
+		/* "protocol stall" on error */
+		retval = -EPIPE;
+	}
+
+	spin_unlock_irqrestore(&sl811->lock, flags);
+	return retval;
+}
+
+#ifdef	CONFIG_PM
+
+static int
+sl811h_hub_suspend(struct usb_hcd *hcd)
+{
+	// SOFs off
+	DBG("%s\n", __FUNCTION__);
+	return 0;
+}
+
+static int
+sl811h_hub_resume(struct usb_hcd *hcd)
+{
+	// SOFs on
+	DBG("%s\n", __FUNCTION__);
+	return 0;
+}
+
+#else
+
+#define	sl811h_hub_suspend	NULL
+#define	sl811h_hub_resume	NULL
+
+#endif
+
+
+/*-------------------------------------------------------------------------*/
+
+#ifdef STUB_DEBUG_FILE
+
+static inline void create_debug_file(struct sl811 *sl811) { }
+static inline void remove_debug_file(struct sl811 *sl811) { }
+
+#else
+
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+static void dump_irq(struct seq_file *s, char *label, u8 mask)
+{
+	seq_printf(s, "%s %02x%s%s%s%s%s%s\n", label, mask,
+		(mask & SL11H_INTMASK_DONE_A) ? " done_a" : "",
+		(mask & SL11H_INTMASK_DONE_B) ? " done_b" : "",
+		(mask & SL11H_INTMASK_SOFINTR) ? " sof" : "",
+		(mask & SL11H_INTMASK_INSRMV) ? " ins/rmv" : "",
+		(mask & SL11H_INTMASK_RD) ? " rd" : "",
+		(mask & SL11H_INTMASK_DP) ? " dp" : "");
+}
+
+static int proc_sl811h_show(struct seq_file *s, void *unused)
+{
+	struct sl811		*sl811 = s->private;
+	struct sl811h_ep	*ep;
+	unsigned		i;
+
+	seq_printf(s, "%s\n%s version %s\nportstatus[1] = %08x\n",
+		sl811->hcd.product_desc,
+		hcd_name, DRIVER_VERSION,
+		sl811->port1);
+
+	seq_printf(s, "insert/remove: %ld\n", sl811->stat_insrmv);
+	seq_printf(s, "current session:  done_a %ld done_b %ld "
+			"wake %ld sof %ld overrun %ld lost %ld\n\n",
+		sl811->stat_a, sl811->stat_b,
+		sl811->stat_wake, sl811->stat_sof,
+		sl811->stat_overrun, sl811->stat_lost);
+
+	spin_lock_irq(&sl811->lock);
+
+	if (sl811->ctrl1 & SL11H_CTL1MASK_SUSPEND)
+		seq_printf(s, "(suspended)\n\n");
+	else {
+		u8	t = sl811_read(sl811, SL11H_CTLREG1);
+
+		seq_printf(s, "ctrl1 %02x%s%s%s%s\n", t,
+			(t & SL11H_CTL1MASK_SOF_ENA) ? " sofgen" : "",
+			({char *s; switch (t & SL11H_CTL1MASK_FORCE) {
+			case SL11H_CTL1MASK_NORMAL: s = ""; break;
+			case SL11H_CTL1MASK_SE0: s = " se0/reset"; break;
+			case SL11H_CTL1MASK_K: s = " k/resume"; break;
+			default: s = "j"; break;
+			}; s; }),
+			(t & SL11H_CTL1MASK_LSPD) ? " lowspeed" : "",
+			(t & SL11H_CTL1MASK_SUSPEND) ? " suspend" : "");
+
+		dump_irq(s, "irq_enable",
+				sl811_read(sl811, SL11H_IRQ_ENABLE));
+		dump_irq(s, "irq_status",
+				sl811_read(sl811, SL11H_IRQ_STATUS));
+		seq_printf(s, "frame clocks remaining:  %d\n",
+				sl811_read(sl811, SL11H_SOFTMRREG) << 6);
+	}
+
+	seq_printf(s, "A: qh%p ctl %02x sts %02x\n", sl811->active_a,
+		sl811_read(sl811, SL811_EP_A(SL11H_HOSTCTLREG)),
+		sl811_read(sl811, SL811_EP_A(SL11H_PKTSTATREG)));
+	seq_printf(s, "B: qh%p ctl %02x sts %02x\n", sl811->active_b,
+		sl811_read(sl811, SL811_EP_B(SL11H_HOSTCTLREG)),
+		sl811_read(sl811, SL811_EP_B(SL11H_PKTSTATREG)));
+	seq_printf(s, "\n");
+	list_for_each_entry (ep, &sl811->async, schedule) {
+		struct sl811h_req	*req;
+
+		seq_printf(s, "%s%sqh%p, ep%d%s, maxpacket %d"
+					" nak %d err %d\n",
+			(ep == sl811->active_a) ? "(A) " : "",
+			(ep == sl811->active_b) ? "(B) " : "",
+			ep, ep->epnum,
+			({ char *s; switch (ep->nextpid) {
+			case USB_PID_IN: s = "in"; break;
+			case USB_PID_OUT: s = "out"; break;
+			case USB_PID_SETUP: s = "setup"; break;
+			case USB_PID_ACK: s = "status"; break;
+			default: s = "?"; break;
+			}; s;}),
+			ep->maxpacket,
+			ep->nak_count, ep->error_count);
+		list_for_each_entry (req, &ep->queue, queue) {
+			seq_printf(s, "  urb%p, %d/%d\n", req->urb,
+				req->urb->actual_length,
+				req->urb->transfer_buffer_length);
+		}
+	}
+	if (!list_empty(&sl811->async))
+		seq_printf(s, "\n");
+
+	seq_printf(s, "periodic size= %d\n", PERIODIC_SIZE);
+
+	for (i = 0; i < PERIODIC_SIZE; i++) {
+		ep = sl811->periodic[i];
+		if (!ep)
+			continue;
+		seq_printf(s, "%2d [%3d]:\n", i, sl811->load[i]);
+
+		/* DUMB: prints shared entries multiple times */
+		do {
+			seq_printf(s,
+				"   %s%sqh%d/%p (%sdev%d ep%d%s max %d) "
+					"err %d\n",
+				(ep == sl811->active_a) ? "(A) " : "",
+				(ep == sl811->active_b) ? "(B) " : "",
+				ep->period, ep,
+				(ep->udev->speed == USB_SPEED_FULL)
+					? "" : "ls ",
+				ep->udev->devnum, ep->epnum,
+				(ep->epnum == 0) ? ""
+					: ((ep->nextpid == USB_PID_IN)
+						? "in"
+						: "out"),
+				ep->maxpacket, ep->error_count);
+			ep = ep->next;
+		} while (ep);
+	}
+
+	spin_unlock_irq(&sl811->lock);
+	seq_printf(s, "\n");
+
+	return 0;
+}
+
+static int proc_sl811h_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, proc_sl811h_show, PDE(inode)->data);
+}
+
+static struct file_operations proc_ops = {
+	.open		= proc_sl811h_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+/* expect just one sl811 per system */
+static const char proc_filename[] = "driver/sl811h";
+
+static void create_debug_file(struct sl811 *sl811)
+{
+	struct proc_dir_entry *pde;
+
+	pde = create_proc_entry(proc_filename, 0, NULL);
+	if (pde == NULL)
+		return;
+
+	pde->proc_fops = &proc_ops;
+	pde->data = sl811;
+	sl811->pde = pde;
+}
+
+static void remove_debug_file(struct sl811 *sl811)
+{
+	if (sl811->pde)
+		remove_proc_entry(proc_filename, NULL);
+}
+
+#endif
+
+/*-------------------------------------------------------------------------*/
+
+static void
+sl811h_stop(struct usb_hcd *hcd)
+{
+	struct sl811	*sl811 = hcd_to_sl811(hcd);
+	unsigned long	flags;
+
+	del_timer_sync(&sl811->hcd.rh_timer);
+
+	spin_lock_irqsave(&sl811->lock, flags);
+	port_power(sl811, 0);
+	spin_unlock_irqrestore(&sl811->lock, flags);
+}
+
+static int
+sl811h_start(struct usb_hcd *hcd)
+{
+	struct sl811		*sl811 = hcd_to_sl811(hcd);
+	struct usb_device	*udev;
+
+	/* chip has been reset, VBUS power is off */
+
+	udev = usb_alloc_dev(NULL, &sl811->hcd.self, 0);
+	if (!udev)
+		return -ENOMEM;
+
+	udev->speed = USB_SPEED_FULL;
+	hcd->state = USB_STATE_RUNNING;
+
+	if (sl811->board)
+		sl811->hcd.can_wakeup = sl811->board->can_wakeup;
+
+	if (hcd_register_root(udev, &sl811->hcd) != 0) {
+		usb_put_dev(udev);
+		sl811h_stop(hcd);
+		return -ENODEV;
+	}
+
+	if (sl811->board && sl811->board->power)
+		hub_set_power_budget(udev, sl811->board->power * 2);
+
+	return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+static struct hc_driver sl811h_hc_driver = {
+	.description =		hcd_name,
+
+	/*
+	 * generic hardware linkage
+	 */
+	.flags =		HCD_USB11,
+
+	/*
+	 * managing i/o requests and associated device resources
+	 */
+	.urb_enqueue =		sl811h_urb_enqueue,
+	.urb_dequeue =		sl811h_urb_dequeue,
+	.endpoint_disable =	sl811h_endpoint_disable,
+
+	/*
+	 * periodic schedule support
+	 */
+	.get_frame_number =	sl811h_get_frame,
+
+	/*
+	 * root hub support
+	 */
+	.hub_status_data =	sl811h_hub_status_data,
+	.hub_control =		sl811h_hub_control,
+	.hub_suspend =		sl811h_hub_suspend,
+	.hub_resume =		sl811h_hub_resume,
+};
+
+/*-------------------------------------------------------------------------*/
+
+static int __init_or_module
+sl811h_remove(struct device *dev)
+{
+	struct sl811		*sl811 = dev_get_drvdata(dev);
+	struct platform_device	*pdev;
+	struct resource		*res;
+
+	pdev = container_of(dev, struct platform_device, dev);
+
+	if (HCD_IS_RUNNING(sl811->hcd.state))
+		sl811->hcd.state = USB_STATE_QUIESCING;
+
+	usb_disconnect(&sl811->hcd.self.root_hub);
+	remove_debug_file(sl811);
+	sl811h_stop(&sl811->hcd);
+
+	if (!list_empty(&sl811->hcd.self.bus_list))
+		usb_deregister_bus(&sl811->hcd.self);
+
+	if (sl811->hcd.irq >= 0)
+		free_irq(sl811->hcd.irq, sl811);
+
+	if (sl811->data_reg)
+		iounmap(sl811->data_reg);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	release_mem_region(res->start, 1);
+
+	if (sl811->addr_reg) 
+		iounmap(sl811->addr_reg);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	release_mem_region(res->start, 1);
+
+	kfree(sl811);
+	return 0;
+}
+
+#define resource_len(r) (((r)->end - (r)->start) + 1)
+
+static int __init
+sl811h_probe(struct device *dev)
+{
+	struct sl811		*sl811;
+	struct platform_device	*pdev;
+	struct resource		*addr, *data;
+	int			irq;
+	int			status;
+	u8			tmp;
+	unsigned long		flags;
+
+	/* basic sanity checks first.  board-specific init logic should
+	 * have initialized these three resources and probably board
+	 * specific platform_data.  we don't probe for IRQs, and do only
+	 * minimal sanity checking.
+	 */
+	pdev = container_of(dev, struct platform_device, dev);
+	if (pdev->num_resources < 3)
+		return -ENODEV;
+
+	addr = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	data = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	irq = platform_get_irq(pdev, 0);
+	if (!addr || !data || irq < 0)
+		return -ENODEV;
+
+	/* refuse to confuse usbcore */
+	if (dev->dma_mask) {
+		DBG("no we won't dma\n");
+		return -EINVAL;
+	}
+
+	if (!request_mem_region(addr->start, 1, hcd_name))
+		return -EBUSY;
+	if (!request_mem_region(data->start, 1, hcd_name)) {
+		release_mem_region(addr->start, 1);
+		return -EBUSY;
+	}
+
+	/* allocate and initialize hcd */
+	sl811 = kcalloc(1, sizeof *sl811, GFP_KERNEL);
+	if (!sl811)
+		return 0;
+	dev_set_drvdata(dev, sl811);
+
+	usb_bus_init(&sl811->hcd.self);
+	sl811->hcd.self.controller = dev;
+	sl811->hcd.self.bus_name = dev->bus_id;
+	sl811->hcd.self.op = &usb_hcd_operations;
+	sl811->hcd.self.hcpriv = sl811;
+
+	// NOTE: 2.6.11 starts to change the hcd glue layer some more,
+	// eventually letting us eliminate struct sl811h_req and a
+	// lot of the boilerplate code here 
+
+	INIT_LIST_HEAD(&sl811->hcd.dev_list);
+	sl811->hcd.self.release = &usb_hcd_release;
+
+	sl811->hcd.description = sl811h_hc_driver.description;
+	init_timer(&sl811->hcd.rh_timer);
+	sl811->hcd.driver = &sl811h_hc_driver;
+	sl811->hcd.irq = -1;
+	sl811->hcd.state = USB_STATE_HALT;
+
+	spin_lock_init(&sl811->lock);
+	INIT_LIST_HEAD(&sl811->async);
+	sl811->board = dev->platform_data;
+	init_timer(&sl811->timer);
+	sl811->timer.function = sl811h_timer;
+	sl811->timer.data = (unsigned long) sl811;
+
+	sl811->addr_reg = ioremap(addr->start, resource_len(addr));
+	if (sl811->addr_reg == NULL) {
+		status = -ENOMEM;
+		goto fail;
+	}
+	sl811->data_reg = ioremap(data->start, resource_len(addr));
+	if (sl811->data_reg == NULL) {
+		status = -ENOMEM;
+		goto fail;
+	}
+
+	spin_lock_irqsave(&sl811->lock, flags);
+	port_power(sl811, 0);
+	spin_unlock_irqrestore(&sl811->lock, flags);
+	msleep(200);
+
+	tmp = sl811_read(sl811, SL11H_HWREVREG);
+	switch (tmp >> 4) {
+	case 1:
+		sl811->hcd.product_desc = "SL811HS v1.2";
+		break;
+	case 2:
+		sl811->hcd.product_desc = "SL811HS v1.5";
+		break;
+	default:
+		/* reject case 0, SL11S is less functional */
+		DBG("chiprev %02x\n", tmp);
+		status = -ENXIO;
+		goto fail;
+	}
+
+	/* sl811s would need a different handler for this irq */
+#ifdef	CONFIG_ARM
+	/* Cypress docs say the IRQ is IRQT_HIGH ... */
+	set_irq_type(irq, IRQT_RISING);
+#endif
+	status = request_irq(irq, sl811h_irq, SA_INTERRUPT, hcd_name, sl811);
+	if (status < 0)
+		goto fail;
+	sl811->hcd.irq = irq;
+
+	INFO("%s, irq %d\n", sl811->hcd.product_desc, irq);
+
+	status = usb_register_bus(&sl811->hcd.self);
+	if (status < 0)
+		goto fail;
+	status = sl811h_start(&sl811->hcd);
+	if (status == 0) {
+		create_debug_file(sl811);
+		return 0;
+	}
+fail:
+	sl811h_remove(dev);
+	DBG("init error, %d\n", status);
+	return status;
+}
+
+#ifdef	CONFIG_PM
+
+/* for this device there's no useful distinction between the controller
+ * and its root hub, except that the root hub only gets direct PM calls 
+ * when CONFIG_USB_SUSPEND is enabled.
+ */
+
+static int
+sl811h_suspend(struct device *dev, u32 state, u32 phase)
+{
+	struct sl811	*sl811 = dev_get_drvdata(dev);
+	int		retval = 0;
+
+	if (phase != SUSPEND_POWER_DOWN)
+		return retval;
+
+	if (state <= PM_SUSPEND_MEM)
+		retval = sl811h_hub_suspend(&sl811->hcd);
+	else
+		port_power(sl811, 0);
+	if (retval == 0)
+		dev->power.power_state = state;
+	return retval;
+}
+
+static int
+sl811h_resume(struct device *dev, u32 phase)
+{
+	struct sl811	*sl811 = dev_get_drvdata(dev);
+
+	if (phase != RESUME_POWER_ON)
+		return 0;
+
+	/* with no "check to see if VBUS is still powered" board hook,
+	 * let's assume it'd only be powered to enable remote wakeup.
+	 */
+	if (dev->power.power_state > PM_SUSPEND_MEM
+			|| !sl811->hcd.can_wakeup) {
+		sl811->port1 = 0;
+		port_power(sl811, 1);
+		return 0;
+	}
+
+	dev->power.power_state = PM_SUSPEND_ON;
+	return sl811h_hub_resume(&sl811->hcd);
+}
+
+#else
+
+#define	sl811h_suspend	NULL
+#define	sl811h_resume	NULL
+
+#endif
+
+
+static struct device_driver sl811h_driver = {
+	.name =		(char *) hcd_name,
+	.bus =		&platform_bus_type,
+
+	.probe =	sl811h_probe,
+	.remove =	sl811h_remove,
+
+	.suspend =	sl811h_suspend,
+	.resume =	sl811h_resume,
+};
+
+/*-------------------------------------------------------------------------*/
+ 
+static int __init sl811h_init(void) 
+{
+	if (usb_disabled())
+		return -ENODEV;
+
+	INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION);
+	return driver_register(&sl811h_driver);
+}
+module_init(sl811h_init);
+
+static void __exit sl811h_cleanup(void) 
+{	
+	driver_unregister(&sl811h_driver);
+}
+module_exit(sl811h_cleanup);
diff -Nru a/drivers/usb/host/sl811.h b/drivers/usb/host/sl811.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/host/sl811.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,270 @@
+/*
+ * SL811HS register declarations and HCD data structures
+ *
+ * Copyright (C) 2004 Psion Teklogix
+ * Copyright (C) 2004 David Brownell
+ * Copyright (C) 2001 Cypress Semiconductor Inc. 
+ */
+
+/*
+ * SL811HS has transfer registers, and control registers.  In host/master
+ * mode one set of registers is used; in peripheral/slave mode, another.
+ *  - SL11H only has some "A" transfer registers from 0x00-0x04
+ *  - SL811HS also has "B" registers from 0x08-0x0c
+ *  - SL811S (or HS in slave mode) has four A+B sets, at 00, 10, 20, 30
+ */
+
+#define SL811_EP_A(base)	((base) + 0)
+#define SL811_EP_B(base)	((base) + 8)
+
+#define SL811_HOST_BUF		0x00
+#define SL811_PERIPH_EP0	0x00
+#define SL811_PERIPH_EP1	0x10
+#define SL811_PERIPH_EP2	0x20
+#define SL811_PERIPH_EP3	0x30
+
+
+/* TRANSFER REGISTERS:  host and peripheral sides are similar
+ * except for the control models (master vs slave).
+ */
+#define SL11H_HOSTCTLREG	0
+#	define SL11H_HCTLMASK_ARM	0x01
+#	define SL11H_HCTLMASK_ENABLE	0x02
+#	define SL11H_HCTLMASK_IN	0x00
+#	define SL11H_HCTLMASK_OUT	0x04
+#	define SL11H_HCTLMASK_ISOCH	0x10
+#	define SL11H_HCTLMASK_AFTERSOF	0x20
+#	define SL11H_HCTLMASK_TOGGLE	0x40
+#	define SL11H_HCTLMASK_PREAMBLE	0x80
+#define SL11H_BUFADDRREG	1
+#define SL11H_BUFLNTHREG	2
+#define SL11H_PKTSTATREG	3	/* read */
+#	define SL11H_STATMASK_ACK	0x01
+#	define SL11H_STATMASK_ERROR	0x02
+#	define SL11H_STATMASK_TMOUT	0x04
+#	define SL11H_STATMASK_SEQ	0x08
+#	define SL11H_STATMASK_SETUP	0x10
+#	define SL11H_STATMASK_OVF	0x20
+#	define SL11H_STATMASK_NAK	0x40
+#	define SL11H_STATMASK_STALL	0x80
+#define SL11H_PIDEPREG		3	/* write */
+#	define	SL_SETUP	0xd0
+#	define	SL_IN		0x90
+#	define	SL_OUT		0x10
+#	define	SL_SOF		0x50
+#	define	SL_PREAMBLE	0xc0
+#	define	SL_NAK		0xa0
+#	define	SL_STALL	0xe0
+#	define	SL_DATA0	0x30
+#	define	SL_DATA1	0xb0
+#define SL11H_XFERCNTREG	4	/* read */
+#define SL11H_DEVADDRREG	4	/* write */
+
+
+/* CONTROL REGISTERS:  host and peripheral are very different.
+ */
+#define SL11H_CTLREG1		5
+#	define SL11H_CTL1MASK_SOF_ENA	0x01
+#	define SL11H_CTL1MASK_FORCE	0x18
+#		define SL11H_CTL1MASK_NORMAL	0x00
+#		define SL11H_CTL1MASK_SE0	0x08	/* reset */
+#		define SL11H_CTL1MASK_J		0x10
+#		define SL11H_CTL1MASK_K		0x18	/* resume */
+#	define SL11H_CTL1MASK_LSPD	0x20
+#	define SL11H_CTL1MASK_SUSPEND	0x40
+#define SL11H_IRQ_ENABLE	6
+#	define SL11H_INTMASK_DONE_A	0x01
+#	define SL11H_INTMASK_DONE_B	0x02
+#	define SL11H_INTMASK_SOFINTR	0x10
+#	define SL11H_INTMASK_INSRMV	0x20	/* to/from SE0 */
+#	define SL11H_INTMASK_RD		0x40
+#	define SL11H_INTMASK_DP		0x80	/* only in INTSTATREG */
+#define SL11S_ADDRESS		7
+
+/* 0x08-0x0c are for the B buffer (not in SL11) */
+
+#define SL11H_IRQ_STATUS	0x0D	/* write to ack */
+#define SL11H_HWREVREG		0x0E	/* read */
+#	define SL11H_HWRMASK_HWREV	0xF0
+#define SL11H_SOFLOWREG		0x0E	/* write */
+#define SL11H_SOFTMRREG		0x0F	/* read */
+
+/* a write to this register enables SL811HS features.
+ * HOST flag presumably overrides the chip input signal?
+ */
+#define SL811HS_CTLREG2		0x0F
+#	define SL811HS_CTL2MASK_SOF_MASK	0x3F
+#	define SL811HS_CTL2MASK_DSWAP		0x40
+#	define SL811HS_CTL2MASK_HOST		0x80
+
+#define SL811HS_CTL2_INIT	(SL811HS_CTL2MASK_HOST | 0x2e)
+
+
+/* DATA BUFFERS: registers from 0x10..0xff are for data buffers;
+ * that's 240 bytes, which we'll split evenly between A and B sides.
+ * Only ISO can use more than 64 bytes per packet.
+ * (The SL11S has 0x40..0xff for buffers.)
+ */
+#define H_MAXPACKET	120		/* bytes in A or B fifos */
+
+#define SL11H_DATA_START	0x10
+#define	SL811HS_PACKET_BUF(is_a)	((is_a) \
+		? SL11H_DATA_START \
+		: (SL11H_DATA_START + H_MAXPACKET))
+
+/*-------------------------------------------------------------------------*/
+
+#define	LOG2_PERIODIC_SIZE	5	/* arbitrary; this matches OHCI */
+#define	PERIODIC_SIZE		(1 << LOG2_PERIODIC_SIZE)
+
+struct sl811 {
+	struct usb_hcd		hcd;
+	spinlock_t		lock;
+	void __iomem		*addr_reg;
+	void __iomem		*data_reg;
+	struct sl811_platform_data	*board;
+	struct proc_dir_entry	*pde;
+
+	unsigned long		stat_insrmv;
+	unsigned long		stat_wake;
+	unsigned long		stat_sof;
+	unsigned long		stat_a;
+	unsigned long		stat_b;
+	unsigned long		stat_lost;
+	unsigned long		stat_overrun;
+
+	/* sw model */
+	struct timer_list	timer;
+	struct sl811h_ep	*next_periodic;
+	struct sl811h_ep	*next_async;
+
+	struct sl811h_ep	*active_a;
+	unsigned long		jiffies_a;
+	struct sl811h_ep	*active_b;
+	unsigned long		jiffies_b;
+
+	u32			port1;
+	u8			ctrl1, ctrl2, irq_enable;
+	u16			frame;
+
+	/* async schedule: control, bulk */
+	struct list_head	async;
+
+	/* periodic schedule: interrupt, iso */
+	u16			load[PERIODIC_SIZE];
+	struct sl811h_ep	*periodic[PERIODIC_SIZE];
+	unsigned		periodic_count;
+};
+
+static inline struct sl811 *hcd_to_sl811(struct usb_hcd *hcd)
+{
+	return container_of(hcd, struct sl811, hcd);
+}
+
+struct sl811h_ep {
+	struct list_head	queue;
+	struct usb_device	*udev;
+
+	u8			defctrl;
+	u8			maxpacket;
+	u8			epnum;
+	u8			nextpid;
+
+	u16			error_count;
+	u16			nak_count;
+	u16			length;		/* of current packet */
+
+	/* periodic schedule */
+	u16			period;
+	u16			branch;
+	u16			load;
+	struct sl811h_ep	*next;
+
+	/* async schedule */
+	struct list_head	schedule;
+};
+
+struct sl811h_req {
+	/* FIXME usbcore should maintain endpoints' urb queues
+	 * directly in 'struct usb_host_endpoint'
+	 */
+	struct urb		*urb;
+	struct list_head	queue;
+};
+
+/*-------------------------------------------------------------------------*/
+
+/* These register utilities should work for the SL811S register API too
+ * NOTE:  caller must hold sl811->lock.
+ */
+
+static inline u8 sl811_read(struct sl811 *sl811, int reg)
+{
+	writeb(reg, sl811->addr_reg);
+	return readb(sl811->data_reg);
+}
+
+static inline void sl811_write(struct sl811 *sl811, int reg, u8 val)
+{
+	writeb(reg, sl811->addr_reg);
+	writeb(val, sl811->data_reg);
+}
+
+static inline void
+sl811_write_buf(struct sl811 *sl811, int addr, const void *buf, size_t count)
+{
+	const u8	*data;
+	void __iomem	*data_reg;
+
+	if (!count)
+		return;
+	writeb(addr, sl811->addr_reg);
+
+	data = buf;
+	data_reg = sl811->data_reg;
+	do {
+		writeb(*data++, data_reg);
+	} while (--count);
+}
+
+static inline void
+sl811_read_buf(struct sl811 *sl811, int addr, void *buf, size_t count)
+{
+	u8 		*data;
+	void __iomem	*data_reg;
+
+	if (!count)
+		return;
+	writeb(addr, sl811->addr_reg);
+
+	data = buf;
+	data_reg = sl811->data_reg;
+	do {
+		*data++ = readb(data_reg);
+	} while (--count);
+}
+
+/*-------------------------------------------------------------------------*/
+
+#ifdef DEBUG
+#define DBG(stuff...)		printk(KERN_DEBUG "sl811: " stuff)
+#else
+#define DBG(stuff...)		do{}while(0)
+#endif
+
+#ifdef VERBOSE
+#    define VDBG		DBG
+#else
+#    define VDBG(stuff...)	do{}while(0)
+#endif
+
+#ifdef PACKET_TRACE
+#    define PACKET		VDBG
+#else
+#    define PACKET(stuff...)	do{}while(0)
+#endif
+
+#define ERR(stuff...)		printk(KERN_ERR "sl811: " stuff)
+#define WARN(stuff...)		printk(KERN_WARNING "sl811: " stuff)
+#define INFO(stuff...)		printk(KERN_INFO "sl811: " stuff)
+
diff -Nru a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
--- a/drivers/usb/host/uhci-debug.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/host/uhci-debug.c	2004-12-24 13:36:18 -08:00
@@ -34,17 +34,6 @@
 	}
 }
 
-static inline int uhci_is_skeleton_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
-{
-	int i;
-
-	for (i = 0; i < UHCI_NUM_SKELQH; i++)
-		if (qh == uhci->skelqh[i])
-			return 1;
-
-	return 0;
-}
-
 static int uhci_show_td(struct uhci_td *td, char *buf, int len, int space)
 {
 	char *out = buf;
diff -Nru a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
--- a/drivers/usb/host/uhci-hcd.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/host/uhci-hcd.c	2004-12-24 13:37:19 -08:00
@@ -51,8 +51,8 @@
 #include <linux/dmapool.h>
 #include <linux/dma-mapping.h>
 #include <linux/usb.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -92,7 +92,7 @@
 
 static kmem_cache_t *uhci_up_cachep;	/* urb_priv */
 
-static int uhci_get_current_frame_number(struct uhci_hcd *uhci);
+static unsigned int uhci_get_current_frame_number(struct uhci_hcd *uhci);
 static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb);
 static void uhci_unlink_generic(struct uhci_hcd *uhci, struct urb *urb);
 static void uhci_remove_pending_urbps(struct uhci_hcd *uhci);
@@ -174,7 +174,7 @@
  */
 static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td, unsigned framenum)
 {
-	framenum %= UHCI_NUMFRAMES;
+	framenum &= (UHCI_NUMFRAMES - 1);
 
 	td->frame = framenum;
 
@@ -230,42 +230,22 @@
 }
 
 /*
- * Inserts a td into qh list at the top.
+ * Inserts a td list into qh.
  */
 static void uhci_insert_tds_in_qh(struct uhci_qh *qh, struct urb *urb, __le32 breadth)
 {
-	struct list_head *tmp, *head;
 	struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv;
-	struct uhci_td *td, *ptd;
-
-	if (list_empty(&urbp->td_list))
-		return;
-
-	head = &urbp->td_list;
-	tmp = head->next;
+	struct uhci_td *td;
+	u32 *plink;
 
 	/* Ordering isn't important here yet since the QH hasn't been */
-	/*  inserted into the schedule yet */
-	td = list_entry(tmp, struct uhci_td, list);
-
-	/* Add the first TD to the QH element pointer */
-	qh->element = cpu_to_le32(td->dma_handle) | breadth;
-
-	ptd = td;
-
-	/* Then link the rest of the TD's */
-	tmp = tmp->next;
-	while (tmp != head) {
-		td = list_entry(tmp, struct uhci_td, list);
-
-		tmp = tmp->next;
-
-		ptd->link = cpu_to_le32(td->dma_handle) | breadth;
-
-		ptd = td;
+	/* inserted into the schedule yet */
+	plink = &qh->element;
+	list_for_each_entry(td, &urbp->td_list, list) {
+		*plink = cpu_to_le32(td->dma_handle) | breadth;
+		plink = &td->link;
 	}
-
-	ptd->link = UHCI_PTR_TERM;
+	*plink = UHCI_PTR_TERM;
 }
 
 static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
@@ -330,7 +310,7 @@
 static void uhci_insert_qh(struct uhci_hcd *uhci, struct uhci_qh *skelqh, struct urb *urb)
 {
 	struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv;
-	struct list_head *tmp;
+	struct urb_priv *turbp;
 	struct uhci_qh *lqh;
 
 	/* Grab the last QH */
@@ -358,12 +338,8 @@
 	 */
 	lqh->link = cpu_to_le32(urbp->qh->dma_handle) | UHCI_PTR_QH;
 	if (lqh->urbp) {
-		list_for_each (tmp, &lqh->urbp->queue_list) {
-			struct urb_priv *turbp =
-				list_entry(tmp, struct urb_priv, queue_list);
-
+		list_for_each_entry(turbp, &lqh->urbp->queue_list, queue_list)
 			turbp->qh->link = lqh->link;
-		}
 	}
 
 	list_add_tail(&urbp->qh->list, &skelqh->list);
@@ -405,18 +381,11 @@
 		pqh = list_entry(qh->list.prev, struct uhci_qh, list);
 		pqh->link = newlink;
 		if (pqh->urbp) {
-			struct list_head *head, *tmp;
-
-			head = &pqh->urbp->queue_list;
-			tmp = head->next;
-			while (head != tmp) {
-				struct urb_priv *turbp =
-					list_entry(tmp, struct urb_priv, queue_list);
-
-				tmp = tmp->next;
+			struct urb_priv *turbp;
 
+			list_for_each_entry(turbp, &pqh->urbp->queue_list,
+					queue_list)
 				turbp->qh->link = newlink;
-			}
 		}
 		wmb();
 
@@ -447,21 +416,14 @@
 static int uhci_fixup_toggle(struct urb *urb, unsigned int toggle)
 {
 	struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv;
-	struct list_head *head, *tmp;
-
-	head = &urbp->td_list;
-	tmp = head->next;
-	while (head != tmp) {
-		struct uhci_td *td = list_entry(tmp, struct uhci_td, list);
-
-		tmp = tmp->next;
+	struct uhci_td *td;
 
+	list_for_each_entry(td, &urbp->td_list, list) {
 		if (toggle)
 			td->token |= cpu_to_le32(TD_TOKEN_TOGGLE);
 		else
 			td->token &= ~cpu_to_le32(TD_TOKEN_TOGGLE);
 
-
 		toggle ^= 1;
 	}
 
@@ -473,30 +435,19 @@
 static void uhci_append_queued_urb(struct uhci_hcd *uhci, struct urb *eurb, struct urb *urb)
 {
 	struct urb_priv *eurbp, *urbp, *furbp, *lurbp;
-	struct list_head *tmp;
 	struct uhci_td *lltd;
 
 	eurbp = eurb->hcpriv;
 	urbp = urb->hcpriv;
 
 	/* Find the first URB in the queue */
+	furbp = eurbp;
 	if (eurbp->queued) {
-		struct list_head *head = &eurbp->queue_list;
-
-		tmp = head->next;
-		while (tmp != head) {
-			struct urb_priv *turbp =
-				list_entry(tmp, struct urb_priv, queue_list);
-
-			if (!turbp->queued)
+		list_for_each_entry(furbp, &eurbp->queue_list, queue_list)
+			if (!furbp->queued)
 				break;
+	}
 
-			tmp = tmp->next;
-		}
-	} else
-		tmp = &eurbp->queue_list;
-
-	furbp = list_entry(tmp, struct urb_priv, queue_list);
 	lurbp = list_entry(furbp->queue_list.prev, struct urb_priv, queue_list);
 
 	lltd = list_entry(lurbp->td_list.prev, struct uhci_td, list);
@@ -522,9 +473,7 @@
 
 static void uhci_delete_queued_urb(struct uhci_hcd *uhci, struct urb *urb)
 {
-	struct urb_priv *urbp, *nurbp;
-	struct list_head *head, *tmp;
-	struct urb_priv *purbp;
+	struct urb_priv *urbp, *nurbp, *purbp, *turbp;
 	struct uhci_td *pltd;
 	unsigned int toggle;
 
@@ -556,14 +505,7 @@
 			toggle = uhci_toggle(td_token(pltd)) ^ 1;
 		}
 
-		head = &urbp->queue_list;
-		tmp = head->next;
-		while (head != tmp) {
-			struct urb_priv *turbp;
-
-			turbp = list_entry(tmp, struct urb_priv, queue_list);
-			tmp = tmp->next;
-
+		list_for_each_entry(turbp, &urbp->queue_list, queue_list) {
 			if (!turbp->queued)
 				break;
 			toggle = uhci_fixup_toggle(turbp->urb, toggle);
@@ -637,7 +579,7 @@
 
 static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb)
 {
-	struct list_head *head, *tmp;
+	struct uhci_td *td, *tmp;
 	struct urb_priv *urbp;
 	unsigned int age;
 
@@ -660,13 +602,7 @@
 	if (list_empty(&uhci->td_remove_list))
 		uhci_set_next_interrupt(uhci);
 
-	head = &urbp->td_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct uhci_td *td = list_entry(tmp, struct uhci_td, list);
-
-		tmp = tmp->next;
-
+	list_for_each_entry_safe(td, tmp, &urbp->td_list, list) {
 		uhci_remove_td_from_urb(td);
 		uhci_remove_td(uhci, td);
 		list_add(&td->remove_list, &uhci->td_remove_list);
@@ -829,8 +765,12 @@
 
 	uhci_insert_tds_in_qh(qh, urb, UHCI_PTR_BREADTH);
 
-	/* Low-speed transfers get a different queue, and won't hog the bus */
-	if (urb->dev->speed == USB_SPEED_LOW)
+	/* Low-speed transfers get a different queue, and won't hog the bus.
+	 * Also, some devices enumerate better without FSBR; the easiest way
+	 * to do that is to put URBs on the low-speed queue while the device
+	 * is in the DEFAULT state. */
+	if (urb->dev->speed == USB_SPEED_LOW ||
+			urb->dev->state == USB_STATE_DEFAULT)
 		skelqh = uhci->skel_ls_control_qh;
 	else {
 		skelqh = uhci->skel_fs_control_qh;
@@ -1083,7 +1023,6 @@
  */
 static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb)
 {
-	struct list_head *tmp, *head;
 	struct urb_priv *urbp = urb->hcpriv;
 	struct uhci_td *td;
 	unsigned int status = 0;
@@ -1091,13 +1030,7 @@
 
 	urb->actual_length = 0;
 
-	head = &urbp->td_list;
-	tmp = head->next;
-	while (tmp != head) {
-		td = list_entry(tmp, struct uhci_td, list);
-
-		tmp = tmp->next;
-
+	list_for_each_entry(td, &urbp->td_list, list) {
 		status = uhci_status_bits(td_status(td));
 		if (status & TD_CTRL_ACTIVE)
 			return -EINPROGRESS;
@@ -1176,17 +1109,12 @@
 static int isochronous_find_limits(struct uhci_hcd *uhci, struct urb *urb, unsigned int *start, unsigned int *end)
 {
 	struct urb *last_urb = NULL;
-	struct list_head *tmp, *head;
+	struct urb_priv *up;
 	int ret = 0;
 
-	head = &uhci->urb_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct urb_priv *up = list_entry(tmp, struct urb_priv, urb_list);
+	list_for_each_entry(up, &uhci->urb_list, urb_list) {
 		struct urb *u = up->urb;
 
-		tmp = tmp->next;
-
 		/* look for pending URB's with identical pipe handle */
 		if ((urb->pipe == u->pipe) && (urb->dev == u->dev) &&
 		    (u->status == -EINPROGRESS) && (u != urb)) {
@@ -1217,15 +1145,14 @@
 	limits = isochronous_find_limits(uhci, urb, &start, &end);
 
 	if (urb->transfer_flags & URB_ISO_ASAP) {
-		if (limits) {
-			int curframe;
-
-			curframe = uhci_get_current_frame_number(uhci) % UHCI_NUMFRAMES;
-			urb->start_frame = (curframe + 10) % UHCI_NUMFRAMES;
-		} else
+		if (limits)
+			urb->start_frame =
+					(uhci_get_current_frame_number(uhci) +
+						10) & (UHCI_NUMFRAMES - 1);
+		else
 			urb->start_frame = end;
 	} else {
-		urb->start_frame %= UHCI_NUMFRAMES;
+		urb->start_frame &= (UHCI_NUMFRAMES - 1);
 		/* FIXME: Sanity check */
 	}
 
@@ -1272,7 +1199,7 @@
 
 static int uhci_result_isochronous(struct uhci_hcd *uhci, struct urb *urb)
 {
-	struct list_head *tmp, *head;
+	struct uhci_td *td;
 	struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv;
 	int status;
 	int i, ret = 0;
@@ -1280,14 +1207,9 @@
 	urb->actual_length = 0;
 
 	i = 0;
-	head = &urbp->td_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct uhci_td *td = list_entry(tmp, struct uhci_td, list);
+	list_for_each_entry(td, &urbp->td_list, list) {
 		int actlength;
 
-		tmp = tmp->next;
-
 		if (td_status(td) & TD_CTRL_ACTIVE)
 			return -EINPROGRESS;
 
@@ -1311,20 +1233,15 @@
 
 static struct urb *uhci_find_urb_ep(struct uhci_hcd *uhci, struct urb *urb)
 {
-	struct list_head *tmp, *head;
+	struct urb_priv *up;
 
 	/* We don't match Isoc transfers since they are special */
 	if (usb_pipeisoc(urb->pipe))
 		return NULL;
 
-	head = &uhci->urb_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct urb_priv *up = list_entry(tmp, struct urb_priv, urb_list);
+	list_for_each_entry(up, &uhci->urb_list, urb_list) {
 		struct urb *u = up->urb;
 
-		tmp = tmp->next;
-
 		if (u->dev == urb->dev && u->status == -EINPROGRESS) {
 			/* For control, ignore the direction */
 			if (usb_pipecontrol(urb->pipe) &&
@@ -1475,9 +1392,10 @@
 
 static void uhci_unlink_generic(struct uhci_hcd *uhci, struct urb *urb)
 {
-	struct list_head *head, *tmp;
+	struct list_head *head;
+	struct uhci_td *td;
 	struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv;
-	int prevactive = 1;
+	int prevactive = 0;
 
 	uhci_dec_fsbr(uhci, urb);	/* Safe since it checks */
 
@@ -1485,25 +1403,28 @@
 	 * Now we need to find out what the last successful toggle was
 	 * so we can update the local data toggle for the next transfer
 	 *
-	 * There's 3 way's the last successful completed TD is found:
+	 * There are 2 ways the last successful completed TD is found:
 	 *
 	 * 1) The TD is NOT active and the actual length < expected length
 	 * 2) The TD is NOT active and it's the last TD in the chain
+	 *
+	 * and a third way the first uncompleted TD is found:
+	 *
 	 * 3) The TD is active and the previous TD is NOT active
 	 *
 	 * Control and Isochronous ignore the toggle, so this is safe
 	 * for all types
+	 *
+	 * FIXME: The toggle fixups won't be 100% reliable until we
+	 * change over to using a single queue for each endpoint and
+	 * stop the queue before unlinking.
 	 */
 	head = &urbp->td_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct uhci_td *td = list_entry(tmp, struct uhci_td, list);
-
-		tmp = tmp->next;
-
+	list_for_each_entry(td, head, list) {
 		if (!(td_status(td) & TD_CTRL_ACTIVE) &&
-		    (uhci_actual_length(td_status(td)) < uhci_expected_length(td_token(td)) ||
-		    tmp == head))
+				(uhci_actual_length(td_status(td)) <
+				 uhci_expected_length(td_token(td)) ||
+				td->list.next == head))
 			usb_settoggle(urb->dev, uhci_endpoint(td_token(td)),
 				uhci_packetout(td_token(td)),
 				uhci_toggle(td_token(td)) ^ 1);
@@ -1556,7 +1477,8 @@
 static int uhci_fsbr_timeout(struct uhci_hcd *uhci, struct urb *urb)
 {
 	struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv;
-	struct list_head *head, *tmp;
+	struct list_head *head;
+	struct uhci_td *td;
 	int count = 0;
 
 	uhci_dec_fsbr(uhci, urb);
@@ -1570,18 +1492,14 @@
 	 */
 
 	head = &urbp->td_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct uhci_td *td = list_entry(tmp, struct uhci_td, list);
-
-		tmp = tmp->next;
-
+	list_for_each_entry(td, head, list) {
 		/*
 		 * Make sure we don't do the last one (since it'll have the
 		 * TERM bit set) as well as we skip every so many TD's to
 		 * make sure it doesn't hog the bandwidth
 		 */
-		if (tmp != head && (count % DEPTH_INTERVAL) == (DEPTH_INTERVAL - 1))
+		if (td->list.next != head && (count % DEPTH_INTERVAL) ==
+				(DEPTH_INTERVAL - 1))
 			td->link |= UHCI_PTR_DEPTH;
 
 		count++;
@@ -1595,7 +1513,7 @@
  *
  * returns the current frame number for a USB bus/controller.
  */
-static int uhci_get_current_frame_number(struct uhci_hcd *uhci)
+static unsigned int uhci_get_current_frame_number(struct uhci_hcd *uhci)
 {
 	return inw(uhci->io_addr + USBFRNUM);
 }
@@ -1606,12 +1524,10 @@
 {
 	struct usb_hcd *hcd = (struct usb_hcd *)ptr;
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
-	struct list_head list, *tmp, *head;
+	struct urb_priv *up;
 	unsigned long flags;
 	int called_uhci_finish_completion = 0;
 
-	INIT_LIST_HEAD(&list);
-
 	spin_lock_irqsave(&uhci->schedule_lock, flags);
 	if (!list_empty(&uhci->urb_remove_list) &&
 	    uhci_get_current_frame_number(uhci) != uhci->urb_remove_age) {
@@ -1620,14 +1536,9 @@
 		called_uhci_finish_completion = 1;
 	}
 
-	head = &uhci->urb_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct urb_priv *up = list_entry(tmp, struct urb_priv, urb_list);
+	list_for_each_entry(up, &uhci->urb_list, urb_list) {
 		struct urb *u = up->urb;
 
-		tmp = tmp->next;
-
 		spin_lock(&u->lock);
 
 		/* Check if the FSBR timed out */
@@ -1642,17 +1553,6 @@
 	if (called_uhci_finish_completion)
 		wake_up_all(&uhci->waitqh);
 
-	head = &list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct urb_priv *up = list_entry(tmp, struct urb_priv, urb_list);
-		struct urb *u = up->urb;
-
-		tmp = tmp->next;
-
-		uhci_urb_dequeue(hcd, u);
-	}
-
 	/* Really disable FSBR */
 	if (!uhci->fsbr && uhci->fsbrtimeout && time_after_eq(jiffies, uhci->fsbrtimeout)) {
 		uhci->fsbrtimeout = 0;
@@ -1661,6 +1561,8 @@
 
 	/* Poll for and perform state transitions */
 	hc_state_transitions(uhci);
+	if (unlikely(uhci->suspended_ports && uhci->state != UHCI_SUSPENDED))
+		uhci_check_resume(uhci);
 
 	init_stall_timer(hcd);
 }
@@ -1680,15 +1582,9 @@
 
 static void uhci_free_pending_qhs(struct uhci_hcd *uhci)
 {
-	struct list_head *tmp, *head;
-
-	head = &uhci->qh_remove_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct uhci_qh *qh = list_entry(tmp, struct uhci_qh, remove_list);
-
-		tmp = tmp->next;
+	struct uhci_qh *qh, *tmp;
 
+	list_for_each_entry_safe(qh, tmp, &uhci->qh_remove_list, remove_list) {
 		list_del_init(&qh->remove_list);
 
 		uhci_free_qh(uhci, qh);
@@ -1697,22 +1593,19 @@
 
 static void uhci_free_pending_tds(struct uhci_hcd *uhci)
 {
-	struct list_head *tmp, *head;
-
-	head = &uhci->td_remove_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct uhci_td *td = list_entry(tmp, struct uhci_td, remove_list);
-
-		tmp = tmp->next;
+	struct uhci_td *td, *tmp;
 
+	list_for_each_entry_safe(td, tmp, &uhci->td_remove_list, remove_list) {
 		list_del_init(&td->remove_list);
 
 		uhci_free_td(uhci, td);
 	}
 }
 
-static void uhci_finish_urb(struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs)
+static void
+uhci_finish_urb(struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs)
+__releases(uhci->schedule_lock)
+__acquires(uhci->schedule_lock)
 {
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
 
@@ -1726,19 +1619,13 @@
 static void uhci_finish_completion(struct usb_hcd *hcd, struct pt_regs *regs)
 {
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
-	struct list_head *tmp, *head;
+	struct urb_priv *urbp, *tmp;
 
-	head = &uhci->complete_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct urb_priv *urbp = list_entry(tmp, struct urb_priv, urb_list);
+	list_for_each_entry_safe(urbp, tmp, &uhci->complete_list, urb_list) {
 		struct urb *urb = urbp->urb;
 
 		list_del_init(&urbp->urb_list);
 		uhci_finish_urb(hcd, urb, regs);
-
-		head = &uhci->complete_list;
-		tmp = head->next;
 	}
 }
 
@@ -1754,7 +1641,7 @@
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
 	unsigned long io_addr = uhci->io_addr;
 	unsigned short status;
-	struct list_head *tmp, *head;
+	struct urb_priv *urbp, *tmp;
 	unsigned int age;
 
 	/*
@@ -1801,15 +1688,11 @@
 	else
 		uhci_set_next_interrupt(uhci);
 
-	/* Walk the list of pending URB's to see which ones completed */
-	head = &uhci->urb_list;
-	tmp = head->next;
-	while (tmp != head) {
-		struct urb_priv *urbp = list_entry(tmp, struct urb_priv, urb_list);
+	/* Walk the list of pending URBs to see which ones completed
+	 * (must be _safe because uhci_transfer_result() dequeues URBs) */
+	list_for_each_entry_safe(urbp, tmp, &uhci->urb_list, urb_list) {
 		struct urb *urb = urbp->urb;
 
-		tmp = tmp->next;
-
 		/* Checks the status and does all of the magic necessary */
 		uhci_transfer_result(uhci, urb);
 	}
@@ -1971,10 +1854,10 @@
 	}
 }
 
-static void start_hc(struct uhci_hcd *uhci)
+static int start_hc(struct uhci_hcd *uhci)
 {
 	unsigned long io_addr = uhci->io_addr;
-	int timeout = 1000;
+	int timeout = 10;
 
 	/*
 	 * Reset the HC - this will force us to get a
@@ -1984,10 +1867,11 @@
 	 */
 	outw(USBCMD_HCRESET, io_addr + USBCMD);
 	while (inw(io_addr + USBCMD) & USBCMD_HCRESET) {
-		if (!--timeout) {
+		if (--timeout < 0) {
 			dev_err(uhci_dev(uhci), "USBCMD_HCRESET timed out!\n");
-			break;
+			return -ETIMEDOUT;
 		}
+		msleep(1);
 	}
 
 	/* Turn on PIRQ and all interrupts */
@@ -2006,6 +1890,7 @@
 	outw(USBCMD_RS | USBCMD_CF | USBCMD_MAXP, io_addr + USBCMD);
 
         uhci->hcd.state = USB_STATE_RUNNING;
+	return 0;
 }
 
 /*
@@ -2257,7 +2142,8 @@
 	 * the memory writes above before the I/O transfers in start_hc().
 	 */
 	mb();
-	start_hc(uhci);
+	if ((retval = start_hc(uhci)) != 0)
+		goto err_alloc_skelqh;
 
 	init_stall_timer(hcd);
 
@@ -2363,6 +2249,7 @@
 static int uhci_resume(struct usb_hcd *hcd)
 {
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
+	int rc;
 
 	pci_set_master(to_pci_dev(uhci_dev(uhci)));
 
@@ -2385,7 +2272,8 @@
 				USBLEGSUP_DEFAULT);
 	} else {
 		reset_hc(uhci);
-		start_hc(uhci);
+		if ((rc = start_hc(uhci)) != 0)
+			return rc;
 	}
 	uhci->hcd.state = USB_STATE_RUNNING;
 	return 0;
@@ -2405,11 +2293,6 @@
 	return &uhci->hcd;
 }
 
-static void uhci_hcd_free(struct usb_hcd *hcd)
-{
-	kfree(hcd_to_uhci(hcd));
-}
-
 /* Are there any URBs for a particular device/endpoint on a given list? */
 static int urbs_for_ep_list(struct list_head *head,
 		struct hcd_dev *hdev, int ep)
@@ -2474,7 +2357,6 @@
 	.stop =			uhci_stop,
 
 	.hcd_alloc =		uhci_hcd_alloc,
-	.hcd_free =		uhci_hcd_free,
 
 	.urb_enqueue =		uhci_urb_enqueue,
 	.urb_dequeue =		uhci_urb_dequeue,
@@ -2534,7 +2416,7 @@
 	if (!uhci_up_cachep)
 		goto up_failed;
 
-	retval = pci_module_init(&uhci_pci_driver);
+	retval = pci_register_driver(&uhci_pci_driver);
 	if (retval)
 		goto init_failed;
 
diff -Nru a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
--- a/drivers/usb/host/uhci-hcd.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/host/uhci-hcd.h	2004-12-24 13:37:18 -08:00
@@ -324,7 +324,7 @@
  * a subset of what the full implementation needs.
  */
 struct uhci_hcd {
-	struct usb_hcd hcd;
+	struct usb_hcd hcd;		/* must come first! */
 
 #ifdef CONFIG_PROC_FS
 	/* procfs */
@@ -352,6 +352,12 @@
 	int resume_detect;			/* Need a Global Resume */
 	unsigned int saved_framenumber;		/* Save during PM suspend */
 
+	/* Support for port suspend/resume */
+	unsigned long port_c_suspend;		/* Bit-arrays of ports */
+	unsigned long suspended_ports;
+	unsigned long resuming_ports;
+	unsigned long resume_timeout;		/* Time to stop signalling */
+
 	/* Main list of URB's currently controlled by this HC */
 	struct list_head urb_list;		/* P: uhci->schedule_lock */
 
@@ -385,12 +391,12 @@
 	struct uhci_qh *qh;		/* QH for this URB */
 	struct list_head td_list;	/* P: urb->lock */
 
-	int fsbr : 1;			/* URB turned on FSBR */
-	int fsbr_timeout : 1;		/* URB timed out on FSBR */
-	int queued : 1;			/* QH was queued (not linked in) */
-	int short_control_packet : 1;	/* If we get a short packet during */
-					/*  a control transfer, retrigger */
-					/*  the status phase */
+	unsigned fsbr : 1;		/* URB turned on FSBR */
+	unsigned fsbr_timeout : 1;	/* URB timed out on FSBR */
+	unsigned queued : 1;		/* QH was queued (not linked in) */
+	unsigned short_control_packet : 1;	/* If we get a short packet during */
+						/*  a control transfer, retrigger */
+						/*  the status phase */
 
 	unsigned long inserttime;	/* In jiffies */
 	unsigned long fsbrtime;		/* In jiffies */
diff -Nru a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
--- a/drivers/usb/host/uhci-hub.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/host/uhci-hub.c	2004-12-24 13:36:18 -08:00
@@ -36,14 +36,16 @@
 static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
-	unsigned long io_addr = uhci->io_addr;
-	int i;
+	int port;
 
 	*buf = 0;
-	for (i = 0; i < uhci->rh_numports; i++) {
-		if (inw(io_addr + USBPORTSC1 + i * 2) & RWC_BITS)
-			*buf |= (1 << (i + 1));
+	for (port = 0; port < uhci->rh_numports; ++port) {
+		if ((inw(uhci->io_addr + USBPORTSC1 + port * 2) & RWC_BITS) ||
+				test_bit(port, &uhci->port_c_suspend))
+			*buf |= (1 << (port + 1));
 	}
+	if (*buf && uhci->state == UHCI_SUSPENDED)
+		uhci->resume_detect = 1;
 	return !!*buf;
 }
 
@@ -62,31 +64,73 @@
 	status &= ~(RWC_BITS|WZ_BITS); \
 	outw(status, port_addr)
 
+/* UHCI controllers don't automatically stop resume signalling after 20 msec,
+ * so we have to poll and check timeouts in order to take care of it.
+ * FIXME:  Synchronize access to these fields by a spinlock.
+ */
+static void uhci_finish_suspend(struct uhci_hcd *uhci, int port,
+		unsigned long port_addr)
+{
+	int status;
+
+	if (test_bit(port, &uhci->suspended_ports)) {
+		CLR_RH_PORTSTAT(USBPORTSC_SUSP | USBPORTSC_RD);
+		clear_bit(port, &uhci->suspended_ports);
+		clear_bit(port, &uhci->resuming_ports);
+		set_bit(port, &uhci->port_c_suspend);
+
+		/* The controller won't actually turn off the RD bit until
+		 * it has had a chance to send a low-speed EOP sequence,
+		 * which takes 3 bit times (= 2 microseconds).  We'll delay
+		 * slightly longer for good luck. */
+		udelay(4);
+	}
+}
+
+static void uhci_check_resume(struct uhci_hcd *uhci)
+{
+	unsigned int port;
+	unsigned long port_addr;
+
+	for (port = 0; port < uhci->rh_numports; ++port) {
+		port_addr = uhci->io_addr + USBPORTSC1 + 2 * port;
+		if (unlikely(inw(port_addr) & USBPORTSC_RD)) {
+			if (!test_bit(port, &uhci->resuming_ports)) {
+
+				/* Port received a wakeup request */
+				set_bit(port, &uhci->resuming_ports);
+				uhci->resume_timeout = jiffies +
+						msecs_to_jiffies(20);
+			} else if (time_after_eq(jiffies,
+						uhci->resume_timeout)) {
+				uhci_finish_suspend(uhci, port, port_addr);
+			}
+		}
+	}
+}
 
 /* size of returned buffer is part of USB spec */
 static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			u16 wIndex, char *buf, u16 wLength)
 {
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
-	int status, retval = 0, len = 0;
-	unsigned long port_addr = uhci->io_addr + USBPORTSC1 + 2 * (wIndex-1);
-	__u16 wPortChange, wPortStatus;
+	int status, lstatus, retval = 0, len = 0;
+	unsigned int port = wIndex - 1;
+	unsigned long port_addr = uhci->io_addr + USBPORTSC1 + 2 * port;
+	u16 wPortChange, wPortStatus;
 
 	switch (typeReq) {
-		/* Request Destination:
-		   without flags: Device,
-		   RH_INTERFACE: interface,
-		   RH_ENDPOINT: endpoint,
-		   RH_CLASS means HUB here,
-		   RH_OTHER | RH_CLASS  almost ever means HUB_PORT here
-		*/
 
 	case GetHubStatus:
 		*(__le32 *)buf = cpu_to_le32(0);
 		OK(4);		/* hub power */
 	case GetPortStatus:
-		if (!wIndex || wIndex > uhci->rh_numports)
+		if (port >= uhci->rh_numports)
 			goto err;
+
+		if (uhci->resuming_ports)
+			uhci_check_resume(uhci);
+
 		status = inw(port_addr);
 
 		/* Intel controllers report the OverCurrent bit active on.
@@ -97,34 +141,43 @@
 				PCI_VENDOR_ID_VIA)
 			status ^= USBPORTSC_OC;
 
-		/* UHCI doesn't support C_SUSPEND and C_RESET (always false) */
-		wPortChange = 0;
+		/* UHCI doesn't support C_RESET (always false) */
+		wPortChange = lstatus = 0;
 		if (status & USBPORTSC_CSC)
-			wPortChange |= 1 << (USB_PORT_FEAT_C_CONNECTION - 16);
+			wPortChange |= USB_PORT_STAT_C_CONNECTION;
 		if (status & USBPORTSC_PEC)
-			wPortChange |= 1 << (USB_PORT_FEAT_C_ENABLE - 16);
+			wPortChange |= USB_PORT_STAT_C_ENABLE;
 		if (status & USBPORTSC_OCC)
-			wPortChange |= 1 << (USB_PORT_FEAT_C_OVER_CURRENT - 16);
+			wPortChange |= USB_PORT_STAT_C_OVERCURRENT;
+
+		if (test_bit(port, &uhci->port_c_suspend)) {
+			wPortChange |= USB_PORT_STAT_C_SUSPEND;
+			lstatus |= 1;
+		}
+		if (test_bit(port, &uhci->suspended_ports))
+			lstatus |= 2;
+		if (test_bit(port, &uhci->resuming_ports))
+			lstatus |= 4;
 
 		/* UHCI has no power switching (always on) */
-		wPortStatus = 1 << USB_PORT_FEAT_POWER;
+		wPortStatus = USB_PORT_STAT_POWER;
 		if (status & USBPORTSC_CCS)
-			wPortStatus |= 1 << USB_PORT_FEAT_CONNECTION;
+			wPortStatus |= USB_PORT_STAT_CONNECTION;
 		if (status & USBPORTSC_PE) {
-			wPortStatus |= 1 << USB_PORT_FEAT_ENABLE;
+			wPortStatus |= USB_PORT_STAT_ENABLE;
 			if (status & (USBPORTSC_SUSP | USBPORTSC_RD))
-				wPortStatus |= 1 << USB_PORT_FEAT_SUSPEND;
+				wPortStatus |= USB_PORT_STAT_SUSPEND;
 		}
 		if (status & USBPORTSC_OC)
-			wPortStatus |= 1 << USB_PORT_FEAT_OVER_CURRENT;
+			wPortStatus |= USB_PORT_STAT_OVERCURRENT;
 		if (status & USBPORTSC_PR)
-			wPortStatus |= 1 << USB_PORT_FEAT_RESET;
+			wPortStatus |= USB_PORT_STAT_RESET;
 		if (status & USBPORTSC_LSDA)
-			wPortStatus |= 1 << USB_PORT_FEAT_LOWSPEED;
+			wPortStatus |= USB_PORT_STAT_LOW_SPEED;
 
 		if (wPortChange)
-			dev_dbg(uhci_dev(uhci), "port %d portsc %04x\n",
-					wIndex, status);
+			dev_dbg(uhci_dev(uhci), "port %d portsc %04x,%02x\n",
+					wIndex, status, lstatus);
 
 		*(__le16 *)buf = cpu_to_le16(wPortStatus);
 		*(__le16 *)(buf + 2) = cpu_to_le16(wPortChange);
@@ -140,11 +193,12 @@
 		}
 		break;
 	case SetPortFeature:
-		if (!wIndex || wIndex > uhci->rh_numports)
+		if (port >= uhci->rh_numports)
 			goto err;
 
 		switch (wValue) {
 		case USB_PORT_FEAT_SUSPEND:
+			set_bit(port, &uhci->suspended_ports);
 			SET_RH_PORTSTAT(USBPORTSC_SUSP);
 			OK(0);
 		case USB_PORT_FEAT_RESET:
@@ -152,6 +206,9 @@
 			mdelay(50);	/* USB v1.1 7.1.7.3 */
 			CLR_RH_PORTSTAT(USBPORTSC_PR);
 			udelay(10);
+
+			/* Reset terminates Resume signalling */
+			uhci_finish_suspend(uhci, port, port_addr);
 			SET_RH_PORTSTAT(USBPORTSC_PE);
 			mdelay(10);
 			CLR_RH_PORTSTAT(USBPORTSC_PEC|USBPORTSC_CSC);
@@ -164,21 +221,38 @@
 		}
 		break;
 	case ClearPortFeature:
-		if (!wIndex || wIndex > uhci->rh_numports)
+		if (port >= uhci->rh_numports)
 			goto err;
 
 		switch (wValue) {
 		case USB_PORT_FEAT_ENABLE:
 			CLR_RH_PORTSTAT(USBPORTSC_PE);
+
+			/* Disable terminates Resume signalling */
+			uhci_finish_suspend(uhci, port, port_addr);
 			OK(0);
 		case USB_PORT_FEAT_C_ENABLE:
 			CLR_RH_PORTSTAT(USBPORTSC_PEC);
 			OK(0);
 		case USB_PORT_FEAT_SUSPEND:
-			CLR_RH_PORTSTAT(USBPORTSC_SUSP);
+			if (test_bit(port, &uhci->suspended_ports) &&
+					!test_and_set_bit(port,
+						&uhci->resuming_ports)) {
+				uhci->resume_timeout = jiffies +
+						msecs_to_jiffies(20);
+				SET_RH_PORTSTAT(USBPORTSC_RD);
+
+				/* The controller won't allow RD to be set
+				 * if the port is disabled.  When this happens
+				 * just skip the Resume signalling.
+				 */
+				if (!(inw(port_addr) & USBPORTSC_RD))
+					uhci_finish_suspend(uhci, port,
+							port_addr);
+			}
 			OK(0);
 		case USB_PORT_FEAT_C_SUSPEND:
-			/* this driver won't report these */
+			clear_bit(port, &uhci->port_c_suspend);
 			OK(0);
 		case USB_PORT_FEAT_POWER:
 			/* UHCI has no power switching */
diff -Nru a/drivers/usb/image/Kconfig b/drivers/usb/image/Kconfig
--- a/drivers/usb/image/Kconfig	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/image/Kconfig	2004-12-24 13:36:18 -08:00
@@ -30,11 +30,12 @@
 	  This driver can be compiled as a module, called microtek.
 
 config USB_HPUSBSCSI
-	tristate "HP53xx USB scanner support (EXPERIMENTAL)"
-	depends on USB && SCSI && EXPERIMENTAL
+	tristate "HP53xx USB scanner support"
+	depends on USB && SCSI
 	help
 	  Say Y here if you want support for the HP 53xx series of scanners
-	  and the Minolta Scan Dual. This driver is experimental.
+	  and the Minolta Scan Dual.
 	  The scanner will be accessible as a SCSI device.
+	  Please note that recent versions of SANE use usbfs, not this driver.
 	  This can be compiled as a module, called hpusbscsi.
 
diff -Nru a/drivers/usb/image/hpusbscsi.c b/drivers/usb/image/hpusbscsi.c
--- a/drivers/usb/image/hpusbscsi.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/usb/image/hpusbscsi.c	2004-12-24 13:37:30 -08:00
@@ -106,7 +106,7 @@
 	/* In host->hostdata we store a pointer to desc */
 	new->host = scsi_host_alloc(&hpusbscsi_scsi_host_template, sizeof(new));
 	if (!new->host)
-		goto out_unlink_controlurb;
+		goto out_kill_controlurb;
 
 	new->host->hostdata[0] = (unsigned long)new;
 	scsi_add_host(new->host, &intf->dev); /* XXX handle failure */
@@ -118,8 +118,8 @@
 	usb_set_intfdata(intf, new);
 	return 0;
 
- out_unlink_controlurb:
-	usb_unlink_urb(new->controlurb);
+ out_kill_controlurb:
+	usb_kill_urb(new->controlurb);
  out_free_controlurb:
 	usb_free_urb(new->controlurb);
  out_free_dataurb:
@@ -137,7 +137,7 @@
 	usb_set_intfdata(intf, NULL);
 
 	scsi_remove_host(desc->host);
-	usb_unlink_urb(desc->controlurb);
+	usb_kill_urb(desc->controlurb);
 	scsi_host_put(desc->host);
 
 	usb_free_urb(desc->controlurb);
@@ -280,8 +280,8 @@
 	struct hpusbscsi* hpusbscsi = (struct hpusbscsi*)(srb->device->host->hostdata[0]);
 	printk(KERN_DEBUG"Requested is canceled.\n");
 
-	usb_unlink_urb(hpusbscsi->dataurb);
-	usb_unlink_urb(hpusbscsi->controlurb);
+	usb_kill_urb(hpusbscsi->dataurb);
+	usb_kill_urb(hpusbscsi->controlurb);
 	hpusbscsi->state = HP_STATE_FREE;
 
 	return SCSI_ABORT_PENDING;
diff -Nru a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
--- a/drivers/usb/image/mdc800.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/usb/image/mdc800.c	2004-12-24 13:36:55 -08:00
@@ -317,7 +317,6 @@
 	mdc800->camera_request_ready=1+mode;
 
 	add_wait_queue(&mdc800->irq_wait, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
 	timeout = msec*HZ/1000;
 	while (!mdc800->irq_woken && timeout)
 	{
@@ -325,7 +324,6 @@
 		timeout = schedule_timeout (timeout);
 	}
         remove_wait_queue(&mdc800->irq_wait, &wait);
-	set_current_state(TASK_RUNNING);
 	mdc800->irq_woken = 0;
 
 	if (mdc800->camera_request_ready>0)
@@ -543,9 +541,9 @@
 
 		mdc800->state=NOT_CONNECTED;
 
-		usb_unlink_urb (mdc800->irq_urb);
-		usb_unlink_urb (mdc800->write_urb);
-		usb_unlink_urb (mdc800->download_urb);
+		usb_kill_urb(mdc800->irq_urb);
+		usb_kill_urb(mdc800->write_urb);
+		usb_kill_urb(mdc800->download_urb);
 
 		mdc800->dev = NULL;
 		usb_set_intfdata(intf, NULL);
@@ -649,9 +647,9 @@
 	down (&mdc800->io_lock);
 	if (mdc800->open && (mdc800->state != NOT_CONNECTED))
 	{
-		usb_unlink_urb (mdc800->irq_urb);
-		usb_unlink_urb (mdc800->write_urb);
-		usb_unlink_urb (mdc800->download_urb);
+		usb_kill_urb(mdc800->irq_urb);
+		usb_kill_urb(mdc800->write_urb);
+		usb_kill_urb(mdc800->download_urb);
 		mdc800->open=0;
 	}
 	else
@@ -725,7 +723,6 @@
 					set_current_state(TASK_UNINTERRUPTIBLE);
 					timeout = schedule_timeout (timeout);
 				}
-				set_current_state(TASK_RUNNING);
 				remove_wait_queue(&mdc800->download_wait, &wait);
 				mdc800->downloaded = 0;
 				if (mdc800->download_urb->status != 0)
@@ -851,12 +848,11 @@
 				set_current_state(TASK_UNINTERRUPTIBLE);
 				timeout = schedule_timeout (timeout);
 			}
-                        set_current_state(TASK_RUNNING);
 			remove_wait_queue(&mdc800->write_wait, &wait);
 			mdc800->written = 0;
 			if (mdc800->state == WORKING)
 			{
-				usb_unlink_urb (mdc800->write_urb);
+				usb_kill_urb(mdc800->write_urb);
 				up (&mdc800->io_lock);
 				return -EIO;
 			}
diff -Nru a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
--- a/drivers/usb/image/microtek.c	2004-12-24 13:37:34 -08:00
+++ b/drivers/usb/image/microtek.c	2004-12-24 13:37:34 -08:00
@@ -324,7 +324,7 @@
 	MTS_DEBUG_GOT_HERE();
 	mts_debug_dump(desc);
 
-	usb_unlink_urb( desc->urb );
+	usb_kill_urb( desc->urb );
 }
 
 static int mts_scsi_abort (Scsi_Cmnd *srb)
@@ -341,12 +341,18 @@
 static int mts_scsi_host_reset (Scsi_Cmnd *srb)
 {
 	struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]);
+	int result, rc;
 
 	MTS_DEBUG_GOT_HERE();
 	mts_debug_dump(desc);
 
-	usb_reset_device(desc->usb_dev); /*FIXME: untested on new reset code */
-	return 0;  /* RANT why here 0 and not SUCCESS */
+	rc = usb_lock_device_for_reset(desc->usb_dev, desc->usb_intf);
+	if (rc < 0)
+		return FAILED;
+	result = usb_reset_device(desc->usb_dev);;
+	if (rc)
+		usb_unlock_device(desc->usb_dev);
+	return result ? FAILED : SUCCESS;
 }
 
 static
@@ -777,6 +783,7 @@
 		goto out_kfree;
 
 	new_desc->usb_dev = dev;
+	new_desc->usb_intf = intf;
 	init_MUTEX(&new_desc->lock);
 
 	/* endpoints */
@@ -822,10 +829,10 @@
 
 	usb_set_intfdata(intf, NULL);
 
+	usb_kill_urb(desc->urb);
 	scsi_remove_host(desc->host);
-	usb_unlink_urb(desc->urb);
-	scsi_host_put(desc->host);
 
+	scsi_host_put(desc->host);
 	usb_free_urb(desc->urb);
 	kfree(desc);
 }
diff -Nru a/drivers/usb/image/microtek.h b/drivers/usb/image/microtek.h
--- a/drivers/usb/image/microtek.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/usb/image/microtek.h	2004-12-24 13:36:31 -08:00
@@ -31,6 +31,7 @@
 	struct mts_desc *prev;
 
 	struct usb_device *usb_dev;
+	struct usb_interface *usb_intf;
 
 	/* Endpoint addresses */
 	u8 ep_out;
diff -Nru a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
--- a/drivers/usb/input/Kconfig	2004-12-24 13:37:04 -08:00
+++ b/drivers/usb/input/Kconfig	2004-12-24 13:37:04 -08:00
@@ -1,7 +1,7 @@
 #
 # USB Input driver configuration
 #
-comment "USB Human Interface Devices (HID)"
+comment "USB Input Devices"
 	depends on USB
 
 config USB_HID
@@ -12,7 +12,8 @@
 	  mice, joysticks, graphic tablets, or any other HID based devices
 	  to your computer via USB. You also need to select HID Input layer
 	  support (below) if you want to use keyboards, mice, joysticks and
-	  the like.
+	  the like ... as well as Uninterruptible Power Supply (UPS) and
+	  monitor control devices.
 
 	  You can't use this driver and the HIDBP (Boot Protocol) keyboard
 	  and mouse drivers at the same time. More information is available:
@@ -24,7 +25,7 @@
 	  module will be called usbhid.
 
 comment "Input core support is needed for USB HID input layer or HIDBP support"
-	depends on USB && INPUT=n
+	depends on USB_HID && INPUT=n
 
 config USB_HIDINPUT
 	bool "HID input layer support"
@@ -32,8 +33,7 @@
 	depends on INPUT && USB_HID
 	help
 	  Say Y here if you want to use a USB keyboard, mouse or joystick,
-	  or any other HID input device. You also need "Input core support", 
-	  (CONFIG_INPUT), which you select under "Input device support", above.
+	  or any other HID input device.
 
 	  If unsure, say Y.
 
@@ -87,7 +87,6 @@
 
 	  This module supports these devices separately using a separate
 	  event interface on /dev/usb/hiddevX (char 180:96 to 180:111).
-	  This driver requires CONFIG_USB_HID.
 
 	  If unsure, say Y.
 
@@ -200,6 +199,9 @@
 
 	  The driver has been tested on a Xenarc 700TSV monitor
 	  with eGalax touchscreen.
+
+	  Have a look at http://linux.chapter7.ch/touchkit/ for
+	  a usage description and the required user-space stuff.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called touchkitusb.
diff -Nru a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
--- a/drivers/usb/input/aiptek.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/usb/input/aiptek.c	2004-12-24 13:37:04 -08:00
@@ -837,7 +837,7 @@
 	struct aiptek *aiptek = inputdev->private;
 
 	if (--aiptek->openCount == 0) {
-		usb_unlink_urb(aiptek->urb);
+		usb_kill_urb(aiptek->urb);
 	}
 }
 
@@ -2258,7 +2258,7 @@
 	if (aiptek != NULL) {
 		/* Free & unhook everything from the system.
 		 */
-		usb_unlink_urb(aiptek->urb);
+		usb_kill_urb(aiptek->urb);
 		input_unregister_device(&aiptek->inputdev);
 		aiptek_delete_files(&intf->dev);
 		usb_free_urb(aiptek->urb);
diff -Nru a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
--- a/drivers/usb/input/ati_remote.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/usb/input/ati_remote.c	2004-12-24 13:37:02 -08:00
@@ -102,6 +102,7 @@
 #define ATI_REMOTE_VENDOR_ID 	0x0bc7
 #define ATI_REMOTE_PRODUCT_ID 	0x004
 #define LOLA_REMOTE_PRODUCT_ID 	0x002
+#define MEDION_REMOTE_PRODUCT_ID 0x006
 
 #define DRIVER_VERSION 	        "2.2.1"
 #define DRIVER_AUTHOR           "Torrey Hoffman <thoffman@arnor.net>"
@@ -126,6 +127,7 @@
 static struct usb_device_id ati_remote_table[] = {
 	{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID) },
 	{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA_REMOTE_PRODUCT_ID) },
+	{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, MEDION_REMOTE_PRODUCT_ID) },
 	{}	/* Terminating entry */
 };
 
@@ -418,13 +420,14 @@
 
 	while (timeout && (ati_remote->out_urb->status == -EINPROGRESS) 
 	       && !(ati_remote->send_flags & SEND_FLAG_COMPLETE)) {
+		set_current_state(TASK_INTERRUPTIBLE);
 		timeout = schedule_timeout(timeout);
 		rmb();
 	}
 
 	set_current_state(TASK_RUNNING);
 	remove_wait_queue(&ati_remote->wait, &wait);
-	usb_unlink_urb(ati_remote->out_urb);
+	usb_kill_urb(ati_remote->out_urb);
 	
 	return retval;
 }
@@ -624,10 +627,10 @@
 	if (!ati_remote) return;
 
 	if (ati_remote->irq_urb)
-		usb_unlink_urb(ati_remote->irq_urb);
+		usb_kill_urb(ati_remote->irq_urb);
 
 	if (ati_remote->out_urb)
-		usb_unlink_urb(ati_remote->out_urb);
+		usb_kill_urb(ati_remote->out_urb);
 
 	input_unregister_device(&ati_remote->idev);
 
@@ -729,7 +732,8 @@
 	/* See if the offered device matches what we can accept */
 	if ((udev->descriptor.idVendor != ATI_REMOTE_VENDOR_ID) ||
 		( (udev->descriptor.idProduct != ATI_REMOTE_PRODUCT_ID) &&
-		  (udev->descriptor.idProduct != LOLA_REMOTE_PRODUCT_ID) ))
+		  (udev->descriptor.idProduct != LOLA_REMOTE_PRODUCT_ID) &&
+		  (udev->descriptor.idProduct != MEDION_REMOTE_PRODUCT_ID) ))
 		return -ENODEV;
 
 	/* Allocate and clear an ati_remote struct */
diff -Nru a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
--- a/drivers/usb/input/hid-core.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/usb/input/hid-core.c	2004-12-24 13:36:59 -08:00
@@ -94,7 +94,8 @@
 	memset(field, 0, sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
 		+ values * sizeof(unsigned));
 
-	report->field[report->maxfield++] = field;
+	field->index = report->maxfield++;
+	report->field[field->index] = field;
 	field->usage = (struct hid_usage *)(field + 1);
 	field->value = (unsigned *)(field->usage + usages);
 	field->report = report;
@@ -925,6 +926,7 @@
 		case -ECONNRESET:	/* unlink */
 		case -ENOENT:
 		case -ESHUTDOWN:
+		case -EPERM:
 			return;
 		case -ETIMEDOUT:	/* NAK */
 			break;
@@ -1260,8 +1262,10 @@
 	add_wait_queue(&hid->wait, &wait);
 
 	while (timeout && (test_bit(HID_CTRL_RUNNING, &hid->iofl) ||
-			   test_bit(HID_OUT_RUNNING, &hid->iofl)))
+			   test_bit(HID_OUT_RUNNING, &hid->iofl))) {
+		set_current_state(TASK_UNINTERRUPTIBLE);
 		timeout = schedule_timeout(timeout);
+	}
 
 	set_current_state(TASK_RUNNING);
 	remove_wait_queue(&hid->wait, &wait);
@@ -1350,9 +1354,9 @@
 	while (ret) {
 		err |= ret;
 		if (test_bit(HID_CTRL_RUNNING, &hid->iofl))
-			usb_unlink_urb(hid->urbctrl);
+			usb_kill_urb(hid->urbctrl);
 		if (test_bit(HID_OUT_RUNNING, &hid->iofl))
-			usb_unlink_urb(hid->urbout);
+			usb_kill_urb(hid->urbout);
 		ret = hid_wait_io(hid);
 	}
 
@@ -1428,6 +1432,7 @@
 
 #define USB_VENDOR_ID_CYPRESS		0x04b4
 #define USB_DEVICE_ID_CYPRESS_MOUSE	0x0001
+#define USB_DEVICE_ID_CYPRESS_HIDCOM	0x5500
 
 #define USB_VENDOR_ID_BERKSHIRE		0x0c98
 #define USB_DEVICE_ID_BERKSHIRE_PCWD	0x1140
@@ -1455,10 +1460,14 @@
 #define USB_DEVICE_ID_1_PHIDGETSERVO_20	0x8101
 #define USB_DEVICE_ID_4_PHIDGETSERVO_20	0x8104
 
-#define USB_VENDOR_ID_CODEMERCS		0x07c0
-#define USB_DEVICE_ID_CODEMERCS_IOW40	0x1500
-#define USB_DEVICE_ID_CODEMERCS_IOW24	0x1501
+#define USB_VENDOR_ID_CODEMERCS        0x07c0
+#define USB_DEVICE_ID_CODEMERCS_IOW40  0x1500
+#define USB_DEVICE_ID_CODEMERCS_IOW24  0x1501
+#define USB_DEVICE_ID_CODEMERCS_IOW48  0x1502
+#define USB_DEVICE_ID_CODEMERCS_IOW28  0x1503
 
+#define USB_VENDOR_ID_DELORME		0x1163
+#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100
 
 static struct hid_blacklist {
 	__u16 idVendor;
@@ -1532,6 +1541,7 @@
 
 	{ USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_BACK },
 	{ USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_EXTRA },
+	{ USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE },
 
 	{ USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD },
 	{ USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD },
@@ -1542,6 +1552,13 @@
 	{ USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD },
 	{ USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
 
+	{ USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW24, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW48, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE },
+
+	{ USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE },
+
 	{ 0, 0 }
 };
 
@@ -1686,8 +1703,8 @@
 
 	init_waitqueue_head(&hid->wait);
 	
-	hid->outlock = SPIN_LOCK_UNLOCKED;
-	hid->ctrllock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&hid->outlock);
+	spin_lock_init(&hid->ctrllock);
 
 	hid->version = le16_to_cpu(hdesc->bcdHID);
 	hid->country = hdesc->bCountryCode;
@@ -1825,6 +1842,30 @@
 	return 0;
 }
 
+static int hid_suspend(struct usb_interface *intf, u32 state)
+{
+	struct hid_device *hid = usb_get_intfdata (intf);
+
+	usb_kill_urb(hid->urbin);
+	intf->dev.power.power_state = state;
+	dev_dbg(&intf->dev, "suspend\n");
+	return 0;
+}
+
+static int hid_resume(struct usb_interface *intf)
+{
+	struct hid_device *hid = usb_get_intfdata (intf);
+	int status;
+
+	intf->dev.power.power_state = PM_SUSPEND_ON;
+	if (hid->open)
+		status = usb_submit_urb(hid->urbin, GFP_NOIO);
+	else
+		status = 0;
+	dev_dbg(&intf->dev, "resume status %d\n", status);
+	return status;
+}
+
 static struct usb_device_id hid_usb_ids [] = {
 	{ .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
 	    .bInterfaceClass = USB_INTERFACE_CLASS_HID },
@@ -1838,6 +1879,8 @@
 	.name =		"usbhid",
 	.probe =	hid_probe,
 	.disconnect =	hid_disconnect,
+	.suspend =	hid_suspend,
+	.resume =	hid_resume,
 	.id_table =	hid_usb_ids,
 };
 
diff -Nru a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
--- a/drivers/usb/input/kbtab.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/usb/input/kbtab.c	2004-12-24 13:36:16 -08:00
@@ -122,7 +122,7 @@
 	struct kbtab *kbtab = dev->private;
 
 	if (!--kbtab->open)
-		usb_unlink_urb(kbtab->irq);
+		usb_kill_urb(kbtab->irq);
 }
 
 static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *id)
@@ -205,7 +205,7 @@
 
 	usb_set_intfdata(intf, NULL);
 	if (kbtab) {
-		usb_unlink_urb(kbtab->irq);
+		usb_kill_urb(kbtab->irq);
 		input_unregister_device(&kbtab->dev);
 		usb_free_urb(kbtab->irq);
 		usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma);
diff -Nru a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
--- a/drivers/usb/input/mtouchusb.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/usb/input/mtouchusb.c	2004-12-24 13:36:55 -08:00
@@ -155,7 +155,7 @@
         struct mtouch_usb *mtouch = input->private;
 
         if (!--mtouch->open)
-                usb_unlink_urb (mtouch->irq);
+                usb_kill_urb (mtouch->irq);
 }
 
 static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
@@ -320,7 +320,7 @@
         usb_set_intfdata(intf, NULL);
         if (mtouch) {
                 dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__);
-                usb_unlink_urb(mtouch->irq);
+                usb_kill_urb(mtouch->irq);
                 input_unregister_device(&mtouch->input);
                 usb_free_urb(mtouch->irq);
                 mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch);
diff -Nru a/drivers/usb/input/pid.c b/drivers/usb/input/pid.c
--- a/drivers/usb/input/pid.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/input/pid.c	2004-12-24 13:37:19 -08:00
@@ -56,7 +56,7 @@
     struct hid_ff_pid *private = hid->ff_private;
     
     if (private->urbffout) {
-	usb_unlink_urb(private->urbffout);
+	usb_kill_urb(private->urbffout);
 	usb_free_urb(private->urbffout);
     }
 }
diff -Nru a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
--- a/drivers/usb/input/powermate.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/usb/input/powermate.c	2004-12-24 13:37:00 -08:00
@@ -349,7 +349,7 @@
 		return -ENOMEM;
 	}
 
-	pm->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&pm->lock);
 	init_input_dev(&pm->input);
 
 	/* get a handle to the interrupt data pipe */
@@ -417,7 +417,7 @@
 	usb_set_intfdata(intf, NULL);
 	if (pm) {
 		pm->requires_update = 0;
-		usb_unlink_urb(pm->irq);
+		usb_kill_urb(pm->irq);
 		input_unregister_device(&pm->input);
 		usb_free_urb(pm->irq);
 		usb_free_urb(pm->config);
diff -Nru a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
--- a/drivers/usb/input/touchkitusb.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/usb/input/touchkitusb.c	2004-12-24 13:36:19 -08:00
@@ -59,6 +59,10 @@
 #define DRIVER_AUTHOR			"Daniel Ritz <daniel.ritz@gmx.ch>"
 #define DRIVER_DESC			"eGalax TouchKit USB HID Touchscreen Driver"
 
+static int swap_xy;
+module_param(swap_xy, bool, 0644);
+MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
+
 struct touchkit_usb {
 	unsigned char *data;
 	dma_addr_t data_dma;
@@ -80,6 +84,7 @@
 {
 	struct touchkit_usb *touchkit = urb->context;
 	int retval;
+	int x, y;
 
 	switch (urb->status) {
 	case 0:
@@ -103,13 +108,19 @@
 		goto exit;
 	}
 
+	if (swap_xy) {
+		y = TOUCHKIT_GET_X(touchkit->data);
+		x = TOUCHKIT_GET_Y(touchkit->data);
+	} else {
+		x = TOUCHKIT_GET_X(touchkit->data);
+		y = TOUCHKIT_GET_Y(touchkit->data);
+	}
+
 	input_regs(&touchkit->input, regs);
 	input_report_key(&touchkit->input, BTN_TOUCH,
 	                 TOUCHKIT_GET_TOUCHED(touchkit->data));
-	input_report_abs(&touchkit->input, ABS_X,
-	                 TOUCHKIT_GET_X(touchkit->data));
-	input_report_abs(&touchkit->input, ABS_Y,
-	                 TOUCHKIT_GET_Y(touchkit->data));
+	input_report_abs(&touchkit->input, ABS_X, x);
+	input_report_abs(&touchkit->input, ABS_Y, y);
 	input_sync(&touchkit->input);
 
 exit:
@@ -141,7 +152,7 @@
 	struct touchkit_usb *touchkit = input->private;
 
 	if (!--touchkit->open)
-		usb_unlink_urb(touchkit->irq);
+		usb_kill_urb(touchkit->irq);
 }
 
 static int touchkit_alloc_buffers(struct usb_device *udev,
@@ -276,7 +287,7 @@
 	dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__);
 	usb_set_intfdata(intf, NULL);
 	input_unregister_device(&touchkit->input);
-	usb_unlink_urb(touchkit->irq);
+	usb_kill_urb(touchkit->irq);
 	usb_free_urb(touchkit->irq);
 	touchkit_free_buffers(interface_to_usbdev(intf), touchkit);
 	kfree(touchkit);
diff -Nru a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
--- a/drivers/usb/input/usbkbd.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/input/usbkbd.c	2004-12-24 13:37:29 -08:00
@@ -196,7 +196,7 @@
 	struct usb_kbd *kbd = dev->private;
 
 	if (!--kbd->open)
-		usb_unlink_urb(kbd->irq);
+		usb_kill_urb(kbd->irq);
 }
 
 static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
@@ -343,7 +343,7 @@
 	
 	usb_set_intfdata(intf, NULL);
 	if (kbd) {
-		usb_unlink_urb(kbd->irq);
+		usb_kill_urb(kbd->irq);
 		input_unregister_device(&kbd->dev);
 		usb_kbd_free_mem(interface_to_usbdev(intf), kbd);
 		kfree(kbd);
diff -Nru a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
--- a/drivers/usb/input/usbmouse.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/input/usbmouse.c	2004-12-24 13:37:19 -08:00
@@ -118,7 +118,7 @@
 	struct usb_mouse *mouse = dev->private;
 
 	if (!--mouse->open)
-		usb_unlink_urb(mouse->irq);
+		usb_kill_urb(mouse->irq);
 }
 
 static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id)
@@ -223,7 +223,7 @@
 	
 	usb_set_intfdata(intf, NULL);
 	if (mouse) {
-		usb_unlink_urb(mouse->irq);
+		usb_kill_urb(mouse->irq);
 		input_unregister_device(&mouse->dev);
 		usb_free_urb(mouse->irq);
 		usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma);
diff -Nru a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c
--- a/drivers/usb/input/wacom.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/input/wacom.c	2004-12-24 13:36:17 -08:00
@@ -608,7 +608,7 @@
 	struct wacom *wacom = dev->private;
 
 	if (!--wacom->open)
-		usb_unlink_urb(wacom->irq);
+		usb_kill_urb(wacom->irq);
 }
 
 static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
@@ -729,7 +729,7 @@
 
 	usb_set_intfdata(intf, NULL);
 	if (wacom) {
-		usb_unlink_urb(wacom->irq);
+		usb_kill_urb(wacom->irq);
 		input_unregister_device(&wacom->dev);
 		usb_free_urb(wacom->irq);
 		usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma);
diff -Nru a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
--- a/drivers/usb/input/xpad.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/usb/input/xpad.c	2004-12-24 13:36:49 -08:00
@@ -214,7 +214,7 @@
 	struct usb_xpad *xpad = dev->private;
 	
 	if (!--xpad->open_count)
-		usb_unlink_urb(xpad->irq_in);
+		usb_kill_urb(xpad->irq_in);
 }
 
 static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
@@ -325,7 +325,7 @@
 	
 	usb_set_intfdata(intf, NULL);
 	if (xpad) {
-		usb_unlink_urb(xpad->irq_in);
+		usb_kill_urb(xpad->irq_in);
 		input_unregister_device(&xpad->dev);
 		usb_free_urb(xpad->irq_in);
 		usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
diff -Nru a/drivers/usb/media/Kconfig b/drivers/usb/media/Kconfig
--- a/drivers/usb/media/Kconfig	2004-12-24 13:36:16 -08:00
+++ b/drivers/usb/media/Kconfig	2004-12-24 13:36:16 -08:00
@@ -123,11 +123,11 @@
 	  module will be called se401.
 
 config USB_SN9C102
-	tristate "USB SN9C10[12] PC Camera Controller support"
+	tristate "USB SN9C10x PC Camera Controller support"
 	depends on USB && VIDEO_DEV
 	---help---
-	  Say Y here if you want support for cameras based on SONiX SN9C101
-	  or SN9C102 PC Camera Controllers.
+	  Say Y here if you want support for cameras based on SONiX SN9C101,
+	  SN9C102 or SN9C103 PC Camera Controllers.
 
 	  See <file:Documentation/usb/sn9c102.txt> for more informations.
 
diff -Nru a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c
--- a/drivers/usb/media/dabusb.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/usb/media/dabusb.c	2004-12-24 13:36:59 -08:00
@@ -109,16 +109,13 @@
 static int dabusb_cancel_queue (pdabusb_t s, struct list_head *q)
 {
 	unsigned long flags;
-	struct list_head *p;
 	pbuff_t b;
 
 	dbg("dabusb_cancel_queue");
 
 	spin_lock_irqsave (&s->lock, flags);
 
-	for (p = q->next; p != q; p = p->next) {
-		b = list_entry (p, buff_t, buff_list);
-
+	list_for_each_entry(b, q, buff_list) {
 #ifdef DEBUG
 		dump_urb(b->purb);
 #endif
@@ -598,7 +595,7 @@
 		if (file->f_flags & O_NONBLOCK) {
 			return -EBUSY;
 		}
-		schedule_timeout (HZ / 2);
+		msleep_interruptible(500);
 
 		if (signal_pending (current)) {
 			return -EAGAIN;
diff -Nru a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c
--- a/drivers/usb/media/konicawc.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/usb/media/konicawc.c	2004-12-24 13:36:16 -08:00
@@ -474,13 +474,8 @@
 
 	/* Unschedule all of the iso td's */
 	for (i=0; i < USBVIDEO_NUMSBUF; i++) {
-		j = usb_unlink_urb(uvd->sbuf[i].urb);
-		if (j < 0)
-			err("usb_unlink_urb() error %d.", j);
-
-		j = usb_unlink_urb(cam->sts_urb[i]);
-		if (j < 0)
-			err("usb_unlink_urb() error %d.", j);
+		usb_kill_urb(uvd->sbuf[i].urb);
+		usb_kill_urb(cam->sts_urb[i]);
 	}
 
 	if (!uvd->remove_pending) {
diff -Nru a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
--- a/drivers/usb/media/ov511.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/usb/media/ov511.c	2004-12-24 13:36:33 -08:00
@@ -183,7 +183,7 @@
 module_param(backlight, int, 0);
 MODULE_PARM_DESC(backlight, "For objects that are lit from behind");
 static int num_uv;
-module_param_array(unit_video, int, num_uv, 0);
+module_param_array(unit_video, int, &num_uv, 0);
 MODULE_PARM_DESC(unit_video,
   "Force use of specific minor number(s). 0 is not allowed.");
 module_param(remove_zeros, int, 0);
@@ -324,21 +324,6 @@
 /**********************************************************************
  * Memory management
  **********************************************************************/
-
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long
-kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *
 rvmalloc(unsigned long size)
 {
@@ -3830,7 +3815,7 @@
 	/* Unschedule all of the iso td's */
 	for (n = OV511_NUMSBUF - 1; n >= 0; n--) {
 		if (ov->sbuf[n].urb) {
-			usb_unlink_urb(ov->sbuf[n].urb);
+			usb_kill_urb(ov->sbuf[n].urb);
 			usb_free_urb(ov->sbuf[n].urb);
 			ov->sbuf[n].urb = NULL;
 		}
@@ -4771,9 +4756,8 @@
 
 	pos = (unsigned long)ov->fbuf;
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
-		if (remap_page_range(vma, start, page, PAGE_SIZE,
-				     PAGE_SHARED)) {
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up(&ov->lock);
 			return -EAGAIN;
 		}
diff -Nru a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c
--- a/drivers/usb/media/se401.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/usb/media/se401.c	2004-12-24 13:36:33 -08:00
@@ -65,20 +65,6 @@
  * Memory management
  *
  **********************************************************************/
-
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *rvmalloc(unsigned long size)
 {
 	void *mem;
@@ -514,7 +500,7 @@
 	se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 0, NULL, 0);
 
 	for (i=0; i<SE401_NUMSBUF; i++) if (se401->urb[i]) {
-		usb_unlink_urb(se401->urb[i]);
+		usb_kill_urb(se401->urb[i]);
 		usb_free_urb(se401->urb[i]);
 		se401->urb[i]=NULL;
 		kfree(se401->sbuf[i].data);
@@ -883,7 +869,7 @@
         se401->dev = NULL;
 
 	for (i=0; i<SE401_NUMSBUF; i++) if (se401->urb[i]) {
-		usb_unlink_urb(se401->urb[i]);
+		usb_kill_urb(se401->urb[i]);
 		usb_free_urb(se401->urb[i]);
 		se401->urb[i] = NULL;
 		kfree(se401->sbuf[i].data);
@@ -892,7 +878,7 @@
 		kfree(se401->scratch[i].data);
 	}
 	if (se401->inturb) {
-		usb_unlink_urb(se401->inturb);
+		usb_kill_urb(se401->inturb);
 		usb_free_urb(se401->inturb);
 	}
         info("%s disconnected", se401->camera_name);
@@ -1182,8 +1168,8 @@
 	}
 	pos = (unsigned long)se401->fbuf;
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
-		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up(&se401->lock);
 			return -EAGAIN;
 		}
diff -Nru a/drivers/usb/media/sn9c102.h b/drivers/usb/media/sn9c102.h
--- a/drivers/usb/media/sn9c102.h	2004-12-24 13:36:49 -08:00
+++ b/drivers/usb/media/sn9c102.h	2004-12-24 13:36:49 -08:00
@@ -1,5 +1,5 @@
 /***************************************************************************
- * V4L2 driver for SN9C10[12] PC Camera Controllers                        *
+ * V4L2 driver for SN9C10x PC Camera Controllers                           *
  *                                                                         *
  * Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>       *
  *                                                                         *
@@ -27,6 +27,7 @@
 #include <linux/device.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
+#include <linux/time.h>
 #include <linux/wait.h>
 #include <linux/types.h>
 #include <linux/param.h>
@@ -45,19 +46,26 @@
 #define SN9C102_URBS              2
 #define SN9C102_ISO_PACKETS       7
 #define SN9C102_ALTERNATE_SETTING 8
-#define SN9C102_CTRL_TIMEOUT      10*HZ
+#define SN9C102_URB_TIMEOUT       msecs_to_jiffies(3)
+#define SN9C102_CTRL_TIMEOUT      msecs_to_jiffies(100)
 
 /*****************************************************************************/
 
-#define SN9C102_MODULE_NAME  "V4L2 driver for SN9C10[12] PC Camera Controllers"
+#define SN9C102_MODULE_NAME     "V4L2 driver for SN9C10x PC Camera Controllers"
 #define SN9C102_MODULE_AUTHOR   "(C) 2004 Luca Risolia"
 #define SN9C102_AUTHOR_EMAIL    "<luca.risolia@studio.unibo.it>"
 #define SN9C102_MODULE_LICENSE  "GPL"
-#define SN9C102_MODULE_VERSION  "1:1.08"
-#define SN9C102_MODULE_VERSION_CODE  KERNEL_VERSION(1, 0, 8)
+#define SN9C102_MODULE_VERSION  "1:1.19"
+#define SN9C102_MODULE_VERSION_CODE  KERNEL_VERSION(1, 0, 19)
 
-SN9C102_ID_TABLE;
-SN9C102_SENSOR_TABLE;
+enum sn9c102_bridge {
+	BRIDGE_SN9C101 = 0x01,
+	BRIDGE_SN9C102 = 0x02,
+	BRIDGE_SN9C103 = 0x04,
+};
+
+SN9C102_ID_TABLE
+SN9C102_SENSOR_TABLE
 
 enum sn9c102_frame_state {
 	F_UNUSED,
@@ -94,7 +102,7 @@
 };
 
 struct sn9c102_sysfs_attr {
-	u8 reg, val, i2c_reg, i2c_val;
+	u8 reg, i2c_reg;
 };
 
 static DECLARE_MUTEX(sn9c102_sysfs_lock);
@@ -105,6 +113,7 @@
 
 	struct video_device* v4ldev;
 
+	enum sn9c102_bridge bridge;
 	struct sn9c102_sensor* sensor;
 
 	struct usb_device* usbdev;
@@ -114,10 +123,12 @@
 
 	struct sn9c102_frame_t *frame_current, frame[SN9C102_MAX_FRAMES];
 	struct list_head inqueue, outqueue;
-	u32 frame_count, nbuffers;
+	u32 frame_count, nbuffers, nreadbuffers;
 
 	enum sn9c102_io_method io;
 	enum sn9c102_stream_state stream;
+
+	struct v4l2_jpegcompression compression;
 
 	struct sn9c102_sysfs_attr sysfs;
 	u16 reg[32];
diff -Nru a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
--- a/drivers/usb/media/sn9c102_core.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/media/sn9c102_core.c	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,5 @@
 /***************************************************************************
- * V4L2 driver for SN9C10[12] PC Camera Controllers                        *
+ * V4L2 driver for SN9C10x PC Camera Controllers                           *
  *                                                                         *
  * Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>       *
  *                                                                         *
@@ -28,7 +28,6 @@
 #include <linux/string.h>
 #include <linux/device.h>
 #include <linux/fs.h>
-#include <linux/time.h>
 #include <linux/delay.h>
 #include <linux/stddef.h>
 #include <linux/compiler.h>
@@ -53,8 +52,7 @@
 MODULE_LICENSE(SN9C102_MODULE_LICENSE);
 
 static short video_nr[] = {[0 ... SN9C102_MAX_DEVICES-1] = -1};
-static unsigned int nv;
-module_param_array(video_nr, short, nv, 0444);
+module_param_array(video_nr, short, NULL, 0444);
 MODULE_PARM_DESC(video_nr,
                  "\n<-1|n[,...]> Specify V4L2 minor mode number."
                  "\n -1 = use next available (default)"
@@ -102,17 +100,6 @@
 
 /*****************************************************************************/
 
-static inline unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long)page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1);
-	ret = __pa(kva);
-	return ret;
-}
-
-
 static void* rvmalloc(size_t size)
 {
 	void* mem;
@@ -169,15 +156,15 @@
 
 	cam->nbuffers = count;
 	while (cam->nbuffers > 0) {
-		if ((buff = rvmalloc(cam->nbuffers * imagesize)))
+		if ((buff = rvmalloc(cam->nbuffers * PAGE_ALIGN(imagesize))))
 			break;
 		cam->nbuffers--;
 	}
 
 	for (i = 0; i < cam->nbuffers; i++) {
-		cam->frame[i].bufmem = buff + i*imagesize;
+		cam->frame[i].bufmem = buff + i*PAGE_ALIGN(imagesize);
 		cam->frame[i].buf.index = i;
-		cam->frame[i].buf.m.offset = i*imagesize;
+		cam->frame[i].buf.m.offset = i*PAGE_ALIGN(imagesize);
 		cam->frame[i].buf.length = imagesize;
 		cam->frame[i].buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 		cam->frame[i].buf.sequence = 0;
@@ -388,7 +375,7 @@
 	data[4] = data3;
 	data[5] = data4;
 	data[6] = data5;
-	data[7] = 0x10;
+	data[7] = 0x14;
 	res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
 	                      0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
 	if (res < 0)
@@ -400,7 +387,7 @@
 	if (err)
 		DBG(3, "I2C write failed for %s image sensor", sensor->name)
 
-	PDBGG("I2C write: %u bytes, data0 = 0x%02X, data1 = 0x%02X, "
+	PDBGG("I2C raw write: %u bytes, data0 = 0x%02X, data1 = 0x%02X, "
 	      "data2 = 0x%02X, data3 = 0x%02X, data4 = 0x%02X, data5 = 0x%02X",
 	      n, data0, data1, data2, data3, data4, data5)
 
@@ -437,7 +424,8 @@
 
 /*****************************************************************************/
 
-static void* sn9c102_find_sof_header(void* mem, size_t len)
+static void*
+sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len)
 {
 	size_t soflen = sizeof(sn9c102_sof_header_t), i;
 	u8 j, n = sizeof(sn9c102_sof_header) / soflen;
@@ -453,11 +441,15 @@
 }
 
 
-static void* sn9c102_find_eof_header(void* mem, size_t len)
+static void*
+sn9c102_find_eof_header(struct sn9c102_device* cam, void* mem, size_t len)
 {
 	size_t eoflen = sizeof(sn9c102_eof_header_t), i;
 	unsigned j, n = sizeof(sn9c102_eof_header) / eoflen;
 
+	if (cam->sensor->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X)
+		return NULL; /* EOF header does not exist in compressed data */
+
 	for (i = 0; (len >= eoflen) && (i <= len - eoflen); i++)
 		for (j = 0; j < n; j++)
 			if (!memcmp(mem + i, sn9c102_eof_header[j], eoflen))
@@ -522,9 +514,9 @@
 		*/
 
 redo:
-		sof = sn9c102_find_sof_header(pos, len);
+		sof = sn9c102_find_sof_header(cam, pos, len);
 		if (!sof) {
-			eof = sn9c102_find_eof_header(pos, len);
+			eof = sn9c102_find_eof_header(cam, pos, len);
 			if ((*f)->state == F_GRABBING) {
 end_of_frame:
 				img = len;
@@ -552,7 +544,9 @@
 
 				(*f)->buf.bytesused += img;
 
-				if ((*f)->buf.bytesused == (*f)->buf.length) {
+				if ((*f)->buf.bytesused == (*f)->buf.length ||
+				    (cam->sensor->pix_format.pixelformat ==
+				                V4L2_PIX_FMT_SN9C10X && eof)) {
 					u32 b = (*f)->buf.bytesused;
 					(*f)->state = F_DONE;
 					(*f)->buf.sequence= ++cam->frame_count;
@@ -605,14 +599,20 @@
 				goto redo;
 
 		} else if ((*f)->state == F_GRABBING) {
-			eof = sn9c102_find_eof_header(pos, len);
+			eof = sn9c102_find_eof_header(cam, pos, len);
 			if (eof && eof < sof)
 				goto end_of_frame; /* (1) */
 			else {
-				DBG(3, "SOF before expected EOF after %lu "
-				       "bytes of image data", 
-				    (unsigned long)((*f)->buf.bytesused))
-				goto start_of_frame;
+				if (cam->sensor->pix_format.pixelformat ==
+				    V4L2_PIX_FMT_SN9C10X) {
+					eof = sof-sizeof(sn9c102_sof_header_t);
+					goto end_of_frame;
+				} else {
+					DBG(3, "SOF before expected EOF after "
+					       "%lu bytes of image data", 
+					  (unsigned long)((*f)->buf.bytesused))
+					goto start_of_frame;
+				}
 			}
 		}
 	}
@@ -634,7 +634,7 @@
 	struct usb_device *udev = cam->usbdev;
 	struct urb* urb;
 	const unsigned int wMaxPacketSize[] = {0, 128, 256, 384, 512,
-                                               680, 800, 900, 1023};
+	                                       680, 800, 900, 1023};
 	const unsigned int psz = wMaxPacketSize[SN9C102_ALTERNATE_SETTING];
 	s8 i, j;
 	int err = 0;
@@ -736,6 +736,29 @@
 	return err;
 }
 
+
+int sn9c102_stream_interrupt(struct sn9c102_device* cam)
+{
+	int err = 0;
+
+	cam->stream = STREAM_INTERRUPT;
+	err = wait_event_timeout(cam->wait_stream,
+	                         (cam->stream == STREAM_OFF) ||
+	                         (cam->state & DEV_DISCONNECTED),
+	                         SN9C102_URB_TIMEOUT);
+	if (err) {
+		cam->state |= DEV_MISCONFIGURED;
+		DBG(1, "The camera is misconfigured. To use "
+		       "it, close and open /dev/video%d "
+		       "again.", cam->v4ldev->minor)
+		return err;
+	}
+	if (cam->state & DEV_DISCONNECTED)
+		return -ENODEV;
+
+	return 0;
+}
+
 /*****************************************************************************/
 
 static u8 sn9c102_strtou8(const char* buff, size_t len, ssize_t* count)
@@ -965,6 +988,11 @@
 		return -ENODEV;
 	}
 
+	if (cam->sensor->slave_read_id == SN9C102_I2C_SLAVEID_UNAVAILABLE) {
+		up(&sn9c102_sysfs_lock);
+		return -ENOSYS;
+	}
+
 	if ((val = sn9c102_i2c_read(cam, cam->sysfs.i2c_reg)) < 0) {
 		up(&sn9c102_sysfs_lock);
 		return -EIO;
@@ -1022,15 +1050,79 @@
 static ssize_t
 sn9c102_store_green(struct class_device* cd, const char* buf, size_t len)
 {
+	struct sn9c102_device* cam;
+	enum sn9c102_bridge bridge;
 	ssize_t res = 0;
 	u8 value;
 	ssize_t count;
 
+	if (down_interruptible(&sn9c102_sysfs_lock))
+		return -ERESTARTSYS;
+
+	cam = video_get_drvdata(to_video_device(cd));
+	if (!cam) {
+		up(&sn9c102_sysfs_lock);
+		return -ENODEV;
+	}
+
+	bridge = cam->bridge;
+
+	up(&sn9c102_sysfs_lock);
+
 	value = sn9c102_strtou8(buf, len, &count);
-	if (!count || value > 0x0f)
+	if (!count)
 		return -EINVAL;
 
-	if ((res = sn9c102_store_reg(cd, "0x11", 4)) >= 0)
+	switch (bridge) {
+	case BRIDGE_SN9C101:
+	case BRIDGE_SN9C102:
+		if (value > 0x0f)
+			return -EINVAL;
+		if ((res = sn9c102_store_reg(cd, "0x11", 4)) >= 0)
+			res = sn9c102_store_val(cd, buf, len);
+		break;
+	case BRIDGE_SN9C103:
+		if (value > 0x7f)
+			return -EINVAL;
+		if ((res = sn9c102_store_reg(cd, "0x04", 4)) >= 0)
+			res = sn9c102_store_val(cd, buf, len);
+		break;
+	}
+
+	return res;
+}
+
+
+static ssize_t
+sn9c102_store_blue(struct class_device* cd, const char* buf, size_t len)
+{
+	ssize_t res = 0;
+	u8 value;
+	ssize_t count;
+
+	value = sn9c102_strtou8(buf, len, &count);
+	if (!count || value > 0x7f)
+		return -EINVAL;
+
+	if ((res = sn9c102_store_reg(cd, "0x06", 4)) >= 0)
+		res = sn9c102_store_val(cd, buf, len);
+
+	return res;
+}
+
+
+static ssize_t
+sn9c102_store_red(struct class_device* cd, const char* buf, size_t len)
+{
+	ssize_t res = 0;
+	u8 value;
+	ssize_t count;
+
+	value = sn9c102_strtou8(buf, len, &count);
+	if (!count || value > 0x7f)
+		return -EINVAL;
+
+	if ((res = sn9c102_store_reg(cd, "0x05", 4)) >= 0)
 		res = sn9c102_store_val(cd, buf, len);
 
 	return res;
@@ -1046,6 +1138,8 @@
 static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
                          sn9c102_show_i2c_val, sn9c102_store_i2c_val);
 static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green);
+static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue);
+static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red);
 
 
 static void sn9c102_create_sysfs(struct sn9c102_device* cam)
@@ -1054,8 +1148,14 @@
 
 	video_device_create_file(v4ldev, &class_device_attr_reg);
 	video_device_create_file(v4ldev, &class_device_attr_val);
-	video_device_create_file(v4ldev, &class_device_attr_green);
-	if (cam->sensor->slave_write_id && cam->sensor->slave_read_id) {
+	if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102)
+		video_device_create_file(v4ldev, &class_device_attr_green);
+	else if (cam->bridge == BRIDGE_SN9C103) {
+		video_device_create_file(v4ldev, &class_device_attr_blue);
+		video_device_create_file(v4ldev, &class_device_attr_red);
+	}
+	if (cam->sensor->slave_write_id != SN9C102_I2C_SLAVEID_UNAVAILABLE ||
+	    cam->sensor->slave_read_id != SN9C102_I2C_SLAVEID_UNAVAILABLE) {
 		video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
 		video_device_create_file(v4ldev, &class_device_attr_i2c_val);
 	}
@@ -1063,6 +1163,35 @@
 
 /*****************************************************************************/
 
+static int
+sn9c102_set_format(struct sn9c102_device* cam, struct v4l2_pix_format* fmt)
+{
+	int err = 0;
+
+	if (fmt->pixelformat == V4L2_PIX_FMT_SN9C10X)
+		err += sn9c102_write_reg(cam, cam->reg[0x18] | 0x80, 0x18);
+	else
+		err += sn9c102_write_reg(cam, cam->reg[0x18] & 0x7f, 0x18);
+
+	return err ? -EIO : 0;
+}
+
+
+static int
+sn9c102_set_compression(struct sn9c102_device* cam,
+                        struct v4l2_jpegcompression* compression)
+{
+	int err = 0;
+
+	if (compression->quality == 0)
+		err += sn9c102_write_reg(cam, cam->reg[0x17] | 0x01, 0x17);
+	else if (compression->quality == 1)
+		err += sn9c102_write_reg(cam, cam->reg[0x17] & 0xfe, 0x17);
+
+	return err ? -EIO : 0;
+}
+
+
 static int sn9c102_set_scale(struct sn9c102_device* cam, u8 scale)
 {
 	u8 r = 0;
@@ -1092,21 +1221,13 @@
 	u8 h_start = (u8)(rect->left - s->cropcap.bounds.left),
 	   v_start = (u8)(rect->top - s->cropcap.bounds.top),
 	   h_size = (u8)(rect->width / 16),
-	   v_size = (u8)(rect->height / 16),
-	   ae_strx = 0x00,
-	   ae_stry = 0x00,
-	   ae_endx = h_size / 2,
-	   ae_endy = v_size / 2;
+	   v_size = (u8)(rect->height / 16);
 	int err = 0;
 
 	err += sn9c102_write_reg(cam, h_start, 0x12);
 	err += sn9c102_write_reg(cam, v_start, 0x13);
 	err += sn9c102_write_reg(cam, h_size, 0x15);
 	err += sn9c102_write_reg(cam, v_size, 0x16);
-	err += sn9c102_write_reg(cam, ae_strx, 0x1c);
-	err += sn9c102_write_reg(cam, ae_stry, 0x1d);
-	err += sn9c102_write_reg(cam, ae_endx, 0x1e);
-	err += sn9c102_write_reg(cam, ae_endy, 0x1f);
 	if (err)
 		return -EIO;
 
@@ -1148,6 +1269,20 @@
 		}
 	}
 
+	if (!(cam->state & DEV_INITIALIZED))
+		cam->compression.quality =  cam->reg[0x17] & 0x01 ? 0 : 1;
+	else
+		err += sn9c102_set_compression(cam, &cam->compression);
+	err += sn9c102_set_format(cam, &s->pix_format);
+	if (err)
+		return err;
+
+	if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X)
+		DBG(3, "Compressed video format is active, quality %d", 
+		    cam->compression.quality)
+	else
+		DBG(3, "Uncompressed video format is active")
+
 	if (s->set_crop)
 		if ((err = s->set_crop(cam, rect))) {
 			DBG(3, "set_crop() failed")
@@ -1163,9 +1298,12 @@
 				ctrl.value = qctrl[i].default_value;
 				err = s->set_ctrl(cam, &ctrl);
 				if (err) {
-					DBG(3, "Set control failed")
+					DBG(3, "Set %s control failed",
+					    s->qctrl[i].name)
 					return err;
 				}
+				DBG(3, "Image sensor supports '%s' control",
+				    s->qctrl[i].name)
 			}
 	}
 
@@ -1174,6 +1312,7 @@
 		spin_lock_init(&cam->queue_lock);
 		init_waitqueue_head(&cam->wait_frame);
 		init_waitqueue_head(&cam->wait_stream);
+		cam->nreadbuffers = 2;
 		memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl));
 		memcpy(&(s->_rect), &(s->cropcap.defrect), 
 		       sizeof(struct v4l2_rect));
@@ -1331,7 +1470,7 @@
 	}
 
 	if (cam->io == IO_NONE) {
-		if (!sn9c102_request_buffers(cam, 2)) {
+		if (!sn9c102_request_buffers(cam, cam->nreadbuffers)) {
 			DBG(1, "read() failed, not enough memory")
 			up(&cam->fileop_sem);
 			return -ENOMEM;
@@ -1375,8 +1514,8 @@
 
 	sn9c102_queue_unusedframes(cam);
 
-	if (count > f->buf.length)
-		count = f->buf.length;
+	if (count > f->buf.bytesused)
+		count = f->buf.bytesused;
 
 	if (copy_to_user(buf, f->bufmem, count)) {
 		up(&cam->fileop_sem);
@@ -1497,11 +1636,15 @@
 		return -EINVAL;
 	}
 
+	/* VM_IO is eventually going to replace PageReserved altogether */
+	vma->vm_flags |= VM_IO;
+	vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */
+
 	pos = (unsigned long)cam->frame[i].bufmem;
 	while (size > 0) { /* size is page-aligned */
-		page = kvirt_to_pa(pos);
-		if (remap_page_range(vma, start, page, PAGE_SIZE, 
-		                     vma->vm_page_prot)) {
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page, PAGE_SIZE,
+		                    vma->vm_page_prot)) {
 			up(&cam->fileop_sem);
 			return -EAGAIN;
 		}
@@ -1511,8 +1654,6 @@
 	}
 
 	vma->vm_ops = &sn9c102_vm_ops;
-	vma->vm_flags &= ~VM_IO; /* not I/O memory */
-	vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */
 	vma->vm_private_data = &cam->frame[i];
 
 	sn9c102_vm_open(vma);
@@ -1537,11 +1678,14 @@
 			.version = SN9C102_MODULE_VERSION_CODE,
 			.capabilities = V4L2_CAP_VIDEO_CAPTURE | 
 			                V4L2_CAP_READWRITE |
-		 	                V4L2_CAP_STREAMING,
+			                V4L2_CAP_STREAMING,
 		};
 
 		strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
-		strlcpy(cap.bus_info, cam->dev.bus_id, sizeof(cap.bus_info));
+		if (usb_make_path(cam->usbdev, cap.bus_info,
+		    sizeof(cap.bus_info)) < 0)
+			strlcpy(cap.bus_info, cam->dev.bus_id,
+			        sizeof(cap.bus_info));
 
 		if (copy_to_user(arg, &cap, sizeof(cap)))
 			return -EFAULT;
@@ -1636,16 +1780,24 @@
 		if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
 			return -EFAULT;
 
-		if ((err = s->set_ctrl(cam, &ctrl)))
-			return err;
-
 		n = sizeof(s->qctrl) / sizeof(s->qctrl[0]);
 		for (i = 0; i < n; i++)
 			if (ctrl.id == s->qctrl[i].id) {
-				s->_qctrl[i].default_value = ctrl.value;
+				if (ctrl.value < s->qctrl[i].minimum ||
+				    ctrl.value > s->qctrl[i].maximum)
+					return -ERANGE;
+				ctrl.value -= ctrl.value % s->qctrl[i].step;
 				break;
 			}
 
+		if ((err = s->set_ctrl(cam, &ctrl)))
+			return err;
+
+		s->_qctrl[i].default_value = ctrl.value;
+
+		PDBGG("VIDIOC_S_CTRL: id %lu, value %lu",
+		      (unsigned long)ctrl.id, (unsigned long)ctrl.value)
+
 		return 0;
 	}
 
@@ -1742,22 +1894,9 @@
 		} else
 			scale = 1;
 
-		if (cam->stream == STREAM_ON) {
-			cam->stream = STREAM_INTERRUPT;
-			err = wait_event_interruptible
-			      ( cam->wait_stream, 
-			        (cam->stream == STREAM_OFF) ||
-			        (cam->state & DEV_DISCONNECTED) );
-			if (err) {
-				cam->state |= DEV_MISCONFIGURED;
-				DBG(1, "The camera is misconfigured. To use "
-				       "it, close and open /dev/video%d "
-				       "again.", cam->v4ldev->minor)
+		if (cam->stream == STREAM_ON)
+			if ((err = sn9c102_stream_interrupt(cam)))
 				return err;
-			}
-			if (cam->state & DEV_DISCONNECTED)
-				return -ENODEV;
-		}
 
 		if (copy_to_user(arg, &crop, sizeof(crop))) {
 			cam->stream = stream;
@@ -1776,7 +1915,7 @@
 			DBG(1, "VIDIOC_S_CROP failed because of hardware "
 			       "problems. To use the camera, close and open "
 			       "/dev/video%d again.", cam->v4ldev->minor)
-			return err;
+			return -EIO;
 		}
 
 		s->pix_format.width = rect->width/scale;
@@ -1798,20 +1937,23 @@
 
 	case VIDIOC_ENUM_FMT:
 	{
-		struct sn9c102_sensor* s = cam->sensor;
 		struct v4l2_fmtdesc fmtd;
 
 		if (copy_from_user(&fmtd, arg, sizeof(fmtd)))
 			return -EFAULT;
 
-		if (fmtd.index != 0)
+		if (fmtd.index == 0) {
+			strcpy(fmtd.description, "bayer rgb");
+			fmtd.pixelformat = V4L2_PIX_FMT_SBGGR8;
+		} else if (fmtd.index == 1) {
+			strcpy(fmtd.description, "compressed");
+			fmtd.pixelformat = V4L2_PIX_FMT_SN9C10X;
+			fmtd.flags = V4L2_FMT_FLAG_COMPRESSED;
+		} else
 			return -EINVAL;
 
-		memset(&fmtd, 0, sizeof(fmtd));
-
 		fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-		strcpy(fmtd.description, "bayer rgb");
-		fmtd.pixelformat = s->pix_format.pixelformat;
+		memset(&fmtd.reserved, 0, sizeof(fmtd.reserved));
 
 		if (copy_to_user(arg, &fmtd, sizeof(fmtd)))
 			return -EFAULT;
@@ -1830,8 +1972,9 @@
 		if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 			return -EINVAL;
 
-		pfmt->bytesperline = (pfmt->width * pfmt->priv) / 8;
-		pfmt->sizeimage = pfmt->height * pfmt->bytesperline;
+		pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X)
+		                     ? 0 : (pfmt->width * pfmt->priv) / 8;
+		pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
 		pfmt->field = V4L2_FIELD_NONE;
 		memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
 
@@ -1900,15 +2043,21 @@
 		pix->width = rect.width / scale;
 		pix->height = rect.height / scale;
 
-		pix->pixelformat = pfmt->pixelformat;
+		if (pix->pixelformat != V4L2_PIX_FMT_SN9C10X &&
+		    pix->pixelformat != V4L2_PIX_FMT_SBGGR8)
+			pix->pixelformat = pfmt->pixelformat;
 		pix->priv = pfmt->priv; /* bpp */
 		pix->colorspace = pfmt->colorspace;
-		pix->bytesperline = (pix->width * pix->priv) / 8;
-		pix->sizeimage = pix->height * pix->bytesperline;
+		pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
+		                    ? 0 : (pix->width * pix->priv) / 8;
+		pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
 		pix->field = V4L2_FIELD_NONE;
 
-		if (cmd == VIDIOC_TRY_FMT)
+		if (cmd == VIDIOC_TRY_FMT) {
+			if (copy_to_user(arg, &format, sizeof(format)))
+				return -EFAULT;
 			return 0;
+		}
 
 		for (i = 0; i < cam->nbuffers; i++)
 			if (cam->frame[i].vma_use_count) {
@@ -1917,22 +2066,9 @@
 				return -EINVAL;
 			}
 
-		if (cam->stream == STREAM_ON) {
-			cam->stream = STREAM_INTERRUPT;
-			err = wait_event_interruptible
-			      ( cam->wait_stream, 
-			        (cam->stream == STREAM_OFF) ||
-			        (cam->state & DEV_DISCONNECTED) );
-			if (err) {
-				cam->state |= DEV_MISCONFIGURED;
-				DBG(1, "The camera is misconfigured. To use "
-				       "it, close and open /dev/video%d "
-				       "again.", cam->v4ldev->minor)
+		if (cam->stream == STREAM_ON)
+			if ((err = sn9c102_stream_interrupt(cam)))
 				return err;
-			}
-			if (cam->state & DEV_DISCONNECTED)
-				return -ENODEV;
-		}
 
 		if (copy_to_user(arg, &format, sizeof(format))) {
 			cam->stream = stream;
@@ -1941,7 +2077,8 @@
 
 		sn9c102_release_buffers(cam);
 
-		err = sn9c102_set_crop(cam, &rect);
+		err += sn9c102_set_format(cam, pix);
+		err += sn9c102_set_crop(cam, &rect);
 		if (s->set_crop)
 			err += s->set_crop(cam, &rect);
 		err += sn9c102_set_scale(cam, scale);
@@ -1951,7 +2088,7 @@
 			DBG(1, "VIDIOC_S_FMT failed because of hardware "
 			       "problems. To use the camera, close and open "
 			       "/dev/video%d again.", cam->v4ldev->minor)
-			return err;
+			return -EIO;
 		}
 
 		memcpy(pfmt, pix, sizeof(*pix));
@@ -1970,6 +2107,47 @@
 		return 0;
 	}
 
+	case VIDIOC_G_JPEGCOMP:
+	{
+		if (copy_to_user(arg, &cam->compression,
+		                 sizeof(cam->compression)))
+			return -EFAULT;
+
+		return 0;
+	}
+
+	case VIDIOC_S_JPEGCOMP:
+	{
+		struct v4l2_jpegcompression jc;
+		const enum sn9c102_stream_state stream = cam->stream;
+		int err = 0;
+
+		if (copy_from_user(&jc, arg, sizeof(jc)))
+			return -EFAULT;
+
+		if (jc.quality != 0 && jc.quality != 1)
+			return -EINVAL;
+
+		if (cam->stream == STREAM_ON)
+			if ((err = sn9c102_stream_interrupt(cam)))
+				return err;
+
+		err += sn9c102_set_compression(cam, &jc);
+		if (err) { /* atomic, no rollback in ioctl() */
+			cam->state |= DEV_MISCONFIGURED;
+			DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
+			       "problems. To use the camera, close and open "
+			       "/dev/video%d again.", cam->v4ldev->minor)
+			return -EIO;
+		}
+
+		cam->compression.quality = jc.quality;
+
+		cam->stream = stream;
+
+		return 0;
+	}
+
 	case VIDIOC_REQBUFS:
 	{
 		struct v4l2_requestbuffers rb;
@@ -1996,22 +2174,9 @@
 				return -EINVAL;
 			}
 
-		if (cam->stream == STREAM_ON) {
-			cam->stream = STREAM_INTERRUPT;
-			err = wait_event_interruptible
-			      ( cam->wait_stream, 
-			        (cam->stream == STREAM_OFF) ||
-			        (cam->state & DEV_DISCONNECTED) );
-			if (err) {
-				cam->state |= DEV_MISCONFIGURED;
-				DBG(1, "The camera is misconfigured. To use "
-				       "it, close and open /dev/video%d "
-				       "again.", cam->v4ldev->minor)
+		if (cam->stream == STREAM_ON)
+			if ((err = sn9c102_stream_interrupt(cam)))
 				return err;
-			}
-			if (cam->state & DEV_DISCONNECTED)
-				return -ENODEV;
-		}
 
 		sn9c102_empty_framequeues(cam);
 
@@ -2161,22 +2326,9 @@
 		if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP)
 			return -EINVAL;
 
-		if (cam->stream == STREAM_ON) {
-			cam->stream = STREAM_INTERRUPT;
-			err = wait_event_interruptible
-			      ( cam->wait_stream, 
-			        (cam->stream == STREAM_OFF) ||
-			        (cam->state & DEV_DISCONNECTED) );
-			if (err) {
-				cam->state |= DEV_MISCONFIGURED;
-				DBG(1, "The camera is misconfigured. To use "
-				       "it, close and open /dev/video%d "
-				       "again.", cam->v4ldev->minor)
+		if (cam->stream == STREAM_ON)
+			if ((err = sn9c102_stream_interrupt(cam)))
 				return err;
-			}
-			if (cam->state & DEV_DISCONNECTED)
-				return -ENODEV;
-		}
 
 		sn9c102_empty_framequeues(cam);
 
@@ -2185,13 +2337,56 @@
 		return 0;
 	}
 
+	case VIDIOC_G_PARM:
+	{
+		struct v4l2_streamparm sp;
+
+		if (copy_from_user(&sp, arg, sizeof(sp)))
+			return -EFAULT;
+
+		if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+
+		sp.parm.capture.extendedmode = 0;
+		sp.parm.capture.readbuffers = cam->nreadbuffers;
+
+		if (copy_to_user(arg, &sp, sizeof(sp)))
+			return -EFAULT;
+
+		return 0;
+	}
+
+	case VIDIOC_S_PARM:
+	{
+		struct v4l2_streamparm sp;
+
+		if (copy_from_user(&sp, arg, sizeof(sp)))
+			return -EFAULT;
+
+		if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+			return -EINVAL;
+
+		sp.parm.capture.extendedmode = 0;
+
+		if (sp.parm.capture.readbuffers == 0)
+			sp.parm.capture.readbuffers = cam->nreadbuffers;
+
+		if (sp.parm.capture.readbuffers > SN9C102_MAX_FRAMES)
+			sp.parm.capture.readbuffers = SN9C102_MAX_FRAMES;
+
+		if (copy_to_user(arg, &sp, sizeof(sp)))
+			return -EFAULT;
+
+		cam->nreadbuffers = sp.parm.capture.readbuffers;
+
+		return 0;
+	}
+
 	case VIDIOC_G_STD:
 	case VIDIOC_S_STD:
 	case VIDIOC_QUERYSTD:
 	case VIDIOC_ENUMSTD:
 	case VIDIOC_QUERYMENU:
-	case VIDIOC_G_PARM:
-	case VIDIOC_S_PARM:
 		return -EINVAL;
 
 	default:
@@ -2286,16 +2481,28 @@
 
 	r = sn9c102_read_reg(cam, 0x00);
 	if (r < 0 || r != 0x10) {
-		DBG(1, "Sorry, this is not a SN9C10[12] based camera "
+		DBG(1, "Sorry, this is not a SN9C10x based camera "
 		       "(vid/pid 0x%04X/0x%04X)",
 		    sn9c102_id_table[i].idVendor,sn9c102_id_table[i].idProduct)
 		err = -ENODEV;
 		goto fail;
 	}
 
-	DBG(2, "SN9C10[12] PC Camera Controller detected "
-	       "(vid/pid 0x%04X/0x%04X)",
-	    sn9c102_id_table[i].idVendor, sn9c102_id_table[i].idProduct)
+	cam->bridge = (sn9c102_id_table[i].idProduct & 0xffc0) == 0x6080 ?
+	              BRIDGE_SN9C103 : BRIDGE_SN9C102;
+	switch (cam->bridge) {
+	case BRIDGE_SN9C101:
+	case BRIDGE_SN9C102:
+		DBG(2, "SN9C10[12] PC Camera Controller detected "
+		       "(vid/pid 0x%04X/0x%04X)", sn9c102_id_table[i].idVendor,
+		    sn9c102_id_table[i].idProduct)
+		break;
+	case BRIDGE_SN9C103:
+		DBG(2, "SN9C103 PC Camera Controller detected "
+		       "(vid/pid 0x%04X/0x%04X)", sn9c102_id_table[i].idVendor,
+		    sn9c102_id_table[i].idProduct)
+		break;
+	}
 
 	for  (i = 0; sn9c102_sensor_table[i]; i++) {
 		err = sn9c102_sensor_table[i](cam);
@@ -2318,7 +2525,7 @@
 		cam->state |= DEV_MISCONFIGURED;
 	}
 
-	strcpy(cam->v4ldev->name, "SN9C10[12] PC Camera");
+	strcpy(cam->v4ldev->name, "SN9C10x PC Camera");
 	cam->v4ldev->owner = THIS_MODULE;
 	cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
 	cam->v4ldev->hardware = VID_HARDWARE_SN9C102;
diff -Nru a/drivers/usb/media/sn9c102_pas106b.c b/drivers/usb/media/sn9c102_pas106b.c
--- a/drivers/usb/media/sn9c102_pas106b.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/media/sn9c102_pas106b.c	2004-12-24 13:36:18 -08:00
@@ -1,5 +1,5 @@
 /***************************************************************************
- * Driver for PAS106B image sensor connected to the SN9C10[12] PC Camera   *
+ * Plug-in for PAS106B image sensor connected to the SN9C10x PC Camera     *
  * Controllers                                                             *
  *                                                                         *
  * Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>       *
@@ -38,14 +38,9 @@
 	err += sn9c102_write_reg(cam, 0x09, 0x18);
 
 	err += sn9c102_i2c_write(cam, 0x02, 0x0c);
-	err += sn9c102_i2c_write(cam, 0x03, 0x12);
-	err += sn9c102_i2c_write(cam, 0x04, 0x05);
 	err += sn9c102_i2c_write(cam, 0x05, 0x5a);
 	err += sn9c102_i2c_write(cam, 0x06, 0x88);
 	err += sn9c102_i2c_write(cam, 0x07, 0x80);
-	err += sn9c102_i2c_write(cam, 0x08, 0x01);
-	err += sn9c102_i2c_write(cam, 0x0a, 0x01);
-	err += sn9c102_i2c_write(cam, 0x0b, 0x00);
 	err += sn9c102_i2c_write(cam, 0x10, 0x06);
 	err += sn9c102_i2c_write(cam, 0x11, 0x06);
 	err += sn9c102_i2c_write(cam, 0x12, 0x00);
@@ -62,6 +57,15 @@
                             struct v4l2_control* ctrl)
 {
 	switch (ctrl->id) {
+	case V4L2_CID_EXPOSURE:
+		{
+			int r1 = sn9c102_i2c_read(cam, 0x03),
+			    r2 = sn9c102_i2c_read(cam, 0x04);
+			if (r1 < 0 || r2 < 0)
+				return -EIO;
+			ctrl->value = (r1 << 4) | (r2 & 0x0f);
+		}
+		return 0;
 	case V4L2_CID_RED_BALANCE:
 		if ((ctrl->value = sn9c102_i2c_read(cam, 0x0c)) < 0)
 			return -EIO;
@@ -77,16 +81,26 @@
 			return -EIO;
 		ctrl->value &= 0x1f;
 		return 0;
-	case V4L2_CID_BRIGHTNESS:
-		if ((ctrl->value = sn9c102_i2c_read(cam, 0x0d)) < 0)
-			return -EIO;
-		ctrl->value &= 0x1f;
-		return 0;
 	case V4L2_CID_CONTRAST:
 		if ((ctrl->value = sn9c102_i2c_read(cam, 0x0f)) < 0)
 			return -EIO;
 		ctrl->value &= 0x07;
 		return 0;
+	case SN9C102_V4L2_CID_GREEN_BALANCE:
+		if ((ctrl->value = sn9c102_i2c_read(cam, 0x0a)) < 0)
+			return -EIO;
+		ctrl->value = (ctrl->value & 0x1f) << 1;
+		return 0;
+	case SN9C102_V4L2_CID_DAC_MAGNITUDE:
+		if ((ctrl->value = sn9c102_i2c_read(cam, 0x08)) < 0)
+			return -EIO;
+		ctrl->value &= 0xf8;
+		return 0;
+	case SN9C102_V4L2_CID_DAC_SIGN:
+		if ((ctrl->value = sn9c102_i2c_read(cam, 0x07)) < 0)
+			return -EIO;
+		ctrl->value &= 0x01;
+		return 0;
 	default:
 		return -EINVAL;
 	}
@@ -99,27 +113,42 @@
 	int err = 0;
 
 	switch (ctrl->id) {
+	case V4L2_CID_EXPOSURE:
+		err += sn9c102_i2c_write(cam, 0x03, ctrl->value >> 4);
+		err += sn9c102_i2c_write(cam, 0x04, ctrl->value & 0x0f);
+		break;
 	case V4L2_CID_RED_BALANCE:
-		err += sn9c102_i2c_write(cam, 0x0c, ctrl->value & 0x1f);
+		err += sn9c102_i2c_write(cam, 0x0c, ctrl->value);
 		break;
 	case V4L2_CID_BLUE_BALANCE:
-		err += sn9c102_i2c_write(cam, 0x09, ctrl->value & 0x1f);
+		err += sn9c102_i2c_write(cam, 0x09, ctrl->value);
 		break;
 	case V4L2_CID_GAIN:
-		err += sn9c102_i2c_write(cam, 0x0e, ctrl->value & 0x1f);
-		break;
-	case V4L2_CID_BRIGHTNESS:
-		err += sn9c102_i2c_write(cam, 0x0d, 0x1f-(ctrl->value & 0x1f));
+		err += sn9c102_i2c_write(cam, 0x0e, ctrl->value);
 		break;
 	case V4L2_CID_CONTRAST:
-		err += sn9c102_i2c_write(cam, 0x0f, ctrl->value & 0x03);
+		err += sn9c102_i2c_write(cam, 0x0f, ctrl->value);
+		break;
+	case SN9C102_V4L2_CID_GREEN_BALANCE:
+		err += sn9c102_i2c_write(cam, 0x0a, ctrl->value >> 1);
+		err += sn9c102_i2c_write(cam, 0x0b, ctrl->value >> 1);
+		break;
+	case SN9C102_V4L2_CID_DAC_MAGNITUDE:
+		err += sn9c102_i2c_write(cam, 0x08, ctrl->value << 3);
+		break;
+	case SN9C102_V4L2_CID_DAC_SIGN:
+		{
+			int r;
+			err += (r = sn9c102_i2c_read(cam, 0x07)) < 0 ? r : 0;
+			err += sn9c102_i2c_write(cam, 0x07, r | ctrl->value);
+		}
 		break;
 	default:
 		return -EINVAL;
 	}
 	err += sn9c102_i2c_write(cam, 0x13, 0x01);
 
-	return err;
+	return err ? -EIO : 0;
 }
 
 
@@ -148,6 +177,36 @@
 	.init = &pas106b_init,
 	.qctrl = {
 		{
+			.id = V4L2_CID_EXPOSURE,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "exposure",
+			.minimum = 0x125,
+			.maximum = 0xfff,
+			.step = 0x01,
+			.default_value = 0x140,
+			.flags = 0,
+		},
+		{
+			.id = V4L2_CID_GAIN,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "global gain",
+			.minimum = 0x00,
+			.maximum = 0x1f,
+			.step = 0x01,
+			.default_value = 0x0d,
+			.flags = 0,
+		},
+		{
+			.id = V4L2_CID_CONTRAST,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "contrast",
+			.minimum = 0x00,
+			.maximum = 0x07,
+			.step = 0x01,
+			.default_value = 0x00, /* 0x00~0x03 have same effect */
+			.flags = 0,
+		},
+		{
 			.id = V4L2_CID_RED_BALANCE,
 			.type = V4L2_CTRL_TYPE_INTEGER,
 			.name = "red balance",
@@ -168,33 +227,33 @@
 			.flags = 0,
 		},
 		{
-			.id = V4L2_CID_GAIN,
+			.id = SN9C102_V4L2_CID_GREEN_BALANCE,
 			.type = V4L2_CTRL_TYPE_INTEGER,
-			.name = "global gain",
+			.name = "green balance",
 			.minimum = 0x00,
-			.maximum = 0x1f,
-			.step = 0x01,
-			.default_value = 0x0d,
+			.maximum = 0x3e,
+			.step = 0x02,
+			.default_value = 0x02,
 			.flags = 0,
 		},
 		{
-			.id = V4L2_CID_BRIGHTNESS,
+			.id = SN9C102_V4L2_CID_DAC_MAGNITUDE,
 			.type = V4L2_CTRL_TYPE_INTEGER,
-			.name = "brightness",
+			.name = "DAC magnitude",
 			.minimum = 0x00,
 			.maximum = 0x1f,
 			.step = 0x01,
-			.default_value = 0x1f,
+			.default_value = 0x01,
 			.flags = 0,
 		},
 		{
-			.id = V4L2_CID_CONTRAST,
-			.type = V4L2_CTRL_TYPE_INTEGER,
-			.name = "contrast",
+			.id = SN9C102_V4L2_CID_DAC_SIGN,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "DAC sign",
 			.minimum = 0x00,
-			.maximum = 0x07,
+			.maximum = 0x01,
 			.step = 0x01,
-			.default_value = 0x00, /* 0x00~0x03 have same effect */
+			.default_value = 0x00,
 			.flags = 0,
 		},
 	},
diff -Nru a/drivers/usb/media/sn9c102_pas202bcb.c b/drivers/usb/media/sn9c102_pas202bcb.c
--- a/drivers/usb/media/sn9c102_pas202bcb.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/media/sn9c102_pas202bcb.c	2004-12-24 13:37:18 -08:00
@@ -1,11 +1,14 @@
 /***************************************************************************
- * Driver for PAS202BCB image sensor connected to the SN9C10[12] PC Camera *
+ * Plug-in for PAS202BCB image sensor connected to the SN9C10x PC Camera   *
  * Controllers                                                             *
  *                                                                         *
  * Copyright (C) 2004 by Carlos Eduardo Medaglia Dyonisio                  *
  *                       <medaglia@undl.org.br>                            *
  *                       http://cadu.homelinux.com:8080/                   *
  *                                                                         *
+ * DAC Magnitude, DAC sign, exposure and green gain controls added by      *
+ * Luca Risolia <luca.risolia@studio.unibo.it>                             *
+ *                                                                         *
  * 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       *
@@ -36,18 +39,15 @@
 	err += sn9c102_write_reg(cam, 0x00, 0x11);
 	err += sn9c102_write_reg(cam, 0x00, 0x14);
 	err += sn9c102_write_reg(cam, 0x20, 0x17);
-	err += sn9c102_write_reg(cam, 0x20, 0x19);
+	err += sn9c102_write_reg(cam, 0x30, 0x19);
 	err += sn9c102_write_reg(cam, 0x09, 0x18);
 
-	err += sn9c102_i2c_write(cam, 0x02, 0x0c);
+	err += sn9c102_i2c_write(cam, 0x02, 0x14);
 	err += sn9c102_i2c_write(cam, 0x03, 0x40);
-	err += sn9c102_i2c_write(cam, 0x04, 0x07);
-	err += sn9c102_i2c_write(cam, 0x05, 0x25);
 	err += sn9c102_i2c_write(cam, 0x0d, 0x2c);
 	err += sn9c102_i2c_write(cam, 0x0e, 0x01);
 	err += sn9c102_i2c_write(cam, 0x0f, 0xa9);
-	err += sn9c102_i2c_write(cam, 0x08, 0x01);
-	err += sn9c102_i2c_write(cam, 0x0b, 0x01);
+	err += sn9c102_i2c_write(cam, 0x10, 0x08);
 	err += sn9c102_i2c_write(cam, 0x13, 0x63);
 	err += sn9c102_i2c_write(cam, 0x15, 0x70);
 	err += sn9c102_i2c_write(cam, 0x11, 0x01);
@@ -62,6 +62,15 @@
                               struct v4l2_control* ctrl)
 {
 	switch (ctrl->id) {
+	case V4L2_CID_EXPOSURE:
+		{
+			int r1 = sn9c102_i2c_read(cam, 0x04),
+			    r2 = sn9c102_i2c_read(cam, 0x05);
+			if (r1 < 0 || r2 < 0)
+				return -EIO;
+			ctrl->value = (r1 << 6) | (r2 & 0x3f);
+		}
+		return 0;
 	case V4L2_CID_RED_BALANCE:
 		if ((ctrl->value = sn9c102_i2c_read(cam, 0x09)) < 0)
 			return -EIO;
@@ -77,11 +86,20 @@
 			return -EIO;
 		ctrl->value &= 0x1f;
 		return 0;
-	case V4L2_CID_BRIGHTNESS:
-		if ((ctrl->value = sn9c102_i2c_read(cam, 0x06)) < 0)
+	case SN9C102_V4L2_CID_GREEN_BALANCE:
+		if ((ctrl->value = sn9c102_i2c_read(cam, 0x08)) < 0)
 			return -EIO;
 		ctrl->value &= 0x0f;
 		return 0;
+	case SN9C102_V4L2_CID_DAC_MAGNITUDE:
+		if ((ctrl->value = sn9c102_i2c_read(cam, 0x0c)) < 0)
+			return -EIO;
+		return 0;
+	case SN9C102_V4L2_CID_DAC_SIGN:
+		if ((ctrl->value = sn9c102_i2c_read(cam, 0x0b)) < 0)
+			return -EIO;
+		ctrl->value &= 0x01;
+		return 0;
 	default:
 		return -EINVAL;
 	}
@@ -94,24 +112,38 @@
 	int err = 0;
 
 	switch (ctrl->id) {
+	case V4L2_CID_EXPOSURE:
+		err += sn9c102_i2c_write(cam, 0x04, ctrl->value >> 6);
+		err += sn9c102_i2c_write(cam, 0x05, ctrl->value & 0x3f);
+		break;
 	case V4L2_CID_RED_BALANCE:
-		err += sn9c102_i2c_write(cam, 0x09, ctrl->value & 0x0f);
+		err += sn9c102_i2c_write(cam, 0x09, ctrl->value);
 		break;
 	case V4L2_CID_BLUE_BALANCE:
-		err += sn9c102_i2c_write(cam, 0x07, ctrl->value & 0x0f);
+		err += sn9c102_i2c_write(cam, 0x07, ctrl->value);
 		break;
 	case V4L2_CID_GAIN:
-		err += sn9c102_i2c_write(cam, 0x10, ctrl->value & 0x1f);
+		err += sn9c102_i2c_write(cam, 0x10, ctrl->value);
+		break;
+	case SN9C102_V4L2_CID_GREEN_BALANCE:
+		err += sn9c102_i2c_write(cam, 0x08, ctrl->value);
+		break;
+	case SN9C102_V4L2_CID_DAC_MAGNITUDE:
+		err += sn9c102_i2c_write(cam, 0x0c, ctrl->value);
 		break;
-	case V4L2_CID_BRIGHTNESS:
-		err += sn9c102_i2c_write(cam, 0x06, 0x0f-(ctrl->value & 0x0f));
+	case SN9C102_V4L2_CID_DAC_SIGN:
+		{
+			int r;
+			err += (r = sn9c102_i2c_read(cam, 0x0b)) < 0 ? r : 0;
+			err += sn9c102_i2c_write(cam, 0x0b, r | ctrl->value);
+		}
 		break;
 	default:
 		return -EINVAL;
 	}
 	err += sn9c102_i2c_write(cam, 0x11, 0x01);
 
-	return err;
+	return err ? -EIO : 0;
 }
 
 
@@ -141,6 +173,26 @@
 	.init = &pas202bcb_init,
 	.qctrl = {
 		{
+			.id = V4L2_CID_EXPOSURE,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "exposure",
+			.minimum = 0x01e5,
+			.maximum = 0x3fff,
+			.step = 0x01,
+			.default_value = 0x01e5,
+			.flags = 0,
+		},
+		{
+			.id = V4L2_CID_GAIN,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "global gain",
+			.minimum = 0x00,
+			.maximum = 0x1f,
+			.step = 0x01,
+			.default_value = 0x0c,
+			.flags = 0,
+		},
+		{
 			.id = V4L2_CID_RED_BALANCE,
 			.type = V4L2_CTRL_TYPE_INTEGER,
 			.name = "red balance",
@@ -161,23 +213,33 @@
 			.flags = 0,
 		},
 		{
-			.id = V4L2_CID_GAIN,
+			.id = SN9C102_V4L2_CID_GREEN_BALANCE,
 			.type = V4L2_CTRL_TYPE_INTEGER,
-			.name = "global gain",
+			.name = "green balance",
 			.minimum = 0x00,
-			.maximum = 0x1f,
+			.maximum = 0x0f,
 			.step = 0x01,
-			.default_value = 0x0c,
+			.default_value = 0x00,
 			.flags = 0,
 		},
 		{
-			.id = V4L2_CID_BRIGHTNESS,
+			.id = SN9C102_V4L2_CID_DAC_MAGNITUDE,
 			.type = V4L2_CTRL_TYPE_INTEGER,
-			.name = "brightness",
+			.name = "DAC magnitude",
 			.minimum = 0x00,
-			.maximum = 0x0f,
+			.maximum = 0xff,
 			.step = 0x01,
-			.default_value = 0x0f,
+			.default_value = 0x04,
+			.flags = 0,
+		},
+		{
+			.id = SN9C102_V4L2_CID_DAC_SIGN,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "DAC sign",
+			.minimum = 0x00,
+			.maximum = 0x01,
+			.step = 0x01,
+			.default_value = 0x01,
 			.flags = 0,
 		},
 	},
@@ -217,7 +279,7 @@
 	 *  NOTE: do NOT change the values!
 	 */
 	err += sn9c102_write_reg(cam, 0x01, 0x01); /* sensor power down */
-	err += sn9c102_write_reg(cam, 0x00, 0x01); /* sensor power on */
+	err += sn9c102_write_reg(cam, 0x40, 0x01); /* sensor power on */
 	err += sn9c102_write_reg(cam, 0x28, 0x17); /* sensor clock at 24 MHz */
 	if (err)
 		return -EIO;
diff -Nru a/drivers/usb/media/sn9c102_sensor.h b/drivers/usb/media/sn9c102_sensor.h
--- a/drivers/usb/media/sn9c102_sensor.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/usb/media/sn9c102_sensor.h	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,5 @@
 /***************************************************************************
- * API for image sensors connected to the SN9C10[12] PC Camera Controllers *
+ * API for image sensors connected to the SN9C10x PC Camera Controllers    *
  *                                                                         *
  * Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>       *
  *                                                                         *
@@ -89,17 +89,44 @@
 /* Each SN9C10X camera has proper PID/VID identifiers. Add them here in case.*/
 #define SN9C102_ID_TABLE                                                      \
 static const struct usb_device_id sn9c102_id_table[] = {                      \
-	{ USB_DEVICE(0xc45, 0x6001), }, /* TAS5110C1B */                      \
-	{ USB_DEVICE(0xc45, 0x6005), }, /* TAS5110C1B */                      \
-	{ USB_DEVICE(0xc45, 0x6009), }, /* PAS106B */                         \
-	{ USB_DEVICE(0xc45, 0x600d), }, /* PAS106B */                         \
-	{ USB_DEVICE(0xc45, 0x6024), },                                       \
-	{ USB_DEVICE(0xc45, 0x6025), }, /* TAS5130D1B and TAS5110C1B */       \
-	{ USB_DEVICE(0xc45, 0x6028), }, /* PAS202BCB */                       \
-	{ USB_DEVICE(0xc45, 0x6029), }, /* PAS106B */                         \
-	{ USB_DEVICE(0xc45, 0x602a), }, /* HV7131[D|E1] */                    \
-	{ USB_DEVICE(0xc45, 0x602c), }, /* OV7620 */                          \
-	{ USB_DEVICE(0xc45, 0x6030), }, /* MI03 */                            \
+	{ USB_DEVICE(0x0c45, 0x6001), }, /* TAS5110C1B */                     \
+	{ USB_DEVICE(0x0c45, 0x6005), }, /* TAS5110C1B */                     \
+	{ USB_DEVICE(0x0c45, 0x6009), }, /* PAS106B */                        \
+	{ USB_DEVICE(0x0c45, 0x600d), }, /* PAS106B */                        \
+	{ USB_DEVICE(0x0c45, 0x6024), },                                      \
+	{ USB_DEVICE(0x0c45, 0x6025), }, /* TAS5130D1B and TAS5110C1B */      \
+	{ USB_DEVICE(0x0c45, 0x6028), }, /* PAS202BCB */                      \
+	{ USB_DEVICE(0x0c45, 0x6029), }, /* PAS106B */                        \
+	{ USB_DEVICE(0x0c45, 0x602a), }, /* HV7131[D|E1] */                   \
+	{ USB_DEVICE(0x0c45, 0x602b), }, /* MI-0343 */                        \
+	{ USB_DEVICE(0x0c45, 0x602c), }, /* OV7620 */                         \
+	{ USB_DEVICE(0x0c45, 0x6030), }, /* MI03x */                          \
+	{ USB_DEVICE(0x0c45, 0x6080), },                                      \
+	{ USB_DEVICE(0x0c45, 0x6082), }, /* MI0343 and MI0360 */              \
+	{ USB_DEVICE(0x0c45, 0x6083), }, /* HV7131[D|E1] */                   \
+	{ USB_DEVICE(0x0c45, 0x6088), },                                      \
+	{ USB_DEVICE(0x0c45, 0x608a), },                                      \
+	{ USB_DEVICE(0x0c45, 0x608b), },                                      \
+	{ USB_DEVICE(0x0c45, 0x608c), }, /* HV7131x */                        \
+	{ USB_DEVICE(0x0c45, 0x608e), }, /* CIS-VF10 */                       \
+	{ USB_DEVICE(0x0c45, 0x608f), }, /* OV7630 */                         \
+	{ USB_DEVICE(0x0c45, 0x60a0), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60a2), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60a3), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60a8), }, /* PAS106B */                        \
+	{ USB_DEVICE(0x0c45, 0x60aa), }, /* TAS5130D1B */                     \
+	{ USB_DEVICE(0x0c45, 0x60ab), }, /* TAS5110C1B */                     \
+	{ USB_DEVICE(0x0c45, 0x60ac), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60ae), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60af), }, /* PAS202BCB */                      \
+	{ USB_DEVICE(0x0c45, 0x60b0), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60b2), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60b3), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60b8), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60ba), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60bb), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60bc), },                                      \
+	{ USB_DEVICE(0x0c45, 0x60be), },                                      \
 	{ }                                                                   \
 };
 
@@ -159,6 +186,9 @@
 	SN9C102_I2C_3WIRES,
 };
 
+#define SN9C102_I2C_SLAVEID_FICTITIOUS 0xff
+#define SN9C102_I2C_SLAVEID_UNAVAILABLE 0x00
+
 struct sn9c102_sensor {
 	char name[32], /* sensor name */
 	     maintainer[64]; /* name of the mantainer <email> */
@@ -173,9 +203,7 @@
 
 	/*
 	   These identifiers must be provided if the image sensor implements
-	   the standard I2C protocol. TASC sensors don't, although they have a
-	   serial interface: so this is a case where the "raw" I2C version
-	   could be helpful.
+	   the standard I2C protocol.
 	*/
 	u8 slave_read_id, slave_write_id; /* reg. 0x09 */
 
@@ -214,7 +242,8 @@
 	   the list above. The returned value must follow the V4L2
 	   specifications for the VIDIOC_G|C_CTRL ioctls. V4L2_CID_H|VCENTER
 	   are not supported by this driver, so do not implement them. Also,
-	   passed values are NOT checked to see if they are out of bounds.
+	   you don't have to check whether the passed values are out of bounds,
+	   given that this is done by the core module.
 	*/
 
 	struct v4l2_cropcap cropcap;
@@ -263,21 +292,25 @@
 	   NOTE: in case, you must program the SN9C10X chip to get rid of 
 	         blank pixels or blank lines at the _start_ of each line or
 	         frame after each HSYNC or VSYNC, so that the image starts with
-	         real RGB data (see regs 0x12,0x13) (having set H_SIZE and,
+	         real RGB data (see regs 0x12, 0x13) (having set H_SIZE and,
 	         V_SIZE you don't have to care about blank pixels or blank
 	         lines at the end of each line or frame).
 	*/
 
 	struct v4l2_pix_format pix_format;
 	/*
-	   What you have to define here are: initial 'width' and 'height' of
-	   the target rectangle, the bayer 'pixelformat' and 'priv' which we'll
-	   be used to indicate the number of bits per pixel, 8 or 9. 
-	   Nothing more.
+	   What you have to define here are: 1) initial 'width' and 'height' of
+	   the target rectangle 2) the initial 'pixelformat', which can be
+	   either V4L2_PIX_FMT_SN9C10X (for compressed video) or
+	   V4L2_PIX_FMT_SBGGR8 3) 'priv', which we'll be used to indicate the
+	   number of bits per pixel for uncompressed video, 8 or 9 (despite the
+	   current value of 'pixelformat').
 	   NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4
 	           of cropcap.defrect.width and cropcap.defrect.height. I
 	           suggest 1/1.
-	   NOTE 2: as said above, you have to program the SN9C10X chip to get
+	   NOTE 2: The initial compression quality is defined by the first bit
+	           of reg 0x17 during the initialization of the image sensor.
+	   NOTE 3: as said above, you have to program the SN9C10X chip to get
 	           rid of any blank pixels, so that the output of the sensor
 	           matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR).
 	*/
@@ -303,5 +336,12 @@
 	struct v4l2_queryctrl _qctrl[V4L2_CID_LASTP1-V4L2_CID_BASE];
 	struct v4l2_rect _rect;
 };
+
+/*****************************************************************************/
+
+/* Private ioctl's for control settings supported by some image sensors */
+#define SN9C102_V4L2_CID_DAC_MAGNITUDE V4L2_CID_PRIVATE_BASE
+#define SN9C102_V4L2_CID_DAC_SIGN V4L2_CID_PRIVATE_BASE + 1
+#define SN9C102_V4L2_CID_GREEN_BALANCE V4L2_CID_PRIVATE_BASE + 2
 
 #endif /* _SN9C102_SENSOR_H_ */
diff -Nru a/drivers/usb/media/sn9c102_tas5110c1b.c b/drivers/usb/media/sn9c102_tas5110c1b.c
--- a/drivers/usb/media/sn9c102_tas5110c1b.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/usb/media/sn9c102_tas5110c1b.c	2004-12-24 13:36:16 -08:00
@@ -1,6 +1,6 @@
 /***************************************************************************
- * Driver for TAS5110C1B image sensor connected to the SN9C10[12] PC       *
- * Camera Controllers                                                      *
+ * Plug-in for TAS5110C1B image sensor connected to the SN9C10x PC Camera  *
+ * Controllers                                                             *
  *                                                                         *
  * Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>       *
  *                                                                         *
@@ -24,6 +24,8 @@
 
 static struct sn9c102_sensor tas5110c1b;
 
+static struct v4l2_control tas5110c1b_gain;
+
 
 static int tas5110c1b_init(struct sn9c102_device* cam)
 {
@@ -38,25 +40,42 @@
 	err += sn9c102_write_reg(cam, 0x06, 0x18);
 	err += sn9c102_write_reg(cam, 0xfb, 0x19);
 
-	err += sn9c102_i2c_try_raw_write(cam, &tas5110c1b, 4, 0x11, 0x00, 0xc0,
-	                                 0x80, 0, 0);
+	err += sn9c102_i2c_write(cam, 0xc0, 0x80);
 
 	return err;
 }
 
 
+static int tas5110c1b_get_ctrl(struct sn9c102_device* cam, 
+                               struct v4l2_control* ctrl)
+{
+	switch (ctrl->id) {
+	case V4L2_CID_GAIN:
+		ctrl->value = tas5110c1b_gain.value;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+
 static int tas5110c1b_set_ctrl(struct sn9c102_device* cam, 
                                const struct v4l2_control* ctrl)
 {
+	int err = 0;
+
 	switch (ctrl->id) {
 	case V4L2_CID_GAIN:
-		return sn9c102_i2c_try_raw_write(cam, &tas5110c1b, 4, 0x11,
-		                                 0x02, 0x20,
-		                                 0xff - (ctrl->value & 0xff),
-		                                 0, 0);
+		if (!(err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value)))
+			tas5110c1b_gain.value = ctrl->value;
+		break;
 	default:
 		return -EINVAL;
 	}
+
+	return err ? -EIO : 0;
 }
 
 
@@ -85,6 +104,8 @@
 	.maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
 	.frequency = SN9C102_I2C_100KHZ,
 	.interface = SN9C102_I2C_3WIRES,
+	.slave_read_id = SN9C102_I2C_SLAVEID_UNAVAILABLE,
+	.slave_write_id = SN9C102_I2C_SLAVEID_FICTITIOUS,
 	.init = &tas5110c1b_init,
 	.qctrl = {
 		{
@@ -92,9 +113,9 @@
 			.type = V4L2_CTRL_TYPE_INTEGER,
 			.name = "global gain",
 			.minimum = 0x00,
-			.maximum = 0xff,
+			.maximum = 0xf6,
 			.step = 0x01,
-			.default_value = 0x48,
+			.default_value = 0x40,
 			.flags = 0,
 		},
 	},
@@ -113,6 +134,7 @@
 			.height = 288,
 		},
 	},
+	.get_ctrl = &tas5110c1b_get_ctrl,
 	.set_crop = &tas5110c1b_set_crop,
 	.pix_format = {
 		.width = 352,
@@ -128,9 +150,10 @@
 	/* This sensor has no identifiers, so let's attach it anyway */
 	sn9c102_attach_sensor(cam, &tas5110c1b);
 
-	/* At the moment, sensor detection is based on USB pid/vid */
+	/* Sensor detection is based on USB pid/vid */
 	if (tas5110c1b.usbdev->descriptor.idProduct != 0x6001 &&
-	    tas5110c1b.usbdev->descriptor.idProduct != 0x6005)
+	    tas5110c1b.usbdev->descriptor.idProduct != 0x6005 &&
+	    tas5110c1b.usbdev->descriptor.idProduct != 0x60ab)
 		return -ENODEV;
 
 	return 0;
diff -Nru a/drivers/usb/media/sn9c102_tas5130d1b.c b/drivers/usb/media/sn9c102_tas5130d1b.c
--- a/drivers/usb/media/sn9c102_tas5130d1b.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/usb/media/sn9c102_tas5130d1b.c	2004-12-24 13:36:56 -08:00
@@ -1,6 +1,6 @@
 /***************************************************************************
- * Driver for TAS5130D1B image sensor connected to the SN9C10[12] PC       *
- * Camera Controllers                                                      *
+ * Plug-in for TAS5130D1B image sensor connected to the SN9C10x PC Camera  *
+ * Controllers                                                             *
  *                                                                         *
  * Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>       *
  *                                                                         *
@@ -24,6 +24,8 @@
 
 static struct sn9c102_sensor tas5130d1b;
 
+static struct v4l2_control tas5130d1b_gain, tas5130d1b_exposure;
+
 
 static int tas5130d1b_init(struct sn9c102_device* cam)
 {
@@ -38,25 +40,47 @@
 	err += sn9c102_write_reg(cam, 0x60, 0x17);
 	err += sn9c102_write_reg(cam, 0x07, 0x18);
 
-	err += sn9c102_i2c_try_raw_write(cam, &tas5130d1b, 4, 0x11, 0x00, 0x40,
-	                                 0x47, 0, 0);
-
 	return err;
 }
 
 
+static int tas5130d1b_get_ctrl(struct sn9c102_device* cam, 
+                               struct v4l2_control* ctrl)
+{
+	switch (ctrl->id) {
+	case V4L2_CID_GAIN:
+		ctrl->value = tas5130d1b_gain.value;
+		break;
+	case V4L2_CID_EXPOSURE:
+		ctrl->value = tas5130d1b_exposure.value;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+
 static int tas5130d1b_set_ctrl(struct sn9c102_device* cam, 
                                const struct v4l2_control* ctrl)
 {
+	int err = 0;
+
 	switch (ctrl->id) {
 	case V4L2_CID_GAIN:
-		return sn9c102_i2c_try_raw_write(cam, &tas5130d1b, 4, 0x11,
-		                                 0x02, 0x20,
-		                                 0xff - (ctrl->value & 0xff),
-		                                 0, 0);
+		if (!(err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value)))
+			tas5130d1b_gain.value = ctrl->value;
+		break;
+	case V4L2_CID_EXPOSURE:
+		if (!(err += sn9c102_i2c_write(cam, 0x40, 0x47 - ctrl->value)))
+			tas5130d1b_exposure.value = ctrl->value;
+		break;
 	default:
 		return -EINVAL;
 	}
+
+	return err ? -EIO : 0;
 }
 
 
@@ -72,8 +96,8 @@
 	err += sn9c102_write_reg(cam, v_start, 0x13);
 
 	/* Do NOT change! */
-	err += sn9c102_write_reg(cam, 0x1d, 0x1a);
-	err += sn9c102_write_reg(cam, 0x10, 0x1b);
+	err += sn9c102_write_reg(cam, 0x1f, 0x1a);
+	err += sn9c102_write_reg(cam, 0x1a, 0x1b);
 	err += sn9c102_write_reg(cam, 0xf3, 0x19);
 
 	return err;
@@ -85,6 +109,8 @@
 	.maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
 	.frequency = SN9C102_I2C_100KHZ,
 	.interface = SN9C102_I2C_3WIRES,
+	.slave_read_id = SN9C102_I2C_SLAVEID_UNAVAILABLE,
+	.slave_write_id = SN9C102_I2C_SLAVEID_FICTITIOUS,
 	.init = &tas5130d1b_init,
 	.qctrl = {
 		{
@@ -92,12 +118,23 @@
 			.type = V4L2_CTRL_TYPE_INTEGER,
 			.name = "global gain",
 			.minimum = 0x00,
-			.maximum = 0xff,
+			.maximum = 0xf6,
+			.step = 0x02,
+			.default_value = 0x00,
+			.flags = 0,
+		},
+		{
+			.id = V4L2_CID_EXPOSURE,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "exposure",
+			.minimum = 0x00,
+			.maximum = 0x47,
 			.step = 0x01,
 			.default_value = 0x00,
 			.flags = 0,
 		},
 	},
+	.get_ctrl = &tas5130d1b_get_ctrl,
 	.set_ctrl = &tas5130d1b_set_ctrl,
 	.cropcap = {
 		.bounds = {
@@ -128,8 +165,9 @@
 	/* This sensor has no identifiers, so let's attach it anyway */
 	sn9c102_attach_sensor(cam, &tas5130d1b);
 
-	/* At the moment, sensor detection is based on USB pid/vid */
-	if (tas5130d1b.usbdev->descriptor.idProduct != 0x6025)
+	/* Sensor detection is based on USB pid/vid */
+	if (tas5130d1b.usbdev->descriptor.idProduct != 0x6025 &&
+	    tas5130d1b.usbdev->descriptor.idProduct != 0x60aa)
 		return -ENODEV;
 
 	return 0;
diff -Nru a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c
--- a/drivers/usb/media/stv680.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/usb/media/stv680.c	2004-12-24 13:37:01 -08:00
@@ -118,20 +118,6 @@
  *
  * And the STV0680 driver - Kevin
  ********************************************************************/
-
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa (unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *rvmalloc (unsigned long size)
 {
 	void *mem;
@@ -512,12 +498,6 @@
 /****************************************************************************
  *  sysfs
  ***************************************************************************/
-static inline struct usb_stv *cd_to_stv(struct class_device *cd)
-{
-	struct video_device *vdev = to_video_device(cd);
-	return video_get_drvdata(vdev);
-}
-
 #define stv680_file(name, variable, field)				\
 static ssize_t show_##name(struct class_device *class_dev, char *buf)	\
 {									\
@@ -725,7 +705,7 @@
 
 	for (i = 0; i < STV680_NUMSBUF; i++)
 		if (stv680->urb[i]) {
-			usb_unlink_urb (stv680->urb[i]);
+			usb_kill_urb (stv680->urb[i]);
 			usb_free_urb (stv680->urb[i]);
 			stv680->urb[i] = NULL;
 			kfree (stv680->sbuf[i].data);
@@ -1291,8 +1271,8 @@
 	}
 	pos = (unsigned long) stv680->fbuf;
 	while (size > 0) {
-		page = kvirt_to_pa (pos);
-		if (remap_page_range (vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up (&stv680->lock);
 			return -EAGAIN;
 		}
@@ -1457,7 +1437,7 @@
 
 	for (i = 0; i < STV680_NUMSBUF; i++)
 		if (stv680->urb[i]) {
-			usb_unlink_urb (stv680->urb[i]);
+			usb_kill_urb (stv680->urb[i]);
 			usb_free_urb (stv680->urb[i]);
 			stv680->urb[i] = NULL;
 			kfree (stv680->sbuf[i].data);
diff -Nru a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c
--- a/drivers/usb/media/usbvideo.c	2004-12-24 13:37:33 -08:00
+++ b/drivers/usb/media/usbvideo.c	2004-12-24 13:37:33 -08:00
@@ -60,21 +60,6 @@
 /*******************************/
 /* Memory management functions */
 /*******************************/
-
-/*
- * Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-unsigned long usbvideo_kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *usbvideo_rvmalloc(unsigned long size)
 {
 	void *mem;
@@ -520,72 +505,6 @@
 }
 
 /*
- * usbvideo_DrawLine()
- *
- * A standard implementation of Bresenham's line drawing algorithm.
- * This procedure is provided primarily for debugging or demo
- * purposes.
- */
-void usbvideo_DrawLine(
-	struct usbvideo_frame *frame,
-	int x1, int y1,
-	int x2, int y2,
-	unsigned char cr, unsigned char cg, unsigned char cb)
-{
-	int i, dx, dy, np, d;
-	int dinc1, dinc2, x, xinc1, xinc2, y, yinc1, yinc2;
-
-	if ((dx = x2 - x1) < 0)
-		dx = -dx;
-	if ((dy = y2 - y1) < 0)
-		dy = -dy;
-	if (dx >= dy) {
-		np = dx + 1;
-		d = (2 * dy) - dx;
-		dinc1 = dy << 1;
-		dinc2 = (dy - dx) << 1;
-		xinc1 = 1;
-		xinc2 = 1;
-		yinc1 = 0;
-		yinc2 = 1;
-	} else {
-		np = dy + 1;
-		d = (2 * dx) - dy;
-		dinc1 = dx << 1;
-		dinc2 = (dx - dy) << 1;
-		xinc1 = 0;
-		xinc2 = 1;
-		yinc1 = 1;
-		yinc2 = 1;
-	}
-	/* Make sure x and y move in the right directions */
-	if (x1 > x2) {
-		xinc1 = -xinc1;
-		xinc2 = -xinc2;
-	}
-	if (y1 > y2) {
-		yinc1 = -yinc1;
-		yinc2 = -yinc2;
-	}
-	for (i=0, x=x1, y=y1; i < np; i++) {
-		if (frame->palette == VIDEO_PALETTE_RGB24) {
-/* TODO */		RGB24_PUTPIXEL(frame, x, y, cr, cg, cb);
-		}
-		if (d < 0) {
-			d += dinc1;
-			x += xinc1;
-			y += yinc1;
-		} else {
-			d += dinc2;
-			x += xinc2;
-			y += yinc2;
-		}
-	}
-}
-
-EXPORT_SYMBOL(usbvideo_DrawLine);
-
-/*
  * usbvideo_TestPattern()
  *
  * Procedure forms a test pattern (yellow grid on blue background).
@@ -673,6 +592,8 @@
 
 EXPORT_SYMBOL(usbvideo_TestPattern);
 
+
+#ifdef DEBUG
 /*
  * usbvideo_HexDump()
  *
@@ -702,16 +623,7 @@
 
 EXPORT_SYMBOL(usbvideo_HexDump);
 
-/* Debugging aid */
-void usbvideo_SayAndWait(const char *what)
-{
-	wait_queue_head_t wq;
-	init_waitqueue_head(&wq);
-	info("Say: %s", what);
-	interruptible_sleep_on_timeout (&wq, HZ*3); /* Timeout */
-}
-
-EXPORT_SYMBOL(usbvideo_SayAndWait);
+#endif
 
 /* ******************************************************************** */
 
@@ -1168,8 +1080,8 @@
 
 	pos = (unsigned long) uvd->fbuf;
 	while (size > 0) {
-		page = usbvideo_kvirt_to_pa(pos);
-		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 
 		start += PAGE_SIZE;
@@ -1910,9 +1822,7 @@
 
 	/* Unschedule all of the iso td's */
 	for (i=0; i < USBVIDEO_NUMSBUF; i++) {
-		j = usb_unlink_urb(uvd->sbuf[i].urb);
-		if (j < 0)
-			err("%s: usb_unlink_urb() error %d.", __FUNCTION__, j);
+		usb_kill_urb(uvd->sbuf[i].urb);
 	}
 	if (uvd->debug > 1)
 		info("%s: streaming=0", __FUNCTION__);
diff -Nru a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c
--- a/drivers/usb/media/vicam.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/usb/media/vicam.c	2004-12-24 13:36:47 -08:00
@@ -351,16 +351,6 @@
 	0x46, 0x05, 0x6C, 0x05, 0x00, 0x00
 };
 
-static unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 /* rvmalloc / rvfree copied from usbvideo.c
  *
  * Not sure why these are not yet non-statics which I can reference through
@@ -1055,8 +1045,8 @@
 
 	pos = (unsigned long)cam->framebuf;
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
-		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 
 		start += PAGE_SIZE;
diff -Nru a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c
--- a/drivers/usb/media/w9968cf.c	2004-12-24 13:37:04 -08:00
+++ b/drivers/usb/media/w9968cf.c	2004-12-24 13:37:04 -08:00
@@ -111,30 +111,30 @@
 module_param(vppmod_load, bool, 0444);
 #endif
 module_param(simcams, ushort, 0644);
-module_param_array(video_nr, short, param_nv[0], 0444);
-module_param_array(packet_size, uint, param_nv[1], 0444);
-module_param_array(max_buffers, ushort, param_nv[2], 0444);
-module_param_array(double_buffer, bool, param_nv[3], 0444);
-module_param_array(clamping, bool, param_nv[4], 0444);
-module_param_array(filter_type, ushort, param_nv[5], 0444);
-module_param_array(largeview, bool, param_nv[6], 0444);
-module_param_array(decompression, ushort, param_nv[7], 0444);
-module_param_array(upscaling, bool, param_nv[8], 0444);
-module_param_array(force_palette, ushort, param_nv[9], 0444);
-module_param_array(force_rgb, ushort, param_nv[10], 0444);
-module_param_array(autobright, bool, param_nv[11], 0444);
-module_param_array(autoexp, bool, param_nv[12], 0444);
-module_param_array(lightfreq, ushort, param_nv[13], 0444);
-module_param_array(bandingfilter, bool, param_nv[14], 0444);
-module_param_array(clockdiv, short, param_nv[15], 0444);
-module_param_array(backlight, bool, param_nv[16], 0444);
-module_param_array(mirror, bool, param_nv[17], 0444);
-module_param_array(monochrome, bool, param_nv[18], 0444);
-module_param_array(brightness, uint, param_nv[19], 0444);
-module_param_array(hue, uint, param_nv[20], 0444);
-module_param_array(colour, uint, param_nv[21], 0444);
-module_param_array(contrast, uint, param_nv[22], 0444);
-module_param_array(whiteness, uint, param_nv[23], 0444);
+module_param_array(video_nr, short, &param_nv[0], 0444);
+module_param_array(packet_size, uint, &param_nv[1], 0444);
+module_param_array(max_buffers, ushort, &param_nv[2], 0444);
+module_param_array(double_buffer, bool, &param_nv[3], 0444);
+module_param_array(clamping, bool, &param_nv[4], 0444);
+module_param_array(filter_type, ushort, &param_nv[5], 0444);
+module_param_array(largeview, bool, &param_nv[6], 0444);
+module_param_array(decompression, ushort, &param_nv[7], 0444);
+module_param_array(upscaling, bool, &param_nv[8], 0444);
+module_param_array(force_palette, ushort, &param_nv[9], 0444);
+module_param_array(force_rgb, ushort, &param_nv[10], 0444);
+module_param_array(autobright, bool, &param_nv[11], 0444);
+module_param_array(autoexp, bool, &param_nv[12], 0444);
+module_param_array(lightfreq, ushort, &param_nv[13], 0444);
+module_param_array(bandingfilter, bool, &param_nv[14], 0444);
+module_param_array(clockdiv, short, &param_nv[15], 0444);
+module_param_array(backlight, bool, &param_nv[16], 0444);
+module_param_array(mirror, bool, &param_nv[17], 0444);
+module_param_array(monochrome, bool, &param_nv[18], 0444);
+module_param_array(brightness, uint, &param_nv[19], 0444);
+module_param_array(hue, uint, &param_nv[20], 0444);
+module_param_array(colour, uint, &param_nv[21], 0444);
+module_param_array(contrast, uint, &param_nv[22], 0444);
+module_param_array(whiteness, uint, &param_nv[23], 0444);
 #ifdef W9968CF_DEBUG
 module_param(debug, ushort, 0644);
 module_param(specific_debug, bool, 0644);
@@ -457,7 +457,6 @@
                                unsigned long arg);
 
 /* Memory management */
-static inline unsigned long kvirt_to_pa(unsigned long adr);
 static void* rvmalloc(unsigned long size);
 static void rvfree(void *mem, unsigned long size);
 static void w9968cf_deallocate_memory(struct w9968cf_device*);
@@ -611,20 +610,6 @@
 /****************************************************************************
  * Memory management functions                                              *
  ****************************************************************************/
-
-/* Here we want the physical address of the memory.
-   This is used when initializing the contents of the area. */
-static inline unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
-
 static void* rvmalloc(unsigned long size)
 {
 	void* mem;
@@ -2919,9 +2904,9 @@
 		return -EINVAL;
 
 	while (vsize > 0) {
-		page = kvirt_to_pa(pos) + vma->vm_pgoff;
-		if (remap_page_range(vma, start, page, PAGE_SIZE, 
-		                     vma->vm_page_prot))
+		page = vmalloc_to_pfn((void *)pos);
+		if (remap_pfn_range(vma, start, page + vma->vm_pgoff,
+						PAGE_SIZE, vma->vm_page_prot))
 			return -EAGAIN;
 		start += PAGE_SIZE;
 		pos += PAGE_SIZE;
diff -Nru a/drivers/usb/media/w9968cf.h b/drivers/usb/media/w9968cf.h
--- a/drivers/usb/media/w9968cf.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/media/w9968cf.h	2004-12-24 13:36:17 -08:00
@@ -135,7 +135,7 @@
 
 #define W9968CF_MODULE_NAME     "V4L driver for W996[87]CF JPEG USB " \
                                 "Dual Mode Camera Chip"
-#define W9968CF_MODULE_VERSION  "1:1.32-basic"
+#define W9968CF_MODULE_VERSION  "1:1.33-basic"
 #define W9968CF_MODULE_AUTHOR   "(C) 2002-2004 Luca Risolia"
 #define W9968CF_AUTHOR_EMAIL    "<luca.risolia@studio.unibo.it>"
 #define W9968CF_MODULE_LICENSE  "GPL"
diff -Nru a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
--- a/drivers/usb/misc/Kconfig	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/misc/Kconfig	2004-12-24 13:37:29 -08:00
@@ -121,17 +121,15 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called cytherm.
 
-config USB_SPEEDTOUCH
-	tristate "Alcatel Speedtouch USB support"
-	depends on USB && ATM
-	select CRC32
+config USB_PHIDGETKIT
+	tristate "USB PhidgetKit support"
+	depends on USB
 	help
-	  Say Y here if you have an Alcatel SpeedTouch USB or SpeedTouch 330
-	  modem.  In order to use your modem you will need to install some user
-	  space tools, see <http://www.linux-usb.org/SpeedTouch/> for details.
+	  Say Y here if you want to connect a PhidgetKit USB device from
+	  Phidgets Inc.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called speedtch.
+	  module will be called phidgetkit.
 
 config USB_PHIDGETSERVO
 	tristate "USB PhidgetServo support"
diff -Nru a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
--- a/drivers/usb/misc/Makefile	2004-12-24 13:36:56 -08:00
+++ b/drivers/usb/misc/Makefile	2004-12-24 13:36:56 -08:00
@@ -10,9 +10,9 @@
 obj-$(CONFIG_USB_LCD)		+= usblcd.o
 obj-$(CONFIG_USB_LED)		+= usbled.o
 obj-$(CONFIG_USB_LEGOTOWER)	+= legousbtower.o
+obj-$(CONFIG_USB_PHIDGETKIT)	+= phidgetkit.o
+obj-$(CONFIG_USB_PHIDGETSERVO)	+= phidgetservo.o
 obj-$(CONFIG_USB_RIO500)	+= rio500.o
-obj-$(CONFIG_USB_SPEEDTOUCH)	+= speedtch.o
 obj-$(CONFIG_USB_TEST)		+= usbtest.o
 obj-$(CONFIG_USB_TIGL)		+= tiglusb.o
 obj-$(CONFIG_USB_USS720)	+= uss720.o
-obj-$(CONFIG_USB_PHIDGETSERVO)	+= phidgetservo.o
diff -Nru a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
--- a/drivers/usb/misc/auerswald.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/misc/auerswald.c	2004-12-24 13:36:48 -08:00
@@ -516,7 +516,7 @@
                 urbp = acep->urbp;
                 urbp->transfer_flags &= ~URB_ASYNC_UNLINK;
                 dbg ("unlink active urb");
-                usb_unlink_urb (urbp);
+                usb_kill_urb (urbp);
         }
 }
 
@@ -1171,22 +1171,16 @@
    endpoint. This function returns 0 if successful or an error code.
    NOTE: no mutex please!
 */
-static int auerswald_int_release (pauerswald_t cp)
+static void auerswald_int_release (pauerswald_t cp)
 {
-        int ret = 0;
         dbg ("auerswald_int_release");
 
         /* stop the int endpoint */
-        if (cp->inturbp) {
-                ret = usb_unlink_urb (cp->inturbp);
-                if (ret)
-	                dbg ("nonzero int unlink result received: %d", ret);
-        }
+        if (cp->inturbp)
+                usb_kill_urb (cp->inturbp);
 
         /* deallocate memory */
         auerswald_int_free (cp);
-
-        return ret;
 }
 
 /* --------------------------------------------------------------------- */
diff -Nru a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
--- a/drivers/usb/misc/legousbtower.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/misc/legousbtower.c	2004-12-24 13:36:48 -08:00
@@ -505,12 +505,12 @@
 		dev->interrupt_in_running = 0;
 		mb();
 		if (dev->interrupt_in_urb != NULL && dev->udev) {
-			usb_unlink_urb (dev->interrupt_in_urb);
+			usb_kill_urb (dev->interrupt_in_urb);
 		}
 	}
 	if (dev->interrupt_out_busy) {
 		if (dev->interrupt_out_urb != NULL && dev->udev) {
-			usb_unlink_urb (dev->interrupt_out_urb);
+			usb_kill_urb (dev->interrupt_out_urb);
 		}
 	}
 
diff -Nru a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/misc/phidgetkit.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,581 @@
+/*
+ * USB PhidgetInterfaceKit driver 1.0
+ *
+ * Copyright (C) 2004 Sean Young <sean@mess.org>
+ * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.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 is a driver for the USB PhidgetInterfaceKit.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/usb.h>
+
+#define DRIVER_AUTHOR "Sean Young <sean@mess.org>"
+#define DRIVER_DESC "USB PhidgetInterfaceKit Driver"
+
+#define USB_VENDOR_ID_GLAB		0x06c2
+#define USB_DEVICE_ID_INTERFACEKIT004	0x0040
+#define USB_DEVICE_ID_INTERFACEKIT888	0x0045
+#define USB_DEVICE_ID_INTERFACEKIT047	0x0051
+#define USB_DEVICE_ID_INTERFACEKIT088	0x0053
+
+#define USB_VENDOR_ID_WISEGROUP		0x0925
+#define USB_DEVICE_ID_INTERFACEKIT884	0x8201
+
+#define MAX_INTERFACES			8
+
+struct driver_interfacekit {
+	int sensors;
+	int inputs;
+	int outputs;
+	int has_lcd;
+};
+#define ifkit(_sensors, _inputs, _outputs, _lcd)			\
+static struct driver_interfacekit ph_##_sensors##_inputs##_outputs = {	\
+	.sensors	= _sensors,					\
+	.inputs		= _inputs,					\
+	.outputs	= _outputs,					\
+	.has_lcd	= _lcd,						\
+};
+ifkit(0, 0, 4, 0);
+ifkit(8, 8, 8, 0);
+ifkit(0, 4, 7, 1);
+ifkit(8, 8, 4, 0);
+ifkit(0, 8, 8, 1);
+
+struct phidget_interfacekit {
+	struct usb_device *udev;
+	struct usb_interface *intf;
+	struct driver_interfacekit *ifkit;
+	int outputs[MAX_INTERFACES];
+	int inputs[MAX_INTERFACES];
+	int sensors[MAX_INTERFACES];
+	u8 lcd_files_on;
+
+	struct urb *irq;
+	unsigned char *data;
+	dma_addr_t data_dma;
+};
+
+static struct usb_device_id id_table[] = {
+	{USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT004),
+		.driver_info = (kernel_ulong_t)&ph_004},
+	{USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT888),
+		.driver_info = (kernel_ulong_t)&ph_888},
+	{USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT047),
+		.driver_info = (kernel_ulong_t)&ph_047},
+	{USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_INTERFACEKIT088),
+		.driver_info = (kernel_ulong_t)&ph_088},
+	{USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_INTERFACEKIT884),
+		.driver_info = (kernel_ulong_t)&ph_884},
+	{}
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
+static int change_outputs(struct phidget_interfacekit *kit, int output_num, int enable)
+{
+	unsigned char *buffer;
+	int retval;
+	int n;
+
+	buffer = kmalloc(4, GFP_KERNEL);
+	if (!buffer) {
+		dev_err(&kit->udev->dev, "%s - out of memory\n",
+			__FUNCTION__);
+		return -ENOMEM;
+	}
+
+	kit->outputs[output_num] = enable;
+	memset(buffer, 0, 4);
+	for (n=0; n<8; n++) {
+		if (kit->outputs[n]) {
+			buffer[0] |= 1 << n;
+		}
+	}
+
+	dev_dbg(&kit->udev->dev, "data: %02x %02x\n", buffer[0], buffer[1]);
+
+	retval = usb_control_msg(kit->udev,
+			 usb_sndctrlpipe(kit->udev, 0),
+			 0x09, 0x21, 0x0200, 0x0000, buffer, 4, 2 * HZ);
+
+	if (retval != 4)
+		dev_err(&kit->udev->dev, "retval = %d\n", retval);
+	kfree(buffer);
+
+	return retval < 0 ? retval : 0;
+}
+
+static int change_string(struct phidget_interfacekit *kit, const char *display, unsigned char row)
+{
+	unsigned char *buffer;
+        unsigned char *form_buffer;
+	int retval = -ENOMEM;
+	int i,j, len, buf_ptr;
+	
+	buffer = kmalloc(8, GFP_KERNEL);
+	form_buffer = kmalloc(30, GFP_KERNEL);
+	if ((!buffer) || (!form_buffer)) {
+		dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__);
+		goto exit;
+	}
+
+	len = strlen(display);
+	if (len > 20)
+		len = 20;
+
+	dev_dbg(&kit->udev->dev, "Setting LCD line %d to %s\n", row, display);
+
+	form_buffer[0] = row * 0x40 + 0x80;
+	form_buffer[1] = 0x02;
+	buf_ptr = 2;
+	for (i = 0; i<len; i++)
+		form_buffer[buf_ptr++] = display[i];
+
+	for (i = 0; i < (20 - len); i++)
+		form_buffer[buf_ptr++] = 0x20;
+	form_buffer[buf_ptr++] = 0x01;
+	form_buffer[buf_ptr++] = row * 0x40 + 0x80 + strlen(display);
+
+	for (i = 0; i < buf_ptr; i += 7) {
+		if ((buf_ptr - i) > 7)
+			len = 7;
+		else
+			len = (buf_ptr - i);
+		for (j = 0; j < len; j++)
+			buffer[j] = form_buffer[i + j];
+		buffer[7] = len;
+
+		retval = usb_control_msg(kit->udev,
+				 usb_sndctrlpipe(kit->udev, 0),
+				 0x09, 0x21, 0x0200, 0x0000, buffer, 8, 2 * HZ);
+		if (retval < 0)
+			goto exit;
+	}
+
+	retval = 0;
+exit:
+	kfree(buffer);
+	kfree(form_buffer);
+
+	return retval;
+}
+
+#define set_lcd_line(number)	\
+static ssize_t lcd_line_##number(struct device *dev, const char *buf, size_t count)	\
+{											\
+	struct usb_interface *intf = to_usb_interface(dev);				\
+	struct phidget_interfacekit *kit = usb_get_intfdata(intf);			\
+	change_string(kit, buf, number - 1);						\
+	return count;									\
+}											\
+static DEVICE_ATTR(lcd_line_##number, S_IWUGO, NULL, lcd_line_##number);
+set_lcd_line(1);
+set_lcd_line(2);
+
+static ssize_t set_backlight(struct device *dev, const char *buf, size_t count)
+{
+	struct usb_interface *intf = to_usb_interface(dev);
+	struct phidget_interfacekit *kit = usb_get_intfdata(intf);
+	int enabled;
+	unsigned char *buffer;
+	int retval = -ENOMEM;
+	
+	buffer = kmalloc(8, GFP_KERNEL);
+	if (!buffer) {
+		dev_err(&kit->udev->dev, "%s - out of memory\n", __FUNCTION__);
+		goto exit;
+	}
+
+	if (sscanf(buf, "%d", &enabled) < 1) {
+		retval = -EINVAL;
+		goto exit;
+	}
+	memset(buffer, 0x00, 8);
+	if (enabled)
+		buffer[0] = 0x01;
+	buffer[7] = 0x11;
+
+	dev_dbg(&kit->udev->dev, "Setting backlight to %s\n", enabled ? "on" : "off");
+	
+	retval = usb_control_msg(kit->udev,
+			 usb_sndctrlpipe(kit->udev, 0),
+			 0x09, 0x21, 0x0200, 0x0000, buffer, 8, 2 * HZ);
+	if (retval < 0)
+		goto exit;
+
+	retval = count;
+exit:
+	kfree(buffer);
+	return retval;
+}
+static DEVICE_ATTR(backlight, S_IWUGO, NULL, set_backlight);
+
+static void remove_lcd_files(struct phidget_interfacekit *kit)
+{
+	if (kit->lcd_files_on) {
+		dev_dbg(&kit->udev->dev, "Removing lcd files\n");
+		device_remove_file(&kit->intf->dev, &dev_attr_lcd_line_1);
+		device_remove_file(&kit->intf->dev, &dev_attr_lcd_line_2);
+		device_remove_file(&kit->intf->dev, &dev_attr_backlight);
+	}
+}
+
+static ssize_t enable_lcd_files(struct device *dev, const char *buf, size_t count)
+{
+	struct usb_interface *intf = to_usb_interface(dev);
+	struct phidget_interfacekit *kit = usb_get_intfdata(intf);
+	int enable;
+	
+	if (kit->ifkit->has_lcd == 0)
+		return -ENODEV;
+
+	if (sscanf(buf, "%d", &enable) < 1)
+		return -EINVAL;
+
+	if (enable) {
+		if (!kit->lcd_files_on) {
+			dev_dbg(&kit->udev->dev, "Adding lcd files\n");
+			device_create_file(&kit->intf->dev, &dev_attr_lcd_line_1);
+			device_create_file(&kit->intf->dev, &dev_attr_lcd_line_2);
+			device_create_file(&kit->intf->dev, &dev_attr_backlight);
+			kit->lcd_files_on = 1;
+		}
+	} else {
+		if (kit->lcd_files_on) {
+			remove_lcd_files(kit);
+			kit->lcd_files_on = 0;
+		}
+	}
+	
+	return count;
+}
+static DEVICE_ATTR(lcd, S_IWUGO, NULL, enable_lcd_files);
+
+static void interfacekit_irq(struct urb *urb, struct pt_regs *regs)
+{
+	struct phidget_interfacekit *kit = urb->context;
+	unsigned char *buffer = kit->data;
+	int status;
+	int n;
+
+	switch (urb->status) {
+	case 0:			/* success */
+		break;
+	case -ECONNRESET:	/* unlink */
+	case -ENOENT:
+	case -ESHUTDOWN:
+		return;
+	/* -EPIPE:  should clear the halt */
+	default:		/* error */
+		goto resubmit;
+	}
+
+	for (n=0; n<8; n++) {
+		kit->inputs[n] = buffer[1] & (1 << n) ? 1 : 0;
+	}
+
+	if (buffer[0] & 1) {
+		kit->sensors[4] = buffer[2] + (buffer[3] & 0x0f) * 256;
+		kit->sensors[5] = buffer[4] + (buffer[3] & 0xf0) * 16;
+		kit->sensors[6] = buffer[5] + (buffer[6] & 0x0f) * 256;
+		kit->sensors[7] = buffer[7] + (buffer[6] & 0xf0) * 16;
+	} else {
+		kit->sensors[0] = buffer[2] + (buffer[3] & 0x0f) * 256;
+		kit->sensors[1] = buffer[4] + (buffer[3] & 0xf0) * 16;
+		kit->sensors[2] = buffer[5] + (buffer[6] & 0x0f) * 256;
+		kit->sensors[3] = buffer[7] + (buffer[6] & 0xf0) * 16;
+	}
+
+resubmit:
+	status = usb_submit_urb(urb, SLAB_ATOMIC);
+	if (status)
+		err("can't resubmit intr, %s-%s/interfacekit0, status %d",
+			kit->udev->bus->bus_name,
+			kit->udev->devpath, status);
+}
+
+#define show_set_output(value)		\
+static ssize_t set_output##value(struct device *dev, const char *buf, 	\
+							size_t count)	\
+{									\
+	struct usb_interface *intf = to_usb_interface(dev);		\
+	struct phidget_interfacekit *kit = usb_get_intfdata(intf);	\
+	int enabled;							\
+	int retval;							\
+									\
+	if (sscanf(buf, "%d", &enabled) < 1) {				\
+		return -EINVAL;						\
+	}								\
+									\
+	retval = change_outputs(kit, value - 1, enabled ? 1 : 0);	\
+									\
+	return retval ? retval : count;					\
+}									\
+									\
+static ssize_t show_output##value(struct device *dev, char *buf)	\
+{									\
+	struct usb_interface *intf = to_usb_interface(dev);		\
+	struct phidget_interfacekit *kit = usb_get_intfdata(intf);	\
+									\
+	return sprintf(buf, "%d\n", kit->outputs[value - 1 ]);		\
+}									\
+static DEVICE_ATTR(output##value, S_IWUGO | S_IRUGO,			\
+		show_output##value, set_output##value);
+show_set_output(1);
+show_set_output(2);
+show_set_output(3);
+show_set_output(4);
+show_set_output(5);
+show_set_output(6);
+show_set_output(7);
+show_set_output(8);	/* should be MAX_INTERFACES - 1 */
+
+#define show_input(value)	\
+static ssize_t show_input##value(struct device *dev, char *buf)	\
+{									\
+	struct usb_interface *intf = to_usb_interface(dev);		\
+	struct phidget_interfacekit *kit = usb_get_intfdata(intf);	\
+									\
+	return sprintf(buf, "%d\n", kit->inputs[value - 1]);		\
+}									\
+static DEVICE_ATTR(input##value, S_IRUGO, show_input##value, NULL);
+
+show_input(1);
+show_input(2);
+show_input(3);
+show_input(4);
+show_input(5);
+show_input(6);
+show_input(7);
+show_input(8);		/* should be MAX_INTERFACES - 1 */
+
+#define show_sensor(value)	\
+static ssize_t show_sensor##value(struct device *dev, char *buf)	\
+{									\
+	struct usb_interface *intf = to_usb_interface(dev);		\
+	struct phidget_interfacekit *kit = usb_get_intfdata(intf);	\
+									\
+	return sprintf(buf, "%d\n", kit->sensors[value - 1]);		\
+}									\
+static DEVICE_ATTR(sensor##value, S_IRUGO, show_sensor##value, NULL);
+
+show_sensor(1);
+show_sensor(2);
+show_sensor(3);
+show_sensor(4);
+show_sensor(5);
+show_sensor(6);
+show_sensor(7);
+show_sensor(8);		/* should be MAX_INTERFACES - 1 */
+
+static int interfacekit_probe(struct usb_interface *intf, const struct usb_device_id *id)
+{
+	struct usb_device *dev = interface_to_usbdev(intf);
+	struct usb_host_interface *interface;
+	struct usb_endpoint_descriptor *endpoint;
+	struct phidget_interfacekit *kit;
+	struct driver_interfacekit *ifkit;
+	int pipe, maxp;
+
+	ifkit = (struct driver_interfacekit *)id->driver_info;
+	if (!ifkit)
+		return -ENODEV;
+
+	interface = intf->cur_altsetting;
+	if (interface->desc.bNumEndpoints != 1)
+		return -ENODEV;
+
+	endpoint = &interface->endpoint[0].desc;
+	if (!(endpoint->bEndpointAddress & 0x80)) 
+		return -ENODEV;
+	/*
+	 * bmAttributes
+	 */
+	pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
+	maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
+	
+	kit = kmalloc(sizeof(*kit), GFP_KERNEL);
+	if (kit  == NULL) {
+		dev_err(&intf->dev, "%s - out of memory\n", __FUNCTION__);
+		return -ENOMEM;
+	}
+	memset(kit, 0, sizeof(*kit));
+	kit->ifkit = ifkit;
+
+	kit->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kit->data_dma);
+	if (!kit->data) {
+		kfree(kit);
+		return -ENOMEM;
+	}
+
+	kit->irq = usb_alloc_urb(0, GFP_KERNEL);
+	if (!kit->irq) {
+		usb_buffer_free(dev, 8, kit->data, kit->data_dma);
+		kfree(kit);
+		return -ENOMEM;
+	}
+
+	kit->udev = usb_get_dev(dev);
+	kit->intf = intf;
+	usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data,
+			(maxp > 8 ? 8 : maxp),
+			interfacekit_irq, kit, endpoint->bInterval);
+	kit->irq->transfer_dma = kit->data_dma;
+	kit->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+
+	usb_set_intfdata(intf, kit);
+
+	if (usb_submit_urb(kit->irq, GFP_KERNEL)) {
+		return -EIO;
+	}
+
+	if (ifkit->outputs == 8) {
+		device_create_file(&intf->dev, &dev_attr_output1);
+		device_create_file(&intf->dev, &dev_attr_output2);
+		device_create_file(&intf->dev, &dev_attr_output3);
+		device_create_file(&intf->dev, &dev_attr_output4);
+		device_create_file(&intf->dev, &dev_attr_output5);
+		device_create_file(&intf->dev, &dev_attr_output6);
+		device_create_file(&intf->dev, &dev_attr_output7);
+		device_create_file(&intf->dev, &dev_attr_output8);
+	} 
+
+	if (ifkit->inputs >= 4) {
+		device_create_file(&intf->dev, &dev_attr_input1);
+		device_create_file(&intf->dev, &dev_attr_input2);
+		device_create_file(&intf->dev, &dev_attr_input3);
+		device_create_file(&intf->dev, &dev_attr_input4);
+	}
+	if (ifkit->inputs == 8) {
+		device_create_file(&intf->dev, &dev_attr_input5);
+		device_create_file(&intf->dev, &dev_attr_input6);
+		device_create_file(&intf->dev, &dev_attr_input7);
+		device_create_file(&intf->dev, &dev_attr_input8);
+	}
+
+	if (ifkit->sensors >= 4) {
+		device_create_file(&intf->dev, &dev_attr_sensor1);
+		device_create_file(&intf->dev, &dev_attr_sensor2);
+		device_create_file(&intf->dev, &dev_attr_sensor3);
+		device_create_file(&intf->dev, &dev_attr_sensor4);
+	}
+	if (ifkit->sensors >= 7) {
+		device_create_file(&intf->dev, &dev_attr_sensor5);
+		device_create_file(&intf->dev, &dev_attr_sensor6);
+		device_create_file(&intf->dev, &dev_attr_sensor7);
+	}
+	if (ifkit->sensors == 8) {
+		device_create_file(&intf->dev, &dev_attr_sensor8);
+	}
+
+	if (ifkit->has_lcd)
+		device_create_file(&intf->dev, &dev_attr_lcd);
+
+	dev_info(&intf->dev, "USB PhidgetInterfaceKit %d/%d/%d attached\n",
+			ifkit->inputs, ifkit->outputs, ifkit->sensors);
+
+	return 0;
+}
+
+static void interfacekit_disconnect(struct usb_interface *interface)
+{
+	struct phidget_interfacekit *kit;
+
+	kit = usb_get_intfdata(interface);
+	usb_set_intfdata(interface, NULL);
+	if (!kit)
+		return;
+
+	if (kit->ifkit->outputs == MAX_INTERFACES) {
+		device_remove_file(&interface->dev, &dev_attr_output1);
+		device_remove_file(&interface->dev, &dev_attr_output2);
+		device_remove_file(&interface->dev, &dev_attr_output3);
+		device_remove_file(&interface->dev, &dev_attr_output4);
+		device_remove_file(&interface->dev, &dev_attr_output5);
+		device_remove_file(&interface->dev, &dev_attr_output6);
+		device_remove_file(&interface->dev, &dev_attr_output7);
+		device_remove_file(&interface->dev, &dev_attr_output7);
+	}
+
+	if (kit->ifkit->inputs >= 4) {
+		device_remove_file(&interface->dev, &dev_attr_input1);
+		device_remove_file(&interface->dev, &dev_attr_input2);
+		device_remove_file(&interface->dev, &dev_attr_input3);
+		device_remove_file(&interface->dev, &dev_attr_input4);
+	}
+	if (kit->ifkit->inputs == 8) {
+		device_remove_file(&interface->dev, &dev_attr_input5);
+		device_remove_file(&interface->dev, &dev_attr_input6);
+		device_remove_file(&interface->dev, &dev_attr_input7);
+		device_remove_file(&interface->dev, &dev_attr_input8);
+	}
+
+	if (kit->ifkit->sensors >= 4) {
+		device_remove_file(&interface->dev, &dev_attr_sensor1);
+		device_remove_file(&interface->dev, &dev_attr_sensor2);
+		device_remove_file(&interface->dev, &dev_attr_sensor3);
+		device_remove_file(&interface->dev, &dev_attr_sensor4);
+	}
+	if (kit->ifkit->sensors >= 7) {
+		device_remove_file(&interface->dev, &dev_attr_sensor5);
+		device_remove_file(&interface->dev, &dev_attr_sensor6);
+		device_remove_file(&interface->dev, &dev_attr_sensor7);
+	}
+	if (kit->ifkit->sensors == 8) {
+		device_remove_file(&interface->dev, &dev_attr_sensor8);
+	}
+	if (kit->ifkit->has_lcd)
+		device_create_file(&interface->dev, &dev_attr_lcd);
+
+	dev_info(&interface->dev, "USB PhidgetInterfaceKit %d/%d/%d detached\n",
+		kit->ifkit->inputs, kit->ifkit->outputs, kit->ifkit->sensors);
+
+	usb_kill_urb(kit->irq);
+	usb_free_urb(kit->irq);
+	usb_buffer_free(kit->udev, 8, kit->data, kit->data_dma);
+
+	usb_put_dev(kit->udev);
+	kfree(kit);
+}
+
+static struct usb_driver interfacekit_driver = {
+	.owner = THIS_MODULE,
+	.name = "phidgetkit",
+	.probe = interfacekit_probe,
+	.disconnect = interfacekit_disconnect,
+	.id_table = id_table
+};
+
+static int __init interfacekit_init(void)
+{
+	int retval = 0;
+
+	retval = usb_register(&interfacekit_driver);
+	if (retval)
+		err("usb_register failed. Error number %d", retval);
+
+	return retval;
+}
+
+static void __exit interfacekit_exit(void)
+{
+	usb_deregister(&interfacekit_driver);
+}
+
+module_init(interfacekit_init);
+module_exit(interfacekit_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
--- a/drivers/usb/misc/rio500.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/usb/misc/rio500.c	2004-12-24 13:37:00 -08:00
@@ -170,13 +170,11 @@
 			if (result == -ETIMEDOUT)
 				retries--;
 			else if (result < 0) {
-				err("Error executing ioctrl. code = %d",
-				     le32_to_cpu(result));
+				err("Error executing ioctrl. code = %d", result);
 				retries = 0;
 			} else {
-				dbg("Executed ioctl. Result = %d (data=%04x)",
-				     le32_to_cpu(result),
-				     le32_to_cpu(*((long *) buffer)));
+				dbg("Executed ioctl. Result = %d (data=%02x)",
+				     result, buffer[0]);
 				if (copy_to_user(rio_cmd.buffer, buffer,
 						 rio_cmd.length)) {
 					free_page((unsigned long) buffer);
@@ -239,12 +237,10 @@
 			if (result == -ETIMEDOUT)
 				retries--;
 			else if (result < 0) {
-				err("Error executing ioctrl. code = %d",
-				     le32_to_cpu(result));
+				err("Error executing ioctrl. code = %d", result);
 				retries = 0;
 			} else {
-				dbg("Executed ioctl. Result = %d",
-				       le32_to_cpu(result));
+				dbg("Executed ioctl. Result = %d", result);
 				retries = 0;
 
 			}
diff -Nru a/drivers/usb/misc/speedtch.c b/drivers/usb/misc/speedtch.c
--- a/drivers/usb/misc/speedtch.c	2004-12-24 13:37:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1373 +0,0 @@
-/******************************************************************************
- *  speedtouch.c  -  Alcatel SpeedTouch USB xDSL modem driver
- *
- *  Copyright (C) 2001, Alcatel
- *  Copyright (C) 2003, Duncan Sands
- *
- *  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.
- *
- ******************************************************************************/
-
-/*
- *  Written by Johan Verrept, maintained by Duncan Sands (duncan.sands@free.fr)
- *
- *  1.7+:	- See the check-in logs
- *
- *  1.6:	- No longer opens a connection if the firmware is not loaded
- *  		- Added support for the speedtouch 330
- *  		- Removed the limit on the number of devices
- *  		- Module now autoloads on device plugin
- *  		- Merged relevant parts of sarlib
- *  		- Replaced the kernel thread with a tasklet
- *  		- New packet transmission code
- *  		- Changed proc file contents
- *  		- Fixed all known SMP races
- *  		- Many fixes and cleanups
- *  		- Various fixes by Oliver Neukum (oliver@neukum.name)
- *
- *  1.5A:	- Version for inclusion in 2.5 series kernel
- *		- Modifications by Richard Purdie (rpurdie@rpsys.net)
- *		- made compatible with kernel 2.5.6 onwards by changing
- *		udsl_usb_send_data_context->urb to a pointer and adding code
- *		to alloc and free it
- *		- remove_wait_queue() added to udsl_atm_processqueue_thread()
- *
- *  1.5:	- fixed memory leak when atmsar_decode_aal5 returned NULL.
- *		(reported by stephen.robinson@zen.co.uk)
- *
- *  1.4:	- changed the spin_lock() under interrupt to spin_lock_irqsave()
- *		- unlink all active send urbs of a vcc that is being closed.
- *
- *  1.3.1:	- added the version number
- *
- *  1.3:	- Added multiple send urb support
- *		- fixed memory leak and vcc->tx_inuse starvation bug
- *		  when not enough memory left in vcc.
- *
- *  1.2:	- Fixed race condition in udsl_usb_send_data()
- *  1.1:	- Turned off packet debugging
- *
- */
-
-#include <asm/semaphore.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/errno.h>
-#include <linux/proc_fs.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-#include <asm/uaccess.h>
-#include <linux/smp_lock.h>
-#include <linux/interrupt.h>
-#include <linux/atm.h>
-#include <linux/atmdev.h>
-#include <linux/crc32.h>
-#include <linux/init.h>
-
-/*
-#define DEBUG
-#define VERBOSE_DEBUG
-*/
-
-#if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
-#	define DEBUG
-#endif
-
-#include <linux/usb.h>
-
-#ifdef DEBUG
-#define DEBUG_ON(x)	BUG_ON(x)
-#else
-#define DEBUG_ON(x)	do { if (x); } while (0)
-#endif
-
-#ifdef VERBOSE_DEBUG
-static int udsl_print_packet (const unsigned char *data, int len);
-#define PACKETDEBUG(arg...)	udsl_print_packet (arg)
-#define vdbg(arg...)		dbg (arg)
-#else
-#define PACKETDEBUG(arg...)
-#define vdbg(arg...)
-#endif
-
-#define DRIVER_AUTHOR	"Johan Verrept, Duncan Sands <duncan.sands@free.fr>"
-#define DRIVER_VERSION	"1.8"
-#define DRIVER_DESC	"Alcatel SpeedTouch USB driver version " DRIVER_VERSION
-
-static const char udsl_driver_name [] = "speedtch";
-
-#define SPEEDTOUCH_VENDORID		0x06b9
-#define SPEEDTOUCH_PRODUCTID		0x4061
-
-#define UDSL_MAX_RCV_URBS		4
-#define UDSL_MAX_SND_URBS		4
-#define UDSL_MAX_RCV_BUFS		8
-#define UDSL_MAX_SND_BUFS		8
-#define UDSL_MAX_RCV_BUF_SIZE		1024 /* ATM cells */
-#define UDSL_MAX_SND_BUF_SIZE		1024 /* ATM cells */
-#define UDSL_DEFAULT_RCV_URBS		2
-#define UDSL_DEFAULT_SND_URBS		2
-#define UDSL_DEFAULT_RCV_BUFS		4
-#define UDSL_DEFAULT_SND_BUFS		4
-#define UDSL_DEFAULT_RCV_BUF_SIZE	64 /* ATM cells */
-#define UDSL_DEFAULT_SND_BUF_SIZE	64 /* ATM cells */
-
-static unsigned int num_rcv_urbs = UDSL_DEFAULT_RCV_URBS;
-static unsigned int num_snd_urbs = UDSL_DEFAULT_SND_URBS;
-static unsigned int num_rcv_bufs = UDSL_DEFAULT_RCV_BUFS;
-static unsigned int num_snd_bufs = UDSL_DEFAULT_SND_BUFS;
-static unsigned int rcv_buf_size = UDSL_DEFAULT_RCV_BUF_SIZE;
-static unsigned int snd_buf_size = UDSL_DEFAULT_SND_BUF_SIZE;
-
-module_param (num_rcv_urbs, uint, 0444);
-MODULE_PARM_DESC (num_rcv_urbs, "Number of urbs used for reception (range: 0-" __MODULE_STRING (UDSL_MAX_RCV_URBS) ", default: " __MODULE_STRING (UDSL_DEFAULT_RCV_URBS) ")");
-
-module_param (num_snd_urbs, uint, 0444);
-MODULE_PARM_DESC (num_snd_urbs, "Number of urbs used for transmission (range: 0-" __MODULE_STRING (UDSL_MAX_SND_URBS) ", default: " __MODULE_STRING (UDSL_DEFAULT_SND_URBS) ")");
-
-module_param (num_rcv_bufs, uint, 0444);
-MODULE_PARM_DESC (num_rcv_bufs, "Number of buffers used for reception (range: 0-" __MODULE_STRING (UDSL_MAX_RCV_BUFS) ", default: " __MODULE_STRING (UDSL_DEFAULT_RCV_BUFS) ")");
-
-module_param (num_snd_bufs, uint, 0444);
-MODULE_PARM_DESC (num_snd_bufs, "Number of buffers used for transmission (range: 0-" __MODULE_STRING (UDSL_MAX_SND_BUFS) ", default: " __MODULE_STRING (UDSL_DEFAULT_SND_BUFS) ")");
-
-module_param (rcv_buf_size, uint, 0444);
-MODULE_PARM_DESC (rcv_buf_size, "Size of the buffers used for reception (range: 0-" __MODULE_STRING (UDSL_MAX_RCV_BUF_SIZE) ", default: " __MODULE_STRING (UDSL_DEFAULT_RCV_BUF_SIZE) ")");
-
-module_param (snd_buf_size, uint, 0444);
-MODULE_PARM_DESC (snd_buf_size, "Size of the buffers used for transmission (range: 0-" __MODULE_STRING (UDSL_MAX_SND_BUF_SIZE) ", default: " __MODULE_STRING (UDSL_DEFAULT_SND_BUF_SIZE) ")");
-
-#define UDSL_IOCTL_LINE_UP		1
-#define UDSL_IOCTL_LINE_DOWN		2
-
-#define UDSL_ENDPOINT_DATA_OUT		0x07
-#define UDSL_ENDPOINT_DATA_IN		0x87
-
-#define ATM_CELL_HEADER			(ATM_CELL_SIZE - ATM_CELL_PAYLOAD)
-#define UDSL_NUM_CELLS(x)		(((x) + ATM_AAL5_TRAILER + ATM_CELL_PAYLOAD - 1) / ATM_CELL_PAYLOAD)
-
-#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) )
-
-static struct usb_device_id udsl_usb_ids [] = {
-	{ USB_DEVICE (SPEEDTOUCH_VENDORID, SPEEDTOUCH_PRODUCTID) },
-	{ }
-};
-
-MODULE_DEVICE_TABLE (usb, udsl_usb_ids);
-
-/* receive */
-
-struct udsl_receive_buffer {
-	struct list_head list;
-	unsigned char *base;
-	unsigned int filled_cells;
-};
-
-struct udsl_receiver {
-	struct list_head list;
-	struct udsl_receive_buffer *buffer;
-	struct urb *urb;
-	struct udsl_instance_data *instance;
-};
-
-struct udsl_vcc_data {
-	/* vpi/vci lookup */
-	struct list_head list;
-	short vpi;
-	int vci;
-	struct atm_vcc *vcc;
-
-	/* raw cell reassembly */
-	struct sk_buff *sarb;
-};
-
-/* send */
-
-struct udsl_send_buffer {
-	struct list_head list;
-	unsigned char *base;
-	unsigned char *free_start;
-	unsigned int free_cells;
-};
-
-struct udsl_sender {
-	struct list_head list;
-	struct udsl_send_buffer *buffer;
-	struct urb *urb;
-	struct udsl_instance_data *instance;
-};
-
-struct udsl_control {
-	struct atm_skb_data atm_data;
-	unsigned int num_cells;
-	unsigned int num_entire;
-	unsigned int pdu_padding;
-	unsigned char cell_header [ATM_CELL_HEADER];
-	unsigned char aal5_trailer [ATM_AAL5_TRAILER];
-};
-
-#define UDSL_SKB(x)		((struct udsl_control *)(x)->cb)
-
-/* main driver data */
-
-struct udsl_instance_data {
-	struct semaphore serialize;
-
-	/* USB device part */
-	struct usb_device *usb_dev;
-	char description [64];
-	int firmware_loaded;
-
-	/* ATM device part */
-	struct atm_dev *atm_dev;
-	struct list_head vcc_list;
-
-	/* receive */
-	struct udsl_receiver receivers [UDSL_MAX_RCV_URBS];
-	struct udsl_receive_buffer receive_buffers [UDSL_MAX_RCV_BUFS];
-
-	spinlock_t receive_lock;
-	struct list_head spare_receivers;
-	struct list_head filled_receive_buffers;
-
-	struct tasklet_struct receive_tasklet;
-	struct list_head spare_receive_buffers;
-
-	/* send */
-	struct udsl_sender senders [UDSL_MAX_SND_URBS];
-	struct udsl_send_buffer send_buffers [UDSL_MAX_SND_BUFS];
-
-	struct sk_buff_head sndqueue;
-
-	spinlock_t send_lock;
-	struct list_head spare_senders;
-	struct list_head spare_send_buffers;
-
-	struct tasklet_struct send_tasklet;
-	struct sk_buff *current_skb;			/* being emptied */
-	struct udsl_send_buffer *current_buffer;	/* being filled */
-	struct list_head filled_send_buffers;
-};
-
-/* ATM */
-
-static void udsl_atm_dev_close (struct atm_dev *dev);
-static int udsl_atm_open (struct atm_vcc *vcc);
-static void udsl_atm_close (struct atm_vcc *vcc);
-static int udsl_atm_ioctl (struct atm_dev *dev, unsigned int cmd, void __user *arg);
-static int udsl_atm_send (struct atm_vcc *vcc, struct sk_buff *skb);
-static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page);
-
-static struct atmdev_ops udsl_atm_devops = {
-	.dev_close =	udsl_atm_dev_close,
-	.open =		udsl_atm_open,
-	.close =	udsl_atm_close,
-	.ioctl =	udsl_atm_ioctl,
-	.send =		udsl_atm_send,
-	.proc_read =	udsl_atm_proc_read,
-	.owner =	THIS_MODULE,
-};
-
-/* USB */
-
-static int udsl_usb_probe (struct usb_interface *intf, const struct usb_device_id *id);
-static void udsl_usb_disconnect (struct usb_interface *intf);
-static int udsl_usb_ioctl (struct usb_interface *intf, unsigned int code, void *user_data);
-
-static struct usb_driver udsl_usb_driver = {
-	.owner =	THIS_MODULE,
-	.name =		udsl_driver_name,
-	.probe =	udsl_usb_probe,
-	.disconnect =	udsl_usb_disconnect,
-	.ioctl =	udsl_usb_ioctl,
-	.id_table =	udsl_usb_ids,
-};
-
-
-/***********
-**  misc  **
-***********/
-
-static inline void udsl_pop (struct atm_vcc *vcc, struct sk_buff *skb)
-{
-	if (vcc->pop)
-		vcc->pop (vcc, skb);
-	else
-		dev_kfree_skb (skb);
-}
-
-
-/*************
-**  decode  **
-*************/
-
-static inline struct udsl_vcc_data *udsl_find_vcc (struct udsl_instance_data *instance, short vpi, int vci)
-{
-	struct udsl_vcc_data *vcc;
-
-	list_for_each_entry (vcc, &instance->vcc_list, list)
-		if ((vcc->vci == vci) && (vcc->vpi == vpi))
-			return vcc;
-	return NULL;
-}
-
-static void udsl_extract_cells (struct udsl_instance_data *instance, unsigned char *source, unsigned int howmany)
-{
-	struct udsl_vcc_data *cached_vcc = NULL;
-	struct atm_vcc *vcc;
-	struct sk_buff *sarb;
-	struct udsl_vcc_data *vcc_data;
-	int cached_vci = 0;
-	unsigned int i;
-	int pti;
-	int vci;
-	short cached_vpi = 0;
-	short vpi;
-
-	for (i = 0; i < howmany; i++, source += ATM_CELL_SIZE) {
-		vpi = ((source [0] & 0x0f) << 4) | (source [1] >> 4);
-		vci = ((source [1] & 0x0f) << 12) | (source [2] << 4) | (source [3] >> 4);
-		pti = (source [3] & 0x2) != 0;
-
-		vdbg ("udsl_extract_cells: vpi %hd, vci %d, pti %d", vpi, vci, pti);
-
-		if (cached_vcc && (vci == cached_vci) && (vpi == cached_vpi))
-			vcc_data = cached_vcc;
-		else if ((vcc_data = udsl_find_vcc (instance, vpi, vci))) {
-			cached_vcc = vcc_data;
-			cached_vpi = vpi;
-			cached_vci = vci;
-		} else {
-			dbg ("udsl_extract_cells: unknown vpi/vci (%hd/%d)!", vpi, vci);
-			continue;
-		}
-
-		vcc = vcc_data->vcc;
-		sarb = vcc_data->sarb;
-
-		if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) {
-			dbg ("udsl_extract_cells: buffer overrun (sarb->len %u, vcc: 0x%p)!", sarb->len, vcc);
-			/* discard cells already received */
-			skb_trim (sarb, 0);
-		}
-
-		memcpy (sarb->tail, source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD);
-		__skb_put (sarb, ATM_CELL_PAYLOAD);
-
-		if (pti) {
-			struct sk_buff *skb;
-			unsigned int length;
-			unsigned int pdu_length;
-
-			length = (source [ATM_CELL_SIZE - 6] << 8) + source [ATM_CELL_SIZE - 5];
-
-			/* guard against overflow */
-			if (length > ATM_MAX_AAL5_PDU) {
-				dbg ("udsl_extract_cells: bogus length %u (vcc: 0x%p)!", length, vcc);
-				atomic_inc (&vcc->stats->rx_err);
-				goto out;
-			}
-
-			pdu_length = UDSL_NUM_CELLS (length) * ATM_CELL_PAYLOAD;
-
-			if (sarb->len < pdu_length) {
-				dbg ("udsl_extract_cells: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!", pdu_length, sarb->len, vcc);
-				atomic_inc (&vcc->stats->rx_err);
-				goto out;
-			}
-
-			if (crc32_be (~0, sarb->tail - pdu_length, pdu_length) != 0xc704dd7b) {
-				dbg ("udsl_extract_cells: packet failed crc check (vcc: 0x%p)!", vcc);
-				atomic_inc (&vcc->stats->rx_err);
-				goto out;
-			}
-
-			vdbg ("udsl_extract_cells: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", length, pdu_length, vcc);
-
-			if (!(skb = dev_alloc_skb (length))) {
-				dbg ("udsl_extract_cells: no memory for skb (length: %u)!", length);
-				atomic_inc (&vcc->stats->rx_drop);
-				goto out;
-			}
-
-			vdbg ("udsl_extract_cells: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", skb, skb->truesize);
-
-			if (!atm_charge (vcc, skb->truesize)) {
-				dbg ("udsl_extract_cells: failed atm_charge (skb->truesize: %u)!", skb->truesize);
-				dev_kfree_skb (skb);
-				goto out; /* atm_charge increments rx_drop */
-			}
-
-			memcpy (skb->data, sarb->tail - pdu_length, length);
-			__skb_put (skb, length);
-
-			vdbg ("udsl_extract_cells: sending skb 0x%p, skb->len %u, skb->truesize %u", skb, skb->len, skb->truesize);
-
-			PACKETDEBUG (skb->data, skb->len);
-
-			vcc->push (vcc, skb);
-
-			atomic_inc (&vcc->stats->rx);
-out:
-			skb_trim (sarb, 0);
-		}
-	}
-}
-
-
-/*************
-**  encode  **
-*************/
-
-static const unsigned char zeros [ATM_CELL_PAYLOAD];
-
-static void udsl_groom_skb (struct atm_vcc *vcc, struct sk_buff *skb)
-{
-	struct udsl_control *ctrl = UDSL_SKB (skb);
-	unsigned int zero_padding;
-	u32 crc;
-
-	ctrl->atm_data.vcc = vcc;
-	ctrl->cell_header [0] = vcc->vpi >> 4;
-	ctrl->cell_header [1] = (vcc->vpi << 4) | (vcc->vci >> 12);
-	ctrl->cell_header [2] = vcc->vci >> 4;
-	ctrl->cell_header [3] = vcc->vci << 4;
-	ctrl->cell_header [4] = 0xec;
-
-	ctrl->num_cells = UDSL_NUM_CELLS (skb->len);
-	ctrl->num_entire = skb->len / ATM_CELL_PAYLOAD;
-
-	zero_padding = ctrl->num_cells * ATM_CELL_PAYLOAD - skb->len - ATM_AAL5_TRAILER;
-
-	if (ctrl->num_entire + 1 < ctrl->num_cells)
-		ctrl->pdu_padding = zero_padding - (ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER);
-	else
-		ctrl->pdu_padding = zero_padding;
-
-	ctrl->aal5_trailer [0] = 0; /* UU = 0 */
-	ctrl->aal5_trailer [1] = 0; /* CPI = 0 */
-	ctrl->aal5_trailer [2] = skb->len >> 8;
-	ctrl->aal5_trailer [3] = skb->len;
-
-	crc = crc32_be (~0, skb->data, skb->len);
-	crc = crc32_be (crc, zeros, zero_padding);
-	crc = crc32_be (crc, ctrl->aal5_trailer, 4);
-	crc = ~crc;
-
-	ctrl->aal5_trailer [4] = crc >> 24;
-	ctrl->aal5_trailer [5] = crc >> 16;
-	ctrl->aal5_trailer [6] = crc >> 8;
-	ctrl->aal5_trailer [7] = crc;
-}
-
-static unsigned int udsl_write_cells (unsigned int howmany, struct sk_buff *skb, unsigned char **target_p)
-{
-	struct udsl_control *ctrl = UDSL_SKB (skb);
-	unsigned char *target = *target_p;
-	unsigned int nc, ne, i;
-
-	vdbg ("udsl_write_cells: howmany=%u, skb->len=%d, num_cells=%u, num_entire=%u, pdu_padding=%u", howmany, skb->len, ctrl->num_cells, ctrl->num_entire, ctrl->pdu_padding);
-
-	nc = ctrl->num_cells;
-	ne = min (howmany, ctrl->num_entire);
-
-	for (i = 0; i < ne; i++) {
-		memcpy (target, ctrl->cell_header, ATM_CELL_HEADER);
-		target += ATM_CELL_HEADER;
-		memcpy (target, skb->data, ATM_CELL_PAYLOAD);
-		target += ATM_CELL_PAYLOAD;
-		__skb_pull (skb, ATM_CELL_PAYLOAD);
-	}
-
-	ctrl->num_entire -= ne;
-
-	if (!(ctrl->num_cells -= ne) || !(howmany -= ne))
-		goto out;
-
-	memcpy (target, ctrl->cell_header, ATM_CELL_HEADER);
-	target += ATM_CELL_HEADER;
-	memcpy (target, skb->data, skb->len);
-	target += skb->len;
-	__skb_pull (skb, skb->len);
-	memset (target, 0, ctrl->pdu_padding);
-	target += ctrl->pdu_padding;
-
-	if (--ctrl->num_cells) {
-		if (!--howmany) {
-			ctrl->pdu_padding = ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER;
-			goto out;
-		}
-
-		memcpy (target, ctrl->cell_header, ATM_CELL_HEADER);
-		target += ATM_CELL_HEADER;
-		memset (target, 0, ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER);
-		target += ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER;
-
-		DEBUG_ON (--ctrl->num_cells);
-	}
-
-	memcpy (target, ctrl->aal5_trailer, ATM_AAL5_TRAILER);
-	target += ATM_AAL5_TRAILER;
-	/* set pti bit in last cell */
-	*(target + 3 - ATM_CELL_SIZE) |= 0x2;
-
-out:
-	*target_p = target;
-	return nc - ctrl->num_cells;
-}
-
-
-/**************
-**  receive  **
-**************/
-
-static void udsl_complete_receive (struct urb *urb, struct pt_regs *regs)
-{
-	struct udsl_receive_buffer *buf;
-	struct udsl_instance_data *instance;
-	struct udsl_receiver *rcv;
-	unsigned long flags;
-
-	if (!urb || !(rcv = urb->context)) {
-		dbg ("udsl_complete_receive: bad urb!");
-		return;
-	}
-
-	instance = rcv->instance;
-	buf = rcv->buffer;
-
-	buf->filled_cells = urb->actual_length / ATM_CELL_SIZE;
-
-	vdbg ("udsl_complete_receive: urb 0x%p, status %d, actual_length %d, filled_cells %u, rcv 0x%p, buf 0x%p", urb, urb->status, urb->actual_length, buf->filled_cells, rcv, buf);
-
-	DEBUG_ON (buf->filled_cells > rcv_buf_size);
-
-	/* may not be in_interrupt() */
-	spin_lock_irqsave (&instance->receive_lock, flags);
-	list_add (&rcv->list, &instance->spare_receivers);
-	list_add_tail (&buf->list, &instance->filled_receive_buffers);
-	if (likely (!urb->status))
-		tasklet_schedule (&instance->receive_tasklet);
-	spin_unlock_irqrestore (&instance->receive_lock, flags);
-}
-
-static void udsl_process_receive (unsigned long data)
-{
-	struct udsl_receive_buffer *buf;
-	struct udsl_instance_data *instance = (struct udsl_instance_data *) data;
-	struct udsl_receiver *rcv;
-	int err;
-
-made_progress:
-	while (!list_empty (&instance->spare_receive_buffers)) {
-		spin_lock_irq (&instance->receive_lock);
-		if (list_empty (&instance->spare_receivers)) {
-			spin_unlock_irq (&instance->receive_lock);
-			break;
-		}
-		rcv = list_entry (instance->spare_receivers.next, struct udsl_receiver, list);
-		list_del (&rcv->list);
-		spin_unlock_irq (&instance->receive_lock);
-
-		buf = list_entry (instance->spare_receive_buffers.next, struct udsl_receive_buffer, list);
-		list_del (&buf->list);
-
-		rcv->buffer = buf;
-
-		usb_fill_bulk_urb (rcv->urb,
-				   instance->usb_dev,
-				   usb_rcvbulkpipe (instance->usb_dev, UDSL_ENDPOINT_DATA_IN),
-				   buf->base,
-				   rcv_buf_size * ATM_CELL_SIZE,
-				   udsl_complete_receive,
-				   rcv);
-
-		vdbg ("udsl_process_receive: sending urb 0x%p, rcv 0x%p, buf 0x%p", rcv->urb, rcv, buf);
-
-		if ((err = usb_submit_urb(rcv->urb, GFP_ATOMIC)) < 0) {
-			dbg ("udsl_process_receive: urb submission failed (%d)!", err);
-			list_add (&buf->list, &instance->spare_receive_buffers);
-			spin_lock_irq (&instance->receive_lock);
-			list_add (&rcv->list, &instance->spare_receivers);
-			spin_unlock_irq (&instance->receive_lock);
-			break;
-		}
-	}
-
-	spin_lock_irq (&instance->receive_lock);
-	if (list_empty (&instance->filled_receive_buffers)) {
-		spin_unlock_irq (&instance->receive_lock);
-		return; /* done - no more buffers */
-	}
-	buf = list_entry (instance->filled_receive_buffers.next, struct udsl_receive_buffer, list);
-	list_del (&buf->list);
-	spin_unlock_irq (&instance->receive_lock);
-	vdbg ("udsl_process_receive: processing buf 0x%p", buf);
-	udsl_extract_cells (instance, buf->base, buf->filled_cells);
-	list_add (&buf->list, &instance->spare_receive_buffers);
-	goto made_progress;
-}
-
-
-/***********
-**  send  **
-***********/
-
-static void udsl_complete_send (struct urb *urb, struct pt_regs *regs)
-{
-	struct udsl_instance_data *instance;
-	struct udsl_sender *snd;
-	unsigned long flags;
-
-	if (!urb || !(snd = urb->context) || !(instance = snd->instance)) {
-		dbg ("udsl_complete_send: bad urb!");
-		return;
-	}
-
-	vdbg ("udsl_complete_send: urb 0x%p, status %d, snd 0x%p, buf 0x%p", urb, urb->status, snd, snd->buffer);
-
-	/* may not be in_interrupt() */
-	spin_lock_irqsave (&instance->send_lock, flags);
-	list_add (&snd->list, &instance->spare_senders);
-	list_add (&snd->buffer->list, &instance->spare_send_buffers);
-	tasklet_schedule (&instance->send_tasklet);
-	spin_unlock_irqrestore (&instance->send_lock, flags);
-}
-
-static void udsl_process_send (unsigned long data)
-{
-	struct udsl_send_buffer *buf;
-	struct udsl_instance_data *instance = (struct udsl_instance_data *) data;
-	struct sk_buff *skb;
-	struct udsl_sender *snd;
-	int err;
-	unsigned int num_written;
-
-made_progress:
-	spin_lock_irq (&instance->send_lock);
-	while (!list_empty (&instance->spare_senders)) {
-		if (!list_empty (&instance->filled_send_buffers)) {
-			buf = list_entry (instance->filled_send_buffers.next, struct udsl_send_buffer, list);
-			list_del (&buf->list);
-		} else if ((buf = instance->current_buffer)) {
-			instance->current_buffer = NULL;
-		} else /* all buffers empty */
-			break;
-
-		snd = list_entry (instance->spare_senders.next, struct udsl_sender, list);
-		list_del (&snd->list);
-		spin_unlock_irq (&instance->send_lock);
-
-		snd->buffer = buf;
-	        usb_fill_bulk_urb (snd->urb,
-				   instance->usb_dev,
-				   usb_sndbulkpipe (instance->usb_dev, UDSL_ENDPOINT_DATA_OUT),
-				   buf->base,
-				   (snd_buf_size - buf->free_cells) * ATM_CELL_SIZE,
-				   udsl_complete_send,
-				   snd);
-
-		vdbg ("udsl_process_send: submitting urb 0x%p (%d cells), snd 0x%p, buf 0x%p", snd->urb, snd_buf_size - buf->free_cells, snd, buf);
-
-		if ((err = usb_submit_urb(snd->urb, GFP_ATOMIC)) < 0) {
-			dbg ("udsl_process_send: urb submission failed (%d)!", err);
-			spin_lock_irq (&instance->send_lock);
-			list_add (&snd->list, &instance->spare_senders);
-			spin_unlock_irq (&instance->send_lock);
-			list_add (&buf->list, &instance->filled_send_buffers);
-			return; /* bail out */
-		}
-
-		spin_lock_irq (&instance->send_lock);
-	} /* while */
-	spin_unlock_irq (&instance->send_lock);
-
-	if (!instance->current_skb && !(instance->current_skb = skb_dequeue (&instance->sndqueue)))
-		return; /* done - no more skbs */
-
-	skb = instance->current_skb;
-
-	if (!(buf = instance->current_buffer)) {
-		spin_lock_irq (&instance->send_lock);
-		if (list_empty (&instance->spare_send_buffers)) {
-			instance->current_buffer = NULL;
-			spin_unlock_irq (&instance->send_lock);
-			return; /* done - no more buffers */
-		}
-		buf = list_entry (instance->spare_send_buffers.next, struct udsl_send_buffer, list);
-		list_del (&buf->list);
-		spin_unlock_irq (&instance->send_lock);
-
-		buf->free_start = buf->base;
-		buf->free_cells = snd_buf_size;
-
-		instance->current_buffer = buf;
-	}
-
-	num_written = udsl_write_cells (buf->free_cells, skb, &buf->free_start);
-
-	vdbg ("udsl_process_send: wrote %u cells from skb 0x%p to buffer 0x%p", num_written, skb, buf);
-
-	if (!(buf->free_cells -= num_written)) {
-		list_add_tail (&buf->list, &instance->filled_send_buffers);
-		instance->current_buffer = NULL;
-	}
-
-	vdbg ("udsl_process_send: buffer contains %d cells, %d left", snd_buf_size - buf->free_cells, buf->free_cells);
-
-	if (!UDSL_SKB (skb)->num_cells) {
-		struct atm_vcc *vcc = UDSL_SKB (skb)->atm_data.vcc;
-
-		udsl_pop (vcc, skb);
-		instance->current_skb = NULL;
-
-		atomic_inc (&vcc->stats->tx);
-	}
-
-	goto made_progress;
-}
-
-static void udsl_cancel_send (struct udsl_instance_data *instance, struct atm_vcc *vcc)
-{
-	struct sk_buff *skb, *n;
-
-	dbg ("udsl_cancel_send entered");
-	spin_lock_irq (&instance->sndqueue.lock);
-	for (skb = instance->sndqueue.next, n = skb->next; skb != (struct sk_buff *)&instance->sndqueue; skb = n, n = skb->next)
-		if (UDSL_SKB (skb)->atm_data.vcc == vcc) {
-			dbg ("udsl_cancel_send: popping skb 0x%p", skb);
-			__skb_unlink (skb, &instance->sndqueue);
-			udsl_pop (vcc, skb);
-		}
-	spin_unlock_irq (&instance->sndqueue.lock);
-
-	tasklet_disable (&instance->send_tasklet);
-	if ((skb = instance->current_skb) && (UDSL_SKB (skb)->atm_data.vcc == vcc)) {
-		dbg ("udsl_cancel_send: popping current skb (0x%p)", skb);
-		instance->current_skb = NULL;
-		udsl_pop (vcc, skb);
-	}
-	tasklet_enable (&instance->send_tasklet);
-	dbg ("udsl_cancel_send done");
-}
-
-static int udsl_atm_send (struct atm_vcc *vcc, struct sk_buff *skb)
-{
-	struct udsl_instance_data *instance = vcc->dev->dev_data;
-	int err;
-
-	vdbg ("udsl_atm_send called (skb 0x%p, len %u)", skb, skb->len);
-
-	if (!instance || !instance->usb_dev) {
-		dbg ("udsl_atm_send: NULL data!");
-		err = -ENODEV;
-		goto fail;
-	}
-
-	if (vcc->qos.aal != ATM_AAL5) {
-		dbg ("udsl_atm_send: unsupported ATM type %d!", vcc->qos.aal);
-		err = -EINVAL;
-		goto fail;
-	}
-
-	if (skb->len > ATM_MAX_AAL5_PDU) {
-		dbg ("udsl_atm_send: packet too long (%d vs %d)!", skb->len, ATM_MAX_AAL5_PDU);
-		err = -EINVAL;
-		goto fail;
-	}
-
-	PACKETDEBUG (skb->data, skb->len);
-
-	udsl_groom_skb (vcc, skb);
-	skb_queue_tail (&instance->sndqueue, skb);
-	tasklet_schedule (&instance->send_tasklet);
-
-	return 0;
-
-fail:
-	udsl_pop (vcc, skb);
-	return err;
-}
-
-
-/**********
-**  ATM  **
-**********/
-
-static void udsl_atm_dev_close (struct atm_dev *dev)
-{
-	struct udsl_instance_data *instance = dev->dev_data;
-
-	if (!instance) {
-		dbg ("udsl_atm_dev_close: NULL instance!");
-		return;
-	}
-
-	dbg ("udsl_atm_dev_close: queue has %u elements", instance->sndqueue.qlen);
-
-	tasklet_kill (&instance->receive_tasklet);
-	tasklet_kill (&instance->send_tasklet);
-	kfree (instance);
-	dev->dev_data = NULL;
-}
-
-static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page)
-{
-	struct udsl_instance_data *instance = atm_dev->dev_data;
-	int left = *pos;
-
-	if (!instance) {
-		dbg ("udsl_atm_proc_read: NULL instance!");
-		return -ENODEV;
-	}
-
-	if (!left--)
-		return sprintf (page, "%s\n", instance->description);
-
-	if (!left--)
-		return sprintf (page, "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
-				atm_dev->esi [0], atm_dev->esi [1], atm_dev->esi [2],
-				atm_dev->esi [3], atm_dev->esi [4], atm_dev->esi [5]);
-
-	if (!left--)
-		return sprintf (page, "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
-				atomic_read (&atm_dev->stats.aal5.tx),
-				atomic_read (&atm_dev->stats.aal5.tx_err),
-				atomic_read (&atm_dev->stats.aal5.rx),
-				atomic_read (&atm_dev->stats.aal5.rx_err),
-				atomic_read (&atm_dev->stats.aal5.rx_drop));
-
-	if (!left--) {
-		switch (atm_dev->signal) {
-		case ATM_PHY_SIG_FOUND:
-			sprintf (page, "Line up");
-			break;
-		case ATM_PHY_SIG_LOST:
-			sprintf (page, "Line down");
-			break;
-		default:
-			sprintf (page, "Line state unknown");
-			break;
-		}
-
-		if (instance->usb_dev) {
-			if (!instance->firmware_loaded)
-				strcat (page, ", no firmware\n");
-			else
-				strcat (page, ", firmware loaded\n");
-		} else
-			strcat (page, ", disconnected\n");
-
-		return strlen (page);
-	}
-
-	return 0;
-}
-
-static int udsl_atm_open (struct atm_vcc *vcc)
-{
-	struct udsl_instance_data *instance = vcc->dev->dev_data;
-	struct udsl_vcc_data *new;
-	unsigned int max_pdu;
-	int vci = vcc->vci;
-	short vpi = vcc->vpi;
-
-	dbg ("udsl_atm_open: vpi %hd, vci %d", vpi, vci);
-
-	if (!instance || !instance->usb_dev) {
-		dbg ("udsl_atm_open: NULL data!");
-		return -ENODEV;
-	}
-
-	/* only support AAL5 */
-	if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
-		dbg ("udsl_atm_open: unsupported ATM type %d!", vcc->qos.aal);
-		return -EINVAL;
-	}
-
-	if (!instance->firmware_loaded) {
-		dbg ("udsl_atm_open: firmware not loaded!");
-		return -EAGAIN;
-	}
-
-	down (&instance->serialize); /* vs self, udsl_atm_close */
-
-	if (udsl_find_vcc (instance, vpi, vci)) {
-		dbg ("udsl_atm_open: %hd/%d already in use!", vpi, vci);
-		up (&instance->serialize);
-		return -EADDRINUSE;
-	}
-
-	if (!(new = kmalloc (sizeof (struct udsl_vcc_data), GFP_KERNEL))) {
-		dbg ("udsl_atm_open: no memory for vcc_data!");
-		up (&instance->serialize);
-		return -ENOMEM;
-	}
-
-	memset (new, 0, sizeof (struct udsl_vcc_data));
-	new->vcc = vcc;
-	new->vpi = vpi;
-	new->vci = vci;
-
-	/* udsl_extract_cells requires at least one cell */
-	max_pdu = max (1, UDSL_NUM_CELLS (vcc->qos.rxtp.max_sdu)) * ATM_CELL_PAYLOAD;
-	if (!(new->sarb = alloc_skb (max_pdu, GFP_KERNEL))) {
-		dbg ("udsl_atm_open: no memory for SAR buffer!");
-	        kfree (new);
-		up (&instance->serialize);
-		return -ENOMEM;
-	}
-
-	vcc->dev_data = new;
-
-	tasklet_disable (&instance->receive_tasklet);
-	list_add (&new->list, &instance->vcc_list);
-	tasklet_enable (&instance->receive_tasklet);
-
-	set_bit (ATM_VF_ADDR, &vcc->flags);
-	set_bit (ATM_VF_PARTIAL, &vcc->flags);
-	set_bit (ATM_VF_READY, &vcc->flags);
-
-	up (&instance->serialize);
-
-	tasklet_schedule (&instance->receive_tasklet);
-
-	dbg ("udsl_atm_open: allocated vcc data 0x%p (max_pdu: %u)", new, max_pdu);
-
-	return 0;
-}
-
-static void udsl_atm_close (struct atm_vcc *vcc)
-{
-	struct udsl_instance_data *instance = vcc->dev->dev_data;
-	struct udsl_vcc_data *vcc_data = vcc->dev_data;
-
-	dbg ("udsl_atm_close called");
-
-	if (!instance || !vcc_data) {
-		dbg ("udsl_atm_close: NULL data!");
-		return;
-	}
-
-	dbg ("udsl_atm_close: deallocating vcc 0x%p with vpi %d vci %d", vcc_data, vcc_data->vpi, vcc_data->vci);
-
-	udsl_cancel_send (instance, vcc);
-
-	down (&instance->serialize); /* vs self, udsl_atm_open */
-
-	tasklet_disable (&instance->receive_tasklet);
-	list_del (&vcc_data->list);
-	tasklet_enable (&instance->receive_tasklet);
-
-	kfree_skb (vcc_data->sarb);
-	vcc_data->sarb = NULL;
-
-	kfree (vcc_data);
-	vcc->dev_data = NULL;
-
-	vcc->vpi = ATM_VPI_UNSPEC;
-	vcc->vci = ATM_VCI_UNSPEC;
-	clear_bit (ATM_VF_READY, &vcc->flags);
-	clear_bit (ATM_VF_PARTIAL, &vcc->flags);
-	clear_bit (ATM_VF_ADDR, &vcc->flags);
-
-	up (&instance->serialize);
-
-	dbg ("udsl_atm_close successful");
-}
-
-static int udsl_atm_ioctl (struct atm_dev *dev, unsigned int cmd, void __user *arg)
-{
-	switch (cmd) {
-	case ATM_QUERYLOOP:
-		return put_user (ATM_LM_NONE, (int __user *)arg) ? -EFAULT : 0;
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-
-
-/**********
-**  USB  **
-**********/
-
-static int udsl_set_alternate (struct udsl_instance_data *instance)
-{
-	down (&instance->serialize); /* vs self */
-	if (!instance->firmware_loaded) {
-		int ret;
-
-		if ((ret = usb_set_interface (instance->usb_dev, 1, 1)) < 0) {
-			dbg ("udsl_set_alternate: usb_set_interface returned %d!", ret);
-			up (&instance->serialize);
-			return ret;
-		}
-		instance->firmware_loaded = 1;
-	}
-	up (&instance->serialize);
-
-	tasklet_schedule (&instance->receive_tasklet);
-
-	return 0;
-}
-
-static int udsl_usb_ioctl (struct usb_interface *intf, unsigned int code, void *user_data)
-{
-	struct udsl_instance_data *instance = usb_get_intfdata (intf);
-
-	dbg ("udsl_usb_ioctl entered");
-
-	if (!instance) {
-		dbg ("udsl_usb_ioctl: NULL instance!");
-		return -ENODEV;
-	}
-
-	switch (code) {
-	case UDSL_IOCTL_LINE_UP:
-		instance->atm_dev->signal = ATM_PHY_SIG_FOUND;
-		return udsl_set_alternate (instance);
-	case UDSL_IOCTL_LINE_DOWN:
-		instance->atm_dev->signal = ATM_PHY_SIG_LOST;
-		return 0;
-	default:
-		return -ENOTTY;
-	}
-}
-
-static int udsl_usb_probe (struct usb_interface *intf, const struct usb_device_id *id)
-{
-	struct usb_device *dev = interface_to_usbdev(intf);
-	int ifnum = intf->altsetting->desc.bInterfaceNumber;
-	struct udsl_instance_data *instance;
-	unsigned char mac_str [13];
-	int i, length;
-	char *buf;
-
-	dbg ("udsl_usb_probe: trying device with vendor=0x%x, product=0x%x, ifnum %d",
-	     dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum);
-
-	if ((dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) ||
-	    (dev->descriptor.idVendor != SPEEDTOUCH_VENDORID) ||
-	    (dev->descriptor.idProduct != SPEEDTOUCH_PRODUCTID) || (ifnum != 1))
-		return -ENODEV;
-
-	dbg ("udsl_usb_probe: device accepted");
-
-	/* instance init */
-	if (!(instance = kmalloc (sizeof (struct udsl_instance_data), GFP_KERNEL))) {
-		dbg ("udsl_usb_probe: no memory for instance data!");
-		return -ENOMEM;
-	}
-
-	memset (instance, 0, sizeof (struct udsl_instance_data));
-
-	init_MUTEX (&instance->serialize);
-
-	instance->usb_dev = dev;
-
-	INIT_LIST_HEAD (&instance->vcc_list);
-
-	spin_lock_init (&instance->receive_lock);
-	INIT_LIST_HEAD (&instance->spare_receivers);
-	INIT_LIST_HEAD (&instance->filled_receive_buffers);
-
-	tasklet_init (&instance->receive_tasklet, udsl_process_receive, (unsigned long) instance);
-	INIT_LIST_HEAD (&instance->spare_receive_buffers);
-
-	skb_queue_head_init (&instance->sndqueue);
-
-	spin_lock_init (&instance->send_lock);
-	INIT_LIST_HEAD (&instance->spare_senders);
-	INIT_LIST_HEAD (&instance->spare_send_buffers);
-
-	tasklet_init (&instance->send_tasklet, udsl_process_send, (unsigned long) instance);
-	INIT_LIST_HEAD (&instance->filled_send_buffers);
-
-	/* receive init */
-	for (i = 0; i < num_rcv_urbs; i++) {
-		struct udsl_receiver *rcv = &(instance->receivers [i]);
-
-		if (!(rcv->urb = usb_alloc_urb (0, GFP_KERNEL))) {
-			dbg ("udsl_usb_probe: no memory for receive urb %d!", i);
-			goto fail;
-		}
-
-		rcv->instance = instance;
-
-		list_add (&rcv->list, &instance->spare_receivers);
-	}
-
-	for (i = 0; i < num_rcv_bufs; i++) {
-		struct udsl_receive_buffer *buf = &(instance->receive_buffers [i]);
-
-		if (!(buf->base = kmalloc (rcv_buf_size * ATM_CELL_SIZE, GFP_KERNEL))) {
-			dbg ("udsl_usb_probe: no memory for receive buffer %d!", i);
-			goto fail;
-		}
-
-		list_add (&buf->list, &instance->spare_receive_buffers);
-	}
-
-	/* send init */
-	for (i = 0; i < num_snd_urbs; i++) {
-		struct udsl_sender *snd = &(instance->senders [i]);
-
-		if (!(snd->urb = usb_alloc_urb (0, GFP_KERNEL))) {
-			dbg ("udsl_usb_probe: no memory for send urb %d!", i);
-			goto fail;
-		}
-
-		snd->instance = instance;
-
-		list_add (&snd->list, &instance->spare_senders);
-	}
-
-	for (i = 0; i < num_snd_bufs; i++) {
-		struct udsl_send_buffer *buf = &(instance->send_buffers [i]);
-
-		if (!(buf->base = kmalloc (snd_buf_size * ATM_CELL_SIZE, GFP_KERNEL))) {
-			dbg ("udsl_usb_probe: no memory for send buffer %d!", i);
-			goto fail;
-		}
-
-		list_add (&buf->list, &instance->spare_send_buffers);
-	}
-
-	/* ATM init */
-	if (!(instance->atm_dev = atm_dev_register (udsl_driver_name, &udsl_atm_devops, -1, NULL))) {
-		dbg ("udsl_usb_probe: failed to register ATM device!");
-		goto fail;
-	}
-
-	instance->atm_dev->ci_range.vpi_bits = ATM_CI_MAX;
-	instance->atm_dev->ci_range.vci_bits = ATM_CI_MAX;
-	instance->atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
-
-	/* temp init ATM device, set to 128kbit */
-	instance->atm_dev->link_rate = 128 * 1000 / 424;
-
-	/* set MAC address, it is stored in the serial number */
-	memset (instance->atm_dev->esi, 0, sizeof (instance->atm_dev->esi));
-	if (usb_string (dev, dev->descriptor.iSerialNumber, mac_str, sizeof (mac_str)) == 12)
-		for (i = 0; i < 6; i++)
-			instance->atm_dev->esi [i] = (hex2int (mac_str [i * 2]) * 16) + (hex2int (mac_str [i * 2 + 1]));
-
-	/* device description */
-	buf = instance->description;
-	length = sizeof (instance->description);
-
-	if ((i = usb_string (dev, dev->descriptor.iProduct, buf, length)) < 0)
-		goto finish;
-
-	buf += i;
-	length -= i;
-
-	i = scnprintf (buf, length, " (");
-	buf += i;
-	length -= i;
-
-	if (length <= 0 || (i = usb_make_path (dev, buf, length)) < 0)
-		goto finish;
-
-	buf += i;
-	length -= i;
-
-	snprintf (buf, length, ")");
-
-finish:
-	/* ready for ATM callbacks */
-	wmb ();
-	instance->atm_dev->dev_data = instance;
-
-	usb_set_intfdata (intf, instance);
-
-	return 0;
-
-fail:
-	for (i = 0; i < num_snd_bufs; i++)
-		kfree (instance->send_buffers [i].base);
-
-	for (i = 0; i < num_snd_urbs; i++)
-		usb_free_urb (instance->senders [i].urb);
-
-	for (i = 0; i < num_rcv_bufs; i++)
-		kfree (instance->receive_buffers [i].base);
-
-	for (i = 0; i < num_rcv_urbs; i++)
-		usb_free_urb (instance->receivers [i].urb);
-
-	kfree (instance);
-
-	return -ENOMEM;
-}
-
-static void udsl_usb_disconnect (struct usb_interface *intf)
-{
-	struct udsl_instance_data *instance = usb_get_intfdata (intf);
-	struct list_head *pos;
-	unsigned int count;
-	int result, i;
-
-	dbg ("udsl_usb_disconnect entered");
-
-	usb_set_intfdata (intf, NULL);
-
-	if (!instance) {
-		dbg ("udsl_usb_disconnect: NULL instance!");
-		return;
-	}
-
-	/* receive finalize */
-	tasklet_disable (&instance->receive_tasklet);
-
-	for (i = 0; i < num_rcv_urbs; i++)
-		if ((result = usb_unlink_urb (instance->receivers [i].urb)) < 0)
-			dbg ("udsl_usb_disconnect: usb_unlink_urb on receive urb %d returned %d!", i, result);
-
-	/* wait for completion handlers to finish */
-	do {
-		count = 0;
-		spin_lock_irq (&instance->receive_lock);
-		list_for_each (pos, &instance->spare_receivers)
-			DEBUG_ON (++count > num_rcv_urbs);
-		spin_unlock_irq (&instance->receive_lock);
-
-		dbg ("udsl_usb_disconnect: found %u spare receivers", count);
-
-		if (count == num_rcv_urbs)
-			break;
-
-		set_current_state (TASK_RUNNING);
-		schedule ();
-	} while (1);
-
-	/* no need to take the spinlock */
-	INIT_LIST_HEAD (&instance->filled_receive_buffers);
-	INIT_LIST_HEAD (&instance->spare_receive_buffers);
-
-	tasklet_enable (&instance->receive_tasklet);
-
-	for (i = 0; i < num_rcv_urbs; i++)
-		usb_free_urb (instance->receivers [i].urb);
-
-	for (i = 0; i < num_rcv_bufs; i++)
-		kfree (instance->receive_buffers [i].base);
-
-	/* send finalize */
-	tasklet_disable (&instance->send_tasklet);
-
-	for (i = 0; i < num_snd_urbs; i++)
-		if ((result = usb_unlink_urb (instance->senders [i].urb)) < 0)
-			dbg ("udsl_usb_disconnect: usb_unlink_urb on send urb %d returned %d!", i, result);
-
-	/* wait for completion handlers to finish */
-	do {
-		count = 0;
-		spin_lock_irq (&instance->send_lock);
-		list_for_each (pos, &instance->spare_senders)
-			DEBUG_ON (++count > num_snd_urbs);
-		spin_unlock_irq (&instance->send_lock);
-
-		dbg ("udsl_usb_disconnect: found %u spare senders", count);
-
-		if (count == num_snd_urbs)
-			break;
-
-		set_current_state (TASK_RUNNING);
-		schedule ();
-	} while (1);
-
-	/* no need to take the spinlock */
-	INIT_LIST_HEAD (&instance->spare_senders);
-	INIT_LIST_HEAD (&instance->spare_send_buffers);
-	instance->current_buffer = NULL;
-
-	tasklet_enable (&instance->send_tasklet);
-
-	for (i = 0; i < num_snd_urbs; i++)
-		usb_free_urb (instance->senders [i].urb);
-
-	for (i = 0; i < num_snd_bufs; i++)
-		kfree (instance->send_buffers [i].base);
-
-	wmb ();
-	instance->usb_dev = NULL;
-
-	/* ATM finalize */
-	shutdown_atm_dev (instance->atm_dev); /* frees instance, kills tasklets */
-}
-
-
-/***********
-**  init  **
-***********/
-
-static int __init udsl_usb_init (void)
-{
-	dbg ("udsl_usb_init: driver version " DRIVER_VERSION);
-
-	if (sizeof (struct udsl_control) > sizeof (((struct sk_buff *)0)->cb)) {
-		printk (KERN_ERR __FILE__ ": unusable with this kernel!\n");
-		return -EIO;
-	}
-
-	if ((num_rcv_urbs > UDSL_MAX_RCV_URBS) || (num_snd_urbs > UDSL_MAX_SND_URBS) ||
-	    (num_rcv_bufs > UDSL_MAX_RCV_BUFS) || (num_snd_bufs > UDSL_MAX_SND_BUFS) ||
-	    (rcv_buf_size > UDSL_MAX_RCV_BUF_SIZE) || (snd_buf_size > UDSL_MAX_SND_BUF_SIZE))
-		return -EINVAL;
-
-	return usb_register (&udsl_usb_driver);
-}
-
-static void __exit udsl_usb_cleanup (void)
-{
-	dbg ("udsl_usb_cleanup entered");
-
-	usb_deregister (&udsl_usb_driver);
-}
-
-module_init (udsl_usb_init);
-module_exit (udsl_usb_cleanup);
-
-MODULE_AUTHOR (DRIVER_AUTHOR);
-MODULE_DESCRIPTION (DRIVER_DESC);
-MODULE_LICENSE ("GPL");
-MODULE_VERSION (DRIVER_VERSION);
-
-
-/************
-**  debug  **
-************/
-
-#ifdef VERBOSE_DEBUG
-static int udsl_print_packet (const unsigned char *data, int len)
-{
-	unsigned char buffer [256];
-	int i = 0, j = 0;
-
-	for (i = 0; i < len;) {
-		buffer [0] = '\0';
-		sprintf (buffer, "%.3d :", i);
-		for (j = 0; (j < 16) && (i < len); j++, i++) {
-			sprintf (buffer, "%s %2.2x", buffer, data [i]);
-		}
-		dbg ("%s", buffer);
-	}
-	return i;
-}
-#endif
diff -Nru a/drivers/usb/misc/tiglusb.c b/drivers/usb/misc/tiglusb.c
--- a/drivers/usb/misc/tiglusb.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/misc/tiglusb.c	2004-12-24 13:36:17 -08:00
@@ -4,7 +4,7 @@
  * Target: Texas Instruments graphing calculators (http://lpg.ticalc.org).
  *
  * Copyright (C) 2001-2004:
- *   Romain Lievin <roms@lpg.ticalc.org>
+ *   Romain Lievin <roms@tilp.info>
  *   Julien BLACHE <jb@technologeek.org>
  * under the terms of the GNU General Public License.
  *
@@ -14,7 +14,7 @@
  * and the website at:  http://lpg.ticalc.org/prj_usb/
  * for more info.
  *
- * History :
+ * History:
  *   1.0x, Romain & Julien: initial submit.
  *   1.03, Greg Kroah: modifications.
  *   1.04, Julien: clean-up & fixes; Romain: 2.4 backport.
@@ -22,6 +22,7 @@
  *   1.06, Romain: synched with 2.5, version/firmware changed (confusing).
  *   1.07, Romain: fixed bad use of usb_clear_halt (invalid argument);
  *          timeout argument checked in ioctl + clean-up.
+ *   1.08, Romain: added support of USB port embedded on some TI's handhelds.
  */
 
 #include <linux/module.h>
@@ -41,7 +42,7 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "1.07"
+#define DRIVER_VERSION "1.08"
 #define DRIVER_AUTHOR  "Romain Lievin <roms@tilp.info> & Julien Blache <jb@jblache.org>"
 #define DRIVER_DESC    "TI-GRAPH LINK USB (aka SilverLink) driver"
 #define DRIVER_LICENSE "GPL"
@@ -115,7 +116,7 @@
 			return -EBUSY;
 		}
 
-		schedule_timeout (HZ / 2);
+		msleep_interruptible(500);
 
 		if (signal_pending (current)) {
 			return -EAGAIN;
@@ -177,11 +178,11 @@
 	if (!s->dev)
 		return -EIO;
 
-	buffer = kmalloc(BULK_RCV_MAX, GFP_KERNEL);
+	buffer = kmalloc (s->max_ps, GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
 
-	bytes_to_read = (count >= BULK_RCV_MAX) ? BULK_RCV_MAX : count;
+	bytes_to_read = (count >= s->max_ps) ? s->max_ps : count;
 
 	pipe = usb_rcvbulkpipe (s->dev, 1);
 	result = usb_bulk_msg (s->dev, pipe, buffer, bytes_to_read,
@@ -234,11 +235,11 @@
 	if (!s->dev)
 		return -EIO;
 
-	buffer = kmalloc(BULK_SND_MAX, GFP_KERNEL);
+	buffer = kmalloc (s->max_ps, GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
 
-	bytes_to_write = (count >= BULK_SND_MAX) ? BULK_SND_MAX : count;
+	bytes_to_write = (count >= s->max_ps) ? s->max_ps : count;
 	if (copy_from_user (buffer, buf, bytes_to_write)) {
 		ret = -EFAULT;
 		goto out;
@@ -308,6 +309,15 @@
 		if (clear_pipes (s->dev))
 			ret = -EIO;
 		break;
+	case IOCTL_TIUSB_GET_MAXPS:
+                if (copy_to_user((int __user *) arg, &s->max_ps, sizeof(int)))
+                        return -EFAULT;
+                break;
+        case IOCTL_TIUSB_GET_DEVID:
+                if (copy_to_user((int __user *) arg, &s->dev->descriptor.idProduct,
+                                 sizeof(int)))
+                        return -EFAULT;
+                break;
 	default:
 		ret = -ENOTTY;
 		break;
@@ -340,6 +350,9 @@
 	int minor = -1;
 	int i, err = 0;
 	ptiglusb_t s;
+	struct usb_host_config *conf;
+        struct usb_host_interface *ifdata = NULL;
+        int max_ps;
 
 	dbg ("probing vendor id 0x%x, device id 0x%x",
 	     dev->descriptor.idVendor, dev->descriptor.idProduct);
@@ -354,19 +367,31 @@
 		goto out;
 	}
 
-	if ((dev->descriptor.idProduct != 0xe001)
-	    && (dev->descriptor.idVendor != 0x451)) {
+	if (dev->descriptor.idVendor != 0x451) {
 		err = -ENODEV;
 		goto out;
 	}
 
-	// NOTE:  it's already in this config, this shouldn't be needed.
-	// is this working around some hardware bug?
-	if (usb_reset_configuration (dev) < 0) {
-		err ("tiglusb_probe: reset_configuration failed");
-		err = -ENODEV;
-		goto out;
-	}
+	if ((dev->descriptor.idProduct != 0xe001) &&
+            (dev->descriptor.idProduct != 0xe004) &&
+            (dev->descriptor.idProduct != 0xe008)) {
+                err = -ENODEV;
+                goto out;
+        }
+
+	/*
+         * TI introduced some new handhelds with embedded USB port.
+         * Port advertises same config as SilverLink cable but with a 
+	 * different maximum packet size (64 rather than 32).
+         */
+
+        conf = dev->actconfig;
+        ifdata = conf->interface[0]->cur_altsetting;
+        max_ps = ifdata->endpoint[0].desc.wMaxPacketSize;
+
+        info("max packet size of %d/%d bytes\n",
+             ifdata->endpoint[0].desc.wMaxPacketSize,
+             ifdata->endpoint[1].desc.wMaxPacketSize);
 
 	/*
 	 * Find a tiglusb struct
@@ -389,6 +414,7 @@
 	down (&s->mutex);
 	s->remove_pending = 0;
 	s->dev = dev;
+	s->max_ps = max_ps;
 	up (&s->mutex);
 	dbg ("bound to interface");
 
diff -Nru a/drivers/usb/misc/tiglusb.h b/drivers/usb/misc/tiglusb.h
--- a/drivers/usb/misc/tiglusb.h	2004-12-24 13:37:31 -08:00
+++ b/drivers/usb/misc/tiglusb.h	2004-12-24 13:37:31 -08:00
@@ -18,12 +18,6 @@
 #define MAXTIGL		16
 
 /*
- * Max. packetsize for IN and OUT pipes
- */
-#define BULK_RCV_MAX	32
-#define BULK_SND_MAX	32
-
-/*
  * The driver context...
  */
 
@@ -42,6 +36,8 @@
 	driver_state_t	state;			/* started/stopped */
 	int		opened;			/* tru if open */
 	int	remove_pending;
+
+	int             max_ps;                 /* max packet size */
 } tiglusb_t, *ptiglusb_t;
 
 #endif
diff -Nru a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
--- a/drivers/usb/misc/usbtest.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/misc/usbtest.c	2004-12-24 13:37:29 -08:00
@@ -1355,7 +1355,7 @@
 				"iso test, %lu errors\n",
 				ctx->errors);
 		complete (&ctx->done);
-	} else
+	}
 done:
 	spin_unlock(&ctx->lock);
 }
@@ -1457,8 +1457,10 @@
 		status = usb_submit_urb (urbs [i], SLAB_ATOMIC);
 		if (status < 0) {
 			ERROR (dev, "submit iso[%d], error %d\n", i, status);
-			if (i == 0)
+			if (i == 0) {
+				spin_unlock_irq (&context.lock);
 				goto fail;
+			}
 
 			simple_free_urb (urbs [i]);
 			context.pending--;
diff -Nru a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
--- a/drivers/usb/misc/uss720.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/usb/misc/uss720.c	2004-12-24 13:36:16 -08:00
@@ -44,6 +44,7 @@
 #include <linux/parport.h>
 #include <linux/init.h>
 #include <linux/usb.h>
+#include <linux/delay.h>
 
 /*
  * Version Information
@@ -159,8 +160,7 @@
 				if (time_after_eq (jiffies, expire))
 					/* The FIFO is stuck. */
 					return -EBUSY;
-				set_current_state(TASK_INTERRUPTIBLE);
-				schedule_timeout((HZ + 99) / 100);
+				msleep_interruptible(10);
 				if (signal_pending (current))
 					break;
 			}
diff -Nru a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
--- a/drivers/usb/net/Kconfig	2004-12-24 13:37:04 -08:00
+++ b/drivers/usb/net/Kconfig	2004-12-24 13:37:04 -08:00
@@ -1,15 +1,15 @@
 #
 # USB Network devices configuration
 #
-comment "USB Network adaptors"
-	depends on USB
-
-comment "Networking support is needed for USB Networking device support"
+comment "Networking support is needed for USB Network Adapter support"
 	depends on USB && !NET
 
+menu "USB Network Adapters"
+	depends on USB && NET
+
 config USB_CATC
 	tristate "USB CATC NetMate-based Ethernet device support (EXPERIMENTAL)"
-	depends on USB && NET && EXPERIMENTAL
+	depends on EXPERIMENTAL
 	select CRC32
 	---help---
 	  Say Y if you want to use one of the following 10Mbps USB Ethernet
@@ -29,7 +29,6 @@
 
 config USB_KAWETH
 	tristate "USB KLSI KL5USB101-based ethernet device support"
-	depends on USB && NET
 	---help---
 	  Say Y here if you want to use one of the following 10Mbps only
 	  USB Ethernet adapters based on the KLSI KL5KUSB101B chipset:
@@ -69,7 +68,6 @@
 
 config USB_PEGASUS
 	tristate "USB Pegasus/Pegasus-II based ethernet device support"
-	depends on USB && NET
 	select MII
 	---help---
 	  Say Y here if you know you have Pegasus or Pegasus-II based adapter.
@@ -85,7 +83,7 @@
 
 config USB_RTL8150
 	tristate "USB RTL8150 based ethernet device support (EXPERIMENTAL)"
-	depends on USB && NET && EXPERIMENTAL
+	depends on EXPERIMENTAL
 	help
 	  Say Y here if you have RTL8150 based usb-ethernet adapter.
 	  Send me <petkan@users.sourceforge.net> any comments you may have.
@@ -96,7 +94,6 @@
 
 config USB_USBNET
 	tristate "Multi-purpose USB Networking Framework"
-	depends on USB && NET
 	---help---
 	  This driver supports several kinds of network links over USB,
 	  with "minidrivers" built around a common network driver core
@@ -185,6 +182,14 @@
 	  Choose this option if you're using a host-to-host cable
 	  with one of these chips.
 
+config USB_KC2190
+	boolean "KT Technology KC2190 based cables (InstaNet)"
+	default y
+	depends on USB_USBNET && EXPERIMENTAL
+	help
+	  Choose this option if you're using a host-to-host cable
+	  with one of these chips.
+
 comment "Intelligent USB Devices/Gadgets"
 	depends on USB_USBNET
 
@@ -198,6 +203,9 @@
 	  such as the SA-11x0 and PXA-25x UDCs, or the tftp capabilities
 	  in some PXA versions of the "blob" boot loader.
 
+	  Linux-based "Gumstix" PXA-25x based systems use this protocol
+	  to talk with other Linux systems.
+
 	  Although the ROMs shipped with Sharp Zaurus products use a
 	  different link level framing protocol, you can have them use
 	  this simpler protocol by installing a different kernel.
@@ -258,17 +266,20 @@
 	select MII
 	default y
 	help
-
 	  This option adds support for ASIX AX88172 based USB 2.0
 	  10/100 Ethernet devices.
 
  	  This driver should work with at least the following devices:
 	    * Aten UC210T
 	    * ASIX AX88172
+	    * Billionton Systems, USB2AR 
+	    * Buffalo LUA-U2-KTX
+	    * Corega FEther USB2-TX
 	    * D-Link DUB-E100
 	    * Hawking UF200
 	    * Linksys USB200M
 	    * Netgear FA120
+	    * Sitecom LN-029
 	    * Intellinet USB 2.0 Ethernet
 	    * ST Lab USB 2.0 Ethernet
 	    * TrendNet TU2-ET100
@@ -276,4 +287,4 @@
 	  This driver creates an interface named "ethX", where X depends on
 	  what other networking devices you have in use.  
 
-
+endmenu
diff -Nru a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
--- a/drivers/usb/net/catc.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/net/catc.c	2004-12-24 13:36:48 -08:00
@@ -43,7 +43,7 @@
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 
 #undef DEBUG
@@ -411,7 +411,7 @@
 
 static int catc_hard_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
-	struct catc *catc = netdev->priv;
+	struct catc *catc = netdev_priv(netdev);
 	unsigned long flags;
 	char *tx_buf;
 
@@ -442,7 +442,7 @@
 
 static void catc_tx_timeout(struct net_device *netdev)
 {
-	struct catc *catc = netdev->priv;
+	struct catc *catc = netdev_priv(netdev);
 
 	warn("Transmit timed out.");
 	catc->tx_urb->transfer_flags |= URB_ASYNC_UNLINK;
@@ -604,7 +604,7 @@
 
 static struct net_device_stats *catc_get_stats(struct net_device *netdev)
 {
-	struct catc *catc = netdev->priv;
+	struct catc *catc = netdev_priv(netdev);
 	return &catc->stats;
 }
 
@@ -622,7 +622,7 @@
 
 static void catc_set_multicast_list(struct net_device *netdev)
 {
-	struct catc *catc = netdev->priv;
+	struct catc *catc = netdev_priv(netdev);
 	struct dev_mc_list *mc;
 	u8 broadcast[6];
 	u8 rx = RxEnable | RxPolarity | RxMultiCast;
@@ -664,74 +664,38 @@
 	}
 }
 
-/*
- * ioctl's
- */
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+void catc_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-        struct catc *catc = dev->priv;
-        u32 cmd;
-        
-        if (get_user(cmd, (u32 __user *)useraddr))
-                return -EFAULT;
-
-        switch (cmd) {
-        /* get driver info */
-        case ETHTOOL_GDRVINFO: {
-                struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-                strncpy(info.driver, driver_name, ETHTOOL_BUSINFO_LEN);
-                strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
-		usb_make_path (catc->usbdev, info.bus_info, sizeof info.bus_info);
-                if (copy_to_user(useraddr, &info, sizeof(info)))
-                        return -EFAULT;
-                return 0;
-        }
-
-	/* get settings */
-	case ETHTOOL_GSET:
-		if (catc->is_f5u011) {
-			struct ethtool_cmd ecmd = { ETHTOOL_GSET, 
-						    SUPPORTED_10baseT_Half | SUPPORTED_TP, 
-						    ADVERTISED_10baseT_Half | ADVERTISED_TP, 
-						    SPEED_10, 
-						    DUPLEX_HALF, 
-						    PORT_TP, 
-						    0, 
-						    XCVR_INTERNAL, 
-						    AUTONEG_DISABLE, 
-						    1, 
-						    1 
-			};
-			if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
-				return -EFAULT;
-			return 0;
-		} else {
-			return -EOPNOTSUPP;
-		}
+	struct catc *catc = netdev_priv(dev);
+	strncpy(info->driver, driver_name, ETHTOOL_BUSINFO_LEN);
+	strncpy(info->version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
+	usb_make_path (catc->usbdev, info->bus_info, sizeof info->bus_info);
+}
+
+static int catc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	struct catc *catc = netdev_priv(dev);
+	if (!catc->is_f5u011)
+		return -EOPNOTSUPP;
 
-        /* get link status */
-        case ETHTOOL_GLINK: {
-                struct ethtool_value edata = {ETHTOOL_GLINK};
-                edata.data = netif_carrier_ok(dev);
-                if (copy_to_user(useraddr, &edata, sizeof(edata)))
-                        return -EFAULT;
-                return 0;
-        }
-	}
-        
-        return -EOPNOTSUPP;
-}
-
-static int catc_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-{
-        switch(cmd) {
-        case SIOCETHTOOL:
-                return netdev_ethtool_ioctl(dev, rq->ifr_data);
-        default:
-                return -EOPNOTSUPP;
-        }
+	cmd->supported = SUPPORTED_10baseT_Half | SUPPORTED_TP;
+	cmd->advertising = ADVERTISED_10baseT_Half | ADVERTISED_TP;
+	cmd->speed = SPEED_10;
+	cmd->duplex = DUPLEX_HALF;
+	cmd->port = PORT_TP; 
+	cmd->phy_address = 0;
+	cmd->transceiver = XCVR_INTERNAL;
+	cmd->autoneg = AUTONEG_DISABLE;
+	cmd->maxtxpkt = 1;
+	cmd->maxrxpkt = 1;
+	return 0;
 }
 
+static struct ethtool_ops ops = {
+	.get_drvinfo = catc_get_drvinfo,
+	.get_settings = catc_get_settings,
+	.get_link = ethtool_op_get_link
+};
 
 /*
  * Open, close.
@@ -739,7 +703,7 @@
 
 static int catc_open(struct net_device *netdev)
 {
-	struct catc *catc = netdev->priv;
+	struct catc *catc = netdev_priv(netdev);
 	int status;
 
 	catc->irq_urb->dev = catc->usbdev;
@@ -758,17 +722,17 @@
 
 static int catc_stop(struct net_device *netdev)
 {
-	struct catc *catc = netdev->priv;
+	struct catc *catc = netdev_priv(netdev);
 
 	netif_stop_queue(netdev);
 
 	if (!catc->is_f5u011)
 		del_timer_sync(&catc->timer);
 
-	usb_unlink_urb(catc->rx_urb);
-	usb_unlink_urb(catc->tx_urb);
-	usb_unlink_urb(catc->irq_urb);
-	usb_unlink_urb(catc->ctrl_urb);
+	usb_kill_urb(catc->rx_urb);
+	usb_kill_urb(catc->tx_urb);
+	usb_kill_urb(catc->irq_urb);
+	usb_kill_urb(catc->ctrl_urb);
 
 	return 0;
 }
@@ -791,17 +755,11 @@
 		return -EIO;
 	}
 
-	catc = kmalloc(sizeof(struct catc), GFP_KERNEL);
-	if (!catc)
+	netdev = alloc_etherdev(sizeof(struct catc));
+	if (!netdev)
 		return -ENOMEM;
 
-	memset(catc, 0, sizeof(struct catc));
-
-	netdev = alloc_etherdev(0);
-	if (!netdev) {
-		kfree(catc);
-		return -EIO;
-	}
+	catc = netdev_priv(netdev);
 
 	netdev->open = catc_open;
 	netdev->hard_start_xmit = catc_hard_start_xmit;
@@ -810,14 +768,13 @@
 	netdev->tx_timeout = catc_tx_timeout;
 	netdev->watchdog_timeo = TX_TIMEOUT;
 	netdev->set_multicast_list = catc_set_multicast_list;
-	netdev->do_ioctl = catc_ioctl;
-	netdev->priv = catc;
+	SET_ETHTOOL_OPS(netdev, &ops);
 
 	catc->usbdev = usbdev;
 	catc->netdev = netdev;
 
-	catc->tx_lock = SPIN_LOCK_UNLOCKED;
-	catc->ctrl_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&catc->tx_lock);
+	spin_lock_init(&catc->ctrl_lock);
 
 	init_timer(&catc->timer);
 	catc->timer.data = (long) catc;
@@ -839,7 +796,6 @@
 		if (catc->irq_urb)
 			usb_free_urb(catc->irq_urb);
 		free_netdev(netdev);
-		kfree(catc);
 		return -ENOMEM;
 	}
 
@@ -944,7 +900,6 @@
 		usb_free_urb(catc->rx_urb);
 		usb_free_urb(catc->irq_urb);
 		free_netdev(netdev);
-		kfree(catc);
 		return -EIO;
 	}
 	return 0;
@@ -962,7 +917,6 @@
 		usb_free_urb(catc->rx_urb);
 		usb_free_urb(catc->irq_urb);
 		free_netdev(catc->netdev);
-		kfree(catc);
 	}
 }
 
diff -Nru a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
--- a/drivers/usb/net/kaweth.c	2004-12-24 13:37:03 -08:00
+++ b/drivers/usb/net/kaweth.c	2004-12-24 13:37:03 -08:00
@@ -246,7 +246,7 @@
 	struct kaweth_ethernet_configuration configuration;
 
 	struct net_device_stats stats;
-} __attribute__ ((packed));
+};
 
 
 /****************************************************************
@@ -651,7 +651,7 @@
  ****************************************************************/
 static int kaweth_open(struct net_device *net)
 {
-	struct kaweth_device *kaweth = (struct kaweth_device *)net->priv;
+	struct kaweth_device *kaweth = netdev_priv(net);
 	int res;
 
 	kaweth_dbg("Opening network device.");
@@ -668,13 +668,13 @@
 		INTBUFFERSIZE,
 		int_callback,
 		kaweth,
-		8);
+		250); /* overriding the descriptor */
 	kaweth->irq_urb->transfer_dma = kaweth->intbufferhandle;
 	kaweth->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
 
 	res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL);
 	if (res) {
-		usb_unlink_urb(kaweth->rx_urb);
+		usb_kill_urb(kaweth->rx_urb);
 		return -EIO;
 	}
 
@@ -689,58 +689,36 @@
  ****************************************************************/
 static int kaweth_close(struct net_device *net)
 {
-	struct kaweth_device *kaweth = net->priv;
+	struct kaweth_device *kaweth = netdev_priv(net);
 
 	netif_stop_queue(net);
 
 	kaweth->status |= KAWETH_STATUS_CLOSING;
 
-	usb_unlink_urb(kaweth->irq_urb);
-	usb_unlink_urb(kaweth->rx_urb);
+	usb_kill_urb(kaweth->irq_urb);
+	usb_kill_urb(kaweth->rx_urb);
 
 	flush_scheduled_work();
 
 	/* a scheduled work may have resubmitted,
 	   we hit them again */
-	usb_unlink_urb(kaweth->irq_urb);
-	usb_unlink_urb(kaweth->rx_urb);
+	usb_kill_urb(kaweth->irq_urb);
+	usb_kill_urb(kaweth->rx_urb);
 
 	kaweth->status &= ~KAWETH_STATUS_CLOSING;
 
 	return 0;
 }
 
-static int netdev_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
+static void kaweth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-	u32 ethcmd;
-
-	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-		return -EFAULT;
-
-	switch (ethcmd) {
-	case ETHTOOL_GDRVINFO: {
-		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-		strlcpy(info.driver, driver_name, sizeof(info.driver));
-		if (copy_to_user(useraddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-	}
-	}
 
-	return -EOPNOTSUPP;
+	strlcpy(info->driver, driver_name, sizeof(info->driver));
 }
 
-/****************************************************************
- *     kaweth_ioctl
- ****************************************************************/
-static int kaweth_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
-{
-	switch (cmd) {
-	case SIOCETHTOOL:
-		return netdev_ethtool_ioctl(net, rq->ifr_data);
-	}
-	return -EOPNOTSUPP;
-}
+static struct ethtool_ops ops = {
+	.get_drvinfo = kaweth_get_drvinfo
+};
 
 /****************************************************************
  *     kaweth_usb_transmit_complete
@@ -751,7 +729,8 @@
 	struct sk_buff *skb = kaweth->tx_skb;
 
 	if (unlikely(urb->status != 0))
-		kaweth_dbg("%s: TX status %d.", kaweth->net->name, urb->status);
+		if (urb->status != -ENOENT)
+			kaweth_dbg("%s: TX status %d.", kaweth->net->name, urb->status);
 
 	netif_wake_queue(kaweth->net);
 	dev_kfree_skb_irq(skb);
@@ -762,7 +741,7 @@
  ****************************************************************/
 static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net)
 {
-	struct kaweth_device *kaweth = net->priv;
+	struct kaweth_device *kaweth = netdev_priv(net);
 	__le16 *private_header;
 
 	int res;
@@ -833,7 +812,7 @@
  ****************************************************************/
 static void kaweth_set_rx_mode(struct net_device *net)
 {
-	struct kaweth_device *kaweth = net->priv;
+	struct kaweth_device *kaweth = netdev_priv(net);
 
 	__u16 packet_filter_bitmap = KAWETH_PACKET_FILTER_DIRECTED |
                                      KAWETH_PACKET_FILTER_BROADCAST |
@@ -890,7 +869,8 @@
  ****************************************************************/
 static struct net_device_stats *kaweth_netdev_stats(struct net_device *dev)
 {
-	return &((struct kaweth_device *)dev->priv)->stats;
+	struct kaweth_device *kaweth = netdev_priv(dev);
+	return &kaweth->stats;
 }
 
 /****************************************************************
@@ -898,7 +878,7 @@
  ****************************************************************/
 static void kaweth_tx_timeout(struct net_device *net)
 {
-	struct kaweth_device *kaweth = net->priv;
+	struct kaweth_device *kaweth = netdev_priv(net);
 
 	kaweth_warn("%s: Tx timed out. Resetting.", net->name);
 	kaweth->stats.tx_errors++;
@@ -933,12 +913,14 @@
 		 (int)dev->descriptor.bLength,
 		 (int)dev->descriptor.bDescriptorType);
 
-	if(!(kaweth = kmalloc(sizeof(struct kaweth_device), GFP_KERNEL)))
+	netdev = alloc_etherdev(sizeof(*kaweth));
+	if (!netdev)
 		return -ENOMEM;
 
-	memset(kaweth, 0, sizeof(struct kaweth_device));
-
+	kaweth = netdev_priv(netdev);
 	kaweth->dev = dev;
+	kaweth->net = netdev;
+
 	spin_lock_init(&kaweth->device_lock);
 	init_waitqueue_head(&kaweth->term_wait);
 
@@ -963,9 +945,7 @@
 						      100,
 						      2)) < 0) {
 			kaweth_err("Error downloading firmware (%d)", result);
-			free_page((unsigned long)kaweth->firmware_buf);
-			kfree(kaweth);
-			return -EIO;
+			goto err_fw;
 		}
 
 		if ((result = kaweth_download_firmware(kaweth,
@@ -974,9 +954,7 @@
 						      100,
 						      3)) < 0) {
 			kaweth_err("Error downloading firmware fix (%d)", result);
-			free_page((unsigned long)kaweth->firmware_buf);
-			kfree(kaweth);
-			return -EIO;
+			goto err_fw;
 		}
 
 		if ((result = kaweth_download_firmware(kaweth,
@@ -985,9 +963,8 @@
 						      126,
 						      2)) < 0) {
 			kaweth_err("Error downloading trigger code (%d)", result);
-			free_page((unsigned long)kaweth->firmware_buf);
-			kfree(kaweth);
-			return -EIO;
+			goto err_fw;
+
 		}
 
 		if ((result = kaweth_download_firmware(kaweth,
@@ -996,23 +973,20 @@
 						      126,
 						      3)) < 0) {
 			kaweth_err("Error downloading trigger code fix (%d)", result);
-			free_page((unsigned long)kaweth->firmware_buf);
-			kfree(kaweth);
-			return -EIO;
+			goto err_fw;
 		}
 
 
 		if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) {
 			kaweth_err("Error triggering firmware (%d)", result);
-			free_page((unsigned long)kaweth->firmware_buf);
-			kfree(kaweth);
-			return -EIO;
+			goto err_fw;
 		}
 
 		/* Device will now disappear for a moment...  */
 		kaweth_info("Firmware loaded.  I'll be back...");
+err_fw:
 		free_page((unsigned long)kaweth->firmware_buf);
-		kfree(kaweth);
+		free_netdev(netdev);
 		return -EIO;
 	}
 
@@ -1020,8 +994,7 @@
 
 	if(result < 0) {
 		kaweth_err("Error reading configuration (%d), no net device created", result);
-		kfree(kaweth);
-		return -EIO;
+		goto err_free_netdev;
 	}
 
 	kaweth_info("Statistics collection: %x", kaweth->configuration.statistics_mask);
@@ -1039,18 +1012,17 @@
                    &bcast_addr,
 		   sizeof(bcast_addr))) {
 		kaweth_err("Firmware not functioning properly, no net device created");
-		kfree(kaweth);
-		return -EIO;
+		goto err_free_netdev;
 	}
 
 	if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) {
 		kaweth_dbg("Error setting URB size");
-		goto err_no_netdev;
+		goto err_free_netdev;
 	}
 
 	if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) {
 		kaweth_err("Error setting SOFS wait");
-		goto err_no_netdev;
+		goto err_free_netdev;
 	}
 
 	result = kaweth_set_receive_filter(kaweth,
@@ -1060,20 +1032,14 @@
 
 	if(result < 0) {
 		kaweth_err("Error setting receive filter");
-		kfree(kaweth);
-		return -EIO;
+		goto err_free_netdev;
 	}
 
 	kaweth_dbg("Initializing net device.");
 
-	if (!(netdev = alloc_etherdev(0))) {
-		kfree(kaweth);
-		return -ENOMEM;
-	}
-
 	kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!kaweth->tx_urb)
-		goto err_no_urb;
+		goto err_free_netdev;
 	kaweth->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!kaweth->rx_urb)
 		goto err_only_tx;
@@ -1094,26 +1060,23 @@
 	if (!kaweth->rx_buf)
 		goto err_all_but_rxbuf;
 
-	kaweth->net = netdev;
-	memcpy(kaweth->net->broadcast, &bcast_addr, sizeof(bcast_addr));
-	memcpy(kaweth->net->dev_addr,
-               &kaweth->configuration.hw_addr,
+	memcpy(netdev->broadcast, &bcast_addr, sizeof(bcast_addr));
+	memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr,
                sizeof(kaweth->configuration.hw_addr));
 
-	kaweth->net->priv = kaweth;
-	kaweth->net->open = kaweth_open;
-	kaweth->net->stop = kaweth_close;
-
-	kaweth->net->watchdog_timeo = KAWETH_TX_TIMEOUT;
-	kaweth->net->tx_timeout = kaweth_tx_timeout;
-
-	kaweth->net->do_ioctl = kaweth_ioctl;
-	kaweth->net->hard_start_xmit = kaweth_start_xmit;
-	kaweth->net->set_multicast_list = kaweth_set_rx_mode;
-	kaweth->net->get_stats = kaweth_netdev_stats;
-	kaweth->net->mtu = le16_to_cpu(kaweth->configuration.segment_size);
+	netdev->open = kaweth_open;
+	netdev->stop = kaweth_close;
+
+	netdev->watchdog_timeo = KAWETH_TX_TIMEOUT;
+	netdev->tx_timeout = kaweth_tx_timeout;
 
-	memset(&kaweth->stats, 0, sizeof(kaweth->stats));
+	netdev->hard_start_xmit = kaweth_start_xmit;
+	netdev->set_multicast_list = kaweth_set_rx_mode;
+	netdev->get_stats = kaweth_netdev_stats;
+	netdev->mtu = le16_to_cpu(kaweth->configuration.segment_size);
+	SET_ETHTOOL_OPS(netdev, &ops);
+
+	/* kaweth is zeroed as part of alloc_netdev */
 
 	INIT_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl, (void *)kaweth);
 
@@ -1150,10 +1113,9 @@
 	usb_free_urb(kaweth->rx_urb);
 err_only_tx:
 	usb_free_urb(kaweth->tx_urb);
-err_no_urb:
+err_free_netdev:
 	free_netdev(netdev);
-err_no_netdev:
-	kfree(kaweth);
+
 	return -EIO;
 }
 
@@ -1163,6 +1125,7 @@
 static void kaweth_disconnect(struct usb_interface *intf)
 {
 	struct kaweth_device *kaweth = usb_get_intfdata(intf);
+	struct net_device *netdev;
 
 	kaweth_info("Unregistering");
 
@@ -1171,40 +1134,23 @@
 		kaweth_warn("unregistering non-existant device");
 		return;
 	}
-
+	netdev = kaweth->net;
 	kaweth->removed = 1;
-	usb_unlink_urb(kaweth->irq_urb);
-	usb_unlink_urb(kaweth->rx_urb);
-
-	/* we need to wait for the urb to be cancelled, if it is active */
-	spin_lock(&kaweth->device_lock);
-	if (usb_unlink_urb(kaweth->tx_urb) == -EINPROGRESS) {
-		spin_unlock(&kaweth->device_lock);
-		wait_event(kaweth->term_wait, kaweth->end);
-	} else {
-		spin_unlock(&kaweth->device_lock);
-	}
-
-	if(kaweth->net) {
-		if(kaweth->net->flags & IFF_UP) {
-			kaweth_dbg("Closing net device");
-			dev_close(kaweth->net);
-		}
+	usb_kill_urb(kaweth->irq_urb);
+	usb_kill_urb(kaweth->rx_urb);
+	usb_kill_urb(kaweth->tx_urb);
 
-		kaweth_dbg("Unregistering net device");
-		unregister_netdev(kaweth->net);
-		free_netdev(kaweth->net);
-	}
+	kaweth_dbg("Unregistering net device");
+	unregister_netdev(netdev);
 
 	usb_free_urb(kaweth->rx_urb);
 	usb_free_urb(kaweth->tx_urb);
 	usb_free_urb(kaweth->irq_urb);
 
-
 	usb_buffer_free(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle);
 	usb_buffer_free(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle);
 
-	kfree(kaweth);
+	free_netdev(netdev);
 }
 
 
@@ -1250,19 +1196,17 @@
                 return status;
         }
 
-	set_current_state(TASK_UNINTERRUPTIBLE);
 	while (timeout && !awd.done) {
-		timeout = schedule_timeout(timeout);
 		set_current_state(TASK_UNINTERRUPTIBLE);
+		timeout = schedule_timeout(timeout);
 	}
 
-        set_current_state(TASK_RUNNING);
         remove_wait_queue(&awd.wqh, &wait);
 
         if (!timeout) {
                 // timeout
                 kaweth_warn("usb_control/bulk_msg: timeout");
-                usb_unlink_urb(urb);  // remove urb safely
+                usb_kill_urb(urb);  // remove urb safely
                 status = -ETIMEDOUT;
         }
 	else {
diff -Nru a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
--- a/drivers/usb/net/pegasus.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/usb/net/pegasus.c	2004-12-24 13:37:30 -08:00
@@ -308,7 +308,7 @@
 
 static int mdio_read(struct net_device *dev, int phy_id, int loc)
 {
-	pegasus_t *pegasus = (pegasus_t *) dev->priv;
+	pegasus_t *pegasus = (pegasus_t *) netdev_priv(dev);
 	int res;
 
 	read_mii_word(pegasus, phy_id, loc, (u16 *) & res);
@@ -322,7 +322,7 @@
 
 	*(data + 1) = cpu_to_le16p(&regd);
 	set_register(pegasus, PhyCtrl, 0);
-	set_registers(pegasus, PhyAddr, 4, data);
+	set_registers(pegasus, PhyAddr, sizeof(data), data);
 	set_register(pegasus, PhyCtrl, (indx | PHY_WRITE));
 	for (i = 0; i < REG_TIMEOUT; i++) {
 		get_registers(pegasus, PhyCtrl, 1, data);
@@ -338,7 +338,7 @@
 
 static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
 {
-	pegasus_t *pegasus = (pegasus_t *) dev->priv;
+	pegasus_t *pegasus = (pegasus_t *) netdev_priv(dev);
 
 	write_mii_word(pegasus, phy_id, loc, val);
 }
@@ -388,8 +388,8 @@
 
 static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data)
 {
-	int i, tmp;
-	__u8 d[4] = { 0x3f, 0, 0, EPROM_WRITE };
+	int i;
+	__u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE };
 
 	set_registers(pegasus, EpromOffset, 4, d);
 	enable_eprom_write(pegasus);
@@ -471,7 +471,7 @@
 {
 	__u16 linkpart;
 	__u8 data[4];
-	pegasus_t *pegasus = dev->priv;
+	pegasus_t *pegasus = netdev_priv(dev);
 
 	read_mii_word(pegasus, pegasus->phy, MII_LPA, &linkpart);
 	data[0] = 0xc9;
@@ -754,11 +754,7 @@
 
 static void pegasus_tx_timeout(struct net_device *net)
 {
-	pegasus_t *pegasus = net->priv;
-
-	if (!pegasus)
-		return;
-
+	pegasus_t *pegasus = netdev_priv(net);
 	warn("%s: Tx timed out.", net->name);
 	pegasus->tx_urb->transfer_flags |= URB_ASYNC_UNLINK;
 	usb_unlink_urb(pegasus->tx_urb);
@@ -767,7 +763,7 @@
 
 static int pegasus_start_xmit(struct sk_buff *skb, struct net_device *net)
 {
-	pegasus_t *pegasus = net->priv;
+	pegasus_t *pegasus = netdev_priv(net);
 	int count = ((skb->len + 2) & 0x3f) ? skb->len + 2 : skb->len + 3;
 	int res;
 	__u16 l16 = skb->len;
@@ -804,7 +800,7 @@
 
 static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev)
 {
-	return &((pegasus_t *) dev->priv)->stats;
+	return &((pegasus_t *) netdev_priv(dev))->stats;
 }
 
 static inline void disable_net_traffic(pegasus_t * pegasus)
@@ -832,10 +828,9 @@
 
 static void set_carrier(struct net_device *net)
 {
-	pegasus_t *pegasus;
+	pegasus_t *pegasus = netdev_priv(net);
 	short tmp;
 
-	pegasus = net->priv;
 	read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp);
 	if (tmp & BMSR_LSTATUS)
 		netif_carrier_on(net);
@@ -854,10 +849,10 @@
 
 static void unlink_all_urbs(pegasus_t * pegasus)
 {
-	usb_unlink_urb(pegasus->intr_urb);
-	usb_unlink_urb(pegasus->tx_urb);
-	usb_unlink_urb(pegasus->rx_urb);
-	usb_unlink_urb(pegasus->ctrl_urb);
+	usb_kill_urb(pegasus->intr_urb);
+	usb_kill_urb(pegasus->tx_urb);
+	usb_kill_urb(pegasus->rx_urb);
+	usb_kill_urb(pegasus->ctrl_urb);
 }
 
 static int alloc_urbs(pegasus_t * pegasus)
@@ -890,7 +885,7 @@
 
 static int pegasus_open(struct net_device *net)
 {
-	pegasus_t *pegasus = (pegasus_t *) net->priv;
+	pegasus_t *pegasus = netdev_priv(net);
 	int res;
 
 	if (pegasus->rx_skb == NULL)
@@ -920,8 +915,8 @@
 	if ((res = enable_net_traffic(net, pegasus->usb))) {
 		err("can't enable_net_traffic() - %d", res);
 		res = -EIO;
-		usb_unlink_urb(pegasus->rx_urb);
-		usb_unlink_urb(pegasus->intr_urb);
+		usb_kill_urb(pegasus->rx_urb);
+		usb_kill_urb(pegasus->intr_urb);
 		free_skb_pool(pegasus);
 		goto exit;
 	}
@@ -933,7 +928,7 @@
 
 static int pegasus_close(struct net_device *net)
 {
-	pegasus_t *pegasus = net->priv;
+	pegasus_t *pegasus = netdev_priv(net);
 
 	pegasus->flags &= ~PEGASUS_RUNNING;
 	netif_stop_queue(net);
@@ -944,177 +939,124 @@
 
 	return 0;
 }
-#ifdef	CONFIG_MII
-static int pegasus_ethtool_ioctl(struct net_device *dev, void __user *useraddr)
-{
 
-	u32 ethcmd;
-	pegasus_t *pegasus = dev->priv;
+void pegasus_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	pegasus_t *pegasus = netdev_priv(dev);
+	strncpy(info->driver, driver_name, sizeof (info->driver) - 1);
+	strncpy(info->version, DRIVER_VERSION, sizeof (info->version) - 1);
+	usb_make_path(pegasus->usb, info->bus_info, sizeof (info->bus_info));
+}
 
-	if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
-		return -EFAULT;
+#ifdef	CONFIG_MII
+static int pegasus_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	pegasus_t *pegasus = netdev_priv(dev);
+	mii_ethtool_gset(&pegasus->mii, ecmd);
+	return 0;
+}
+static int pegasus_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	pegasus_t *pegasus = netdev_priv(dev);
+	return mii_ethtool_sset(&pegasus->mii, ecmd);
+}
 
-	switch (ethcmd) {
-	/* get driver-specific version/etc. info */
-	case ETHTOOL_GDRVINFO:{
-			struct ethtool_drvinfo info;
-			memset (&info, 0, sizeof (info));
-			info.cmd = ETHTOOL_GDRVINFO;
-			strncpy(info.driver, driver_name,
-				sizeof (info.driver) - 1);
-			strncpy(info.version, DRIVER_VERSION,
-				sizeof (info.version) - 1);
-			usb_make_path(pegasus->usb, info.bus_info,
-				      sizeof (info.bus_info));
-			if (copy_to_user(useraddr, &info, sizeof (info)))
-				return -EFAULT;
-			return 0;
-		}
+static int pegasus_nway_reset(struct net_device *dev)
+{
+	pegasus_t *pegasus = netdev_priv(dev);
+	return mii_nway_restart(&pegasus->mii);
+}
 
-	/* get settings */
-	case ETHTOOL_GSET:{
-			struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-			mii_ethtool_gset(&pegasus->mii, &ecmd);
-			if (copy_to_user(useraddr, &ecmd, sizeof (ecmd)))
-				return -EFAULT;
-			return 0;
-		}
-	/* set settings */
-	case ETHTOOL_SSET:{
-			int r;
-			struct ethtool_cmd ecmd;
-			if (copy_from_user(&ecmd, useraddr, sizeof (ecmd)))
-				return -EFAULT;
-			r = mii_ethtool_sset(&pegasus->mii, &ecmd);
-			return r;
-		}
-	/* restart autonegotiation */
-	case ETHTOOL_NWAY_RST:{
-			return mii_nway_restart(&pegasus->mii);
-		}
+static u32 pegasus_get_link(struct net_device *dev)
+{
+	pegasus_t *pegasus = netdev_priv(dev);
+	return mii_link_ok(&pegasus->mii);
+}
 
-	/* get link status */
-	case ETHTOOL_GLINK:{
-			struct ethtool_value edata = { ETHTOOL_GLINK };
-			edata.data = mii_link_ok(&pegasus->mii);
-			if (copy_to_user(useraddr, &edata, sizeof (edata)))
-				return -EFAULT;
-			return 0;
-		}
-	/* get message-level */
-	case ETHTOOL_GMSGLVL:{
-			struct ethtool_value edata = { ETHTOOL_GMSGLVL };
-			/* edata.data = pegasus->msg_enable; FIXME */
-			if (copy_to_user(useraddr, &edata, sizeof (edata)))
-				return -EFAULT;
-			return 0;
-		}
-	/* set message-level */
-	case ETHTOOL_SMSGLVL:{
-			struct ethtool_value edata;
-			if (copy_from_user(&edata, useraddr, sizeof (edata)))
-				return -EFAULT;
-			/* sp->msg_enable = edata.data; FIXME */
-			return 0;
-		}
+static u32 pegasus_get_msglevel(struct net_device *dev)
+{
+	/*
+	 * pegasus_t *pegasus = netdev_priv(dev);
+	 * return pegasus->msg_enable; FIXME
+	 */
+	return 0;
+}
 
-	}
+static void pegasus_set_msglevel(struct net_device *dev, u32 v)
+{
+	/*
+	 * pegasus_t *pegasus = netdev_priv(dev);
+	 * pegasus->msg_enable = edata.data; FIXME
+	 */
+}
 
-	return -EOPNOTSUPP;
+static struct ethtool_ops ops = {
+	.get_drvinfo = pegasus_get_drvinfo,
+	.get_settings = pegasus_get_settings,
+	.set_settings = pegasus_set_settings,
+	.nway_reset = pegasus_nway_reset,
+	.get_link = pegasus_get_link,
+	.get_msglevel = pegasus_get_msglevel,
+	.set_msglevel = pegasus_set_msglevel,
+};
 
-}
 #else
-static int pegasus_ethtool_ioctl(struct net_device *net, void __user *uaddr)
-{
-	pegasus_t *pegasus;
-	int cmd;
 
-	pegasus = net->priv;
-	if (get_user(cmd, (int __user *) uaddr))
-		return -EFAULT;
-	switch (cmd) {
-	case ETHTOOL_GDRVINFO:{
-			struct ethtool_drvinfo info;
-			memset (&info, 0, sizeof (info));
-			info.cmd = ETHTOOL_GDRVINFO;
-			strncpy(info.driver, driver_name,
-				sizeof (info.driver) - 1);
-			strncpy(info.version, DRIVER_VERSION,
-				sizeof (info.version) - 1);
-			usb_make_path(pegasus->usb, info.bus_info,
-				      sizeof (info.bus_info));
-			if (copy_to_user(uaddr, &info, sizeof (info)))
-				return -EFAULT;
-			return 0;
-		}
-	case ETHTOOL_GSET:{
-			struct ethtool_cmd ecmd;
-			short lpa, bmcr;
-			u8 port;
-
-			memset(&ecmd, 0, sizeof (ecmd));
-			ecmd.supported = (SUPPORTED_10baseT_Half |
-					  SUPPORTED_10baseT_Full |
-					  SUPPORTED_100baseT_Half |
-					  SUPPORTED_100baseT_Full |
-					  SUPPORTED_Autoneg |
-					  SUPPORTED_TP | SUPPORTED_MII);
-			get_registers(pegasus, Reg7b, 1, &port);
-			if (port == 0)
-				ecmd.port = PORT_MII;
-			else
-				ecmd.port = PORT_TP;
-			ecmd.transceiver = XCVR_INTERNAL;
-			ecmd.phy_address = pegasus->phy;
-			read_mii_word(pegasus, pegasus->phy, MII_BMCR, &bmcr);
-			read_mii_word(pegasus, pegasus->phy, MII_LPA, &lpa);
-			if (bmcr & BMCR_ANENABLE) {
-				ecmd.autoneg = AUTONEG_ENABLE;
-				ecmd.speed = lpa & (LPA_100HALF | LPA_100FULL) ?
-				    SPEED_100 : SPEED_10;
-				if (ecmd.speed == SPEED_100)
-					ecmd.duplex = lpa & LPA_100FULL ?
-					    DUPLEX_FULL : DUPLEX_HALF;
-				else
-					ecmd.duplex = lpa & LPA_10FULL ?
-					    DUPLEX_FULL : DUPLEX_HALF;
-			} else {
-				ecmd.autoneg = AUTONEG_DISABLE;
-				ecmd.speed = bmcr & BMCR_SPEED100 ?
-				    SPEED_100 : SPEED_10;
-				ecmd.duplex = bmcr & BMCR_FULLDPLX ?
-				    DUPLEX_FULL : DUPLEX_HALF;
-			}
-			if (copy_to_user(uaddr, &ecmd, sizeof (ecmd)))
-				return -EFAULT;
-
-			return 0;
-		}
-	case ETHTOOL_SSET:{
-			return -EOPNOTSUPP;
-		}
-	case ETHTOOL_GLINK:{
-			struct ethtool_value edata = { ETHTOOL_GLINK };
-			edata.data = netif_carrier_ok(net);
-			if (copy_to_user(uaddr, &edata, sizeof (edata)))
-				return -EFAULT;
-			return 0;
-		}
-	default:
-		return -EOPNOTSUPP;
+static int pegasus_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	pegasus_t *pegasus = netdev_priv(dev);
+	short lpa, bmcr;
+	u8 port;
+
+	ecmd->supported = (SUPPORTED_10baseT_Half |
+			  SUPPORTED_10baseT_Full |
+			  SUPPORTED_100baseT_Half |
+			  SUPPORTED_100baseT_Full |
+			  SUPPORTED_Autoneg |
+			  SUPPORTED_TP | SUPPORTED_MII);
+	get_registers(pegasus, Reg7b, 1, &port);
+	if (port == 0)
+		ecmd->port = PORT_MII;
+	else
+		ecmd->port = PORT_TP;
+	ecmd->transceiver = XCVR_INTERNAL;
+	ecmd->phy_address = pegasus->phy;
+	read_mii_word(pegasus, pegasus->phy, MII_BMCR, &bmcr);
+	read_mii_word(pegasus, pegasus->phy, MII_LPA, &lpa);
+	if (bmcr & BMCR_ANENABLE) {
+		ecmd->autoneg = AUTONEG_ENABLE;
+		ecmd->speed = lpa & (LPA_100HALF | LPA_100FULL) ?
+		    SPEED_100 : SPEED_10;
+		if (ecmd->speed == SPEED_100)
+			ecmd->duplex = lpa & LPA_100FULL ?
+			    DUPLEX_FULL : DUPLEX_HALF;
+		else
+			ecmd->duplex = lpa & LPA_10FULL ?
+			    DUPLEX_FULL : DUPLEX_HALF;
+	} else {
+		ecmd->autoneg = AUTONEG_DISABLE;
+		ecmd->speed = bmcr & BMCR_SPEED100 ?
+		    SPEED_100 : SPEED_10;
+		ecmd->duplex = bmcr & BMCR_FULLDPLX ?
+		    DUPLEX_FULL : DUPLEX_HALF;
 	}
+	return 0;
 }
+
+static struct ethtool_ops ops = {
+	.get_drvinfo = pegasus_get_drvinfo,
+	.get_settings = pegasus_get_settings,
+	.get_link = ethtool_op_get_link,
+};
 #endif
+
 static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
 {
 	__u16 *data = (__u16 *) & rq->ifr_ifru;
-	pegasus_t *pegasus = net->priv;
+	pegasus_t *pegasus = netdev_priv(net);
 	int res;
 
 	switch (cmd) {
-	case SIOCETHTOOL:
-		res = pegasus_ethtool_ioctl(net, rq->ifr_data);
-		break;
 	case SIOCDEVPRIVATE:
 		data[0] = pegasus->phy;
 	case SIOCDEVPRIVATE + 1:
@@ -1135,7 +1077,7 @@
 
 static void pegasus_set_multicast(struct net_device *net)
 {
-	pegasus_t *pegasus = net->priv;
+	pegasus_t *pegasus = netdev_priv(net);
 
 	if (net->flags & IFF_PROMISC) {
 		pegasus->eth_regs[EthCtrl2] |= RX_PROMISCUOUS;
@@ -1172,7 +1114,7 @@
 
 static inline void setup_pegasus_II(pegasus_t * pegasus)
 {
-	u16 data = 0xa5;
+	__u8 data = 0xa5;
 	
 	set_register(pegasus, Reg1d, 0);
 	set_register(pegasus, Reg7b, 1);
@@ -1211,11 +1153,13 @@
 	int res = -ENOMEM;
 
 	usb_get_dev(dev);
-	if (!(pegasus = kmalloc(sizeof (struct pegasus), GFP_KERNEL))) {
+	net = alloc_etherdev(sizeof(struct pegasus));
+	if (!net) {
 		err("out of memory allocating device structure");
 		goto out;
 	}
 
+	pegasus = netdev_priv(net);
 	memset(pegasus, 0, sizeof (struct pegasus));
 	pegasus->dev_index = dev_index;
 	init_waitqueue_head(&pegasus->ctrl_wait);
@@ -1223,16 +1167,11 @@
 	if (!alloc_urbs(pegasus))
 		goto out1;
 
-	net = alloc_etherdev(0);
-	if (!net)
-		goto out2;
-
 	tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus);
 
 	pegasus->usb = dev;
 	pegasus->net = net;
 	SET_MODULE_OWNER(net);
-	net->priv = pegasus;
 	net->open = pegasus_open;
 	net->stop = pegasus_close;
 	net->watchdog_timeo = PEGASUS_TX_TIMEOUT;
@@ -1242,6 +1181,7 @@
 	net->set_multicast_list = pegasus_set_multicast;
 	net->get_stats = pegasus_netdev_stats;
 	net->mtu = PEGASUS_MTU;
+	SET_ETHTOOL_OPS(net, &ops);
 	pegasus->mii.dev = net;
 	pegasus->mii.mdio_read = mdio_read;
 	pegasus->mii.mdio_write = mdio_write;
@@ -1254,7 +1194,7 @@
 	if (reset_mac(pegasus)) {
 		err("can't reset MAC");
 		res = -EIO;
-		goto out3;
+		goto out2;
 	}
 	set_ethernet_addr(pegasus);
 	fill_skb_pool(pegasus);
@@ -1271,19 +1211,17 @@
 	SET_NETDEV_DEV(net, &intf->dev);
 	res = register_netdev(net);
 	if (res)
-		goto out4;
+		goto out3;
 	printk("%s: %s\n", net->name, usb_dev_id[dev_index].name);
 	return 0;
 
-out4:
+out3:
 	usb_set_intfdata(intf, NULL);
 	free_skb_pool(pegasus);
-out3:
-	free_netdev(net);
 out2:
 	free_all_urbs(pegasus);
 out1:
-	kfree(pegasus);
+	free_netdev(net);
 out:
 	usb_put_dev(dev);
 	return res;
@@ -1307,7 +1245,6 @@
 	if (pegasus->rx_skb)
 		dev_kfree_skb(pegasus->rx_skb);
 	free_netdev(pegasus->net);
-	kfree(pegasus);
 }
 
 static struct usb_driver pegasus_driver = {
diff -Nru a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
--- a/drivers/usb/net/rtl8150.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/usb/net/rtl8150.c	2004-12-24 13:37:00 -08:00
@@ -20,7 +20,7 @@
 #include <asm/uaccess.h>
 
 /* Version Information */
-#define DRIVER_VERSION "v0.6.1 (2004/03/13)"
+#define DRIVER_VERSION "v0.6.2 (2004/08/27)"
 #define DRIVER_AUTHOR "Petko Manolov <petkan@users.sourceforge.net>"
 #define DRIVER_DESC "rtl8150 based usb-ethernet driver"
 
@@ -304,15 +304,12 @@
 static int rtl8150_set_mac_address(struct net_device *netdev, void *p)
 {
 	struct sockaddr *addr = p;
-	rtl8150_t *dev;
+	rtl8150_t *dev = netdev_priv(netdev);
 	int i;
 
 	if (netif_running(netdev))
 		return -EBUSY;
-	dev = netdev->priv;
-	if (dev == NULL) {
-		return -ENODEV;
-	}
+
 	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
 	dbg("%s: Setting MAC address to ", netdev->name);
 	for (i = 0; i < 5; i++)
@@ -392,10 +389,10 @@
 
 static void unlink_all_urbs(rtl8150_t * dev)
 {
-	usb_unlink_urb(dev->rx_urb);
-	usb_unlink_urb(dev->tx_urb);
-	usb_unlink_urb(dev->intr_urb);
-	usb_unlink_urb(dev->ctrl_urb);
+	usb_kill_urb(dev->rx_urb);
+	usb_kill_urb(dev->tx_urb);
+	usb_kill_urb(dev->intr_urb);
+	usb_kill_urb(dev->ctrl_urb);
 }
 
 static inline struct sk_buff *pull_skb(rtl8150_t *dev)
@@ -651,16 +648,12 @@
 
 static struct net_device_stats *rtl8150_netdev_stats(struct net_device *dev)
 {
-	return &((rtl8150_t *) dev->priv)->stats;
+	return &((rtl8150_t *)netdev_priv(dev))->stats;
 }
 
 static void rtl8150_tx_timeout(struct net_device *netdev)
 {
-	rtl8150_t *dev;
-
-	dev = netdev->priv;
-	if (!dev)
-		return;
+	rtl8150_t *dev = netdev_priv(netdev);
 	warn("%s: Tx timeout.", netdev->name);
 	dev->tx_urb->transfer_flags |= URB_ASYNC_UNLINK;
 	usb_unlink_urb(dev->tx_urb);
@@ -669,9 +662,7 @@
 
 static void rtl8150_set_multicast(struct net_device *netdev)
 {
-	rtl8150_t *dev;
-
-	dev = netdev->priv;
+	rtl8150_t *dev = netdev_priv(netdev);
 	netif_stop_queue(netdev);
 	if (netdev->flags & IFF_PROMISC) {
 		dev->rx_creg |= cpu_to_le16(0x0001);
@@ -691,11 +682,10 @@
 
 static int rtl8150_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
-	rtl8150_t *dev;
+	rtl8150_t *dev = netdev_priv(netdev);
 	int count, res;
 
 	netif_stop_queue(netdev);
-	dev = netdev->priv;
 	count = (skb->len < 60) ? 60 : skb->len;
 	count = (count & 0x3f) ? count : count + 1;
 	dev->tx_skb = skb;
@@ -717,7 +707,7 @@
 
 static void set_carrier(struct net_device *netdev)
 {
-	rtl8150_t *dev = netdev->priv;
+	rtl8150_t *dev = netdev_priv(netdev);
 	short tmp;
 
 	get_registers(dev, CSCR, 2, &tmp);
@@ -729,13 +719,9 @@
 
 static int rtl8150_open(struct net_device *netdev)
 {
-	rtl8150_t *dev;
+	rtl8150_t *dev = netdev_priv(netdev);
 	int res;
 
-	dev = netdev->priv;
-	if (dev == NULL) {
-		return -ENODEV;
-	}
 	if (dev->rx_skb == NULL)
 		dev->rx_skb = pull_skb(dev);
 	if (!dev->rx_skb)
@@ -761,13 +747,9 @@
 
 static int rtl8150_close(struct net_device *netdev)
 {
-	rtl8150_t *dev;
+	rtl8150_t *dev = netdev_priv(netdev);
 	int res = 0;
 
-	dev = netdev->priv;
-	if (!dev)
-		return -ENODEV;
-
 	netif_stop_queue(netdev);
 	if (!test_bit(RTL8150_UNPLUG, &dev->flags))
 		disable_net_traffic(dev);
@@ -776,93 +758,64 @@
 	return res;
 }
 
-static int rtl8150_ethtool_ioctl(struct net_device *netdev, void __user *uaddr)
+static void rtl8150_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info)
 {
-	rtl8150_t *dev;
-	int cmd;
-
-	dev = netdev->priv;
-	if (get_user(cmd, (int __user *) uaddr))
-		return -EFAULT;
+	rtl8150_t *dev = netdev_priv(netdev);
 
-	switch (cmd) {
-	case ETHTOOL_GDRVINFO:{
-		struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-
-		strncpy(info.driver, driver_name, ETHTOOL_BUSINFO_LEN);
-		strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
-		usb_make_path(dev->udev, info.bus_info, sizeof info.bus_info);
-		if (copy_to_user(uaddr, &info, sizeof(info)))
-			return -EFAULT;
-		return 0;
-		}
-	case ETHTOOL_GSET:{
-		struct ethtool_cmd ecmd;
-		short lpa, bmcr;
-
-		if (copy_from_user(&ecmd, uaddr, sizeof(ecmd)))
-			return -EFAULT;
-		ecmd.supported = (SUPPORTED_10baseT_Half |
-				  SUPPORTED_10baseT_Full |
-				  SUPPORTED_100baseT_Half |
-				  SUPPORTED_100baseT_Full |
-				  SUPPORTED_Autoneg |
-				  SUPPORTED_TP | SUPPORTED_MII);
-		ecmd.port = PORT_TP;
-		ecmd.transceiver = XCVR_INTERNAL;
-		ecmd.phy_address = dev->phy;
-		get_registers(dev, BMCR, 2, &bmcr);
-		get_registers(dev, ANLP, 2, &lpa);
-		if (bmcr & BMCR_ANENABLE) {
-			ecmd.autoneg = AUTONEG_ENABLE;
-			ecmd.speed = (lpa & (LPA_100HALF | LPA_100FULL)) ?
-			             SPEED_100 : SPEED_10;
-			if (ecmd.speed == SPEED_100)
-				ecmd.duplex = (lpa & LPA_100FULL) ?
-				    DUPLEX_FULL : DUPLEX_HALF;
-			else
-				ecmd.duplex = (lpa & LPA_10FULL) ?
-				    DUPLEX_FULL : DUPLEX_HALF;
-		} else {
-			ecmd.autoneg = AUTONEG_DISABLE;
-			ecmd.speed = (bmcr & BMCR_SPEED100) ?
-			    SPEED_100 : SPEED_10;
-			ecmd.duplex = (bmcr & BMCR_FULLDPLX) ?
+	strncpy(info->driver, driver_name, ETHTOOL_BUSINFO_LEN);
+	strncpy(info->version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
+	usb_make_path(dev->udev, info->bus_info, sizeof info->bus_info);
+}
+
+static int rtl8150_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
+{
+	rtl8150_t *dev = netdev_priv(netdev);
+	short lpa, bmcr;
+
+	ecmd->supported = (SUPPORTED_10baseT_Half |
+			  SUPPORTED_10baseT_Full |
+			  SUPPORTED_100baseT_Half |
+			  SUPPORTED_100baseT_Full |
+			  SUPPORTED_Autoneg |
+			  SUPPORTED_TP | SUPPORTED_MII);
+	ecmd->port = PORT_TP;
+	ecmd->transceiver = XCVR_INTERNAL;
+	ecmd->phy_address = dev->phy;
+	get_registers(dev, BMCR, 2, &bmcr);
+	get_registers(dev, ANLP, 2, &lpa);
+	if (bmcr & BMCR_ANENABLE) {
+		ecmd->autoneg = AUTONEG_ENABLE;
+		ecmd->speed = (lpa & (LPA_100HALF | LPA_100FULL)) ?
+			     SPEED_100 : SPEED_10;
+		if (ecmd->speed == SPEED_100)
+			ecmd->duplex = (lpa & LPA_100FULL) ?
 			    DUPLEX_FULL : DUPLEX_HALF;
-		}
-		if (copy_to_user(uaddr, &ecmd, sizeof(ecmd)))
-			return -EFAULT;
-		return 0;
-		}
-	case ETHTOOL_SSET:
-		return -ENOTSUPP;
-	case ETHTOOL_GLINK:{
-		struct ethtool_value edata = { ETHTOOL_GLINK };
-
-		edata.data = netif_carrier_ok(netdev);
-		if (copy_to_user(uaddr, &edata, sizeof(edata)))
-			return -EFAULT;
-		return 0;
-		}
-	default:
-		return -EOPNOTSUPP;
+		else
+			ecmd->duplex = (lpa & LPA_10FULL) ?
+			    DUPLEX_FULL : DUPLEX_HALF;
+	} else {
+		ecmd->autoneg = AUTONEG_DISABLE;
+		ecmd->speed = (bmcr & BMCR_SPEED100) ?
+		    SPEED_100 : SPEED_10;
+		ecmd->duplex = (bmcr & BMCR_FULLDPLX) ?
+		    DUPLEX_FULL : DUPLEX_HALF;
 	}
+	return 0;
 }
 
+static struct ethtool_ops ops = {
+	.get_drvinfo = rtl8150_get_drvinfo,
+	.get_settings = rtl8150_get_settings,
+	.get_link = ethtool_op_get_link
+};
+
 static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 {
-	rtl8150_t *dev;
-	u16 *data;
-	int res;
-
-	dev = netdev->priv;
-	data = (u16 *) & rq->ifr_ifru;
-	res = 0;
+	rtl8150_t *dev = netdev_priv(netdev);
+	u16 *data = (u16 *) & rq->ifr_ifru;
+	int res = 0;
 
 	switch (cmd) {
-	case SIOCETHTOOL:
-		res = rtl8150_ethtool_ioctl(netdev, rq->ifr_data);
-		break;
 	case SIOCDEVPRIVATE:
 		data[0] = dev->phy;
 	case SIOCDEVPRIVATE + 1:
@@ -887,23 +840,18 @@
 	rtl8150_t *dev;
 	struct net_device *netdev;
 
-	dev = kmalloc(sizeof(rtl8150_t), GFP_KERNEL);
-	if (!dev) {
+	netdev = alloc_etherdev(sizeof(rtl8150_t));
+	if (!netdev) {
 		err("Out of memory");
 		return -ENOMEM;
-	} else
-		memset(dev, 0, sizeof(rtl8150_t));
+	}
+
+	dev = netdev_priv(netdev);
+	memset(dev, 0, sizeof(rtl8150_t));
 
 	dev->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL);
 	if (!dev->intr_buff) {
-		kfree(dev);
-		return -ENOMEM;
-	}
-	netdev = alloc_etherdev(0);
-	if (!netdev) {
-		kfree(dev->intr_buff);
-		kfree(dev);
-		err("Oh boy, out of memory again?!?");
+		free_netdev(netdev);
 		return -ENOMEM;
 	}
 
@@ -913,7 +861,6 @@
 	dev->udev = udev;
 	dev->netdev = netdev;
 	SET_MODULE_OWNER(netdev);
-	netdev->priv = dev;
 	netdev->open = rtl8150_open;
 	netdev->stop = rtl8150_close;
 	netdev->do_ioctl = rtl8150_ioctl;
@@ -924,6 +871,7 @@
 	netdev->set_mac_address = rtl8150_set_mac_address;
 	netdev->get_stats = rtl8150_netdev_stats;
 	netdev->mtu = RTL8150_MTU;
+	SET_ETHTOOL_OPS(netdev, &ops);
 	dev->intr_interval = 100;	/* 100ms */
 
 	if (!alloc_all_urbs(dev)) {
@@ -954,7 +902,6 @@
 out:
 	kfree(dev->intr_buff);
 	free_netdev(netdev);
-	kfree(dev);
 	return -EIO;
 }
 
@@ -971,9 +918,8 @@
 		free_skb_pool(dev);
 		if (dev->rx_skb)
 			dev_kfree_skb(dev->rx_skb);
-		free_netdev(dev->netdev);
 		kfree(dev->intr_buff);
-		kfree(dev);
+		free_netdev(dev->netdev);
 	}
 }
 
diff -Nru a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
--- a/drivers/usb/net/usbnet.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/usb/net/usbnet.c	2004-12-24 13:36:55 -08:00
@@ -31,6 +31,7 @@
  *	- GeneSys GL620USB-A
  *	- NetChip 1080 (interoperates with NetChip Win32 drivers)
  *	- Prolific PL-2301/2302 (replaces "plusb" driver)
+ *	- KC Technology KC2190
  *
  *   + Smart USB devices can support such links directly, using Internet
  *     standard protocols instead of proprietary host-to-device links.
@@ -106,6 +107,7 @@
  * 22-aug-2003	AX8817X support (Dave Hollis).
  * 14-jun-2004  Trivial patch for AX8817X based Buffalo LUA-U2-KTX in Japan
  *		(Neil Bortnak)
+ * 03-nov-2004	Trivial patch for KC2190 (KC-190) chip. (Jonathan McDowell)
  *
  *-------------------------------------------------------------------------*/
 
@@ -134,7 +136,7 @@
 #include <linux/mm.h>
 #include <linux/dma-mapping.h>
 
-#define DRIVER_VERSION		"25-Aug-2003"
+#define DRIVER_VERSION		"03-Nov-2004"
 
 
 /*-------------------------------------------------------------------------*/
@@ -525,7 +527,7 @@
 				devdbg(dev, "ax8817x - Link Status is: %d", link);
 			}
 		}
-		usb_submit_urb(data->int_urb, GFP_KERNEL);
+		usb_submit_urb(data->int_urb, GFP_ATOMIC);
 	}
 }
 
@@ -567,7 +569,7 @@
 
 static void ax8817x_set_multicast(struct net_device *net)
 {
-	struct usbnet *dev = (struct usbnet *) net->priv;
+	struct usbnet *dev = netdev_priv(net);
 	struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
 	u8 rx_ctl = 0x8c;
 
@@ -610,7 +612,7 @@
 
 static int ax8817x_mdio_read(struct net_device *netdev, int phy_id, int loc)
 {
-	struct usbnet *dev = netdev->priv;
+	struct usbnet *dev = netdev_priv(netdev);
 	u16 res;
 	u8 buf[1];
 
@@ -623,7 +625,7 @@
 
 static void ax8817x_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
 {
-	struct usbnet *dev = netdev->priv;
+	struct usbnet *dev = netdev_priv(netdev);
 	u16 res = val;
 	u8 buf[1];
 
@@ -634,7 +636,7 @@
 
 static void ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
 {
-	struct usbnet *dev = (struct usbnet *)net->priv;
+	struct usbnet *dev = netdev_priv(net);
 	u8 opt;
 
 	if (ax8817x_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) {
@@ -654,7 +656,7 @@
 
 static int ax8817x_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
 {
-	struct usbnet *dev = (struct usbnet *)net->priv;
+	struct usbnet *dev = netdev_priv(net);
 	u8 opt = 0;
 	u8 buf[1];
 
@@ -675,7 +677,7 @@
 static int ax8817x_get_eeprom(struct net_device *net,
 			      struct ethtool_eeprom *eeprom, u8 *data)
 {
-	struct usbnet *dev = (struct usbnet *)net->priv;
+	struct usbnet *dev = netdev_priv(net);
 	u16 *ebuf = (u16 *)data;
 	int i;
 
@@ -704,14 +706,14 @@
 
 static int ax8817x_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
 {
-	struct usbnet *dev = (struct usbnet *)net->priv;
+	struct usbnet *dev = netdev_priv(net);
 
 	return mii_ethtool_gset(&dev->mii,cmd);
 }
 
 static int ax8817x_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
 {
-	struct usbnet *dev = (struct usbnet *)net->priv;
+	struct usbnet *dev = netdev_priv(net);
 
 	return mii_ethtool_sset(&dev->mii,cmd);
 }
@@ -825,7 +827,7 @@
 {
 	struct ax8817x_data *data = (struct ax8817x_data *)dev->data;
 
-	usb_unlink_urb(data->int_urb);
+	usb_kill_urb(data->int_urb);
 	usb_free_urb(data->int_urb);
 	kfree(data->int_buf);
 }
@@ -1437,7 +1439,7 @@
 // handling needs to be generic)
 
 	// cancel irq urb first
-	usb_unlink_urb (priv->irq_urb);
+	usb_kill_urb (priv->irq_urb);
 
 	// free irq urb
 	usb_free_urb (priv->irq_urb);
@@ -2159,6 +2161,13 @@
 
 #endif /* CONFIG_USB_PL2301 */
 
+
+#ifdef CONFIG_USB_KC2190
+#define HAVE_HARDWARE
+static const struct driver_info kc2190_info = {
+	.description =  "KC Technology KC-190",
+};
+#endif /* CONFIG_USB_KC2190 */
 
 
 #ifdef	CONFIG_USB_ARMLINUX
@@ -2276,7 +2285,7 @@
 
 static int usbnet_change_mtu (struct net_device *net, int new_mtu)
 {
-	struct usbnet	*dev = (struct usbnet *) net->priv;
+	struct usbnet	*dev = netdev_priv(net);
 
 	if (new_mtu <= MIN_PACKET || new_mtu > MAX_PACKET)
 		return -EINVAL;
@@ -2302,7 +2311,8 @@
 
 static struct net_device_stats *usbnet_get_stats (struct net_device *net)
 {
-	return &((struct usbnet *) net->priv)->stats;
+	struct usbnet	*dev = netdev_priv(net);
+	return &dev->stats;
 }
 
 /*-------------------------------------------------------------------------*/
@@ -2569,7 +2579,7 @@
 
 static int usbnet_stop (struct net_device *net)
 {
-	struct usbnet		*dev = (struct usbnet *) net->priv;
+	struct usbnet		*dev = netdev_priv(net);
 	int			temp;
 	DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); 
 	DECLARE_WAITQUEUE (wait, current);
@@ -2616,7 +2626,7 @@
 
 static int usbnet_open (struct net_device *net)
 {
-	struct usbnet		*dev = (struct usbnet *) net->priv;
+	struct usbnet		*dev = netdev_priv(net);
 	int			retval = 0;
 	struct driver_info	*info = dev->driver_info;
 
@@ -2666,7 +2676,7 @@
 
 static void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
 {
-	struct usbnet *dev = net->priv;
+	struct usbnet *dev = netdev_priv(net);
 
 	strncpy (info->driver, driver_name, sizeof info->driver);
 	strncpy (info->version, DRIVER_VERSION, sizeof info->version);
@@ -2677,7 +2687,7 @@
 
 static u32 usbnet_get_link (struct net_device *net)
 {
-	struct usbnet *dev = net->priv;
+	struct usbnet *dev = netdev_priv(net);
 
 	/* If a check_connect is defined, return it's results */
 	if (dev->driver_info->check_connect)
@@ -2689,14 +2699,14 @@
 
 static u32 usbnet_get_msglevel (struct net_device *net)
 {
-	struct usbnet *dev = net->priv;
+	struct usbnet *dev = netdev_priv(net);
 
 	return dev->msg_level;
 }
 
 static void usbnet_set_msglevel (struct net_device *net, u32 level)
 {
-	struct usbnet *dev = net->priv;
+	struct usbnet *dev = netdev_priv(net);
 
 	dev->msg_level = level;
 }
@@ -2705,7 +2715,7 @@
 {
 #ifdef NEED_MII
 	{
-	struct usbnet *dev = (struct usbnet *)net->priv;
+	struct usbnet *dev = netdev_priv(net);
 
 	if (dev->mii.mdio_read != NULL && dev->mii.mdio_write != NULL)
 		return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
@@ -2817,7 +2827,7 @@
 
 static void usbnet_tx_timeout (struct net_device *net)
 {
-	struct usbnet		*dev = (struct usbnet *) net->priv;
+	struct usbnet		*dev = netdev_priv(net);
 
 	unlink_urbs (dev, &dev->txq);
 	tasklet_schedule (&dev->bh);
@@ -2829,7 +2839,7 @@
 
 static int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net)
 {
-	struct usbnet		*dev = (struct usbnet *) net->priv;
+	struct usbnet		*dev = netdev_priv(net);
 	int			length;
 	int			retval = NET_XMIT_SUCCESS;
 	struct urb		*urb = NULL;
@@ -3014,6 +3024,7 @@
 {
 	struct usbnet		*dev;
 	struct usb_device	*xdev;
+	struct net_device	*net;
 
 	dev = usb_get_intfdata(intf);
 	usb_set_intfdata(intf, NULL);
@@ -3026,7 +3037,8 @@
 		xdev->bus->bus_name, xdev->devpath,
 		dev->driver_info->description);
 	
-	unregister_netdev (dev->net);
+	net = dev->net;
+	unregister_netdev (net);
 
 	/* we don't hold rtnl here ... */
 	flush_scheduled_work ();
@@ -3034,8 +3046,7 @@
 	if (dev->driver_info->unbind)
 		dev->driver_info->unbind (dev, intf);
 
-	free_netdev(dev->net);
-	kfree (dev);
+	free_netdev(net);
 	usb_put_dev (xdev);
 }
 
@@ -3069,12 +3080,13 @@
 	status = -ENOMEM;
 
 	// set up our own records
-	if (!(dev = kmalloc (sizeof *dev, GFP_KERNEL))) {
+	net = alloc_etherdev(sizeof(*dev));
+	if (!net) {
 		dbg ("can't kmalloc dev");
 		goto out;
 	}
-	memset (dev, 0, sizeof *dev);
 
+	dev = netdev_priv(net);
 	dev->udev = xdev;
 	dev->driver_info = info;
 	dev->msg_level = msg_level;
@@ -3088,14 +3100,8 @@
 	dev->delay.data = (unsigned long) dev;
 	init_timer (&dev->delay);
 
-	// set up network interface records
-	net = alloc_etherdev(0);
-	if (!net)
-		goto out1;
-
 	SET_MODULE_OWNER (net);
 	dev->net = net;
-	net->priv = dev;
 	strcpy (net->name, "usb%d");
 	memcpy (net->dev_addr, node_id, sizeof node_id);
 
@@ -3144,8 +3150,8 @@
 
 	dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
 	
-	SET_NETDEV_DEV(dev->net, &udev->dev);
-	status = register_netdev (dev->net);
+	SET_NETDEV_DEV(net, &udev->dev);
+	status = register_netdev (net);
 	if (status)
 		goto out3;
 	devinfo (dev, "register usbnet at usb-%s-%s, %s",
@@ -3156,16 +3162,15 @@
 	usb_set_intfdata (udev, dev);
 
 	// start as if the link is up
-	netif_device_attach (dev->net);
+	netif_device_attach (net);
 
 	return 0;
 
 out3:
 	if (info->unbind)
 		info->unbind (dev, udev);
-	free_netdev(net);
 out1:
-	kfree(dev);
+	free_netdev(net);
 out:
 	usb_put_dev(xdev);
 	return status;
@@ -3252,6 +3257,14 @@
 	// Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter"
 	USB_DEVICE (0x6189, 0x182d),
 	.driver_info =  (unsigned long) &ax8817x_info,
+}, {
+	// corega FEther USB2-TX
+	USB_DEVICE (0x07aa, 0x0017),
+	.driver_info =  (unsigned long) &ax8817x_info,
+}, {
+	// Surecom EP-1427X-2
+	USB_DEVICE (0x1189, 0x0893),
+	.driver_info = (unsigned long) &ax8817x_info,
 },
 #endif
 
@@ -3292,6 +3305,13 @@
 },
 #endif
 
+#ifdef CONFIG_USB_KC2190
+{
+	USB_DEVICE (0x050f, 0x0190),	// KC-190
+	.driver_info =	(unsigned long) &kc2190_info,
+},
+#endif
+
 #ifdef	CONFIG_USB_RNDIS
 {
 	/* RNDIS is MSFT's un-official variant of CDC ACM */
@@ -3308,11 +3328,18 @@
  *
  * PXA25x or PXA210 ...  these use a "usb-eth" driver much like
  * the sa1100 one, but hardware uses different endpoint numbers.
+ *
+ * Or the Linux "Ethernet" gadget on hardware that can't talk
+ * CDC Ethernet (e.g., no altsettings), in either of two modes:
+ *  - acting just like the old "usb-eth" firmware, though
+ *    the implementation is different 
+ *  - supporting RNDIS as the first/default configuration for
+ *    MS-Windows interop; Linux needs to use the other config
  */
 {
 	// 1183 = 0x049F, both used as hex values?
 	// Compaq "Itsy" vendor/product id
-	USB_DEVICE (0x049F, 0x505A),
+	USB_DEVICE (0x049F, 0x505A),	// usb-eth, or compatible
 	.driver_info =	(unsigned long) &linuxdev_info,
 }, {
 	USB_DEVICE (0x0E7E, 0x1001),	// G.Mate "Yopy"
@@ -3320,6 +3347,10 @@
 }, {
 	USB_DEVICE (0x8086, 0x07d3),	// "blob" bootloader
 	.driver_info =	(unsigned long) &blob_info,
+}, {
+	// Linux Ethernet/RNDIS gadget on pxa210/25x/26x
+	USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
+	.driver_info =	(unsigned long) &linuxdev_info,
 }, 
 #endif
 
diff -Nru a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
--- a/drivers/usb/serial/Kconfig	2004-12-24 13:37:03 -08:00
+++ b/drivers/usb/serial/Kconfig	2004-12-24 13:37:03 -08:00
@@ -89,6 +89,21 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called digi_acceleport.
 
+config USB_SERIAL_CYPRESS_M8
+	tristate "USB Cypress M8 USB Serial Driver"
+	depends on USB_SERIAL && EXPERIMENTAL
+	help
+	  Say Y here if you want to use a device that contains the Cypress
+	  USB to Serial microcontroller, such as the DeLorme Earthmate GPS.
+
+		Attempted SMP support... send bug reports!
+
+	  Supported microcontrollers in the CY4601 family are:
+		CY7C63741 CY7C63742 CY7C63743 CY7C64013
+	
+	  To compile this driver as a module, choose M here: the
+	  module will be called cypress_m8.
+
 config USB_SERIAL_EMPEG
 	tristate "USB Empeg empeg-car Mark I/II Driver"
 	depends on USB_SERIAL
@@ -186,6 +201,16 @@
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called io_ti.
+
+config USB_SERIAL_IPW
+        tristate "USB IPWireless (3G UMTS TDD) Driver (EXPERIMENTAL)"
+	depends on USB_SERIAL && EXPERIMENTAL
+	help
+	  Say Y here if you want to use a IPWireless USB modem such as
+	  the ones supplied by Axity3G/Sentech South Africa.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ipw.
 
 config USB_SERIAL_KEYSPAN_PDA
 	tristate "USB Keyspan PDA Single Port Serial Driver"
diff -Nru a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
--- a/drivers/usb/serial/Makefile	2004-12-24 13:36:19 -08:00
+++ b/drivers/usb/serial/Makefile	2004-12-24 13:36:19 -08:00
@@ -13,12 +13,14 @@
 
 obj-$(CONFIG_USB_SERIAL_BELKIN)			+= belkin_sa.o
 obj-$(CONFIG_USB_SERIAL_CYBERJACK)		+= cyberjack.o
+obj-$(CONFIG_USB_SERIAL_CYPRESS_M8)		+= cypress_m8.o
 obj-$(CONFIG_USB_SERIAL_DIGI_ACCELEPORT)	+= digi_acceleport.o
 obj-$(CONFIG_USB_SERIAL_EDGEPORT)		+= io_edgeport.o
 obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI)		+= io_ti.o
 obj-$(CONFIG_USB_SERIAL_EMPEG)			+= empeg.o
 obj-$(CONFIG_USB_SERIAL_FTDI_SIO)		+= ftdi_sio.o
 obj-$(CONFIG_USB_SERIAL_IPAQ)			+= ipaq.o
+obj-$(CONFIG_USB_SERIAL_IPW)			+= ipw.o
 obj-$(CONFIG_USB_SERIAL_IR)			+= ir-usb.o
 obj-$(CONFIG_USB_SERIAL_KEYSPAN)		+= keyspan.o
 obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA)		+= keyspan_pda.o
diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
--- a/drivers/usb/serial/belkin_sa.c	2004-12-24 13:36:59 -08:00
+++ b/drivers/usb/serial/belkin_sa.c	2004-12-24 13:36:59 -08:00
@@ -228,7 +228,7 @@
 	port->interrupt_in_urb->dev = port->serial->dev;
 	retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
 	if (retval) {
-		usb_unlink_urb(port->read_urb);
+		usb_kill_urb(port->read_urb);
 		err(" usb_submit_urb(read int) failed");
 	}
 
@@ -242,9 +242,9 @@
 	dbg("%s port %d", __FUNCTION__, port->number);
 
 	/* shutdown our bulk reads and writes */
-	usb_unlink_urb (port->write_urb);
-	usb_unlink_urb (port->read_urb);
-	usb_unlink_urb (port->interrupt_in_urb);
+	usb_kill_urb(port->write_urb);
+	usb_kill_urb(port->read_urb);
+	usb_kill_urb(port->interrupt_in_urb);
 } /* belkin_sa_close */
 
 
@@ -607,6 +607,7 @@
 
 MODULE_AUTHOR( DRIVER_AUTHOR );
 MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_VERSION( DRIVER_VERSION );
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
diff -Nru a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
--- a/drivers/usb/serial/bus.c	2004-12-24 13:37:34 -08:00
+++ b/drivers/usb/serial/bus.c	2004-12-24 13:37:34 -08:00
@@ -120,6 +120,7 @@
 	device->driver.bus = &usb_serial_bus_type;
 	device->driver.probe = usb_serial_device_probe;
 	device->driver.remove = usb_serial_device_remove;
+	device->driver.owner = device->owner;
 
 	retval = driver_register(&device->driver);
 
diff -Nru a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
--- a/drivers/usb/serial/console.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/serial/console.c	2004-12-24 13:37:18 -08:00
@@ -218,9 +218,9 @@
 
 	/* pass on to the driver specific version of this function if it is available */
 	if (serial->type->write)
-		retval = serial->type->write(port, 0, buf, count);
+		retval = serial->type->write(port, buf, count);
 	else
-		retval = usb_serial_generic_write(port, 0, buf, count);
+		retval = usb_serial_generic_write(port, buf, count);
 
 exit:
 	dbg("%s - return value (if we had one): %d", __FUNCTION__, retval);
diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
--- a/drivers/usb/serial/cyberjack.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/serial/cyberjack.c	2004-12-24 13:37:19 -08:00
@@ -57,8 +57,7 @@
 static void cyberjack_shutdown (struct usb_serial *serial);
 static int  cyberjack_open (struct usb_serial_port *port, struct file *filp);
 static void cyberjack_close (struct usb_serial_port *port, struct file *filp);
-static int cyberjack_write (struct usb_serial_port *port, int from_user,
-	const unsigned char *buf, int count);
+static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count);
 static int cyberjack_write_room( struct usb_serial_port *port );
 static void cyberjack_read_int_callback (struct urb *urb, struct pt_regs *regs);
 static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
@@ -149,7 +148,7 @@
 	dbg("%s", __FUNCTION__);
 
 	for (i=0; i < serial->num_ports; ++i) {
-		usb_unlink_urb (serial->port[i]->interrupt_in_urb);
+		usb_kill_urb(serial->port[i]->interrupt_in_urb);
 		/* My special items, the standard routines free my urbs */
 		kfree(usb_get_serial_port_data(serial->port[i]));
 		usb_set_serial_port_data(serial->port[i], NULL);
@@ -189,12 +188,12 @@
 
 	if (port->serial->dev) {
 		/* shutdown any bulk reads that might be going on */
-		usb_unlink_urb (port->write_urb);
-		usb_unlink_urb (port->read_urb);
+		usb_kill_urb(port->write_urb);
+		usb_kill_urb(port->read_urb);
 	}
 }
 
-static int cyberjack_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count)
 {
 	struct usb_serial *serial = port->serial;
 	struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -203,7 +202,6 @@
 	int wrexpected;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
-	dbg("%s - from_user %d", __FUNCTION__, from_user);
 
 	if (count == 0) {
 		dbg("%s - write request of 0 bytes", __FUNCTION__);
@@ -225,14 +223,7 @@
 	}
 
 	/* Copy data */
-	if (from_user) {
-		if (copy_from_user(priv->wrbuf+priv->wrfilled, buf, count)) {
-			spin_unlock_irqrestore(&priv->lock, flags);
-			return -EFAULT;
-		}
-	} else {
-		memcpy (priv->wrbuf+priv->wrfilled, buf, count);
-	}  
+	memcpy (priv->wrbuf+priv->wrfilled, buf, count);
 
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count,
 		priv->wrbuf+priv->wrfilled);
@@ -511,6 +502,7 @@
 
 MODULE_AUTHOR( DRIVER_AUTHOR );
 MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_VERSION( DRIVER_VERSION );
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
diff -Nru a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/serial/cypress_m8.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1222 @@
+/*
+ * USB Cypress M8 driver
+ *
+ * 	Copyright (C) 2004
+ * 	    Lonnie Mendez (dignome@gmail.com) 
+ *	Copyright (C) 2003,2004
+ *	    Neil Whelchel (koyama@firstlight.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.
+ *
+ * See Documentation/usb/usb-serial.txt for more information on using this driver
+ *
+ * See http://geocities.com/i0xox0i for information on this driver and the
+ * earthmate usb device.
+ *
+ *
+ *  Lonnie Mendez <dignome@gmail.com>
+ *  04-10-2004
+ *	Driver modified to support dynamic line settings.  Various improvments
+ *      and features.
+ *
+ *  Neil Whelchel
+ *  10-2003
+ *	Driver first released.
+ *
+ *
+ * Long Term TODO:
+ *	Improve transfer speeds - both read/write are somewhat slow
+ *   at this point.
+ */
+
+/* Neil Whelchel wrote the cypress m8 implementation */
+/* Thanks to cypress for providing references for the hid reports. */
+/* Thanks to Jiang Zhang for providing links and for general help. */
+/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others. */
+
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/tty.h>
+#include <linux/tty_driver.h>
+#include <linux/tty_flip.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/spinlock.h>
+#include <asm/uaccess.h>
+#include <linux/usb.h>
+#include <linux/serial.h>
+
+#ifdef CONFIG_USB_SERIAL_DEBUG
+	static int debug = 1;
+#else
+	static int debug;
+#endif
+
+static int stats;
+
+#include "usb-serial.h"
+#include "cypress_m8.h"
+
+/*
+ * Version Information
+ */
+#define DRIVER_VERSION "v1.06"
+#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>"
+#define DRIVER_DESC "Cypress USB to Serial Driver"
+
+static struct usb_device_id id_table_earthmate [] = {
+	{ USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
+	{ }						/* Terminating entry */
+};
+
+static struct usb_device_id id_table_cyphidcomrs232 [] = {
+	{ USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
+	{ }						/* Terminating entry */
+};
+
+static struct usb_device_id id_table_combined [] = {
+	{ USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
+	{ USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
+	{ }						/* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE (usb, id_table_combined);
+
+static struct usb_driver cypress_driver = {
+	.name =		"cypress",
+	.probe =	usb_serial_probe,
+	.disconnect =	usb_serial_disconnect,
+	.id_table =	id_table_combined,
+};
+
+struct cypress_private {
+	spinlock_t lock;		   /* private lock */
+	int chiptype;			   /* identifier of device, for quirks/etc */
+	int bytes_in;			   /* used for statistics */
+	int bytes_out;			   /* used for statistics */
+	int cmd_count;			   /* used for statistics */
+	int cmd_ctrl;			   /* always set this to 1 before issuing a command */
+	int termios_initialized;
+	__u8 line_control;	   	   /* holds dtr / rts value */
+	__u8 current_status;	   	   /* received from last read - info on dsr,cts,cd,ri,etc */
+	__u8 current_config;	   	   /* stores the current configuration byte */
+	__u8 rx_flags;			   /* throttling - used from whiteheat/ftdi_sio */
+	int baud_rate;			   /* stores current baud rate in integer form */
+	int cbr_mask;			   /* stores current baud rate in masked form */
+	int isthrottled;		   /* if throttled, discard reads */
+	wait_queue_head_t delta_msr_wait;  /* used for TIOCMIWAIT */
+	char prev_status, diff_status;	   /* used for TIOCMIWAIT */
+	/* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */
+	struct termios tmp_termios; 	   /* stores the old termios settings */
+	int write_interval;		   /* interrupt out write interval, as obtained from interrupt_out_urb */
+	int writepipe;			   /* used for clear halt, if necessary */
+};
+
+/* function prototypes for the Cypress USB to serial device */
+static int  cypress_earthmate_startup	(struct usb_serial *serial);
+static int  cypress_hidcom_startup	(struct usb_serial *serial);
+static void cypress_shutdown		(struct usb_serial *serial);
+static int  cypress_open		(struct usb_serial_port *port, struct file *filp);
+static void cypress_close		(struct usb_serial_port *port, struct file *filp);
+static int  cypress_write		(struct usb_serial_port *port, const unsigned char *buf, int count);
+static int  cypress_write_room		(struct usb_serial_port *port);
+static int  cypress_ioctl		(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
+static void cypress_set_termios		(struct usb_serial_port *port, struct termios * old);
+static int  cypress_tiocmget		(struct usb_serial_port *port, struct file *file);
+static int  cypress_tiocmset		(struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
+static int  cypress_chars_in_buffer	(struct usb_serial_port *port);
+static void cypress_throttle		(struct usb_serial_port *port);
+static void cypress_unthrottle		(struct usb_serial_port *port);
+static void cypress_read_int_callback	(struct urb *urb, struct pt_regs *regs);
+static void cypress_write_int_callback	(struct urb *urb, struct pt_regs *regs);
+static int  mask_to_rate		(unsigned mask);
+static unsigned rate_to_mask		(int rate);
+
+static struct usb_serial_device_type cypress_earthmate_device = {
+	.owner =			THIS_MODULE,
+	.name =				"DeLorme Earthmate USB",
+	.short_name =			"earthmate",
+	.id_table =			id_table_earthmate,
+	.num_interrupt_in = 		1,
+	.num_interrupt_out =		1,
+	.num_bulk_in =			NUM_DONT_CARE,
+	.num_bulk_out =			NUM_DONT_CARE,
+	.num_ports =			1,
+	.attach =			cypress_earthmate_startup,
+	.shutdown =			cypress_shutdown,
+	.open =				cypress_open,
+	.close =			cypress_close,
+	.write =			cypress_write,
+	.write_room =			cypress_write_room,
+	.ioctl =			cypress_ioctl,
+	.set_termios =			cypress_set_termios,
+	.tiocmget =			cypress_tiocmget,
+	.tiocmset =			cypress_tiocmset,
+	.chars_in_buffer =		cypress_chars_in_buffer,
+	.throttle =		 	cypress_throttle,
+	.unthrottle =			cypress_unthrottle,
+	.read_int_callback =		cypress_read_int_callback,
+	.write_int_callback =		cypress_write_int_callback,
+};
+
+static struct usb_serial_device_type cypress_hidcom_device = {
+	.owner =			THIS_MODULE,
+	.name =				"HID->COM RS232 Adapter",
+	.short_name =			"cyphidcom",
+	.id_table =			id_table_cyphidcomrs232,
+	.num_interrupt_in =		1,
+	.num_interrupt_out =		1,
+	.num_bulk_in =			NUM_DONT_CARE,
+	.num_bulk_out =			NUM_DONT_CARE,
+	.num_ports =			1,
+	.attach =			cypress_hidcom_startup,
+	.shutdown =			cypress_shutdown,
+	.open =				cypress_open,
+	.close =			cypress_close,
+	.write =			cypress_write,
+	.write_room =			cypress_write_room,
+	.ioctl =			cypress_ioctl,
+	.set_termios =			cypress_set_termios,
+	.tiocmget =			cypress_tiocmget,
+	.tiocmset =			cypress_tiocmset,
+	.chars_in_buffer =		cypress_chars_in_buffer,
+	.throttle =			cypress_throttle,
+	.unthrottle =			cypress_unthrottle,
+	.read_int_callback =		cypress_read_int_callback,
+	.write_int_callback =		cypress_write_int_callback,
+};
+
+
+/*****************************************************************************
+ * Cypress serial helper functions
+ *****************************************************************************/
+
+
+/* This function can either set or retreive the current serial line settings */
+static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits,
+				   int parity_enable, int parity_type, int reset, int cypress_request_type)
+{
+	int i, n_baud_rate = 0, retval = 0;
+	struct cypress_private *priv;
+	__u8 feature_buffer[5];
+	__u8 config;
+	unsigned long flags;
+
+	dbg("%s", __FUNCTION__);
+	
+	priv = usb_get_serial_port_data(port);
+
+	switch(cypress_request_type) {
+		case CYPRESS_SET_CONFIG:
+
+			/*
+			 * The general purpose firmware for the Cypress M8 allows for a maximum speed
+ 			 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose
+			 * firmware or not), if you need to modify this speed setting for your own
+			 * project please add your own chiptype and modify the code likewise.  The
+			 * Cypress HID->COM device will work successfully up to 115200bps.
+			 */
+			if (baud_mask != priv->cbr_mask) {
+				dbg("%s - baud rate is changing", __FUNCTION__);
+				if ( priv->chiptype == CT_EARTHMATE ) {
+					/* 300 and 600 baud rates are supported under the generic firmware,
+					 * but are not used with NMEA and SiRF protocols */
+					
+					if ( (baud_mask == B300) || (baud_mask == B600) ) {
+						err("%s - failed setting baud rate, unsupported speed (default to 4800)",
+						    __FUNCTION__);
+						n_baud_rate = 4800;
+					} else if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) {
+						err("%s - failed setting baud rate, unsupported speed (default to 4800)",
+						    __FUNCTION__);
+						n_baud_rate = 4800;
+					}
+				} else if (priv->chiptype == CT_CYPHIDCOM) {
+					if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) {
+						err("%s - failed setting baud rate, unsupported speed (default to 4800)",
+						    __FUNCTION__);
+						n_baud_rate = 4800;
+					}
+				} else if (priv->chiptype == CT_GENERIC) {
+					if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) {
+						err("%s - failed setting baud rate, unsupported speed (default to 4800)",
+						    __FUNCTION__);
+						n_baud_rate = 4800;
+					}
+				} else {
+					info("%s - please define your chiptype, using 4800bps default", __FUNCTION__);
+					n_baud_rate = 4800;
+				}
+			} else {  /* baud rate not changing, keep the old */
+				n_baud_rate = priv->baud_rate;
+			}
+			dbg("%s - baud rate is being sent as %d", __FUNCTION__, n_baud_rate);
+
+			
+			/*
+			 * This algorithm accredited to Jiang Jay Zhang... thanks for all the help!
+			 */
+			for (i = 0; i < 4; ++i) {
+				feature_buffer[i] = ( n_baud_rate >> (i*8) & 0xFF );
+			}
+
+			config = 0;	                 // reset config byte
+			config |= data_bits;	         // assign data bits in 2 bit space ( max 3 )
+			/* 1 bit gap */
+			config |= (stop_bits << 3);      // assign stop bits in 1 bit space
+			config |= (parity_enable << 4);  // assign parity flag in 1 bit space
+			config |= (parity_type << 5); 	 // assign parity type in 1 bit space
+			/* 1 bit gap */
+			config |= (reset << 7);		 // assign reset at end of byte, 1 bit space
+
+			feature_buffer[4] = config;
+				
+			dbg("%s - device is being sent this feature report:", __FUNCTION__);
+			dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1],
+		            feature_buffer[2], feature_buffer[3], feature_buffer[4]);
+			
+			retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
+					  	  HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
+					  	  0x0300, 0, feature_buffer, 5, 500);
+
+			if (retval != 5)
+				err("%s - failed sending serial line settings - %d", __FUNCTION__, retval);
+			else {
+				spin_lock_irqsave(&priv->lock, flags);
+				priv->baud_rate = n_baud_rate;
+				priv->cbr_mask = baud_mask;
+				priv->current_config = config;
+				++priv->cmd_count;
+				spin_unlock_irqrestore(&priv->lock, flags);
+			}
+		break;
+		case CYPRESS_GET_CONFIG:
+			dbg("%s - retreiving serial line settings", __FUNCTION__);
+			/* reset values in feature buffer */
+			memset(feature_buffer, 0, 5);
+
+			retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0),
+						  HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
+						  0x0300, 0, feature_buffer, 5, 500);
+			if (retval != 5) {
+				err("%s - failed to retreive serial line settings - %d", __FUNCTION__, retval);
+				return retval;
+			} else {
+				spin_lock_irqsave(&priv->lock, flags);
+				/* store the config in one byte, and later use bit masks to check values */
+				priv->current_config = feature_buffer[4];
+				/* reverse the process above to get the baud_mask value */
+				n_baud_rate = 0; // reset bits
+				for (i = 0; i < 4; ++i) {
+					n_baud_rate |= ( feature_buffer[i] << (i*8) );
+				}
+				
+				priv->baud_rate = n_baud_rate;
+				if ( (priv->cbr_mask = rate_to_mask(n_baud_rate)) == 0x40)
+					dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__);
+				++priv->cmd_count;
+				spin_unlock_irqrestore(&priv->lock, flags);
+			}
+			break;
+		default:
+			err("%s - unsupported serial control command issued", __FUNCTION__);
+	}
+	return retval;
+} /* cypress_serial_control */
+
+
+/* given a baud mask, it will return speed on success */
+static int mask_to_rate (unsigned mask)
+{
+	int rate;
+
+	switch (mask) {
+		case B0: rate = 0; break;
+		case B300: rate = 300; break;
+		case B600: rate = 600; break;
+		case B1200: rate = 1200; break;
+		case B2400: rate = 2400; break;
+		case B4800: rate = 4800; break;
+		case B9600: rate = 9600; break;
+		case B19200: rate = 19200; break;
+		case B38400: rate = 38400; break;
+		case B57600: rate = 57600; break;
+		case B115200: rate = 115200; break;
+		default: rate = -1;
+	}
+
+	return rate;
+}
+
+
+static unsigned rate_to_mask (int rate)
+{
+	unsigned mask;
+
+	switch (rate) {
+		case 0: mask = B0; break;
+		case 300: mask = B300; break;
+		case 600: mask = B600; break;
+		case 1200: mask = B1200; break;
+		case 2400: mask = B2400; break;
+		case 4800: mask = B4800; break;
+		case 9600: mask = B9600; break;
+		case 19200: mask = B19200; break;
+		case 38400: mask = B38400; break;
+		case 57600: mask = B57600; break;
+		case 115200: mask = B115200; break;
+		default: mask = 0x40;
+	}
+
+	return mask;
+}
+/*****************************************************************************
+ * Cypress serial driver functions
+ *****************************************************************************/
+
+
+static int generic_startup (struct usb_serial *serial)
+{
+	struct cypress_private *priv;
+
+	dbg("%s - port %d", __FUNCTION__, serial->port[0]->number);
+
+	priv = kmalloc(sizeof (struct cypress_private), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	memset(priv, 0x00, sizeof (struct cypress_private));
+	spin_lock_init(&priv->lock);
+	init_waitqueue_head(&priv->delta_msr_wait);
+	priv->writepipe = serial->port[0]->interrupt_out_urb->pipe;
+	
+	/* free up interrupt_out buffer / urb allocated by usbserial
+ 	 * for this port as we use our own urbs for writing */
+	if (serial->port[0]->interrupt_out_buffer) {
+		kfree(serial->port[0]->interrupt_out_buffer);
+		serial->port[0]->interrupt_out_buffer = NULL;
+	}
+	if (serial->port[0]->interrupt_out_urb) {
+		priv->write_interval = serial->port[0]->interrupt_out_urb->interval;
+		usb_free_urb(serial->port[0]->interrupt_out_urb);
+		serial->port[0]->interrupt_out_urb = NULL;
+	} else /* still need a write interval */
+		priv->write_interval = 10;
+
+	priv->cmd_ctrl = 0;
+	priv->line_control = 0;
+	priv->termios_initialized = 0;
+	priv->rx_flags = 0;
+	usb_set_serial_port_data(serial->port[0], priv);
+	
+	return (0);	
+}	
+
+
+static int cypress_earthmate_startup (struct usb_serial *serial)
+{
+	struct cypress_private *priv;
+
+	dbg("%s", __FUNCTION__);
+
+	if (generic_startup(serial)) {
+		dbg("%s - Failed setting up port %d", __FUNCTION__, serial->port[0]->number);
+		return 1;
+	}
+
+	priv = usb_get_serial_port_data(serial->port[0]);
+	priv->chiptype = CT_EARTHMATE;
+	
+	return (0);	
+} /* cypress_earthmate_startup */
+
+
+static int cypress_hidcom_startup (struct usb_serial *serial)
+{
+	struct cypress_private *priv;
+
+	dbg("%s", __FUNCTION__);
+
+	if (generic_startup(serial)) {
+		dbg("%s - Failed setting up port %d", __FUNCTION__, serial->port[0]->number);
+		return 1;
+	}
+
+	priv = usb_get_serial_port_data(serial->port[0]);
+	priv->chiptype = CT_CYPHIDCOM;
+	
+	return (0);	
+} /* cypress_hidcom_startup */
+
+
+static void cypress_shutdown (struct usb_serial *serial)
+{
+	struct cypress_private *priv;
+
+	dbg ("%s - port %d", __FUNCTION__, serial->port[0]->number);
+
+	/* all open ports are closed at this point */
+
+	priv = usb_get_serial_port_data(serial->port[0]);
+
+	if (priv) {
+		kfree(priv);
+		usb_set_serial_port_data(serial->port[0], NULL);
+	}
+}
+
+
+static int cypress_open (struct usb_serial_port *port, struct file *filp)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	struct usb_serial *serial = port->serial;
+	unsigned long flags;
+	int result = 0;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	/* reset read/write statistics */
+	priv->bytes_in = 0;
+	priv->bytes_out = 0;
+	priv->cmd_count = 0;
+
+	/* turn on dtr / rts since we are not flow controlling by default */
+	priv->line_control = CONTROL_DTR | CONTROL_RTS; /* sent in status byte */
+	spin_unlock_irqrestore(&priv->lock, flags);
+	priv->cmd_ctrl = 1;
+	result = cypress_write(port, NULL, 0);
+	
+	port->tty->low_latency = 1;
+
+	/* termios defaults are set by usb_serial_init */
+	
+	cypress_set_termios(port, &priv->tmp_termios);
+
+	if (result) {
+		dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __FUNCTION__, result);
+		return result;
+	} else
+		dbg("%s - success setting the control lines", __FUNCTION__);
+
+	/* throttling off */
+	spin_lock_irqsave(&priv->lock, flags);
+	priv->rx_flags = 0;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	/* setup the port and
+	 * start reading from the device */
+	if(!port->interrupt_in_urb){
+		err("%s - interrupt_in_urb is empty!", __FUNCTION__);
+		return(-1);
+	}
+
+	usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
+		usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
+		port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length,
+		cypress_read_int_callback, port, port->interrupt_in_urb->interval);
+	result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
+
+	if (result){
+		dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
+	}
+
+	return result;
+} /* cypress_open */
+
+
+static void cypress_close(struct usb_serial_port *port, struct file * filp)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	unsigned int c_cflag;
+	unsigned long flags;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	if (port->tty) {
+		c_cflag = port->tty->termios->c_cflag;
+		if (c_cflag & HUPCL) {
+			/* drop dtr and rts */
+			priv = usb_get_serial_port_data(port);
+			spin_lock_irqsave(&priv->lock, flags);
+			priv->line_control = 0;
+			priv->cmd_ctrl = 1;
+			spin_unlock_irqrestore(&priv->lock, flags);
+			cypress_write(port, NULL, 0);
+		}
+	}
+
+	if (port->interrupt_in_urb) {
+		dbg("%s - stopping read urb", __FUNCTION__);
+		usb_kill_urb (port->interrupt_in_urb);
+	}
+
+	if (stats)
+		dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
+		          priv->bytes_in, priv->bytes_out, priv->cmd_count);
+} /* cypress_close */
+
+
+static int cypress_write(struct usb_serial_port *port, const unsigned char *buf, int count)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
+	struct urb *urb;
+	int status, s_pos = 0;
+	__u8 transfer_size = 0;
+	__u8 *buffer;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	if (count == 0 && !priv->cmd_ctrl) {
+		spin_unlock_irqrestore(&priv->lock, flags);
+		dbg("%s - write request of 0 bytes", __FUNCTION__);
+		return 0;
+	}
+
+	if (priv->cmd_ctrl)
+		++priv->cmd_count;
+	priv->cmd_ctrl = 0;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	dbg("%s - interrupt out size is %d", __FUNCTION__, port->interrupt_out_size);
+	dbg("%s - count is %d", __FUNCTION__, count);
+
+	/* Allocate buffer and urb */
+	buffer = kmalloc (port->interrupt_out_size, GFP_ATOMIC);
+	if (!buffer) {
+		dev_err(&port->dev, "ran out of memory for buffer\n");
+		return -ENOMEM;
+	}
+
+	urb = usb_alloc_urb (0, GFP_ATOMIC);
+	if (!urb) {
+		dev_err(&port->dev, "failed allocating write urb\n");
+		kfree (buffer);
+		return -ENOMEM;
+	}
+
+	memset(buffer, 0, port->interrupt_out_size); // test if this is needed... probably not since loop removed
+
+	spin_lock_irqsave(&priv->lock, flags);
+	switch (port->interrupt_out_size) {
+		case 32:
+			// this is for the CY7C64013...
+			transfer_size = min (count, 30);
+			buffer[0] = priv->line_control;
+			buffer[1] = transfer_size;
+			s_pos = 2;
+			break;
+		case 8:
+			// this is for the CY7C63743...
+			transfer_size = min (count, 7);
+			buffer[0] = priv->line_control | transfer_size;
+			s_pos = 1;
+			break;
+		default:
+			dbg("%s - wrong packet size", __FUNCTION__);
+			spin_unlock_irqrestore(&priv->lock, flags);
+			kfree (buffer);
+			usb_free_urb (urb);
+			return -1;
+	}
+
+	if (priv->line_control & CONTROL_RESET)
+		priv->line_control &= ~CONTROL_RESET;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	/* copy data to offset position in urb transfer buffer */
+	memcpy (&buffer[s_pos], buf, transfer_size);
+
+	usb_serial_debug_data (debug, &port->dev, __FUNCTION__, port->interrupt_out_size, buffer);
+
+	/* build up the urb */
+	usb_fill_int_urb (urb, port->serial->dev,
+			  usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress),
+			  buffer, port->interrupt_out_size,
+			  cypress_write_int_callback, port, priv->write_interval);
+
+	status = usb_submit_urb(urb, GFP_ATOMIC);
+
+	if (status) {
+		dev_err(&port->dev, "%s - usb_submit_urb (write interrupt) failed with status %d\n",
+			__FUNCTION__, status);
+		transfer_size = status;
+		kfree (buffer);
+		goto exit;
+	}
+
+	spin_lock_irqsave(&priv->lock, flags);
+	priv->bytes_out += transfer_size;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+exit:
+	/* buffer free'd in callback */
+	usb_free_urb (urb);
+
+	return transfer_size;
+
+} /* cypress_write */
+
+
+static int cypress_write_room(struct usb_serial_port *port)
+{
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	/*
+	 * We really can take anything the user throw at us
+	 * but let's pick a nice big number to tell the tty
+	 * layer that we have lots of free space
+	 */	
+
+	return 2048;
+}
+
+
+static int cypress_tiocmget (struct usb_serial_port *port, struct file *file)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	__u8 status, control;
+	unsigned int result = 0;
+	unsigned long flags;
+	
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	control = priv->line_control;
+	status = priv->current_status;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	result = ((control & CONTROL_DTR)        ? TIOCM_DTR : 0)
+		| ((control & CONTROL_RTS)       ? TIOCM_RTS : 0)
+		| ((status & UART_CTS)        ? TIOCM_CTS : 0)
+		| ((status & UART_DSR)        ? TIOCM_DSR : 0)
+		| ((status & UART_RI)         ? TIOCM_RI  : 0)
+		| ((status & UART_CD)         ? TIOCM_CD  : 0);
+
+	dbg("%s - result = %x", __FUNCTION__, result);
+
+	return result;
+}
+
+
+static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
+			       unsigned int set, unsigned int clear)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
+	
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	if (set & TIOCM_RTS)
+		priv->line_control |= CONTROL_RTS;
+	if (set & TIOCM_DTR)
+		priv->line_control |= CONTROL_DTR;
+	if (clear & TIOCM_RTS)
+		priv->line_control &= ~CONTROL_RTS;
+	if (clear & TIOCM_DTR)
+		priv->line_control &= ~CONTROL_DTR;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	priv->cmd_ctrl = 1;
+	return cypress_write(port, NULL, 0);
+}
+
+
+static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+
+	dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
+
+	switch (cmd) {
+		case TIOCGSERIAL:
+			if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct termios))) {
+				return -EFAULT;
+			}
+			return (0);
+			break;
+		case TIOCSSERIAL:
+			if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct termios))) {
+				return -EFAULT;
+			}
+			/* here we need to call cypress_set_termios to invoke the new settings */
+			cypress_set_termios(port, &priv->tmp_termios);
+			return (0);
+			break;
+		/* these are called when setting baud rate from gpsd */
+		case TCGETS:
+			if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct termios))) {
+				return -EFAULT;
+			}
+			return (0);
+			break;
+		case TCSETS:
+			if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct termios))) {
+				return -EFAULT;
+			}
+			/* here we need to call cypress_set_termios to invoke the new settings */
+			cypress_set_termios(port, &priv->tmp_termios);
+			return (0);
+			break;
+		/* This code comes from drivers/char/serial.c and ftdi_sio.c */
+		case TIOCMIWAIT:
+			while (priv != NULL) {
+				interruptible_sleep_on(&priv->delta_msr_wait);
+				/* see if a signal did it */
+				if (signal_pending(current))
+					return -ERESTARTSYS;
+				else {
+					char diff = priv->diff_status;
+
+					if (diff == 0) {
+						return -EIO; /* no change => error */
+					}
+					
+					/* consume all events */
+					priv->diff_status = 0;
+
+					/* return 0 if caller wanted to know about these bits */
+					if ( ((arg & TIOCM_RNG) && (diff & UART_RI)) ||
+					     ((arg & TIOCM_DSR) && (diff & UART_DSR)) ||
+					     ((arg & TIOCM_CD) && (diff & UART_CD)) ||
+					     ((arg & TIOCM_CTS) && (diff & UART_CTS)) ) {
+						return 0;
+					}
+					/* otherwise caller can't care less about what happened,
+					 * and so we continue to wait for more events.
+					 */
+				}
+			}
+			return 0;
+			break;
+		default:
+			break;
+	}
+
+	dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __FUNCTION__, cmd);
+
+	return -ENOIOCTLCMD;
+} /* cypress_ioctl */
+
+
+static void cypress_set_termios (struct usb_serial_port *port, struct termios *old_termios)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	struct tty_struct *tty;
+	int data_bits, stop_bits, parity_type, parity_enable;
+	unsigned cflag, iflag, baud_mask;
+	unsigned long flags;
+	
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	tty = port->tty;
+	if ((!tty) || (!tty->termios)) {
+		dbg("%s - no tty structures", __FUNCTION__);
+		return;
+	}
+
+	spin_lock_irqsave(&priv->lock, flags);
+	if (!priv->termios_initialized) {
+		if (priv->chiptype == CT_EARTHMATE) {
+			*(tty->termios) = tty_std_termios;
+			tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL | CLOCAL;
+		} else if (priv->chiptype == CT_CYPHIDCOM) {
+			*(tty->termios) = tty_std_termios;
+			tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+		}
+		priv->termios_initialized = 1;
+	}
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	cflag = tty->termios->c_cflag;
+	iflag = tty->termios->c_iflag;
+
+	/* check if there are new settings */
+	if (old_termios) {
+		if ((cflag != old_termios->c_cflag) ||
+		    (RELEVANT_IFLAG(iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
+			dbg("%s - attempting to set new termios settings", __FUNCTION__);
+			/* should make a copy of this in case something goes wrong in the function, we can restore it */
+			spin_lock_irqsave(&priv->lock, flags);
+			priv->tmp_termios = *(tty->termios);
+			spin_unlock_irqrestore(&priv->lock, flags); 
+		} else {
+			dbg("%s - nothing to do, exiting", __FUNCTION__);
+			return;
+		}
+	} else
+		return;
+
+	/* set number of data bits, parity, stop bits */
+	/* when parity is disabled the parity type bit is ignored */
+
+	stop_bits = cflag & CSTOPB ? 1 : 0; /* 1 means 2 stop bits, 0 means 1 stop bit */
+	
+	if (cflag & PARENB) {
+		parity_enable = 1;
+		parity_type = cflag & PARODD ? 1 : 0; /* 1 means odd parity, 0 means even parity */
+	} else
+		parity_enable = parity_type = 0;
+
+	if (cflag & CSIZE) {
+		switch (cflag & CSIZE) {
+			case CS5: data_bits = 0; break;
+			case CS6: data_bits = 1; break;
+			case CS7: data_bits = 2; break;
+			case CS8: data_bits = 3; break;
+			default: err("%s - CSIZE was set, but not CS5-CS8", __FUNCTION__); data_bits = 3;
+		}
+	} else
+		data_bits = 3;
+
+	spin_lock_irqsave(&priv->lock, flags);
+	if ((cflag & CBAUD) == B0) {
+		/* drop dtr and rts */
+		dbg("%s - dropping the lines, baud rate 0bps", __FUNCTION__);
+		baud_mask = B0;
+		priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
+	} else {
+		baud_mask = (cflag & CBAUD);
+		switch(baud_mask) {
+			case B300: dbg("%s - setting baud 300bps", __FUNCTION__); break;
+			case B600: dbg("%s - setting baud 600bps", __FUNCTION__); break;
+			case B1200: dbg("%s - setting baud 1200bps", __FUNCTION__); break;
+			case B2400: dbg("%s - setting baud 2400bps", __FUNCTION__); break;
+			case B4800: dbg("%s - setting baud 4800bps", __FUNCTION__); break;
+			case B9600: dbg("%s - setting baud 9600bps", __FUNCTION__); break;
+			case B19200: dbg("%s - setting baud 19200bps", __FUNCTION__); break;
+			case B38400: dbg("%s - setting baud 38400bps", __FUNCTION__); break;
+			case B57600: dbg("%s - setting baud 57600bps", __FUNCTION__); break;
+			case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break;
+			default: dbg("%s - unknown masked baud rate", __FUNCTION__);
+		}
+		priv->line_control |= CONTROL_DTR;
+		
+		/* this is probably not what I think it is... check into it */
+		if (cflag & CRTSCTS)
+			priv->line_control |= CONTROL_RTS;
+		else
+			priv->line_control &= ~CONTROL_RTS;
+	}
+	spin_unlock_irqrestore(&priv->lock, flags);
+	
+	dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, %d data_bits (+5)", __FUNCTION__,
+	    stop_bits, parity_enable, parity_type, data_bits);
+
+	cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable,
+			       parity_type, 0, CYPRESS_SET_CONFIG);
+
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(50*HZ/1000); /* give some time between change and read (50ms) */ 
+
+	/* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure
+         * this should confirm that all is working if it returns what we just set */
+	cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
+
+	/* Here we can define custom tty settings for devices
+         *
+         * the main tty base comes from empeg.c
+         */
+
+	spin_lock_irqsave(&priv->lock, flags);	
+	if ( (priv->chiptype == CT_EARTHMATE) && (priv->baud_rate == 4800) ) {
+
+		dbg("Using custom termios settings for a baud rate of 4800bps.");
+		/* define custom termios settings for NMEA protocol */
+
+		
+		tty->termios->c_iflag /* input modes - */
+			&= ~(IGNBRK		/* disable ignore break */
+			| BRKINT		/* disable break causes interrupt */
+			| PARMRK		/* disable mark parity errors */
+			| ISTRIP		/* disable clear high bit of input characters */
+			| INLCR			/* disable translate NL to CR */
+			| IGNCR			/* disable ignore CR */
+			| ICRNL			/* disable translate CR to NL */
+			| IXON);		/* disable enable XON/XOFF flow control */
+		
+		tty->termios->c_oflag /* output modes */
+			&= ~OPOST;		/* disable postprocess output characters */
+		
+		tty->termios->c_lflag /* line discipline modes */
+			&= ~(ECHO 		/* disable echo input characters */
+			| ECHONL		/* disable echo new line */
+			| ICANON		/* disable erase, kill, werase, and rprnt special characters */
+			| ISIG			/* disable interrupt, quit, and suspend special characters */
+			| IEXTEN);		/* disable non-POSIX special characters */
+
+	} else if (priv->chiptype == CT_CYPHIDCOM) {
+
+		// Software app handling it for device...	
+
+	} else {
+		
+		/* do something here */
+
+	}
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	/* set lines */
+	priv->cmd_ctrl = 1;
+	cypress_write(port, NULL, 0);
+	
+	return;
+} /* cypress_set_termios */
+
+
+static int cypress_chars_in_buffer(struct usb_serial_port *port)
+{
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	/*
+	 * We can't really account for how much data we
+	 * have sent out, but hasn't made it through to the
+	 * device, so just tell the tty layer that everything
+	 * is flushed.
+	 */
+
+	return 0;
+}
+
+
+static void cypress_throttle (struct usb_serial_port *port)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	priv->rx_flags = THROTTLED;
+	spin_unlock_irqrestore(&priv->lock, flags);	   
+}
+
+
+static void cypress_unthrottle (struct usb_serial_port *port)
+{
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	int actually_throttled, result;
+	unsigned long flags;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
+	priv->rx_flags = 0;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	if (actually_throttled) {
+		port->interrupt_in_urb->dev = port->serial->dev;
+
+		result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
+		if (result)
+			dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
+	}
+}
+
+
+static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
+{
+	struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+	struct cypress_private *priv = usb_get_serial_port_data(port);
+	struct tty_struct *tty;
+	unsigned char *data = urb->transfer_buffer;
+	unsigned long flags;
+	char tty_flag = TTY_NORMAL;
+	int bytes=0;
+	int result;
+	int i=0;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	if (urb->status) {
+		dbg("%s - nonzero read status received: %d", __FUNCTION__, urb->status);
+		return;
+	}
+
+	spin_lock_irqsave(&priv->lock, flags);
+	if (priv->rx_flags & THROTTLED) {
+		priv->rx_flags |= ACTUALLY_THROTTLED;
+		spin_unlock_irqrestore(&priv->lock, flags);
+		return;
+	}
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	tty = port->tty;
+	if (!tty) {
+		dbg("%s - bad tty pointer - exiting", __FUNCTION__);
+		return;
+	}
+
+	usb_serial_debug_data (debug, &port->dev, __FUNCTION__, urb->actual_length, data);
+	
+	spin_lock_irqsave(&priv->lock, flags);
+	switch(urb->actual_length) {
+		case 32:
+			// This is for the CY7C64013...
+			priv->current_status = data[0] & 0xF8;
+			bytes = data[1]+2;
+			i=2;
+			break;
+		case 8:
+			// This is for the CY7C63743...
+			priv->current_status = data[0] & 0xF8;
+			bytes = (data[0] & 0x07)+1;
+			i=1;
+			break;
+		default:
+			dbg("%s - wrong packet size - received %d bytes", __FUNCTION__, urb->actual_length);
+			spin_unlock_irqrestore(&priv->lock, flags);
+			goto continue_read;
+	}
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	/* check to see if status has changed */
+	if (priv != NULL) {
+		if (priv->current_status != priv->prev_status) {
+			priv->diff_status |= priv->current_status ^ priv->prev_status;
+			wake_up_interruptible(&priv->delta_msr_wait);
+			priv->prev_status = priv->current_status;
+		}
+	}
+	spin_unlock_irqrestore(&priv->lock, flags);	
+
+	/* hangup, as defined in acm.c... this might be a bad place for it though */
+	if (tty && !(tty->termios->c_cflag & CLOCAL) && !(priv->current_status & UART_CD)) {
+		dbg("%s - calling hangup", __FUNCTION__);
+		tty_hangup(tty);
+		goto continue_read;
+	}
+
+	/* There is one error bit... I'm assuming it is a parity error indicator
+	 * as the generic firmware will set this bit to 1 if a parity error occurs.
+	 * I can not find reference to any other error events.
+	 *
+	 */
+	spin_lock_irqsave(&priv->lock, flags);
+	if (priv->current_status & CYP_ERROR) {
+		spin_unlock_irqrestore(&priv->lock, flags);
+		tty_flag = TTY_PARITY;
+		dbg("%s - Parity Error detected", __FUNCTION__);
+	} else
+		spin_unlock_irqrestore(&priv->lock, flags);
+
+	/* process read if there is data other than line status */
+	if (tty && (bytes > i)) {
+		for (; i < bytes ; ++i) {
+			dbg("pushing byte number %d - %d",i,data[i]);
+			if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
+				tty_flip_buffer_push(tty);
+			}
+			tty_insert_flip_char(tty, data[i], tty_flag);
+		}
+		tty_flip_buffer_push(port->tty);
+	}
+
+	spin_lock_irqsave(&priv->lock, flags);
+	priv->bytes_in += bytes;  /* control and status byte(s) are also counted */
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+continue_read:
+	
+	/* Continue trying to always read... unless the port has closed.  */
+
+	if (port->open_count > 0) {
+	usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
+		usb_rcvintpipe(port->serial->dev, port->interrupt_in_endpointAddress),
+		port->interrupt_in_urb->transfer_buffer,
+		port->interrupt_in_urb->transfer_buffer_length,
+		cypress_read_int_callback, port,
+		port->interrupt_in_urb->interval);
+	result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
+	if (result)
+		dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
+	}
+	
+	return;
+} /* cypress_read_int_callback */
+
+
+static void cypress_write_int_callback(struct urb *urb, struct pt_regs *regs)
+{
+	struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+
+	/* free up the transfer buffer, as usb_free_urb() does not do this */
+	kfree (urb->transfer_buffer);
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+	
+	if (urb->status) {
+		dbg("%s - nonzero write status received: %d", __FUNCTION__, urb->status);
+		return;
+	}
+
+	schedule_work(&port->work);
+}
+
+
+/*****************************************************************************
+ * Module functions
+ *****************************************************************************/
+
+static int __init cypress_init(void)
+{
+	int retval;
+	
+	dbg("%s", __FUNCTION__);
+	
+	retval = usb_serial_register(&cypress_earthmate_device);
+	if (retval)
+		goto failed_em_register;
+	retval = usb_serial_register(&cypress_hidcom_device);
+	if (retval)
+		goto failed_hidcom_register;
+	retval = usb_register(&cypress_driver);
+	if (retval)
+		goto failed_usb_register;
+
+	info(DRIVER_DESC " " DRIVER_VERSION);
+	return 0;
+failed_usb_register:
+	usb_deregister(&cypress_driver);
+failed_hidcom_register:
+	usb_serial_deregister(&cypress_hidcom_device);
+failed_em_register:
+	usb_serial_deregister(&cypress_earthmate_device);
+
+	return retval;
+}
+
+
+static void __exit cypress_exit (void)
+{
+	dbg("%s", __FUNCTION__);
+
+	usb_deregister (&cypress_driver);
+	usb_serial_deregister (&cypress_earthmate_device);
+	usb_serial_deregister (&cypress_hidcom_device);
+}
+
+
+module_init(cypress_init);
+module_exit(cypress_exit);
+
+MODULE_AUTHOR( DRIVER_AUTHOR );
+MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_LICENSE("GPL");
+
+module_param(debug, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+module_param(stats, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(stats, "Enable statistics or not");
diff -Nru a/drivers/usb/serial/cypress_m8.h b/drivers/usb/serial/cypress_m8.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/serial/cypress_m8.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,55 @@
+#ifndef CYPRESS_M8_H
+#define CYPRESS_M8_H
+
+/* definitions and function prototypes used for the cypress USB to Serial controller */
+
+/* For sending our feature buffer - controlling serial communication states */
+/* Linux HID has no support for serial devices so we do this through the driver */
+#define HID_REQ_GET_REPORT 0x01
+#define HID_REQ_SET_REPORT 0x09
+
+/* List other cypress USB to Serial devices here, and add them to the id_table */
+
+/* DeLorme Earthmate USB - a GPS device */
+#define	VENDOR_ID_DELORME		 0x1163
+#define PRODUCT_ID_EARTHMATEUSB		 0x0100
+
+/* Cypress HID->COM RS232 Adapter */
+#define VENDOR_ID_CYPRESS		 0x04b4
+#define PRODUCT_ID_CYPHIDCOM		 0x5500
+/* End of device listing */
+
+/* Used for setting / requesting serial line settings */
+#define CYPRESS_SET_CONFIG 0x01
+#define CYPRESS_GET_CONFIG 0x02
+
+/* Used for throttle control */
+#define THROTTLED 0x1
+#define ACTUALLY_THROTTLED 0x2
+
+/* chiptypes - used in case firmware differs from the generic form ... offering
+ * 	different baud speeds/etc.
+ */
+
+#define CT_EARTHMATE	0x01
+#define CT_CYPHIDCOM	0x02
+#define CT_GENERIC	0x0F
+/* End of chiptype definitions */
+
+/* RS-232 serial data communication protocol definitions */
+/* these are sent / read at byte 0 of the input/output hid reports */
+/* You can find these values defined in the CY4601 USB to Serial design notes */
+
+#define CONTROL_DTR 	0x20	/* data terminal ready - flow control - host to device */
+#define UART_DSR	0x20	/* data set ready - flow control - device to host */
+#define CONTROL_RTS 	0x10	/* request to send - flow control - host to device */
+#define UART_CTS	0x10	/* clear to send - flow control - device to host */
+#define	UART_RI		0x10	/* ring indicator - modem - device to host */ 
+#define UART_CD		0x40	/* carrier detect - modem - device to host */
+#define CYP_ERROR 	0x08	/* received from input report - device to host */
+/* Note - the below has nothing to to with the "feature report" reset */
+#define CONTROL_RESET	0x08  	/* sent with output report - host to device */
+
+/* End of RS-232 protocol definitions */
+
+#endif /* CYPRESS_M8_H */
diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
--- a/drivers/usb/serial/digi_acceleport.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/serial/digi_acceleport.c	2004-12-24 13:36:48 -08:00
@@ -455,8 +455,7 @@
 static int digi_tiocmget( struct usb_serial_port *port, struct file *file );
 static int digi_tiocmset( struct usb_serial_port *port, struct file *file,
 	unsigned int set, unsigned int clear );
-static int digi_write( struct usb_serial_port *port, int from_user,
-	const unsigned char *buf, int count );
+static int digi_write( struct usb_serial_port *port, const unsigned char *buf, int count );
 static void digi_write_bulk_callback( struct urb *urb, struct pt_regs *regs );
 static int digi_write_room( struct usb_serial_port *port );
 static int digi_chars_in_buffer( struct usb_serial_port *port );
@@ -1262,26 +1261,21 @@
 }
 
 
-static int digi_write( struct usb_serial_port *port, int from_user,
-	const unsigned char *buf, int count )
+static int digi_write( struct usb_serial_port *port, const unsigned char *buf, int count )
 {
 
 	int ret,data_len,new_len;
 	struct digi_port *priv = usb_get_serial_port_data(port);
 	unsigned char *data = port->write_urb->transfer_buffer;
-	unsigned char user_buf[64];	/* 64 bytes is max USB bulk packet */
 	unsigned long flags = 0;
 
 
-dbg( "digi_write: TOP: port=%d, count=%d, from_user=%d, in_interrupt=%ld",
-priv->dp_port_num, count, from_user, in_interrupt() );
+dbg( "digi_write: TOP: port=%d, count=%d, in_interrupt=%ld",
+priv->dp_port_num, count, in_interrupt() );
 
 	/* copy user data (which can sleep) before getting spin lock */
 	count = min( count, port->bulk_out_size-2 );
 	count = min( 64, count);
-	if( from_user && copy_from_user( user_buf, buf, count ) ) {
-		return( -EFAULT );
-	}
 
 	/* be sure only one write proceeds at a time */
 	/* there are races on the port private buffer */
@@ -1294,8 +1288,7 @@
 
 		/* buffer data if count is 1 (probably put_char) if possible */
 		if( count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE ) {
-			priv->dp_out_buf[priv->dp_out_buf_len++]
-				= *(from_user ? user_buf : buf);
+			priv->dp_out_buf[priv->dp_out_buf_len++] = *buf;
 			new_len = 1;
 		} else {
 			new_len = 0;
@@ -1328,7 +1321,7 @@
 	data += priv->dp_out_buf_len;
 
 	/* copy in new data */
-	memcpy( data, from_user ? user_buf : buf, new_len );
+	memcpy( data, buf, new_len );
 
 	if( (ret=usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0 ) {
 		priv->dp_write_urb_in_use = 1;
@@ -1615,7 +1608,7 @@
 			DIGI_CLOSE_TIMEOUT );
 
 		/* shutdown any outstanding bulk writes */
-		usb_unlink_urb (port->write_urb);
+		usb_kill_urb(port->write_urb);
 	}
 
 	tty->closing = 0;
@@ -1754,8 +1747,8 @@
 
 	/* stop reads and writes on all ports */
 	for( i=0; i<serial->type->num_ports+1; i++ ) {
-		usb_unlink_urb( serial->port[i]->read_urb );
-		usb_unlink_urb( serial->port[i]->write_urb );
+		usb_kill_urb(serial->port[i]->read_urb);
+		usb_kill_urb(serial->port[i]->write_urb);
 	}
 
 	/* free the private data structures for all ports */
diff -Nru a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
--- a/drivers/usb/serial/empeg.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/serial/empeg.c	2004-12-24 13:37:29 -08:00
@@ -81,7 +81,6 @@
 static int  empeg_open			(struct usb_serial_port *port, struct file *filp);
 static void empeg_close			(struct usb_serial_port *port, struct file *filp);
 static int  empeg_write			(struct usb_serial_port *port,
-					int from_user,
 					const unsigned char *buf,
 					int count);
 static int  empeg_write_room		(struct usb_serial_port *port);
@@ -185,13 +184,13 @@
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
 	/* shutdown our bulk read */
-	usb_unlink_urb (port->read_urb);
+	usb_kill_urb(port->read_urb);
 	/* Uncomment the following line if you want to see some statistics in your syslog */
 	/* dev_info (&port->dev, "Bytes In = %d  Bytes Out = %d\n", bytes_in, bytes_out); */
 }
 
 
-static int empeg_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, int count)
 {
 	struct usb_serial *serial = port->serial;
 	struct urb *urb;
@@ -235,14 +234,7 @@
 
 		transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE);
 
-		if (from_user) {
-			if (copy_from_user (urb->transfer_buffer, current_position, transfer_size)) {
-				bytes_sent = -EFAULT;
-				break;
-			}
-		} else {
-			memcpy (urb->transfer_buffer, current_position, transfer_size);
-		}
+		memcpy (urb->transfer_buffer, current_position, transfer_size);
 
 		usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, urb->transfer_buffer);
 
@@ -406,7 +398,7 @@
 static void empeg_throttle (struct usb_serial_port *port)
 {
 	dbg("%s - port %d", __FUNCTION__, port->number);
-	usb_unlink_urb (port->read_urb);
+	usb_kill_urb(port->read_urb);
 }
 
 
@@ -579,10 +571,10 @@
 
 	for (i = 0; i < NUM_URBS; ++i) {
 		if (write_urb_pool[i]) {
-			/* FIXME - uncomment the following usb_unlink_urb call when
+			/* FIXME - uncomment the following usb_kill_urb call when
 			 * the host controllers get fixed to set urb->dev = NULL after
 			 * the urb is finished.  Otherwise this call oopses. */
-			/* usb_unlink_urb(write_urb_pool[i]); */
+			/* usb_kill_urb(write_urb_pool[i]); */
 			if (write_urb_pool[i]->transfer_buffer)
 				kfree(write_urb_pool[i]->transfer_buffer);
 			usb_free_urb (write_urb_pool[i]);
diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
--- a/drivers/usb/serial/ftdi_sio.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/serial/ftdi_sio.c	2004-12-24 13:37:18 -08:00
@@ -368,6 +368,10 @@
 	{ USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) },
 	{ USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) },
 	{ USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) },
+	{ USB_DEVICE_VER(FTDI_RM_VID, FTDI_RMCANVIEW_PID, 0, 0x3ff) },
+	{ USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) },
+	{ USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) },
+	{ USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) },
 	{ }						/* Terminating entry */
 };
 
@@ -478,6 +482,10 @@
 	{ USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) },
 	{ USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) },
 	{ USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) },
+	{ USB_DEVICE_VER(FTDI_RM_VID, FTDI_RMCANVIEW_PID, 0x400, 0xffff) },
+	{ USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) },
+	{ USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) },
+	{ USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) },
 	{ }						/* Terminating entry */
 };
 
@@ -528,6 +536,7 @@
 	{ USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_5_PID, 0x400, 0xffff) },
 	{ USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_6_PID, 0x400, 0xffff) },
 	{ USB_DEVICE_VER(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID, 0x400, 0xffff) },
+	{ USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) },
 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) },
 	{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2103_PID) },
@@ -595,6 +604,10 @@
 	{ USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
 	{ USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) },
+	{ USB_DEVICE(FTDI_RM_VID, FTDI_RMCANVIEW_PID) },
+	{ USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
+	{ USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
+	{ USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
 	{ }						/* Terminating entry */
 };
 
@@ -657,7 +670,7 @@
 static void ftdi_shutdown		(struct usb_serial *serial);
 static int  ftdi_open			(struct usb_serial_port *port, struct file *filp);
 static void ftdi_close			(struct usb_serial_port *port, struct file *filp);
-static int  ftdi_write			(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+static int  ftdi_write			(struct usb_serial_port *port, const unsigned char *buf, int count);
 static int  ftdi_write_room		(struct usb_serial_port *port);
 static int  ftdi_chars_in_buffer	(struct usb_serial_port *port);
 static void ftdi_write_bulk_callback	(struct urb *urb, struct pt_regs *regs);
@@ -1479,16 +1492,8 @@
 	} /* Note change no line if hupcl is off */
 	
 	/* shutdown our bulk read */
-	if (port->read_urb) {
-		if (usb_unlink_urb (port->read_urb) < 0) {
-			/* Generally, this isn't an error.  If the previous
-			   read bulk callback occurred (or is about to occur)
-			   while the port was being closed or was throtted
-			   (and is still throttled), the read urb will not
-			   have been submitted. */
-			dbg("%s - failed to unlink read urb (generally not an error)", __FUNCTION__);
-		}
-	}
+	if (port->read_urb)
+		usb_kill_urb(port->read_urb);
 } /* ftdi_close */
 
 
@@ -1500,7 +1505,7 @@
  *
  * The new devices do not require this byte
  */
-static int ftdi_write (struct usb_serial_port *port, int from_user,
+static int ftdi_write (struct usb_serial_port *port,
 			   const unsigned char *buf, int count)
 { /* ftdi_write */
 	struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1557,17 +1562,8 @@
 			/* Write the control byte at the front of the packet*/
 			*first_byte = 1 | ((user_pktsz) << 2); 
 			/* Copy data for packet */
-			if (from_user) {
-				if (copy_from_user (first_byte + data_offset,
-						    current_position, user_pktsz)){
-					kfree (buffer);
-					usb_free_urb (urb);
-					return -EFAULT;
-				}
-			} else {
-				memcpy (first_byte + data_offset,
-					current_position, user_pktsz);
-			}
+			memcpy (first_byte + data_offset,
+				current_position, user_pktsz);
 			first_byte += user_pktsz + data_offset;
 			current_position += user_pktsz;
 			todo -= user_pktsz;
@@ -1575,15 +1571,7 @@
 	} else {
 		/* No control byte required. */
 		/* Copy in the data to send */
-		if (from_user) {
-			if (copy_from_user (buffer, buf, count)) {
-				kfree (buffer);
-				usb_free_urb (urb);
-				return -EFAULT;
-			}
-		} else {
-			memcpy (buffer, buf, count);
-		}
+		memcpy (buffer, buf, count);
 	}
 
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer);
diff -Nru a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
--- a/drivers/usb/serial/ftdi_sio.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/serial/ftdi_sio.h	2004-12-24 13:37:18 -08:00
@@ -225,6 +225,21 @@
  */
 #define FTDI_SUUNTO_SPORTS_PID	0xF680	/* Suunto Sports instrument */
 
+/*
+ * Definitions for B&B Electronics products.
+ */
+#define BANDB_VID		0x0856	/* B&B Electronics Vendor ID */
+#define BANDB_USOTL4_PID	0xAC01	/* USOTL4 Isolated RS-485 Converter */
+#define BANDB_USTL4_PID		0xAC02	/* USTL4 RS-485 Converter */
+#define BANDB_USO9ML2_PID	0xAC03	/* USO9ML2 Isolated RS-232 Converter */
+
+/*
+ * RM Michaelides CANview USB (http://www.rmcan.com)
+ * CAN filedbus interface adapter, addad by port GmbH www.port.de)
+ */
+#define FTDI_RM_VID		0x0403	/* Vendor  Id */
+#define FTDI_RMCANVIEW_PID	0xfd60	/* Product Id */
+
 /* Commands */
 #define FTDI_SIO_RESET 		0 /* Reset the port */
 #define FTDI_SIO_MODEM_CTRL 	1 /* Set the modem control register */
diff -Nru a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
--- a/drivers/usb/serial/generic.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/serial/generic.c	2004-12-24 13:36:18 -08:00
@@ -147,9 +147,9 @@
 	if (serial->dev) {
 		/* shutdown any bulk reads that might be going on */
 		if (serial->num_bulk_out)
-			usb_unlink_urb (port->write_urb);
+			usb_kill_urb(port->write_urb);
 		if (serial->num_bulk_in)
-			usb_unlink_urb (port->read_urb);
+			usb_kill_urb(port->read_urb);
 	}
 }
 
@@ -159,7 +159,7 @@
 	generic_cleanup (port);
 }
 
-int usb_serial_generic_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *buf, int count)
 {
 	struct usb_serial *serial = port->serial;
 	int result;
@@ -181,13 +181,7 @@
 
 		count = (count > port->bulk_out_size) ? port->bulk_out_size : count;
 
-		if (from_user) {
-			if (copy_from_user(port->write_urb->transfer_buffer, buf, count))
-				return -EFAULT;
-		}
-		else {
-			memcpy (port->write_urb->transfer_buffer, buf, count);
-		}
+		memcpy (port->write_urb->transfer_buffer, buf, count);
 		data = port->write_urb->transfer_buffer;
 		usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, data);
 
diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
--- a/drivers/usb/serial/io_edgeport.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/serial/io_edgeport.c	2004-12-24 13:36:17 -08:00
@@ -23,6 +23,10 @@
  *	Edgeport/4D8
  *	Edgeport/8i
  *
+ * For questions or problems with this driver, contact Inside Out
+ * Networks technical support, or Peter Berger <pberger@brimson.com>,
+ * or Al Borchers <alborchers@steinerpoint.com>.
+ *
  * Version history:
  * 
  * 2003_04_03 al borchers
@@ -267,7 +271,7 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v2.3"
+#define DRIVER_VERSION "v2.7"
 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli"
 #define DRIVER_DESC "Edgeport USB Serial Driver"
 
@@ -297,8 +301,6 @@
 #define OPEN_TIMEOUT		(5*HZ)		/* 5 seconds */
 #define COMMAND_TIMEOUT		(5*HZ)		/* 5 seconds */
 
-static int debug;
-
 /* receive port state */
 enum RXSTATE {
 	EXPECT_HDR1 = 0,	/* Expect header byte 1 */
@@ -329,6 +331,7 @@
 	struct TxFifo		txfifo;			/* transmit fifo -- size will be maxTxCredits */
 	struct urb		*write_urb;		/* write URB for this port */
 	char			write_in_progress;	/* TRUE while a write URB is outstanding */
+	spinlock_t		ep_lock;
 
 	__u8			shadowLCR;		/* last LCR value received */
 	__u8			shadowMCR;		/* last MCR value received */
@@ -370,6 +373,8 @@
 	__u8			bulk_in_endpoint;		/* the bulk in endpoint handle */
 	unsigned char *		bulk_in_buffer;			/* the buffer we use for the bulk in endpoint */
 	struct urb *		read_urb;			/* our bulk read urb */
+	int			read_in_progress;
+	spinlock_t		es_lock;
 
 	__u8			bulk_out_endpoint;		/* the bulk out endpoint handle */
 
@@ -420,7 +425,11 @@
 };
 
 /* local variables */
-static int	CmdUrbs = 0;							/* Number of outstanding Command Write Urbs */
+static int debug;
+
+static int low_latency = 1;	/* tty low latency flag, on by default */
+
+static int CmdUrbs = 0;		/* Number of outstanding Command Write Urbs */
 
 
 /* local function prototypes */
@@ -434,7 +443,7 @@
 /* function prototypes for the usbserial callbacks */
 static int  edge_open			(struct usb_serial_port *port, struct file *filp);
 static void edge_close			(struct usb_serial_port *port, struct file *filp);
-static int  edge_write			(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+static int  edge_write			(struct usb_serial_port *port, const unsigned char *buf, int count);
 static int  edge_write_room		(struct usb_serial_port *port);
 static int  edge_chars_in_buffer	(struct usb_serial_port *port);
 static void edge_throttle		(struct usb_serial_port *port);
@@ -459,8 +468,9 @@
 };
 
 /* function prototypes for all of our local functions */
-static int  process_rcvd_data		(struct edgeport_serial *edge_serial, unsigned char *buffer, __u16 bufferLength);
+static void  process_rcvd_data		(struct edgeport_serial *edge_serial, unsigned char *buffer, __u16 bufferLength);
 static void process_rcvd_status		(struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3);
+static void edge_tty_recv			(struct device *dev, struct tty_struct *tty, unsigned char *data, int length);
 static void handle_new_msr		(struct edgeport_port *edge_port, __u8 newMsr);
 static void handle_new_lsr		(struct edgeport_port *edge_port, __u8 lsrData, __u8 lsr, __u8 data);
 static int  send_iosp_ext_cmd		(struct edgeport_port *edge_port, __u8 command, __u8 param);
@@ -478,13 +488,9 @@
 static void get_boot_desc		(struct edgeport_serial *edge_serial);
 static void load_application_firmware	(struct edgeport_serial *edge_serial);
 
-
 static void unicode_to_ascii		(char *string, __le16 *unicode, int unicode_size);
 
 
-
-
-
 // ************************************************************************
 // ************************************************************************
 // ************************************************************************
@@ -784,20 +790,24 @@
 		if (length > 1) {
 			bytes_avail = data[0] | (data[1] << 8);
 			if (bytes_avail) {
+				spin_lock(&edge_serial->es_lock);
 				edge_serial->rxBytesAvail += bytes_avail;
-				dbg("%s - bytes_avail = %d, rxBytesAvail %d", __FUNCTION__, bytes_avail, edge_serial->rxBytesAvail);
+				dbg("%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d", __FUNCTION__, bytes_avail, edge_serial->rxBytesAvail, edge_serial->read_in_progress);
 
-				if ((edge_serial->rxBytesAvail > 0) &&
-				    (edge_serial->read_urb->status != -EINPROGRESS)) {
-					dbg(" --- Posting a read");
+				if (edge_serial->rxBytesAvail > 0 &&
+				    !edge_serial->read_in_progress) {
+					dbg("%s - posting a read", __FUNCTION__);
+					edge_serial->read_in_progress = TRUE;
 
 					/* we have pending bytes on the bulk in pipe, send a request */
 					edge_serial->read_urb->dev = edge_serial->serial->dev;
 					result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
 					if (result) {
-						dbg("%s - usb_submit_urb(read bulk) failed with result = %d", __FUNCTION__, result);
+						dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __FUNCTION__, result);
+						edge_serial->read_in_progress = FALSE;
 					}
 				}
+				spin_unlock(&edge_serial->es_lock);
 			}
 		}
 		/* grab the txcredits for the ports if available */
@@ -809,12 +819,14 @@
 				port = edge_serial->serial->port[portNumber];
 				edge_port = usb_get_serial_port_data(port);
 				if (edge_port->open) {
+					spin_lock(&edge_port->ep_lock);
 					edge_port->txCredits += txCredits;
+					spin_unlock(&edge_port->ep_lock);
 					dbg("%s - txcredits for port%d = %d", __FUNCTION__, portNumber, edge_port->txCredits);
 
 					/* tell the tty driver that something has changed */
 					if (edge_port->port->tty)
-						wake_up_interruptible(&edge_port->port->tty->write_wait);
+						tty_wakeup(edge_port->port->tty);
 
 					// Since we have more credit, check if more data can be sent
 					send_more_port_data(edge_serial, edge_port);
@@ -849,34 +861,43 @@
 
 	if (urb->status) {
 		dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
+		edge_serial->read_in_progress = FALSE;
 		return;
 	}
 
-	if (urb->actual_length) {
-		raw_data_length = urb->actual_length;
+	if (urb->actual_length == 0) {
+		dbg("%s - read bulk callback with no data", __FUNCTION__);
+		edge_serial->read_in_progress = FALSE;
+		return;
+	}
 
-		usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __FUNCTION__, raw_data_length, data);
+	raw_data_length = urb->actual_length;
 
-		/* decrement our rxBytes available by the number that we just got */
-		edge_serial->rxBytesAvail -= raw_data_length;
+	usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __FUNCTION__, raw_data_length, data);
 
-		dbg("%s - Received = %d, rxBytesAvail %d", __FUNCTION__, raw_data_length, edge_serial->rxBytesAvail);
+	spin_lock(&edge_serial->es_lock);
 
-		process_rcvd_data (edge_serial, data, urb->actual_length);
+	/* decrement our rxBytes available by the number that we just got */
+	edge_serial->rxBytesAvail -= raw_data_length;
 
-		/* check to see if there's any more data for us to read */
-		if ((edge_serial->rxBytesAvail > 0) &&
-		    (edge_serial->read_urb->status != -EINPROGRESS)) {
-			dbg(" --- Posting a read");
+	dbg("%s - Received = %d, rxBytesAvail %d", __FUNCTION__, raw_data_length, edge_serial->rxBytesAvail);
 
-			/* there is, so resubmit our urb */
-			edge_serial->read_urb->dev = edge_serial->serial->dev;
-			status = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
-			if (status) {
-				dev_err(&urb->dev->dev, "%s - usb_submit_urb(read bulk) failed, status = %d\n", __FUNCTION__, status);
-			}
+	process_rcvd_data (edge_serial, data, urb->actual_length);
+
+	/* check to see if there's any more data for us to read */
+	if (edge_serial->rxBytesAvail > 0) {
+		dbg("%s - posting a read", __FUNCTION__);
+		edge_serial->read_urb->dev = edge_serial->serial->dev;
+		status = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
+		if (status) {
+			dev_err(&urb->dev->dev, "%s - usb_submit_urb(read bulk) failed, status = %d\n", __FUNCTION__, status);
+			edge_serial->read_in_progress = FALSE;
 		}
+	} else {
+		edge_serial->read_in_progress = FALSE;
 	}
+
+	spin_unlock(&edge_serial->es_lock);
 }
 
 
@@ -946,7 +967,7 @@
 
 	/* tell the tty driver that something has changed */
 	if (tty && edge_port->open)
-		wake_up_interruptible(&tty->write_wait);
+		tty_wakeup(tty);
 
 	/* we have completed the command */
 	edge_port->commandPending = FALSE;
@@ -977,11 +998,8 @@
 	if (edge_port == NULL)
 		return -ENODEV;
 
-	/* force low_latency on so that our tty_push actually forces the data through, 
-	   otherwise it is scheduled, and with high data rates (like with OHCI) data
-	   can get lost. */
 	if (port->tty)
-		port->tty->low_latency = 1;
+		port->tty->low_latency = low_latency;
 
 	/* see if we've set up our endpoint info yet (can't set it up in edge_startup
 	   as the structures were not set up at that time.) */
@@ -1019,6 +1037,7 @@
 				  port0->bulk_in_buffer,
 				  edge_serial->read_urb->transfer_buffer_length,
 				  edge_bulk_in_callback, edge_serial);
+		edge_serial->read_in_progress = FALSE;
 
 		/* start interrupt read for this edgeport
 		 * this interrupt will continue as long as the edgeport is connected */
@@ -1081,6 +1100,7 @@
 
 	/* Allocate a URB for the write */
 	edge_port->write_urb = usb_alloc_urb (0, GFP_KERNEL);
+	edge_port->write_in_progress = FALSE;
 
 	if (!edge_port->write_urb) {
 		dbg("%s - no memory", __FUNCTION__);
@@ -1238,7 +1258,7 @@
 	edge_port->openPending = FALSE;
 
 	if (edge_port->write_urb) {
-		usb_unlink_urb (edge_port->write_urb);
+		usb_kill_urb(edge_port->write_urb);
 	}
 
 	if (edge_port->write_urb) {
@@ -1247,9 +1267,11 @@
 			kfree(edge_port->write_urb->transfer_buffer);
 		}
 		usb_free_urb   (edge_port->write_urb);
+		edge_port->write_urb = NULL;
 	}
 	if (edge_port->txfifo.fifo) {
 		kfree(edge_port->txfifo.fifo);
+		edge_port->txfifo.fifo = NULL;
 	}
 
 	dbg("%s exited", __FUNCTION__);
@@ -1262,14 +1284,15 @@
  *	If successful, we return the number of bytes written, otherwise we return
  *	a negative error number.
  *****************************************************************************/
-static int edge_write (struct usb_serial_port *port, int from_user, const unsigned char *data, int count)
+static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	struct TxFifo *fifo;
 	int copySize;
 	int bytesleft;
 	int firsthalf;
 	int secondhalf;
+	unsigned long flags;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
@@ -1279,6 +1302,8 @@
 	// get a pointer to the Tx fifo
 	fifo = &edge_port->txfifo;
 
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
+
 	// calculate number of bytes to put in fifo
 	copySize = min ((unsigned int)count, (edge_port->txCredits - fifo->count));
 
@@ -1288,7 +1313,7 @@
 	/* catch writes of 0 bytes which the tty driver likes to give us, and when txCredits is empty */
 	if (copySize == 0) {
 		dbg("%s - copySize = Zero", __FUNCTION__);
-		return 0;
+		goto finish_write;
 	}
 
 	// queue the data	
@@ -1302,12 +1327,7 @@
 	dbg("%s - copy %d bytes of %d into fifo ", __FUNCTION__, firsthalf, bytesleft);
 
 	/* now copy our data */
-	if (from_user) {
-		if (copy_from_user(&fifo->fifo[fifo->head], data, firsthalf))
-			return -EFAULT;
-	} else {
-		memcpy(&fifo->fifo[fifo->head], data, firsthalf);
-	}  
+	memcpy(&fifo->fifo[fifo->head], data, firsthalf);
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, firsthalf, &fifo->fifo[fifo->head]);
 
 	// update the index and size
@@ -1323,12 +1343,7 @@
 
 	if (secondhalf) {
 		dbg("%s - copy rest of data %d", __FUNCTION__, secondhalf);
-		if (from_user) {
-			if (copy_from_user(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf))
-				return -EFAULT;
-		} else {
-			memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf);
-		}
+		memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf);
 		usb_serial_debug_data(debug, &port->dev, __FUNCTION__, secondhalf, &fifo->fifo[fifo->head]);
 		// update the index and size
 		fifo->count += secondhalf;
@@ -1336,6 +1351,9 @@
 		// No need to check for wrap since we can not get to end of fifo in this part
 	}
 
+finish_write:
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
+
 	send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port);
 
 	dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __FUNCTION__, copySize, edge_port->txCredits, fifo->count);
@@ -1367,14 +1385,17 @@
 	int		bytesleft;
 	int		firsthalf;
 	int		secondhalf;
+	unsigned long	flags;
 
 	dbg("%s(%d)", __FUNCTION__, edge_port->port->number);
 
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
+
 	if (edge_port->write_in_progress ||
 	    !edge_port->open             ||
 	    (fifo->count == 0)) {
 		dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", __FUNCTION__, edge_port->port->number, fifo->count, edge_port->write_in_progress);
-		return;
+		goto exit_send;
 	}
 
 	// since the amount of data in the fifo will always fit into the
@@ -1386,7 +1407,7 @@
 	//	write.
 	if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE)) {
 		dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", __FUNCTION__, edge_port->port->number, fifo->count, edge_port->txCredits );
-		return;
+		goto exit_send;
 	}
 
 	// lock this write
@@ -1407,7 +1428,7 @@
 	if (buffer == NULL) {
 		dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __FUNCTION__);
 		edge_port->write_in_progress = FALSE;
-		return;
+		goto exit_send;
 	}
 	buffer[0] = IOSP_BUILD_DATA_HDR1 (edge_port->port->number - edge_port->port->serial->minor, count);
 	buffer[1] = IOSP_BUILD_DATA_HDR2 (edge_port->port->number - edge_port->port->serial->minor, count);
@@ -1445,7 +1466,7 @@
 	status = usb_submit_urb(urb, GFP_ATOMIC);
 	if (status) {
 		/* something went wrong */
-		dbg("%s - usb_submit_urb(write bulk) failed", __FUNCTION__);
+		dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __FUNCTION__, status);
 		edge_port->write_in_progress = FALSE;
 
 		/* revert the credits as something bad happened. */
@@ -1453,6 +1474,9 @@
 		edge_port->icount.tx -= count;
 	}
 	dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", __FUNCTION__, count, edge_port->txCredits, fifo->count);
+
+exit_send:
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
 }
 
 
@@ -1466,8 +1490,9 @@
  *****************************************************************************/
 static int edge_write_room (struct usb_serial_port *port)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	int room;
+	unsigned long flags;
 
 	dbg("%s", __FUNCTION__);
 
@@ -1484,7 +1509,9 @@
 	}
 
 	// total of both buffers is still txCredit
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
 	room = edge_port->txCredits - edge_port->txfifo.count;
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
 
 	dbg("%s - returns %d", __FUNCTION__, room);
 	return room;
@@ -1502,8 +1529,9 @@
  *****************************************************************************/
 static int edge_chars_in_buffer (struct usb_serial_port *port)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	int num_chars;
+	unsigned long flags;
 
 	dbg("%s", __FUNCTION__);
 
@@ -1517,7 +1545,9 @@
 		return -EINVAL;
 	}
 
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
 	num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count;
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
 	if (num_chars) {
 		dbg("%s(port %d) - returns %d", __FUNCTION__, port->number, num_chars);
 	}
@@ -1533,7 +1563,7 @@
  *****************************************************************************/
 static void edge_throttle (struct usb_serial_port *port)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	struct tty_struct *tty;
 	int status;
 
@@ -1556,7 +1586,7 @@
 	/* if we are implementing XON/XOFF, send the stop character */
 	if (I_IXOFF(tty)) {
 		unsigned char stop_char = STOP_CHAR(tty);
-		status = edge_write (port, 0, &stop_char, 1);
+		status = edge_write (port, &stop_char, 1);
 		if (status <= 0) {
 			return;
 		}
@@ -1582,7 +1612,7 @@
  *****************************************************************************/
 static void edge_unthrottle (struct usb_serial_port *port)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	struct tty_struct *tty;
 	int status;
 
@@ -1605,7 +1635,7 @@
 	/* if we are implementing XON/XOFF, send the start character */
 	if (I_IXOFF(tty)) {
 		unsigned char start_char = START_CHAR(tty);
-		status = edge_write (port, 0, &start_char, 1);
+		status = edge_write (port, &start_char, 1);
 		if (status <= 0) {
 			return;
 		}
@@ -1630,7 +1660,7 @@
  *****************************************************************************/
 static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	struct tty_struct *tty = port->tty;
 	unsigned int cflag;
 
@@ -1642,20 +1672,18 @@
 	cflag = tty->termios->c_cflag;
 	/* check that they really want us to change something */
 	if (old_termios) {
-		if ((cflag == old_termios->c_cflag) &&
-		    (RELEVANT_IFLAG(tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) {
+		if (cflag == old_termios->c_cflag &&
+		    tty->termios->c_iflag == old_termios->c_iflag) {
 			dbg("%s - nothing to change", __FUNCTION__);
 			return;
 		}
 	}
 
 	dbg("%s - clfag %08x iflag %08x", __FUNCTION__, 
-	    tty->termios->c_cflag,
-	    RELEVANT_IFLAG(tty->termios->c_iflag));
+	    tty->termios->c_cflag, tty->termios->c_iflag);
 	if (old_termios) {
 		dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__,
-		    old_termios->c_cflag,
-		    RELEVANT_IFLAG(old_termios->c_iflag));
+		    old_termios->c_cflag, old_termios->c_iflag);
 	}
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
@@ -1688,12 +1716,15 @@
 static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *value)
 {
 	unsigned int result = 0;
+	unsigned long flags;
 
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
 	if (edge_port->maxTxCredits == edge_port->txCredits &&
 	    edge_port->txfifo.count == 0) {
 		dbg("%s -- Empty", __FUNCTION__);
 		result = TIOCSER_TEMT;
 	}
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
 
 	if (copy_to_user(value, &result, sizeof(int)))
 		return -EFAULT;
@@ -1719,7 +1750,7 @@
 
 static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	unsigned int mcr;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
@@ -1748,7 +1779,7 @@
 
 static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	unsigned int result = 0;
 	unsigned int msr;
 	unsigned int mcr;
@@ -1805,7 +1836,7 @@
  *****************************************************************************/
 static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	struct async_icount cnow;
 	struct async_icount cprev;
 	struct serial_icounter_struct icount;
@@ -1887,7 +1918,7 @@
  *****************************************************************************/
 static void edge_break (struct usb_serial_port *port, int break_state)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	int status;
 
 	/* flush and chase */
@@ -1921,14 +1952,13 @@
  * process_rcvd_data
  *	this function handles the data received on the bulk in pipe.
  *****************************************************************************/
-static int process_rcvd_data (struct edgeport_serial *edge_serial, unsigned char * buffer, __u16 bufferLength)
+static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned char * buffer, __u16 bufferLength)
 {
 	struct usb_serial_port *port;
 	struct edgeport_port *edge_port;
 	struct tty_struct *tty;
 	__u16 lastBufferLength;
 	__u16 rxLen;
-	int i;
 
 	dbg("%s", __FUNCTION__);
 
@@ -1983,7 +2013,6 @@
 
 					// We have all the header bytes, process the status now
 					process_rcvd_status (edge_serial, edge_serial->rxHeader2, 0);
-
 					edge_serial->rxState = EXPECT_HDR1;
 					break;
 				} else {
@@ -2024,15 +2053,7 @@
 						tty = edge_port->port->tty;
 						if (tty) {
 							dbg("%s - Sending %d bytes to TTY for port %d", __FUNCTION__, rxLen, edge_serial->rxPort);
-							for (i = 0; i < rxLen ; ++i) {
-								/* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */
-								if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
-									tty_flip_buffer_push(tty);
-								}
-								/* this doesn't actually push the data through unless tty->low_latency is set */
-								tty_insert_flip_char(tty, buffer[i], 0);
-							}
-							tty_flip_buffer_push(tty);
+							edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
 						}
 						edge_port->icount.rx += rxLen;
 					}
@@ -2053,8 +2074,6 @@
 
 		}
 	}
-
-	return 0;
 }
 
 
@@ -2070,7 +2089,7 @@
 
 	/* switch the port pointer to the one being currently talked about */
 	port = edge_serial->serial->port[edge_serial->rxPort];
-        edge_port = usb_get_serial_port_data(port);
+	edge_port = usb_get_serial_port_data(port);
 	if (edge_port == NULL) {
 		dev_err(&edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __FUNCTION__, edge_serial->rxPort);
 		return;
@@ -2160,6 +2179,37 @@
 
 
 /*****************************************************************************
+ * edge_tty_recv
+ *	this function passes data on to the tty flip buffer
+ *****************************************************************************/
+static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length)
+{
+	int cnt;
+
+	do {
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+			tty_flip_buffer_push(tty);
+			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+				dev_err(dev, "%s - dropping data, %d bytes lost\n",
+					__FUNCTION__, length);
+				return;
+			}
+		}
+		cnt = min(length, TTY_FLIPBUF_SIZE - tty->flip.count);
+		memcpy(tty->flip.char_buf_ptr, data, cnt);
+		memset(tty->flip.flag_buf_ptr, 0, cnt);
+		tty->flip.char_buf_ptr += cnt;
+		tty->flip.flag_buf_ptr += cnt;
+		tty->flip.count += cnt;
+		data += cnt;
+		length -= cnt;
+	} while (length > 0);
+
+	tty_flip_buffer_push(tty);
+}
+
+
+/*****************************************************************************
  * handle_new_msr
  *	this function handles any change to the msr register for a port.
  *****************************************************************************/
@@ -2218,10 +2268,8 @@
 	}
 
 	/* Place LSR data byte into Rx buffer */
-	if (lsrData && edge_port->port->tty) {
-		tty_insert_flip_char(edge_port->port->tty, data, 0);
-		tty_flip_buffer_push(edge_port->port->tty);
-	}
+	if (lsrData && edge_port->port->tty)
+		edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1);
 
 	/* update input line counters */
 	icount = &edge_port->icount;
@@ -2442,9 +2490,10 @@
 
 	if (status) {
 		/* something went wrong */
-		dbg("%s - usb_submit_urb(write bulk) failed", __FUNCTION__);
-		usb_unlink_urb (urb);
-		usb_free_urb   (urb);
+		dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __FUNCTION__, status);
+		usb_kill_urb(urb);
+		usb_free_urb(urb);
+		CmdUrbs--;
 		return status;
 	}
 
@@ -2524,8 +2573,6 @@
 {
 	int i;
 	__u16 custom;
-	__u16 round1;
-	__u16 round;
 
 
 	dbg("%s - %d", __FUNCTION__, baudrate);
@@ -2540,16 +2587,10 @@
 	// We have tried all of the standard baud rates
 	// lets try to calculate the divisor for this baud rate
 	// Make sure the baud rate is reasonable
-	if (baudrate < 230400) {
+	if (baudrate > 50 && baudrate < 230400) {
 		// get divisor
-		custom = (__u16)(230400L  / baudrate);
+		custom = (__u16)((230400L + baudrate/2) / baudrate);
 
-		// Check for round off
-		round1 = (__u16)(2304000L / baudrate);
-		round = (__u16)(round1 - (custom * 10));
-		if (round > 4) {
-			custom++;
-		}
 		*divisor = custom;
 
 		dbg("%s - Baud %d = %d\n", __FUNCTION__, baudrate, custom);
@@ -2601,6 +2642,9 @@
  *	This routine is called to set the UART on the device to match the specified
  *	new settings.
  *****************************************************************************/
+#ifndef CMSPAR
+#define CMSPAR 0
+#endif
 static void change_port_settings (struct edgeport_port *edge_port, struct termios *old_termios)
 {
 	struct tty_struct *tty;
@@ -2641,7 +2685,15 @@
 
 	lParity = LCR_PAR_NONE;
 	if (cflag & PARENB) {
-		if (cflag & PARODD) {
+		if (cflag & CMSPAR) {
+			if (cflag & PARODD) {
+				lParity = LCR_PAR_MARK;
+				dbg("%s - parity = mark", __FUNCTION__);
+			} else {
+				lParity = LCR_PAR_SPACE;
+				dbg("%s - parity = space", __FUNCTION__);
+			}
+		} else if (cflag & PARODD) {
 			lParity = LCR_PAR_ODD;
 			dbg("%s - parity = odd", __FUNCTION__);
 		} else {
@@ -2745,9 +2797,12 @@
 static void unicode_to_ascii (char *string, __le16 *unicode, int unicode_size)
 {
 	int i;
-	for (i = 0; i < unicode_size; ++i) {
+
+	if (unicode_size <= 0)
+		return;
+
+	for (i = 0; i < unicode_size; ++i)
 		string[i] = (char)(le16_to_cpu(unicode[i]));
-	}
 	string[unicode_size] = 0x00;
 }
 
@@ -2868,7 +2923,7 @@
 		record = (struct edge_firmware_image_record *)firmware;
 		response = sram_write (edge_serial->serial, le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len), &record->Data[0]);
 		if (response < 0) {
-			dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), record->Len);
+			dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len));
 			break;
 		}
 		firmware += sizeof (struct edge_firmware_image_record) + le16_to_cpu(record->Len);
@@ -2887,8 +2942,6 @@
 }
 
 
-
-
 /****************************************************************************
  * edge_startup
  ****************************************************************************/
@@ -2904,10 +2957,11 @@
 	/* create our private serial structure */
 	edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
 	if (edge_serial == NULL) {
-		dev_err(&serial->dev->dev, "%s - Out of memory", __FUNCTION__);
+		dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
 	memset (edge_serial, 0, sizeof(struct edgeport_serial));
+	spin_lock_init(&edge_serial->es_lock);
 	edge_serial->serial = serial;
 	usb_set_serial_data(serial, edge_serial);
 
@@ -2960,12 +3014,13 @@
 	for (i = 0; i < serial->num_ports; ++i) {
 		edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
 		if (edge_port == NULL) {
-			dev_err(&serial->dev->dev, "%s - Out of memory", __FUNCTION__);
+			dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
 			usb_set_serial_data(serial, NULL);
 			kfree(edge_serial);
 			return -ENOMEM;
 		}
 		memset (edge_port, 0, sizeof(struct edgeport_port));
+		spin_lock_init(&edge_port->ep_lock);
 		edge_port->port = serial->port[i];
 		usb_set_serial_port_data(serial->port[i], edge_port);
 	}
@@ -2974,7 +3029,6 @@
 }
 
 
-
 /****************************************************************************
  * edge_shutdown
  *	This function is called whenever the device is removed from the usb bus.
@@ -3002,6 +3056,7 @@
 static int __init edgeport_init(void)
 {
 	int retval;
+
 	retval = usb_serial_register(&edgeport_2port_device);
 	if (retval)
 		goto failed_2port_device_register;
@@ -3016,6 +3071,7 @@
 		goto failed_usb_register;
 	info(DRIVER_DESC " " DRIVER_VERSION);
 	return 0;
+
 failed_usb_register:
 	usb_serial_deregister(&edgeport_8port_device);
 failed_8port_device_register:
@@ -3027,7 +3083,6 @@
 }
 
 
-
 /****************************************************************************
  * edgeport_exit
  *	Called when the driver is about to be unloaded.
@@ -3050,3 +3105,6 @@
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debug enabled or not");
+
+module_param(low_latency, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, "Low latency enabled or not");
diff -Nru a/drivers/usb/serial/io_fw_boot.h b/drivers/usb/serial/io_fw_boot.h
--- a/drivers/usb/serial/io_fw_boot.h	2004-12-24 13:37:30 -08:00
+++ b/drivers/usb/serial/io_fw_boot.h	2004-12-24 13:37:30 -08:00
@@ -13,9 +13,9 @@
 #if !defined(DEFINED_EDGE_FIRMWARE_IMAGE_RECORD)
 #define DEFINED_EDGE_FIRMWARE_IMAGE_RECORD
 	struct edge_firmware_image_record {
-		unsigned short ExtAddr;
-		unsigned short Addr;
-		unsigned short Len;
+		__le16 ExtAddr;
+		__le16 Addr;
+		__le16 Len;
 		unsigned char  Data[0];
 	} __attribute__ ((packed));
 
diff -Nru a/drivers/usb/serial/io_fw_boot2.h b/drivers/usb/serial/io_fw_boot2.h
--- a/drivers/usb/serial/io_fw_boot2.h	2004-12-24 13:36:30 -08:00
+++ b/drivers/usb/serial/io_fw_boot2.h	2004-12-24 13:36:30 -08:00
@@ -13,9 +13,9 @@
 #if !defined(DEFINED_EDGE_FIRMWARE_IMAGE_RECORD)
 #define DEFINED_EDGE_FIRMWARE_IMAGE_RECORD
 	struct edge_firmware_image_record {
-		unsigned short ExtAddr;
-		unsigned short Addr;
-		unsigned short Len;
+		__le16 ExtAddr;
+		__le16 Addr;
+		__le16 Len;
 		unsigned char  Data[0];
 	} __attribute__ ((packed));
 
diff -Nru a/drivers/usb/serial/io_fw_down.h b/drivers/usb/serial/io_fw_down.h
--- a/drivers/usb/serial/io_fw_down.h	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/serial/io_fw_down.h	2004-12-24 13:37:29 -08:00
@@ -13,9 +13,9 @@
 #if !defined(DEFINED_EDGE_FIRMWARE_IMAGE_RECORD)
 	#define DEFINED_EDGE_FIRMWARE_IMAGE_RECORD
 	struct edge_firmware_image_record {
-		unsigned short	ExtAddr;
-		unsigned short	Addr;
-		unsigned short	Len;
+		__le16 ExtAddr;
+		__le16 Addr;
+		__le16 Len;
 		unsigned char	Data[0];
 	} __attribute__ ((packed));
 
diff -Nru a/drivers/usb/serial/io_fw_down2.h b/drivers/usb/serial/io_fw_down2.h
--- a/drivers/usb/serial/io_fw_down2.h	2004-12-24 13:36:31 -08:00
+++ b/drivers/usb/serial/io_fw_down2.h	2004-12-24 13:36:31 -08:00
@@ -13,9 +13,9 @@
 #if !defined(DEFINED_EDGE_FIRMWARE_IMAGE_RECORD)
 	#define DEFINED_EDGE_FIRMWARE_IMAGE_RECORD
 	struct edge_firmware_image_record {
-		unsigned short ExtAddr;
-		unsigned short Addr;
-		unsigned short Len;
+		__le16 ExtAddr;
+		__le16 Addr;
+		__le16 Len;
 		unsigned char  Data[0];
 	} __attribute__ ((packed));
 
diff -Nru a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
--- a/drivers/usb/serial/io_tables.h	2004-12-24 13:37:00 -08:00
+++ b/drivers/usb/serial/io_tables.h	2004-12-24 13:37:00 -08:00
@@ -98,6 +98,9 @@
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
 	.break_ctl		= edge_break,
+	.read_int_callback	= edge_interrupt_callback,
+	.read_bulk_callback	= edge_bulk_in_callback,
+	.write_bulk_callback	= edge_bulk_out_data_callback,
 };
 
 static struct usb_serial_device_type edgeport_4port_device = {
@@ -123,6 +126,9 @@
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
 	.break_ctl		= edge_break,
+	.read_int_callback	= edge_interrupt_callback,
+	.read_bulk_callback	= edge_bulk_in_callback,
+	.write_bulk_callback	= edge_bulk_out_data_callback,
 };
 
 static struct usb_serial_device_type edgeport_8port_device = {
@@ -148,6 +154,9 @@
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
 	.break_ctl		= edge_break,
+	.read_int_callback	= edge_interrupt_callback,
+	.read_bulk_callback	= edge_bulk_in_callback,
+	.write_bulk_callback	= edge_bulk_out_data_callback,
 };
 
 #endif
diff -Nru a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
--- a/drivers/usb/serial/io_ti.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/serial/io_ti.c	2004-12-24 13:37:29 -08:00
@@ -10,7 +10,11 @@
  *	(at your option) any later version.
  *
  * Supports the following devices:
- *	EP/1 EP/2 EP/4
+ *	EP/1 EP/2 EP/4 EP/21 EP/22 EP/221 EP/42 EP/421 WATCHPORT
+ *
+ * For questions or problems with this driver, contact Inside Out
+ * Networks technical support, or Peter Berger <pberger@brimson.com>,
+ * or Al Borchers <alborchers@steinerpoint.com>.
  *
  * Version history:
  *
@@ -34,18 +38,18 @@
 #include <linux/serial.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
+#include <asm/semaphore.h>
 #include <linux/usb.h>
+
 #include "usb-serial.h"
 #include "io_16654.h"
 #include "io_usbvend.h"
 #include "io_ti.h"
 
-static int debug;
-
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.2"
+#define DRIVER_VERSION "v0.7"
 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli"
 #define DRIVER_DESC "Edgeport USB Serial Driver"
 
@@ -73,6 +77,16 @@
 #define TI_MODE_DOWNLOAD	2   // Made it to download mode
 #define TI_MODE_TRANSITIONING	3   // Currently in boot mode but transitioning to download mode
 
+/* read urb state */
+#define EDGE_READ_URB_RUNNING	0
+#define EDGE_READ_URB_STOPPING	1
+#define EDGE_READ_URB_STOPPED	2
+
+#define EDGE_LOW_LATENCY	1
+#define EDGE_CLOSING_WAIT	4000	/* in .01 sec */
+
+#define EDGE_OUT_BUF_SIZE	1024
+
 
 /* Product information read from the Edgeport */
 struct product_info
@@ -81,6 +95,13 @@
 	__u8	hardware_type;		// Type of hardware
 } __attribute__((packed));
 
+/* circular buffer */
+struct edge_buf {
+	unsigned int	buf_size;
+	char		*buf_buf;
+	char		*buf_get;
+	char		*buf_put;
+};
 
 struct edgeport_port {
 	__u16 uart_base;
@@ -102,12 +123,18 @@
 						   happen */
 	struct edgeport_serial	*edge_serial;
 	struct usb_serial_port	*port;
+	__u8 bUartMode;		/* Port type, 0: RS232, etc. */ 
+	spinlock_t ep_lock;
+	int ep_read_urb_state;
+	int ep_write_urb_in_use;
+	struct edge_buf *ep_out_buf;
 };
 
 struct edgeport_serial {
 	struct product_info product_info;
 	u8 TI_I2C_Type;			// Type of I2C in UMP
 	u8 TiReadI2C;			// Set to TRUE if we have read the I2c in Boot Mode
+	struct semaphore es_sem;
 	int num_ports_open;
 	struct usb_serial *serial;
 };
@@ -116,6 +143,21 @@
 /* Devices that this driver supports */
 static struct usb_device_id edgeport_1port_id_table [] = {
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROXIMITY) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOTION) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOISTURE) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_TEMPERATURE) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_HUMIDITY) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_POWER) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_LIGHT) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_RADIATION) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_DISTANCE) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_ACCELERATION) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROX_DIST) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_HP4CD) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_PCI) },
 	{ }
 };
 
@@ -129,12 +171,32 @@
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4) },
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4I) },
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22I) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_221C) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22C) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21C) },
+// The 4-port shows up as two 2-port devices
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4S) },
 	{ }
 };
 
 /* Devices that this driver supports */
 static struct usb_device_id id_table_combined [] = {
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROXIMITY) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOTION) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_MOISTURE) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_TEMPERATURE) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_HUMIDITY) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_POWER) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_LIGHT) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_RADIATION) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_DISTANCE) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_ACCELERATION) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_WP_PROX_DIST) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_HP4CD) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_PLUS_PWR_PCI) },
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) },
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) },
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) },
@@ -144,6 +206,10 @@
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4) },
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4I) },
 	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22I) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_221C) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_22C) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_21C) },
+	{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_4S) },
 	{ }
 };
 
@@ -160,12 +226,33 @@
 
 static struct EDGE_FIRMWARE_VERSION_INFO OperationalCodeImageVersion;
 
+static int debug;
+
 static int TIStayInBootMode = 0;
+static int low_latency = EDGE_LOW_LATENCY;
+static int closing_wait = EDGE_CLOSING_WAIT;
 static int ignore_cpu_rev = 0;
 
 
+static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length);
+
+static void stop_read(struct edgeport_port *edge_port);
+static int restart_read(struct edgeport_port *edge_port);
 
 static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios);
+static void edge_send(struct usb_serial_port *port);
+
+/* circular buffer */
+static struct edge_buf *edge_buf_alloc(unsigned int size);
+static void edge_buf_free(struct edge_buf *eb);
+static void edge_buf_clear(struct edge_buf *eb);
+static unsigned int edge_buf_data_avail(struct edge_buf *eb);
+static unsigned int edge_buf_space_avail(struct edge_buf *eb);
+static unsigned int edge_buf_put(struct edge_buf *eb, const char *buf,
+	unsigned int count);
+static unsigned int edge_buf_get(struct edge_buf *eb, char *buf,
+	unsigned int count);
+
 
 static int TIReadVendorRequestSync (struct usb_device *dev,
 				__u8		request,
@@ -241,7 +328,6 @@
 
 }
 
-
 /* clear tx/rx buffers and fifo in TI UMP */
 static int TIPurgeDataSync (struct usb_serial_port *port, __u16 mask)
 {
@@ -291,7 +377,7 @@
 		status = TIReadVendorRequestSync (dev,
 						  UMPC_MEMORY_READ,	// Request
 						  (__u16)address_type,	// wValue (Address type)
-						  be_start_address,	// wIndex (Address to read)
+						  (__force __u16)be_start_address,	// wIndex (Address to read)
 						  buffer,		// TransferBuffer
 						  read_length);	// TransferBufferLength
 
@@ -405,7 +491,7 @@
 	status = TISendVendorRequestSync (serial->serial->dev,
 					UMPC_MEMORY_WRITE,	// Request
 					(__u16)address_type,	// wValue
-					be_start_address,	// wIndex
+					(__force __u16)be_start_address,	// wIndex
 					buffer,			// TransferBuffer
 					write_length);
 	if (status) {
@@ -432,11 +518,11 @@
 		status = TISendVendorRequestSync (serial->serial->dev,
 						UMPC_MEMORY_WRITE,	// Request
 						(__u16)address_type,	// wValue
-						be_start_address,	// wIndex
+						(__force __u16)be_start_address,	// wIndex
 						buffer,	  		// TransferBuffer
 						write_length);		// TransferBufferLength
 		if (status) {
-			dbg ("%s - ERROR %d", __FUNCTION__, status);
+			dev_err (&serial->serial->dev->dev, "%s - ERROR %d\n", __FUNCTION__, status);
 			return status;
 		}
 		
@@ -510,74 +596,54 @@
 	return bytes_left;
 }
 
-static void TIChasePort(struct edgeport_port *port)
+static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int flush)
 {
-	int loops;
-	int last_count;
-	int write_size;
-
-restart_tx_loop:
-	// Base the LoopTime on the baud rate
-	if (port->baud_rate == 0)
-		port->baud_rate = 1200;
-
-	write_size = port->tx.count;
-	loops = max(100, (100*write_size)/(port->baud_rate/10));
-	dbg ("%s - write_size %d, baud %d loop = %d", __FUNCTION__,
-	     write_size, port->baud_rate, loops);
-
-	while (1) {
-		// Save Last count
-		last_count = port->tx.count;
-
-		dbg ("%s - Tx Buffer Size = %d loops = %d", __FUNCTION__,
-		     last_count, loops);
-
-		/* Is the Edgeport Buffer empty? */
-		if (port->tx.count == 0)
+	int baud_rate;
+	struct tty_struct *tty = port->port->tty;
+	wait_queue_t wait;
+	unsigned long flags;
+
+	if (!timeout)
+		timeout = (HZ*EDGE_CLOSING_WAIT)/100;
+
+	/* wait for data to drain from the buffer */
+	spin_lock_irqsave(&port->ep_lock, flags);
+	init_waitqueue_entry(&wait, current);
+	add_wait_queue(&tty->write_wait, &wait);
+	for (;;) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		if (edge_buf_data_avail(port->ep_out_buf) == 0
+		|| timeout == 0 || signal_pending(current)
+		|| !usb_get_intfdata(port->port->serial->interface))  /* disconnect */
+			break;
+		spin_unlock_irqrestore(&port->ep_lock, flags);
+		timeout = schedule_timeout(timeout);
+		spin_lock_irqsave(&port->ep_lock, flags);
+	}
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&tty->write_wait, &wait);
+	if (flush)
+		edge_buf_clear(port->ep_out_buf);
+	spin_unlock_irqrestore(&port->ep_lock, flags);
+
+	/* wait for data to drain from the device */
+	timeout += jiffies;
+	while ((long)(jiffies - timeout) < 0 && !signal_pending(current)
+	&& usb_get_intfdata(port->port->serial->interface)) {  /* not disconnected */
+		if (!TIIsTxActive(port))
 			break;
-
-		/* Block the thread for 10ms */
 		msleep(10);
-
-		if (last_count == port->tx.count) {
-			/* No activity.. count down. */
-			--loops;
-			if (loops == 0) {
-				dbg ("%s - Wait for TxEmpty - TIMEOUT",
-				     __FUNCTION__);
-				return;
-			}
-		} else {
-			/* Reset timeout value back to a minimum of 1 second */
-			dbg ("%s - Wait for TxEmpty  Reset Count", __FUNCTION__);
-			goto restart_tx_loop;
-		}
 	}
 
-	dbg ("%s - Local Tx Buffer Empty -- Waiting for TI UMP to EMPTY X/Y and FIFO",
-	     __FUNCTION__);
-
-	write_size = TIIsTxActive (port);
-	loops = max(50, (100*write_size)/(port->baud_rate/10));
-	dbg ("%s - write_size %d, baud %d loop = %d", __FUNCTION__, 
-	     write_size, port->baud_rate, loops);
-
-	while (1) {
-		/* This function takes 4 ms; */
-		if (!TIIsTxActive (port)) {
-			/* Delay a few char times */
-			msleep(50);
-			dbg ("%s - Empty", __FUNCTION__);
-			return;
-		}
+	/* disconnected */
+	if (!usb_get_intfdata(port->port->serial->interface))
+		return;
 
-		--loops;
-		if (loops == 0) {
-			dbg ("%s - TIMEOUT", __FUNCTION__);
-			return;
-		}
-	}
+	/* wait one more character time, based on baud rate */
+	/* (TIIsTxActive doesn't seem to wait for the last byte) */
+	if ((baud_rate=port->baud_rate) == 0)
+		baud_rate = 50;
+	msleep(max(1,(10000+baud_rate-1)/baud_rate));
 }
 
 static int TIChooseConfiguration (struct usb_device *dev)
@@ -688,6 +754,7 @@
 	struct ti_i2c_desc *rom_desc;
 	int start_address = 2;
 	__u8 *buffer;
+	__u16 ttype;
 
 	rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL);
 	if (!rom_desc) {
@@ -701,12 +768,12 @@
 		return -ENOMEM;
 	}
 
-	// Read the first byte (Signature0) must be 0x52
+	// Read the first byte (Signature0) must be 0x52 or 0x10
 	status = TIReadRom (serial, 0, 1, buffer);
 	if (status)
 		goto ExitTiValidateI2cImage; 
 
-	if (*buffer != 0x52) {
+	if (*buffer != UMP5152 && *buffer != UMP3410) {
 		dev_err (dev, "%s - invalid buffer signature\n", __FUNCTION__);
 		status = -ENODEV;
 		goto ExitTiValidateI2cImage;
@@ -730,7 +797,9 @@
 		dbg ("%s Type = 0x%x", __FUNCTION__, rom_desc->Type);
 
 		// Skip type 2 record
-		if ((rom_desc->Type & 0x0f) != I2C_DESC_TYPE_FIRMWARE_BASIC) {
+		ttype = rom_desc->Type & 0x0f;
+		if ( ttype != I2C_DESC_TYPE_FIRMWARE_BASIC
+			&& ttype != I2C_DESC_TYPE_FIRMWARE_AUTO ) {
 			// Read the descriptor data
 			status = TIReadRom(serial,
 						start_address+sizeof(struct ti_i2c_desc),
@@ -840,7 +909,7 @@
 
 	memcpy (buffer + sizeof(struct ti_i2c_firmware_rec),
 		&PagableOperationalCodeImage[sizeof(struct ti_i2c_image_header)],
-		img_header->Length);
+		le16_to_cpu(img_header->Length));
 
 	for (i=0; i < buffer_size; i++) {
 		cs = (__u8)(cs + buffer[i]);
@@ -878,7 +947,7 @@
 		dbg ("%s - read 2 status error = %d", __FUNCTION__, status);
 	else
 		dbg ("%s - read 2 data = 0x%x", __FUNCTION__, data);
-	if ((!status) && data == 0x52) {
+	if ((!status) && (data == UMP5152 || data == UMP3410)) {
 		dbg ("%s - ROM_TYPE_II", __FUNCTION__);
 		serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
 		return 0;
@@ -895,7 +964,7 @@
 		dbg ("%s - read 3 status error = %d", __FUNCTION__, status);
 	else
 		dbg ("%s - read 2 data = 0x%x", __FUNCTION__, data);
-	if ((!status) && data == 0x52) {
+	if ((!status) && (data == UMP5152 || data == UMP3410)) {
 		dbg ("%s - ROM_TYPE_III", __FUNCTION__);
 		serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III;
 		return 0;
@@ -983,7 +1052,7 @@
 
 	interface = &serial->serial->interface->cur_altsetting->desc;
 	if (!interface) {
-		dev_err (&serial->serial->dev->dev, "%s - no interface set, error!", __FUNCTION__);
+		dev_err (dev, "%s - no interface set, error!\n", __FUNCTION__);
 		return -ENODEV;
 	}
 
@@ -1249,7 +1318,7 @@
 
 		  	dbg ("%s - Update complete 0x%x", __FUNCTION__, status);
 			if (status) {
-				dbg ("%s - UMPC_COPY_DNLD_TO_I2C failed", __FUNCTION__);
+				dev_err (dev, "%s - UMPC_COPY_DNLD_TO_I2C failed\n", __FUNCTION__);
 				kfree (rom_desc);
 				kfree (ti_manuf_desc);
 				return status;
@@ -1356,7 +1425,7 @@
 		header = (struct ti_i2c_image_header *)buffer;
 		
 		// update length and checksum after padding
-		header->Length 	 = (__u16)(buffer_size - sizeof(struct ti_i2c_image_header));
+		header->Length 	 = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_i2c_image_header)));
 		header->CheckSum = cs;
 
 		// Download the operational code 
@@ -1560,6 +1629,7 @@
 static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr)
 {
 	struct async_icount *icount;
+	struct tty_struct *tty;
 
 	dbg ("%s - %02x", __FUNCTION__, msr);
 
@@ -1581,6 +1651,17 @@
 	/* Save the new modem status */
 	edge_port->shadow_msr = msr & 0xf0;
 
+	tty = edge_port->port->tty;
+	/* handle CTS flow control */
+	if (tty && C_CRTSCTS(tty)) {
+		if (msr & EDGEPORT_MSR_CTS) {
+			tty->hw_stopped = 0;
+			tty_wakeup(tty);
+		} else {
+			tty->hw_stopped = 1;
+		}
+	}
+
 	return;
 }
 
@@ -1602,10 +1683,8 @@
 	}
 
 	/* Place LSR data byte into Rx buffer */
-	if (lsr_data && edge_port->port->tty) {
-		tty_insert_flip_char(edge_port->port->tty, data, 0);
-		tty_flip_buffer_push(edge_port->port->tty);
-	}
+	if (lsr_data && edge_port->port->tty)
+		edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1);
 
 	/* update input line counters */
 	icount = &edge_port->icount;
@@ -1646,7 +1725,7 @@
 		dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
 		return;
 	default:
-		dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
+		dev_err(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __FUNCTION__, urb->status);
 		goto exit;
 	}
 
@@ -1715,21 +1794,31 @@
 	struct edgeport_port *edge_port = (struct edgeport_port *)urb->context;
 	unsigned char *data = urb->transfer_buffer;
 	struct tty_struct *tty;
-	int status;
-	int i;
+	int status = 0;
 	int port_number;
 
 	dbg("%s", __FUNCTION__);
 
-	if (urb->status) {
-		dbg ("%s - nonzero read bulk status received: %d",
-		     __FUNCTION__, urb->status);
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		/* this urb is terminated, clean up */
+		dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
+		return;
+	default:
+		dev_err (&urb->dev->dev,"%s - nonzero read bulk status received: %d\n",
+		     __FUNCTION__, urb->status );
+	}
 
-		if (urb->status == -EPIPE) {
-			/* clear any problem that might have happened on this pipe */
-			usb_clear_halt (edge_port->port->serial->dev, urb->pipe);
-			goto exit;
-		}
+	if (urb->status == -EPIPE)
+		goto exit;
+
+	if (urb->status) {
+		dev_err(&urb->dev->dev,"%s - stopping read!\n", __FUNCTION__);
 		return;
 	}
 
@@ -1752,52 +1841,78 @@
 		if (edge_port->close_pending) {
 			dbg ("%s - close is pending, dropping data on the floor.", __FUNCTION__);
 		} else {
-			for (i = 0; i < urb->actual_length ; ++i) {
-				/* if we insert more than TTY_FLIPBUF_SIZE characters,
-				 * we drop them. */
-				if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-					tty_flip_buffer_push(tty);
-				}
-				/* this doesn't actually push the data through unless
-				 * tty->low_latency is set */
-				tty_insert_flip_char(tty, data[i], 0);
-			}
-			tty_flip_buffer_push(tty);
+			edge_tty_recv(&edge_port->port->dev, tty, data, urb->actual_length);
 		}
 		edge_port->icount.rx += urb->actual_length;
 	}
 
 exit:
-	/* continue always trying to read */
-	status = usb_submit_urb (urb, GFP_ATOMIC);
+	/* continue read unless stopped */
+	spin_lock(&edge_port->ep_lock);
+	if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING) {
+		urb->dev = edge_port->port->serial->dev;
+		status = usb_submit_urb(urb, GFP_ATOMIC);
+	} else if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPING) {
+		edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPED;
+	}
+	spin_unlock(&edge_port->ep_lock);
 	if (status)
 		dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n",
 			 __FUNCTION__, status);
 }
 
+static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length)
+{
+	int cnt;
+
+	do {
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+			tty_flip_buffer_push(tty);
+			if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+				dev_err(dev, "%s - dropping data, %d bytes lost\n",
+					__FUNCTION__, length);
+				return;
+			}
+		}
+		cnt = min(length, TTY_FLIPBUF_SIZE - tty->flip.count);
+		memcpy(tty->flip.char_buf_ptr, data, cnt);
+		memset(tty->flip.flag_buf_ptr, 0, cnt);
+		tty->flip.char_buf_ptr += cnt;
+		tty->flip.flag_buf_ptr += cnt;
+		tty->flip.count += cnt;
+		data += cnt;
+		length -= cnt;
+	} while (length > 0);
+
+	tty_flip_buffer_push(tty);
+}
+
 static void edge_bulk_out_callback (struct urb *urb, struct pt_regs *regs)
 {
 	struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
-	struct tty_struct *tty;
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 
 	dbg ("%s - port %d", __FUNCTION__, port->number);
 
-	if (urb->status) {
-		dbg ("%s - nonzero write bulk status received: %d",
-		     __FUNCTION__, urb->status);
+	edge_port->ep_write_urb_in_use = 0;
 
-		if (urb->status == -EPIPE) {
-			/* clear any problem that might have happened on this pipe */
-			usb_clear_halt (port->serial->dev, urb->pipe);
-		}
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		/* this urb is terminated, clean up */
+		dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
 		return;
+	default:
+		dev_err (&urb->dev->dev,"%s - nonzero write bulk status received: %d\n",
+		     __FUNCTION__, urb->status);
 	}
 
-	tty = port->tty;
-	if (tty) {
-		/* let the tty driver wakeup if it has a special write_wakeup function */
-		tty_wakeup(tty);
-	}
+	/* send any buffered data */
+	edge_send(port);
 }
 
 static int edge_open (struct usb_serial_port *port, struct file * filp)
@@ -1816,11 +1931,8 @@
 	if (edge_port == NULL)
 		return -ENODEV;
 
-	/* force low_latency on so that our tty_push actually forces the data through, 
-	   otherwise it is scheduled, and with high data rates (like with OHCI) data
-	   can get lost. */
 	if (port->tty)
-		port->tty->low_latency = 1;
+		port->tty->low_latency = low_latency;
 
 	port_number = port->number - port->serial->minor;
 	switch (port_number) {
@@ -1847,8 +1959,11 @@
 
 	/* turn off loopback */
 	status = TIClearLoopBack (edge_port);
-	if (status)
+	if (status) {
+		dev_err(&port->dev,"%s - cannot send clear loopback command, %d\n",
+			__FUNCTION__, status);
 		return status;
+	}
 	
 	/* set up the port settings */
 	edge_set_termios (port, NULL);
@@ -1874,8 +1989,10 @@
 					open_settings,
 					NULL,
 					0);
-	if (status)
+	if (status) {
+		dev_err(&port->dev,"%s - cannot send open command, %d\n", __FUNCTION__, status);
 		return status;
+	}
 
 	/* Start the DMA? */
 	status = TIWriteCommandSync (dev,
@@ -1884,13 +2001,17 @@
 					0,
 					NULL,
 					0);
-	if (status)
+	if (status) {
+		dev_err(&port->dev,"%s - cannot send start DMA command, %d\n", __FUNCTION__, status);
 		return status;
+	}
 
 	/* Clear TX and RX buffers in UMP */
 	status = TIPurgeDataSync (port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN);
-	if (status)
+	if (status) {
+		dev_err(&port->dev,"%s - cannot send clear buffers command, %d\n", __FUNCTION__, status);
 		return status;
+	}
 
 	/* Read Initial MSR */
 	status = TIReadVendorRequestSync (dev,
@@ -1899,18 +2020,27 @@
 					(__u16)(UMPM_UART1_PORT + port_number),	// wIndex (Address)
 					&edge_port->shadow_msr,			// TransferBuffer
 					1);					// TransferBufferLength
-	if (status)
+	if (status) {
+ 		dev_err(&port->dev,"%s - cannot send read MSR command, %d\n", __FUNCTION__, status);
 		return status;
+	}
 
 	dbg ("ShadowMSR 0x%X", edge_port->shadow_msr);
  
+	/* Set Initial MCR */
+	edge_port->shadow_mcr = MCR_RTS | MCR_DTR;
+	dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr);
+
 	edge_serial = edge_port->edge_serial;
+	if (down_interruptible(&edge_serial->es_sem))
+		return -ERESTARTSYS;
 	if (edge_serial->num_ports_open == 0) {
 		/* we are the first port to be opened, let's post the interrupt urb */
 		urb = edge_serial->serial->port[0]->interrupt_in_urb;
 		if (!urb) {
 			dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__);
-			return -EINVAL;
+			status = -EINVAL;
+			goto up_es_sem;
 		}
 		urb->complete = edge_interrupt_callback;
 		urb->context = edge_serial;
@@ -1918,7 +2048,7 @@
 		status = usb_submit_urb (urb, GFP_KERNEL);
 		if (status) {
 			dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status);
-			return status;
+			goto up_es_sem;
 		}
 	}
 
@@ -1933,25 +2063,34 @@
 	urb = port->read_urb;
 	if (!urb) {
 		dev_err (&port->dev, "%s - no read urb present, exiting\n", __FUNCTION__);
-		return -EINVAL;
+		status = -EINVAL;
+		goto unlink_int_urb;
 	}
+	edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING;
 	urb->complete = edge_bulk_in_callback;
 	urb->context = edge_port;
 	urb->dev = dev;
 	status = usb_submit_urb (urb, GFP_KERNEL);
 	if (status) {
 		dev_err (&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __FUNCTION__, status);
-		return status;
+		goto unlink_int_urb;
 	}
 
 	++edge_serial->num_ports_open;
 
 	dbg("%s - exited", __FUNCTION__);
 
-	return 0;
+	goto up_es_sem;
+
+unlink_int_urb:
+	if (edge_port->edge_serial->num_ports_open == 0)
+		usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
+up_es_sem:
+	up(&edge_serial->es_sem);
+	return status;
 }
 
-static void edge_close (struct usb_serial_port *port, struct file * filp)
+static void edge_close (struct usb_serial_port *port, struct file *filp)
 {
 	struct edgeport_serial *edge_serial;
 	struct edgeport_port *edge_port;
@@ -1969,10 +2108,12 @@
 	 * this flag and dump add read data */
 	edge_port->close_pending = 1;
 
-	/* chase the port close */
-	TIChasePort (edge_port);
+	/* chase the port close and flush */
+	TIChasePort (edge_port, (HZ*closing_wait)/100, 1);
 
-	usb_unlink_urb (port->read_urb);
+	usb_kill_urb(port->read_urb);
+	usb_kill_urb(port->write_urb);
+	edge_port->ep_write_urb_in_use = 0;
 
 	/* assuming we can still talk to the device,
 	 * send a close port command to it */
@@ -1984,21 +2125,23 @@
 				     0,
 				     NULL,
 				     0);
+	down(&edge_serial->es_sem);
 	--edge_port->edge_serial->num_ports_open;
 	if (edge_port->edge_serial->num_ports_open <= 0) {
 		/* last port is now closed, let's shut down our interrupt urb */
-		usb_unlink_urb (port->serial->port[0]->interrupt_in_urb);
+		usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
 		edge_port->edge_serial->num_ports_open = 0;
 	}
+	up(&edge_serial->es_sem);
 	edge_port->close_pending = 0;
 
 	dbg("%s - exited", __FUNCTION__);
 }
 
-static int edge_write (struct usb_serial_port *port, int from_user, const unsigned char *data, int count)
+static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count)
 {
 	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-	int result;
+	unsigned long flags;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
@@ -2011,21 +2154,46 @@
 		return -ENODEV;
 	if (edge_port->close_pending == 1)
 		return -ENODEV;
-	
-	if (port->write_urb->status == -EINPROGRESS) {
-		dbg ("%s - already writing", __FUNCTION__);
-		return 0;
+
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
+	count = edge_buf_put(edge_port->ep_out_buf, data, count);
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
+
+	edge_send(port);
+
+	return count;
+}
+
+static void edge_send(struct usb_serial_port *port)
+{
+	int count, result;
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct tty_struct *tty = port->tty;
+	unsigned long flags;
+
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
+
+	if (edge_port->ep_write_urb_in_use) {
+		spin_unlock_irqrestore(&edge_port->ep_lock, flags);
+		return;
 	}
 
-	count = min (count, port->bulk_out_size);
+	count = edge_buf_get(edge_port->ep_out_buf,
+				port->write_urb->transfer_buffer,
+				port->bulk_out_size);
 
-	if (from_user) {
-		if (copy_from_user(port->write_urb->transfer_buffer, data, count))
-			return -EFAULT;
-	} else {
-		memcpy (port->write_urb->transfer_buffer, data, count);
+	if (count == 0) {
+		spin_unlock_irqrestore(&edge_port->ep_lock, flags);
+		return;
 	}
 
+	edge_port->ep_write_urb_in_use = 1;
+
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
+
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer);
 
 	/* set up our urb */
@@ -2038,33 +2206,38 @@
 
 	/* send the data out the bulk port */
 	result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
-	if (result)
+	if (result) {
 		dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
-	else
-		result = count;
-
-	if (result > 0)
+		edge_port->ep_write_urb_in_use = 0;
+		// TODO: reschedule edge_send
+	} else {
 		edge_port->icount.tx += count;
+	}
 
-	return result;
+	/* wakeup any process waiting for writes to complete */
+	/* there is now more room in the buffer for new writes */
+	if (tty) {
+		/* let the tty driver wakeup if it has a special write_wakeup function */
+		tty_wakeup(tty);
+	}
 }
 
 static int edge_write_room (struct usb_serial_port *port)
 {
 	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	int room = 0;
+	unsigned long flags;
 
-	dbg("%s", __FUNCTION__);
+	dbg("%s - port %d", __FUNCTION__, port->number);
 
 	if (edge_port == NULL)
 		return -ENODEV;
 	if (edge_port->close_pending == 1)
 		return -ENODEV;
-	
-	dbg("%s - port %d", __FUNCTION__, port->number);
 
-	if (port->write_urb->status != -EINPROGRESS)
-		room = port->bulk_out_size;
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
+	room = edge_buf_space_avail(edge_port->ep_out_buf);
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
 
 	dbg("%s - returns %d", __FUNCTION__, room);
 	return room;
@@ -2074,18 +2247,18 @@
 {
 	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	int chars = 0;
+	unsigned long flags;
 
-	dbg("%s", __FUNCTION__);
+	dbg("%s - port %d", __FUNCTION__, port->number);
 
 	if (edge_port == NULL)
 		return -ENODEV;
 	if (edge_port->close_pending == 1)
 		return -ENODEV;
 
-	dbg("%s - port %d", __FUNCTION__, port->number);
-
-	if (port->write_urb->status == -EINPROGRESS)
-		chars = port->write_urb->transfer_buffer_length;
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
+	chars = edge_buf_data_avail(edge_port->ep_out_buf);
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
 
 	dbg ("%s - returns %d", __FUNCTION__, chars);
 	return chars;
@@ -2107,21 +2280,21 @@
 		dbg ("%s - no tty available", __FUNCTION__);
 		return;
 	}
+
 	/* if we are implementing XON/XOFF, send the stop character */
 	if (I_IXOFF(tty)) {
 		unsigned char stop_char = STOP_CHAR(tty);
-		status = edge_write (port, 0, &stop_char, 1);
+		status = edge_write (port, &stop_char, 1);
 		if (status <= 0) {
-			return;
+			dev_err(&port->dev, "%s - failed to write stop character, %d\n", __FUNCTION__, status);
 		}
 	}
 
-	/* if we are implementing RTS/CTS, toggle that line */
-	if (tty->termios->c_cflag & CRTSCTS) {
-		status = TIClearRts (edge_port);
-	}
+	/* if we are implementing RTS/CTS, stop reads */
+	/* and the Edgeport will clear the RTS line */
+	if (C_CRTSCTS(tty))
+		stop_read(edge_port);
 
-	usb_unlink_urb (port->read_urb);
 }
 
 static void edge_unthrottle (struct usb_serial_port *port)
@@ -2144,31 +2317,63 @@
 	/* if we are implementing XON/XOFF, send the start character */
 	if (I_IXOFF(tty)) {
 		unsigned char start_char = START_CHAR(tty);
-		status = edge_write (port, 0, &start_char, 1);
+		status = edge_write (port, &start_char, 1);
 		if (status <= 0) {
-			return;
+			dev_err(&port->dev, "%s - failed to write start character, %d\n", __FUNCTION__, status);
 		}
 	}
 
-	/* if we are implementing RTS/CTS, toggle that line */
-	if (tty->termios->c_cflag & CRTSCTS) {
-		status = TISetRts (edge_port);
+	/* if we are implementing RTS/CTS, restart reads */
+	/* are the Edgeport will assert the RTS line */
+	if (C_CRTSCTS(tty)) {
+		status = restart_read(edge_port);
+		if (status)
+			dev_err(&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __FUNCTION__, status);
 	}
 
-	port->read_urb->dev = port->serial->dev;
-	status = usb_submit_urb (port->read_urb, GFP_ATOMIC);
-	if (status) {
-		dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status);
-	}
 }
 
+static void stop_read(struct edgeport_port *edge_port)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
+
+	if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING)
+		edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPING;
+	edge_port->shadow_mcr &= ~MCR_RTS;
+
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
+}
+
+static int restart_read(struct edgeport_port *edge_port)
+{
+	struct urb *urb;
+	int status = 0;
+	unsigned long flags;
+
+	spin_lock_irqsave(&edge_port->ep_lock, flags);
+
+	if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPED) {
+		urb = edge_port->port->read_urb;
+		urb->complete = edge_bulk_in_callback;
+		urb->context = edge_port;
+		urb->dev = edge_port->port->serial->dev;
+		status = usb_submit_urb(urb, GFP_KERNEL);
+	}
+	edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING;
+	edge_port->shadow_mcr |= MCR_RTS;
+
+	spin_unlock_irqrestore(&edge_port->ep_lock, flags);
+
+	return status;
+}
 
 static void change_port_settings (struct edgeport_port *edge_port, struct termios *old_termios)
 {
 	struct ump_uart_config *config;
 	struct tty_struct *tty;
 	int baud;
-	int round;
 	unsigned cflag;
 	int status;
 	int port_number = edge_port->port->number - edge_port->port->serial->minor;
@@ -2195,7 +2400,7 @@
 	/* These flags must be set */
 	config->wFlags |= UMP_MASK_UART_FLAGS_RECEIVE_MS_INT;
 	config->wFlags |= UMP_MASK_UART_FLAGS_AUTO_START_ON_ERR;
-	config->bUartMode = 0;
+	config->bUartMode = (__u8)(edge_port->bUartMode);
 
 	switch (cflag & CSIZE) {
 		case CS5:
@@ -2247,6 +2452,8 @@
 		dbg("%s - RTS/CTS is enabled", __FUNCTION__);
 	} else {
 		dbg("%s - RTS/CTS is disabled", __FUNCTION__);
+		tty->hw_stopped = 0;
+		restart_read(edge_port);
 	}
 
 	/* if we are implementing XON/XOFF, set the start and stop character in the device */
@@ -2279,10 +2486,8 @@
 		/* pick a default, any default... */
 		baud = 9600;
 	}
-	config->wBaudRate = (__u16)(461550L / baud);
-	round = 4615500L / baud;
-	if ((round - (config->wBaudRate * 10)) >= 5)
-		config->wBaudRate++;
+	edge_port->baud_rate = baud;
+	config->wBaudRate = (__u16)((461550L + baud/2) / baud);
 
 	dbg ("%s - baud rate = %d, wBaudRate = %d", __FUNCTION__, baud, config->wBaudRate);
 
@@ -2329,20 +2534,18 @@
 	cflag = tty->termios->c_cflag;
 	/* check that they really want us to change something */
 	if (old_termios) {
-		if ((cflag == old_termios->c_cflag) &&
-		    (RELEVANT_IFLAG(tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) {
+		if (cflag == old_termios->c_cflag &&
+		    tty->termios->c_iflag == old_termios->c_iflag) {
 			dbg ("%s - nothing to change", __FUNCTION__);
 			return;
 		}
 	}
 
 	dbg("%s - clfag %08x iflag %08x", __FUNCTION__, 
-	    tty->termios->c_cflag,
-	    RELEVANT_IFLAG(tty->termios->c_iflag));
+	    tty->termios->c_cflag, tty->termios->c_iflag);
 	if (old_termios) {
 		dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__,
-		    old_termios->c_cflag,
-		    RELEVANT_IFLAG(old_termios->c_iflag));
+		    old_termios->c_cflag, old_termios->c_iflag);
 	}
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
@@ -2358,7 +2561,7 @@
 
 static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	unsigned int mcr;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
@@ -2387,7 +2590,7 @@
 
 static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
 {
-        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
+	struct edgeport_port *edge_port = usb_get_serial_port_data(port);
 	unsigned int result = 0;
 	unsigned int msr;
 	unsigned int mcr;
@@ -2426,7 +2629,7 @@
 	tmp.xmit_fifo_size	= edge_port->port->bulk_out_size;
 	tmp.baud_base		= 9600;
 	tmp.close_delay		= 5*HZ;
-	tmp.closing_wait	= 30*HZ;
+	tmp.closing_wait	= closing_wait;
 //	tmp.custom_divisor	= state->custom_divisor;
 //	tmp.hub6		= state->hub6;
 //	tmp.io_type		= state->io_type;
@@ -2507,7 +2710,7 @@
 	dbg ("%s - state = %d", __FUNCTION__, break_state);
 
 	/* chase the port close */
-	TIChasePort (edge_port);
+	TIChasePort (edge_port, 0, 0);
 
 	if (break_state == -1) {
 		status = TISetBreak (edge_port);
@@ -2537,6 +2740,7 @@
 		return -ENOMEM;
 	}
 	memset (edge_serial, 0, sizeof(struct edgeport_serial));
+	sema_init(&edge_serial->es_sem, 1);
 	edge_serial->serial = serial;
 	usb_set_serial_data(serial, edge_serial);
 
@@ -2551,25 +2755,49 @@
 		edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
 		if (edge_port == NULL) {
 			dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
-			return -ENOMEM;
+			goto cleanup;
 		}
 		memset (edge_port, 0, sizeof(struct edgeport_port));
+		spin_lock_init(&edge_port->ep_lock);
+		edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE);
+		if (edge_port->ep_out_buf == NULL) {
+			dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
+			kfree(edge_port);
+			goto cleanup;
+		}
 		edge_port->port = serial->port[i];
 		edge_port->edge_serial = edge_serial;
 		usb_set_serial_port_data(serial->port[i], edge_port);
+		edge_port->bUartMode = 0;	/* Default is RS232 */
 	}
 	
 	return 0;
+
+cleanup:
+	for (--i; i>=0; --i) {
+		edge_port = usb_get_serial_port_data(serial->port[i]);
+		edge_buf_free(edge_port->ep_out_buf);
+		kfree(edge_port);
+		usb_set_serial_port_data(serial->port[i], NULL);
+	}
+	kfree (edge_serial);
+	usb_set_serial_data(serial, NULL);
+	return -ENOMEM;
 }
 
 static void edge_shutdown (struct usb_serial *serial)
 {
 	int i;
+	struct edgeport_port *edge_port;
 
 	dbg ("%s", __FUNCTION__);
 
 	for (i=0; i < serial->num_ports; ++i) {
-		kfree (usb_get_serial_port_data(serial->port[i]));
+		edge_port = usb_get_serial_port_data(serial->port[i]);
+		if (edge_port) {
+			edge_buf_free(edge_port->ep_out_buf);
+			kfree(edge_port);
+		}
 		usb_set_serial_port_data(serial->port[i], NULL);
 	}
 	kfree (usb_get_serial_data(serial));
@@ -2577,6 +2805,185 @@
 }
 
 
+/* Circular Buffer */
+
+/*
+ * edge_buf_alloc
+ *
+ * Allocate a circular buffer and all associated memory.
+ */
+
+static struct edge_buf *edge_buf_alloc(unsigned int size)
+{
+	struct edge_buf *eb;
+
+
+	if (size == 0)
+		return NULL;
+
+	eb = (struct edge_buf *)kmalloc(sizeof(struct edge_buf), GFP_KERNEL);
+	if (eb == NULL)
+		return NULL;
+
+	eb->buf_buf = kmalloc(size, GFP_KERNEL);
+	if (eb->buf_buf == NULL) {
+		kfree(eb);
+		return NULL;
+	}
+
+	eb->buf_size = size;
+	eb->buf_get = eb->buf_put = eb->buf_buf;
+
+	return eb;
+}
+
+
+/*
+ * edge_buf_free
+ *
+ * Free the buffer and all associated memory.
+ */
+
+void edge_buf_free(struct edge_buf *eb)
+{
+	if (eb != NULL) {
+		if (eb->buf_buf != NULL)
+			kfree(eb->buf_buf);
+		kfree(eb);
+	}
+}
+
+
+/*
+ * edge_buf_clear
+ *
+ * Clear out all data in the circular buffer.
+ */
+
+static void edge_buf_clear(struct edge_buf *eb)
+{
+        if (eb != NULL)
+                eb->buf_get = eb->buf_put;
+                /* equivalent to a get of all data available */
+}
+
+
+/*
+ * edge_buf_data_avail
+ *
+ * Return the number of bytes of data available in the circular
+ * buffer.
+ */
+
+static unsigned int edge_buf_data_avail(struct edge_buf *eb)
+{
+	if (eb != NULL)
+		return ((eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size);
+	else
+		return 0;
+}
+
+
+/*
+ * edge_buf_space_avail
+ *
+ * Return the number of bytes of space available in the circular
+ * buffer.
+ */
+
+static unsigned int edge_buf_space_avail(struct edge_buf *eb)
+{
+	if (eb != NULL)
+		return ((eb->buf_size + eb->buf_get - eb->buf_put - 1) % eb->buf_size);
+	else
+		return 0;
+}
+
+
+/*
+ * edge_buf_put
+ *
+ * Copy data data from a user buffer and put it into the circular buffer.
+ * Restrict to the amount of space available.
+ *
+ * Return the number of bytes copied.
+ */
+
+static unsigned int edge_buf_put(struct edge_buf *eb, const char *buf,
+	unsigned int count)
+{
+	unsigned int len;
+
+
+	if (eb == NULL)
+		return 0;
+
+	len  = edge_buf_space_avail(eb);
+	if (count > len)
+		count = len;
+
+	if (count == 0)
+		return 0;
+
+	len = eb->buf_buf + eb->buf_size - eb->buf_put;
+	if (count > len) {
+		memcpy(eb->buf_put, buf, len);
+		memcpy(eb->buf_buf, buf+len, count - len);
+		eb->buf_put = eb->buf_buf + count - len;
+	} else {
+		memcpy(eb->buf_put, buf, count);
+		if (count < len)
+			eb->buf_put += count;
+		else /* count == len */
+			eb->buf_put = eb->buf_buf;
+	}
+
+	return count;
+}
+
+
+/*
+ * edge_buf_get
+ *
+ * Get data from the circular buffer and copy to the given buffer.
+ * Restrict to the amount of data available.
+ *
+ * Return the number of bytes copied.
+ */
+
+static unsigned int edge_buf_get(struct edge_buf *eb, char *buf,
+	unsigned int count)
+{
+	unsigned int len;
+
+
+	if (eb == NULL)
+		return 0;
+
+	len = edge_buf_data_avail(eb);
+	if (count > len)
+		count = len;
+
+	if (count == 0)
+		return 0;
+
+	len = eb->buf_buf + eb->buf_size - eb->buf_get;
+	if (count > len) {
+		memcpy(buf, eb->buf_get, len);
+		memcpy(buf+len, eb->buf_buf, count - len);
+		eb->buf_get = eb->buf_buf + count - len;
+	} else {
+		memcpy(buf, eb->buf_get, count);
+		if (count < len)
+			eb->buf_get += count;
+		else /* count == len */
+			eb->buf_get = eb->buf_buf;
+	}
+
+	return count;
+}
+
+
 static struct usb_serial_device_type edgeport_1port_device = {
 	.owner			= THIS_MODULE,
 	.name			= "Edgeport TI 1 port adapter",
@@ -2600,6 +3007,9 @@
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
 	.break_ctl		= edge_break,
+	.read_int_callback	= edge_interrupt_callback,
+	.read_bulk_callback	= edge_bulk_in_callback,
+	.write_bulk_callback	= edge_bulk_out_callback,
 };
 
 static struct usb_serial_device_type edgeport_2port_device = {
@@ -2625,6 +3035,9 @@
 	.write_room		= edge_write_room,
 	.chars_in_buffer	= edge_chars_in_buffer,
 	.break_ctl		= edge_break,
+	.read_int_callback	= edge_interrupt_callback,
+	.read_bulk_callback	= edge_bulk_in_callback,
+	.write_bulk_callback	= edge_bulk_out_callback,
 };
 
 
@@ -2667,6 +3080,12 @@
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debug enabled or not");
+
+module_param(low_latency, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(low_latency, "Low latency enabled or not");
+
+module_param(closing_wait, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs");
 
 module_param(ignore_cpu_rev, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(ignore_cpu_rev, "Ignore the cpu revision when connecting to a device");
diff -Nru a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
--- a/drivers/usb/serial/io_usbvend.h	2004-12-24 13:37:04 -08:00
+++ b/drivers/usb/serial/io_usbvend.h	2004-12-24 13:37:04 -08:00
@@ -619,7 +619,7 @@
 // Structure of header of download image in fw_down.h
 struct ti_i2c_image_header
 {
-	__u16	Length;
+	__le16	Length;
 	__u8	CheckSum;
 }__attribute__((packed));
 
diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
--- a/drivers/usb/serial/ipaq.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/serial/ipaq.c	2004-12-24 13:37:18 -08:00
@@ -77,9 +77,9 @@
 static void ipaq_close (struct usb_serial_port *port, struct file *filp);
 static int  ipaq_startup (struct usb_serial *serial);
 static void ipaq_shutdown (struct usb_serial *serial);
-static int ipaq_write(struct usb_serial_port *port, int from_user, const unsigned char *buf,
+static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf,
 		       int count);
-static int ipaq_write_bulk(struct usb_serial_port *port, int from_user, const unsigned char *buf,
+static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
 			   int count);
 static void ipaq_write_gather(struct usb_serial_port *port);
 static void ipaq_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
@@ -91,47 +91,448 @@
 
 static struct usb_device_id ipaq_id_table [] = {
 	/* The first entry is a placeholder for the insmod-specified device */
-	{ USB_DEVICE(COMPAQ_VENDOR_ID, COMPAQ_IPAQ_ID) },
-	{ USB_DEVICE(ASKEY_VENDOR_ID, ASKEY_PRODUCT_ID) },
-	{ USB_DEVICE(BCOM_VENDOR_ID, BCOM_0065_ID) },
-	{ USB_DEVICE(BCOM_VENDOR_ID, BCOM_0066_ID) },
-	{ USB_DEVICE(BCOM_VENDOR_ID, BCOM_0067_ID) },
-	{ USB_DEVICE(CASIO_VENDOR_ID, CASIO_2001_ID) },
-	{ USB_DEVICE(CASIO_VENDOR_ID, CASIO_EM500_ID) },
-	{ USB_DEVICE(COMPAQ_VENDOR_ID, COMPAQ_IPAQ_ID) },
-	{ USB_DEVICE(COMPAQ_VENDOR_ID, COMPAQ_0032_ID) },
-	{ USB_DEVICE(DELL_VENDOR_ID, DELL_AXIM_ID) },
-	{ USB_DEVICE(FSC_VENDOR_ID, FSC_LOOX_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_JORNADA_548_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_JORNADA_568_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_2016_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_2116_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_2216_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_3016_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_3116_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_3216_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_4016_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_4116_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_4216_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_5016_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_5116_ID) },
-	{ USB_DEVICE(HP_VENDOR_ID, HP_5216_ID) },
-	{ USB_DEVICE(LINKUP_VENDOR_ID, LINKUP_PRODUCT_ID) },
-	{ USB_DEVICE(MICROSOFT_VENDOR_ID, MICROSOFT_00CE_ID) },
-	{ USB_DEVICE(PORTATEC_VENDOR_ID, PORTATEC_PRODUCT_ID) },
-	{ USB_DEVICE(ROVER_VENDOR_ID, ROVER_P5_ID) },
-	{ USB_DEVICE(SAGEM_VENDOR_ID, SAGEM_WIRELESS_ID) },
-	{ USB_DEVICE(SOCKET_VENDOR_ID, SOCKET_PRODUCT_ID) },
-	{ USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_ID) },
-	{ USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_E310_ID) },
-	{ USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_E740_ID) },
-	{ USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_E335_ID) },
-	{ USB_DEVICE(HTC_VENDOR_ID, HTC_PRODUCT_ID) },
-	{ USB_DEVICE(HTC_VENDOR_ID, HTC_HIMALAYA_ID) },
-	{ USB_DEVICE(NEC_VENDOR_ID, NEC_PRODUCT_ID) },
-	{ USB_DEVICE(ASUS_VENDOR_ID, ASUS_A600_PRODUCT_ID) },
-	{ USB_DEVICE(ASUS_VENDOR_ID, ASUS_A620_PRODUCT_ID) },
-	{ }					/* Terminating entry */
+	{ USB_DEVICE(0x049F, 0x0003) },
+	{ USB_DEVICE(0x1690, 0x0601) }, /* Askey USB Sync */
+	{ USB_DEVICE(0x0960, 0x0065) }, /* BCOM USB Sync 0065 */
+	{ USB_DEVICE(0x0960, 0x0066) }, /* BCOM USB Sync 0066 */
+	{ USB_DEVICE(0x0960, 0x0067) }, /* BCOM USB Sync 0067 */
+	{ USB_DEVICE(0x07CF, 0x2001) }, /* CASIO USB Sync 2001 */
+	{ USB_DEVICE(0x07CF, 0x2002) }, /* CASIO USB Sync 2002 */
+	{ USB_DEVICE(0x07CF, 0x2003) }, /* CASIO USB Sync 2003 */
+	{ USB_DEVICE(0x049F, 0x0003) }, /* Compaq iPAQ USB Sync */
+	{ USB_DEVICE(0x049F, 0x0032) }, /* Compaq iPAQ USB Sync */
+	{ USB_DEVICE(0x413C, 0x4001) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x413C, 0x4002) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x413C, 0x4003) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x413C, 0x4004) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x413C, 0x4005) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x413C, 0x4006) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x413C, 0x4007) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x413C, 0x4008) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */
+	{ USB_DEVICE(0x03F0, 0x1016) }, /* HP USB Sync */
+	{ USB_DEVICE(0x03F0, 0x1116) }, /* HP USB Sync 1611 */
+	{ USB_DEVICE(0x03F0, 0x1216) }, /* HP USB Sync 1612 */
+	{ USB_DEVICE(0x03F0, 0x2016) }, /* HP USB Sync 1620 */
+	{ USB_DEVICE(0x03F0, 0x2116) }, /* HP USB Sync 1621 */
+	{ USB_DEVICE(0x03F0, 0x2216) }, /* HP USB Sync 1622 */
+	{ USB_DEVICE(0x03F0, 0x3016) }, /* HP USB Sync 1630 */
+	{ USB_DEVICE(0x03F0, 0x3116) }, /* HP USB Sync 1631 */
+	{ USB_DEVICE(0x03F0, 0x3216) }, /* HP USB Sync 1632 */
+	{ USB_DEVICE(0x03F0, 0x4016) }, /* HP USB Sync 1640 */
+	{ USB_DEVICE(0x03F0, 0x4116) }, /* HP USB Sync 1641 */
+	{ USB_DEVICE(0x03F0, 0x4216) }, /* HP USB Sync 1642 */
+	{ USB_DEVICE(0x03F0, 0x5016) }, /* HP USB Sync 1650 */
+	{ USB_DEVICE(0x03F0, 0x5116) }, /* HP USB Sync 1651 */
+	{ USB_DEVICE(0x03F0, 0x5216) }, /* HP USB Sync 1652 */
+	{ USB_DEVICE(0x094B, 0x0001) }, /* Linkup Systems USB Sync */
+	{ USB_DEVICE(0x045E, 0x0400) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0401) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0402) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0403) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0404) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0405) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0406) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0407) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0408) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0409) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x040A) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x040B) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x040C) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x040D) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x040E) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x040F) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0410) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0411) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0412) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0413) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0414) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0415) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0416) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0417) }, /* Windows Powered Pocket PC 2002 */
+	{ USB_DEVICE(0x045E, 0x0432) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0433) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0434) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0435) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0436) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0437) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0438) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0439) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x043A) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x043B) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x043C) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x043D) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x043E) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x043F) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0440) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0441) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0442) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0443) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0444) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0445) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0446) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0447) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0448) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0449) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x044A) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x044B) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x044C) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x044D) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x044E) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x044F) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0450) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0451) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0452) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0453) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0454) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0455) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0456) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0457) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0458) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0459) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x045A) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x045B) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x045C) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x045D) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x045E) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x045F) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0460) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0461) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0462) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0463) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0464) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0465) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0466) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0467) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0468) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0469) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x046A) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x046B) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x046C) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x046D) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x046E) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x046F) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0470) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0471) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0472) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0473) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0474) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0475) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0476) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0477) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0478) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x0479) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x047A) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x047B) }, /* Windows Powered Pocket PC 2003 */
+	{ USB_DEVICE(0x045E, 0x04C8) }, /* Windows Powered Smartphone 2002 */
+	{ USB_DEVICE(0x045E, 0x04C9) }, /* Windows Powered Smartphone 2002 */
+	{ USB_DEVICE(0x045E, 0x04CA) }, /* Windows Powered Smartphone 2002 */
+	{ USB_DEVICE(0x045E, 0x04CB) }, /* Windows Powered Smartphone 2002 */
+	{ USB_DEVICE(0x045E, 0x04CC) }, /* Windows Powered Smartphone 2002 */
+	{ USB_DEVICE(0x045E, 0x04CD) }, /* Windows Powered Smartphone 2002 */
+	{ USB_DEVICE(0x045E, 0x04CE) }, /* Windows Powered Smartphone 2002 */
+	{ USB_DEVICE(0x045E, 0x04D7) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04D8) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04D9) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04DA) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04DB) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04DC) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04DD) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04DE) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04DF) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E0) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E1) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E2) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E3) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E4) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E5) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E6) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E7) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E8) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04E9) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x045E, 0x04EA) }, /* Windows Powered Smartphone 2003 */
+	{ USB_DEVICE(0x0961, 0x0010) }, /* Portatec USB Sync */
+	{ USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */
+	{ USB_DEVICE(0x0104, 0x00BE) }, /* Socket USB Sync */
+	{ USB_DEVICE(0x0930, 0x0700) }, /* TOSHIBA USB Sync 0700 */
+	{ USB_DEVICE(0x0930, 0x0705) }, /* TOSHIBA Pocket PC e310 */
+	{ USB_DEVICE(0x0930, 0x0707) }, /* TOSHIBA Pocket PC e330 Series */
+	{ USB_DEVICE(0x0930, 0x0708) }, /* TOSHIBA Pocket PC e350 Series */
+	{ USB_DEVICE(0x0930, 0x0706) }, /* TOSHIBA Pocket PC e740 */
+	{ USB_DEVICE(0x0930, 0x0709) }, /* TOSHIBA Pocket PC e750 Series */
+	{ USB_DEVICE(0x0930, 0x070A) }, /* TOSHIBA Pocket PC e400 Series */
+	{ USB_DEVICE(0x0930, 0x070B) }, /* TOSHIBA Pocket PC e800 Series */
+	{ USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A04) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A05) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A06) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A07) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A08) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A09) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A0A) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A0B) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A0C) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A0D) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A0E) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A0F) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A10) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A11) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A12) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A13) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A14) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A15) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A16) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A17) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A18) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A19) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A1A) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A1B) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A1C) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A1D) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A1E) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A1F) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A20) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A21) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A22) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A23) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A24) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A25) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A26) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A27) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A28) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A29) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A2A) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A2B) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A2C) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A2D) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A2E) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A2F) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A30) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A31) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A32) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A33) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A34) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A35) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A36) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A37) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A38) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A39) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A3A) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A3B) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A3C) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A3D) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A3E) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A3F) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A40) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A41) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A42) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A43) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A44) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A45) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A46) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A47) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A48) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A49) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A4A) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A4B) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A4C) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A4D) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A4E) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A4F) }, /* PocketPC USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A50) }, /* HTC SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A51) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A52) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A53) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A54) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A55) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A56) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A57) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A58) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A59) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A5A) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A5B) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A5C) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A5D) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A5E) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A5F) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A60) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A61) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A62) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A63) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A64) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A65) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A66) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A67) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A68) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A69) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A6A) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A6B) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A6C) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A6D) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A6E) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A6F) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A70) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A71) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A72) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A73) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A74) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A75) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A76) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A77) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A78) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A79) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A7A) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A7B) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A7C) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A7D) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A7E) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A7F) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A80) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A81) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A82) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A83) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A84) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A85) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A86) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A87) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A88) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A89) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A8A) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A8B) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A8C) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A8D) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A8E) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A8F) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A90) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A91) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A92) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A93) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A94) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A95) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A96) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A97) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A98) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A99) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A9A) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A9B) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A9C) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A9D) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A9E) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0BB4, 0x0A9F) }, /* SmartPhone USB Sync */
+	{ USB_DEVICE(0x0409, 0x00D5) }, /* NEC USB Sync */
+	{ USB_DEVICE(0x0409, 0x00D6) }, /* NEC USB Sync */
+	{ USB_DEVICE(0x0409, 0x00D7) }, /* NEC USB Sync */
+	{ USB_DEVICE(0x0409, 0x8024) }, /* NEC USB Sync */
+	{ USB_DEVICE(0x0409, 0x8025) }, /* NEC USB Sync */
+	{ USB_DEVICE(0x04A4, 0x0014) }, /* Hitachi USB Sync */
+	{ USB_DEVICE(0x0BF8, 0x1001) }, /* Fujitsu Siemens Computers USB Sync */
+	{ USB_DEVICE(0x0F98, 0x0201) }, /* Cyberbank USB Sync */
+	{ USB_DEVICE(0x0502, 0x16E1) }, /* Acer n10 Handheld USB Sync */
+	{ USB_DEVICE(0x0502, 0x16E3) }, /* Acer n30 Handheld USB Sync */
+	{ USB_DEVICE(0x0502, 0x16E2) }, /* Acer n20 Handheld USB Sync */
+	{ USB_DEVICE(0x0502, 0x1631) }, /* c10 Series */
+	{ USB_DEVICE(0x0502, 0x1632) }, /* c20 Series */
+	{ USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */
+	{ USB_DEVICE(0x0B05, 0x420F) }, /* ASUS USB Sync */
+	{ USB_DEVICE(0x0B05, 0x4200) }, /* ASUS USB Sync */
+	{ USB_DEVICE(0x0B05, 0x4201) }, /* ASUS USB Sync */
+	{ USB_DEVICE(0x0B05, 0x4202) }, /* ASUS USB Sync */
+	{ USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */
+	{ USB_DEVICE(0x0C8E, 0x6000) }, /* Cesscom Luxian Series */
+	{ USB_DEVICE(0x04AD, 0x0301) }, /* USB Sync 0301 */
+	{ USB_DEVICE(0x04AD, 0x0302) }, /* USB Sync 0302 */
+	{ USB_DEVICE(0x04AD, 0x0303) }, /* USB Sync 0303 */
+	{ USB_DEVICE(0x1066, 0x0300) }, /* E-TEN P3XX Pocket PC */
+	{ USB_DEVICE(0x1066, 0x0500) }, /* E-TEN P5XX Pocket PC */
+	{ USB_DEVICE(0x1066, 0x0600) }, /* E-TEN P6XX Pocket PC */
+	{ USB_DEVICE(0x1066, 0x0700) }, /* E-TEN P7XX Pocket PC */
+	{ USB_DEVICE(0x1066, 0x00CE) }, /* E-TEN USB Sync */
+	{ USB_DEVICE(0x0F4E, 0x0200) }, /* Freedom Scientific USB Sync */
+	{ USB_DEVICE(0x04C5, 0x1058) }, /* FUJITSU USB Sync */
+	{ USB_DEVICE(0x04C5, 0x1079) }, /* FUJITSU USB Sync */
+	{ USB_DEVICE(0x067E, 0x1001) }, /* Intermec Mobile Computer */
+	{ USB_DEVICE(0x04f1, 0x3011) }, /* JVC USB Sync */
+	{ USB_DEVICE(0x04F1, 0x3012) }, /* JVC USB Sync */
+	{ USB_DEVICE(0x3708, 0x20CE) }, /* Legend USB Sync */
+	{ USB_DEVICE(0x3708, 0x21CE) }, /* Lenovo USB Sync */
+	{ USB_DEVICE(0x043E, 0x9C01) }, /* LGE USB Sync */
+	{ USB_DEVICE(0x04DA, 0x2500) }, /* Panasonic USB Sync */
+	{ USB_DEVICE(0x3340, 0x0B1C) }, /* Generic PPC StrongARM */
+	{ USB_DEVICE(0x3340, 0x0E3A) }, /* Generic PPC USB Sync */
+	{ USB_DEVICE(0x3340, 0x0F3A) }, /* Generic SmartPhone USB Sync */
+	{ USB_DEVICE(0x3340, 0x0F1C) }, /* Itautec USB Sync */
+	{ USB_DEVICE(0x3340, 0x1326) }, /* Itautec USB Sync */
+	{ USB_DEVICE(0x3340, 0x3326) }, /* MEDION Winodws Moble USB Sync */
+	{ USB_DEVICE(0x3340, 0x0326) }, /* Mio DigiWalker 338 */
+	{ USB_DEVICE(0x3340, 0x0426) }, /* Mio DigiWalker 338 */
+	{ USB_DEVICE(0x3340, 0x011C) }, /* Mio DigiWalker PPC StrongARM */
+	{ USB_DEVICE(0x3340, 0x053A) }, /* Mio DigiWalker SmartPhone USB Sync */
+	{ USB_DEVICE(0x3340, 0x043A) }, /* Mio DigiWalker USB Sync */
+	{ USB_DEVICE(0x3340, 0x071C) }, /* MiTAC USB Sync */
+	{ USB_DEVICE(0x3340, 0x051C) }, /* MiTAC USB Sync 528 */
+	{ USB_DEVICE(0x3340, 0x2326) }, /* Vobis USB Sync */
+	{ USB_DEVICE(0x3340, 0x191C) }, /* YAKUMO USB Sync */
+	{ USB_DEVICE(0x4113, 0x0210) }, /* Mobile Media Technology USB Sync */
+	{ USB_DEVICE(0x4113, 0x0211) }, /* Mobile Media Technology USB Sync */
+	{ USB_DEVICE(0x4113, 0x0400) }, /* Mobile Media Technology USB Sync */
+	{ USB_DEVICE(0x4113, 0x0410) }, /* Mobile Media Technology USB Sync */
+	{ USB_DEVICE(0x0CAD, 0x9001) }, /* Motorola PowerPad Pocket PC Device */
+	{ USB_DEVICE(0x0C44, 0x03A2) }, /* Motorola iDEN Smartphone */
+	{ USB_DEVICE(0x04E8, 0x6611) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x04E8, 0x6613) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x04E8, 0x6615) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x04E8, 0x6617) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x04E8, 0x6619) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x04E8, 0x661B) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */
+	{ USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */
+	{ USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */
+	{ USB_DEVICE(0x04E8, 0x5F03) }, /* Samsung NEXiO USB Sync */
+	{ USB_DEVICE(0x04E8, 0x5F04) }, /* Samsung NEXiO USB Sync */
+	{ USB_DEVICE(0x04E8, 0x662E) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x04E8, 0x6630) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x04E8, 0x6632) }, /* Samsung MITs USB Sync */
+	{ USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */
+	{ USB_DEVICE(0x05E0, 0x2000) }, /* Symbol USB Sync */
+	{ USB_DEVICE(0x05E0, 0x2001) }, /* Symbol USB Sync 0x2001 */
+	{ USB_DEVICE(0x05E0, 0x2002) }, /* Symbol USB Sync 0x2002 */
+	{ USB_DEVICE(0x05E0, 0x2003) }, /* Symbol USB Sync 0x2003 */
+	{ USB_DEVICE(0x05E0, 0x2004) }, /* Symbol USB Sync 0x2004 */
+	{ USB_DEVICE(0x05E0, 0x2005) }, /* Symbol USB Sync 0x2005 */
+	{ USB_DEVICE(0x05E0, 0x2006) }, /* Symbol USB Sync 0x2006 */
+	{ USB_DEVICE(0x05E0, 0x2007) }, /* Symbol USB Sync 0x2007 */
+	{ USB_DEVICE(0x05E0, 0x2008) }, /* Symbol USB Sync 0x2008 */
+	{ USB_DEVICE(0x05E0, 0x2009) }, /* Symbol USB Sync 0x2009 */
+	{ USB_DEVICE(0x05E0, 0x200A) }, /* Symbol USB Sync 0x200A */
+	{ USB_DEVICE(0x1182, 0x1388) }, /* VES USB Sync */
+	{ USB_DEVICE(0x0543, 0x0ED9) }, /* ViewSonic Color Pocket PC V35 */
+	{ USB_DEVICE(0x0543, 0x1527) }, /* ViewSonic Color Pocket PC V36 */
+	{ USB_DEVICE(0x0543, 0x1529) }, /* ViewSonic Color Pocket PC V37 */
+	{ USB_DEVICE(0x0543, 0x152B) }, /* ViewSonic Color Pocket PC V38 */
+	{ USB_DEVICE(0x0543, 0x152E) }, /* ViewSonic Pocket PC */
+	{ USB_DEVICE(0x0543, 0x1921) }, /* ViewSonic Communicator Pocket PC */
+	{ USB_DEVICE(0x0543, 0x1922) }, /* ViewSonic Smartphone */
+	{ USB_DEVICE(0x0543, 0x1923) }, /* ViewSonic Pocket PC V30 */
+	{ USB_DEVICE(0x0536, 0x01A0) }, /* HHP PDT */
+	{ USB_DEVICE(0x099E, 0x0052) }, /* Trimble GeoExplorer */
+	{ USB_DEVICE(0x099E, 0x4000) }, /* TDS Data Collector */
+	{ USB_DEVICE(0x0FB8, 0x3001) }, /* Wistron USB Sync */
+	{ USB_DEVICE(0x0FB8, 0x3002) }, /* Wistron USB Sync */
+	{ USB_DEVICE(0x0FB8, 0x3003) }, /* Wistron USB Sync */
+	{ USB_DEVICE(0x0FB8, 0x4001) }, /* Wistron USB Sync */
+	{ USB_DEVICE(0x11D9, 0x1003) }, /* Rugged Pocket PC 2003 */
+	{ USB_DEVICE(0x11D9, 0x1002) }, /* Rugged Pocket PC 2003 */
+	{ USB_DEVICE(0x22B8, 0x4204) }, /* Motorola MPx200 Smartphone */
+	{ USB_DEVICE(0x22B8, 0x4214) }, /* Motorola MPc GSM */
+	{ USB_DEVICE(0x22B8, 0x4224) }, /* Motorola MPx220 Smartphone */
+	{ USB_DEVICE(0x22B8, 0x4234) }, /* Motorola MPc CDMA */
+	{ USB_DEVICE(0x22B8, 0x4244) }, /* Motorola MPx100 Smartphone */
+	{ USB_DEVICE(0x1231, 0xCE01) }, /* USB Sync 03 */
+	{ USB_DEVICE(0x1231, 0xCE02) }, /* USB Sync 03 */
+	{ }                             /* Terminating entry */
 };
 
 MODULE_DEVICE_TABLE (usb, ipaq_id_table);
@@ -288,8 +689,8 @@
 	/*
 	 * shut down bulk read and write
 	 */
-	usb_unlink_urb(port->write_urb);
-	usb_unlink_urb(port->read_urb);
+	usb_kill_urb(port->write_urb);
+	usb_kill_urb(port->read_urb);
 	ipaq_destroy_lists(port);
 	kfree(priv);
 	usb_set_serial_port_data(port, NULL);
@@ -339,7 +740,7 @@
 	return;
 }
 
-static int ipaq_write(struct usb_serial_port *port, int from_user, const unsigned char *buf,
+static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf,
 		       int count)
 {
 	const unsigned char	*current_position = buf;
@@ -350,7 +751,7 @@
 
 	while (count > 0) {
 		transfer_size = min(count, PACKET_SIZE);
-		if (ipaq_write_bulk(port, from_user, current_position, transfer_size)) {
+		if (ipaq_write_bulk(port, current_position, transfer_size)) {
 			break;
 		}
 		current_position += transfer_size;
@@ -362,7 +763,7 @@
 	return bytes_sent;
 } 
 
-static int ipaq_write_bulk(struct usb_serial_port *port, int from_user, const unsigned char *buf,
+static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
 			   int count)
 {
 	struct ipaq_private	*priv = usb_get_serial_port_data(port);
@@ -387,12 +788,7 @@
 		return -EAGAIN;
 	}
 
-	if (from_user) {
-		if (copy_from_user(pkt->data, buf, count))
-			return -EFAULT;
-	} else {
-		memcpy(pkt->data, buf, count);
-	}
+	memcpy(pkt->data, buf, count);
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, pkt->data);
 
 	pkt->len = count;
@@ -419,9 +815,8 @@
 	struct ipaq_private	*priv = usb_get_serial_port_data(port);
 	struct usb_serial	*serial = port->serial;
 	int			count, room;
-	struct ipaq_packet	*pkt;
+	struct ipaq_packet	*pkt, *tmp;
 	struct urb		*urb = port->write_urb;
-	struct list_head	*tmp;
 
 	if (urb->status == -EINPROGRESS) {
 		/* Should never happen */
@@ -429,9 +824,7 @@
 		return;
 	}
 	room = URBDATA_SIZE;
-	for (tmp = priv->queue.next; tmp != &priv->queue;) {
-		pkt = list_entry(tmp, struct ipaq_packet, list);
-		tmp = tmp->next;
+	list_for_each_entry_safe(pkt, tmp, &priv->queue, list) {
 		count = min(room, (int)(pkt->len - pkt->written));
 		memcpy(urb->transfer_buffer + (URBDATA_SIZE - room),
 		       pkt->data + pkt->written, count);
@@ -503,22 +896,16 @@
 static void ipaq_destroy_lists(struct usb_serial_port *port)
 {
 	struct ipaq_private	*priv = usb_get_serial_port_data(port);
-	struct list_head	*tmp;
-	struct ipaq_packet	*pkt;
+	struct ipaq_packet	*pkt, *tmp;
 
-	for (tmp = priv->queue.next; tmp != &priv->queue;) {
-		pkt = list_entry(tmp, struct ipaq_packet, list);
-		tmp = tmp->next;
+	list_for_each_entry_safe(pkt, tmp, &priv->queue, list) {
 		kfree(pkt->data);
 		kfree(pkt);
 	}
-	for (tmp = priv->freelist.next; tmp != &priv->freelist;) {
-		pkt = list_entry(tmp, struct ipaq_packet, list);
-		tmp = tmp->next;
+	list_for_each_entry_safe(pkt, tmp, &priv->freelist, list) {
 		kfree(pkt->data);
 		kfree(pkt);
 	}
-	return;
 }
 
 
diff -Nru a/drivers/usb/serial/ipaq.h b/drivers/usb/serial/ipaq.h
--- a/drivers/usb/serial/ipaq.h	2004-12-24 13:36:17 -08:00
+++ b/drivers/usb/serial/ipaq.h	2004-12-24 13:36:17 -08:00
@@ -14,81 +14,6 @@
 #ifndef __LINUX_USB_SERIAL_IPAQ_H
 #define __LINUX_USB_SERIAL_IPAQ_H
 
-#define ASKEY_VENDOR_ID		0x1690
-#define ASKEY_PRODUCT_ID	0x0601
-
-#define BCOM_VENDOR_ID		0x0960
-#define BCOM_0065_ID		0x0065
-#define BCOM_0066_ID		0x0066
-#define BCOM_0067_ID		0x0067
-
-#define CASIO_VENDOR_ID		0x07cf
-#define CASIO_2001_ID		0x2001
-#define CASIO_EM500_ID		0x2002
-
-#define COMPAQ_VENDOR_ID	0x049f
-#define COMPAQ_IPAQ_ID		0x0003
-#define COMPAQ_0032_ID		0x0032
-
-#define DELL_VENDOR_ID		0x413c
-#define DELL_AXIM_ID		0x4001
-
-#define FSC_VENDOR_ID		0x0bf8
-#define FSC_LOOX_ID		0x1001
-
-#define HP_VENDOR_ID		0x03f0
-#define HP_JORNADA_548_ID	0x1016
-#define HP_JORNADA_568_ID	0x1116
-#define HP_2016_ID		0x2016
-#define HP_2116_ID		0x2116
-#define HP_2216_ID		0x2216
-#define HP_3016_ID		0x3016
-#define HP_3116_ID		0x3116
-#define HP_3216_ID		0x3216
-#define HP_4016_ID		0x4016
-#define HP_4116_ID		0x4116
-#define HP_4216_ID		0x4216
-#define HP_5016_ID		0x5016
-#define HP_5116_ID		0x5116
-#define HP_5216_ID		0x5216
-
-#define LINKUP_VENDOR_ID	0x094b
-#define LINKUP_PRODUCT_ID	0x0001
-
-#define MICROSOFT_VENDOR_ID	0x045e
-#define MICROSOFT_00CE_ID	0x00ce
-
-#define PORTATEC_VENDOR_ID	0x0961
-#define PORTATEC_PRODUCT_ID	0x0010
-
-#define ROVER_VENDOR_ID		0x047b
-#define ROVER_P5_ID		0x3000
-
-#define SAGEM_VENDOR_ID		0x5e04
-#define SAGEM_WIRELESS_ID	0xce00
-
-#define SOCKET_VENDOR_ID	0x0104
-#define SOCKET_PRODUCT_ID	0x00be
-
-#define TOSHIBA_VENDOR_ID	0x0930
-#define TOSHIBA_PRODUCT_ID	0x0700
-#define TOSHIBA_E310_ID		0x0705
-#define TOSHIBA_E740_ID		0x0706
-#define TOSHIBA_E335_ID		0x0707
-
-#define HTC_VENDOR_ID		0x0bb4
-#define HTC_PRODUCT_ID		0x00ce
-#define HTC_HIMALAYA_ID		0x0a02
-
-#define NEC_VENDOR_ID		0x0409
-#define NEC_PRODUCT_ID		0x00d5
-
-#define ASUS_VENDOR_ID		0x0b05
-#define ASUS_A600_PRODUCT_ID	0x4201
-
-#define ASUS_VENDOR_ID		0x0b05
-#define ASUS_A620_PRODUCT_ID	0x4202
-
 /*
  * Since we can't queue our bulk write urbs (don't know why - it just
  * doesn't work), we can send down only one write urb at a time. The simplistic
diff -Nru a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/usb/serial/ipw.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,491 @@
+/*
+ * IPWireless 3G UMTS TDD Modem driver (USB connected)
+ *
+ *   Copyright (C) 2004 Roelf Diedericks <roelfd@inet.co.za>
+ *   Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.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.
+ *
+ * All information about the device was acquired using SnoopyPro
+ * on MSFT's O/S, and examing the MSFT drivers' debug output 
+ * (insanely left _on_ in the enduser version)
+ *
+ * It was written out of frustration with the IPWireless USB modem
+ * supplied by Axity3G/Sentech South Africa not supporting
+ * Linux whatsoever.
+ *
+ * Nobody provided any proprietary information that was not already 
+ * available for this device.
+ * 
+ * The modem adheres to the "3GPP TS  27.007 AT command set for 3G 
+ * User Equipment (UE)" standard, available from 
+ * http://www.3gpp.org/ftp/Specs/html-info/27007.htm
+ *
+ * The code was only tested the IPWireless handheld modem distributed
+ * in South Africa by Sentech.
+ * 
+ * It may work for Woosh Inc in .nz too, as it appears they use the
+ * same kit.
+ *
+ * There is still some work to be done in terms of handling 
+ * DCD, DTR, RTS, CTS which are currently faked.
+ * It's good enough for PPP at this point. It's based off all kinds of
+ * code found in usb/serial and usb/class
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <linux/usb.h>
+#include <linux/usb.h>
+#include <asm/uaccess.h>
+#include "usb-serial.h"
+
+/*
+ * Version Information
+ */
+#define DRIVER_VERSION	"v0.3"
+#define DRIVER_AUTHOR	"Roelf Diedericks"
+#define DRIVER_DESC	"IPWireless tty driver"
+
+#define IPW_TTY_MAJOR	240	/* real device node major id, experimental range */
+#define IPW_TTY_MINORS	256	/* we support 256 devices, dunno why, it'd be insane :) */
+
+#define USB_IPW_MAGIC	0x6d02	/* magic number for ipw struct */
+
+
+/* Message sizes */
+#define EVENT_BUFFER_SIZE	0xFF
+#define CHAR2INT16(c1,c0)	(((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff))
+#define NUM_BULK_URBS		24
+#define NUM_CONTROL_URBS	16
+
+/* vendor/product pairs that are known work with this driver*/
+#define IPW_VID		0x0bc3
+#define IPW_PID		0x0001
+
+
+/* Vendor commands: */
+
+/* baud rates */
+enum {
+	ipw_sio_b256000 = 0x000e,
+	ipw_sio_b128000 = 0x001d,
+	ipw_sio_b115200 = 0x0020,
+	ipw_sio_b57600  = 0x0040,
+	ipw_sio_b56000  = 0x0042,
+	ipw_sio_b38400  = 0x0060,
+	ipw_sio_b19200  = 0x00c0,
+	ipw_sio_b14400  = 0x0100,
+	ipw_sio_b9600   = 0x0180,
+	ipw_sio_b4800   = 0x0300,
+	ipw_sio_b2400   = 0x0600,
+	ipw_sio_b1200   = 0x0c00,
+	ipw_sio_b600    = 0x1800
+};
+
+/* data bits */
+#define ipw_dtb_7		0x700
+#define ipw_dtb_8		0x810	// ok so the define is misleading, I know, but forces 8,n,1
+					// I mean, is there a point to any other setting these days? :)	
+
+/* usb control request types : */
+#define IPW_SIO_RXCTL		0x00	// control bulk rx channel transmissions, value=1/0 (on/off)
+#define IPW_SIO_SET_BAUD	0x01	// set baud, value=requested ipw_sio_bxxxx
+#define IPW_SIO_SET_LINE	0x03	// set databits, parity. value=ipw_dtb_x
+#define IPW_SIO_SET_PIN		0x03	// set/clear dtr/rts value=ipw_pin_xxx
+#define IPW_SIO_POLL		0x08	// get serial port status byte, call with value=0
+#define IPW_SIO_INIT		0x11	// initializes ? value=0 (appears as first thing todo on open)
+#define IPW_SIO_PURGE		0x12	// purge all transmissions?, call with value=numchar_to_purge
+#define IPW_SIO_HANDFLOW	0x13	// set xon/xoff limits value=0, and a buffer of 0x10 bytes
+#define IPW_SIO_SETCHARS	0x13	// set the flowcontrol special chars, value=0, buf=6 bytes, 
+					// last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13
+
+/* values used for request IPW_SIO_SET_PIN */
+#define IPW_PIN_SETDTR		0x101
+#define IPW_PIN_SETRTS		0x202
+#define IPW_PIN_CLRDTR		0x100
+#define IPW_PIN_CLRRTS		0x200 // unconfirmed
+
+/* values used for request IPW_SIO_RXCTL */
+#define IPW_RXBULK_ON		1
+#define IPW_RXBULK_OFF		0
+
+/* various 16 byte hardcoded transferbuffers used by flow control */
+#define IPW_BYTES_FLOWINIT	{ 0x01, 0, 0, 0, 0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+
+/* Interpretation of modem status lines */
+/* These need sorting out by individually connecting pins and checking
+ * results. FIXME!
+ * When data is being sent we see 0x30 in the lower byte; this must
+ * contain DSR and CTS ...
+ */
+#define IPW_DSR			((1<<4) | (1<<5))
+#define IPW_CTS			((1<<5) | (1<<4))
+
+#define IPW_WANTS_TO_SEND	0x30
+//#define IPW_DTR			/* Data Terminal Ready */
+//#define IPW_CTS			/* Clear To Send */
+//#define IPW_CD			/* Carrier Detect */
+//#define IPW_DSR			/* Data Set Ready */
+//#define IPW_RxD			/* Receive pin */
+
+//#define IPW_LE
+//#define IPW_RTS		
+//#define IPW_ST		
+//#define IPW_SR		
+//#define IPW_RI			/* Ring Indicator */
+
+static struct usb_device_id usb_ipw_ids[] = {
+	{ USB_DEVICE(IPW_VID, IPW_PID) },
+	{ },
+};
+
+MODULE_DEVICE_TABLE(usb, usb_ipw_ids);
+
+static struct usb_driver usb_ipw_driver = {
+	.owner =	THIS_MODULE,
+	.name =		"ipwtty",
+	.probe =	usb_serial_probe,
+	.disconnect =	usb_serial_disconnect,
+	.id_table =	usb_ipw_ids,
+};
+
+static int debug;
+
+static void ipw_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
+{
+	struct usb_serial_port *port = urb->context;
+	unsigned char *data = urb->transfer_buffer;
+	struct tty_struct *tty;
+	int i;
+	int result;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	if (urb->status) {
+		dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
+		return;
+	}
+
+	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
+
+	tty = port->tty;
+	if (tty && urb->actual_length) {
+		for (i = 0; i < urb->actual_length ; ++i) {
+			/* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */
+			if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
+				tty_flip_buffer_push(tty);
+			}
+			/* this doesn't actually push the data through unless tty->low_latency is set */
+			tty_insert_flip_char(tty, data[i], 0);
+		}
+		tty_flip_buffer_push(tty);
+	}
+
+	/* Continue trying to always read  */
+	usb_fill_bulk_urb (port->read_urb, port->serial->dev,
+			   usb_rcvbulkpipe(port->serial->dev,
+					   port->bulk_in_endpointAddress),
+			   port->read_urb->transfer_buffer,
+			   port->read_urb->transfer_buffer_length,
+			   ipw_read_bulk_callback, port);
+	result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
+	if (result)
+		dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
+	return;
+}
+
+static int ipw_open(struct usb_serial_port *port, struct file *filp)
+{
+	struct usb_device *dev = port->serial->dev;
+	u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT;
+	u8 *buf_flow_init;
+	int result;
+
+	dbg("%s", __FUNCTION__);
+
+	buf_flow_init = kmalloc(16, GFP_KERNEL);
+	if (!buf_flow_init)
+		return -ENOMEM;
+	memcpy(buf_flow_init, buf_flow_static, 16);
+
+	if (port->tty)
+		port->tty->low_latency = 1;
+
+	/* --1: Tell the modem to initialize (we think) From sniffs this is always the
+	 * first thing that gets sent to the modem during opening of the device */
+	dbg("%s: Sending SIO_INIT (we guess)",__FUNCTION__);
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev,0),
+				 IPW_SIO_INIT,
+				 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 0,
+				 0, /* index */
+				 NULL,
+				 0,
+				 100*HZ);
+	if (result < 0)
+		dev_err(&port->dev, "Init of modem failed (error = %d)", result);
+
+	/* reset the bulk pipes */
+	usb_clear_halt(dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress));
+	usb_clear_halt(dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress));
+
+	/*--2: Start reading from the device */	
+	dbg("%s: setting up bulk read callback",__FUNCTION__);
+	usb_fill_bulk_urb(port->read_urb, dev,
+			  usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
+			  port->bulk_in_buffer,
+			  port->bulk_in_size,
+			  ipw_read_bulk_callback, port);
+	result = usb_submit_urb(port->read_urb, GFP_KERNEL);
+	if (result < 0)
+		dbg("%s - usb_submit_urb(read bulk) failed with status %d", __FUNCTION__, result);
+
+	/*--3: Tell the modem to open the floodgates on the rx bulk channel */
+	dbg("%s:asking modem for RxRead (RXBULK_ON)",__FUNCTION__);
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				 IPW_SIO_RXCTL,
+				 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 IPW_RXBULK_ON,
+				 0, /* index */
+				 NULL,
+				 0,
+				 100*HZ);
+	if (result < 0) 
+		dev_err(&port->dev, "Enabling bulk RxRead failed (error = %d)", result);
+
+	/*--4: setup the initial flowcontrol */
+	dbg("%s:setting init flowcontrol (%s)",__FUNCTION__,buf_flow_init);
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				 IPW_SIO_HANDFLOW,
+				 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 0,
+				 0,
+				 buf_flow_init,
+				 0x10,
+				 200*HZ);
+	if (result < 0)
+		dev_err(&port->dev, "initial flowcontrol failed (error = %d)", result);
+
+
+	/*--5: raise the dtr */
+	dbg("%s:raising dtr",__FUNCTION__);
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				 IPW_SIO_SET_PIN,
+				 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 IPW_PIN_SETDTR,
+				 0,
+				 NULL,
+				 0,
+				 200*HZ);
+	if (result < 0)
+		dev_err(&port->dev, "setting dtr failed (error = %d)", result);
+
+	/*--6: raise the rts */
+	dbg("%s:raising rts",__FUNCTION__);
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				 IPW_SIO_SET_PIN,
+				 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 IPW_PIN_SETRTS,
+				 0,
+				 NULL,
+				 0,
+				 200*HZ);
+	if (result < 0)
+		dev_err(&port->dev, "setting dtr failed (error = %d)", result);
+	
+	kfree(buf_flow_init);
+	return 0;
+}
+
+static void ipw_close(struct usb_serial_port *port, struct file * filp)
+{
+	struct usb_device *dev = port->serial->dev;
+	int result;
+
+	if (tty_hung_up_p(filp)) {
+		dbg("%s: tty_hung_up_p ...", __FUNCTION__);
+		return;
+	}
+
+	/*--1: drop the dtr */
+	dbg("%s:dropping dtr",__FUNCTION__);
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				 IPW_SIO_SET_PIN,
+				 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 IPW_PIN_CLRDTR,
+				 0,
+				 NULL,
+				 0,
+				 200*HZ);
+	if (result < 0)
+		dev_err(&port->dev, "dropping dtr failed (error = %d)", result);
+
+	/*--2: drop the rts */
+	dbg("%s:dropping rts",__FUNCTION__);
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				 IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 IPW_PIN_CLRRTS,
+				 0,
+				 NULL,
+				 0,
+				 200*HZ);
+	if (result < 0)
+		dev_err(&port->dev, "dropping rts failed (error = %d)", result);
+
+
+	/*--3: purge */
+	dbg("%s:sending purge",__FUNCTION__);
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				 IPW_SIO_PURGE, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 0x03,
+				 0,
+				 NULL,
+				 0,
+				 200*HZ);
+	if (result < 0)
+		dev_err(&port->dev, "purge failed (error = %d)", result);
+
+
+	/* send RXBULK_off (tell modem to stop transmitting bulk data on rx chan) */
+	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+				 IPW_SIO_RXCTL,
+				 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+				 IPW_RXBULK_OFF,
+				 0, /* index */
+				 NULL,
+				 0,
+				 100*HZ);
+
+	if (result < 0)
+		dev_err(&port->dev, "Disabling bulk RxRead failed (error = %d)", result);
+
+	/* shutdown any in-flight urbs that we know about */
+	usb_kill_urb(port->read_urb);
+	usb_kill_urb(port->write_urb);
+}
+
+static void ipw_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
+{
+	struct usb_serial_port *port = urb->context;
+
+	dbg("%s", __FUNCTION__);
+
+	if (urb->status)
+		dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
+
+	schedule_work(&port->work);
+}
+
+static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int count)
+{
+	struct usb_device *dev = port->serial->dev;
+	int ret;
+
+	dbg("%s: TOP: count=%d, in_interrupt=%ld", __FUNCTION__,
+		count, in_interrupt() );
+
+	if (count == 0) {
+		dbg("%s - write request of 0 bytes", __FUNCTION__);
+		return 0;
+	}
+	
+	/* Racy and broken, FIXME properly! */
+	if (port->write_urb->status == -EINPROGRESS)
+		return 0;
+
+	count = min(count, port->bulk_out_size);
+	memcpy(port->bulk_out_buffer, buf, count);
+
+	dbg("%s count now:%d", __FUNCTION__, count);
+	
+	usb_fill_bulk_urb(port->write_urb, dev,
+			  usb_sndbulkpipe(dev, port->bulk_out_endpointAddress),
+			  port->write_urb->transfer_buffer,
+			  count,
+			  ipw_write_bulk_callback,
+			  port);
+
+	ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
+	if (ret != 0) {
+		dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __FUNCTION__, ret);
+		return ret;
+	}
+
+	dbg("%s returning %d", __FUNCTION__, count);
+	return count;
+} 
+
+static int ipw_probe(struct usb_serial_port *port)
+{
+	return 0;
+}
+
+static int ipw_disconnect(struct usb_serial_port *port)
+{
+	usb_set_serial_port_data(port, NULL);
+	return 0;
+}
+
+static struct usb_serial_device_type ipw_device = {
+	.owner =		THIS_MODULE,
+	.name =			"IPWireless converter",
+	.short_name =		"ipw",
+	.id_table =		usb_ipw_ids,
+	.num_interrupt_in =	NUM_DONT_CARE,
+	.num_bulk_in =		1,
+	.num_bulk_out =		1,
+	.num_ports =		1,
+	.open =			ipw_open,
+	.close =		ipw_close,
+	.port_probe = 		ipw_probe,
+	.port_remove =		ipw_disconnect,
+	.write =		ipw_write,
+	.write_bulk_callback =	ipw_write_bulk_callback,
+	.read_bulk_callback =	ipw_read_bulk_callback,
+};
+
+
+
+int usb_ipw_init(void)
+{
+	int retval;
+
+	retval = usb_serial_register(&ipw_device);
+	if (retval)
+		return retval;
+	retval = usb_register(&usb_ipw_driver);
+	if (retval) {
+		usb_serial_deregister(&ipw_device);
+		return retval;
+	}
+	info(DRIVER_DESC " " DRIVER_VERSION);
+	return 0;
+}
+
+void usb_ipw_exit(void)
+{
+	usb_deregister(&usb_ipw_driver);
+	usb_serial_deregister(&ipw_device);
+}
+
+module_init(usb_ipw_init);
+module_exit(usb_ipw_exit);
+
+/* Module information */
+MODULE_AUTHOR( DRIVER_AUTHOR );
+MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_LICENSE("GPL");
+
+module_param(debug, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, "Debug enabled or not");
diff -Nru a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
--- a/drivers/usb/serial/ir-usb.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/serial/ir-usb.c	2004-12-24 13:36:48 -08:00
@@ -105,7 +105,7 @@
 static int  ir_startup (struct usb_serial *serial);
 static int  ir_open (struct usb_serial_port *port, struct file *filep);
 static void ir_close (struct usb_serial_port *port, struct file *filep);
-static int  ir_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+static int  ir_write (struct usb_serial_port *port, const unsigned char *buf, int count);
 static void ir_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
 static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
 static void ir_set_termios (struct usb_serial_port *port, struct termios *old_termios);
@@ -322,10 +322,10 @@
 	dbg("%s - port %d", __FUNCTION__, port->number);
 			 
 	/* shutdown our bulk read */
-	usb_unlink_urb (port->read_urb);
+	usb_kill_urb(port->read_urb);
 }
 
-static int ir_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int count)
 {
 	unsigned char *transfer_buffer;
 	int result;
@@ -359,12 +359,7 @@
 	*transfer_buffer = ir_xbof | ir_baud;
 	++transfer_buffer;
 
-	if (from_user) {
-		if (copy_from_user (transfer_buffer, buf, transfer_size))
-			return -EFAULT;
-	} else {
-		memcpy (transfer_buffer, buf, transfer_size);
-	}
+	memcpy (transfer_buffer, buf, transfer_size);
 
 	usb_fill_bulk_urb (
 		port->write_urb,
diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
--- a/drivers/usb/serial/keyspan.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/usb/serial/keyspan.c	2004-12-24 13:36:18 -08:00
@@ -342,7 +342,7 @@
 
 	/* Write function is similar for the four protocols used
 	   with only a minor change for usa90 (usa19hs) required */
-static int keyspan_write(struct usb_serial_port *port, int from_user, 
+static int keyspan_write(struct usb_serial_port *port, 
 			 const unsigned char *buf, int count)
 {
 	struct keyspan_port_private 	*p_priv;
@@ -396,12 +396,7 @@
 		   for now so set to zero */
 		((char *)this_urb->transfer_buffer)[0] = 0;
 
-		if (from_user) {
-			if (copy_from_user(this_urb->transfer_buffer + dataOffset, buf, todo))
-				return -EFAULT;
-		} else {
-			memcpy (this_urb->transfer_buffer + dataOffset, buf, todo);
-		}
+		memcpy (this_urb->transfer_buffer + dataOffset, buf, todo);
 		buf += todo;
 
 		/* send the data out the bulk port */
@@ -1126,7 +1121,7 @@
 {
 	if (urb && urb->status == -EINPROGRESS) {
 		urb->transfer_flags &= ~URB_ASYNC_UNLINK;
-		usb_unlink_urb(urb);
+		usb_kill_urb(urb);
 	}
 }
 
diff -Nru a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
--- a/drivers/usb/serial/keyspan.h	2004-12-24 13:37:02 -08:00
+++ b/drivers/usb/serial/keyspan.h	2004-12-24 13:37:02 -08:00
@@ -46,7 +46,6 @@
 static int  keyspan_write_room		(struct usb_serial_port *port);
 
 static int  keyspan_write		(struct usb_serial_port *port,
-					 int from_user,
 					 const unsigned char *buf,
 					 int count);
 
diff -Nru a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
--- a/drivers/usb/serial/keyspan_pda.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/usb/serial/keyspan_pda.c	2004-12-24 13:37:01 -08:00
@@ -285,7 +285,7 @@
 	   upon the device too. */
 
 	dbg("keyspan_pda_rx_throttle port %d", port->number);
-	usb_unlink_urb(port->interrupt_in_urb);
+	usb_kill_urb(port->interrupt_in_urb);
 }
 
 
@@ -493,7 +493,7 @@
 	return -ENOIOCTLCMD;
 }
 
-static int keyspan_pda_write(struct usb_serial_port *port, int from_user, 
+static int keyspan_pda_write(struct usb_serial_port *port, 
 			     const unsigned char *buf, int count)
 {
 	struct usb_serial *serial = port->serial;
@@ -567,16 +567,7 @@
 
 	if (count) {
 		/* now transfer data */
-		if (from_user) {
-			if( copy_from_user(port->write_urb->transfer_buffer,
-			buf, count) ) {
-				rc = -EFAULT;
-				goto exit;
-			}
-		}
-		else {
-			memcpy (port->write_urb->transfer_buffer, buf, count);
-		}  
+		memcpy (port->write_urb->transfer_buffer, buf, count);
 		/* send the data out the bulk port */
 		port->write_urb->transfer_buffer_length = count;
 		
@@ -706,8 +697,8 @@
 			keyspan_pda_set_modem_info(serial, 0);
 
 		/* shutdown our bulk reads and writes */
-		usb_unlink_urb (port->write_urb);
-		usb_unlink_urb (port->interrupt_in_urb);
+		usb_kill_urb(port->write_urb);
+		usb_kill_urb(port->interrupt_in_urb);
 	}
 }
 
diff -Nru a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
--- a/drivers/usb/serial/kl5kusb105.c	2004-12-24 13:36:57 -08:00
+++ b/drivers/usb/serial/kl5kusb105.c	2004-12-24 13:36:57 -08:00
@@ -79,7 +79,6 @@
 static void klsi_105_close	         (struct usb_serial_port *port,
 					  struct file *filp);
 static int  klsi_105_write	         (struct usb_serial_port *port,
-					  int from_user,
 					  const unsigned char *buf,
 					  int count);
 static void klsi_105_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
@@ -336,12 +335,12 @@
 			for (j = 0; j < NUM_URBS; j++) {
 				if (write_urbs[j]) {
 					/* FIXME - uncomment the following
-					 * usb_unlink_urb call when the host
+					 * usb_kill_urb call when the host
 					 * controllers get fixed to set
 					 * urb->dev = NULL after the urb is
 					 * finished.  Otherwise this call
 					 * oopses. */
-					/* usb_unlink_urb(write_urbs[j]); */
+					/* usb_kill_urb(write_urbs[j]); */
 					if (write_urbs[j]->transfer_buffer)
 						    kfree(write_urbs[j]->transfer_buffer);
 					usb_free_urb (write_urbs[j]);
@@ -467,12 +466,12 @@
 		    err("Disabling read failed (error = %d)", rc);
 
 	/* shutdown our bulk reads and writes */
-	usb_unlink_urb (port->write_urb);
-	usb_unlink_urb (port->read_urb);
+	usb_kill_urb(port->write_urb);
+	usb_kill_urb(port->read_urb);
 	/* unlink our write pool */
 	/* FIXME */
 	/* wgg - do I need this? I think so. */
-	usb_unlink_urb (port->interrupt_in_urb);
+	usb_kill_urb(port->interrupt_in_urb);
 	info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", priv->bytes_in, priv->bytes_out);
 } /* klsi_105_close */
 
@@ -484,7 +483,7 @@
 #define KLSI_105_DATA_OFFSET	2   /* in the bulk urb data block */
 
 
-static int klsi_105_write (struct usb_serial_port *port, int from_user,
+static int klsi_105_write (struct usb_serial_port *port,
 			   const unsigned char *buf, int count)
 {
 	struct klsi_105_private *priv = usb_get_serial_port_data(port);
@@ -525,15 +524,7 @@
 		size = min (count, port->bulk_out_size - KLSI_105_DATA_OFFSET);
 		size = min (size, URB_TRANSFER_BUFFER_SIZE - KLSI_105_DATA_OFFSET);
 
-		if (from_user) {
-			if (copy_from_user(urb->transfer_buffer
-					   + KLSI_105_DATA_OFFSET, buf, size)) {
-				return -EFAULT;
-			}
-		} else {
-			memcpy (urb->transfer_buffer + KLSI_105_DATA_OFFSET,
-			       	buf, size);
-		}
+		memcpy (urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size);
 
 		/* write payload size into transfer buffer */
 		((__u8 *)urb->transfer_buffer)[0] = (__u8) (size & 0xFF);
@@ -782,9 +773,11 @@
 		switch (cflag & CSIZE) {
 		case CS5:
 			dbg("%s - 5 bits/byte not supported", __FUNCTION__);
+			spin_unlock_irqrestore (&priv->lock, flags);
 			return ;
 		case CS6:
 			dbg("%s - 6 bits/byte not supported", __FUNCTION__);
+			spin_unlock_irqrestore (&priv->lock, flags);
 			return ;
 		case CS7:
 			priv->cfg.databits = kl5kusb105a_dtb_7;
@@ -994,7 +987,7 @@
 static void klsi_105_throttle (struct usb_serial_port *port)
 {
 	dbg("%s - port %d", __FUNCTION__, port->number);
-	usb_unlink_urb (port->read_urb);
+	usb_kill_urb(port->read_urb);
 }
 
 static void klsi_105_unthrottle (struct usb_serial_port *port)
diff -Nru a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
--- a/drivers/usb/serial/kobil_sct.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/serial/kobil_sct.c	2004-12-24 13:37:19 -08:00
@@ -73,7 +73,7 @@
 static void kobil_shutdown (struct usb_serial *serial);
 static int  kobil_open (struct usb_serial_port *port, struct file *filp);
 static void kobil_close (struct usb_serial_port *port, struct file *filp);
-static int  kobil_write (struct usb_serial_port *port, int from_user, 
+static int  kobil_write (struct usb_serial_port *port, 
 			 const unsigned char *buf, int count);
 static int  kobil_write_room(struct usb_serial_port *port);
 static int  kobil_ioctl(struct usb_serial_port *port, struct file *file,
@@ -350,14 +350,13 @@
 {
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
-	if (port->write_urb){
-		usb_unlink_urb( port->write_urb );
+	if (port->write_urb) {
+		usb_kill_urb(port->write_urb);
 		usb_free_urb( port->write_urb );
 		port->write_urb = NULL;
 	}
-	if (port->interrupt_in_urb){
-		usb_unlink_urb (port->interrupt_in_urb);
-	}
+	if (port->interrupt_in_urb)
+		usb_kill_urb(port->interrupt_in_urb);
 }
 
 
@@ -419,7 +418,7 @@
 }
 
 
-static int kobil_write (struct usb_serial_port *port, int from_user, 
+static int kobil_write (struct usb_serial_port *port, 
 			const unsigned char *buf, int count)
 {
 	int length = 0;
@@ -440,13 +439,7 @@
 	}
 
 	// Copy data to buffer
-	if (from_user) {
-		if (copy_from_user(priv->buf + priv->filled, buf, count)) {
-			return -EFAULT;
-		}
-	} else {
-		memcpy (priv->buf + priv->filled, buf, count);
-	}
+	memcpy (priv->buf + priv->filled, buf, count);
 
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, priv->buf + priv->filled);
 
@@ -458,9 +451,8 @@
 	     ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) {
 		
 		// stop reading (except TWIN and KAAN SIM)
-		if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) {
-			usb_unlink_urb( port->interrupt_in_urb );
-		}
+		if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) )
+			usb_kill_urb(port->interrupt_in_urb);
 
 		todo = priv->filled - priv->cur_pos;
 
diff -Nru a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
--- a/drivers/usb/serial/mct_u232.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/usb/serial/mct_u232.c	2004-12-24 13:37:01 -08:00
@@ -110,7 +110,6 @@
 					  struct file *filp);
 #ifdef FIX_WRITE_RETURN_CODE_PROBLEM
 static int  mct_u232_write	         (struct usb_serial_port *port,
-					  int from_user,
 					  const unsigned char *buf,
 					  int count);
 static void mct_u232_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
@@ -237,7 +236,7 @@
 
 static int mct_u232_set_baud_rate(struct usb_serial *serial, int value)
 {
-	unsigned int divisor;
+	__le32 divisor;
         int rc;
         unsigned char zero_byte = 0;
 
@@ -480,9 +479,9 @@
 
 	if (port->serial->dev) {
 		/* shutdown our urbs */
-		usb_unlink_urb (port->write_urb);
-		usb_unlink_urb (port->read_urb);
-		usb_unlink_urb (port->interrupt_in_urb);
+		usb_kill_urb(port->write_urb);
+		usb_kill_urb(port->read_urb);
+		usb_kill_urb(port->interrupt_in_urb);
 	}
 } /* mct_u232_close */
 
@@ -490,7 +489,7 @@
 #ifdef FIX_WRITE_RETURN_CODE_PROBLEM
 /* The generic routines work fine otherwise */
 
-static int mct_u232_write (struct usb_serial_port *port, int from_user,
+static int mct_u232_write (struct usb_serial_port *port,
 			   const unsigned char *buf, int count)
 {
 	struct usb_serial *serial = port->serial;
@@ -519,14 +518,7 @@
 		
 		usb_serial_debug_data(debug, &port->dev, __FUNCTION__, size, buf);
 		
-		if (from_user) {
-			if (copy_from_user(port->write_urb->transfer_buffer, buf, size)) {
-				return -EFAULT;
-			}
-		}
-		else {
-			memcpy (port->write_urb->transfer_buffer, buf, size);
-		}
+		memcpy (port->write_urb->transfer_buffer, buf, size);
 		
 		/* set up our urb */
 		usb_fill_bulk_urb(port->write_urb, serial->dev,
diff -Nru a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
--- a/drivers/usb/serial/omninet.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/usb/serial/omninet.c	2004-12-24 13:37:19 -08:00
@@ -67,7 +67,7 @@
 static void omninet_close		(struct usb_serial_port *port, struct file *filp);
 static void omninet_read_bulk_callback	(struct urb *urb, struct pt_regs *regs);
 static void omninet_write_bulk_callback	(struct urb *urb, struct pt_regs *regs);
-static int  omninet_write		(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+static int  omninet_write		(struct usb_serial_port *port, const unsigned char *buf, int count);
 static int  omninet_write_room		(struct usb_serial_port *port);
 static void omninet_shutdown		(struct usb_serial *serial);
 
@@ -183,8 +183,8 @@
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
 	wport = serial->port[1];
-	usb_unlink_urb(wport->write_urb);
-	usb_unlink_urb(port->read_urb);
+	usb_kill_urb(wport->write_urb);
+	usb_kill_urb(port->read_urb);
 
 	od = usb_get_serial_port_data(port);
 	if (od)
@@ -241,7 +241,7 @@
 	return;
 }
 
-static int omninet_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count)
 {
 	struct usb_serial 	*serial	= port->serial;
 	struct usb_serial_port 	*wport	= serial->port[1];
@@ -264,15 +264,7 @@
 
 	count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count;
 
-	if (from_user) {
-		if (copy_from_user(wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count) != 0) {
-			result = -EFAULT;
-			goto exit;
-		}
-	}
-	else {
-		memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count);
-	}
+	memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count);
 
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, wport->write_urb->transfer_buffer);
 
@@ -291,7 +283,6 @@
 	else
 		result = count;
 
-exit:	
 	return result;
 }
 
diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
--- a/drivers/usb/serial/pl2303.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/usb/serial/pl2303.c	2004-12-24 13:36:48 -08:00
@@ -55,18 +55,35 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.11"
+#define DRIVER_VERSION "v0.12"
 #define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver"
 
 static int debug;
 
+#define PL2303_CLOSING_WAIT	(30*HZ)
+
+#define PL2303_BUF_SIZE		1024
+#define PL2303_TMP_BUF_SIZE	1024
+
+static DECLARE_MUTEX(pl2303_tmp_buf_sem);
+
+struct pl2303_buf {
+	unsigned int	buf_size;
+	char		*buf_buf;
+	char		*buf_get;
+	char		*buf_put;
+};
+
 static struct usb_device_id id_table [] = {
 	{ USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) },
 	{ USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) },
+	{ USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) },
+	{ USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) },
 	{ USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
 	{ USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
 	{ USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) },
 	{ USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) },
+	{ USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID_UCSGT) },
 	{ USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID) },
 	{ USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) },
 	{ USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) },
@@ -76,6 +93,7 @@
 	{ USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) },
 	{ USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) },
 	{ USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) },
+	{ USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) },
 	{ }					/* Terminating entry */
 };
 
@@ -132,14 +150,26 @@
 static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs);
 static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
 static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
-static int pl2303_write (struct usb_serial_port *port, int from_user,
+static int pl2303_write (struct usb_serial_port *port,
 			 const unsigned char *buf, int count);
+static void pl2303_send (struct usb_serial_port *port);
+static int pl2303_write_room(struct usb_serial_port *port);
+static int pl2303_chars_in_buffer(struct usb_serial_port *port);
 static void pl2303_break_ctl(struct usb_serial_port *port,int break_state);
 static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file);
 static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
 			    unsigned int set, unsigned int clear);
 static int pl2303_startup (struct usb_serial *serial);
 static void pl2303_shutdown (struct usb_serial *serial);
+static struct pl2303_buf *pl2303_buf_alloc(unsigned int size);
+static void pl2303_buf_free(struct pl2303_buf *pb);
+static void pl2303_buf_clear(struct pl2303_buf *pb);
+static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb);
+static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb);
+static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf,
+	unsigned int count);
+static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
+	unsigned int count);
 
 
 /* All of the device info needed for the PL2303 SIO serial converter */
@@ -162,6 +192,8 @@
 	.read_bulk_callback =	pl2303_read_bulk_callback,
 	.read_int_callback =	pl2303_read_int_callback,
 	.write_bulk_callback =	pl2303_write_bulk_callback,
+	.write_room =		pl2303_write_room,
+	.chars_in_buffer =	pl2303_chars_in_buffer,
 	.attach =		pl2303_startup,
 	.shutdown =		pl2303_shutdown,
 };
@@ -174,6 +206,8 @@
 
 struct pl2303_private {
 	spinlock_t lock;
+	struct pl2303_buf *buf;
+	int write_urb_in_use;
 	wait_queue_head_t delta_msr_wait;
 	u8 line_control;
 	u8 line_status;
@@ -201,14 +235,28 @@
 	for (i = 0; i < serial->num_ports; ++i) {
 		priv = kmalloc (sizeof (struct pl2303_private), GFP_KERNEL);
 		if (!priv)
-			return -ENOMEM;
+			goto cleanup;
 		memset (priv, 0x00, sizeof (struct pl2303_private));
 		spin_lock_init(&priv->lock);
+		priv->buf = pl2303_buf_alloc(PL2303_BUF_SIZE);
+		if (priv->buf == NULL) {
+			kfree(priv);
+			goto cleanup;
+		}
 		init_waitqueue_head(&priv->delta_msr_wait);
 		priv->type = type;
 		usb_set_serial_port_data(serial->port[i], priv);
 	}
 	return 0;
+
+cleanup:
+	for (--i; i>=0; --i) {
+		priv = usb_get_serial_port_data(serial->port[i]);
+		pl2303_buf_free(priv->buf);
+		kfree(priv);
+		usb_set_serial_port_data(serial->port[i], NULL);
+	}
+	return -ENOMEM;
 }
 
 static int set_control_lines (struct usb_device *dev, u8 value)
@@ -222,42 +270,97 @@
 	return retval;
 }
 
-static int pl2303_write (struct usb_serial_port *port, int from_user,  const unsigned char *buf, int count)
+static int pl2303_write (struct usb_serial_port *port,  const unsigned char *buf, int count)
 {
-	int result;
+	struct pl2303_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
 
 	dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count);
 
 	if (!count)
 		return count;
 
-	if (port->write_urb->status == -EINPROGRESS) {
-		dbg("%s - already writing", __FUNCTION__);
-		return 0;
+	spin_lock_irqsave(&priv->lock, flags);
+	count = pl2303_buf_put(priv->buf, buf, count);
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	pl2303_send(port);
+
+	return count;
+}
+
+static void pl2303_send(struct usb_serial_port *port)
+{
+	int count, result;
+	struct pl2303_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&priv->lock, flags);
+
+	if (priv->write_urb_in_use) {
+		spin_unlock_irqrestore(&priv->lock, flags);
+		return;
 	}
 
-	count = (count > port->bulk_out_size) ? port->bulk_out_size : count;
-	if (from_user) {
-		if (copy_from_user (port->write_urb->transfer_buffer, buf, count))
-			return -EFAULT;
-	} else {
-		memcpy (port->write_urb->transfer_buffer, buf, count);
+	count = pl2303_buf_get(priv->buf, port->write_urb->transfer_buffer,
+		port->bulk_out_size);
+
+	if (count == 0) {
+		spin_unlock_irqrestore(&priv->lock, flags);
+		return;
 	}
-	
+
+	priv->write_urb_in_use = 1;
+
+	spin_unlock_irqrestore(&priv->lock, flags);
+
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer);
 
 	port->write_urb->transfer_buffer_length = count;
 	port->write_urb->dev = port->serial->dev;
 	result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
-	if (result)
+	if (result) {
 		dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
-	else
-		result = count;
+		priv->write_urb_in_use = 0;
+		// TODO: reschedule pl2303_send
+	}
 
-	return result;
+	schedule_work(&port->work);
 }
 
+static int pl2303_write_room(struct usb_serial_port *port)
+{
+	struct pl2303_private *priv = usb_get_serial_port_data(port);
+	int room = 0;
+	unsigned long flags;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	room = pl2303_buf_space_avail(priv->buf);
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	dbg("%s - returns %d", __FUNCTION__, room);
+	return room;
+}
+
+static int pl2303_chars_in_buffer(struct usb_serial_port *port)
+{
+	struct pl2303_private *priv = usb_get_serial_port_data(port);
+	int chars = 0;
+	unsigned long flags;
+
+	dbg("%s - port %d", __FUNCTION__, port->number);
 
+	spin_lock_irqsave(&priv->lock, flags);
+	chars = pl2303_buf_data_avail(priv->buf);
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	dbg("%s - returns %d", __FUNCTION__, chars);
+	return chars;
+}
 
 static void pl2303_set_termios (struct usb_serial_port *port, struct termios *old_termios)
 {
@@ -422,7 +525,7 @@
 	}
 
 	kfree (buf);
-} 
+}
 
 static int pl2303_open (struct usb_serial_port *port, struct file *filp)
 {
@@ -461,7 +564,7 @@
 	FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0);
 	SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0, 1);
 	SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 1, 0);
- 
+
 	if (priv->type == HX) {
 		/* HX chip */
 		SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x44);
@@ -504,45 +607,67 @@
 
 static void pl2303_close (struct usb_serial_port *port, struct file *filp)
 {
-	struct pl2303_private *priv;
+	struct pl2303_private *priv = usb_get_serial_port_data(port);
 	unsigned long flags;
 	unsigned int c_cflag;
-	int result;
+	int bps;
+	long timeout;
+	wait_queue_t wait;						\
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
-	/* shutdown our urbs */
-	dbg("%s - shutting down urbs", __FUNCTION__);
-	result = usb_unlink_urb (port->write_urb);
-	if (result)
-		dbg("%s - usb_unlink_urb (write_urb)"
-		    " failed with reason: %d", __FUNCTION__,
-		     result);
+	/* wait for data to drain from the buffer */
+	spin_lock_irqsave(&priv->lock, flags);
+	timeout = PL2303_CLOSING_WAIT;
+	init_waitqueue_entry(&wait, current);
+	add_wait_queue(&port->tty->write_wait, &wait);
+	for (;;) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		if (pl2303_buf_data_avail(priv->buf) == 0
+		|| timeout == 0 || signal_pending(current)
+		|| !usb_get_intfdata(port->serial->interface))	/* disconnect */
+			break;
+		spin_unlock_irqrestore(&priv->lock, flags);
+		timeout = schedule_timeout(timeout);
+		spin_lock_irqsave(&priv->lock, flags);
+	}
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&port->tty->write_wait, &wait);
+	/* clear out any remaining data in the buffer */
+	pl2303_buf_clear(priv->buf);
+	spin_unlock_irqrestore(&priv->lock, flags);
 
-	result = usb_unlink_urb (port->read_urb);
-	if (result)
-		dbg("%s - usb_unlink_urb (read_urb) "
-		    "failed with reason: %d", __FUNCTION__,
-		     result);
+	/* wait for characters to drain from the device */
+	/* (this is long enough for the entire 256 byte */
+	/* pl2303 hardware buffer to drain with no flow */
+	/* control for data rates of 1200 bps or more, */
+	/* for lower rates we should really know how much */
+	/* data is in the buffer to compute a delay */
+	/* that is not unnecessarily long) */
+	bps = tty_get_baud_rate(port->tty);
+	if (bps > 1200)
+		timeout = max((HZ*2560)/bps,HZ/10);
+	else
+		timeout = 2*HZ;
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(timeout);
 
-	result = usb_unlink_urb (port->interrupt_in_urb);
-	if (result)
-		dbg("%s - usb_unlink_urb (interrupt_in_urb)"
-		    " failed with reason: %d", __FUNCTION__,
-		     result);
+	/* shutdown our urbs */
+	dbg("%s - shutting down urbs", __FUNCTION__);
+	usb_kill_urb(port->write_urb);
+	usb_kill_urb(port->read_urb);
+	usb_kill_urb(port->interrupt_in_urb);
 
 	if (port->tty) {
 		c_cflag = port->tty->termios->c_cflag;
 		if (c_cflag & HUPCL) {
 			/* drop DTR and RTS */
-			priv = usb_get_serial_port_data(port);
 			spin_lock_irqsave(&priv->lock, flags);
 			priv->line_control = 0;
 			spin_unlock_irqrestore (&priv->lock, flags);
 			set_control_lines (port->serial->dev, 0);
 		}
 	}
-
 }
 
 static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
@@ -672,12 +797,17 @@
 static void pl2303_shutdown (struct usb_serial *serial)
 {
 	int i;
+	struct pl2303_private *priv;
 
 	dbg("%s", __FUNCTION__);
 
 	for (i = 0; i < serial->num_ports; ++i) {
-		kfree (usb_get_serial_port_data(serial->port[i]));
-		usb_set_serial_port_data(serial->port[i], NULL);
+		priv = usb_get_serial_port_data(serial->port[i]);
+		if (priv) {
+			pl2303_buf_free(priv->buf);
+			kfree(priv);
+			usb_set_serial_port_data(serial->port[i], NULL);
+		}
 	}		
 }
 
@@ -815,11 +945,23 @@
 static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
 {
 	struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
+	struct pl2303_private *priv = usb_get_serial_port_data(port);
 	int result;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
-	
-	if (urb->status) {
+
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		/* this urb is terminated, clean up */
+		dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
+		priv->write_urb_in_use = 0;
+		return;
+	default:
 		/* error in the urb, so we have to resubmit it */
 		dbg("%s - Overflow in write", __FUNCTION__);
 		dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
@@ -828,14 +970,199 @@
 		result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
 		if (result)
 			dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n", __FUNCTION__, result);
+		else
+			return;
+	}
 
-		return;
+	priv->write_urb_in_use = 0;
+
+	/* send any buffered data */
+	pl2303_send(port);
+}
+
+
+/*
+ * pl2303_buf_alloc
+ *
+ * Allocate a circular buffer and all associated memory.
+ */
+
+static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
+{
+
+	struct pl2303_buf *pb;
+
+
+	if (size == 0)
+		return NULL;
+
+	pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
+	if (pb == NULL)
+		return NULL;
+
+	pb->buf_buf = kmalloc(size, GFP_KERNEL);
+	if (pb->buf_buf == NULL) {
+		kfree(pb);
+		return NULL;
 	}
 
-	schedule_work(&port->work);
+	pb->buf_size = size;
+	pb->buf_get = pb->buf_put = pb->buf_buf;
+
+	return pb;
+
+}
+
+
+/*
+ * pl2303_buf_free
+ *
+ * Free the buffer and all associated memory.
+ */
+
+static void pl2303_buf_free(struct pl2303_buf *pb)
+{
+	if (pb != NULL) {
+		if (pb->buf_buf != NULL)
+			kfree(pb->buf_buf);
+		kfree(pb);
+	}
+}
+
+
+/*
+ * pl2303_buf_clear
+ *
+ * Clear out all data in the circular buffer.
+ */
+
+static void pl2303_buf_clear(struct pl2303_buf *pb)
+{
+	if (pb != NULL)
+		pb->buf_get = pb->buf_put;
+		/* equivalent to a get of all data available */
+}
+
+
+/*
+ * pl2303_buf_data_avail
+ *
+ * Return the number of bytes of data available in the circular
+ * buffer.
+ */
+
+static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)
+{
+	if (pb != NULL)
+		return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
+	else
+		return 0;
+}
+
+
+/*
+ * pl2303_buf_space_avail
+ *
+ * Return the number of bytes of space available in the circular
+ * buffer.
+ */
+
+static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
+{
+	if (pb != NULL)
+		return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
+	else
+		return 0;
+}
+
+
+/*
+ * pl2303_buf_put
+ *
+ * Copy data data from a user buffer and put it into the circular buffer.
+ * Restrict to the amount of space available.
+ *
+ * Return the number of bytes copied.
+ */
+
+static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf,
+	unsigned int count)
+{
+
+	unsigned int len;
+
+
+	if (pb == NULL)
+		return 0;
+
+	len  = pl2303_buf_space_avail(pb);
+	if (count > len)
+		count = len;
+
+	if (count == 0)
+		return 0;
+
+	len = pb->buf_buf + pb->buf_size - pb->buf_put;
+	if (count > len) {
+		memcpy(pb->buf_put, buf, len);
+		memcpy(pb->buf_buf, buf+len, count - len);
+		pb->buf_put = pb->buf_buf + count - len;
+	} else {
+		memcpy(pb->buf_put, buf, count);
+		if (count < len)
+			pb->buf_put += count;
+		else /* count == len */
+			pb->buf_put = pb->buf_buf;
+	}
+
+	return count;
+
 }
 
 
+/*
+ * pl2303_buf_get
+ *
+ * Get data from the circular buffer and copy to the given buffer.
+ * Restrict to the amount of data available.
+ *
+ * Return the number of bytes copied.
+ */
+
+static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
+	unsigned int count)
+{
+
+	unsigned int len;
+
+
+	if (pb == NULL)
+		return 0;
+
+	len = pl2303_buf_data_avail(pb);
+	if (count > len)
+		count = len;
+
+	if (count == 0)
+		return 0;
+
+	len = pb->buf_buf + pb->buf_size - pb->buf_get;
+	if (count > len) {
+		memcpy(buf, pb->buf_get, len);
+		memcpy(buf+len, pb->buf_buf, count - len);
+		pb->buf_get = pb->buf_buf + count - len;
+	} else {
+		memcpy(buf, pb->buf_get, count);
+		if (count < len)
+			pb->buf_get += count;
+		else /* count == len */
+			pb->buf_get = pb->buf_buf;
+	}
+
+	return count;
+
+}
+
 static int __init pl2303_init (void)
 {
 	int retval;
@@ -865,6 +1192,7 @@
 module_exit(pl2303_exit);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
diff -Nru a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
--- a/drivers/usb/serial/pl2303.h	2004-12-24 13:36:56 -08:00
+++ b/drivers/usb/serial/pl2303.h	2004-12-24 13:36:56 -08:00
@@ -9,7 +9,9 @@
  */
 #define PL2303_VENDOR_ID	0x067b
 #define PL2303_PRODUCT_ID	0x2303
-#define PL2303_PRODUCT_ID_RSAQ2	0x04bb
+#define PL2303_PRODUCT_ID_RSAQ2		0x04bb
+#define PL2303_PRODUCT_ID_PHAROS	0xaaa0
+#define PL2303_PRODUCT_ID_RSAQ3		0xaaa2
 
 #define ATEN_VENDOR_ID		0x0557
 #define ATEN_VENDOR_ID2		0x0547
@@ -20,6 +22,7 @@
 
 #define ELCOM_VENDOR_ID		0x056e
 #define ELCOM_PRODUCT_ID	0x5003
+#define ELCOM_PRODUCT_ID_UCSGT	0x5004
 
 #define ITEGNO_VENDOR_ID	0x0eba
 #define ITEGNO_PRODUCT_ID	0x1080
@@ -47,6 +50,8 @@
 #define ALCATEL_PRODUCT_ID	0x02df
 
 /* Samsung I330 phone cradle */
-#define SAMSUNG_VENDOR_ID       0x04e8
-#define SAMSUNG_PRODUCT_ID      0x8001
+#define SAMSUNG_VENDOR_ID	0x04e8
+#define SAMSUNG_PRODUCT_ID	0x8001
 
+#define SIEMENS_VENDOR_ID	0x11f5
+#define SIEMENS_PRODUCT_ID_X65	0x0003
diff -Nru a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
--- a/drivers/usb/serial/safe_serial.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/usb/serial/safe_serial.c	2004-12-24 13:37:43 -08:00
@@ -273,7 +273,7 @@
 	}
 }
 
-static int safe_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+static int safe_write (struct usb_serial_port *port, const unsigned char *buf, int count)
 {
 	unsigned char *data;
 	int result;
@@ -314,12 +314,7 @@
 	data = port->write_urb->transfer_buffer;
 	memset (data, '0', packet_length);
 
-	if (from_user) {
-		if (copy_from_user (data, buf, count))
-			return -EFAULT;
-	} else {
-		memcpy (data, buf, count);
-	}
+	memcpy (data, buf, count);
 
 	if (safe) {
 		__u16 fcs;
diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
--- a/drivers/usb/serial/usb-serial.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/usb/serial/usb-serial.c	2004-12-24 13:37:43 -08:00
@@ -388,7 +388,7 @@
 
 		good_spot = 1;
 		for (j = 1; j <= num_ports-1; ++j)
-			if ((serial_table[i+j]) || (i+j >= SERIAL_TTY_MINORS)) {
+			if ((i+j >= SERIAL_TTY_MINORS) || (serial_table[i+j])) {
 				good_spot = 0;
 				i += j;
 				break;
@@ -405,7 +405,7 @@
 	return NULL;
 }
 
-static void return_serial (struct usb_serial *serial)
+static void return_serial(struct usb_serial *serial)
 {
 	int i;
 
@@ -417,8 +417,6 @@
 	for (i = 0; i < serial->num_ports; ++i) {
 		serial_table[serial->minor + i] = NULL;
 	}
-
-	return;
 }
 
 static void destroy_serial(struct kref *kref)
@@ -454,21 +452,18 @@
 			port = serial->port[i];
 			if (!port)
 				continue;
-			if (port->read_urb) {
-				usb_unlink_urb(port->read_urb);
-				usb_free_urb(port->read_urb);
-			}
-			if (port->write_urb) {
-				usb_unlink_urb(port->write_urb);
-				usb_free_urb(port->write_urb);
-			}
-			if (port->interrupt_in_urb) {
-				usb_unlink_urb(port->interrupt_in_urb);
-				usb_free_urb(port->interrupt_in_urb);
-			}
+			usb_kill_urb(port->read_urb);
+			usb_free_urb(port->read_urb);
+			usb_kill_urb(port->write_urb);
+			usb_free_urb(port->write_urb);
+			usb_kill_urb(port->interrupt_in_urb);
+			usb_free_urb(port->interrupt_in_urb);
+			usb_kill_urb(port->interrupt_out_urb);
+			usb_free_urb(port->interrupt_out_urb);
 			kfree(port->bulk_in_buffer);
 			kfree(port->bulk_out_buffer);
 			kfree(port->interrupt_in_buffer);
+			kfree(port->interrupt_out_buffer);
 		}
 	}
 
@@ -486,46 +481,51 @@
 	struct usb_serial *serial;
 	struct usb_serial_port *port;
 	unsigned int portNumber;
-	int retval = 0;
+	int retval;
 	
 	dbg("%s", __FUNCTION__);
 
-	/* initialize the pointer incase something fails */
-	tty->driver_data = NULL;
-
 	/* get the serial object associated with this tty pointer */
 	serial = usb_serial_get_by_index(tty->index);
 	if (!serial) {
-		retval = -ENODEV;
-		goto bailout;
+		tty->driver_data = NULL;
+		return -ENODEV;
 	}
 
-	/* set up our port structure making the tty driver remember our port object, and us it */
 	portNumber = tty->index - serial->minor;
 	port = serial->port[portNumber];
-	tty->driver_data = port;
-
-	port->tty = tty;
 	 
-	/* lock this module before we call it,
-	   this may, which means we must bail out, safe because we are called with BKL held */
-	if (!try_module_get(serial->type->owner)) {
-		retval = -ENODEV;
-		goto bailout;
-	}
-
 	++port->open_count;
+
 	if (port->open_count == 1) {
+
+		/* set up our port structure making the tty driver
+		 * remember our port object, and us it */
+		tty->driver_data = port;
+		port->tty = tty;
+
+		/* lock this module before we call it
+		 * this may fail, which means we must bail out,
+		 * safe because we are called with BKL held */
+		if (!try_module_get(serial->type->owner)) {
+			retval = -ENODEV;
+			goto bailout_kref_put;
+		}
+
 		/* only call the device specific open if this 
 		 * is the first time the port is opened */
 		retval = serial->type->open(port, filp);
-		if (retval) {
-			port->open_count = 0;
-			module_put(serial->type->owner);
-			kref_put(&serial->kref, destroy_serial);
-		}
+		if (retval)
+			goto bailout_module_put;
 	}
-bailout:
+
+	return 0;
+
+bailout_module_put:
+	module_put(serial->type->owner);
+bailout_kref_put:
+	kref_put(&serial->kref, destroy_serial);
+	port->open_count = 0;
 	return retval;
 }
 
@@ -538,25 +538,28 @@
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
+	if (port->open_count == 0)
+		return;
+
 	--port->open_count;
-	if (port->open_count <= 0) {
+	if (port->open_count == 0) {
 		/* only call the device specific close if this 
 		 * port is being closed by the last owner */
 		port->serial->type->close(port, filp);
-		port->open_count = 0;
 
 		if (port->tty) {
 			if (port->tty->driver_data)
 				port->tty->driver_data = NULL;
 			port->tty = NULL;
 		}
+
+		module_put(port->serial->type->owner);
 	}
 
-	module_put(port->serial->type->owner);
 	kref_put(&port->serial->kref, destroy_serial);
 }
 
-static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count)
+static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count)
 {
 	struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
 	int retval = -EINVAL;
@@ -569,7 +572,7 @@
 	}
 
 	/* pass on to the driver specific version of this function */
-	retval = port->serial->type->write(port, from_user, buf, count);
+	retval = port->serial->type->write(port, buf, count);
 
 exit:
 	return retval;
@@ -621,15 +624,12 @@
 
 	if (!port->open_count) {
 		dbg ("%s - port not open", __FUNCTION__);
-		goto exit;
+		return;
 	}
 
 	/* pass on to the driver specific version of this function */
 	if (port->serial->type->throttle)
 		port->serial->type->throttle(port);
-
-exit:
-	;
 }
 
 static void serial_unthrottle (struct tty_struct * tty)
@@ -640,15 +640,12 @@
 
 	if (!port->open_count) {
 		dbg("%s - port not open", __FUNCTION__);
-		goto exit;
+		return;
 	}
 
 	/* pass on to the driver specific version of this function */
 	if (port->serial->type->unthrottle)
 		port->serial->type->unthrottle(port);
-
-exit:
-	;
 }
 
 static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
@@ -681,15 +678,12 @@
 
 	if (!port->open_count) {
 		dbg("%s - port not open", __FUNCTION__);
-		goto exit;
+		return;
 	}
 
 	/* pass on to the driver specific version of this function if it is available */
 	if (port->serial->type->set_termios)
 		port->serial->type->set_termios(port, old);
-
-exit:
-	;
 }
 
 static void serial_break (struct tty_struct *tty, int break_state)
@@ -700,15 +694,12 @@
 
 	if (!port->open_count) {
 		dbg("%s - port not open", __FUNCTION__);
-		goto exit;
+		return;
 	}
 
 	/* pass on to the driver specific version of this function if it is available */
 	if (port->serial->type->break_ctl)
 		port->serial->type->break_ctl(port, break_state);
-
-exit:
-	;
 }
 
 static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data)
@@ -813,21 +804,18 @@
 	struct usb_serial_port *port = to_usb_serial_port(dev);
 
 	dbg ("%s - %s", __FUNCTION__, dev->bus_id);
-	if (port->read_urb) {
-		usb_unlink_urb(port->read_urb);
-		usb_free_urb(port->read_urb);
-	}
-	if (port->write_urb) {
-		usb_unlink_urb(port->write_urb);
-		usb_free_urb(port->write_urb);
-	}
-	if (port->interrupt_in_urb) {
-		usb_unlink_urb(port->interrupt_in_urb);
-		usb_free_urb(port->interrupt_in_urb);
-	}
+	usb_kill_urb(port->read_urb);
+	usb_free_urb(port->read_urb);
+	usb_kill_urb(port->write_urb);
+	usb_free_urb(port->write_urb);
+	usb_kill_urb(port->interrupt_in_urb);
+	usb_free_urb(port->interrupt_in_urb);
+	usb_kill_urb(port->interrupt_out_urb);
+	usb_free_urb(port->interrupt_out_urb);
 	kfree(port->bulk_in_buffer);
 	kfree(port->bulk_out_buffer);
 	kfree(port->interrupt_in_buffer);
+	kfree(port->interrupt_out_buffer);
 	kfree(port);
 }
 
@@ -853,6 +841,25 @@
 	return serial;
 }
 
+static struct usb_serial_device_type *search_serial_device(struct usb_interface *iface)
+{
+	struct list_head *p;
+	const struct usb_device_id *id;
+	struct usb_serial_device_type *t;
+
+	/* List trough know devices and see if the usb id matches */
+	list_for_each(p, &usb_serial_driver_list) {
+		t = list_entry(p, struct usb_serial_device_type, driver_list);
+		id = usb_match_id(iface, t->id_table);
+		if (id != NULL) {
+			dbg("descriptor matches");
+			return t;
+		}
+	}
+
+	return NULL;
+}
+
 int usb_serial_probe(struct usb_interface *interface,
 			       const struct usb_device_id *id)
 {
@@ -862,36 +869,23 @@
 	struct usb_host_interface *iface_desc;
 	struct usb_endpoint_descriptor *endpoint;
 	struct usb_endpoint_descriptor *interrupt_in_endpoint[MAX_NUM_PORTS];
+	struct usb_endpoint_descriptor *interrupt_out_endpoint[MAX_NUM_PORTS];
 	struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS];
 	struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS];
 	struct usb_serial_device_type *type = NULL;
-	struct list_head *tmp;
 	int retval;
-	int found;
 	int minor;
 	int buffer_size;
 	int i;
 	int num_interrupt_in = 0;
+	int num_interrupt_out = 0;
 	int num_bulk_in = 0;
 	int num_bulk_out = 0;
 	int num_ports = 0;
 	int max_endpoints;
-	const struct usb_device_id *id_pattern = NULL;
 
-	/* loop through our list of known serial converters, and see if this
-	   device matches. */
-	found = 0;
-	list_for_each (tmp, &usb_serial_driver_list) {
-		type = list_entry(tmp, struct usb_serial_device_type, driver_list);
-		id_pattern = usb_match_id(interface, type->id_table);
-		if (id_pattern != NULL) {
-			dbg("descriptor matches");
-			found = 1;
-			break;
-		}
-	}
-	if (!found) {
-		/* no match */
+	type = search_serial_device(interface);
+	if (!type) {
 		dbg("none matched");
 		return -ENODEV;
 	}
@@ -899,17 +893,21 @@
 	serial = create_serial (dev, interface, type);
 	if (!serial) {
 		dev_err(&interface->dev, "%s - out of memory\n", __FUNCTION__);
-		return -ENODEV;
+		return -ENOMEM;
 	}
 
 	/* if this device type has a probe function, call it */
 	if (type->probe) {
+		const struct usb_device_id *id;
+
 		if (!try_module_get(type->owner)) {
 			dev_err(&interface->dev, "module get failed, exiting\n");
 			kfree (serial);
 			return -EIO;
 		}
-		retval = type->probe (serial, id_pattern);
+
+		id = usb_match_id(interface, type->id_table);
+		retval = type->probe(serial, id);
 		module_put(type->owner);
 
 		if (retval) {
@@ -928,7 +926,7 @@
 		if ((endpoint->bEndpointAddress & 0x80) &&
 		    ((endpoint->bmAttributes & 3) == 0x02)) {
 			/* we found a bulk in endpoint */
-			dbg("found bulk in");
+			dbg("found bulk in on endpoint %d", i);
 			bulk_in_endpoint[num_bulk_in] = endpoint;
 			++num_bulk_in;
 		}
@@ -936,7 +934,7 @@
 		if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
 		    ((endpoint->bmAttributes & 3) == 0x02)) {
 			/* we found a bulk out endpoint */
-			dbg("found bulk out");
+			dbg("found bulk out on endpoint %d", i);
 			bulk_out_endpoint[num_bulk_out] = endpoint;
 			++num_bulk_out;
 		}
@@ -944,10 +942,18 @@
 		if ((endpoint->bEndpointAddress & 0x80) &&
 		    ((endpoint->bmAttributes & 3) == 0x03)) {
 			/* we found a interrupt in endpoint */
-			dbg("found interrupt in");
+			dbg("found interrupt in on endpoint %d", i);
 			interrupt_in_endpoint[num_interrupt_in] = endpoint;
 			++num_interrupt_in;
 		}
+
+		if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
+		    ((endpoint->bmAttributes & 3) == 0x03)) {
+			/* we found an interrupt out endpoint */
+			dbg("found interrupt out on endpoint %d", i);
+			interrupt_out_endpoint[num_interrupt_out] = endpoint;
+			++num_interrupt_out;
+		}
 	}
 
 #if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE)
@@ -1024,11 +1030,13 @@
 	serial->num_bulk_in = num_bulk_in;
 	serial->num_bulk_out = num_bulk_out;
 	serial->num_interrupt_in = num_interrupt_in;
+	serial->num_interrupt_out = num_interrupt_out;
 
 	/* create our ports, we need as many as the max endpoints */
 	/* we don't use num_ports here cauz some devices have more endpoint pairs than ports */
 	max_endpoints = max(num_bulk_in, num_bulk_out);
 	max_endpoints = max(max_endpoints, num_interrupt_in);
+	max_endpoints = max(max_endpoints, num_interrupt_out);
 	max_endpoints = max(max_endpoints, (int)serial->num_ports);
 	serial->num_port_pointers = max_endpoints;
 	dbg("%s - setting up %d port structures for this device", __FUNCTION__, max_endpoints);
@@ -1053,6 +1061,7 @@
 			goto probe_error;
 		}
 		buffer_size = endpoint->wMaxPacketSize;
+		port->bulk_in_size = buffer_size;
 		port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
 		port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
 		if (!port->bulk_in_buffer) {
@@ -1091,29 +1100,61 @@
 				   port);
 	}
 
-	for (i = 0; i < num_interrupt_in; ++i) {
-		endpoint = interrupt_in_endpoint[i];
-		port = serial->port[i];
-		port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
-		if (!port->interrupt_in_urb) {
-			dev_err(&interface->dev, "No free urbs available\n");
-			goto probe_error;
+	if (serial->type->read_int_callback) {
+		for (i = 0; i < num_interrupt_in; ++i) {
+			endpoint = interrupt_in_endpoint[i];
+			port = serial->port[i];
+			port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
+			if (!port->interrupt_in_urb) {
+				dev_err(&interface->dev, "No free urbs available\n");
+				goto probe_error;
+			}
+			buffer_size = endpoint->wMaxPacketSize;
+			port->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
+			port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
+			if (!port->interrupt_in_buffer) {
+				dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n");
+				goto probe_error;
+			}
+			usb_fill_int_urb (port->interrupt_in_urb, dev, 
+					  usb_rcvintpipe (dev,
+							  endpoint->bEndpointAddress),
+					  port->interrupt_in_buffer, buffer_size, 
+					  serial->type->read_int_callback, port, 
+					  endpoint->bInterval);
 		}
-		buffer_size = endpoint->wMaxPacketSize;
-		port->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
-		port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
-		if (!port->interrupt_in_buffer) {
-			dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n");
-			goto probe_error;
+	} else if (num_interrupt_in) {
+		dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined");
+	}
+	
+	if (serial->type->write_int_callback) {
+		for (i = 0; i < num_interrupt_out; ++i) {
+			endpoint = interrupt_out_endpoint[i];
+			port = serial->port[i];
+			port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
+			if (!port->interrupt_out_urb) {
+				dev_err(&interface->dev, "No free urbs available\n");
+				goto probe_error;
+			}
+			buffer_size = endpoint->wMaxPacketSize;
+			port->interrupt_out_size = buffer_size;
+			port->interrupt_out_endpointAddress = endpoint->bEndpointAddress;
+			port->interrupt_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
+			if (!port->interrupt_out_buffer) {
+				dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n");
+				goto probe_error;
+			}
+			usb_fill_int_urb (port->interrupt_out_urb, dev,
+					  usb_sndintpipe (dev,
+							  endpoint->bEndpointAddress),
+					  port->interrupt_out_buffer, buffer_size,
+					  serial->type->write_int_callback, port,
+					  endpoint->bInterval);
 		}
-		usb_fill_int_urb (port->interrupt_in_urb, dev, 
-				  usb_rcvintpipe (dev,
-						  endpoint->bEndpointAddress),
-				  port->interrupt_in_buffer, buffer_size, 
-				  serial->type->read_int_callback, port, 
-				  endpoint->bInterval);
+	} else if (num_interrupt_out) {
+		dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
 	}
-
+	
 	/* if this device type has an attach function, call it */
 	if (type->attach) {
 		if (!try_module_get(type->owner)) {
@@ -1176,6 +1217,14 @@
 			usb_free_urb (port->interrupt_in_urb);
 		kfree(port->interrupt_in_buffer);
 	}
+	for (i = 0; i < num_interrupt_out; ++i) {
+		port = serial->port[i];
+		if (!port)
+			continue;
+		if (port->interrupt_out_urb)
+			usb_free_urb (port->interrupt_out_urb);
+		kfree(port->interrupt_out_buffer);
+	}
 
 	/* return the minor range that this device had */
 	return_serial (serial);
@@ -1224,7 +1273,7 @@
 static int __init usb_serial_init(void)
 {
 	int i;
-	int result = 0;
+	int result;
 
 	usb_serial_tty_driver = alloc_tty_driver(SERIAL_TTY_MINORS);
 	if (!usb_serial_tty_driver)
@@ -1235,13 +1284,17 @@
 		serial_table[i] = NULL;
 	}
 
-	bus_register(&usb_serial_bus_type);
+	result = bus_register(&usb_serial_bus_type);
+	if (result) {
+		err("%s - registering bus driver failed", __FUNCTION__);
+		goto exit_bus;
+	}
 
 	/* register the generic driver, if we should */
 	result = usb_serial_generic_register(debug);
 	if (result < 0) {
 		err("%s - registering generic driver failed", __FUNCTION__);
-		goto exit;
+		goto exit_generic;
 	}
 
 	usb_serial_tty_driver->owner = THIS_MODULE;
@@ -1259,7 +1312,7 @@
 	result = tty_register_driver(usb_serial_tty_driver);
 	if (result) {
 		err("%s - tty_register_driver failed", __FUNCTION__);
-		goto exit_generic;
+		goto exit_reg_driver;
 	}
 
 	/* register the USB driver */
@@ -1276,10 +1329,13 @@
 exit_tty:
 	tty_unregister_driver(usb_serial_tty_driver);
 
-exit_generic:
+exit_reg_driver:
 	usb_serial_generic_deregister();
 
-exit:
+exit_generic:
+	bus_unregister(&usb_serial_bus_type);
+
+exit_bus:
 	err ("%s - returning with error %d", __FUNCTION__, result);
 	put_tty_driver(usb_serial_tty_driver);
 	return result;
@@ -1332,17 +1388,13 @@
 	/* Add this device to our list of devices */
 	list_add(&new_device->driver_list, &usb_serial_driver_list);
 
-	retval =  usb_serial_bus_register (new_device);
-
-	if (retval)
-		goto error;
-
-	info("USB Serial support registered for %s", new_device->name);
-
-	return retval;
-error:
-	err("problem %d when registering driver %s", retval, new_device->name);
-	list_del(&new_device->driver_list);
+	retval = usb_serial_bus_register(new_device);
+	if (retval) {
+		err("problem %d when registering driver %s", retval, new_device->name);
+		list_del(&new_device->driver_list);
+	}
+	else
+		info("USB Serial support registered for %s", new_device->name);
 
 	return retval;
 }
@@ -1369,6 +1421,7 @@
 /* Module information */
 MODULE_AUTHOR( DRIVER_AUTHOR );
 MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_VERSION( DRIVER_VERSION );
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
diff -Nru a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
--- a/drivers/usb/serial/usb-serial.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/usb/serial/usb-serial.h	2004-12-24 13:37:43 -08:00
@@ -74,6 +74,11 @@
  * @interrupt_in_urb: pointer to the interrupt in struct urb for this port.
  * @interrupt_in_endpointAddress: endpoint address for the interrupt in pipe
  *	for this port.
+ * @interrupt_out_buffer: pointer to the interrupt out buffer for this port.
+ * @interrupt_out_size: the size of the interrupt_out_buffer, in bytes.
+ * @interrupt_out_urb: pointer to the interrupt out struct urb for this port.
+ * @interrupt_out_endpointAddress: endpoint address for the interrupt out pipe
+ * 	for this port.
  * @bulk_in_buffer: pointer to the bulk in buffer for this port.
  * @read_urb: pointer to the bulk in struct urb for this port.
  * @bulk_in_endpointAddress: endpoint address for the bulk in pipe for this
@@ -99,7 +104,13 @@
 	struct urb *		interrupt_in_urb;
 	__u8			interrupt_in_endpointAddress;
 
+	unsigned char *		interrupt_out_buffer;
+	int			interrupt_out_size;
+	struct urb *		interrupt_out_urb;
+	__u8			interrupt_out_endpointAddress;
+
 	unsigned char *		bulk_in_buffer;
+	int			bulk_in_size;
 	struct urb *		read_urb;
 	__u8			bulk_in_endpointAddress;
 
@@ -134,6 +145,7 @@
  * @minor: the starting minor number for this device
  * @num_ports: the number of ports this device has
  * @num_interrupt_in: number of interrupt in endpoints we have
+ * @num_interrupt_out: number of interrupt out endpoints we have
  * @num_bulk_in: number of bulk in endpoints we have
  * @num_bulk_out: number of bulk out endpoints we have
  * @vendor: vendor id of this device
@@ -152,6 +164,7 @@
 	unsigned char			num_ports;
 	unsigned char			num_port_pointers;
 	char				num_interrupt_in;
+	char				num_interrupt_out;
 	char				num_bulk_in;
 	char				num_bulk_out;
 	__u16				vendor;
@@ -187,6 +200,8 @@
  *	of the devices this structure can support.
  * @num_interrupt_in: the number of interrupt in endpoints this device will
  *	have.
+ * @num_interrupt_out: the number of interrupt out endpoints this device will
+ *	have.
  * @num_bulk_in: the number of bulk in endpoints this device will have.
  * @num_bulk_out: the number of bulk out endpoints this device will have.
  * @num_ports: the number of different ports this device will have.
@@ -219,6 +234,7 @@
 	char	*short_name;
 	const struct usb_device_id *id_table;
 	char	num_interrupt_in;
+	char	num_interrupt_out;
 	char	num_bulk_in;
 	char	num_bulk_out;
 	char	num_ports;
@@ -238,7 +254,7 @@
 	/* serial function calls */
 	int  (*open)		(struct usb_serial_port *port, struct file * filp);
 	void (*close)		(struct usb_serial_port *port, struct file * filp);
-	int  (*write)		(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+	int  (*write)		(struct usb_serial_port *port, const unsigned char *buf, int count);
 	int  (*write_room)	(struct usb_serial_port *port);
 	int  (*ioctl)		(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
 	void (*set_termios)	(struct usb_serial_port *port, struct termios * old);
@@ -250,6 +266,7 @@
 	int  (*tiocmset)	(struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
 
 	void (*read_int_callback)(struct urb *urb, struct pt_regs *regs);
+	void (*write_int_callback)(struct urb *urb, struct pt_regs *regs);
 	void (*read_bulk_callback)(struct urb *urb, struct pt_regs *regs);
 	void (*write_bulk_callback)(struct urb *urb, struct pt_regs *regs);
 };
@@ -277,7 +294,7 @@
 /* Functions needed by other parts of the usbserial core */
 extern struct usb_serial *usb_serial_get_by_index (unsigned int minor);
 extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp);
-extern int usb_serial_generic_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count);
 extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp);
 extern int usb_serial_generic_write_room (struct usb_serial_port *port);
 extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port);
diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
--- a/drivers/usb/serial/visor.c	2004-12-24 13:36:33 -08:00
+++ b/drivers/usb/serial/visor.c	2004-12-24 13:36:33 -08:00
@@ -168,7 +168,7 @@
 /* function prototypes for a handspring visor */
 static int  visor_open		(struct usb_serial_port *port, struct file *filp);
 static void visor_close		(struct usb_serial_port *port, struct file *filp);
-static int  visor_write		(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+static int  visor_write		(struct usb_serial_port *port, const unsigned char *buf, int count);
 static int  visor_write_room		(struct usb_serial_port *port);
 static int  visor_chars_in_buffer	(struct usb_serial_port *port);
 static void visor_throttle	(struct usb_serial_port *port);
@@ -381,10 +381,17 @@
 	.read_bulk_callback =	visor_read_bulk_callback,
 };
 
+struct visor_private {
+	spinlock_t lock;
+	int bytes_in;
+	int bytes_out;
+	int outstanding_urbs;
+};
 
-static int bytes_in;
-static int bytes_out;
+/* number of outstanding urbs to prevent userspace DoS from happening */
+#define URB_UPPER_LIMIT	42
 
+static int stats;
 
 /******************************************************************************
  * Handspring Visor specific driver functions
@@ -392,6 +399,8 @@
 static int visor_open (struct usb_serial_port *port, struct file *filp)
 {
 	struct usb_serial *serial = port->serial;
+	struct visor_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
 	int result = 0;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
@@ -402,8 +411,11 @@
 		return -ENODEV;
 	}
 
-	bytes_in = 0;
-	bytes_out = 0;
+	spin_lock_irqsave(&priv->lock, flags);
+	priv->bytes_in = 0;
+	priv->bytes_out = 0;
+	priv->outstanding_urbs = 0;
+	spin_unlock_irqrestore(&priv->lock, flags);
 
 	/*
 	 * Force low_latency on so that our tty_push actually forces the data
@@ -441,14 +453,15 @@
 
 static void visor_close (struct usb_serial_port *port, struct file * filp)
 {
+	struct visor_private *priv = usb_get_serial_port_data(port);
 	unsigned char *transfer_buffer;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 			 
 	/* shutdown our urbs */
-	usb_unlink_urb (port->read_urb);
+	usb_kill_urb(port->read_urb);
 	if (port->interrupt_in_urb)
-		usb_unlink_urb (port->interrupt_in_urb);
+		usb_kill_urb(port->interrupt_in_urb);
 
 	/* Try to send shutdown message, if the device is gone, this will just fail. */
 	transfer_buffer =  kmalloc (0x12, GFP_KERNEL);
@@ -461,20 +474,31 @@
 		kfree (transfer_buffer);
 	}
 
-	/* Uncomment the following line if you want to see some statistics in your syslog */
-	/* dev_info (&port->dev, "Bytes In = %d  Bytes Out = %d\n", bytes_in, bytes_out); */
+	if (stats)
+		dev_info(&port->dev, "Bytes In = %d  Bytes Out = %d\n",
+			 priv->bytes_in, priv->bytes_out);
 }
 
 
-static int visor_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count)
 {
+	struct visor_private *priv = usb_get_serial_port_data(port);
 	struct usb_serial *serial = port->serial;
 	struct urb *urb;
 	unsigned char *buffer;
+	unsigned long flags;
 	int status;
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
+	spin_lock_irqsave(&priv->lock, flags);
+	if (priv->outstanding_urbs > URB_UPPER_LIMIT) {
+		spin_unlock_irqrestore(&priv->lock, flags);
+		dbg("%s - write limit hit\n", __FUNCTION__);
+		return 0;
+	}
+	spin_unlock_irqrestore(&priv->lock, flags);
+
 	buffer = kmalloc (count, GFP_ATOMIC);
 	if (!buffer) {
 		dev_err(&port->dev, "out of memory\n");
@@ -488,15 +512,7 @@
 		return -ENOMEM;
 	}
 
-	if (from_user) {
-		if (copy_from_user (buffer, buf, count)) {
-			kfree (buffer);
-			usb_free_urb (urb);
-			return -EFAULT;
-		}
-	} else {
-		memcpy (buffer, buf, count);
-	}
+	memcpy (buffer, buf, count);
 
 	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer);
 
@@ -514,7 +530,10 @@
 		count = status;
 		kfree (buffer);
 	} else {
-		bytes_out += count;
+		spin_lock_irqsave(&priv->lock, flags);
+		++priv->outstanding_urbs;
+		priv->bytes_out += count;
+		spin_unlock_irqrestore(&priv->lock, flags);
 	}
 
 	/* we are done with this urb, so let the host driver
@@ -555,6 +574,8 @@
 static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
 {
 	struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+	struct visor_private *priv = usb_get_serial_port_data(port);
+	unsigned long flags;
 
 	/* free up the transfer buffer, as usb_free_urb() does not do this */
 	kfree (urb->transfer_buffer);
@@ -565,6 +586,10 @@
 		dbg("%s - nonzero write bulk status received: %d",
 		    __FUNCTION__, urb->status);
 
+	spin_lock_irqsave(&priv->lock, flags);
+	--priv->outstanding_urbs;
+	spin_unlock_irqrestore(&priv->lock, flags);
+
 	schedule_work(&port->work);
 }
 
@@ -572,8 +597,10 @@
 static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
 {
 	struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
-	struct tty_struct *tty;
+	struct visor_private *priv = usb_get_serial_port_data(port);
 	unsigned char *data = urb->transfer_buffer;
+	struct tty_struct *tty;
+	unsigned long flags;
 	int i;
 	int result;
 
@@ -598,7 +625,9 @@
 		}
 		tty_flip_buffer_push(tty);
 	}
-	bytes_in += urb->actual_length;
+	spin_lock_irqsave(&priv->lock, flags);
+	priv->bytes_in += urb->actual_length;
+	spin_unlock_irqrestore(&priv->lock, flags);
 
 	/* Continue trying to always read  */
 	usb_fill_bulk_urb (port->read_urb, port->serial->dev,
@@ -655,7 +684,7 @@
 static void visor_throttle (struct usb_serial_port *port)
 {
 	dbg("%s - port %d", __FUNCTION__, port->number);
-	usb_unlink_urb (port->read_urb);
+	usb_kill_urb(port->read_urb);
 }
 
 
@@ -833,6 +862,22 @@
 	return num_ports;
 }
 
+static int generic_startup(struct usb_serial *serial)
+{
+	struct visor_private *priv;
+	int i;
+
+	for (i = 0; i < serial->num_ports; ++i) {
+		priv = kmalloc (sizeof(*priv), GFP_KERNEL);
+		if (!priv)
+			return -ENOMEM;
+		memset (priv, 0x00, sizeof(*priv));
+		spin_lock_init(&priv->lock);
+		usb_set_serial_port_data(serial->port[i], priv);
+	}
+	return 0;
+}
+
 static int clie_3_5_startup (struct usb_serial *serial)
 {
 	struct device *dev = &serial->dev->dev;
@@ -872,7 +917,7 @@
 		return -EIO;
 	}
 
-	return 0;
+	return generic_startup(serial);
 }
  
 static int treo_attach (struct usb_serial *serial)
@@ -884,7 +929,7 @@
 	if (!((serial->dev->descriptor.idVendor == HANDSPRING_VENDOR_ID) ||
 	      (serial->dev->descriptor.idVendor == KYOCERA_VENDOR_ID)) ||
 	    (serial->num_interrupt_in == 0))
-		return 0;
+		goto generic_startup;
 
 	dbg("%s", __FUNCTION__);
 
@@ -911,7 +956,8 @@
 	COPY_PORT(serial->port[1], swap_port);
 	kfree(swap_port);
 
-	return 0;
+generic_startup:
+	return generic_startup(serial);
 }
 
 static int clie_5_attach (struct usb_serial *serial)
@@ -932,7 +978,7 @@
 	/* port 0 now uses the modified endpoint Address */
 	serial->port[0]->bulk_out_endpointAddress = serial->port[1]->bulk_out_endpointAddress;
 
-	return 0;
+	return generic_startup(serial);
 }
 
 static void visor_shutdown (struct usb_serial *serial)
@@ -1088,8 +1134,11 @@
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debug enabled or not");
+module_param(stats, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(stats, "Enables statistics or not");
 
 module_param(vendor, ushort, 0);
 MODULE_PARM_DESC(vendor, "User specified vendor ID");
 module_param(product, ushort, 0);
 MODULE_PARM_DESC(product, "User specified product ID");
+
diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
--- a/drivers/usb/serial/whiteheat.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/usb/serial/whiteheat.c	2004-12-24 13:36:47 -08:00
@@ -143,7 +143,7 @@
 static void whiteheat_shutdown		(struct usb_serial *serial);
 static int  whiteheat_open		(struct usb_serial_port *port, struct file *filp);
 static void whiteheat_close		(struct usb_serial_port *port, struct file *filp);
-static int  whiteheat_write		(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+static int  whiteheat_write		(struct usb_serial_port *port, const unsigned char *buf, int count);
 static int  whiteheat_write_room	(struct usb_serial_port *port);
 static int  whiteheat_ioctl		(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
 static void whiteheat_set_termios	(struct usb_serial_port *port, struct termios * old);
@@ -679,7 +679,7 @@
 	list_for_each_safe(tmp, tmp2, &info->rx_urbs_submitted) {
 		wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
 		urb = wrap->urb;
-		usb_unlink_urb(urb);
+		usb_kill_urb(urb);
 		list_del(tmp);
 		list_add(tmp, &info->rx_urbs_free);
 	}
@@ -690,7 +690,7 @@
 	list_for_each_safe(tmp, tmp2, &info->tx_urbs_submitted) {
 		wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
 		urb = wrap->urb;
-		usb_unlink_urb(urb);
+		usb_kill_urb(urb);
 		list_del(tmp);
 		list_add(tmp, &info->tx_urbs_free);
 	}
@@ -702,7 +702,7 @@
 }
 
 
-static int whiteheat_write(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+static int whiteheat_write(struct usb_serial_port *port, const unsigned char *buf, int count)
 {
 	struct usb_serial *serial = port->serial;
 	struct whiteheat_private *info = usb_get_serial_port_data(port);
@@ -734,12 +734,7 @@
 		wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
 		urb = wrap->urb;
 		bytes = (count > port->bulk_out_size) ? port->bulk_out_size : count;
-		if (from_user) {
-			if (copy_from_user(urb->transfer_buffer, buf + sent, bytes))
-				return -EFAULT;
-		} else {
-			memcpy (urb->transfer_buffer, buf + sent, bytes);
-		}
+		memcpy (urb->transfer_buffer, buf + sent, bytes);
 
 		usb_serial_debug_data(debug, &port->dev, __FUNCTION__, bytes, urb->transfer_buffer);
 
@@ -1119,11 +1114,11 @@
 	command_port->write_urb->transfer_buffer_length = datasize + 1;
 	command_port->write_urb->dev = port->serial->dev;
 	retval = usb_submit_urb (command_port->write_urb, GFP_KERNEL);
-	spin_unlock_irqrestore(&command_info->lock, flags);
 	if (retval) {
 		dbg("%s - submit urb failed", __FUNCTION__);
 		goto exit;
 	}
+	spin_unlock_irqrestore(&command_info->lock, flags);
 
 	/* wait for the command to complete */
 	wait_event_interruptible_timeout(command_info->wait_command, 
@@ -1343,7 +1338,7 @@
 	spin_lock_irqsave(&command_info->lock, flags);
 	command_info->port_running--;
 	if (!command_info->port_running)
-		usb_unlink_urb(command_port->read_urb);
+		usb_kill_urb(command_port->read_urb);
 	spin_unlock_irqrestore(&command_info->lock, flags);
 }
 
@@ -1371,7 +1366,7 @@
 			list_for_each_safe(tmp, tmp2, &info->rx_urbs_submitted) {
 				wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
 				urb = wrap->urb;
-				usb_unlink_urb(urb);
+				usb_kill_urb(urb);
 				list_del(tmp);
 				list_add(tmp, &info->rx_urbs_free);
 			}
diff -Nru a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
--- a/drivers/usb/storage/Kconfig	2004-12-24 13:37:29 -08:00
+++ b/drivers/usb/storage/Kconfig	2004-12-24 13:37:29 -08:00
@@ -2,16 +2,23 @@
 # USB Storage driver configuration
 #
 
+comment "NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information"
+
 config USB_STORAGE
 	tristate "USB Mass Storage support"
 	depends on USB
 	select SCSI
 	---help---
 	  Say Y here if you want to connect USB mass storage devices to your
-	  computer's USB port. This is the driver you need for USB floppy drives,
-	  USB hard disks, USB tape drives and USB CD-ROMs, along with
-	  similar devices. This driver may also be used for some cameras and
-	  card readers.
+	  computer's USB port. This is the driver you need for USB
+	  floppy drives, USB hard disks, USB tape drives, USB CD-ROMs,
+	  USB flash devices, and memory sticks, along with
+	  similar devices. This driver may also be used for some cameras
+	  and card readers.
+
+	  This option 'selects' (turns on, enables) 'SCSI', but you
+	  probably also need 'SCSI device support: SCSI disk support'
+	  (BLK_DEV_SD) for most USB storage devices.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called usb-storage.
diff -Nru a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
--- a/drivers/usb/storage/freecom.c	2004-12-24 13:37:31 -08:00
+++ b/drivers/usb/storage/freecom.c	2004-12-24 13:37:31 -08:00
@@ -290,7 +290,7 @@
 		case REQUEST_SENSE:		/* 16 or 18 bytes? spec says 18, lots of devices only have 16 */
 		case MODE_SENSE:
 		case MODE_SENSE_10:
-			length = fst->Count;
+			length = le16_to_cpu(fst->Count);
 			break;
 		default:
  			length = srb->request_bufflen;
diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
--- a/drivers/usb/storage/isd200.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/usb/storage/isd200.c	2004-12-24 13:36:49 -08:00
@@ -555,7 +555,7 @@
 	/* if the command gets aborted by the higher layers, we need to
 	 * short-circuit all other processing
 	 */
-	if (us->sm_state == US_STATE_ABORTING) {
+	if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
 		US_DEBUGP("-- command was aborted\n");
 		goto Handle_Abort;
 	}
@@ -602,7 +602,7 @@
 
 	if (need_auto_sense) {
 		result = isd200_read_regs(us);
-		if (us->sm_state == US_STATE_ABORTING) {
+		if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
 			US_DEBUGP("-- auto-sense aborted\n");
 			goto Handle_Abort;
 		}
@@ -1052,12 +1052,6 @@
 
 				/* Standard IDE interface only supports disks */
 				info->InquiryData.DeviceType = DIRECT_ACCESS_DEVICE;
-
-				/* Fix-up the return data from an INQUIRY command to show 
-				 * ANSI SCSI rev 2 so we don't confuse the SCSI layers above us
-				 * in Linux.
-				 */
-				info->InquiryData.Versions = 0x2;
 
 				/* The length must be at least 36 (5 + 31) */
 				info->InquiryData.AdditionalLength = 0x1F;
diff -Nru a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
--- a/drivers/usb/storage/protocol.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/usb/storage/protocol.c	2004-12-24 13:36:16 -08:00
@@ -58,38 +58,6 @@
  ***********************************************************************/
 
 /*
- * Fix-up the return data from an INQUIRY command to show 
- * ANSI SCSI rev 2 so we don't confuse the SCSI layers above us
- */
-static void fix_inquiry_data(struct scsi_cmnd *srb)
-{
-	unsigned char databuf[3];
-	unsigned int index, offset;
-
-	/* verify that it's an INQUIRY command */
-	if (srb->cmnd[0] != INQUIRY)
-		return;
-
-	index = offset = 0;
-	if (usb_stor_access_xfer_buf(databuf, sizeof(databuf), srb,
-			&index, &offset, FROM_XFER_BUF) != sizeof(databuf))
-		return;
-
-	if ((databuf[2] & 7) == 2)
-		return;
-
-	US_DEBUGP("Fixing INQUIRY data to show SCSI rev 2 - was %d\n",
-		  databuf[2] & 7);
-
-	/* Change the SCSI revision number */
-	databuf[2] = (databuf[2] & ~7) | 2;
-
-	index = offset = 0;
-	usb_stor_access_xfer_buf(databuf, sizeof(databuf), srb,
-			&index, &offset, TO_XFER_BUF);
-}
-
-/*
  * Fix-up the return data from a READ CAPACITY command. My Feiya reader
  * returns a value that is 1 too large.
  */
@@ -137,10 +105,6 @@
 
 	/* send the command to the transport layer */
 	usb_stor_invoke_transport(srb, us);
-	if (srb->result == SAM_STAT_GOOD) {
-		/* fix the INQUIRY data if necessary */
-		fix_inquiry_data(srb);
-	}
 }
 
 void usb_stor_ATAPI_command(struct scsi_cmnd *srb, struct us_data *us)
@@ -160,11 +124,6 @@
 
 	/* send the command to the transport layer */
 	usb_stor_invoke_transport(srb, us);
-
-	if (srb->result == SAM_STAT_GOOD) {
-		/* fix the INQUIRY data if necessary */
-		fix_inquiry_data(srb);
-	}
 }
 
 
@@ -208,11 +167,6 @@
 
 	/* send the command to the transport layer */
 	usb_stor_invoke_transport(srb, us);
-
-	if (srb->result == SAM_STAT_GOOD) {
-		/* Fix the data for an INQUIRY, if necessary */
-		fix_inquiry_data(srb);
-	}
 }
 
 void usb_stor_transparent_scsi_command(struct scsi_cmnd *srb,
@@ -222,9 +176,6 @@
 	usb_stor_invoke_transport(srb, us);
 
 	if (srb->result == SAM_STAT_GOOD) {
-		/* Fix the INQUIRY data if necessary */
-		fix_inquiry_data(srb);
-
 		/* Fix the READ CAPACITY result if necessary */
 		if (us->flags & US_FL_FIX_CAPACITY)
 			fix_read_capacity(srb);
diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
--- a/drivers/usb/storage/scsiglue.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/usb/storage/scsiglue.c	2004-12-24 13:36:49 -08:00
@@ -73,14 +73,11 @@
 static int slave_alloc (struct scsi_device *sdev)
 {
 	/*
-	 * Set default bflags. These can be overridden for individual
-	 * models and vendors via the scsi devinfo mechanism.  The only
-	 * flag we need is to force 36-byte INQUIRYs; we don't use any
-	 * of the extra data and many devices choke if asked for more or
+	 * Set the INQUIRY transfer length to 36.  We don't use any of
+	 * the extra data and many devices choke if asked for more or
 	 * less than 36 bytes.
 	 */
-	sdev->sdev_bflags = BLIST_INQUIRY_36;
-
+	sdev->inquiry_len = 36;
 	return 0;
 }
 
@@ -98,6 +95,23 @@
 	 * the end, scatter-gather buffers follow page boundaries. */
 	blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
 
+	/* Set the SCSI level to at least 2.  We'll leave it at 3 if that's
+	 * what is originally reported.  We need this to avoid confusing
+	 * the SCSI layer with devices that report 0 or 1, but need 10-byte
+	 * commands (ala ATAPI devices behind certain bridges, or devices
+	 * which simply have broken INQUIRY data).
+	 *
+	 * NOTE: This means /dev/sg programs (ala cdrecord) will get the
+	 * actual information.  This seems to be the preference for
+	 * programs like that.
+	 *
+	 * NOTE: This also means that /proc/scsi/scsi and sysfs may report
+	 * the actual value or the modified one, depending on where the
+	 * data comes from.
+	 */
+	if (sdev->scsi_level < SCSI_2)
+		sdev->scsi_level = SCSI_2;
+
 	/* According to the technical support people at Genesys Logic,
 	 * devices using their chips have problems transferring more than
 	 * 32 KB at a time.  In practice people have found that 64 KB
@@ -158,18 +172,24 @@
 	US_DEBUGP("%s called\n", __FUNCTION__);
 	srb->host_scribble = (unsigned char *)us;
 
-	/* enqueue the command */
-	if (us->sm_state != US_STATE_IDLE || us->srb != NULL) {
-		printk(KERN_ERR USB_STORAGE "Error in %s: " 
-			"state = %d, us->srb = %p\n",
-			__FUNCTION__, us->sm_state, us->srb);
+	/* check for state-transition errors */
+	if (us->srb != NULL) {
+		printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n",
+			__FUNCTION__, us->srb);
 		return SCSI_MLQUEUE_HOST_BUSY;
 	}
 
+	/* fail the command if we are disconnecting */
+	if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
+		US_DEBUGP("Fail command during disconnect\n");
+		srb->result = DID_NO_CONNECT << 16;
+		done(srb);
+		return 0;
+	}
+
+	/* enqueue the command and wake up the control thread */
 	srb->scsi_done = done;
 	us->srb = srb;
-
-	/* wake up the process task */
 	up(&(us->sema));
 
 	return 0;
@@ -179,7 +199,7 @@
  * Error handling functions
  ***********************************************************************/
 
-/* Command abort */
+/* Command timeout and abort */
 /* This is always called with scsi_lock(srb->host) held */
 static int command_abort(struct scsi_cmnd *srb )
 {
@@ -194,22 +214,12 @@
 		return FAILED;
 	}
 
-	/* Normally the current state is RUNNING.  If the control thread
-	 * hasn't even started processing this command, the state will be
-	 * IDLE.  Anything else is a bug. */
-	if (us->sm_state != US_STATE_RUNNING
-				&& us->sm_state != US_STATE_IDLE) {
-		printk(KERN_ERR USB_STORAGE "Error in %s: "
-			"invalid state %d\n", __FUNCTION__, us->sm_state);
-		return FAILED;
-	}
-
-	/* Set state to ABORTING and set the ABORTING bit, but only if
+	/* Set the TIMED_OUT bit.  Also set the ABORTING bit, but only if
 	 * a device reset isn't already in progress (to avoid interfering
 	 * with the reset).  To prevent races with auto-reset, we must
 	 * stop any ongoing USB transfers while still holding the host
 	 * lock. */
-	us->sm_state = US_STATE_ABORTING;
+	set_bit(US_FLIDX_TIMED_OUT, &us->flags);
 	if (!test_bit(US_FLIDX_RESETTING, &us->flags)) {
 		set_bit(US_FLIDX_ABORTING, &us->flags);
 		usb_stor_stop_transport(us);
@@ -222,6 +232,7 @@
 	/* Reacquire the lock and allow USB transfers to resume */
 	scsi_lock(host);
 	clear_bit(US_FLIDX_ABORTING, &us->flags);
+	clear_bit(US_FLIDX_TIMED_OUT, &us->flags);
 	return SUCCESS;
 }
 
@@ -234,14 +245,7 @@
 	int result;
 
 	US_DEBUGP("%s called\n", __FUNCTION__);
-	if (us->sm_state != US_STATE_IDLE) {
-		printk(KERN_ERR USB_STORAGE "Error in %s: "
-			"invalid state %d\n", __FUNCTION__, us->sm_state);
-		return FAILED;
-	}
 
-	/* set the state and release the lock */
-	us->sm_state = US_STATE_RESETTING;
 	scsi_unlock(srb->device->host);
 
 	/* lock the device pointers and do the reset */
@@ -253,9 +257,8 @@
 		result = us->transport_reset(us);
 	up(&(us->dev_semaphore));
 
-	/* lock access to the state and clear it */
+	/* lock the host for the return */
 	scsi_lock(srb->device->host);
-	us->sm_state = US_STATE_IDLE;
 	return result;
 }
 
@@ -266,17 +269,10 @@
 static int bus_reset(struct scsi_cmnd *srb)
 {
 	struct us_data *us = (struct us_data *)srb->device->host->hostdata[0];
-	int result;
+	int result, rc;
 
 	US_DEBUGP("%s called\n", __FUNCTION__);
-	if (us->sm_state != US_STATE_IDLE) {
-		printk(KERN_ERR USB_STORAGE "Error in %s: "
-			"invalid state %d\n", __FUNCTION__, us->sm_state);
-		return FAILED;
-	}
 
-	/* set the state and release the lock */
-	us->sm_state = US_STATE_RESETTING;
 	scsi_unlock(srb->device->host);
 
 	/* The USB subsystem doesn't handle synchronisation between
@@ -291,14 +287,21 @@
 		result = -EBUSY;
 		US_DEBUGP("Refusing to reset a multi-interface device\n");
 	} else {
-		result = usb_reset_device(us->pusb_dev);
-		US_DEBUGP("usb_reset_device returns %d\n", result);
+		rc = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
+		if (rc < 0) {
+			US_DEBUGP("unable to lock device for reset: %d\n", rc);
+			result = rc;
+		} else {
+			result = usb_reset_device(us->pusb_dev);
+			if (rc)
+				usb_unlock_device(us->pusb_dev);
+			US_DEBUGP("usb_reset_device returns %d\n", result);
+		}
 	}
 	up(&(us->dev_semaphore));
 
-	/* lock access to the state and clear it */
+	/* lock the host for the return */
 	scsi_lock(srb->device->host);
-	us->sm_state = US_STATE_IDLE;
 	return result < 0 ? FAILED : SUCCESS;
 }
 
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/usb/storage/transport.c	2004-12-24 13:36:47 -08:00
@@ -537,7 +537,7 @@
 	/* if the command gets aborted by the higher layers, we need to
 	 * short-circuit all other processing
 	 */
-	if (us->sm_state == US_STATE_ABORTING) {
+	if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
 		US_DEBUGP("-- command was aborted\n");
 		goto Handle_Abort;
 	}
@@ -665,7 +665,7 @@
 		srb->cmd_len = old_cmd_len;
 		memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE);
 
-		if (us->sm_state == US_STATE_ABORTING) {
+		if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
 			US_DEBUGP("-- auto-sense aborted\n");
 			goto Handle_Abort;
 		}
@@ -911,7 +911,6 @@
 	int result;
 
 	/* issue the command */
-	us->iobuf[0] = 0;
 	result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
 				 US_BULK_GET_MAX_LUN, 
 				 USB_DIR_IN | USB_TYPE_CLASS | 
@@ -922,7 +921,7 @@
 		  result, us->iobuf[0]);
 
 	/* if we have a successful request, return the result */
-	if (result >= 0)
+	if (result > 0)
 		return us->iobuf[0];
 
 	/* 
@@ -934,13 +933,16 @@
 	if (result == -EPIPE) {
 		usb_stor_clear_halt(us, us->recv_bulk_pipe);
 		usb_stor_clear_halt(us, us->send_bulk_pipe);
-		/* return the default -- no LUNs */
-		return 0;
 	}
 
-	/* An answer or a STALL are the only valid responses.  If we get
-	 * something else, return an indication of error */
-	return -1;
+	/*
+	 * Some devices don't like GetMaxLUN.  They may STALL the control
+	 * pipe, they may return a zero-length result, they may do nothing at
+	 * all and timeout, or they may fail in even more bizarrely creative
+	 * ways.  In these cases the best approach is to use the default
+	 * value: only one LUN.
+	 */
+	return 0;
 }
 
 int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
@@ -1055,8 +1057,13 @@
 
 	/* try to compute the actual residue, based on how much data
 	 * was really transferred and what the device tells us */
-	residue = min(residue, transfer_length);
-	srb->resid = max(srb->resid, (int) residue);
+	if (residue) {
+		if (!(us->flags & US_FL_IGNORE_RESIDUE) ||
+				srb->sc_data_direction == DMA_TO_DEVICE) {
+			residue = min(residue, transfer_length);
+			srb->resid = max(srb->resid, (int) residue);
+		}
+	}
 
 	/* based on the status code, we report good or bad */
 	switch (bcs->Status) {
diff -Nru a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
--- a/drivers/usb/storage/unusual_devs.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/usb/storage/unusual_devs.h	2004-12-24 13:37:18 -08:00
@@ -36,13 +36,16 @@
 /* If you edit this file, please try to keep it sorted first by VendorID,
  * then by ProductID.
  *
- * If you want to add an entry for this file, please send the following
- * to greg@kroah.com:
- *	- patch that adds the entry for your device which includes your
- *	  email address right above the entry.
+ * If you want to add an entry for this file, be sure to include the
+ * following information:
+ *	- a patch that adds the entry for your device, including your
+ *	  email address right above the entry (plus maybe a brief
+ *	  explanation of the reason for the entry),
  *	- a copy of /proc/bus/usb/devices with your device plugged in
  *	  running with this patch.
- *
+ * Send your submission to either Phil Dibowitz <phil@ipom.com> or
+ * Alan Stern <stern@rowland.harvard.edu>, and don't forget to CC: the
+ * USB development list <linux-usb-devel@lists.sourceforge.net>.
  */
 
 UNUSUAL_DEV(  0x03ee, 0x6901, 0x0000, 0x0100,
@@ -68,16 +71,6 @@
 		US_SC_8070, US_PR_SCM_ATAPI, init_8200e, 0), 
 #endif
 
-/* <torsten.scherer@uni-bielefeld.de>: I don't know the name of the bridge
- * manufacturer, but I've got an external USB drive by the Revoltec company
- * that needs this. otherwise the drive is recognized as /dev/sda, but any
- * access to it blocks indefinitely.
- */
-UNUSUAL_DEV(  0x0402, 0x5621, 0x0103, 0x0103,
-		"Revoltec",
-		"USB/IDE Bridge (ATA/ATAPI)",
-		US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
-
 /* Deduced by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message
  * always fails and confuses drive.
@@ -95,12 +88,6 @@
  		US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ),
 #endif
 
-/* Patch submitted by Alessandro Fracchetti <al.fracchetti@tin.it> */
-UNUSUAL_DEV(  0x0482, 0x0105, 0x0100, 0x0100,
-		"Kyocera",
-		"Finecam L3",
-		US_SC_SCSI, US_PR_BULK, NULL, US_FL_FIX_INQUIRY),
-
 /* Patch submitted by Philipp Friedrich <philipp@void.at> */
 UNUSUAL_DEV(  0x0482, 0x0100, 0x0100, 0x0100,
 		"Kyocera",
@@ -121,6 +108,7 @@
 
 /* Patch for Kyocera Finecam L3
  * Submitted by Michael Krauth <michael.krauth@web.de>
+ * and Alessandro Fracchetti <al.fracchetti@tin.it>
  */
 UNUSUAL_DEV(  0x0482, 0x0105, 0x0100, 0x0100,
 		"Kyocera",
@@ -149,10 +137,13 @@
 		"785EPX Storage",
 		US_SC_SCSI, US_PR_BULK, NULL, US_FL_SINGLE_LUN),
 
+/* Not sure who reported this originally but
+ * Pavel Machek <pavel@ucw.cz> reported that the extra US_FL_SINGLE_LUN
+ * flag be added */
 UNUSUAL_DEV(  0x04cb, 0x0100, 0x0000, 0x2210,
 		"Fujifilm",
 		"FinePix 1400Zoom",
-		US_SC_UFI, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
+		US_SC_UFI, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY | US_FL_SINGLE_LUN),
 
 /* Reported by Peter Wächtler <pwaechtler@loewe-komp.de>
  * The device needs the flags only.
@@ -180,6 +171,16 @@
 		"CD-R/RW Drive",
 		US_SC_8070, US_PR_CB, NULL, 0),
 
+/* Reported by Adriaan Penning <a.penning@luon.net>
+ * Note that these cameras report "Medium not present" after
+ * ALLOW_MEDIUM_REMOVAL, so they also need to be marked
+ * NOT_LOCKABLE in the SCSI blacklist (and the vendor is MATSHITA). */
+UNUSUAL_DEV(  0x04da, 0x2372, 0x0000, 0x9999,
+		"Panasonic",
+		"DMC-LCx Camera",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_FIX_CAPACITY ),
+
 /* Most of the following entries were developed with the help of
  * Shuttle/SCM directly.
  */
@@ -265,6 +266,45 @@
 		US_SC_8070, US_PR_BULK, NULL,
 		US_FL_FIX_INQUIRY ),
 
+/* Yakumo Mega Image 37
+ * Submitted by Stephan Fuhrmann <atomenergie@t-online.de> */
+UNUSUAL_DEV(  0x052b, 0x1801, 0x0100, 0x0100,
+		"Tekom Technologies, Inc",
+		"300_CAMERA",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
+
+/* Another Yakumo camera.
+ * Reported by Michele Alzetta <michele.alzetta@aliceposta.it> */
+UNUSUAL_DEV(  0x052b, 0x1804, 0x0100, 0x0100,
+		"Tekom Technologies, Inc",
+		"300_CAMERA",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
+
+/* Reported by Iacopo Spalletti <avvisi@spalletti.it> */
+UNUSUAL_DEV(  0x052b, 0x1807, 0x0100, 0x0100,
+		"Tekom Technologies, Inc",
+		"300_CAMERA",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
+
+/* Yakumo Mega Image 47
+ * Reported by Bjoern Paetzel <kolrabi@kolrabi.de> */
+UNUSUAL_DEV(  0x052b, 0x1905, 0x0100, 0x0100,
+		"Tekom Technologies, Inc",
+		"400_CAMERA",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
+
+/* Reported by Paul Ortyl <ortylp@3miasto.net>
+ * Note that it's similar to the device above, only different prodID */
+UNUSUAL_DEV(  0x052b, 0x1911, 0x0100, 0x0100,
+		"Tekom Technologies, Inc",
+		"400_CAMERA",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
+
 /* This entry is needed because the device reports Sub=ff */
 UNUSUAL_DEV(  0x054c, 0x0010, 0x0106, 0x0450, 
 		"Sony",
@@ -383,10 +423,17 @@
 		"Digital Camera EX-20 DSC",
 		US_SC_8070, US_PR_DEVICE, NULL, 0 ),
 
+/* The entry was here before I took over, and had US_SC_RBC. It turns
+ * out that isn't needed. Additionally, Torsten Eriksson
+ * <Torsten.Eriksson@bergianska.se> is able to use his device fine
+ * without this entry at all - but I don't suspect that will be true
+ * for all users (the protocol is likely needed), so is staying at
+ * this time. - Phil Dibowitz <phil@ipom.com>
+ */
 UNUSUAL_DEV(  0x059f, 0xa601, 0x0200, 0x0200, 
 		"LaCie",
 		"USB Hard Disk",
-		US_SC_RBC, US_PR_CB, NULL, 0 ), 
+		US_SC_DEVICE, US_PR_CB, NULL, 0 ),
 
 /* Submitted by Joel Bourquard <numlock@freesurf.ch>
  * Some versions of this device need the SubClass and Protocol overrides
@@ -424,6 +471,13 @@
 		0 ),
 #endif
 
+/* Reported by Avi Kivity <avi@argo.co.il> */
+UNUSUAL_DEV( 0x05ac, 0x1203, 0x0001, 0x0001,
+		"Apple",
+		"iPod",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_FIX_CAPACITY ),
+
 #ifdef CONFIG_USB_STORAGE_JUMPSHOT
 UNUSUAL_DEV(  0x05dc, 0x0001, 0x0000, 0x0001,
 		"Lexar",
@@ -439,36 +493,6 @@
 		US_SC_DEVICE, US_PR_DEVICE, NULL,
 		US_FL_FIX_INQUIRY ),
 
-/* Reported by Carlos Villegas <cav@uniscope.co.jp>
- * This device needs an INQUIRY of exactly 36-bytes to function.
- * That is the only reason this entry is needed.
- */
-UNUSUAL_DEV(  0x05e3, 0x0700, 0x0000, 0xffff,
-		"Genesys Logic",
-		"USB to IDE Card Reader",
-		US_SC_DEVICE, US_PR_DEVICE, NULL,
-		US_FL_FIX_INQUIRY ),
-
-/* Submitted Alexander Oltu <alexander@all-2.com> */
-UNUSUAL_DEV(  0x05e3, 0x0701, 0x0000, 0xffff, 
-		"Genesys Logic", 
-		"USB to IDE Optical",
-		US_SC_DEVICE, US_PR_DEVICE, NULL,
-		US_FL_MODE_XLATE ), 
-
-/* Reported by Peter Marks <peter.marks@turner.com>
- * Like the SIIG unit above, this unit needs an INQUIRY to ask for exactly
- * 36 bytes of data.  No more, no less. That is the only reason this entry
- * is needed.
- *
- * ST818 slim drives (rev 0.02) don't need special care.
-*/
-UNUSUAL_DEV(  0x05e3, 0x0702, 0x0000, 0xffff,
-		"Genesys Logic",
-		"USB to IDE Disk",
-		US_SC_DEVICE, US_PR_DEVICE, NULL,
-		US_FL_FIX_INQUIRY ),
-
 /* Reported by Hanno Boeck <hanno@gmx.de>
  * Taken from the Lycoris Kernel */
 UNUSUAL_DEV(  0x0636, 0x0003, 0x0000, 0x9999,
@@ -554,6 +578,13 @@
 		US_SC_QIC, US_PR_FREECOM, freecom_init, 0),
 #endif
 
+/* Reported by Eero Volotinen <eero@ping-viini.org> */
+UNUSUAL_DEV(  0x07ab, 0xfccd, 0x0406, 0x0406,
+		"Freecom Technologies",
+		"FHD-Classic",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_FIX_CAPACITY),
+
 UNUSUAL_DEV(  0x07af, 0x0004, 0x0100, 0x0133, 
 		"Microtech",
 		"USB-SCSI-DB25",
@@ -724,12 +755,6 @@
  		US_SC_DEVICE, US_PR_DEVICE, NULL,
 		US_FL_MODE_XLATE ),
 
-UNUSUAL_DEV(  0x0a16, 0x8888, 0x0100, 0x0100,
-		"IBM",
-		"IBM USB Memory Key",
-		US_SC_DEVICE, US_PR_DEVICE, NULL,
-		US_FL_FIX_INQUIRY ),
-
 /* This Pentax still camera is not conformant
  * to the USB storage specification: -
  * - It does not like the INQUIRY command. So we must handle this command
@@ -802,13 +827,28 @@
 		US_SC_DEVICE, US_PR_DEVICE, NULL,
 		US_FL_FIX_INQUIRY ),
 
+/* Patch by Stephan Walter <stephan.walter@epfl.ch>
+ * I don't know why, but it works... */
+UNUSUAL_DEV( 0x0dda, 0x0001, 0x0012, 0x0012,
+		"WINWARD",
+		"Music Disk",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
+
 /* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */
 UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
 		"USB",
 		"Solid state disk",
 		US_SC_DEVICE, US_PR_DEVICE, NULL,
 		US_FL_FIX_INQUIRY ),
-		
+
+/* Reported by Rastislav Stanik <rs_kernel@yahoo.com> */
+UNUSUAL_DEV(  0x0ea0, 0x6828, 0x0110, 0x0110,
+		"USB",
+		"Flash Disk",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
+
 /* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
  * Tested on hardware version 1.10.
  * Entry is needed only for the initializer function override.
@@ -829,6 +869,13 @@
 		"EasyDisk Portable Device",
 		US_SC_DEVICE, US_PR_DEVICE, NULL,
 		US_FL_MODE_XLATE ),
+
+/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */
+UNUSUAL_DEV(  0x1370, 0x6828, 0x0110, 0x0110,
+		"SWISSBIT",
+		"Black Silver",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
 
 #ifdef CONFIG_USB_STORAGE_SDDR55
 UNUSUAL_DEV(  0x55aa, 0xa103, 0x0000, 0x9999, 
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/usb/storage/usb.c	2004-12-24 13:36:31 -08:00
@@ -50,6 +50,7 @@
 #include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <linux/suspend.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -97,6 +98,11 @@
 MODULE_DESCRIPTION("USB Mass Storage driver for Linux");
 MODULE_LICENSE("GPL");
 
+static unsigned int delay_use = 5;
+module_param(delay_use, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
+
+
 static int storage_probe(struct usb_interface *iface,
 			 const struct usb_device_id *id);
 
@@ -312,8 +318,8 @@
 		/* lock access to the state */
 		scsi_lock(host);
 
-		/* has the command been aborted *already* ? */
-		if (us->sm_state == US_STATE_ABORTING) {
+		/* has the command timed out *already* ? */
+		if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
 			us->srb->result = DID_ABORT << 16;
 			goto SkipForAbort;
 		}
@@ -324,8 +330,6 @@
 			goto SkipForDisconnect;
 		}
 
-		/* set the state and release the lock */
-		us->sm_state = US_STATE_RUNNING;
 		scsi_unlock(host);
 
 		/* reject the command if the direction indicator 
@@ -386,16 +390,15 @@
 
 		/* If an abort request was received we need to signal that
 		 * the abort has finished.  The proper test for this is
-		 * sm_state == US_STATE_ABORTING, not srb->result == DID_ABORT,
-		 * because an abort request might be received after all the
+		 * the TIMED_OUT flag, not srb->result == DID_ABORT, because
+		 * a timeout/abort request might be received after all the
 		 * USB processing was complete. */
-		if (us->sm_state == US_STATE_ABORTING)
+		if (test_bit(US_FLIDX_TIMED_OUT, &us->flags))
 			complete(&(us->notify));
 
-		/* empty the queue, reset the state, and release the lock */
+		/* finished working on this command */
 SkipForDisconnect:
 		us->srb = NULL;
-		us->sm_state = US_STATE_IDLE;
 		scsi_unlock(host);
 
 		/* unlock the device pointers */
@@ -795,7 +798,6 @@
 	us->host->hostdata[0] = (unsigned long) us;
 
 	/* Start up our control thread */
-	us->sm_state = US_STATE_IDLE;
 	p = kernel_thread(usb_stor_control_thread, us, CLONE_VM);
 	if (p < 0) {
 		printk(KERN_WARNING USB_STORAGE 
@@ -823,7 +825,6 @@
 		/* Wait for the thread to be idle */
 		down(&us->dev_semaphore);
 		US_DEBUGP("-- sending exit command to thread\n");
-		BUG_ON(us->sm_state != US_STATE_IDLE);
 
 		/* If the SCSI midlayer queued a final command just before
 		 * scsi_remove_host() was called, us->srb might not be
@@ -882,6 +883,46 @@
 	kfree(us);
 }
 
+/* Thread to carry out delayed SCSI-device scanning */
+static int usb_stor_scan_thread(void * __us)
+{
+	struct us_data *us = (struct us_data *)__us;
+
+	/*
+	 * This thread doesn't need any user-level access,
+	 * so get rid of all our resources.
+	 */
+	lock_kernel();
+	daemonize("usb-stor-scan");
+	unlock_kernel();
+
+	printk(KERN_DEBUG
+		"usb-storage: device found at %d\n", us->pusb_dev->devnum);
+
+	/* Wait for the timeout to expire or for a disconnect */
+	if (delay_use > 0) {
+		printk(KERN_DEBUG "usb-storage: waiting for device "
+				"to settle before scanning\n");
+retry:
+		wait_event_interruptible_timeout(us->scsi_scan_wait,
+				test_bit(US_FLIDX_DISCONNECTING, &us->flags),
+				delay_use * HZ);
+		if (current->flags & PF_FREEZE) {
+			refrigerator(PF_FREEZE);
+			goto retry;
+		}
+	}
+
+	/* If the device is still connected, perform the scanning */
+	if (!test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
+		scsi_scan_host(us->host);
+		printk(KERN_DEBUG "usb-storage: device scan complete\n");
+	}
+
+	complete_and_exit(&us->scsi_scan_done, 0);
+}
+
+
 /* Probe to see if we can drive a newly-connected USB device */
 static int storage_probe(struct usb_interface *intf,
 			 const struct usb_device_id *id)
@@ -903,6 +944,8 @@
 	init_MUTEX_LOCKED(&(us->sema));
 	init_completion(&(us->notify));
 	init_waitqueue_head(&us->dev_reset_wait);
+	init_waitqueue_head(&us->scsi_scan_wait);
+	init_completion(&us->scsi_scan_done);
 
 	/* Associate the us_data structure with the USB device */
 	result = associate_dev(us, intf);
@@ -951,12 +994,10 @@
 	if (result)
 		goto BadDevice;
 
-	/* Acquire all the other resources */
+	/* Acquire all the other resources and add the host */
 	result = usb_stor_acquire_resources(us);
 	if (result)
 		goto BadDevice;
-
-	/* Finally, add the host (this does SCSI device scanning) */
 	result = scsi_add_host(us->host, &intf->dev);
 	if (result) {
 		printk(KERN_WARNING USB_STORAGE
@@ -964,10 +1005,15 @@
 		goto BadDevice;
 	}
 
-	scsi_scan_host(us->host);
+	/* Start up the thread for delayed SCSI-device scanning */
+	result = kernel_thread(usb_stor_scan_thread, us, CLONE_VM);
+	if (result < 0) {
+		printk(KERN_WARNING USB_STORAGE 
+		       "Unable to start the device-scanning thread\n");
+		scsi_remove_host(us->host);
+		goto BadDevice;
+	}
 
-	printk(KERN_DEBUG 
-	       "USB Mass Storage device found at %d\n", us->pusb_dev->devnum);
 	return 0;
 
 	/* We come here if there are any problems */
@@ -991,6 +1037,11 @@
 	usb_stor_stop_transport(us);
 	wake_up(&us->dev_reset_wait);
 
+	/* Interrupt the SCSI-device-scanning thread's time delay, and
+	 * wait for the thread to finish */
+	wake_up(&us->scsi_scan_wait);
+	wait_for_completion(&us->scsi_scan_done);
+
 	/* Wait for the current command to finish, then remove the host */
 	down(&us->dev_semaphore);
 	up(&us->dev_semaphore);
@@ -1012,12 +1063,9 @@
 
 	/* register the driver, return usb_register return code if error */
 	retval = usb_register(&usb_storage_driver);
-	if (retval)
-		goto out;
+	if (retval == 0)
+		printk(KERN_INFO "USB Mass Storage support registered.\n");
 
-	/* we're all set */
-	printk(KERN_INFO "USB Mass Storage support registered.\n");
-out:
 	return retval;
 }
 
diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
--- a/drivers/usb/storage/usb.h	2004-12-24 13:37:01 -08:00
+++ b/drivers/usb/storage/usb.h	2004-12-24 13:37:01 -08:00
@@ -73,6 +73,7 @@
 #define US_FL_SCM_MULT_TARG   0x00000020 /* supports multiple targets	    */
 #define US_FL_FIX_INQUIRY     0x00000040 /* INQUIRY response needs faking   */
 #define US_FL_FIX_CAPACITY    0x00000080 /* READ CAPACITY response too big  */
+#define US_FL_IGNORE_RESIDUE  0x00000100 /* reported residue is wrong	    */
 
 /* Dynamic flag definitions: used in set_bit() etc. */
 #define US_FLIDX_URB_ACTIVE	18  /* 0x00040000  current_urb is in use  */
@@ -82,14 +83,9 @@
 #define ABORTING_OR_DISCONNECTING	((1UL << US_FLIDX_ABORTING) | \
 					 (1UL << US_FLIDX_DISCONNECTING))
 #define US_FLIDX_RESETTING	22  /* 0x00400000  device reset in progress */
+#define US_FLIDX_TIMED_OUT	23  /* 0x00800000  SCSI midlayer timed out  */
 
 
-/* processing state machine states */
-#define US_STATE_IDLE		1
-#define US_STATE_RUNNING	2
-#define US_STATE_RESETTING	3
-#define US_STATE_ABORTING	4
-
 #define USB_STOR_STRING_LEN 32
 
 /*
@@ -147,7 +143,6 @@
 
 	/* thread information */
 	int			pid;		 /* control thread	 */
-	int			sm_state;	 /* what we are doing	 */
 
 	/* control and bulk communications data */
 	struct urb		*current_urb;	 /* USB requests	 */
@@ -161,6 +156,8 @@
 	struct semaphore	sema;		 /* to sleep thread on   */
 	struct completion	notify;		 /* thread begin/end	 */
 	wait_queue_head_t	dev_reset_wait;  /* wait during reset    */
+	wait_queue_head_t	scsi_scan_wait;	 /* wait before scanning */
+	struct completion	scsi_scan_done;	 /* scan thread end	 */
 
 	/* subdriver information */
 	void			*extra;		 /* Any extra data          */
diff -Nru a/drivers/video/Kconfig b/drivers/video/Kconfig
--- a/drivers/video/Kconfig	2004-12-24 13:36:17 -08:00
+++ b/drivers/video/Kconfig	2004-12-24 13:36:17 -08:00
@@ -41,7 +41,7 @@
 config FB_MODE_HELPERS
         bool "Enable Video Mode Handling Helpers"
         depends on FB
-	default y
+	default n
 	---help---
 	  This enables functions for handling video modes using the
 	  Generalized Timing Formula and the EDID parser. A few drivers rely
@@ -49,6 +49,24 @@
 	  your driver does not take advantage of this feature, choosing Y will
 	  just increase the kernel size by about 5K.
 
+config FB_TILEBLITTING
+       bool "Enable Tile Blitting Support"
+       depends on FB
+       default n
+       ---help---
+         This enables tile blitting.  Tile blitting is a drawing technique
+	 where the screen is divided into rectangular sections (tiles), whereas
+	 the standard blitting divides the screen into pixels. Because the
+	 default drawing element is a tile, drawing functions will be passed
+	 parameters in terms of number of tiles instead of number of pixels.
+	 For example, to draw a single character, instead of using bitmaps,
+	 an index to an array of bitmaps will be used.  To clear or move a
+	 rectangular section of a screen, the rectangle will be described in
+	 terms of number of tiles in the x- and y-axis.
+
+	 This is particularly important to one driver, matroxfb.  If
+	 unsure, say N.
+
 config FB_CIRRUS
 	tristate "Cirrus Logic support"
 	depends on FB && (ZORRO || PCI)
@@ -499,6 +517,27 @@
   
           If unsure, say N.
 
+config FB_INTEL
+	tristate "Intel 830M/845G/852GM/855GM/865G support (EXPERIMENTAL)"
+	depends on FB && EXPERIMENTAL && PCI && X86 && !X86_64
+	select AGP
+	select AGP_INTEL
+	help
+	  This driver supports the on-board graphics built in to the Intel
+          830M/845G/852GM/855GM/865G chipsets.
+          Say Y if you have and plan to use such a board.
+
+          To compile this driver as a module, choose M here: the
+	  module will be called intelfb.
+
+config FB_INTEL_DEBUG
+        bool "Intel driver Debug Messages"
+	depends on FB_INTEL
+	---help---
+	  Say Y here if you want the Intel driver to output all sorts
+	  of debugging informations to provide to the maintainer when
+	  something goes wrong.
+
 config FB_MATROX
 	tristate "Matrox acceleration"
 	depends on FB && PCI
@@ -732,6 +771,19 @@
 	  framebuffer device.  The ATI product support page for these boards
 	  is at <http://support.ati.com/products/pc/mach64/>.
 
+config FB_ATY_GENERIC_LCD
+	bool "Mach64 generic LCD support (EXPERIMENTAL)"
+	depends on FB_ATY_CT
+	help
+	  Say Y if you have a laptop with an ATI Rage LT PRO, Rage Mobility,
+	  Rage XC, or Rage XL chipset.
+
+config FB_ATY_XL_INIT
+	bool "Rage XL No-BIOS Init support"
+	depends on FB_ATY_CT
+	help
+	  Say Y here to support booting a Rage XL without BIOS support.
+
 config FB_ATY_GX
 	bool "Mach64 GX support" if PCI
 	depends on FB_ATY
@@ -743,11 +795,41 @@
 	  is at
 	  <http://support.ati.com/products/pc/mach64/graphics_xpression.html>.
 
-config FB_ATY_XL_INIT
-	bool "  Rage XL No-BIOS Init support" if FB_ATY_CT
-	depends on FB_ATY
+config FB_SAVAGE
+	tristate "S3 Savage support"
+	depends on FB && PCI && EXPERIMENTAL
+	select I2C_ALGOBIT if FB_SAVAGE_I2C
+	select I2C if FB_SAVAGE_I2C
+	select FB_MODE_HELPERS
 	help
-	  Say Y here to support booting a Rage XL without BIOS support.
+	  This driver supports notebooks and computers with S3 Savage PCI/AGP
+	  chips.
+
+	  Say Y if you have such a graphics card.
+
+	  To compile this driver as a module, choose M here; the module
+	  will be called savagefb.
+
+config FB_SAVAGE_I2C
+       tristate "Enable DDC2 Support"
+       depends on FB_SAVAGE
+       help
+	  This enables I2C support for S3 Savage Chipsets.  This is used
+	  only for getting EDID information from the attached display
+	  allowing for robust video mode handling and switching.
+
+	  Because fbdev-2.6 requires that drivers must be able to
+	  independently validate video mode parameters, you should say Y
+	  here.
+
+config FB_SAVAGE_ACCEL
+       tristate "Enable Console Acceleration"
+       depends on FB_SAVAGE
+       default n
+       help
+          This option will compile in console acceleration support. If
+          the resulting framebuffer console has bothersome glitches, then
+          choose N here.
 
 config FB_SIS
 	tristate "SiS acceleration"
diff -Nru a/drivers/video/Makefile b/drivers/video/Makefile
--- a/drivers/video/Makefile	2004-12-24 13:36:18 -08:00
+++ b/drivers/video/Makefile	2004-12-24 13:36:18 -08:00
@@ -23,15 +23,20 @@
 obj-$(CONFIG_FB_PM3)		  += pm3fb.o
 
 obj-$(CONFIG_FB_MATROX)		  += matrox/ cfbfillrect.o cfbcopyarea.o cfbimgblt.o
-obj-$(CONFIG_FB_RIVA)		  += riva/ cfbimgblt.o vgastate.o
+obj-$(CONFIG_FB_RIVA)		  += riva/ cfbimgblt.o cfbfillrect.o \
+				     cfbcopyarea.o vgastate.o
 obj-$(CONFIG_FB_ATY)		  += aty/ cfbcopyarea.o cfbfillrect.o cfbimgblt.o
 obj-$(CONFIG_FB_ATY128)		  += aty/ cfbcopyarea.o cfbfillrect.o cfbimgblt.o
 obj-$(CONFIG_FB_RADEON)		  += aty/ cfbcopyarea.o cfbfillrect.o cfbimgblt.o
 obj-$(CONFIG_FB_SIS)		  += sis/ cfbcopyarea.o cfbfillrect.o cfbimgblt.o
 obj-$(CONFIG_FB_KYRO)             += kyro/ cfbfillrect.o cfbcopyarea.o cfbimgblt.o
-
+obj-$(CONFIG_FB_SAVAGE)		  += savage/ cfbfillrect.o cfbcopyarea.o \
+				     cfbimgblt.o
 obj-$(CONFIG_FB_I810)             += cfbcopyarea.o cfbfillrect.o cfbimgblt.o \
 				     vgastate.o
+obj-$(CONFIG_FB_INTEL)            += cfbfillrect.o cfbcopyarea.o \
+	                             cfbimgblt.o
+
 obj-$(CONFIG_FB_RADEON_OLD)	  += radeonfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
 obj-$(CONFIG_FB_NEOMAGIC)         += neofb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o vgastate.o
 obj-$(CONFIG_FB_VIRGE)            += virgefb.o
diff -Nru a/drivers/video/acornfb.c b/drivers/video/acornfb.c
--- a/drivers/video/acornfb.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/video/acornfb.c	2004-12-24 13:37:29 -08:00
@@ -1280,13 +1280,7 @@
 	printk("acornfb: freed %dK memory\n", mb_freed);
 }
 
-static struct device acornfb_device = {
-	.bus_id			= "acornfb",
-	.coherent_dma_mask	= 0xffffffff,
-};
-
-int __init
-acornfb_init(void)
+static int __init acornfb_probe(struct device *dev)
 {
 	unsigned long size;
 	u_int h_sync, v_sync;
@@ -1299,7 +1293,7 @@
 
 	acornfb_init_fbinfo();
 
-	current_par.dev = &acornfb_device;
+	current_par.dev = dev;
 
 	if (current_par.montype == -1)
 		current_par.montype = acornfb_detect_monitortype();
@@ -1332,7 +1326,6 @@
 		}
 	}
 
-	fb_info.currcon	       = -1;
 	fb_info.screen_base    = (char *)SCREEN_BASE;
 	fb_info.fix.smem_start = SCREEN_START;
 	current_par.using_vram = 0;
@@ -1459,6 +1452,17 @@
 	if (register_framebuffer(&fb_info) < 0)
 		return -EINVAL;
 	return 0;
+}
+
+static struct device_driver acornfb_driver = {
+	.name	= "acornfb",
+	.bus	= &platform_bus_type,
+	.probe	= acornfb_probe,
+};
+
+static int __init acornfb_init(void)
+{
+	return driver_register(&acornfb_driver);
 }
 
 module_init(acornfb_init);
diff -Nru a/drivers/video/amifb.c b/drivers/video/amifb.c
--- a/drivers/video/amifb.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/video/amifb.c	2004-12-24 13:37:18 -08:00
@@ -1239,8 +1239,6 @@
 		if (!strcmp(this_opt, "inverse")) {
 			amifb_inverse = 1;
 			fb_invert_cmaps();
-		} else if (!strcmp(this_opt, "off")) {
-			amifb_video_off();
 		} else if (!strcmp(this_opt, "ilbm"))
 			amifb_ilbm = 1;
 		else if (!strncmp(this_opt, "monitorcap:", 11))
@@ -2260,27 +2258,16 @@
 #ifndef MODULE
 	char *option = NULL;
 
-	if (fb_get_options("amifb", &option))
+	if (fb_get_options("amifb", &option)) {
+		amifb_video_off();
 		return -ENODEV;
+	}
 	amifb_setup(option);
 #endif
 	if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_VIDEO))
 		return -ENXIO;
 
 	/*
-	 * TODO: where should we put this? The DMI Resolver doesn't have a
-	 *	 frame buffer accessible by the CPU
-	 */
-
-#ifdef CONFIG_GSP_RESOLVER
-	if (amifb_resolver){
-		custom.dmacon = DMAF_MASTER | DMAF_RASTER | DMAF_COPPER |
-				DMAF_BLITTER | DMAF_SPRITE;
-		return 0;
-	}
-#endif
-
-	/*
 	 * We request all registers starting from bplpt[0]
 	 */
 	if (!request_mem_region(CUSTOM_PHYSADDR+0xe0, 0x120,
@@ -2482,6 +2469,7 @@
 static int amifb_blank(int blank, struct fb_info *info)
 {
 	do_blank = blank ? blank : -1;
+
 	return 0;
 }
 
@@ -2956,21 +2944,11 @@
 	var->bits_per_pixel = par->bpp;
 	var->grayscale = 0;
 
-	if (IS_AGA) {
-		var->red.offset = 0;
-		var->red.length = 8;
-		var->red.msb_right = 0;
-	} else {
-		if (clk_shift == TAG_SHRES) {
-			var->red.offset = 0;
-			var->red.length = 2;
-			var->red.msb_right = 0;
-		} else {
-			var->red.offset = 0;
-			var->red.length = 4;
-			var->red.msb_right = 0;
-		}
-	}
+	var->red.offset = 0;
+	var->red.msb_right = 0;
+	var->red.length = par->bpp;
+	if (par->bplcon0 & BPC0_HAM)
+	    var->red.length -= 2;
 	var->blue = var->green = var->red;
 	var->transp.offset = 0;
 	var->transp.length = 0;
@@ -3270,20 +3248,20 @@
 		custom.dmacon = DMAF_RASTER | DMAF_SPRITE;
 		red = green = blue = 0;
 		if (!IS_OCS && do_blank > 1) {
-			switch (do_blank-1) {
-				case VESA_VSYNC_SUSPEND:
+			switch (do_blank) {
+				case FB_BLANK_VSYNC_SUSPEND:
 					custom.hsstrt = hsstrt2hw(par->hsstrt);
 					custom.hsstop = hsstop2hw(par->hsstop);
 					custom.vsstrt = vsstrt2hw(par->vtotal+4);
 					custom.vsstop = vsstop2hw(par->vtotal+4);
 					break;
-				case VESA_HSYNC_SUSPEND:
+				case FB_BLANK_HSYNC_SUSPEND:
 					custom.hsstrt = hsstrt2hw(par->htotal+16);
 					custom.hsstop = hsstop2hw(par->htotal+16);
 					custom.vsstrt = vsstrt2hw(par->vsstrt);
 					custom.vsstop = vsstrt2hw(par->vsstop);
 					break;
-				case VESA_POWERDOWN:
+				case FB_BLANK_POWERDOWN:
 					custom.hsstrt = hsstrt2hw(par->htotal+16);
 					custom.hsstop = hsstop2hw(par->htotal+16);
 					custom.vsstrt = vsstrt2hw(par->vtotal+4);
diff -Nru a/drivers/video/asiliantfb.c b/drivers/video/asiliantfb.c
--- a/drivers/video/asiliantfb.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/video/asiliantfb.c	2004-12-24 13:37:19 -08:00
@@ -575,9 +575,6 @@
 
 	init_asiliant(p, addr);
 
-	/* Clear the entire framebuffer */
-	memset(p->screen_base, 0, 0x200000);
-
 	pci_set_drvdata(dp, p);
 	return 0;
 }
diff -Nru a/drivers/video/aty/Makefile b/drivers/video/aty/Makefile
--- a/drivers/video/aty/Makefile	2004-12-24 13:36:33 -08:00
+++ b/drivers/video/aty/Makefile	2004-12-24 13:36:33 -08:00
@@ -2,9 +2,9 @@
 obj-$(CONFIG_FB_ATY128) += aty128fb.o
 obj-$(CONFIG_FB_RADEON) += radeonfb.o
 
-atyfb-y				:= atyfb_base.o mach64_accel.o
+atyfb-y				:= atyfb_base.o mach64_accel.o mach64_cursor.o
 atyfb-$(CONFIG_FB_ATY_GX)	+= mach64_gx.o
-atyfb-$(CONFIG_FB_ATY_CT)	+= mach64_ct.o mach64_cursor.o
+atyfb-$(CONFIG_FB_ATY_CT)	+= mach64_ct.o
 atyfb-objs			:= $(atyfb-y)
 
 radeonfb-y			:= radeon_base.o radeon_pm.o radeon_monitor.o radeon_accel.o
diff -Nru a/drivers/video/aty/ati_ids.h b/drivers/video/aty/ati_ids.h
--- a/drivers/video/aty/ati_ids.h	2004-12-24 13:36:47 -08:00
+++ b/drivers/video/aty/ati_ids.h	2004-12-24 13:36:47 -08:00
@@ -64,6 +64,7 @@
 #define PCI_CHIP_MACH64LQ		0x4C51
 #define PCI_CHIP_MACH64LR		0x4C52
 #define PCI_CHIP_MACH64LS		0x4C53
+#define PCI_CHIP_MACH64LT		0x4C54
 #define PCI_CHIP_RADEON_LW		0x4C57
 #define PCI_CHIP_RADEON_LX		0x4C58
 #define PCI_CHIP_RADEON_LY		0x4C59
diff -Nru a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
--- a/drivers/video/aty/aty128fb.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/video/aty/aty128fb.c	2004-12-24 13:36:49 -08:00
@@ -397,7 +397,7 @@
 	struct aty128_ddafifo fifo_reg;
 	u32 accel_flags;
 	struct aty128_constants constants;  /* PLL and others      */
-	void *regbase;                      /* remapped mmio       */
+	void __iomem *regbase;              /* remapped mmio       */
 	u32 vram_size;                      /* onboard video ram   */
 	int chip_gen;
 	const struct aty128_meminfo *mem;   /* onboard mem info    */
@@ -450,9 +450,9 @@
                              struct aty128fb_par *par);
 #if 0
 static void __init aty128_get_pllinfo(struct aty128fb_par *par,
-				      void *bios);
-static void __init *aty128_map_ROM(struct pci_dev *pdev, const struct aty128fb_par *par);
-static void __init aty128_unmap_ROM(struct pci_dev *dev, void * rom);
+				      void __iomem *bios);
+static void __init __iomem *aty128_map_ROM(struct pci_dev *pdev, const struct aty128fb_par *par);
+static void __init aty128_unmap_ROM(struct pci_dev *dev, void __iomem * rom);
 #endif
 static void aty128_timings(struct aty128fb_par *par);
 static void aty128_init_engine(struct aty128fb_par *par);
@@ -788,7 +788,7 @@
 
 
 #ifndef __sparc__
-static void __init aty128_unmap_ROM(struct pci_dev *dev, void * rom)
+static void __init aty128_unmap_ROM(struct pci_dev *dev, void __iomem * rom)
 {
 	struct resource *r = &dev->resource[PCI_ROM_RESOURCE];
 	
@@ -806,12 +806,12 @@
 }
 
 
-static void * __init aty128_map_ROM(const struct aty128fb_par *par, struct pci_dev *dev)
+static void __iomem * __init aty128_map_ROM(const struct aty128fb_par *par, struct pci_dev *dev)
 {
 	struct resource *r;
 	u16 dptr;
 	u8 rom_type;
-	void *bios;
+	void __iomem *bios;
 
     	/* Fix from ATI for problem with Rage128 hardware not leaving ROM enabled */
     	unsigned int temp;
@@ -903,7 +903,7 @@
 	return NULL;
 }
 
-static void __init aty128_get_pllinfo(struct aty128fb_par *par, unsigned char *bios)
+static void __init aty128_get_pllinfo(struct aty128fb_par *par, unsigned char __iomem *bios)
 {
 	unsigned int bios_hdr;
 	unsigned int bios_pll;
@@ -925,7 +925,7 @@
 }           
 
 #ifdef CONFIG_X86
-static void *  __devinit aty128_find_mem_vbios(struct aty128fb_par *par)
+static void __iomem *  __devinit aty128_find_mem_vbios(struct aty128fb_par *par)
 {
 	/* I simplified this code as we used to miss the signatures in
 	 * a lot of case. It's now closer to XFree, we just don't check
@@ -933,13 +933,13 @@
 	 * if we end up having conflicts
 	 */
         u32  segstart;
-        unsigned char *rom_base = NULL;
+        unsigned char __iomem *rom_base = NULL;
                                                 
         for (segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) {
-                rom_base = (char *)ioremap(segstart, 0x10000);
+                rom_base = ioremap(segstart, 0x10000);
 		if (rom_base == NULL)
 			return NULL;
-                if ((*rom_base == 0x55) && (((*(rom_base + 1)) & 0xff) == 0xaa))
+		if (readb(rom_base) == 0x55 && readb(rom_base + 1) == 0xaa)
 	                break;
                 iounmap(rom_base);
 		rom_base = NULL;
@@ -1885,7 +1885,7 @@
 	struct fb_info *info;
 	int err;
 #ifndef __sparc__
-	void *bios = NULL;
+	void __iomem *bios = NULL;
 #endif
 
 	/* Enable device in PCI config */
@@ -2016,8 +2016,6 @@
 
 	release_mem_region(pci_resource_start(pdev, 0),
 			   pci_resource_len(pdev, 0));
-	release_mem_region(pci_resource_start(pdev, 1),
-			   pci_resource_len(pdev, 1));
 	release_mem_region(pci_resource_start(pdev, 2),
 			   pci_resource_len(pdev, 2));
 	framebuffer_release(info);
@@ -2042,11 +2040,11 @@
 		set_backlight_enable(0);
 #endif /* CONFIG_PMAC_BACKLIGHT */
 
-	if (blank & VESA_VSYNC_SUSPEND)
+	if (blank & FB_BLANK_VSYNC_SUSPEND)
 		state |= 2;
-	if (blank & VESA_HSYNC_SUSPEND)
+	if (blank & FB_BLANK_HSYNC_SUSPEND)
 		state |= 1;
-	if (blank & VESA_POWERDOWN)
+	if (blank & FB_BLANK_POWERDOWN)
 		state |= 4;
 
 	aty_st_8(CRTC_EXT_CNTL+1, state);
@@ -2363,7 +2361,7 @@
 		state = 2;
 #endif /* CONFIG_PPC_PMAC */
 	 
-	if (state != 2 || state == pdev->dev.power_state)
+	if (state != 2 || state == pdev->dev.power.power_state)
 		return 0;
 
 	printk(KERN_DEBUG "aty128fb: suspending...\n");
@@ -2394,7 +2392,7 @@
 
 	release_console_sem();
 
-	pdev->dev.power_state = state;
+	pdev->dev.power.power_state = state;
 
 	return 0;
 }
@@ -2404,13 +2402,13 @@
 	struct fb_info *info = pci_get_drvdata(pdev);
 	struct aty128fb_par *par = info->par;
 
-	if (pdev->dev.power_state == 0)
+	if (pdev->dev.power.power_state == 0)
 		return 0;
 
 	acquire_console_sem();
 
 	/* Wakeup chip */
-	if (pdev->dev.power_state == 2)
+	if (pdev->dev.power.power_state == 2)
 		aty128_set_suspend(par, 0);
 	par->asleep = 0;
 
@@ -2430,7 +2428,7 @@
 
 	release_console_sem();
 
-	pdev->dev.power_state = 0;
+	pdev->dev.power.power_state = 0;
 
 	printk(KERN_DEBUG "aty128fb: resumed !\n");
 
diff -Nru a/drivers/video/aty/atyfb.h b/drivers/video/aty/atyfb.h
--- a/drivers/video/aty/atyfb.h	2004-12-24 13:37:01 -08:00
+++ b/drivers/video/aty/atyfb.h	2004-12-24 13:37:01 -08:00
@@ -3,6 +3,8 @@
  */
 
 #include <linux/config.h>
+#include <linux/spinlock.h>
+#include <linux/wait.h>
     /*
      *  Elements of the hardware specific atyfb_par structure
      */
@@ -10,16 +12,60 @@
 struct crtc {
 	u32 vxres;
 	u32 vyres;
+	u32 xoffset;
+	u32 yoffset;
+	u32 bpp;
 	u32 h_tot_disp;
 	u32 h_sync_strt_wid;
 	u32 v_tot_disp;
 	u32 v_sync_strt_wid;
+	u32 vline_crnt_vline;
 	u32 off_pitch;
 	u32 gen_cntl;
 	u32 dp_pix_width;	/* acceleration */
 	u32 dp_chain_mask;	/* acceleration */
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	u32 horz_stretching;
+	u32 vert_stretching;
+	u32 ext_vert_stretch;
+	u32 shadow_h_tot_disp;
+	u32 shadow_h_sync_strt_wid;
+	u32 shadow_v_tot_disp;
+	u32 shadow_v_sync_strt_wid;
+	u32 lcd_gen_cntl;
+	u32 lcd_config_panel;
+	u32 lcd_index;
+#endif
+};
+
+struct aty_interrupt {
+	wait_queue_head_t wait;
+	unsigned int count;
+	int pan_display;
+};
+
+struct pll_info {
+	int pll_max;
+	int pll_min;
+	int sclk, mclk, mclk_pm, xclk;
+	int ref_div;
+	int ref_clk;
 };
 
+typedef struct {
+	u16 unknown1;
+	u16 PCLK_min_freq;
+	u16 PCLK_max_freq;
+	u16 unknown2;
+	u16 ref_freq;
+	u16 ref_divider;
+	u16 unknown3;
+	u16 MCLK_pwd;
+	u16 MCLK_max_freq;
+	u16 XCLK_max_freq;
+	u16 SCLK_freq;
+} __attribute__ ((packed)) PLL_BLOCK_MACH64;
+
 struct pll_514 {
 	u8 m;
 	u8 n;
@@ -36,16 +82,39 @@
 	u8 pll_ref_div;
 	u8 pll_gen_cntl;
 	u8 mclk_fb_div;
+	u8 mclk_fb_mult; /* 2 ro 4 */
+/*	u8 sclk_fb_div;*/
 	u8 pll_vclk_cntl;
 	u8 vclk_post_div;
 	u8 vclk_fb_div;
 	u8 pll_ext_cntl;
-	u32 dsp_config;		/* Mach64 GTB DSP */
-	u32 dsp_on_off;		/* Mach64 GTB DSP */
+/*	u8 ext_vpll_cntl;
+	u8 spll_cntl2;*/
+	u32 dsp_config; /* Mach64 GTB DSP */
+	u32 dsp_on_off; /* Mach64 GTB DSP */
+	u32 dsp_loop_latency;
+	u32 fifo_size;
+	u32 xclkpagefaultdelay;
+	u32 xclkmaxrasdelay;
+	u8 xclk_ref_div;
+	u8 xclk_post_div;
 	u8 mclk_post_div_real;
+	u8 xclk_post_div_real;
 	u8 vclk_post_div_real;
+	u8 features;
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	u32 xres; /* use for LCD stretching/scaling */
+#endif
 };
 
+/*
+	for pll_ct.features
+*/
+#define DONT_USE_SPLL 0x1
+#define DONT_USE_XDLL 0x2
+#define USE_CPUCLK    0x4
+#define POWERDOWN_PLL 0x8
+
 union aty_pll {
 	struct pll_ct ct;
 	struct pll_514 ibm514;
@@ -56,42 +125,68 @@
      *  The hardware parameters for each card
      */
 
-struct aty_cursor {
-	u8 bits[8][64];
-	u8 mask[8][64];
-	u8 *ram;
-};
-
 struct atyfb_par {
-	struct aty_cmap_regs *aty_cmap_regs;
+	struct aty_cmap_regs __iomem *aty_cmap_regs;
+	struct { u8 red, green, blue; } palette[256];
 	const struct aty_dac_ops *dac_ops;
 	const struct aty_pll_ops *pll_ops;
-	struct aty_cursor *cursor;
-	unsigned long ati_regbase;
-	unsigned long clk_wr_offset;
+	void __iomem *ati_regbase;
+	unsigned long clk_wr_offset; /* meaning overloaded, clock id by CT */
 	struct crtc crtc;
 	union aty_pll pll;
+	struct pll_info pll_limits;
 	u32 features;
 	u32 ref_clk_per;
 	u32 pll_per;
 	u32 mclk_per;
+	u32 xclk_per;
 	u8 bus_type;
 	u8 ram_type;
 	u8 mem_refresh_rate;
-	u8 blitter_may_be_busy;
+	u16 pci_id;
 	u32 accel_flags;
+	int blitter_may_be_busy;
+	int asleep;
+	int lock_blank;
+	unsigned long res_start;
+	unsigned long res_size;
 #ifdef __sparc__
 	struct pci_mmap_map *mmap_map;
 	u8 mmaped;
+#endif
 	int open;
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	unsigned long bios_base_phys;
+	unsigned long bios_base;
+	unsigned long lcd_table;
+	u16 lcd_width;
+	u16 lcd_height;
+	u32 lcd_pixclock;
+	u16 lcd_refreshrate;
+	u16 lcd_htotal;
+	u16 lcd_hdisp;
+	u16 lcd_hsync_dly;
+	u16 lcd_hsync_len;
+	u16 lcd_vtotal;
+	u16 lcd_vdisp;
+	u16 lcd_vsync_len;
+	u16 lcd_right_margin;
+	u16 lcd_lower_margin;
+	u16 lcd_hblank_len;
+	u16 lcd_vblank_len;
 #endif
-#ifdef CONFIG_PMAC_PBOOK
-	struct fb_info *next;
-	unsigned char *save_framebuffer;
-	unsigned long save_pll[64];
+	unsigned long aux_start; /* auxiliary aperture */
+	unsigned long aux_size;
+	struct aty_interrupt vblank;
+	unsigned long irq_flags;
+	unsigned int irq;
+	spinlock_t int_lock;
+#ifdef CONFIG_MTRR
+	int mtrr_aper;
+	int mtrr_reg;
 #endif
 };
-    
+
     /*
      *  ATI Mach64 features
      */
@@ -101,7 +196,7 @@
 #define M64F_RESET_3D		0x00000001
 #define M64F_MAGIC_FIFO		0x00000002
 #define M64F_GTB_DSP		0x00000004
-#define M64F_FIFO_24		0x00000008
+#define M64F_FIFO_32		0x00000008
 #define M64F_SDRAM_MAGIC_PLL	0x00000010
 #define M64F_MAGIC_POSTDIV	0x00000020
 #define M64F_INTEGRATED		0x00000040
@@ -116,9 +211,10 @@
 #define M64F_G3_PB_1_1		0x00008000
 #define M64F_G3_PB_1024x768	0x00010000
 #define M64F_EXTRA_BRIGHT	0x00020000
-#define M64F_LT_SLEEP		0x00040000
+#define M64F_LT_LCD_REGS	0x00040000
 #define M64F_XL_DLL		0x00080000
-
+#define M64F_MFB_FORCE_4	0x00100000
+#define M64F_HW_TRIPLE		0x00200000
 
     /*
      *  Register access
@@ -137,8 +233,7 @@
 #endif
 }
 
-static inline void aty_st_le32(int regindex, u32 val,
-			       const struct atyfb_par *par)
+static inline void aty_st_le32(int regindex, u32 val, const struct atyfb_par *par)
 {
 	/* Hack for bloc 1, should be cleanly optimized by compiler */
 	if (regindex >= 0x400)
@@ -163,8 +258,7 @@
 #endif
 }
 
-static inline void aty_st_8(int regindex, u8 val,
-			    const struct atyfb_par *par)
+static inline void aty_st_8(int regindex, u8 val, const struct atyfb_par *par)
 {
 	/* Hack for bloc 1, should be cleanly optimized by compiler */
 	if (regindex >= 0x400)
@@ -177,17 +271,10 @@
 #endif
 }
 
-static inline u8 aty_ld_pll(int offset, const struct atyfb_par *par)
-{
-	u8 res;
-
-	/* write addr byte */
-	aty_st_8(CLOCK_CNTL + 1, (offset << 2), par);
-	/* read the register value */
-	res = aty_ld_8(CLOCK_CNTL + 2, par);
-	return res;
-}
-
+#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD)
+extern void aty_st_lcd(int index, u32 val, const struct atyfb_par *par);
+extern u32 aty_ld_lcd(int index, const struct atyfb_par *par);
+#endif
 
     /*
      *  DAC operations
@@ -195,14 +282,14 @@
 
 struct aty_dac_ops {
 	int (*set_dac) (const struct fb_info * info,
-			const union aty_pll * pll, u32 bpp, u32 accel);
+		const union aty_pll * pll, u32 bpp, u32 accel);
 };
 
-extern const struct aty_dac_ops aty_dac_ibm514;	/* IBM RGB514 */
-extern const struct aty_dac_ops aty_dac_ati68860b;	/* ATI 68860-B */
-extern const struct aty_dac_ops aty_dac_att21c498;	/* AT&T 21C498 */
-extern const struct aty_dac_ops aty_dac_unsupported;	/* unsupported */
-extern const struct aty_dac_ops aty_dac_ct;	/* Integrated */
+extern const struct aty_dac_ops aty_dac_ibm514; /* IBM RGB514 */
+extern const struct aty_dac_ops aty_dac_ati68860b; /* ATI 68860-B */
+extern const struct aty_dac_ops aty_dac_att21c498; /* AT&T 21C498 */
+extern const struct aty_dac_ops aty_dac_unsupported; /* unsupported */
+extern const struct aty_dac_ops aty_dac_ct; /* Integrated */
 
 
     /*
@@ -210,37 +297,32 @@
      */
 
 struct aty_pll_ops {
-	int (*var_to_pll) (const struct fb_info * info, u32 vclk_per,
-			   u8 bpp, union aty_pll * pll);
-	 u32(*pll_to_var) (const struct fb_info * info,
-			   const union aty_pll * pll);
-	void (*set_pll) (const struct fb_info * info,
-			 const union aty_pll * pll);
+	int (*var_to_pll) (const struct fb_info * info, u32 vclk_per, u32 bpp, union aty_pll * pll);
+	u32 (*pll_to_var) (const struct fb_info * info, const union aty_pll * pll);
+	void (*set_pll)   (const struct fb_info * info, const union aty_pll * pll);
+	void (*get_pll)   (const struct fb_info *info, union aty_pll * pll);
+	int (*init_pll)   (const struct fb_info * info, union aty_pll * pll);
 };
 
-extern const struct aty_pll_ops aty_pll_ati18818_1;	/* ATI 18818 */
-extern const struct aty_pll_ops aty_pll_stg1703;	/* STG 1703 */
-extern const struct aty_pll_ops aty_pll_ch8398;	/* Chrontel 8398 */
-extern const struct aty_pll_ops aty_pll_att20c408;	/* AT&T 20C408 */
-extern const struct aty_pll_ops aty_pll_ibm514;	/* IBM RGB514 */
-extern const struct aty_pll_ops aty_pll_unsupported;	/* unsupported */
-extern const struct aty_pll_ops aty_pll_ct;	/* Integrated */
+extern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */
+extern const struct aty_pll_ops aty_pll_stg1703; /* STG 1703 */
+extern const struct aty_pll_ops aty_pll_ch8398; /* Chrontel 8398 */
+extern const struct aty_pll_ops aty_pll_att20c408; /* AT&T 20C408 */
+extern const struct aty_pll_ops aty_pll_ibm514; /* IBM RGB514 */
+extern const struct aty_pll_ops aty_pll_unsupported; /* unsupported */
+extern const struct aty_pll_ops aty_pll_ct; /* Integrated */
 
 
-extern void aty_set_pll_ct(const struct fb_info *info,
-			   const union aty_pll *pll);
-extern void aty_calc_pll_ct(const struct fb_info *info,
-			    struct pll_ct *pll);
+extern void aty_set_pll_ct(const struct fb_info *info, const union aty_pll *pll);
+extern u8 aty_ld_pll_ct(int offset, const struct atyfb_par *par);
 
 
     /*
      *  Hardware cursor support
      */
 
-extern struct aty_cursor *aty_init_cursor(struct fb_info *info);
+extern int aty_init_cursor(struct fb_info *info);
 extern int atyfb_cursor(struct fb_info *info, struct fb_cursor *cursor);
-extern void aty_set_cursor_color(struct fb_info *info);
-extern void aty_set_cursor_shape(struct fb_info *info);
 
     /*
      *  Hardware acceleration
@@ -260,6 +342,5 @@
 }
 
 extern void aty_reset_engine(const struct atyfb_par *par);
-extern void aty_init_engine(struct atyfb_par *par,
-			    struct fb_info *info);
+extern void aty_init_engine(struct atyfb_par *par, struct fb_info *info);
 
diff -Nru a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
--- a/drivers/video/aty/atyfb_base.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/video/aty/atyfb_base.c	2004-12-24 13:37:02 -08:00
@@ -1,6 +1,7 @@
 /*
  *  ATI Frame Buffer Device Driver Core
  *
+ *	Copyright (C) 2004  Alex Kern <alex.kern@gmx.de>
  *	Copyright (C) 1997-2001  Geert Uytterhoeven
  *	Copyright (C) 1998  Bernd Harries
  *	Copyright (C) 1998  Eddie C. Dost  (ecd@skynet.be)
@@ -24,10 +25,13 @@
  *			   Harry AC Eaton
  *			   Anthony Tong <atong@uiuc.edu>
  *
+ *  Generic LCD support written by Daniel Mantione, ported from 2.4.20 by Alex Kern
+ *  Many Thanks to Ville Syrjälä for patches and fixing nasting 16 bit color bug.
+ *
  *  This file is subject to the terms and conditions of the GNU General Public
  *  License. See the file COPYING in the main directory of this archive for
  *  more details.
- *  
+ *
  *  Many thanks to Nitya from ATI devrel for support and patience !
  */
 
@@ -38,15 +42,16 @@
     - cursor support on all cards and all ramdacs.
     - cursor parameters controlable via ioctl()s.
     - guess PLL and MCLK based on the original PLL register values initialized
-      by the BIOS or Open Firmware (if they are initialized).
+      by Open Firmware (if they are initialized). BIOS is done
 
-						(Anyone to help with this?)
+    (Anyone with Mac to help with this?)
 
 ******************************************************************************/
 
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
@@ -54,19 +59,20 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
-#include <linux/selection.h>
 #include <linux/console.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/vt_kern.h>
-#include <linux/kd.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/wait.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
 #include <video/mach64.h>
 #include "atyfb.h"
+#include "ati_ids.h"
 
 #ifdef __powerpc__
 #include <asm/prom.h>
@@ -87,23 +93,102 @@
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include <asm/backlight.h>
 #endif
-
+#ifdef CONFIG_MTRR
+#include <asm/mtrr.h>
+#endif
 
 /*
  * Debug flags.
  */
-#undef DEBUG
+/*#undef DEBUG*/
+#define DEBUG
 
 /* Make sure n * PAGE_SIZE is protected at end of Aperture for GUI-regs */
 /*  - must be large enough to catch all GUI-Regs   */
 /*  - must be aligned to a PAGE boundary           */
 #define GUI_RESERVE	(1 * PAGE_SIZE)
 
-
 /* FIXME: remove the FAIL definition */
-#define FAIL(x) do { printk(x "\n"); return -EINVAL; } while (0)
+#define FAIL(msg) do { printk(KERN_CRIT "atyfb: " msg "\n"); return -EINVAL; } while (0)
+#define FAIL_MAX(msg, x, _max_) do { if(x > _max_) { printk(KERN_CRIT "atyfb: " msg " %x(%x)\n", x, _max_); return -EINVAL; } } while (0)
+
+#ifdef DEBUG
+#define DPRINTK(fmt, args...)	printk(KERN_DEBUG "atyfb: " fmt, ## args)
+#else
+#define DPRINTK(fmt, args...)
+#endif
+
+#define PRINTKI(fmt, args...)	printk(KERN_INFO "atyfb: " fmt, ## args)
+#define PRINTKE(fmt, args...)	 printk(KERN_ERR "atyfb: " fmt, ## args)
+
+#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD)
+static const u32 lt_lcd_regs[] = {
+	CONFIG_PANEL_LG,
+	LCD_GEN_CNTL_LG,
+	DSTN_CONTROL_LG,
+	HFB_PITCH_ADDR_LG,
+	HORZ_STRETCHING_LG,
+	VERT_STRETCHING_LG,
+	0, /* EXT_VERT_STRETCH */
+	LT_GIO_LG,
+	POWER_MANAGEMENT_LG
+};
+
+void aty_st_lcd(int index, u32 val, const struct atyfb_par *par)
+{
+	if (M64_HAS(LT_LCD_REGS)) {
+		aty_st_le32(lt_lcd_regs[index], val, par);
+	} else {
+		unsigned long temp;
+
+		/* write addr byte */
+		temp = aty_ld_le32(LCD_INDEX, par);
+		aty_st_le32(LCD_INDEX, (temp & ~LCD_INDEX_MASK) | index, par);
+		/* write the register value */
+		aty_st_le32(LCD_DATA, val, par);
+	}
+}
+
+u32 aty_ld_lcd(int index, const struct atyfb_par *par)
+{
+	if (M64_HAS(LT_LCD_REGS)) {
+		return aty_ld_le32(lt_lcd_regs[index], par);
+	} else {
+		unsigned long temp;
+
+		/* write addr byte */
+		temp = aty_ld_le32(LCD_INDEX, par);
+		aty_st_le32(LCD_INDEX, (temp & ~LCD_INDEX_MASK) | index, par);
+		/* read the register value */
+		return aty_ld_le32(LCD_DATA, par);
+	}
+}
+#endif /* defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */
+
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+/*
+ * ATIReduceRatio --
+ *
+ * Reduce a fraction by factoring out the largest common divider of the
+ * fraction's numerator and denominator.
+ */
+static void ATIReduceRatio(int *Numerator, int *Denominator)
+{
+    int Multiplier, Divider, Remainder;
 
+    Multiplier = *Numerator;
+    Divider = *Denominator;
 
+    while ((Remainder = Multiplier % Divider))
+    {
+        Multiplier = Divider;
+        Divider = Remainder;
+    }
+
+    *Numerator /= Divider;
+    *Denominator /= Divider;
+}
+#endif
     /*
      *  The Hardware parameters for each card
      */
@@ -138,22 +223,19 @@
 
 static int atyfb_open(struct fb_info *info, int user);
 static int atyfb_release(struct fb_info *info, int user);
-static int atyfb_check_var(struct fb_var_screeninfo *var,
-			   struct fb_info *info);
-static int atyfb_set_par(struct fb_info *info); 
+static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info);
+static int atyfb_set_par(struct fb_info *info);
 static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
-			   u_int transp, struct fb_info *info);
-static int atyfb_pan_display(struct fb_var_screeninfo *var,
-			     struct fb_info *info);
+	u_int transp, struct fb_info *info);
+static int atyfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info);
 static int atyfb_blank(int blank, struct fb_info *info);
 static int atyfb_ioctl(struct inode *inode, struct file *file, u_int cmd,
-		       u_long arg, struct fb_info *info);
+	u_long arg, struct fb_info *info);
 extern void atyfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
 extern void atyfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
 extern void atyfb_imageblit(struct fb_info *info, const struct fb_image *image);
 #ifdef __sparc__
-static int atyfb_mmap(struct fb_info *info, struct file *file,
-		      struct vm_area_struct *vma);
+static int atyfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma);
 #endif
 static int atyfb_sync(struct fb_info *info);
 
@@ -166,15 +248,14 @@
 static int store_video_par(char *videopar, unsigned char m64_num);
 #endif
 
-static void aty_set_crtc(const struct atyfb_par *par,
-			 const struct crtc *crtc);
-static int aty_var_to_crtc(const struct fb_info *info,
-			   const struct fb_var_screeninfo *var,
-			   struct crtc *crtc);
-static int aty_crtc_to_var(const struct crtc *crtc,
-			   struct fb_var_screeninfo *var);
-static void set_off_pitch(struct atyfb_par *par,
-			  const struct fb_info *info);
+static struct crtc saved_crtc;
+static union aty_pll saved_pll;
+static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc);
+
+static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc);
+static int aty_var_to_crtc(const struct fb_info *info, const struct fb_var_screeninfo *var, struct crtc *crtc);
+static int aty_crtc_to_var(const struct crtc *crtc, struct fb_var_screeninfo *var);
+static void set_off_pitch(struct atyfb_par *par, const struct fb_info *info);
 #ifdef CONFIG_PPC
 static int read_aty_sense(const struct atyfb_par *par);
 #endif
@@ -184,10 +265,19 @@
      *  Interface used by the world
      */
 
-int atyfb_init(void);
-#ifndef MODULE
-int atyfb_setup(char *);
-#endif
+struct fb_var_screeninfo default_var = {
+	/* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
+	640, 480, 640, 480, 0, 0, 8, 0,
+	{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
+	0, 0, -1, -1, 0, 39722, 48, 16, 33, 10, 96, 2,
+	0, FB_VMODE_NONINTERLACED
+};
+
+static struct fb_videomode defmode = {
+	/* 640x480 @ 60 Hz, 31.5 kHz hsync */
+	NULL, 60, 640, 480, 39721, 40, 24, 32, 11, 96, 2,
+	0, FB_VMODE_NONINTERLACED
+};
 
 static struct fb_ops atyfb_ops = {
 	.owner		= THIS_MODULE,
@@ -209,19 +299,24 @@
 	.fb_sync	= atyfb_sync,
 };
 
-static char curblink __initdata = 1;
-static char noaccel __initdata = 0;
-static u32 default_vram __initdata = 0;
-static int default_pll __initdata = 0;
-static int default_mclk __initdata = 0;
-
-#ifndef MODULE
-static char *mode_option __initdata = NULL;
-#endif
+static int noaccel;
+#ifdef CONFIG_MTRR
+static int nomtrr;
+#endif
+static int vram;
+static int pll;
+static int mclk;
+static int xclk;
+static char *mode;
 
 #ifdef CONFIG_PPC
 static int default_vmode __initdata = VMODE_CHOOSE;
 static int default_cmode __initdata = CMODE_CHOOSE;
+
+module_param_named(vmode, default_vmode, int, 0);
+MODULE_PARM_DESC(vmode, "int: video mode for mac");
+module_param_named(cmode, default_cmode, int, 0);
+MODULE_PARM_DESC(cmode, "int: color mode for mac");
 #endif
 
 #ifdef CONFIG_ATARI
@@ -231,177 +326,185 @@
 static unsigned long phys_guiregbase[FB_MAX] __initdata = { 0, };
 #endif
 
-#ifdef CONFIG_FB_ATY_GX
-static char m64n_gx[] __initdata = "mach64GX (ATI888GX00)";
-static char m64n_cx[] __initdata = "mach64CX (ATI888CX00)";
-#endif /* CONFIG_FB_ATY_GX */
-#ifdef CONFIG_FB_ATY_CT
-static char m64n_ct[] __initdata = "mach64CT (ATI264CT)";
-static char m64n_et[] __initdata = "mach64ET (ATI264ET)";
-static char m64n_vta3[] __initdata = "mach64VTA3 (ATI264VT)";
-static char m64n_vta4[] __initdata = "mach64VTA4 (ATI264VT)";
-static char m64n_vtb[] __initdata = "mach64VTB (ATI264VTB)";
-static char m64n_vt4[] __initdata = "mach64VT4 (ATI264VT4)";
-static char m64n_gt[] __initdata = "3D RAGE (GT)";
-static char m64n_gtb[] __initdata = "3D RAGE II+ (GTB)";
-static char m64n_iic_p[] __initdata = "3D RAGE IIC (PCI)";
-static char m64n_iic_a[] __initdata = "3D RAGE IIC (AGP)";
-static char m64n_lt[] __initdata = "3D RAGE LT";
-static char m64n_ltg[] __initdata = "3D RAGE LT-G";
-static char m64n_gtc_ba[] __initdata = "3D RAGE PRO (BGA, AGP)";
-static char m64n_gtc_ba1[] __initdata = "3D RAGE PRO (BGA, AGP, 1x only)";
-static char m64n_gtc_bp[] __initdata = "3D RAGE PRO (BGA, PCI)";
-static char m64n_gtc_pp[] __initdata = "3D RAGE PRO (PQFP, PCI)";
-static char m64n_gtc_ppl[] __initdata =
-    "3D RAGE PRO (PQFP, PCI, limited 3D)";
-static char m64n_xl[] __initdata = "3D RAGE (XL)";
-static char m64n_ltp_a[] __initdata = "3D RAGE LT PRO (AGP)";
-static char m64n_ltp_p[] __initdata = "3D RAGE LT PRO (PCI)";
-static char m64n_mob_p[] __initdata = "3D RAGE Mobility (PCI)";
-static char m64n_mob_a[] __initdata = "3D RAGE Mobility (AGP)";
-#endif /* CONFIG_FB_ATY_CT */
+/* top -> down is an evolution of mach64 chipset, any corrections? */
+#define ATI_CHIP_88800GX   (M64F_GX)
+#define ATI_CHIP_88800CX   (M64F_GX)
+
+#define ATI_CHIP_264CT     (M64F_CT | M64F_INTEGRATED | M64F_CT_BUS | M64F_MAGIC_FIFO)
+#define ATI_CHIP_264ET     (M64F_CT | M64F_INTEGRATED | M64F_CT_BUS | M64F_MAGIC_FIFO)
+
+#define ATI_CHIP_264VT     (M64F_VT | M64F_INTEGRATED | M64F_VT_BUS | M64F_MAGIC_FIFO)
+#define ATI_CHIP_264GT     (M64F_GT | M64F_INTEGRATED               | M64F_MAGIC_FIFO | M64F_EXTRA_BRIGHT)
+
+#define ATI_CHIP_264VTB    (M64F_VT | M64F_INTEGRATED | M64F_VT_BUS | M64F_GTB_DSP)
+#define ATI_CHIP_264VT3    (M64F_VT | M64F_INTEGRATED | M64F_VT_BUS | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL)
+#define ATI_CHIP_264VT4    (M64F_VT | M64F_INTEGRATED               | M64F_GTB_DSP)
+
+#define ATI_CHIP_264LT     (M64F_GT | M64F_INTEGRATED               | M64F_GTB_DSP)
+
+/* make sets shorter */
+#define ATI_MODERN_SET     (M64F_GT | M64F_INTEGRATED               | M64F_GTB_DSP | M64F_EXTRA_BRIGHT)
+
+#define ATI_CHIP_264GTB    (ATI_MODERN_SET | M64F_SDRAM_MAGIC_PLL)
+/*#define ATI_CHIP_264GTDVD  ?*/
+#define ATI_CHIP_264LTG    (ATI_MODERN_SET | M64F_SDRAM_MAGIC_PLL)
+
+#define ATI_CHIP_264GT2C   (ATI_MODERN_SET | M64F_SDRAM_MAGIC_PLL | M64F_HW_TRIPLE)
+#define ATI_CHIP_264GTPRO  (ATI_MODERN_SET | M64F_SDRAM_MAGIC_PLL | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D)
+#define ATI_CHIP_264LTPRO  (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D)
+
+#define ATI_CHIP_264XL     (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D | M64F_XL_DLL | M64F_MFB_FORCE_4)
+#define ATI_CHIP_MOBILITY  (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D | M64F_XL_DLL | M64F_MFB_FORCE_4 | M64F_MOBIL_BUS)
 
 static struct {
-	u16 pci_id, chip_type;
-	u8 rev_mask, rev_val;
+	u16 pci_id;
 	const char *name;
-	int pll, mclk;
+	int pll, mclk, xclk;
 	u32 features;
 } aty_chips[] __initdata = {
 #ifdef CONFIG_FB_ATY_GX
 	/* Mach64 GX */
-	{
-	0x4758, 0x00d7, 0x00, 0x00, m64n_gx, 135, 50, M64F_GX}, {
-	0x4358, 0x0057, 0x00, 0x00, m64n_cx, 135, 50, M64F_GX},
-#endif				/* CONFIG_FB_ATY_GX */
+	{ PCI_CHIP_MACH64GX, "ATI888GX00 (Mach64 GX)", 135, 50, 50, ATI_CHIP_88800GX },
+	{ PCI_CHIP_MACH64CX, "ATI888CX00 (Mach64 CX)", 135, 50, 50, ATI_CHIP_88800CX },
+#endif /* CONFIG_FB_ATY_GX */
+
 #ifdef CONFIG_FB_ATY_CT
-	    /* Mach64 CT */
-	{
-	0x4354, 0x4354, 0x00, 0x00, m64n_ct, 135, 60,
-		    M64F_CT | M64F_INTEGRATED | M64F_CT_BUS |
-		    M64F_MAGIC_FIFO}, {
-	0x4554, 0x4554, 0x00, 0x00, m64n_et, 135, 60,
-		    M64F_CT | M64F_INTEGRATED | M64F_CT_BUS |
-		    M64F_MAGIC_FIFO},
-	    /* Mach64 VT */
-	{
-	0x5654, 0x5654, 0xc7, 0x00, m64n_vta3, 170, 67,
-		    M64F_VT | M64F_INTEGRATED | M64F_VT_BUS |
-		    M64F_MAGIC_FIFO | M64F_FIFO_24}, {
-	0x5654, 0x5654, 0xc7, 0x40, m64n_vta4, 200, 67,
-		    M64F_VT | M64F_INTEGRATED | M64F_VT_BUS |
-		    M64F_MAGIC_FIFO | M64F_FIFO_24 | M64F_MAGIC_POSTDIV}, {
-	0x5654, 0x5654, 0x00, 0x00, m64n_vtb, 200, 67,
-		    M64F_VT | M64F_INTEGRATED | M64F_VT_BUS |
-		    M64F_GTB_DSP | M64F_FIFO_24}, {
-	0x5655, 0x5655, 0x00, 0x00, m64n_vtb, 200, 67,
-		    M64F_VT | M64F_INTEGRATED | M64F_VT_BUS |
-		    M64F_GTB_DSP | M64F_FIFO_24 | M64F_SDRAM_MAGIC_PLL}, {
-	0x5656, 0x5656, 0x00, 0x00, m64n_vt4, 230, 83,
-		    M64F_VT | M64F_INTEGRATED | M64F_GTB_DSP},
-	    /* Mach64 GT (3D RAGE) */
-	{
-	0x4754, 0x4754, 0x07, 0x00, m64n_gt, 135, 63,
-		    M64F_GT | M64F_INTEGRATED | M64F_MAGIC_FIFO |
-		    M64F_FIFO_24 | M64F_EXTRA_BRIGHT}, {
-	0x4754, 0x4754, 0x07, 0x01, m64n_gt, 170, 67,
-		    M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP |
-		    M64F_FIFO_24 | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT}, {
-	0x4754, 0x4754, 0x07, 0x02, m64n_gt, 200, 67,
-		    M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP |
-		    M64F_FIFO_24 | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT}, {
-	0x4755, 0x4755, 0x00, 0x00, m64n_gtb, 200, 67,
-		    M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP |
-		    M64F_FIFO_24 | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT}, {
-	0x4756, 0x4756, 0x00, 0x00, m64n_iic_p, 230, 83,
-		    M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP |
-		    M64F_FIFO_24 | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT}, {
-	0x4757, 0x4757, 0x00, 0x00, m64n_iic_a, 230, 83,
-		    M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP |
-		    M64F_FIFO_24 | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT}, {
-	0x475a, 0x475a, 0x00, 0x00, m64n_iic_a, 230, 83,
-		    M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP |
-		    M64F_FIFO_24 | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT},
-	    /* Mach64 LT */
-	{
-	0x4c54, 0x4c54, 0x00, 0x00, m64n_lt, 135, 63,
-		    M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP}, {
-	0x4c47, 0x4c47, 0x00, 0x00, m64n_ltg, 230, 63,
-		    M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP |
-		    M64F_SDRAM_MAGIC_PLL | M64F_EXTRA_BRIGHT |
-		    M64F_LT_SLEEP | M64F_G3_PB_1024x768},
-	    /* Mach64 GTC (3D RAGE PRO) */
-	{
-	0x4742, 0x4742, 0x00, 0x00, m64n_gtc_ba, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT}, {
-	0x4744, 0x4744, 0x00, 0x00, m64n_gtc_ba1, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT}, {
-	0x4749, 0x4749, 0x00, 0x00, m64n_gtc_bp, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT | M64F_MAGIC_VRAM_SIZE}, {
-	0x4750, 0x4750, 0x00, 0x00, m64n_gtc_pp, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT}, {
-	0x4751, 0x4751, 0x00, 0x00, m64n_gtc_ppl, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT},
-	    /* 3D RAGE XL */
-	{
-	0x4752, 0x4752, 0x00, 0x00, m64n_xl, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL |
-		    M64F_EXTRA_BRIGHT | M64F_XL_DLL},
-	    /* Mach64 LT PRO */
-	{
-	0x4c42, 0x4c42, 0x00, 0x00, m64n_ltp_a, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP}, {
-	0x4c44, 0x4c44, 0x00, 0x00, m64n_ltp_p, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP}, {
-	0x4c49, 0x4c49, 0x00, 0x00, m64n_ltp_p, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_EXTRA_BRIGHT |
-		    M64F_G3_PB_1_1 | M64F_G3_PB_1024x768}, {
-	0x4c50, 0x4c50, 0x00, 0x00, m64n_ltp_p, 230, 100,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP},
-	    /* 3D RAGE Mobility */
-	{
-	0x4c4d, 0x4c4d, 0x00, 0x00, m64n_mob_p, 230, 50,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_MOBIL_BUS}, {
-	0x4c4e, 0x4c4e, 0x00, 0x00, m64n_mob_a, 230, 50,
-		    M64F_GT | M64F_INTEGRATED | M64F_RESET_3D |
-		    M64F_GTB_DSP | M64F_MOBIL_BUS},
-#endif				/* CONFIG_FB_ATY_CT */
+	{ PCI_CHIP_MACH64CT, "ATI264CT (Mach64 CT)", 135, 60, 60, ATI_CHIP_264CT },
+	{ PCI_CHIP_MACH64ET, "ATI264ET (Mach64 ET)", 135, 60, 60, ATI_CHIP_264ET },
+	{ PCI_CHIP_MACH64VT, "ATI264VT? (Mach64 VT)", 170, 67, 67, ATI_CHIP_264VT },
+	{ PCI_CHIP_MACH64GT, "3D RAGE (Mach64 GT)", 135, 63, 63, ATI_CHIP_264GT },
+	/* FIXME { ...ATI_264GU, maybe ATI_CHIP_264GTDVD }, */
+	{ PCI_CHIP_MACH64GU, "3D RAGE II+ (Mach64 GTB)", 200, 67, 67, ATI_CHIP_264GTB  },
+	{ PCI_CHIP_MACH64VU, "ATI264VTB (Mach64 VU)", 200, 67, 67, ATI_CHIP_264VT3 },
+
+	{ PCI_CHIP_MACH64LT, "3D RAGE LT (Mach64 LT)", 135, 63, 63, ATI_CHIP_264LT },
+	 /* FIXME chipset maybe ATI_CHIP_264LTPRO ? */
+	{ PCI_CHIP_MACH64LG, "3D RAGE LT-G (Mach64 LG)", 230, 63, 63, ATI_CHIP_264LTG | M64F_LT_LCD_REGS | M64F_G3_PB_1024x768 },
+
+	{ PCI_CHIP_MACH64VV, "ATI264VT4 (Mach64 VV)", 230, 83, 83, ATI_CHIP_264VT4 },
+
+	{ PCI_CHIP_MACH64GV, "3D RAGE IIC (Mach64 GV, PCI)", 230, 83, 83, ATI_CHIP_264GT2C },
+	{ PCI_CHIP_MACH64GW, "3D RAGE IIC (Mach64 GW, AGP)", 230, 83, 83, ATI_CHIP_264GT2C },
+	{ PCI_CHIP_MACH64GY, "3D RAGE IIC (Mach64 GY, PCI)", 230, 83, 83, ATI_CHIP_264GT2C },
+	{ PCI_CHIP_MACH64GZ, "3D RAGE IIC (Mach64 GZ, AGP)", 230, 83, 83, ATI_CHIP_264GT2C },
+
+	{ PCI_CHIP_MACH64GB, "3D RAGE PRO (Mach64 GB, BGA, AGP)", 230, 100, 100, ATI_CHIP_264GTPRO },
+	{ PCI_CHIP_MACH64GD, "3D RAGE PRO (Mach64 GD, BGA, AGP 1x)", 230, 100, 100, ATI_CHIP_264GTPRO },
+	{ PCI_CHIP_MACH64GI, "3D RAGE PRO (Mach64 GI, BGA, PCI)", 230, 100, 100, ATI_CHIP_264GTPRO | M64F_MAGIC_VRAM_SIZE },
+	{ PCI_CHIP_MACH64GP, "3D RAGE PRO (Mach64 GP, PQFP, PCI)", 230, 100, 100, ATI_CHIP_264GTPRO },
+	{ PCI_CHIP_MACH64GQ, "3D RAGE PRO (Mach64 GQ, PQFP, PCI, limited 3D)", 230, 100, 100, ATI_CHIP_264GTPRO },
+
+	{ PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, ATI_CHIP_264LTPRO },
+	{ PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, ATI_CHIP_264LTPRO },
+	{ PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 },
+	{ PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, ATI_CHIP_264LTPRO },
+	{ PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, ATI_CHIP_264LTPRO },
+
+	{ PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP)", 230, 83, 63, ATI_CHIP_264XL },
+	{ PCI_CHIP_MACH64GN, "3D RAGE XL (Mach64 GN, AGP)", 230, 83, 63, ATI_CHIP_264XL },
+	{ PCI_CHIP_MACH64GO, "3D RAGE XL (Mach64 GO, PCI-66/BGA)", 230, 83, 63, ATI_CHIP_264XL },
+	{ PCI_CHIP_MACH64GR, "3D RAGE XL (Mach64 GR, PCI-33MHz)", 230, 83, 63, ATI_CHIP_264XL },
+	{ PCI_CHIP_MACH64GL, "3D RAGE XL (Mach64 GL, PCI)", 230, 83, 63, ATI_CHIP_264XL },
+	{ PCI_CHIP_MACH64GS, "3D RAGE XL (Mach64 GS, PCI)", 230, 83, 63, ATI_CHIP_264XL },
+
+	{ PCI_CHIP_MACH64LM, "3D RAGE Mobility P/M (Mach64 LM, AGP 2x)", 230, 83, 125, ATI_CHIP_MOBILITY },
+	{ PCI_CHIP_MACH64LN, "3D RAGE Mobility L (Mach64 LN, AGP 2x)", 230, 83, 125, ATI_CHIP_MOBILITY },
+	{ PCI_CHIP_MACH64LR, "3D RAGE Mobility P/M (Mach64 LR, PCI)", 230, 83, 125, ATI_CHIP_MOBILITY },
+	{ PCI_CHIP_MACH64LS, "3D RAGE Mobility L (Mach64 LS, PCI)", 230, 83, 125, ATI_CHIP_MOBILITY },
+#endif /* CONFIG_FB_ATY_CT */
 };
 
+/* can not fail */
+static int __devinit correct_chipset(struct atyfb_par *par)
+{
+	u8 rev;
+	u16 type;
+	u32 chip_id;
+	const char *name;
+	int i;
+
+	for (i = sizeof(aty_chips) / sizeof(*aty_chips) - 1; i >= 0; i--)
+		if (par->pci_id == aty_chips[i].pci_id)
+			break;
+
+	name = aty_chips[i].name;
+	par->pll_limits.pll_max = aty_chips[i].pll;
+	par->pll_limits.mclk = aty_chips[i].mclk;
+	par->pll_limits.xclk = aty_chips[i].xclk;
+	par->features = aty_chips[i].features;
+
+	chip_id = aty_ld_le32(CONFIG_CHIP_ID, par);
+	type = chip_id & CFG_CHIP_TYPE;
+	rev = (chip_id & CFG_CHIP_REV) >> 24;
+
+	switch(par->pci_id) {
+#ifdef CONFIG_FB_ATY_GX
+	case PCI_CHIP_MACH64GX:
+		if(type != 0x00d7)
+			return -ENODEV;
+		break;
+	case PCI_CHIP_MACH64CX:
+		if(type != 0x0057)
+			return -ENODEV;
+		break;
+#endif
+#ifdef CONFIG_FB_ATY_CT
+	case PCI_CHIP_MACH64VT:
+		rev &= 0xc7;
+		if(rev == 0x00) {
+			name = "ATI264VTA3 (Mach64 VT)";
+			par->pll_limits.pll_max = 170;
+			par->pll_limits.mclk = 67;
+			par->pll_limits.xclk = 67;
+			par->features = ATI_CHIP_264VT;
+		} else if(rev == 0x40) {
+			name = "ATI264VTA4 (Mach64 VT)";
+			par->pll_limits.pll_max = 200;
+			par->pll_limits.mclk = 67;
+			par->pll_limits.xclk = 67;
+			par->features = ATI_CHIP_264VT | M64F_MAGIC_POSTDIV;
+		} else {
+			name = "ATI264VTB (Mach64 VT)";
+			par->pll_limits.pll_max = 200;
+			par->pll_limits.mclk = 67;
+			par->pll_limits.xclk = 67;
+			par->features = ATI_CHIP_264VTB;
+		}
+		break;
+	case PCI_CHIP_MACH64GT:
+		rev &= 0x07;
+		if(rev == 0x01) {
+			par->pll_limits.pll_max = 170;
+			par->pll_limits.mclk = 67;
+			par->pll_limits.xclk = 67;
+			par->features = ATI_CHIP_264GTB;
+		} else if(rev == 0x02) {
+			par->pll_limits.pll_max = 200;
+			par->pll_limits.mclk = 67;
+			par->pll_limits.xclk = 67;
+			par->features = ATI_CHIP_264GTB;
+		}
+		break;
+#endif
+	}
+
+	PRINTKI("%s [0x%04x rev 0x%02x]\n", name, type, rev);
+	return 0;
+}
+
 static char ram_dram[] __initdata = "DRAM";
+static char ram_resv[] __initdata = "RESV";
 #ifdef CONFIG_FB_ATY_GX
 static char ram_vram[] __initdata = "VRAM";
 #endif /* CONFIG_FB_ATY_GX */
 #ifdef CONFIG_FB_ATY_CT
 static char ram_edo[] __initdata = "EDO";
-static char ram_sdram[] __initdata = "SDRAM";
-static char ram_sgram[] __initdata = "SGRAM";
-static char ram_wram[] __initdata = "WRAM";
+static char ram_sdram[] __initdata = "SDRAM (1:1)";
+static char ram_sgram[] __initdata = "SGRAM (1:1)";
+static char ram_sdram32[] __initdata = "SDRAM (2:1) (32-bit)";
 static char ram_off[] __initdata = "OFF";
 #endif /* CONFIG_FB_ATY_CT */
-static char ram_resv[] __initdata = "RESV";
+
 
 static u32 pseudo_palette[17];
 
@@ -410,109 +513,226 @@
 	ram_dram, ram_vram, ram_vram, ram_dram,
 	ram_dram, ram_vram, ram_vram, ram_resv
 };
-#endif				/* CONFIG_FB_ATY_GX */
+#endif /* CONFIG_FB_ATY_GX */
 
 #ifdef CONFIG_FB_ATY_CT
 static char *aty_ct_ram[8] __initdata = {
 	ram_off, ram_dram, ram_edo, ram_edo,
-	ram_sdram, ram_sgram, ram_wram, ram_resv
+	ram_sdram, ram_sgram, ram_sdram32, ram_resv
 };
-#endif				/* CONFIG_FB_ATY_CT */
+#endif /* CONFIG_FB_ATY_CT */
 
+static u32 atyfb_get_pixclock(struct fb_var_screeninfo *var, struct atyfb_par *par)
+{
+	u32 pixclock = var->pixclock;
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	u32 lcd_on_off;
+	par->pll.ct.xres = 0;
+	if (par->lcd_table != 0) {
+		lcd_on_off = aty_ld_lcd(LCD_GEN_CNTL, par);
+		if(lcd_on_off & LCD_ON) {
+			par->pll.ct.xres = var->xres;
+			pixclock = par->lcd_pixclock;
+		}
+	}
+#endif
+	return pixclock;
+}
 
 #if defined(CONFIG_PPC)
 
-    /*
-     *  Apple monitor sense
-     */
+/*
+ *  Apple monitor sense
+ */
 
 static int __init read_aty_sense(const struct atyfb_par *par)
 {
 	int sense, i;
 
-	aty_st_le32(GP_IO, 0x31003100, par);	/* drive outputs high */
+	aty_st_le32(GP_IO, 0x31003100, par); /* drive outputs high */
 	__delay(200);
-	aty_st_le32(GP_IO, 0, par);	/* turn off outputs */
+	aty_st_le32(GP_IO, 0, par); /* turn off outputs */
 	__delay(2000);
-	i = aty_ld_le32(GP_IO, par);	/* get primary sense value */
+	i = aty_ld_le32(GP_IO, par); /* get primary sense value */
 	sense = ((i & 0x3000) >> 3) | (i & 0x100);
 
 	/* drive each sense line low in turn and collect the other 2 */
-	aty_st_le32(GP_IO, 0x20000000, par);	/* drive A low */
+	aty_st_le32(GP_IO, 0x20000000, par); /* drive A low */
 	__delay(2000);
 	i = aty_ld_le32(GP_IO, par);
 	sense |= ((i & 0x1000) >> 7) | ((i & 0x100) >> 4);
-	aty_st_le32(GP_IO, 0x20002000, par);	/* drive A high again */
+	aty_st_le32(GP_IO, 0x20002000, par); /* drive A high again */
 	__delay(200);
 
-	aty_st_le32(GP_IO, 0x10000000, par);	/* drive B low */
+	aty_st_le32(GP_IO, 0x10000000, par); /* drive B low */
 	__delay(2000);
 	i = aty_ld_le32(GP_IO, par);
 	sense |= ((i & 0x2000) >> 10) | ((i & 0x100) >> 6);
-	aty_st_le32(GP_IO, 0x10001000, par);	/* drive B high again */
+	aty_st_le32(GP_IO, 0x10001000, par); /* drive B high again */
 	__delay(200);
 
-	aty_st_le32(GP_IO, 0x01000000, par);	/* drive C low */
+	aty_st_le32(GP_IO, 0x01000000, par); /* drive C low */
 	__delay(2000);
 	sense |= (aty_ld_le32(GP_IO, par) & 0x3000) >> 12;
-	aty_st_le32(GP_IO, 0, par);	/* turn off outputs */
+	aty_st_le32(GP_IO, 0, par); /* turn off outputs */
 	return sense;
 }
 
-#endif				/* defined(CONFIG_PPC) */
-
-#if defined(CONFIG_PMAC_PBOOK) || defined(CONFIG_PMAC_BACKLIGHT)
-static void aty_st_lcd(int index, u32 val, const struct atyfb_par *par)
-{
-	unsigned long temp;
-
-	/* write addr byte */
-	temp = aty_ld_le32(LCD_INDEX, par);
-	aty_st_le32(LCD_INDEX, (temp & ~LCD_INDEX_MASK) | index, par);
-	/* write the register value */
-	aty_st_le32(LCD_DATA, val, par);
-}
-
-static u32 aty_ld_lcd(int index, const struct atyfb_par *par)
-{
-	unsigned long temp;
-
-	/* write addr byte */
-	temp = aty_ld_le32(LCD_INDEX, par);
-	aty_st_le32(LCD_INDEX, (temp & ~LCD_INDEX_MASK) | index, par);
-	/* read the register value */
-	return aty_ld_le32(LCD_DATA, par);
-}
-#endif				/* CONFIG_PMAC_PBOOK || CONFIG_PMAC_BACKLIGHT */
+#endif /* defined(CONFIG_PPC) */
 
 /* ------------------------------------------------------------------------- */
 
-    /*
-     *  CRTC programming
-     */
+/*
+ *  CRTC programming
+ */
 
-static void aty_set_crtc(const struct atyfb_par *par,
-			 const struct crtc *crtc)
+static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc)
 {
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (par->lcd_table != 0) {
+		if(!M64_HAS(LT_LCD_REGS)) {
+		    crtc->lcd_index = aty_ld_le32(LCD_INDEX, par);
+		    aty_st_le32(LCD_INDEX, crtc->lcd_index, par);
+		}
+		crtc->lcd_config_panel = aty_ld_lcd(CONFIG_PANEL, par);
+		crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par);
+
+
+		/* switch to non shadow registers */
+		aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl &
+                    ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par);
+
+		/* save stretching */
+		crtc->horz_stretching = aty_ld_lcd(HORZ_STRETCHING, par);
+		crtc->vert_stretching = aty_ld_lcd(VERT_STRETCHING, par);
+		if (!M64_HAS(LT_LCD_REGS))
+			crtc->ext_vert_stretch = aty_ld_lcd(EXT_VERT_STRETCH, par);
+	}
+#endif
+	crtc->h_tot_disp = aty_ld_le32(CRTC_H_TOTAL_DISP, par);
+	crtc->h_sync_strt_wid = aty_ld_le32(CRTC_H_SYNC_STRT_WID, par);
+	crtc->v_tot_disp = aty_ld_le32(CRTC_V_TOTAL_DISP, par);
+	crtc->v_sync_strt_wid = aty_ld_le32(CRTC_V_SYNC_STRT_WID, par);
+	crtc->vline_crnt_vline = aty_ld_le32(CRTC_VLINE_CRNT_VLINE, par);
+	crtc->off_pitch = aty_ld_le32(CRTC_OFF_PITCH, par);
+	crtc->gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par);
+
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (par->lcd_table != 0) {
+		/* switch to shadow registers */
+		aty_st_lcd(LCD_GEN_CNTL, (crtc->lcd_gen_cntl & ~CRTC_RW_SELECT) |
+			SHADOW_EN | SHADOW_RW_EN, par);
+
+		crtc->shadow_h_tot_disp = aty_ld_le32(CRTC_H_TOTAL_DISP, par);
+		crtc->shadow_h_sync_strt_wid = aty_ld_le32(CRTC_H_SYNC_STRT_WID, par);
+		crtc->shadow_v_tot_disp = aty_ld_le32(CRTC_V_TOTAL_DISP, par);
+		crtc->shadow_v_sync_strt_wid = aty_ld_le32(CRTC_V_SYNC_STRT_WID, par);
+
+		aty_st_le32(LCD_GEN_CNTL, crtc->lcd_gen_cntl, par);
+	}
+#endif /* CONFIG_FB_ATY_GENERIC_LCD */
+}
+
+static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc)
+{
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (par->lcd_table != 0) {
+		/* stop CRTC */
+		aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl & ~(CRTC_EXT_DISP_EN | CRTC_EN), par);
+
+		/* update non-shadow registers first */
+		aty_st_lcd(CONFIG_PANEL, crtc->lcd_config_panel, par);
+		aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl &
+			~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par);
+
+		/* temporarily disable stretching */
+		aty_st_lcd(HORZ_STRETCHING,
+			crtc->horz_stretching &
+			~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN), par);
+		aty_st_lcd(VERT_STRETCHING,
+			crtc->vert_stretching &
+			~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 |
+			VERT_STRETCH_USE0 | VERT_STRETCH_EN), par);
+	}
+#endif
+	/* turn off CRT */
+	aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl & ~CRTC_EN, par);
+
+	DPRINTK("setting up CRTC\n");
+	DPRINTK("set primary CRT to %ix%i %c%c composite %c\n",
+	    ((((crtc->h_tot_disp>>16) & 0xff) + 1)<<3), (((crtc->v_tot_disp>>16) & 0x7ff) + 1),
+	    (crtc->h_sync_strt_wid & 0x200000)?'N':'P', (crtc->v_sync_strt_wid & 0x200000)?'N':'P',
+	    (crtc->gen_cntl & CRTC_CSYNC_EN)?'P':'N');
+
+	DPRINTK("CRTC_H_TOTAL_DISP: %x\n",crtc->h_tot_disp);
+	DPRINTK("CRTC_H_SYNC_STRT_WID: %x\n",crtc->h_sync_strt_wid);
+	DPRINTK("CRTC_V_TOTAL_DISP: %x\n",crtc->v_tot_disp);
+	DPRINTK("CRTC_V_SYNC_STRT_WID: %x\n",crtc->v_sync_strt_wid);
+	DPRINTK("CRTC_OFF_PITCH: %x\n", crtc->off_pitch);
+	DPRINTK("CRTC_VLINE_CRNT_VLINE: %x\n", crtc->vline_crnt_vline);
+	DPRINTK("CRTC_GEN_CNTL: %x\n",crtc->gen_cntl);
+
 	aty_st_le32(CRTC_H_TOTAL_DISP, crtc->h_tot_disp, par);
 	aty_st_le32(CRTC_H_SYNC_STRT_WID, crtc->h_sync_strt_wid, par);
 	aty_st_le32(CRTC_V_TOTAL_DISP, crtc->v_tot_disp, par);
 	aty_st_le32(CRTC_V_SYNC_STRT_WID, crtc->v_sync_strt_wid, par);
-	aty_st_le32(CRTC_VLINE_CRNT_VLINE, 0, par);
 	aty_st_le32(CRTC_OFF_PITCH, crtc->off_pitch, par);
+	aty_st_le32(CRTC_VLINE_CRNT_VLINE, crtc->vline_crnt_vline, par);
+
 	aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl, par);
+#if 0
+	FIXME
+	if (par->accel_flags & FB_ACCELF_TEXT)
+		aty_init_engine(par, info);
+#endif
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	/* after setting the CRTC registers we should set the LCD registers. */
+	if (par->lcd_table != 0) {
+		/* switch to shadow registers */
+		aty_st_lcd(LCD_GEN_CNTL, (crtc->lcd_gen_cntl & ~CRTC_RW_SELECT) |
+			(SHADOW_EN | SHADOW_RW_EN), par);
+
+		DPRINTK("set secondary CRT to %ix%i %c%c\n",
+		    ((((crtc->shadow_h_tot_disp>>16) & 0xff) + 1)<<3), (((crtc->shadow_v_tot_disp>>16) & 0x7ff) + 1),
+		    (crtc->shadow_h_sync_strt_wid & 0x200000)?'N':'P', (crtc->shadow_v_sync_strt_wid & 0x200000)?'N':'P');
+
+		DPRINTK("SHADOW CRTC_H_TOTAL_DISP: %x\n", crtc->shadow_h_tot_disp);
+		DPRINTK("SHADOW CRTC_H_SYNC_STRT_WID: %x\n", crtc->shadow_h_sync_strt_wid);
+		DPRINTK("SHADOW CRTC_V_TOTAL_DISP: %x\n", crtc->shadow_v_tot_disp);
+		DPRINTK("SHADOW CRTC_V_SYNC_STRT_WID: %x\n", crtc->shadow_v_sync_strt_wid);
+
+		aty_st_le32(CRTC_H_TOTAL_DISP, crtc->shadow_h_tot_disp, par);
+		aty_st_le32(CRTC_H_SYNC_STRT_WID, crtc->shadow_h_sync_strt_wid, par);
+		aty_st_le32(CRTC_V_TOTAL_DISP, crtc->shadow_v_tot_disp, par);
+		aty_st_le32(CRTC_V_SYNC_STRT_WID, crtc->shadow_v_sync_strt_wid, par);
+
+		/* restore CRTC selection & shadow state and enable stretching */
+		DPRINTK("LCD_GEN_CNTL: %x\n", crtc->lcd_gen_cntl);
+		DPRINTK("HORZ_STRETCHING: %x\n", crtc->horz_stretching);
+		DPRINTK("VERT_STRETCHING: %x\n", crtc->vert_stretching);
+		if(!M64_HAS(LT_LCD_REGS))
+		    DPRINTK("EXT_VERT_STRETCH: %x\n", crtc->ext_vert_stretch);
+
+		aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl, par);
+		aty_st_lcd(HORZ_STRETCHING, crtc->horz_stretching, par);
+		aty_st_lcd(VERT_STRETCHING, crtc->vert_stretching, par);
+		if(!M64_HAS(LT_LCD_REGS)) {
+		    aty_st_lcd(EXT_VERT_STRETCH, crtc->ext_vert_stretch, par);
+		    aty_ld_le32(LCD_INDEX, par);
+		    aty_st_le32(LCD_INDEX, crtc->lcd_index, par);
+		}
+	}
+#endif /* CONFIG_FB_ATY_GENERIC_LCD */
 }
 
 static int aty_var_to_crtc(const struct fb_info *info,
-			   const struct fb_var_screeninfo *var,
-			   struct crtc *crtc)
+	const struct fb_var_screeninfo *var, struct crtc *crtc)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
 	u32 xres, yres, vxres, vyres, xoffset, yoffset, bpp;
-	u32 left, right, upper, lower, hslen, vslen, sync, vmode;
-	u32 h_total, h_disp, h_sync_strt, h_sync_dly, h_sync_wid,
-	    h_sync_pol;
-	u32 v_total, v_disp, v_sync_strt, v_sync_wid, v_sync_pol, c_sync;
+	u32 sync, vmode, vdisplay;
+	u32 h_total, h_disp, h_sync_strt, h_sync_end, h_sync_dly, h_sync_wid, h_sync_pol;
+	u32 v_total, v_disp, v_sync_strt, v_sync_end, v_sync_wid, v_sync_pol, c_sync;
 	u32 pix_width, dp_pix_width, dp_chain_mask;
 
 	/* input */
@@ -523,53 +743,19 @@
 	xoffset = var->xoffset;
 	yoffset = var->yoffset;
 	bpp = var->bits_per_pixel;
-	left = var->left_margin;
-	right = var->right_margin;
-	upper = var->upper_margin;
-	lower = var->lower_margin;
-	hslen = var->hsync_len;
-	vslen = var->vsync_len;
+	if (bpp == 16)
+		bpp = (var->green.length == 5) ? 15 : 16;
 	sync = var->sync;
 	vmode = var->vmode;
 
 	/* convert (and round up) and validate */
-	xres = (xres + 7) & ~7;
-	xoffset = (xoffset + 7) & ~7;
-	vxres = (vxres + 7) & ~7;
 	if (vxres < xres + xoffset)
 		vxres = xres + xoffset;
-	h_disp = xres / 8 - 1;
-	if (h_disp > 0xff)
-		FAIL("h_disp too large");
-	h_sync_strt = h_disp + (right / 8);
-	if (h_sync_strt > 0x1ff)
-		FAIL("h_sync_start too large");
-	h_sync_dly = right & 7;
-	h_sync_wid = (hslen + 7) / 8;
-	if (h_sync_wid > 0x1f)
-		FAIL("h_sync_wid too large");
-	h_total = h_sync_strt + h_sync_wid + (h_sync_dly + left + 7) / 8;
-	if (h_total > 0x1ff)
-		FAIL("h_total too large");
-	h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
+	h_disp = xres;
 
 	if (vyres < yres + yoffset)
 		vyres = yres + yoffset;
-	v_disp = yres - 1;
-	if (v_disp > 0x7ff)
-		FAIL("v_disp too large");
-	v_sync_strt = v_disp + lower;
-	if (v_sync_strt > 0x7ff)
-		FAIL("v_sync_strt too large");
-	v_sync_wid = vslen;
-	if (v_sync_wid > 0x1f)
-		FAIL("v_sync_wid too large");
-	v_total = v_sync_strt + v_sync_wid + upper;
-	if (v_total > 0x7ff)
-		FAIL("v_total too large");
-	v_sync_pol = sync & FB_SYNC_VERT_HIGH_ACT ? 0 : 1;
-
-	c_sync = sync & FB_SYNC_COMP_HIGH_ACT ? CRTC_CSYNC_EN : 0;
+	v_disp = yres;
 
 	if (bpp <= 8) {
 		bpp = 8;
@@ -577,54 +763,325 @@
 		dp_pix_width =
 		    HOST_8BPP | SRC_8BPP | DST_8BPP |
 		    BYTE_ORDER_LSB_TO_MSB;
-		dp_chain_mask = 0x8080;
-	} else if (bpp <= 16) {
+		dp_chain_mask = DP_CHAIN_8BPP;
+	} else if (bpp <= 15) {
 		bpp = 16;
 		pix_width = CRTC_PIX_WIDTH_15BPP;
 		dp_pix_width = HOST_15BPP | SRC_15BPP | DST_15BPP |
 		    BYTE_ORDER_LSB_TO_MSB;
-		dp_chain_mask = 0x4210;
+		dp_chain_mask = DP_CHAIN_15BPP;
+	} else if (bpp <= 16) {
+		bpp = 16;
+		pix_width = CRTC_PIX_WIDTH_16BPP;
+		dp_pix_width = HOST_16BPP | SRC_16BPP | DST_16BPP |
+		    BYTE_ORDER_LSB_TO_MSB;
+		dp_chain_mask = DP_CHAIN_16BPP;
 	} else if (bpp <= 24 && M64_HAS(INTEGRATED)) {
 		bpp = 24;
 		pix_width = CRTC_PIX_WIDTH_24BPP;
 		dp_pix_width =
 		    HOST_8BPP | SRC_8BPP | DST_8BPP |
 		    BYTE_ORDER_LSB_TO_MSB;
-		dp_chain_mask = 0x8080;
+		dp_chain_mask = DP_CHAIN_24BPP;
 	} else if (bpp <= 32) {
 		bpp = 32;
 		pix_width = CRTC_PIX_WIDTH_32BPP;
 		dp_pix_width = HOST_32BPP | SRC_32BPP | DST_32BPP |
 		    BYTE_ORDER_LSB_TO_MSB;
-		dp_chain_mask = 0x8080;
+		dp_chain_mask = DP_CHAIN_32BPP;
 	} else
 		FAIL("invalid bpp");
 
 	if (vxres * vyres * bpp / 8 > info->fix.smem_len)
 		FAIL("not enough video RAM");
 
-	if ((vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED)
-		FAIL("invalid vmode");
+	h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
+	v_sync_pol = sync & FB_SYNC_VERT_HIGH_ACT ? 0 : 1;
+
+	if((xres > 1600) || (yres > 1200)) {
+		FAIL("MACH64 chips are designed for max 1600x1200\n"
+		"select anoter resolution.");
+	}
+	h_sync_strt = h_disp + var->right_margin;
+	h_sync_end = h_sync_strt + var->hsync_len;
+	h_sync_dly  = var->right_margin & 7;
+	h_total = h_sync_end + h_sync_dly + var->left_margin;
+
+	v_sync_strt = v_disp + var->lower_margin;
+	v_sync_end = v_sync_strt + var->vsync_len;
+	v_total = v_sync_end + var->upper_margin;
+
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (par->lcd_table != 0) {
+		if(!M64_HAS(LT_LCD_REGS)) {
+		    u32 lcd_index = aty_ld_le32(LCD_INDEX, par);
+		    crtc->lcd_index = lcd_index &
+			~(LCD_INDEX_MASK | LCD_DISPLAY_DIS | LCD_SRC_SEL | CRTC2_DISPLAY_DIS);
+		    aty_st_le32(LCD_INDEX, lcd_index, par);
+		}
+
+		if (!M64_HAS(MOBIL_BUS))
+			crtc->lcd_index |= CRTC2_DISPLAY_DIS;
+
+		crtc->lcd_config_panel = aty_ld_lcd(CONFIG_PANEL, par) | 0x4000;
+		crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par) & ~CRTC_RW_SELECT;
+
+		crtc->lcd_gen_cntl &=
+			~(HORZ_DIVBY2_EN | DIS_HOR_CRT_DIVBY2 | TVCLK_PM_EN |
+			/*VCLK_DAC_PM_EN | USE_SHADOWED_VEND |*/
+			USE_SHADOWED_ROWCUR | SHADOW_EN | SHADOW_RW_EN);
+		crtc->lcd_gen_cntl |= DONT_SHADOW_VPAR | LOCK_8DOT;
+
+		if((crtc->lcd_gen_cntl & LCD_ON) &&
+			((xres > par->lcd_width) || (yres > par->lcd_height))) {
+			/* We cannot display the mode on the LCD. If the CRT is enabled
+			   we can turn off the LCD.
+			   If the CRT is off, it isn't a good idea to switch it on; we don't
+			   know if one is connected. So it's better to fail then.
+			 */
+			if (crtc->lcd_gen_cntl & CRT_ON) {
+				PRINTKI("Disable lcd panel, because video mode does not fit.\n");
+				crtc->lcd_gen_cntl &= ~LCD_ON;
+				/*aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl, par);*/
+			} else {
+				FAIL("Video mode exceeds size of lcd panel.\nConnect this computer to a conventional monitor if you really need this mode.");
+			}
+		}
+	}
+
+	if ((par->lcd_table != 0) && (crtc->lcd_gen_cntl & LCD_ON)) {
+		int VScan = 1;
+		/* bpp -> bytespp, 1,4 -> 0; 8 -> 2; 15,16 -> 1; 24 -> 6; 32 -> 5
+		const u8 DFP_h_sync_dly_LT[] = { 0, 2, 1, 6, 5 };
+		const u8 ADD_to_strt_wid_and_dly_LT_DAC[] = { 0, 5, 6, 9, 9, 12, 12 };  */
+
+		vmode &= ~(FB_VMODE_DOUBLE | FB_VMODE_INTERLACED);
+
+		/* This is horror! When we simulate, say 640x480 on an 800x600
+		   lcd monitor, the CRTC should be programmed 800x600 values for
+		   the non visible part, but 640x480 for the visible part.
+		   This code has been tested on a laptop with it's 1400x1050 lcd
+		   monitor and a conventional monitor both switched on.
+		   Tested modes: 1280x1024, 1152x864, 1024x768, 800x600,
+		    works with little glitches also with DOUBLESCAN modes
+		 */
+		if (yres < par->lcd_height) {
+			VScan = par->lcd_height / yres;
+			if(VScan > 1) {
+				VScan = 2;
+				vmode |= FB_VMODE_DOUBLE;
+			}
+		}
+
+		h_sync_strt = h_disp + par->lcd_right_margin;
+		h_sync_end = h_sync_strt + par->lcd_hsync_len;
+		h_sync_dly = /*DFP_h_sync_dly[ ( bpp + 1 ) / 3 ]; */par->lcd_hsync_dly;
+		h_total = h_disp + par->lcd_hblank_len;
+
+		v_sync_strt = v_disp + par->lcd_lower_margin / VScan;
+		v_sync_end = v_sync_strt + par->lcd_vsync_len / VScan;
+		v_total = v_disp + par->lcd_vblank_len / VScan;
+	}
+#endif /* CONFIG_FB_ATY_GENERIC_LCD */
+
+	h_disp = (h_disp >> 3) - 1;
+	h_sync_strt = (h_sync_strt >> 3) - 1;
+	h_sync_end = (h_sync_end >> 3) - 1;
+	h_total = (h_total >> 3) - 1;
+	h_sync_wid = h_sync_end - h_sync_strt;
+
+	FAIL_MAX("h_disp too large", h_disp, 0xff);
+	FAIL_MAX("h_sync_strt too large", h_sync_strt, 0x1ff);
+	/*FAIL_MAX("h_sync_wid too large", h_sync_wid, 0x1f);*/
+	if(h_sync_wid > 0x1f)
+		h_sync_wid = 0x1f;
+	FAIL_MAX("h_total too large", h_total, 0x1ff);
+
+	if (vmode & FB_VMODE_DOUBLE) {
+		v_disp <<= 1;
+		v_sync_strt <<= 1;
+		v_sync_end <<= 1;
+		v_total <<= 1;
+	}
+
+	vdisplay = yres;
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if ((par->lcd_table != 0) && (crtc->lcd_gen_cntl & LCD_ON))
+		vdisplay  = par->lcd_height;
+#endif
+
+	if(vdisplay < 400) {
+		h_sync_pol = 1;
+		v_sync_pol = 0;
+	} else if(vdisplay < 480) {
+		h_sync_pol = 0;
+		v_sync_pol = 1;
+	} else if(vdisplay < 768) {
+		h_sync_pol = 0;
+		v_sync_pol = 0;
+	} else {
+		h_sync_pol = 1;
+		v_sync_pol = 1;
+	}
+
+	v_disp--;
+	v_sync_strt--;
+	v_sync_end--;
+	v_total--;
+	v_sync_wid = v_sync_end - v_sync_strt;
+
+	FAIL_MAX("v_disp too large", v_disp, 0x7ff);
+	FAIL_MAX("v_sync_stsrt too large", v_sync_strt, 0x7ff);
+	/*FAIL_MAX("v_sync_wid too large", v_sync_wid, 0x1f);*/
+	if(v_sync_wid > 0x1f)
+		v_sync_wid = 0x1f;
+	FAIL_MAX("v_total too large", v_total, 0x7ff);
+
+	c_sync = sync & FB_SYNC_COMP_HIGH_ACT ? CRTC_CSYNC_EN : 0;
 
 	/* output */
 	crtc->vxres = vxres;
 	crtc->vyres = vyres;
-	crtc->h_tot_disp = h_total | (h_disp << 16);
-	crtc->h_sync_strt_wid = (h_sync_strt & 0xff) | (h_sync_dly << 8) |
-	    ((h_sync_strt & 0x100) << 4) | (h_sync_wid << 16) |
-	    (h_sync_pol << 21);
-	crtc->v_tot_disp = v_total | (v_disp << 16);
-	crtc->v_sync_strt_wid =
-	    v_sync_strt | (v_sync_wid << 16) | (v_sync_pol << 21);
-	crtc->off_pitch =
-	    ((yoffset * vxres + xoffset) * bpp / 64) | (vxres << 19);
-	crtc->gen_cntl =
-	    pix_width | c_sync | CRTC_EXT_DISP_EN | CRTC_ENABLE;
+	crtc->xoffset = xoffset;
+	crtc->yoffset = yoffset;
+	crtc->bpp = bpp;
+	crtc->off_pitch = ((yoffset*vxres+xoffset)*bpp/64) | (vxres<<19);
+	crtc->vline_crnt_vline = 0;
+
+	crtc->h_tot_disp = h_total | (h_disp<<16);
+	crtc->h_sync_strt_wid = (h_sync_strt & 0xff) | (h_sync_dly<<8) |
+		((h_sync_strt & 0x100)<<4) | (h_sync_wid<<16) | (h_sync_pol<<21);
+	crtc->v_tot_disp = v_total | (v_disp<<16);
+	crtc->v_sync_strt_wid = v_sync_strt | (v_sync_wid<<16) | (v_sync_pol<<21);
+
+	/* crtc->gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC_PRESERVED_MASK; */
+	crtc->gen_cntl = CRTC_EXT_DISP_EN | CRTC_EN | pix_width | c_sync;
+	crtc->gen_cntl |= CRTC_VGA_LINEAR;
+
+	/* Enable doublescan mode if requested */
+	if (vmode & FB_VMODE_DOUBLE)
+		crtc->gen_cntl |= CRTC_DBL_SCAN_EN;
+	/* Enable interlaced mode if requested */
+	if (vmode & FB_VMODE_INTERLACED)
+		crtc->gen_cntl |= CRTC_INTERLACE_EN;
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (par->lcd_table != 0) {
+		vdisplay = yres;
+		if(vmode & FB_VMODE_DOUBLE)
+			vdisplay <<= 1;
+		if(vmode & FB_VMODE_INTERLACED) {
+			vdisplay >>= 1;
+
+			/* The prefered mode for the lcd is not interlaced, so disable it if
+			   it was enabled. For doublescan there is no problem, because we can
+			   compensate for it in the hardware stretching (we stretch half as much)
+			 */
+			vmode &= ~FB_VMODE_INTERLACED;
+			/*crtc->gen_cntl &= ~CRTC_INTERLACE_EN;*/
+		}
+		crtc->gen_cntl &= ~(CRTC2_EN | CRTC2_PIX_WIDTH);
+		crtc->lcd_gen_cntl &= ~(HORZ_DIVBY2_EN | DIS_HOR_CRT_DIVBY2 |
+			/*TVCLK_PM_EN | VCLK_DAC_PM_EN |*/
+			USE_SHADOWED_VEND | USE_SHADOWED_ROWCUR | SHADOW_EN | SHADOW_RW_EN);
+		crtc->lcd_gen_cntl |= (DONT_SHADOW_VPAR/* | LOCK_8DOT*/);
+
+		/* MOBILITY M1 tested, FIXME: LT */
+		crtc->horz_stretching = aty_ld_lcd(HORZ_STRETCHING, par);
+		if (!M64_HAS(LT_LCD_REGS))
+			crtc->ext_vert_stretch = aty_ld_lcd(EXT_VERT_STRETCH, par) &
+				~(AUTO_VERT_RATIO | VERT_STRETCH_MODE | VERT_STRETCH_RATIO3);
+
+		crtc->horz_stretching &=
+			~(HORZ_STRETCH_RATIO | HORZ_STRETCH_LOOP | AUTO_HORZ_RATIO |
+			HORZ_STRETCH_MODE | HORZ_STRETCH_EN);
+		if (xres < par->lcd_width) {
+			do {
+				/*
+				* The horizontal blender misbehaves when HDisplay is less than a
+				* a certain threshold (440 for a 1024-wide panel).  It doesn't
+				* stretch such modes enough.  Use pixel replication instead of
+				* blending to stretch modes that can be made to exactly fit the
+				* panel width.  The undocumented "NoLCDBlend" option allows the
+				* pixel-replicated mode to be slightly wider or narrower than the
+				* panel width.  It also causes a mode that is exactly half as wide
+				* as the panel to be pixel-replicated, rather than blended.
+				*/
+				int HDisplay  = xres & ~7;
+				int nStretch  = par->lcd_width / HDisplay;
+				int Remainder = par->lcd_width % HDisplay;
+
+				if ((!Remainder && ((nStretch > 2))) ||
+					(((HDisplay * 16) / par->lcd_width) < 7)) {
+					static const char StretchLoops[] = {10, 12, 13, 15, 16};
+					int horz_stretch_loop = -1, BestRemainder;
+					int Numerator = HDisplay, Denominator = par->lcd_width;
+					int Index = 5;
+					ATIReduceRatio(&Numerator, &Denominator);
+
+					BestRemainder = (Numerator * 16) / Denominator;
+					while (--Index >= 0) {
+						Remainder = ((Denominator - Numerator) * StretchLoops[Index]) %
+							Denominator;
+						if (Remainder < BestRemainder) {
+							horz_stretch_loop = Index;
+							if (!(BestRemainder = Remainder))
+								break;
+						}
+					}
+
+					if ((horz_stretch_loop >= 0) && !BestRemainder) {
+						int horz_stretch_ratio = 0, Accumulator = 0;
+						int reuse_previous = 1;
+
+						Index = StretchLoops[horz_stretch_loop];
+
+						while (--Index >= 0) {
+							if (Accumulator > 0)
+								horz_stretch_ratio |= reuse_previous;
+							else
+								Accumulator += Denominator;
+							Accumulator -= Numerator;
+							reuse_previous <<= 1;
+						}
+
+						crtc->horz_stretching |= (HORZ_STRETCH_EN |
+							((horz_stretch_loop & HORZ_STRETCH_LOOP) << 16) |
+							(horz_stretch_ratio & HORZ_STRETCH_RATIO));
+						break;      /* Out of the do { ... } while (0) */
+					}
+				}
+
+				crtc->horz_stretching |= (HORZ_STRETCH_MODE | HORZ_STRETCH_EN |
+					(((HDisplay * (HORZ_STRETCH_BLEND + 1)) / par->lcd_width) & HORZ_STRETCH_BLEND));
+			} while (0);
+		}
+
+		if (vdisplay < par->lcd_height) {
+			crtc->vert_stretching = (VERT_STRETCH_USE0 | VERT_STRETCH_EN |
+				(((vdisplay * (VERT_STRETCH_RATIO0 + 1)) / par->lcd_height) & VERT_STRETCH_RATIO0));
+
+			if (!M64_HAS(LT_LCD_REGS) &&
+			    xres <= (M64_HAS(MOBIL_BUS)?1024:800))
+				crtc->ext_vert_stretch |= VERT_STRETCH_MODE;
+		} else {
+			/*
+			 * Don't use vertical blending if the mode is too wide or not
+			 * vertically stretched.
+			 */
+			crtc->vert_stretching = 0;
+		}
+		/* copy to shadow crtc */
+		crtc->shadow_h_tot_disp = crtc->h_tot_disp;
+		crtc->shadow_h_sync_strt_wid = crtc->h_sync_strt_wid;
+		crtc->shadow_v_tot_disp = crtc->v_tot_disp;
+		crtc->shadow_v_sync_strt_wid = crtc->v_sync_strt_wid;
+	}
+#endif /* CONFIG_FB_ATY_GENERIC_LCD */
+
 	if (M64_HAS(MAGIC_FIFO)) {
 		/* Not VTB/GTB */
 		/* FIXME: magic FIFO values */
-		crtc->gen_cntl |=
-		    aty_ld_le32(CRTC_GEN_CNTL, par) & 0x000e0000;
+		crtc->gen_cntl |= (aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC2_PIX_WIDTH);
 	}
 	crtc->dp_pix_width = dp_pix_width;
 	crtc->dp_chain_mask = dp_chain_mask;
@@ -632,21 +1089,19 @@
 	return 0;
 }
 
-
-static int aty_crtc_to_var(const struct crtc *crtc,
-			   struct fb_var_screeninfo *var)
+static int aty_crtc_to_var(const struct crtc *crtc, struct fb_var_screeninfo *var)
 {
 	u32 xres, yres, bpp, left, right, upper, lower, hslen, vslen, sync;
 	u32 h_total, h_disp, h_sync_strt, h_sync_dly, h_sync_wid,
 	    h_sync_pol;
 	u32 v_total, v_disp, v_sync_strt, v_sync_wid, v_sync_pol, c_sync;
 	u32 pix_width;
+	u32 double_scan, interlace;
 
 	/* input */
 	h_total = crtc->h_tot_disp & 0x1ff;
 	h_disp = (crtc->h_tot_disp >> 16) & 0xff;
-	h_sync_strt = (crtc->h_sync_strt_wid & 0xff) |
-	    ((crtc->h_sync_strt_wid >> 4) & 0x100);
+	h_sync_strt = (crtc->h_sync_strt_wid & 0xff) | ((crtc->h_sync_strt_wid >> 4) & 0x100);
 	h_sync_dly = (crtc->h_sync_strt_wid >> 8) & 0x7;
 	h_sync_wid = (crtc->h_sync_strt_wid >> 16) & 0x1f;
 	h_sync_pol = (crtc->h_sync_strt_wid >> 21) & 0x1;
@@ -657,6 +1112,8 @@
 	v_sync_pol = (crtc->v_sync_strt_wid >> 21) & 0x1;
 	c_sync = crtc->gen_cntl & CRTC_CSYNC_EN ? 1 : 0;
 	pix_width = crtc->gen_cntl & CRTC_PIX_WIDTH_MASK;
+	double_scan = crtc->gen_cntl & CRTC_DBL_SCAN_EN;
+	interlace = crtc->gen_cntl & CRTC_INTERLACE_EN;
 
 	/* convert */
 	xres = (h_disp + 1) * 8;
@@ -707,7 +1164,6 @@
 		var->transp.offset = 0;
 		var->transp.length = 0;
 		break;
-#if 0
 	case CRTC_PIX_WIDTH_16BPP:	/* RGB 565 */
 		bpp = 16;
 		var->red.offset = 11;
@@ -719,7 +1175,6 @@
 		var->transp.offset = 0;
 		var->transp.length = 0;
 		break;
-#endif
 	case CRTC_PIX_WIDTH_24BPP:	/* RGB 888 */
 		bpp = 24;
 		var->red.offset = 16;
@@ -760,6 +1215,21 @@
 	var->vsync_len = vslen;
 	var->sync = sync;
 	var->vmode = FB_VMODE_NONINTERLACED;
+	/* In double scan mode, the vertical parameters are doubled, so we need to
+	   half them to get the right values.
+	   In interlaced mode the values are already correct, so no correction is
+	   necessary.
+	 */
+	if (interlace)
+		var->vmode = FB_VMODE_INTERLACED;
+
+	if (double_scan) {
+		var->vmode = FB_VMODE_DOUBLE;
+		var->yres>>=1;
+		var->upper_margin>>=1;
+		var->lower_margin>>=1;
+		var->vsync_len>>=1;
+	}
 
 	return 0;
 }
@@ -770,58 +1240,116 @@
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
 	struct fb_var_screeninfo *var = &info->var;
-	u8 tmp;
-	u32 i;
+	u32 tmp, pixclock;
 	int err;
+#ifdef DEBUG
+	struct fb_var_screeninfo debug;
+	u32 pixclock_in_ps;
+#endif
+	if (par->asleep)
+		return 0;
 
-	if ((err = aty_var_to_crtc(info, var, &par->crtc)) ||
-	    (err = par->pll_ops->var_to_pll(info, var->pixclock,
-					var->bits_per_pixel, &par->pll)))
+	if ((err = aty_var_to_crtc(info, var, &par->crtc)))
 		return err;
 
-	par->accel_flags = var->accel_flags;	/* hack */
+	pixclock = atyfb_get_pixclock(var, par);
+
+	if (pixclock == 0) {
+		FAIL("Invalid pixclock");
+	} else {
+		if((err = par->pll_ops->var_to_pll(info, pixclock, var->bits_per_pixel, &par->pll)))
+			return err;
+	}
+
+	par->accel_flags = var->accel_flags; /* hack */
 
 	if (par->blitter_may_be_busy)
 		wait_for_idle(par);
-	tmp = aty_ld_8(CRTC_GEN_CNTL + 3, par);
-	aty_set_crtc(par, &par->crtc);
-	aty_st_8(CLOCK_CNTL + par->clk_wr_offset, 0, par);
-	/* better call aty_StrobeClock ?? */
-	aty_st_8(CLOCK_CNTL + par->clk_wr_offset, CLOCK_STROBE, par);
 
-	par->dac_ops->set_dac(info, &par->pll, var->bits_per_pixel,
-			      par->accel_flags);
+	aty_set_crtc(par, &par->crtc);
+	par->dac_ops->set_dac(info, &par->pll, var->bits_per_pixel, par->accel_flags);
 	par->pll_ops->set_pll(info, &par->pll);
 
+#ifdef DEBUG
+	if(par->pll_ops && par->pll_ops->pll_to_var)
+		pixclock_in_ps = par->pll_ops->pll_to_var(info, &(par->pll));
+	else
+		pixclock_in_ps = 0;
+
+	if(0 == pixclock_in_ps) {
+		PRINTKE("ALERT ops->pll_to_var get 0\n");
+		pixclock_in_ps = pixclock;
+	}
+
+	memset(&debug, 0, sizeof(debug));
+	if(!aty_crtc_to_var(&(par->crtc), &debug)) {
+		u32 hSync, vRefresh;
+		u32 h_disp, h_sync_strt, h_sync_end, h_total;
+		u32 v_disp, v_sync_strt, v_sync_end, v_total;
+
+		h_disp = debug.xres;
+		h_sync_strt = h_disp + debug.right_margin;
+		h_sync_end = h_sync_strt + debug.hsync_len;
+		h_total = h_sync_end + debug.left_margin;
+		v_disp = debug.yres;
+		v_sync_strt = v_disp + debug.lower_margin;
+		v_sync_end = v_sync_strt + debug.vsync_len;
+		v_total = v_sync_end + debug.upper_margin;
+
+		hSync = 1000000000 / (pixclock_in_ps * h_total);
+		vRefresh = (hSync * 1000) / v_total;
+        	if (par->crtc.gen_cntl & CRTC_INTERLACE_EN)
+            	vRefresh *= 2;
+        	if (par->crtc.gen_cntl & CRTC_DBL_SCAN_EN)
+            	vRefresh /= 2;
+
+		DPRINTK("atyfb_set_par\n");
+		DPRINTK(" Set Visible Mode to %ix%i-%i\n", var->xres, var->yres, var->bits_per_pixel);
+		DPRINTK(" Virtual resolution %ix%i, pixclock_in_ps %i (calculated %i)\n",
+			var->xres_virtual, var->yres_virtual, pixclock, pixclock_in_ps);
+		DPRINTK(" Dot clock:           %i MHz\n", 1000000 / pixclock_in_ps);
+		DPRINTK(" Horizontal sync:     %i kHz\n", hSync);
+		DPRINTK(" Vertical refresh:    %i Hz\n", vRefresh);
+		DPRINTK(" x  style: %i.%03i %i %i %i %i   %i %i %i %i\n",
+			1000000 / pixclock_in_ps, 1000000 % pixclock_in_ps,
+			h_disp, h_sync_strt, h_sync_end, h_total,
+			v_disp, v_sync_strt, v_sync_end, v_total);
+		DPRINTK(" fb style: %i  %i %i %i %i %i %i %i %i\n",
+			pixclock_in_ps,
+			debug.left_margin, h_disp, debug.right_margin, debug.hsync_len,
+			debug.upper_margin, v_disp, debug.lower_margin, debug.vsync_len);
+	}
+#endif /* DEBUG */
+
 	if (!M64_HAS(INTEGRATED)) {
 		/* Don't forget MEM_CNTL */
-		i = aty_ld_le32(MEM_CNTL, par) & 0xf0ffffff;
+		tmp = aty_ld_le32(MEM_CNTL, par) & 0xf0ffffff;
 		switch (var->bits_per_pixel) {
 		case 8:
-			i |= 0x02000000;
+			tmp |= 0x02000000;
 			break;
 		case 16:
-			i |= 0x03000000;
+			tmp |= 0x03000000;
 			break;
 		case 32:
-			i |= 0x06000000;
+			tmp |= 0x06000000;
 			break;
 		}
-		aty_st_le32(MEM_CNTL, i, par);
+		aty_st_le32(MEM_CNTL, tmp, par);
 	} else {
-		i = aty_ld_le32(MEM_CNTL, par) & 0xf00fffff;
+		tmp = aty_ld_le32(MEM_CNTL, par) & 0xf00fffff;
 		if (!M64_HAS(MAGIC_POSTDIV))
-			i |= par->mem_refresh_rate << 20;
+			tmp |= par->mem_refresh_rate << 20;
 		switch (var->bits_per_pixel) {
 		case 8:
 		case 24:
-			i |= 0x00000000;
+			tmp |= 0x00000000;
 			break;
 		case 16:
-			i |= 0x04000000;
+			tmp |= 0x04000000;
 			break;
 		case 32:
-			i |= 0x08000000;
+			tmp |= 0x08000000;
 			break;
 		}
 		if (M64_HAS(CT_BUS)) {
@@ -832,16 +1360,14 @@
 			aty_st_le32(BUS_CNTL, 0x680000f9, par);
 		} else if (M64_HAS(MOBIL_BUS)) {
 			aty_st_le32(DAC_CNTL, 0x80010102, par);
-			aty_st_le32(BUS_CNTL, 0x7b33a040, par);
+			aty_st_le32(BUS_CNTL, 0x7b33a040 | (par->aux_start ? BUS_APER_REG_DIS : 0), par);
 		} else {
 			/* GT */
 			aty_st_le32(DAC_CNTL, 0x86010102, par);
-			aty_st_le32(BUS_CNTL, 0x7b23a040, par);
-			aty_st_le32(EXT_MEM_CNTL,
-				    aty_ld_le32(EXT_MEM_CNTL,
-						par) | 0x5000001, par);
+			aty_st_le32(BUS_CNTL, 0x7b23a040 | (par->aux_start ? BUS_APER_REG_DIS : 0), par);
+			aty_st_le32(EXT_MEM_CNTL, aty_ld_le32(EXT_MEM_CNTL, par) | 0x5000001, par);
 		}
-		aty_st_le32(MEM_CNTL, i, par);
+		aty_st_le32(MEM_CNTL, tmp, par);
 	}
 	aty_st_8(DAC_MASK, 0xff, par);
 
@@ -855,29 +1381,98 @@
 
 #ifdef CONFIG_BOOTX_TEXT
 	btext_update_display(info->fix.smem_start,
-			     (((par->crtc.h_tot_disp >> 16) & 0xff) + 1) * 8,
-			     ((par->crtc.v_tot_disp >> 16) & 0x7ff) + 1,
-			     var->bits_per_pixel,
-			     par->crtc.vxres * var->bits_per_pixel / 8);
-#endif				/* CONFIG_BOOTX_TEXT */
+		(((par->crtc.h_tot_disp >> 16) & 0xff) + 1) * 8,
+		((par->crtc.v_tot_disp >> 16) & 0x7ff) + 1,
+		var->bits_per_pixel,
+		par->crtc.vxres * var->bits_per_pixel / 8);
+#endif /* CONFIG_BOOTX_TEXT */
+#if 0
+	/* switch to accelerator mode */
+	if (!(par->crtc.gen_cntl & CRTC_EXT_DISP_EN))
+		aty_st_le32(CRTC_GEN_CNTL, par->crtc.gen_cntl | CRTC_EXT_DISP_EN, par);
+#endif
+#ifdef DEBUG
+{
+	/* dump non shadow CRTC, pll, LCD registers */
+	int i; u32 base;
+
+	/* CRTC registers */
+	base = 0x2000;
+	printk("debug atyfb: Mach64 non-shadow register values:");
+	for (i = 0; i < 256; i = i+4) {
+		if(i%16 == 0) printk("\ndebug atyfb: 0x%04X: ", base + i);
+		printk(" %08X", aty_ld_le32(i, par));
+	}
+	printk("\n\n");
+
+#ifdef CONFIG_FB_ATY_CT
+	/* PLL registers */
+	base = 0x00;
+	printk("debug atyfb: Mach64 PLL register values:");
+	for (i = 0; i < 64; i++) {
+		if(i%16 == 0) printk("\ndebug atyfb: 0x%02X: ", base + i);
+		if(i%4 == 0)  printk(" ");
+		printk("%02X", aty_ld_pll_ct(i, par));
+	}
+	printk("\n\n");
+#endif	/* CONFIG_FB_ATY_CT */
+
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (par->lcd_table != 0) {
+		/* LCD registers */
+		base = 0x00;
+		printk("debug atyfb: LCD register values:");
+		if(M64_HAS(LT_LCD_REGS)) {
+		    for(i = 0; i <= POWER_MANAGEMENT; i++) {
+			if(i == EXT_VERT_STRETCH)
+			    continue;
+			printk("\ndebug atyfb: 0x%04X: ", lt_lcd_regs[i]);
+			printk(" %08X", aty_ld_lcd(i, par));
+		    }
+
+		} else {
+		    for (i = 0; i < 64; i++) {
+			if(i%4 == 0) printk("\ndebug atyfb: 0x%02X: ", base + i);
+			printk(" %08X", aty_ld_lcd(i, par));
+		    }
+		}
+		printk("\n\n");
+	}
+#endif /* CONFIG_FB_ATY_GENERIC_LCD */
+}
+#endif /* DEBUG */
 	return 0;
 }
 
-static int atyfb_check_var(struct fb_var_screeninfo *var,
-			   struct fb_info *info)
+static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
+	int err;
 	struct crtc crtc;
 	union aty_pll pll;
-	int err;
+	u32 pixclock;
+
+	memcpy(&pll, &(par->pll), sizeof(pll));
 
-	if ((err = aty_var_to_crtc(info, var, &crtc)) ||
-	    (err = par->pll_ops->var_to_pll(info, var->pixclock,
-					var->bits_per_pixel, &pll)))
+	if((err = aty_var_to_crtc(info, var, &crtc)))
 		return err;
 
-#if 0	/* fbmon is not done. uncomment for 2.5.x -brad */
-	if (!fbmon_valid_timings(var->pixclock, htotal, vtotal, info))
+	pixclock = atyfb_get_pixclock(var, par);
+
+	if (pixclock == 0) {
+		FAIL("Invalid pixclock");
+	} else {
+		if((err = par->pll_ops->var_to_pll(info, pixclock, var->bits_per_pixel, &pll)))
+			return err;
+	}
+
+	if (var->accel_flags & FB_ACCELF_TEXT)
+		info->var.accel_flags = FB_ACCELF_TEXT;
+	else
+		info->var.accel_flags = 0;
+
+#if 0 /* fbmon is not done. uncomment for 2.5.x -brad */
+	if (!fbmon_valid_timings(pixclock, htotal, vtotal, info))
 		return -EINVAL;
 #endif
 	aty_crtc_to_var(&crtc, var);
@@ -885,17 +1480,14 @@
 	return 0;
 }
 
-static void set_off_pitch(struct atyfb_par *par,
-			  const struct fb_info *info)
+static void set_off_pitch(struct atyfb_par *par, const struct fb_info *info)
 {
 	u32 xoffset = info->var.xoffset;
 	u32 yoffset = info->var.yoffset;
 	u32 vxres = par->crtc.vxres;
 	u32 bpp = info->var.bits_per_pixel;
 
-	par->crtc.off_pitch =
-	    ((yoffset * vxres + xoffset) * bpp / 64) | (vxres << 19);
-	aty_st_le32(CRTC_OFF_PITCH, par->crtc.off_pitch, par);
+	par->crtc.off_pitch = ((yoffset * vxres + xoffset) * bpp / 64) | (vxres << 19);
 }
 
 
@@ -905,35 +1497,103 @@
 
 static int atyfb_open(struct fb_info *info, int user)
 {
-#ifdef __sparc__
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
 
 	if (user) {
 		par->open++;
+#ifdef __sparc__
 		par->mmaped = 0;
-	}
 #endif
+	}
 	return (0);
 }
 
-struct fb_var_screeninfo default_var = {
-	/* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
-	640, 480, 640, 480, 0, 0, 8, 0,
-	{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
-	0, 0, -1, -1, 0, 39722, 48, 16, 33, 10, 96, 2,
-	0, FB_VMODE_NONINTERLACED
-};
+static irqreturn_t aty_irq(int irq, void *dev_id, struct pt_regs *fp)
+{
+	struct atyfb_par *par = dev_id;
+	int handled = 0;
+	u32 int_cntl;
 
-static int atyfb_release(struct fb_info *info, int user)
+	spin_lock(&par->int_lock);
+
+	int_cntl = aty_ld_le32(CRTC_INT_CNTL, par);
+
+	if (int_cntl & CRTC_VBLANK_INT) {
+		/* clear interrupt */
+		aty_st_le32(CRTC_INT_CNTL, (int_cntl & CRTC_INT_EN_MASK) | CRTC_VBLANK_INT_AK, par);
+		par->vblank.count++;
+		if (par->vblank.pan_display) {
+			par->vblank.pan_display = 0;
+			aty_st_le32(CRTC_OFF_PITCH, par->crtc.off_pitch, par);
+		}
+		wake_up_interruptible(&par->vblank.wait);
+		handled = 1;
+	}
+
+	spin_unlock(&par->int_lock);
+
+	return IRQ_RETVAL(handled);
+}
+
+static int aty_enable_irq(struct atyfb_par *par, int reenable)
 {
-#ifdef __sparc__
-	struct atyfb_par *par = (struct atyfb_par *) info->par;	
+	u32 int_cntl;
 
+	if (!test_and_set_bit(0, &par->irq_flags)) {
+		if (request_irq(par->irq, aty_irq, SA_SHIRQ, "atyfb", par)) {
+			clear_bit(0, &par->irq_flags);
+			return -EINVAL;
+		}
+		spin_lock_irq(&par->int_lock);
+		int_cntl = aty_ld_le32(CRTC_INT_CNTL, par) & CRTC_INT_EN_MASK;
+		/* clear interrupt */
+		aty_st_le32(CRTC_INT_CNTL, int_cntl | CRTC_VBLANK_INT_AK, par);
+		/* enable interrupt */
+		aty_st_le32(CRTC_INT_CNTL, int_cntl | CRTC_VBLANK_INT_EN, par);
+		spin_unlock_irq(&par->int_lock);
+	} else if (reenable) {
+		spin_lock_irq(&par->int_lock);
+		int_cntl = aty_ld_le32(CRTC_INT_CNTL, par) & CRTC_INT_EN_MASK;
+		if (!(int_cntl & CRTC_VBLANK_INT_EN)) {
+			printk("atyfb: someone disabled IRQ [%08x]\n", int_cntl);
+			/* re-enable interrupt */
+			aty_st_le32(CRTC_INT_CNTL, int_cntl | CRTC_VBLANK_INT_EN, par );
+		}
+		spin_unlock_irq(&par->int_lock);
+	}
+
+	return 0;
+}
+
+static int aty_disable_irq(struct atyfb_par *par)
+{
+	u32 int_cntl;
+
+	if (test_and_clear_bit(0, &par->irq_flags)) {
+		if (par->vblank.pan_display) {
+			par->vblank.pan_display = 0;
+			aty_st_le32(CRTC_OFF_PITCH, par->crtc.off_pitch, par);
+		}
+		spin_lock_irq(&par->int_lock);
+		int_cntl = aty_ld_le32(CRTC_INT_CNTL, par) & CRTC_INT_EN_MASK;
+		/* disable interrupt */
+		aty_st_le32(CRTC_INT_CNTL, int_cntl & ~CRTC_VBLANK_INT_EN, par );
+		spin_unlock_irq(&par->int_lock);
+		free_irq(par->irq, par);
+	}
+
+	return 0;
+}
+
+static int atyfb_release(struct fb_info *info, int user)
+{
+	struct atyfb_par *par = (struct atyfb_par *) info->par;
 	if (user) {
 		par->open--;
 		mdelay(1);
 		wait_for_idle(par);
 		if (!par->open) {
+#ifdef __sparc__
 			int was_mmaped = par->mmaped;
 
 			par->mmaped = 0;
@@ -952,21 +1612,16 @@
 				else
 					var.accel_flags |= FB_ACCELF_TEXT;
 				if (var.yres == var.yres_virtual) {
-					u32 vram =
-					    (info->fix.smem_len -
-					     (PAGE_SIZE << 2));
-					var.yres_virtual =
-					    ((vram * 8) /
-					     var.bits_per_pixel) /
-					    var.xres_virtual;
+					u32 videoram = (info->fix.smem_len - (PAGE_SIZE << 2));
+					var.yres_virtual = ((videoram * 8) / var.bits_per_pixel) / var.xres_virtual;
 					if (var.yres_virtual < var.yres)
-						var.yres_virtual =
-						    var.yres;
+						var.yres_virtual = var.yres;
 				}
 			}
-		}
-	} 
 #endif
+			aty_disable_irq(par);
+		}
+	}
 	return (0);
 }
 
@@ -976,25 +1631,67 @@
      *  This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
      */
 
-static int atyfb_pan_display(struct fb_var_screeninfo *var,
-			     struct fb_info *info)
+static int atyfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
 	u32 xres, yres, xoffset, yoffset;
 
 	xres = (((par->crtc.h_tot_disp >> 16) & 0xff) + 1) * 8;
 	yres = ((par->crtc.v_tot_disp >> 16) & 0x7ff) + 1;
+	if (par->crtc.gen_cntl & CRTC_DBL_SCAN_EN)
+		yres >>= 1;
 	xoffset = (var->xoffset + 7) & ~7;
 	yoffset = var->yoffset;
-	if (xoffset + xres > par->crtc.vxres
-	    || yoffset + yres > par->crtc.vyres)
+	if (xoffset + xres > par->crtc.vxres || yoffset + yres > par->crtc.vyres)
 		return -EINVAL;
 	info->var.xoffset = xoffset;
 	info->var.yoffset = yoffset;
+	if (par->asleep)
+		return 0;
+
 	set_off_pitch(par, info);
+	if ((var->activate & FB_ACTIVATE_VBL) && !aty_enable_irq(par, 0)) {
+		par->vblank.pan_display = 1;
+	} else {
+		par->vblank.pan_display = 0;
+		aty_st_le32(CRTC_OFF_PITCH, par->crtc.off_pitch, par);
+	}
+
+	return 0;
+}
+
+static int aty_waitforvblank(struct atyfb_par *par, u32 crtc)
+{
+	struct aty_interrupt *vbl;
+	unsigned int count;
+	int ret;
+
+	switch (crtc) {
+	case 0:
+		vbl = &par->vblank;
+		break;
+	default:
+		return -ENODEV;
+	}
+
+	ret = aty_enable_irq(par, 0);
+	if (ret)
+		return ret;
+
+	count = vbl->count;
+	ret = wait_event_interruptible_timeout(vbl->wait, count != vbl->count, HZ/10);
+	if (ret < 0) {
+		return ret;
+	}
+	if (ret == 0) {
+		aty_enable_irq(par, 1);
+		return -ETIMEDOUT;
+	}
+
 	return 0;
 }
 
+
 #ifdef DEBUG
 #define ATYIO_CLKR		0x41545900	/* ATY\00 */
 #define ATYIO_CLKW		0x41545901	/* ATY\01 */
@@ -1004,6 +1701,8 @@
 	u8 pll_ref_div;
 	u8 mclk_fb_div;
 	u8 mclk_post_div;	/* 1,2,3,4,8 */
+	u8 mclk_fb_mult;	/* 2 or 4 */
+	u8 xclk_post_div;	/* 1,2,3,4,8 */
 	u8 vclk_fb_div;
 	u8 vclk_post_div;	/* 1,2,3,4,6,8,12 */
 	u32 dsp_xclks_per_row;	/* 0-16383 */
@@ -1017,12 +1716,14 @@
 #define ATYIO_FEATW		0x41545903	/* ATY\03 */
 #endif
 
+#ifndef FBIO_WAITFORVSYNC
+#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
+#endif
+
 static int atyfb_ioctl(struct inode *inode, struct file *file, u_int cmd,
-		       u_long arg, struct fb_info *info)
+	u_long arg, struct fb_info *info)
 {
-#if defined(__sparc__) || (defined(DEBUG) && defined(CONFIG_FB_ATY_CT))
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
-#endif				/* __sparc__ || DEBUG */
 #ifdef __sparc__
 	struct fbtype fbtyp;
 #endif
@@ -1036,31 +1737,44 @@
 		fbtyp.fb_depth = info->var.bits_per_pixel;
 		fbtyp.fb_cmsize = info->cmap.len;
 		fbtyp.fb_size = info->fix.smem_len;
-		if (copy_to_user
-		    ((struct fbtype __user *) arg, &fbtyp, sizeof(fbtyp)))
+		if (copy_to_user((struct fbtype __user *) arg, &fbtyp, sizeof(fbtyp)))
 			return -EFAULT;
 		break;
-#endif				/* __sparc__ */
+#endif /* __sparc__ */
+
+	case FBIO_WAITFORVSYNC:
+		{
+			u32 crtc;
+
+			if (get_user(crtc, (__u32 __user *) arg))
+				return -EFAULT;
+
+			return aty_waitforvblank(par, crtc);
+		}
+		break;
+
 #if defined(DEBUG) && defined(CONFIG_FB_ATY_CT)
 	case ATYIO_CLKR:
 		if (M64_HAS(INTEGRATED)) {
 			struct atyclk clk;
-			union aty_pll *pll = par->pll;
+			union aty_pll *pll = &(par->pll);
 			u32 dsp_config = pll->ct.dsp_config;
 			u32 dsp_on_off = pll->ct.dsp_on_off;
 			clk.ref_clk_per = par->ref_clk_per;
 			clk.pll_ref_div = pll->ct.pll_ref_div;
 			clk.mclk_fb_div = pll->ct.mclk_fb_div;
 			clk.mclk_post_div = pll->ct.mclk_post_div_real;
+			clk.mclk_fb_mult = pll->ct.mclk_fb_mult;
+			clk.xclk_post_div = pll->ct.xclk_post_div_real;
 			clk.vclk_fb_div = pll->ct.vclk_fb_div;
 			clk.vclk_post_div = pll->ct.vclk_post_div_real;
 			clk.dsp_xclks_per_row = dsp_config & 0x3fff;
 			clk.dsp_loop_latency = (dsp_config >> 16) & 0xf;
 			clk.dsp_precision = (dsp_config >> 20) & 7;
-			clk.dsp_on = dsp_on_off & 0x7ff;
-			clk.dsp_off = (dsp_on_off >> 16) & 0x7ff;
-			if (copy_to_user
-			    ((struct atyclk *) arg, &clk, sizeof(clk)))
+			clk.dsp_off = dsp_on_off & 0x7ff;
+			clk.dsp_on = (dsp_on_off >> 16) & 0x7ff;
+			if (copy_to_user((struct atyclk __user *) arg, &clk,
+					 sizeof(clk)))
 				return -EFAULT;
 		} else
 			return -EINVAL;
@@ -1068,40 +1782,34 @@
 	case ATYIO_CLKW:
 		if (M64_HAS(INTEGRATED)) {
 			struct atyclk clk;
-			union aty_pll *pll = par->pll;
-			if (copy_from_user
-			    (&clk, (struct atyclk *) arg, sizeof(clk)))
+			union aty_pll *pll = &(par->pll);
+			if (copy_from_user(&clk, (struct atyclk __user *) arg, sizeof(clk)))
 				return -EFAULT;
 			par->ref_clk_per = clk.ref_clk_per;
 			pll->ct.pll_ref_div = clk.pll_ref_div;
 			pll->ct.mclk_fb_div = clk.mclk_fb_div;
 			pll->ct.mclk_post_div_real = clk.mclk_post_div;
+			pll->ct.mclk_fb_mult = clk.mclk_fb_mult;
+			pll->ct.xclk_post_div_real = clk.xclk_post_div;
 			pll->ct.vclk_fb_div = clk.vclk_fb_div;
 			pll->ct.vclk_post_div_real = clk.vclk_post_div;
-			pll->ct.dsp_config =
-			    (clk.
-			     dsp_xclks_per_row & 0x3fff) | ((clk.
-							     dsp_loop_latency
-							     & 0xf) << 16)
-			    | ((clk.dsp_precision & 7) << 20);
-			pll->ct.dsp_on_off =
-			    (clk.
-			     dsp_on & 0x7ff) | ((clk.
-						 dsp_off & 0x7ff) << 16);
-			aty_calc_pll_ct(info, &pll->ct);
+			pll->ct.dsp_config = (clk.dsp_xclks_per_row & 0x3fff) |
+				((clk.dsp_loop_latency & 0xf)<<16)| ((clk.dsp_precision & 7)<<20);
+			pll->ct.dsp_on_off = (clk.dsp_off & 0x7ff) | ((clk.dsp_on & 0x7ff)<<16);
+			/*aty_calc_pll_ct(info, &pll->ct);*/
 			aty_set_pll_ct(info, pll);
 		} else
 			return -EINVAL;
 		break;
 	case ATYIO_FEATR:
-		if (get_user(par->features, (u32 *) arg))
+		if (get_user(par->features, (u32 __user *) arg))
 			return -EFAULT;
 		break;
 	case ATYIO_FEATW:
-		if (put_user(par->features, (u32 *) arg))
+		if (put_user(par->features, (u32 __user *) arg))
 			return -EFAULT;
 		break;
-#endif				/* DEBUG && CONFIG_FB_ATY_CT */
+#endif /* DEBUG && CONFIG_FB_ATY_CT */
 	default:
 		return -EINVAL;
 	}
@@ -1118,8 +1826,7 @@
 }
 
 #ifdef __sparc__
-static int atyfb_mmap(struct fb_info *info, struct file *file,
-		      struct vm_area_struct *vma)
+static int atyfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
 	unsigned int size, page, map_size = 0;
@@ -1137,7 +1844,7 @@
 	size = vma->vm_end - vma->vm_start;
 
 	/* To stop the swapper from even considering these pages. */
-	vma->vm_flags |= (VM_SHM | VM_LOCKED);
+	vma->vm_flags |= (VM_IO | VM_RESERVED);
 
 	if (((vma->vm_pgoff == 0) && (size == info->fix.smem_len)) ||
 	    ((off == info->fix.smem_len) && (size == PAGE_SIZE)))
@@ -1174,8 +1881,8 @@
 		    ~(par->mmap_map[i].prot_mask);
 		pgprot_val(vma->vm_page_prot) |= par->mmap_map[i].prot_flag;
 
-		if (remap_page_range(vma, vma->vm_start + page, map_offset,
-				     map_size, vma->vm_page_prot))
+		if (remap_pfn_range(vma, vma->vm_start + page,
+			map_offset >> PAGE_SHIFT, map_size, vma->vm_page_prot))
 			return -EAGAIN;
 
 		page += map_size;
@@ -1184,8 +1891,6 @@
 	if (!map_size)
 		return -EINVAL;
 
-	vma->vm_flags |= VM_IO;
-
 	if (!par->mmaped)
 		par->mmaped = 1;
 	return 0;
@@ -1243,83 +1948,22 @@
 				info->var.yoffset = atyfb_save.yoffset;
 				set_off_pitch(par, info);
 			}
+			aty_st_le32(CRTC_OFF_PITCH, par->crtc.off_pitch, par);
 			break;
 		}
 	}
 }
-#endif				/* __sparc__ */
-
+#endif /* __sparc__ */
 
 
-#ifdef CONFIG_PMAC_PBOOK
 
-static struct fb_info *first_display = NULL;
+#if defined(CONFIG_PM) && defined(CONFIG_PCI)
 
 /* Power management routines. Those are used for PowerBook sleep.
- *
- * It appears that Rage LT and Rage LT Pro have different power
- * management registers. There's is some confusion about which
- * chipID is a Rage LT or LT pro :(
  */
-static int aty_power_mgmt_LT(int sleep, struct atyfb_par *par)
-{
-	unsigned int pm;
-	int timeout;
-
-	pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
-	pm = (pm & ~PWR_MGT_MODE_MASK) | PWR_MGT_MODE_REG;
-	aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
-	pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
-
-	timeout = 200000;
-	if (sleep) {
-		/* Sleep */
-		pm &= ~PWR_MGT_ON;
-		aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
-		pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
-		udelay(10);
-		pm &= ~(PWR_BLON | AUTO_PWR_UP);
-		pm |= SUSPEND_NOW;
-		aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
-		pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
-		udelay(10);
-		pm |= PWR_MGT_ON;
-		aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
-		do {
-			pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
-			udelay(10);
-			if ((--timeout) == 0)
-				break;
-		} while ((pm & PWR_MGT_STATUS_MASK) !=
-			 PWR_MGT_STATUS_SUSPEND);
-	} else {
-		/* Wakeup */
-		pm &= ~PWR_MGT_ON;
-		aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
-		pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
-		udelay(10);
-		pm |= (PWR_BLON | AUTO_PWR_UP);
-		pm &= ~SUSPEND_NOW;
-		aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
-		pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
-		udelay(10);
-		pm |= PWR_MGT_ON;
-		aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
-		do {
-			pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
-			udelay(10);
-			if ((--timeout) == 0)
-				break;
-		} while ((pm & PWR_MGT_STATUS_MASK) != 0);
-	}
-	mdelay(500);
-
-	return timeout ? PBOOK_SLEEP_OK : PBOOK_SLEEP_REFUSE;
-}
-
-static int aty_power_mgmt_LTPro(int sleep, struct atyfb_par *par)
+static int aty_power_mgmt(int sleep, struct atyfb_par *par)
 {
-	unsigned int pm;
+	u32 pm;
 	int timeout;
 
 	pm = aty_ld_lcd(POWER_MANAGEMENT, par);
@@ -1327,7 +1971,7 @@
 	aty_st_lcd(POWER_MANAGEMENT, pm, par);
 	pm = aty_ld_lcd(POWER_MANAGEMENT, par);
 
-	timeout = 200;
+	timeout = 2000;
 	if (sleep) {
 		/* Sleep */
 		pm &= ~PWR_MGT_ON;
@@ -1346,8 +1990,7 @@
 			mdelay(1);
 			if ((--timeout) == 0)
 				break;
-		} while ((pm & PWR_MGT_STATUS_MASK) !=
-			 PWR_MGT_STATUS_SUSPEND);
+		} while ((pm & PWR_MGT_STATUS_MASK) != PWR_MGT_STATUS_SUSPEND);
 	} else {
 		/* Wakeup */
 		pm &= ~PWR_MGT_ON;
@@ -1368,88 +2011,92 @@
 				break;
 		} while ((pm & PWR_MGT_STATUS_MASK) != 0);
 	}
+	mdelay(500);
 
-	return timeout ? PBOOK_SLEEP_OK : PBOOK_SLEEP_REFUSE;
+	return timeout ? 0 : -EIO;
 }
 
-static int aty_power_mgmt(int sleep, struct atyfb_par *par)
+static int atyfb_pci_suspend(struct pci_dev *pdev, u32 state)
 {
-	return M64_HAS(LT_SLEEP) ? aty_power_mgmt_LT(sleep, par)
-	    : aty_power_mgmt_LTPro(sleep, par);
+	struct fb_info *info = pci_get_drvdata(pdev);
+	struct atyfb_par *par = (struct atyfb_par *) info->par;
+
+#ifdef CONFIG_PPC_PMAC
+	/* HACK ALERT ! Once I find a proper way to say to each driver
+	 * individually what will happen with it's PCI slot, I'll change
+	 * that. On laptops, the AGP slot is just unclocked, so D2 is
+	 * expected, while on desktops, the card is powered off
+	 */
+	if (state >= 3)
+		state = 2;
+#endif /* CONFIG_PPC_PMAC */
+
+	if (state != 2 || state == pdev->dev.power.power_state)
+		return 0;
+
+	acquire_console_sem();
+
+	fb_set_suspend(info, 1);
+
+	/* Idle & reset engine */
+	wait_for_idle(par);
+	aty_reset_engine(par);
+
+	/* Blank display and LCD */
+	atyfb_blank(FB_BLANK_POWERDOWN, info);
+
+	par->asleep = 1;
+	par->lock_blank = 1;
+
+	/* Set chip to "suspend" mode */
+	if (aty_power_mgmt(1, par)) {
+		par->asleep = 0;
+		par->lock_blank = 0;
+		atyfb_blank(FB_BLANK_UNBLANK, info);
+		fb_set_suspend(info, 0);
+		release_console_sem();
+		return -EIO;
+	}
+
+	release_console_sem();
+
+	pdev->dev.power.power_state = state;
+
+	return 0;
 }
 
-/*
- * Save the contents of the frame buffer when we go to sleep,
- * and restore it when we wake up again.
- */
-static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when)
+static int atyfb_pci_resume(struct pci_dev *pdev)
 {
-	struct fb_info *info;
-	struct atyfb_par *par; 
-	int result;
+	struct fb_info *info = pci_get_drvdata(pdev);
+	struct atyfb_par *par = (struct atyfb_par *) info->par;
 
-	result = PBOOK_SLEEP_OK;
+	if (pdev->dev.power.power_state == 0)
+		return 0;
 
-	for (info = first_display; info != NULL; info = par->next) {
-		int nb;
+	acquire_console_sem();
 
-		par = (struct atyfb_par *) info->par;
-		nb = info->var.yres * info->fix.line_length;
-
-		switch (when) {
-		case PBOOK_SLEEP_REQUEST:
-			par->save_framebuffer = vmalloc(nb);
-			if (par->save_framebuffer == NULL)
-				return PBOOK_SLEEP_REFUSE;
-			break;
-		case PBOOK_SLEEP_REJECT:
-			if (par->save_framebuffer) {
-				vfree(par->save_framebuffer);
-				par->save_framebuffer = NULL;
-			}
-			break;
-		case PBOOK_SLEEP_NOW:
-			if (par->blitter_may_be_busy)
-				wait_for_idle(par);
-			/* Stop accel engine (stop bus mastering) */
-			if (par->accel_flags & FB_ACCELF_TEXT)
-				aty_reset_engine(par);
-
-			/* Backup fb content */
-			if (par->save_framebuffer)
-				memcpy_fromio(par->save_framebuffer,
-					      (void *) info->screen_base, nb);
-
-			/* Blank display and LCD */
-			atyfb_blank(VESA_POWERDOWN + 1, info);
-
-			/* Set chip to "suspend" mode */
-			result = aty_power_mgmt(1, par);
-			break;
-		case PBOOK_WAKE:
-			/* Wakeup chip */
-			result = aty_power_mgmt(0, par);
-
-			/* Restore fb content */
-			if (par->save_framebuffer) {
-				memcpy_toio((void *) info->screen_base,
-					    par->save_framebuffer, nb);
-				vfree(par->save_framebuffer);
-				par->save_framebuffer = NULL;
-			}
-			/* Restore display */
-			atyfb_set_par(info);
-			atyfb_blank(0, info);
-			break;
-		}
-	}
-	return result;
+	if (pdev->dev.power.power_state == 2)
+		aty_power_mgmt(0, par);
+	par->asleep = 0;
+
+	/* Restore display */
+	atyfb_set_par(info);
+
+	/* Refresh */
+	fb_set_suspend(info, 0);
+
+	/* Unblank */
+	par->lock_blank = 0;
+	atyfb_blank(FB_BLANK_UNBLANK, info);
+
+	release_console_sem();
+
+	pdev->dev.power.power_state = 0;
+
+	return 0;
 }
 
-static struct pmu_sleep_notifier aty_sleep_notifier = {
-	aty_sleep_notify, SLEEP_LEVEL_VIDEO,
-};
-#endif				/* CONFIG_PMAC_PBOOK */
+#endif /*  defined(CONFIG_PM) && defined(CONFIG_PCI) */
 
 #ifdef CONFIG_PMAC_BACKLIGHT
 
@@ -1489,9 +2136,34 @@
 	aty_set_backlight_enable,
 	aty_set_backlight_level
 };
-#endif				/* CONFIG_PMAC_BACKLIGHT */
+#endif /* CONFIG_PMAC_BACKLIGHT */
 
+static void __init aty_calc_mem_refresh(struct atyfb_par *par, int xclk)
+{
+	const int ragepro_tbl[] = {
+		44, 50, 55, 66, 75, 80, 100
+	};
+	const int ragexl_tbl[] = {
+		50, 66, 75, 83, 90, 95, 100, 105,
+		110, 115, 120, 125, 133, 143, 166
+	};
+	const int *refresh_tbl;
+	int i, size;
+
+	if (IS_XL(par->pci_id) || IS_MOBILITY(par->pci_id)) {
+		refresh_tbl = ragexl_tbl;
+		size = sizeof(ragexl_tbl)/sizeof(int);
+	} else {
+		refresh_tbl = ragepro_tbl;
+		size = sizeof(ragepro_tbl)/sizeof(int);
+	}
 
+	for (i=0; i < size; i++) {
+		if (xclk < refresh_tbl[i])
+		break;
+	}
+	par->mem_refresh_rate = i;
+}
 
     /*
      *  Initialisation
@@ -1502,37 +2174,44 @@
 static int __init aty_init(struct fb_info *info, const char *name)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	const char *chipname = NULL, *ramname = NULL, *xtal;
-	int j, pll, mclk, gtb_memsize;
+	const char *ramname = NULL, *xtal;
+	int gtb_memsize;
 	struct fb_var_screeninfo var;
-	u32 chip_id, i;
-	u16 type;
-	u8 rev;
+	u8 pll_ref_div;
+	u32 i;
 #if defined(CONFIG_PPC)
 	int sense;
 #endif
-	u8 pll_ref_div;
+
+	init_waitqueue_head(&par->vblank.wait);
+	spin_lock_init(&par->int_lock);
 
 	par->aty_cmap_regs =
-	    (struct aty_cmap_regs *) (par->ati_regbase + 0xc0);
-	chip_id = aty_ld_le32(CONFIG_CHIP_ID, par);
-	type = chip_id & CFG_CHIP_TYPE;
-	rev = (chip_id & CFG_CHIP_REV) >> 24;
-	for (j = 0; j < (sizeof(aty_chips) / sizeof(*aty_chips)); j++)
-		if (type == aty_chips[j].chip_type &&
-		    (rev & aty_chips[j].rev_mask) ==
-		    aty_chips[j].rev_val) {
-			chipname = aty_chips[j].name;
-			pll = aty_chips[j].pll;
-			mclk = aty_chips[j].mclk;
-			par->features = aty_chips[j].features;
-			goto found;
-		}
-	printk("atyfb: Unknown mach64 0x%04x rev 0x%04x\n", type, rev);
-	return 0;
+	    (struct aty_cmap_regs __iomem *) (par->ati_regbase + 0xc0);
+
+#ifdef CONFIG_PPC_PMAC
+	/* The Apple iBook1 uses non-standard memory frequencies. We detect it
+	 * and set the frequency manually. */
+	if (machine_is_compatible("PowerBook2,1")) {
+		par->pll_limits.mclk = 70;
+		par->pll_limits.xclk = 53;
+	}
+#endif
+	if (pll)
+		par->pll_limits.pll_max = pll;
+	if (mclk)
+		par->pll_limits.mclk = mclk;
+	if (xclk)
+		par->pll_limits.xclk = xclk;
+
+	aty_calc_mem_refresh(par, par->pll_limits.xclk);
+	par->pll_per = 1000000/par->pll_limits.pll_max;
+	par->mclk_per = 1000000/par->pll_limits.mclk;
+	par->xclk_per = 1000000/par->pll_limits.xclk;
+
+	par->ref_clk_per = 1000000000000ULL / 14318180;
+	xtal = "14.31818";
 
-      found:
-	printk("atyfb: %s [0x%04x rev 0x%02x] ", chipname, type, rev);
 #ifdef CONFIG_FB_ATY_GX
 	if (!M64_HAS(INTEGRATED)) {
 		u32 stat0;
@@ -1549,9 +2228,7 @@
 		if (dac_type == 0x07)
 			dac_subtype = DAC_ATT20C408;
 		else
-			dac_subtype =
-			    (aty_ld_8(SCRATCH_REG1 + 1, par) & 0xF0) |
-			    dac_type;
+			dac_subtype = (aty_ld_8(SCRATCH_REG1 + 1, par) & 0xF0) | dac_type;
 #else
 		dac_type = DAC_IBMRGB514;
 		dac_subtype = DAC_IBMRGB514;
@@ -1570,8 +2247,7 @@
 			par->dac_ops = &aty_dac_att21c498;
 			break;
 		default:
-			printk
-			    (" atyfb_set_par: DAC type not implemented yet!\n");
+			PRINTKI("aty_init: DAC type not implemented yet!\n");
 			par->dac_ops = &aty_dac_unsupported;
 			break;
 		}
@@ -1592,33 +2268,30 @@
 			par->pll_ops = &aty_pll_ibm514;
 			break;
 		default:
-			printk
-			    (" atyfb_set_par: CLK type not implemented yet!");
+			PRINTKI("aty_init: CLK type not implemented yet!");
 			par->pll_ops = &aty_pll_unsupported;
 			break;
 		}
 	}
-#endif				/* CONFIG_FB_ATY_GX */
+#endif /* CONFIG_FB_ATY_GX */
 #ifdef CONFIG_FB_ATY_CT
 	if (M64_HAS(INTEGRATED)) {
+		par->dac_ops = &aty_dac_ct;
+		par->pll_ops = &aty_pll_ct;
 		par->bus_type = PCI;
 		par->ram_type = (aty_ld_le32(CONFIG_STAT0, par) & 0x07);
 		ramname = aty_ct_ram[par->ram_type];
-		par->dac_ops = &aty_dac_ct;
-		par->pll_ops = &aty_pll_ct;
+
 		/* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz otherwise */
-		if (mclk == 67 && par->ram_type < SDRAM)
-			mclk = 63;
+		if (par->pll_limits.mclk == 67 && par->ram_type < SDRAM)
+			par->pll_limits.mclk = 63;
 	}
-#endif				/* CONFIG_FB_ATY_CT */
 
-	par->ref_clk_per = 1000000000000ULL / 14318180;
-	xtal = "14.31818";
 	if (M64_HAS(GTB_DSP)
-	    && (pll_ref_div = aty_ld_pll(PLL_REF_DIV, par))) {
+	    && (pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par))) {
 		int diff1, diff2;
-		diff1 = 510 * 14 / pll_ref_div - pll;
-		diff2 = 510 * 29 / pll_ref_div - pll;
+		diff1 = 510 * 14 / pll_ref_div - par->pll_limits.pll_max;
+		diff2 = 510 * 29 / pll_ref_div - par->pll_limits.pll_max;
 		if (diff1 < 0)
 			diff1 = -diff1;
 		if (diff2 < 0)
@@ -1628,6 +2301,12 @@
 			xtal = "29.498928";
 		}
 	}
+#endif /* CONFIG_FB_ATY_CT */
+
+	/* save previous video mode */
+	aty_get_crtc(par, &saved_crtc);
+	if(par->pll_ops->get_pll)
+		par->pll_ops->get_pll(info, &saved_pll);
 
 	i = aty_ld_le32(MEM_CNTL, par);
 	gtb_memsize = M64_HAS(GTB_DSP);
@@ -1682,8 +2361,8 @@
 			info->fix.smem_len += 0x400000;
 	}
 
-	if (default_vram) {
-		info->fix.smem_len = default_vram * 1024;
+	if (vram) {
+		info->fix.smem_len = vram * 1024;
 		i = i & ~(gtb_memsize ? 0xF : MEM_SIZE_ALIAS);
 		if (info->fix.smem_len <= 0x80000)
 			i |= MEM_SIZE_512K;
@@ -1701,7 +2380,7 @@
 	}
 
 	/*
-	 *  Reg Block 0 (CT-compatible block) is at mmio_start 
+	 *  Reg Block 0 (CT-compatible block) is at mmio_start
 	 *  Reg Block 1 (multimedia extensions) is at mmio_start - 0x400
 	 */
 	if (M64_HAS(GX)) {
@@ -1711,79 +2390,74 @@
 		info->fix.mmio_len = 0x400;
 		info->fix.accel = FB_ACCEL_ATI_MACH64CT;
 	} else if (M64_HAS(VT)) {
-		info->fix.mmio_start = -0x400;
+		info->fix.mmio_start -= 0x400;
 		info->fix.mmio_len = 0x800;
 		info->fix.accel = FB_ACCEL_ATI_MACH64VT;
-	} else {		/* if (M64_HAS(GT)) */
-
-		info->fix.mmio_start = -0x400;
+	} else {/* GT */
+		info->fix.mmio_start -= 0x400;
 		info->fix.mmio_len = 0x800;
 		info->fix.accel = FB_ACCEL_ATI_MACH64GT;
 	}
 
-	if (default_pll)
-		pll = default_pll;
-	if (default_mclk)
-		mclk = default_mclk;
-
-	printk("%d%c %s, %s MHz XTAL, %d MHz PLL, %d Mhz MCLK\n",
-	       info->fix.smem_len ==
-	       0x80000 ? 512 : (info->fix.smem_len >> 20),
-	       info->fix.smem_len == 0x80000 ? 'K' : 'M', ramname,
-	       xtal, pll, mclk);
-
-	if (mclk < 44)
-		par->mem_refresh_rate = 0;	/* 000 = 10 Mhz - 43 Mhz */
-	else if (mclk < 50)
-		par->mem_refresh_rate = 1;	/* 001 = 44 Mhz - 49 Mhz */
-	else if (mclk < 55)
-		par->mem_refresh_rate = 2;	/* 010 = 50 Mhz - 54 Mhz */
-	else if (mclk < 66)
-		par->mem_refresh_rate = 3;	/* 011 = 55 Mhz - 65 Mhz */
-	else if (mclk < 75)
-		par->mem_refresh_rate = 4;	/* 100 = 66 Mhz - 74 Mhz */
-	else if (mclk < 80)
-		par->mem_refresh_rate = 5;	/* 101 = 75 Mhz - 79 Mhz */
-	else if (mclk < 100)
-		par->mem_refresh_rate = 6;	/* 110 = 80 Mhz - 100 Mhz */
-	else
-		par->mem_refresh_rate = 7;	/* 111 = 100 Mhz and above */
-	par->pll_per = 1000000 / pll;
-	par->mclk_per = 1000000 / mclk;
+	PRINTKI("%d%c %s, %s MHz XTAL, %d MHz PLL, %d Mhz MCLK, %d MHz XCLK\n",
+	       info->fix.smem_len == 0x80000 ? 512 : (info->fix.smem_len >> 20),
+	       info->fix.smem_len == 0x80000 ? 'K' : 'M', ramname, xtal, par->pll_limits.pll_max,
+	       par->pll_limits.mclk, par->pll_limits.xclk);
 
-#ifdef DEBUG
+#if defined(DEBUG) && defined(CONFIG_ATY_CT)
 	if (M64_HAS(INTEGRATED)) {
 		int i;
-		printk
-		    ("BUS_CNTL DAC_CNTL MEM_CNTL EXT_MEM_CNTL CRTC_GEN_CNTL "
-		     "DSP_CONFIG DSP_ON_OFF\n"
-		     "%08x %08x %08x %08x     %08x      %08x   %08x\n"
-		     "PLL", aty_ld_le32(BUS_CNTL, par),
-		     aty_ld_le32(DAC_CNTL, par), aty_ld_le32(MEM_CNTL,
-							     par),
-		     aty_ld_le32(EXT_MEM_CNTL, par),
-		     aty_ld_le32(CRTC_GEN_CNTL, par),
-		     aty_ld_le32(DSP_CONFIG, par), aty_ld_le32(DSP_ON_OFF,
-							       par));
-		for (i = 0; i < 16; i++)
-			printk(" %02x", aty_ld_pll(i, par));
+		printk("debug atyfb: BUS_CNTL DAC_CNTL MEM_CNTL EXT_MEM_CNTL CRTC_GEN_CNTL "
+		       "DSP_CONFIG DSP_ON_OFF CLOCK_CNTL\n"
+		       "debug atyfb: %08x %08x %08x %08x     %08x      %08x   %08x   %08x\n"
+		       "debug atyfb: PLL",
+			aty_ld_le32(BUS_CNTL, par), aty_ld_le32(DAC_CNTL, par),
+			aty_ld_le32(MEM_CNTL, par), aty_ld_le32(EXT_MEM_CNTL, par),
+			aty_ld_le32(CRTC_GEN_CNTL, par), aty_ld_le32(DSP_CONFIG, par),
+			aty_ld_le32(DSP_ON_OFF, par), aty_ld_le32(CLOCK_CNTL, par));
+		for (i = 0; i < 40; i++)
+			printk(" %02x", aty_ld_pll_ct(i, par));
 		printk("\n");
 	}
 #endif
+	if(par->pll_ops->init_pll)
+		par->pll_ops->init_pll(info, &par->pll);
 
 	/*
 	 *  Last page of 8 MB (4 MB on ISA) aperture is MMIO
 	 *  FIXME: we should use the auxiliary aperture instead so we can access
 	 *  the full 8 MB of video RAM on 8 MB boards
 	 */
-	if (info->fix.smem_len == 0x800000 ||
-	    (par->bus_type == ISA 
-	     && info->fix.smem_len == 0x400000))
+
+	if (!par->aux_start &&
+		(info->fix.smem_len == 0x800000 || (par->bus_type == ISA && info->fix.smem_len == 0x400000)))
 		info->fix.smem_len -= GUI_RESERVE;
 
-	/* Clear the video memory */
-	fb_memset((void *) info->screen_base, 0,
-		  info->fix.smem_len);
+	/*
+	 *  Disable register access through the linear aperture
+	 *  if the auxiliary aperture is used so we can access
+	 *  the full 8 MB of video RAM on 8 MB boards.
+	 */
+	if (par->aux_start)
+		aty_st_le32(BUS_CNTL, aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par);
+
+#ifdef CONFIG_MTRR
+	par->mtrr_aper = -1;
+	par->mtrr_reg = -1;
+	if (!nomtrr) {
+		/* Cover the whole resource. */
+		 par->mtrr_aper = mtrr_add(par->res_start, par->res_size, MTRR_TYPE_WRCOMB, 1);
+		 if (par->mtrr_aper >= 0 && !par->aux_start) {
+			/* Make a hole for mmio. */
+			par->mtrr_reg = mtrr_add(par->res_start + 0x800000 - GUI_RESERVE,
+				GUI_RESERVE, MTRR_TYPE_UNCACHABLE, 1);
+			if (par->mtrr_reg < 0) {
+				mtrr_del(par->mtrr_aper, 0, 0);
+				par->mtrr_aper = -1;
+			}
+		 }
+	}
+#endif
 
 	info->fbops = &atyfb_ops;
 	info->pseudo_palette = pseudo_palette;
@@ -1792,18 +2466,12 @@
 #ifdef CONFIG_PMAC_BACKLIGHT
 	if (M64_HAS(G3_PB_1_1) && machine_is_compatible("PowerBook1,1")) {
 		/* these bits let the 101 powerbook wake up from sleep -- paulus */
-		aty_st_lcd(POWER_MANAGEMENT,
-			   aty_ld_lcd(POWER_MANAGEMENT, par)
+		aty_st_lcd(POWER_MANAGEMENT, aty_ld_lcd(POWER_MANAGEMENT, par)
 			   | (USE_F32KHZ | TRISTATE_MEM_EN), par);
-	}
-	if (M64_HAS(MOBIL_BUS))
-		register_backlight_controller(&aty_backlight_controller,
-					      info, "ati");
-#endif				/* CONFIG_PMAC_BACKLIGHT */
+	} else if (M64_HAS(MOBIL_BUS))
+		register_backlight_controller(&aty_backlight_controller, info, "ati");
+#endif /* CONFIG_PMAC_BACKLIGHT */
 
-#ifdef MODULE
-	var = default_var;
-#else				/* !MODULE */
 	memset(&var, 0, sizeof(var));
 #ifdef CONFIG_PPC
 	if (_machine == _MACH_Pmac) {
@@ -1811,9 +2479,8 @@
 		 *  FIXME: The NVRAM stuff should be put in a Mac-specific file, as it
 		 *         applies to all Mac video cards
 		 */
-		if (mode_option) {
-			if (!mac_find_mode
-			    (&var, info, mode_option, 8))
+		if (mode) {
+			if (!mac_find_mode(&var, info, mode, 8))
 				var = default_var;
 		} else {
 			if (default_vmode == VMODE_CHOOSE) {
@@ -1829,484 +2496,951 @@
 				else
 					default_vmode = VMODE_640_480_67;
 				sense = read_aty_sense(par);
-				printk(KERN_INFO
-				       "atyfb: monitor sense=%x, mode %d\n",
-				       sense,
-				       mac_map_monitor_sense(sense));
+				PRINTKI("monitor sense=%x, mode %d\n",
+					sense,  mac_map_monitor_sense(sense));
 			}
-			if (default_vmode <= 0
-			    || default_vmode > VMODE_MAX)
+			if (default_vmode <= 0 || default_vmode > VMODE_MAX)
 				default_vmode = VMODE_640_480_60;
-			if (default_cmode < CMODE_8
-			    || default_cmode > CMODE_32)
+			if (default_cmode < CMODE_8 || default_cmode > CMODE_32)
 				default_cmode = CMODE_8;
-			if (mac_vmode_to_var
-			    (default_vmode, default_cmode, &var))
+			if (mac_vmode_to_var(default_vmode, default_cmode, &var))
 				var = default_var;
 		}
 	} else
-	    if (!fb_find_mode
-		(&var, info, mode_option, NULL, 0, NULL, 8))
-		var = default_var;
-#else				/* !CONFIG_PPC */
-#ifdef __sparc__
-	if (mode_option) {
-		if (!fb_find_mode
-		    (&var, info, mode_option, NULL, 0, NULL, 8))
-			var = default_var;
-	} else
+#endif /* !CONFIG_PPC */
+	if (!fb_find_mode(&var, info, mode, NULL, 0, &defmode, 8))
 		var = default_var;
-#else
-	if (!fb_find_mode
-	    (&var, info, mode_option, NULL, 0, NULL, 8))
-		var = default_var;
-#endif				/* !__sparc__ */
-#endif				/* !CONFIG_PPC */
-#endif				/* !MODULE */
+
 	if (noaccel)
 		var.accel_flags &= ~FB_ACCELF_TEXT;
 	else
 		var.accel_flags |= FB_ACCELF_TEXT;
 
 	if (var.yres == var.yres_virtual) {
-		u32 vram = (info->fix.smem_len - (PAGE_SIZE << 2));
-		var.yres_virtual =
-		    ((vram * 8) / var.bits_per_pixel) / var.xres_virtual;
+		u32 videoram = (info->fix.smem_len - (PAGE_SIZE << 2));
+		var.yres_virtual = ((videoram * 8) / var.bits_per_pixel) / var.xres_virtual;
 		if (var.yres_virtual < var.yres)
 			var.yres_virtual = var.yres;
 	}
 
 	if (atyfb_check_var(&var, info)) {
-		printk("atyfb: can't set default video mode\n");
-		return 0;
+		PRINTKE("can't set default video mode\n");
+		goto aty_init_exit;
 	}
+
 #ifdef __sparc__
 	atyfb_save_palette(par, 0);
 #endif
 
 #ifdef CONFIG_FB_ATY_CT
-	if (curblink && M64_HAS(INTEGRATED))
-		par->cursor = aty_init_cursor(info);
-#endif				/* CONFIG_FB_ATY_CT */
+	if (!noaccel && M64_HAS(INTEGRATED))
+		aty_init_cursor(info);
+#endif /* CONFIG_FB_ATY_CT */
 	info->var = var;
 
 	fb_alloc_cmap(&info->cmap, 256, 0);
 
 	if (register_framebuffer(info) < 0)
-		return 0;
+		goto aty_init_exit;
 
 	fb_list = info;
 
-	printk("fb%d: %s frame buffer device on %s\n",
+	PRINTKI("fb%d: %s frame buffer device on %s\n",
 	       info->node, info->fix.id, name);
-	return 1;
+	return 0;
+
+aty_init_exit:
+	/* restore video mode */
+	aty_set_crtc(par, &saved_crtc);
+	par->pll_ops->set_pll(info, &saved_pll);
+
+#ifdef CONFIG_MTRR
+	if (par->mtrr_reg >= 0) {
+	    mtrr_del(par->mtrr_reg, 0, 0);
+	    par->mtrr_reg = -1;
+	}
+	if (par->mtrr_aper >= 0) {
+	    mtrr_del(par->mtrr_aper, 0, 0);
+	    par->mtrr_aper = -1;
+	}
+#endif
+	return -1;
 }
 
-int __init atyfb_do_init(void)
+#ifdef CONFIG_ATARI
+static int __init store_video_par(char *video_str, unsigned char m64_num)
 {
-#if defined(CONFIG_PCI)
-	unsigned long addr, res_start, res_size;
-	struct atyfb_par *default_par;
-	struct pci_dev *pdev = NULL;
-	struct fb_info *info;
-	int i;
+	char *p;
+	unsigned long vmembase, size, guiregbase;
+
+	PRINTKI("store_video_par() '%s' \n", video_str);
+
+	if (!(p = strsep(&video_str, ";")) || !*p)
+		goto mach64_invalid;
+	vmembase = simple_strtoul(p, NULL, 0);
+	if (!(p = strsep(&video_str, ";")) || !*p)
+		goto mach64_invalid;
+	size = simple_strtoul(p, NULL, 0);
+	if (!(p = strsep(&video_str, ";")) || !*p)
+		goto mach64_invalid;
+	guiregbase = simple_strtoul(p, NULL, 0);
+
+	phys_vmembase[m64_num] = vmembase;
+	phys_size[m64_num] = size;
+	phys_guiregbase[m64_num] = guiregbase;
+	PRINTKI("stored them all: $%08lX $%08lX $%08lX \n", vmembase, size,
+	       guiregbase);
+	return 0;
+
+      mach64_invalid:
+	phys_vmembase[m64_num] = 0;
+	return -1;
+}
+#endif /* CONFIG_ATARI */
+
+    /*
+     *  Blank the display.
+     */
+
+static int atyfb_blank(int blank, struct fb_info *info)
+{
+	struct atyfb_par *par = (struct atyfb_par *) info->par;
+	u8 gen_cntl;
+
+	if (par->lock_blank || par->asleep)
+		return 0;
+
+#ifdef CONFIG_PMAC_BACKLIGHT
+	if ((_machine == _MACH_Pmac) && blank)
+		set_backlight_enable(0);
+#elif defined(CONFIG_FB_ATY_GENERIC_LCD)
+	if (par->lcd_table && blank &&
+	    (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {
+		u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par);
+		pm &= ~PWR_BLON;
+		aty_st_lcd(POWER_MANAGEMENT, pm, par);
+	}
+#endif
+
+	gen_cntl = aty_ld_8(CRTC_GEN_CNTL, par);
+	switch (blank) {
+        	case FB_BLANK_UNBLANK:
+			gen_cntl &= ~(0x4c);
+			break;
+		case FB_BLANK_NORMAL:
+			gen_cntl |= 0x40;
+			break;
+		case FB_BLANK_VSYNC_SUSPEND:
+			gen_cntl |= 0x8;
+			break;
+		case FB_BLANK_HSYNC_SUSPEND:
+			gen_cntl |= 0x4;
+			break;
+		case FB_BLANK_POWERDOWN:
+			gen_cntl |= 0x4c;
+			break;
+	}
+	aty_st_8(CRTC_GEN_CNTL, gen_cntl, par);
+
+#ifdef CONFIG_PMAC_BACKLIGHT
+	if ((_machine == _MACH_Pmac) && !blank)
+		set_backlight_enable(1);
+#elif defined(CONFIG_FB_ATY_GENERIC_LCD)
+	if (par->lcd_table && !blank &&
+	    (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {
+		u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par);
+		pm |= PWR_BLON;
+		aty_st_lcd(POWER_MANAGEMENT, pm, par);
+	}
+#endif
+
+	return 0;
+}
+
+static void aty_st_pal(u_int regno, u_int red, u_int green, u_int blue,
+		       const struct atyfb_par *par)
+{
+#ifdef CONFIG_ATARI
+	out_8(&par->aty_cmap_regs->windex, regno);
+	out_8(&par->aty_cmap_regs->lut, red);
+	out_8(&par->aty_cmap_regs->lut, green);
+	out_8(&par->aty_cmap_regs->lut, blue);
+#else
+	writeb(regno, &par->aty_cmap_regs->windex);
+	writeb(red, &par->aty_cmap_regs->lut);
+	writeb(green, &par->aty_cmap_regs->lut);
+	writeb(blue, &par->aty_cmap_regs->lut);
+#endif
+}
+
+    /*
+     *  Set a single color register. The values supplied are already
+     *  rounded down to the hardware's capabilities (according to the
+     *  entries in the var structure). Return != 0 for invalid regno.
+     *  !! 4 & 8 =  PSEUDO, > 8 = DIRECTCOLOR
+     */
+
+static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
+	u_int transp, struct fb_info *info)
+{
+	struct atyfb_par *par = (struct atyfb_par *) info->par;
+	int i, depth;
+	u32 *pal = info->pseudo_palette;
+
+	depth = info->var.bits_per_pixel;
+	if (depth == 16)
+		depth = (info->var.green.length == 5) ? 15 : 16;
+
+	if (par->asleep)
+		return 0;
+
+	if (regno > 255 ||
+	    (depth == 16 && regno > 63) ||
+	    (depth == 15 && regno > 31))
+		return 1;
+
+	red >>= 8;
+	green >>= 8;
+	blue >>= 8;
+
+	par->palette[regno].red = red;
+	par->palette[regno].green = green;
+	par->palette[regno].blue = blue;
+
+	if (regno < 16) {
+		switch (depth) {
+		case 15:
+			pal[regno] = (regno << 10) | (regno << 5) | regno;
+			break;
+		case 16:
+			pal[regno] = (regno << 11) | (regno << 5) | regno;
+			break;
+		case 24:
+			pal[regno] = (regno << 16) | (regno << 8) | regno;
+			break;
+		case 32:
+			i = (regno << 8) | regno;
+			pal[regno] = (i << 16) | i;
+			break;
+		}
+	}
+
+	i = aty_ld_8(DAC_CNTL, par) & 0xfc;
+	if (M64_HAS(EXTRA_BRIGHT))
+		i |= 0x2; /* DAC_CNTL | 0x2 turns off the extra brightness for gt */
+	aty_st_8(DAC_CNTL, i, par);
+	aty_st_8(DAC_MASK, 0xff, par);
+
+	if (M64_HAS(INTEGRATED)) {
+		if (depth == 16) {
+			if (regno < 32)
+				aty_st_pal(regno << 3, red,
+					   par->palette[regno<<1].green,
+					   blue, par);
+			red = par->palette[regno>>1].red;
+			blue = par->palette[regno>>1].blue;
+			regno <<= 2;
+		} else if (depth == 15) {
+			regno <<= 3;
+			for(i = 0; i < 8; i++) {
+			    aty_st_pal(regno + i, red, green, blue, par);
+			}
+		}
+	}
+	aty_st_pal(regno, red, green, blue, par);
+
+	return 0;
+}
+
+#ifdef CONFIG_PCI
+
 #ifdef __sparc__
-	extern void (*prom_palette) (int);
+
+extern void (*prom_palette) (int);
+
+static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
+			struct fb_info *info, unsigned long addr)
+{
 	extern int con_is_present(void);
+
+	struct atyfb_par *par = info->par;
 	struct pcidev_cookie *pcp;
 	char prop[128];
-	int node, len, j;
+	int node, len, i, j, ret;
 	u32 mem, chip_id;
-#else
-	u16 tmp;
-#endif
 
-#ifdef __sparc__
 	/* Do not attach when we have a serial console. */
 	if (!con_is_present())
 		return -ENXIO;
-#endif
 
-	while ((pdev =
-		pci_find_device(PCI_VENDOR_ID_ATI, PCI_ANY_ID, pdev))) {
-		if ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
-			struct resource *rp;
-
-			for (i =
-			     sizeof(aty_chips) / sizeof(*aty_chips) - 1;
-			     i >= 0; i--)
-				if (pdev->device == aty_chips[i].pci_id)
-					break;
-			if (i < 0)
-				continue;
+	/*
+	 * Map memory-mapped registers.
+	 */
+	par->ati_regbase = (void *)addr + 0x7ffc00UL;
+	info->fix.mmio_start = addr + 0x7ffc00UL;
 
-			rp = &pdev->resource[0];
-			if (rp->flags & IORESOURCE_IO)
-				rp = &pdev->resource[1];
-			addr = rp->start;
-			if (!addr)
-				continue;
+	/*
+	 * Map in big-endian aperture.
+	 */
+	info->screen_base = (char *) (addr + 0x800000UL);
+	info->fix.smem_start = addr + 0x800000UL;
 
-			res_start = rp->start;
-			res_size = rp->end - rp->start + 1;
-			if (!request_mem_region
-			    (res_start, res_size, "atyfb"))
-				continue;
+	/*
+	 * Figure mmap addresses from PCI config space.
+	 * Split Framebuffer in big- and little-endian halfs.
+	 */
+	for (i = 0; i < 6 && pdev->resource[i].start; i++)
+		/* nothing */ ;
+	j = i + 4;
 
-			info =
-			    kmalloc(sizeof(struct fb_info), GFP_ATOMIC);
-			if (!info) {
-				printk
-				    ("atyfb_init: can't alloc fb_info\n");
-				return -ENXIO;
-			}
-			memset(info, 0, sizeof(struct fb_info));
+	par->mmap_map = kmalloc(j * sizeof(*par->mmap_map), GFP_ATOMIC);
+	if (!par->mmap_map) {
+		PRINTKE("atyfb_setup_sparc() can't alloc mmap_map\n");
+		return -ENOMEM;
+	}
+	memset(par->mmap_map, 0, j * sizeof(*par->mmap_map));
 
-			default_par =
-			    kmalloc(sizeof(struct atyfb_par), GFP_ATOMIC);
-			if (!default_par) {
-				printk
-				    ("atyfb_init: can't alloc atyfb_par\n");
-				kfree(info);
-				return -ENXIO;
-			}
-			memset(default_par, 0, sizeof(struct atyfb_par));
+	for (i = 0, j = 2; i < 6 && pdev->resource[i].start; i++) {
+		struct resource *rp = &pdev->resource[i];
+		int io, breg = PCI_BASE_ADDRESS_0 + (i << 2);
+		unsigned long base;
+		u32 size, pbase;
 
-			info->fix = atyfb_fix;
-			info->par = default_par;
+		base = rp->start;
 
-#ifdef __sparc__
-			/*
-			 * Map memory-mapped registers.
-			 */
-			default_par->ati_regbase = addr + 0x7ffc00UL;
-			info->fix.mmio_start = addr + 0x7ffc00UL;
+		io = (rp->flags & IORESOURCE_IO);
 
-			/*
-			 * Map in big-endian aperture.
-			 */
-			info->screen_base = (char *) (addr + 0x800000UL);
-			info->fix.smem_start = addr + 0x800000UL;
+		size = rp->end - base + 1;
 
-			/*
-			 * Figure mmap addresses from PCI config space.
-			 * Split Framebuffer in big- and little-endian halfs.
-			 */
-			for (i = 0; i < 6 && pdev->resource[i].start; i++)
-				/* nothing */ ;
-			j = i + 4;
-
-			default_par->mmap_map =
-			    kmalloc(j * sizeof(*default_par->mmap_map),
-				    GFP_ATOMIC);
-			if (!default_par->mmap_map) {
-				printk
-				    ("atyfb_init: can't alloc mmap_map\n");
-				kfree(default_par);
-				kfree(info);
-				release_mem_region(res_start, res_size);
-				return -ENXIO;
+		pci_read_config_dword(pdev, breg, &pbase);
+
+		if (io)
+			size &= ~1;
+
+		/*
+		 * Map the framebuffer a second time, this time without
+		 * the braindead _PAGE_IE setting. This is used by the
+		 * fixed Xserver, but we need to maintain the old mapping
+		 * to stay compatible with older ones...
+		 */
+		if (base == addr) {
+			par->mmap_map[j].voff = (pbase + 0x10000000) & PAGE_MASK;
+			par->mmap_map[j].poff = base & PAGE_MASK;
+			par->mmap_map[j].size = (size + ~PAGE_MASK) & PAGE_MASK;
+			par->mmap_map[j].prot_mask = _PAGE_CACHE;
+			par->mmap_map[j].prot_flag = _PAGE_E;
+			j++;
+		}
+
+		/*
+		 * Here comes the old framebuffer mapping with _PAGE_IE
+		 * set for the big endian half of the framebuffer...
+		 */
+		if (base == addr) {
+			par->mmap_map[j].voff = (pbase + 0x800000) & PAGE_MASK;
+			par->mmap_map[j].poff = (base + 0x800000) & PAGE_MASK;
+			par->mmap_map[j].size = 0x800000;
+			par->mmap_map[j].prot_mask = _PAGE_CACHE;
+			par->mmap_map[j].prot_flag = _PAGE_E | _PAGE_IE;
+			size -= 0x800000;
+			j++;
+		}
+
+		par->mmap_map[j].voff = pbase & PAGE_MASK;
+		par->mmap_map[j].poff = base & PAGE_MASK;
+		par->mmap_map[j].size = (size + ~PAGE_MASK) & PAGE_MASK;
+		par->mmap_map[j].prot_mask = _PAGE_CACHE;
+		par->mmap_map[j].prot_flag = _PAGE_E;
+		j++;
+	}
+
+	if((ret = correct_chipset(par)))
+		return ret;
+
+	if (IS_XL(pdev->device)) {
+		/*
+		 * Fix PROMs idea of MEM_CNTL settings...
+		 */
+		mem = aty_ld_le32(MEM_CNTL, par);
+		chip_id = aty_ld_le32(CONFIG_CHIP_ID, par);
+		if (((chip_id & CFG_CHIP_TYPE) == VT_CHIP_ID) && !((chip_id >> 24) & 1)) {
+			switch (mem & 0x0f) {
+			case 3:
+				mem = (mem & ~(0x0f)) | 2;
+				break;
+			case 7:
+				mem = (mem & ~(0x0f)) | 3;
+				break;
+			case 9:
+				mem = (mem & ~(0x0f)) | 4;
+				break;
+			case 11:
+				mem = (mem & ~(0x0f)) | 5;
+				break;
+			default:
+				break;
 			}
-			memset(default_par->mmap_map, 0,
-			       j * sizeof(*default_par->mmap_map));
+			if ((aty_ld_le32(CONFIG_STAT0, par) & 7) >= SDRAM)
+				mem &= ~(0x00700000);
+		}
+		mem &= ~(0xcf80e000);	/* Turn off all undocumented bits. */
+		aty_st_le32(MEM_CNTL, mem, par);
+	}
 
-			for (i = 0, j = 2;
-			     i < 6 && pdev->resource[i].start; i++) {
-				struct resource *rp = &pdev->resource[i];
-				int io, breg =
-				    PCI_BASE_ADDRESS_0 + (i << 2);
-				unsigned long base;
-				u32 size, pbase;
+	/*
+	 * If this is the console device, we will set default video
+	 * settings to what the PROM left us with.
+	 */
+	node = prom_getchild(prom_root_node);
+	node = prom_searchsiblings(node, "aliases");
+	if (node) {
+		len = prom_getproperty(node, "screen", prop, sizeof(prop));
+		if (len > 0) {
+			prop[len] = '\0';
+			node = prom_finddevice(prop);
+		} else
+			node = 0;
+	}
 
-				base = rp->start;
+	pcp = pdev->sysdata;
+	if (node == pcp->prom_node) {
+		struct fb_var_screeninfo *var = &default_var;
+		unsigned int N, P, Q, M, T, R;
+		u32 v_total, h_total;
+		struct crtc crtc;
+		u8 pll_regs[16];
+		u8 clock_cntl;
+
+		crtc.vxres = prom_getintdefault(node, "width", 1024);
+		crtc.vyres = prom_getintdefault(node, "height", 768);
+		var->bits_per_pixel = prom_getintdefault(node, "depth", 8);
+		var->xoffset = var->yoffset = 0;
+		crtc.h_tot_disp = aty_ld_le32(CRTC_H_TOTAL_DISP, par);
+		crtc.h_sync_strt_wid = aty_ld_le32(CRTC_H_SYNC_STRT_WID, par);
+		crtc.v_tot_disp = aty_ld_le32(CRTC_V_TOTAL_DISP, par);
+		crtc.v_sync_strt_wid = aty_ld_le32(CRTC_V_SYNC_STRT_WID, par);
+		crtc.gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par);
+		aty_crtc_to_var(&crtc, var);
 
-				io = (rp->flags & IORESOURCE_IO);
+		h_total = var->xres + var->right_margin + var->hsync_len + var->left_margin;
+		v_total = var->yres + var->lower_margin + var->vsync_len + var->upper_margin;
 
-				size = rp->end - base + 1;
+		/*
+		 * Read the PLL to figure actual Refresh Rate.
+		 */
+		clock_cntl = aty_ld_8(CLOCK_CNTL, par);
+		/* DPRINTK("CLOCK_CNTL %02x\n", clock_cntl); */
+		for (i = 0; i < 16; i++)
+			pll_regs[i] = aty_ld_pll_ct(i, par);
 
-				pci_read_config_dword(pdev, breg, &pbase);
+		/*
+		 * PLL Reference Divider M:
+		 */
+		M = pll_regs[2];
 
-				if (io)
-					size &= ~1;
+		/*
+		 * PLL Feedback Divider N (Dependant on CLOCK_CNTL):
+		 */
+		N = pll_regs[7 + (clock_cntl & 3)];
 
-				/*
-				 * Map the framebuffer a second time, this time without
-				 * the braindead _PAGE_IE setting. This is used by the
-				 * fixed Xserver, but we need to maintain the old mapping
-				 * to stay compatible with older ones...
-				 */
-				if (base == addr) {
-					default_par->mmap_map[j].voff =
-					    (pbase +
-					     0x10000000) & PAGE_MASK;
-					default_par->mmap_map[j].poff =
-					    base & PAGE_MASK;
-					default_par->mmap_map[j].size =
-					    (size +
-					     ~PAGE_MASK) & PAGE_MASK;
-					default_par->mmap_map[j].prot_mask =
-					    _PAGE_CACHE;
-					default_par->mmap_map[j].prot_flag =
-					    _PAGE_E;
-					j++;
-				}
+		/*
+		 * PLL Post Divider P (Dependant on CLOCK_CNTL):
+		 */
+		P = 1 << (pll_regs[6] >> ((clock_cntl & 3) << 1));
 
-				/*
-				 * Here comes the old framebuffer mapping with _PAGE_IE
-				 * set for the big endian half of the framebuffer...
-				 */
-				if (base == addr) {
-					default_par->mmap_map[j].voff =
-					    (pbase + 0x800000) & PAGE_MASK;
-					default_par->mmap_map[j].poff =
-					    (base + 0x800000) & PAGE_MASK;
-					default_par->mmap_map[j].size = 0x800000;
-					default_par->mmap_map[j].prot_mask =
-					    _PAGE_CACHE;
-					default_par->mmap_map[j].prot_flag =
-					    _PAGE_E | _PAGE_IE;
-					size -= 0x800000;
-					j++;
-				}
+		/*
+		 * PLL Divider Q:
+		 */
+		Q = N / P;
 
-				default_par->mmap_map[j].voff = pbase & PAGE_MASK;
-				default_par->mmap_map[j].poff = base & PAGE_MASK;
-				default_par->mmap_map[j].size =
-				    (size + ~PAGE_MASK) & PAGE_MASK;
-				default_par->mmap_map[j].prot_mask = _PAGE_CACHE;
-				default_par->mmap_map[j].prot_flag = _PAGE_E;
-				j++;
-			}
+		/*
+		 * Target Frequency:
+		 *
+		 *      T * M
+		 * Q = -------
+		 *      2 * R
+		 *
+		 * where R is XTALIN (= 14318 or 29498 kHz).
+		 */
+		if (IS_XL(pdev->device))
+			R = 29498;
+		else
+			R = 14318;
 
-			if (pdev->device != XL_CHIP_ID) {
-				/*
-				 * Fix PROMs idea of MEM_CNTL settings...
-				 */
-				mem = aty_ld_le32(MEM_CNTL, default_par);
-				chip_id = aty_ld_le32(CONFIG_CHIP_ID, default_par);
-				if (((chip_id & CFG_CHIP_TYPE) == VT_CHIP_ID)
-				    && !((chip_id >> 24) & 1)) {
-					switch (mem & 0x0f) {
-					case 3:
-						mem = (mem & ~(0x0f)) | 2;
-						break;
-					case 7:
-						mem = (mem & ~(0x0f)) | 3;
-						break;
-					case 9:
-						mem = (mem & ~(0x0f)) | 4;
-						break;
-					case 11:
-						mem = (mem & ~(0x0f)) | 5;
-						break;
-					default:
-						break;
-					}
-					if ((aty_ld_le32(CONFIG_STAT0, default_par) & 7) >= SDRAM)
-						mem &= ~(0x00700000);
-				}
-				mem &= ~(0xcf80e000);	/* Turn off all undocumented bits. */
-				aty_st_le32(MEM_CNTL, mem, default_par);
-			}
+		T = 2 * Q * R / M;
 
-			/*
-			 * If this is the console device, we will set default video
-			 * settings to what the PROM left us with.
-			 */
-			node = prom_getchild(prom_root_node);
-			node = prom_searchsiblings(node, "aliases");
-			if (node) {
-				len =
-				    prom_getproperty(node, "screen", prop,
-						     sizeof(prop));
-				if (len > 0) {
-					prop[len] = '\0';
-					node = prom_finddevice(prop);
+		default_var.pixclock = 1000000000 / T;
+	}
+
+	return 0;
+}
+
+#else /* __sparc__ */
+
+#ifdef __i386__
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+void aty_init_lcd(struct atyfb_par *par, u32 bios_base)
+{
+	u32 driv_inf_tab, sig;
+	u16 lcd_ofs;
+
+	/* To support an LCD panel, we should know it's dimensions and
+	 *  it's desired pixel clock.
+	 * There are two ways to do it:
+	 *  - Check the startup video mode and calculate the panel
+	 *    size from it. This is unreliable.
+	 *  - Read it from the driver information table in the video BIOS.
+	*/
+	/* Address of driver information table is at offset 0x78. */
+	driv_inf_tab = bios_base + *((u16 *)(bios_base+0x78));
+
+	/* Check for the driver information table signature. */
+	sig = (*(u32 *)driv_inf_tab);
+	if ((sig == 0x54504c24) || /* Rage LT pro */
+		(sig == 0x544d5224) || /* Rage mobility */
+		(sig == 0x54435824) || /* Rage XC */
+		(sig == 0x544c5824)) { /* Rage XL */
+		PRINTKI("BIOS contains driver information table.\n");
+		lcd_ofs = (*(u16 *)(driv_inf_tab + 10));
+		par->lcd_table = 0;
+		if (lcd_ofs != 0) {
+			par->lcd_table = bios_base + lcd_ofs;
+		}
+	}
+
+	if (par->lcd_table != 0) {
+		char model[24];
+		char strbuf[16];
+		char refresh_rates_buf[100];
+		int id, tech, f, i, m, default_refresh_rate;
+		char *txtcolour;
+		char *txtmonitor;
+		char *txtdual;
+		char *txtformat;
+		u16 width, height, panel_type, refresh_rates;
+		u16 *lcdmodeptr;
+		u32 format;
+		u8 lcd_refresh_rates[16] = {50,56,60,67,70,72,75,76,85,90,100,120,140,150,160,200};
+		/* The most important information is the panel size at
+		 * offset 25 and 27, but there's some other nice information
+		 * which we print to the screen.
+		 */
+		id = *(u8 *)par->lcd_table;
+		strncpy(model,(char *)par->lcd_table+1,24);
+		model[23]=0;
+
+		width = par->lcd_width = *(u16 *)(par->lcd_table+25);
+		height = par->lcd_height = *(u16 *)(par->lcd_table+27);
+		panel_type = *(u16 *)(par->lcd_table+29);
+		if (panel_type & 1)
+			txtcolour = "colour";
+		else
+			txtcolour = "monochrome";
+		if (panel_type & 2)
+			txtdual = "dual (split) ";
+		else
+			txtdual = "";
+		tech = (panel_type>>2) & 63;
+		switch (tech) {
+		case 0:
+			txtmonitor = "passive matrix";
+			break;
+		case 1:
+			txtmonitor = "active matrix";
+			break;
+		case 2:
+			txtmonitor = "active addressed STN";
+			break;
+		case 3:
+			txtmonitor = "EL";
+			break;
+		case 4:
+			txtmonitor = "plasma";
+			break;
+		default:
+			txtmonitor = "unknown";
+		}
+		format = *(u32 *)(par->lcd_table+57);
+		if (tech == 0 || tech == 2) {
+			switch (format & 7) {
+			case 0:
+				txtformat = "12 bit interface";
+				break;
+			case 1:
+				txtformat = "16 bit interface";
+				break;
+			case 2:
+				txtformat = "24 bit interface";
+				break;
+			default:
+				txtformat = "unkown format";
+			}
+		} else {
+			switch (format & 7) {
+			case 0:
+				txtformat = "8 colours";
+				break;
+			case 1:
+				txtformat = "512 colours";
+				break;
+			case 2:
+				txtformat = "4096 colours";
+				break;
+			case 4:
+				txtformat = "262144 colours (LT mode)";
+				break;
+			case 5:
+				txtformat = "16777216 colours";
+				break;
+			case 6:
+				txtformat = "262144 colours (FDPI-2 mode)";
+				break;
+			default:
+				txtformat = "unkown format";
+			}
+		}
+		PRINTKI("%s%s %s monitor detected: %s\n",
+			txtdual ,txtcolour, txtmonitor, model);
+		PRINTKI("       id=%d, %dx%d pixels, %s\n",
+			id, width, height, txtformat);
+		refresh_rates_buf[0] = 0;
+		refresh_rates = *(u16 *)(par->lcd_table+62);
+		m = 1;
+		f = 0;
+		for (i=0;i<16;i++) {
+			if (refresh_rates & m) {
+				if (f == 0) {
+					sprintf(strbuf, "%d", lcd_refresh_rates[i]);
+					f++;
 				} else {
-					node = 0;
+					sprintf(strbuf, ",%d", lcd_refresh_rates[i]);
 				}
+				strcat(refresh_rates_buf,strbuf);
+			}
+			m = m << 1;
+		}
+		default_refresh_rate = (*(u8 *)(par->lcd_table+61) & 0xf0) >> 4;
+		PRINTKI("       supports refresh rates [%s], default %d Hz\n",
+			refresh_rates_buf, lcd_refresh_rates[default_refresh_rate]);
+		par->lcd_refreshrate = lcd_refresh_rates[default_refresh_rate];
+		/* We now need to determine the crtc parameters for the
+		 * lcd monitor. This is tricky, because they are not stored
+		 * individually in the BIOS. Instead, the BIOS contains a
+		 * table of display modes that work for this monitor.
+		 *
+		 * The idea is that we search for a mode of the same dimensions
+		 * as the dimensions of the lcd monitor. Say our lcd monitor
+		 * is 800x600 pixels, we search for a 800x600 monitor.
+		 * The CRTC parameters we find here are the ones that we need
+		 * to use to simulate other resolutions on the lcd screen.
+		 */
+		lcdmodeptr = (u16 *)(par->lcd_table + 64);
+		while (*lcdmodeptr != 0) {
+			u32 modeptr;
+			u16 mwidth, mheight, lcd_hsync_start, lcd_vsync_start;
+			modeptr = bios_base + *lcdmodeptr;
+
+			mwidth = *((u16 *)(modeptr+0));
+			mheight = *((u16 *)(modeptr+2));
+
+			if (mwidth == width && mheight == height) {
+				par->lcd_pixclock = 100000000 / *((u16 *)(modeptr+9));
+				par->lcd_htotal = *((u16 *)(modeptr+17)) & 511;
+				par->lcd_hdisp = *((u16 *)(modeptr+19)) & 511;
+				lcd_hsync_start = *((u16 *)(modeptr+21)) & 511;
+				par->lcd_hsync_dly = (*((u16 *)(modeptr+21)) >> 9) & 7;
+				par->lcd_hsync_len = *((u8 *)(modeptr+23)) & 63;
+
+				par->lcd_vtotal = *((u16 *)(modeptr+24)) & 2047;
+				par->lcd_vdisp = *((u16 *)(modeptr+26)) & 2047;
+				lcd_vsync_start = *((u16 *)(modeptr+28)) & 2047;
+				par->lcd_vsync_len = (*((u16 *)(modeptr+28)) >> 11) & 31;
+
+				par->lcd_htotal = (par->lcd_htotal + 1) * 8;
+				par->lcd_hdisp = (par->lcd_hdisp + 1) * 8;
+				lcd_hsync_start = (lcd_hsync_start + 1) * 8;
+				par->lcd_hsync_len = par->lcd_hsync_len * 8;
+
+				par->lcd_vtotal++;
+				par->lcd_vdisp++;
+				lcd_vsync_start++;
+
+				par->lcd_right_margin = lcd_hsync_start - par->lcd_hdisp;
+				par->lcd_lower_margin = lcd_vsync_start - par->lcd_vdisp;
+				par->lcd_hblank_len = par->lcd_htotal - par->lcd_hdisp;
+				par->lcd_vblank_len = par->lcd_vtotal - par->lcd_vdisp;
+				break;
 			}
 
-			pcp = pdev->sysdata;
-			if (node == pcp->prom_node) {
+			lcdmodeptr++;
+		}
+		if (*lcdmodeptr == 0) {
+			PRINTKE("LCD monitor CRTC parameters not found!!!\n");
+			/* To do: Switch to CRT if possible. */
+		} else {
+			PRINTKI("       LCD CRTC parameters: %d.%d  %d %d %d %d  %d %d %d %d\n",
+				1000000 / par->lcd_pixclock, 1000000 % par->lcd_pixclock,
+				par->lcd_hdisp,
+				par->lcd_hdisp + par->lcd_right_margin,
+				par->lcd_hdisp + par->lcd_right_margin
+					+ par->lcd_hsync_dly + par->lcd_hsync_len,
+				par->lcd_htotal,
+				par->lcd_vdisp,
+				par->lcd_vdisp + par->lcd_lower_margin,
+				par->lcd_vdisp + par->lcd_lower_margin + par->lcd_vsync_len,
+				par->lcd_vtotal);
+			PRINTKI("                          : %d %d %d %d %d %d %d %d %d\n",
+				par->lcd_pixclock,
+				par->lcd_hblank_len - (par->lcd_right_margin +
+					par->lcd_hsync_dly + par->lcd_hsync_len),
+				par->lcd_hdisp,
+				par->lcd_right_margin,
+				par->lcd_hsync_len,
+				par->lcd_vblank_len - (par->lcd_lower_margin + par->lcd_vsync_len),
+				par->lcd_vdisp,
+				par->lcd_lower_margin,
+				par->lcd_vsync_len);
+		}
+	}
+}
+#endif /* CONFIG_FB_ATY_GENERIC_LCD */
+
+static int __devinit init_from_bios(struct atyfb_par *par)
+{
+	u32 bios_base, rom_addr;
+	int ret;
+
+	rom_addr = 0xc0000 + ((aty_ld_le32(SCRATCH_REG1, par) & 0x7f) << 11);
+	bios_base = (unsigned long)ioremap(rom_addr, 0x10000);
+
+	/* The BIOS starts with 0xaa55. */
+	if (*((u16 *)bios_base) == 0xaa55) {
+
+		u8 *bios_ptr;
+		u16 rom_table_offset, freq_table_offset;
+		PLL_BLOCK_MACH64 pll_block;
+
+		PRINTKI("Mach64 BIOS is located at %x, mapped at %x.\n", rom_addr, bios_base);
+
+		/* check for frequncy table */
+		bios_ptr = (u8*)bios_base;
+		rom_table_offset = (u16)(bios_ptr[0x48] | (bios_ptr[0x49] << 8));
+		freq_table_offset = bios_ptr[rom_table_offset + 16] | (bios_ptr[rom_table_offset + 17] << 8);
+		memcpy(&pll_block, bios_ptr + freq_table_offset, sizeof(PLL_BLOCK_MACH64));
+
+		PRINTKI("BIOS frequency table:\n");
+		PRINTKI("PCLK_min_freq %d, PCLK_max_freq %d, ref_freq %d, ref_divider %d\n",
+			pll_block.PCLK_min_freq, pll_block.PCLK_max_freq,
+			pll_block.ref_freq, pll_block.ref_divider);
+		PRINTKI("MCLK_pwd %d, MCLK_max_freq %d, XCLK_max_freq %d, SCLK_freq %d\n",
+			pll_block.MCLK_pwd, pll_block.MCLK_max_freq,
+			pll_block.XCLK_max_freq, pll_block.SCLK_freq);
+
+		par->pll_limits.pll_min = pll_block.PCLK_min_freq/100;
+		par->pll_limits.pll_max = pll_block.PCLK_max_freq/100;
+		par->pll_limits.ref_clk = pll_block.ref_freq/100;
+		par->pll_limits.ref_div = pll_block.ref_divider;
+		par->pll_limits.sclk = pll_block.SCLK_freq/100;
+		par->pll_limits.mclk = pll_block.MCLK_max_freq/100;
+		par->pll_limits.mclk_pm = pll_block.MCLK_pwd/100;
+		par->pll_limits.xclk = pll_block.XCLK_max_freq/100;
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+		aty_init_lcd(par, bios_base);
+#endif
+		ret = 0;
+	} else {
+		PRINTKE("no BIOS frequency table found, use parameters\n");
+		ret = -ENXIO;
+	}
+	iounmap((void* __iomem )bios_base);
 
-				struct fb_var_screeninfo *var =
-				    &default_var;
-				unsigned int N, P, Q, M, T, R;
-				u32 v_total, h_total;
-				struct crtc crtc;
-				u8 pll_regs[16];
-				u8 clock_cntl;
-
-				crtc.vxres =
-				    prom_getintdefault(node, "width",
-						       1024);
-				crtc.vyres =
-				    prom_getintdefault(node, "height",
-						       768);
-				var->bits_per_pixel =
-				    prom_getintdefault(node, "depth", 8);
-				var->xoffset = var->yoffset = 0;
-				crtc.h_tot_disp =
-				    aty_ld_le32(CRTC_H_TOTAL_DISP, default_par);
-				crtc.h_sync_strt_wid =
-				    aty_ld_le32(CRTC_H_SYNC_STRT_WID,
-						default_par);
-				crtc.v_tot_disp =
-				    aty_ld_le32(CRTC_V_TOTAL_DISP, default_par);
-				crtc.v_sync_strt_wid =
-				    aty_ld_le32(CRTC_V_SYNC_STRT_WID,
-						default_par);
-				crtc.gen_cntl =
-				    aty_ld_le32(CRTC_GEN_CNTL, default_par);
-				aty_crtc_to_var(&crtc, var);
-
-				h_total = var->xres + var->right_margin +
-				    var->hsync_len + var->left_margin;
-				v_total = var->yres + var->lower_margin +
-				    var->vsync_len + var->upper_margin;
+	return ret;
+}
+#endif /* __i386__ */
 
-				/*
-				 * Read the PLL to figure actual Refresh Rate.
-				 */
-				clock_cntl = aty_ld_8(CLOCK_CNTL, default_par);
-				/* printk("atyfb: CLOCK_CNTL: %02x\n", clock_cntl); */
-				for (i = 0; i < 16; i++)
-					pll_regs[i] = aty_ld_pll(i, default_par);
+static int __devinit atyfb_setup_generic(struct pci_dev *pdev, struct fb_info *info, unsigned long addr)
+{
+	struct atyfb_par *par = info->par;
+	u16 tmp;
+	unsigned long raddr;
+	struct resource *rrp;
+	int ret = 0;
+
+	raddr = addr + 0x7ff000UL;
+	rrp = &pdev->resource[2];
+	if ((rrp->flags & IORESOURCE_MEM) && request_mem_region(rrp->start, rrp->end - rrp->start + 1, "atyfb")) {
+		par->aux_start = rrp->start;
+		par->aux_size = rrp->end - rrp->start + 1;
+		raddr = rrp->start;
+		PRINTKI("using auxiliary register aperture\n");
+	}
+
+	info->fix.mmio_start = raddr;
+	par->ati_regbase = ioremap(info->fix.mmio_start, 0x1000);
+	if (par->ati_regbase == 0)
+		return -ENOMEM;
 
-				/*
-				 * PLL Reference Divider M:
-				 */
-				M = pll_regs[2];
+	info->fix.mmio_start += par->aux_start ? 0x400 : 0xc00;
+	par->ati_regbase += par->aux_start ? 0x400 : 0xc00;
 
-				/*
-				 * PLL Feedback Divider N (Dependant on CLOCK_CNTL):
-				 */
-				N = pll_regs[7 + (clock_cntl & 3)];
+	/*
+	 * Enable memory-space accesses using config-space
+	 * command register.
+	 */
+	pci_read_config_word(pdev, PCI_COMMAND, &tmp);
+	if (!(tmp & PCI_COMMAND_MEMORY)) {
+		tmp |= PCI_COMMAND_MEMORY;
+		pci_write_config_word(pdev, PCI_COMMAND, tmp);
+	}
+#ifdef __BIG_ENDIAN
+	/* Use the big-endian aperture */
+	addr += 0x800000;
+#endif
 
-				/*
-				 * PLL Post Divider P (Dependant on CLOCK_CNTL):
-				 */
-				P = 1 << (pll_regs[6] >>
-					  ((clock_cntl & 3) << 1));
+	/* Map in frame buffer */
+	info->fix.smem_start = addr;
+	info->screen_base = ioremap(addr, 0x800000);
+	if (info->screen_base == NULL) {
+		ret = -ENOMEM;
+		goto atyfb_setup_generic_fail;
+	}
+
+	if((ret = correct_chipset(par)))
+		goto atyfb_setup_generic_fail;
+#ifdef __i386__
+	if((ret = init_from_bios(par)))
+		goto atyfb_setup_generic_fail;
+#endif
+	if (!(aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC_EXT_DISP_EN))
+		par->clk_wr_offset = (inb(R_GENMO) & 0x0CU) >> 2;
+	else
+		par->clk_wr_offset = aty_ld_8(CLOCK_CNTL, par) & 0x03U;
 
-				/*
-				 * PLL Divider Q:
-				 */
-				Q = N / P;
+	/* according to ATI, we should use clock 3 for acelerated mode */
+	par->clk_wr_offset = 3;
 
-				/*
-				 * Target Frequency:
-				 *
-				 *      T * M
-				 * Q = -------
-				 *      2 * R
-				 *
-				 * where R is XTALIN (= 14318 or 29498 kHz).
-				 */
-				if (pdev->device == XL_CHIP_ID)
-					R = 29498;
-				else
-					R = 14318;
+	return 0;
 
-				T = 2 * Q * R / M;
+atyfb_setup_generic_fail:
+	iounmap(par->ati_regbase);
+	par->ati_regbase = NULL;
+	return ret;
+}
 
-				default_var.pixclock = 1000000000 / T;
-			}
-#else				/* __sparc__ */
+#endif /* !__sparc__ */
 
-			info->fix.mmio_start = 0x7ff000 + addr;
-			default_par->ati_regbase = (unsigned long)
-			    ioremap(info->fix.mmio_start, 0x1000);
+static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	unsigned long addr, res_start, res_size;
+	struct fb_info *info;
+	struct resource *rp;
+	struct atyfb_par *par;
+	int i, rc = -ENOMEM;
 
-			if (!default_par->ati_regbase) {
-#ifdef __sparc__
-				kfree(default_par->mmap_map);
-#endif
-				kfree(default_par);
-				kfree(info);
-				release_mem_region(res_start, res_size);
-				return -ENOMEM;
-			}
+	for (i = sizeof(aty_chips) / sizeof(*aty_chips) - 1; i >= 0; i--)
+		if (pdev->device == aty_chips[i].pci_id)
+			break;
 
-			info->fix.mmio_start += 0xc00;
-			default_par->ati_regbase += 0xc00;
+	if (i < 0)
+		return -ENODEV;
 
-			/*
-			 * Enable memory-space accesses using config-space
-			 * command register.
-			 */
-			pci_read_config_word(pdev, PCI_COMMAND, &tmp);
-			if (!(tmp & PCI_COMMAND_MEMORY)) {
-				tmp |= PCI_COMMAND_MEMORY;
-				pci_write_config_word(pdev, PCI_COMMAND,
-						      tmp);
-			}
-#ifdef __BIG_ENDIAN
-			/* Use the big-endian aperture */
-			addr += 0x800000;
-#endif
+	/* Enable device in PCI config */
+	if (pci_enable_device(pdev)) {
+		PRINTKE("Cannot enable PCI device\n");
+		return -ENXIO;
+	}
+
+	/* Find which resource to use */
+	rp = &pdev->resource[0];
+	if (rp->flags & IORESOURCE_IO)
+		rp = &pdev->resource[1];
+	addr = rp->start;
+	if (!addr)
+		return -ENXIO;
 
-			/* Map in frame buffer */
-			info->fix.smem_start = addr;
-			info->screen_base =
-			    (char *) ioremap(addr, 0x800000);
+	/* Reserve space */
+	res_start = rp->start;
+	res_size = rp->end - rp->start + 1;
+	if (!request_mem_region (res_start, res_size, "atyfb"))
+		return -EBUSY;
+
+        /* Allocate framebuffer */
+	info = framebuffer_alloc(sizeof(struct atyfb_par), &pdev->dev);
+	if (!info) {
+		PRINTKE("atyfb_pci_probe() can't alloc fb_info\n");
+		return -ENOMEM;
+	}
+	par = info->par;
+	info->fix = atyfb_fix;
+	info->device = &pdev->dev;
+	par->pci_id = aty_chips[i].pci_id;
+	par->res_start = res_start;
+	par->res_size = res_size;
+	par->irq = pdev->irq;
 
-			if (!info->screen_base) {
+	/* Setup "info" structure */
 #ifdef __sparc__
-				kfree(default_par->mmap_map);
+	rc = atyfb_setup_sparc(pdev, info, addr);
+#else
+	rc = atyfb_setup_generic(pdev, info, addr);
 #endif
-				kfree(default_par);
-				kfree(info);
-				release_mem_region(res_start, res_size);
-				return -ENXIO;
-			}
-#endif				/* __sparc__ */
+	if (rc)
+		goto err_release_mem;
+
+	pci_set_drvdata(pdev, info);
+
+	/* Init chip & register framebuffer */
+	if (aty_init(info, "PCI"))
+		goto err_release_io;
 
-			if (!aty_init(info, "PCI")) {
-#ifdef __sparc__	
-				if (default_par->mmap_map)
-					kfree(default_par->mmap_map);
-#endif
-				kfree(default_par);
-				kfree(info);
-				release_mem_region(res_start, res_size);
-				return -ENXIO;
-			}
 #ifdef __sparc__
-			if (!prom_palette)
-				prom_palette = atyfb_palette;
+	if (!prom_palette)
+		prom_palette = atyfb_palette;
 
-			/*
-			 * Add /dev/fb mmap values.
-			 */
-			default_par->mmap_map[0].voff = 0x8000000000000000UL;
-			default_par->mmap_map[0].poff =
-			    (unsigned long) info->screen_base & PAGE_MASK;
-			default_par->mmap_map[0].size =
-			    info->fix.smem_len;
-			default_par->mmap_map[0].prot_mask = _PAGE_CACHE;
-			default_par->mmap_map[0].prot_flag = _PAGE_E;
-			default_par->mmap_map[1].voff =
-			    default_par->mmap_map[0].voff +
-			    info->fix.smem_len;
-			default_par->mmap_map[1].poff =
-			    default_par->ati_regbase & PAGE_MASK;
-			default_par->mmap_map[1].size = PAGE_SIZE;
-			default_par->mmap_map[1].prot_mask = _PAGE_CACHE;
-			default_par->mmap_map[1].prot_flag = _PAGE_E;
-#endif				/* __sparc__ */
-
-#ifdef CONFIG_PMAC_PBOOK
-			if (first_display == NULL)
-				pmu_register_sleep_notifier(&aty_sleep_notifier);
-			default_par->next = first_display;
+	/*
+	 * Add /dev/fb mmap values.
+	 */
+	par->mmap_map[0].voff = 0x8000000000000000UL;
+	par->mmap_map[0].poff = (unsigned long) info->screen_base & PAGE_MASK;
+	par->mmap_map[0].size = info->fix.smem_len;
+	par->mmap_map[0].prot_mask = _PAGE_CACHE;
+	par->mmap_map[0].prot_flag = _PAGE_E;
+	par->mmap_map[1].voff = par->mmap_map[0].voff + info->fix.smem_len;
+	par->mmap_map[1].poff = (long)par->ati_regbase & PAGE_MASK;
+	par->mmap_map[1].size = PAGE_SIZE;
+	par->mmap_map[1].prot_mask = _PAGE_CACHE;
+	par->mmap_map[1].prot_flag = _PAGE_E;
+#endif /* __sparc__ */
+
+	return 0;
+
+err_release_io:
+#ifdef __sparc__
+	if (par->mmap_map)
+		kfree(par->mmap_map);
+#else
+	if (par->ati_regbase)
+		iounmap(par->ati_regbase);
+	if (info->screen_base)
+		iounmap(info->screen_base);
 #endif
-		}
-	}
+err_release_mem:
+	if(par->aux_start)
+		release_mem_region(par->aux_start, par->aux_size);
 
-#elif defined(CONFIG_ATARI)
-	struct atyfb_par *default_par;
+	release_mem_region(par->res_start, par->res_size);
+	framebuffer_release(info);
+
+	return rc;
+}
+
+#endif /* CONFIG_PCI */
+
+#ifdef CONFIG_ATARI
+
+static int __devinit atyfb_atari_probe(void)
+{
+	struct aty_par *par;
 	struct fb_info *info;
 	int m64_num;
 	u32 clock_r;
@@ -2314,85 +3448,136 @@
 	for (m64_num = 0; m64_num < mach64_count; m64_num++) {
 		if (!phys_vmembase[m64_num] || !phys_size[m64_num] ||
 		    !phys_guiregbase[m64_num]) {
-			printk
-			    (" phys_*[%d] parameters not set => returning early. \n",
-			     m64_num);
+		    PRINTKI("phys_*[%d] parameters not set => returning early. \n", m64_num);
 			continue;
 		}
 
-		info = kmalloc(sizeof(struct fb_info), GFP_ATOMIC);
+		info = framebuffer_alloc(sizeof(struct atyfb_par), NULL);
 		if (!info) {
-			printk("atyfb_init: can't alloc fb_info\n");
+			PRINTKE("atyfb_atari_probe() can't alloc fb_info\n");
 			return -ENOMEM;
 		}
-		memset(info, 0, sizeof(struct fb_info));
-
-		default_par = kmalloc(sizeof(struct atyfb_par), GFP_ATOMIC);
-		if (!default_par) {
-			printk
-			    ("atyfb_init: can't alloc atyfb_par\n");
-			kfree(info);
-			return -ENXIO;
-		}
-		memset(default_par, 0, sizeof(struct atyfb_par));
+		par = info->par;
 
 		info->fix = atyfb_fix;
-		info->par = default_par;
+
+		par->irq = (unsigned int) -1; /* something invalid */
 
 		/*
 		 *  Map the video memory (physical address given) to somewhere in the
 		 *  kernel address space.
 		 */
-		info->screen_base = ioremap(phys_vmembase[m64_num],
-					 		   phys_size[m64_num]);	
-		info->fix.smem_start = (unsigned long)info->screen_base;	/* Fake! */
-		default_par->ati_regbase = (unsigned long)ioremap(phys_guiregbase[m64_num],
-							  0x10000) + 0xFC00ul;
-		info->fix.mmio_start = default_par->ati_regbase; /* Fake! */
+		info->screen_base = ioremap(phys_vmembase[m64_num], phys_size[m64_num]);
+		info->fix.smem_start = (unsigned long)info->screen_base; /* Fake! */
+		par->ati_regbase = ioremap(phys_guiregbase[m64_num], 0x10000) +
+						0xFC00ul;
+		info->fix.mmio_start = (unsigned long)par->ati_regbase; /* Fake! */
 
-		aty_st_le32(CLOCK_CNTL, 0x12345678, default_par);
-		clock_r = aty_ld_le32(CLOCK_CNTL, default_par);
+		aty_st_le32(CLOCK_CNTL, 0x12345678, par);
+		clock_r = aty_ld_le32(CLOCK_CNTL, par);
 
 		switch (clock_r & 0x003F) {
 		case 0x12:
-			default_par->clk_wr_offset = 3;	/*  */
+			par->clk_wr_offset = 3; /*  */
 			break;
 		case 0x34:
-			default_par->clk_wr_offset = 2;	/* Medusa ST-IO ISA Adapter etc. */
+			par->clk_wr_offset = 2; /* Medusa ST-IO ISA Adapter etc. */
 			break;
 		case 0x16:
-			default_par->clk_wr_offset = 1;	/*  */
+			par->clk_wr_offset = 1; /*  */
 			break;
 		case 0x38:
-			default_par->clk_wr_offset = 0;	/* Panther 1 ISA Adapter (Gerald) */
+			par->clk_wr_offset = 0; /* Panther 1 ISA Adapter (Gerald) */
 			break;
 		}
 
-		if (!aty_init(info, "ISA bus")) {
-			kfree(default_par);
-			kfree(info);
+		if (aty_init(info, "ISA bus")) {
+			framebuffer_release(info);
 			/* This is insufficient! kernel_map has added two large chunks!! */
 			return -ENXIO;
 		}
 	}
-#endif				/* CONFIG_ATARI */
-	return 0;
 }
 
-int __init atyfb_init(void)
+#endif /* CONFIG_ATARI */
+
+static void __devexit atyfb_remove(struct fb_info *info)
 {
-#ifndef MODULE
-	char *option = NULL;
+	struct atyfb_par *par = (struct atyfb_par *) info->par;
 
-	if (fb_get_options("atyfb", &option))
-		return -ENODEV;
-	atyfb_setup(option);
+	/* restore video mode */
+	aty_set_crtc(par, &saved_crtc);
+	par->pll_ops->set_pll(info, &saved_pll);
+
+	unregister_framebuffer(info);
+
+#ifdef CONFIG_MTRR
+	if (par->mtrr_reg >= 0) {
+	    mtrr_del(par->mtrr_reg, 0, 0);
+	    par->mtrr_reg = -1;
+	}
+	if (par->mtrr_aper >= 0) {
+	    mtrr_del(par->mtrr_aper, 0, 0);
+	    par->mtrr_aper = -1;
+	}
+#endif
+#ifndef __sparc__
+	if (par->ati_regbase)
+		iounmap(par->ati_regbase);
+	if (info->screen_base)
+		iounmap(info->screen_base);
+#ifdef __BIG_ENDIAN
+	if (info->sprite.addr)
+		iounmap(info->sprite.addr);
 #endif
-	return atyfb_do_init();
+#endif
+#ifdef __sparc__
+	if (par->mmap_map)
+		kfree(par->mmap_map);
+#endif
+	if (par->aux_start)
+		release_mem_region(par->aux_start, par->aux_size);
+
+	if (par->res_start)
+		release_mem_region(par->res_start, par->res_size);
+
+	framebuffer_release(info);
 }
 
+#ifdef CONFIG_PCI
+
+static void __devexit atyfb_pci_remove(struct pci_dev *pdev)
+{
+	struct fb_info *info = pci_get_drvdata(pdev);
+
+	atyfb_remove(info);
+}
+
+/*
+ * This driver uses its own matching table. That will be more difficult
+ * to fix, so for now, we just match against any ATI ID and let the
+ * probe() function find out what's up. That also mean we don't have
+ * a module ID table though.
+ */
+static struct pci_device_id atyfb_pci_tbl[] = {
+	{ PCI_VENDOR_ID_ATI, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+	  PCI_BASE_CLASS_DISPLAY << 16, 0xff0000, 0 },
+	{ 0, }
+};
+
+static struct pci_driver atyfb_driver = {
+	.name		= "atyfb",
+	.id_table	= atyfb_pci_tbl,
+	.probe		= atyfb_pci_probe,
+	.remove		= __devexit_p(atyfb_pci_remove),
+#ifdef CONFIG_PM
+	.suspend	= atyfb_pci_suspend,
+	.resume		= atyfb_pci_resume,
+#endif /* CONFIG_PM */
+};
+
+#endif /* CONFIG_PCI */
 
-#ifndef MODULE
 int __init atyfb_setup(char *options)
 {
 	char *this_opt;
@@ -2401,19 +3586,20 @@
 		return 0;
 
 	while ((this_opt = strsep(&options, ",")) != NULL) {
-		if (!strncmp(this_opt, "noblink", 7)) {
-			curblink = 0;
-		} else if (!strncmp(this_opt, "noaccel", 7)) {
+		if (!strncmp(this_opt, "noaccel", 7)) {
 			noaccel = 1;
+#ifdef CONFIG_MTRR
+		} else if (!strncmp(this_opt, "nomtrr", 6)) {
+			nomtrr = 1;
+#endif
 		} else if (!strncmp(this_opt, "vram:", 5))
-			default_vram =
-			    simple_strtoul(this_opt + 5, NULL, 0);
+			vram = simple_strtoul(this_opt + 5, NULL, 0);
 		else if (!strncmp(this_opt, "pll:", 4))
-			default_pll =
-			    simple_strtoul(this_opt + 4, NULL, 0);
+			pll = simple_strtoul(this_opt + 4, NULL, 0);
 		else if (!strncmp(this_opt, "mclk:", 5))
-			default_mclk =
-			    simple_strtoul(this_opt + 5, NULL, 0);
+			mclk = simple_strtoul(this_opt + 5, NULL, 0);
+		else if (!strncmp(this_opt, "xclk:", 5))
+			xclk = simple_strtoul(this_opt+5, NULL, 0);
 #ifdef CONFIG_PPC
 		else if (!strncmp(this_opt, "vmode:", 6)) {
 			unsigned int vmode =
@@ -2456,182 +3642,57 @@
 		}
 #endif
 		else
-			mode_option = this_opt;
+			mode = this_opt;
 	}
 	return 0;
 }
-module_init(atyfb_init);
-#endif				/* !MODULE */
-
-#ifdef CONFIG_ATARI
-static int __init store_video_par(char *video_str, unsigned char m64_num)
-{
-	char *p;
-	unsigned long vmembase, size, guiregbase;
-
-	printk("store_video_par() '%s' \n", video_str);
 
-	if (!(p = strsep(&video_str, ";")) || !*p)
-		goto mach64_invalid;
-	vmembase = simple_strtoul(p, NULL, 0);
-	if (!(p = strsep(&video_str, ";")) || !*p)
-		goto mach64_invalid;
-	size = simple_strtoul(p, NULL, 0);
-	if (!(p = strsep(&video_str, ";")) || !*p)
-		goto mach64_invalid;
-	guiregbase = simple_strtoul(p, NULL, 0);
-
-	phys_vmembase[m64_num] = vmembase;
-	phys_size[m64_num] = size;
-	phys_guiregbase[m64_num] = guiregbase;
-	printk(" stored them all: $%08lX $%08lX $%08lX \n", vmembase, size,
-	       guiregbase);
-	return 0;
-
-      mach64_invalid:
-	phys_vmembase[m64_num] = 0;
-	return -1;
-}
-#endif				/* CONFIG_ATARI */
-
-/*
-#ifdef CONFIG_FB_ATY_CT
-   * Erase HW Cursor *
-    if (par->cursor && (info->currcon >= 0))
-	atyfb_cursor(&fb_display[par->currcon], CM_ERASE,
-		     par->cursor->pos.x, par->cursor->pos.y);
-#endif * CONFIG_FB_ATY_CT *
-
-#ifdef CONFIG_FB_ATY_CT
-    * Install hw cursor *
-    if (par->cursor) {
-	aty_set_cursor_color(info);
-	aty_set_cursor_shape(info);
-    }
-#endif * CONFIG_FB_ATY_CT */
-
-    /*
-     *  Blank the display.
-     */
-
-static int atyfb_blank(int blank, struct fb_info *info)
+int __init atyfb_init(void)
 {
-	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	u8 gen_cntl;
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	if ((_machine == _MACH_Pmac) && blank)
-		set_backlight_enable(0);
-#endif				/* CONFIG_PMAC_BACKLIGHT */
-
-	gen_cntl = aty_ld_8(CRTC_GEN_CNTL, par);
-	if (blank > 0)
-		switch (blank - 1) {
-		case VESA_NO_BLANKING:
-			gen_cntl |= 0x40;
-			break;
-		case VESA_VSYNC_SUSPEND:
-			gen_cntl |= 0x8;
-			break;
-		case VESA_HSYNC_SUSPEND:
-			gen_cntl |= 0x4;
-			break;
-		case VESA_POWERDOWN:
-			gen_cntl |= 0x4c;
-			break;
-	} else
-		gen_cntl &= ~(0x4c);
-	aty_st_8(CRTC_GEN_CNTL, gen_cntl, par);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	if ((_machine == _MACH_Pmac) && !blank)
-		set_backlight_enable(1);
-#endif				/* CONFIG_PMAC_BACKLIGHT */
-	return 0;
-}
-
-    /*
-     *  Set a single color register. The values supplied are already
-     *  rounded down to the hardware's capabilities (according to the
-     *  entries in the var structure). Return != 0 for invalid regno.
-     */
+#ifndef MODULE
+    char *option = NULL;
 
-static int atyfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
-			   u_int transp, struct fb_info *info)
-{
-	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	int i, scale;
-	u32 *pal = info->pseudo_palette;
+    if (fb_get_options("atyfb", &option))
+	return -ENODEV;
+    atyfb_setup(option);
+#endif
 
-	if (regno > 255)
-		return 1;
-	red >>= 8;
-	green >>= 8;
-	blue >>= 8;
-	i = aty_ld_8(DAC_CNTL, par) & 0xfc;
-	if (M64_HAS(EXTRA_BRIGHT))
-		i |= 0x2;	/*DAC_CNTL|0x2 turns off the extra brightness for gt */
-	aty_st_8(DAC_CNTL, i, par);
-	aty_st_8(DAC_MASK, 0xff, par);
-	scale = (M64_HAS(INTEGRATED) && info->var.bits_per_pixel == 16) ? 3 : 0;
+#ifdef CONFIG_PCI
+    pci_module_init(&atyfb_driver);
+#endif
 #ifdef CONFIG_ATARI
-	out_8(&par->aty_cmap_regs->windex, regno << scale);
-	out_8(&par->aty_cmap_regs->lut, red);
-	out_8(&par->aty_cmap_regs->lut, green);
-	out_8(&par->aty_cmap_regs->lut, blue);
-#else
-	writeb(regno << scale, &par->aty_cmap_regs->windex);
-	writeb(red, &par->aty_cmap_regs->lut);
-	writeb(green, &par->aty_cmap_regs->lut);
-	writeb(blue, &par->aty_cmap_regs->lut);
+    atyfb_atari_probe();
 #endif
-	if (regno < 16)
-		switch (info->var.bits_per_pixel) {
-		case 16:
-			pal[regno] = (regno << 10) | (regno << 5) | regno;
-			break;
-		case 24:
-			pal[regno] = (regno << 16) | (regno << 8) | regno;
-			break;
-		case 32:
-			i = (regno << 8) | regno;
-			pal[regno] = (i << 16) | i;
-			break;
-		}
-	return 0;
+    return 0;
 }
 
-#ifdef MODULE
-int __init init_module(void)
+void __exit atyfb_exit(void)
 {
-	atyfb_init();
-	return fb_list ? 0 : -ENXIO;
-}
-
-void cleanup_module(void)
-{
-	struct fb_info *info = fb_list;
-	struct atyfb_par *par = (struct atyfb_par *) info->par;		
-	unregister_framebuffer(info);
-
-#ifndef __sparc__
-	if (par->ati_regbase)
-		iounmap((void *) par->ati_regbase);
-	if (info->screen_base)
-		iounmap((void *) info->screen_base);
-#ifdef __BIG_ENDIAN
-	if (par->cursor && par->cursor->ram)
-		iounmap(par->cursor->ram);
-#endif
-#endif
-	if (par->cursor)
-		kfree(par->cursor);
-#ifdef __sparc__
-	if (par->mmap_map)
-		kfree(par->mmap_map);
+#ifdef CONFIG_PCI
+	pci_unregister_driver(&atyfb_driver);
 #endif
-	kfree(info);
 }
 
+module_init(atyfb_init);
+#ifdef MODULE
+module_exit(atyfb_exit);
 #endif
+
+MODULE_DESCRIPTION("FBDev driver for ATI Mach64 cards");
 MODULE_LICENSE("GPL");
+module_param(noaccel, bool, 0);
+MODULE_PARM_DESC(noaccel, "bool: disable acceleration");
+module_param(vram, int, 0);
+MODULE_PARM_DESC(vram, "int: override size of video ram");
+module_param(pll, int, 0);
+MODULE_PARM_DESC(pll, "int: override video clock");
+module_param(mclk, int, 0);
+MODULE_PARM_DESC(mclk, "int: override memory clock");
+module_param(xclk, int, 0);
+MODULE_PARM_DESC(xclk, "int: override accelerated engine clock");
+module_param(mode, charp, 0);
+MODULE_PARM_DESC(mode, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
+#ifdef CONFIG_MTRR
+module_param(nomtrr, bool, 0);
+MODULE_PARM_DESC(nomtrr, "bool: disable use of MTRR registers");
+#endif
diff -Nru a/drivers/video/aty/mach64_accel.c b/drivers/video/aty/mach64_accel.c
--- a/drivers/video/aty/mach64_accel.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/video/aty/mach64_accel.c	2004-12-24 13:36:17 -08:00
@@ -13,22 +13,41 @@
      *  Generic Mach64 routines
      */
 
+/* this is for DMA GUI engine! work in progress */
+typedef struct {
+	u32 frame_buf_offset;
+	u32 system_mem_addr;
+	u32 command;
+	u32 reserved;
+} BM_DESCRIPTOR_ENTRY;
+
+#define LAST_DESCRIPTOR (1 << 31)
+#define SYSTEM_TO_FRAME_BUFFER 0
+
+static u32 rotation24bpp(u32 dx, u32 direction)
+{
+	u32 rotation;
+	if (direction & DST_X_LEFT_TO_RIGHT) {
+		rotation = (dx / 4) % 6;
+	} else {
+		rotation = ((dx + 2) / 4) % 6;
+	}
+
+	return ((rotation << 8) | DST_24_ROTATION_ENABLE);
+}
+
 void aty_reset_engine(const struct atyfb_par *par)
 {
 	/* reset engine */
 	aty_st_le32(GEN_TEST_CNTL,
-		    aty_ld_le32(GEN_TEST_CNTL, par) & ~GUI_ENGINE_ENABLE,
-		    par);
+		aty_ld_le32(GEN_TEST_CNTL, par) & ~GUI_ENGINE_ENABLE, par);
 	/* enable engine */
 	aty_st_le32(GEN_TEST_CNTL,
-		    aty_ld_le32(GEN_TEST_CNTL, par) | GUI_ENGINE_ENABLE,
-		    par);
+		aty_ld_le32(GEN_TEST_CNTL, par) | GUI_ENGINE_ENABLE, par);
 	/* ensure engine is not locked up by clearing any FIFO or */
 	/* HOST errors */
 	aty_st_le32(BUS_CNTL,
-		    aty_ld_le32(BUS_CNTL,
-				par) | BUS_HOST_ERR_ACK | BUS_FIFO_ERR_ACK,
-		    par);
+		aty_ld_le32(BUS_CNTL, par) | BUS_HOST_ERR_ACK | BUS_FIFO_ERR_ACK, par);
 }
 
 static void reset_GTC_3D_engine(const struct atyfb_par *par)
@@ -51,7 +70,7 @@
 	if (info->var.bits_per_pixel == 24) {
 		/* In 24 bpp, the engine is in 8 bpp - this requires that all */
 		/* horizontal coordinates and widths must be adjusted */
-		pitch_value = pitch_value * 3;
+		pitch_value *= 3;
 	}
 
 	/* On GTC (RagePro), we need to reset the 3D engine before */
@@ -146,7 +165,7 @@
 	aty_st_le32(DP_CHAIN_MASK, par->crtc.dp_chain_mask, par);
 
 	wait_for_fifo(5, par);
-	aty_st_le32(SCALE_3D_CNTL, 0, par);
+ 	aty_st_le32(SCALE_3D_CNTL, 0, par);
 	aty_st_le32(Z_CNTL, 0, par);
 	aty_st_le32(CRTC_INT_CNTL, aty_ld_le32(CRTC_INT_CNTL, par) & ~0x20,
 		    par);
@@ -174,9 +193,10 @@
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
 	u32 dy = area->dy, sy = area->sy, direction = DST_LAST_PEL;
-	u32 sx = area->sx, dx = area->dx, width = area->width;	
-	u32 pitch_value;
+	u32 sx = area->sx, dx = area->dx, width = area->width, rotation = 0;
 
+	if (par->asleep)
+		return;
 	if (!area->width || !area->height)
 		return;
 	if (!par->accel_flags) {
@@ -186,11 +206,9 @@
 		return;
 	}
 
-	pitch_value = info->var.xres_virtual;
 	if (info->var.bits_per_pixel == 24) {
 		/* In 24 bpp, the engine is in 8 bpp - this requires that all */
 		/* horizontal coordinates and widths must be adjusted */
-		pitch_value *= 3;
 		sx *= 3;
 		dx *= 3;
 		width *= 3;
@@ -208,19 +226,25 @@
 	} else
 		direction |= DST_X_LEFT_TO_RIGHT;
 
+	if (info->var.bits_per_pixel == 24) {
+		rotation = rotation24bpp(dx, direction);
+	}
+
 	wait_for_fifo(4, par);
 	aty_st_le32(DP_SRC, FRGD_SRC_BLIT, par);
 	aty_st_le32(SRC_Y_X, (sx << 16) | sy, par);
 	aty_st_le32(SRC_HEIGHT1_WIDTH1, (width << 16) | area->height, par);
-	aty_st_le32(DST_CNTL, direction, par);
+	aty_st_le32(DST_CNTL, direction | rotation, par);
 	draw_rect(dx, dy, width, area->height, par);
 }
 
 void atyfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	u32 color = rect->color, dx = rect->dx, width = rect->width;
+	u32 color = rect->color, dx = rect->dx, width = rect->width, rotation = 0;
 
+	if (par->asleep)
+		return;
 	if (!rect->width || !rect->height)
 		return;
 	if (!par->accel_flags) {
@@ -238,6 +262,7 @@
 		/* horizontal coordinates and widths must be adjusted */
 		dx *= 3;
 		width *= 3;
+		rotation = rotation24bpp(dx, DST_X_LEFT_TO_RIGHT);
 	}
 
 	wait_for_fifo(3, par);
@@ -247,15 +272,162 @@
 		    par);
 	aty_st_le32(DST_CNTL,
 		    DST_LAST_PEL | DST_Y_TOP_TO_BOTTOM |
-		    DST_X_LEFT_TO_RIGHT, par);
+		    DST_X_LEFT_TO_RIGHT | rotation, par);
 	draw_rect(dx, rect->dy, width, rect->height, par);
 }
 
 void atyfb_imageblit(struct fb_info *info, const struct fb_image *image)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
-    
-	if (par->blitter_may_be_busy)
-		wait_for_idle(par);
-	cfb_imageblit(info, image);
+	u32 src_bytes, dx = image->dx, dy = image->dy, width = image->width;
+	u32 pix_width_save, pix_width, host_cntl, rotation = 0, src, mix;
+
+	if (par->asleep)
+		return;
+	if (!image->width || !image->height)
+		return;
+	if (!par->accel_flags ||
+	    (image->depth != 1 && info->var.bits_per_pixel != image->depth)) {
+		if (par->blitter_may_be_busy)
+			wait_for_idle(par);
+
+		cfb_imageblit(info, image);
+		return;
+	}
+
+	wait_for_idle(par);
+	pix_width = pix_width_save = aty_ld_le32(DP_PIX_WIDTH, par);
+	host_cntl = aty_ld_le32(HOST_CNTL, par) | HOST_BYTE_ALIGN;
+
+	switch (image->depth) {
+	case 1:
+	    pix_width &= ~(BYTE_ORDER_MASK | HOST_MASK);
+	    pix_width |= (BYTE_ORDER_MSB_TO_LSB | HOST_1BPP);
+	    break;
+	case 4:
+	    pix_width &= ~(BYTE_ORDER_MASK | HOST_MASK);
+	    pix_width |= (BYTE_ORDER_MSB_TO_LSB | HOST_4BPP);
+	    break;
+	case 8:
+	    pix_width &= ~HOST_MASK;
+	    pix_width |= HOST_8BPP;
+	    break;
+	case 15:
+	    pix_width &= ~HOST_MASK;
+	    pix_width |= HOST_15BPP;
+	    break;
+	case 16:
+	    pix_width &= ~HOST_MASK;
+	    pix_width |= HOST_16BPP;
+	    break;
+	case 24:
+	    pix_width &= ~HOST_MASK;
+	    pix_width |= HOST_24BPP;
+	    break;
+	case 32:
+	    pix_width &= ~HOST_MASK;
+	    pix_width |= HOST_32BPP;
+	    break;
+	}
+
+	if (info->var.bits_per_pixel == 24) {
+		/* In 24 bpp, the engine is in 8 bpp - this requires that all */
+		/* horizontal coordinates and widths must be adjusted */
+		dx *= 3;
+		width *= 3;
+
+		rotation = rotation24bpp(dx, DST_X_LEFT_TO_RIGHT);
+
+		pix_width &= ~DST_MASK;
+		pix_width |= DST_8BPP;
+
+		/*
+		 * since Rage 3D IIc we have DP_HOST_TRIPLE_EN bit
+		 * this hwaccelerated triple has an issue with not aligned data
+		 */
+		if (M64_HAS(HW_TRIPLE) && image->width % 8 == 0)
+			pix_width |= DP_HOST_TRIPLE_EN;
+	}
+
+	if (image->depth == 1) {
+		u32 fg, bg;
+		if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
+		    info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
+			fg = ((u32*)(info->pseudo_palette))[image->fg_color];
+			bg = ((u32*)(info->pseudo_palette))[image->bg_color];
+		} else {
+			fg = image->fg_color;
+			bg = image->bg_color;
+		}
+
+		wait_for_fifo(2, par);
+		aty_st_le32(DP_BKGD_CLR, bg, par);
+		aty_st_le32(DP_FRGD_CLR, fg, par);
+		src = MONO_SRC_HOST | FRGD_SRC_FRGD_CLR | BKGD_SRC_BKGD_CLR;
+		mix = FRGD_MIX_S | BKGD_MIX_S;
+	} else {
+		src = MONO_SRC_ONE | FRGD_SRC_HOST;
+		mix = FRGD_MIX_D_XOR_S | BKGD_MIX_D;
+	}
+
+	wait_for_fifo(6, par);
+	aty_st_le32(DP_WRITE_MASK, 0xFFFFFFFF, par);
+	aty_st_le32(DP_PIX_WIDTH, pix_width, par);
+	aty_st_le32(DP_MIX, mix, par);
+	aty_st_le32(DP_SRC, src, par);
+	aty_st_le32(HOST_CNTL, host_cntl, par);
+	aty_st_le32(DST_CNTL, DST_Y_TOP_TO_BOTTOM | DST_X_LEFT_TO_RIGHT | rotation, par);
+
+	draw_rect(dx, dy, width, image->height, par);
+	src_bytes = (((image->width * image->depth) + 7) / 8) * image->height;
+
+	/* manual triple each pixel */
+	if (info->var.bits_per_pixel == 24 && !(pix_width & DP_HOST_TRIPLE_EN)) {
+		int inbit, outbit, mult24, byte_id_in_dword, width;
+		u8 *pbitmapin = (u8*)image->data, *pbitmapout;
+		u32 hostdword;
+
+		for (width = image->width, inbit = 7, mult24 = 0; src_bytes; ) {
+			for (hostdword = 0, pbitmapout = (u8*)&hostdword, byte_id_in_dword = 0;
+				byte_id_in_dword < 4 && src_bytes;
+				byte_id_in_dword++, pbitmapout++) {
+				for (outbit = 7; outbit >= 0; outbit--) {
+					*pbitmapout |= (((*pbitmapin >> inbit) & 1) << outbit);
+					mult24++;
+					/* next bit */
+					if (mult24 == 3) {
+						mult24 = 0;
+						inbit--;
+						width--;
+					}
+
+					/* next byte */
+					if (inbit < 0 || width == 0) {
+						src_bytes--;
+						pbitmapin++;
+						inbit = 7;
+
+						if (width == 0) {
+						    width = image->width;
+						    outbit = 0;
+						}
+					}
+				}
+			}
+			wait_for_fifo(1, par);
+			aty_st_le32(HOST_DATA0, hostdword, par);
+		}
+	} else {
+		u32 *pbitmap, dwords = (src_bytes + 3) / 4;
+		for (pbitmap = (u32*)(image->data); dwords; dwords--, pbitmap++) {
+			wait_for_fifo(1, par);
+			aty_st_le32(HOST_DATA0, le32_to_cpup(pbitmap), par);
+		}
+	}
+
+	wait_for_idle(par);
+
+	/* restore pix_width */
+	wait_for_fifo(1, par);
+	aty_st_le32(DP_PIX_WIDTH, pix_width_save, par);
 }
diff -Nru a/drivers/video/aty/mach64_ct.c b/drivers/video/aty/mach64_ct.c
--- a/drivers/video/aty/mach64_ct.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/video/aty/mach64_ct.c	2004-12-24 13:36:16 -08:00
@@ -4,214 +4,236 @@
  */
 
 #include <linux/fb.h>
-
+#include <linux/delay.h>
 #include <asm/io.h>
-
 #include <video/mach64.h>
 #include "atyfb.h"
 
+#undef DEBUG
 
-/* FIXME: remove the FAIL definition */
-#define FAIL(x) do { printk(x "\n"); return -EINVAL; } while (0)
-
-static void aty_st_pll(int offset, u8 val, const struct atyfb_par *par);
-static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per,
-			    struct pll_ct *pll);
-static int aty_dsp_gt(const struct fb_info *info, u8 bpp,
-		      struct pll_ct *pll);
-static int aty_var_to_pll_ct(const struct fb_info *info, u32 vclk_per,
-			     u8 bpp, union aty_pll *pll);
-static u32 aty_pll_ct_to_var(const struct fb_info *info,
-			     const union aty_pll *pll);
+static int aty_valid_pll_ct (const struct fb_info *info, u32 vclk_per, struct pll_ct *pll);
+static int aty_dsp_gt       (const struct fb_info *info, u32 bpp, struct pll_ct *pll);
+static int aty_var_to_pll_ct(const struct fb_info *info, u32 vclk_per, u32 bpp, union aty_pll *pll);
+static u32 aty_pll_to_var_ct(const struct fb_info *info, const union aty_pll *pll);
 
+u8 aty_ld_pll_ct(int offset, const struct atyfb_par *par)
+{
+	u8 res;
 
+	/* write addr byte */
+	aty_st_8(CLOCK_CNTL_ADDR, (offset << 2) & PLL_ADDR, par);
+	/* read the register value */
+	res = aty_ld_8(CLOCK_CNTL_DATA, par);
+	return res;
+}
 
-static void aty_st_pll(int offset, u8 val, const struct atyfb_par *par)
+void aty_st_pll_ct(int offset, u8 val, const struct atyfb_par *par)
 {
 	/* write addr byte */
-	aty_st_8(CLOCK_CNTL + 1, (offset << 2) | PLL_WR_EN, par);
+	aty_st_8(CLOCK_CNTL_ADDR, ((offset << 2) & PLL_ADDR) | PLL_WR_EN, par);
 	/* write the register value */
-	aty_st_8(CLOCK_CNTL + 2, val, par);
-	aty_st_8(CLOCK_CNTL + 1, (offset << 2) & ~PLL_WR_EN, par);
+	aty_st_8(CLOCK_CNTL_DATA, val & PLL_DATA, par);
+	aty_st_8(CLOCK_CNTL_ADDR, ((offset << 2) & PLL_ADDR) & ~PLL_WR_EN, par);
 }
 
+/*
+ * by Daniel Mantione
+ *                                  <daniel.mantione@freepascal.org>
+ *
+ *
+ * ATI Mach64 CT clock synthesis description.
+ *
+ * All clocks on the Mach64 can be calculated using the same principle:
+ *
+ *       XTALIN * x * FB_DIV
+ * CLK = ----------------------
+ *       PLL_REF_DIV * POST_DIV
+ *
+ * XTALIN is a fixed speed clock. Common speeds are 14.31 MHz and 29.50 MHz.
+ * PLL_REF_DIV can be set by the user, but is the same for all clocks.
+ * FB_DIV can be set by the user for each clock individually, it should be set
+ * between 128 and 255, the chip will generate a bad clock signal for too low
+ * values.
+ * x depends on the type of clock; usually it is 2, but for the MCLK it can also
+ * be set to 4.
+ * POST_DIV can be set by the user for each clock individually, Possible values
+ * are 1,2,4,8 and for some clocks other values are available too.
+ * CLK is of course the clock speed that is generated.
+ *
+ * The Mach64 has these clocks:
+ *
+ * MCLK			The clock rate of the chip
+ * XCLK			The clock rate of the on-chip memory
+ * VCLK0		First pixel clock of first CRT controller
+ * VCLK1    Second pixel clock of first CRT controller
+ * VCLK2		Third pixel clock of first CRT controller
+ * VCLK3    Fourth pixel clock of first CRT controller
+ * VCLK			Selected pixel clock, one of VCLK0, VCLK1, VCLK2, VCLK3
+ * V2CLK		Pixel clock of the second CRT controller.
+ * SCLK			Multi-purpose clock
+ *
+ * - MCLK and XCLK use the same FB_DIV
+ * - VCLK0 .. VCLK3 use the same FB_DIV
+ * - V2CLK is needed when the second CRTC is used (can be used for dualhead);
+ *   i.e. CRT monitor connected to laptop has different resolution than built
+ *   in LCD monitor.
+ * - SCLK is not available on all cards; it is know to exist on the Rage LT-PRO,
+ *   Rage XL and Rage Mobility. It is know not to exist on the Mach64 VT.
+ * - V2CLK is not available on all cards, most likely only the Rage LT-PRO,
+ *   the Rage XL and the Rage Mobility
+ *
+ * SCLK can be used to:
+ * - Clock the chip instead of MCLK
+ * - Replace XTALIN with a user defined frequency
+ * - Generate the pixel clock for the LCD monitor (instead of VCLK)
+ */
+
+ /*
+  * It can be quite hard to calculate XCLK and MCLK if they don't run at the
+  * same frequency. Luckily, until now all cards that need asynchrone clock
+  * speeds seem to have SCLK.
+  * So this driver uses SCLK to clock the chip and XCLK to clock the memory.
+  */
 
 /* ------------------------------------------------------------------------- */
 
-    /*
-     *  PLL programming (Mach64 CT family)
-     */
+/*
+ *  PLL programming (Mach64 CT family)
+ *
+ *
+ * This procedure sets the display fifo. The display fifo is a buffer that
+ * contains data read from the video memory that waits to be processed by
+ * the CRT controller.
+ *
+ * On the more modern Mach64 variants, the chip doesn't calculate the
+ * interval after which the display fifo has to be reloaded from memory
+ * automatically, the driver has to do it instead.
+ */
+
+#define Maximum_DSP_PRECISION 7
+static u8 postdividers[] = {1,2,4,8,3};
 
-static int aty_dsp_gt(const struct fb_info *info, u8 bpp,
-		      struct pll_ct *pll)
+static int aty_dsp_gt(const struct fb_info *info, u32 bpp, struct pll_ct *pll)
 {
-	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	u32 dsp_xclks_per_row, dsp_loop_latency, dsp_precision, dsp_off,
-	    dsp_on;
-	u32 xclks_per_row, fifo_off, fifo_on, y, fifo_size, page_size;
-
-	/* xclocks_per_row<<11 */
-	xclks_per_row =
-	    (pll->mclk_fb_div * pll->vclk_post_div_real * 64 << 11) /
-	    (pll->vclk_fb_div * pll->mclk_post_div_real * bpp);
-	if (xclks_per_row < (1 << 11))
-		FAIL("Dotclock to high");
-	if (M64_HAS(FIFO_24)) {
-		fifo_size = 24;
-		dsp_loop_latency = 0;
-	} else {
-		fifo_size = 32;
-		dsp_loop_latency = 2;
+	u32 dsp_off, dsp_on, dsp_xclks;
+	u32 multiplier, divider, ras_multiplier, ras_divider, tmp;
+	u8 vshift, xshift;
+	s8 dsp_precision;
+
+	multiplier = ((u32)pll->mclk_fb_div) * pll->vclk_post_div_real;
+	divider = ((u32)pll->vclk_fb_div) * pll->xclk_ref_div;
+
+	ras_multiplier = pll->xclkmaxrasdelay;
+	ras_divider = 1;
+
+	if (bpp>=8)
+		divider = divider * (bpp >> 2);
+
+	vshift = (6 - 2) - pll->xclk_post_div;	/* FIFO is 64 bits wide in accelerator mode ... */
+
+	if (bpp == 0)
+		vshift--;	/* ... but only 32 bits in VGA mode. */
+
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (pll->xres != 0) {
+		struct atyfb_par *par = (struct atyfb_par *) info->par;
+
+		multiplier = multiplier * par->lcd_width;
+		divider = divider * pll->xres & ~7;
+
+		ras_multiplier = ras_multiplier * par->lcd_width;
+		ras_divider = ras_divider * pll->xres & ~7;
 	}
-	dsp_precision = 0;
-	y = (xclks_per_row * fifo_size) >> 11;
-	while (y) {
-		y >>= 1;
-		dsp_precision++;
-	}
-	dsp_precision -= 5;
-	/* fifo_off<<6 */
-	fifo_off = ((xclks_per_row * (fifo_size - 1)) >> 5) + (3 << 6);
-
-	if (info->fix.smem_len > 1 * 1024 * 1024) {
-		if (par->ram_type >= SDRAM) {
-			/* >1 MB SDRAM */
-			dsp_loop_latency += 8;
-			page_size = 8;
-		} else {
-			/* >1 MB DRAM */
-			dsp_loop_latency += 6;
-			page_size = 9;
-		}
-	} else {
-		if (par->ram_type >= SDRAM) {
-			/* <2 MB SDRAM */
-			dsp_loop_latency += 9;
-			page_size = 10;
-		} else {
-			/* <2 MB DRAM */
-			dsp_loop_latency += 8;
-			page_size = 10;
-		}
+#endif
+	/* If we don't do this, 32 bits for multiplier & divider won't be
+	enough in certain situations! */
+	while (((multiplier | divider) & 1) == 0) {
+		multiplier = multiplier >> 1;
+		divider = divider >> 1;
 	}
-	/* fifo_on<<6 */
-	if (xclks_per_row >= (page_size << 11))
-		fifo_on =
-		    ((2 * page_size + 1) << 6) + (xclks_per_row >> 5);
-	else
-		fifo_on = (3 * page_size + 2) << 6;
 
-	dsp_xclks_per_row = xclks_per_row >> dsp_precision;
-	dsp_on = fifo_on >> dsp_precision;
-	dsp_off = fifo_off >> dsp_precision;
-
-	pll->dsp_config = (dsp_xclks_per_row & 0x3fff) |
-	    ((dsp_loop_latency & 0xf) << 16) | ((dsp_precision & 7) << 20);
-	pll->dsp_on_off = (dsp_on & 0x7ff) | ((dsp_off & 0x7ff) << 16);
-	return 0;
-}
+	/* Determine DSP precision first */
+	tmp = ((multiplier * pll->fifo_size) << vshift) / divider;
 
-static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per,
-			    struct pll_ct *pll)
-{
-	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	u32 q, x;		/* x is a workaround for sparc64-linux-gcc */
-	x = x;			/* x is a workaround for sparc64-linux-gcc */
+	for (dsp_precision = -5;  tmp;  dsp_precision++)
+		tmp >>= 1;
+	if (dsp_precision < 0)
+		dsp_precision = 0;
+	else if (dsp_precision > Maximum_DSP_PRECISION)
+		dsp_precision = Maximum_DSP_PRECISION;
+
+	xshift = 6 - dsp_precision;
+	vshift += xshift;
+
+	/* Move on to dsp_off */
+	dsp_off = ((multiplier * (pll->fifo_size - 1)) << vshift) / divider -
+		(1 << (vshift - xshift));
+
+/*    if (bpp == 0)
+        dsp_on = ((multiplier * 20 << vshift) + divider) / divider;
+    else */
+	{
+		dsp_on = ((multiplier << vshift) + divider) / divider;
+		tmp = ((ras_multiplier << xshift) + ras_divider) / ras_divider;
+		if (dsp_on < tmp)
+		dsp_on = tmp;
+		dsp_on = dsp_on + (tmp * 2) + (pll->xclkpagefaultdelay << xshift);
+	}
 
-	pll->pll_ref_div = par->pll_per * 2 * 255 / par->ref_clk_per;
+	/* Calculate rounding factor and apply it to dsp_on */
+	tmp = ((1 << (Maximum_DSP_PRECISION - dsp_precision)) - 1) >> 1;
+	dsp_on = ((dsp_on + tmp) / (tmp + 1)) * (tmp + 1);
+
+	if (dsp_on >= ((dsp_off / (tmp + 1)) * (tmp + 1))) {
+		dsp_on = dsp_off - (multiplier << vshift) / divider;
+		dsp_on = (dsp_on / (tmp + 1)) * (tmp + 1);
+	}
 
-	/* FIXME: use the VTB/GTB /3 post divider if it's better suited */
-	q = par->ref_clk_per * pll->pll_ref_div * 4 / par->mclk_per;	/* actually 8*q */
-	if (q < 16 * 8 || q > 255 * 8)
-		FAIL("mclk out of range");
-	else if (q < 32 * 8)
-		pll->mclk_post_div_real = 8;
-	else if (q < 64 * 8)
-		pll->mclk_post_div_real = 4;
-	else if (q < 128 * 8)
-		pll->mclk_post_div_real = 2;
-	else
-		pll->mclk_post_div_real = 1;
-	pll->mclk_fb_div = q * pll->mclk_post_div_real / 8;
+	/* Last but not least:  dsp_xclks */
+	dsp_xclks = ((multiplier << (vshift + 5)) + divider) / divider;
 
-	/* FIXME: use the VTB/GTB /{3,6,12} post dividers if they're better suited */
-	q = par->ref_clk_per * pll->pll_ref_div * 4 / vclk_per;	/* actually 8*q */
-	if (q < 16 * 8 || q > 255 * 8)
-		FAIL("vclk out of range");
-	else if (q < 32 * 8)
-		pll->vclk_post_div_real = 8;
-	else if (q < 64 * 8)
-		pll->vclk_post_div_real = 4;
-	else if (q < 128 * 8)
-		pll->vclk_post_div_real = 2;
-	else
-		pll->vclk_post_div_real = 1;
-	pll->vclk_fb_div = q * pll->vclk_post_div_real / 8;
+	/* Get register values. */
+	pll->dsp_on_off = (dsp_on << 16) + dsp_off;
+	pll->dsp_config = (dsp_precision << 20) | (pll->dsp_loop_latency << 16) | dsp_xclks;
+#ifdef DEBUG
+	printk("atyfb(%s): dsp_config 0x%08x, dsp_on_off 0x%08x\n",
+		__FUNCTION__, pll->dsp_config, pll->dsp_on_off);
+#endif
 	return 0;
 }
 
-void aty_calc_pll_ct(const struct fb_info *info, struct pll_ct *pll)
+static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per, struct pll_ct *pll)
 {
+	u32 q;
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	u8 mpostdiv = 0;
-	u8 vpostdiv = 0;
+#ifdef DEBUG
+	int pllvclk;
+#endif
 
-	if (M64_HAS(SDRAM_MAGIC_PLL) && (par->ram_type >= SDRAM))
-		pll->pll_gen_cntl = 0x04;
-	else
-		pll->pll_gen_cntl = 0x84;
-
-	switch (pll->mclk_post_div_real) {
-	case 1:
-		mpostdiv = 0;
-		break;
-	case 2:
-		mpostdiv = 1;
-		break;
-	case 3:
-		mpostdiv = 4;
-		break;
-	case 4:
-		mpostdiv = 2;
-		break;
-	case 8:
-		mpostdiv = 3;
-		break;
-	}
-	pll->pll_gen_cntl |= mpostdiv << 4;	/* mclk */
-
-	if (M64_HAS(MAGIC_POSTDIV))
-		pll->pll_ext_cntl = 0;
-	else
-		pll->pll_ext_cntl = mpostdiv;	/* xclk == mclk */
-
-	switch (pll->vclk_post_div_real) {
-	case 2:
-		vpostdiv = 1;
-		break;
-	case 3:
-		pll->pll_ext_cntl |= 0x10;
-	case 1:
-		vpostdiv = 0;
-		break;
-	case 6:
-		pll->pll_ext_cntl |= 0x10;
-	case 4:
-		vpostdiv = 2;
-		break;
-	case 12:
-		pll->pll_ext_cntl |= 0x10;
-	case 8:
-		vpostdiv = 3;
-		break;
+	/* FIXME: use the VTB/GTB /{3,6,12} post dividers if they're better suited */
+	q = par->ref_clk_per * pll->pll_ref_div * 4 / vclk_per;
+	if (q < 16*8 || q > 255*8) {
+		printk(KERN_CRIT "atyfb: vclk out of range\n");
+		return -EINVAL;
+	} else {
+		pll->vclk_post_div  = (q < 128*8);
+		pll->vclk_post_div += (q <  64*8);
+		pll->vclk_post_div += (q <  32*8);
 	}
-
-	pll->pll_vclk_cntl = 0x03;	/* VCLK = PLL_VCLK/VCLKx_POST */
-	pll->vclk_post_div = vpostdiv;
+	pll->vclk_post_div_real = postdividers[pll->vclk_post_div];
+	//    pll->vclk_post_div <<= 6;
+	pll->vclk_fb_div = q * pll->vclk_post_div_real / 8;
+#ifdef DEBUG
+	pllvclk = (1000000 * 2 * pll->vclk_fb_div) /
+		(par->ref_clk_per * pll->pll_ref_div);
+	printk("atyfb(%s): pllvclk=%d MHz, vclk=%d MHz\n",
+		__FUNCTION__, pllvclk, pllvclk / pll->vclk_post_div_real);
+#endif
+	pll->pll_vclk_cntl = 0x03; /* VCLK = PLL_VCLK/VCLKx_POST */
+	return 0;
 }
 
-static int aty_var_to_pll_ct(const struct fb_info *info, u32 vclk_per,
-			     u8 bpp, union aty_pll *pll)
+static int aty_var_to_pll_ct(const struct fb_info *info, u32 vclk_per, u32 bpp, union aty_pll *pll)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
 	int err;
@@ -220,47 +242,360 @@
 		return err;
 	if (M64_HAS(GTB_DSP) && (err = aty_dsp_gt(info, bpp, &pll->ct)))
 		return err;
-	aty_calc_pll_ct(info, &pll->ct);
+	/*aty_calc_pll_ct(info, &pll->ct);*/
 	return 0;
 }
 
-static u32 aty_pll_ct_to_var(const struct fb_info *info,
-			     const union aty_pll *pll)
+static u32 aty_pll_to_var_ct(const struct fb_info *info, const union aty_pll *pll)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
-
-	u32 ref_clk_per = par->ref_clk_per;
-	u8 pll_ref_div = pll->ct.pll_ref_div;
-	u8 vclk_fb_div = pll->ct.vclk_fb_div;
-	u8 vclk_post_div = pll->ct.vclk_post_div_real;
-
-	return ref_clk_per * pll_ref_div * vclk_post_div / vclk_fb_div / 2;
+	u32 ret;
+	ret = par->ref_clk_per * pll->ct.pll_ref_div * pll->ct.vclk_post_div_real / pll->ct.vclk_fb_div / 2;
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if(pll->ct.xres > 0) {
+		ret *= par->lcd_width;
+		ret /= pll->ct.xres;
+	}
+#endif
+#ifdef DEBUG
+	printk("atyfb(%s): calculated 0x%08X(%i)\n", __FUNCTION__, ret, ret);
+#endif
+	return ret;
 }
 
-void aty_set_pll_ct(const struct fb_info *info,
-		    const union aty_pll *pll)
+void aty_set_pll_ct(const struct fb_info *info, const union aty_pll *pll)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
+	u32 crtc_gen_cntl, lcd_gen_cntrl;
+	u8 tmp, tmp2;
+
+	lcd_gen_cntrl = 0;
+#ifdef DEBUG
+	printk("atyfb(%s): about to program:\n"
+		"pll_ext_cntl=0x%02x pll_gen_cntl=0x%02x pll_vclk_cntl=0x%02x\n",
+		__FUNCTION__,
+		pll->ct.pll_ext_cntl, pll->ct.pll_gen_cntl, pll->ct.pll_vclk_cntl);
+
+	printk("atyfb(%s): setting clock %lu for FeedBackDivider %i, ReferenceDivider %i, PostDivider %i(%i)\n",
+		__FUNCTION__,
+		par->clk_wr_offset, pll->ct.vclk_fb_div,
+		pll->ct.pll_ref_div, pll->ct.vclk_post_div, pll->ct.vclk_post_div_real);
+#endif
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (par->lcd_table != 0) {
+		/* turn off LCD */
+		lcd_gen_cntrl = aty_ld_lcd(LCD_GEN_CNTL, par);
+		aty_st_lcd(LCD_GEN_CNTL, lcd_gen_cntrl & ~LCD_ON, par);
+	}
+#endif
+	aty_st_8(CLOCK_CNTL, par->clk_wr_offset | CLOCK_STROBE, par);
 
-	aty_st_pll(PLL_REF_DIV, pll->ct.pll_ref_div, par);
-	aty_st_pll(PLL_GEN_CNTL, pll->ct.pll_gen_cntl, par);
-	aty_st_pll(MCLK_FB_DIV, pll->ct.mclk_fb_div, par);
-	aty_st_pll(PLL_VCLK_CNTL, pll->ct.pll_vclk_cntl, par);
-	aty_st_pll(VCLK_POST_DIV, pll->ct.vclk_post_div, par);
-	aty_st_pll(VCLK0_FB_DIV, pll->ct.vclk_fb_div, par);
-	aty_st_pll(PLL_EXT_CNTL, pll->ct.pll_ext_cntl, par);
+	/* Temporarily switch to accelerator mode */
+	crtc_gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par);
+	if (!(crtc_gen_cntl & CRTC_EXT_DISP_EN))
+		aty_st_le32(CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_EXT_DISP_EN, par);
+
+	/* Reset VCLK generator */
+	aty_st_pll_ct(PLL_VCLK_CNTL, pll->ct.pll_vclk_cntl, par);
+
+	/* Set post-divider */
+	tmp2 = par->clk_wr_offset << 1;
+	tmp = aty_ld_pll_ct(VCLK_POST_DIV, par);
+	tmp &= ~(0x03U << tmp2);
+	tmp |= ((pll->ct.vclk_post_div & 0x03U) << tmp2);
+	aty_st_pll_ct(VCLK_POST_DIV, tmp, par);
+
+	/* Set extended post-divider */
+	tmp = aty_ld_pll_ct(PLL_EXT_CNTL, par);
+	tmp &= ~(0x10U << par->clk_wr_offset);
+	tmp &= 0xF0U;
+	tmp |= pll->ct.pll_ext_cntl;
+	aty_st_pll_ct(PLL_EXT_CNTL, tmp, par);
+
+	/* Set feedback divider */
+	tmp = VCLK0_FB_DIV + par->clk_wr_offset;
+	aty_st_pll_ct(tmp, (pll->ct.vclk_fb_div & 0xFFU), par);
+
+	aty_st_pll_ct(PLL_GEN_CNTL, (pll->ct.pll_gen_cntl & (~(PLL_OVERRIDE | PLL_MCLK_RST))) | OSC_EN, par);
+
+	/* End VCLK generator reset */
+	aty_st_pll_ct(PLL_VCLK_CNTL, pll->ct.pll_vclk_cntl & ~(PLL_VCLK_RST), par);
+	mdelay(5);
+
+	aty_st_pll_ct(PLL_GEN_CNTL, pll->ct.pll_gen_cntl, par);
+	aty_st_pll_ct(PLL_VCLK_CNTL, pll->ct.pll_vclk_cntl, par);
+	mdelay(1);
+
+	/* Restore mode register */
+	if (!(crtc_gen_cntl & CRTC_EXT_DISP_EN))
+		aty_st_le32(CRTC_GEN_CNTL, crtc_gen_cntl, par);
 
 	if (M64_HAS(GTB_DSP)) {
+		u8 dll_cntl;
+
 		if (M64_HAS(XL_DLL))
-			aty_st_pll(DLL_CNTL, 0x80, par);
+			dll_cntl = 0x80;
 		else if (par->ram_type >= SDRAM)
-			aty_st_pll(DLL_CNTL, 0xa6, par);
+			dll_cntl = 0xa6;
 		else
-			aty_st_pll(DLL_CNTL, 0xa0, par);
-		aty_st_pll(VFC_CNTL, 0x1b, par);
+			dll_cntl = 0xa0;
+		aty_st_pll_ct(DLL_CNTL, dll_cntl, par);
+		aty_st_pll_ct(VFC_CNTL, 0x1b, par);
 		aty_st_le32(DSP_CONFIG, pll->ct.dsp_config, par);
 		aty_st_le32(DSP_ON_OFF, pll->ct.dsp_on_off, par);
+
+		mdelay(10);
+		aty_st_pll_ct(DLL_CNTL, dll_cntl, par);
+		mdelay(10);
+		aty_st_pll_ct(DLL_CNTL, dll_cntl | 0x40, par);
+		mdelay(10);
+		aty_st_pll_ct(DLL_CNTL, dll_cntl & ~0x40, par);
+	}
+#ifdef CONFIG_FB_ATY_GENERIC_LCD
+	if (par->lcd_table != 0) {
+		/* restore LCD */
+		aty_st_lcd(LCD_GEN_CNTL, lcd_gen_cntrl, par);
 	}
+#endif
+}
+
+void __init aty_get_pll_ct(const struct fb_info *info, union aty_pll *pll)
+{
+	struct atyfb_par *par = (struct atyfb_par *) info->par;
+	u8 tmp, clock;
+
+	clock = aty_ld_8(CLOCK_CNTL, par) & 0x03U;
+	tmp = clock << 1;
+	pll->ct.vclk_post_div = (aty_ld_pll_ct(VCLK_POST_DIV, par) >> tmp) & 0x03U;
+
+	pll->ct.pll_ext_cntl = aty_ld_pll_ct(PLL_EXT_CNTL, par) & 0x0FU;
+	pll->ct.vclk_fb_div = aty_ld_pll_ct(VCLK0_FB_DIV + clock, par) & 0xFFU;
+	pll->ct.pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par);
+	pll->ct.mclk_fb_div = aty_ld_pll_ct(MCLK_FB_DIV, par);
+
+	pll->ct.pll_gen_cntl = aty_ld_pll_ct(PLL_GEN_CNTL, par);
+	pll->ct.pll_vclk_cntl = aty_ld_pll_ct(PLL_VCLK_CNTL, par);
+
+	if (M64_HAS(GTB_DSP)) {
+		pll->ct.dsp_config = aty_ld_le32(DSP_CONFIG, par);
+		pll->ct.dsp_on_off = aty_ld_le32(DSP_ON_OFF, par);
+	}
+}
+
+int __init aty_init_pll_ct(const struct fb_info *info, union aty_pll *pll) {
+	struct atyfb_par *par = (struct atyfb_par *) info->par;
+	u8 mpost_div, xpost_div, sclk_post_div_real, sclk_fb_div, spll_cntl2;
+	u32 q, i, memcntl, trp;
+	u32 dsp_config, dsp_on_off, vga_dsp_config, vga_dsp_on_off;
+#ifdef DEBUG
+	int pllmclk, pllsclk;
+#endif
+	pll->ct.pll_ext_cntl = aty_ld_pll_ct(PLL_EXT_CNTL, par);
+	pll->ct.xclk_post_div = pll->ct.pll_ext_cntl & 0x07;
+	pll->ct.xclk_ref_div = 1;
+	switch (pll->ct.xclk_post_div) {
+	case 0:  case 1:  case 2:  case 3:
+		break;
+
+	case 4:
+		pll->ct.xclk_ref_div = 3;
+		pll->ct.xclk_post_div = 0;
+		break;
+
+	default:
+		printk(KERN_CRIT "atyfb: Unsupported xclk source:  %d.\n", pll->ct.xclk_post_div);
+		return -EINVAL;
+	}
+	pll->ct.mclk_fb_mult = 2;
+	if(pll->ct.pll_ext_cntl & PLL_MFB_TIMES_4_2B) {
+		pll->ct.mclk_fb_mult = 4;
+		pll->ct.xclk_post_div -= 1;
+	}
+
+#ifdef DEBUG
+	printk("atyfb(%s): mclk_fb_mult=%d, xclk_post_div=%d\n",
+		__FUNCTION__, pll->ct.mclk_fb_mult, pll->ct.xclk_post_div);
+#endif
+
+	memcntl = aty_ld_le32(MEM_CNTL, par);
+	trp = (memcntl & 0x300) >> 8;
+
+	pll->ct.xclkpagefaultdelay = ((memcntl & 0xc00) >> 10) + ((memcntl & 0x1000) >> 12) + trp + 2;
+	pll->ct.xclkmaxrasdelay = ((memcntl & 0x70000) >> 16) + trp + 2;
+
+	if (M64_HAS(FIFO_32)) {
+		pll->ct.fifo_size = 32;
+	} else {
+		pll->ct.fifo_size = 24;
+		pll->ct.xclkpagefaultdelay += 2;
+		pll->ct.xclkmaxrasdelay += 3;
+	}
+
+	switch (par->ram_type) {
+	case DRAM:
+		if (info->fix.smem_len<=ONE_MB) {
+			pll->ct.dsp_loop_latency = 10;
+		} else {
+			pll->ct.dsp_loop_latency = 8;
+			pll->ct.xclkpagefaultdelay += 2;
+		}
+		break;
+	case EDO:
+	case PSEUDO_EDO:
+		if (info->fix.smem_len<=ONE_MB) {
+			pll->ct.dsp_loop_latency = 9;
+		} else {
+			pll->ct.dsp_loop_latency = 8;
+			pll->ct.xclkpagefaultdelay += 1;
+		}
+		break;
+	case SDRAM:
+		if (info->fix.smem_len<=ONE_MB) {
+			pll->ct.dsp_loop_latency = 11;
+		} else {
+			pll->ct.dsp_loop_latency = 10;
+			pll->ct.xclkpagefaultdelay += 1;
+		}
+		break;
+	case SGRAM:
+		pll->ct.dsp_loop_latency = 8;
+		pll->ct.xclkpagefaultdelay += 3;
+		break;
+	default:
+		pll->ct.dsp_loop_latency = 11;
+		pll->ct.xclkpagefaultdelay += 3;
+		break;
+	}
+
+	if (pll->ct.xclkmaxrasdelay <= pll->ct.xclkpagefaultdelay)
+		pll->ct.xclkmaxrasdelay = pll->ct.xclkpagefaultdelay + 1;
+
+	/* Allow BIOS to override */
+	dsp_config = aty_ld_le32(DSP_CONFIG, par);
+	dsp_on_off = aty_ld_le32(DSP_ON_OFF, par);
+	vga_dsp_config = aty_ld_le32(VGA_DSP_CONFIG, par);
+	vga_dsp_on_off = aty_ld_le32(VGA_DSP_ON_OFF, par);
+
+	if (dsp_config)
+		pll->ct.dsp_loop_latency = (dsp_config & DSP_LOOP_LATENCY) >> 16;
+#if 0
+	FIXME: is it relevant for us?
+	if ((!dsp_on_off && !M64_HAS(RESET_3D)) ||
+		((dsp_on_off == vga_dsp_on_off) &&
+		(!dsp_config || !((dsp_config ^ vga_dsp_config) & DSP_XCLKS_PER_QW)))) {
+		vga_dsp_on_off &= VGA_DSP_OFF;
+		vga_dsp_config &= VGA_DSP_XCLKS_PER_QW;
+		if (ATIDivide(vga_dsp_on_off, vga_dsp_config, 5, 1) > 24)
+			pll->ct.fifo_size = 32;
+		else
+			pll->ct.fifo_size = 24;
+	}
+#endif
+	/* Exit if the user does not want us to tamper with the clock
+	rates of her chip. */
+	if (par->mclk_per == 0) {
+		u8 mclk_fb_div, pll_ext_cntl;
+		pll->ct.pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par);
+		pll_ext_cntl = aty_ld_pll_ct(PLL_EXT_CNTL, par);
+		pll->ct.xclk_post_div_real = postdividers[pll_ext_cntl & 0x07];
+		mclk_fb_div = aty_ld_pll_ct(MCLK_FB_DIV, par);
+		if (pll_ext_cntl & PLL_MFB_TIMES_4_2B)
+			mclk_fb_div <<= 1;
+		pll->ct.mclk_fb_div = mclk_fb_div;
+		return 0;
+	}
+
+	pll->ct.pll_ref_div = par->pll_per * 2 * 255 / par->ref_clk_per;
+
+	/* FIXME: use the VTB/GTB /3 post divider if it's better suited */
+	q = par->ref_clk_per * pll->ct.pll_ref_div * 8 /
+		(pll->ct.mclk_fb_mult * par->xclk_per);
+
+	if (q < 16*8 || q > 255*8) {
+		printk(KERN_CRIT "atxfb: xclk out of range\n");
+		return -EINVAL;
+	} else {
+		xpost_div  = (q < 128*8);
+		xpost_div += (q <  64*8);
+		xpost_div += (q <  32*8);
+	}
+	pll->ct.xclk_post_div_real = postdividers[xpost_div];
+	pll->ct.mclk_fb_div = q * pll->ct.xclk_post_div_real / 8;
+
+#ifdef DEBUG
+	pllmclk = (1000000 * pll->ct.mclk_fb_mult * pll->ct.mclk_fb_div) /
+			(par->ref_clk_per * pll->ct.pll_ref_div);
+	printk("atyfb(%s): pllmclk=%d MHz, xclk=%d MHz\n",
+		__FUNCTION__, pllmclk, pllmclk / pll->ct.xclk_post_div_real);
+#endif
+
+	if (M64_HAS(SDRAM_MAGIC_PLL) && (par->ram_type >= SDRAM))
+		pll->ct.pll_gen_cntl = OSC_EN;
+	else
+		pll->ct.pll_gen_cntl = OSC_EN | DLL_PWDN /* | FORCE_DCLK_TRI_STATE */;
+
+	if (M64_HAS(MAGIC_POSTDIV))
+		pll->ct.pll_ext_cntl = 0;
+	else
+		pll->ct.pll_ext_cntl = xpost_div;
+
+	if (pll->ct.mclk_fb_mult == 4)
+		pll->ct.pll_ext_cntl |= PLL_MFB_TIMES_4_2B;
+
+	if (par->mclk_per == par->xclk_per) {
+		pll->ct.pll_gen_cntl |= (xpost_div << 4); /* mclk == xclk */
+	} else {
+		/*
+		* The chip clock is not equal to the memory clock.
+		* Therefore we will use sclk to clock the chip.
+		*/
+		pll->ct.pll_gen_cntl |= (6 << 4); /* mclk == sclk */
+
+		q = par->ref_clk_per * pll->ct.pll_ref_div * 4 / par->mclk_per;
+		if (q < 16*8 || q > 255*8) {
+			printk(KERN_CRIT "atyfb: mclk out of range\n");
+			return -EINVAL;
+		} else {
+			mpost_div  = (q < 128*8);
+			mpost_div += (q <  64*8);
+			mpost_div += (q <  32*8);
+		}
+		sclk_post_div_real = postdividers[mpost_div];
+		sclk_fb_div = q * sclk_post_div_real / 8;
+		spll_cntl2 = mpost_div << 4;
+#ifdef DEBUG
+		pllsclk = (1000000 * 2 * sclk_fb_div) /
+			(par->ref_clk_per * pll->ct.pll_ref_div);
+		printk("atyfb(%s): use sclk, pllsclk=%d MHz, sclk=mclk=%d MHz\n",
+			__FUNCTION__, pllsclk, pllsclk / sclk_post_div_real);
+#endif
+		/*
+		* This disables the sclk, crashes the computer as reported:
+		* aty_st_pll_ct(SPLL_CNTL2, 3, info);
+		*
+		* So it seems the sclk must be enabled before it is used;
+		* so PLL_GEN_CNTL must be programmed *after* the sclk.
+		*/
+		aty_st_pll_ct(SCLK_FB_DIV, sclk_fb_div, par);
+		aty_st_pll_ct(SPLL_CNTL2, spll_cntl2, par);
+		/*
+		 * The sclk has been started. However, I believe the first clock
+		 * ticks it generates are not very stable. Hope this primitive loop
+		 * helps for Rage Mobilities that sometimes crash when
+		 * we switch to sclk. (Daniel Mantione, 13-05-2003)
+		 */
+		for (i=0;i<=0x1ffff;i++);
+	}
+
+	aty_st_pll_ct(PLL_REF_DIV, pll->ct.pll_ref_div, par);
+	aty_st_pll_ct(PLL_GEN_CNTL, pll->ct.pll_gen_cntl, par);
+	aty_st_pll_ct(MCLK_FB_DIV, pll->ct.mclk_fb_div, par);
+	aty_st_pll_ct(PLL_EXT_CNTL, pll->ct.pll_ext_cntl, par);
+	/* Disable the extra precision pixel clock controls since we do not use them. */
+	aty_st_pll_ct(EXT_VPLL_CNTL, aty_ld_pll_ct(EXT_VPLL_CNTL, par) &
+		~(EXT_VPLL_EN | EXT_VPLL_VGA_EN | EXT_VPLL_INSYNC), par);
+
+	return 0;
 }
 
 static int dummy(void)
@@ -274,6 +609,8 @@
 
 const struct aty_pll_ops aty_pll_ct = {
 	.var_to_pll	= aty_var_to_pll_ct,
-	.pll_to_var	= aty_pll_ct_to_var,
+	.pll_to_var	= aty_pll_to_var_ct,
 	.set_pll	= aty_set_pll_ct,
+	.get_pll	= aty_get_pll_ct,
+	.init_pll       = aty_init_pll_ct
 };
diff -Nru a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
--- a/drivers/video/aty/mach64_cursor.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/video/aty/mach64_cursor.c	2004-12-24 13:37:29 -08:00
@@ -1,12 +1,11 @@
-
 /*
  *  ATI Mach64 CT/VT/GT/LT Cursor Support
  */
 
 #include <linux/slab.h>
-#include <linux/console.h>
 #include <linux/fb.h>
 #include <linux/init.h>
+#include <linux/string.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -19,13 +18,49 @@
 #include <video/mach64.h>
 #include "atyfb.h"
 
+/*
+ * The hardware cursor definition requires 2 bits per pixel. The
+ * Cursor size reguardless of the visible cursor size is 64 pixels
+ * by 64 lines. The total memory required to define the cursor is
+ * 16 bytes / line for 64 lines or 1024 bytes of data. The data
+ * must be in a contigiuos format. The 2 bit cursor code values are
+ * as follows:
+ *
+ *	00 - pixel colour = CURSOR_CLR_0
+ *	01 - pixel colour = CURSOR_CLR_1
+ *	10 - pixel colour = transparent (current display pixel)
+ *	11 - pixel colour = 1's complement of current display pixel
+ *
+ *	Cursor Offset        64 pixels		 Actual Displayed Area
+ *            \_________________________/
+ *	      |			|	|	|
+ *	      |<--------------->|	|	|
+ *	      | CURS_HORZ_OFFSET|	|	|
+ *	      |			|_______|	|  64 Lines
+ *	      |			   ^	|	|
+ *	      |			   |	|	|
+ *	      |		CURS_VERT_OFFSET|	|
+ *	      |			   |	|	|
+ *	      |____________________|____|	|
+ *
+ *
+ * The Screen position of the top left corner of the displayed
+ * cursor is specificed by CURS_HORZ_VERT_POSN. Care must be taken
+ * when the cursor hot spot is not the top left corner and the
+ * physical cursor position becomes negative. It will be be displayed
+ * if either the horizontal or vertical cursor position is negative
+ *
+ * If x becomes negative the cursor manager must adjust the CURS_HORZ_OFFSET
+ * to a larger number and saturate CUR_HORZ_POSN to zero.
+ *
+ * if Y becomes negative, CUR_VERT_OFFSET must be adjusted to a larger number,
+ * CUR_OFFSET must be adjusted to a point to the appropraite line in the cursor
+ * definitation and CUR_VERT_POSN must be saturated to zero.
+ */
+
     /*
      *  Hardware Cursor support.
      */
-
-static const u8 cursor_pixel_map[2] = { 0, 15 };
-static const u8 cursor_color_map[2] = { 0, 0xff };
-
 static const u8 cursor_bits_lookup[16] = {
 	0x00, 0x40, 0x10, 0x50, 0x04, 0x44, 0x14, 0x54,
 	0x01, 0x41, 0x11, 0x51, 0x05, 0x45, 0x15, 0x55
@@ -36,89 +71,25 @@
 	0xa8, 0x28, 0x88, 0x08, 0xa0, 0x20, 0x80, 0x00
 };
 
-void aty_set_cursor_color(struct fb_info *info)
-{
-	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	struct aty_cursor *c = par->cursor;
-	const u8 *pixel = cursor_pixel_map;	/* ++Geert: Why?? */
-	const u8 *red = cursor_color_map;
-	const u8 *green = cursor_color_map;
-	const u8 *blue = cursor_color_map;
-	u32 fg_color, bg_color;
-
-	if (!c)
-		return;
-
-#ifdef __sparc__
-	if (par->mmaped)
-		return;
-#endif
-	fg_color = (u32) red[0] << 24;
-	fg_color |= (u32) green[0] << 16;
-	fg_color |= (u32) blue[0] << 8;
-	fg_color |= (u32) pixel[0];
-
-	bg_color = (u32) red[1] << 24;
-	bg_color |= (u32) green[1] << 16;
-	bg_color |= (u32) blue[1] << 8;
-	bg_color |= (u32) pixel[1];
-
-	wait_for_fifo(2, par);
-	aty_st_le32(CUR_CLR0, fg_color, par);
-	aty_st_le32(CUR_CLR1, bg_color, par);
-}
-
-void aty_set_cursor_shape(struct fb_info *info)
-{
-	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	struct fb_cursor *cursor = &info->cursor;
-	struct aty_cursor *c = par->cursor;
-	u8 *ram, m, b;
-	int x, y;
-
-	if (!c)
-		return;
-#ifdef __sparc__
-	if (par->mmaped)
-		return;
-#endif
-
-	ram = c->ram;
-	for (y = 0; y < cursor->image.height; y++) {
-		for (x = 0; x < cursor->image.width >> 2; x++) {
-			m = c->mask[x][y];
-			b = c->bits[x][y];
-			fb_writeb(cursor_mask_lookup[m >> 4] |
-				  cursor_bits_lookup[(b & m) >> 4], ram++);
-			fb_writeb(cursor_mask_lookup[m & 0x0f] |
-				  cursor_bits_lookup[(b & m) & 0x0f],
-				  ram++);
-		}
-		for (; x < 8; x++) {
-			fb_writeb(0xaa, ram++);
-			fb_writeb(0xaa, ram++);
-		}
-	}
-	fb_memset(ram, 0xaa, (64 - cursor->image.height) * 16);
-}
-
-static void aty_set_cursor(struct fb_info *info)
+int atyfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 {
 	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	struct fb_cursor *cursor = &info->cursor;
-	struct aty_cursor *c = par->cursor;
 	u16 xoff, yoff;
-	int x, y;
-
-	if (!c)
-		return;
+	int x, y, h;
 
 #ifdef __sparc__
 	if (par->mmaped)
-		return;
+		return -EPERM;
 #endif
+	if (par->asleep)
+		return -EPERM;
 
-	if (cursor->enable) {
+	/* Hide cursor */
+	wait_for_fifo(1, par);
+	aty_st_le32(GEN_TEST_CNTL, aty_ld_le32(GEN_TEST_CNTL, par) & ~HWCURSOR_ENABLE, par);
+
+	/* set position */
+	if (cursor->set & FB_CUR_SETPOS) {
 		x = cursor->image.dx - cursor->hot.x - info->var.xoffset;
 		if (x < 0) {
 			xoff = -x;
@@ -135,107 +106,121 @@
 			yoff = 0;
 		}
 
+		h = cursor->image.height;
+
+		/*
+		 * In doublescan mode, the cursor location
+		 * and heigh also needs to be doubled.
+		 */
+                if (par->crtc.gen_cntl & CRTC_DBL_SCAN_EN) {
+			y<<=1;
+			h<<=1;
+		}
 		wait_for_fifo(4, par);
-		aty_st_le32(CUR_OFFSET, (info->fix.smem_len >> 3) + (yoff << 1),
-			    par);
+		aty_st_le32(CUR_OFFSET, (info->fix.smem_len >> 3) + (yoff << 1), par);
 		aty_st_le32(CUR_HORZ_VERT_OFF,
-			    ((u32) (64 - cursor->image.height + yoff) << 16) | xoff,
-			    par);
+			    ((u32) (64 - h + yoff) << 16) | xoff, par);
 		aty_st_le32(CUR_HORZ_VERT_POSN, ((u32) y << 16) | x, par);
-		aty_st_le32(GEN_TEST_CNTL, aty_ld_le32(GEN_TEST_CNTL, par)
-			    | HWCURSOR_ENABLE, par);
-	} else {
-		wait_for_fifo(1, par);
-		aty_st_le32(GEN_TEST_CNTL,
-			    aty_ld_le32(GEN_TEST_CNTL,
-					par) & ~HWCURSOR_ENABLE, par);
 	}
-	if (par->blitter_may_be_busy)
-		wait_for_idle(par);
-}
-
-int atyfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
-{
-	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	struct aty_cursor *c = par->cursor;
-
-	if (!c)
-		return -1;
 
-#ifdef __sparc__
-	if (par->mmaped)
-		return 0;
-#endif
+	/* Set color map */
+	if (cursor->set & FB_CUR_SETCMAP) {
+		u32 fg_idx, bg_idx, fg, bg;
+
+		fg_idx = cursor->image.fg_color;
+		bg_idx = cursor->image.bg_color;
+
+		fg = (info->cmap.red[fg_idx] << 24) |
+		     (info->cmap.green[fg_idx] << 16) |
+		     (info->cmap.blue[fg_idx] << 8) | 15;
+
+		bg = (info->cmap.red[bg_idx] << 24) |
+		     (info->cmap.green[bg_idx] << 16) |
+		     (info->cmap.blue[bg_idx] << 8);
+
+		wait_for_fifo(2, par);
+		aty_st_le32(CUR_CLR0, bg, par);
+		aty_st_le32(CUR_CLR1, fg, par);
+	}
 
-	aty_set_cursor(info);
-	cursor->image.dx = info->cursor.image.dx;
-	cursor->image.dy = info->cursor.image.dy;
+	if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
+	    u8 *src = (u8 *)cursor->image.data;
+	    u8 *msk = (u8 *)cursor->mask;
+	    u8 __iomem *dst = (u8 __iomem *)info->sprite.addr;
+	    unsigned int width = (cursor->image.width + 7) >> 3;
+	    unsigned int height = cursor->image.height;
+	    unsigned int align = info->sprite.scan_align;
+
+	    unsigned int i, j, offset;
+	    u8 m, b;
+
+	    // Clear cursor image with 1010101010...
+	    fb_memset(dst, 0xaa, 1024);
+
+	    offset = align - width*2;
+
+	    for (i = 0; i < height; i++) {
+		for (j = 0; j < width; j++) {
+			b = *src++;
+			m = *msk++;
+			switch (cursor->rop) {
+			case ROP_XOR:
+			    // Upper 4 bits of mask data
+			    fb_writeb(cursor_mask_lookup[m >> 4 ] |
+				cursor_bits_lookup[(b ^ m) >> 4], dst++);
+			    // Lower 4 bits of mask
+			    fb_writeb(cursor_mask_lookup[m & 0x0f ] |
+				cursor_bits_lookup[(b ^ m) & 0x0f], dst++);
+			    break;
+			case ROP_COPY:
+			    // Upper 4 bits of mask data
+			    fb_writeb(cursor_mask_lookup[m >> 4 ] |
+				cursor_bits_lookup[(b & m) >> 4], dst++);
+			    // Lower 4 bits of mask
+			    fb_writeb(cursor_mask_lookup[m & 0x0f ] |
+				cursor_bits_lookup[(b & m) & 0x0f], dst++);
+			    break;
+			}
+		}
+		dst += offset;
+	    }
+	}
 
-	aty_set_cursor(info);
+	if (cursor->enable) {
+		wait_for_fifo(1, par);
+		aty_st_le32(GEN_TEST_CNTL, aty_ld_le32(GEN_TEST_CNTL, par)
+			    | HWCURSOR_ENABLE, par);
+	}
 	return 0;
 }
 
-struct aty_cursor *__init aty_init_cursor(struct fb_info *info)
+int __init aty_init_cursor(struct fb_info *info)
 {
-	struct aty_cursor *cursor;
 	unsigned long addr;
 
-	cursor = kmalloc(sizeof(struct aty_cursor), GFP_ATOMIC);
-	if (!cursor)
-		return NULL;
-	memset(cursor, 0, sizeof(*cursor));
-
 	info->fix.smem_len -= PAGE_SIZE;
 
 #ifdef __sparc__
 	addr = (unsigned long) info->screen_base - 0x800000 + info->fix.smem_len;
-	cursor->ram = (u8 *) addr;
+	info->sprite.addr = (u8 *) addr;
 #else
 #ifdef __BIG_ENDIAN
 	addr = info->fix.smem_start - 0x800000 + info->fix.smem_len;
-	cursor->ram = (u8 *) ioremap(addr, 1024);
+	info->sprite.addr = (u8 *) ioremap(addr, 1024);
 #else
 	addr = (unsigned long) info->screen_base + info->fix.smem_len;
-	cursor->ram = (u8 *) addr;
+	info->sprite.addr = (u8 *) addr;
 #endif
 #endif
-	if (!cursor->ram) {
-		kfree(cursor);
-		return NULL;
-	}
-	return cursor;
-}
+	if (!info->sprite.addr)
+		return -ENXIO;
+	info->sprite.size = PAGE_SIZE;
+	info->sprite.scan_align = 16;	/* Scratch pad 64 bytes wide */
+	info->sprite.buf_align = 16; 	/* and 64 lines tall. */
+	info->sprite.flags = FB_PIXMAP_IO;
 
-int atyfb_set_font(struct fb_info *info, int width, int height)
-{
-	struct atyfb_par *par = (struct atyfb_par *) info->par;
-	struct fb_cursor *cursor = &info->cursor;
-	struct aty_cursor *c = par->cursor;
-	int i, j;
-
-	if (c) {
-		if (!width || !height) {
-			width = 8;
-			height = 16;
-		}
-
-		cursor->hot.x = 0;
-		cursor->hot.y = 0;
-		cursor->image.width = width;
-		cursor->image.height = height;
-
-		memset(c->bits, 0xff, sizeof(c->bits));
-		memset(c->mask, 0, sizeof(c->mask));
-
-		for (i = 0, j = width; j >= 0; j -= 8, i++) {
-			c->mask[i][height - 2] =
-			    (j >= 8) ? 0xff : (0xff << (8 - j));
-			c->mask[i][height - 1] =
-			    (j >= 8) ? 0xff : (0xff << (8 - j));
-		}
+	info->fbops->fb_cursor = atyfb_cursor;
 
-		aty_set_cursor_color(info);
-		aty_set_cursor_shape(info);
-	}
-	return 1;
+	return 0;
 }
+
diff -Nru a/drivers/video/aty/mach64_gx.c b/drivers/video/aty/mach64_gx.c
--- a/drivers/video/aty/mach64_gx.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/video/aty/mach64_gx.c	2004-12-24 13:36:19 -08:00
@@ -121,7 +121,7 @@
 }
 
 static int aty_var_to_pll_514(const struct fb_info *info, u32 vclk_per,
-			      u8 bpp, union aty_pll *pll)
+			      u32 bpp, union aty_pll *pll)
 {
 	/*
 	 *  FIXME: use real calculations instead of using fixed values from the old
@@ -253,9 +253,9 @@
 	temp = aty_ld_8(DAC_CNTL, par);
 	aty_st_8(DAC_CNTL, temp | DAC_EXT_SEL_RS2 | DAC_EXT_SEL_RS3, par);
 
-	if (info->fix.smem_len < MEM_SIZE_1M)
+	if (info->fix.smem_len < ONE_MB)
 		mask = 0x04;
-	else if (info->fix.smem_len == MEM_SIZE_1M)
+	else if (info->fix.smem_len == ONE_MB)
 		mask = 0x08;
 	else
 		mask = 0x0C;
@@ -339,8 +339,8 @@
      *  ATI 18818 / ICS 2595 Clock Chip
      */
 
-static int aty_var_to_pll_18818(const struct fb_info *info,
-				u32 vclk_per, u8 bpp, union aty_pll *pll)
+static int aty_var_to_pll_18818(const struct fb_info *info, u32 vclk_per,
+				u32 bpp, union aty_pll *pll)
 {
 	u32 MHz100;		/* in 0.01 MHz */
 	u32 program_bits;
@@ -495,8 +495,8 @@
      *  STG 1703 Clock Chip
      */
 
-static int aty_var_to_pll_1703(const struct fb_info *info,
-			       u32 vclk_per, u8 bpp, union aty_pll *pll)
+static int aty_var_to_pll_1703(const struct fb_info *info, u32 vclk_per,
+			       u32 bpp, union aty_pll *pll)
 {
 	u32 mhz100;		/* in 0.01 MHz */
 	u32 program_bits;
@@ -611,8 +611,8 @@
      *  Chrontel 8398 Clock Chip
      */
 
-static int aty_var_to_pll_8398(const struct fb_info *info,
-			       u32 vclk_per, u8 bpp, union aty_pll *pll)
+static int aty_var_to_pll_8398(const struct fb_info *info, u32 vclk_per,
+			       u32 bpp, union aty_pll *pll)
 {
 	u32 tempA, tempB, fOut, longMHz100, diff, preDiff;
 
@@ -736,7 +736,7 @@
      */
 
 static int aty_var_to_pll_408(const struct fb_info *info, u32 vclk_per,
-			      u8 bpp, union aty_pll *pll)
+			      u32 bpp, union aty_pll *pll)
 {
 	u32 mhz100;		/* in 0.01 MHz */
 	u32 program_bits;
diff -Nru a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
--- a/drivers/video/aty/radeon_base.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/video/aty/radeon_base.c	2004-12-24 13:36:34 -08:00
@@ -61,6 +61,7 @@
 #include <linux/tty.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
+#include <linux/time.h>
 #include <linux/fb.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -527,8 +528,7 @@
         break;
 	}
 
-	OUTREG8(CLOCK_CNTL_INDEX, 1);
-	ppll_div_sel = INREG8(CLOCK_CNTL_DATA + 1) & 0x3;
+	ppll_div_sel = INREG(CLOCK_CNTL_INDEX + 1) & 0x3;
 
 	n = (INPLL(PPLL_DIV_0 + ppll_div_sel) & 0x7ff);
 	m = (INPLL(PPLL_REF_DIV) & 0x3ff);
@@ -595,53 +595,10 @@
  */
 static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo)
 {
-#ifdef CONFIG_PPC_OF
-	/*
-	 * Retreive PLL infos from Open Firmware first
-	 */
-       	if (!force_measure_pll && radeon_read_xtal_OF(rinfo) == 0) {
-       		printk(KERN_INFO "radeonfb: Retreived PLL infos from Open Firmware\n");
-       		rinfo->pll.ref_div = INPLL(PPLL_REF_DIV) & 0x3ff;
-		/* FIXME: Max clock may be higher on newer chips */
-       		rinfo->pll.ppll_min = 12000;
-       		rinfo->pll.ppll_max = 35000;
-		goto found;
-	}
-#endif /* CONFIG_PPC_OF */
-
-	/*
-	 * Check out if we have an X86 which gave us some PLL informations
-	 * and if yes, retreive them
-	 */
-	if (!force_measure_pll && rinfo->bios_seg) {
-		u16 pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30);
-
-		rinfo->pll.sclk		= BIOS_IN16(pll_info_block + 0x08);
-		rinfo->pll.mclk		= BIOS_IN16(pll_info_block + 0x0a);
-		rinfo->pll.ref_clk	= BIOS_IN16(pll_info_block + 0x0e);
-		rinfo->pll.ref_div	= BIOS_IN16(pll_info_block + 0x10);
-		rinfo->pll.ppll_min	= BIOS_IN32(pll_info_block + 0x12);
-		rinfo->pll.ppll_max	= BIOS_IN32(pll_info_block + 0x16);
-
-		printk(KERN_INFO "radeonfb: Retreived PLL infos from BIOS\n");
-		goto found;
-	}
-
 	/*
-	 * We didn't get PLL parameters from either OF or BIOS, we try to
-	 * probe them
-	 */
-	if (radeon_probe_pll_params(rinfo) == 0) {
-		printk(KERN_INFO "radeonfb: Retreived PLL infos from registers\n");
-		/* FIXME: Max clock may be higher on newer chips */
-       		rinfo->pll.ppll_min = 12000;
-       		rinfo->pll.ppll_max = 35000;
-		goto found;
-	}
-
-	/*
-	 * Neither of the above worked, we have a few default values, though
-	 * that's mostly incomplete
+	 * In the case nothing works, these are defaults; they are mostly
+	 * incomplete, however.  It does provide ppll_max and _min values
+	 * even for most other methods, however.
 	 */
 	switch (rinfo->chipset) {
 	case PCI_DEVICE_ID_ATI_RADEON_QW:
@@ -697,6 +654,47 @@
 	}
 	rinfo->pll.ref_div = INPLL(PPLL_REF_DIV) & 0x3ff;
 
+
+#ifdef CONFIG_PPC_OF
+	/*
+	 * Retreive PLL infos from Open Firmware first
+	 */
+       	if (!force_measure_pll && radeon_read_xtal_OF(rinfo) == 0) {
+       		printk(KERN_INFO "radeonfb: Retreived PLL infos from Open Firmware\n");
+		goto found;
+	}
+#endif /* CONFIG_PPC_OF */
+
+	/*
+	 * Check out if we have an X86 which gave us some PLL informations
+	 * and if yes, retreive them
+	 */
+	if (!force_measure_pll && rinfo->bios_seg) {
+		u16 pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30);
+
+		rinfo->pll.sclk		= BIOS_IN16(pll_info_block + 0x08);
+		rinfo->pll.mclk		= BIOS_IN16(pll_info_block + 0x0a);
+		rinfo->pll.ref_clk	= BIOS_IN16(pll_info_block + 0x0e);
+		rinfo->pll.ref_div	= BIOS_IN16(pll_info_block + 0x10);
+		rinfo->pll.ppll_min	= BIOS_IN32(pll_info_block + 0x12);
+		rinfo->pll.ppll_max	= BIOS_IN32(pll_info_block + 0x16);
+
+		printk(KERN_INFO "radeonfb: Retreived PLL infos from BIOS\n");
+		goto found;
+	}
+
+	/*
+	 * We didn't get PLL parameters from either OF or BIOS, we try to
+	 * probe them
+	 */
+	if (radeon_probe_pll_params(rinfo) == 0) {
+		printk(KERN_INFO "radeonfb: Retreived PLL infos from registers\n");
+		goto found;
+	}
+
+	/*
+	 * Fall back to already-set defaults...
+	 */
        	printk(KERN_INFO "radeonfb: Used default PLL infos\n");
 
 found:
@@ -715,6 +713,7 @@
 	       rinfo->pll.ref_div,
 	       rinfo->pll.mclk / 100, rinfo->pll.mclk % 100,
 	       rinfo->pll.sclk / 100, rinfo->pll.sclk % 100);
+	printk("radeonfb: PLL min %d max %d\n", rinfo->pll.ppll_min, rinfo->pll.ppll_max);
 }
 
 static int radeonfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info)
@@ -934,46 +933,101 @@
 }
 
 
-static int radeon_screen_blank (struct radeonfb_info *rinfo, int blank)
+static int radeon_screen_blank (struct radeonfb_info *rinfo, int blank, int mode_switch)
 {
-        u32 val = INREG(CRTC_EXT_CNTL);
-	u32 val2 = 0;
+        u32 val;
+	u32 tmp_pix_clks;
 
-	if (rinfo->mon1_type == MT_LCD)
-		val2 = INREG(LVDS_GEN_CNTL) & ~LVDS_DISPLAY_DIS;
-	
-        /* reset it */
+	if (rinfo->lock_blank)
+		return 0;
+
+	radeon_engine_idle();
+
+	val = INREG(CRTC_EXT_CNTL);
         val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS |
                  CRTC_VSYNC_DIS);
-
         switch (blank) {
-                case VESA_NO_BLANKING:
-                        break;
-                case VESA_VSYNC_SUSPEND:
-                        val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS);
-                        break;
-                case VESA_HSYNC_SUSPEND:
-                        val |= (CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS);
-                        break;
-                case VESA_POWERDOWN:
-                        val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS | 
-                                CRTC_HSYNC_DIS);
-			val2 |= (LVDS_DISPLAY_DIS);
-                        break;
+	case FB_BLANK_UNBLANK:
+	case FB_BLANK_NORMAL:
+		break;
+	case FB_BLANK_VSYNC_SUSPEND:
+		val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS);
+		break;
+	case FB_BLANK_HSYNC_SUSPEND:
+		val |= (CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS);
+		break;
+	case FB_BLANK_POWERDOWN:
+		val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS |
+			CRTC_HSYNC_DIS);
+		break;
         }
+	OUTREG(CRTC_EXT_CNTL, val);
+
 
-	radeon_fifo_wait(1);
 	switch (rinfo->mon1_type) {
-		case MT_LCD:
-			OUTREG(LVDS_GEN_CNTL, val2);
-			break;
-		case MT_CRT:
-		default:
-		        OUTREG(CRTC_EXT_CNTL, val);
+	case MT_DFP:
+		if (mode_switch)
 			break;
+		if (blank == FB_BLANK_UNBLANK ||
+		    blank == FB_BLANK_NORMAL)
+			OUTREGP(FP_GEN_CNTL, (FP_FPON | FP_TMDS_EN),
+				~(FP_FPON | FP_TMDS_EN));
+		else
+			OUTREGP(FP_GEN_CNTL, 0, ~(FP_FPON | FP_TMDS_EN));
+		break;
+	case MT_LCD:
+		val = INREG(LVDS_GEN_CNTL);
+		if (blank == FB_BLANK_UNBLANK ||
+		    blank == FB_BLANK_NORMAL) {
+			u32 target_val = (val & ~LVDS_DISPLAY_DIS) | LVDS_BLON | LVDS_ON
+				| LVDS_ON | (rinfo->init_state.lvds_gen_cntl & LVDS_DIGON);
+			if ((val ^ target_val) == LVDS_DISPLAY_DIS)
+				OUTREG(LVDS_GEN_CNTL, target_val);
+			else if ((val ^ target_val) != 0) {
+				del_timer_sync(&rinfo->lvds_timer);
+				OUTREG(LVDS_GEN_CNTL, target_val & ~LVDS_ON);
+				rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK;
+				rinfo->init_state.lvds_gen_cntl |= target_val & LVDS_STATE_MASK;
+				if (mode_switch) {
+					msleep(rinfo->panel_info.pwr_delay);
+					OUTREG(LVDS_GEN_CNTL, target_val);
+				}
+				else {
+					rinfo->pending_lvds_gen_cntl = target_val;
+					mod_timer(&rinfo->lvds_timer,
+						jiffies + msecs_to_jiffies(rinfo->panel_info.pwr_delay));
+				}
+			}
+		} else {
+			val |= LVDS_DISPLAY_DIS;
+			OUTREG(LVDS_GEN_CNTL, val);
+
+			/* We don't do a full switch-off on a simple mode switch */
+			if (mode_switch)
+				break;
+
+			/* Asic bug, when turning off LVDS_ON, we have to make sure
+			 * RADEON_PIXCLK_LVDS_ALWAYS_ON bit is off
+			 */
+			tmp_pix_clks = INPLL(PIXCLKS_CNTL);
+			if (rinfo->is_mobility || rinfo->is_IGP)
+				OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb);
+			val &= ~(LVDS_BLON | LVDS_ON);
+			OUTREG(LVDS_GEN_CNTL, val);
+			rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK;
+			rinfo->init_state.lvds_gen_cntl |= val & LVDS_STATE_MASK;
+			if (rinfo->is_mobility || rinfo->is_IGP)
+				OUTPLL(PIXCLKS_CNTL, tmp_pix_clks);
+		}
+		break;
+	case MT_CRT:
+		// todo: powerdown DAC
+	default:
+		break;
 	}
 
-	return 0;
+	/* let fbcon do a soft blank for us */
+	return (blank == FB_BLANK_NORMAL) ? -EINVAL : 0;
 }
 
 int radeonfb_blank (int blank, struct fb_info *info)
@@ -983,17 +1037,7 @@
 	if (rinfo->asleep)
 		return 0;
 		
-#ifdef CONFIG_PMAC_BACKLIGHT
-	if (rinfo->mon1_type == MT_LCD && _machine == _MACH_Pmac && blank)
-		set_backlight_enable(0);
-#endif
-                        
-	radeon_screen_blank(rinfo, blank);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	if (rinfo->mon1_type == MT_LCD && _machine == _MACH_Pmac && !blank)
-		set_backlight_enable(1);
-#endif
+	radeon_screen_blank(rinfo, blank, 0);
 
 	return 0;
 }
@@ -1225,7 +1269,8 @@
 
 	del_timer_sync(&rinfo->lvds_timer);
 
-	radeon_screen_blank(rinfo, VESA_POWERDOWN);
+	radeon_screen_blank(rinfo, FB_BLANK_POWERDOWN, 1);
+	msleep(100);
 
 	radeon_fifo_wait(31);
 	for (i=0; i<10; i++)
@@ -1265,35 +1310,9 @@
 		OUTREG(FP_GEN_CNTL, mode->fp_gen_cntl);
 		OUTREG(TMDS_CRC, mode->tmds_crc);
 		OUTREG(TMDS_TRANSMITTER_CNTL, mode->tmds_transmitter_cntl);
-
-		if (primary_mon == MT_LCD) {
-			unsigned int tmp = INREG(LVDS_GEN_CNTL);
-
-			/* HACK: The backlight control code may have modified init_state.lvds_gen_cntl,
-			 * so we update ourselves
-			 */
-			mode->lvds_gen_cntl &= ~LVDS_STATE_MASK;
-			mode->lvds_gen_cntl |= (rinfo->init_state.lvds_gen_cntl & LVDS_STATE_MASK);
-
-			if ((tmp & (LVDS_ON | LVDS_BLON)) ==
-			    (mode->lvds_gen_cntl & (LVDS_ON | LVDS_BLON))) {
-				OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl);
-			} else {
-				rinfo->pending_pixclks_cntl = INPLL(PIXCLKS_CNTL);
-				if (rinfo->is_mobility || rinfo->is_IGP)
-					OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb);
-				if (!(tmp & (LVDS_ON | LVDS_BLON)))
-					OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl | LVDS_BLON);
-				rinfo->pending_lvds_gen_cntl = mode->lvds_gen_cntl;
-				mod_timer(&rinfo->lvds_timer,
-					  jiffies + MS_TO_HZ(rinfo->panel_info.pwr_delay));
-			}
-		}
 	}
 
-	RTRACE("lvds_gen_cntl: %08x\n", INREG(LVDS_GEN_CNTL));
-
-	radeon_screen_blank(rinfo, VESA_NO_BLANKING);
+	radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 1);
 
 	radeon_fifo_wait(2);
 	OUTPLL(VCLK_ECP_CNTL, mode->vclk_ecp_cntl);
@@ -1329,7 +1348,7 @@
 	 * not sure which model starts having FP2_GEN_CNTL, I assume anything more
 	 * recent than an r(v)100...
 	 */
-#if 0
+#if 1
 	/* XXX I had reports of flicker happening with the cinema display
 	 * on TMDS1 that seem to be fixed if I also forbit odd dividers in
 	 * this case. This could just be a bandwidth calculation issue, I
@@ -1379,6 +1398,8 @@
 		freq = rinfo->pll.ppll_max;
 	if (freq*12 < rinfo->pll.ppll_min)
 		freq = rinfo->pll.ppll_min / 12;
+	RTRACE("freq = %lu, PLL min = %u, PLL max = %u\n",
+	       freq, rinfo->pll.ppll_min, rinfo->pll.ppll_max);
 
 	for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
 		pll_output_freq = post_div->divider * freq;
@@ -1392,6 +1413,16 @@
 			break;
 	}
 
+	/* If we fall through the bottom, try the "default value"
+	   given by the terminal post_div->bitvalue */
+	if ( !post_div->divider ) {
+		post_div = &post_divs[post_div->bitvalue];
+		pll_output_freq = post_div->divider * freq;
+	}
+	RTRACE("ref_div = %d, ref_clk = %d, output_freq = %d\n",
+	       rinfo->pll.ref_div, rinfo->pll.ref_clk,
+	       pll_output_freq);
+
 	fb_div = round_div(rinfo->pll.ref_div*pll_output_freq,
 				  rinfo->pll.ref_clk);
 	regs->ppll_ref_div = rinfo->pll.ref_div;
@@ -1722,7 +1753,6 @@
 {
 	struct fb_info *info = rinfo->info;
 
-	info->currcon = -1;
 	info->par = rinfo;
 	info->pseudo_palette = rinfo->pseudo_palette;
 	info->flags = FBINFO_DEFAULT
@@ -1780,8 +1810,7 @@
 static int radeon_set_backlight_enable(int on, int level, void *data)
 {
 	struct radeonfb_info *rinfo = (struct radeonfb_info *)data;
-	unsigned int lvds_gen_cntl = INREG(LVDS_GEN_CNTL);
-	unsigned long tmpPixclksCntl = INPLL(PIXCLKS_CNTL);
+	u32 lvds_gen_cntl, tmpPixclksCntl;
 	int* conv_table;
 
 	if (rinfo->mon1_type != MT_LCD)
@@ -1803,42 +1832,47 @@
 		conv_table = backlight_conv_m6;
 
 	del_timer_sync(&rinfo->lvds_timer);
+	radeon_engine_idle();
 
-	lvds_gen_cntl |= (LVDS_BL_MOD_EN | LVDS_BLON);
-	radeon_fifo_wait(3);
+	lvds_gen_cntl = INREG(LVDS_GEN_CNTL);
 	if (on && (level > BACKLIGHT_OFF)) {
-		lvds_gen_cntl |= LVDS_DIGON;
-		if (!(lvds_gen_cntl & LVDS_ON)) {
-			lvds_gen_cntl &= ~LVDS_BLON;
+		lvds_gen_cntl &= ~LVDS_DISPLAY_DIS;
+		if (!(lvds_gen_cntl & LVDS_BLON) || !(lvds_gen_cntl & LVDS_ON)) {
+			lvds_gen_cntl |= LVDS_BLON /* | LVDS_EN | LVDS_DIGON */;
 			OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl);
-			(void)INREG(LVDS_GEN_CNTL);
-			mdelay(rinfo->panel_info.pwr_delay);/* OUCH !!! FIXME */
-			lvds_gen_cntl |= LVDS_BLON;
+			lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK;
+			lvds_gen_cntl |= (conv_table[level] <<
+					  LVDS_BL_MOD_LEVEL_SHIFT);
+			lvds_gen_cntl |= LVDS_ON;
+			rinfo->pending_lvds_gen_cntl = lvds_gen_cntl;
+			mod_timer(&rinfo->lvds_timer,
+				  jiffies + msecs_to_jiffies(rinfo->panel_info.pwr_delay));
+		} else {
+			lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK;
+			lvds_gen_cntl |= (conv_table[level] <<
+					  LVDS_BL_MOD_LEVEL_SHIFT);
 			OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl);
 		}
-		lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK;
-		lvds_gen_cntl |= (conv_table[level] <<
-				  LVDS_BL_MOD_LEVEL_SHIFT);
-		lvds_gen_cntl |= (LVDS_ON | LVDS_EN);
-		lvds_gen_cntl &= ~LVDS_DISPLAY_DIS;
+		rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK;
+		rinfo->init_state.lvds_gen_cntl |= rinfo->pending_lvds_gen_cntl
+			& LVDS_STATE_MASK;
 	} else {
 		/* Asic bug, when turning off LVDS_ON, we have to make sure
 		   RADEON_PIXCLK_LVDS_ALWAYS_ON bit is off
 		*/
+		tmpPixclksCntl = INPLL(PIXCLKS_CNTL);
 		if (rinfo->is_mobility || rinfo->is_IGP)
 			OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb);
 		lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK;
 		lvds_gen_cntl |= (conv_table[0] <<
 				  LVDS_BL_MOD_LEVEL_SHIFT);
-		lvds_gen_cntl |= LVDS_DISPLAY_DIS | LVDS_BLON;
+		lvds_gen_cntl |= LVDS_DISPLAY_DIS;
 		OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl);
-		mdelay(rinfo->panel_info.pwr_delay);/* OUCH !!! FIXME */
-		lvds_gen_cntl &= ~(LVDS_ON | LVDS_EN | LVDS_BLON | LVDS_DIGON);
+		lvds_gen_cntl &= ~(LVDS_ON | LVDS_BLON /* | LVDS_EN | LVDS_DIGON */);
+		OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl);
+		if (rinfo->is_mobility || rinfo->is_IGP)
+			OUTPLL(PIXCLKS_CNTL, tmpPixclksCntl);
 	}
-
-	OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl);
-	if (rinfo->is_mobility || rinfo->is_IGP)
-		OUTPLL(PIXCLKS_CNTL, tmpPixclksCntl);
 	rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK;
 	rinfo->init_state.lvds_gen_cntl |= (lvds_gen_cntl & LVDS_STATE_MASK);
 
@@ -2155,7 +2189,9 @@
 	       		rinfo->video_ram = 8192 * 1024;
 	       		break;
 	       	default:
-	       		break;
+			printk (KERN_ERR "radeonfb: no video RAM reported\n");
+			ret = -ENXIO;
+			goto err_unmap_rom;
 		}
 	}
 
diff -Nru a/drivers/video/aty/radeon_monitor.c b/drivers/video/aty/radeon_monitor.c
--- a/drivers/video/aty/radeon_monitor.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/video/aty/radeon_monitor.c	2004-12-24 13:36:16 -08:00
@@ -7,10 +7,25 @@
 #endif /* CONFIG_PPC_OF */
 
 static struct fb_var_screeninfo radeonfb_default_var = {
-        640, 480, 640, 480, 0, 0, 8, 0,
-        {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0},
-        0, 0, -1, -1, 0, 39721, 40, 24, 32, 11, 96, 2,
-        0, FB_VMODE_NONINTERLACED
+	.xres		= 640,
+	.yres		= 480,
+	.xres_virtual	= 640,
+	.yres_virtual	= 480,
+	.bits_per_pixel = 8,
+	.red		= { .length = 8 },
+	.green		= { .length = 8 },
+	.blue		= { .length = 8 },
+	.activate	= FB_ACTIVATE_NOW,
+	.height		= -1,
+	.width		= -1,
+	.pixclock	= 39721,
+	.left_margin	= 40,
+	.right_margin	= 24,
+	.upper_margin	= 32,
+	.lower_margin	= 11,
+	.hsync_len	= 96,
+	.vsync_len	= 2,
+	.vmode		= FB_VMODE_NONINTERLACED
 };
 
 static char *radeon_get_mon_name(int type)
@@ -69,11 +84,12 @@
 		mt = MT_DFP;
 	else if (!strcmp(pmt, "CRT"))
 		mt = MT_CRT;
-	else if (strcmp(pmt, "NONE")) {
-		printk(KERN_WARNING "radeonfb: Unknown OF display-type: %s\n", pmt);
-		return MT_NONE;
-	} else
+	else {
+		if (strcmp(pmt, "NONE") != 0)
+			printk(KERN_WARNING "radeonfb: Unknown OF display-type: %s\n",
+			       pmt);
 		return MT_NONE;
+	}
 
 	for (i = 0; propnames[i] != NULL; ++i) {
 		pedid = (u8 *)get_property(dp, propnames[i], NULL);
@@ -632,43 +648,25 @@
  */
 static void radeon_fixup_panel_info(struct radeonfb_info *rinfo)
 {
+ #ifdef CONFIG_PPC_OF
 	/*
-	 * A few iBook laptop panels seem to need a fixed PLL setting
-	 *
-	 * We should probably do this differently based on the panel
-	 * type/model or eventually some other device-tree informations,
-	 * but these tweaks below work enough for now. --BenH
+	 * LCD Flat panels should use fixed dividers, we enfore that on
+	 * PowerMac only for now...
 	 */
-#ifdef CONFIG_PPC_OF
-	/* iBook2's */
-	if (machine_is_compatible("PowerBook4,3")) {
-		rinfo->panel_info.ref_divider = rinfo->pll.ref_div;
-		rinfo->panel_info.post_divider = 0x6;
-		rinfo->panel_info.fbk_divider = 0xad;
-		rinfo->panel_info.use_bios_dividers = 1;
-	}
-	/* Aluminium PowerBook 15" */
-	if (machine_is_compatible("PowerBook5,4")) {
+	if (!rinfo->panel_info.use_bios_dividers && rinfo->mon1_type == MT_LCD
+	    && rinfo->is_mobility) {
+		int ppll_div_sel = INREG8(CLOCK_CNTL_INDEX + 1) & 0x3;
+		u32 ppll_divn = INPLL(PPLL_DIV_0 + ppll_div_sel);
 		rinfo->panel_info.ref_divider = rinfo->pll.ref_div;
-		rinfo->panel_info.post_divider = 0x2;
-		rinfo->panel_info.fbk_divider = 0x8e;
-		rinfo->panel_info.use_bios_dividers = 1;
-	}
-	/* Aluminium PowerBook 17" */
-	if (machine_is_compatible("PowerBook5,3") ||
-	    machine_is_compatible("PowerBook5,5")) {
-		rinfo->panel_info.ref_divider = rinfo->pll.ref_div;
-		rinfo->panel_info.post_divider = 0x4;
-		rinfo->panel_info.fbk_divider = 0x80;
-		rinfo->panel_info.use_bios_dividers = 1;
-	}
-	/* iBook G4 */
-        if (machine_is_compatible("PowerBook6,3") ||
-            machine_is_compatible("PowerBook6,5")) {
-		rinfo->panel_info.ref_divider = rinfo->pll.ref_div;
-		rinfo->panel_info.post_divider = 0x6;
-		rinfo->panel_info.fbk_divider = 0xad;
+		rinfo->panel_info.fbk_divider = ppll_divn & 0x7ff;
+		rinfo->panel_info.post_divider = (ppll_divn >> 16) & 0x7;
 		rinfo->panel_info.use_bios_dividers = 1;
+
+		printk(KERN_DEBUG "radeonfb: Using Firmware dividers 0x%08x "
+		       "from PPLL %d\n",
+		       rinfo->panel_info.fbk_divider |
+		       (rinfo->panel_info.post_divider << 16),
+		       ppll_div_sel);
 	}
 #endif /* CONFIG_PPC_OF */
 }
diff -Nru a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
--- a/drivers/video/aty/radeon_pm.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/video/aty/radeon_pm.c	2004-12-24 13:37:02 -08:00
@@ -465,7 +465,9 @@
 						
  	OUTPLL( pllPIXCLKS_CNTL, pixclks_cntl);
 
-
+	/* Switch off LVDS interface */
+	OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) &
+	       ~(LVDS_BLON | LVDS_EN | LVDS_ON | LVDS_DIGON));
 
 	/* Enable System power management */
 	pll_pwrmgt_cntl = INPLL( pllPLL_PWRMGT_CNTL);
@@ -896,7 +898,7 @@
 
 	release_console_sem();
 
-	pdev->dev.power_state = state;
+	pdev->dev.power.power_state = state;
 
 	return 0;
 }
@@ -906,7 +908,7 @@
         struct fb_info *info = pci_get_drvdata(pdev);
         struct radeonfb_info *rinfo = info->par;
 
-	if (pdev->dev.power_state == 0)
+	if (pdev->dev.power.power_state == 0)
 		return 0;
 
 	acquire_console_sem();
@@ -933,7 +935,7 @@
 
 	release_console_sem();
 
-	pdev->dev.power_state = 0;
+	pdev->dev.power.power_state = 0;
 
 	printk(KERN_DEBUG "radeonfb: resumed !\n");
 
diff -Nru a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
--- a/drivers/video/aty/radeonfb.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/video/aty/radeonfb.h	2004-12-24 13:37:43 -08:00
@@ -425,8 +425,6 @@
 		spin_unlock_irqrestore(&rinfo->reg_lock, flags); 	\
 	} while (0)
 
-#define MS_TO_HZ(ms)       ((ms * HZ + 999) / 1000)
-
 #define BIOS_IN8(v)  	(readb(rinfo->bios_seg + (v)))
 #define BIOS_IN16(v) 	(readb(rinfo->bios_seg + (v)) | \
 			  (readb(rinfo->bios_seg + (v) + 1) << 8))
diff -Nru a/drivers/video/aty/xlinit.c b/drivers/video/aty/xlinit.c
--- a/drivers/video/aty/xlinit.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/video/aty/xlinit.c	2004-12-24 13:36:48 -08:00
@@ -148,15 +148,15 @@
 static void init_dll(struct atyfb_par *par)
 {
 	// enable DLL
-	aty_st_pll(PLL_GEN_CNTL,
-		   aty_ld_pll(PLL_GEN_CNTL, par) & 0x7f,
+	aty_st_pll_ct(PLL_GEN_CNTL,
+		   aty_ld_pll_ct(PLL_GEN_CNTL, par) & 0x7f,
 		   par);
 
 	// reset DLL
-	aty_st_pll(DLL_CNTL, 0x82, par);
-	aty_st_pll(DLL_CNTL, 0xE2, par);
+	aty_st_pll_ct(DLL_CNTL, 0x82, par);
+	aty_st_pll_ct(DLL_CNTL, 0xE2, par);
 	mdelay(5);
-	aty_st_pll(DLL_CNTL, 0x82, par);
+	aty_st_pll_ct(DLL_CNTL, 0x82, par);
 	mdelay(6);
 }
 
@@ -164,8 +164,8 @@
 			 int hsync_enb)
 {
 	reset_gui(par);
-	aty_st_pll(MCLK_FB_DIV, pll->mclk_fb_div, par);
-	aty_st_pll(SCLK_FB_DIV, pll->sclk_fb_div, par);
+	aty_st_pll_ct(MCLK_FB_DIV, pll->mclk_fb_div, par);
+	aty_st_pll_ct(SCLK_FB_DIV, pll->sclk_fb_div, par);
 
 	mdelay(15);
 	init_dll(par);
@@ -177,9 +177,9 @@
 	aty_st_8(CRTC_GEN_CNTL+3,
 		 hsync_enb ? 0x00 : 0x04, par);
 
-	aty_st_pll(SPLL_CNTL2, pll->spll_cntl2, par);
-	aty_st_pll(PLL_GEN_CNTL, pll->pll_gen_cntl, par);
-	aty_st_pll(PLL_VCLK_CNTL, pll->pll_vclk_cntl, par);
+	aty_st_pll_ct(SPLL_CNTL2, pll->spll_cntl2, par);
+	aty_st_pll_ct(PLL_GEN_CNTL, pll->pll_gen_cntl, par);
+	aty_st_pll_ct(PLL_VCLK_CNTL, pll->pll_vclk_cntl, par);
 }
 
 int atyfb_xl_init(struct fb_info *info)
@@ -216,31 +216,31 @@
 	if ((err = aty_pll_ct.var_to_pll(info, 39726, 8, &pll)))
 		return err;
 
-	aty_st_pll(LVDS_CNTL0, 0x00, par);
-	aty_st_pll(DLL2_CNTL, card->dll2_cntl, par);
-	aty_st_pll(V2PLL_CNTL, 0x10, par);
-	aty_st_pll(MPLL_CNTL, MPLL_GAIN, par);
-	aty_st_pll(VPLL_CNTL, VPLL_GAIN, par);
-	aty_st_pll(PLL_VCLK_CNTL, 0x00, par);
-	aty_st_pll(VFC_CNTL, 0x1B, par);
-	aty_st_pll(PLL_REF_DIV, pll.ct.pll_ref_div, par);
-	aty_st_pll(PLL_EXT_CNTL, pll.ct.pll_ext_cntl, par);
-	aty_st_pll(SPLL_CNTL2, 0x03, par);
-	aty_st_pll(PLL_GEN_CNTL, 0x44, par);
+	aty_st_pll_ct(LVDS_CNTL0, 0x00, par);
+	aty_st_pll_ct(DLL2_CNTL, card->dll2_cntl, par);
+	aty_st_pll_ct(V2PLL_CNTL, 0x10, par);
+	aty_st_pll_ct(MPLL_CNTL, MPLL_GAIN, par);
+	aty_st_pll_ct(VPLL_CNTL, VPLL_GAIN, par);
+	aty_st_pll_ct(PLL_VCLK_CNTL, 0x00, par);
+	aty_st_pll_ct(VFC_CNTL, 0x1B, par);
+	aty_st_pll_ct(PLL_REF_DIV, pll.ct.pll_ref_div, par);
+	aty_st_pll_ct(PLL_EXT_CNTL, pll.ct.pll_ext_cntl, par);
+	aty_st_pll_ct(SPLL_CNTL2, 0x03, par);
+	aty_st_pll_ct(PLL_GEN_CNTL, 0x44, par);
 
 	reset_clocks(par, &pll.ct, 0);
 	mdelay(10);
 
-	aty_st_pll(VCLK_POST_DIV, 0x03, par);
-	aty_st_pll(VCLK0_FB_DIV, 0xDA, par);
-	aty_st_pll(VCLK_POST_DIV, 0x0F, par);
-	aty_st_pll(VCLK1_FB_DIV, 0xF5, par);
-	aty_st_pll(VCLK_POST_DIV, 0x3F, par);
-	aty_st_pll(PLL_EXT_CNTL, 0x40 | pll.ct.pll_ext_cntl, par);
-	aty_st_pll(VCLK2_FB_DIV, 0x00, par);
-	aty_st_pll(VCLK_POST_DIV, 0xFF, par);
-	aty_st_pll(PLL_EXT_CNTL, 0xC0 | pll.ct.pll_ext_cntl, par);
-	aty_st_pll(VCLK3_FB_DIV, 0x00, par);
+	aty_st_pll_ct(VCLK_POST_DIV, 0x03, par);
+	aty_st_pll_ct(VCLK0_FB_DIV, 0xDA, par);
+	aty_st_pll_ct(VCLK_POST_DIV, 0x0F, par);
+	aty_st_pll_ct(VCLK1_FB_DIV, 0xF5, par);
+	aty_st_pll_ct(VCLK_POST_DIV, 0x3F, par);
+	aty_st_pll_ct(PLL_EXT_CNTL, 0x40 | pll.ct.pll_ext_cntl, par);
+	aty_st_pll_ct(VCLK2_FB_DIV, 0x00, par);
+	aty_st_pll_ct(VCLK_POST_DIV, 0xFF, par);
+	aty_st_pll_ct(PLL_EXT_CNTL, 0xC0 | pll.ct.pll_ext_cntl, par);
+	aty_st_pll_ct(VCLK3_FB_DIV, 0x00, par);
 
 	aty_st_8(BUS_CNTL, 0x01, par);
 	aty_st_le32(BUS_CNTL, card->bus_cntl | 0x08000000, par);
@@ -295,7 +295,7 @@
 	aty_st_8(CRTC_GEN_CNTL+3, 0x04, par);
 	mdelay(10);
 
-	aty_st_pll(PLL_YCLK_CNTL, 0x25, par);
+	aty_st_pll_ct(PLL_YCLK_CNTL, 0x25, par);
 
 	aty_st_le16(CUSTOM_MACRO_CNTL, 0x0179, par);
 	aty_st_le16(CUSTOM_MACRO_CNTL+2, 0x005E, par);
@@ -309,9 +309,9 @@
 
 	aty_st_8(CONFIG_STAT0, 0xA0 | card->mem_type, par);
 
-	aty_st_pll(PLL_YCLK_CNTL, 0x01, par);
+	aty_st_pll_ct(PLL_YCLK_CNTL, 0x01, par);
 	mdelay(15);
-	aty_st_pll(PLL_YCLK_CNTL, card->pll_yclk_cntl, par);
+	aty_st_pll_ct(PLL_YCLK_CNTL, card->pll_yclk_cntl, par);
 	mdelay(1);
 	
 	reset_clocks(par, &pll.ct, 0);
diff -Nru a/drivers/video/bw2.c b/drivers/video/bw2.c
--- a/drivers/video/bw2.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/video/bw2.c	2004-12-24 13:37:00 -08:00
@@ -110,7 +110,7 @@
 
 struct bw2_par {
 	spinlock_t		lock;
-	struct bw2_regs		*regs;
+	struct bw2_regs		__iomem *regs;
 
 	u32			flags;
 #define BW2_FLAG_BLANKED	0x00000001
@@ -131,24 +131,24 @@
 bw2_blank(int blank, struct fb_info *info)
 {
 	struct bw2_par *par = (struct bw2_par *) info->par;
-	struct bw2_regs *regs = par->regs;
+	struct bw2_regs __iomem *regs = par->regs;
 	unsigned long flags;
 	u8 val;
 
 	spin_lock_irqsave(&par->lock, flags);
 
 	switch (blank) {
-	case 0: /* Unblanking */
+	case FB_BLANK_UNBLANK: /* Unblanking */
 		val = sbus_readb(&regs->control);
 		val |= BWTWO_CTL_ENABLE_VIDEO;
 		sbus_writeb(val, &regs->control);
 		par->flags &= ~BW2_FLAG_BLANKED;
 		break;
 
-	case 1: /* Normal blanking */
-	case 2: /* VESA blank (vsync off) */
-	case 3: /* VESA blank (hsync off) */
-	case 4: /* Poweroff */
+	case FB_BLANK_NORMAL: /* Normal blanking */
+	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
+	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
+	case FB_BLANK_POWERDOWN: /* Poweroff */
 		val = sbus_readb(&regs->control);
 		val &= ~BWTWO_CTL_ENABLE_VIDEO;
 		sbus_writeb(val, &regs->control);
@@ -281,7 +281,7 @@
 		prom_halt();
 	}
 	for ( ; *p; p += 2) {
-		u8 *regp = &((u8 *)par->regs)[p[0]];
+		u8 __iomem *regp = &((u8 __iomem *)par->regs)[p[0]];
 		sbus_writeb(p[1], regp);
 	}
 }
@@ -342,8 +342,7 @@
 	all->info.var.red.offset = all->info.var.green.offset =
 		all->info.var.blue.offset = 0;
 
-	all->par.regs = (struct bw2_regs *)
-		sbus_ioremap(resp, BWTWO_REGISTER_OFFSET,
+	all->par.regs = sbus_ioremap(resp, BWTWO_REGISTER_OFFSET,
 			     sizeof(struct bw2_regs), "bw2 regs");
 
 	if (sdev && !prom_getbool(sdev->prom_node, "width"))
@@ -355,13 +354,12 @@
 	all->info.fbops = &bw2_ops;
 #if defined(CONFIG_SPARC32)
 	if (sdev)
-		all->info.screen_base = (char *)
+		all->info.screen_base = (char __iomem *)
 			prom_getintdefault(sdev->prom_node, "address", 0);
 #endif
 	if (!all->info.screen_base)
-		all->info.screen_base = (char *)
+		all->info.screen_base =
 			sbus_ioremap(resp, 0, all->par.fbsize, "bw2 ram");
-	all->info.currcon = -1;
 	all->info.par = &all->par;
 
 	bw2_blank(0, &all->info);
@@ -386,7 +384,7 @@
 	struct sbus_bus *sbus;
 	struct sbus_dev *sdev;
 
-	if (fb_get_options("bw2fb", &option))
+	if (fb_get_options("bw2fb", NULL))
 		return -ENODEV;
 
 #ifdef CONFIG_SUN4
diff -Nru a/drivers/video/cg14.c b/drivers/video/cg14.c
--- a/drivers/video/cg14.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/video/cg14.c	2004-12-24 13:37:29 -08:00
@@ -188,9 +188,9 @@
 
 struct cg14_par {
 	spinlock_t		lock;
-	struct cg14_regs	*regs;
-	struct cg14_clut	*clut;
-	struct cg14_cursor	*cursor;
+	struct cg14_regs	__iomem *regs;
+	struct cg14_clut	__iomem *clut;
+	struct cg14_cursor	__iomem *cursor;
 
 	u32			flags;
 #define CG14_FLAG_BLANKED	0x00000001
@@ -209,7 +209,7 @@
 
 static void __cg14_reset(struct cg14_par *par)
 {
-	struct cg14_regs *regs = par->regs;
+	struct cg14_regs __iomem *regs = par->regs;
 	u8 val;
 
 	val = sbus_readb(&regs->mcr);
@@ -248,13 +248,16 @@
 			  unsigned transp, struct fb_info *info)
 {
 	struct cg14_par *par = (struct cg14_par *) info->par;
-	struct cg14_clut *clut = par->clut;
+	struct cg14_clut __iomem *clut = par->clut;
 	unsigned long flags;
 	u32 val;
 
 	if (regno >= 256)
 		return 1;
 
+	red >>= 8;
+	green >>= 8;
+	blue >>= 8;
 	val = (red | (green << 8) | (blue << 16));
 
 	spin_lock_irqsave(&par->lock, flags);
@@ -277,7 +280,7 @@
 		      unsigned long arg, struct fb_info *info)
 {
 	struct cg14_par *par = (struct cg14_par *) info->par;
-	struct cg14_regs *regs = par->regs;
+	struct cg14_regs __iomem *regs = par->regs;
 	struct mdi_cfginfo kmdi, __user *mdii;
 	unsigned long flags;
 	int cur_mode, mode, ret = 0;
@@ -322,7 +325,8 @@
 			break;
 
 		case MDI_16_PIX:
-			cur_mode |= 0x20;
+			cur_mode |= (CG14_MCR_PIXMODE_16 <<
+				     CG14_MCR_PIXMODE_SHIFT);
 			break;
 
 		case MDI_8_PIX:
@@ -341,7 +345,7 @@
 
 	default:
 		ret = sbusfb_ioctl_helper(cmd, arg, info,
-					  FBTYPE_MDICOLOR, 24, par->fbsize);
+					  FBTYPE_MDICOLOR, 8, par->fbsize);
 		break;
 	};
 
@@ -355,11 +359,16 @@
 static void cg14_init_fix(struct fb_info *info, int linebytes)
 {
 	struct cg14_par *par = (struct cg14_par *)info->par;
+	const char *name;
+
+	name = "cgfourteen";
+	if (par->sdev)
+		name = par->sdev->prom_name;
 
-	strlcpy(info->fix.id, par->sdev->prom_name, sizeof(info->fix.id));
+	strlcpy(info->fix.id, name, sizeof(info->fix.id));
 
 	info->fix.type = FB_TYPE_PACKED_PIXELS;
-	info->fix.visual = FB_VISUAL_TRUECOLOR;
+	info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
 
 	info->fix.line_length = linebytes;
 
@@ -484,8 +493,11 @@
 	spin_lock_init(&all->par.lock);
 
 	sbusfb_fill_var(&all->info.var, node, 8);
+	all->info.var.red.length = 8;
+	all->info.var.green.length = 8;
+	all->info.var.blue.length = 8;
 
-	linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
+	linebytes = prom_getintdefault(node, "linebytes",
 				       all->info.var.xres);
 	all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
 
@@ -495,33 +507,29 @@
 		all->par.physbase = phys = sdev->reg_addrs[1].phys_addr;
 		all->par.iospace = sdev->reg_addrs[0].which_io;
 
-		all->par.regs = (struct cg14_regs *)
-			sbus_ioremap(&sdev->resource[0], 0,
+		all->par.regs = sbus_ioremap(&sdev->resource[0], 0,
 				     sizeof(struct cg14_regs),
 				     "cg14 regs");
-		all->par.clut = (struct cg14_clut *)
-			sbus_ioremap(&sdev->resource[0], CG14_CLUT1,
+		all->par.clut = sbus_ioremap(&sdev->resource[0], CG14_CLUT1,
 				     sizeof(struct cg14_clut),
 				     "cg14 clut");
-		all->par.cursor = (struct cg14_cursor *)
-			sbus_ioremap(&sdev->resource[0], CG14_CURSORREGS,
+		all->par.cursor = sbus_ioremap(&sdev->resource[0], CG14_CURSORREGS,
 				     sizeof(struct cg14_cursor),
 				     "cg14 cursor");
-		all->info.screen_base = (char *)
-			sbus_ioremap(&sdev->resource[1], 0,
+		all->info.screen_base = sbus_ioremap(&sdev->resource[1], 0,
 				     all->par.fbsize, "cg14 ram");
 	} else {
 		rphys = __get_phys(bases[0]);
 		all->par.physbase = phys = __get_phys(bases[1]);
 		all->par.iospace = __get_iospace(bases[0]);
-		all->par.regs = (struct cg14_regs *)(unsigned long)bases[0];
-		all->par.clut = (struct cg14_clut *)((unsigned long)bases[0] +
+		all->par.regs = (struct cg14_regs __iomem *)(unsigned long)bases[0];
+		all->par.clut = (struct cg14_clut __iomem *)((unsigned long)bases[0] +
 						     CG14_CLUT1);
 		all->par.cursor =
-			(struct cg14_cursor *)((unsigned long)bases[0] +
+			(struct cg14_cursor __iomem *)((unsigned long)bases[0] +
 					       CG14_CURSORREGS);
 
-		all->info.screen_base = (char *)(unsigned long)bases[1];
+		all->info.screen_base = (char __iomem *)(unsigned long)bases[1];
 	}
 
 	prom_getproperty(node, "reg", (char *) &bases[0], sizeof(bases));
@@ -552,7 +560,6 @@
 
 	all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
 	all->info.fbops = &cg14_ops;
-	all->info.currcon = -1;
 	all->info.par = &all->par;
 
 	__cg14_reset(&all->par);
@@ -562,6 +569,7 @@
 		kfree(all);
 		return;
 	}
+	fb_set_cmap(&all->info.cmap, &all->info);
 
 	cg14_init_fix(&all->info, linebytes);
 
@@ -574,8 +582,8 @@
 
 	list_add(&all->list, &cg14_list);
 
-	printk("cg14: cgfourteen at %lx:%lx\n",
-	       all->par.physbase, all->par.iospace);
+	printk("cg14: cgfourteen at %lx:%lx, %dMB\n",
+	       all->par.iospace, all->par.physbase, all->par.ramsize >> 20);
 
 }
 
diff -Nru a/drivers/video/cg3.c b/drivers/video/cg3.c
--- a/drivers/video/cg3.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/video/cg3.c	2004-12-24 13:37:00 -08:00
@@ -111,7 +111,7 @@
 
 struct cg3_par {
 	spinlock_t		lock;
-	struct cg3_regs		*regs;
+	struct cg3_regs		__iomem *regs;
 	u32			sw_cmap[((256 * 3) + 3) / 4];
 
 	u32			flags;
@@ -144,7 +144,7 @@
 			 unsigned transp, struct fb_info *info)
 {
 	struct cg3_par *par = (struct cg3_par *) info->par;
-	struct bt_regs *bt = &par->regs->cmap;
+	struct bt_regs __iomem *bt = &par->regs->cmap;
 	unsigned long flags;
 	u32 *p32;
 	u8 *p8;
@@ -190,27 +190,27 @@
 cg3_blank(int blank, struct fb_info *info)
 {
 	struct cg3_par *par = (struct cg3_par *) info->par;
-	struct cg3_regs *regs = par->regs;
+	struct cg3_regs __iomem *regs = par->regs;
 	unsigned long flags;
 	u8 val;
 
 	spin_lock_irqsave(&par->lock, flags);
 
 	switch (blank) {
-	case 0: /* Unblanking */
-		val = sbus_readl(&regs->control);
+	case FB_BLANK_UNBLANK: /* Unblanking */
+		val = sbus_readb(&regs->control);
 		val |= CG3_CR_ENABLE_VIDEO;
-		sbus_writel(val, &regs->control);
+		sbus_writeb(val, &regs->control);
 		par->flags &= ~CG3_FLAG_BLANKED;
 		break;
 
-	case 1: /* Normal blanking */
-	case 2: /* VESA blank (vsync off) */
-	case 3: /* VESA blank (hsync off) */
-	case 4: /* Poweroff */
-		val = sbus_readl(&regs->control);
+	case FB_BLANK_NORMAL: /* Normal blanking */
+	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
+	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
+	case FB_BLANK_POWERDOWN: /* Poweroff */
+		val = sbus_readb(&regs->control);
 		val |= CG3_CR_ENABLE_VIDEO;
-		sbus_writel(val, &regs->control);
+		sbus_writeb(val, &regs->control);
 		par->flags |= CG3_FLAG_BLANKED;
 		break;
 	}
@@ -345,15 +345,15 @@
 	}
 
 	for (p = cg3_regvals[type]; *p; p += 2) {
-		u8 *regp = &((u8 *)par->regs)[p[0]];
+		u8 __iomem *regp = &((u8 __iomem *)par->regs)[p[0]];
 		sbus_writeb(p[1], regp);
 	}
 	for (p = cg3_dacvals; *p; p += 2) {
-		volatile u8 *regp;
+		volatile u8 __iomem *regp;
 
-		regp = (volatile u8 *)&par->regs->cmap.addr;
+		regp = (volatile u8 __iomem *)&par->regs->cmap.addr;
 		sbus_writeb(p[0], regp);
-		regp = (volatile u8 *)&par->regs->cmap.control;
+		regp = (volatile u8 __iomem *)&par->regs->cmap.control;
 		sbus_writeb(p[1], regp);
 	}
 }
@@ -394,21 +394,19 @@
 				       all->info.var.xres);
 	all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
 
-	all->par.regs = (struct cg3_regs *)
-		sbus_ioremap(&sdev->resource[0], CG3_REGS_OFFSET,
+	all->par.regs = sbus_ioremap(&sdev->resource[0], CG3_REGS_OFFSET,
 			     sizeof(struct cg3_regs), "cg3 regs");
 
 	all->info.flags = FBINFO_DEFAULT;
 	all->info.fbops = &cg3_ops;
 #ifdef CONFIG_SPARC32
-	all->info.screen_base = (char *)
+	all->info.screen_base = (char __iomem *)
 		prom_getintdefault(sdev->prom_node, "address", 0);
 #endif
 	if (!all->info.screen_base)
-		all->info.screen_base = (char *)
+		all->info.screen_base =
 			sbus_ioremap(&sdev->resource[0], CG3_RAM_OFFSET,
 				     all->par.fbsize, "cg3 ram");
-	all->info.currcon = -1;
 	all->info.par = &all->par;
 
 	cg3_blank(0, &all->info);
diff -Nru a/drivers/video/cg6.c b/drivers/video/cg6.c
--- a/drivers/video/cg6.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/video/cg6.c	2004-12-24 13:36:31 -08:00
@@ -250,11 +250,11 @@
 
 struct cg6_par {
 	spinlock_t		lock;
-	struct bt_regs		*bt;
-	struct cg6_fbc		*fbc;
-	struct cg6_thc		*thc;
-	struct cg6_tec		*tec;
-	volatile u32		*fhc;
+	struct bt_regs		__iomem *bt;
+	struct cg6_fbc		__iomem *fbc;
+	struct cg6_thc		__iomem *thc;
+	struct cg6_tec		__iomem *tec;
+	volatile u32		__iomem *fhc;
 
 	u32			flags;
 #define CG6_FLAG_BLANKED	0x00000001
@@ -269,7 +269,7 @@
 static int cg6_sync(struct fb_info *info)
 {
 	struct cg6_par *par = (struct cg6_par *) info->par;
-	struct cg6_fbc *fbc = par->fbc;
+	struct cg6_fbc __iomem *fbc = par->fbc;
 	int limit = 10000;
 
 	do {
@@ -292,7 +292,7 @@
 static void cg6_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 {
 	struct cg6_par *par = (struct cg6_par *) info->par;
-	struct cg6_fbc *fbc = par->fbc;
+	struct cg6_fbc __iomem *fbc = par->fbc;
 	unsigned long flags;
 	s32 val;
 
@@ -327,7 +327,7 @@
 static void cg6_imageblit(struct fb_info *info, const struct fb_image *image)
 {
 	struct cg6_par *par = (struct cg6_par *) info->par;
-	struct cg6_fbc *fbc = par->fbc;
+	struct cg6_fbc __iomem *fbc = par->fbc;
 	const u8 *data = image->data;
 	unsigned long flags;
 	u32 x, y;
@@ -418,7 +418,7 @@
 			 unsigned transp, struct fb_info *info)
 {
 	struct cg6_par *par = (struct cg6_par *) info->par;
-	struct bt_regs *bt = par->bt;
+	struct bt_regs __iomem *bt = par->bt;
 	unsigned long flags;
 
 	if (regno >= 256)
@@ -449,24 +449,24 @@
 cg6_blank(int blank, struct fb_info *info)
 {
 	struct cg6_par *par = (struct cg6_par *) info->par;
-	struct cg6_thc *thc = par->thc;
+	struct cg6_thc __iomem *thc = par->thc;
 	unsigned long flags;
 	u32 val;
 
 	spin_lock_irqsave(&par->lock, flags);
 
 	switch (blank) {
-	case 0: /* Unblanking */
+	case FB_BLANK_UNBLANK: /* Unblanking */
 		val = sbus_readl(&thc->thc_misc);
 		val |= CG6_THC_MISC_VIDEO;
 		sbus_writel(val, &thc->thc_misc);
 		par->flags &= ~CG6_FLAG_BLANKED;
 		break;
 
-	case 1: /* Normal blanking */
-	case 2: /* VESA blank (vsync off) */
-	case 3: /* VESA blank (hsync off) */
-	case 4: /* Poweroff */
+	case FB_BLANK_NORMAL: /* Normal blanking */
+	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
+	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
+	case FB_BLANK_POWERDOWN: /* Poweroff */
 		val = sbus_readl(&thc->thc_misc);
 		val &= ~CG6_THC_MISC_VIDEO;
 		sbus_writel(val, &thc->thc_misc);
@@ -593,7 +593,7 @@
 /* Initialize Brooktree DAC */
 static void cg6_bt_init(struct cg6_par *par)
 {
-	struct bt_regs *bt = par->bt;
+	struct bt_regs __iomem *bt = par->bt;
 
 	sbus_writel(0x04 << 24, &bt->addr);         /* color planes */
 	sbus_writel(0xff << 24, &bt->control);
@@ -608,8 +608,8 @@
 static void cg6_chip_init(struct fb_info *info)
 {
 	struct cg6_par *par = (struct cg6_par *) info->par;
-	struct cg6_tec *tec = par->tec;
-	struct cg6_fbc *fbc = par->fbc;
+	struct cg6_tec __iomem *tec = par->tec;
+	struct cg6_fbc __iomem *fbc = par->fbc;
 	u32 rev, conf, mode, tmp;
 	int i;
 	
@@ -696,34 +696,28 @@
 	if (prom_getbool(sdev->prom_node, "dblbuf"))
 		all->par.fbsize *= 4;
 
-	all->par.fbc = (struct cg6_fbc *)
-		sbus_ioremap(&sdev->resource[0], CG6_FBC_OFFSET,
+	all->par.fbc = sbus_ioremap(&sdev->resource[0], CG6_FBC_OFFSET,
 			     4096, "cgsix fbc");
-	all->par.tec = (struct cg6_tec *)
-		sbus_ioremap(&sdev->resource[0], CG6_TEC_OFFSET,
+	all->par.tec = sbus_ioremap(&sdev->resource[0], CG6_TEC_OFFSET,
 			     sizeof(struct cg6_tec), "cgsix tec");
-	all->par.thc = (struct cg6_thc *)
-		sbus_ioremap(&sdev->resource[0], CG6_THC_OFFSET,
+	all->par.thc = sbus_ioremap(&sdev->resource[0], CG6_THC_OFFSET,
 			     sizeof(struct cg6_thc), "cgsix thc");
-	all->par.bt = (struct bt_regs *)
-		sbus_ioremap(&sdev->resource[0], CG6_BROOKTREE_OFFSET,
+	all->par.bt = sbus_ioremap(&sdev->resource[0], CG6_BROOKTREE_OFFSET,
 			     sizeof(struct bt_regs), "cgsix dac");
-	all->par.fhc = (u32 *)
-		sbus_ioremap(&sdev->resource[0], CG6_FHC_OFFSET,
+	all->par.fhc = sbus_ioremap(&sdev->resource[0], CG6_FHC_OFFSET,
 			     sizeof(u32), "cgsix fhc");
 
 	all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_IMAGEBLIT |
                           FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT;
 	all->info.fbops = &cg6_ops;
 #ifdef CONFIG_SPARC32
-	all->info.screen_base = (char *)
+	all->info.screen_base = (char __iomem *)
 		prom_getintdefault(sdev->prom_node, "address", 0);
 #endif
 	if (!all->info.screen_base)
-		all->info.screen_base = (char *)
+		all->info.screen_base = 
 			sbus_ioremap(&sdev->resource[0], CG6_RAM_OFFSET,
 				     all->par.fbsize, "cgsix ram");
-	all->info.currcon = -1;
 	all->info.par = &all->par;
 
 	all->info.var.accel_flags = FB_ACCELF_TEXT;
diff -Nru a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
--- a/drivers/video/chipsfb.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/video/chipsfb.c	2004-12-24 13:36:48 -08:00
@@ -416,7 +416,7 @@
 		release_mem_region(addr, size);
 		return -ENOMEM;
 	}
-
+	p->device = &dp->dev;
 	init_chips(p, addr);
 
 #ifdef CONFIG_PMAC_PBOOK
diff -Nru a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
--- a/drivers/video/cirrusfb.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/video/cirrusfb.c	2004-12-24 13:37:19 -08:00
@@ -391,9 +391,9 @@
 struct cirrusfb_info {
 	struct fb_info *info;
 
-	caddr_t fbmem;
-	caddr_t regbase;
-	caddr_t mem;
+	u8 __iomem *fbmem;
+	u8 __iomem *regbase;
+	u8 __iomem *mem;
 	unsigned long size;
 	cirrusfb_board_t btype;
 	unsigned char SFR;	/* Shadow of special function register */
@@ -571,13 +571,13 @@
 		   unsigned char *green,
 		   unsigned char *blue);
 #endif
-static void cirrusfb_WaitBLT (caddr_t regbase);
-static void cirrusfb_BitBLT (caddr_t regbase, int bits_per_pixel,
+static void cirrusfb_WaitBLT (u8 __iomem *regbase);
+static void cirrusfb_BitBLT (u8 __iomem *regbase, int bits_per_pixel,
 			     u_short curx, u_short cury,
 			     u_short destx, u_short desty,
 			     u_short width, u_short height,
 			     u_short line_length);
-static void cirrusfb_RectFill (caddr_t regbase, int bits_per_pixel,
+static void cirrusfb_RectFill (u8 __iomem *regbase, int bits_per_pixel,
 			       u_short x, u_short y,
 			       u_short width, u_short height,
 			       u_char color, u_short line_length);
@@ -1016,7 +1016,7 @@
 	struct cirrusfb_info *cinfo = info->par;
 	struct fb_var_screeninfo *var = &info->var;
 	struct cirrusfb_regs regs;
-	caddr_t regbase = cinfo->regbase;
+	u8 __iomem *regbase = cinfo->regbase;
 	unsigned char tmp;
 	int offset = 0, err;
 	const struct cirrusfb_board_info_rec *bi;
@@ -1727,7 +1727,8 @@
 	}
 
 	/* Undo current */
-	if (current_mode != VESA_NO_BLANKING) {
+	if (current_mode == FB_BLANK_NORMAL ||
+	    current_mode == FB_BLANK_UNBLANK) {
 		/* unblank the screen */
 		val = vga_rseq (cinfo->regbase, VGA_SEQ_CLOCK_MODE);
 		vga_wseq (cinfo->regbase, VGA_SEQ_CLOCK_MODE, val & 0xdf);	/* clear "FullBandwidth" bit */
@@ -1736,22 +1737,23 @@
 	}
 
 	/* set new */
-	if(blank_mode != VESA_NO_BLANKING) {
+	if(blank_mode > FB_BLANK_NORMAL) {
 		/* blank the screen */
 		val = vga_rseq (cinfo->regbase, VGA_SEQ_CLOCK_MODE);
 		vga_wseq (cinfo->regbase, VGA_SEQ_CLOCK_MODE, val | 0x20);	/* set "FullBandwidth" bit */
 	}
 
 	switch (blank_mode) {
-	case VESA_NO_BLANKING:
+	case FB_BLANK_UNBLANK:
+	case FB_BLANK_NORMAL:
 		break;
-	case VESA_VSYNC_SUSPEND:
+	case FB_BLANK_VSYNC_SUSPEND:
 		vga_wgfx (cinfo->regbase, CL_GRE, 0x04);
 		break;
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		vga_wgfx (cinfo->regbase, CL_GRE, 0x02);
 		break;
-	case VESA_POWERDOWN:
+	case FB_BLANK_POWERDOWN:
 		vga_wgfx (cinfo->regbase, CL_GRE, 0x06);
 		break;
 	default:
@@ -1761,7 +1763,9 @@
 
 	cinfo->blank_mode = blank_mode;
 	DPRINTK ("EXIT, returning 0\n");
-	return 0;
+
+	/* Let fbcon do a soft blank for us */
+	return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0;
 }
 /**** END   Hardware specific Routines **************************************/
 /****************************************************************************/
@@ -2149,7 +2153,7 @@
  * based on the DRAM bandwidth bit and DRAM bank switching bit.  This
  * works with 1MB, 2MB and 4MB configurations (which the Motorola boards
  * seem to have. */
-static unsigned int cirrusfb_get_memsize (caddr_t regbase)
+static unsigned int cirrusfb_get_memsize (u8 __iomem *regbase)
 {
 	unsigned long mem;
 	unsigned char SRF;
@@ -2246,7 +2250,6 @@
 	struct fb_info *info = cinfo->info;
 	struct fb_var_screeninfo *var = &info->var;
 
-	info->currcon = -1;
 	info->par = cinfo;
 	info->pseudo_palette = cinfo->pseudo_palette;
 	info->flags = FBINFO_DEFAULT
@@ -2394,7 +2397,7 @@
 		get_prep_addrs (&board_addr, &cinfo->fbregs_phys);
 #endif
 		/* PReP dies if we ioremap the IO registers, but it works w/out... */
-		cinfo->regbase = (char *) cinfo->fbregs_phys;
+		cinfo->regbase = (char __iomem *) cinfo->fbregs_phys;
 	} else {
 		DPRINTK ("Attempt to get PCI info for Cirrus Graphics Card\n");
 		get_pci_addrs (pdev, &board_addr, &cinfo->fbregs_phys);
@@ -2865,7 +2868,7 @@
 *********************************************************************/
 
 /* FIXME: use interrupts instead */
-static void cirrusfb_WaitBLT (caddr_t regbase)
+static void cirrusfb_WaitBLT (u8 __iomem *regbase)
 {
 	/* now busy-wait until we're done */
 	while (vga_rgfx (regbase, CL_GR31) & 0x08)
@@ -2878,7 +2881,7 @@
 	perform accelerated "scrolling"
 ********************************************************************/
 
-static void cirrusfb_BitBLT (caddr_t regbase, int bits_per_pixel,
+static void cirrusfb_BitBLT (u8 __iomem *regbase, int bits_per_pixel,
 			     u_short curx, u_short cury, u_short destx, u_short desty,
 			     u_short width, u_short height, u_short line_length)
 {
@@ -2969,7 +2972,7 @@
 	perform accelerated rectangle fill
 ********************************************************************/
 
-static void cirrusfb_RectFill (caddr_t regbase, int bits_per_pixel,
+static void cirrusfb_RectFill (u8 __iomem *regbase, int bits_per_pixel,
 		     u_short x, u_short y, u_short width, u_short height,
 		     u_char color, u_short line_length)
 {
diff -Nru a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
--- a/drivers/video/console/Kconfig	2004-12-24 13:36:31 -08:00
+++ b/drivers/video/console/Kconfig	2004-12-24 13:36:31 -08:00
@@ -105,6 +105,7 @@
 config FRAMEBUFFER_CONSOLE
 	tristate "Framebuffer Console support"
 	depends on FB
+	select CRC32
 
 config FONTS
 	bool "Select compiled-in fonts"
diff -Nru a/drivers/video/console/Makefile b/drivers/video/console/Makefile
--- a/drivers/video/console/Makefile	2004-12-24 13:36:48 -08:00
+++ b/drivers/video/console/Makefile	2004-12-24 13:36:48 -08:00
@@ -24,7 +24,8 @@
 obj-$(CONFIG_STI_CONSOLE)         += sticon.o sticore.o
 obj-$(CONFIG_VGA_CONSOLE)         += vgacon.o
 obj-$(CONFIG_MDA_CONSOLE)         += mdacon.o
-obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon.o font.o
+obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon.o bitblit.o font.o
+obj-$(CONFIG_FB_TILEBLITTING)     += tileblit.o
 
 obj-$(CONFIG_FB_STI)              += sticore.o
 
diff -Nru a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/console/bitblit.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,395 @@
+/*
+ *  linux/drivers/video/console/bitblit.c -- BitBlitting Operation
+ *
+ *  Originally from the 'accel_*' routines in drivers/video/console/fbcon.c
+ *
+ *      Copyright (C) 2004 Antonino Daplas <adaplas @pol.net>
+ *
+ *  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 <linux/config.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/fb.h>
+#include <linux/vt_kern.h>
+#include <linux/console.h>
+#include <asm/types.h>
+#include "fbcon.h"
+
+/*
+ * Accelerated handlers.
+ */
+#define FBCON_ATTRIBUTE_UNDERLINE 1
+#define FBCON_ATTRIBUTE_REVERSE   2
+#define FBCON_ATTRIBUTE_BOLD      4
+
+static inline int real_y(struct display *p, int ypos)
+{
+	int rows = p->vrows;
+
+	ypos += p->yscroll;
+	return ypos < rows ? ypos : ypos - rows;
+}
+
+
+static inline int get_attribute(struct fb_info *info, u16 c)
+{
+	int attribute = 0;
+
+	if (fb_get_color_depth(info) == 1) {
+		if (attr_underline(c))
+			attribute |= FBCON_ATTRIBUTE_UNDERLINE;
+		if (attr_reverse(c))
+			attribute |= FBCON_ATTRIBUTE_REVERSE;
+		if (attr_bold(c))
+			attribute |= FBCON_ATTRIBUTE_BOLD;
+	}
+
+	return attribute;
+}
+
+static inline void update_attr(u8 *dst, u8 *src, int attribute,
+			       struct vc_data *vc)
+{
+	int i, offset = (vc->vc_font.height < 10) ? 1 : 2;
+	int width = (vc->vc_font.width + 7) >> 3;
+	unsigned int cellsize = vc->vc_font.height * width;
+	u8 c;
+
+	offset = cellsize - (offset * width);
+	for (i = 0; i < cellsize; i++) {
+		c = src[i];
+		if (attribute & FBCON_ATTRIBUTE_UNDERLINE && i >= offset)
+			c = 0xff;
+		if (attribute & FBCON_ATTRIBUTE_BOLD)
+			c |= c >> 1;
+		if (attribute & FBCON_ATTRIBUTE_REVERSE)
+			c = ~c;
+		dst[i] = c;
+	}
+}
+
+static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,
+		      int sx, int dy, int dx, int height, int width)
+{
+	struct fb_copyarea area;
+
+	area.sx = sx * vc->vc_font.width;
+	area.sy = sy * vc->vc_font.height;
+	area.dx = dx * vc->vc_font.width;
+	area.dy = dy * vc->vc_font.height;
+	area.height = height * vc->vc_font.height;
+	area.width = width * vc->vc_font.width;
+
+	info->fbops->fb_copyarea(info, &area);
+}
+
+static void bit_clear(struct vc_data *vc, struct fb_info *info, int sy,
+		      int sx, int height, int width)
+{
+	int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
+	struct fb_fillrect region;
+
+	region.color = attr_bgcol_ec(bgshift, vc);
+	region.dx = sx * vc->vc_font.width;
+	region.dy = sy * vc->vc_font.height;
+	region.width = width * vc->vc_font.width;
+	region.height = height * vc->vc_font.height;
+	region.rop = ROP_COPY;
+
+	info->fbops->fb_fillrect(info, &region);
+}
+
+static void bit_putcs(struct vc_data *vc, struct fb_info *info,
+		      const unsigned short *s, int count, int yy, int xx,
+		      int fg, int bg)
+{
+	void (*move_unaligned)(struct fb_info *info, struct fb_pixmap *buf,
+			       u8 *dst, u32 d_pitch, u8 *src, u32 idx,
+			       u32 height, u32 shift_high, u32 shift_low,
+			       u32 mod);
+	void (*move_aligned)(struct fb_info *info, struct fb_pixmap *buf,
+			     u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
+			     u32 height);
+	unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
+	unsigned int width = (vc->vc_font.width + 7) >> 3;
+	unsigned int cellsize = vc->vc_font.height * width;
+	unsigned int maxcnt = info->pixmap.size/cellsize;
+	unsigned int scan_align = info->pixmap.scan_align - 1;
+	unsigned int buf_align = info->pixmap.buf_align - 1;
+	unsigned int shift_low = 0, mod = vc->vc_font.width % 8;
+	unsigned int shift_high = 8, pitch, cnt, size, k;
+	unsigned int idx = vc->vc_font.width >> 3;
+	unsigned int attribute = get_attribute(info, scr_readw(s));
+	struct fb_image image;
+	u8 *src, *dst, *buf = NULL;
+
+	if (attribute) {
+		buf = kmalloc(cellsize, GFP_KERNEL);
+		if (!buf)
+			return;
+	}
+
+	image.fg_color = fg;
+	image.bg_color = bg;
+
+	image.dx = xx * vc->vc_font.width;
+	image.dy = yy * vc->vc_font.height;
+	image.height = vc->vc_font.height;
+	image.depth = 1;
+
+	if (info->pixmap.outbuf && info->pixmap.inbuf) {
+		move_aligned = fb_iomove_buf_aligned;
+		move_unaligned = fb_iomove_buf_unaligned;
+	} else {
+		move_aligned = fb_sysmove_buf_aligned;
+		move_unaligned = fb_sysmove_buf_unaligned;
+	}
+	while (count) {
+		if (count > maxcnt)
+			cnt = k = maxcnt;
+		else
+			cnt = k = count;
+
+		image.width = vc->vc_font.width * cnt;
+		pitch = ((image.width + 7) >> 3) + scan_align;
+		pitch &= ~scan_align;
+		size = pitch * image.height + buf_align;
+		size &= ~buf_align;
+		dst = fb_get_buffer_offset(info, &info->pixmap, size);
+		image.data = dst;
+		if (mod) {
+			while (k--) {
+				src = vc->vc_font.data + (scr_readw(s++)&
+							  charmask)*cellsize;
+
+				if (attribute) {
+					update_attr(buf, src, attribute, vc);
+					src = buf;
+				}
+
+				move_unaligned(info, &info->pixmap, dst, pitch,
+					       src, idx, image.height,
+					       shift_high, shift_low, mod);
+				shift_low += mod;
+				dst += (shift_low >= 8) ? width : width - 1;
+				shift_low &= 7;
+				shift_high = 8 - shift_low;
+			}
+		} else {
+			while (k--) {
+				src = vc->vc_font.data + (scr_readw(s++)&
+							  charmask)*cellsize;
+
+				if (attribute) {
+					update_attr(buf, src, attribute, vc);
+					src = buf;
+				}
+
+				move_aligned(info, &info->pixmap, dst, pitch,
+					     src, idx, image.height);
+				dst += width;
+			}
+		}
+		info->fbops->fb_imageblit(info, &image);
+		image.dx += cnt * vc->vc_font.width;
+		count -= cnt;
+	}
+
+	if (buf)
+		kfree(buf);
+}
+
+static void bit_clear_margins(struct vc_data *vc, struct fb_info *info,
+			      int bottom_only)
+{
+	int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
+	unsigned int cw = vc->vc_font.width;
+	unsigned int ch = vc->vc_font.height;
+	unsigned int rw = info->var.xres - (vc->vc_cols*cw);
+	unsigned int bh = info->var.yres - (vc->vc_rows*ch);
+	unsigned int rs = info->var.xres - rw;
+	unsigned int bs = info->var.yres - bh;
+	struct fb_fillrect region;
+
+	region.color = attr_bgcol_ec(bgshift, vc);
+	region.rop = ROP_COPY;
+
+	if (rw && !bottom_only) {
+		region.dx = info->var.xoffset + rs;
+		region.dy = 0;
+		region.width = rw;
+		region.height = info->var.yres_virtual;
+		info->fbops->fb_fillrect(info, &region);
+	}
+
+	if (bh) {
+		region.dx = info->var.xoffset;
+		region.dy = info->var.yoffset + bs;
+		region.width = rs;
+		region.height = bh;
+		info->fbops->fb_fillrect(info, &region);
+	}
+}
+
+static void bit_cursor(struct vc_data *vc, struct fb_info *info,
+		       struct display *p, int mode, int fg, int bg)
+{
+	struct fb_cursor cursor;
+	struct fbcon_ops *ops = (struct fbcon_ops *) info->fbcon_par;
+	unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
+	int w = (vc->vc_font.width + 7) >> 3, c;
+	int y = real_y(p, vc->vc_y);
+	int attribute, use_sw = (vc->vc_cursor_type & 0x10);
+	char *src;
+
+	cursor.set = 0;
+
+ 	c = scr_readw((u16 *) vc->vc_pos);
+	attribute = get_attribute(info, c);
+	src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height));
+
+	if (ops->cursor_state.image.data != src ||
+	    ops->cursor_reset) {
+	    ops->cursor_state.image.data = src;
+	    cursor.set |= FB_CUR_SETIMAGE;
+	}
+
+	if (attribute) {
+		u8 *dst;
+
+		dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC);
+		if (!dst)
+			return;
+		if (ops->cursor_data)
+			kfree(ops->cursor_data);
+		ops->cursor_data = dst;
+		update_attr(dst, src, attribute, vc);
+		src = dst;
+	}
+
+	if (ops->cursor_state.image.fg_color != fg ||
+	    ops->cursor_state.image.bg_color != bg ||
+	    ops->cursor_reset) {
+		ops->cursor_state.image.fg_color = fg;
+		ops->cursor_state.image.bg_color = bg;
+		cursor.set |= FB_CUR_SETCMAP;
+	}
+
+	if ((ops->cursor_state.image.dx != (vc->vc_font.width * vc->vc_x)) ||
+	    (ops->cursor_state.image.dy != (vc->vc_font.height * y)) ||
+	    ops->cursor_reset) {
+		ops->cursor_state.image.dx = vc->vc_font.width * vc->vc_x;
+		ops->cursor_state.image.dy = vc->vc_font.height * y;
+		cursor.set |= FB_CUR_SETPOS;
+	}
+
+	if (ops->cursor_state.image.height != vc->vc_font.height ||
+	    ops->cursor_state.image.width != vc->vc_font.width ||
+	    ops->cursor_reset) {
+		ops->cursor_state.image.height = vc->vc_font.height;
+		ops->cursor_state.image.width = vc->vc_font.width;
+		cursor.set |= FB_CUR_SETSIZE;
+	}
+
+	if (ops->cursor_state.hot.x || ops->cursor_state.hot.y ||
+	    ops->cursor_reset) {
+		ops->cursor_state.hot.x = cursor.hot.y = 0;
+		cursor.set |= FB_CUR_SETHOT;
+	}
+
+	if (cursor.set & FB_CUR_SETSIZE ||
+	    vc->vc_cursor_type != p->cursor_shape ||
+	    ops->cursor_state.mask == NULL ||
+	    ops->cursor_reset) {
+		char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC);
+		int cur_height, size, i = 0;
+		u8 msk = 0xff;
+
+		if (!mask)
+			return;
+
+		if (ops->cursor_state.mask)
+			kfree(ops->cursor_state.mask);
+		ops->cursor_state.mask = mask;
+
+		p->cursor_shape = vc->vc_cursor_type;
+		cursor.set |= FB_CUR_SETSHAPE;
+
+		switch (p->cursor_shape & CUR_HWMASK) {
+		case CUR_NONE:
+			cur_height = 0;
+			break;
+		case CUR_UNDERLINE:
+			cur_height = (vc->vc_font.height < 10) ? 1 : 2;
+			break;
+		case CUR_LOWER_THIRD:
+			cur_height = vc->vc_font.height/3;
+			break;
+		case CUR_LOWER_HALF:
+			cur_height = vc->vc_font.height >> 1;
+			break;
+		case CUR_TWO_THIRDS:
+			cur_height = (vc->vc_font.height << 1)/3;
+			break;
+		case CUR_BLOCK:
+		default:
+			cur_height = vc->vc_font.height;
+			break;
+		}
+		size = (vc->vc_font.height - cur_height) * w;
+		while (size--)
+			mask[i++] = ~msk;
+		size = cur_height * w;
+		while (size--)
+			mask[i++] = msk;
+	}
+
+	switch (mode) {
+	case CM_ERASE:
+		ops->cursor_state.enable = 0;
+		break;
+	case CM_DRAW:
+	case CM_MOVE:
+	default:
+		ops->cursor_state.enable = (use_sw) ? 0 : 1;
+		break;
+	}
+
+	cursor.image.data = src;
+	cursor.image.fg_color = ops->cursor_state.image.fg_color;
+	cursor.image.bg_color = ops->cursor_state.image.bg_color;
+	cursor.image.dx = ops->cursor_state.image.dx;
+	cursor.image.dy = ops->cursor_state.image.dy;
+	cursor.image.height = ops->cursor_state.image.height;
+	cursor.image.width = ops->cursor_state.image.width;
+	cursor.hot.x = ops->cursor_state.hot.x;
+	cursor.hot.y = ops->cursor_state.hot.y;
+	cursor.mask = ops->cursor_state.mask;
+	cursor.enable = ops->cursor_state.enable;
+	cursor.image.depth = 1;
+	cursor.rop = ROP_XOR;
+
+	info->fbops->fb_cursor(info, &cursor);
+
+	ops->cursor_reset = 0;
+}
+
+void fbcon_set_bitops(struct fbcon_ops *ops)
+{
+	ops->bmove = bit_bmove;
+	ops->clear = bit_clear;
+	ops->putcs = bit_putcs;
+	ops->clear_margins = bit_clear_margins;
+	ops->cursor = bit_cursor;
+}
+
+EXPORT_SYMBOL(fbcon_set_bitops);
+
+MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
+MODULE_DESCRIPTION("Bit Blitting Operation");
+MODULE_LICENSE("GPL");
+
diff -Nru a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
--- a/drivers/video/console/fbcon.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/video/console/fbcon.c	2004-12-24 13:37:02 -08:00
@@ -77,7 +77,7 @@
 #include <linux/smp.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-
+#include <linux/crc32.h> /* For counting font checksums */
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -100,11 +100,20 @@
 #  define DPRINTK(fmt, args...)
 #endif
 
+enum {
+	FBCON_LOGO_CANSHOW	= -1,	/* the logo can be shown */
+	FBCON_LOGO_DRAW		= -2,	/* draw the logo to a console */
+	FBCON_LOGO_DONTSHOW	= -3	/* do not show the logo */
+};
+
 struct display fb_display[MAX_NR_CONSOLES];
 signed char con2fb_map[MAX_NR_CONSOLES];
+signed char con2fb_map_boot[MAX_NR_CONSOLES];
 static int logo_height;
 static int logo_lines;
-static int logo_shown = -1;
+/* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO
+   enums.  */
+static int logo_shown = FBCON_LOGO_CANSHOW;
 /* Software scrollback */
 int fbcon_softback_size = 32768;
 static unsigned long softback_buf, softback_curr;
@@ -119,13 +128,7 @@
 static char fontname[40];
 
 /* current fb_info */
-static int info_idx =  -1;
-
-#define REFCOUNT(fd)	(((int *)(fd))[-1])
-#define FNTSIZE(fd)	(((int *)(fd))[-2])
-#define FNTCHARCNT(fd)	(((int *)(fd))[-3])
-#define FNTSUM(fd)	(((int *)(fd))[-4])
-#define FONT_EXTRA_WORDS 4
+static int info_idx = -1;
 
 #define CM_SOFTBACK	(8)
 
@@ -158,6 +161,7 @@
 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos);
 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
 			int count, int ypos, int xpos);
+static void fbcon_clear_margins(struct vc_data *vc, int bottom_only);
 static void fbcon_cursor(struct vc_data *vc, int mode);
 static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
 			int count);
@@ -167,9 +171,6 @@
 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch);
 static int fbcon_set_palette(struct vc_data *vc, unsigned char *table);
 static int fbcon_scrolldelta(struct vc_data *vc, int lines);
-void accel_clear_margins(struct vc_data *vc, struct fb_info *info,
-			 int bottom_only);
-
 
 /*
  *  Internal routines
@@ -182,6 +183,7 @@
 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
 			    int dy, int dx, int height, int width, u_int y_break);
 static void fbcon_set_disp(struct fb_info *info, struct vc_data *vc);
+static void fbcon_preset_disp(struct fb_info *info, int unit);
 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
 			      int line, int count, int dy);
 
@@ -198,21 +200,85 @@
 }
 #endif
 
+static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
+{
+	return (info->state != FBINFO_STATE_RUNNING ||
+		vt_cons[vc->vc_num]->vc_mode != KD_TEXT);
+}
+
+static inline int get_color(struct vc_data *vc, struct fb_info *info,
+	      u16 c, int is_fg)
+{
+	int depth = fb_get_color_depth(info);
+	int color = 0;
+
+	if (console_blanked) {
+		unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
+
+		c = vc->vc_video_erase_char & charmask;
+	}
+
+	if (depth != 1)
+		color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c)
+			: attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c);
+
+	switch (depth) {
+	case 1:
+	{
+		/* 0 or 1 */
+		int fg = (info->fix.visual != FB_VISUAL_MONO01) ? 1 : 0;
+		int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : 1;
+
+		if (console_blanked)
+			fg = bg;
+
+		color = (is_fg) ? fg : bg;
+		break;
+	}
+	case 2:
+		/*
+		 * Scale down 16-colors to 4 colors. Default 4-color palette
+		 * is grayscale.
+		 */
+		color /= 4;
+		break;
+	case 3:
+		/*
+		 * Last 8 entries of default 16-color palette is a more intense
+		 * version of the first 8 (i.e., same chrominance, different
+		 * luminance).
+		 */
+		color &= 7;
+		break;
+	}
+
+
+	return color;
+}
+
 static void fb_flashcursor(void *private)
 {
-	struct fb_info *info = (struct fb_info *) private;
+	struct fb_info *info = private;
+	struct fbcon_ops *ops = info->fbcon_par;
+	struct display *p;
 	struct vc_data *vc = NULL;
+	int c;
+	int mode;
 
-	if (info->currcon != -1)
-		vc = vc_cons[info->currcon].d;
+	if (ops->currcon != -1)
+		vc = vc_cons[ops->currcon].d;
 
-	if (info->state != FBINFO_STATE_RUNNING ||
-	    info->cursor.rop == ROP_COPY || !vc || !CON_IS_VISIBLE(vc)
-	    || registered_fb[(int) con2fb_map[vc->vc_num]] != info)
+	if (!vc || !CON_IS_VISIBLE(vc) ||
+	    fbcon_is_inactive(vc, info) ||
+ 	    registered_fb[con2fb_map[vc->vc_num]] != info)
 		return;
 	acquire_console_sem();
-	info->cursor.enable ^= 1;
-	info->fbops->fb_cursor(info, &info->cursor);
+	p = &fb_display[vc->vc_num];
+	c = scr_readw((u16 *) vc->vc_pos);
+	mode = (!ops->cursor_flash || ops->cursor_state.enable) ?
+		CM_ERASE : CM_DRAW;
+	ops->cursor(vc, info, p, mode, get_color(vc, info, c, 1),
+		    get_color(vc, info, c, 0));
 	release_console_sem();
 }
 
@@ -233,9 +299,10 @@
 static void cursor_timer_handler(unsigned long dev_addr)
 {
 	struct fb_info *info = (struct fb_info *) dev_addr;
-	
+	struct fbcon_ops *ops = info->fbcon_par;
+
 	schedule_work(&info->queue);
-	mod_timer(&info->cursor_timer, jiffies + HZ/5);
+	mod_timer(&ops->cursor_timer, jiffies + HZ/5);
 }
 
 int __init fb_console_setup(char *this_opt)
@@ -271,7 +338,8 @@
 				for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) {
 					if (!options[j])
 						j = 0;
-					con2fb_map[i] = (options[j++]-'0') % FB_MAX;
+					con2fb_map_boot[i] =
+						(options[j++]-'0') % FB_MAX;
 				}
 			return 0;
 		}
@@ -294,33 +362,36 @@
 
 static int search_fb_in_map(int idx)
 {
-	int i;
+	int i, retval = 0;
 
 	for (i = 0; i < MAX_NR_CONSOLES; i++) {
 		if (con2fb_map[i] == idx)
-			return 1;
+			retval = 1;
 	}
-	return 0;
+	return retval;
 }
 
 static int search_for_mapped_con(void)
 {
-	int i;
+	int i, retval = 0;
 
 	for (i = 0; i < MAX_NR_CONSOLES; i++) {
 		if (con2fb_map[i] != -1)
-			return 1;
+			retval = 1;
 	}
-	return 0;
+	return retval;
 }
 
-static int fbcon_takeover(void)
+static int fbcon_takeover(int show_logo)
 {
 	int err, i;
 
 	if (!num_registered_fb)
 		return -ENODEV;
 
+	if (!show_logo)
+		logo_shown = FBCON_LOGO_DONTSHOW;
+
 	for (i = first_fb_vc; i <= last_fb_vc; i++)
 		con2fb_map[i] = info_idx;
 
@@ -336,338 +407,271 @@
 	return err;
 }
 
-/**
- *	set_con2fb_map - map console to frame buffer device
- *	@unit: virtual console number to map
- *	@newidx: frame buffer index to map virtual console to
- *
- *	Maps a virtual console @unit to a frame buffer device
- *	@newidx.
- */
-static int set_con2fb_map(int unit, int newidx)
+static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
+			       int cols, int rows, int new_cols, int new_rows)
 {
-	struct vc_data *vc = vc_cons[unit].d;
-	int oldidx = con2fb_map[unit];
-	struct fb_info *info = registered_fb[newidx];
-	struct fb_info *oldinfo = NULL;
-	int found;
+	/* Need to make room for the logo */
+	int cnt, erase = vc->vc_video_erase_char, step;
+	unsigned short *save = NULL, *r, *q;
 
-	if (oldidx == newidx)
-		return 0;
+	/*
+	 * remove underline attribute from erase character
+	 * if black and white framebuffer.
+	 */
+	if (fb_get_color_depth(info) == 1)
+		erase &= ~0x400;
+	logo_height = fb_prepare_logo(info);
+	logo_lines = (logo_height + vc->vc_font.height - 1) /
+		vc->vc_font.height;
+	q = (unsigned short *) (vc->vc_origin +
+				vc->vc_size_row * rows);
+	step = logo_lines * cols;
+	for (r = q - logo_lines * cols; r < q; r++)
+		if (scr_readw(r) != vc->vc_video_erase_char)
+			break;
+	if (r != q && new_rows >= rows + logo_lines) {
+		save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL);
+		if (save) {
+			int i = cols < new_cols ? cols : new_cols;
+			scr_memsetw(save, erase, logo_lines * new_cols * 2);
+			r = q - step;
+			for (cnt = 0; cnt < logo_lines; cnt++, r += i)
+				scr_memcpyw(save + cnt * new_cols, r, 2 * i);
+			r = q;
+		}
+	}
+	if (r == q) {
+		/* We can scroll screen down */
+		r = q - step - cols;
+		for (cnt = rows - logo_lines; cnt > 0; cnt--) {
+			scr_memcpyw(r + step, r, vc->vc_size_row);
+			r -= cols;
+		}
+		if (!save) {
+			vc->vc_y += logo_lines;
+			vc->vc_pos += logo_lines * vc->vc_size_row;
+		}
+	}
+	scr_memsetw((unsigned short *) vc->vc_origin,
+		    erase,
+		    vc->vc_size_row * logo_lines);
 
-	if (!vc)
-	    return -ENODEV;
+	if (CON_IS_VISIBLE(vc) && vt_cons[vc->vc_num]->vc_mode == KD_TEXT) {
+		fbcon_clear_margins(vc, 0);
+		update_screen(vc->vc_num);
+	}
 
-	if (!search_for_mapped_con()) {
-		info_idx = newidx;
-		return fbcon_takeover();
+	if (save) {
+		q = (unsigned short *) (vc->vc_origin +
+					vc->vc_size_row *
+					rows);
+		scr_memcpyw(q, save, logo_lines * new_cols * 2);
+		vc->vc_y += logo_lines;
+		vc->vc_pos += logo_lines * vc->vc_size_row;
+		kfree(save);
 	}
 
-	if (oldidx != -1)
-		oldinfo = registered_fb[oldidx];
+	if (logo_lines > vc->vc_bottom) {
+		logo_shown = FBCON_LOGO_CANSHOW;
+		printk(KERN_INFO
+		       "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n");
+	} else if (logo_shown != FBCON_LOGO_DONTSHOW) {
+		logo_shown = FBCON_LOGO_DRAW;
+		vc->vc_top = logo_lines;
+	}
+}
 
-	found = search_fb_in_map(newidx);
+#ifdef CONFIG_FB_TILEBLITTING
+static void set_blitting_type(struct vc_data *vc, struct fb_info *info,
+			      struct display *p)
+{
+	struct fbcon_ops *ops = info->fbcon_par;
 
-	acquire_console_sem();
-	con2fb_map[unit] = newidx;
-	if (!found) {
-		if (!try_module_get(info->fbops->owner)) {
-			con2fb_map[unit] = oldidx;
-			release_console_sem();
-			return -ENODEV;
-		}
-		if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
-			module_put(info->fbops->owner);
-			con2fb_map[unit] = oldidx;
-			release_console_sem();
-			return -ENODEV;
-		}
-	}
+	if ((info->flags & FBINFO_MISC_TILEBLITTING))
+		fbcon_set_tileops(vc, info, p, ops);
+	else
+		fbcon_set_bitops(ops);
+}
+#else
+static void set_blitting_type(struct vc_data *vc, struct fb_info *info,
+			      struct display *p)
+{
+	struct fbcon_ops *ops = info->fbcon_par;
 
-	/*
-	 * If old fb is not mapped to any of the consoles,
-	 * fbcon should release it.
-	 */
-	if (oldinfo && !search_fb_in_map(oldidx)) {
-		if (oldinfo->fbops->fb_release &&
-		    oldinfo->fbops->fb_release(oldinfo, 0)) {
-			con2fb_map[unit] = oldidx;
-			if (!found && info->fbops->fb_release)
-				info->fbops->fb_release(info, 0);
-			if (!found)
-				module_put(info->fbops->owner);
-			release_console_sem();
-			return -ENODEV;
-		}
-		if (oldinfo->queue.func == fb_flashcursor)
-			del_timer_sync(&oldinfo->cursor_timer);
-		module_put(oldinfo->fbops->owner);
-	}
-	info->currcon = -1;
-	if (!found) {
-		if (!info->queue.func || info->queue.func == fb_flashcursor) {
-			if (!info->queue.func)
-				INIT_WORK(&info->queue, fb_flashcursor, info);
-
-			init_timer(&info->cursor_timer);
-			info->cursor_timer.function = cursor_timer_handler;
-			info->cursor_timer.expires = jiffies + HZ / 5;
-			info->cursor_timer.data = (unsigned long ) info;
-			add_timer(&info->cursor_timer);
-		}
-	}
-	if (info->fbops->fb_set_par)
-		info->fbops->fb_set_par(info);
-	fbcon_set_disp(info, vc);
-	release_console_sem();
-	return 0;
+	info->flags &= ~FBINFO_MISC_TILEBLITTING;
+	fbcon_set_bitops(ops);
 }
+#endif /* CONFIG_MISC_TILEBLITTING */
 
-/*
- * Accelerated handlers.
- */
-static inline int get_color(struct vc_data *vc, struct fb_info *info,
-			    u16 c, int is_fg)
+
+static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info,
+				  int unit, int oldidx)
 {
-	int depth = fb_get_color_depth(info);
-	int color = 0;
+	struct fbcon_ops *ops = NULL;
+	int err = 0;
 
-	if (depth != 1)
-		color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c)
-			: attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c);
+	if (!try_module_get(info->fbops->owner))
+		err = -ENODEV;
 
-	switch (depth) {
-	case 1:
-	{
-		/* 0 or 1 */
-		int fg = (info->fix.visual != FB_VISUAL_MONO01) ? 1 : 0;
-		int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : 1;
+	if (!err && info->fbops->fb_open &&
+	    info->fbops->fb_open(info, 0))
+		err = -ENODEV;
 
-		color = (is_fg) ? fg : bg;
-		break;
+	if (!err) {
+		ops = kmalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
+		if (!ops)
+			err = -ENOMEM;
 	}
-	case 2:
-		/*
-		 * Scale down 16-colors to 4 colors. Default 4-color palette
-		 * is grayscale.
-		 */
-		color /= 4;
-		break;
-	case 3:
-		/*
-		 * Last 8 entries of default 16-color palette is a more intense
-		 * version of the first 8 (i.e., same chrominance, different
-		 * luminance).
-		 */
-		color &= 7;
-		break;
+
+	if (!err) {
+		memset(ops, 0, sizeof(struct fbcon_ops));
+		info->fbcon_par = ops;
+		set_blitting_type(vc, info, NULL);
 	}
 
-	return color;
+	if (err) {
+		con2fb_map[unit] = oldidx;
+		module_put(info->fbops->owner);
+	}
+
+	return err;
 }
 
-#define FBCON_ATTRIBUTE_UNDERLINE 1
-#define FBCON_ATTRIBUTE_REVERSE   2
-#define FBCON_ATTRIBUTE_BOLD      4
+static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
+				  struct fb_info *newinfo, int unit,
+				  int oldidx, int found)
+{
+	struct fbcon_ops *ops = oldinfo->fbcon_par;
+	int err = 0;
+
+	if (oldinfo->fbops->fb_release &&
+	    oldinfo->fbops->fb_release(oldinfo, 0)) {
+		con2fb_map[unit] = oldidx;
+		if (!found && newinfo->fbops->fb_release)
+			newinfo->fbops->fb_release(newinfo, 0);
+		if (!found)
+			module_put(newinfo->fbops->owner);
+		err = -ENODEV;
+	}
 
-static inline int get_attribute(struct fb_info *info, u16 c)
-{
-	int attribute = 0;
+	if (!err) {
+		if (oldinfo->queue.func == fb_flashcursor)
+			del_timer_sync(&ops->cursor_timer);
 
-	if (fb_get_color_depth(info) == 1) {
-		if (attr_underline(c))
-			attribute |= FBCON_ATTRIBUTE_UNDERLINE;
-		if (attr_reverse(c))
-			attribute |= FBCON_ATTRIBUTE_REVERSE;
-		if (attr_bold(c))
-			attribute |= FBCON_ATTRIBUTE_BOLD;
+		kfree(ops->cursor_state.mask);
+		kfree(ops->cursor_data);
+		kfree(oldinfo->fbcon_par);
+		oldinfo->fbcon_par = NULL;
+		module_put(oldinfo->fbops->owner);
 	}
 
-	return attribute;
+	return err;
 }
 
-static inline void update_attr(u8 *dst, u8 *src, int attribute,
-			       struct vc_data *vc)
+static void con2fb_init_newinfo(struct fb_info *info)
 {
-	int i, offset = (vc->vc_font.height < 10) ? 1 : 2;
-	int width = (vc->vc_font.width + 7) >> 3;
-	unsigned int cellsize = vc->vc_font.height * width;
-	u8 c;
+	if (!info->queue.func || info->queue.func == fb_flashcursor) {
+		struct fbcon_ops *ops = info->fbcon_par;
+
+		if (!info->queue.func)
+			INIT_WORK(&info->queue, fb_flashcursor, info);
 
-	offset = cellsize - (offset * width);
-	for (i = 0; i < cellsize; i++) {
-		c = src[i];
-		if (attribute & FBCON_ATTRIBUTE_UNDERLINE && i >= offset)
-			c = 0xff;
-		if (attribute & FBCON_ATTRIBUTE_BOLD)
-			c |= c >> 1;
-		if (attribute & FBCON_ATTRIBUTE_REVERSE)
-			c = ~c;
-		dst[i] = c;
+		init_timer(&ops->cursor_timer);
+		ops->cursor_timer.function = cursor_timer_handler;
+		ops->cursor_timer.expires = jiffies + HZ / 5;
+		ops->cursor_timer.data = (unsigned long ) info;
+		add_timer(&ops->cursor_timer);
 	}
 }
 
-void accel_bmove(struct vc_data *vc, struct fb_info *info, int sy, 
-		int sx, int dy, int dx, int height, int width)
+static void con2fb_init_display(struct vc_data *vc, struct fb_info *info,
+				int unit, int show_logo)
 {
-	struct fb_copyarea area;
+	struct fbcon_ops *ops = info->fbcon_par;
+
+	ops->currcon = fg_console;
+
+	if (info->fbops->fb_set_par)
+		info->fbops->fb_set_par(info);
 
-	area.sx = sx * vc->vc_font.width;
-	area.sy = sy * vc->vc_font.height;
-	area.dx = dx * vc->vc_font.width;
-	area.dy = dy * vc->vc_font.height;
-	area.height = height * vc->vc_font.height;
-	area.width = width * vc->vc_font.width;
+	if (vc)
+		fbcon_set_disp(info, vc);
+	else
+		fbcon_preset_disp(info, unit);
+
+	if (show_logo) {
+		struct vc_data *fg_vc = vc_cons[fg_console].d;
+		struct fb_info *fg_info =
+			registered_fb[con2fb_map[fg_console]];
+
+		fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols,
+				   fg_vc->vc_rows, fg_vc->vc_cols,
+				   fg_vc->vc_rows);
+	}
 
-	info->fbops->fb_copyarea(info, &area);
+	switch_screen(fg_console);
 }
 
-void accel_clear(struct vc_data *vc, struct fb_info *info, int sy,
-			int sx, int height, int width)
+/**
+ *	set_con2fb_map - map console to frame buffer device
+ *	@unit: virtual console number to map
+ *	@newidx: frame buffer index to map virtual console to
+ *      @user: user request
+ *
+ *	Maps a virtual console @unit to a frame buffer device
+ *	@newidx.
+ */
+static int set_con2fb_map(int unit, int newidx, int user)
 {
-	int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-	struct fb_fillrect region;
+	struct vc_data *vc = vc_cons[unit].d;
+	int oldidx = con2fb_map[unit];
+	struct fb_info *info = registered_fb[newidx];
+	struct fb_info *oldinfo = NULL;
+ 	int found, err = 0;
 
-	region.color = attr_bgcol_ec(bgshift, vc);
-	region.dx = sx * vc->vc_font.width;
-	region.dy = sy * vc->vc_font.height;
-	region.width = width * vc->vc_font.width;
-	region.height = height * vc->vc_font.height;
-	region.rop = ROP_COPY;
+	if (oldidx == newidx)
+		return 0;
 
-	info->fbops->fb_fillrect(info, &region);
-}	
+	if (!info)
+ 		err =  -EINVAL;
 
-void accel_putcs(struct vc_data *vc, struct fb_info *info,
-		 const unsigned short *s, int count, int yy, int xx)
-{
-	void (*move_unaligned)(struct fb_info *info, struct fb_pixmap *buf,
-			       u8 *dst, u32 d_pitch, u8 *src, u32 idx,
-			       u32 height, u32 shift_high, u32 shift_low,
-			       u32 mod);
-	void (*move_aligned)(struct fb_info *info, struct fb_pixmap *buf,
-			     u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
-			     u32 height);
-	unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
-	unsigned int width = (vc->vc_font.width + 7) >> 3;
-	unsigned int cellsize = vc->vc_font.height * width;
-	unsigned int maxcnt = info->pixmap.size/cellsize;
-	unsigned int scan_align = info->pixmap.scan_align - 1;
-	unsigned int buf_align = info->pixmap.buf_align - 1;
-	unsigned int shift_low = 0, mod = vc->vc_font.width % 8;
-	unsigned int shift_high = 8, pitch, cnt, size, k;
-	unsigned int idx = vc->vc_font.width >> 3;
-	unsigned int attribute = get_attribute(info, scr_readw(s));
-	struct fb_image image;
-	u8 *src, *dst, *buf = NULL;
-
-	if (attribute) {
-		buf = kmalloc(cellsize, GFP_KERNEL);
-		if (!buf)
-			return;
-	}
-
-	image.fg_color = get_color(vc, info, scr_readw(s), 1);
-	image.bg_color = get_color(vc, info, scr_readw(s), 0);
-
-	image.dx = xx * vc->vc_font.width;
-	image.dy = yy * vc->vc_font.height;
-	image.height = vc->vc_font.height;
-	image.depth = 1;
-
-	if (info->pixmap.outbuf && info->pixmap.inbuf) {
-		move_aligned = fb_iomove_buf_aligned;
-		move_unaligned = fb_iomove_buf_unaligned;
-	} else {
-		move_aligned = fb_sysmove_buf_aligned;
-		move_unaligned = fb_sysmove_buf_unaligned;
+ 	if (!err && !search_for_mapped_con()) {
+		info_idx = newidx;
+		return fbcon_takeover(0);
 	}
-	while (count) {
-		if (count > maxcnt)
-			cnt = k = maxcnt;
-		else
-			cnt = k = count;
 
-		image.width = vc->vc_font.width * cnt;
-		pitch = ((image.width + 7) >> 3) + scan_align;
-		pitch &= ~scan_align;
-		size = pitch * image.height + buf_align;
-		size &= ~buf_align;
-		dst = fb_get_buffer_offset(info, &info->pixmap, size);
-		image.data = dst;
-		if (mod) {
-			while (k--) {
-				src = vc->vc_font.data + (scr_readw(s++)&
-							  charmask)*cellsize;
-
-				if (attribute) {
-					update_attr(buf, src, attribute, vc);
-					src = buf;
-				}
+	if (oldidx != -1)
+		oldinfo = registered_fb[oldidx];
 
-				move_unaligned(info, &info->pixmap, dst, pitch,
-					       src, idx, image.height,
-					       shift_high, shift_low, mod);
-				shift_low += mod;
-				dst += (shift_low >= 8) ? width : width - 1;
-				shift_low &= 7;
-				shift_high = 8 - shift_low;
-			}
-		} else {
-			while (k--) {
-				src = vc->vc_font.data + (scr_readw(s++)&
-							  charmask)*cellsize;
-
-				if (attribute) {
-					update_attr(buf, src, attribute, vc);
-					src = buf;
-				}
+	found = search_fb_in_map(newidx);
 
-				move_aligned(info, &info->pixmap, dst, pitch,
-					     src, idx, image.height);
-				dst += width;
-			}
-		}
-		info->fbops->fb_imageblit(info, &image);
-		image.dx += cnt * vc->vc_font.width;
-		count -= cnt;
-	}
-
-	if (buf)
-		kfree(buf);
-}
-
-void accel_clear_margins(struct vc_data *vc, struct fb_info *info,
-				int bottom_only)
-{
-	int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-	unsigned int cw = vc->vc_font.width;
-	unsigned int ch = vc->vc_font.height;
-	unsigned int rw = info->var.xres - (vc->vc_cols*cw);
-	unsigned int bh = info->var.yres - (vc->vc_rows*ch);
-	unsigned int rs = info->var.xres - rw;
-	unsigned int bs = info->var.yres - bh;
-	struct fb_fillrect region;
-
-	region.color = attr_bgcol_ec(bgshift, vc);
-	region.rop = ROP_COPY;
-
-	if (rw && !bottom_only) {
-		region.dx = info->var.xoffset + rs;
-		region.dy = 0;
-		region.width = rw;
-		region.height = info->var.yres_virtual;
-		info->fbops->fb_fillrect(info, &region);
-	}
-
-	if (bh) {
-		region.dx = info->var.xoffset;
-		region.dy = info->var.yoffset + bs;
-		region.width = rs;
-		region.height = bh;
-		info->fbops->fb_fillrect(info, &region);
-	}	
-}	
+	acquire_console_sem();
+	con2fb_map[unit] = newidx;
+	if (!err && !found)
+ 		err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
+
+
+	/*
+	 * If old fb is not mapped to any of the consoles,
+	 * fbcon should release it.
+	 */
+ 	if (!err && oldinfo && !search_fb_in_map(oldidx))
+ 		err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx,
+ 					     found);
+
+ 	if (!err) {
+ 		int show_logo = (fg_console == 0 && !user &&
+ 				 logo_shown != FBCON_LOGO_DONTSHOW);
+
+ 		if (!found)
+ 			con2fb_init_newinfo(info);
+ 		con2fb_map_boot[unit] = newidx;
+ 		con2fb_init_display(vc, info, unit, show_logo);
+	}
+
+	release_console_sem();
+ 	return err;
+}
 
 /*
  *  Low Level Operations
@@ -722,6 +726,7 @@
 	struct font_desc *font = NULL;
 	struct module *owner;
 	struct fb_info *info = NULL;
+	struct fbcon_ops *ops;
 	int rows, cols;
 	int irqres;
 
@@ -739,7 +744,6 @@
 	info = registered_fb[info_idx];
 	if (!info)
 		return NULL;
-	info->currcon = -1;
 	
 	owner = info->fbops->owner;
 	if (!try_module_get(owner))
@@ -748,6 +752,18 @@
 		module_put(owner);
 		return NULL;
 	}
+
+	ops = kmalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
+	if (!ops) {
+		module_put(owner);
+		return NULL;
+	}
+
+	memset(ops, 0, sizeof(struct fbcon_ops));
+	ops->currcon = -1;
+	info->fbcon_par = ops;
+	set_blitting_type(vc, info, NULL);
+
 	if (info->fix.type != FB_TYPE_TEXT) {
 		if (fbcon_softback_size) {
 			if (!softback_buf) {
@@ -777,7 +793,7 @@
 	if (!p->fontdata) {
 		if (!fontname[0] || !(font = find_font(fontname)))
 			font = get_default_font(info->var.xres,
-						   info->var.yres);
+						info->var.yres);
 		vc->vc_font.width = font->width;
 		vc->vc_font.height = font->height;
 		vc->vc_font.data = p->fontdata = font->data;
@@ -793,7 +809,6 @@
 	DPRINTK("res:    %dx%d-%d\n", info->var.xres,
 		info->var.yres,
 		info->var.bits_per_pixel);
-	con_set_default_unimap(vc->vc_num);
 
 #ifdef CONFIG_ATARI
 	if (MACH_IS_ATARI) {
@@ -860,28 +875,28 @@
 	if (!info->queue.func) {
 		INIT_WORK(&info->queue, fb_flashcursor, info);
 
-		init_timer(&info->cursor_timer);
-		info->cursor_timer.function = cursor_timer_handler;
-		info->cursor_timer.expires = jiffies + HZ / 5;
-		info->cursor_timer.data = (unsigned long ) info;
-		add_timer(&info->cursor_timer);
+		init_timer(&ops->cursor_timer);
+		ops->cursor_timer.function = cursor_timer_handler;
+		ops->cursor_timer.expires = jiffies + HZ / 5;
+		ops->cursor_timer.data = (unsigned long ) info;
+		add_timer(&ops->cursor_timer);
 	}
 	return display_desc;
 }
 
 static void fbcon_init(struct vc_data *vc, int init)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct vc_data **default_mode = vc->vc_display_fg;
+	struct vc_data *svc = *default_mode;
 	struct display *t, *p = &fb_display[vc->vc_num];
 	int display_fg = (*default_mode)->vc_num;
 	int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
-	unsigned short *save = NULL, *r, *q;
 	int cap = info->flags;
 
 	if (info_idx == -1 || info == NULL)
 	    return;
-	if (vc->vc_num != display_fg || (info->flags & FBINFO_MODULE) ||
+	if (vc->vc_num != display_fg || logo_shown == FBCON_LOGO_DONTSHOW ||
 	    (info->fix.type == FB_TYPE_TEXT))
 		logo = 0;
 
@@ -900,7 +915,6 @@
 		p->userfont = t->userfont;
 		if (p->userfont)
 			REFCOUNT(p->fontdata)++;
-		con_copy_unimap(vc->vc_num, display_fg);
 	}
 	if (p->userfont)
 		charcnt = FNTCHARCNT(p->fontdata);
@@ -913,6 +927,12 @@
 		if (vc->vc_can_do_color)
 			vc->vc_complement_mask <<= 1;
 	}
+
+	if (!*svc->vc_uni_pagedir_loc)
+		con_set_default_unimap(display_fg);
+	if (!*vc->vc_uni_pagedir_loc)
+		con_copy_unimap(vc->vc_num, display_fg);
+
 	cols = vc->vc_cols;
 	rows = vc->vc_rows;
 	new_cols = info->var.xres / vc->vc_font.width;
@@ -945,75 +965,8 @@
 		vc->vc_rows = new_rows;
 	}
 
-	if (logo) {
-		/* Need to make room for the logo */
-		int cnt, erase = vc->vc_video_erase_char;
-		int step;
-
-		/*
-		 * remove underline attribute from erase character
-		 * if black and white framebuffer.
-		 */
-		if (fb_get_color_depth(info) == 1)
-			erase &= ~0x400;
-		logo_height = fb_prepare_logo(info);
-		logo_lines = (logo_height + vc->vc_font.height - 1) /
-			     vc->vc_font.height;
-		q = (unsigned short *) (vc->vc_origin +
-					vc->vc_size_row * rows);
-		step = logo_lines * cols;
-		for (r = q - logo_lines * cols; r < q; r++)
-			if (scr_readw(r) != vc->vc_video_erase_char)
-				break;
-		if (r != q && new_rows >= rows + logo_lines) {
-			save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL);
-			if (save) {
-				int i = cols < new_cols ? cols : new_cols;
-				scr_memsetw(save, erase, logo_lines * new_cols * 2);
-				r = q - step;
-				for (cnt = 0; cnt < logo_lines; cnt++, r += i)
-					scr_memcpyw(save + cnt * new_cols, r, 2 * i);
-				r = q;
-			}
-		}
-		if (r == q) {
-			/* We can scroll screen down */
-			r = q - step - cols;
-			for (cnt = rows - logo_lines; cnt > 0; cnt--) {
-				scr_memcpyw(r + step, r, vc->vc_size_row);
-				r -= cols;
-			}
-			if (!save) {
-				vc->vc_y += logo_lines;
-				vc->vc_pos += logo_lines * vc->vc_size_row;
-			}
-		}
-		scr_memsetw((unsigned short *) vc->vc_origin,
-			    erase,
-			    vc->vc_size_row * logo_lines);
-
-		if (CON_IS_VISIBLE(vc) && vt_cons[vc->vc_num]->vc_mode == KD_TEXT) {
-			accel_clear_margins(vc, info, 0);
-			update_screen(vc->vc_num);
-		}
-		if (save) {
-			q = (unsigned short *) (vc->vc_origin +
-						vc->vc_size_row *
-						rows);
-			scr_memcpyw(q, save, logo_lines * new_cols * 2);
-			vc->vc_y += logo_lines;
-			vc->vc_pos += logo_lines * vc->vc_size_row;
-			kfree(save);
-		}
-		if (logo_lines > vc->vc_bottom) {
-			logo_shown = -1;
-			printk(KERN_INFO
-			       "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n");
-		} else {
-			logo_shown = -2;
-			vc->vc_top = logo_lines;
-		}
-	}
+	if (logo)
+		fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
 
 	if (vc->vc_num == display_fg && softback_buf) {
 		int l = fbcon_softback_size / vc->vc_size_row;
@@ -1043,7 +996,7 @@
  *  This system is now divided into two levels because of complications
  *  caused by hardware scrolling. Top level functions:
  *
- *	fbcon_bmove(), fbcon_clear(), fbcon_putc()
+ *	fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins()
  *
  *  handles y values in range [0, scr_height-1] that correspond to real
  *  screen positions. y_wrap shift means that first line of bitmap may be
@@ -1073,14 +1026,13 @@
 static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
 			int width)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
-	
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
+	struct fbcon_ops *ops = info->fbcon_par;
+
 	struct display *p = &fb_display[vc->vc_num];
 	u_int y_break;
 
-	if (!info->fbops->fb_blank && console_blanked)
-		return;
-	if (info->state != FBINFO_STATE_RUNNING)
+	if (fbcon_is_inactive(vc, info))
 		return;
 
 	if (!height || !width)
@@ -1091,166 +1043,71 @@
 	y_break = p->vrows - p->yscroll;
 	if (sy < y_break && sy + height - 1 >= y_break) {
 		u_int b = y_break - sy;
-		accel_clear(vc, info, real_y(p, sy), sx, b, width);
-		accel_clear(vc, info, real_y(p, sy + b), sx, height - b,
+		ops->clear(vc, info, real_y(p, sy), sx, b, width);
+		ops->clear(vc, info, real_y(p, sy + b), sx, height - b,
 				 width);
 	} else
-		accel_clear(vc, info, real_y(p, sy), sx, height, width);
+		ops->clear(vc, info, real_y(p, sy), sx, height, width);
 }
 
 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
 			int count, int ypos, int xpos)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
+	struct fbcon_ops *ops = info->fbcon_par;
 
-	if (!info->fbops->fb_blank && console_blanked)
-		return;
-	if (info->state != FBINFO_STATE_RUNNING)
-		return;
+	if (!fbcon_is_inactive(vc, info))
+		ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
+			   get_color(vc, info, scr_readw(s), 1),
+			   get_color(vc, info, scr_readw(s), 0));
+}
 
-	if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT)
-		return;
+static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
+{
+	unsigned short chr;
 
-	accel_putcs(vc, info, s, count, real_y(p, ypos), xpos);
+	scr_writew(c, &chr);
+	fbcon_putcs(vc, &chr, 1, ypos, xpos);
 }
 
-static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
+static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
 {
-	fbcon_putcs(vc, (const unsigned short *) &c, 1, ypos, xpos);
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
+	struct fbcon_ops *ops = info->fbcon_par;
+
+	if (!fbcon_is_inactive(vc, info))
+		ops->clear_margins(vc, info, bottom_only);
 }
 
 static void fbcon_cursor(struct vc_data *vc, int mode)
 {
-	struct fb_cursor cursor;
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
-	unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
+	struct fbcon_ops *ops = info->fbcon_par;
 	struct display *p = &fb_display[vc->vc_num];
-	int w = (vc->vc_font.width + 7) >> 3, c;
-	int y = real_y(p, vc->vc_y), fg, bg;
-	int attribute;
-	u8 *src;
+	int y = real_y(p, vc->vc_y);
+ 	int c = scr_readw((u16 *) vc->vc_pos);
+
+	if (fbcon_is_inactive(vc, info))
+		return;
 
+	ops->cursor_flash = 1;
 	if (mode & CM_SOFTBACK) {
 		mode &= ~CM_SOFTBACK;
 		if (softback_lines) {
-			if (y + softback_lines >= vc->vc_rows)
+			if (y + softback_lines >= vc->vc_rows) {
 				mode = CM_ERASE;
+				ops->cursor_flash = 0;
+			}
 			else
 				y += softback_lines;
 		}
 	} else if (softback_lines)
 		fbcon_set_origin(vc);
 
- 	c = scr_readw((u16 *) vc->vc_pos);
-	attribute = get_attribute(info, c);
-	src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height));
-	if (attribute) {
-		u8 *dst;
-
-		dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC);
-		if (!dst)
-			return;
-		if (info->cursor.data)
-			kfree(info->cursor.data);
-		info->cursor.data = dst;
-		update_attr(dst, src, attribute, vc);
-		src = dst;
-	}
-
-	cursor.image.data = src;
-	cursor.set = FB_CUR_SETCUR;
-	cursor.image.depth = 1;
-	
-	switch (mode) {
-	case CM_ERASE:
-		if (info->cursor.rop == ROP_XOR) {
-			info->cursor.enable = 0;
-			info->cursor.rop = ROP_COPY;
-			info->fbops->fb_cursor(info, &cursor);
-		}	
-		break;
-	case CM_MOVE:
-	case CM_DRAW:
-		info->cursor.enable = 1;
-		fg = get_color(vc, info, c, 1);
-		bg = get_color(vc, info, c, 0);
-
-		if (info->cursor.image.fg_color != fg ||
-		    info->cursor.image.bg_color != bg) {
-			cursor.image.fg_color = fg;
-			cursor.image.bg_color = bg;
-			cursor.set |= FB_CUR_SETCMAP;
-		}
-		
-		if ((info->cursor.image.dx != (vc->vc_font.width * vc->vc_x)) ||
-		    (info->cursor.image.dy != (vc->vc_font.height * y))) {
-			cursor.image.dx = vc->vc_font.width * vc->vc_x;
-			cursor.image.dy = vc->vc_font.height * y;
-			cursor.set |= FB_CUR_SETPOS;
-		}
-
-		if (info->cursor.image.height != vc->vc_font.height ||
-		    info->cursor.image.width != vc->vc_font.width) {
-			cursor.image.height = vc->vc_font.height;
-			cursor.image.width = vc->vc_font.width;
-			cursor.set |= FB_CUR_SETSIZE;
-		}
-
-		if (info->cursor.hot.x || info->cursor.hot.y) {
-			cursor.hot.x = cursor.hot.y = 0;
-			cursor.set |= FB_CUR_SETHOT;
-		}
-
-		if ((cursor.set & FB_CUR_SETSIZE) ||
-		    ((vc->vc_cursor_type & 0x0f) != p->cursor_shape)
-		    || info->cursor.mask == NULL) {
-			char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC);
-			int cur_height, size, i = 0;
-			u8 msk = 0xff;
-
-			if (!mask)
-				return;
-		
-			if (info->cursor.mask)
-				kfree(info->cursor.mask);
-			info->cursor.mask = mask;
-			p->cursor_shape = vc->vc_cursor_type & 0x0f;
-			cursor.set |= FB_CUR_SETSHAPE;
-
-			switch (vc->vc_cursor_type & 0x0f) {
-			case CUR_NONE:
-				cur_height = 0;
-				break;
-			case CUR_UNDERLINE:
-				cur_height = (vc->vc_font.height < 10) ? 1 : 2;
-				break;
-			case CUR_LOWER_THIRD:
-				cur_height = vc->vc_font.height/3;
-				break;
-			case CUR_LOWER_HALF:
-				cur_height = vc->vc_font.height >> 1;
-				break;
-			case CUR_TWO_THIRDS:
-				cur_height = (vc->vc_font.height << 1)/3;
-				break;
-			case CUR_BLOCK:
-			default:
-				cur_height = vc->vc_font.height;
-				break;
-			}
-			size = (vc->vc_font.height - cur_height) * w;
-			while (size--)
-				mask[i++] = ~msk;
-			size = cur_height * w;
-			while (size--)
-				mask[i++] = msk;
-		}
-        	info->cursor.rop = ROP_XOR;
-		info->fbops->fb_cursor(info, &cursor);
-		vbl_cursor_cnt = CURSOR_DRAW_DELAY;
-		break;
-	}
+	ops->cursor(vc, info, p, mode, get_color(vc, info, c, 1),
+		    get_color(vc, info, c, 0));
+	vbl_cursor_cnt = CURSOR_DRAW_DELAY;
 }
 
 static int scrollback_phys_max = 0;
@@ -1259,15 +1116,34 @@
 
 int update_var(int con, struct fb_info *info)
 {
-	if (con == info->currcon) 
+	if (con == ((struct fbcon_ops *)info->fbcon_par)->currcon)
 		return fb_pan_display(info, &info->var);
 	return 0;
 }
 
+/*
+ * If no vc is existent yet, just set struct display
+ */
+static void fbcon_preset_disp(struct fb_info *info, int unit)
+{
+	struct display *p = &fb_display[unit];
+	struct display *t = &fb_display[fg_console];
+
+	info->var.xoffset = info->var.yoffset = p->yscroll = 0;
+	if (var_to_display(p, &info->var, info))
+		return;
+
+	p->fontdata = t->fontdata;
+	p->userfont = t->userfont;
+	if (p->userfont)
+		REFCOUNT(p->fontdata)++;
+}
+
 static void fbcon_set_disp(struct fb_info *info, struct vc_data *vc)
 {
 	struct display *p = &fb_display[vc->vc_num], *t;
 	struct vc_data **default_mode = vc->vc_display_fg;
+	struct vc_data *svc = *default_mode;
 	int display_fg = (*default_mode)->vc_num;
 	int rows, cols, charcnt = 256;
 
@@ -1282,7 +1158,6 @@
 		p->userfont = t->userfont;
 		if (p->userfont)
 			REFCOUNT(p->fontdata)++;
-		con_copy_unimap(vc->vc_num, display_fg);
 	}
 	if (p->userfont)
 		charcnt = FNTCHARCNT(p->fontdata);
@@ -1296,6 +1171,12 @@
 		if (vc->vc_can_do_color)
 			vc->vc_complement_mask <<= 1;
 	}
+
+	if (!*svc->vc_uni_pagedir_loc)
+		con_set_default_unimap(display_fg);
+	if (!*vc->vc_uni_pagedir_loc)
+		con_copy_unimap(vc->vc_num, display_fg);
+
 	cols = info->var.xres / vc->vc_font.width;
 	rows = info->var.yres / vc->vc_font.height;
 	vc_resize(vc->vc_num, cols, rows);
@@ -1314,12 +1195,11 @@
 			}
 		}
 	}
-	switch_screen(fg_console);
 }
 
 static __inline__ void ywrap_up(struct vc_data *vc, int count)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
 	
 	p->yscroll += count;
@@ -1337,7 +1217,7 @@
 
 static __inline__ void ywrap_down(struct vc_data *vc, int count)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
 	
 	p->yscroll -= count;
@@ -1355,20 +1235,21 @@
 
 static __inline__ void ypan_up(struct vc_data *vc, int count)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
-	
+	struct fbcon_ops *ops = info->fbcon_par;
+
 	p->yscroll += count;
 	if (p->yscroll > p->vrows - vc->vc_rows) {
-		accel_bmove(vc, info, p->vrows - vc->vc_rows, 
-			 	0, 0, 0, vc->vc_rows, vc->vc_cols);
+		ops->bmove(vc, info, p->vrows - vc->vc_rows,
+			    0, 0, 0, vc->vc_rows, vc->vc_cols);
 		p->yscroll -= p->vrows - vc->vc_rows;
 	}
 	info->var.xoffset = 0;
 	info->var.yoffset = p->yscroll * vc->vc_font.height;
 	info->var.vmode &= ~FB_VMODE_YWRAP;
 	update_var(vc->vc_num, info);
-	accel_clear_margins(vc, info, 1);
+	fbcon_clear_margins(vc, 1);
 	scrollback_max += count;
 	if (scrollback_max > scrollback_phys_max)
 		scrollback_max = scrollback_phys_max;
@@ -1377,7 +1258,7 @@
 
 static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
 	int redraw = 0;
 
@@ -1393,7 +1274,7 @@
 	if (redraw)
 		fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t);
 	update_var(vc->vc_num, info);
-	accel_clear_margins(vc, info, 1);
+	fbcon_clear_margins(vc, 1);
 	scrollback_max += count;
 	if (scrollback_max > scrollback_phys_max)
 		scrollback_max = scrollback_phys_max;
@@ -1402,20 +1283,21 @@
 
 static __inline__ void ypan_down(struct vc_data *vc, int count)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
+	struct fbcon_ops *ops = info->fbcon_par;
 	
 	p->yscroll -= count;
 	if (p->yscroll < 0) {
-		accel_bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,
-			 	0, vc->vc_rows, vc->vc_cols);
+		ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,
+			    0, vc->vc_rows, vc->vc_cols);
 		p->yscroll += p->vrows - vc->vc_rows;
 	}
 	info->var.xoffset = 0;
 	info->var.yoffset = p->yscroll * vc->vc_font.height;
 	info->var.vmode &= ~FB_VMODE_YWRAP;
 	update_var(vc->vc_num, info);
-	accel_clear_margins(vc, info, 1);
+	fbcon_clear_margins(vc, 1);
 	scrollback_max -= count;
 	if (scrollback_max < 0)
 		scrollback_max = 0;
@@ -1424,7 +1306,7 @@
 
 static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
 	int redraw = 0;
 
@@ -1439,7 +1321,7 @@
 	if (redraw)
 		fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count);
 	update_var(vc->vc_num, info);
-	accel_clear_margins(vc, info, 1);
+	fbcon_clear_margins(vc, 1);
 	scrollback_max -= count;
 	if (scrollback_max < 0)
 		scrollback_max = 0;
@@ -1449,7 +1331,6 @@
 static void fbcon_redraw_softback(struct vc_data *vc, struct display *p,
 				  long delta)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
 	int count = vc->vc_rows;
 	unsigned short *d, *s;
 	unsigned long n;
@@ -1506,16 +1387,16 @@
 			if (attr != (c & 0xff00)) {
 				attr = c & 0xff00;
 				if (s > start) {
-					accel_putcs(vc, info, start, s - start,
-						    real_y(p, line), x);
+					fbcon_putcs(vc, start, s - start,
+						    line, x);
 					x += s - start;
 					start = s;
 				}
 			}
 			if (c == scr_readw(d)) {
 				if (s > start) {
-					accel_putcs(vc, info, start, s - start,
-						    real_y(p, line), x);
+					fbcon_putcs(vc, start, s - start,
+						    line, x);
 					x += s - start + 1;
 					start = s + 1;
 				} else {
@@ -1527,8 +1408,7 @@
 			d++;
 		} while (s < le);
 		if (s > start)
-			accel_putcs(vc, info, start, s - start,
-				    real_y(p, line), x);
+			fbcon_putcs(vc, start, s - start, line, x);
 		line++;
 		if (d == (u16 *) softback_end)
 			d = (u16 *) softback_buf;
@@ -1544,7 +1424,6 @@
 static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
 			      int line, int count, int dy)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
 	unsigned short *s = (unsigned short *)
 		(vc->vc_origin + vc->vc_size_row * line);
 
@@ -1560,8 +1439,8 @@
 			if (attr != (c & 0xff00)) {
 				attr = c & 0xff00;
 				if (s > start) {
-					accel_putcs(vc, info, start, s - start,
-						    real_y(p, dy), x);
+					fbcon_putcs(vc, start, s - start,
+						    dy, x);
 					x += s - start;
 					start = s;
 				}
@@ -1570,8 +1449,7 @@
 			s++;
 		} while (s < le);
 		if (s > start)
-			accel_putcs(vc, info, start, s - start,
-				    real_y(p, dy), x);
+			fbcon_putcs(vc, start, s - start, dy, x);
 		console_conditional_schedule();
 		dy++;
 	}
@@ -1582,7 +1460,6 @@
 {
 	unsigned short *d = (unsigned short *)
 	    (vc->vc_origin + vc->vc_size_row * line);
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
 	unsigned short *s = d + offset;
 
 	while (count--) {
@@ -1597,16 +1474,16 @@
 			if (attr != (c & 0xff00)) {
 				attr = c & 0xff00;
 				if (s > start) {
-					accel_putcs(vc, info, start, s - start,
-						    real_y(p, line), x);
+					fbcon_putcs(vc, start, s - start,
+						    line, x);
 					x += s - start;
 					start = s;
 				}
 			}
 			if (c == scr_readw(d)) {
 				if (s > start) {
-					accel_putcs(vc, info, start, s - start,
-						    real_y(p, line), x);
+					fbcon_putcs(vc, start, s - start,
+						     line, x);
 					x += s - start + 1;
 					start = s + 1;
 				} else {
@@ -1620,8 +1497,7 @@
 			d++;
 		} while (s < le);
 		if (s > start)
-			accel_putcs(vc, info, start, s - start,
-				    real_y(p, line), x);
+			fbcon_putcs(vc, start, s - start, line, x);
 		console_conditional_schedule();
 		if (offset > 0)
 			line++;
@@ -1662,15 +1538,13 @@
 static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
 			int count)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
+	struct fbcon_ops *ops = info->fbcon_par;
 	int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
 
-	if (!info->fbops->fb_blank && console_blanked)
-		return 0;
-
-	if (!count || vt_cons[vc->vc_num]->vc_mode != KD_TEXT)
-		return 0;
+	if (fbcon_is_inactive(vc, info))
+		return -EINVAL;
 
 	fbcon_cursor(vc, CM_ERASE);
 
@@ -1690,10 +1564,10 @@
 			goto redraw_up;
 		switch (p->scrollmode) {
 		case SCROLL_MOVE:
-			accel_bmove(vc, info, t + count, 0, t, 0,
-					 b - t - count, vc->vc_cols);
-			accel_clear(vc, info, b - count, 0, count,
-					 vc->vc_cols);
+			ops->bmove(vc, info, t + count, 0, t, 0,
+				    b - t - count, vc->vc_cols);
+			ops->clear(vc, info, b - count, 0, count,
+				  vc->vc_cols);
 			break;
 
 		case SCROLL_WRAP_MOVE:
@@ -1759,8 +1633,7 @@
 		      redraw_up:
 			fbcon_redraw(vc, p, t, b - t - count,
 				     count * vc->vc_cols);
-			accel_clear(vc, info, real_y(p, b - count), 0,
-					 count, vc->vc_cols);
+			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
 			scr_memsetw((unsigned short *) (vc->vc_origin +
 							vc->vc_size_row *
 							(b - count)),
@@ -1775,9 +1648,9 @@
 			count = vc->vc_rows;
 		switch (p->scrollmode) {
 		case SCROLL_MOVE:
-			accel_bmove(vc, info, t, 0, t + count, 0,
-					 b - t - count, vc->vc_cols);
-			accel_clear(vc, info, t, 0, count, vc->vc_cols);
+			ops->bmove(vc, info, t, 0, t + count, 0,
+				    b - t - count, vc->vc_cols);
+			ops->clear(vc, info, t, 0, count, vc->vc_cols);
 			break;
 
 		case SCROLL_WRAP_MOVE:
@@ -1841,8 +1714,7 @@
 		      redraw_down:
 			fbcon_redraw(vc, p, b - 1, b - t - count,
 				     -count * vc->vc_cols);
-			accel_clear(vc, info, real_y(p, t), 0, count,
-					 vc->vc_cols);
+			fbcon_clear(vc, t, 0, count, vc->vc_cols);
 			scr_memsetw((unsigned short *) (vc->vc_origin +
 							vc->vc_size_row *
 							t),
@@ -1858,10 +1730,10 @@
 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
 			int height, int width)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
 	
-	if (!info->fbops->fb_blank && console_blanked)
+	if (fbcon_is_inactive(vc, info))
 		return;
 
 	if (!width || !height)
@@ -1881,7 +1753,8 @@
 static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx, 
 			    int dy, int dx, int height, int width, u_int y_break)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
+	struct fbcon_ops *ops = info->fbcon_par;
 	u_int b;
 
 	if (sy < y_break && sy + height > y_break) {
@@ -1915,8 +1788,8 @@
 		}
 		return;
 	}
-	accel_bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
-			height, width);
+	ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
+		   height, width);
 }
 
 static __inline__ void updatescrollmode(struct display *p, struct fb_info *info,
@@ -1958,7 +1831,7 @@
 static int fbcon_resize(struct vc_data *vc, unsigned int width, 
 			unsigned int height)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
 	struct fb_var_screeninfo var = info->var;
 	int x_diff, y_diff;
@@ -2010,10 +1883,12 @@
 
 static int fbcon_switch(struct vc_data *vc)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info;
 	struct display *p = &fb_display[vc->vc_num];
 	struct fb_var_screeninfo var;
-	int i;
+	int i, prev_console, do_set_par = 0;
+
+	info = registered_fb[con2fb_map[vc->vc_num]];
 
 	if (softback_top) {
 		int l = fbcon_softback_size / vc->vc_size_row;
@@ -2030,15 +1905,18 @@
 			softback_top = 0;
 		}
 	}
+
 	if (logo_shown >= 0) {
 		struct vc_data *conp2 = vc_cons[logo_shown].d;
 
 		if (conp2->vc_top == logo_lines
 		    && conp2->vc_bottom == conp2->vc_rows)
 			conp2->vc_top = 0;
-		logo_shown = -1;
+		logo_shown = FBCON_LOGO_CANSHOW;
 	}
 
+	prev_console = ((struct fbcon_ops *)info->fbcon_par)->currcon;
+
 	/*
 	 * FIXME: If we have multiple fbdev's loaded, we need to
 	 * update all info->currcon.  Perhaps, we can place this
@@ -2048,12 +1926,13 @@
 	 * info->currcon = vc->vc_num;
 	 */
 	for (i = 0; i < FB_MAX; i++) {
-		if (registered_fb[i] != NULL)
-			registered_fb[i]->currcon = vc->vc_num;
-	}
+		if (registered_fb[i] != NULL && registered_fb[i]->fbcon_par) {
+			struct fbcon_ops *ops = registered_fb[i]->fbcon_par;
 
+			ops->currcon = vc->vc_num;
+		}
+	}
 	memset(&var, 0, sizeof(struct fb_var_screeninfo));
-	fb_videomode_to_var(&var, p->mode);
 	display_to_var(&var, p);
 	var.activate = FB_ACTIVATE_NOW;
 
@@ -2065,12 +1944,19 @@
 	info->var.yoffset = info->var.xoffset = p->yscroll = 0;
 	fb_set_var(info, &var);
 
-	if (info->flags & FBINFO_MISC_MODESWITCH) {
+	if (prev_console != -1 &&
+	    registered_fb[con2fb_map[prev_console]] != info)
+		do_set_par = 1;
+
+	if (do_set_par || info->flags & FBINFO_MISC_MODESWITCH) {
 		if (info->fbops->fb_set_par)
 			info->fbops->fb_set_par(info);
 		info->flags &= ~FBINFO_MISC_MODESWITCH;
 	}
 
+	set_blitting_type(vc, info, p);
+	((struct fbcon_ops *)info->fbcon_par)->cursor_reset = 1;
+
 	vc->vc_can_do_color = (fb_get_color_depth(info) != 1);
 	vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
 	updatescrollmode(p, info, vc);
@@ -2094,10 +1980,10 @@
 
 	update_var(vc->vc_num, info);
 	fbcon_set_palette(vc, color_table); 	
+	fbcon_clear_margins(vc, 0);
+
+	if (logo_shown == FBCON_LOGO_DRAW) {
 
-	if (vt_cons[vc->vc_num]->vc_mode == KD_TEXT)
-		accel_clear_margins(vc, info, 0);
-	if (logo_shown == -2) {
 		logo_shown = fg_console;
 		/* This is protected above by initmem_freed */
 		fb_show_logo(info);
@@ -2110,15 +1996,52 @@
 	return 1;
 }
 
+static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
+				int blank)
+{
+	if (blank) {
+		if (info->fix.visual == FB_VISUAL_DIRECTCOLOR ||
+		    info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
+			struct fb_cmap cmap;
+			u16 *black;
+
+			black = kmalloc(sizeof(u16) * info->cmap.len,
+					GFP_KERNEL);
+			if (black) {
+				memset(black, 0, info->cmap.len * sizeof(u16));
+				cmap.red = cmap.green = cmap.blue = black;
+				cmap.transp = info->cmap.transp ? black : NULL;
+				cmap.start = info->cmap.start;
+				cmap.len = info->cmap.len;
+				fb_set_cmap(&cmap, info);
+			}
+
+			kfree(black);
+		} else {
+			unsigned short charmask = vc->vc_hi_font_mask ?
+				0x1ff : 0xff;
+			unsigned short oldc;
+
+			oldc = vc->vc_video_erase_char;
+			vc->vc_video_erase_char &= charmask;
+			fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
+			vc->vc_video_erase_char = oldc;
+		}
+	} else {
+		if (info->fix.visual == FB_VISUAL_DIRECTCOLOR ||
+		    info->fix.visual == FB_VISUAL_PSEUDOCOLOR)
+			fb_set_cmap(&info->cmap, info);
+	}
+}
+
 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
 {
-	unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
-	struct display *p = &fb_display[vc->vc_num];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
+	struct fbcon_ops *ops = info->fbcon_par;
+	int active = !fbcon_is_inactive(vc, info);
 
 	if (mode_switch) {
 		struct fb_var_screeninfo var = info->var;
-
 /*
  * HACK ALERT: Some hardware will require reinitializion at this stage,
  *             others will require it to be done as late as possible.
@@ -2131,44 +2054,29 @@
 		if (info->flags & FBINFO_MISC_MODESWITCHLATE)
 			info->flags |= FBINFO_MISC_MODESWITCH;
 
-		if (blank) {
-			fbcon_cursor(vc, CM_ERASE);
-			return 0;
-		}
-
-		if (!(info->flags & FBINFO_MISC_MODESWITCHLATE)) {
+		if (!blank && !(info->flags & FBINFO_MISC_MODESWITCHLATE)) {
 			var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
 			fb_set_var(info, &var);
 		}
 	}
 
-	fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
+ 	if (active) {
+ 		int ret = -1;
 
-	if (!info->fbops->fb_blank) {
-		if (blank) {
-			unsigned short oldc;
-			u_int height;
-			u_int y_break;
+ 		fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
+ 		ops->cursor_flash = (!blank);
 
-			oldc = vc->vc_video_erase_char;
-			vc->vc_video_erase_char &= charmask;
-			height = vc->vc_rows;
-			y_break = p->vrows - p->yscroll;
-			if (height > y_break) {
-				accel_clear(vc, info, real_y(p, 0),
-					    0, y_break, vc->vc_cols);
-				accel_clear(vc, info, real_y(p, y_break),
-					    0, height - y_break, 
-					    vc->vc_cols);
-			} else
-				accel_clear(vc, info, real_y(p, 0),
-					    0, height, vc->vc_cols);
-			vc->vc_video_erase_char = oldc;
-		} else
-			update_screen(vc->vc_num);
-		return 0;
-	} else
-		return fb_blank(info, blank);
+ 		if (info->fbops->fb_blank)
+ 			ret = info->fbops->fb_blank(blank, info);
+
+ 		if (ret)
+ 			fbcon_generic_blank(vc, info, blank);
+
+ 		if (!blank)
+  			update_screen(vc->vc_num);
+ 	}
+
+ 	return 0;
 }
 
 static void fbcon_free_font(struct display *p)
@@ -2233,7 +2141,7 @@
 static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
 			     u8 * data, int userfont)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct display *p = &fb_display[vc->vc_num];
 	int resize;
 	int cnt;
@@ -2329,7 +2237,7 @@
 		}
 	} else if (CON_IS_VISIBLE(vc)
 		   && vt_cons[vc->vc_num]->vc_mode == KD_TEXT) {
-		accel_clear_margins(vc, info, 0);
+		fbcon_clear_margins(vc, 0);
 		update_screen(vc->vc_num);
 	}
 
@@ -2352,6 +2260,12 @@
  *  User asked to set font; we are guaranteed that
  *	a) width and height are in range 1..32
  *	b) charcount does not exceed 512
+ *  but lets not assume that, since someone might someday want to use larger
+ *  fonts. And charcount of 512 is small for unicode support.
+ *
+ *  However, user space gives the font in 32 rows , regardless of
+ *  actual font height. So a new API is needed if support for larger fonts
+ *  is ever implemented.
  */
 
 static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags)
@@ -2359,20 +2273,17 @@
 	unsigned charcount = font->charcount;
 	int w = font->width;
 	int h = font->height;
-	int size = h;
-	int i, k;
-	u8 *new_data, *data = font->data, *p;
+	int size;
+	int i, csum;
+	u8 *new_data, *data = font->data;
+	int pitch = (font->width+7) >> 3;
 
+	/* Is there a reason why fbconsole couldn't handle any charcount >256?
+	 * If not this check should be changed to charcount < 256 */
 	if (charcount != 256 && charcount != 512)
 		return -EINVAL;
 
-	if (w > 8) {
-		if (w <= 16)
-			size *= 2;
-		else
-			size *= 4;
-	}
-	size *= charcount;
+	size = h * pitch * charcount;
 
 	new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
 
@@ -2383,55 +2294,22 @@
 	FNTSIZE(new_data) = size;
 	FNTCHARCNT(new_data) = charcount;
 	REFCOUNT(new_data) = 0;	/* usage counter */
-	p = new_data;
-	if (w <= 8) {
-		for (i = 0; i < charcount; i++) {
-			memcpy(p, data, h);
-			data += 32;
-			p += h;
-		}
-	} else if (w <= 16) {
-		h *= 2;
-		for (i = 0; i < charcount; i++) {
-			memcpy(p, data, h);
-			data += 64;
-			p += h;
-		}
-	} else if (w <= 24) {
-		for (i = 0; i < charcount; i++) {
-			int j;
-			for (j = 0; j < h; j++) {
-				memcpy(p, data, 3);
-				p[3] = 0;
-				data += 3;
-				p += sizeof(u32);
-			}
-			data += 3 * (32 - h);
-		}
-	} else {
-		h *= 4;
-		for (i = 0; i < charcount; i++) {
-			memcpy(p, data, h);
-			data += 128;
-			p += h;
-		}
+	for (i=0; i< charcount; i++) {
+		memcpy(new_data + i*h*pitch, data +  i*32*pitch, h*pitch);
 	}
-	/* we can do it in u32 chunks because of charcount is 256 or 512, so
-	   font length must be multiple of 256, at least. And 256 is multiple
-	   of 4 */
-	k = 0;
-	while (p > new_data) {
-		p = (u8 *)((u32 *)p - 1);
-		k += *(u32 *) p;
-	}
-	FNTSUM(new_data) = k;
+
+	/* Since linux has a nice crc32 function use it for counting font
+	 * checksums. */
+	csum = crc32(0, new_data, size);
+
+	FNTSUM(new_data) = csum;
 	/* Check if the same font is on some other console already */
 	for (i = 0; i < MAX_NR_CONSOLES; i++) {
 		struct vc_data *tmp = vc_cons[i].d;
 		
 		if (fb_display[i].userfont &&
 		    fb_display[i].fontdata &&
-		    FNTSUM(fb_display[i].fontdata) == k &&
+		    FNTSUM(fb_display[i].fontdata) == csum &&
 		    FNTSIZE(fb_display[i].fontdata) == size &&
 		    tmp->vc_font.width == w &&
 		    !memcmp(fb_display[i].fontdata, new_data, size)) {
@@ -2445,7 +2323,7 @@
 
 static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct font_desc *f;
 
 	if (!name)
@@ -2468,12 +2346,13 @@
 
 static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
+	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	int i, j, k, depth;
 	u8 val;
 
-	if (!info->fbops->fb_blank && console_blanked)
+	if (fbcon_is_inactive(vc, info))
 		return -EINVAL;
+
 	depth = fb_get_color_depth(info);
 	if (depth > 3) {
 		for (i = j = 0; i < 16; i++) {
@@ -2577,7 +2456,7 @@
 
 static int fbcon_scrolldelta(struct vc_data *vc, int lines)
 {
-	struct fb_info *info = registered_fb[(int) con2fb_map[fg_console]];
+	struct fb_info *info = registered_fb[con2fb_map[fg_console]];
 	struct display *p = &fb_display[fg_console];
 	int offset, limit, scrollback_old;
 
@@ -2613,7 +2492,7 @@
 				update_region(vc->vc_num, vc->vc_origin,
 					      logo_lines * vc->vc_cols);
 			}
-			logo_shown = -1;
+			logo_shown = FBCON_LOGO_CANSHOW;
 		}
 		fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK);
 		fbcon_redraw_softback(vc, p, lines);
@@ -2633,10 +2512,9 @@
 	if (scrollback_current == scrollback_old)
 		return 0;
 
-	if (!info->fbops->fb_blank &&
-	    (console_blanked || vt_cons[vc->vc_num]->vc_mode != KD_TEXT
-	     || !lines))
+	if (fbcon_is_inactive(vc, info))
 		return 0;
+
 	fbcon_cursor(vc, CM_ERASE);
 
 	offset = p->yscroll - scrollback_current;
@@ -2665,36 +2543,49 @@
 
 static int fbcon_set_origin(struct vc_data *vc)
 {
-	if (softback_lines && !console_blanked)
+	if (softback_lines)
 		fbcon_scrolldelta(vc, softback_lines);
 	return 0;
 }
 
 static void fbcon_suspended(struct fb_info *info)
 {
+	struct vc_data *vc = NULL;
+	struct fbcon_ops *ops = info->fbcon_par;
+
+	if (!ops || ops->currcon < 0)
+		return;
+	vc = vc_cons[ops->currcon].d;
+
 	/* Clear cursor, restore saved data */
-	info->cursor.enable = 0;
-	info->fbops->fb_cursor(info, &info->cursor);
+	fbcon_cursor(vc, CM_ERASE);
 }
 
 static void fbcon_resumed(struct fb_info *info)
 {
 	struct vc_data *vc;
+	struct fbcon_ops *ops = info->fbcon_par;
 
-	if (info->currcon < 0)
+	if (!ops || ops->currcon < 0)
 		return;
-	vc = vc_cons[info->currcon].d;
+	vc = vc_cons[ops->currcon].d;
 
 	update_screen(vc->vc_num);
 }
 
 static void fbcon_modechanged(struct fb_info *info)
 {
-	struct vc_data *vc = vc_cons[info->currcon].d;
+	struct fbcon_ops *ops = info->fbcon_par;
+	struct vc_data *vc;
 	struct display *p;
 	int rows, cols;
 
-	if (info->currcon < 0 || vt_cons[info->currcon]->vc_mode !=
+	if (!ops)
+		return;
+
+	vc = vc_cons[ops->currcon].d;
+
+	if (ops->currcon < 0 || vt_cons[ops->currcon]->vc_mode !=
 	    KD_TEXT)
 		return;
 	p = &fb_display[vc->vc_num];
@@ -2734,7 +2625,7 @@
 
 	/* before deletion, ensure that mode is not in use */
 	for (i = first_fb_vc; i <= last_fb_vc; i++) {
-		j = (int) con2fb_map[i];
+		j = con2fb_map[i];
 		if (j == -1)
 			continue;
 		fb_info = registered_fb[j];
@@ -2753,11 +2644,22 @@
 
 static int fbcon_fb_registered(int idx)
 {
-	int ret = 0;
+	int ret = 0, i;
 
 	if (info_idx == -1) {
-		info_idx = idx;
-		ret = fbcon_takeover();
+		for (i = 0; i < MAX_NR_CONSOLES; i++) {
+			if (con2fb_map_boot[i] == idx) {
+				info_idx = idx;
+				break;
+			}
+		}
+		if (info_idx != -1)
+			ret = fbcon_takeover(1);
+	} else {
+		for (i = 0; i < MAX_NR_CONSOLES; i++) {
+			if (con2fb_map_boot[i] == idx)
+				set_con2fb_map(i, idx, 0);
+		}
 	}
 
 	return ret;
@@ -2766,7 +2668,7 @@
 static int fbcon_event_notify(struct notifier_block *self, 
 			      unsigned long action, void *data)
 {
-	struct fb_event *event = (struct fb_event *) data;
+	struct fb_event *event = data;
 	struct fb_info *info = event->info;
 	struct fb_videomode *mode;
 	struct fb_con2fbmap *con2fb;
@@ -2783,18 +2685,19 @@
 		fbcon_modechanged(info);
 		break;
 	case FB_EVENT_MODE_DELETE:
-		mode = (struct fb_videomode *) event->data;
+		mode = event->data;
 		ret = fbcon_mode_deleted(info, mode);
 		break;
 	case FB_EVENT_FB_REGISTERED:
 		ret = fbcon_fb_registered(info->node);
 		break;
 	case FB_EVENT_SET_CONSOLE_MAP:
-		con2fb = (struct fb_con2fbmap *) event->data;
-		ret = set_con2fb_map(con2fb->console - 1, con2fb->framebuffer);
+		con2fb = event->data;
+		ret = set_con2fb_map(con2fb->console - 1,
+				     con2fb->framebuffer, 1);
 		break;
 	case FB_EVENT_GET_CONSOLE_MAP:
-		con2fb = (struct fb_con2fbmap *) event->data;
+		con2fb = event->data;
 		con2fb->framebuffer = con2fb_map[con2fb->console - 1];
 		break;
 	}
@@ -2854,7 +2757,7 @@
 				break;
 			}
 		}
-		fbcon_takeover();
+		fbcon_takeover(0);
 	}
 
 	return 0;
@@ -2880,7 +2783,6 @@
  *  Visible symbols for modules
  */
 
-EXPORT_SYMBOL(fb_display);
 EXPORT_SYMBOL(fb_con);
 
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
--- a/drivers/video/console/fbcon.h	2004-12-24 13:37:03 -08:00
+++ b/drivers/video/console/fbcon.h	2004-12-24 13:37:03 -08:00
@@ -48,6 +48,26 @@
     struct fb_videomode *mode;
 };
 
+struct fbcon_ops {
+	void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
+		      int sx, int dy, int dx, int height, int width);
+	void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
+		      int sx, int height, int width);
+	void (*putcs)(struct vc_data *vc, struct fb_info *info,
+		      const unsigned short *s, int count, int yy, int xx,
+		      int fg, int bg);
+	void (*clear_margins)(struct vc_data *vc, struct fb_info *info,
+			      int bottom_only);
+	void (*cursor)(struct vc_data *vc, struct fb_info *info,
+		       struct display *p, int mode, int fg, int bg);
+
+	struct timer_list cursor_timer; /* Cursor timer */
+	struct fb_cursor cursor_state;
+        int    currcon;	                /* Current VC. */
+	int    cursor_flash;
+	int    cursor_reset;
+	char  *cursor_data;
+};
     /*
      *  Attribute Decoding
      */
@@ -72,6 +92,13 @@
 #define attr_blink(s) \
 	((s) & 0x8000)
 	
+/* Font */
+#define REFCOUNT(fd)	(((int *)(fd))[-1])
+#define FNTSIZE(fd)	(((int *)(fd))[-2])
+#define FNTCHARCNT(fd)	(((int *)(fd))[-3])
+#define FNTSUM(fd)	(((int *)(fd))[-4])
+#define FONT_EXTRA_WORDS 4
+
     /*
      *  Scroll Method
      */
@@ -129,5 +156,9 @@
 #define SCROLL_PAN_REDRAW  0x005
 
 extern int fb_console_init(void);
-
+#ifdef CONFIG_FB_TILEBLITTING
+extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info,
+			      struct display *p, struct fbcon_ops *ops);
+#endif
+extern void fbcon_set_bitops(struct fbcon_ops *ops);
 #endif /* _VIDEO_FBCON_H */
diff -Nru a/drivers/video/console/font_6x11.c b/drivers/video/console/font_6x11.c
--- a/drivers/video/console/font_6x11.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/video/console/font_6x11.c	2004-12-24 13:36:18 -08:00
@@ -10,7 +10,7 @@
 
 static unsigned char fontdata_6x11[FONTDATAMAX] = {
 
-	/* 0 0x00 '^A' */
+	/* 0 0x00 '^@' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -23,405 +23,405 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 1 0x01 '^B' */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 1 0x01 '^A' */
 	0x00, /* 00000000 */
+	0x78, /* 0    000 */
+	0x84, /*  0000 00 */
+	0xcc, /*   00  00 */
+	0x84, /*  0000 00 */
+	0xb4, /*  0  0 00 */
+	0x84, /*  0000 00 */
+	0x78, /* 0    000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 2 0x02 '^C' */
-	0x00, /* 00000000 */
+	/* 2 0x02 '^B' */
 	0x00, /* 00000000 */
+	0x78, /* 0    000 */
+	0xfc, /*       00 */
+	0xb4, /*  0  0 00 */
+	0xfc, /*       00 */
+	0xcc, /*   00  00 */
+	0xfc, /*       00 */
+	0x78, /* 0    000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+
+	/* 3 0x03 '^C' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x28, /* 00 0 000 */
+	0x7c, /* 0     00 */
+	0x7c, /* 0     00 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 3 0x03 '^D' */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 4 0x04 '^D' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
+	0x7c, /* 0     00 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 4 0x04 '^E' */
-	0x00, /* 00000000 */
+	/* 5 0x05 '^E' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x38, /* 00   000 */
+	0x38, /* 00   000 */
+	0x6c, /* 0  0  00 */
+	0x6c, /* 0  0  00 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+
+	/* 6 0x06 '^F' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
+	0x7c, /* 0     00 */
+	0x7c, /* 0     00 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 5 0x05 '^F' */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 7 0x07 '^G' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x30, /* 00  0000 */
+	0x78, /* 0    000 */
+	0x30, /* 00  0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 6 0x06 '^G' */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
+	/* 8 0x08 '^H' */
+	0xff, /*          */
+	0xff, /*          */
+	0xff, /*          */
+	0xcf, /*   00     */
+	0x87, /*  0000    */
+	0xcf, /*   00     */
+	0xff, /*          */
+	0xff, /*          */
+	0xff, /*          */
+	0xff, /*          */
+	0xff, /*          */
+
+	/* 9 0x09 '^I' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 7 0x07 '^H' */
+	0x30, /* 00  0000 */
+	0x48, /* 0 00 000 */
+	0x84, /*  0000 00 */
+	0x48, /* 0 00 000 */
+	0x30, /* 00  0000 */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 8 0x08 '^I' */
+	/* 10 0x0a '^J' */
+	0xff, /*          */
+	0xff, /*          */
+	0xcf, /*   00     */
+	0xb7, /*  0  0    */
+	0x7b, /* 0    0   */
+	0xb7, /*  0  0    */
+	0xcf, /*   00     */
+	0xff, /*          */
+	0xff, /*          */
+	0xff, /*          */
+	0xff, /*          */
+
+	/* 11 0x0b '^K' */
 	0x00, /* 00000000 */
 	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x14, /* 000 0 00 */
+	0x20, /* 00 00000 */
+	0x78, /* 0    000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 9 0x09 '^J' */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 12 0x0c '^L' */
 	0x00, /* 00000000 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
+	0x7c, /* 0     00 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 10 0x0a '^K' */
+	/* 13 0x0d '^M' */
 	0x00, /* 00000000 */
 	0x3c, /* 00    00 */
+	0x24, /* 00 00 00 */
 	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x20, /* 00 00000 */
+	0x20, /* 00 00000 */
+	0xe0, /*    00000 */
+	0xc0, /*   000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 11 0x0b '^L' */
+	/* 14 0x0e '^N' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x7c, /* 0     00 */
+	0x44, /* 0 000 00 */
+	0x7c, /* 0     00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0xcc, /*   00  00 */
+	0xcc, /*   00  00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 12 0x0c '^M' */
+	/* 15 0x0f '^O' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x10, /* 000 0000 */
+	0x54, /* 0 0 0 00 */
+	0x38, /* 00   000 */
+	0x6c, /* 0  0  00 */
+	0x38, /* 00   000 */
+	0x54, /* 0 0 0 00 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 13 0x0d '^N' */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 16 0x10 '^P' */
 	0x00, /* 00000000 */
+	0x40, /* 0 000000 */
+	0x60, /* 0  00000 */
+	0x70, /* 0   0000 */
+	0x7c, /* 0     00 */
+	0x70, /* 0   0000 */
+	0x60, /* 0  00000 */
+	0x40, /* 0 000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+
+	/* 17 0x11 '^Q' */
 	0x00, /* 00000000 */
+	0x04, /* 00000 00 */
+	0x0c, /* 0000  00 */
+	0x1c, /* 000   00 */
+	0x7c, /* 0     00 */
+	0x1c, /* 000   00 */
+	0x0c, /* 0000  00 */
+	0x04, /* 00000 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 14 0x0e '^O' */
+	/* 18 0x12 '^R' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
+	0x54, /* 0 0 0 00 */
+	0x10, /* 000 0000 */
+	0x54, /* 0 0 0 00 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 15 0x0f '^P' */
+	/* 19 0x13 '^S' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
 	0x00, /* 00000000 */
+	0x48, /* 0 00 000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 16 0x10 '^Q' */
 	0x00, /* 00000000 */
+
+	/* 20 0x14 '^T' */
 	0x3c, /* 00    00 */
+	0x54, /* 0 0 0 00 */
+	0x54, /* 0 0 0 00 */
+	0x54, /* 0 0 0 00 */
 	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x14, /* 000 0 00 */
+	0x14, /* 000 0 00 */
+	0x14, /* 000 0 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 17 0x11 '^R' */
+	/* 21 0x15 '^U' */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x24, /* 00 00 00 */
+	0x50, /* 0 0 0000 */
+	0x48, /* 0 00 000 */
+	0x24, /* 00 00 00 */
+	0x14, /* 000 0 00 */
+	0x48, /* 0 00 000 */
+	0x44, /* 0 000 00 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
+
+	/* 22 0x16 '^V' */
 	0x00, /* 00000000 */
-	0x28, /* 00 0 000 */
-	0x54, /* 0 0 0 00 */
-	0x38, /* 00   000 */
-	0x54, /* 0 0 0 00 */
-	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 18 0x12 '^S' */
-	0x04, /* 00000 00 */
-	0x04, /* 00000 00 */
-	0x08, /* 0000 000 */
-	0x08, /* 0000 000 */
-	0x50, /* 0 0 0000 */
-	0x50, /* 0 0 0000 */
-	0x20, /* 00 00000 */
-	0x20, /* 00 00000 */
+	0xf8, /*      000 */
+	0xf8, /*      000 */
+	0xf8, /*      000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 19 0x13 '^T' */
-	0x00, /* 00000000 */
+	/* 23 0x17 '^W' */
 	0x00, /* 00000000 */
 	0x10, /* 000 0000 */
 	0x38, /* 00   000 */
-	0x7c, /* 0     00 */
-	0x38, /* 00   000 */
+	0x54, /* 0 0 0 00 */
 	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 20 0x14 '^U' */
-	0x18, /* 000  000 */
+	0x54, /* 0 0 0 00 */
+	0x38, /* 00   000 */
 	0x10, /* 000 0000 */
-	0x28, /* 00 0 000 */
 	0x7c, /* 0     00 */
-	0x78, /* 0    000 */
-	0x78, /* 0    000 */
-	0x7c, /* 0     00 */
-	0x28, /* 00 0 000 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 21 0x15 '^V' */
+	/* 24 0x18 '^X' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
+	0x54, /* 0 0 0 00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 22 0x16 '^W' */
+	/* 25 0x19 '^Y' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x54, /* 0 0 0 00 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 23 0x17 '^X' */
+	/* 26 0x1a '^Z' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x08, /* 0000 000 */
+	0x7c, /* 0     00 */
+	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 24 0x18 '^Y' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
+
+	/* 27 0x1b '^[' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 25 0x19 '^Z' */
+	0x10, /* 000 0000 */
+	0x20, /* 00 00000 */
+	0x7c, /* 0     00 */
+	0x20, /* 00 00000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 26 0x1a '^[' */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	/* 28 0x1c '^\' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 27 0x1b '^\' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
+	0x78, /* 0    000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 28 0x1c '^]' */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
+	/* 29 0x1d '^]' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 29 0x1d '^^' */
+	0x48, /* 0 00 000 */
+	0x84, /*  0000 00 */
+	0xfc, /*       00 */
+	0x84, /*  0000 00 */
+	0x48, /* 0 00 000 */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 30 0x1e '^_' */
+	/* 30 0x1e '^^' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
+	0x38, /* 00   000 */
+	0x7c, /* 0     00 */
+	0x7c, /* 0     00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 31 0x1f '^`' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x7c, /* 0     00 */
+	0x7c, /* 0     00 */
+	0x38, /* 00   000 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -467,16 +467,16 @@
 
 	/* 35 0x23 '#' */
 	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x28, /* 00 0 000 */
 	0x7c, /* 0     00 */
 	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 	0x7c, /* 0     00 */
 	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
 
 	/* 36 0x24 '$' */
 	0x10, /* 000 0000 */
@@ -493,13 +493,13 @@
 
 	/* 37 0x25 '%' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x54, /* 0 0 0 00 */
-	0x58, /* 0 0  000 */
-	0x28, /* 00 0 000 */
-	0x34, /* 00  0 00 */
-	0x54, /* 0 0 0 00 */
-	0x48, /* 0 00 000 */
+	0x64, /* 0  00 00 */
+	0x64, /* 0  00 00 */
+	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
+	0x20, /* 00 00000 */
+	0x4c, /* 0 00  00 */
+	0x4c, /* 0 00  00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -1610,6 +1610,7 @@
 	0x00, /* 00000000 */
 
 	/* 123 0x7b '{' */
+	0x04, /* 00000 00 */
 	0x08, /* 0000 000 */
 	0x08, /* 0000 000 */
 	0x08, /* 0000 000 */
@@ -1620,7 +1621,6 @@
 	0x08, /* 0000 000 */
 	0x08, /* 0000 000 */
 	0x04, /* 00000 00 */
-	0x00, /* 00000000 */
 
 	/* 124 0x7c '|' */
 	0x10, /* 000 0000 */
@@ -1636,6 +1636,7 @@
 	0x00, /* 00000000 */
 
 	/* 125 0x7d '}' */
+	0x20, /* 00 00000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
@@ -1646,7 +1647,6 @@
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x20, /* 00 00000 */
-	0x00, /* 00000000 */
 
 	/* 126 0x7e '~' */
 	0x00, /* 00000000 */
@@ -1665,42 +1665,16 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 128 0x80 '\200' */
-	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x7c, /* 0     00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 129 0x81 '\201' */
+	0x10, /* 000 0000 */
 	0x28, /* 00 0 000 */
-	0x38, /* 00   000 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
 	0x7c, /* 0     00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 130 0x82 '\202' */
+	/* 128 0x80 '\200' */
 	0x00, /* 00000000 */
 	0x38, /* 00   000 */
 	0x44, /* 0 000 00 */
@@ -1709,89 +1683,37 @@
 	0x40, /* 0 000000 */
 	0x44, /* 0 000 00 */
 	0x38, /* 00   000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 131 0x83 '\203' */
 	0x10, /* 000 0000 */
-	0x7c, /* 0     00 */
-	0x40, /* 0 000000 */
-	0x40, /* 0 000000 */
-	0x78, /* 0    000 */
-	0x40, /* 0 000000 */
-	0x40, /* 0 000000 */
-	0x7c, /* 0     00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 132 0x84 '\204' */
-	0x58, /* 0 0  000 */
-	0x44, /* 0 000 00 */
-	0x64, /* 0  00 00 */
-	0x54, /* 0 0 0 00 */
-	0x4c, /* 0 00  00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x20, /* 00 00000 */
 	0x00, /* 00000000 */
 
-	/* 133 0x85 '\205' */
-	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x38, /* 00   000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 129 0x81 '\201' */
 	0x00, /* 00000000 */
-
-	/* 134 0x86 '\206' */
+	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x38, /* 00   000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 135 0x87 '\207' */
-	0x08, /* 0000 000 */
-	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
 	0x4c, /* 0 00  00 */
 	0x34, /* 00  0 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 136 0x88 '\210' */
-	0x10, /* 000 0000 */
+	/* 130 0x82 '\202' */
 	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x44, /* 0 000 00 */
+	0x38, /* 00   000 */
 	0x44, /* 0 000 00 */
-	0x4c, /* 0 00  00 */
-	0x34, /* 00  0 00 */
+	0x7c, /* 0     00 */
+	0x40, /* 0 000000 */
+	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 137 0x89 '\211' */
+	/* 131 0x83 '\203' */
 	0x10, /* 000 0000 */
 	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
@@ -1804,7 +1726,7 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 138 0x8a '\212' */
+	/* 132 0x84 '\204' */
 	0x00, /* 00000000 */
 	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
@@ -1817,9 +1739,9 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 139 0x8b '\213' */
-	0x34, /* 00  0 00 */
-	0x58, /* 0 0  000 */
+	/* 133 0x85 '\205' */
+	0x10, /* 000 0000 */
+	0x08, /* 0000 000 */
 	0x00, /* 00000000 */
 	0x3c, /* 00    00 */
 	0x44, /* 0 000 00 */
@@ -1830,7 +1752,7 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 140 0x8c '\214' */
+	/* 134 0x86 '\206' */
 	0x18, /* 000  000 */
 	0x24, /* 00 00 00 */
 	0x18, /* 000  000 */
@@ -1843,7 +1765,7 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 141 0x8d '\215' */
+	/* 135 0x87 '\207' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -1856,9 +1778,9 @@
 	0x20, /* 00 00000 */
 	0x00, /* 00000000 */
 
-	/* 142 0x8e '\216' */
-	0x08, /* 0000 000 */
+	/* 136 0x88 '\210' */
 	0x10, /* 000 0000 */
+	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x38, /* 00   000 */
 	0x44, /* 0 000 00 */
@@ -1869,9 +1791,9 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 143 0x8f '\217' */
-	0x20, /* 00 00000 */
-	0x10, /* 000 0000 */
+	/* 137 0x89 '\211' */
+	0x00, /* 00000000 */
+	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x38, /* 00   000 */
 	0x44, /* 0 000 00 */
@@ -1882,9 +1804,9 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 144 0x90 '\220' */
+	/* 138 0x8a '\212' */
+	0x20, /* 00 00000 */
 	0x10, /* 000 0000 */
-	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x38, /* 00   000 */
 	0x44, /* 0 000 00 */
@@ -1895,23 +1817,10 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 145 0x91 '\221' */
+	/* 139 0x8b '\213' */
 	0x00, /* 00000000 */
 	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x7c, /* 0     00 */
-	0x40, /* 0 000000 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 146 0x92 '\222' */
-	0x08, /* 0000 000 */
-	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
@@ -1921,9 +1830,9 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 147 0x93 '\223' */
-	0x20, /* 00 00000 */
+	/* 140 0x8c '\214' */
 	0x10, /* 000 0000 */
+	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
@@ -1934,9 +1843,9 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 148 0x94 '\224' */
+	/* 141 0x8d '\215' */
+	0x20, /* 00 00000 */
 	0x10, /* 000 0000 */
-	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
@@ -1947,25 +1856,25 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 149 0x95 '\225' */
-	0x00, /* 00000000 */
-	0x28, /* 00 0 000 */
-	0x00, /* 00000000 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
+	/* 142 0x8e '\216' */
+	0x84, /*  0000 00 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x7c, /* 0     00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 150 0x96 '\226' */
-	0x34, /* 00  0 00 */
-	0x58, /* 0 0  000 */
-	0x00, /* 00000000 */
+	/* 143 0x8f '\217' */
 	0x58, /* 0 0  000 */
-	0x64, /* 0  00 00 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x7c, /* 0     00 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
@@ -1973,33 +1882,46 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 151 0x97 '\227' */
-	0x08, /* 0000 000 */
+	/* 144 0x90 '\220' */
 	0x10, /* 000 0000 */
+	0x7c, /* 0     00 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
+	0x78, /* 0    000 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
+	0x7c, /* 0     00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+
+	/* 145 0x91 '\221' */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x38, /* 00   000 */
+	0x54, /* 0 0 0 00 */
+	0x5c, /* 0 0   00 */
+	0x50, /* 0 0 0000 */
+	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 152 0x98 '\230' */
-	0x20, /* 00 00000 */
-	0x10, /* 000 0000 */
+	/* 146 0x92 '\222' */
 	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x38, /* 00   000 */
+	0x3c, /* 00    00 */
+	0x50, /* 0 0 0000 */
+	0x50, /* 0 0 0000 */
+	0x78, /* 0    000 */
+	0x50, /* 0 0 0000 */
+	0x50, /* 0 0 0000 */
+	0x5c, /* 0 0   00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 153 0x99 '\231' */
+	/* 147 0x93 '\223' */
 	0x10, /* 000 0000 */
 	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
@@ -2012,7 +1934,7 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 154 0x9a '\232' */
+	/* 148 0x94 '\224' */
 	0x00, /* 00000000 */
 	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
@@ -2025,9 +1947,9 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 155 0x9b '\233' */
-	0x34, /* 00  0 00 */
-	0x58, /* 0 0  000 */
+	/* 149 0x95 '\225' */
+	0x20, /* 00 00000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x38, /* 00   000 */
 	0x44, /* 0 000 00 */
@@ -2038,9 +1960,9 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 156 0x9c '\234' */
-	0x08, /* 0000 000 */
+	/* 150 0x96 '\226' */
 	0x10, /* 000 0000 */
+	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
@@ -2051,7 +1973,7 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 157 0x9d '\235' */
+	/* 151 0x97 '\227' */
 	0x20, /* 00 00000 */
 	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
@@ -2064,59 +1986,46 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 158 0x9e '\236' */
-	0x10, /* 000 0000 */
+	/* 152 0x98 '\230' */
+	0x00, /* 00000000 */
 	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
-	0x4c, /* 0 00  00 */
-	0x34, /* 00  0 00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x44, /* 0 000 00 */
+	0x3c, /* 00    00 */
+	0x04, /* 00000 00 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 
-	/* 159 0x9f '\237' */
-	0x00, /* 00000000 */
-	0x28, /* 00 0 000 */
-	0x00, /* 00000000 */
+	/* 153 0x99 '\231' */
+	0x84, /*  0000 00 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
-	0x4c, /* 0 00  00 */
-	0x34, /* 00  0 00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 160 0xa0 '\240' */
-	0x00, /* 00000000 */
-	0x10, /* 000 0000 */
 	0x38, /* 00   000 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 161 0xa1 '\241' */
-	0x18, /* 000  000 */
-	0x24, /* 00 00 00 */
-	0x24, /* 00 00 00 */
-	0x18, /* 000  000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 154 0x9a '\232' */
+	0x88, /*  000 000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 162 0xa2 '\242' */
+	/* 155 0x9b '\233' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x10, /* 000 0000 */
@@ -2129,7 +2038,7 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 163 0xa3 '\243' */
+	/* 156 0x9c '\234' */
 	0x30, /* 00  0000 */
 	0x48, /* 0 00 000 */
 	0x40, /* 0 000000 */
@@ -2142,354 +2051,445 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 164 0xa4 '\244' */
-	0x44, /* 0 000 00 */
-	0x24, /* 00 00 00 */
-	0x50, /* 0 0 0000 */
-	0x48, /* 0 00 000 */
-	0x24, /* 00 00 00 */
-	0x14, /* 000 0 00 */
-	0x48, /* 0 00 000 */
-	0x44, /* 0 000 00 */
-	0x38, /* 00   000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 165 0xa5 '\245' */
-	0x00, /* 00000000 */
+	/* 157 0x9d '\235' */
 	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x7c, /* 0     00 */
+	0x44, /* 0 000 00 */
+	0x28, /* 00 0 000 */
 	0x7c, /* 0     00 */
+	0x10, /* 000 0000 */
 	0x7c, /* 0     00 */
-	0x38, /* 00   000 */
-	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 166 0xa6 '\246' */
-	0x3c, /* 00    00 */
-	0x54, /* 0 0 0 00 */
-	0x54, /* 0 0 0 00 */
-	0x54, /* 0 0 0 00 */
-	0x3c, /* 00    00 */
-	0x14, /* 000 0 00 */
-	0x14, /* 000 0 00 */
-	0x14, /* 000 0 00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 158 0x9e '\236' */
 	0x00, /* 00000000 */
-
-	/* 167 0xa7 '\247' */
-	0x18, /* 000  000 */
-	0x24, /* 00 00 00 */
-	0x44, /* 0 000 00 */
+	0x70, /* 0   0000 */
 	0x48, /* 0 00 000 */
+	0x70, /* 0   0000 */
+	0x48, /* 0 00 000 */
+	0x5c, /* 0 0   00 */
 	0x48, /* 0 00 000 */
 	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x58, /* 0 0  000 */
-	0x40, /* 0 000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 168 0xa8 '\250' */
 	0x00, /* 00000000 */
-	0x70, /* 0   0000 */
-	0x08, /* 0000 000 */
-	0x64, /* 0  00 00 */
-	0x54, /* 0 0 0 00 */
-	0x64, /* 0  00 00 */
-	0x58, /* 0 0  000 */
+
+	/* 159 0x9f '\237' */
 	0x00, /* 00000000 */
+	0x0c, /* 0000  00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x60, /* 0  00000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 169 0xa9 '\251' */
-	0x00, /* 00000000 */
-	0x70, /* 0   0000 */
+	/* 160 0xa0 '\240' */
 	0x08, /* 0000 000 */
-	0x34, /* 00  0 00 */
+	0x10, /* 000 0000 */
+	0x00, /* 00000000 */
+	0x3c, /* 00    00 */
+	0x44, /* 0 000 00 */
 	0x44, /* 0 000 00 */
+	0x4c, /* 0 00  00 */
 	0x34, /* 00  0 00 */
-	0x08, /* 0000 000 */
-	0x70, /* 0   0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 170 0xaa '\252' */
+	/* 161 0xa1 '\241' */
+	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
-	0xf4, /*     0 00 */
-	0x5c, /* 0 0   00 */
-	0x5c, /* 0 0   00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+
+	/* 162 0xa2 '\242' */
+	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 171 0xab '\253' */
-	0x00, /* 00000000 */
+	/* 163 0xa3 '\243' */
 	0x08, /* 0000 000 */
 	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x4c, /* 0 00  00 */
+	0x34, /* 00  0 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+
+	/* 164 0xa4 '\244' */
+	0x34, /* 00  0 00 */
+	0x58, /* 0 0  000 */
 	0x00, /* 00000000 */
+	0x58, /* 0 0  000 */
+	0x64, /* 0  00 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 172 0xac '\254' */
-	0x00, /* 00000000 */
-	0x28, /* 00 0 000 */
+	/* 165 0xa5 '\245' */
+	0x58, /* 0 0  000 */
+	0x44, /* 0 000 00 */
+	0x64, /* 0  00 00 */
+	0x54, /* 0 0 0 00 */
+	0x4c, /* 0 00  00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+
+	/* 166 0xa6 '\246' */
 	0x00, /* 00000000 */
+	0x1c, /* 000   00 */
+	0x24, /* 00 00 00 */
+	0x24, /* 00 00 00 */
+	0x1c, /* 000   00 */
 	0x00, /* 00000000 */
+	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 173 0xad '\255' */
+	/* 167 0xa7 '\247' */
 	0x00, /* 00000000 */
+	0x18, /* 000  000 */
+	0x24, /* 00 00 00 */
+	0x24, /* 00 00 00 */
+	0x18, /* 000  000 */
 	0x00, /* 00000000 */
-	0x08, /* 0000 000 */
-	0x7c, /* 0     00 */
-	0x10, /* 000 0000 */
-	0x7c, /* 0     00 */
-	0x20, /* 00 00000 */
+	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 174 0xae '\256' */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x50, /* 0 0 0000 */
-	0x50, /* 0 0 0000 */
-	0x78, /* 0    000 */
-	0x50, /* 0 0 0000 */
-	0x50, /* 0 0 0000 */
-	0x5c, /* 0 0   00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	/* 168 0xa8 '\250' */
 	0x00, /* 00000000 */
-
-	/* 175 0xaf '\257' */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x4c, /* 0 00  00 */
-	0x54, /* 0 0 0 00 */
-	0x64, /* 0  00 00 */
+	0x10, /* 000 0000 */
+	0x20, /* 00 00000 */
+	0x40, /* 0 000000 */
 	0x44, /* 0 000 00 */
 	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 176 0xb0 '\260' */
+	/* 169 0xa9 '\251' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x6c, /* 0  0  00 */
-	0x54, /* 0 0 0 00 */
-	0x6c, /* 0  0  00 */
 	0x00, /* 00000000 */
+	0x7c, /* 0     00 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 177 0xb1 '\261' */
+	/* 170 0xaa '\252' */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
-	0x7c, /* 0     00 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
 	0x7c, /* 0     00 */
+	0x04, /* 00000 00 */
+	0x04, /* 00000 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 178 0xb2 '\262' */
 	0x00, /* 00000000 */
-	0x08, /* 0000 000 */
-	0x10, /* 000 0000 */
+
+	/* 171 0xab '\253' */
 	0x20, /* 00 00000 */
+	0x60, /* 0  00000 */
+	0x24, /* 00 00 00 */
+	0x28, /* 00 0 000 */
 	0x10, /* 000 0000 */
+	0x28, /* 00 0 000 */
+	0x44, /* 0 000 00 */
 	0x08, /* 0000 000 */
-	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x00, /* 00000000 */
+	0x1c, /* 000   00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 179 0xb3 '\263' */
-	0x00, /* 00000000 */
+	/* 172 0xac '\254' */
+	0x20, /* 00 00000 */
+	0x60, /* 0  00000 */
+	0x24, /* 00 00 00 */
+	0x28, /* 00 0 000 */
 	0x10, /* 000 0000 */
+	0x28, /* 00 0 000 */
+	0x58, /* 0 0  000 */
+	0x3c, /* 00    00 */
 	0x08, /* 0000 000 */
-	0x04, /* 00000 00 */
-	0x08, /* 0000 000 */
-	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
-	0x1c, /* 000   00 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 180 0xb4 '\264' */
+	/* 173 0xad '\255' */
 	0x00, /* 00000000 */
-	0x44, /* 0 000 00 */
-	0x28, /* 00 0 000 */
-	0x7c, /* 0     00 */
-	0x10, /* 000 0000 */
-	0x7c, /* 0     00 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
+	0x08, /* 0000 000 */
+	0x00, /* 00000000 */
+	0x08, /* 0000 000 */
+	0x08, /* 0000 000 */
+	0x08, /* 0000 000 */
+	0x08, /* 0000 000 */
+	0x08, /* 0000 000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 181 0xb5 '\265' */
+	/* 174 0xae '\256' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x48, /* 0 00 000 */
-	0x48, /* 0 00 000 */
-	0x48, /* 0 00 000 */
-	0x48, /* 0 00 000 */
-	0x74, /* 0   0 00 */
-	0x40, /* 0 000000 */
-	0x40, /* 0 000000 */
-	0x00, /* 00000000 */
-
-	/* 182 0xb6 '\266' */
 	0x00, /* 00000000 */
-	0x10, /* 000 0000 */
-	0x08, /* 0000 000 */
-	0x0c, /* 0000  00 */
-	0x14, /* 000 0 00 */
 	0x24, /* 00 00 00 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
 	0x24, /* 00 00 00 */
-	0x18, /* 000  000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 183 0xb7 '\267' */
+	/* 175 0xaf '\257' */
 	0x00, /* 00000000 */
-	0x7c, /* 0     00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x48, /* 0 00 000 */
 	0x24, /* 00 00 00 */
-	0x10, /* 000 0000 */
-	0x08, /* 0000 000 */
-	0x10, /* 000 0000 */
 	0x24, /* 00 00 00 */
-	0x7c, /* 0     00 */
+	0x48, /* 0 00 000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 184 0xb8 '\270' */
-	0x00, /* 00000000 */
-	0x7c, /* 0     00 */
+	/* 176 0xb0 '\260' */
+	0x11, /* 000 000  */
+	0x44, /* 0 000 00 */
+	0x11, /* 000 000  */
+	0x44, /* 0 000 00 */
+	0x11, /* 000 000  */
+	0x44, /* 0 000 00 */
+	0x11, /* 000 000  */
+	0x44, /* 0 000 00 */
+	0x11, /* 000 000  */
+	0x44, /* 0 000 00 */
+	0x11, /* 000 000  */
+
+	/* 177 0xb1 '\261' */
+	0x55, /* 0 0 0 0  */
+	0xaa, /*  0 0 0 0 */
+	0x55, /* 0 0 0 0  */
+	0xaa, /*  0 0 0 0 */
+	0x55, /* 0 0 0 0  */
+	0xaa, /*  0 0 0 0 */
+	0x55, /* 0 0 0 0  */
+	0xaa, /*  0 0 0 0 */
+	0x55, /* 0 0 0 0  */
+	0xaa, /*  0 0 0 0 */
+	0x55, /* 0 0 0 0  */
+
+	/* 178 0xb2 '\262' */
+	0xdd, /*   0   0  */
+	0x77, /* 0   0    */
+	0xdd, /*   0   0  */
+	0x77, /* 0   0    */
+	0xdd, /*   0   0  */
+	0x77, /* 0   0    */
+	0xdd, /*   0   0  */
+	0x77, /* 0   0    */
+	0xdd, /*   0   0  */
+	0x77, /* 0   0    */
+	0xdd, /*   0   0  */
+
+	/* 179 0xb3 '\263' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+
+	/* 180 0xb4 '\264' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0xf0, /*     0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+
+	/* 181 0xb5 '\265' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0xf0, /*     0000 */
+	0x10, /* 000 0000 */
+	0xf0, /*     0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+
+	/* 182 0xb6 '\266' */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0xe8, /*    0 000 */
 	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
 
-	/* 185 0xb9 '\271' */
+	/* 183 0xb7 '\267' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x7c, /* 0     00 */
+	0x00, /* 00000000 */
+	0xf8, /*      000 */
+	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
 	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+
+	/* 184 0xb8 '\270' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 186 0xba '\272' */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
+	0xf0, /*     0000 */
 	0x10, /* 000 0000 */
+	0xf0, /*     0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
-	0x60, /* 0  00000 */
-	0x00, /* 00000000 */
+
+	/* 185 0xb9 '\271' */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0xe8, /*    0 000 */
+	0x08, /* 0000 000 */
+	0xe8, /*    0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+
+	/* 186 0xba '\272' */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 187 0xbb '\273' */
 	0x00, /* 00000000 */
-	0x1c, /* 000   00 */
-	0x24, /* 00 00 00 */
-	0x24, /* 00 00 00 */
-	0x1c, /* 000   00 */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0xf8, /*      000 */
+	0x08, /* 0000 000 */
+	0xe8, /*    0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 188 0xbc '\274' */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0xe8, /*    0 000 */
+	0x08, /* 0000 000 */
+	0xf8, /*      000 */
 	0x00, /* 00000000 */
-	0x18, /* 000  000 */
-	0x24, /* 00 00 00 */
-	0x24, /* 00 00 00 */
-	0x18, /* 000  000 */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 189 0xbd '\275' */
-	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
 	0x28, /* 00 0 000 */
-	0x6c, /* 0  0  00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0xf8, /*      000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 190 0xbe '\276' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0xf0, /*     0000 */
+	0x10, /* 000 0000 */
+	0xf0, /*     0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x54, /* 0 0 0 00 */
-	0x5c, /* 0 0   00 */
-	0x50, /* 0 0 0000 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
@@ -2497,152 +2497,152 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x38, /* 00   000 */
-	0x4c, /* 0 00  00 */
-	0x54, /* 0 0 0 00 */
-	0x64, /* 0  00 00 */
-	0x38, /* 00   000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0xf0, /*     0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 
 	/* 192 0xc0 '\300' */
-	0x00, /* 00000000 */
 	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
 	0x10, /* 000 0000 */
-	0x20, /* 00 00000 */
-	0x40, /* 0 000000 */
-	0x44, /* 0 000 00 */
-	0x38, /* 00   000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x1c, /* 000   00 */
 	0x00, /* 00000000 */
-
-	/* 193 0xc1 '\301' */
 	0x00, /* 00000000 */
-	0x08, /* 0000 000 */
 	0x00, /* 00000000 */
-	0x08, /* 0000 000 */
-	0x08, /* 0000 000 */
-	0x08, /* 0000 000 */
-	0x08, /* 0000 000 */
-	0x08, /* 0000 000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 194 0xc2 '\302' */
-	0x00, /* 00000000 */
+	/* 193 0xc1 '\301' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0xfc, /*       00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x7c, /* 0     00 */
-	0x04, /* 00000 00 */
-	0x04, /* 00000 00 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
-	/* 195 0xc3 '\303' */
+	/* 194 0xc2 '\302' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x0c, /* 0000  00 */
-	0x08, /* 0000 000 */
-	0x10, /* 000 0000 */
-	0x50, /* 0 0 0000 */
-	0x20, /* 00 00000 */
-	0x20, /* 00 00000 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 
-	/* 196 0xc4 '\304' */
+	/* 195 0xc3 '\303' */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
-	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
+	0x1c, /* 000   00 */
+	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
-	0x60, /* 0  00000 */
-	0x00, /* 00000000 */
 
-	/* 197 0xc5 '\305' */
+	/* 196 0xc4 '\304' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x04, /* 00000 00 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x38, /* 00   000 */
-	0x40, /* 0 000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0xfc, /*       00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 198 0xc6 '\306' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x10, /* 000 0000 */
-	0x10, /* 000 0000 */
-	0x28, /* 00 0 000 */
-	0x28, /* 00 0 000 */
-	0x44, /* 0 000 00 */
-	0x7c, /* 0     00 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
+	/* 197 0xc5 '\305' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0xfc, /*       00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+
+	/* 198 0xc6 '\306' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x1c, /* 000   00 */
+	0x10, /* 000 0000 */
+	0x1c, /* 000   00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+
 	/* 199 0xc7 '\307' */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x24, /* 00 00 00 */
-	0x48, /* 0 00 000 */
-	0x48, /* 0 00 000 */
-	0x24, /* 00 00 00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x2c, /* 00 0  00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 200 0xc8 '\310' */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x2c, /* 00 0  00 */
+	0x20, /* 00 00000 */
+	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x48, /* 0 00 000 */
-	0x24, /* 00 00 00 */
-	0x24, /* 00 00 00 */
-	0x48, /* 0 00 000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 201 0xc9 '\311' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x54, /* 0 0 0 00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x3c, /* 00    00 */
+	0x20, /* 00 00000 */
+	0x2c, /* 00 0  00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 202 0xca '\312' */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0xec, /*    0  00 */
 	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0xfc, /*       00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -2650,76 +2650,76 @@
 	0x00, /* 00000000 */
 
 	/* 203 0xcb '\313' */
-	0x10, /* 000 0000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x7c, /* 0     00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0x00, /* 00000000 */
+	0xec, /*    0  00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 204 0xcc '\314' */
-	0x58, /* 0 0  000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x7c, /* 0     00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x2c, /* 00 0  00 */
+	0x20, /* 00 00000 */
+	0x2c, /* 00 0  00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+
+	/* 205 0xcd '\315' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 205 0xcd '\315' */
-	0x58, /* 0 0  000 */
-	0x38, /* 00   000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x38, /* 00   000 */
+	0xfc, /*       00 */
 	0x00, /* 00000000 */
+	0xfc, /*       00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-
-	/* 206 0xce '\316' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x50, /* 0 0 0000 */
-	0x50, /* 0 0 0000 */
-	0x58, /* 0 0  000 */
-	0x50, /* 0 0 0000 */
-	0x50, /* 0 0 0000 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+
+	/* 206 0xce '\316' */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0xec, /*    0  00 */
 	0x00, /* 00000000 */
+	0xec, /*    0  00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 207 0xcf '\317' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0xfc, /*       00 */
 	0x00, /* 00000000 */
+	0xfc, /*       00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x28, /* 00 0 000 */
-	0x54, /* 0 0 0 00 */
-	0x5c, /* 0 0   00 */
-	0x50, /* 0 0 0000 */
-	0x2c, /* 00 0  00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 208 0xd0 '\320' */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x38, /* 00   000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0xfc, /*       00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -2731,34 +2731,34 @@
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x00, /* 00000000 */
 	0xfc, /*       00 */
 	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 
 	/* 210 0xd2 '\322' */
 	0x00, /* 00000000 */
-	0x14, /* 000 0 00 */
-	0x28, /* 00 0 000 */
-	0x28, /* 00 0 000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 211 0xd3 '\323' */
-	0x00, /* 00000000 */
-	0x14, /* 000 0 00 */
-	0x14, /* 000 0 00 */
 	0x28, /* 00 0 000 */
-	0x00, /* 00000000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -2767,12 +2767,12 @@
 	0x00, /* 00000000 */
 
 	/* 212 0xd4 '\324' */
-	0x00, /* 00000000 */
-	0x08, /* 0000 000 */
 	0x10, /* 000 0000 */
-	0x18, /* 000  000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x1c, /* 000   00 */
+	0x10, /* 000 0000 */
+	0x1c, /* 000   00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -2781,64 +2781,64 @@
 
 	/* 213 0xd5 '\325' */
 	0x00, /* 00000000 */
-	0x18, /* 000  000 */
-	0x08, /* 0000 000 */
-	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-
-	/* 214 0xd6 '\326' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x1c, /* 000   00 */
+	0x10, /* 000 0000 */
+	0x1c, /* 000   00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
-	0x7c, /* 0     00 */
-	0x00, /* 00000000 */
 	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+
+	/* 214 0xd6 '\326' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x3c, /* 00    00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 215 0xd7 '\327' */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x10, /* 000 0000 */
 	0x28, /* 00 0 000 */
-	0x44, /* 0 000 00 */
 	0x28, /* 00 0 000 */
-	0x10, /* 000 0000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0xfc, /*       00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 
 	/* 216 0xd8 '\330' */
-	0x00, /* 00000000 */
-	0x28, /* 00 0 000 */
-	0x00, /* 00000000 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x44, /* 0 000 00 */
-	0x3c, /* 00    00 */
-	0x04, /* 00000 00 */
-	0x38, /* 00   000 */
-	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0xfc, /*       00 */
+	0x10, /* 000 0000 */
+	0xfc, /*       00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 
 	/* 217 0xd9 '\331' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0xf0, /*     0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0xfc, /*       00 */
-	0x00, /* 00000000 */
-	0xfc, /*       00 */
-	0x00, /* 00000000 */
-	0xfc, /*       00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -2846,260 +2846,260 @@
 
 	/* 218 0xda '\332' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x1f, /* 000      */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 
 	/* 219 0xdb '\333' */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
 
 	/* 220 0xdc '\334' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
 
 	/* 221 0xdd '\335' */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
+	0xe0, /*    00000 */
 
 	/* 222 0xde '\336' */
-	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
+	0x1c, /* 000   00 */
 
 	/* 223 0xdf '\337' */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0xfc, /*       00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 224 0xe0 '\340' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x24, /* 00 00 00 */
+	0x58, /* 0 0  000 */
+	0x50, /* 0 0 0000 */
+	0x54, /* 0 0 0 00 */
+	0x2c, /* 00 0  00 */
 	0x00, /* 00000000 */
-
-	/* 225 0xe1 '\341' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
+
+	/* 225 0xe1 '\341' */
+	0x18, /* 000  000 */
+	0x24, /* 00 00 00 */
+	0x44, /* 0 000 00 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x58, /* 0 0  000 */
+	0x40, /* 0 000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 226 0xe2 '\342' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x7c, /* 0     00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 227 0xe3 '\343' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x7c, /* 0     00 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 228 0xe4 '\344' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x7c, /* 0     00 */
+	0x24, /* 00 00 00 */
+	0x10, /* 000 0000 */
+	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
+	0x24, /* 00 00 00 */
+	0x7c, /* 0     00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 229 0xe5 '\345' */
 	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x30, /* 00  0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 230 0xe6 '\346' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x48, /* 0 00 000 */
+	0x74, /* 0   0 00 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
 	0x00, /* 00000000 */
 
 	/* 231 0xe7 '\347' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x6c, /* 0  0  00 */
+	0x98, /*  00  000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 232 0xe8 '\350' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 233 0xe9 '\351' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x38, /* 00   000 */
+	0x4c, /* 0 00  00 */
+	0x54, /* 0 0 0 00 */
+	0x64, /* 0  00 00 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 234 0xea '\352' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x28, /* 00 0 000 */
+	0x6c, /* 0  0  00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 235 0xeb '\353' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x10, /* 000 0000 */
+	0x08, /* 0000 000 */
+	0x0c, /* 0000  00 */
+	0x14, /* 000 0 00 */
+	0x24, /* 00 00 00 */
+	0x24, /* 00 00 00 */
+	0x18, /* 000  000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 236 0xec '\354' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x38, /* 00   000 */
+	0x54, /* 0 0 0 00 */
+	0x54, /* 0 0 0 00 */
+	0x54, /* 0 0 0 00 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 237 0xed '\355' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x04, /* 00000 00 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x38, /* 00   000 */
+	0x40, /* 0 000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -3107,11 +3107,11 @@
 	/* 238 0xee '\356' */
 	0x00, /* 00000000 */
 	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
+	0x78, /* 0    000 */
+	0x40, /* 0 000000 */
+	0x40, /* 0 000000 */
 	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
@@ -3119,221 +3119,221 @@
 
 	/* 239 0xef '\357' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x38, /* 00   000 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
+	0x44, /* 0 000 00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 240 0xf0 '\360' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0x00, /* 00000000 */
+	0xfc, /*       00 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 241 0xf1 '\361' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x7c, /* 0     00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x7c, /* 0     00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 242 0xf2 '\362' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x10, /* 000 0000 */
+	0x08, /* 0000 000 */
+	0x04, /* 00000 00 */
+	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
+	0x00, /* 00000000 */
+	0x1c, /* 000   00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 243 0xf3 '\363' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
+	0x20, /* 00 00000 */
+	0x10, /* 000 0000 */
+	0x08, /* 0000 000 */
+	0x00, /* 00000000 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 244 0xf4 '\364' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
-	0x00, /* 00000000 */
+	0x0c, /* 0000  00 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
 
 	/* 245 0xf5 '\365' */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x10, /* 000 0000 */
+	0x60, /* 0  00000 */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+
+	/* 246 0xf6 '\366' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
-
-	/* 246 0xf6 '\366' */
+	0x7c, /* 0     00 */
+	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 247 0xf7 '\367' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x34, /* 00  0 00 */
+	0x48, /* 0 00 000 */
+	0x00, /* 00000000 */
+	0x34, /* 00  0 00 */
+	0x48, /* 0 00 000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 248 0xf8 '\370' */
+	0x18, /* 000  000 */
+	0x24, /* 00 00 00 */
+	0x24, /* 00 00 00 */
+	0x18, /* 000  000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 249 0xf9 '\371' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x38, /* 00   000 */
+	0x10, /* 000 0000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 250 0xfa '\372' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x10, /* 000 0000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 251 0xfb '\373' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x0c, /* 0000  00 */
+	0x08, /* 0000 000 */
+	0x10, /* 000 0000 */
+	0x50, /* 0 0 0000 */
+	0x20, /* 00 00000 */
+	0x20, /* 00 00000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 252 0xfc '\374' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x50, /* 0 0 0000 */
+	0x28, /* 00 0 000 */
+	0x28, /* 00 0 000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 253 0xfd '\375' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x70, /* 0   0000 */
+	0x08, /* 0000 000 */
+	0x20, /* 00 00000 */
+	0x78, /* 0    000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 254 0xfe '\376' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x38, /* 00   000 */
+	0x38, /* 00   000 */
+	0x38, /* 00   000 */
+	0x38, /* 00   000 */
+	0x38, /* 00   000 */
+	0x38, /* 00   000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 
 	/* 255 0xff '\377' */
 	0x00, /* 00000000 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
-	0x3c, /* 00    00 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
+	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
diff -Nru a/drivers/video/console/tileblit.c b/drivers/video/console/tileblit.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/console/tileblit.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,147 @@
+/*
+ *  linux/drivers/video/console/tileblit.c -- Tile Blitting Operation
+ *
+ *      Copyright (C) 2004 Antonino Daplas <adaplas @pol.net>
+ *
+ *  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 <linux/config.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/fb.h>
+#include <linux/vt_kern.h>
+#include <linux/console.h>
+#include <asm/types.h>
+#include "fbcon.h"
+
+static void tile_bmove(struct vc_data *vc, struct fb_info *info, int sy,
+		       int sx, int dy, int dx, int height, int width)
+{
+	struct fb_tilearea area;
+
+	area.sx = sx;
+	area.sy = sy;
+	area.dx = dx;
+	area.dy = dy;
+	area.height = height;
+	area.width = width;
+
+	info->tileops->fb_tilecopy(info, &area);
+}
+
+static void tile_clear(struct vc_data *vc, struct fb_info *info, int sy,
+		       int sx, int height, int width)
+{
+	struct fb_tilerect rect;
+	int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
+	int fgshift = (vc->vc_hi_font_mask) ? 9 : 8;
+
+	rect.index = vc->vc_video_erase_char &
+		((vc->vc_hi_font_mask) ? 0x1ff : 0xff);
+	rect.fg = attr_fgcol_ec(fgshift, vc);
+	rect.bg = attr_bgcol_ec(bgshift, vc);
+	rect.sx = sx;
+	rect.sy = sy;
+	rect.width = width;
+	rect.height = height;
+	rect.rop = ROP_COPY;
+
+	info->tileops->fb_tilefill(info, &rect);
+}
+
+static void tile_putcs(struct vc_data *vc, struct fb_info *info,
+		       const unsigned short *s, int count, int yy, int xx,
+		       int fg, int bg)
+{
+	struct fb_tileblit blit;
+	unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
+	int size = sizeof(u32) * count, i;
+
+	blit.sx = xx;
+	blit.sy = yy;
+	blit.width = count;
+	blit.height = 1;
+	blit.fg = fg;
+	blit.bg = bg;
+	blit.length = count;
+	blit.indices = (u32 *) fb_get_buffer_offset(info, &info->pixmap, size);
+	for (i = 0; i < count; i++)
+		blit.indices[i] = (u32)(scr_readw(s++) & charmask);
+
+	info->tileops->fb_tileblit(info, &blit);
+}
+
+static void tile_clear_margins(struct vc_data *vc, struct fb_info *info,
+			       int bottom_only)
+{
+	return;
+}
+
+static void tile_cursor(struct vc_data *vc, struct fb_info *info,
+			struct display *p, int mode, int fg, int bg)
+{
+	struct fb_tilecursor cursor;
+	int use_sw = (vc->vc_cursor_type & 0x01);
+
+	cursor.sx = vc->vc_x;
+	cursor.sy = vc->vc_y;
+	cursor.mode = (mode == CM_ERASE || use_sw) ? 0 : 1;
+	cursor.fg = fg;
+	cursor.bg = bg;
+
+	switch (vc->vc_cursor_type & 0x0f) {
+	case CUR_NONE:
+		cursor.shape = FB_TILE_CURSOR_NONE;
+		break;
+	case CUR_UNDERLINE:
+		cursor.shape = FB_TILE_CURSOR_UNDERLINE;
+		break;
+	case CUR_LOWER_THIRD:
+		cursor.shape = FB_TILE_CURSOR_LOWER_THIRD;
+		break;
+	case CUR_LOWER_HALF:
+		cursor.shape = FB_TILE_CURSOR_LOWER_HALF;
+		break;
+	case CUR_TWO_THIRDS:
+		cursor.shape = FB_TILE_CURSOR_TWO_THIRDS;
+		break;
+	case CUR_BLOCK:
+	default:
+		cursor.shape = FB_TILE_CURSOR_BLOCK;
+		break;
+	}
+
+	info->tileops->fb_tilecursor(info, &cursor);
+}
+
+void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info,
+		       struct display *p, struct fbcon_ops *ops)
+{
+	struct fb_tilemap map;
+
+	ops->bmove = tile_bmove;
+	ops->clear = tile_clear;
+	ops->putcs = tile_putcs;
+	ops->clear_margins = tile_clear_margins;
+	ops->cursor = tile_cursor;
+
+	if (p) {
+		map.width = vc->vc_font.width;
+		map.height = vc->vc_font.height;
+		map.depth = 1;
+		map.length = (p->userfont) ?
+			FNTCHARCNT(p->fontdata) : 256;
+		map.data = p->fontdata;
+		info->tileops->fb_settile(info, &map);
+	}
+}
+
+EXPORT_SYMBOL(fbcon_set_tileops);
+
+MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
+MODULE_DESCRIPTION("Tile Blitting Operation");
+MODULE_LICENSE("GPL");
+
diff -Nru a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
--- a/drivers/video/console/vgacon.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/video/console/vgacon.c	2004-12-24 13:36:48 -08:00
@@ -901,8 +901,10 @@
 	for (i = 0; i < MAX_NR_CONSOLES; i++) {
 		struct vc_data *c = vc_cons[i].d;
 
-		if (c && c->vc_sw == &vga_con)
+		if (c && c->vc_sw == &vga_con) {
+			c->vc_font.height = fontheight;
 			vc_resize(c->vc_num, 0, rows);	/* Adjust console size */
+		}
 	}
 	return 0;
 }
diff -Nru a/drivers/video/controlfb.c b/drivers/video/controlfb.c
--- a/drivers/video/controlfb.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/video/controlfb.c	2004-12-24 13:36:31 -08:00
@@ -98,14 +98,14 @@
 	struct fb_par_control	par;
 	u32			pseudo_palette[17];
 		
-	struct cmap_regs	*cmap_regs;
+	struct cmap_regs	__iomem *cmap_regs;
 	unsigned long		cmap_regs_phys;
 	
-	struct control_regs	*control_regs;
+	struct control_regs	__iomem *control_regs;
 	unsigned long		control_regs_phys;
 	unsigned long		control_regs_size;
 	
-	__u8			*frame_buffer;
+	__u8			__iomem *frame_buffer;
 	unsigned long		frame_buffer_phys;
 	unsigned long		fb_orig_base;
 	unsigned long		fb_orig_size;
@@ -329,17 +329,17 @@
 
 	ctrl = ld_le32(CNTRL_REG(p,ctrl));
 	if (blank_mode > 0)
-		switch (blank_mode - 1) {
-		case VESA_VSYNC_SUSPEND:
+		switch (blank_mode) {
+		case FB_BLANK_VSYNC_SUSPEND:
 			ctrl &= ~3;
 			break;
-		case VESA_HSYNC_SUSPEND:
+		case FB_BLANK_HSYNC_SUSPEND:
 			ctrl &= ~0x30;
 			break;
-		case VESA_POWERDOWN:
+		case FB_BLANK_POWERDOWN:
 			ctrl &= ~0x33;
 			/* fall through */
-		case VESA_NO_BLANKING:
+		case FB_BLANK_NORMAL:
 			ctrl |= 0x400;
 			break;
 		default:
@@ -497,7 +497,7 @@
 static void control_set_hardware(struct fb_info_control *p, struct fb_par_control *par)
 {
 	struct control_regvals	*r;
-	volatile struct preg	*rp;
+	volatile struct preg	__iomem *rp;
 	int			i, cmode;
 
 	if (PAR_EQUAL(&p->par, par)) {
@@ -1017,7 +1017,7 @@
 	info->fbops = &controlfb_ops;
 	info->pseudo_palette = p->pseudo_palette;
         info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
-	info->screen_base = (char *) p->frame_buffer + CTRLFB_OFF;
+	info->screen_base = p->frame_buffer + CTRLFB_OFF;
 
 	fb_alloc_cmap(&info->cmap, 256, 0);
 
diff -Nru a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
--- a/drivers/video/cyber2000fb.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/video/cyber2000fb.c	2004-12-24 13:36:31 -08:00
@@ -66,8 +66,8 @@
 	struct display_switch	*dispsw;
 	struct display		*display;
 	struct pci_dev		*dev;
-	unsigned char 		*region;
-	unsigned char		*regs;
+	unsigned char 		__iomem *region;
+	unsigned char		__iomem *regs;
 	u_int			id;
 	int			func_use_count;
 	u_long			ref_ps;
@@ -1003,16 +1003,16 @@
 	int i;
 
 	switch (blank) {
-	case 4:	/* powerdown - both sync lines down */
+	case FB_BLANK_POWERDOWN:	/* powerdown - both sync lines down */
 		sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_0;
 		break;	
-	case 3:	/* hsync off */
+	case FB_BLANK_HSYNC_SUSPEND:	/* hsync off */
 		sync = EXT_SYNC_CTL_VS_NORMAL | EXT_SYNC_CTL_HS_0;
 		break;	
-	case 2:	/* vsync off */
+	case FB_BLANK_VSYNC_SUSPEND:	/* vsync off */
 		sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_NORMAL;
 		break;
-	case 1:	/* soft blank */
+	case FB_BLANK_NORMAL:	        /* soft blank */
 	default: /* unblank */
 		break;
 	}
@@ -1399,6 +1399,8 @@
 		cfb->fb.var.xres, cfb->fb.var.yres,
 		h_sync / 1000, h_sync % 1000, v_sync);
 
+	if (cfb->dev)
+		cfb->fb.device = &cfb->dev->dev;
 	err = register_framebuffer(&cfb->fb);
 
 failed:
@@ -1722,7 +1724,7 @@
 #ifndef MODULE
 	char *option = NULL;
 
-	if (fb_get_options("cyber2000fb", NULL))
+	if (fb_get_options("cyber2000fb", &option))
 		return -ENODEV;
 	cyber2000fb_setup(option);
 #endif
diff -Nru a/drivers/video/cyber2000fb.h b/drivers/video/cyber2000fb.h
--- a/drivers/video/cyber2000fb.h	2004-12-24 13:37:18 -08:00
+++ b/drivers/video/cyber2000fb.h	2004-12-24 13:37:18 -08:00
@@ -466,8 +466,8 @@
 
 struct cyberpro_info {
 	struct pci_dev	*dev;
-	unsigned char	*regs;
-	char		*fb;
+	unsigned char	__iomem *regs;
+	char		__iomem *fb;
 	char		dev_name[32];
 	unsigned int	fb_size;
 	unsigned int	chip_id;
diff -Nru a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
--- a/drivers/video/epson1355fb.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/video/epson1355fb.c	2004-12-24 13:36:17 -08:00
@@ -288,22 +288,25 @@
 	struct epson1355_par *par = info->par;
 
 	switch (blank_mode) {
-	case VESA_NO_BLANKING:
+	case FB_BLANK_UNBLANKING:
+	case FB_BLANK_NORMAL:
 		lcd_enable(par, 1);
 		backlight_enable(1);
 		break;
-	case VESA_VSYNC_SUSPEND:
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_VSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		backlight_enable(0);
 		break;
-	case VESA_POWERDOWN:
+	case FB_BLANK_POWERDOWN:
 		backlight_enable(0);
 		lcd_enable(par, 0);
 		break;
 	default:
 		return -EINVAL;
 	}
-	return 0;
+
+	/* let fbcon do a soft blank for us */
+	return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0;
 }
 
 /* ------------------------------------------------------------------------- */
diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
--- a/drivers/video/fbmem.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/video/fbmem.c	2004-12-24 13:36:16 -08:00
@@ -51,7 +51,7 @@
      *  Frame buffer device initialization and setup routines
      */
 
-#define FBPIXMAPSIZE	16384
+#define FBPIXMAPSIZE	(1024 * 8)
 
 static struct notifier_block *fb_notifier_list;
 struct fb_info *registered_fb[FB_MAX];
@@ -368,6 +368,9 @@
 
 	memset(&fb_logo, 0, sizeof(struct logo_data));
 
+	if (info->flags & FBINFO_MISC_TILEBLITTING)
+		return 0;
+
 	if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
 		depth = info->var.blue.length;
 		if (info->var.red.length < depth)
@@ -504,7 +507,8 @@
 	struct inode *inode = file->f_dentry->d_inode;
 	int fbidx = iminor(inode);
 	struct fb_info *info = registered_fb[fbidx];
-	u32 *buffer, *dst, *src;
+	u32 *buffer, *dst;
+	u32 __iomem *src;
 	int c, i, cnt = 0, err = 0;
 	unsigned long total_size;
 
@@ -534,7 +538,7 @@
 	if (!buffer)
 		return -ENOMEM;
 
-	src = (u32 *) (info->screen_base + p);
+	src = (u32 __iomem *) (info->screen_base + p);
 
 	if (info->fbops->fb_sync)
 		info->fbops->fb_sync(info);
@@ -546,12 +550,12 @@
 			*dst++ = fb_readl(src++);
 		if (c & 3) {
 			u8 *dst8 = (u8 *) dst;
-			u8 *src8 = (u8 *) src;
+			u8 __iomem *src8 = (u8 __iomem *) src;
 
 			for (i = c & 3; i--;)
 				*dst8++ = fb_readb(src8++);
 
-			src = (u32 *) src8;
+			src = (u32 __iomem *) src8;
 		}
 
 		if (copy_to_user(buf, buffer, c)) {
@@ -575,7 +579,8 @@
 	struct inode *inode = file->f_dentry->d_inode;
 	int fbidx = iminor(inode);
 	struct fb_info *info = registered_fb[fbidx];
-	u32 *buffer, *dst, *src;
+	u32 *buffer, *src;
+	u32 __iomem *dst;
 	int c, i, cnt = 0, err;
 	unsigned long total_size;
 
@@ -607,7 +612,7 @@
 	if (!buffer)
 		return -ENOMEM;
 
-	dst = (u32 *) (info->screen_base + p);
+	dst = (u32 __iomem *) (info->screen_base + p);
 
 	if (info->fbops->fb_sync)
 		info->fbops->fb_sync(info);
@@ -623,12 +628,12 @@
 			fb_writel(*src++, dst++);
 		if (c & 3) {
 			u8 *src8 = (u8 *) src;
-			u8 *dst8 = (u8 *) dst;
+			u8 __iomem *dst8 = (u8 __iomem *) dst;
 
 			for (i = c & 3; i--; )
 				fb_writeb(*src8++, dst8++);
 
-			dst = (u32 *) dst8;
+			dst = (u32 __iomem *) dst8;
 		}
 		*ppos += c;
 		buf += c;
@@ -647,114 +652,6 @@
 }
 #endif /* CONFIG_KMOD */
 
-void
-fb_load_cursor_image(struct fb_info *info)
-{
-	unsigned int width = (info->cursor.image.width + 7) >> 3;
-	u8 *data = (u8 *) info->cursor.image.data;
-
-	if (info->sprite.outbuf)
-	    info->sprite.outbuf(info, info->sprite.addr, data, width);
-	else
-	    memcpy(info->sprite.addr, data, width);
-}
-
-int
-fb_cursor(struct fb_info *info, struct fb_cursor_user __user *sprite)
-{
-	struct fb_cursor_user cursor_user;
-	struct fb_cursor cursor;
-	char *data = NULL, *mask = NULL, *info_mask = NULL;
-	u16 *red = NULL, *green = NULL, *blue = NULL, *transp = NULL;
-	int err = -EINVAL;
-	
-	if (copy_from_user(&cursor_user, sprite, sizeof(struct fb_cursor_user)))
-		return -EFAULT;
-
-	memcpy(&cursor, &cursor_user, sizeof(cursor_user));
-	cursor.mask = info->cursor.mask;
-	cursor.image.data = info->cursor.image.data;
-	cursor.image.cmap.red = info->cursor.image.cmap.red;
-	cursor.image.cmap.green = info->cursor.image.cmap.green;
-	cursor.image.cmap.blue = info->cursor.image.cmap.blue;
-	cursor.image.cmap.transp = info->cursor.image.cmap.transp;
-	cursor.data = NULL;
-
-	if (cursor.set & FB_CUR_SETCUR)
-		info->cursor.enable = 1;
-	
-	if (cursor.set & FB_CUR_SETCMAP) {
-		unsigned len = cursor.image.cmap.len;
-		if ((int)len <= 0)
-			goto out;
-		len *= 2;
-		err = -ENOMEM;
-		red = kmalloc(len, GFP_USER);
-		green = kmalloc(len, GFP_USER);
-		blue = kmalloc(len, GFP_USER);
-		if (!red || !green || !blue)
-			goto out;
-		if (cursor_user.image.cmap.transp) {
-			transp = kmalloc(len, GFP_USER);
-			if (!transp)
-				goto out;
-		}
-		err = -EFAULT;
-		if (copy_from_user(red, cursor_user.image.cmap.red, len))
-			goto out;
-		if (copy_from_user(green, cursor_user.image.cmap.green, len))
-			goto out;
-		if (copy_from_user(blue, cursor_user.image.cmap.blue, len))
-			goto out;
-		if (transp) {
-			if (copy_from_user(transp,
-					   cursor_user.image.cmap.transp, len))
-				goto out;
-		}
-		cursor.image.cmap.red = red;
-		cursor.image.cmap.green = green;
-		cursor.image.cmap.blue = blue;
-		cursor.image.cmap.transp = transp;
-	}
-	
-	if (cursor.set & FB_CUR_SETSHAPE) {
-		int size = ((cursor.image.width + 7) >> 3) * cursor.image.height;		
-
-		if ((cursor.image.height != info->cursor.image.height) ||
-		    (cursor.image.width != info->cursor.image.width))
-			cursor.set |= FB_CUR_SETSIZE;
-		
-		err = -ENOMEM;
-		data = kmalloc(size, GFP_USER);
-		mask = kmalloc(size, GFP_USER);
-		if (!mask || !data)
-			goto out;
-		
-		err = -EFAULT;
-		if (copy_from_user(data, cursor_user.image.data, size) ||
-		    copy_from_user(mask, cursor_user.mask, size))
-			goto out;
-		
-		cursor.image.data = data;
-		cursor.mask = mask;
-		info_mask = (char *) info->cursor.mask;
-		info->cursor.mask = mask;
-	}
-	info->cursor.set = cursor.set;
-	info->cursor.rop = cursor.rop;
-	err = info->fbops->fb_cursor(info, &cursor);
-out:
-	kfree(data);
-	kfree(mask);
-	kfree(red);
-	kfree(green);
-	kfree(blue);
-	kfree(transp);
-	if (info_mask)
-		info->cursor.mask = info_mask;
-	return err;
-}
-
 int
 fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
 {
@@ -828,7 +725,10 @@
 			fb_set_cmap(&info->cmap, info);
 
 			fb_var_to_videomode(&mode, &info->var);
-			fb_add_videomode(&mode, &info->modelist);
+
+			if (info->modelist.prev && info->modelist.next &&
+			    !list_empty(&info->modelist))
+				fb_add_videomode(&mode, &info->modelist);
 
 			if (info->flags & FBINFO_MISC_MODECHANGEUSER) {
 				struct fb_event event;
@@ -846,21 +746,15 @@
 int
 fb_blank(struct fb_info *info, int blank)
 {	
-	/* ??? Variable sized stack allocation.  */
-	u16 black[info->cmap.len];
-	struct fb_cmap cmap;
+	int err = -EINVAL;
 	
-	if (info->fbops->fb_blank && !info->fbops->fb_blank(blank, info))
-		return 0;
-	if (blank) { 
-		memset(black, 0, info->cmap.len * sizeof(u16));
-		cmap.red = cmap.green = cmap.blue = black;
-		cmap.transp = info->cmap.transp ? black : NULL;
-		cmap.start = info->cmap.start;
-		cmap.len = info->cmap.len;
-	} else
-		cmap = info->cmap;
-	return fb_set_cmap(&cmap, info);
+ 	if (blank > FB_BLANK_POWERDOWN)
+ 		blank = FB_BLANK_POWERDOWN;
+
+	if (info->fbops->fb_blank)
+ 		err = info->fbops->fb_blank(blank, info);
+
+	return err;
 }
 
 static int 
@@ -919,10 +813,7 @@
 			return -EFAULT;
 		return 0;
 	case FBIO_CURSOR:
-		acquire_console_sem();
-		i = fb_cursor(info, argp);
-		release_console_sem();
-		return i;
+		return -EINVAL;
 	case FBIOGET_CON2FBMAP:
 		if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
 			return -EFAULT;
@@ -948,14 +839,11 @@
 #endif /* CONFIG_KMOD */
 		if (!registered_fb[con2fb.framebuffer])
 		    return -EINVAL;
-		if (con2fb.console > 0 && con2fb.console < MAX_NR_CONSOLES) {
-			event.info = info;
-			event.data = &con2fb;
-			return notifier_call_chain(&fb_notifier_list,
-						   FB_EVENT_SET_CONSOLE_MAP,
-						   &event);
-		}
-		return -EINVAL;
+		event.info = info;
+		event.data = &con2fb;
+		return notifier_call_chain(&fb_notifier_list,
+					   FB_EVENT_SET_CONSOLE_MAP,
+					   &event);
 	case FBIOBLANK:
 		acquire_console_sem();
 		i = fb_blank(info, arg);
@@ -1021,9 +909,8 @@
 	off += start;
 	vma->vm_pgoff = off >> PAGE_SHIFT;
 	/* This is an IO map - tell maydump to skip this VMA */
-	vma->vm_flags |= VM_IO;
+	vma->vm_flags |= VM_IO | VM_RESERVED;
 #if defined(__sparc_v9__)
-	vma->vm_flags |= (VM_SHM | VM_LOCKED);
 	if (io_remap_page_range(vma, vma->vm_start, off,
 				vma->vm_end - vma->vm_start, vma->vm_page_prot, 0))
 		return -EAGAIN;
@@ -1144,7 +1031,8 @@
 			break;
 	fb_info->node = i;
 
-	c = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
+	c = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i),
+				    fb_info->device, "fb%d", i);
 	if (IS_ERR(c)) {
 		/* Not fatal */
 		printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(c));
@@ -1162,18 +1050,6 @@
 	}	
 	fb_info->pixmap.offset = 0;
 
-	if (fb_info->sprite.addr == NULL) {
-		fb_info->sprite.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
-		if (fb_info->sprite.addr) {
-			fb_info->sprite.size = FBPIXMAPSIZE;
-			fb_info->sprite.buf_align = 1;
-			fb_info->sprite.scan_align = 1;
-			fb_info->sprite.access_align = 4;
-			fb_info->sprite.flags = FB_PIXMAP_DEFAULT;
-		}
-	}
-	fb_info->sprite.offset = 0;
-
 	if (!fb_info->modelist.prev ||
 	    !fb_info->modelist.next ||
 	    list_empty(&fb_info->modelist)) {
@@ -1217,8 +1093,6 @@
 
 	if (fb_info->pixmap.addr && (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
 		kfree(fb_info->pixmap.addr);
-	if (fb_info->sprite.addr && (fb_info->sprite.flags & FB_PIXMAP_DEFAULT))
-		kfree(fb_info->sprite.addr);
 	fb_destroy_modelist(&fb_info->modelist);
 	registered_fb[i]=NULL;
 	num_registered_fb--;
@@ -1294,8 +1168,7 @@
 }
 module_init(fbmem_init);
 
-#define NR_FB_DRIVERS 64
-static char *video_options[NR_FB_DRIVERS];
+static char *video_options[FB_MAX];
 static int ofonly;
 
 /**
@@ -1316,7 +1189,7 @@
 		retval = 1;
 
 	if (name_len && !retval) {
-		for (i = 0; i < NR_FB_DRIVERS; i++) {
+		for (i = 0; i < FB_MAX; i++) {
 			if (video_options[i] == NULL)
 				continue;
 			opt_len = strlen(video_options[i]);
@@ -1358,7 +1231,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (i = 0; i < NR_FB_DRIVERS; i++) {
+	for (i = 0; i < FB_MAX; i++) {
 		if (!strncmp(options, "ofonly", 6))
 			ofonly = 1;
 		if (video_options[i] == NULL) {
@@ -1389,7 +1262,6 @@
 EXPORT_SYMBOL(fb_iomove_buf_aligned);
 EXPORT_SYMBOL(fb_sysmove_buf_unaligned);
 EXPORT_SYMBOL(fb_sysmove_buf_aligned);
-EXPORT_SYMBOL(fb_load_cursor_image);
 EXPORT_SYMBOL(fb_set_suspend);
 EXPORT_SYMBOL(fb_register_client);
 EXPORT_SYMBOL(fb_unregister_client);
diff -Nru a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
--- a/drivers/video/fbsysfs.c	2004-12-24 13:37:30 -08:00
+++ b/drivers/video/fbsysfs.c	2004-12-24 13:37:30 -08:00
@@ -51,6 +51,8 @@
 	if (size)
 		info->par = p + fb_info_size;
 
+	info->device = dev;
+
 	return info;
 #undef PADDING
 #undef BYTES_PER_LONG
diff -Nru a/drivers/video/ffb.c b/drivers/video/ffb.c
--- a/drivers/video/ffb.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/video/ffb.c	2004-12-24 13:37:43 -08:00
@@ -676,7 +676,7 @@
 	FFBWait(par);
 
 	switch (blank) {
-	case 0: /* Unblanking */
+	case FB_BLANK_UNBLANK: /* Unblanking */
 		upa_writel(0x6000, &dac->type);
 		tmp = (upa_readl(&dac->value) | 0x1);
 		upa_writel(0x6000, &dac->type);
@@ -684,10 +684,10 @@
 		par->flags &= ~FFB_FLAG_BLANKED;
 		break;
 
-	case 1: /* Normal blanking */
-	case 2: /* VESA blank (vsync off) */
-	case 3: /* VESA blank (hsync off) */
-	case 4: /* Poweroff */
+	case FB_BLANK_NORMAL: /* Normal blanking */
+	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
+	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
+	case FB_BLANK_POWERDOWN: /* Poweroff */
 		upa_writel(0x6000, &dac->type);
 		tmp = (upa_readl(&dac->value) & ~0x1);
 		upa_writel(0x6000, &dac->type);
@@ -969,7 +969,6 @@
 			   FBINFO_HWACCEL_IMAGEBLIT);
 	all->info.fbops = &ffb_ops;
 	all->info.screen_base = (char *) all->par.physbase + FFB_DFB24_POFF;
-	all->info.currcon = -1;
 	all->info.par = &all->par;
 	all->info.pseudo_palette = all->pseudo_palette;
 
diff -Nru a/drivers/video/fm2fb.c b/drivers/video/fm2fb.c
--- a/drivers/video/fm2fb.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/video/fm2fb.c	2004-12-24 13:36:47 -08:00
@@ -2,7 +2,7 @@
  *  linux/drivers/video/fm2fb.c -- BSC FrameMaster II/Rainbow II frame buffer
  *				   device
  *
- *	Copyright (C) 1998 Steffen A. Mork (mork@ls7.cs.uni-dortmund.de)
+ *	Copyright (C) 1998 Steffen A. Mork (linux-dev@morknet.de)
  *	Copyright (C) 1999 Geert Uytterhoeven
  *
  *  Written for 2.0.x by Steffen A. Mork
@@ -292,18 +292,7 @@
 	return 0;
 }
 
-int __init fm2fb_setup(char *options);
-
-int __init fm2fb_init(void)
-{
-	char *option = NULL;
-
-	if (fb_get_options("fm2fb", &option))
-		return -ENODEV;
-	fm2fb_setup(option);
-	return zorro_register_driver(&fm2fb_driver);
-}
-
+int __init fm2fb_setup(char *options)
 {
 	char *this_opt;
 
@@ -317,6 +306,16 @@
 			fm2fb_mode = FM2FB_MODE_NTSC;
 	}
 	return 0;
+}
+
+int __init fm2fb_init(void)
+{
+	char *option = NULL;
+
+	if (fb_get_options("fm2fb", &option))
+		return -ENODEV;
+	fm2fb_setup(option);
+	return zorro_register_driver(&fm2fb_driver);
 }
 
 module_init(fm2fb_init);
diff -Nru a/drivers/video/gbefb.c b/drivers/video/gbefb.c
--- a/drivers/video/gbefb.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/video/gbefb.c	2004-12-24 13:36:47 -08:00
@@ -384,11 +384,11 @@
 {
 	/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */
 	switch (blank) {
-	case 0:		/* unblank */
+	case FB_BLANK_UNBLANK:		/* unblank */
 		gbe_turn_on();
 		break;
 
-	case 1:		/* blank */
+	case FB_BLANK_NORMAL:		/* blank */
 		gbe_turn_off();
 		break;
 
@@ -1018,8 +1018,8 @@
 		else
 			phys_size = TILE_SIZE - offset;
 
-		if (remap_page_range
-		    (vma, addr, phys_addr, phys_size, vma->vm_page_prot))
+		if (remap_pfn_range(vma, addr, phys_addr >> PAGE_SHIFT,
+						phys_size, vma->vm_page_prot))
 			return -EAGAIN;
 
 		offset = 0;
@@ -1084,9 +1084,9 @@
 	int i, ret = 0;
 
 #ifndef MODULE
-	char *option = NULL;
+	char *options = NULL;
 
-	if (fb_get_options("gbefb", &option))
+	if (fb_get_options("gbefb", &options))
 		return -ENODEV;
 	gbefb_setup(options);
 #endif
@@ -1140,7 +1140,6 @@
 	for (i = 0; i < (gbe_mem_size >> TILE_SHIFT); i++)
 		gbe_tiles.cpu[i] = (gbe_mem_phys >> TILE_SHIFT) + i;
 
-	fb_info.currcon = -1;
 	fb_info.fbops = &gbefb_ops;
 	fb_info.pseudo_palette = pseudo_palette;
 	fb_info.flags = FBINFO_DEFAULT;
diff -Nru a/drivers/video/hgafb.c b/drivers/video/hgafb.c
--- a/drivers/video/hgafb.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/video/hgafb.c	2004-12-24 13:37:18 -08:00
@@ -59,16 +59,16 @@
 
 /* Description of the hardware layout */
 
-static unsigned long hga_vram_base;		/* Base of video memory */
+static void __iomem *hga_vram;			/* Base of video memory */
 static unsigned long hga_vram_len;		/* Size of video memory */
 
 #define HGA_ROWADDR(row) ((row%4)*8192 + (row>>2)*90)
 #define HGA_TXT			0
 #define HGA_GFX			1
 
-static inline u8* rowaddr(struct fb_info *info, u_int row)
+static inline u8 __iomem * rowaddr(struct fb_info *info, u_int row)
 {
-        return info->screen_base + HGA_ROWADDR(row);
+	return info->screen_base + HGA_ROWADDR(row);
 }
 
 static int hga_mode = -1;			/* 0 = txt, 1 = gfx mode */
@@ -176,7 +176,7 @@
 		fillchar = 0x00;
 	spin_unlock_irqrestore(&hga_reg_lock, flags);
 	if (fillchar != 0xbf)
-		isa_memset_io(hga_vram_base, fillchar, hga_vram_len);
+		memset_io(hga_vram, fillchar, hga_vram_len);
 }
 
 static void hga_txt_mode(void)
@@ -244,13 +244,13 @@
 static void hga_show_logo(struct fb_info *info)
 {
 /*
-	unsigned long dest = hga_vram_base;
+	void __iomem *dest = hga_vram;
 	char *logo = linux_logo_bw;
 	int x, y;
 	
 	for (y = 134; y < 134 + 80 ; y++) * this needs some cleanup *
 		for (x = 0; x < 10 ; x++)
-			isa_writeb(~*(logo++),(dest + HGA_ROWADDR(y) + x + 40));
+			writeb(~*(logo++),(dest + HGA_ROWADDR(y) + x + 40));
 */
 }
 
@@ -282,12 +282,13 @@
 static int __init hga_card_detect(void)
 {
 	int count=0;
-	unsigned long p, q;
+	void __iomem *p, *q;
 	unsigned short p_save, q_save;
 
-	hga_vram_base = 0xb0000;
 	hga_vram_len  = 0x08000;
 
+	hga_vram = ioremap(0xb0000, hga_vram_len);
+
 	if (request_region(0x3b0, 12, "hgafb"))
 		release_io_ports = 1;
 	if (request_region(0x3bf, 1, "hgafb"))
@@ -295,14 +296,14 @@
 
 	/* do a memory check */
 
-	p = hga_vram_base;
-	q = hga_vram_base + 0x01000;
+	p = hga_vram;
+	q = hga_vram + 0x01000;
 
-	p_save = isa_readw(p); q_save = isa_readw(q);
+	p_save = readw(p); q_save = readw(q);
 
-	isa_writew(0xaa55, p); if (isa_readw(p) == 0xaa55) count++;
-	isa_writew(0x55aa, p); if (isa_readw(p) == 0x55aa) count++;
-	isa_writew(p_save, p);
+	writew(0xaa55, p); if (readw(p) == 0xaa55) count++;
+	writew(0x55aa, p); if (readw(p) == 0x55aa) count++;
+	writew(p_save, p);
 
 	if (count != 2) {
 		return 0;
@@ -455,7 +456,7 @@
 static void hgafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 {
 	u_int rows, y;
-	u8 *dest;
+	u8 __iomem *dest;
 
 	y = rect->dy;
 
@@ -466,7 +467,7 @@
 			//fb_memset(dest, rect->color, (rect->width >> 3));
 			break;
 		case ROP_XOR:
-			*dest = ~*dest;
+			fb_writeb(~(fb_readb(dest)), dest);
 			break;
 		}
 	}
@@ -475,7 +476,8 @@
 static void hgafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
 {
 	u_int rows, y1, y2;
-	u8 *src, *dest;
+	u8 __iomem *src;
+	u8 __iomem *dest;
 
 	if (area->dy <= area->sy) {
 		y1 = area->sy;
@@ -504,14 +506,15 @@
 
 static void hgafb_imageblit(struct fb_info *info, const struct fb_image *image)
 {
-	u8 *dest, *cdat = (u8 *) image->data;
+	u8 __iomem *dest;
+	u8 *cdat = (u8 *) image->data;
 	u_int rows, y = image->dy;
 	u8 d;
 
 	for (rows = image->height; rows--; y++) {
 		d = *cdat++;
 		dest = rowaddr(info, y) + (image->dx >> 3);
-		*dest = d;
+		fb_writeb(d, dest);
 	}
 }
 #else /* !CONFIG_FB_HGA_ACCEL */
@@ -552,13 +555,15 @@
 
 	if (! hga_card_detect()) {
 		printk(KERN_INFO "hgafb: HGA card not detected.\n");
+		if (hga_vram)
+			iounmap(hga_vram);
 		return -EINVAL;
 	}
 
 	printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n",
 		hga_type_name, hga_vram_len/1024);
 
-	hga_fix.smem_start = VGA_MAP_MEM(hga_vram_base);
+	hga_fix.smem_start = (unsigned long)hga_vram;
 	hga_fix.smem_len = hga_vram_len;
 
 	fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
@@ -570,10 +575,12 @@
 	fb_info.monspecs.vfmax = 10000;
 	fb_info.monspecs.dpms = 0;
 	fb_info.fbops = &hgafb_ops;
-	fb_info.screen_base = (char *)hga_fix.smem_start;
+	fb_info.screen_base = hga_vram;
 
-        if (register_framebuffer(&fb_info) < 0)
-                return -EINVAL;
+        if (register_framebuffer(&fb_info) < 0) {
+		iounmap(hga_vram);
+		return -EINVAL;
+	}
 
         printk(KERN_INFO "fb%d: %s frame buffer device\n",
                fb_info.node, fb_info.fix.id);
@@ -595,6 +602,7 @@
 	hga_txt_mode();
 	hga_clear_screen();
 	unregister_framebuffer(&fb_info);
+	iounmap(hga_vram);
 	if (release_io_ports) release_region(0x3b0, 12);
 	if (release_io_port) release_region(0x3bf, 1);
 }
diff -Nru a/drivers/video/hpfb.c b/drivers/video/hpfb.c
--- a/drivers/video/hpfb.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/video/hpfb.c	2004-12-24 13:36:55 -08:00
@@ -1,6 +1,8 @@
 /*
  *	HP300 Topcat framebuffer support (derived from macfb of all things)
  *	Phil Blundell <philb@gnu.org> 1998
+ *	DIO-II, colour map and Catseye support by
+ *	Kars de Jong <jongk@linux-m68k.org>, May 2004.
  */
 
 #include <linux/module.h>
@@ -15,19 +17,36 @@
 #include <linux/init.h>
 #include <linux/fb.h>
 #include <linux/dio.h>
+
 #include <asm/io.h>
-#include <asm/blinken.h>
-#include <asm/hwtest.h>
+#include <asm/uaccess.h>
 
-static struct fb_info fb_info;
+static struct fb_info fb_info = {
+	.fix = {
+		.id		= "HP300 ",
+		.type		= FB_TYPE_PACKED_PIXELS,
+		.visual		= FB_VISUAL_PSEUDOCOLOR,
+		.accel		= FB_ACCEL_NONE,
+	}
+};
 
-unsigned long fb_regs;
-unsigned char fb_bitmask;
+static unsigned long fb_regs;
+static unsigned char fb_bitmask;
 
+#define TC_NBLANK	0x4080
 #define TC_WEN		0x4088
 #define TC_REN		0x408c
 #define TC_FBEN		0x4090
-#define TC_NBLANK	0x4080
+#define TC_PRR		0x40ea
+
+/* These defines match the X window system */
+#define RR_CLEAR	0x0
+#define RR_COPY		0x3
+#define RR_NOOP		0x5
+#define RR_XOR		0x6
+#define RR_INVERT	0xa
+#define RR_COPYINVERTED 0xc
+#define RR_SET		0xf
 
 /* blitter regs */
 #define BUSY		0x4044
@@ -40,129 +59,250 @@
 #define WWIDTH		0x4102
 #define WMOVE		0x409c
 
-static struct fb_fix_screeninfo hpfb_fix __initdata = {
-	.id		= "HP300 Topcat",
-	.smem_len	= 1024*768,
-	.type		= FB_TYPE_PACKED_PIXELS,
-	.visual		= FB_VISUAL_PSEUDOCOLOR,
-	.line_length	= 1024,
-	.accel		= FB_ACCEL_NONE,
-};
-
 static struct fb_var_screeninfo hpfb_defined = {
-	.xres		= 1024,
-	.yres		= 768,
-	.xres_virtual	= 1024,
-	.yres_virtual	= 786,
-	.bits_per_pixel	= 1,
-	.red		= {0,2,0},	/* R */
-	.green		= {0,2,0},	/* G */
-	.blue		= {0,2,0},	/* B */
+	.red		= {
+		.length = 8,
+	},
+	.green		= {
+		.length = 8,
+	},
+	.blue		= {
+		.length = 8,
+	},
 	.activate	= FB_ACTIVATE_NOW,
-	.height		= 274,
-	.width		= 195,	/* 14" monitor */
-	.accel_flags	= FB_ACCEL_NONE,
+	.height		= -1,
+	.width		= -1,
 	.vmode		= FB_VMODE_NONINTERLACED,
 };
 
-/*
- * Set the palette.  This may not work on all boards but only experimentation 
- * will tell.
- * XXX Doesn't work at all.
- */
 static int hpfb_setcolreg(unsigned regno, unsigned red, unsigned green,
-                           unsigned blue, unsigned transp,
-                           struct fb_info *info)
+			  unsigned blue, unsigned transp,
+			  struct fb_info *info)
 {
+	/* use MSBs */
+	unsigned char _red  =red>>8;
+	unsigned char _green=green>>8;
+	unsigned char _blue =blue>>8;
+	unsigned char _regno=regno;
+
+	/*
+	 *  Set a single color register. The values supplied are
+	 *  already rounded down to the hardware's capabilities
+	 *  (according to the entries in the `var' structure). Return
+	 *  != 0 for invalid regno.
+	 */
+
+	if (regno >= info->cmap.len)
+		return 1;
+	
 	while (in_be16(fb_regs + 0x6002) & 0x4) udelay(1);
-	out_be16(fb_regs + 0x60f0, 0);
-	out_be16(fb_regs + 0x60b8, regno);
-	out_be16(fb_regs + 0x60b2, red);
-	out_be16(fb_regs + 0x60b4, green);
-	out_be16(fb_regs + 0x60b6, blue);
+
+	out_be16(fb_regs + 0x60ba, 0xff);
+
+	out_be16(fb_regs + 0x60b2, _red);
+	out_be16(fb_regs + 0x60b4, _green);
+	out_be16(fb_regs + 0x60b6, _blue);
+	out_be16(fb_regs + 0x60b8, ~_regno);
 	out_be16(fb_regs + 0x60f0, 0xff);
+
 	udelay(100);
-	out_be16(fb_regs + 0x60ba, 0xffff);
+
+	while (in_be16(fb_regs + 0x6002) & 0x4) udelay(1);
+	out_be16(fb_regs + 0x60b2, 0);
+	out_be16(fb_regs + 0x60b4, 0);
+	out_be16(fb_regs + 0x60b6, 0);
+	out_be16(fb_regs + 0x60b8, 0);
+
+	return 0;
+}
+
+/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */
+
+static int hpfb_blank(int blank, struct fb_info *info)
+{
+	out_8(fb_regs + TC_NBLANK, (blank ? 0x00 : fb_bitmask));
+
 	return 0;
 }
 
-void hpfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) 
+static void topcat_blit(int x0, int y0, int x1, int y1, int w, int h, int rr)
 {
-	while (in_8(fb_regs + BUSY) & fb_bitmask);
-	out_8(fb_regs + WMRR, 0x3);
-	out_be16(fb_regs + SOURCE_X, area->sx);
-	out_be16(fb_regs + SOURCE_Y, area->sy);
-	out_be16(fb_regs + DEST_X, area->dx);
-	out_be16(fb_regs + DEST_Y, area->dy);
-	out_be16(fb_regs + WHEIGHT, area->height);
-	out_be16(fb_regs + WWIDTH, area->width);
+	if (rr >= 0) {
+		while (in_8(fb_regs + BUSY) & fb_bitmask)
+			;
+	}
+	out_8(fb_regs + TC_FBEN, fb_bitmask);
+	if (rr >= 0) {
+		out_8(fb_regs + TC_WEN, fb_bitmask);
+		out_8(fb_regs + WMRR, rr);
+	}
+	out_be16(fb_regs + SOURCE_X, x0);
+	out_be16(fb_regs + SOURCE_Y, y0);
+	out_be16(fb_regs + DEST_X, x1);
+	out_be16(fb_regs + DEST_Y, y1);
+	out_be16(fb_regs + WWIDTH, w);
+	out_be16(fb_regs + WHEIGHT, h);
 	out_8(fb_regs + WMOVE, fb_bitmask);
 }
 
+static void hpfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) 
+{
+	topcat_blit(area->sx, area->sy, area->dx, area->dy, area->width, area->height, RR_COPY);
+}
+
+static void hpfb_fillrect(struct fb_info *p, const struct fb_fillrect *region)
+{
+	u8 clr;
+
+	clr = region->color & 0xff;
+
+	while (in_8(fb_regs + BUSY) & fb_bitmask)
+		;
+
+	/* Foreground */
+	out_8(fb_regs + TC_WEN, fb_bitmask & clr);
+	out_8(fb_regs + WMRR, (region->rop == ROP_COPY ? RR_SET : RR_INVERT));
+
+	/* Background */
+	out_8(fb_regs + TC_WEN, fb_bitmask & ~clr);
+	out_8(fb_regs + WMRR, (region->rop == ROP_COPY ? RR_CLEAR : RR_NOOP));
+
+	topcat_blit(region->dx, region->dy, region->dx, region->dy, region->width, region->height, -1);
+}
+
+static int hpfb_sync(struct fb_info *info)
+{
+	/*
+	 * Since we also access the framebuffer directly, we have to wait
+	 * until the block mover is finished
+	 */
+	while (in_8(fb_regs + BUSY) & fb_bitmask)
+		;
+
+	out_8(fb_regs + TC_WEN, fb_bitmask);
+	out_8(fb_regs + TC_PRR, RR_COPY);
+	out_8(fb_regs + TC_FBEN, fb_bitmask);
+
+	return 0;
+}
+
 static struct fb_ops hpfb_ops = {
 	.owner		= THIS_MODULE,
 	.fb_setcolreg	= hpfb_setcolreg,
-	.fb_fillrect	= cfb_fillrect,
+	.fb_blank	= hpfb_blank,
+	.fb_fillrect	= hpfb_fillrect,
 	.fb_copyarea	= hpfb_copyarea,
 	.fb_imageblit	= cfb_imageblit,
 	.fb_cursor	= soft_cursor,
+	.fb_sync	= hpfb_sync,
 };
 
-#define TOPCAT_FBOMSB	0x5d
-#define TOPCAT_FBOLSB	0x5f
+/* Common to all HP framebuffers */
+#define HPFB_FBWMSB	0x05	/* Frame buffer width 		*/
+#define HPFB_FBWLSB	0x07
+#define HPFB_FBHMSB	0x09	/* Frame buffer height		*/
+#define HPFB_FBHLSB	0x0b
+#define HPFB_DWMSB	0x0d	/* Display width		*/
+#define HPFB_DWLSB	0x0f
+#define HPFB_DHMSB	0x11	/* Display height		*/
+#define HPFB_DHLSB	0x13
+#define HPFB_NUMPLANES	0x5b	/* Number of colour planes	*/
+#define HPFB_FBOMSB	0x5d	/* Frame buffer offset		*/
+#define HPFB_FBOLSB	0x5f
 
-int __init hpfb_init_one(unsigned long base)
+static int __init hpfb_init_one(unsigned long phys_base, unsigned long virt_base)
 {
-	unsigned long fboff;
+	unsigned long fboff, fb_width, fb_height, fb_start;
 
-	if (fb_get_options("hpfb", NULL))
-		return -ENODEV;
+	fb_regs = virt_base;
+	fboff = (in_8(fb_regs + HPFB_FBOMSB) << 8) | in_8(fb_regs + HPFB_FBOLSB);
 
-	fboff = (in_8(base + TOPCAT_FBOMSB) << 8) | in_8(base + TOPCAT_FBOLSB);
+	fb_info.fix.smem_start = (in_8(fb_regs + fboff) << 16);
 
-	hpfb_fix.smem_start = 0xf0000000 | (in_8(base + fboff) << 16);
-	fb_regs = base;
+	if (phys_base >= DIOII_BASE) {
+		fb_info.fix.smem_start += phys_base;
+	}
+
+	if (DIO_SECID(fb_regs) != DIO_ID2_TOPCAT) {
+		/* This is the magic incantation the HP X server uses to make Catseye boards work. */
+		while (in_be16(fb_regs+0x4800) & 1)
+			;
+		out_be16(fb_regs+0x4800, 0);	/* Catseye status */
+		out_be16(fb_regs+0x4510, 0);	/* VB */
+		out_be16(fb_regs+0x4512, 0);	/* TCNTRL */
+		out_be16(fb_regs+0x4514, 0);	/* ACNTRL */
+		out_be16(fb_regs+0x4516, 0);	/* PNCNTRL */
+		out_be16(fb_regs+0x4206, 0x90);	/* RUG Command/Status */
+		out_be16(fb_regs+0x60a2, 0);	/* Overlay Mask */
+		out_be16(fb_regs+0x60bc, 0);	/* Ram Select */
+	}
+
+	/*
+	 *	Fill in the available video resolution
+	 */
+	fb_width = (in_8(fb_regs + HPFB_FBWMSB) << 8) | in_8(fb_regs + HPFB_FBWLSB);
+	fb_info.fix.line_length = fb_width;
+	fb_height = (in_8(fb_regs + HPFB_FBHMSB) << 8) | in_8(fb_regs + HPFB_FBHLSB);
+	fb_info.fix.smem_len = fb_width * fb_height;
+	fb_start = (unsigned long)ioremap_writethrough(fb_info.fix.smem_start,
+						       fb_info.fix.smem_len);
+	hpfb_defined.xres = (in_8(fb_regs + HPFB_DWMSB) << 8) | in_8(fb_regs + HPFB_DWLSB);
+	hpfb_defined.yres = (in_8(fb_regs + HPFB_DHMSB) << 8) | in_8(fb_regs + HPFB_DHLSB);
+	hpfb_defined.xres_virtual = hpfb_defined.xres;
+	hpfb_defined.yres_virtual = hpfb_defined.yres;
+	hpfb_defined.bits_per_pixel = in_8(fb_regs + HPFB_NUMPLANES);
+
+	printk(KERN_INFO "hpfb: framebuffer at 0x%lx, mapped to 0x%lx, size %dk\n",
+	       fb_info.fix.smem_start, fb_start, fb_info.fix.smem_len/1024);
+	printk(KERN_INFO "hpfb: mode is %dx%dx%d, linelength=%d\n",
+	       hpfb_defined.xres, hpfb_defined.yres, hpfb_defined.bits_per_pixel, fb_info.fix.line_length);
 
-#if 0
-	/* This is the magic incantation NetBSD uses to make Catseye boards work. */
-	out_8(base+0x4800, 0);
-	out_8(base+0x4510, 0);
-	out_8(base+0x4512, 0);
-	out_8(base+0x4514, 0);
-	out_8(base+0x4516, 0);
-	out_8(base+0x4206, 0x90);
-#endif
-	/* 
+	/*
 	 *	Give the hardware a bit of a prod and work out how many bits per
 	 *	pixel are supported.
 	 */
-	
-	out_8(base + TC_WEN, 0xff);
-	out_8(base + TC_FBEN, 0xff);
-	out_8(hpfb_fix.smem_start, 0xff);
-	fb_bitmask = in_8(hpfb_fix.smem_start);
+	out_8(fb_regs + TC_WEN, 0xff);
+	out_8(fb_regs + TC_PRR, RR_COPY);
+	out_8(fb_regs + TC_FBEN, 0xff);
+	out_8(fb_start, 0xff);
+	fb_bitmask = in_8(fb_start);
+	out_8(fb_start, 0);
 
 	/*
 	 *	Enable reading/writing of all the planes.
 	 */
-	out_8(base + TC_WEN, fb_bitmask);
-	out_8(base + TC_REN, fb_bitmask);
-	out_8(base + TC_FBEN, fb_bitmask);
-	out_8(base + TC_NBLANK, 0x1);
+	out_8(fb_regs + TC_WEN, fb_bitmask);
+	out_8(fb_regs + TC_PRR, RR_COPY);
+	out_8(fb_regs + TC_REN, fb_bitmask);
+	out_8(fb_regs + TC_FBEN, fb_bitmask);
+
+	/*
+	 *	Clear the screen.
+	 */
+	topcat_blit(0, 0, 0, 0, fb_width, fb_height, RR_CLEAR);
 
 	/*
 	 *	Let there be consoles..
 	 */
+	if (DIO_SECID(fb_regs) == DIO_ID2_TOPCAT)
+		strcat(fb_info.fix.id, "Topcat");
+	else
+		strcat(fb_info.fix.id, "Catseye");
 	fb_info.fbops = &hpfb_ops;
 	fb_info.flags = FBINFO_DEFAULT;
 	fb_info.var   = hpfb_defined;
-	fb_info.fix   = hpfb_fix;
-	fb_info.screen_base = (char *)hpfb_fix.smem_start;	// FIXME
+	fb_info.screen_base = (char *)fb_start;
 
-	fb_alloc_cmap(&fb_info.cmap, 256, 0);
+	fb_alloc_cmap(&fb_info.cmap, 1 << hpfb_defined.bits_per_pixel, 0);
 
-	if (register_framebuffer(&fb_info) < 0)
+	if (register_framebuffer(&fb_info) < 0) {
+		fb_dealloc_cmap(&fb_info.cmap);
 		return 1;
+	}
+
+	printk(KERN_INFO "fb%d: %s frame buffer device\n",
+	       fb_info.node, fb_info.fix.id);
+
 	return 0;
 }
 
@@ -177,42 +317,100 @@
 /* 
  * Initialise the framebuffer
  */
+static int __devinit hpfb_dio_probe(struct dio_dev * d, const struct dio_device_id * ent)
+{
+	unsigned long paddr, vaddr;
+
+	paddr = d->resource.start;
+	if (!request_mem_region(d->resource.start, d->resource.end - d->resource.start, d->name))
+                return -EBUSY;
+
+	if (d->scode >= DIOII_SCBASE) {
+		vaddr = (unsigned long)ioremap(paddr, d->resource.end - d->resource.start);
+	} else {
+		vaddr = paddr + DIO_VIRADDRBASE;
+	}
+	printk(KERN_INFO "Topcat found at DIO select code %d "
+	       "(secondary id %02x)\n", d->scode, (d->id >> 8) & 0xff);
+	if (hpfb_init_one(paddr, vaddr)) {
+		if (d->scode >= DIOII_SCBASE)
+			iounmap((void *)vaddr);
+		return -ENOMEM;
+	}
+	return 0;
+}
+
+static void __devexit hpfb_remove_one(struct dio_dev *d)
+{
+	unregister_framebuffer(&fb_info);
+	if (d->scode >= DIOII_SCBASE)
+		iounmap((void *)fb_regs);
+        release_mem_region(d->resource.start, d->resource.end - d->resource.start);
+}
+
+static struct dio_device_id hpfb_dio_tbl[] = {
+    { DIO_ENCODE_ID(DIO_ID_FBUFFER, DIO_ID2_LRCATSEYE) },
+    { DIO_ENCODE_ID(DIO_ID_FBUFFER, DIO_ID2_HRCCATSEYE) },
+    { DIO_ENCODE_ID(DIO_ID_FBUFFER, DIO_ID2_HRMCATSEYE) },
+    { DIO_ENCODE_ID(DIO_ID_FBUFFER, DIO_ID2_TOPCAT) },
+    { 0 }
+};
+
+static struct dio_driver hpfb_driver = {
+    .name      = "hpfb",
+    .id_table  = hpfb_dio_tbl,
+    .probe     = hpfb_dio_probe,
+    .remove    = __devexit_p(hpfb_remove_one),
+};
 
 int __init hpfb_init(void)
 {
 	unsigned int sid;
+	mm_segment_t fs;
+	unsigned char i;
+	int err;
 
 	/* Topcats can be on the internal IO bus or real DIO devices.
-	 * The internal variant sits at 0xf0560000; it has primary
+	 * The internal variant sits at 0x560000; it has primary
 	 * and secondary ID registers just like the DIO version.
 	 * So we merge the two detection routines.
 	 *
 	 * Perhaps this #define should be in a global header file:
 	 * I believe it's common to all internal fbs, not just topcat.
 	 */
-#define INTFBADDR 0xf0560000
+#define INTFBVADDR 0xf0560000
+#define INTFBPADDR 0x560000
 
-	if (hwreg_present((void *)INTFBADDR) && 
-	   (DIO_ID(INTFBADDR) == DIO_ID_FBUFFER) &&
-	    topcat_sid_ok(sid = DIO_SECID(INTFBADDR))) {
-		printk("Internal Topcat found (secondary id %02x)\n", sid); 
-		hpfb_init_one(INTFBADDR);
-	} else {
-		int sc = dio_find(DIO_ID_FBUFFER);
+	if (!MACH_IS_HP300)
+		return -ENXIO;
+
+	if (fb_get_options("hpfb", NULL))
+		return -ENODEV;
 
-		if (sc) {
-			unsigned long addr = (unsigned long)dio_scodetoviraddr(sc);
-			unsigned int sid = DIO_SECID(addr);
-
-			if (topcat_sid_ok(sid)) {
-				printk("Topcat found at DIO select code %02x "
-					"(secondary id %02x)\n", sc, sid);
-				hpfb_init_one(addr);
-			}
+	dio_module_init(&hpfb_driver);
+
+	fs = get_fs();
+	set_fs(KERNEL_DS);
+	err = get_user(i, (unsigned char *)INTFBVADDR + DIO_IDOFF);
+	set_fs(fs);
+
+	if (!err && (i == DIO_ID_FBUFFER) && topcat_sid_ok(sid = DIO_SECID(INTFBVADDR))) {
+		if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat"))
+			return -EBUSY;
+		printk(KERN_INFO "Internal Topcat found (secondary id %02x)\n", sid);
+		if (hpfb_init_one(INTFBPADDR, INTFBVADDR)) {
+			return -ENOMEM;
 		}
 	}
 	return 0;
 }
 
+void __exit hpfb_cleanup_module(void)
+{
+	dio_unregister_driver(&hpfb_driver);
+}
+
 module_init(hpfb_init);
+module_exit(hpfb_cleanup_module);
+
 MODULE_LICENSE("GPL");
diff -Nru a/drivers/video/i810/i810.h b/drivers/video/i810/i810.h
--- a/drivers/video/i810/i810.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/video/i810/i810.h	2004-12-24 13:37:19 -08:00
@@ -201,6 +201,7 @@
 #define HAS_ACCELERATION            2
 #define ALWAYS_SYNC                 4
 #define LOCKUP                      8
+#define USE_HWCUR                  16
 
 struct gtt_data {
 	struct agp_memory *i810_fb_memory;
@@ -222,7 +223,7 @@
 
 struct heap_data {
         unsigned long physical;
-	__u8 *virtual;
+	__u8 __iomem *virtual;
 	u32 offset;
 	u32 size;
 };	
@@ -251,12 +252,10 @@
 	struct heap_data         iring;
 	struct heap_data         cursor_heap;
 	struct vgastate          state;
-	drm_agp_t                *drm_agp;
 	atomic_t                 use_count;
 	u32 pseudo_palette[17];
-	u32 pci_state[16];
 	unsigned long mmio_start_phys;
-	u8 *mmio_start_virtual;
+	u8 __iomem *mmio_start_virtual;
 	u32 pitch;
 	u32 pixconf;
 	u32 watermark;
diff -Nru a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
--- a/drivers/video/i810/i810_accel.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/video/i810/i810_accel.c	2004-12-24 13:36:18 -08:00
@@ -32,7 +32,7 @@
 /************************************************************/
 
 /* BLT Engine Routines */
-static inline void i810_report_error(u8 *mmio)
+static inline void i810_report_error(u8 __iomem *mmio)
 {
 	printk("IIR     : 0x%04x\n"
 	       "EIR     : 0x%04x\n"
@@ -59,7 +59,7 @@
 {
 	struct i810fb_par *par = (struct i810fb_par *) info->par;
 	u32 head, count = WAIT_COUNT, tail;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	tail = par->cur_tail;
 	while (count--) {
@@ -89,7 +89,7 @@
 static inline int wait_for_engine_idle(struct fb_info *info)
 {
 	struct i810fb_par *par = (struct i810fb_par *) info->par;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 	int count = WAIT_COUNT;
 
 	if (wait_for_space(info, par->iring.size)) /* flush */
@@ -133,7 +133,7 @@
  */
 static inline void end_iring(struct i810fb_par *par)
 {
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	i810_writel(IRING, mmio, par->cur_tail);
 }
@@ -326,7 +326,7 @@
 static inline void i810fb_iring_enable(struct i810fb_par *par, u32 mode)
 {
 	u32 tmp;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	tmp = i810_readl(IRING + 12, mmio);
 	if (mode == OFF) 
@@ -451,7 +451,7 @@
 void i810fb_load_front(u32 offset, struct fb_info *info)
 {
 	struct i810fb_par *par = (struct i810fb_par *) info->par;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	if (!info->var.accel_flags || par->dev_flags & LOCKUP)
 		i810_writel(DPLYBASE, mmio, par->fb.physical + offset);
@@ -472,7 +472,7 @@
 {
 	struct i810fb_par *par = (struct i810fb_par *) info->par;
 	u32 tmp1, tmp2;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 	
 	wait_for_engine_idle(info);
 	i810fb_iring_enable(par, OFF);
diff -Nru a/drivers/video/i810/i810_gtf.c b/drivers/video/i810/i810_gtf.c
--- a/drivers/video/i810/i810_gtf.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/video/i810/i810_gtf.c	2004-12-24 13:36:56 -08:00
@@ -124,7 +124,8 @@
 			     struct i810fb_par *par, u32 xres, u32 yres)
 {
 	int n, blank_s, blank_e;
-	u8 *mmio = par->mmio_start_virtual, msr = 0;
+	u8 __iomem *mmio = par->mmio_start_virtual;
+	u8 msr = 0;
 
 	/* Horizontal */
 	/* htotal */
diff -Nru a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
--- a/drivers/video/i810/i810_main.c	2004-12-24 13:36:34 -08:00
+++ b/drivers/video/i810/i810_main.c	2004-12-24 13:36:34 -08:00
@@ -121,7 +121,7 @@
  * DESCRIPTION:
  * Blanks/unblanks the display
  */
-static void i810_screen_off(u8 *mmio, u8 mode)
+static void i810_screen_off(u8 __iomem *mmio, u8 mode)
 {
 	u32 count = WAIT_COUNT;
 	u8 val;
@@ -145,7 +145,7 @@
  * Turns off DRAM refresh.  Must be off for only 2 vsyncs
  * before data becomes corrupt
  */
-static void i810_dram_off(u8 *mmio, u8 mode)
+static void i810_dram_off(u8 __iomem *mmio, u8 mode)
 {
 	u8 val;
 
@@ -164,7 +164,7 @@
  * The IBM VGA standard allows protection of certain VGA registers.  
  * This will  protect or unprotect them. 
  */
-static void i810_protect_regs(u8 *mmio, int mode)
+static void i810_protect_regs(u8 __iomem *mmio, int mode)
 {
 	u8 reg;
 
@@ -187,7 +187,7 @@
 static void i810_load_pll(struct i810fb_par *par)
 {
 	u32 tmp1, tmp2;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 	
 	tmp1 = par->regs.M | par->regs.N << 16;
 	tmp2 = i810_readl(DCLK_2D, mmio);
@@ -212,7 +212,7 @@
  */
 static void i810_load_vga(struct i810fb_par *par)
 {	
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	/* interlace */
 	i810_writeb(CR_INDEX_CGA, mmio, CR70);
@@ -255,7 +255,7 @@
  */
 static void i810_load_vgax(struct i810fb_par *par)
 {
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	i810_writeb(CR_INDEX_CGA, mmio, CR30);
 	i810_writeb(CR_DATA_CGA, mmio, par->regs.cr30);
@@ -281,7 +281,8 @@
 static void i810_load_2d(struct i810fb_par *par)
 {
 	u32 tmp;
-	u8 tmp8, *mmio = par->mmio_start_virtual;
+	u8 tmp8;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
   	i810_writel(FW_BLC, mmio, par->watermark); 
 	tmp = i810_readl(PIXCONF, mmio);
@@ -301,7 +302,7 @@
  * i810_hires - enables high resolution mode
  * @mmio: address of register space
  */
-static void i810_hires(u8 *mmio)
+static void i810_hires(u8 __iomem *mmio)
 {
 	u8 val;
 	
@@ -321,7 +322,8 @@
 static void i810_load_pitch(struct i810fb_par *par)
 {
 	u32 tmp, pitch;
-	u8 val, *mmio = par->mmio_start_virtual;
+	u8 val;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 			
 	pitch = par->pitch >> 3;
 	i810_writeb(SR_INDEX, mmio, SR01);
@@ -351,9 +353,10 @@
  */
 static void i810_load_color(struct i810fb_par *par)
 {
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 	u32 reg1;
 	u16 reg2;
+
 	reg1 = i810_readl(PIXCONF, mmio) & ~(0xF0000 | 1 << 27);
 	reg2 = i810_readw(BLTCNTL, mmio) & ~0x30;
 
@@ -372,7 +375,7 @@
  */
 static void i810_load_regs(struct i810fb_par *par)
 {
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	i810_screen_off(mmio, OFF);
 	i810_protect_regs(mmio, OFF);
@@ -390,7 +393,7 @@
 }
 
 static void i810_write_dac(u8 regno, u8 red, u8 green, u8 blue,
-			  u8 *mmio)
+			  u8 __iomem *mmio)
 {
 	i810_writeb(CLUT_INDEX_WRITE, mmio, regno);
 	i810_writeb(CLUT_DATA, mmio, red);
@@ -399,7 +402,7 @@
 }
 
 static void i810_read_dac(u8 regno, u8 *red, u8 *green, u8 *blue,
-			  u8 *mmio)
+			  u8 __iomem *mmio)
 {
 	i810_writeb(CLUT_INDEX_READ, mmio, regno);
 	*red = i810_readb(CLUT_DATA, mmio);
@@ -413,7 +416,7 @@
 static void i810_restore_pll(struct i810fb_par *par)
 {
 	u32 tmp1, tmp2;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 	
 	tmp1 = par->hw_state.dclk_2d;
 	tmp2 = i810_readl(DCLK_2D, mmio);
@@ -433,7 +436,7 @@
 static void i810_restore_dac(struct i810fb_par *par)
 {
 	u32 tmp1, tmp2;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	tmp1 = par->hw_state.pixconf;
 	tmp2 = i810_readl(PIXCONF, mmio);
@@ -444,7 +447,8 @@
 
 static void i810_restore_vgax(struct i810fb_par *par)
 {
-	u8 i, j, *mmio = par->mmio_start_virtual;
+	u8 i, j;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 	
 	for (i = 0; i < 4; i++) {
 		i810_writeb(CR_INDEX_CGA, mmio, CR30+i);
@@ -477,7 +481,8 @@
 
 static void i810_restore_vga(struct i810fb_par *par)
 {
-	u8 i, *mmio = par->mmio_start_virtual;
+	u8 i;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 	
 	for (i = 0; i < 10; i++) {
 		i810_writeb(CR_INDEX_CGA, mmio, CR00 + i);
@@ -491,7 +496,8 @@
 
 static void i810_restore_addr_map(struct i810fb_par *par)
 {
-	u8 tmp, *mmio = par->mmio_start_virtual;
+	u8 tmp;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	i810_writeb(GR_INDEX, mmio, GR10);
 	tmp = i810_readb(GR_DATA, mmio);
@@ -505,7 +511,7 @@
 {
 	u32 tmp_long;
 	u16 tmp_word;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	tmp_word = i810_readw(BLTCNTL, mmio);
 	tmp_word &= ~(3 << 4); 
@@ -534,7 +540,7 @@
 
 static void i810_restore_vga_state(struct i810fb_par *par)
 {
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	i810_screen_off(mmio, OFF);
 	i810_protect_regs(mmio, OFF);
@@ -556,7 +562,8 @@
 
 static void i810_save_vgax(struct i810fb_par *par)
 {
-	u8 i, *mmio = par->mmio_start_virtual;
+	u8 i;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	for (i = 0; i < 4; i++) {
 		i810_writeb(CR_INDEX_CGA, mmio, CR30 + i);
@@ -579,7 +586,8 @@
 
 static void i810_save_vga(struct i810fb_par *par)
 {
-	u8 i, *mmio = par->mmio_start_virtual;
+	u8 i;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	for (i = 0; i < 10; i++) {
 		i810_writeb(CR_INDEX_CGA, mmio, CR00 + i);
@@ -593,7 +601,7 @@
 
 static void i810_save_2d(struct i810fb_par *par)
 {
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	par->hw_state.dclk_2d = i810_readl(DCLK_2D, mmio);
 	par->hw_state.dclk_1d = i810_readl(DCLK_1D, mmio);
@@ -716,7 +724,7 @@
  * Description:
  * Shows or hides the hardware cursor
  */
-void i810_enable_cursor(u8 *mmio, int mode)
+void i810_enable_cursor(u8 __iomem *mmio, int mode)
 {
 	u32 temp;
 	
@@ -729,7 +737,7 @@
 
 static void i810_reset_cursor_image(struct i810fb_par *par)
 {
-	u8 *addr = par->cursor_heap.virtual;
+	u8 __iomem *addr = par->cursor_heap.virtual;
 	int i, j;
 
 	for (i = 64; i--; ) {
@@ -744,7 +752,7 @@
 static void i810_load_cursor_image(int width, int height, u8 *data,
 				   struct i810fb_par *par)
 {
-	u8 *addr = par->cursor_heap.virtual;
+	u8 __iomem *addr = par->cursor_heap.virtual;
 	int i, j, w = width/8;
 	int mod = width % 8, t_mask, d_mask;
 	
@@ -766,8 +774,8 @@
 static void i810_load_cursor_colors(int fg, int bg, struct fb_info *info)
 {
 	struct i810fb_par *par = (struct i810fb_par *) info->par;
-	u8 *mmio = par->mmio_start_virtual, temp;
-	u8 red, green, blue, trans;
+	u8 __iomem *mmio = par->mmio_start_virtual;
+	u8 red, green, blue, trans, temp;
 
 	i810fb_getcolreg(bg, &red, &green, &blue, &trans, info);
 
@@ -796,7 +804,7 @@
  */
 static void i810_init_cursor(struct i810fb_par *par)
 {
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	i810_enable_cursor(mmio, OFF);
 	i810_writel(CURBASE, mmio, par->cursor_heap.physical);
@@ -1124,7 +1132,8 @@
 			    u8 *transp, struct fb_info *info)
 {
 	struct i810fb_par *par = (struct i810fb_par *) info->par;
-	u8 *mmio = par->mmio_start_virtual, temp;
+	u8 __iomem *mmio = par->mmio_start_virtual;
+	u8 temp;
 
 	if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
 		if ((info->var.green.length == 5 && regno > 31) ||
@@ -1167,7 +1176,7 @@
 	if (count == 0) {
 		memset(&par->state, 0, sizeof(struct vgastate));
 		par->state.flags = VGA_SAVE_CMAP;
-		par->state.vgabase = (caddr_t) par->mmio_start_virtual;
+		par->state.vgabase = par->mmio_start_virtual;
 		save_vga(&par->state);
 
 		i810_save_vga_state(par);
@@ -1203,7 +1212,8 @@
 			    struct fb_info *info)
 {
 	struct i810fb_par *par = (struct i810fb_par *) info->par;
-	u8 *mmio = par->mmio_start_virtual, temp;
+	u8 __iomem *mmio = par->mmio_start_virtual;
+	u8 temp;
 	int i;
 
  	if (regno > 255) return 1;
@@ -1308,28 +1318,33 @@
 static int i810fb_blank (int blank_mode, struct fb_info *info)
 {
 	struct i810fb_par *par = (struct i810fb_par *) info->par;
-	u8 *mmio = par->mmio_start_virtual;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 	int mode = 0, pwr, scr_off = 0;
 	
 	pwr = i810_readl(PWR_CLKC, mmio);
 
-	switch(blank_mode) {
-	case VESA_NO_BLANKING:
+	switch (blank_mode) {
+	case FB_BLANK_UNBLANK:
 		mode = POWERON;
 		pwr |= 1;
 		scr_off = ON;
 		break;
-	case VESA_VSYNC_SUSPEND:
+	case FB_BLANK_NORMAL:
+		mode = POWERON;
+		pwr |= 1;
+		scr_off = OFF;
+		break;
+	case FB_BLANK_VSYNC_SUSPEND:
 		mode = STANDBY;
 		pwr |= 1;
 		scr_off = OFF;
 		break;
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		mode = SUSPEND;
 		pwr |= 1;
 		scr_off = OFF;
 		break;
-	case VESA_POWERDOWN:
+	case FB_BLANK_POWERDOWN:
 		mode = POWERDOWN;
 		pwr &= ~1;
 		scr_off = OFF;
@@ -1337,9 +1352,11 @@
 	default:
 		return -EINVAL; 
 	}
+
 	i810_screen_off(mmio, scr_off);
 	i810_writel(HVSYNC, mmio, mode);
 	i810_writel(PWR_CLKC, mmio, pwr);
+
 	return 0;
 }
 
@@ -1391,9 +1408,10 @@
 static int i810fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 {
 	struct i810fb_par *par = (struct i810fb_par *)info->par;
-	u8 *mmio = par->mmio_start_virtual;	
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
-	if (!info->var.accel_flags || par->dev_flags & LOCKUP) 
+	if (!(par->dev_flags & USE_HWCUR) || !info->var.accel_flags ||
+	    par->dev_flags & LOCKUP)
 		return soft_cursor(info, cursor);
 
 	if (cursor->image.width > 64 || cursor->image.height > 64)
@@ -1406,62 +1424,50 @@
 
 	i810_enable_cursor(mmio, OFF);
 
-	if (cursor->set & FB_CUR_SETHOT)
-		info->cursor.hot = cursor->hot;
-	
 	if (cursor->set & FB_CUR_SETPOS) {
 		u32 tmp;
 
-		info->cursor.image.dx = cursor->image.dx;
-		info->cursor.image.dy = cursor->image.dy;
-		tmp = (info->cursor.image.dx - info->var.xoffset) & 0xffff;
-		tmp |= (info->cursor.image.dy - info->var.yoffset) << 16;
+		tmp = (cursor->image.dx - info->var.xoffset) & 0xffff;
+		tmp |= (cursor->image.dy - info->var.yoffset) << 16;
 		i810_writel(CURPOS, mmio, tmp);
 	}
 
-	if (cursor->set & FB_CUR_SETSIZE) {
+	if (cursor->set & FB_CUR_SETSIZE)
 		i810_reset_cursor_image(par);
-		info->cursor.image.height = cursor->image.height;
-		info->cursor.image.width = cursor->image.width;
-	}
 
-	if (cursor->set & FB_CUR_SETCMAP) {
+	if (cursor->set & FB_CUR_SETCMAP)
 		i810_load_cursor_colors(cursor->image.fg_color,
 					cursor->image.bg_color,
 					info);
-		info->cursor.image.fg_color = cursor->image.fg_color;
-		info->cursor.image.bg_color = cursor->image.bg_color;
-
-	}
 
-	if (cursor->set & (FB_CUR_SETSHAPE)) {
-		int size = ((info->cursor.image.width + 7) >> 3) * 
-			info->cursor.image.height;
+	if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
+		int size = ((cursor->image.width + 7) >> 3) *
+			cursor->image.height;
 		int i;
 		u8 *data = kmalloc(64 * 8, GFP_KERNEL);
 
 		if (data == NULL)
 			return -ENOMEM;
-		info->cursor.image.data = cursor->image.data;
 
-		switch (info->cursor.rop) {
+		switch (cursor->rop) {
 		case ROP_XOR:
 			for (i = 0; i < size; i++)
-				data[i] = info->cursor.image.data[i] ^ info->cursor.mask[i];
+				data[i] = cursor->image.data[i] ^ cursor->mask[i];
 			break;
 		case ROP_COPY:
 		default:
 			for (i = 0; i < size; i++)
-				data[i] = info->cursor.image.data[i] & info->cursor.mask[i];
+				data[i] = cursor->image.data[i] & cursor->mask[i];
 			break;
 		}
-		i810_load_cursor_image(info->cursor.image.width, 
-				       info->cursor.image.height, data,
+
+		i810_load_cursor_image(cursor->image.width,
+				       cursor->image.height, data,
 				       par);
 		kfree(data);
 	}
 
-	if (info->cursor.enable)
+	if (cursor->enable)
 		i810_enable_cursor(mmio, ON);
 
 	return 0;
@@ -1513,11 +1519,11 @@
 	info->fbops->fb_blank(blank, info);
 
 	if (!prev_state) { 
-		par->drm_agp->unbind_memory(par->i810_gtt.i810_fb_memory);
-		par->drm_agp->unbind_memory(par->i810_gtt.i810_cursor_memory);
+		agp_unbind_memory(par->i810_gtt.i810_fb_memory);
+		agp_unbind_memory(par->i810_gtt.i810_cursor_memory);
 		pci_disable_device(dev);
 	}
-	pci_save_state(dev, par->pci_state);
+	pci_save_state(dev);
 	pci_set_power_state(dev, state);
 
 	return 0;
@@ -1531,13 +1537,13 @@
 	if (par->cur_state == 0)
 		return 0;
 
-	pci_restore_state(dev, par->pci_state);
+	pci_restore_state(dev);
 	pci_set_power_state(dev, 0);
 	pci_enable_device(dev);
-	par->drm_agp->bind_memory(par->i810_gtt.i810_fb_memory, 
-				  par->fb.offset);
-	par->drm_agp->bind_memory(par->i810_gtt.i810_cursor_memory, 
-				  par->cursor_heap.offset);
+	agp_bind_memory(par->i810_gtt.i810_fb_memory,
+			par->fb.offset);
+	agp_bind_memory(par->i810_gtt.i810_cursor_memory,
+			par->cursor_heap.offset);
 
 	info->fbops->fb_blank(VESA_NO_BLANKING, info);
 
@@ -1589,39 +1595,36 @@
 	i810_fix_offsets(par);
 	size = par->fb.size + par->iring.size;
 
-	par->drm_agp = (drm_agp_t *) inter_module_get("drm_agp");
-	if (!par->drm_agp) {
-		printk("i810fb: cannot acquire agp\n");
+	if (agp_backend_acquire()) {
+		printk("i810fb_alloc_fbmem: cannot acquire agpgart\n");
 		return -ENODEV;
 	}
-	par->drm_agp->acquire(); 
-
 	if (!(par->i810_gtt.i810_fb_memory = 
-	      par->drm_agp->allocate_memory(size >> 12, AGP_NORMAL_MEMORY))) {
+	      agp_allocate_memory(size >> 12, AGP_NORMAL_MEMORY))) {
 		printk("i810fb_alloc_fbmem: can't allocate framebuffer "
 		       "memory\n");
-		par->drm_agp->release();
+		agp_backend_release();
 		return -ENOMEM;
 	}
-	if (par->drm_agp->bind_memory(par->i810_gtt.i810_fb_memory, 
-				      par->fb.offset)) {
+	if (agp_bind_memory(par->i810_gtt.i810_fb_memory,
+			    par->fb.offset)) {
 		printk("i810fb_alloc_fbmem: can't bind framebuffer memory\n");
-		par->drm_agp->release();
+		agp_backend_release();
 		return -EBUSY;
 	}	
 	
 	if (!(par->i810_gtt.i810_cursor_memory = 
-	      par->drm_agp->allocate_memory(par->cursor_heap.size >> 12, 
-					    AGP_PHYSICAL_MEMORY))) {
+	      agp_allocate_memory(par->cursor_heap.size >> 12,
+				  AGP_PHYSICAL_MEMORY))) {
 		printk("i810fb_alloc_cursormem:  can't allocate" 
 		       "cursor memory\n");
-		par->drm_agp->release();
+		agp_backend_release();
 		return -ENOMEM;
 	}
-	if (par->drm_agp->bind_memory(par->i810_gtt.i810_cursor_memory, 
+	if (agp_bind_memory(par->i810_gtt.i810_cursor_memory,
 			    par->cursor_heap.offset)) {
 		printk("i810fb_alloc_cursormem: cannot bind cursor memory\n");
-		par->drm_agp->release();
+		agp_backend_release();
 		return -EBUSY;
 	}	
 
@@ -1629,7 +1632,7 @@
 
 	i810_fix_pointers(par);
 
-	par->drm_agp->release();
+	agp_backend_release();
 
 	return 0;
 }
@@ -1724,7 +1727,8 @@
  */
 static void __devinit i810_init_device(struct i810fb_par *par)
 {
-	u8 reg, *mmio = par->mmio_start_virtual;
+	u8 reg;
+	u8 __iomem *mmio = par->mmio_start_virtual;
 
 	if (mtrr) set_mtrr(par);
 
@@ -1855,27 +1859,20 @@
 	int i, err = -1, vfreq, hfreq, pixclock;
 
 	i = 0;
-	if (!(info = kmalloc(sizeof(struct fb_info), GFP_KERNEL))) {
-		i810fb_release_resource(info, par);
-		return -ENOMEM;
-	}
-	memset(info, 0, sizeof(struct fb_info));
 
-	if(!(par = kmalloc(sizeof(struct i810fb_par), GFP_KERNEL))) {
-		i810fb_release_resource(info, par);
+	info = framebuffer_alloc(sizeof(struct i810fb_par), &dev->dev);
+	if (!info)
 		return -ENOMEM;
-	}
-	memset(par, 0, sizeof(struct i810fb_par));
 
+	par = (struct i810fb_par *) info->par;
 	par->dev = dev;
-	info->par = par;
 
-	if (!(info->pixmap.addr = kmalloc(64*1024, GFP_KERNEL))) {
+	if (!(info->pixmap.addr = kmalloc(8*1024, GFP_KERNEL))) {
 		i810fb_release_resource(info, par);
 		return -ENOMEM;
 	}
-	memset(info->pixmap.addr, 0, 64*1024);
-	info->pixmap.size = 64*1024;
+	memset(info->pixmap.addr, 0, 8*1024);
+	info->pixmap.size = 8*1024;
 	info->pixmap.buf_align = 8;
 	info->pixmap.flags = FB_PIXMAP_SYSTEM;
 
@@ -1941,38 +1938,30 @@
 static void i810fb_release_resource(struct fb_info *info, 
 				    struct i810fb_par *par)
 {
-	if (par) {
-		unset_mtrr(par);
-		if (par->drm_agp) {
-			drm_agp_t *agp = par->drm_agp;
-			struct gtt_data *gtt = &par->i810_gtt;
-
-			if (par->i810_gtt.i810_cursor_memory) 
-				agp->free_memory(gtt->i810_cursor_memory);
-			if (par->i810_gtt.i810_fb_memory) 
-				agp->free_memory(gtt->i810_fb_memory);
+	struct gtt_data *gtt = &par->i810_gtt;
+	unset_mtrr(par);
 
-			inter_module_put("drm_agp");
-			par->drm_agp = NULL;
-		}
+	if (par->i810_gtt.i810_cursor_memory)
+		agp_free_memory(gtt->i810_cursor_memory);
+	if (par->i810_gtt.i810_fb_memory)
+		agp_free_memory(gtt->i810_fb_memory);
+
+	if (par->mmio_start_virtual)
+		iounmap(par->mmio_start_virtual);
+	if (par->aperture.virtual)
+		iounmap(par->aperture.virtual);
+
+	if (par->res_flags & FRAMEBUFFER_REQ)
+		release_mem_region(par->aperture.physical,
+				   par->aperture.size);
+	if (par->res_flags & MMIO_REQ)
+		release_mem_region(par->mmio_start_phys, MMIO_SIZE);
 
-		if (par->mmio_start_virtual) 
-			iounmap(par->mmio_start_virtual);
-		if (par->aperture.virtual) 
-			iounmap(par->aperture.virtual);
-
-		if (par->res_flags & FRAMEBUFFER_REQ)
-			release_mem_region(par->aperture.physical, 
-					   par->aperture.size);
-		if (par->res_flags & MMIO_REQ)
-			release_mem_region(par->mmio_start_phys, MMIO_SIZE);
+	if (par->res_flags & PCI_DEVICE_ENABLED)
+		pci_disable_device(par->dev);
 
-		if (par->res_flags & PCI_DEVICE_ENABLED)
-			pci_disable_device(par->dev); 
+	framebuffer_release(info);
 
-		kfree(par);
-	}
-	kfree(info);
 }
 
 static void __exit i810fb_remove_pci(struct pci_dev *dev)
@@ -1995,10 +1984,7 @@
 		return -ENODEV;
 	i810fb_setup(option);
 
-	if (pci_register_driver(&i810fb_driver) > 0)
-		return 0;
-	pci_unregister_driver(&i810fb_driver);
-	return -ENODEV;
+	return pci_register_driver(&i810fb_driver);
 }
 #endif 
 
@@ -2013,50 +1999,47 @@
 	hsync1 *= 1000;
 	hsync2 *= 1000;
 
-	if (pci_register_driver(&i810fb_driver) > 0)
-		return 0;
-	pci_unregister_driver(&i810fb_driver);
-	return -ENODEV;
+	return pci_register_driver(&i810fb_driver);
 }
 
-MODULE_PARM(vram, "i");
+module_param(vram, int, 4);
 MODULE_PARM_DESC(vram, "System RAM to allocate to framebuffer in MiB" 
 		 " (default=4)");
-MODULE_PARM(voffset, "i");
+module_param(voffset, int, 0);
 MODULE_PARM_DESC(voffset, "at what offset to place start of framebuffer "
                  "memory (0 to maximum aperture size), in MiB (default = 48)");
-MODULE_PARM(bpp, "i");
+module_param(bpp, int, 8);
 MODULE_PARM_DESC(bpp, "Color depth for display in bits per pixel"
 		 " (default = 8)");
-MODULE_PARM(xres, "i");
+module_param(xres, int, 640);
 MODULE_PARM_DESC(xres, "Horizontal resolution in pixels (default = 640)");
-MODULE_PARM(yres, "i");
+module_param(yres, int, 480);
 MODULE_PARM_DESC(yres, "Vertical resolution in scanlines (default = 480)");
-MODULE_PARM(vyres, "i");
+module_param(vyres,int, 480);
 MODULE_PARM_DESC(vyres, "Virtual vertical resolution in scanlines"
 		 " (default = 480)");
-MODULE_PARM(hsync1, "i");
+module_param(hsync1, int, 0);
 MODULE_PARM_DESC(hsync1, "Minimum horizontal frequency of monitor in KHz"
 		 " (default = 31)");
-MODULE_PARM(hsync2, "i");
+module_param(hsync2, int, 0);
 MODULE_PARM_DESC(hsync2, "Maximum horizontal frequency of monitor in KHz"
 		 " (default = 31)");
-MODULE_PARM(vsync1, "i");
+module_param(vsync1, int, 0);
 MODULE_PARM_DESC(vsync1, "Minimum vertical frequency of monitor in Hz"
 		 " (default = 50)");
-MODULE_PARM(vsync2, "i");
+module_param(vsync2, int, 0);
 MODULE_PARM_DESC(vsync2, "Maximum vertical frequency of monitor in Hz" 
 		 " (default = 60)");
-MODULE_PARM(accel, "i");
+module_param(accel, bool, 0);
 MODULE_PARM_DESC(accel, "Use Acceleration (BLIT) engine (default = 0)");
-MODULE_PARM(mtrr, "i");
+module_param(mtrr, bool, 0);
 MODULE_PARM_DESC(mtrr, "Use MTRR (default = 0)");
-MODULE_PARM(ext_vga, "i");
+module_param(ext_vga, bool, 0);
 MODULE_PARM_DESC(ext_vga, "Enable external VGA connector (default = 0)");
-MODULE_PARM(sync, "i");
+module_param(sync, bool, 0);
 MODULE_PARM_DESC(sync, "wait for accel engine to finish drawing"
 		 " (default = 0)");
-MODULE_PARM(dcolor, "i");
+module_param(dcolor, bool, 0);
 MODULE_PARM_DESC(dcolor, "use DirectColor visuals"
 		 " (default = 0 = TrueColor)");
 
diff -Nru a/drivers/video/igafb.c b/drivers/video/igafb.c
--- a/drivers/video/igafb.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/video/igafb.c	2004-12-24 13:36:56 -08:00
@@ -262,8 +262,8 @@
 		pgprot_val(vma->vm_page_prot) &= ~(par->mmap_map[i].prot_mask);
 		pgprot_val(vma->vm_page_prot) |= par->mmap_map[i].prot_flag;
 
-		if (remap_page_range(vma, vma->vm_start + page, map_offset,
-				     map_size, vma->vm_page_prot))
+		if (remap_pfn_range(vma, vma->vm_start + page,
+			map_offset >> PAGE_SHIFT, map_size, vma->vm_page_prot))
 			return -EAGAIN;
 
 		page += map_size;
@@ -531,6 +531,7 @@
 	info->var = default_var;
 	info->fix = igafb_fix;
 	info->pseudo_palette = (void *)(par + 1);
+	info->device = &pdev->dev;
 
 	if (!iga_init(info, par)) {
 		iounmap((void *)par->io_base);
diff -Nru a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
--- a/drivers/video/imsttfb.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/video/imsttfb.c	2004-12-24 13:36:49 -08:00
@@ -319,7 +319,7 @@
 
 struct imstt_par {
 	struct imstt_regvals init;
-	__u32 *dc_regs;
+	__u32 __iomem *dc_regs;
 	unsigned long cmap_regs_phys;
 	__u8 *cmap_regs;
 	__u32 ramdac;
@@ -406,19 +406,19 @@
 /*
  * Register access
  */
-static inline u32 read_reg_le32(volatile u32 *base, int regindex)
+static inline u32 read_reg_le32(volatile u32 __iomem *base, int regindex)
 {
 #ifdef __powerpc__
-	return in_le32((volatile u32 *) (base + regindex));
+	return in_le32(base + regindex);
 #else
 	return readl(base + regindex);
 #endif
 }
 
-static inline void write_reg_le32(volatile u32 *base, int regindex, u32 val)
+static inline void write_reg_le32(volatile u32 __iomem *base, int regindex, u32 val)
 {
 #ifdef __powerpc__
-	out_le32((volatile u32 *) (base + regindex), val);
+	out_le32(base + regindex, val);
 #else
 	writel(val, base + regindex);
 #endif
@@ -940,9 +940,9 @@
 
 	ctrl = read_reg_le32(par->dc_regs, STGCTL);
 	if (blank > 0) {
-		switch (blank - 1) {
-		case VESA_NO_BLANKING:
-		case VESA_POWERDOWN:
+		switch (blank) {
+		case FB_BLANK_NORMAL:
+		case FB_BLANK_POWERDOWN:
 			ctrl &= ~0x00000380;
 			if (par->ramdac == IBM) {
 				par->cmap_regs[PIDXHI] = 0;		eieio();
@@ -958,10 +958,10 @@
 				par->cmap_regs[PIDXDATA] = 0xc0;
 			}
 			break;
-		case VESA_VSYNC_SUSPEND:
+		case FB_BLANK_VSYNC_SUSPEND:
 			ctrl &= ~0x00000020;
 			break;
-		case VESA_HSYNC_SUSPEND:
+		case FB_BLANK_HSYNC_SUSPEND:
 			ctrl &= ~0x00000010;
 			break;
 		}
@@ -1519,11 +1519,12 @@
 	info->fix.smem_start = addr;
 	info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ? 0x400000 : 0x800000);
 	info->fix.mmio_start = addr + 0x800000;
-	par->dc_regs = (__u32 *)ioremap(addr + 0x800000, 0x1000);
+	par->dc_regs = ioremap(addr + 0x800000, 0x1000);
 	par->cmap_regs_phys = addr + 0x840000;
 	par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000);
 	info->par = par;
 	info->pseudo_palette = (void *) (par + 1);
+	info->device = &pdev->dev;
 	init_imstt(info);
 
 	pci_set_drvdata(pdev, info);
diff -Nru a/drivers/video/intelfb/Makefile b/drivers/video/intelfb/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/intelfb/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,8 @@
+obj-$(CONFIG_FB_INTEL) += intelfb.o
+
+intelfb-objs := intelfbdrv.o intelfbhw.o
+
+ifdef CONFIG_FB_INTEL_DEBUG
+#EXTRA_CFLAGS += -DDEBUG -DVERBOSE -DREGDUMP
+EXTRA_CFLAGS += -DDEBUG -DREGDUMP
+endif
diff -Nru a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/intelfb/intelfb.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,278 @@
+#ifndef _INTELFB_H
+#define _INTELFB_H
+
+/* $DHD: intelfb/intelfb.h,v 1.40 2003/06/27 15:06:25 dawes Exp $ */
+
+#include <linux/agp_backend.h>
+#include <linux/fb.h>
+
+
+/*** Version/name ***/
+#define INTELFB_VERSION			"0.9.2"
+#define INTELFB_MODULE_NAME		"intelfb"
+#define SUPPORTED_CHIPSETS		"830M/845G/852GM/855GM/865G"
+
+
+/*** Debug/feature defines ***/
+
+#ifndef DEBUG
+#define DEBUG				0
+#endif
+
+#ifndef VERBOSE
+#define VERBOSE				0
+#endif
+
+#ifndef REGDUMP
+#define REGDUMP				0
+#endif
+
+#ifndef DETECT_VGA_CLASS_ONLY
+#define DETECT_VGA_CLASS_ONLY		1
+#endif
+
+#ifndef ALLOCATE_FOR_PANNING
+#define ALLOCATE_FOR_PANNING		1
+#endif
+
+#ifndef PREFERRED_MODE
+#define PREFERRED_MODE			"1024x768-16@60"
+#endif
+
+/*** hw-related values ***/
+
+/* PCI ids for supported devices */
+#define PCI_DEVICE_ID_INTEL_830M	0x3577
+#define PCI_DEVICE_ID_INTEL_845G	0x2562
+#define PCI_DEVICE_ID_INTEL_85XGM	0x3582
+#define PCI_DEVICE_ID_INTEL_865G	0x2572
+
+/* Size of MMIO region */
+#define INTEL_REG_SIZE			0x80000
+
+#define STRIDE_ALIGNMENT		16
+
+#define PALETTE_8_ENTRIES		256
+
+
+/*** Macros ***/
+
+/* basic arithmetic */
+#define KB(x)			((x) * 1024)
+#define MB(x)			((x) * 1024 * 1024)
+#define BtoKB(x)		((x) / 1024)
+#define BtoMB(x)		((x) / 1024 / 1024)
+
+#define GTT_PAGE_SIZE           KB(4)
+
+#define ROUND_UP_TO(x, y)	(((x) + (y) - 1) / (y) * (y))
+#define ROUND_DOWN_TO(x, y)	((x) / (y) * (y))
+#define ROUND_UP_TO_PAGE(x)	ROUND_UP_TO((x), GTT_PAGE_SIZE)
+#define ROUND_DOWN_TO_PAGE(x)	ROUND_DOWN_TO((x), GTT_PAGE_SIZE)
+
+/* messages */
+#define PFX			INTELFB_MODULE_NAME ": "
+
+#define ERR_MSG(fmt, args...)	printk(KERN_ERR PFX fmt, ## args)
+#define WRN_MSG(fmt, args...)	printk(KERN_WARNING PFX fmt, ## args)
+#define NOT_MSG(fmt, args...)	printk(KERN_NOTICE PFX fmt, ## args)
+#define INF_MSG(fmt, args...)	printk(KERN_INFO PFX fmt, ## args)
+#if DEBUG
+#define DBG_MSG(fmt, args...)	printk(KERN_DEBUG PFX fmt, ## args)
+#else
+#define DBG_MSG(fmt, args...)	while (0) printk(fmt, ## args)
+#endif
+
+/* get commonly used pointers */
+#define GET_DINFO(info)		(info)->par
+
+/* misc macros */
+#define ACCEL(d, i)                                                     \
+	((d)->accel && !(d)->ring_lockup &&                             \
+	 ((i)->var.accel_flags & FB_ACCELF_TEXT))
+
+/*#define NOACCEL_CHIPSET(d)						\
+	((d)->chipset != INTEL_865G)*/
+#define NOACCEL_CHIPSET(d)						\
+	(0)
+
+#define FIXED_MODE(d) ((d)->fixed_mode)
+
+/*** Driver paramters ***/
+
+#define RINGBUFFER_SIZE		KB(64)
+#define HW_CURSOR_SIZE		KB(4)
+
+/* Intel agpgart driver */
+#define AGP_PHYSICAL_MEMORY     2
+
+/*** Data Types ***/
+
+/* supported chipsets */
+enum intel_chips {
+	INTEL_830M,
+	INTEL_845G,
+	INTEL_85XGM,
+	INTEL_852GM,
+	INTEL_852GME,
+	INTEL_855GM,
+	INTEL_855GME,
+	INTEL_865G
+};
+
+struct intelfb_hwstate {
+	u32 vga0_divisor;
+	u32 vga1_divisor;
+	u32 vga_pd;
+	u32 dpll_a;
+	u32 dpll_b;
+	u32 fpa0;
+	u32 fpa1;
+	u32 fpb0;
+	u32 fpb1;
+	u32 palette_a[PALETTE_8_ENTRIES];
+	u32 palette_b[PALETTE_8_ENTRIES];
+	u32 htotal_a;
+	u32 hblank_a;
+	u32 hsync_a;
+	u32 vtotal_a;
+	u32 vblank_a;
+	u32 vsync_a;
+	u32 src_size_a;
+	u32 bclrpat_a;
+	u32 htotal_b;
+	u32 hblank_b;
+	u32 hsync_b;
+	u32 vtotal_b;
+	u32 vblank_b;
+	u32 vsync_b;
+	u32 src_size_b;
+	u32 bclrpat_b;
+	u32 adpa;
+	u32 dvoa;
+	u32 dvob;
+	u32 dvoc;
+	u32 dvoa_srcdim;
+	u32 dvob_srcdim;
+	u32 dvoc_srcdim;
+	u32 lvds;
+	u32 pipe_a_conf;
+	u32 pipe_b_conf;
+	u32 disp_arb;
+	u32 cursor_a_control;
+	u32 cursor_b_control;
+	u32 cursor_a_base;
+	u32 cursor_b_base;
+	u32 cursor_size;
+	u32 disp_a_ctrl;
+	u32 disp_b_ctrl;
+	u32 disp_a_base;
+	u32 disp_b_base;
+	u32 cursor_a_palette[4];
+	u32 cursor_b_palette[4];
+	u32 disp_a_stride;
+	u32 disp_b_stride;
+	u32 vgacntrl;
+	u32 add_id;
+	u32 swf0x[7];
+	u32 swf1x[7];
+	u32 swf3x[3];
+	u32 fence[8];
+	u32 instpm;
+	u32 mem_mode;
+	u32 fw_blc_0;
+	u32 fw_blc_1;
+};
+
+struct intelfb_heap_data {
+	u32 physical;
+	u8 __iomem *virtual;
+	u32 offset;  // in GATT pages
+	u32 size;    // in bytes
+};
+
+struct intelfb_info {
+	struct fb_info *info;
+	struct fb_ops  *fbops;
+	struct pci_dev *pdev;
+
+	struct intelfb_hwstate save_state;
+
+	/* agpgart structs */
+	struct agp_memory *gtt_fb_mem;     // use all stolen memory or vram
+	struct agp_memory *gtt_ring_mem;   // ring buffer
+	struct agp_memory *gtt_cursor_mem; // hw cursor
+
+	/* use a gart reserved fb mem */
+	u8 fbmem_gart;
+
+	/* mtrr support */
+	u32 mtrr_reg;
+	u32 has_mtrr;
+
+	/* heap data */
+	struct intelfb_heap_data aperture;
+	struct intelfb_heap_data fb;
+	struct intelfb_heap_data ring;
+	struct intelfb_heap_data cursor;
+
+	/* mmio regs */
+	u32 mmio_base_phys;
+	u8 __iomem *mmio_base;
+
+	/* fb start offset (in bytes) */
+	u32 fb_start;
+
+	/* ring buffer */
+	u8 __iomem *ring_head;
+	u32 ring_tail;
+	u32 ring_tail_mask;
+	u32 ring_space;
+	u32 ring_lockup;
+
+	/* palette */
+	u32 pseudo_palette[17];
+	struct { u8 red, green, blue, pad; } palette[256];
+
+	/* chip info */
+	int pci_chipset;
+	int chipset;
+	const char *name;
+	int mobile;
+
+	/* current mode */
+	int bpp, depth;
+	u32 visual;
+	int xres, yres, pitch;
+	int pixclock;
+
+	/* current pipe */
+	int pipe;
+
+	/* some flags */
+	int accel;
+	int hwcursor;
+	int fixed_mode;
+	int ring_active;
+
+	/* hw cursor */
+	int cursor_on;
+	int cursor_blanked;
+	u8  cursor_src[64];
+
+	/* initial parameters */
+	int initial_vga;
+	struct fb_var_screeninfo initial_var;
+	u32 initial_fb_base;
+	u32 initial_video_ram;
+	u32 initial_pitch;
+
+	/* driver registered */
+	int registered;
+};
+
+/*** function prototypes ***/
+
+extern int intelfb_var_to_depth(const struct fb_var_screeninfo *var);
+
+#endif /* _INTELFB_H */
diff -Nru a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/intelfb/intelfbdrv.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1557 @@
+/*
+ * intelfb
+ *
+ * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G
+ * integrated graphics chips.
+ *
+ * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
+ *                   2004 Sylvain Meyer
+ *
+ * This driver consists of two parts.  The first part (intelfbdrv.c) provides
+ * the basic fbdev interfaces, is derived in part from the radeonfb and
+ * vesafb drivers, and is covered by the GPL.  The second part (intelfbhw.c)
+ * provides the code to program the hardware.  Most of it is derived from
+ * the i810/i830 XFree86 driver.  The HW-specific code is covered here
+ * under a dual license (GPL and MIT/XFree86 license).
+ *
+ * Author: David Dawes
+ *
+ */
+
+/* $DHD: intelfb/intelfbdrv.c,v 1.20 2003/06/27 15:17:40 dawes Exp $ */
+
+/*
+ * Changes:
+ *    01/2003 - Initial driver (0.1.0), no mode switching, no acceleration.
+ *		This initial version is a basic core that works a lot like
+ *		the vesafb driver.  It must be built-in to the kernel,
+ *		and the initial video mode must be set with vga=XXX at
+ *		boot time.  (David Dawes)
+ *
+ *    01/2003 - Version 0.2.0: Mode switching added, colormap support
+ *		implemented, Y panning, and soft screen blanking implemented.
+ *		No acceleration yet.  (David Dawes)
+ *
+ *    01/2003 - Version 0.3.0: fbcon acceleration support added.  Module
+ *		option handling added.  (David Dawes)
+ *
+ *    01/2003 - Version 0.4.0: fbcon HW cursor support added.  (David Dawes)
+ *
+ *    01/2003 - Version 0.4.1: Add auto-generation of built-in modes.
+ *		(David Dawes)
+ *
+ *    02/2003 - Version 0.4.2: Add check for active non-CRT devices, and
+ *		mode validation checks.  (David Dawes)
+ *
+ *    02/2003 - Version 0.4.3: Check when the VC is in graphics mode so that
+ *		acceleration is disabled while an XFree86 server is running.
+ *		(David Dawes)
+ *
+ *    02/2003 - Version 0.4.4: Monitor DPMS support.  (David Dawes)
+ *
+ *    02/2003 - Version 0.4.5: Basic XFree86 + fbdev working.  (David Dawes)
+ *
+ *    02/2003 - Version 0.5.0: Modify to work with the 2.5.32 kernel as well
+ *		as 2.4.x kernels.  (David Dawes)
+ *
+ *    02/2003 - Version 0.6.0: Split out HW-specifics into a separate file.
+ *		(David Dawes)
+ *
+ *    02/2003 - Version 0.7.0: Test on 852GM/855GM.  Acceleration and HW
+ *		cursor are disabled on this platform.  (David Dawes)
+ *
+ *    02/2003 - Version 0.7.1: Test on 845G.  Acceleration is disabled
+ *		on this platform.  (David Dawes)
+ *
+ *    02/2003 - Version 0.7.2: Test on 830M.  Acceleration and HW
+ *		cursor are disabled on this platform.  (David Dawes)
+ *
+ *    02/2003 - Version 0.7.3: Fix 8-bit modes for mobile platforms
+ *		(David Dawes)
+ *
+ *    02/2003 - Version 0.7.4: Add checks for FB and FBCON_HAS_CFB* configured
+ *		in the kernel, and add mode bpp verification and default
+ *		bpp selection based on which FBCON_HAS_CFB* are configured.
+ *		(David Dawes)
+ *
+ *    02/2003 - Version 0.7.5: Add basic package/install scripts based on the
+ *		DRI packaging scripts.  (David Dawes)
+ *
+ *    04/2003 - Version 0.7.6: Fix typo that affects builds with SMP-enabled
+ *		kernels.  (David Dawes, reported by Anupam).
+ *
+ *    06/2003 - Version 0.7.7:
+ *              Fix Makefile.kernel build problem (Tsutomu Yasuda).
+ *		Fix mis-placed #endif (2.4.21 kernel).
+ *
+ *    09/2004 - Version 0.9.0 - by Sylvain Meyer
+ *              Port to linux 2.6 kernel fbdev
+ *              Fix HW accel and HW cursor on i845G
+ *              Use of agpgart for fb memory reservation
+ *              Add mtrr support
+ *
+ *    10/2004 - Version 0.9.1
+ *              Use module_param instead of old MODULE_PARM
+ *              Some cleanup
+ *
+ *    11/2004 - Version 0.9.2
+ *              Add vram option to reserve more memory than stolen by BIOS
+ *              Fix intelfbhw_pan_display typo
+ *              Add __initdata annotations
+ *
+ * TODO:
+ *
+ *
+ * Wish List:
+ *
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/tty.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fb.h>
+#include <linux/console.h>
+#include <linux/selection.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/vmalloc.h>
+#include <linux/kd.h>
+#include <linux/vt_kern.h>
+#include <linux/pagemap.h>
+#include <linux/version.h>
+
+#include <asm/io.h>
+
+#ifdef CONFIG_MTRR
+#include <asm/mtrr.h>
+#endif
+
+#include "intelfb.h"
+#include "intelfbdrv.h"
+#include "intelfbhw.h"
+
+/*
+ * Limiting the class to PCI_CLASS_DISPLAY_VGA prevents function 1 of the
+ * mobile chipsets from being registered.
+ */
+#if DETECT_VGA_CLASS_ONLY
+#define INTELFB_CLASS_MASK ~0 << 8
+#else
+#define INTELFB_CLASS_MASK 0
+#endif
+
+static struct pci_device_id intelfb_pci_table[] __devinitdata = {
+	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_830M, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_830M },
+	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_845G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_845G },
+	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_85XGM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_85XGM },
+	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_865G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_865G },
+	{ 0, }
+};
+
+/* Global data */
+static int num_registered = 0;
+
+/* fb ops */
+static struct fb_ops intel_fb_ops = {
+	.owner =		THIS_MODULE,
+	.fb_check_var =         intelfb_check_var,
+	.fb_set_par =           intelfb_set_par,
+	.fb_setcolreg =		intelfb_setcolreg,
+	.fb_blank =		intelfb_blank,
+	.fb_pan_display =       intelfb_pan_display,
+	.fb_fillrect  =         intelfb_fillrect,
+	.fb_copyarea  =         intelfb_copyarea,
+	.fb_imageblit =         intelfb_imageblit,
+	.fb_cursor =            intelfb_cursor,
+	.fb_sync =              intelfb_sync,
+	.fb_ioctl =		intelfb_ioctl
+};
+
+/* PCI driver module table */
+static struct pci_driver intelfb_driver = {
+	.name =		"Intel(R) " SUPPORTED_CHIPSETS " Framebuffer Driver",
+	.id_table =	intelfb_pci_table,
+	.probe =	intelfb_pci_register,
+	.remove =	__devexit_p(intelfb_pci_unregister)
+};
+
+/* Module description/parameters */
+MODULE_AUTHOR("David Dawes <dawes@tungstengraphics.com>, "
+	      "Sylvain Meyer <sylvain.meyer@worldonline.fr>");
+MODULE_DESCRIPTION(
+	"Framebuffer driver for Intel(R) " SUPPORTED_CHIPSETS " chipsets");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DEVICE_TABLE(pci, intelfb_pci_table);
+
+static int accel        __initdata = 1;
+static int vram         __initdata = 4;
+static int hwcursor     __initdata = 1;
+static int mtrr         __initdata = 1;
+static int fixed        __initdata = 0;
+static int noinit       __initdata = 0;
+static int noregister   __initdata = 0;
+static int probeonly    __initdata = 0;
+static int idonly       __initdata = 0;
+static int bailearly    __initdata = 0;
+static char *mode       __initdata = NULL;
+
+module_param(accel, bool, S_IRUGO);
+MODULE_PARM_DESC(accel, "Enable console acceleration");
+module_param(vram, int, S_IRUGO);
+MODULE_PARM_DESC(vram, "System RAM to allocate to framebuffer in MiB");
+module_param(hwcursor, bool, S_IRUGO);
+MODULE_PARM_DESC(hwcursor, "Enable HW cursor");
+module_param(mtrr, bool, S_IRUGO);
+MODULE_PARM_DESC(mtrr, "Enable MTRR support");
+module_param(fixed, bool, S_IRUGO);
+MODULE_PARM_DESC(fixed, "Disable mode switching");
+module_param(noinit, bool, 0);
+MODULE_PARM_DESC(noinit, "Don't initialise graphics mode when loading");
+module_param(noregister, bool, 0);
+MODULE_PARM_DESC(noregister, "Don't register, just probe and exit (debug)");
+module_param(probeonly, bool, 0);
+MODULE_PARM_DESC(probeonly, "Do a minimal probe (debug)");
+module_param(idonly, bool, 0);
+MODULE_PARM_DESC(idonly, "Just identify without doing anything else (debug)");
+module_param(bailearly, bool, 0);
+MODULE_PARM_DESC(bailearly, "Bail out early, depending on value (debug)");
+module_param(mode, charp, S_IRUGO);
+MODULE_PARM_DESC(mode,
+		 "Initial video mode \"<xres>x<yres>[-<depth>][@<refresh>]\"");
+/***************************************************************
+ *                     modules entry points                    *
+ ***************************************************************/
+
+/* module load/unload entry points */
+int __init
+intelfb_init(void)
+{
+#ifndef MODULE
+	char *option = NULL;
+#endif
+
+	DBG_MSG("intelfb_init\n");
+
+	INF_MSG("Framebuffer driver for "
+		"Intel(R) " SUPPORTED_CHIPSETS " chipsets\n");
+	INF_MSG("Version " INTELFB_VERSION "\n");
+
+	if (idonly)
+		return -ENODEV;
+
+#ifndef MODULE
+	if (fb_get_options("intelfb", &option))
+		return -ENODEV;
+	intelfb_setup(option);
+#endif
+
+	return pci_module_init(&intelfb_driver);
+}
+
+static void __exit
+intelfb_exit(void)
+{
+	DBG_MSG("intelfb_exit\n");
+	pci_unregister_driver(&intelfb_driver);
+}
+
+#ifndef MODULE
+#define OPT_EQUAL(opt, name) (!strncmp(opt, name, strlen(name)))
+#define OPT_INTVAL(opt, name) simple_strtoul(opt + strlen(name), NULL, 0)
+#define OPT_STRVAL(opt, name) (opt + strlen(name))
+
+static __inline__ char *
+get_opt_string(const char *this_opt, const char *name)
+{
+	const char *p;
+	int i;
+	char *ret;
+
+	p = OPT_STRVAL(this_opt, name);
+	i = 0;
+	while (p[i] && p[i] != ' ' && p[i] != ',')
+		i++;
+	ret = kmalloc(i + 1, GFP_KERNEL);
+	if (ret) {
+		strncpy(ret, p, i);
+		ret[i] = '\0';
+	}
+	return ret;
+}
+
+static __inline__ int
+get_opt_int(const char *this_opt, const char *name, int *ret)
+{
+	if (!ret)
+		return 0;
+
+	if (!OPT_EQUAL(this_opt, name))
+		return 0;
+
+	*ret = OPT_INTVAL(this_opt, name);
+	return 1;
+}
+
+static __inline__ int
+get_opt_bool(const char *this_opt, const char *name, int *ret)
+{
+	if (!ret)
+		return 0;
+
+	if (OPT_EQUAL(this_opt, name)) {
+		if (this_opt[strlen(name)] == '=')
+			*ret = simple_strtoul(this_opt + strlen(name) + 1,
+					      NULL, 0);
+		else
+			*ret = 1;
+	} else {
+		if (OPT_EQUAL(this_opt, "no") && OPT_EQUAL(this_opt + 2, name))
+			*ret = 0;
+		else
+			return 0;
+	}
+	return 1;
+}
+
+int __init
+intelfb_setup(char *options)
+{
+	char *this_opt;
+
+	DBG_MSG("intelfb_setup\n");
+
+	if (!options || !*options) {
+		DBG_MSG("no options\n");
+		return 0;
+	} else
+		DBG_MSG("options: %s\n", options);
+
+	/*
+	 * These are the built-in options analogous to the module parameters
+	 * defined above.
+	 *
+	 * The syntax is:
+	 *
+	 *    video=intelfb:[mode][,<param>=<val>] ...
+	 *
+	 * e.g.,
+	 *
+	 *    video=intelfb:1024x768-16@75,accel=0
+	 */
+
+	while ((this_opt = strsep(&options, ","))) {
+		if (!*this_opt)
+			continue;
+		if (get_opt_bool(this_opt, "accel", &accel))
+			;
+ 		else if (get_opt_int(this_opt, "vram", &vram))
+			;
+		else if (get_opt_bool(this_opt, "hwcursor", &hwcursor))
+			;
+		else if (get_opt_bool(this_opt, "mtrr", &mtrr))
+			;
+		else if (get_opt_bool(this_opt, "fixed", &fixed))
+			;
+		else if (get_opt_bool(this_opt, "init", &noinit))
+			noinit = !noinit;
+		else if (OPT_EQUAL(this_opt, "mode="))
+			mode = get_opt_string(this_opt, "mode=");
+		else
+			mode = this_opt;
+	}
+
+	return 0;
+}
+
+#endif
+
+module_init(intelfb_init);
+
+#ifdef MODULE
+module_exit(intelfb_exit);
+#endif
+
+/***************************************************************
+ *                     mtrr support functions                  *
+ ***************************************************************/
+
+#ifdef CONFIG_MTRR
+static inline void __devinit set_mtrr(struct intelfb_info *dinfo)
+{
+	dinfo->mtrr_reg = mtrr_add(dinfo->aperture.physical,
+				   dinfo->aperture.size, MTRR_TYPE_WRCOMB, 1);
+	if (dinfo->mtrr_reg < 0) {
+		ERR_MSG("unable to set MTRR\n");
+		return;
+	}
+	dinfo->has_mtrr = 1;
+}
+static inline void unset_mtrr(struct intelfb_info *dinfo)
+{
+  	if (dinfo->has_mtrr)
+  		mtrr_del(dinfo->mtrr_reg, dinfo->aperture.physical,
+			 dinfo->aperture.size);
+}
+#else
+#define set_mtrr(x) WRN_MSG("MTRR is disabled in the kernel\n")
+
+#define unset_mtrr(x) do { } while (0)
+#endif /* CONFIG_MTRR */
+
+/***************************************************************
+ *                        driver init / cleanup                *
+ ***************************************************************/
+
+static void
+cleanup(struct intelfb_info *dinfo)
+{
+	DBG_MSG("cleanup\n");
+
+	if (!dinfo)
+		return;
+
+	fb_dealloc_cmap(&dinfo->info->cmap);
+	kfree(dinfo->info->pixmap.addr);
+
+	if (dinfo->registered)
+		unregister_framebuffer(dinfo->info);
+
+	unset_mtrr(dinfo);
+
+	if (dinfo->fbmem_gart && dinfo->gtt_fb_mem) {
+		agp_unbind_memory(dinfo->gtt_fb_mem);
+		agp_free_memory(dinfo->gtt_fb_mem);
+	}
+	if (dinfo->gtt_cursor_mem) {
+		agp_unbind_memory(dinfo->gtt_cursor_mem);
+		agp_free_memory(dinfo->gtt_cursor_mem);
+	}
+	if (dinfo->gtt_ring_mem) {
+		agp_unbind_memory(dinfo->gtt_ring_mem);
+		agp_free_memory(dinfo->gtt_ring_mem);
+	}
+
+	if (dinfo->mmio_base)
+		iounmap((void __iomem *)dinfo->mmio_base);
+	if (dinfo->aperture.virtual)
+		iounmap((void __iomem *)dinfo->aperture.virtual);
+
+	if (dinfo->mmio_base_phys)
+		release_mem_region(dinfo->mmio_base_phys, INTEL_REG_SIZE);
+	if (dinfo->aperture.physical)
+		release_mem_region(dinfo->aperture.physical,
+				   dinfo->aperture.size);
+	framebuffer_release(dinfo->info);
+}
+
+#define bailout(dinfo) do {						\
+	DBG_MSG("bailout\n");						\
+	cleanup(dinfo);							\
+	INF_MSG("Not going to register framebuffer, exiting...\n");	\
+	return -ENODEV;							\
+} while (0)
+
+
+static int __devinit
+intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	struct fb_info *info;
+	struct intelfb_info *dinfo;
+	int i, j, err, dvo;
+	int aperture_size, stolen_size;
+	struct agp_kern_info gtt_info;
+	int agp_memtype;
+	const char *s;
+
+	DBG_MSG("intelfb_pci_register\n");
+
+	num_registered++;
+	if (num_registered != 1) {
+		ERR_MSG("Attempted to register %d devices "
+			"(should be only 1).\n", num_registered);
+		return -ENODEV;
+	}
+
+	info = framebuffer_alloc(sizeof(struct intelfb_info), &pdev->dev);
+	if (!info) {
+		ERR_MSG("Could not allocate memory for intelfb_info.\n");
+		return -ENODEV;
+	}
+	if (fb_alloc_cmap(&info->cmap, 256, 1) < 0) {
+		ERR_MSG("Could not allocate cmap for intelfb_info.\n");
+		goto err_out_cmap;
+		return -ENODEV;
+	}
+
+	dinfo = info->par;
+	dinfo->info  = info;
+	dinfo->fbops = &intel_fb_ops;
+	dinfo->pdev  = pdev;
+
+	/* Reserve pixmap space. */
+	info->pixmap.addr = kmalloc(64 * 1024, GFP_KERNEL);
+	if (info->pixmap.addr == NULL) {
+		ERR_MSG("Cannot reserve pixmap memory.\n");
+		goto err_out_pixmap;
+	}
+	memset(info->pixmap.addr, 0, 64 * 1024);
+
+	/* set early this option because it could be changed by tv encoder
+	   driver */
+	dinfo->fixed_mode = fixed;
+
+	/* Enable device. */
+	if ((err = pci_enable_device(pdev))) {
+		ERR_MSG("Cannot enable device.\n");
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	/* Set base addresses. */
+	dinfo->aperture.physical = pci_resource_start(pdev, 0);
+	dinfo->aperture.size     = pci_resource_len(pdev, 0);
+	dinfo->mmio_base_phys    = pci_resource_start(pdev, 1);
+
+	DBG_MSG("fb aperture: 0x%lx/0x%lx, MMIO region: 0x%lx/0x%lx\n",
+		pci_resource_start(pdev, 0), pci_resource_len(pdev, 0),
+		pci_resource_start(pdev, 1), pci_resource_len(pdev, 1));
+
+	/* Reserve the fb and MMIO regions */
+	if (!request_mem_region(dinfo->aperture.physical, dinfo->aperture.size,
+				INTELFB_MODULE_NAME)) {
+		ERR_MSG("Cannot reserve FB region.\n");
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+	if (!request_mem_region(dinfo->mmio_base_phys,
+				INTEL_REG_SIZE,
+				INTELFB_MODULE_NAME)) {
+		ERR_MSG("Cannot reserve MMIO region.\n");
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	/* Map the fb and MMIO regions */
+	dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache
+		(dinfo->aperture.physical, dinfo->aperture.size);
+	if (!dinfo->aperture.virtual) {
+		ERR_MSG("Cannot remap FB region.\n");
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+	dinfo->mmio_base =
+		(u8 __iomem *)ioremap_nocache(dinfo->mmio_base_phys,
+					       INTEL_REG_SIZE);
+	if (!dinfo->mmio_base) {
+		ERR_MSG("Cannot remap MMIO region.\n");
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	/* Get the chipset info. */
+	dinfo->pci_chipset = pdev->device;
+
+	if (intelfbhw_get_chipset(pdev, &dinfo->name, &dinfo->chipset,
+				  &dinfo->mobile)) {
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	if (intelfbhw_get_memory(pdev, &aperture_size,&stolen_size)) {
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	INF_MSG("%02x:%02x.%d: %s, aperture size %dMB, "
+		"stolen memory %dkB\n",
+		pdev->bus->number, PCI_SLOT(pdev->devfn),
+		PCI_FUNC(pdev->devfn), dinfo->name,
+		BtoMB(aperture_size), BtoKB(stolen_size));
+
+	/* Set these from the options. */
+	dinfo->accel    = accel;
+	dinfo->hwcursor = hwcursor;
+
+	if (NOACCEL_CHIPSET(dinfo) && dinfo->accel == 1) {
+		INF_MSG("Acceleration is not supported for the %s chipset.\n",
+			dinfo->name);
+		dinfo->accel = 0;
+	}
+
+	/* Framebuffer parameters - Use all the stolen memory if >= vram */
+	if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) {
+		dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size);
+		dinfo->fbmem_gart = 0;
+	} else {
+		dinfo->fb.size =  MB(vram);
+		dinfo->fbmem_gart = 1;
+	}
+
+	/* Allocate space for the ring buffer and HW cursor if enabled. */
+	if (dinfo->accel) {
+		dinfo->ring.size = RINGBUFFER_SIZE;
+		dinfo->ring_tail_mask = dinfo->ring.size - 1;
+	}
+	if (dinfo->hwcursor) {
+		dinfo->cursor.size = HW_CURSOR_SIZE;
+	}
+
+	/* Use agpgart to manage the GATT */
+	if (agp_backend_acquire()) {
+		ERR_MSG("cannot acquire agp\n");
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	/* get the current gatt info */
+	if (agp_copy_info(&gtt_info)) {
+		ERR_MSG("cannot get agp info\n");
+		agp_backend_release();
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	/* set the mem offsets - set them after the already used pages */
+	if (dinfo->accel) {
+		dinfo->ring.offset = (stolen_size >> 12)
+			+ gtt_info.current_memory;
+	}
+	if (dinfo->hwcursor) {
+		dinfo->cursor.offset = (stolen_size >> 12) +
+			+ gtt_info.current_memory + (dinfo->ring.size >> 12);
+	}
+	if (dinfo->fbmem_gart) {
+		dinfo->fb.offset = (stolen_size >> 12) +
+			+ gtt_info.current_memory + (dinfo->ring.size >> 12)
+			+ (dinfo->cursor.size >> 12);
+	}
+
+	/* Allocate memories (which aren't stolen) */
+	if (dinfo->accel) {
+		if (!(dinfo->gtt_ring_mem =
+		      agp_allocate_memory(dinfo->ring.size >> 12,
+					  AGP_NORMAL_MEMORY))) {
+			ERR_MSG("cannot allocate ring buffer memory\n");
+			agp_backend_release();
+			cleanup(dinfo);
+			return -ENOMEM;
+		}
+		if (agp_bind_memory(dinfo->gtt_ring_mem,
+				    dinfo->ring.offset)) {
+			ERR_MSG("cannot bind ring buffer memory\n");
+			agp_backend_release();
+			cleanup(dinfo);
+			return -EBUSY;
+		}
+		dinfo->ring.physical = dinfo->aperture.physical
+			+ (dinfo->ring.offset << 12);
+		dinfo->ring.virtual  = dinfo->aperture.virtual
+			+ (dinfo->ring.offset << 12);
+		dinfo->ring_head = dinfo->ring.virtual;
+	}
+	if (dinfo->hwcursor) {
+		agp_memtype = dinfo->mobile ? AGP_PHYSICAL_MEMORY
+			: AGP_NORMAL_MEMORY;
+		if (!(dinfo->gtt_cursor_mem =
+		      agp_allocate_memory(dinfo->cursor.size >> 12,
+					  agp_memtype))) {
+			ERR_MSG("cannot allocate cursor memory\n");
+			agp_backend_release();
+			cleanup(dinfo);
+			return -ENOMEM;
+		}
+		if (agp_bind_memory(dinfo->gtt_cursor_mem,
+				    dinfo->cursor.offset)) {
+			ERR_MSG("cannot bind cursor memory\n");
+			agp_backend_release();
+			cleanup(dinfo);
+			return -EBUSY;
+		}
+		if (dinfo->mobile)
+			dinfo->cursor.physical
+				= dinfo->gtt_cursor_mem->physical;
+		else
+			dinfo->cursor.physical = dinfo->aperture.physical
+				+ (dinfo->cursor.offset << 12);
+		dinfo->cursor.virtual = dinfo->aperture.virtual
+			+ (dinfo->cursor.offset << 12);
+	}
+	if (dinfo->fbmem_gart) {
+		if (!(dinfo->gtt_fb_mem =
+		      agp_allocate_memory(dinfo->fb.size >> 12,
+					  AGP_NORMAL_MEMORY))) {
+			WRN_MSG("cannot allocate framebuffer memory - use "
+				"the stolen one\n");
+			dinfo->fbmem_gart = 0;
+		}
+		if (agp_bind_memory(dinfo->gtt_fb_mem,
+				    dinfo->fb.offset)) {
+			WRN_MSG("cannot bind framebuffer memory - use "
+				"the stolen one\n");
+			dinfo->fbmem_gart = 0;
+		}
+	}
+
+	/* update framebuffer memory parameters */
+	if (!dinfo->fbmem_gart)
+		dinfo->fb.offset = 0;   /* starts at offset 0 */
+	dinfo->fb.physical = dinfo->aperture.physical
+		+ (dinfo->fb.offset << 12);
+	dinfo->fb.virtual = dinfo->aperture.virtual + (dinfo->fb.offset << 12);
+	dinfo->fb_start = dinfo->fb.offset << 12;
+
+	/* release agpgart */
+	agp_backend_release();
+
+	if (mtrr)
+		set_mtrr(dinfo);
+
+	DBG_MSG("fb: 0x%x(+ 0x%x)/0x%x (0x%x)\n",
+		dinfo->fb.physical, dinfo->fb.offset, dinfo->fb.size,
+		(u32 __iomem ) dinfo->fb.virtual);
+	DBG_MSG("MMIO: 0x%x/0x%x (0x%x)\n",
+		dinfo->mmio_base_phys, INTEL_REG_SIZE,
+		(u32 __iomem) dinfo->mmio_base);
+	DBG_MSG("ring buffer: 0x%x/0x%x (0x%x)\n",
+		dinfo->ring.physical, dinfo->ring.size,
+		(u32 __iomem ) dinfo->ring.virtual);
+	DBG_MSG("HW cursor: 0x%x/0x%x (0x%x) (offset 0x%x) (phys 0x%x)\n",
+		dinfo->cursor.physical, dinfo->cursor.size,
+		(u32 __iomem ) dinfo->cursor.virtual, dinfo->cursor.offset,
+		dinfo->cursor.physical);
+
+	DBG_MSG("options: vram = %d, accel = %d, hwcursor = %d, fixed = %d, "
+		"noinit = %d\n", vram, accel, hwcursor, fixed, noinit);
+	DBG_MSG("options: mode = \"%s\"\n", mode ? mode : "");
+
+	if (probeonly)
+		bailout(dinfo);
+
+	/*
+	 * Check if the LVDS port or any DVO ports are enabled.  If so,
+	 * don't allow mode switching
+	 */
+	dvo = intelfbhw_check_non_crt(dinfo);
+	if (dvo) {
+		dinfo->fixed_mode = 1;
+		WRN_MSG("Non-CRT device is enabled ( ");
+		i = 0;
+		while (dvo) {
+			if (dvo & 1) {
+				s = intelfbhw_dvo_to_string(1 << i);
+				if (s)
+					printk("%s ", s);
+			}
+			dvo >>= 1;
+			++i;
+		}
+		printk(").  Disabling mode switching.\n");
+	}
+
+	if (bailearly == 1)
+		bailout(dinfo);
+
+	if (FIXED_MODE(dinfo) && ORIG_VIDEO_ISVGA != VIDEO_TYPE_VLFB) {
+		ERR_MSG("Video mode must be programmed at boot time.\n");
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	if (bailearly == 2)
+		bailout(dinfo);
+
+	/* Initialise dinfo and related data. */
+	/* If an initial mode was programmed at boot time, get its details. */
+	if (ORIG_VIDEO_ISVGA == VIDEO_TYPE_VLFB)
+		get_initial_mode(dinfo);
+
+	if (bailearly == 3)
+		bailout(dinfo);
+
+	if (FIXED_MODE(dinfo)) {
+		/* remap fb address */
+		update_dinfo(dinfo, &dinfo->initial_var);
+	}
+
+	if (bailearly == 4)
+		bailout(dinfo);
+
+
+	if (intelfb_set_fbinfo(dinfo)) {
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	if (bailearly == 5)
+		bailout(dinfo);
+
+	for (i = 0; i < 16; i++) {
+		j = color_table[i];
+		dinfo->palette[i].red = default_red[j];
+		dinfo->palette[i].green = default_grn[j];
+		dinfo->palette[i].blue = default_blu[j];
+	}
+
+	if (bailearly == 6)
+		bailout(dinfo);
+
+	pci_set_drvdata(pdev, dinfo);
+
+	/* Save the initial register state. */
+	i = intelfbhw_read_hw_state(dinfo, &dinfo->save_state,
+				    bailearly > 6 ? bailearly - 6 : 0);
+	if (i != 0) {
+		DBG_MSG("intelfbhw_read_hw_state returned %d\n", i);
+		bailout(dinfo);
+	}
+
+	intelfbhw_print_hw_state(dinfo, &dinfo->save_state);
+
+	if (bailearly == 18)
+		bailout(dinfo);
+
+	/* Cursor initialisation */
+	if (dinfo->hwcursor) {
+		intelfbhw_cursor_init(dinfo);
+		intelfbhw_cursor_reset(dinfo);
+	}
+
+	if (bailearly == 19)
+		bailout(dinfo);
+
+	/* 2d acceleration init */
+	if (dinfo->accel)
+		intelfbhw_2d_start(dinfo);
+
+	if (bailearly == 20)
+		bailout(dinfo);
+
+	if (noregister)
+		bailout(dinfo);
+
+	if (register_framebuffer(dinfo->info) < 0) {
+		ERR_MSG("Cannot register framebuffer.\n");
+		cleanup(dinfo);
+		return -ENODEV;
+	}
+
+	dinfo->registered = 1;
+
+	return 0;
+
+err_out_pixmap:
+	fb_dealloc_cmap(&info->cmap);
+err_out_cmap:
+	framebuffer_release(info);
+	return -ENODEV;
+}
+
+static void __devexit
+intelfb_pci_unregister(struct pci_dev *pdev)
+{
+	struct intelfb_info *dinfo = pci_get_drvdata(pdev);
+
+	DBG_MSG("intelfb_pci_unregister\n");
+
+	if (!dinfo)
+		return;
+
+	cleanup(dinfo);
+
+	pci_set_drvdata(pdev, NULL);
+}
+
+/***************************************************************
+ *                       helper functions                      *
+ ***************************************************************/
+
+int __inline__
+intelfb_var_to_depth(const struct fb_var_screeninfo *var)
+{
+	DBG_MSG("intelfb_var_to_depth: bpp: %d, green.length is %d\n",
+		var->bits_per_pixel, var->green.length);
+
+	switch (var->bits_per_pixel) {
+	case 16:
+		return (var->green.length == 6) ? 16 : 15;
+	case 32:
+		return 24;
+	default:
+		return var->bits_per_pixel;
+	}
+}
+
+
+static __inline__ int
+var_to_refresh(const struct fb_var_screeninfo *var)
+{
+	int xtot = var->xres + var->left_margin + var->right_margin +
+		   var->hsync_len;
+	int ytot = var->yres + var->upper_margin + var->lower_margin +
+		   var->vsync_len;
+
+	return (1000000000 / var->pixclock * 1000 + 500) / xtot / ytot;
+}
+
+/***************************************************************
+ *                Various intialisation functions              *
+ ***************************************************************/
+
+static void __devinit
+get_initial_mode(struct intelfb_info *dinfo)
+{
+	struct fb_var_screeninfo *var;
+	int xtot, ytot;
+
+	DBG_MSG("get_initial_mode\n");
+
+	dinfo->initial_vga = 1;
+	dinfo->initial_fb_base = screen_info.lfb_base;
+	dinfo->initial_video_ram = screen_info.lfb_size * KB(64);
+	dinfo->initial_pitch = screen_info.lfb_linelength;
+
+	var = &dinfo->initial_var;
+	memset(var, 0, sizeof(*var));
+	var->xres = screen_info.lfb_width;
+	var->yres = screen_info.lfb_height;
+	var->bits_per_pixel = screen_info.lfb_depth;
+	switch (screen_info.lfb_depth) {
+	case 15:
+		var->bits_per_pixel = 16;
+		break;
+	case 24:
+		var->bits_per_pixel = 32;
+		break;
+	}
+
+	DBG_MSG("Initial info: FB is 0x%x/0x%x (%d kByte)\n",
+		dinfo->initial_fb_base, dinfo->initial_video_ram,
+		BtoKB(dinfo->initial_video_ram));
+
+	DBG_MSG("Initial info: mode is %dx%d-%d (%d)\n",
+		var->xres, var->yres, var->bits_per_pixel,
+		dinfo->initial_pitch);
+
+	/* Dummy timing values (assume 60Hz) */
+	var->left_margin = (var->xres / 8) & 0xf8;
+	var->right_margin = 32;
+	var->upper_margin = 16;
+	var->lower_margin = 4;
+	var->hsync_len = (var->xres / 8) & 0xf8;
+	var->vsync_len = 4;
+
+	xtot = var->xres + var->left_margin +
+		var->right_margin + var->hsync_len;
+	ytot = var->yres + var->upper_margin +
+		var->lower_margin + var->vsync_len;
+	var->pixclock = 10000000 / xtot * 1000 / ytot * 100 / 60;
+
+	var->height = -1;
+	var->width = -1;
+
+	if (var->bits_per_pixel > 8) {
+		var->red.offset = screen_info.red_pos;
+		var->red.length = screen_info.red_size;
+		var->green.offset = screen_info.green_pos;
+		var->green.length = screen_info.green_size;
+		var->blue.offset = screen_info.blue_pos;
+		var->blue.length = screen_info.blue_size;
+		var->transp.offset = screen_info.rsvd_pos;
+		var->transp.length = screen_info.rsvd_size;
+	} else {
+		var->red.length = 8;
+		var->green.length = 8;
+		var->blue.length = 8;
+	}
+}
+
+static int __devinit
+intelfb_init_var(struct intelfb_info *dinfo)
+{
+	struct fb_var_screeninfo *var;
+	int msrc = 0;
+
+	DBG_MSG("intelfb_init_var\n");
+
+	var = &dinfo->info->var;
+	if (FIXED_MODE(dinfo)) {
+	        memcpy(var, &dinfo->initial_var,
+		       sizeof(struct fb_var_screeninfo));
+		msrc = 5;
+	} else {
+		if (mode) {
+			msrc = fb_find_mode(var, dinfo->info, mode,
+					    NULL, 0, NULL, 0);
+			if (msrc)
+				msrc |= 8;
+		}
+		if (!msrc) {
+			msrc = fb_find_mode(var, dinfo->info, PREFERRED_MODE,
+					    NULL, 0, NULL, 0);
+		}
+	}
+
+	if (!msrc) {
+		ERR_MSG("Cannot find a suitable video mode.\n");
+		return 1;
+	}
+
+	INF_MSG("Initial video mode is %dx%d-%d@%d.\n", var->xres, var->yres,
+		var->bits_per_pixel, var_to_refresh(var));
+
+	DBG_MSG("Initial video mode is from %d.\n", msrc);
+
+#if ALLOCATE_FOR_PANNING
+	/* Allow use of half of the video ram for panning */
+	var->xres_virtual = var->xres;
+	var->yres_virtual =
+		dinfo->fb.size / 2 / (var->bits_per_pixel * var->xres);
+	if (var->yres_virtual < var->yres)
+		var->yres_virtual = var->yres;
+#else
+	var->yres_virtual = var->yres;
+#endif
+
+	if (dinfo->accel)
+		var->accel_flags |= FB_ACCELF_TEXT;
+	else
+		var->accel_flags &= ~FB_ACCELF_TEXT;
+
+	return 0;
+}
+
+static int __devinit
+intelfb_set_fbinfo(struct intelfb_info *dinfo)
+{
+	struct fb_info *info = dinfo->info;
+
+	DBG_MSG("intelfb_set_fbinfo\n");
+
+	info->flags = FBINFO_FLAG_DEFAULT;
+	info->fbops = &intel_fb_ops;
+	info->pseudo_palette = dinfo->pseudo_palette;
+
+	info->pixmap.size = 64*1024;
+	info->pixmap.buf_align = 8;
+	info->pixmap.flags = FB_PIXMAP_SYSTEM;
+
+	if (intelfb_init_var(dinfo))
+		return 1;
+
+	info->pixmap.scan_align = 1;
+
+	update_dinfo(dinfo, &info->var);
+
+	return 0;
+}
+
+/* Update dinfo to match the active video mode. */
+static void
+update_dinfo(struct intelfb_info *dinfo, struct fb_var_screeninfo *var)
+{
+	DBG_MSG("update_dinfo\n");
+
+	dinfo->bpp = var->bits_per_pixel;
+	dinfo->depth = intelfb_var_to_depth(var);
+	dinfo->xres = var->xres;
+	dinfo->yres = var->xres;
+	dinfo->pixclock = var->pixclock;
+
+	intelfb_get_fix(&dinfo->info->fix, dinfo->info);
+
+	switch (dinfo->bpp) {
+	case 8:
+		dinfo->visual = FB_VISUAL_PSEUDOCOLOR;
+		dinfo->pitch = var->xres_virtual;
+		break;
+	case 16:
+		dinfo->visual = FB_VISUAL_TRUECOLOR;
+		dinfo->pitch = var->xres_virtual * 2;
+		break;
+	case 32:
+		dinfo->visual = FB_VISUAL_TRUECOLOR;
+		dinfo->pitch = var->xres_virtual * 4;
+		break;
+	}
+
+	/* Make sure the line length is a aligned correctly. */
+	dinfo->pitch = ROUND_UP_TO(dinfo->pitch, STRIDE_ALIGNMENT);
+
+	if (FIXED_MODE(dinfo))
+		dinfo->pitch = dinfo->initial_pitch;
+
+	dinfo->info->screen_base = (char __iomem *)dinfo->fb.virtual;
+	dinfo->info->fix.line_length = dinfo->pitch;
+	dinfo->info->fix.visual = dinfo->visual;
+}
+
+/* fbops functions */
+
+static int
+intelfb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info)
+{
+	struct intelfb_info *dinfo = GET_DINFO(info);
+
+	DBG_MSG("intelfb_get_fix\n");
+
+	memset(fix, 0, sizeof(*fix));
+	strcpy(fix->id, dinfo->name);
+	fix->smem_start = dinfo->fb.physical;
+	fix->smem_len = dinfo->fb.size;
+	fix->type = FB_TYPE_PACKED_PIXELS;
+	fix->type_aux = 0;
+	fix->visual = dinfo->visual;
+	fix->xpanstep = 8;
+	fix->ypanstep = 1;
+	fix->ywrapstep = 0;
+	fix->line_length = dinfo->pitch;
+	fix->mmio_start = dinfo->mmio_base_phys;
+	fix->mmio_len = INTEL_REG_SIZE;
+	fix->accel = FB_ACCEL_I830;
+	return 0;
+}
+
+/***************************************************************
+ *                       fbdev interface                       *
+ ***************************************************************/
+
+static int
+intelfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+	int change_var = 0;
+	struct fb_var_screeninfo v;
+	struct intelfb_info *dinfo;
+	static int first = 1;
+
+	DBG_MSG("intelfb_check_var: accel_flags is %d\n", var->accel_flags);
+
+	dinfo = GET_DINFO(info);
+
+	if (intelfbhw_validate_mode(dinfo, var) != 0)
+		return -EINVAL;
+
+	v = *var;
+
+	/* Check for a supported bpp. */
+	if (v.bits_per_pixel <= 8) {
+		v.bits_per_pixel = 8;
+	} else if (v.bits_per_pixel <= 16) {
+		if (v.bits_per_pixel == 16)
+			v.green.length = 6;
+		v.bits_per_pixel = 16;
+	} else if (v.bits_per_pixel <= 32) {
+		v.bits_per_pixel = 32;
+	} else
+		return -EINVAL;
+
+	change_var = ((info->var.xres != var->xres) ||
+		      (info->var.yres != var->yres) ||
+		      (info->var.xres_virtual != var->xres_virtual) ||
+		      (info->var.yres_virtual != var->yres_virtual) ||
+		      (info->var.bits_per_pixel != var->bits_per_pixel) ||
+		      memcmp(&info->var.red, &var->red, sizeof(var->red)) ||
+		      memcmp(&info->var.green, &var->green,
+			     sizeof(var->green)) ||
+		      memcmp(&info->var.blue, &var->blue, sizeof(var->blue)));
+
+	if (FIXED_MODE(dinfo) &&
+	    (change_var ||
+	     var->yres_virtual > dinfo->initial_var.yres_virtual ||
+	     var->yres_virtual < dinfo->initial_var.yres ||
+	     var->xoffset || var->nonstd)) {
+		if (first) {
+			ERR_MSG("Changing the video mode is not supported.\n");
+			first = 0;
+		}
+		return -EINVAL;
+	}
+
+	switch (intelfb_var_to_depth(&v)) {
+	case 8:
+		v.red.offset = v.green.offset = v.blue.offset = 0;
+		v.red.length = v.green.length = v.blue.length = 8;
+		v.transp.offset = v.transp.length = 0;
+		break;
+	case 15:
+		v.red.offset = 10;
+		v.green.offset = 5;
+		v.blue.offset = 0;
+		v.red.length = v.green.length = v.blue.length = 5;
+		v.transp.offset = v.transp.length = 0;
+		break;
+	case 16:
+		v.red.offset = 11;
+		v.green.offset = 5;
+		v.blue.offset = 0;
+		v.red.length = 5;
+		v.green.length = 6;
+		v.blue.length = 5;
+		v.transp.offset = v.transp.length = 0;
+		break;
+	case 24:
+		v.red.offset = 16;
+		v.green.offset = 8;
+		v.blue.offset = 0;
+		v.red.length = v.green.length = v.blue.length = 8;
+		v.transp.offset = v.transp.length = 0;
+		break;
+	case 32:
+		v.red.offset = 16;
+		v.green.offset = 8;
+		v.blue.offset = 0;
+		v.red.length = v.green.length = v.blue.length = 8;
+		v.transp.offset = 24;
+		v.transp.length = 8;
+		break;
+	}
+
+	if (v.xoffset < 0)
+		v.xoffset = 0;
+	if (v.yoffset < 0)
+		v.yoffset = 0;
+
+	if (v.xoffset > v.xres_virtual - v.xres)
+		v.xoffset = v.xres_virtual - v.xres;
+	if (v.yoffset > v.yres_virtual - v.yres)
+		v.yoffset = v.yres_virtual - v.yres;
+
+	v.red.msb_right = v.green.msb_right = v.blue.msb_right =
+			  v.transp.msb_right = 0;
+
+        *var = v;
+
+	return 0;
+}
+
+static int
+intelfb_set_par(struct fb_info *info)
+{
+	struct intelfb_hwstate hw;
+
+        struct intelfb_info *dinfo = GET_DINFO(info);
+
+	if (FIXED_MODE(dinfo)) {
+		ERR_MSG("Changing the video mode is not supported.\n");
+		return -EINVAL;
+	}
+
+	DBG_MSG("intelfb_set_par (%dx%d-%d)\n", info->var.xres,
+		info->var.yres, info->var.bits_per_pixel);
+
+	intelfb_blank(FB_BLANK_POWERDOWN, info);
+
+	if (dinfo->accel)
+		intelfbhw_2d_stop(dinfo);
+
+	hw = dinfo->save_state;
+	if (intelfbhw_mode_to_hw(dinfo, &hw, &info->var))
+		return -EINVAL;
+	if (intelfbhw_program_mode(dinfo, &hw, 0))
+		return -EINVAL;
+
+#if REGDUMP > 0
+	intelfbhw_read_hw_state(dinfo, &hw, 0);
+	intelfbhw_print_hw_state(dinfo, &hw);
+#endif
+
+	update_dinfo(dinfo, &info->var);
+
+	if (dinfo->accel)
+		intelfbhw_2d_start(dinfo);
+
+	intelfb_pan_display(&info->var, info);
+
+	intelfb_blank(FB_BLANK_UNBLANK, info);
+
+	if (ACCEL(dinfo, info)) {
+		info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
+		FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
+		FBINFO_HWACCEL_IMAGEBLIT;
+	} else {
+		info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
+	}
+	return 0;
+}
+
+static int
+intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
+		  unsigned blue, unsigned transp, struct fb_info *info)
+{
+	struct intelfb_info *dinfo = GET_DINFO(info);
+
+#if VERBOSE > 0
+	DBG_MSG("intelfb_setcolreg: regno %d, depth %d\n", regno, dinfo->depth);
+#endif
+
+	if (regno > 255)
+		return 1;
+
+	switch (dinfo->depth) {
+	case 8:
+		{
+			red >>= 8;
+			green >>= 8;
+			blue >>= 8;
+
+			dinfo->palette[regno].red = red;
+			dinfo->palette[regno].green = green;
+			dinfo->palette[regno].blue = blue;
+
+			intelfbhw_setcolreg(dinfo, regno, red, green, blue,
+					    transp);
+		}
+		break;
+	case 15:
+		dinfo->pseudo_palette[regno] = ((red & 0xf800) >>  1) |
+					       ((green & 0xf800) >>  6) |
+					       ((blue & 0xf800) >> 11);
+		break;
+	case 16:
+		dinfo->pseudo_palette[regno] = (red & 0xf800) |
+					       ((green & 0xfc00) >>  5) |
+					       ((blue  & 0xf800) >> 11);
+		break;
+	case 24:
+		dinfo->pseudo_palette[regno] = ((red & 0xff00) << 8) |
+					       (green & 0xff00) |
+					       ((blue  & 0xff00) >> 8);
+		break;
+	}
+	return 0;
+}
+
+static int
+intelfb_blank(int blank, struct fb_info *info)
+{
+	intelfbhw_do_blank(blank, info);
+	return 0;
+}
+
+static int
+intelfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+	intelfbhw_pan_display(var, info);
+	return 0;
+}
+
+/* When/if we have our own ioctls. */
+static int
+intelfb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+	      unsigned long arg, struct fb_info *info)
+{
+	int retval = 0;
+
+	return retval;
+}
+
+static void
+intelfb_fillrect (struct fb_info *info, const struct fb_fillrect *rect)
+{
+        struct intelfb_info *dinfo = GET_DINFO(info);
+	u32 rop, color;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfb_fillrect\n");
+#endif
+
+	if (!ACCEL(dinfo, info) || dinfo->depth == 4)
+		return cfb_fillrect(info, rect);
+
+	if (rect->rop == ROP_COPY)
+		rop = PAT_ROP_GXCOPY;
+	else // ROP_XOR
+		rop = PAT_ROP_GXXOR;
+
+	if (dinfo->depth != 8)
+		color = dinfo->pseudo_palette[rect->color];
+	else
+		color = rect->color;
+
+	intelfbhw_do_fillrect(dinfo, rect->dx, rect->dy,
+			      rect->width, rect->height, color,
+			      dinfo->pitch, info->var.bits_per_pixel,
+			      rop);
+}
+
+static void
+intelfb_copyarea(struct fb_info *info, const struct fb_copyarea *region)
+{
+        struct intelfb_info *dinfo = GET_DINFO(info);
+
+#if VERBOSE > 0
+	DBG_MSG("intelfb_copyarea\n");
+#endif
+
+	if (!ACCEL(dinfo, info) || dinfo->depth == 4)
+		return cfb_copyarea(info, region);
+
+	intelfbhw_do_bitblt(dinfo, region->sx, region->sy, region->dx,
+			    region->dy, region->width, region->height,
+			    dinfo->pitch, info->var.bits_per_pixel);
+}
+
+static void
+intelfb_imageblit(struct fb_info *info, const struct fb_image *image)
+{
+        struct intelfb_info *dinfo = GET_DINFO(info);
+	u32 fgcolor, bgcolor;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfb_imageblit\n");
+#endif
+
+	if (!ACCEL(dinfo, info) || dinfo->depth == 4
+	    || image->depth != 1)
+		return cfb_imageblit(info, image);
+
+	if (dinfo->depth != 8) {
+		fgcolor = dinfo->pseudo_palette[image->fg_color];
+		bgcolor = dinfo->pseudo_palette[image->bg_color];
+	} else {
+		fgcolor = image->fg_color;
+		bgcolor = image->bg_color;
+	}
+
+	if (!intelfbhw_do_drawglyph(dinfo, fgcolor, bgcolor, image->width,
+				    image->height, image->data,
+				    image->dx, image->dy,
+				    dinfo->pitch, info->var.bits_per_pixel))
+		return cfb_imageblit(info, image);
+}
+
+static int
+intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
+{
+        struct intelfb_info *dinfo = GET_DINFO(info);
+
+#if VERBOSE > 0
+	DBG_MSG("intelfb_cursor\n");
+#endif
+
+	if (!dinfo->hwcursor)
+		return soft_cursor(info, cursor);
+
+	intelfbhw_cursor_hide(dinfo);
+
+	/* If XFree killed the cursor - restore it */
+	if (INREG(CURSOR_A_BASEADDR) != dinfo->cursor.offset << 12) {
+		u32 fg, bg;
+
+		DBG_MSG("the cursor was killed - restore it !!\n");
+		DBG_MSG("size %d, %d   pos %d, %d\n",
+			cursor->image.width, cursor->image.height,
+			cursor->image.dx, cursor->image.dy);
+
+		intelfbhw_cursor_init(dinfo);
+		intelfbhw_cursor_reset(dinfo);
+		intelfbhw_cursor_setpos(dinfo, cursor->image.dx,
+					cursor->image.dy);
+
+		if (dinfo->depth != 8) {
+			fg =dinfo->pseudo_palette[cursor->image.fg_color];
+			bg =dinfo->pseudo_palette[cursor->image.bg_color];
+		} else {
+			fg = cursor->image.fg_color;
+			bg = cursor->image.bg_color;
+		}
+		intelfbhw_cursor_setcolor(dinfo, bg, fg);
+		intelfbhw_cursor_load(dinfo, cursor->image.width,
+				      cursor->image.height,
+				      dinfo->cursor_src);
+
+		if (cursor->enable)
+			intelfbhw_cursor_show(dinfo);
+		return 0;
+	}
+
+	if (cursor->set & FB_CUR_SETPOS) {
+		u32 dx, dy;
+
+		dx = cursor->image.dx - info->var.xoffset;
+		dy = cursor->image.dy - info->var.yoffset;
+
+		intelfbhw_cursor_setpos(dinfo, dx, dy);
+	}
+
+	if (cursor->set & FB_CUR_SETSIZE) {
+		if (cursor->image.width > 64 || cursor->image.height > 64)
+			return -ENXIO;
+
+		intelfbhw_cursor_reset(dinfo);
+	}
+
+	if (cursor->set & FB_CUR_SETCMAP) {
+		u32 fg, bg;
+
+		if (dinfo->depth != 8) {
+			fg = dinfo->pseudo_palette[cursor->image.fg_color];
+			bg = dinfo->pseudo_palette[cursor->image.bg_color];
+		} else {
+			fg = cursor->image.fg_color;
+			bg = cursor->image.bg_color;
+		}
+
+		intelfbhw_cursor_setcolor(dinfo, bg, fg);
+	}
+
+	if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
+		u32 s_pitch = (ROUND_UP_TO(cursor->image.width, 8) / 8);
+		u32 size = s_pitch * cursor->image.height;
+		u8 *dat = (u8 *) cursor->image.data;
+		u8 *msk = (u8 *) cursor->mask;
+		u8 src[64];
+		u32 i;
+
+		if (cursor->image.depth != 1)
+			return -ENXIO;
+
+		switch (cursor->rop) {
+		case ROP_XOR:
+			for (i = 0; i < size; i++)
+				src[i] = dat[i] ^ msk[i];
+			break;
+		case ROP_COPY:
+		default:
+			for (i = 0; i < size; i++)
+				src[i] = dat[i] & msk[i];
+			break;
+		}
+
+		/* save the bitmap to restore it when XFree will
+		   make the cursor dirty */
+		memcpy(dinfo->cursor_src, src, size);
+
+		intelfbhw_cursor_load(dinfo, cursor->image.width,
+				      cursor->image.height, src);
+	}
+
+	if (cursor->enable)
+		intelfbhw_cursor_show(dinfo);
+
+	return 0;
+}
+
+static int
+intelfb_sync(struct fb_info *info)
+{
+        struct intelfb_info *dinfo = GET_DINFO(info);
+
+#if VERBOSE > 0
+	DBG_MSG("intelfb_sync\n");
+#endif
+
+	if (dinfo->ring_lockup)
+		return 0;
+
+	intelfbhw_do_sync(dinfo);
+	return 0;
+}
+
diff -Nru a/drivers/video/intelfb/intelfbdrv.h b/drivers/video/intelfb/intelfbdrv.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/intelfb/intelfbdrv.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,69 @@
+#ifndef _INTELFBDRV_H
+#define _INTELFBDRV_H
+
+/*
+ ******************************************************************************
+ * intelfb
+ *
+ * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G
+ * integrated graphics chips.
+ *
+ * Copyright © 2004 Sylvain Meyer
+ *
+ * Author: Sylvain Meyer
+ *
+ ******************************************************************************
+ *    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.
+*/
+
+int __init intelfb_setup(char *options);
+static void __devinit get_initial_mode(struct intelfb_info *dinfo);
+static void update_dinfo(struct intelfb_info *dinfo,
+			 struct fb_var_screeninfo *var);
+static int intelfb_get_fix(struct fb_fix_screeninfo *fix,
+			   struct fb_info *info);
+
+static int intelfb_check_var(struct fb_var_screeninfo *var,
+			     struct fb_info *info);
+static int intelfb_set_par(struct fb_info *info);
+static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
+			     unsigned blue, unsigned transp,
+			     struct fb_info *info);
+
+static int intelfb_blank(int blank, struct fb_info *info);
+static int intelfb_pan_display(struct fb_var_screeninfo *var,
+			       struct fb_info *info);
+
+static void intelfb_fillrect(struct fb_info *info,
+			     const struct fb_fillrect *rect);
+static void intelfb_copyarea(struct fb_info *info,
+			     const struct fb_copyarea *region);
+static void intelfb_imageblit(struct fb_info *info,
+			      const struct fb_image *image);
+static int intelfb_cursor(struct fb_info *info,
+			   struct fb_cursor *cursor);
+
+static int intelfb_sync(struct fb_info *info);
+
+static int intelfb_ioctl(struct inode *inode, struct file *file,
+			 unsigned int cmd, unsigned long arg,
+			 struct fb_info *info);
+
+static int __devinit intelfb_pci_register(struct pci_dev *pdev,
+					  const struct pci_device_id *ent);
+static void __devexit intelfb_pci_unregister(struct pci_dev *pdev);
+static int __devinit intelfb_set_fbinfo(struct intelfb_info *dinfo);
+
+#endif
diff -Nru a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/intelfb/intelfbhw.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1753 @@
+/*
+ * intelfb
+ *
+ * Linux framebuffer driver for Intel(R) 865G integrated graphics chips.
+ *
+ * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
+ *                   2004 Sylvain Meyer
+ *
+ * This driver consists of two parts.  The first part (intelfbdrv.c) provides
+ * the basic fbdev interfaces, is derived in part from the radeonfb and
+ * vesafb drivers, and is covered by the GPL.  The second part (intelfbhw.c)
+ * provides the code to program the hardware.  Most of it is derived from
+ * the i810/i830 XFree86 driver.  The HW-specific code is covered here
+ * under a dual license (GPL and MIT/XFree86 license).
+ *
+ * Author: David Dawes
+ *
+ */
+
+/* $DHD: intelfb/intelfbhw.c,v 1.9 2003/06/27 15:06:25 dawes Exp $ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/tty.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fb.h>
+#include <linux/console.h>
+#include <linux/selection.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/vmalloc.h>
+#include <linux/kd.h>
+#include <linux/vt_kern.h>
+#include <linux/pagemap.h>
+#include <linux/version.h>
+
+#include <asm/io.h>
+
+#include "intelfb.h"
+#include "intelfbhw.h"
+
+int
+intelfbhw_get_chipset(struct pci_dev *pdev, const char **name, int *chipset,
+		      int *mobile)
+{
+	u32 tmp;
+
+	if (!pdev || !name || !chipset || !mobile)
+		return 1;
+
+	switch (pdev->device) {
+	case PCI_DEVICE_ID_INTEL_830M:
+		*name = "Intel(R) 830M";
+		*chipset = INTEL_830M;
+		*mobile = 1;
+		return 0;
+	case PCI_DEVICE_ID_INTEL_845G:
+		*name = "Intel(R) 845G";
+		*chipset = INTEL_845G;
+		*mobile = 0;
+		return 0;
+	case PCI_DEVICE_ID_INTEL_85XGM:
+		tmp = 0;
+		*mobile = 1;
+		pci_read_config_dword(pdev, INTEL_85X_CAPID, &tmp);
+		switch ((tmp >> INTEL_85X_VARIANT_SHIFT) &
+			INTEL_85X_VARIANT_MASK) {
+		case INTEL_VAR_855GME:
+			*name = "Intel(R) 855GME";
+			*chipset = INTEL_855GME;
+			return 0;
+		case INTEL_VAR_855GM:
+			*name = "Intel(R) 855GM";
+			*chipset = INTEL_855GM;
+			return 0;
+		case INTEL_VAR_852GME:
+			*name = "Intel(R) 852GME";
+			*chipset = INTEL_852GME;
+			return 0;
+		case INTEL_VAR_852GM:
+			*name = "Intel(R) 852GM";
+			*chipset = INTEL_852GM;
+			return 0;
+		default:
+			*name = "Intel(R) 852GM/855GM";
+			*chipset = INTEL_85XGM;
+			return 0;
+		}
+		break;
+	case PCI_DEVICE_ID_INTEL_865G:
+		*name = "Intel(R) 865G";
+		*chipset = INTEL_865G;
+		*mobile = 0;
+		return 0;
+	default:
+		return 1;
+	}
+}
+
+int
+intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
+		     int *stolen_size)
+{
+	struct pci_dev *bridge_dev;
+	u16 tmp;
+
+	if (!pdev || !aperture_size || !stolen_size)
+		return 1;
+
+	/* Find the bridge device.  It is always 0:0.0 */
+	if (!(bridge_dev = pci_find_slot(0, PCI_DEVFN(0, 0)))) {
+		ERR_MSG("cannot find bridge device\n");
+		return 1;
+	}
+
+	/* Get the fb aperture size and "stolen" memory amount. */
+	tmp = 0;
+	pci_read_config_word(bridge_dev, INTEL_GMCH_CTRL, &tmp);
+	switch (pdev->device) {
+	case PCI_DEVICE_ID_INTEL_830M:
+	case PCI_DEVICE_ID_INTEL_845G:
+		if ((tmp & INTEL_GMCH_MEM_MASK) == INTEL_GMCH_MEM_64M)
+			*aperture_size = MB(64);
+		else
+			*aperture_size = MB(128);
+		switch (tmp & INTEL_830_GMCH_GMS_MASK) {
+		case INTEL_830_GMCH_GMS_STOLEN_512:
+			*stolen_size = KB(512) - KB(132);
+			return 0;
+		case INTEL_830_GMCH_GMS_STOLEN_1024:
+			*stolen_size = MB(1) - KB(132);
+			return 0;
+		case INTEL_830_GMCH_GMS_STOLEN_8192:
+			*stolen_size = MB(8) - KB(132);
+			return 0;
+		case INTEL_830_GMCH_GMS_LOCAL:
+			ERR_MSG("only local memory found\n");
+			return 1;
+		case INTEL_830_GMCH_GMS_DISABLED:
+			ERR_MSG("video memory is disabled\n");
+			return 1;
+		default:
+			ERR_MSG("unexpected GMCH_GMS value: 0x%02x\n",
+				tmp & INTEL_830_GMCH_GMS_MASK);
+			return 1;
+		}
+		break;
+	default:
+		*aperture_size = MB(128);
+		switch (tmp & INTEL_855_GMCH_GMS_MASK) {
+		case INTEL_855_GMCH_GMS_STOLEN_1M:
+			*stolen_size = MB(1) - KB(132);
+			return 0;
+		case INTEL_855_GMCH_GMS_STOLEN_4M:
+			*stolen_size = MB(4) - KB(132);
+			return 0;
+		case INTEL_855_GMCH_GMS_STOLEN_8M:
+			*stolen_size = MB(8) - KB(132);
+			return 0;
+		case INTEL_855_GMCH_GMS_STOLEN_16M:
+			*stolen_size = MB(16) - KB(132);
+			return 0;
+		case INTEL_855_GMCH_GMS_STOLEN_32M:
+			*stolen_size = MB(32) - KB(132);
+			return 0;
+		case INTEL_855_GMCH_GMS_DISABLED:
+			ERR_MSG("video memory is disabled\n");
+			return 0;
+		default:
+			ERR_MSG("unexpected GMCH_GMS value: 0x%02x\n",
+				tmp & INTEL_855_GMCH_GMS_MASK);
+			return 1;
+		}
+	}
+}
+
+int
+intelfbhw_check_non_crt(struct intelfb_info *dinfo)
+{
+	int dvo = 0;
+
+	if (INREG(LVDS) & PORT_ENABLE)
+		dvo |= LVDS_PORT;
+	if (INREG(DVOA) & PORT_ENABLE)
+		dvo |= DVOA_PORT;
+	if (INREG(DVOB) & PORT_ENABLE)
+		dvo |= DVOB_PORT;
+	if (INREG(DVOC) & PORT_ENABLE)
+		dvo |= DVOC_PORT;
+
+	return dvo;
+}
+
+const char *
+intelfbhw_dvo_to_string(int dvo)
+{
+	if (dvo & DVOA_PORT)
+		return "DVO port A";
+	else if (dvo & DVOB_PORT)
+		return "DVO port B";
+	else if (dvo & DVOC_PORT)
+		return "DVO port C";
+	else if (dvo & LVDS_PORT)
+		return "LVDS port";
+	else
+		return NULL;
+}
+
+
+int
+intelfbhw_validate_mode(struct intelfb_info *dinfo,
+			struct fb_var_screeninfo *var)
+{
+	int bytes_per_pixel;
+	int tmp;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_validate_mode\n");
+#endif
+
+	bytes_per_pixel = var->bits_per_pixel / 8;
+	if (bytes_per_pixel == 3)
+		bytes_per_pixel = 4;
+
+	/* Check if enough video memory. */
+	tmp = var->yres_virtual * var->xres_virtual * bytes_per_pixel;
+	if (tmp > dinfo->fb.size) {
+		WRN_MSG("Not enough video ram for mode "
+			"(%d KByte vs %d KByte).\n",
+			BtoKB(tmp), BtoKB(dinfo->fb.size));
+		return 1;
+	}
+
+	/* Check if x/y limits are OK. */
+	if (var->xres - 1 > HACTIVE_MASK) {
+		WRN_MSG("X resolution too large (%d vs %d).\n",
+			var->xres, HACTIVE_MASK + 1);
+		return 1;
+	}
+	if (var->yres - 1 > VACTIVE_MASK) {
+		WRN_MSG("Y resolution too large (%d vs %d).\n",
+			var->yres, VACTIVE_MASK + 1);
+		return 1;
+	}
+
+	/* Check for interlaced/doublescan modes. */
+	if (var->vmode & FB_VMODE_INTERLACED) {
+		WRN_MSG("Mode is interlaced.\n");
+		return 1;
+	}
+	if (var->vmode & FB_VMODE_DOUBLE) {
+		WRN_MSG("Mode is double-scan.\n");
+		return 1;
+	}
+
+	/* Check if clock is OK. */
+	tmp = 1000000000 / var->pixclock;
+	if (tmp < MIN_CLOCK) {
+		WRN_MSG("Pixel clock is too low (%d MHz vs %d MHz).\n",
+			(tmp + 500) / 1000, MIN_CLOCK / 1000);
+		return 1;
+	}
+	if (tmp > MAX_CLOCK) {
+		WRN_MSG("Pixel clock is too high (%d MHz vs %d MHz).\n",
+			(tmp + 500) / 1000, MAX_CLOCK / 1000);
+		return 1;
+	}
+
+	return 0;
+}
+
+int
+intelfbhw_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+	struct intelfb_info *dinfo = GET_DINFO(info);
+	u32 offset, xoffset, yoffset;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_pan_display\n");
+#endif
+
+	xoffset = ROUND_DOWN_TO(var->xoffset, 8);
+	yoffset = var->yoffset;
+
+	if ((xoffset + var->xres > var->xres_virtual) ||
+	    (yoffset + var->yres > var->yres_virtual))
+		return -EINVAL;
+
+	offset = (yoffset * dinfo->pitch) +
+		 (xoffset * var->bits_per_pixel) / 8;
+
+	offset += dinfo->fb.offset << 12;
+
+	OUTREG(DSPABASE, offset);
+
+	return 0;
+}
+
+/* Blank the screen. */
+void
+intelfbhw_do_blank(int blank, struct fb_info *info)
+{
+	struct intelfb_info *dinfo = GET_DINFO(info);
+	u32 tmp;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_do_blank: blank is %d\n", blank);
+#endif
+
+	/* Turn plane A on or off */
+	tmp = INREG(DSPACNTR);
+	if (blank)
+		tmp &= ~DISPPLANE_PLANE_ENABLE;
+	else
+		tmp |= DISPPLANE_PLANE_ENABLE;
+	OUTREG(DSPACNTR, tmp);
+	/* Flush */
+	tmp = INREG(DSPABASE);
+	OUTREG(DSPABASE, tmp);
+
+	/* Turn off/on the HW cursor */
+#if VERBOSE > 0
+	DBG_MSG("cursor_on is %d\n", dinfo->cursor_on);
+#endif
+	if (dinfo->cursor_on) {
+		if (blank) {
+			intelfbhw_cursor_hide(dinfo);
+		} else {
+			intelfbhw_cursor_show(dinfo);
+		}
+		dinfo->cursor_on = 1;
+	}
+	dinfo->cursor_blanked = blank;
+
+	/* Set DPMS level */
+	tmp = INREG(ADPA) & ~ADPA_DPMS_CONTROL_MASK;
+	switch (blank) {
+	case FB_BLANK_UNBLANK:
+	case FB_BLANK_NORMAL:
+		tmp |= ADPA_DPMS_D0;
+		break;
+	case FB_BLANK_VSYNC_SUSPEND:
+		tmp |= ADPA_DPMS_D1;
+		break;
+	case FB_BLANK_HSYNC_SUSPEND:
+		tmp |= ADPA_DPMS_D2;
+		break;
+	case FB_BLANK_POWERDOWN:
+		tmp |= ADPA_DPMS_D3;
+		break;
+	}
+	OUTREG(ADPA, tmp);
+
+	return;
+}
+
+
+void
+intelfbhw_setcolreg(struct intelfb_info *dinfo, unsigned regno,
+		    unsigned red, unsigned green, unsigned blue,
+		    unsigned transp)
+{
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_setcolreg: %d: (%d, %d, %d)\n",
+		regno, red, green, blue);
+#endif
+
+	u32 palette_reg = (dinfo->pipe == PIPE_A) ?
+			  PALETTE_A : PALETTE_B;
+
+	OUTREG(palette_reg + (regno << 2),
+	       (red << PALETTE_8_RED_SHIFT) |
+	       (green << PALETTE_8_GREEN_SHIFT) |
+	       (blue << PALETTE_8_BLUE_SHIFT));
+}
+
+
+int
+intelfbhw_read_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw,
+			int flag)
+{
+	int i;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_read_hw_state\n");
+#endif
+
+	if (!hw || !dinfo)
+		return -1;
+
+	/* Read in as much of the HW state as possible. */
+	hw->vga0_divisor = INREG(VGA0_DIVISOR);
+	hw->vga1_divisor = INREG(VGA1_DIVISOR);
+	hw->vga_pd = INREG(VGAPD);
+	hw->dpll_a = INREG(DPLL_A);
+	hw->dpll_b = INREG(DPLL_B);
+	hw->fpa0 = INREG(FPA0);
+	hw->fpa1 = INREG(FPA1);
+	hw->fpb0 = INREG(FPB0);
+	hw->fpb1 = INREG(FPB1);
+
+	if (flag == 1)
+		return flag;
+
+#if 0
+	/* This seems to be a problem with the 852GM/855GM */
+	for (i = 0; i < PALETTE_8_ENTRIES; i++) {
+		hw->palette_a[i] = INREG(PALETTE_A + (i << 2));
+		hw->palette_b[i] = INREG(PALETTE_B + (i << 2));
+	}
+#endif
+
+	if (flag == 2)
+		return flag;
+
+	hw->htotal_a = INREG(HTOTAL_A);
+	hw->hblank_a = INREG(HBLANK_A);
+	hw->hsync_a = INREG(HSYNC_A);
+	hw->vtotal_a = INREG(VTOTAL_A);
+	hw->vblank_a = INREG(VBLANK_A);
+	hw->vsync_a = INREG(VSYNC_A);
+	hw->src_size_a = INREG(SRC_SIZE_A);
+	hw->bclrpat_a = INREG(BCLRPAT_A);
+	hw->htotal_b = INREG(HTOTAL_B);
+	hw->hblank_b = INREG(HBLANK_B);
+	hw->hsync_b = INREG(HSYNC_B);
+	hw->vtotal_b = INREG(VTOTAL_B);
+	hw->vblank_b = INREG(VBLANK_B);
+	hw->vsync_b = INREG(VSYNC_B);
+	hw->src_size_b = INREG(SRC_SIZE_B);
+	hw->bclrpat_b = INREG(BCLRPAT_B);
+
+	if (flag == 3)
+		return flag;
+
+	hw->adpa = INREG(ADPA);
+	hw->dvoa = INREG(DVOA);
+	hw->dvob = INREG(DVOB);
+	hw->dvoc = INREG(DVOC);
+	hw->dvoa_srcdim = INREG(DVOA_SRCDIM);
+	hw->dvob_srcdim = INREG(DVOB_SRCDIM);
+	hw->dvoc_srcdim = INREG(DVOC_SRCDIM);
+	hw->lvds = INREG(LVDS);
+
+	if (flag == 4)
+		return flag;
+
+	hw->pipe_a_conf = INREG(PIPEACONF);
+	hw->pipe_b_conf = INREG(PIPEBCONF);
+	hw->disp_arb = INREG(DISPARB);
+
+	if (flag == 5)
+		return flag;
+
+	hw->cursor_a_control = INREG(CURSOR_A_CONTROL);
+	hw->cursor_b_control = INREG(CURSOR_B_CONTROL);
+	hw->cursor_a_base = INREG(CURSOR_A_BASEADDR);
+	hw->cursor_b_base = INREG(CURSOR_B_BASEADDR);
+
+	if (flag == 6)
+		return flag;
+
+	for (i = 0; i < 4; i++) {
+		hw->cursor_a_palette[i] = INREG(CURSOR_A_PALETTE0 + (i << 2));
+		hw->cursor_b_palette[i] = INREG(CURSOR_B_PALETTE0 + (i << 2));
+	}
+
+	if (flag == 7)
+		return flag;
+
+	hw->cursor_size = INREG(CURSOR_SIZE);
+
+	if (flag == 8)
+		return flag;
+
+	hw->disp_a_ctrl = INREG(DSPACNTR);
+	hw->disp_b_ctrl = INREG(DSPBCNTR);
+	hw->disp_a_base = INREG(DSPABASE);
+	hw->disp_b_base = INREG(DSPBBASE);
+	hw->disp_a_stride = INREG(DSPASTRIDE);
+	hw->disp_b_stride = INREG(DSPBSTRIDE);
+
+	if (flag == 9)
+		return flag;
+
+	hw->vgacntrl = INREG(VGACNTRL);
+
+	if (flag == 10)
+		return flag;
+
+	hw->add_id = INREG(ADD_ID);
+
+	if (flag == 11)
+		return flag;
+
+	for (i = 0; i < 7; i++) {
+		hw->swf0x[i] = INREG(SWF00 + (i << 2));
+		hw->swf1x[i] = INREG(SWF10 + (i << 2));
+		if (i < 3)
+			hw->swf3x[i] = INREG(SWF30 + (i << 2));
+	}
+
+	for (i = 0; i < 8; i++)
+		hw->fence[i] = INREG(FENCE + (i << 2));
+
+	hw->instpm = INREG(INSTPM);
+	hw->mem_mode = INREG(MEM_MODE);
+	hw->fw_blc_0 = INREG(FW_BLC_0);
+	hw->fw_blc_1 = INREG(FW_BLC_1);
+
+	return 0;
+}
+
+
+void
+intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw)
+{
+#if REGDUMP
+	int i, m1, m2, n, p1, p2;
+
+	DBG_MSG("intelfbhw_print_hw_state\n");
+
+	if (!hw || !dinfo)
+		return;
+	/* Read in as much of the HW state as possible. */
+	printk("hw state dump start\n");
+	printk("	VGA0_DIVISOR:		0x%08x\n", hw->vga0_divisor);
+	printk("	VGA1_DIVISOR:		0x%08x\n", hw->vga1_divisor);
+	printk("	VGAPD: 			0x%08x\n", hw->vga_pd);
+	n = (hw->vga0_divisor >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	m1 = (hw->vga0_divisor >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	m2 = (hw->vga0_divisor >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	if (hw->vga_pd & VGAPD_0_P1_FORCE_DIV2)
+		p1 = 0;
+	else
+		p1 = (hw->vga_pd >> VGAPD_0_P1_SHIFT) & DPLL_P1_MASK;
+	p2 = (hw->vga_pd >> VGAPD_0_P2_SHIFT) & DPLL_P2_MASK;
+	printk("	VGA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
+		m1, m2, n, p1, p2);
+	printk("	VGA0: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2));
+
+	n = (hw->vga1_divisor >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	m1 = (hw->vga1_divisor >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	m2 = (hw->vga1_divisor >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	if (hw->vga_pd & VGAPD_1_P1_FORCE_DIV2)
+		p1 = 0;
+	else
+		p1 = (hw->vga_pd >> VGAPD_1_P1_SHIFT) & DPLL_P1_MASK;
+	p2 = (hw->vga_pd >> VGAPD_1_P2_SHIFT) & DPLL_P2_MASK;
+	printk("	VGA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
+		m1, m2, n, p1, p2);
+	printk("	VGA1: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2));
+
+	printk("	DPLL_A:			0x%08x\n", hw->dpll_a);
+	printk("	DPLL_B:			0x%08x\n", hw->dpll_b);
+	printk("	FPA0:			0x%08x\n", hw->fpa0);
+	printk("	FPA1:			0x%08x\n", hw->fpa1);
+	printk("	FPB0:			0x%08x\n", hw->fpb0);
+	printk("	FPB1:			0x%08x\n", hw->fpb1);
+
+	n = (hw->fpa0 >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	m1 = (hw->fpa0 >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	m2 = (hw->fpa0 >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	if (hw->dpll_a & DPLL_P1_FORCE_DIV2)
+		p1 = 0;
+	else
+		p1 = (hw->dpll_a >> DPLL_P1_SHIFT) & DPLL_P1_MASK;
+	p2 = (hw->dpll_a >> DPLL_P2_SHIFT) & DPLL_P2_MASK;
+	printk("	PLLA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
+		m1, m2, n, p1, p2);
+	printk("	PLLA0: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2));
+
+	n = (hw->fpa1 >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	m1 = (hw->fpa1 >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	m2 = (hw->fpa1 >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
+	if (hw->dpll_a & DPLL_P1_FORCE_DIV2)
+		p1 = 0;
+	else
+		p1 = (hw->dpll_a >> DPLL_P1_SHIFT) & DPLL_P1_MASK;
+	p2 = (hw->dpll_a >> DPLL_P2_SHIFT) & DPLL_P2_MASK;
+	printk("	PLLA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
+		m1, m2, n, p1, p2);
+	printk("	PLLA1: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2));
+
+#if 0
+	printk("	PALETTE_A:\n");
+	for (i = 0; i < PALETTE_8_ENTRIES)
+		printk("	%3d:	0x%08x\n", i, hw->palette_a[i];
+	printk("	PALETTE_B:\n");
+	for (i = 0; i < PALETTE_8_ENTRIES)
+		printk("	%3d:	0x%08x\n", i, hw->palette_b[i];
+#endif
+
+	printk("	HTOTAL_A:		0x%08x\n", hw->htotal_a);
+	printk("	HBLANK_A:		0x%08x\n", hw->hblank_a);
+	printk("	HSYNC_A:		0x%08x\n", hw->hsync_a);
+	printk("	VTOTAL_A:		0x%08x\n", hw->vtotal_a);
+	printk("	VBLANK_A:		0x%08x\n", hw->vblank_a);
+	printk("	VSYNC_A:		0x%08x\n", hw->vsync_a);
+	printk("	SRC_SIZE_A:		0x%08x\n", hw->src_size_a);
+	printk("	BCLRPAT_A:		0x%08x\n", hw->bclrpat_a);
+	printk("	HTOTAL_B:		0x%08x\n", hw->htotal_b);
+	printk("	HBLANK_B:		0x%08x\n", hw->hblank_b);
+	printk("	HSYNC_B:		0x%08x\n", hw->hsync_b);
+	printk("	VTOTAL_B:		0x%08x\n", hw->vtotal_b);
+	printk("	VBLANK_B:		0x%08x\n", hw->vblank_b);
+	printk("	VSYNC_B:		0x%08x\n", hw->vsync_b);
+	printk("	SRC_SIZE_B:		0x%08x\n", hw->src_size_b);
+	printk("	BCLRPAT_B:		0x%08x\n", hw->bclrpat_b);
+
+	printk("	ADPA:			0x%08x\n", hw->adpa);
+	printk("	DVOA:			0x%08x\n", hw->dvoa);
+	printk("	DVOB:			0x%08x\n", hw->dvob);
+	printk("	DVOC:			0x%08x\n", hw->dvoc);
+	printk("	DVOA_SRCDIM:		0x%08x\n", hw->dvoa_srcdim);
+	printk("	DVOB_SRCDIM:		0x%08x\n", hw->dvob_srcdim);
+	printk("	DVOC_SRCDIM:		0x%08x\n", hw->dvoc_srcdim);
+	printk("	LVDS:			0x%08x\n", hw->lvds);
+
+	printk("	PIPEACONF:		0x%08x\n", hw->pipe_a_conf);
+	printk("	PIPEBCONF:		0x%08x\n", hw->pipe_b_conf);
+	printk("	DISPARB:		0x%08x\n", hw->disp_arb);
+
+	printk("	CURSOR_A_CONTROL:	0x%08x\n", hw->cursor_a_control);
+	printk("	CURSOR_B_CONTROL:	0x%08x\n", hw->cursor_b_control);
+	printk("	CURSOR_A_BASEADDR:	0x%08x\n", hw->cursor_a_base);
+	printk("	CURSOR_B_BASEADDR:	0x%08x\n", hw->cursor_b_base);
+
+	printk("	CURSOR_A_PALETTE:	");
+	for (i = 0; i < 4; i++) {
+		printk("0x%08x", hw->cursor_a_palette[i]);
+		if (i < 3)
+			printk(", ");
+	}
+	printk("\n");
+	printk("	CURSOR_B_PALETTE:	");
+	for (i = 0; i < 4; i++) {
+		printk("0x%08x", hw->cursor_b_palette[i]);
+		if (i < 3)
+			printk(", ");
+	}
+	printk("\n");
+
+	printk("	CURSOR_SIZE:		0x%08x\n", hw->cursor_size);
+
+	printk("	DSPACNTR:		0x%08x\n", hw->disp_a_ctrl);
+	printk("	DSPBCNTR:		0x%08x\n", hw->disp_b_ctrl);
+	printk("	DSPABASE:		0x%08x\n", hw->disp_a_base);
+	printk("	DSPBBASE:		0x%08x\n", hw->disp_b_base);
+	printk("	DSPASTRIDE:		0x%08x\n", hw->disp_a_stride);
+	printk("	DSPBSTRIDE:		0x%08x\n", hw->disp_b_stride);
+
+	printk("	VGACNTRL:		0x%08x\n", hw->vgacntrl);
+	printk("	ADD_ID:			0x%08x\n", hw->add_id);
+
+	for (i = 0; i < 7; i++) {
+		printk("	SWF0%d			0x%08x\n", i,
+			hw->swf0x[i]);
+	}
+	for (i = 0; i < 7; i++) {
+		printk("	SWF1%d			0x%08x\n", i,
+			hw->swf1x[i]);
+	}
+	for (i = 0; i < 3; i++) {
+		printk("	SWF3%d			0x%08x\n", i,
+			hw->swf3x[i]);
+	}
+	for (i = 0; i < 8; i++)
+		printk("	FENCE%d			0x%08x\n", i,
+			hw->fence[i]);
+
+	printk("	INSTPM			0x%08x\n", hw->instpm);
+	printk("	MEM_MODE		0x%08x\n", hw->mem_mode);
+	printk("	FW_BLC_0		0x%08x\n", hw->fw_blc_0);
+	printk("	FW_BLC_1		0x%08x\n", hw->fw_blc_1);
+
+	printk("hw state dump end\n");
+#endif
+}
+
+/* Split the M parameter into M1 and M2. */
+static int
+splitm(unsigned int m, unsigned int *retm1, unsigned int *retm2)
+{
+	int m1, m2;
+
+	m1 = (m - 2 - (MIN_M2 + MAX_M2) / 2) / 5 - 2;
+	if (m1 < MIN_M1)
+		m1 = MIN_M1;
+	if (m1 > MAX_M1)
+		m1 = MAX_M1;
+	m2 = m - 5 * (m1 + 2) - 2;
+	if (m2 < MIN_M2 || m2 > MAX_M2 || m2 >= m1) {
+		return 1;
+	} else {
+		*retm1 = (unsigned int)m1;
+		*retm2 = (unsigned int)m2;
+		return 0;
+	}
+}
+
+/* Split the P parameter into P1 and P2. */
+static int
+splitp(unsigned int p, unsigned int *retp1, unsigned int *retp2)
+{
+	int p1, p2;
+
+	if (p % 4 == 0)
+		p2 = 1;
+	else
+		p2 = 0;
+	p1 = (p / (1 << (p2 + 1))) - 2;
+	if (p % 4 == 0 && p1 < MIN_P1) {
+		p2 = 0;
+		p1 = (p / (1 << (p2 + 1))) - 2;
+	}
+	if (p1  < MIN_P1 || p1 > MAX_P1 || (p1 + 2) * (1 << (p2 + 1)) != p) {
+		return 1;
+	} else {
+		*retp1 = (unsigned int)p1;
+		*retp2 = (unsigned int)p2;
+		return 0;
+	}
+}
+
+static int
+calc_pll_params(int clock, u32 *retm1, u32 *retm2, u32 *retn, u32 *retp1,
+		u32 *retp2, u32 *retclock)
+{
+	u32 m1, m2, n, p1, p2, n1;
+	u32 f_vco, p, p_best = 0, m, f_out;
+	u32 err_max, err_target, err_best = 10000000;
+	u32 n_best = 0, m_best = 0, f_best, f_err;
+	u32 p_min, p_max, p_inc, div_min, div_max;
+
+	/* Accept 0.5% difference, but aim for 0.1% */
+	err_max = 5 * clock / 1000;
+	err_target = clock / 1000;
+
+	DBG_MSG("Clock is %d\n", clock);
+
+	div_max = MAX_VCO_FREQ / clock;
+	div_min = ROUND_UP_TO(MIN_VCO_FREQ, clock) / clock;
+
+	if (clock <= P_TRANSITION_CLOCK)
+		p_inc = 4;
+	else
+		p_inc = 2;
+	p_min = ROUND_UP_TO(div_min, p_inc);
+	p_max = ROUND_DOWN_TO(div_max, p_inc);
+	if (p_min < MIN_P)
+		p_min = 4;
+	if (p_max > MAX_P)
+		p_max = 128;
+
+	DBG_MSG("p range is %d-%d (%d)\n", p_min, p_max, p_inc);
+
+	p = p_min;
+	do {
+		if (splitp(p, &p1, &p2)) {
+			WRN_MSG("cannot split p = %d\n", p);
+			p += p_inc;
+			continue;
+		}
+		n = MIN_N;
+		f_vco = clock * p;
+
+		do {
+			m = ROUND_UP_TO(f_vco * n, PLL_REFCLK) / PLL_REFCLK;
+			if (m < MIN_M)
+				m = MIN_M;
+			if (m > MAX_M)
+				m = MAX_M;
+			f_out = CALC_VCLOCK3(m, n, p);
+			if (splitm(m, &m1, &m2)) {
+				WRN_MSG("cannot split m = %d\n", m);
+				n++;
+				continue;
+			}
+			if (clock > f_out)
+				f_err = clock - f_out;
+			else
+				f_err = f_out - clock;
+
+			if (f_err < err_best) {
+				m_best = m;
+				n_best = n;
+				p_best = p;
+				f_best = f_out;
+				err_best = f_err;
+			}
+			n++;
+		} while ((n <= MAX_N) && (f_out >= clock));
+		p += p_inc;
+	} while ((p <= p_max));
+
+	if (!m_best) {
+		WRN_MSG("cannot find parameters for clock %d\n", clock);
+		return 1;
+	}
+	m = m_best;
+	n = n_best;
+	p = p_best;
+	splitm(m, &m1, &m2);
+	splitp(p, &p1, &p2);
+	n1 = n - 2;
+
+	DBG_MSG("m, n, p: %d (%d,%d), %d (%d), %d (%d,%d), "
+		"f: %d (%d), VCO: %d\n",
+		m, m1, m2, n, n1, p, p1, p2,
+		CALC_VCLOCK3(m, n, p), CALC_VCLOCK(m1, m2, n1, p1, p2),
+		CALC_VCLOCK3(m, n, p) * p);
+	*retm1 = m1;
+	*retm2 = m2;
+	*retn = n1;
+	*retp1 = p1;
+	*retp2 = p2;
+	*retclock = CALC_VCLOCK(m1, m2, n1, p1, p2);
+
+	return 0;
+}
+
+static __inline__ int
+check_overflow(u32 value, u32 limit, const char *description)
+{
+	if (value > limit) {
+		WRN_MSG("%s value %d exceeds limit %d\n",
+			description, value, limit);
+		return 1;
+	}
+	return 0;
+}
+
+/* It is assumed that hw is filled in with the initial state information. */
+int
+intelfbhw_mode_to_hw(struct intelfb_info *dinfo, struct intelfb_hwstate *hw,
+		     struct fb_var_screeninfo *var)
+{
+	int pipe = PIPE_A;
+	u32 *dpll, *fp0, *fp1;
+	u32 m1, m2, n, p1, p2, clock_target, clock;
+	u32 hsync_start, hsync_end, hblank_start, hblank_end, htotal, hactive;
+	u32 vsync_start, vsync_end, vblank_start, vblank_end, vtotal, vactive;
+	u32 vsync_pol, hsync_pol;
+	u32 *vs, *vb, *vt, *hs, *hb, *ht, *ss, *pipe_conf;
+
+	DBG_MSG("intelfbhw_mode_to_hw\n");
+
+	/* Disable VGA */
+	hw->vgacntrl |= VGA_DISABLE;
+
+	/* Check whether pipe A or pipe B is enabled. */
+	if (hw->pipe_a_conf & PIPECONF_ENABLE)
+		pipe = PIPE_A;
+	else if (hw->pipe_b_conf & PIPECONF_ENABLE)
+		pipe = PIPE_B;
+
+	/* Set which pipe's registers will be set. */
+	if (pipe == PIPE_B) {
+		dpll = &hw->dpll_b;
+		fp0 = &hw->fpb0;
+		fp1 = &hw->fpb1;
+		hs = &hw->hsync_b;
+		hb = &hw->hblank_b;
+		ht = &hw->htotal_b;
+		vs = &hw->vsync_b;
+		vb = &hw->vblank_b;
+		vt = &hw->vtotal_b;
+		ss = &hw->src_size_b;
+		pipe_conf = &hw->pipe_b_conf;
+	} else {
+		dpll = &hw->dpll_a;
+		fp0 = &hw->fpa0;
+		fp1 = &hw->fpa1;
+		hs = &hw->hsync_a;
+		hb = &hw->hblank_a;
+		ht = &hw->htotal_a;
+		vs = &hw->vsync_a;
+		vb = &hw->vblank_a;
+		vt = &hw->vtotal_a;
+		ss = &hw->src_size_a;
+		pipe_conf = &hw->pipe_a_conf;
+	}
+
+	/* Use ADPA register for sync control. */
+	hw->adpa &= ~ADPA_USE_VGA_HVPOLARITY;
+
+	/* sync polarity */
+	hsync_pol = (var->sync & FB_SYNC_HOR_HIGH_ACT) ?
+			ADPA_SYNC_ACTIVE_HIGH : ADPA_SYNC_ACTIVE_LOW;
+	vsync_pol = (var->sync & FB_SYNC_VERT_HIGH_ACT) ?
+			ADPA_SYNC_ACTIVE_HIGH : ADPA_SYNC_ACTIVE_LOW;
+	hw->adpa &= ~((ADPA_SYNC_ACTIVE_MASK << ADPA_VSYNC_ACTIVE_SHIFT) |
+		      (ADPA_SYNC_ACTIVE_MASK << ADPA_HSYNC_ACTIVE_SHIFT));
+	hw->adpa |= (hsync_pol << ADPA_HSYNC_ACTIVE_SHIFT) |
+		    (vsync_pol << ADPA_VSYNC_ACTIVE_SHIFT);
+
+	/* Connect correct pipe to the analog port DAC */
+	hw->adpa &= ~(PIPE_MASK << ADPA_PIPE_SELECT_SHIFT);
+	hw->adpa |= (pipe << ADPA_PIPE_SELECT_SHIFT);
+
+	/* Set DPMS state to D0 (on) */
+	hw->adpa &= ~ADPA_DPMS_CONTROL_MASK;
+	hw->adpa |= ADPA_DPMS_D0;
+
+	hw->adpa |= ADPA_DAC_ENABLE;
+
+	*dpll |= (DPLL_VCO_ENABLE | DPLL_VGA_MODE_DISABLE);
+	*dpll &= ~(DPLL_RATE_SELECT_MASK | DPLL_REFERENCE_SELECT_MASK);
+	*dpll |= (DPLL_REFERENCE_DEFAULT | DPLL_RATE_SELECT_FP0);
+
+	/* Desired clock in kHz */
+	clock_target = 1000000000 / var->pixclock;
+
+	if (calc_pll_params(clock_target, &m1, &m2, &n, &p1, &p2, &clock)) {
+		WRN_MSG("calc_pll_params failed\n");
+		return 1;
+	}
+
+	/* Check for overflow. */
+	if (check_overflow(p1, DPLL_P1_MASK, "PLL P1 parameter"))
+		return 1;
+	if (check_overflow(p2, DPLL_P2_MASK, "PLL P2 parameter"))
+		return 1;
+	if (check_overflow(m1, FP_DIVISOR_MASK, "PLL M1 parameter"))
+		return 1;
+	if (check_overflow(m2, FP_DIVISOR_MASK, "PLL M2 parameter"))
+		return 1;
+	if (check_overflow(n, FP_DIVISOR_MASK, "PLL N parameter"))
+		return 1;
+
+	*dpll &= ~DPLL_P1_FORCE_DIV2;
+	*dpll &= ~((DPLL_P2_MASK << DPLL_P2_SHIFT) |
+		   (DPLL_P1_MASK << DPLL_P1_SHIFT));
+	*dpll |= (p2 << DPLL_P2_SHIFT) | (p1 << DPLL_P1_SHIFT);
+	*fp0 = (n << FP_N_DIVISOR_SHIFT) |
+	       (m1 << FP_M1_DIVISOR_SHIFT) |
+	       (m2 << FP_M2_DIVISOR_SHIFT);
+	*fp1 = *fp0;
+
+	hw->dvob &= ~PORT_ENABLE;
+	hw->dvoc &= ~PORT_ENABLE;
+
+	/* Use display plane A. */
+	hw->disp_a_ctrl |= DISPPLANE_PLANE_ENABLE;
+	hw->disp_a_ctrl &= ~DISPPLANE_GAMMA_ENABLE;
+	hw->disp_a_ctrl &= ~DISPPLANE_PIXFORMAT_MASK;
+	switch (intelfb_var_to_depth(var)) {
+	case 8:
+		hw->disp_a_ctrl |= DISPPLANE_8BPP | DISPPLANE_GAMMA_ENABLE;
+		break;
+	case 15:
+		hw->disp_a_ctrl |= DISPPLANE_15_16BPP;
+		break;
+	case 16:
+		hw->disp_a_ctrl |= DISPPLANE_16BPP;
+		break;
+	case 24:
+		hw->disp_a_ctrl |= DISPPLANE_32BPP_NO_ALPHA;
+		break;
+	}
+	hw->disp_a_ctrl &= ~(PIPE_MASK << DISPPLANE_SEL_PIPE_SHIFT);
+	hw->disp_a_ctrl |= (pipe << DISPPLANE_SEL_PIPE_SHIFT);
+
+	/* Set CRTC registers. */
+	hactive = var->xres;
+	hsync_start = hactive + var->right_margin;
+	hsync_end = hsync_start + var->hsync_len;
+	htotal = hsync_end + var->left_margin;
+	hblank_start = hactive;
+	hblank_end = htotal;
+
+	DBG_MSG("H: act %d, ss %d, se %d, tot %d bs %d, be %d\n",
+		hactive, hsync_start, hsync_end, htotal, hblank_start,
+		hblank_end);
+
+	vactive = var->yres;
+	vsync_start = vactive + var->lower_margin;
+	vsync_end = vsync_start + var->vsync_len;
+	vtotal = vsync_end + var->upper_margin;
+	vblank_start = vactive;
+	vblank_end = vtotal;
+	vblank_end = vsync_end + 1;
+
+	DBG_MSG("V: act %d, ss %d, se %d, tot %d bs %d, be %d\n",
+		vactive, vsync_start, vsync_end, vtotal, vblank_start,
+		vblank_end);
+
+	/* Adjust for register values, and check for overflow. */
+	hactive--;
+	if (check_overflow(hactive, HACTIVE_MASK, "CRTC hactive"))
+		return 1;
+	hsync_start--;
+	if (check_overflow(hsync_start, HSYNCSTART_MASK, "CRTC hsync_start"))
+		return 1;
+	hsync_end--;
+	if (check_overflow(hsync_end, HSYNCEND_MASK, "CRTC hsync_end"))
+		return 1;
+	htotal--;
+	if (check_overflow(htotal, HTOTAL_MASK, "CRTC htotal"))
+		return 1;
+	hblank_start--;
+	if (check_overflow(hblank_start, HBLANKSTART_MASK, "CRTC hblank_start"))
+		return 1;
+	hblank_end--;
+	if (check_overflow(hblank_end, HBLANKEND_MASK, "CRTC hblank_end"))
+		return 1;
+
+	vactive--;
+	if (check_overflow(vactive, VACTIVE_MASK, "CRTC vactive"))
+		return 1;
+	vsync_start--;
+	if (check_overflow(vsync_start, VSYNCSTART_MASK, "CRTC vsync_start"))
+		return 1;
+	vsync_end--;
+	if (check_overflow(vsync_end, VSYNCEND_MASK, "CRTC vsync_end"))
+		return 1;
+	vtotal--;
+	if (check_overflow(vtotal, VTOTAL_MASK, "CRTC vtotal"))
+		return 1;
+	vblank_start--;
+	if (check_overflow(vblank_start, VBLANKSTART_MASK, "CRTC vblank_start"))
+		return 1;
+	vblank_end--;
+	if (check_overflow(vblank_end, VBLANKEND_MASK, "CRTC vblank_end"))
+		return 1;
+
+	*ht = (htotal << HTOTAL_SHIFT) | (hactive << HACTIVE_SHIFT);
+	*hb = (hblank_start << HBLANKSTART_SHIFT) |
+	      (hblank_end << HSYNCEND_SHIFT);
+	*hs = (hsync_start << HSYNCSTART_SHIFT) | (hsync_end << HSYNCEND_SHIFT);
+
+	*vt = (vtotal << VTOTAL_SHIFT) | (vactive << VACTIVE_SHIFT);
+	*vb = (vblank_start << VBLANKSTART_SHIFT) |
+	      (vblank_end << VSYNCEND_SHIFT);
+	*vs = (vsync_start << VSYNCSTART_SHIFT) | (vsync_end << VSYNCEND_SHIFT);
+	*ss = (hactive << SRC_SIZE_HORIZ_SHIFT) |
+	      (vactive << SRC_SIZE_VERT_SHIFT);
+
+	hw->disp_a_stride = var->xres_virtual * var->bits_per_pixel / 8;
+	DBG_MSG("pitch is %d\n", hw->disp_a_stride);
+
+	hw->disp_a_base = hw->disp_a_stride * var->yoffset +
+			  var->xoffset * var->bits_per_pixel / 8;
+
+	hw->disp_a_base += dinfo->fb.offset << 12;
+
+	/* Check stride alignment. */
+	if (hw->disp_a_stride % STRIDE_ALIGNMENT != 0) {
+		WRN_MSG("display stride %d has bad alignment %d\n",
+			hw->disp_a_stride, STRIDE_ALIGNMENT);
+		return 1;
+	}
+
+	/* Set the palette to 8-bit mode. */
+	*pipe_conf &= ~PIPECONF_GAMMA;
+	return 0;
+}
+
+/* Program a (non-VGA) video mode. */
+int
+intelfbhw_program_mode(struct intelfb_info *dinfo,
+		     const struct intelfb_hwstate *hw, int blank)
+{
+	int pipe = PIPE_A;
+	u32 tmp;
+	const u32 *dpll, *fp0, *fp1, *pipe_conf;
+	const u32 *hs, *ht, *hb, *vs, *vt, *vb, *ss;
+	u32 dpll_reg, fp0_reg, fp1_reg, pipe_conf_reg;
+	u32 hsync_reg, htotal_reg, hblank_reg;
+	u32 vsync_reg, vtotal_reg, vblank_reg;
+	u32 src_size_reg;
+
+	/* Assume single pipe, display plane A, analog CRT. */
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_program_mode\n");
+#endif
+
+	/* Disable VGA */
+	tmp = INREG(VGACNTRL);
+	tmp |= VGA_DISABLE;
+	OUTREG(VGACNTRL, tmp);
+
+	/* Check whether pipe A or pipe B is enabled. */
+	if (hw->pipe_a_conf & PIPECONF_ENABLE)
+		pipe = PIPE_A;
+	else if (hw->pipe_b_conf & PIPECONF_ENABLE)
+		pipe = PIPE_B;
+
+	dinfo->pipe = pipe;
+
+	if (pipe == PIPE_B) {
+		dpll = &hw->dpll_b;
+		fp0 = &hw->fpb0;
+		fp1 = &hw->fpb1;
+		pipe_conf = &hw->pipe_b_conf;
+		hs = &hw->hsync_b;
+		hb = &hw->hblank_b;
+		ht = &hw->htotal_b;
+		vs = &hw->vsync_b;
+		vb = &hw->vblank_b;
+		vt = &hw->vtotal_b;
+		ss = &hw->src_size_b;
+		dpll_reg = DPLL_B;
+		fp0_reg = FPB0;
+		fp1_reg = FPB1;
+		pipe_conf_reg = PIPEBCONF;
+		hsync_reg = HSYNC_B;
+		htotal_reg = HTOTAL_B;
+		hblank_reg = HBLANK_B;
+		vsync_reg = VSYNC_B;
+		vtotal_reg = VTOTAL_B;
+		vblank_reg = VBLANK_B;
+		src_size_reg = SRC_SIZE_B;
+	} else {
+		dpll = &hw->dpll_a;
+		fp0 = &hw->fpa0;
+		fp1 = &hw->fpa1;
+		pipe_conf = &hw->pipe_a_conf;
+		hs = &hw->hsync_a;
+		hb = &hw->hblank_a;
+		ht = &hw->htotal_a;
+		vs = &hw->vsync_a;
+		vb = &hw->vblank_a;
+		vt = &hw->vtotal_a;
+		ss = &hw->src_size_a;
+		dpll_reg = DPLL_A;
+		fp0_reg = FPA0;
+		fp1_reg = FPA1;
+		pipe_conf_reg = PIPEACONF;
+		hsync_reg = HSYNC_A;
+		htotal_reg = HTOTAL_A;
+		hblank_reg = HBLANK_A;
+		vsync_reg = VSYNC_A;
+		vtotal_reg = VTOTAL_A;
+		vblank_reg = VBLANK_A;
+		src_size_reg = SRC_SIZE_A;
+	}
+
+	/* Disable planes A and B. */
+	tmp = INREG(DSPACNTR);
+	tmp &= ~DISPPLANE_PLANE_ENABLE;
+	OUTREG(DSPACNTR, tmp);
+	tmp = INREG(DSPBCNTR);
+	tmp &= ~DISPPLANE_PLANE_ENABLE;
+	OUTREG(DSPBCNTR, tmp);
+
+	/* Wait for vblank.  For now, just wait for a 50Hz cycle (20ms)) */
+	mdelay(20);
+
+	/* Disable Sync */
+	tmp = INREG(ADPA);
+	tmp &= ~ADPA_DPMS_CONTROL_MASK;
+	tmp |= ADPA_DPMS_D3;
+	OUTREG(ADPA, tmp);
+
+	/* turn off pipe */
+	tmp = INREG(pipe_conf_reg);
+	tmp &= ~PIPECONF_ENABLE;
+	OUTREG(pipe_conf_reg, tmp);
+
+	/* turn off PLL */
+	tmp = INREG(dpll_reg);
+	dpll_reg &= ~DPLL_VCO_ENABLE;
+	OUTREG(dpll_reg, tmp);
+
+	/* Set PLL parameters */
+	OUTREG(dpll_reg, *dpll & ~DPLL_VCO_ENABLE);
+	OUTREG(fp0_reg, *fp0);
+	OUTREG(fp1_reg, *fp1);
+
+	/* Set pipe parameters */
+	OUTREG(hsync_reg, *hs);
+	OUTREG(hblank_reg, *hb);
+	OUTREG(htotal_reg, *ht);
+	OUTREG(vsync_reg, *vs);
+	OUTREG(vblank_reg, *vb);
+	OUTREG(vtotal_reg, *vt);
+	OUTREG(src_size_reg, *ss);
+
+	/* Set DVOs B/C */
+	OUTREG(DVOB, hw->dvob);
+	OUTREG(DVOC, hw->dvoc);
+
+	/* Set ADPA */
+	OUTREG(ADPA, (hw->adpa & ~(ADPA_DPMS_CONTROL_MASK)) | ADPA_DPMS_D3);
+
+	/* Enable PLL */
+	tmp = INREG(dpll_reg);
+	tmp |= DPLL_VCO_ENABLE;
+	OUTREG(dpll_reg, tmp);
+
+	/* Enable pipe */
+	OUTREG(pipe_conf_reg, *pipe_conf | PIPECONF_ENABLE);
+
+	/* Enable sync */
+	tmp = INREG(ADPA);
+	tmp &= ~ADPA_DPMS_CONTROL_MASK;
+	tmp |= ADPA_DPMS_D0;
+	OUTREG(ADPA, tmp);
+
+	/* setup display plane */
+	OUTREG(DSPACNTR, hw->disp_a_ctrl & ~DISPPLANE_PLANE_ENABLE);
+	OUTREG(DSPASTRIDE, hw->disp_a_stride);
+	OUTREG(DSPABASE, hw->disp_a_base);
+
+	/* Enable plane */
+	if (!blank) {
+		tmp = INREG(DSPACNTR);
+		tmp |= DISPPLANE_PLANE_ENABLE;
+		OUTREG(DSPACNTR, tmp);
+		OUTREG(DSPABASE, hw->disp_a_base);
+	}
+
+	return 0;
+}
+
+/* forward declarations */
+static void refresh_ring(struct intelfb_info *dinfo);
+static void reset_state(struct intelfb_info *dinfo);
+static void do_flush(struct intelfb_info *dinfo);
+
+static int
+wait_ring(struct intelfb_info *dinfo, int n)
+{
+	int i = 0;
+	unsigned long end;
+	u32 last_head = INREG(PRI_RING_HEAD) & RING_HEAD_MASK;
+
+#if VERBOSE > 0
+	DBG_MSG("wait_ring: %d\n", n);
+#endif
+
+	end = jiffies + (HZ * 3);
+	while (dinfo->ring_space < n) {
+		dinfo->ring_head = (u8 __iomem *)(INREG(PRI_RING_HEAD) &
+						   RING_HEAD_MASK);
+		if (dinfo->ring_tail + RING_MIN_FREE <
+		    (u32 __iomem) dinfo->ring_head)
+			dinfo->ring_space = (u32 __iomem) dinfo->ring_head
+				- (dinfo->ring_tail + RING_MIN_FREE);
+		else
+			dinfo->ring_space = (dinfo->ring.size +
+					     (u32 __iomem) dinfo->ring_head)
+				- (dinfo->ring_tail + RING_MIN_FREE);
+		if ((u32 __iomem) dinfo->ring_head != last_head) {
+			end = jiffies + (HZ * 3);
+			last_head = (u32 __iomem) dinfo->ring_head;
+		}
+		i++;
+		if (time_before(end, jiffies)) {
+			if (!i) {
+				/* Try again */
+				reset_state(dinfo);
+				refresh_ring(dinfo);
+				do_flush(dinfo);
+				end = jiffies + (HZ * 3);
+				i = 1;
+			} else {
+				WRN_MSG("ring buffer : space: %d wanted %d\n",
+					dinfo->ring_space, n);
+				WRN_MSG("lockup - turning off hardware "
+					"acceleration\n");
+				dinfo->ring_lockup = 1;
+				break;
+			}
+		}
+		udelay(1);
+	}
+	return i;
+}
+
+static void
+do_flush(struct intelfb_info *dinfo) {
+	START_RING(2);
+	OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE);
+	OUT_RING(MI_NOOP);
+	ADVANCE_RING();
+}
+
+void
+intelfbhw_do_sync(struct intelfb_info *dinfo)
+{
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_do_sync\n");
+#endif
+
+	if (!dinfo->accel)
+		return;
+
+	/*
+	 * Send a flush, then wait until the ring is empty.  This is what
+	 * the XFree86 driver does, and actually it doesn't seem a lot worse
+	 * than the recommended method (both have problems).
+	 */
+	do_flush(dinfo);
+	wait_ring(dinfo, dinfo->ring.size - RING_MIN_FREE);
+	dinfo->ring_space = dinfo->ring.size - RING_MIN_FREE;
+}
+
+static void
+refresh_ring(struct intelfb_info *dinfo)
+{
+#if VERBOSE > 0
+	DBG_MSG("refresh_ring\n");
+#endif
+
+	dinfo->ring_head = (u8 __iomem *) (INREG(PRI_RING_HEAD) &
+					   RING_HEAD_MASK);
+	dinfo->ring_tail = INREG(PRI_RING_TAIL) & RING_TAIL_MASK;
+	if (dinfo->ring_tail + RING_MIN_FREE < (u32 __iomem)dinfo->ring_head)
+		dinfo->ring_space = (u32 __iomem) dinfo->ring_head
+			- (dinfo->ring_tail + RING_MIN_FREE);
+	else
+		dinfo->ring_space = (dinfo->ring.size +
+				     (u32 __iomem) dinfo->ring_head)
+			- (dinfo->ring_tail + RING_MIN_FREE);
+}
+
+static void
+reset_state(struct intelfb_info *dinfo)
+{
+	int i;
+	u32 tmp;
+
+#if VERBOSE > 0
+	DBG_MSG("reset_state\n");
+#endif
+
+	for (i = 0; i < FENCE_NUM; i++)
+		OUTREG(FENCE + (i << 2), 0);
+
+	/* Flush the ring buffer if it's enabled. */
+	tmp = INREG(PRI_RING_LENGTH);
+	if (tmp & RING_ENABLE) {
+#if VERBOSE > 0
+		DBG_MSG("reset_state: ring was enabled\n");
+#endif
+		refresh_ring(dinfo);
+		intelfbhw_do_sync(dinfo);
+		DO_RING_IDLE();
+	}
+
+	OUTREG(PRI_RING_LENGTH, 0);
+	OUTREG(PRI_RING_HEAD, 0);
+	OUTREG(PRI_RING_TAIL, 0);
+	OUTREG(PRI_RING_START, 0);
+}
+
+/* Stop the 2D engine, and turn off the ring buffer. */
+void
+intelfbhw_2d_stop(struct intelfb_info *dinfo)
+{
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_2d_stop: accel: %d, ring_active: %d\n", dinfo->accel,
+		dinfo->ring_active);
+#endif
+
+	if (!dinfo->accel)
+		return;
+
+	dinfo->ring_active = 0;
+	reset_state(dinfo);
+}
+
+/*
+ * Enable the ring buffer, and initialise the 2D engine.
+ * It is assumed that the graphics engine has been stopped by previously
+ * calling intelfb_2d_stop().
+ */
+void
+intelfbhw_2d_start(struct intelfb_info *dinfo)
+{
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_2d_start: accel: %d, ring_active: %d\n",
+		dinfo->accel, dinfo->ring_active);
+#endif
+
+	if (!dinfo->accel)
+		return;
+
+	/* Initialise the primary ring buffer. */
+	OUTREG(PRI_RING_LENGTH, 0);
+	OUTREG(PRI_RING_TAIL, 0);
+	OUTREG(PRI_RING_HEAD, 0);
+
+	OUTREG(PRI_RING_START, dinfo->ring.physical & RING_START_MASK);
+	OUTREG(PRI_RING_LENGTH,
+		((dinfo->ring.size - GTT_PAGE_SIZE) & RING_LENGTH_MASK) |
+		RING_NO_REPORT | RING_ENABLE);
+	refresh_ring(dinfo);
+	dinfo->ring_active = 1;
+}
+
+/* 2D fillrect (solid fill or invert) */
+void
+intelfbhw_do_fillrect(struct intelfb_info *dinfo, u32 x, u32 y, u32 w, u32 h,
+		      u32 color, u32 pitch, u32 bpp, u32 rop)
+{
+	u32 br00, br09, br13, br14, br16;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_do_fillrect: (%d,%d) %dx%d, c 0x%06x, p %d bpp %d, "
+		"rop 0x%02x\n", x, y, w, h, color, pitch, bpp, rop);
+#endif
+
+	br00 = COLOR_BLT_CMD;
+	br09 = dinfo->fb_start + (y * pitch + x * (bpp / 8));
+	br13 = (rop << ROP_SHIFT) | pitch;
+	br14 = (h << HEIGHT_SHIFT) | ((w * (bpp / 8)) << WIDTH_SHIFT);
+	br16 = color;
+
+	switch (bpp) {
+	case 8:
+		br13 |= COLOR_DEPTH_8;
+		break;
+	case 16:
+		br13 |= COLOR_DEPTH_16;
+		break;
+	case 32:
+		br13 |= COLOR_DEPTH_32;
+		br00 |= WRITE_ALPHA | WRITE_RGB;
+		break;
+	}
+
+	START_RING(6);
+	OUT_RING(br00);
+	OUT_RING(br13);
+	OUT_RING(br14);
+	OUT_RING(br09);
+	OUT_RING(br16);
+	OUT_RING(MI_NOOP);
+	ADVANCE_RING();
+
+#if VERBOSE > 0
+	DBG_MSG("ring = 0x%08x, 0x%08x (%d)\n", dinfo->ring_head,
+		dinfo->ring_tail, dinfo->ring_space);
+#endif
+}
+
+void
+intelfbhw_do_bitblt(struct intelfb_info *dinfo, u32 curx, u32 cury,
+		    u32 dstx, u32 dsty, u32 w, u32 h, u32 pitch, u32 bpp)
+{
+	u32 br00, br09, br11, br12, br13, br22, br23, br26;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_do_bitblt: (%d,%d)->(%d,%d) %dx%d, p %d bpp %d\n",
+		curx, cury, dstx, dsty, w, h, pitch, bpp);
+#endif
+
+	br00 = XY_SRC_COPY_BLT_CMD;
+	br09 = dinfo->fb_start;
+	br11 = (pitch << PITCH_SHIFT);
+	br12 = dinfo->fb_start;
+	br13 = (SRC_ROP_GXCOPY << ROP_SHIFT) | (pitch << PITCH_SHIFT);
+	br22 = (dstx << WIDTH_SHIFT) | (dsty << HEIGHT_SHIFT);
+	br23 = ((dstx + w) << WIDTH_SHIFT) |
+	       ((dsty + h) << HEIGHT_SHIFT);
+	br26 = (curx << WIDTH_SHIFT) | (cury << HEIGHT_SHIFT);
+
+	switch (bpp) {
+	case 8:
+		br13 |= COLOR_DEPTH_8;
+		break;
+	case 16:
+		br13 |= COLOR_DEPTH_16;
+		break;
+	case 32:
+		br13 |= COLOR_DEPTH_32;
+		br00 |= WRITE_ALPHA | WRITE_RGB;
+		break;
+	}
+
+	START_RING(8);
+	OUT_RING(br00);
+	OUT_RING(br13);
+	OUT_RING(br22);
+	OUT_RING(br23);
+	OUT_RING(br09);
+	OUT_RING(br26);
+	OUT_RING(br11);
+	OUT_RING(br12);
+	ADVANCE_RING();
+}
+
+int
+intelfbhw_do_drawglyph(struct intelfb_info *dinfo, u32 fg, u32 bg, u32 w,
+		       u32 h, const u8* cdat, u32 x, u32 y, u32 pitch, u32 bpp)
+{
+	int nbytes, ndwords, pad, tmp;
+	u32 br00, br09, br13, br18, br19, br22, br23;
+	int dat, ix, iy, iw;
+	int i, j;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_do_drawglyph: (%d,%d) %dx%d\n", x, y, w, h);
+#endif
+
+	/* size in bytes of a padded scanline */
+	nbytes = ROUND_UP_TO(w, 16) / 8;
+
+	/* Total bytes of padded scanline data to write out. */
+	nbytes = nbytes * h;
+
+	/*
+	 * Check if the glyph data exceeds the immediate mode limit.
+	 * It would take a large font (1K pixels) to hit this limit.
+	 */
+	if (nbytes > MAX_MONO_IMM_SIZE)
+		return 0;
+
+	/* Src data is packaged a dword (32-bit) at a time. */
+	ndwords = ROUND_UP_TO(nbytes, 4) / 4;
+
+	/*
+	 * Ring has to be padded to a quad word. But because the command starts
+	   with 7 bytes, pad only if there is an even number of ndwords
+	 */
+	pad = !(ndwords % 2);
+
+	tmp = (XY_MONO_SRC_IMM_BLT_CMD & DW_LENGTH_MASK) + ndwords;
+	br00 = (XY_MONO_SRC_IMM_BLT_CMD & ~DW_LENGTH_MASK) | tmp;
+	br09 = dinfo->fb_start;
+	br13 = (SRC_ROP_GXCOPY << ROP_SHIFT) | (pitch << PITCH_SHIFT);
+	br18 = bg;
+	br19 = fg;
+	br22 = (x << WIDTH_SHIFT) | (y << HEIGHT_SHIFT);
+	br23 = ((x + w) << WIDTH_SHIFT) | ((y + h) << HEIGHT_SHIFT);
+
+	switch (bpp) {
+	case 8:
+		br13 |= COLOR_DEPTH_8;
+		break;
+	case 16:
+		br13 |= COLOR_DEPTH_16;
+		break;
+	case 32:
+		br13 |= COLOR_DEPTH_32;
+		br00 |= WRITE_ALPHA | WRITE_RGB;
+		break;
+	}
+
+	START_RING(8 + ndwords);
+	OUT_RING(br00);
+	OUT_RING(br13);
+	OUT_RING(br22);
+	OUT_RING(br23);
+	OUT_RING(br09);
+	OUT_RING(br18);
+	OUT_RING(br19);
+	ix = iy = 0;
+	iw = ROUND_UP_TO(w, 8) / 8;
+	while (ndwords--) {
+		dat = 0;
+		for (j = 0; j < 2; ++j) {
+			for (i = 0; i < 2; ++i) {
+				if (ix != iw || i == 0)
+					dat |= cdat[iy*iw + ix++] << (i+j*2)*8;
+			}
+			if (ix == iw && iy != (h-1)) {
+				ix = 0;
+				++iy;
+			}
+		}
+		OUT_RING(dat);
+	}
+	if (pad)
+		OUT_RING(MI_NOOP);
+	ADVANCE_RING();
+
+	return 1;
+}
+
+/* HW cursor functions. */
+void
+intelfbhw_cursor_init(struct intelfb_info *dinfo)
+{
+	u32 tmp;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_cursor_init\n");
+#endif
+
+	if (dinfo->mobile) {
+		if (!dinfo->cursor.physical)
+			return;
+		tmp = INREG(CURSOR_A_CONTROL);
+		tmp &= ~(CURSOR_MODE_MASK | CURSOR_MOBILE_GAMMA_ENABLE |
+			 CURSOR_MEM_TYPE_LOCAL |
+			 (1 << CURSOR_PIPE_SELECT_SHIFT));
+		tmp |= CURSOR_MODE_DISABLE;
+		OUTREG(CURSOR_A_CONTROL, tmp);
+		OUTREG(CURSOR_A_BASEADDR, dinfo->cursor.physical);
+	} else {
+		tmp = INREG(CURSOR_CONTROL);
+		tmp &= ~(CURSOR_FORMAT_MASK | CURSOR_GAMMA_ENABLE |
+			 CURSOR_ENABLE | CURSOR_STRIDE_MASK);
+		tmp = CURSOR_FORMAT_3C;
+		OUTREG(CURSOR_CONTROL, tmp);
+		OUTREG(CURSOR_A_BASEADDR, dinfo->cursor.offset << 12);
+		tmp = (64 << CURSOR_SIZE_H_SHIFT) |
+		      (64 << CURSOR_SIZE_V_SHIFT);
+		OUTREG(CURSOR_SIZE, tmp);
+	}
+}
+
+void
+intelfbhw_cursor_hide(struct intelfb_info *dinfo)
+{
+	u32 tmp;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_cursor_hide\n");
+#endif
+
+	dinfo->cursor_on = 0;
+	if (dinfo->mobile) {
+		if (!dinfo->cursor.physical)
+			return;
+		tmp = INREG(CURSOR_A_CONTROL);
+		tmp &= ~CURSOR_MODE_MASK;
+		tmp |= CURSOR_MODE_DISABLE;
+		OUTREG(CURSOR_A_CONTROL, tmp);
+		/* Flush changes */
+		OUTREG(CURSOR_A_BASEADDR, dinfo->cursor.physical);
+	} else {
+		tmp = INREG(CURSOR_CONTROL);
+		tmp &= ~CURSOR_ENABLE;
+		OUTREG(CURSOR_CONTROL, tmp);
+	}
+}
+
+void
+intelfbhw_cursor_show(struct intelfb_info *dinfo)
+{
+	u32 tmp;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_cursor_show\n");
+#endif
+
+	dinfo->cursor_on = 1;
+
+	if (dinfo->cursor_blanked)
+		return;
+
+	if (dinfo->mobile) {
+		if (!dinfo->cursor.physical)
+			return;
+		tmp = INREG(CURSOR_A_CONTROL);
+		tmp &= ~CURSOR_MODE_MASK;
+		tmp |= CURSOR_MODE_64_4C_AX;
+		OUTREG(CURSOR_A_CONTROL, tmp);
+		/* Flush changes */
+		OUTREG(CURSOR_A_BASEADDR, dinfo->cursor.physical);
+	} else {
+		tmp = INREG(CURSOR_CONTROL);
+		tmp |= CURSOR_ENABLE;
+		OUTREG(CURSOR_CONTROL, tmp);
+	}
+}
+
+void
+intelfbhw_cursor_setpos(struct intelfb_info *dinfo, int x, int y)
+{
+	u32 tmp;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_cursor_setpos: (%d, %d)\n", x, y);
+#endif
+
+	/*
+	 * Sets the position.  The coordinates are assumed to already
+	 * have any offset adjusted.  Assume that the cursor is never
+	 * completely off-screen, and that x, y are always >= 0.
+	 */
+
+	tmp = ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT) |
+	      ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT);
+	OUTREG(CURSOR_A_POSITION, tmp);
+}
+
+void
+intelfbhw_cursor_setcolor(struct intelfb_info *dinfo, u32 bg, u32 fg)
+{
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_cursor_setcolor\n");
+#endif
+
+	OUTREG(CURSOR_A_PALETTE0, bg & CURSOR_PALETTE_MASK);
+	OUTREG(CURSOR_A_PALETTE1, fg & CURSOR_PALETTE_MASK);
+	OUTREG(CURSOR_A_PALETTE2, fg & CURSOR_PALETTE_MASK);
+	OUTREG(CURSOR_A_PALETTE3, bg & CURSOR_PALETTE_MASK);
+}
+
+void
+intelfbhw_cursor_load(struct intelfb_info *dinfo, int width, int height,
+		      u8 *data)
+{
+	u8 __iomem *addr = (u8 __iomem *)dinfo->cursor.virtual;
+	int i, j, w = width / 8;
+	int mod = width % 8, t_mask, d_mask;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_cursor_load\n");
+#endif
+
+	if (!dinfo->cursor.virtual)
+		return;
+
+	t_mask = 0xff >> mod;
+	d_mask = ~(0xff >> mod);
+	for (i = height; i--; ) {
+		for (j = 0; j < w; j++) {
+			writeb(0x00, addr + j);
+			writeb(*(data++), addr + j+8);
+		}
+		if (mod) {
+			writeb(t_mask, addr + j);
+			writeb(*(data++) & d_mask, addr + j+8);
+		}
+		addr += 16;
+	}
+}
+
+void
+intelfbhw_cursor_reset(struct intelfb_info *dinfo) {
+	u8 __iomem *addr = (u8 __iomem *)dinfo->cursor.virtual;
+	int i, j;
+
+#if VERBOSE > 0
+	DBG_MSG("intelfbhw_cursor_reset\n");
+#endif
+
+	if (!dinfo->cursor.virtual)
+		return;
+
+	for (i = 64; i--; ) {
+		for (j = 0; j < 8; j++) {
+			writeb(0xff, addr + j+0);
+			writeb(0x00, addr + j+8);
+		}
+		addr += 16;
+	}
+}
diff -Nru a/drivers/video/intelfb/intelfbhw.h b/drivers/video/intelfb/intelfbhw.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/intelfb/intelfbhw.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,567 @@
+#ifndef _INTELFBHW_H
+#define _INTELFBHW_H
+
+/* $DHD: intelfb/intelfbhw.h,v 1.5 2003/06/27 15:06:25 dawes Exp $ */
+
+
+/*** HW-specific data ***/
+
+/* Information about the 852GM/855GM variants */
+#define INTEL_85X_CAPID		0x44
+#define INTEL_85X_VARIANT_MASK		0x7
+#define INTEL_85X_VARIANT_SHIFT		5
+#define INTEL_VAR_855GME		0x0
+#define INTEL_VAR_855GM			0x4
+#define INTEL_VAR_852GME		0x2
+#define INTEL_VAR_852GM			0x5
+
+/* Information about DVO/LVDS Ports */
+#define DVOA_PORT  0x1
+#define DVOB_PORT  0x2
+#define DVOC_PORT  0x4
+#define LVDS_PORT  0x8
+
+/*
+ * The Bridge device's PCI config space has information about the
+ * fb aperture size and the amount of pre-reserved memory.
+ */
+#define INTEL_GMCH_CTRL		0x52
+#define INTEL_GMCH_ENABLED		0x4
+#define INTEL_GMCH_MEM_MASK		0x1
+#define INTEL_GMCH_MEM_64M		0x1
+#define INTEL_GMCH_MEM_128M		0
+
+#define INTEL_830_GMCH_GMS_MASK		(0x7 << 4)
+#define INTEL_830_GMCH_GMS_DISABLED	(0x0 << 4)
+#define INTEL_830_GMCH_GMS_LOCAL	(0x1 << 4)
+#define INTEL_830_GMCH_GMS_STOLEN_512	(0x2 << 4)
+#define INTEL_830_GMCH_GMS_STOLEN_1024	(0x3 << 4)
+#define INTEL_830_GMCH_GMS_STOLEN_8192	(0x4 << 4)
+
+#define INTEL_855_GMCH_GMS_MASK		(0x7 << 4)
+#define INTEL_855_GMCH_GMS_DISABLED	(0x0 << 4)
+#define INTEL_855_GMCH_GMS_STOLEN_1M	(0x1 << 4)
+#define INTEL_855_GMCH_GMS_STOLEN_4M	(0x2 << 4)
+#define INTEL_855_GMCH_GMS_STOLEN_8M	(0x3 << 4)
+#define INTEL_855_GMCH_GMS_STOLEN_16M	(0x4 << 4)
+#define INTEL_855_GMCH_GMS_STOLEN_32M	(0x5 << 4)
+
+/* HW registers */
+
+/* Fence registers */
+#define FENCE			0x2000
+#define FENCE_NUM			8
+
+/* Primary ring buffer */
+#define PRI_RING_TAIL		0x2030
+#define RING_TAIL_MASK			0x001ffff8
+#define RING_INUSE			0x1
+
+#define PRI_RING_HEAD		0x2034
+#define RING_HEAD_WRAP_MASK		0x7ff
+#define RING_HEAD_WRAP_SHIFT		21
+#define RING_HEAD_MASK			0x001ffffc
+
+#define PRI_RING_START		0x2038
+#define RING_START_MASK			0xfffff000
+
+#define PRI_RING_LENGTH		0x203c
+#define RING_LENGTH_MASK		0x001ff000
+#define RING_REPORT_MASK		(0x3 << 1)
+#define RING_NO_REPORT			(0x0 << 1)
+#define RING_REPORT_64K			(0x1 << 1)
+#define RING_REPORT_4K			(0x2 << 1)
+#define RING_REPORT_128K		(0x3 << 1)
+#define RING_ENABLE			0x1
+
+/*
+ * Tail can't wrap to any closer than RING_MIN_FREE bytes of the head,
+ * and the last RING_MIN_FREE bytes need to be padded with MI_NOOP
+ */
+#define RING_MIN_FREE			64
+
+#define IPEHR     		0x2088
+
+#define INSTDONE		0x2090
+#define PRI_RING_EMPTY			1
+
+#define INSTPM			0x20c0
+#define SYNC_FLUSH_ENABLE		(1 << 5)
+
+#define INSTPS			0x20c4
+
+#define MEM_MODE		0x20cc
+
+#define MASK_SHIFT			16
+
+#define FW_BLC_0		0x20d8
+#define FW_DISPA_WM_SHIFT		0
+#define FW_DISPA_WM_MASK		0x3f
+#define FW_DISPA_BL_SHIFT		8
+#define FW_DISPA_BL_MASK		0xf
+#define FW_DISPB_WM_SHIFT		16
+#define FW_DISPB_WM_MASK		0x1f
+#define FW_DISPB_BL_SHIFT		24
+#define FW_DISPB_BL_MASK		0x7
+
+#define FW_BLC_1		0x20dc
+#define FW_DISPC_WM_SHIFT		0
+#define FW_DISPC_WM_MASK		0x1f
+#define FW_DISPC_BL_SHIFT		8
+#define FW_DISPC_BL_MASK		0x7
+
+
+/* PLL registers */
+#define VGA0_DIVISOR		0x06000
+#define VGA1_DIVISOR		0x06004
+#define VGAPD			0x06010
+#define VGAPD_0_P1_SHIFT		0
+#define VGAPD_0_P1_FORCE_DIV2		(1 << 5)
+#define VGAPD_0_P2_SHIFT		7
+#define VGAPD_1_P1_SHIFT		8
+#define VGAPD_1_P1_FORCE_DIV2		(1 << 13)
+#define VGAPD_1_P2_SHIFT		15
+
+#define DPLL_A			0x06014
+#define DPLL_B			0x06018
+#define DPLL_VCO_ENABLE			(1 << 31)
+#define DPLL_2X_CLOCK_ENABLE		(1 << 30)
+#define DPLL_SYNCLOCK_ENABLE		(1 << 29)
+#define DPLL_VGA_MODE_DISABLE		(1 << 28)
+#define DPLL_P2_MASK			1
+#define DPLL_P2_SHIFT			23
+#define DPLL_P1_FORCE_DIV2		(1 << 21)
+#define DPLL_P1_MASK			0x1f
+#define DPLL_P1_SHIFT			16
+#define DPLL_REFERENCE_SELECT_MASK	(0x3 << 13)
+#define DPLL_REFERENCE_DEFAULT		(0x0 << 13)
+#define DPLL_REFERENCE_TVCLK		(0x2 << 13)
+#define DPLL_RATE_SELECT_MASK		(1 << 8)
+#define DPLL_RATE_SELECT_FP0		(0 << 8)
+#define DPLL_RATE_SELECT_FP1		(1 << 8)
+
+#define FPA0			0x06040
+#define FPA1			0x06044
+#define FPB0			0x06048
+#define FPB1			0x0604c
+#define FP_DIVISOR_MASK			0x3f
+#define FP_N_DIVISOR_SHIFT		16
+#define FP_M1_DIVISOR_SHIFT		8
+#define FP_M2_DIVISOR_SHIFT		0
+
+/* PLL parameters (these are for 852GM/855GM/865G, check earlier chips). */
+/* Clock values are in units of kHz */
+#define PLL_REFCLK		48000
+#define MIN_VCO_FREQ		930000
+#define MAX_VCO_FREQ		1400000
+#define MIN_CLOCK		25000
+#define MAX_CLOCK		350000
+#define P_TRANSITION_CLOCK	165000
+#define MIN_M			108
+#define MAX_M			140
+#define MIN_M1			18
+#define MAX_M1			26
+#define MIN_M2			6
+#define MAX_M2			16
+#define MIN_P			4
+#define MAX_P			128
+#define MIN_P1			0
+#define MAX_P1			31
+#define MIN_N			3
+#define MAX_N			16
+
+#define CALC_VCLOCK(m1, m2, n, p1, p2) \
+        ((PLL_REFCLK * (5 * ((m1) + 2) + ((m2) + 2)) / ((n) + 2)) / \
+        (((p1) + 2) * (1 << (p2 + 1))))
+
+#define CALC_VCLOCK3(m, n, p)	((PLL_REFCLK * (m) / (n)) / (p))
+
+/* Two pipes */
+#define PIPE_A			0
+#define PIPE_B			1
+#define PIPE_MASK		1
+
+/* palette registers */
+#define PALETTE_A		0x0a000
+#define PALETTE_B		0x0a800
+#ifndef PALETTE_8_ENTRIES
+#define PALETTE_8_ENTRIES		256
+#endif
+#define PALETTE_8_SIZE			(PALETTE_8_ENTRIES * 4)
+#define PALETTE_10_ENTRIES		128
+#define PALETTE_10_SIZE			(PALETTE_10_ENTRIES * 8)
+#define PALETTE_8_MASK			0xff
+#define PALETTE_8_RED_SHIFT		16
+#define PALETTE_8_GREEN_SHIFT		8
+#define PALETTE_8_BLUE_SHIFT		0
+
+/* CRTC registers */
+#define HTOTAL_A		0x60000
+#define HBLANK_A		0x60004
+#define HSYNC_A			0x60008
+#define VTOTAL_A		0x6000c
+#define VBLANK_A		0x60010
+#define VSYNC_A			0x60014
+#define SRC_SIZE_A		0x6001c
+#define BCLRPAT_A		0x60020
+
+#define HTOTAL_B		0x61000
+#define HBLANK_B		0x61004
+#define HSYNC_B			0x61008
+#define VTOTAL_B		0x6100c
+#define VBLANK_B		0x61010
+#define VSYNC_B			0x61014
+#define SRC_SIZE_B		0x6101c
+#define BCLRPAT_B		0x61020
+
+#define HTOTAL_MASK			0xfff
+#define HTOTAL_SHIFT			16
+#define HACTIVE_MASK			0x7ff
+#define HACTIVE_SHIFT			0
+#define HBLANKEND_MASK			0xfff
+#define HBLANKEND_SHIFT			16
+#define HBLANKSTART_MASK		0xfff
+#define HBLANKSTART_SHIFT		0
+#define HSYNCEND_MASK			0xfff
+#define HSYNCEND_SHIFT			16
+#define HSYNCSTART_MASK			0xfff
+#define HSYNCSTART_SHIFT		0
+#define VTOTAL_MASK			0xfff
+#define VTOTAL_SHIFT			16
+#define VACTIVE_MASK			0x7ff
+#define VACTIVE_SHIFT			0
+#define VBLANKEND_MASK			0xfff
+#define VBLANKEND_SHIFT			16
+#define VBLANKSTART_MASK		0xfff
+#define VBLANKSTART_SHIFT		0
+#define VSYNCEND_MASK			0xfff
+#define VSYNCEND_SHIFT			16
+#define VSYNCSTART_MASK			0xfff
+#define VSYNCSTART_SHIFT		0
+#define SRC_SIZE_HORIZ_MASK		0x7ff
+#define SRC_SIZE_HORIZ_SHIFT		16
+#define SRC_SIZE_VERT_MASK		0x7ff
+#define SRC_SIZE_VERT_SHIFT		0
+
+#define ADPA			0x61100
+#define ADPA_DAC_ENABLE			(1 << 31)
+#define ADPA_DAC_DISABLE		0
+#define ADPA_PIPE_SELECT_SHIFT		30
+#define ADPA_USE_VGA_HVPOLARITY		(1 << 15)
+#define ADPA_SETS_HVPOLARITY		0
+#define ADPA_DPMS_CONTROL_MASK		(0x3 << 10)
+#define ADPA_DPMS_D0			(0x0 << 10)
+#define ADPA_DPMS_D2			(0x1 << 10)
+#define ADPA_DPMS_D1			(0x2 << 10)
+#define ADPA_DPMS_D3			(0x3 << 10)
+#define ADPA_VSYNC_ACTIVE_SHIFT		4
+#define ADPA_HSYNC_ACTIVE_SHIFT		3
+#define ADPA_SYNC_ACTIVE_MASK		1
+#define ADPA_SYNC_ACTIVE_HIGH		1
+#define ADPA_SYNC_ACTIVE_LOW		0
+
+#define DVOA			0x61120
+#define DVOB			0x61140
+#define DVOC			0x61160
+#define LVDS			0x61180
+#define PORT_ENABLE		        (1 << 31)
+#define PORT_PIPE_SELECT_SHIFT	        30
+#define PORT_TV_FLAGS_MASK              0xFF
+#define PORT_TV_FLAGS                   0xC4  // ripped from my BIOS
+                                              // to understand and correct
+
+#define DVOA_SRCDIM		0x61124
+#define DVOB_SRCDIM		0x61144
+#define DVOC_SRCDIM		0x61164
+
+#define PIPEACONF		0x70008
+#define PIPEBCONF		0x71008
+#define PIPECONF_ENABLE			(1 << 31)
+#define PIPECONF_DISABLE		0
+#define PIPECONF_DOUBLE_WIDE		(1 << 30)
+#define PIPECONF_SINGLE_WIDE		0
+#define PIPECONF_LOCKED			(1 << 25)
+#define PIPECONF_UNLOCKED		0
+#define PIPECONF_GAMMA			(1 << 24)
+#define PIPECONF_PALETTE		0
+
+#define DISPARB			0x70030
+#define DISPARB_AEND_MASK		0x1ff
+#define DISPARB_AEND_SHIFT		0
+#define DISPARB_BEND_MASK		0x3ff
+#define DISPARB_BEND_SHIFT		9
+
+/* Desktop HW cursor */
+#define CURSOR_CONTROL		0x70080
+#define CURSOR_ENABLE			(1 << 31)
+#define CURSOR_GAMMA_ENABLE		(1 << 30)
+#define CURSOR_STRIDE_MASK		(0x3 << 28)
+#define CURSOR_STRIDE_256		(0x0 << 28)
+#define CURSOR_STRIDE_512		(0x1 << 28)
+#define CURSOR_STRIDE_1K		(0x2 << 28)
+#define CURSOR_STRIDE_2K		(0x3 << 28)
+#define CURSOR_FORMAT_MASK		(0x7 << 24)
+#define CURSOR_FORMAT_2C		(0x0 << 24)
+#define CURSOR_FORMAT_3C		(0x1 << 24)
+#define CURSOR_FORMAT_4C		(0x2 << 24)
+#define CURSOR_FORMAT_ARGB		(0x4 << 24)
+#define CURSOR_FORMAT_XRGB		(0x5 << 24)
+
+/* Mobile HW cursor (and i810) */
+#define CURSOR_A_CONTROL	CURSOR_CONTROL
+#define CURSOR_B_CONTROL	0x700c0
+#define CURSOR_MODE_MASK		0x27
+#define CURSOR_MODE_DISABLE		0
+#define CURSOR_MODE_64_3C		0x04
+#define CURSOR_MODE_64_4C_AX		0x05
+#define CURSOR_MODE_64_4C		0x06
+#define CURSOR_MODE_64_32B_AX		0x07
+#define CURSOR_MODE_64_ARGB_AX		0x27
+#define CURSOR_PIPE_SELECT_SHIFT	28
+#define CURSOR_MOBILE_GAMMA_ENABLE	(1 << 26)
+#define CURSOR_MEM_TYPE_LOCAL		(1 << 25)
+
+/* All platforms (desktop has no pipe B) */
+#define CURSOR_A_BASEADDR	0x70084
+#define CURSOR_B_BASEADDR	0x700c4
+#define CURSOR_BASE_MASK		0xffffff00
+
+#define CURSOR_A_POSITION	0x70088
+#define CURSOR_B_POSITION	0x700c8
+#define CURSOR_POS_SIGN			(1 << 15)
+#define CURSOR_POS_MASK			0x7ff
+#define CURSOR_X_SHIFT			0
+#define CURSOR_Y_SHIFT			16
+
+#define CURSOR_A_PALETTE0	0x70090
+#define CURSOR_A_PALETTE1	0x70094
+#define CURSOR_A_PALETTE2	0x70098
+#define CURSOR_A_PALETTE3	0x7009c
+#define CURSOR_B_PALETTE0	0x700d0
+#define CURSOR_B_PALETTE1	0x700d4
+#define CURSOR_B_PALETTE2	0x700d8
+#define CURSOR_B_PALETTE3	0x700dc
+#define CURSOR_COLOR_MASK			0xff
+#define CURSOR_RED_SHIFT			16
+#define CURSOR_GREEN_SHIFT			8
+#define CURSOR_BLUE_SHIFT			0
+#define CURSOR_PALETTE_MASK			0xffffff
+
+/* Desktop only */
+#define CURSOR_SIZE		0x700a0
+#define CURSOR_SIZE_MASK		0x3ff
+#define CURSOR_SIZE_H_SHIFT		0
+#define CURSOR_SIZE_V_SHIFT		12
+
+#define DSPACNTR		0x70180
+#define DSPBCNTR		0x71180
+#define DISPPLANE_PLANE_ENABLE		(1 << 31)
+#define DISPPLANE_PLANE_DISABLE		0
+#define DISPPLANE_GAMMA_ENABLE		(1<<30)
+#define DISPPLANE_GAMMA_DISABLE		0
+#define DISPPLANE_PIXFORMAT_MASK	(0xf<<26)
+#define DISPPLANE_8BPP			(0x2<<26)
+#define DISPPLANE_15_16BPP		(0x4<<26)
+#define DISPPLANE_16BPP			(0x5<<26)
+#define DISPPLANE_32BPP_NO_ALPHA 	(0x6<<26)
+#define DISPPLANE_32BPP			(0x7<<26)
+#define DISPPLANE_STEREO_ENABLE		(1<<25)
+#define DISPPLANE_STEREO_DISABLE	0
+#define DISPPLANE_SEL_PIPE_SHIFT	24
+#define DISPPLANE_SRC_KEY_ENABLE	(1<<22)
+#define DISPPLANE_SRC_KEY_DISABLE	0
+#define DISPPLANE_LINE_DOUBLE		(1<<20)
+#define DISPPLANE_NO_LINE_DOUBLE	0
+#define DISPPLANE_STEREO_POLARITY_FIRST	0
+#define DISPPLANE_STEREO_POLARITY_SECOND (1<<18)
+/* plane B only */
+#define DISPPLANE_ALPHA_TRANS_ENABLE	(1<<15)
+#define DISPPLANE_ALPHA_TRANS_DISABLE	0
+#define DISPPLANE_SPRITE_ABOVE_DISPLAYA	0
+#define DISPPLANE_SPRITE_ABOVE_OVERLAY	1
+
+#define DSPABASE		0x70184
+#define DSPASTRIDE		0x70188
+
+#define DSPBBASE		0x71184
+#define DSPBSTRIDE		0x71188
+
+#define VGACNTRL		0x71400
+#define VGA_DISABLE			(1 << 31)
+#define VGA_ENABLE			0
+#define VGA_PIPE_SELECT_SHIFT		29
+#define VGA_PALETTE_READ_SELECT		23
+#define VGA_PALETTE_A_WRITE_DISABLE	(1 << 22)
+#define VGA_PALETTE_B_WRITE_DISABLE	(1 << 21)
+#define VGA_LEGACY_PALETTE		(1 << 20)
+#define VGA_6BIT_DAC			0
+#define VGA_8BIT_DAC			(1 << 20)
+
+#define ADD_ID			0x71408
+#define ADD_ID_MASK			0xff
+
+/* BIOS scratch area registers (830M and 845G). */
+#define SWF0			0x71410
+#define SWF1			0x71414
+#define SWF2			0x71418
+#define SWF3			0x7141c
+#define SWF4			0x71420
+#define SWF5			0x71424
+#define SWF6			0x71428
+
+/* BIOS scratch area registers (852GM, 855GM, 865G). */
+#define SWF00			0x70410
+#define SWF01			0x70414
+#define SWF02			0x70418
+#define SWF03			0x7041c
+#define SWF04			0x70420
+#define SWF05			0x70424
+#define SWF06			0x70428
+
+#define SWF10			SWF0
+#define SWF11			SWF1
+#define SWF12			SWF2
+#define SWF13			SWF3
+#define SWF14			SWF4
+#define SWF15			SWF5
+#define SWF16			SWF6
+
+#define SWF30			0x72414
+#define SWF31			0x72418
+#define SWF32			0x7241c
+
+/* Memory Commands */
+#define MI_NOOP			(0x00 << 23)
+#define MI_NOOP_WRITE_ID		(1 << 22)
+#define MI_NOOP_ID_MASK			((1 << 22) - 1)
+
+#define MI_FLUSH		(0x04 << 23)
+#define MI_WRITE_DIRTY_STATE		(1 << 4)
+#define MI_END_SCENE			(1 << 3)
+#define MI_INHIBIT_RENDER_CACHE_FLUSH	(1 << 2)
+#define MI_INVALIDATE_MAP_CACHE		(1 << 0)
+
+#define MI_STORE_DWORD_IMM	((0x20 << 23) | 1)
+
+/* 2D Commands */
+#define COLOR_BLT_CMD		((2 << 29) | (0x40 << 22) | 3)
+#define XY_COLOR_BLT_CMD	((2 << 29) | (0x50 << 22) | 4)
+#define XY_SETUP_CLIP_BLT_CMD	((2 << 29) | (0x03 << 22) | 1)
+#define XY_SRC_COPY_BLT_CMD	((2 << 29) | (0x53 << 22) | 6)
+#define SRC_COPY_BLT_CMD	((2 << 29) | (0x43 << 22) | 4)
+#define XY_MONO_PAT_BLT_CMD	((2 << 29) | (0x52 << 22) | 7)
+#define XY_MONO_SRC_BLT_CMD	((2 << 29) | (0x54 << 22) | 6)
+#define XY_MONO_SRC_IMM_BLT_CMD	((2 << 29) | (0x71 << 22) | 5)
+#define TXT_IMM_BLT_CMD	        ((2 << 29) | (0x30 << 22) | 2)
+#define SETUP_BLT_CMD	        ((2 << 29) | (0x00 << 22) | 6)
+
+#define DW_LENGTH_MASK			0xff
+
+#define WRITE_ALPHA			(1 << 21)
+#define WRITE_RGB			(1 << 20)
+#define VERT_SEED			(3 << 8)
+#define HORIZ_SEED			(3 << 12)
+
+#define COLOR_DEPTH_8			(0 << 24)
+#define COLOR_DEPTH_16			(1 << 24)
+#define COLOR_DEPTH_32			(3 << 24)
+
+#define SRC_ROP_GXCOPY			0xcc
+#define SRC_ROP_GXXOR			0x66
+
+#define PAT_ROP_GXCOPY                  0xf0
+#define PAT_ROP_GXXOR                   0x5a
+
+#define PITCH_SHIFT			0
+#define ROP_SHIFT			16
+#define WIDTH_SHIFT			0
+#define HEIGHT_SHIFT			16
+
+/* in bytes */
+#define MAX_MONO_IMM_SIZE		128
+
+
+/*** Macros ***/
+
+/* I/O macros */
+#define INREG8(addr)	      readb((u8 __iomem *)(dinfo->mmio_base + (addr)))
+#define INREG(addr)	      readl((u32 __iomem *)(dinfo->mmio_base + (addr)))
+#define OUTREG8(addr, val)    writeb((val),(u8 __iomem *)(dinfo->mmio_base + \
+							   (addr)))
+#define OUTREG(addr, val)     writel((val),(u32 __iomem *)(dinfo->mmio_base + \
+                                     (addr)))
+
+/* Ring buffer macros */
+#define OUT_RING(n)	do {						\
+	writel((n), (u32 __iomem *)(dinfo->ring.virtual + dinfo->ring_tail));\
+	dinfo->ring_tail += 4;						\
+	dinfo->ring_tail &= dinfo->ring_tail_mask;			\
+} while (0)
+
+#define START_RING(n)	do {						\
+	if (dinfo->ring_space < (n) * 4)				\
+		wait_ring(dinfo,(n) * 4);				\
+	dinfo->ring_space -= (n) * 4;					\
+} while (0)
+
+#define ADVANCE_RING()	do {						\
+	OUTREG(PRI_RING_TAIL, dinfo->ring_tail);                        \
+} while (0)
+
+#define DO_RING_IDLE()	do {						\
+	u32 head, tail;							\
+	do {								\
+		head = INREG(PRI_RING_HEAD) & RING_HEAD_MASK;		\
+		tail = INREG(PRI_RING_TAIL) & RING_TAIL_MASK;		\
+		udelay(10);						\
+	} while (head != tail);						\
+} while (0)
+
+
+/* function protoypes */
+extern int intelfbhw_get_chipset(struct pci_dev *pdev, const char **name,
+				 int *chipset, int *mobile);
+extern int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
+				int *stolen_size);
+extern int intelfbhw_check_non_crt(struct intelfb_info *dinfo);
+extern const char *intelfbhw_dvo_to_string(int dvo);
+extern int intelfbhw_validate_mode(struct intelfb_info *dinfo,
+				   struct fb_var_screeninfo *var);
+extern int intelfbhw_pan_display(struct fb_var_screeninfo *var,
+				 struct fb_info *info);
+extern void intelfbhw_do_blank(int blank, struct fb_info *info);
+extern void intelfbhw_setcolreg(struct intelfb_info *dinfo, unsigned regno,
+				unsigned red, unsigned green, unsigned blue,
+				unsigned transp);
+extern int intelfbhw_read_hw_state(struct intelfb_info *dinfo,
+				   struct intelfb_hwstate *hw, int flag);
+extern void intelfbhw_print_hw_state(struct intelfb_info *dinfo,
+				     struct intelfb_hwstate *hw);
+extern int intelfbhw_mode_to_hw(struct intelfb_info *dinfo,
+				struct intelfb_hwstate *hw,
+				struct fb_var_screeninfo *var);
+extern int intelfbhw_program_mode(struct intelfb_info *dinfo,
+				  const struct intelfb_hwstate *hw, int blank);
+extern void intelfbhw_do_sync(struct intelfb_info *dinfo);
+extern void intelfbhw_2d_stop(struct intelfb_info *dinfo);
+extern void intelfbhw_2d_start(struct intelfb_info *dinfo);
+extern void intelfbhw_do_fillrect(struct intelfb_info *dinfo, u32 x, u32 y,
+				  u32 w, u32 h, u32 color, u32 pitch, u32 bpp,
+				  u32 rop);
+extern void intelfbhw_do_bitblt(struct intelfb_info *dinfo, u32 curx, u32 cury,
+				u32 dstx, u32 dsty, u32 w, u32 h, u32 pitch,
+				u32 bpp);
+extern int intelfbhw_do_drawglyph(struct intelfb_info *dinfo, u32 fg, u32 bg,
+				  u32 w, u32 h, const u8* cdat, u32 x, u32 y,
+				  u32 pitch, u32 bpp);
+extern void intelfbhw_cursor_init(struct intelfb_info *dinfo);
+extern void intelfbhw_cursor_hide(struct intelfb_info *dinfo);
+extern void intelfbhw_cursor_show(struct intelfb_info *dinfo);
+extern void intelfbhw_cursor_setpos(struct intelfb_info *dinfo, int x, int y);
+extern void intelfbhw_cursor_setcolor(struct intelfb_info *dinfo, u32 bg,
+				      u32 fg);
+extern void intelfbhw_cursor_load(struct intelfb_info *dinfo, int width,
+				  int height, u8 *data);
+extern void intelfbhw_cursor_reset(struct intelfb_info *dinfo);
+
+#endif /* _INTELFBHW_H */
diff -Nru a/drivers/video/kyro/STG4000InitDevice.c b/drivers/video/kyro/STG4000InitDevice.c
--- a/drivers/video/kyro/STG4000InitDevice.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/video/kyro/STG4000InitDevice.c	2004-12-24 13:36:16 -08:00
@@ -79,7 +79,7 @@
     for(i=0;i<X;i++) count++; \
 }
 
-u32 InitSDRAMRegisters(volatile STG4000REG * pSTGReg, u32 dwSubSysID,
+u32 InitSDRAMRegisters(volatile STG4000REG __iomem *pSTGReg, u32 dwSubSysID,
 			 u32 dwRevID)
 {
 	u32 adwSDRAMArgCfg0[] = { 0xa0, 0x80, 0xa0, 0xa0, 0xa0 };
@@ -239,7 +239,7 @@
 	return (ulBestClk);
 }
 
-int SetCoreClockPLL(volatile STG4000REG * pSTGReg, struct pci_dev *pDev)
+int SetCoreClockPLL(volatile STG4000REG __iomem *pSTGReg, struct pci_dev *pDev)
 {
 	u32 F, R, P;
 	u16 core_pll = 0, sub;
diff -Nru a/drivers/video/kyro/STG4000Interface.h b/drivers/video/kyro/STG4000Interface.h
--- a/drivers/video/kyro/STG4000Interface.h	2004-12-24 13:37:02 -08:00
+++ b/drivers/video/kyro/STG4000Interface.h	2004-12-24 13:37:02 -08:00
@@ -16,45 +16,45 @@
 /*
  * Ramdac Setup
  */
-extern int InitialiseRamdac(volatile STG4000REG *pSTGReg, u32 displayDepth,
+extern int InitialiseRamdac(volatile STG4000REG __iomem *pSTGReg, u32 displayDepth,
 			    u32 displayWidth, u32 displayHeight,
 			    s32 HSyncPolarity, s32 VSyncPolarity,
 			    u32 *pixelClock);
 
-extern void DisableRamdacOutput(volatile STG4000REG * pSTGReg);
-extern void EnableRamdacOutput(volatile STG4000REG * pSTGReg);
+extern void DisableRamdacOutput(volatile STG4000REG __iomem *pSTGReg);
+extern void EnableRamdacOutput(volatile STG4000REG __iomem *pSTGReg);
 
 /*
  * Timing generator setup
  */
-extern void DisableVGA(volatile STG4000REG * pSTGReg);
-extern void StopVTG(volatile STG4000REG * pSTGReg);
-extern void StartVTG(volatile STG4000REG * pSTGReg);
-extern void SetupVTG(volatile STG4000REG * pSTGReg,
+extern void DisableVGA(volatile STG4000REG __iomem *pSTGReg);
+extern void StopVTG(volatile STG4000REG __iomem *pSTGReg);
+extern void StartVTG(volatile STG4000REG __iomem *pSTGReg);
+extern void SetupVTG(volatile STG4000REG __iomem *pSTGReg,
 		     const struct kyrofb_info * pTiming);
 
 extern u32 ProgramClock(u32 refClock, u32 coreClock, u32 *FOut, u32 *ROut, u32 *POut);
-extern int SetCoreClockPLL(volatile STG4000REG * pSTGReg, struct pci_dev *pDev);
+extern int SetCoreClockPLL(volatile STG4000REG __iomem *pSTGReg, struct pci_dev *pDev);
 
 /*
  * Overlay setup
  */
-extern void ResetOverlayRegisters(volatile STG4000REG * pSTGReg);
+extern void ResetOverlayRegisters(volatile STG4000REG __iomem *pSTGReg);
 
-extern int CreateOverlaySurface(volatile STG4000REG * pSTGReg,
+extern int CreateOverlaySurface(volatile STG4000REG __iomem *pSTGReg,
 				u32 ulWidth, u32 ulHeight,
 				int bLinear,
 				u32 ulOverlayOffset,
 				u32 * retStride, u32 * retUVStride);
 
-extern int SetOverlayBlendMode(volatile STG4000REG * pSTGReg,
+extern int SetOverlayBlendMode(volatile STG4000REG __iomem *pSTGReg,
 			       OVRL_BLEND_MODE mode,
 			       u32 ulAlpha, u32 ulColorKey);
 
-extern int SetOverlayViewPort(volatile STG4000REG * pSTGReg,
+extern int SetOverlayViewPort(volatile STG4000REG __iomem *pSTGReg,
 			      u32 left, u32 top,
 			      u32 right, u32 bottom);
 
-extern void EnableOverlayPlane(volatile STG4000REG * pSTGReg);
+extern void EnableOverlayPlane(volatile STG4000REG __iomem *pSTGReg);
 
 #endif /* _STG4000INTERFACE_H */
diff -Nru a/drivers/video/kyro/STG4000OverlayDevice.c b/drivers/video/kyro/STG4000OverlayDevice.c
--- a/drivers/video/kyro/STG4000OverlayDevice.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/video/kyro/STG4000OverlayDevice.c	2004-12-24 13:36:31 -08:00
@@ -75,7 +75,7 @@
 static u32 ovlWidth, ovlHeight, ovlStride;
 static int ovlLinear;
 
-void ResetOverlayRegisters(volatile STG4000REG * pSTGReg)
+void ResetOverlayRegisters(volatile STG4000REG __iomem *pSTGReg)
 {
 	u32 tmp;
 
@@ -136,7 +136,7 @@
 
 }
 
-int CreateOverlaySurface(volatile STG4000REG * pSTGReg,
+int CreateOverlaySurface(volatile STG4000REG __iomem *pSTGReg,
 			 u32 inWidth,
 			 u32 inHeight,
 			 int bLinear,
@@ -238,7 +238,7 @@
 	return 0;
 }
 
-int SetOverlayBlendMode(volatile STG4000REG * pSTGReg,
+int SetOverlayBlendMode(volatile STG4000REG __iomem *pSTGReg,
 			OVRL_BLEND_MODE mode,
 			u32 ulAlpha, u32 ulColorKey)
 {
@@ -284,7 +284,7 @@
 	return 0;
 }
 
-void EnableOverlayPlane(volatile STG4000REG * pSTGReg)
+void EnableOverlayPlane(volatile STG4000REG __iomem *pSTGReg)
 {
 	u32 tmp;
 	/* Enable Overlay */
@@ -313,7 +313,7 @@
 
 }
 
-int SetOverlayViewPort(volatile STG4000REG * pSTGReg,
+int SetOverlayViewPort(volatile STG4000REG __iomem *pSTGReg,
 		       u32 left, u32 top,
 		       u32 right, u32 bottom)
 {
diff -Nru a/drivers/video/kyro/STG4000Ramdac.c b/drivers/video/kyro/STG4000Ramdac.c
--- a/drivers/video/kyro/STG4000Ramdac.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/video/kyro/STG4000Ramdac.c	2004-12-24 13:37:00 -08:00
@@ -18,9 +18,9 @@
 
 static u32 STG_PIXEL_BUS_WIDTH = 128;	/* 128 bit bus width      */
 static u32 REF_CLOCK = 14318;
-STG4000REG *pSTGReg;
+STG4000REG __iomem *pSTGReg;
 
-int InitialiseRamdac(volatile STG4000REG * pSTGReg,
+int InitialiseRamdac(volatile STG4000REG __iomem * pSTGReg,
 		     u32 displayDepth,
 		     u32 displayWidth,
 		     u32 displayHeight,
@@ -145,7 +145,7 @@
 }
 
 /* Ramdac control, turning output to the screen on and off */
-void DisableRamdacOutput(volatile STG4000REG * pSTGReg)
+void DisableRamdacOutput(volatile STG4000REG __iomem * pSTGReg)
 {
 	u32 tmp;
 
@@ -154,7 +154,7 @@
 	STG_WRITE_REG(DACStreamCtrl, tmp);
 }
 
-void EnableRamdacOutput(volatile STG4000REG * pSTGReg)
+void EnableRamdacOutput(volatile STG4000REG __iomem * pSTGReg)
 {
 	u32 tmp;
 
diff -Nru a/drivers/video/kyro/STG4000Reg.h b/drivers/video/kyro/STG4000Reg.h
--- a/drivers/video/kyro/STG4000Reg.h	2004-12-24 13:36:55 -08:00
+++ b/drivers/video/kyro/STG4000Reg.h	2004-12-24 13:36:55 -08:00
@@ -21,8 +21,8 @@
 #if defined(__KERNEL__)
 #include <asm/page.h>
 #include <asm/io.h>
-#define STG_WRITE_REG(reg,data) (writel(data,(unsigned long)&pSTGReg->reg))
-#define STG_READ_REG(reg)      (readl((unsigned long)&pSTGReg->reg))
+#define STG_WRITE_REG(reg,data) (writel(data,&pSTGReg->reg))
+#define STG_READ_REG(reg)      (readl(&pSTGReg->reg))
 #else
 #define STG_WRITE_REG(reg,data) (pSTGReg->reg = data)
 #define STG_READ_REG(reg)      (pSTGReg->reg)
diff -Nru a/drivers/video/kyro/STG4000VTG.c b/drivers/video/kyro/STG4000VTG.c
--- a/drivers/video/kyro/STG4000VTG.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/video/kyro/STG4000VTG.c	2004-12-24 13:36:16 -08:00
@@ -14,7 +14,7 @@
 #include "STG4000Reg.h"
 #include "STG4000Interface.h"
 
-void DisableVGA(volatile STG4000REG * pSTGReg)
+void DisableVGA(volatile STG4000REG __iomem *pSTGReg)
 {
 	u32 tmp;
 	volatile u32 count, i;
@@ -35,7 +35,7 @@
 	STG_WRITE_REG(SoftwareReset, tmp);
 }
 
-void StopVTG(volatile STG4000REG * pSTGReg)
+void StopVTG(volatile STG4000REG __iomem *pSTGReg)
 {
 	u32 tmp = 0;
 
@@ -45,7 +45,7 @@
 	STG_WRITE_REG(DACSyncCtrl, tmp);
 }
 
-void StartVTG(volatile STG4000REG * pSTGReg)
+void StartVTG(volatile STG4000REG __iomem *pSTGReg)
 {
 	u32 tmp = 0;
 
@@ -56,7 +56,7 @@
 	STG_WRITE_REG(DACSyncCtrl, tmp);
 }
 
-void SetupVTG(volatile STG4000REG * pSTGReg,
+void SetupVTG(volatile STG4000REG __iomem *pSTGReg,
 	      const struct kyrofb_info * pTiming)
 {
 	u32 tmp = 0;
diff -Nru a/drivers/video/kyro/fbdev.c b/drivers/video/kyro/fbdev.c
--- a/drivers/video/kyro/fbdev.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/video/kyro/fbdev.c	2004-12-24 13:36:17 -08:00
@@ -76,7 +76,7 @@
 static struct kyrofb_info *currentpar;
 
 typedef struct {
-	STG4000REG *pSTGReg;	/* Virtual address of PCI register region */
+	STG4000REG __iomem *pSTGReg;	/* Virtual address of PCI register region */
 	u32 ulNextFreeVidMem;	/* Offset from start of vid mem to next free region */
 	u32 ulOverlayOffset;	/* Offset from start of vid mem to overlay */
 	u32 ulOverlayStride;	/* Interleaved YUV and 422 mode Y stride */
@@ -735,6 +735,7 @@
 
 	fb_memset(info->screen_base, 0, size);
 
+	info->device = &pdev->dev;
 	if (register_framebuffer(info) < 0)
 		goto out_unmap;
 
diff -Nru a/drivers/video/leo.c b/drivers/video/leo.c
--- a/drivers/video/leo.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/video/leo.c	2004-12-24 13:37:19 -08:00
@@ -180,11 +180,11 @@
 
 struct leo_par {
 	spinlock_t		lock;
-	struct leo_lx_krn	*lx_krn;
-	struct leo_lc_ss0_usr	*lc_ss0_usr;
-	struct leo_ld_ss0	*ld_ss0;
-	struct leo_ld_ss1	*ld_ss1;
-	struct leo_cursor	*cursor;
+	struct leo_lx_krn	__iomem *lx_krn;
+	struct leo_lc_ss0_usr	__iomem *lc_ss0_usr;
+	struct leo_ld_ss0	__iomem *ld_ss0;
+	struct leo_ld_ss1	__iomem *ld_ss1;
+	struct leo_cursor	__iomem *cursor;
 	u32			extent;
 	u32			clut_data[256];
 
@@ -198,7 +198,7 @@
 	struct list_head	list;
 };
 
-static void leo_wait(struct leo_lx_krn *lx_krn)
+static void leo_wait(struct leo_lx_krn __iomem *lx_krn)
 {
 	int i;
 	
@@ -223,7 +223,7 @@
 			 unsigned transp, struct fb_info *info)
 {
 	struct leo_par *par = (struct leo_par *) info->par;
-        struct leo_lx_krn *lx_krn = par->lx_krn;
+        struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
 	unsigned long flags;
 	u32 val;
 	int i;
@@ -263,24 +263,24 @@
 static int leo_blank(int blank, struct fb_info *info)
 {
 	struct leo_par *par = (struct leo_par *) info->par;
-	struct leo_lx_krn *lx_krn = par->lx_krn;
+	struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
 	unsigned long flags;
 	u32 val;
 
 	spin_lock_irqsave(&par->lock, flags);
 
 	switch (blank) {
-	case 0: /* Unblanking */
+	case FB_BLANK_UNBLANK: /* Unblanking */
 		val = sbus_readl(&lx_krn->krn_csr);
 		val |= LEO_KRN_CSR_ENABLE;
 		sbus_writel(val, &lx_krn->krn_csr);
 		par->flags &= ~LEO_FLAG_BLANKED;
 		break;
 
-	case 1: /* Normal blanking */
-	case 2: /* VESA blank (vsync off) */
-	case 3: /* VESA blank (hsync off) */
-	case 4: /* Poweroff */
+	case FB_BLANK_NORMAL: /* Normal blanking */
+	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
+	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
+	case FB_BLANK_POWERDOWN: /* Poweroff */
 		val = sbus_readl(&lx_krn->krn_csr);
 		val &= ~LEO_KRN_CSR_ENABLE;
 		sbus_writel(val, &lx_krn->krn_csr);
@@ -403,7 +403,7 @@
 static void leo_wid_put(struct fb_info *info, struct fb_wid_list *wl)
 {
 	struct leo_par *par = (struct leo_par *) info->par;
-	struct leo_lx_krn *lx_krn = par->lx_krn;
+	struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
 	struct fb_wid_item *wi;
 	unsigned long flags;
 	u32 val;
@@ -465,7 +465,7 @@
 static void leo_switch_from_graph(struct fb_info *info)
 {
 	struct leo_par *par = (struct leo_par *) info->par;
-	struct leo_ld *ss = (struct leo_ld *) par->ld_ss0;
+	struct leo_ld __iomem *ss = (struct leo_ld __iomem *) par->ld_ss0;
 	unsigned long flags;
 	u32 val;
 
@@ -564,33 +564,32 @@
 	all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
 
 #ifdef CONFIG_SPARC32
-	all->info.screen_base = (char *)
+	all->info.screen_base = (char __iomem *)
 		prom_getintdefault(sdev->prom_node, "address", 0);
 #endif
 	if (!all->info.screen_base)
-		all->info.screen_base = (char *)
+		all->info.screen_base = 
 			sbus_ioremap(&sdev->resource[0], LEO_OFF_SS0,
 				     0x800000, "leo ram");
 
-	all->par.lc_ss0_usr = (struct leo_lc_ss0_usr *)
+	all->par.lc_ss0_usr =
 		sbus_ioremap(&sdev->resource[0], LEO_OFF_LC_SS0_USR,
 			     0x1000, "leolc ss0usr");
-	all->par.ld_ss0 = (struct leo_ld_ss0 *)
+	all->par.ld_ss0 =
 		sbus_ioremap(&sdev->resource[0], LEO_OFF_LD_SS0,
 			     0x1000, "leold ss0");
-	all->par.ld_ss1 = (struct leo_ld_ss1 *)
+	all->par.ld_ss1 =
 		sbus_ioremap(&sdev->resource[0], LEO_OFF_LD_SS1,
 			     0x1000, "leold ss1");
-	all->par.lx_krn = (struct leo_lx_krn *)
+	all->par.lx_krn =
 		sbus_ioremap(&sdev->resource[0], LEO_OFF_LX_KRN,
 			     0x1000, "leolx krn");
-	all->par.cursor = (struct leo_cursor *)
+	all->par.cursor =
 		sbus_ioremap(&sdev->resource[0], LEO_OFF_LX_CURSOR,
 			     sizeof(struct leo_cursor), "leolx cursor");
 
 	all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
 	all->info.fbops = &leo_ops;
-	all->info.currcon = -1;
 	all->info.par = &all->par;
 
 	leo_init_wids(&all->info);
diff -Nru a/drivers/video/matrox/matroxfb_accel.c b/drivers/video/matrox/matroxfb_accel.c
--- a/drivers/video/matrox/matroxfb_accel.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/video/matrox/matroxfb_accel.c	2004-12-24 13:37:43 -08:00
@@ -411,12 +411,7 @@
 
 	CRITBEGIN
 
-#ifdef __BIG_ENDIAN
-	WaitTillIdle();
-	mga_outl(M_OPMODE, M_OPMODE_8BPP);
-#else
 	mga_fifo(3);
-#endif
 	if (easy)
 		mga_outl(M_DWGCTL, M_DWG_ILOAD | M_DWG_SGNZERO | M_DWG_SHIFTZERO | M_DWG_BMONOWF | M_DWG_LINEAR | M_DWG_REPLACE);
 	else
@@ -432,32 +427,24 @@
 	mga_writel(mmio, M_AR3, 0);
 	if (easy) {
 		mga_writel(mmio, M_YDSTLEN | M_EXEC, ydstlen);
-		mga_memcpy_toio(mmio, 0, chardata, xlen);
+		mga_memcpy_toio(mmio, chardata, xlen);
 	} else {
 		mga_writel(mmio, M_AR5, 0);
 		mga_writel(mmio, M_YDSTLEN | M_EXEC, ydstlen);
 		if ((step & 3) == 0) {
 			/* Great. Source has 32bit aligned lines, so we can feed them
 			   directly to the accelerator. */
-			mga_memcpy_toio(mmio, 0, chardata, charcell);
+			mga_memcpy_toio(mmio, chardata, charcell);
 		} else if (step == 1) {
 			/* Special case for 1..8bit widths */
 			while (height--) {
-#ifdef __LITTLE_ENDIAN
 				mga_writel(mmio, 0, *chardata);
-#else
-				mga_writel(mmio, 0, (*chardata) << 24);
-#endif
 				chardata++;
 			}
 		} else if (step == 2) {
 			/* Special case for 9..15bit widths */
 			while (height--) {
-#ifdef __LITTLE_ENDIAN
 				mga_writel(mmio, 0, *(u_int16_t*)chardata);
-#else
-				mga_writel(mmio, 0, (*(u_int16_t*)chardata) << 16);
-#endif
 				chardata += 2;
 			}
 		} else {
@@ -474,9 +461,6 @@
 		}
 	}
 	WaitTillIdle();
-#ifdef __BIG_ENDIAN
-	mga_outl(M_OPMODE, ACCESS_FBINFO(accel.m_opmode));
-#endif
 	CRITEND
 }
 
@@ -486,7 +470,7 @@
 
 	DBG_HEAVY(__FUNCTION__);
 
-	if (image->depth == 0) {
+	if (image->depth == 1) {
 		u_int32_t fgx, bgx;
 
 		fgx = ((u_int32_t*)info->pseudo_palette)[image->fg_color];
diff -Nru a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
--- a/drivers/video/matrox/matroxfb_base.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/video/matrox/matroxfb_base.c	2004-12-24 13:37:02 -08:00
@@ -835,6 +835,7 @@
 			matrox_cfbX_init(PMINFO2);
 		}
 	}
+	ACCESS_FBINFO(initialized) = 1;
 	return 0;
 }
 
@@ -1143,6 +1144,7 @@
 					return -EFAULT;
 				return err;
 			}
+		case VIDIOC_S_CTRL_OLD:
 		case VIDIOC_S_CTRL:
 			{
 				struct v4l2_control ctrl;
@@ -1181,11 +1183,11 @@
 		return 1;
 
 	switch (blank) {
-		case 1:  seq = 0x20; crtc = 0x00; break; /* works ??? */
-		case 2:  seq = 0x20; crtc = 0x10; break;
-		case 3:  seq = 0x20; crtc = 0x20; break;
-		case 4:  seq = 0x20; crtc = 0x30; break;
-		default: seq = 0x00; crtc = 0x00; break;
+	case FB_BLANK_NORMAL:  seq = 0x20; crtc = 0x00; break; /* works ??? */
+	case FB_BLANK_VSYNC_SUSPEND:  seq = 0x20; crtc = 0x10; break;
+	case FB_BLANK_HSYNC_SUSPEND:  seq = 0x20; crtc = 0x20; break;
+	case FB_BLANK_POWERDOWN:  seq = 0x20; crtc = 0x30; break;
+	default: seq = 0x00; crtc = 0x00; break;
 	}
 
 	CRITBEGIN
@@ -1578,6 +1580,11 @@
 	unsigned int memsize;
 	int err;
 
+	static struct pci_device_id intel_82437[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437) },
+		{ },
+	};
+
 	DBG(__FUNCTION__)
 
 	/* set default values... */
@@ -1682,7 +1689,7 @@
 		mga_option |= MX_OPTION_BSWAP;
                 /* disable palette snooping */
                 cmd &= ~PCI_COMMAND_VGA_PALETTE;
-		if (pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437, NULL)) {
+		if (pci_dev_present(intel_82437)) {
 			if (!(mga_option & 0x20000000) && !ACCESS_FBINFO(devflags.nopciretry)) {
 				printk(KERN_WARNING "matroxfb: Disabling PCI retries due to i82437 present\n");
 			}
@@ -1711,7 +1718,6 @@
 	}
 	ACCESS_FBINFO(devflags.ydstorg) = 0;
 
-	ACCESS_FBINFO(fbcon.currcon) = -1;
 	ACCESS_FBINFO(video.base) = video_base_phys;
 	ACCESS_FBINFO(video.len_usable) = ACCESS_FBINFO(video.len);
 	if (ACCESS_FBINFO(video.len_usable) > b->base->maxdisplayable)
@@ -1750,6 +1756,12 @@
 	ACCESS_FBINFO(fbcon.pseudo_palette) = ACCESS_FBINFO(cmap);
 	/* after __init time we are like module... no logo */
 	ACCESS_FBINFO(fbcon.flags) = hotplug ? FBINFO_FLAG_MODULE : FBINFO_FLAG_DEFAULT;
+	ACCESS_FBINFO(fbcon.flags) |= FBINFO_PARTIAL_PAN_OK | 	 /* Prefer panning for scroll under MC viewer/edit */
+				      FBINFO_HWACCEL_COPYAREA |  /* We have hw-assisted bmove */
+				      FBINFO_HWACCEL_FILLRECT |  /* And fillrect */
+				      FBINFO_HWACCEL_IMAGEBLIT | /* And imageblit */
+				      FBINFO_HWACCEL_XPAN |      /* And we support both horizontal */
+				      FBINFO_HWACCEL_YPAN;       /* And vertical panning */
 	ACCESS_FBINFO(video.len_usable) &= PAGE_MASK;
 	fb_alloc_cmap(&ACCESS_FBINFO(fbcon.cmap), 256, 1);
 
@@ -1864,21 +1876,24 @@
 /* We do not have to set currcon to 0... register_framebuffer do it for us on first console
  * and we do not want currcon == 0 for subsequent framebuffers */
 
+	ACCESS_FBINFO(fbcon).device = &ACCESS_FBINFO(pcidev)->dev;
 	if (register_framebuffer(&ACCESS_FBINFO(fbcon)) < 0) {
 		goto failVideoIO;
 	}
 	printk("fb%d: %s frame buffer device\n",
 	       ACCESS_FBINFO(fbcon.node), ACCESS_FBINFO(fbcon.fix.id));
-	if (ACCESS_FBINFO(fbcon.currcon) < 0) {
-		/* there is no console on this fb... but we have to initialize hardware
-		 * until someone tells me what is proper thing to do */
-		printk(KERN_INFO "fb%d: initializing hardware\n",
-			ACCESS_FBINFO(fbcon.node));
-		/* We have to use FB_ACTIVATE_FORCE, as we had to put vesafb_defined to the fbcon.var
-		 * already before, so register_framebuffer works correctly. */
-		vesafb_defined.activate |= FB_ACTIVATE_FORCE;
-		fb_set_var(&ACCESS_FBINFO(fbcon), &vesafb_defined);
-	}
+
+	/* there is no console on this fb... but we have to initialize hardware
+	 * until someone tells me what is proper thing to do */
+ 	if (!ACCESS_FBINFO(initialized)) {
+ 		printk(KERN_INFO "fb%d: initializing hardware\n",
+ 		       ACCESS_FBINFO(fbcon.node));
+ 		/* We have to use FB_ACTIVATE_FORCE, as we had to put vesafb_defined to the fbcon.var
+ 		 * already before, so register_framebuffer works correctly. */
+ 		vesafb_defined.activate |= FB_ACTIVATE_FORCE;
+ 		fb_set_var(&ACCESS_FBINFO(fbcon), &vesafb_defined);
+ 	}
+
 	return 0;
 failVideoIO:;
 	matroxfb_g450_shutdown(PMINFO2);
diff -Nru a/drivers/video/matrox/matroxfb_base.h b/drivers/video/matrox/matroxfb_base.h
--- a/drivers/video/matrox/matroxfb_base.h	2004-12-24 13:36:49 -08:00
+++ b/drivers/video/matrox/matroxfb_base.h	2004-12-24 13:36:49 -08:00
@@ -93,29 +93,6 @@
 
 #endif /* MATROXFB_DEBUG */
 
-#if !defined(__i386__) && !defined(__x86_64__)
-#ifndef ioremap_nocache
-#define ioremap_nocache(X,Y) ioremap(X,Y)
-#endif
-#endif
-
-#if defined(__alpha__) || defined(__mc68000__) || defined(__i386__) || defined(__x86_64__)
-#define READx_WORKS
-#define MEMCPYTOIO_WORKS
-#else
-/* ppc/ppc64 must use __raw_{read,write}[bwl] as we drive adapter 
-   in big-endian mode for compatibility with XFree mga driver, and
-   so we do not want little-endian {read,write}[bwl] */
-#define READx_FAILS
-#define MEMCPYTOIO_WRITEL
-#endif
-
-#if defined(__mc68000__)
-#define MAP_BUSTOVIRT
-#else
-#define MAP_IOREMAP
-#endif
-
 #ifdef DEBUG
 #define dprintk(X...)	printk(X)
 #else
@@ -155,22 +132,13 @@
 #endif
 
 typedef struct {
-	u_int8_t __iomem*	vaddr;
+	void __iomem*	vaddr;
 } vaddr_t;
 
-#ifdef READx_WORKS
 static inline unsigned int mga_readb(vaddr_t va, unsigned int offs) {
 	return readb(va.vaddr + offs);
 }
 
-static inline unsigned int mga_readw(vaddr_t va, unsigned int offs) {
-	return readw(va.vaddr + offs);
-}
-
-static inline u_int32_t mga_readl(vaddr_t va, unsigned int offs) {
-	return readl(va.vaddr + offs);
-}
-
 static inline void mga_writeb(vaddr_t va, unsigned int offs, u_int8_t value) {
 	writeb(value, va.vaddr + offs);
 }
@@ -179,62 +147,42 @@
 	writew(value, va.vaddr + offs);
 }
 
-static inline void mga_writel(vaddr_t va, unsigned int offs, u_int32_t value) {
-	writel(value, va.vaddr + offs);
-}
-#else
-static inline unsigned int mga_readb(vaddr_t va, unsigned int offs) {
-	return __raw_readb(va.vaddr + offs);
-}
-
-static inline unsigned int mga_readw(vaddr_t va, unsigned int offs) {
-	return __raw_readw(va.vaddr + offs);
-}
-
 static inline u_int32_t mga_readl(vaddr_t va, unsigned int offs) {
-	return __raw_readl(va.vaddr + offs);
-}
-
-static inline void mga_writeb(vaddr_t va, unsigned int offs, u_int8_t value) {
-	__raw_writeb(value, va.vaddr + offs);
-}
-
-static inline void mga_writew(vaddr_t va, unsigned int offs, u_int16_t value) {
-	__raw_writew(value, va.vaddr + offs);
+	return readl(va.vaddr + offs);
 }
 
 static inline void mga_writel(vaddr_t va, unsigned int offs, u_int32_t value) {
-	__raw_writel(value, va.vaddr + offs);
+	writel(value, va.vaddr + offs);
 }
-#endif
 
-static inline void mga_memcpy_toio(vaddr_t va, unsigned int offs, const void* src, int len) {
-#ifdef MEMCPYTOIO_WORKS
-	memcpy_toio(va.vaddr + offs, src, len);
-#elif defined(MEMCPYTOIO_WRITEL)
-	if (offs & 3) {
+static inline void mga_memcpy_toio(vaddr_t va, const void* src, int len) {
+#if defined(__alpha__) || defined(__i386__) || defined(__x86_64__)
+	/*
+	 * memcpy_toio works for us if:
+	 *  (1) Copies data as 32bit quantities, not byte after byte,
+	 *  (2) Performs LE ordered stores, and
+	 *  (3) It copes with unaligned source (destination is guaranteed to be page
+	 *      aligned and length is guaranteed to be multiple of 4).
+	 */
+	memcpy_toio(va.vaddr, src, len);
+#else
+        u_int32_t __iomem* addr = va.vaddr;
+
+	if ((unsigned long)src & 3) {
 		while (len >= 4) {
-			mga_writel(va, offs, get_unaligned((u32 *)src));
-			offs += 4;
+			writel(get_unaligned((u32 *)src), addr);
+			addr++;
 			len -= 4;
 			src += 4;
 		}
 	} else {
 		while (len >= 4) {
-			mga_writel(va, offs, *(u32 *)src);
-			offs += 4;
+			writel(*(u32 *)src, addr);
+			addr++;
 			len -= 4;
 			src += 4;
 		}
 	}
-	if (len) {
-		u_int32_t tmp;
-
-		memcpy(&tmp, src, len);
-		mga_writel(va, offs, tmp);
-	}
-#else
-#error "Sorry, do not know how to write block of data to device"
 #endif
 }
 
@@ -252,25 +200,15 @@
 #define MGA_IOREMAP_FB		MGA_IOREMAP_NOCACHE
 #define MGA_IOREMAP_MMIO	MGA_IOREMAP_NOCACHE
 static inline int mga_ioremap(unsigned long phys, unsigned long size, int flags, vaddr_t* virt) {
-#ifdef MAP_IOREMAP
 	if (flags & MGA_IOREMAP_NOCACHE)
 		virt->vaddr = ioremap_nocache(phys, size);
 	else
 		virt->vaddr = ioremap(phys, size);
-#else
-#ifdef MAP_BUSTOVIRT
-	virt->vaddr = bus_to_virt(phys);
-#else
-#error "Your architecture does not have neither ioremap nor bus_to_virt... Giving up"
-#endif
-#endif
 	return (virt->vaddr == 0); /* 0, !0... 0, error_code in future */
 }
 
 static inline void mga_iounmap(vaddr_t va) {
-#ifdef MAP_IOREMAP
 	iounmap(va.vaddr);
-#endif
 }
 
 struct my_timming {
@@ -434,6 +372,7 @@
 	struct list_head	next_fb;
 
 	int			dead;
+	int                     initialized;
 	unsigned int		usecount;
 
 	unsigned int		userusecount;
@@ -774,11 +713,11 @@
 #define DAC_XGENIOCTRL		0x2A
 #define DAC_XGENIODATA		0x2B
 
-#define M_C2CTL		0x3E10
+#define M_C2CTL		0x3C10
 
-#ifdef __LITTLE_ENDIAN
-#define MX_OPTION_BSWAP		0x00000000
+#define MX_OPTION_BSWAP         0x00000000
 
+#ifdef __LITTLE_ENDIAN
 #define M_OPMODE_4BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_LE | M_OPMODE_DMA_BLIT)
 #define M_OPMODE_8BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_LE | M_OPMODE_DMA_BLIT)
 #define M_OPMODE_16BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_LE | M_OPMODE_DMA_BLIT)
@@ -786,29 +725,23 @@
 #define M_OPMODE_32BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_LE | M_OPMODE_DMA_BLIT)
 #else
 #ifdef __BIG_ENDIAN
-#define MX_OPTION_BSWAP		0x80000000
-
-#define M_OPMODE_4BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_LE | M_OPMODE_DMA_BLIT)	/* TODO */
-#define M_OPMODE_8BPP	(M_OPMODE_DMA_BE_8BPP  | M_OPMODE_DIR_BE_8BPP  | M_OPMODE_DMA_BLIT)
-#define M_OPMODE_16BPP	(M_OPMODE_DMA_BE_16BPP | M_OPMODE_DIR_BE_16BPP | M_OPMODE_DMA_BLIT)
-#define M_OPMODE_24BPP	(M_OPMODE_DMA_BE_8BPP | M_OPMODE_DIR_BE_8BPP | M_OPMODE_DMA_BLIT)	/* TODO, ?32 */
-#define M_OPMODE_32BPP	(M_OPMODE_DMA_BE_32BPP | M_OPMODE_DIR_BE_32BPP | M_OPMODE_DMA_BLIT)
+#define M_OPMODE_4BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_LE       | M_OPMODE_DMA_BLIT)	/* TODO */
+#define M_OPMODE_8BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_BE_8BPP  | M_OPMODE_DMA_BLIT)
+#define M_OPMODE_16BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_BE_16BPP | M_OPMODE_DMA_BLIT)
+#define M_OPMODE_24BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_BE_8BPP  | M_OPMODE_DMA_BLIT)	/* TODO, ?32 */
+#define M_OPMODE_32BPP	(M_OPMODE_DMA_LE | M_OPMODE_DIR_BE_32BPP | M_OPMODE_DMA_BLIT)
 #else
 #error "Byte ordering have to be defined. Cannot continue."
 #endif
 #endif
 
-#define mga_inb(addr)	mga_readb(ACCESS_FBINFO(mmio.vbase), (addr))
-#define mga_inl(addr)	mga_readl(ACCESS_FBINFO(mmio.vbase), (addr))
-#define mga_outb(addr,val) mga_writeb(ACCESS_FBINFO(mmio.vbase), (addr), (val))
-#define mga_outw(addr,val) mga_writew(ACCESS_FBINFO(mmio.vbase), (addr), (val))
-#define mga_outl(addr,val) mga_writel(ACCESS_FBINFO(mmio.vbase), (addr), (val))
-#define mga_readr(port,idx) (mga_outb((port),(idx)), mga_inb((port)+1))
-#ifdef __LITTLE_ENDIAN
-#define mga_setr(addr,port,val) mga_outw(addr, ((val)<<8) | (port))
-#else
-#define mga_setr(addr,port,val) do { mga_outb(addr, port); mga_outb((addr)+1, val); } while (0)
-#endif
+#define mga_inb(addr)		mga_readb(ACCESS_FBINFO(mmio.vbase), (addr))
+#define mga_inl(addr)		mga_readl(ACCESS_FBINFO(mmio.vbase), (addr))
+#define mga_outb(addr,val)	mga_writeb(ACCESS_FBINFO(mmio.vbase), (addr), (val))
+#define mga_outw(addr,val)	mga_writew(ACCESS_FBINFO(mmio.vbase), (addr), (val))
+#define mga_outl(addr,val)	mga_writel(ACCESS_FBINFO(mmio.vbase), (addr), (val))
+#define mga_readr(port,idx)	(mga_outb((port),(idx)), mga_inb((port)+1))
+#define mga_setr(addr,port,val)	mga_outw(addr, ((val)<<8) | (port))
 
 #define mga_fifo(n)	do {} while ((mga_inl(M_FIFOSTATUS) & 0xFF) < (n))
 
diff -Nru a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c
--- a/drivers/video/matrox/matroxfb_crtc2.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/video/matrox/matroxfb_crtc2.c	2004-12-24 13:37:18 -08:00
@@ -387,6 +387,7 @@
 		up_read(&ACCESS_FBINFO(altout).lock);
 		matroxfb_dh_cfbX_init(m2info);
 	}
+	m2info->initialized = 1;
 	return 0;
 #undef m2info
 }
@@ -603,7 +604,8 @@
 
 	m2info->fbcon.fbops = &matroxfb_dh_ops;
 	m2info->fbcon.flags = FBINFO_FLAG_DEFAULT;
-	m2info->fbcon.currcon = -1;
+	m2info->fbcon.flags |= FBINFO_HWACCEL_XPAN |
+			       FBINFO_HWACCEL_YPAN;
 	m2info->fbcon.pseudo_palette = m2info->cmap;
 	fb_alloc_cmap(&m2info->fbcon.cmap, 256, 1);
 
@@ -632,9 +634,8 @@
 	if (register_framebuffer(&m2info->fbcon)) {
 		return -ENXIO;
 	}
-	if (m2info->fbcon.currcon < 0) {
+	if (!m2info->initialized)
 		fb_set_var(&m2info->fbcon, &matroxfb_dh_defined);
-	}
 	down_write(&ACCESS_FBINFO(crtc2.lock));
 	oldcrtc2 = ACCESS_FBINFO(crtc2.info);
 	ACCESS_FBINFO(crtc2.info) = m2info;
diff -Nru a/drivers/video/matrox/matroxfb_crtc2.h b/drivers/video/matrox/matroxfb_crtc2.h
--- a/drivers/video/matrox/matroxfb_crtc2.h	2004-12-24 13:36:19 -08:00
+++ b/drivers/video/matrox/matroxfb_crtc2.h	2004-12-24 13:36:19 -08:00
@@ -9,6 +9,7 @@
 struct matroxfb_dh_fb_info {
 	struct fb_info		fbcon;
 	int			fbcon_registered;
+	int                     initialized;
 
 	struct matrox_fb_info*	primary_dev;
 
diff -Nru a/drivers/video/modedb.c b/drivers/video/modedb.c
--- a/drivers/video/modedb.c	2004-12-24 13:36:48 -08:00
+++ b/drivers/video/modedb.c	2004-12-24 13:36:48 -08:00
@@ -24,7 +24,7 @@
     ((v).xres == (x) && (v).yres == (y))
 
 #ifdef DEBUG
-#define DPRINTK(fmt, args...)	printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
+#define DPRINTK(fmt, args...)	printk("modedb %s: " fmt, __FUNCTION__ , ## args)
 #else
 #define DPRINTK(fmt, args...)
 #endif
@@ -474,7 +474,7 @@
 		 const struct fb_videomode *default_mode,
 		 unsigned int default_bpp)
 {
-    int i, j;
+    int i;
 
     /* Set up defaults */
     if (!db) {
@@ -493,7 +493,7 @@
 	int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
 	unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0;
 	int yres_specified = 0;
-	u32 best = -1, diff = -1;
+	u32 best, diff;
 
 	for (i = namelen-1; i >= 0; i--) {
 	    switch (name[i]) {
@@ -532,16 +532,35 @@
 	    res_specified = 1;
 	}
 done:
-	for (i = refresh_specified; i >= 0; i--) {
-	    DPRINTK("Trying specified video mode%s %ix%i\n",
-		    i ? "" : " (ignoring refresh rate)", xres, yres);
-	    for (j = 0; j < dbsize; j++)
-		if ((name_matches(db[j], name, namelen) ||
-		     (res_specified && res_matches(db[j], xres, yres))) &&
-		    (!i || db[j].refresh == refresh) &&
-		    !fb_try_mode(var, info, &db[j], bpp))
-		    return 2-i;
+	DPRINTK("Trying specified video mode%s %ix%i\n",
+	    refresh_specified ? "" : " (ignoring refresh rate)", xres, yres);
+
+	diff = refresh;
+	best = -1;
+	for (i = 0; i < dbsize; i++) {
+		if ((name_matches(db[i], name, namelen) &&
+			!fb_try_mode(var, info, &db[i], bpp)))
+			return 1;
+		if (res_specified && res_matches(db[i], xres, yres)) {
+			if(!fb_try_mode(var, info, &db[i], bpp)) {
+				if(!refresh_specified || db[i].refresh == refresh)
+					return 1;
+				else {
+					if(diff > abs(db[i].refresh - refresh)) {
+						diff = abs(db[i].refresh - refresh);
+						best = i;
+					}
+				}
+			}
+		}
+	}
+	if (best != -1) {
+		fb_try_mode(var, info, &db[best], bpp);
+		return 2;
 	}
+
+	diff = xres + yres;
+	best = -1;
 	DPRINTK("Trying best-fit modes\n");
 	for (i = 0; i < dbsize; i++) {
 	    if (xres <= db[i].xres && yres <= db[i].yres) {
diff -Nru a/drivers/video/neofb.c b/drivers/video/neofb.c
--- a/drivers/video/neofb.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/video/neofb.c	2004-12-24 13:37:00 -08:00
@@ -100,18 +100,18 @@
 MODULE_AUTHOR("(c) 2001-2002  Denis Oliver Kropp <dok@convergence.de>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("FBDev driver for NeoMagic PCI Chips");
-MODULE_PARM(internal, "i");
+module_param(internal, bool, 0);
 MODULE_PARM_DESC(internal, "Enable output on internal LCD Display.");
-MODULE_PARM(external, "i");
+module_param(external, bool, 0);
 MODULE_PARM_DESC(external, "Enable output on external CRT.");
-MODULE_PARM(libretto, "i");
+module_param(libretto, bool, 0);
 MODULE_PARM_DESC(libretto, "Force Libretto 100/110 800x480 LCD.");
-MODULE_PARM(nostretch, "i");
+module_param(nostretch, bool, 0);
 MODULE_PARM_DESC(nostretch,
 		 "Disable stretching of modes smaller than LCD.");
-MODULE_PARM(nopciburst, "i");
+module_param(nopciburst, bool, 0);
 MODULE_PARM_DESC(nopciburst, "Disable PCI burst mode.");
-MODULE_PARM(mode_option, "s");
+module_param(mode_option, charp, 0);
 MODULE_PARM_DESC(mode_option, "Preferred video mode ('640x480-8@60', etc)");
 
 #endif
@@ -493,7 +493,7 @@
 	struct neofb_par *par = (struct neofb_par *) info->par;
 	int waitcycles;
 
-	while (par->neo2200->bltStat & 1)
+	while (readl(&par->neo2200->bltStat) & 1)
 		waitcycles++;
 	return 0;
 }
@@ -531,7 +531,7 @@
 				      struct fb_var_screeninfo *var)
 {
 	struct neofb_par *par = (struct neofb_par *) info->par;
-	Neo2200 *neo2200 = par->neo2200;
+	Neo2200 __iomem *neo2200 = par->neo2200;
 	u32 bltMod, pitch;
 
 	neo2200_sync(info);
@@ -556,8 +556,8 @@
 		return;
 	}
 
-	neo2200->bltStat = bltMod << 16;
-	neo2200->pitch = (pitch << 16) | pitch;
+	writel(bltMod << 16, &neo2200->bltStat);
+	writel((pitch << 16) | pitch, &neo2200->pitch);
 }
 
 /* --------------------------------------------------------------------- */
@@ -1340,7 +1340,7 @@
 	int seqflags, lcdflags, dpmsflags, reg;
 
 	switch (blank_mode) {
-	case 4:		/* powerdown - both sync lines down */
+	case FB_BLANK_POWERDOWN:	/* powerdown - both sync lines down */
 		seqflags = VGA_SR01_SCREEN_OFF; /* Disable sequencer */
 		lcdflags = 0;			/* LCD off */
 		dpmsflags = NEO_GR01_SUPPRESS_HSYNC |
@@ -1358,22 +1358,22 @@
 		}
 #endif
 		break;
-	case 3:		/* hsync off */
+	case FB_BLANK_HSYNC_SUSPEND:		/* hsync off */
 		seqflags = VGA_SR01_SCREEN_OFF;	/* Disable sequencer */
 		lcdflags = 0;			/* LCD off */
 		dpmsflags = NEO_GR01_SUPPRESS_HSYNC;
 		break;
-	case 2:		/* vsync off */
+	case FB_BLANK_VSYNC_SUSPEND:		/* vsync off */
 		seqflags = VGA_SR01_SCREEN_OFF;	/* Disable sequencer */
 		lcdflags = 0;			/* LCD off */
 		dpmsflags = NEO_GR01_SUPPRESS_VSYNC;
 		break;
-	case 1:		/* just blank screen (backlight stays on) */
+	case FB_BLANK_NORMAL:		/* just blank screen (backlight stays on) */
 		seqflags = VGA_SR01_SCREEN_OFF;	/* Disable sequencer */
 		lcdflags = par->PanelDispCntlReg1 & 0x02; /* LCD normal */
 		dpmsflags = 0;			/* no hsync/vsync suppression */
 		break;
-	case 0:		/* unblank */
+	case FB_BLANK_UNBLANK:		/* unblank */
 		seqflags = 0;			/* Enable sequencer */
 		lcdflags = par->PanelDispCntlReg1 & 0x02; /* LCD normal */
 		dpmsflags = 0x00;	/* no hsync/vsync suppression */
@@ -1418,27 +1418,27 @@
 	neo2200_wait_fifo(info, 4);
 
 	/* set blt control */
-	par->neo2200->bltCntl = NEO_BC3_FIFO_EN |
-	    NEO_BC0_SRC_IS_FG | NEO_BC3_SKIP_MAPPING |
-	    //               NEO_BC3_DST_XY_ADDR  |
-	    //               NEO_BC3_SRC_XY_ADDR  |
-	    rop;
+	writel(NEO_BC3_FIFO_EN |
+	       NEO_BC0_SRC_IS_FG | NEO_BC3_SKIP_MAPPING |
+	       //               NEO_BC3_DST_XY_ADDR  |
+	       //               NEO_BC3_SRC_XY_ADDR  |
+	       rop, &par->neo2200->bltCntl);
 
 	switch (info->var.bits_per_pixel) {
 	case 8:
-		par->neo2200->fgColor = rect->color;
+		writel(rect->color, &par->neo2200->fgColor);
 		break;
 	case 16:
 	case 24:
-		par->neo2200->fgColor =
-		    ((u32 *) (info->pseudo_palette))[rect->color];
+		writel(((u32 *) (info->pseudo_palette))[rect->color],
+		       &par->neo2200->fgColor);
 		break;
 	}
 
-	par->neo2200->dstStart =
-	    dst * ((info->var.bits_per_pixel + 7) >> 3);
-	par->neo2200->xyExt =
-	    (rect->height << 16) | (rect->width & 0xffff);
+	writel(dst * ((info->var.bits_per_pixel + 7) >> 3),
+	       &par->neo2200->dstStart);
+	writel((rect->height << 16) | (rect->width & 0xffff),
+	       &par->neo2200->xyExt);
 }
 
 static void
@@ -1466,12 +1466,12 @@
 	neo2200_wait_fifo(info, 4);
 
 	/* set blt control */
-	par->neo2200->bltCntl = bltCntl;
+	writel(bltCntl, &par->neo2200->bltCntl);
 
-	par->neo2200->srcStart = src;
-	par->neo2200->dstStart = dst;
-	par->neo2200->xyExt =
-	    (area->height << 16) | (area->width & 0xffff);
+	writel(src, &par->neo2200->srcStart);
+	writel(dst, &par->neo2200->dstStart);
+	writel((area->height << 16) | (area->width & 0xffff),
+	       &par->neo2200->xyExt);
 }
 
 static void
@@ -1509,32 +1509,31 @@
 
 	switch (info->var.bits_per_pixel) {
 	case 8:
-		par->neo2200->fgColor = image->fg_color;
-		par->neo2200->bgColor = image->bg_color;
+		writel(image->fg_color, &par->neo2200->fgColor);
+		writel(image->bg_color, &par->neo2200->bgColor);
 		break;
 	case 16:
 	case 24:
-		par->neo2200->fgColor =
-		    ((u32 *) (info->pseudo_palette))[image->fg_color];
-		par->neo2200->bgColor =
-		    ((u32 *) (info->pseudo_palette))[image->bg_color];
+		writel(((u32 *) (info->pseudo_palette))[image->fg_color],
+		       &par->neo2200->fgColor);
+		writel(((u32 *) (info->pseudo_palette))[image->bg_color],
+		       &par->neo2200->bgColor);
 		break;
 	}
 
-	par->neo2200->bltCntl = NEO_BC0_SYS_TO_VID |
+	writel(NEO_BC0_SYS_TO_VID |
 		NEO_BC3_SKIP_MAPPING | bltCntl_flags |
 		// NEO_BC3_DST_XY_ADDR |
-		0x0c0000;
+		0x0c0000, &par->neo2200->bltCntl);
 
-	par->neo2200->srcStart = 0;
+	writel(0, &par->neo2200->srcStart);
 //      par->neo2200->dstStart = (image->dy << 16) | (image->dx & 0xffff);
-	par->neo2200->dstStart =
-	    ((image->dx & 0xffff) * (info->var.bits_per_pixel >> 3) +
-	     image->dy * info->fix.line_length);
-	par->neo2200->xyExt =
-	    (image->height << 16) | (image->width & 0xffff);
+	writel(((image->dx & 0xffff) * (info->var.bits_per_pixel >> 3) +
+		image->dy * info->fix.line_length), &par->neo2200->dstStart);
+	writel((image->height << 16) | (image->width & 0xffff),
+	       &par->neo2200->xyExt);
 
-	memcpy(par->mmio_vbase + 0x100000, image->data, data_len);
+	memcpy_toio(par->mmio_vbase + 0x100000, image->data, data_len);
 }
 
 static void
@@ -1765,7 +1764,7 @@
 #endif
 
 	/* Clear framebuffer, it's all white in memory after boot */
-	memset(info->screen_base, 0, info->fix.smem_len);
+	memset_io(info->screen_base, 0, info->fix.smem_len);
 
 	/* Allocate Cursor drawing pad.
 	info->fix.smem_len -= PAGE_SIZE;
@@ -1946,7 +1945,7 @@
 		maxWidth = 1280;
 		maxHeight = 1024;	/* ???? */
 
-		par->neo2200 = (Neo2200 *) par->mmio_vbase;
+		par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase;
 		break;
 	case FB_ACCEL_NEOMAGIC_NM2230:
 		videoRam = 3008;
@@ -1957,7 +1956,7 @@
 		maxWidth = 1280;
 		maxHeight = 1024;	/* ???? */
 
-		par->neo2200 = (Neo2200 *) par->mmio_vbase;
+		par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase;
 		break;
 	case FB_ACCEL_NEOMAGIC_NM2360:
 		videoRam = 4096;
@@ -1968,7 +1967,7 @@
 		maxWidth = 1280;
 		maxHeight = 1024;	/* ???? */
 
-		par->neo2200 = (Neo2200 *) par->mmio_vbase;
+		par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase;
 		break;
 	case FB_ACCEL_NEOMAGIC_NM2380:
 		videoRam = 6144;
@@ -1979,7 +1978,7 @@
 		maxWidth = 1280;
 		maxHeight = 1024;	/* ???? */
 
-		par->neo2200 = (Neo2200 *) par->mmio_vbase;
+		par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase;
 		break;
 	}
 /*
diff -Nru a/drivers/video/offb.c b/drivers/video/offb.c
--- a/drivers/video/offb.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/video/offb.c	2004-12-24 13:37:29 -08:00
@@ -47,20 +47,14 @@
 };
 
 struct offb_par {
-	volatile unsigned char *cmap_adr;
-	volatile unsigned char *cmap_data;
+	volatile void __iomem *cmap_adr;
+	volatile void __iomem *cmap_data;
 	int cmap_type;
 	int blanked;
 };
 
 struct offb_par default_par;
 
-#ifdef __powerpc__
-#define mach_eieio()	eieio()
-#else
-#define mach_eieio()	do {} while (0)
-#endif
-
     /*
      *  Interface used by the world
      */
@@ -110,44 +104,36 @@
 
 	switch (par->cmap_type) {
 	case cmap_m64:
-		*par->cmap_adr = regno;
-		mach_eieio();
-		*par->cmap_data = red;
-		mach_eieio();
-		*par->cmap_data = green;
-		mach_eieio();
-		*par->cmap_data = blue;
-		mach_eieio();
+		writeb(regno, par->cmap_adr);
+		writeb(red, par->cmap_data);
+		writeb(green, par->cmap_data);
+		writeb(blue, par->cmap_data);
 		break;
 	case cmap_M3A:
 		/* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */
-		out_le32((unsigned *) (par->cmap_adr + 0x58),
-			 in_le32((unsigned *) (par->cmap_adr +
-					       0x58)) & ~0x20);
+		out_le32(par->cmap_adr + 0x58,
+			 in_le32(par->cmap_adr + 0x58) & ~0x20);
 	case cmap_r128:
 		/* Set palette index & data */
 		out_8(par->cmap_adr + 0xb0, regno);
-		out_le32((unsigned *) (par->cmap_adr + 0xb4),
+		out_le32(par->cmap_adr + 0xb4,
 			 (red << 16 | green << 8 | blue));
 		break;
 	case cmap_M3B:
 		/* Set PALETTE_ACCESS_CNTL in DAC_CNTL */
-		out_le32((unsigned *) (par->cmap_adr + 0x58),
-			 in_le32((unsigned *) (par->cmap_adr +
-					       0x58)) | 0x20);
+		out_le32(par->cmap_adr + 0x58,
+			 in_le32(par->cmap_adr + 0x58) | 0x20);
 		/* Set palette index & data */
 		out_8(par->cmap_adr + 0xb0, regno);
-		out_le32((unsigned *) (par->cmap_adr + 0xb4),
-			 (red << 16 | green << 8 | blue));
+		out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue));
 		break;
 	case cmap_radeon:
 		/* Set palette index & data (could be smarter) */
 		out_8(par->cmap_adr + 0xb0, regno);
-		out_le32((unsigned *) (par->cmap_adr + 0xb4),
-			 (red << 16 | green << 8 | blue));
+		out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue));
 		break;
 	case cmap_gxt2000:
-		out_le32((unsigned *) par->cmap_adr + regno,
+		out_le32((unsigned __iomem *) par->cmap_adr + regno,
 			 (red << 16 | green << 8 | blue));
 		break;
 	}
@@ -191,47 +177,33 @@
 		for (i = 0; i < 256; i++) {
 			switch (par->cmap_type) {
 			case cmap_m64:
-				*par->cmap_adr = i;
-				mach_eieio();
-				for (j = 0; j < 3; j++) {
-					*par->cmap_data = 0;
-					mach_eieio();
-				}
+				writeb(i, par->cmap_adr);
+				for (j = 0; j < 3; j++)
+					writeb(0, par->cmap_data);
 				break;
 			case cmap_M3A:
 				/* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */
-				out_le32((unsigned *) (par->cmap_adr +
-						       0x58),
-					 in_le32((unsigned *) (par->
-							       cmap_adr +
-							       0x58)) &
-					 ~0x20);
+				out_le32(par->cmap_adr + 0x58,
+					 in_le32(par->cmap_adr + 0x58) & ~0x20);
 			case cmap_r128:
 				/* Set palette index & data */
 				out_8(par->cmap_adr + 0xb0, i);
-				out_le32((unsigned *) (par->cmap_adr +
-						       0xb4), 0);
+				out_le32(par->cmap_adr + 0xb4, 0);
 				break;
 			case cmap_M3B:
 				/* Set PALETTE_ACCESS_CNTL in DAC_CNTL */
-				out_le32((unsigned *) (par->cmap_adr +
-						       0x58),
-					 in_le32((unsigned *) (par->
-							       cmap_adr +
-							       0x58)) |
-					 0x20);
+				out_le32(par->cmap_adr + 0x58,
+					 in_le32(par->cmap_adr + 0x58) | 0x20);
 				/* Set palette index & data */
 				out_8(par->cmap_adr + 0xb0, i);
-				out_le32((unsigned *) (par->cmap_adr +
-						       0xb4), 0);
+				out_le32(par->cmap_adr + 0xb4, 0);
 				break;
 			case cmap_radeon:
 				out_8(par->cmap_adr + 0xb0, i);
-				out_le32((unsigned *) (par->cmap_adr +
-						       0xb4), 0);
+				out_le32(par->cmap_adr + 0xb4, 0);
 				break;
 			case cmap_gxt2000:
-				out_le32((unsigned *) par->cmap_adr + i,
+				out_le32((unsigned __iomem *) par->cmap_adr + i,
 					 0);
 				break;
 			}
diff -Nru a/drivers/video/p9100.c b/drivers/video/p9100.c
--- a/drivers/video/p9100.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/video/p9100.c	2004-12-24 13:37:02 -08:00
@@ -129,7 +129,7 @@
 
 struct p9100_par {
 	spinlock_t		lock;
-	struct p9100_regs	*regs;
+	struct p9100_regs	__iomem *regs;
 
 	u32			flags;
 #define P9100_FLAG_BLANKED	0x00000001
@@ -155,7 +155,7 @@
 			   unsigned transp, struct fb_info *info)
 {
 	struct p9100_par *par = (struct p9100_par *) info->par;
-	struct p9100_regs *regs = par->regs;
+	struct p9100_regs __iomem *regs = par->regs;
 	unsigned long flags;
 
 	if (regno >= 256)
@@ -186,24 +186,24 @@
 p9100_blank(int blank, struct fb_info *info)
 {
 	struct p9100_par *par = (struct p9100_par *) info->par;
-	struct p9100_regs *regs = par->regs;
+	struct p9100_regs __iomem *regs = par->regs;
 	unsigned long flags;
 	u32 val;
 
 	spin_lock_irqsave(&par->lock, flags);
 
 	switch (blank) {
-	case 0: /* Unblanking */
+	case FB_BLANK_UNBLANK: /* Unblanking */
 		val = sbus_readl(&regs->vid_screenpaint_timectl1);
 		val |= SCREENPAINT_TIMECTL1_ENABLE_VIDEO;
 		sbus_writel(val, &regs->vid_screenpaint_timectl1);
 		par->flags &= ~P9100_FLAG_BLANKED;
 		break;
 
-	case 1: /* Normal blanking */
-	case 2: /* VESA blank (vsync off) */
-	case 3: /* VESA blank (hsync off) */
-	case 4: /* Poweroff */
+	case FB_BLANK_NORMAL: /* Normal blanking */
+	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
+	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
+	case FB_BLANK_POWERDOWN: /* Poweroff */
 		val = sbus_readl(&regs->vid_screenpaint_timectl1);
 		val &= ~SCREENPAINT_TIMECTL1_ENABLE_VIDEO;
 		sbus_writel(val, &regs->vid_screenpaint_timectl1);
@@ -293,21 +293,18 @@
 				       all->info.var.xres);
 	all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
 
-	all->par.regs = (struct p9100_regs *)
-		sbus_ioremap(&sdev->resource[0], 0,
+	all->par.regs = sbus_ioremap(&sdev->resource[0], 0,
 			     sizeof(struct p9100_regs), "p9100 regs");
 
 	all->info.flags = FBINFO_DEFAULT;
 	all->info.fbops = &p9100_ops;
 #ifdef CONFIG_SPARC32
-	all->info.screen_base = (char *)
+	all->info.screen_base = (char __iomem *)
 		prom_getintdefault(sdev->prom_node, "address", 0);
 #endif
 	if (!all->info.screen_base)
-		all->info.screen_base = (char *)
-			sbus_ioremap(&sdev->resource[2], 0,
+		all->info.screen_base = sbus_ioremap(&sdev->resource[2], 0,
 				     all->par.fbsize, "p9100 ram");
-	all->info.currcon = -1;
 	all->info.par = &all->par;
 
 	p9100_blank(0, &all->info);
diff -Nru a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
--- a/drivers/video/platinumfb.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/video/platinumfb.c	2004-12-24 13:36:47 -08:00
@@ -56,14 +56,14 @@
 	}				palette[256];
 	u32				pseudo_palette[17];
 	
-	volatile struct cmap_regs	*cmap_regs;
+	volatile struct cmap_regs	__iomem *cmap_regs;
 	unsigned long			cmap_regs_phys;
 	
-	volatile struct platinum_regs	*platinum_regs;
+	volatile struct platinum_regs	__iomem *platinum_regs;
 	unsigned long			platinum_regs_phys;
 	
-	__u8				*frame_buffer;
-	volatile __u8			*base_frame_buffer;
+	__u8				__iomem *frame_buffer;
+	volatile __u8			__iomem *base_frame_buffer;
 	unsigned long			frame_buffer_phys;
 	
 	unsigned long			total_vram;
@@ -141,7 +141,7 @@
 	
 	if (pinfo->vmode == 13 && pinfo->cmode > 0)
 		offset = 0x10;
-	info->screen_base = (char *) pinfo->frame_buffer + init->fb_offset + offset;
+	info->screen_base = pinfo->frame_buffer + init->fb_offset + offset;
 	info->fix.smem_start = (pinfo->frame_buffer_phys) + init->fb_offset + offset;
 	info->fix.visual = (pinfo->cmode == CMODE_8) ?
 		FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
@@ -184,7 +184,7 @@
 			      u_int transp, struct fb_info *info)
 {
 	struct fb_info_platinum *pinfo = info->par;
-	volatile struct cmap_regs *cmap_regs = pinfo->cmap_regs;
+	volatile struct cmap_regs __iomem *cmap_regs = pinfo->cmap_regs;
 
 	if (regno > 255)
 		return 1;
@@ -232,7 +232,7 @@
 
 static void set_platinum_clock(struct fb_info_platinum *pinfo)
 {
-	volatile struct cmap_regs *cmap_regs = pinfo->cmap_regs;
+	volatile struct cmap_regs __iomem *cmap_regs = pinfo->cmap_regs;
 	struct platinum_regvals	*init;
 
 	init = platinum_reg_init[pinfo->vmode-1];
@@ -259,8 +259,8 @@
 /* Some things in here probably don't need to be done each time. */
 static void platinum_set_hardware(struct fb_info_platinum *pinfo)
 {
-	volatile struct platinum_regs	*platinum_regs = pinfo->platinum_regs;
-	volatile struct cmap_regs	*cmap_regs = pinfo->cmap_regs;
+	volatile struct platinum_regs	__iomem *platinum_regs = pinfo->platinum_regs;
+	volatile struct cmap_regs	__iomem *cmap_regs = pinfo->cmap_regs;
 	struct platinum_regvals		*init;
 	int				i;
 	int				vmode, cmode;
@@ -312,7 +312,7 @@
 	info->fbops = &platinumfb_ops;
 	info->pseudo_palette = pinfo->pseudo_palette;
         info->flags = FBINFO_DEFAULT;
-	info->screen_base = (char *) pinfo->frame_buffer + 0x20;
+	info->screen_base = pinfo->frame_buffer + 0x20;
 
 	fb_alloc_cmap(&info->cmap, 256, 0);
 
@@ -404,7 +404,7 @@
  */
 static int read_platinum_sense(struct fb_info_platinum *info)
 {
-	volatile struct platinum_regs *platinum_regs = info->platinum_regs;
+	volatile struct platinum_regs __iomem *platinum_regs = info->platinum_regs;
 	int sense;
 
 	out_be32(&platinum_regs->reg[23].r, 7);	/* turn off drivers */
@@ -637,10 +637,10 @@
 		size = dp->addrs[i].size;
 		release_mem_region(addr, size);
 	}
-	iounmap((void *)pinfo->frame_buffer);
-	iounmap((void *)pinfo->platinum_regs);
+	iounmap(pinfo->frame_buffer);
+	iounmap(pinfo->platinum_regs);
 	release_mem_region(pinfo->cmap_regs_phys, 0x1000);
-	iounmap((void *)pinfo->cmap_regs);
+	iounmap(pinfo->cmap_regs);
 
 	framebuffer_release(info);
 
diff -Nru a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c
--- a/drivers/video/pm2fb.c	2004-12-24 13:37:33 -08:00
+++ b/drivers/video/pm2fb.c	2004-12-24 13:37:33 -08:00
@@ -97,8 +97,8 @@
 {
 	pm2type_t	type;		/* Board type */
 	u32		fb_size;	/* framebuffer memory size */
-	unsigned char*	v_fb;		/* virtual address of frame buffer */
-	unsigned char*	v_regs;		/* virtual address of p_regs */
+	unsigned char	__iomem *v_fb;  /* virtual address of frame buffer */
+	unsigned char	__iomem *v_regs;/* virtual address of p_regs */
 	u32 	   	memclock;	/* memclock */
 	u32		video;		/* video flags before blanking */
 };
@@ -149,12 +149,12 @@
  * Utility functions
  */
 
-inline static u32 RD32(unsigned char* base, s32 off)
+inline static u32 RD32(unsigned char __iomem *base, s32 off)
 {
 	return fb_readl(base + off);
 }
 
-inline static void WR32(unsigned char* base, s32 off, u32 v)
+inline static void WR32(unsigned char __iomem *base, s32 off, u32 v)
 {
 	fb_writel(v, base + off);
 }
@@ -877,7 +877,6 @@
 		green = CNVT_TOHW(green, info->var.green.length);
 		blue = CNVT_TOHW(blue, info->var.blue.length);
 		transp = CNVT_TOHW(transp, info->var.transp.length);
-		set_color(par, regno, red, green, blue);
 		break;
 	case FB_VISUAL_DIRECTCOLOR:
 		/* example here assumes 8 bit DAC. Might be different 
@@ -904,12 +903,8 @@
 
 		switch (info->var.bits_per_pixel) {
 		case 8:
-			/* Yes some hand held devices have this. */ 
-           		((u8*)(info->pseudo_palette))[regno] = v;
 			break;	
    		case 16:
-           		((u16*)(info->pseudo_palette))[regno] = v;
-			break;
 		case 24:
 		case 32:	
            		((u32*)(info->pseudo_palette))[regno] = v;
@@ -917,7 +912,9 @@
 		}
 		return 0;
 	}
-	/* ... */
+	else if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR)
+		set_color(par, regno, red, green, blue);
+
 	return 0;
 }
 
@@ -973,24 +970,26 @@
 
 	DPRINTK("blank_mode %d\n", blank_mode);
 
-	/* Turn everything on, then disable as requested. */
-	video |= (PM2F_VIDEO_ENABLE | PM2F_HSYNC_MASK | PM2F_VSYNC_MASK);
-
 	switch (blank_mode) {
-	case 0: 	/* Screen: On; HSync: On, VSync: On */
+	case FB_BLANK_UNBLANK:
+		/* Screen: On */
+		video |= PM2F_VIDEO_ENABLE;
 		break;
-	case 1: 	/* Screen: Off; HSync: On, VSync: On */
+	case FB_BLANK_NORMAL:
+		/* Screen: Off */
 		video &= ~PM2F_VIDEO_ENABLE;
 		break;
-	case 2: /* Screen: Off; HSync: On, VSync: Off */
-		video &= ~(PM2F_VIDEO_ENABLE | PM2F_VSYNC_MASK | PM2F_BLANK_LOW );
-		break;
-	case 3: /* Screen: Off; HSync: Off, VSync: On */
-		video &= ~(PM2F_VIDEO_ENABLE | PM2F_HSYNC_MASK | PM2F_BLANK_LOW );
-		break;
-	case 4: /* Screen: Off; HSync: Off, VSync: Off */
-		video &= ~(PM2F_VIDEO_ENABLE | PM2F_VSYNC_MASK | PM2F_HSYNC_MASK|
-			   PM2F_BLANK_LOW);
+	case FB_BLANK_VSYNC_SUSPEND:
+		/* VSync: Off */
+		video &= ~(PM2F_VSYNC_MASK | PM2F_BLANK_LOW );
+		break;
+	case FB_BLANK_HSYNC_SUSPEND:
+		/* HSync: Off */
+		video &= ~(PM2F_HSYNC_MASK | PM2F_BLANK_LOW );
+		break;
+	case FB_BLANK_POWERDOWN:
+		/* HSync: Off, VSync: Off */
+		video &= ~(PM2F_VSYNC_MASK | PM2F_HSYNC_MASK| PM2F_BLANK_LOW);
 		break;
 	}
 	set_video(par, video);
@@ -1155,10 +1154,10 @@
  err_exit_all:
 	fb_dealloc_cmap(&info->cmap);	
  err_exit_both:    
-	iounmap((void*) pm2fb_fix.smem_start);
+	iounmap(info->screen_base);
 	release_mem_region(pm2fb_fix.smem_start, pm2fb_fix.smem_len);
  err_exit_mmio:
-	iounmap((void*) pm2fb_fix.mmio_start);
+	iounmap(default_par->v_regs);
 	release_mem_region(pm2fb_fix.mmio_start, pm2fb_fix.mmio_len);
  err_exit_neither:
 	framebuffer_release(info);
@@ -1176,12 +1175,13 @@
 {
 	struct fb_info* info = pci_get_drvdata(pdev);
 	struct fb_fix_screeninfo* fix = &info->fix;
-    
+	struct pm2fb_par *par = info->par;
+
 	unregister_framebuffer(info);
     
-	iounmap((void*) fix->smem_start);
+	iounmap(info->screen_base);
 	release_mem_region(fix->smem_start, fix->smem_len);
-	iounmap((void*) fix->mmio_start);
+	iounmap(par->v_regs);
 	release_mem_region(fix->mmio_start, fix->mmio_len);
 
 	pci_set_drvdata(pdev, NULL);
diff -Nru a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
--- a/drivers/video/pvr2fb.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/video/pvr2fb.c	2004-12-24 13:36:18 -08:00
@@ -939,6 +939,7 @@
 
 	pvr2_fix.mmio_start	= pci_resource_start(pdev, 1);
 	pvr2_fix.mmio_len	= pci_resource_len(pdev, 1);
+	fbinfo->device = &pdev->dev;
 
 	return pvr2fb_common_init();
 }
diff -Nru a/drivers/video/pxafb.c b/drivers/video/pxafb.c
--- a/drivers/video/pxafb.c	2004-12-24 13:36:47 -08:00
+++ b/drivers/video/pxafb.c	2004-12-24 13:36:47 -08:00
@@ -371,9 +371,10 @@
 	DPRINTK("pxafb_blank: blank=%d\n", blank);
 
 	switch (blank) {
-	case VESA_POWERDOWN:
-	case VESA_VSYNC_SUSPEND:
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_POWERDOWN:
+	case FB_BLANK_VSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
+	case FB_BLANK_NORMAL:
 		if (fbi->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR ||
 		    fbi->fb.fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
 			for (i = 0; i < fbi->palette_size; i++)
@@ -383,7 +384,7 @@
 		//TODO if (pxafb_blank_helper) pxafb_blank_helper(blank);
 		break;
 
-	case VESA_NO_BLANKING:
+	case FB_BLANK_UNBLANK:
 		//TODO if (pxafb_blank_helper) pxafb_blank_helper(blank);
 		if (fbi->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR ||
 		    fbi->fb.fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
@@ -652,6 +653,7 @@
 
 static void pxafb_setup_gpio(struct pxafb_info *fbi)
 {
+	int gpio, ldd_bits;
         unsigned int lccr0 = fbi->lccr0;
 
 	/*
@@ -662,49 +664,31 @@
 	if ((lccr0 & LCCR0_CMS) == LCCR0_Mono &&
 	    (lccr0 & LCCR0_SDS) == LCCR0_Sngl &&
 	    (lccr0 & LCCR0_DPD) == LCCR0_4PixMono)
-	{
-		// bits 58-61
-		GPDR1 |= (0xf << 26);
-		GAFR1_U = (GAFR1_U & ~(0xff << 20)) | (0xaa << 20);
-
-		// bits 74-77
-		GPDR2 |= (0xf << 10);
-		GAFR2_L = (GAFR2_L & ~(0xff << 20)) | (0xaa << 20);
-	}
+		ldd_bits = 4;
 
 	/* 8 bit interface */
         else if (((lccr0 & LCCR0_CMS) == LCCR0_Mono &&
 		  ((lccr0 & LCCR0_SDS) == LCCR0_Dual || (lccr0 & LCCR0_DPD) == LCCR0_8PixMono)) ||
                  ((lccr0 & LCCR0_CMS) == LCCR0_Color &&
 		  (lccr0 & LCCR0_PAS) == LCCR0_Pas && (lccr0 & LCCR0_SDS) == LCCR0_Sngl))
-	{
-		// bits 58-65
-		GPDR1 |= (0x3f << 26);
-		GPDR2 |= (0x3);
-
-		GAFR1_U = (GAFR1_U & ~(0xfff << 20)) | (0xaaa << 20);
-		GAFR2_L = (GAFR2_L & ~0xf) | (0xa);
-
-		// bits 74-77
-		GPDR2 |= (0xf << 10);
-		GAFR2_L = (GAFR2_L & ~(0xff << 20)) | (0xaa << 20);
-	}
+		ldd_bits = 8;
 
 	/* 16 bit interface */
 	else if ((lccr0 & LCCR0_CMS) == LCCR0_Color &&
 		 ((lccr0 & LCCR0_SDS) == LCCR0_Dual || (lccr0 & LCCR0_PAS) == LCCR0_Act))
-	{
-		// bits 58-77
-		GPDR1 |= (0x3f << 26);
-		GPDR2 |= 0x00003fff;
-
-		GAFR1_U = (GAFR1_U & ~(0xfff << 20)) | (0xaaa << 20);
-		GAFR2_L = (GAFR2_L & 0xf0000000) | 0x0aaaaaaa;
-	}
+		ldd_bits = 16;
 
 	else {
 	        printk(KERN_ERR "pxafb_setup_gpio: unable to determine bits per pixel\n");
+		return;
         }
+
+	for (gpio = 58; ldd_bits; gpio++, ldd_bits--)
+		pxa_gpio_mode(gpio | GPIO_ALT_FN_2_OUT);
+	pxa_gpio_mode(GPIO74_LCD_FCLK_MD);
+	pxa_gpio_mode(GPIO75_LCD_LCLK_MD);
+	pxa_gpio_mode(GPIO76_LCD_PCLK_MD);
+	pxa_gpio_mode(GPIO77_LCD_ACBIAS_MD);
 }
 
 static void pxafb_enable_controller(struct pxafb_info *fbi)
@@ -1043,7 +1027,6 @@
 	fbi->fb.fbops		= &pxafb_ops;
 	fbi->fb.flags		= FBINFO_DEFAULT;
 	fbi->fb.node		= -1;
-	fbi->fb.currcon		= -1;
 
 	addr = fbi;
 	addr = addr + sizeof(struct pxafb_info);
diff -Nru a/drivers/video/radeonfb.c b/drivers/video/radeonfb.c
--- a/drivers/video/radeonfb.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/video/radeonfb.c	2004-12-24 13:37:29 -08:00
@@ -1629,15 +1629,16 @@
 	val2 &= ~(LVDS_DISPLAY_DIS);
 
         switch (blank) {
-                case VESA_NO_BLANKING:
+	        case FB_BLANK_UNBLANK:
+	        case FB_BLANK_NORMAL:
                         break;
-                case VESA_VSYNC_SUSPEND:
+                case FB_BLANK_VSYNC_SUSPEND:
                         val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS);
                         break;
-                case VESA_HSYNC_SUSPEND:
+                case FB_BLANK_HSYNC_SUSPEND:
                         val |= (CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS);
                         break;
-                case VESA_POWERDOWN:
+                case FB_BLANK_POWERDOWN:
                         val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS | 
                                 CRTC_HSYNC_DIS);
 			val2 |= (LVDS_DISPLAY_DIS);
@@ -1654,7 +1655,8 @@
 			break;
 	}
 
-	return 0;
+	/* let fbcon do a soft blank for us */
+	return (blank == FB_BLANK_NORMAL) ? 1 : 0;
 }
 
 
@@ -2247,7 +2249,6 @@
 
 	info = &rinfo->info;
 
-	info->currcon = -1;
 	info->par = rinfo;
 	info->pseudo_palette = rinfo->pseudo_palette;
         info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
@@ -3040,7 +3041,7 @@
 	pci_set_drvdata(pdev, rinfo);
 	rinfo->next = board_list;
 	board_list = rinfo;
-
+	((struct fb_info *) rinfo)->device = &pdev->dev;
 	if (register_framebuffer ((struct fb_info *) rinfo) < 0) {
 		printk ("radeonfb: could not register framebuffer\n");
 		iounmap(rinfo->fb_base);
diff -Nru a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
--- a/drivers/video/riva/fbdev.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/video/riva/fbdev.c	2004-12-24 13:37:02 -08:00
@@ -192,6 +192,8 @@
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
 	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
 	{ 0, } /* terminate list */
 };
 MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl);
@@ -205,6 +207,7 @@
 /* command line data, set in rivafb_setup() */
 static int flatpanel __initdata = -1; /* Autodetect later */
 static int forceCRTC __initdata = -1;
+static int noaccel   __initdata = 0;
 #ifdef CONFIG_MTRR
 static int nomtrr __initdata = 0;
 #endif
@@ -231,7 +234,6 @@
 	.activate	= FB_ACTIVATE_NOW,
 	.height		= -1,
 	.width		= -1,
-	.accel_flags	= FB_ACCELF_TEXT,
 	.pixclock	= 39721,
 	.left_margin	= 40,
 	.right_margin	= 24,
@@ -444,6 +446,8 @@
 	bg = le16_to_cpu(bg);
 	fg = le16_to_cpu(fg);
 
+	w = (w + 1) & ~1;
+
 	for (i = 0; i < h; i++) {
 		b = *data++;
 		reverse_order(&b);
@@ -717,7 +721,7 @@
 		newmode.ext.interlace = 0xff; /* interlace off */
 
 	if (par->riva.Architecture >= NV_ARCH_10)
-		par->riva.CURSOR = (U032 *)(info->screen_base + par->riva.CursorStart);
+		par->riva.CURSOR = (U032 __iomem *)(info->screen_base + par->riva.CursorStart);
 
 	if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
 		newmode.misc_output &= ~0x40;
@@ -731,22 +735,27 @@
 	par->riva.CalcStateExt(&par->riva, &newmode.ext, bpp, width,
 				  hDisplaySize, height, dotClock);
 
-	newmode.ext.scale = par->riva.PRAMDAC[0x00000848/4] & 0xfff000ff;
+	newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) &
+		0xfff000ff;
 	if (par->FlatPanel == 1) {
 		newmode.ext.pixel |= (1 << 7);
 		newmode.ext.scale |= (1 << 8);
 	}
 	if (par->SecondCRTC) {
-		newmode.ext.head  = par->riva.PCRTC0[0x00000860/4] & ~0x00001000;
-		newmode.ext.head2 = par->riva.PCRTC0[0x00002860/4] | 0x00001000;
+		newmode.ext.head  = NV_RD32(par->riva.PCRTC0, 0x00000860) &
+			~0x00001000;
+		newmode.ext.head2 = NV_RD32(par->riva.PCRTC0, 0x00002860) |
+			0x00001000;
 		newmode.ext.crtcOwner = 3;
 		newmode.ext.pllsel |= 0x20000800;
 		newmode.ext.vpll2 = newmode.ext.vpll;
 	} else if (par->riva.twoHeads) {
-		newmode.ext.head  =  par->riva.PCRTC0[0x00000860/4] | 0x00001000;
-		newmode.ext.head2 =  par->riva.PCRTC0[0x00002860/4] & ~0x00001000;
+		newmode.ext.head  =  NV_RD32(par->riva.PCRTC0, 0x00000860) |
+			0x00001000;
+		newmode.ext.head2 =  NV_RD32(par->riva.PCRTC0, 0x00002860) &
+			~0x00001000;
 		newmode.ext.crtcOwner = 0;
-		newmode.ext.vpll2 = par->riva.PRAMDAC0[0x00000520/4];
+		newmode.ext.vpll2 = NV_RD32(par->riva.PRAMDAC0, 0x00000520);
 	}
 	if (par->FlatPanel == 1) {
 		newmode.ext.pixel |= (1 << 7);
@@ -887,10 +896,10 @@
 riva_set_pattern(struct riva_par *par, int clr0, int clr1, int pat0, int pat1)
 {
 	RIVA_FIFO_FREE(par->riva, Patt, 4);
-	par->riva.Patt->Color0        = clr0;
-	par->riva.Patt->Color1        = clr1;
-	par->riva.Patt->Monochrome[0] = pat0;
-	par->riva.Patt->Monochrome[1] = pat1;
+	NV_WR32(&par->riva.Patt->Color0, 0, clr0);
+	NV_WR32(&par->riva.Patt->Color1, 0, clr1);
+	NV_WR32(par->riva.Patt->Monochrome, 0, pat0);
+	NV_WR32(par->riva.Patt->Monochrome, 4, pat1);
 }
 
 /* acceleration routines */
@@ -907,7 +916,7 @@
 {
 	riva_set_pattern(par, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
         RIVA_FIFO_FREE(par->riva, Rop, 1);
-        par->riva.Rop->Rop3 = rop;
+        NV_WR32(&par->riva.Rop->Rop3, 0, rop);
 
 }
 
@@ -916,9 +925,10 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 
 	RIVA_FIFO_FREE(par->riva, Clip, 2);
-	par->riva.Clip->TopLeft     = 0x0;
-	par->riva.Clip->WidthHeight = (info->var.xres_virtual & 0xffff) |
-		(info->var.yres_virtual << 16);
+	NV_WR32(&par->riva.Clip->TopLeft, 0, 0x0);
+	NV_WR32(&par->riva.Clip->WidthHeight, 0,
+		(info->var.xres_virtual & 0xffff) |
+		(info->var.yres_virtual << 16));
 	riva_set_rop_solid(par, 0xcc);
 	wait_for_idle(par);
 }
@@ -1008,8 +1018,6 @@
 			par->state.flags |= VGA_SAVE_CMAP;
 		save_vga(&par->state);
 #endif
-		riva_common_setup(par);
-		RivaGetConfig(&par->riva, par->Chipset);
 		/* vgaHWunlock() + riva unlock (0x7F) */
 		CRTCout(par, 0x11, 0xFF);
 		par->riva.LockUnlock(&par->riva, 0);
@@ -1104,7 +1112,8 @@
 	}
 
 	if (!strictmode) {
-		if (!fb_validate_mode(var, info))
+		if (!info->monspecs.vfmax || !info->monspecs.hfmax ||
+		    !info->monspecs.dclkmax || !fb_validate_mode(var, info))
 			mode_valid = 1;
 	}
 
@@ -1122,7 +1131,7 @@
 		}
 	}
 
-	if (!mode_valid && !list_empty(&info->modelist))
+	if (!mode_valid && info->monspecs.modedb_len)
 		return -EINVAL;
 
 	if (var->xres_virtual < var->xres)
@@ -1157,20 +1166,22 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 
 	NVTRACE_ENTER();
-	riva_common_setup(par);
-	RivaGetConfig(&par->riva, par->Chipset);
 	/* vgaHWunlock() + riva unlock (0x7F) */
 	CRTCout(par, 0x11, 0xFF);
 	par->riva.LockUnlock(&par->riva, 0);
-
 	riva_load_video_mode(info);
-	riva_setup_accel(info);
+	if(!(info->flags & FBINFO_HWACCEL_DISABLED))
+		riva_setup_accel(info);
 	
-	memset_io(par->riva.CURSOR, 0, MAX_CURS * MAX_CURS * 2);
+	par->cursor_reset = 1;
 	info->fix.line_length = (info->var.xres_virtual * (info->var.bits_per_pixel >> 3));
 	info->fix.visual = (info->var.bits_per_pixel == 8) ?
 				FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
 
+	if (info->flags & FBINFO_HWACCEL_DISABLED)
+		info->pixmap.scan_align = 1;
+	else
+		info->pixmap.scan_align = 4;
 	NVTRACE_LEAVE();
 	return 0;
 }
@@ -1234,22 +1245,25 @@
 	vesa = CRTCin(par, 0x1a) & ~0xc0;	/* sync on/off */
 
 	NVTRACE_ENTER();
-	if (blank) {
+
+	if (blank)
 		tmp |= 0x20;
-		switch (blank - 1) {
-		case VESA_NO_BLANKING:
-			break;
-		case VESA_VSYNC_SUSPEND:
-			vesa |= 0x80;
-			break;
-		case VESA_HSYNC_SUSPEND:
-			vesa |= 0x40;
-			break;
-		case VESA_POWERDOWN:
-			vesa |= 0xc0;
-			break;
-		}
+
+	switch (blank) {
+	case FB_BLANK_UNBLANK:
+	case FB_BLANK_NORMAL:
+		break;
+	case FB_BLANK_VSYNC_SUSPEND:
+		vesa |= 0x80;
+		break;
+	case FB_BLANK_HSYNC_SUSPEND:
+		vesa |= 0x40;
+		break;
+	case FB_BLANK_POWERDOWN:
+		vesa |= 0xc0;
+		break;
 	}
+
 	SEQout(par, 0x01, tmp);
 	CRTCout(par, 0x1a, vesa);
 
@@ -1260,6 +1274,7 @@
 #endif
 
 	NVTRACE_LEAVE();
+
 	return 0;
 }
 
@@ -1378,6 +1393,11 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 	u_int color, rop = 0;
 
+	if ((info->flags & FBINFO_HWACCEL_DISABLED)) {
+		cfb_fillrect(info, rect);
+		return;
+	}
+
 	if (info->var.bits_per_pixel == 8)
 		color = rect->color;
 	else {
@@ -1400,14 +1420,14 @@
 	riva_set_rop_solid(par, rop);
 
 	RIVA_FIFO_FREE(par->riva, Bitmap, 1);
-	par->riva.Bitmap->Color1A = color;
+	NV_WR32(&par->riva.Bitmap->Color1A, 0, color);
 
 	RIVA_FIFO_FREE(par->riva, Bitmap, 2);
-	par->riva.Bitmap->UnclippedRectangle[0].TopLeft =
-			(rect->dx << 16) | rect->dy;
+	NV_WR32(&par->riva.Bitmap->UnclippedRectangle[0].TopLeft, 0,
+		(rect->dx << 16) | rect->dy);
 	mb();
-	par->riva.Bitmap->UnclippedRectangle[0].WidthHeight =
-			(rect->width << 16) | rect->height;
+	NV_WR32(&par->riva.Bitmap->UnclippedRectangle[0].WidthHeight, 0,
+		(rect->width << 16) | rect->height);
 	mb();
 	riva_set_rop_solid(par, 0xcc);
 
@@ -1428,11 +1448,19 @@
 {
 	struct riva_par *par = (struct riva_par *) info->par;
 
+	if ((info->flags & FBINFO_HWACCEL_DISABLED)) {
+		cfb_copyarea(info, region);
+		return;
+	}
+
 	RIVA_FIFO_FREE(par->riva, Blt, 3);
-	par->riva.Blt->TopLeftSrc  = (region->sy << 16) | region->sx;
-	par->riva.Blt->TopLeftDst  = (region->dy << 16) | region->dx;
+	NV_WR32(&par->riva.Blt->TopLeftSrc, 0,
+		(region->sy << 16) | region->sx);
+	NV_WR32(&par->riva.Blt->TopLeftDst, 0,
+		(region->dy << 16) | region->dx);
 	mb();
-	par->riva.Blt->WidthHeight = (region->height << 16) | region->width;
+	NV_WR32(&par->riva.Blt->WidthHeight, 0,
+		(region->height << 16) | region->width);
 	mb();
 }
 
@@ -1467,10 +1495,10 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 	u32 fgx = 0, bgx = 0, width, tmp;
 	u8 *cdat = (u8 *) image->data;
-	volatile u32 *d;
+	volatile u32 __iomem *d;
 	int i, size;
 
-	if (image->depth != 1) {
+	if ((info->flags & FBINFO_HWACCEL_DISABLED) || image->depth != 1) {
 		cfb_imageblit(info, image);
 		return;
 	}
@@ -1495,19 +1523,19 @@
 	}
 
 	RIVA_FIFO_FREE(par->riva, Bitmap, 7);
-	par->riva.Bitmap->ClipE.TopLeft     = 
-		(image->dy << 16) | (image->dx & 0xFFFF);
-	par->riva.Bitmap->ClipE.BottomRight = 
+	NV_WR32(&par->riva.Bitmap->ClipE.TopLeft, 0,
+		(image->dy << 16) | (image->dx & 0xFFFF));
+	NV_WR32(&par->riva.Bitmap->ClipE.BottomRight, 0,
 		(((image->dy + image->height) << 16) |
-		 ((image->dx + image->width) & 0xffff));
-	par->riva.Bitmap->Color0E           = bgx;
-	par->riva.Bitmap->Color1E           = fgx;
-	par->riva.Bitmap->WidthHeightInE    = 
-		(image->height << 16) | ((image->width + 31) & ~31);
-	par->riva.Bitmap->WidthHeightOutE   = 
-		(image->height << 16) | ((image->width + 31) & ~31);
-	par->riva.Bitmap->PointE            = 
-		(image->dy << 16) | (image->dx & 0xFFFF);
+		 ((image->dx + image->width) & 0xffff)));
+	NV_WR32(&par->riva.Bitmap->Color0E, 0, bgx);
+	NV_WR32(&par->riva.Bitmap->Color1E, 0, fgx);
+	NV_WR32(&par->riva.Bitmap->WidthHeightInE, 0,
+		(image->height << 16) | ((image->width + 31) & ~31));
+	NV_WR32(&par->riva.Bitmap->WidthHeightOutE, 0,
+		(image->height << 16) | ((image->width + 31) & ~31));
+	NV_WR32(&par->riva.Bitmap->PointE, 0,
+		(image->dy << 16) | (image->dx & 0xFFFF));
 
 	d = &par->riva.Bitmap->MonochromeData01E;
 
@@ -1519,7 +1547,7 @@
 			tmp = *((u32 *)cdat);
 			cdat = (u8 *)((u32 *)cdat + 1);
 			reverse_order(&tmp);
-			d[i] = tmp;
+			NV_WR32(d, i*4, tmp);
 		}
 		size -= 16;
 	}
@@ -1529,7 +1557,7 @@
 			tmp = *((u32 *) cdat);
 			cdat = (u8 *)((u32 *)cdat + 1);
 			reverse_order(&tmp);
-			d[i] = tmp;
+			NV_WR32(d, i*4, tmp);
 		}
 	}
 }
@@ -1552,77 +1580,86 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 	u8 data[MAX_CURS * MAX_CURS/8];
 	u16 fg, bg;
-	int i;
+	int i, set = cursor->set;
+
+	if (cursor->image.width > MAX_CURS ||
+	    cursor->image.height > MAX_CURS)
+		return soft_cursor(info, cursor);
 
 	par->riva.ShowHideCursor(&par->riva, 0);
 
-	if (cursor->set & FB_CUR_SETPOS) {
+	if (par->cursor_reset) {
+		set = FB_CUR_SETALL;
+		par->cursor_reset = 0;
+	}
+
+	if (set & FB_CUR_SETSIZE)
+		memset_io(par->riva.CURSOR, 0, MAX_CURS * MAX_CURS * 2);
+
+	if (set & FB_CUR_SETPOS) {
 		u32 xx, yy, temp;
 
-		info->cursor.image.dx = cursor->image.dx;
-		info->cursor.image.dy = cursor->image.dy;
 		yy = cursor->image.dy - info->var.yoffset;
 		xx = cursor->image.dx - info->var.xoffset;
 		temp = xx & 0xFFFF;
 		temp |= yy << 16;
 
-		par->riva.PRAMDAC[0x0000300/4] = temp;
+		NV_WR32(par->riva.PRAMDAC, 0x0000300, temp);
 	}
 
-	if (cursor->set & FB_CUR_SETSIZE) {
-		info->cursor.image.height = cursor->image.height;
-		info->cursor.image.width = cursor->image.width;
-		memset_io(par->riva.CURSOR, 0, MAX_CURS * MAX_CURS * 2);
-	}
-
-	if (cursor->set & FB_CUR_SETCMAP) {
-		info->cursor.image.bg_color = cursor->image.bg_color;
-		info->cursor.image.fg_color = cursor->image.fg_color;
-	}
 
-	if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETCMAP | FB_CUR_SETCUR)) {
-		u32 bg_idx = info->cursor.image.bg_color;
-		u32 fg_idx = info->cursor.image.fg_color;
-		u32 s_pitch = (info->cursor.image.width+7) >> 3;
+	if (set & (FB_CUR_SETSHAPE | FB_CUR_SETCMAP | FB_CUR_SETIMAGE)) {
+		u32 bg_idx = cursor->image.bg_color;
+		u32 fg_idx = cursor->image.fg_color;
+		u32 s_pitch = (cursor->image.width+7) >> 3;
 		u32 d_pitch = MAX_CURS/8;
 		u8 *dat = (u8 *) cursor->image.data;
-		u8 *msk = (u8 *) info->cursor.mask;
-		u8 src[64];	
+		u8 *msk = (u8 *) cursor->mask;
+		u8 *src;
 		
-		info->cursor.image.data = cursor->image.data;
-		switch (info->cursor.rop) {
-		case ROP_XOR:
-			for (i = 0; i < s_pitch * info->cursor.image.height;
-			     i++)
-				src[i] = dat[i] ^ msk[i];
-			break;
-		case ROP_COPY:
-		default:
-			for (i = 0; i < s_pitch * info->cursor.image.height;
-			     i++)
-				src[i] = dat[i] & msk[i];
-			break;
-		}
-		
-		fb_sysmove_buf_aligned(info, &info->sprite, data, d_pitch, src,
-				       s_pitch, info->cursor.image.height);
-
-		bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) |
-		     ((info->cmap.green[bg_idx] & 0xf8) << 2) |
-		     ((info->cmap.blue[bg_idx] & 0xf8) >> 3) | 1 << 15;
-
-		fg = ((info->cmap.red[fg_idx] & 0xf8) << 7) |
-		     ((info->cmap.green[fg_idx] & 0xf8) << 2) |
-		     ((info->cmap.blue[fg_idx] & 0xf8) >> 3) | 1 << 15;
+		src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC);
 
-		par->riva.LockUnlock(&par->riva, 0);
+		if (src) {
+			switch (cursor->rop) {
+			case ROP_XOR:
+				for (i = 0; i < s_pitch * cursor->image.height;
+				     i++)
+					src[i] = dat[i] ^ msk[i];
+				break;
+			case ROP_COPY:
+			default:
+				for (i = 0; i < s_pitch * cursor->image.height;
+				     i++)
+					src[i] = dat[i] & msk[i];
+				break;
+			}
 
-		rivafb_load_cursor_image(par, data, bg, fg,
-					 info->cursor.image.width, 
-					 info->cursor.image.height);
+			fb_sysmove_buf_aligned(info, &info->pixmap, data,
+					       d_pitch, src, s_pitch,
+					       cursor->image.height);
+
+			bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) |
+				((info->cmap.green[bg_idx] & 0xf8) << 2) |
+				((info->cmap.blue[bg_idx] & 0xf8) >> 3) |
+				1 << 15;
+
+			fg = ((info->cmap.red[fg_idx] & 0xf8) << 7) |
+				((info->cmap.green[fg_idx] & 0xf8) << 2) |
+				((info->cmap.blue[fg_idx] & 0xf8) >> 3) |
+				1 << 15;
+
+			par->riva.LockUnlock(&par->riva, 0);
+
+			rivafb_load_cursor_image(par, data, bg, fg,
+						 cursor->image.width,
+						 cursor->image.height);
+			kfree(src);
+		}
 	}
-	if (info->cursor.enable)
+
+	if (cursor->enable)
 		par->riva.ShowHideCursor(&par->riva, 1);
+
 	return 0;
 }
 
@@ -1670,6 +1707,13 @@
 		    | FBINFO_HWACCEL_FILLRECT
 		    | FBINFO_HWACCEL_IMAGEBLIT
 	            | FBINFO_MISC_MODESWITCHLATE;
+
+	/* Accel seems to not work properly on NV30 yet...*/
+	if ((par->riva.Architecture == NV_ARCH_30) || noaccel) {
+	    	printk(KERN_DEBUG PFX "disabling acceleration\n");
+  		info->flags |= FBINFO_HWACCEL_DISABLED;
+	}
+
 	info->var = rivafb_default_var;
 	info->fix.visual = (info->var.bits_per_pixel == 8) ?
 				FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
@@ -1679,9 +1723,8 @@
 	cmap_len = riva_get_cmap_len(&info->var);
 	fb_alloc_cmap(&info->cmap, cmap_len, 0);	
 
-	info->pixmap.size = 64 * 1024;
+	info->pixmap.size = 8 * 1024;
 	info->pixmap.buf_align = 4;
-	info->pixmap.scan_align = 4;
 	info->pixmap.flags = FB_PIXMAP_SYSTEM;
 	info->var.yres_virtual = -1;
 	NVTRACE_LEAVE();
@@ -1711,13 +1754,14 @@
 			pedid = (unsigned char *)
 				get_property(dp, propnames[i], NULL);
 			if (pedid != NULL) {
-		par->EDID = pedid;
-		return 1;
+				par->EDID = pedid;
+				NVTRACE("LCD found.\n");
+				return 1;
 			}
 		}
 	}
 	NVTRACE_LEAVE();
-		return 0;
+	return 0;
 }
 #endif /* CONFIG_PPC_OF */
 
@@ -1732,7 +1776,7 @@
 	for (i = par->bus; i >= 1; i--) {
 		riva_probe_i2c_connector(par, i, &par->EDID);
 		if (par->EDID) {
-			printk("rivafb: Found EDID Block from BUS %i\n", i);
+			printk(PFX "Found EDID Block from BUS %i\n", i);
 			break;
 		}
 	}
@@ -1771,7 +1815,6 @@
 		var->bits_per_pixel = 8;
 		riva_update_var(var, &modedb);
 	}
-	var->accel_flags |= FB_ACCELF_TEXT;
 	NVTRACE_LEAVE();
 }
 
@@ -1781,10 +1824,10 @@
 	NVTRACE_ENTER();
 #ifdef CONFIG_PPC_OF
 	if (!riva_get_EDID_OF(info, pdev))
-		printk("rivafb: could not retrieve EDID from OF\n");
+		printk(PFX "could not retrieve EDID from OF\n");
 #elif CONFIG_FB_RIVA_I2C
 	if (!riva_get_EDID_i2c(info))
-		printk("rivafb: could not retrieve EDID from DDC/I2C\n");
+		printk(PFX "could not retrieve EDID from DDC/I2C\n");
 #endif
 	NVTRACE_LEAVE();
 }
@@ -1854,35 +1897,37 @@
 {
 	struct riva_par *default_par;
 	struct fb_info *info;
+	int ret;
 
 	NVTRACE_ENTER();
 	assert(pd != NULL);
 
-	info = kmalloc(sizeof(struct fb_info), GFP_KERNEL);
-	if (!info)
-		goto err_out;
-
-	default_par = kmalloc(sizeof(struct riva_par), GFP_KERNEL);
-	if (!default_par)
-		goto err_out_kfree;
-
-	memset(info, 0, sizeof(struct fb_info));
-	memset(default_par, 0, sizeof(struct riva_par));
+	info = framebuffer_alloc(sizeof(struct riva_par), &pd->dev);
+	if (!info) {
+		printk (KERN_ERR PFX "could not allocate memory\n");
+		ret = -ENOMEM;
+		goto err_ret;
+	}
+	default_par = (struct riva_par *) info->par;
 	default_par->pdev = pd;
 
-	info->pixmap.addr = kmalloc(64 * 1024, GFP_KERNEL);
-	if (info->pixmap.addr == NULL)
-		goto err_out_kfree1;
-	memset(info->pixmap.addr, 0, 64 * 1024);
+	info->pixmap.addr = kmalloc(8 * 1024, GFP_KERNEL);
+	if (info->pixmap.addr == NULL) {
+	    	ret = -ENOMEM;
+		goto err_framebuffer_release;
+	}
+	memset(info->pixmap.addr, 0, 8 * 1024);
 
-	if (pci_enable_device(pd)) {
+	ret = pci_enable_device(pd);
+	if (ret < 0) {
 		printk(KERN_ERR PFX "cannot enable PCI device\n");
-		goto err_out_enable;
+		goto err_free_pixmap;
 	}
 
-	if (pci_request_regions(pd, "rivafb")) {
+	ret = pci_request_regions(pd, "rivafb");
+	if (ret < 0) {
 		printk(KERN_ERR PFX "cannot request PCI regions\n");
-		goto err_out_request;
+		goto err_disable_device;
 	}
 
 	default_par->riva.Architecture = riva_get_arch(pd);
@@ -1896,7 +1941,8 @@
 
 	if(default_par->riva.Architecture == 0) {
 		printk(KERN_ERR PFX "unknown NV_ARCH\n");
-		goto err_out_kfree1;
+		ret=-ENODEV;
+		goto err_release_region;
 	}
 	if(default_par->riva.Architecture == NV_ARCH_10 ||
 	   default_par->riva.Architecture == NV_ARCH_20 ||
@@ -1930,11 +1976,10 @@
 					 rivafb_fix.mmio_len);
 	if (!default_par->ctrl_base) {
 		printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
-		goto err_out_free_base0;
+		ret = -EIO;
+		goto err_release_region;
 	}
 
-	info->par = default_par;
-
 	switch (default_par->riva.Architecture) {
 	case NV_ARCH_03:
 		/* Riva128's PRAMIN is in the "framebuffer" space
@@ -1944,24 +1989,25 @@
 		default_par->riva.PRAMIN = ioremap(rivafb_fix.smem_start + 0x00C00000, 0x00008000);
 		if (!default_par->riva.PRAMIN) {
 			printk(KERN_ERR PFX "cannot ioremap PRAMIN region\n");
-			goto err_out_free_nv3_pramin;
+			ret = -EIO;
+			goto err_iounmap_ctrl_base;
 		}
-		rivafb_fix.accel = FB_ACCEL_NV3;
 		break;
 	case NV_ARCH_04:
 	case NV_ARCH_10:
 	case NV_ARCH_20:
 	case NV_ARCH_30:
-		default_par->riva.PCRTC0 = (unsigned *)(default_par->ctrl_base + 0x00600000);
-		default_par->riva.PRAMIN = (unsigned *)(default_par->ctrl_base + 0x00710000);
-		rivafb_fix.accel = FB_ACCEL_NV4;
+		default_par->riva.PCRTC0 =
+			(u32 __iomem *)(default_par->ctrl_base + 0x00600000);
+		default_par->riva.PRAMIN =
+			(u32 __iomem *)(default_par->ctrl_base + 0x00710000);
 		break;
 	}
-
 	riva_common_setup(default_par);
 
 	if (default_par->riva.Architecture == NV_ARCH_03) {
-		default_par->riva.PCRTC = default_par->riva.PCRTC0 = default_par->riva.PGRAPH;
+		default_par->riva.PCRTC = default_par->riva.PCRTC0
+		                        = default_par->riva.PGRAPH;
 	}
 
 	rivafb_fix.smem_len = riva_get_memlen(default_par) * 1024;
@@ -1970,7 +2016,8 @@
 				    rivafb_fix.smem_len);
 	if (!info->screen_base) {
 		printk(KERN_ERR PFX "cannot ioremap FB base\n");
-		goto err_out_free_base1;
+		ret = -EIO;
+		goto err_iounmap_pramin;
 	}
 
 #ifdef CONFIG_MTRR
@@ -1993,19 +2040,19 @@
 	riva_get_EDID(info, pd);
 	riva_get_edidinfo(info);
 
-	if (riva_set_fbinfo(info) < 0) {
+	ret=riva_set_fbinfo(info);
+	if (ret < 0) {
 		printk(KERN_ERR PFX "error setting initial video mode\n");
-		goto err_out_iounmap_fb;
+		goto err_iounmap_screen_base;
 	}
 
 	fb_destroy_modedb(info->monspecs.modedb);
-	info->monspecs.modedb_len = 0;
 	info->monspecs.modedb = NULL;
-
-	if (register_framebuffer(info) < 0) {
+	ret = register_framebuffer(info);
+	if (ret < 0) {
 		printk(KERN_ERR PFX
 			"error registering riva framebuffer\n");
-		goto err_out_iounmap_fb;
+		goto err_iounmap_screen_base;
 	}
 
 	pci_set_drvdata(pd, info);
@@ -2024,28 +2071,26 @@
 	NVTRACE_LEAVE();
 	return 0;
 
-err_out_iounmap_fb:
+err_iounmap_screen_base:
 #ifdef CONFIG_FB_RIVA_I2C
 	riva_delete_i2c_busses((struct riva_par *) info->par);
 #endif
 	iounmap(info->screen_base);
-err_out_free_base1:
+err_iounmap_pramin:
 	if (default_par->riva.Architecture == NV_ARCH_03) 
-		iounmap((caddr_t)default_par->riva.PRAMIN);
-err_out_free_nv3_pramin:
+		iounmap(default_par->riva.PRAMIN);
+err_iounmap_ctrl_base:
 	iounmap(default_par->ctrl_base);
-err_out_free_base0:
+err_release_region:
 	pci_release_regions(pd);
-err_out_request:
+err_disable_device:
 	pci_disable_device(pd);
-err_out_enable:
+err_free_pixmap:
 	kfree(info->pixmap.addr);
-err_out_kfree1:
-	kfree(default_par);
-err_out_kfree:
-	kfree(info);
-err_out:
-	return -ENODEV;
+err_framebuffer_release:
+	framebuffer_release(info);
+err_ret:
+	return ret;
 }
 
 static void __exit rivafb_remove(struct pci_dev *pd)
@@ -2073,12 +2118,11 @@
 	iounmap(par->ctrl_base);
 	iounmap(info->screen_base);
 	if (par->riva.Architecture == NV_ARCH_03)
-		iounmap((caddr_t)par->riva.PRAMIN);
+		iounmap(par->riva.PRAMIN);
 	pci_release_regions(pd);
 	pci_disable_device(pd);
 	kfree(info->pixmap.addr);
-	kfree(par);
-	kfree(info);
+	framebuffer_release(info);
 	pci_set_drvdata(pd, NULL);
 	NVTRACE_LEAVE();
 }
@@ -2115,6 +2159,8 @@
 #endif
 		} else if (!strncmp(this_opt, "strictmode", 10)) {
 			strictmode = 1;
+		} else if (!strncmp(this_opt, "noaccel", 7)) {
+			noaccel = 1;
 		} else
 			mode_option = this_opt;
 	}
@@ -2147,10 +2193,7 @@
 		return -ENODEV;
 	rivafb_setup(option);
 #endif
-	if (pci_register_driver(&rivafb_driver) > 0)
-		return 0;
-	pci_unregister_driver(&rivafb_driver);
-	return -ENODEV;
+	return pci_register_driver(&rivafb_driver);
 }
 
 
@@ -2163,19 +2206,20 @@
 }
 
 module_exit(rivafb_exit);
+#endif /* MODULE */
 
-MODULE_PARM(flatpanel, "i");
+module_param(noaccel, bool, 0);
+MODULE_PARM_DESC(noaccel, "bool: disable acceleration");
+module_param(flatpanel, int, 0);
 MODULE_PARM_DESC(flatpanel, "Enables experimental flat panel support for some chipsets. (0 or 1=enabled) (default=0)");
-MODULE_PARM(forceCRTC, "i");
+module_param(forceCRTC, int, 0);
 MODULE_PARM_DESC(forceCRTC, "Forces usage of a particular CRTC in case autodetection fails. (0 or 1) (default=autodetect)");
-
 #ifdef CONFIG_MTRR
-MODULE_PARM(nomtrr, "i");
+module_param(nomtrr, bool, 0);
 MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)");
 #endif
-MODULE_PARM(strictmode, "i");
+module_param(strictmode, bool, 0);
 MODULE_PARM_DESC(strictmode, "Only use video modes from EDID");
-#endif /* MODULE */
 
 MODULE_AUTHOR("Ani Joshi, maintainer");
 MODULE_DESCRIPTION("Framebuffer driver for nVidia Riva 128, TNT, TNT2, and the GeForce series");
diff -Nru a/drivers/video/riva/nv_driver.c b/drivers/video/riva/nv_driver.c
--- a/drivers/video/riva/nv_driver.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/video/riva/nv_driver.c	2004-12-24 13:37:18 -08:00
@@ -56,32 +56,33 @@
 static Bool 
 riva_is_connected(struct riva_par *par, Bool second)
 {
-	volatile U032 *PRAMDAC = par->riva.PRAMDAC0;
+	volatile U032 __iomem *PRAMDAC = par->riva.PRAMDAC0;
 	U032 reg52C, reg608;
 	Bool present;
 
 	if(second) PRAMDAC += 0x800;
 
-	reg52C = PRAMDAC[0x052C/4];
-	reg608 = PRAMDAC[0x0608/4];
+	reg52C = NV_RD32(PRAMDAC, 0x052C);
+	reg608 = NV_RD32(PRAMDAC, 0x0608);
 
-	PRAMDAC[0x0608/4] = reg608 & ~0x00010000;
+	NV_WR32(PRAMDAC, 0x0608, reg608 & ~0x00010000);
 
-	PRAMDAC[0x052C/4] = reg52C & 0x0000FEEE;
+	NV_WR32(PRAMDAC, 0x052C, reg52C & 0x0000FEEE);
 	mdelay(1); 
-	PRAMDAC[0x052C/4] |= 1;
+	NV_WR32(PRAMDAC, 0x052C, NV_RD32(PRAMDAC, 0x052C) | 1);
 
-	par->riva.PRAMDAC0[0x0610/4] = 0x94050140;
-	par->riva.PRAMDAC0[0x0608/4] |= 0x00001000;
+	NV_WR32(par->riva.PRAMDAC0, 0x0610, 0x94050140);
+	NV_WR32(par->riva.PRAMDAC0, 0x0608, 0x00001000);
 
 	mdelay(1);
 
-	present = (PRAMDAC[0x0608/4] & (1 << 28)) ? TRUE : FALSE;
+	present = (NV_RD32(PRAMDAC, 0x0608) & (1 << 28)) ? TRUE : FALSE;
 
-	par->riva.PRAMDAC0[0x0608/4] &= 0x0000EFFF;
+	NV_WR32(par->riva.PRAMDAC0, 0x0608,
+		NV_RD32(par->riva.PRAMDAC0, 0x0608) & 0x0000EFFF);
 
-	PRAMDAC[0x052C/4] = reg52C;
-	PRAMDAC[0x0608/4] = reg608;
+	NV_WR32(PRAMDAC, 0x052C, reg52C);
+	NV_WR32(PRAMDAC, 0x0608, reg608);
 
 	return present;
 }
@@ -104,12 +105,33 @@
 riva_is_second(struct riva_par *par)
 {
 	if (par->FlatPanel == 1) {
-		switch(par->Chipset) {
-		case NV_CHIP_GEFORCE4_440_GO:
-		case NV_CHIP_GEFORCE4_440_GO_M64:
-		case NV_CHIP_GEFORCE4_420_GO:
-		case NV_CHIP_GEFORCE4_420_GO_M32:
-		case NV_CHIP_QUADRO4_500_GOGL:
+		switch(par->Chipset & 0xffff) {
+		case 0x0174:
+		case 0x0175:
+		case 0x0176:
+		case 0x0177:
+		case 0x0179:
+		case 0x017C:
+		case 0x017D:
+		case 0x0186:
+		case 0x0187:
+		/* this might not be a good default for the chips below */
+		case 0x0286:
+		case 0x028C:
+		case 0x0316:
+		case 0x0317:
+		case 0x031A:
+		case 0x031B:
+		case 0x031C:
+		case 0x031D:
+		case 0x031E:
+		case 0x031F:
+		case 0x0324:
+		case 0x0325:
+		case 0x0328:
+		case 0x0329:
+		case 0x032C:
+		case 0x032D:
 			par->SecondCRTC = TRUE;
 			break;
 		default:
@@ -118,13 +140,14 @@
 		}
 	} else {
 		if(riva_is_connected(par, 0)) {
-			if(par->riva.PRAMDAC0[0x0000052C/4] & 0x100)
+
+			if (NV_RD32(par->riva.PRAMDAC0, 0x0000052C) & 0x100)
 				par->SecondCRTC = TRUE;
 			else
 				par->SecondCRTC = FALSE;
 		} else 
 		if (riva_is_connected(par, 1)) {
-			if(par->riva.PRAMDAC0[0x0000252C/4] & 0x100)
+			if(NV_RD32(par->riva.PRAMDAC0, 0x0000252C) & 0x100)
 				par->SecondCRTC = TRUE;
 			else
 				par->SecondCRTC = FALSE;
@@ -144,13 +167,13 @@
 
 	switch (chip->Architecture) {
 	case NV_ARCH_03:
-		if (chip->PFB[0x00000000/4] & 0x00000020) {
-			if (((chip->PMC[0x00000000/4] & 0xF0) == 0x20)
-			    && ((chip->PMC[0x00000000/4] & 0x0F) >= 0x02)) {
+		if (NV_RD32(chip->PFB, 0x00000000) & 0x00000020) {
+			if (((NV_RD32(chip->PMC, 0x00000000) & 0xF0) == 0x20)
+			    && ((NV_RD32(chip->PMC, 0x00000000)&0x0F)>=0x02)) {
 				/*
 				 * SDRAM 128 ZX.
 				 */
-				switch (chip->PFB[0x00000000/4] & 0x03) {
+				switch (NV_RD32(chip->PFB,0x00000000) & 0x03) {
 				case 2:
 					memlen = 1024 * 4;
 					break;
@@ -168,7 +191,7 @@
 			/*
 			 * SGRAM 128.
 			 */
-			switch (chip->PFB[0x00000000/4] & 0x00000003) {
+			switch (NV_RD32(chip->PFB, 0x00000000) & 0x00000003) {
 			case 0:
 				memlen = 1024 * 8;
 				break;
@@ -182,11 +205,11 @@
 		}        
 		break;
 	case NV_ARCH_04:
-		if (chip->PFB[0x00000000/4] & 0x00000100) {
-			memlen = ((chip->PFB[0x00000000/4] >> 12) & 0x0F) * 
+		if (NV_RD32(chip->PFB, 0x00000000) & 0x00000100) {
+			memlen = ((NV_RD32(chip->PFB, 0x00000000)>>12)&0x0F) *
 				1024 * 2 + 1024 * 2;
 		} else {
-			switch (chip->PFB[0x00000000/4] & 0x00000003) {
+			switch (NV_RD32(chip->PFB, 0x00000000) & 0x00000003) {
 			case 0:
 				memlen = 1024 * 32;
 				break;
@@ -216,7 +239,8 @@
 			pci_read_config_dword(dev, 0x84, &amt);
 			memlen = (((amt >> 4) & 127) + 1) * 1024;
 		} else {
-			switch ((chip->PFB[0x0000020C/4] >> 20) & 0x000000FF){
+			switch ((NV_RD32(chip->PFB, 0x0000020C) >> 20) &
+				0x000000FF){
 			case 0x02:
 				memlen = 1024 * 2;
 				break;
@@ -255,9 +279,9 @@
 
 	switch (chip->Architecture) {
 	case NV_ARCH_03:
-		if (chip->PFB[0x00000000/4] & 0x00000020) {
-			if (((chip->PMC[0x00000000/4] & 0xF0) == 0x20)
-			    && ((chip->PMC[0x00000000/4] & 0x0F) >= 0x02)) {   
+		if (NV_RD32(chip->PFB, 0x00000000) & 0x00000020) {
+			if (((NV_RD32(chip->PMC, 0x00000000) & 0xF0) == 0x20)
+			    && ((NV_RD32(chip->PMC,0x00000000)&0x0F) >= 0x02)) {
 				/*
 				 * SDRAM 128 ZX.
 				 */
@@ -276,7 +300,7 @@
 	case NV_ARCH_10:
 	case NV_ARCH_20:
 	case NV_ARCH_30:
-		switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003) {
+		switch ((NV_RD32(chip->PFB, 0x00000000) >> 3) & 0x00000003) {
 		case 3:
 			dclk = 800000;
 			break;
@@ -293,28 +317,56 @@
 riva_common_setup(struct riva_par *par)
 {
 	par->riva.EnableIRQ = 0;
-	par->riva.PRAMDAC0 = (unsigned *)(par->ctrl_base + 0x00680000);
-	par->riva.PFB = (unsigned *)(par->ctrl_base + 0x00100000);
-	par->riva.PFIFO = (unsigned *)(par->ctrl_base + 0x00002000);
-	par->riva.PGRAPH = (unsigned *)(par->ctrl_base + 0x00400000);
-	par->riva.PEXTDEV = (unsigned *)(par->ctrl_base + 0x00101000);
-	par->riva.PTIMER = (unsigned *)(par->ctrl_base + 0x00009000);
-	par->riva.PMC = (unsigned *)(par->ctrl_base + 0x00000000);
-	par->riva.FIFO = (unsigned *)(par->ctrl_base + 0x00800000);
-	par->riva.PCIO0 = (U008 *)(par->ctrl_base + 0x00601000);
-	par->riva.PDIO0 = (U008 *)(par->ctrl_base + 0x00681000);
-	par->riva.PVIO = (U008 *)(par->ctrl_base + 0x000C0000);
+	par->riva.PRAMDAC0 =
+		(volatile U032 __iomem *)(par->ctrl_base + 0x00680000);
+	par->riva.PFB =
+		(volatile U032 __iomem *)(par->ctrl_base + 0x00100000);
+	par->riva.PFIFO =
+		(volatile U032 __iomem *)(par->ctrl_base + 0x00002000);
+	par->riva.PGRAPH =
+		(volatile U032 __iomem *)(par->ctrl_base + 0x00400000);
+	par->riva.PEXTDEV =
+		(volatile U032 __iomem *)(par->ctrl_base + 0x00101000);
+	par->riva.PTIMER =
+		(volatile U032 __iomem *)(par->ctrl_base + 0x00009000);
+	par->riva.PMC =
+		(volatile U032 __iomem *)(par->ctrl_base + 0x00000000);
+	par->riva.FIFO =
+		(volatile U032 __iomem *)(par->ctrl_base + 0x00800000);
+	par->riva.PCIO0 = par->ctrl_base + 0x00601000;
+	par->riva.PDIO0 = par->ctrl_base + 0x00681000;
+	par->riva.PVIO = par->ctrl_base + 0x000C0000;
 
 	par->riva.IO = (MISCin(par) & 0x01) ? 0x3D0 : 0x3B0;
 	
 	if (par->FlatPanel == -1) {
-		switch (par->Chipset) {
-		case NV_CHIP_GEFORCE4_440_GO:
-		case NV_CHIP_GEFORCE4_440_GO_M64:
-		case NV_CHIP_GEFORCE4_420_GO:
-		case NV_CHIP_GEFORCE4_420_GO_M32:
-		case NV_CHIP_QUADRO4_500_GOGL:
-		case NV_CHIP_GEFORCE2_GO:
+		switch (par->Chipset & 0xffff) {
+		case 0x0112:   /* known laptop chips */
+		case 0x0174:
+		case 0x0175:
+		case 0x0176:
+		case 0x0177:
+		case 0x0179:
+		case 0x017C:
+		case 0x017D:
+		case 0x0186:
+		case 0x0187:
+		case 0x0286:
+		case 0x028C:
+		case 0x0316:
+		case 0x0317:
+		case 0x031A:
+		case 0x031B:
+		case 0x031C:
+		case 0x031D:
+		case 0x031E:
+		case 0x031F:
+		case 0x0324:
+		case 0x0325:
+		case 0x0328:
+		case 0x0329:
+		case 0x032C:
+		case 0x032D:
 			printk(KERN_INFO PFX 
 				"On a laptop.  Assuming Digital Flat Panel\n");
 			par->FlatPanel = 1;
@@ -339,6 +391,11 @@
 	case 0x01F0:
 	case 0x0250:
 	case 0x0280:
+	case 0x0300:
+	case 0x0310:
+	case 0x0320:
+	case 0x0330:
+	case 0x0340:
 		riva_is_second(par);
 		break;
 	default:
@@ -362,5 +419,7 @@
 		par->FlatPanel = 0;
 	}
 	par->riva.flatPanel = (par->FlatPanel > 0) ? TRUE : FALSE;
+
+	RivaGetConfig(&par->riva, par->Chipset);
 }
 
diff -Nru a/drivers/video/riva/riva_hw.c b/drivers/video/riva/riva_hw.c
--- a/drivers/video/riva/riva_hw.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/video/riva/riva_hw.c	2004-12-24 13:37:43 -08:00
@@ -62,21 +62,24 @@
     RIVA_HW_INST *chip
 )
 {
-    return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x000006B0/4] & 0x01));
+    return ((NV_RD32(&chip->Rop->FifoFree, 0) < chip->FifoEmptyCount) ||
+	    NV_RD32(&chip->PGRAPH[0x000006B0/4], 0) & 0x01);
 }
 static int nv4Busy
 (
     RIVA_HW_INST *chip
 )
 {
-    return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x00000700/4] & 0x01));
+    return ((NV_RD32(&chip->Rop->FifoFree, 0) < chip->FifoEmptyCount) ||
+	    NV_RD32(&chip->PGRAPH[0x00000700/4], 0) & 0x01);
 }
 static int nv10Busy
 (
     RIVA_HW_INST *chip
 )
 {
-    return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x00000700/4] & 0x01));
+    return ((NV_RD32(&chip->Rop->FifoFree, 0) < chip->FifoEmptyCount) ||
+	    NV_RD32(&chip->PGRAPH[0x00000700/4], 0) & 0x01);
 }
 
 static void vgaLockUnlock
@@ -616,14 +619,15 @@
     nv3_sim_state sim_data;
     unsigned int M, N, P, pll, MClk;
     
-    pll = chip->PRAMDAC0[0x00000504/4]; 
+    pll = NV_RD32(&chip->PRAMDAC0[0x00000504/4], 0);
     M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
     MClk = (N * chip->CrystalFreqKHz / M) >> P;
     sim_data.pix_bpp        = (char)pixelDepth;
     sim_data.enable_video   = 0;
     sim_data.enable_mp      = 0;
     sim_data.video_scale    = 1;
-    sim_data.memory_width   = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
+    sim_data.memory_width   = (NV_RD32(&chip->PEXTDEV[0x00000000/4], 0) & 0x10) ?
+	128 : 64;
     sim_data.memory_width   = 128;
 
     sim_data.mem_latency    = 9;
@@ -637,7 +641,8 @@
     {
         int  b = fifo_data.graphics_burst_size >> 4;
         *burst = 0;
-        while (b >>= 1) (*burst)++;
+        while (b >>= 1)
+	    (*burst)++;
         *lwm   = fifo_data.graphics_lwm >> 3;
     }
     else
@@ -803,17 +808,18 @@
     nv4_sim_state sim_data;
     unsigned int M, N, P, pll, MClk, NVClk, cfg1;
 
-    pll = chip->PRAMDAC0[0x00000504/4];
+    pll = NV_RD32(&chip->PRAMDAC0[0x00000504/4], 0);
     M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
     MClk  = (N * chip->CrystalFreqKHz / M) >> P;
-    pll = chip->PRAMDAC0[0x00000500/4];
+    pll = NV_RD32(&chip->PRAMDAC0[0x00000500/4], 0);
     M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
     NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
-    cfg1 = chip->PFB[0x00000204/4];
+    cfg1 = NV_RD32(&chip->PFB[0x00000204/4], 0);
     sim_data.pix_bpp        = (char)pixelDepth;
     sim_data.enable_video   = 0;
     sim_data.enable_mp      = 0;
-    sim_data.memory_width   = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
+    sim_data.memory_width   = (NV_RD32(&chip->PEXTDEV[0x00000000/4], 0) & 0x10) ?
+	128 : 64;
     sim_data.mem_latency    = (char)cfg1 & 0x0F;
     sim_data.mem_aligned    = 1;
     sim_data.mem_page_miss  = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
@@ -826,7 +832,8 @@
     {
         int  b = fifo_data.graphics_burst_size >> 4;
         *burst = 0;
-        while (b >>= 1) (*burst)++;
+        while (b >>= 1)
+	    (*burst)++;
         *lwm   = fifo_data.graphics_lwm >> 3;
     }
 }
@@ -1064,18 +1071,20 @@
     nv10_sim_state sim_data;
     unsigned int M, N, P, pll, MClk, NVClk, cfg1;
 
-    pll = chip->PRAMDAC0[0x00000504/4];
+    pll = NV_RD32(&chip->PRAMDAC0[0x00000504/4], 0);
     M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
     MClk  = (N * chip->CrystalFreqKHz / M) >> P;
-    pll = chip->PRAMDAC0[0x00000500/4];
+    pll = NV_RD32(&chip->PRAMDAC0[0x00000500/4], 0);
     M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
     NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
-    cfg1 = chip->PFB[0x00000204/4];
+    cfg1 = NV_RD32(&chip->PFB[0x00000204/4], 0);
     sim_data.pix_bpp        = (char)pixelDepth;
     sim_data.enable_video   = 0;
     sim_data.enable_mp      = 0;
-    sim_data.memory_type    = (chip->PFB[0x00000200/4] & 0x01) ? 1 : 0;
-    sim_data.memory_width   = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
+    sim_data.memory_type    = (NV_RD32(&chip->PFB[0x00000200/4], 0) & 0x01) ?
+	1 : 0;
+    sim_data.memory_width   = (NV_RD32(&chip->PEXTDEV[0x00000000/4], 0) & 0x10) ?
+	128 : 64;
     sim_data.mem_latency    = (char)cfg1 & 0x0F;
     sim_data.mem_aligned    = 1;
     sim_data.mem_page_miss  = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
@@ -1088,7 +1097,8 @@
     {
         int  b = fifo_data.graphics_burst_size >> 4;
         *burst = 0;
-        while (b >>= 1) (*burst)++;
+        while (b >>= 1)
+	    (*burst)++;
         *lwm   = fifo_data.graphics_lwm >> 3;
     }
 }
@@ -1115,7 +1125,7 @@
     if(!uMClkPostDiv) uMClkPostDiv = 4;
     MClk = 400000 / uMClkPostDiv;
 
-    pll = chip->PRAMDAC0[0x00000500/4];
+    pll = NV_RD32(&chip->PRAMDAC0[0x00000500/4], 0);
     M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
     NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
     sim_data.pix_bpp        = (char)pixelDepth;
@@ -1139,7 +1149,8 @@
     {
         int  b = fifo_data.graphics_burst_size >> 4;
         *burst = 0;
-        while (b >>= 1) (*burst)++;
+        while (b >>= 1)
+	    (*burst)++;
         *lwm   = fifo_data.graphics_lwm >> 3;
     }
 }
@@ -1294,7 +1305,7 @@
             state->cursor1  = (chip->CursorStart >> 11) << 2;
             state->cursor2  = chip->CursorStart >> 24;
             state->pllsel   = 0x10000700;
-            state->config   = chip->PFB[0x00000200/4];
+            state->config   = NV_RD32(&chip->PFB[0x00000200/4], 0);
             state->general  = bpp == 16 ? 0x00101100 : 0x00100100;
             state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
             break;
@@ -1320,6 +1331,7 @@
 /*
  * Load fixed function state and pre-calculated/stored state.
  */
+#if 0
 #define LOAD_FIXED_STATE(tbl,dev)                                       \
     for (i = 0; i < sizeof(tbl##Table##dev)/8; i++)                 \
         chip->dev[tbl##Table##dev[i][0]] = tbl##Table##dev[i][1]
@@ -1335,6 +1347,24 @@
 #define LOAD_FIXED_STATE_32BPP(tbl,dev)                                 \
     for (i = 0; i < sizeof(tbl##Table##dev##_32BPP)/8; i++)           \
         chip->dev[tbl##Table##dev##_32BPP[i][0]] = tbl##Table##dev##_32BPP[i][1]
+#endif
+
+#define LOAD_FIXED_STATE(tbl,dev)                                       \
+    for (i = 0; i < sizeof(tbl##Table##dev)/8; i++)                 \
+        NV_WR32(&chip->dev[tbl##Table##dev[i][0]], 0, tbl##Table##dev[i][1])
+#define LOAD_FIXED_STATE_8BPP(tbl,dev)                                  \
+    for (i = 0; i < sizeof(tbl##Table##dev##_8BPP)/8; i++)            \
+        NV_WR32(&chip->dev[tbl##Table##dev##_8BPP[i][0]], 0, tbl##Table##dev##_8BPP[i][1])
+#define LOAD_FIXED_STATE_15BPP(tbl,dev)                                 \
+    for (i = 0; i < sizeof(tbl##Table##dev##_15BPP)/8; i++)           \
+        NV_WR32(&chip->dev[tbl##Table##dev##_15BPP[i][0]], 0, tbl##Table##dev##_15BPP[i][1])
+#define LOAD_FIXED_STATE_16BPP(tbl,dev)                                 \
+    for (i = 0; i < sizeof(tbl##Table##dev##_16BPP)/8; i++)           \
+        NV_WR32(&chip->dev[tbl##Table##dev##_16BPP[i][0]], 0, tbl##Table##dev##_16BPP[i][1])
+#define LOAD_FIXED_STATE_32BPP(tbl,dev)                                 \
+    for (i = 0; i < sizeof(tbl##Table##dev##_32BPP)/8; i++)           \
+        NV_WR32(&chip->dev[tbl##Table##dev##_32BPP[i][0]], 0, tbl##Table##dev##_32BPP[i][1])
+
 static void UpdateFifoState
 (
     RIVA_HW_INST  *chip
@@ -1347,7 +1377,7 @@
         case NV_ARCH_04:
             LOAD_FIXED_STATE(nv4,FIFO);
             chip->Tri03 = NULL;
-            chip->Tri05 = (RivaTexturedTriangle05 *)&(chip->FIFO[0x0000E000/4]);
+            chip->Tri05 = (RivaTexturedTriangle05 __iomem *)&(chip->FIFO[0x0000E000/4]);
             break;
         case NV_ARCH_10:
         case NV_ARCH_20:
@@ -1358,7 +1388,7 @@
             LOAD_FIXED_STATE(nv10tri05,PGRAPH);
             LOAD_FIXED_STATE(nv10,FIFO);
             chip->Tri03 = NULL;
-            chip->Tri05 = (RivaTexturedTriangle05 *)&(chip->FIFO[0x0000E000/4]);
+            chip->Tri05 = (RivaTexturedTriangle05 __iomem *)&(chip->FIFO[0x0000E000/4]);
             break;
     }
 }
@@ -1381,7 +1411,7 @@
             /*
              * Make sure frame buffer config gets set before loading PRAMIN.
              */
-            chip->PFB[0x00000200/4] = state->config;
+            NV_WR32(chip->PFB, 0x00000200, state->config);
             LOAD_FIXED_STATE(nv3,PFIFO);
             LOAD_FIXED_STATE(nv3,PRAMIN);
             LOAD_FIXED_STATE(nv3,PGRAPH);
@@ -1391,7 +1421,7 @@
                 case 16:
                     LOAD_FIXED_STATE_15BPP(nv3,PRAMIN);
                     LOAD_FIXED_STATE_15BPP(nv3,PGRAPH);
-                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
+                    chip->Tri03 = (RivaTexturedTriangle03  __iomem *)&(chip->FIFO[0x0000E000/4]);
                     break;
                 case 24:
                 case 32:
@@ -1407,21 +1437,21 @@
                     break;
             }
             for (i = 0x00000; i < 0x00800; i++)
-                chip->PRAMIN[0x00000502 + i] = (i << 12) | 0x03;
-            chip->PGRAPH[0x00000630/4] = state->offset0;
-            chip->PGRAPH[0x00000634/4] = state->offset1;
-            chip->PGRAPH[0x00000638/4] = state->offset2;
-            chip->PGRAPH[0x0000063C/4] = state->offset3;
-            chip->PGRAPH[0x00000650/4] = state->pitch0;
-            chip->PGRAPH[0x00000654/4] = state->pitch1;
-            chip->PGRAPH[0x00000658/4] = state->pitch2;
-            chip->PGRAPH[0x0000065C/4] = state->pitch3;
+                NV_WR32(&chip->PRAMIN[0x00000502 + i], 0, (i << 12) | 0x03);
+            NV_WR32(chip->PGRAPH, 0x00000630, state->offset0);
+            NV_WR32(chip->PGRAPH, 0x00000634, state->offset1);
+            NV_WR32(chip->PGRAPH, 0x00000638, state->offset2);
+            NV_WR32(chip->PGRAPH, 0x0000063C, state->offset3);
+            NV_WR32(chip->PGRAPH, 0x00000650, state->pitch0);
+            NV_WR32(chip->PGRAPH, 0x00000654, state->pitch1);
+            NV_WR32(chip->PGRAPH, 0x00000658, state->pitch2);
+            NV_WR32(chip->PGRAPH, 0x0000065C, state->pitch3);
             break;
         case NV_ARCH_04:
             /*
              * Make sure frame buffer config gets set before loading PRAMIN.
              */
-            chip->PFB[0x00000200/4] = state->config;
+            NV_WR32(chip->PFB, 0x00000200, state->config);
             LOAD_FIXED_STATE(nv4,PFIFO);
             LOAD_FIXED_STATE(nv4,PRAMIN);
             LOAD_FIXED_STATE(nv4,PGRAPH);
@@ -1430,12 +1460,12 @@
                 case 15:
                     LOAD_FIXED_STATE_15BPP(nv4,PRAMIN);
                     LOAD_FIXED_STATE_15BPP(nv4,PGRAPH);
-                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
+                    chip->Tri03 = (RivaTexturedTriangle03  __iomem *)&(chip->FIFO[0x0000E000/4]);
                     break;
                 case 16:
                     LOAD_FIXED_STATE_16BPP(nv4,PRAMIN);
                     LOAD_FIXED_STATE_16BPP(nv4,PGRAPH);
-                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
+                    chip->Tri03 = (RivaTexturedTriangle03  __iomem *)&(chip->FIFO[0x0000E000/4]);
                     break;
                 case 24:
                 case 32:
@@ -1450,14 +1480,14 @@
                     chip->Tri03 = NULL;
                     break;
             }
-            chip->PGRAPH[0x00000640/4] = state->offset0;
-            chip->PGRAPH[0x00000644/4] = state->offset1;
-            chip->PGRAPH[0x00000648/4] = state->offset2;
-            chip->PGRAPH[0x0000064C/4] = state->offset3;
-            chip->PGRAPH[0x00000670/4] = state->pitch0;
-            chip->PGRAPH[0x00000674/4] = state->pitch1;
-            chip->PGRAPH[0x00000678/4] = state->pitch2;
-            chip->PGRAPH[0x0000067C/4] = state->pitch3;
+            NV_WR32(chip->PGRAPH, 0x00000640, state->offset0);
+            NV_WR32(chip->PGRAPH, 0x00000644, state->offset1);
+            NV_WR32(chip->PGRAPH, 0x00000648, state->offset2);
+            NV_WR32(chip->PGRAPH, 0x0000064C, state->offset3);
+            NV_WR32(chip->PGRAPH, 0x00000670, state->pitch0);
+            NV_WR32(chip->PGRAPH, 0x00000674, state->pitch1);
+            NV_WR32(chip->PGRAPH, 0x00000678, state->pitch2);
+            NV_WR32(chip->PGRAPH, 0x0000067C, state->pitch3);
             break;
         case NV_ARCH_10:
         case NV_ARCH_20:
@@ -1476,12 +1506,12 @@
                 case 15:
                     LOAD_FIXED_STATE_15BPP(nv10,PRAMIN);
                     LOAD_FIXED_STATE_15BPP(nv10,PGRAPH);
-                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
+                    chip->Tri03 = (RivaTexturedTriangle03  __iomem *)&(chip->FIFO[0x0000E000/4]);
                     break;
                 case 16:
                     LOAD_FIXED_STATE_16BPP(nv10,PRAMIN);
                     LOAD_FIXED_STATE_16BPP(nv10,PGRAPH);
-                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
+                    chip->Tri03 = (RivaTexturedTriangle03  __iomem *)&(chip->FIFO[0x0000E000/4]);
                     break;
                 case 24:
                 case 32:
@@ -1498,134 +1528,134 @@
             }
 
             if(chip->Architecture == NV_ARCH_10) {
-                chip->PGRAPH[0x00000640/4] = state->offset0;
-                chip->PGRAPH[0x00000644/4] = state->offset1;
-                chip->PGRAPH[0x00000648/4] = state->offset2;
-                chip->PGRAPH[0x0000064C/4] = state->offset3;
-                chip->PGRAPH[0x00000670/4] = state->pitch0;
-                chip->PGRAPH[0x00000674/4] = state->pitch1;
-                chip->PGRAPH[0x00000678/4] = state->pitch2;
-                chip->PGRAPH[0x0000067C/4] = state->pitch3;
-                chip->PGRAPH[0x00000680/4] = state->pitch3;
+                NV_WR32(chip->PGRAPH, 0x00000640, state->offset0);
+                NV_WR32(chip->PGRAPH, 0x00000644, state->offset1);
+                NV_WR32(chip->PGRAPH, 0x00000648, state->offset2);
+                NV_WR32(chip->PGRAPH, 0x0000064C, state->offset3);
+                NV_WR32(chip->PGRAPH, 0x00000670, state->pitch0);
+                NV_WR32(chip->PGRAPH, 0x00000674, state->pitch1);
+                NV_WR32(chip->PGRAPH, 0x00000678, state->pitch2);
+                NV_WR32(chip->PGRAPH, 0x0000067C, state->pitch3);
+                NV_WR32(chip->PGRAPH, 0x00000680, state->pitch3);
         } else {
-        chip->PGRAPH[0x00000820/4] = state->offset0;
-        chip->PGRAPH[0x00000824/4] = state->offset1;
-        chip->PGRAPH[0x00000828/4] = state->offset2;
-        chip->PGRAPH[0x0000082C/4] = state->offset3;
-        chip->PGRAPH[0x00000850/4] = state->pitch0;
-        chip->PGRAPH[0x00000854/4] = state->pitch1;
-        chip->PGRAPH[0x00000858/4] = state->pitch2;
-        chip->PGRAPH[0x0000085C/4] = state->pitch3;
-        chip->PGRAPH[0x00000860/4] = state->pitch3;
-        chip->PGRAPH[0x00000864/4] = state->pitch3;
-        chip->PGRAPH[0x000009A4/4] = chip->PFB[0x00000200/4];
-        chip->PGRAPH[0x000009A8/4] = chip->PFB[0x00000204/4];
+        NV_WR32(chip->PGRAPH, 0x00000820, state->offset0);
+        NV_WR32(chip->PGRAPH, 0x00000824, state->offset1);
+        NV_WR32(chip->PGRAPH, 0x00000828, state->offset2);
+        NV_WR32(chip->PGRAPH, 0x0000082C, state->offset3);
+        NV_WR32(chip->PGRAPH, 0x00000850, state->pitch0);
+        NV_WR32(chip->PGRAPH, 0x00000854, state->pitch1);
+        NV_WR32(chip->PGRAPH, 0x00000858, state->pitch2);
+        NV_WR32(chip->PGRAPH, 0x0000085C, state->pitch3);
+        NV_WR32(chip->PGRAPH, 0x00000860, state->pitch3);
+        NV_WR32(chip->PGRAPH, 0x00000864, state->pitch3);
+        NV_WR32(chip->PGRAPH, 0x000009A4, NV_RD32(chip->PFB, 0x00000200));
+        NV_WR32(chip->PGRAPH, 0x000009A8, NV_RD32(chip->PFB, 0x00000204));
         }
             if(chip->twoHeads) {
-               chip->PCRTC0[0x00000860/4] = state->head;
-               chip->PCRTC0[0x00002860/4] = state->head2;
+               NV_WR32(chip->PCRTC0, 0x00000860, state->head);
+               NV_WR32(chip->PCRTC0, 0x00002860, state->head2);
             }
-            chip->PRAMDAC[0x00000404/4] |= (1 << 25);
+            NV_WR32(chip->PRAMDAC, 0x00000404, NV_RD32(chip->PRAMDAC, 0x00000404) | (1 << 25));
 
-            chip->PMC[0x00008704/4] = 1;
-            chip->PMC[0x00008140/4] = 0;
-            chip->PMC[0x00008920/4] = 0;
-            chip->PMC[0x00008924/4] = 0;
-            chip->PMC[0x00008908/4] = 0x01ffffff;
-            chip->PMC[0x0000890C/4] = 0x01ffffff;
-            chip->PMC[0x00001588/4] = 0;
-
-            chip->PFB[0x00000240/4] = 0;
-            chip->PFB[0x00000244/4] = 0;
-            chip->PFB[0x00000248/4] = 0;
-            chip->PFB[0x0000024C/4] = 0;
-            chip->PFB[0x00000250/4] = 0;
-            chip->PFB[0x00000254/4] = 0;
-            chip->PFB[0x00000258/4] = 0;
-            chip->PFB[0x0000025C/4] = 0;
-
-            chip->PGRAPH[0x00000B00/4] = chip->PFB[0x00000240/4];
-            chip->PGRAPH[0x00000B04/4] = chip->PFB[0x00000244/4];
-            chip->PGRAPH[0x00000B08/4] = chip->PFB[0x00000248/4];
-            chip->PGRAPH[0x00000B0C/4] = chip->PFB[0x0000024C/4];
-            chip->PGRAPH[0x00000B10/4] = chip->PFB[0x00000250/4];
-            chip->PGRAPH[0x00000B14/4] = chip->PFB[0x00000254/4];
-            chip->PGRAPH[0x00000B18/4] = chip->PFB[0x00000258/4];
-            chip->PGRAPH[0x00000B1C/4] = chip->PFB[0x0000025C/4];
-            chip->PGRAPH[0x00000B20/4] = chip->PFB[0x00000260/4];
-            chip->PGRAPH[0x00000B24/4] = chip->PFB[0x00000264/4];
-            chip->PGRAPH[0x00000B28/4] = chip->PFB[0x00000268/4];
-            chip->PGRAPH[0x00000B2C/4] = chip->PFB[0x0000026C/4];
-            chip->PGRAPH[0x00000B30/4] = chip->PFB[0x00000270/4];
-            chip->PGRAPH[0x00000B34/4] = chip->PFB[0x00000274/4];
-            chip->PGRAPH[0x00000B38/4] = chip->PFB[0x00000278/4];
-            chip->PGRAPH[0x00000B3C/4] = chip->PFB[0x0000027C/4];
-            chip->PGRAPH[0x00000B40/4] = chip->PFB[0x00000280/4];
-            chip->PGRAPH[0x00000B44/4] = chip->PFB[0x00000284/4];
-            chip->PGRAPH[0x00000B48/4] = chip->PFB[0x00000288/4];
-            chip->PGRAPH[0x00000B4C/4] = chip->PFB[0x0000028C/4];
-            chip->PGRAPH[0x00000B50/4] = chip->PFB[0x00000290/4];
-            chip->PGRAPH[0x00000B54/4] = chip->PFB[0x00000294/4];
-            chip->PGRAPH[0x00000B58/4] = chip->PFB[0x00000298/4];
-            chip->PGRAPH[0x00000B5C/4] = chip->PFB[0x0000029C/4];
-            chip->PGRAPH[0x00000B60/4] = chip->PFB[0x000002A0/4];
-            chip->PGRAPH[0x00000B64/4] = chip->PFB[0x000002A4/4];
-            chip->PGRAPH[0x00000B68/4] = chip->PFB[0x000002A8/4];
-            chip->PGRAPH[0x00000B6C/4] = chip->PFB[0x000002AC/4];
-            chip->PGRAPH[0x00000B70/4] = chip->PFB[0x000002B0/4];
-            chip->PGRAPH[0x00000B74/4] = chip->PFB[0x000002B4/4];
-            chip->PGRAPH[0x00000B78/4] = chip->PFB[0x000002B8/4];
-            chip->PGRAPH[0x00000B7C/4] = chip->PFB[0x000002BC/4];
-            chip->PGRAPH[0x00000F40/4] = 0x10000000;
-            chip->PGRAPH[0x00000F44/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00000040;
-            chip->PGRAPH[0x00000F54/4] = 0x00000008;
-            chip->PGRAPH[0x00000F50/4] = 0x00000200;
+            NV_WR32(chip->PMC, 0x00008704, 1);
+            NV_WR32(chip->PMC, 0x00008140, 0);
+            NV_WR32(chip->PMC, 0x00008920, 0);
+            NV_WR32(chip->PMC, 0x00008924, 0);
+            NV_WR32(chip->PMC, 0x00008908, 0x01ffffff);
+            NV_WR32(chip->PMC, 0x0000890C, 0x01ffffff);
+            NV_WR32(chip->PMC, 0x00001588, 0);
+
+            NV_WR32(chip->PFB, 0x00000240, 0);
+            NV_WR32(chip->PFB, 0x00000250, 0);
+            NV_WR32(chip->PFB, 0x00000260, 0);
+            NV_WR32(chip->PFB, 0x00000270, 0);
+            NV_WR32(chip->PFB, 0x00000280, 0);
+            NV_WR32(chip->PFB, 0x00000290, 0);
+            NV_WR32(chip->PFB, 0x000002A0, 0);
+            NV_WR32(chip->PFB, 0x000002B0, 0);
+
+            NV_WR32(chip->PGRAPH, 0x00000B00, NV_RD32(chip->PFB, 0x00000240));
+            NV_WR32(chip->PGRAPH, 0x00000B04, NV_RD32(chip->PFB, 0x00000244));
+            NV_WR32(chip->PGRAPH, 0x00000B08, NV_RD32(chip->PFB, 0x00000248));
+            NV_WR32(chip->PGRAPH, 0x00000B0C, NV_RD32(chip->PFB, 0x0000024C));
+            NV_WR32(chip->PGRAPH, 0x00000B10, NV_RD32(chip->PFB, 0x00000250));
+            NV_WR32(chip->PGRAPH, 0x00000B14, NV_RD32(chip->PFB, 0x00000254));
+            NV_WR32(chip->PGRAPH, 0x00000B18, NV_RD32(chip->PFB, 0x00000258));
+            NV_WR32(chip->PGRAPH, 0x00000B1C, NV_RD32(chip->PFB, 0x0000025C));
+            NV_WR32(chip->PGRAPH, 0x00000B20, NV_RD32(chip->PFB, 0x00000260));
+            NV_WR32(chip->PGRAPH, 0x00000B24, NV_RD32(chip->PFB, 0x00000264));
+            NV_WR32(chip->PGRAPH, 0x00000B28, NV_RD32(chip->PFB, 0x00000268));
+            NV_WR32(chip->PGRAPH, 0x00000B2C, NV_RD32(chip->PFB, 0x0000026C));
+            NV_WR32(chip->PGRAPH, 0x00000B30, NV_RD32(chip->PFB, 0x00000270));
+            NV_WR32(chip->PGRAPH, 0x00000B34, NV_RD32(chip->PFB, 0x00000274));
+            NV_WR32(chip->PGRAPH, 0x00000B38, NV_RD32(chip->PFB, 0x00000278));
+            NV_WR32(chip->PGRAPH, 0x00000B3C, NV_RD32(chip->PFB, 0x0000027C));
+            NV_WR32(chip->PGRAPH, 0x00000B40, NV_RD32(chip->PFB, 0x00000280));
+            NV_WR32(chip->PGRAPH, 0x00000B44, NV_RD32(chip->PFB, 0x00000284));
+            NV_WR32(chip->PGRAPH, 0x00000B48, NV_RD32(chip->PFB, 0x00000288));
+            NV_WR32(chip->PGRAPH, 0x00000B4C, NV_RD32(chip->PFB, 0x0000028C));
+            NV_WR32(chip->PGRAPH, 0x00000B50, NV_RD32(chip->PFB, 0x00000290));
+            NV_WR32(chip->PGRAPH, 0x00000B54, NV_RD32(chip->PFB, 0x00000294));
+            NV_WR32(chip->PGRAPH, 0x00000B58, NV_RD32(chip->PFB, 0x00000298));
+            NV_WR32(chip->PGRAPH, 0x00000B5C, NV_RD32(chip->PFB, 0x0000029C));
+            NV_WR32(chip->PGRAPH, 0x00000B60, NV_RD32(chip->PFB, 0x000002A0));
+            NV_WR32(chip->PGRAPH, 0x00000B64, NV_RD32(chip->PFB, 0x000002A4));
+            NV_WR32(chip->PGRAPH, 0x00000B68, NV_RD32(chip->PFB, 0x000002A8));
+            NV_WR32(chip->PGRAPH, 0x00000B6C, NV_RD32(chip->PFB, 0x000002AC));
+            NV_WR32(chip->PGRAPH, 0x00000B70, NV_RD32(chip->PFB, 0x000002B0));
+            NV_WR32(chip->PGRAPH, 0x00000B74, NV_RD32(chip->PFB, 0x000002B4));
+            NV_WR32(chip->PGRAPH, 0x00000B78, NV_RD32(chip->PFB, 0x000002B8));
+            NV_WR32(chip->PGRAPH, 0x00000B7C, NV_RD32(chip->PFB, 0x000002BC));
+            NV_WR32(chip->PGRAPH, 0x00000F40, 0x10000000);
+            NV_WR32(chip->PGRAPH, 0x00000F44, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00000040);
+            NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000008);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00000200);
             for (i = 0; i < (3*16); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00000040;
-            chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00000800;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00000040);
+            NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00000800);
             for (i = 0; i < (16*16); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F40/4] = 0x30000000;
-            chip->PGRAPH[0x00000F44/4] = 0x00000004;
-            chip->PGRAPH[0x00000F50/4] = 0x00006400;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F40, 0x30000000);
+            NV_WR32(chip->PGRAPH, 0x00000F44, 0x00000004);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00006400);
             for (i = 0; i < (59*4); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00006800;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00006800);
             for (i = 0; i < (47*4); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00006C00;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00006C00);
             for (i = 0; i < (3*4); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00007000;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00007000);
             for (i = 0; i < (19*4); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00007400;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00007400);
             for (i = 0; i < (12*4); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00007800;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00007800);
             for (i = 0; i < (12*4); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00004400;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00004400);
             for (i = 0; i < (8*4); i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00000000;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00000000);
             for (i = 0; i < 16; i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
-            chip->PGRAPH[0x00000F50/4] = 0x00000040;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
+            NV_WR32(chip->PGRAPH, 0x00000F50, 0x00000040);
             for (i = 0; i < 4; i++)
-                chip->PGRAPH[0x00000F54/4] = 0x00000000;
+                NV_WR32(chip->PGRAPH, 0x00000F54, 0x00000000);
 
-            chip->PCRTC[0x00000810/4] = state->cursorConfig;
+            NV_WR32(chip->PCRTC, 0x00000810, state->cursorConfig);
 
             if(chip->flatPanel) {
                if((chip->Chipset & 0x0ff0) == 0x0110) {
-                   chip->PRAMDAC[0x0528/4] = state->dither;
+                   NV_WR32(chip->PRAMDAC, 0x0528, state->dither);
                } else 
                if((chip->Chipset & 0x0ff0) >= 0x0170) {
-                   chip->PRAMDAC[0x083C/4] = state->dither;
+                   NV_WR32(chip->PRAMDAC, 0x083C, state->dither);
                }
             
                VGA_WR08(chip->PCIO, 0x03D4, 0x53);
@@ -1668,24 +1698,24 @@
     VGA_WR08(chip->PCIO, 0x03D5, state->interlace);
 
     if(!chip->flatPanel) {
-       chip->PRAMDAC0[0x00000508/4] = state->vpll;
-       chip->PRAMDAC0[0x0000050C/4] = state->pllsel;
+       NV_WR32(chip->PRAMDAC0, 0x00000508, state->vpll);
+       NV_WR32(chip->PRAMDAC0, 0x0000050C, state->pllsel);
        if(chip->twoHeads)
-          chip->PRAMDAC0[0x00000520/4] = state->vpll2;
+          NV_WR32(chip->PRAMDAC0, 0x00000520, state->vpll2);
     }  else {
-       chip->PRAMDAC[0x00000848/4]  = state->scale;
+       NV_WR32(chip->PRAMDAC, 0x00000848 , state->scale);
     }  
-    chip->PRAMDAC[0x00000600/4]  = state->general;
+    NV_WR32(chip->PRAMDAC, 0x00000600 , state->general);
 
     /*
      * Turn off VBlank enable and reset.
      */
-    chip->PCRTC[0x00000140/4] = 0;
-    chip->PCRTC[0x00000100/4] = chip->VBlankBit;
+    NV_WR32(chip->PCRTC, 0x00000140, 0);
+    NV_WR32(chip->PCRTC, 0x00000100, chip->VBlankBit);
     /*
      * Set interrupt enable.
      */    
-    chip->PMC[0x00000140/4]  = chip->EnableIRQ & 0x01;
+    NV_WR32(chip->PMC, 0x00000140, chip->EnableIRQ & 0x01);
     /*
      * Set current state pointer.
      */
@@ -1695,7 +1725,7 @@
      */
     chip->FifoFreeCount  = 0;
     /* Free count from first subchannel */
-    chip->FifoEmptyCount = chip->Rop->FifoFree; 
+    chip->FifoEmptyCount = NV_RD32(&chip->Rop->FifoFree, 0);
 }
 static void UnloadStateExt
 (
@@ -1728,60 +1758,60 @@
     state->cursor2      = VGA_RD08(chip->PCIO, 0x03D5);
     VGA_WR08(chip->PCIO, 0x03D4, 0x39);
     state->interlace    = VGA_RD08(chip->PCIO, 0x03D5);
-    state->vpll         = chip->PRAMDAC0[0x00000508/4];
-    state->vpll2        = chip->PRAMDAC0[0x00000520/4];
-    state->pllsel       = chip->PRAMDAC0[0x0000050C/4];
-    state->general      = chip->PRAMDAC[0x00000600/4];
-    state->scale        = chip->PRAMDAC[0x00000848/4];
-    state->config       = chip->PFB[0x00000200/4];
+    state->vpll         = NV_RD32(chip->PRAMDAC0, 0x00000508);
+    state->vpll2        = NV_RD32(chip->PRAMDAC0, 0x00000520);
+    state->pllsel       = NV_RD32(chip->PRAMDAC0, 0x0000050C);
+    state->general      = NV_RD32(chip->PRAMDAC, 0x00000600);
+    state->scale        = NV_RD32(chip->PRAMDAC, 0x00000848);
+    state->config       = NV_RD32(chip->PFB, 0x00000200);
     switch (chip->Architecture)
     {
         case NV_ARCH_03:
-            state->offset0  = chip->PGRAPH[0x00000630/4];
-            state->offset1  = chip->PGRAPH[0x00000634/4];
-            state->offset2  = chip->PGRAPH[0x00000638/4];
-            state->offset3  = chip->PGRAPH[0x0000063C/4];
-            state->pitch0   = chip->PGRAPH[0x00000650/4];
-            state->pitch1   = chip->PGRAPH[0x00000654/4];
-            state->pitch2   = chip->PGRAPH[0x00000658/4];
-            state->pitch3   = chip->PGRAPH[0x0000065C/4];
+            state->offset0  = NV_RD32(chip->PGRAPH, 0x00000630);
+            state->offset1  = NV_RD32(chip->PGRAPH, 0x00000634);
+            state->offset2  = NV_RD32(chip->PGRAPH, 0x00000638);
+            state->offset3  = NV_RD32(chip->PGRAPH, 0x0000063C);
+            state->pitch0   = NV_RD32(chip->PGRAPH, 0x00000650);
+            state->pitch1   = NV_RD32(chip->PGRAPH, 0x00000654);
+            state->pitch2   = NV_RD32(chip->PGRAPH, 0x00000658);
+            state->pitch3   = NV_RD32(chip->PGRAPH, 0x0000065C);
             break;
         case NV_ARCH_04:
-            state->offset0  = chip->PGRAPH[0x00000640/4];
-            state->offset1  = chip->PGRAPH[0x00000644/4];
-            state->offset2  = chip->PGRAPH[0x00000648/4];
-            state->offset3  = chip->PGRAPH[0x0000064C/4];
-            state->pitch0   = chip->PGRAPH[0x00000670/4];
-            state->pitch1   = chip->PGRAPH[0x00000674/4];
-            state->pitch2   = chip->PGRAPH[0x00000678/4];
-            state->pitch3   = chip->PGRAPH[0x0000067C/4];
+            state->offset0  = NV_RD32(chip->PGRAPH, 0x00000640);
+            state->offset1  = NV_RD32(chip->PGRAPH, 0x00000644);
+            state->offset2  = NV_RD32(chip->PGRAPH, 0x00000648);
+            state->offset3  = NV_RD32(chip->PGRAPH, 0x0000064C);
+            state->pitch0   = NV_RD32(chip->PGRAPH, 0x00000670);
+            state->pitch1   = NV_RD32(chip->PGRAPH, 0x00000674);
+            state->pitch2   = NV_RD32(chip->PGRAPH, 0x00000678);
+            state->pitch3   = NV_RD32(chip->PGRAPH, 0x0000067C);
             break;
         case NV_ARCH_10:
         case NV_ARCH_20:
         case NV_ARCH_30:
-            state->offset0  = chip->PGRAPH[0x00000640/4];
-            state->offset1  = chip->PGRAPH[0x00000644/4];
-            state->offset2  = chip->PGRAPH[0x00000648/4];
-            state->offset3  = chip->PGRAPH[0x0000064C/4];
-            state->pitch0   = chip->PGRAPH[0x00000670/4];
-            state->pitch1   = chip->PGRAPH[0x00000674/4];
-            state->pitch2   = chip->PGRAPH[0x00000678/4];
-            state->pitch3   = chip->PGRAPH[0x0000067C/4];
+            state->offset0  = NV_RD32(chip->PGRAPH, 0x00000640);
+            state->offset1  = NV_RD32(chip->PGRAPH, 0x00000644);
+            state->offset2  = NV_RD32(chip->PGRAPH, 0x00000648);
+            state->offset3  = NV_RD32(chip->PGRAPH, 0x0000064C);
+            state->pitch0   = NV_RD32(chip->PGRAPH, 0x00000670);
+            state->pitch1   = NV_RD32(chip->PGRAPH, 0x00000674);
+            state->pitch2   = NV_RD32(chip->PGRAPH, 0x00000678);
+            state->pitch3   = NV_RD32(chip->PGRAPH, 0x0000067C);
             if(chip->twoHeads) {
-               state->head     = chip->PCRTC0[0x00000860/4];
-               state->head2    = chip->PCRTC0[0x00002860/4];
+               state->head     = NV_RD32(chip->PCRTC0, 0x00000860);
+               state->head2    = NV_RD32(chip->PCRTC0, 0x00002860);
                VGA_WR08(chip->PCIO, 0x03D4, 0x44);
                state->crtcOwner = VGA_RD08(chip->PCIO, 0x03D5);
             }
             VGA_WR08(chip->PCIO, 0x03D4, 0x41);
             state->extra = VGA_RD08(chip->PCIO, 0x03D5);
-            state->cursorConfig = chip->PCRTC[0x00000810/4];
+            state->cursorConfig = NV_RD32(chip->PCRTC, 0x00000810);
 
             if((chip->Chipset & 0x0ff0) == 0x0110) {
-                state->dither = chip->PRAMDAC[0x0528/4];
+                state->dither = NV_RD32(chip->PRAMDAC, 0x0528);
             } else 
             if((chip->Chipset & 0x0ff0) >= 0x0170) {
-                state->dither = chip->PRAMDAC[0x083C/4];
+                state->dither = NV_RD32(chip->PRAMDAC, 0x083C);
             }
             break;
     }
@@ -1792,7 +1822,7 @@
     unsigned      start
 )
 {
-    chip->PCRTC[0x800/4] = start;
+    NV_WR32(chip->PCRTC, 0x800, start);
 }
 
 static void SetStartAddress3
@@ -1834,14 +1864,15 @@
     unsigned     surf1
 )
 {
-    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
+    RivaSurface __iomem *Surface =
+	(RivaSurface __iomem *)&(chip->FIFO[0x0000E000/4]);
 
     RIVA_FIFO_FREE(*chip,Tri03,5);
-    chip->FIFO[0x00003800] = 0x80000003;
-    Surface->Offset        = surf0;
-    chip->FIFO[0x00003800] = 0x80000004;
-    Surface->Offset        = surf1;
-    chip->FIFO[0x00003800] = 0x80000013;
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000003);
+    NV_WR32(&Surface->Offset, 0, surf0);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000004);
+    NV_WR32(&Surface->Offset, 0, surf1);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000013);
 }
 static void nv4SetSurfaces2D
 (
@@ -1850,13 +1881,14 @@
     unsigned     surf1
 )
 {
-    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
+    RivaSurface __iomem *Surface =
+	(RivaSurface __iomem *)&(chip->FIFO[0x0000E000/4]);
 
-    chip->FIFO[0x00003800] = 0x80000003;
-    Surface->Offset        = surf0;
-    chip->FIFO[0x00003800] = 0x80000004;
-    Surface->Offset        = surf1;
-    chip->FIFO[0x00003800] = 0x80000014;
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000003);
+    NV_WR32(&Surface->Offset, 0, surf0);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000004);
+    NV_WR32(&Surface->Offset, 0, surf1);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000014);
 }
 static void nv10SetSurfaces2D
 (
@@ -1865,13 +1897,14 @@
     unsigned     surf1
 )
 {
-    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
+    RivaSurface __iomem *Surface =
+	(RivaSurface __iomem *)&(chip->FIFO[0x0000E000/4]);
 
-    chip->FIFO[0x00003800] = 0x80000003;
-    Surface->Offset        = surf0;
-    chip->FIFO[0x00003800] = 0x80000004;
-    Surface->Offset        = surf1;
-    chip->FIFO[0x00003800] = 0x80000014;
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000003);
+    NV_WR32(&Surface->Offset, 0, surf0);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000004);
+    NV_WR32(&Surface->Offset, 0, surf1);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000014);
 }
 static void nv3SetSurfaces3D
 (
@@ -1880,14 +1913,15 @@
     unsigned     surf1
 )
 {
-    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
+    RivaSurface __iomem *Surface =
+	(RivaSurface __iomem *)&(chip->FIFO[0x0000E000/4]);
 
     RIVA_FIFO_FREE(*chip,Tri03,5);
-    chip->FIFO[0x00003800] = 0x80000005;
-    Surface->Offset        = surf0;
-    chip->FIFO[0x00003800] = 0x80000006;
-    Surface->Offset        = surf1;
-    chip->FIFO[0x00003800] = 0x80000013;
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000005);
+    NV_WR32(&Surface->Offset, 0, surf0);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000006);
+    NV_WR32(&Surface->Offset, 0, surf1);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000013);
 }
 static void nv4SetSurfaces3D
 (
@@ -1896,13 +1930,14 @@
     unsigned     surf1
 )
 {
-    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
+    RivaSurface __iomem *Surface =
+	(RivaSurface __iomem *)&(chip->FIFO[0x0000E000/4]);
 
-    chip->FIFO[0x00003800] = 0x80000005;
-    Surface->Offset        = surf0;
-    chip->FIFO[0x00003800] = 0x80000006;
-    Surface->Offset        = surf1;
-    chip->FIFO[0x00003800] = 0x80000014;
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000005);
+    NV_WR32(&Surface->Offset, 0, surf0);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000006);
+    NV_WR32(&Surface->Offset, 0, surf1);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000014);
 }
 static void nv10SetSurfaces3D
 (
@@ -1911,13 +1946,14 @@
     unsigned     surf1
 )
 {
-    RivaSurface3D *Surfaces3D = (RivaSurface3D *)&(chip->FIFO[0x0000E000/4]);
+    RivaSurface3D __iomem *Surfaces3D =
+	(RivaSurface3D __iomem *)&(chip->FIFO[0x0000E000/4]);
 
     RIVA_FIFO_FREE(*chip,Tri03,4);
-    chip->FIFO[0x00003800]         = 0x80000007;
-    Surfaces3D->RenderBufferOffset = surf0;
-    Surfaces3D->ZBufferOffset      = surf1;
-    chip->FIFO[0x00003800]         = 0x80000014;
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000007);
+    NV_WR32(&Surfaces3D->RenderBufferOffset, 0, surf0);
+    NV_WR32(&Surfaces3D->ZBufferOffset, 0, surf1);
+    NV_WR32(&chip->FIFO[0x00003800], 0, 0x80000014);
 }
 
 /****************************************************************************\
@@ -1934,16 +1970,16 @@
     /*
      * Fill in chip configuration.
      */
-    if (chip->PFB[0x00000000/4] & 0x00000020)
+    if (NV_RD32(&chip->PFB[0x00000000/4], 0) & 0x00000020)
     {
-        if (((chip->PMC[0x00000000/4] & 0xF0) == 0x20)
-         && ((chip->PMC[0x00000000/4] & 0x0F) >= 0x02))
+        if (((NV_RD32(chip->PMC, 0x00000000) & 0xF0) == 0x20)
+         && ((NV_RD32(chip->PMC, 0x00000000) & 0x0F) >= 0x02))
         {        
             /*
              * SDRAM 128 ZX.
              */
             chip->RamBandwidthKBytesPerSec = 800000;
-            switch (chip->PFB[0x00000000/4] & 0x03)
+            switch (NV_RD32(chip->PFB, 0x00000000) & 0x03)
             {
                 case 2:
                     chip->RamAmountKBytes = 1024 * 4;
@@ -1968,7 +2004,7 @@
          * SGRAM 128.
          */
         chip->RamBandwidthKBytesPerSec = 1000000;
-        switch (chip->PFB[0x00000000/4] & 0x00000003)
+        switch (NV_RD32(chip->PFB, 0x00000000) & 0x00000003)
         {
             case 0:
                 chip->RamAmountKBytes = 1024 * 8;
@@ -1981,7 +2017,7 @@
                 break;
         }
     }        
-    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
+    chip->CrystalFreqKHz   = (NV_RD32(chip->PEXTDEV, 0x00000000) & 0x00000040) ? 14318 : 13500;
     chip->CURSOR           = &(chip->PRAMIN[0x00008000/4 - 0x0800/4]);
     chip->VBlankBit        = 0x00000100;
     chip->MaxVClockFreqKHz = 256000;
@@ -2006,14 +2042,14 @@
     /*
      * Fill in chip configuration.
      */
-    if (chip->PFB[0x00000000/4] & 0x00000100)
+    if (NV_RD32(chip->PFB, 0x00000000) & 0x00000100)
     {
-        chip->RamAmountKBytes = ((chip->PFB[0x00000000/4] >> 12) & 0x0F) * 1024 * 2
+        chip->RamAmountKBytes = ((NV_RD32(chip->PFB, 0x00000000) >> 12) & 0x0F) * 1024 * 2
                               + 1024 * 2;
     }
     else
     {
-        switch (chip->PFB[0x00000000/4] & 0x00000003)
+        switch (NV_RD32(chip->PFB, 0x00000000) & 0x00000003)
         {
             case 0:
                 chip->RamAmountKBytes = 1024 * 32;
@@ -2030,7 +2066,7 @@
                 break;
         }
     }
-    switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
+    switch ((NV_RD32(chip->PFB, 0x00000000) >> 3) & 0x00000003)
     {
         case 3:
             chip->RamBandwidthKBytesPerSec = 800000;
@@ -2039,7 +2075,7 @@
             chip->RamBandwidthKBytesPerSec = 1000000;
             break;
     }
-    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
+    chip->CrystalFreqKHz   = (NV_RD32(chip->PEXTDEV, 0x00000000) & 0x00000040) ? 14318 : 13500;
     chip->CURSOR           = &(chip->PRAMIN[0x00010000/4 - 0x0800/4]);
     chip->VBlankBit        = 0x00000001;
     chip->MaxVClockFreqKHz = 350000;
@@ -2067,7 +2103,8 @@
 
 #ifdef __BIG_ENDIAN
     /* turn on big endian register access */
-    chip->PMC[0x00000004/4] = 0x01000001;
+    if(!(NV_RD32(chip->PMC, 0x00000004) & 0x01000001))
+    	NV_WR32(chip->PMC, 0x00000004, 0x01000001);
 #endif
 
     /*
@@ -2082,7 +2119,7 @@
         pci_read_config_dword(dev, 0x84, &amt);
         chip->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024;
     } else {
-        switch ((chip->PFB[0x0000020C/4] >> 20) & 0x000000FF)
+        switch ((NV_RD32(chip->PFB, 0x0000020C) >> 20) & 0x000000FF)
         {
             case 0x02:
                 chip->RamAmountKBytes = 1024 * 2;
@@ -2110,7 +2147,7 @@
                 break;
         }
     }
-    switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
+    switch ((NV_RD32(chip->PFB, 0x00000000) >> 3) & 0x00000003)
     {
         case 3:
             chip->RamBandwidthKBytesPerSec = 800000;
@@ -2119,8 +2156,8 @@
             chip->RamBandwidthKBytesPerSec = 1000000;
             break;
     }
-    chip->CrystalFreqKHz = (chip->PEXTDEV[0x0000/4] & (1 << 6)) ? 14318 :
-                                                                  13500;
+    chip->CrystalFreqKHz = (NV_RD32(chip->PEXTDEV, 0x0000) & (1 << 6)) ?
+	14318 : 13500;
 
     switch (chipset & 0x0ff0) {
     case 0x0170:
@@ -2128,7 +2165,12 @@
     case 0x01F0:
     case 0x0250:
     case 0x0280:
-       if(chip->PEXTDEV[0x0000/4] & (1 << 22))
+    case 0x0300:
+    case 0x0310:
+    case 0x0320:
+    case 0x0330:
+    case 0x0340:
+       if(NV_RD32(chip->PEXTDEV, 0x0000) & (1 << 22))
            chip->CrystalFreqKHz = 27000;
        break;
     default:
@@ -2159,6 +2201,11 @@
     case 0x01F0:
     case 0x0250:
     case 0x0280:
+    case 0x0300:
+    case 0x0310:
+    case 0x0320:
+    case 0x0330:
+    case 0x0340:
         chip->twoHeads = TRUE;
         break;
     default:
@@ -2199,14 +2246,14 @@
     /*
      * Fill in FIFO pointers.
      */
-    chip->Rop    = (RivaRop                 *)&(chip->FIFO[0x00000000/4]);
-    chip->Clip   = (RivaClip                *)&(chip->FIFO[0x00002000/4]);
-    chip->Patt   = (RivaPattern             *)&(chip->FIFO[0x00004000/4]);
-    chip->Pixmap = (RivaPixmap              *)&(chip->FIFO[0x00006000/4]);
-    chip->Blt    = (RivaScreenBlt           *)&(chip->FIFO[0x00008000/4]);
-    chip->Bitmap = (RivaBitmap              *)&(chip->FIFO[0x0000A000/4]);
-    chip->Line   = (RivaLine                *)&(chip->FIFO[0x0000C000/4]);
-    chip->Tri03  = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
+    chip->Rop    = (RivaRop __iomem         *)&(chip->FIFO[0x00000000/4]);
+    chip->Clip   = (RivaClip __iomem        *)&(chip->FIFO[0x00002000/4]);
+    chip->Patt   = (RivaPattern __iomem     *)&(chip->FIFO[0x00004000/4]);
+    chip->Pixmap = (RivaPixmap __iomem      *)&(chip->FIFO[0x00006000/4]);
+    chip->Blt    = (RivaScreenBlt __iomem   *)&(chip->FIFO[0x00008000/4]);
+    chip->Bitmap = (RivaBitmap __iomem      *)&(chip->FIFO[0x0000A000/4]);
+    chip->Line   = (RivaLine __iomem        *)&(chip->FIFO[0x0000C000/4]);
+    chip->Tri03  = (RivaTexturedTriangle03 __iomem *)&(chip->FIFO[0x0000E000/4]);
     return (0);
 }
 
diff -Nru a/drivers/video/riva/riva_hw.h b/drivers/video/riva/riva_hw.h
--- a/drivers/video/riva/riva_hw.h	2004-12-24 13:37:19 -08:00
+++ b/drivers/video/riva/riva_hw.h	2004-12-24 13:37:19 -08:00
@@ -73,20 +73,17 @@
 /*
  * HW access macros.
  */
-#if defined(__powerpc__)
 #include <asm/io.h>
-#define NV_WR08(p,i,d)	out_8(p+i, d)
-#define NV_RD08(p,i)	in_8(p+i)
-#else
-#define NV_WR08(p,i,d)  (((U008 *)(p))[i]=(d))
-#define NV_RD08(p,i)    (((U008 *)(p))[i])
-#endif
-#define NV_WR16(p,i,d)  (((U016 *)(p))[(i)/2]=(d))
-#define NV_RD16(p,i)    (((U016 *)(p))[(i)/2])
-#define NV_WR32(p,i,d)  (((U032 *)(p))[(i)/4]=(d))
-#define NV_RD32(p,i)    (((U032 *)(p))[(i)/4])
-#define VGA_WR08(p,i,d) NV_WR08(p,i,d)
-#define VGA_RD08(p,i)   NV_RD08(p,i)
+
+#define NV_WR08(p,i,d)  (__raw_writeb((d), (void __iomem *)(p) + (i)))
+#define NV_RD08(p,i)    (__raw_readb((void __iomem *)(p) + (i)))
+#define NV_WR16(p,i,d)  (__raw_writew((d), (void __iomem *)(p) + (i)))
+#define NV_RD16(p,i)    (__raw_readw((void __iomem *)(p) + (i)))
+#define NV_WR32(p,i,d)  (__raw_writel((d), (void __iomem *)(p) + (i)))
+#define NV_RD32(p,i)    (__raw_readl((void __iomem *)(p) + (i)))
+
+#define VGA_WR08(p,i,d) (writeb((d), (void __iomem *)(p) + (i)))
+#define VGA_RD08(p,i)   (readb((void __iomem *)(p) + (i)))
 
 /*
  * Define different architectures.
@@ -444,24 +441,24 @@
     /*
      * Non-FIFO registers.
      */
-    volatile U032 *PCRTC0;
-    volatile U032 *PCRTC;
-    volatile U032 *PRAMDAC0;
-    volatile U032 *PFB;
-    volatile U032 *PFIFO;
-    volatile U032 *PGRAPH;
-    volatile U032 *PEXTDEV;
-    volatile U032 *PTIMER;
-    volatile U032 *PMC;
-    volatile U032 *PRAMIN;
-    volatile U032 *FIFO;
-    volatile U032 *CURSOR;
-    volatile U008 *PCIO0;
-    volatile U008 *PCIO;
-    volatile U008 *PVIO;
-    volatile U008 *PDIO0;
-    volatile U008 *PDIO;
-    volatile U032 *PRAMDAC;
+    volatile U032 __iomem *PCRTC0;
+    volatile U032 __iomem *PCRTC;
+    volatile U032 __iomem *PRAMDAC0;
+    volatile U032 __iomem *PFB;
+    volatile U032 __iomem *PFIFO;
+    volatile U032 __iomem *PGRAPH;
+    volatile U032 __iomem *PEXTDEV;
+    volatile U032 __iomem *PTIMER;
+    volatile U032 __iomem *PMC;
+    volatile U032 __iomem *PRAMIN;
+    volatile U032 __iomem *FIFO;
+    volatile U032 __iomem *CURSOR;
+    volatile U008 __iomem *PCIO0;
+    volatile U008 __iomem *PCIO;
+    volatile U008 __iomem *PVIO;
+    volatile U008 __iomem *PDIO0;
+    volatile U008 __iomem *PDIO;
+    volatile U032 __iomem *PRAMDAC;
     /*
      * Common chip functions.
      */
@@ -481,15 +478,15 @@
     /*
      * FIFO registers.
      */
-    RivaRop                 *Rop;
-    RivaPattern             *Patt;
-    RivaClip                *Clip;
-    RivaPixmap              *Pixmap;
-    RivaScreenBlt           *Blt;
-    RivaBitmap              *Bitmap;
-    RivaLine                *Line;
-    RivaTexturedTriangle03  *Tri03;
-    RivaTexturedTriangle05  *Tri05;
+    RivaRop                 __iomem *Rop;
+    RivaPattern             __iomem *Patt;
+    RivaClip                __iomem *Clip;
+    RivaPixmap              __iomem *Pixmap;
+    RivaScreenBlt           __iomem *Blt;
+    RivaBitmap              __iomem *Bitmap;
+    RivaLine                __iomem *Line;
+    RivaTexturedTriangle03  __iomem *Tri03;
+    RivaTexturedTriangle05  __iomem *Tri05;
 } RIVA_HW_INST;
 /*
  * Extended mode state information.
@@ -541,8 +538,10 @@
 
 #define RIVA_FIFO_FREE(hwinst,hwptr,cnt)                            \
 {                                                                   \
-    while ((hwinst).FifoFreeCount < (cnt))                          \
-        (hwinst).FifoFreeCount = (hwinst).hwptr->FifoFree >> 2;     \
+    while ((hwinst).FifoFreeCount < (cnt)) {                        \
+	mb();mb();						    \
+        (hwinst).FifoFreeCount = NV_RD32(&(hwinst).hwptr->FifoFree, 0) >> 2;     \
+    }								    \
     (hwinst).FifoFreeCount -= (cnt);                                \
 }
 #endif /* __RIVA_HW_H__ */
diff -Nru a/drivers/video/riva/rivafb.h b/drivers/video/riva/rivafb.h
--- a/drivers/video/riva/rivafb.h	2004-12-24 13:36:33 -08:00
+++ b/drivers/video/riva/rivafb.h	2004-12-24 13:36:33 -08:00
@@ -46,7 +46,7 @@
 	RIVA_HW_INST riva;	/* interface to riva_hw.c */
 	u32 pseudo_palette[16]; /* default palette */
 	u32 palette[16];        /* for Riva128 */
-	caddr_t ctrl_base;	/* virtual control register base addr */
+	u8 __iomem *ctrl_base;	/* virtual control register base addr */
 	unsigned dclk_max;	/* max DCLK */
 
 	struct riva_regs initial_state;	/* initial startup video mode */
@@ -62,6 +62,7 @@
 	int FlatPanel;
 	struct pci_dev *pdev;
 	int bus;
+	int cursor_reset;
 #ifdef CONFIG_MTRR
 	struct { int vram; int vram_valid; } mtrr;
 #endif
diff -Nru a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
--- a/drivers/video/sa1100fb.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/video/sa1100fb.c	2004-12-24 13:36:31 -08:00
@@ -309,23 +309,6 @@
 };
 #endif
 
-#ifdef CONFIG_SA1100_BRUTUS
-static struct sa1100fb_mach_info brutus_info __initdata = {
-	.pixclock	= 0,		.bpp		= 8,
-	.xres		= 320,		.yres		= 240,
-
-	.hsync_len	= 3,		.vsync_len	= 1,
-	.left_margin	= 41,		.upper_margin	= 0,
-	.right_margin	= 101,		.lower_margin	= 0,
-
-	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-
-	.lccr0		= LCCR0_Color | LCCR0_Sngl | LCCR0_Pas,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2) |
-			  LCCR3_PixClkDiv(44),
-};
-#endif
-
 #ifdef CONFIG_SA1100_COLLIE
 static struct sa1100fb_mach_info collie_info __initdata = {
 	.pixclock	= 171521,	.bpp		= 16,
@@ -342,65 +325,6 @@
 };
 #endif
 
-#ifdef CONFIG_SA1100_FREEBIRD
-#warning Please check this carefully
-static struct sa1100fb_mach_info freebird_info __initdata = {
-	.pixclock	= 171521,	.bpp		= 16,
-	.xres		= 240,		.yres		= 320,
-
-	.hsync_len	= 3,		.vsync_len	= 2,
-	.left_margin	= 2,		.upper_margin	= 0,
-	.right_margin	= 2,		.lower_margin	= 0,
-
-	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-
-	.lccr0		= LCCR0_Color | LCCR0_Sngl | LCCR0_Pas,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixFlEdg | LCCR3_ACBsDiv(2),
-};
-
-static struct sa1100fb_rgb freebird_rgb_16 = {
-	.red	= { .offset = 8,  .length = 4, },
-	.green	= { .offset = 4,  .length = 4, },
-	.blue	= { .offset = 0,  .length = 4, },
-	.transp	= { .offset = 12, .length = 4, },
-};
-#endif
-
-#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-static struct sa1100fb_mach_info graphicsclient_info __initdata = {
-	.pixclock	= 53500,	.bpp		= 8,
-	.xres		= 640,		.yres		= 480,
-
-	.hsync_len	= 9,		.vsync_len	= 9,
-	.left_margin	= 54,		.upper_margin	= 24,
-	.right_margin	= 54,		.lower_margin	= 32,
-
-	.lccr0		= LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
-};
-#endif
-
-#ifdef CONFIG_SA1100_HUW_WEBPANEL
-static struct sa1100fb_mach_info huw_webpanel_info __initdata = {
-	.pixclock	= 0,		.bpp		= 8,
-	.xres		= 640,		.yres		= 480,
-
-	.hsync_len	= 3,		.vsync_len	= 1,
-	.left_margin	= 41,		.upper_margin	= 0,
-	.right_margin	= 101,		.lower_margin	= 0,
-
-	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-
-	.lccr0		= LCCR0_Color | LCCR0_Dual | LCCR0_Pas,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2) | 8,
-#error FIXME
-	/*
-	 * FIXME: please get rid of the '| 8' in preference to an
-	 * LCCR3_PixClkDiv() version. --rmk
-	 */
-};
-#endif
-
 #ifdef LART_GREY_LCD
 static struct sa1100fb_mach_info lart_grey_info __initdata = {
 	.pixclock	= 150000,	.bpp		= 4,
@@ -476,138 +400,6 @@
 };
 #endif
 
-#ifdef CONFIG_SA1100_OMNIMETER
-static struct sa1100fb_mach_info omnimeter_info __initdata = {
-	.pixclock	= 0,		.bpp		= 4,
-	.xres		= 480,		.yres		= 320,
-
-	.hsync_len	= 1,		.vsync_len	= 1,
-	.left_margin	= 10,		.upper_margin	= 0,
-	.right_margin	= 10,		.lower_margin	= 0,
-
-	.cmap_greyscale	= 1,
-	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-
-	.lccr0		= LCCR0_Mono | LCCR0_Sngl | LCCR0_Pas | LCCR0_8PixMono,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(255) |
-			  LCCR3_PixClkDiv(44),
-#error FIXME: fix pixclock, ACBsDiv
-	/*
-	 * FIXME: I think ACBsDiv is wrong above - should it be 512 (disabled)?
-	 *   - rmk
-	 */
-};
-#endif
-
-#ifdef CONFIG_SA1100_PANGOLIN
-static struct sa1100fb_mach_info pangolin_info __initdata = {
-	.pixclock	= 341521,	.bpp		= 16,
-	.xres		= 800,		.yres		= 600,
-
-	.hsync_len	= 64,		.vsync_len	= 7,
-	.left_margin	= 160,		.upper_margin	= 7,
-	.right_margin	= 24,		.lower_margin	= 1,
-
-	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-
-	.lccr0		= LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixFlEdg | LCCR3_ACBsCntOff,
-};
-#endif
-
-#ifdef CONFIG_SA1100_STORK
-#if STORK_TFT			/* ie the NEC TFT */
-/*
- * pixclock is ps per clock. say 72Hz, 800x600 clocks => (1/72)/(800*600)
- * = 28935 and a bit
- * NB likely to be increased to ease bus timings wrt pcmcia interface
- */
-static struct sa1100fb_mach_info stork_tft_info __initdata = {
-	.pixclock	= 28935,	.bpp		= 16,
-	.xres		= 640,		.yres		= 480,
-
-	.hsync_len	= 64,		.vsync_len	= 2,
-	.left_margin	= 48,		.upper_margin	= 12,
-	.right_margin	= 48,		.lower_margin	= 31,
-
-	.lccr0		= LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsCntOff,
-};
-
-static struct sa1100fb_rgb stork_tft_rgb_16 = {
-	.red	= { .offset = 11, .length = 5, },
-	.green	= { .offset = 5,  .length = 6, },
-	.blue	= { .offset = 0,  .length = 5, },
-	.transp	= { .offset = 0,  .length = 0, },
-};
-
-#else	/* Kyocera DSTN */
-
-static struct sa1100fb_mach_info stork_dstn_info __initdata = {
-	.pixclock	= 0,		.bpp		= 16,
-	.xres		= 640,		.yres		= 480,
-
-	.hsync_len	= 2,		.vsync_len	= 2,
-	.left_margin	= 2,		.upper_margin	= 0,
-	.right_margin	= 2,		.lower_margin	= 0,
-
-	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT ,
-
-	.lccr0		= LCCR0_Color | LCCR0_Dual | LCCR0_Pas,
-#error Fixme
-	.lccr3		= 0xff00 |
-			0x18		/* ought to be 0x14 but DMA isn't up to that as yet */
-};
-
-static struct sa1100fb_rgb stork_dstn_rgb_16 = {
-	.red	= { .offset = 8,  .length = 4, },
-	.green	= { .offset = 4,  .length = 4, },
-	.blue	= { .offset = 0,  .length = 4, },
-	.transp	= { .offset = 0,  .length = 0, },
-};
-#endif
-#endif
-
-#ifdef CONFIG_SA1100_PT_SYSTEM3
-/*
- * 648 x 480 x 8bpp x 75Hz Dual Panel Color STN Display
- *
- * pixclock = 1/( 640*3/8*240 ), [pixclock]=1e-12s=ps
- *	3 due to r,g,b lines
- *	8 due to 8 bit data bus
- *	640 due to 640 pixels per line
- *	240 = 480/2 due to dual panel display
- *	=>4.32Mhz => 231481E-12s
- */
-static struct sa1100fb_mach_info system3_info __initdata = {
-	.pixclock	= 231481,	.bpp		= 8,
-	.xres		= 640,		.yres		= 480,
-
-	.hsync_len	= 2,		.vsync_len	= 2,
-	.left_margin	= 2,		.upper_margin	= 0,
-	.right_margin	= 2,		.lower_margin	= 0,
-
-	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-
-	.lccr0		= LCCR0_Color | LCCR0_Dual | LCCR0_Pas,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(512),
-};
-#endif
-
-#ifdef CONFIG_SA1100_XP860
-static struct sa1100fb_mach_info xp860_info __initdata = {
-	.pixclock	= 0,		.bpp		= 8,
-	.xres		= 1024,		.yres		= 768,
-
-	.hsync_len	= 3,		.vsync_len	= 3,
-	.left_margin	= 3,		.upper_margin	= 2,
-	.right_margin	= 2,		.lower_margin	= 1,
-
-	.lccr0		= LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
-	.lccr3		= LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_PixClkDiv(6),
-};
-#endif
-
 
 
 static struct sa1100fb_mach_info * __init
@@ -646,32 +438,11 @@
 		inf = &h3800_info;
 	}
 #endif
-#ifdef CONFIG_SA1100_BRUTUS
-	if (machine_is_brutus()) {
-		inf = &brutus_info;
-	}
-#endif
 #ifdef CONFIG_SA1100_COLLIE
 	if (machine_is_collie()) {
 		inf = &collie_info;
 	}
 #endif
-#ifdef CONFIG_SA1100_FREEBIRD
-	if (machine_is_freebird()) {
-		inf = &freebird_info;
-		fbi->rgb[RGB_16] = &freebird_rgb16;
-	}
-#endif
-#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-	if (machine_is_graphicsclient()) {
-		inf = &graphicsclient_info;
-	}
-#endif
-#ifdef CONFIG_SA1100_HUW_WEBPANEL
-	if (machine_is_huw_webpanel()) {
-		inf = &huw_webpanel_info;
-	}
-#endif
 #ifdef CONFIG_SA1100_LART
 	if (machine_is_lart()) {
 #ifdef LART_GREY_LCD
@@ -688,42 +459,11 @@
 #endif
 	}
 #endif
-#ifdef CONFIG_SA1100_OMNIMETER
-	if (machine_is_omnimeter()) {
-		inf = &omnimeter_info;
-	}
-#endif
-#ifdef CONFIG_SA1100_PANGOLIN
-	if (machine_is_pangolin()) {
-		inf = &pangolin_info;
-	}
-#endif
-#ifdef CONFIG_SA1100_PT_SYSTEM3
-	if (machine_is_pt_system3()) {
-		inf = &system3_info;
-	}
-#endif
 #ifdef CONFIG_SA1100_SHANNON
 	if (machine_is_shannon()) {
 		inf = &shannon_info;
 	}
 #endif
-#ifdef CONFIG_SA1100_STORK
-	if (machine_is_stork()) {
-#if STORK_TFT
-		inf = &stork_tft_info;
-		fbi->rgb[RGB_16] = &stork_tft_rgb_16;
-#else
-		inf = &stork_dstn_info;
-		fbi->rgb[RGB_16] = &stork_dstn_rgb_16;
-#endif
-	}
-#endif
-#ifdef CONFIG_SA1100_XP860
-	if (machine_is_xp860()) {
-		inf = &xp860_info;
-	}
-#endif
 	return inf;
 }
 
@@ -989,13 +729,6 @@
 	 * Set (any) board control register to handle new color depth
 	 */
 	sa1100fb_set_truecolor(fbi->fb.fix.visual == FB_VISUAL_TRUECOLOR);
-
-#ifdef CONFIG_SA1100_OMNIMETER
-#error Do we have to do this here?   We already do it at init time.
-	if (machine_is_omnimeter())
-		SetLCDContrast(DefaultLCDContrast);
-#endif
-
 	sa1100fb_activate_var(var, fbi);
 
 	return 0;
@@ -1061,9 +794,10 @@
 	DPRINTK("sa1100fb_blank: blank=%d\n", blank);
 
 	switch (blank) {
-	case VESA_POWERDOWN:
-	case VESA_VSYNC_SUSPEND:
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_POWERDOWN:
+	case FB_BLANK_VSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
+	case FB_BLANK_NORMAL:
 		if (fbi->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR ||
 		    fbi->fb.fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
 			for (i = 0; i < fbi->palette_size; i++)
@@ -1071,7 +805,7 @@
 		sa1100fb_schedule_work(fbi, C_DISABLE);
 		break;
 
-	case VESA_NO_BLANKING:
+	case FB_BLANK_UNBLANK:
 		if (fbi->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR ||
 		    fbi->fb.fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
 			fb_set_cmap(&fbi->fb.cmap, info);
@@ -1287,15 +1021,6 @@
 	DBAR2 = fbi->dbar2;
 	LCCR0 |= LCCR0_LEN;
 
-#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-#error Where is GPIO24 set as an output?  Can we fit this in somewhere else?
-	if (machine_is_graphicsclient()) {
-		// From ADS doc again...same as disable
-		msleep(20);
-		GPSR |= GPIO_GPIO24;
-	}
-#endif
-
 	if (machine_is_shannon()) {
 		GPDR |= SHANNON_GPIO_DISP_EN;
 		GPSR |= SHANNON_GPIO_DISP_EN;
@@ -1315,29 +1040,6 @@
 
 	DPRINTK("Disabling LCD controller\n");
 
-#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-#error Where is GPIO24 set as an output?  Can we fit this in somewhere else?
-	if (machine_is_graphicsclient()) {
-		/*
-		 * From ADS internal document:
-		 *  GPIO24 should be LOW at least 10msec prior to disabling
-		 *  the LCD interface.
-		 *
-		 * We'll wait 20msec.
-		 */
-		GPCR |= GPIO_GPIO24;
-		msleep(20);
-	}
-#endif
-#ifdef CONFIG_SA1100_HUW_WEBPANEL
-#error Move me into __sa1100fb_lcd_power and/or __sa1100fb_backlight_power
-	if (machine_is_huw_webpanel()) {
-		// don't forget to set the control lines to zero (?)
-		DPRINTK("ShutDown HuW LCD controller\n");
-		BCR_clear(BCR_TFT_ENA + BCR_CCFL_POW + BCR_PWM_BACKLIGHT);
-	}
-#endif
-
 	if (machine_is_shannon()) {
 		GPCR |= SHANNON_GPIO_DISP_EN;
 	}	
@@ -1673,7 +1375,6 @@
 	fbi->fb.fbops		= &sa1100fb_ops;
 	fbi->fb.flags		= FBINFO_DEFAULT;
 	fbi->fb.monspecs	= monspecs;
-	fbi->fb.currcon		= -1;
 	fbi->fb.pseudo_palette	= (fbi + 1);
 
 	fbi->rgb[RGB_8]		= &rgb_8;
@@ -1752,16 +1453,6 @@
 #ifdef ASSABET_PAL_VIDEO
 	if (machine_is_assabet())
 		ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
-#endif
-
-#ifdef CONFIG_SA1100_FREEBIRD
-#error Please move this into __sa1100fb_lcd_power
-	if (machine_is_freebird()) {
-		BCR_set(BCR_FREEBIRD_LCD_DISP);
-		mdelay(20);
-		BCR_set(BCR_FREEBIRD_LCD_PWR);
-		mdelay(20);
-	}
 #endif
 
 	/*
diff -Nru a/drivers/video/savage/Makefile b/drivers/video/savage/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/savage/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,8 @@
+#
+# Makefile for the S3 Savage framebuffer driver
+#
+
+obj-$(CONFIG_FB_SAVAGE)		+= savagefb.o
+obj-$(CONFIG_FB_SAVAGE_I2C)     += savagefb-i2c.o
+obj-$(CONFIG_FB_SAVAGE_ACCEL)   += savagefb_accel.o
+
diff -Nru a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/savage/savagefb-i2c.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,277 @@
+/*
+ * linux/drivers/video/savage/savagefb-i2c.c - S3 Savage DDC2
+ *
+ * Copyright 2004 Antonino A. Daplas <adaplas @pol.net>
+ *
+ * Based partly on rivafb-i2c.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.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/fb.h>
+
+#include <asm/io.h>
+#include "savagefb.h"
+
+#define SAVAGE_DDC 	0x50
+
+#define VGA_CR_IX	0x3d4
+#define VGA_CR_DATA	0x3d5
+
+#define CR_SERIAL1	0xa0	/* I2C serial communications interface */
+#define MM_SERIAL1	0xff20
+#define CR_SERIAL2	0xb1	/* DDC2 monitor communications interface */
+
+/* based on vt8365 documentation */
+#define PROSAVAGE_I2C_ENAB	0x10
+#define PROSAVAGE_I2C_SCL_OUT	0x01
+#define PROSAVAGE_I2C_SDA_OUT	0x02
+#define PROSAVAGE_I2C_SCL_IN	0x04
+#define PROSAVAGE_I2C_SDA_IN	0x08
+
+#define SAVAGE4_I2C_ENAB	0x00000020
+#define SAVAGE4_I2C_SCL_OUT	0x00000001
+#define SAVAGE4_I2C_SDA_OUT	0x00000002
+#define SAVAGE4_I2C_SCL_IN	0x00000008
+#define SAVAGE4_I2C_SDA_IN	0x00000010
+
+#define SET_CR_IX(base, val)	writeb((val), base + 0x8000 + VGA_CR_IX)
+#define SET_CR_DATA(base, val)	writeb((val), base + 0x8000 + VGA_CR_DATA)
+#define GET_CR_DATA(base)	readb(base + 0x8000 + VGA_CR_DATA)
+
+static void savage4_gpio_setscl(void *data, int val)
+{
+	struct savagefb_i2c_chan *chan = (struct savagefb_i2c_chan *)data;
+	unsigned int r;
+
+	r = readl(chan->ioaddr + chan->reg);
+	if(val)
+		r |= SAVAGE4_I2C_SCL_OUT;
+	else
+		r &= ~SAVAGE4_I2C_SCL_OUT;
+	writel(r, chan->ioaddr + chan->reg);
+	readl(chan->ioaddr + chan->reg);	/* flush posted write */
+}
+
+static void savage4_gpio_setsda(void *data, int val)
+{
+	struct savagefb_i2c_chan *chan = (struct savagefb_i2c_chan *)data;
+
+	unsigned int r;
+	r = readl(chan->ioaddr + chan->reg);
+	if(val)
+		r |= SAVAGE4_I2C_SDA_OUT;
+	else
+		r &= ~SAVAGE4_I2C_SDA_OUT;
+	writel(r, chan->ioaddr + chan->reg);
+	readl(chan->ioaddr + chan->reg);	/* flush posted write */
+}
+
+static int savage4_gpio_getscl(void *data)
+{
+	struct savagefb_i2c_chan *chan = (struct savagefb_i2c_chan *)data;
+
+	return (0 != (readl(chan->ioaddr + chan->reg) & SAVAGE4_I2C_SCL_IN));
+}
+
+static int savage4_gpio_getsda(void *data)
+{
+	struct savagefb_i2c_chan *chan = (struct savagefb_i2c_chan *)data;
+
+	return (0 != (readl(chan->ioaddr + chan->reg) & SAVAGE4_I2C_SDA_IN));
+}
+
+static void prosavage_gpio_setscl(void* data, int val)
+{
+	struct savagefb_i2c_chan *chan = (struct savagefb_i2c_chan *)data;
+	u32			  r;
+
+	SET_CR_IX(chan->ioaddr, chan->reg);
+	r = GET_CR_DATA(chan->ioaddr);
+	r |= PROSAVAGE_I2C_ENAB;
+	if (val) {
+		r |= PROSAVAGE_I2C_SCL_OUT;
+	} else {
+		r &= ~PROSAVAGE_I2C_SCL_OUT;
+	}
+	SET_CR_DATA(chan->ioaddr, r);
+}
+
+static void prosavage_gpio_setsda(void* data, int val)
+{
+	struct savagefb_i2c_chan *chan = (struct savagefb_i2c_chan *)data;
+	unsigned int r;
+
+	SET_CR_IX(chan->ioaddr, chan->reg);
+	r = GET_CR_DATA(chan->ioaddr);
+	r |= PROSAVAGE_I2C_ENAB;
+	if (val) {
+		r |= PROSAVAGE_I2C_SDA_OUT;
+	} else {
+		r &= ~PROSAVAGE_I2C_SDA_OUT;
+	}
+	SET_CR_DATA(chan->ioaddr, r);
+}
+
+static int prosavage_gpio_getscl(void* data)
+{
+	struct savagefb_i2c_chan *chan = (struct savagefb_i2c_chan *)data;
+
+	SET_CR_IX(chan->ioaddr, chan->reg);
+	return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SCL_IN));
+}
+
+static int prosavage_gpio_getsda(void* data)
+{
+	struct savagefb_i2c_chan *chan = (struct savagefb_i2c_chan *)data;
+
+	SET_CR_IX(chan->ioaddr, chan->reg);
+	return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN));
+}
+
+#define I2C_ALGO_SAVAGE   0x0f0000
+static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
+				const char *name)
+{
+	int (*add_bus)(struct i2c_adapter *) = symbol_get(i2c_bit_add_bus);
+	int rc = 0;
+
+	if (add_bus && chan->par) {
+		strcpy(chan->adapter.name, name);
+		chan->adapter.owner		= THIS_MODULE;
+		chan->adapter.id		= I2C_ALGO_SAVAGE;
+		chan->adapter.algo_data		= &chan->algo;
+		chan->adapter.dev.parent	= &chan->par->pcidev->dev;
+		chan->algo.udelay		= 40;
+		chan->algo.mdelay               = 5;
+		chan->algo.timeout		= 20;
+		chan->algo.data 		= chan;
+
+		i2c_set_adapdata(&chan->adapter, chan);
+
+		/* Raise SCL and SDA */
+		chan->algo.setsda(chan, 1);
+		chan->algo.setscl(chan, 1);
+		udelay(20);
+
+		rc = add_bus(&chan->adapter);
+		if (rc == 0)
+			dev_dbg(&chan->par->pcidev->dev,
+				"I2C bus %s registered.\n", name);
+		else
+			dev_warn(&chan->par->pcidev->dev,
+				 "Failed to register I2C bus %s.\n", name);
+	} else
+		chan->par = NULL;
+
+	return rc;
+}
+
+void savagefb_create_i2c_busses(struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	par->chan.par	= par;
+
+	switch(info->fix.accel) {
+	case FB_ACCEL_PROSAVAGE_DDRK:
+	case FB_ACCEL_PROSAVAGE_PM:
+		par->chan.reg         = CR_SERIAL2;
+		par->chan.ioaddr      = par->mmio.vbase;
+		par->chan.algo.setsda = prosavage_gpio_setsda;
+		par->chan.algo.setscl = prosavage_gpio_setscl;
+		par->chan.algo.getsda = prosavage_gpio_getsda;
+		par->chan.algo.getscl = prosavage_gpio_getscl;
+		break;
+	case FB_ACCEL_SAVAGE4:
+		par->chan.reg         = 0xff20;
+		par->chan.ioaddr      = par->mmio.vbase;
+		par->chan.algo.setsda = savage4_gpio_setsda;
+		par->chan.algo.setscl = savage4_gpio_setscl;
+		par->chan.algo.getsda = savage4_gpio_getsda;
+		par->chan.algo.getscl = savage4_gpio_getscl;
+		break;
+	default:
+		par->chan.par = NULL;
+	}
+
+	savage_setup_i2c_bus(&par->chan, "SAVAGE DDC2");
+}
+EXPORT_SYMBOL(savagefb_create_i2c_busses);
+
+void savagefb_delete_i2c_busses(struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	int (*del_bus)(struct i2c_adapter *) =
+		symbol_get(i2c_bit_del_bus);
+
+	if (del_bus && par->chan.par)
+		del_bus(&par->chan.adapter);
+
+	par->chan.par = NULL;
+}
+EXPORT_SYMBOL(savagefb_delete_i2c_busses);
+
+static u8 *savage_do_probe_i2c_edid(struct savagefb_i2c_chan *chan)
+{
+	u8 start = 0x0;
+	int (*transfer)(struct i2c_adapter *, struct i2c_msg *, int) =
+		symbol_get(i2c_transfer);
+	struct i2c_msg msgs[] = {
+		{
+			.addr	= SAVAGE_DDC,
+			.len	= 1,
+			.buf	= &start,
+		}, {
+			.addr	= SAVAGE_DDC,
+			.flags	= I2C_M_RD,
+			.len	= EDID_LENGTH,
+		},
+	};
+	u8 *buf = NULL;
+
+	if (transfer && chan->par) {
+		buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
+		if (buf) {
+			msgs[1].buf = buf;
+
+			if (transfer(&chan->adapter, msgs, 2) != 2) {
+				dev_dbg(&chan->par->pcidev->dev,
+					"Unable to read EDID block.\n");
+				kfree(buf);
+				buf = NULL;
+			}
+		}
+	}
+
+	return buf;
+}
+
+int savagefb_probe_i2c_connector(struct savagefb_par *par, u8 **out_edid)
+{
+	u8 *edid = NULL;
+	int i;
+
+	for (i = 0; i < 3; i++) {
+		/* Do the real work */
+		edid = savage_do_probe_i2c_edid(&par->chan);
+		if (edid)
+			break;
+	}
+	if (out_edid)
+		*out_edid = edid;
+	if (!edid)
+		return 1;
+
+	return 0;
+}
+EXPORT_SYMBOL(savagefb_probe_i2c_connector);
+
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/video/savage/savagefb.c b/drivers/video/savage/savagefb.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/savage/savagefb.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,2276 @@
+/*
+ * linux/drivers/video/savagefb.c -- S3 Savage Framebuffer Driver
+ *
+ * Copyright (c) 2001-2002  Denis Oliver Kropp <dok@directfb.org>
+ *                          Sven Neumann <neo@directfb.org>
+ *
+ *
+ * Card specific code is based on XFree86's savage driver.
+ * Framebuffer framework code is based on code of cyber2000fb and tdfxfb.
+ *
+ * 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.
+ *
+ * 0.4.0 (neo)
+ *  - hardware accelerated clear and move
+ *
+ * 0.3.2 (dok)
+ *  - wait for vertical retrace before writing to cr67
+ *    at the beginning of savagefb_set_par
+ *  - use synchronization registers cr23 and cr26
+ *
+ * 0.3.1 (dok)
+ *  - reset 3D engine
+ *  - don't return alpha bits for 32bit format
+ *
+ * 0.3.0 (dok)
+ *  - added WaitIdle functions for all Savage types
+ *  - do WaitIdle before mode switching
+ *  - code cleanup
+ *
+ * 0.2.0 (dok)
+ *  - first working version
+ *
+ *
+ * TODO
+ * - clock validations in decode_var
+ *
+ * BUGS
+ * - white margin on bootup
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/tty.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fb.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/console.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/pgtable.h>
+#include <asm/system.h>
+#include <asm/uaccess.h>
+
+#ifdef CONFIG_MTRR
+#include <asm/mtrr.h>
+#endif
+
+#include "savagefb.h"
+
+
+#define SAVAGEFB_VERSION "0.4.0_2.6"
+
+/* --------------------------------------------------------------------- */
+
+
+static char *mode_option __initdata = NULL;
+static int   paletteEnabled = 0;
+
+#ifdef MODULE
+
+MODULE_AUTHOR("(c) 2001-2002  Denis Oliver Kropp <dok@directfb.org>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("FBDev driver for S3 Savage PCI/AGP Chips");
+
+#endif
+
+
+/* --------------------------------------------------------------------- */
+
+static void vgaHWSeqReset (struct savagefb_par *par, int start)
+{
+	if (start)
+		VGAwSEQ (0x00, 0x01);		/* Synchronous Reset */
+	else
+		VGAwSEQ (0x00, 0x03);		/* End Reset */
+}
+
+static void vgaHWProtect (struct savagefb_par *par, int on)
+{
+	unsigned char tmp;
+
+	if (on) {
+		/*
+		 * Turn off screen and disable sequencer.
+		 */
+		tmp = VGArSEQ (0x01);
+
+		vgaHWSeqReset (par, 1);	        /* start synchronous reset */
+		VGAwSEQ (0x01, tmp | 0x20);	/* disable the display */
+
+		VGAenablePalette();
+	} else {
+		/*
+		 * Reenable sequencer, then turn on screen.
+		 */
+
+		tmp = VGArSEQ (0x01);
+
+		VGAwSEQ (0x01, tmp & ~0x20);	/* reenable display */
+		vgaHWSeqReset (par, 0);	        /* clear synchronous reset */
+
+		VGAdisablePalette();
+	}
+}
+
+static void vgaHWRestore (struct savagefb_par  *par)
+{
+	int i;
+
+	VGAwMISC (par->MiscOutReg);
+
+	for (i = 1; i < 5; i++)
+		VGAwSEQ (i, par->Sequencer[i]);
+
+	/* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or
+	   CRTC[17] */
+	VGAwCR (17, par->CRTC[17] & ~0x80);
+
+	for (i = 0; i < 25; i++)
+		VGAwCR (i, par->CRTC[i]);
+
+	for (i = 0; i < 9; i++)
+		VGAwGR (i, par->Graphics[i]);
+
+	VGAenablePalette();
+
+	for (i = 0; i < 21; i++)
+		VGAwATTR (i, par->Attribute[i]);
+
+	VGAdisablePalette();
+}
+
+static void vgaHWInit (struct fb_var_screeninfo *var,
+		       struct savagefb_par            *par,
+		       struct xtimings                *timings)
+{
+	par->MiscOutReg = 0x23;
+
+	if (!(timings->sync & FB_SYNC_HOR_HIGH_ACT))
+		par->MiscOutReg |= 0x40;
+
+	if (!(timings->sync & FB_SYNC_VERT_HIGH_ACT))
+		par->MiscOutReg |= 0x80;
+
+	/*
+	 * Time Sequencer
+	 */
+	par->Sequencer[0x00] = 0x00;
+	par->Sequencer[0x01] = 0x01;
+	par->Sequencer[0x02] = 0x0F;
+	par->Sequencer[0x03] = 0x00;          /* Font select */
+	par->Sequencer[0x04] = 0x0E;          /* Misc */
+
+	/*
+	 * CRTC Controller
+	 */
+	par->CRTC[0x00] = (timings->HTotal >> 3) - 5;
+	par->CRTC[0x01] = (timings->HDisplay >> 3) - 1;
+	par->CRTC[0x02] = (timings->HSyncStart >> 3) - 1;
+	par->CRTC[0x03] = (((timings->HSyncEnd >> 3)  - 1) & 0x1f) | 0x80;
+	par->CRTC[0x04] = (timings->HSyncStart >> 3);
+	par->CRTC[0x05] = ((((timings->HSyncEnd >> 3) - 1) & 0x20) << 2) |
+		(((timings->HSyncEnd >> 3)) & 0x1f);
+	par->CRTC[0x06] = (timings->VTotal - 2) & 0xFF;
+	par->CRTC[0x07] = (((timings->VTotal - 2) & 0x100) >> 8) |
+		(((timings->VDisplay - 1) & 0x100) >> 7) |
+		((timings->VSyncStart & 0x100) >> 6) |
+		(((timings->VSyncStart - 1) & 0x100) >> 5) |
+		0x10 |
+		(((timings->VTotal - 2) & 0x200) >> 4) |
+		(((timings->VDisplay - 1) & 0x200) >> 3) |
+		((timings->VSyncStart & 0x200) >> 2);
+	par->CRTC[0x08] = 0x00;
+	par->CRTC[0x09] = (((timings->VSyncStart - 1) & 0x200) >> 4) | 0x40;
+
+	if (timings->dblscan)
+		par->CRTC[0x09] |= 0x80;
+
+	par->CRTC[0x0a] = 0x00;
+	par->CRTC[0x0b] = 0x00;
+	par->CRTC[0x0c] = 0x00;
+	par->CRTC[0x0d] = 0x00;
+	par->CRTC[0x0e] = 0x00;
+	par->CRTC[0x0f] = 0x00;
+	par->CRTC[0x10] = timings->VSyncStart & 0xff;
+	par->CRTC[0x11] = (timings->VSyncEnd & 0x0f) | 0x20;
+	par->CRTC[0x12] = (timings->VDisplay - 1) & 0xff;
+	par->CRTC[0x13] = var->xres_virtual >> 4;
+	par->CRTC[0x14] = 0x00;
+	par->CRTC[0x15] = (timings->VSyncStart - 1) & 0xff;
+	par->CRTC[0x16] = (timings->VSyncEnd - 1) & 0xff;
+	par->CRTC[0x17] = 0xc3;
+	par->CRTC[0x18] = 0xff;
+
+	/*
+	 * are these unnecessary?
+	 * vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN|KGA_ENABLE_ON_ZERO);
+	 * vgaHWVBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN|KGA_ENABLE_ON_ZERO);
+	 */
+
+	/*
+	 * Graphics Display Controller
+	 */
+	par->Graphics[0x00] = 0x00;
+	par->Graphics[0x01] = 0x00;
+	par->Graphics[0x02] = 0x00;
+	par->Graphics[0x03] = 0x00;
+	par->Graphics[0x04] = 0x00;
+	par->Graphics[0x05] = 0x40;
+	par->Graphics[0x06] = 0x05;   /* only map 64k VGA memory !!!! */
+	par->Graphics[0x07] = 0x0F;
+	par->Graphics[0x08] = 0xFF;
+
+
+	par->Attribute[0x00]  = 0x00; /* standard colormap translation */
+	par->Attribute[0x01]  = 0x01;
+	par->Attribute[0x02]  = 0x02;
+	par->Attribute[0x03]  = 0x03;
+	par->Attribute[0x04]  = 0x04;
+	par->Attribute[0x05]  = 0x05;
+	par->Attribute[0x06]  = 0x06;
+	par->Attribute[0x07]  = 0x07;
+	par->Attribute[0x08]  = 0x08;
+	par->Attribute[0x09]  = 0x09;
+	par->Attribute[0x0a] = 0x0A;
+	par->Attribute[0x0b] = 0x0B;
+	par->Attribute[0x0c] = 0x0C;
+	par->Attribute[0x0d] = 0x0D;
+	par->Attribute[0x0e] = 0x0E;
+	par->Attribute[0x0f] = 0x0F;
+	par->Attribute[0x10] = 0x41;
+	par->Attribute[0x11] = 0xFF;
+	par->Attribute[0x12] = 0x0F;
+	par->Attribute[0x13] = 0x00;
+	par->Attribute[0x14] = 0x00;
+}
+
+/* -------------------- Hardware specific routines ------------------------- */
+
+/*
+ * Hardware Acceleration for SavageFB
+ */
+
+/* Wait for fifo space */
+static void
+savage3D_waitfifo(struct savagefb_par *par, int space)
+{
+	int slots = MAXFIFO - space;
+
+	while ((savage_in32(0x48C00) & 0x0000ffff) > slots);
+}
+
+static void
+savage4_waitfifo(struct savagefb_par *par, int space)
+{
+	int slots = MAXFIFO - space;
+
+	while ((savage_in32(0x48C60) & 0x001fffff) > slots);
+}
+
+static void
+savage2000_waitfifo(struct savagefb_par *par, int space)
+{
+	int slots = MAXFIFO - space;
+
+	while ((savage_in32(0x48C60) & 0x0000ffff) > slots);
+}
+
+/* Wait for idle accelerator */
+static void
+savage3D_waitidle(struct savagefb_par *par)
+{
+	while ((savage_in32(0x48C00) & 0x0008ffff) != 0x80000);
+}
+
+static void
+savage4_waitidle(struct savagefb_par *par)
+{
+	while ((savage_in32(0x48C60) & 0x00a00000) != 0x00a00000);
+}
+
+static void
+savage2000_waitidle(struct savagefb_par *par)
+{
+	while ((savage_in32(0x48C60) & 0x009fffff));
+}
+
+
+static void
+SavageSetup2DEngine (struct savagefb_par  *par)
+{
+	unsigned long GlobalBitmapDescriptor;
+
+	GlobalBitmapDescriptor = 1 | 8 | BCI_BD_BW_DISABLE;
+	BCI_BD_SET_BPP (GlobalBitmapDescriptor, par->depth);
+	BCI_BD_SET_STRIDE (GlobalBitmapDescriptor, par->vwidth);
+
+	switch(par->chip) {
+	case S3_SAVAGE3D:
+	case S3_SAVAGE_MX:
+		/* Disable BCI */
+		savage_out32(0x48C18, savage_in32(0x48C18) & 0x3FF0);
+		/* Setup BCI command overflow buffer */
+		savage_out32(0x48C14, (par->cob_offset >> 11) | (par->cob_index << 29));
+		/* Program shadow status update. */
+		savage_out32(0x48C10, 0x78207220);
+		savage_out32(0x48C0C, 0);
+		/* Enable BCI and command overflow buffer */
+		savage_out32(0x48C18, savage_in32(0x48C18) | 0x0C);
+		break;
+	case S3_SAVAGE4:
+	case S3_PROSAVAGE:
+	case S3_SUPERSAVAGE:
+		/* Disable BCI */
+		savage_out32(0x48C18, savage_in32(0x48C18) & 0x3FF0);
+		/* Program shadow status update */
+		savage_out32(0x48C10, 0x00700040);
+		savage_out32(0x48C0C, 0);
+		/* Enable BCI without the COB */
+		savage_out32(0x48C18, savage_in32(0x48C18) | 0x08);
+		break;
+	case S3_SAVAGE2000:
+		/* Disable BCI */
+		savage_out32(0x48C18, 0);
+		/* Setup BCI command overflow buffer */
+		savage_out32(0x48C18, (par->cob_offset >> 7) | (par->cob_index));
+		/* Disable shadow status update */
+		savage_out32(0x48A30, 0);
+		/* Enable BCI and command overflow buffer */
+		savage_out32(0x48C18, savage_in32(0x48C18) | 0x00280000 );
+		break;
+	    default:
+		break;
+	}
+	/* Turn on 16-bit register access. */
+	vga_out8(0x3d4, 0x31);
+	vga_out8(0x3d5, 0x0c);
+
+	/* Set stride to use GBD. */
+	vga_out8 (0x3d4, 0x50);
+	vga_out8 (0x3d5, vga_in8 (0x3d5 ) | 0xC1);
+
+	/* Enable 2D engine. */
+	vga_out8 (0x3d4, 0x40 );
+	vga_out8 (0x3d5, 0x01 );
+
+	savage_out32 (MONO_PAT_0, ~0);
+	savage_out32 (MONO_PAT_1, ~0);
+
+	/* Setup plane masks */
+	savage_out32 (0x8128, ~0 ); /* enable all write planes */
+	savage_out32 (0x812C, ~0 ); /* enable all read planes */
+	savage_out16 (0x8134, 0x27 );
+	savage_out16 (0x8136, 0x07 );
+
+	/* Now set the GBD */
+	par->bci_ptr = 0;
+	par->SavageWaitFifo (par, 4);
+
+	BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_GBD1 );
+	BCI_SEND( 0 );
+	BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_GBD2 );
+	BCI_SEND( GlobalBitmapDescriptor );
+}
+
+
+static void SavageCalcClock(long freq, int min_m, int min_n1, int max_n1,
+			    int min_n2, int max_n2, long freq_min,
+			    long freq_max, unsigned int *mdiv,
+			    unsigned int *ndiv, unsigned int *r)
+{
+	long diff, best_diff;
+	unsigned int m;
+	unsigned char n1, n2, best_n1=16+2, best_n2=2, best_m=125+2;
+
+	if (freq < freq_min / (1 << max_n2)) {
+		printk (KERN_ERR "invalid frequency %ld Khz\n", freq);
+		freq = freq_min / (1 << max_n2);
+	}
+	if (freq > freq_max / (1 << min_n2)) {
+		printk (KERN_ERR "invalid frequency %ld Khz\n", freq);
+		freq = freq_max / (1 << min_n2);
+	}
+
+	/* work out suitable timings */
+	best_diff = freq;
+
+	for (n2=min_n2; n2<=max_n2; n2++) {
+		for (n1=min_n1+2; n1<=max_n1+2; n1++) {
+			m = (freq * n1 * (1 << n2) + HALF_BASE_FREQ) /
+				BASE_FREQ;
+			if (m < min_m+2 || m > 127+2)
+				continue;
+			if ((m * BASE_FREQ >= freq_min * n1) &&
+			    (m * BASE_FREQ <= freq_max * n1)) {
+				diff = freq * (1 << n2) * n1 - BASE_FREQ * m;
+				if (diff < 0)
+					diff = -diff;
+				if (diff < best_diff) {
+					best_diff = diff;
+					best_m = m;
+					best_n1 = n1;
+					best_n2 = n2;
+				}
+			}
+		}
+	}
+
+	*ndiv = best_n1 - 2;
+	*r = best_n2;
+	*mdiv = best_m - 2;
+}
+
+static int common_calc_clock(long freq, int min_m, int min_n1, int max_n1,
+			     int min_n2, int max_n2, long freq_min,
+			     long freq_max, unsigned char *mdiv,
+			     unsigned char *ndiv)
+{
+	long diff, best_diff;
+	unsigned int m;
+	unsigned char n1, n2;
+	unsigned char best_n1 = 16+2, best_n2 = 2, best_m = 125+2;
+
+	best_diff = freq;
+
+	for (n2 = min_n2; n2 <= max_n2; n2++) {
+		for (n1 = min_n1+2; n1 <= max_n1+2; n1++) {
+			m = (freq * n1 * (1 << n2) + HALF_BASE_FREQ) /
+				BASE_FREQ;
+			if (m < min_m + 2 || m > 127+2)
+				continue;
+			if((m * BASE_FREQ >= freq_min * n1) &&
+			   (m * BASE_FREQ <= freq_max * n1)) {
+				diff = freq * (1 << n2) * n1 - BASE_FREQ * m;
+				if(diff < 0)
+					diff = -diff;
+				if(diff < best_diff) {
+					best_diff = diff;
+					best_m = m;
+					best_n1 = n1;
+					best_n2 = n2;
+				}
+			}
+		}
+	}
+
+	if(max_n1 == 63)
+		*ndiv = (best_n1 - 2) | (best_n2 << 6);
+	else
+		*ndiv = (best_n1 - 2) | (best_n2 << 5);
+
+	*mdiv = best_m - 2;
+
+	return 0;
+}
+
+#ifdef SAVAGEFB_DEBUG
+/* This function is used to debug, it prints out the contents of s3 regs */
+
+static void SavagePrintRegs(void)
+{
+	unsigned char i;
+	int vgaCRIndex = 0x3d4;
+	int vgaCRReg = 0x3d5;
+
+	printk(KERN_DEBUG "SR    x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE "
+	       "xF" );
+
+	for( i = 0; i < 0x70; i++ ) {
+		if( !(i % 16) )
+			printk(KERN_DEBUG "\nSR%xx ", i >> 4 );
+		vga_out8( 0x3c4, i );
+		printk(KERN_DEBUG " %02x", vga_in8(0x3c5) );
+	}
+
+	printk(KERN_DEBUG "\n\nCR    x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC "
+	       "xD xE xF" );
+
+	for( i = 0; i < 0xB7; i++ ) {
+		if( !(i % 16) )
+			printk(KERN_DEBUG "\nCR%xx ", i >> 4 );
+		vga_out8( vgaCRIndex, i );
+		printk(KERN_DEBUG " %02x", vga_in8(vgaCRReg) );
+	}
+
+	printk(KERN_DEBUG "\n\n");
+}
+#endif
+
+/* --------------------------------------------------------------------- */
+
+static void savage_get_default_par(struct savagefb_par *par)
+{
+	unsigned char cr3a, cr53, cr66;
+
+	vga_out16 (0x3d4, 0x4838);
+	vga_out16 (0x3d4, 0xa039);
+	vga_out16 (0x3c4, 0x0608);
+
+	vga_out8 (0x3d4, 0x66);
+	cr66 = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr66 | 0x80);
+	vga_out8 (0x3d4, 0x3a);
+	cr3a = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr3a | 0x80);
+	vga_out8 (0x3d4, 0x53);
+	cr53 = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr53 & 0x7f);
+
+	vga_out8 (0x3d4, 0x66);
+	vga_out8 (0x3d5, cr66);
+	vga_out8 (0x3d4, 0x3a);
+	vga_out8 (0x3d5, cr3a);
+
+	vga_out8 (0x3d4, 0x66);
+	vga_out8 (0x3d5, cr66);
+	vga_out8 (0x3d4, 0x3a);
+	vga_out8 (0x3d5, cr3a);
+
+	/* unlock extended seq regs */
+	vga_out8 (0x3c4, 0x08);
+	par->SR08 = vga_in8 (0x3c5);
+	vga_out8 (0x3c5, 0x06);
+
+	/* now save all the extended regs we need */
+	vga_out8 (0x3d4, 0x31);
+	par->CR31 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x32);
+	par->CR32 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x34);
+	par->CR34 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x36);
+	par->CR36 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x3a);
+	par->CR3A = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x40);
+	par->CR40 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x42);
+	par->CR42 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x45);
+	par->CR45 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x50);
+	par->CR50 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x51);
+	par->CR51 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x53);
+	par->CR53 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x58);
+	par->CR58 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x60);
+	par->CR60 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x66);
+	par->CR66 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x67);
+	par->CR67 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x68);
+	par->CR68 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x69);
+	par->CR69 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x6f);
+	par->CR6F = vga_in8 (0x3d5);
+
+	vga_out8 (0x3d4, 0x33);
+	par->CR33 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x86);
+	par->CR86 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x88);
+	par->CR88 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x90);
+	par->CR90 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x91);
+	par->CR91 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0xb0);
+	par->CRB0 = vga_in8 (0x3d5) | 0x80;
+
+	/* extended mode timing regs */
+	vga_out8 (0x3d4, 0x3b);
+	par->CR3B = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x3c);
+	par->CR3C = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x43);
+	par->CR43 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x5d);
+	par->CR5D = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x5e);
+	par->CR5E = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x65);
+	par->CR65 = vga_in8 (0x3d5);
+
+	/* save seq extended regs for DCLK PLL programming */
+	vga_out8 (0x3c4, 0x0e);
+	par->SR0E = vga_in8 (0x3c5);
+	vga_out8 (0x3c4, 0x0f);
+	par->SR0F = vga_in8 (0x3c5);
+	vga_out8 (0x3c4, 0x10);
+	par->SR10 = vga_in8 (0x3c5);
+	vga_out8 (0x3c4, 0x11);
+	par->SR11 = vga_in8 (0x3c5);
+	vga_out8 (0x3c4, 0x12);
+	par->SR12 = vga_in8 (0x3c5);
+	vga_out8 (0x3c4, 0x13);
+	par->SR13 = vga_in8 (0x3c5);
+	vga_out8 (0x3c4, 0x29);
+	par->SR29 = vga_in8 (0x3c5);
+
+	vga_out8 (0x3c4, 0x15);
+	par->SR15 = vga_in8 (0x3c5);
+	vga_out8 (0x3c4, 0x30);
+	par->SR30 = vga_in8 (0x3c5);
+	vga_out8 (0x3c4, 0x18);
+	par->SR18 = vga_in8 (0x3c5);
+
+	/* Save flat panel expansion regsters. */
+	if (par->chip == S3_SAVAGE_MX) {
+		int i;
+
+		for (i = 0; i < 8; i++) {
+			vga_out8 (0x3c4, 0x54+i);
+			par->SR54[i] = vga_in8 (0x3c5);
+		}
+	}
+
+	vga_out8 (0x3d4, 0x66);
+	cr66 = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr66 | 0x80);
+	vga_out8 (0x3d4, 0x3a);
+	cr3a = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr3a | 0x80);
+
+	/* now save MIU regs */
+	if (par->chip != S3_SAVAGE_MX) {
+		par->MMPR0 = savage_in32(FIFO_CONTROL_REG);
+		par->MMPR1 = savage_in32(MIU_CONTROL_REG);
+		par->MMPR2 = savage_in32(STREAMS_TIMEOUT_REG);
+		par->MMPR3 = savage_in32(MISC_TIMEOUT_REG);
+	}
+
+	vga_out8 (0x3d4, 0x3a);
+	vga_out8 (0x3d5, cr3a);
+	vga_out8 (0x3d4, 0x66);
+	vga_out8 (0x3d5, cr66);
+}
+
+static void savage_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb)
+{
+	var->xres = var->xres_virtual = modedb->xres;
+	var->yres = modedb->yres;
+        if (var->yres_virtual < var->yres)
+	    var->yres_virtual = var->yres;
+        var->xoffset = var->yoffset = 0;
+        var->pixclock = modedb->pixclock;
+        var->left_margin = modedb->left_margin;
+        var->right_margin = modedb->right_margin;
+        var->upper_margin = modedb->upper_margin;
+        var->lower_margin = modedb->lower_margin;
+        var->hsync_len = modedb->hsync_len;
+        var->vsync_len = modedb->vsync_len;
+        var->sync = modedb->sync;
+        var->vmode = modedb->vmode;
+}
+
+static int savagefb_check_var (struct fb_var_screeninfo   *var,
+			       struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	int memlen, vramlen, mode_valid = 0;
+
+	DBG("savagefb_check_var");
+
+	var->transp.offset = 0;
+	var->transp.length = 0;
+	switch (var->bits_per_pixel) {
+	case 8:
+		var->red.offset = var->green.offset =
+			var->blue.offset = 0;
+		var->red.length = var->green.length =
+			var->blue.length = var->bits_per_pixel;
+		break;
+	case 16:
+		var->red.offset = 11;
+		var->red.length = 5;
+		var->green.offset = 5;
+		var->green.length = 6;
+		var->blue.offset = 0;
+		var->blue.length = 5;
+		break;
+	case 32:
+		var->transp.offset = 24;
+		var->transp.length = 8;
+		var->red.offset = 16;
+		var->red.length = 8;
+		var->green.offset = 8;
+		var->green.length = 8;
+		var->blue.offset = 0;
+		var->blue.length = 8;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	if (!info->monspecs.hfmax || !info->monspecs.vfmax ||
+	    !info->monspecs.dclkmax || !fb_validate_mode(var, info))
+		mode_valid = 1;
+
+	/* calculate modeline if supported by monitor */
+	if (!mode_valid && info->monspecs.gtf) {
+		if (!fb_get_mode(FB_MAXTIMINGS, 0, var, info))
+			mode_valid = 1;
+	}
+
+	if (!mode_valid) {
+		struct fb_videomode *mode;
+
+		mode = fb_find_best_mode(var, &info->modelist);
+		if (mode) {
+			savage_update_var(var, mode);
+			mode_valid = 1;
+		}
+	}
+
+	if (!mode_valid && info->monspecs.modedb_len)
+		return -EINVAL;
+
+	/* Is the mode larger than the LCD panel? */
+	if (par->SavagePanelWidth &&
+	    (var->xres > par->SavagePanelWidth ||
+	     var->yres > par->SavagePanelHeight)) {
+		printk (KERN_INFO "Mode (%dx%d) larger than the LCD panel "
+			"(%dx%d)\n", var->xres,  var->yres,
+			par->SavagePanelWidth,
+			par->SavagePanelHeight);
+		return -1;
+	}
+
+	if (var->yres_virtual < var->yres)
+		var->yres_virtual = var->yres;
+	if (var->xres_virtual < var->xres)
+		var->xres_virtual = var->xres;
+
+	vramlen = info->fix.smem_len;
+
+	memlen = var->xres_virtual * var->bits_per_pixel *
+		var->yres_virtual / 8;
+	if (memlen > vramlen) {
+		var->yres_virtual = vramlen * 8 /
+			(var->xres_virtual * var->bits_per_pixel);
+		memlen = var->xres_virtual * var->bits_per_pixel *
+			var->yres_virtual / 8;
+	}
+
+	/* we must round yres/xres down, we already rounded y/xres_virtual up
+	   if it was possible. We should return -EINVAL, but I disagree */
+	if (var->yres_virtual < var->yres)
+		var->yres = var->yres_virtual;
+	if (var->xres_virtual < var->xres)
+		var->xres = var->xres_virtual;
+	if (var->xoffset + var->xres > var->xres_virtual)
+		var->xoffset = var->xres_virtual - var->xres;
+	if (var->yoffset + var->yres > var->yres_virtual)
+		var->yoffset = var->yres_virtual - var->yres;
+
+	return 0;
+}
+
+
+static int savagefb_decode_var (struct fb_var_screeninfo   *var,
+				struct savagefb_par        *par)
+{
+	struct xtimings timings;
+	int width, dclk, i, j; /*, refresh; */
+	unsigned int m, n, r;
+	unsigned char tmp = 0;
+	unsigned int pixclock = var->pixclock;
+
+	DBG("savagefb_decode_var");
+
+	memset (&timings, 0, sizeof(timings));
+
+	if (!pixclock) pixclock = 10000;	/* 10ns = 100MHz */
+	timings.Clock = 1000000000 / pixclock;
+	if (timings.Clock < 1) timings.Clock = 1;
+	timings.dblscan = var->vmode & FB_VMODE_DOUBLE;
+	timings.interlaced = var->vmode & FB_VMODE_INTERLACED;
+	timings.HDisplay = var->xres;
+	timings.HSyncStart = timings.HDisplay + var->right_margin;
+	timings.HSyncEnd = timings.HSyncStart + var->hsync_len;
+	timings.HTotal = timings.HSyncEnd + var->left_margin;
+	timings.VDisplay = var->yres;
+	timings.VSyncStart = timings.VDisplay + var->lower_margin;
+	timings.VSyncEnd = timings.VSyncStart + var->vsync_len;
+	timings.VTotal = timings.VSyncEnd + var->upper_margin;
+	timings.sync = var->sync;
+
+
+	par->depth  = var->bits_per_pixel;
+	par->vwidth = var->xres_virtual;
+
+	if (var->bits_per_pixel == 16  &&  par->chip == S3_SAVAGE3D) {
+		timings.HDisplay *= 2;
+		timings.HSyncStart *= 2;
+		timings.HSyncEnd *= 2;
+		timings.HTotal *= 2;
+	}
+
+	/*
+	 * This will allocate the datastructure and initialize all of the
+	 * generic VGA registers.
+	 */
+	vgaHWInit (var, par, &timings);
+
+	/* We need to set CR67 whether or not we use the BIOS. */
+
+	dclk = timings.Clock;
+	par->CR67 = 0x00;
+
+	switch( var->bits_per_pixel ) {
+	case 8:
+		if( (par->chip == S3_SAVAGE2000) && (dclk >= 230000) )
+			par->CR67 = 0x10;	/* 8bpp, 2 pixels/clock */
+		else
+			par->CR67 = 0x00;	/* 8bpp, 1 pixel/clock */
+		break;
+	case 15:
+		if ( S3_SAVAGE_MOBILE_SERIES(par->chip) ||
+		     ((par->chip == S3_SAVAGE2000) && (dclk >= 230000)) )
+			par->CR67 = 0x30;	/* 15bpp, 2 pixel/clock */
+		else
+			par->CR67 = 0x20;	/* 15bpp, 1 pixels/clock */
+		break;
+	case 16:
+		if( S3_SAVAGE_MOBILE_SERIES(par->chip) ||
+		    ((par->chip == S3_SAVAGE2000) && (dclk >= 230000)) )
+			par->CR67 = 0x50;	/* 16bpp, 2 pixel/clock */
+		else
+			par->CR67 = 0x40;	/* 16bpp, 1 pixels/clock */
+		break;
+	case 24:
+		par->CR67 = 0x70;
+		break;
+	case 32:
+		par->CR67 = 0xd0;
+		break;
+	}
+
+	/*
+	 * Either BIOS use is disabled, or we failed to find a suitable
+	 * match.  Fall back to traditional register-crunching.
+	 */
+
+	vga_out8 (0x3d4, 0x3a);
+	tmp = vga_in8 (0x3d5);
+	if (1 /*FIXME:psav->pci_burst*/)
+		par->CR3A = (tmp & 0x7f) | 0x15;
+	else
+		par->CR3A = tmp | 0x95;
+
+	par->CR53 = 0x00;
+	par->CR31 = 0x8c;
+	par->CR66 = 0x89;
+
+	vga_out8 (0x3d4, 0x58);
+	par->CR58 = vga_in8 (0x3d5) & 0x80;
+	par->CR58 |= 0x13;
+
+	par->SR15 = 0x03 | 0x80;
+	par->SR18 = 0x00;
+	par->CR43 = par->CR45 = par->CR65 = 0x00;
+
+	vga_out8 (0x3d4, 0x40);
+	par->CR40 = vga_in8 (0x3d5) & ~0x01;
+
+	par->MMPR0 = 0x010400;
+	par->MMPR1 = 0x00;
+	par->MMPR2 = 0x0808;
+	par->MMPR3 = 0x08080810;
+
+	SavageCalcClock (dclk, 1, 1, 127, 0, 4, 180000, 360000, &m, &n, &r);
+	/* m = 107; n = 4; r = 2; */
+
+	if (par->MCLK <= 0) {
+		par->SR10 = 255;
+		par->SR11 = 255;
+	} else {
+		common_calc_clock (par->MCLK, 1, 1, 31, 0, 3, 135000, 270000,
+				   &par->SR11, &par->SR10);
+		/*      par->SR10 = 80; // MCLK == 286000 */
+		/*      par->SR11 = 125; */
+	}
+
+	par->SR12 = (r << 6) | (n & 0x3f);
+	par->SR13 = m & 0xff;
+	par->SR29 = (r & 4) | (m & 0x100) >> 5 | (n & 0x40) >> 2;
+
+	if (var->bits_per_pixel < 24)
+		par->MMPR0 -= 0x8000;
+	else
+		par->MMPR0 -= 0x4000;
+
+	if (timings.interlaced)
+		par->CR42 = 0x20;
+	else
+		par->CR42 = 0x00;
+
+	par->CR34 = 0x10; /* display fifo */
+
+	i = ((((timings.HTotal >> 3) - 5) & 0x100) >> 8) |
+		((((timings.HDisplay >> 3) - 1) & 0x100) >> 7) |
+		((((timings.HSyncStart >> 3) - 1) & 0x100) >> 6) |
+		((timings.HSyncStart & 0x800) >> 7);
+
+	if ((timings.HSyncEnd >> 3) - (timings.HSyncStart >> 3) > 64)
+		i |= 0x08;
+	if ((timings.HSyncEnd >> 3) - (timings.HSyncStart >> 3) > 32)
+		i |= 0x20;
+
+	j = (par->CRTC[0] + ((i & 0x01) << 8) +
+	     par->CRTC[4] + ((i & 0x10) << 4) + 1) / 2;
+
+	if (j - (par->CRTC[4] + ((i & 0x10) << 4)) < 4) {
+		if (par->CRTC[4] + ((i & 0x10) << 4) + 4 <=
+		    par->CRTC[0] + ((i & 0x01) << 8))
+			j = par->CRTC[4] + ((i & 0x10) << 4) + 4;
+		else
+			j = par->CRTC[0] + ((i & 0x01) << 8) + 1;
+	}
+
+	par->CR3B = j & 0xff;
+	i |= (j & 0x100) >> 2;
+	par->CR3C = (par->CRTC[0] + ((i & 0x01) << 8)) / 2;
+	par->CR5D = i;
+	par->CR5E = (((timings.VTotal - 2) & 0x400) >> 10) |
+		(((timings.VDisplay - 1) & 0x400) >> 9) |
+		(((timings.VSyncStart) & 0x400) >> 8) |
+		(((timings.VSyncStart) & 0x400) >> 6) | 0x40;
+	width = (var->xres_virtual * ((var->bits_per_pixel+7) / 8)) >> 3;
+	par->CR91 = par->CRTC[19] = 0xff & width;
+	par->CR51 = (0x300 & width) >> 4;
+	par->CR90 = 0x80 | (width >> 8);
+	par->MiscOutReg |= 0x0c;
+
+	/* Set frame buffer description. */
+
+	if (var->bits_per_pixel <= 8)
+		par->CR50 = 0;
+	else if (var->bits_per_pixel <= 16)
+		par->CR50 = 0x10;
+	else
+		par->CR50 = 0x30;
+
+	if (var->xres_virtual <= 640)
+		par->CR50 |= 0x40;
+	else if (var->xres_virtual == 800)
+		par->CR50 |= 0x80;
+	else if (var->xres_virtual == 1024)
+		par->CR50 |= 0x00;
+	else if (var->xres_virtual == 1152)
+		par->CR50 |= 0x01;
+	else if (var->xres_virtual == 1280)
+		par->CR50 |= 0xc0;
+	else if (var->xres_virtual == 1600)
+		par->CR50 |= 0x81;
+	else
+		par->CR50 |= 0xc1;	/* Use GBD */
+
+	if( par->chip == S3_SAVAGE2000 )
+		par->CR33 = 0x08;
+	else
+		par->CR33 = 0x20;
+
+	par->CRTC[0x17] = 0xeb;
+
+	par->CR67 |= 1;
+
+	vga_out8(0x3d4, 0x36);
+	par->CR36 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x68);
+	par->CR68 = vga_in8 (0x3d5);
+	par->CR69 = 0;
+	vga_out8 (0x3d4, 0x6f);
+	par->CR6F = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x86);
+	par->CR86 = vga_in8 (0x3d5);
+	vga_out8 (0x3d4, 0x88);
+	par->CR88 = vga_in8 (0x3d5) | 0x08;
+	vga_out8 (0x3d4, 0xb0);
+	par->CRB0 = vga_in8 (0x3d5) | 0x80;
+
+	return 0;
+}
+
+/* --------------------------------------------------------------------- */
+
+/*
+ *    Set a single color register. Return != 0 for invalid regno.
+ */
+static int savagefb_setcolreg(unsigned        regno,
+			      unsigned        red,
+			      unsigned        green,
+			      unsigned        blue,
+			      unsigned        transp,
+			      struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+
+	if (regno >= NR_PALETTE)
+		return -EINVAL;
+
+	par->palette[regno].red    = red;
+	par->palette[regno].green  = green;
+	par->palette[regno].blue   = blue;
+	par->palette[regno].transp = transp;
+
+	switch (info->var.bits_per_pixel) {
+	case 8:
+		vga_out8 (0x3c8, regno);
+
+		vga_out8 (0x3c9, red   >> 10);
+		vga_out8 (0x3c9, green >> 10);
+		vga_out8 (0x3c9, blue  >> 10);
+		break;
+
+	case 16:
+		if (regno < 16)
+			((u32 *)info->pseudo_palette)[regno] =
+				((red   & 0xf800)      ) |
+				((green & 0xfc00) >>  5) |
+				((blue  & 0xf800) >> 11);
+		break;
+
+	case 24:
+		if (regno < 16)
+			((u32 *)info->pseudo_palette)[regno] =
+				((red    & 0xff00) <<  8) |
+				((green  & 0xff00)      ) |
+				((blue   & 0xff00) >>  8);
+		break;
+	case 32:
+		if (regno < 16)
+			((u32 *)info->pseudo_palette)[regno] =
+				((transp & 0xff00) << 16) |
+				((red    & 0xff00) <<  8) |
+				((green  & 0xff00)      ) |
+				((blue   & 0xff00) >>  8);
+		break;
+
+	default:
+		return 1;
+	}
+
+	return 0;
+}
+
+static void savagefb_set_par_int (struct savagefb_par  *par)
+{
+	unsigned char tmp, cr3a, cr66, cr67;
+
+	DBG ("savagefb_set_par_int");
+
+	par->SavageWaitIdle (par);
+
+	vga_out8 (0x3c2, 0x23);
+
+	vga_out16 (0x3d4, 0x4838);
+	vga_out16 (0x3d4, 0xa539);
+	vga_out16 (0x3c4, 0x0608);
+
+	vgaHWProtect (par, 1);
+
+	/*
+	 * Some Savage/MX and /IX systems go nuts when trying to exit the
+	 * server after WindowMaker has displayed a gradient background.  I
+	 * haven't been able to find what causes it, but a non-destructive
+	 * switch to mode 3 here seems to eliminate the issue.
+	 */
+
+	VerticalRetraceWait();
+	vga_out8 (0x3d4, 0x67);
+	cr67 = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr67/*par->CR67*/ & ~0x0c); /* no STREAMS yet */
+
+	vga_out8 (0x3d4, 0x23);
+	vga_out8 (0x3d5, 0x00);
+	vga_out8 (0x3d4, 0x26);
+	vga_out8 (0x3d5, 0x00);
+
+	/* restore extended regs */
+	vga_out8 (0x3d4, 0x66);
+	vga_out8 (0x3d5, par->CR66);
+	vga_out8 (0x3d4, 0x3a);
+	vga_out8 (0x3d5, par->CR3A);
+	vga_out8 (0x3d4, 0x31);
+	vga_out8 (0x3d5, par->CR31);
+	vga_out8 (0x3d4, 0x32);
+	vga_out8 (0x3d5, par->CR32);
+	vga_out8 (0x3d4, 0x58);
+	vga_out8 (0x3d5, par->CR58);
+	vga_out8 (0x3d4, 0x53);
+	vga_out8 (0x3d5, par->CR53 & 0x7f);
+
+	vga_out16 (0x3c4, 0x0608);
+
+	/* Restore DCLK registers. */
+
+	vga_out8 (0x3c4, 0x0e);
+	vga_out8 (0x3c5, par->SR0E);
+	vga_out8 (0x3c4, 0x0f);
+	vga_out8 (0x3c5, par->SR0F);
+	vga_out8 (0x3c4, 0x29);
+	vga_out8 (0x3c5, par->SR29);
+	vga_out8 (0x3c4, 0x15);
+	vga_out8 (0x3c5, par->SR15);
+
+	/* Restore flat panel expansion regsters. */
+	if( par->chip == S3_SAVAGE_MX ) {
+		int i;
+
+		for( i = 0; i < 8; i++ ) {
+			vga_out8 (0x3c4, 0x54+i);
+			vga_out8 (0x3c5, par->SR54[i]);
+		}
+	}
+
+	vgaHWRestore (par);
+
+	/* extended mode timing registers */
+	vga_out8 (0x3d4, 0x53);
+	vga_out8 (0x3d5, par->CR53);
+	vga_out8 (0x3d4, 0x5d);
+	vga_out8 (0x3d5, par->CR5D);
+	vga_out8 (0x3d4, 0x5e);
+	vga_out8 (0x3d5, par->CR5E);
+	vga_out8 (0x3d4, 0x3b);
+	vga_out8 (0x3d5, par->CR3B);
+	vga_out8 (0x3d4, 0x3c);
+	vga_out8 (0x3d5, par->CR3C);
+	vga_out8 (0x3d4, 0x43);
+	vga_out8 (0x3d5, par->CR43);
+	vga_out8 (0x3d4, 0x65);
+	vga_out8 (0x3d5, par->CR65);
+
+	/* restore the desired video mode with cr67 */
+	vga_out8 (0x3d4, 0x67);
+	/* following part not present in X11 driver */
+	cr67 = vga_in8 (0x3d5) & 0xf;
+	vga_out8 (0x3d5, 0x50 | cr67);
+	udelay (10000);
+	vga_out8 (0x3d4, 0x67);
+	/* end of part */
+	vga_out8 (0x3d5, par->CR67 & ~0x0c);
+
+	/* other mode timing and extended regs */
+	vga_out8 (0x3d4, 0x34);
+	vga_out8 (0x3d5, par->CR34);
+	vga_out8 (0x3d4, 0x40);
+	vga_out8 (0x3d5, par->CR40);
+	vga_out8 (0x3d4, 0x42);
+	vga_out8 (0x3d5, par->CR42);
+	vga_out8 (0x3d4, 0x45);
+	vga_out8 (0x3d5, par->CR45);
+	vga_out8 (0x3d4, 0x50);
+	vga_out8 (0x3d5, par->CR50);
+	vga_out8 (0x3d4, 0x51);
+	vga_out8 (0x3d5, par->CR51);
+
+	/* memory timings */
+	vga_out8 (0x3d4, 0x36);
+	vga_out8 (0x3d5, par->CR36);
+	vga_out8 (0x3d4, 0x60);
+	vga_out8 (0x3d5, par->CR60);
+	vga_out8 (0x3d4, 0x68);
+	vga_out8 (0x3d5, par->CR68);
+	vga_out8 (0x3d4, 0x69);
+	vga_out8 (0x3d5, par->CR69);
+	vga_out8 (0x3d4, 0x6f);
+	vga_out8 (0x3d5, par->CR6F);
+
+	vga_out8 (0x3d4, 0x33);
+	vga_out8 (0x3d5, par->CR33);
+	vga_out8 (0x3d4, 0x86);
+	vga_out8 (0x3d5, par->CR86);
+	vga_out8 (0x3d4, 0x88);
+	vga_out8 (0x3d5, par->CR88);
+	vga_out8 (0x3d4, 0x90);
+	vga_out8 (0x3d5, par->CR90);
+	vga_out8 (0x3d4, 0x91);
+	vga_out8 (0x3d5, par->CR91);
+
+	if (par->chip == S3_SAVAGE4) {
+		vga_out8 (0x3d4, 0xb0);
+		vga_out8 (0x3d5, par->CRB0);
+	}
+
+	vga_out8 (0x3d4, 0x32);
+	vga_out8 (0x3d5, par->CR32);
+
+	/* unlock extended seq regs */
+	vga_out8 (0x3c4, 0x08);
+	vga_out8 (0x3c5, 0x06);
+
+	/* Restore extended sequencer regs for MCLK. SR10 == 255 indicates
+	 * that we should leave the default SR10 and SR11 values there.
+	 */
+	if (par->SR10 != 255) {
+		vga_out8 (0x3c4, 0x10);
+		vga_out8 (0x3c5, par->SR10);
+		vga_out8 (0x3c4, 0x11);
+		vga_out8 (0x3c5, par->SR11);
+	}
+
+	/* restore extended seq regs for dclk */
+	vga_out8 (0x3c4, 0x0e);
+	vga_out8 (0x3c5, par->SR0E);
+	vga_out8 (0x3c4, 0x0f);
+	vga_out8 (0x3c5, par->SR0F);
+	vga_out8 (0x3c4, 0x12);
+	vga_out8 (0x3c5, par->SR12);
+	vga_out8 (0x3c4, 0x13);
+	vga_out8 (0x3c5, par->SR13);
+	vga_out8 (0x3c4, 0x29);
+	vga_out8 (0x3c5, par->SR29);
+
+	vga_out8 (0x3c4, 0x18);
+	vga_out8 (0x3c5, par->SR18);
+
+	/* load new m, n pll values for dclk & mclk */
+	vga_out8 (0x3c4, 0x15);
+	tmp = vga_in8 (0x3c5) & ~0x21;
+
+	vga_out8 (0x3c5, tmp | 0x03);
+	vga_out8 (0x3c5, tmp | 0x23);
+	vga_out8 (0x3c5, tmp | 0x03);
+	vga_out8 (0x3c5, par->SR15);
+	udelay (100);
+
+	vga_out8 (0x3c4, 0x30);
+	vga_out8 (0x3c5, par->SR30);
+	vga_out8 (0x3c4, 0x08);
+	vga_out8 (0x3c5, par->SR08);
+
+	/* now write out cr67 in full, possibly starting STREAMS */
+	VerticalRetraceWait();
+	vga_out8 (0x3d4, 0x67);
+	vga_out8 (0x3d5, par->CR67);
+
+	vga_out8 (0x3d4, 0x66);
+	cr66 = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr66 | 0x80);
+	vga_out8 (0x3d4, 0x3a);
+	cr3a = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr3a | 0x80);
+
+	if (par->chip != S3_SAVAGE_MX) {
+		VerticalRetraceWait();
+		savage_out32 (FIFO_CONTROL_REG, par->MMPR0);
+		par->SavageWaitIdle (par);
+		savage_out32 (MIU_CONTROL_REG, par->MMPR1);
+		par->SavageWaitIdle (par);
+		savage_out32 (STREAMS_TIMEOUT_REG, par->MMPR2);
+		par->SavageWaitIdle (par);
+		savage_out32 (MISC_TIMEOUT_REG, par->MMPR3);
+	}
+
+	vga_out8 (0x3d4, 0x66);
+	vga_out8 (0x3d5, cr66);
+	vga_out8 (0x3d4, 0x3a);
+	vga_out8 (0x3d5, cr3a);
+
+	SavageSetup2DEngine (par);
+	vgaHWProtect (par, 0);
+}
+
+static void savagefb_update_start (struct savagefb_par      *par,
+				   struct fb_var_screeninfo *var)
+{
+	int base;
+
+	base = ((var->yoffset * var->xres_virtual + (var->xoffset & ~1))
+		* ((var->bits_per_pixel+7) / 8)) >> 2;
+
+	/* now program the start address registers */
+	vga_out16(0x3d4, (base & 0x00ff00) | 0x0c);
+	vga_out16(0x3d4, ((base & 0x00ff) << 8) | 0x0d);
+	vga_out8 (0x3d4, 0x69);
+	vga_out8 (0x3d5, (base & 0x7f0000) >> 16);
+}
+
+
+static void savagefb_set_fix(struct fb_info *info)
+{
+	info->fix.line_length = info->var.xres_virtual *
+		info->var.bits_per_pixel / 8;
+
+	if (info->var.bits_per_pixel == 8)
+		info->fix.visual      = FB_VISUAL_PSEUDOCOLOR;
+	else
+		info->fix.visual      = FB_VISUAL_TRUECOLOR;
+}
+
+#if defined(CONFIG_FB_SAVAGE_ACCEL)
+static void savagefb_set_clip(struct fb_info *info)
+{
+    struct savagefb_par *par = (struct savagefb_par *)info->par;
+    int cmd;
+
+    cmd = BCI_CMD_NOP | BCI_CMD_CLIP_NEW;
+    par->bci_ptr = 0;
+    par->SavageWaitFifo(par,3);
+    BCI_SEND(cmd);
+    BCI_SEND(BCI_CLIP_TL(0, 0));
+    BCI_SEND(BCI_CLIP_BR(0xfff, 0xfff));
+}
+#endif
+
+static int savagefb_set_par (struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	struct fb_var_screeninfo *var = &info->var;
+	int err;
+
+	DBG("savagefb_set_par");
+	err = savagefb_decode_var (var, par);
+	if (err)
+		return err;
+
+	if (par->dacSpeedBpp <= 0) {
+		if (var->bits_per_pixel > 24)
+			par->dacSpeedBpp = par->clock[3];
+		else if (var->bits_per_pixel >= 24)
+			par->dacSpeedBpp = par->clock[2];
+		else if ((var->bits_per_pixel > 8) && (var->bits_per_pixel < 24))
+			par->dacSpeedBpp = par->clock[1];
+		else if (var->bits_per_pixel <= 8)
+			par->dacSpeedBpp = par->clock[0];
+	}
+
+	/* Set ramdac limits */
+	par->maxClock = par->dacSpeedBpp;
+	par->minClock = 10000;
+
+	savagefb_set_par_int (par);
+	savagefb_update_start (par, var);
+	fb_set_cmap (&info->cmap, info);
+	savagefb_set_fix(info);
+	savagefb_set_clip(info);
+
+	SavagePrintRegs();
+	return 0;
+}
+
+/*
+ *    Pan or Wrap the Display
+ */
+static int savagefb_pan_display (struct fb_var_screeninfo *var,
+				 struct fb_info           *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	u_int y_bottom;
+
+	y_bottom = var->yoffset;
+
+	if (!(var->vmode & FB_VMODE_YWRAP))
+		y_bottom += var->yres;
+
+	if (var->xoffset > (var->xres_virtual - var->xres))
+		return -EINVAL;
+	if (y_bottom > info->var.yres_virtual)
+		return -EINVAL;
+
+	savagefb_update_start (par, var);
+
+	info->var.xoffset = var->xoffset;
+	info->var.yoffset = var->yoffset;
+
+	if (var->vmode & FB_VMODE_YWRAP)
+		info->var.vmode |= FB_VMODE_YWRAP;
+	else
+		info->var.vmode &= ~FB_VMODE_YWRAP;
+
+	return 0;
+}
+
+
+static struct fb_ops savagefb_ops = {
+	.owner          = THIS_MODULE,
+	.fb_check_var   = savagefb_check_var,
+	.fb_set_par     = savagefb_set_par,
+	.fb_setcolreg   = savagefb_setcolreg,
+	.fb_pan_display = savagefb_pan_display,
+#if defined(CONFIG_FB_SAVAGE_ACCEL)
+	.fb_fillrect    = savagefb_fillrect,
+	.fb_copyarea    = savagefb_copyarea,
+	.fb_imageblit   = savagefb_imageblit,
+	.fb_sync        = savagefb_sync,
+#else
+	.fb_fillrect    = cfb_fillrect,
+	.fb_copyarea    = cfb_copyarea,
+	.fb_imageblit   = cfb_imageblit,
+#endif
+	.fb_cursor      = soft_cursor,
+};
+
+/* --------------------------------------------------------------------- */
+
+static struct fb_var_screeninfo __devinitdata savagefb_var800x600x8 = {
+	.accel_flags =	FB_ACCELF_TEXT,
+	.xres =		800,
+	.yres =		600,
+	.xres_virtual =  800,
+	.yres_virtual =  600,
+	.bits_per_pixel = 8,
+	.pixclock =	25000,
+	.left_margin =	88,
+	.right_margin =	40,
+	.upper_margin =	23,
+	.lower_margin =	1,
+	.hsync_len =	128,
+	.vsync_len =	4,
+	.sync =		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+	.vmode =	FB_VMODE_NONINTERLACED
+};
+
+static void savage_enable_mmio (struct savagefb_par *par)
+{
+	unsigned char val;
+
+	DBG ("savage_enable_mmio\n");
+
+	val = vga_in8 (0x3c3);
+	vga_out8 (0x3c3, val | 0x01);
+	val = vga_in8 (0x3cc);
+	vga_out8 (0x3c2, val | 0x01);
+
+	if (par->chip >= S3_SAVAGE4) {
+		vga_out8 (0x3d4, 0x40);
+		val = vga_in8 (0x3d5);
+		vga_out8 (0x3d5, val | 1);
+	}
+}
+
+
+void savage_disable_mmio (struct savagefb_par *par)
+{
+	unsigned char val;
+
+	DBG ("savage_disable_mmio\n");
+
+	if(par->chip >= S3_SAVAGE4 ) {
+		vga_out8 (0x3d4, 0x40);
+		val = vga_in8 (0x3d5);
+		vga_out8 (0x3d5, val | 1);
+	}
+}
+
+
+static int __devinit savage_map_mmio (struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	DBG ("savage_map_mmio");
+
+	if (S3_SAVAGE3D_SERIES (par->chip))
+		par->mmio.pbase = pci_resource_start (par->pcidev, 0) +
+			SAVAGE_NEWMMIO_REGBASE_S3;
+	else
+		par->mmio.pbase = pci_resource_start (par->pcidev, 0) +
+			SAVAGE_NEWMMIO_REGBASE_S4;
+
+	par->mmio.len = SAVAGE_NEWMMIO_REGSIZE;
+
+	par->mmio.vbase = ioremap (par->mmio.pbase, par->mmio.len);
+	if (!par->mmio.vbase) {
+		printk ("savagefb: unable to map memory mapped IO\n");
+		return -ENOMEM;
+	} else
+		printk (KERN_INFO "savagefb: mapped io at %p\n",
+			par->mmio.vbase);
+
+	info->fix.mmio_start = par->mmio.pbase;
+	info->fix.mmio_len   = par->mmio.len;
+
+	par->bci_base = (u32 __iomem *)(par->mmio.vbase + BCI_BUFFER_OFFSET);
+	par->bci_ptr  = 0;
+
+	savage_enable_mmio (par);
+
+	return 0;
+}
+
+static void __devinit savage_unmap_mmio (struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	DBG ("savage_unmap_mmio");
+
+	savage_disable_mmio(par);
+
+	if (par->mmio.vbase) {
+		iounmap ((void __iomem *)par->mmio.vbase);
+		par->mmio.vbase = NULL;
+	}
+}
+
+static int __devinit savage_map_video (struct fb_info *info,
+				       int video_len)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	int resource;
+
+	DBG("savage_map_video");
+
+	if (S3_SAVAGE3D_SERIES (par->chip))
+		resource = 0;
+	else
+		resource = 1;
+
+	par->video.pbase = pci_resource_start (par->pcidev, resource);
+	par->video.len   = video_len;
+	par->video.vbase = ioremap (par->video.pbase, par->video.len);
+
+	if (!par->video.vbase) {
+		printk ("savagefb: unable to map screen memory\n");
+		return -ENOMEM;
+	} else
+		printk (KERN_INFO "savagefb: mapped framebuffer at %p, "
+			"pbase == %x\n", par->video.vbase, par->video.pbase);
+
+	info->fix.smem_start = par->video.pbase;
+	info->fix.smem_len   = par->video.len - par->cob_size;
+	info->screen_base    = par->video.vbase;
+
+#ifdef CONFIG_MTRR
+	par->video.mtrr = mtrr_add (par->video.pbase, video_len,
+				     MTRR_TYPE_WRCOMB, 1);
+#endif
+	return 0;
+}
+
+static void __devinit savage_unmap_video (struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+
+	DBG("savage_unmap_video");
+
+	if (par->video.vbase) {
+#ifdef CONFIG_MTRR
+		mtrr_del (par->video.mtrr, par->video.pbase, par->video.len);
+#endif
+
+		iounmap (par->video.vbase);
+		par->video.vbase = NULL;
+		info->screen_base = NULL;
+	}
+}
+
+static int __devinit savage_init_hw (struct savagefb_par *par)
+{
+	unsigned char config1, m, n, n1, n2, sr8, cr3f, cr66 = 0, tmp;
+
+	static unsigned char RamSavage3D[] = { 8, 4, 4, 2 };
+	static unsigned char RamSavage4[] =  { 2, 4, 8, 12, 16, 32, 64, 32 };
+	static unsigned char RamSavageMX[] = { 2, 8, 4, 16, 8, 16, 4, 16 };
+	static unsigned char RamSavageNB[] = { 0, 2, 4, 8, 16, 32, 2, 2 };
+
+	int videoRam, videoRambytes;
+
+	DBG("savage_init_hw");
+
+	/* unprotect CRTC[0-7] */
+	vga_out8(0x3d4, 0x11);
+	tmp = vga_in8(0x3d5);
+	vga_out8(0x3d5, tmp & 0x7f);
+
+	/* unlock extended regs */
+	vga_out16(0x3d4, 0x4838);
+	vga_out16(0x3d4, 0xa039);
+	vga_out16(0x3c4, 0x0608);
+
+	vga_out8(0x3d4, 0x40);
+	tmp = vga_in8(0x3d5);
+	vga_out8(0x3d5, tmp & ~0x01);
+
+	/* unlock sys regs */
+	vga_out8(0x3d4, 0x38);
+	vga_out8(0x3d5, 0x48);
+
+	/* Unlock system registers. */
+	vga_out16(0x3d4, 0x4838);
+
+	/* Next go on to detect amount of installed ram */
+
+	vga_out8(0x3d4, 0x36);            /* for register CR36 (CONFG_REG1), */
+	config1 = vga_in8(0x3d5);           /* get amount of vram installed */
+
+	/* Compute the amount of video memory and offscreen memory. */
+
+	switch  (par->chip) {
+	case S3_SAVAGE3D:
+		videoRam = RamSavage3D[ (config1 & 0xC0) >> 6 ] * 1024;
+		break;
+
+	case S3_SAVAGE4:
+		/*
+		 * The Savage4 has one ugly special case to consider.  On
+		 * systems with 4 banks of 2Mx32 SDRAM, the BIOS says 4MB
+		 * when it really means 8MB.  Why do it the same when you
+		 * can do it different...
+		 */
+		vga_out8(0x3d4, 0x68);	/* memory control 1 */
+		if( (vga_in8(0x3d5) & 0xC0) == (0x01 << 6) )
+			RamSavage4[1] = 8;
+
+		/*FALLTHROUGH*/
+
+	case S3_SAVAGE2000:
+		videoRam = RamSavage4[ (config1 & 0xE0) >> 5 ] * 1024;
+		break;
+
+	case S3_SAVAGE_MX:
+	case S3_SUPERSAVAGE:
+		videoRam = RamSavageMX[ (config1 & 0x0E) >> 1 ] * 1024;
+		break;
+
+	case S3_PROSAVAGE:
+		videoRam = RamSavageNB[ (config1 & 0xE0) >> 5 ] * 1024;
+		break;
+
+	default:
+		/* How did we get here? */
+		videoRam = 0;
+		break;
+	}
+
+	videoRambytes = videoRam * 1024;
+
+	printk (KERN_INFO "savagefb: probed videoram:  %dk\n", videoRam);
+
+	/* reset graphics engine to avoid memory corruption */
+	vga_out8 (0x3d4, 0x66);
+	cr66 = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr66 | 0x02);
+	udelay (10000);
+
+	vga_out8 (0x3d4, 0x66);
+	vga_out8 (0x3d5, cr66 & ~0x02);	/* clear reset flag */
+	udelay (10000);
+
+
+	/*
+	 * reset memory interface, 3D engine, AGP master, PCI master,
+	 * master engine unit, motion compensation/LPB
+	 */
+	vga_out8 (0x3d4, 0x3f);
+	cr3f = vga_in8 (0x3d5);
+	vga_out8 (0x3d5, cr3f | 0x08);
+	udelay (10000);
+
+	vga_out8 (0x3d4, 0x3f);
+	vga_out8 (0x3d5, cr3f & ~0x08);	/* clear reset flags */
+	udelay (10000);
+
+	/* Savage ramdac speeds */
+	par->numClocks = 4;
+	par->clock[0] = 250000;
+	par->clock[1] = 250000;
+	par->clock[2] = 220000;
+	par->clock[3] = 220000;
+
+	/* detect current mclk */
+	vga_out8(0x3c4, 0x08);
+	sr8 = vga_in8(0x3c5);
+	vga_out8(0x3c5, 0x06);
+	vga_out8(0x3c4, 0x10);
+	n = vga_in8(0x3c5);
+	vga_out8(0x3c4, 0x11);
+	m = vga_in8(0x3c5);
+	vga_out8(0x3c4, 0x08);
+	vga_out8(0x3c5, sr8);
+	m &= 0x7f;
+	n1 = n & 0x1f;
+	n2 = (n >> 5) & 0x03;
+	par->MCLK = ((1431818 * (m+2)) / (n1+2) / (1 << n2) + 50) / 100;
+	printk (KERN_INFO "savagefb: Detected current MCLK value of %d kHz\n",
+		par->MCLK);
+
+	/* Check LCD panel parrmation */
+
+	if (par->chip == S3_SAVAGE_MX) {
+		unsigned char cr6b = VGArCR( 0x6b );
+
+		int panelX = (VGArSEQ (0x61) +
+			      ((VGArSEQ (0x66) & 0x02) << 7) + 1) * 8;
+		int panelY = (VGArSEQ (0x69) +
+			      ((VGArSEQ (0x6e) & 0x70) << 4) + 1);
+
+		char * sTechnology = "Unknown";
+
+		/* OK, I admit it.  I don't know how to limit the max dot clock
+		 * for LCD panels of various sizes.  I thought I copied the
+		 * formula from the BIOS, but many users have parrmed me of
+		 * my folly.
+		 *
+		 * Instead, I'll abandon any attempt to automatically limit the
+		 * clock, and add an LCDClock option to XF86Config.  Some day,
+		 * I should come back to this.
+		 */
+
+		enum ACTIVE_DISPLAYS { /* These are the bits in CR6B */
+			ActiveCRT = 0x01,
+			ActiveLCD = 0x02,
+			ActiveTV = 0x04,
+			ActiveCRT2 = 0x20,
+			ActiveDUO = 0x80
+		};
+
+		if ((VGArSEQ (0x39) & 0x03) == 0) {
+			sTechnology = "TFT";
+		} else if ((VGArSEQ (0x30) & 0x01) == 0) {
+			sTechnology = "DSTN";
+		} else 	{
+			sTechnology = "STN";
+		}
+
+		printk (KERN_INFO "savagefb: %dx%d %s LCD panel detected %s\n",
+			panelX, panelY, sTechnology,
+			cr6b & ActiveLCD ? "and active" : "but not active");
+
+		if( cr6b & ActiveLCD ) 	{
+			/*
+			 * If the LCD is active and panel expansion is enabled,
+			 * we probably want to kill the HW cursor.
+			 */
+
+			printk (KERN_INFO "savagefb: Limiting video mode to "
+				"%dx%d\n", panelX, panelY );
+
+			par->SavagePanelWidth = panelX;
+			par->SavagePanelHeight = panelY;
+
+		}
+	}
+
+	savage_get_default_par (par);
+
+	if( S3_SAVAGE4_SERIES(par->chip) ) {
+		/*
+		 * The Savage4 and ProSavage have COB coherency bugs which
+		 * render the buffer useless.  We disable it.
+		 */
+		par->cob_index = 2;
+		par->cob_size = 0x8000 << par->cob_index;
+		par->cob_offset = videoRambytes;
+	} else {
+		/* We use 128kB for the COB on all chips. */
+
+		par->cob_index  = 7;
+		par->cob_size   = 0x400 << par->cob_index;
+		par->cob_offset = videoRambytes - par->cob_size;
+	}
+
+	return videoRambytes;
+}
+
+static int __devinit savage_init_fb_info (struct fb_info *info,
+					  struct pci_dev *dev,
+					  const struct pci_device_id *id)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	int err = 0;
+
+	par->pcidev  = dev;
+
+	info->fix.type	   = FB_TYPE_PACKED_PIXELS;
+	info->fix.type_aux	   = 0;
+	info->fix.xpanstep	   = 2;
+	info->fix.ypanstep	   = 1;
+	info->fix.ywrapstep   = 0;
+	info->fix.accel       = id->driver_data;
+
+	switch (info->fix.accel) {
+	case FB_ACCEL_SUPERSAVAGE:
+		par->chip = S3_SUPERSAVAGE;
+		snprintf (info->fix.id, 16, "SuperSavage");
+		break;
+	case FB_ACCEL_SAVAGE4:
+		par->chip = S3_SAVAGE4;
+		snprintf (info->fix.id, 16, "Savage4");
+		break;
+	case FB_ACCEL_SAVAGE3D:
+		par->chip = S3_SAVAGE3D;
+		snprintf (info->fix.id, 16, "Savage3D");
+		break;
+	case FB_ACCEL_SAVAGE3D_MV:
+		par->chip = S3_SAVAGE3D;
+		snprintf (info->fix.id, 16, "Savage3D-MV");
+		break;
+	case FB_ACCEL_SAVAGE2000:
+		par->chip = S3_SAVAGE2000;
+		snprintf (info->fix.id, 16, "Savage2000");
+		break;
+	case FB_ACCEL_SAVAGE_MX_MV:
+		par->chip = S3_SAVAGE_MX;
+		snprintf (info->fix.id, 16, "Savage/MX-MV");
+		break;
+	case FB_ACCEL_SAVAGE_MX:
+		par->chip = S3_SAVAGE_MX;
+		snprintf (info->fix.id, 16, "Savage/MX");
+		break;
+	case FB_ACCEL_SAVAGE_IX_MV:
+		par->chip = S3_SAVAGE_MX;
+		snprintf (info->fix.id, 16, "Savage/IX-MV");
+		break;
+	case FB_ACCEL_SAVAGE_IX:
+		par->chip = S3_SAVAGE_MX;
+		snprintf (info->fix.id, 16, "Savage/IX");
+		break;
+	case FB_ACCEL_PROSAVAGE_PM:
+		par->chip = S3_PROSAVAGE;
+		snprintf (info->fix.id, 16, "ProSavagePM");
+		break;
+	case FB_ACCEL_PROSAVAGE_KM:
+		par->chip = S3_PROSAVAGE;
+		snprintf (info->fix.id, 16, "ProSavageKM");
+		break;
+	case FB_ACCEL_S3TWISTER_P:
+		par->chip = S3_PROSAVAGE;
+		snprintf (info->fix.id, 16, "TwisterP");
+		break;
+	case FB_ACCEL_S3TWISTER_K:
+		par->chip = S3_PROSAVAGE;
+		snprintf (info->fix.id, 16, "TwisterK");
+		break;
+	case FB_ACCEL_PROSAVAGE_DDR:
+		par->chip = S3_PROSAVAGE;
+		snprintf (info->fix.id, 16, "ProSavageDDR");
+		break;
+	case FB_ACCEL_PROSAVAGE_DDRK:
+		par->chip = S3_PROSAVAGE;
+		snprintf (info->fix.id, 16, "ProSavage8");
+		break;
+	}
+
+	if (S3_SAVAGE3D_SERIES(par->chip)) {
+		par->SavageWaitIdle = savage3D_waitidle;
+		par->SavageWaitFifo = savage3D_waitfifo;
+	} else if (S3_SAVAGE4_SERIES(par->chip) ||
+		   S3_SUPERSAVAGE == par->chip) {
+		par->SavageWaitIdle = savage4_waitidle;
+		par->SavageWaitFifo = savage4_waitfifo;
+	} else {
+		par->SavageWaitIdle = savage2000_waitidle;
+		par->SavageWaitFifo = savage2000_waitfifo;
+	}
+
+	info->var.nonstd      = 0;
+	info->var.activate    = FB_ACTIVATE_NOW;
+	info->var.width       = -1;
+	info->var.height      = -1;
+	info->var.accel_flags = 0;
+
+	info->fbops          = &savagefb_ops;
+	info->flags          = FBINFO_DEFAULT |
+		               FBINFO_HWACCEL_YPAN |
+		               FBINFO_HWACCEL_XPAN |
+	                       FBINFO_MISC_MODESWITCHLATE;
+
+	info->pseudo_palette = par->pseudo_palette;
+
+#if defined(CONFIG_FB_SAVAGE_ACCEL)
+	/* FIFO size + padding for commands */
+	info->pixmap.addr = kmalloc(8*1024, GFP_KERNEL);
+
+	err = -ENOMEM;
+	if (info->pixmap.addr) {
+		memset(info->pixmap.addr, 0, 8*1024);
+		info->pixmap.size = 8*1024;
+		info->pixmap.scan_align = 4;
+		info->pixmap.buf_align = 4;
+		info->pixmap.access_align = 4;
+
+		fb_alloc_cmap (&info->cmap, NR_PALETTE, 0);
+		info->flags |= FBINFO_HWACCEL_COPYAREA |
+	                       FBINFO_HWACCEL_FILLRECT |
+		               FBINFO_HWACCEL_IMAGEBLIT;
+
+		err = 0;
+	}
+#endif
+	return err;
+}
+
+/* --------------------------------------------------------------------- */
+
+static int __devinit savagefb_probe (struct pci_dev* dev,
+				     const struct pci_device_id* id)
+{
+	struct fb_info *info;
+	struct savagefb_par *par;
+	u_int h_sync, v_sync;
+	int err, lpitch;
+	int video_len;
+
+	DBG("savagefb_probe");
+	SavagePrintRegs();
+
+	info = framebuffer_alloc(sizeof(struct savagefb_par), &dev->dev);
+	if (!info)
+		return -ENOMEM;
+	par = info->par;
+	err = pci_enable_device(dev);
+	if (err)
+		goto failed_enable;
+
+	if (pci_request_regions(dev, "savagefb")) {
+		printk(KERN_ERR "cannot request PCI regions\n");
+		goto failed_enable;
+	}
+
+	err = -ENOMEM;
+
+	if (savage_init_fb_info(info, dev, id))
+		goto failed_init;
+
+	err = savage_map_mmio(info);
+	if (err)
+		goto failed_mmio;
+
+	video_len = savage_init_hw(par);
+	if (video_len < 0) {
+		err = video_len;
+		goto failed_mmio;
+	}
+
+	err = savage_map_video(info, video_len);
+	if (err)
+		goto failed_video;
+
+	INIT_LIST_HEAD(&info->modelist);
+#if defined(CONFIG_FB_SAVAGE_I2C)
+	savagefb_create_i2c_busses(info);
+	savagefb_probe_i2c_connector(par, &par->edid);
+	fb_edid_to_monspecs(par->edid, &info->monspecs);
+	fb_videomode_to_modelist(info->monspecs.modedb,
+				 info->monspecs.modedb_len,
+				 &info->modelist);
+#endif
+	info->var = savagefb_var800x600x8;
+
+	if (mode_option) {
+		fb_find_mode(&info->var, info, mode_option,
+			     info->monspecs.modedb, info->monspecs.modedb_len,
+			     NULL, 8);
+	} else if (info->monspecs.modedb != NULL) {
+		struct fb_monspecs *specs = &info->monspecs;
+		struct fb_videomode modedb;
+
+		if (info->monspecs.misc & FB_MISC_1ST_DETAIL) {
+			int i;
+
+			for (i = 0; i < specs->modedb_len; i++) {
+				if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
+					modedb = specs->modedb[i];
+					break;
+				}
+			}
+		} else {
+			/* otherwise, get first mode in database */
+			modedb = specs->modedb[0];
+		}
+
+		savage_update_var(&info->var, &modedb);
+	}
+
+	/* maximize virtual vertical length */
+	lpitch = info->var.xres_virtual*((info->var.bits_per_pixel + 7) >> 3);
+	info->var.yres_virtual = info->fix.smem_len/lpitch;
+
+	if (info->var.yres_virtual < info->var.yres)
+		goto failed;
+
+#if defined(CONFIG_FB_SAVAGE_ACCEL)
+	/*
+	 * The clipping coordinates are masked with 0xFFF, so limit our
+	 * virtual resolutions to these sizes.
+	 */
+	if (info->var.yres_virtual > 0x1000)
+		info->var.yres_virtual = 0x1000;
+
+	if (info->var.xres_virtual > 0x1000)
+		info->var.xres_virtual = 0x1000;
+#endif
+	savagefb_check_var(&info->var, info);
+	savagefb_set_fix(info);
+
+	/*
+	 * Calculate the hsync and vsync frequencies.  Note that
+	 * we split the 1e12 constant up so that we can preserve
+	 * the precision and fit the results into 32-bit registers.
+	 *  (1953125000 * 512 = 1e12)
+	 */
+	h_sync = 1953125000 / info->var.pixclock;
+	h_sync = h_sync * 512 / (info->var.xres + info->var.left_margin +
+				 info->var.right_margin +
+				 info->var.hsync_len);
+	v_sync = h_sync / (info->var.yres + info->var.upper_margin +
+			   info->var.lower_margin + info->var.vsync_len);
+
+	printk(KERN_INFO "savagefb v" SAVAGEFB_VERSION ": "
+	       "%dkB VRAM, using %dx%d, %d.%03dkHz, %dHz\n",
+	       info->fix.smem_len >> 10,
+	       info->var.xres, info->var.yres,
+	       h_sync / 1000, h_sync % 1000, v_sync);
+
+
+	fb_destroy_modedb(info->monspecs.modedb);
+	info->monspecs.modedb = NULL;
+
+	err = register_framebuffer (info);
+	if (err < 0)
+		goto failed;
+
+	printk (KERN_INFO "fb: S3 %s frame buffer device\n",
+		info->fix.id);
+
+	/*
+	 * Our driver data
+	 */
+	pci_set_drvdata(dev, info);
+
+	return 0;
+
+ failed:
+#ifdef CONFIG_FB_SAVAGE_I2C
+	savagefb_delete_i2c_busses(info);
+#endif
+	fb_alloc_cmap (&info->cmap, 0, 0);
+	savage_unmap_video(info);
+ failed_video:
+	savage_unmap_mmio (info);
+ failed_mmio:
+	kfree(info->pixmap.addr);
+ failed_init:
+	pci_release_regions(dev);
+ failed_enable:
+	framebuffer_release(info);
+
+	return err;
+}
+
+static void __devexit savagefb_remove (struct pci_dev *dev)
+{
+	struct fb_info *info =
+		(struct fb_info *)pci_get_drvdata(dev);
+
+	DBG("savagefb_remove");
+
+	if (info) {
+		/*
+		 * If unregister_framebuffer fails, then
+		 * we will be leaving hooks that could cause
+		 * oopsen laying around.
+		 */
+		if (unregister_framebuffer (info))
+			printk (KERN_WARNING "savagefb: danger danger! "
+				"Oopsen imminent!\n");
+
+#ifdef CONFIG_FB_SAVAGE_I2C
+		savagefb_delete_i2c_busses(info);
+#endif
+		fb_alloc_cmap (&info->cmap, 0, 0);
+		savage_unmap_video (info);
+		savage_unmap_mmio (info);
+		kfree(info->pixmap.addr);
+		pci_release_regions(dev);
+		framebuffer_release(info);
+
+		/*
+		 * Ensure that the driver data is no longer
+		 * valid.
+		 */
+		pci_set_drvdata(dev, NULL);
+	}
+}
+
+static int savagefb_suspend (struct pci_dev* dev, u32 state)
+{
+	struct fb_info *info =
+		(struct fb_info *)pci_get_drvdata(dev);
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+
+	DBG("savagefb_suspend");
+	printk(KERN_DEBUG "state: %u\n", state);
+
+	acquire_console_sem();
+	fb_set_suspend(info, state);
+	savage_disable_mmio(par);
+	release_console_sem();
+
+	pci_disable_device(dev);
+	pci_set_power_state(dev, state);
+
+	return 0;
+}
+
+static int savagefb_resume (struct pci_dev* dev)
+{
+	struct fb_info *info =
+		(struct fb_info *)pci_get_drvdata(dev);
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+
+	DBG("savage_resume");
+
+	pci_set_power_state(dev, 0);
+	pci_restore_state(dev);
+	if(pci_enable_device(dev))
+		DBG("err");
+
+	SavagePrintRegs();
+
+	acquire_console_sem();
+
+	savage_enable_mmio(par);
+	savage_init_hw(par);
+	savagefb_set_par (info);
+
+	fb_set_suspend (info, 0);
+	release_console_sem();
+
+	return 0;
+}
+
+
+static struct pci_device_id savagefb_devices[] __devinitdata = {
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_MX128,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_MX64,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_MX64C,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_IX128SDR,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_IX128DDR,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_IX64SDR,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_IX64DDR,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_IXCSDR,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_IXCDDR,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SUPERSAVAGE},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE4,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SAVAGE4},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE3D,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SAVAGE3D},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE3D_MV,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SAVAGE3D_MV},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE2000,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SAVAGE2000},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE_MX_MV,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SAVAGE_MX_MV},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE_MX,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SAVAGE_MX},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE_IX_MV,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SAVAGE_IX_MV},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE_IX,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_SAVAGE_IX},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_PROSAVAGE_PM,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_PROSAVAGE_PM},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_PROSAVAGE_KM,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_PROSAVAGE_KM},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_S3TWISTER_P,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_S3TWISTER_P},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_S3TWISTER_K,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_S3TWISTER_K},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_PROSAVAGE_DDR,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_PROSAVAGE_DDR},
+
+	{PCI_VENDOR_ID_S3, PCI_CHIP_PROSAVAGE_DDRK,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_PROSAVAGE_DDRK},
+
+	{0, 0, 0, 0, 0, 0, 0}
+};
+
+MODULE_DEVICE_TABLE(pci, savagefb_devices);
+
+static struct pci_driver savagefb_driver = {
+	.name =     "savagefb",
+	.id_table = savagefb_devices,
+	.probe =    savagefb_probe,
+	.suspend =  savagefb_suspend,
+	.resume =   savagefb_resume,
+	.remove =   __devexit_p(savagefb_remove)
+};
+
+/* **************************** exit-time only **************************** */
+
+static void __exit savage_done (void)
+{
+	DBG("savage_done");
+	pci_unregister_driver (&savagefb_driver);
+}
+
+
+/* ************************* init in-kernel code ************************** */
+
+int __init savagefb_setup(char *options)
+{
+#ifndef MODULE
+	char *this_opt;
+
+	if (!options || !*options)
+		return 0;
+
+	while ((this_opt = strsep(&options, ",")) != NULL) {
+		mode_option = this_opt;
+	}
+#endif /* !MODULE */
+	return 0;
+}
+
+int __init savagefb_init(void)
+{
+	char *option;
+
+	DBG("savagefb_init");
+
+	if (fb_get_options("savagefb", &option))
+		return -ENODEV;
+
+	savagefb_setup(option);
+	return pci_register_driver (&savagefb_driver);
+
+}
+
+module_init(savagefb_init);
+module_exit(savage_done);
diff -Nru a/drivers/video/savage/savagefb.h b/drivers/video/savage/savagefb.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/savage/savagefb.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,354 @@
+/*
+ * linux/drivers/video/savagefb.h -- S3 Savage Framebuffer Driver
+ *
+ * Copyright (c) 2001  Denis Oliver Kropp <dok@convergence.de>
+ *
+ * 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.
+ */
+
+
+#ifndef __SAVAGEFB_H__
+#define __SAVAGEFB_H__
+
+#include <linux/i2c.h>
+#include <linux/i2c-id.h>
+#include <linux/i2c-algo-bit.h>
+#include "../edid.h"
+
+#ifdef SAVAGEFB_DEBUG
+# define DBG(x)		printk (KERN_DEBUG "savagefb: %s\n", (x));
+#else
+# define DBG(x)
+# define SavagePrintRegs(...)
+#endif
+
+
+#define PCI_CHIP_SAVAGE4      0x8a22
+#define PCI_CHIP_SAVAGE3D     0x8a20
+#define PCI_CHIP_SAVAGE3D_MV  0x8a21
+#define PCI_CHIP_SAVAGE2000   0x9102
+#define PCI_CHIP_SAVAGE_MX_MV 0x8c10
+#define PCI_CHIP_SAVAGE_MX    0x8c11
+#define PCI_CHIP_SAVAGE_IX_MV 0x8c12
+#define PCI_CHIP_SAVAGE_IX    0x8c13
+#define PCI_CHIP_PROSAVAGE_PM 0x8a25
+#define PCI_CHIP_PROSAVAGE_KM 0x8a26
+ /* Twister is a code name; hope I get the real name soon. */
+#define PCI_CHIP_S3TWISTER_P  0x8d01
+#define PCI_CHIP_S3TWISTER_K  0x8d02
+#define PCI_CHIP_PROSAVAGE_DDR          0x8d03
+#define PCI_CHIP_PROSAVAGE_DDRK         0x8d04
+#define PCI_CHIP_SUPSAV_MX128		0x8c22
+#define PCI_CHIP_SUPSAV_MX64		0x8c24
+#define PCI_CHIP_SUPSAV_MX64C		0x8c26
+#define PCI_CHIP_SUPSAV_IX128SDR	0x8c2a
+#define PCI_CHIP_SUPSAV_IX128DDR	0x8c2b
+#define PCI_CHIP_SUPSAV_IX64SDR		0x8c2c
+#define PCI_CHIP_SUPSAV_IX64DDR		0x8c2d
+#define PCI_CHIP_SUPSAV_IXCSDR		0x8c2e
+#define PCI_CHIP_SUPSAV_IXCDDR		0x8c2f
+
+
+
+#define S3_SAVAGE3D_SERIES(chip)  ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX))
+
+#define S3_SAVAGE4_SERIES(chip)   ((chip==S3_SAVAGE4) || (chip==S3_PROSAVAGE))
+
+#define S3_SAVAGE_MOBILE_SERIES(chip)  ((chip==S3_SAVAGE_MX) || (chip==S3_SUPERSAVAGE))
+
+#define S3_SAVAGE_SERIES(chip)    ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000))
+
+
+/* Chip tags.  These are used to group the adapters into
+ * related families.
+ */
+
+typedef enum {
+  S3_UNKNOWN = 0,
+  S3_SAVAGE3D,
+  S3_SAVAGE_MX,
+  S3_SAVAGE4,
+  S3_PROSAVAGE,
+  S3_SUPERSAVAGE,
+  S3_SAVAGE2000,
+  S3_LAST
+} savage_chipset;
+
+#define BIOS_BSIZE		     1024
+#define BIOS_BASE		     0xc0000
+
+#define SAVAGE_NEWMMIO_REGBASE_S3    0x1000000  /* 16MB */
+#define SAVAGE_NEWMMIO_REGBASE_S4    0x0000000
+#define SAVAGE_NEWMMIO_REGSIZE	     0x0080000  /* 512kb */
+#define SAVAGE_NEWMMIO_VGABASE	     0x8000
+
+#define BASE_FREQ		     14318
+#define HALF_BASE_FREQ               7159
+
+#define FIFO_CONTROL_REG	     0x8200
+#define MIU_CONTROL_REG		     0x8204
+#define STREAMS_TIMEOUT_REG	     0x8208
+#define MISC_TIMEOUT_REG	     0x820c
+
+#define MONO_PAT_0                   0xa4e8
+#define MONO_PAT_1                   0xa4ec
+
+#define MAXFIFO                      0x7f00
+
+#define BCI_CMD_NOP                  0x40000000
+#define BCI_CMD_SETREG               0x96000000
+#define BCI_CMD_RECT                 0x48000000
+#define BCI_CMD_RECT_XP              0x01000000
+#define BCI_CMD_RECT_YP              0x02000000
+#define BCI_CMD_SEND_COLOR           0x00008000
+#define BCI_CMD_DEST_GBD             0x00000000
+#define BCI_CMD_SRC_GBD              0x00000020
+#define BCI_CMD_SRC_SOLID            0x00000000
+#define BCI_CMD_SRC_MONO             0x00000060
+#define BCI_CMD_CLIP_NEW             0x00006000
+#define BCI_CMD_CLIP_LR              0x00004000
+
+#define BCI_CLIP_LR(l, r)            ((((r) << 16) | (l)) & 0x0FFF0FFF)
+#define BCI_CLIP_TL(t, l)            ((((t) << 16) | (l)) & 0x0FFF0FFF)
+#define BCI_CLIP_BR(b, r)            ((((b) << 16) | (r)) & 0x0FFF0FFF)
+#define BCI_W_H(w, h)                (((h) << 16) | ((w) & 0xFFF))
+#define BCI_X_Y(x, y)                (((y) << 16) | ((x) & 0xFFF))
+
+#define BCI_GBD1                     0xE0
+#define BCI_GBD2                     0xE1
+
+#define BCI_BUFFER_OFFSET            0x10000
+#define BCI_SIZE                     0x4000
+
+#define BCI_SEND(dw)                 writel(dw, par->bci_base + par->bci_ptr++)
+
+#define BCI_CMD_GET_ROP(cmd)         (((cmd) >> 16) & 0xFF)
+#define BCI_CMD_SET_ROP(cmd, rop)    ((cmd) |= ((rop & 0xFF) << 16))
+#define BCI_CMD_SEND_COLOR           0x00008000
+
+struct xtimings {
+	unsigned int Clock;
+	unsigned int HDisplay;
+	unsigned int HSyncStart;
+	unsigned int HSyncEnd;
+	unsigned int HTotal;
+	unsigned int HAdjusted;
+	unsigned int VDisplay;
+	unsigned int VSyncStart;
+	unsigned int VSyncEnd;
+	unsigned int VTotal;
+	unsigned int sync;
+	int	       dblscan;
+	int	       interlaced;
+};
+
+
+/* --------------------------------------------------------------------- */
+
+#define NR_PALETTE	256
+
+
+struct savagefb_par;
+
+struct savagefb_i2c_chan {
+	struct savagefb_par *par;
+	struct i2c_adapter adapter;
+	struct i2c_algo_bit_data algo;
+	volatile u8 __iomem *ioaddr;
+	u32   reg;
+};
+
+struct savagefb_par {
+	struct pci_dev *pcidev;
+	savage_chipset  chip;
+	struct savagefb_i2c_chan chan;
+	unsigned char   *edid;
+	u32 pseudo_palette[16];
+	int dacSpeedBpp;
+	int maxClock;
+	int minClock;
+	int numClocks;
+	int clock[4];
+	struct {
+		u8   __iomem *vbase;
+		u32    pbase;
+		u32    len;
+#ifdef CONFIG_MTRR
+		int    mtrr;
+#endif
+	} video;
+
+	struct {
+		volatile u8  __iomem *vbase;
+		u32           pbase;
+		u32           len;
+	} mmio;
+
+	volatile u32  __iomem *bci_base;
+	unsigned int  bci_ptr;
+
+	u32           cob_offset;
+	u32           cob_size;
+	int           cob_index;
+
+	void (*SavageWaitIdle) (struct savagefb_par *par);
+	void (*SavageWaitFifo) (struct savagefb_par *par, int space);
+
+	int MCLK, REFCLK, LCDclk;
+	int HorizScaleFactor;
+
+	/* Panels size */
+	int SavagePanelWidth;
+	int SavagePanelHeight;
+
+	struct {
+		u16 red, green, blue, transp;
+	} palette[NR_PALETTE];
+
+	int depth;
+	int vwidth;
+
+	unsigned char MiscOutReg;     /* Misc */
+	unsigned char CRTC[25];       /* Crtc Controller */
+	unsigned char Sequencer[5];   /* Video Sequencer */
+	unsigned char Graphics[9];    /* Video Graphics */
+	unsigned char Attribute[21];  /* Video Atribute */
+
+	unsigned int mode, refresh;
+	unsigned char SR08, SR0E, SR0F;
+	unsigned char SR10, SR11, SR12, SR13, SR15, SR18, SR29, SR30;
+	unsigned char SR54[8];
+	unsigned char Clock;
+	unsigned char CR31, CR32, CR33, CR34, CR36, CR3A, CR3B, CR3C;
+	unsigned char CR40, CR41, CR42, CR43, CR45;
+	unsigned char CR50, CR51, CR53, CR55, CR58, CR5B, CR5D, CR5E;
+	unsigned char CR60, CR63, CR65, CR66, CR67, CR68, CR69, CR6D, CR6F;
+	unsigned char CR86, CR88;
+	unsigned char CR90, CR91, CRB0;
+	unsigned int  STREAMS[22];	/* yuck, streams regs */
+	unsigned int  MMPR0, MMPR1, MMPR2, MMPR3;
+};
+
+#define BCI_BD_BW_DISABLE            0x10000000
+#define BCI_BD_SET_BPP(bd, bpp)      ((bd) |= (((bpp) & 0xFF) << 16))
+#define BCI_BD_SET_STRIDE(bd, st)    ((bd) |= ((st) & 0xFFFF))
+
+
+/* IO functions */
+
+#define  vga_in8(addr)         (inb (addr))
+#define vga_in16(addr)         (inw (addr))
+#define vga_in32(addr)         (inl (addr))
+
+#define  vga_out8(addr,val)    (outb ((val), (addr)))
+#define vga_out16(addr,val)    (outw ((val), (addr)))
+#define vga_out32(addr,val)    (outl ((val), (addr)))
+
+#define savage_in16(addr)      readw(par->mmio.vbase + (addr))
+#define savage_in32(addr)      readl(par->mmio.vbase + (addr))
+
+#define savage_out16(addr,val) writew((val), par->mmio.vbase + (addr))
+#define savage_out32(addr,val) writel((val), par->mmio.vbase + (addr))
+
+static inline u8 VGArCR (u8 index)
+{
+  outb (index, 0x3d4);
+  return inb (0x3d5);
+}
+
+static inline u8 VGArGR (u8 index)
+{
+  outb (index, 0x3ce);
+  return inb (0x3cf);
+}
+
+static inline u8 VGArSEQ (u8 index)
+{
+  outb (index, 0x3c4);
+  return inb (0x3c5);
+}
+
+#define VGAwCR(index, val) \
+do {                       \
+  vga_out8 (0x3d4, index); \
+  vga_out8 (0x3d5, val);   \
+} while (0)
+
+#define VGAwGR(index, val) \
+do {                       \
+  vga_out8 (0x3ce, index); \
+  vga_out8 (0x3cf, val);   \
+} while (0)
+
+#define VGAwSEQ(index, val) \
+do {                        \
+  vga_out8 (0x3c4, index);  \
+  vga_out8 (0x3c5, val);    \
+} while (0)
+
+#define VGAenablePalette() \
+do {                       \
+  u8 tmp;                  \
+                           \
+  tmp = vga_in8 (0x3da);   \
+  vga_out8 (0x3c0, 0x00);  \
+  paletteEnabled = 1;      \
+} while (0)
+
+#define VGAdisablePalette() \
+do {                        \
+  u8 tmp;                   \
+                            \
+  tmp = vga_in8 (0x3da);    \
+  vga_out8 (0x3c0, 0x20);   \
+  paletteEnabled = 0;       \
+} while (0)
+
+#define VGAwATTR(index, value) \
+do {                           \
+  u8 tmp;                      \
+                               \
+  if (paletteEnabled)          \
+    index &= ~0x20;            \
+  else                         \
+    index |= 0x20;             \
+                               \
+  tmp = vga_in8 (0x3da);       \
+  vga_out8 (0x3c0, index);     \
+  vga_out8 (0x3c0, value);     \
+} while (0)
+
+#define VGAwMISC(value)    \
+do {                       \
+  vga_out8 (0x3c2, value); \
+} while (0)
+
+#ifndef CONFIG_FB_SAVAGE_ACCEL
+#define savagefb_set_clip(x)
+#endif
+
+#define VerticalRetraceWait() \
+{ \
+	vga_out8 (0x3d4, 0x17); \
+	if (vga_in8 (0x3d5) & 0x80) { \
+		while ((vga_in8(0x3da) & 0x08) == 0x08) ; \
+		while ((vga_in8(0x3da) & 0x08) == 0x00) ; \
+	} \
+}
+
+extern int savagefb_probe_i2c_connector(struct savagefb_par *par,
+					u8 **out_edid);
+extern void savagefb_create_i2c_busses(struct fb_info *info);
+extern void savagefb_delete_i2c_busses(struct fb_info *info);
+extern int  savagefb_sync(struct fb_info *info);
+extern void savagefb_copyarea(struct fb_info *info,
+			      const struct fb_copyarea *region);
+extern void savagefb_fillrect(struct fb_info *info,
+			      const struct fb_fillrect *rect);
+extern void savagefb_imageblit(struct fb_info *info,
+			       const struct fb_image *image);
+
+
+#endif /* __SAVAGEFB_H__ */
diff -Nru a/drivers/video/savage/savagefb_accel.c b/drivers/video/savage/savagefb_accel.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/video/savage/savagefb_accel.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,140 @@
+/*-*- linux-c -*-
+ *  linux/drivers/video/savage/savage_accel.c -- Hardware Acceleration
+ *
+ *      Copyright (C) 2004 Antonino Daplas<adaplas@pol.net>
+ *      All Rights Reserved
+ *
+ *  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 <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/fb.h>
+
+#include "savagefb.h"
+
+static u32 savagefb_rop[] = {
+	0xCC, /* ROP_COPY */
+	0x5A  /* ROP_XOR  */
+};
+
+int savagefb_sync(struct fb_info *info)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+
+	par->SavageWaitIdle(par);
+	return 0;
+}
+EXPORT_SYMBOL(savagefb_sync);
+
+void savagefb_copyarea(struct fb_info *info, const struct fb_copyarea *region)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	int sx = region->sx, dx = region->dx;
+	int sy = region->sy, dy = region->dy;
+	int cmd;
+
+	if (!region->width || !region->height)
+		return;
+	par->bci_ptr = 0;
+	cmd = BCI_CMD_RECT | BCI_CMD_DEST_GBD | BCI_CMD_SRC_GBD;
+	BCI_CMD_SET_ROP(cmd, savagefb_rop[0]);
+
+	if (dx <= sx) {
+		cmd |= BCI_CMD_RECT_XP;
+	} else {
+		sx += region->width - 1;
+		dx += region->width - 1;
+	}
+
+	if (dy <= sy) {
+		cmd |= BCI_CMD_RECT_YP;
+	} else {
+		sy += region->height - 1;
+		dy += region->height - 1;
+	}
+
+	par->SavageWaitFifo(par,4);
+	BCI_SEND(cmd);
+	BCI_SEND(BCI_X_Y(sx, sy));
+	BCI_SEND(BCI_X_Y(dx, dy));
+	BCI_SEND(BCI_W_H(region->width, region->height));
+}
+EXPORT_SYMBOL(savagefb_copyarea);
+
+void savagefb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	int cmd, color;
+
+	if (!rect->width || !rect->height)
+		return;
+
+	if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR)
+		color = rect->color;
+	else
+		color = ((u32 *)info->pseudo_palette)[rect->color];
+
+	cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP |
+	      BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID |
+	      BCI_CMD_SEND_COLOR;
+
+	par->bci_ptr = 0;
+	BCI_CMD_SET_ROP(cmd, savagefb_rop[rect->rop]);
+
+	par->SavageWaitFifo(par,4);
+	BCI_SEND(cmd);
+	BCI_SEND(color);
+	BCI_SEND( BCI_X_Y(rect->dx, rect->dy) );
+	BCI_SEND( BCI_W_H(rect->width, rect->height) );
+}
+EXPORT_SYMBOL(savagefb_fillrect);
+
+void savagefb_imageblit(struct fb_info *info, const struct fb_image *image)
+{
+	struct savagefb_par *par = (struct savagefb_par *)info->par;
+	int fg, bg, size, i, width;
+	int cmd;
+	u32 *src = (u32 *) image->data;
+
+	if (!image->width || !image->height)
+		return;
+
+	if (image->depth != 1) {
+		cfb_imageblit(info, image);
+		return;
+	}
+
+	if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
+		fg = image->fg_color;
+		bg = image->bg_color;
+	} else {
+		fg = ((u32 *)info->pseudo_palette)[image->fg_color];
+		bg = ((u32 *)info->pseudo_palette)[image->bg_color];
+	}
+
+	cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP |
+	      BCI_CMD_CLIP_LR | BCI_CMD_DEST_GBD | BCI_CMD_SRC_MONO |
+	      BCI_CMD_SEND_COLOR;
+
+	par->bci_ptr = 0;
+	BCI_CMD_SET_ROP(cmd, savagefb_rop[0]);
+
+	width = (image->width + 31) & ~31;
+	size = (width * image->height)/8;
+	size >>= 2;
+
+	par->SavageWaitFifo(par, size + 5);
+	BCI_SEND(cmd);
+	BCI_SEND(BCI_CLIP_LR(image->dx, image->dx + image->width - 1));
+	BCI_SEND(fg);
+	BCI_SEND(bg);
+	BCI_SEND(BCI_X_Y(image->dx, image->dy));
+	BCI_SEND(BCI_W_H(width, image->height));
+	for (i = 0; i < size; i++)
+		BCI_SEND(src[i]);
+}
+EXPORT_SYMBOL(savagefb_imageblit);
+
+MODULE_LICENSE("GPL");
diff -Nru a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c
--- a/drivers/video/sbuslib.c	2004-12-24 13:36:32 -08:00
+++ b/drivers/video/sbuslib.c	2004-12-24 13:36:32 -08:00
@@ -52,7 +52,7 @@
 	off = vma->vm_pgoff << PAGE_SHIFT;
 
 	/* To stop the swapper from even considering these pages */
-	vma->vm_flags |= (VM_SHM | VM_IO | VM_LOCKED);
+	vma->vm_flags |= (VM_IO | VM_RESERVED);
 	
 	/* Each page, see which map applies */
 	for (page = 0; page < size; ){
diff -Nru a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
--- a/drivers/video/sgivwfb.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/video/sgivwfb.c	2004-12-24 13:36:49 -08:00
@@ -719,8 +719,8 @@
 	pgprot_val(vma->vm_page_prot) =
 	    pgprot_val(vma->vm_page_prot) | _PAGE_PCD;
 	vma->vm_flags |= VM_IO;
-	if (remap_page_range
-	    (vma, vma->vm_start, offset, size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start, offset >> PAGE_SHIFT,
+						size, vma->vm_page_prot))
 		return -EAGAIN;
 	vma->vm_file = file;
 	printk(KERN_DEBUG "sgivwfb: mmap framebuffer P(%lx)->V(%lx)\n",
diff -Nru a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
--- a/drivers/video/sis/sis_main.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/video/sis/sis_main.c	2004-12-24 13:37:01 -08:00
@@ -1813,8 +1813,11 @@
 		return err;
 	}
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
 	sisfb_get_fix(&info->fix, info->currcon, info);
-
+#else
+	sisfb_get_fix(&info->fix, -1, info);
+#endif
 	return 0;
 }
 
diff -Nru a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
--- a/drivers/video/skeletonfb.c	2004-12-24 13:36:19 -08:00
+++ b/drivers/video/skeletonfb.c	2004-12-24 13:36:19 -08:00
@@ -477,6 +477,28 @@
  *		Used internally by the driver.	 
  *      @hot:	The hot spot. 
  *	@image:	The actual data for the cursor image.
+ *
+ *      NOTES ON FLAGS (cursor->set):
+ *
+ *      FB_CUR_SETIMAGE - the cursor image has changed (cursor->image.data)
+ *      FB_CUR_SETPOS   - the cursor position has changed (cursor->image.dx|dy)
+ *      FB_CUR_SETHOT   - the cursor hot spot has changed (cursor->hot.dx|dy)
+ *      FB_CUR_SETCMAP  - the cursor colors has changed (cursor->fg_color|bg_color)
+ *      FB_CUR_SETSHAPE - the cursor bitmask has changed (cursor->mask)
+ *      FB_CUR_SETSIZE  - the cursor size has changed (cursor->width|height)
+ *      FB_CUR_SETALL   - everything has changed
+ *
+ *      NOTES ON ROPs (cursor->rop, Raster Operation)
+ *
+ *      ROP_XOR         - cursor->image.data XOR cursor->mask
+ *      ROP_COPY        - curosr->image.data AND cursor->mask
+ *
+ *      OTHER NOTES:
+ *
+ *      - fbcon only supports a 2-color cursor (cursor->image.depth = 1)
+ *      - The fb_cursor structure, @cursor, _will_ always contain valid
+ *        fields, whether any particular bitfields in cursor->set is set
+ *        or not.
  */
 }
 
@@ -529,6 +551,17 @@
 {
     int cmap_len, retval;	
    
+    /*
+     *  For kernel boot options (in 'video=xxxfb:<options>' format)
+     */
+#ifndef MODULE
+    char *option = NULL;
+
+    if (fb_get_options("xxxfb", &option))
+	    return -ENODEV;
+    xxxfb_setup(option);
+#endif
+
     /* 
      * Here we set the screen_base to the vitrual memory address
      * for the framebuffer. Usually we obtain the resource address
@@ -582,17 +615,6 @@
 
 static void __exit xxxfb_cleanup(void)
 {
-    /*
-     *  For kernel boot options (in 'video=xxxfb:<options>' format)
-     */
-#ifndef MODULE
-    char *option = NULL;
-
-    if (fb_get_options("xxxfb", &option))
-	    return -ENODEV;
-    xxxfb_setup(option);
-#endif
-
     /*
      *  If your driver supports multiple boards, you should unregister and
      *  clean up all instances.
diff -Nru a/drivers/video/softcursor.c b/drivers/video/softcursor.c
--- a/drivers/video/softcursor.c	2004-12-24 13:36:55 -08:00
+++ b/drivers/video/softcursor.c	2004-12-24 13:36:55 -08:00
@@ -19,79 +19,54 @@
 
 int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
 {
-	unsigned int scan_align = info->sprite.scan_align - 1;
-	unsigned int buf_align = info->sprite.buf_align - 1;
+	unsigned int scan_align = info->pixmap.scan_align - 1;
+	unsigned int buf_align = info->pixmap.buf_align - 1;
 	unsigned int i, size, dsize, s_pitch, d_pitch;
-	struct fb_cursor *cur;
+	struct fb_image *image;
 	u8 *dst, *src;
 
-	if (cursor->set & FB_CUR_SETSIZE) {
-		info->cursor.image.height = cursor->image.height;
-		info->cursor.image.width = cursor->image.width;
-	}
-
-	if (cursor->set & FB_CUR_SETPOS) {
-		info->cursor.image.dx = cursor->image.dx;
-		info->cursor.image.dy = cursor->image.dy;
-	}
-
-	if (cursor->set & FB_CUR_SETHOT)
-		info->cursor.hot = cursor->hot;
-	
-	if (cursor->set & FB_CUR_SETCMAP) {
-		if (cursor->image.depth == 1) {
-			info->cursor.image.bg_color = cursor->image.bg_color;
-			info->cursor.image.fg_color = cursor->image.fg_color;
-		} else {
-			if (cursor->image.cmap.len)
-				fb_copy_cmap(&cursor->image.cmap, &info->cursor.image.cmap);
-		}
-		info->cursor.image.depth = cursor->image.depth;
-	}	
-
-	info->cursor.image.data = cursor->image.data;
-
 	if (info->state != FBINFO_STATE_RUNNING)
 		return 0;
 
-	src = kmalloc(64 + sizeof(struct fb_cursor), GFP_ATOMIC);
+	s_pitch = (cursor->image.width + 7) >> 3;
+	dsize = s_pitch * cursor->image.height;
+
+	src = kmalloc(dsize + sizeof(struct fb_image), GFP_ATOMIC);
 	if (!src)
 		return -ENOMEM;
-	cur = (struct fb_cursor *) (src + 64);
-	*cur = info->cursor;
 
-	s_pitch = (info->cursor.image.width + 7) >> 3;
-	dsize = s_pitch * info->cursor.image.height;
+	image = (struct fb_image *) (src + dsize);
+	*image = cursor->image;
 	d_pitch = (s_pitch + scan_align) & ~scan_align;
-	size = d_pitch * info->cursor.image.height + buf_align;
+
+	size = d_pitch * image->height + buf_align;
 	size &= ~buf_align;
-	dst = fb_get_buffer_offset(info, &info->sprite, size);
+	dst = fb_get_buffer_offset(info, &info->pixmap, size);
 
-	if (info->cursor.enable) {
-		switch (info->cursor.rop) {
+	if (cursor->enable) {
+		switch (cursor->rop) {
 		case ROP_XOR:
 			for (i = 0; i < dsize; i++)
-				src[i] = cursor->image.data[i] ^ info->cursor.mask[i]; 
+				src[i] = image->data[i] ^ cursor->mask[i];
 			break;
 		case ROP_COPY:
 		default:
 			for (i = 0; i < dsize; i++)
-				src[i] = cursor->image.data[i] & info->cursor.mask[i];
+				src[i] = image->data[i] & cursor->mask[i];
 			break;
 		}
 	} else 
-		memcpy(src, cursor->image.data, dsize);
+		memcpy(src, image->data, dsize);
 	
-	if (info->sprite.outbuf)
-		fb_iomove_buf_aligned(info, &info->sprite, dst, d_pitch, src,
-				  s_pitch, info->cursor.image.height);
+	if (info->pixmap.outbuf)
+		fb_iomove_buf_aligned(info, &info->pixmap, dst, d_pitch, src,
+				  s_pitch, image->height);
 	else
-		fb_sysmove_buf_aligned(info, &info->sprite, dst, d_pitch, src,
-				   s_pitch, info->cursor.image.height);
-	cur->image.data = dst;
-	
-	info->fbops->fb_imageblit(info, &cur->image);
+		fb_sysmove_buf_aligned(info, &info->pixmap, dst, d_pitch, src,
+				   s_pitch, image->height);
 
+	image->data = dst;
+	info->fbops->fb_imageblit(info, image);
 	kfree(src);
 
 	return 0;
diff -Nru a/drivers/video/sstfb.c b/drivers/video/sstfb.c
--- a/drivers/video/sstfb.c	2004-12-24 13:37:00 -08:00
+++ b/drivers/video/sstfb.c	2004-12-24 13:37:00 -08:00
@@ -67,10 +67,6 @@
 
 #undef SST_DEBUG
 
-#define SST_DEBUG_REG   0
-#define SST_DEBUG_FUNC  0
-#define SST_DEBUG_VAR   0
-
 /* enable 24/32 bpp functions ? (completely untested!) */
 #undef EN_24_32_BPP
 
@@ -220,26 +216,26 @@
 #define dac_i_read(reg)		__dac_i_read(par->mmio_vbase, reg)
 #define dac_i_write(reg,val)	__dac_i_write(par->mmio_vbase, reg, val)
 
-static inline u32 __sst_read(u_long vbase, u32 reg)
+static inline u32 __sst_read(u8 __iomem *vbase, u32 reg)
 {
 	u32 ret = readl(vbase + reg);
 	sst_dbg_print_read_reg(reg, ret);
 	return ret;
 }
 
-static inline void __sst_write(u_long vbase, u32 reg, u32 val)
+static inline void __sst_write(u8 __iomem *vbase, u32 reg, u32 val)
 {
 	sst_dbg_print_write_reg(reg, val);
 	writel(val, vbase + reg);
 }
 
-static inline void __sst_set_bits(u_long vbase, u32 reg, u32 val)
+static inline void __sst_set_bits(u8 __iomem *vbase, u32 reg, u32 val)
 {
 	r_dprintk("sst_set_bits(%#x, %#x)\n", reg, val);
 	__sst_write(vbase, reg, __sst_read(vbase, reg) | val);
 }
 
-static inline void __sst_unset_bits(u_long vbase, u32 reg, u32 val)
+static inline void __sst_unset_bits(u8 __iomem *vbase, u32 reg, u32 val)
 {
 	r_dprintk("sst_unset_bits(%#x, %#x)\n", reg, val);
 	__sst_write(vbase, reg, __sst_read(vbase, reg) & ~val);
@@ -254,7 +250,7 @@
 
 #define sst_wait_idle() __sst_wait_idle(par->mmio_vbase)
 
-static int __sst_wait_idle(u_long vbase)
+static int __sst_wait_idle(u8 __iomem *vbase)
 {
 	int count = 0;
 
@@ -279,7 +275,7 @@
 
 /* dac access */
 /* dac_read should be remaped to FbiInit2 (via the pci reg init_enable) */
-static u8 __sst_dac_read(u_long vbase, u8 reg)
+static u8 __sst_dac_read(u8 __iomem *vbase, u8 reg)
 {
 	u8 ret;
 
@@ -293,7 +289,7 @@
 	return ret;
 }
 
-static void __sst_dac_write(u_long vbase, u8 reg, u8 val)
+static void __sst_dac_write(u8 __iomem *vbase, u8 reg, u8 val)
 {
 	r_dprintk("sst_dac_write(%#x, %#x)\n", reg, val);
 	reg &= 0x07;
@@ -301,7 +297,7 @@
 }
 
 /* indexed access to ti/att dacs */
-static u32 __dac_i_read(u_long vbase, u8 reg)
+static u32 __dac_i_read(u8 __iomem *vbase, u8 reg)
 {
 	u32 ret;
 
@@ -310,7 +306,7 @@
 	r_dprintk("sst_dac_read_i(%#x): %#x\n", reg, ret);
 	return ret;
 }
-static void __dac_i_write(u_long vbase, u8 reg,u8 val)
+static void __dac_i_write(u8 __iomem *vbase, u8 reg,u8 val)
 {
 	r_dprintk("sst_dac_write_i(%#x, %#x)\n", reg, val);
 	__sst_dac_write(vbase, DACREG_ADDR_I, reg);
@@ -886,7 +882,7 @@
  */
 static int __devinit sst_get_memsize(struct fb_info *info, __u32 *memsize)
 {
-	u_long fbbase_virt = (u_long) info->screen_base;
+	u8 __iomem *fbbase_virt = info->screen_base;
 
 	/* force memsize */
 	if ((mem >= 1 ) &&  (mem <= 4)) {
@@ -1442,7 +1438,7 @@
 		goto fail_fb_mem;
 	}
 
-	par->mmio_vbase = (u_long) ioremap_nocache(fix->mmio_start,
+	par->mmio_vbase = ioremap_nocache(fix->mmio_start,
 					fix->mmio_len);
 	if (!par->mmio_vbase) {
 		eprintk("cannot remap register area %#lx\n",
@@ -1475,7 +1471,6 @@
 
 	info->flags	= FBINFO_DEFAULT;
 	info->fbops	= &sstfb_ops;
-	info->currcon	= -1;
 	info->pseudo_palette = &all->pseudo_palette;
 
 	fix->type	= FB_TYPE_PACKED_PIXELS;
@@ -1507,6 +1502,7 @@
 	fb_alloc_cmap(&info->cmap, 256, 0);
 
 	/* register fb */
+	info->device = &pdev->dev;
 	if (register_framebuffer(info) < 0) {
 		eprintk("can't register framebuffer.\n");
 		goto fail;
@@ -1525,7 +1521,7 @@
 fail:
 	iounmap(info->screen_base);
 fail_fb_remap:
-	iounmap((void *)par->mmio_vbase);
+	iounmap(par->mmio_vbase);
 fail_mmio_remap:
 	release_mem_region(fix->smem_start, 0x400000);
 fail_fb_mem:
@@ -1546,7 +1542,7 @@
 	sst_shutdown(info);
 	unregister_framebuffer(info);
 	iounmap(info->screen_base);
-	iounmap((void*)par->mmio_vbase);
+	iounmap(par->mmio_vbase);
 	release_mem_region(info->fix.smem_start, 0x400000);
 	release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
 	kfree(info);
@@ -1643,10 +1639,10 @@
 
 static void sstfb_fillrect_softw( struct fb_info *info, const struct fb_fillrect *rect)
 {
-	unsigned long fbbase_virt = (unsigned long) info->screen_base;
+	u8 __iomem *fbbase_virt = info->screen_base;
 	int x, y, w = info->var.bits_per_pixel == 16 ? 2 : 4;
 	u32 color = rect->color, height = rect->height;
-	unsigned long p;
+	u8 __iomem *p;
 	
 	if (w==2) color |= color<<16;
 	for (y=rect->dy; height; y++, height--) {
diff -Nru a/drivers/video/stifb.c b/drivers/video/stifb.c
--- a/drivers/video/stifb.c	2004-12-24 13:37:43 -08:00
+++ b/drivers/video/stifb.c	2004-12-24 13:37:43 -08:00
@@ -112,6 +112,7 @@
 	ngle_rom_t ngle_rom;
 	struct sti_struct *sti;
 	int deviceSpecificConfig;
+	u32 pseudo_palette[16];
 };
 
 static int __initdata bpp = 8;	/* parameter from modprobe */
@@ -1030,6 +1031,14 @@
 				/* 0x100 is same as used in WRITE_IMAGE_COLOR() */
 		START_COLORMAPLOAD(fb, lutBltCtl.all);
 		SETUP_FB(fb);
+
+		/* info->var.bits_per_pixel == 32 */
+		if (regno < 16) 
+		  ((u32 *)(info->pseudo_palette))[regno] =
+			(red   << info->var.red.offset)   |
+			(green << info->var.green.offset) |
+			(blue  << info->var.blue.offset);
+
 	} else {
 		/* cleanup colormap hardware */
 		FINISH_IMAGE_COLORMAP_ACCESS(fb);
@@ -1326,7 +1335,7 @@
 	info->fbops = &stifb_ops;
 	info->screen_base = (void*) REGION_BASE(fb,1);
 	info->flags = FBINFO_DEFAULT;
-	info->currcon = -1;
+	info->pseudo_palette = &fb->pseudo_palette;
 
 	/* This has to been done !!! */
 	fb_alloc_cmap(&info->cmap, 256, 0);
@@ -1383,6 +1392,7 @@
 stifb_init(void)
 {
 	struct sti_struct *sti;
+	struct sti_struct *def_sti;
 	int i;
 	
 #ifndef MODULE
@@ -1397,9 +1407,19 @@
 		return -ENXIO;
 	}
 	
+	def_sti = sti_get_rom(0);
+	if (def_sti) {
+		for (i = 1; i < MAX_STI_ROMS; i++) {
+			sti = sti_get_rom(i);
+			if (sti == def_sti && bpp > 0)
+				stifb_force_bpp[i] = bpp;
+		}
+		stifb_init_fb(def_sti, stifb_force_bpp[i]);
+	}
+
 	for (i = 1; i < MAX_STI_ROMS; i++) {
 		sti = sti_get_rom(i);
-		if (!sti)
+		if (!sti || sti==def_sti)
 			break;
 		if (bpp > 0)
 			stifb_force_bpp[i] = bpp;
diff -Nru a/drivers/video/tcx.c b/drivers/video/tcx.c
--- a/drivers/video/tcx.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/video/tcx.c	2004-12-24 13:36:16 -08:00
@@ -106,10 +106,10 @@
 
 struct tcx_par {
 	spinlock_t		lock;
-	struct bt_regs		*bt;
-	struct tcx_thc		*thc;
-	struct tcx_tec		*tec;
-	volatile u32		*cplane;
+	struct bt_regs		__iomem *bt;
+	struct tcx_thc		__iomem *thc;
+	struct tcx_tec		__iomem *tec;
+	volatile u32		__iomem *cplane;
 
 	u32			flags;
 #define TCX_FLAG_BLANKED	0x00000001
@@ -127,7 +127,7 @@
 /* Reset control plane so that WID is 8-bit plane. */
 static void __tcx_set_control_plane (struct tcx_par *par)
 {
-	volatile u32 *p, *pend;
+	volatile u32 __iomem *p, *pend;
         
 	if (par->lowdepth)
 		return;
@@ -167,7 +167,7 @@
 			 unsigned transp, struct fb_info *info)
 {
 	struct tcx_par *par = (struct tcx_par *) info->par;
-	struct bt_regs *bt = par->bt;
+	struct bt_regs __iomem *bt = par->bt;
 	unsigned long flags;
 
 	if (regno >= 256)
@@ -198,7 +198,7 @@
 tcx_blank(int blank, struct fb_info *info)
 {
 	struct tcx_par *par = (struct tcx_par *) info->par;
-	struct tcx_thc *thc = par->thc;
+	struct tcx_thc __iomem *thc = par->thc;
 	unsigned long flags;
 	u32 val;
 
@@ -207,26 +207,26 @@
 	val = sbus_readl(&thc->thc_misc);
 
 	switch (blank) {
-	case 0: /* Unblanking */
+	case FB_BLANK_UNBLANK: /* Unblanking */
 		val &= ~(TCX_THC_MISC_VSYNC_DIS |
 			 TCX_THC_MISC_HSYNC_DIS);
 		val |= TCX_THC_MISC_VIDEO;
 		par->flags &= ~TCX_FLAG_BLANKED;
 		break;
 
-	case 1: /* Normal blanking */
+	case FB_BLANK_NORMAL: /* Normal blanking */
 		val &= ~TCX_THC_MISC_VIDEO;
 		par->flags |= TCX_FLAG_BLANKED;
 		break;
 
-	case 2: /* VESA blank (vsync off) */
+	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
 		val |= TCX_THC_MISC_VSYNC_DIS;
 		break;
-	case 3: /* VESA blank (hsync off) */
+	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
 		val |= TCX_THC_MISC_HSYNC_DIS;
 		break;
 
-	case 4: /* Poweroff */
+	case FB_BLANK_POWERDOWN: /* Poweroff */
 		break;
 	};
 
@@ -371,19 +371,15 @@
 				       all->info.var.xres);
 	all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
 
-	all->par.tec = (struct tcx_tec *)
-		sbus_ioremap(&sdev->resource[7], 0,
+	all->par.tec = sbus_ioremap(&sdev->resource[7], 0,
 			     sizeof(struct tcx_tec), "tcx tec");
-	all->par.thc = (struct tcx_thc *)
-		sbus_ioremap(&sdev->resource[9], 0,
+	all->par.thc = sbus_ioremap(&sdev->resource[9], 0,
 			     sizeof(struct tcx_thc), "tcx thc");
-	all->par.bt = (struct bt_regs *)
-		sbus_ioremap(&sdev->resource[8], 0,
+	all->par.bt = sbus_ioremap(&sdev->resource[8], 0,
 			     sizeof(struct bt_regs), "tcx dac");
 	memcpy(&all->par.mmap_map, &__tcx_mmap_map, sizeof(all->par.mmap_map));
 	if (!all->par.lowdepth) {
-		all->par.cplane = (volatile u32 *)
-			sbus_ioremap(&sdev->resource[4], 0,
+		all->par.cplane = sbus_ioremap(&sdev->resource[4], 0,
 				     all->par.fbsize * sizeof(u32), "tcx cplane");
 	} else {
 		all->par.mmap_map[1].size = SBUS_MMAP_EMPTY;
@@ -415,14 +411,12 @@
 	all->info.flags = FBINFO_DEFAULT;
 	all->info.fbops = &tcx_ops;
 #ifdef CONFIG_SPARC32
-	all->info.screen_base = (char *)
+	all->info.screen_base = (char __iomem *)
 		prom_getintdefault(sdev->prom_node, "address", 0);
 #endif
 	if (!all->info.screen_base)
-		all->info.screen_base = (char *)
-			sbus_ioremap(&sdev->resource[0], 0,
+		all->info.screen_base = sbus_ioremap(&sdev->resource[0], 0,
 				     all->par.fbsize, "tcx ram");
-	all->info.currcon = -1;
 	all->info.par = &all->par;
 
 	/* Initialize brooktree DAC. */
diff -Nru a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
--- a/drivers/video/tdfxfb.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/video/tdfxfb.c	2004-12-24 13:36:31 -08:00
@@ -202,7 +202,6 @@
  */
 static int  nopan   = 0;
 static int  nowrap  = 1;      // not implemented (yet)
-static int  inverse = 0;
 static char *mode_option __initdata = NULL;
 
 /* ------------------------------------------------------------------------- 
@@ -838,23 +837,23 @@
 	dacmode = tdfx_inl(par, DACMODE);
 
 	switch (blank) {
-		case 0: /* Screen: On; HSync: On, VSync: On */    
+		case FB_BLANK_UNBLANK: /* Screen: On; HSync: On, VSync: On */
 			state    = 0;
 			vgablank = 0;
 			break;
-		case 1: /* Screen: Off; HSync: On, VSync: On */
+		case FB_BLANK_NORMAL: /* Screen: Off; HSync: On, VSync: On */
 			state    = 0;
 			vgablank = 1;
 			break;
-		case 2: /* Screen: Off; HSync: On, VSync: Off */
+		case FB_BLANK_VSYNC_SUSPEND: /* Screen: Off; HSync: On, VSync: Off */
 			state    = BIT(3);
 			vgablank = 1;
 			break;
-		case 3: /* Screen: Off; HSync: Off, VSync: On */
+		case FB_BLANK_HSYNC_SUSPEND: /* Screen: Off; HSync: Off, VSync: On */
 			state    = BIT(1);
 			vgablank = 1;
 			break;
-		case 4: /* Screen: Off; HSync: Off, VSync: Off */
+		case FB_BLANK_POWERDOWN: /* Screen: Off; HSync: Off, VSync: Off */
 			state    = BIT(1) | BIT(3);
 			vgablank = 1;
 			break;
@@ -921,7 +920,6 @@
 	tdfx_outl(par,	COMMAND_2D, COMMAND_2D_FILLRECT | (tdfx_rop << 24));
 	tdfx_outl(par,	DSTSIZE,    rect->width | (rect->height << 16));
 	tdfx_outl(par,	LAUNCH_2D,  rect->dx | (rect->dy << 16));
-	banshee_wait_idle(info);
 }
 
 /*
@@ -957,7 +955,6 @@
 	tdfx_outl(par,	DSTSIZE,   area->width | (area->height << 16));
 	tdfx_outl(par,	DSTXY,     dx | (dy << 16));
 	tdfx_outl(par,	LAUNCH_2D, sx | (sy << 16)); 
-	banshee_wait_idle(info);
 }
 
 static void tdfxfb_imageblit(struct fb_info *info, const struct fb_image *image) 
@@ -1025,7 +1022,6 @@
 		case 2:  tdfx_outl(par,	LAUNCH_2D,*(u16*)chardata); break;
 		case 3:  tdfx_outl(par,	LAUNCH_2D,*(u16*)chardata | ((chardata[3]) << 24)); break;
 	}
-	banshee_wait_idle(info);
 }
 #endif /* CONFIG_FB_3DFX_ACCEL */
 
@@ -1397,10 +1393,7 @@
 	while ((this_opt = strsep(&options, ",")) != NULL) {	
 		if (!*this_opt)
 			continue;
-		if (!strcmp(this_opt, "inverse")) {
-			inverse = 1;
-			fb_invert_cmaps();
-		} else if(!strcmp(this_opt, "nopan")) {
+		if(!strcmp(this_opt, "nopan")) {
 			nopan = 1;
 		} else if(!strcmp(this_opt, "nowrap")) {
 			nowrap = 1;
diff -Nru a/drivers/video/tgafb.c b/drivers/video/tgafb.c
--- a/drivers/video/tgafb.c	2004-12-24 13:37:02 -08:00
+++ b/drivers/video/tgafb.c	2004-12-24 13:37:02 -08:00
@@ -468,7 +468,7 @@
 	vvvr &= ~(TGA_VALID_VIDEO | TGA_VALID_BLANK);
 
 	switch (blank) {
-	case 0: /* Unblanking */
+	case FB_BLANK_UNBLANK: /* Unblanking */
 		if (par->vesa_blanked) {
 			TGA_WRITE_REG(par, vhcr & 0xbfffffff, TGA_HORIZ_REG);
 			TGA_WRITE_REG(par, vvcr & 0xbfffffff, TGA_VERT_REG);
@@ -477,24 +477,24 @@
 		TGA_WRITE_REG(par, vvvr | TGA_VALID_VIDEO, TGA_VALID_REG);
 		break;
 
-	case 1: /* Normal blanking */
+	case FB_BLANK_NORMAL: /* Normal blanking */
 		TGA_WRITE_REG(par, vvvr | TGA_VALID_VIDEO | TGA_VALID_BLANK,
 			      TGA_VALID_REG);
 		break;
 
-	case 2: /* VESA blank (vsync off) */
+	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
 		TGA_WRITE_REG(par, vvcr | 0x40000000, TGA_VERT_REG);
 		TGA_WRITE_REG(par, vvvr | TGA_VALID_BLANK, TGA_VALID_REG);
 		par->vesa_blanked = 1;
 		break;
 
-	case 3: /* VESA blank (hsync off) */
+	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
 		TGA_WRITE_REG(par, vhcr | 0x40000000, TGA_HORIZ_REG);
 		TGA_WRITE_REG(par, vvvr | TGA_VALID_BLANK, TGA_VALID_REG);
 		par->vesa_blanked = 1;
 		break;
 
-	case 4: /* Poweroff */
+	case FB_BLANK_POWERDOWN: /* Poweroff */
 		TGA_WRITE_REG(par, vhcr | 0x40000000, TGA_HORIZ_REG);
 		TGA_WRITE_REG(par, vvcr | 0x40000000, TGA_VERT_REG);
 		TGA_WRITE_REG(par, vvvr | TGA_VALID_BLANK, TGA_VALID_REG);
@@ -562,7 +562,8 @@
 	unsigned long rincr, line_length, shift, pos, is8bpp;
 	unsigned long i, j;
 	const unsigned char *data;
-	void *regs_base, *fb_base;
+	void __iomem *regs_base;
+	void __iomem *fb_base;
 
 	dx = image->dx;
 	dy = image->dy;
@@ -785,7 +786,8 @@
 	int is8bpp = info->var.bits_per_pixel == 8;
 	u32 dx, dy, width, height, vxres, vyres, color;
 	unsigned long pos, align, line_length, i, j;
-	void *regs_base, *fb_base;
+	void __iomem *regs_base;
+	void __iomem *fb_base;
 
 	dx = rect->dx;
 	dy = rect->dy;
@@ -912,7 +914,7 @@
 		   u32 height, u32 width)
 {
 	struct tga_par *par = (struct tga_par *) info->par;
-	void *tga_regs = par->tga_regs_base;
+	void __iomem *tga_regs = par->tga_regs_base;
 	unsigned long dpos, spos, i, n64;
 
 	/* Set up the MODE and PIXELSHIFT registers.  */
@@ -957,9 +959,10 @@
 		    u32 height, u32 width)
 {
 	struct tga_par *par = (struct tga_par *) info->par;
-	void *tga_regs = par->tga_regs_base;
-	void *tga_fb = par->tga_fb_base;
-	void *src, *dst;
+	void __iomem *tga_regs = par->tga_regs_base;
+	void __iomem *tga_fb = par->tga_fb_base;
+	void __iomem *src;
+	void __iomem *dst;
 	unsigned long i, n16;
 
 	/* Set up the MODE and PIXELSHIFT registers.  */
@@ -1010,7 +1013,8 @@
 	u32 smask_first, dmask_first, dmask_last;
 	int pixel_shift, need_prime, need_second;
 	unsigned long n64, n32, xincr_first;
-	void *tga_regs, *tga_fb;
+	void __iomem *tga_regs;
+	void __iomem *tga_fb;
 
 	yincr = line_length;
 	if (dy > sy) {
@@ -1098,7 +1102,8 @@
 
 	for (i = 0; i < height; ++i) {
 		unsigned long j;
-		void *sfb, *dfb;
+		void __iomem *sfb;
+		void __iomem *dfb;
 
 		sfb = tga_fb + spos;
 		dfb = tga_fb + dpos;
@@ -1120,7 +1125,7 @@
 			dfb += 32;
 		}
 
-		if (n64 && (((long)sfb | (long)dfb) & 63))
+		if (n64 && (((unsigned long)sfb | (unsigned long)dfb) & 63))
 			printk(KERN_ERR
 			       "tgafb: misaligned copy64 (s:%p, d:%p)\n",
 			       sfb, dfb);
@@ -1169,7 +1174,8 @@
 	unsigned long depos, sepos, dealign, sealign;
 	u32 mask_first, mask_last;
 	unsigned long n32;
-	void *tga_regs, *tga_fb;
+	void __iomem *tga_regs;
+	void __iomem *tga_fb;
 
 	yincr = line_length;
 	if (dy > sy) {
@@ -1223,7 +1229,8 @@
 
 	for (i = 0; i < height; ++i) {
 		unsigned long j;
-		void *sfb, *dfb;
+		void __iomem *sfb;
+		void __iomem *dfb;
 
 		sfb = tga_fb + sepos;
 		dfb = tga_fb + depos;
@@ -1380,7 +1387,7 @@
 		u32 pseudo_palette[16];
 	} *all;
 
-	void *mem_base;
+	void __iomem *mem_base;
 	unsigned long bar0_start, bar0_len;
 	u8 tga_type;
 	int ret;
@@ -1429,8 +1436,7 @@
 	all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
                           FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_FILLRECT;
 	all->info.fbops = &tgafb_ops;
-	all->info.screen_base = (char *) all->par.tga_fb_base;
-	all->info.currcon = -1;
+	all->info.screen_base = all->par.tga_fb_base;
 	all->info.par = &all->par;
 	all->info.pseudo_palette = all->pseudo_palette;
 
@@ -1454,6 +1460,7 @@
 	tgafb_set_par(&all->info);
 	tgafb_init_fix(&all->info);
 
+	all->info.device = &pdev->dev;
 	if (register_framebuffer(&all->info) < 0) {
 		printk(KERN_ERR "tgafb: Could not register framebuffer\n");
 		ret = -EINVAL;
diff -Nru a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
--- a/drivers/video/tridentfb.c	2004-12-24 13:36:49 -08:00
+++ b/drivers/video/tridentfb.c	2004-12-24 13:36:49 -08:00
@@ -38,7 +38,7 @@
 
 /* FIXME:kmalloc these 3 instead */
 static struct fb_info fb_info;
-static int pseudo_pal[16];
+static u32 pseudo_pal[16];
 
 
 static struct fb_var_screeninfo default_var;
@@ -460,7 +460,7 @@
 		default:
 		case 8: col = fr->color;
 			break;
-		case 16: col = ((u16 *)(info->pseudo_palette))[fr->color];
+		case 16: col = ((u32 *)(info->pseudo_palette))[fr->color];
 			 break;
 		case 32: col = ((u32 *)(info->pseudo_palette))[fr->color];
 			 break;
@@ -990,7 +990,7 @@
 
 	} else
 	if (bpp == 16) 			/* RGB 565 */
-			((u16*)info->pseudo_palette)[regno] = (red & 0xF800) |
+			((u32*)info->pseudo_palette)[regno] = (red & 0xF800) |
 			((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
 	else
 	if (bpp == 32)		/* ARGB 8888 */
@@ -1017,22 +1017,24 @@
 	DPMSCont = read3CE(PowerStatus) & 0xFC;
 	switch (blank_mode)
 	{
-	case VESA_NO_BLANKING:
+	case FB_BLANK_UNBLANK:
 		/* Screen: On, HSync: On, VSync: On */
+	case FB_BLANK_NORMAL:
+		/* Screen: Off, HSync: On, VSync: On */
 		PMCont |= 0x03;
 		DPMSCont |= 0x00;
 		break;
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		/* Screen: Off, HSync: Off, VSync: On */
 		PMCont |= 0x02;
 		DPMSCont |= 0x01;
 		break;
-	case VESA_VSYNC_SUSPEND:
+	case FB_BLANK_VSYNC_SUSPEND:
 		/* Screen: Off, HSync: On, VSync: Off */
 		PMCont |= 0x02;
 		DPMSCont |= 0x02;
 		break;
-	case VESA_POWERDOWN:
+	case FB_BLANK_POWERDOWN:
 		/* Screen: Off, HSync: Off, VSync: Off */
 		PMCont |= 0x00;
 		DPMSCont |= 0x03;
@@ -1044,7 +1046,9 @@
 	t_outb(PMCont,0x83C6);
 
 	debug("exit\n");
-	return 0;
+
+	/* let fbcon do a softblank for us */
+	return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0;
 }
 
 static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_device_id * id)
@@ -1164,6 +1168,7 @@
 		default_var.accel_flags &= ~FB_ACCELF_TEXT;
 	default_var.activate |= FB_ACTIVATE_NOW;
 	fb_info.var = default_var;
+	fb_info.device = &dev->dev;
 	if (register_framebuffer(&fb_info) < 0) {
 		output("Could not register Trident framebuffer\n");
 		return -EINVAL;
diff -Nru a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
--- a/drivers/video/valkyriefb.c	2004-12-24 13:37:18 -08:00
+++ b/drivers/video/valkyriefb.c	2004-12-24 13:37:18 -08:00
@@ -89,13 +89,13 @@
 struct fb_info_valkyrie {
 	struct fb_info		info;
 	struct fb_par_valkyrie	par;
-	struct cmap_regs	*cmap_regs;
+	struct cmap_regs	__iomem *cmap_regs;
 	unsigned long		cmap_regs_phys;
 	
-	struct valkyrie_regs	*valkyrie_regs;
+	struct valkyrie_regs	__iomem *valkyrie_regs;
 	unsigned long		valkyrie_regs_phys;
 	
-	__u8			*frame_buffer;
+	__u8			__iomem *frame_buffer;
 	unsigned long		frame_buffer_phys;
 	
 	int			sense;
@@ -142,7 +142,7 @@
 static int valkyriefb_set_par(struct fb_info *info)
 {
 	struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info;
-	volatile struct valkyrie_regs *valkyrie_regs = p->valkyrie_regs;
+	volatile struct valkyrie_regs __iomem *valkyrie_regs = p->valkyrie_regs;
 	struct fb_par_valkyrie *par = info->par;
 	struct valkyrie_regvals	*init;
 	int err;
@@ -207,13 +207,13 @@
 		return 1;
 
 	switch (blank_mode) {
-	case 0:			/* unblank */
+	case FB_BLANK_UNBLANK:			/* unblank */
 		out_8(&p->valkyrie_regs->mode.r, init->mode);
 		break;
-	case 1:
+	case FB_BLANK_NORMAL:
 		return 1;	/* get caller to set CLUT to all black */
-	case VESA_VSYNC_SUSPEND+1:
-	case VESA_HSYNC_SUSPEND+1:
+	case FB_BLANK_VSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		/*
 		 * [kps] Value extracted from MacOS. I don't know
 		 * whether this bit disables hsync or vsync, or
@@ -221,7 +221,7 @@
 		 */
 		out_8(&p->valkyrie_regs->mode.r, init->mode | 0x40);
 		break;
-	case VESA_POWERDOWN+1:
+	case FB_BLANK_POWERDOWN:
 		out_8(&p->valkyrie_regs->mode.r, 0x66);
 		break;
 	}
@@ -232,7 +232,7 @@
 			     u_int transp, struct fb_info *info)
 {
 	struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info;
-	volatile struct cmap_regs *cmap_regs = p->cmap_regs;
+	volatile struct cmap_regs __iomem *cmap_regs = p->cmap_regs;
 	struct fb_par_valkyrie *par = info->par;
 
 	if (regno > 255)
@@ -341,21 +341,23 @@
 	cmap_regs_phys = 0x50f24000;
 	flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */
 #else /* ppc (!CONFIG_MAC) */
-	struct device_node *dp;
+	{
+		struct device_node *dp;
 
-	dp = find_devices("valkyrie");
-	if (dp == 0)
-		return 0;
-
-	if (dp->n_addrs != 1) {
-		printk(KERN_ERR "expecting 1 address for valkyrie (got %d)\n",
-		       dp->n_addrs);
-		return 0;
+		dp = find_devices("valkyrie");
+		if (dp == 0)
+			return 0;
+
+		if (dp->n_addrs != 1) {
+			printk(KERN_ERR "expecting 1 address for valkyrie (got %d)\n",
+			       dp->n_addrs);
+			return 0;
+		}
+
+		frame_buffer_phys = dp->addrs[0].address;
+		cmap_regs_phys = dp->addrs[0].address+0x304000;
+		flags = _PAGE_WRITETHRU;
 	}
-
-	frame_buffer_phys = dp->addrs[0].address;
-	cmap_regs_phys = dp->addrs[0].address+0x304000;
-	flags = _PAGE_WRITETHRU;
 #endif /* ppc (!CONFIG_MAC) */
 
 	p = kmalloc(sizeof(*p), GFP_ATOMIC);
@@ -544,7 +546,7 @@
 static void __init valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p)
 {
 	info->fbops = &valkyriefb_ops;
-	info->screen_base = (char *) p->frame_buffer + 0x1000;
+	info->screen_base = p->frame_buffer + 0x1000;
 	info->flags = FBINFO_DEFAULT;
 	info->pseudo_palette = p->pseudo_palette;
 	fb_alloc_cmap(&info->cmap, 256, 0);
diff -Nru a/drivers/video/vesafb.c b/drivers/video/vesafb.c
--- a/drivers/video/vesafb.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/video/vesafb.c	2004-12-24 13:36:18 -08:00
@@ -49,12 +49,14 @@
 
 static int             inverse   = 0;
 static int             mtrr      = 1;
-static int	       vram __initdata = 0; /* Set amount of memory to be used */
+static int	       vram_remap __initdata = 0; /* Set amount of memory to be used */
+static int	       vram_total __initdata = 0; /* Set total amount of memory */
 static int             pmi_setpal = 0;	/* pmi for palette changes ??? */
 static int             ypan       = 0;  /* 0..nothing, 1..ypan, 2..ywrap */
 static unsigned short  *pmi_base  = NULL;
 static void            (*pmi_start)(void);
 static void            (*pmi_pal)(void);
+static int             depth;
 
 /* --------------------------------------------------------------------- */
 
@@ -88,11 +90,11 @@
 }
 
 static void vesa_setpalette(int regno, unsigned red, unsigned green,
-			    unsigned blue, struct fb_var_screeninfo *var)
+			    unsigned blue)
 {
 #ifdef __i386__
 	struct { u_char blue, green, red, pad; } entry;
-	int shift = 16 - var->green.length;
+	int shift = 16 - depth;
 
 	if (pmi_setpal) {
 		entry.red   = red   >> shift;
@@ -134,7 +136,7 @@
 
 	switch (info->var.bits_per_pixel) {
 	case 8:
-		vesa_setpalette(regno,red,green,blue, &info->var);
+		vesa_setpalette(regno,red,green,blue);
 		break;
 	case 16:
 		if (info->var.red.offset == 10) {
@@ -209,8 +211,10 @@
 			mtrr=1;
 		else if (! strcmp(this_opt, "nomtrr"))
 			mtrr=0;
-		else if (! strncmp(this_opt, "vram:", 5))
-			vram = simple_strtoul(this_opt+5, NULL, 0);
+		else if (! strncmp(this_opt, "vtotal:", 7))
+			vram_total = simple_strtoul(this_opt+7, NULL, 0);
+		else if (! strncmp(this_opt, "vremap:", 7))
+			vram_remap = simple_strtoul(this_opt+7, NULL, 0);
 	}
 	return 0;
 }
@@ -220,6 +224,9 @@
 	struct platform_device *dev = to_platform_device(device);
 	struct fb_info *info;
 	int i, err;
+	unsigned int size_vmode;
+	unsigned int size_remap;
+	unsigned int size_total;
 
 	if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
 		return -ENXIO;
@@ -231,32 +238,41 @@
 	vesafb_defined.xres = screen_info.lfb_width;
 	vesafb_defined.yres = screen_info.lfb_height;
 	vesafb_fix.line_length = screen_info.lfb_linelength;
-
-	/* Allocate enough memory for double buffering */
-	vesafb_fix.smem_len = screen_info.lfb_width * screen_info.lfb_height * vesafb_defined.bits_per_pixel >> 2;
-
-	/* check that we don't remap more memory than old cards have */
-	if (vesafb_fix.smem_len > (screen_info.lfb_size * 65536))
-		vesafb_fix.smem_len = screen_info.lfb_size * 65536;
-
-	/* Set video size according to vram boot option */
-	if (vram)
-		vesafb_fix.smem_len = vram * 1024 * 1024;
-
 	vesafb_fix.visual   = (vesafb_defined.bits_per_pixel == 8) ?
 		FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
 
-	/* limit framebuffer size to 16 MB.  Otherwise we'll eat tons of
-	 * kernel address space for nothing if the gfx card has alot of
-	 * memory (>= 128 MB isn't uncommon these days ...) */
-	if (vesafb_fix.smem_len > 16 * 1024 * 1024)
-		vesafb_fix.smem_len = 16 * 1024 * 1024;
+	/*   size_vmode -- that is the amount of memory needed for the
+	 *                 used video mode, i.e. the minimum amount of
+	 *                 memory we need. */
+	size_vmode = vesafb_defined.yres * vesafb_fix.line_length;
+
+	/*   size_total -- all video memory we have. Used for mtrr
+	 *                 entries, ressource allocation and bounds
+	 *                 checking. */
+	size_total = screen_info.lfb_size * 65536;
+	if (vram_total)
+		size_total = vram_total * 1024 * 1024;
+	if (size_total < size_vmode)
+		size_total = size_vmode;
+
+	/*   size_remap -- the amount of video memory we are going to
+	 *                 use for vesafb.  With modern cards it is no
+	 *                 option to simply use size_total as that
+	 *                 wastes plenty of kernel address space. */
+	size_remap  = size_vmode * 2;
+	if (vram_remap)
+		size_remap = vram_remap * 1024 * 1024;
+	if (size_remap < size_vmode)
+		size_remap = size_vmode;
+	if (size_remap > size_total)
+		size_remap = size_total;
+	vesafb_fix.smem_len = size_remap;
 
 #ifndef __i386__
 	screen_info.vesapm_seg = 0;
 #endif
 
-	if (!request_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len, "vesafb")) {
+	if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
 		printk(KERN_WARNING
 		       "vesafb: abort, cannot reserve video memory at 0x%lx\n",
 			vesafb_fix.smem_start);
@@ -281,8 +297,10 @@
 		goto err;
 	}
 
-	printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, size %dk\n",
-	       vesafb_fix.smem_start, info->screen_base, vesafb_fix.smem_len/1024);
+	printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, "
+	       "using %dk, total %dk\n",
+	       vesafb_fix.smem_start, info->screen_base,
+	       size_remap/1024, size_total/1024);
 	printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
 	       vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
 
@@ -341,6 +359,15 @@
 	vesafb_defined.blue.length   = screen_info.blue_size;
 	vesafb_defined.transp.offset = screen_info.rsvd_pos;
 	vesafb_defined.transp.length = screen_info.rsvd_size;
+
+	if (vesafb_defined.bits_per_pixel <= 8) {
+		depth = vesafb_defined.green.length;
+		vesafb_defined.red.length =
+		vesafb_defined.green.length =
+		vesafb_defined.blue.length =
+		vesafb_defined.bits_per_pixel;
+	}
+
 	printk(KERN_INFO "vesafb: %s: "
 	       "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
 	       (vesafb_defined.bits_per_pixel > 8) ?
@@ -362,7 +389,7 @@
 	request_region(0x3c0, 32, "vesafb");
 
 	if (mtrr) {
-		int temp_size = vesafb_fix.smem_len;
+		int temp_size = size_total;
 		/* Find the largest power-of-two */
 		while (temp_size & (temp_size - 1))
                 	temp_size &= (temp_size - 1);
@@ -393,7 +420,7 @@
 	return 0;
 err:
 	framebuffer_release(info);
-	release_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len);
+	release_mem_region(vesafb_fix.smem_start, size_total);
 	return err;
 }
 
diff -Nru a/drivers/video/vfb.c b/drivers/video/vfb.c
--- a/drivers/video/vfb.c	2004-12-24 13:36:16 -08:00
+++ b/drivers/video/vfb.c	2004-12-24 13:36:16 -08:00
@@ -430,7 +430,7 @@
 	if (!info)
 		goto err;
 
-	info->screen_base = videomemory;
+	info->screen_base = (char __iomem *)videomemory;
 	info->fbops = &vfb_ops;
 
 	retval = fb_find_mode(&info->var, info, NULL,
diff -Nru a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
--- a/drivers/video/vga16fb.c	2004-12-24 13:36:31 -08:00
+++ b/drivers/video/vga16fb.c	2004-12-24 13:36:31 -08:00
@@ -123,7 +123,7 @@
    suitable instruction is the x86 bitwise OR.  The following
    read-modify-write routine should optimize to one such bitwise
    OR. */
-static inline void rmw(volatile char *p)
+static inline void rmw(volatile char __iomem *p)
 {
 	readb(p);
 	writeb(1, p);
@@ -771,7 +771,7 @@
 	 * <Start of vertical Retrace> to maximum (incl. overflow)
 	 * Result: turn off vertical sync (VSync) pulse.
 	 */
-	if (mode & VESA_VSYNC_SUSPEND) {
+	if (mode & FB_BLANK_VSYNC_SUSPEND) {
 		outb_p(0x10,vga_video_port_reg);	/* StartVertRetrace */
 		outb_p(0xff,vga_video_port_val); 	/* maximum value */
 		outb_p(0x11,vga_video_port_reg);	/* EndVertRetrace */
@@ -780,7 +780,7 @@
 		outb_p(par->vga_state.Overflow | 0x84,vga_video_port_val); /* bits 9,10 of vert. retrace */
 	}
 
-	if (mode & VESA_HSYNC_SUSPEND) {
+	if (mode & FB_BLANK_HSYNC_SUSPEND) {
 		/*
 		 * Set <End of horizontal retrace> to minimum (0) and
 		 *  <Start of horizontal Retrace> to maximum
@@ -853,22 +853,21 @@
 	struct vga16fb_par *par = (struct vga16fb_par *) info->par;
 
 	switch (blank) {
-	case 0:				/* Unblank */
+	case FB_BLANK_UNBLANK:				/* Unblank */
 		if (par->vesa_blanked) {
 			vga_vesa_unblank(par);
 			par->vesa_blanked = 0;
 		}
 		if (par->palette_blanked) {
-			//do_install_cmap(info->currcon, info);
 			par->palette_blanked = 0;
 		}
 		break;
-	case 1:				/* blank */
+	case FB_BLANK_NORMAL:				/* blank */
 		vga_pal_blank();
 		par->palette_blanked = 1;
 		break;
 	default:			/* VESA blanking */
-		vga_vesa_blank(par, blank-1);
+		vga_vesa_blank(par, blank);
 		par->vesa_blanked = 1;
 		break;
 	}
@@ -883,7 +882,7 @@
         char oldmask = selectmask();
         int line_ofs, height;
         char oldop, oldsr;
-        char *where;
+        char __iomem *where;
 
         dx /= 4;
         where = info->screen_base + dx + rect->dy * info->fix.line_length;
@@ -932,7 +931,7 @@
 void vga16fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 {
 	int x, x2, y2, vxres, vyres, width, height, line_ofs;
-	char *dst;
+	char __iomem *dst;
 
 	vxres = info->var.xres_virtual;
 	vyres = info->var.yres_virtual;
@@ -1012,7 +1011,8 @@
         char oldsr = setsr(0xf);
         int height, line_ofs, x;
 	u32 sx, dx, width;
-	char *dest, *src;
+	char __iomem *dest;
+	char __iomem *src;
 
         height = area->height;
 
@@ -1063,7 +1063,8 @@
 	u32 dx = area->dx, dy = area->dy, sx = area->sx, sy = area->sy; 
 	int x, x2, y2, old_dx, old_dy, vxres, vyres;
 	int height, width, line_ofs;
-	char *dst = NULL, *src = NULL;
+	char __iomem *dst = NULL;
+	char __iomem *src = NULL;
 
 	vxres = info->var.xres_virtual;
 	vyres = info->var.yres_virtual;
@@ -1174,7 +1175,7 @@
         char oldmask = selectmask();
         const char *cdat = image->data;
 	u32 dx = image->dx;
-        char *where;
+        char __iomem *where;
         int y;
 
         dx /= 4;
@@ -1198,10 +1199,11 @@
 
 void vga_imageblit_expand(struct fb_info *info, const struct fb_image *image)
 {
-	char *where = info->screen_base + (image->dx/8) + 
+	char __iomem *where = info->screen_base + (image->dx/8) +
 		image->dy * info->fix.line_length;
 	struct vga16fb_par *par = (struct vga16fb_par *) info->par;
-	char *cdat = (char *) image->data, *dst;
+	char *cdat = (char *) image->data;
+	char __iomem *dst;
 	int x, y;
 
 	switch (info->fix.type) {
@@ -1265,9 +1267,11 @@
 	 * Draw logo 
 	 */
 	struct vga16fb_par *par = (struct vga16fb_par *) info->par;
-	char *where = info->screen_base + image->dy * info->fix.line_length + 
+	char __iomem *where =
+		info->screen_base + image->dy * info->fix.line_length +
 		image->dx/8;
-	const char *cdat = image->data, *dst;
+	const char *cdat = image->data;
+	char __iomem *dst;
 	int x, y;
 
 	switch (info->fix.type) {
@@ -1306,7 +1310,7 @@
 {
 	if (image->depth == 1)
 		vga_imageblit_expand(info, image);
-	else if (image->depth <= info->var.bits_per_pixel)
+	else
 		vga_imageblit_color(info, image);
 }
 
@@ -1354,7 +1358,7 @@
 
 	/* XXX share VGA_FB_PHYS and I/O region with vgacon and others */
 
-	vga16fb.screen_base = (void *)VGA_MAP_MEM(VGA_FB_PHYS);
+	vga16fb.screen_base = (void __iomem *)VGA_MAP_MEM(VGA_FB_PHYS);
 	if (!vga16fb.screen_base) {
 		printk(KERN_ERR "vga16fb: unable to map device\n");
 		ret = -ENOMEM;
diff -Nru a/drivers/w1/Kconfig b/drivers/w1/Kconfig
--- a/drivers/w1/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/drivers/w1/Kconfig	2004-12-24 13:37:18 -08:00
@@ -30,7 +30,7 @@
 	  This support is also available as a module.  If so, the module 
 	  will be called ds9490r.ko.
 
-config W1_DS9490R_BRIDGE
+config W1_DS9490_BRIDGE
 	tristate "DS9490R USB <-> W1 transport layer for 1-wire"
 	depends on W1_DS9490
 	help
diff -Nru a/drivers/w1/Makefile b/drivers/w1/Makefile
--- a/drivers/w1/Makefile	2004-12-24 13:36:49 -08:00
+++ b/drivers/w1/Makefile	2004-12-24 13:36:49 -08:00
@@ -2,6 +2,10 @@
 # Makefile for the Dallas's 1-wire bus.
 #
 
+ifneq ($(CONFIG_NET), y)
+EXTRA_CFLAGS	+= -DNETLINK_DISABLED
+endif
+
 obj-$(CONFIG_W1)	+= wire.o
 wire-objs		:= w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o
 
diff -Nru a/drivers/w1/dscore.c b/drivers/w1/dscore.c
--- a/drivers/w1/dscore.c	2004-12-24 13:37:29 -08:00
+++ b/drivers/w1/dscore.c	2004-12-24 13:37:29 -08:00
@@ -35,26 +35,26 @@
 int ds_probe(struct usb_interface *, const struct usb_device_id *);
 void ds_disconnect(struct usb_interface *);
 
-inline int ds_touch_bit(struct ds_device *, u8, u8 *);
-inline int ds_read_byte(struct ds_device *, u8 *);
-inline int ds_read_bit(struct ds_device *, u8 *);
-inline int ds_write_byte(struct ds_device *, u8);
-inline int ds_write_bit(struct ds_device *, u8);
-inline int ds_start_pulse(struct ds_device *, int);
-inline int ds_set_speed(struct ds_device *, int);
-inline int ds_reset(struct ds_device *, struct ds_status *);
-inline int ds_detect(struct ds_device *, struct ds_status *);
-inline int ds_stop_pulse(struct ds_device *, int);
-inline int ds_send_data(struct ds_device *, unsigned char *, int);
-inline int ds_recv_data(struct ds_device *, unsigned char *, int);
-inline int ds_recv_status(struct ds_device *, struct ds_status *);
-inline struct ds_device * ds_get_device(void);
-inline void ds_put_device(struct ds_device *);
+int ds_touch_bit(struct ds_device *, u8, u8 *);
+int ds_read_byte(struct ds_device *, u8 *);
+int ds_read_bit(struct ds_device *, u8 *);
+int ds_write_byte(struct ds_device *, u8);
+int ds_write_bit(struct ds_device *, u8);
+int ds_start_pulse(struct ds_device *, int);
+int ds_set_speed(struct ds_device *, int);
+int ds_reset(struct ds_device *, struct ds_status *);
+int ds_detect(struct ds_device *, struct ds_status *);
+int ds_stop_pulse(struct ds_device *, int);
+int ds_send_data(struct ds_device *, unsigned char *, int);
+int ds_recv_data(struct ds_device *, unsigned char *, int);
+int ds_recv_status(struct ds_device *, struct ds_status *);
+struct ds_device * ds_get_device(void);
+void ds_put_device(struct ds_device *);
 
 static inline void ds_dump_status(unsigned char *, unsigned char *, int);
-static inline int ds_send_control(struct ds_device *, u16, u16);
-static inline int ds_send_control_mode(struct ds_device *, u16, u16);
-static inline int ds_send_control_cmd(struct ds_device *, u16, u16);
+static int ds_send_control(struct ds_device *, u16, u16);
+static int ds_send_control_mode(struct ds_device *, u16, u16);
+static int ds_send_control_cmd(struct ds_device *, u16, u16);
 
 
 static struct usb_driver ds_driver = {
@@ -503,7 +503,7 @@
 	return 0;
 }
 
-inline int ds_read_block(struct ds_device *dev, u8 *buf, int len)
+int ds_read_block(struct ds_device *dev, u8 *buf, int len)
 {
 	struct ds_status st;
 	int err;
@@ -529,7 +529,7 @@
 	return err;
 }
 
-inline int ds_write_block(struct ds_device *dev, u8 *buf, int len)
+int ds_write_block(struct ds_device *dev, u8 *buf, int len)
 {
 	int err;
 	struct ds_status st;
@@ -727,11 +727,16 @@
 {
 	struct ds_device *dev;
 	
-	dev = usb_get_intfdata (intf);
-	usb_set_intfdata (intf, NULL);
+	dev = usb_get_intfdata(intf);
+	usb_set_intfdata(intf, NULL);
 
-	while(atomic_read(&dev->refcnt))
-		schedule_timeout(HZ);
+	while (atomic_read(&dev->refcnt)) {
+		printk(KERN_INFO "Waiting for DS to become free: refcnt=%d.\n",
+				atomic_read(&dev->refcnt));
+
+		if (msleep_interruptible(1000))
+			flush_signals(current);
+	}
 
 	usb_put_dev(dev->udev);
 	kfree(dev);
diff -Nru a/drivers/w1/dscore.h b/drivers/w1/dscore.h
--- a/drivers/w1/dscore.h	2004-12-24 13:36:49 -08:00
+++ b/drivers/w1/dscore.h	2004-12-24 13:36:49 -08:00
@@ -151,23 +151,23 @@
 
 };
 
-inline int ds_touch_bit(struct ds_device *, u8, u8 *);
-inline int ds_read_byte(struct ds_device *, u8 *);
-inline int ds_read_bit(struct ds_device *, u8 *);
-inline int ds_write_byte(struct ds_device *, u8);
-inline int ds_write_bit(struct ds_device *, u8);
-inline int ds_start_pulse(struct ds_device *, int);
-inline int ds_set_speed(struct ds_device *, int);
-inline int ds_reset(struct ds_device *, struct ds_status *);
-inline int ds_detect(struct ds_device *, struct ds_status *);
-inline int ds_stop_pulse(struct ds_device *, int);
-inline int ds_send_data(struct ds_device *, unsigned char *, int);
-inline int ds_recv_data(struct ds_device *, unsigned char *, int);
-inline int ds_recv_status(struct ds_device *, struct ds_status *);
-inline struct ds_device * ds_get_device(void);
-inline void ds_put_device(struct ds_device *);
-inline int ds_write_block(struct ds_device *, u8 *, int);
-inline int ds_read_block(struct ds_device *, u8 *, int);
+int ds_touch_bit(struct ds_device *, u8, u8 *);
+int ds_read_byte(struct ds_device *, u8 *);
+int ds_read_bit(struct ds_device *, u8 *);
+int ds_write_byte(struct ds_device *, u8);
+int ds_write_bit(struct ds_device *, u8);
+int ds_start_pulse(struct ds_device *, int);
+int ds_set_speed(struct ds_device *, int);
+int ds_reset(struct ds_device *, struct ds_status *);
+int ds_detect(struct ds_device *, struct ds_status *);
+int ds_stop_pulse(struct ds_device *, int);
+int ds_send_data(struct ds_device *, unsigned char *, int);
+int ds_recv_data(struct ds_device *, unsigned char *, int);
+int ds_recv_status(struct ds_device *, struct ds_status *);
+struct ds_device * ds_get_device(void);
+void ds_put_device(struct ds_device *);
+int ds_write_block(struct ds_device *, u8 *, int);
+int ds_read_block(struct ds_device *, u8 *, int);
 
 #endif /* __DSCORE_H */
 
diff -Nru a/drivers/w1/matrox_w1.c b/drivers/w1/matrox_w1.c
--- a/drivers/w1/matrox_w1.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/w1/matrox_w1.c	2004-12-24 13:37:01 -08:00
@@ -78,11 +78,13 @@
 
 struct matrox_device
 {
-	unsigned long base_addr;
-	unsigned long port_index, port_data;
+	void __iomem *base_addr;
+	void __iomem *port_index;
+	void __iomem *port_data;
 	u8 data_mask;
 
-	unsigned long phys_addr, virt_addr;
+	unsigned long phys_addr;
+	void __iomem *virt_addr;
 	unsigned long found;
 
 	struct w1_bus_master *bus_master;
@@ -181,8 +183,7 @@
 
 	dev->phys_addr = pci_resource_start(pdev, 1);
 
-	dev->virt_addr =
-		(unsigned long) ioremap_nocache(dev->phys_addr, 16384);
+	dev->virt_addr = ioremap_nocache(dev->phys_addr, 16384);
 	if (!dev->virt_addr) {
 		dev_err(&pdev->dev, "%s: failed to ioremap(0x%lx, %d).\n",
 			__func__, dev->phys_addr, 16384);
@@ -227,7 +228,7 @@
 
 	if (dev->found) {
 		w1_remove_master_device(dev->bus_master);
-		iounmap((void *) dev->virt_addr);
+		iounmap(dev->virt_addr);
 	}
 	kfree(dev);
 }
diff -Nru a/drivers/w1/w1.c b/drivers/w1/w1.c
--- a/drivers/w1/w1.c	2004-12-24 13:36:35 -08:00
+++ b/drivers/w1/w1.c	2004-12-24 13:36:35 -08:00
@@ -47,9 +47,11 @@
 
 static int w1_timeout = 10;
 int w1_max_slave_count = 10;
+int w1_max_slave_ttl = 10;
 
 module_param_named(timeout, w1_timeout, int, 0);
 module_param_named(max_slave_count, w1_max_slave_count, int, 0);
+module_param_named(slave_ttl, w1_max_slave_ttl, int, 0);
 
 spinlock_t w1_mlock = SPIN_LOCK_UNLOCKED;
 LIST_HEAD(w1_masters);
@@ -431,6 +433,7 @@
 		return err;
 	}
 
+	sl->ttl = dev->slave_ttl;
 	dev->slave_count++;
 
 	memcpy(&msg.id.id, rn, sizeof(msg.id.id));
@@ -446,8 +449,13 @@
 	
 	dev_info(&sl->dev, "%s: detaching %s.\n", __func__, sl->name);
 
-	while (atomic_read(&sl->refcnt))
-		schedule_timeout(10);
+	while (atomic_read(&sl->refcnt)) {
+		printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n",
+				sl->name, atomic_read(&sl->refcnt));
+
+		if (msleep_interruptible(1000))
+			flush_signals(current);
+	}
 
 	sysfs_remove_bin_file (&sl->dev.kobj, &sl->attr_bin);
 	device_remove_file(&sl->dev, &sl->attr_name);
@@ -504,8 +512,8 @@
 			 * All who don't sleep must send ID bit and COMPLEMENT ID bit.
 			 * They actually are ANDed between all senders.
 			 */
-			id_bit = w1_read_bit(dev);
-			comp_bit = w1_read_bit(dev);
+			id_bit = w1_touch_bit(dev, 1);
+			comp_bit = w1_touch_bit(dev, 1);
 
 			if (id_bit && comp_bit)
 				break;
@@ -536,7 +544,10 @@
 			 * and make all who don't have "search_bit" in "i"'th position
 			 * in it's registration number sleep.
 			 */
-			w1_write_bit(dev, search_bit);
+			if (dev->bus_master->touch_bit)
+				w1_touch_bit(dev, search_bit);
+			else
+				w1_write_bit(dev, search_bit);
 
 		}
 #endif
@@ -569,7 +580,7 @@
 		}
 
 		if (slave_count == dev->slave_count &&
-		    ((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) {
+			rn && ((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) {
 			w1_attach_slave_device(dev, (struct w1_reg_num *) &rn);
 		}
 	}
@@ -718,7 +729,7 @@
 		list_for_each_safe(ent, n, &dev->slist) {
 			sl = list_entry(ent, struct w1_slave, w1_slave_entry);
 
-			if (sl && !test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags)) {
+			if (sl && !test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags) && !--sl->ttl) {
 				list_del (&sl->w1_slave_entry);
 
 				w1_slave_detach (sl);
@@ -726,6 +737,8 @@
 
 				dev->slave_count--;
 			}
+			else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags))
+				sl->ttl = dev->slave_ttl;
 		}
 		up(&dev->mutex);
 	}
diff -Nru a/drivers/w1/w1.h b/drivers/w1/w1.h
--- a/drivers/w1/w1.h	2004-12-24 13:37:43 -08:00
+++ b/drivers/w1/w1.h	2004-12-24 13:37:43 -08:00
@@ -63,6 +63,7 @@
 	atomic_t		refcnt;
 	u8			rom[9];
 	u32			flags;
+	int			ttl;
 
 	struct w1_master	*master;
 	struct w1_family 	*family;
@@ -99,6 +100,7 @@
 	struct list_head	slist;
 	int			max_slave_count, slave_count;
 	unsigned long		attempts;
+	int			slave_ttl;
 	int			initialized;
 	u32			id;
 
diff -Nru a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
--- a/drivers/w1/w1_family.c	2004-12-24 13:37:01 -08:00
+++ b/drivers/w1/w1_family.c	2004-12-24 13:37:01 -08:00
@@ -21,6 +21,7 @@
 
 #include <linux/spinlock.h>
 #include <linux/list.h>
+#include <linux/delay.h>
 
 #include "w1_family.h"
 
@@ -84,8 +85,13 @@
 
 	spin_unlock(&w1_flock);
 
-	while (atomic_read(&fent->refcnt))
-		schedule_timeout(10);
+	while (atomic_read(&fent->refcnt)) {
+		printk(KERN_INFO "Waiting for family %u to become free: refcnt=%d.\n",
+				fent->fid, atomic_read(&fent->refcnt));
+
+		if (msleep_interruptible(1000))
+			flush_signals(current);
+	}
 }
 
 /*
diff -Nru a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
--- a/drivers/w1/w1_int.c	2004-12-24 13:37:19 -08:00
+++ b/drivers/w1/w1_int.c	2004-12-24 13:37:19 -08:00
@@ -21,6 +21,7 @@
 
 #include <linux/kernel.h>
 #include <linux/list.h>
+#include <linux/delay.h>
 
 #include "w1.h"
 #include "w1_log.h"
@@ -32,12 +33,13 @@
 extern struct bus_type w1_bus_type;
 extern struct device w1_device;
 extern int w1_max_slave_count;
+extern int w1_max_slave_ttl;
 extern struct list_head w1_masters;
 extern spinlock_t w1_mlock;
 
 extern int w1_process(void *);
 
-struct w1_master * w1_alloc_dev(u32 id, int slave_count,
+struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
 	      struct device_driver *driver, struct device *device)
 {
 	struct w1_master *dev;
@@ -65,6 +67,7 @@
 	dev->kpid 		= -1;
 	dev->initialized 	= 0;
 	dev->id 		= id;
+	dev->slave_ttl		= slave_ttl;
 
 	atomic_set(&dev->refcnt, 2);
 
@@ -86,17 +89,14 @@
 	dev->seq = 1;
 	dev->nls = netlink_kernel_create(NETLINK_NFLOG, NULL);
 	if (!dev->nls) {
-		printk(KERN_ERR "Failed to create new netlink socket(%u).\n",
-			NETLINK_NFLOG);
-		memset(dev, 0, sizeof(struct w1_master));
-		kfree(dev);
-		dev = NULL;
+		printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
+			NETLINK_NFLOG, dev->dev.bus_id);
 	}
 
 	err = device_register(&dev->dev);
 	if (err) {
 		printk(KERN_ERR "Failed to register master device. err=%d\n", err);
-		if (dev->nls->sk_socket)
+		if (dev->nls && dev->nls->sk_socket)
 			sock_release(dev->nls->sk_socket);
 		memset(dev, 0, sizeof(struct w1_master));
 		kfree(dev);
@@ -109,7 +109,7 @@
 void w1_free_dev(struct w1_master *dev)
 {
 	device_unregister(&dev->dev);
-	if (dev->nls->sk_socket)
+	if (dev->nls && dev->nls->sk_socket)
 		sock_release(dev->nls->sk_socket);
 	memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
 	kfree(dev);
@@ -121,7 +121,7 @@
 	int retval = 0;
 	struct w1_netlink_msg msg;
 
-	dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, &w1_driver, &w1_device);
+	dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_driver, &w1_device);
 	if (!dev)
 		return -ENOMEM;
 
@@ -179,8 +179,13 @@
 			 "%s: Failed to send signal to w1 kernel thread %d.\n",
 			 __func__, dev->kpid);
 
-	while (atomic_read(&dev->refcnt))
-		schedule_timeout(10);
+	while (atomic_read(&dev->refcnt)) {
+		printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n",
+				dev->name, atomic_read(&dev->refcnt));
+
+		if (msleep_interruptible(1000))
+			flush_signals(current);
+	}
 
 	msg.id.mst.id = dev->id;
 	msg.id.mst.pid = dev->kpid;
diff -Nru a/drivers/w1/w1_int.h b/drivers/w1/w1_int.h
--- a/drivers/w1/w1_int.h	2004-12-24 13:36:18 -08:00
+++ b/drivers/w1/w1_int.h	2004-12-24 13:36:18 -08:00
@@ -27,7 +27,7 @@
 
 #include "w1.h"
 
-struct w1_master * w1_alloc_dev(int, struct device_driver *, struct device *);
+struct w1_master * w1_alloc_dev(u32, int, int, struct device_driver *, struct device *);
 void w1_free_dev(struct w1_master *dev);
 int w1_add_master_device(struct w1_bus_master *);
 void w1_remove_master_device(struct w1_bus_master *);
diff -Nru a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
--- a/drivers/w1/w1_netlink.c	2004-12-24 13:36:17 -08:00
+++ b/drivers/w1/w1_netlink.c	2004-12-24 13:36:17 -08:00
@@ -26,6 +26,7 @@
 #include "w1_log.h"
 #include "w1_netlink.h"
 
+#ifndef NETLINK_DISABLED
 void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
 {
 	unsigned int size;
@@ -33,6 +34,9 @@
 	struct w1_netlink_msg *data;
 	struct nlmsghdr *nlh;
 
+	if (!dev->nls)
+		return;
+
 	size = NLMSG_SPACE(sizeof(struct w1_netlink_msg));
 
 	skb = alloc_skb(size, GFP_ATOMIC);
@@ -53,3 +57,10 @@
 nlmsg_failure:
 	return;
 }
+#else
+#warning Netlink support is disabled. Please compile with NET support enabled.
+
+void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
+{
+}
+#endif
diff -Nru a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c
--- a/drivers/w1/w1_therm.c	2004-12-24 13:36:18 -08:00
+++ b/drivers/w1/w1_therm.c	2004-12-24 13:36:18 -08:00
@@ -59,19 +59,28 @@
 	return sprintf(buf, "%s\n", sl->name);
 }
 
+static inline int w1_convert_temp(u8 rom[9])
+{
+	int t, h;
+	
+	if (rom[1] == 0)
+		t = ((s32)rom[0] >> 1)*1000;
+	else
+		t = 1000*(-1*(s32)(0x100-rom[0]) >> 1);
+	
+	t -= 250;
+	h = 1000*((s32)rom[7] - (s32)rom[6]);
+	h /= (s32)rom[7];
+	t += h;
+
+	return t;
+}
+
 static ssize_t w1_therm_read_temp(struct device *dev, char *buf)
 {
 	struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
-	s16 temp;
-
-	/* 
-	 * Must be more precise.
-	 */
-	temp = 0;
-	temp <<= sl->rom[1] / 2;
-	temp |= sl->rom[0] / 2;
 
-	return sprintf(buf, "%d\n", temp * 1000);
+	return sprintf(buf, "%d\n", w1_convert_temp(sl->rom));
 }
 
 static int w1_therm_check_rom(u8 rom[9])
@@ -92,7 +101,6 @@
 	struct w1_master *dev = sl->master;
 	u8 rom[9], crc, verdict;
 	int i, max_trying = 10;
-	u16 temp;
 
 	atomic_inc(&sl->refcnt);
 	if (down_interruptible(&sl->master->mutex)) {
@@ -120,6 +128,7 @@
 		if (!w1_reset_bus (dev)) {
 			int count = 0;
 			u8 match[9] = {W1_MATCH_ROM, };
+			unsigned long tm;
 
 			memcpy(&match[1], (u64 *) & sl->reg_num, 8);
 			
@@ -127,24 +136,29 @@
 
 			w1_write_8(dev, W1_CONVERT_TEMP);
 
-			if (count < 10) {
-				if (!w1_reset_bus(dev)) {
-					w1_write_block(dev, match, 9);
-
-					w1_write_8(dev, W1_READ_SCRATCHPAD);
-					if ((count = w1_read_block(dev, rom, 9)) != 9) {
-						dev_warn(&dev->dev, "w1_read_block() returned %d instead of 9.\n", count);
-					}
+			tm = jiffies + msecs_to_jiffies(750);
+			while(time_before(jiffies, tm)) {
+				set_current_state(TASK_INTERRUPTIBLE);
+				schedule_timeout(tm-jiffies);
 
-					crc = w1_calc_crc8(rom, 8);
+				if (signal_pending(current))
+					flush_signals(current);
+			}
 
-					if (rom[8] == crc && rom[0])
-						verdict = 1;
+			if (!w1_reset_bus (dev)) {
+				w1_write_block(dev, match, 9);
+				
+				w1_write_8(dev, W1_READ_SCRATCHPAD);
+				if ((count = w1_read_block(dev, rom, 9)) != 9) {
+					dev_warn(&dev->dev, "w1_read_block() returned %d instead of 9.\n", count);
 				}
+
+				crc = w1_calc_crc8(rom, 8);
+
+				if (rom[8] == crc && rom[0])
+					verdict = 1;
+
 			}
-			else
-				dev_warn(&dev->dev,
-					  "18S20 doesn't respond to CONVERT_TEMP.\n");
 		}
 
 		if (!w1_therm_check_rom(rom))
@@ -157,12 +171,13 @@
 			   crc, (verdict) ? "YES" : "NO");
 	if (verdict)
 		memcpy(sl->rom, rom, sizeof(sl->rom));
+	else
+		dev_warn(&dev->dev, "18S20 doesn't respond to CONVERT_TEMP.\n");
+
 	for (i = 0; i < 9; ++i)
 		count += sprintf(buf + count, "%02x ", sl->rom[i]);
-	temp = 0;
-	temp <<= sl->rom[1] / 2;
-	temp |= sl->rom[0] / 2;
-	count += sprintf(buf + count, "t=%u\n", temp);
+	
+	count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom));
 out:
 	up(&dev->mutex);
 out_dec:
diff -Nru a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
--- a/drivers/zorro/zorro.c	2004-12-24 13:36:56 -08:00
+++ b/drivers/zorro/zorro.c	2004-12-24 13:36:56 -08:00
@@ -15,8 +15,8 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/zorro.h>
+#include <linux/bitops.h>
 #include <asm/setup.h>
-#include <asm/bitops.h>
 #include <asm/amigahw.h>
 
 #include "zorro.h"
diff -Nru a/fs/Kconfig b/fs/Kconfig
--- a/fs/Kconfig	2004-12-24 13:36:59 -08:00
+++ b/fs/Kconfig	2004-12-24 13:36:59 -08:00
@@ -438,6 +438,17 @@
 	depends on XFS_QUOTA || QUOTA
 	default y
 
+config DNOTIFY
+	bool "Dnotify support" if EMBEDDED
+	default y
+	help
+	  Dnotify is a directory-based per-fd file change notification system
+	  that uses signals to communicate events to user-space.  There exist
+	  superior alternatives, but some applications may still rely on
+	  dnotify.
+
+	  Because of this, if unsure, say Y.
+
 config AUTOFS_FS
 	tristate "Kernel automounter support"
 	help
@@ -808,8 +819,8 @@
 	  programs depend on this, so everyone should say Y here.
 
 config PROC_KCORE
-	bool
-	default y if !ARM
+	bool "/proc/kcore support" if !ARM
+	depends on PROC_FS && MMU
 
 config SYSFS
 	bool "sysfs file system support" if EMBEDDED
@@ -919,6 +930,27 @@
 
 	  See <file:Documentation/filesystems/tmpfs.txt> for details.
 
+config TMPFS_XATTR
+	bool "tmpfs Extended Attributes"
+	depends on TMPFS
+	help
+	  Extended attributes are name:value pairs associated with inodes by
+	  the kernel or by users (see the attr(5) manual page, or visit
+	  <http://acl.bestbits.at/> for details).
+
+	  If unsure, say N.
+
+config TMPFS_SECURITY
+	bool "tmpfs Security Labels"
+	depends on TMPFS_XATTR
+	help
+	  Security labels support alternative access control models
+	  implemented by security modules like SELinux.  This option
+	  enables an extended attribute handler for file security
+	  labels in the tmpfs filesystem.
+	  If you are not using a security module that requires using
+	  extended attributes for file security labels, say N.
+
 config HUGETLBFS
 	bool "HugeTLB file system support"
 	depends X86 || IA64 || PPC64 || SPARC64 || SUPERH || X86_64 || BROKEN
@@ -1686,12 +1718,22 @@
 
 config CIFS_POSIX
         bool "CIFS POSIX Extensions (EXPERIMENTAL)"
-        depends on CIFS
+        depends on CIFS_XATTR
         help
           Enabling this option will cause the cifs client to attempt to
 	  negotiate a newer dialect with servers, such as Samba 3.0.5
 	  or later, that optionally can handle more POSIX like (rather
-	  than Windows like) file behavior.  If unsure, say N.
+	  than Windows like) file behavior.  It also enables
+	  support for POSIX ACLs (getfacl and setfacl) to servers
+	  (such as Samba 3.10 and later) which can negotiate
+	  CIFS POSIX ACL support.  If unsure, say N.
+
+config CIFS_EXPERIMENTAL
+	  bool "CIFS Experimental Features (EXPERIMENTAL)"
+	  depends on CIFS
+	  help
+	    Enables cifs features under testing. These features
+	    are highly experimental.  If unsure, say N.
 
 config NCP_FS
 	tristate "NCP file system support (to mount NetWare volumes)"
diff -Nru a/fs/Makefile b/fs/Makefile
--- a/fs/Makefile	2004-12-24 13:36:59 -08:00
+++ b/fs/Makefile	2004-12-24 13:36:59 -08:00
@@ -5,12 +5,11 @@
 # Rewritten to use lists instead of if-statements.
 # 
 
-obj-y :=	open.o read_write.o file_table.o buffer.o \
-		bio.o super.o block_dev.o char_dev.o stat.o exec.o pipe.o \
-		namei.o fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \
-		dcache.o inode.o attr.o bad_inode.o file.o dnotify.o \
-		filesystems.o namespace.o seq_file.o xattr.o libfs.o \
-		fs-writeback.o mpage.o direct-io.o aio.o
+obj-y :=	open.o read_write.o file_table.o buffer.o  bio.o super.o \
+		block_dev.o char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
+		ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
+		attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \
+		seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \
 
 obj-$(CONFIG_EPOLL)		+= eventpoll.o
 obj-$(CONFIG_COMPAT)		+= compat.o
@@ -36,6 +35,8 @@
 obj-$(CONFIG_QFMT_V1)		+= quota_v1.o
 obj-$(CONFIG_QFMT_V2)		+= quota_v2.o
 obj-$(CONFIG_QUOTACTL)		+= quota.o
+
+obj-$(CONFIG_DNOTIFY)		+= dnotify.o
 
 obj-$(CONFIG_PROC_FS)		+= proc/
 obj-y				+= partitions/
diff -Nru a/fs/adfs/super.c b/fs/adfs/super.c
--- a/fs/adfs/super.c	2004-12-24 13:36:16 -08:00
+++ b/fs/adfs/super.c	2004-12-24 13:36:16 -08:00
@@ -19,8 +19,8 @@
 #include <linux/buffer_head.h>
 #include <linux/vfs.h>
 #include <linux/parser.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
diff -Nru a/fs/afs/main.c b/fs/afs/main.c
--- a/fs/afs/main.c	2004-12-24 13:36:31 -08:00
+++ b/fs/afs/main.c	2004-12-24 13:36:31 -08:00
@@ -100,7 +100,7 @@
 		goto error;
 #endif
 
-#ifdef CONFIG_KEYS
+#ifdef CONFIG_KEYS_TURNED_OFF
 	ret = afs_key_register();
 	if (ret < 0)
 		goto error_cache;
@@ -142,7 +142,7 @@
  error_kafstimod:
 	afs_kafstimod_stop();
  error_keys:
-#ifdef CONFIG_KEYS
+#ifdef CONFIG_KEYS_TURNED_OFF
 	afs_key_unregister();
  error_cache:
 #endif
@@ -169,7 +169,7 @@
 	afs_kafstimod_stop();
 	afs_kafsasyncd_stop();
 	afs_cell_purge();
-#ifdef CONFIG_KEYS
+#ifdef CONFIG_KEYS_TURNED_OFF
 	afs_key_unregister();
 #endif
 #ifdef AFS_CACHING_SUPPORT
diff -Nru a/fs/aio.c b/fs/aio.c
--- a/fs/aio.c	2004-12-24 13:36:48 -08:00
+++ b/fs/aio.c	2004-12-24 13:36:48 -08:00
@@ -14,6 +14,7 @@
 #include <linux/time.h>
 #include <linux/aio_abi.h>
 #include <linux/module.h>
+#include <linux/syscalls.h>
 
 #define DEBUG 0
 
@@ -117,8 +118,6 @@
 	if (nr_pages < 0)
 		return -EINVAL;
 
-	info->nr_pages = nr_pages;
-
 	nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
 
 	info->nr = 0;
@@ -571,6 +570,7 @@
 	struct task_struct *tsk = current;
 
 	task_lock(tsk);
+	tsk->flags |= PF_BORROWED_MM;
 	active_mm = tsk->active_mm;
 	atomic_inc(&mm->mm_count);
 	tsk->mm = mm;
@@ -597,6 +597,7 @@
 	struct task_struct *tsk = current;
 
 	task_lock(tsk);
+	tsk->flags &= ~PF_BORROWED_MM;
 	tsk->mm = NULL;
 	/* active_mm is still 'mm' */
 	enter_lazy_tlb(mm, tsk);
diff -Nru a/fs/autofs/inode.c b/fs/autofs/inode.c
--- a/fs/autofs/inode.c	2004-12-24 13:37:04 -08:00
+++ b/fs/autofs/inode.c	2004-12-24 13:37:04 -08:00
@@ -15,7 +15,7 @@
 #include <linux/slab.h>
 #include <linux/file.h>
 #include <linux/parser.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include "autofs_i.h"
 #include <linux/module.h>
 
diff -Nru a/fs/autofs4/inode.c b/fs/autofs4/inode.c
--- a/fs/autofs4/inode.c	2004-12-24 13:37:04 -08:00
+++ b/fs/autofs4/inode.c	2004-12-24 13:37:04 -08:00
@@ -15,7 +15,7 @@
 #include <linux/file.h>
 #include <linux/pagemap.h>
 #include <linux/parser.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include "autofs_i.h"
 #include <linux/module.h>
 
diff -Nru a/fs/autofs4/root.c b/fs/autofs4/root.c
--- a/fs/autofs4/root.c	2004-12-24 13:36:17 -08:00
+++ b/fs/autofs4/root.c	2004-12-24 13:36:17 -08:00
@@ -19,7 +19,6 @@
 #include <linux/smp_lock.h>
 #include "autofs_i.h"
 
-static struct dentry *autofs4_dir_lookup(struct inode *,struct dentry *, struct nameidata *);
 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
 static int autofs4_dir_unlink(struct inode *,struct dentry *);
 static int autofs4_dir_rmdir(struct inode *,struct dentry *);
@@ -29,7 +28,7 @@
 static int autofs4_dir_close(struct inode *inode, struct file *file);
 static int autofs4_dir_readdir(struct file * filp, void * dirent, filldir_t filldir);
 static int autofs4_root_readdir(struct file * filp, void * dirent, filldir_t filldir);
-static struct dentry *autofs4_root_lookup(struct inode *,struct dentry *, struct nameidata *);
+static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *);
 static int autofs4_dcache_readdir(struct file *, void *, filldir_t);
 
 struct file_operations autofs4_root_operations = {
@@ -48,7 +47,7 @@
 };
 
 struct inode_operations autofs4_root_inode_operations = {
-	.lookup		= autofs4_root_lookup,
+	.lookup		= autofs4_lookup,
 	.unlink		= autofs4_dir_unlink,
 	.symlink	= autofs4_dir_symlink,
 	.mkdir		= autofs4_dir_mkdir,
@@ -56,7 +55,7 @@
 };
 
 struct inode_operations autofs4_dir_inode_operations = {
-	.lookup		= autofs4_dir_lookup,
+	.lookup		= autofs4_lookup,
 	.unlink		= autofs4_dir_unlink,
 	.symlink	= autofs4_dir_symlink,
 	.mkdir		= autofs4_dir_mkdir,
@@ -439,23 +438,8 @@
 	.d_release	= autofs4_dentry_release,
 };
 
-/* Lookups in non-root dirs never find anything - if it's there, it's
-   already in the dcache */
-static struct dentry *autofs4_dir_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
-{
-#if 0
-	DPRINTK("ignoring lookup of %.*s/%.*s",
-		 dentry->d_parent->d_name.len, dentry->d_parent->d_name.name,
-		 dentry->d_name.len, dentry->d_name.name);
-#endif
-
-	dentry->d_fsdata = NULL;
-	d_add(dentry, NULL);
-	return NULL;
-}
-
 /* Lookups in the root directory */
-static struct dentry *autofs4_root_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
+static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
 {
 	struct autofs_sb_info *sbi;
 	int oz_mode;
diff -Nru a/fs/binfmt_aout.c b/fs/binfmt_aout.c
--- a/fs/binfmt_aout.c	2004-12-24 13:36:30 -08:00
+++ b/fs/binfmt_aout.c	2004-12-24 13:36:30 -08:00
@@ -43,13 +43,18 @@
 	.min_coredump	= PAGE_SIZE
 };
 
-static void set_brk(unsigned long start, unsigned long end)
+#define BAD_ADDR(x)	((unsigned long)(x) >= TASK_SIZE)
+
+static int set_brk(unsigned long start, unsigned long end)
 {
 	start = PAGE_ALIGN(start);
 	end = PAGE_ALIGN(end);
-	if (end <= start)
-		return;
-	do_brk(start, end - start);
+	if (end > start) {
+		unsigned long addr = do_brk(start, end - start);
+		if (BAD_ADDR(addr))
+			return addr;
+	}
+	return 0;
 }
 
 /*
@@ -118,22 +123,22 @@
    if we wrote the stack, but not the data area.  */
 #ifdef __sparc__
 	if ((dump.u_dsize+dump.u_ssize) >
-	    current->rlim[RLIMIT_CORE].rlim_cur)
+	    current->signal->rlim[RLIMIT_CORE].rlim_cur)
 		dump.u_dsize = 0;
 #else
 	if ((dump.u_dsize+dump.u_ssize+1) * PAGE_SIZE >
-	    current->rlim[RLIMIT_CORE].rlim_cur)
+	    current->signal->rlim[RLIMIT_CORE].rlim_cur)
 		dump.u_dsize = 0;
 #endif
 
 /* Make sure we have enough room to write the stack and data areas. */
 #ifdef __sparc__
 	if ((dump.u_ssize) >
-	    current->rlim[RLIMIT_CORE].rlim_cur)
+	    current->signal->rlim[RLIMIT_CORE].rlim_cur)
 		dump.u_ssize = 0;
 #else
 	if ((dump.u_ssize+1) * PAGE_SIZE >
-	    current->rlim[RLIMIT_CORE].rlim_cur)
+	    current->signal->rlim[RLIMIT_CORE].rlim_cur)
 		dump.u_ssize = 0;
 #endif
 
@@ -278,7 +283,7 @@
 	 * size limits imposed on them by creating programs with large
 	 * arrays in the data or bss.
 	 */
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim >= RLIM_INFINITY)
 		rlim = ~0;
 	if (ex.a_data + ex.a_bss > rlim)
@@ -413,7 +418,11 @@
 beyond_if:
 	set_binfmt(&aout_format);
 
-	set_brk(current->mm->start_brk, current->mm->brk);
+	retval = set_brk(current->mm->start_brk, current->mm->brk);
+	if (retval < 0) {
+		send_sig(SIGKILL, current, 0);
+		return retval;
+	}
 
 	retval = setup_arg_pages(bprm, EXSTACK_DEFAULT);
 	if (retval < 0) { 
diff -Nru a/fs/binfmt_elf.c b/fs/binfmt_elf.c
--- a/fs/binfmt_elf.c	2004-12-24 13:36:48 -08:00
+++ b/fs/binfmt_elf.c	2004-12-24 13:36:48 -08:00
@@ -335,9 +335,12 @@
 		goto out;
 
 	retval = kernel_read(interpreter,interp_elf_ex->e_phoff,(char *)elf_phdata,size);
-	error = retval;
-	if (retval < 0)
+	error = -EIO;
+	if (retval != size) {
+		if (retval < 0)
+			error = retval;	
 		goto out_close;
+	}
 
 	eppnt = elf_phdata;
 	for (i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) {
@@ -532,8 +535,11 @@
 		goto out;
 
 	retval = kernel_read(bprm->file, loc->elf_ex.e_phoff, (char *) elf_phdata, size);
-	if (retval < 0)
+	if (retval != size) {
+		if (retval >= 0)
+			retval = -EIO;
 		goto out_free_ph;
+	}
 
 	files = current->files;		/* Refcounted so ok */
 	retval = unshare_files();
@@ -570,7 +576,8 @@
 			 */
 
 			retval = -ENOMEM;
-			if (elf_ppnt->p_filesz > PATH_MAX)
+			if (elf_ppnt->p_filesz > PATH_MAX || 
+			    elf_ppnt->p_filesz == 0)
 				goto out_free_file;
 			elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz,
 							   GFP_KERNEL);
@@ -580,8 +587,16 @@
 			retval = kernel_read(bprm->file, elf_ppnt->p_offset,
 					   elf_interpreter,
 					   elf_ppnt->p_filesz);
-			if (retval < 0)
+			if (retval != elf_ppnt->p_filesz) {
+				if (retval >= 0)
+					retval = -EIO;
 				goto out_free_interp;
+			}
+			/* make sure path is NULL terminated */
+			retval = -EINVAL;
+			if (elf_interpreter[elf_ppnt->p_filesz - 1] != '\0')
+				goto out_free_interp;
+
 			/* If the program interpreter is one of these two,
 			 * then assume an iBCS2 image. Otherwise assume
 			 * a native linux image.
@@ -616,8 +631,11 @@
 			if (IS_ERR(interpreter))
 				goto out_free_interp;
 			retval = kernel_read(interpreter, 0, bprm->buf, BINPRM_BUF_SIZE);
-			if (retval < 0)
+			if (retval != BINPRM_BUF_SIZE) {
+				if (retval >= 0)
+					retval = -EIO;
 				goto out_free_dentry;
+			}
 
 			/* Get the exec headers */
 			loc->interp_ex = *((struct exec *) bprm->buf);
@@ -776,8 +794,10 @@
 		}
 
 		error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, elf_prot, elf_flags);
-		if (BAD_ADDR(error))
-			continue;
+		if (BAD_ADDR(error)) {
+			send_sig(SIGKILL, current, 0);
+			goto out_free_dentry;
+		}
 
 		if (!load_addr_set) {
 			load_addr_set = 1;
@@ -1054,22 +1074,14 @@
  */
 static int maydump(struct vm_area_struct *vma)
 {
-	/*
-	 * If we may not read the contents, don't allow us to dump
-	 * them either. "dump_write()" can't handle it anyway.
-	 */
-	if (!(vma->vm_flags & VM_READ))
+	/* Do not dump I/O mapped devices, shared memory, or special mappings */
+	if (vma->vm_flags & (VM_IO | VM_SHARED | VM_RESERVED))
 		return 0;
 
-	/* Do not dump I/O mapped devices! -DaveM */
-	if (vma->vm_flags & VM_IO)
-		return 0;
-#if 1
-	if (vma->vm_flags & (VM_WRITE|VM_GROWSUP|VM_GROWSDOWN))
-		return 1;
-	if (vma->vm_flags & (VM_READ|VM_EXEC|VM_EXECUTABLE|VM_SHARED))
+	/* If it hasn't been written to, don't write it out */
+	if (!vma->anon_vma)
 		return 0;
-#endif
+
 	return 1;
 }
 
@@ -1314,7 +1326,7 @@
 	struct vm_area_struct *vma;
 	struct elfhdr *elf = NULL;
 	off_t offset = 0, dataoff;
-	unsigned long limit = current->rlim[RLIMIT_CORE].rlim_cur;
+	unsigned long limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
 	int numnote;
 	struct memelfnote *notes = NULL;
 	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
diff -Nru a/fs/binfmt_flat.c b/fs/binfmt_flat.c
--- a/fs/binfmt_flat.c	2004-12-24 13:36:16 -08:00
+++ b/fs/binfmt_flat.c	2004-12-24 13:36:16 -08:00
@@ -486,7 +486,7 @@
 	 * size limits imposed on them by creating programs with large
 	 * arrays in the data or bss.
 	 */
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim >= RLIM_INFINITY)
 		rlim = ~0;
 	if (data_len + bss_len > rlim)
diff -Nru a/fs/bio.c b/fs/bio.c
--- a/fs/bio.c	2004-12-24 13:37:00 -08:00
+++ b/fs/bio.c	2004-12-24 13:37:00 -08:00
@@ -461,11 +461,10 @@
 
 	bmd->userptr = (void __user *) uaddr;
 
+	ret = -ENOMEM;
 	bio = bio_alloc(GFP_KERNEL, end - start);
-	if (!bio) {
-		bio_free_map_data(bmd);
-		return ERR_PTR(-ENOMEM);
-	}
+	if (!bio)
+		goto out_bmd;
 
 	bio->bi_rw |= (!write_to_vm << BIO_RW);
 
@@ -519,6 +518,8 @@
 		__free_page(bvec->bv_page);
 
 	bio_put(bio);
+out_bmd:
+	bio_free_map_data(bmd);
 	return ERR_PTR(ret);
 }
 
diff -Nru a/fs/block_dev.c b/fs/block_dev.c
--- a/fs/block_dev.c	2004-12-24 13:37:43 -08:00
+++ b/fs/block_dev.c	2004-12-24 13:37:43 -08:00
@@ -137,13 +137,26 @@
 blkdev_get_blocks(struct inode *inode, sector_t iblock,
 		unsigned long max_blocks, struct buffer_head *bh, int create)
 {
-	if ((iblock + max_blocks) > max_block(I_BDEV(inode)))
-		return -EIO;
+	sector_t end_block = max_block(I_BDEV(inode));
+
+	if ((iblock + max_blocks) > end_block) {
+		max_blocks = end_block - iblock;
+		if ((long)max_blocks <= 0) {
+			if (create)
+				return -EIO;	/* write fully beyond EOF */
+			/*
+			 * It is a read which is fully beyond EOF.  We return
+			 * a !buffer_mapped buffer
+			 */
+			max_blocks = 0;
+		}
+	}
 
 	bh->b_bdev = I_BDEV(inode);
 	bh->b_blocknr = iblock;
 	bh->b_size = max_blocks << inode->i_blkbits;
-	set_buffer_mapped(bh);
+	if (max_blocks)
+		set_buffer_mapped(bh);
 	return 0;
 }
 
@@ -666,7 +679,7 @@
 
 EXPORT_SYMBOL(blkdev_get);
 
-int blkdev_open(struct inode * inode, struct file * filp)
+static int blkdev_open(struct inode * inode, struct file * filp)
 {
 	struct block_device *bdev;
 	int res;
@@ -695,8 +708,6 @@
 	return res;
 }
 
-EXPORT_SYMBOL(blkdev_open);
-
 int blkdev_put(struct block_device *bdev)
 {
 	int ret = 0;
@@ -797,8 +808,6 @@
 	.writev		= generic_file_write_nolock,
 	.sendfile	= generic_file_sendfile,
 };
-
-EXPORT_SYMBOL(def_blk_fops);
 
 int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg)
 {
diff -Nru a/fs/buffer.c b/fs/buffer.c
--- a/fs/buffer.c	2004-12-24 13:36:59 -08:00
+++ b/fs/buffer.c	2004-12-24 13:36:59 -08:00
@@ -20,6 +20,7 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
+#include <linux/syscalls.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/percpu.h>
@@ -37,41 +38,13 @@
 #include <linux/bio.h>
 #include <linux/notifier.h>
 #include <linux/cpu.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
 static void invalidate_bh_lrus(void);
 
 #define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers)
 
-struct bh_wait_queue {
-	struct buffer_head *bh;
-	wait_queue_t wait;
-};
-
-#define __DEFINE_BH_WAIT(name, b, f)					\
-	struct bh_wait_queue name = {					\
-		.bh	= b,						\
-		.wait	= {						\
-				.task	= current,			\
-				.flags	= f,				\
-				.func	= bh_wake_function,		\
-				.task_list =				\
-					LIST_HEAD_INIT(name.wait.task_list),\
-			},						\
-	}
-#define DEFINE_BH_WAIT(name, bh)	__DEFINE_BH_WAIT(name, bh, 0)
-#define DEFINE_BH_WAIT_EXCLUSIVE(name, bh) \
-		__DEFINE_BH_WAIT(name, bh, WQ_FLAG_EXCLUSIVE)
-
-/*
- * Hashed waitqueue_head's for wait_on_buffer()
- */
-#define BH_WAIT_TABLE_ORDER	7
-static struct bh_wait_queue_head {
-	wait_queue_head_t wqh;
-} ____cacheline_aligned_in_smp bh_wait_queue_heads[1<<BH_WAIT_TABLE_ORDER];
-
 inline void
 init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *private)
 {
@@ -79,63 +52,24 @@
 	bh->b_private = private;
 }
 
-/*
- * Return the address of the waitqueue_head to be used for this
- * buffer_head
- */
-wait_queue_head_t *bh_waitq_head(struct buffer_head *bh)
-{
-	return &bh_wait_queue_heads[hash_ptr(bh, BH_WAIT_TABLE_ORDER)].wqh;
-}
-EXPORT_SYMBOL(bh_waitq_head);
-
-void wake_up_buffer(struct buffer_head *bh)
-{
-	wait_queue_head_t *wq = bh_waitq_head(bh);
-
-	smp_mb();
-	if (waitqueue_active(wq))
-		__wake_up(wq, TASK_INTERRUPTIBLE|TASK_UNINTERRUPTIBLE, 1, bh);
-}
-EXPORT_SYMBOL(wake_up_buffer);
-
-static int bh_wake_function(wait_queue_t *wait, unsigned mode,
-				int sync, void *key)
-{
-	struct buffer_head *bh = key;
-	struct bh_wait_queue *wq;
-
-	wq = container_of(wait, struct bh_wait_queue, wait);
-	if (wq->bh != bh || buffer_locked(bh))
-		return 0;
-	else
-		return autoremove_wake_function(wait, mode, sync, key);
-}
-
-static void sync_buffer(struct buffer_head *bh)
+static int sync_buffer(void *word)
 {
 	struct block_device *bd;
+	struct buffer_head *bh
+		= container_of(word, struct buffer_head, b_state);
 
 	smp_mb();
 	bd = bh->b_bdev;
 	if (bd)
 		blk_run_address_space(bd->bd_inode->i_mapping);
+	io_schedule();
+	return 0;
 }
 
 void fastcall __lock_buffer(struct buffer_head *bh)
 {
-	wait_queue_head_t *wqh = bh_waitq_head(bh);
-	DEFINE_BH_WAIT_EXCLUSIVE(wait, bh);
-
-	do {
-		prepare_to_wait_exclusive(wqh, &wait.wait,
-					TASK_UNINTERRUPTIBLE);
-		if (buffer_locked(bh)) {
-			sync_buffer(bh);
-			io_schedule();
-		}
-	} while (test_set_buffer_locked(bh));
-	finish_wait(wqh, &wait.wait);
+	wait_on_bit_lock(&bh->b_state, BH_Lock, sync_buffer,
+							TASK_UNINTERRUPTIBLE);
 }
 EXPORT_SYMBOL(__lock_buffer);
 
@@ -143,7 +77,7 @@
 {
 	clear_buffer_locked(bh);
 	smp_mb__after_clear_bit();
-	wake_up_buffer(bh);
+	wake_up_bit(&bh->b_state, BH_Lock);
 }
 
 /*
@@ -153,25 +87,7 @@
  */
 void __wait_on_buffer(struct buffer_head * bh)
 {
-	wait_queue_head_t *wqh = bh_waitq_head(bh);
-	DEFINE_BH_WAIT(wait, bh);
-
-	do {
-		prepare_to_wait(wqh, &wait.wait, TASK_UNINTERRUPTIBLE);
-		if (buffer_locked(bh)) {
-			sync_buffer(bh);
-			io_schedule();
-		}
-	} while (buffer_locked(bh));
-	finish_wait(wqh, &wait.wait);
-}
-
-static void
-__set_page_buffers(struct page *page, struct buffer_head *head)
-{
-	page_cache_get(page);
-	SetPagePrivate(page);
-	page->private = (unsigned long)head;
+	wait_on_bit(&bh->b_state, BH_Lock, sync_buffer, TASK_UNINTERRUPTIBLE);
 }
 
 static void
@@ -1089,8 +1005,8 @@
  * The retry flag is used to differentiate async IO (paging, swapping)
  * which may not fail from ordinary buffer allocations.
  */
-static struct buffer_head *
-create_buffers(struct page * page, unsigned long size, int retry)
+struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
+		int retry)
 {
 	struct buffer_head *bh, *head;
 	long offset;
@@ -1148,6 +1064,7 @@
 	free_more_memory();
 	goto try_again;
 }
+EXPORT_SYMBOL_GPL(alloc_page_buffers);
 
 static inline void
 link_dev_buffers(struct page *page, struct buffer_head *head)
@@ -1160,7 +1077,7 @@
 		bh = bh->b_this_page;
 	} while (bh);
 	tail->b_this_page = head;
-	__set_page_buffers(page, head);
+	attach_page_buffers(page, head);
 }
 
 /*
@@ -1221,7 +1138,7 @@
 	/*
 	 * Allocate some buffers for this page
 	 */
-	bh = create_buffers(page, size, 0);
+	bh = alloc_page_buffers(page, size, 0);
 	if (!bh)
 		goto failed;
 
@@ -1727,7 +1644,7 @@
 {
 	struct buffer_head *bh, *head, *tail;
 
-	head = create_buffers(page, blocksize, 1);
+	head = alloc_page_buffers(page, blocksize, 1);
 	bh = head;
 	do {
 		bh->b_state |= b_state;
@@ -1747,7 +1664,7 @@
 			bh = bh->b_this_page;
 		} while (bh != head);
 	}
-	__set_page_buffers(page, head);
+	attach_page_buffers(page, head);
 	spin_unlock(&page->mapping->private_lock);
 }
 EXPORT_SYMBOL(create_empty_buffers);
@@ -2232,7 +2149,7 @@
 	int err;
 
 	err = -EFBIG;
-        limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+        limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
 	if (limit != RLIM_INFINITY && size > (loff_t)limit) {
 		send_sig(SIGXFSZ, current, 0);
 		goto out;
@@ -2307,8 +2224,7 @@
 		memset(kaddr+zerofrom, 0, PAGE_CACHE_SIZE-zerofrom);
 		flush_dcache_page(new_page);
 		kunmap_atomic(kaddr, KM_USER0);
-		__block_commit_write(inode, new_page,
-				zerofrom, PAGE_CACHE_SIZE);
+		generic_commit_write(NULL, new_page, zerofrom, PAGE_CACHE_SIZE);
 		unlock_page(new_page);
 		page_cache_release(new_page);
 	}
@@ -3122,14 +3038,11 @@
 
 void __init buffer_init(void)
 {
-	int i;
 	int nrpages;
 
 	bh_cachep = kmem_cache_create("buffer_head",
 			sizeof(struct buffer_head), 0,
 			SLAB_PANIC, init_buffer_head, NULL);
-	for (i = 0; i < ARRAY_SIZE(bh_wait_queue_heads); i++)
-		init_waitqueue_head(&bh_wait_queue_heads[i].wqh);
 
 	/*
 	 * Limit the bh occupancy to 10% of ZONE_NORMAL
diff -Nru a/fs/char_dev.c b/fs/char_dev.c
--- a/fs/char_dev.c	2004-12-24 13:36:35 -08:00
+++ b/fs/char_dev.c	2004-12-24 13:36:35 -08:00
@@ -153,7 +153,7 @@
 	return cd;
 }
 
-int register_chrdev_region(dev_t from, unsigned count, char *name)
+int register_chrdev_region(dev_t from, unsigned count, const char *name)
 {
 	struct char_device_struct *cd;
 	dev_t to = from + count;
@@ -178,7 +178,8 @@
 	return PTR_ERR(cd);
 }
 
-int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, char *name)
+int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count,
+			const char *name)
 {
 	struct char_device_struct *cd;
 	cd = __register_chrdev_region(0, baseminor, count, name);
@@ -206,8 +207,8 @@
 
 	cdev->owner = fops->owner;
 	cdev->ops = fops;
-	strcpy(cdev->kobj.name, name);
-	for (s = strchr(cdev->kobj.name, '/'); s; s = strchr(s, '/'))
+	kobject_set_name(&cdev->kobj, "%s", name);
+	for (s = strchr(kobject_name(&cdev->kobj),'/'); s; s = strchr(s, '/'))
 		*s = '!';
 		
 	err = cdev_add(cdev, MKDEV(cd->major, 0), 256);
@@ -248,6 +249,28 @@
 }
 
 static spinlock_t cdev_lock = SPIN_LOCK_UNLOCKED;
+
+static struct kobject *cdev_get(struct cdev *p)
+{
+	struct module *owner = p->owner;
+	struct kobject *kobj;
+
+	if (owner && !try_module_get(owner))
+		return NULL;
+	kobj = kobject_get(&p->kobj);
+	if (!kobj)
+		module_put(owner);
+	return kobj;
+}
+
+void cdev_put(struct cdev *p)
+{
+	if (p) {
+		kobject_put(&p->kobj);
+		module_put(p->owner);
+	}
+}
+
 /*
  * Called every time a character special file is opened
  */
@@ -356,26 +379,6 @@
 	kobject_put(&p->kobj);
 }
 
-struct kobject *cdev_get(struct cdev *p)
-{
-	struct module *owner = p->owner;
-	struct kobject *kobj;
-
-	if (owner && !try_module_get(owner))
-		return NULL;
-	kobj = kobject_get(&p->kobj);
-	if (!kobj)
-		module_put(owner);
-	return kobj;
-}
-
-void cdev_put(struct cdev *p)
-{
-	if (p) {
-		kobject_put(&p->kobj);
-		module_put(p->owner);
-	}
-}
 
 static decl_subsys(cdev, NULL, NULL);
 
@@ -414,6 +417,7 @@
 
 void cdev_init(struct cdev *cdev, struct file_operations *fops)
 {
+	memset(cdev, 0, sizeof *cdev);
 	INIT_LIST_HEAD(&cdev->list);
 	cdev->kobj.ktype = &ktype_cdev_default;
 	kobject_init(&cdev->kobj);
@@ -446,8 +450,6 @@
 EXPORT_SYMBOL(alloc_chrdev_region);
 EXPORT_SYMBOL(cdev_init);
 EXPORT_SYMBOL(cdev_alloc);
-EXPORT_SYMBOL(cdev_get);
-EXPORT_SYMBOL(cdev_put);
 EXPORT_SYMBOL(cdev_del);
 EXPORT_SYMBOL(cdev_add);
 EXPORT_SYMBOL(register_chrdev);
diff -Nru a/fs/cifs/CHANGES b/fs/cifs/CHANGES
--- a/fs/cifs/CHANGES	2004-12-24 13:37:19 -08:00
+++ b/fs/cifs/CHANGES	2004-12-24 13:37:19 -08:00
@@ -1,3 +1,53 @@
+Version 1.28
+------------
+Add module init parm for large SMB buffer size (to allow it to be changed
+from its default of 16K) which is especially useful for large file copy
+when mounting with the directio mount option. Fix oops after 
+returning from mount when experimental ExtendedSecurity enabled and
+SpnegoNegotiated returning invalid error. Fix case to retry better when 
+peek returns from 1 to 3 bytes on socket which should have more data.
+Fixed path based calls (such as cifs lookup) to handle path names
+longer than 530 (now can handle PATH_MAX).
+
+Version 1.27
+------------
+Turn off DNOTIFY (directory change notification support) by default
+(unless built with the experimental flag) to fix hang with KDE
+file browser. Fix DNOTIFY flag mappings.  Fix hang (in wait_event
+waiting on an SMB response) in SendReceive when session dies but
+reconnects quickly from another task.  Add module init  parms for
+minimum number of large and small network buffers in the buffer pools,
+and for the maximum number of simultaneous requests.
+
+Version 1.26
+------------
+Add setfacl support to allow setting of ACLs remotely to Samba 3.10 and later
+and other POSIX CIFS compliant servers.  Fix error mapping for getfacl 
+to EOPNOTSUPP when server does not support posix acls on the wire. Fix 
+improperly zeroed buffer in CIFS Unix extensions set times call. 
+
+Version 1.25
+------------
+Fix internationlization problem in cifs readdir with filenames that map to 
+longer UTF8 strings than the string on the wire was in Unicode.  Add workaround
+for readdir to netapp servers. Fix search rewind (seek into readdir to return 
+non-consecutive entries).  Do not do readdir when server negotiates 
+buffer size to small to fit filename. Add support for reading POSIX ACLs from
+the server (add also acl and noacl mount options).
+
+Version 1.24
+------------
+Optionally allow using server side inode numbers, rather than client generated
+ones by specifying mount option "serverino" - this is required for some apps
+to work which double check hardlinked files and have persistent inode numbers.
+
+Version 1.23
+------------
+Multiple bigendian fixes. On little endian systems (for reconnect after
+network failure) fix tcp session reconnect code so we do not try first
+to reconnect on reverse of port 445. Treat reparse points (NTFS junctions)
+as directories rather than symlinks because we can do follow link on them.
+
 Version 1.22
 ------------
 Add config option to enable XATTR (extended attribute) support, mapping
@@ -7,8 +57,8 @@
 
 Version 1.21
 ------------
-Add new mount parm to control whether mode check (vfs_permission) is done on
-the client.  If Unix extensions are enabled and the uids on the client
+Add new mount parm to control whether mode check (generic_permission) is done
+on the client.  If Unix extensions are enabled and the uids on the client
 and server do not match, client permission checks are meaningless on
 server uids that do not exist on the client (this does not affect the
 normal ACL check which occurs on the server).  Fix default uid
diff -Nru a/fs/cifs/Makefile b/fs/cifs/Makefile
--- a/fs/cifs/Makefile	2004-12-24 13:36:31 -08:00
+++ b/fs/cifs/Makefile	2004-12-24 13:36:31 -08:00
@@ -3,4 +3,4 @@
 #
 obj-$(CONFIG_CIFS) += cifs.o
 
-cifs-objs := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o
+cifs-objs := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o
diff -Nru a/fs/cifs/README b/fs/cifs/README
--- a/fs/cifs/README	2004-12-24 13:37:29 -08:00
+++ b/fs/cifs/README	2004-12-24 13:37:29 -08:00
@@ -64,6 +64,13 @@
 
 	gcc samba/source/client/mount.cifs.c -o mount.cifs
 
+If cifs is built as a module, then the size and number of network buffers
+and maximum number of simultaneous requests to one server can be configured.
+Changing these from their defaults is not recommended. By executing modinfo
+	modinfo kernel/fs/cifs/cifs.ko
+on kernel/fs/cifs/cifs.ko the list of configuration changes that can be made
+at module initialization time (by running insmod cifs.ko) can be seen.
+
 Allowing User Mounts
 ====================
 To permit users to mount and unmount over directories they own is possible
@@ -115,11 +122,20 @@
 3.0.6 and later (also EA support works in all versions of Windows, at least to
 shares on NTFS filesystems).  Extended Attribute (xattr) support is an optional
 feature of most Linux filesystems which may require enabling via
-make menuconfig
+make menuconfig.
+
+The CIFS client can get and set POSIX ACLs (getfacl, setfacl) to Samba servers
+version 3.10 and later.  Setting POSIX ACLs requires enabling both XATTR and 
+then POSIX support in the CIFS configuration options when building the cifs
+module.
  
 Some administrators may want to change Samba's smb.conf "map archive" and 
-"create mask" parameters from the default.  Creating special devices (mknod) 
-remotely may require specifying a mkdev function to Samba if you are not using 
+"create mask" parameters from the default.  Unless the create mask is changed
+newly created files can end up with an unnecessarily restrictive default mode,
+which may not be what you want, although if the CIFS Unix extensions are
+enabled on the server and client, subsequent setattr calls (e.g. chmod) can
+fix the mode.  Note that creating special devices (mknod) remotely 
+may require specifying a mkdev function to Samba if you are not using 
 Samba 3.0.6 or later.  For more information on these see the manual pages
 ("man smb.conf") on the Samba server system.  Note that the cifs vfs,
 unlike the smbfs vfs, does not read the smb.conf on the client system 
@@ -191,7 +207,20 @@
 by Samba and Windows NT version 4, 2000 and XP and many other SMB/CIFS servers) 
 Servers must support either "pure-TCP" (port 445 TCP/IP CIFS connections) or RFC 
 1001/1002 support for "Netbios-Over-TCP/IP." Neither of these is likely to be a 
-problem as most servers support this.  IPv6 support is planned for the future.  
+problem as most servers support this.  IPv6 support is planned for the future,
+and is almost complete.
+
+Valid filenames differ between Windows and Linux.  Windows typically restricts
+filenames which contain certain reserved characters (e.g.the character : 
+which is used to delimit the beginning of a stream name by Windows), while
+Linux allows a slightly wider set of valid characters in filenames. Windows
+servers can remap such characters when an explicit mapping is specified in
+the Server's registry.  Samba starting with version 3.10 will allow such 
+filenames (ie those which contain valid Linux characters, which normally
+would be forbidden for Windows/CIFS semantics) as long as the server is
+configured for Unix Extensions (and the client has not disabled
+/proc/fs/cifs/LinuxExtensionsEnabled).
+  
 
 CIFS VFS Mount Options
 ======================
@@ -266,6 +295,10 @@
 		If you do not trust the servers in your network (your mount
 		targets) it is recommended that you specify this option for
 		greater security.
+  exec		Permit execution of binaries on the mount.
+  noexec	Do not permit execution of binaries on the mount.
+  dev		Recognize block devices on the remote mount.
+  nodev		Do not recognize devices on the remote mount.
   suid          Allow remote files on this mountpoint with suid enabled to 
 		be executed (default for mounts when executed as root,
 		nosuid is default for user mounts).
@@ -292,6 +325,22 @@
 		Note that this does not affect the normal ACL check on the
 		target machine done by the server software (of the server
 		ACL against the user name provided at mount time).
+  serverino	Use servers inode numbers instead of generating automatically
+		incrementing inode numbers on the client.  Although this will
+		make it easier to spot hardlinked files (as they will have
+		the same inode numbers) and inode numbers may be persistent,
+		note that the server does not guarantee that the inode numbers
+		are unique if multiple server side mounts are exported under a
+		single share (since inode numbers on the servers might not
+		be unique if multiple filesystems are mounted under the same
+		shared higher level directory).  Note that this requires that
+		the server support the CIFS Unix Extensions as other servers
+		do not return a unique IndexNumber on SMB FindFirst (most
+		servers return zero as the IndexNumber).  Parameter has no
+		effect to Windows servers and others which do not support the
+		CIFS Unix Extensions.
+  noserverino   Client generates inode numbers (rather than using the actual one
+		from the server) by default.
   setuids       If the CIFS Unix extensions are negotiated with the server
 		the client will attempt to set the effective uid and gid of
 		the local process on newly created files, directories, and
@@ -304,6 +353,23 @@
 		the client) set the uid and gid is the default. This
 		parameter has no effect if the CIFS Unix Extensions are not
 		negotiated.
+  netbiosname   When mounting to servers via port 139, specifies the RFC1001
+		source name to use to represent the client netbios machine 
+		name when doing the RFC1001 netbios session initialize.
+  direct        Do not do inode data caching on files opened on this mount.
+		This precludes mmaping files on this mount. In some cases
+		with fast networks and little or no caching benefits on the
+		client (e.g. when the application is doing large sequential
+		reads bigger than page size without rereading the same data) 
+		this can provide better performance than the default
+		behavior which caches reads (reaadahead) and writes 
+		(writebehind) through the local Linux client pagecache 
+		if oplock (caching token) is granted and held. Note that
+		direct allows write operations larger than page size
+		to be sent to the server.
+  acl   	Allow setfacl and getfacl to manage posix ACLs if server
+		supports them.  (default)
+  noacl 	Do not allow setfacl and getfacl calls on this mount
 		
 The mount.cifs mount helper also accepts a few mount options before -o
 including:
@@ -375,14 +441,14 @@
 	echo 1 > /proc/fs/cifs/traceSMB
 
 Two other experimental features are under development and to test 
-require enabling an ifdef (e.g. by  adding "#define CIFS_FCNTL" in cifsglob.h)
+require enabling CONFIG_CIFS_EXPERIMENTAL
 
-	CONFIG_CIFS_QUOTA
+	More efficient write operations and SMB buffer handling
 
-	CONFIG_CIFS_FCNTL  (fcntl needed for support of directory change 
+	DNOTIFY fcntl: needed for support of directory change 
 			    notification and perhaps later for file leases)
 
-Per share (per client mount) statistics are available in /proc/fs/cifs/DebugData
+Per share (per client mount) statistics are available in /proc/fs/cifs/Stats
 if the kernel was configured with cifs statistics enabled.  The statistics
 represent the number of successful (ie non-zero return code from the server) 
 SMB responses to some of the more common commands (open, delete, mkdir etc.).
diff -Nru a/fs/cifs/TODO b/fs/cifs/TODO
--- a/fs/cifs/TODO	2004-12-24 13:37:29 -08:00
+++ b/fs/cifs/TODO	2004-12-24 13:37:29 -08:00
@@ -14,7 +14,7 @@
 better)
 
 c) multi-user mounts - multiplexed sessionsetups over single vc
-(ie tcp session) - prettying up needed
+(ie tcp session) - prettying up needed, and more testing needed
 
 d) Kerberos/SPNEGO session setup support - (started)
 
@@ -40,8 +40,8 @@
 extra copy in/out of the socket buffers in some cases.
 
 l) finish support for IPv6.  This is mostly complete but
-needs a simple inet_pton like function to convert ipv6
-addresses in string representation.
+needs a simple conversion of ipv6 to sin6_addr from the
+address in string representation.
 
 m) Better optimize open (and pathbased setfilesize) to reduce the
 oplock breaks coming from windows srv.  Piggyback identical file
@@ -50,23 +50,24 @@
 spurious oplock breaks).
 
 o) Improve performance of readpages by sending more than one read
-at a time when 8 pages or more are requested.  Evaluate whether
-reads larger than 16K would be helpful.
+at a time when 8 pages or more are requested. In conjuntion
+add support for async_cifs_readpages.
 
-p) For support of Windows9x/98 we need to retry failed mounts
-to *SMBSERVER (default server name) with the uppercase hostname
-in the RFC1001 session_init request.
-
-q) Add support for storing symlink and fifo info to Windows servers 
+p) Add support for storing symlink and fifo info to Windows servers 
 in the Extended Attribute format their SFU clients would recognize.
 
-r) Finish fcntl D_NOTIFY support so kde and gnome file list windows
-will autorefresh
+q) Finish fcntl D_NOTIFY support so kde and gnome file list windows
+will autorefresh (started)
+
+r) Add GUI tool to configure /proc/fs/cifs settings and for display of
+the CIFS statistics (started)
+
+q) implement support for security and trusted categories of xattrs
+(requires minor protocol extension) to enable better support for SELINUX
 
-s) Add GUI tool to configure /proc/fs/cifs settings and for display of
-the CIFS statistics
+r) Implement O_DIRECT flag on open (already supported on mount)
 
-KNOWN BUGS (updated May 27, 2004)
+KNOWN BUGS (updated December 10, 2004)
 ====================================
 1) existing symbolic links (Windows reparse points) are recognized but
 can not be created remotely. They are implemented for Samba and those that
@@ -83,9 +84,6 @@
 differences but worth investigating).  Also debug Samba to 
 see why lock test case 7 takes longer to complete to Samba
 than to Windows.
-5) implement search rewind (seeking backward in a readdir), which is
-necessary for one of the "special" subsection of posix file API
-tests in the Connectathon nfs test suite.
 
 Misc testing to do
 ==================
diff -Nru a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
--- a/fs/cifs/cifs_debug.c	2004-12-24 13:36:49 -08:00
+++ b/fs/cifs/cifs_debug.c	2004-12-24 13:36:49 -08:00
@@ -201,7 +201,12 @@
 		sprintf(buf,"SMB Request/Response Buffer: %d\n",
 			bufAllocCount.counter);
 	length += item_length;
-	buf += item_length;      
+	buf += item_length;
+	item_length = 
+		sprintf(buf,"SMB Small Req/Resp Buffer: %d\n",
+			smBufAllocCount.counter);
+	length += item_length;
+	buf += item_length;
 	item_length = 
 		sprintf(buf,"Operations (MIDs): %d\n",
 			midCount.counter);
@@ -337,7 +342,7 @@
 	if (pde)
 		pde->write_proc = oplockEnabled_write;
 
-	pde = create_proc_read_entry("QuotaEnabled", 0, proc_fs_cifs,
+	pde = create_proc_read_entry("ReenableOldCifsReaddirCode", 0, proc_fs_cifs,
 				quotaEnabled_read, NULL);
 	if (pde)
 		pde->write_proc = quotaEnabled_write;
@@ -396,7 +401,7 @@
 	remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
 	remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
 	remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
-	remove_proc_entry("QuotaEnabled",proc_fs_cifs);
+	remove_proc_entry("ReenableOldCifsReaddirCode",proc_fs_cifs);
 	remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
 	remove_proc_entry("cifs", proc_root_fs);
 }
@@ -485,7 +490,7 @@
 {
         int len;
 
-        len = sprintf(page, "%d\n", quotaEnabled);
+        len = sprintf(page, "%d\n", experimEnabled);
 /* could also check if quotas are enabled in kernel
 	as a whole first */
         len -= off;
@@ -512,9 +517,9 @@
         if (rc)
                 return rc;
         if (c == '0' || c == 'n' || c == 'N')
-                quotaEnabled = 0;
+                experimEnabled = 0;
         else if (c == '1' || c == 'y' || c == 'Y')
-                quotaEnabled = 1;
+                experimEnabled = 1;
 
         return count;
 }
diff -Nru a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h
--- a/fs/cifs/cifs_fs_sb.h	2004-12-24 13:36:31 -08:00
+++ b/fs/cifs/cifs_fs_sb.h	2004-12-24 13:36:31 -08:00
@@ -1,7 +1,7 @@
 /*
  *   fs/cifs/cifs_fs_sb.h
  *
- *   Copyright (c) International Business Machines  Corp., 2002
+ *   Copyright (c) International Business Machines  Corp., 2002,2004
  *   Author(s): Steve French (sfrench@us.ibm.com)
  *
  *   This library is free software; you can redistribute it and/or modify
@@ -18,8 +18,10 @@
 #ifndef _CIFS_FS_SB_H
 #define _CIFS_FS_SB_H
 
-#define CIFS_MOUNT_NO_PERM	1 /* do not do client vfs_perm check */
+#define CIFS_MOUNT_NO_PERM      1 /* do not do client vfs_perm check */
 #define CIFS_MOUNT_SET_UID      2 /* set current->euid in create etc. */
+#define CIFS_MOUNT_SERVER_INUM  4 /* inode numbers from uniqueid from server */
+#define CIFS_MOUNT_DIRECT_IO          8 /* do not write nor read through page cache */
 
 struct cifs_sb_info {
 	struct cifsTconInfo *tcon;	/* primary mount */
diff -Nru a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
--- a/fs/cifs/cifsfs.c	2004-12-24 13:36:56 -08:00
+++ b/fs/cifs/cifsfs.c	2004-12-24 13:36:56 -08:00
@@ -50,15 +50,27 @@
 int cifsERROR = 1;
 int traceSMB = 0;
 unsigned int oplockEnabled = 1;
-unsigned int quotaEnabled = 0;
+unsigned int experimEnabled = 0;
 unsigned int linuxExtEnabled = 1;
 unsigned int lookupCacheEnabled = 1;
 unsigned int multiuser_mount = 0;
 unsigned int extended_security = 0;
 unsigned int ntlmv2_support = 0;
 unsigned int sign_CIFS_PDUs = 1;
-unsigned int CIFSMaximumBufferSize = CIFS_MAX_MSGSIZE;
 struct task_struct * oplockThread = NULL;
+unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
+module_param(CIFSMaxBufSize, int, CIFS_MAX_MSGSIZE);
+MODULE_PARM_DESC(CIFSMaxBufSize,"Network buffer size (not including header). Default: 16384 Range: 8192 to 130048");
+unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
+module_param(cifs_min_rcv, int, CIFS_MIN_RCV_POOL);
+MODULE_PARM_DESC(cifs_min_rcv,"Network buffers in pool. Default: 4 Range: 1 to 64");
+unsigned int cifs_min_small = 30;
+module_param(cifs_min_small, int, 30);
+MODULE_PARM_DESC(cifs_small_rcv,"Small network buffers in pool. Default: 30 Range: 2 to 256");
+unsigned int cifs_max_pending = CIFS_MAX_REQ;
+module_param(cifs_max_pending, int, CIFS_MAX_REQ);
+MODULE_PARM_DESC(cifs_max_pending,"Simultaneous requests to server. Default: 50 Range: 2 to 256");
+
 
 extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
 			const char *);
@@ -200,13 +212,15 @@
 		on the client (above and beyond ACL on servers) for  
 		servers which do not support setting and viewing mode bits,
 		so allowing client to check permissions is useful */ 
-		return vfs_permission(inode, mask);
+		return generic_permission(inode, mask, NULL);
 }
 
 static kmem_cache_t *cifs_inode_cachep;
 static kmem_cache_t *cifs_req_cachep;
 static kmem_cache_t *cifs_mid_cachep;
 kmem_cache_t *cifs_oplock_cachep;
+static kmem_cache_t *cifs_sm_req_cachep;
+mempool_t *cifs_sm_req_poolp;
 mempool_t *cifs_req_poolp;
 mempool_t *cifs_mid_poolp;
 
@@ -431,6 +445,20 @@
 		return -EIO;
 
 	cFYI(1,("In read_wrapper size %zd at %lld",read_size,*poffset));
+
+#ifdef CONFIG_CIFS_EXPERIMENTAL
+	/* check whether we can cache writes locally */
+	if(file->f_dentry->d_sb) {
+		struct cifs_sb_info *cifs_sb;
+		cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+		if(cifs_sb != NULL) {
+			if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
+				return cifs_user_read(file,read_data,
+							read_size,poffset);
+		}
+	}
+#endif /* CIFS_EXPERIMENTAL */
+
 	if(CIFS_I(file->f_dentry->d_inode)->clientCanCacheRead) {
 		return generic_file_read(file,read_data,read_size,poffset);
 	} else {
@@ -463,7 +491,19 @@
 
 	cFYI(1,("In write_wrapper size %zd at %lld",write_size,*poffset));
 
+#ifdef CONFIG_CIFS_EXPERIMENTAL    /* BB fixme - fix user char * to kernel char * mapping here BB */
 	/* check whether we can cache writes locally */
+	if(file->f_dentry->d_sb) {
+		struct cifs_sb_info *cifs_sb;
+		cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+		if(cifs_sb != NULL) {
+			if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
+				return cifs_user_write(file,write_data,
+							write_size,poffset);
+			}
+		}
+	}
+#endif /* CIFS_EXPERIMENTAL */
 	written = generic_file_write(file,write_data,write_size,poffset);
 	if(!CIFS_I(file->f_dentry->d_inode)->clientCanCacheAll)  {
 		if(file->f_dentry->d_inode->i_mapping) {
@@ -495,6 +535,12 @@
 	.setattr = cifs_setattr,
 	.symlink = cifs_symlink,
 	.mknod   = cifs_mknod,
+#ifdef CONFIG_CIFS_XATTR
+	.setxattr = cifs_setxattr,
+	.getxattr = cifs_getxattr,
+	.listxattr = cifs_listxattr,
+	.removexattr = cifs_removexattr,
+#endif
 };
 
 struct inode_operations cifs_file_inode_ops = {
@@ -537,14 +583,18 @@
 	.flush = cifs_flush,
 	.mmap  = cifs_file_mmap,
 	.sendfile = generic_file_sendfile,
+#ifdef CONFIG_CIFS_EXPERIMENTAL
 	.dir_notify = cifs_dir_notify,
+#endif /* CONFIG_CIFS_EXPERIMENTAL */
 };
 
 struct file_operations cifs_dir_ops = {
 	.readdir = cifs_readdir,
 	.release = cifs_closedir,
 	.read    = generic_read_dir,
+#ifdef CONFIG_CIFS_EXPERIMENTAL
 	.dir_notify = cifs_dir_notify,
+#endif /* CONFIG_CIFS_EXPERIMENTAL */
 };
 
 static void
@@ -582,14 +632,31 @@
 static int
 cifs_init_request_bufs(void)
 {
+	if(CIFSMaxBufSize < 8192) {
+	/* Buffer size can not be smaller than 2 * PATH_MAX since maximum
+	Unicode path name has to fit in any SMB/CIFS path based frames */
+		CIFSMaxBufSize = 8192;
+	} else if (CIFSMaxBufSize > 1024*127) {
+		CIFSMaxBufSize = 1024 * 127;
+	} else {
+		CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
+	}
+/*	cERROR(1,("CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize)); */
 	cifs_req_cachep = kmem_cache_create("cifs_request",
-					    CIFS_MAX_MSGSIZE +
+					    CIFSMaxBufSize +
 					    MAX_CIFS_HDR_SIZE, 0,
 					    SLAB_HWCACHE_ALIGN, NULL, NULL);
 	if (cifs_req_cachep == NULL)
 		return -ENOMEM;
 
-	cifs_req_poolp = mempool_create(CIFS_MIN_RCV_POOL,
+	if(cifs_min_rcv < 1)
+		cifs_min_rcv = 1;
+	else if (cifs_min_rcv > 64) {
+		cifs_min_rcv = 64;
+		cFYI(1,("cifs_min_rcv set to maximum (64)"));
+	}
+
+	cifs_req_poolp = mempool_create(cifs_min_rcv,
 					mempool_alloc_slab,
 					mempool_free_slab,
 					cifs_req_cachep);
@@ -598,6 +665,40 @@
 		kmem_cache_destroy(cifs_req_cachep);
 		return -ENOMEM;
 	}
+	/* 256 (MAX_CIFS_HDR_SIZE bytes is enough for most SMB responses and
+	almost all handle based requests (but not write response, nor is it
+	sufficient for path based requests).  A smaller size would have
+	been more efficient (compacting multiple slab items on one 4k page) 
+	for the case in which debug was on, but this larger size allows
+	more SMBs to use small buffer alloc and is still much more
+	efficient to alloc 1 per page off the slab compared to 17K (5page) 
+	alloc of large cifs buffers even when page debugging is on */
+	cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
+			MAX_CIFS_HDR_SIZE, 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
+	if (cifs_sm_req_cachep == NULL) {
+		mempool_destroy(cifs_req_poolp);
+		kmem_cache_destroy(cifs_req_cachep);
+		return -ENOMEM;              
+	}
+
+	if(cifs_min_small < 2)
+		cifs_min_small = 2;
+	else if (cifs_min_small > 256) {
+		cifs_min_small = 256;
+		cFYI(1,("cifs_min_small set to maximum (256)"));
+	}
+
+	cifs_sm_req_poolp = mempool_create(cifs_min_small,
+				mempool_alloc_slab,
+				mempool_free_slab,
+				cifs_sm_req_cachep);
+
+	if(cifs_sm_req_poolp == NULL) {
+		mempool_destroy(cifs_req_poolp);
+		kmem_cache_destroy(cifs_req_cachep);
+		kmem_cache_destroy(cifs_sm_req_cachep);
+		return -ENOMEM;
+	}
 
 	return 0;
 }
@@ -609,6 +710,10 @@
 	if (kmem_cache_destroy(cifs_req_cachep))
 		printk(KERN_WARNING
 		       "cifs_destroy_request_cache: error not all structures were freed\n");
+	mempool_destroy(cifs_sm_req_poolp);
+	if (kmem_cache_destroy(cifs_sm_req_cachep))
+		printk(KERN_WARNING
+		      "cifs_destroy_request_cache: cifs_small_rq free error\n");
 }
 
 static int
@@ -750,6 +855,14 @@
 	GlobalMaxActiveXid = 0;
 	GlobalSMBSeslock = RW_LOCK_UNLOCKED;
 	GlobalMid_Lock = SPIN_LOCK_UNLOCKED;
+
+	if(cifs_max_pending < 2) {
+		cifs_max_pending = 2;
+		cFYI(1,("cifs_max_pending set to min of 2"));
+	} else if(cifs_max_pending > 256) {
+		cifs_max_pending = 256;
+		cFYI(1,("cifs_max_pending set to max of 256"));
+	}
 
 	rc = cifs_init_inodecache();
 	if (!rc) {
diff -Nru a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
--- a/fs/cifs/cifsfs.h	2004-12-24 13:36:19 -08:00
+++ b/fs/cifs/cifsfs.h	2004-12-24 13:36:19 -08:00
@@ -63,10 +63,10 @@
 extern int cifs_open(struct inode *inode, struct file *file);
 extern int cifs_close(struct inode *inode, struct file *file);
 extern int cifs_closedir(struct inode *inode, struct file *file);
-extern ssize_t cifs_read(struct file *file, char *read_data,
+extern ssize_t cifs_user_read(struct file *file, char __user *read_data,
 			 size_t read_size, loff_t * poffset);
-extern ssize_t cifs_write(struct file *file, const char *write_data,
-			  size_t write_size, loff_t * poffset);
+extern ssize_t cifs_user_write(struct file *file, const char __user *write_data,
+			 size_t write_size, loff_t * poffset);
 extern int cifs_lock(struct file *, int, struct file_lock *);
 extern int cifs_fsync(struct file *, struct dentry *, int);
 extern int cifs_flush(struct file *);
@@ -90,5 +90,5 @@
 			 size_t, int);
 extern ssize_t	cifs_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t	cifs_listxattr(struct dentry *, char *, size_t);
-#define CIFS_VERSION   "1.20"
+#define CIFS_VERSION   "1.28"
 #endif				/* _CIFSFS_H */
diff -Nru a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
--- a/fs/cifs/cifsglob.h	2004-12-24 13:36:30 -08:00
+++ b/fs/cifs/cifsglob.h	2004-12-24 13:36:30 -08:00
@@ -240,6 +240,20 @@
 /*
  * One of these for each open instance of a file
  */
+struct cifs_search_info {
+	loff_t index_of_last_entry;
+	__u16 entries_in_buffer;
+	__u16 info_level;
+	__u32 resume_key;
+	char * ntwrk_buf_start;
+	char * srch_entries_start;
+	char * presume_name;
+	unsigned int resume_name_len;
+	unsigned endOfSearch:1;
+	unsigned emptyDir:1;
+	unsigned unicode:1;
+};
+
 struct cifsFileInfo {
 	struct list_head tlist;	/* pointer to next fid owned by tcon */
 	struct list_head flist;	/* next fid (file instance) for this inode */
@@ -250,14 +264,12 @@
 	/* lock scope id (0 if none) */
 	struct file * pfile; /* needed for writepage */
 	struct inode * pInode; /* needed for oplock break */
-	unsigned endOfSearch:1;	/* we have reached end of search */
 	unsigned closePend:1;	/* file is marked to close */
-	unsigned emptyDir:1;
 	unsigned invalidHandle:1;  /* file closed via session abend */
 	struct semaphore fh_sem; /* prevents reopen race after dead ses*/
-	char * search_resume_name;
-	unsigned int resume_name_length;
-	__u32 resume_key;
+	char * search_resume_name; /* BB removeme BB */
+	unsigned int resume_name_length; /* BB removeme - field renamed and moved BB */
+	struct cifs_search_info srch_inf;
 };
 
 /*
@@ -317,6 +329,8 @@
 #define   MID_REQUEST_SUBMITTED 2
 #define   MID_RESPONSE_RECEIVED 4
 #define   MID_RETRY_NEEDED      8 /* session closed while this request out */
+#define   MID_NO_RESP_NEEDED 0x10
+#define   MID_SMALL_BUFFER   0x20 /* 112 byte response buffer instead of 4K */
 
 /*
  *****************************************************************
@@ -399,6 +413,7 @@
 
 /* Various Debug counters to remove someday (BB) */
 GLOBAL_EXTERN atomic_t bufAllocCount;
+GLOBAL_EXTERN atomic_t smBufAllocCount;      
 GLOBAL_EXTERN atomic_t midCount;
 
 /* Misc globals */
@@ -407,11 +422,15 @@
 				have the uid/password or Kerberos credential 
 				or equivalent for current user */
 GLOBAL_EXTERN unsigned int oplockEnabled;
-GLOBAL_EXTERN unsigned int quotaEnabled;
+GLOBAL_EXTERN unsigned int experimEnabled;
 GLOBAL_EXTERN unsigned int lookupCacheEnabled;
 GLOBAL_EXTERN unsigned int extended_security;	/* if on, session setup sent 
 				with more secure ntlmssp2 challenge/resp */
 GLOBAL_EXTERN unsigned int ntlmv2_support;  /* better optional password hash */
 GLOBAL_EXTERN unsigned int sign_CIFS_PDUs;  /* enable smb packet signing */
-GLOBAL_EXTERN unsigned int linuxExtEnabled;  /* enable Linux/Unix CIFS extensions */
+GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
+GLOBAL_EXTERN unsigned int CIFSMaxBufSize;  /* max size not including hdr */
+GLOBAL_EXTERN unsigned int cifs_min_rcv;    /* min size of big ntwrk buf pool */
+GLOBAL_EXTERN unsigned int cifs_min_small;  /* min size of small buf pool */
+GLOBAL_EXTERN unsigned int cifs_max_pending; /* MAX requests at once to server*/
 
diff -Nru a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
--- a/fs/cifs/cifspdu.h	2004-12-24 13:37:18 -08:00
+++ b/fs/cifs/cifspdu.h	2004-12-24 13:37:18 -08:00
@@ -28,27 +28,30 @@
 #define BAD_PROT    CIFS_PROT+1
 
 /* SMB command codes */
-#define SMB_COM_CREATE_DIRECTORY      0x00
-#define SMB_COM_DELETE_DIRECTORY      0x01
-#define SMB_COM_CLOSE                 0x04
-#define SMB_COM_DELETE                0x06
-#define SMB_COM_RENAME                0x07
-#define SMB_COM_LOCKING_ANDX          0x24
-#define SMB_COM_COPY                  0x29
+/* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
+ (ie which include no useful data other than the SMB error code itself).
+ Knowing this helps avoid response buffer allocations and copy in some cases */
+#define SMB_COM_CREATE_DIRECTORY      0x00 /* trivial response */
+#define SMB_COM_DELETE_DIRECTORY      0x01 /* trivial response */
+#define SMB_COM_CLOSE                 0x04 /* triv req/rsp, timestamp ignored */
+#define SMB_COM_DELETE                0x06 /* trivial response */
+#define SMB_COM_RENAME                0x07 /* trivial response */
+#define SMB_COM_LOCKING_ANDX          0x24 /* trivial response */
+#define SMB_COM_COPY                  0x29 /* trivial rsp, fail filename ignrd*/
 #define SMB_COM_READ_ANDX             0x2E
 #define SMB_COM_WRITE_ANDX            0x2F
 #define SMB_COM_TRANSACTION2          0x32
 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
-#define SMB_COM_FIND_CLOSE2           0x34
-#define SMB_COM_TREE_DISCONNECT       0x71
+#define SMB_COM_FIND_CLOSE2           0x34 /* trivial response */
+#define SMB_COM_TREE_DISCONNECT       0x71 /* trivial response */
 #define SMB_COM_NEGOTIATE             0x72
 #define SMB_COM_SESSION_SETUP_ANDX    0x73
-#define SMB_COM_LOGOFF_ANDX           0x74
+#define SMB_COM_LOGOFF_ANDX           0x74 /* trivial response */
 #define SMB_COM_TREE_CONNECT_ANDX     0x75
 #define SMB_COM_NT_TRANSACT           0xA0
 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
 #define SMB_COM_NT_CREATE_ANDX        0xA2
-#define SMB_COM_NT_RENAME             0xA5
+#define SMB_COM_NT_RENAME             0xA5 /* trivial response */
 
 /* Transact2 subcommand codes */
 #define TRANS2_OPEN                   0x00
@@ -141,7 +144,7 @@
 #define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
 #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
-#define SMBFLG2_EXT_SEC cpu_to_le16(0x80)
+#define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
 #define SMBFLG2_DFS cpu_to_le16(0x1000)
 #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
@@ -682,7 +685,7 @@
 	__le32 OffsetHigh;
 	__le16 ByteCount;
 	__u8 Pad;		/* BB check for whether padded to DWORD boundary and optimum performance here */
-	char Data[1];
+	char Data[0];
 } WRITE_REQ;
 
 typedef struct smb_com_write_rsp {
@@ -972,10 +975,10 @@
 
 /* response contains array of the following structures */
 struct file_notify_information {
-	__u32 NextEntryOffset;
-	__u32 Action;
-	__u32 FileNameLength;
-	__u8  FileName[1];
+	__le32 NextEntryOffset;
+	__le32 Action;
+	__le32 FileNameLength;
+	__u8  FileName[0];
 }; 
 
 struct reparse_data {
@@ -1004,45 +1007,55 @@
 #define QUOTA_LIST_START	0x100
 #define QUOTA_FOR_SID		0x101
 
-typedef union smb_com_transaction2 {
-	struct {
-		struct smb_hdr hdr;	/* wct = 14+ */
-		__u16 TotalParameterCount;
-		__u16 TotalDataCount;
-		__u16 MaxParameterCount;
-		__u16 MaxDataCount;
-		__u8 MaxSetupCount;
-		__u8 Reserved;
-		__u16 Flags;
-		__u32 Timeout;
-		__u16 Reserved2;
-		__u16 ParameterCount;
-		__u16 ParameterOffset;
-		__u16 DataCount;
-		__u16 DataOffset;
-		__u8 SetupCount;
-		__u8 Reserved3;
-		__u16 SubCommand;	/* 1st setup word - can be followed by SetupCount words */
-		__u16 ByteCount;	/* careful - setupcount is not always one */
-	} req;
-	struct {
-		struct smb_hdr hdr;	/* wct = 0 */
-		__u16 TotalParameterCount;
-		__u16 TotalDataCount;
-		__u16 Reserved;
-		__u16 ParameterCount;
-		__u16 ParamterOffset;
-		__u16 ParameterDisplacement;
-		__u16 DataCount;
-		__u16 DataOffset;
-		__u16 DataDisplacement;
-		__u8 SetupCount;
-		__u8 Reserved1;	/* should be zero setup words following */
-		__u16 ByteCount;
-		__u16 Reserved2;	/* parameter word reserved - present for infolevels > 100 */
-		/* data area follows */
-	} resp;
-} TRANSACTION2;
+struct trans2_req {
+	/* struct smb_hdr hdr precedes. Set wct = 14+ */
+	__le16 TotalParameterCount;
+	__le16 TotalDataCount;
+	__le16 MaxParameterCount;
+	__le16 MaxDataCount;
+	__u8 MaxSetupCount;
+	__u8 Reserved;
+	__le16 Flags;
+	__le32 Timeout;
+	__u16 Reserved2;
+	__le16 ParameterCount;
+	__le16 ParameterOffset;
+	__le16 DataCount;
+	__le16 DataOffset;
+	__u8 SetupCount;
+	__u8 Reserved3;
+	__le16 SubCommand; /* 1st setup word - SetupCount words follow */
+	__le16 ByteCount;
+};
+
+struct smb_t2_req {
+	struct smb_hdr hdr;
+	struct trans2_req t2_req;
+};
+
+struct trans2_resp {
+	/* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
+	__le16 TotalParameterCount;
+	__le16 TotalDataCount;
+	__u16 Reserved;
+	__le16 ParameterCount;
+	__le16 ParameterOffset;
+	__le16 ParameterDisplacement;
+	__le16 DataCount;
+	__le16 DataOffset;
+	__le16 DataDisplacement;
+	__u8 SetupCount;
+	__u8 Reserved1;
+	/* SetupWords[SetupCount];
+	__u16 ByteCount;
+	__u16 Reserved2;*/	
+	/* data area follows */
+};
+
+struct smb_t2_rsp {
+	struct smb_hdr hdr;
+	struct trans2_resp t2_rsp;
+};
 
 /* PathInfo/FileInfo infolevels */
 #define SMB_INFO_STANDARD                   1
@@ -1063,6 +1076,15 @@
 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
 #define SMB_QUERY_FILE_UNIX_BASIC       0x200
 #define SMB_QUERY_FILE_UNIX_LINK        0x201
+#define SMB_QUERY_POSIX_ACL             0x204
+#define SMB_QUERY_XATTR                 0x205
+#define SMB_QUERY_FILE_INTERNAL_INFO    0x3ee
+#define SMB_QUERY_FILE_ACCESS_INFO      0x3f0
+#define SMB_QUERY_FILE_NAME_INFO2       0x3f1 /* 0x30 bytes */
+#define SMB_QUERY_FILE_POSITION_INFO    0x3f6 
+#define SMB_QUERY_FILE_MODE_INFO        0x3f8
+#define SMB_QUERY_FILE_ALGN_INFO        0x3f9 
+
 
 #define SMB_SET_FILE_BASIC_INFO	        0x101
 #define SMB_SET_FILE_DISPOSITION_INFO   0x102
@@ -1071,8 +1093,10 @@
 #define SMB_SET_FILE_UNIX_BASIC         0x200
 #define SMB_SET_FILE_UNIX_LINK          0x201
 #define SMB_SET_FILE_UNIX_HLINK         0x203
+#define SMB_SET_POSIX_ACL               0x204
+#define SMB_SET_XATTR                   0x205
 #define SMB_SET_FILE_BASIC_INFO2        0x3ec
-#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2
+#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo level too */
 #define SMB_FILE_ALL_INFO2              0x3fa
 #define SMB_SET_FILE_ALLOCATION_INFO2   0x3fb
 #define SMB_SET_FILE_END_OF_FILE_INFO2  0x3fc
@@ -1086,6 +1110,8 @@
 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
 #define SMB_FIND_FILE_NAMES_INFO          0x103
 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
+#define SMB_FIND_FILE_ID_FULL_DIR_INFO    0x105
+#define SMB_FIND_FILE_ID_BOTH_DIR_INFO    0x106
 #define SMB_FIND_FILE_UNIX                0x202
 
 typedef struct smb_com_transaction2_qpi_req {
@@ -1115,17 +1141,7 @@
 
 typedef struct smb_com_transaction2_qpi_rsp {
 	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
-	__le16 TotalParameterCount;
-	__le16 TotalDataCount;
-	__le16 Reserved;
-	__le16 ParameterCount;
-	__le16 ParameterOffset;
-	__le16 ParameterDisplacement;
-	__le16 DataCount;
-	__le16 DataOffset;
-	__le16 DataDisplacement;
-	__u8 SetupCount;
-	__u8 Reserved1;		/* should be zero setup words following */
+	struct trans2_resp t2;
 	__u16 ByteCount;
 	__u16 Reserved2;	/* parameter word reserved - present for infolevels > 100 */
 } TRANSACTION2_QPI_RSP;
@@ -1158,17 +1174,7 @@
 
 typedef struct smb_com_transaction2_spi_rsp {
 	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
-	__le16 TotalParameterCount;
-	__le16 TotalDataCount;
-	__u16 Reserved;
-	__le16 ParameterCount;
-	__le16 ParameterOffset;
-	__le16 ParameterDisplacement;
-	__le16 DataCount;
-	__le16 DataOffset;
-	__le16 DataDisplacement;
-	__u8 SetupCount;
-	__u8 Reserved1;		/* should be zero setup words following */
+	struct trans2_resp t2;
 	__u16 ByteCount;
 	__u16 Reserved2;	/* parameter word reserved - present for infolevels > 100 */
 } TRANSACTION2_SPI_RSP;
@@ -1208,17 +1214,7 @@
 
 struct smb_com_transaction2_sfi_rsp {
 	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
-	__le16 TotalParameterCount;
-	__le16 TotalDataCount;
-	__u16 Reserved;
-	__le16 ParameterCount;
-	__le16 ParameterOffset;
-	__le16 ParameterDisplacement;
-	__le16 DataCount;
-	__le16 DataOffset;
-	__le16 DataDisplacement;
-	__u8 SetupCount;
-	__u8 Reserved1;		/* should be zero setup words following */
+	struct trans2_resp t2;
 	__u16 ByteCount;
 	__u16 Reserved2;	/* parameter word reserved - present for infolevels > 100 */
 };
@@ -1268,17 +1264,7 @@
 
 typedef struct smb_com_transaction2_ffirst_rsp {
 	struct smb_hdr hdr;	/* wct = 10 */
-	__le16 TotalParameterCount;
-	__le16 TotalDataCount;
-	__u16 Reserved;
-	__le16 ParameterCount;
-	__le16 ParameterOffset;
-	__le16 ParameterDisplacement;
-	__le16 DataCount;
-	__le16 DataOffset;
-	__le16 DataDisplacement;
-	__u8 SetupCount;
-	__u8 Reserved1;		/* should be zero setup words following */
+	struct trans2_resp t2;
 	__u16 ByteCount;
 } TRANSACTION2_FFIRST_RSP;
 
@@ -1320,17 +1306,7 @@
 
 typedef struct smb_com_transaction2_fnext_rsp {
 	struct smb_hdr hdr;	/* wct = 10 */
-	__le16 TotalParameterCount;
-	__le16 TotalDataCount;
-	__u16 Reserved;
-	__le16 ParameterCount;
-	__le16 ParameterOffset;
-	__le16 ParameterDisplacement;
-	__le16 DataCount;
-	__le16 DataOffset;
-	__le16 DataDisplacement;
-	__u8 SetupCount;
-	__u8 Reserved1;		/* should be zero setup words following */
+	struct trans2_resp t2;
 	__u16 ByteCount;
 } TRANSACTION2_FNEXT_RSP;
 
@@ -1351,6 +1327,8 @@
 #define SMB_QUERY_CIFS_UNIX_INFO    0x200
 #define SMB_QUERY_LABEL_INFO        0x3ea
 #define SMB_QUERY_FS_QUOTA_INFO     0x3ee
+#define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
+#define SMB_QUERY_OBJECTID_INFO     0x3f0
 
 typedef struct smb_com_transaction2_qfsi_req {
 	struct smb_hdr hdr;	/* wct = 14+ */
@@ -1377,17 +1355,7 @@
 
 typedef struct smb_com_transaction_qfsi_rsp {
 	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
-	__le16 TotalParameterCount;
-	__le16 TotalDataCount;
-	__u16 Reserved;
-	__le16 ParameterCount;
-	__le16 ParameterOffset;
-	__le16 ParameterDisplacement;
-	__le16 DataCount;
-	__le16 DataOffset;
-	__le16 DataDisplacement;
-	__u8 SetupCount;
-	__u8 Reserved1;		/* should be zero setup words following */
+	struct trans2_resp t2;
 	__u16 ByteCount;
 	__u8 Pad;		/* may be three bytes *//* followed by data area */
 } TRANSACTION2_QFSI_RSP;
@@ -1430,17 +1398,7 @@
 
 typedef struct smb_com_transaction_get_dfs_refer_rsp {
 	struct smb_hdr hdr;	/* wct = 10 */
-	__le16 TotalParameterCount;
-	__le16 TotalDataCount;
-	__u16 Reserved;
-	__le16 ParameterCount;
-	__le16 ParameterOffset;
-	__le16 ParameterDisplacement;
-	__le16 DataCount;
-	__le16 DataOffset;
-	__le16 DataDisplacement;
-	__u8 SetupCount;
-	__u8 Reserved1;		/* zero setup words following */
+	struct trans2_resp t2;
 	__u16 ByteCount;
 	__u8 Pad;
 	__le16 PathConsumed;
@@ -1545,6 +1503,7 @@
 /* Linux/Unix extensions capability flags */
 #define CIFS_UNIX_FCNTL_CAP             0x00000001 /* support for fcntl locks */
 #define CIFS_UNIX_POSIX_ACL_CAP         0x00000002
+#define CIFS_UNIX_XATTR_CAP             0x00000004 /*support for new namespace*/
 
 /* DeviceType Flags */
 #define FILE_DEVICE_CD_ROM              0x00000002
@@ -1575,10 +1534,13 @@
 	__le32 Attributes;
 	__le32 MaxPathNameComponentLength;
 	__le32 FileSystemNameLen;
-	char FileSystemName[52];	/* do not really need to save this - so potentially get only subset of name */
+	char FileSystemName[52]; /* do not really need to save this - so potentially get only subset of name */
 } FILE_SYSTEM_ATTRIBUTE_INFO;
 
-typedef struct {		/* data block encoding of response to level 263 QPathInfo */
+/******************************************************************************/
+/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
+/******************************************************************************/
+typedef struct { /* data block encoding of response to level 263 QPathInfo */
 	__le64 CreationTime;
 	__le64 LastAccessTime;
 	__le64 LastWriteTime;
@@ -1600,12 +1562,20 @@
 	__le32 AlignmentRequirement;
 	__le32 FileNameLength;
 	char FileName[1];
-} FILE_ALL_INFO;		/* level 263 QPathInfo */
+} FILE_ALL_INFO;		/* level 0x107 QPathInfo */
 
+/* defines for enumerating possible values of the Unix type field below */
+#define UNIX_FILE      0
+#define UNIX_DIR       1
+#define UNIX_SYMLINK   2
+#define UNIX_CHARDEV   3
+#define UNIX_BLOCKDEV  4
+#define UNIX_FIFO      5
+#define UNIX_SOCKET    6
 typedef struct {
 	__le64 EndOfFile;
 	__le64 NumOfBytes;
-	__le64 LastStatusChange;	/*SNIA spec says DCE time for the three time fields */
+	__le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
 	__le64 LastAccessTime;
 	__le64 LastModificationTime;
 	__le64 Uid;
@@ -1616,11 +1586,11 @@
 	__u64 UniqueId;
 	__le64 Permissions;
 	__le64 Nlinks;
-} FILE_UNIX_BASIC_INFO;		/* level 512 QPathInfo */
+} FILE_UNIX_BASIC_INFO;		/* level 0x200 QPathInfo */
 
 typedef struct {
 	char LinkDest[1];
-} FILE_UNIX_LINK_INFO;		/* level 513 QPathInfo */
+} FILE_UNIX_LINK_INFO;		/* level 0x201 QPathInfo */
 
 typedef struct {
 	__u16 CreationDate;
@@ -1635,21 +1605,99 @@
 	__u32 EASize;
 } FILE_INFO_STANDARD;  /* level 1 SetPath/FileInfo */
 
-/* defines for enumerating possible values of the Unix type field below */
-#define UNIX_FILE      0
-#define UNIX_DIR       1
-#define UNIX_SYMLINK   2
-#define UNIX_CHARDEV   3
-#define UNIX_BLOCKDEV  4
-#define UNIX_FIFO      5
-#define UNIX_SOCKET    6
+typedef struct {
+	__le64 CreationTime;
+	__le64 LastAccessTime;
+	__le64 LastWriteTime;
+	__le64 ChangeTime;
+	__le32 Attributes;
+	__u32 Pad;
+} FILE_BASIC_INFO;		/* size info, level 0x101 */
+
+struct file_allocation_info {
+	__le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
+};	/* size used on disk, level 0x103 for set, 0x105 for query */
+
+struct file_end_of_file_info {
+	__le64 FileSize;		/* offset to end of file */
+};	/* size info, level 0x104 for set, 0x106 for query */
+
+struct file_alt_name_info {
+	__u8   alt_name[1];
+};      /* level 0x0108 */
+
+struct file_stream_info {
+	__le32 number_of_streams;  /* BB check sizes and verify location */
+	/* followed by info on streams themselves 
+		u64 size;
+		u64 allocation_size 
+		stream info */
+};      /* level 0x109 */
+
+struct file_compression_info {
+	__le64 compressed_size;
+	__le16 format;
+	__u8   unit_shift;
+	__u8   ch_shift;
+	__u8   cl_shift;
+	__u8   pad[3];
+};      /* level 0x10b */
+
+/* POSIX ACL set/query path info structures */
+#define CIFS_ACL_VERSION 1
+struct cifs_posix_ace { /* access control entry (ACE) */
+	__u8  cifs_e_tag;
+	__u8  cifs_e_perm;
+	__le64 cifs_uid; /* or gid */
+}; 
+
+struct cifs_posix_acl { /* access conrol list  (ACL) */
+	__le16	version;
+	__le16	access_entry_count;  /* access ACL - count of entries */
+	__le16	default_entry_count; /* default ACL - count of entries */
+	struct cifs_posix_ace ace_array[0];
+	/* followed by
+	struct cifs_posix_ace default_ace_arraay[] */
+};  /* level 0x204 */
+
+/* types of access control entries already defined in posix_acl.h */
+/* #define CIFS_POSIX_ACL_USER_OBJ	 0x01
+#define CIFS_POSIX_ACL_USER      0x02
+#define CIFS_POSIX_ACL_GROUP_OBJ 0x04
+#define CIFS_POSIX_ACL_GROUP     0x08
+#define CIFS_POSIX_ACL_MASK      0x10
+#define CIFS_POSIX_ACL_OTHER     0x20 */
+
+/* types of perms */
+/* #define CIFS_POSIX_ACL_EXECUTE   0x01
+#define CIFS_POSIX_ACL_WRITE     0x02
+#define CIFS_POSIX_ACL_READ	     0x04 */
+
+/* end of POSIX ACL definitions */
+
+struct file_internal_info {
+	__u64  UniqueId; /* inode number */
+};      /* level 0x3ee */
+struct file_mode_info {
+	__le32	Mode;
+};      /* level 0x3f8 */
+
+struct file_attrib_tag {
+	__le32 Attribute;
+	__le32 ReparseTag;
+};      /* level 0x40b */
+
+
+/********************************************************/
+/*  FindFirst/FindNext transact2 data buffer formats    */ 
+/********************************************************/
 
 typedef struct {
 	__le32 NextEntryOffset;
-	__le32 ResumeKey;
+	__u32 ResumeKey; /* as with FileIndex - no need to convert */
 	__le64 EndOfFile;
 	__le64 NumOfBytes;
-	__le64 LastStatusChange;	/*SNIA spec says DCE time for the three time fields */
+	__le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
 	__le64 LastAccessTime;
 	__le64 LastModificationTime;
 	__le64 Uid;
@@ -1657,28 +1705,40 @@
 	__le32 Type;
 	__le64 DevMajor;
 	__le64 DevMinor;
-	__le64 UniqueId;
+	__u64 UniqueId;
 	__le64 Permissions;
 	__le64 Nlinks;
 	char FileName[1];
-} FILE_UNIX_INFO;
+} FILE_UNIX_INFO; /* level 0x202 */
 
 typedef struct {
+	__le32 NextEntryOffset;
+	__u32 FileIndex;
 	__le64 CreationTime;
 	__le64 LastAccessTime;
 	__le64 LastWriteTime;
 	__le64 ChangeTime;
-	__le32 Attributes;
-	__u32 Pad;
-} FILE_BASIC_INFO;		/* size info, level 0x101 */
-
-struct file_allocation_info {
+	__le64 EndOfFile;
 	__le64 AllocationSize;
-};		/* size info, level 0x103 */
+	__le32 ExtFileAttributes;
+	__le32 FileNameLength;
+	char FileName[1];
+} FILE_DIRECTORY_INFO;   /* level 0x101 FF response data area */
 
-struct file_end_of_file_info {
-	__le64 FileSize;		/* offset to end of file */
-};	/* size info, level 0x104 */
+typedef struct {
+	__le32 NextEntryOffset;
+	__u32 FileIndex;
+	__le64 CreationTime;
+	__le64 LastAccessTime;
+	__le64 LastWriteTime;
+	__le64 ChangeTime;
+	__le64 EndOfFile;
+	__le64 AllocationSize;
+	__le32 ExtFileAttributes;
+	__le32 FileNameLength;
+	__le32 EaSize; /* length of the xattrs */
+	char FileName[1];
+} FILE_FULL_DIRECTORY_INFO;   /* level 0x102 FF response data area */
 
 typedef struct {
 	__le32 NextEntryOffset;
@@ -1691,8 +1751,30 @@
 	__le64 AllocationSize;
 	__le32 ExtFileAttributes;
 	__le32 FileNameLength;
+	__le32 EaSize; /* EA size */
+	__le32 Reserved;
+	__u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
 	char FileName[1];
-} FILE_DIRECTORY_INFO;   /* level 257 FF response data area */
+} SEARCH_ID_FULL_DIR_INFO;   /* level 0x105 FF response data area */
+
+typedef struct {
+	__le32 NextEntryOffset;
+	__u32 FileIndex;
+	__le64 CreationTime;
+	__le64 LastAccessTime;
+	__le64 LastWriteTime;
+	__le64 ChangeTime;
+	__le64 EndOfFile;
+	__le64 AllocationSize;
+	__le32 ExtFileAttributes;
+	__le32 FileNameLength; 
+	__le32 EaSize; /* length of the xattrs */
+	__u8   ShortNameLength;
+	__u8   Reserved;
+	__u8   ShortName[12];
+	char FileName[1];
+} FILE_BOTH_DIRECTORY_INFO;   /* level 0x104 FF response data area */
+
 
 struct gea {
 	unsigned char name_len;
@@ -1829,6 +1911,15 @@
 /* if room left, then end with \n then 0x20s by convention but not required */
 	char path[1024];  
 };
+
+typedef struct {
+	/* BB do we need another field for flags? BB */
+	__u32 xattr_name_len;
+	__u32 xattr_value_len;
+	char  xattr_name[0];
+	/* followed by xattr_value[xattr_value_len], no pad */
+} FILE_XATTR_INFO;	/* extended attribute, info level 205 */
+
 
 #endif 
 
diff -Nru a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
--- a/fs/cifs/cifsproto.h	2004-12-24 13:36:17 -08:00
+++ b/fs/cifs/cifsproto.h	2004-12-24 13:36:17 -08:00
@@ -1,7 +1,7 @@
 /*
  *   fs/cifs/cifsproto.h
  *
- *   Copyright (c) International Business Machines  Corp., 2002
+ *   Copyright (c) International Business Machines  Corp., 2002,2004
  *   Author(s): Steve French (sfrench@us.ibm.com)
  *
  *   This library is free software; you can redistribute it and/or modify
@@ -32,6 +32,8 @@
 
 extern struct smb_hdr *cifs_buf_get(void);
 extern void cifs_buf_release(void *);
+extern struct smb_hdr *cifs_small_buf_get(void);
+extern void cifs_small_buf_release(void *);
 extern int smb_send(struct socket *, struct smb_hdr *,
 			unsigned int /* length */ , struct sockaddr *);
 extern unsigned int _GetXid(void);
@@ -190,7 +192,8 @@
 extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
 			const int netfid, const unsigned int count,
 			const __u64 lseek, unsigned int *nbytes,
-			const char *buf, const int long_op);
+			const char *buf, const char __user *ubuf, 
+			const int long_op);
 extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
 			const __u16 netfid, const __u64 len,
 			const __u64 offset, const __u32 numUnlock,
@@ -232,5 +235,13 @@
 extern int CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, 
 		const char *fileName, const char * ea_name, 
 		const void * ea_value, const __u16 ea_value_len, 
+		const struct nls_table *nls_codepage);
+extern int CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon,
+		const unsigned char *searchName,
+		char *acl_inf, const int buflen,const int acl_type,
+		const struct nls_table *nls_codepage);
+extern int CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon,
+		const unsigned char *fileName,
+		const char *local_acl, const int buflen, const int acl_type,
 		const struct nls_table *nls_codepage);
 #endif			/* _CIFSPROTO_H */
diff -Nru a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
--- a/fs/cifs/cifssmb.c	2004-12-24 13:36:31 -08:00
+++ b/fs/cifs/cifssmb.c	2004-12-24 13:36:31 -08:00
@@ -30,6 +30,7 @@
 #include <linux/fs.h>
 #include <linux/kernel.h>
 #include <linux/vfs.h>
+#include <linux/posix_acl_xattr.h>
 #include <asm/uaccess.h>
 #include "cifspdu.h"
 #include "cifsglob.h"
@@ -78,6 +79,97 @@
 }
 
 static int
+small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
+	 void **request_buf /* returned */)
+{
+	int rc = 0;
+
+	/* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
+	   check for tcp and smb session status done differently
+	   for those three - in the calling routine */
+	if(tcon) {
+		if((tcon->ses) && (tcon->ses->server)){
+			struct nls_table *nls_codepage;
+				/* Give Demultiplex thread up to 10 seconds to 
+					reconnect, should be greater than cifs socket
+					timeout which is 7 seconds */
+			while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
+				wait_event_interruptible_timeout(tcon->ses->server->response_q,
+					(tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
+				if(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
+					/* on "soft" mounts we wait once */
+					if((tcon->retry == FALSE) || 
+					   (tcon->ses->status == CifsExiting)) {
+						cFYI(1,("gave up waiting on reconnect in smb_init"));
+						return -EHOSTDOWN;
+					} /* else "hard" mount - keep retrying until 
+					process is killed or server comes back up */
+				} else /* TCP session is reestablished now */
+					break;
+				 
+			}
+			
+			nls_codepage = load_nls_default();
+		/* need to prevent multiple threads trying to
+		simultaneously reconnect the same SMB session */
+			down(&tcon->ses->sesSem);
+			if(tcon->ses->status == CifsNeedReconnect)
+				rc = cifs_setup_session(0, tcon->ses, nls_codepage);
+			if(!rc && (tcon->tidStatus == CifsNeedReconnect)) {
+				mark_open_files_invalid(tcon);
+				rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon,
+					nls_codepage);
+				up(&tcon->ses->sesSem);
+				if(rc == 0)
+					atomic_inc(&tconInfoReconnectCount);
+
+				cFYI(1, ("reconnect tcon rc = %d", rc));
+				/* Removed call to reopen open files here - 
+					it is safer (and faster) to reopen files
+					one at a time as needed in read and write */
+
+				/* Check if handle based operation so we 
+					know whether we can continue or not without
+					returning to caller to reset file handle */
+				switch(smb_command) {
+					case SMB_COM_READ_ANDX:
+					case SMB_COM_WRITE_ANDX:
+					case SMB_COM_CLOSE:
+					case SMB_COM_FIND_CLOSE2:
+					case SMB_COM_LOCKING_ANDX: {
+						unload_nls(nls_codepage);
+						return -EAGAIN;
+					}
+				}
+			} else {
+				up(&tcon->ses->sesSem);
+			}
+			unload_nls(nls_codepage);
+
+		} else {
+			return -EIO;
+		}
+	}
+	if(rc)
+		return rc;
+
+	*request_buf = cifs_small_buf_get();
+	if (*request_buf == 0) {
+		/* BB should we add a retry in here if not a writepage? */
+		return -ENOMEM;
+	}
+
+	header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct);
+
+#ifdef CONFIG_CIFS_STATS
+        if(tcon != NULL) {
+                atomic_inc(&tcon->num_smbs_sent);
+        }
+#endif /* CONFIG_CIFS_STATS */
+	return rc;
+}  
+
+static int
 smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
 	 void **request_buf /* returned */ ,
 	 void **response_buf /* returned */ )
@@ -171,10 +263,42 @@
         if(tcon != NULL) {
                 atomic_inc(&tcon->num_smbs_sent);
         }
-#endif
+#endif /* CONFIG_CIFS_STATS */
 	return rc;
 }
 
+static int validate_t2(struct smb_t2_rsp * pSMB) 
+{
+	int rc = -EINVAL;
+	int total_size;
+	char * pBCC;
+
+	/* check for plausible wct, bcc and t2 data and parm sizes */
+	/* check for parm and data offset going beyond end of smb */
+	if(pSMB->hdr.WordCount >= 10) {
+		if((le16_to_cpu(pSMB->t2_rsp.ParameterOffset) <= 1024) &&
+		   (le16_to_cpu(pSMB->t2_rsp.DataOffset) <= 1024)) {
+			/* check that bcc is at least as big as parms + data */
+			/* check that bcc is less than negotiated smb buffer */
+			total_size = le16_to_cpu(pSMB->t2_rsp.ParameterCount);
+			if(total_size < 512) {
+				total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount);
+				/* BCC le converted in SendReceive */
+				pBCC = (pSMB->hdr.WordCount * 2) + sizeof(struct smb_hdr) + 
+					(char *)pSMB;
+				if((total_size <= (*(u16 *)pBCC)) && 
+				   (total_size < 
+					CIFSMaxBufSize+MAX_CIFS_HDR_SIZE)) {
+					return 0;
+				}
+				
+			}
+		}
+	}
+	cifs_dump_mem("Invalid transact2 SMB: ",(char *)pSMB,
+		sizeof(struct smb_t2_rsp) + 16);
+	return rc;
+}
 int
 CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
 {
@@ -217,7 +341,7 @@
 		/* probably no need to store and check maxvcs */
 		server->maxBuf =
 			min(le32_to_cpu(pSMBr->MaxBufferSize),
-			(__u32) CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE);
+			(__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
 		server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
 		cFYI(0, ("Max buf = %d ", ses->server->maxBuf));
 		GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
@@ -265,6 +389,12 @@
 							 SecurityBlob,
 							 count - 16,
 							 &server->secType);
+				if(rc == 1) {
+				/* BB Need to fill struct for sessetup here */
+					rc = -EOPNOTSUPP;
+				} else {
+					rc = -EINVAL;
+				}
 			}
 		} else
 			server->capabilities &= ~CAP_EXTENDED_SECURITY;
@@ -288,7 +418,7 @@
 CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
 {
 	struct smb_hdr *smb_buffer;
-	struct smb_hdr *smb_buffer_response;
+	struct smb_hdr *smb_buffer_response; /* BB removeme BB */
 	int rc = 0;
 	int length;
 
@@ -322,20 +452,20 @@
 		up(&tcon->tconSem);
 		return -EIO;
 	}
-
-	rc = smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon,
-		      (void **) &smb_buffer, (void **) &smb_buffer_response);
+	rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, (void **)&smb_buffer);
 	if (rc) {
 		up(&tcon->tconSem);
 		return rc;
-	}
+	} else {
+		smb_buffer_response = smb_buffer; /* BB removeme BB */
+    }
 	rc = SendReceive(xid, tcon->ses, smb_buffer, smb_buffer_response,
 			 &length, 0);
 	if (rc)
 		cFYI(1, (" Tree disconnect failed %d", rc));
 
 	if (smb_buffer)
-		cifs_buf_release(smb_buffer);
+		cifs_small_buf_release(smb_buffer);
 	up(&tcon->tconSem);
 
 	/* No need to return error on this operation if tid invalidated and 
@@ -365,9 +495,8 @@
 		up(&ses->sesSem);
 		return -EBUSY;
 	}
-
-	rc = smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL /* no tcon anymore */,
-		 (void **) &pSMB, (void **) &smb_buffer_response);
+	rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB);
+	smb_buffer_response = (struct smb_hdr *)pSMB; /* BB removeme BB */
 	
 	if(ses->server) {
 		if(ses->server->secMode & 
@@ -395,7 +524,7 @@
 		}
 	}
 	if (pSMB)
-		cifs_buf_release(pSMB);
+		cifs_small_buf_release(pSMB);
 	up(&ses->sesSem);
 
 	/* if session dead then we do not need to do ulogoff,
@@ -424,13 +553,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->fileName, fileName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->fileName, fileName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fileName, 530);
+		name_len = strnlen(fileName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->fileName, fileName, name_len);
 	}
@@ -476,13 +605,13 @@
 		return rc;
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
-		name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, dirName, 530
+		name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, dirName, PATH_MAX
 				/* find define for this maxpathcomponent */
 				, nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(dirName, 530);
+		name_len = strnlen(dirName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->DirName, dirName, name_len);
 	}
@@ -526,13 +655,13 @@
 		return rc;
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
-		name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, name, 530
+		name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, name, PATH_MAX
 					 /* find define for this maxpathcomponent */
 					 , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(name, 530);
+		name_len = strnlen(name, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->DirName, name, name_len);
 	}
@@ -583,7 +712,7 @@
 		count = 1;	/* account for one byte pad to word boundary */
 		name_len =
 		    cifs_strtoUCS((wchar_t *) (pSMB->fileName + 1),
-				  fileName, 530
+				  fileName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
@@ -591,7 +720,7 @@
 		pSMB->NameLength = cpu_to_le16(name_len);
 	} else {		/* BB improve the check for buffer overruns BB */
 		count = 0;	/* no pad */
-		name_len = strnlen(fileName, 530);
+		name_len = strnlen(fileName, PATH_MAX);
 		name_len++;	/* trailing null */
 		pSMB->NameLength = cpu_to_le16(name_len);
 		strncpy(pSMB->fileName, fileName, name_len);
@@ -700,7 +829,7 @@
 		__u16 data_length = le16_to_cpu(pSMBr->DataLength);
 		*nbytes = data_length;
 		/*check that DataLength would not go beyond end of SMB */
-		if ((data_length > CIFS_MAX_MSGSIZE) 
+		if ((data_length > CIFSMaxBufSize) 
 				|| (data_length > count)) {
 			cFYI(1,("bad length %d for count %d",data_length,count));
 			rc = -EIO;
@@ -733,7 +862,7 @@
 CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
 	     const int netfid, const unsigned int count,
 	     const __u64 offset, unsigned int *nbytes, const char *buf,
-	     const int long_op)
+	     const char __user * ubuf, const int long_op)
 {
 	int rc = -EACCES;
 	WRITE_REQ *pSMB = NULL;
@@ -754,15 +883,29 @@
 	pSMB->Fid = netfid;
 	pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF);
 	pSMB->OffsetHigh = cpu_to_le32(offset >> 32);
+	pSMB->Reserved = 0xFFFFFFFF;
+	pSMB->WriteMode = 0;
 	pSMB->Remaining = 0;
+	/* BB can relax this if buffer is big enough in some cases - ie we can 
+	send more  if LARGE_WRITE_X capability returned by the server and if
+	our buffer is big enough or if we convert to iovecs on socket writes
+	and eliminate the copy to the CIFS buffer */
 	bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & ~0xFF;
 	if (bytes_sent > count)
 		bytes_sent = count;
 	pSMB->DataLengthHigh = 0;
 	pSMB->DataOffset =
 	    cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4);
-
-	memcpy(pSMB->Data,buf,bytes_sent);
+    if(buf)
+	    memcpy(pSMB->Data,buf,bytes_sent);
+	else if(ubuf)
+		copy_from_user(pSMB->Data,ubuf,bytes_sent);
+    else {
+		/* No buffer */
+		if(pSMB)
+			cifs_buf_release(pSMB);
+		return -EINVAL;
+	}
 
 	byte_count = bytes_sent + 1 /* pad */ ;
 	pSMB->DataLengthLow = cpu_to_le16(bytes_sent);
@@ -787,6 +930,66 @@
 	return rc;
 }
 
+#ifdef CONFIG_CIFS_EXPERIMENTAL
+int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
+	     const int netfid, const unsigned int count,
+	     const __u64 offset, unsigned int *nbytes, const char __user *buf,
+	     const int long_op)
+{
+	int rc = -EACCES;
+	WRITE_REQ *pSMB = NULL;
+	WRITE_RSP *pSMBr = NULL;
+	/*int bytes_returned;*/
+	unsigned bytes_sent;
+	__u16 byte_count;
+
+	rc = small_smb_init(SMB_COM_WRITE_ANDX, 14, tcon, (void **) &pSMB);
+	pSMBr = (WRITE_RSP *)pSMB; /* BB removeme BB */
+    
+    if (rc)
+		return rc;
+	/* tcon and ses pointer are checked in smb_init */
+	if (tcon->ses->server == NULL)
+		return -ECONNABORTED;
+
+	pSMB->AndXCommand = 0xFF; /* none */
+	pSMB->Fid = netfid;
+	pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF);
+	pSMB->OffsetHigh = cpu_to_le32(offset >> 32);
+	pSMB->Reserved = 0xFFFFFFFF;
+	pSMB->WriteMode = 0;
+	pSMB->Remaining = 0;
+	bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & ~0xFF;
+	if (bytes_sent > count)
+		bytes_sent = count;
+	pSMB->DataLengthHigh = 0;
+	pSMB->DataOffset =
+	    cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4);
+
+	byte_count = bytes_sent + 1 /* pad */ ;
+	pSMB->DataLengthLow = cpu_to_le16(bytes_sent);
+	pSMB->DataLengthHigh = 0;
+	pSMB->hdr.smb_buf_length += byte_count;
+	pSMB->ByteCount = cpu_to_le16(byte_count);
+
+/*	rc = SendReceive2(xid, tcon->ses, (struct smb_hdr *) pSMB,
+			 (struct smb_hdr *) pSMBr, buf, buflen, &bytes_returned, long_op); */  /* BB fixme BB */
+	if (rc) {
+		cFYI(1, ("Send error in write2 (large write) = %d", rc));
+		*nbytes = 0;
+	} else
+		*nbytes = le16_to_cpu(pSMBr->Count);
+
+	if (pSMB)
+		cifs_small_buf_release(pSMB);
+
+	/* Note: On -EAGAIN error only caller can retry on handle based calls 
+		since file handle passed in no longer valid */
+
+	return rc;
+}
+#endif /* CIFS_EXPERIMENTAL */
+
 int
 CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
 	    const __u16 smb_file_id, const __u64 len,
@@ -861,8 +1064,8 @@
 	cFYI(1, ("In CIFSSMBClose"));
 
 /* do not retry on dead session on close */
-	rc = smb_init(SMB_COM_CLOSE, 3, tcon, (void **) &pSMB,
-		      (void **) &pSMBr);
+	rc = small_smb_init(SMB_COM_CLOSE, 3, tcon, (void **) &pSMB);
+	pSMBr = (CLOSE_RSP *)pSMB; /* BB removeme BB */
 	if(rc == -EAGAIN)
 		return 0;
 	if (rc)
@@ -879,8 +1082,9 @@
 			cERROR(1, ("Send error in Close = %d", rc));
 		}
 	}
+
 	if (pSMB)
-		cifs_buf_release(pSMB);
+		cifs_small_buf_release(pSMB);
 
 	/* Since session is dead, file will be closed on server already */
 	if(rc == -EAGAIN)
@@ -915,7 +1119,7 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
@@ -925,15 +1129,15 @@
 		pSMB->OldFileName[name_len + 1] = 0x00;
 		name_len2 =
 		    cifs_strtoUCS((wchar_t *) & pSMB->
-				  OldFileName[name_len + 2], toName, 530,
+				  OldFileName[name_len + 2], toName, PATH_MAX,
 				  nls_codepage);
 		name_len2 += 1 /* trailing null */  + 1 /* Signature word */ ;
 		name_len2 *= 2;	/* convert to bytes */
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fromName, 530);
+		name_len = strnlen(fromName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->OldFileName, fromName, name_len);
-		name_len2 = strnlen(toName, 530);
+		name_len2 = strnlen(toName, PATH_MAX);
 		name_len2++;	/* trailing null */
 		pSMB->OldFileName[name_len] = 0x04;  /* 2nd buffer format */
 		strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2);
@@ -1014,7 +1218,7 @@
 		sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid);
 	        len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, dummy_string, 24, nls_codepage);
 	} else {
-		len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, target_name, 530, nls_codepage);
+		len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, target_name, PATH_MAX, nls_codepage);
 	}
 	rename_info->target_name_len = cpu_to_le32(2 * len_of_str);
 	count = 12 /* sizeof(struct set_file_rename) */ + (2 * len_of_str) + 2;
@@ -1073,7 +1277,7 @@
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len = cifs_strtoUCS((wchar_t *) pSMB->OldFileName, 
 				fromName, 
-				530 /* find define for this maxpathcomponent */,
+				PATH_MAX /* find define for this maxpathcomponent */,
 				nls_codepage);
 		name_len++;     /* trailing null */
 		name_len *= 2;
@@ -1081,15 +1285,15 @@
 		/* protocol requires ASCII signature byte on Unicode string */
 		pSMB->OldFileName[name_len + 1] = 0x00;
 		name_len2 = cifs_strtoUCS((wchar_t *) & pSMB->
-				OldFileName[name_len + 2], toName, 530,
+				OldFileName[name_len + 2], toName, PATH_MAX,
 				nls_codepage);
 		name_len2 += 1 /* trailing null */  + 1 /* Signature word */ ;
 		name_len2 *= 2; /* convert to bytes */
 	} else {                /* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fromName, 530);
+		name_len = strnlen(fromName, PATH_MAX);
 		name_len++;     /* trailing null */
 		strncpy(pSMB->OldFileName, fromName, name_len);
-		name_len2 = strnlen(toName, 530);
+		name_len2 = strnlen(toName, PATH_MAX);
 		name_len2++;    /* trailing null */
 		pSMB->OldFileName[name_len] = 0x04;  /* 2nd buffer format */
 		strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2);
@@ -1139,14 +1343,14 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fromName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fromName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fromName, 530);
+		name_len = strnlen(fromName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, fromName, name_len);
 	}
@@ -1163,13 +1367,13 @@
 	data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len_target =
-		    cifs_strtoUCS((wchar_t *) data_offset, toName, 530
+		    cifs_strtoUCS((wchar_t *) data_offset, toName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len_target++;	/* trailing null */
 		name_len_target *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len_target = strnlen(toName, 530);
+		name_len_target = strnlen(toName, PATH_MAX);
 		name_len_target++;	/* trailing null */
 		strncpy(data_offset, toName, name_len_target);
 	}
@@ -1230,14 +1434,14 @@
 		return rc;
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
-		name_len = cifs_strtoUCS((wchar_t *) pSMB->FileName, toName, 530
+		name_len = cifs_strtoUCS((wchar_t *) pSMB->FileName, toName, PATH_MAX
 					 /* find define for this maxpathcomponent */
 					 , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(toName, 530);
+		name_len = strnlen(toName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, toName, name_len);
 	}
@@ -1254,13 +1458,13 @@
 	data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len_target =
-		    cifs_strtoUCS((wchar_t *) data_offset, fromName, 530
+		    cifs_strtoUCS((wchar_t *) data_offset, fromName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len_target++;	/* trailing null */
 		name_len_target *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len_target = strnlen(fromName, 530);
+		name_len_target = strnlen(fromName, PATH_MAX);
 		name_len_target++;	/* trailing null */
 		strncpy(data_offset, fromName, name_len_target);
 	}
@@ -1326,7 +1530,7 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
@@ -1335,15 +1539,15 @@
 		pSMB->OldFileName[name_len + 1] = 0x04; 
 		name_len2 =
 		    cifs_strtoUCS((wchar_t *) & pSMB->
-				  OldFileName[name_len + 2], toName, 530,
+				  OldFileName[name_len + 2], toName, PATH_MAX,
 				  nls_codepage);
 		name_len2 += 1 /* trailing null */  + 1 /* Signature word */ ;
 		name_len2 *= 2;	/* convert to bytes */
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fromName, 530);
+		name_len = strnlen(fromName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->OldFileName, fromName, name_len);
-		name_len2 = strnlen(toName, 530);
+		name_len2 = strnlen(toName, PATH_MAX);
 		name_len2++;	/* trailing null */
 		pSMB->OldFileName[name_len] = 0x04;	/* 2nd buffer format */
 		strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2);
@@ -1392,13 +1596,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(searchName, 530);
+		name_len = strnlen(searchName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, searchName, name_len);
 	}
@@ -1432,13 +1636,17 @@
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
 		cFYI(1, ("Send error in QuerySymLinkInfo = %d", rc));
-	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
-		__u16 count = le16_to_cpu(pSMBr->DataCount);
-		if ((pSMBr->ByteCount < 2) || (data_offset > 512))
+	} else {
+		/* decode response */
+
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+		if (rc || (pSMBr->ByteCount < 2))
 		/* BB also check enough total bytes returned */
 			rc = -EIO;	/* bad smb */
 		else {
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
+			__u16 count = le16_to_cpu(pSMBr->t2.DataCount);
+
 			if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) {
 				name_len = UniStrnlen((wchar_t *) ((char *)
 					&pSMBr->hdr.Protocol +data_offset),
@@ -1550,6 +1758,306 @@
 	return rc;
 }
 
+#ifdef CONFIG_CIFS_POSIX
+
+/*Convert an Access Control Entry from wire format to local POSIX xattr format*/
+static void cifs_convert_ace(posix_acl_xattr_entry * ace, struct cifs_posix_ace * cifs_ace)
+{
+	/* u8 cifs fields do not need le conversion */
+	ace->e_perm = (__u16)cifs_ace->cifs_e_perm; 
+	ace->e_tag  = (__u16)cifs_ace->cifs_e_tag;
+	ace->e_id   = (__u32)le64_to_cpu(cifs_ace->cifs_uid);
+	/* cFYI(1,("perm %d tag %d id %d",ace->e_perm,ace->e_tag,ace->e_id)); */
+
+	return;
+}
+
+/* Convert ACL from CIFS POSIX wire format to local Linux POSIX ACL xattr */
+static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,const int acl_type,const int size_of_data_area)
+{
+	int size =  0;
+	int i;
+	__u16 count;
+	struct cifs_posix_ace * pACE;
+	struct cifs_posix_acl * cifs_acl = (struct cifs_posix_acl *)src;
+	posix_acl_xattr_header * local_acl = (posix_acl_xattr_header *)trgt;
+
+	if (le16_to_cpu(cifs_acl->version) != CIFS_ACL_VERSION)
+		return -EOPNOTSUPP;
+
+	if(acl_type & ACL_TYPE_ACCESS) {
+		count = le16_to_cpu(cifs_acl->access_entry_count);
+		pACE = &cifs_acl->ace_array[0];
+		size = sizeof(struct cifs_posix_acl);
+		size += sizeof(struct cifs_posix_ace) * count;
+		/* check if we would go beyond end of SMB */
+		if(size_of_data_area < size) {
+			cFYI(1,("bad CIFS POSIX ACL size %d vs. %d",size_of_data_area,size));
+			return -EINVAL;
+		}
+	} else if(acl_type & ACL_TYPE_DEFAULT) {
+		count = le16_to_cpu(cifs_acl->access_entry_count);
+		size = sizeof(struct cifs_posix_acl);
+		size += sizeof(struct cifs_posix_ace) * count;
+/* skip past access ACEs to get to default ACEs */
+		pACE = &cifs_acl->ace_array[count];
+		count = le16_to_cpu(cifs_acl->default_entry_count);
+		size += sizeof(struct cifs_posix_ace) * count;
+		/* check if we would go beyond end of SMB */
+		if(size_of_data_area < size)
+			return -EINVAL;
+	} else {
+		/* illegal type */
+		return -EINVAL;
+	}
+
+	size = posix_acl_xattr_size(count);
+	if((buflen == 0) || (local_acl == NULL)) {
+		/* used to query ACL EA size */				
+	} else if(size > buflen) {
+		return -ERANGE;
+	} else /* buffer big enough */ {
+		local_acl->a_version = POSIX_ACL_XATTR_VERSION;
+		for(i = 0;i < count ;i++) {
+			cifs_convert_ace(&local_acl->a_entries[i],pACE);
+			pACE ++;
+		}
+	}
+	return size;
+}
+
+__u16 convert_ace_to_cifs_ace(struct cifs_posix_ace * cifs_ace,
+			const posix_acl_xattr_entry * local_ace)
+{
+	__u16 rc = 0; /* 0 = ACL converted ok */
+
+	cifs_ace->cifs_e_perm = (__u8)cpu_to_le16(local_ace->e_perm);
+	cifs_ace->cifs_e_tag =  (__u8)cpu_to_le16(local_ace->e_tag);
+	/* BB is there a better way to handle the large uid? */
+	if(local_ace->e_id == -1) {
+	/* Probably no need to le convert -1 on any arch but can not hurt */
+		cifs_ace->cifs_uid = cpu_to_le64(-1);
+	} else 
+		cifs_ace->cifs_uid = (__u64)cpu_to_le32(local_ace->e_id);
+        /*cFYI(1,("perm %d tag %d id %d",ace->e_perm,ace->e_tag,ace->e_id));*/
+	return rc;
+}
+
+/* Convert ACL from local Linux POSIX xattr to CIFS POSIX ACL wire format */
+__u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int buflen,
+		const int acl_type)
+{
+	__u16 rc = 0;
+        struct cifs_posix_acl * cifs_acl = (struct cifs_posix_acl *)parm_data;
+        posix_acl_xattr_header * local_acl = (posix_acl_xattr_header *)pACL;
+	int count;
+	int i;
+
+	if((buflen == 0) || (pACL == NULL) || (cifs_acl == NULL))
+		return 0;
+
+	count = posix_acl_xattr_count((size_t)buflen);
+	cFYI(1,("setting acl with %d entries from buf of length %d and version of %d",
+		count,buflen,local_acl->a_version));
+	if(local_acl->a_version != 2) {
+		cFYI(1,("unknown POSIX ACL version %d",local_acl->a_version));
+		return 0;
+	}
+	cifs_acl->version = cpu_to_le16(1);
+	if(acl_type == ACL_TYPE_ACCESS) 
+		cifs_acl->access_entry_count = count;
+	else if(acl_type == ACL_TYPE_DEFAULT)
+		cifs_acl->default_entry_count = count;
+	else {
+		cFYI(1,("unknown ACL type %d",acl_type));
+		return 0;
+	}
+	for(i=0;i<count;i++) {
+		rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i],
+					&local_acl->a_entries[i]);
+		if(rc != 0) {
+			/* ACE not converted */
+			break;
+		}
+	}
+	if(rc == 0) {
+		rc = (__u16)(count * sizeof(struct cifs_posix_ace));
+		rc += sizeof(struct cifs_posix_acl);
+		/* BB add check to make sure ACL does not overflow SMB */
+	}
+	return rc;
+}
+
+int
+CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon,
+                        const unsigned char *searchName,
+                        char *acl_inf, const int buflen, const int acl_type,
+                        const struct nls_table *nls_codepage)
+{
+/* SMB_QUERY_POSIX_ACL */
+	TRANSACTION2_QPI_REQ *pSMB = NULL;
+	TRANSACTION2_QPI_RSP *pSMBr = NULL;
+	int rc = 0;
+	int bytes_returned;
+	int name_len;
+	__u16 params, byte_count;
+                                                                                                                                             
+	cFYI(1, ("In GetPosixACL (Unix) for path %s", searchName));
+
+queryAclRetry:
+	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
+		(void **) &pSMBr);
+	if (rc)
+		return rc;
+                                                                                                                                             
+	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
+		name_len =
+			cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
+				/* BB fixme find define for this maxpathcomponent */
+				, nls_codepage);
+		name_len++;     /* trailing null */
+		name_len *= 2;
+		pSMB->FileName[name_len] = 0;
+		pSMB->FileName[name_len+1] = 0;
+	} else {                /* BB improve the check for buffer overruns BB */
+		name_len = strnlen(searchName, PATH_MAX /* BB fixme */);
+		name_len++;     /* trailing null */
+		strncpy(pSMB->FileName, searchName, name_len);
+	}
+
+	params = 2 /* level */  + 4 /* rsrvd */  + name_len /* incl null */ ;
+	pSMB->TotalDataCount = 0;
+	pSMB->MaxParameterCount = cpu_to_le16(2);
+        /* BB find exact max data count below from sess structure BB */
+	pSMB->MaxDataCount = cpu_to_le16(4000);
+	pSMB->MaxSetupCount = 0;
+	pSMB->Reserved = 0;
+	pSMB->Flags = 0;
+	pSMB->Timeout = 0;
+	pSMB->Reserved2 = 0;
+	pSMB->ParameterOffset = cpu_to_le16(
+		offsetof(struct smb_com_transaction2_qpi_req ,InformationLevel) - 4);
+	pSMB->DataCount = 0;
+	pSMB->DataOffset = 0;
+	pSMB->SetupCount = 1;
+	pSMB->Reserved3 = 0;
+	pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION);
+	byte_count = params + 1 /* pad */ ;
+	pSMB->TotalParameterCount = cpu_to_le16(params);
+	pSMB->ParameterCount = pSMB->TotalParameterCount;
+	pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_POSIX_ACL);
+	pSMB->Reserved4 = 0;
+	pSMB->hdr.smb_buf_length += byte_count;
+	pSMB->ByteCount = cpu_to_le16(byte_count);
+
+	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
+		(struct smb_hdr *) pSMBr, &bytes_returned, 0);
+	if (rc) {
+		cFYI(1, ("Send error in Query POSIX ACL = %d", rc));
+	} else {
+		/* decode response */
+ 
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+		if (rc || (pSMBr->ByteCount < 2))
+		/* BB also check enough total bytes returned */
+			rc = -EIO;      /* bad smb */
+		else {
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
+			__u16 count = le16_to_cpu(pSMBr->t2.DataCount);
+			rc = cifs_copy_posix_acl(acl_inf,
+				(char *)&pSMBr->hdr.Protocol+data_offset,
+				buflen,acl_type,count);
+		}
+	}
+	if (pSMB)
+		cifs_buf_release(pSMB);
+	if (rc == -EAGAIN)
+		goto queryAclRetry;
+	return rc;
+}
+
+int
+CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon,
+                        const unsigned char *fileName,
+                        const char *local_acl, const int buflen, const int acl_type,
+                        const struct nls_table *nls_codepage)
+{
+	struct smb_com_transaction2_spi_req *pSMB = NULL;
+	struct smb_com_transaction2_spi_rsp *pSMBr = NULL;
+	char *parm_data;
+	int name_len;
+	int rc = 0;
+	int bytes_returned = 0;
+	__u16 params, byte_count, data_count, param_offset, offset;
+
+	cFYI(1, ("In SetPosixACL (Unix) for path %s", fileName));
+setAclRetry:
+	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
+                      (void **) &pSMBr);
+	if (rc)
+		return rc;
+                                                                                                               	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
+		name_len =
+			cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX
+				/* BB fixme find define for this maxpathcomponent */
+				, nls_codepage);
+		name_len++;     /* trailing null */
+		name_len *= 2;
+	} else {                /* BB improve the check for buffer overruns BB */
+		name_len = strnlen(fileName, PATH_MAX);
+		name_len++;     /* trailing null */
+		strncpy(pSMB->FileName, fileName, name_len);
+	}
+	params = 6 + name_len;
+	pSMB->MaxParameterCount = cpu_to_le16(2);
+	pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB size from sess */
+	pSMB->MaxSetupCount = 0;
+	pSMB->Reserved = 0;
+	pSMB->Flags = 0;
+	pSMB->Timeout = 0;
+	pSMB->Reserved2 = 0;
+	param_offset = offsetof(struct smb_com_transaction2_spi_req,
+                                     InformationLevel) - 4;
+	offset = param_offset + params;
+	parm_data = ((char *) &pSMB->hdr.Protocol) + offset;
+	pSMB->ParameterOffset = cpu_to_le16(param_offset);
+
+	/* convert to on the wire format for POSIX ACL */
+	data_count = ACL_to_cifs_posix(parm_data,local_acl,buflen,acl_type);
+
+	if(data_count == 0) {
+		rc = -EOPNOTSUPP;
+		goto setACLerrorExit;
+	}
+	pSMB->DataOffset = cpu_to_le16(offset);
+	pSMB->SetupCount = 1;
+	pSMB->Reserved3 = 0;
+	pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION);
+	pSMB->InformationLevel = cpu_to_le16(SMB_SET_POSIX_ACL);
+	byte_count = 3 /* pad */  + params + data_count;
+	pSMB->DataCount = cpu_to_le16(data_count);
+	pSMB->TotalDataCount = pSMB->DataCount;
+	pSMB->ParameterCount = cpu_to_le16(params);
+	pSMB->TotalParameterCount = pSMB->ParameterCount;
+	pSMB->Reserved4 = 0;
+	pSMB->hdr.smb_buf_length += byte_count;
+	pSMB->ByteCount = cpu_to_le16(byte_count);
+	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
+                         (struct smb_hdr *) pSMBr, &bytes_returned, 0);
+	if (rc) {
+		cFYI(1, ("Set POSIX ACL returned %d", rc));
+	}
+
+setACLerrorExit:
+	if (pSMB)
+		cifs_buf_release(pSMB);
+                                                                                                            	if (rc == -EAGAIN)
+		goto setAclRetry;
+                                                                                                           	return rc;
+}
+
+#endif
+
 int
 CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
 		 const unsigned char *searchName,
@@ -1564,7 +2072,7 @@
 	int name_len;
 	__u16 params, byte_count;
 
-	cFYI(1, ("In QPathInfo path %s", searchName));
+/* cFYI(1, ("In QPathInfo path %s", searchName)); */ /* BB fixme BB */
 QPathInfoRetry:
 	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
 		      (void **) &pSMBr);
@@ -1573,13 +2081,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(searchName, 530);
+		name_len = strnlen(searchName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, searchName, name_len);
 	}
@@ -1613,13 +2121,12 @@
 	if (rc) {
 		cFYI(1, ("Send error in QPathInfo = %d", rc));
 	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
-		/* BB also check enough total bytes returned */
-		/* BB we need to improve the validity checking
-		of these trans2 responses */
-		if ((pSMBr->ByteCount < 40) || (data_offset > 512)) 
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+		if (rc || (pSMBr->ByteCount < 40)) 
 			rc = -EIO;	/* bad smb */
 		else if (pFindData){
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
 			memcpy((char *) pFindData,
 			       (char *) &pSMBr->hdr.Protocol +
 			       data_offset, sizeof (FILE_ALL_INFO));
@@ -1657,13 +2164,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(searchName, 530);
+		name_len = strnlen(searchName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, searchName, name_len);
 	}
@@ -1698,15 +2205,12 @@
 	if (rc) {
 		cFYI(1, ("Send error in QPathInfo = %d", rc));
 	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
-		/* BB also check if enough total bytes returned */
-		if ((pSMBr->ByteCount < sizeof(FILE_UNIX_BASIC_INFO)) || 
-			(data_offset > 512) || 
-			(data_offset < sizeof(struct smb_hdr))) {
-			cFYI(1,("UnixQPathinfo invalid data offset %d bytes returned %d",
-					(int)data_offset,bytes_returned));
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+		if (rc || (pSMBr->ByteCount < sizeof(FILE_UNIX_BASIC_INFO))) {
 			rc = -EIO;	/* bad smb */
 		} else {
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
 			memcpy((char *) pFindData,
 			       (char *) &pSMBr->hdr.Protocol +
 			       data_offset,
@@ -1721,6 +2225,7 @@
 	return rc;
 }
 
+#ifdef CONFIG_CIFS_EXPERIMENTAL  /* function unused at present */
 int
 CIFSFindSingle(const int xid, struct cifsTconInfo *tcon,
 	       const char *searchName, FILE_ALL_INFO * findData,
@@ -1743,13 +2248,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(searchName, 530);
+		name_len = strnlen(searchName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, searchName, name_len);
 	}
@@ -1764,7 +2269,7 @@
 	pSMB->Timeout = 0;
 	pSMB->Reserved2 = 0;
 	pSMB->ParameterOffset = cpu_to_le16(
-        offsetof(struct smb_com_transaction2_ffirst_req,InformationLevel) - 4);
+         offsetof(struct smb_com_transaction2_ffirst_req,InformationLevel) - 4);
 	pSMB->DataCount = 0;
 	pSMB->DataOffset = 0;
 	pSMB->SetupCount = 1;	/* one byte, no need to le convert */
@@ -1799,6 +2304,7 @@
 
 	return rc;
 }
+#endif /* CIFS_EXPERIMENTAL */
 
 int
 CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
@@ -1825,13 +2331,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(searchName, 530);
+		name_len = strnlen(searchName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, searchName, name_len);
 	}
@@ -1849,8 +2355,8 @@
 	byte_count = params + 1 /* pad */ ;
 	pSMB->TotalParameterCount = cpu_to_le16(params);
 	pSMB->ParameterCount = pSMB->TotalParameterCount;
-	pSMB->ParameterOffset = cpu_to_le16(offsetof(struct 
-        smb_com_transaction2_ffirst_req, SearchAttributes) - 4);
+	pSMB->ParameterOffset = cpu_to_le16(
+		offsetof(struct smb_com_transaction2_ffirst_req, SearchAttributes) - 4);
 	pSMB->DataCount = 0;
 	pSMB->DataOffset = 0;
 	pSMB->SetupCount = 1;	/* one byte no need to make endian neutral */
@@ -1859,7 +2365,7 @@
 	pSMB->SearchAttributes =
 	    cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM |
 			ATTR_DIRECTORY);
-	pSMB->SearchCount = cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof (FILE_DIRECTORY_INFO));	/* should this be shrunk even more ? */
+	pSMB->SearchCount = cpu_to_le16(CIFSMaxBufSize / sizeof (FILE_DIRECTORY_INFO));	/* should this be shrunk even more ? */
 	pSMB->SearchFlags = cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME);
 
 	/* test for Unix extensions */
@@ -1880,20 +2386,25 @@
 
 	if (rc) {		/* BB add logic to retry regular search if Unix search rejected unexpectedly by server */
 		cFYI(1, ("Error in FindFirst = %d", rc));
-	} else {		/* decode response */
+	} else {
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+		if(!rc) {
+		/* decode response */
 		/* BB add safety checks for these memcpys */
-		if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
-			*pUnicodeFlag = TRUE;
-		else
-			*pUnicodeFlag = FALSE;
-		memcpy(findParms,
-		       (char *) &pSMBr->hdr.Protocol +
-		       le16_to_cpu(pSMBr->ParameterOffset),
-		       sizeof (T2_FFIRST_RSP_PARMS));
-		response_data =
-		    (char *) &pSMBr->hdr.Protocol +
-		    le16_to_cpu(pSMBr->DataOffset);
-		memcpy(findData, response_data, le16_to_cpu(pSMBr->DataCount));
+			if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
+				*pUnicodeFlag = TRUE;
+			else
+				*pUnicodeFlag = FALSE;
+			memcpy(findParms,
+			       (char *) &pSMBr->hdr.Protocol +
+			       le16_to_cpu(pSMBr->t2.ParameterOffset),
+			       sizeof (T2_FFIRST_RSP_PARMS));
+			response_data =
+			    (char *) &pSMBr->hdr.Protocol +
+			    le16_to_cpu(pSMBr->t2.DataOffset);
+			memcpy(findData, response_data, 
+				le16_to_cpu(pSMBr->t2.DataCount));
+		}
 	}
 	if (pSMB)
 		cifs_buf_release(pSMB);
@@ -1904,6 +2415,256 @@
 	return rc;
 }
 
+/* xid, tcon, searchName and codepage are input parms, rest are returned */
+int
+CIFSFindFirst2(const int xid, struct cifsTconInfo *tcon,
+	      const char *searchName, 
+	      const struct nls_table *nls_codepage,
+	      __u16 *	pnetfid,
+	      struct cifs_search_info * psrch_inf)
+{
+/* level 257 SMB_ */
+	TRANSACTION2_FFIRST_REQ *pSMB = NULL;
+	TRANSACTION2_FFIRST_RSP *pSMBr = NULL;
+	T2_FFIRST_RSP_PARMS * parms;
+	int rc = 0;
+	int bytes_returned = 0;
+	int name_len;
+	__u16 params, byte_count;
+
+	cFYI(1, ("In FindFirst2"));
+
+findFirst2Retry:
+	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
+		      (void **) &pSMBr);
+	if (rc)
+		return rc;
+
+	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
+		name_len =
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName,searchName,
+				 PATH_MAX, nls_codepage);
+		name_len++;	/* trailing null */
+		name_len *= 2;
+		pSMB->FileName[name_len] = 0; /* null terminate just in case */
+		pSMB->FileName[name_len+1] = 0;
+	} else {	/* BB add check for overrun of SMB buf BB */
+		name_len = strnlen(searchName, PATH_MAX);
+		name_len++;	/* trailing null */
+/* BB fix here and in unicode clause above ie
+		if(name_len > buffersize-header)
+			free buffer exit; BB */
+		strncpy(pSMB->FileName, searchName, name_len);
+		pSMB->FileName[name_len] = 0; /* just in case */
+	}
+
+	params = 12 + name_len /* includes null */ ;
+	pSMB->TotalDataCount = 0;	/* no EAs */
+	pSMB->MaxParameterCount = cpu_to_le16(10);
+	pSMB->MaxDataCount = cpu_to_le16((tcon->ses->server->maxBuf -
+					  MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);
+	pSMB->MaxSetupCount = 0;
+	pSMB->Reserved = 0;
+	pSMB->Flags = 0;
+	pSMB->Timeout = 0;
+	pSMB->Reserved2 = 0;
+	byte_count = params + 1 /* pad */ ;
+	pSMB->TotalParameterCount = cpu_to_le16(params);
+	pSMB->ParameterCount = pSMB->TotalParameterCount;
+	pSMB->ParameterOffset = cpu_to_le16(
+	  offsetof(struct smb_com_transaction2_ffirst_req, SearchAttributes) - 4);
+	pSMB->DataCount = 0;
+	pSMB->DataOffset = 0;
+	pSMB->SetupCount = 1;	/* one byte, no need to make endian neutral */
+	pSMB->Reserved3 = 0;
+	pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_FIRST);
+	pSMB->SearchAttributes =
+	    cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM |
+			ATTR_DIRECTORY);
+	pSMB->SearchCount= cpu_to_le16(CIFSMaxBufSize/sizeof(FILE_UNIX_INFO));
+	pSMB->SearchFlags = cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | 
+		CIFS_SEARCH_RETURN_RESUME);
+	pSMB->InformationLevel = cpu_to_le16(psrch_inf->info_level);
+
+	/* BB what should we set StorageType to? Does it matter? BB */
+	pSMB->SearchStorageType = 0;
+	pSMB->hdr.smb_buf_length += byte_count;
+	pSMB->ByteCount = cpu_to_le16(byte_count);
+
+	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
+			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
+
+	if (rc) {/* BB add logic to retry regular search if Unix search rejected unexpectedly by server */
+		/* BB Add code to handle unsupported level rc */
+		cFYI(1, ("Error in FindFirst = %d", rc));
+
+		if (pSMB)
+			cifs_buf_release(pSMB);
+
+		/* BB eventually could optimize out free and realloc of buf */
+		/*    for this case */
+		if (rc == -EAGAIN)
+			goto findFirst2Retry;
+	} else { /* decode response */
+		/* BB remember to free buffer if error BB */
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+		if(rc == 0) {
+			if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
+				psrch_inf->unicode = TRUE;
+			else
+				psrch_inf->unicode = FALSE;
+
+			psrch_inf->ntwrk_buf_start = (char *)pSMBr;
+			psrch_inf->srch_entries_start = 
+				(char *) &pSMBr->hdr.Protocol + 
+					le16_to_cpu(pSMBr->t2.DataOffset);
+
+			parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol +
+			       le16_to_cpu(pSMBr->t2.ParameterOffset));
+
+			if(parms->EndofSearch)
+				psrch_inf->endOfSearch = TRUE;
+			else
+				psrch_inf->endOfSearch = FALSE;
+
+			psrch_inf->entries_in_buffer  = le16_to_cpu(parms->SearchCount);
+			psrch_inf->index_of_last_entry = 
+				psrch_inf->entries_in_buffer;
+/*cFYI(1,("entries in buf %d index_of_last %d",psrch_inf->entries_in_buffer,psrch_inf->index_of_last_entry));  */
+			*pnetfid = parms->SearchHandle;
+		} else {
+			if(pSMB)
+				cifs_buf_release(pSMB);
+		}
+	}
+
+	return rc;
+}
+
+int CIFSFindNext2(const int xid, struct cifsTconInfo *tcon,
+            __u16 searchHandle, struct cifs_search_info * psrch_inf)
+{
+	TRANSACTION2_FNEXT_REQ *pSMB = NULL;
+	TRANSACTION2_FNEXT_RSP *pSMBr = NULL;
+	T2_FNEXT_RSP_PARMS * parms;
+	char *response_data;
+	int rc = 0;
+	int bytes_returned, name_len;
+	__u16 params, byte_count;
+
+	cFYI(1, ("In FindNext2"));
+
+	if(psrch_inf->endOfSearch == TRUE)
+		return -ENOENT;
+
+	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
+		(void **) &pSMBr);
+	if (rc)
+		return rc;
+
+	params = 14;    /* includes 2 bytes of null string, converted to LE below */
+	byte_count = 0;
+	pSMB->TotalDataCount = 0;       /* no EAs */
+	pSMB->MaxParameterCount = cpu_to_le16(8);
+	pSMB->MaxDataCount =
+            cpu_to_le16((tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);
+	pSMB->MaxSetupCount = 0;
+	pSMB->Reserved = 0;
+	pSMB->Flags = 0;
+	pSMB->Timeout = 0;
+	pSMB->Reserved2 = 0;
+	pSMB->ParameterOffset =  cpu_to_le16(
+	      offsetof(struct smb_com_transaction2_fnext_req,SearchHandle) - 4);
+	pSMB->DataCount = 0;
+	pSMB->DataOffset = 0;
+	pSMB->SetupCount = 1;
+	pSMB->Reserved3 = 0;
+	pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_NEXT);
+	pSMB->SearchHandle = searchHandle;      /* always kept as le */
+	pSMB->SearchCount =
+		cpu_to_le16(CIFSMaxBufSize / sizeof (FILE_UNIX_INFO));
+	/* test for Unix extensions */
+/*	if (tcon->ses->capabilities & CAP_UNIX) {
+		pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_UNIX);
+		psrch_inf->info_level = SMB_FIND_FILE_UNIX;
+	} else {
+		pSMB->InformationLevel =
+		   cpu_to_le16(SMB_FIND_FILE_DIRECTORY_INFO);
+		psrch_inf->info_level = SMB_FIND_FILE_DIRECTORY_INFO;
+	} */
+	pSMB->InformationLevel = cpu_to_le16(psrch_inf->info_level);
+	pSMB->ResumeKey = psrch_inf->resume_key;
+	pSMB->SearchFlags =
+	      cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME);
+
+	name_len = psrch_inf->resume_name_len;
+	params += name_len;
+	if(name_len < PATH_MAX) {
+		memcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len);
+		byte_count += name_len;
+	} else {
+		rc = -EINVAL;
+		goto FNext2_err_exit;
+	}
+	byte_count = params + 1 /* pad */ ;
+	pSMB->TotalParameterCount = cpu_to_le16(params);
+	pSMB->ParameterCount = pSMB->TotalParameterCount;
+	pSMB->hdr.smb_buf_length += byte_count;
+	pSMB->ByteCount = cpu_to_le16(byte_count);
+                                                                                              
+	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
+			(struct smb_hdr *) pSMBr, &bytes_returned, 0);
+                                                                                              
+	if (rc) {
+		if (rc == -EBADF) {
+			psrch_inf->endOfSearch = TRUE;
+			rc = 0; /* search probably was closed at end of search above */
+		} else
+			cFYI(1, ("FindNext returned = %d", rc));
+	} else {                /* decode response */
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+		
+		if(rc == 0) {
+			/* BB fixme add lock for file (srch_info) struct here */
+			if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
+				psrch_inf->unicode = TRUE;
+			else
+				psrch_inf->unicode = FALSE;
+			response_data = (char *) &pSMBr->hdr.Protocol +
+			       le16_to_cpu(pSMBr->t2.ParameterOffset);
+			parms = (T2_FNEXT_RSP_PARMS *)response_data;
+			response_data = (char *)&pSMBr->hdr.Protocol +
+				le16_to_cpu(pSMBr->t2.DataOffset);
+			cifs_buf_release(psrch_inf->ntwrk_buf_start);
+			psrch_inf->srch_entries_start = response_data;
+			psrch_inf->ntwrk_buf_start = (char *)pSMB;
+			if(parms->EndofSearch)
+				psrch_inf->endOfSearch = TRUE;
+			else
+				psrch_inf->endOfSearch = FALSE;
+                                                                                              
+			psrch_inf->entries_in_buffer  = le16_to_cpu(parms->SearchCount);
+			psrch_inf->index_of_last_entry +=
+				psrch_inf->entries_in_buffer;
+/*  cFYI(1,("fnxt2 entries in buf %d index_of_last %d",psrch_inf->entries_in_buffer,psrch_inf->index_of_last_entry)); */
+
+			/* BB fixme add unlock here */
+		}
+
+	}
+
+	/* BB On error, should we leave previous search buf (and count and
+	last entry fields) intact or free the previous one? */
+
+	/* Note: On -EAGAIN error only caller can retry on handle based calls
+	since file handle passed in no longer valid */
+FNext2_err_exit:
+	if ((rc != 0) && pSMB)
+		cifs_buf_release(pSMB);
+                                                                                              
+	return rc;
+}
+
 int
 CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
 		FILE_DIRECTORY_INFO * findData, T2_FNEXT_RSP_PARMS * findParms,
@@ -1939,8 +2700,8 @@
 	pSMB->Flags = 0;
 	pSMB->Timeout = 0;
 	pSMB->Reserved2 = 0;
-	pSMB->ParameterOffset =  cpu_to_le16(offsetof(
-        struct smb_com_transaction2_fnext_req,SearchHandle) - 4);
+	pSMB->ParameterOffset =  cpu_to_le16(
+           offsetof(struct smb_com_transaction2_fnext_req,SearchHandle) - 4);
 	pSMB->DataCount = 0;
 	pSMB->DataOffset = 0;
 	pSMB->SetupCount = 1;
@@ -1949,7 +2710,7 @@
 	pSMB->SearchHandle = searchHandle;	/* always kept as le */
 	findParms->SearchCount = 0;	/* set to zero in case of error */
 	pSMB->SearchCount =
-	    cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof (FILE_DIRECTORY_INFO));
+	    cpu_to_le16(CIFSMaxBufSize / sizeof (FILE_UNIX_INFO));
 	/* test for Unix extensions */
 	if (tcon->ses->capabilities & CAP_UNIX) {
 		pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_UNIX);
@@ -1963,7 +2724,7 @@
 	pSMB->SearchFlags =
 	    cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME);
 	/* BB add check to make sure we do not cross end of smb */
-	if(name_len < CIFS_MAX_MSGSIZE) {
+	if(name_len < PATH_MAX) {
 		memcpy(pSMB->ResumeFileName, resume_file_name, name_len);
 		byte_count += name_len;
 	}
@@ -1984,19 +2745,23 @@
 		else
 			cFYI(1, ("FindNext returned = %d", rc));
 	} else {		/* decode response */
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
 		/* BB add safety checks for these memcpys */
-		if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
-			*pUnicodeFlag = TRUE;
-		else
-			*pUnicodeFlag = FALSE;
-		memcpy(findParms,
-		       (char *) &pSMBr->hdr.Protocol +
-		       le16_to_cpu(pSMBr->ParameterOffset),
-		       sizeof (T2_FNEXT_RSP_PARMS));
-		response_data =
-		    (char *) &pSMBr->hdr.Protocol +
-		    le16_to_cpu(pSMBr->DataOffset);
-		memcpy(findData, response_data, le16_to_cpu(pSMBr->DataCount));
+		if(rc == 0) {
+			if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
+				*pUnicodeFlag = TRUE;
+			else
+				*pUnicodeFlag = FALSE;
+			memcpy(findParms,
+			       (char *) &pSMBr->hdr.Protocol +
+			       le16_to_cpu(pSMBr->t2.ParameterOffset),
+			       sizeof (T2_FNEXT_RSP_PARMS));
+			response_data =
+			    (char *) &pSMBr->hdr.Protocol +
+			    le16_to_cpu(pSMBr->t2.DataOffset);
+			memcpy(findData,response_data,le16_to_cpu(pSMBr->t2.DataCount));
+		}
 	}
 	if (pSMB)
 		cifs_buf_release(pSMB);
@@ -2012,12 +2777,12 @@
 {
 	int rc = 0;
 	FINDCLOSE_REQ *pSMB = NULL;
-	CLOSE_RSP *pSMBr = NULL;
+	CLOSE_RSP *pSMBr = NULL; /* BB removeme BB */
 	int bytes_returned;
 
 	cFYI(1, ("In CIFSSMBFindClose"));
-	rc = smb_init(SMB_COM_FIND_CLOSE2, 1, tcon, (void **) &pSMB,
-		      (void **) &pSMBr);
+	rc = small_smb_init(SMB_COM_FIND_CLOSE2, 1, tcon, (void **)&pSMB);
+	pSMBr = (CLOSE_RSP *)pSMB;  /* BB removeme BB */
 	/* no sense returning error if session restarted
 		file handle has been closed */
 	if(rc == -EAGAIN)
@@ -2033,7 +2798,7 @@
 		cERROR(1, ("Send error in FindClose = %d", rc));
 	}
 	if (pSMB)
-		cifs_buf_release(pSMB);
+		cifs_small_buf_release(pSMB);
 
 	/* Since session is dead, search handle closed on server already */
 	if (rc == -EAGAIN)
@@ -2042,6 +2807,39 @@
 	return rc;
 }
 
+#ifdef CONFIG_CIFS_EXPERIMENTAL
+int
+CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
+                const unsigned char *searchName,
+                __u64 * inode_number,
+                const struct nls_table *nls_codepage)
+{
+	int rc = 0;
+	TRANSACTION2_QPI_REQ *pSMB = NULL;
+	TRANSACTION2_QPI_RSP *pSMBr = NULL;
+
+	cFYI(1,("In GetSrvInodeNumber for %s",searchName));
+	if(tcon == NULL)
+		return -ENODEV; 
+
+        cFYI(1, ("In QPathInfo path %s", searchName));
+GetInodeNumberRetry:
+	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
+                      (void **) &pSMBr);
+	if (rc)
+		return rc;
+
+/* BB add missing code here */
+
+	if (pSMB)
+		cifs_buf_release(pSMB);
+                                                                                                                         
+	if (rc == -EAGAIN)
+		goto GetInodeNumberRetry;
+	return rc;
+}
+#endif /* CIFS_EXPERIMENTAL */
+
 int
 CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
 		const unsigned char *searchName,
@@ -2084,13 +2882,13 @@
 		pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
 		name_len =
 		    cifs_strtoUCS((wchar_t *) pSMB->RequestFileName,
-				  searchName, 530
+				  searchName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(searchName, 530);
+		name_len = strnlen(searchName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->RequestFileName, searchName, name_len);
 	}
@@ -2124,14 +2922,17 @@
 		cFYI(1, ("Send error in GetDFSRefer = %d", rc));
 	} else {		/* decode response */
 /* BB Add logic to parse referrals here */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
-		__u16 data_count = le16_to_cpu(pSMBr->DataCount);
-		cFYI(1,
-		     ("Decoding GetDFSRefer response.  BCC: %d  Offset %d",
-		      pSMBr->ByteCount, data_offset));
-		if ((pSMBr->ByteCount < 17) || (data_offset > 512))	/* BB also check enough total bytes returned */
-			rc = -EIO;	/* bad smb */
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+		if (rc || (pSMBr->ByteCount < 17))      /* BB also check enough total bytes returned */
+			rc = -EIO;      /* bad smb */
 		else {
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 
+			__u16 data_count = le16_to_cpu(pSMBr->t2.DataCount);
+
+			cFYI(1,
+			     ("Decoding GetDFSRefer response.  BCC: %d  Offset %d",
+			      pSMBr->ByteCount, data_offset));
 			referrals = 
 			    (struct dfs_referral_level_3 *) 
 					(8 /* sizeof start of data block */ +
@@ -2257,13 +3058,16 @@
 	if (rc) {
 		cERROR(1, ("Send error in QFSInfo = %d", rc));
 	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
-		cFYI(1,
-		     ("Decoding qfsinfo response.  BCC: %d  Offset %d",
-		      pSMBr->ByteCount, data_offset));
-		if ((pSMBr->ByteCount < 24) || (data_offset > 512))	/* BB also check enough total bytes returned */
+                rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+		if (rc || (pSMBr->ByteCount < 24)) /* BB alsO CHEck enough total bytes returned */
 			rc = -EIO;	/* bad smb */
 		else {
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
+			cFYI(1,
+				("Decoding qfsinfo response.  BCC: %d  Offset %d",
+				pSMBr->ByteCount, data_offset));
+
 			response_data =
 			    (FILE_SYSTEM_INFO
 			     *) (((char *) &pSMBr->hdr.Protocol) +
@@ -2339,10 +3143,12 @@
 	if (rc) {
 		cERROR(1, ("Send error in QFSAttributeInfo = %d", rc));
 	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
-		if ((pSMBr->ByteCount < 13) || (data_offset > 512)) {	/* BB also check enough bytes returned */
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+		if (rc || (pSMBr->ByteCount < 13)) {	/* BB also check enough bytes returned */
 			rc = -EIO;	/* bad smb */
 		} else {
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
 			response_data =
 			    (FILE_SYSTEM_ATTRIBUTE_INFO
 			     *) (((char *) &pSMBr->hdr.Protocol) +
@@ -2408,11 +3214,12 @@
 	if (rc) {
 		cFYI(1, ("Send error in QFSDeviceInfo = %d", rc));
 	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
-		if ((pSMBr->ByteCount < sizeof (FILE_SYSTEM_DEVICE_INFO))
-                 || (data_offset > 512))
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+		if (rc || (pSMBr->ByteCount < sizeof (FILE_SYSTEM_DEVICE_INFO)))
 			rc = -EIO;	/* bad smb */
 		else {
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
 			response_data =
 			    (FILE_SYSTEM_DEVICE_INFO
 			     *) (((char *) &pSMBr->hdr.Protocol) +
@@ -2477,10 +3284,12 @@
 	if (rc) {
 		cERROR(1, ("Send error in QFSUnixInfo = %d", rc));
 	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
-		if ((pSMBr->ByteCount < 13) || (data_offset > 512)) {
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+		if (rc || (pSMBr->ByteCount < 13)) {
 			rc = -EIO;	/* bad smb */
 		} else {
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
 			response_data =
 			    (FILE_SYSTEM_UNIX_INFO
 			     *) (((char *) &pSMBr->hdr.Protocol) +
@@ -2526,13 +3335,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fileName, 530);
+		name_len = strnlen(fileName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, fileName, name_len);
 	}
@@ -2705,13 +3514,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fileName, 530);
+		name_len = strnlen(fileName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, fileName, name_len);
 	}
@@ -2785,13 +3594,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fileName, 530);
+		name_len = strnlen(fileName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, fileName, name_len);
 	}
@@ -2821,12 +3630,7 @@
 	pSMB->ParameterCount = cpu_to_le16(params);
 	pSMB->TotalDataCount = pSMB->DataCount;
 	pSMB->TotalParameterCount = pSMB->ParameterCount;
-	/* I doubt that passthrough levels apply to this old
-	preNT info level */
-/*	if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
-		pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_BASIC_INFO2);
-	else*/
-		pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD);
+	pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD);
 	pSMB->Reserved4 = 0;
 	pSMB->hdr.smb_buf_length += byte_count;
 	memcpy(data_offset, data, sizeof (FILE_INFO_STANDARD));
@@ -2868,13 +3672,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fileName, 530);
+		name_len = strnlen(fileName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, fileName, name_len);
 	}
@@ -2894,6 +3698,7 @@
 	data_offset =
 	    (FILE_UNIX_BASIC_INFO *) ((char *) &pSMB->hdr.Protocol +
 				      offset);
+	memset(data_offset, 0, count);
 	pSMB->DataOffset = cpu_to_le16(offset);
 	pSMB->ParameterOffset = cpu_to_le16(param_offset);
 	pSMB->SetupCount = 1;
@@ -2980,7 +3785,7 @@
 	pSMB->ByteCount = 0;
 
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
-			(struct smb_hdr *) pSMBr, &bytes_returned, 0);
+			(struct smb_hdr *) pSMBr, &bytes_returned, -1);
 	if (rc) {
 		cFYI(1, ("Error in Notify = %d", rc));
 	}
@@ -3016,13 +3821,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {	/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(searchName, 530);
+		name_len = strnlen(searchName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, searchName, name_len);
 	}
@@ -3056,11 +3861,12 @@
 	if (rc) {
 		cFYI(1, ("Send error in QueryAllEAs = %d", rc));
 	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
 		/* BB also check enough total bytes returned */
 		/* BB we need to improve the validity checking
 		of these trans2 responses */
-		if ((pSMBr->ByteCount < 4) || (data_offset > 512)) 
+		if (rc || (pSMBr->ByteCount < 4)) 
 			rc = -EIO;	/* bad smb */
 	   /* else if (pFindData){
 			memcpy((char *) pFindData,
@@ -3072,6 +3878,7 @@
 			   of list */
 			/* check that each element of each entry does not
 			   go beyond end of list */
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
 			struct fealist * ea_response_data;
 			rc = 0;
 			/* validate_trans2_offsets() */
@@ -3158,13 +3965,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {	/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(searchName, 530);
+		name_len = strnlen(searchName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, searchName, name_len);
 	}
@@ -3198,11 +4005,12 @@
 	if (rc) {
 		cFYI(1, ("Send error in Query EA = %d", rc));
 	} else {		/* decode response */
-		__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
+		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
 		/* BB also check enough total bytes returned */
 		/* BB we need to improve the validity checking
 		of these trans2 responses */
-		if ((pSMBr->ByteCount < 4) || (data_offset > 512)) 
+		if (rc || (pSMBr->ByteCount < 4)) 
 			rc = -EIO;	/* bad smb */
 	   /* else if (pFindData){
 			memcpy((char *) pFindData,
@@ -3214,8 +4022,9 @@
 			   of list */
 			/* check that each element of each entry does not
 			   go beyond end of list */
+			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
 			struct fealist * ea_response_data;
-			rc = -ENOENT;
+			rc = -ENODATA;
 			/* validate_trans2_offsets() */
 			/* BB to check if(start of smb + data_offset > &bcc+ bcc)*/
 			ea_response_data = (struct fealist *)
@@ -3303,13 +4112,13 @@
 
 	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
 		name_len =
-		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, 530
+		    cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX
 				  /* find define for this maxpathcomponent */
 				  , nls_codepage);
 		name_len++;	/* trailing null */
 		name_len *= 2;
 	} else {		/* BB improve the check for buffer overruns BB */
-		name_len = strnlen(fileName, 530);
+		name_len = strnlen(fileName, PATH_MAX);
 		name_len++;	/* trailing null */
 		strncpy(pSMB->FileName, fileName, name_len);
 	}
diff -Nru a/fs/cifs/connect.c b/fs/cifs/connect.c
--- a/fs/cifs/connect.c	2004-12-24 13:37:19 -08:00
+++ b/fs/cifs/connect.c	2004-12-24 13:37:19 -08:00
@@ -58,6 +58,7 @@
 	char *domainname;
 	char *UNC;
 	char *UNCip;
+	char *in6_addr;  /* ipv6 address as human readable form of in6_addr */
 	char *iocharset;  /* local code page for mapping to and from Unicode */
 	char source_rfc1001_name[16]; /* netbios name of client */
 	uid_t linux_uid;
@@ -69,6 +70,9 @@
 	unsigned intr:1;
 	unsigned setuids:1;
 	unsigned noperm:1;
+	unsigned no_psx_acl:1; /* set if posix acl support should be disabled */
+	unsigned server_ino:1; /* use inode numbers from server ie UniqueId */
+	unsigned direct_io:1;
 	unsigned int rsize;
 	unsigned int wsize;
 	unsigned int sockopt;
@@ -213,7 +217,7 @@
 	write_unlock(&GlobalSMBSeslock);
 	if(length  > 1) {
 		mempool_resize(cifs_req_poolp,
-			length + CIFS_MIN_RCV_POOL,
+			length + cifs_min_rcv,
 			GFP_KERNEL);
 	}
 
@@ -250,7 +254,8 @@
 			cFYI(1,("call to reconnect done"));
 			csocket = server->ssocket;
 			continue;
-		} else if ((length == -ERESTARTSYS) || (length == -EAGAIN)) {
+		} else if ((length == -ERESTARTSYS) || (length == -EAGAIN)
+				|| ((length > 0) && (length <= 3)) ) {
 			set_current_state(TASK_INTERRUPTIBLE);
 			schedule_timeout(1); /* minimum sleep to prevent looping
 				allowing socket to clear and app threads to set
@@ -276,7 +281,7 @@
 		}
 
 		pdu_length = 4 + ntohl(smb_buffer->smb_buf_length);
-		/* Ony read pdu_length after below checks for too short (due
+		/* Only read pdu_length after below checks for too short (due
 		   to e.g. int overflow) and too long ie beyond end of buf */
 		cFYI(1, ("Peek length rcvd: 0x%x beginning 0x%x)", length, pdu_length));
 
@@ -326,18 +331,24 @@
 				csocket = server->ssocket;
 				continue;
 			} else {
-				if ((length != sizeof (struct smb_hdr) - 1)
-				    || (pdu_length >
-					CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE)
+				if (length < 16) {
+					/* We can not validate the SMB unless 
+					at least this much of SMB available
+					so give the socket time to copy
+					a few more bytes and retry */ 
+					set_current_state(TASK_INTERRUPTIBLE);
+					schedule_timeout(10);
+					continue;
+				} else if( (pdu_length >
+					CIFSMaxBufSize + MAX_CIFS_HDR_SIZE)
 				    || (pdu_length <
 					sizeof (struct smb_hdr) - 1)
-				    ||
-				    (checkSMBhdr
+				    || (checkSMBhdr
 				     (smb_buffer, smb_buffer->Mid))) {
 					cERROR(1,
-					    ("Invalid size or format for SMB found with length %d and pdu_lenght %d",
+					    ("Invalid size or format for SMB found with length %d and pdu_length %d",
 						length, pdu_length));
-					cifs_dump_mem("Received Data is: ",temp,sizeof(struct smb_hdr));
+					cifs_dump_mem("Received Data is: ",temp,sizeof(struct smb_hdr)+3);
 					/* could we fix this network corruption by finding next 
 						smb header (instead of killing the session) and
 						restart reading from next valid SMB found? */
@@ -485,7 +496,7 @@
 	write_unlock(&GlobalSMBSeslock);
 	if(length  > 0) {
 		mempool_resize(cifs_req_poolp,
-			length + CIFS_MIN_RCV_POOL,
+			length + cifs_min_rcv,
 			GFP_KERNEL);
 	}
 
@@ -505,7 +516,7 @@
 }
 
 static int
-cifs_parse_mount_options(char *options, const char *devname, struct smb_vol *vol)
+cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
 {
 	char *value;
 	char *data;
@@ -692,7 +703,12 @@
 				vol->file_mode =
 					simple_strtoul(value, &value, 0);
 			}
-		} else if (strnicmp(data, "dir_mode", 3) == 0) {
+		} else if (strnicmp(data, "dir_mode", 4) == 0) {
+			if (value && *value) {
+				vol->dir_mode =
+					simple_strtoul(value, &value, 0);
+			}
+		} else if (strnicmp(data, "dirmode", 4) == 0) {
 			if (value && *value) {
 				vol->dir_mode =
 					simple_strtoul(value, &value, 0);
@@ -742,6 +758,8 @@
 			/* ignore */
 		} else if (strnicmp(data, "version", 3) == 0) {
 			/* ignore */
+		} else if (strnicmp(data, "guest",5) == 0) {
+			/* ignore */
 		} else if (strnicmp(data, "rw", 2) == 0) {
 			vol->rw = TRUE;
 		} else if ((strnicmp(data, "suid", 4) == 0) ||
@@ -780,6 +798,27 @@
 			vol->intr = 0;
 		} else if (strnicmp(data, "intr", 4) == 0) {
 			vol->intr = 1;
+		} else if (strnicmp(data, "serverino",7) == 0) {
+			vol->server_ino = 1;
+		} else if (strnicmp(data, "noserverino",9) == 0) {
+			vol->server_ino = 0;
+		} else if (strnicmp(data, "acl",3) == 0) {
+			vol->no_psx_acl = 0;
+		} else if (strnicmp(data, "noacl",5) == 0) {
+			vol->no_psx_acl = 1;
+		} else if (strnicmp(data, "direct",6) == 0) {
+			vol->direct_io = 1;
+		} else if (strnicmp(data, "forcedirectio",13) == 0) {
+			vol->direct_io = 1;
+		} else if (strnicmp(data, "in6_addr",8) == 0) {
+			if (!value || !*value) {
+				vol->in6_addr = NULL;
+			} else if (strnlen(value, 49) == 48) {
+				vol->in6_addr = value;
+			} else {
+				printk(KERN_WARNING "CIFS: ip v6 address not 48 characters long\n");
+				return 1;
+			}
 		} else if (strnicmp(data, "noac", 4) == 0) {
 			printk(KERN_WARNING "CIFS: Mount option noac not supported. Instead set /proc/fs/cifs/LookupCacheEnabled to 0\n");
 		} else
@@ -1393,6 +1432,12 @@
 			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
 		if(volume_info.setuids)
 			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
+		if(volume_info.server_ino)
+			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
+		if(volume_info.direct_io) {
+			cERROR(1,("mounting share using direct i/o"));
+			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
+		}
 
 		tcon =
 		    find_unc(sin_server.sin_addr.s_addr, volume_info.UNC,
@@ -1482,8 +1527,16 @@
 		/* do not care if following two calls succeed - informational only */
 		CIFSSMBQFSDeviceInfo(xid, tcon, cifs_sb->local_nls);
 		CIFSSMBQFSAttributeInfo(xid, tcon, cifs_sb->local_nls);
-		if (tcon->ses->capabilities & CAP_UNIX)
-			CIFSSMBQFSUnixInfo(xid, tcon, cifs_sb->local_nls);
+		if (tcon->ses->capabilities & CAP_UNIX) {
+			if(!CIFSSMBQFSUnixInfo(xid, tcon, cifs_sb->local_nls)) {
+				if(!volume_info.no_psx_acl) {
+					if(CIFS_UNIX_POSIX_ACL_CAP & 
+					   le64_to_cpu(tcon->fsUnixInfo.Capability))
+						cFYI(1,("server negotiated posix acl support"));
+						sb->s_flags |= MS_POSIXACL;
+				}
+			}
+		}
 	}
 
 	/* volume_info.password is freed above when existing session found
@@ -1552,14 +1605,15 @@
 		capabilities |= CAP_DFS;
 	}
 	pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
-	/* pSMB->req_no_secext.CaseInsensitivePasswordLength =
-	   CIFS_SESSION_KEY_SIZE; */
-	pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
+
+	pSMB->req_no_secext.CaseInsensitivePasswordLength = 
+		cpu_to_le16(CIFS_SESSION_KEY_SIZE);
+
 	pSMB->req_no_secext.CaseSensitivePasswordLength =
 	    cpu_to_le16(CIFS_SESSION_KEY_SIZE);
 	bcc_ptr = pByteArea(smb_buffer);
-	/* memcpy(bcc_ptr, (char *) lm_session_key, CIFS_SESSION_KEY_SIZE);
-	   bcc_ptr += CIFS_SESSION_KEY_SIZE; */
+	memcpy(bcc_ptr, (char *) session_key, CIFS_SESSION_KEY_SIZE);
+	bcc_ptr += CIFS_SESSION_KEY_SIZE;
 	memcpy(bcc_ptr, (char *) session_key, CIFS_SESSION_KEY_SIZE);
 	bcc_ptr += CIFS_SESSION_KEY_SIZE;
 
diff -Nru a/fs/cifs/dir.c b/fs/cifs/dir.c
--- a/fs/cifs/dir.c	2004-12-24 13:37:00 -08:00
+++ b/fs/cifs/dir.c	2004-12-24 13:37:00 -08:00
@@ -399,9 +399,6 @@
 	     (" parent inode = 0x%p name is: %s and dentry = 0x%p",
 	      parent_dir_inode, direntry->d_name.name, direntry));
 
-	if(nd) {  /* BB removeme */
-		cFYI(1,("In lookup nd flags 0x%x open intent flags 0x%x",nd->flags,nd->intent.open.flags));
-	} /* BB removeme BB */
 	/* BB Add check of incoming data - e.g. frame not longer than maximum SMB - let server check the namelen BB */
 
 	/* check whether path exists */
diff -Nru a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
--- a/fs/cifs/fcntl.c	2004-12-24 13:37:03 -08:00
+++ b/fs/cifs/fcntl.c	2004-12-24 13:37:03 -08:00
@@ -28,6 +28,44 @@
 #include "cifs_unicode.h"
 #include "cifs_debug.h"
 
+__u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags)
+{
+	__u32 cifs_ntfy_flags = 0;
+
+	/* No way on Linux VFS to ask to monitor xattr
+	changes (and no stream support either */
+	if(fcntl_notify_flags & DN_ACCESS) {
+		cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS;
+	}
+	if(fcntl_notify_flags & DN_MODIFY) {
+		/* What does this mean on directories? */
+		cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE |
+			FILE_NOTIFY_CHANGE_SIZE;
+	}
+	if(fcntl_notify_flags & DN_CREATE) {
+		cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_CREATION | 
+			FILE_NOTIFY_CHANGE_LAST_WRITE;
+	}
+	if(fcntl_notify_flags & DN_DELETE) {
+		cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE;
+	}
+	if(fcntl_notify_flags & DN_RENAME) {
+		/* BB review this - checking various server behaviors */
+		cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_DIR_NAME | 
+			FILE_NOTIFY_CHANGE_FILE_NAME;
+	}
+	if(fcntl_notify_flags & DN_ATTRIB) {
+		cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_SECURITY | 
+			FILE_NOTIFY_CHANGE_ATTRIBUTES;
+	}
+/*	if(fcntl_notify_flags & DN_MULTISHOT) {
+		cifs_ntfy_flags |= ;
+	} */ /* BB fixme - not sure how to handle this with CIFS yet */
+
+
+	return cifs_ntfy_flags;
+}
+
 int cifs_dir_notify(struct file * file, unsigned long arg)
 {
 	int xid;
@@ -37,7 +75,7 @@
 	struct cifsTconInfo *pTcon;
 	char *full_path = NULL;
 	__u32 filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES;
-    __u16 netfid;
+	__u16 netfid;
 
 	xid = GetXid();
 	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
@@ -50,20 +88,26 @@
 	if(full_path == NULL) {
 		rc = -ENOMEM;
 	} else {
-		cFYI(1,("cifs dir notify on file %s",full_path));
+		cERROR(1,("cifs dir notify on file %s with arg 0x%lx",full_path,arg)); /* BB removeme BB */
 		rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 
 			GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
 			&netfid, &oplock,NULL, cifs_sb->local_nls);
 		/* BB fixme - add this handle to a notify handle list */
 		if(rc) {
-			cFYI(1,("Could not open directory for notify"));
+			cERROR(1,("Could not open directory for notify"));  /* BB remove BB */
 		} else {
-			rc = CIFSSMBNotify(xid, pTcon, 1 /* subdirs */, netfid, 
-				filter, cifs_sb->local_nls);
+			filter = convert_to_cifs_notify_flags(arg);
+			if(filter != 0) {
+				rc = CIFSSMBNotify(xid, pTcon, 0 /* no subdirs */, netfid, 
+					filter, cifs_sb->local_nls);
+			} else {
+				rc = -EINVAL;
+			}
 			/* BB add code to close file eventually (at unmount
 			it would close automatically but may be a way
 			to do it easily when inode freed or when
 			notify info is cleared/changed */
+            cERROR(1,("notify rc %d",rc));
 		}
 	}
 	
diff -Nru a/fs/cifs/file.c b/fs/cifs/file.c
--- a/fs/cifs/file.c	2004-12-24 13:36:16 -08:00
+++ b/fs/cifs/file.c	2004-12-24 13:36:16 -08:00
@@ -35,6 +35,8 @@
 #include "cifs_debug.h"
 #include "cifs_fs_sb.h"
 
+extern int cifs_readdir2(struct file *file, void *direntry, filldir_t filldir); /* BB removeme BB */
+
 int
 cifs_open(struct inode *inode, struct file *file)
 {
@@ -62,7 +64,7 @@
 		read_lock(&GlobalSMBSeslock);
 		list_for_each(tmp, &pCifsInode->openFileList) {            
 			pCifsFile = list_entry(tmp,struct cifsFileInfo, flist);           
-			if((pCifsFile->pfile == NULL)&& (pCifsFile->pid = current->pid)){
+			if((pCifsFile->pfile == NULL)&& (pCifsFile->pid == current->tgid)){
 			/* mode set in cifs_create */
 				pCifsFile->pfile = file; /* needed for writepage */
 				file->private_data = pCifsFile;
@@ -166,7 +168,7 @@
 			memset(file->private_data, 0, sizeof(struct cifsFileInfo));
 			pCifsFile = (struct cifsFileInfo *) file->private_data;
 			pCifsFile->netfid = netfid;
-			pCifsFile->pid = current->pid;
+			pCifsFile->pid = current->tgid;
 			init_MUTEX(&pCifsFile->fh_sem);
 			pCifsFile->pfile = file; /* needed for writepage */
 			pCifsFile->pInode = inode;
@@ -452,18 +454,44 @@
 {
 	int rc = 0;
 	int xid;
-	struct cifsFileInfo *pSMBFileStruct =
+	struct cifsFileInfo *pCFileStruct =
 	    (struct cifsFileInfo *) file->private_data;
+	char * ptmp;
 
 	cFYI(1, ("Closedir inode = 0x%p with ", inode));
 
 	xid = GetXid();
 
-	if (pSMBFileStruct) {
+	if (pCFileStruct) {
+		struct cifsTconInfo *pTcon;
+		struct cifs_sb_info * cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+
+		pTcon = cifs_sb->tcon;
+
 		cFYI(1, ("Freeing private data in close dir"));
+		if(pCFileStruct->srch_inf.endOfSearch == FALSE) {
+			pCFileStruct->invalidHandle = TRUE;
+			rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid);
+			cFYI(1,("Closing uncompleted readdir with rc %d",rc));
+			/* not much we can do if it fails anywway, ignore rc */
+			rc = 0;
+		}
+		ptmp = pCFileStruct->srch_inf.ntwrk_buf_start;
+		if(ptmp) {
+			cFYI(1,("freeing smb buf in srch struct in closedir")); /* BB removeme BB */
+			pCFileStruct->srch_inf.ntwrk_buf_start = NULL;
+			cifs_buf_release(ptmp);
+		}
+		ptmp = pCFileStruct->search_resume_name;
+		if(ptmp) {
+			cFYI(1,("freeing resume name in closedir")); /* BB removeme BB */
+			pCFileStruct->search_resume_name = NULL;
+			kfree(ptmp);
+		}
 		kfree(file->private_data);
 		file->private_data = NULL;
 	}
+	/* BB can we lock the filestruct while this is going on? */
 	FreeXid(xid);
 	return rc;
 }
@@ -570,12 +598,131 @@
 			 pfLock->fl_start, numUnlock, numLock, lockType,
 			 wait_flag);
 	if (rc == 0 && (pfLock->fl_flags & FL_POSIX))
-		posix_lock_file(file, pfLock);
+		posix_lock_file_wait(file, pfLock);
 	FreeXid(xid);
 	return rc;
 }
 
 ssize_t
+cifs_user_write(struct file * file, const char __user * write_data,
+	   size_t write_size, loff_t * poffset)
+{
+	int rc = 0;
+	unsigned int bytes_written = 0;
+	unsigned int total_written;
+	struct cifs_sb_info *cifs_sb;
+	struct cifsTconInfo *pTcon;
+	int xid, long_op;
+	struct cifsFileInfo * open_file;
+
+	if(file->f_dentry == NULL)
+		return -EBADF;
+
+	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+	if(cifs_sb == NULL) {
+		return -EBADF;
+	}
+	pTcon = cifs_sb->tcon;
+
+	/*cFYI(1,
+	   (" write %d bytes to offset %lld of %s", write_size,
+	   *poffset, file->f_dentry->d_name.name)); */
+
+	if (file->private_data == NULL) {
+		return -EBADF;
+	} else {
+		open_file = (struct cifsFileInfo *) file->private_data;
+	}
+	
+	xid = GetXid();
+	if(file->f_dentry->d_inode == NULL) {
+		FreeXid(xid);
+		return -EBADF;
+	}
+
+	if (*poffset > file->f_dentry->d_inode->i_size)
+		long_op = 2;  /* writes past end of file can take a long time */
+	else
+		long_op = 1;
+
+	for (total_written = 0; write_size > total_written;
+	     total_written += bytes_written) {
+		rc = -EAGAIN;
+		while(rc == -EAGAIN) {
+			if(file->private_data == NULL) {
+				/* file has been closed on us */
+				FreeXid(xid);
+			/* if we have gotten here we have written some data
+			and blocked, and the file has been freed on us
+			while we blocked so return what we managed to write */
+				return total_written;
+			} 
+			if(open_file->closePend) {
+				FreeXid(xid);
+				if(total_written)
+					return total_written;
+				else
+					return -EBADF;
+			}
+			if (open_file->invalidHandle) {
+				if((file->f_dentry == NULL) ||
+				   (file->f_dentry->d_inode == NULL)) {
+					FreeXid(xid);
+					return total_written;
+				}
+				/* we could deadlock if we called
+				 filemap_fdatawait from here so tell
+				reopen_file not to flush data to server now */
+				rc = cifs_reopen_file(file->f_dentry->d_inode,
+					file,FALSE);
+				if(rc != 0)
+					break;
+			}
+
+			rc = CIFSSMBWrite(xid, pTcon,
+				  open_file->netfid,
+				  write_size - total_written, *poffset,
+				  &bytes_written,
+				  NULL, write_data + total_written, long_op);
+		}
+		if (rc || (bytes_written == 0)) {
+			if (total_written)
+				break;
+			else {
+				FreeXid(xid);
+				return rc;
+			}
+		} else
+			*poffset += bytes_written;
+		long_op = FALSE; /* subsequent writes fast - 15 seconds is plenty */
+	}
+
+#ifdef CONFIG_CIFS_STATS
+	if(total_written > 0) {
+		atomic_inc(&pTcon->num_writes);
+		spin_lock(&pTcon->stat_lock);
+		pTcon->bytes_written += total_written;
+		spin_unlock(&pTcon->stat_lock);
+	}
+#endif		
+
+	/* since the write may have blocked check these pointers again */
+	if(file->f_dentry) {
+		if(file->f_dentry->d_inode) {
+			file->f_dentry->d_inode->i_ctime = file->f_dentry->d_inode->i_mtime =
+				CURRENT_TIME;
+			if (total_written > 0) {
+				if (*poffset > file->f_dentry->d_inode->i_size)
+					i_size_write(file->f_dentry->d_inode, *poffset);
+			}
+			mark_inode_dirty_sync(file->f_dentry->d_inode);
+		}
+	}
+	FreeXid(xid);
+	return total_written;
+}
+
+static ssize_t
 cifs_write(struct file * file, const char *write_data,
 	   size_t write_size, loff_t * poffset)
 {
@@ -652,10 +799,10 @@
 			}
 
 			rc = CIFSSMBWrite(xid, pTcon,
-				   open_file->netfid,
+				  open_file->netfid,
 				  write_size - total_written, *poffset,
 				  &bytes_written,
-				  write_data + total_written, long_op);
+				  write_data + total_written, NULL, long_op);
 		}
 		if (rc || (bytes_written == 0)) {
 			if (total_written)
@@ -969,6 +1116,83 @@
 
 
 ssize_t
+cifs_user_read(struct file * file, char __user *read_data, size_t read_size,
+	  loff_t * poffset)
+{
+	int rc = -EACCES;
+	unsigned int bytes_read = 0;
+	unsigned int total_read = 0;
+	unsigned int current_read_size;
+	struct cifs_sb_info *cifs_sb;
+	struct cifsTconInfo *pTcon;
+	int xid;
+	struct cifsFileInfo * open_file;
+	char * smb_read_data;
+	char __user * current_offset;
+	struct smb_com_read_rsp * pSMBr;
+
+	xid = GetXid();
+	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+	pTcon = cifs_sb->tcon;
+
+	if (file->private_data == NULL) {
+		FreeXid(xid);
+		return -EBADF;
+	}
+	open_file = (struct cifsFileInfo *)file->private_data;
+
+	if((file->f_flags & O_ACCMODE) == O_WRONLY) {
+		cFYI(1,("attempting read on write only file instance"));
+	}
+
+	for (total_read = 0,current_offset=read_data; read_size > total_read;
+				total_read += bytes_read,current_offset+=bytes_read) {
+		current_read_size = min_t(const int,read_size - total_read,cifs_sb->rsize);
+		rc = -EAGAIN;
+		smb_read_data = NULL;
+		while(rc == -EAGAIN) {
+			if ((open_file->invalidHandle) && (!open_file->closePend)) {
+				rc = cifs_reopen_file(file->f_dentry->d_inode,
+					file,TRUE);
+				if(rc != 0)
+					break;
+			}
+
+			rc = CIFSSMBRead(xid, pTcon,
+				 open_file->netfid,
+				 current_read_size, *poffset,
+				 &bytes_read, &smb_read_data);
+
+			pSMBr = (struct smb_com_read_rsp *)smb_read_data;
+			copy_to_user(current_offset,smb_read_data + 4/* RFC1001 hdr*/
+				+ le16_to_cpu(pSMBr->DataOffset), bytes_read);
+			if(smb_read_data) {
+				cifs_buf_release(smb_read_data);
+				smb_read_data = NULL;
+			}
+		}
+		if (rc || (bytes_read == 0)) {
+			if (total_read) {
+				break;
+			} else {
+				FreeXid(xid);
+				return rc;
+			}
+		} else {
+#ifdef CONFIG_CIFS_STATS
+			atomic_inc(&pTcon->num_reads);
+			spin_lock(&pTcon->stat_lock);
+			pTcon->bytes_read += total_read;
+			spin_unlock(&pTcon->stat_lock);
+#endif
+			*poffset += bytes_read;
+		}
+	}
+	FreeXid(xid);
+	return total_read;
+}
+
+static ssize_t
 cifs_read(struct file * file, char *read_data, size_t read_size,
 	  loff_t * poffset)
 {
@@ -1039,6 +1263,17 @@
 	struct dentry * dentry = file->f_dentry;
 	int	rc, xid;
 
+#ifdef CIFS_EXPERIMENTAL   /* BB fixme reenable when cifs_read_wrapper fixed */
+	if(dentry->d_sb) {
+		struct cifs_sb_info *cifs_sb;
+		cifs_sb = CIFS_SB(sb);
+		if(cifs_sb != NULL) {
+			if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
+				return -ENODEV
+		}
+	}
+#endif /* CIFS_EXPERIMENTAL */
+
 	xid = GetXid();
 	rc = cifs_revalidate(dentry);
 	if (rc) {
@@ -1199,8 +1434,6 @@
 			spin_unlock(&pTcon->stat_lock);
 #endif
 			if((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) {
-				cFYI(1,("Partial page %d of %d read to cache",i++,num_pages));
-
 				i++; /* account for partial page */
 
 				/* server copy of file can have smaller size than client */
@@ -1376,23 +1609,22 @@
 	cFYI(0,
 	     ("CIFS FFIRST: Attributes came in as 0x%x",
 	      attr));
-	if (attr & ATTR_REPARSE) {
-		*pobject_type = DT_LNK;
-		/* BB can this and S_IFREG or S_IFDIR be set as in Windows? */
-		tmp_inode->i_mode |= S_IFLNK;
-	} else if (attr & ATTR_DIRECTORY) {
+	if (attr & ATTR_DIRECTORY) {
 		*pobject_type = DT_DIR;
 		/* override default perms since we do not lock dirs */
 		if(atomic_read(&cifsInfo->inUse) == 0) {
 			tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
 		}
 		tmp_inode->i_mode |= S_IFDIR;
+/* we no longer mark these because we could not follow them */
+/*        } else if (attr & ATTR_REPARSE) {
+                *pobject_type = DT_LNK;
+                tmp_inode->i_mode |= S_IFLNK;*/
 	} else {
 		*pobject_type = DT_REG;
 		tmp_inode->i_mode |= S_IFREG;
 		if(attr & ATTR_READONLY)
 			tmp_inode->i_mode &= ~(S_IWUGO);
-
 	}/* could add code here - to validate if device or weird share type? */
 
 	/* can not fill in nlink here as in qpathinfo version and Unx search */
@@ -1516,13 +1748,16 @@
 	}
 }
 
-static void
+/* Returns one if new inode created (which therefore needs to be hashed) */
+/* Might check in the future if inode number changed so we can rehash inode */
+int
 construct_dentry(struct qstr *qstring, struct file *file,
 		 struct inode **ptmp_inode, struct dentry **pnew_dentry)
 {
 	struct dentry *tmp_dentry;
 	struct cifs_sb_info *cifs_sb;
 	struct cifsTconInfo *pTcon;
+	int rc = 0;
 
 	cFYI(1, ("For %s ", qstring->name));
 	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
@@ -1537,29 +1772,30 @@
 		if(*ptmp_inode == NULL) {
 	                *ptmp_inode = new_inode(file->f_dentry->d_sb);
 			if(*ptmp_inode == NULL)
-				return;
+				return rc;
+			rc = 1;
 			d_instantiate(tmp_dentry, *ptmp_inode);
-			insert_inode_hash(*ptmp_inode);
 		}
 	} else {
 		tmp_dentry = d_alloc(file->f_dentry, qstring);
 		if(tmp_dentry == NULL) {
 			cERROR(1,("Failed allocating dentry"));
 			*ptmp_inode = NULL;
-			return;
+			return rc;
 		}
 			
 		*ptmp_inode = new_inode(file->f_dentry->d_sb);
 		tmp_dentry->d_op = &cifs_dentry_ops;
 		if(*ptmp_inode == NULL)
-			return;
+			return rc;
+		rc = 1;
 		d_instantiate(tmp_dentry, *ptmp_inode);
 		d_rehash(tmp_dentry);
-		insert_inode_hash(*ptmp_inode);
 	}
 
 	tmp_dentry->d_time = jiffies;
 	*pnew_dentry = tmp_dentry;
+	return rc; 
 }
 
 static void reset_resume_key(struct file * dir_file, 
@@ -1609,11 +1845,19 @@
 	pqstring->name = pfindData->FileName;
 	/* pqstring->len is already set by caller */
 
-	construct_dentry(pqstring, file, &tmp_inode, &tmp_dentry);
+	rc = construct_dentry(pqstring, file, &tmp_inode, &tmp_dentry);
 	if((tmp_inode == NULL) || (tmp_dentry == NULL)) {
 		return -ENOMEM;
 	}
 	fill_in_inode(tmp_inode, pfindData, &object_type);
+	if(rc) {
+		/* We have no reliable way to get inode numbers
+		from servers w/o Unix extensions yet so we can not set
+		i_ino from pfindData yet */
+
+		/* new inode created, let us hash it */
+		insert_inode_hash(tmp_inode);
+	} /* else if inode number changed do we rehash it? */
 	rc = filldir(direntry, pfindData->FileName, pqstring->len, file->f_pos,
 		tmp_inode->i_ino, object_type);
 	if(rc) {
@@ -1637,11 +1881,19 @@
 	pqstring->name = pUnixFindData->FileName;
 	pqstring->len = strnlen(pUnixFindData->FileName, MAX_PATHCONF);
 
-	construct_dentry(pqstring, file, &tmp_inode, &tmp_dentry);
+	rc = construct_dentry(pqstring, file, &tmp_inode, &tmp_dentry);
 	if((tmp_inode == NULL) || (tmp_dentry == NULL)) {
 		return -ENOMEM;
-	}
+	} 
+	if(rc) {
+		struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb);
 
+		if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
+			tmp_inode->i_ino = 
+				(unsigned long)pUnixFindData->UniqueId;
+		}
+		insert_inode_hash(tmp_inode);
+	} /* else if i_ino has changed should we rehash it? */
 	unix_fill_in_inode(tmp_inode, pUnixFindData, &object_type);
 	rc = filldir(direntry, pUnixFindData->FileName, pqstring->len,
 		file->f_pos, tmp_inode->i_ino, object_type);
@@ -1675,25 +1927,34 @@
 	FILE_DIRECTORY_INFO *lastFindData;
 	FILE_UNIX_INFO *pfindDataUnix;
 
+
+    /* BB removeme begin */
+	if(!experimEnabled)
+		return cifs_readdir2(file,direntry,filldir);
+    /* BB removeme end */
+
+
 	xid = GetXid();
 
+	if(file->f_dentry == NULL) {
+		rc = -EIO;
+		FreeXid(xid);
+		return rc;
+	}
 	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
 	pTcon = cifs_sb->tcon;
 	bufsize = pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE;
-	if(bufsize > CIFS_MAX_MSGSIZE) {
+	if(bufsize > CIFSMaxBufSize) {
+		rc = -EIO;
 		FreeXid(xid);
-		return -EIO;
+		return rc;
 	}
 	data = kmalloc(bufsize, GFP_KERNEL);
 	pfindData = (FILE_DIRECTORY_INFO *) data;
 	if(data == NULL) {
+		rc = -ENOMEM;
 		FreeXid(xid);
-		return -ENOMEM;
-	}
-	if(file->f_dentry == NULL) {
-		kfree(data);
-		FreeXid(xid);
-		return -EIO;
+		return rc;
 	}
 	down(&file->f_dentry->d_sb->s_vfs_rename_sem);
 	full_path = build_wildcard_path_from_dentry(file->f_dentry);
@@ -1727,8 +1988,8 @@
 		if (file->private_data != NULL) {
 			cifsFile =
 				(struct cifsFileInfo *) file->private_data;
-			if (cifsFile->endOfSearch) {
-				if(cifsFile->emptyDir) {
+			if (cifsFile->srch_inf.endOfSearch) {
+				if(cifsFile->srch_inf.emptyDir) {
 					cFYI(1, ("End of search, empty dir"));
 					rc = 0;
 					break;
@@ -1778,7 +2039,7 @@
 				break;
 			}
 			/* Offset of resume key same for levels 257 and 514 */
-			cifsFile->resume_key = lastFindData->FileIndex;
+			cifsFile->srch_inf.resume_key = lastFindData->FileIndex;
 			if(UnixSearch == FALSE) {
 				cifsFile->resume_name_length = 
 					le32_to_cpu(lastFindData->FileNameLength);
@@ -1915,13 +2176,13 @@
 				/* if(pfindData > lastFindData) rc = -EIO; break; */
 			}	/* end for loop */
 			if ((findParms.EndofSearch != 0) && cifsFile) {
-				cifsFile->endOfSearch = TRUE;
+				cifsFile->srch_inf.endOfSearch = TRUE;
 				if(findParms.SearchCount == cpu_to_le16(2))
-					cifsFile->emptyDir = TRUE;
+					cifsFile->srch_inf.emptyDir = TRUE;
 			}
 		} else {
 			if (cifsFile)
-				cifsFile->endOfSearch = TRUE;
+				cifsFile->srch_inf.endOfSearch = TRUE;
 			/* unless parent directory gone do not return error */
 			rc = 0;
 		}
@@ -1934,7 +2195,7 @@
 			      file->f_pos));
 		} else {
 			cifsFile = (struct cifsFileInfo *) file->private_data;
-			if (cifsFile->endOfSearch) {
+			if (cifsFile->srch_inf.endOfSearch) {
 				rc = 0;
 				cFYI(1, ("End of search "));
 				break;
@@ -1944,7 +2205,7 @@
 				&findNextParms, searchHandle, 
 				cifsFile->search_resume_name,
 				cifsFile->resume_name_length,
-				cifsFile->resume_key,
+				cifsFile->srch_inf.resume_key,
 				&Unicode, &UnixSearch);
 			cFYI(1,("Count: %d  End: %d ",
 			      le16_to_cpu(findNextParms.SearchCount),
@@ -1961,7 +2222,7 @@
 					break;
 				}
 				/* Offset of resume key same for levels 257 and 514 */
-				cifsFile->resume_key = lastFindData->FileIndex;
+				cifsFile->srch_inf.resume_key = lastFindData->FileIndex;
 
 				if(UnixSearch == FALSE) {
 					cifsFile->resume_name_length = 
@@ -2114,10 +2375,10 @@
 	/* BB also should check to ensure pointer not beyond end of SMB */
 				} /* end for loop */
 				if (findNextParms.EndofSearch != 0) {
-					cifsFile->endOfSearch = TRUE;
+					cifsFile->srch_inf.endOfSearch = TRUE;
 				}
 			} else {
-				cifsFile->endOfSearch = TRUE;
+				cifsFile->srch_inf.endOfSearch = TRUE;
 				rc = 0;	/* unless parent directory disappeared - do not
 				return error here (eg Access Denied or no more files) */
 			}
diff -Nru a/fs/cifs/inode.c b/fs/cifs/inode.c
--- a/fs/cifs/inode.c	2004-12-24 13:36:17 -08:00
+++ b/fs/cifs/inode.c	2004-12-24 13:36:17 -08:00
@@ -85,6 +85,13 @@
 			*pinode = new_inode(sb);
 			if(*pinode == NULL) 
 				return -ENOMEM;
+			/* Is an i_ino of zero legal? */
+			/* Are there sanity checks we can use to ensure that
+			the server is really filling in that field? */
+			if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
+				(*pinode)->i_ino = 
+					(unsigned long)findData.UniqueId;
+			} /* note ino incremented to unique num in new_inode */
 			insert_inode_hash(*pinode);
 		}
 			
@@ -244,6 +251,21 @@
 			*pinode = new_inode(sb);
 			if(*pinode == NULL)
 				return -ENOMEM;
+			/* Is an i_ino of zero legal? */
+			/* Are there sanity checks we can use to ensure that
+			the server is really filling in that field? */
+
+			/* We can not use the IndexNumber from either
+			Windows or Samba as it is frequently set to zero */
+			/* There may be higher info levels that work but
+			Are there Windows server or network appliances
+			for which IndexNumber field is not guaranteed unique? */
+		
+			/* if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
+				(*pinode)->i_ino = 
+					(unsigned long)pfindData->IndexNumber;
+			} */ /*NB: ino incremented to unique num in new_inode*/
+
 			insert_inode_hash(*pinode);
 		}
 		inode = *pinode;
@@ -273,10 +295,10 @@
 			/* new inode, can safely set these fields */
 			inode->i_mode = cifs_sb->mnt_file_mode;
 
-		if (attr & ATTR_REPARSE) {
-	/* Can IFLNK be set as it basically is on windows with IFREG or IFDIR? */
-			inode->i_mode |= S_IFLNK;
-		} else if (attr & ATTR_DIRECTORY) {
+/*		if (attr & ATTR_REPARSE)  */
+/* 		We no longer handle these as symlinks because we could not */
+/* 		follow them due to the absolute path with drive letter */
+		if (attr & ATTR_DIRECTORY) {
 	/* override default perms since we do not do byte range locking on dirs */
 			inode->i_mode = cifs_sb->mnt_dir_mode;
 			inode->i_mode |= S_IFDIR;
@@ -958,6 +980,16 @@
 			 via Handle (SetFileInfo) instead of by path */
 		rc = CIFSSMBSetTimes(xid, pTcon, full_path, &time_buf,
 				cifs_sb->local_nls);
+		if(rc == -EOPNOTSUPP) {
+			cFYI(1,("OS2 level of SetPathInfo not implemented"));
+			/* Need to convert time_buf into old format, 
+			but probably better to do that inside the function
+			below rather than here */
+			/* Better to return EOPNOTSUPP until function
+			below is ready */
+			/* CIFSSMBSetTimesLegacy(xid, pTcon, full_path,
+        	        FILE_INFO_STANDARD * data, cifs_sb->local_nls); */
+		}
 	}
 
 	/* do not  need local check to inode_check_ok since the server does that */
diff -Nru a/fs/cifs/misc.c b/fs/cifs/misc.c
--- a/fs/cifs/misc.c	2004-12-24 13:37:29 -08:00
+++ b/fs/cifs/misc.c	2004-12-24 13:37:29 -08:00
@@ -1,7 +1,7 @@
 /*
  *   fs/cifs/misc.c
  *
- *   Copyright (C) International Business Machines  Corp., 2002,2003
+ *   Copyright (C) International Business Machines  Corp., 2002,2004
  *   Author(s): Steve French (sfrench@us.ibm.com)
  *
  *   This library is free software; you can redistribute it and/or modify
@@ -29,6 +29,7 @@
 #include "smberr.h"
 #include "nterr.h"
 
+extern mempool_t *cifs_sm_req_poolp;
 extern mempool_t *cifs_req_poolp;
 extern struct task_struct * oplockThread;
 
@@ -160,8 +161,9 @@
 	    (struct smb_hdr *) mempool_alloc(cifs_req_poolp, SLAB_KERNEL | SLAB_NOFS);
 
 	/* clear the first few header bytes */
+	/* for most paths, more is cleared in header_assemble */
 	if (ret_buf) {
-		memset(ret_buf, 0, sizeof (struct smb_hdr));
+		memset(ret_buf, 0, sizeof(struct smb_hdr) + 3);
 		atomic_inc(&bufAllocCount);
 	}
 
@@ -173,7 +175,7 @@
 {
 
 	if (buf_to_free == NULL) {
-		cFYI(1, ("Null buffer passed to cifs_buf_release"));
+		/* cFYI(1, ("Null buffer passed to cifs_buf_release"));*/
 		return;
 	}
 	mempool_free(buf_to_free,cifs_req_poolp);
@@ -182,20 +184,49 @@
 	return;
 }
 
+struct smb_hdr *
+cifs_small_buf_get(void)
+{
+	struct smb_hdr *ret_buf = NULL;
+
+/* We could use negotiated size instead of max_msgsize - 
+   but it may be more efficient to always alloc same size 
+   albeit slightly larger than necessary and maxbuffersize 
+   defaults to this and can not be bigger */
+	ret_buf =
+	    (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, SLAB_KERNEL | SLAB_NOFS);
+	if (ret_buf) {
+	/* No need to clear memory here, cleared in header assemble */
+	/*	memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
+		atomic_inc(&smBufAllocCount);
+	}
+	return ret_buf;
+}
+
+void
+cifs_small_buf_release(void *buf_to_free)
+{
+
+	if (buf_to_free == NULL) {
+		cFYI(1, ("Null buffer passed to cifs_small_buf_release"));
+		return;
+	}
+	mempool_free(buf_to_free,cifs_sm_req_poolp);
+
+	atomic_dec(&smBufAllocCount);
+	return;
+}
+
 void
 header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
 		const struct cifsTconInfo *treeCon, int word_count
-		/* length of fixed section (word count) in two byte units  */
-    )
+		/* length of fixed section (word count) in two byte units  */)
 {
-	int i;
 	struct list_head* temp_item;
 	struct cifsSesInfo * ses;
 	char *temp = (char *) buffer;
 
-	for (i = 0; i < MAX_CIFS_HDR_SIZE; i++) {
-		temp[i] = 0;	/* BB is this needed ?? */
-	}
+	memset(temp,0,MAX_CIFS_HDR_SIZE);
 
 	buffer->smb_buf_length =
 	    (2 * word_count) + sizeof (struct smb_hdr) -
@@ -320,7 +351,7 @@
 	     ("Entering checkSMB with Length: %x, smb_buf_length: %x ",
 	      length, len));
 	if (((unsigned int)length < 2 + sizeof (struct smb_hdr)) ||
-	    (len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)) {
+	    (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)) {
 		if ((unsigned int)length < 2 + sizeof (struct smb_hdr)) {
 			cERROR(1, ("Length less than 2 + sizeof smb_hdr "));
 			if (((unsigned int)length >= sizeof (struct smb_hdr) - 1)
@@ -328,9 +359,9 @@
 				return 0;	/* some error cases do not return wct and bcc */
 
 		}
-		if (len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)
+		if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)
 			cERROR(1,
-			       ("smb_buf_length greater than CIFS_MAX_MSGSIZE ... "));
+			       ("smb_buf_length greater than MaxBufSize"));
 		cERROR(1,
 		       ("bad smb detected. Illegal length. The mid=%d",
 			smb->Mid));
@@ -359,8 +390,29 @@
 	struct cifsTconInfo *tcon;
 	struct cifsFileInfo *netfile;
 
-	/* could add check for smb response flag 0x80 */
-	cFYI(1,("Checking for oplock break"));    
+	cFYI(1,("Checking for oplock break or dnotify response"));
+	if((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) &&
+	   (pSMB->hdr.Flags & SMBFLG_RESPONSE)) {
+		struct smb_com_transaction_change_notify_rsp * pSMBr =
+			(struct smb_com_transaction_change_notify_rsp *)buf;
+		struct file_notify_information * pnotify;
+		__u32 data_offset = 0;
+		if(pSMBr->ByteCount > sizeof(struct file_notify_information)) {
+			data_offset = le32_to_cpu(pSMBr->DataOffset);
+
+			pnotify = (struct file_notify_information *)((char *)&pSMBr->hdr.Protocol
+				+ data_offset);
+			cFYI(1,("dnotify on %s with action: 0x%x",pnotify->FileName,
+				pnotify->Action));  /* BB removeme BB */
+	             /*   cifs_dump_mem("Received notify Data is: ",buf,sizeof(struct smb_hdr)+60); */
+			return TRUE;
+		}
+		if(pSMBr->hdr.Status.CifsError) {
+			cFYI(1,("notify err 0x%d",pSMBr->hdr.Status.CifsError));
+			return TRUE;
+		}
+		return FALSE;
+	}  
 	if(pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
 		return FALSE;
 	if(pSMB->hdr.Flags & SMBFLG_RESPONSE) {
diff -Nru a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
--- a/fs/cifs/netmisc.c	2004-12-24 13:37:19 -08:00
+++ b/fs/cifs/netmisc.c	2004-12-24 13:37:19 -08:00
@@ -69,10 +69,12 @@
 	{ERRinvparm, -EINVAL},
 	{ERRdiskfull, -ENOSPC},
 	{ERRinvname, -ENOENT},
+	{ERRinvlevel,-EOPNOTSUPP},
 	{ERRdirnotempty, -ENOTEMPTY},
 	{ERRnotlocked, -ENOLCK},
 	{ERRalreadyexists, -EEXIST},
 	{ERRmoredata, -EOVERFLOW},
+	{ERReasnotsupported,-EOPNOTSUPP},
 	{ErrQuota, -EDQUOT},
 	{ErrNotALink, -ENOLINK},
 	{ERRnetlogonNotStarted,-ENOPROTOOPT},
@@ -287,7 +289,7 @@
 	ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, {
 	ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, {
 	ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, {
-	ERRDOS, 282, NT_STATUS_EAS_NOT_SUPPORTED}, {
+	ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED}, {
 	ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, {
 	ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, {
 	ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, {
@@ -752,7 +754,8 @@
 	ERRDOS, ERRnoaccess, 0xc000028e}, {
 	ERRDOS, ERRnoaccess, 0xc000028f}, {
 	ERRDOS, ERRnoaccess, 0xc0000290}, {
-ERRDOS, ERRbadfunc, 0xc000029c},};
+	ERRDOS, ERRbadfunc, 0xc000029c}, {
+	ERRDOS, ERRinvlevel, 0x007c0001}, };
 
 /*****************************************************************************
  Print an error message from the status code
diff -Nru a/fs/cifs/readdir.c b/fs/cifs/readdir.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/fs/cifs/readdir.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,648 @@
+/*
+ *   fs/cifs/readdir.c
+ *
+ *   Directory search handling
+ * 
+ *   Copyright (C) International Business Machines  Corp., 2004
+ *   Author(s): Steve French (sfrench@us.ibm.com)
+ *
+ *   This library is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Lesser General Public License as published
+ *   by the Free Software Foundation; either version 2.1 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This library 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 Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public License
+ *   along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <linux/fs.h>
+#include <linux/stat.h>
+#include <linux/smp_lock.h>
+#include "cifspdu.h"
+#include "cifsglob.h"
+#include "cifsproto.h"
+#include "cifs_unicode.h"
+#include "cifs_debug.h"
+#include "cifs_fs_sb.h"
+
+extern int CIFSFindFirst2(const int xid, struct cifsTconInfo *tcon,
+            const char *searchName, const struct nls_table *nls_codepage,
+            __u16 *searchHandle, struct cifs_search_info * psrch_inf);
+
+extern int CIFSFindNext2(const int xid, struct cifsTconInfo *tcon,
+            __u16 searchHandle, struct cifs_search_info * psrch_inf);
+
+extern int construct_dentry(struct qstr *qstring, struct file *file,
+		 struct inode **ptmp_inode, struct dentry **pnew_dentry);
+
+extern void fill_in_inode(struct inode *tmp_inode,
+	      FILE_DIRECTORY_INFO * pfindData, int *pobject_type);
+
+extern void unix_fill_in_inode(struct inode *tmp_inode,
+	      FILE_UNIX_INFO * pfindData, int *pobject_type);
+
+
+/* BB fixme - add debug wrappers around this function to disable it fixme BB */
+/* static void dump_cifs_file_struct(struct file * file, char * label)
+{
+	struct cifsFileInfo * cf;
+
+	if(file) {
+		cf = (struct cifsFileInfo *)file->private_data;
+		if(cf == NULL) {
+			cFYI(1,("empty cifs private file data"));
+			return;
+		}
+		if(cf->invalidHandle) {
+			cFYI(1,("invalid handle"));
+		}
+		if(cf->srch_inf.endOfSearch) {
+			cFYI(1,("end of search"));
+		}
+		if(cf->srch_inf.emptyDir) {
+			cFYI(1,("empty dir"));
+		}
+		
+	}
+} */
+
+static int initiate_cifs_search(const int xid, struct file * file)
+{
+	int rc = 0;
+	char * full_path;
+	struct cifsFileInfo * cifsFile;
+	struct cifs_sb_info *cifs_sb;
+	struct cifsTconInfo *pTcon;
+
+	if(file->private_data == NULL) {
+		file->private_data = 
+			kmalloc(sizeof(struct cifsFileInfo),GFP_KERNEL);
+	}
+
+	if(file->private_data == NULL) {
+		return -ENOMEM;
+	} else {
+		memset(file->private_data,0,sizeof(struct cifsFileInfo));
+	}
+	cifsFile = (struct cifsFileInfo *)file->private_data;
+	cifsFile->invalidHandle = TRUE;
+	cifsFile->srch_inf.endOfSearch = FALSE;
+
+	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+	if(cifs_sb == NULL)
+		return -EINVAL;
+
+	pTcon = cifs_sb->tcon;
+	if(pTcon == NULL)
+		return -EINVAL;
+
+	if(file->f_dentry == NULL)
+		return -ENOENT;
+
+	down(&file->f_dentry->d_sb->s_vfs_rename_sem);
+	full_path = build_wildcard_path_from_dentry(file->f_dentry);
+	up(&file->f_dentry->d_sb->s_vfs_rename_sem);
+
+	if(full_path == NULL) {
+		return -ENOMEM;
+	}
+
+	cFYI(1, ("Full path: %s start at: %lld ", full_path, file->f_pos));
+
+	/* test for Unix extensions */
+	if (pTcon->ses->capabilities & CAP_UNIX) {
+		cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX;
+	} else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
+		cifsFile->srch_inf.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO;
+	} else /* not srvinos - BB fixme add check for backlevel? */ {
+		cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO;
+	}
+
+	rc = CIFSFindFirst2(xid, pTcon,full_path,cifs_sb->local_nls, 
+		&cifsFile->netfid, &cifsFile->srch_inf); 
+	if(rc == 0)
+		cifsFile->invalidHandle = FALSE;
+	if(full_path)
+		kfree(full_path);
+	return rc;
+}
+
+/* return length of unicode string in bytes */
+static int cifs_unicode_bytelen(char * str)
+{
+	int len;
+	__le16 * ustr = (__le16 *)str;
+
+	for(len=0;len <= PATH_MAX;len++) {
+		if(ustr[len] == 0)
+			return len << 1;
+	}
+	cFYI(1,("Unicode string longer than PATH_MAX found"));
+	return len << 1;
+}
+
+static char * nxt_dir_entry(char * old_entry, char * end_of_smb)
+{
+	char * new_entry;
+	FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
+
+	new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset);
+	cFYI(1,("new entry %p old entry %p",new_entry,old_entry));
+	/* validate that new_entry is not past end of SMB */
+	if(new_entry >= end_of_smb) {
+		cFYI(1,("search entry %p began after end of SMB %p old entry %p",
+			new_entry,end_of_smb,old_entry)); 
+		return NULL;
+	} else
+		return new_entry;
+
+}
+
+#define UNICODE_DOT cpu_to_le16(0x2e)
+
+/* return 0 if no match and 1 for . (current directory) and 2 for .. (parent) */
+static int cifs_entry_is_dot(char * current_entry, struct cifsFileInfo * cfile)
+{
+	int rc = 0;
+	char * filename = NULL;
+	int len = 0; 
+
+	if(cfile->srch_inf.info_level == 0x202) {
+		FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		if(cfile->srch_inf.unicode) {
+			len = cifs_unicode_bytelen(filename);
+		} else {
+			/* BB should we make this strnlen of PATH_MAX? */
+			len = strnlen(filename, 5);
+		}
+	} else if(cfile->srch_inf.info_level == 0x101) {
+		FILE_DIRECTORY_INFO * pFindData = 
+			(FILE_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+	} else if(cfile->srch_inf.info_level == 0x102) {
+		FILE_FULL_DIRECTORY_INFO * pFindData = 
+			(FILE_FULL_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+	} else if(cfile->srch_inf.info_level == 0x105) {
+		SEARCH_ID_FULL_DIR_INFO * pFindData = 
+			(SEARCH_ID_FULL_DIR_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+	} else if(cfile->srch_inf.info_level == 0x104) {
+		FILE_BOTH_DIRECTORY_INFO * pFindData = 
+			(FILE_BOTH_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+	} else {
+		cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level));
+	}
+
+	if(filename) {
+		if(cfile->srch_inf.unicode) {
+			__le16 *ufilename = (__le16 *)filename;
+			if(len == 2) {
+				/* check for . */
+				if(ufilename[0] == UNICODE_DOT)
+					rc = 1;
+			} else if(len == 4) {
+				/* check for .. */
+				if((ufilename[0] == UNICODE_DOT)
+				   &&(ufilename[1] == UNICODE_DOT))
+					rc = 2;
+			}
+		} else /* ASCII */ {
+			if(len == 1) {
+				if(filename[0] == '.') 
+					rc = 1;
+			} else if(len == 2) {
+				if((filename[0] == '.') && (filename[1] == '.')) 
+					rc = 2;
+			}
+		}
+	}
+
+	return rc;
+}
+
+/* find the corresponding entry in the search */
+/* Note that the SMB server returns search entries for . and .. which
+   complicates logic here if we choose to parse for them and we do not
+   assume that they are located in the findfirst return buffer.*/
+/* We start counting in the buffer with entry 2 and increment for every
+   entry (do not increment for . or .. entry) */
+static int find_cifs_entry(const int xid, struct cifsTconInfo * pTcon, 
+		struct file * file, char ** ppCurrentEntry,int * num_to_ret) 
+{
+	int rc = 0;
+	int pos_in_buf = 0;
+	loff_t first_entry_in_buffer;
+	loff_t index_to_find = file->f_pos;
+	struct cifsFileInfo * cifsFile = (struct cifsFileInfo *)file->private_data;
+	/* check if index in the buffer */
+	
+	if((cifsFile == NULL) || (ppCurrentEntry == NULL) || (num_to_ret == NULL))
+		return -ENOENT;
+	
+	*ppCurrentEntry = NULL;
+	first_entry_in_buffer = 
+		cifsFile->srch_inf.index_of_last_entry - 
+			cifsFile->srch_inf.entries_in_buffer;
+/*	dump_cifs_file_struct(file, "In fce ");*/
+	if(index_to_find < first_entry_in_buffer) {
+		/* close and restart search */
+		cFYI(1,("search backing up - close and restart search"));
+		cifsFile->invalidHandle = TRUE;
+		CIFSFindClose(xid, pTcon, cifsFile->netfid);
+		if(cifsFile->search_resume_name) {
+			kfree(cifsFile->search_resume_name);
+			cifsFile->search_resume_name = NULL;
+		}
+		if(cifsFile->srch_inf.ntwrk_buf_start) {
+			cFYI(1,("freeing SMB ff cache buf on search rewind")); 
+			cifs_buf_release(cifsFile->srch_inf.ntwrk_buf_start);
+		}
+		rc = initiate_cifs_search(xid,file);
+		if(rc) {
+			cFYI(1,("error %d reinitiating a search on rewind",rc));
+			return rc;
+		}
+	}
+
+	while((index_to_find >= cifsFile->srch_inf.index_of_last_entry) && 
+	      (rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)){
+	 	cFYI(1,("calling findnext2"));
+		rc = CIFSFindNext2(xid,pTcon,cifsFile->netfid, &cifsFile->srch_inf);
+		if(rc)
+			return -ENOENT;
+	}
+	if(index_to_find < cifsFile->srch_inf.index_of_last_entry) {
+		/* we found the buffer that contains the entry */
+		/* scan and find it */
+		int i;
+		char * current_entry;
+		char * end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + 
+			smbCalcSize((struct smb_hdr *)cifsFile->srch_inf.ntwrk_buf_start);
+/*	dump_cifs_file_struct(file,"found entry in fce "); */
+		first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry -
+			cifsFile->srch_inf.entries_in_buffer;
+		pos_in_buf = index_to_find - first_entry_in_buffer;
+		cFYI(1,("found entry - pos_in_buf %d",pos_in_buf)); 
+		current_entry = cifsFile->srch_inf.srch_entries_start;
+		for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) {
+			/* go entry to next entry figuring out which we need to start with */
+			/* if( . or ..)
+				skip */
+			rc = cifs_entry_is_dot(current_entry,cifsFile);
+			if(rc == 1) /* is . or .. so skip */ {
+				cFYI(1,("Entry is .")); /* BB removeme BB */
+				/* continue; */
+			} else if (rc == 2 ) {
+				cFYI(1,("Entry is ..")); /* BB removeme BB */
+				/* continue; */
+			}
+			current_entry = nxt_dir_entry(current_entry,end_of_smb);
+		}
+		if((current_entry == NULL) && (i < pos_in_buf)) {
+			cERROR(1,("reached end of buf searching for pos in buf %d index to find %lld rc %d",pos_in_buf,index_to_find,rc)); /* BB removeme BB */
+		}
+		rc = 0;
+		*ppCurrentEntry = current_entry;
+	} else {
+		cFYI(1,("index not in buffer - could not findnext into it"));
+		return 0;
+	}
+
+	if(pos_in_buf >= cifsFile->srch_inf.entries_in_buffer) {
+		cFYI(1,("can not return entries when pos_in_buf beyond last entry"));
+		*num_to_ret = 0;
+	} else
+		*num_to_ret = cifsFile->srch_inf.entries_in_buffer - pos_in_buf;
+/*	dump_cifs_file_struct(file, "end fce ");*/
+
+	return rc;
+}
+
+/* inode num, inode type and filename returned */
+static int cifs_get_name_from_search_buf(struct qstr * pqst,char * current_entry,
+			__u16 level,unsigned int unicode,struct nls_table * nlt,
+			ino_t * pinum)
+{
+	int rc = 0;
+	unsigned int len = 0;
+	char * filename;
+
+	*pinum = 0;
+
+	if(level == SMB_FIND_FILE_UNIX) {
+		FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
+
+		filename = &pFindData->FileName[0];
+		if(unicode) {
+			len = cifs_unicode_bytelen(filename);
+		} else {
+			/* BB should we make this strnlen of PATH_MAX? */
+			len = strnlen(filename, PATH_MAX);
+		}
+
+		/* BB fixme - hash low and high 32 bits if not 64 bit arch BB fixme */
+		*pinum = pFindData->UniqueId;
+	} else if(level == SMB_FIND_FILE_DIRECTORY_INFO) {
+		FILE_DIRECTORY_INFO * pFindData = 
+			(FILE_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+	} else if(level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
+		FILE_FULL_DIRECTORY_INFO * pFindData = 
+			(FILE_FULL_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+	} else if(level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
+		SEARCH_ID_FULL_DIR_INFO * pFindData = 
+			(SEARCH_ID_FULL_DIR_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+		*pinum = pFindData->UniqueId;
+	} else if(level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
+		FILE_BOTH_DIRECTORY_INFO * pFindData = 
+			(FILE_BOTH_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+	} else {
+		cFYI(1,("Unknown findfirst level %d",level));
+		return -EINVAL;
+	}
+	if(unicode) {
+		/* BB fixme - test with long names */
+		/* Note converted filename can be longer than in unicode */
+		pqst->len = cifs_strfromUCS_le((char *)pqst->name,(wchar_t *)filename,len/2,nlt);
+	} else {
+		pqst->name = filename;
+		pqst->len = len;
+	}
+	pqst->hash = full_name_hash(pqst->name,pqst->len);
+/*	cFYI(1,("filldir on %s",pqst->name));  */
+	return rc;
+}
+
+
+static int
+cifs_filldir2(char * pfindEntry, struct file *file, 
+			  filldir_t filldir, void *direntry,char * scratch_buf)
+{
+	int rc = 0;
+	struct qstr qstring;
+	struct cifsFileInfo * pCifsF;
+	unsigned obj_type;
+	ino_t  inum;
+	struct cifs_sb_info * cifs_sb;
+	struct inode *tmp_inode;
+	struct dentry *tmp_dentry;
+
+	/* get filename and len into qstring */
+	/* get dentry */
+	/* decide whether to create and populate ionde */
+	if((direntry == NULL) || (file == NULL))
+		return -EINVAL;
+
+	pCifsF = file->private_data;
+	
+	if((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL))
+		return -ENOENT;
+
+	if(file->f_dentry == NULL)
+		return -ENOENT;
+
+	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+
+	qstring.name = scratch_buf;
+	rc = cifs_get_name_from_search_buf(&qstring,pfindEntry,
+			pCifsF->srch_inf.info_level,
+			pCifsF->srch_inf.unicode,cifs_sb->local_nls,
+			&inum /* returned */);
+
+	if(rc)
+		return rc;
+
+	rc = construct_dentry(&qstring,file,&tmp_inode, &tmp_dentry);
+	if((tmp_inode == NULL) || (tmp_dentry == NULL))
+		return -ENOMEM;
+
+	if(rc) {
+		/* inode created, we need to hash it with right inode number */
+		if(inum != 0) {
+			/* BB fixme - hash the 2 32 quantities bits together if necessary BB */
+			tmp_inode->i_ino = inum;
+		}
+		insert_inode_hash(tmp_inode);
+	}
+
+	if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
+		unix_fill_in_inode(tmp_inode,(FILE_UNIX_INFO *)pfindEntry,&obj_type);
+	} else {
+		fill_in_inode(tmp_inode,(FILE_DIRECTORY_INFO *)pfindEntry,&obj_type);
+	}
+	
+	rc = filldir(direntry,qstring.name,qstring.len,file->f_pos,tmp_inode->i_ino,obj_type);
+	if(rc) {
+		cFYI(1,("filldir rc = %d",rc));
+	}
+
+	dput(tmp_dentry);
+	return rc;
+}
+
+int cifs_save_resume_key(const char * current_entry,struct cifsFileInfo * cifsFile)
+{
+	int rc = 0;
+	unsigned int len = 0;
+	__u16 level;
+	char * filename;
+
+	if((cifsFile == NULL) || (current_entry == NULL))
+		return -EINVAL;
+
+	level = cifsFile->srch_inf.info_level;
+
+	if(level == SMB_FIND_FILE_UNIX) {
+		FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
+
+		filename = &pFindData->FileName[0];
+		if(cifsFile->srch_inf.unicode) {
+			len = cifs_unicode_bytelen(filename);
+		} else {
+			/* BB should we make this strnlen of PATH_MAX? */
+			len = strnlen(filename, PATH_MAX);
+		}
+		cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
+	} else if(level == SMB_FIND_FILE_DIRECTORY_INFO) {
+		FILE_DIRECTORY_INFO * pFindData = 
+			(FILE_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+		cifsFile->srch_inf.resume_key = pFindData->FileIndex;
+	} else if(level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
+		FILE_FULL_DIRECTORY_INFO * pFindData = 
+			(FILE_FULL_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+		cifsFile->srch_inf.resume_key = pFindData->FileIndex;
+	} else if(level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
+		SEARCH_ID_FULL_DIR_INFO * pFindData = 
+			(SEARCH_ID_FULL_DIR_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+		cifsFile->srch_inf.resume_key = pFindData->FileIndex;
+	} else if(level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
+		FILE_BOTH_DIRECTORY_INFO * pFindData = 
+			(FILE_BOTH_DIRECTORY_INFO *)current_entry;
+		filename = &pFindData->FileName[0];
+		len = le32_to_cpu(pFindData->FileNameLength);
+		cifsFile->srch_inf.resume_key = pFindData->FileIndex;
+	} else {
+		cFYI(1,("Unknown findfirst level %d",level));
+		return -EINVAL;
+	}
+	cifsFile->srch_inf.resume_name_len = len;
+	cifsFile->srch_inf.presume_name = filename;
+	return rc;
+}
+
+int cifs_readdir2(struct file *file, void *direntry, filldir_t filldir)
+{
+	int rc = 0;
+	int xid,i;
+	struct cifs_sb_info *cifs_sb;
+	struct cifsTconInfo *pTcon;
+	struct cifsFileInfo *cifsFile = NULL;
+	char * current_entry;
+	int num_to_fill = 0;
+	char * tmp_buf = NULL;
+	char * end_of_smb;
+
+	xid = GetXid();
+
+	if(file->f_dentry == NULL) {
+		FreeXid(xid);
+		return -EIO;
+	}
+/*	dump_cifs_file_struct(file, "Begin rdir "); */
+
+	cifs_sb = CIFS_SB(file->f_dentry->d_sb);
+	pTcon = cifs_sb->tcon;
+	if(pTcon == NULL)
+		return -EINVAL;
+
+/*	cFYI(1,("readdir2 pos: %lld",file->f_pos)); */
+
+	switch ((int) file->f_pos) {
+	case 0:
+		/*if (filldir(direntry, ".", 1, file->f_pos,
+		     file->f_dentry->d_inode->i_ino, DT_DIR) < 0) {
+			cERROR(1, ("Filldir for current dir failed "));
+			rc = -ENOMEM;
+			break;
+		}
+		file->f_pos++; */
+	case 1:
+		/* if (filldir(direntry, "..", 2, file->f_pos,
+		     file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
+			cERROR(1, ("Filldir for parent dir failed "));
+			rc = -ENOMEM;
+			break;
+		}
+		file->f_pos++; */
+	case 2:
+		/* 1) If search is active, 
+			is in current search buffer? 
+			if it before then restart search
+			if after then keep searching till find it */
+
+		if(file->private_data == NULL) {
+			rc = initiate_cifs_search(xid,file);
+			cFYI(1,("initiate cifs search rc %d",rc));
+			if(rc) {
+				FreeXid(xid);
+				return rc;
+			}
+		}
+	default:
+		if(file->private_data == NULL) {
+			rc = -EINVAL;
+			FreeXid(xid);
+			return rc;
+		}
+		cifsFile = (struct cifsFileInfo *) file->private_data;
+		if (cifsFile->srch_inf.endOfSearch) {
+			if(cifsFile->srch_inf.emptyDir) {
+				cFYI(1, ("End of search, empty dir"));
+				rc = 0;
+				break;
+			}
+		} /* else {
+			cifsFile->invalidHandle = TRUE;
+			CIFSFindClose(xid, pTcon, cifsFile->netfid);
+		} 
+		if(cifsFile->search_resume_name) {
+			kfree(cifsFile->search_resume_name);
+			cifsFile->search_resume_name = NULL;
+		} */
+/* BB account for . and .. in f_pos */
+		/* dump_cifs_file_struct(file, "rdir after default ");*/
+
+		rc = find_cifs_entry(xid,pTcon, file,
+				&current_entry,&num_to_fill);
+		if(rc) {
+			cFYI(1,("fce error %d",rc)); 
+			goto rddir2_exit;
+		} else if (current_entry != NULL) {
+			cFYI(1,("entry %lld found",file->f_pos));
+		} else {
+			cFYI(1,("could not find entry"));
+			goto rddir2_exit;
+		}
+		cFYI(1,("loop through %d times filling dir for net buf %p",
+			num_to_fill,cifsFile->srch_inf.ntwrk_buf_start)); 
+		end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + 
+			smbCalcSize((struct smb_hdr *)cifsFile->srch_inf.ntwrk_buf_start);
+		tmp_buf = kmalloc(NAME_MAX+1,GFP_KERNEL);
+		for(i=0;(i<num_to_fill) && (rc == 0);i++) {
+			if(current_entry == NULL) {
+				cERROR(1,("beyond end of smb with num to fill %d i %d",num_to_fill,i)); /* BB removeme BB */
+				break;
+			}
+/*			if((!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) || 
+			   (cifsFile->srch_inf.info_level != something that supports server inodes)) {
+				create dentry
+				create inode
+				fill in inode new_inode (which makes number locally)
+			}
+			also create local inode for per reasons unless new mount parm says otherwise */
+			rc = cifs_filldir2(current_entry, file, 
+					filldir, direntry,tmp_buf);
+			file->f_pos++;
+			if(file->f_pos == cifsFile->srch_inf.index_of_last_entry) {
+				cFYI(1,("last entry in buf at pos %lld %s",file->f_pos,tmp_buf)); /* BB removeme BB */
+				cifs_save_resume_key(current_entry,cifsFile);
+				break;
+			} else 
+				current_entry = nxt_dir_entry(current_entry,end_of_smb);
+		}
+		if(tmp_buf != NULL)
+			kfree(tmp_buf);
+		break;
+	} /* end switch */
+
+rddir2_exit:
+	/* dump_cifs_file_struct(file, "end rdir ");  */
+	FreeXid(xid);
+	return rc;
+}
+
diff -Nru a/fs/cifs/smberr.h b/fs/cifs/smberr.h
--- a/fs/cifs/smberr.h	2004-12-24 13:37:01 -08:00
+++ b/fs/cifs/smberr.h	2004-12-24 13:37:01 -08:00
@@ -69,6 +69,7 @@
 #define ERRpipeclosing 232
 #define ERRnotconnected 233
 #define ERRmoredata    234
+#define ERReasnotsupported 282
 #define ErrQuota 0x200		/* The operation would cause a quota limit to be exceeded. */
 #define ErrNotALink 0x201	/* A link operation was performed on a pathname that
 				   was not a link. */
diff -Nru a/fs/cifs/transport.c b/fs/cifs/transport.c
--- a/fs/cifs/transport.c	2004-12-24 13:36:31 -08:00
+++ b/fs/cifs/transport.c	2004-12-24 13:36:31 -08:00
@@ -176,6 +176,143 @@
 	return rc;
 }
 
+#ifdef CIFS_EXPERIMENTAL
+/* BB finish off this function, adding support for writing set of pages as iovec */
+/* and also adding support for operations that need to parse the response smb    */
+int
+CIFSSendRcv(const unsigned int xid, struct cifsSesInfo *ses,
+	    struct smb_hdr *in_buf, struct kvec * write_vector /* page list */, int *pbytes_returned, const int long_op)
+{
+	int rc = 0;
+	unsigned long timeout = 15 * HZ;
+	struct mid_q_entry *midQ = NULL;
+
+	if (ses == NULL) {
+		cERROR(1,("Null smb session"));
+		return -EIO;
+	}
+	if(ses->server == NULL) {
+		cERROR(1,("Null tcp session"));
+		return -EIO;
+	}
+	if(pbytes_returned == NULL)
+		return -EIO;
+	else
+		*pbytes_returned = 0;
+
+  
+
+	/* Ensure that we do not send more than 50 overlapping requests 
+	   to the same server. We may make this configurable later or
+	   use ses->maxReq */
+	if(long_op == -1) {
+		/* oplock breaks must not be held up */
+		atomic_inc(&ses->server->inFlight);
+	} else {
+		spin_lock(&GlobalMid_Lock); 
+		while(1) {        
+			if(atomic_read(&ses->server->inFlight) >= cifs_max_pending){
+				spin_unlock(&GlobalMid_Lock);
+				wait_event(ses->server->request_q,
+					atomic_read(&ses->server->inFlight)
+					 < cifs_max_pending);
+				spin_lock(&GlobalMid_Lock);
+			} else {
+				if(ses->server->tcpStatus == CifsExiting) {
+					spin_unlock(&GlobalMid_Lock);
+					return -ENOENT;
+				}
+
+			/* can not count locking commands against total since
+			   they are allowed to block on server */
+					
+				if(long_op < 3) {
+				/* update # of requests on the wire to server */
+					atomic_inc(&ses->server->inFlight);
+				}
+				spin_unlock(&GlobalMid_Lock);
+				break;
+			}
+		}
+	}
+	/* make sure that we sign in the same order that we send on this socket 
+	   and avoid races inside tcp sendmsg code that could cause corruption
+	   of smb data */
+
+	down(&ses->server->tcpSem); 
+
+	if (ses->server->tcpStatus == CifsExiting) {
+		rc = -ENOENT;
+		goto cifs_out_label;
+	} else if (ses->server->tcpStatus == CifsNeedReconnect) {
+		cFYI(1,("tcp session dead - return to caller to retry"));
+		rc = -EAGAIN;
+		goto cifs_out_label;
+	} else if (ses->status != CifsGood) {
+		/* check if SMB session is bad because we are setting it up */
+		if((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) && 
+			(in_buf->Command != SMB_COM_NEGOTIATE)) {
+			rc = -EAGAIN;
+			goto cifs_out_label;
+		} /* else ok - we are setting up session */
+	}
+	midQ = AllocMidQEntry(in_buf, ses);
+	if (midQ == NULL) {
+		up(&ses->server->tcpSem);
+		/* If not lock req, update # of requests on wire to server */
+		if(long_op < 3) {
+			atomic_dec(&ses->server->inFlight); 
+			wake_up(&ses->server->request_q);
+		}
+		return -ENOMEM;
+	}
+
+	if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
+		up(&ses->server->tcpSem);
+		cERROR(1,
+		       ("Illegal length, greater than maximum frame, %d ",
+			in_buf->smb_buf_length));
+		DeleteMidQEntry(midQ);
+		/* If not lock req, update # of requests on wire to server */
+		if(long_op < 3) {
+			atomic_dec(&ses->server->inFlight); 
+			wake_up(&ses->server->request_q);
+		}
+		return -EIO;
+	}
+
+	/* BB can we sign efficiently in this path? */
+	rc = cifs_sign_smb(in_buf, ses, &midQ->sequence_number);
+
+	midQ->midState = MID_REQUEST_SUBMITTED;
+/*	rc = smb_send2(ses->server->ssocket, in_buf, in_buf->smb_buf_length, piovec,
+		      (struct sockaddr *) &(ses->server->addr.sockAddr));*/
+	if(rc < 0) {
+		DeleteMidQEntry(midQ);
+		up(&ses->server->tcpSem);
+		/* If not lock req, update # of requests on wire to server */
+		if(long_op < 3) {
+			atomic_dec(&ses->server->inFlight); 
+			wake_up(&ses->server->request_q);
+		}
+		return rc;
+	} else
+		up(&ses->server->tcpSem);
+cifs_out_label:
+	if(midQ)
+	        DeleteMidQEntry(midQ);
+                                                                                                                           
+	if(long_op < 3) {
+		atomic_dec(&ses->server->inFlight);
+		wake_up(&ses->server->request_q);
+	}
+
+	return rc;
+}
+
+
+#endif /* CIFS_EXPERIMENTAL */
+
 int
 SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
 	    struct smb_hdr *in_buf, struct smb_hdr *out_buf,
@@ -204,11 +341,11 @@
 	} else {
 		spin_lock(&GlobalMid_Lock); 
 		while(1) {        
-			if(atomic_read(&ses->server->inFlight) >= CIFS_MAX_REQ){
+			if(atomic_read(&ses->server->inFlight) >= cifs_max_pending){
 				spin_unlock(&GlobalMid_Lock);
 				wait_event(ses->server->request_q,
 					atomic_read(&ses->server->inFlight)
-					 < CIFS_MAX_REQ);
+					 < cifs_max_pending);
 				spin_lock(&GlobalMid_Lock);
 			} else {
 				if(ses->server->tcpStatus == CifsExiting) {
@@ -260,7 +397,7 @@
 		return -ENOMEM;
 	}
 
-	if (in_buf->smb_buf_length > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4) {
+	if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
 		up(&ses->server->tcpSem);
 		cERROR(1,
 		       ("Illegal length, greater than maximum frame, %d ",
@@ -307,20 +444,19 @@
 		/* if signal pending do not hold up user for full smb timeout
 		but we still give response a change to complete */
 		timeout = 2 * HZ;
-		
 	}   
 
 	/* No user interrupts in wait - wreaks havoc with performance */
 	if(timeout != MAX_SCHEDULE_TIMEOUT) {
 		timeout += jiffies;
 		wait_event(ses->server->response_q,
-			(midQ->midState & MID_RESPONSE_RECEIVED) || 
+			(!(midQ->midState & MID_REQUEST_SUBMITTED)) || 
 			time_after(jiffies, timeout) || 
 			((ses->server->tcpStatus != CifsGood) &&
 			 (ses->server->tcpStatus != CifsNew)));
 	} else {
 		wait_event(ses->server->response_q,
-			(midQ->midState & MID_RESPONSE_RECEIVED) || 
+			(!(midQ->midState & MID_REQUEST_SUBMITTED)) || 
 			((ses->server->tcpStatus != CifsGood) &&
 			 (ses->server->tcpStatus != CifsNew)));
 	}
@@ -358,7 +494,7 @@
 		return rc;
 	}
   
-	if (receive_len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE) {
+	if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
 		cERROR(1,
 		       ("Frame too large received.  Length: %d  Xid: %d",
 			receive_len, xid));
diff -Nru a/fs/cifs/xattr.c b/fs/cifs/xattr.c
--- a/fs/cifs/xattr.c	2004-12-24 13:36:48 -08:00
+++ b/fs/cifs/xattr.c	2004-12-24 13:36:48 -08:00
@@ -20,6 +20,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/posix_acl_xattr.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
 #include "cifsglob.h"
@@ -27,11 +28,16 @@
 #include "cifs_debug.h"
 
 #define MAX_EA_VALUE_SIZE 65535
-#define CIFS_XATTR_DOS_ATTRIB "user.DOSATTRIB"
+#define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib"
 #define CIFS_XATTR_USER_PREFIX "user."
 #define CIFS_XATTR_SYSTEM_PREFIX "system."
-#define CIFS_XATTR_OS2_PREFIX "OS2." /* BB should check for this someday */
-/* also note could add check for security prefix XATTR_SECURITY_PREFIX */ 
+#define CIFS_XATTR_OS2_PREFIX "os2."
+#define CIFS_XATTR_SECURITY_PREFIX ".security"
+#define CIFS_XATTR_TRUSTED_PREFIX "trusted."
+#define XATTR_TRUSTED_PREFIX_LEN  8
+#define XATTR_SECURITY_PREFIX_LEN 9
+/* BB need to add server (Samba e.g) support for security and trusted prefix */
+  
 
 
 int cifs_removexattr(struct dentry * direntry, const char * ea_name)
@@ -128,16 +134,47 @@
 
 	if(ea_name == NULL) {
 		cFYI(1,("Null xattr names not supported"));
-	} else if(strncmp(ea_name,CIFS_XATTR_USER_PREFIX,5)) {
-		cFYI(1,("illegal xattr namespace %s (only user namespace supported)",ea_name));
+	} else if(strncmp(ea_name,CIFS_XATTR_USER_PREFIX,5) == 0) {
+		if(strncmp(ea_name,CIFS_XATTR_DOS_ATTRIB,14) == 0) {
+			cFYI(1,("attempt to set cifs inode metadata"));
+		}
+		ea_name += 5; /* skip past user. prefix */
+		rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,ea_value,
+			(__u16)value_size, cifs_sb->local_nls);
+	} else if(strncmp(ea_name, CIFS_XATTR_OS2_PREFIX,4) == 0) {
+		ea_name += 4; /* skip past os2. prefix */
+		rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,ea_value,
+			(__u16)value_size, cifs_sb->local_nls);
+	} else {
+		int temp; 
+		temp = strncmp(ea_name,POSIX_ACL_XATTR_ACCESS,
+			strlen(POSIX_ACL_XATTR_ACCESS));
+		if (temp == 0) {
+#ifdef CONFIG_CIFS_POSIX
+			rc = CIFSSMBSetPosixACL(xid, pTcon,full_path,ea_value,
+				(const int)value_size, ACL_TYPE_ACCESS,
+				cifs_sb->local_nls);
+			cFYI(1,("set POSIX ACL rc %d",rc));
+#else
+			cFYI(1,("set POSIX ACL not supported"));
+#endif
+		} else if(strncmp(ea_name,POSIX_ACL_XATTR_DEFAULT,strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
+#ifdef CONFIG_CIFS_POSIX
+			rc = CIFSSMBSetPosixACL(xid, pTcon,full_path,ea_value,
+				(const int)value_size, ACL_TYPE_DEFAULT,
+				cifs_sb->local_nls);
+			cFYI(1,("set POSIX default ACL rc %d",rc));
+#else
+			cFYI(1,("set default POSIX ACL not supported"));
+#endif
+		} else {
+			cFYI(1,("illegal xattr request %s (only user namespace supported)",ea_name));
 		  /* BB what if no namespace prefix? */
 		  /* Should we just pass them to server, except for 
 		  system and perhaps security prefixes? */
-	} else {
-		ea_name+=5; /* skip past user. prefix */
-		rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,ea_value,
-			(__u16)value_size, cifs_sb->local_nls);
+		}
 	}
+ 
 	if (full_path)
 		kfree(full_path);
 	FreeXid(xid);
@@ -163,6 +200,7 @@
 	sb = direntry->d_inode->i_sb;
 	if(sb == NULL)
 		return -EIO;
+
 	xid = GetXid();
 
 	cifs_sb = CIFS_SB(sb);
@@ -177,19 +215,54 @@
 	}
 	/* return dos attributes as pseudo xattr */
 	/* return alt name if available as pseudo attr */
-	if(strncmp(ea_name,CIFS_XATTR_USER_PREFIX,5)) {
-		cFYI(1,("illegal xattr namespace %s (only user namespace supported)",ea_name));
-		/* BB what if no namespace prefix? */
-		/* Should we just pass them to server, except for system? */
+	if(ea_name == NULL) {
+		cFYI(1,("Null xattr names not supported"));
+	} else if(strncmp(ea_name,CIFS_XATTR_USER_PREFIX,5) == 0) {
+		if(strncmp(ea_name,CIFS_XATTR_DOS_ATTRIB,14) == 0) {
+			cFYI(1,("attempt to query cifs inode metadata"));
+			/* revalidate/getattr then populate from inode */
+		} /* BB add else when above is implemented */
+		ea_name += 5; /* skip past user. prefix */
+		rc = CIFSSMBQueryEA(xid,pTcon,full_path,ea_name,ea_value,
+			buf_size, cifs_sb->local_nls);
+	} else if(strncmp(ea_name, CIFS_XATTR_OS2_PREFIX,4) == 0) {
+		ea_name += 4; /* skip past os2. prefix */
+		rc = CIFSSMBQueryEA(xid,pTcon,full_path,ea_name,ea_value,
+			buf_size, cifs_sb->local_nls);
+	} else if(strncmp(ea_name,POSIX_ACL_XATTR_ACCESS,strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
+#ifdef CONFIG_CIFS_POSIX
+		rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
+				ea_value, buf_size, ACL_TYPE_ACCESS, 
+				cifs_sb->local_nls);
+#else 
+		cFYI(1,("query POSIX ACL not supported yet"));
+#endif /* CONFIG_CIFS_POSIX */
+	} else if(strncmp(ea_name,POSIX_ACL_XATTR_DEFAULT,strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
+#ifdef CONFIG_CIFS_POSIX
+		rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
+				ea_value, buf_size, ACL_TYPE_DEFAULT, 
+				cifs_sb->local_nls);
+#else 
+		cFYI(1,("query POSIX default ACL not supported yet"));
+#endif
+	} else if(strncmp(ea_name,
+		  CIFS_XATTR_TRUSTED_PREFIX,XATTR_TRUSTED_PREFIX_LEN) == 0) {
+		cFYI(1,("Trusted xattr namespace not supported yet"));
+	} else if(strncmp(ea_name,
+		  CIFS_XATTR_SECURITY_PREFIX,XATTR_SECURITY_PREFIX_LEN) == 0) {
+		cFYI(1,("Security xattr namespace not supported yet"));
 	} else {
-	/* We could add a check here
+		cFYI(1,("illegal xattr name request %s (only user namespace supported)",ea_name));
+	}
+
+	/* We could add an additional check for streams ie 
 	    if proc/fs/cifs/streamstoxattr is set then
 		search server for EAs or streams to 
 		returns as xattrs */
-		ea_name+=5; /* skip past user. */
-		rc = CIFSSMBQueryEA(xid,pTcon,full_path,ea_name,ea_value,
-				buf_size, cifs_sb->local_nls);
-	}
+
+	if(rc == -EINVAL)
+		rc = -EOPNOTSUPP; 
+
 	if (full_path)
 		kfree(full_path);
 	FreeXid(xid);
diff -Nru a/fs/coda/sysctl.c b/fs/coda/sysctl.c
--- a/fs/coda/sysctl.c	2004-12-24 13:36:47 -08:00
+++ b/fs/coda/sysctl.c	2004-12-24 13:36:47 -08:00
@@ -19,7 +19,7 @@
 #include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/ctype.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <linux/utsname.h>
 #include <linux/module.h>
diff -Nru a/fs/compat.c b/fs/compat.c
--- a/fs/compat.c	2004-12-24 13:36:48 -08:00
+++ b/fs/compat.c	2004-12-24 13:36:48 -08:00
@@ -117,10 +117,17 @@
 {
 	
 	if (sizeof ubuf->f_blocks == 4) {
-		if ((kbuf->f_blocks | kbuf->f_bfree |
-		     kbuf->f_bavail | kbuf->f_files | kbuf->f_ffree) &
+		if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail) &
 		    0xffffffff00000000ULL)
 			return -EOVERFLOW;
+		/* f_files and f_ffree may be -1; it's okay
+		 * to stuff that into 32 bits */
+		if (kbuf->f_files != 0xffffffffffffffffULL
+		 && (kbuf->f_files & 0xffffffff00000000ULL))
+			return -EOVERFLOW;
+		if (kbuf->f_ffree != 0xffffffffffffffffULL
+		 && (kbuf->f_ffree & 0xffffffff00000000ULL))
+			return -EOVERFLOW;
 	}
 	if (verify_area(VERIFY_WRITE, ubuf, sizeof(*ubuf)) ||
 	    __put_user(kbuf->f_type, &ubuf->f_type) ||
@@ -184,10 +191,17 @@
 static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatfs *kbuf)
 {
 	if (sizeof ubuf->f_blocks == 4) {
-		if ((kbuf->f_blocks | kbuf->f_bfree |
-		     kbuf->f_bavail | kbuf->f_files | kbuf->f_ffree) &
+		if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail) &
 		    0xffffffff00000000ULL)
 			return -EOVERFLOW;
+		/* f_files and f_ffree may be -1; it's okay
+		 * to stuff that into 32 bits */
+		if (kbuf->f_files != 0xffffffffffffffffULL
+		 && (kbuf->f_files & 0xffffffff00000000ULL))
+			return -EOVERFLOW;
+		if (kbuf->f_ffree != 0xffffffffffffffffULL
+		 && (kbuf->f_ffree & 0xffffffff00000000ULL))
+			return -EOVERFLOW;
 	}
 	if (verify_area(VERIFY_WRITE, ubuf, sizeof(*ubuf)) ||
 	    __put_user(kbuf->f_type, &ubuf->f_type) ||
@@ -205,7 +219,7 @@
 	return 0;
 }
 
-asmlinkage long compat_statfs64(const char __user *path, compat_size_t sz, struct compat_statfs64 __user *buf)
+asmlinkage long compat_sys_statfs64(const char __user *path, compat_size_t sz, struct compat_statfs64 __user *buf)
 {
 	struct nameidata nd;
 	int error;
@@ -224,7 +238,7 @@
 	return error;
 }
 
-asmlinkage long compat_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user *buf)
+asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user *buf)
 {
 	struct file * file;
 	struct kstatfs tmp;
@@ -527,14 +541,7 @@
 		set_fs(KERNEL_DS);
 		ret = sys_fcntl(fd, cmd, (unsigned long)&f);
 		set_fs(old_fs);
-		if ((cmd == F_GETLK) && (ret == 0)) {
-			/* POSIX-2001 now defines negative l_len */
-			if (f.l_len < 0) {
-				f.l_start += f.l_len;
-				f.l_len = -f.l_len;
-			}
-			if (f.l_start < 0)
-				return -EINVAL;
+		if (cmd == F_GETLK && ret == 0) {
 			if ((f.l_start >= COMPAT_OFF_T_MAX) ||
 			    ((f.l_start + f.l_len) > COMPAT_OFF_T_MAX))
 				ret = -EOVERFLOW;
@@ -555,14 +562,7 @@
 				((cmd == F_SETLK64) ? F_SETLK : F_SETLKW),
 				(unsigned long)&f);
 		set_fs(old_fs);
-		if ((cmd == F_GETLK64) && (ret == 0)) {
-			/* POSIX-2001 now defines negative l_len */
-			if (f.l_len < 0) {
-				f.l_start += f.l_len;
-				f.l_len = -f.l_len;
-			}
-			if (f.l_start < 0)
-				return -EINVAL;
+		if (cmd == F_GETLK64 && ret == 0) {
 			if ((f.l_start >= COMPAT_LOFF_T_MAX) ||
 			    ((f.l_start + f.l_len) > COMPAT_LOFF_T_MAX))
 				ret = -EOVERFLOW;
@@ -860,7 +860,7 @@
 	return -EFAULT;
 }
 
-asmlinkage long compat_old_readdir(unsigned int fd,
+asmlinkage long compat_sys_old_readdir(unsigned int fd,
 	struct compat_old_linux_dirent __user *dirent, unsigned int count)
 {
 	int error;
@@ -1387,25 +1387,25 @@
 	int retval;
 	int i;
 
-	file = open_exec(filename);
-
-	retval = PTR_ERR(file);
-	if (IS_ERR(file))
-		return retval;
-
-	sched_exec();
-
 	retval = -ENOMEM;
 	bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
 	if (!bprm)
 		goto out_ret;
 	memset(bprm, 0, sizeof(*bprm));
 
+	file = open_exec(filename);
+	retval = PTR_ERR(file);
+	if (IS_ERR(file))
+		goto out_kfree;
+
+	sched_exec();
+
 	bprm->p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
 	bprm->file = file;
 	bprm->filename = filename;
 	bprm->interp = filename;
 	bprm->mm = mm_alloc();
+	retval = -ENOMEM;
 	if (!bprm->mm)
 		goto out_file;
 
@@ -1472,6 +1472,8 @@
 		allow_write_access(bprm->file);
 		fput(bprm->file);
 	}
+
+out_kfree:
 	kfree(bprm);
 
 out_ret:
diff -Nru a/fs/compat_ioctl.c b/fs/compat_ioctl.c
--- a/fs/compat_ioctl.c	2004-12-24 13:37:29 -08:00
+++ b/fs/compat_ioctl.c	2004-12-24 13:37:29 -08:00
@@ -69,6 +69,7 @@
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
 #include <linux/wireless.h>
+#include <linux/atalk.h>
 
 #include <net/sock.h>          /* siocdevprivate_ioctl */
 #include <net/bluetooth/bluetooth.h>
@@ -95,6 +96,7 @@
 #include <asm/module.h>
 #include <linux/soundcard.h>
 #include <linux/lp.h>
+#include <linux/ppdev.h>
 
 #include <linux/atm.h>
 #include <linux/atmarp.h>
@@ -115,6 +117,7 @@
 #include <linux/random.h>
 #include <linux/filter.h>
 #include <linux/msdos_fs.h>
+#include <linux/pktcdvd.h>
 
 #include <linux/hiddev.h>
 
@@ -3184,6 +3187,13 @@
 HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
 HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
 HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
+
+/* ioctls used by appletalk ddp.c */
+HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
+HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
+HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
+
 HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
 HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
 HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
diff -Nru a/fs/dcache.c b/fs/dcache.c
--- a/fs/dcache.c	2004-12-24 13:36:18 -08:00
+++ b/fs/dcache.c	2004-12-24 13:36:18 -08:00
@@ -15,6 +15,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/syscalls.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
@@ -278,14 +279,18 @@
 /**
  * d_find_alias - grab a hashed alias of inode
  * @inode: inode in question
+ * @want_discon:  flag, used by d_splice_alias, to request
+ *          that only a DISCONNECTED alias be returned.
  *
- * If inode has a hashed alias - acquire the reference to alias and
- * return it. Otherwise return NULL. Notice that if inode is a directory
- * there can be only one alias and it can be unhashed only if it has
- * no children.
+ * If inode has a hashed alias, or is a directory and has any alias,
+ * acquire the reference to alias and return it. Otherwise return NULL.
+ * Notice that if inode is a directory there can be only one alias and
+ * it can be unhashed only if it has no children, or if it is the root
+ * of a filesystem.
  *
  * If the inode has a DCACHE_DISCONNECTED alias, then prefer
- * any other hashed alias over that one.
+ * any other hashed alias over that one unless @want_discon is set,
+ * in which case only return a DCACHE_DISCONNECTED alias.
  */
 
 static struct dentry * __d_find_alias(struct inode *inode, int want_discon)
@@ -300,7 +305,7 @@
 		next = tmp->next;
 		prefetch(next);
 		alias = list_entry(tmp, struct dentry, d_alias);
- 		if (!d_unhashed(alias)) {
+ 		if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) {
 			if (alias->d_flags & DCACHE_DISCONNECTED)
 				discon_alias = alias;
 			else if (!want_discon) {
@@ -721,7 +726,6 @@
 	dentry->d_fsdata = NULL;
 	dentry->d_mounted = 0;
 	dentry->d_cookie = NULL;
-	dentry->d_bucket = NULL;
 	INIT_HLIST_NODE(&dentry->d_hash);
 	INIT_LIST_HEAD(&dentry->d_lru);
 	INIT_LIST_HEAD(&dentry->d_subdirs);
@@ -743,6 +747,16 @@
 	return dentry;
 }
 
+struct dentry *d_alloc_name(struct dentry *parent, const char *name)
+{
+	struct qstr q;
+
+	q.name = name;
+	q.len = strlen(name);
+	q.hash = full_name_hash(q.name, q.len);
+	return d_alloc(parent, &q);
+}
+
 /**
  * d_instantiate - fill in inode information for a dentry
  * @entry: dentry to complete
@@ -850,12 +864,6 @@
 		res->d_sb = inode->i_sb;
 		res->d_parent = res;
 		res->d_inode = inode;
-
-		/*
-		 * Set d_bucket to an "impossible" bucket address so
-		 * that d_move() doesn't get a false positive
-		 */
-		res->d_bucket = NULL;
 		res->d_flags |= DCACHE_DISCONNECTED;
 		res->d_flags &= ~DCACHE_UNHASHED;
 		list_add(&res->d_alias, &inode->i_dentry);
@@ -978,8 +986,6 @@
 
 		dentry = hlist_entry(node, struct dentry, d_hash);
 
-		smp_rmb();
-
 		if (dentry->d_name.hash != hash)
 			continue;
 		if (dentry->d_parent != parent)
@@ -988,13 +994,6 @@
 		spin_lock(&dentry->d_lock);
 
 		/*
-		 * If lookup ends up in a different bucket due to concurrent
-		 * rename, fail it
-		 */
-		if (unlikely(dentry->d_bucket != head))
-			goto terminate;
-
-		/*
 		 * Recheck the dentry after taking the lock - d_move may have
 		 * changed things.  Don't bother checking the hash because we're
 		 * about to compare the whole name anyway.
@@ -1002,7 +1001,11 @@
 		if (dentry->d_parent != parent)
 			goto next;
 
-		qstr = rcu_dereference(&dentry->d_name);
+		/*
+		 * It is safe to compare names since d_move() cannot
+		 * change the qstr (protected by d_lock).
+		 */
+		qstr = &dentry->d_name;
 		if (parent->d_op && parent->d_op->d_compare) {
 			if (parent->d_op->d_compare(parent, qstr, name))
 				goto next;
@@ -1017,7 +1020,6 @@
 			atomic_inc(&dentry->d_count);
 			found = dentry;
 		}
-terminate:
 		spin_unlock(&dentry->d_lock);
 		break;
 next:
@@ -1109,6 +1111,13 @@
 	spin_unlock(&dcache_lock);
 }
 
+static void __d_rehash(struct dentry * entry, struct hlist_head *list)
+{
+
+ 	entry->d_flags &= ~DCACHE_UNHASHED;
+ 	hlist_add_head_rcu(&entry->d_hash, list);
+}
+
 /**
  * d_rehash	- add an entry back to the hash
  * @entry: dentry to add to the hash
@@ -1122,10 +1131,8 @@
 
 	spin_lock(&dcache_lock);
 	spin_lock(&entry->d_lock);
- 	entry->d_flags &= ~DCACHE_UNHASHED;
+	__d_rehash(entry, list);
 	spin_unlock(&entry->d_lock);
-	entry->d_bucket = list;
- 	hlist_add_head_rcu(&entry->d_hash, list);
 	spin_unlock(&dcache_lock);
 }
 
@@ -1203,6 +1210,8 @@
 
 void d_move(struct dentry * dentry, struct dentry * target)
 {
+	struct hlist_head *list;
+
 	if (!dentry->d_inode)
 		printk(KERN_WARNING "VFS: moving negative dcache entry\n");
 
@@ -1222,13 +1231,12 @@
 	/* Move the dentry to the target hash queue, if on different bucket */
 	if (dentry->d_flags & DCACHE_UNHASHED)
 		goto already_unhashed;
-	if (dentry->d_bucket != target->d_bucket) {
-		hlist_del_rcu(&dentry->d_hash);
+
+	hlist_del_rcu(&dentry->d_hash);
+
 already_unhashed:
-		dentry->d_bucket = target->d_bucket;
-		hlist_add_head_rcu(&dentry->d_hash, target->d_bucket);
-		dentry->d_flags &= ~DCACHE_UNHASHED;
-	}
+	list = d_hash(target->d_parent, target->d_name.hash);
+	__d_rehash(dentry, list);
 
 	/* Unhash the target: dput() will then get rid of it */
 	__d_drop(target);
@@ -1238,7 +1246,6 @@
 
 	/* Switch the names.. */
 	switch_names(dentry, target);
-	smp_wmb();
 	do_switch(dentry->d_name.len, target->d_name.len);
 	do_switch(dentry->d_name.hash, target->d_name.hash);
 
@@ -1655,8 +1662,6 @@
 EXPORT_SYMBOL(dput);
 EXPORT_SYMBOL(find_inode_number);
 EXPORT_SYMBOL(have_submounts);
-EXPORT_SYMBOL(is_subdir);
 EXPORT_SYMBOL(names_cachep);
-EXPORT_SYMBOL(shrink_dcache_anon);
 EXPORT_SYMBOL(shrink_dcache_parent);
 EXPORT_SYMBOL(shrink_dcache_sb);
diff -Nru a/fs/dcookies.c b/fs/dcookies.c
--- a/fs/dcookies.c	2004-12-24 13:36:16 -08:00
+++ b/fs/dcookies.c	2004-12-24 13:36:16 -08:00
@@ -13,6 +13,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/syscalls.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/list.h>
diff -Nru a/fs/devfs/base.c b/fs/devfs/base.c
--- a/fs/devfs/base.c	2004-12-24 13:36:19 -08:00
+++ b/fs/devfs/base.c	2004-12-24 13:36:19 -08:00
@@ -677,13 +677,13 @@
 #include <linux/rwsem.h>
 #include <linux/sched.h>
 #include <linux/namei.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
-#include <asm/bitops.h>
 #include <asm/atomic.h>
 
 #define DEVFS_VERSION            "2004-01-31"
@@ -1802,7 +1802,6 @@
 
 __setup("devfs=", devfs_setup);
 
-EXPORT_SYMBOL(devfs_mk_symlink);
 EXPORT_SYMBOL(devfs_mk_dir);
 EXPORT_SYMBOL(devfs_remove);
 
diff -Nru a/fs/devfs/util.c b/fs/devfs/util.c
--- a/fs/devfs/util.c	2004-12-24 13:36:56 -08:00
+++ b/fs/devfs/util.c	2004-12-24 13:36:56 -08:00
@@ -71,7 +71,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/genhd.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 int devfs_register_tape(const char *name)
 {
diff -Nru a/fs/devpts/Makefile b/fs/devpts/Makefile
--- a/fs/devpts/Makefile	2004-12-24 13:37:02 -08:00
+++ b/fs/devpts/Makefile	2004-12-24 13:37:02 -08:00
@@ -5,5 +5,4 @@
 obj-$(CONFIG_UNIX98_PTYS)		+= devpts.o
 
 devpts-$(CONFIG_UNIX98_PTYS)		:= inode.o
-devpts-$(CONFIG_DEVPTS_FS_XATTR)	+= xattr.o 
 devpts-$(CONFIG_DEVPTS_FS_SECURITY)	+= xattr_security.o
diff -Nru a/fs/devpts/inode.c b/fs/devpts/inode.c
--- a/fs/devpts/inode.c	2004-12-24 13:36:31 -08:00
+++ b/fs/devpts/inode.c	2004-12-24 13:36:31 -08:00
@@ -18,10 +18,28 @@
 #include <linux/mount.h>
 #include <linux/tty.h>
 #include <linux/devpts_fs.h>
-#include "xattr.h"
+#include <linux/xattr.h>
 
 #define DEVPTS_SUPER_MAGIC 0x1cd1
 
+extern struct xattr_handler devpts_xattr_security_handler;
+
+static struct xattr_handler *devpts_xattr_handlers[] = {
+#ifdef CONFIG_DEVPTS_FS_SECURITY
+	&devpts_xattr_security_handler,
+#endif
+	NULL
+};
+
+struct inode_operations devpts_file_inode_operations = {
+#ifdef CONFIG_DEVPTS_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
+	.listxattr	= generic_listxattr,
+	.removexattr	= generic_removexattr,
+#endif
+};
+
 static struct vfsmount *devpts_mnt;
 static struct dentry *devpts_root;
 
@@ -84,6 +102,7 @@
 	s->s_blocksize_bits = 10;
 	s->s_magic = DEVPTS_SUPER_MAGIC;
 	s->s_op = &devpts_sops;
+	s->s_xattr = devpts_xattr_handlers;
 
 	inode = new_inode(s);
 	if (!inode)
@@ -134,13 +153,6 @@
 	return lookup_one_len(s, root, sprintf(s, "%d", num));
 }
 
-static struct inode_operations devpts_file_inode_operations = {
-	.setxattr	= devpts_setxattr,
-	.getxattr	= devpts_getxattr,
-	.listxattr	= devpts_listxattr,
-	.removexattr	= devpts_removexattr,
-};
-
 int devpts_pty_new(struct tty_struct *tty)
 {
 	int number = tty->index;
@@ -209,10 +221,7 @@
 
 static int __init init_devpts_fs(void)
 {
-	int err = init_devpts_xattr();
-	if (err)
-		return err;
-	err = register_filesystem(&devpts_fs_type);
+	int err = register_filesystem(&devpts_fs_type);
 	if (!err) {
 		devpts_mnt = kern_mount(&devpts_fs_type);
 		if (IS_ERR(devpts_mnt))
@@ -225,7 +234,6 @@
 {
 	unregister_filesystem(&devpts_fs_type);
 	mntput(devpts_mnt);
-	exit_devpts_xattr();
 }
 
 module_init(init_devpts_fs)
diff -Nru a/fs/devpts/xattr.c b/fs/devpts/xattr.c
--- a/fs/devpts/xattr.c	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,214 +0,0 @@
-/*
-  File: fs/devpts/xattr.c
- 
-  Derived from fs/ext3/xattr.c, changed in the following ways:
-      drop everything related to persistent storage of EAs
-      pass dentry rather than inode to internal methods
-      only presently define a handler for security modules
-*/
-
-#include <linux/init.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <asm/semaphore.h>
-#include "xattr.h"
-
-static struct devpts_xattr_handler *devpts_xattr_handlers[DEVPTS_XATTR_INDEX_MAX];
-static rwlock_t devpts_handler_lock = RW_LOCK_UNLOCKED;
-
-int
-devpts_xattr_register(int name_index, struct devpts_xattr_handler *handler)
-{
-	int error = -EINVAL;
-
-	if (name_index > 0 && name_index <= DEVPTS_XATTR_INDEX_MAX) {
-		write_lock(&devpts_handler_lock);
-		if (!devpts_xattr_handlers[name_index-1]) {
-			devpts_xattr_handlers[name_index-1] = handler;
-			error = 0;
-		}
-		write_unlock(&devpts_handler_lock);
-	}
-	return error;
-}
-
-void
-devpts_xattr_unregister(int name_index, struct devpts_xattr_handler *handler)
-{
-	if (name_index > 0 || name_index <= DEVPTS_XATTR_INDEX_MAX) {
-		write_lock(&devpts_handler_lock);
-		devpts_xattr_handlers[name_index-1] = NULL;
-		write_unlock(&devpts_handler_lock);
-	}
-}
-
-static inline const char *
-strcmp_prefix(const char *a, const char *a_prefix)
-{
-	while (*a_prefix && *a == *a_prefix) {
-		a++;
-		a_prefix++;
-	}
-	return *a_prefix ? NULL : a;
-}
-
-/*
- * Decode the extended attribute name, and translate it into
- * the name_index and name suffix.
- */
-static inline struct devpts_xattr_handler *
-devpts_xattr_resolve_name(const char **name)
-{
-	struct devpts_xattr_handler *handler = NULL;
-	int i;
-
-	if (!*name)
-		return NULL;
-	read_lock(&devpts_handler_lock);
-	for (i=0; i<DEVPTS_XATTR_INDEX_MAX; i++) {
-		if (devpts_xattr_handlers[i]) {
-			const char *n = strcmp_prefix(*name,
-				devpts_xattr_handlers[i]->prefix);
-			if (n) {
-				handler = devpts_xattr_handlers[i];
-				*name = n;
-				break;
-			}
-		}
-	}
-	read_unlock(&devpts_handler_lock);
-	return handler;
-}
-
-static inline struct devpts_xattr_handler *
-devpts_xattr_handler(int name_index)
-{
-	struct devpts_xattr_handler *handler = NULL;
-	if (name_index > 0 && name_index <= DEVPTS_XATTR_INDEX_MAX) {
-		read_lock(&devpts_handler_lock);
-		handler = devpts_xattr_handlers[name_index-1];
-		read_unlock(&devpts_handler_lock);
-	}
-	return handler;
-}
-
-/*
- * Inode operation getxattr()
- *
- * dentry->d_inode->i_sem down
- */
-ssize_t
-devpts_getxattr(struct dentry *dentry, const char *name,
-	      void *buffer, size_t size)
-{
-	struct devpts_xattr_handler *handler;
-
-	handler = devpts_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->get(dentry, name, buffer, size);
-}
-
-/*
- * Inode operation listxattr()
- *
- * dentry->d_inode->i_sem down
- */
-ssize_t
-devpts_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
-{
-	struct devpts_xattr_handler *handler = NULL;
-	int i, error = 0;
-	unsigned int size = 0;
-	char *buf;
-
-	read_lock(&devpts_handler_lock);
-
-	for (i=0; i<DEVPTS_XATTR_INDEX_MAX; i++) {
-		handler = devpts_xattr_handlers[i];
-		if (handler)
-			size += handler->list(dentry, NULL);
-	}
-
-	if (!buffer) {
-		error = size;
-		goto out;
-	} else {
-		error = -ERANGE;
-		if (size > buffer_size)
-			goto out;
-	}
-
-	buf = buffer;
-	for (i=0; i<DEVPTS_XATTR_INDEX_MAX; i++) {
-		handler = devpts_xattr_handlers[i];
-		if (handler)
-			buf += handler->list(dentry, buf);
-	}
-	error = size;
-
-out:
-	read_unlock(&devpts_handler_lock);
-	return size;
-}
-
-/*
- * Inode operation setxattr()
- *
- * dentry->d_inode->i_sem down
- */
-int
-devpts_setxattr(struct dentry *dentry, const char *name,
-	      const void *value, size_t size, int flags)
-{
-	struct devpts_xattr_handler *handler;
-
-	if (size == 0)
-		value = "";  /* empty EA, do not remove */
-	handler = devpts_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->set(dentry, name, value, size, flags);
-}
-
-/*
- * Inode operation removexattr()
- *
- * dentry->d_inode->i_sem down
- */
-int
-devpts_removexattr(struct dentry *dentry, const char *name)
-{
-	struct devpts_xattr_handler *handler;
-
-	handler = devpts_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->set(dentry, name, NULL, 0, XATTR_REPLACE);
-}
-
-int __init
-init_devpts_xattr(void)
-{
-#ifdef CONFIG_DEVPTS_FS_SECURITY	
-	int	err;
-
-	err = devpts_xattr_register(DEVPTS_XATTR_INDEX_SECURITY,
-				    &devpts_xattr_security_handler);
-	if (err)
-		return err;
-#endif
-
-	return 0;
-}
-
-void
-exit_devpts_xattr(void)
-{
-#ifdef CONFIG_DEVPTS_FS_SECURITY	
-	devpts_xattr_unregister(DEVPTS_XATTR_INDEX_SECURITY,
-				&devpts_xattr_security_handler);
-#endif
-
-}
diff -Nru a/fs/devpts/xattr.h b/fs/devpts/xattr.h
--- a/fs/devpts/xattr.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,59 +0,0 @@
-/*
-  File: fs/devpts/xattr.h
- 
-  Derived from fs/ext3/xattr.h, changed in the following ways:
-      drop everything related to persistent storage of EAs
-      pass dentry rather than inode to internal methods
-      only presently define a handler for security modules
-*/
-
-#include <linux/config.h>
-#include <linux/xattr.h>
-
-/* Name indexes */
-#define DEVPTS_XATTR_INDEX_MAX			10
-#define DEVPTS_XATTR_INDEX_SECURITY	        1
-
-# ifdef CONFIG_DEVPTS_FS_XATTR
-
-struct devpts_xattr_handler {
-	char *prefix;
-	size_t (*list)(struct dentry *dentry, char *buffer);
-	int (*get)(struct dentry *dentry, const char *name, void *buffer,
-		   size_t size);
-	int (*set)(struct dentry *dentry, const char *name, const void *buffer,
-		   size_t size, int flags);
-};
-
-extern int devpts_xattr_register(int, struct devpts_xattr_handler *);
-extern void devpts_xattr_unregister(int, struct devpts_xattr_handler *);
-
-extern int devpts_setxattr(struct dentry *, const char *, const void *, size_t, int);
-extern ssize_t devpts_getxattr(struct dentry *, const char *, void *, size_t);
-extern ssize_t devpts_listxattr(struct dentry *, char *, size_t);
-extern int devpts_removexattr(struct dentry *, const char *);
-
-extern int init_devpts_xattr(void);
-extern void exit_devpts_xattr(void);
-
-# else  /* CONFIG_DEVPTS_FS_XATTR */
-#  define devpts_setxattr		NULL
-#  define devpts_getxattr		NULL
-#  define devpts_listxattr	NULL
-#  define devpts_removexattr	NULL
-
-static inline int
-init_devpts_xattr(void)
-{
-	return 0;
-}
-
-static inline void
-exit_devpts_xattr(void)
-{
-}
-
-# endif  /* CONFIG_DEVPTS_FS_XATTR */
-
-extern struct devpts_xattr_handler devpts_xattr_security_handler;
-
diff -Nru a/fs/devpts/xattr_security.c b/fs/devpts/xattr_security.c
--- a/fs/devpts/xattr_security.c	2004-12-24 13:36:49 -08:00
+++ b/fs/devpts/xattr_security.c	2004-12-24 13:36:49 -08:00
@@ -1,38 +1,45 @@
 /*
- * File: fs/devpts/xattr_security.c
+ * Security xattr support for devpts.
+ *
+ * Author: Stephen Smalley <sds@epoch.ncsc.mil>
+ * Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.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/module.h>
 #include <linux/string.h>
 #include <linux/fs.h>
 #include <linux/security.h>
-#include "xattr.h"
+#include <linux/xattr.h>
 
 static size_t
-devpts_xattr_security_list(struct dentry *dentry, char *buffer)
+devpts_xattr_security_list(struct inode *inode, char *list, size_t list_len,
+			   const char *name, size_t name_len)
 {
-	return security_inode_listsecurity(dentry, buffer);
+	return security_inode_listsecurity(inode, list, list_len);
 }
 
 static int
-devpts_xattr_security_get(struct dentry *dentry, const char *name,
+devpts_xattr_security_get(struct inode *inode, const char *name,
 			  void *buffer, size_t size)
 {
 	if (strcmp(name, "") == 0)
 		return -EINVAL;
-	return security_inode_getsecurity(dentry, name, buffer, size);
+	return security_inode_getsecurity(inode, name, buffer, size);
 }
 
 static int
-devpts_xattr_security_set(struct dentry *dentry, const char *name,
+devpts_xattr_security_set(struct inode *inode, const char *name,
 			  const void *value, size_t size, int flags)
 {
 	if (strcmp(name, "") == 0)
 		return -EINVAL;
-	return security_inode_setsecurity(dentry, name, value, size, flags);
+	return security_inode_setsecurity(inode, name, value, size, flags);
 }
 
-struct devpts_xattr_handler devpts_xattr_security_handler = {
+struct xattr_handler devpts_xattr_security_handler = {
 	.prefix	= XATTR_SECURITY_PREFIX,
 	.list	= devpts_xattr_security_list,
 	.get	= devpts_xattr_security_get,
diff -Nru a/fs/direct-io.c b/fs/direct-io.c
--- a/fs/direct-io.c	2004-12-24 13:36:59 -08:00
+++ b/fs/direct-io.c	2004-12-24 13:36:59 -08:00
@@ -844,8 +844,10 @@
 				char *kaddr;
 
 				/* AKPM: eargh, -ENOTBLK is a hack */
-				if (dio->rw == WRITE)
+				if (dio->rw == WRITE) {
+					page_cache_release(page);
 					return -ENOTBLK;
+				}
 
 				if (dio->block_in_file >=
 					i_size_read(dio->inode)>>blkbits) {
@@ -1124,11 +1126,23 @@
 
 /*
  * This is a library function for use by filesystem drivers.
+ * The locking rules are governed by the dio_lock_type parameter.
+ *
+ * DIO_NO_LOCKING (no locking, for raw block device access)
+ * For writes, i_sem is not held on entry; it is never taken.
  *
- * For writes to S_ISREG files, we are called under i_sem and return with i_sem
- * held, even though it is internally dropped.
+ * DIO_LOCKING (simple locking for regular files)
+ * For writes we are called under i_sem and return with i_sem held, even though
+ * it is internally dropped.
+ * For reads, i_sem is not held on entry, but it is taken and dropped before
+ * returning.
  *
- * For writes to S_ISBLK files, i_sem is not held on entry; it is never taken.
+ * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of
+ *	uninitialised data, allowing parallel direct readers and writers)
+ * For writes we are called without i_sem, return without it, never touch it.
+ * For reads, i_sem is held on entry and will be released before returning.
+ *
+ * Additional i_alloc_sem locking requirements described inline below.
  */
 ssize_t
 __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
@@ -1145,6 +1159,10 @@
 	ssize_t retval = -EINVAL;
 	loff_t end = offset;
 	struct dio *dio;
+	int reader_with_isem = (rw == READ && dio_lock_type == DIO_OWN_LOCKING);
+
+	if (rw & WRITE)
+		current->flags |= PF_SYNCWRITE;
 
 	if (bdev)
 		bdev_blkbits = blksize_bits(bdev_hardsect_size(bdev));
@@ -1177,12 +1195,14 @@
 		goto out;
 
 	/*
+	 * For block device access DIO_NO_LOCKING is used,
+	 *	neither readers nor writers do any locking at all
 	 * For regular files using DIO_LOCKING,
 	 *	readers need to grab i_sem and i_alloc_sem
 	 *	writers need to grab i_alloc_sem only (i_sem is already held)
 	 * For regular files using DIO_OWN_LOCKING,
-	 *	both readers and writers need to grab i_alloc_sem
-	 *	neither readers nor writers hold i_sem on entry (nor exit)
+	 *	readers need to grab i_alloc_sem only (i_sem is already held)
+	 *	writers need to grab i_alloc_sem only
 	 */
 	dio->lock_type = dio_lock_type;
 	if (dio_lock_type != DIO_NO_LOCKING) {
@@ -1190,20 +1210,25 @@
 			struct address_space *mapping;
 
 			mapping = iocb->ki_filp->f_mapping;
-			down(&inode->i_sem);
+			if (dio_lock_type != DIO_OWN_LOCKING) {
+				down(&inode->i_sem);
+				reader_with_isem = 1;
+			}
 			retval = filemap_write_and_wait(mapping);
 			if (retval) {
-				up(&inode->i_sem);
 				kfree(dio);
 				goto out;
 			}
 			down_read(&inode->i_alloc_sem);
-			if (dio_lock_type == DIO_OWN_LOCKING)
+			if (dio_lock_type == DIO_OWN_LOCKING) {
 				up(&inode->i_sem);
+				reader_with_isem = 0;
+			}
 		} else {
 			down_read(&inode->i_alloc_sem);
 		}
 	}
+
 	/*
 	 * For file extending writes updating i_size before data
 	 * writeouts complete can expose uninitialized blocks. So
@@ -1215,7 +1240,15 @@
 
 	retval = direct_io_worker(rw, iocb, inode, iov, offset,
 				nr_segs, blkbits, get_blocks, end_io, dio);
+
+	if (rw == READ && dio_lock_type == DIO_LOCKING)
+		reader_with_isem = 0;
+
 out:
+	if (reader_with_isem)
+		up(&inode->i_sem);
+	if (rw & WRITE)
+		current->flags &= ~PF_SYNCWRITE;
 	return retval;
 }
 EXPORT_SYMBOL(__blockdev_direct_IO);
diff -Nru a/fs/dquot.c b/fs/dquot.c
--- a/fs/dquot.c	2004-12-24 13:37:01 -08:00
+++ b/fs/dquot.c	2004-12-24 13:37:01 -08:00
@@ -758,7 +758,7 @@
 		dquot->dq_dqb.dqb_curinodes -= number;
 	else
 		dquot->dq_dqb.dqb_curinodes = 0;
-	if (dquot->dq_dqb.dqb_curinodes < dquot->dq_dqb.dqb_isoftlimit)
+	if (dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit)
 		dquot->dq_dqb.dqb_itime = (time_t) 0;
 	clear_bit(DQ_INODES_B, &dquot->dq_flags);
 }
@@ -769,7 +769,7 @@
 		dquot->dq_dqb.dqb_curspace -= number;
 	else
 		dquot->dq_dqb.dqb_curspace = 0;
-	if (toqb(dquot->dq_dqb.dqb_curspace) < dquot->dq_dqb.dqb_bsoftlimit)
+	if (toqb(dquot->dq_dqb.dqb_curspace) <= dquot->dq_dqb.dqb_bsoftlimit)
 		dquot->dq_dqb.dqb_btime = (time_t) 0;
 	clear_bit(DQ_BLKS_B, &dquot->dq_flags);
 }
@@ -811,22 +811,22 @@
 	tty_write_message(current->signal->tty, quotatypes[dquot->dq_type]);
 	switch (warntype) {
 		case IHARDWARN:
-			msg = " file limit reached.\n";
+			msg = " file limit reached.\r\n";
 			break;
 		case ISOFTLONGWARN:
-			msg = " file quota exceeded too long.\n";
+			msg = " file quota exceeded too long.\r\n";
 			break;
 		case ISOFTWARN:
-			msg = " file quota exceeded.\n";
+			msg = " file quota exceeded.\r\n";
 			break;
 		case BHARDWARN:
-			msg = " block limit reached.\n";
+			msg = " block limit reached.\r\n";
 			break;
 		case BSOFTLONGWARN:
-			msg = " block quota exceeded too long.\n";
+			msg = " block quota exceeded too long.\r\n";
 			break;
 		case BSOFTWARN:
-			msg = " block quota exceeded.\n";
+			msg = " block quota exceeded.\r\n";
 			break;
 	}
 	tty_write_message(current->signal->tty, msg);
diff -Nru a/fs/efs/namei.c b/fs/efs/namei.c
--- a/fs/efs/namei.c	2004-12-24 13:37:01 -08:00
+++ b/fs/efs/namei.c	2004-12-24 13:37:01 -08:00
@@ -75,3 +75,36 @@
 	return NULL;
 }
 
+struct dentry *efs_get_parent(struct dentry *child)
+{
+	struct dentry *parent;
+	struct inode *inode;
+	efs_ino_t ino;
+	int error;
+
+	lock_kernel();
+
+	error = -ENOENT;
+	ino = efs_find_entry(child->d_inode, "..", 2);
+	if (!ino)
+		goto fail;
+
+	error = -EACCES;
+	inode = iget(child->d_inode->i_sb, ino);
+	if (!inode)
+		goto fail;
+
+	error = -ENOMEM;
+	parent = d_alloc_anon(inode);
+	if (!parent)
+		goto fail_iput;
+
+	unlock_kernel();
+	return parent;
+
+ fail_iput:
+	iput(inode);
+ fail:
+	unlock_kernel();
+	return ERR_PTR(error);
+}
diff -Nru a/fs/efs/super.c b/fs/efs/super.c
--- a/fs/efs/super.c	2004-12-24 13:37:18 -08:00
+++ b/fs/efs/super.c	2004-12-24 13:37:18 -08:00
@@ -95,6 +95,10 @@
 	.remount_fs	= efs_remount,
 };
 
+static struct export_operations efs_export_ops = {
+	.get_parent	= efs_get_parent,
+};
+
 static int __init init_efs_fs(void) {
 	int err;
 	printk("EFS: "EFS_VERSION" - http://aeschi.ch.eu.org/efs/\n");
@@ -278,6 +282,7 @@
 		s->s_flags |= MS_RDONLY;
 	}
 	s->s_op   = &efs_superblock_operations;
+	s->s_export_op = &efs_export_ops;
 	root = iget(s, EFS_ROOTINODE);
 	s->s_root = d_alloc_root(root);
  
diff -Nru a/fs/eventpoll.c b/fs/eventpoll.c
--- a/fs/eventpoll.c	2004-12-24 13:36:47 -08:00
+++ b/fs/eventpoll.c	2004-12-24 13:36:47 -08:00
@@ -33,7 +33,7 @@
 #include <linux/wait.h>
 #include <linux/eventpoll.h>
 #include <linux/mount.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/io.h>
diff -Nru a/fs/exec.c b/fs/exec.c
--- a/fs/exec.c	2004-12-24 13:36:47 -08:00
+++ b/fs/exec.c	2004-12-24 13:36:47 -08:00
@@ -34,6 +34,7 @@
 #include <linux/pagemap.h>
 #include <linux/highmem.h>
 #include <linux/spinlock.h>
+#include <linux/key.h>
 #include <linux/personality.h>
 #include <linux/binfmts.h>
 #include <linux/swap.h>
@@ -341,7 +342,7 @@
 	unsigned long stack_base;
 	struct vm_area_struct *mpnt;
 	struct mm_struct *mm = current->mm;
-	int i;
+	int i, ret;
 	long arg_size;
 
 #ifdef CONFIG_STACK_GROWSUP
@@ -377,7 +378,7 @@
 	bprm->p = PAGE_SIZE * i - offset;
 
 	/* Limit stack size to 1GB */
-	stack_base = current->rlim[RLIMIT_STACK].rlim_max;
+	stack_base = current->signal->rlim[RLIMIT_STACK].rlim_max;
 	if (stack_base > (1 << 30))
 		stack_base = 1 << 30;
 	stack_base = PAGE_ALIGN(STACK_TOP - stack_base);
@@ -432,7 +433,11 @@
 			mpnt->vm_flags = VM_STACK_FLAGS;
 		mpnt->vm_flags |= mm->def_flags;
 		mpnt->vm_page_prot = protection_map[mpnt->vm_flags & 0x7];
-		insert_vm_struct(mm, mpnt);
+		if ((ret = insert_vm_struct(mm, mpnt))) {
+			up_write(&mm->mmap_sem);
+			kmem_cache_free(vm_area_cachep, mpnt);
+			return ret;
+		}
 		mm->stack_vm = mm->total_vm = vma_pages(mpnt);
 	}
 
@@ -529,12 +534,6 @@
 	struct task_struct *tsk;
 	struct mm_struct * old_mm, *active_mm;
 
-	/* Add it to the list of mm's */
-	spin_lock(&mmlist_lock);
-	list_add(&mm->mmlist, &init_mm.mmlist);
-	mmlist_nr++;
-	spin_unlock(&mmlist_lock);
-
 	/* Notify parent that we're no longer interested in the old VM */
 	tsk = current;
 	old_mm = current->mm;
@@ -564,7 +563,7 @@
  */
 static inline int de_thread(struct task_struct *tsk)
 {
-	struct signal_struct *newsig, *oldsig = tsk->signal;
+	struct signal_struct *sig = tsk->signal;
 	struct sighand_struct *newsighand, *oldsighand = tsk->sighand;
 	spinlock_t *lock = &oldsighand->siglock;
 	int count;
@@ -573,43 +572,16 @@
 	 * If we don't share sighandlers, then we aren't sharing anything
 	 * and we can just re-use it all.
 	 */
-	if (atomic_read(&oldsighand->count) <= 1)
+	if (atomic_read(&oldsighand->count) <= 1) {
+		BUG_ON(atomic_read(&sig->count) != 1);
+		exit_itimers(sig);
 		return 0;
+	}
 
 	newsighand = kmem_cache_alloc(sighand_cachep, GFP_KERNEL);
 	if (!newsighand)
 		return -ENOMEM;
 
-	spin_lock_init(&newsighand->siglock);
-	atomic_set(&newsighand->count, 1);
-	memcpy(newsighand->action, oldsighand->action, sizeof(newsighand->action));
-
-	/*
-	 * See if we need to allocate a new signal structure
-	 */
-	newsig = NULL;
-	if (atomic_read(&oldsig->count) > 1) {
-		newsig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
-		if (!newsig) {
-			kmem_cache_free(sighand_cachep, newsighand);
-			return -ENOMEM;
-		}
-		atomic_set(&newsig->count, 1);
-		newsig->group_exit = 0;
-		newsig->group_exit_code = 0;
-		newsig->group_exit_task = NULL;
-		newsig->group_stop_count = 0;
-		newsig->curr_target = NULL;
-		init_sigpending(&newsig->shared_pending);
-		INIT_LIST_HEAD(&newsig->posix_timers);
-
-		newsig->tty = oldsig->tty;
-		newsig->pgrp = oldsig->pgrp;
-		newsig->session = oldsig->session;
-		newsig->leader = oldsig->leader;
-		newsig->tty_old_pgrp = oldsig->tty_old_pgrp;
-	}
-
 	if (thread_group_empty(current))
 		goto no_thread_group;
 
@@ -619,7 +591,7 @@
 	 */
 	read_lock(&tasklist_lock);
 	spin_lock_irq(lock);
-	if (oldsig->group_exit) {
+	if (sig->group_exit) {
 		/*
 		 * Another group action in progress, just
 		 * return so that the signal is processed.
@@ -627,11 +599,9 @@
 		spin_unlock_irq(lock);
 		read_unlock(&tasklist_lock);
 		kmem_cache_free(sighand_cachep, newsighand);
-		if (newsig)
-			kmem_cache_free(signal_cachep, newsig);
 		return -EAGAIN;
 	}
-	oldsig->group_exit = 1;
+	sig->group_exit = 1;
 	zap_other_threads(current);
 	read_unlock(&tasklist_lock);
 
@@ -641,14 +611,16 @@
 	count = 2;
 	if (current->pid == current->tgid)
 		count = 1;
-	while (atomic_read(&oldsig->count) > count) {
-		oldsig->group_exit_task = current;
-		oldsig->notify_count = count;
+	while (atomic_read(&sig->count) > count) {
+		sig->group_exit_task = current;
+		sig->notify_count = count;
 		__set_current_state(TASK_UNINTERRUPTIBLE);
 		spin_unlock_irq(lock);
 		schedule();
 		spin_lock_irq(lock);
 	}
+	sig->group_exit_task = NULL;
+	sig->notify_count = 0;
 	spin_unlock_irq(lock);
 
 	/*
@@ -659,14 +631,14 @@
 	if (current->pid != current->tgid) {
 		struct task_struct *leader = current->group_leader, *parent;
 		struct dentry *proc_dentry1, *proc_dentry2;
-		unsigned long state, ptrace;
+		unsigned long exit_state, ptrace;
 
 		/*
 		 * Wait for the thread group leader to be a zombie.
 		 * It should already be zombie at this point, most
 		 * of the time.
 		 */
-		while (leader->state != TASK_ZOMBIE)
+		while (leader->exit_state != EXIT_ZOMBIE)
 			yield();
 
 		spin_lock(&leader->proc_lock);
@@ -710,7 +682,7 @@
 		list_del(&current->tasks);
 		list_add_tail(&current->tasks, &init_task.tasks);
 		current->exit_signal = SIGCHLD;
-		state = leader->state;
+		exit_state = leader->exit_state;
 
 		write_unlock_irq(&tasklist_lock);
 		spin_unlock(&leader->proc_lock);
@@ -718,36 +690,51 @@
 		proc_pid_flush(proc_dentry1);
 		proc_pid_flush(proc_dentry2);
 
-		if (state != TASK_ZOMBIE)
+		if (exit_state != EXIT_ZOMBIE)
 			BUG();
 		release_task(leader);
         }
 
+	/*
+	 * Now there are really no other threads at all,
+	 * so it's safe to stop telling them to kill themselves.
+	 */
+	sig->group_exit = 0;
+
 no_thread_group:
+	BUG_ON(atomic_read(&sig->count) != 1);
+	exit_itimers(sig);
 
-	write_lock_irq(&tasklist_lock);
-	spin_lock(&oldsighand->siglock);
-	spin_lock(&newsighand->siglock);
-
-	if (current == oldsig->curr_target)
-		oldsig->curr_target = next_thread(current);
-	if (newsig)
-		current->signal = newsig;
-	current->sighand = newsighand;
-	init_sigpending(&current->pending);
-	recalc_sigpending();
-
-	spin_unlock(&newsighand->siglock);
-	spin_unlock(&oldsighand->siglock);
-	write_unlock_irq(&tasklist_lock);
-
-	if (newsig && atomic_dec_and_test(&oldsig->count)) {
-		exit_itimers(oldsig);
-		kmem_cache_free(signal_cachep, oldsig);
-	}
+	if (atomic_read(&oldsighand->count) == 1) {
+		/*
+		 * Now that we nuked the rest of the thread group,
+		 * it turns out we are not sharing sighand any more either.
+		 * So we can just keep it.
+		 */
+		kmem_cache_free(sighand_cachep, newsighand);
+	} else {
+		/*
+		 * Move our state over to newsighand and switch it in.
+		 */
+		spin_lock_init(&newsighand->siglock);
+		atomic_set(&newsighand->count, 1);
+		memcpy(newsighand->action, oldsighand->action,
+		       sizeof(newsighand->action));
+
+		write_lock_irq(&tasklist_lock);
+		spin_lock(&oldsighand->siglock);
+		spin_lock(&newsighand->siglock);
+
+		current->sighand = newsighand;
+		recalc_sigpending();
+
+		spin_unlock(&newsighand->siglock);
+		spin_unlock(&oldsighand->siglock);
+		write_unlock_irq(&tasklist_lock);
 
-	if (atomic_dec_and_test(&oldsighand->count))
-		kmem_cache_free(sighand_cachep, oldsighand);
+		if (atomic_dec_and_test(&oldsighand->count))
+			kmem_cache_free(sighand_cachep, oldsighand);
+	}
 
 	if (!thread_group_empty(current))
 		BUG();
@@ -860,8 +847,10 @@
 
 	if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || 
 	    permission(bprm->file->f_dentry->d_inode,MAY_READ, NULL) ||
-	    (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP))
+	    (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) {
+		suid_keys(current);
 		current->mm->dumpable = 0;
+	}
 
 	/* An exec changes our domain. We are no longer part of the thread
 	   group */
@@ -895,7 +884,7 @@
 	mode = inode->i_mode;
 	/*
 	 * Check execute perms again - if the caller has CAP_DAC_OVERRIDE,
-	 * vfs_permission lets a non-executable through
+	 * generic_permission lets a non-executable through
 	 */
 	if (!(mode & 0111))	/* with at least _one_ execute bit set */
 		return -EACCES;
@@ -955,6 +944,11 @@
 void compute_creds(struct linux_binprm *bprm)
 {
 	int unsafe;
+
+	if (bprm->e_uid != current->uid)
+		suid_keys(current);
+	exec_keys(current);
+
 	task_lock(current);
 	unsafe = unsafe_exec(current);
 	security_bprm_apply_creds(bprm, unsafe);
@@ -994,7 +988,7 @@
  */
 int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
 {
-	int try,retval=0;
+	int try,retval;
 	struct linux_binfmt *fmt;
 #ifdef __alpha__
 	/* handle /sbin/loader.. */
@@ -1038,6 +1032,7 @@
 	/* kernel module loader fixup */
 	/* so we don't try to load run modprobe in kernel space. */
 	set_fs(USER_DS);
+	retval = -ENOENT;
 	for (try=0; try<2; try++) {
 		read_lock(&binfmt_lock);
 		for (fmt = formats ; fmt ; fmt = fmt->next) {
@@ -1099,26 +1094,26 @@
 	int retval;
 	int i;
 
-	file = open_exec(filename);
-
-	retval = PTR_ERR(file);
-	if (IS_ERR(file))
-		return retval;
-
-	sched_exec();
-
 	retval = -ENOMEM;
 	bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
 	if (!bprm)
 		goto out_ret;
 	memset(bprm, 0, sizeof(*bprm));
 
+	file = open_exec(filename);
+	retval = PTR_ERR(file);
+	if (IS_ERR(file))
+		goto out_kfree;
+
+	sched_exec();
+
 	bprm->p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
 
 	bprm->file = file;
 	bprm->filename = filename;
 	bprm->interp = filename;
 	bprm->mm = mm_alloc();
+	retval = -ENOMEM;
 	if (!bprm->mm)
 		goto out_file;
 
@@ -1185,14 +1180,14 @@
 		allow_write_access(bprm->file);
 		fput(bprm->file);
 	}
+
+out_kfree:
 	kfree(bprm);
 
 out_ret:
 	return retval;
 }
 
-EXPORT_SYMBOL(do_execve);
-
 int set_binfmt(struct linux_binfmt *new)
 {
 	struct linux_binfmt *old = current->binfmt;
@@ -1393,7 +1388,7 @@
 	current->signal->group_exit_code = exit_code;
 	coredump_wait(mm);
 
-	if (current->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump)
+	if (current->signal->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump)
 		goto fail_unlock;
 
 	/*
@@ -1423,7 +1418,8 @@
 
 	retval = binfmt->core_dump(signr, regs, file);
 
-	current->signal->group_exit_code |= 0x80;
+	if (retval)
+		current->signal->group_exit_code |= 0x80;
 close_fail:
 	filp_close(file, NULL);
 fail_unlock:
diff -Nru a/fs/ext2/acl.c b/fs/ext2/acl.c
--- a/fs/ext2/acl.c	2004-12-24 13:37:18 -08:00
+++ b/fs/ext2/acl.c	2004-12-24 13:37:18 -08:00
@@ -280,60 +280,24 @@
 	return error;
 }
 
-/*
- * Inode operation permission().
- *
- * inode->i_sem: don't care
- */
-int
-ext2_permission(struct inode *inode, int mask, struct nameidata *nd)
+static int
+ext2_check_acl(struct inode *inode, int mask)
 {
-	int mode = inode->i_mode;
+	struct posix_acl *acl = ext2_get_acl(inode, ACL_TYPE_ACCESS);
 
-	/* Nobody gets write access to a read-only fs */
-	if ((mask & MAY_WRITE) && IS_RDONLY(inode) &&
-	    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
-		return -EROFS;
-	/* Nobody gets write access to an immutable file */
-	if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
-	    return -EACCES;
-	if (current->fsuid == inode->i_uid) {
-		mode >>= 6;
-	} else if (test_opt(inode->i_sb, POSIX_ACL)) {
-		struct posix_acl *acl;
-
-		/* The access ACL cannot grant access if the group class
-		   permission bits don't contain all requested permissions. */
-		if (((mode >> 3) & mask & S_IRWXO) != mask)
-			goto check_groups;
-		acl = ext2_get_acl(inode, ACL_TYPE_ACCESS);
-		if (acl) {
-			int error = posix_acl_permission(inode, acl, mask);
-			posix_acl_release(acl);
-			if (error == -EACCES)
-				goto check_capabilities;
-			return error;
-		} else
-			goto check_groups;
-	} else {
-check_groups:
-		if (in_group_p(inode->i_gid))
-			mode >>= 3;
+	if (acl) {
+		int error = posix_acl_permission(inode, acl, mask);
+		posix_acl_release(acl);
+		return error;
 	}
-	if ((mode & mask & S_IRWXO) == mask)
-		return 0;
 
-check_capabilities:
-	/* Allowed to override Discretionary Access Control? */
-	if (!(mask & MAY_EXEC) ||
-	    (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode))
-		if (capable(CAP_DAC_OVERRIDE))
-			return 0;
-	/* Read and search granted if capable(CAP_DAC_READ_SEARCH) */
-	if (capable(CAP_DAC_READ_SEARCH) && ((mask == MAY_READ) ||
-	    (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE))))
-		return 0;
-	return -EACCES;
+	return -EAGAIN;
+}
+
+int
+ext2_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+	return generic_permission(inode, mask, ext2_check_acl);
 }
 
 /*
@@ -429,27 +393,27 @@
  * Extended attribut handlers
  */
 static size_t
-ext2_xattr_list_acl_access(char *list, struct inode *inode,
-			   const char *name, int name_len)
+ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size,
+			   const char *name, size_t name_len)
 {
 	const size_t size = sizeof(XATTR_NAME_ACL_ACCESS);
 
 	if (!test_opt(inode->i_sb, POSIX_ACL))
 		return 0;
-	if (list)
+	if (list && size <= list_size)
 		memcpy(list, XATTR_NAME_ACL_ACCESS, size);
 	return size;
 }
 
 static size_t
-ext2_xattr_list_acl_default(char *list, struct inode *inode,
-			    const char *name, int name_len)
+ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size,
+			    const char *name, size_t name_len)
 {
 	const size_t size = sizeof(XATTR_NAME_ACL_DEFAULT);
 
 	if (!test_opt(inode->i_sb, POSIX_ACL))
 		return 0;
-	if (list)
+	if (list && size <= list_size)
 		memcpy(list, XATTR_NAME_ACL_DEFAULT, size);
 	return size;
 }
@@ -541,45 +505,16 @@
 	return ext2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
 }
 
-struct ext2_xattr_handler ext2_xattr_acl_access_handler = {
+struct xattr_handler ext2_xattr_acl_access_handler = {
 	.prefix	= XATTR_NAME_ACL_ACCESS,
 	.list	= ext2_xattr_list_acl_access,
 	.get	= ext2_xattr_get_acl_access,
 	.set	= ext2_xattr_set_acl_access,
 };
 
-struct ext2_xattr_handler ext2_xattr_acl_default_handler = {
+struct xattr_handler ext2_xattr_acl_default_handler = {
 	.prefix	= XATTR_NAME_ACL_DEFAULT,
 	.list	= ext2_xattr_list_acl_default,
 	.get	= ext2_xattr_get_acl_default,
 	.set	= ext2_xattr_set_acl_default,
 };
-
-void
-exit_ext2_acl(void)
-{
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_POSIX_ACL_ACCESS,
-			      &ext2_xattr_acl_access_handler);
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT,
-			      &ext2_xattr_acl_default_handler);
-}
-
-int __init
-init_ext2_acl(void)
-{
-	int error;
-
-	error = ext2_xattr_register(EXT2_XATTR_INDEX_POSIX_ACL_ACCESS,
-				    &ext2_xattr_acl_access_handler);
-	if (error)
-		goto fail;
-	error = ext2_xattr_register(EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT,
-				    &ext2_xattr_acl_default_handler);
-	if (error)
-		goto fail;
-	return 0;
-
-fail:
-	exit_ext2_acl();
-	return error;
-}
diff -Nru a/fs/ext2/acl.h b/fs/ext2/acl.h
--- a/fs/ext2/acl.h	2004-12-24 13:37:03 -08:00
+++ b/fs/ext2/acl.h	2004-12-24 13:37:03 -08:00
@@ -63,9 +63,6 @@
 extern int ext2_acl_chmod (struct inode *);
 extern int ext2_init_acl (struct inode *, struct inode *);
 
-extern int init_ext2_acl(void);
-extern void exit_ext2_acl(void);
-
 #else
 #include <linux/sched.h>
 #define ext2_permission NULL
diff -Nru a/fs/ext2/dir.c b/fs/ext2/dir.c
--- a/fs/ext2/dir.c	2004-12-24 13:36:55 -08:00
+++ b/fs/ext2/dir.c	2004-12-24 13:36:55 -08:00
@@ -275,7 +275,8 @@
 				   "bad page in #%lu",
 				   inode->i_ino);
 			filp->f_pos += PAGE_CACHE_SIZE - offset;
-			continue;
+			ret = -EIO;
+			goto done;
 		}
 		kaddr = page_address(page);
 		if (need_revalidate) {
diff -Nru a/fs/ext2/ext2.h b/fs/ext2/ext2.h
--- a/fs/ext2/ext2.h	2004-12-24 13:37:31 -08:00
+++ b/fs/ext2/ext2.h	2004-12-24 13:37:31 -08:00
@@ -116,7 +116,6 @@
 /* inode.c */
 extern void ext2_read_inode (struct inode *);
 extern int ext2_write_inode (struct inode *, int);
-extern void ext2_put_inode (struct inode *);
 extern void ext2_delete_inode (struct inode *);
 extern int ext2_sync_inode (struct inode *);
 extern void ext2_discard_prealloc (struct inode *);
diff -Nru a/fs/ext2/file.c b/fs/ext2/file.c
--- a/fs/ext2/file.c	2004-12-24 13:36:47 -08:00
+++ b/fs/ext2/file.c	2004-12-24 13:36:47 -08:00
@@ -57,10 +57,12 @@
 
 struct inode_operations ext2_file_inode_operations = {
 	.truncate	= ext2_truncate,
-	.setxattr	= ext2_setxattr,
-	.getxattr	= ext2_getxattr,
+#ifdef CONFIG_EXT2_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext2_listxattr,
-	.removexattr	= ext2_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 	.setattr	= ext2_setattr,
 	.permission	= ext2_permission,
 };
diff -Nru a/fs/ext2/inode.c b/fs/ext2/inode.c
--- a/fs/ext2/inode.c	2004-12-24 13:36:17 -08:00
+++ b/fs/ext2/inode.c	2004-12-24 13:36:17 -08:00
@@ -53,19 +53,6 @@
 }
 
 /*
- * Called at each iput().
- *
- * The inode may be "bad" if ext2_read_inode() saw an error from
- * ext2_get_inode(), so we need to check that to avoid freeing random disk
- * blocks.
- */
-void ext2_put_inode(struct inode *inode)
-{
-	if (!is_bad_inode(inode))
-		ext2_discard_prealloc(inode);
-}
-
-/*
  * Called at the last iput() if i_nlink is zero.
  */
 void ext2_delete_inode (struct inode * inode)
diff -Nru a/fs/ext2/namei.c b/fs/ext2/namei.c
--- a/fs/ext2/namei.c	2004-12-24 13:37:19 -08:00
+++ b/fs/ext2/namei.c	2004-12-24 13:37:19 -08:00
@@ -2,7 +2,8 @@
  * linux/fs/ext2/namei.c
  *
  * Rewrite to pagecache. Almost all code had been changed, so blame me
- * if the things go wrong. Please, send bug reports to viro@math.psu.edu
+ * if the things go wrong. Please, send bug reports to
+ * viro@parcelfarce.linux.theplanet.co.uk
  *
  * Stuff here is basically a glue between the VFS and generic UNIXish
  * filesystem that keeps everything in pagecache. All knowledge of the
@@ -395,19 +396,23 @@
 	.rmdir		= ext2_rmdir,
 	.mknod		= ext2_mknod,
 	.rename		= ext2_rename,
-	.setxattr	= ext2_setxattr,
-	.getxattr	= ext2_getxattr,
+#ifdef CONFIG_EXT2_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext2_listxattr,
-	.removexattr	= ext2_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 	.setattr	= ext2_setattr,
 	.permission	= ext2_permission,
 };
 
 struct inode_operations ext2_special_inode_operations = {
-	.setxattr	= ext2_setxattr,
-	.getxattr	= ext2_getxattr,
+#ifdef CONFIG_EXT2_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext2_listxattr,
-	.removexattr	= ext2_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 	.setattr	= ext2_setattr,
 	.permission	= ext2_permission,
 };
diff -Nru a/fs/ext2/super.c b/fs/ext2/super.c
--- a/fs/ext2/super.c	2004-12-24 13:37:01 -08:00
+++ b/fs/ext2/super.c	2004-12-24 13:37:01 -08:00
@@ -122,6 +122,9 @@
 			brelse (sbi->s_group_desc[i]);
 	kfree(sbi->s_group_desc);
 	kfree(sbi->s_debts);
+	percpu_counter_destroy(&sbi->s_freeblocks_counter);
+	percpu_counter_destroy(&sbi->s_freeinodes_counter);
+	percpu_counter_destroy(&sbi->s_dirs_counter);
 	brelse (sbi->s_sbh);
 	sb->s_fs_info = NULL;
 	kfree(sbi);
@@ -181,10 +184,9 @@
 		printk(KERN_INFO "ext2_inode_cache: not all structures were freed\n");
 }
 
-#ifdef CONFIG_EXT2_FS_POSIX_ACL
-
 static void ext2_clear_inode(struct inode *inode)
 {
+#ifdef CONFIG_EXT2_FS_POSIX_ACL
 	struct ext2_inode_info *ei = EXT2_I(inode);
 
 	if (ei->i_acl && ei->i_acl != EXT2_ACL_NOT_CACHED) {
@@ -195,18 +197,17 @@
 		posix_acl_release(ei->i_default_acl);
 		ei->i_default_acl = EXT2_ACL_NOT_CACHED;
 	}
+#endif
+	if (!is_bad_inode(inode))
+		ext2_discard_prealloc(inode);
 }
 
-#else
-# define ext2_clear_inode NULL
-#endif
 
 static struct super_operations ext2_sops = {
 	.alloc_inode	= ext2_alloc_inode,
 	.destroy_inode	= ext2_destroy_inode,
 	.read_inode	= ext2_read_inode,
 	.write_inode	= ext2_write_inode,
-	.put_inode	= ext2_put_inode,
 	.delete_inode	= ext2_delete_inode,
 	.put_super	= ext2_put_super,
 	.write_super	= ext2_write_super,
@@ -595,12 +596,9 @@
 	sbi->s_es = es;
 	sb->s_magic = le16_to_cpu(es->s_magic);
 	sb->s_flags |= MS_ONE_SECOND;
-	if (sb->s_magic != EXT2_SUPER_MAGIC) {
-		if (!silent)
-			printk ("VFS: Can't find ext2 filesystem on dev %s.\n",
-				sb->s_id);
-		goto failed_mount;
-	}
+
+	if (sb->s_magic != EXT2_SUPER_MAGIC)
+		goto cantfind_ext2;
 
 	/* Set defaults before we parse the mount options */
 	def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
@@ -655,7 +653,9 @@
 		       sb->s_id, le32_to_cpu(features));
 		goto failed_mount;
 	}
+
 	blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
+
 	/* If the blocksize doesn't match, re-read the thing.. */
 	if (sb->s_blocksize != blocksize) {
 		brelse(bh);
@@ -697,35 +697,36 @@
 			goto failed_mount;
 		}
 	}
+
 	sbi->s_frag_size = EXT2_MIN_FRAG_SIZE <<
 				   le32_to_cpu(es->s_log_frag_size);
-	if (sbi->s_frag_size)
-		sbi->s_frags_per_block = sb->s_blocksize /
-						  sbi->s_frag_size;
-	else
-		sb->s_magic = 0;
+	if (sbi->s_frag_size == 0)
+		goto cantfind_ext2;
+	sbi->s_frags_per_block = sb->s_blocksize / sbi->s_frag_size;
+
 	sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
 	sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
 	sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
-	sbi->s_inodes_per_block = sb->s_blocksize /
-					   EXT2_INODE_SIZE(sb);
+
+	if (EXT2_INODE_SIZE(sb) == 0)
+		goto cantfind_ext2;
+	sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
+	if (sbi->s_inodes_per_block == 0)
+		goto cantfind_ext2;
 	sbi->s_itb_per_group = sbi->s_inodes_per_group /
-				        sbi->s_inodes_per_block;
+					sbi->s_inodes_per_block;
 	sbi->s_desc_per_block = sb->s_blocksize /
-					 sizeof (struct ext2_group_desc);
+					sizeof (struct ext2_group_desc);
 	sbi->s_sbh = bh;
 	sbi->s_mount_state = le16_to_cpu(es->s_state);
 	sbi->s_addr_per_block_bits =
 		log2 (EXT2_ADDR_PER_BLOCK(sb));
 	sbi->s_desc_per_block_bits =
 		log2 (EXT2_DESC_PER_BLOCK(sb));
-	if (sb->s_magic != EXT2_SUPER_MAGIC) {
-		if (!silent)
-			printk ("VFS: Can't find an ext2 filesystem on dev "
-				"%s.\n",
-				sb->s_id);
-		goto failed_mount;
-	}
+
+	if (sb->s_magic != EXT2_SUPER_MAGIC)
+		goto cantfind_ext2;
+
 	if (sb->s_blocksize != bh->b_size) {
 		if (!silent)
 			printk ("VFS: Unsupported blocksize on dev "
@@ -755,6 +756,8 @@
 		goto failed_mount;
 	}
 
+	if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
+		goto cantfind_ext2;
 	sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) -
 				        le32_to_cpu(es->s_first_data_block) +
 				       EXT2_BLOCKS_PER_GROUP(sb) - 1) /
@@ -800,6 +803,7 @@
 	 */
 	sb->s_op = &ext2_sops;
 	sb->s_export_op = &ext2_export_ops;
+	sb->s_xattr = ext2_xattr_handlers;
 	root = iget(sb, EXT2_ROOT_INO);
 	sb->s_root = d_alloc_root(root);
 	if (!sb->s_root) {
@@ -824,13 +828,19 @@
 	percpu_counter_mod(&sbi->s_dirs_counter,
 				ext2_count_dirs(sb));
 	return 0;
+
+cantfind_ext2:
+	if (!silent)
+		printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
+		       sb->s_id);
+	goto failed_mount;
+
 failed_mount2:
 	for (i = 0; i < db_count; i++)
 		brelse(sbi->s_group_desc[i]);
 failed_mount_group_desc:
 	kfree(sbi->s_group_desc);
-	if (sbi->s_debts)
-		kfree(sbi->s_debts);
+	kfree(sbi->s_debts);
 failed_mount:
 	brelse(bh);
 failed_sbi:
diff -Nru a/fs/ext2/symlink.c b/fs/ext2/symlink.c
--- a/fs/ext2/symlink.c	2004-12-24 13:36:31 -08:00
+++ b/fs/ext2/symlink.c	2004-12-24 13:36:31 -08:00
@@ -32,17 +32,21 @@
 	.readlink	= generic_readlink,
 	.follow_link	= page_follow_link_light,
 	.put_link	= page_put_link,
-	.setxattr	= ext2_setxattr,
-	.getxattr	= ext2_getxattr,
+#ifdef CONFIG_EXT2_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext2_listxattr,
-	.removexattr	= ext2_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 };
  
 struct inode_operations ext2_fast_symlink_inode_operations = {
 	.readlink	= generic_readlink,
 	.follow_link	= ext2_follow_link,
-	.setxattr	= ext2_setxattr,
-	.getxattr	= ext2_getxattr,
+#ifdef CONFIG_EXT2_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext2_listxattr,
-	.removexattr	= ext2_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 };
diff -Nru a/fs/ext2/xattr.c b/fs/ext2/xattr.c
--- a/fs/ext2/xattr.c	2004-12-24 13:37:00 -08:00
+++ b/fs/ext2/xattr.c	2004-12-24 13:37:00 -08:00
@@ -6,6 +6,9 @@
  * Fix by Harrison Xing <harrison@mountainviewdata.com>.
  * Extended attributes for symlinks and special files added per
  *  suggestion of Luka Renko <luka.renko@hermes.si>.
+ * xattr consolidation Copyright (c) 2004 James Morris <jmorris@redhat.com>,
+ *  Red Hat Inc.
+ *
  */
 
 /*
@@ -61,13 +64,6 @@
 #include "xattr.h"
 #include "acl.h"
 
-/* These symbols may be needed by a module. */
-EXPORT_SYMBOL(ext2_xattr_register);
-EXPORT_SYMBOL(ext2_xattr_unregister);
-EXPORT_SYMBOL(ext2_xattr_get);
-EXPORT_SYMBOL(ext2_xattr_list);
-EXPORT_SYMBOL(ext2_xattr_set);
-
 #define HDR(bh) ((struct ext2_xattr_header *)((bh)->b_data))
 #define ENTRY(ptr) ((struct ext2_xattr_entry *)(ptr))
 #define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
@@ -104,101 +100,40 @@
 			      struct ext2_xattr_entry *);
 
 static struct mb_cache *ext2_xattr_cache;
-static struct ext2_xattr_handler *ext2_xattr_handlers[EXT2_XATTR_INDEX_MAX];
-static rwlock_t ext2_handler_lock = RW_LOCK_UNLOCKED;
-
-int
-ext2_xattr_register(int name_index, struct ext2_xattr_handler *handler)
-{
-	int error = -EINVAL;
-
-	if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
-		write_lock(&ext2_handler_lock);
-		if (!ext2_xattr_handlers[name_index-1]) {
-			ext2_xattr_handlers[name_index-1] = handler;
-			error = 0;
-		}
-		write_unlock(&ext2_handler_lock);
-	}
-	return error;
-}
-
-void
-ext2_xattr_unregister(int name_index, struct ext2_xattr_handler *handler)
-{
-	if (name_index > 0 || name_index <= EXT2_XATTR_INDEX_MAX) {
-		write_lock(&ext2_handler_lock);
-		ext2_xattr_handlers[name_index-1] = NULL;
-		write_unlock(&ext2_handler_lock);
-	}
-}
-
-static inline const char *
-strcmp_prefix(const char *a, const char *a_prefix)
-{
-	while (*a_prefix && *a == *a_prefix) {
-		a++;
-		a_prefix++;
-	}
-	return *a_prefix ? NULL : a;
-}
 
-/*
- * Decode the extended attribute name, and translate it into
- * the name_index and name suffix.
- */
-static struct ext2_xattr_handler *
-ext2_xattr_resolve_name(const char **name)
-{
-	struct ext2_xattr_handler *handler = NULL;
-	int i;
+static struct xattr_handler *ext2_xattr_handler_map[EXT2_XATTR_INDEX_MAX] = {
+	[EXT2_XATTR_INDEX_USER]		     = &ext2_xattr_user_handler,
+#ifdef CONFIG_EXT2_FS_POSIX_ACL
+	[EXT2_XATTR_INDEX_POSIX_ACL_ACCESS]  = &ext2_xattr_acl_access_handler,
+	[EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext2_xattr_acl_default_handler,
+#endif
+	[EXT2_XATTR_INDEX_TRUSTED]	     = &ext2_xattr_trusted_handler,
+#ifdef CONFIG_EXT2_FS_SECURITY
+	[EXT2_XATTR_INDEX_SECURITY]	     = &ext2_xattr_security_handler,
+#endif
+};
 
-	if (!*name)
-		return NULL;
-	read_lock(&ext2_handler_lock);
-	for (i=0; i<EXT2_XATTR_INDEX_MAX; i++) {
-		if (ext2_xattr_handlers[i]) {
-			const char *n = strcmp_prefix(*name,
-				ext2_xattr_handlers[i]->prefix);
-			if (n) {
-				handler = ext2_xattr_handlers[i];
-				*name = n;
-				break;
-			}
-		}
-	}
-	read_unlock(&ext2_handler_lock);
-	return handler;
-}
+struct xattr_handler *ext2_xattr_handlers[] = {
+	&ext2_xattr_user_handler,
+	&ext2_xattr_trusted_handler,
+#ifdef CONFIG_EXT2_FS_POSIX_ACL
+	&ext2_xattr_acl_access_handler,
+	&ext2_xattr_acl_default_handler,
+#endif
+#ifdef CONFIG_EXT2_FS_SECURITY
+	&ext2_xattr_security_handler,
+#endif
+	NULL
+};
 
-static inline struct ext2_xattr_handler *
+static inline struct xattr_handler *
 ext2_xattr_handler(int name_index)
 {
-	struct ext2_xattr_handler *handler = NULL;
-	if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
-		read_lock(&ext2_handler_lock);
-		handler = ext2_xattr_handlers[name_index-1];
-		read_unlock(&ext2_handler_lock);
-	}
-	return handler;
-}
-
-/*
- * Inode operation getxattr()
- *
- * dentry->d_inode->i_sem: don't care
- */
-ssize_t
-ext2_getxattr(struct dentry *dentry, const char *name,
-	      void *buffer, size_t size)
-{
-	struct ext2_xattr_handler *handler;
-	struct inode *inode = dentry->d_inode;
+	struct xattr_handler *handler = NULL;
 
-	handler = ext2_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->get(inode, name, buffer, size);
+	if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX)
+		handler = ext2_xattr_handler_map[name_index];
+	return handler;
 }
 
 /*
@@ -213,43 +148,6 @@
 }
 
 /*
- * Inode operation setxattr()
- *
- * dentry->d_inode->i_sem: down
- */
-int
-ext2_setxattr(struct dentry *dentry, const char *name,
-	      const void *value, size_t size, int flags)
-{
-	struct ext2_xattr_handler *handler;
-	struct inode *inode = dentry->d_inode;
-
-	if (size == 0)
-		value = "";  /* empty EA, do not remove */
-	handler = ext2_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->set(inode, name, value, size, flags);
-}
-
-/*
- * Inode operation removexattr()
- *
- * dentry->d_inode->i_sem: down
- */
-int
-ext2_removexattr(struct dentry *dentry, const char *name)
-{
-	struct ext2_xattr_handler *handler;
-	struct inode *inode = dentry->d_inode;
-
-	handler = ext2_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
-}
-
-/*
  * ext2_xattr_get()
  *
  * Copy an extended attribute into the buffer
@@ -367,8 +265,8 @@
 {
 	struct buffer_head *bh = NULL;
 	struct ext2_xattr_entry *entry;
-	size_t size = 0;
-	char *buf, *end;
+	char *end;
+	size_t rest = buffer_size;
 	int error;
 
 	ea_idebug(inode, "buffer=%p, buffer_size=%ld",
@@ -394,44 +292,40 @@
 		error = -EIO;
 		goto cleanup;
 	}
-	/* compute the size required for the list of attribute names */
-	for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
-	     entry = EXT2_XATTR_NEXT(entry)) {
-		struct ext2_xattr_handler *handler;
-		struct ext2_xattr_entry *next =
-			EXT2_XATTR_NEXT(entry);
+
+	/* check the on-disk data structure */
+	entry = FIRST_ENTRY(bh);
+	while (!IS_LAST_ENTRY(entry)) {
+		struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(entry);
+
 		if ((char *)next >= end)
 			goto bad_block;
-
-		handler = ext2_xattr_handler(entry->e_name_index);
-		if (handler)
-			size += handler->list(NULL, inode, entry->e_name,
-					      entry->e_name_len);
+		entry = next;
 	}
-
 	if (ext2_xattr_cache_insert(bh))
 		ea_idebug(inode, "cache insert failed");
-	if (!buffer) {
-		error = size;
-		goto cleanup;
-	} else {
-		error = -ERANGE;
-		if (size > buffer_size)
-			goto cleanup;
-	}
 
 	/* list the attribute names */
-	buf = buffer;
 	for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
 	     entry = EXT2_XATTR_NEXT(entry)) {
-		struct ext2_xattr_handler *handler;
-		
-		handler = ext2_xattr_handler(entry->e_name_index);
-		if (handler)
-			buf += handler->list(buf, inode, entry->e_name,
-					     entry->e_name_len);
+		struct xattr_handler *handler =
+			ext2_xattr_handler(entry->e_name_index);
+
+		if (handler) {
+			size_t size = handler->list(inode, buffer, rest,
+						    entry->e_name,
+						    entry->e_name_len);
+			if (buffer) {
+				if (size > rest) {
+					error = -ERANGE;
+					goto cleanup;
+				}
+				buffer += size;
+			}
+			rest -= size;
+		}
 	}
-	error = size;
+	error = buffer_size - rest;  /* total size */
 
 cleanup:
 	brelse(bh);
@@ -1120,66 +1014,16 @@
 int __init
 init_ext2_xattr(void)
 {
-	int	err;
-	
-	err = ext2_xattr_register(EXT2_XATTR_INDEX_USER,
-				  &ext2_xattr_user_handler);
-	if (err)
-		return err;
-	err = ext2_xattr_register(EXT2_XATTR_INDEX_TRUSTED,
-				  &ext2_xattr_trusted_handler);
-	if (err)
-		goto out;
-#ifdef CONFIG_EXT2_FS_SECURITY
-	err = ext2_xattr_register(EXT2_XATTR_INDEX_SECURITY,
-				  &ext2_xattr_security_handler);
-	if (err)
-		goto out1;
-#endif
-#ifdef CONFIG_EXT2_FS_POSIX_ACL
-	err = init_ext2_acl();
-	if (err)
-		goto out2;
-#endif
 	ext2_xattr_cache = mb_cache_create("ext2_xattr", NULL,
 		sizeof(struct mb_cache_entry) +
 		sizeof(struct mb_cache_entry_index), 1, 6);
-	if (!ext2_xattr_cache) {
-		err = -ENOMEM;
-		goto out3;
-	}
+	if (!ext2_xattr_cache)
+		return -ENOMEM;
 	return 0;
-out3:
-#ifdef CONFIG_EXT2_FS_POSIX_ACL
-	exit_ext2_acl();
-out2:
-#endif
-#ifdef CONFIG_EXT2_FS_SECURITY
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_SECURITY,
-			      &ext2_xattr_security_handler);
-out1:
-#endif
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_TRUSTED,
-			      &ext2_xattr_trusted_handler);
-out:
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_USER,
-			      &ext2_xattr_user_handler);
-	return err;
 }
 
 void
 exit_ext2_xattr(void)
 {
 	mb_cache_destroy(ext2_xattr_cache);
-#ifdef CONFIG_EXT2_FS_POSIX_ACL
-	exit_ext2_acl();
-#endif
-#ifdef CONFIG_EXT2_FS_SECURITY
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_SECURITY,
-			      &ext2_xattr_security_handler);
-#endif
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_TRUSTED,
-			      &ext2_xattr_trusted_handler);
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_USER,
-			      &ext2_xattr_user_handler);
 }
diff -Nru a/fs/ext2/xattr.h b/fs/ext2/xattr.h
--- a/fs/ext2/xattr.h	2004-12-24 13:37:01 -08:00
+++ b/fs/ext2/xattr.h	2004-12-24 13:37:01 -08:00
@@ -57,23 +57,13 @@
 
 # ifdef CONFIG_EXT2_FS_XATTR
 
-struct ext2_xattr_handler {
-	char *prefix;
-	size_t (*list)(char *list, struct inode *inode, const char *name,
-		       int name_len);
-	int (*get)(struct inode *inode, const char *name, void *buffer,
-		   size_t size);
-	int (*set)(struct inode *inode, const char *name, const void *buffer,
-		   size_t size, int flags);
-};
+extern struct xattr_handler ext2_xattr_user_handler;
+extern struct xattr_handler ext2_xattr_trusted_handler;
+extern struct xattr_handler ext2_xattr_acl_access_handler;
+extern struct xattr_handler ext2_xattr_acl_default_handler;
+extern struct xattr_handler ext2_xattr_security_handler;
 
-extern int ext2_xattr_register(int, struct ext2_xattr_handler *);
-extern void ext2_xattr_unregister(int, struct ext2_xattr_handler *);
-
-extern int ext2_setxattr(struct dentry *, const char *, const void *, size_t, int);
-extern ssize_t ext2_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
-extern int ext2_removexattr(struct dentry *, const char *);
 
 extern int ext2_xattr_get(struct inode *, int, const char *, void *, size_t);
 extern int ext2_xattr_list(struct inode *, char *, size_t);
@@ -85,11 +75,9 @@
 extern int init_ext2_xattr(void);
 extern void exit_ext2_xattr(void);
 
+extern struct xattr_handler *ext2_xattr_handlers[];
+
 # else  /* CONFIG_EXT2_FS_XATTR */
-#  define ext2_setxattr		NULL
-#  define ext2_getxattr		NULL
-#  define ext2_listxattr	NULL
-#  define ext2_removexattr	NULL
 
 static inline int
 ext2_xattr_get(struct inode *inode, int name_index,
@@ -132,9 +120,7 @@
 {
 }
 
-# endif  /* CONFIG_EXT2_FS_XATTR */
+#define ext2_xattr_handlers NULL
 
-extern struct ext2_xattr_handler ext2_xattr_user_handler;
-extern struct ext2_xattr_handler ext2_xattr_trusted_handler;
-extern struct ext2_xattr_handler ext2_xattr_security_handler;
+# endif  /* CONFIG_EXT2_FS_XATTR */
 
diff -Nru a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c
--- a/fs/ext2/xattr_security.c	2004-12-24 13:36:55 -08:00
+++ b/fs/ext2/xattr_security.c	2004-12-24 13:36:55 -08:00
@@ -11,17 +11,18 @@
 #include "xattr.h"
 
 static size_t
-ext2_xattr_security_list(char *list, struct inode *inode,
-			const char *name, int name_len)
+ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size,
+			 const char *name, size_t name_len)
 {
 	const int prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
+	const size_t total_len = prefix_len + name_len + 1;
 
-	if (list) {
+	if (list && total_len <= list_size) {
 		memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
 		memcpy(list+prefix_len, name, name_len);
 		list[prefix_len + name_len] = '\0';
 	}
-	return prefix_len + name_len + 1;
+	return total_len;
 }
 
 static int
@@ -44,7 +45,7 @@
 			      value, size, flags);
 }
 
-struct ext2_xattr_handler ext2_xattr_security_handler = {
+struct xattr_handler ext2_xattr_security_handler = {
 	.prefix	= XATTR_SECURITY_PREFIX,
 	.list	= ext2_xattr_security_list,
 	.get	= ext2_xattr_security_get,
diff -Nru a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c
--- a/fs/ext2/xattr_trusted.c	2004-12-24 13:36:18 -08:00
+++ b/fs/ext2/xattr_trusted.c	2004-12-24 13:36:18 -08:00
@@ -15,20 +15,21 @@
 #define XATTR_TRUSTED_PREFIX "trusted."
 
 static size_t
-ext2_xattr_trusted_list(char *list, struct inode *inode,
-			const char *name, int name_len)
+ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
+			const char *name, size_t name_len)
 {
 	const int prefix_len = sizeof(XATTR_TRUSTED_PREFIX)-1;
+	const size_t total_len = prefix_len + name_len + 1;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return 0;
 
-	if (list) {
+	if (list && total_len <= list_size) {
 		memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len);
 		memcpy(list+prefix_len, name, name_len);
 		list[prefix_len + name_len] = '\0';
 	}
-	return prefix_len + name_len + 1;
+	return total_len;
 }
 
 static int
@@ -55,7 +56,7 @@
 			      value, size, flags);
 }
 
-struct ext2_xattr_handler ext2_xattr_trusted_handler = {
+struct xattr_handler ext2_xattr_trusted_handler = {
 	.prefix	= XATTR_TRUSTED_PREFIX,
 	.list	= ext2_xattr_trusted_list,
 	.get	= ext2_xattr_trusted_get,
diff -Nru a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c
--- a/fs/ext2/xattr_user.c	2004-12-24 13:37:00 -08:00
+++ b/fs/ext2/xattr_user.c	2004-12-24 13:37:00 -08:00
@@ -14,20 +14,21 @@
 #define XATTR_USER_PREFIX "user."
 
 static size_t
-ext2_xattr_user_list(char *list, struct inode *inode,
-		     const char *name, int name_len)
+ext2_xattr_user_list(struct inode *inode, char *list, size_t list_size,
+		     const char *name, size_t name_len)
 {
-	const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
+	const size_t prefix_len = sizeof(XATTR_USER_PREFIX)-1;
+	const size_t total_len = prefix_len + name_len + 1;
 
 	if (!test_opt(inode->i_sb, XATTR_USER))
 		return 0;
 
-	if (list) {
+	if (list && total_len <= list_size) {
 		memcpy(list, XATTR_USER_PREFIX, prefix_len);
 		memcpy(list+prefix_len, name, name_len);
 		list[prefix_len + name_len] = '\0';
 	}
-	return prefix_len + name_len + 1;
+	return total_len;
 }
 
 static int
@@ -68,23 +69,9 @@
 			      value, size, flags);
 }
 
-struct ext2_xattr_handler ext2_xattr_user_handler = {
+struct xattr_handler ext2_xattr_user_handler = {
 	.prefix	= XATTR_USER_PREFIX,
 	.list	= ext2_xattr_user_list,
 	.get	= ext2_xattr_user_get,
 	.set	= ext2_xattr_user_set,
 };
-
-int __init
-init_ext2_xattr_user(void)
-{
-	return ext2_xattr_register(EXT2_XATTR_INDEX_USER,
-				   &ext2_xattr_user_handler);
-}
-
-void
-exit_ext2_xattr_user(void)
-{
-	ext2_xattr_unregister(EXT2_XATTR_INDEX_USER,
-			      &ext2_xattr_user_handler);
-}
diff -Nru a/fs/ext3/Makefile b/fs/ext3/Makefile
--- a/fs/ext3/Makefile	2004-12-24 13:36:18 -08:00
+++ b/fs/ext3/Makefile	2004-12-24 13:36:18 -08:00
@@ -5,7 +5,7 @@
 obj-$(CONFIG_EXT3_FS) += ext3.o
 
 ext3-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
-	   ioctl.o namei.o super.o symlink.o hash.o
+	   ioctl.o namei.o super.o symlink.o hash.o resize.o
 
 ext3-$(CONFIG_EXT3_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
 ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
diff -Nru a/fs/ext3/acl.c b/fs/ext3/acl.c
--- a/fs/ext3/acl.c	2004-12-24 13:36:47 -08:00
+++ b/fs/ext3/acl.c	2004-12-24 13:36:47 -08:00
@@ -285,60 +285,24 @@
 	return error;
 }
 
-/*
- * Inode operation permission().
- *
- * inode->i_sem: don't care
- */
-int
-ext3_permission(struct inode *inode, int mask, struct nameidata *nd)
+static int
+ext3_check_acl(struct inode *inode, int mask)
 {
-	int mode = inode->i_mode;
+	struct posix_acl *acl = ext3_get_acl(inode, ACL_TYPE_ACCESS);
 
-	/* Nobody gets write access to a read-only fs */
-	if ((mask & MAY_WRITE) && IS_RDONLY(inode) &&
-	    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
-		return -EROFS;
-	/* Nobody gets write access to an immutable file */
-	if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
-	    return -EACCES;
-	if (current->fsuid == inode->i_uid) {
-		mode >>= 6;
-	} else if (test_opt(inode->i_sb, POSIX_ACL)) {
-		struct posix_acl *acl;
-
-		/* The access ACL cannot grant access if the group class
-		   permission bits don't contain all requested permissions. */
-		if (((mode >> 3) & mask & S_IRWXO) != mask)
-			goto check_groups;
-		acl = ext3_get_acl(inode, ACL_TYPE_ACCESS);
-		if (acl) {
-			int error = posix_acl_permission(inode, acl, mask);
-			posix_acl_release(acl);
-			if (error == -EACCES)
-				goto check_capabilities;
-			return error;
-		} else
-			goto check_groups;
-	} else {
-check_groups:
-		if (in_group_p(inode->i_gid))
-			mode >>= 3;
+	if (acl) {
+		int error = posix_acl_permission(inode, acl, mask);
+		posix_acl_release(acl);
+		return error;
 	}
-	if ((mode & mask & S_IRWXO) == mask)
-		return 0;
 
-check_capabilities:
-	/* Allowed to override Discretionary Access Control? */
-	if (!(mask & MAY_EXEC) ||
-	    (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode))
-		if (capable(CAP_DAC_OVERRIDE))
-			return 0;
-	/* Read and search granted if capable(CAP_DAC_READ_SEARCH) */
-	if (capable(CAP_DAC_READ_SEARCH) && ((mask == MAY_READ) ||
-	    (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE))))
-		return 0;
-	return -EACCES;
+	return -EAGAIN;
+}
+
+int
+ext3_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+	return generic_permission(inode, mask, ext3_check_acl);
 }
 
 /*
@@ -452,27 +416,27 @@
  * Extended attribute handlers
  */
 static size_t
-ext3_xattr_list_acl_access(char *list, struct inode *inode,
-			   const char *name, int name_len)
+ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
+			   const char *name, size_t name_len)
 {
 	const size_t size = sizeof(XATTR_NAME_ACL_ACCESS);
 
 	if (!test_opt(inode->i_sb, POSIX_ACL))
 		return 0;
-	if (list)
+	if (list && size <= list_len)
 		memcpy(list, XATTR_NAME_ACL_ACCESS, size);
 	return size;
 }
 
 static size_t
-ext3_xattr_list_acl_default(char *list, struct inode *inode,
-			    const char *name, int name_len)
+ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
+			    const char *name, size_t name_len)
 {
 	const size_t size = sizeof(XATTR_NAME_ACL_DEFAULT);
 
 	if (!test_opt(inode->i_sb, POSIX_ACL))
 		return 0;
-	if (list)
+	if (list && size <= list_len)
 		memcpy(list, XATTR_NAME_ACL_DEFAULT, size);
 	return size;
 }
@@ -572,45 +536,16 @@
 	return ext3_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
 }
 
-struct ext3_xattr_handler ext3_xattr_acl_access_handler = {
+struct xattr_handler ext3_xattr_acl_access_handler = {
 	.prefix	= XATTR_NAME_ACL_ACCESS,
 	.list	= ext3_xattr_list_acl_access,
 	.get	= ext3_xattr_get_acl_access,
 	.set	= ext3_xattr_set_acl_access,
 };
 
-struct ext3_xattr_handler ext3_xattr_acl_default_handler = {
+struct xattr_handler ext3_xattr_acl_default_handler = {
 	.prefix	= XATTR_NAME_ACL_DEFAULT,
 	.list	= ext3_xattr_list_acl_default,
 	.get	= ext3_xattr_get_acl_default,
 	.set	= ext3_xattr_set_acl_default,
 };
-
-void
-exit_ext3_acl(void)
-{
-	ext3_xattr_unregister(EXT3_XATTR_INDEX_POSIX_ACL_ACCESS,
-			      &ext3_xattr_acl_access_handler);
-	ext3_xattr_unregister(EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT,
-			      &ext3_xattr_acl_default_handler);
-}
-
-int __init
-init_ext3_acl(void)
-{
-	int error;
-
-	error = ext3_xattr_register(EXT3_XATTR_INDEX_POSIX_ACL_ACCESS,
-				    &ext3_xattr_acl_access_handler);
-	if (error)
-		goto fail;
-	error = ext3_xattr_register(EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT,
-				    &ext3_xattr_acl_default_handler);
-	if (error)
-		goto fail;
-	return 0;
-
-fail:
-	exit_ext3_acl();
-	return error;
-}
diff -Nru a/fs/ext3/balloc.c b/fs/ext3/balloc.c
--- a/fs/ext3/balloc.c	2004-12-24 13:36:17 -08:00
+++ b/fs/ext3/balloc.c	2004-12-24 13:36:17 -08:00
@@ -54,6 +54,7 @@
 
 		return NULL;
 	}
+	smp_rmb();
 
 	group_desc = block_group / EXT3_DESC_PER_BLOCK(sb);
 	desc = block_group % EXT3_DESC_PER_BLOCK(sb);
@@ -96,10 +97,186 @@
 error_out:
 	return bh;
 }
+/*
+ * The reservation window structure operations
+ * --------------------------------------------
+ * Operations include:
+ * dump, find, add, remove, is_empty, find_next_reservable_window, etc.
+ *
+ * We use sorted double linked list for the per-filesystem reservation
+ * window list. (like in vm_region).
+ *
+ * Initially, we keep those small operations in the abstract functions,
+ * so later if we need a better searching tree than double linked-list,
+ * we could easily switch to that without changing too much
+ * code.
+ */
+#if 0
+static void __rsv_window_dump(struct rb_root *root, int verbose,
+			      const char *fn)
+{
+	struct rb_node *n;
+	struct ext3_reserve_window_node *rsv, *prev;
+	int bad;
+
+restart:
+	n = rb_first(root);
+	bad = 0;
+	prev = NULL;
+
+	printk("Block Allocation Reservation Windows Map (%s):\n", fn);
+	while (n) {
+		rsv = list_entry(n, struct ext3_reserve_window_node, rsv_node);
+		if (verbose)
+			printk("reservation window 0x%p "
+			       "start:  %d, end:  %d\n",
+			       rsv, rsv->rsv_start, rsv->rsv_end);
+		if (rsv->rsv_start && rsv->rsv_start >= rsv->rsv_end) {
+			printk("Bad reservation %p (start >= end)\n",
+			       rsv);
+			bad = 1;
+		}
+		if (prev && prev->rsv_end >= rsv->rsv_start) {
+			printk("Bad reservation %p (prev->end >= start)\n",
+			       rsv);
+			bad = 1;
+		}
+		if (bad) {
+			if (!verbose) {
+				printk("Restarting reservation walk in verbose mode\n");
+				verbose = 1;
+				goto restart;
+			}
+		}
+		n = rb_next(n);
+		prev = rsv;
+	}
+	printk("Window map complete.\n");
+	if (bad)
+		BUG();
+}
+#define rsv_window_dump(root, verbose) \
+	__rsv_window_dump((root), (verbose), __FUNCTION__)
+#else
+#define rsv_window_dump(root, verbose) do {} while (0)
+#endif
+
+static int
+goal_in_my_reservation(struct ext3_reserve_window *rsv, int goal,
+			unsigned int group, struct super_block * sb)
+{
+	unsigned long group_first_block, group_last_block;
+
+	group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
+				group * EXT3_BLOCKS_PER_GROUP(sb);
+	group_last_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1;
+
+	if ((rsv->_rsv_start > group_last_block) ||
+	    (rsv->_rsv_end < group_first_block))
+		return 0;
+	if ((goal >= 0) && ((goal + group_first_block < rsv->_rsv_start)
+		|| (goal + group_first_block > rsv->_rsv_end)))
+		return 0;
+	return 1;
+}
+
+/*
+ * Find the reserved window which includes the goal, or the previous one
+ * if the goal is not in any window.
+ * Returns NULL if there are no windows or if all windows start after the goal.
+ */
+static struct ext3_reserve_window_node *
+search_reserve_window(struct rb_root *root, unsigned long goal)
+{
+	struct rb_node *n = root->rb_node;
+	struct ext3_reserve_window_node *rsv;
+
+	if (!n)
+		return NULL;
+
+	do {
+		rsv = rb_entry(n, struct ext3_reserve_window_node, rsv_node);
+
+		if (goal < rsv->rsv_start)
+			n = n->rb_left;
+		else if (goal > rsv->rsv_end)
+			n = n->rb_right;
+		else
+			return rsv;
+	} while (n);
+	/*
+	 * We've fallen off the end of the tree: the goal wasn't inside
+	 * any particular node.  OK, the previous node must be to one
+	 * side of the interval containing the goal.  If it's the RHS,
+	 * we need to back up one.
+	 */
+	if (rsv->rsv_start > goal) {
+		n = rb_prev(&rsv->rsv_node);
+		rsv = rb_entry(n, struct ext3_reserve_window_node, rsv_node);
+	}
+	return rsv;
+}
+
+void ext3_rsv_window_add(struct super_block *sb,
+		    struct ext3_reserve_window_node *rsv)
+{
+	struct rb_root *root = &EXT3_SB(sb)->s_rsv_window_root;
+	struct rb_node *node = &rsv->rsv_node;
+	unsigned int start = rsv->rsv_start;
+
+	struct rb_node ** p = &root->rb_node;
+	struct rb_node * parent = NULL;
+	struct ext3_reserve_window_node *this;
+
+	while (*p)
+	{
+		parent = *p;
+		this = rb_entry(parent, struct ext3_reserve_window_node, rsv_node);
+
+		if (start < this->rsv_start)
+			p = &(*p)->rb_left;
+		else if (start > this->rsv_end)
+			p = &(*p)->rb_right;
+		else
+			BUG();
+	}
+
+	rb_link_node(node, parent, p);
+	rb_insert_color(node, root);
+}
+
+static void rsv_window_remove(struct super_block *sb,
+			      struct ext3_reserve_window_node *rsv)
+{
+	rsv->rsv_start = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
+	rsv->rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
+	atomic_set(&rsv->rsv_alloc_hit, 0);
+	rb_erase(&rsv->rsv_node, &EXT3_SB(sb)->s_rsv_window_root);
+}
+
+static inline int rsv_is_empty(struct ext3_reserve_window *rsv)
+{
+	/* a valid reservation end block could not be 0 */
+	return (rsv->_rsv_end == EXT3_RESERVE_WINDOW_NOT_ALLOCATED);
+}
+
+void ext3_discard_reservation(struct inode *inode)
+{
+	struct ext3_inode_info *ei = EXT3_I(inode);
+	struct ext3_reserve_window_node *rsv = &ei->i_rsv_window;
+	spinlock_t *rsv_lock = &EXT3_SB(inode->i_sb)->s_rsv_window_lock;
+
+	if (!rsv_is_empty(&rsv->rsv_window)) {
+		spin_lock(rsv_lock);
+		rsv_window_remove(inode->i_sb, rsv);
+		spin_unlock(rsv_lock);
+	}
+}
 
 /* Free given blocks, update quota and i_blocks field */
-void ext3_free_blocks (handle_t *handle, struct inode * inode,
-			unsigned long block, unsigned long count)
+void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb,
+			 unsigned long block, unsigned long count,
+			 int *pdquot_freed_blocks)
 {
 	struct buffer_head *bitmap_bh = NULL;
 	struct buffer_head *gd_bh;
@@ -107,18 +284,12 @@
 	unsigned long bit;
 	unsigned long i;
 	unsigned long overflow;
-	struct super_block * sb;
 	struct ext3_group_desc * gdp;
 	struct ext3_super_block * es;
 	struct ext3_sb_info *sbi;
 	int err = 0, ret;
-	int dquot_freed_blocks = 0;
 
-	sb = inode->i_sb;
-	if (!sb) {
-		printk ("ext3_free_blocks: nonexistent device");
-		return;
-	}
+	*pdquot_freed_blocks = 0;
 	sbi = EXT3_SB(sb);
 	es = EXT3_SB(sb)->s_es;
 	if (block < le32_to_cpu(es->s_first_data_block) ||
@@ -245,7 +416,7 @@
 			jbd_lock_bh_state(bitmap_bh);
 			BUFFER_TRACE(bitmap_bh, "bit already cleared");
 		} else {
-			dquot_freed_blocks++;
+			(*pdquot_freed_blocks)++;
 		}
 	}
 	jbd_unlock_bh_state(bitmap_bh);
@@ -253,7 +424,7 @@
 	spin_lock(sb_bgl_lock(sbi, block_group));
 	gdp->bg_free_blocks_count =
 		cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) +
-			dquot_freed_blocks);
+			*pdquot_freed_blocks);
 	spin_unlock(sb_bgl_lock(sbi, block_group));
 	percpu_counter_mod(&sbi->s_freeblocks_counter, count);
 
@@ -275,6 +446,22 @@
 error_return:
 	brelse(bitmap_bh);
 	ext3_std_error(sb, err);
+	return;
+}
+
+/* Free given blocks, update quota and i_blocks field */
+void ext3_free_blocks(handle_t *handle, struct inode *inode,
+			unsigned long block, unsigned long count)
+{
+	struct super_block * sb;
+	int dquot_freed_blocks;
+
+	sb = inode->i_sb;
+	if (!sb) {
+		printk ("ext3_free_blocks: nonexistent device");
+		return;
+	}
+	ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
 	if (dquot_freed_blocks)
 		DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
 	return;
@@ -296,7 +483,7 @@
  * data-writes at some point, and disable it for metadata allocations or
  * sync-data inodes.
  */
-static inline int ext3_test_allocatable(int nr, struct buffer_head *bh)
+static int ext3_test_allocatable(int nr, struct buffer_head *bh)
 {
 	int ret;
 	struct journal_head *jh = bh2jh(bh);
@@ -313,6 +500,33 @@
 	return ret;
 }
 
+static int
+bitmap_search_next_usable_block(int start, struct buffer_head *bh,
+					int maxblocks)
+{
+	int next;
+	struct journal_head *jh = bh2jh(bh);
+
+	/*
+	 * The bitmap search --- search forward alternately through the actual
+	 * bitmap and the last-committed copy until we find a bit free in
+	 * both
+	 */
+	while (start < maxblocks) {
+		next = ext3_find_next_zero_bit(bh->b_data, maxblocks, start);
+		if (next >= maxblocks)
+			return -1;
+		if (ext3_test_allocatable(next, bh))
+			return next;
+		jbd_lock_bh_state(bh);
+		if (jh->b_committed_data)
+			start = ext3_find_next_zero_bit(jh->b_committed_data,
+						 	maxblocks, next);
+		jbd_unlock_bh_state(bh);
+	}
+	return -1;
+}
+
 /*
  * Find an allocatable block in a bitmap.  We honour both the bitmap and
  * its last-committed copy (if that exists), and perform the "most
@@ -325,7 +539,6 @@
 {
 	int here, next;
 	char *p, *r;
-	struct journal_head *jh = bh2jh(bh);
 
 	if (start > 0) {
 		/*
@@ -337,6 +550,8 @@
 		 * next 64-bit boundary is simple..
 		 */
 		int end_goal = (start + 63) & ~63;
+		if (end_goal > maxblocks)
+			end_goal = maxblocks;
 		here = ext3_find_next_zero_bit(bh->b_data, end_goal, start);
 		if (here < end_goal && ext3_test_allocatable(here, bh))
 			return here;
@@ -351,7 +566,7 @@
 	r = memscan(p, 0, (maxblocks - here + 7) >> 3);
 	next = (r - ((char *)bh->b_data)) << 3;
 
-	if (next < maxblocks && ext3_test_allocatable(next, bh))
+	if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh))
 		return next;
 
 	/*
@@ -359,19 +574,8 @@
 	 * bitmap and the last-committed copy until we find a bit free in
 	 * both
 	 */
-	while (here < maxblocks) {
-		next = ext3_find_next_zero_bit(bh->b_data, maxblocks, here);
-		if (next >= maxblocks)
-			return -1;
-		if (ext3_test_allocatable(next, bh))
-			return next;
-		jbd_lock_bh_state(bh);
-		if (jh->b_committed_data)
-			here = ext3_find_next_zero_bit(jh->b_committed_data,
-						 	maxblocks, next);
-		jbd_unlock_bh_state(bh);
-	}
-	return -1;
+	here = bitmap_search_next_usable_block(here, bh, maxblocks);
+	return here;
 }
 
 /*
@@ -407,62 +611,484 @@
  */
 static int
 ext3_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
-		struct buffer_head *bitmap_bh, int goal, int *errp)
+	struct buffer_head *bitmap_bh, int goal, struct ext3_reserve_window *my_rsv)
 {
-	int i;
-	int fatal;
-	int credits = 0;
-
-	*errp = 0;
+	int group_first_block, start, end;
 
-	/*
-	 * Make sure we use undo access for the bitmap, because it is critical
-	 * that we do the frozen_data COW on bitmap buffers in all cases even
-	 * if the buffer is in BJ_Forget state in the committing transaction.
-	 */
-	BUFFER_TRACE(bitmap_bh, "get undo access for new block");
-	fatal = ext3_journal_get_undo_access(handle, bitmap_bh, &credits);
-	if (fatal) {
-		*errp = fatal;
-		goto fail;
+	/* we do allocation within the reservation window if we have a window */
+	if (my_rsv) {
+		group_first_block =
+			le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
+			group * EXT3_BLOCKS_PER_GROUP(sb);
+		if (my_rsv->_rsv_start >= group_first_block)
+			start = my_rsv->_rsv_start - group_first_block;
+		else
+			/* reservation window cross group boundary */
+			start = 0;
+		end = my_rsv->_rsv_end - group_first_block + 1;
+		if (end > EXT3_BLOCKS_PER_GROUP(sb))
+			/* reservation window crosses group boundary */
+			end = EXT3_BLOCKS_PER_GROUP(sb);
+		if ((start <= goal) && (goal < end))
+			start = goal;
+		else
+			goal = -1;
+	} else {
+		if (goal > 0)
+			start = goal;
+		else
+			start = 0;
+		end = EXT3_BLOCKS_PER_GROUP(sb);
 	}
 
+	BUG_ON(start > EXT3_BLOCKS_PER_GROUP(sb));
+
 repeat:
 	if (goal < 0 || !ext3_test_allocatable(goal, bitmap_bh)) {
-		goal = find_next_usable_block(goal, bitmap_bh,
-					EXT3_BLOCKS_PER_GROUP(sb));
+		goal = find_next_usable_block(start, bitmap_bh, end);
 		if (goal < 0)
 			goto fail_access;
+		if (!my_rsv) {
+			int i;
 
-		for (i = 0; i < 7 && goal > 0 &&
-				ext3_test_allocatable(goal - 1, bitmap_bh);
-			i++, goal--);
+			for (i = 0; i < 7 && goal > start &&
+					ext3_test_allocatable(goal - 1,
+								bitmap_bh);
+					i++, goal--)
+				;
+		}
 	}
+	start = goal;
 
 	if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group), goal, bitmap_bh)) {
 		/*
 		 * The block was allocated by another thread, or it was
 		 * allocated and then freed by another thread
 		 */
+		start++;
 		goal++;
-		if (goal >= EXT3_BLOCKS_PER_GROUP(sb))
+		if (start >= end)
 			goto fail_access;
 		goto repeat;
 	}
+	return goal;
+fail_access:
+	return -1;
+}
+
+/**
+ * 	find_next_reservable_window():
+ *		find a reservable space within the given range.
+ *		It does not allocate the reservation window for now:
+ *		alloc_new_reservation() will do the work later.
+ *
+ * 	@search_head: the head of the searching list;
+ *		This is not necessarily the list head of the whole filesystem
+ *
+ *		We have both head and start_block to assist the search
+ *		for the reservable space. The list starts from head,
+ *		but we will shift to the place where start_block is,
+ *		then start from there, when looking for a reservable space.
+ *
+ * 	@size: the target new reservation window size
+ *
+ * 	@group_first_block: the first block we consider to start
+ *			the real search from
+ *
+ * 	@last_block:
+ *		the maximum block number that our goal reservable space
+ *		could start from. This is normally the last block in this
+ *		group. The search will end when we found the start of next
+ *		possible reservable space is out of this boundary.
+ *		This could handle the cross boundary reservation window
+ *		request.
+ *
+ * 	basically we search from the given range, rather than the whole
+ * 	reservation double linked list, (start_block, last_block)
+ * 	to find a free region that is of my size and has not
+ * 	been reserved.
+ *
+ *	on succeed, it returns the reservation window to be appended to.
+ *	failed, return NULL.
+ */
+static struct ext3_reserve_window_node *find_next_reservable_window(
+				struct ext3_reserve_window_node *search_head,
+				unsigned long size, int *start_block,
+				int last_block)
+{
+	struct rb_node *next;
+	struct ext3_reserve_window_node *rsv, *prev;
+	int cur;
+
+	/* TODO: make the start of the reservation window byte-aligned */
+	/* cur = *start_block & ~7;*/
+	cur = *start_block;
+	rsv = search_head;
+	if (!rsv)
+		return NULL;
+
+	while (1) {
+		if (cur <= rsv->rsv_end)
+			cur = rsv->rsv_end + 1;
+
+		/* TODO?
+		 * in the case we could not find a reservable space
+		 * that is what is expected, during the re-search, we could
+		 * remember what's the largest reservable space we could have
+		 * and return that one.
+		 *
+		 * For now it will fail if we could not find the reservable
+		 * space with expected-size (or more)...
+		 */
+		if (cur > last_block)
+			return NULL;		/* fail */
+
+		prev = rsv;
+		next = rb_next(&rsv->rsv_node);
+		rsv = list_entry(next, struct ext3_reserve_window_node, rsv_node);
+
+		/*
+		 * Reached the last reservation, we can just append to the
+		 * previous one.
+		 */
+		if (!next)
+			break;
+
+		if (cur + size <= rsv->rsv_start) {
+			/*
+			 * Found a reserveable space big enough.  We could
+			 * have a reservation across the group boundary here
+		 	 */
+			break;
+		}
+	}
+	/*
+	 * we come here either :
+	 * when we reach the end of the whole list,
+	 * and there is empty reservable space after last entry in the list.
+	 * append it to the end of the list.
+	 *
+	 * or we found one reservable space in the middle of the list,
+	 * return the reservation window that we could append to.
+	 * succeed.
+	 */
+	*start_block = cur;
+	return prev;
+}
+
+/**
+ * 	alloc_new_reservation()--allocate a new reservation window
+ *
+ *		To make a new reservation, we search part of the filesystem
+ *		reservation list (the list that inside the group). We try to
+ *		allocate a new reservation window near the allocation goal,
+ *		or the beginning of the group, if there is no goal.
+ *
+ *		We first find a reservable space after the goal, then from
+ *		there, we check the bitmap for the first free block after
+ *		it. If there is no free block until the end of group, then the
+ *		whole group is full, we failed. Otherwise, check if the free
+ *		block is inside the expected reservable space, if so, we
+ *		succeed.
+ *		If the first free block is outside the reservable space, then
+ *		start from the first free block, we search for next available
+ *		space, and go on.
+ *
+ *	on succeed, a new reservation will be found and inserted into the list
+ *	It contains at least one free block, and it does not overlap with other
+ *	reservation windows.
+ *
+ *	failed: we failed to find a reservation window in this group
+ *
+ *	@rsv: the reservation
+ *
+ *	@goal: The goal (group-relative).  It is where the search for a
+ *		free reservable space should start from.
+ *		if we have a goal(goal >0 ), then start from there,
+ *		no goal(goal = -1), we start from the first block
+ *		of the group.
+ *
+ *	@sb: the super block
+ *	@group: the group we are trying to allocate in
+ *	@bitmap_bh: the block group block bitmap
+ */
+static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
+		int goal, struct super_block *sb,
+		unsigned int group, struct buffer_head *bitmap_bh)
+{
+	struct ext3_reserve_window_node *search_head;
+	int group_first_block, group_end_block, start_block;
+	int first_free_block;
+	int reservable_space_start;
+	struct ext3_reserve_window_node *prev_rsv;
+	struct rb_root *fs_rsv_root = &EXT3_SB(sb)->s_rsv_window_root;
+	unsigned long size;
+
+	group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
+				group * EXT3_BLOCKS_PER_GROUP(sb);
+	group_end_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1;
+
+	if (goal < 0)
+		start_block = group_first_block;
+	else
+		start_block = goal + group_first_block;
+
+	size = atomic_read(&my_rsv->rsv_goal_size);
+	if (!rsv_is_empty(&my_rsv->rsv_window)) {
+		/*
+		 * if the old reservation is cross group boundary
+		 * and if the goal is inside the old reservation window,
+		 * we will come here when we just failed to allocate from
+		 * the first part of the window. We still have another part
+		 * that belongs to the next group. In this case, there is no
+		 * point to discard our window and try to allocate a new one
+		 * in this group(which will fail). we should
+		 * keep the reservation window, just simply move on.
+		 *
+		 * Maybe we could shift the start block of the reservation
+		 * window to the first block of next group.
+		 */
+
+		if ((my_rsv->rsv_start <= group_end_block) &&
+				(my_rsv->rsv_end > group_end_block) &&
+				(start_block >= my_rsv->rsv_start))
+			return -1;
+
+		if ((atomic_read(&my_rsv->rsv_alloc_hit) >
+		     (my_rsv->rsv_end - my_rsv->rsv_start + 1) / 2)) {
+			/*
+			 * if we previously allocation hit ration is greater than half
+			 * we double the size of reservation window next time
+			 * otherwise keep the same
+			 */
+			size = size * 2;
+			if (size > EXT3_MAX_RESERVE_BLOCKS)
+				size = EXT3_MAX_RESERVE_BLOCKS;
+			atomic_set(&my_rsv->rsv_goal_size, size);
+		}
+	}
+	/*
+	 * shift the search start to the window near the goal block
+	 */
+	search_head = search_reserve_window(fs_rsv_root, start_block);
+
+	/*
+	 * find_next_reservable_window() simply finds a reservable window
+	 * inside the given range(start_block, group_end_block).
+	 *
+	 * To make sure the reservation window has a free bit inside it, we
+	 * need to check the bitmap after we found a reservable window.
+	 */
+retry:
+	prev_rsv = find_next_reservable_window(search_head, size,
+						&start_block, group_end_block);
+	if (prev_rsv == NULL)
+		goto failed;
+	reservable_space_start = start_block;
+	/*
+	 * On success, find_next_reservable_window() returns the
+	 * reservation window where there is a reservable space after it.
+	 * Before we reserve this reservable space, we need
+	 * to make sure there is at least a free block inside this region.
+	 *
+	 * searching the first free bit on the block bitmap and copy of
+	 * last committed bitmap alternatively, until we found a allocatable
+	 * block. Search start from the start block of the reservable space
+	 * we just found.
+	 */
+	first_free_block = bitmap_search_next_usable_block(
+			reservable_space_start - group_first_block,
+			bitmap_bh, group_end_block - group_first_block + 1);
+
+	if (first_free_block < 0) {
+		/*
+		 * no free block left on the bitmap, no point
+		 * to reserve the space. return failed.
+		 */
+		goto failed;
+	}
+	start_block = first_free_block + group_first_block;
+	/*
+	 * check if the first free block is within the
+	 * free space we just found
+	 */
+	if ((start_block >= reservable_space_start) &&
+	  (start_block < reservable_space_start + size))
+		goto found_rsv_window;
+	/*
+	 * if the first free bit we found is out of the reservable space
+	 * this means there is no free block on the reservable space
+	 * we should continue search for next reservable space,
+	 * start from where the free block is,
+	 * we also shift the list head to where we stopped last time
+	 */
+	search_head = prev_rsv;
+	goto retry;
+
+found_rsv_window:
+	/*
+	 * great! the reservable space contains some free blocks.
+	 * if the search returns that we should add the new
+	 * window just next to where the old window, we don't
+ 	 * need to remove the old window first then add it to the
+	 * same place, just update the new start and new end.
+	 */
+	if (my_rsv != prev_rsv)  {
+		if (!rsv_is_empty(&my_rsv->rsv_window))
+			rsv_window_remove(sb, my_rsv);
+	}
+	my_rsv->rsv_start = reservable_space_start;
+	my_rsv->rsv_end = my_rsv->rsv_start + size - 1;
+	atomic_set(&my_rsv->rsv_alloc_hit, 0);
+	if (my_rsv != prev_rsv)  {
+		ext3_rsv_window_add(sb, my_rsv);
+	}
+	return 0;		/* succeed */
+failed:
+	/*
+	 * failed to find a new reservation window in the current
+	 * group, remove the current(stale) reservation window
+	 * if there is any
+	 */
+	if (!rsv_is_empty(&my_rsv->rsv_window))
+		rsv_window_remove(sb, my_rsv);
+	return -1;		/* failed */
+}
 
-	BUFFER_TRACE(bitmap_bh, "journal_dirty_metadata for bitmap block");
-	fatal = ext3_journal_dirty_metadata(handle, bitmap_bh);
+/*
+ * This is the main function used to allocate a new block and its reservation
+ * window.
+ *
+ * Each time when a new block allocation is need, first try to allocate from
+ * its own reservation.  If it does not have a reservation window, instead of
+ * looking for a free bit on bitmap first, then look up the reservation list to
+ * see if it is inside somebody else's reservation window, we try to allocate a
+ * reservation window for it starting from the goal first. Then do the block
+ * allocation within the reservation window.
+ *
+ * This will avoid keeping on searching the reservation list again and
+ * again when someboday is looking for a free block (without
+ * reservation), and there are lots of free blocks, but they are all
+ * being reserved.
+ *
+ * We use a sorted double linked list for the per-filesystem reservation list.
+ * The insert, remove and find a free space(non-reserved) operations for the
+ * sorted double linked list should be fast.
+ *
+ */
+static int
+ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
+			unsigned int group, struct buffer_head *bitmap_bh,
+			int goal, struct ext3_reserve_window_node * my_rsv,
+			int *errp)
+{
+	spinlock_t *rsv_lock;
+	unsigned long group_first_block;
+	int ret = 0;
+	int fatal;
+	int credits = 0;
+
+	*errp = 0;
+
+	/*
+	 * Make sure we use undo access for the bitmap, because it is critical
+	 * that we do the frozen_data COW on bitmap buffers in all cases even
+	 * if the buffer is in BJ_Forget state in the committing transaction.
+	 */
+	BUFFER_TRACE(bitmap_bh, "get undo access for new block");
+	fatal = ext3_journal_get_undo_access(handle, bitmap_bh, &credits);
 	if (fatal) {
 		*errp = fatal;
-		goto fail;
+		return -1;
+	}
+
+	/*
+	 * we don't deal with reservation when
+	 * filesystem is mounted without reservation
+	 * or the file is not a regular file
+	 * or last attempt to allocate a block with reservation turned on failed
+	 */
+	if (my_rsv == NULL ) {
+		ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, goal, NULL);
+		goto out;
+	}
+	rsv_lock = &EXT3_SB(sb)->s_rsv_window_lock;
+	/*
+	 * goal is a group relative block number (if there is a goal)
+	 * 0 < goal < EXT3_BLOCKS_PER_GROUP(sb)
+	 * first block is a filesystem wide block number
+	 * first block is the block number of the first block in this group
+	 */
+	group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
+			group * EXT3_BLOCKS_PER_GROUP(sb);
+
+	/*
+	 * Basically we will allocate a new block from inode's reservation
+	 * window.
+	 *
+	 * We need to allocate a new reservation window, if:
+	 * a) inode does not have a reservation window; or
+	 * b) last attempt to allocate a block from existing reservation
+	 *    failed; or
+	 * c) we come here with a goal and with a reservation window
+	 *
+	 * We do not need to allocate a new reservation window if we come here
+	 * at the beginning with a goal and the goal is inside the window, or
+	 * we don't have a goal but already have a reservation window.
+	 * then we could go to allocate from the reservation window directly.
+	 */
+	while (1) {
+		struct ext3_reserve_window rsv_copy;
+		unsigned int seq;
+
+		do {
+			seq = read_seqbegin(&my_rsv->rsv_seqlock);
+			rsv_copy._rsv_start = my_rsv->rsv_start;
+			rsv_copy._rsv_end = my_rsv->rsv_end;
+		} while (read_seqretry(&my_rsv->rsv_seqlock, seq));
+
+		if (rsv_is_empty(&rsv_copy) || (ret < 0) ||
+			!goal_in_my_reservation(&rsv_copy, goal, group, sb)) {
+			spin_lock(rsv_lock);
+			write_seqlock(&my_rsv->rsv_seqlock);
+			ret = alloc_new_reservation(my_rsv, goal, sb,
+							group, bitmap_bh);
+			rsv_copy._rsv_start = my_rsv->rsv_start;
+			rsv_copy._rsv_end = my_rsv->rsv_end;
+			write_sequnlock(&my_rsv->rsv_seqlock);
+			spin_unlock(rsv_lock);
+			if (ret < 0)
+				break;			/* failed */
+
+			if (!goal_in_my_reservation(&rsv_copy, goal, group, sb))
+				goal = -1;
+		}
+		if ((rsv_copy._rsv_start >= group_first_block + EXT3_BLOCKS_PER_GROUP(sb))
+		    || (rsv_copy._rsv_end < group_first_block))
+			BUG();
+		ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, goal,
+					   &rsv_copy);
+		if (ret >= 0) {
+			if (!read_seqretry(&my_rsv->rsv_seqlock, seq))
+				atomic_inc(&my_rsv->rsv_alloc_hit);
+			break;				/* succeed */
+		}
+	}
+out:
+	if (ret >= 0) {
+		BUFFER_TRACE(bitmap_bh, "journal_dirty_metadata for "
+					"bitmap block");
+		fatal = ext3_journal_dirty_metadata(handle, bitmap_bh);
+		if (fatal) {
+			*errp = fatal;
+			return -1;
+		}
+		return ret;
 	}
-	return goal;
 
-fail_access:
 	BUFFER_TRACE(bitmap_bh, "journal_release_buffer");
 	ext3_journal_release_buffer(handle, bitmap_bh, credits);
-fail:
-	return -1;
+	return ret;
 }
 
 static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
@@ -503,16 +1129,16 @@
  * bitmap, and then for any free bit if that fails.
  * This function also updates quota and i_blocks field.
  */
-int
-ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal,
-		u32 *prealloc_count, u32 *prealloc_block, int *errp)
-{
-	struct buffer_head *bitmap_bh = NULL;	/* bh */
-	struct buffer_head *gdp_bh;		/* bh2 */
-	int group_no;				/* i */
-	int ret_block;				/* j */
-	int bgi;				/* blockgroup iteration index */
-	int target_block;			/* tmp */
+int ext3_new_block(handle_t *handle, struct inode *inode,
+			unsigned long goal, int *errp)
+{
+	struct buffer_head *bitmap_bh = NULL;
+	struct buffer_head *gdp_bh;
+	int group_no;
+	int goal_group;
+	int ret_block;
+	int bgi;			/* blockgroup iteration index */
+	int target_block;
 	int fatal = 0, err;
 	int performed_allocation = 0;
 	int free_blocks;
@@ -520,9 +1146,14 @@
 	struct ext3_group_desc *gdp;
 	struct ext3_super_block *es;
 	struct ext3_sb_info *sbi;
+	struct ext3_reserve_window_node *my_rsv = NULL;
+	struct ext3_reserve_window_node *rsv = &EXT3_I(inode)->i_rsv_window;
+	unsigned short windowsz = 0;
 #ifdef EXT3FS_DEBUG
 	static int goal_hits, goal_attempts;
 #endif
+	unsigned long ngroups;
+
 	*errp = -ENOSPC;
 	sb = inode->i_sb;
 	if (!sb) {
@@ -541,7 +1172,18 @@
 	sbi = EXT3_SB(sb);
 	es = EXT3_SB(sb)->s_es;
 	ext3_debug("goal=%lu.\n", goal);
-
+	/*
+	 * Allocate a block from reservation only when
+	 * filesystem is mounted with reservation(default,-o reservation), and
+	 * it's a regular file, and
+	 * the desired window size is greater than 0 (One could use ioctl
+	 * command EXT3_IOC_SETRSVSZ to set the window size to 0 to turn off
+	 * reservation on that particular file)
+	 */
+	windowsz = atomic_read(&rsv->rsv_goal_size);
+	if (test_opt(sb, RESERVATION) &&
+		S_ISREG(inode->i_mode) && (windowsz > 0))
+		my_rsv = rsv;
 	if (!ext3_has_free_blocks(sbi)) {
 		*errp = -ENOSPC;
 		goto out;
@@ -559,6 +1201,8 @@
 	if (!gdp)
 		goto io_error;
 
+	goal_group = group_no;
+retry:
 	free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
 	if (free_blocks > 0) {
 		ret_block = ((goal - le32_to_cpu(es->s_first_data_block)) %
@@ -566,21 +1210,24 @@
 		bitmap_bh = read_block_bitmap(sb, group_no);
 		if (!bitmap_bh)
 			goto io_error;
-		ret_block = ext3_try_to_allocate(sb, handle, group_no,
-					bitmap_bh, ret_block, &fatal);
+		ret_block = ext3_try_to_allocate_with_rsv(sb, handle, group_no,
+					bitmap_bh, ret_block, my_rsv, &fatal);
 		if (fatal)
 			goto out;
 		if (ret_block >= 0)
 			goto allocated;
 	}
 
+	ngroups = EXT3_SB(sb)->s_groups_count;
+	smp_rmb();
+
 	/*
 	 * Now search the rest of the groups.  We assume that 
 	 * i and gdp correctly point to the last group visited.
 	 */
-	for (bgi = 0; bgi < EXT3_SB(sb)->s_groups_count; bgi++) {
+	for (bgi = 0; bgi < ngroups; bgi++) {
 		group_no++;
-		if (group_no >= EXT3_SB(sb)->s_groups_count)
+		if (group_no >= ngroups)
 			group_no = 0;
 		gdp = ext3_get_group_desc(sb, group_no, &gdp_bh);
 		if (!gdp) {
@@ -588,21 +1235,37 @@
 			goto out;
 		}
 		free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
-		if (free_blocks <= 0)
+		/*
+		 * skip this group if the number of
+		 * free blocks is less than half of the reservation
+		 * window size.
+		 */
+		if (free_blocks <= (windowsz/2))
 			continue;
 
 		brelse(bitmap_bh);
 		bitmap_bh = read_block_bitmap(sb, group_no);
 		if (!bitmap_bh)
 			goto io_error;
-		ret_block = ext3_try_to_allocate(sb, handle, group_no,
-						bitmap_bh, -1, &fatal);
+		ret_block = ext3_try_to_allocate_with_rsv(sb, handle, group_no,
+					bitmap_bh, -1, my_rsv, &fatal);
 		if (fatal)
 			goto out;
 		if (ret_block >= 0) 
 			goto allocated;
 	}
-
+	/*
+	 * We may end up a bogus ealier ENOSPC error due to
+	 * filesystem is "full" of reservations, but
+	 * there maybe indeed free blocks avaliable on disk
+	 * In this case, we just forget about the reservations
+	 * just do block allocation as without reservations.
+	 */
+	if (my_rsv) {
+		my_rsv = NULL;
+		group_no = goal_group;
+		goto retry;
+	}
 	/* No space left on the device */
 	*errp = -ENOSPC;
 	goto out;
@@ -715,6 +1378,7 @@
 	unsigned long desc_count;
 	struct ext3_group_desc *gdp;
 	int i;
+	unsigned long ngroups;
 #ifdef EXT3FS_DEBUG
 	struct ext3_super_block *es;
 	unsigned long bitmap_count, x;
@@ -747,7 +1411,9 @@
 	return bitmap_count;
 #else
 	desc_count = 0;
-	for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
+	ngroups = EXT3_SB(sb)->s_groups_count;
+	smp_rmb();
+	for (i = 0; i < ngroups; i++) {
 		gdp = ext3_get_group_desc(sb, i, NULL);
 		if (!gdp)
 			continue;
diff -Nru a/fs/ext3/file.c b/fs/ext3/file.c
--- a/fs/ext3/file.c	2004-12-24 13:37:29 -08:00
+++ b/fs/ext3/file.c	2004-12-24 13:37:29 -08:00
@@ -33,8 +33,10 @@
  */
 static int ext3_release_file (struct inode * inode, struct file * filp)
 {
-	if (filp->f_mode & FMODE_WRITE)
-		ext3_discard_prealloc (inode);
+	/* if we are the last writer on the inode, drop the block reservation */
+	if ((filp->f_mode & FMODE_WRITE) &&
+			(atomic_read(&inode->i_writecount) == 1))
+		ext3_discard_reservation(inode);
 	if (is_dx(inode) && filp->private_data)
 		ext3_htree_free_dir_info(filp->private_data);
 
@@ -132,10 +134,12 @@
 struct inode_operations ext3_file_inode_operations = {
 	.truncate	= ext3_truncate,
 	.setattr	= ext3_setattr,
-	.setxattr	= ext3_setxattr,
-	.getxattr	= ext3_getxattr,
+#ifdef CONFIG_EXT3_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext3_listxattr,
-	.removexattr	= ext3_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 	.permission	= ext3_permission,
 };
 
diff -Nru a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
--- a/fs/ext3/ialloc.c	2004-12-24 13:36:49 -08:00
+++ b/fs/ext3/ialloc.c	2004-12-24 13:36:49 -08:00
@@ -22,8 +22,8 @@
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
 #include <linux/random.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
 
 #include "xattr.h"
@@ -320,8 +320,6 @@
 		desc = ext3_get_group_desc (sb, group, &bh);
 		if (!desc || !desc->bg_free_inodes_count)
 			continue;
-		if (sbi->s_debts[group] >= max_debt)
-			continue;
 		if (le16_to_cpu(desc->bg_used_dirs_count) >= max_dirs)
 			continue;
 		if (le16_to_cpu(desc->bg_free_inodes_count) < min_inodes)
@@ -582,10 +580,11 @@
 	ei->i_file_acl = 0;
 	ei->i_dir_acl = 0;
 	ei->i_dtime = 0;
-#ifdef EXT3_PREALLOCATE
-	ei->i_prealloc_block = 0;
-	ei->i_prealloc_count = 0;
-#endif
+	ei->i_rsv_window.rsv_start = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
+	ei->i_rsv_window.rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
+	atomic_set(&ei->i_rsv_window.rsv_goal_size, EXT3_DEFAULT_RESERVE_BLOCKS);
+	atomic_set(&ei->i_rsv_window.rsv_alloc_hit, 0);
+	seqlock_init(&ei->i_rsv_window.rsv_seqlock);
 	ei->i_block_group = group;
 
 	ext3_set_inode_flags(inode);
diff -Nru a/fs/ext3/inode.c b/fs/ext3/inode.c
--- a/fs/ext3/inode.c	2004-12-24 13:37:01 -08:00
+++ b/fs/ext3/inode.c	2004-12-24 13:37:01 -08:00
@@ -179,19 +179,6 @@
 }
 
 /*
- * Called at each iput()
- *
- * The inode may be "bad" if ext3_read_inode() saw an error from
- * ext3_get_inode(), so we need to check that to avoid freeing random disk
- * blocks.
- */
-void ext3_put_inode(struct inode *inode)
-{
-	if (!is_bad_inode(inode))
-		ext3_discard_prealloc(inode);
-}
-
-/*
  * Called at the last iput() if i_nlink is zero.
  */
 void ext3_delete_inode (struct inode * inode)
@@ -244,62 +231,12 @@
 	clear_inode(inode);	/* We must guarantee clearing of inode... */
 }
 
-void ext3_discard_prealloc (struct inode * inode)
-{
-#ifdef EXT3_PREALLOCATE
-	struct ext3_inode_info *ei = EXT3_I(inode);
-	/* Writer: ->i_prealloc* */
-	if (ei->i_prealloc_count) {
-		unsigned short total = ei->i_prealloc_count;
-		unsigned long block = ei->i_prealloc_block;
-		ei->i_prealloc_count = 0;
-		ei->i_prealloc_block = 0;
-		/* Writer: end */
-		ext3_free_blocks (inode, block, total);
-	}
-#endif
-}
-
 static int ext3_alloc_block (handle_t *handle,
 			struct inode * inode, unsigned long goal, int *err)
 {
 	unsigned long result;
 
-#ifdef EXT3_PREALLOCATE
-#ifdef EXT3FS_DEBUG
-	static unsigned long alloc_hits, alloc_attempts;
-#endif
-	struct ext3_inode_info *ei = EXT3_I(inode);
-	/* Writer: ->i_prealloc* */
-	if (ei->i_prealloc_count &&
-	    (goal == ei->i_prealloc_block ||
-	     goal + 1 == ei->i_prealloc_block))
-	{
-		result = ei->i_prealloc_block++;
-		ei->i_prealloc_count--;
-		/* Writer: end */
-		ext3_debug ("preallocation hit (%lu/%lu).\n",
-			    ++alloc_hits, ++alloc_attempts);
-	} else {
-		ext3_discard_prealloc (inode);
-		ext3_debug ("preallocation miss (%lu/%lu).\n",
-			    alloc_hits, ++alloc_attempts);
-		if (S_ISREG(inode->i_mode))
-			result = ext3_new_block (inode, goal, 
-				 &ei->i_prealloc_count,
-				 &ei->i_prealloc_block, err);
-		else
-			result = ext3_new_block(inode, goal, NULL, NULL, err);
-		/*
-		 * AKPM: this is somewhat sticky.  I'm not surprised it was
-		 * disabled in 2.2's ext3.  Need to integrate b_committed_data
-		 * guarding with preallocation, if indeed preallocation is
-		 * effective.
-		 */
-	}
-#else
-	result = ext3_new_block(handle, inode, goal, NULL, NULL, err);
-#endif
+	result = ext3_new_block(handle, inode, goal, err);
 	return result;
 }
 
@@ -976,52 +913,17 @@
 			       int block, int create, int *err)
 {
 	struct buffer_head * bh;
-	int prev_blocks;
 
-	prev_blocks = inode->i_blocks;
-
-	bh = ext3_getblk (handle, inode, block, create, err);
+	bh = ext3_getblk(handle, inode, block, create, err);
 	if (!bh)
 		return bh;
-#ifdef EXT3_PREALLOCATE
-	/*
-	 * If the inode has grown, and this is a directory, then use a few
-	 * more of the preallocated blocks to keep directory fragmentation
-	 * down.  The preallocated blocks are guaranteed to be contiguous.
-	 */
-	if (create &&
-	    S_ISDIR(inode->i_mode) &&
-	    inode->i_blocks > prev_blocks &&
-	    EXT3_HAS_COMPAT_FEATURE(inode->i_sb,
-				    EXT3_FEATURE_COMPAT_DIR_PREALLOC)) {
-		int i;
-		struct buffer_head *tmp_bh;
-
-		for (i = 1;
-		     EXT3_I(inode)->i_prealloc_count &&
-		     i < EXT3_SB(inode->i_sb)->s_es->s_prealloc_dir_blocks;
-		     i++) {
-			/*
-			 * ext3_getblk will zero out the contents of the
-			 * directory for us
-			 */
-			tmp_bh = ext3_getblk(handle, inode,
-						block+i, create, err);
-			if (!tmp_bh) {
-				brelse (bh);
-				return 0;
-			}
-			brelse (tmp_bh);
-		}
-	}
-#endif
 	if (buffer_uptodate(bh))
 		return bh;
-	ll_rw_block (READ, 1, &bh);
-	wait_on_buffer (bh);
+	ll_rw_block(READ, 1, &bh);
+	wait_on_buffer(bh);
 	if (buffer_uptodate(bh))
 		return bh;
-	brelse (bh);
+	put_bh(bh);
 	*err = -EIO;
 	return NULL;
 }
@@ -1589,16 +1491,21 @@
 	if (handle) {
 		int err;
 
-		if (orphan) 
+		if (orphan && inode->i_nlink)
 			ext3_orphan_del(handle, inode);
 		if (orphan && ret > 0) {
 			loff_t end = offset + ret;
 			if (end > inode->i_size) {
 				ei->i_disksize = end;
 				i_size_write(inode, end);
-				err = ext3_mark_inode_dirty(handle, inode);
-				if (!ret) 
-					ret = err;
+				/*
+				 * We're going to return a positive `ret'
+				 * here due to non-zero-length I/O, so there's
+				 * no way of reporting error returns from
+				 * ext3_mark_inode_dirty() to userspace.  So
+				 * ignore it.
+				 */
+				ext3_mark_inode_dirty(handle, inode);
 			}
 		}
 		err = ext3_journal_stop(handle);
@@ -2165,7 +2072,7 @@
 	if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
 		return;
 
-	ext3_discard_prealloc(inode);
+	ext3_discard_reservation(inode);
 
 	/*
 	 * We have to lock the EOF page here, because lock_page() nests
@@ -2321,8 +2228,10 @@
 	struct buffer_head *bh;
 	struct ext3_group_desc * gdp;
 
+
 	if ((ino != EXT3_ROOT_INO &&
 		ino != EXT3_JOURNAL_INO &&
+		ino != EXT3_RESIZE_INO &&
 		ino < EXT3_FIRST_INO(sb)) ||
 		ino > le32_to_cpu(
 			EXT3_SB(sb)->s_es->s_inodes_count)) {
@@ -2336,6 +2245,7 @@
 			    "group >= groups count");
 		return 0;
 	}
+	smp_rmb();
 	group_desc = block_group >> EXT3_DESC_PER_BLOCK_BITS(sb);
 	desc = block_group & (EXT3_DESC_PER_BLOCK(sb) - 1);
 	bh = EXT3_SB(sb)->s_group_desc[group_desc];
@@ -2499,6 +2409,8 @@
 	ei->i_acl = EXT3_ACL_NOT_CACHED;
 	ei->i_default_acl = EXT3_ACL_NOT_CACHED;
 #endif
+	ei->i_rsv_window.rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
+
 	if (ext3_get_inode_loc(inode, &iloc, 0))
 		goto bad_inode;
 	bh = iloc.bh;
@@ -2558,11 +2470,11 @@
 	}
 	ei->i_disksize = inode->i_size;
 	inode->i_generation = le32_to_cpu(raw_inode->i_generation);
-#ifdef EXT3_PREALLOCATE
-	ei->i_prealloc_count = 0;
-#endif
 	ei->i_block_group = iloc.block_group;
-
+	ei->i_rsv_window.rsv_start = 0;
+	ei->i_rsv_window.rsv_end= 0;
+	atomic_set(&ei->i_rsv_window.rsv_goal_size, EXT3_DEFAULT_RESERVE_BLOCKS);
+	seqlock_init(&ei->i_rsv_window.rsv_seqlock);
 	/*
 	 * NOTE! The in-memory inode i_data array is in little-endian order
 	 * even on big-endian machines: we do NOT byteswap the block numbers!
diff -Nru a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
--- a/fs/ext3/ioctl.c	2004-12-24 13:36:47 -08:00
+++ b/fs/ext3/ioctl.c	2004-12-24 13:36:47 -08:00
@@ -20,6 +20,7 @@
 {
 	struct ext3_inode_info *ei = EXT3_I(inode);
 	unsigned int flags;
+	unsigned short rsv_window_size;
 
 	ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
 
@@ -151,6 +152,74 @@
 			return ret;
 		}
 #endif
+	case EXT3_IOC_GETRSVSZ:
+		if (test_opt(inode->i_sb, RESERVATION) && S_ISREG(inode->i_mode)) {
+			rsv_window_size = atomic_read(&ei->i_rsv_window.rsv_goal_size);
+			return put_user(rsv_window_size, (int __user *)arg);
+		}
+		return -ENOTTY;
+	case EXT3_IOC_SETRSVSZ:
+		if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
+			return -ENOTTY;
+
+		if (IS_RDONLY(inode))
+			return -EROFS;
+
+		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
+			return -EACCES;
+
+		if (get_user(rsv_window_size, (int __user *)arg))
+			return -EFAULT;
+
+		if (rsv_window_size > EXT3_MAX_RESERVE_BLOCKS)
+			rsv_window_size = EXT3_MAX_RESERVE_BLOCKS;
+		atomic_set(&ei->i_rsv_window.rsv_goal_size, rsv_window_size);
+		return 0;
+	case EXT3_IOC_GROUP_EXTEND: {
+		unsigned long n_blocks_count;
+		struct super_block *sb = inode->i_sb;
+		int err;
+
+		if (!capable(CAP_SYS_RESOURCE))
+			return -EPERM;
+
+		if (IS_RDONLY(inode))
+			return -EROFS;
+
+		if (get_user(n_blocks_count, (__u32 __user *)arg))
+			return -EFAULT;
+
+		err = ext3_group_extend(sb, EXT3_SB(sb)->s_es, n_blocks_count);
+		journal_lock_updates(EXT3_SB(sb)->s_journal);
+		journal_flush(EXT3_SB(sb)->s_journal);
+		journal_unlock_updates(EXT3_SB(sb)->s_journal);
+
+		return err;
+	}
+	case EXT3_IOC_GROUP_ADD: {
+		struct ext3_new_group_data input;
+		struct super_block *sb = inode->i_sb;
+		int err;
+
+		if (!capable(CAP_SYS_RESOURCE))
+			return -EPERM;
+
+		if (IS_RDONLY(inode))
+			return -EROFS;
+
+		if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
+				sizeof(input)))
+			return -EFAULT;
+
+		err = ext3_group_add(sb, &input);
+		journal_lock_updates(EXT3_SB(sb)->s_journal);
+		journal_flush(EXT3_SB(sb)->s_journal);
+		journal_unlock_updates(EXT3_SB(sb)->s_journal);
+
+		return err;
+	}
+
+
 	default:
 		return -ENOTTY;
 	}
diff -Nru a/fs/ext3/namei.c b/fs/ext3/namei.c
--- a/fs/ext3/namei.c	2004-12-24 13:36:59 -08:00
+++ b/fs/ext3/namei.c	2004-12-24 13:36:59 -08:00
@@ -872,7 +872,7 @@
 		if (!buffer_uptodate(bh)) {
 			/* read error, skip block & hope for the best */
 			ext3_error(sb, __FUNCTION__, "reading directory #%lu "
-				   "offset %lu\n", dir->i_ino, block);
+				   "offset %lu", dir->i_ino, block);
 			brelse(bh);
 			goto next;
 		}
@@ -2352,18 +2352,22 @@
 	.mknod		= ext3_mknod,
 	.rename		= ext3_rename,
 	.setattr	= ext3_setattr,
-	.setxattr	= ext3_setxattr,
-	.getxattr	= ext3_getxattr,
+#ifdef CONFIG_EXT3_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext3_listxattr,
-	.removexattr	= ext3_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 	.permission	= ext3_permission,
 };
 
 struct inode_operations ext3_special_inode_operations = {
 	.setattr	= ext3_setattr,
-	.setxattr	= ext3_setxattr,
-	.getxattr	= ext3_getxattr,
+#ifdef CONFIG_EXT3_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext3_listxattr,
-	.removexattr	= ext3_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 	.permission	= ext3_permission,
 }; 
diff -Nru a/fs/ext3/resize.c b/fs/ext3/resize.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/fs/ext3/resize.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,996 @@
+/*
+ *  linux/fs/ext3/resize.c
+ *
+ * Support for resizing an ext3 filesystem while it is mounted.
+ *
+ * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com>
+ *
+ * This could probably be made into a module, because it is not often in use.
+ */
+
+#include <linux/config.h>
+
+#define EXT3FS_DEBUG
+
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
+#include <linux/ext3_jbd.h>
+
+#include <linux/errno.h>
+#include <linux/slab.h>
+
+
+#define outside(b, first, last)	((b) < (first) || (b) >= (last))
+#define inside(b, first, last)	((b) >= (first) && (b) < (last))
+
+static int verify_group_input(struct super_block *sb,
+			      struct ext3_new_group_data *input)
+{
+	struct ext3_sb_info *sbi = EXT3_SB(sb);
+	struct ext3_super_block *es = sbi->s_es;
+	unsigned start = le32_to_cpu(es->s_blocks_count);
+	unsigned end = start + input->blocks_count;
+	unsigned group = input->group;
+	unsigned itend = input->inode_table + EXT3_SB(sb)->s_itb_per_group;
+	unsigned overhead = ext3_bg_has_super(sb, group) ?
+		(1 + ext3_bg_num_gdb(sb, group) +
+		 le16_to_cpu(es->s_reserved_gdt_blocks)) : 0;
+	unsigned metaend = start + overhead;
+	struct buffer_head *bh = NULL;
+	int free_blocks_count;
+	int err = -EINVAL;
+
+	input->free_blocks_count = free_blocks_count =
+		input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
+
+	if (test_opt(sb, DEBUG))
+		printk(KERN_DEBUG "EXT3-fs: adding %s group %u: %u blocks "
+		       "(%d free, %u reserved)\n",
+		       ext3_bg_has_super(sb, input->group) ? "normal" :
+		       "no-super", input->group, input->blocks_count,
+		       free_blocks_count, input->reserved_blocks);
+
+	if (group != sbi->s_groups_count)
+		ext3_warning(sb, __FUNCTION__,
+			     "Cannot add at group %u (only %lu groups)",
+			     input->group, sbi->s_groups_count);
+	else if ((start - le32_to_cpu(es->s_first_data_block)) %
+		 EXT3_BLOCKS_PER_GROUP(sb))
+		ext3_warning(sb, __FUNCTION__, "Last group not full");
+	else if (input->reserved_blocks > input->blocks_count / 5)
+		ext3_warning(sb, __FUNCTION__, "Reserved blocks too high (%u)",
+			     input->reserved_blocks);
+	else if (free_blocks_count < 0)
+		ext3_warning(sb, __FUNCTION__, "Bad blocks count %u",
+			     input->blocks_count);
+	else if (!(bh = sb_bread(sb, end - 1)))
+		ext3_warning(sb, __FUNCTION__, "Cannot read last block (%u)",
+			     end - 1);
+	else if (outside(input->block_bitmap, start, end))
+		ext3_warning(sb, __FUNCTION__,
+			     "Block bitmap not in group (block %u)",
+			     input->block_bitmap);
+	else if (outside(input->inode_bitmap, start, end))
+		ext3_warning(sb, __FUNCTION__,
+			     "Inode bitmap not in group (block %u)",
+			     input->inode_bitmap);
+	else if (outside(input->inode_table, start, end) ||
+	         outside(itend - 1, start, end))
+		ext3_warning(sb, __FUNCTION__,
+			     "Inode table not in group (blocks %u-%u)",
+			     input->inode_table, itend - 1);
+	else if (input->inode_bitmap == input->block_bitmap)
+		ext3_warning(sb, __FUNCTION__,
+			     "Block bitmap same as inode bitmap (%u)",
+			     input->block_bitmap);
+	else if (inside(input->block_bitmap, input->inode_table, itend))
+		ext3_warning(sb, __FUNCTION__,
+			     "Block bitmap (%u) in inode table (%u-%u)",
+			     input->block_bitmap, input->inode_table, itend-1);
+	else if (inside(input->inode_bitmap, input->inode_table, itend))
+		ext3_warning(sb, __FUNCTION__,
+			     "Inode bitmap (%u) in inode table (%u-%u)",
+			     input->inode_bitmap, input->inode_table, itend-1);
+	else if (inside(input->block_bitmap, start, metaend))
+		ext3_warning(sb, __FUNCTION__,
+			     "Block bitmap (%u) in GDT table (%u-%u)",
+			     input->block_bitmap, start, metaend - 1);
+	else if (inside(input->inode_bitmap, start, metaend))
+		ext3_warning(sb, __FUNCTION__,
+			     "Inode bitmap (%u) in GDT table (%u-%u)",
+			     input->inode_bitmap, start, metaend - 1);
+	else if (inside(input->inode_table, start, metaend) ||
+	         inside(itend - 1, start, metaend))
+		ext3_warning(sb, __FUNCTION__,
+			     "Inode table (%u-%u) overlaps GDT table (%u-%u)",
+			     input->inode_table, itend - 1, start, metaend - 1);
+	else
+		err = 0;
+	brelse(bh);
+
+	return err;
+}
+
+static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
+				  unsigned long blk)
+{
+	struct buffer_head *bh;
+	int err;
+
+	bh = sb_getblk(sb, blk);
+	if ((err = ext3_journal_get_write_access(handle, bh))) {
+		brelse(bh);
+		bh = ERR_PTR(err);
+	} else {
+		lock_buffer(bh);
+		memset(bh->b_data, 0, sb->s_blocksize);
+		set_buffer_uptodate(bh);
+		unlock_buffer(bh);
+	}
+
+	return bh;
+}
+
+/*
+ * To avoid calling the atomic setbit hundreds or thousands of times, we only
+ * need to use it within a single byte (to ensure we get endianness right).
+ * We can use memset for the rest of the bitmap as there are no other users.
+ */
+static void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
+{
+	int i;
+
+	if (start_bit >= end_bit)
+		return;
+
+	ext3_debug("mark end bits +%d through +%d used\n", start_bit, end_bit);
+	for (i = start_bit; i < ((start_bit + 7) & ~7UL); i++)
+		ext3_set_bit(i, bitmap);
+	if (i < end_bit)
+		memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
+}
+
+/*
+ * Set up the block and inode bitmaps, and the inode table for the new group.
+ * This doesn't need to be part of the main transaction, since we are only
+ * changing blocks outside the actual filesystem.  We still do journaling to
+ * ensure the recovery is correct in case of a failure just after resize.
+ * If any part of this fails, we simply abort the resize.
+ */
+static int setup_new_group_blocks(struct super_block *sb,
+				  struct ext3_new_group_data *input)
+{
+	struct ext3_sb_info *sbi = EXT3_SB(sb);
+	unsigned long start = input->group * sbi->s_blocks_per_group +
+		le32_to_cpu(sbi->s_es->s_first_data_block);
+	int reserved_gdb = ext3_bg_has_super(sb, input->group) ?
+		le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0;
+	unsigned long gdblocks = ext3_bg_num_gdb(sb, input->group);
+	struct buffer_head *bh;
+	handle_t *handle;
+	unsigned long block;
+	int bit;
+	int i;
+	int err = 0, err2;
+
+	handle = ext3_journal_start_sb(sb, reserved_gdb + gdblocks +
+				       2 + sbi->s_itb_per_group);
+	if (IS_ERR(handle))
+		return PTR_ERR(handle);
+
+	lock_super(sb);
+	if (input->group != sbi->s_groups_count) {
+		err = -EBUSY;
+		goto exit_journal;
+	}
+
+	if (IS_ERR(bh = bclean(handle, sb, input->block_bitmap))) {
+		err = PTR_ERR(bh);
+		goto exit_journal;
+	}
+
+	if (ext3_bg_has_super(sb, input->group)) {
+		ext3_debug("mark backup superblock %#04lx (+0)\n", start);
+		ext3_set_bit(0, bh->b_data);
+	}
+
+	/* Copy all of the GDT blocks into the backup in this group */
+	for (i = 0, bit = 1, block = start + 1;
+	     i < gdblocks; i++, block++, bit++) {
+		struct buffer_head *gdb;
+
+		ext3_debug("update backup group %#04lx (+%d)\n", block, bit);
+
+		gdb = sb_getblk(sb, block);
+		if ((err = ext3_journal_get_write_access(handle, gdb))) {
+			brelse(gdb);
+			goto exit_bh;
+		}
+		lock_buffer(bh);
+		memcpy(gdb->b_data, sbi->s_group_desc[i], bh->b_size);
+		set_buffer_uptodate(gdb);
+		unlock_buffer(bh);
+		ext3_journal_dirty_metadata(handle, gdb);
+		ext3_set_bit(bit, bh->b_data);
+		brelse(gdb);
+	}
+
+	/* Zero out all of the reserved backup group descriptor table blocks */
+	for (i = 0, bit = gdblocks + 1, block = start + bit;
+	     i < reserved_gdb; i++, block++, bit++) {
+		struct buffer_head *gdb;
+
+		ext3_debug("clear reserved block %#04lx (+%d)\n", block, bit);
+
+		if (IS_ERR(gdb = bclean(handle, sb, block))) {
+			err = PTR_ERR(bh);
+			goto exit_bh;
+		}
+		ext3_journal_dirty_metadata(handle, gdb);
+		ext3_set_bit(bit, bh->b_data);
+		brelse(gdb);
+	}
+	ext3_debug("mark block bitmap %#04x (+%ld)\n", input->block_bitmap,
+		   input->block_bitmap - start);
+	ext3_set_bit(input->block_bitmap - start, bh->b_data);
+	ext3_debug("mark inode bitmap %#04x (+%ld)\n", input->inode_bitmap,
+		   input->inode_bitmap - start);
+	ext3_set_bit(input->inode_bitmap - start, bh->b_data);
+
+	/* Zero out all of the inode table blocks */
+	for (i = 0, block = input->inode_table, bit = block - start;
+	     i < sbi->s_itb_per_group; i++, bit++, block++) {
+		struct buffer_head *it;
+
+		ext3_debug("clear inode block %#04x (+%ld)\n", block, bit);
+		if (IS_ERR(it = bclean(handle, sb, block))) {
+			err = PTR_ERR(it);
+			goto exit_bh;
+		}
+		ext3_journal_dirty_metadata(handle, it);
+		brelse(it);
+		ext3_set_bit(bit, bh->b_data);
+	}
+	mark_bitmap_end(input->blocks_count, EXT3_BLOCKS_PER_GROUP(sb),
+			bh->b_data);
+	ext3_journal_dirty_metadata(handle, bh);
+	brelse(bh);
+
+	/* Mark unused entries in inode bitmap used */
+	ext3_debug("clear inode bitmap %#04x (+%ld)\n",
+		   input->inode_bitmap, input->inode_bitmap - start);
+	if (IS_ERR(bh = bclean(handle, sb, input->inode_bitmap))) {
+		err = PTR_ERR(bh);
+		goto exit_journal;
+	}
+
+	mark_bitmap_end(EXT3_INODES_PER_GROUP(sb), EXT3_BLOCKS_PER_GROUP(sb),
+			bh->b_data);
+	ext3_journal_dirty_metadata(handle, bh);
+exit_bh:
+	brelse(bh);
+
+exit_journal:
+	unlock_super(sb);
+	if ((err2 = ext3_journal_stop(handle)) && !err)
+		err = err2;
+
+	return err;
+}
+
+/*
+ * Iterate through the groups which hold BACKUP superblock/GDT copies in an
+ * ext3 filesystem.  The counters should be initialized to 1, 5, and 7 before
+ * calling this for the first time.  In a sparse filesystem it will be the
+ * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ...
+ * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ...
+ */
+unsigned ext3_list_backups(struct super_block *sb, unsigned *three,
+			   unsigned *five, unsigned *seven)
+{
+	unsigned *min = three;
+	int mult = 3;
+	unsigned ret;
+
+	if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
+					EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
+		ret = *min;
+		*min += 1;
+		return ret;
+	}
+
+	if (*five < *min) {
+		min = five;
+		mult = 5;
+	}
+	if (*seven < *min) {
+		min = seven;
+		mult = 7;
+	}
+
+	ret = *min;
+	*min *= mult;
+
+	return ret;
+}
+
+/*
+ * Check that all of the backup GDT blocks are held in the primary GDT block.
+ * It is assumed that they are stored in group order.  Returns the number of
+ * groups in current filesystem that have BACKUPS, or -ve error code.
+ */
+static int verify_reserved_gdb(struct super_block *sb,
+			       struct buffer_head *primary)
+{
+	const unsigned long blk = primary->b_blocknr;
+	const unsigned long end = EXT3_SB(sb)->s_groups_count;
+	unsigned three = 1;
+	unsigned five = 5;
+	unsigned seven = 7;
+	unsigned grp;
+	__u32 *p = (__u32 *)primary->b_data;
+	int gdbackups = 0;
+
+	while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) {
+		if (le32_to_cpu(*p++) != grp * EXT3_BLOCKS_PER_GROUP(sb) + blk){
+			ext3_warning(sb, __FUNCTION__,
+				     "reserved GDT %ld missing grp %d (%ld)\n",
+				     blk, grp,
+				     grp * EXT3_BLOCKS_PER_GROUP(sb) + blk);
+			return -EINVAL;
+		}
+		if (++gdbackups > EXT3_ADDR_PER_BLOCK(sb))
+			return -EFBIG;
+	}
+
+	return gdbackups;
+}
+
+/*
+ * Called when we need to bring a reserved group descriptor table block into
+ * use from the resize inode.  The primary copy of the new GDT block currently
+ * is an indirect block (under the double indirect block in the resize inode).
+ * The new backup GDT blocks will be stored as leaf blocks in this indirect
+ * block, in group order.  Even though we know all the block numbers we need,
+ * we check to ensure that the resize inode has actually reserved these blocks.
+ *
+ * Don't need to update the block bitmaps because the blocks are still in use.
+ *
+ * We get all of the error cases out of the way, so that we are sure to not
+ * fail once we start modifying the data on disk, because JBD has no rollback.
+ */
+static int add_new_gdb(handle_t *handle, struct inode *inode,
+		       struct ext3_new_group_data *input,
+		       struct buffer_head **primary)
+{
+	struct super_block *sb = inode->i_sb;
+	struct ext3_super_block *es = EXT3_SB(sb)->s_es;
+	unsigned long gdb_num = input->group / EXT3_DESC_PER_BLOCK(sb);
+	unsigned long gdblock = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + gdb_num;
+	struct buffer_head **o_group_desc, **n_group_desc;
+	struct buffer_head *dind;
+	int gdbackups;
+	struct ext3_iloc iloc;
+	__u32 *data;
+	int err;
+
+	if (test_opt(sb, DEBUG))
+		printk(KERN_DEBUG
+		       "EXT3-fs: ext3_add_new_gdb: adding group block %lu\n",
+		       gdb_num);
+
+	/*
+	 * If we are not using the primary superblock/GDT copy don't resize,
+	 * because the user tools have no way of handling this.  Probably a
+	 * bad time to do it anyways.
+	 */
+	if (EXT3_SB(sb)->s_sbh->b_blocknr !=
+	    le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) {
+		ext3_warning(sb, __FUNCTION__,
+			"won't resize using backup superblock at %llu\n",
+			(unsigned long long)EXT3_SB(sb)->s_sbh->b_blocknr);
+		return -EPERM;
+	}
+
+	*primary = sb_bread(sb, gdblock);
+	if (!*primary)
+		return -EIO;
+
+	if ((gdbackups = verify_reserved_gdb(sb, *primary)) < 0) {
+		err = gdbackups;
+		goto exit_bh;
+	}
+
+	data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
+	dind = sb_bread(sb, le32_to_cpu(*data));
+	if (!dind) {
+		err = -EIO;
+		goto exit_bh;
+	}
+
+	data = (__u32 *)dind->b_data;
+	if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) {
+		ext3_warning(sb, __FUNCTION__,
+			     "new group %u GDT block %lu not reserved\n",
+			     input->group, gdblock);
+		err = -EINVAL;
+		goto exit_dind;
+	}
+
+	if ((err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh)))
+		goto exit_dind;
+
+	if ((err = ext3_journal_get_write_access(handle, *primary)))
+		goto exit_sbh;
+
+	if ((err = ext3_journal_get_write_access(handle, dind)))
+		goto exit_primary;
+
+	/* ext3_reserve_inode_write() gets a reference on the iloc */
+	if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
+		goto exit_dindj;
+
+	n_group_desc = (struct buffer_head **)kmalloc((gdb_num + 1) *
+				sizeof(struct buffer_head *), GFP_KERNEL);
+	if (!n_group_desc) {
+		err = -ENOMEM;
+		ext3_warning (sb, __FUNCTION__,
+			      "not enough memory for %lu groups", gdb_num + 1);
+		goto exit_inode;
+	}
+
+	/*
+	 * Finally, we have all of the possible failures behind us...
+	 *
+	 * Remove new GDT block from inode double-indirect block and clear out
+	 * the new GDT block for use (which also "frees" the backup GDT blocks
+	 * from the reserved inode).  We don't need to change the bitmaps for
+	 * these blocks, because they are marked as in-use from being in the
+	 * reserved inode, and will become GDT blocks (primary and backup).
+	 */
+	data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)] = 0;
+	ext3_journal_dirty_metadata(handle, dind);
+	brelse(dind);
+	inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9;
+	ext3_mark_iloc_dirty(handle, inode, &iloc);
+	memset((*primary)->b_data, 0, sb->s_blocksize);
+	ext3_journal_dirty_metadata(handle, *primary);
+
+	o_group_desc = EXT3_SB(sb)->s_group_desc;
+	memcpy(n_group_desc, o_group_desc,
+	       EXT3_SB(sb)->s_gdb_count * sizeof(struct buffer_head *));
+	n_group_desc[gdb_num] = *primary;
+	EXT3_SB(sb)->s_group_desc = n_group_desc;
+	EXT3_SB(sb)->s_gdb_count++;
+	kfree(o_group_desc);
+
+	es->s_reserved_gdt_blocks =
+		cpu_to_le16(le16_to_cpu(es->s_reserved_gdt_blocks) - 1);
+	ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
+
+	return 0;
+
+exit_inode:
+	//ext3_journal_release_buffer(handle, iloc.bh);
+	brelse(iloc.bh);
+exit_dindj:
+	//ext3_journal_release_buffer(handle, dind);
+exit_primary:
+	//ext3_journal_release_buffer(handle, *primary);
+exit_sbh:
+	//ext3_journal_release_buffer(handle, *primary);
+exit_dind:
+	brelse(dind);
+exit_bh:
+	brelse(*primary);
+
+	ext3_debug("leaving with error %d\n", err);
+	return err;
+}
+
+/*
+ * Called when we are adding a new group which has a backup copy of each of
+ * the GDT blocks (i.e. sparse group) and there are reserved GDT blocks.
+ * We need to add these reserved backup GDT blocks to the resize inode, so
+ * that they are kept for future resizing and not allocated to files.
+ *
+ * Each reserved backup GDT block will go into a different indirect block.
+ * The indirect blocks are actually the primary reserved GDT blocks,
+ * so we know in advance what their block numbers are.  We only get the
+ * double-indirect block to verify it is pointing to the primary reserved
+ * GDT blocks so we don't overwrite a data block by accident.  The reserved
+ * backup GDT blocks are stored in their reserved primary GDT block.
+ */
+static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
+			      struct ext3_new_group_data *input)
+{
+	struct super_block *sb = inode->i_sb;
+	int reserved_gdb =le16_to_cpu(EXT3_SB(sb)->s_es->s_reserved_gdt_blocks);
+	struct buffer_head **primary;
+	struct buffer_head *dind;
+	struct ext3_iloc iloc;
+	unsigned long blk;
+	__u32 *data, *end;
+	int gdbackups = 0;
+	int res, i;
+	int err;
+
+	primary = kmalloc(reserved_gdb * sizeof(*primary), GFP_KERNEL);
+	if (!primary)
+		return -ENOMEM;
+
+	data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
+	dind = sb_bread(sb, le32_to_cpu(*data));
+	if (!dind) {
+		err = -EIO;
+		goto exit_free;
+	}
+
+	blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count;
+	data = (__u32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count;
+	end = (__u32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);
+
+	/* Get each reserved primary GDT block and verify it holds backups */
+	for (res = 0; res < reserved_gdb; res++, blk++) {
+		if (le32_to_cpu(*data) != blk) {
+			ext3_warning(sb, __FUNCTION__,
+				     "reserved block %lu not at offset %ld\n",
+				     blk, (long)(data - (__u32 *)dind->b_data));
+			err = -EINVAL;
+			goto exit_bh;
+		}
+		primary[res] = sb_bread(sb, blk);
+		if (!primary[res]) {
+			err = -EIO;
+			goto exit_bh;
+		}
+		if ((gdbackups = verify_reserved_gdb(sb, primary[res])) < 0) {
+			brelse(primary[res]);
+			err = gdbackups;
+			goto exit_bh;
+		}
+		if (++data >= end)
+			data = (__u32 *)dind->b_data;
+	}
+
+	for (i = 0; i < reserved_gdb; i++) {
+		if ((err = ext3_journal_get_write_access(handle, primary[i]))) {
+			/*
+			int j;
+			for (j = 0; j < i; j++)
+				ext3_journal_release_buffer(handle, primary[j]);
+			 */
+			goto exit_bh;
+		}
+	}
+
+	if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
+		goto exit_bh;
+
+	/*
+	 * Finally we can add each of the reserved backup GDT blocks from
+	 * the new group to its reserved primary GDT block.
+	 */
+	blk = input->group * EXT3_BLOCKS_PER_GROUP(sb);
+	for (i = 0; i < reserved_gdb; i++) {
+		int err2;
+		data = (__u32 *)primary[i]->b_data;
+		/* printk("reserving backup %lu[%u] = %lu\n",
+		       primary[i]->b_blocknr, gdbackups,
+		       blk + primary[i]->b_blocknr); */
+		data[gdbackups] = cpu_to_le32(blk + primary[i]->b_blocknr);
+		err2 = ext3_journal_dirty_metadata(handle, primary[i]);
+		if (!err)
+			err = err2;
+	}
+	inode->i_blocks += reserved_gdb * sb->s_blocksize >> 9;
+	ext3_mark_iloc_dirty(handle, inode, &iloc);
+
+exit_bh:
+	while (--res >= 0)
+		brelse(primary[res]);
+	brelse(dind);
+
+exit_free:
+	kfree(primary);
+
+	return err;
+}
+
+/*
+ * Update the backup copies of the ext3 metadata.  These don't need to be part
+ * of the main resize transaction, because e2fsck will re-write them if there
+ * is a problem (basically only OOM will cause a problem).  However, we
+ * _should_ update the backups if possible, in case the primary gets trashed
+ * for some reason and we need to run e2fsck from a backup superblock.  The
+ * important part is that the new block and inode counts are in the backup
+ * superblocks, and the location of the new group metadata in the GDT backups.
+ *
+ * We do not need lock_super() for this, because these blocks are not
+ * otherwise touched by the filesystem code when it is mounted.  We don't
+ * need to worry about last changing from sbi->s_groups_count, because the
+ * worst that can happen is that we do not copy the full number of backups
+ * at this time.  The resize which changed s_groups_count will backup again.
+ */
+static void update_backups(struct super_block *sb,
+			   int blk_off, char *data, int size)
+{
+	struct ext3_sb_info *sbi = EXT3_SB(sb);
+	const unsigned long last = sbi->s_groups_count;
+	const int bpg = EXT3_BLOCKS_PER_GROUP(sb);
+	unsigned three = 1;
+	unsigned five = 5;
+	unsigned seven = 7;
+	unsigned group;
+	int rest = sb->s_blocksize - size;
+	handle_t *handle;
+	int err = 0, err2;
+
+	handle = ext3_journal_start_sb(sb, EXT3_MAX_TRANS_DATA);
+	if (IS_ERR(handle)) {
+		group = 1;
+		err = PTR_ERR(handle);
+		goto exit_err;
+	}
+
+	while ((group = ext3_list_backups(sb, &three, &five, &seven)) < last) {
+		struct buffer_head *bh;
+
+		/* Out of journal space, and can't get more - abort - so sad */
+		if (handle->h_buffer_credits == 0 &&
+		    ext3_journal_extend(handle, EXT3_MAX_TRANS_DATA) &&
+		    (err = ext3_journal_restart(handle, EXT3_MAX_TRANS_DATA)))
+			break;
+
+		bh = sb_getblk(sb, group * bpg + blk_off);
+		ext3_debug(sb, __FUNCTION__, "update metadata backup %#04lx\n",
+			   bh->b_blocknr);
+		if ((err = ext3_journal_get_write_access(handle, bh)))
+			break;
+		lock_buffer(bh);
+		memcpy(bh->b_data, data, size);
+		if (rest)
+			memset(bh->b_data + size, 0, rest);
+		set_buffer_uptodate(bh);
+		unlock_buffer(bh);
+		ext3_journal_dirty_metadata(handle, bh);
+		brelse(bh);
+	}
+	if ((err2 = ext3_journal_stop(handle)) && !err)
+		err = err2;
+
+	/*
+	 * Ugh! Need to have e2fsck write the backup copies.  It is too
+	 * late to revert the resize, we shouldn't fail just because of
+	 * the backup copies (they are only needed in case of corruption).
+	 *
+	 * However, if we got here we have a journal problem too, so we
+	 * can't really start a transaction to mark the superblock.
+	 * Chicken out and just set the flag on the hope it will be written
+	 * to disk, and if not - we will simply wait until next fsck.
+	 */
+exit_err:
+	if (err) {
+		ext3_warning(sb, __FUNCTION__,
+			     "can't update backup for group %d (err %d), "
+			     "forcing fsck on next reboot\n", group, err);
+		sbi->s_mount_state &= ~EXT3_VALID_FS;
+		sbi->s_es->s_state &= ~cpu_to_le16(EXT3_VALID_FS);
+		mark_buffer_dirty(sbi->s_sbh);
+	}
+}
+
+/* Add group descriptor data to an existing or new group descriptor block.
+ * Ensure we handle all possible error conditions _before_ we start modifying
+ * the filesystem, because we cannot abort the transaction and not have it
+ * write the data to disk.
+ *
+ * If we are on a GDT block boundary, we need to get the reserved GDT block.
+ * Otherwise, we may need to add backup GDT blocks for a sparse group.
+ *
+ * We only need to hold the superblock lock while we are actually adding
+ * in the new group's counts to the superblock.  Prior to that we have
+ * not really "added" the group at all.  We re-check that we are still
+ * adding in the last group in case things have changed since verifying.
+ */
+int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
+{
+	struct ext3_sb_info *sbi = EXT3_SB(sb);
+	struct ext3_super_block *es = sbi->s_es;
+	int reserved_gdb = ext3_bg_has_super(sb, input->group) ?
+		le16_to_cpu(es->s_reserved_gdt_blocks) : 0;
+	struct buffer_head *primary = NULL;
+	struct ext3_group_desc *gdp;
+	struct inode *inode = NULL;
+	handle_t *handle;
+	int gdb_off, gdb_num;
+	int err, err2;
+
+	gdb_num = input->group / EXT3_DESC_PER_BLOCK(sb);
+	gdb_off = input->group % EXT3_DESC_PER_BLOCK(sb);
+
+	if (gdb_off == 0 && !EXT3_HAS_RO_COMPAT_FEATURE(sb,
+					EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
+		ext3_warning(sb, __FUNCTION__,
+			     "Can't resize non-sparse filesystem further\n");
+		return -EPERM;
+	}
+
+	if (reserved_gdb || gdb_off == 0) {
+		if (!EXT3_HAS_COMPAT_FEATURE(sb,
+					     EXT3_FEATURE_COMPAT_RESIZE_INODE)){
+			ext3_warning(sb, __FUNCTION__,
+				     "No reserved GDT blocks, can't resize\n");
+			return -EPERM;
+		}
+		inode = iget(sb, EXT3_RESIZE_INO);
+		if (!inode || is_bad_inode(inode)) {
+			ext3_warning(sb, __FUNCTION__,
+				     "Error opening resize inode\n");
+			iput(inode);
+			return -ENOENT;
+		}
+	}
+
+	if ((err = verify_group_input(sb, input)))
+		goto exit_put;
+
+	if ((err = setup_new_group_blocks(sb, input)))
+		goto exit_put;
+
+	/*
+	 * We will always be modifying at least the superblock and a GDT
+	 * block.  If we are adding a group past the last current GDT block,
+	 * we will also modify the inode and the dindirect block.  If we
+	 * are adding a group with superblock/GDT backups  we will also
+	 * modify each of the reserved GDT dindirect blocks.
+	 */
+	handle = ext3_journal_start_sb(sb,
+				       ext3_bg_has_super(sb, input->group) ?
+				       3 + reserved_gdb : 4);
+	if (IS_ERR(handle)) {
+		err = PTR_ERR(handle);
+		goto exit_put;
+	}
+
+	lock_super(sb);
+	if (input->group != EXT3_SB(sb)->s_groups_count) {
+		ext3_warning(sb, __FUNCTION__,
+			     "multiple resizers run on filesystem!\n");
+		goto exit_journal;
+	}
+
+	if ((err = ext3_journal_get_write_access(handle, sbi->s_sbh)))
+		goto exit_journal;
+
+	/*
+	 * We will only either add reserved group blocks to a backup group
+	 * or remove reserved blocks for the first group in a new group block.
+	 * Doing both would be mean more complex code, and sane people don't
+	 * use non-sparse filesystems anymore.  This is already checked above.
+	 */
+	if (gdb_off) {
+		primary = sbi->s_group_desc[gdb_num];
+		if ((err = ext3_journal_get_write_access(handle, primary)))
+			goto exit_journal;
+
+		if (reserved_gdb && ext3_bg_num_gdb(sb, input->group) &&
+		    (err = reserve_backup_gdb(handle, inode, input)))
+			goto exit_journal;
+	} else if ((err = add_new_gdb(handle, inode, input, &primary)))
+		goto exit_journal;
+
+	/*
+	 * OK, now we've set up the new group.  Time to make it active.
+	 *
+	 * Current kernels don't lock all allocations via lock_super(),
+	 * so we have to be safe wrt. concurrent accesses the group
+	 * data.  So we need to be careful to set all of the relevant
+	 * group descriptor data etc. *before* we enable the group.
+	 *
+	 * The key field here is EXT3_SB(sb)->s_groups_count: as long as
+	 * that retains its old value, nobody is going to access the new
+	 * group.
+	 *
+	 * So first we update all the descriptor metadata for the new
+	 * group; then we update the total disk blocks count; then we
+	 * update the groups count to enable the group; then finally we
+	 * update the free space counts so that the system can start
+	 * using the new disk blocks.
+	 */
+
+	/* Update group descriptor block for new group */
+	gdp = (struct ext3_group_desc *)primary->b_data + gdb_off;
+
+	gdp->bg_block_bitmap = cpu_to_le32(input->block_bitmap);
+	gdp->bg_inode_bitmap = cpu_to_le32(input->inode_bitmap);
+	gdp->bg_inode_table = cpu_to_le32(input->inode_table);
+	gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
+	gdp->bg_free_inodes_count = cpu_to_le16(EXT3_INODES_PER_GROUP(sb));
+
+	/*
+	 * Make the new blocks and inodes valid next.  We do this before
+	 * increasing the group count so that once the group is enabled,
+	 * all of its blocks and inodes are already valid.
+	 *
+	 * We always allocate group-by-group, then block-by-block or
+	 * inode-by-inode within a group, so enabling these
+	 * blocks/inodes before the group is live won't actually let us
+	 * allocate the new space yet.
+	 */
+	es->s_blocks_count = cpu_to_le32(le32_to_cpu(es->s_blocks_count) +
+		input->blocks_count);
+	es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) +
+		EXT3_INODES_PER_GROUP(sb));
+
+	/*
+	 * We need to protect s_groups_count against other CPUs seeing
+	 * inconsistent state in the superblock.
+	 *
+	 * The precise rules we use are:
+	 *
+	 * * Writers of s_groups_count *must* hold lock_super
+	 * AND
+	 * * Writers must perform a smp_wmb() after updating all dependent
+	 *   data and before modifying the groups count
+	 *
+	 * * Readers must hold lock_super() over the access
+	 * OR
+	 * * Readers must perform an smp_rmb() after reading the groups count
+	 *   and before reading any dependent data.
+	 *
+	 * NB. These rules can be relaxed when checking the group count
+	 * while freeing data, as we can only allocate from a block
+	 * group after serialising against the group count, and we can
+	 * only then free after serialising in turn against that
+	 * allocation.
+	 */
+	smp_wmb();
+
+	/* Update the global fs size fields */
+	EXT3_SB(sb)->s_groups_count++;
+
+	ext3_journal_dirty_metadata(handle, primary);
+
+	/* Update the reserved block counts only once the new group is
+	 * active. */
+	es->s_r_blocks_count = cpu_to_le32(le32_to_cpu(es->s_r_blocks_count) +
+		input->reserved_blocks);
+
+	/* Update the free space counts */
+	percpu_counter_mod(&sbi->s_freeblocks_counter,
+			   input->free_blocks_count);
+	percpu_counter_mod(&sbi->s_freeinodes_counter,
+			   EXT3_INODES_PER_GROUP(sb));
+
+	ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
+	sb->s_dirt = 1;
+
+exit_journal:
+	unlock_super(sb);
+	if ((err2 = ext3_journal_stop(handle)) && !err)
+		err = err2;
+	if (!err) {
+		update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
+			       sizeof(struct ext3_super_block));
+		update_backups(sb, primary->b_blocknr, primary->b_data,
+			       primary->b_size);
+	}
+exit_put:
+	iput(inode);
+	return err;
+} /* ext3_group_add */
+
+/* Extend the filesystem to the new number of blocks specified.  This entry
+ * point is only used to extend the current filesystem to the end of the last
+ * existing group.  It can be accessed via ioctl, or by "remount,resize=<size>"
+ * for emergencies (because it has no dependencies on reserved blocks).
+ *
+ * If we _really_ wanted, we could use default values to call ext3_group_add()
+ * allow the "remount" trick to work for arbitrary resizing, assuming enough
+ * GDT blocks are reserved to grow to the desired size.
+ */
+int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
+		      unsigned long n_blocks_count)
+{
+	unsigned long o_blocks_count;
+	unsigned long o_groups_count;
+	unsigned long last;
+	int add;
+	struct buffer_head * bh;
+	handle_t *handle;
+	int err, freed_blocks;
+
+	/* We don't need to worry about locking wrt other resizers just
+	 * yet: we're going to revalidate es->s_blocks_count after
+	 * taking lock_super() below. */
+	o_blocks_count = le32_to_cpu(es->s_blocks_count);
+	o_groups_count = EXT3_SB(sb)->s_groups_count;
+
+	if (test_opt(sb, DEBUG))
+		printk(KERN_DEBUG "EXT3-fs: extending last group from %lu to %lu blocks\n",
+		       o_blocks_count, n_blocks_count);
+
+	if (n_blocks_count == 0 || n_blocks_count == o_blocks_count)
+		return 0;
+
+	if (n_blocks_count < o_blocks_count) {
+		ext3_warning(sb, __FUNCTION__,
+			     "can't shrink FS - resize aborted");
+		return -EBUSY;
+	}
+
+	/* Handle the remaining blocks in the last group only. */
+	last = (o_blocks_count - le32_to_cpu(es->s_first_data_block)) %
+		EXT3_BLOCKS_PER_GROUP(sb);
+
+	if (last == 0) {
+		ext3_warning(sb, __FUNCTION__,
+			     "need to use ext2online to resize further\n");
+		return -EPERM;
+	}
+
+	add = EXT3_BLOCKS_PER_GROUP(sb) - last;
+
+	if (o_blocks_count + add > n_blocks_count)
+		add = n_blocks_count - o_blocks_count;
+
+	if (o_blocks_count + add < n_blocks_count)
+		ext3_warning(sb, __FUNCTION__,
+			     "will only finish group (%lu blocks, %u new)",
+			     o_blocks_count + add, add);
+
+	/* See if the device is actually as big as what was requested */
+	bh = sb_bread(sb, o_blocks_count + add -1);
+	if (!bh) {
+		ext3_warning(sb, __FUNCTION__,
+			     "can't read last block, resize aborted");
+		return -ENOSPC;
+	}
+	brelse(bh);
+
+	/* We will update the superblock, one block bitmap, and
+	 * one group descriptor via ext3_free_blocks().
+	 */
+	handle = ext3_journal_start_sb(sb, 3);
+	if (IS_ERR(handle)) {
+		err = PTR_ERR(handle);
+		ext3_warning(sb, __FUNCTION__, "error %d on journal start",err);
+		goto exit_put;
+	}
+
+	lock_super(sb);
+	if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) {
+		ext3_warning(sb, __FUNCTION__,
+			     "multiple resizers run on filesystem!\n");
+		err = -EBUSY;
+		goto exit_put;
+	}
+
+	if ((err = ext3_journal_get_write_access(handle,
+						 EXT3_SB(sb)->s_sbh))) {
+		ext3_warning(sb, __FUNCTION__,
+			     "error %d on journal write access", err);
+		unlock_super(sb);
+		ext3_journal_stop(handle);
+		goto exit_put;
+	}
+	es->s_blocks_count = cpu_to_le32(o_blocks_count + add);
+	ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
+	sb->s_dirt = 1;
+	unlock_super(sb);
+	ext3_debug("freeing blocks %ld through %ld\n", o_blocks_count,
+		   o_blocks_count + add);
+	ext3_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks);
+	ext3_debug("freed blocks %ld through %ld\n", o_blocks_count,
+		   o_blocks_count + add);
+	if ((err = ext3_journal_stop(handle)))
+		goto exit_put;
+	if (test_opt(sb, DEBUG))
+		printk(KERN_DEBUG "EXT3-fs: extended group to %u blocks\n",
+		       le32_to_cpu(es->s_blocks_count));
+	update_backups(sb, EXT3_SB(sb)->s_sbh->b_blocknr, (char *)es,
+		       sizeof(struct ext3_super_block));
+exit_put:
+	return err;
+} /* ext3_group_extend */
diff -Nru a/fs/ext3/super.c b/fs/ext3/super.c
--- a/fs/ext3/super.c	2004-12-24 13:37:19 -08:00
+++ b/fs/ext3/super.c	2004-12-24 13:37:19 -08:00
@@ -59,19 +59,19 @@
  * that sync() will call the filesystem's write_super callback if
  * appropriate. 
  */
-handle_t *ext3_journal_start(struct inode *inode, int nblocks)
+handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks)
 {
 	journal_t *journal;
 
-	if (inode->i_sb->s_flags & MS_RDONLY)
+	if (sb->s_flags & MS_RDONLY)
 		return ERR_PTR(-EROFS);
 
 	/* Special case here: if the journal has aborted behind our
 	 * backs (eg. EIO in the commit thread), then we still need to
 	 * take the FS itself readonly cleanly. */
-	journal = EXT3_JOURNAL(inode);
+	journal = EXT3_SB(sb)->s_journal;
 	if (is_journal_aborted(journal)) {
-		ext3_abort(inode->i_sb, __FUNCTION__,
+		ext3_abort(sb, __FUNCTION__,
 			   "Detected aborted journal");
 		return ERR_PTR(-EROFS);
 	}
@@ -400,7 +400,9 @@
 	for (i = 0; i < sbi->s_gdb_count; i++)
 		brelse(sbi->s_group_desc[i]);
 	kfree(sbi->s_group_desc);
-	kfree(sbi->s_debts);
+	percpu_counter_destroy(&sbi->s_freeblocks_counter);
+	percpu_counter_destroy(&sbi->s_freeinodes_counter);
+	percpu_counter_destroy(&sbi->s_dirs_counter);
 	brelse(sbi->s_sbh);
 #ifdef CONFIG_QUOTA
 	for (i = 0; i < MAXQUOTAS; i++) {
@@ -449,6 +451,7 @@
 	ei->i_acl = EXT3_ACL_NOT_CACHED;
 	ei->i_default_acl = EXT3_ACL_NOT_CACHED;
 #endif
+	ei->i_rsv_window.rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
 	ei->vfs_inode.i_version = 1;
 	return &ei->vfs_inode;
 }
@@ -490,10 +493,9 @@
 		printk(KERN_INFO "ext3_inode_cache: not all structures were freed\n");
 }
 
-#ifdef CONFIG_EXT3_FS_POSIX_ACL
-
 static void ext3_clear_inode(struct inode *inode)
 {
+#ifdef CONFIG_EXT3_FS_POSIX_ACL
        if (EXT3_I(inode)->i_acl &&
            EXT3_I(inode)->i_acl != EXT3_ACL_NOT_CACHED) {
                posix_acl_release(EXT3_I(inode)->i_acl);
@@ -504,11 +506,9 @@
                posix_acl_release(EXT3_I(inode)->i_default_acl);
                EXT3_I(inode)->i_default_acl = EXT3_ACL_NOT_CACHED;
        }
-}
-
-#else
-# define ext3_clear_inode NULL
 #endif
+	ext3_discard_reservation(inode);
+}
 
 #ifdef CONFIG_QUOTA
 
@@ -558,7 +558,6 @@
 	.read_inode	= ext3_read_inode,
 	.write_inode	= ext3_write_inode,
 	.dirty_inode	= ext3_dirty_inode,
-	.put_inode	= ext3_put_inode,
 	.delete_inode	= ext3_delete_inode,
 	.put_super	= ext3_put_super,
 	.write_super	= ext3_write_super,
@@ -579,12 +578,13 @@
 	Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
 	Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
 	Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov,
-	Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_noload,
+	Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
+	Opt_reservation, Opt_noreservation, Opt_noload,
 	Opt_commit, Opt_journal_update, Opt_journal_inum,
 	Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
 	Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
 	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0,
-	Opt_ignore, Opt_barrier, Opt_err,
+	Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
 };
 
 static match_table_t tokens = {
@@ -611,6 +611,8 @@
 	{Opt_nouser_xattr, "nouser_xattr"},
 	{Opt_acl, "acl"},
 	{Opt_noacl, "noacl"},
+	{Opt_reservation, "reservation"},
+	{Opt_noreservation, "noreservation"},
 	{Opt_noload, "noload"},
 	{Opt_commit, "commit=%u"},
 	{Opt_journal_update, "journal=update"},
@@ -630,7 +632,8 @@
 	{Opt_ignore, "quota"},
 	{Opt_ignore, "usrquota"},
 	{Opt_barrier, "barrier=%u"},
-	{Opt_err, NULL}
+	{Opt_err, NULL},
+	{Opt_resize, "resize"},
 };
 
 static unsigned long get_sb_block(void **data)
@@ -654,7 +657,7 @@
 }
 
 static int parse_options (char * options, struct super_block *sb,
-			  unsigned long * inum, int is_remount)
+			  unsigned long * inum, unsigned long *n_blocks_count, int is_remount)
 {
 	struct ext3_sb_info *sbi = EXT3_SB(sb);
 	char * p;
@@ -765,6 +768,12 @@
 			printk("EXT3 (no)acl options not supported\n");
 			break;
 #endif
+		case Opt_reservation:
+			set_opt(sbi->s_mount_opt, RESERVATION);
+			break;
+		case Opt_noreservation:
+			clear_opt(sbi->s_mount_opt, RESERVATION);
+			break;
 		case Opt_journal_update:
 			/* @@@ FIXME */
 			/* Eventually we will want to be able to create
@@ -905,6 +914,15 @@
 			break;
 		case Opt_ignore:
 			break;
+		case Opt_resize:
+			if (!n_blocks_count) {
+				printk("EXT3-fs: resize option only available "
+					"for remount\n");
+				return 0;
+			}
+			match_int(&args[0], &option);
+			*n_blocks_count = option;
+			break;
 		default:
 			printk (KERN_ERR
 				"EXT3-fs: Unrecognized mount option \"%s\" "
@@ -998,6 +1016,7 @@
 	return res;
 }
 
+/* Called at mount-time, super-block is locked */
 static int ext3_check_descriptors (struct super_block * sb)
 {
 	struct ext3_sb_info *sbi = EXT3_SB(sb);
@@ -1259,13 +1278,8 @@
 	es = (struct ext3_super_block *) (((char *)bh->b_data) + offset);
 	sbi->s_es = es;
 	sb->s_magic = le16_to_cpu(es->s_magic);
-	if (sb->s_magic != EXT3_SUPER_MAGIC) {
-		if (!silent)
-			printk(KERN_ERR 
-			       "VFS: Can't find ext3 filesystem on dev %s.\n",
-			       sb->s_id);
-		goto failed_mount;
-	}
+	if (sb->s_magic != EXT3_SUPER_MAGIC)
+		goto cantfind_ext3;
 
 	/* Set defaults before we parse the mount options */
 	def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
@@ -1294,7 +1308,9 @@
 	sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
 	sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
 
-	if (!parse_options ((char *) data, sb, &journal_inum, 0))
+	set_opt(sbi->s_mount_opt, RESERVATION);
+
+	if (!parse_options ((char *) data, sb, &journal_inum, NULL, 0))
 		goto failed_mount;
 
 	sb->s_flags |= MS_ONE_SECOND;
@@ -1397,8 +1413,13 @@
 	sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
 	sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
 	sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
+	if (EXT3_INODE_SIZE(sb) == 0)
+		goto cantfind_ext3;
 	sbi->s_inodes_per_block = blocksize / EXT3_INODE_SIZE(sb);
-	sbi->s_itb_per_group = sbi->s_inodes_per_group /sbi->s_inodes_per_block;
+	if (sbi->s_inodes_per_block == 0)
+		goto cantfind_ext3;
+	sbi->s_itb_per_group = sbi->s_inodes_per_group /
+					sbi->s_inodes_per_block;
 	sbi->s_desc_per_block = blocksize / sizeof(struct ext3_group_desc);
 	sbi->s_sbh = bh;
 	sbi->s_mount_state = le16_to_cpu(es->s_state);
@@ -1427,6 +1448,8 @@
 		goto failed_mount;
 	}
 
+	if (EXT3_BLOCKS_PER_GROUP(sb) == 0)
+		goto cantfind_ext3;
 	sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) -
 			       le32_to_cpu(es->s_first_data_block) +
 			       EXT3_BLOCKS_PER_GROUP(sb) - 1) /
@@ -1439,13 +1462,6 @@
 		printk (KERN_ERR "EXT3-fs: not enough memory\n");
 		goto failed_mount;
 	}
-	sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(u8),
-			GFP_KERNEL);
-	if (!sbi->s_debts) {
-		printk("EXT3-fs: not enough memory to allocate s_bgi\n");
-		goto failed_mount2;
-	}
-	memset(sbi->s_debts, 0,  sbi->s_groups_count * sizeof(u8));
 
 	percpu_counter_init(&sbi->s_freeblocks_counter);
 	percpu_counter_init(&sbi->s_freeinodes_counter);
@@ -1469,11 +1485,25 @@
 	sbi->s_gdb_count = db_count;
 	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
 	spin_lock_init(&sbi->s_next_gen_lock);
+	/* per fileystem reservation list head & lock */
+	spin_lock_init(&sbi->s_rsv_window_lock);
+	sbi->s_rsv_window_root = RB_ROOT;
+	/* Add a single, static dummy reservation to the start of the
+	 * reservation window list --- it gives us a placeholder for
+	 * append-at-start-of-list which makes the allocation logic
+	 * _much_ simpler. */
+	sbi->s_rsv_window_head.rsv_start = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
+	sbi->s_rsv_window_head.rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
+	atomic_set(&sbi->s_rsv_window_head.rsv_alloc_hit, 0);
+	atomic_set(&sbi->s_rsv_window_head.rsv_goal_size, 0);
+	ext3_rsv_window_add(sb, &sbi->s_rsv_window_head);
+
 	/*
 	 * set up enough so that it can read an inode
 	 */
 	sb->s_op = &ext3_sops;
 	sb->s_export_op = &ext3_export_ops;
+	sb->s_xattr = ext3_xattr_handlers;
 #ifdef CONFIG_QUOTA
 	sb->s_qcop = &ext3_qctl_operations;
 	sb->dq_op = &ext3_quota_operations;
@@ -1579,19 +1609,22 @@
 
 	return 0;
 
+cantfind_ext3:
+	if (!silent)
+		printk(KERN_ERR "VFS: Can't find ext3 filesystem on dev %s.\n",
+		       sb->s_id);
+	goto failed_mount;
+
 failed_mount3:
 	journal_destroy(sbi->s_journal);
 failed_mount2:
-	kfree(sbi->s_debts);
 	for (i = 0; i < db_count; i++)
 		brelse(sbi->s_group_desc[i]);
 	kfree(sbi->s_group_desc);
 failed_mount:
 #ifdef CONFIG_QUOTA
-	for (i = 0; i < MAXQUOTAS; i++) {
-		if (sbi->s_qf_names[i])
-			kfree(sbi->s_qf_names[i]);
-	}
+	for (i = 0; i < MAXQUOTAS; i++)
+		kfree(sbi->s_qf_names[i]);
 #endif
 	ext3_blkdev_remove(sbi);
 	brelse(bh);
@@ -2027,11 +2060,12 @@
 	struct ext3_super_block * es;
 	struct ext3_sb_info *sbi = EXT3_SB(sb);
 	unsigned long tmp;
+	unsigned long n_blocks_count = 0;
 
 	/*
 	 * Allow the "check" option to be passed as a remount option.
 	 */
-	if (!parse_options(data, sb, &tmp, 1))
+	if (!parse_options(data, sb, &tmp, &n_blocks_count, 1))
 		return -EINVAL;
 
 	if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
@@ -2044,7 +2078,8 @@
 
 	ext3_init_journal_params(sb, sbi->s_journal);
 
-	if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
+	if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) ||
+		n_blocks_count > le32_to_cpu(es->s_blocks_count)) {
 		if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
 			return -EROFS;
 
@@ -2083,6 +2118,8 @@
 			 */
 			ext3_clear_journal_err(sb, es);
 			sbi->s_mount_state = le16_to_cpu(es->s_state);
+			if ((ret = ext3_group_extend(sb, es, n_blocks_count)))
+				return ret;
 			if (!ext3_setup_super (sb, es, 0))
 				sb->s_flags &= ~MS_RDONLY;
 		}
@@ -2099,6 +2136,10 @@
 	if (test_opt (sb, MINIX_DF))
 		overhead = 0;
 	else {
+		unsigned long ngroups;
+		ngroups = EXT3_SB(sb)->s_groups_count;
+		smp_rmb();
+
 		/*
 		 * Compute the overhead (FS structures)
 		 */
@@ -2114,7 +2155,7 @@
 		 * block group descriptors.  If the sparse superblocks
 		 * feature is turned on, then not all groups have this.
 		 */
-		for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++)
+		for (i = 0; i < ngroups; i++)
 			overhead += ext3_bg_has_super(sb, i) +
 				ext3_bg_num_gdb(sb, i);
 
@@ -2122,8 +2163,7 @@
 		 * Every block group has an inode bitmap, a block
 		 * bitmap, and an inode table.
 		 */
-		overhead += (EXT3_SB(sb)->s_groups_count *
-			     (2 + EXT3_SB(sb)->s_itb_per_group));
+		overhead += (ngroups * (2 + EXT3_SB(sb)->s_itb_per_group));
 	}
 
 	buf->f_type = EXT3_SUPER_MAGIC;
diff -Nru a/fs/ext3/symlink.c b/fs/ext3/symlink.c
--- a/fs/ext3/symlink.c	2004-12-24 13:36:55 -08:00
+++ b/fs/ext3/symlink.c	2004-12-24 13:36:55 -08:00
@@ -34,17 +34,21 @@
 	.readlink	= generic_readlink,
 	.follow_link	= page_follow_link_light,
 	.put_link	= page_put_link,
-	.setxattr	= ext3_setxattr,
-	.getxattr	= ext3_getxattr,
+#ifdef CONFIG_EXT3_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext3_listxattr,
-	.removexattr	= ext3_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 };
 
 struct inode_operations ext3_fast_symlink_inode_operations = {
 	.readlink	= generic_readlink,
 	.follow_link	= ext3_follow_link,
-	.setxattr	= ext3_setxattr,
-	.getxattr	= ext3_getxattr,
+#ifdef CONFIG_EXT3_FS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
 	.listxattr	= ext3_listxattr,
-	.removexattr	= ext3_removexattr,
+	.removexattr	= generic_removexattr,
+#endif
 };
diff -Nru a/fs/ext3/xattr.c b/fs/ext3/xattr.c
--- a/fs/ext3/xattr.c	2004-12-24 13:36:57 -08:00
+++ b/fs/ext3/xattr.c	2004-12-24 13:36:57 -08:00
@@ -7,6 +7,8 @@
  * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
  * Extended attributes for symlinks and special files added per
  *  suggestion of Luka Renko <luka.renko@hermes.si>.
+ * xattr consolidation Copyright (c) 2004 James Morris <jmorris@redhat.com>,
+ *  Red Hat Inc.
  */
 
 /*
@@ -100,101 +102,40 @@
 			      struct ext3_xattr_entry *);
 
 static struct mb_cache *ext3_xattr_cache;
-static struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX];
-static rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED;
 
-int
-ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler)
-{
-	int error = -EINVAL;
-
-	if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
-		write_lock(&ext3_handler_lock);
-		if (!ext3_xattr_handlers[name_index-1]) {
-			ext3_xattr_handlers[name_index-1] = handler;
-			error = 0;
-		}
-		write_unlock(&ext3_handler_lock);
-	}
-	return error;
-}
-
-void
-ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler)
-{
-	if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) {
-		write_lock(&ext3_handler_lock);
-		ext3_xattr_handlers[name_index-1] = NULL;
-		write_unlock(&ext3_handler_lock);
-	}
-}
-
-static inline const char *
-strcmp_prefix(const char *a, const char *a_prefix)
-{
-	while (*a_prefix && *a == *a_prefix) {
-		a++;
-		a_prefix++;
-	}
-	return *a_prefix ? NULL : a;
-}
-
-/*
- * Decode the extended attribute name, and translate it into
- * the name_index and name suffix.
- */
-static inline struct ext3_xattr_handler *
-ext3_xattr_resolve_name(const char **name)
-{
-	struct ext3_xattr_handler *handler = NULL;
-	int i;
+static struct xattr_handler *ext3_xattr_handler_map[EXT3_XATTR_INDEX_MAX] = {
+	[EXT3_XATTR_INDEX_USER]		     = &ext3_xattr_user_handler,
+#ifdef CONFIG_EXT3_FS_POSIX_ACL
+	[EXT3_XATTR_INDEX_POSIX_ACL_ACCESS]  = &ext3_xattr_acl_access_handler,
+	[EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext3_xattr_acl_default_handler,
+#endif
+	[EXT3_XATTR_INDEX_TRUSTED]	     = &ext3_xattr_trusted_handler,
+#ifdef CONFIG_EXT3_FS_SECURITY
+	[EXT3_XATTR_INDEX_SECURITY]	     = &ext3_xattr_security_handler,
+#endif
+};
 
-	if (!*name)
-		return NULL;
-	read_lock(&ext3_handler_lock);
-	for (i=0; i<EXT3_XATTR_INDEX_MAX; i++) {
-		if (ext3_xattr_handlers[i]) {
-			const char *n = strcmp_prefix(*name,
-				ext3_xattr_handlers[i]->prefix);
-			if (n) {
-				handler = ext3_xattr_handlers[i];
-				*name = n;
-				break;
-			}
-		}
-	}
-	read_unlock(&ext3_handler_lock);
-	return handler;
-}
+struct xattr_handler *ext3_xattr_handlers[] = {
+	&ext3_xattr_user_handler,
+	&ext3_xattr_trusted_handler,
+#ifdef CONFIG_EXT3_FS_POSIX_ACL
+	&ext3_xattr_acl_access_handler,
+	&ext3_xattr_acl_default_handler,
+#endif
+#ifdef CONFIG_EXT3_FS_SECURITY
+	&ext3_xattr_security_handler,
+#endif
+	NULL
+};
 
-static inline struct ext3_xattr_handler *
+static inline struct xattr_handler *
 ext3_xattr_handler(int name_index)
 {
-	struct ext3_xattr_handler *handler = NULL;
-	if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
-		read_lock(&ext3_handler_lock);
-		handler = ext3_xattr_handlers[name_index-1];
-		read_unlock(&ext3_handler_lock);
-	}
-	return handler;
-}
+	struct xattr_handler *handler = NULL;
 
-/*
- * Inode operation getxattr()
- *
- * dentry->d_inode->i_sem: don't care
- */
-ssize_t
-ext3_getxattr(struct dentry *dentry, const char *name,
-	      void *buffer, size_t size)
-{
-	struct ext3_xattr_handler *handler;
-	struct inode *inode = dentry->d_inode;
-
-	handler = ext3_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->get(inode, name, buffer, size);
+	if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX)
+		handler = ext3_xattr_handler_map[name_index];
+	return handler;
 }
 
 /*
@@ -209,43 +150,6 @@
 }
 
 /*
- * Inode operation setxattr()
- *
- * dentry->d_inode->i_sem: down
- */
-int
-ext3_setxattr(struct dentry *dentry, const char *name,
-	      const void *value, size_t size, int flags)
-{
-	struct ext3_xattr_handler *handler;
-	struct inode *inode = dentry->d_inode;
-
-	if (size == 0)
-		value = "";  /* empty EA, do not remove */
-	handler = ext3_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->set(inode, name, value, size, flags);
-}
-
-/*
- * Inode operation removexattr()
- *
- * dentry->d_inode->i_sem: down
- */
-int
-ext3_removexattr(struct dentry *dentry, const char *name)
-{
-	struct ext3_xattr_handler *handler;
-	struct inode *inode = dentry->d_inode;
-
-	handler = ext3_xattr_resolve_name(&name);
-	if (!handler)
-		return -EOPNOTSUPP;
-	return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
-}
-
-/*
  * ext3_xattr_get()
  *
  * Copy an extended attribute into the buffer
@@ -363,8 +267,8 @@
 {
 	struct buffer_head *bh = NULL;
 	struct ext3_xattr_entry *entry;
-	size_t size = 0;
-	char *buf, *end;
+	char *end;
+	size_t rest = buffer_size;
 	int error;
 
 	ea_idebug(inode, "buffer=%p, buffer_size=%ld",
@@ -390,44 +294,40 @@
 		error = -EIO;
 		goto cleanup;
 	}
-	/* compute the size required for the list of attribute names */
-	for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
-	     entry = EXT3_XATTR_NEXT(entry)) {
-		struct ext3_xattr_handler *handler;
-		struct ext3_xattr_entry *next =
-			EXT3_XATTR_NEXT(entry);
+
+	/* check the on-disk data structure */
+	entry = FIRST_ENTRY(bh);
+	while (!IS_LAST_ENTRY(entry)) {
+		struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(entry);
+
 		if ((char *)next >= end)
 			goto bad_block;
-
-		handler = ext3_xattr_handler(entry->e_name_index);
-		if (handler)
-			size += handler->list(NULL, inode, entry->e_name,
-					      entry->e_name_len);
+		entry = next;
 	}
-
 	if (ext3_xattr_cache_insert(bh))
 		ea_idebug(inode, "cache insert failed");
-	if (!buffer) {
-		error = size;
-		goto cleanup;
-	} else {
-		error = -ERANGE;
-		if (size > buffer_size)
-			goto cleanup;
-	}
 
 	/* list the attribute names */
-	buf = buffer;
 	for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
 	     entry = EXT3_XATTR_NEXT(entry)) {
-		struct ext3_xattr_handler *handler;
+		struct xattr_handler *handler =
+			ext3_xattr_handler(entry->e_name_index);
 
-		handler = ext3_xattr_handler(entry->e_name_index);
-		if (handler)
-			buf += handler->list(buf, inode, entry->e_name,
-					     entry->e_name_len);
+		if (handler) {
+			size_t size = handler->list(inode, buffer, rest,
+						    entry->e_name,
+						    entry->e_name_len);
+			if (buffer) {
+				if (size > rest) {
+					error = -ERANGE;
+					goto cleanup;
+				}
+				buffer += size;
+			}
+			rest -= size;
+		}
 	}
-	error = size;
+	error = buffer_size - rest;  /* total size */
 
 cleanup:
 	brelse(bh);
@@ -786,8 +686,7 @@
 					EXT3_SB(sb)->s_es->s_first_data_block) +
 				EXT3_I(inode)->i_block_group *
 				EXT3_BLOCKS_PER_GROUP(sb);
-			int block = ext3_new_block(handle, inode, goal,
-						   NULL, NULL, &error);
+			int block = ext3_new_block(handle, inode, goal, &error);
 			if (error)
 				goto cleanup;
 			ea_idebug(inode, "creating block %d", block);
@@ -1179,51 +1078,12 @@
 int __init
 init_ext3_xattr(void)
 {
-	int	err;
-
-	err = ext3_xattr_register(EXT3_XATTR_INDEX_USER,
-				  &ext3_xattr_user_handler);
-	if (err)
-		return err;
-	err = ext3_xattr_register(EXT3_XATTR_INDEX_TRUSTED,
-				  &ext3_xattr_trusted_handler);
-	if (err)
-		goto out;
-#ifdef CONFIG_EXT3_FS_SECURITY
-	err = ext3_xattr_register(EXT3_XATTR_INDEX_SECURITY,
-				  &ext3_xattr_security_handler);
-	if (err)
-		goto out1;
-#endif
-#ifdef CONFIG_EXT3_FS_POSIX_ACL
-	err = init_ext3_acl();
-	if (err)
-		goto out2;
-#endif
 	ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
 		sizeof(struct mb_cache_entry) +
 		sizeof(struct mb_cache_entry_index), 1, 6);
-	if (!ext3_xattr_cache) {
-		err = -ENOMEM;
-		goto out3;
-	}
+	if (!ext3_xattr_cache)
+		return -ENOMEM;
 	return 0;
-out3:
-#ifdef CONFIG_EXT3_FS_POSIX_ACL
-	exit_ext3_acl();
-out2:
-#endif
-#ifdef CONFIG_EXT3_FS_SECURITY
-	ext3_xattr_unregister(EXT3_XATTR_INDEX_SECURITY,
-			      &ext3_xattr_security_handler);
-out1:
-#endif
-	ext3_xattr_unregister(EXT3_XATTR_INDEX_TRUSTED,
-			      &ext3_xattr_trusted_handler);
-out:
-	ext3_xattr_unregister(EXT3_XATTR_INDEX_USER,
-			      &ext3_xattr_user_handler);
-	return err;
 }
 
 void
@@ -1232,15 +1092,4 @@
 	if (ext3_xattr_cache)
 		mb_cache_destroy(ext3_xattr_cache);
 	ext3_xattr_cache = NULL;
-#ifdef CONFIG_EXT3_FS_POSIX_ACL
-	exit_ext3_acl();
-#endif
-#ifdef CONFIG_EXT3_FS_SECURITY
-	ext3_xattr_unregister(EXT3_XATTR_INDEX_SECURITY,
-			      &ext3_xattr_security_handler);
-#endif
-	ext3_xattr_unregister(EXT3_XATTR_INDEX_TRUSTED,
-			      &ext3_xattr_trusted_handler);
-	ext3_xattr_unregister(EXT3_XATTR_INDEX_USER,
-			      &ext3_xattr_user_handler);
 }
diff -Nru a/fs/ext3/xattr.h b/fs/ext3/xattr.h
--- a/fs/ext3/xattr.h	2004-12-24 13:37:29 -08:00
+++ b/fs/ext3/xattr.h	2004-12-24 13:37:29 -08:00
@@ -56,23 +56,13 @@
 
 # ifdef CONFIG_EXT3_FS_XATTR
 
-struct ext3_xattr_handler {
-	char *prefix;
-	size_t (*list)(char *list, struct inode *inode, const char *name,
-		       int name_len);
-	int (*get)(struct inode *inode, const char *name, void *buffer,
-		   size_t size);
-	int (*set)(struct inode *inode, const char *name, const void *buffer,
-		   size_t size, int flags);
-};
+extern struct xattr_handler ext3_xattr_user_handler;
+extern struct xattr_handler ext3_xattr_trusted_handler;
+extern struct xattr_handler ext3_xattr_acl_access_handler;
+extern struct xattr_handler ext3_xattr_acl_default_handler;
+extern struct xattr_handler ext3_xattr_security_handler;
 
-extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
-extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
-
-extern int ext3_setxattr(struct dentry *, const char *, const void *, size_t, int);
-extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
-extern int ext3_removexattr(struct dentry *, const char *);
 
 extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
 extern int ext3_xattr_list(struct inode *, char *, size_t);
@@ -85,11 +75,9 @@
 extern int init_ext3_xattr(void);
 extern void exit_ext3_xattr(void);
 
+extern struct xattr_handler *ext3_xattr_handlers[];
+
 # else  /* CONFIG_EXT3_FS_XATTR */
-#  define ext3_setxattr		NULL
-#  define ext3_getxattr		NULL
-#  define ext3_listxattr	NULL
-#  define ext3_removexattr	NULL
 
 static inline int
 ext3_xattr_get(struct inode *inode, int name_index, const char *name,
@@ -139,8 +127,6 @@
 {
 }
 
-# endif  /* CONFIG_EXT3_FS_XATTR */
+#define ext3_xattr_handlers	NULL
 
-extern struct ext3_xattr_handler ext3_xattr_user_handler;
-extern struct ext3_xattr_handler ext3_xattr_trusted_handler;
-extern struct ext3_xattr_handler ext3_xattr_security_handler;
+# endif  /* CONFIG_EXT3_FS_XATTR */
diff -Nru a/fs/ext3/xattr_security.c b/fs/ext3/xattr_security.c
--- a/fs/ext3/xattr_security.c	2004-12-24 13:36:49 -08:00
+++ b/fs/ext3/xattr_security.c	2004-12-24 13:36:49 -08:00
@@ -12,17 +12,19 @@
 #include "xattr.h"
 
 static size_t
-ext3_xattr_security_list(char *list, struct inode *inode,
-		    const char *name, int name_len)
+ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size,
+			 const char *name, size_t name_len)
 {
-	const int prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
+	const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
+	const size_t total_len = prefix_len + name_len + 1;
 
-	if (list) {
+
+	if (list && total_len <= list_size) {
 		memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
 		memcpy(list+prefix_len, name, name_len);
 		list[prefix_len + name_len] = '\0';
 	}
-	return prefix_len + name_len + 1;
+	return total_len;
 }
 
 static int
@@ -45,7 +47,7 @@
 			      value, size, flags);
 }
 
-struct ext3_xattr_handler ext3_xattr_security_handler = {
+struct xattr_handler ext3_xattr_security_handler = {
 	.prefix	= XATTR_SECURITY_PREFIX,
 	.list	= ext3_xattr_security_list,
 	.get	= ext3_xattr_security_get,
diff -Nru a/fs/ext3/xattr_trusted.c b/fs/ext3/xattr_trusted.c
--- a/fs/ext3/xattr_trusted.c	2004-12-24 13:37:02 -08:00
+++ b/fs/ext3/xattr_trusted.c	2004-12-24 13:37:02 -08:00
@@ -16,20 +16,21 @@
 #define XATTR_TRUSTED_PREFIX "trusted."
 
 static size_t
-ext3_xattr_trusted_list(char *list, struct inode *inode,
-			const char *name, int name_len)
+ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
+			const char *name, size_t name_len)
 {
-	const int prefix_len = sizeof(XATTR_TRUSTED_PREFIX)-1;
+	const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX)-1;
+	const size_t total_len = prefix_len + name_len + 1;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return 0;
 
-	if (list) {
+	if (list && total_len <= list_size) {
 		memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len);
 		memcpy(list+prefix_len, name, name_len);
 		list[prefix_len + name_len] = '\0';
 	}
-	return prefix_len + name_len + 1;
+	return total_len;
 }
 
 static int
@@ -56,7 +57,7 @@
 			      value, size, flags);
 }
 
-struct ext3_xattr_handler ext3_xattr_trusted_handler = {
+struct xattr_handler ext3_xattr_trusted_handler = {
 	.prefix	= XATTR_TRUSTED_PREFIX,
 	.list	= ext3_xattr_trusted_list,
 	.get	= ext3_xattr_trusted_get,
diff -Nru a/fs/ext3/xattr_user.c b/fs/ext3/xattr_user.c
--- a/fs/ext3/xattr_user.c	2004-12-24 13:36:18 -08:00
+++ b/fs/ext3/xattr_user.c	2004-12-24 13:36:18 -08:00
@@ -16,20 +16,21 @@
 #define XATTR_USER_PREFIX "user."
 
 static size_t
-ext3_xattr_user_list(char *list, struct inode *inode,
-		     const char *name, int name_len)
+ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size,
+		     const char *name, size_t name_len)
 {
-	const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
+	const size_t prefix_len = sizeof(XATTR_USER_PREFIX)-1;
+	const size_t total_len = prefix_len + name_len + 1;
 
 	if (!test_opt(inode->i_sb, XATTR_USER))
 		return 0;
 
-	if (list) {
+	if (list && total_len <= list_size) {
 		memcpy(list, XATTR_USER_PREFIX, prefix_len);
 		memcpy(list+prefix_len, name, name_len);
 		list[prefix_len + name_len] = '\0';
 	}
-	return prefix_len + name_len + 1;
+	return total_len;
 }
 
 static int
@@ -70,7 +71,7 @@
 			      value, size, flags);
 }
 
-struct ext3_xattr_handler ext3_xattr_user_handler = {
+struct xattr_handler ext3_xattr_user_handler = {
 	.prefix	= XATTR_USER_PREFIX,
 	.list	= ext3_xattr_user_list,
 	.get	= ext3_xattr_user_get,
diff -Nru a/fs/fat/cache.c b/fs/fat/cache.c
--- a/fs/fat/cache.c	2004-12-24 13:37:18 -08:00
+++ b/fs/fat/cache.c	2004-12-24 13:37:18 -08:00
@@ -12,6 +12,197 @@
 #include <linux/msdos_fs.h>
 #include <linux/buffer_head.h>
 
+/* this must be > 0. */
+#define FAT_MAX_CACHE	8
+
+struct fat_cache {
+	struct list_head cache_list;
+	int nr_contig;	/* number of contiguous clusters */
+	int fcluster;	/* cluster number in the file. */
+	int dcluster;	/* cluster number on disk. */
+};
+
+struct fat_cache_id {
+	unsigned int id;
+	int nr_contig;
+	int fcluster;
+	int dcluster;
+};
+
+static inline int fat_max_cache(struct inode *inode)
+{
+	return FAT_MAX_CACHE;
+}
+
+static kmem_cache_t *fat_cache_cachep;
+
+static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+{
+	struct fat_cache *cache = (struct fat_cache *)foo;
+
+	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+	    SLAB_CTOR_CONSTRUCTOR)
+		INIT_LIST_HEAD(&cache->cache_list);
+}
+
+int __init fat_cache_init(void)
+{
+	fat_cache_cachep = kmem_cache_create("fat_cache",
+				sizeof(struct fat_cache),
+				0, SLAB_RECLAIM_ACCOUNT,
+				init_once, NULL);
+	if (fat_cache_cachep == NULL)
+		return -ENOMEM;
+	return 0;
+}
+
+void __exit fat_cache_destroy(void)
+{
+	if (kmem_cache_destroy(fat_cache_cachep))
+		printk(KERN_INFO "fat_cache: not all structures were freed\n");
+}
+
+static inline struct fat_cache *fat_cache_alloc(struct inode *inode)
+{
+	return kmem_cache_alloc(fat_cache_cachep, SLAB_KERNEL);
+}
+
+static inline void fat_cache_free(struct fat_cache *cache)
+{
+	BUG_ON(!list_empty(&cache->cache_list));
+	kmem_cache_free(fat_cache_cachep, cache);
+}
+
+static inline void fat_cache_update_lru(struct inode *inode,
+					struct fat_cache *cache)
+{
+	if (MSDOS_I(inode)->cache_lru.next != &cache->cache_list)
+		list_move(&cache->cache_list, &MSDOS_I(inode)->cache_lru);
+}
+
+static int fat_cache_lookup(struct inode *inode, int fclus,
+			    struct fat_cache_id *cid,
+			    int *cached_fclus, int *cached_dclus)
+{
+	static struct fat_cache nohit = { .fcluster = 0, };
+
+	struct fat_cache *hit = &nohit, *p;
+	int offset = -1;
+
+	spin_lock(&MSDOS_I(inode)->cache_lru_lock);
+	list_for_each_entry(p, &MSDOS_I(inode)->cache_lru, cache_list) {
+		/* Find the cache of "fclus" or nearest cache. */
+		if (p->fcluster <= fclus && hit->fcluster < p->fcluster) {
+			hit = p;
+			if ((hit->fcluster + hit->nr_contig) < fclus) {
+				offset = hit->nr_contig;
+			} else {
+				offset = fclus - hit->fcluster;
+				break;
+			}
+		}
+	}
+	if (hit != &nohit) {
+		fat_cache_update_lru(inode, hit);
+
+		cid->id = MSDOS_I(inode)->cache_valid_id;
+		cid->nr_contig = hit->nr_contig;
+		cid->fcluster = hit->fcluster;
+		cid->dcluster = hit->dcluster;
+		*cached_fclus = cid->fcluster + offset;
+		*cached_dclus = cid->dcluster + offset;
+	}
+	spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
+
+	return offset;
+}
+
+static struct fat_cache *fat_cache_merge(struct inode *inode,
+					 struct fat_cache_id *new)
+{
+	struct fat_cache *p;
+
+	list_for_each_entry(p, &MSDOS_I(inode)->cache_lru, cache_list) {
+		/* Find the same part as "new" in cluster-chain. */
+		if (p->fcluster == new->fcluster) {
+			BUG_ON(p->dcluster != new->dcluster);
+			if (new->nr_contig > p->nr_contig)
+				p->nr_contig = new->nr_contig;
+			return p;
+		}
+	}
+	return NULL;
+}
+
+static void fat_cache_add(struct inode *inode, struct fat_cache_id *new)
+{
+	struct fat_cache *cache, *tmp;
+
+	if (new->fcluster == -1) /* dummy cache */
+		return;
+
+	spin_lock(&MSDOS_I(inode)->cache_lru_lock);
+	if (new->id != FAT_CACHE_VALID &&
+	    new->id != MSDOS_I(inode)->cache_valid_id)
+		goto out;	/* this cache was invalidated */
+
+	cache = fat_cache_merge(inode, new);
+	if (cache == NULL) {
+		if (MSDOS_I(inode)->nr_caches < fat_max_cache(inode)) {
+			MSDOS_I(inode)->nr_caches++;
+			spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
+
+			tmp = fat_cache_alloc(inode);
+			spin_lock(&MSDOS_I(inode)->cache_lru_lock);
+			cache = fat_cache_merge(inode, new);
+			if (cache != NULL) {
+				MSDOS_I(inode)->nr_caches--;
+				fat_cache_free(tmp);
+				goto out_update_lru;
+			}
+			cache = tmp;
+		} else {
+			struct list_head *p = MSDOS_I(inode)->cache_lru.prev;
+			cache = list_entry(p, struct fat_cache, cache_list);
+		}
+		cache->fcluster = new->fcluster;
+		cache->dcluster = new->dcluster;
+		cache->nr_contig = new->nr_contig;
+	}
+out_update_lru:
+	fat_cache_update_lru(inode, cache);
+out:
+	spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
+}
+
+/*
+ * Cache invalidation occurs rarely, thus the LRU chain is not updated. It
+ * fixes itself after a while.
+ */
+static void __fat_cache_inval_inode(struct inode *inode)
+{
+	struct msdos_inode_info *i = MSDOS_I(inode);
+	struct fat_cache *cache;
+
+	while (!list_empty(&i->cache_lru)) {
+		cache = list_entry(i->cache_lru.next, struct fat_cache, cache_list);
+		list_del_init(&cache->cache_list);
+		i->nr_caches--;
+		fat_cache_free(cache);
+	}
+	/* Update. The copy of caches before this id is discarded. */
+	i->cache_valid_id++;
+	if (i->cache_valid_id == FAT_CACHE_VALID)
+		i->cache_valid_id++;
+}
+
+void fat_cache_inval_inode(struct inode *inode)
+{
+	spin_lock(&MSDOS_I(inode)->cache_lru_lock);
+	__fat_cache_inval_inode(inode);
+	spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
+}
+
 int __fat_access(struct super_block *sb, int nr, int new_value)
 {
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
@@ -45,13 +236,13 @@
 	}
 	if (sbi->fat_bits == 32) {
 		p_first = p_last = NULL; /* GCC needs that stuff */
-		next = CF_LE_L(((__le32 *) bh->b_data)[(first &
+		next = le32_to_cpu(((__le32 *) bh->b_data)[(first &
 		    (sb->s_blocksize - 1)) >> 2]);
 		/* Fscking Microsoft marketing department. Their "32" is 28. */
 		next &= 0x0fffffff;
 	} else if (sbi->fat_bits == 16) {
 		p_first = p_last = NULL; /* GCC needs that stuff */
-		next = CF_LE_W(((__le16 *) bh->b_data)[(first &
+		next = le16_to_cpu(((__le16 *) bh->b_data)[(first &
 		    (sb->s_blocksize - 1)) >> 1]);
 	} else {
 		p_first = &((__u8 *)bh->b_data)[first & (sb->s_blocksize - 1)];
@@ -64,10 +255,10 @@
 	if (new_value != -1) {
 		if (sbi->fat_bits == 32) {
 			((__le32 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 2]
-				= CT_LE_L(new_value);
+				= cpu_to_le32(new_value);
 		} else if (sbi->fat_bits == 16) {
 			((__le16 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 1]
-				= CT_LE_W(new_value);
+				= cpu_to_le16(new_value);
 		} else {
 			if (nr & 1) {
 				*p_first = (*p_first & 0xf) | (new_value << 4);
@@ -130,170 +321,25 @@
 	return next;
 }
 
-void fat_cache_init(struct super_block *sb)
-{
-	struct msdos_sb_info *sbi = MSDOS_SB(sb);
-	int count;
-
-	spin_lock_init(&sbi->cache_lock);
-
-	for (count = 0; count < FAT_CACHE_NR - 1; count++) {
-		sbi->cache_array[count].start_cluster = 0;
-		sbi->cache_array[count].next = &sbi->cache_array[count + 1];
-	}
-	sbi->cache_array[count].start_cluster = 0;
-	sbi->cache_array[count].next = NULL;
-	sbi->cache = sbi->cache_array;
-}
-
-static void
-fat_cache_lookup(struct inode *inode, int cluster, int *f_clu, int *d_clu)
+static inline int cache_contiguous(struct fat_cache_id *cid, int dclus)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
-	struct fat_cache *walk;
-	int first;
-
-	BUG_ON(cluster == 0);
-	
-	first = MSDOS_I(inode)->i_start;
-	if (!first)
-		return;
-
-	spin_lock(&sbi->cache_lock);
-
-	if (MSDOS_I(inode)->disk_cluster &&
-	    MSDOS_I(inode)->file_cluster <= cluster) {
-		*d_clu = MSDOS_I(inode)->disk_cluster;
-		*f_clu = MSDOS_I(inode)->file_cluster;
-	}
-
-	for (walk = sbi->cache; walk; walk = walk->next) {
-		if (walk->start_cluster == first
-		    && walk->file_cluster <= cluster
-		    && walk->file_cluster > *f_clu) {
-			*d_clu = walk->disk_cluster;
-			*f_clu = walk->file_cluster;
-#ifdef DEBUG
-			printk("cache hit: %d (%d)\n", *f_clu, *d_clu);
-#endif
-			if (*f_clu == cluster)
-				goto out;
-		}
-	}
-#ifdef DEBUG
-	printk("cache miss\n");
-#endif
-out:
-	spin_unlock(&sbi->cache_lock);
+	cid->nr_contig++;
+	return ((cid->dcluster + cid->nr_contig) == dclus);
 }
 
-#ifdef DEBUG
-static void list_cache(struct super_block *sb)
+static inline void cache_init(struct fat_cache_id *cid, int fclus, int dclus)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(sb);
-	struct fat_cache *walk;
-
-	for (walk = sbi->cache; walk; walk = walk->next) {
-		if (walk->start_cluster)
-			printk("<%s,%d>(%d,%d) ", sb->s_id,
-			       walk->start_cluster, walk->file_cluster,
-			       walk->disk_cluster);
-		else
-			printk("-- ");
-	}
-	printk("\n");
-}
-#endif
-
-/*
- * Cache invalidation occurs rarely, thus the LRU chain is not updated. It
- * fixes itself after a while.
- */
-static void __fat_cache_inval_inode(struct inode *inode)
-{
-	struct fat_cache *walk;
-	int first = MSDOS_I(inode)->i_start;
-	MSDOS_I(inode)->file_cluster = MSDOS_I(inode)->disk_cluster = 0;
-	for (walk = MSDOS_SB(inode->i_sb)->cache; walk; walk = walk->next)
-		if (walk->start_cluster == first)
-			walk->start_cluster = 0;
-}
-
-void fat_cache_inval_inode(struct inode *inode)
-{
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
-	spin_lock(&sbi->cache_lock);
-	__fat_cache_inval_inode(inode);
-	spin_unlock(&sbi->cache_lock);
-}
-
-void fat_cache_add(struct inode *inode, int f_clu, int d_clu)
-{
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
-	struct fat_cache *walk, *last;
-	int first, prev_f_clu, prev_d_clu;
-
-	if (f_clu == 0)
-		return;
-	first = MSDOS_I(inode)->i_start;
-	if (!first)
-		return;
-
-	last = NULL;
-	spin_lock(&sbi->cache_lock);
-
-	if (MSDOS_I(inode)->file_cluster == f_clu)
-		goto out;
-	else {
-		prev_f_clu = MSDOS_I(inode)->file_cluster;
-		prev_d_clu = MSDOS_I(inode)->disk_cluster;
-		MSDOS_I(inode)->file_cluster = f_clu;
-		MSDOS_I(inode)->disk_cluster = d_clu;
-		if (prev_f_clu == 0)
-			goto out;
-		f_clu = prev_f_clu;
-		d_clu = prev_d_clu;
-	}
-	
-	for (walk = sbi->cache; walk->next; walk = (last = walk)->next) {
-		if (walk->start_cluster == first &&
-		    walk->file_cluster == f_clu) {
-			if (walk->disk_cluster != d_clu) {
-				printk(KERN_ERR "FAT: cache corruption "
-				       "(i_pos %lld)\n", MSDOS_I(inode)->i_pos);
-				__fat_cache_inval_inode(inode);
-				goto out;
-			}
-			if (last == NULL)
-				goto out;
-
-			/* update LRU */
-			last->next = walk->next;
-			walk->next = sbi->cache;
-			sbi->cache = walk;
-#ifdef DEBUG
-			list_cache();
-#endif
-			goto out;
-		}
-	}
-	walk->start_cluster = first;
-	walk->file_cluster = f_clu;
-	walk->disk_cluster = d_clu;
-	last->next = NULL;
-	walk->next = sbi->cache;
-	sbi->cache = walk;
-#ifdef DEBUG
-	list_cache();
-#endif
-out:
-	spin_unlock(&sbi->cache_lock);
+	cid->id = FAT_CACHE_VALID;
+	cid->fcluster = fclus;
+	cid->dcluster = dclus;
+	cid->nr_contig = 0;
 }
 
 int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
 {
 	struct super_block *sb = inode->i_sb;
 	const int limit = sb->s_maxbytes >> MSDOS_SB(sb)->cluster_bits;
+	struct fat_cache_id cid;
 	int nr;
 
 	BUG_ON(MSDOS_I(inode)->i_start == 0);
@@ -303,7 +349,14 @@
 	if (cluster == 0)
 		return 0;
 
-	fat_cache_lookup(inode, cluster, fclus, dclus);
+	if (fat_cache_lookup(inode, cluster, &cid, fclus, dclus) < 0) {
+		/*
+		 * dummy, always not contiguous
+		 * This is reinitialized by cache_init(), later.
+		 */
+		cache_init(&cid, -1, -1);
+	}
+
 	while (*fclus < cluster) {
 		/* prevent the infinite loop of cluster chain */
 		if (*fclus > limit) {
@@ -322,13 +375,15 @@
 				     MSDOS_I(inode)->i_pos);
 			return -EIO;
 		} else if (nr == FAT_ENT_EOF) {
-			fat_cache_add(inode, *fclus, *dclus);
+			fat_cache_add(inode, &cid);
 			return FAT_ENT_EOF;
 		}
 		(*fclus)++;
 		*dclus = nr;
+		if (!cache_contiguous(&cid, *dclus))
+			cache_init(&cid, *fclus, *dclus);
 	}
-	fat_cache_add(inode, *fclus, *dclus);
+	fat_cache_add(inode, &cid);
 	return 0;
 }
 
diff -Nru a/fs/fat/dir.c b/fs/fat/dir.c
--- a/fs/fat/dir.c	2004-12-24 13:36:17 -08:00
+++ b/fs/fat/dir.c	2004-12-24 13:36:17 -08:00
@@ -22,6 +22,10 @@
 
 #include <asm/uaccess.h>
 
+static int fat_dir_ioctl(struct inode * inode, struct file * filp,
+		  unsigned int cmd, unsigned long arg);
+static int fat_readdir(struct file *filp, void *dirent, filldir_t filldir);
+
 struct file_operations fat_dir_operations = {
 	.read		= generic_read_dir,
 	.readdir	= fat_readdir,
@@ -321,16 +325,28 @@
 	return res;
 }
 
+struct fat_ioctl_filldir_callback {
+	struct dirent __user *dirent;
+	int result;
+	/* for dir ioctl */
+	const char *longname;
+	int long_len;
+	const char *shortname;
+	int short_len;
+};
+
 static int fat_readdirx(struct inode *inode, struct file *filp, void *dirent,
-			filldir_t filldir, int shortnames, int both)
+			filldir_t filldir, int short_only, int both)
 {
 	struct super_block *sb = inode->i_sb;
 	struct buffer_head *bh;
 	struct msdos_dir_entry *de;
 	struct nls_table *nls_io = MSDOS_SB(sb)->nls_io;
 	struct nls_table *nls_disk = MSDOS_SB(sb)->nls_disk;
-	wchar_t bufuname[14];
 	unsigned char long_slots;
+	const char *fill_name;
+	int fill_len;
+	wchar_t bufuname[14];
 	wchar_t *unicode = NULL;
 	unsigned char c, work[8], bufname[56], *ptname = bufname;
 	unsigned long lpos, dummy, *furrfu = &lpos;
@@ -393,8 +409,7 @@
 		unsigned char alias_checksum;
 
 		if (!unicode) {
-			unicode = (wchar_t *)
-				__get_free_page(GFP_KERNEL);
+			unicode = (wchar_t *)__get_free_page(GFP_KERNEL);
 			if (!unicode) {
 				filp->f_pos = cpos;
 				brelse(bh);
@@ -529,26 +544,35 @@
 			 : uni16_to_x8(bufname, bufuname, uni_xlate, nls_io);
 	}
 
-	if (!long_slots||shortnames) {
-		if (both)
-			bufname[i] = '\0';
-		if (filldir(dirent, bufname, i, *furrfu, inum,
-			    (de->attr & ATTR_DIR) ? DT_DIR : DT_REG) < 0)
-			goto FillFailed;
-	} else {
-		unsigned char longname[275];
+	fill_name = bufname;
+	fill_len = i;
+	if (!short_only && long_slots) {
+		/* convert the unicode long name. 261 is maximum size
+		 * of unicode buffer. (13 * slots + nul) */
+		void *longname = unicode + 261;
+		int buf_size = PAGE_SIZE - (261 * sizeof(unicode[0]));
 		int long_len = utf8
-			? utf8_wcstombs(longname, unicode, sizeof(longname))
-			: uni16_to_x8(longname, unicode, uni_xlate,
-				      nls_io);
-		if (both) {
-			memcpy(&longname[long_len+1], bufname, i);
-			long_len += i;
-		}
-		if (filldir(dirent, longname, long_len, *furrfu, inum,
-			    (de->attr & ATTR_DIR) ? DT_DIR : DT_REG) < 0)
-			goto FillFailed;
+			? utf8_wcstombs(longname, unicode, buf_size)
+			: uni16_to_x8(longname, unicode, uni_xlate, nls_io);
+
+		if (!both) {
+			fill_name = longname;
+			fill_len = long_len;
+		} else {
+			/* hack for fat_ioctl_filldir() */
+			struct fat_ioctl_filldir_callback *p = dirent;
+
+			p->longname = longname;
+			p->long_len = long_len;
+			p->shortname = bufname;
+			p->short_len = i;
+			fill_name = NULL;
+			fill_len = 0;
+		}
 	}
+	if (filldir(dirent, fill_name, fill_len, *furrfu, inum,
+		    (de->attr & ATTR_DIR) ? DT_DIR : DT_REG) < 0)
+		goto FillFailed;
 
 RecEnd:
 	furrfu = &lpos;
@@ -559,63 +583,61 @@
 FillFailed:
 	if (bh)
 		brelse(bh);
-	if (unicode) {
-		free_page((unsigned long) unicode);
-	}
+	if (unicode)
+		free_page((unsigned long)unicode);
 out:
 	unlock_kernel();
 	return ret;
 }
 
-int fat_readdir(struct file *filp, void *dirent, filldir_t filldir)
+static int fat_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
 	struct inode *inode = filp->f_dentry->d_inode;
 	return fat_readdirx(inode, filp, dirent, filldir, 0, 0);
 }
 
-struct fat_ioctl_filldir_callback {
-	struct dirent __user *dirent;
-	int result;
-};
-
-static int fat_ioctl_filldir(void *__buf, const char * name, int name_len,
+static int fat_ioctl_filldir(void *__buf, const char *name, int name_len,
 			     loff_t offset, ino_t ino, unsigned int d_type)
 {
 	struct fat_ioctl_filldir_callback *buf = __buf;
 	struct dirent __user *d1 = buf->dirent;
 	struct dirent __user *d2 = d1 + 1;
-	int len, slen;
-	int dotdir;
 
 	if (buf->result)
 		return -EINVAL;
 	buf->result++;
 
-	if ((name_len == 1 && name[0] == '.') ||
-	    (name_len == 2 && name[0] == '.' && name[1] == '.')) {
-		dotdir = 1;
-		len = name_len;
-	} else {
-		dotdir = 0;
-		len = strlen(name);
-	}
-	if (len != name_len) {
-		slen = name_len - len;
-		if (copy_to_user(d2->d_name, name, len)		||
-		    put_user(0, d2->d_name + len)		||
-		    put_user(len, &d2->d_reclen)		||
-		    put_user(ino, &d2->d_ino)			||
-		    put_user(offset, &d2->d_off)		||
-		    copy_to_user(d1->d_name, name+len+1, slen)	||
-		    put_user(0, d1->d_name+slen)		||
-		    put_user(slen, &d1->d_reclen))
-			goto efault;
-	} else {
+	if (name != NULL) {
+		/* dirent has only short name */
+		if (name_len >= sizeof(d1->d_name))
+			name_len = sizeof(d1->d_name) - 1;
+
 		if (put_user(0, d2->d_name)			||
 		    put_user(0, &d2->d_reclen)			||
-		    copy_to_user(d1->d_name, name, len)		||
-		    put_user(0, d1->d_name+len)			||
-		    put_user(len, &d1->d_reclen))
+		    copy_to_user(d1->d_name, name, name_len)	||
+		    put_user(0, d1->d_name + name_len)		||
+		    put_user(name_len, &d1->d_reclen))
+			goto efault;
+	} else {
+		/* dirent has short and long name */
+		const char *longname = buf->longname;
+		int long_len = buf->long_len;
+		const char *shortname = buf->shortname;
+		int short_len = buf->short_len;
+
+		if (long_len >= sizeof(d1->d_name))
+			long_len = sizeof(d1->d_name) - 1;
+		if (short_len >= sizeof(d1->d_name))
+			short_len = sizeof(d1->d_name) - 1;
+
+		if (copy_to_user(d2->d_name, longname, long_len)	||
+		    put_user(0, d2->d_name + long_len)			||
+		    put_user(long_len, &d2->d_reclen)			||
+		    put_user(ino, &d2->d_ino)				||
+		    put_user(offset, &d2->d_off)			||
+		    copy_to_user(d1->d_name, shortname, short_len)	||
+		    put_user(0, d1->d_name + short_len)			||
+		    put_user(short_len, &d1->d_reclen))
 			goto efault;
 	}
 	return 0;
@@ -624,20 +646,20 @@
 	return -EFAULT;
 }
 
-int fat_dir_ioctl(struct inode * inode, struct file * filp,
+static int fat_dir_ioctl(struct inode * inode, struct file * filp,
 		  unsigned int cmd, unsigned long arg)
 {
 	struct fat_ioctl_filldir_callback buf;
 	struct dirent __user *d1;
-	int ret, shortname, both;
+	int ret, short_only, both;
 
 	switch (cmd) {
 	case VFAT_IOCTL_READDIR_SHORT:
-		shortname = 1;
-		both = 1;
+		short_only = 1;
+		both = 0;
 		break;
 	case VFAT_IOCTL_READDIR_BOTH:
-		shortname = 0;
+		short_only = 0;
 		both = 1;
 		break;
 	default:
@@ -661,7 +683,7 @@
 	ret = -ENOENT;
 	if (!IS_DEADDIR(inode)) {
 		ret = fat_readdirx(inode, filp, &buf, fat_ioctl_filldir,
-				   shortname, both);
+				   short_only, both);
 	}
 	up(&inode->i_sem);
 	if (ret >= 0)
@@ -733,10 +755,10 @@
 		de[0].adate = de[0].cdate =
 			de[1].adate = de[1].cdate = date;
 	}
-	de[0].start = CT_LE_W(MSDOS_I(dir)->i_logstart);
-	de[0].starthi = CT_LE_W(MSDOS_I(dir)->i_logstart>>16);
-	de[1].start = CT_LE_W(MSDOS_I(parent)->i_logstart);
-	de[1].starthi = CT_LE_W(MSDOS_I(parent)->i_logstart>>16);
+	de[0].start = cpu_to_le16(MSDOS_I(dir)->i_logstart);
+	de[0].starthi = cpu_to_le16(MSDOS_I(dir)->i_logstart>>16);
+	de[1].start = cpu_to_le16(MSDOS_I(parent)->i_logstart);
+	de[1].starthi = cpu_to_le16(MSDOS_I(parent)->i_logstart>>16);
 	mark_buffer_dirty(bh);
 	brelse(bh);
 	dir->i_atime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
diff -Nru a/fs/fat/fatfs_syms.c b/fs/fat/fatfs_syms.c
--- a/fs/fat/fatfs_syms.c	2004-12-24 13:36:19 -08:00
+++ b/fs/fat/fatfs_syms.c	2004-12-24 13:36:19 -08:00
@@ -12,37 +12,35 @@
 #include <linux/msdos_fs.h>
 
 EXPORT_SYMBOL(fat_new_dir);
-EXPORT_SYMBOL(fat_get_block);
-EXPORT_SYMBOL(fat_clear_inode);
 EXPORT_SYMBOL(fat_date_unix2dos);
-EXPORT_SYMBOL(fat_delete_inode);
 EXPORT_SYMBOL(fat__get_entry);
 EXPORT_SYMBOL(fat_notify_change);
-EXPORT_SYMBOL(fat_put_super);
 EXPORT_SYMBOL(fat_attach);
 EXPORT_SYMBOL(fat_detach);
 EXPORT_SYMBOL(fat_build_inode);
 EXPORT_SYMBOL(fat_fill_super);
 EXPORT_SYMBOL(fat_search_long);
-EXPORT_SYMBOL(fat_readdir);
 EXPORT_SYMBOL(fat_scan);
-EXPORT_SYMBOL(fat_statfs);
-EXPORT_SYMBOL(fat_write_inode);
-EXPORT_SYMBOL(fat_dir_ioctl);
 EXPORT_SYMBOL(fat_add_entries);
 EXPORT_SYMBOL(fat_dir_empty);
-EXPORT_SYMBOL(fat_truncate);
 
+int __init fat_cache_init(void);
+void __exit fat_cache_destroy(void);
 int __init fat_init_inodecache(void);
 void __exit fat_destroy_inodecache(void);
 static int __init init_fat_fs(void)
 {
-	fat_hash_init();
+	int ret;
+
+	ret = fat_cache_init();
+	if (ret < 0)
+		return ret;
 	return fat_init_inodecache();
 }
 
 static void __exit exit_fat_fs(void)
 {
+	fat_cache_destroy();
 	fat_destroy_inodecache();
 }
 
diff -Nru a/fs/fat/inode.c b/fs/fat/inode.c
--- a/fs/fat/inode.c	2004-12-24 13:36:48 -08:00
+++ b/fs/fat/inode.c	2004-12-24 13:36:48 -08:00
@@ -31,6 +31,9 @@
 static int fat_default_codepage = CONFIG_FAT_DEFAULT_CODEPAGE;
 static char fat_default_iocharset[] = CONFIG_FAT_DEFAULT_IOCHARSET;
 
+static int fat_statfs(struct super_block *sb, struct kstatfs *buf);
+static int fat_write_inode(struct inode *inode, int wait);
+
 /*
  * New FAT inode stuff. We do the following:
  *	a) i_ino is constant and has nothing with on-disk location.
@@ -55,18 +58,14 @@
  *			and consider negative result as cache miss.
  */
 
-#define FAT_HASH_BITS	8
-#define FAT_HASH_SIZE	(1UL << FAT_HASH_BITS)
-#define FAT_HASH_MASK	(FAT_HASH_SIZE-1)
-static struct list_head fat_inode_hashtable[FAT_HASH_SIZE];
-static spinlock_t fat_inode_lock = SPIN_LOCK_UNLOCKED;
-
-void fat_hash_init(void)
+static void fat_hash_init(struct super_block *sb)
 {
+	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	int i;
-	for(i = 0; i < FAT_HASH_SIZE; i++) {
-		INIT_LIST_HEAD(&fat_inode_hashtable[i]);
-	}
+
+	spin_lock_init(&sbi->inode_hash_lock);
+	for (i = 0; i < FAT_HASH_SIZE; i++)
+		INIT_HLIST_HEAD(&sbi->inode_hashtable[i]);
 }
 
 static inline unsigned long fat_hash(struct super_block *sb, loff_t i_pos)
@@ -78,40 +77,43 @@
 
 void fat_attach(struct inode *inode, loff_t i_pos)
 {
-	spin_lock(&fat_inode_lock);
+	struct super_block *sb = inode->i_sb;
+	struct msdos_sb_info *sbi = MSDOS_SB(sb);
+
+	spin_lock(&sbi->inode_hash_lock);
 	MSDOS_I(inode)->i_pos = i_pos;
-	list_add(&MSDOS_I(inode)->i_fat_hash,
-		fat_inode_hashtable + fat_hash(inode->i_sb, i_pos));
-	spin_unlock(&fat_inode_lock);
+	hlist_add_head(&MSDOS_I(inode)->i_fat_hash,
+			sbi->inode_hashtable + fat_hash(sb, i_pos));
+	spin_unlock(&sbi->inode_hash_lock);
 }
 
 void fat_detach(struct inode *inode)
 {
-	spin_lock(&fat_inode_lock);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	spin_lock(&sbi->inode_hash_lock);
 	MSDOS_I(inode)->i_pos = 0;
-	list_del_init(&MSDOS_I(inode)->i_fat_hash);
-	spin_unlock(&fat_inode_lock);
+	hlist_del_init(&MSDOS_I(inode)->i_fat_hash);
+	spin_unlock(&sbi->inode_hash_lock);
 }
 
 struct inode *fat_iget(struct super_block *sb, loff_t i_pos)
 {
-	struct list_head *p = fat_inode_hashtable + fat_hash(sb, i_pos);
-	struct list_head *walk;
+	struct msdos_sb_info *sbi = MSDOS_SB(sb);
+	struct hlist_head *head = sbi->inode_hashtable + fat_hash(sb, i_pos);
+	struct hlist_node *_p;
 	struct msdos_inode_info *i;
 	struct inode *inode = NULL;
 
-	spin_lock(&fat_inode_lock);
-	list_for_each(walk, p) {
-		i = list_entry(walk, struct msdos_inode_info, i_fat_hash);
-		if (i->vfs_inode.i_sb != sb)
-			continue;
+	spin_lock(&sbi->inode_hash_lock);
+	hlist_for_each_entry(i, _p, head, i_fat_hash) {
+		BUG_ON(i->vfs_inode.i_sb != sb);
 		if (i->i_pos != i_pos)
 			continue;
 		inode = igrab(&i->vfs_inode);
 		if (inode)
 			break;
 	}
-	spin_unlock(&fat_inode_lock);
+	spin_unlock(&sbi->inode_hash_lock);
 	return inode;
 }
 
@@ -143,7 +145,7 @@
 	return inode;
 }
 
-void fat_delete_inode(struct inode *inode)
+static void fat_delete_inode(struct inode *inode)
 {
 	if (!is_bad_inode(inode)) {
 		inode->i_size = 0;
@@ -152,19 +154,21 @@
 	clear_inode(inode);
 }
 
-void fat_clear_inode(struct inode *inode)
+static void fat_clear_inode(struct inode *inode)
 {
+	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+
 	if (is_bad_inode(inode))
 		return;
 	lock_kernel();
-	spin_lock(&fat_inode_lock);
+	spin_lock(&sbi->inode_hash_lock);
 	fat_cache_inval_inode(inode);
-	list_del_init(&MSDOS_I(inode)->i_fat_hash);
-	spin_unlock(&fat_inode_lock);
+	hlist_del_init(&MSDOS_I(inode)->i_fat_hash);
+	spin_unlock(&sbi->inode_hash_lock);
 	unlock_kernel();
 }
 
-void fat_put_super(struct super_block *sb)
+static void fat_put_super(struct super_block *sb)
 {
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 
@@ -532,7 +536,6 @@
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	int error;
 
-	MSDOS_I(inode)->file_cluster = MSDOS_I(inode)->disk_cluster = 0;
 	MSDOS_I(inode)->i_pos = 0;
 	inode->i_uid = sbi->options.fs_uid;
 	inode->i_gid = sbi->options.fs_gid;
@@ -735,7 +738,11 @@
 
 	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
 	    SLAB_CTOR_CONSTRUCTOR) {
-		INIT_LIST_HEAD(&ei->i_fat_hash);
+		spin_lock_init(&ei->cache_lru_lock);
+		ei->nr_caches = 0;
+		ei->cache_valid_id = FAT_CACHE_VALID + 1;
+		INIT_LIST_HEAD(&ei->cache_lru);
+		INIT_HLIST_NODE(&ei->i_fat_hash);
 		inode_init_once(&ei->vfs_inode);
 	}
 }
@@ -797,7 +804,7 @@
 	struct msdos_sb_info *sbi;
 	u16 logical_sector_size;
 	u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors;
-	int debug, first;
+	int debug;
 	unsigned int media;
 	long error;
 	char buf[50];
@@ -818,8 +825,8 @@
 	if (error)
 		goto out_fail;
 
-	fat_cache_init(sb);
 	/* set up enough so that it can read an inode */
+	fat_hash_init(sb);
 	init_MUTEX(&sbi->fat_lock);
 
 	error = -EIO;
@@ -857,7 +864,8 @@
 		brelse(bh);
 		goto out_invalid;
 	}
-	logical_sector_size = CF_LE_W(get_unaligned((__le16 *)&b->sector_size));
+	logical_sector_size =
+		le16_to_cpu(get_unaligned((__le16 *)&b->sector_size));
 	if (!logical_sector_size
 	    || (logical_sector_size & (logical_sector_size - 1))
 	    || (logical_sector_size < 512)
@@ -906,8 +914,8 @@
 	sbi->cluster_bits = ffs(sbi->cluster_size) - 1;
 	sbi->fats = b->fats;
 	sbi->fat_bits = 0;		/* Don't know yet */
-	sbi->fat_start = CF_LE_W(b->reserved);
-	sbi->fat_length = CF_LE_W(b->fat_length);
+	sbi->fat_start = le16_to_cpu(b->reserved);
+	sbi->fat_length = le16_to_cpu(b->fat_length);
 	sbi->root_cluster = 0;
 	sbi->free_clusters = -1;	/* Don't know yet */
 	sbi->prev_free = -1;
@@ -918,13 +926,13 @@
 
 		/* Must be FAT32 */
 		sbi->fat_bits = 32;
-		sbi->fat_length = CF_LE_L(b->fat32_length);
-		sbi->root_cluster = CF_LE_L(b->root_cluster);
+		sbi->fat_length = le32_to_cpu(b->fat32_length);
+		sbi->root_cluster = le32_to_cpu(b->root_cluster);
 
 		sb->s_maxbytes = 0xffffffff;
 		
 		/* MC - if info_sector is 0, don't multiply by 0 */
-		sbi->fsinfo_sector = CF_LE_W(b->info_sector);
+		sbi->fsinfo_sector = le16_to_cpu(b->info_sector);
 		if (sbi->fsinfo_sector == 0)
 			sbi->fsinfo_sector = 1;
 
@@ -942,12 +950,12 @@
 			       "FAT: Did not find valid FSINFO signature.\n"
 			       "     Found signature1 0x%08x signature2 0x%08x"
 			       " (sector = %lu)\n",
-			       CF_LE_L(fsinfo->signature1),
-			       CF_LE_L(fsinfo->signature2),
+			       le32_to_cpu(fsinfo->signature1),
+			       le32_to_cpu(fsinfo->signature2),
 			       sbi->fsinfo_sector);
 		} else {
-			sbi->free_clusters = CF_LE_L(fsinfo->free_clusters);
-			sbi->prev_free = CF_LE_L(fsinfo->next_cluster);
+			sbi->free_clusters = le32_to_cpu(fsinfo->free_clusters);
+			sbi->prev_free = le32_to_cpu(fsinfo->next_cluster);
 		}
 
 		brelse(fsinfo_bh);
@@ -957,7 +965,8 @@
 	sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1;
 
 	sbi->dir_start = sbi->fat_start + sbi->fats * sbi->fat_length;
-	sbi->dir_entries = CF_LE_W(get_unaligned((__le16 *)&b->dir_entries));
+	sbi->dir_entries =
+		le16_to_cpu(get_unaligned((__le16 *)&b->dir_entries));
 	if (sbi->dir_entries & (sbi->dir_per_block - 1)) {
 		if (!silent)
 			printk(KERN_ERR "FAT: bogus directroy-entries per block"
@@ -969,9 +978,9 @@
 	rootdir_sectors = sbi->dir_entries
 		* sizeof(struct msdos_dir_entry) / sb->s_blocksize;
 	sbi->data_start = sbi->dir_start + rootdir_sectors;
-	total_sectors = CF_LE_W(get_unaligned((__le16 *)&b->sectors));
+	total_sectors = le16_to_cpu(get_unaligned((__le16 *)&b->sectors));
 	if (total_sectors == 0)
-		total_sectors = CF_LE_L(b->total_sect);
+		total_sectors = le32_to_cpu(b->total_sect);
 
 	total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus;
 
@@ -990,30 +999,19 @@
 	}
 
 	sbi->clusters = total_clusters;
+	/* check the free_clusters, it's not necessarily correct */
+	if (sbi->free_clusters != -1 && sbi->free_clusters > sbi->clusters)
+		sbi->free_clusters = -1;
 
 	brelse(bh);
 
-	/* validity check of FAT */
-	first = __fat_access(sb, 0, -1);
-	if (first < 0) {
-		error = first;
-		goto out_fail;
-	}
-	if (FAT_FIRST_ENT(sb, media) == first) {
-		/* all is as it should be */
-	} else if (media == 0xf8 && FAT_FIRST_ENT(sb, 0xfe) == first) {
-		/* bad, reported on pc9800 */
-	} else if (media == 0xf0 && FAT_FIRST_ENT(sb, 0xf8) == first) {
-		/* bad, reported with a MO disk on win95/me */
-	} else if (first == 0) {
-		/* bad, reported with a SmartMedia card */
-	} else {
-		if (!silent)
-			printk(KERN_ERR "FAT: invalid first entry of FAT "
-			       "(0x%x != 0x%x)\n",
-			       FAT_FIRST_ENT(sb, media), first);
-		goto out_invalid;
-	}
+	/*
+	 * The low byte of FAT's first entry must have same value with
+	 * media-field.  But in real world, too many devices is
+	 * writing wrong value.  So, removed that validity check.
+	 *
+	 * if (FAT_FIRST_ENT(sb, media) != first)
+	 */
 
 	error = -EINVAL;
 	sprintf(buf, "cp%d", sbi->options.codepage);
@@ -1072,7 +1070,7 @@
 	return error;
 }
 
-int fat_statfs(struct super_block *sb, struct kstatfs *buf)
+static int fat_statfs(struct super_block *sb, struct kstatfs *buf)
 {
 	int free, nr, ret;
        
@@ -1163,7 +1161,6 @@
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	int error;
 
-	MSDOS_I(inode)->file_cluster = MSDOS_I(inode)->disk_cluster = 0;
 	MSDOS_I(inode)->i_pos = 0;
 	inode->i_uid = sbi->options.fs_uid;
 	inode->i_gid = sbi->options.fs_gid;
@@ -1177,9 +1174,9 @@
 		inode->i_op = sbi->dir_ops;
 		inode->i_fop = &fat_dir_operations;
 
-		MSDOS_I(inode)->i_start = CF_LE_W(de->start);
+		MSDOS_I(inode)->i_start = le16_to_cpu(de->start);
 		if (sbi->fat_bits == 32)
-			MSDOS_I(inode)->i_start |= (CF_LE_W(de->starthi) << 16);
+			MSDOS_I(inode)->i_start |= (le16_to_cpu(de->starthi) << 16);
 
 		MSDOS_I(inode)->i_logstart = MSDOS_I(inode)->i_start;
 		error = fat_calc_dir_size(inode);
@@ -1195,12 +1192,12 @@
 		       !is_exec(de->ext))
 		    	? S_IRUGO|S_IWUGO : S_IRWXUGO)
 		    & ~sbi->options.fs_fmask) | S_IFREG;
-		MSDOS_I(inode)->i_start = CF_LE_W(de->start);
+		MSDOS_I(inode)->i_start = le16_to_cpu(de->start);
 		if (sbi->fat_bits == 32)
-			MSDOS_I(inode)->i_start |= (CF_LE_W(de->starthi) << 16);
+			MSDOS_I(inode)->i_start |= (le16_to_cpu(de->starthi) << 16);
 
 		MSDOS_I(inode)->i_logstart = MSDOS_I(inode)->i_start;
-		inode->i_size = CF_LE_L(de->size);
+		inode->i_size = le32_to_cpu(de->size);
 	        inode->i_op = &fat_file_inode_operations;
 	        inode->i_fop = &fat_file_operations;
 		inode->i_mapping->a_ops = &fat_aops;
@@ -1215,11 +1212,11 @@
 	inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
 			   & ~((loff_t)sbi->cluster_size - 1)) >> 9;
 	inode->i_mtime.tv_sec = inode->i_atime.tv_sec =
-		date_dos2unix(CF_LE_W(de->time),CF_LE_W(de->date));
+		date_dos2unix(le16_to_cpu(de->time), le16_to_cpu(de->date));
 	inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = 0;
 	inode->i_ctime.tv_sec =
 		MSDOS_SB(sb)->options.isvfat
-		? date_dos2unix(CF_LE_W(de->ctime),CF_LE_W(de->cdate))
+		? date_dos2unix(le16_to_cpu(de->ctime), le16_to_cpu(de->cdate))
 		: inode->i_mtime.tv_sec;
 	inode->i_ctime.tv_nsec = de->ctime_ms * 1000000;
 	MSDOS_I(inode)->i_ctime_ms = de->ctime_ms;
@@ -1227,9 +1224,10 @@
 	return 0;
 }
 
-int fat_write_inode(struct inode *inode, int wait)
+static int fat_write_inode(struct inode *inode, int wait)
 {
 	struct super_block *sb = inode->i_sb;
+	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	struct buffer_head *bh;
 	struct msdos_dir_entry *raw_entry;
 	loff_t i_pos;
@@ -1240,40 +1238,40 @@
 		return 0;
 	}
 	lock_kernel();
-	if (!(bh = sb_bread(sb, i_pos >> MSDOS_SB(sb)->dir_per_block_bits))) {
+	if (!(bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits))) {
 		printk(KERN_ERR "FAT: unable to read inode block "
 		       "for updating (i_pos %lld)\n", i_pos);
 		unlock_kernel();
 		return -EIO;
 	}
-	spin_lock(&fat_inode_lock);
+	spin_lock(&sbi->inode_hash_lock);
 	if (i_pos != MSDOS_I(inode)->i_pos) {
-		spin_unlock(&fat_inode_lock);
+		spin_unlock(&sbi->inode_hash_lock);
 		brelse(bh);
 		unlock_kernel();
 		goto retry;
 	}
 
 	raw_entry = &((struct msdos_dir_entry *) (bh->b_data))
-	    [i_pos & (MSDOS_SB(sb)->dir_per_block - 1)];
+	    [i_pos & (sbi->dir_per_block - 1)];
 	if (S_ISDIR(inode->i_mode)) {
 		raw_entry->attr = ATTR_DIR;
 		raw_entry->size = 0;
 	}
 	else {
 		raw_entry->attr = ATTR_NONE;
-		raw_entry->size = CT_LE_L(inode->i_size);
+		raw_entry->size = cpu_to_le32(inode->i_size);
 	}
 	raw_entry->attr |= MSDOS_MKATTR(inode->i_mode) |
 	    MSDOS_I(inode)->i_attrs;
-	raw_entry->start = CT_LE_W(MSDOS_I(inode)->i_logstart);
-	raw_entry->starthi = CT_LE_W(MSDOS_I(inode)->i_logstart >> 16);
+	raw_entry->start = cpu_to_le16(MSDOS_I(inode)->i_logstart);
+	raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16);
 	fat_date_unix2dos(inode->i_mtime.tv_sec, &raw_entry->time, &raw_entry->date);
-	if (MSDOS_SB(sb)->options.isvfat) {
+	if (sbi->options.isvfat) {
 		fat_date_unix2dos(inode->i_ctime.tv_sec,&raw_entry->ctime,&raw_entry->cdate);
 		raw_entry->ctime_ms = MSDOS_I(inode)->i_ctime_ms; /* use i_ctime.tv_nsec? */
 	}
-	spin_unlock(&fat_inode_lock);
+	spin_unlock(&sbi->inode_hash_lock);
 	mark_buffer_dirty(bh);
 	brelse(bh);
 	unlock_kernel();
diff -Nru a/fs/fat/misc.c b/fs/fat/misc.c
--- a/fs/fat/misc.c	2004-12-24 13:37:18 -08:00
+++ b/fs/fat/misc.c	2004-12-24 13:37:18 -08:00
@@ -69,7 +69,8 @@
 		printk(KERN_ERR "FAT: Did not find valid FSINFO signature.\n"
 		       "     Found signature1 0x%08x signature2 0x%08x"
 		       " (sector = %lu)\n",
-		       CF_LE_L(fsinfo->signature1), CF_LE_L(fsinfo->signature2),
+		       le32_to_cpu(fsinfo->signature1),
+		       le32_to_cpu(fsinfo->signature2),
 		       sbi->fsinfo_sector);
 	} else {
 		if (sbi->free_clusters != -1)
@@ -155,7 +156,7 @@
 		ret = fat_access(sb, last, new_dclus);
 		if (ret < 0)
 			return ret;
-		fat_cache_add(inode, new_fclus, new_dclus);
+//		fat_cache_add(inode, new_fclus, new_dclus);
 	} else {
 		MSDOS_I(inode)->i_start = new_dclus;
 		MSDOS_I(inode)->i_logstart = new_dclus;
diff -Nru a/fs/fcntl.c b/fs/fcntl.c
--- a/fs/fcntl.c	2004-12-24 13:37:01 -08:00
+++ b/fs/fcntl.c	2004-12-24 13:37:01 -08:00
@@ -4,6 +4,7 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
+#include <linux/syscalls.h>
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
@@ -86,7 +87,7 @@
 	int error;
 
 	error = -EINVAL;
-	if (orig_start >= current->rlim[RLIMIT_NOFILE].rlim_cur)
+	if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
 		goto out;
 
 repeat:
@@ -105,7 +106,7 @@
 	}
 	
 	error = -EMFILE;
-	if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
+	if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
 		goto out;
 
 	error = expand_files(files, newfd);
@@ -161,7 +162,7 @@
 	if (newfd == oldfd)
 		goto out_unlock;
 	err = -EBADF;
-	if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
+	if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
 		goto out_unlock;
 	get_file(file);			/* We are now finished with oldfd */
 
@@ -290,8 +291,6 @@
 	f_modown(filp, 0, 0, 0, 1);
 }
 
-EXPORT_SYMBOL(f_delown);
-
 static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
 		struct file *filp)
 {
@@ -362,7 +361,7 @@
 	return err;
 }
 
-asmlinkage long sys_fcntl(int fd, unsigned int cmd, unsigned long arg)
+asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {	
 	struct file *filp;
 	long err = -EBADF;
@@ -432,11 +431,12 @@
 };
 
 static inline int sigio_perm(struct task_struct *p,
-                             struct fown_struct *fown)
+                             struct fown_struct *fown, int sig)
 {
-	return ((fown->euid == 0) ||
- 	        (fown->euid == p->suid) || (fown->euid == p->uid) ||
- 	        (fown->uid == p->suid) || (fown->uid == p->uid));
+	return (((fown->euid == 0) ||
+		 (fown->euid == p->suid) || (fown->euid == p->uid) ||
+		 (fown->uid == p->suid) || (fown->uid == p->uid)) &&
+		!security_file_send_sigiotask(p, fown, sig));
 }
 
 static void send_sigio_to_task(struct task_struct *p,
@@ -444,10 +444,7 @@
 			       int fd,
 			       int reason)
 {
-	if (!sigio_perm(p, fown))
-		return;
-
-	if (security_file_send_sigiotask(p, fown, fd, reason))
+	if (!sigio_perm(p, fown, fown->signum))
 		return;
 
 	switch (fown->signum) {
@@ -509,7 +506,7 @@
 static void send_sigurg_to_task(struct task_struct *p,
                                 struct fown_struct *fown)
 {
-	if (sigio_perm(p, fown))
+	if (sigio_perm(p, fown, SIGURG))
 		send_group_sig_info(SIGURG, SEND_SIG_PRIV, p);
 }
 
diff -Nru a/fs/file.c b/fs/file.c
--- a/fs/file.c	2004-12-24 13:36:18 -08:00
+++ b/fs/file.c	2004-12-24 13:36:18 -08:00
@@ -12,8 +12,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/file.h>
-
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 
 /*
@@ -55,6 +54,8 @@
  */
 
 int expand_fd_array(struct files_struct *files, int nr)
+	__releases(files->file_lock)
+	__acquires(files->file_lock)
 {
 	struct file **new_fds;
 	int error, nfds;
@@ -158,6 +159,8 @@
  * held for write.
  */
 int expand_fdset(struct files_struct *files, int nr)
+	__releases(file->file_lock)
+	__acquires(file->file_lock)
 {
 	fd_set *new_openset = NULL, *new_execset = NULL;
 	int error, nfds = 0;
diff -Nru a/fs/file_table.c b/fs/file_table.c
--- a/fs/file_table.c	2004-12-24 13:36:17 -08:00
+++ b/fs/file_table.c	2004-12-24 13:36:17 -08:00
@@ -24,11 +24,9 @@
 
 EXPORT_SYMBOL(files_stat); /* Needed by unix.o */
 
-/* public *and* exported. Not pretty! */
+/* public. Not pretty! */
 spinlock_t __cacheline_aligned_in_smp files_lock = SPIN_LOCK_UNLOCKED;
 
-EXPORT_SYMBOL(files_lock);
-
 static spinlock_t filp_count_lock = SPIN_LOCK_UNLOCKED;
 
 /* slab constructors and destructors are called from arbitrary
@@ -198,8 +196,6 @@
 		file_free(file);
 	}
 }
-
-EXPORT_SYMBOL(put_filp);
 
 void file_move(struct file *file, struct list_head *list)
 {
diff -Nru a/fs/filesystems.c b/fs/filesystems.c
--- a/fs/filesystems.c	2004-12-24 13:37:18 -08:00
+++ b/fs/filesystems.c	2004-12-24 13:37:18 -08:00
@@ -6,6 +6,7 @@
  *  table of configured filesystems
  */
 
+#include <linux/syscalls.h>
 #include <linux/fs.h>
 #include <linux/slab.h>
 #include <linux/kmod.h>
diff -Nru a/fs/fs-writeback.c b/fs/fs-writeback.c
--- a/fs/fs-writeback.c	2004-12-24 13:37:33 -08:00
+++ b/fs/fs-writeback.c	2004-12-24 13:37:33 -08:00
@@ -244,6 +244,8 @@
 __writeback_single_inode(struct inode *inode,
 			struct writeback_control *wbc)
 {
+	wait_queue_head_t *wqh;
+
 	if ((wbc->sync_mode != WB_SYNC_ALL) && (inode->i_state & I_LOCK)) {
 		list_move(&inode->i_list, &inode->i_sb->s_dirty);
 		return 0;
@@ -252,12 +254,18 @@
 	/*
 	 * It's a data-integrity sync.  We must wait.
 	 */
-	while (inode->i_state & I_LOCK) {
-		__iget(inode);
-		spin_unlock(&inode_lock);
-		__wait_on_inode(inode);
-		iput(inode);
-		spin_lock(&inode_lock);
+	if (inode->i_state & I_LOCK) {
+		DEFINE_WAIT_BIT(wq, &inode->i_state, __I_LOCK);
+
+		wqh = bit_waitqueue(&inode->i_state, __I_LOCK);
+		do {
+			__iget(inode);
+			spin_unlock(&inode_lock);
+			__wait_on_bit(wqh, &wq, inode_wait,
+							TASK_UNINTERRUPTIBLE);
+			iput(inode);
+			spin_lock(&inode_lock);
+		} while (inode->i_state & I_LOCK);
 	}
 	return __sync_single_inode(inode, wbc);
 }
diff -Nru a/fs/hfs/Makefile b/fs/hfs/Makefile
--- a/fs/hfs/Makefile	2004-12-24 13:37:44 -08:00
+++ b/fs/hfs/Makefile	2004-12-24 13:37:44 -08:00
@@ -5,6 +5,6 @@
 obj-$(CONFIG_HFS_FS) += hfs.o
 
 hfs-objs := bitmap.o bfind.o bnode.o brec.o btree.o \
-	    catalog.o dir.o extent.o inode.o mdb.o \
+	    catalog.o dir.o extent.o inode.o attr.o mdb.o \
             part_tbl.o string.o super.o sysdep.o trans.o
 
diff -Nru a/fs/hfs/attr.c b/fs/hfs/attr.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/fs/hfs/attr.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,121 @@
+/*
+ *  linux/fs/hfs/attr.c
+ *
+ * (C) 2003 Ardis Technologies <roman@ardistech.com>
+ *
+ * Export hfs data via xattr
+ */
+
+
+#include <linux/fs.h>
+#include <linux/xattr.h>
+
+#include "hfs_fs.h"
+#include "btree.h"
+
+int hfs_setxattr(struct dentry *dentry, const char *name,
+		 const void *value, size_t size, int flags)
+{
+	struct inode *inode = dentry->d_inode;
+	struct hfs_find_data fd;
+	hfs_cat_rec rec;
+	struct hfs_cat_file *file;
+	int res;
+
+	if (!S_ISREG(inode->i_mode) || HFS_IS_RSRC(inode))
+		return -EOPNOTSUPP;
+
+	res = hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd);
+	if (res)
+		return res;
+	fd.search_key->cat = HFS_I(inode)->cat_key;
+	res = hfs_brec_find(&fd);
+	if (res)
+		goto out;
+	hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
+			sizeof(struct hfs_cat_file));
+	file = &rec.file;
+
+	if (!strcmp(name, "hfs.type")) {
+		if (size == 4)
+			memcpy(&file->UsrWds.fdType, value, 4);
+		else
+			res = -ERANGE;
+	} else if (!strcmp(name, "hfs.creator")) {
+		if (size == 4)
+			memcpy(&file->UsrWds.fdCreator, value, 4);
+		else
+			res = -ERANGE;
+	} else
+		res = -EOPNOTSUPP;
+	if (!res)
+		hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
+				sizeof(struct hfs_cat_file));
+out:
+	hfs_find_exit(&fd);
+	return res;
+}
+
+ssize_t hfs_getxattr(struct dentry *dentry, const char *name,
+			 void *value, size_t size)
+{
+	struct inode *inode = dentry->d_inode;
+	struct hfs_find_data fd;
+	hfs_cat_rec rec;
+	struct hfs_cat_file *file;
+	ssize_t res = 0;
+
+	if (!S_ISREG(inode->i_mode) || HFS_IS_RSRC(inode))
+		return -EOPNOTSUPP;
+
+	if (size) {
+		res = hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd);
+		if (res)
+			return res;
+		fd.search_key->cat = HFS_I(inode)->cat_key;
+		res = hfs_brec_find(&fd);
+		if (res)
+			goto out;
+		hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
+				sizeof(struct hfs_cat_file));
+	}
+	file = &rec.file;
+
+	if (!strcmp(name, "hfs.type")) {
+		if (size >= 4) {
+			memcpy(value, &file->UsrWds.fdType, 4);
+			res = 4;
+		} else
+			res = size ? -ERANGE : 4;
+	} else if (!strcmp(name, "hfs.creator")) {
+		if (size >= 4) {
+			memcpy(value, &file->UsrWds.fdCreator, 4);
+			res = 4;
+		} else
+			res = size ? -ERANGE : 4;
+	} else
+		res = -ENODATA;
+out:
+	if (size)
+		hfs_find_exit(&fd);
+	return res;
+}
+
+#define HFS_ATTRLIST_SIZE (sizeof("hfs.creator")+sizeof("hfs.type"))
+
+ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
+{
+	struct inode *inode = dentry->d_inode;
+
+	if (!S_ISREG(inode->i_mode) || HFS_IS_RSRC(inode))
+		return -EOPNOTSUPP;
+
+	if (!buffer || !size)
+		return HFS_ATTRLIST_SIZE;
+	if (size < HFS_ATTRLIST_SIZE)
+		return -ERANGE;
+	strcpy(buffer, "hfs.type");
+	strcpy(buffer + sizeof("hfs.type"), "hfs.creator");
+
+	return HFS_ATTRLIST_SIZE;
+}
diff -Nru a/fs/hfs/btree.c b/fs/hfs/btree.c
--- a/fs/hfs/btree.c	2004-12-24 13:36:47 -08:00
+++ b/fs/hfs/btree.c	2004-12-24 13:36:47 -08:00
@@ -201,10 +201,12 @@
 		res = hfs_extend_file(inode);
 		if (res)
 			return ERR_PTR(res);
-		inode->i_blocks = HFS_I(inode)->alloc_blocks *
-				  HFS_SB(tree->sb)->fs_div;
 		HFS_I(inode)->phys_size = inode->i_size =
-			(loff_t)inode->i_blocks << tree->sb->s_blocksize_bits;
+				(loff_t)HFS_I(inode)->alloc_blocks *
+				HFS_SB(tree->sb)->alloc_blksz;
+		HFS_I(inode)->fs_blocks = inode->i_size >>
+					  tree->sb->s_blocksize_bits;
+		inode_set_bytes(inode, inode->i_size);
 		count = inode->i_size >> tree->node_size_shift;
 		tree->free_nodes = count - tree->node_count;
 		tree->node_count = count;
diff -Nru a/fs/hfs/dir.c b/fs/hfs/dir.c
--- a/fs/hfs/dir.c	2004-12-24 13:37:18 -08:00
+++ b/fs/hfs/dir.c	2004-12-24 13:37:18 -08:00
@@ -306,6 +306,9 @@
 	res = hfs_cat_move(old_dentry->d_inode->i_ino,
 			   old_dir, &old_dentry->d_name,
 			   new_dir, &new_dentry->d_name);
+	if (!res)
+		hfs_cat_build_key((btree_key *)&HFS_I(old_dentry->d_inode)->cat_key,
+				  new_dir->i_ino, &new_dentry->d_name);
 	return res;
 }
 
diff -Nru a/fs/hfs/extent.c b/fs/hfs/extent.c
--- a/fs/hfs/extent.c	2004-12-24 13:36:55 -08:00
+++ b/fs/hfs/extent.c	2004-12-24 13:36:55 -08:00
@@ -328,8 +328,8 @@
 	/* Convert inode block to disk allocation block */
 	ablock = (u32)block / HFS_SB(sb)->fs_div;
 
-	if (block >= inode->i_blocks) {
-		if (block > inode->i_blocks || !create)
+	if (block >= HFS_I(inode)->fs_blocks) {
+		if (block > HFS_I(inode)->fs_blocks || !create)
 			return -EIO;
 		if (ablock >= HFS_I(inode)->alloc_blocks) {
 			res = hfs_extend_file(inode);
@@ -363,7 +363,8 @@
 	if (create) {
 		set_buffer_new(bh_result);
 		HFS_I(inode)->phys_size += sb->s_blocksize;
-		inode->i_blocks++;
+		HFS_I(inode)->fs_blocks++;
+		inode_add_bytes(inode, sb->s_blocksize);
 		mark_inode_dirty(inode);
 	}
 	return 0;
@@ -521,6 +522,7 @@
 	HFS_I(inode)->alloc_blocks = blk_cnt;
 out:
 	HFS_I(inode)->phys_size = inode->i_size;
+	HFS_I(inode)->fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
+	inode_set_bytes(inode, HFS_I(inode)->fs_blocks << sb->s_blocksize_bits);
 	mark_inode_dirty(inode);
-	inode->i_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
 }
diff -Nru a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
--- a/fs/hfs/hfs_fs.h	2004-12-24 13:37:02 -08:00
+++ b/fs/hfs/hfs_fs.h	2004-12-24 13:37:02 -08:00
@@ -60,6 +60,7 @@
 	struct semaphore extents_lock;
 
 	u16 alloc_blocks, clump_blocks;
+	sector_t fs_blocks;
 	/* Allocation extents from catlog record or volume header */
 	hfs_extent_rec first_extents;
 	u16 first_blocks;
@@ -205,6 +206,13 @@
 extern struct inode *hfs_iget(struct super_block *, struct hfs_cat_key *, hfs_cat_rec *);
 extern void hfs_clear_inode(struct inode *);
 extern void hfs_delete_inode(struct inode *);
+
+/* attr.c */
+extern int hfs_setxattr(struct dentry *dentry, const char *name,
+			const void *value, size_t size, int flags);
+extern ssize_t hfs_getxattr(struct dentry *dentry, const char *name,
+			    void *value, size_t size);
+extern ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 
 /* mdb.c */
 extern int hfs_mdb_get(struct super_block *);
diff -Nru a/fs/hfs/inode.c b/fs/hfs/inode.c
--- a/fs/hfs/inode.c	2004-12-24 13:37:31 -08:00
+++ b/fs/hfs/inode.c	2004-12-24 13:37:31 -08:00
@@ -170,8 +170,10 @@
 	inode->i_gid = current->fsgid;
 	inode->i_nlink = 1;
 	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
+	inode->i_blksize = HFS_SB(sb)->alloc_blksz;
 	HFS_I(inode)->flags = 0;
 	HFS_I(inode)->rsrc_inode = NULL;
+	HFS_I(inode)->fs_blocks = 0;
 	if (S_ISDIR(inode->i_mode)) {
 		inode->i_size = 2;
 		HFS_SB(sb)->folder_count++;
@@ -243,7 +245,8 @@
 	HFS_I(inode)->first_blocks = count;
 
 	inode->i_size = HFS_I(inode)->phys_size = log_size;
-	inode->i_blocks = (log_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
+	HFS_I(inode)->fs_blocks = (log_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
+	inode_set_bytes(inode, HFS_I(inode)->fs_blocks << sb->s_blocksize_bits);
 	HFS_I(inode)->alloc_blocks = be32_to_cpu(phys_size) /
 				     HFS_SB(sb)->alloc_blksz;
 	HFS_I(inode)->clump_blocks = clump_size / HFS_SB(sb)->alloc_blksz;
@@ -291,6 +294,7 @@
 	inode->i_uid = hsb->s_uid;
 	inode->i_gid = hsb->s_gid;
 	inode->i_nlink = 1;
+	inode->i_blksize = HFS_SB(inode->i_sb)->alloc_blksz;
 
 	if (idata->key)
 		HFS_I(inode)->cat_key = *idata->key;
@@ -320,15 +324,14 @@
 		inode->i_op = &hfs_file_inode_operations;
 		inode->i_fop = &hfs_file_operations;
 		inode->i_mapping->a_ops = &hfs_aops;
-		HFS_I(inode)->phys_size = inode->i_size;
 		break;
 	case HFS_CDR_DIR:
 		inode->i_ino = be32_to_cpu(rec->dir.DirID);
-		inode->i_blocks = 0;
 		inode->i_size = be16_to_cpu(rec->dir.Val) + 2;
+		HFS_I(inode)->fs_blocks = 0;
 		inode->i_mode = S_IFDIR | (S_IRWXUGO & hsb->s_dir_umask);
 		inode->i_ctime = inode->i_atime = inode->i_mtime =
-				hfs_m_to_utime(rec->file.MdDat);
+				hfs_m_to_utime(rec->dir.MdDat);
 		inode->i_op = &hfs_dir_inode_operations;
 		inode->i_fop = &hfs_dir_operations;
 		break;
@@ -383,6 +386,7 @@
 
 int hfs_write_inode(struct inode *inode, int unused)
 {
+	struct inode *main_inode = inode;
 	struct hfs_find_data fd;
 	hfs_cat_rec rec;
 
@@ -405,24 +409,22 @@
 		}
 	}
 
-	if (HFS_IS_RSRC(inode)) {
-		mark_inode_dirty(HFS_I(inode)->rsrc_inode);
-		return 0;
-	}
+	if (HFS_IS_RSRC(inode))
+		main_inode = HFS_I(inode)->rsrc_inode;
 
-	if (!inode->i_nlink)
+	if (!main_inode->i_nlink)
 		return 0;
 
-	if (hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd))
+	if (hfs_find_init(HFS_SB(main_inode->i_sb)->cat_tree, &fd))
 		/* panic? */
 		return -EIO;
 
-	fd.search_key->cat = HFS_I(inode)->cat_key;
+	fd.search_key->cat = HFS_I(main_inode)->cat_key;
 	if (hfs_brec_find(&fd))
 		/* panic? */
 		goto out;
 
-	if (S_ISDIR(inode->i_mode)) {
+	if (S_ISDIR(main_inode->i_mode)) {
 		if (fd.entrylength < sizeof(struct hfs_cat_dir))
 			/* panic? */;
 		hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
@@ -436,6 +438,13 @@
 
 		hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
 			    sizeof(struct hfs_cat_dir));
+	} else if (HFS_IS_RSRC(inode)) {
+		hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
+			       sizeof(struct hfs_cat_file));
+		hfs_inode_write_fork(inode, rec.file.RExtRec,
+				     &rec.file.RLgLen, &rec.file.RPyLen);
+		hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
+				sizeof(struct hfs_cat_file));
 	} else {
 		if (fd.entrylength < sizeof(struct hfs_cat_file))
 			/* panic? */;
@@ -450,9 +459,6 @@
 		else
 			rec.file.Flags |= HFS_FIL_LOCK;
 		hfs_inode_write_fork(inode, rec.file.ExtRec, &rec.file.LgLen, &rec.file.PyLen);
-		if (HFS_I(inode)->rsrc_inode)
-			hfs_inode_write_fork(HFS_I(inode)->rsrc_inode, rec.file.RExtRec,
-					     &rec.file.RLgLen, &rec.file.RPyLen);
 		rec.file.MdDat = hfs_u_to_mtime(inode->i_mtime);
 
 		hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
@@ -517,7 +523,7 @@
 {
 	if (S_ISREG(inode->i_mode) && mask & MAY_EXEC)
 		return 0;
-	return vfs_permission(inode, mask);
+	return generic_permission(inode, mask, NULL);
 }
 
 static int hfs_file_open(struct inode *inode, struct file *file)
@@ -621,4 +627,7 @@
 	.truncate	= hfs_file_truncate,
 	.setattr	= hfs_inode_setattr,
 	.permission	= hfs_permission,
+	.setxattr	= hfs_setxattr,
+	.getxattr	= hfs_getxattr,
+	.listxattr	= hfs_listxattr,
 };
diff -Nru a/fs/hfs/mdb.c b/fs/hfs/mdb.c
--- a/fs/hfs/mdb.c	2004-12-24 13:36:47 -08:00
+++ b/fs/hfs/mdb.c	2004-12-24 13:36:47 -08:00
@@ -200,8 +200,7 @@
 	}
 
 	attrib = mdb->drAtrb;
-	if (!(attrib & cpu_to_be16(HFS_SB_ATTRIB_UNMNT))
-	    || (attrib & cpu_to_be16(HFS_SB_ATTRIB_INCNSTNT))) {
+	if (!(attrib & cpu_to_be16(HFS_SB_ATTRIB_UNMNT))) {
 		hfs_warn("HFS-fs warning: Filesystem was not cleanly unmounted, "
 			 "running fsck.hfs is recommended.  mounting read-only.\n");
 		sb->s_flags |= MS_RDONLY;
@@ -212,8 +211,9 @@
 	}
 	if (!(sb->s_flags & MS_RDONLY)) {
 		/* Mark the volume uncleanly unmounted in case we crash */
-		mdb->drAtrb = attrib & cpu_to_be16(~HFS_SB_ATTRIB_UNMNT);
-		mdb->drAtrb = attrib | cpu_to_be16(HFS_SB_ATTRIB_INCNSTNT);
+		attrib &= cpu_to_be16(~HFS_SB_ATTRIB_UNMNT);
+		attrib |= cpu_to_be16(HFS_SB_ATTRIB_INCNSTNT);
+		mdb->drAtrb = attrib;
 		mdb->drWrCnt = cpu_to_be32(be32_to_cpu(mdb->drWrCnt) + 1);
 		mdb->drLsMod = hfs_mtime();
 
diff -Nru a/fs/hfs/super.c b/fs/hfs/super.c
--- a/fs/hfs/super.c	2004-12-24 13:36:47 -08:00
+++ b/fs/hfs/super.c	2004-12-24 13:36:47 -08:00
@@ -98,8 +98,7 @@
 	if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
 		return 0;
 	if (!(*flags & MS_RDONLY)) {
-		if (!(HFS_SB(sb)->mdb->drAtrb & cpu_to_be16(HFS_SB_ATTRIB_UNMNT))
-		    || (HFS_SB(sb)->mdb->drAtrb & cpu_to_be16(HFS_SB_ATTRIB_INCNSTNT))) {
+		if (!(HFS_SB(sb)->mdb->drAtrb & cpu_to_be16(HFS_SB_ATTRIB_UNMNT))) {
 			printk("HFS-fs warning: Filesystem was not cleanly unmounted, "
 			       "running fsck.hfs is recommended.  leaving read-only.\n");
 			sb->s_flags |= MS_RDONLY;
diff -Nru a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
--- a/fs/hfsplus/btree.c	2004-12-24 13:36:31 -08:00
+++ b/fs/hfsplus/btree.c	2004-12-24 13:36:31 -08:00
@@ -187,10 +187,12 @@
 		res = hfsplus_file_extend(inode);
 		if (res)
 			return ERR_PTR(res);
-		inode->i_blocks = HFSPLUS_I(inode).alloc_blocks <<
-				  HFSPLUS_SB(tree->sb).fs_shift;
 		HFSPLUS_I(inode).phys_size = inode->i_size =
-			(loff_t)inode->i_blocks << tree->sb->s_blocksize_bits;
+				(loff_t)HFSPLUS_I(inode).alloc_blocks <<
+				HFSPLUS_SB(tree->sb).alloc_blksz_shift;
+		HFSPLUS_I(inode).fs_blocks = HFSPLUS_I(inode).alloc_blocks <<
+					     HFSPLUS_SB(tree->sb).fs_shift;
+		inode_set_bytes(inode, inode->i_size);
 		count = inode->i_size >> tree->node_size_shift;
 		tree->free_nodes = count - tree->node_count;
 		tree->node_count = count;
diff -Nru a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
--- a/fs/hfsplus/extents.c	2004-12-24 13:36:17 -08:00
+++ b/fs/hfsplus/extents.c	2004-12-24 13:36:17 -08:00
@@ -183,8 +183,8 @@
 	shift = HFSPLUS_SB(sb).alloc_blksz_shift - sb->s_blocksize_bits;
 	ablock = iblock >> HFSPLUS_SB(sb).fs_shift;
 
-	if (iblock >= inode->i_blocks) {
-		if (iblock > inode->i_blocks || !create)
+	if (iblock >= HFSPLUS_I(inode).fs_blocks) {
+		if (iblock > HFSPLUS_I(inode).fs_blocks || !create)
 			return -EIO;
 		if (ablock >= HFSPLUS_I(inode).alloc_blocks) {
 			res = hfsplus_file_extend(inode);
@@ -217,7 +217,8 @@
 	if (create) {
 		set_buffer_new(bh_result);
 		HFSPLUS_I(inode).phys_size += sb->s_blocksize;
-		inode->i_blocks++;
+		HFSPLUS_I(inode).fs_blocks++;
+		inode_add_bytes(inode, sb->s_blocksize);
 		mark_inode_dirty(inode);
 	}
 	return 0;
@@ -497,6 +498,7 @@
 	HFSPLUS_I(inode).alloc_blocks = blk_cnt;
 out:
 	HFSPLUS_I(inode).phys_size = inode->i_size;
+	HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
+	inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits);
 	mark_inode_dirty(inode);
-	inode->i_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
 }
diff -Nru a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
--- a/fs/hfsplus/hfsplus_fs.h	2004-12-24 13:37:18 -08:00
+++ b/fs/hfsplus/hfsplus_fs.h	2004-12-24 13:37:18 -08:00
@@ -155,6 +155,7 @@
 struct hfsplus_inode_info {
 	struct semaphore extents_lock;
 	u32 clump_blocks, alloc_blocks;
+	sector_t fs_blocks;
 	/* Allocation extents from catalog record or volume header */
 	hfsplus_extent_rec first_extents;
 	u32 first_blocks;
@@ -340,6 +341,11 @@
 /* ioctl.c */
 int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
 		  unsigned long arg);
+int hfsplus_setxattr(struct dentry *dentry, const char *name,
+		     const void *value, size_t size, int flags);
+ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
+			 void *value, size_t size);
+ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size);
 
 /* options.c */
 int parse_options(char *, struct hfsplus_sb_info *);
diff -Nru a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
--- a/fs/hfsplus/inode.c	2004-12-24 13:36:31 -08:00
+++ b/fs/hfsplus/inode.c	2004-12-24 13:36:31 -08:00
@@ -260,7 +260,7 @@
 	 */
 	if (S_ISREG(inode->i_mode) && mask & MAY_EXEC && !(inode->i_mode & 0111))
 		return 0;
-	return vfs_permission(inode, mask);
+	return generic_permission(inode, mask, NULL);
 }
 
 
@@ -301,6 +301,9 @@
 	.lookup		= hfsplus_file_lookup,
 	.truncate	= hfsplus_file_truncate,
 	.permission	= hfsplus_permission,
+	.setxattr	= hfsplus_setxattr,
+	.getxattr	= hfsplus_getxattr,
+	.listxattr	= hfsplus_listxattr,
 };
 
 struct file_operations hfsplus_file_operations = {
@@ -332,6 +335,7 @@
 	inode->i_gid = current->fsgid;
 	inode->i_nlink = 1;
 	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
+	inode->i_blksize = HFSPLUS_SB(sb).alloc_blksz;
 	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
 	init_MUTEX(&HFSPLUS_I(inode).extents_lock);
 	atomic_set(&HFSPLUS_I(inode).opencnt, 0);
@@ -343,6 +347,7 @@
 	HFSPLUS_I(inode).cached_start = 0;
 	HFSPLUS_I(inode).cached_blocks = 0;
 	HFSPLUS_I(inode).phys_size = 0;
+	HFSPLUS_I(inode).fs_blocks = 0;
 	HFSPLUS_I(inode).rsrc_inode = NULL;
 	if (S_ISDIR(inode->i_mode)) {
 		inode->i_size = 2;
@@ -408,7 +413,8 @@
 
 	HFSPLUS_I(inode).alloc_blocks = be32_to_cpu(fork->total_blocks);
 	inode->i_size = HFSPLUS_I(inode).phys_size = be64_to_cpu(fork->total_size);
-	inode->i_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
+	HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
+	inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits);
 	HFSPLUS_I(inode).clump_blocks = be32_to_cpu(fork->clump_size) >> HFSPLUS_SB(sb).alloc_blksz_shift;
 	if (!HFSPLUS_I(inode).clump_blocks)
 		HFSPLUS_I(inode).clump_blocks = HFSPLUS_IS_RSRC(inode) ? HFSPLUS_SB(sb).rsrc_clump_blocks :
@@ -432,7 +438,7 @@
 	type = hfs_bnode_read_u16(fd->bnode, fd->entryoffset);
 
 	HFSPLUS_I(inode).dev = 0;
-	inode->i_blksize = PAGE_SIZE; /* Doesn't seem to be useful... */
+	inode->i_blksize = HFSPLUS_SB(inode->i_sb).alloc_blksz;
 	if (type == HFSPLUS_FOLDER) {
 		struct hfsplus_cat_folder *folder = &entry.folder;
 
@@ -446,7 +452,7 @@
 		inode->i_atime = hfsp_mt2ut(folder->access_date);
 		inode->i_mtime = hfsp_mt2ut(folder->content_mod_date);
 		inode->i_ctime = inode->i_mtime;
-		inode->i_blocks = 0;
+		HFSPLUS_I(inode).fs_blocks = 0;
 		inode->i_op = &hfsplus_dir_inode_operations;
 		inode->i_fop = &hfsplus_dir_operations;
 	} else if (type == HFSPLUS_FILE) {
@@ -486,26 +492,25 @@
 
 int hfsplus_cat_write_inode(struct inode *inode)
 {
+	struct inode *main_inode = inode;
 	struct hfs_find_data fd;
 	hfsplus_cat_entry entry;
 
-	if (HFSPLUS_IS_RSRC(inode)) {
-		mark_inode_dirty(HFSPLUS_I(inode).rsrc_inode);
-		return 0;
-	}
+	if (HFSPLUS_IS_RSRC(inode))
+		main_inode = HFSPLUS_I(inode).rsrc_inode;
 
-	if (!inode->i_nlink)
+	if (!main_inode->i_nlink)
 		return 0;
 
-	if (hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd))
+	if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb).cat_tree, &fd))
 		/* panic? */
 		return -EIO;
 
-	if (hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd))
+	if (hfsplus_find_cat(main_inode->i_sb, main_inode->i_ino, &fd))
 		/* panic? */
 		goto out;
 
-	if (S_ISDIR(inode->i_mode)) {
+	if (S_ISDIR(main_inode->i_mode)) {
 		struct hfsplus_cat_folder *folder = &entry.folder;
 
 		if (fd.entrylength < sizeof(struct hfsplus_cat_folder))
@@ -520,6 +525,13 @@
 		folder->valence = cpu_to_be32(inode->i_size - 2);
 		hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
 					 sizeof(struct hfsplus_cat_folder));
+	} else if (HFSPLUS_IS_RSRC(inode)) {
+		struct hfsplus_cat_file *file = &entry.file;
+		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
+			       sizeof(struct hfsplus_cat_file));
+		hfsplus_inode_write_fork(inode, &file->rsrc_fork);
+		hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
+				sizeof(struct hfsplus_cat_file));
 	} else {
 		struct hfsplus_cat_file *file = &entry.file;
 
@@ -528,8 +540,6 @@
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
 					sizeof(struct hfsplus_cat_file));
 		hfsplus_inode_write_fork(inode, &file->data_fork);
-		if (HFSPLUS_I(inode).rsrc_inode)
-			hfsplus_inode_write_fork(HFSPLUS_I(inode).rsrc_inode, &file->rsrc_fork);
 		if (S_ISREG(inode->i_mode))
 			HFSPLUS_I(inode).dev = inode->i_nlink;
 		if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
diff -Nru a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
--- a/fs/hfsplus/ioctl.c	2004-12-24 13:36:31 -08:00
+++ b/fs/hfsplus/ioctl.c	2004-12-24 13:36:31 -08:00
@@ -14,6 +14,7 @@
 
 #include <linux/fs.h>
 #include <linux/sched.h>
+#include <linux/xattr.h>
 #include <asm/uaccess.h>
 #include "hfsplus_fs.h"
 
@@ -79,4 +80,109 @@
 	default:
 		return -ENOTTY;
 	}
+}
+
+int hfsplus_setxattr(struct dentry *dentry, const char *name,
+		     const void *value, size_t size, int flags)
+{
+	struct inode *inode = dentry->d_inode;
+	struct hfs_find_data fd;
+	hfsplus_cat_entry entry;
+	struct hfsplus_cat_file *file;
+	int res;
+
+	if (!S_ISREG(inode->i_mode) || HFSPLUS_IS_RSRC(inode))
+		return -EOPNOTSUPP;
+
+	res = hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd);
+	if (res)
+		return res;
+	res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
+	if (res)
+		goto out;
+	hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
+			sizeof(struct hfsplus_cat_file));
+	file = &entry.file;
+
+	if (!strcmp(name, "hfs.type")) {
+		if (size == 4)
+			memcpy(&file->user_info.fdType, value, 4);
+		else
+			res = -ERANGE;
+	} else if (!strcmp(name, "hfs.creator")) {
+		if (size == 4)
+			memcpy(&file->user_info.fdCreator, value, 4);
+		else
+			res = -ERANGE;
+	} else
+		res = -EOPNOTSUPP;
+	if (!res)
+		hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
+				sizeof(struct hfsplus_cat_file));
+out:
+	hfs_find_exit(&fd);
+	return res;
+}
+
+ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
+			 void *value, size_t size)
+{
+	struct inode *inode = dentry->d_inode;
+	struct hfs_find_data fd;
+	hfsplus_cat_entry entry;
+	struct hfsplus_cat_file *file;
+	ssize_t res = 0;
+
+	if (!S_ISREG(inode->i_mode) || HFSPLUS_IS_RSRC(inode))
+		return -EOPNOTSUPP;
+
+	if (size) {
+		res = hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd);
+		if (res)
+			return res;
+		res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
+		if (res)
+			goto out;
+		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
+				sizeof(struct hfsplus_cat_file));
+	}
+	file = &entry.file;
+
+	if (!strcmp(name, "hfs.type")) {
+		if (size >= 4) {
+			memcpy(value, &file->user_info.fdType, 4);
+			res = 4;
+		} else
+			res = size ? -ERANGE : 4;
+	} else if (!strcmp(name, "hfs.creator")) {
+		if (size >= 4) {
+			memcpy(value, &file->user_info.fdCreator, 4);
+			res = 4;
+		} else
+			res = size ? -ERANGE : 4;
+	} else
+		res = -ENODATA;
+out:
+	if (size)
+		hfs_find_exit(&fd);
+	return res;
+}
+
+#define HFSPLUS_ATTRLIST_SIZE (sizeof("hfs.creator")+sizeof("hfs.type"))
+
+ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
+{
+	struct inode *inode = dentry->d_inode;
+
+	if (!S_ISREG(inode->i_mode) || HFSPLUS_IS_RSRC(inode))
+		return -EOPNOTSUPP;
+
+	if (!buffer || !size)
+		return HFSPLUS_ATTRLIST_SIZE;
+	if (size < HFSPLUS_ATTRLIST_SIZE)
+		return -ERANGE;
+	strcpy(buffer, "hfs.type");
+	strcpy(buffer + sizeof("hfs.type"), "hfs.creator");
+
+	return HFSPLUS_ATTRLIST_SIZE;
 }
diff -Nru a/fs/hfsplus/super.c b/fs/hfsplus/super.c
--- a/fs/hfsplus/super.c	2004-12-24 13:36:30 -08:00
+++ b/fs/hfsplus/super.c	2004-12-24 13:36:30 -08:00
@@ -246,8 +246,7 @@
 	if (!(*flags & MS_RDONLY)) {
 		struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
 
-		if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_INCNSTNT)) ||
-		    !(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
+		if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
 			printk("HFS+-fs warning: Filesystem was not cleanly unmounted, "
 			       "running fsck.hfsplus is recommended.  leaving read-only.\n");
 			sb->s_flags |= MS_RDONLY;
@@ -332,8 +331,7 @@
 	sb->s_op = &hfsplus_sops;
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
 
-	if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_INCNSTNT)) ||
-	    !(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
+	if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
 		if (!silent)
 			printk("HFS+-fs warning: Filesystem was not cleanly unmounted, "
 			       "running fsck.hfsplus is recommended.  mounting read-only.\n");
diff -Nru a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
--- a/fs/hostfs/hostfs_kern.c	2004-12-24 13:36:19 -08:00
+++ b/fs/hostfs/hostfs_kern.c	2004-12-24 13:36:19 -08:00
@@ -808,7 +808,7 @@
 	if(name == NULL) return(-ENOMEM);
 	err = access_file(name, r, w, x);
 	kfree(name);
-	if(!err) err = vfs_permission(ino, desired);
+	if(!err) err = generic_permission(ino, desired, NULL);
 	return(err);
 }
 
diff -Nru a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
--- a/fs/hugetlbfs/inode.c	2004-12-24 13:37:19 -08:00
+++ b/fs/hugetlbfs/inode.c	2004-12-24 13:37:19 -08:00
@@ -105,6 +105,7 @@
 {
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma;
+	unsigned long start_addr;
 
 	if (len & ~HPAGE_MASK)
 		return -EINVAL;
@@ -119,12 +120,25 @@
 			return addr;
 	}
 
-	addr = ALIGN(mm->free_area_cache, HPAGE_SIZE);
+	start_addr = mm->free_area_cache;
+
+full_search:
+	addr = ALIGN(start_addr, HPAGE_SIZE);
 
 	for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
 		/* At this point:  (!vma || addr < vma->vm_end). */
-		if (TASK_SIZE - len < addr)
+		if (TASK_SIZE - len < addr) {
+			/*
+			 * Start a new search - just in case we missed
+			 * some holes.
+			 */
+			if (start_addr != TASK_UNMAPPED_BASE) {
+				start_addr = TASK_UNMAPPED_BASE;
+				goto full_search;
+			}
 			return -ENOMEM;
+		}
+
 		if (!vma || addr + len <= vma->vm_start)
 			return addr;
 		addr = ALIGN(vma->vm_end, HPAGE_SIZE);
diff -Nru a/fs/inode.c b/fs/inode.c
--- a/fs/inode.c	2004-12-24 13:37:30 -08:00
+++ b/fs/inode.c	2004-12-24 13:37:30 -08:00
@@ -1264,37 +1264,10 @@
 
 #endif
 
-/*
- * Hashed waitqueues for wait_on_inode().  The table is pretty small - the
- * kernel doesn't lock many inodes at the same time.
- */
-#define I_WAIT_TABLE_ORDER	3
-static struct i_wait_queue_head {
-	wait_queue_head_t wqh;
-} ____cacheline_aligned_in_smp i_wait_queue_heads[1<<I_WAIT_TABLE_ORDER];
-
-/*
- * Return the address of the waitqueue_head to be used for this inode
- */
-static wait_queue_head_t *i_waitq_head(struct inode *inode)
+int inode_wait(void *word)
 {
-	return &i_wait_queue_heads[hash_ptr(inode, I_WAIT_TABLE_ORDER)].wqh;
-}
-
-void __wait_on_inode(struct inode *inode)
-{
-	DECLARE_WAITQUEUE(wait, current);
-	wait_queue_head_t *wq = i_waitq_head(inode);
-
-	add_wait_queue(wq, &wait);
-repeat:
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	if (inode->i_state & I_LOCK) {
-		schedule();
-		goto repeat;
-	}
-	remove_wait_queue(wq, &wait);
-	__set_current_state(TASK_RUNNING);
+	schedule();
+	return 0;
 }
 
 /*
@@ -1303,36 +1276,39 @@
  * that it isn't found.  This is because iget will immediately call
  * ->read_inode, and we want to be sure that evidence of the deletion is found
  * by ->read_inode.
- *
- * This call might return early if an inode which shares the waitq is woken up.
- * This is most easily handled by the caller which will loop around again
- * looking for the inode.
- *
  * This is called with inode_lock held.
  */
 static void __wait_on_freeing_inode(struct inode *inode)
 {
-	DECLARE_WAITQUEUE(wait, current);
-	wait_queue_head_t *wq = i_waitq_head(inode);
+	wait_queue_head_t *wq;
+	DEFINE_WAIT_BIT(wait, &inode->i_state, __I_LOCK);
 
-	add_wait_queue(wq, &wait);
-	set_current_state(TASK_UNINTERRUPTIBLE);
+	/*
+	 * I_FREEING and I_CLEAR are cleared in process context under
+	 * inode_lock, so we have to give the tasks who would clear them
+	 * a chance to run and acquire inode_lock.
+	 */
+	if (!(inode->i_state & I_LOCK)) {
+		spin_unlock(&inode_lock);
+		yield();
+		spin_lock(&inode_lock);
+		return;
+	}
+	wq = bit_waitqueue(&inode->i_state, __I_LOCK);
+	prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
 	spin_unlock(&inode_lock);
 	schedule();
-	remove_wait_queue(wq, &wait);
+	finish_wait(wq, &wait.wait);
 	spin_lock(&inode_lock);
 }
 
 void wake_up_inode(struct inode *inode)
 {
-	wait_queue_head_t *wq = i_waitq_head(inode);
-
 	/*
 	 * Prevent speculative execution through spin_unlock(&inode_lock);
 	 */
 	smp_mb();
-	if (waitqueue_active(wq))
-		wake_up_all(wq);
+	wake_up_bit(&inode->i_state, __I_LOCK);
 }
 
 static __initdata unsigned long ihash_entries;
@@ -1367,11 +1343,6 @@
 
 void __init inode_init(unsigned long mempages)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(i_wait_queue_heads); i++)
-		init_waitqueue_head(&i_wait_queue_heads[i].wqh);
-
 	/* inode slab cache */
 	inode_cachep = kmem_cache_create("inode_cache", sizeof(struct inode),
 				0, SLAB_PANIC, init_once, NULL);
diff -Nru a/fs/ioctl.c b/fs/ioctl.c
--- a/fs/ioctl.c	2004-12-24 13:36:31 -08:00
+++ b/fs/ioctl.c	2004-12-24 13:36:31 -08:00
@@ -5,6 +5,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/syscalls.h>
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/file.h>
diff -Nru a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c
--- a/fs/jbd/checkpoint.c	2004-12-24 13:37:43 -08:00
+++ b/fs/jbd/checkpoint.c	2004-12-24 13:37:43 -08:00
@@ -616,7 +616,6 @@
 	J_ASSERT(transaction->t_log_list == NULL);
 	J_ASSERT(transaction->t_checkpoint_list == NULL);
 	J_ASSERT(transaction->t_updates == 0);
-	J_ASSERT(list_empty(&transaction->t_jcb));
 	J_ASSERT(journal->j_committing_transaction != transaction);
 	J_ASSERT(journal->j_running_transaction != transaction);
 
diff -Nru a/fs/jbd/commit.c b/fs/jbd/commit.c
--- a/fs/jbd/commit.c	2004-12-24 13:37:19 -08:00
+++ b/fs/jbd/commit.c	2004-12-24 13:37:19 -08:00
@@ -579,7 +579,7 @@
 		journal_file_buffer(jh, commit_transaction, BJ_Forget);
 		/* Wake up any transactions which were waiting for this
 		   IO to complete */
-		wake_up_buffer(bh);
+		wake_up_bit(&bh->b_state, BH_Unshadow);
 		JBUFFER_TRACE(jh, "brelse shadowed buffer");
 		__brelse(bh);
 	}
@@ -685,30 +685,6 @@
 
 	if (err)
 		__journal_abort_hard(journal);
-
-	/*
-	 * Call any callbacks that had been registered for handles in this
-	 * transaction.  It is up to the callback to free any allocated
-	 * memory.
-	 *
-	 * The spinlocking (t_jcb_lock) here is surely unnecessary...
-	 */
-	spin_lock(&commit_transaction->t_jcb_lock);
-	if (!list_empty(&commit_transaction->t_jcb)) {
-		struct list_head *p, *n;
-		int error = is_journal_aborted(journal);
-
-		list_for_each_safe(p, n, &commit_transaction->t_jcb) {
-			struct journal_callback *jcb;
-
-			jcb = list_entry(p, struct journal_callback, jcb_list);
-			list_del(p);
-			spin_unlock(&commit_transaction->t_jcb_lock);
-			jcb->jcb_func(jcb, error);
-			spin_lock(&commit_transaction->t_jcb_lock);
-		}
-	}
-	spin_unlock(&commit_transaction->t_jcb_lock);
 
 	jbd_debug(3, "JBD: commit phase 7\n");
 
diff -Nru a/fs/jbd/journal.c b/fs/jbd/journal.c
--- a/fs/jbd/journal.c	2004-12-24 13:36:19 -08:00
+++ b/fs/jbd/journal.c	2004-12-24 13:36:19 -08:00
@@ -55,7 +55,6 @@
 #endif
 EXPORT_SYMBOL(journal_flush);
 EXPORT_SYMBOL(journal_revoke);
-EXPORT_SYMBOL(journal_callback_set);
 
 EXPORT_SYMBOL(journal_init_dev);
 EXPORT_SYMBOL(journal_init_inode);
@@ -79,7 +78,6 @@
 EXPORT_SYMBOL(journal_blocks_per_page);
 EXPORT_SYMBOL(journal_invalidatepage);
 EXPORT_SYMBOL(journal_try_to_free_buffers);
-EXPORT_SYMBOL(journal_bmap);
 EXPORT_SYMBOL(journal_force_commit);
 
 static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);
@@ -153,6 +151,9 @@
 	spin_lock(&journal->j_state_lock);
 
 loop:
+	if (journal->j_flags & JFS_UNMOUNT)
+		goto end_loop;
+
 	jbd_debug(1, "commit_sequence=%d, commit_request=%d\n",
 		journal->j_commit_sequence, journal->j_commit_request);
 
@@ -162,7 +163,7 @@
 		del_timer_sync(journal->j_commit_timer);
 		journal_commit_transaction(journal);
 		spin_lock(&journal->j_state_lock);
-		goto end_loop;
+		goto loop;
 	}
 
 	wake_up(&journal->j_wait_done_commit);
@@ -210,10 +211,9 @@
 		journal->j_commit_request = transaction->t_tid;
 		jbd_debug(1, "woke because of timeout\n");
 	}
-end_loop:
-	if (!(journal->j_flags & JFS_UNMOUNT))
-		goto loop;
+	goto loop;
 
+end_loop:
 	spin_unlock(&journal->j_state_lock);
 	del_timer_sync(journal->j_commit_timer);
 	journal->j_task = NULL;
diff -Nru a/fs/jbd/transaction.c b/fs/jbd/transaction.c
--- a/fs/jbd/transaction.c	2004-12-24 13:36:33 -08:00
+++ b/fs/jbd/transaction.c	2004-12-24 13:36:33 -08:00
@@ -50,9 +50,7 @@
 	transaction->t_state = T_RUNNING;
 	transaction->t_tid = journal->j_transaction_sequence++;
 	transaction->t_expires = jiffies + journal->j_commit_interval;
-	INIT_LIST_HEAD(&transaction->t_jcb);
 	spin_lock_init(&transaction->t_handle_lock);
-	spin_lock_init(&transaction->t_jcb_lock);
 
 	/* Set up the commit timer for the new transaction. */
 	journal->j_commit_timer->expires = transaction->t_expires;
@@ -243,7 +241,6 @@
 	memset(handle, 0, sizeof(*handle));
 	handle->h_buffer_credits = nblocks;
 	handle->h_ref = 1;
-	INIT_LIST_HEAD(&handle->h_jcb);
 
 	return handle;
 }
@@ -633,21 +630,22 @@
 		 * disk then we cannot do copy-out here. */
 
 		if (jh->b_jlist == BJ_Shadow) {
+			DEFINE_WAIT_BIT(wait, &bh->b_state, BH_Unshadow);
 			wait_queue_head_t *wqh;
-			DEFINE_WAIT(wait);
+
+			wqh = bit_waitqueue(&bh->b_state, BH_Unshadow);
 
 			JBUFFER_TRACE(jh, "on shadow: sleep");
 			jbd_unlock_bh_state(bh);
 			/* commit wakes up all shadow buffers after IO */
-			wqh = bh_waitq_head(bh);
 			for ( ; ; ) {
-				prepare_to_wait(wqh, &wait,
+				prepare_to_wait(wqh, &wait.wait,
 						TASK_UNINTERRUPTIBLE);
 				if (jh->b_jlist != BJ_Shadow)
 					break;
 				schedule();
 			}
-			finish_wait(wqh, &wait);
+			finish_wait(wqh, &wait.wait);
 			goto repeat;
 		}
 
@@ -1276,36 +1274,6 @@
 }
 
 /**
- * void journal_callback_set() -  Register a callback function for this handle.
- * @handle: handle to attach the callback to.
- * @func: function to callback.
- * @jcb:  structure with additional information required by func() , and
- *        some space for jbd internal information.
- * 
- * The function will be
- * called when the transaction that this handle is part of has been
- * committed to disk with the original callback data struct and the
- * error status of the journal as parameters.  There is no guarantee of
- * ordering between handles within a single transaction, nor between
- * callbacks registered on the same handle.
- *
- * The caller is responsible for allocating the journal_callback struct.
- * This is to allow the caller to add as much extra data to the callback
- * as needed, but reduce the overhead of multiple allocations.  The caller
- * allocated struct must start with a struct journal_callback at offset 0,
- * and has the caller-specific data afterwards.
- */
-void journal_callback_set(handle_t *handle,
-			void (*func)(struct journal_callback *jcb, int error),
-			struct journal_callback *jcb)
-{
-	spin_lock(&handle->h_transaction->t_jcb_lock);
-	list_add_tail(&jcb->jcb_list, &handle->h_jcb);
-	spin_unlock(&handle->h_transaction->t_jcb_lock);
-	jcb->jcb_func = func;
-}
-
-/**
  * int journal_stop() - complete a transaction
  * @handle: tranaction to complete.
  * 
@@ -1370,11 +1338,6 @@
 		if (journal->j_barrier_count)
 			wake_up(&journal->j_wait_transaction_locked);
 	}
-
-	/* Move callbacks from the handle to the transaction. */
-	spin_lock(&transaction->t_jcb_lock);
-	list_splice(&handle->h_jcb, &transaction->t_jcb);
-	spin_unlock(&transaction->t_jcb_lock);
 
 	/*
 	 * If the handle is marked SYNC, we need to set another commit
diff -Nru a/fs/jffs2/compr.c b/fs/jffs2/compr.c
--- a/fs/jffs2/compr.c	2004-12-24 13:36:33 -08:00
+++ b/fs/jffs2/compr.c	2004-12-24 13:36:33 -08:00
@@ -9,7 +9,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: compr.c,v 1.41 2004/06/24 09:51:38 havasi Exp $
+ * $Id: compr.c,v 1.42 2004/08/07 21:56:08 dwmw2 Exp $
  *
  */
 
@@ -180,6 +180,11 @@
         struct jffs2_compressor *this;
         int ret;
 
+	/* Older code had a bug where it would write non-zero 'usercompr'
+	   fields. Deal with it. */
+	if ((comprtype & 0xff) <= JFFS2_COMPR_ZLIB)
+		comprtype &= 0xff;
+
 	switch (comprtype & 0xff) {
 	case JFFS2_COMPR_NONE:
 		/* This should be special-cased elsewhere, but we might as well deal with it */
@@ -208,7 +213,7 @@
                                 return ret;
                         }
                 }
-		printk(KERN_WARNING "JFFS2 compression type 0x%02x not avaiable.\n", comprtype);
+		printk(KERN_WARNING "JFFS2 compression type 0x%02x not available.\n", comprtype);
                 spin_unlock(&jffs2_compressor_list_lock);
 		return -EIO;
 	}
diff -Nru a/fs/jffs2/dir.c b/fs/jffs2/dir.c
--- a/fs/jffs2/dir.c	2004-12-24 13:37:18 -08:00
+++ b/fs/jffs2/dir.c	2004-12-24 13:37:18 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: dir.c,v 1.82 2003/10/11 11:47:23 dwmw2 Exp $
+ * $Id: dir.c,v 1.83 2004/10/19 07:48:44 havasi Exp $
  *
  */
 
@@ -217,7 +217,6 @@
 			      dentry->d_name.name, dentry->d_name.len);
 
 	if (ret) {
-		jffs2_clear_inode(inode);
 		make_bad_inode(inode);
 		iput(inode);
 		jffs2_free_raw_inode(ri);
diff -Nru a/fs/jffs2/erase.c b/fs/jffs2/erase.c
--- a/fs/jffs2/erase.c	2004-12-24 13:36:18 -08:00
+++ b/fs/jffs2/erase.c	2004-12-24 13:36:18 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: erase.c,v 1.60 2004/06/30 17:26:15 dbrown Exp $
+ * $Id: erase.c,v 1.61 2004/10/20 23:59:49 dwmw2 Exp $
  *
  */
 
diff -Nru a/fs/jffs2/gc.c b/fs/jffs2/gc.c
--- a/fs/jffs2/gc.c	2004-12-24 13:36:31 -08:00
+++ b/fs/jffs2/gc.c	2004-12-24 13:36:31 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: gc.c,v 1.136 2004/05/27 19:06:09 gleixner Exp $
+ * $Id: gc.c,v 1.140 2004/11/13 10:59:22 dedekind Exp $
  *
  */
 
@@ -359,10 +359,14 @@
 	spin_unlock(&c->inocache_lock);
 
 	f = jffs2_gc_fetch_inode(c, inum, nlink);
-	if (IS_ERR(f))
-		return PTR_ERR(f);
-	if (!f)
-		return 0;
+	if (IS_ERR(f)) {
+		ret = PTR_ERR(f);
+		goto release_sem;
+	}
+	if (!f) {
+		ret = 0;
+		goto release_sem;
+	}
 
 	ret = jffs2_garbage_collect_live(c, jeb, raw, f);
 
@@ -624,6 +628,7 @@
 			jffs2_free_raw_node_ref(nraw);
 		}
 
+		jffs2_free_raw_node_ref(nraw);
 		if (!ret)
 			ret = -EIO;
 		goto out_node;
@@ -633,10 +638,12 @@
 
 	/* Link into per-inode list. This is safe because of the ic
 	   state being INO_STATE_GC. Note that if we're doing this
-	   for an inode which is in-code, the 'nraw' pointer is then
+	   for an inode which is in-core, the 'nraw' pointer is then
 	   going to be fetched from ic->nodes by our caller. */
+	spin_lock(&c->erase_completion_lock);
         nraw->next_in_ino = ic->nodes;
         ic->nodes = nraw;
+	spin_unlock(&c->erase_completion_lock);
 
 	jffs2_mark_node_obsolete(c, raw);
 	D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw)));
diff -Nru a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
--- a/fs/jffs2/nodelist.c	2004-12-24 13:36:56 -08:00
+++ b/fs/jffs2/nodelist.c	2004-12-24 13:36:56 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: nodelist.c,v 1.86 2003/10/31 15:37:51 dwmw2 Exp $
+ * $Id: nodelist.c,v 1.87 2004/11/14 17:07:07 dedekind Exp $
  *
  */
 
@@ -96,7 +96,7 @@
 /* Get tmp_dnode_info and full_dirent for all non-obsolete nodes associated
    with this ino, returning the former in order of version */
 
-int jffs2_get_inode_nodes(struct jffs2_sb_info *c, ino_t ino, struct jffs2_inode_info *f,
+int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
 			  struct jffs2_tmp_dnode_info **tnp, struct jffs2_full_dirent **fdp,
 			  uint32_t *highest_version, uint32_t *latest_mctime,
 			  uint32_t *mctime_ver)
@@ -104,16 +104,15 @@
 	struct jffs2_raw_node_ref *ref = f->inocache->nodes;
 	struct jffs2_tmp_dnode_info *tn, *ret_tn = NULL;
 	struct jffs2_full_dirent *fd, *ret_fd = NULL;
-
 	union jffs2_node_union node;
 	size_t retlen;
 	int err;
 
 	*mctime_ver = 0;
-
-	D1(printk(KERN_DEBUG "jffs2_get_inode_nodes(): ino #%lu\n", ino));
+	
+	D1(printk(KERN_DEBUG "jffs2_get_inode_nodes(): ino #%u\n", f->inocache->ino));
 	if (!f->inocache->nodes) {
-		printk(KERN_WARNING "Eep. no nodes for ino #%lu\n", (unsigned long)ino);
+		printk(KERN_WARNING "Eep. no nodes for ino #%u\n", f->inocache->ino);
 	}
 
 	spin_lock(&c->erase_completion_lock);
diff -Nru a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
--- a/fs/jffs2/nodelist.h	2004-12-24 13:37:43 -08:00
+++ b/fs/jffs2/nodelist.h	2004-12-24 13:37:43 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: nodelist.h,v 1.119 2004/05/26 12:28:12 gleixner Exp $
+ * $Id: nodelist.h,v 1.121 2004/11/14 17:07:07 dedekind Exp $
  *
  */
 
@@ -281,9 +281,14 @@
 			else if (!ref_obsolete(ref2)) \
 				my_used_size += ref_totlen(c, jeb, ref2); \
 			if (unlikely((!ref2->next_phys) != (ref2 == jeb->last_node))) { \
-				printk("ref for node at %p (phys %08x) has next_phys->%p (%08x), last_node->%p (phys %08x)\n", \
-				       ref2, ref_offset(ref2), ref2->next_phys, ref_offset(ref2->next_phys), \
-				       jeb->last_node, ref_offset(jeb->last_node)); \
+                                if (!ref2->next_phys) \
+				       printk("ref for node at %p (phys %08x) has next_phys->%p (----), last_node->%p (phys %08x)\n", \
+				             ref2, ref_offset(ref2), ref2->next_phys, \
+				             jeb->last_node, ref_offset(jeb->last_node)); \
+                                else \
+                                       printk("ref for node at %p (phys %08x) has next_phys->%p (%08x), last_node->%p (phys %08x)\n", \
+				             ref2, ref_offset(ref2), ref2->next_phys, ref_offset(ref2->next_phys), \
+				             jeb->last_node, ref_offset(jeb->last_node)); \
 				paranoia_failed_dump(jeb); \
 				BUG(); \
 			} \
@@ -393,7 +398,7 @@
 /* nodelist.c */
 D1(void jffs2_print_frag_list(struct jffs2_inode_info *f));
 void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list);
-int jffs2_get_inode_nodes(struct jffs2_sb_info *c, ino_t ino, struct jffs2_inode_info *f,
+int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
 			  struct jffs2_tmp_dnode_info **tnp, struct jffs2_full_dirent **fdp,
 			  uint32_t *highest_version, uint32_t *latest_mctime,
 			  uint32_t *mctime_ver);
diff -Nru a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
--- a/fs/jffs2/nodemgmt.c	2004-12-24 13:36:19 -08:00
+++ b/fs/jffs2/nodemgmt.c	2004-12-24 13:36:19 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: nodemgmt.c,v 1.107 2003/11/26 15:30:58 dwmw2 Exp $
+ * $Id: nodemgmt.c,v 1.109 2004/10/07 15:08:47 havasi Exp $
  *
  */
 
@@ -548,6 +548,59 @@
 	if (retlen != sizeof(n)) {
 		printk(KERN_WARNING "Short write in obliterating obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen);
 		return;
+	}
+
+	/* Nodes which have been marked obsolete no longer need to be
+	   associated with any inode. Remove them from the per-inode list */
+	if (ref->next_in_ino) {
+		struct jffs2_inode_cache *ic;
+		struct jffs2_raw_node_ref **p;
+
+		ic = jffs2_raw_ref_to_ic(ref);
+		for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino))
+			;
+
+		*p = ref->next_in_ino;
+		ref->next_in_ino = NULL;
+	}
+
+
+	/* Merge with the next node in the physical list, if there is one
+	   and if it's also obsolete. */
+	if (ref->next_phys && ref_obsolete(ref->next_phys) ) {
+		struct jffs2_raw_node_ref *n = ref->next_phys;
+		
+		ref->__totlen += n->__totlen;
+		ref->next_phys = n->next_phys;
+                if (jeb->last_node == n) jeb->last_node = ref;
+		if (jeb->gc_node == n) {
+			/* gc will be happy continuing gc on this node */
+			jeb->gc_node=ref;
+		}
+		BUG_ON(n->next_in_ino);
+		jffs2_free_raw_node_ref(n);
+	}
+	
+	/* Also merge with the previous node in the list, if there is one
+	   and that one is obsolete */
+	if (ref != jeb->first_node ) {
+		struct jffs2_raw_node_ref *p = jeb->first_node;
+		
+		while (p->next_phys != ref)
+			p = p->next_phys;
+		
+		if (ref_obsolete(p) ) {
+			p->__totlen += ref->__totlen;
+			if (jeb->last_node == ref) {
+				jeb->last_node = p;
+			}
+			if (jeb->gc_node == ref) {
+				/* gc will be happy continuing gc on this node */
+				jeb->gc_node=p;
+			}
+			p->next_phys = ref->next_phys;
+			jffs2_free_raw_node_ref(ref);
+		}
 	}
 }
 
diff -Nru a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
--- a/fs/jffs2/readinode.c	2004-12-24 13:36:17 -08:00
+++ b/fs/jffs2/readinode.c	2004-12-24 13:36:17 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: readinode.c,v 1.113 2003/11/03 13:20:33 dwmw2 Exp $
+ * $Id: readinode.c,v 1.114 2004/11/14 17:07:07 dedekind Exp $
  *
  */
 
@@ -510,7 +510,7 @@
 	D1(printk(KERN_DEBUG "jffs2_do_read_inode_internal(): ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink));
 
 	/* Grab all nodes relevant to this ino */
-	ret = jffs2_get_inode_nodes(c, f->inocache->ino, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver);
+	ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver);
 
 	if (ret) {
 		printk(KERN_CRIT "jffs2_get_inode_nodes() for ino %u returned %d\n", f->inocache->ino, ret);
diff -Nru a/fs/jffs2/scan.c b/fs/jffs2/scan.c
--- a/fs/jffs2/scan.c	2004-12-24 13:37:19 -08:00
+++ b/fs/jffs2/scan.c	2004-12-24 13:37:19 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: scan.c,v 1.110 2004/06/17 17:15:31 gleixner Exp $
+ * $Id: scan.c,v 1.112 2004/09/12 09:56:13 gleixner Exp $
  *
  */
 #include <linux/kernel.h>
@@ -104,6 +104,10 @@
 		else
 			buf_size = PAGE_SIZE;
 
+		/* Respect kmalloc limitations */
+		if (buf_size > 128*1024)
+			buf_size = 128*1024;
+
 		D1(printk(KERN_DEBUG "Allocating readbuf of %d bytes\n", buf_size));
 		flashbuf = kmalloc(buf_size, GFP_KERNEL);
 		if (!flashbuf)
@@ -237,7 +241,7 @@
 	}
 #endif
 	if (c->nr_erasing_blocks) {
-		if ( !c->used_size && ((empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {
+		if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { 
 			printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");
 			printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks);
 			ret = -EIO;
diff -Nru a/fs/jffs2/super.c b/fs/jffs2/super.c
--- a/fs/jffs2/super.c	2004-12-24 13:36:34 -08:00
+++ b/fs/jffs2/super.c	2004-12-24 13:36:34 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: super.c,v 1.99 2004/08/24 07:59:57 dwmw2 Exp $
+ * $Id: super.c,v 1.102 2004/11/12 02:42:17 tpoynor Exp $
  *
  */
 
@@ -56,6 +56,16 @@
 	}
 }
 
+static int jffs2_sync_fs(struct super_block *sb, int wait)
+{
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
+
+	down(&c->alloc_sem);
+	jffs2_flush_wbuf_pad(c);
+	up(&c->alloc_sem);	
+	return 0;
+}
+
 static struct super_operations jffs2_super_operations =
 {
 	.alloc_inode =	jffs2_alloc_inode,
@@ -67,6 +77,7 @@
 	.remount_fs =	jffs2_remount_fs,
 	.clear_inode =	jffs2_clear_inode,
 	.dirty_inode =	jffs2_dirty_inode,
+	.sync_fs =	jffs2_sync_fs,
 };
 
 static int jffs2_sb_compare(struct super_block *sb, void *data)
diff -Nru a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
--- a/fs/jffs2/wbuf.c	2004-12-24 13:36:31 -08:00
+++ b/fs/jffs2/wbuf.c	2004-12-24 13:36:31 -08:00
@@ -9,7 +9,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: wbuf.c,v 1.70 2004/07/13 08:58:25 dwmw2 Exp $
+ * $Id: wbuf.c,v 1.72 2004/09/11 19:22:43 gleixner Exp $
  *
  */
 
@@ -225,7 +225,7 @@
 
 		/* Do the read... */
 		ret = c->mtd->read_ecc(c->mtd, start, c->wbuf_ofs - start, &retlen, buf, NULL, c->oobinfo);
-		if (ret == -EIO && retlen == c->wbuf_ofs - start) {
+		if (ret == -EBADMSG && retlen == c->wbuf_ofs - start) {
 			/* ECC recovered */
 			ret = 0;
 		}
@@ -791,7 +791,7 @@
 	if (!jffs2_can_mark_obsolete(c)) {
 		ret = c->mtd->read_ecc(c->mtd, ofs, len, retlen, buf, NULL, c->oobinfo);
 
-		if ( (ret == -EIO) && (*retlen == len) ) {
+		if ( (ret == -EBADMSG) && (*retlen == len) ) {
 			printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n",
 			       len, ofs);
 			/* 
@@ -1047,7 +1047,7 @@
 	if (oinfo && oinfo->useecc == MTD_NANDECC_AUTOPLACE) {
 		D1(printk(KERN_DEBUG "JFFS2 using autoplace on NAND\n"));
 		/* Get the position of the free bytes */
-		if (!oinfo->oobfree[0][0]) {
+		if (!oinfo->oobfree[0][1]) {
 			printk (KERN_WARNING "jffs2_nand_set_oobinfo(): Eeep. Autoplacement selected and no empty space in oob\n");
 			return -ENOSPC;
 		}
diff -Nru a/fs/jffs2/write.c b/fs/jffs2/write.c
--- a/fs/jffs2/write.c	2004-12-24 13:36:48 -08:00
+++ b/fs/jffs2/write.c	2004-12-24 13:36:48 -08:00
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: write.c,v 1.85 2004/07/13 08:58:25 dwmw2 Exp $
+ * $Id: write.c,v 1.86 2004/11/13 10:44:26 dedekind Exp $
  *
  */
 
@@ -213,8 +213,10 @@
 	jffs2_add_physical_node_ref(c, raw);
 
 	/* Link into per-inode list */
+	spin_lock(&c->erase_completion_lock);
 	raw->next_in_ino = f->inocache->nodes;
 	f->inocache->nodes = raw;
+	spin_unlock(&c->erase_completion_lock);
 
 	D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n",
 		  flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize), 
@@ -333,8 +335,10 @@
 	raw->flash_offset |= REF_PRISTINE;
 	jffs2_add_physical_node_ref(c, raw);
 
+	spin_lock(&c->erase_completion_lock);
 	raw->next_in_ino = f->inocache->nodes;
 	f->inocache->nodes = raw;
+	spin_unlock(&c->erase_completion_lock);
 
 	if (retried) {
 		ACCT_SANITY_CHECK(c,NULL);
diff -Nru a/fs/jfs/acl.c b/fs/jfs/acl.c
--- a/fs/jfs/acl.c	2004-12-24 13:36:17 -08:00
+++ b/fs/jfs/acl.c	2004-12-24 13:36:17 -08:00
@@ -123,88 +123,25 @@
 	return rc;
 }
 
-/*
- *	jfs_permission()
- *
- * modified vfs_permission to check posix acl
- */
-int jfs_permission(struct inode * inode, int mask, struct nameidata *nd)
+static int jfs_check_acl(struct inode *inode, int mask)
 {
-	umode_t mode = inode->i_mode;
 	struct jfs_inode_info *ji = JFS_IP(inode);
 
-	if (mask & MAY_WRITE) {
-		/*
-		 * Nobody gets write access to a read-only fs.
-		 */
-		if (IS_RDONLY(inode) &&
-		    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
-			return -EROFS;
-
-		/*
-		 * Nobody gets write access to an immutable file.
-		 */
-		if (IS_IMMUTABLE(inode))
-			return -EACCES;
-	}
-
-	if (current->fsuid == inode->i_uid) {
-		mode >>= 6;
-		goto check_mode;
-	}
-	/*
-	 * ACL can't contain additional permissions if the ACL_MASK entry
-	 * is zero.
-	 */
-	if (!(mode & S_IRWXG))
-		goto check_groups;
-
 	if (ji->i_acl == JFS_ACL_NOT_CACHED) {
-		struct posix_acl *acl;
-
-		acl = jfs_get_acl(inode, ACL_TYPE_ACCESS);
-
+		struct posix_acl *acl = jfs_get_acl(inode, ACL_TYPE_ACCESS);
 		if (IS_ERR(acl))
 			return PTR_ERR(acl);
 		posix_acl_release(acl);
 	}
 
-	if (ji->i_acl) {
-		int rc = posix_acl_permission(inode, ji->i_acl, mask);
-		if (rc == -EACCES)
-			goto check_capabilities;
-		return rc;
-	}
-
-check_groups:
-	if (in_group_p(inode->i_gid))
-		mode >>= 3;
-
-check_mode:
-	/*
-	 * If the DACs are ok we don't need any capability check.
-	 */
-	if (((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask))
-		return 0;
+	if (ji->i_acl)
+		return posix_acl_permission(inode, ji->i_acl, mask);
+	return -EAGAIN;
+}
 
-check_capabilities:
-	/*
-	 * Read/write DACs are always overridable.
-	 * Executable DACs are overridable if at least one exec bit is set.
-	 */
-	if (!(mask & MAY_EXEC) ||
-	    (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode))
-		if (capable(CAP_DAC_OVERRIDE))
-			return 0;
-
-	/*
-	 * Searching includes executable on directories, else just read.
-	 */
-	if (mask == MAY_READ || (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE)))
-		if (capable(CAP_DAC_READ_SEARCH))
-			return 0;
-
-	return -EACCES;
+int jfs_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+	return generic_permission(inode, mask, jfs_check_acl);
 }
 
 int jfs_init_acl(struct inode *inode, struct inode *dir)
diff -Nru a/fs/jfs/jfs_dinode.h b/fs/jfs/jfs_dinode.h
--- a/fs/jfs/jfs_dinode.h	2004-12-24 13:37:19 -08:00
+++ b/fs/jfs/jfs_dinode.h	2004-12-24 13:37:19 -08:00
@@ -39,22 +39,22 @@
 	 *
 	 * define generic/POSIX attributes
 	 */
-	u32 di_inostamp;	/* 4: stamp to show inode belongs to fileset */
-	s32 di_fileset;		/* 4: fileset number */
-	u32 di_number;		/* 4: inode number, aka file serial number */
-	u32 di_gen;		/* 4: inode generation number */
+	__le32 di_inostamp;	/* 4: stamp to show inode belongs to fileset */
+	__le32 di_fileset;	/* 4: fileset number */
+	__le32 di_number;	/* 4: inode number, aka file serial number */
+	__le32 di_gen;		/* 4: inode generation number */
 
 	pxd_t di_ixpxd;		/* 8: inode extent descriptor */
 
-	s64 di_size;		/* 8: size */
-	s64 di_nblocks;		/* 8: number of blocks allocated */
+	__le64 di_size;		/* 8: size */
+	__le64 di_nblocks;	/* 8: number of blocks allocated */
 
-	u32 di_nlink;		/* 4: number of links to the object */
+	__le32 di_nlink;	/* 4: number of links to the object */
 
-	u32 di_uid;		/* 4: user id of owner */
-	u32 di_gid;		/* 4: group id of owner */
+	__le32 di_uid;		/* 4: user id of owner */
+	__le32 di_gid;		/* 4: group id of owner */
 
-	u32 di_mode;		/* 4: attribute, format and permission */
+	__le32 di_mode;		/* 4: attribute, format and permission */
 
 	struct timestruc_t di_atime;	/* 8: time last data accessed */
 	struct timestruc_t di_ctime;	/* 8: time last status changed */
@@ -65,9 +65,9 @@
 
 	dxd_t di_ea;		/* 16: ea descriptor */
 
-	u32 di_next_index;	/* 4: Next available dir_table index */
+	__le32 di_next_index;	/* 4: Next available dir_table index */
 
-	s32 di_acltype;		/* 4: Type of ACL */
+	__le32 di_acltype;	/* 4: Type of ACL */
 
 	/*
 	 *      Extension Areas.
@@ -103,7 +103,7 @@
 				u8 _data[96];		/* 96: unused */
 				struct {
 					void *_imap;	/* 4: unused */
-					u32 _gengen;	/* 4: generator */
+					__le32 _gengen;	/* 4: generator */
 				} _imap;
 			} _u1;				/* 96: */
 #define di_gengen	u._file._u1._imap._gengen
@@ -114,7 +114,7 @@
 					u8 unused[16];	/* 16: */
 					dxd_t _dxd;	/* 16: */
 					union {
-						u32 _rdev;	/* 4: */
+						__le32 _rdev;	/* 4: */
 						u8 _fastsymlink[128];
 					} _u;
 					u8 _inlineea[128];
diff -Nru a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
--- a/fs/jfs/jfs_dmap.c	2004-12-24 13:37:18 -08:00
+++ b/fs/jfs/jfs_dmap.c	2004-12-24 13:37:18 -08:00
@@ -194,7 +194,7 @@
 int dbMount(struct inode *ipbmap)
 {
 	struct bmap *bmp;
-	struct dbmap *dbmp_le;
+	struct dbmap_disk *dbmp_le;
 	struct metapage *mp;
 	int i;
 
@@ -216,7 +216,7 @@
 	}
 
 	/* copy the on-disk bmap descriptor to its in-memory version. */
-	dbmp_le = (struct dbmap *) mp->data;
+	dbmp_le = (struct dbmap_disk *) mp->data;
 	bmp->db_mapsize = le64_to_cpu(dbmp_le->dn_mapsize);
 	bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
 	bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
@@ -301,7 +301,7 @@
  */
 int dbSync(struct inode *ipbmap)
 {
-	struct dbmap *dbmp_le;
+	struct dbmap_disk *dbmp_le;
 	struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
 	struct metapage *mp;
 	int i;
@@ -318,7 +318,7 @@
 		return -EIO;
 	}
 	/* copy the in-memory version of the bmap to the on-disk version */
-	dbmp_le = (struct dbmap *) mp->data;
+	dbmp_le = (struct dbmap_disk *) mp->data;
 	dbmp_le->dn_mapsize = cpu_to_le64(bmp->db_mapsize);
 	dbmp_le->dn_nfree = cpu_to_le64(bmp->db_nfree);
 	dbmp_le->dn_l2nbperpage = cpu_to_le32(bmp->db_l2nbperpage);
@@ -3782,7 +3782,7 @@
 
 	/* set the rest of the words in the page to allocated (ONES) */
 	for (i = w; i < LPERDMAP; i++)
-		dp->pmap[i] = dp->wmap[i] = ONES;
+		dp->pmap[i] = dp->wmap[i] = cpu_to_le32(ONES);
 
 	/*
 	 * init tree
diff -Nru a/fs/jfs/jfs_dmap.h b/fs/jfs/jfs_dmap.h
--- a/fs/jfs/jfs_dmap.h	2004-12-24 13:36:55 -08:00
+++ b/fs/jfs/jfs_dmap.h	2004-12-24 13:36:55 -08:00
@@ -145,10 +145,10 @@
  * dmaptree must be consistent with dmapctl.
  */
 struct dmaptree {
-	s32 nleafs;		/* 4: number of tree leafs      */
-	s32 l2nleafs;		/* 4: l2 number of tree leafs   */
-	s32 leafidx;		/* 4: index of first tree leaf  */
-	s32 height;		/* 4: height of the tree        */
+	__le32 nleafs;		/* 4: number of tree leafs      */
+	__le32 l2nleafs;	/* 4: l2 number of tree leafs   */
+	__le32 leafidx;		/* 4: index of first tree leaf  */
+	__le32 height;		/* 4: height of the tree        */
 	s8 budmin;		/* 1: min l2 tree leaf value to combine */
 	s8 stree[TREESIZE];	/* TREESIZE: tree               */
 	u8 pad[2];		/* 2: pad to word boundary      */
@@ -158,13 +158,13 @@
  *	dmap page per 8K blocks bitmap
  */
 struct dmap {
-	s32 nblocks;		/* 4: num blks covered by this dmap     */
-	s32 nfree;		/* 4: num of free blks in this dmap     */
-	s64 start;		/* 8: starting blkno for this dmap      */
+	__le32 nblocks;		/* 4: num blks covered by this dmap     */
+	__le32 nfree;		/* 4: num of free blks in this dmap     */
+	__le64 start;		/* 8: starting blkno for this dmap      */
 	struct dmaptree tree;	/* 360: dmap tree                       */
 	u8 pad[1672];		/* 1672: pad to 2048 bytes              */
-	u32 wmap[LPERDMAP];	/* 1024: bits of the working map        */
-	u32 pmap[LPERDMAP];	/* 1024: bits of the persistent map     */
+	__le32 wmap[LPERDMAP];	/* 1024: bits of the working map        */
+	__le32 pmap[LPERDMAP];	/* 1024: bits of the persistent map     */
 };				/* - 4096 -                             */
 
 /*
@@ -173,10 +173,10 @@
  * dmapctl must be consistent with dmaptree.
  */
 struct dmapctl {
-	s32 nleafs;		/* 4: number of tree leafs      */
-	s32 l2nleafs;		/* 4: l2 number of tree leafs   */
-	s32 leafidx;		/* 4: index of the first tree leaf      */
-	s32 height;		/* 4: height of tree            */
+	__le32 nleafs;		/* 4: number of tree leafs      */
+	__le32 l2nleafs;	/* 4: l2 number of tree leafs   */
+	__le32 leafidx;		/* 4: index of the first tree leaf      */
+	__le32 height;		/* 4: height of tree            */
 	s8 budmin;		/* 1: minimum l2 tree leaf value        */
 	s8 stree[CTLTREESIZE];	/* CTLTREESIZE: dmapctl tree    */
 	u8 pad[2714];		/* 2714: pad to 4096            */
@@ -201,30 +201,47 @@
 /* 
  *	on-disk aggregate disk allocation map descriptor.
  */
-struct dbmap {
-	s64 dn_mapsize;		/* 8: number of blocks in aggregate     */
-	s64 dn_nfree;		/* 8: num free blks in aggregate map    */
-	s32 dn_l2nbperpage;	/* 4: number of blks per page           */
-	s32 dn_numag;		/* 4: total number of ags               */
-	s32 dn_maxlevel;	/* 4: number of active ags              */
-	s32 dn_maxag;		/* 4: max active alloc group number     */
-	s32 dn_agpref;		/* 4: preferred alloc group (hint)      */
-	s32 dn_aglevel;		/* 4: dmapctl level holding the AG      */
-	s32 dn_agheigth;	/* 4: height in dmapctl of the AG       */
-	s32 dn_agwidth;		/* 4: width in dmapctl of the AG        */
-	s32 dn_agstart;		/* 4: start tree index at AG height     */
-	s32 dn_agl2size;	/* 4: l2 num of blks per alloc group    */
-	s64 dn_agfree[MAXAG];	/* 8*MAXAG: per AG free count           */
-	s64 dn_agsize;		/* 8: num of blks per alloc group       */
+struct dbmap_disk {
+	__le64 dn_mapsize;	/* 8: number of blocks in aggregate     */
+	__le64 dn_nfree;	/* 8: num free blks in aggregate map    */
+	__le32 dn_l2nbperpage;	/* 4: number of blks per page           */
+	__le32 dn_numag;	/* 4: total number of ags               */
+	__le32 dn_maxlevel;	/* 4: number of active ags              */
+	__le32 dn_maxag;	/* 4: max active alloc group number     */
+	__le32 dn_agpref;	/* 4: preferred alloc group (hint)      */
+	__le32 dn_aglevel;	/* 4: dmapctl level holding the AG      */
+	__le32 dn_agheigth;	/* 4: height in dmapctl of the AG       */
+	__le32 dn_agwidth;	/* 4: width in dmapctl of the AG        */
+	__le32 dn_agstart;	/* 4: start tree index at AG height     */
+	__le32 dn_agl2size;	/* 4: l2 num of blks per alloc group    */
+	__le64 dn_agfree[MAXAG];/* 8*MAXAG: per AG free count           */
+	__le64 dn_agsize;	/* 8: num of blks per alloc group       */
 	s8 dn_maxfreebud;	/* 1: max free buddy system             */
 	u8 pad[3007];		/* 3007: pad to 4096                    */
 };				/* - 4096 -                             */
 
+struct dbmap {
+	s64 dn_mapsize;		/* number of blocks in aggregate     */
+	s64 dn_nfree;		/* num free blks in aggregate map    */
+	int dn_l2nbperpage;	/* number of blks per page           */
+	int dn_numag;		/* total number of ags               */
+	int dn_maxlevel;	/* number of active ags              */
+	int dn_maxag;		/* max active alloc group number     */
+	int dn_agpref;		/* preferred alloc group (hint)      */
+	int dn_aglevel;		/* dmapctl level holding the AG      */
+	int dn_agheigth;	/* height in dmapctl of the AG       */
+	int dn_agwidth;		/* width in dmapctl of the AG        */
+	int dn_agstart;		/* start tree index at AG height     */
+	int dn_agl2size;	/* l2 num of blks per alloc group    */
+	s64 dn_agfree[MAXAG];	/* per AG free count           */
+	s64 dn_agsize;		/* num of blks per alloc group       */
+	signed char dn_maxfreebud;	/* max free buddy system             */
+};				/* - 4096 -                             */
 /* 
  *	in-memory aggregate disk allocation map descriptor.
  */
 struct bmap {
-	struct dbmap db_bmap;	/* on-disk aggregate map descriptor */
+	struct dbmap db_bmap;		/* on-disk aggregate map descriptor */
 	struct inode *db_ipbmap;	/* ptr to aggregate map incore inode */
 	struct semaphore db_bmaplock;	/* aggregate map lock */
 	atomic_t db_active[MAXAG];	/* count of active, open files in AG */
diff -Nru a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
--- a/fs/jfs/jfs_dtree.c	2004-12-24 13:37:02 -08:00
+++ b/fs/jfs/jfs_dtree.c	2004-12-24 13:37:02 -08:00
@@ -852,7 +852,7 @@
 		n = NDTLEAF_LEGACY(name->namlen);
 		data.leaf.ip = NULL;	/* signifies legacy directory format */
 	}
-	data.leaf.ino = cpu_to_le32(*fsn);
+	data.leaf.ino = *fsn;
 
 	/*
 	 *      leaf page does not have enough room for new entry:
@@ -3570,7 +3570,8 @@
 		     dtpage_t * p,	/* directory page */
 		     int si)
 {				/* entry slot index */
-	wchar_t *kname, *name;
+	wchar_t *kname;
+	__le16 *name;
 	int klen, namlen, len, rc;
 	struct idtentry *ih;
 	struct dtslot *t;
@@ -3646,7 +3647,8 @@
 		     int si,	/* entry slot index */
 		     int flag)
 {
-	wchar_t *kname, *name, x;
+	wchar_t *kname, x;
+	__le16 *name;
 	int klen, namlen, len, rc;
 	struct ldtentry *lh;
 	struct idtentry *ih;
@@ -3824,7 +3826,8 @@
 	struct idtentry *ih;
 	struct dtslot *t;
 	int namlen, len;
-	wchar_t *name, *kname;
+	wchar_t *kname;
+	__le16 *name;
 
 	/* get entry */
 	stbl = DT_GETSTBL(p);
@@ -3852,7 +3855,7 @@
 	/*
 	 * move head/only segment
 	 */
-	UniStrncpy_le(kname, name, len);
+	UniStrncpy_from_le(kname, name, len);
 
 	/*
 	 * move additional segment(s)
@@ -3863,7 +3866,7 @@
 		kname += len;
 		namlen -= len;
 		len = min(namlen, DTSLOTDATALEN);
-		UniStrncpy_le(kname, t->name, len);
+		UniStrncpy_from_le(kname, t->name, len);
 
 		si = t->next;
 	}
@@ -3885,7 +3888,8 @@
 	struct ldtentry *lh = NULL;
 	struct idtentry *ih = NULL;
 	int hsi, fsi, klen, len, nextindex;
-	wchar_t *kname, *name;
+	wchar_t *kname;
+	__le16 *name;
 	s8 *stbl;
 	pxd_t *xd;
 	struct dt_lock *dtlck = *dtlock;
@@ -3914,7 +3918,7 @@
 	if (p->header.flag & BT_LEAF) {
 		lh = (struct ldtentry *) h;
 		lh->next = h->next;
-		lh->inumber = data->leaf.ino;	/* little-endian */
+		lh->inumber = cpu_to_le32(data->leaf.ino);
 		lh->namlen = klen;
 		name = lh->name;
 		if (data->leaf.ip) {
@@ -3936,7 +3940,7 @@
 		len = min(klen, DTIHDRDATALEN);
 	}
 
-	UniStrncpy_le(name, kname, len);
+	UniStrncpy_to_le(name, kname, len);
 
 	n = 1;
 	xsi = hsi;
@@ -3971,7 +3975,7 @@
 
 		kname += len;
 		len = min(klen, DTSLOTDATALEN);
-		UniStrncpy_le(t->name, kname, len);
+		UniStrncpy_to_le(t->name, kname, len);
 
 		n++;
 		xsi = fsi;
@@ -4174,7 +4178,7 @@
 			d++;
 
 			len = min(snamlen, DTSLOTDATALEN);
-			UniStrncpy(d->name, s->name, len);
+			UniStrncpy_le(d->name, s->name, len);
 
 			ns++;
 			nd++;
diff -Nru a/fs/jfs/jfs_dtree.h b/fs/jfs/jfs_dtree.h
--- a/fs/jfs/jfs_dtree.h	2004-12-24 13:36:55 -08:00
+++ b/fs/jfs/jfs_dtree.h	2004-12-24 13:36:55 -08:00
@@ -47,7 +47,7 @@
 struct dtslot {
 	s8 next;		/* 1: */
 	s8 cnt;			/* 1: */
-	wchar_t name[15];	/* 30: */
+	__le16 name[15];	/* 30: */
 };				/* (32) */
 
 
@@ -67,7 +67,7 @@
 
 	s8 next;		/* 1: */
 	u8 namlen;		/* 1: */
-	wchar_t name[11];	/* 22: 2-byte aligned */
+	__le16 name[11];	/* 22: 2-byte aligned */
 };				/* (32) */
 
 #define DTIHDRSIZE	10
@@ -83,11 +83,11 @@
  * 	For legacy filesystems, name contains 13 wchars -- no index field
  */
 struct ldtentry {
-	u32 inumber;		/* 4: 4-byte aligned */
+	__le32 inumber;		/* 4: 4-byte aligned */
 	s8 next;		/* 1: */
 	u8 namlen;		/* 1: */
-	wchar_t name[11];	/* 22: 2-byte aligned */
-	u32 index;		/* 4: index into dir_table */
+	__le16 name[11];	/* 22: 2-byte aligned */
+	__le32 index;		/* 4: index into dir_table */
 };				/* (32) */
 
 #define DTLHDRSIZE	6
@@ -113,7 +113,7 @@
 	u8 flag;		/* 1: 0 if free */
 	u8 slot;		/* 1: slot within leaf page of entry */
 	u8 addr1;		/* 1: upper 8 bits of leaf page address */
-	u32 addr2;		/* 4: lower 32 bits of leaf page address -OR-
+	__le32 addr2;		/* 4: lower 32 bits of leaf page address -OR-
 				   index of next entry when this entry was deleted */
 };				/* (8) */
 
@@ -151,7 +151,7 @@
 		s8 freecnt;	/* 1: free count */
 		s8 freelist;	/* 1: freelist header */
 
-		u32 idotdot;	/* 4: parent inode number */
+		__le32 idotdot;	/* 4: parent inode number */
 
 		s8 stbl[8];	/* 8: sorted entry index table */
 	} header;		/* (32) */
@@ -192,8 +192,8 @@
  */
 typedef union {
 	struct {
-		s64 next;	/* 8: next sibling */
-		s64 prev;	/* 8: previous sibling */
+		__le64 next;	/* 8: next sibling */
+		__le64 prev;	/* 8: previous sibling */
 
 		u8 flag;	/* 1: */
 		u8 nextindex;	/* 1: next entry index in stbl */
diff -Nru a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
--- a/fs/jfs/jfs_imap.c	2004-12-24 13:36:19 -08:00
+++ b/fs/jfs/jfs_imap.c	2004-12-24 13:36:19 -08:00
@@ -131,7 +131,7 @@
 	struct inomap *imap;
 	struct metapage *mp;
 	int index;
-	struct dinomap *dinom_le;
+	struct dinomap_disk *dinom_le;
 
 	/*
 	 * allocate/initialize the in-memory inode map control structure
@@ -154,7 +154,7 @@
 	}
 
 	/* copy the on-disk version to the in-memory version. */
-	dinom_le = (struct dinomap *) mp->data;
+	dinom_le = (struct dinomap_disk *) mp->data;
 	imap->im_freeiag = le32_to_cpu(dinom_le->in_freeiag);
 	imap->im_nextiag = le32_to_cpu(dinom_le->in_nextiag);
 	atomic_set(&imap->im_numinos, le32_to_cpu(dinom_le->in_numinos));
@@ -242,7 +242,7 @@
  */
 int diSync(struct inode *ipimap)
 {
-	struct dinomap *dinom_le;
+	struct dinomap_disk *dinom_le;
 	struct inomap *imp = JFS_IP(ipimap)->i_imap;
 	struct metapage *mp;
 	int index;
@@ -260,7 +260,7 @@
 	}
 
 	/* copy the in-memory version to the on-disk version */
-	dinom_le = (struct dinomap *) mp->data;
+	dinom_le = (struct dinomap_disk *) mp->data;
 	dinom_le->in_freeiag = cpu_to_le32(imp->im_freeiag);
 	dinom_le->in_nextiag = cpu_to_le32(imp->im_nextiag);
 	dinom_le->in_numinos = cpu_to_le32(atomic_read(&imp->im_numinos));
@@ -1027,7 +1027,7 @@
 			 */
 			iagp->inofreefwd =
 			    cpu_to_le32(imap->im_agctl[agno].inofree);
-			iagp->inofreeback = -1;
+			iagp->inofreeback = cpu_to_le32(-1);
 			imap->im_agctl[agno].inofree = iagno;
 		}
 		IREAD_UNLOCK(ipimap);
@@ -1037,7 +1037,7 @@
 		 * inodes (i.e., the inode being freed is the first free 
 		 * inode of extent),
 		 */
-		if (iagp->wmap[extno] == ONES) {
+		if (iagp->wmap[extno] == cpu_to_le32(ONES)) {
 			sword = extno >> L2EXTSPERSUM;
 			bitno = extno & (EXTSPERSUM - 1);
 			iagp->inosmap[sword] &=
@@ -1185,7 +1185,7 @@
 
 		iagp->extfreefwd =
 		    cpu_to_le32(imap->im_agctl[agno].extfree);
-		iagp->extfreeback = -1;
+		iagp->extfreeback = cpu_to_le32(-1);
 		imap->im_agctl[agno].extfree = iagno;
 	} else {
 		/* remove the iag from the ag extent list if all extents
@@ -1201,7 +1201,7 @@
 				imap->im_agctl[agno].extfree =
 				    le32_to_cpu(iagp->extfreefwd);
 
-			iagp->extfreefwd = iagp->extfreeback = -1;
+			iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
 
 			IAGFREE_LOCK(imap);
 			iagp->iagfree = cpu_to_le32(imap->im_freeiag);
@@ -1223,7 +1223,7 @@
 			imap->im_agctl[agno].inofree =
 			    le32_to_cpu(iagp->inofreefwd);
 
-		iagp->inofreefwd = iagp->inofreeback = -1;
+		iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
 	}
 
 	/* update the inode extent address and working map 
@@ -2131,7 +2131,7 @@
 	 * allocated.  if so, update the free inode summary
 	 * map to reflect this.
 	 */
-	if (iagp->wmap[extno] == ONES) {
+	if (iagp->wmap[extno] == cpu_to_le32(ONES)) {
 		sword = extno >> L2EXTSPERSUM;
 		bitno = extno & (EXTSPERSUM - 1);
 		iagp->inosmap[sword] |= cpu_to_le32(HIGHORDER >> bitno);
@@ -2153,7 +2153,7 @@
 			imap->im_agctl[agno].inofree =
 			    le32_to_cpu(iagp->inofreefwd);
 		}
-		iagp->inofreefwd = iagp->inofreeback = -1;
+		iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
 	}
 
 	/* update the free inode count at the iag, ag, inode
@@ -2362,7 +2362,7 @@
 			imap->im_agctl[agno].extfree =
 			    le32_to_cpu(iagp->extfreefwd);
 
-		iagp->extfreefwd = iagp->extfreeback = -1;
+		iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
 	} else {
 		/* if the iag has all free extents (newly allocated iag),
 		 * add the iag to the ag free extent list.
@@ -2372,7 +2372,7 @@
 				aiagp->extfreeback = cpu_to_le32(iagno);
 
 			iagp->extfreefwd = cpu_to_le32(fwd);
-			iagp->extfreeback = -1;
+			iagp->extfreeback = cpu_to_le32(-1);
 			imap->im_agctl[agno].extfree = iagno;
 		}
 	}
@@ -2386,7 +2386,7 @@
 
 		iagp->inofreefwd =
 		    cpu_to_le32(imap->im_agctl[agno].inofree);
-		iagp->inofreeback = -1;
+		iagp->inofreeback = cpu_to_le32(-1);
 		imap->im_agctl[agno].inofree = iagno;
 	}
 
@@ -2592,9 +2592,9 @@
 		/* init the iag */
 		memset(iagp, 0, sizeof(struct iag));
 		iagp->iagnum = cpu_to_le32(iagno);
-		iagp->inofreefwd = iagp->inofreeback = -1;
-		iagp->extfreefwd = iagp->extfreeback = -1;
-		iagp->iagfree = -1;
+		iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
+		iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
+		iagp->iagfree = cpu_to_le32(-1);
 		iagp->nfreeinos = 0;
 		iagp->nfreeexts = cpu_to_le32(EXTSPERIAG);
 
@@ -2602,7 +2602,7 @@
 		 * summary map initialization handled by bzero).
 		 */
 		for (i = 0; i < SMAPSZ; i++)
-			iagp->inosmap[i] = ONES;
+			iagp->inosmap[i] = cpu_to_le32(ONES);
 
 		flush_metapage(mp);
 
@@ -2676,7 +2676,7 @@
 
 	/* remove the iag from the iag free list */
 	imap->im_freeiag = le32_to_cpu(iagp->iagfree);
-	iagp->iagfree = -1;
+	iagp->iagfree = cpu_to_le32(-1);
 
 	/* set the return iag number and buffer pointer */
 	*iagnop = iagno;
@@ -2924,8 +2924,8 @@
 
 	/* init per AG control information im_agctl[] */
 	for (i = 0; i < MAXAG; i++) {
-		imap->im_agctl[i].inofree = -1;	/* free inode list */
-		imap->im_agctl[i].extfree = -1;	/* free extent list */
+		imap->im_agctl[i].inofree = -1;
+		imap->im_agctl[i].extfree = -1;
 		imap->im_agctl[i].numinos = 0;	/* number of backed inodes */
 		imap->im_agctl[i].numfree = 0;	/* number of free backed inodes */
 	}
@@ -2970,18 +2970,18 @@
 
 		/* if any backed free inodes, insert at AG free inode list */
 		if ((int) le32_to_cpu(iagp->nfreeinos) > 0) {
-			if ((head = imap->im_agctl[n].inofree) == -1)
-				iagp->inofreefwd = iagp->inofreeback = -1;
-			else {
+			if ((head = imap->im_agctl[n].inofree) == -1) {
+				iagp->inofreefwd = cpu_to_le32(-1);
+				iagp->inofreeback = cpu_to_le32(-1);
+			} else {
 				if ((rc = diIAGRead(imap, head, &hbp))) {
 					rcx = rc;
 					goto nextiag;
 				}
 				hiagp = (struct iag *) hbp->data;
-				hiagp->inofreeback =
-				    le32_to_cpu(iagp->iagnum);
+				hiagp->inofreeback = iagp->iagnum;
 				iagp->inofreefwd = cpu_to_le32(head);
-				iagp->inofreeback = -1;
+				iagp->inofreeback = cpu_to_le32(-1);
 				write_metapage(hbp);
 			}
 
@@ -2996,9 +2996,10 @@
 
 		/* if any free extents, insert at AG free extent list */
 		if (le32_to_cpu(iagp->nfreeexts) > 0) {
-			if ((head = imap->im_agctl[n].extfree) == -1)
-				iagp->extfreefwd = iagp->extfreeback = -1;
-			else {
+			if ((head = imap->im_agctl[n].extfree) == -1) {
+				iagp->extfreefwd = cpu_to_le32(-1);
+				iagp->extfreeback = cpu_to_le32(-1);
+			} else {
 				if ((rc = diIAGRead(imap, head, &hbp))) {
 					rcx = rc;
 					goto nextiag;
@@ -3006,7 +3007,7 @@
 				hiagp = (struct iag *) hbp->data;
 				hiagp->extfreeback = iagp->iagnum;
 				iagp->extfreefwd = cpu_to_le32(head);
-				iagp->extfreeback = -1;
+				iagp->extfreeback = cpu_to_le32(-1);
 				write_metapage(hbp);
 			}
 
@@ -3053,7 +3054,7 @@
 		if (readSuper(sb, &bh))
 			return;
 		j_sb = (struct jfs_superblock *)bh->b_data;
-		j_sb->s_flag |= JFS_BAD_SAIT;
+		j_sb->s_flag |= cpu_to_le32(JFS_BAD_SAIT);
 
 		mark_buffer_dirty(bh);
 		sync_dirty_buffer(bh);
diff -Nru a/fs/jfs/jfs_imap.h b/fs/jfs/jfs_imap.h
--- a/fs/jfs/jfs_imap.h	2004-12-24 13:37:18 -08:00
+++ b/fs/jfs/jfs_imap.h	2004-12-24 13:37:18 -08:00
@@ -60,16 +60,16 @@
  *	inode allocation group page (per 4096 inodes of an AG)
  */
 struct iag {
-	s64 agstart;		/* 8: starting block of ag              */
-	s32 iagnum;		/* 4: inode allocation group number     */
-	s32 inofreefwd;		/* 4: ag inode free list forward        */
-	s32 inofreeback;	/* 4: ag inode free list back           */
-	s32 extfreefwd;		/* 4: ag inode extent free list forward */
-	s32 extfreeback;	/* 4: ag inode extent free list back    */
-	s32 iagfree;		/* 4: iag free list                     */
+	__le64 agstart;		/* 8: starting block of ag              */
+	__le32 iagnum;		/* 4: inode allocation group number     */
+	__le32 inofreefwd;	/* 4: ag inode free list forward        */
+	__le32 inofreeback;	/* 4: ag inode free list back           */
+	__le32 extfreefwd;	/* 4: ag inode extent free list forward */
+	__le32 extfreeback;	/* 4: ag inode extent free list back    */
+	__le32 iagfree;		/* 4: iag free list                     */
 
 	/* summary map: 1 bit per inode extent */
-	s32 inosmap[SMAPSZ];	/* 16: sum map of mapwords w/ free inodes;
+	__le32 inosmap[SMAPSZ];	/* 16: sum map of mapwords w/ free inodes;
 				 *      note: this indicates free and backed
 				 *      inodes, if the extent is not backed the
 				 *      value will be 1.  if the extent is
@@ -78,43 +78,61 @@
 				 *      backed but at least one of the inodes is
 				 *      free the value will be 0.
 				 */
-	s32 extsmap[SMAPSZ];	/* 16: sum map of mapwords w/ free extents */
-	s32 nfreeinos;		/* 4: number of free inodes             */
-	s32 nfreeexts;		/* 4: number of free extents            */
+	__le32 extsmap[SMAPSZ];	/* 16: sum map of mapwords w/ free extents */
+	__le32 nfreeinos;		/* 4: number of free inodes             */
+	__le32 nfreeexts;		/* 4: number of free extents            */
 	/* (72) */
 	u8 pad[1976];		/* 1976: pad to 2048 bytes */
 	/* allocation bit map: 1 bit per inode (0 - free, 1 - allocated) */
-	u32 wmap[EXTSPERIAG];	/* 512: working allocation map  */
-	u32 pmap[EXTSPERIAG];	/* 512: persistent allocation map */
+	__le32 wmap[EXTSPERIAG];	/* 512: working allocation map  */
+	__le32 pmap[EXTSPERIAG];	/* 512: persistent allocation map */
 	pxd_t inoext[EXTSPERIAG];	/* 1024: inode extent addresses */
 };				/* (4096) */
 
 /*
  *	per AG control information (in inode map control page)
  */
-struct iagctl {
-	s32 inofree;		/* 4: free inode list anchor            */
-	s32 extfree;		/* 4: free extent list anchor           */
-	s32 numinos;		/* 4: number of backed inodes           */
-	s32 numfree;		/* 4: number of free inodes             */
+struct iagctl_disk {
+	__le32 inofree;		/* 4: free inode list anchor            */
+	__le32 extfree;		/* 4: free extent list anchor           */
+	__le32 numinos;		/* 4: number of backed inodes           */
+	__le32 numfree;		/* 4: number of free inodes             */
 };				/* (16) */
 
+struct iagctl {
+	int inofree;		/* free inode list anchor            */
+	int extfree;		/* free extent list anchor           */
+	int numinos;		/* number of backed inodes           */
+	int numfree;		/* number of free inodes             */
+};
+
 /*
  *	per fileset/aggregate inode map control page
  */
-struct dinomap {
-	s32 in_freeiag;		/* 4: free iag list anchor     */
-	s32 in_nextiag;		/* 4: next free iag number     */
-	s32 in_numinos;		/* 4: num of backed inodes */
-	s32 in_numfree;		/* 4: num of free backed inodes */
-	s32 in_nbperiext;	/* 4: num of blocks per inode extent */
-	s32 in_l2nbperiext;	/* 4: l2 of in_nbperiext */
-	s32 in_diskblock;	/* 4: for standalone test driver  */
-	s32 in_maxag;		/* 4: for standalone test driver  */
+struct dinomap_disk {
+	__le32 in_freeiag;	/* 4: free iag list anchor     */
+	__le32 in_nextiag;	/* 4: next free iag number     */
+	__le32 in_numinos;	/* 4: num of backed inodes */
+	__le32 in_numfree;	/* 4: num of free backed inodes */
+	__le32 in_nbperiext;	/* 4: num of blocks per inode extent */
+	__le32 in_l2nbperiext;	/* 4: l2 of in_nbperiext */
+	__le32 in_diskblock;	/* 4: for standalone test driver  */
+	__le32 in_maxag;	/* 4: for standalone test driver  */
 	u8 pad[2016];		/* 2016: pad to 2048 */
-	struct iagctl in_agctl[MAXAG];	/* 2048: AG control information */
+	struct iagctl_disk in_agctl[MAXAG]; /* 2048: AG control information */
 };				/* (4096) */
 
+struct dinomap {
+	int in_freeiag;		/* free iag list anchor     */
+	int in_nextiag;		/* next free iag number     */
+	int in_numinos;		/* num of backed inodes */
+	int in_numfree;		/* num of free backed inodes */
+	int in_nbperiext;	/* num of blocks per inode extent */
+	int in_l2nbperiext;	/* l2 of in_nbperiext */
+	int in_diskblock;	/* for standalone test driver  */
+	int in_maxag;		/* for standalone test driver  */
+	struct iagctl in_agctl[MAXAG];	/* AG control information */
+};
 
 /*
  *	In-core inode map control page
diff -Nru a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
--- a/fs/jfs/jfs_incore.h	2004-12-24 13:36:17 -08:00
+++ b/fs/jfs/jfs_incore.h	2004-12-24 13:36:17 -08:00
@@ -21,7 +21,7 @@
 
 #include <linux/rwsem.h>
 #include <linux/slab.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include "jfs_types.h"
 #include "jfs_xtree.h"
 #include "jfs_dtree.h"
diff -Nru a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
--- a/fs/jfs/jfs_logmgr.c	2004-12-24 13:36:55 -08:00
+++ b/fs/jfs/jfs_logmgr.c	2004-12-24 13:36:55 -08:00
@@ -161,9 +161,9 @@
 /*
  * Global list of active external journals
  */
-LIST_HEAD(jfs_external_logs);
-struct jfs_log *dummy_log = NULL;
-DECLARE_MUTEX(jfs_log_sem);
+static LIST_HEAD(jfs_external_logs);
+static struct jfs_log *dummy_log = NULL;
+static DECLARE_MUTEX(jfs_log_sem);
 
 /*
  * external references
@@ -205,7 +205,7 @@
  *	statistics
  */
 #ifdef CONFIG_JFS_STATISTICS
-struct lmStat {
+static struct lmStat {
 	uint commit;		/* # of commit */
 	uint pagedone;		/* # of page written */
 	uint submitted;		/* # of pages submitted */
@@ -1435,6 +1435,8 @@
 	 *      unwind on error
 	 */
       errout30:		/* release log page */
+	log->wqueue = NULL;
+	bp->l_wqnext = NULL;
 	lbmFree(bp);
 
       errout20:		/* release log superblock */
diff -Nru a/fs/jfs/jfs_logmgr.h b/fs/jfs/jfs_logmgr.h
--- a/fs/jfs/jfs_logmgr.h	2004-12-24 13:36:32 -08:00
+++ b/fs/jfs/jfs_logmgr.h	2004-12-24 13:36:32 -08:00
@@ -62,17 +62,17 @@
 #define MAX_ACTIVE	128	/* Max active file systems sharing log */
 
 struct logsuper {
-	u32 magic;		/* 4: log lv identifier */
-	s32 version;		/* 4: version number */
-	s32 serial;		/* 4: log open/mount counter */
-	s32 size;		/* 4: size in number of LOGPSIZE blocks */
-	s32 bsize;		/* 4: logical block size in byte */
-	s32 l2bsize;		/* 4: log2 of bsize */
+	__le32 magic;		/* 4: log lv identifier */
+	__le32 version;		/* 4: version number */
+	__le32 serial;		/* 4: log open/mount counter */
+	__le32 size;		/* 4: size in number of LOGPSIZE blocks */
+	__le32 bsize;		/* 4: logical block size in byte */
+	__le32 l2bsize;		/* 4: log2 of bsize */
 
-	u32 flag;		/* 4: option */
-	u32 state;		/* 4: state - see below */
+	__le32 flag;		/* 4: option */
+	__le32 state;		/* 4: state - see below */
 
-	s32 end;		/* 4: addr of last log record set by logredo */
+	__le32 end;		/* 4: addr of last log record set by logredo */
 	char uuid[16];		/* 16: 128-bit journal uuid */
 	char label[16];		/* 16: journal label */
 	struct {
@@ -121,17 +121,17 @@
  */
 struct logpage {
 	struct {		/* header */
-		s32 page;	/* 4: log sequence page number */
-		s16 rsrvd;	/* 2: */
-		s16 eor;	/* 2: end-of-log offset of lasrt record write */
+		__le32 page;	/* 4: log sequence page number */
+		__le16 rsrvd;	/* 2: */
+		__le16 eor;	/* 2: end-of-log offset of lasrt record write */
 	} h;
 
-	s32 data[LOGPSIZE / 4 - 4];	/* log record area */
+	__le32 data[LOGPSIZE / 4 - 4];	/* log record area */
 
 	struct {		/* trailer */
-		s32 page;	/* 4: normally the same as h.page */
-		s16 rsrvd;	/* 2: */
-		s16 eor;	/* 2: normally the same as h.eor */
+		__le32 page;	/* 4: normally the same as h.page */
+		__le16 rsrvd;	/* 2: */
+		__le16 eor;	/* 2: normally the same as h.eor */
 	} t;
 };
 
@@ -202,11 +202,11 @@
 	/*
 	 * type independent area
 	 */
-	s32 logtid;		/* 4: log transaction identifier */
-	s32 backchain;		/* 4: ptr to prev record of same transaction */
-	u16 type;		/* 2: record type */
-	s16 length;		/* 2: length of data in record (in byte) */
-	u32 aggregate;		/* 4: file system lv/aggregate */
+	__le32 logtid;		/* 4: log transaction identifier */
+	__le32 backchain;	/* 4: ptr to prev record of same transaction */
+	__le16 type;		/* 2: record type */
+	__le16 length;		/* 2: length of data in record (in byte) */
+	__le32 aggregate;	/* 4: file system lv/aggregate */
 	/* (16) */
 
 	/*
@@ -228,10 +228,10 @@
 		 * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format;
 		 */
 		struct {
-			u32 fileset;	/* 4: fileset number */
-			u32 inode;	/* 4: inode number */
-			u16 type;	/* 2: REDOPAGE record type */
-			s16 l2linesize;	/* 2: log2 of line size */
+			__le32 fileset;	/* 4: fileset number */
+			__le32 inode;	/* 4: inode number */
+			__le16 type;	/* 2: REDOPAGE record type */
+			__le16 l2linesize;	/* 2: log2 of line size */
 			pxd_t pxd;	/* 8: on-disk page pxd */
 		} redopage;	/* (20) */
 
@@ -244,10 +244,10 @@
 		 * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format;
 		 */
 		struct {
-			s32 fileset;	/* 4: fileset number */
-			u32 inode;	/* 4: inode number */
-			u16 type;	/* 2: NOREDOPAGE record type */
-			s16 rsrvd;	/* 2: reserved */
+			__le32 fileset;	/* 4: fileset number */
+			__le32 inode;	/* 4: inode number */
+			__le16 type;	/* 2: NOREDOPAGE record type */
+			__le16 rsrvd;	/* 2: reserved */
 			pxd_t pxd;	/* 8: on-disk page pxd */
 		} noredopage;	/* (20) */
 
@@ -260,10 +260,10 @@
 		 * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format;
 		 */
 		struct {
-			u32 fileset;	/* 4: fileset number */
-			u32 inode;	/* 4: inode number */
-			u16 type;	/* 2: UPDATEMAP record type */
-			s16 nxd;	/* 2: number of extents */
+			__le32 fileset;	/* 4: fileset number */
+			__le32 inode;	/* 4: inode number */
+			__le16 type;	/* 2: UPDATEMAP record type */
+			__le16 nxd;	/* 2: number of extents */
 			pxd_t pxd;	/* 8: pxd */
 		} updatemap;	/* (20) */
 
@@ -279,9 +279,9 @@
 		 *
 		 */
 		struct {
-			s32 fileset;	/* 4: fileset number */
-			s32 iagnum;	/* 4: IAG number     */
-			s32 inoext_idx;	/* 4: inode extent index */
+			__le32 fileset;	/* 4: fileset number */
+			__le32 iagnum;	/* 4: IAG number     */
+			__le32 inoext_idx;	/* 4: inode extent index */
 			pxd_t pxd;	/* 8: on-disk page pxd */
 		} noredoinoext;	/* (20) */
 
@@ -291,7 +291,7 @@
 		 * replay log upto syncpt address specified;
 		 */
 		struct {
-			s32 sync;	/* 4: syncpt address (0 = here) */
+			__le32 sync;	/* 4: syncpt address (0 = here) */
 		} syncpt;
 
 		/*
@@ -307,8 +307,8 @@
 		 * N.B.: nextents should be length of data/sizeof(xad_t)
 		 */
 		struct {
-			s32 type;	/* 4: FREEXTENT record type */
-			s32 nextent;	/* 4: number of extents */
+			__le32 type;	/* 4: FREEXTENT record type */
+			__le32 nextent;	/* 4: number of extents */
 
 			/* data: PXD or XAD list */
 		} freextent;
@@ -327,8 +327,8 @@
 		 * replay of the 
 		 */
 		struct {
-			s32 fileset;	/* 4: fileset number */
-			u32 inode;	/* 4: inode number */
+			__le32 fileset;	/* 4: fileset number */
+			__le32 inode;	/* 4: inode number */
 		} noredofile;
 
 		/*
@@ -337,9 +337,9 @@
 		 * metadata type dependent
 		 */
 		struct {
-			s32 fileset;	/* 4: fileset number */
-			u32 inode;	/* 4: inode number */
-			s32 type;	/* 4: NEWPAGE record type */
+			__le32 fileset;	/* 4: fileset number */
+			__le32 inode;	/* 4: inode number */
+			__le32 type;	/* 4: NEWPAGE record type */
 			pxd_t pxd;	/* 8: on-disk page pxd */
 		} newpage;
 
@@ -357,8 +357,8 @@
  *	line vector descriptor
  */
 struct lvd {
-	s16 offset;
-	s16 length;
+	__le16 offset;
+	__le16 length;
 };
 
 
@@ -372,7 +372,7 @@
 				 */
 	struct list_head journal_list; /* Global list */
 	struct block_device *bdev; /* 4: log lv pointer */
-	s32 serial;		/* 4: log mount serial number */
+	int serial;		/* 4: log mount serial number */
 
 	s64 base;		/* @8: log extent address (inline log ) */
 	int size;		/* 4: log size in log page (in page) */
@@ -398,7 +398,7 @@
 
 	/* commit */
 	uint cflag;		/* 4: */
-	struct list_head	cqueue; /* FIFO commit queue */
+	struct list_head cqueue; /* FIFO commit queue */
 	struct tblock *flush_tblk; /* tblk we're waiting on for flush */
 	int gcrtc;		/* 4: GC_READY transaction count */
 	struct tblock *gclrt;	/* 4: latest GC_READY transaction */
diff -Nru a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
--- a/fs/jfs/jfs_metapage.c	2004-12-24 13:36:31 -08:00
+++ b/fs/jfs/jfs_metapage.c	2004-12-24 13:36:31 -08:00
@@ -31,7 +31,7 @@
 static spinlock_t meta_lock = SPIN_LOCK_UNLOCKED;
 
 #ifdef CONFIG_JFS_STATISTICS
-struct {
+static struct {
 	uint	pagealloc;	/* # of page allocations */
 	uint	pagefree;	/* # of page frees */
 	uint	lockwait;	/* # of sleeping lock_metapage() calls */
@@ -108,9 +108,9 @@
 	}
 }
 
-static inline struct metapage *alloc_metapage(int no_wait)
+static inline struct metapage *alloc_metapage(int gfp_mask)
 {
-	return mempool_alloc(metapage_mempool, no_wait ? GFP_ATOMIC : GFP_NOFS);
+	return mempool_alloc(metapage_mempool, gfp_mask);
 }
 
 static inline void free_metapage(struct metapage *mp)
@@ -289,7 +289,7 @@
 		 */
 		mp = NULL;
 		if (JFS_IP(inode)->fileset == AGGREGATE_I) {
-			mp =  mempool_alloc(metapage_mempool, GFP_ATOMIC);
+			mp = alloc_metapage(GFP_ATOMIC);
 			if (!mp) {
 				/*
 				 * mempool is supposed to protect us from
@@ -306,7 +306,7 @@
 			struct metapage *mp2;
 
 			spin_unlock(&meta_lock);
-			mp =  mempool_alloc(metapage_mempool, GFP_NOFS);
+			mp = alloc_metapage(GFP_NOFS);
 			spin_lock(&meta_lock);
 
 			/* we dropped the meta_lock, we need to search the
diff -Nru a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
--- a/fs/jfs/jfs_mount.c	2004-12-24 13:36:31 -08:00
+++ b/fs/jfs/jfs_mount.c	2004-12-24 13:36:31 -08:00
@@ -324,7 +324,7 @@
 	 */
 	/* validate fs signature */
 	if (strncmp(j_sb->s_magic, JFS_MAGIC, 4) ||
-	    j_sb->s_version > cpu_to_le32(JFS_VERSION)) {
+	    le32_to_cpu(j_sb->s_version) > JFS_VERSION) {
 		rc = -EINVAL;
 		goto out;
 	}
diff -Nru a/fs/jfs/jfs_superblock.h b/fs/jfs/jfs_superblock.h
--- a/fs/jfs/jfs_superblock.h	2004-12-24 13:36:19 -08:00
+++ b/fs/jfs/jfs_superblock.h	2004-12-24 13:36:19 -08:00
@@ -35,29 +35,29 @@
  */
 struct jfs_superblock {
 	char s_magic[4];	/* 4: magic number */
-	u32 s_version;		/* 4: version number */
+	__le32 s_version;	/* 4: version number */
 
-	s64 s_size;		/* 8: aggregate size in hardware/LVM blocks;
+	__le64 s_size;		/* 8: aggregate size in hardware/LVM blocks;
 				 * VFS: number of blocks
 				 */
-	s32 s_bsize;		/* 4: aggregate block size in bytes; 
+	__le32 s_bsize;		/* 4: aggregate block size in bytes; 
 				 * VFS: fragment size
 				 */
-	s16 s_l2bsize;		/* 2: log2 of s_bsize */
-	s16 s_l2bfactor;	/* 2: log2(s_bsize/hardware block size) */
-	s32 s_pbsize;		/* 4: hardware/LVM block size in bytes */
-	s16 s_l2pbsize;		/* 2: log2 of s_pbsize */
-	s16 pad;		/* 2: padding necessary for alignment */
+	__le16 s_l2bsize;	/* 2: log2 of s_bsize */
+	__le16 s_l2bfactor;	/* 2: log2(s_bsize/hardware block size) */
+	__le32 s_pbsize;	/* 4: hardware/LVM block size in bytes */
+	__le16 s_l2pbsize;	/* 2: log2 of s_pbsize */
+	__le16 pad;		/* 2: padding necessary for alignment */
 
-	u32 s_agsize;		/* 4: allocation group size in aggr. blocks */
+	__le32 s_agsize;	/* 4: allocation group size in aggr. blocks */
 
-	u32 s_flag;		/* 4: aggregate attributes:
+	__le32 s_flag;		/* 4: aggregate attributes:
 				 *    see jfs_filsys.h
 				 */
-	u32 s_state;		/* 4: mount/unmount/recovery state: 
+	__le32 s_state;		/* 4: mount/unmount/recovery state: 
 				 *    see jfs_filsys.h
 				 */
-	s32 s_compress;		/* 4: > 0 if data compression */
+	__le32 s_compress;		/* 4: > 0 if data compression */
 
 	pxd_t s_ait2;		/* 8: first extent of secondary
 				 *    aggregate inode table
@@ -66,15 +66,15 @@
 	pxd_t s_aim2;		/* 8: first extent of secondary
 				 *    aggregate inode map
 				 */
-	u32 s_logdev;		/* 4: device address of log */
-	s32 s_logserial;	/* 4: log serial number at aggregate mount */
+	__le32 s_logdev;		/* 4: device address of log */
+	__le32 s_logserial;	/* 4: log serial number at aggregate mount */
 	pxd_t s_logpxd;		/* 8: inline log extent */
 
 	pxd_t s_fsckpxd;	/* 8: inline fsck work space extent */
 
 	struct timestruc_t s_time;	/* 8: time last updated */
 
-	s32 s_fsckloglen;	/* 4: Number of filesystem blocks reserved for
+	__le32 s_fsckloglen;	/* 4: Number of filesystem blocks reserved for
 				 *    the fsck service log.  
 				 *    N.B. These blocks are divided among the
 				 *         versions kept.  This is not a per
@@ -95,7 +95,7 @@
 				 */
 
 	/* extendfs() parameter under s_state & FM_EXTENDFS */
-	s64 s_xsize;		/* 8: extendfs s_size */
+	__le64 s_xsize;		/* 8: extendfs s_size */
 	pxd_t s_xfsckpxd;	/* 8: extendfs fsckpxd */
 	pxd_t s_xlogpxd;	/* 8: extendfs logpxd */
 	/* - 128 byte boundary - */
diff -Nru a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
--- a/fs/jfs/jfs_txnmgr.c	2004-12-24 13:37:00 -08:00
+++ b/fs/jfs/jfs_txnmgr.c	2004-12-24 13:37:00 -08:00
@@ -80,7 +80,7 @@
 int jfs_tlocks_low;		/* Indicates low number of available tlocks */
 
 #ifdef CONFIG_JFS_STATISTICS
-struct {
+static struct {
 	uint txBegin;
 	uint txBegin_barrier;
 	uint txBegin_lockslow;
@@ -152,7 +152,7 @@
 /*
  *      statistics
  */
-struct {
+static struct {
 	tid_t maxtid;		/* 4: biggest tid ever used */
 	lid_t maxlid;		/* 4: biggest lid ever used */
 	int ntid;		/* 4: # of transactions performed */
diff -Nru a/fs/jfs/jfs_types.h b/fs/jfs/jfs_types.h
--- a/fs/jfs/jfs_types.h	2004-12-24 13:36:49 -08:00
+++ b/fs/jfs/jfs_types.h	2004-12-24 13:36:49 -08:00
@@ -45,8 +45,8 @@
  * Almost identical to Linux's timespec, but not quite
  */
 struct timestruc_t {
-	u32 tv_sec;
-	u32 tv_nsec;
+	__le32 tv_sec;
+	__le32 tv_nsec;
 };
 
 /*
@@ -96,7 +96,7 @@
 typedef struct {
 	unsigned len:24;
 	unsigned addr1:8;
-	u32 addr2;
+	__le32 addr2;
 } pxd_t;
 
 /* xd_t field construction */
@@ -127,11 +127,11 @@
  */
 typedef struct {
 	unsigned flag:8;	/* 1: flags */
-	unsigned rsrvd:24;	/* 3: */
-	u32 size;		/* 4: size in byte */
+	unsigned rsrvd:24;
+	__le32 size;		/* 4: size in byte */
 	unsigned len:24;	/* 3: length in unit of fsblksize */
 	unsigned addr1:8;	/* 1: address in unit of fsblksize */
-	u32 addr2;		/* 4: address in unit of fsblksize */
+	__le32 addr2;		/* 4: address in unit of fsblksize */
 } dxd_t;			/* - 16 - */
 
 /* dxd_t flags */
@@ -168,10 +168,10 @@
 	u8 delta;		/* Alert Threshold delta (in percent)   */
 	u8 rsrvd1;
 	u8 limit_hi;		/* DASD limit (in logical blocks)       */
-	u32 limit_lo;		/* DASD limit (in logical blocks)       */
+	__le32 limit_lo;	/* DASD limit (in logical blocks)       */
 	u8 rsrvd2[3];
 	u8 used_hi;		/* DASD usage (in logical blocks)       */
-	u32 used_lo;		/* DASD usage (in logical blocks)       */
+	__le32 used_lo;		/* DASD usage (in logical blocks)       */
 };
 
 #define DASDLIMIT(dasdp) \
diff -Nru a/fs/jfs/jfs_unicode.c b/fs/jfs/jfs_unicode.c
--- a/fs/jfs/jfs_unicode.c	2004-12-24 13:37:18 -08:00
+++ b/fs/jfs/jfs_unicode.c	2004-12-24 13:37:18 -08:00
@@ -29,7 +29,7 @@
  * FUNCTION:	Convert little-endian unicode string to character string
  *
  */
-int jfs_strfromUCS_le(char *to, const wchar_t * from,	/* LITTLE ENDIAN */
+int jfs_strfromUCS_le(char *to, const __le16 * from,
 		      int len, struct nls_table *codepage)
 {
 	int i;
diff -Nru a/fs/jfs/jfs_unicode.h b/fs/jfs/jfs_unicode.h
--- a/fs/jfs/jfs_unicode.h	2004-12-24 13:36:17 -08:00
+++ b/fs/jfs/jfs_unicode.h	2004-12-24 13:36:17 -08:00
@@ -31,7 +31,7 @@
 extern signed char UniUpperTable[512];
 extern UNICASERANGE UniUpperRange[];
 extern int get_UCSname(struct component_name *, struct dentry *);
-extern int jfs_strfromUCS_le(char *, const wchar_t *, int, struct nls_table *);
+extern int jfs_strfromUCS_le(char *, const __le16 *, int, struct nls_table *);
 
 #define free_UCSname(COMP) kfree((COMP)->name)
 
@@ -51,10 +51,10 @@
 /*
  * UniStrncpy:  Copy length limited string with pad
  */
-static inline wchar_t *UniStrncpy(wchar_t * ucs1, const wchar_t * ucs2,
+static inline __le16 *UniStrncpy_le(__le16 * ucs1, const __le16 * ucs2,
 				  size_t n)
 {
-	wchar_t *anchor = ucs1;
+	__le16 *anchor = ucs1;
 
 	while (n-- && *ucs2)	/* Copy the strings */
 		*ucs1++ = *ucs2++;
@@ -68,7 +68,7 @@
 /*
  * UniStrncmp_le:  Compare length limited string - native to little-endian
  */
-static inline int UniStrncmp_le(const wchar_t * ucs1, const wchar_t * ucs2,
+static inline int UniStrncmp_le(const wchar_t * ucs1, const __le16 * ucs2,
 				size_t n)
 {
 	if (!n)
@@ -81,10 +81,27 @@
 }
 
 /*
- * UniStrncpy_le:  Copy length limited string with pad to little-endian
+ * UniStrncpy_to_le:  Copy length limited string with pad to little-endian
+ */
+static inline __le16 *UniStrncpy_to_le(__le16 * ucs1, const wchar_t * ucs2,
+				       size_t n)
+{
+	__le16 *anchor = ucs1;
+
+	while (n-- && *ucs2)	/* Copy the strings */
+		*ucs1++ = cpu_to_le16(*ucs2++);
+
+	n++;
+	while (n--)		/* Pad with nulls */
+		*ucs1++ = 0;
+	return anchor;
+}
+
+/*
+ * UniStrncpy_from_le:  Copy length limited string with pad from little-endian
  */
-static inline wchar_t *UniStrncpy_le(wchar_t * ucs1, const wchar_t * ucs2,
-				     size_t n)
+static inline wchar_t *UniStrncpy_from_le(wchar_t * ucs1, const __le16 * ucs2,
+					  size_t n)
 {
 	wchar_t *anchor = ucs1;
 
@@ -96,7 +113,6 @@
 		*ucs1++ = 0;
 	return anchor;
 }
-
 
 /*
  * UniToupper:  Convert a unicode character to upper case
diff -Nru a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h
--- a/fs/jfs/jfs_xattr.h	2004-12-24 13:37:19 -08:00
+++ b/fs/jfs/jfs_xattr.h	2004-12-24 13:37:19 -08:00
@@ -27,12 +27,12 @@
 struct jfs_ea {
 	u8 flag;	/* Unused? */
 	u8 namelen;	/* Length of name */
-	u16 valuelen;	/* Length of value */
+	__le16 valuelen;	/* Length of value */
 	char name[0];	/* Attribute name (includes null-terminator) */
 };			/* Value immediately follows name */
 
 struct jfs_ea_list {
-	u32 size;		/* overall size */
+	__le32 size;		/* overall size */
 	struct jfs_ea ea[0];	/* Variable length list */
 };
 
diff -Nru a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
--- a/fs/jfs/jfs_xtree.c	2004-12-24 13:36:49 -08:00
+++ b/fs/jfs/jfs_xtree.c	2004-12-24 13:36:49 -08:00
@@ -958,7 +958,7 @@
 
 	/* is inode xtree root extension/inline EA area free ? */
 	if ((sp->header.flag & BT_ROOT) && (!S_ISDIR(ip->i_mode)) &&
-	    (sp->header.maxentry < cpu_to_le16(XTROOTMAXSLOT)) &&
+	    (le16_to_cpu(sp->header.maxentry) < XTROOTMAXSLOT) &&
 	    (JFS_IP(ip)->mode2 & INLINEEA)) {
 		sp->header.maxentry = cpu_to_le16(XTROOTMAXSLOT);
 		JFS_IP(ip)->mode2 &= ~INLINEEA;
@@ -1622,7 +1622,6 @@
 	s64 xaddr;
 	struct tlock *tlck;
 	struct xtlock *xtlck = NULL;
-	int rootsplit = 0;
 
 	jfs_info("xtExtend: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen);
 
@@ -1678,8 +1677,6 @@
 	 * The xtSplitUp() will insert the entry and unpin the leaf page.
 	 */
 	if (nextindex == le16_to_cpu(p->header.maxentry)) {
-		rootsplit = p->header.flag & BT_ROOT;
-
 		/* xtSpliUp() unpins leaf pages */
 		split.mp = mp;
 		split.index = index + 1;
@@ -1691,16 +1688,21 @@
 		if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
 			return rc;
 
+		/* get back old page */
+		XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+		if (rc)
+			return rc;
 		/*
 		 * if leaf root has been split, original root has been
 		 * copied to new child page, i.e., original entry now
 		 * resides on the new child page;
 		 */
-		if (rootsplit) {
+		if (p->header.flag & BT_INTERNAL) {
 			ASSERT(p->header.nextindex ==
 			       cpu_to_le16(XTENTRYSTART + 1));
 			xad = &p->xad[XTENTRYSTART];
 			bn = addressXAD(xad);
+			XT_PUTPAGE(mp);
 
 			/* get new child page */
 			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
@@ -1712,11 +1714,6 @@
 				tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
 				xtlck = (struct xtlock *) & tlck->lock;
 			}
-		} else {
-			/* get back old page */
-			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
-			if (rc)
-				return rc;
 		}
 	}
 	/*
@@ -1790,7 +1787,6 @@
 	struct xtlock *xtlck = 0;
 	struct tlock *mtlck;
 	struct maplock *pxdlock;
-	int rootsplit = 0;
 
 /*
 printf("xtTailgate: nxoff:0x%lx nxlen:0x%x nxaddr:0x%lx\n",
@@ -1848,8 +1844,6 @@
 	 * The xtSplitUp() will insert the entry and unpin the leaf page.
 	 */
 	if (nextindex == le16_to_cpu(p->header.maxentry)) {
-		rootsplit = p->header.flag & BT_ROOT;
-
 		/* xtSpliUp() unpins leaf pages */
 		split.mp = mp;
 		split.index = index + 1;
@@ -1861,16 +1855,21 @@
 		if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
 			return rc;
 
+		/* get back old page */
+		XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+		if (rc)
+			return rc;
 		/*
 		 * if leaf root has been split, original root has been
 		 * copied to new child page, i.e., original entry now
 		 * resides on the new child page;
 		 */
-		if (rootsplit) {
+		if (p->header.flag & BT_INTERNAL) {
 			ASSERT(p->header.nextindex ==
 			       cpu_to_le16(XTENTRYSTART + 1));
 			xad = &p->xad[XTENTRYSTART];
 			bn = addressXAD(xad);
+			XT_PUTPAGE(mp);
 
 			/* get new child page */
 			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
@@ -1882,11 +1881,6 @@
 				tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
 				xtlck = (struct xtlock *) & tlck->lock;
 			}
-		} else {
-			/* get back old page */
-			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
-			if (rc)
-				return rc;
 		}
 	}
 	/*
@@ -1976,7 +1970,7 @@
 	s64 nxaddr, xaddr;
 	struct tlock *tlck;
 	struct xtlock *xtlck = NULL;
-	int rootsplit = 0, newpage = 0;
+	int newpage = 0;
 
 	/* there must exist extent to be tailgated */
 	nxoff = offsetXAD(nxad);
@@ -2183,7 +2177,6 @@
 
 	/* insert nXAD:recorded */
 	if (nextindex == le16_to_cpu(p->header.maxentry)) {
-		rootsplit = p->header.flag & BT_ROOT;
 
 		/* xtSpliUp() unpins leaf pages */
 		split.mp = mp;
@@ -2196,16 +2189,21 @@
 		if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
 			return rc;
 
+		/* get back old page */
+		XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+		if (rc)
+			return rc;
 		/*
 		 * if leaf root has been split, original root has been
 		 * copied to new child page, i.e., original entry now
 		 * resides on the new child page;
 		 */
-		if (rootsplit) {
+		if (p->header.flag & BT_INTERNAL) {
 			ASSERT(p->header.nextindex ==
 			       cpu_to_le16(XTENTRYSTART + 1));
 			xad = &p->xad[XTENTRYSTART];
 			bn = addressXAD(xad);
+			XT_PUTPAGE(mp);
 
 			/* get new child page */
 			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
@@ -2218,11 +2216,6 @@
 				xtlck = (struct xtlock *) & tlck->lock;
 			}
 		} else {
-			/* get back old page */
-			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
-			if (rc)
-				return rc;
-
 			/* is nXAD on new page ? */
 			if (newindex >
 			    (le16_to_cpu(p->header.maxentry) >> 1)) {
@@ -2336,8 +2329,6 @@
 	xlen = xlen - nxlen;
 	xaddr = xaddr + nxlen;
 	if (nextindex == le16_to_cpu(p->header.maxentry)) {
-		rootsplit = p->header.flag & BT_ROOT;
-
 /*
 printf("xtUpdate.updateLeft.split p:0x%p\n", p);
 */
@@ -2352,16 +2343,22 @@
 		if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
 			return rc;
 
+		/* get back old page */
+		XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+		if (rc)
+			return rc;
+
 		/*
 		 * if leaf root has been split, original root has been
 		 * copied to new child page, i.e., original entry now
 		 * resides on the new child page;
 		 */
-		if (rootsplit) {
+		if (p->header.flag & BT_INTERNAL) {
 			ASSERT(p->header.nextindex ==
 			       cpu_to_le16(XTENTRYSTART + 1));
 			xad = &p->xad[XTENTRYSTART];
 			bn = addressXAD(xad);
+			XT_PUTPAGE(mp);
 
 			/* get new child page */
 			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
@@ -2373,11 +2370,6 @@
 				tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
 				xtlck = (struct xtlock *) & tlck->lock;
 			}
-		} else {
-			/* get back old page */
-			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
-			if (rc)
-				return rc;
 		}
 	} else {
 		/* if insert into middle, shift right remaining entries */
diff -Nru a/fs/jfs/jfs_xtree.h b/fs/jfs/jfs_xtree.h
--- a/fs/jfs/jfs_xtree.h	2004-12-24 13:37:30 -08:00
+++ b/fs/jfs/jfs_xtree.h	2004-12-24 13:37:30 -08:00
@@ -32,10 +32,10 @@
 	unsigned flag:8;	/* 1: flag */
 	unsigned rsvrd:16;	/* 2: reserved */
 	unsigned off1:8;	/* 1: offset in unit of fsblksize */
-	u32 off2;		/* 4: offset in unit of fsblksize */
+	__le32 off2;		/* 4: offset in unit of fsblksize */
 	unsigned len:24;	/* 3: length in unit of fsblksize */
 	unsigned addr1:8;	/* 1: address in unit of fsblksize */
-	u32 addr2;		/* 4: address in unit of fsblksize */
+	__le32 addr2;		/* 4: address in unit of fsblksize */
 } xad_t;			/* (16) */
 
 #define MAXXLEN         ((1 << 24) - 1)
@@ -90,14 +90,14 @@
  */
 typedef union {
 	struct xtheader {
-		s64 next;	/* 8: */
-		s64 prev;	/* 8: */
+		__le64 next;	/* 8: */
+		__le64 prev;	/* 8: */
 
 		u8 flag;	/* 1: */
 		u8 rsrvd1;	/* 1: */
-		s16 nextindex;	/* 2: next index = number of entries */
-		s16 maxentry;	/* 2: max number of entries */
-		s16 rsrvd2;	/* 2: */
+		__le16 nextindex;	/* 2: next index = number of entries */
+		__le16 maxentry;	/* 2: max number of entries */
+		__le16 rsrvd2;	/* 2: */
 
 		pxd_t self;	/* 8: self */
 	} header;		/* (32) */
diff -Nru a/fs/jfs/super.c b/fs/jfs/super.c
--- a/fs/jfs/super.c	2004-12-24 13:36:48 -08:00
+++ b/fs/jfs/super.c	2004-12-24 13:36:48 -08:00
@@ -403,6 +403,10 @@
 	}
 	sbi->flag = flag;
 
+#ifdef CONFIG_JFS_POSIX_ACL
+	sb->s_flags |= MS_POSIXACL;
+#endif
+
 	if (newLVSize) {
 		printk(KERN_ERR "resize option for remount only\n");
 		return -EINVAL;
diff -Nru a/fs/libfs.c b/fs/libfs.c
--- a/fs/libfs.c	2004-12-24 13:36:17 -08:00
+++ b/fs/libfs.c	2004-12-24 13:36:17 -08:00
@@ -391,13 +391,9 @@
 		return -ENOMEM;
 	}
 	for (i = 0; !files->name || files->name[0]; i++, files++) {
-		struct qstr name;
 		if (!files->name)
 			continue;
-		name.name = files->name;
-		name.len = strlen(name.name);
-		name.hash = full_name_hash(name.name, name.len);
-		dentry = d_alloc(root, &name);
+		dentry = d_alloc_name(root, files->name);
 		if (!dentry)
 			goto out;
 		inode = new_inode(s);
@@ -530,6 +526,7 @@
 EXPORT_SYMBOL(simple_dir_inode_operations);
 EXPORT_SYMBOL(simple_dir_operations);
 EXPORT_SYMBOL(simple_empty);
+EXPORT_SYMBOL(d_alloc_name);
 EXPORT_SYMBOL(simple_fill_super);
 EXPORT_SYMBOL(simple_getattr);
 EXPORT_SYMBOL(simple_link);
diff -Nru a/fs/lockd/Makefile b/fs/lockd/Makefile
--- a/fs/lockd/Makefile	2004-12-24 13:36:18 -08:00
+++ b/fs/lockd/Makefile	2004-12-24 13:36:18 -08:00
@@ -5,6 +5,6 @@
 obj-$(CONFIG_LOCKD) += lockd.o
 
 lockd-objs-y := clntlock.o clntproc.o host.o svc.o svclock.o svcshare.o \
-	        svcproc.o svcsubs.o mon.o xdr.o lockd_syms.o
+	        svcproc.o svcsubs.o mon.o xdr.o
 lockd-objs-$(CONFIG_LOCKD_V4) += xdr4.o svc4proc.o
 lockd-objs		      := $(lockd-objs-y)
diff -Nru a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
--- a/fs/lockd/clntproc.c	2004-12-24 13:37:43 -08:00
+++ b/fs/lockd/clntproc.c	2004-12-24 13:37:43 -08:00
@@ -7,6 +7,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
@@ -278,6 +279,7 @@
 	nlm_release_host(host);
 	return status;
 }
+EXPORT_SYMBOL(nlmclnt_proc);
 
 /*
  * Allocate an NLM RPC call struct
diff -Nru a/fs/lockd/host.c b/fs/lockd/host.c
--- a/fs/lockd/host.c	2004-12-24 13:36:56 -08:00
+++ b/fs/lockd/host.c	2004-12-24 13:36:56 -08:00
@@ -104,11 +104,7 @@
 	memset(host, 0, sizeof(*host));
 
 	addr = sin->sin_addr.s_addr;
-	sprintf(host->h_name, "%d.%d.%d.%d",
-			(unsigned char) (ntohl(addr) >> 24),
-			(unsigned char) (ntohl(addr) >> 16),
-			(unsigned char) (ntohl(addr) >>  8),
-			(unsigned char) (ntohl(addr) >>  0));
+	sprintf(host->h_name, "%u.%u.%u.%u", NIPQUAD(addr));
 
 	host->h_addr       = *sin;
 	host->h_addr.sin_port = 0;	/* ouch! */
diff -Nru a/fs/lockd/lockd_syms.c b/fs/lockd/lockd_syms.c
--- a/fs/lockd/lockd_syms.c	2004-12-24 13:36:57 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,36 +0,0 @@
-/*
- * linux/fs/lockd/lockd_syms.c
- *
- * Symbols exported by the lockd module.
- *
- * Authors:	Olaf Kirch (okir@monad.swb.de)
- *
- * Copyright (C) 1997 Olaf Kirch <okir@monad.swb.de>
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#ifdef CONFIG_MODULES
-
-#include <linux/types.h>
-#include <linux/socket.h>
-#include <linux/time.h>
-#include <linux/uio.h>
-#include <linux/unistd.h>
-
-#include <linux/sunrpc/clnt.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/lockd/lockd.h>
-
-/* Start/stop the daemon */
-EXPORT_SYMBOL(lockd_up);
-EXPORT_SYMBOL(lockd_down);
-
-/* NFS client entry */
-EXPORT_SYMBOL(nlmclnt_proc);
-
-/* NFS server entry points/hooks */
-EXPORT_SYMBOL(nlmsvc_ops);
-
-#endif /* CONFIG_MODULES */
diff -Nru a/fs/lockd/mon.c b/fs/lockd/mon.c
--- a/fs/lockd/mon.c	2004-12-24 13:37:03 -08:00
+++ b/fs/lockd/mon.c	2004-12-24 13:37:03 -08:00
@@ -140,7 +140,6 @@
 xdr_encode_common(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp)
 {
 	char	buffer[20];
-	u32	addr = ntohl(argp->addr);
 
 	/*
 	 * Use the dotted-quad IP address of the remote host as
@@ -148,8 +147,7 @@
 	 * hostname first for whatever remote hostname it receives,
 	 * so this works alright.
 	 */
-	sprintf(buffer, "%d.%d.%d.%d", (addr>>24) & 0xff, (addr>>16) & 0xff,
-				 	(addr>>8) & 0xff,  (addr) & 0xff);
+	sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(argp->addr));
 	if (!(p = xdr_encode_string(p, buffer))
 	 || !(p = xdr_encode_string(p, system_utsname.nodename)))
 		return ERR_PTR(-EIO);
diff -Nru a/fs/lockd/svc.c b/fs/lockd/svc.c
--- a/fs/lockd/svc.c	2004-12-24 13:37:00 -08:00
+++ b/fs/lockd/svc.c	2004-12-24 13:37:00 -08:00
@@ -39,7 +39,10 @@
 #define ALLOWED_SIGS		(sigmask(SIGKILL))
 
 extern struct svc_program	nlmsvc_program;
+
 struct nlmsvc_binding *		nlmsvc_ops;
+EXPORT_SYMBOL(nlmsvc_ops);
+
 static DECLARE_MUTEX(nlmsvc_sema);
 static unsigned int		nlmsvc_users;
 static pid_t			nlmsvc_pid;
@@ -270,6 +273,7 @@
 	up(&nlmsvc_sema);
 	return error;
 }
+EXPORT_SYMBOL(lockd_up);
 
 /*
  * Decrement the user count and bring down lockd if we're the last.
@@ -311,6 +315,7 @@
 out:
 	up(&nlmsvc_sema);
 }
+EXPORT_SYMBOL(lockd_down);
 
 /*
  * Sysctl parameters (same as module parameters, different interface).
diff -Nru a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
--- a/fs/lockd/svc4proc.c	2004-12-24 13:36:47 -08:00
+++ b/fs/lockd/svc4proc.c	2004-12-24 13:36:47 -08:00
@@ -546,10 +546,10 @@
    .pc_ressize	= sizeof(struct nlm_##rest),		\
    .pc_xdrressize = respsize,				\
  }
-#define	Ck	(1+8)	/* cookie */
-#define	No	(1+1024/4)	/* netobj */
-#define	St	1	/* status */
-#define	Rg	4	/* range (offset + length) */
+#define	Ck	(1+XDR_QUADLEN(NLM_MAXCOOKIELEN))	/* cookie */
+#define	No	(1+1024/4)				/* netobj */
+#define	St	1					/* status */
+#define	Rg	4					/* range (offset + length) */
 struct svc_procedure		nlmsvc_procedures4[] = {
   PROC(null,		void,		void,		void,	void, 1),
   PROC(test,		testargs,	testres,	args,	res, Ck+St+2+No+Rg),
diff -Nru a/fs/lockd/svclock.c b/fs/lockd/svclock.c
--- a/fs/lockd/svclock.c	2004-12-24 13:36:31 -08:00
+++ b/fs/lockd/svclock.c	2004-12-24 13:36:31 -08:00
@@ -112,11 +112,11 @@
 				(long long)lock->fl.fl_end, lock->fl.fl_type);
 	for (head = &nlm_blocked; (block = *head) != 0; head = &block->b_next) {
 		fl = &block->b_call.a_args.lock.fl;
-		dprintk("lockd: check f=%p pd=%d %Ld-%Ld ty=%d cookie=%x\n",
+		dprintk("lockd: check f=%p pd=%d %Ld-%Ld ty=%d cookie=%s\n",
 				block->b_file, fl->fl_pid,
 				(long long)fl->fl_start,
 				(long long)fl->fl_end, fl->fl_type,
-				*(unsigned int*)(block->b_call.a_args.cookie.data));
+				nlmdbg_cookie2a(&block->b_call.a_args.cookie));
 		if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) {
 			if (remove) {
 				*head = block->b_next;
@@ -584,13 +584,13 @@
 	struct sockaddr_in	*peer_addr = RPC_PEERADDR(task->tk_client);
 
 	dprintk("lockd: GRANT_MSG RPC callback\n");
-	dprintk("callback: looking for cookie %x, host (%08x)\n", 
-		*(unsigned int *)(call->a_args.cookie.data),
-		ntohl(peer_addr->sin_addr.s_addr));
+	dprintk("callback: looking for cookie %s, host (%u.%u.%u.%u)\n",
+		nlmdbg_cookie2a(&call->a_args.cookie),
+		NIPQUAD(peer_addr->sin_addr.s_addr));
 	if (!(block = nlmsvc_find_block(&call->a_args.cookie, peer_addr))) {
-		dprintk("lockd: no block for cookie %x, host (%08x)\n",
-			*(u32 *)(call->a_args.cookie.data),
-			ntohl(peer_addr->sin_addr.s_addr));
+		dprintk("lockd: no block for cookie %s, host (%u.%u.%u.%u)\n",
+			nlmdbg_cookie2a(&call->a_args.cookie),
+			NIPQUAD(peer_addr->sin_addr.s_addr));
 		return;
 	}
 
diff -Nru a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
--- a/fs/lockd/svcproc.c	2004-12-24 13:37:01 -08:00
+++ b/fs/lockd/svcproc.c	2004-12-24 13:37:01 -08:00
@@ -571,10 +571,10 @@
    .pc_xdrressize = respsize,				\
  }
 
-#define	Ck	(1+8)	/* cookie */
-#define	St	1	/* status */
-#define	No	(1+1024/4) /* Net Obj */
-#define	Rg	2	/* range - offset + size */
+#define	Ck	(1+XDR_QUADLEN(NLM_MAXCOOKIELEN))	/* cookie */
+#define	St	1				/* status */
+#define	No	(1+1024/4)			/* Net Obj */
+#define	Rg	2				/* range - offset + size */
 
 struct svc_procedure		nlmsvc_procedures[] = {
   PROC(null,		void,		void,		void,	void, 1),
diff -Nru a/fs/lockd/xdr.c b/fs/lockd/xdr.c
--- a/fs/lockd/xdr.c	2004-12-24 13:36:17 -08:00
+++ b/fs/lockd/xdr.c	2004-12-24 13:36:17 -08:00
@@ -55,16 +55,16 @@
 		c->len=4;
 		memset(c->data, 0, 4);	/* hockeypux brain damage */
 	}
-	else if(len<=8)
+	else if(len<=NLM_MAXCOOKIELEN)
 	{
 		c->len=len;
 		memcpy(c->data, p, len);
-		p+=(len+3)>>2;
+		p+=XDR_QUADLEN(len);
 	}
 	else 
 	{
 		printk(KERN_NOTICE
-			"lockd: bad cookie size %d (only cookies under 8 bytes are supported.)\n", len);
+			"lockd: bad cookie size %d (only cookies under %d bytes are supported.)\n", len, NLM_MAXCOOKIELEN);
 		return NULL;
 	}
 	return p;
@@ -75,7 +75,7 @@
 {
 	*p++ = htonl(c->len);
 	memcpy(p, c->data, c->len);
-	p+=(c->len+3)>>2;
+	p+=XDR_QUADLEN(c->len);
 	return p;
 }
 
@@ -86,7 +86,7 @@
 
 	if ((len = ntohl(*p++)) != NFS2_FHSIZE) {
 		printk(KERN_NOTICE
-			"lockd: bad fhandle size %x (should be %d)\n",
+			"lockd: bad fhandle size %d (should be %d)\n",
 			len, NFS2_FHSIZE);
 		return NULL;
 	}
@@ -512,11 +512,11 @@
  * Buffer requirements for NLM
  */
 #define NLM_void_sz		0
-#define NLM_cookie_sz		3	/* 1 len , 2 data */
-#define NLM_caller_sz		1+QUADLEN(sizeof(system_utsname.nodename))
-#define NLM_netobj_sz		1+QUADLEN(XDR_MAX_NETOBJ)
-/* #define NLM_owner_sz		1+QUADLEN(NLM_MAXOWNER) */
-#define NLM_fhandle_sz		1+QUADLEN(NFS2_FHSIZE)
+#define NLM_cookie_sz		1+XDR_QUADLEN(NLM_MAXCOOKIELEN)
+#define NLM_caller_sz		1+XDR_QUADLEN(sizeof(system_utsname.nodename))
+#define NLM_netobj_sz		1+XDR_QUADLEN(XDR_MAX_NETOBJ)
+/* #define NLM_owner_sz		1+XDR_QUADLEN(NLM_MAXOWNER) */
+#define NLM_fhandle_sz		1+XDR_QUADLEN(NFS2_FHSIZE)
 #define NLM_lock_sz		3+NLM_caller_sz+NLM_netobj_sz+NLM_fhandle_sz
 #define NLM_holder_sz		4+NLM_netobj_sz
 
@@ -604,3 +604,32 @@
 		.stats		= &nlm_stats,
 };
 
+#ifdef RPC_DEBUG
+const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie)
+{
+	/*
+	 * We can get away with a static buffer because we're only
+	 * called with BKL held.
+	 */
+	static char buf[2*NLM_MAXCOOKIELEN+1];
+	int i;
+	int len = sizeof(buf);
+	char *p = buf;
+
+	len--;	/* allow for trailing \0 */
+	if (len < 3)
+		return "???";
+	for (i = 0 ; i < cookie->len ; i++) {
+		if (len < 2) {
+			strcpy(p-3, "...");
+			break;
+		}
+		sprintf(p, "%02x", cookie->data[i]);
+		p += 2;
+		len -= 2;
+	}
+	*p = '\0';
+
+	return buf;
+}
+#endif
diff -Nru a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
--- a/fs/lockd/xdr4.c	2004-12-24 13:36:17 -08:00
+++ b/fs/lockd/xdr4.c	2004-12-24 13:36:17 -08:00
@@ -56,16 +56,16 @@
 		c->len=4;
 		memset(c->data, 0, 4);	/* hockeypux brain damage */
 	}
-	else if(len<=8)
+	else if(len<=NLM_MAXCOOKIELEN)
 	{
 		c->len=len;
 		memcpy(c->data, p, len);
-		p+=(len+3)>>2;
+		p+=XDR_QUADLEN(len);
 	}
 	else 
 	{
 		printk(KERN_NOTICE
-			"lockd: bad cookie size %d (only cookies under 8 bytes are supported.)\n", len);
+			"lockd: bad cookie size %d (only cookies under %d bytes are supported.)\n", len, NLM_MAXCOOKIELEN);
 		return NULL;
 	}
 	return p;
@@ -76,7 +76,7 @@
 {
 	*p++ = htonl(c->len);
 	memcpy(p, c->data, c->len);
-	p+=(c->len+3)>>2;
+	p+=XDR_QUADLEN(c->len);
 	return p;
 }
 
@@ -515,7 +515,7 @@
  * Buffer requirements for NLM
  */
 #define NLM4_void_sz		0
-#define NLM4_cookie_sz		3	/* 1 len , 2 data */
+#define NLM4_cookie_sz		1+XDR_QUADLEN(NLM_MAXCOOKIELEN)
 #define NLM4_caller_sz		1+XDR_QUADLEN(NLM_MAXSTRLEN)
 #define NLM4_netobj_sz		1+XDR_QUADLEN(XDR_MAX_NETOBJ)
 /* #define NLM4_owner_sz		1+XDR_QUADLEN(NLM4_MAXOWNER) */
diff -Nru a/fs/locks.c b/fs/locks.c
--- a/fs/locks.c	2004-12-24 13:37:20 -08:00
+++ b/fs/locks.c	2004-12-24 13:37:20 -08:00
@@ -122,6 +122,7 @@
 #include <linux/security.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
+#include <linux/syscalls.h>
 #include <linux/time.h>
 
 #include <asm/semaphore.h>
@@ -172,7 +173,12 @@
 			fl->fl_ops->fl_release_private(fl);
 		fl->fl_ops = NULL;
 	}
-	fl->fl_lmops = NULL;
+
+	if (fl->fl_lmops) {
+		if (fl->fl_lmops->fl_release_private)
+			fl->fl_lmops->fl_release_private(fl);
+		fl->fl_lmops = NULL;
+	}
 
 	kmem_cache_free(filelock_cache, fl);
 }
@@ -227,6 +233,8 @@
 	new->fl_lmops = fl->fl_lmops;
 	if (fl->fl_ops && fl->fl_ops->fl_copy_lock)
 		fl->fl_ops->fl_copy_lock(new, fl);
+	if (fl->fl_lmops && fl->fl_lmops->fl_copy_lock)
+		fl->fl_lmops->fl_copy_lock(new, fl);
 }
 
 EXPORT_SYMBOL(locks_copy_lock);
@@ -383,13 +391,31 @@
 }
 #endif
 
-/* Allocate a file_lock initialised to this type of lease */
-static int lease_alloc(struct file *filp, int type, struct file_lock **flp)
+/* default lease lock manager operations */
+static void lease_break_callback(struct file_lock *fl)
 {
-	struct file_lock *fl = locks_alloc_lock();
-	if (fl == NULL)
-		return -ENOMEM;
+	kill_fasync(&fl->fl_fasync, SIGIO, POLL_MSG);
+}
 
+static void lease_release_private_callback(struct file_lock *fl)
+{
+	if (!fl->fl_file)
+		return;
+
+	f_delown(fl->fl_file);
+	fl->fl_file->f_owner.signum = 0;
+}
+
+struct lock_manager_operations lease_manager_ops = {
+	.fl_break = lease_break_callback,
+	.fl_release_private = lease_release_private_callback,
+};
+
+/*
+ * Initialize a lease, use the default lock manager operations
+ */
+static int lease_init(struct file *filp, int type, struct file_lock *fl)
+ {
 	fl->fl_owner = current->files;
 	fl->fl_pid = current->tgid;
 
@@ -402,8 +428,22 @@
 	fl->fl_start = 0;
 	fl->fl_end = OFFSET_MAX;
 	fl->fl_ops = NULL;
-	fl->fl_lmops = NULL;
+	fl->fl_lmops = &lease_manager_ops;
+	return 0;
+}
+
+/* Allocate a file_lock initialised to this type of lease */
+static int lease_alloc(struct file *filp, int type, struct file_lock **flp)
+{
+	struct file_lock *fl = locks_alloc_lock();
+	int error;
+
+	if (fl == NULL)
+		return -ENOMEM;
 
+	error = lease_init(filp, type, fl);
+	if (error)
+		return error;
 	*flp = fl;
 	return 0;
 }
@@ -1026,13 +1066,8 @@
 	if (error)
 		return error;
 	locks_wake_up_blocks(fl);
-	if (arg == F_UNLCK) {
-		struct file *filp = fl->fl_file;
-
-		f_delown(filp);
-		filp->f_owner.signum = 0;
+	if (arg == F_UNLCK)
 		locks_delete_lock(before);
-	}
 	return 0;
 }
 
@@ -1055,6 +1090,26 @@
 	}
 }
 
+ /**
+*	remove_lease - let time_out_leases remove the lease.
+*	@@file_lock: the lease to remove
+*/
+void remove_lease(struct file_lock *fl)
+{
+	if (!IS_LEASE(fl))
+		return;
+
+	lock_kernel();
+
+	fl->fl_type = F_UNLCK | F_INPROGRESS;
+	fl->fl_break_time = jiffies - 10;
+	time_out_leases(fl->fl_file->f_dentry->d_inode);
+
+	unlock_kernel();
+}
+
+EXPORT_SYMBOL(remove_lease);
+
 /**
  *	__break_lease	-	revoke all outstanding leases on file
  *	@inode: the inode of the file to return
@@ -1119,7 +1174,10 @@
 		if (fl->fl_type != future) {
 			fl->fl_type = future;
 			fl->fl_break_time = break_time;
-			kill_fasync(&fl->fl_fasync, SIGIO, POLL_MSG);
+			if (fl->fl_lmops && fl->fl_lmops->fl_break)
+				fl->fl_lmops->fl_break(fl);
+			else    /* lease must have lmops break callback */
+				BUG();
 		}
 	}
 
@@ -1219,45 +1277,36 @@
 }
 
 /**
- *	fcntl_setlease	-	sets a lease on an open file
- *	@fd: open file descriptor
+ *	__setlease	-	sets a lease on an open file
  *	@filp: file pointer
  *	@arg: type of lease to obtain
+ *	@flp: input - file_lock to use, output - file_lock inserted
  *
- *	Call this fcntl to establish a lease on the file.
- *	Note that you also need to call %F_SETSIG to
- *	receive a signal when the lease is broken.
+ *	The (input) flp->fl_lmops->fl_break function is required
+ *	by break_lease().
+ *
+ *	Called with kernel lock held.
  */
-int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
+int __setlease(struct file *filp, long arg, struct file_lock **flp)
 {
-	struct file_lock *fl, **before, **my_before = NULL;
-	struct dentry *dentry;
-	struct inode *inode;
+	struct file_lock *fl, **before, **my_before = NULL, *lease = *flp;
+	struct dentry *dentry = filp->f_dentry;
+	struct inode *inode = dentry->d_inode;
 	int error, rdlease_count = 0, wrlease_count = 0;
 
-	dentry = filp->f_dentry;
-	inode = dentry->d_inode;
-
-	if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE))
-		return -EACCES;
-	if (!S_ISREG(inode->i_mode))
-		return -EINVAL;
-	error = security_file_lock(filp, arg);
-	if (error)
-		return error;
-
-	lock_kernel();
-
 	time_out_leases(inode);
 
-	/*
-	 * FIXME: What about F_RDLCK and files open for writing?
-	 */
+	error = -EINVAL;
+	if (!flp || !(*flp) || !(*flp)->fl_lmops || !(*flp)->fl_lmops->fl_break)
+		goto out;
+
 	error = -EAGAIN;
+	if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))
+		goto out;
 	if ((arg == F_WRLCK)
 	    && ((atomic_read(&dentry->d_count) > 1)
 		|| (atomic_read(&inode->i_count) > 1)))
-		goto out_unlock;
+		goto out;
 
 	/*
 	 * At this point, we know that if there is an exclusive
@@ -1285,32 +1334,111 @@
 
 	if ((arg == F_RDLCK && (wrlease_count > 0)) ||
 	    (arg == F_WRLCK && ((rdlease_count + wrlease_count) > 0)))
-		goto out_unlock;
+		goto out;
 
 	if (my_before != NULL) {
 		error = lease_modify(my_before, arg);
-		goto out_unlock;
+		goto out;
 	}
 
 	error = 0;
 	if (arg == F_UNLCK)
-		goto out_unlock;
+		goto out;
 
 	error = -EINVAL;
 	if (!leases_enable)
-		goto out_unlock;
+		goto out;
 
 	error = lease_alloc(filp, arg, &fl);
 	if (error)
+		goto out;
+
+	locks_copy_lock(fl, lease);
+
+	locks_insert_lock(before, fl);
+
+	*flp = fl;
+out:
+	return error;
+}
+
+ /**
+ *	setlease        -       sets a lease on an open file
+ *	@filp: file pointer
+ *	@arg: type of lease to obtain
+ *	@lease: file_lock to use
+ *
+ *	Call this to establish a lease on the file.
+ *	The fl_lmops fl_break function is required by break_lease
+ */
+
+int setlease(struct file *filp, long arg, struct file_lock **lease)
+{
+	struct dentry *dentry = filp->f_dentry;
+	struct inode *inode = dentry->d_inode;
+	int error;
+
+	if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE))
+		return -EACCES;
+	if (!S_ISREG(inode->i_mode))
+		return -EINVAL;
+	error = security_file_lock(filp, arg);
+	if (error)
+		return error;
+
+	lock_kernel();
+	error = __setlease(filp, arg, lease);
+	unlock_kernel();
+
+	return error;
+}
+
+EXPORT_SYMBOL(setlease);
+
+/**
+ *	fcntl_setlease	-	sets a lease on an open file
+ *	@fd: open file descriptor
+ *	@filp: file pointer
+ *	@arg: type of lease to obtain
+ *
+ *	Call this fcntl to establish a lease on the file.
+ *	Note that you also need to call %F_SETSIG to
+ *	receive a signal when the lease is broken.
+ */
+int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
+{
+	struct file_lock fl, *flp = &fl;
+	struct dentry *dentry = filp->f_dentry;
+	struct inode *inode = dentry->d_inode;
+	int error;
+
+	if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE))
+		return -EACCES;
+	if (!S_ISREG(inode->i_mode))
+		return -EINVAL;
+	error = security_file_lock(filp, arg);
+	if (error)
+		return error;
+
+	locks_init_lock(&fl);
+	error = lease_init(filp, arg, &fl);
+	if (error)
+		return error;
+
+	lock_kernel();
+
+	error = __setlease(filp, arg, &flp);
+	if (error)
 		goto out_unlock;
 
-	error = fasync_helper(fd, filp, 1, &fl->fl_fasync);
+	error = fasync_helper(fd, filp, 1, &flp->fl_fasync);
 	if (error < 0) {
-		locks_free_lock(fl);
+		/* remove lease just inserted by __setlease */
+		flp->fl_type = F_UNLCK | F_INPROGRESS;
+		flp->fl_break_time = jiffies- 10;
+		time_out_leases(inode);
 		goto out_unlock;
 	}
-
-	locks_insert_lock(before, fl);
 
 	error = f_setown(filp, current->pid, 0);
 out_unlock:
diff -Nru a/fs/mbcache.c b/fs/mbcache.c
--- a/fs/mbcache.c	2004-12-24 13:37:29 -08:00
+++ b/fs/mbcache.c	2004-12-24 13:37:29 -08:00
@@ -65,9 +65,7 @@
 EXPORT_SYMBOL(mb_cache_entry_alloc);
 EXPORT_SYMBOL(mb_cache_entry_insert);
 EXPORT_SYMBOL(mb_cache_entry_release);
-EXPORT_SYMBOL(mb_cache_entry_takeout);
 EXPORT_SYMBOL(mb_cache_entry_free);
-EXPORT_SYMBOL(mb_cache_entry_dup);
 EXPORT_SYMBOL(mb_cache_entry_get);
 #if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
 EXPORT_SYMBOL(mb_cache_entry_find_first);
@@ -456,23 +454,6 @@
 
 
 /*
- * mb_cache_entry_takeout()
- *
- * Take a cache entry out of the cache, making it invalid. The entry can later
- * be re-inserted using mb_cache_entry_insert(), or released using
- * mb_cache_entry_release().
- */
-void
-mb_cache_entry_takeout(struct mb_cache_entry *ce)
-{
-	spin_lock(&mb_cache_spinlock);
-	mb_assert(list_empty(&ce->e_lru_list));
-	__mb_cache_entry_unhash(ce);
-	spin_unlock(&mb_cache_spinlock);
-}
-
-
-/*
  * mb_cache_entry_free()
  *
  * This is equivalent to the sequence mb_cache_entry_takeout() --
@@ -485,20 +466,6 @@
 	mb_assert(list_empty(&ce->e_lru_list));
 	__mb_cache_entry_unhash(ce);
 	__mb_cache_entry_release_unlock(ce);
-}
-
-
-/*
- * mb_cache_entry_dup()
- *
- * Duplicate a handle to a cache entry (does not duplicate the cache entry
- * itself). After the call, both the old and the new handle must be released.
- */
-struct mb_cache_entry *
-mb_cache_entry_dup(struct mb_cache_entry *ce)
-{
-	atomic_inc(&ce->e_used);
-	return ce;
 }
 
 
diff -Nru a/fs/minix/bitmap.c b/fs/minix/bitmap.c
--- a/fs/minix/bitmap.c	2004-12-24 13:37:04 -08:00
+++ b/fs/minix/bitmap.c	2004-12-24 13:37:04 -08:00
@@ -14,7 +14,7 @@
 #include "minix.h"
 #include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 static int nibblemap[] = { 4,3,3,2,3,2,2,1,3,2,2,1,2,1,1,0 };
 
@@ -160,7 +160,8 @@
 
 static void minix_clear_inode(struct inode *inode)
 {
-	struct buffer_head *bh;
+	struct buffer_head *bh = NULL;
+
 	if (INODE_VERSION(inode) == MINIX_V1) {
 		struct minix_inode *raw_inode;
 		raw_inode = minix_V1_raw_inode(inode->i_sb, inode->i_ino, &bh);
@@ -188,24 +189,26 @@
 	struct buffer_head * bh;
 	unsigned long ino;
 
-	if (inode->i_ino < 1 || inode->i_ino > sbi->s_ninodes) {
-		printk("free_inode: inode 0 or nonexistent inode\n");
-		return;
-	}
 	ino = inode->i_ino;
+	if (ino < 1 || ino > sbi->s_ninodes) {
+		printk("minix_free_inode: inode 0 or nonexistent inode\n");
+		goto out;
+	}
 	if ((ino >> 13) >= sbi->s_imap_blocks) {
-		printk("free_inode: nonexistent imap in superblock\n");
-		return;
+		printk("minix_free_inode: nonexistent imap in superblock\n");
+		goto out;
 	}
 
+	minix_clear_inode(inode);	/* clear on-disk copy */
+
 	bh = sbi->s_imap[ino >> 13];
-	minix_clear_inode(inode);
-	clear_inode(inode);
 	lock_kernel();
 	if (!minix_test_and_clear_bit(ino & 8191, bh->b_data))
-		printk("free_inode: bit %lu already cleared.\n",ino);
+		printk("minix_free_inode: bit %lu already cleared.\n", ino);
 	unlock_kernel();
 	mark_buffer_dirty(bh);
+ out:
+	clear_inode(inode);		/* clear in-memory copy */
 }
 
 struct inode * minix_new_inode(const struct inode * dir, int * error)
diff -Nru a/fs/msdos/namei.c b/fs/msdos/namei.c
--- a/fs/msdos/namei.c	2004-12-24 13:37:33 -08:00
+++ b/fs/msdos/namei.c	2004-12-24 13:37:33 -08:00
@@ -501,8 +501,8 @@
 		mark_inode_dirty(new_inode);
 	}
 	if (dotdot_bh) {
-		dotdot_de->start = CT_LE_W(MSDOS_I(new_dir)->i_logstart);
-		dotdot_de->starthi = CT_LE_W((MSDOS_I(new_dir)->i_logstart) >> 16);
+		dotdot_de->start = cpu_to_le16(MSDOS_I(new_dir)->i_logstart);
+		dotdot_de->starthi = cpu_to_le16((MSDOS_I(new_dir)->i_logstart) >> 16);
 		mark_buffer_dirty(dotdot_bh);
 		old_dir->i_nlink--;
 		mark_inode_dirty(old_dir);
diff -Nru a/fs/namei.c b/fs/namei.c
--- a/fs/namei.c	2004-12-24 13:36:47 -08:00
+++ b/fs/namei.c	2004-12-24 13:36:47 -08:00
@@ -25,6 +25,7 @@
 #include <linux/smp_lock.h>
 #include <linux/personality.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 #include <linux/mount.h>
 #include <linux/audit.h>
 #include <asm/namei.h>
@@ -151,15 +152,19 @@
 	return result;
 }
 
-/*
- *	vfs_permission()
+/**
+ * generic_permission  -  check for access rights on a Posix-like filesystem
+ * @inode:	inode to check access rights for
+ * @mask:	right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
+ * @check_acl:	optional callback to check for Posix ACLs
  *
- * is used to check for read/write/execute permissions on a file.
+ * Used to check for read/write/execute permissions on a file.
  * We use "fsuid" for this, letting us set arbitrary permissions
  * for filesystem access without changing the "normal" uids which
  * are used for other things..
  */
-int vfs_permission(struct inode * inode, int mask)
+int generic_permission(struct inode *inode, int mask,
+		int (*check_acl)(struct inode *inode, int mask))
 {
 	umode_t			mode = inode->i_mode;
 
@@ -180,8 +185,18 @@
 
 	if (current->fsuid == inode->i_uid)
 		mode >>= 6;
-	else if (in_group_p(inode->i_gid))
-		mode >>= 3;
+	else {
+		if (IS_POSIXACL(inode) && (mode & S_IRWXG) && check_acl) {
+			int error = check_acl(inode, mask);
+			if (error == -EACCES)
+				goto check_capabilities;
+			else if (error != -EAGAIN)
+				return error;
+		}
+
+		if (in_group_p(inode->i_gid))
+			mode >>= 3;
+	}
 
 	/*
 	 * If the DACs are ok we don't need any capability check.
@@ -189,6 +204,7 @@
 	if (((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask))
 		return 0;
 
+ check_capabilities:
 	/*
 	 * Read/write DACs are always overridable.
 	 * Executable DACs are overridable if at least one exec bit is set.
@@ -219,7 +235,7 @@
 	if (inode->i_op && inode->i_op->permission)
 		retval = inode->i_op->permission(inode, submask, nd);
 	else
-		retval = vfs_permission(inode, submask);
+		retval = generic_permission(inode, submask, NULL);
 	if (retval)
 		return retval;
 
@@ -314,7 +330,7 @@
 /*
  * Short-cut version of permission(), for calling by
  * path_walk(), when dcache lock is held.  Combines parts
- * of permission() and vfs_permission(), and tests ONLY for
+ * of permission() and generic_permission(), and tests ONLY for
  * MAY_EXEC permission.
  *
  * If appropriate, check DAC only.  If not appropriate, or
@@ -2320,18 +2336,6 @@
 	}
 }
 
-int page_follow_link(struct dentry *dentry, struct nameidata *nd)
-{
-	struct page *page = NULL;
-	char *s = page_getlink(dentry, &page);
-	int res = __vfs_follow_link(nd, s);
-	if (page) {
-		kunmap(page);
-		page_cache_release(page);
-	}
-	return res;
-}
-
 int page_symlink(struct inode *inode, const char *symname, int len)
 {
 	struct address_space *mapping = inode->i_mapping;
@@ -2385,10 +2389,8 @@
 EXPORT_SYMBOL(get_write_access); /* binfmt_aout */
 EXPORT_SYMBOL(getname);
 EXPORT_SYMBOL(lock_rename);
-EXPORT_SYMBOL(lookup_create);
 EXPORT_SYMBOL(lookup_hash);
 EXPORT_SYMBOL(lookup_one_len);
-EXPORT_SYMBOL(page_follow_link);
 EXPORT_SYMBOL(page_follow_link_light);
 EXPORT_SYMBOL(page_put_link);
 EXPORT_SYMBOL(page_readlink);
@@ -2404,7 +2406,7 @@
 EXPORT_SYMBOL(vfs_link);
 EXPORT_SYMBOL(vfs_mkdir);
 EXPORT_SYMBOL(vfs_mknod);
-EXPORT_SYMBOL(vfs_permission);
+EXPORT_SYMBOL(generic_permission);
 EXPORT_SYMBOL(vfs_readlink);
 EXPORT_SYMBOL(vfs_rename);
 EXPORT_SYMBOL(vfs_rmdir);
diff -Nru a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c	2004-12-24 13:37:01 -08:00
+++ b/fs/namespace.c	2004-12-24 13:37:01 -08:00
@@ -9,6 +9,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/syscalls.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
@@ -105,8 +106,6 @@
 	return found;
 }
 
-EXPORT_SYMBOL(lookup_mnt);
-
 static inline int check_mnt(struct vfsmount *mnt)
 {
 	return mnt->mnt_namespace == current->namespace;
@@ -424,6 +423,7 @@
 		down_write(&sb->s_umount);
 		if (!(sb->s_flags & MS_RDONLY)) {
 			lock_kernel();
+			DQUOT_OFF(sb);
 			retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
 			unlock_kernel();
 		}
@@ -1208,8 +1208,6 @@
 	}
 }
 
-EXPORT_SYMBOL(set_fs_root);
-
 /*
  * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
  * It can block. Requires the big lock held.
@@ -1232,8 +1230,6 @@
 		mntput(old_pwdmnt);
 	}
 }
-
-EXPORT_SYMBOL(set_fs_pwd);
 
 static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
 {
diff -Nru a/fs/nfs/dir.c b/fs/nfs/dir.c
--- a/fs/nfs/dir.c	2004-12-24 13:36:49 -08:00
+++ b/fs/nfs/dir.c	2004-12-24 13:36:49 -08:00
@@ -1600,7 +1600,7 @@
 	return res;
 out_notsup:
 	nfs_revalidate_inode(NFS_SERVER(inode), inode);
-	res = vfs_permission(inode, mask);
+	res = generic_permission(inode, mask, NULL);
 	unlock_kernel();
 	return res;
 }
diff -Nru a/fs/nfs/direct.c b/fs/nfs/direct.c
--- a/fs/nfs/direct.c	2004-12-24 13:37:19 -08:00
+++ b/fs/nfs/direct.c	2004-12-24 13:37:19 -08:00
@@ -545,7 +545,7 @@
 {
 	ssize_t retval = -EINVAL;
 	loff_t *ppos = &iocb->ki_pos;
-	unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	unsigned long limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
 	struct file *file = iocb->ki_filp;
 	struct nfs_open_context *ctx =
 			(struct nfs_open_context *) file->private_data;
diff -Nru a/fs/nfsctl.c b/fs/nfsctl.c
--- a/fs/nfsctl.c	2004-12-24 13:37:31 -08:00
+++ b/fs/nfsctl.c	2004-12-24 13:37:31 -08:00
@@ -13,6 +13,7 @@
 #include <linux/linkage.h>
 #include <linux/namei.h>
 #include <linux/mount.h>
+#include <linux/syscalls.h>
 #include <asm/uaccess.h>
 
 /*
diff -Nru a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
--- a/fs/nfsd/nfs4proc.c	2004-12-24 13:37:32 -08:00
+++ b/fs/nfsd/nfs4proc.c	2004-12-24 13:37:32 -08:00
@@ -161,9 +161,6 @@
 }
 
 
-/*
- * nfs4_unlock_state() called in encode
- */
 static inline int
 nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
 {
@@ -182,7 +179,6 @@
 	if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
 		return nfserr_inval;
 
-	open->op_stateowner = NULL;
 	nfs4_lock_state();
 
 	/* check seqid for replay. set nfs4_owner */
@@ -201,7 +197,7 @@
 			status = NFSERR_REPLAY_ME;
 	}
 	if (status)
-		return status;
+		goto out;
 	if (open->op_claim_type == NFS4_OPEN_CLAIM_NULL) {
 	/*
 	 * This block of code will (1) set CURRENT_FH to the file being opened,
@@ -211,7 +207,7 @@
 	 */
 		status = do_open_lookup(rqstp, current_fh, open);
 		if (status)
-			return status;
+			goto out;
 	} else if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) {
 	/*
 	* The CURRENT_FH is already set to the file being opened. This
@@ -221,10 +217,11 @@
 	*/
 		status = do_open_fhandle(rqstp, current_fh, open);
 		if (status)
-			return status;
+			goto out;
 	} else {
 		printk("NFSD: unsupported OPEN claim type\n");
-		return nfserr_inval;
+		status = nfserr_inval;
+		goto out;
 	}
 	/*
 	 * nfsd4_process_open2() does the actual opening of the file.  If
@@ -232,9 +229,11 @@
 	 * set, (2) sets open->op_stateid, (3) sets open->op_delegation.
 	 */
 	status = nfsd4_process_open2(rqstp, current_fh, open);
-	if (status)
-		return status;
-	return 0;
+out:
+	if (open->op_stateowner)
+		nfs4_get_stateowner(open->op_stateowner);
+	nfs4_unlock_state();
+	return status;
 }
 
 /*
@@ -268,7 +267,7 @@
 	status = exp_pseudoroot(rqstp->rq_client, current_fh,
 			      &rqstp->rq_chandle);
 	if (!status)
-		status = nfsd_setuser(rqstp, current_fh->fh_export);
+		status = nfserrno(nfsd_setuser(rqstp, current_fh->fh_export));
 	return status;
 }
 
@@ -785,6 +784,7 @@
 	struct nfsd4_op	*op;
 	struct svc_fh	*current_fh = NULL;
 	struct svc_fh	*save_fh = NULL;
+	struct nfs4_stateowner *replay_owner = NULL;
 	int		slack_space;    /* in words, not bytes! */
 	int		status;
 
@@ -864,9 +864,7 @@
 			break;
 		case OP_CLOSE:
 			op->status = nfsd4_close(rqstp, current_fh, &op->u.close);
-			if (op->u.close.cl_stateowner)
-				op->replay =
-					&op->u.close.cl_stateowner->so_replay;
+			replay_owner = op->u.close.cl_stateowner;
 			break;
 		case OP_COMMIT:
 			op->status = nfsd4_commit(rqstp, current_fh, &op->u.commit);
@@ -885,18 +883,14 @@
 			break;
 		case OP_LOCK:
 			op->status = nfsd4_lock(rqstp, current_fh, &op->u.lock);
-			if (op->u.lock.lk_stateowner)
-				op->replay =
-					&op->u.lock.lk_stateowner->so_replay;
+			replay_owner = op->u.lock.lk_stateowner;
 			break;
 		case OP_LOCKT:
 			op->status = nfsd4_lockt(rqstp, current_fh, &op->u.lockt);
 			break;
 		case OP_LOCKU:
 			op->status = nfsd4_locku(rqstp, current_fh, &op->u.locku);
-			if (op->u.locku.lu_stateowner)
-				op->replay =
-					&op->u.locku.lu_stateowner->so_replay;
+			replay_owner = op->u.locku.lu_stateowner;
 			break;
 		case OP_LOOKUP:
 			op->status = nfsd4_lookup(rqstp, current_fh, &op->u.lookup);
@@ -911,21 +905,15 @@
 			break;
 		case OP_OPEN:
 			op->status = nfsd4_open(rqstp, current_fh, &op->u.open);
-			if (op->u.open.op_stateowner)
-				op->replay =
-					&op->u.open.op_stateowner->so_replay;
+			replay_owner = op->u.open.op_stateowner;
 			break;
 		case OP_OPEN_CONFIRM:
 			op->status = nfsd4_open_confirm(rqstp, current_fh, &op->u.open_confirm);
-			if (op->u.open_confirm.oc_stateowner)
-				op->replay =
-					&op->u.open_confirm.oc_stateowner->so_replay;
+			replay_owner = op->u.open_confirm.oc_stateowner;
 			break;
 		case OP_OPEN_DOWNGRADE:
 			op->status = nfsd4_open_downgrade(rqstp, current_fh, &op->u.open_downgrade);
-			if (op->u.open_downgrade.od_stateowner)
-				op->replay =
-					&op->u.open_downgrade.od_stateowner->so_replay;
+			replay_owner = op->u.open_downgrade.od_stateowner;
 			break;
 		case OP_PUTFH:
 			op->status = nfsd4_putfh(rqstp, current_fh, &op->u.putfh);
@@ -984,11 +972,16 @@
 
 encode_op:
 		if (op->status == NFSERR_REPLAY_ME) {
+			op->replay = &replay_owner->so_replay;
 			nfsd4_encode_replay(resp, op);
 			status = op->status = op->replay->rp_status;
 		} else {
 			nfsd4_encode_operation(resp, op);
 			status = op->status;
+		}
+		if (replay_owner && (replay_owner != (void *)(-1))) {
+			nfs4_put_stateowner(replay_owner);
+			replay_owner = NULL;
 		}
 	}
 
diff -Nru a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
--- a/fs/nfsd/nfs4state.c	2004-12-24 13:37:02 -08:00
+++ b/fs/nfsd/nfs4state.c	2004-12-24 13:37:02 -08:00
@@ -93,9 +93,6 @@
 	down(&client_sema);
 }
 
-/*
- * nfs4_unlock_state(); called in encode
- */
 void
 nfs4_unlock_state(void)
 {
@@ -833,6 +830,17 @@
 	}
 }
 
+/* should use a slab cache */
+void
+nfs4_free_stateowner(struct kref *kref)
+{
+	struct nfs4_stateowner *sop =
+		container_of(kref, struct nfs4_stateowner, so_ref);
+	kfree(sop->so_owner.data);
+	kfree(sop);
+	free_sowner++;
+}
+
 static inline struct nfs4_stateowner *
 alloc_stateowner(struct xdr_netobj *owner)
 {
@@ -842,6 +850,7 @@
 		if ((sop->so_owner.data = kmalloc(owner->len, GFP_KERNEL))) {
 			memcpy(sop->so_owner.data, owner->data, owner->len);
 			sop->so_owner.len = owner->len;
+			kref_init(&sop->so_ref);
 			return sop;
 		} 
 		kfree(sop);
@@ -849,17 +858,6 @@
 	return NULL;
 }
 
-/* should use a slab cache */
-static void
-free_stateowner(struct nfs4_stateowner *sop) {
-	if (sop) {
-		kfree(sop->so_owner.data);
-		kfree(sop);
-		sop = NULL;
-		free_sowner++;
-	}
-}
-
 static struct nfs4_stateowner *
 alloc_init_open_stateowner(unsigned int strhashval, struct nfs4_client *clp, struct nfsd4_open *open) {
 	struct nfs4_stateowner *sop;
@@ -932,7 +930,7 @@
 {
 	unhash_stateowner(sop);
 	list_del(&sop->so_close_lru);
-	free_stateowner(sop);
+	nfs4_put_stateowner(sop);
 }
 
 static inline void
@@ -1134,20 +1132,6 @@
 	return nfs_ok;
 }
 
-static inline int
-nfs4_file_upgrade(struct file *filp, unsigned int share_access)
-{
-int status;
-
-	if (share_access & NFS4_SHARE_ACCESS_WRITE) {
-		status = get_write_access(filp->f_dentry->d_inode);
-		if (status)
-			return nfserrno(status);
-		filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ;
-	}
-	return nfs_ok;
-}
-
 static inline void
 nfs4_file_downgrade(struct file *filp, unsigned int share_access)
 {
@@ -1252,18 +1236,119 @@
 		status = nfserr_reclaim_bad;
 	return status;
 }
+
+static int
+nfs4_check_open(struct nfs4_file *fp, struct nfs4_stateowner *sop, struct nfsd4_open *open, struct nfs4_stateid **stpp)
+{
+	struct nfs4_stateid *local;
+	int status = nfserr_share_denied;
+
+	list_for_each_entry(local, &fp->fi_perfile, st_perfile) {
+		/* have we seen this open owner */
+		if (local->st_stateowner == sop) {
+			*stpp = local;
+			continue;
+		}
+		/* ignore lock owners */
+		if (local->st_stateowner->so_is_open_owner == 0)
+			continue;
+		/* check for conflicting share reservations */
+		if (!test_share(local, open))
+			goto out;
+	}
+	status = 0;
+out:
+	return status;
+}
+
+static int
+nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
+		struct svc_fh *cur_fh, int flags)
+{
+	struct nfs4_stateid *stp;
+	int status;
+
+	stp = kmalloc(sizeof(struct nfs4_stateid), GFP_KERNEL);
+	if (stp == NULL)
+		return nfserr_resource;
+
+	status = nfsd_open(rqstp, cur_fh, S_IFREG, flags, &stp->st_vfs_file);
+	if (status) {
+		if (status == nfserr_dropit)
+			status = nfserr_jukebox;
+		kfree(stp);
+		return status;
+	}
+	vfsopen++;
+	stp->st_vfs_set = 1;
+	*stpp = stp;
+	return 0;
+}
+
+static int
+nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open)
+{
+	struct file *filp = stp->st_vfs_file;
+	struct inode *inode = filp->f_dentry->d_inode;
+	unsigned int share_access;
+	int status;
+
+	set_access(&share_access, stp->st_access_bmap);
+	share_access = ~share_access;
+	share_access &= open->op_share_access;
+
+	/* update the struct file */
+	if (share_access & NFS4_SHARE_ACCESS_WRITE) {
+		status = get_write_access(inode);
+		if (status)
+			return nfserrno(status);
+		if (open->op_truncate) {
+			struct iattr iattr = {
+				.ia_valid = ATTR_SIZE,
+				.ia_size = 0,
+			};
+			status = nfsd_setattr(rqstp, cur_fh, &iattr, 0,
+					(time_t)0);
+			if (status) {
+				put_write_access(inode);
+				return status;
+			}
+		}
+
+		/* remember the open */
+		filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ;
+		set_bit(open->op_share_access, &stp->st_access_bmap);
+		set_bit(open->op_share_deny, &stp->st_deny_bmap);
+	}
+	return nfs_ok;
+}
+
+
+/* decrement seqid on successful reclaim, it will be bumped in encode_open */
+static void
+nfs4_set_claim_prev(struct nfsd4_open *open, int *status)
+{
+	if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) {
+		if (*status)
+			*status = nfserr_reclaim_bad;
+		else {
+			open->op_stateowner->so_confirmed = 1;
+			open->op_stateowner->so_seqid--;
+		}
+	}
+}
+
 /*
  * called with nfs4_lock_state() held.
  */
 int
 nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
 {
-	struct iattr iattr;
 	struct nfs4_stateowner *sop = open->op_stateowner;
 	struct nfs4_file *fp = NULL;
 	struct inode *ino;
 	unsigned int fi_hashval;
-	struct nfs4_stateid *stq, *stp = NULL;
+	struct nfs4_stateid *stp = NULL;
 	int status;
 
 	status = nfserr_resource;
@@ -1275,110 +1360,76 @@
 	status = nfserr_inval;
 	if (!TEST_ACCESS(open->op_share_access) || !TEST_DENY(open->op_share_deny))
 		goto out;
-
+	/*
+	 * Lookup file; if found, lookup stateid and check open request;
+	 * not found, create
+	 */
 	fi_hashval = file_hashval(ino);
 	if (find_file(fi_hashval, ino, &fp)) {
-		/* Search for conflicting share reservations */
-		status = nfserr_share_denied;
-		list_for_each_entry(stq, &fp->fi_perfile, st_perfile) {
-			if (stq->st_stateowner == sop) {
-				stp = stq;
-				continue;
-			}
-			/* ignore lock owners */
-			if (stq->st_stateowner->so_is_open_owner == 0)
-				continue;
-			if (!test_share(stq,open))	
-				goto out;
-		}
+		status = nfs4_check_open(fp, sop, open, &stp);
+		if (status)
+			goto out;
 	} else {
-	/* No nfs4_file found; allocate and init a new one */
 		status = nfserr_resource;
 		if ((fp = alloc_init_file(fi_hashval, ino)) == NULL)
 			goto out;
 	}
 
-	if (!stp) {
-		int flags = 0;
-
-		status = nfserr_resource;
-		if ((stp = kmalloc(sizeof(struct nfs4_stateid),
-						GFP_KERNEL)) == NULL)
+	/*
+	 * OPEN the file, or upgrade an existing OPEN.
+	 * If truncate fails, the OPEN fails.
+	 */
+	if (stp) {
+		/* Stateid was found, this is an OPEN upgrade */
+		status = nfs4_upgrade_open(rqstp, current_fh, stp, open);
+		if (status)
 			goto out;
-
+	} else {
+		/* Stateid was not found, this is a new OPEN */
+		int flags = 0;
 		if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE)
 			flags = MAY_WRITE;
 		else
 			flags = MAY_READ;
-		if ((status = nfsd_open(rqstp, current_fh,  S_IFREG,
-			                      flags,
-			                      &stp->st_vfs_file)) != 0)
-			goto out_free;
-
-		vfsopen++;
-
-		init_stateid(stp, fp, sop, open);
-		stp->st_vfs_set = 1;
-	} else {
-		/* This is an upgrade of an existing OPEN. 
-		 * OR the incoming share with the existing 
-		 * nfs4_stateid share */
-		unsigned int share_access;
-
-		set_access(&share_access, stp->st_access_bmap);
-		share_access = ~share_access;
-		share_access &= open->op_share_access;
-
-		/* update the struct file */
-		if ((status = nfs4_file_upgrade(stp->st_vfs_file, share_access)))
+		if ((status = nfs4_new_open(rqstp, &stp, current_fh, flags)))
 			goto out;
-		/* remember the open */
-		set_bit(open->op_share_access, &stp->st_access_bmap);
-		set_bit(open->op_share_deny, &stp->st_deny_bmap);
-		/* bump the stateid */
-		update_stateid(&stp->st_stateid);
+		init_stateid(stp, fp, sop, open);
+		if (open->op_truncate) {
+			struct iattr iattr = {
+				.ia_valid = ATTR_SIZE,
+				.ia_size = 0,
+			};
+			status = nfsd_setattr(rqstp, current_fh, &iattr, 0,
+					(time_t)0);
+			if (status) {
+				release_stateid(stp, OPEN_STATE);
+				goto out;
+			}
+		}
 	}
-	dprintk("nfs4_process_open2: stateid=(%08x/%08x/%08x/%08x)\n\n",
+	dprintk("nfs4_process_open2: stateid=(%08x/%08x/%08x/%08x)\n",
 	            stp->st_stateid.si_boot, stp->st_stateid.si_stateownerid,
 	            stp->st_stateid.si_fileid, stp->st_stateid.si_generation);
 
-	if (open->op_truncate) {
-		iattr.ia_valid = ATTR_SIZE;
-		iattr.ia_size = 0;
-		status = nfsd_setattr(rqstp, current_fh, &iattr, 0, (time_t)0);
-		if (status)
-			goto out;
-	}
 	memcpy(&open->op_stateid, &stp->st_stateid, sizeof(stateid_t));
 
 	open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE;
 	status = nfs_ok;
 out:
+	/* take the opportunity to clean up unused state */
 	if (fp && list_empty(&fp->fi_perfile))
 		release_file(fp);
 
-	if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) {
-		if (status)
-			status = nfserr_reclaim_bad;
-		else {
-		/* successful reclaim. so_seqid is decremented because
-		* it will be bumped in encode_open
-		*/
-			open->op_stateowner->so_confirmed = 1;
-			open->op_stateowner->so_seqid--;
-		}
-	}
+	/* CLAIM_PREVIOUS has different error returns */
+	nfs4_set_claim_prev(open, &status);
 	/*
 	* To finish the open response, we just need to set the rflags.
 	*/
-	open->op_rflags = 0;
+	open->op_rflags = NFS4_OPEN_RESULT_LOCKTYPE_POSIX;
 	if (!open->op_stateowner->so_confirmed)
 		open->op_rflags |= NFS4_OPEN_RESULT_CONFIRM;
 
 	return status;
-out_free:
-	kfree(stp);
-	goto out;
 }
 
 static struct work_struct laundromat_work;
@@ -1460,7 +1511,7 @@
 		dprintk("NFSD: purging unused open stateowner (so_id %d)\n",
 			sop->so_id);
 		list_del(&sop->so_close_lru);
-		free_stateowner(sop);
+		nfs4_put_stateowner(sop);
 	}
 	if (clientid_val < NFSD_LAUNDROMAT_MINTIMEOUT)
 		clientid_val = NFSD_LAUNDROMAT_MINTIMEOUT;
@@ -1710,9 +1761,6 @@
 		clp->cl_first_state = get_seconds();
 }
 
-/*
- * nfs4_unlock_state(); called in encode
- */
 int
 nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc)
 {
@@ -1727,7 +1775,6 @@
 	if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0)))
 		goto out;
 
-	oc->oc_stateowner = NULL;
 	nfs4_lock_state();
 
 	if ((status = nfs4_preprocess_seqid_op(current_fh, oc->oc_seqid,
@@ -1749,6 +1796,9 @@
 	status = nfs_ok;
 	first_state(sop->so_client);
 out:
+	if (oc->oc_stateowner)
+		nfs4_get_stateowner(oc->oc_stateowner);
+	nfs4_unlock_state();
 	return status;
 }
 
@@ -1777,10 +1827,6 @@
 	}
 }
 
-/*
- * nfs4_unlock_state(); called in encode
- */
-
 int
 nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od)
 {
@@ -1792,10 +1838,8 @@
 			(int)current_fh->fh_dentry->d_name.len,
 			current_fh->fh_dentry->d_name.name);
 
-	od->od_stateowner = NULL;
-	status = nfserr_inval;
 	if (!TEST_ACCESS(od->od_share_access) || !TEST_DENY(od->od_share_deny))
-		goto out;
+		return nfserr_inval;
 
 	nfs4_lock_state();
 	if ((status = nfs4_preprocess_seqid_op(current_fh, od->od_seqid, 
@@ -1826,6 +1870,9 @@
 	memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t));
 	status = nfs_ok;
 out:
+	if (od->od_stateowner)
+		nfs4_get_stateowner(od->od_stateowner);
+	nfs4_unlock_state();
 	return status;
 }
 
@@ -1842,7 +1889,6 @@
 			(int)current_fh->fh_dentry->d_name.len,
 			current_fh->fh_dentry->d_name.name);
 
-	close->cl_stateowner = NULL;
 	nfs4_lock_state();
 	/* check close_lru for replay */
 	if ((status = nfs4_preprocess_seqid_op(current_fh, close->cl_seqid, 
@@ -1860,6 +1906,9 @@
 	/* release_state_owner() calls nfsd_close() if needed */
 	release_state_owner(stp, &close->cl_stateowner, OPEN_STATE);
 out:
+	if (close->cl_stateowner)
+		nfs4_get_stateowner(close->cl_stateowner);
+	nfs4_unlock_state();
 	return status;
 }
 
@@ -1953,8 +2002,11 @@
 	unsigned int hval = lockownerid_hashval(sop->so_id);
 
 	deny->ld_sop = NULL;
-	if (nfs4_verify_lock_stateowner(sop, hval))
+	if (nfs4_verify_lock_stateowner(sop, hval)) {
+		kref_get(&sop->so_ref);
 		deny->ld_sop = sop;
+		deny->ld_clientid = sop->so_client->cl_clientid;
+	}
 	deny->ld_start = fl->fl_start;
 	deny->ld_length = ~(u64)0;
 	if (fl->fl_end != ~(u64)0)
@@ -2078,8 +2130,6 @@
 
 /*
  *  LOCK operation 
- *
- * nfs4_unlock_state(); called in encode
  */
 int
 nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock)
@@ -2104,7 +2154,6 @@
 	if (check_lock_length(lock->lk_offset, lock->lk_length))
 		 return nfserr_inval;
 
-	lock->lk_stateowner = NULL;
 	nfs4_lock_state();
 
 	if (lock->lk_is_new) {
@@ -2160,6 +2209,7 @@
 		if ((lock_stp = alloc_init_lock_stateid(lock->lk_stateowner, 
 						fp, open_stp)) == NULL) {
 			release_stateowner(lock->lk_stateowner);
+			lock->lk_stateowner = NULL;
 			goto out;
 		}
 		/* bump the open seqid used to create the lock */
@@ -2258,6 +2308,9 @@
 		release_state_owner(lock_stp, &lock->lk_stateowner, LOCK_STATE);
 	}
 out:
+	if (lock->lk_stateowner)
+		nfs4_get_stateowner(lock->lk_stateowner);
+	nfs4_unlock_state();
 	return status;
 }
 
@@ -2366,7 +2419,6 @@
 	if (check_lock_length(locku->lu_offset, locku->lu_length))
 		 return nfserr_inval;
 
-	locku->lu_stateowner = NULL;
 	nfs4_lock_state();
 									        
 	if ((status = nfs4_preprocess_seqid_op(current_fh, 
@@ -2409,6 +2461,9 @@
 	memcpy(&locku->lu_stateid, &stp->st_stateid, sizeof(stateid_t));
 
 out:
+	if (locku->lu_stateowner)
+		nfs4_get_stateowner(locku->lu_stateowner);
+	nfs4_unlock_state();
 	return status;
 
 out_nfserr:
diff -Nru a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
--- a/fs/nfsd/nfs4xdr.c	2004-12-24 13:37:18 -08:00
+++ b/fs/nfsd/nfs4xdr.c	2004-12-24 13:37:18 -08:00
@@ -545,14 +545,12 @@
 	DECODE_TAIL;
 }
 
-#define NFS4_STATE_NOT_LOCKED	((void *)-1)
-
 static int
 nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close)
 {
 	DECODE_HEAD;
 
-	close->cl_stateowner = NFS4_STATE_NOT_LOCKED;
+	close->cl_stateowner = NULL;
 	READ_BUF(4 + sizeof(stateid_t));
 	READ32(close->cl_seqid);
 	READ32(close->cl_stateid.si_generation);
@@ -642,7 +640,7 @@
 {
 	DECODE_HEAD;
 
-	lock->lk_stateowner = NFS4_STATE_NOT_LOCKED;
+	lock->lk_stateowner = NULL;
 	/*
 	* type, reclaim(boolean), offset, length, new_lock_owner(boolean)
 	*/
@@ -700,7 +698,7 @@
 {
 	DECODE_HEAD;
 
-	locku->lu_stateowner = NFS4_STATE_NOT_LOCKED;
+	locku->lu_stateowner = NULL;
 	READ_BUF(24 + sizeof(stateid_t));
 	READ32(locku->lu_type);
 	if ((locku->lu_type < NFS4_READ_LT) || (locku->lu_type > NFS4_WRITEW_LT))
@@ -736,7 +734,7 @@
 
 	memset(open->op_bmval, 0, sizeof(open->op_bmval));
 	open->op_iattr.ia_valid = 0;
-	open->op_stateowner = NFS4_STATE_NOT_LOCKED;
+	open->op_stateowner = NULL;
 
 	/* seqid, share_access, share_deny, clientid, ownerlen */
 	READ_BUF(16 + sizeof(clientid_t));
@@ -812,7 +810,7 @@
 {
 	DECODE_HEAD;
 		    
-	open_conf->oc_stateowner = NFS4_STATE_NOT_LOCKED;
+	open_conf->oc_stateowner = NULL;
 	READ_BUF(4 + sizeof(stateid_t));
 	READ32(open_conf->oc_req_stateid.si_generation);
 	COPYMEM(&open_conf->oc_req_stateid.si_opaque, sizeof(stateid_opaque_t));
@@ -826,7 +824,7 @@
 {
 	DECODE_HEAD;
 		    
-	open_down->od_stateowner = NFS4_STATE_NOT_LOCKED;
+	open_down->od_stateowner = NULL;
 	READ_BUF(4 + sizeof(stateid_t));
 	READ32(open_down->od_stateid.si_generation);
 	COPYMEM(&open_down->od_stateid.si_opaque, sizeof(stateid_opaque_t));
@@ -1327,8 +1325,7 @@
  */
 
 #define ENCODE_SEQID_OP_TAIL(stateowner) do {			\
-	if (seqid_mutating_err(nfserr) && stateowner		\
-	    && (stateowner != NFS4_STATE_NOT_LOCKED)) { 	\
+	if (seqid_mutating_err(nfserr) && stateowner) { 	\
 		if (stateowner->so_confirmed)			\
 			stateowner->so_seqid++;			\
 		stateowner->so_replay.rp_status = nfserr;   	\
@@ -1336,10 +1333,7 @@
 			  (((char *)(resp)->p - (char *)save)); \
 		memcpy(stateowner->so_replay.rp_buf, save,      \
  			stateowner->so_replay.rp_buflen); 	\
-	}							\
-	if (stateowner != NFS4_STATE_NOT_LOCKED)		\
-		nfs4_unlock_state();				\
-	} while (0);
+	} } while (0);
 
 
 static u32 nfs4_ftypes[16] = {
@@ -1995,13 +1989,19 @@
 {
 	ENCODE_HEAD;
 
-	RESERVE_SPACE(32 + XDR_LEN(ld->ld_sop->so_owner.len));
+	RESERVE_SPACE(32 + XDR_LEN(ld->ld_sop ? ld->ld_sop->so_owner.len : 0));
 	WRITE64(ld->ld_start);
 	WRITE64(ld->ld_length);
 	WRITE32(ld->ld_type);
-	WRITEMEM(&ld->ld_sop->so_client->cl_clientid, 8);
-	WRITE32(ld->ld_sop->so_owner.len);
-	WRITEMEM(ld->ld_sop->so_owner.data, ld->ld_sop->so_owner.len);
+	if (ld->ld_sop) {
+		WRITEMEM(&ld->ld_clientid, 8);
+		WRITE32(ld->ld_sop->so_owner.len);
+		WRITEMEM(ld->ld_sop->so_owner.data, ld->ld_sop->so_owner.len);
+		kref_put(&ld->ld_sop->so_ref, nfs4_free_stateowner);
+	}  else {  /* non - nfsv4 lock in conflict, no clientid nor owner */
+		WRITE64((u64)0); /* clientid */
+		WRITE32(0); /* length of owner name */
+	}
 	ADJUST_ARGS();
 }
 
@@ -2568,7 +2568,6 @@
 	RESERVE_SPACE(rp->rp_buflen);
 	WRITEMEM(rp->rp_buf, rp->rp_buflen);
 	ADJUST_ARGS();
-	nfs4_unlock_state();
 }
 
 /*
diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
--- a/fs/nfsd/nfsfh.c	2004-12-24 13:36:47 -08:00
+++ b/fs/nfsd/nfsfh.c	2004-12-24 13:36:47 -08:00
@@ -71,6 +71,35 @@
 	return rv;
 }
 
+/* Type check. The correct error return for type mismatches does not seem to be
+ * generally agreed upon. SunOS seems to use EISDIR if file isn't S_IFREG; a
+ * comment in the NFSv3 spec says this is incorrect (implementation notes for
+ * the write call).
+ */
+static inline int
+nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
+{
+	/* Type can be negative when creating hardlinks - not to a dir */
+	if (type > 0 && (mode & S_IFMT) != type) {
+		if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
+			return nfserr_symlink;
+		else if (type == S_IFDIR)
+			return nfserr_notdir;
+		else if ((mode & S_IFMT) == S_IFDIR)
+			return nfserr_isdir;
+		else
+			return nfserr_inval;
+	}
+	if (type < 0 && (mode & S_IFMT) == -type) {
+		if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
+			return nfserr_symlink;
+		else if (type == -S_IFDIR)
+			return nfserr_isdir;
+		else
+			return nfserr_notdir;
+	}
+	return 0;
+}
 
 /*
  * Perform sanity checks on the dentry in a client's file handle.
@@ -87,7 +116,6 @@
 	struct knfsd_fh	*fh = &fhp->fh_handle;
 	struct svc_export *exp = NULL;
 	struct dentry	*dentry;
-	struct inode	*inode;
 	u32		error = 0;
 
 	dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp));
@@ -153,8 +181,8 @@
 		error = nfserr_perm;
 		if (!rqstp->rq_secure && EX_SECURE(exp)) {
 			printk(KERN_WARNING
-			       "nfsd: request from insecure port (%08x:%d)!\n",
-			       ntohl(rqstp->rq_addr.sin_addr.s_addr),
+			       "nfsd: request from insecure port (%u.%u.%u.%u:%d)!\n",
+			       NIPQUAD(rqstp->rq_addr.sin_addr.s_addr),
 			       ntohs(rqstp->rq_addr.sin_port));
 			goto out;
 		}
@@ -223,37 +251,9 @@
 	}
 	cache_get(&exp->h);
 
-	inode = dentry->d_inode;
-
-
-	/* Type check. The correct error return for type mismatches
-	 * does not seem to be generally agreed upon. SunOS seems to
-	 * use EISDIR if file isn't S_IFREG; a comment in the NFSv3
-	 * spec says this is incorrect (implementation notes for the
-	 * write call).
-	 */
-
-	/* Type can be negative when creating hardlinks - not to a dir */
-	if (type > 0 && (inode->i_mode & S_IFMT) != type) {
-		if (rqstp->rq_vers == 4 && (inode->i_mode & S_IFMT) == S_IFLNK)
-			error = nfserr_symlink;
-		else if (type == S_IFDIR)
-			error = nfserr_notdir;
-		else if ((inode->i_mode & S_IFMT) == S_IFDIR)
-			error = nfserr_isdir;
-		else
-			error = nfserr_inval;
+	error = nfsd_mode_check(rqstp, dentry->d_inode->i_mode, type);
+	if (error)
 		goto out;
-	}
-	if (type < 0 && (inode->i_mode & S_IFMT) == -type) {
-		if (rqstp->rq_vers == 4 && (inode->i_mode & S_IFMT) == S_IFLNK)
-			error = nfserr_symlink;
-		else if (type == -S_IFDIR)
-			error = nfserr_isdir;
-		else
-			error = nfserr_notdir;
-		goto out;
-	}
 
 	/* Finally, check access permissions. */
 	error = nfsd_permission(exp, dentry, access);
diff -Nru a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
--- a/fs/nfsd/nfsproc.c	2004-12-24 13:36:34 -08:00
+++ b/fs/nfsd/nfsproc.c	2004-12-24 13:36:34 -08:00
@@ -128,8 +128,8 @@
 
 	if (NFSSVC_MAXBLKSIZE < argp->count) {
 		printk(KERN_NOTICE
-			"oversized read request from %08x:%d (%d bytes)\n",
-				ntohl(rqstp->rq_addr.sin_addr.s_addr),
+			"oversized read request from %u.%u.%u.%u:%d (%d bytes)\n",
+				NIPQUAD(rqstp->rq_addr.sin_addr.s_addr),
 				ntohs(rqstp->rq_addr.sin_port),
 				argp->count);
 		argp->count = NFSSVC_MAXBLKSIZE;
diff -Nru a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
--- a/fs/nfsd/nfssvc.c	2004-12-24 13:36:56 -08:00
+++ b/fs/nfsd/nfssvc.c	2004-12-24 13:36:56 -08:00
@@ -180,7 +180,6 @@
 	/* Lock module and set up kernel thread */
 	lock_kernel();
 	daemonize("nfsd");
-	current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
 
 	/* After daemonize() this kernel thread shares current->fs
 	 * with the init process. We need to create files with a
diff -Nru a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
--- a/fs/nfsd/vfs.c	2004-12-24 13:36:47 -08:00
+++ b/fs/nfsd/vfs.c	2004-12-24 13:36:47 -08:00
@@ -448,39 +448,37 @@
 	int buflen, error = 0;
 	struct posix_acl *pacl = NULL;
 
-	down(&inode->i_sem);
+	error = -EOPNOTSUPP;
+	if (inode->i_op == NULL)
+		goto out_err;
+	if (inode->i_op->getxattr == NULL)
+		goto out_err;
+
+	error = security_inode_getxattr(dentry, key);
+	if (error)
+		goto out_err;
 
 	buflen = inode->i_op->getxattr(dentry, key, NULL, 0);
 	if (buflen <= 0) {
 		error = buflen < 0 ? buflen : -ENODATA;
-		goto out_sem;
+		goto out_err;
 	}
 
 	buf = kmalloc(buflen, GFP_KERNEL);
 	if (buf == NULL) {
 		error = -ENOMEM;
-		goto out_sem;
+		goto out_err;
 	}
 
-	error = -EOPNOTSUPP;
-	if (inode->i_op && inode->i_op->getxattr) {
-		error = security_inode_getxattr(dentry, key);
-		if (error)
-			goto out_sem;
-		error = inode->i_op->getxattr(dentry, key, buf, buflen);
-	}
+	error = inode->i_op->getxattr(dentry, key, buf, buflen);
 	if (error < 0)
-		goto out_sem;
-
-	error = 0;
-	up(&inode->i_sem);
+		goto out_err;
 
 	pacl = posix_acl_from_xattr(buf, buflen);
  out:
 	kfree(buf);
 	return pacl;
- out_sem:
-	up(&inode->i_sem);
+ out_err:
 	pacl = ERR_PTR(error);
 	goto out;
 }
diff -Nru a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
--- a/fs/ntfs/ChangeLog	2004-12-24 13:36:31 -08:00
+++ b/fs/ntfs/ChangeLog	2004-12-24 13:36:31 -08:00
@@ -12,6 +12,10 @@
 	  OTOH, perhaps i_sem, which is held accross generic_file_write is
 	  sufficient for synchronisation here. We then just need to make sure
 	  ntfs_readpage/writepage/truncate interoperate properly with us.
+	  UPDATE: The above is all ok as it is due to i_sem held.  The only
+	  thing that needs to be checked is ntfs_writepage() which does not
+	  hold i_sem.  It cannot change i_size but it needs to cope with a
+	  concurrent i_size change.
 	- Implement mft.c::sync_mft_mirror_umount().  We currently will just
 	  leave the volume dirty on umount if the final iput(vol->mft_ino)
 	  causes a write of any mirrored mft records due to the mft mirror
@@ -21,7 +25,193 @@
 	- Enable the code for setting the NT4 compatibility flag when we start
 	  making NTFS 1.2 specific modifications.
 
-2.1.20 - Fix a stupid bug in ntfs_attr_reinit_search_ctx().
+2.1.22 - Many bug and race fixes and error handling improvements.
+
+	- Improve error handling in fs/ntfs/inode.c::ntfs_truncate().
+	- Change fs/ntfs/inode.c::ntfs_truncate() to return an error code
+	  instead of void and provide a helper ntfs_truncate_vfs() for the
+	  vfs ->truncate method.
+	- Add a new ntfs inode flag NInoTruncateFailed() and modify
+	  fs/ntfs/inode.c::ntfs_truncate() to set and clear it appropriately.
+	- Fix min_size and max_size definitions in ATTR_DEF structure in
+	  fs/ntfs/layout.h to be signed.
+	- Add attribute definition handling helpers to fs/ntfs/attrib.[hc]:
+	  ntfs_attr_size_bounds_check(), ntfs_attr_can_be_non_resident(), and
+	  ntfs_attr_can_be_resident(), which in turn use the new private helper
+	  ntfs_attr_find_in_attrdef().
+	- In fs/ntfs/aops.c::mark_ntfs_record_dirty(), take the
+	  mapping->private_lock around the dirtying of the buffer heads
+	  analagous to the way it is done in __set_page_dirty_buffers().
+	- Ensure the mft record size does not exceed the PAGE_CACHE_SIZE at
+	  mount time as this cannot work with the current implementation.
+	- Check for location of attribute name and improve error handling in
+	  general in fs/ntfs/inode.c::ntfs_read_locked_inode() and friends.
+	- In fs/ntfs/aops.c::ntfs_writepage(), if the page is fully outside
+	  i_size, i.e. race with truncate, invalidate the buffers on the page
+	  so that they become freeable and hence the page does not leak.
+	- Remove unused function fs/ntfs/runlist.c::ntfs_rl_merge().  (Adrian
+	  Bunk)
+	- Fix stupid bug in fs/ntfs/attrib.c::ntfs_attr_find() that resulted in
+	  a NULL pointer dereference in the error code path when a corrupt
+	  attribute was found.  (Thanks to Domen Puncer for the bug report.)
+	- Add MODULE_VERSION() to fs/ntfs/super.c.
+	- Make several functions and variables static.  (Adrian Bunk)
+	- Modify fs/ntfs/aops.c::mark_ntfs_record_dirty() so it allocates
+	  buffers for the page if they are not present and then marks the
+	  buffers belonging to the ntfs record dirty.  This causes the buffers
+	  to become busy and hence they are safe from removal until the page
+	  has been written out.
+	- Fix stupid bug in fs/ntfs/attrib.c::ntfs_external_attr_find() in the
+	  error handling code path that resulted in a BUG() due to trying to
+	  unmap an extent mft record when the mapping of it had failed and it
+	  thus was not mapped.  (Thanks to Ken MacFerrin for the bug report.)
+	- Drop the runlist lock after the vcn has been read in
+	  fs/ntfs/lcnalloc.c::__ntfs_cluster_free().
+	- Rewrite handling of multi sector transfer errors.  We now do not set
+	  PageError() when such errors are detected in the async i/o handler
+	  fs/ntfs/aops.c::ntfs_end_buffer_async_read().  All users of mst
+	  protected attributes now check the magic of each ntfs record as they
+	  use it and act appropriately.  This has the effect of making errors
+	  granular per ntfs record rather than per page which solves the case
+	  where we cannot access any of the ntfs records in a page when a
+	  single one of them had an mst error.  (Thanks to Ken MacFerrin for
+	  the bug report.)
+	- Fix error handling in fs/ntfs/quota.c::ntfs_mark_quotas_out_of_date()
+	  where we failed to release i_sem on the $Quota/$Q attribute inode.
+	- Fix bug in handling of bad inodes in fs/ntfs/namei.c::ntfs_lookup().
+	- Add mapping of unmapped buffers to all remaining code paths, i.e.
+	  fs/ntfs/aops.c::ntfs_write_mst_block(), mft.c::ntfs_sync_mft_mirror(),
+	  and write_mft_record_nolock().  From now on we require that the
+	  complete runlist for the mft mirror is always mapped into memory.
+	- Add creation of buffers to fs/ntfs/mft.c::ntfs_sync_mft_mirror().
+	- Improve error handling in fs/ntfs/aops.c::ntfs_{read,write}_block().
+	- Cleanup fs/ntfs/aops.c::ntfs_{read,write}page() since we know that a
+	  resident attribute will be smaller than a page which makes the code
+	  simpler.  Also make the code more tolerant to concurrent ->truncate.
+
+2.1.21 - Fix some races and bugs, rewrite mft write code, add mft allocator.
+
+	- Implement extent mft record deallocation
+	  fs/ntfs/mft.c::ntfs_extent_mft_record_free().
+	- Splitt runlist related functions off from attrib.[hc] to runlist.[hc].
+	- Add vol->mft_data_pos and initialize it at mount time.
+	- Rename init_runlist() to ntfs_init_runlist(), ntfs_vcn_to_lcn() to
+	  ntfs_rl_vcn_to_lcn(), decompress_mapping_pairs() to
+	  ntfs_mapping_pairs_decompress(), ntfs_merge_runlists() to
+	  ntfs_runlists_merge() and adapt all callers.
+	- Add fs/ntfs/runlist.[hc]::ntfs_get_nr_significant_bytes(),
+	  ntfs_get_size_for_mapping_pairs(), ntfs_write_significant_bytes(),
+	  and ntfs_mapping_pairs_build(), adapted from libntfs.
+	- Make fs/ntfs/lcnalloc.c::ntfs_cluster_free_from_rl_nolock() not
+	  static and add a declaration for it to lcnalloc.h.
+	- Add fs/ntfs/lcnalloc.h::ntfs_cluster_free_from_rl() which is a static
+	  inline wrapper for ntfs_cluster_free_from_rl_nolock() which takes the
+	  cluster bitmap lock for the duration of the call.
+	- Add fs/ntfs/attrib.[hc]::ntfs_attr_record_resize().
+	- Implement the equivalent of memset() for an ntfs attribute in
+	  fs/ntfs/attrib.[hc]::ntfs_attr_set() and switch
+	  fs/ntfs/logfile.c::ntfs_empty_logfile() to using it.
+	- Remove unnecessary casts from LCN_* constants.
+	- Implement fs/ntfs/runlist.c::ntfs_rl_truncate_nolock().
+	- Add MFT_RECORD_OLD as a copy of MFT_RECORD in fs/ntfs/layout.h and
+	  change MFT_RECORD to contain the NTFS 3.1+ specific fields.
+	- Add a helper function fs/ntfs/aops.c::mark_ntfs_record_dirty() which
+	  marks all buffers belonging to an ntfs record dirty, followed by
+	  marking the page the ntfs record is in dirty and also marking the vfs
+	  inode containing the ntfs record dirty (I_DIRTY_PAGES).
+	- Switch fs/ntfs/index.h::ntfs_index_entry_mark_dirty() to using the
+	  new helper fs/ntfs/aops.c::mark_ntfs_record_dirty() and remove the no
+	  longer needed fs/ntfs/index.[hc]::__ntfs_index_entry_mark_dirty().
+	- Move ntfs_{un,}map_page() from ntfs.h to aops.h and fix resulting
+	  include errors.
+	- Move the typedefs for runlist_element and runlist from types.h to
+	  runlist.h and fix resulting include errors.
+	- Remove unused {__,}format_mft_record() from fs/ntfs/mft.c.
+	- Modify fs/ntfs/mft.c::__mark_mft_record_dirty() to use the helper
+	  mark_ntfs_record_dirty() which also changes the behaviour in that we
+	  now set the buffers belonging to the mft record dirty as well as the
+	  page itself.
+	- Update fs/ntfs/mft.c::write_mft_record_nolock() and sync_mft_mirror()
+	  to cope with the fact that there now are dirty buffers in mft pages.
+	- Update fs/ntfs/inode.c::ntfs_write_inode() to also use the helper
+	  mark_ntfs_record_dirty() and thus to set the buffers belonging to the
+	  mft record dirty as well as the page itself.
+	- Fix compiler warnings on x86-64 in fs/ntfs/dir.c.  (Randy Dunlap,
+	  slightly modified by me)
+	- Add fs/ntfs/mft.c::try_map_mft_record() which fails with -EALREADY if
+	  the mft record is already locked and otherwise behaves the same way
+	  as fs/ntfs/mft.c::map_mft_record().
+	- Modify fs/ntfs/mft.c::write_mft_record_nolock() so that it only
+	  writes the mft record if the buffers belonging to it are dirty.
+	  Otherwise we assume that it was written out by other means already.
+	- Attempting to write outside initialized size is _not_ a bug so remove
+	  the bug check from fs/ntfs/aops.c::ntfs_write_mst_block().  It is in
+	  fact required to write outside initialized size when preparing to
+	  extend the initialized size.
+	- Map the page instead of using page_address() before writing to it in
+	  fs/ntfs/aops.c::ntfs_mft_writepage().
+	- Provide exclusion between opening an inode / mapping an mft record
+	  and accessing the mft record in fs/ntfs/mft.c::ntfs_mft_writepage()
+	  by setting the page not uptodate throughout ntfs_mft_writepage().
+	- Clear the page uptodate flag in fs/ntfs/aops.c::ntfs_write_mst_block()
+	  to ensure noone can see the page whilst the mst fixups are applied.
+	- Add the helper fs/ntfs/mft.c::ntfs_may_write_mft_record() which
+	  checks if an mft record may be written out safely obtaining any
+	  necessary locks in the process.  This is used by
+	  fs/ntfs/aops.c::ntfs_write_mst_block().
+	- Modify fs/ntfs/aops.c::ntfs_write_mst_block() to also work for
+	  writing mft records and improve its error handling in the process.
+	  Now if any of the records in the page fail to be written out, all
+	  other records will be written out instead of aborting completely.
+	- Remove ntfs_mft_aops and update all users to use ntfs_mst_aops.
+	- Modify fs/ntfs/inode.c::ntfs_read_locked_inode() to set the
+	  ntfs_mst_aops for all inodes which are NInoMstProtected() and
+	  ntfs_aops for all other inodes.
+	- Rename fs/ntfs/mft.c::sync_mft_mirror{,_umount}() to
+	  ntfs_sync_mft_mirror{,_umount}() and change their parameters so they
+	  no longer require an ntfs inode to be present.  Update all callers.
+	- Cleanup the error handling in fs/ntfs/mft.c::ntfs_sync_mft_mirror().
+	- Clear the page uptodate flag in fs/ntfs/mft.c::ntfs_sync_mft_mirror()
+	  to ensure noone can see the page whilst the mst fixups are applied.
+	- Remove the no longer needed fs/ntfs/mft.c::ntfs_mft_writepage() and
+	  fs/ntfs/mft.c::try_map_mft_record().
+	- Fix callers of fs/ntfs/aops.c::mark_ntfs_record_dirty() to call it
+	  with the ntfs inode which contains the page rather than the ntfs
+	  inode the mft record of which is in the page.
+	- Fix race condition in fs/ntfs/inode.c::ntfs_put_inode() by moving the
+	  index inode bitmap inode release code from there to
+	  fs/ntfs/inode.c::ntfs_clear_big_inode().  (Thanks to Christoph
+	  Hellwig for spotting this.)
+	- Fix race condition in fs/ntfs/inode.c::ntfs_put_inode() by taking the
+	  inode semaphore around the code that sets ni->itype.index.bmp_ino to
+	  NULL and reorganize the code to optimize it a bit.  (Thanks to
+	  Christoph Hellwig for spotting this.)
+	- Modify fs/ntfs/aops.c::mark_ntfs_record_dirty() to no longer take the
+	  ntfs inode as a parameter as this is confusing and misleading and the
+	  needed ntfs inode is available via NTFS_I(page->mapping->host).
+	  Adapt all callers to this change.
+	- Modify fs/ntfs/mft.c::write_mft_record_nolock() and
+	  fs/ntfs/aops.c::ntfs_write_mst_block() to only check the dirty state
+	  of the first buffer in a record and to take this as the ntfs record
+	  dirty state.  We cannot look at the dirty state for subsequent
+	  buffers because we might be racing with
+	  fs/ntfs/aops.c::mark_ntfs_record_dirty().
+	- Move the static inline ntfs_init_big_inode() from fs/ntfs/inode.c to
+	  inode.h and make fs/ntfs/inode.c::__ntfs_init_inode() non-static and
+	  add a declaration for it to inode.h.  Fix some compilation issues
+	  that resulted due to #includes and header file interdependencies.
+	- Simplify setup of i_mode in fs/ntfs/inode.c::ntfs_read_locked_inode().
+	- Add helpers fs/ntfs/layout.h::MK_MREF() and MK_LE_MREF().
+	- Modify fs/ntfs/mft.c::map_extent_mft_record() to only verify the mft
+	  record sequence number if it is specified (i.e. not zero).
+	- Add fs/ntfs/mft.[hc]::ntfs_mft_record_alloc() and various helper
+	  functions used by it.
+	- Update Documentation/filesystems/ntfs.txt with instructions on how to
+	  use the Device-Mapper driver with NTFS ftdisk/LDM raid.  This removes
+	  the linear raid problem with the Software RAID / MD driver when one
+	  or more of the devices has an odd number of sectors.
+
+2.1.20 - Fix two stupid bugs introduced in 2.1.18 release.
 
 	- Fix stupid bug in fs/ntfs/attrib.c::ntfs_attr_reinit_search_ctx()
 	  where we did not clear ctx->al_entry but it was still set due to
diff -Nru a/fs/ntfs/Makefile b/fs/ntfs/Makefile
--- a/fs/ntfs/Makefile	2004-12-24 13:36:56 -08:00
+++ b/fs/ntfs/Makefile	2004-12-24 13:36:56 -08:00
@@ -3,10 +3,10 @@
 obj-$(CONFIG_NTFS_FS) += ntfs.o
 
 ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
-	     index.o inode.o mft.o mst.o namei.o super.o sysctl.o unistr.o \
-	     upcase.o
+	     index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \
+	     unistr.o upcase.o
 
-EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.20\"
+EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.22\"
 
 ifeq ($(CONFIG_NTFS_DEBUG),y)
 EXTRA_CFLAGS += -DDEBUG
diff -Nru a/fs/ntfs/aops.c b/fs/ntfs/aops.c
--- a/fs/ntfs/aops.c	2004-12-24 13:37:18 -08:00
+++ b/fs/ntfs/aops.c	2004-12-24 13:37:18 -08:00
@@ -26,7 +26,15 @@
 #include <linux/pagemap.h>
 #include <linux/swap.h>
 #include <linux/buffer_head.h>
+#include <linux/writeback.h>
 
+#include "aops.h"
+#include "attrib.h"
+#include "debug.h"
+#include "inode.h"
+#include "mft.h"
+#include "runlist.h"
+#include "types.h"
 #include "ntfs.h"
 
 /**
@@ -35,13 +43,13 @@
  * @uptodate:	whether @bh is now uptodate or not
  *
  * Asynchronous I/O completion handler for reading pages belonging to the
- * attribute address space of an inode. The inodes can either be files or
+ * attribute address space of an inode.  The inodes can either be files or
  * directories or they can be fake inodes describing some attribute.
  *
  * If NInoMstProtected(), perform the post read mst fixups when all IO on the
  * page has been completed and mark the page uptodate or set the error bit on
- * the page. To determine the size of the records that need fixing up, we cheat
- * a little bit by setting the index_block_size in ntfs_inode to the ntfs
+ * the page.  To determine the size of the records that need fixing up, we
+ * cheat a little bit by setting the index_block_size in ntfs_inode to the ntfs
  * record size, and index_block_size_bits, to the log(base 2) of the ntfs
  * record size.
  */
@@ -82,7 +90,6 @@
 				(unsigned long long)bh->b_blocknr);
 		SetPageError(page);
 	}
-
 	spin_lock_irqsave(&page_uptodate_lock, flags);
 	clear_buffer_async_read(bh);
 	unlock_buffer(bh);
@@ -103,42 +110,30 @@
 	 * If none of the buffers had errors then we can set the page uptodate,
 	 * but we first have to perform the post read mst fixups, if the
 	 * attribute is mst protected, i.e. if NInoMstProteced(ni) is true.
+	 * Note we ignore fixup errors as those are detected when
+	 * map_mft_record() is called which gives us per record granularity
+	 * rather than per page granularity.
 	 */
 	if (!NInoMstProtected(ni)) {
 		if (likely(page_uptodate && !PageError(page)))
 			SetPageUptodate(page);
 	} else {
 		char *addr;
-		unsigned int i, recs, nr_err;
+		unsigned int i, recs;
 		u32 rec_size;
 
 		rec_size = ni->itype.index.block_size;
 		recs = PAGE_CACHE_SIZE / rec_size;
+		/* Should have been verified before we got here... */
+		BUG_ON(!recs);
 		addr = kmap_atomic(page, KM_BIO_SRC_IRQ);
-		for (i = nr_err = 0; i < recs; i++) {
-			if (likely(!post_read_mst_fixup((NTFS_RECORD*)(addr +
-					i * rec_size), rec_size)))
-				continue;
-			nr_err++;
-			ntfs_error(ni->vol->sb, "post_read_mst_fixup() failed, "
-					"corrupt %s record 0x%llx. Run chkdsk.",
-					ni->mft_no ? "index" : "mft",
-					(unsigned long long)(((s64)page->index
-					<< PAGE_CACHE_SHIFT >>
-					ni->itype.index.block_size_bits) + i));
-		}
+		for (i = 0; i < recs; i++)
+			post_read_mst_fixup((NTFS_RECORD*)(addr +
+					i * rec_size), rec_size);
 		flush_dcache_page(page);
 		kunmap_atomic(addr, KM_BIO_SRC_IRQ);
-		if (likely(!PageError(page))) {
-			if (likely(!nr_err && recs)) {
-				if (likely(page_uptodate))
-					SetPageUptodate(page);
-			} else {
-				ntfs_error(ni->vol->sb, "Setting page error, "
-						"index 0x%lx.", page->index);
-				SetPageError(page);
-			}
-		}
+		if (likely(!PageError(page) && page_uptodate))
+			SetPageUptodate(page);
 	}
 	unlock_page(page);
 	return;
@@ -180,6 +175,9 @@
 	ni = NTFS_I(page->mapping->host);
 	vol = ni->vol;
 
+	/* $MFT/$DATA must have its complete runlist in memory at all times. */
+	BUG_ON(!ni->runlist.rl && !ni->mft_no && !NInoAttr(ni));
+
 	blocksize_bits = VFS_I(ni)->i_blkbits;
 	blocksize = 1 << blocksize_bits;
 
@@ -195,12 +193,6 @@
 	lblock = (ni->allocated_size + blocksize - 1) >> blocksize_bits;
 	zblock = (ni->initialized_size + blocksize - 1) >> blocksize_bits;
 
-#ifdef DEBUG
-	if (unlikely(!ni->runlist.rl && !ni->mft_no && !NInoAttr(ni)))
-		panic("NTFS: $MFT/$DATA runlist has been unmapped! This is a "
-				"very serious bug! Cannot continue...");
-#endif
-
 	/* Loop through all the buffers in the page. */
 	rl = NULL;
 	nr = i = 0;
@@ -232,9 +224,9 @@
 				/* Seek to element containing target vcn. */
 				while (rl->length && rl[1].vcn <= vcn)
 					rl++;
-				lcn = ntfs_vcn_to_lcn(rl, vcn);
+				lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
 			} else
-				lcn = (LCN)LCN_RL_NOT_MAPPED;
+				lcn = LCN_RL_NOT_MAPPED;
 			/* Successful remap. */
 			if (lcn >= 0) {
 				/* Setup buffer head to correct block. */
@@ -254,29 +246,35 @@
 				goto handle_hole;
 			/* If first try and runlist unmapped, map and retry. */
 			if (!is_retry && lcn == LCN_RL_NOT_MAPPED) {
+				int err;
 				is_retry = TRUE;
 				/*
 				 * Attempt to map runlist, dropping lock for
 				 * the duration.
 				 */
 				up_read(&ni->runlist.lock);
-				if (!ntfs_map_runlist(ni, vcn))
+				err = ntfs_map_runlist(ni, vcn);
+				if (likely(!err))
 					goto lock_retry_remap;
 				rl = NULL;
+				lcn = err;
 			}
 			/* Hard error, zero out region. */
+			bh->b_blocknr = -1;
 			SetPageError(page);
-			ntfs_error(vol->sb, "ntfs_vcn_to_lcn(vcn = 0x%llx) "
-					"failed with error code 0x%llx%s.",
-					(unsigned long long)vcn,
-					(unsigned long long)-lcn,
-					is_retry ? " even after retrying" : "");
-			// FIXME: Depending on vol->on_errors, do something.
+			ntfs_error(vol->sb, "Failed to read from inode 0x%lx, "
+					"attribute type 0x%x, vcn 0x%llx, "
+					"offset 0x%x because its location on "
+					"disk could not be determined%s "
+					"(error code %lli).", ni->mft_no,
+					ni->type, (unsigned long long)vcn,
+					vcn_ofs, is_retry ? " even after "
+					"retrying" : "", (long long)lcn);
 		}
 		/*
-		 * Either iblock was outside lblock limits or ntfs_vcn_to_lcn()
-		 * returned error. Just zero that portion of the page and set
-		 * the buffer uptodate.
+		 * Either iblock was outside lblock limits or
+		 * ntfs_rl_vcn_to_lcn() returned error.  Just zero that portion
+		 * of the page and set the buffer uptodate.
 		 */
 handle_hole:
 		bh->b_blocknr = -1UL;
@@ -340,12 +338,10 @@
  * for it to be read in before we can do the copy.
  *
  * Return 0 on success and -errno on error.
- *
- * WARNING: Do not make this function static! It is used by mft.c!
  */
-int ntfs_readpage(struct file *file, struct page *page)
+static int ntfs_readpage(struct file *file, struct page *page)
 {
-	s64 attr_pos;
+	loff_t i_size;
 	ntfs_inode *ni, *base_ni;
 	u8 *kaddr;
 	ntfs_attr_search_ctx *ctx;
@@ -354,7 +350,6 @@
 	int err = 0;
 
 	BUG_ON(!PageLocked(page));
-
 	/*
 	 * This can potentially happen because we clear PageUptodate() during
 	 * ntfs_writepage() of MstProtected() attributes.
@@ -363,7 +358,6 @@
 		unlock_page(page);
 		return 0;
 	}
-
 	ni = NTFS_I(page->mapping->host);
 
 	/* NInoNonResident() == NInoIndexAllocPresent() */
@@ -385,12 +379,23 @@
 		/* Normal data stream. */
 		return ntfs_read_block(page);
 	}
-	/* Attribute is resident, implying it is not compressed or encrypted. */
+	/*
+	 * Attribute is resident, implying it is not compressed or encrypted.
+	 * This also means the attribute is smaller than an mft record and
+	 * hence smaller than a page, so can simply zero out any pages with
+	 * index above 0.  We can also do this if the file size is 0.
+	 */
+	if (unlikely(page->index > 0 || !i_size_read(VFS_I(ni)))) {
+		kaddr = kmap_atomic(page, KM_USER0);
+		memset(kaddr, 0, PAGE_CACHE_SIZE);
+		flush_dcache_page(page);
+		kunmap_atomic(kaddr, KM_USER0);
+		goto done;
+	}
 	if (!NInoAttr(ni))
 		base_ni = ni;
 	else
 		base_ni = ni->ext.base_ntfs_ino;
-
 	/* Map, pin, and lock the mft record. */
 	mrec = map_mft_record(base_ni);
 	if (IS_ERR(mrec)) {
@@ -406,35 +411,25 @@
 			CASE_SENSITIVE, 0, NULL, 0, ctx);
 	if (unlikely(err))
 		goto put_unm_err_out;
-
-	/* Starting position of the page within the attribute value. */
-	attr_pos = page->index << PAGE_CACHE_SHIFT;
-
-	/* The total length of the attribute value. */
 	attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
-
+	i_size = i_size_read(VFS_I(ni));
+	if (unlikely(attr_len > i_size))
+		attr_len = i_size;
 	kaddr = kmap_atomic(page, KM_USER0);
-	/* Copy over in bounds data, zeroing the remainder of the page. */
-	if (attr_pos < attr_len) {
-		u32 bytes = attr_len - attr_pos;
-		if (bytes > PAGE_CACHE_SIZE)
-			bytes = PAGE_CACHE_SIZE;
-		else if (bytes < PAGE_CACHE_SIZE)
-			memset(kaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
-		/* Copy the data to the page. */
-		memcpy(kaddr, attr_pos + (char*)ctx->attr +
-				le16_to_cpu(
-				ctx->attr->data.resident.value_offset), bytes);
-	} else
-		memset(kaddr, 0, PAGE_CACHE_SIZE);
+	/* Copy the data to the page. */
+	memcpy(kaddr, (u8*)ctx->attr +
+			le16_to_cpu(ctx->attr->data.resident.value_offset),
+			attr_len);
+	/* Zero the remainder of the page. */
+	memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len);
 	flush_dcache_page(page);
 	kunmap_atomic(kaddr, KM_USER0);
-
-	SetPageUptodate(page);
 put_unm_err_out:
 	ntfs_attr_put_search_ctx(ctx);
 unm_err_out:
 	unmap_mft_record(base_ni);
+done:
+	SetPageUptodate(page);
 err_out:
 	unlock_page(page);
 	return err;
@@ -444,8 +439,8 @@
 
 /**
  * ntfs_write_block - write a @page to the backing store
- * @wbc:	writeback control structure
  * @page:	page cache page to write out
+ * @wbc:	writeback control structure
  *
  * This function is for writing pages belonging to non-resident, non-mst
  * protected attributes to their backing store.
@@ -464,7 +459,7 @@
  *
  * Based on ntfs_read_block() and __block_write_full_page().
  */
-static int ntfs_write_block(struct writeback_control *wbc, struct page *page)
+static int ntfs_write_block(struct page *page, struct writeback_control *wbc)
 {
 	VCN vcn;
 	LCN lcn;
@@ -484,7 +479,7 @@
 	vol = ni->vol;
 
 	ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
-			"0x%lx.", vi->i_ino, ni->type, page->index);
+			"0x%lx.", ni->mft_no, ni->type, page->index);
 
 	BUG_ON(!NInoNonResident(ni));
 	BUG_ON(NInoMstProtected(ni));
@@ -625,9 +620,9 @@
 		bh->b_bdev = vol->sb->s_bdev;
 
 		/* Convert block into corresponding vcn and offset. */
-		vcn = (VCN)block << blocksize_bits >> vol->cluster_size_bits;
-		vcn_ofs = ((VCN)block << blocksize_bits) &
-				vol->cluster_size_mask;
+		vcn = (VCN)block << blocksize_bits;
+		vcn_ofs = vcn & vol->cluster_size_mask;
+		vcn >>= vol->cluster_size_bits;
 		if (!rl) {
 lock_retry_remap:
 			down_read(&ni->runlist.lock);
@@ -637,9 +632,9 @@
 			/* Seek to element containing target vcn. */
 			while (rl->length && rl[1].vcn <= vcn)
 				rl++;
-			lcn = ntfs_vcn_to_lcn(rl, vcn);
+			lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
 		} else
-			lcn = (LCN)LCN_RL_NOT_MAPPED;
+			lcn = LCN_RL_NOT_MAPPED;
 		/* Successful remap. */
 		if (lcn >= 0) {
 			/* Setup buffer head to point to correct block. */
@@ -670,15 +665,17 @@
 			if (likely(!err))
 				goto lock_retry_remap;
 			rl = NULL;
+			lcn = err;
 		}
 		/* Failed to map the buffer, even after retrying. */
-		bh->b_blocknr = -1UL;
-		ntfs_error(vol->sb, "ntfs_vcn_to_lcn(vcn = 0x%llx) failed "
-				"with error code 0x%llx%s.",
-				(unsigned long long)vcn,
-				(unsigned long long)-lcn,
-				is_retry ? " even after retrying" : "");
-		// FIXME: Depending on vol->on_errors, do something.
+		bh->b_blocknr = -1;
+		ntfs_error(vol->sb, "Failed to write to inode 0x%lx, "
+				"attribute type 0x%x, vcn 0x%llx, offset 0x%x "
+				"because its location on disk could not be "
+				"determined%s (error code %lli).", ni->mft_no,
+				ni->type, (unsigned long long)vcn,
+				vcn_ofs, is_retry ? " even after "
+				"retrying" : "", (long long)lcn);
 		if (!err)
 			err = -EIO;
 		break;
@@ -772,234 +769,432 @@
 	return err;
 }
 
-static const char *ntfs_please_email = "Please email "
-		"linux-ntfs-dev@lists.sourceforge.net and say that you saw "
-		"this message.  Thank you.";
-
 /**
  * ntfs_write_mst_block - write a @page to the backing store
- * @wbc:	writeback control structure
  * @page:	page cache page to write out
+ * @wbc:	writeback control structure
  *
  * This function is for writing pages belonging to non-resident, mst protected
- * attributes to their backing store.  The only supported attribute is the
- * index allocation attribute.  Both directory inodes and index inodes are
- * supported.
+ * attributes to their backing store.  The only supported attributes are index
+ * allocation and $MFT/$DATA.  Both directory inodes and index inodes are
+ * supported for the index allocation case.
  *
  * The page must remain locked for the duration of the write because we apply
  * the mst fixups, write, and then undo the fixups, so if we were to unlock the
  * page before undoing the fixups, any other user of the page will see the
  * page contents as corrupt.
  *
+ * We clear the page uptodate flag for the duration of the function to ensure
+ * exclusion for the $MFT/$DATA case against someone mapping an mft record we
+ * are about to apply the mst fixups to.
+ *
  * Return 0 on success and -errno on error.
  *
  * Based on ntfs_write_block(), ntfs_mft_writepage(), and
  * write_mft_record_nolock().
  */
-static int ntfs_write_mst_block(struct writeback_control *wbc,
-		struct page *page)
+static int ntfs_write_mst_block(struct page *page,
+		struct writeback_control *wbc)
 {
 	sector_t block, dblock, rec_block;
 	struct inode *vi = page->mapping->host;
 	ntfs_inode *ni = NTFS_I(vi);
 	ntfs_volume *vol = ni->vol;
 	u8 *kaddr;
-	unsigned int bh_size = 1 << vi->i_blkbits;
-	unsigned int rec_size;
-	struct buffer_head *bh, *head;
+	unsigned char bh_size_bits = vi->i_blkbits;
+	unsigned int bh_size = 1 << bh_size_bits;
+	unsigned int rec_size = ni->itype.index.block_size;
+	ntfs_inode *locked_nis[PAGE_CACHE_SIZE / rec_size];
+	struct buffer_head *bh, *head, *tbh, *rec_start_bh;
 	int max_bhs = PAGE_CACHE_SIZE / bh_size;
 	struct buffer_head *bhs[max_bhs];
-	int i, nr_recs, nr_bhs, bhs_per_rec, err;
-	unsigned char bh_size_bits;
-	BOOL rec_is_dirty;
+	runlist_element *rl;
+	int i, nr_locked_nis, nr_recs, nr_bhs, bhs_per_rec, err, err2;
+	unsigned rec_size_bits;
+	BOOL sync, is_mft, page_is_dirty, rec_is_dirty;
 
 	ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
 			"0x%lx.", vi->i_ino, ni->type, page->index);
 	BUG_ON(!NInoNonResident(ni));
 	BUG_ON(!NInoMstProtected(ni));
-	BUG_ON(!(S_ISDIR(vi->i_mode) ||
+	is_mft = (S_ISREG(vi->i_mode) && !vi->i_ino);
+	/*
+	 * NOTE: ntfs_write_mst_block() would be called for $MFTMirr if a page
+	 * in its page cache were to be marked dirty.  However this should
+	 * never happen with the current driver and considering we do not
+	 * handle this case here we do want to BUG(), at least for now.
+	 */
+	BUG_ON(!(is_mft || S_ISDIR(vi->i_mode) ||
 			(NInoAttr(ni) && ni->type == AT_INDEX_ALLOCATION)));
-	BUG_ON(PageWriteback(page));
-	BUG_ON(!PageUptodate(page));
 	BUG_ON(!max_bhs);
 
+	/* Were we called for sync purposes? */
+	sync = (wbc->sync_mode == WB_SYNC_ALL);
+
 	/* Make sure we have mapped buffers. */
-	if (unlikely(!page_has_buffers(page))) {
-no_buffers_err_out:
-		ntfs_error(vol->sb, "Writing ntfs records without existing "
-				"buffers is not implemented yet.  %s",
-				ntfs_please_email);
-		err = -EOPNOTSUPP;
-		goto err_out;
-	}
+	BUG_ON(!page_has_buffers(page));
 	bh = head = page_buffers(page);
-	if (unlikely(!bh))
-		goto no_buffers_err_out;
+	BUG_ON(!bh);
 
-	bh_size_bits = vi->i_blkbits;
-	rec_size = ni->itype.index.block_size;
-	nr_recs = PAGE_CACHE_SIZE / rec_size;
-	BUG_ON(!nr_recs);
+	rec_size_bits = ni->itype.index.block_size_bits;
+	BUG_ON(!(PAGE_CACHE_SIZE >> rec_size_bits));
 	bhs_per_rec = rec_size >> bh_size_bits;
 	BUG_ON(!bhs_per_rec);
 
 	/* The first block in the page. */
-	rec_block = block = (s64)page->index <<
+	rec_block = block = (sector_t)page->index <<
 			(PAGE_CACHE_SHIFT - bh_size_bits);
 
 	/* The first out of bounds block for the data size. */
 	dblock = (vi->i_size + bh_size - 1) >> bh_size_bits;
 
-	err = nr_bhs = 0;
-	/* Need this to silence a stupid gcc warning. */
-	rec_is_dirty = FALSE;
+	rl = NULL;
+	err = err2 = nr_bhs = nr_recs = nr_locked_nis = 0;
+	page_is_dirty = rec_is_dirty = FALSE;
+	rec_start_bh = NULL;
 	do {
-		if (unlikely(block >= dblock)) {
+		BOOL is_retry = FALSE;
+
+		if (likely(block < rec_block)) {
+			if (unlikely(block >= dblock)) {
+				clear_buffer_dirty(bh);
+				continue;
+			}
 			/*
-			 * Mapped buffers outside i_size will occur, because
-			 * this page can be outside i_size when there is a
-			 * truncate in progress. The contents of such buffers
-			 * were zeroed by ntfs_writepage().
-			 *
-			 * FIXME: What about the small race window where
-			 * ntfs_writepage() has not done any clearing because
-			 * the page was within i_size but before we get here,
-			 * vmtruncate() modifies i_size?
+			 * This block is not the first one in the record.  We
+			 * ignore the buffer's dirty state because we could
+			 * have raced with a parallel mark_ntfs_record_dirty().
 			 */
-			clear_buffer_dirty(bh);
-			continue;
-		}
-		if (rec_block == block) {
+			if (!rec_is_dirty)
+				continue;
+			if (unlikely(err2)) {
+				if (err2 != -ENOMEM)
+					clear_buffer_dirty(bh);
+				continue;
+			}
+		} else /* if (block == rec_block) */ {
+			BUG_ON(block > rec_block);
 			/* This block is the first one in the record. */
-			rec_block += rec_size >> bh_size_bits;
+			rec_block += bhs_per_rec;
+			err2 = 0;
+			if (unlikely(block >= dblock)) {
+				clear_buffer_dirty(bh);
+				continue;
+			}
 			if (!buffer_dirty(bh)) {
-				/* Clean buffers are not written out. */
+				/* Clean records are not written out. */
 				rec_is_dirty = FALSE;
 				continue;
 			}
 			rec_is_dirty = TRUE;
-		} else {
-			/* This block is not the first one in the record. */
-			if (!buffer_dirty(bh)) {
-				/* Clean buffers are not written out. */
-				BUG_ON(rec_is_dirty);
+			rec_start_bh = bh;
+		}
+		/* Need to map the buffer if it is not mapped already. */
+		if (unlikely(!buffer_mapped(bh))) {
+			VCN vcn;
+			LCN lcn;
+			unsigned int vcn_ofs;
+
+			/* Obtain the vcn and offset of the current block. */
+			vcn = (VCN)block << bh_size_bits;
+			vcn_ofs = vcn & vol->cluster_size_mask;
+			vcn >>= vol->cluster_size_bits;
+			if (!rl) {
+lock_retry_remap:
+				down_read(&ni->runlist.lock);
+				rl = ni->runlist.rl;
+			}
+			if (likely(rl != NULL)) {
+				/* Seek to element containing target vcn. */
+				while (rl->length && rl[1].vcn <= vcn)
+					rl++;
+				lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
+			} else
+				lcn = LCN_RL_NOT_MAPPED;
+			/* Successful remap. */
+			if (likely(lcn >= 0)) {
+				/* Setup buffer head to correct block. */
+				bh->b_blocknr = ((lcn <<
+						vol->cluster_size_bits) +
+						vcn_ofs) >> bh_size_bits;
+				set_buffer_mapped(bh);
+			} else {
+				/*
+				 * Remap failed.  Retry to map the runlist once
+				 * unless we are working on $MFT which always
+				 * has the whole of its runlist in memory.
+				 */
+				if (!is_mft && !is_retry &&
+						lcn == LCN_RL_NOT_MAPPED) {
+					is_retry = TRUE;
+					/*
+					 * Attempt to map runlist, dropping
+					 * lock for the duration.
+					 */
+					up_read(&ni->runlist.lock);
+					err2 = ntfs_map_runlist(ni, vcn);
+					if (likely(!err2))
+						goto lock_retry_remap;
+					if (err2 == -ENOMEM)
+						page_is_dirty = TRUE;
+					lcn = err2;
+				} else
+					err2 = -EIO;
+				/* Hard error.  Abort writing this record. */
+				if (!err || err == -ENOMEM)
+					err = err2;
+				bh->b_blocknr = -1;
+				ntfs_error(vol->sb, "Cannot write ntfs record "
+						"0x%llx (inode 0x%lx, "
+						"attribute type 0x%x) because "
+						"its location on disk could "
+						"not be determined (error "
+						"code %lli).", (s64)block <<
+						bh_size_bits >>
+						vol->mft_record_size_bits,
+						ni->mft_no, ni->type,
+						(long long)lcn);
+				/*
+				 * If this is not the first buffer, remove the
+				 * buffers in this record from the list of
+				 * buffers to write and clear their dirty bit
+				 * if not error -ENOMEM.
+				 */
+				if (rec_start_bh != bh) {
+					while (bhs[--nr_bhs] != rec_start_bh)
+						;
+					if (err2 != -ENOMEM) {
+						do {
+							clear_buffer_dirty(
+								rec_start_bh);
+						} while ((rec_start_bh =
+								rec_start_bh->
+								b_this_page) !=
+								bh);
+					}
+				}
 				continue;
 			}
-			BUG_ON(!rec_is_dirty);
-		}
-		/* Attempting to write outside the initialized size is a bug. */
-		BUG_ON(((block + 1) << bh_size_bits) > ni->initialized_size);
-		if (!buffer_mapped(bh)) {
-			ntfs_error(vol->sb, "Writing ntfs records without "
-					"existing mapped buffers is not "
-					"implemented yet.  %s",
-					ntfs_please_email);
-			clear_buffer_dirty(bh);
-			err = -EOPNOTSUPP;
-			goto cleanup_out;
-		}
-		if (!buffer_uptodate(bh)) {
-			ntfs_error(vol->sb, "Writing ntfs records without "
-					"existing uptodate buffers is not "
-					"implemented yet.  %s",
-					ntfs_please_email);
-			clear_buffer_dirty(bh);
-			err = -EOPNOTSUPP;
-			goto cleanup_out;
 		}
+		BUG_ON(!buffer_uptodate(bh));
+		BUG_ON(nr_bhs >= max_bhs);
 		bhs[nr_bhs++] = bh;
-		BUG_ON(nr_bhs > max_bhs);
 	} while (block++, (bh = bh->b_this_page) != head);
+	if (unlikely(rl))
+		up_read(&ni->runlist.lock);
 	/* If there were no dirty buffers, we are done. */
 	if (!nr_bhs)
 		goto done;
-	/* Apply the mst protection fixups. */
-	kaddr = page_address(page);
+	/* Map the page so we can access its contents. */
+	kaddr = kmap(page);
+	/* Clear the page uptodate flag whilst the mst fixups are applied. */
+	BUG_ON(!PageUptodate(page));
+	ClearPageUptodate(page);
 	for (i = 0; i < nr_bhs; i++) {
-		if (!(i % bhs_per_rec)) {
-			err = pre_write_mst_fixup((NTFS_RECORD*)(kaddr +
-					bh_offset(bhs[i])), rec_size);
-			if (err) {
-				ntfs_error(vol->sb, "Failed to apply mst "
-						"fixups (inode 0x%lx, "
-						"attribute type 0x%x, page "
-						"index 0x%lx)!  Umount and "
-						"run chkdsk.", vi->i_ino,
-						ni->type,
-				page->index);
-				nr_bhs = i;
-				goto mst_cleanup_out;
+		unsigned int ofs;
+
+		/* Skip buffers which are not at the beginning of records. */
+		if (i % bhs_per_rec)
+			continue;
+		tbh = bhs[i];
+		ofs = bh_offset(tbh);
+		if (is_mft) {
+			ntfs_inode *tni;
+			unsigned long mft_no;
+
+			/* Get the mft record number. */
+			mft_no = (((s64)page->index << PAGE_CACHE_SHIFT) + ofs)
+					>> rec_size_bits;
+			/* Check whether to write this mft record. */
+			tni = NULL;
+			if (!ntfs_may_write_mft_record(vol, mft_no,
+					(MFT_RECORD*)(kaddr + ofs), &tni)) {
+				/*
+				 * The record should not be written.  This
+				 * means we need to redirty the page before
+				 * returning.
+				 */
+				page_is_dirty = TRUE;
+				/*
+				 * Remove the buffers in this mft record from
+				 * the list of buffers to write.
+				 */
+				do {
+					bhs[i] = NULL;
+				} while (++i % bhs_per_rec);
+				continue;
 			}
+			/*
+			 * The record should be written.  If a locked ntfs
+			 * inode was returned, add it to the array of locked
+			 * ntfs inodes.
+			 */
+			if (tni)
+				locked_nis[nr_locked_nis++] = tni;
+		}
+		/* Apply the mst protection fixups. */
+		err2 = pre_write_mst_fixup((NTFS_RECORD*)(kaddr + ofs),
+				rec_size);
+		if (unlikely(err2)) {
+			if (!err || err == -ENOMEM)
+				err = -EIO;
+			ntfs_error(vol->sb, "Failed to apply mst fixups "
+					"(inode 0x%lx, attribute type 0x%x, "
+					"page index 0x%lx, page offset 0x%x)!"
+					"  Unmount and run chkdsk.", vi->i_ino,
+					ni->type, page->index, ofs);
+			/*
+			 * Mark all the buffers in this record clean as we do
+			 * not want to write corrupt data to disk.
+			 */
+			do {
+				clear_buffer_dirty(bhs[i]);
+				bhs[i] = NULL;
+			} while (++i % bhs_per_rec);
+			continue;
 		}
+		nr_recs++;
 	}
+	/* If no records are to be written out, we are done. */
+	if (!nr_recs)
+		goto unm_done;
 	flush_dcache_page(page);
 	/* Lock buffers and start synchronous write i/o on them. */
 	for (i = 0; i < nr_bhs; i++) {
-		struct buffer_head *tbh = bhs[i];
-
+		tbh = bhs[i];
+		if (!tbh)
+			continue;
 		if (unlikely(test_set_buffer_locked(tbh)))
 			BUG();
-		if (unlikely(!test_clear_buffer_dirty(tbh))) {
-			unlock_buffer(tbh);
-			continue;
-		}
+		/* The buffer dirty state is now irrelevant, just clean it. */
+		clear_buffer_dirty(tbh);
 		BUG_ON(!buffer_uptodate(tbh));
 		BUG_ON(!buffer_mapped(tbh));
 		get_bh(tbh);
 		tbh->b_end_io = end_buffer_write_sync;
 		submit_bh(WRITE, tbh);
 	}
+	/* Synchronize the mft mirror now if not @sync. */
+	if (is_mft && !sync)
+		goto do_mirror;
+do_wait:
 	/* Wait on i/o completion of buffers. */
 	for (i = 0; i < nr_bhs; i++) {
-		struct buffer_head *tbh = bhs[i];
-
+		tbh = bhs[i];
+		if (!tbh)
+			continue;
 		wait_on_buffer(tbh);
 		if (unlikely(!buffer_uptodate(tbh))) {
-			err = -EIO;
+			ntfs_error(vol->sb, "I/O error while writing ntfs "
+					"record buffer (inode 0x%lx, "
+					"attribute type 0x%x, page index "
+					"0x%lx, page offset 0x%lx)!  Unmount "
+					"and run chkdsk.", vi->i_ino, ni->type,
+					page->index, bh_offset(tbh));
+			if (!err || err == -ENOMEM)
+				err = -EIO;
+			/*
+			 * Set the buffer uptodate so the page and buffer
+			 * states do not become out of sync.
+			 */
+			set_buffer_uptodate(tbh);
+		}
+	}
+	/* If @sync, now synchronize the mft mirror. */
+	if (is_mft && sync) {
+do_mirror:
+		for (i = 0; i < nr_bhs; i++) {
+			unsigned long mft_no;
+			unsigned int ofs;
+
 			/*
-			 * Set the buffer uptodate so the page & buffer states
-			 * don't become out of sync.
+			 * Skip buffers which are not at the beginning of
+			 * records.
 			 */
-			if (PageUptodate(page))
-				set_buffer_uptodate(tbh);
+			if (i % bhs_per_rec)
+				continue;
+			tbh = bhs[i];
+			/* Skip removed buffers (and hence records). */
+			if (!tbh)
+				continue;
+			ofs = bh_offset(tbh);
+			/* Get the mft record number. */
+			mft_no = (((s64)page->index << PAGE_CACHE_SHIFT) + ofs)
+					>> rec_size_bits;
+			if (mft_no < vol->mftmirr_size)
+				ntfs_sync_mft_mirror(vol, mft_no,
+						(MFT_RECORD*)(kaddr + ofs),
+						sync);
 		}
+		if (!sync)
+			goto do_wait;
 	}
 	/* Remove the mst protection fixups again. */
 	for (i = 0; i < nr_bhs; i++) {
-		if (!(i % bhs_per_rec))
+		if (!(i % bhs_per_rec)) {
+			tbh = bhs[i];
+			if (!tbh)
+				continue;
 			post_write_mst_fixup((NTFS_RECORD*)(kaddr +
-					bh_offset(bhs[i])));
+					bh_offset(tbh)));
+		}
 	}
 	flush_dcache_page(page);
-	if (unlikely(err)) {
-		/* I/O error during writing.  This is really bad! */
-		ntfs_error(vol->sb, "I/O error while writing ntfs record "
-				"(inode 0x%lx, attribute type 0x%x, page "
-				"index 0x%lx)!  Umount and run chkdsk.",
-				vi->i_ino, ni->type, page->index);
-		goto err_out;
+unm_done:
+	/* Unlock any locked inodes. */
+	while (nr_locked_nis-- > 0) {
+		ntfs_inode *tni, *base_tni;
+		
+		tni = locked_nis[nr_locked_nis];
+		/* Get the base inode. */
+		down(&tni->extent_lock);
+		if (tni->nr_extents >= 0)
+			base_tni = tni;
+		else {
+			base_tni = tni->ext.base_ntfs_ino;
+			BUG_ON(!base_tni);
+		}
+		up(&tni->extent_lock);
+		ntfs_debug("Unlocking %s inode 0x%lx.",
+				tni == base_tni ? "base" : "extent",
+				tni->mft_no);
+		up(&tni->mrec_lock);
+		atomic_dec(&tni->count);
+		iput(VFS_I(base_tni));
 	}
+	SetPageUptodate(page);
+	kunmap(page);
 done:
-	set_page_writeback(page);
-	unlock_page(page);
-	end_page_writeback(page);
-	if (!err)
+	if (unlikely(err && err != -ENOMEM)) {
+		/*
+		 * Set page error if there is only one ntfs record in the page.
+		 * Otherwise we would loose per-record granularity.
+		 */
+		if (ni->itype.index.block_size == PAGE_CACHE_SIZE)
+			SetPageError(page);
+		NVolSetErrors(vol);
+	}
+	if (page_is_dirty) {
+		ntfs_debug("Page still contains one or more dirty ntfs "
+				"records.  Redirtying the page starting at "
+				"record 0x%lx.", page->index <<
+				(PAGE_CACHE_SHIFT - rec_size_bits));
+		redirty_page_for_writepage(wbc, page);
+		unlock_page(page);
+	} else {
+		/*
+		 * Keep the VM happy.  This must be done otherwise the
+		 * radix-tree tag PAGECACHE_TAG_DIRTY remains set even though
+		 * the page is clean.
+		 */
+		BUG_ON(PageWriteback(page));
+		set_page_writeback(page);
+		unlock_page(page);
+		end_page_writeback(page);
+	}
+	if (likely(!err))
 		ntfs_debug("Done.");
 	return err;
-mst_cleanup_out:
-	/* Remove the mst protection fixups again. */
-	for (i = 0; i < nr_bhs; i++) {
-		if (!(i % bhs_per_rec))
-			post_write_mst_fixup((NTFS_RECORD*)(kaddr +
-					bh_offset(bhs[i])));
-	}
-cleanup_out:
-	/* Clean the buffers. */
-	for (i = 0; i < nr_bhs; i++)
-		clear_buffer_dirty(bhs[i]);
-err_out:
-	SetPageError(page);
-	goto done;
 }
 
 /**
@@ -1007,6 +1202,9 @@
  * @page:	page cache page to write out
  * @wbc:	writeback control structure
  *
+ * This is called from the VM when it wants to have a dirty ntfs page cache
+ * page cleaned.  The VM has already locked the page and marked it clean.
+ *
  * For non-resident attributes, ntfs_writepage() writes the @page by calling
  * the ntfs version of the generic block_write_full_page() function,
  * ntfs_write_block(), which in turn if necessary creates and writes the
@@ -1015,9 +1213,8 @@
  * For resident attributes, OTOH, ntfs_writepage() writes the @page by copying
  * the data to the mft record (which at this stage is most likely in memory).
  * The mft record is then marked dirty and written out asynchronously via the
- * vfs inode dirty code path.
- *
- * Note the caller clears the page dirty flag before calling ntfs_writepage().
+ * vfs inode dirty code path for the inode the mft record belongs to or via the
+ * vm page dirty code path for the page the mft record is in.
  *
  * Based on ntfs_readpage() and fs/buffer.c::block_write_full_page().
  *
@@ -1025,27 +1222,32 @@
  */
 static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
 {
-	s64 attr_pos;
+	loff_t i_size;
 	struct inode *vi;
 	ntfs_inode *ni, *base_ni;
 	char *kaddr;
 	ntfs_attr_search_ctx *ctx;
 	MFT_RECORD *m;
-	u32 attr_len, bytes;
+	u32 attr_len;
 	int err;
 
 	BUG_ON(!PageLocked(page));
 
 	vi = page->mapping->host;
+	i_size = i_size_read(vi);
 
 	/* Is the page fully outside i_size? (truncate in progress) */
-	if (unlikely(page->index >= (vi->i_size + PAGE_CACHE_SIZE - 1) >>
+	if (unlikely(page->index >= (i_size + PAGE_CACHE_SIZE - 1) >>
 			PAGE_CACHE_SHIFT)) {
+		/*
+		 * The page may have dirty, unmapped buffers.  Make them
+		 * freeable here, so the page does not leak.
+		 */
+		block_invalidatepage(page, 0);
 		unlock_page(page);
 		ntfs_debug("Write outside i_size - truncated?");
 		return 0;
 	}
-
 	ni = NTFS_I(vi);
 
 	/* NInoNonResident() == NInoIndexAllocPresent() */
@@ -1081,9 +1283,9 @@
 			}
 		}
 		/* We have to zero every time due to mmap-at-end-of-file. */
-		if (page->index >= (vi->i_size >> PAGE_CACHE_SHIFT)) {
+		if (page->index >= (i_size >> PAGE_CACHE_SHIFT)) {
 			/* The page straddles i_size. */
-			unsigned int ofs = vi->i_size & ~PAGE_CACHE_MASK;
+			unsigned int ofs = i_size & ~PAGE_CACHE_MASK;
 			kaddr = kmap_atomic(page, KM_USER0);
 			memset(kaddr + ofs, 0, PAGE_CACHE_SIZE - ofs);
 			flush_dcache_page(page);
@@ -1091,23 +1293,31 @@
 		}
 		/* Handle mst protected attributes. */
 		if (NInoMstProtected(ni))
-			return ntfs_write_mst_block(wbc, page);
+			return ntfs_write_mst_block(page, wbc);
 		/* Normal data stream. */
-		return ntfs_write_block(wbc, page);
+		return ntfs_write_block(page, wbc);
 	}
-
 	/*
-	 * Attribute is resident, implying it is not compressed, encrypted, or
-	 * mst protected.
+	 * Attribute is resident, implying it is not compressed, encrypted,
+	 * sparse, or mst protected.  This also means the attribute is smaller
+	 * than an mft record and hence smaller than a page, so can simply
+	 * return error on any pages with index above 0.
 	 */
 	BUG_ON(page_has_buffers(page));
 	BUG_ON(!PageUptodate(page));
-
+	if (unlikely(page->index > 0)) {
+		ntfs_error(vi->i_sb, "BUG()! page->index (0x%lx) > 0.  "
+				"Aborting write.", page->index);
+		BUG_ON(PageWriteback(page));
+		set_page_writeback(page);
+		unlock_page(page);
+		end_page_writeback(page);
+		return -EIO;
+	}
 	if (!NInoAttr(ni))
 		base_ni = ni;
 	else
 		base_ni = ni->ext.base_ntfs_ino;
-
 	/* Map, pin, and lock the mft record. */
 	m = map_mft_record(base_ni);
 	if (IS_ERR(m)) {
@@ -1125,32 +1335,6 @@
 			CASE_SENSITIVE, 0, NULL, 0, ctx);
 	if (unlikely(err))
 		goto err_out;
-
-	/* Starting position of the page within the attribute value. */
-	attr_pos = page->index << PAGE_CACHE_SHIFT;
-
-	/* The total length of the attribute value. */
-	attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
-
-	if (unlikely(vi->i_size != attr_len)) {
-		ntfs_error(vi->i_sb, "BUG()! i_size (0x%llx) doesn't match "
-				"attr_len (0x%x). Aborting write.", vi->i_size,
-				attr_len);
-		err = -EIO;
-		goto err_out;
-	}
-	if (unlikely(attr_pos >= attr_len)) {
-		ntfs_error(vi->i_sb, "BUG()! attr_pos (0x%llx) > attr_len "
-				"(0x%x). Aborting write.",
-				(unsigned long long)attr_pos, attr_len);
-		err = -EIO;
-		goto err_out;
-	}
-
-	bytes = attr_len - attr_pos;
-	if (unlikely(bytes > PAGE_CACHE_SIZE))
-		bytes = PAGE_CACHE_SIZE;
-
 	/*
 	 * Keep the VM happy.  This must be done otherwise the radix-tree tag
 	 * PAGECACHE_TAG_DIRTY remains set even though the page is clean.
@@ -1177,28 +1361,35 @@
 	 * zeroing below is enabled, we MUST move the unlock_page() from above
 	 * to after the kunmap_atomic(), i.e. just before the
 	 * end_page_writeback().
+	 * UPDATE: ntfs_prepare/commit_write() do the zeroing on i_size
+	 * increases for resident attributes so those are ok.
+	 * TODO: ntfs_truncate(), others?
 	 */
 
+	attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
+	i_size = i_size_read(VFS_I(ni));
 	kaddr = kmap_atomic(page, KM_USER0);
+	if (unlikely(attr_len > i_size)) {
+		/* Zero out of bounds area in the mft record. */
+		memset((u8*)ctx->attr + le16_to_cpu(
+				ctx->attr->data.resident.value_offset) +
+				i_size, 0, attr_len - i_size);
+		attr_len = i_size;
+	}
 	/* Copy the data from the page to the mft record. */
-	memcpy((u8*)ctx->attr + le16_to_cpu(
-			ctx->attr->data.resident.value_offset) + attr_pos,
-			kaddr, bytes);
+	memcpy((u8*)ctx->attr +
+			le16_to_cpu(ctx->attr->data.resident.value_offset),
+			kaddr, attr_len);
 	flush_dcache_mft_record_page(ctx->ntfs_ino);
-#if 0
-	/* Zero out of bounds area. */
-	if (likely(bytes < PAGE_CACHE_SIZE)) {
-		memset(kaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
-		flush_dcache_page(page);
-	}
-#endif
+	/* Zero out of bounds area in the page cache page. */
+	memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len);
+	flush_dcache_page(page);
 	kunmap_atomic(kaddr, KM_USER0);
 
 	end_page_writeback(page);
 
 	/* Mark the mft record dirty, so it gets written back. */
 	mark_mft_record_dirty(ctx->ntfs_ino);
-
 	ntfs_attr_put_search_ctx(ctx);
 	unmap_mft_record(base_ni);
 	return 0;
@@ -1208,13 +1399,13 @@
 				"page so we try again later.");
 		/*
 		 * Put the page back on mapping->dirty_pages, but leave its
-		 * buffer's dirty state as-is.
+		 * buffers' dirty state as-is.
 		 */
 		redirty_page_for_writepage(wbc, page);
 		err = 0;
 	} else {
 		ntfs_error(vi->i_sb, "Resident attribute write failed with "
-				"error %i. Setting page error flag.", -err);
+				"error %i.  Setting page error flag.", err);
 		SetPageError(page);
 	}
 	unlock_page(page);
@@ -1250,11 +1441,10 @@
 	vol = ni->vol;
 
 	ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
-			"0x%lx, from = %u, to = %u.", vi->i_ino, ni->type,
+			"0x%lx, from = %u, to = %u.", ni->mft_no, ni->type,
 			page->index, from, to);
 
 	BUG_ON(!NInoNonResident(ni));
-	BUG_ON(NInoMstProtected(ni));
 
 	blocksize_bits = vi->i_blkbits;
 	blocksize = 1 << blocksize_bits;
@@ -1402,9 +1592,9 @@
 				/* Seek to element containing target vcn. */
 				while (rl->length && rl[1].vcn <= vcn)
 					rl++;
-				lcn = ntfs_vcn_to_lcn(rl, vcn);
+				lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
 			} else
-				lcn = (LCN)LCN_RL_NOT_MAPPED;
+				lcn = LCN_RL_NOT_MAPPED;
 			if (unlikely(lcn < 0)) {
 				/*
 				 * We extended the attribute allocation above.
@@ -1445,21 +1635,24 @@
 					if (likely(!err))
 						goto lock_retry_remap;
 					rl = NULL;
+					lcn = err;
 				}
 				/*
 				 * Failed to map the buffer, even after
 				 * retrying.
 				 */
-				bh->b_blocknr = -1UL;
-				ntfs_error(vol->sb, "ntfs_vcn_to_lcn(vcn = "
-						"0x%llx) failed with error "
-						"code 0x%llx%s.",
+				bh->b_blocknr = -1;
+				ntfs_error(vol->sb, "Failed to write to inode "
+						"0x%lx, attribute type 0x%x, "
+						"vcn 0x%llx, offset 0x%x "
+						"because its location on disk "
+						"could not be determined%s "
+						"(error code %lli).",
+						ni->mft_no, ni->type,
 						(unsigned long long)vcn,
-						(unsigned long long)-lcn,
-						is_retry ? " even after "
-						"retrying" : "");
-				// FIXME: Depending on vol->on_errors, do
-				// something.
+						vcn_ofs, is_retry ? " even "
+						"after retrying" : "",
+						(long long)lcn);
 				if (!err)
 					err = -EIO;
 				goto err_out;
@@ -1582,8 +1775,8 @@
  * ntfs_prepare_write - prepare a page for receiving data
  *
  * This is called from generic_file_write() with i_sem held on the inode
- * (@page->mapping->host). The @page is locked and kmap()ped so page_address()
- * can simply be used. The source data has not yet been copied into the @page.
+ * (@page->mapping->host).  The @page is locked but not kmap()ped.  The source
+ * data has not yet been copied into the @page.
  *
  * Need to extend the attribute/fill in holes if necessary, create blocks and
  * make partially overwritten blocks uptodate,
@@ -1593,8 +1786,8 @@
  * Return 0 on success or -errno on error.
  *
  * Should be using block_prepare_write() [support for sparse files] or
- * cont_prepare_write() [no support for sparse files]. Can't do that due to
- * ntfs specifics but can look at them for implementation guidancea.
+ * cont_prepare_write() [no support for sparse files].  Cannot do that due to
+ * ntfs specifics but can look at them for implementation guidance.
  *
  * Note: In the range, @from is inclusive and @to is exclusive, i.e. @from is
  * the first byte in the page that will be written to and @to is the first byte
@@ -1603,18 +1796,40 @@
 static int ntfs_prepare_write(struct file *file, struct page *page,
 		unsigned from, unsigned to)
 {
+	s64 new_size;
 	struct inode *vi = page->mapping->host;
-	ntfs_inode   *ni = NTFS_I(vi);
+	ntfs_inode *base_ni = NULL, *ni = NTFS_I(vi);
+	ntfs_volume *vol = ni->vol;
+	ntfs_attr_search_ctx *ctx = NULL;
+	MFT_RECORD *m = NULL;
+	ATTR_RECORD *a;
+	u8 *kaddr;
+	u32 attr_len;
+	int err;
 
 	ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
 			"0x%lx, from = %u, to = %u.", vi->i_ino, ni->type,
 			page->index, from, to);
-
 	BUG_ON(!PageLocked(page));
 	BUG_ON(from > PAGE_CACHE_SIZE);
 	BUG_ON(to > PAGE_CACHE_SIZE);
 	BUG_ON(from > to);
-
+	BUG_ON(NInoMstProtected(ni));
+	/*
+	 * If a previous ntfs_truncate() failed, repeat it and abort if it
+	 * fails again.
+	 */
+	if (unlikely(NInoTruncateFailed(ni))) {
+		down_write(&vi->i_alloc_sem);
+		err = ntfs_truncate(vi);
+		up_write(&vi->i_alloc_sem);
+		if (err || NInoTruncateFailed(ni)) {
+			if (!err)
+				err = -EIO;
+			goto err_out;
+		}
+	}
+	/* If the attribute is not resident, deal with it elsewhere. */
 	if (NInoNonResident(ni)) {
 		/*
 		 * Only unnamed $DATA attributes can be compressed, encrypted,
@@ -1643,33 +1858,112 @@
 				return -EOPNOTSUPP;
 			}
 		}
-
-		// TODO: Implement and remove this check.
-		if (NInoMstProtected(ni)) {
-			ntfs_error(vi->i_sb, "Writing to MST protected "
-					"attributes is not supported yet. "
-					"Sorry.");
-			return -EOPNOTSUPP;
-		}
-
 		/* Normal data stream. */
 		return ntfs_prepare_nonresident_write(page, from, to);
 	}
-
 	/*
 	 * Attribute is resident, implying it is not compressed, encrypted, or
-	 * mst protected.
+	 * sparse.
 	 */
 	BUG_ON(page_has_buffers(page));
+	new_size = ((s64)page->index << PAGE_CACHE_SHIFT) + to;
+	/* If we do not need to resize the attribute allocation we are done. */
+	if (new_size <= vi->i_size)
+		goto done;
 
-	/* Do we need to resize the attribute? */
-	if (((s64)page->index << PAGE_CACHE_SHIFT) + to > vi->i_size) {
-		// TODO: Implement resize...
-		ntfs_error(vi->i_sb, "Writing beyond the existing file size is "
-				"not supported yet. Sorry.");
-		return -EOPNOTSUPP;
-	}
+	// FIXME: We abort for now as this code is not safe.
+	ntfs_error(vi->i_sb, "Changing the file size is not supported yet.  "
+			"Sorry.");
+	return -EOPNOTSUPP;
 
+	/* Map, pin, and lock the (base) mft record. */
+	if (!NInoAttr(ni))
+		base_ni = ni;
+	else
+		base_ni = ni->ext.base_ntfs_ino;
+	m = map_mft_record(base_ni);
+	if (IS_ERR(m)) {
+		err = PTR_ERR(m);
+		m = NULL;
+		ctx = NULL;
+		goto err_out;
+	}
+	ctx = ntfs_attr_get_search_ctx(base_ni, m);
+	if (unlikely(!ctx)) {
+		err = -ENOMEM;
+		goto err_out;
+	}
+	err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
+			CASE_SENSITIVE, 0, NULL, 0, ctx);
+	if (unlikely(err)) {
+		if (err == -ENOENT)
+			err = -EIO;
+		goto err_out;
+	}
+	m = ctx->mrec;
+	a = ctx->attr;
+	/* The total length of the attribute value. */
+	attr_len = le32_to_cpu(a->data.resident.value_length);
+	BUG_ON(vi->i_size != attr_len);
+	/* Check if new size is allowed in $AttrDef. */
+	err = ntfs_attr_size_bounds_check(vol, ni->type, new_size);
+	if (unlikely(err)) {
+		if (err == -ERANGE) {
+			ntfs_error(vol->sb, "Write would cause the inode "
+					"0x%lx to exceed the maximum size for "
+					"its attribute type (0x%x).  Aborting "
+					"write.", vi->i_ino,
+					le32_to_cpu(ni->type));
+		} else {
+			ntfs_error(vol->sb, "Inode 0x%lx has unknown "
+					"attribute type 0x%x.  Aborting "
+					"write.", vi->i_ino,
+					le32_to_cpu(ni->type));
+			err = -EIO;
+		}
+		goto err_out2;
+	}
+	/*
+	 * Extend the attribute record to be able to store the new attribute
+	 * size.
+	 */
+	if (new_size >= vol->mft_record_size || ntfs_attr_record_resize(m, a,
+			le16_to_cpu(a->data.resident.value_offset) +
+			new_size)) {
+		/* Not enough space in the mft record. */
+		ntfs_error(vol->sb, "Not enough space in the mft record for "
+				"the resized attribute value.  This is not "
+				"supported yet.  Aborting write.");
+		err = -EOPNOTSUPP;
+		goto err_out2;
+	}
+	/*
+	 * We have enough space in the mft record to fit the write.  This
+	 * implies the attribute is smaller than the mft record and hence the
+	 * attribute must be in a single page and hence page->index must be 0.
+	 */
+	BUG_ON(page->index);
+	/*
+	 * If the beginning of the write is past the old size, enlarge the
+	 * attribute value up to the beginning of the write and fill it with
+	 * zeroes.
+	 */
+	if (from > attr_len) {
+		memset((u8*)a + le16_to_cpu(a->data.resident.value_offset) +
+				attr_len, 0, from - attr_len);
+		a->data.resident.value_length = cpu_to_le32(from);
+		/* Zero the corresponding area in the page as well. */
+		if (PageUptodate(page)) {
+			kaddr = kmap_atomic(page, KM_USER0);
+			memset(kaddr + attr_len, 0, from - attr_len);
+			kunmap_atomic(kaddr, KM_USER0);
+			flush_dcache_page(page);
+		}
+	}
+	flush_dcache_mft_record_page(ctx->ntfs_ino);
+	mark_mft_record_dirty(ctx->ntfs_ino);
+	ntfs_attr_put_search_ctx(ctx);
+	unmap_mft_record(base_ni);
 	/*
 	 * Because resident attributes are handled by memcpy() to/from the
 	 * corresponding MFT record, and because this form of i/o is byte
@@ -1679,26 +1973,30 @@
 	 * generic_file_write() does the copying from userspace.
 	 *
 	 * We thus defer the uptodate bringing of the page region outside the
-	 * region written to to ntfs_commit_write(). The reason for doing this
-	 * is that we save one round of:
-	 *	map_mft_record(), ntfs_attr_get_search_ctx(),
-	 *	ntfs_attr_lookup(), kmap_atomic(), kunmap_atomic(),
-	 *	ntfs_attr_put_search_ctx(), unmap_mft_record().
-	 * Which is obviously a very worthwhile save.
-	 *
-	 * Thus we just return success now...
+	 * region written to to ntfs_commit_write(), which makes the code
+	 * simpler and saves one atomic kmap which is good.
 	 */
+done:
 	ntfs_debug("Done.");
 	return 0;
+err_out:
+	if (err == -ENOMEM)
+		ntfs_warning(vi->i_sb, "Error allocating memory required to "
+				"prepare the write.");
+	else {
+		ntfs_error(vi->i_sb, "Resident attribute prepare write failed "
+				"with error %i.", err);
+		NVolSetErrors(vol);
+		make_bad_inode(vi);
+	}
+err_out2:
+	if (ctx)
+		ntfs_attr_put_search_ctx(ctx);
+	if (m)
+		unmap_mft_record(base_ni);
+	return err;
 }
 
-/*
- * NOTES: There is a disparity between the apparent need to extend the
- * attribute in prepare write but to update i_size only in commit write.
- * Need to make sure i_sem protection is sufficient. And if not will need to
- * handle this in some way or another.
- */
-
 /**
  * ntfs_commit_nonresident_write -
  *
@@ -1707,24 +2005,21 @@
 		unsigned from, unsigned to)
 {
 	s64 pos = ((s64)page->index << PAGE_CACHE_SHIFT) + to;
-	struct inode *vi;
+	struct inode *vi = page->mapping->host;
 	struct buffer_head *bh, *head;
 	unsigned int block_start, block_end, blocksize;
 	BOOL partial;
 
-	vi = page->mapping->host;
-
 	ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
 			"0x%lx, from = %u, to = %u.", vi->i_ino,
 			NTFS_I(vi)->type, page->index, from, to);
-
 	blocksize = 1 << vi->i_blkbits;
 
-	// FIXME: We need a whole slew of special cases in here for MST
-	// protected attributes for example. For compressed files, too...
+	// FIXME: We need a whole slew of special cases in here for compressed
+	// files for example...
 	// For now, we know ntfs_prepare_write() would have failed so we can't
 	// get here in any of the cases which we have to special case, so we
-	// are just a ripped off unrolled generic_commit_write() at present.
+	// are just a ripped off, unrolled generic_commit_write().
 
 	bh = head = page_buffers(page);
 	block_start = 0;
@@ -1739,24 +2034,22 @@
 			mark_buffer_dirty(bh);
 		}
 	} while (block_start = block_end, (bh = bh->b_this_page) != head);
-
 	/*
 	 * If this is a partial write which happened to make all buffers
 	 * uptodate then we can optimize away a bogus ->readpage() for the next
-	 * read(). Here we 'discover' whether the page went uptodate as a
+	 * read().  Here we 'discover' whether the page went uptodate as a
 	 * result of this (potentially partial) write.
 	 */
 	if (!partial)
 		SetPageUptodate(page);
-
 	/*
-	 * Not convinced about this at all. See disparity comment above. For
+	 * Not convinced about this at all.  See disparity comment above.  For
 	 * now we know ntfs_prepare_write() would have failed in the write
 	 * exceeds i_size case, so this will never trigger which is fine.
 	 */
 	if (pos > vi->i_size) {
 		ntfs_error(vi->i_sb, "Writing beyond the existing file size is "
-				"not supported yet. Sorry.");
+				"not supported yet.  Sorry.");
 		return -EOPNOTSUPP;
 		// vi->i_size = pos;
 		// mark_inode_dirty(vi);
@@ -1769,118 +2062,73 @@
  * ntfs_commit_write - commit the received data
  *
  * This is called from generic_file_write() with i_sem held on the inode
- * (@page->mapping->host). The @page is locked and kmap()ped so page_address()
- * can simply be used. The source data has already been copied into the @page.
+ * (@page->mapping->host).  The @page is locked but not kmap()ped.  The source
+ * data has already been copied into the @page.  ntfs_prepare_write() has been
+ * called before the data copied and it returned success so we can take the
+ * results of various BUG checks and some error handling for granted.
  *
  * Need to mark modified blocks dirty so they get written out later when
  * ntfs_writepage() is invoked by the VM.
  *
  * Return 0 on success or -errno on error.
  *
- * Should be using generic_commit_write(). This marks buffers uptodate and
+ * Should be using generic_commit_write().  This marks buffers uptodate and
  * dirty, sets the page uptodate if all buffers in the page are uptodate, and
- * updates i_size if the end of io is beyond i_size. In that case, it also
- * marks the inode dirty. - We could still use this (obviously except for
- * NInoMstProtected() attributes, where we will need to duplicate the core code
- * because we need our own async_io completion handler) but we could just do
- * the i_size update in prepare write, when we resize the attribute. Then
- * we would avoid the i_size update and mark_inode_dirty() happening here.
+ * updates i_size if the end of io is beyond i_size.  In that case, it also
+ * marks the inode dirty.
  *
- * Can't use generic_commit_write() due to ntfs specialities but can look at
+ * Cannot use generic_commit_write() due to ntfs specialities but can look at
  * it for implementation guidance.
  *
  * If things have gone as outlined in ntfs_prepare_write(), then we do not
  * need to do any page content modifications here at all, except in the write
  * to resident attribute case, where we need to do the uptodate bringing here
- * which we combine with the copying into the mft record which means we only
- * need to map the mft record and find the attribute record in it only once.
+ * which we combine with the copying into the mft record which means we save
+ * one atomic kmap.
  */
 static int ntfs_commit_write(struct file *file, struct page *page,
 		unsigned from, unsigned to)
 {
-	s64 attr_pos;
-	struct inode *vi;
-	ntfs_inode *ni, *base_ni;
+	struct inode *vi = page->mapping->host;
+	ntfs_inode *base_ni, *ni = NTFS_I(vi);
 	char *kaddr, *kattr;
 	ntfs_attr_search_ctx *ctx;
 	MFT_RECORD *m;
-	u32 attr_len, bytes;
+	ATTR_RECORD *a;
+	u32 attr_len;
 	int err;
 
-	vi = page->mapping->host;
-	ni = NTFS_I(vi);
-
 	ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
 			"0x%lx, from = %u, to = %u.", vi->i_ino, ni->type,
 			page->index, from, to);
-
+	/* If the attribute is not resident, deal with it elsewhere. */
 	if (NInoNonResident(ni)) {
-		/*
-		 * Only unnamed $DATA attributes can be compressed, encrypted,
-		 * and/or sparse.
-		 */
+		/* Only unnamed $DATA attributes can be compressed/encrypted. */
 		if (ni->type == AT_DATA && !ni->name_len) {
-			/* If file is encrypted, deny access, just like NT4. */
+			/* Encrypted files need separate handling. */
 			if (NInoEncrypted(ni)) {
-				// Should never get here!
-				ntfs_debug("Denying write access to encrypted "
-						"file.");
-				return -EACCES;
+				// We never get here at present!
+				BUG();
 			}
 			/* Compressed data streams are handled in compress.c. */
 			if (NInoCompressed(ni)) {
-				// TODO: Implement and replace this check with
+				// TODO: Implement this!
 				// return ntfs_write_compressed_block(page);
-				// Should never get here!
-				ntfs_error(vi->i_sb, "Writing to compressed "
-						"files is not supported yet. "
-						"Sorry.");
-				return -EOPNOTSUPP;
-			}
-			// TODO: Implement and remove this check.
-			if (NInoSparse(ni)) {
-				// Should never get here!
-				ntfs_error(vi->i_sb, "Writing to sparse files "
-						"is not supported yet. Sorry.");
-				return -EOPNOTSUPP;
+				// We never get here at present!
+				BUG();
 			}
 		}
-
-		// TODO: Implement and remove this check.
-		if (NInoMstProtected(ni)) {
-			// Should never get here!
-			ntfs_error(vi->i_sb, "Writing to MST protected "
-					"attributes is not supported yet. "
-					"Sorry.");
-			return -EOPNOTSUPP;
-		}
-
 		/* Normal data stream. */
 		return ntfs_commit_nonresident_write(page, from, to);
 	}
-
 	/*
 	 * Attribute is resident, implying it is not compressed, encrypted, or
-	 * mst protected.
+	 * sparse.
 	 */
-
-	/* Do we need to resize the attribute? */
-	if (((s64)page->index << PAGE_CACHE_SHIFT) + to > vi->i_size) {
-		// TODO: Implement resize...
-		// pos = ((s64)page->index << PAGE_CACHE_SHIFT) + to;
-		// vi->i_size = pos;
-		// mark_inode_dirty(vi);
-		// Should never get here!
-		ntfs_error(vi->i_sb, "Writing beyond the existing file size is "
-				"not supported yet. Sorry.");
-		return -EOPNOTSUPP;
-	}
-
 	if (!NInoAttr(ni))
 		base_ni = ni;
 	else
 		base_ni = ni->ext.base_ntfs_ino;
-
 	/* Map, pin, and lock the mft record. */
 	m = map_mft_record(base_ni);
 	if (IS_ERR(m)) {
@@ -1896,61 +2144,36 @@
 	}
 	err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
 			CASE_SENSITIVE, 0, NULL, 0, ctx);
-	if (unlikely(err))
-		goto err_out;
-
-	/* Starting position of the page within the attribute value. */
-	attr_pos = page->index << PAGE_CACHE_SHIFT;
-
-	/* The total length of the attribute value. */
-	attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
-
-	if (unlikely(vi->i_size != attr_len)) {
-		ntfs_error(vi->i_sb, "BUG()! i_size (0x%llx) doesn't match "
-				"attr_len (0x%x). Aborting write.", vi->i_size,
-				attr_len);
-		err = -EIO;
-		goto err_out;
-	}
-	if (unlikely(attr_pos >= attr_len)) {
-		ntfs_error(vi->i_sb, "BUG()! attr_pos (0x%llx) > attr_len "
-				"(0x%x). Aborting write.",
-				(unsigned long long)attr_pos, attr_len);
-		err = -EIO;
+	if (unlikely(err)) {
+		if (err == -ENOENT)
+			err = -EIO;
 		goto err_out;
 	}
-
-	bytes = attr_len - attr_pos;
-	if (unlikely(bytes > PAGE_CACHE_SIZE))
-		bytes = PAGE_CACHE_SIZE;
-
-	/*
-	 * Calculate the address of the attribute value corresponding to the
-	 * beginning of the current data @page.
-	 */
-	kattr = (u8*)ctx->attr + le16_to_cpu(
-			ctx->attr->data.resident.value_offset) + attr_pos;
-
+	a = ctx->attr;
+	/* The total length of the attribute value. */
+	attr_len = le32_to_cpu(a->data.resident.value_length);
+	BUG_ON(from > attr_len);
+	kattr = (u8*)a + le16_to_cpu(a->data.resident.value_offset);
 	kaddr = kmap_atomic(page, KM_USER0);
-
 	/* Copy the received data from the page to the mft record. */
 	memcpy(kattr + from, kaddr + from, to - from);
-	flush_dcache_mft_record_page(ctx->ntfs_ino);
-
+	/* Update the attribute length if necessary. */
+	if (to > attr_len) {
+		attr_len = to;
+		a->data.resident.value_length = cpu_to_le32(attr_len);
+	}
+	/*
+	 * If the page is not uptodate, bring the out of bounds area(s)
+	 * uptodate by copying data from the mft record to the page.
+	 */
 	if (!PageUptodate(page)) {
-		/*
-		 * Bring the out of bounds area(s) uptodate by copying data
-		 * from the mft record to the page.
-		 */
 		if (from > 0)
 			memcpy(kaddr, kattr, from);
-		if (to < bytes)
-			memcpy(kaddr + to, kattr + to, bytes - to);
-
+		if (to < attr_len)
+			memcpy(kaddr + to, kattr + to, attr_len - to);
 		/* Zero the region outside the end of the attribute value. */
-		if (likely(bytes < PAGE_CACHE_SIZE))
-			memset(kaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
-
+		if (attr_len < PAGE_CACHE_SIZE)
+			memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len);
 		/*
 		 * The probability of not having done any of the above is
 		 * extremely small, so we just flush unconditionally.
@@ -1959,10 +2182,14 @@
 		SetPageUptodate(page);
 	}
 	kunmap_atomic(kaddr, KM_USER0);
-
+	/* Update i_size if necessary. */
+	if (vi->i_size < attr_len) {
+		ni->allocated_size = ni->initialized_size = attr_len;
+		i_size_write(vi, attr_len);
+	}
 	/* Mark the mft record dirty, so it gets written back. */
+	flush_dcache_mft_record_page(ctx->ntfs_ino);
 	mark_mft_record_dirty(ctx->ntfs_ino);
-
 	ntfs_attr_put_search_ctx(ctx);
 	unmap_mft_record(base_ni);
 	ntfs_debug("Done.");
@@ -1977,17 +2204,18 @@
 					"later on by the VM.");
 			/*
 			 * Put the page on mapping->dirty_pages, but leave its
-			 * buffer's dirty state as-is.
+			 * buffers' dirty state as-is.
 			 */
 			__set_page_dirty_nobuffers(page);
 			err = 0;
 		} else
-			ntfs_error(vi->i_sb, "Page is not uptodate. Written "
-					"data has been lost. )-:");
+			ntfs_error(vi->i_sb, "Page is not uptodate.  Written "
+					"data has been lost.");
 	} else {
-		ntfs_error(vi->i_sb, "Resident attribute write failed with "
-				"error %i. Setting page error flag.", -err);
-		SetPageError(page);
+		ntfs_error(vi->i_sb, "Resident attribute commit write failed "
+				"with error %i.", err);
+		NVolSetErrors(ni->vol);
+		make_bad_inode(vi);
 	}
 	if (ctx)
 		ntfs_attr_put_search_ctx(ctx);
@@ -2028,3 +2256,69 @@
 						   belonging to the page. */
 #endif /* NTFS_RW */
 };
+
+#ifdef NTFS_RW
+
+/**
+ * mark_ntfs_record_dirty - mark an ntfs record dirty
+ * @page:	page containing the ntfs record to mark dirty
+ * @ofs:	byte offset within @page at which the ntfs record begins
+ *
+ * Set the buffers and the page in which the ntfs record is located dirty.
+ *
+ * The latter also marks the vfs inode the ntfs record belongs to dirty
+ * (I_DIRTY_PAGES only).
+ *
+ * If the page does not have buffers, we create them and set them uptodate.
+ * The page may not be locked which is why we need to handle the buffers under
+ * the mapping->private_lock.  Once the buffers are marked dirty we no longer
+ * need the lock since try_to_free_buffers() does not free dirty buffers.
+ */
+void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) {
+	struct address_space *mapping = page->mapping;
+	ntfs_inode *ni = NTFS_I(mapping->host);
+	struct buffer_head *bh, *head, *buffers_to_free = NULL;
+	unsigned int end, bh_size, bh_ofs;
+
+	BUG_ON(!PageUptodate(page));
+	end = ofs + ni->itype.index.block_size;
+	bh_size = 1 << VFS_I(ni)->i_blkbits;
+	spin_lock(&mapping->private_lock);
+	if (unlikely(!page_has_buffers(page))) {
+		spin_unlock(&mapping->private_lock);
+		bh = head = alloc_page_buffers(page, bh_size, 1);
+		spin_lock(&mapping->private_lock);
+		if (likely(!page_has_buffers(page))) {
+			struct buffer_head *tail;
+
+			do {
+				set_buffer_uptodate(bh);
+				tail = bh;
+				bh = bh->b_this_page;
+			} while (bh);
+			tail->b_this_page = head;
+			attach_page_buffers(page, head);
+		} else
+			buffers_to_free = bh;
+	}
+	bh = head = page_buffers(page);
+	do {
+		bh_ofs = bh_offset(bh);
+		if (bh_ofs + bh_size <= ofs)
+			continue;
+		if (unlikely(bh_ofs >= end))
+			break;
+		set_buffer_dirty(bh);
+	} while ((bh = bh->b_this_page) != head);
+	spin_unlock(&mapping->private_lock);
+	__set_page_dirty_nobuffers(page);
+	if (unlikely(buffers_to_free)) {
+		do {
+			bh = buffers_to_free->b_this_page;
+			free_buffer_head(buffers_to_free);
+			buffers_to_free = bh;
+		} while (buffers_to_free);
+	}
+}
+
+#endif /* NTFS_RW */
diff -Nru a/fs/ntfs/aops.h b/fs/ntfs/aops.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/fs/ntfs/aops.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,109 @@
+/**
+ * aops.h - Defines for NTFS kernel address space operations and page cache
+ *	    handling.  Part of the Linux-NTFS project.
+ *
+ * Copyright (c) 2001-2004 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
+ *
+ * This program/include file 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/include file 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 (in the main directory of the Linux-NTFS
+ * distribution in the file COPYING); if not, write to the Free Software
+ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _LINUX_NTFS_AOPS_H
+#define _LINUX_NTFS_AOPS_H
+
+#include <linux/mm.h>
+#include <linux/highmem.h>
+#include <linux/pagemap.h>
+#include <linux/fs.h>
+
+#include "inode.h"
+
+/**
+ * ntfs_unmap_page - release a page that was mapped using ntfs_map_page()
+ * @page:	the page to release
+ *
+ * Unpin, unmap and release a page that was obtained from ntfs_map_page().
+ */
+static inline void ntfs_unmap_page(struct page *page)
+{
+	kunmap(page);
+	page_cache_release(page);
+}
+
+/**
+ * ntfs_map_page - map a page into accessible memory, reading it if necessary
+ * @mapping:	address space for which to obtain the page
+ * @index:	index into the page cache for @mapping of the page to map
+ *
+ * Read a page from the page cache of the address space @mapping at position
+ * @index, where @index is in units of PAGE_CACHE_SIZE, and not in bytes.
+ *
+ * If the page is not in memory it is loaded from disk first using the readpage
+ * method defined in the address space operations of @mapping and the page is
+ * added to the page cache of @mapping in the process.
+ *
+ * If the page belongs to an mst protected attribute and it is marked as such
+ * in its ntfs inode (NInoMstProtected()) the mst fixups are applied but no
+ * error checking is performed.  This means the caller has to verify whether
+ * the ntfs record(s) contained in the page are valid or not using one of the
+ * ntfs_is_XXXX_record{,p}() macros, where XXXX is the record type you are
+ * expecting to see.  (For details of the macros, see fs/ntfs/layout.h.)
+ *
+ * If the page is in high memory it is mapped into memory directly addressible
+ * by the kernel.
+ *
+ * Finally the page count is incremented, thus pinning the page into place.
+ *
+ * The above means that page_address(page) can be used on all pages obtained
+ * with ntfs_map_page() to get the kernel virtual address of the page.
+ *
+ * When finished with the page, the caller has to call ntfs_unmap_page() to
+ * unpin, unmap and release the page.
+ *
+ * Note this does not grant exclusive access. If such is desired, the caller
+ * must provide it independently of the ntfs_{un}map_page() calls by using
+ * a {rw_}semaphore or other means of serialization. A spin lock cannot be
+ * used as ntfs_map_page() can block.
+ *
+ * The unlocked and uptodate page is returned on success or an encoded error
+ * on failure. Caller has to test for error using the IS_ERR() macro on the
+ * return value. If that evaluates to TRUE, the negative error code can be
+ * obtained using PTR_ERR() on the return value of ntfs_map_page().
+ */
+static inline struct page *ntfs_map_page(struct address_space *mapping,
+		unsigned long index)
+{
+	struct page *page = read_cache_page(mapping, index,
+			(filler_t*)mapping->a_ops->readpage, NULL);
+
+	if (!IS_ERR(page)) {
+		wait_on_page_locked(page);
+		kmap(page);
+		if (PageUptodate(page) && !PageError(page))
+			return page;
+		ntfs_unmap_page(page);
+		return ERR_PTR(-EIO);
+	}
+	return page;
+}
+
+#ifdef NTFS_RW
+
+extern void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs);
+
+#endif /* NTFS_RW */
+
+#endif /* _LINUX_NTFS_AOPS_H */
diff -Nru a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
--- a/fs/ntfs/attrib.c	2004-12-24 13:37:32 -08:00
+++ b/fs/ntfs/attrib.c	2004-12-24 13:37:32 -08:00
@@ -1,5 +1,5 @@
 /**
- * attrib.c - NTFS attribute operations. Part of the Linux-NTFS project.
+ * attrib.c - NTFS attribute operations.  Part of the Linux-NTFS project.
  *
  * Copyright (c) 2001-2004 Anton Altaparmakov
  * Copyright (c) 2002 Richard Russon
@@ -21,915 +21,13 @@
  */
 
 #include <linux/buffer_head.h>
-#include "ntfs.h"
-#include "dir.h"
-
-/* Temporary helper functions -- might become macros */
-
-/**
- * ntfs_rl_mm - runlist memmove
- *
- * It is up to the caller to serialize access to the runlist @base.
- */
-static inline void ntfs_rl_mm(runlist_element *base, int dst, int src,
-		int size)
-{
-	if (likely((dst != src) && (size > 0)))
-		memmove(base + dst, base + src, size * sizeof (*base));
-}
-
-/**
- * ntfs_rl_mc - runlist memory copy
- *
- * It is up to the caller to serialize access to the runlists @dstbase and
- * @srcbase.
- */
-static inline void ntfs_rl_mc(runlist_element *dstbase, int dst,
-		runlist_element *srcbase, int src, int size)
-{
-	if (likely(size > 0))
-		memcpy(dstbase + dst, srcbase + src, size * sizeof(*dstbase));
-}
-
-/**
- * ntfs_rl_realloc - Reallocate memory for runlists
- * @rl:		original runlist
- * @old_size:	number of runlist elements in the original runlist @rl
- * @new_size:	number of runlist elements we need space for
- *
- * As the runlists grow, more memory will be required.  To prevent the
- * kernel having to allocate and reallocate large numbers of small bits of
- * memory, this function returns and entire page of memory.
- *
- * It is up to the caller to serialize access to the runlist @rl.
- *
- * N.B.  If the new allocation doesn't require a different number of pages in
- *       memory, the function will return the original pointer.
- *
- * On success, return a pointer to the newly allocated, or recycled, memory.
- * On error, return -errno. The following error codes are defined:
- *	-ENOMEM	- Not enough memory to allocate runlist array.
- *	-EINVAL	- Invalid parameters were passed in.
- */
-static inline runlist_element *ntfs_rl_realloc(runlist_element *rl,
-		int old_size, int new_size)
-{
-	runlist_element *new_rl;
-
-	old_size = PAGE_ALIGN(old_size * sizeof(*rl));
-	new_size = PAGE_ALIGN(new_size * sizeof(*rl));
-	if (old_size == new_size)
-		return rl;
-
-	new_rl = ntfs_malloc_nofs(new_size);
-	if (unlikely(!new_rl))
-		return ERR_PTR(-ENOMEM);
-
-	if (likely(rl != NULL)) {
-		if (unlikely(old_size > new_size))
-			old_size = new_size;
-		memcpy(new_rl, rl, old_size);
-		ntfs_free(rl);
-	}
-	return new_rl;
-}
-
-/**
- * ntfs_are_rl_mergeable - test if two runlists can be joined together
- * @dst:	original runlist
- * @src:	new runlist to test for mergeability with @dst
- *
- * Test if two runlists can be joined together. For this, their VCNs and LCNs
- * must be adjacent.
- *
- * It is up to the caller to serialize access to the runlists @dst and @src.
- *
- * Return: TRUE   Success, the runlists can be merged.
- *	   FALSE  Failure, the runlists cannot be merged.
- */
-static inline BOOL ntfs_are_rl_mergeable(runlist_element *dst,
-		runlist_element *src)
-{
-	BUG_ON(!dst);
-	BUG_ON(!src);
-
-	if ((dst->lcn < 0) || (src->lcn < 0))     /* Are we merging holes? */
-		return FALSE;
-	if ((dst->lcn + dst->length) != src->lcn) /* Are the runs contiguous? */
-		return FALSE;
-	if ((dst->vcn + dst->length) != src->vcn) /* Are the runs misaligned? */
-		return FALSE;
-
-	return TRUE;
-}
-
-/**
- * __ntfs_rl_merge - merge two runlists without testing if they can be merged
- * @dst:	original, destination runlist
- * @src:	new runlist to merge with @dst
- *
- * Merge the two runlists, writing into the destination runlist @dst. The
- * caller must make sure the runlists can be merged or this will corrupt the
- * destination runlist.
- *
- * It is up to the caller to serialize access to the runlists @dst and @src.
- */
-static inline void __ntfs_rl_merge(runlist_element *dst, runlist_element *src)
-{
-	dst->length += src->length;
-}
-
-/**
- * ntfs_rl_merge - test if two runlists can be joined together and merge them
- * @dst:	original, destination runlist
- * @src:	new runlist to merge with @dst
- *
- * Test if two runlists can be joined together. For this, their VCNs and LCNs
- * must be adjacent. If they can be merged, perform the merge, writing into
- * the destination runlist @dst.
- *
- * It is up to the caller to serialize access to the runlists @dst and @src.
- *
- * Return: TRUE   Success, the runlists have been merged.
- *	   FALSE  Failure, the runlists cannot be merged and have not been
- *		  modified.
- */
-static inline BOOL ntfs_rl_merge(runlist_element *dst, runlist_element *src)
-{
-	BOOL merge = ntfs_are_rl_mergeable(dst, src);
-
-	if (merge)
-		__ntfs_rl_merge(dst, src);
-	return merge;
-}
-
-/**
- * ntfs_rl_append - append a runlist after a given element
- * @dst:	original runlist to be worked on
- * @dsize:	number of elements in @dst (including end marker)
- * @src:	runlist to be inserted into @dst
- * @ssize:	number of elements in @src (excluding end marker)
- * @loc:	append the new runlist @src after this element in @dst
- *
- * Append the runlist @src after element @loc in @dst.  Merge the right end of
- * the new runlist, if necessary. Adjust the size of the hole before the
- * appended runlist.
- *
- * It is up to the caller to serialize access to the runlists @dst and @src.
- *
- * On success, return a pointer to the new, combined, runlist. Note, both
- * runlists @dst and @src are deallocated before returning so you cannot use
- * the pointers for anything any more. (Strictly speaking the returned runlist
- * may be the same as @dst but this is irrelevant.)
- *
- * On error, return -errno. Both runlists are left unmodified. The following
- * error codes are defined:
- *	-ENOMEM	- Not enough memory to allocate runlist array.
- *	-EINVAL	- Invalid parameters were passed in.
- */
-static inline runlist_element *ntfs_rl_append(runlist_element *dst,
-		int dsize, runlist_element *src, int ssize, int loc)
-{
-	BOOL right;
-	int magic;
-
-	BUG_ON(!dst);
-	BUG_ON(!src);
-
-	/* First, check if the right hand end needs merging. */
-	right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
-
-	/* Space required: @dst size + @src size, less one if we merged. */
-	dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - right);
-	if (IS_ERR(dst))
-		return dst;
-	/*
-	 * We are guaranteed to succeed from here so can start modifying the
-	 * original runlists.
-	 */
-
-	/* First, merge the right hand end, if necessary. */
-	if (right)
-		__ntfs_rl_merge(src + ssize - 1, dst + loc + 1);
-
-	magic = loc + ssize;
-
-	/* Move the tail of @dst out of the way, then copy in @src. */
-	ntfs_rl_mm(dst, magic + 1, loc + 1 + right, dsize - loc - 1 - right);
-	ntfs_rl_mc(dst, loc + 1, src, 0, ssize);
-
-	/* Adjust the size of the preceding hole. */
-	dst[loc].length = dst[loc + 1].vcn - dst[loc].vcn;
-
-	/* We may have changed the length of the file, so fix the end marker */
-	if (dst[magic + 1].lcn == LCN_ENOENT)
-		dst[magic + 1].vcn = dst[magic].vcn + dst[magic].length;
-
-	return dst;
-}
-
-/**
- * ntfs_rl_insert - insert a runlist into another
- * @dst:	original runlist to be worked on
- * @dsize:	number of elements in @dst (including end marker)
- * @src:	new runlist to be inserted
- * @ssize:	number of elements in @src (excluding end marker)
- * @loc:	insert the new runlist @src before this element in @dst
- *
- * Insert the runlist @src before element @loc in the runlist @dst. Merge the
- * left end of the new runlist, if necessary. Adjust the size of the hole
- * after the inserted runlist.
- *
- * It is up to the caller to serialize access to the runlists @dst and @src.
- *
- * On success, return a pointer to the new, combined, runlist. Note, both
- * runlists @dst and @src are deallocated before returning so you cannot use
- * the pointers for anything any more. (Strictly speaking the returned runlist
- * may be the same as @dst but this is irrelevant.)
- *
- * On error, return -errno. Both runlists are left unmodified. The following
- * error codes are defined:
- *	-ENOMEM	- Not enough memory to allocate runlist array.
- *	-EINVAL	- Invalid parameters were passed in.
- */
-static inline runlist_element *ntfs_rl_insert(runlist_element *dst,
-		int dsize, runlist_element *src, int ssize, int loc)
-{
-	BOOL left = FALSE;
-	BOOL disc = FALSE;	/* Discontinuity */
-	BOOL hole = FALSE;	/* Following a hole */
-	int magic;
-
-	BUG_ON(!dst);
-	BUG_ON(!src);
-
-	/* disc => Discontinuity between the end of @dst and the start of @src.
-	 *	   This means we might need to insert a hole.
-	 * hole => @dst ends with a hole or an unmapped region which we can
-	 *	   extend to match the discontinuity. */
-	if (loc == 0)
-		disc = (src[0].vcn > 0);
-	else {
-		s64 merged_length;
-
-		left = ntfs_are_rl_mergeable(dst + loc - 1, src);
-
-		merged_length = dst[loc - 1].length;
-		if (left)
-			merged_length += src->length;
-
-		disc = (src[0].vcn > dst[loc - 1].vcn + merged_length);
-		if (disc)
-			hole = (dst[loc - 1].lcn == LCN_HOLE);
-	}
-
-	/* Space required: @dst size + @src size, less one if we merged, plus
-	 * one if there was a discontinuity, less one for a trailing hole. */
-	dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left + disc - hole);
-	if (IS_ERR(dst))
-		return dst;
-	/*
-	 * We are guaranteed to succeed from here so can start modifying the
-	 * original runlist.
-	 */
-
-	if (left)
-		__ntfs_rl_merge(dst + loc - 1, src);
-
-	magic = loc + ssize - left + disc - hole;
-
-	/* Move the tail of @dst out of the way, then copy in @src. */
-	ntfs_rl_mm(dst, magic, loc, dsize - loc);
-	ntfs_rl_mc(dst, loc + disc - hole, src, left, ssize - left);
-
-	/* Adjust the VCN of the last run ... */
-	if (dst[magic].lcn <= LCN_HOLE)
-		dst[magic].vcn = dst[magic - 1].vcn + dst[magic - 1].length;
-	/* ... and the length. */
-	if (dst[magic].lcn == LCN_HOLE || dst[magic].lcn == LCN_RL_NOT_MAPPED)
-		dst[magic].length = dst[magic + 1].vcn - dst[magic].vcn;
-
-	/* Writing beyond the end of the file and there's a discontinuity. */
-	if (disc) {
-		if (hole)
-			dst[loc - 1].length = dst[loc].vcn - dst[loc - 1].vcn;
-		else {
-			if (loc > 0) {
-				dst[loc].vcn = dst[loc - 1].vcn +
-						dst[loc - 1].length;
-				dst[loc].length = dst[loc + 1].vcn -
-						dst[loc].vcn;
-			} else {
-				dst[loc].vcn = 0;
-				dst[loc].length = dst[loc + 1].vcn;
-			}
-			dst[loc].lcn = LCN_RL_NOT_MAPPED;
-		}
-
-		magic += hole;
-
-		if (dst[magic].lcn == LCN_ENOENT)
-			dst[magic].vcn = dst[magic - 1].vcn +
-					dst[magic - 1].length;
-	}
-	return dst;
-}
-
-/**
- * ntfs_rl_replace - overwrite a runlist element with another runlist
- * @dst:	original runlist to be worked on
- * @dsize:	number of elements in @dst (including end marker)
- * @src:	new runlist to be inserted
- * @ssize:	number of elements in @src (excluding end marker)
- * @loc:	index in runlist @dst to overwrite with @src
- *
- * Replace the runlist element @dst at @loc with @src. Merge the left and
- * right ends of the inserted runlist, if necessary.
- *
- * It is up to the caller to serialize access to the runlists @dst and @src.
- *
- * On success, return a pointer to the new, combined, runlist. Note, both
- * runlists @dst and @src are deallocated before returning so you cannot use
- * the pointers for anything any more. (Strictly speaking the returned runlist
- * may be the same as @dst but this is irrelevant.)
- *
- * On error, return -errno. Both runlists are left unmodified. The following
- * error codes are defined:
- *	-ENOMEM	- Not enough memory to allocate runlist array.
- *	-EINVAL	- Invalid parameters were passed in.
- */
-static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
-		int dsize, runlist_element *src, int ssize, int loc)
-{
-	BOOL left = FALSE;
-	BOOL right;
-	int magic;
-
-	BUG_ON(!dst);
-	BUG_ON(!src);
-
-	/* First, merge the left and right ends, if necessary. */
-	right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
-	if (loc > 0)
-		left = ntfs_are_rl_mergeable(dst + loc - 1, src);
-
-	/* Allocate some space. We'll need less if the left, right, or both
-	 * ends were merged. */
-	dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left - right);
-	if (IS_ERR(dst))
-		return dst;
-	/*
-	 * We are guaranteed to succeed from here so can start modifying the
-	 * original runlists.
-	 */
-	if (right)
-		__ntfs_rl_merge(src + ssize - 1, dst + loc + 1);
-	if (left)
-		__ntfs_rl_merge(dst + loc - 1, src);
-
-	/* FIXME: What does this mean? (AIA) */
-	magic = loc + ssize - left;
-
-	/* Move the tail of @dst out of the way, then copy in @src. */
-	ntfs_rl_mm(dst, magic, loc + right + 1, dsize - loc - right - 1);
-	ntfs_rl_mc(dst, loc, src, left, ssize - left);
-
-	/* We may have changed the length of the file, so fix the end marker */
-	if (dst[magic].lcn == LCN_ENOENT)
-		dst[magic].vcn = dst[magic - 1].vcn + dst[magic - 1].length;
-	return dst;
-}
-
-/**
- * ntfs_rl_split - insert a runlist into the centre of a hole
- * @dst:	original runlist to be worked on
- * @dsize:	number of elements in @dst (including end marker)
- * @src:	new runlist to be inserted
- * @ssize:	number of elements in @src (excluding end marker)
- * @loc:	index in runlist @dst at which to split and insert @src
- *
- * Split the runlist @dst at @loc into two and insert @new in between the two
- * fragments. No merging of runlists is necessary. Adjust the size of the
- * holes either side.
- *
- * It is up to the caller to serialize access to the runlists @dst and @src.
- *
- * On success, return a pointer to the new, combined, runlist. Note, both
- * runlists @dst and @src are deallocated before returning so you cannot use
- * the pointers for anything any more. (Strictly speaking the returned runlist
- * may be the same as @dst but this is irrelevant.)
- *
- * On error, return -errno. Both runlists are left unmodified. The following
- * error codes are defined:
- *	-ENOMEM	- Not enough memory to allocate runlist array.
- *	-EINVAL	- Invalid parameters were passed in.
- */
-static inline runlist_element *ntfs_rl_split(runlist_element *dst, int dsize,
-		runlist_element *src, int ssize, int loc)
-{
-	BUG_ON(!dst);
-	BUG_ON(!src);
-
-	/* Space required: @dst size + @src size + one new hole. */
-	dst = ntfs_rl_realloc(dst, dsize, dsize + ssize + 1);
-	if (IS_ERR(dst))
-		return dst;
-	/*
-	 * We are guaranteed to succeed from here so can start modifying the
-	 * original runlists.
-	 */
-
-	/* Move the tail of @dst out of the way, then copy in @src. */
-	ntfs_rl_mm(dst, loc + 1 + ssize, loc, dsize - loc);
-	ntfs_rl_mc(dst, loc + 1, src, 0, ssize);
-
-	/* Adjust the size of the holes either size of @src. */
-	dst[loc].length		= dst[loc+1].vcn       - dst[loc].vcn;
-	dst[loc+ssize+1].vcn    = dst[loc+ssize].vcn   + dst[loc+ssize].length;
-	dst[loc+ssize+1].length = dst[loc+ssize+2].vcn - dst[loc+ssize+1].vcn;
-
-	return dst;
-}
-
-/**
- * ntfs_merge_runlists - merge two runlists into one
- * @drl:	original runlist to be worked on
- * @srl:	new runlist to be merged into @drl
- *
- * First we sanity check the two runlists @srl and @drl to make sure that they
- * are sensible and can be merged. The runlist @srl must be either after the
- * runlist @drl or completely within a hole (or unmapped region) in @drl.
- *
- * It is up to the caller to serialize access to the runlists @drl and @srl.
- *
- * Merging of runlists is necessary in two cases:
- *   1. When attribute lists are used and a further extent is being mapped.
- *   2. When new clusters are allocated to fill a hole or extend a file.
- *
- * There are four possible ways @srl can be merged. It can:
- *	- be inserted at the beginning of a hole,
- *	- split the hole in two and be inserted between the two fragments,
- *	- be appended at the end of a hole, or it can
- *	- replace the whole hole.
- * It can also be appended to the end of the runlist, which is just a variant
- * of the insert case.
- *
- * On success, return a pointer to the new, combined, runlist. Note, both
- * runlists @drl and @srl are deallocated before returning so you cannot use
- * the pointers for anything any more. (Strictly speaking the returned runlist
- * may be the same as @dst but this is irrelevant.)
- *
- * On error, return -errno. Both runlists are left unmodified. The following
- * error codes are defined:
- *	-ENOMEM	- Not enough memory to allocate runlist array.
- *	-EINVAL	- Invalid parameters were passed in.
- *	-ERANGE	- The runlists overlap and cannot be merged.
- */
-runlist_element *ntfs_merge_runlists(runlist_element *drl,
-		runlist_element *srl)
-{
-	int di, si;		/* Current index into @[ds]rl. */
-	int sstart;		/* First index with lcn > LCN_RL_NOT_MAPPED. */
-	int dins;		/* Index into @drl at which to insert @srl. */
-	int dend, send;		/* Last index into @[ds]rl. */
-	int dfinal, sfinal;	/* The last index into @[ds]rl with
-				   lcn >= LCN_HOLE. */
-	int marker = 0;
-	VCN marker_vcn = 0;
-
-#ifdef DEBUG
-	ntfs_debug("dst:");
-	ntfs_debug_dump_runlist(drl);
-	ntfs_debug("src:");
-	ntfs_debug_dump_runlist(srl);
-#endif
-
-	/* Check for silly calling... */
-	if (unlikely(!srl))
-		return drl;
-	if (IS_ERR(srl) || IS_ERR(drl))
-		return ERR_PTR(-EINVAL);
-
-	/* Check for the case where the first mapping is being done now. */
-	if (unlikely(!drl)) {
-		drl = srl;
-		/* Complete the source runlist if necessary. */
-		if (unlikely(drl[0].vcn)) {
-			/* Scan to the end of the source runlist. */
-			for (dend = 0; likely(drl[dend].length); dend++)
-				;
-			drl = ntfs_rl_realloc(drl, dend, dend + 1);
-			if (IS_ERR(drl))
-				return drl;
-			/* Insert start element at the front of the runlist. */
-			ntfs_rl_mm(drl, 1, 0, dend);
-			drl[0].vcn = 0;
-			drl[0].lcn = LCN_RL_NOT_MAPPED;
-			drl[0].length = drl[1].vcn;
-		}
-		goto finished;
-	}
-
-	si = di = 0;
-
-	/* Skip any unmapped start element(s) in the source runlist. */
-	while (srl[si].length && srl[si].lcn < (LCN)LCN_HOLE)
-		si++;
-
-	/* Can't have an entirely unmapped source runlist. */
-	BUG_ON(!srl[si].length);
-
-	/* Record the starting points. */
-	sstart = si;
-
-	/*
-	 * Skip forward in @drl until we reach the position where @srl needs to
-	 * be inserted. If we reach the end of @drl, @srl just needs to be
-	 * appended to @drl.
-	 */
-	for (; drl[di].length; di++) {
-		if (drl[di].vcn + drl[di].length > srl[sstart].vcn)
-			break;
-	}
-	dins = di;
-
-	/* Sanity check for illegal overlaps. */
-	if ((drl[di].vcn == srl[si].vcn) && (drl[di].lcn >= 0) &&
-			(srl[si].lcn >= 0)) {
-		ntfs_error(NULL, "Run lists overlap. Cannot merge!");
-		return ERR_PTR(-ERANGE);
-	}
-
-	/* Scan to the end of both runlists in order to know their sizes. */
-	for (send = si; srl[send].length; send++)
-		;
-	for (dend = di; drl[dend].length; dend++)
-		;
-
-	if (srl[send].lcn == (LCN)LCN_ENOENT)
-		marker_vcn = srl[marker = send].vcn;
-
-	/* Scan to the last element with lcn >= LCN_HOLE. */
-	for (sfinal = send; sfinal >= 0 && srl[sfinal].lcn < LCN_HOLE; sfinal--)
-		;
-	for (dfinal = dend; dfinal >= 0 && drl[dfinal].lcn < LCN_HOLE; dfinal--)
-		;
-
-	{
-	BOOL start;
-	BOOL finish;
-	int ds = dend + 1;		/* Number of elements in drl & srl */
-	int ss = sfinal - sstart + 1;
-
-	start  = ((drl[dins].lcn <  LCN_RL_NOT_MAPPED) ||    /* End of file   */
-		  (drl[dins].vcn == srl[sstart].vcn));	     /* Start of hole */
-	finish = ((drl[dins].lcn >= LCN_RL_NOT_MAPPED) &&    /* End of file   */
-		 ((drl[dins].vcn + drl[dins].length) <=      /* End of hole   */
-		  (srl[send - 1].vcn + srl[send - 1].length)));
-
-	/* Or we'll lose an end marker */
-	if (start && finish && (drl[dins].length == 0))
-		ss++;
-	if (marker && (drl[dins].vcn + drl[dins].length > srl[send - 1].vcn))
-		finish = FALSE;
-#if 0
-	ntfs_debug("dfinal = %i, dend = %i", dfinal, dend);
-	ntfs_debug("sstart = %i, sfinal = %i, send = %i", sstart, sfinal, send);
-	ntfs_debug("start = %i, finish = %i", start, finish);
-	ntfs_debug("ds = %i, ss = %i, dins = %i", ds, ss, dins);
-#endif
-	if (start) {
-		if (finish)
-			drl = ntfs_rl_replace(drl, ds, srl + sstart, ss, dins);
-		else
-			drl = ntfs_rl_insert(drl, ds, srl + sstart, ss, dins);
-	} else {
-		if (finish)
-			drl = ntfs_rl_append(drl, ds, srl + sstart, ss, dins);
-		else
-			drl = ntfs_rl_split(drl, ds, srl + sstart, ss, dins);
-	}
-	if (IS_ERR(drl)) {
-		ntfs_error(NULL, "Merge failed.");
-		return drl;
-	}
-	ntfs_free(srl);
-	if (marker) {
-		ntfs_debug("Triggering marker code.");
-		for (ds = dend; drl[ds].length; ds++)
-			;
-		/* We only need to care if @srl ended after @drl. */
-		if (drl[ds].vcn <= marker_vcn) {
-			int slots = 0;
-
-			if (drl[ds].vcn == marker_vcn) {
-				ntfs_debug("Old marker = 0x%llx, replacing "
-						"with LCN_ENOENT.",
-						(unsigned long long)
-						drl[ds].lcn);
-				drl[ds].lcn = (LCN)LCN_ENOENT;
-				goto finished;
-			}
-			/*
-			 * We need to create an unmapped runlist element in
-			 * @drl or extend an existing one before adding the
-			 * ENOENT terminator.
-			 */
-			if (drl[ds].lcn == (LCN)LCN_ENOENT) {
-				ds--;
-				slots = 1;
-			}
-			if (drl[ds].lcn != (LCN)LCN_RL_NOT_MAPPED) {
-				/* Add an unmapped runlist element. */
-				if (!slots) {
-					/* FIXME/TODO: We need to have the
-					 * extra memory already! (AIA) */
-					drl = ntfs_rl_realloc(drl, ds, ds + 2);
-					if (!drl)
-						goto critical_error;
-					slots = 2;
-				}
-				ds++;
-				/* Need to set vcn if it isn't set already. */
-				if (slots != 1)
-					drl[ds].vcn = drl[ds - 1].vcn +
-							drl[ds - 1].length;
-				drl[ds].lcn = (LCN)LCN_RL_NOT_MAPPED;
-				/* We now used up a slot. */
-				slots--;
-			}
-			drl[ds].length = marker_vcn - drl[ds].vcn;
-			/* Finally add the ENOENT terminator. */
-			ds++;
-			if (!slots) {
-				/* FIXME/TODO: We need to have the extra
-				 * memory already! (AIA) */
-				drl = ntfs_rl_realloc(drl, ds, ds + 1);
-				if (!drl)
-					goto critical_error;
-			}
-			drl[ds].vcn = marker_vcn;
-			drl[ds].lcn = (LCN)LCN_ENOENT;
-			drl[ds].length = (s64)0;
-		}
-	}
-	}
-
-finished:
-	/* The merge was completed successfully. */
-	ntfs_debug("Merged runlist:");
-	ntfs_debug_dump_runlist(drl);
-	return drl;
-
-critical_error:
-	/* Critical error! We cannot afford to fail here. */
-	ntfs_error(NULL, "Critical error! Not enough memory.");
-	panic("NTFS: Cannot continue.");
-}
-
-/**
- * decompress_mapping_pairs - convert mapping pairs array to runlist
- * @vol:	ntfs volume on which the attribute resides
- * @attr:	attribute record whose mapping pairs array to decompress
- * @old_rl:	optional runlist in which to insert @attr's runlist
- *
- * It is up to the caller to serialize access to the runlist @old_rl.
- *
- * Decompress the attribute @attr's mapping pairs array into a runlist. On
- * success, return the decompressed runlist.
- *
- * If @old_rl is not NULL, decompressed runlist is inserted into the
- * appropriate place in @old_rl and the resultant, combined runlist is
- * returned. The original @old_rl is deallocated.
- *
- * On error, return -errno. @old_rl is left unmodified in that case.
- *
- * The following error codes are defined:
- *	-ENOMEM	- Not enough memory to allocate runlist array.
- *	-EIO	- Corrupt runlist.
- *	-EINVAL	- Invalid parameters were passed in.
- *	-ERANGE	- The two runlists overlap.
- *
- * FIXME: For now we take the conceptionally simplest approach of creating the
- * new runlist disregarding the already existing one and then splicing the
- * two into one, if that is possible (we check for overlap and discard the new
- * runlist if overlap present before returning ERR_PTR(-ERANGE)).
- */
-runlist_element *decompress_mapping_pairs(const ntfs_volume *vol,
-		const ATTR_RECORD *attr, runlist_element *old_rl)
-{
-	VCN vcn;		/* Current vcn. */
-	LCN lcn;		/* Current lcn. */
-	s64 deltaxcn;		/* Change in [vl]cn. */
-	runlist_element *rl;	/* The output runlist. */
-	u8 *buf;		/* Current position in mapping pairs array. */
-	u8 *attr_end;		/* End of attribute. */
-	int rlsize;		/* Size of runlist buffer. */
-	u16 rlpos;		/* Current runlist position in units of
-				   runlist_elements. */
-	u8 b;			/* Current byte offset in buf. */
-
-#ifdef DEBUG
-	/* Make sure attr exists and is non-resident. */
-	if (!attr || !attr->non_resident || sle64_to_cpu(
-			attr->data.non_resident.lowest_vcn) < (VCN)0) {
-		ntfs_error(vol->sb, "Invalid arguments.");
-		return ERR_PTR(-EINVAL);
-	}
-#endif
-	/* Start at vcn = lowest_vcn and lcn 0. */
-	vcn = sle64_to_cpu(attr->data.non_resident.lowest_vcn);
-	lcn = 0;
-	/* Get start of the mapping pairs array. */
-	buf = (u8*)attr + le16_to_cpu(
-			attr->data.non_resident.mapping_pairs_offset);
-	attr_end = (u8*)attr + le32_to_cpu(attr->length);
-	if (unlikely(buf < (u8*)attr || buf > attr_end)) {
-		ntfs_error(vol->sb, "Corrupt attribute.");
-		return ERR_PTR(-EIO);
-	}
-	/* Current position in runlist array. */
-	rlpos = 0;
-	/* Allocate first page and set current runlist size to one page. */
-	rl = ntfs_malloc_nofs(rlsize = PAGE_SIZE);
-	if (unlikely(!rl))
-		return ERR_PTR(-ENOMEM);
-	/* Insert unmapped starting element if necessary. */
-	if (vcn) {
-		rl->vcn = (VCN)0;
-		rl->lcn = (LCN)LCN_RL_NOT_MAPPED;
-		rl->length = vcn;
-		rlpos++;
-	}
-	while (buf < attr_end && *buf) {
-		/*
-		 * Allocate more memory if needed, including space for the
-		 * not-mapped and terminator elements. ntfs_malloc_nofs()
-		 * operates on whole pages only.
-		 */
-		if (((rlpos + 3) * sizeof(*old_rl)) > rlsize) {
-			runlist_element *rl2;
 
-			rl2 = ntfs_malloc_nofs(rlsize + (int)PAGE_SIZE);
-			if (unlikely(!rl2)) {
-				ntfs_free(rl);
-				return ERR_PTR(-ENOMEM);
-			}
-			memcpy(rl2, rl, rlsize);
-			ntfs_free(rl);
-			rl = rl2;
-			rlsize += PAGE_SIZE;
-		}
-		/* Enter the current vcn into the current runlist element. */
-		rl[rlpos].vcn = vcn;
-		/*
-		 * Get the change in vcn, i.e. the run length in clusters.
-		 * Doing it this way ensures that we signextend negative values.
-		 * A negative run length doesn't make any sense, but hey, I
-		 * didn't make up the NTFS specs and Windows NT4 treats the run
-		 * length as a signed value so that's how it is...
-		 */
-		b = *buf & 0xf;
-		if (b) {
-			if (unlikely(buf + b > attr_end))
-				goto io_error;
-			for (deltaxcn = (s8)buf[b--]; b; b--)
-				deltaxcn = (deltaxcn << 8) + buf[b];
-		} else { /* The length entry is compulsory. */
-			ntfs_error(vol->sb, "Missing length entry in mapping "
-					"pairs array.");
-			deltaxcn = (s64)-1;
-		}
-		/*
-		 * Assume a negative length to indicate data corruption and
-		 * hence clean-up and return NULL.
-		 */
-		if (unlikely(deltaxcn < 0)) {
-			ntfs_error(vol->sb, "Invalid length in mapping pairs "
-					"array.");
-			goto err_out;
-		}
-		/*
-		 * Enter the current run length into the current runlist
-		 * element.
-		 */
-		rl[rlpos].length = deltaxcn;
-		/* Increment the current vcn by the current run length. */
-		vcn += deltaxcn;
-		/*
-		 * There might be no lcn change at all, as is the case for
-		 * sparse clusters on NTFS 3.0+, in which case we set the lcn
-		 * to LCN_HOLE.
-		 */
-		if (!(*buf & 0xf0))
-			rl[rlpos].lcn = (LCN)LCN_HOLE;
-		else {
-			/* Get the lcn change which really can be negative. */
-			u8 b2 = *buf & 0xf;
-			b = b2 + ((*buf >> 4) & 0xf);
-			if (buf + b > attr_end)
-				goto io_error;
-			for (deltaxcn = (s8)buf[b--]; b > b2; b--)
-				deltaxcn = (deltaxcn << 8) + buf[b];
-			/* Change the current lcn to its new value. */
-			lcn += deltaxcn;
-#ifdef DEBUG
-			/*
-			 * On NTFS 1.2-, apparently can have lcn == -1 to
-			 * indicate a hole. But we haven't verified ourselves
-			 * whether it is really the lcn or the deltaxcn that is
-			 * -1. So if either is found give us a message so we
-			 * can investigate it further!
-			 */
-			if (vol->major_ver < 3) {
-				if (unlikely(deltaxcn == (LCN)-1))
-					ntfs_error(vol->sb, "lcn delta == -1");
-				if (unlikely(lcn == (LCN)-1))
-					ntfs_error(vol->sb, "lcn == -1");
-			}
-#endif
-			/* Check lcn is not below -1. */
-			if (unlikely(lcn < (LCN)-1)) {
-				ntfs_error(vol->sb, "Invalid LCN < -1 in "
-						"mapping pairs array.");
-				goto err_out;
-			}
-			/* Enter the current lcn into the runlist element. */
-			rl[rlpos].lcn = lcn;
-		}
-		/* Get to the next runlist element. */
-		rlpos++;
-		/* Increment the buffer position to the next mapping pair. */
-		buf += (*buf & 0xf) + ((*buf >> 4) & 0xf) + 1;
-	}
-	if (unlikely(buf >= attr_end))
-		goto io_error;
-	/*
-	 * If there is a highest_vcn specified, it must be equal to the final
-	 * vcn in the runlist - 1, or something has gone badly wrong.
-	 */
-	deltaxcn = sle64_to_cpu(attr->data.non_resident.highest_vcn);
-	if (unlikely(deltaxcn && vcn - 1 != deltaxcn)) {
-mpa_err:
-		ntfs_error(vol->sb, "Corrupt mapping pairs array in "
-				"non-resident attribute.");
-		goto err_out;
-	}
-	/* Setup not mapped runlist element if this is the base extent. */
-	if (!attr->data.non_resident.lowest_vcn) {
-		VCN max_cluster;
-
-		max_cluster = (sle64_to_cpu(
-				attr->data.non_resident.allocated_size) +
-				vol->cluster_size - 1) >>
-				vol->cluster_size_bits;
-		/*
-		 * If there is a difference between the highest_vcn and the
-		 * highest cluster, the runlist is either corrupt or, more
-		 * likely, there are more extents following this one.
-		 */
-		if (deltaxcn < --max_cluster) {
-			ntfs_debug("More extents to follow; deltaxcn = 0x%llx, "
-					"max_cluster = 0x%llx",
-					(unsigned long long)deltaxcn,
-					(unsigned long long)max_cluster);
-			rl[rlpos].vcn = vcn;
-			vcn += rl[rlpos].length = max_cluster - deltaxcn;
-			rl[rlpos].lcn = (LCN)LCN_RL_NOT_MAPPED;
-			rlpos++;
-		} else if (unlikely(deltaxcn > max_cluster)) {
-			ntfs_error(vol->sb, "Corrupt attribute. deltaxcn = "
-					"0x%llx, max_cluster = 0x%llx",
-					(unsigned long long)deltaxcn,
-					(unsigned long long)max_cluster);
-			goto mpa_err;
-		}
-		rl[rlpos].lcn = (LCN)LCN_ENOENT;
-	} else /* Not the base extent. There may be more extents to follow. */
-		rl[rlpos].lcn = (LCN)LCN_RL_NOT_MAPPED;
-
-	/* Setup terminating runlist element. */
-	rl[rlpos].vcn = vcn;
-	rl[rlpos].length = (s64)0;
-	/* If no existing runlist was specified, we are done. */
-	if (!old_rl) {
-		ntfs_debug("Mapping pairs array successfully decompressed:");
-		ntfs_debug_dump_runlist(rl);
-		return rl;
-	}
-	/* Now combine the new and old runlists checking for overlaps. */
-	old_rl = ntfs_merge_runlists(old_rl, rl);
-	if (likely(!IS_ERR(old_rl)))
-		return old_rl;
-	ntfs_free(rl);
-	ntfs_error(vol->sb, "Failed to merge runlists.");
-	return old_rl;
-io_error:
-	ntfs_error(vol->sb, "Corrupt attribute.");
-err_out:
-	ntfs_free(rl);
-	return ERR_PTR(-EIO);
-}
+#include "attrib.h"
+#include "debug.h"
+#include "layout.h"
+#include "mft.h"
+#include "ntfs.h"
+#include "types.h"
 
 /**
  * ntfs_map_runlist - map (a part of) a runlist of an ntfs inode
@@ -973,10 +71,11 @@
 
 	down_write(&ni->runlist.lock);
 	/* Make sure someone else didn't do the work while we were sleeping. */
-	if (likely(ntfs_vcn_to_lcn(ni->runlist.rl, vcn) <= LCN_RL_NOT_MAPPED)) {
+	if (likely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) <=
+			LCN_RL_NOT_MAPPED)) {
 		runlist_element *rl;
 
-		rl = decompress_mapping_pairs(ni->vol, ctx->attr,
+		rl = ntfs_mapping_pairs_decompress(ni->vol, ctx->attr,
 				ni->runlist.rl);
 		if (IS_ERR(rl))
 			err = PTR_ERR(rl);
@@ -993,63 +92,6 @@
 }
 
 /**
- * ntfs_vcn_to_lcn - convert a vcn into a lcn given a runlist
- * @rl:		runlist to use for conversion
- * @vcn:	vcn to convert
- *
- * Convert the virtual cluster number @vcn of an attribute into a logical
- * cluster number (lcn) of a device using the runlist @rl to map vcns to their
- * corresponding lcns.
- *
- * It is up to the caller to serialize access to the runlist @rl.
- *
- * Since lcns must be >= 0, we use negative return values with special meaning:
- *
- * Return value			Meaning / Description
- * ==================================================
- *  -1 = LCN_HOLE		Hole / not allocated on disk.
- *  -2 = LCN_RL_NOT_MAPPED	This is part of the runlist which has not been
- *				inserted into the runlist yet.
- *  -3 = LCN_ENOENT		There is no such vcn in the attribute.
- *
- * Locking: - The caller must have locked the runlist (for reading or writing).
- *	    - This function does not touch the lock.
- */
-LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn)
-{
-	int i;
-
-	BUG_ON(vcn < 0);
-	/*
-	 * If rl is NULL, assume that we have found an unmapped runlist. The
-	 * caller can then attempt to map it and fail appropriately if
-	 * necessary.
-	 */
-	if (unlikely(!rl))
-		return (LCN)LCN_RL_NOT_MAPPED;
-
-	/* Catch out of lower bounds vcn. */
-	if (unlikely(vcn < rl[0].vcn))
-		return (LCN)LCN_ENOENT;
-
-	for (i = 0; likely(rl[i].length); i++) {
-		if (unlikely(vcn < rl[i+1].vcn)) {
-			if (likely(rl[i].lcn >= (LCN)0))
-				return rl[i].lcn + (vcn - rl[i].vcn);
-			return rl[i].lcn;
-		}
-	}
-	/*
-	 * The terminator element is setup to the correct value, i.e. one of
-	 * LCN_HOLE, LCN_RL_NOT_MAPPED, or LCN_ENOENT.
-	 */
-	if (likely(rl[i].lcn < (LCN)0))
-		return rl[i].lcn;
-	/* Just in case... We could replace this with BUG() some day. */
-	return (LCN)LCN_ENOENT;
-}
-
-/**
  * ntfs_find_vcn - find a vcn in the runlist described by an ntfs inode
  * @ni:		ntfs inode describing the runlist to search
  * @vcn:	vcn to find
@@ -1104,7 +146,7 @@
 	if (likely(rl && vcn >= rl[0].vcn)) {
 		while (likely(rl->length)) {
 			if (likely(vcn < rl[1].vcn)) {
-				if (likely(rl->lcn >= (LCN)LCN_HOLE)) {
+				if (likely(rl->lcn >= LCN_HOLE)) {
 					ntfs_debug("Done.");
 					return rl;
 				}
@@ -1112,8 +154,8 @@
 			}
 			rl++;
 		}
-		if (likely(rl->lcn != (LCN)LCN_RL_NOT_MAPPED)) {
-			if (likely(rl->lcn == (LCN)LCN_ENOENT))
+		if (likely(rl->lcn != LCN_RL_NOT_MAPPED)) {
+			if (likely(rl->lcn == LCN_ENOENT))
 				err = -ENOENT;
 			else
 				err = -EIO;
@@ -1208,19 +250,10 @@
 		const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
 {
 	ATTR_RECORD *a;
-	ntfs_volume *vol;
-	ntfschar *upcase;
-	u32 upcase_len;
+	ntfs_volume *vol = ctx->ntfs_ino->vol;
+	ntfschar *upcase = vol->upcase;
+	u32 upcase_len = vol->upcase_len;
 
-	if (ic == IGNORE_CASE) {
-		vol = ctx->ntfs_ino->vol;
-		upcase = vol->upcase;
-		upcase_len = vol->upcase_len;
-	} else {
-		vol = NULL;
-		upcase = NULL;
-		upcase_len = 0;
-	}
 	/*
 	 * Iterate over attributes in mft record starting at @ctx->attr, or the
 	 * attribute following that, if @ctx->is_first is TRUE.
@@ -1312,7 +345,7 @@
 				return -ENOENT;
 		}
 	}
-	ntfs_error(NULL, "Inode is corrupt.  Run chkdsk.");
+	ntfs_error(vol->sb, "Inode is corrupt.  Run chkdsk.");
 	NVolSetErrors(vol);
 	return -EIO;
 }
@@ -1362,14 +395,14 @@
 	rl = runlist->rl;
 	/* Read all clusters specified by the runlist one run at a time. */
 	while (rl->length) {
-		lcn = ntfs_vcn_to_lcn(rl, rl->vcn);
+		lcn = ntfs_rl_vcn_to_lcn(rl, rl->vcn);
 		ntfs_debug("Reading vcn = 0x%llx, lcn = 0x%llx.",
 				(unsigned long long)rl->vcn,
 				(unsigned long long)lcn);
 		/* The attribute list cannot be sparse. */
 		if (lcn < 0) {
-			ntfs_error(sb, "ntfs_vcn_to_lcn() failed. Cannot read "
-					"attribute list.");
+			ntfs_error(sb, "ntfs_rl_vcn_to_lcn() failed.  Cannot "
+					"read attribute list.");
 			goto err_out;
 		}
 		block = lcn << vol->cluster_size_bits >> block_size_bits;
@@ -1622,7 +655,6 @@
 				ctx->mrec = map_extent_mft_record(base_ni,
 						le64_to_cpu(
 						al_entry->mft_reference), &ni);
-				ctx->ntfs_ino = ni;
 				if (IS_ERR(ctx->mrec)) {
 					ntfs_error(vol->sb, "Failed to map "
 							"extent mft record "
@@ -1634,8 +666,11 @@
 					err = PTR_ERR(ctx->mrec);
 					if (err == -ENOENT)
 						err = -EIO;
+					/* Cause @ctx to be sanitized below. */
+					ni = NULL;
 					break;
 				}
+				ctx->ntfs_ino = ni;
 			}
 			ctx->attr = (ATTR_RECORD*)((u8*)ctx->mrec +
 					le16_to_cpu(ctx->mrec->attrs_offset));
@@ -1707,7 +742,8 @@
 		err = -EIO;
 	}
 	if (ni != base_ni) {
-		unmap_extent_mft_record(ni);
+		if (ni)
+			unmap_extent_mft_record(ni);
 		ctx->ntfs_ino = base_ni;
 		ctx->mrec = ctx->base_mrec;
 		ctx->attr = ctx->base_attr;
@@ -1907,4 +943,316 @@
 		unmap_extent_mft_record(ctx->ntfs_ino);
 	kmem_cache_free(ntfs_attr_ctx_cache, ctx);
 	return;
+}
+
+/**
+ * ntfs_attr_find_in_attrdef - find an attribute in the $AttrDef system file
+ * @vol:	ntfs volume to which the attribute belongs
+ * @type:	attribute type which to find
+ *
+ * Search for the attribute definition record corresponding to the attribute
+ * @type in the $AttrDef system file.
+ *
+ * Return the attribute type definition record if found and NULL if not found.
+ */
+static ATTR_DEF *ntfs_attr_find_in_attrdef(const ntfs_volume *vol,
+		const ATTR_TYPE type)
+{
+	ATTR_DEF *ad;
+
+	BUG_ON(!vol->attrdef);
+	BUG_ON(!type);
+	for (ad = vol->attrdef; (u8*)ad - (u8*)vol->attrdef <
+			vol->attrdef_size && ad->type; ++ad) {
+		/* We have not found it yet, carry on searching. */
+		if (likely(le32_to_cpu(ad->type) < le32_to_cpu(type)))
+			continue;
+		/* We found the attribute; return it. */
+		if (likely(ad->type == type))
+			return ad;
+		/* We have gone too far already.  No point in continuing. */
+		break;
+	}
+	/* Attribute not found. */
+	ntfs_debug("Attribute type 0x%x not found in $AttrDef.",
+			le32_to_cpu(type));
+	return NULL;
+}
+
+/**
+ * ntfs_attr_size_bounds_check - check a size of an attribute type for validity
+ * @vol:	ntfs volume to which the attribute belongs
+ * @type:	attribute type which to check
+ * @size:	size which to check
+ *
+ * Check whether the @size in bytes is valid for an attribute of @type on the
+ * ntfs volume @vol.  This information is obtained from $AttrDef system file.
+ *
+ * Return 0 if valid, -ERANGE if not valid, or -ENOENT if the attribute is not
+ * listed in $AttrDef.
+ */
+int ntfs_attr_size_bounds_check(const ntfs_volume *vol, const ATTR_TYPE type,
+		const s64 size)
+{
+	ATTR_DEF *ad;
+
+	BUG_ON(size < 0);
+	/*
+	 * $ATTRIBUTE_LIST has a maximum size of 256kiB, but this is not
+	 * listed in $AttrDef.
+	 */
+	if (unlikely(type == AT_ATTRIBUTE_LIST && size > 256 * 1024))
+		return -ERANGE;
+	/* Get the $AttrDef entry for the attribute @type. */
+	ad = ntfs_attr_find_in_attrdef(vol, type);
+	if (unlikely(!ad))
+		return -ENOENT;
+	/* Do the bounds check. */
+	if (((sle64_to_cpu(ad->min_size) > 0) &&
+			size < sle64_to_cpu(ad->min_size)) ||
+			((sle64_to_cpu(ad->max_size) > 0) && size >
+			sle64_to_cpu(ad->max_size)))
+		return -ERANGE;
+	return 0;
+}
+
+/**
+ * ntfs_attr_can_be_non_resident - check if an attribute can be non-resident
+ * @vol:	ntfs volume to which the attribute belongs
+ * @type:	attribute type which to check
+ *
+ * Check whether the attribute of @type on the ntfs volume @vol is allowed to
+ * be non-resident.  This information is obtained from $AttrDef system file.
+ *
+ * Return 0 if the attribute is allowed to be non-resident, -EPERM if not, or
+ * -ENOENT if the attribute is not listed in $AttrDef.
+ */
+int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, const ATTR_TYPE type)
+{
+	ATTR_DEF *ad;
+
+	/*
+	 * $DATA is always allowed to be non-resident even if $AttrDef does not
+	 * specify this in the flags of the $DATA attribute definition record.
+	 */
+	if (type == AT_DATA)
+		return 0;
+	/* Find the attribute definition record in $AttrDef. */
+	ad = ntfs_attr_find_in_attrdef(vol, type);
+	if (unlikely(!ad))
+		return -ENOENT;
+	/* Check the flags and return the result. */
+	if (ad->flags & CAN_BE_NON_RESIDENT)
+		return 0;
+	return -EPERM;
+}
+
+/**
+ * ntfs_attr_can_be_resident - check if an attribute can be resident
+ * @vol:	ntfs volume to which the attribute belongs
+ * @type:	attribute type which to check
+ *
+ * Check whether the attribute of @type on the ntfs volume @vol is allowed to
+ * be resident.  This information is derived from our ntfs knowledge and may
+ * not be completely accurate, especially when user defined attributes are
+ * present.  Basically we allow everything to be resident except for index
+ * allocation and $EA attributes.
+ *
+ * Return 0 if the attribute is allowed to be non-resident and -EPERM if not.
+ *
+ * Warning: In the system file $MFT the attribute $Bitmap must be non-resident
+ *	    otherwise windows will not boot (blue screen of death)!  We cannot
+ *	    check for this here as we do not know which inode's $Bitmap is
+ *	    being asked about so the caller needs to special case this.
+ */
+int ntfs_attr_can_be_resident(const ntfs_volume *vol, const ATTR_TYPE type)
+{
+	if (type != AT_INDEX_ALLOCATION && type != AT_EA)
+		return 0;
+	return -EPERM;
+}
+
+/**
+ * ntfs_attr_record_resize - resize an attribute record
+ * @m:		mft record containing attribute record
+ * @a:		attribute record to resize
+ * @new_size:	new size in bytes to which to resize the attribute record @a
+ *
+ * Resize the attribute record @a, i.e. the resident part of the attribute, in
+ * the mft record @m to @new_size bytes.
+ *
+ * Return 0 on success and -errno on error.  The following error codes are
+ * defined:
+ *	-ENOSPC	- Not enough space in the mft record @m to perform the resize.
+ *
+ * Note: On error, no modifications have been performed whatsoever.
+ *
+ * Warning: If you make a record smaller without having copied all the data you
+ *	    are interested in the data may be overwritten.
+ */
+int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size)
+{
+	ntfs_debug("Entering for new_size %u.", new_size);
+	/* Align to 8 bytes if it is not already done. */
+	if (new_size & 7)
+		new_size = (new_size + 7) & ~7;
+	/* If the actual attribute length has changed, move things around. */
+	if (new_size != le32_to_cpu(a->length)) {
+		u32 new_muse = le32_to_cpu(m->bytes_in_use) -
+				le32_to_cpu(a->length) + new_size;
+		/* Not enough space in this mft record. */
+		if (new_muse > le32_to_cpu(m->bytes_allocated))
+			return -ENOSPC;
+		/* Move attributes following @a to their new location. */
+		memmove((u8*)a + new_size, (u8*)a + le32_to_cpu(a->length),
+				le32_to_cpu(m->bytes_in_use) - ((u8*)a -
+				(u8*)m) - le32_to_cpu(a->length));
+		/* Adjust @m to reflect the change in used space. */
+		m->bytes_in_use = cpu_to_le32(new_muse);
+		/* Adjust @a to reflect the new size. */
+		if (new_size >= offsetof(ATTR_REC, length) + sizeof(a->length))
+			a->length = cpu_to_le32(new_size);
+	}
+	return 0;
+}
+
+/**
+ * ntfs_attr_set - fill (a part of) an attribute with a byte
+ * @ni:		ntfs inode describing the attribute to fill
+ * @ofs:	offset inside the attribute at which to start to fill
+ * @cnt:	number of bytes to fill
+ * @val:	the unsigned 8-bit value with which to fill the attribute
+ *
+ * Fill @cnt bytes of the attribute described by the ntfs inode @ni starting at
+ * byte offset @ofs inside the attribute with the constant byte @val.
+ *
+ * This function is effectively like memset() applied to an ntfs attribute.
+ *
+ * Return 0 on success and -errno on error.  An error code of -ESPIPE means
+ * that @ofs + @cnt were outside the end of the attribute and no write was
+ * performed.
+ */
+int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val)
+{
+	ntfs_volume *vol = ni->vol;
+	struct address_space *mapping;
+	struct page *page;
+	u8 *kaddr;
+	pgoff_t idx, end;
+	unsigned int start_ofs, end_ofs, size;
+
+	ntfs_debug("Entering for ofs 0x%llx, cnt 0x%llx, val 0x%hx.",
+			(long long)ofs, (long long)cnt, val);
+	BUG_ON(ofs < 0);
+	BUG_ON(cnt < 0);
+	if (!cnt)
+		goto done;
+	mapping = VFS_I(ni)->i_mapping;
+	/* Work out the starting index and page offset. */
+	idx = ofs >> PAGE_CACHE_SHIFT;
+	start_ofs = ofs & ~PAGE_CACHE_MASK;
+	/* Work out the ending index and page offset. */
+	end = ofs + cnt;
+	end_ofs = end & ~PAGE_CACHE_MASK;
+	/* If the end is outside the inode size return -ESPIPE. */
+	if (unlikely(end > VFS_I(ni)->i_size)) {
+		ntfs_error(vol->sb, "Request exceeds end of attribute.");
+		return -ESPIPE;
+	}
+	end >>= PAGE_CACHE_SHIFT;
+	/* If there is a first partial page, need to do it the slow way. */
+	if (start_ofs) {
+		page = read_cache_page(mapping, idx,
+				(filler_t*)mapping->a_ops->readpage, NULL);
+		if (IS_ERR(page)) {
+			ntfs_error(vol->sb, "Failed to read first partial "
+					"page (sync error, index 0x%lx).", idx);
+			return PTR_ERR(page);
+		}
+		wait_on_page_locked(page);
+		if (unlikely(!PageUptodate(page))) {
+			ntfs_error(vol->sb, "Failed to read first partial page "
+					"(async error, index 0x%lx).", idx);
+			page_cache_release(page);
+			return PTR_ERR(page);
+		}
+		/*
+		 * If the last page is the same as the first page, need to
+		 * limit the write to the end offset.
+		 */
+		size = PAGE_CACHE_SIZE;
+		if (idx == end)
+			size = end_ofs;
+		kaddr = kmap_atomic(page, KM_USER0);
+		memset(kaddr + start_ofs, val, size - start_ofs);
+		flush_dcache_page(page);
+		kunmap_atomic(kaddr, KM_USER0);
+		set_page_dirty(page);
+		page_cache_release(page);
+		if (idx == end)
+			goto done;
+		idx++;
+	}
+	/* Do the whole pages the fast way. */
+	for (; idx < end; idx++) {
+		/* Find or create the current page.  (The page is locked.) */
+		page = grab_cache_page(mapping, idx);
+		if (unlikely(!page)) {
+			ntfs_error(vol->sb, "Insufficient memory to grab "
+					"page (index 0x%lx).", idx);
+			return -ENOMEM;
+		}
+		kaddr = kmap_atomic(page, KM_USER0);
+		memset(kaddr, val, PAGE_CACHE_SIZE);
+		flush_dcache_page(page);
+		kunmap_atomic(kaddr, KM_USER0);
+		/*
+		 * If the page has buffers, mark them uptodate since buffer
+		 * state and not page state is definitive in 2.6 kernels.
+		 */
+		if (page_has_buffers(page)) {
+			struct buffer_head *bh, *head;
+
+			bh = head = page_buffers(page);
+			do {
+				set_buffer_uptodate(bh);
+			} while ((bh = bh->b_this_page) != head);
+		}
+		/* Now that buffers are uptodate, set the page uptodate, too. */
+		SetPageUptodate(page);
+		/*
+		 * Set the page and all its buffers dirty and mark the inode
+		 * dirty, too.  The VM will write the page later on.
+		 */
+		set_page_dirty(page);
+		/* Finally unlock and release the page. */
+		unlock_page(page);
+		page_cache_release(page);
+	}
+	/* If there is a last partial page, need to do it the slow way. */
+	if (end_ofs) {
+		page = read_cache_page(mapping, idx,
+				(filler_t*)mapping->a_ops->readpage, NULL);
+		if (IS_ERR(page)) {
+			ntfs_error(vol->sb, "Failed to read last partial page "
+					"(sync error, index 0x%lx).", idx);
+			return PTR_ERR(page);
+		}
+		wait_on_page_locked(page);
+		if (unlikely(!PageUptodate(page))) {
+			ntfs_error(vol->sb, "Failed to read last partial page "
+					"(async error, index 0x%lx).", idx);
+			page_cache_release(page);
+			return PTR_ERR(page);
+		}
+		kaddr = kmap_atomic(page, KM_USER0);
+		memset(kaddr, val, end_ofs);
+		flush_dcache_page(page);
+		kunmap_atomic(kaddr, KM_USER0);
+		set_page_dirty(page);
+		page_cache_release(page);
+	}
+done:
+	ntfs_debug("Done.");
+	return 0;
 }
diff -Nru a/fs/ntfs/attrib.h b/fs/ntfs/attrib.h
--- a/fs/ntfs/attrib.h	2004-12-24 13:36:48 -08:00
+++ b/fs/ntfs/attrib.h	2004-12-24 13:36:48 -08:00
@@ -24,23 +24,12 @@
 #ifndef _LINUX_NTFS_ATTRIB_H
 #define _LINUX_NTFS_ATTRIB_H
 
-#include <linux/fs.h>
-
 #include "endian.h"
 #include "types.h"
 #include "layout.h"
-
-static inline void init_runlist(runlist *rl)
-{
-	rl->rl = NULL;
-	init_rwsem(&rl->lock);
-}
-
-typedef enum {
-	LCN_HOLE		= -1,	/* Keep this as highest value or die! */
-	LCN_RL_NOT_MAPPED	= -2,
-	LCN_ENOENT		= -3,
-} LCN_SPECIAL_VALUES;
+#include "inode.h"
+#include "runlist.h"
+#include "volume.h"
 
 /**
  * ntfs_attr_search_ctx - used in attribute search functions
@@ -71,13 +60,8 @@
 	ATTR_RECORD *base_attr;
 } ntfs_attr_search_ctx;
 
-extern runlist_element *decompress_mapping_pairs(const ntfs_volume *vol,
-		const ATTR_RECORD *attr, runlist_element *old_rl);
-
 extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn);
 
-extern LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
-
 extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
 		const BOOL need_write);
 
@@ -100,5 +84,17 @@
 extern ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni,
 		MFT_RECORD *mrec);
 extern void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx);
+
+extern int ntfs_attr_size_bounds_check(const ntfs_volume *vol,
+		const ATTR_TYPE type, const s64 size);
+extern int ntfs_attr_can_be_non_resident(const ntfs_volume *vol,
+		const ATTR_TYPE type);
+extern int ntfs_attr_can_be_resident(const ntfs_volume *vol,
+		const ATTR_TYPE type);
+
+extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size);
+
+extern int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt,
+		const u8 val);
 
 #endif /* _LINUX_NTFS_ATTRIB_H */
diff -Nru a/fs/ntfs/bitmap.c b/fs/ntfs/bitmap.c
--- a/fs/ntfs/bitmap.c	2004-12-24 13:37:02 -08:00
+++ b/fs/ntfs/bitmap.c	2004-12-24 13:37:02 -08:00
@@ -25,6 +25,7 @@
 
 #include "bitmap.h"
 #include "debug.h"
+#include "aops.h"
 #include "ntfs.h"
 
 /**
diff -Nru a/fs/ntfs/collate.c b/fs/ntfs/collate.c
--- a/fs/ntfs/collate.c	2004-12-24 13:37:18 -08:00
+++ b/fs/ntfs/collate.c	2004-12-24 13:37:18 -08:00
@@ -19,8 +19,9 @@
  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "ntfs.h"
 #include "collate.h"
+#include "debug.h"
+#include "ntfs.h"
 
 static int ntfs_collate_binary(ntfs_volume *vol,
 		const void *data1, const int data1_len,
diff -Nru a/fs/ntfs/compress.c b/fs/ntfs/compress.c
--- a/fs/ntfs/compress.c	2004-12-24 13:36:54 -08:00
+++ b/fs/ntfs/compress.c	2004-12-24 13:36:54 -08:00
@@ -24,7 +24,11 @@
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
 #include <linux/blkdev.h>
+#include <linux/vmalloc.h>
 
+#include "attrib.h"
+#include "inode.h"
+#include "debug.h"
 #include "ntfs.h"
 
 /**
@@ -600,9 +604,9 @@
 			/* Seek to element containing target vcn. */
 			while (rl->length && rl[1].vcn <= vcn)
 				rl++;
-			lcn = ntfs_vcn_to_lcn(rl, vcn);
+			lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
 		} else
-			lcn = (LCN)LCN_RL_NOT_MAPPED;
+			lcn = LCN_RL_NOT_MAPPED;
 		ntfs_debug("Reading vcn = 0x%llx, lcn = 0x%llx.",
 				(unsigned long long)vcn,
 				(unsigned long long)lcn);
@@ -926,7 +930,7 @@
 
 rl_err:
 	up_read(&ni->runlist.lock);
-	ntfs_error(vol->sb, "ntfs_vcn_to_lcn() failed. Cannot read "
+	ntfs_error(vol->sb, "ntfs_rl_vcn_to_lcn() failed. Cannot read "
 			"compression block.");
 	goto err_out;
 
diff -Nru a/fs/ntfs/debug.c b/fs/ntfs/debug.c
--- a/fs/ntfs/debug.c	2004-12-24 13:37:43 -08:00
+++ b/fs/ntfs/debug.c	2004-12-24 13:37:43 -08:00
@@ -127,8 +127,8 @@
 	va_start(args, fmt);
 	vsnprintf(err_buf, sizeof(err_buf), fmt, args);
 	va_end(args);
-	printk(KERN_DEBUG "NTFS-fs DEBUG (%s, %d): %s(): %s\n",
-		file, line, flen ? function : "", err_buf);
+	printk(KERN_DEBUG "NTFS-fs DEBUG (%s, %d): %s(): %s\n", file, line,
+			flen ? function : "", err_buf);
 	spin_unlock(&err_buf_lock);
 }
 
@@ -141,8 +141,7 @@
 
 	if (!debug_msgs)
 		return;
-	printk(KERN_DEBUG "NTFS-fs DEBUG: Dumping runlist (values "
-			"in hex):\n");
+	printk(KERN_DEBUG "NTFS-fs DEBUG: Dumping runlist (values in hex):\n");
 	if (!rl) {
 		printk(KERN_DEBUG "Run list not present.\n");
 		return;
@@ -157,14 +156,14 @@
 			if (index > -LCN_ENOENT - 1)
 				index = 3;
 			printk(KERN_DEBUG "%-16Lx %s %-16Lx%s\n",
-				(rl + i)->vcn, lcn_str[index],
-				(rl + i)->length, (rl + i)->length ?
-				"" : " (runlist end)");
+					(rl + i)->vcn, lcn_str[index],
+					(rl + i)->length, (rl + i)->length ?
+					"" : " (runlist end)");
 		} else
 			printk(KERN_DEBUG "%-16Lx %-16Lx  %-16Lx%s\n",
-				(rl + i)->vcn, (rl + i)->lcn,
-				(rl + i)->length, (rl + i)->length ?
-				"" : " (runlist end)");
+					(rl + i)->vcn, (rl + i)->lcn,
+					(rl + i)->length, (rl + i)->length ?
+					"" : " (runlist end)");
 		if (!(rl + i)->length)
 			break;
 	}
diff -Nru a/fs/ntfs/debug.h b/fs/ntfs/debug.h
--- a/fs/ntfs/debug.h	2004-12-24 13:37:02 -08:00
+++ b/fs/ntfs/debug.h	2004-12-24 13:37:02 -08:00
@@ -22,13 +22,9 @@
 #ifndef _LINUX_NTFS_DEBUG_H
 #define _LINUX_NTFS_DEBUG_H
 
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/spinlock.h>
 #include <linux/fs.h>
 
-#include "inode.h"
-#include "attrib.h"
+#include "runlist.h"
 
 #ifdef DEBUG
 
diff -Nru a/fs/ntfs/dir.c b/fs/ntfs/dir.c
--- a/fs/ntfs/dir.c	2004-12-24 13:36:34 -08:00
+++ b/fs/ntfs/dir.c	2004-12-24 13:36:34 -08:00
@@ -21,8 +21,14 @@
  */
 
 #include <linux/smp_lock.h>
-#include "ntfs.h"
+#include <linux/buffer_head.h>
+
 #include "dir.h"
+#include "aops.h"
+#include "attrib.h"
+#include "mft.h"
+#include "debug.h"
+#include "ntfs.h"
 
 /**
  * The little endian Unicode string $I30 as a global constant.
@@ -294,7 +300,6 @@
 		ntfs_error(sb, "No index allocation attribute but index entry "
 				"requires one. Directory inode 0x%lx is "
 				"corrupt or driver bug.", dir_ni->mft_no);
-		err = -EIO;
 		goto err_out;
 	}
 	/* Get the starting vcn of the index_block holding the child node. */
@@ -332,7 +337,13 @@
 	if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) {
 		ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
 				"inode 0x%lx or driver bug.", dir_ni->mft_no);
-		err = -EIO;
+		goto unm_err_out;
+	}
+	/* Catch multi sector transfer fixup errors. */
+	if (unlikely(!ntfs_is_indx_record(ia->magic))) {
+		ntfs_error(sb, "Directory index record with vcn 0x%llx is "
+				"corrupt.  Corrupt inode 0x%lx.  Run chkdsk.",
+				(unsigned long long)vcn, dir_ni->mft_no);
 		goto unm_err_out;
 	}
 	if (sle64_to_cpu(ia->index_block_vcn) != vcn) {
@@ -342,7 +353,6 @@
 				"bug.", (unsigned long long)
 				sle64_to_cpu(ia->index_block_vcn),
 				(unsigned long long)vcn, dir_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
@@ -354,7 +364,6 @@
 				(unsigned long long)vcn, dir_ni->mft_no,
 				le32_to_cpu(ia->index.allocated_size) + 0x18,
 				dir_ni->itype.index.block_size);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	index_end = (u8*)ia + dir_ni->itype.index.block_size;
@@ -364,7 +373,6 @@
 				"Cannot access! This is probably a bug in the "
 				"driver.", (unsigned long long)vcn,
 				dir_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
@@ -372,7 +380,6 @@
 		ntfs_error(sb, "Size of index buffer (VCN 0x%llx) of directory "
 				"inode 0x%lx exceeds maximum size.",
 				(unsigned long long)vcn, dir_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	/* The first index entry. */
@@ -392,7 +399,6 @@
 			ntfs_error(sb, "Index entry out of bounds in "
 					"directory inode 0x%lx.",
 					dir_ni->mft_no);
-			err = -EIO;
 			goto unm_err_out;
 		}
 		/*
@@ -545,7 +551,6 @@
 			ntfs_error(sb, "Index entry with child node found in "
 					"a leaf node in directory inode 0x%lx.",
 					dir_ni->mft_no);
-			err = -EIO;
 			goto unm_err_out;
 		}
 		/* Child node present, descend into it. */
@@ -566,7 +571,6 @@
 		}
 		ntfs_error(sb, "Negative child node vcn in directory inode "
 				"0x%lx.", dir_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	/*
@@ -585,6 +589,8 @@
 	unlock_page(page);
 	ntfs_unmap_page(page);
 err_out:
+	if (!err)
+		err = -EIO;
 	if (ctx)
 		ntfs_attr_put_search_ctx(ctx);
 	if (m)
@@ -595,8 +601,7 @@
 	}
 	return ERR_MREF(err);
 dir_err_out:
-	ntfs_error(sb, "Corrupt directory. Aborting lookup.");
-	err = -EIO;
+	ntfs_error(sb, "Corrupt directory.  Aborting lookup.");
 	goto err_out;
 }
 
@@ -774,7 +779,6 @@
 		ntfs_error(sb, "No index allocation attribute but index entry "
 				"requires one. Directory inode 0x%lx is "
 				"corrupt or driver bug.", dir_ni->mft_no);
-		err = -EIO;
 		goto err_out;
 	}
 	/* Get the starting vcn of the index_block holding the child node. */
@@ -812,7 +816,13 @@
 	if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) {
 		ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
 				"inode 0x%lx or driver bug.", dir_ni->mft_no);
-		err = -EIO;
+		goto unm_err_out;
+	}
+	/* Catch multi sector transfer fixup errors. */
+	if (unlikely(!ntfs_is_indx_record(ia->magic))) {
+		ntfs_error(sb, "Directory index record with vcn 0x%llx is "
+				"corrupt.  Corrupt inode 0x%lx.  Run chkdsk.",
+				(unsigned long long)vcn, dir_ni->mft_no);
 		goto unm_err_out;
 	}
 	if (sle64_to_cpu(ia->index_block_vcn) != vcn) {
@@ -822,7 +832,6 @@
 				"bug.", (unsigned long long)
 				sle64_to_cpu(ia->index_block_vcn),
 				(unsigned long long)vcn, dir_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
@@ -834,7 +843,6 @@
 				(unsigned long long)vcn, dir_ni->mft_no,
 				le32_to_cpu(ia->index.allocated_size) + 0x18,
 				dir_ni->itype.index.block_size);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	index_end = (u8*)ia + dir_ni->itype.index.block_size;
@@ -844,7 +852,6 @@
 				"Cannot access! This is probably a bug in the "
 				"driver.", (unsigned long long)vcn,
 				dir_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
@@ -852,7 +859,6 @@
 		ntfs_error(sb, "Size of index buffer (VCN 0x%llx) of directory "
 				"inode 0x%lx exceeds maximum size.",
 				(unsigned long long)vcn, dir_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	/* The first index entry. */
@@ -872,7 +878,6 @@
 			ntfs_error(sb, "Index entry out of bounds in "
 					"directory inode 0x%lx.",
 					dir_ni->mft_no);
-			err = -EIO;
 			goto unm_err_out;
 		}
 		/*
@@ -956,7 +961,6 @@
 			ntfs_error(sb, "Index entry with child node found in "
 					"a leaf node in directory inode 0x%lx.",
 					dir_ni->mft_no);
-			err = -EIO;
 			goto unm_err_out;
 		}
 		/* Child node present, descend into it. */
@@ -976,7 +980,6 @@
 		}
 		ntfs_error(sb, "Negative child node vcn in directory inode "
 				"0x%lx.", dir_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	/* No child node, return -ENOENT. */
@@ -986,6 +989,8 @@
 	unlock_page(page);
 	ntfs_unmap_page(page);
 err_out:
+	if (!err)
+		err = -EIO;
 	if (ctx)
 		ntfs_attr_put_search_ctx(ctx);
 	if (m)
@@ -993,7 +998,6 @@
 	return ERR_MREF(err);
 dir_err_out:
 	ntfs_error(sb, "Corrupt directory. Aborting lookup.");
-	err = -EIO;
 	goto err_out;
 }
 
@@ -1272,7 +1276,7 @@
 	ntfs_debug("Reading bitmap with page index 0x%llx, bit ofs 0x%llx",
 			(unsigned long long)bmp_pos >> (3 + PAGE_CACHE_SHIFT),
 			(unsigned long long)bmp_pos &
-			((PAGE_CACHE_SIZE * 8) - 1));
+			(unsigned long long)((PAGE_CACHE_SIZE * 8) - 1));
 	bmp_page = ntfs_map_page(bmp_mapping,
 			bmp_pos >> (3 + PAGE_CACHE_SHIFT));
 	if (IS_ERR(bmp_page)) {
@@ -1334,6 +1338,14 @@
 				"inode 0x%lx or driver bug.", vdir->i_ino);
 		goto err_out;
 	}
+	/* Catch multi sector transfer fixup errors. */
+	if (unlikely(!ntfs_is_indx_record(ia->magic))) {
+		ntfs_error(sb, "Directory index record with vcn 0x%llx is "
+				"corrupt.  Corrupt inode 0x%lx.  Run chkdsk.",
+				(unsigned long long)ia_pos >>
+				ndir->itype.index.vcn_size_bits, vdir->i_ino);
+		goto err_out;
+	}
 	if (unlikely(sle64_to_cpu(ia->index_block_vcn) != (ia_pos &
 			~(s64)(ndir->itype.index.block_size - 1)) >>
 			ndir->itype.index.vcn_size_bits)) {
@@ -1386,8 +1398,8 @@
 	 */
 	for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) {
 		ntfs_debug("In index allocation, offset 0x%llx.",
-				(unsigned long long)ia_start + ((u8*)ie -
-				(u8*)ia));
+				(unsigned long long)ia_start +
+				(unsigned long long)((u8*)ie - (u8*)ia));
 		/* Bounds checks. */
 		if (unlikely((u8*)ie < (u8*)ia || (u8*)ie +
 				sizeof(INDEX_ENTRY_HEADER) > index_end ||
diff -Nru a/fs/ntfs/dir.h b/fs/ntfs/dir.h
--- a/fs/ntfs/dir.h	2004-12-24 13:37:01 -08:00
+++ b/fs/ntfs/dir.h	2004-12-24 13:37:01 -08:00
@@ -24,6 +24,8 @@
 #define _LINUX_NTFS_DIR_H
 
 #include "layout.h"
+#include "inode.h"
+#include "types.h"
 
 /*
  * ntfs_name is used to return the file name to the caller of
diff -Nru a/fs/ntfs/file.c b/fs/ntfs/file.c
--- a/fs/ntfs/file.c	2004-12-24 13:37:18 -08:00
+++ b/fs/ntfs/file.c	2004-12-24 13:37:18 -08:00
@@ -19,6 +19,11 @@
  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/pagemap.h>
+#include <linux/buffer_head.h>
+
+#include "inode.h"
+#include "debug.h"
 #include "ntfs.h"
 
 /**
@@ -140,7 +145,7 @@
 
 struct inode_operations ntfs_file_inode_ops = {
 #ifdef NTFS_RW
-	.truncate	= ntfs_truncate,
+	.truncate	= ntfs_truncate_vfs,
 	.setattr	= ntfs_setattr,
 #endif /* NTFS_RW */
 };
diff -Nru a/fs/ntfs/index.c b/fs/ntfs/index.c
--- a/fs/ntfs/index.c	2004-12-24 13:37:04 -08:00
+++ b/fs/ntfs/index.c	2004-12-24 13:37:04 -08:00
@@ -19,9 +19,11 @@
  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "ntfs.h"
+#include "aops.h"
 #include "collate.h"
+#include "debug.h"
 #include "index.h"
+#include "ntfs.h"
 
 /**
  * ntfs_index_ctx_get - allocate and initialize a new index context
@@ -261,7 +263,6 @@
 		ntfs_error(sb, "No index allocation attribute but index entry "
 				"requires one.  Inode 0x%lx is corrupt or "
 				"driver bug.", idx_ni->mft_no);
-		err = -EIO;
 		goto err_out;
 	}
 	/* Get the starting vcn of the index_block holding the child node. */
@@ -299,7 +300,13 @@
 	if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) {
 		ntfs_error(sb, "Out of bounds check failed.  Corrupt inode "
 				"0x%lx or driver bug.", idx_ni->mft_no);
-		err = -EIO;
+		goto unm_err_out;
+	}
+	/* Catch multi sector transfer fixup errors. */
+	if (unlikely(!ntfs_is_indx_record(ia->magic))) {
+		ntfs_error(sb, "Index record with vcn 0x%llx is corrupt.  "
+				"Corrupt inode 0x%lx.  Run chkdsk.",
+				(long long)vcn, idx_ni->mft_no);
 		goto unm_err_out;
 	}
 	if (sle64_to_cpu(ia->index_block_vcn) != vcn) {
@@ -309,7 +316,6 @@
 				(unsigned long long)
 				sle64_to_cpu(ia->index_block_vcn),
 				(unsigned long long)vcn, idx_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
@@ -321,7 +327,6 @@
 				idx_ni->mft_no,
 				le32_to_cpu(ia->index.allocated_size) + 0x18,
 				idx_ni->itype.index.block_size);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	index_end = (u8*)ia + idx_ni->itype.index.block_size;
@@ -331,7 +336,6 @@
 				"access!  This is probably a bug in the "
 				"driver.", (unsigned long long)vcn,
 				idx_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
@@ -339,7 +343,6 @@
 		ntfs_error(sb, "Size of index buffer (VCN 0x%llx) of inode "
 				"0x%lx exceeds maximum size.",
 				(unsigned long long)vcn, idx_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	/* The first index entry. */
@@ -357,11 +360,10 @@
 				(u8*)ie + le16_to_cpu(ie->length) > index_end) {
 			ntfs_error(sb, "Index entry out of bounds in inode "
 					"0x%lx.", idx_ni->mft_no);
-			err = -EIO;
 			goto unm_err_out;
 		}
 		/*
-		 * The last entry cannot contain a ket.  It can however contain
+		 * The last entry cannot contain a key.  It can however contain
 		 * a pointer to a child node in the B+tree so we just break out.
 		 */
 		if (ie->flags & INDEX_ENTRY_END)
@@ -375,7 +377,6 @@
 				le16_to_cpu(ie->length)) {
 			ntfs_error(sb, "Index entry out of bounds in inode "
 					"0x%lx.", idx_ni->mft_no);
-			err = -EIO;
 			goto unm_err_out;
 		}
 		/* If the keys match perfectly, we setup @ictx and return 0. */
@@ -422,7 +423,6 @@
 	if ((ia->index.flags & NODE_MASK) == LEAF_NODE) {
 		ntfs_error(sb, "Index entry with child node found in a leaf "
 				"node in inode 0x%lx.", idx_ni->mft_no);
-		err = -EIO;
 		goto unm_err_out;
 	}
 	/* Child node present, descend into it. */
@@ -444,11 +444,12 @@
 	}
 	ntfs_error(sb, "Negative child node vcn in inode 0x%lx.",
 			idx_ni->mft_no);
-	err = -EIO;
 unm_err_out:
 	unlock_page(page);
 	ntfs_unmap_page(page);
 err_out:
+	if (!err)
+		err = -EIO;
 	if (actx)
 		ntfs_attr_put_search_ctx(actx);
 	if (m)
@@ -456,61 +457,5 @@
 	return err;
 idx_err_out:
 	ntfs_error(sb, "Corrupt index.  Aborting lookup.");
-	err = -EIO;
 	goto err_out;
 }
-
-#ifdef NTFS_RW
-
-/**
- * __ntfs_index_entry_mark_dirty - mark an index allocation entry dirty
- * @ictx:	ntfs index context describing the index entry
- *
- * NOTE: You want to use fs/ntfs/index.h::ntfs_index_entry_mark_dirty() instead!
- * 
- * Mark the index allocation entry described by the index entry context @ictx
- * dirty.
- *
- * The index entry must be in an index block belonging to the index allocation
- * attribute.  Mark the buffers belonging to the index record as well as the
- * page cache page the index block is in dirty.  This automatically marks the
- * VFS inode of the ntfs index inode to which the index entry belongs dirty,
- * too (I_DIRTY_PAGES) and this in turn ensures the page buffers, and hence the
- * dirty index block, will be written out to disk later.
- */
-void __ntfs_index_entry_mark_dirty(ntfs_index_context *ictx)
-{
-	ntfs_inode *ni;
-	struct page *page;
-	struct buffer_head *bh, *head;
-	unsigned int rec_start, rec_end, bh_size, bh_start, bh_end;
-
-	BUG_ON(ictx->is_in_root);
-	ni = ictx->idx_ni;
-	page = ictx->page;
-	BUG_ON(!page_has_buffers(page));
-	/*
-	 * If the index block is the same size as the page cache page, set all
-	 * the buffers in the page, as well as the page itself, dirty.
-	 */
-	if (ni->itype.index.block_size == PAGE_CACHE_SIZE) {
-		__set_page_dirty_buffers(page);
-		return;
-	}
-	/* Set only the buffers in which the index block is located dirty. */
-	rec_start = (unsigned int)((u8*)ictx->ia - (u8*)page_address(page));
-	rec_end = rec_start + ni->itype.index.block_size;
-	bh_size = ni->vol->sb->s_blocksize;
-	bh_start = 0;
-	bh = head = page_buffers(page);
-	do {
-		bh_end = bh_start + bh_size;
-		if ((bh_start >= rec_start) && (bh_end <= rec_end))
-			set_buffer_dirty(bh);
-		bh_start = bh_end;
-	} while ((bh = bh->b_this_page) != head);
-	/* Finally, set the page itself dirty, too. */
-	__set_page_dirty_nobuffers(page);
-}
-
-#endif /* NTFS_RW */
diff -Nru a/fs/ntfs/index.h b/fs/ntfs/index.h
--- a/fs/ntfs/index.h	2004-12-24 13:37:19 -08:00
+++ b/fs/ntfs/index.h	2004-12-24 13:37:19 -08:00
@@ -30,6 +30,7 @@
 #include "inode.h"
 #include "attrib.h"
 #include "mft.h"
+#include "aops.h"
 
 /**
  * @idx_ni:	index inode containing the @entry described by this context
@@ -115,8 +116,6 @@
 		flush_dcache_page(ictx->page);
 }
 
-extern void __ntfs_index_entry_mark_dirty(ntfs_index_context *ictx);
-
 /**
  * ntfs_index_entry_mark_dirty - mark an index entry dirty
  * @ictx:	ntfs index context describing the index entry
@@ -140,7 +139,8 @@
 	if (ictx->is_in_root)
 		mark_mft_record_dirty(ictx->actx->ntfs_ino);
 	else
-		__ntfs_index_entry_mark_dirty(ictx);
+		mark_ntfs_record_dirty(ictx->page,
+				(u8*)ictx->ia - (u8*)page_address(ictx->page));
 }
 
 #endif /* NTFS_RW */
diff -Nru a/fs/ntfs/inode.c b/fs/ntfs/inode.c
--- a/fs/ntfs/inode.c	2004-12-24 13:37:19 -08:00
+++ b/fs/ntfs/inode.c	2004-12-24 13:37:19 -08:00
@@ -25,11 +25,15 @@
 #include <linux/quotaops.h>
 #include <linux/mount.h>
 
-#include "ntfs.h"
+#include "aops.h"
 #include "dir.h"
+#include "debug.h"
 #include "inode.h"
 #include "attrib.h"
+#include "malloc.h"
+#include "mft.h"
 #include "time.h"
+#include "ntfs.h"
 
 /**
  * ntfs_test_inode - compare two (possibly fake) inodes for equality
@@ -348,7 +352,7 @@
 	return NULL;
 }
 
-void ntfs_destroy_extent_inode(ntfs_inode *ni)
+static void ntfs_destroy_extent_inode(ntfs_inode *ni)
 {
 	ntfs_debug("Entering.");
 	BUG_ON(ni->page);
@@ -369,20 +373,20 @@
  *
  * Return zero on success and -ENOMEM on error.
  */
-static void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni)
+void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni)
 {
 	ntfs_debug("Entering.");
 	ni->initialized_size = ni->allocated_size = 0;
 	ni->seq_no = 0;
 	atomic_set(&ni->count, 1);
 	ni->vol = NTFS_SB(sb);
-	init_runlist(&ni->runlist);
+	ntfs_init_runlist(&ni->runlist);
 	init_MUTEX(&ni->mrec_lock);
 	ni->page = NULL;
 	ni->page_ofs = 0;
 	ni->attr_list_size = 0;
 	ni->attr_list = NULL;
-	init_runlist(&ni->attr_list_rl);
+	ntfs_init_runlist(&ni->attr_list_rl);
 	ni->itype.index.bmp_ino = NULL;
 	ni->itype.index.block_size = 0;
 	ni->itype.index.vcn_size = 0;
@@ -392,17 +396,6 @@
 	init_MUTEX(&ni->extent_lock);
 	ni->nr_extents = 0;
 	ni->ext.base_ntfs_ino = NULL;
-	return;
-}
-
-static inline void ntfs_init_big_inode(struct inode *vi)
-{
-	ntfs_inode *ni = NTFS_I(vi);
-
-	ntfs_debug("Entering.");
-	__ntfs_init_inode(vi->i_sb, ni);
-	ni->mft_no = vi->i_ino;
-	return;
 }
 
 inline ntfs_inode *ntfs_new_extent_inode(struct super_block *sb,
@@ -571,13 +564,11 @@
 	}
 
 	if (!(m->flags & MFT_RECORD_IN_USE)) {
-		ntfs_error(vi->i_sb, "Inode is not in use! You should "
-				"run chkdsk.");
+		ntfs_error(vi->i_sb, "Inode is not in use!");
 		goto unm_err_out;
 	}
 	if (m->base_mft_record) {
-		ntfs_error(vi->i_sb, "Inode is an extent inode! You should "
-				"run chkdsk.");
+		ntfs_error(vi->i_sb, "Inode is an extent inode!");
 		goto unm_err_out;
 	}
 
@@ -601,14 +592,26 @@
 	 * Also if not a directory, it could be something else, rather than
 	 * a regular file. But again, will do for now.
 	 */
+	/* Everyone gets all permissions. */
+	vi->i_mode |= S_IRWXUGO;
+	/* If read-only, noone gets write permissions. */
+	if (IS_RDONLY(vi))
+		vi->i_mode &= ~S_IWUGO;
 	if (m->flags & MFT_RECORD_IS_DIRECTORY) {
 		vi->i_mode |= S_IFDIR;
+		/*
+		 * Apply the directory permissions mask set in the mount
+		 * options.
+		 */
+		vi->i_mode &= ~vol->dmask;
 		/* Things break without this kludge! */
 		if (vi->i_nlink > 1)
 			vi->i_nlink = 1;
-	} else
+	} else {
 		vi->i_mode |= S_IFREG;
-
+		/* Apply the file permissions mask set in the mount options. */
+		vi->i_mode &= ~vol->fmask;
+	}
 	/*
 	 * Find the standard information attribute in the mft record. At this
 	 * stage we haven't setup the attribute list stuff yet, so this could
@@ -662,7 +665,7 @@
 	if (err) {
 		if (unlikely(err != -ENOENT)) {
 			ntfs_error(vi->i_sb, "Failed to lookup attribute list "
-					"attribute. You should run chkdsk.");
+					"attribute.");
 			goto unm_err_out;
 		}
 	} else /* if (!err) */ {
@@ -674,9 +677,7 @@
 				ctx->attr->flags & ATTR_COMPRESSION_MASK ||
 				ctx->attr->flags & ATTR_IS_SPARSE) {
 			ntfs_error(vi->i_sb, "Attribute list attribute is "
-					"compressed/encrypted/sparse. Not "
-					"allowed. Corrupt inode. You should "
-					"run chkdsk.");
+					"compressed/encrypted/sparse.");
 			goto unm_err_out;
 		}
 		/* Now allocate memory for the attribute list. */
@@ -692,25 +693,20 @@
 			NInoSetAttrListNonResident(ni);
 			if (ctx->attr->data.non_resident.lowest_vcn) {
 				ntfs_error(vi->i_sb, "Attribute list has non "
-						"zero lowest_vcn. Inode is "
-						"corrupt. You should run "
-						"chkdsk.");
+						"zero lowest_vcn.");
 				goto unm_err_out;
 			}
 			/*
 			 * Setup the runlist. No need for locking as we have
 			 * exclusive access to the inode at this time.
 			 */
-			ni->attr_list_rl.rl = decompress_mapping_pairs(vol,
+			ni->attr_list_rl.rl = ntfs_mapping_pairs_decompress(vol,
 					ctx->attr, NULL);
 			if (IS_ERR(ni->attr_list_rl.rl)) {
 				err = PTR_ERR(ni->attr_list_rl.rl);
 				ni->attr_list_rl.rl = NULL;
 				ntfs_error(vi->i_sb, "Mapping pairs "
-						"decompression failed with "
-						"error code %i. Corrupt "
-						"attribute list in inode.",
-						-err);
+						"decompression failed.");
 				goto unm_err_out;
 			}
 			/* Now load the attribute list. */
@@ -765,9 +761,18 @@
 			goto unm_err_out;
 		}
 		/* Set up the state. */
-		if (ctx->attr->non_resident) {
-			ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is "
-					"not resident. Not allowed.");
+		if (unlikely(ctx->attr->non_resident)) {
+			ntfs_error(vol->sb, "$INDEX_ROOT attribute is not "
+					"resident.");
+			goto unm_err_out;
+		}
+		/* Ensure the attribute name is placed before the value. */
+		if (unlikely(ctx->attr->name_length &&
+				(le16_to_cpu(ctx->attr->name_offset) >=
+				le16_to_cpu(ctx->attr->data.resident.
+				value_offset)))) {
+			ntfs_error(vol->sb, "$INDEX_ROOT attribute name is "
+					"placed after the attribute value.");
 			goto unm_err_out;
 		}
 		/*
@@ -781,8 +786,7 @@
 		if (ctx->attr->flags & ATTR_IS_ENCRYPTED) {
 			if (ctx->attr->flags & ATTR_COMPRESSION_MASK) {
 				ntfs_error(vi->i_sb, "Found encrypted and "
-						"compressed attribute. Not "
-						"allowed.");
+						"compressed attribute.");
 				goto unm_err_out;
 			}
 			NInoSetEncrypted(ni);
@@ -806,12 +810,12 @@
 		}
 		if (ir->type != AT_FILE_NAME) {
 			ntfs_error(vi->i_sb, "Indexed attribute is not "
-					"$FILE_NAME. Not allowed.");
+					"$FILE_NAME.");
 			goto unm_err_out;
 		}
 		if (ir->collation_rule != COLLATION_FILE_NAME) {
 			ntfs_error(vi->i_sb, "Index collation rule is not "
-					"COLLATION_FILE_NAME. Not allowed.");
+					"COLLATION_FILE_NAME.");
 			goto unm_err_out;
 		}
 		ni->itype.index.collation_rule = ir->collation_rule;
@@ -826,7 +830,7 @@
 		if (ni->itype.index.block_size > PAGE_CACHE_SIZE) {
 			ntfs_error(vi->i_sb, "Index block size (%u) > "
 					"PAGE_CACHE_SIZE (%ld) is not "
-					"supported. Sorry.",
+					"supported.  Sorry.",
 					ni->itype.index.block_size,
 					PAGE_CACHE_SIZE);
 			err = -EOPNOTSUPP;
@@ -835,7 +839,7 @@
 		if (ni->itype.index.block_size < NTFS_BLOCK_SIZE) {
 			ntfs_error(vi->i_sb, "Index block size (%u) < "
 					"NTFS_BLOCK_SIZE (%i) is not "
-					"supported. Sorry.",
+					"supported.  Sorry.",
 					ni->itype.index.block_size,
 					NTFS_BLOCK_SIZE);
 			err = -EOPNOTSUPP;
@@ -878,8 +882,7 @@
 			if (err == -ENOENT)
 				ntfs_error(vi->i_sb, "$INDEX_ALLOCATION "
 						"attribute is not present but "
-						"$INDEX_ROOT indicated it "
-						"is.");
+						"$INDEX_ROOT indicated it is.");
 			else
 				ntfs_error(vi->i_sb, "Failed to lookup "
 						"$INDEX_ALLOCATION "
@@ -891,6 +894,19 @@
 					"is resident.");
 			goto unm_err_out;
 		}
+		/*
+		 * Ensure the attribute name is placed before the mapping pairs
+		 * array.
+		 */
+		if (unlikely(ctx->attr->name_length &&
+				(le16_to_cpu(ctx->attr->name_offset) >=
+				le16_to_cpu(ctx->attr->data.non_resident.
+				mapping_pairs_offset)))) {
+			ntfs_error(vol->sb, "$INDEX_ALLOCATION attribute name "
+					"is placed after the mapping pairs "
+					"array.");
+			goto unm_err_out;
+		}
 		if (ctx->attr->flags & ATTR_IS_ENCRYPTED) {
 			ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute "
 					"is encrypted.");
@@ -909,8 +925,7 @@
 		if (ctx->attr->data.non_resident.lowest_vcn) {
 			ntfs_error(vi->i_sb, "First extent of "
 					"$INDEX_ALLOCATION attribute has non "
-					"zero lowest_vcn. Inode is corrupt. "
-					"You should run chkdsk.");
+					"zero lowest_vcn.");
 			goto unm_err_out;
 		}
 		vi->i_size = sle64_to_cpu(
@@ -951,20 +966,9 @@
 			goto unm_err_out;
 		}
 skip_large_dir_stuff:
-		/* Everyone gets read and scan permissions. */
-		vi->i_mode |= S_IRUGO | S_IXUGO;
-		/* If not read-only, set write permissions. */
-		if (!IS_RDONLY(vi))
-			vi->i_mode |= S_IWUGO;
-		/*
-		 * Apply the directory permissions mask set in the mount
-		 * options.
-		 */
-		vi->i_mode &= ~vol->dmask;
 		/* Setup the operations for this inode. */
 		vi->i_op = &ntfs_dir_inode_ops;
 		vi->i_fop = &ntfs_dir_ops;
-		vi->i_mapping->a_ops = &ntfs_mst_aops;
 	} else {
 		/* It is a file. */
 		ntfs_attr_reinit_search_ctx(ctx);
@@ -1003,8 +1007,7 @@
 				goto no_data_attr_special_case;
 			// FIXME: File is corrupt! Hot-fix with empty data
 			// attribute if recovery option is set.
-			ntfs_error(vi->i_sb, "$DATA attribute is "
-					"missing.");
+			ntfs_error(vi->i_sb, "$DATA attribute is missing.");
 			goto unm_err_out;
 		}
 		/* Setup the state. */
@@ -1034,10 +1037,8 @@
 						compression_unit != 4) {
 					ntfs_error(vi->i_sb, "Found "
 						"nonstandard compression unit "
-						"(%u instead of 4). Cannot "
-						"handle this. This might "
-						"indicate corruption so you "
-						"should run chkdsk.",
+						"(%u instead of 4).  Cannot "
+						"handle this.",
 						ctx->attr->data.non_resident.
 						compression_unit);
 					err = -EOPNOTSUPP;
@@ -1063,8 +1064,7 @@
 			if (ctx->attr->data.non_resident.lowest_vcn) {
 				ntfs_error(vi->i_sb, "First extent of $DATA "
 						"attribute has non zero "
-						"lowest_vcn. Inode is corrupt. "
-						"You should run chkdsk.");
+						"lowest_vcn.");
 				goto unm_err_out;
 			}
 			/* Setup all the sizes. */
@@ -1098,18 +1098,14 @@
 		unmap_mft_record(ni);
 		m = NULL;
 		ctx = NULL;
-		/* Everyone gets all permissions. */
-		vi->i_mode |= S_IRWXUGO;
-		/* If read-only, noone gets write permissions. */
-		if (IS_RDONLY(vi))
-			vi->i_mode &= ~S_IWUGO;
-		/* Apply the file permissions mask set in the mount options. */
-		vi->i_mode &= ~vol->fmask;
 		/* Setup the operations for this inode. */
 		vi->i_op = &ntfs_file_inode_ops;
 		vi->i_fop = &ntfs_file_ops;
-		vi->i_mapping->a_ops = &ntfs_aops;
 	}
+	if (NInoMstProtected(ni))
+		vi->i_mapping->a_ops = &ntfs_mst_aops;
+	else
+		vi->i_mapping->a_ops = &ntfs_aops;
 	/*
 	 * The number of 512-byte blocks used on disk (for stat). This is in so
 	 * far inaccurate as it doesn't account for any named streams or other
@@ -1137,9 +1133,11 @@
 	if (m)
 		unmap_mft_record(ni);
 err_out:
-	ntfs_error(vi->i_sb, "Failed with error code %i. Marking inode 0x%lx "
-			"as bad.", -err, vi->i_ino);
+	ntfs_error(vol->sb, "Failed with error code %i.  Marking corrupt "
+			"inode 0x%lx as bad.  Run chkdsk.", err, vi->i_ino);
 	make_bad_inode(vi);
+	if (err != -EOPNOTSUPP && err != -ENOMEM)
+		NVolSetErrors(vol);
 	return err;
 }
 
@@ -1210,15 +1208,21 @@
 		goto unm_err_out;
 
 	if (!ctx->attr->non_resident) {
+		/* Ensure the attribute name is placed before the value. */
+		if (unlikely(ctx->attr->name_length &&
+				(le16_to_cpu(ctx->attr->name_offset) >=
+				le16_to_cpu(ctx->attr->data.resident.
+				value_offset)))) {
+			ntfs_error(vol->sb, "Attribute name is placed after "
+					"the attribute value.");
+			goto unm_err_out;
+		}
 		if (NInoMstProtected(ni) || ctx->attr->flags) {
 			ntfs_error(vi->i_sb, "Found mst protected attribute "
 					"or attribute with non-zero flags but "
-					"the attribute is resident (mft_no "
-					"0x%lx, type 0x%x, name_len %i). "
-					"Please report you saw this message "
-					"to linux-ntfs-dev@lists."
-					"sourceforge.net",
-					vi->i_ino, ni->type, ni->name_len);
+					"the attribute is resident.  Please "
+					"report you saw this message to "
+					"linux-ntfs-dev@lists.sourceforge.net");
 			goto unm_err_out;
 		}
 		/*
@@ -1229,60 +1233,63 @@
 			le32_to_cpu(ctx->attr->data.resident.value_length);
 	} else {
 		NInoSetNonResident(ni);
+		/*
+		 * Ensure the attribute name is placed before the mapping pairs
+		 * array.
+		 */
+		if (unlikely(ctx->attr->name_length &&
+				(le16_to_cpu(ctx->attr->name_offset) >=
+				le16_to_cpu(ctx->attr->data.non_resident.
+				mapping_pairs_offset)))) {
+			ntfs_error(vol->sb, "Attribute name is placed after "
+					"the mapping pairs array.");
+			goto unm_err_out;
+		}
 		if (ctx->attr->flags & ATTR_COMPRESSION_MASK) {
 			if (NInoMstProtected(ni)) {
 				ntfs_error(vi->i_sb, "Found mst protected "
 						"attribute but the attribute "
-						"is compressed (mft_no 0x%lx, "
-						"type 0x%x, name_len %i). "
-						"Please report you saw this "
-						"message to linux-ntfs-dev@"
-						"lists.sourceforge.net",
-						vi->i_ino, ni->type,
-						ni->name_len);
+						"is compressed.  Please report "
+						"you saw this message to "
+						"linux-ntfs-dev@lists."
+						"sourceforge.net");
 				goto unm_err_out;
 			}
 			NInoSetCompressed(ni);
 			if ((ni->type != AT_DATA) || (ni->type == AT_DATA &&
 					ni->name_len)) {
-				ntfs_error(vi->i_sb, "Found compressed non-"
-						"data or named data attribute "
-						"(mft_no 0x%lx, type 0x%x, "
-						"name_len %i). Please report "
+				ntfs_error(vi->i_sb, "Found compressed "
+						"non-data or named data "
+						"attribute.  Please report "
 						"you saw this message to "
 						"linux-ntfs-dev@lists."
-						"sourceforge.net",
-						vi->i_ino, ni->type,
-						ni->name_len);
+						"sourceforge.net");
 				goto unm_err_out;
 			}
 			if (vol->cluster_size > 4096) {
-				ntfs_error(vi->i_sb, "Found "
-					"compressed attribute but "
-					"compression is disabled due "
-					"to cluster size (%i) > 4kiB.",
-					vol->cluster_size);
+				ntfs_error(vi->i_sb, "Found compressed "
+						"attribute but compression is "
+						"disabled due to cluster size "
+						"(%i) > 4kiB.",
+						vol->cluster_size);
 				goto unm_err_out;
 			}
 			if ((ctx->attr->flags & ATTR_COMPRESSION_MASK)
 					!= ATTR_IS_COMPRESSED) {
 				ntfs_error(vi->i_sb, "Found unknown "
-						"compression method or "
-						"corrupt file.");
+						"compression method.");
 				goto unm_err_out;
 			}
 			ni->itype.compressed.block_clusters = 1U <<
 					ctx->attr->data.non_resident.
 					compression_unit;
-			if (ctx->attr->data.non_resident.compression_unit != 4) {
-				ntfs_error(vi->i_sb, "Found "
-					"nonstandard compression unit "
-					"(%u instead of 4). Cannot "
-					"handle this. This might "
-					"indicate corruption so you "
-					"should run chkdsk.",
-					ctx->attr->data.non_resident.
-					compression_unit);
+			if (ctx->attr->data.non_resident.compression_unit !=
+					4) {
+				ntfs_error(vi->i_sb, "Found nonstandard "
+						"compression unit (%u instead "
+						"of 4).  Cannot handle this.",
+						ctx->attr->data.non_resident.
+						compression_unit);
 				err = -EOPNOTSUPP;
 				goto unm_err_out;
 			}
@@ -1302,13 +1309,10 @@
 			if (NInoMstProtected(ni)) {
 				ntfs_error(vi->i_sb, "Found mst protected "
 						"attribute but the attribute "
-						"is encrypted (mft_no 0x%lx, "
-						"type 0x%x, name_len %i). "
-						"Please report you saw this "
-						"message to linux-ntfs-dev@"
-						"lists.sourceforge.net",
-						vi->i_ino, ni->type,
-						ni->name_len);
+						"is encrypted.  Please report "
+						"you saw this message to "
+						"linux-ntfs-dev@lists."
+						"sourceforge.net");
 				goto unm_err_out;
 			}
 			NInoSetEncrypted(ni);
@@ -1317,21 +1321,17 @@
 			if (NInoMstProtected(ni)) {
 				ntfs_error(vi->i_sb, "Found mst protected "
 						"attribute but the attribute "
-						"is sparse (mft_no 0x%lx, "
-						"type 0x%x, name_len %i). "
-						"Please report you saw this "
-						"message to linux-ntfs-dev@"
-						"lists.sourceforge.net",
-						vi->i_ino, ni->type,
-						ni->name_len);
+						"is sparse.  Please report "
+						"you saw this message to "
+						"linux-ntfs-dev@lists."
+						"sourceforge.net");
 				goto unm_err_out;
 			}
 			NInoSetSparse(ni);
 		}
 		if (ctx->attr->data.non_resident.lowest_vcn) {
 			ntfs_error(vi->i_sb, "First extent of attribute has "
-					"non-zero lowest_vcn. Inode is "
-					"corrupt. You should run chkdsk.");
+					"non-zero lowest_vcn.");
 			goto unm_err_out;
 		}
 		/* Setup all the sizes. */
@@ -1382,10 +1382,15 @@
 		ntfs_attr_put_search_ctx(ctx);
 	unmap_mft_record(base_ni);
 err_out:
-	ntfs_error(vi->i_sb, "Failed with error code %i while reading "
-			"attribute inode (mft_no 0x%lx, type 0x%x, name_len "
-			"%i.", -err, vi->i_ino, ni->type, ni->name_len);
+	ntfs_error(vol->sb, "Failed with error code %i while reading attribute "
+			"inode (mft_no 0x%lx, type 0x%x, name_len %i).  "
+			"Marking corrupt inode and base inode 0x%lx as bad.  "
+			"Run chkdsk.", err, vi->i_ino, ni->type, ni->name_len,
+			base_vi->i_ino);
 	make_bad_inode(vi);
+	make_bad_inode(base_vi);
+	if (err != -ENOMEM)
+		NVolSetErrors(vol);
 	return err;
 }
 
@@ -1470,16 +1475,24 @@
 		goto unm_err_out;
 	}
 	/* Set up the state. */
-	if (ctx->attr->non_resident) {
-		ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is not resident.  "
-				"Not allowed.");
+	if (unlikely(ctx->attr->non_resident)) {
+		ntfs_error(vol->sb, "$INDEX_ROOT attribute is not resident.");
+		goto unm_err_out;
+	}
+	/* Ensure the attribute name is placed before the value. */
+	if (unlikely(ctx->attr->name_length &&
+			(le16_to_cpu(ctx->attr->name_offset) >=
+			le16_to_cpu(ctx->attr->data.resident.
+			value_offset)))) {
+		ntfs_error(vol->sb, "$INDEX_ROOT attribute name is placed "
+				"after the attribute value.");
 		goto unm_err_out;
 	}
 	/* Compressed/encrypted/sparse index root is not allowed. */
 	if (ctx->attr->flags & (ATTR_COMPRESSION_MASK | ATTR_IS_ENCRYPTED |
 			ATTR_IS_SPARSE)) {
 		ntfs_error(vi->i_sb, "Found compressed/encrypted/sparse index "
-				"root attribute.  Not allowed.");
+				"root attribute.");
 		goto unm_err_out;
 	}
 	ir = (INDEX_ROOT*)((u8*)ctx->attr +
@@ -1495,8 +1508,8 @@
 		goto unm_err_out;
 	}
 	if (ir->type) {
-		ntfs_error(vi->i_sb, "Index type is not 0 (type is 0x%x).  "
-				"Not allowed.", le32_to_cpu(ir->type));
+		ntfs_error(vi->i_sb, "Index type is not 0 (type is 0x%x).",
+				le32_to_cpu(ir->type));
 		goto unm_err_out;
 	}
 	ni->itype.index.collation_rule = ir->collation_rule;
@@ -1562,6 +1575,16 @@
 				"resident.");
 		goto unm_err_out;
 	}
+	/*
+	 * Ensure the attribute name is placed before the mapping pairs array.
+	 */
+	if (unlikely(ctx->attr->name_length && (le16_to_cpu(
+			ctx->attr->name_offset) >= le16_to_cpu(
+			ctx->attr->data.non_resident.mapping_pairs_offset)))) {
+		ntfs_error(vol->sb, "$INDEX_ALLOCATION attribute name is "
+				"placed after the mapping pairs array.");
+		goto unm_err_out;
+	}
 	if (ctx->attr->flags & ATTR_IS_ENCRYPTED) {
 		ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute is "
 				"encrypted.");
@@ -1578,8 +1601,7 @@
 	}
 	if (ctx->attr->data.non_resident.lowest_vcn) {
 		ntfs_error(vi->i_sb, "First extent of $INDEX_ALLOCATION "
-				"attribute has non zero lowest_vcn.  Inode is "
-				"corrupt. You should run chkdsk.");
+				"attribute has non zero lowest_vcn.");
 		goto unm_err_out;
 	}
 	vi->i_size = sle64_to_cpu(ctx->attr->data.non_resident.data_size);
@@ -1605,16 +1627,16 @@
 	bni = NTFS_I(bvi);
 	if (NInoCompressed(bni) || NInoEncrypted(bni) ||
 			NInoSparse(bni)) {
-		ntfs_error(vi->i_sb, "$BITMAP attribute is compressed "
-				"and/or encrypted and/or sparse.");
+		ntfs_error(vi->i_sb, "$BITMAP attribute is compressed and/or "
+				"encrypted and/or sparse.");
 		goto iput_unm_err_out;
 	}
 	/* Consistency check bitmap size vs. index allocation size. */
 	if ((bvi->i_size << 3) < (vi->i_size >>
 			ni->itype.index.block_size_bits)) {
-		ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) "
-				"for index allocation (0x%llx).",
-				bvi->i_size << 3, vi->i_size);
+		ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) for "
+				"index allocation (0x%llx).", bvi->i_size << 3,
+				vi->i_size);
 		goto iput_unm_err_out;
 	}
 	ni->itype.index.bmp_ino = bvi;
@@ -1647,9 +1669,11 @@
 		unmap_mft_record(base_ni);
 err_out:
 	ntfs_error(vi->i_sb, "Failed with error code %i while reading index "
-			"inode (mft_no 0x%lx, name_len %i.", -err, vi->i_ino,
+			"inode (mft_no 0x%lx, name_len %i.", err, vi->i_ino,
 			ni->name_len);
 	make_bad_inode(vi);
+	if (err != -EOPNOTSUPP && err != -ENOMEM)
+		NVolSetErrors(vol);
 	return err;
 }
 
@@ -1672,8 +1696,8 @@
  *
  * We solve these problems by starting with the $DATA attribute before anything
  * else and iterating using ntfs_attr_lookup($DATA) over all extents.  As each
- * extent is found, we decompress_mapping_pairs() including the implied
- * ntfs_merge_runlists().  Each step of the iteration necessarily provides
+ * extent is found, we ntfs_mapping_pairs_decompress() including the implied
+ * ntfs_runlists_merge().  Each step of the iteration necessarily provides
  * sufficient information for the next step to complete.
  *
  * This should work but there are two possible pit falls (see inline comments
@@ -1762,7 +1786,7 @@
 	vi->i_generation = ni->seq_no = le16_to_cpu(m->sequence_number);
 
 	/* Provides readpage() and sync_page() for map_mft_record(). */
-	vi->i_mapping->a_ops = &ntfs_mft_aops;
+	vi->i_mapping->a_ops = &ntfs_mst_aops;
 
 	ctx = ntfs_attr_get_search_ctx(ni, m);
 	if (!ctx) {
@@ -1810,7 +1834,7 @@
 				goto put_err_out;
 			}
 			/* Setup the runlist. */
-			ni->attr_list_rl.rl = decompress_mapping_pairs(vol,
+			ni->attr_list_rl.rl = ntfs_mapping_pairs_decompress(vol,
 					ctx->attr, NULL);
 			if (IS_ERR(ni->attr_list_rl.rl)) {
 				err = PTR_ERR(ni->attr_list_rl.rl);
@@ -1942,11 +1966,11 @@
 		 * as we have exclusive access to the inode at this time and we
 		 * are a mount in progress task, too.
 		 */
-		nrl = decompress_mapping_pairs(vol, attr, ni->runlist.rl);
+		nrl = ntfs_mapping_pairs_decompress(vol, attr, ni->runlist.rl);
 		if (IS_ERR(nrl)) {
-			ntfs_error(sb, "decompress_mapping_pairs() failed with "
-					"error code %ld. $MFT is corrupt.",
-					PTR_ERR(nrl));
+			ntfs_error(sb, "ntfs_mapping_pairs_decompress() "
+					"failed with error code %ld.  $MFT is "
+					"corrupt.", PTR_ERR(nrl));
 			goto put_err_out;
 		}
 		ni->runlist.rl = nrl;
@@ -2024,8 +2048,6 @@
 			/* No VFS initiated operations allowed for $MFT. */
 			vi->i_op = &ntfs_empty_inode_ops;
 			vi->i_fop = &ntfs_empty_file_ops;
-			/* Put back our special address space operations. */
-			vi->i_mapping->a_ops = &ntfs_mft_aops;
 		}
 
 		/* Get the lowest vcn for the next extent. */
@@ -2091,40 +2113,27 @@
  * dropped, we need to put the attribute inode for the directory index bitmap,
  * if it is present, otherwise the directory inode would remain pinned for
  * ever.
- *
- * If the inode @vi is an index inode with only one reference which is being
- * dropped, we need to put the attribute inode for the index bitmap, if it is
- * present, otherwise the index inode would disappear and the attribute inode
- * for the index bitmap would no longer be referenced from anywhere and thus it
- * would remain pinned for ever.
  */
 void ntfs_put_inode(struct inode *vi)
 {
-	ntfs_inode *ni;
-
-	if (S_ISDIR(vi->i_mode)) {
-		if (atomic_read(&vi->i_count) == 2) {
-			ni = NTFS_I(vi);
-			if (NInoIndexAllocPresent(ni) &&
-					ni->itype.index.bmp_ino) {
-				iput(ni->itype.index.bmp_ino);
-				ni->itype.index.bmp_ino = NULL;
+	if (S_ISDIR(vi->i_mode) && atomic_read(&vi->i_count) == 2) {
+		ntfs_inode *ni = NTFS_I(vi);
+		if (NInoIndexAllocPresent(ni)) {
+			struct inode *bvi = NULL;
+			down(&vi->i_sem);
+			if (atomic_read(&vi->i_count) == 2) {
+				bvi = ni->itype.index.bmp_ino;
+				if (bvi)
+					ni->itype.index.bmp_ino = NULL;
 			}
+			up(&vi->i_sem);
+			if (bvi)
+				iput(bvi);
 		}
-		return;
-	}
-	if (atomic_read(&vi->i_count) != 1)
-		return;
-	ni = NTFS_I(vi);
-	if (NInoAttr(ni) && (ni->type == AT_INDEX_ALLOCATION) &&
-			NInoIndexAllocPresent(ni) && ni->itype.index.bmp_ino) {
-		iput(ni->itype.index.bmp_ino);
-		ni->itype.index.bmp_ino = NULL;
 	}
-	return;
 }
 
-void __ntfs_clear_inode(ntfs_inode *ni)
+static void __ntfs_clear_inode(ntfs_inode *ni)
 {
 	/* Free all alocated memory. */
 	down_write(&ni->runlist.lock);
@@ -2189,6 +2198,18 @@
 {
 	ntfs_inode *ni = NTFS_I(vi);
 
+	/*
+	 * If the inode @vi is an index inode we need to put the attribute
+	 * inode for the index bitmap, if it is present, otherwise the index
+	 * inode would disappear and the attribute inode for the index bitmap
+	 * would no longer be referenced from anywhere and thus it would remain
+	 * pinned for ever.
+	 */
+	if (NInoAttr(ni) && (ni->type == AT_INDEX_ALLOCATION) &&
+			NInoIndexAllocPresent(ni) && ni->itype.index.bmp_ino) {
+		iput(ni->itype.index.bmp_ino);
+		ni->itype.index.bmp_ino = NULL;
+	}
 #ifdef NTFS_RW
 	if (NInoDirty(ni)) {
 		BOOL was_bad = (is_bad_inode(vi));
@@ -2268,7 +2289,7 @@
  * ntfs_truncate - called when the i_size of an ntfs inode is changed
  * @vi:		inode for which the i_size was changed
  *
- * We don't support i_size changes yet.
+ * We do not support i_size changes yet.
  *
  * The kernel guarantees that @vi is a regular file (S_ISREG() is true) and
  * that the change is allowed.
@@ -2276,66 +2297,93 @@
  * This implies for us that @vi is a file inode rather than a directory, index,
  * or attribute inode as well as that @vi is a base inode.
  *
+ * Returns 0 on success or -errno on error.
+ *
  * Called with ->i_sem held.  In all but one case ->i_alloc_sem is held for
  * writing.  The only case where ->i_alloc_sem is not held is
  * mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called
  * with the current i_size as the offset which means that it is a noop as far
  * as ntfs_truncate() is concerned.
  */
-void ntfs_truncate(struct inode *vi)
+int ntfs_truncate(struct inode *vi)
 {
 	ntfs_inode *ni = NTFS_I(vi);
+	ntfs_volume *vol = ni->vol;
 	ntfs_attr_search_ctx *ctx;
 	MFT_RECORD *m;
+	const char *te = "  Leaving file length out of sync with i_size.";
 	int err;
 
+	ntfs_debug("Entering for inode 0x%lx.", vi->i_ino);
+	BUG_ON(NInoAttr(ni));
+	BUG_ON(ni->nr_extents < 0);
 	m = map_mft_record(ni);
 	if (IS_ERR(m)) {
+		err = PTR_ERR(m);
 		ntfs_error(vi->i_sb, "Failed to map mft record for inode 0x%lx "
-				"(error code %ld).", vi->i_ino, PTR_ERR(m));
-		if (PTR_ERR(m) != ENOMEM)
-			make_bad_inode(vi);
-		return;
+				"(error code %d).%s", vi->i_ino, err, te);
+		ctx = NULL;
+		m = NULL;
+		goto err_out;
 	}
 	ctx = ntfs_attr_get_search_ctx(ni, m);
 	if (unlikely(!ctx)) {
-		ntfs_error(vi->i_sb, "Failed to allocate a search context: "
-				"Not enough memory");
-		// FIXME: We can't report an error code upstream.  So what do
-		// we do?!?  make_bad_inode() seems a bit harsh...
-		unmap_mft_record(ni);
-		return;
+		ntfs_error(vi->i_sb, "Failed to allocate a search context for "
+				"inode 0x%lx (not enough memory).%s",
+				vi->i_ino, te);
+		err = -ENOMEM;
+		goto err_out;
 	}
 	err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
 			CASE_SENSITIVE, 0, NULL, 0, ctx);
 	if (unlikely(err)) {
-		if (err == -ENOENT) {
+		if (err == -ENOENT)
 			ntfs_error(vi->i_sb, "Open attribute is missing from "
 					"mft record.  Inode 0x%lx is corrupt.  "
 					"Run chkdsk.", vi->i_ino);
-			make_bad_inode(vi);
-		} else {
+		else
 			ntfs_error(vi->i_sb, "Failed to lookup attribute in "
 					"inode 0x%lx (error code %d).",
 					vi->i_ino, err);
-			// FIXME: We can't report an error code upstream.  So
-			// what do we do?!?  make_bad_inode() seems a bit
-			// harsh...
-		}
-		goto out;
+		goto err_out;
 	}
 	/* If the size has not changed there is nothing to do. */
 	if (ntfs_attr_size(ctx->attr) == i_size_read(vi))
-		goto out;
+		goto done;
 	// TODO: Implement the truncate...
 	ntfs_error(vi->i_sb, "Inode size has changed but this is not "
 			"implemented yet.  Resetting inode size to old value. "
 			" This is most likely a bug in the ntfs driver!");
 	i_size_write(vi, ntfs_attr_size(ctx->attr)); 
-out:
+done:
 	ntfs_attr_put_search_ctx(ctx);
 	unmap_mft_record(ni);
-	return;
+	NInoClearTruncateFailed(ni);
+	ntfs_debug("Done.");
+	return 0;
+err_out:
+	if (err != -ENOMEM) {
+		NVolSetErrors(vol);
+		make_bad_inode(vi);
+	}
+	if (ctx)
+		ntfs_attr_put_search_ctx(ctx);
+	if (m)
+		unmap_mft_record(ni);
+	NInoSetTruncateFailed(ni);
+	return err;
+}
+
+/**
+ * ntfs_truncate_vfs - wrapper for ntfs_truncate() that has no return value
+ * @vi:		inode for which the i_size was changed
+ *
+ * Wrapper for ntfs_truncate() that has no return value.
+ *
+ * See ntfs_truncate() description above for details.
+ */
+void ntfs_truncate_vfs(struct inode *vi) {
+	ntfs_truncate(vi);
 }
 
 /**
@@ -2500,9 +2548,16 @@
 	 * dirty, since we are going to write this mft record below in any case
 	 * and the base mft record may actually not have been modified so it
 	 * might not need to be written out.
+	 * NOTE: It is not a problem when the inode for $MFT itself is being
+	 * written out as mark_ntfs_record_dirty() will only set I_DIRTY_PAGES
+	 * on the $MFT inode and hence ntfs_write_inode() will not be
+	 * re-invoked because of it which in turn is ok since the dirtied mft
+	 * record will be cleaned and written out to disk below, i.e. before
+	 * this function returns.
 	 */
 	if (modified && !NInoTestSetDirty(ctx->ntfs_ino))
-		__set_page_dirty_nobuffers(ctx->ntfs_ino->page);
+		mark_ntfs_record_dirty(ctx->ntfs_ino->page,
+				ctx->ntfs_ino->page_ofs);
 	ntfs_attr_put_search_ctx(ctx);
 	/* Now the access times are updated, write the base mft record. */
 	if (NInoDirty(ni))
@@ -2553,6 +2608,7 @@
 		ntfs_error(vi->i_sb, "Failed (error code %i):  Marking inode "
 				"as bad.  You should run chkdsk.", -err);
 		make_bad_inode(vi);
+		NVolSetErrors(ni->vol);
 	}
 	return err;
 }
diff -Nru a/fs/ntfs/inode.h b/fs/ntfs/inode.h
--- a/fs/ntfs/inode.h	2004-12-24 13:37:18 -08:00
+++ b/fs/ntfs/inode.h	2004-12-24 13:37:18 -08:00
@@ -24,10 +24,18 @@
 #ifndef _LINUX_NTFS_INODE_H
 #define _LINUX_NTFS_INODE_H
 
+#include <linux/mm.h>
+#include <linux/fs.h>
 #include <linux/seq_file.h>
+#include <linux/list.h>
+#include <asm/atomic.h>
+#include <asm/semaphore.h>
 
 #include "layout.h"
 #include "volume.h"
+#include "types.h"
+#include "runlist.h"
+#include "debug.h"
 
 typedef struct _ntfs_inode ntfs_inode;
 
@@ -157,6 +165,7 @@
 	NI_Sparse,		/* 1: Unnamed data attr is sparse (f).
 				   1: Create sparse files by default (d).
 				   1: Attribute is sparse (a). */
+	NI_TruncateFailed,	/* 1: Last ntfs_truncate() call failed. */
 } ntfs_inode_state_bits;
 
 /*
@@ -208,6 +217,7 @@
 NINO_FNS(Compressed)
 NINO_FNS(Encrypted)
 NINO_FNS(Sparse)
+NINO_FNS(TruncateFailed)
 
 /*
  * The full structure containing a ntfs_inode and a vfs struct inode. Used for
@@ -269,6 +279,17 @@
 extern void ntfs_destroy_big_inode(struct inode *inode);
 extern void ntfs_clear_big_inode(struct inode *vi);
 
+extern void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni);
+
+static inline void ntfs_init_big_inode(struct inode *vi)
+{
+	ntfs_inode *ni = NTFS_I(vi);
+
+	ntfs_debug("Entering.");
+	__ntfs_init_inode(vi->i_sb, ni);
+	ni->mft_no = vi->i_ino;
+}
+
 extern ntfs_inode *ntfs_new_extent_inode(struct super_block *sb,
 		unsigned long mft_no);
 extern void ntfs_clear_extent_inode(ntfs_inode *ni);
@@ -281,7 +302,8 @@
 
 #ifdef NTFS_RW
 
-extern void ntfs_truncate(struct inode *vi);
+extern int ntfs_truncate(struct inode *vi);
+extern void ntfs_truncate_vfs(struct inode *vi);
 
 extern int ntfs_setattr(struct dentry *dentry, struct iattr *attr);
 
diff -Nru a/fs/ntfs/layout.h b/fs/ntfs/layout.h
--- a/fs/ntfs/layout.h	2004-12-24 13:36:55 -08:00
+++ b/fs/ntfs/layout.h	2004-12-24 13:36:55 -08:00
@@ -260,7 +260,7 @@
 enum {
 	MFT_RECORD_IN_USE	= const_cpu_to_le16(0x0001),
 	MFT_RECORD_IS_DIRECTORY = const_cpu_to_le16(0x0002),
-};
+} __attribute__ ((__packed__));
 
 typedef le16 MFT_RECORD_FLAGS;
 
@@ -316,6 +316,10 @@
 typedef u64 MFT_REF;
 typedef le64 leMFT_REF;
 
+#define MK_MREF(m, s)	((MFT_REF)(((MFT_REF)(s) << 48) |		\
+					((MFT_REF)(m) & MFT_REF_MASK_CPU)))
+#define MK_LE_MREF(m, s) cpu_to_le64(MK_MREF(m, s))
+
 #define MREF(x)		((unsigned long)((x) & MFT_REF_MASK_CPU))
 #define MSEQNO(x)	((u16)(((x) >> 48) & 0xffff))
 #define MREF_LE(x)	((unsigned long)(le64_to_cpu(x) & MFT_REF_MASK_CPU))
@@ -385,22 +389,87 @@
 				   NOTE: Every time the mft record is reused
 				   this number is set to zero.  NOTE: The first
 				   instance number is always 0. */
-/* sizeof() = 42 bytes */
-/* NTFS 3.1+ (Windows XP and above) introduce the following additions. */
-/* 42*/ //le16 reserved;	/* Reserved/alignment. */
-/* 44*/ //le32 mft_record_number;/* Number of this mft record. */
+/* The below fields are specific to NTFS 3.1+ (Windows XP and above): */
+/* 42*/ le16 reserved;		/* Reserved/alignment. */
+/* 44*/ le32 mft_record_number;	/* Number of this mft record. */
 /* sizeof() = 48 bytes */
 /*
  * When (re)using the mft record, we place the update sequence array at this
- * offset, i.e. before we start with the attributes. This also makes sense,
+ * offset, i.e. before we start with the attributes.  This also makes sense,
  * otherwise we could run into problems with the update sequence array
  * containing in itself the last two bytes of a sector which would mean that
- * multi sector transfer protection wouldn't work. As you can't protect data
+ * multi sector transfer protection wouldn't work.  As you can't protect data
  * by overwriting it since you then can't get it back...
  * When reading we obviously use the data from the ntfs record header.
  */
 } __attribute__ ((__packed__)) MFT_RECORD;
 
+/* This is the version without the NTFS 3.1+ specific fields. */
+typedef struct {
+/*Ofs*/
+/*  0	NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
+	NTFS_RECORD_TYPE magic;	/* Usually the magic is "FILE". */
+	le16 usa_ofs;		/* See NTFS_RECORD definition above. */
+	le16 usa_count;		/* See NTFS_RECORD definition above. */
+
+/*  8*/	le64 lsn;		/* $LogFile sequence number for this record.
+				   Changed every time the record is modified. */
+/* 16*/	le16 sequence_number;	/* Number of times this mft record has been
+				   reused. (See description for MFT_REF
+				   above.) NOTE: The increment (skipping zero)
+				   is done when the file is deleted. NOTE: If
+				   this is zero it is left zero. */
+/* 18*/	le16 link_count;	/* Number of hard links, i.e. the number of
+				   directory entries referencing this record.
+				   NOTE: Only used in mft base records.
+				   NOTE: When deleting a directory entry we
+				   check the link_count and if it is 1 we
+				   delete the file. Otherwise we delete the
+				   FILE_NAME_ATTR being referenced by the
+				   directory entry from the mft record and
+				   decrement the link_count.
+				   FIXME: Careful with Win32 + DOS names! */
+/* 20*/	le16 attrs_offset;	/* Byte offset to the first attribute in this
+				   mft record from the start of the mft record.
+				   NOTE: Must be aligned to 8-byte boundary. */
+/* 22*/	MFT_RECORD_FLAGS flags;	/* Bit array of MFT_RECORD_FLAGS. When a file
+				   is deleted, the MFT_RECORD_IN_USE flag is
+				   set to zero. */
+/* 24*/	le32 bytes_in_use;	/* Number of bytes used in this mft record.
+				   NOTE: Must be aligned to 8-byte boundary. */
+/* 28*/	le32 bytes_allocated;	/* Number of bytes allocated for this mft
+				   record. This should be equal to the mft
+				   record size. */
+/* 32*/	leMFT_REF base_mft_record;/* This is zero for base mft records.
+				   When it is not zero it is a mft reference
+				   pointing to the base mft record to which
+				   this record belongs (this is then used to
+				   locate the attribute list attribute present
+				   in the base record which describes this
+				   extension record and hence might need
+				   modification when the extension record
+				   itself is modified, also locating the
+				   attribute list also means finding the other
+				   potential extents, belonging to the non-base
+				   mft record). */
+/* 40*/	le16 next_attr_instance;/* The instance number that will be assigned to
+				   the next attribute added to this mft record.
+				   NOTE: Incremented each time after it is used.
+				   NOTE: Every time the mft record is reused
+				   this number is set to zero.  NOTE: The first
+				   instance number is always 0. */
+/* sizeof() = 42 bytes */
+/*
+ * When (re)using the mft record, we place the update sequence array at this
+ * offset, i.e. before we start with the attributes.  This also makes sense,
+ * otherwise we could run into problems with the update sequence array
+ * containing in itself the last two bytes of a sector which would mean that
+ * multi sector transfer protection wouldn't work.  As you can't protect data
+ * by overwriting it since you then can't get it back...
+ * When reading we obviously use the data from the ntfs record header.
+ */
+} __attribute__ ((__packed__)) MFT_RECORD_OLD;
+
 /*
  * System defined attributes (32-bit).  Each attribute type has a corresponding
  * attribute name (Unicode string of maximum 64 character length) as described
@@ -520,8 +589,8 @@
 					   FIXME: What does it mean? (AIA) */
 /* 88*/ COLLATION_RULE collation_rule;	/* Default collation rule. */
 /* 8c*/	ATTR_DEF_FLAGS flags;		/* Flags describing the attribute. */
-/* 90*/	le64 min_size;			/* Optional minimum attribute size. */
-/* 98*/	le64 max_size;			/* Maximum size of attribute. */
+/* 90*/	sle64 min_size;			/* Optional minimum attribute size. */
+/* 98*/	sle64 max_size;			/* Maximum size of attribute. */
 /* sizeof() = 0xa0 or 160 bytes */
 } __attribute__ ((__packed__)) ATTR_DEF;
 
diff -Nru a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c
--- a/fs/ntfs/lcnalloc.c	2004-12-24 13:37:43 -08:00
+++ b/fs/ntfs/lcnalloc.c	2004-12-24 13:37:43 -08:00
@@ -30,6 +30,7 @@
 #include "volume.h"
 #include "attrib.h"
 #include "malloc.h"
+#include "aops.h"
 #include "ntfs.h"
 
 /**
@@ -46,7 +47,7 @@
  * Locking: - The volume lcn bitmap must be locked for writing on entry and is
  *	      left locked on return.
  */
-static int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol,
+int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol,
 		const runlist_element *rl)
 {
 	struct inode *lcnbmp_vi = vol->lcnbmp_ino;
@@ -855,7 +856,7 @@
 		err = PTR_ERR(rl);
 		goto err_out;
 	}
-	if (unlikely(rl->lcn < (LCN)LCN_HOLE)) {
+	if (unlikely(rl->lcn < LCN_HOLE)) {
 		if (!is_rollback)
 			ntfs_error(vol->sb, "First runlist element has "
 					"invalid lcn, aborting.");
@@ -895,15 +896,15 @@
 	 * free them.
 	 */
 	for (; rl->length && count != 0; ++rl) {
-		if (unlikely(rl->lcn < (LCN)LCN_HOLE)) {
+		if (unlikely(rl->lcn < LCN_HOLE)) {
 			VCN vcn;
 
 			/*
 			 * Attempt to map runlist, dropping runlist lock for
 			 * the duration.
 			 */
-			up_read(&ni->runlist.lock);
 			vcn = rl->vcn;
+			up_read(&ni->runlist.lock);
 			err = ntfs_map_runlist(ni, vcn);
 			if (err) {
 				if (!is_rollback)
@@ -926,7 +927,7 @@
 							"element.");
 				goto err_out;
 			}
-			if (unlikely(rl->lcn < (LCN)LCN_HOLE)) {
+			if (unlikely(rl->lcn < LCN_HOLE)) {
 				if (!is_rollback)
 					ntfs_error(vol->sb, "Runlist element "
 							"has invalid lcn "
diff -Nru a/fs/ntfs/lcnalloc.h b/fs/ntfs/lcnalloc.h
--- a/fs/ntfs/lcnalloc.h	2004-12-24 13:37:18 -08:00
+++ b/fs/ntfs/lcnalloc.h	2004-12-24 13:37:18 -08:00
@@ -28,6 +28,7 @@
 #include <linux/fs.h>
 
 #include "types.h"
+#include "runlist.h"
 #include "volume.h"
 
 typedef enum {
@@ -76,6 +77,34 @@
 		s64 count)
 {
 	return __ntfs_cluster_free(vi, start_vcn, count, FALSE);
+}
+
+extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol,
+		const runlist_element *rl);
+
+/**
+ * ntfs_cluster_free_from_rl - free clusters from runlist
+ * @vol:	mounted ntfs volume on which to free the clusters
+ * @rl:		runlist describing the clusters to free
+ *
+ * Free all the clusters described by the runlist @rl on the volume @vol.  In
+ * the case of an error being returned, at least some of the clusters were not
+ * freed.
+ *
+ * Return 0 on success and -errno on error.
+ *
+ * Locking: This function takes the volume lcn bitmap lock for writing and
+ *	    modifies the bitmap contents.
+ */
+static inline int ntfs_cluster_free_from_rl(ntfs_volume *vol,
+		const runlist_element *rl)
+{
+	int ret;
+
+	down_write(&vol->lcnbmp_lock);
+	ret = ntfs_cluster_free_from_rl_nolock(vol, rl);
+	up_write(&vol->lcnbmp_lock);
+	return ret;
 }
 
 #endif /* NTFS_RW */
diff -Nru a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
--- a/fs/ntfs/logfile.c	2004-12-24 13:36:48 -08:00
+++ b/fs/ntfs/logfile.c	2004-12-24 13:36:48 -08:00
@@ -27,10 +27,13 @@
 #include <linux/buffer_head.h>
 #include <linux/bitops.h>
 
+#include "attrib.h"
+#include "aops.h"
+#include "debug.h"
 #include "logfile.h"
+#include "malloc.h"
 #include "volume.h"
 #include "ntfs.h"
-#include "debug.h"
 
 /**
  * ntfs_check_restart_page_header - check the page header for consistency
@@ -681,60 +684,20 @@
 BOOL ntfs_empty_logfile(struct inode *log_vi)
 {
 	ntfs_volume *vol = NTFS_SB(log_vi->i_sb);
-	struct address_space *mapping;
-	pgoff_t idx, end;
 
 	ntfs_debug("Entering.");
-	if (NVolLogFileEmpty(vol))
-		goto done;
-	mapping = log_vi->i_mapping;
-	end = (log_vi->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
-	for (idx = 0; idx < end; ++idx) {
-		struct page *page;
-		u8 *kaddr;
-
-		/* Find or create the current page.  (The page is locked.) */
-		page = grab_cache_page(mapping, idx);
-		if (unlikely(!page)) {
-			ntfs_error(vol->sb, "Insufficient memory to grab "
-					"$LogFile page (index %lu).", idx);
+	if (!NVolLogFileEmpty(vol)) {
+		int err;
+		
+		err = ntfs_attr_set(NTFS_I(log_vi), 0, log_vi->i_size, 0xff);
+		if (unlikely(err)) {
+			ntfs_error(vol->sb, "Failed to fill $LogFile with "
+					"0xff bytes (error code %i).", err);
 			return FALSE;
 		}
-		/*
-		 * Set all bytes in the page to 0xff.  It doesn't matter if we
-		 * go beyond i_size, because ntfs_writepage() will take care of
-		 * that for us.
-		 */
-		kaddr = (u8*)kmap_atomic(page, KM_USER0);
-		memset(kaddr, 0xff, PAGE_CACHE_SIZE);
-		flush_dcache_page(page);
-		kunmap_atomic(kaddr, KM_USER0);
-		/*
-		 * If the page has buffers, mark them uptodate since buffer
-		 * state and not page state is definitive in 2.6 kernels.
-		 */
-		if (page_has_buffers(page)) {
-			struct buffer_head *bh, *head;
-
-			bh = head = page_buffers(page);
-			do {
-				set_buffer_uptodate(bh);
-			} while ((bh = bh->b_this_page) != head);
-		}
-		/* Now that buffers are uptodate, set the page uptodate, too. */
-		SetPageUptodate(page);
-		/*
-		 * Set the page and all its buffers dirty and mark the inode
-		 * dirty, too. The VM will write the page later on.
-		 */
-		set_page_dirty(page);
-		/* Finally unlock and release the page. */
-		unlock_page(page);
-		page_cache_release(page);
-	}
-	/* We set the flag so we do not clear the log file again on remount. */
-	NVolSetLogFileEmpty(vol);
-done:
+		/* Set the flag so we do not have to do it again on remount. */
+		NVolSetLogFileEmpty(vol);
+	}
 	ntfs_debug("Done.");
 	return TRUE;
 }
diff -Nru a/fs/ntfs/malloc.h b/fs/ntfs/malloc.h
--- a/fs/ntfs/malloc.h	2004-12-24 13:36:18 -08:00
+++ b/fs/ntfs/malloc.h	2004-12-24 13:36:18 -08:00
@@ -24,6 +24,7 @@
 
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
+#include <linux/highmem.h>
 
 /**
  * ntfs_malloc_nofs - allocate memory in multiples of pages
diff -Nru a/fs/ntfs/mft.c b/fs/ntfs/mft.c
--- a/fs/ntfs/mft.c	2004-12-24 13:37:01 -08:00
+++ b/fs/ntfs/mft.c	2004-12-24 13:37:01 -08:00
@@ -20,115 +20,20 @@
  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/buffer_head.h>
 #include <linux/swap.h>
 
+#include "attrib.h"
+#include "aops.h"
+#include "bitmap.h"
+#include "debug.h"
+#include "dir.h"
+#include "lcnalloc.h"
+#include "malloc.h"
+#include "mft.h"
 #include "ntfs.h"
 
 /**
- * __format_mft_record - initialize an empty mft record
- * @m:		mapped, pinned and locked for writing mft record
- * @size:	size of the mft record
- * @rec_no:	mft record number / inode number
- *
- * Private function to initialize an empty mft record. Use one of the two
- * provided format_mft_record() functions instead.
- */
-static void __format_mft_record(MFT_RECORD *m, const int size,
-		const unsigned long rec_no)
-{
-	ATTR_RECORD *a;
-
-	memset(m, 0, size);
-	m->magic = magic_FILE;
-	/* Aligned to 2-byte boundary. */
-	m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1);
-	m->usa_count = cpu_to_le16(size / NTFS_BLOCK_SIZE + 1);
-	/* Set the update sequence number to 1. */
-	*(le16*)((char*)m + ((sizeof(MFT_RECORD) + 1) & ~1)) = cpu_to_le16(1);
-	m->lsn = cpu_to_le64(0LL);
-	m->sequence_number = cpu_to_le16(1);
-	m->link_count = 0;
-	/* Aligned to 8-byte boundary. */
-	m->attrs_offset = cpu_to_le16((le16_to_cpu(m->usa_ofs) +
-			(le16_to_cpu(m->usa_count) << 1) + 7) & ~7);
-	m->flags = 0;
-	/*
-	 * Using attrs_offset plus eight bytes (for the termination attribute),
-	 * aligned to 8-byte boundary.
-	 */
-	m->bytes_in_use = cpu_to_le32((le16_to_cpu(m->attrs_offset) + 8 + 7) &
-			~7);
-	m->bytes_allocated = cpu_to_le32(size);
-	m->base_mft_record = cpu_to_le64((MFT_REF)0);
-	m->next_attr_instance = 0;
-	a = (ATTR_RECORD*)((char*)m + le16_to_cpu(m->attrs_offset));
-	a->type = AT_END;
-	a->length = 0;
-}
-
-/**
- * format_mft_record - initialize an empty mft record
- * @ni:		ntfs inode of mft record
- * @mft_rec:	mapped, pinned and locked mft record (optional)
- *
- * Initialize an empty mft record. This is used when extending the MFT.
- *
- * If @mft_rec is NULL, we call map_mft_record() to obtain the
- * record and we unmap it again when finished.
- *
- * We return 0 on success or -errno on error.
- */
-int format_mft_record(ntfs_inode *ni, MFT_RECORD *mft_rec)
-{
-	MFT_RECORD *m;
-
-	if (mft_rec)
-		m = mft_rec;
-	else {
-		m = map_mft_record(ni);
-		if (IS_ERR(m))
-			return PTR_ERR(m);
-	}
-	__format_mft_record(m, ni->vol->mft_record_size, ni->mft_no);
-	if (!mft_rec) {
-		// FIXME: Need to set the mft record dirty!
-		unmap_mft_record(ni);
-	}
-	return 0;
-}
-
-/**
- * ntfs_readpage - external declaration, function is in fs/ntfs/aops.c
- */
-extern int ntfs_readpage(struct file *, struct page *);
-
-#ifdef NTFS_RW
-/**
- * ntfs_mft_writepage - forward declaration, function is further below
- */
-static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc);
-#endif /* NTFS_RW */
-
-/**
- * ntfs_mft_aops - address space operations for access to $MFT
- *
- * Address space operations for access to $MFT. This allows us to simply use
- * ntfs_map_page() in map_mft_record_page().
- */
-struct address_space_operations ntfs_mft_aops = {
-	.readpage	= ntfs_readpage,	/* Fill page with data. */
-	.sync_page	= block_sync_page,	/* Currently, just unplugs the
-						   disk request queue. */
-#ifdef NTFS_RW
-	.writepage	= ntfs_mft_writepage,	/* Write out the dirty mft
-						   records in a page. */
-	.set_page_dirty	= __set_page_dirty_nobuffers,	/* Set the page dirty
-						   without touching the buffers
-						   belonging to the page. */
-#endif /* NTFS_RW */
-};
-
-/**
  * map_mft_record_page - map the page in which a specific mft record resides
  * @ni:		ntfs inode whose mft record page to map
  *
@@ -163,20 +68,31 @@
 		if (index > end_index || (mft_vi->i_size & ~PAGE_CACHE_MASK) <
 				ofs + vol->mft_record_size) {
 			page = ERR_PTR(-ENOENT);
+			ntfs_error(vol->sb, "Attemt to read mft record 0x%lx, "
+					"which is beyond the end of the mft.  "
+					"This is probably a bug in the ntfs "
+					"driver.", ni->mft_no);
 			goto err_out;
 		}
 	}
 	/* Read, map, and pin the page. */
 	page = ntfs_map_page(mft_vi->i_mapping, index);
 	if (likely(!IS_ERR(page))) {
-		ni->page = page;
-		ni->page_ofs = ofs;
-		return page_address(page) + ofs;
+		/* Catch multi sector transfer fixup errors. */
+		if (likely(ntfs_is_mft_recordp((le32*)(page_address(page) +
+				ofs)))) {
+			ni->page = page;
+			ni->page_ofs = ofs;
+			return page_address(page) + ofs;
+		}
+		ntfs_error(vol->sb, "Mft record 0x%lx is corrupt.  "
+				"Run chkdsk.", ni->mft_no);
+		ntfs_unmap_page(page);
+		page = ERR_PTR(-EIO);
 	}
 err_out:
 	ni->page = NULL;
 	ni->page_ofs = 0;
-	ntfs_error(vol->sb, "Failed with error code %lu.", -PTR_ERR(page));
 	return (void*)page;
 }
 
@@ -397,8 +313,8 @@
 		ntfs_clear_extent_inode(ni);
 		goto map_err_out;
 	}
-	/* Verify the sequence number. */
-	if (unlikely(le16_to_cpu(m->sequence_number) != seq_no)) {
+	/* Verify the sequence number if it is present. */
+	if (seq_no && (le16_to_cpu(m->sequence_number) != seq_no)) {
 		ntfs_error(base_ni->vol->sb, "Found stale extent mft "
 				"reference! Corrupt file system. Run chkdsk.");
 		destroy_ni = TRUE;
@@ -473,19 +389,11 @@
  */
 void __mark_mft_record_dirty(ntfs_inode *ni)
 {
-	struct page *page = ni->page;
 	ntfs_inode *base_ni;
 
 	ntfs_debug("Entering for inode 0x%lx.", ni->mft_no);
-	BUG_ON(!page);
 	BUG_ON(NInoAttr(ni));
-
-	/*
-	 * Set the page containing the mft record dirty.  This also marks the
-	 * $MFT inode dirty (I_DIRTY_PAGES).
-	 */
-	__set_page_dirty_nobuffers(page);
-
+	mark_ntfs_record_dirty(ni->page, ni->page_ofs);
 	/* Determine the base vfs inode and mark it dirty, too. */
 	down(&ni->extent_lock);
 	if (likely(ni->nr_extents >= 0))
@@ -501,13 +409,14 @@
 		"this message.  Thank you.";
 
 /**
- * sync_mft_mirror_umount - synchronise an mft record to the mft mirror
- * @ni:		ntfs inode whose mft record to synchronize
+ * ntfs_sync_mft_mirror_umount - synchronise an mft record to the mft mirror
+ * @vol:	ntfs volume on which the mft record to synchronize resides
+ * @mft_no:	mft record number of mft record to synchronize
  * @m:		mapped, mst protected (extent) mft record to synchronize
  *
- * Write the mapped, mst protected (extent) mft record @m described by the
- * (regular or extent) ntfs inode @ni to the mft mirror ($MFTMirr) bypassing
- * the page cache and the $MFTMirr inode itself.
+ * Write the mapped, mst protected (extent) mft record @m with mft record
+ * number @mft_no to the mft mirror ($MFTMirr) of the ntfs volume @vol,
+ * bypassing the page cache and the $MFTMirr inode itself.
  *
  * This function is only for use at umount time when the mft mirror inode has
  * already been disposed off.  We BUG() if we are called while the mft mirror
@@ -521,10 +430,9 @@
  * alternative would be either to BUG() or to get a NULL pointer dereference
  * and Oops.
  */
-static int sync_mft_mirror_umount(ntfs_inode *ni, MFT_RECORD *m)
+static int ntfs_sync_mft_mirror_umount(ntfs_volume *vol,
+		const unsigned long mft_no, MFT_RECORD *m)
 {
-	ntfs_volume *vol = ni->vol;
-
 	BUG_ON(vol->mftmirr_ino);
 	ntfs_error(vol->sb, "Umount time mft mirror syncing is not "
 			"implemented yet.  %s", ntfs_please_email);
@@ -532,116 +440,142 @@
 }
 
 /**
- * sync_mft_mirror - synchronize an mft record to the mft mirror
- * @ni:		ntfs inode whose mft record to synchronize
+ * ntfs_sync_mft_mirror - synchronize an mft record to the mft mirror
+ * @vol:	ntfs volume on which the mft record to synchronize resides
+ * @mft_no:	mft record number of mft record to synchronize
  * @m:		mapped, mst protected (extent) mft record to synchronize
  * @sync:	if true, wait for i/o completion
  *
- * Write the mapped, mst protected (extent) mft record @m described by the
- * (regular or extent) ntfs inode @ni to the mft mirror ($MFTMirr).
+ * Write the mapped, mst protected (extent) mft record @m with mft record
+ * number @mft_no to the mft mirror ($MFTMirr) of the ntfs volume @vol.
  *
  * On success return 0.  On error return -errno and set the volume errors flag
- * in the ntfs_volume to which @ni belongs.
+ * in the ntfs volume @vol.
  *
  * NOTE:  We always perform synchronous i/o and ignore the @sync parameter.
  *
  * TODO:  If @sync is false, want to do truly asynchronous i/o, i.e. just
  * schedule i/o via ->writepage or do it via kntfsd or whatever.
  */
-static int sync_mft_mirror(ntfs_inode *ni, MFT_RECORD *m, int sync)
+int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no,
+		MFT_RECORD *m, int sync)
 {
-	ntfs_volume *vol = ni->vol;
 	struct page *page;
 	unsigned int blocksize = vol->sb->s_blocksize;
 	int max_bhs = vol->mft_record_size / blocksize;
 	struct buffer_head *bhs[max_bhs];
 	struct buffer_head *bh, *head;
 	u8 *kmirr;
-	unsigned int block_start, block_end, m_start, m_end;
+	runlist_element *rl;
+	unsigned int block_start, block_end, m_start, m_end, page_ofs;
 	int i_bhs, nr_bhs, err = 0;
+	unsigned char blocksize_bits = vol->mftmirr_ino->i_blkbits;
 
-	ntfs_debug("Entering for inode 0x%lx.", ni->mft_no);
+	ntfs_debug("Entering for inode 0x%lx.", mft_no);
 	BUG_ON(!max_bhs);
 	if (unlikely(!vol->mftmirr_ino)) {
 		/* This could happen during umount... */
-		err = sync_mft_mirror_umount(ni, m);
+		err = ntfs_sync_mft_mirror_umount(vol, mft_no, m);
 		if (likely(!err))
 			return err;
 		goto err_out;
 	}
 	/* Get the page containing the mirror copy of the mft record @m. */
-	page = ntfs_map_page(vol->mftmirr_ino->i_mapping, ni->mft_no >>
+	page = ntfs_map_page(vol->mftmirr_ino->i_mapping, mft_no >>
 			(PAGE_CACHE_SHIFT - vol->mft_record_size_bits));
 	if (IS_ERR(page)) {
 		ntfs_error(vol->sb, "Failed to map mft mirror page.");
 		err = PTR_ERR(page);
 		goto err_out;
 	}
-	/*
-	 * Exclusion against other writers.   This should never be a problem
-	 * since the page in which the mft record @m resides is also locked and
-	 * hence any other writers would be held up there but it is better to
-	 * make sure no one is writing from elsewhere.
-	 */
 	lock_page(page);
+	BUG_ON(!PageUptodate(page));
+	ClearPageUptodate(page);
+	/* Offset of the mft mirror record inside the page. */
+	page_ofs = (mft_no << vol->mft_record_size_bits) & ~PAGE_CACHE_MASK;
 	/* The address in the page of the mirror copy of the mft record @m. */
-	kmirr = page_address(page) + ((ni->mft_no << vol->mft_record_size_bits)
-			& ~PAGE_CACHE_MASK);
+	kmirr = page_address(page) + page_ofs;
 	/* Copy the mst protected mft record to the mirror. */
 	memcpy(kmirr, m, vol->mft_record_size);
-	/* Make sure we have mapped buffers. */
-	if (!page_has_buffers(page)) {
-no_buffers_err_out:
-		ntfs_error(vol->sb, "Writing mft mirror records without "
-				"existing buffers is not implemented yet.  %s",
-				ntfs_please_email);
-		err = -EOPNOTSUPP;
-		goto unlock_err_out;
+	/* Create uptodate buffers if not present. */
+	if (unlikely(!page_has_buffers(page))) {
+		struct buffer_head *tail;
+
+		bh = head = alloc_page_buffers(page, blocksize, 1);
+		do {
+			set_buffer_uptodate(bh);
+			tail = bh;
+			bh = bh->b_this_page;
+		} while (bh);
+		tail->b_this_page = head;
+		attach_page_buffers(page, head);
+		BUG_ON(!page_has_buffers(page));
 	}
 	bh = head = page_buffers(page);
-	if (!bh)
-		goto no_buffers_err_out;
+	BUG_ON(!bh);
+	rl = NULL;
 	nr_bhs = 0;
 	block_start = 0;
 	m_start = kmirr - (u8*)page_address(page);
 	m_end = m_start + vol->mft_record_size;
 	do {
 		block_end = block_start + blocksize;
-		/*
-		 * If the buffer is outside the mft record, just skip it,
-		 * clearing it if it is dirty to make sure it is not written
-		 * out.  It should never be marked dirty but better be safe.
-		 */
-		if ((block_end <= m_start) || (block_start >= m_end)) {
-			if (buffer_dirty(bh)) {
-				ntfs_warning(vol->sb, "Clearing dirty mft "
-						"record page buffer.  %s",
-						ntfs_please_email);
-				clear_buffer_dirty(bh);
-			}
-			continue;
-		}
-		if (!buffer_mapped(bh)) {
-			ntfs_error(vol->sb, "Writing mft mirror records "
-					"without existing mapped buffers is "
-					"not implemented yet.  %s",
-					ntfs_please_email);
-			err = -EOPNOTSUPP;
-			continue;
-		}
-		if (!buffer_uptodate(bh)) {
-			ntfs_error(vol->sb, "Writing mft mirror records "
-					"without existing uptodate buffers is "
-					"not implemented yet.  %s",
-					ntfs_please_email);
-			err = -EOPNOTSUPP;
+		/* If the buffer is outside the mft record, skip it. */
+		if (block_end <= m_start)
 			continue;
+		if (unlikely(block_start >= m_end))
+			break;
+		/* Need to map the buffer if it is not mapped already. */
+		if (unlikely(!buffer_mapped(bh))) {
+			VCN vcn;
+			LCN lcn;
+			unsigned int vcn_ofs;
+
+			/* Obtain the vcn and offset of the current block. */
+			vcn = ((VCN)mft_no << vol->mft_record_size_bits) +
+					(block_start - m_start);
+			vcn_ofs = vcn & vol->cluster_size_mask;
+			vcn >>= vol->cluster_size_bits;
+			if (!rl) {
+				down_read(&NTFS_I(vol->mftmirr_ino)->
+						runlist.lock);
+				rl = NTFS_I(vol->mftmirr_ino)->runlist.rl;
+				/*
+				 * $MFTMirr always has the whole of its runlist
+				 * in memory.
+				 */
+				BUG_ON(!rl);
+			}
+			/* Seek to element containing target vcn. */
+			while (rl->length && rl[1].vcn <= vcn)
+				rl++;
+			lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
+			/* For $MFTMirr, only lcn >= 0 is a successful remap. */
+			if (likely(lcn >= 0)) {
+				/* Setup buffer head to correct block. */
+				bh->b_blocknr = ((lcn <<
+						vol->cluster_size_bits) +
+						vcn_ofs) >> blocksize_bits;
+				set_buffer_mapped(bh);
+			} else {
+				bh->b_blocknr = -1;
+				ntfs_error(vol->sb, "Cannot write mft mirror "
+						"record 0x%lx because its "
+						"location on disk could not "
+						"be determined (error code "
+						"%lli).", mft_no,
+						(long long)lcn);
+				err = -EIO;
+			}
 		}
+		BUG_ON(!buffer_uptodate(bh));
 		BUG_ON(!nr_bhs && (m_start != block_start));
 		BUG_ON(nr_bhs >= max_bhs);
 		bhs[nr_bhs++] = bh;
 		BUG_ON((nr_bhs >= max_bhs) && (m_end != block_end));
 	} while (block_start = block_end, (bh = bh->b_this_page) != head);
+	if (unlikely(rl))
+		up_read(&NTFS_I(vol->mftmirr_ino)->runlist.lock);
 	if (likely(!err)) {
 		/* Lock buffers and start synchronous write i/o on them. */
 		for (i_bhs = 0; i_bhs < nr_bhs; i_bhs++) {
@@ -650,8 +584,7 @@
 			if (unlikely(test_set_buffer_locked(tbh)))
 				BUG();
 			BUG_ON(!buffer_uptodate(tbh));
-			if (buffer_dirty(tbh))
-				clear_buffer_dirty(tbh);
+			clear_buffer_dirty(tbh);
 			get_bh(tbh);
 			tbh->b_end_io = end_buffer_write_sync;
 			submit_bh(WRITE, tbh);
@@ -664,11 +597,10 @@
 			if (unlikely(!buffer_uptodate(tbh))) {
 				err = -EIO;
 				/*
-				 * Set the buffer uptodate so the page & buffer
-				 * states don't become out of sync.
+				 * Set the buffer uptodate so the page and
+				 * buffer states do not become out of sync.
 				 */
-				if (PageUptodate(page))
-					set_buffer_uptodate(tbh);
+				set_buffer_uptodate(tbh);
 			}
 		}
 	} else /* if (unlikely(err)) */ {
@@ -676,29 +608,25 @@
 		for (i_bhs = 0; i_bhs < nr_bhs; i_bhs++)
 			clear_buffer_dirty(bhs[i_bhs]);
 	}
-unlock_err_out:
 	/* Current state: all buffers are clean, unlocked, and uptodate. */
 	/* Remove the mst protection fixups again. */
 	post_write_mst_fixup((NTFS_RECORD*)kmirr);
 	flush_dcache_page(page);
+	SetPageUptodate(page);
 	unlock_page(page);
 	ntfs_unmap_page(page);
-	if (unlikely(err)) {
-		/* I/O error during writing.  This is really bad! */
+	if (likely(!err)) {
+		ntfs_debug("Done.");
+	} else {
 		ntfs_error(vol->sb, "I/O error while writing mft mirror "
-				"record 0x%lx!  You should unmount the volume "
-				"and run chkdsk or ntfsfix.", ni->mft_no);
-		goto err_out;
-	}
-	ntfs_debug("Done.");
-	return 0;
+				"record 0x%lx!", mft_no);
 err_out:
-	ntfs_error(vol->sb, "Failed to synchronize $MFTMirr (error code %i).  "
-			"Volume will be left marked dirty on umount.  Run "
-			"ntfsfix on the partition after umounting to correct "
-			"this.", -err);
-	/* We don't want to clear the dirty bit on umount. */
-	NVolSetErrors(vol);
+		ntfs_error(vol->sb, "Failed to synchronize $MFTMirr (error "
+				"code %i).  Volume will be left marked dirty "
+				"on umount.  Run ntfsfix on the partition "
+				"after umounting to correct this.", -err);
+		NVolSetErrors(vol);
+	}
 	return err;
 }
 
@@ -712,6 +640,11 @@
  * ntfs inode @ni to backing store.  If the mft record @m has a counterpart in
  * the mft mirror, that is also updated.
  *
+ * We only write the mft record if the ntfs inode @ni is dirty and the first
+ * buffer belonging to its mft record is dirty, too.  We ignore the dirty state
+ * of subsequent buffers because we could have raced with
+ * fs/ntfs/aops.c::mark_ntfs_record_dirty().
+ *
  * On success, clean the mft record and return 0.  On error, leave the mft
  * record dirty and return -errno.  The caller should call make_bad_inode() on
  * the base inode to ensure no more access happens to this inode.  We do not do
@@ -735,10 +668,12 @@
 {
 	ntfs_volume *vol = ni->vol;
 	struct page *page = ni->page;
-	unsigned int blocksize = vol->sb->s_blocksize;
+	unsigned char blocksize_bits = vol->mft_ino->i_blkbits;
+	unsigned int blocksize = 1 << blocksize_bits;
 	int max_bhs = vol->mft_record_size / blocksize;
 	struct buffer_head *bhs[max_bhs];
 	struct buffer_head *bh, *head;
+	runlist_element *rl;
 	unsigned int block_start, block_end, m_start, m_end;
 	int i_bhs, nr_bhs, err = 0;
 
@@ -754,59 +689,81 @@
 	 */
 	if (!NInoTestClearDirty(ni))
 		goto done;
-	/* Make sure we have mapped buffers. */
-	if (!page_has_buffers(page)) {
-no_buffers_err_out:
-		ntfs_error(vol->sb, "Writing mft records without existing "
-				"buffers is not implemented yet.  %s",
-				ntfs_please_email);
-		err = -EOPNOTSUPP;
-		goto err_out;
-	}
+	BUG_ON(!page_has_buffers(page));
 	bh = head = page_buffers(page);
-	if (!bh)
-		goto no_buffers_err_out;
+	BUG_ON(!bh);
+	rl = NULL;
 	nr_bhs = 0;
 	block_start = 0;
 	m_start = ni->page_ofs;
 	m_end = m_start + vol->mft_record_size;
 	do {
 		block_end = block_start + blocksize;
+		/* If the buffer is outside the mft record, skip it. */
+		if (block_end <= m_start)
+			continue;
+		if (unlikely(block_start >= m_end))
+			break;
 		/*
-		 * If the buffer is outside the mft record, just skip it,
-		 * clearing it if it is dirty to make sure it is not written
-		 * out.  It should never be marked dirty but better be safe.
-		 */
-		if ((block_end <= m_start) || (block_start >= m_end)) {
-			if (buffer_dirty(bh)) {
-				ntfs_warning(vol->sb, "Clearing dirty mft "
-						"record page buffer.  %s",
-						ntfs_please_email);
-				clear_buffer_dirty(bh);
+		 * If this block is not the first one in the record, we ignore
+		 * the buffer's dirty state because we could have raced with a
+		 * parallel mark_ntfs_record_dirty().
+		 */
+		if (block_start == m_start) {
+			/* This block is the first one in the record. */
+			if (!buffer_dirty(bh)) {
+				BUG_ON(nr_bhs);
+				/* Clean records are not written out. */
+				break;
 			}
-			continue;
-		}
-		if (!buffer_mapped(bh)) {
-			ntfs_error(vol->sb, "Writing mft records without "
-					"existing mapped buffers is not "
-					"implemented yet.  %s",
-					ntfs_please_email);
-			err = -EOPNOTSUPP;
-			continue;
 		}
-		if (!buffer_uptodate(bh)) {
-			ntfs_error(vol->sb, "Writing mft records without "
-					"existing uptodate buffers is not "
-					"implemented yet.  %s",
-					ntfs_please_email);
-			err = -EOPNOTSUPP;
-			continue;
+		/* Need to map the buffer if it is not mapped already. */
+		if (unlikely(!buffer_mapped(bh))) {
+			VCN vcn;
+			LCN lcn;
+			unsigned int vcn_ofs;
+
+			/* Obtain the vcn and offset of the current block. */
+			vcn = ((VCN)ni->mft_no << vol->mft_record_size_bits) +
+					(block_start - m_start);
+			vcn_ofs = vcn & vol->cluster_size_mask;
+			vcn >>= vol->cluster_size_bits;
+			if (!rl) {
+				down_read(&NTFS_I(vol->mft_ino)->runlist.lock);
+				rl = NTFS_I(vol->mft_ino)->runlist.rl;
+				BUG_ON(!rl);
+			}
+			/* Seek to element containing target vcn. */
+			while (rl->length && rl[1].vcn <= vcn)
+				rl++;
+			lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
+			/* For $MFT, only lcn >= 0 is a successful remap. */
+			if (likely(lcn >= 0)) {
+				/* Setup buffer head to correct block. */
+				bh->b_blocknr = ((lcn <<
+						vol->cluster_size_bits) +
+						vcn_ofs) >> blocksize_bits;
+				set_buffer_mapped(bh);
+			} else {
+				bh->b_blocknr = -1;
+				ntfs_error(vol->sb, "Cannot write mft record "
+						"0x%lx because its location "
+						"on disk could not be "
+						"determined (error code %lli).",
+						ni->mft_no, (long long)lcn);
+				err = -EIO;
+			}
 		}
+		BUG_ON(!buffer_uptodate(bh));
 		BUG_ON(!nr_bhs && (m_start != block_start));
 		BUG_ON(nr_bhs >= max_bhs);
 		bhs[nr_bhs++] = bh;
 		BUG_ON((nr_bhs >= max_bhs) && (m_end != block_end));
 	} while (block_start = block_end, (bh = bh->b_this_page) != head);
+	if (unlikely(rl))
+		up_read(&NTFS_I(vol->mft_ino)->runlist.lock);
+	if (!nr_bhs)
+		goto done;
 	if (unlikely(err))
 		goto cleanup_out;
 	/* Apply the mst protection fixups. */
@@ -823,15 +780,14 @@
 		if (unlikely(test_set_buffer_locked(tbh)))
 			BUG();
 		BUG_ON(!buffer_uptodate(tbh));
-		if (buffer_dirty(tbh))
-			clear_buffer_dirty(tbh);
+		clear_buffer_dirty(tbh);
 		get_bh(tbh);
 		tbh->b_end_io = end_buffer_write_sync;
 		submit_bh(WRITE, tbh);
 	}
 	/* Synchronize the mft mirror now if not @sync. */
 	if (!sync && ni->mft_no < vol->mftmirr_size)
-		sync_mft_mirror(ni, m, sync);
+		ntfs_sync_mft_mirror(vol, ni->mft_no, m, sync);
 	/* Wait on i/o completion of buffers. */
 	for (i_bhs = 0; i_bhs < nr_bhs; i_bhs++) {
 		struct buffer_head *tbh = bhs[i_bhs];
@@ -840,8 +796,8 @@
 		if (unlikely(!buffer_uptodate(tbh))) {
 			err = -EIO;
 			/*
-			 * Set the buffer uptodate so the page & buffer states
-			 * don't become out of sync.
+			 * Set the buffer uptodate so the page and buffer
+			 * states do not become out of sync.
 			 */
 			if (PageUptodate(page))
 				set_buffer_uptodate(tbh);
@@ -849,7 +805,7 @@
 	}
 	/* If @sync, now synchronize the mft mirror. */
 	if (sync && ni->mft_no < vol->mftmirr_size)
-		sync_mft_mirror(ni, m, sync);
+		ntfs_sync_mft_mirror(vol, ni->mft_no, m, sync);
 	/* Remove the mst protection fixups again. */
 	post_write_mst_fixup((NTFS_RECORD*)m);
 	flush_dcache_mft_record_page(ni);
@@ -880,219 +836,1993 @@
 				"Redirtying so the write is retried later.");
 		mark_mft_record_dirty(ni);
 		err = 0;
-	}
+	} else
+		NVolSetErrors(vol);
 	return err;
 }
 
 /**
- * ntfs_mft_writepage - check if a metadata page contains dirty mft records
- * @page:	metadata page possibly containing dirty mft records
- * @wbc:	writeback control structure
- *
- * This is called from the VM when it wants to have a dirty $MFT/$DATA metadata
- * page cache page cleaned.  The VM has already locked the page and marked it
- * clean.  Instead of writing the page as a conventional ->writepage function
- * would do, we check if the page still contains any dirty mft records (it must
- * have done at some point in the past since the page was marked dirty) and if
- * none are found, i.e. all mft records are clean, we unlock the page and
- * return.  The VM is then free to do with the page as it pleases.  If on the
- * other hand we do find any dirty mft records in the page, we redirty the page
- * before unlocking it and returning so the VM knows that the page is still
- * busy and cannot be thrown out.
- *
- * Note, we do not actually write any dirty mft records here because they are
- * dirty inodes and hence will be written by the VFS inode dirty code paths.
- * There is no need to write them from the VM page dirty code paths, too and in
- * fact once we implement journalling it would be a complete nightmare having
- * two code paths leading to mft record writeout.
+ * ntfs_may_write_mft_record - check if an mft record may be written out
+ * @vol:	[IN]  ntfs volume on which the mft record to check resides
+ * @mft_no:	[IN]  mft record number of the mft record to check
+ * @m:		[IN]  mapped mft record to check
+ * @locked_ni:	[OUT] caller has to unlock this ntfs inode if one is returned
+ *
+ * Check if the mapped (base or extent) mft record @m with mft record number
+ * @mft_no belonging to the ntfs volume @vol may be written out.  If necessary
+ * and possible the ntfs inode of the mft record is locked and the base vfs
+ * inode is pinned.  The locked ntfs inode is then returned in @locked_ni.  The
+ * caller is responsible for unlocking the ntfs inode and unpinning the base
+ * vfs inode.
+ *
+ * Return TRUE if the mft record may be written out and FALSE if not.
+ *
+ * The caller has locked the page and cleared the uptodate flag on it which
+ * means that we can safely write out any dirty mft records that do not have
+ * their inodes in icache as determined by ilookup5() as anyone
+ * opening/creating such an inode would block when attempting to map the mft
+ * record in read_cache_page() until we are finished with the write out.
+ *
+ * Here is a description of the tests we perform:
+ *
+ * If the inode is found in icache we know the mft record must be a base mft
+ * record.  If it is dirty, we do not write it and return FALSE as the vfs
+ * inode write paths will result in the access times being updated which would
+ * cause the base mft record to be redirtied and written out again.  (We know
+ * the access time update will modify the base mft record because Windows
+ * chkdsk complains if the standard information attribute is not in the base
+ * mft record.)
+ *
+ * If the inode is in icache and not dirty, we attempt to lock the mft record
+ * and if we find the lock was already taken, it is not safe to write the mft
+ * record and we return FALSE.
+ *
+ * If we manage to obtain the lock we have exclusive access to the mft record,
+ * which also allows us safe writeout of the mft record.  We then set
+ * @locked_ni to the locked ntfs inode and return TRUE.
+ *
+ * Note we cannot just lock the mft record and sleep while waiting for the lock
+ * because this would deadlock due to lock reversal (normally the mft record is
+ * locked before the page is locked but we already have the page locked here
+ * when we try to lock the mft record).
+ *
+ * If the inode is not in icache we need to perform further checks.
+ *
+ * If the mft record is not a FILE record or it is a base mft record, we can
+ * safely write it and return TRUE.
+ *
+ * We now know the mft record is an extent mft record.  We check if the inode
+ * corresponding to its base mft record is in icache and obtain a reference to
+ * it if it is.  If it is not, we can safely write it and return TRUE.
+ *
+ * We now have the base inode for the extent mft record.  We check if it has an
+ * ntfs inode for the extent mft record attached and if not it is safe to write
+ * the extent mft record and we return TRUE.
+ *
+ * The ntfs inode for the extent mft record is attached to the base inode so we
+ * attempt to lock the extent mft record and if we find the lock was already
+ * taken, it is not safe to write the extent mft record and we return FALSE.
+ *
+ * If we manage to obtain the lock we have exclusive access to the extent mft
+ * record, which also allows us safe writeout of the extent mft record.  We
+ * set the ntfs inode of the extent mft record clean and then set @locked_ni to
+ * the now locked ntfs inode and return TRUE.
+ *
+ * Note, the reason for actually writing dirty mft records here and not just
+ * relying on the vfs inode dirty code paths is that we can have mft records
+ * modified without them ever having actual inodes in memory.  Also we can have
+ * dirty mft records with clean ntfs inodes in memory.  None of the described
+ * cases would result in the dirty mft records being written out if we only
+ * relied on the vfs inode dirty code paths.  And these cases can really occur
+ * during allocation of new mft records and in particular when the
+ * initialized_size of the $MFT/$DATA attribute is extended and the new space
+ * is initialized using ntfs_mft_record_format().  The clean inode can then
+ * appear if the mft record is reused for a new inode before it got written
+ * out.
  */
-static int ntfs_mft_writepage(struct page *page, struct writeback_control *wbc)
+BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
+		const MFT_RECORD *m, ntfs_inode **locked_ni)
 {
-	struct inode *mft_vi = page->mapping->host;
-	struct super_block *sb = mft_vi->i_sb;
-	ntfs_volume *vol = NTFS_SB(sb);
-	u8 *maddr;
-	MFT_RECORD *m;
-	ntfs_inode **extent_nis;
-	unsigned long mft_no;
-	int nr, i, j;
-	BOOL is_dirty = FALSE;
+	struct super_block *sb = vol->sb;
+	struct inode *mft_vi = vol->mft_ino;
+	struct inode *vi;
+	ntfs_inode *ni, *eni, **extent_nis;
+	int i;
+	ntfs_attr na;
 
-	BUG_ON(!PageLocked(page));
-	BUG_ON(PageWriteback(page));
-	BUG_ON(mft_vi != vol->mft_ino);
-	/* The first mft record number in the page. */
-	mft_no = page->index << (PAGE_CACHE_SHIFT - vol->mft_record_size_bits);
-	/* Number of mft records in the page. */
-	nr = PAGE_CACHE_SIZE >> vol->mft_record_size_bits;
-	BUG_ON(!nr);
-	ntfs_debug("Entering for %i inodes starting at 0x%lx.", nr, mft_no);
-	/* Iterate over the mft records in the page looking for a dirty one. */
-	maddr = (u8*)kmap(page);
-	for (i = 0; i < nr; ++i, ++mft_no, maddr += vol->mft_record_size) {
-		struct inode *vi;
-		ntfs_inode *ni, *eni;
-		ntfs_attr na;
-
-		na.mft_no = mft_no;
-		na.name = NULL;
-		na.name_len = 0;
-		na.type = AT_UNUSED;
-		/*
-		 * Check if the inode corresponding to this mft record is in
-		 * the VFS inode cache and obtain a reference to it if it is.
-		 */
-		ntfs_debug("Looking for inode 0x%lx in icache.", mft_no);
-		/*
-		 * For inode 0, i.e. $MFT itself, we cannot use ilookup5() from
-		 * here or we deadlock because the inode is already locked by
-		 * the kernel (fs/fs-writeback.c::__sync_single_inode()) and
-		 * ilookup5() waits until the inode is unlocked before
-		 * returning it and it never gets unlocked because
-		 * ntfs_mft_writepage() never returns.  )-:  Fortunately, we
-		 * have inode 0 pinned in icache for the duration of the mount
-		 * so we can access it directly.
-		 */
-		if (!mft_no) {
-			/* Balance the below iput(). */
-			vi = igrab(mft_vi);
-			BUG_ON(vi != mft_vi);
-		} else
-			vi = ilookup5(sb, mft_no, (test_t)ntfs_test_inode, &na);
-		if (vi) {
-			ntfs_debug("Inode 0x%lx is in icache.", mft_no);
-			/* The inode is in icache.  Check if it is dirty. */
-			ni = NTFS_I(vi);
-			if (!NInoDirty(ni)) {
-				/* The inode is not dirty, skip this record. */
-				ntfs_debug("Inode 0x%lx is not dirty, "
-						"continuing search.", mft_no);
-				iput(vi);
-				continue;
-			}
-			ntfs_debug("Inode 0x%lx is dirty, aborting search.",
+	ntfs_debug("Entering for inode 0x%lx.", mft_no);
+	/*
+	 * Normally we do not return a locked inode so set @locked_ni to NULL.
+	 */
+	BUG_ON(!locked_ni);
+	*locked_ni = NULL;
+	/*
+	 * Check if the inode corresponding to this mft record is in the VFS
+	 * inode cache and obtain a reference to it if it is.
+	 */
+	ntfs_debug("Looking for inode 0x%lx in icache.", mft_no);
+	na.mft_no = mft_no;
+	na.name = NULL;
+	na.name_len = 0;
+	na.type = AT_UNUSED;
+	/*
+	 * For inode 0, i.e. $MFT itself, we cannot use ilookup5() from here or
+	 * we deadlock because the inode is already locked by the kernel
+	 * (fs/fs-writeback.c::__sync_single_inode()) and ilookup5() waits
+	 * until the inode is unlocked before returning it and it never gets
+	 * unlocked because ntfs_should_write_mft_record() never returns.  )-:
+	 * Fortunately, we have inode 0 pinned in icache for the duration of
+	 * the mount so we can access it directly.
+	 */
+	if (!mft_no) {
+		/* Balance the below iput(). */
+		vi = igrab(mft_vi);
+		BUG_ON(vi != mft_vi);
+	} else
+		vi = ilookup5(sb, mft_no, (test_t)ntfs_test_inode, &na);
+	if (vi) {
+		ntfs_debug("Base inode 0x%lx is in icache.", mft_no);
+		/* The inode is in icache. */
+		ni = NTFS_I(vi);
+		/* Take a reference to the ntfs inode. */
+		atomic_inc(&ni->count);
+		/* If the inode is dirty, do not write this record. */
+		if (NInoDirty(ni)) {
+			ntfs_debug("Inode 0x%lx is dirty, do not write it.",
 					mft_no);
-			/* The inode is dirty, no need to search further. */
+			atomic_dec(&ni->count);
 			iput(vi);
-			is_dirty = TRUE;
-			break;
+			return FALSE;
 		}
-		ntfs_debug("Inode 0x%lx is not in icache.", mft_no);
-		/* The inode is not in icache. */
-		/* Skip the record if it is not a mft record (type "FILE"). */
-		if (!ntfs_is_mft_recordp((le32*)maddr)) {
-			ntfs_debug("Mft record 0x%lx is not a FILE record, "
-					"continuing search.", mft_no);
-			continue;
+		ntfs_debug("Inode 0x%lx is not dirty.", mft_no);
+		/* The inode is not dirty, try to take the mft record lock. */
+		if (unlikely(down_trylock(&ni->mrec_lock))) {
+			ntfs_debug("Mft record 0x%lx is already locked, do "
+					"not write it.", mft_no);
+			atomic_dec(&ni->count);
+			iput(vi);
+			return FALSE;
 		}
-		m = (MFT_RECORD*)maddr;
+		ntfs_debug("Managed to lock mft record 0x%lx, write it.",
+				mft_no);
 		/*
-		 * Skip the mft record if it is not in use.  FIXME:  What about
-		 * deleted/deallocated (extent) inodes?  (AIA)
+		 * The write has to occur while we hold the mft record lock so
+		 * return the locked ntfs inode.
 		 */
-		if (!(m->flags & MFT_RECORD_IN_USE)) {
-			ntfs_debug("Mft record 0x%lx is not in use, "
-					"continuing search.", mft_no);
-			continue;
-		}
-		/* Skip the mft record if it is a base inode. */
-		if (!m->base_mft_record) {
-			ntfs_debug("Mft record 0x%lx is a base record, "
-					"continuing search.", mft_no);
-			continue;
-		}
+		*locked_ni = ni;
+		return TRUE;
+	}
+	ntfs_debug("Inode 0x%lx is not in icache.", mft_no);
+	/* The inode is not in icache. */
+	/* Write the record if it is not a mft record (type "FILE"). */
+	if (!ntfs_is_mft_record(m->magic)) {
+		ntfs_debug("Mft record 0x%lx is not a FILE record, write it.",
+				mft_no);
+		return TRUE;
+	}
+	/* Write the mft record if it is a base inode. */
+	if (!m->base_mft_record) {
+		ntfs_debug("Mft record 0x%lx is a base record, write it.",
+				mft_no);
+		return TRUE;
+	}
+	/*
+	 * This is an extent mft record.  Check if the inode corresponding to
+	 * its base mft record is in icache and obtain a reference to it if it
+	 * is.
+	 */
+	na.mft_no = MREF_LE(m->base_mft_record);
+	ntfs_debug("Mft record 0x%lx is an extent record.  Looking for base "
+			"inode 0x%lx in icache.", mft_no, na.mft_no);
+	vi = ilookup5(sb, na.mft_no, (test_t)ntfs_test_inode, &na);
+	if (!vi) {
 		/*
-		 * This is an extent mft record.  Check if the inode
-		 * corresponding to its base mft record is in icache.
+		 * The base inode is not in icache, write this extent mft
+		 * record.
 		 */
-		na.mft_no = MREF_LE(m->base_mft_record);
-		ntfs_debug("Mft record 0x%lx is an extent record.  Looking "
-				"for base inode 0x%lx in icache.", mft_no,
-				na.mft_no);
-		vi = ilookup5(sb, na.mft_no, (test_t)ntfs_test_inode,
-				&na);
-		if (!vi) {
+		ntfs_debug("Base inode 0x%lx is not in icache, write the "
+				"extent record.", na.mft_no);
+		return TRUE;
+	}
+	ntfs_debug("Base inode 0x%lx is in icache.", na.mft_no);
+	/*
+	 * The base inode is in icache.  Check if it has the extent inode
+	 * corresponding to this extent mft record attached.
+	 */
+	ni = NTFS_I(vi);
+	down(&ni->extent_lock);
+	if (ni->nr_extents <= 0) {
+		/*
+		 * The base inode has no attached extent inodes, write this
+		 * extent mft record.
+		 */
+		up(&ni->extent_lock);
+		iput(vi);
+		ntfs_debug("Base inode 0x%lx has no attached extent inodes, "
+				"write the extent record.", na.mft_no);
+		return TRUE;
+	}
+	/* Iterate over the attached extent inodes. */
+	extent_nis = ni->ext.extent_ntfs_inos;
+	for (eni = NULL, i = 0; i < ni->nr_extents; ++i) {
+		if (mft_no == extent_nis[i]->mft_no) {
 			/*
-			 * The base inode is not in icache.  Skip this extent
+			 * Found the extent inode corresponding to this extent
 			 * mft record.
 			 */
-			ntfs_debug("Base inode 0x%lx is not in icache, "
-					"continuing search.", na.mft_no);
-			continue;
+			eni = extent_nis[i];
+			break;
 		}
-		ntfs_debug("Base inode 0x%lx is in icache.", na.mft_no);
+	}
+	/*
+	 * If the extent inode was not attached to the base inode, write this
+	 * extent mft record.
+	 */
+	if (!eni) {
+		up(&ni->extent_lock);
+		iput(vi);
+		ntfs_debug("Extent inode 0x%lx is not attached to its base "
+				"inode 0x%lx, write the extent record.",
+				mft_no, na.mft_no);
+		return TRUE;
+	}
+	ntfs_debug("Extent inode 0x%lx is attached to its base inode 0x%lx.",
+			mft_no, na.mft_no);
+	/* Take a reference to the extent ntfs inode. */
+	atomic_inc(&eni->count);
+	up(&ni->extent_lock);
+	/*
+	 * Found the extent inode coresponding to this extent mft record.
+	 * Try to take the mft record lock.
+	 */
+	if (unlikely(down_trylock(&eni->mrec_lock))) {
+		atomic_dec(&eni->count);
+		iput(vi);
+		ntfs_debug("Extent mft record 0x%lx is already locked, do "
+				"not write it.", mft_no);
+		return FALSE;
+	}
+	ntfs_debug("Managed to lock extent mft record 0x%lx, write it.",
+			mft_no);
+	if (NInoTestClearDirty(eni))
+		ntfs_debug("Extent inode 0x%lx is dirty, marking it clean.",
+				mft_no);
+	/*
+	 * The write has to occur while we hold the mft record lock so return
+	 * the locked extent ntfs inode.
+	 */
+	*locked_ni = eni;
+	return TRUE;
+}
+
+static const char *es = "  Leaving inconsistent metadata.  Unmount and run "
+		"chkdsk.";
+
+/**
+ * ntfs_mft_bitmap_find_and_alloc_free_rec_nolock - see name
+ * @vol:	volume on which to search for a free mft record
+ * @base_ni:	open base inode if allocating an extent mft record or NULL
+ *
+ * Search for a free mft record in the mft bitmap attribute on the ntfs volume
+ * @vol.
+ *
+ * If @base_ni is NULL start the search at the default allocator position.
+ *
+ * If @base_ni is not NULL start the search at the mft record after the base
+ * mft record @base_ni.
+ *
+ * Return the free mft record on success and -errno on error.  An error code of
+ * -ENOSPC means that there are no free mft records in the currently
+ * initialized mft bitmap.
+ *
+ * Locking: Caller must hold vol->mftbmp_lock for writing.
+ */
+static int ntfs_mft_bitmap_find_and_alloc_free_rec_nolock(ntfs_volume *vol,
+		ntfs_inode *base_ni)
+{
+	s64 pass_end, ll, data_pos, pass_start, ofs, bit;
+	struct address_space *mftbmp_mapping;
+	u8 *buf, *byte;
+	struct page *page;
+	unsigned int page_ofs, size;
+	u8 pass, b;
+
+	ntfs_debug("Searching for free mft record in the currently "
+			"initialized mft bitmap.");
+	mftbmp_mapping = vol->mftbmp_ino->i_mapping;
+	/*
+	 * Set the end of the pass making sure we do not overflow the mft
+	 * bitmap.
+	 */
+	pass_end = NTFS_I(vol->mft_ino)->allocated_size >>
+			vol->mft_record_size_bits;
+	ll = NTFS_I(vol->mftbmp_ino)->initialized_size << 3;
+	if (pass_end > ll)
+		pass_end = ll;
+	pass = 1;
+	if (!base_ni)
+		data_pos = vol->mft_data_pos;
+	else
+		data_pos = base_ni->mft_no + 1;
+	if (data_pos < 24)
+		data_pos = 24;
+	if (data_pos >= pass_end) {
+		data_pos = 24;
+		pass = 2;
+		/* This happens on a freshly formatted volume. */
+		if (data_pos >= pass_end)
+			return -ENOSPC;
+	}
+	pass_start = data_pos;
+	ntfs_debug("Starting bitmap search: pass %u, pass_start 0x%llx, "
+			"pass_end 0x%llx, data_pos 0x%llx.", pass,
+			(long long)pass_start, (long long)pass_end,
+			(long long)data_pos);
+	/* Loop until a free mft record is found. */
+	for (; pass <= 2;) {
+		/* Cap size to pass_end. */
+		ofs = data_pos >> 3;
+		page_ofs = ofs & ~PAGE_CACHE_MASK;
+		size = PAGE_CACHE_SIZE - page_ofs;
+		ll = ((pass_end + 7) >> 3) - ofs;
+		if (size > ll)
+			size = ll;
+		size <<= 3;
 		/*
-		 * The base inode is in icache.  Check if it has the extent
-		 * inode corresponding to this extent mft record attached.
+		 * If we are still within the active pass, search the next page
+		 * for a zero bit.
 		 */
-		ni = NTFS_I(vi);
-		down(&ni->extent_lock);
-		if (ni->nr_extents <= 0) {
+		if (size) {
+			page = ntfs_map_page(mftbmp_mapping,
+					ofs >> PAGE_CACHE_SHIFT);
+			if (unlikely(IS_ERR(page))) {
+				ntfs_error(vol->sb, "Failed to read mft "
+						"bitmap, aborting.");
+				return PTR_ERR(page);
+			}
+			buf = (u8*)page_address(page) + page_ofs;
+			bit = data_pos & 7;
+			data_pos &= ~7ull;
+			ntfs_debug("Before inner for loop: size 0x%x, "
+					"data_pos 0x%llx, bit 0x%llx", size,
+					(long long)data_pos, (long long)bit);
+			for (; bit < size && data_pos + bit < pass_end;
+					bit &= ~7ull, bit += 8) {
+				byte = buf + (bit >> 3);
+				if (*byte == 0xff)
+					continue;
+				b = ffz((unsigned long)*byte);
+				if (b < 8 && b >= (bit & 7)) {
+					ll = data_pos + (bit & ~7ull) + b;
+					if (unlikely(ll > (1ll << 32))) {
+						ntfs_unmap_page(page);
+						return -ENOSPC;
+					}
+					*byte |= 1 << b;
+					flush_dcache_page(page);
+					set_page_dirty(page);
+					ntfs_unmap_page(page);
+					ntfs_debug("Done.  (Found and "
+							"allocated mft record "
+							"0x%llx.)",
+							(long long)ll);
+					return ll;
+				}
+			}
+			ntfs_debug("After inner for loop: size 0x%x, "
+					"data_pos 0x%llx, bit 0x%llx", size,
+					(long long)data_pos, (long long)bit);
+			data_pos += size;
+			ntfs_unmap_page(page);
 			/*
-			 * The base inode has no attached extent inodes.  Skip
-			 * this extent mft record.
+			 * If the end of the pass has not been reached yet,
+			 * continue searching the mft bitmap for a zero bit.
 			 */
-			up(&ni->extent_lock);
-			iput(vi);
-			continue;
+			if (data_pos < pass_end)
+				continue;
 		}
-		/* Iterate over the attached extent inodes. */
-		extent_nis = ni->ext.extent_ntfs_inos;
-		for (eni = NULL, j = 0; j < ni->nr_extents; ++j) {
-			if (mft_no == extent_nis[j]->mft_no) {
-				/*
-				 * Found the extent inode corresponding to this
-				 * extent mft record.
-				 */
-				eni = extent_nis[j];
+		/* Do the next pass. */
+		if (++pass == 2) {
+			/*
+			 * Starting the second pass, in which we scan the first
+			 * part of the zone which we omitted earlier.
+			 */
+			pass_end = pass_start;
+			data_pos = pass_start = 24;
+			ntfs_debug("pass %i, pass_start 0x%llx, pass_end "
+					"0x%llx.", pass, (long long)pass_start,
+					(long long)pass_end);
+			if (data_pos >= pass_end)
 				break;
+		}
+	}
+	/* No free mft records in currently initialized mft bitmap. */
+	ntfs_debug("Done.  (No free mft records left in currently initialized "
+			"mft bitmap.)");
+	return -ENOSPC;
+}
+
+/**
+ * ntfs_mft_bitmap_extend_allocation_nolock - extend mft bitmap by a cluster
+ * @vol:	volume on which to extend the mft bitmap attribute
+ *
+ * Extend the mft bitmap attribute on the ntfs volume @vol by one cluster.
+ *
+ * Note: Only changes allocated_size, i.e. does not touch initialized_size or
+ * data_size.
+ *
+ * Return 0 on success and -errno on error.
+ *
+ * Locking: - Caller must hold vol->mftbmp_lock for writing.
+ *	    - This function takes NTFS_I(vol->mftbmp_ino)->runlist.lock for
+ *	      writing and releases it before returning.
+ *	    - This function takes vol->lcnbmp_lock for writing and releases it
+ *	      before returning.
+ */
+static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol)
+{
+	LCN lcn;
+	s64 ll;
+	struct page *page;
+	ntfs_inode *mft_ni, *mftbmp_ni;
+	runlist_element *rl, *rl2 = NULL;
+	ntfs_attr_search_ctx *ctx = NULL;
+	MFT_RECORD *mrec;
+	ATTR_RECORD *a = NULL;
+	int ret, mp_size;
+	u32 old_alen = 0;
+	u8 *b, tb;
+	struct {
+		u8 added_cluster:1;
+		u8 added_run:1;
+		u8 mp_rebuilt:1;
+	} status = { 0, 0, 0 };
+
+	ntfs_debug("Extending mft bitmap allocation.");
+	mft_ni = NTFS_I(vol->mft_ino);
+	mftbmp_ni = NTFS_I(vol->mftbmp_ino);
+	/*
+	 * Determine the last lcn of the mft bitmap.  The allocated size of the
+	 * mft bitmap cannot be zero so we are ok to do this.
+	 * ntfs_find_vcn() returns the runlist locked on success.
+	 */
+	rl = ntfs_find_vcn(mftbmp_ni, (mftbmp_ni->allocated_size - 1) >>
+			vol->cluster_size_bits, TRUE);
+	if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) {
+		ntfs_error(vol->sb, "Failed to determine last allocated "
+				"cluster of mft bitmap attribute.");
+		if (!IS_ERR(rl)) {
+			up_write(&mftbmp_ni->runlist.lock);
+			ret = -EIO;
+		} else
+			ret = PTR_ERR(rl);
+		return ret;
+	}
+	lcn = rl->lcn + rl->length;
+	ntfs_debug("Last lcn of mft bitmap attribute is 0x%llx.",
+			(long long)lcn);
+	/*
+	 * Attempt to get the cluster following the last allocated cluster by
+	 * hand as it may be in the MFT zone so the allocator would not give it
+	 * to us.
+	 */
+	ll = lcn >> 3;
+	page = ntfs_map_page(vol->lcnbmp_ino->i_mapping,
+			ll >> PAGE_CACHE_SHIFT);
+	if (IS_ERR(page)) {
+		up_write(&mftbmp_ni->runlist.lock);
+		ntfs_error(vol->sb, "Failed to read from lcn bitmap.");
+		return PTR_ERR(page);
+	}
+	b = (u8*)page_address(page) + (ll & ~PAGE_CACHE_MASK);
+	tb = 1 << (lcn & 7ull);
+	down_write(&vol->lcnbmp_lock);
+	if (*b != 0xff && !(*b & tb)) {
+		/* Next cluster is free, allocate it. */
+		*b |= tb;
+		flush_dcache_page(page);
+		set_page_dirty(page);
+		up_write(&vol->lcnbmp_lock);
+		ntfs_unmap_page(page);
+		/* Update the mft bitmap runlist. */
+		rl->length++;
+		rl[1].vcn++;
+		status.added_cluster = 1;
+		ntfs_debug("Appending one cluster to mft bitmap.");
+	} else {
+		up_write(&vol->lcnbmp_lock);
+		ntfs_unmap_page(page);
+		/* Allocate a cluster from the DATA_ZONE. */
+		rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE);
+		if (IS_ERR(rl2)) {
+			up_write(&mftbmp_ni->runlist.lock);
+			ntfs_error(vol->sb, "Failed to allocate a cluster for "
+					"the mft bitmap.");
+			return PTR_ERR(rl2);
+		}
+		rl = ntfs_runlists_merge(mftbmp_ni->runlist.rl, rl2);
+		if (IS_ERR(rl)) {
+			up_write(&mftbmp_ni->runlist.lock);
+			ntfs_error(vol->sb, "Failed to merge runlists for mft "
+					"bitmap.");
+			if (ntfs_cluster_free_from_rl(vol, rl2)) {
+				ntfs_error(vol->sb, "Failed to dealocate "
+						"allocated cluster.%s", es);
+				NVolSetErrors(vol);
 			}
+			ntfs_free(rl2);
+			return PTR_ERR(rl);
 		}
+		mftbmp_ni->runlist.rl = rl;
+		status.added_run = 1;
+		ntfs_debug("Adding one run to mft bitmap.");
+		/* Find the last run in the new runlist. */
+		for (; rl[1].length; rl++)
+			;
+	}
+	/*
+	 * Update the attribute record as well.  Note: @rl is the last
+	 * (non-terminator) runlist element of mft bitmap.
+	 */
+	mrec = map_mft_record(mft_ni);
+	if (IS_ERR(mrec)) {
+		ntfs_error(vol->sb, "Failed to map mft record.");
+		ret = PTR_ERR(mrec);
+		goto undo_alloc;
+	}
+	ctx = ntfs_attr_get_search_ctx(mft_ni, mrec);
+	if (unlikely(!ctx)) {
+		ntfs_error(vol->sb, "Failed to get search context.");
+		ret = -ENOMEM;
+		goto undo_alloc;
+	}
+	ret = ntfs_attr_lookup(mftbmp_ni->type, mftbmp_ni->name,
+			mftbmp_ni->name_len, CASE_SENSITIVE, rl[1].vcn, NULL,
+			0, ctx);
+	if (unlikely(ret)) {
+		ntfs_error(vol->sb, "Failed to find last attribute extent of "
+				"mft bitmap attribute.");
+		if (ret == -ENOENT)
+			ret = -EIO;
+		goto undo_alloc;
+	}
+	a = ctx->attr;
+	ll = sle64_to_cpu(a->data.non_resident.lowest_vcn);
+	/* Search back for the previous last allocated cluster of mft bitmap. */
+	for (rl2 = rl; rl2 > mftbmp_ni->runlist.rl; rl2--) {
+		if (ll >= rl2->vcn)
+			break;
+	}
+	BUG_ON(ll < rl2->vcn);
+	BUG_ON(ll >= rl2->vcn + rl2->length);
+	/* Get the size for the new mapping pairs array for this extent. */
+	mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll);
+	if (unlikely(mp_size <= 0)) {
+		ntfs_error(vol->sb, "Get size for mapping pairs failed for "
+				"mft bitmap attribute extent.");
+		ret = mp_size;
+		if (!ret)
+			ret = -EIO;
+		goto undo_alloc;
+	}
+	/* Expand the attribute record if necessary. */
+	old_alen = le32_to_cpu(a->length);
+	ret = ntfs_attr_record_resize(ctx->mrec, a, mp_size +
+			le16_to_cpu(a->data.non_resident.mapping_pairs_offset));
+	if (unlikely(ret)) {
+		if (ret != -ENOSPC) {
+			ntfs_error(vol->sb, "Failed to resize attribute "
+					"record for mft bitmap attribute.");
+			goto undo_alloc;
+		}
+		// TODO: Deal with this by moving this extent to a new mft
+		// record or by starting a new extent in a new mft record or by
+		// moving other attributes out of this mft record.
+		ntfs_error(vol->sb, "Not enough space in this mft record to "
+				"accomodate extended mft bitmap attribute "
+				"extent.  Cannot handle this yet.");
+		ret = -EOPNOTSUPP;
+		goto undo_alloc;
+	}
+	status.mp_rebuilt = 1;
+	/* Generate the mapping pairs array directly into the attr record. */
+	ret = ntfs_mapping_pairs_build(vol, (u8*)a +
+			le16_to_cpu(a->data.non_resident.mapping_pairs_offset),
+			mp_size, rl2, ll, NULL);
+	if (unlikely(ret)) {
+		ntfs_error(vol->sb, "Failed to build mapping pairs array for "
+				"mft bitmap attribute.");
+		goto undo_alloc;
+	}
+	/* Update the highest_vcn. */
+	a->data.non_resident.highest_vcn = cpu_to_sle64(rl[1].vcn - 1);
+	/*
+	 * We now have extended the mft bitmap allocated_size by one cluster.
+	 * Reflect this in the ntfs_inode structure and the attribute record.
+	 */
+	if (a->data.non_resident.lowest_vcn) {
 		/*
-		 * If the extent inode was not attached to the base inode, skip
-		 * this extent mft record.
+		 * We are not in the first attribute extent, switch to it, but
+		 * first ensure the changes will make it to disk later.
 		 */
-		if (!eni) {
-			up(&ni->extent_lock);
-			iput(vi);
-			continue;
+		flush_dcache_mft_record_page(ctx->ntfs_ino);
+		mark_mft_record_dirty(ctx->ntfs_ino);
+		ntfs_attr_reinit_search_ctx(ctx);
+		ret = ntfs_attr_lookup(mftbmp_ni->type, mftbmp_ni->name,
+				mftbmp_ni->name_len, CASE_SENSITIVE, 0, NULL,
+				0, ctx);
+		if (unlikely(ret)) {
+			ntfs_error(vol->sb, "Failed to find first attribute "
+					"extent of mft bitmap attribute.");
+			goto restore_undo_alloc;
+		}
+		a = ctx->attr;
+	}
+	mftbmp_ni->allocated_size += vol->cluster_size;
+	a->data.non_resident.allocated_size =
+			cpu_to_sle64(mftbmp_ni->allocated_size);
+	/* Ensure the changes make it to disk. */
+	flush_dcache_mft_record_page(ctx->ntfs_ino);
+	mark_mft_record_dirty(ctx->ntfs_ino);
+	ntfs_attr_put_search_ctx(ctx);
+	unmap_mft_record(mft_ni);
+	up_write(&mftbmp_ni->runlist.lock);
+	ntfs_debug("Done.");
+	return 0;
+restore_undo_alloc:
+	ntfs_attr_reinit_search_ctx(ctx);
+	if (ntfs_attr_lookup(mftbmp_ni->type, mftbmp_ni->name,
+			mftbmp_ni->name_len, CASE_SENSITIVE, rl[1].vcn, NULL,
+			0, ctx)) {
+		ntfs_error(vol->sb, "Failed to find last attribute extent of "
+				"mft bitmap attribute.%s", es);
+		mftbmp_ni->allocated_size += vol->cluster_size;
+		ntfs_attr_put_search_ctx(ctx);
+		unmap_mft_record(mft_ni);
+		up_write(&mftbmp_ni->runlist.lock);
+		/*
+		 * The only thing that is now wrong is ->allocated_size of the
+		 * base attribute extent which chkdsk should be able to fix.
+		 */
+		NVolSetErrors(vol);
+		return ret;
+	}
+	a = ctx->attr;
+	a->data.non_resident.highest_vcn = cpu_to_sle64(rl[1].vcn - 2);
+undo_alloc:
+	if (status.added_cluster) {
+		/* Truncate the last run in the runlist by one cluster. */
+		rl->length--;
+		rl[1].vcn--;
+	} else if (status.added_run) {
+		lcn = rl->lcn;
+		/* Remove the last run from the runlist. */
+		rl->lcn = rl[1].lcn;
+		rl->length = 0;
+	}
+	/* Deallocate the cluster. */
+	down_write(&vol->lcnbmp_lock);
+	if (ntfs_bitmap_clear_bit(vol->lcnbmp_ino, lcn)) {
+		ntfs_error(vol->sb, "Failed to free allocated cluster.%s", es);
+		NVolSetErrors(vol);
+	}
+	up_write(&vol->lcnbmp_lock);
+	if (status.mp_rebuilt) {
+		if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu(
+				a->data.non_resident.mapping_pairs_offset),
+				old_alen - le16_to_cpu(
+				a->data.non_resident.mapping_pairs_offset),
+				rl2, ll, NULL)) {
+			ntfs_error(vol->sb, "Failed to restore mapping pairs "
+					"array.%s", es);
+			NVolSetErrors(vol);
+		}
+		if (ntfs_attr_record_resize(ctx->mrec, a, old_alen)) {
+			ntfs_error(vol->sb, "Failed to restore attribute "
+					"record.%s", es);
+			NVolSetErrors(vol);
+		}
+		flush_dcache_mft_record_page(ctx->ntfs_ino);
+		mark_mft_record_dirty(ctx->ntfs_ino);
+	}
+	if (ctx)
+		ntfs_attr_put_search_ctx(ctx);
+	if (!IS_ERR(mrec))
+		unmap_mft_record(mft_ni);
+	up_write(&mftbmp_ni->runlist.lock);
+	return ret;
+}
+
+/**
+ * ntfs_mft_bitmap_extend_initialized_nolock - extend mftbmp initialized data
+ * @vol:	volume on which to extend the mft bitmap attribute
+ *
+ * Extend the initialized portion of the mft bitmap attribute on the ntfs
+ * volume @vol by 8 bytes.
+ *
+ * Note:  Only changes initialized_size and data_size, i.e. requires that
+ * allocated_size is big enough to fit the new initialized_size.
+ *
+ * Return 0 on success and -error on error.
+ *
+ * Locking: Caller must hold vol->mftbmp_lock for writing.
+ */
+static int ntfs_mft_bitmap_extend_initialized_nolock(ntfs_volume *vol)
+{
+	s64 old_data_size, old_initialized_size;
+	struct inode *mftbmp_vi;
+	ntfs_inode *mft_ni, *mftbmp_ni;
+	ntfs_attr_search_ctx *ctx;
+	MFT_RECORD *mrec;
+	ATTR_RECORD *a;
+	int ret;
+
+	ntfs_debug("Extending mft bitmap initiailized (and data) size.");
+	mft_ni = NTFS_I(vol->mft_ino);
+	mftbmp_vi = vol->mftbmp_ino;
+	mftbmp_ni = NTFS_I(mftbmp_vi);
+	/* Get the attribute record. */
+	mrec = map_mft_record(mft_ni);
+	if (IS_ERR(mrec)) {
+		ntfs_error(vol->sb, "Failed to map mft record.");
+		return PTR_ERR(mrec);
+	}
+	ctx = ntfs_attr_get_search_ctx(mft_ni, mrec);
+	if (unlikely(!ctx)) {
+		ntfs_error(vol->sb, "Failed to get search context.");
+		ret = -ENOMEM;
+		goto unm_err_out;
+	}
+	ret = ntfs_attr_lookup(mftbmp_ni->type, mftbmp_ni->name,
+			mftbmp_ni->name_len, CASE_SENSITIVE, 0, NULL, 0, ctx);
+	if (unlikely(ret)) {
+		ntfs_error(vol->sb, "Failed to find first attribute extent of "
+				"mft bitmap attribute.");
+		if (ret == -ENOENT)
+			ret = -EIO;
+		goto put_err_out;
+	}
+	a = ctx->attr;
+	old_data_size = mftbmp_vi->i_size;
+	old_initialized_size = mftbmp_ni->initialized_size;
+	/*
+	 * We can simply update the initialized_size before filling the space
+	 * with zeroes because the caller is holding the mft bitmap lock for
+	 * writing which ensures that no one else is trying to access the data.
+	 */
+	mftbmp_ni->initialized_size += 8;
+	a->data.non_resident.initialized_size =
+			cpu_to_sle64(mftbmp_ni->initialized_size);
+	if (mftbmp_ni->initialized_size > mftbmp_vi->i_size) {
+		mftbmp_vi->i_size = mftbmp_ni->initialized_size;
+		a->data.non_resident.data_size =
+				cpu_to_sle64(mftbmp_vi->i_size);
+	}
+	/* Ensure the changes make it to disk. */
+	flush_dcache_mft_record_page(ctx->ntfs_ino);
+	mark_mft_record_dirty(ctx->ntfs_ino);
+	ntfs_attr_put_search_ctx(ctx);
+	unmap_mft_record(mft_ni);
+	/* Initialize the mft bitmap attribute value with zeroes. */
+	ret = ntfs_attr_set(mftbmp_ni, old_initialized_size, 8, 0);
+	if (likely(!ret)) {
+		ntfs_debug("Done.  (Wrote eight initialized bytes to mft "
+				"bitmap.");
+		return 0;
+	}
+	ntfs_error(vol->sb, "Failed to write to mft bitmap.");
+	/* Try to recover from the error. */
+	mrec = map_mft_record(mft_ni);
+	if (IS_ERR(mrec)) {
+		ntfs_error(vol->sb, "Failed to map mft record.%s", es);
+		NVolSetErrors(vol);
+		return ret;
+	}
+	ctx = ntfs_attr_get_search_ctx(mft_ni, mrec);
+	if (unlikely(!ctx)) {
+		ntfs_error(vol->sb, "Failed to get search context.%s", es);
+		NVolSetErrors(vol);
+		goto unm_err_out;
+	}
+	if (ntfs_attr_lookup(mftbmp_ni->type, mftbmp_ni->name,
+			mftbmp_ni->name_len, CASE_SENSITIVE, 0, NULL, 0, ctx)) {
+		ntfs_error(vol->sb, "Failed to find first attribute extent of "
+				"mft bitmap attribute.%s", es);
+		NVolSetErrors(vol);
+put_err_out:
+		ntfs_attr_put_search_ctx(ctx);
+unm_err_out:
+		unmap_mft_record(mft_ni);
+		goto err_out;
+	}
+	a = ctx->attr;
+	mftbmp_ni->initialized_size = old_initialized_size;
+	a->data.non_resident.initialized_size =
+			cpu_to_sle64(old_initialized_size);
+	if (mftbmp_vi->i_size != old_data_size) {
+		mftbmp_vi->i_size = old_data_size;
+		a->data.non_resident.data_size = cpu_to_sle64(old_data_size);
+	}
+	flush_dcache_mft_record_page(ctx->ntfs_ino);
+	mark_mft_record_dirty(ctx->ntfs_ino);
+	ntfs_attr_put_search_ctx(ctx);
+	unmap_mft_record(mft_ni);
+	ntfs_debug("Restored status of mftbmp: allocated_size 0x%llx, "
+			"data_size 0x%llx, initialized_size 0x%llx.",
+			(long long)mftbmp_ni->allocated_size,
+			(long long)mftbmp_vi->i_size,
+			(long long)mftbmp_ni->initialized_size);
+err_out:
+	return ret;
+}
+
+/**
+ * ntfs_mft_data_extend_allocation_nolock - extend mft data attribute
+ * @vol:	volume on which to extend the mft data attribute
+ *
+ * Extend the mft data attribute on the ntfs volume @vol by 16 mft records
+ * worth of clusters or if not enough space for this by one mft record worth
+ * of clusters.
+ *
+ * Note:  Only changes allocated_size, i.e. does not touch initialized_size or
+ * data_size.
+ *
+ * Return 0 on success and -errno on error.
+ *
+ * Locking: - Caller must hold vol->mftbmp_lock for writing.
+ *	    - This function takes NTFS_I(vol->mft_ino)->runlist.lock for
+ *	      writing and releases it before returning.
+ *	    - This function calls functions which take vol->lcnbmp_lock for
+ *	      writing and release it before returning.
+ */
+static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
+{
+	LCN lcn;
+	VCN old_last_vcn;
+	s64 min_nr, nr, ll = 0;
+	ntfs_inode *mft_ni;
+	runlist_element *rl, *rl2;
+	ntfs_attr_search_ctx *ctx = NULL;
+	MFT_RECORD *mrec;
+	ATTR_RECORD *a = NULL;
+	int ret, mp_size;
+	u32 old_alen = 0;
+	BOOL mp_rebuilt = FALSE;
+
+	ntfs_debug("Extending mft data allocation.");
+	mft_ni = NTFS_I(vol->mft_ino);
+	/*
+	 * Determine the preferred allocation location, i.e. the last lcn of
+	 * the mft data attribute.  The allocated size of the mft data
+	 * attribute cannot be zero so we are ok to do this.
+	 * ntfs_find_vcn() returns the runlist locked on success.
+	 */
+	rl = ntfs_find_vcn(mft_ni, (mft_ni->allocated_size - 1) >>
+			vol->cluster_size_bits, TRUE);
+	if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) {
+		ntfs_error(vol->sb, "Failed to determine last allocated "
+				"cluster of mft data attribute.");
+		if (!IS_ERR(rl)) {
+			up_write(&mft_ni->runlist.lock);
+			ret = -EIO;
+		} else
+			ret = PTR_ERR(rl);
+		return ret;
+	}
+	lcn = rl->lcn + rl->length;
+	ntfs_debug("Last lcn of mft data attribute is 0x%llx.",
+			(long long)lcn);
+	/* Minimum allocation is one mft record worth of clusters. */
+	min_nr = vol->mft_record_size >> vol->cluster_size_bits;
+	if (!min_nr)
+		min_nr = 1;
+	/* Want to allocate 16 mft records worth of clusters. */
+	nr = vol->mft_record_size << 4 >> vol->cluster_size_bits;
+	if (!nr)
+		nr = min_nr;
+	/* Ensure we do not go above 2^32-1 mft records. */
+	if (unlikely((mft_ni->allocated_size +
+			(nr << vol->cluster_size_bits)) >>
+			vol->mft_record_size_bits >= (1ll << 32))) {
+		nr = min_nr;
+		if (unlikely((mft_ni->allocated_size +
+				(nr << vol->cluster_size_bits)) >>
+				vol->mft_record_size_bits >= (1ll << 32))) {
+			ntfs_warning(vol->sb, "Cannot allocate mft record "
+					"because the maximum number of inodes "
+					"(2^32) has already been reached.");
+			up_write(&mft_ni->runlist.lock);
+			return -ENOSPC;
+		}
+	}
+	ntfs_debug("Trying mft data allocation with %s cluster count %lli.",
+			nr > min_nr ? "default" : "minimal", (long long)nr);
+	old_last_vcn = rl[1].vcn;
+	do {
+		rl2 = ntfs_cluster_alloc(vol, old_last_vcn, nr, lcn, MFT_ZONE);
+		if (likely(!IS_ERR(rl2)))
+			break;
+		if (PTR_ERR(rl2) != -ENOSPC || nr == min_nr) {
+			ntfs_error(vol->sb, "Failed to allocate the minimal "
+					"number of clusters (%lli) for the "
+					"mft data attribute.", (long long)nr);
+			up_write(&mft_ni->runlist.lock);
+			return PTR_ERR(rl2);
 		}
 		/*
-		 * Found the extent inode corrsponding to this extent mft
-		 * record.  If it is dirty, no need to search further.
+		 * There is not enough space to do the allocation, but there
+		 * might be enough space to do a minimal allocation so try that
+		 * before failing.
 		 */
-		if (NInoDirty(eni)) {
-			up(&ni->extent_lock);
-			iput(vi);
-			is_dirty = TRUE;
+		nr = min_nr;
+		ntfs_debug("Retrying mft data allocation with minimal cluster "
+				"count %lli.", (long long)nr);
+	} while (1);
+	rl = ntfs_runlists_merge(mft_ni->runlist.rl, rl2);
+	if (IS_ERR(rl)) {
+		up_write(&mft_ni->runlist.lock);
+		ntfs_error(vol->sb, "Failed to merge runlists for mft data "
+				"attribute.");
+		if (ntfs_cluster_free_from_rl(vol, rl2)) {
+			ntfs_error(vol->sb, "Failed to dealocate clusters "
+					"from the mft data attribute.%s", es);
+			NVolSetErrors(vol);
+		}
+		ntfs_free(rl2);
+		return PTR_ERR(rl);
+	}
+	mft_ni->runlist.rl = rl;
+	ntfs_debug("Allocated %lli clusters.", nr);
+	/* Find the last run in the new runlist. */
+	for (; rl[1].length; rl++)
+		;
+	/* Update the attribute record as well. */
+	mrec = map_mft_record(mft_ni);
+	if (IS_ERR(mrec)) {
+		ntfs_error(vol->sb, "Failed to map mft record.");
+		ret = PTR_ERR(mrec);
+		goto undo_alloc;
+	}
+	ctx = ntfs_attr_get_search_ctx(mft_ni, mrec);
+	if (unlikely(!ctx)) {
+		ntfs_error(vol->sb, "Failed to get search context.");
+		ret = -ENOMEM;
+		goto undo_alloc;
+	}
+	ret = ntfs_attr_lookup(mft_ni->type, mft_ni->name, mft_ni->name_len,
+			CASE_SENSITIVE, rl[1].vcn, NULL, 0, ctx);
+	if (unlikely(ret)) {
+		ntfs_error(vol->sb, "Failed to find last attribute extent of "
+				"mft data attribute.");
+		if (ret == -ENOENT)
+			ret = -EIO;
+		goto undo_alloc;
+	}
+	a = ctx->attr;
+	ll = sle64_to_cpu(a->data.non_resident.lowest_vcn);
+	/* Search back for the previous last allocated cluster of mft bitmap. */
+	for (rl2 = rl; rl2 > mft_ni->runlist.rl; rl2--) {
+		if (ll >= rl2->vcn)
 			break;
+	}
+	BUG_ON(ll < rl2->vcn);
+	BUG_ON(ll >= rl2->vcn + rl2->length);
+	/* Get the size for the new mapping pairs array for this extent. */
+	mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll);
+	if (unlikely(mp_size <= 0)) {
+		ntfs_error(vol->sb, "Get size for mapping pairs failed for "
+				"mft data attribute extent.");
+		ret = mp_size;
+		if (!ret)
+			ret = -EIO;
+		goto undo_alloc;
+	}
+	/* Expand the attribute record if necessary. */
+	old_alen = le32_to_cpu(a->length);
+	ret = ntfs_attr_record_resize(ctx->mrec, a, mp_size +
+			le16_to_cpu(a->data.non_resident.mapping_pairs_offset));
+	if (unlikely(ret)) {
+		if (ret != -ENOSPC) {
+			ntfs_error(vol->sb, "Failed to resize attribute "
+					"record for mft data attribute.");
+			goto undo_alloc;
+		}
+		// TODO: Deal with this by moving this extent to a new mft
+		// record or by starting a new extent in a new mft record or by
+		// moving other attributes out of this mft record.
+		// Note: Use the special reserved mft records and ensure that
+		// this extent is not required to find the mft record in
+		// question.
+		ntfs_error(vol->sb, "Not enough space in this mft record to "
+				"accomodate extended mft data attribute "
+				"extent.  Cannot handle this yet.");
+		ret = -EOPNOTSUPP;
+		goto undo_alloc;
+	}
+	mp_rebuilt = TRUE;
+	/* Generate the mapping pairs array directly into the attr record. */
+	ret = ntfs_mapping_pairs_build(vol, (u8*)a +
+			le16_to_cpu(a->data.non_resident.mapping_pairs_offset),
+			mp_size, rl2, ll, NULL);
+	if (unlikely(ret)) {
+		ntfs_error(vol->sb, "Failed to build mapping pairs array of "
+				"mft data attribute.");
+		goto undo_alloc;
+	}
+	/* Update the highest_vcn. */
+	a->data.non_resident.highest_vcn = cpu_to_sle64(rl[1].vcn - 1);
+	/*
+	 * We now have extended the mft data allocated_size by nr clusters.
+	 * Reflect this in the ntfs_inode structure and the attribute record.
+	 * @rl is the last (non-terminator) runlist element of mft data
+	 * attribute.
+	 */
+	if (a->data.non_resident.lowest_vcn) {
+		/*
+		 * We are not in the first attribute extent, switch to it, but
+		 * first ensure the changes will make it to disk later.
+		 */
+		flush_dcache_mft_record_page(ctx->ntfs_ino);
+		mark_mft_record_dirty(ctx->ntfs_ino);
+		ntfs_attr_reinit_search_ctx(ctx);
+		ret = ntfs_attr_lookup(mft_ni->type, mft_ni->name,
+				mft_ni->name_len, CASE_SENSITIVE, 0, NULL, 0,
+				ctx);
+		if (unlikely(ret)) {
+			ntfs_error(vol->sb, "Failed to find first attribute "
+					"extent of mft data attribute.");
+			goto restore_undo_alloc;
+		}
+		a = ctx->attr;
+	}
+	mft_ni->allocated_size += nr << vol->cluster_size_bits;
+	a->data.non_resident.allocated_size =
+			cpu_to_sle64(mft_ni->allocated_size);
+	/* Ensure the changes make it to disk. */
+	flush_dcache_mft_record_page(ctx->ntfs_ino);
+	mark_mft_record_dirty(ctx->ntfs_ino);
+	ntfs_attr_put_search_ctx(ctx);
+	unmap_mft_record(mft_ni);
+	up_write(&mft_ni->runlist.lock);
+	ntfs_debug("Done.");
+	return 0;
+restore_undo_alloc:
+	ntfs_attr_reinit_search_ctx(ctx);
+	if (ntfs_attr_lookup(mft_ni->type, mft_ni->name, mft_ni->name_len,
+			CASE_SENSITIVE, rl[1].vcn, NULL, 0, ctx)) {
+		ntfs_error(vol->sb, "Failed to find last attribute extent of "
+				"mft data attribute.%s", es);
+		mft_ni->allocated_size += nr << vol->cluster_size_bits;
+		ntfs_attr_put_search_ctx(ctx);
+		unmap_mft_record(mft_ni);
+		up_write(&mft_ni->runlist.lock);
+		/*
+		 * The only thing that is now wrong is ->allocated_size of the
+		 * base attribute extent which chkdsk should be able to fix.
+		 */
+		NVolSetErrors(vol);
+		return ret;
+	}
+	a = ctx->attr;
+	a->data.non_resident.highest_vcn = cpu_to_sle64(old_last_vcn - 1);
+undo_alloc:
+	if (ntfs_cluster_free(vol->mft_ino, old_last_vcn, -1) < 0) {
+		ntfs_error(vol->sb, "Failed to free clusters from mft data "
+				"attribute.%s", es);
+		NVolSetErrors(vol);
+	}
+	if (ntfs_rl_truncate_nolock(vol, &mft_ni->runlist, old_last_vcn)) {
+		ntfs_error(vol->sb, "Failed to truncate mft data attribute "
+				"runlist.%s", es);
+		NVolSetErrors(vol);
+	}
+	if (mp_rebuilt) {
+		if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu(
+				a->data.non_resident.mapping_pairs_offset),
+				old_alen - le16_to_cpu(
+				a->data.non_resident.mapping_pairs_offset),
+				rl2, ll, NULL)) {
+			ntfs_error(vol->sb, "Failed to restore mapping pairs "
+					"array.%s", es);
+			NVolSetErrors(vol);
+		}
+		if (ntfs_attr_record_resize(ctx->mrec, a, old_alen)) {
+			ntfs_error(vol->sb, "Failed to restore attribute "
+					"record.%s", es);
+			NVolSetErrors(vol);
+		}
+		flush_dcache_mft_record_page(ctx->ntfs_ino);
+		mark_mft_record_dirty(ctx->ntfs_ino);
+	}
+	if (ctx)
+		ntfs_attr_put_search_ctx(ctx);
+	if (!IS_ERR(mrec))
+		unmap_mft_record(mft_ni);
+	up_write(&mft_ni->runlist.lock);
+	return ret;
+}
+
+/**
+ * ntfs_mft_record_layout - layout an mft record into a memory buffer
+ * @vol:	volume to which the mft record will belong
+ * @mft_no:	mft reference specifying the mft record number
+ * @m:		destination buffer of size >= @vol->mft_record_size bytes
+ *
+ * Layout an empty, unused mft record with the mft record number @mft_no into
+ * the buffer @m.  The volume @vol is needed because the mft record structure
+ * was modified in NTFS 3.1 so we need to know which volume version this mft
+ * record will be used on.
+ *
+ * Return 0 on success and -errno on error.
+ */
+static int ntfs_mft_record_layout(const ntfs_volume *vol, const s64 mft_no,
+		MFT_RECORD *m)
+{
+	ATTR_RECORD *a;
+
+	ntfs_debug("Entering for mft record 0x%llx.", (long long)mft_no);
+	if (mft_no >= (1ll << 32)) {
+		ntfs_error(vol->sb, "Mft record number 0x%llx exceeds "
+				"maximum of 2^32.", (long long)mft_no);
+		return -ERANGE;
+	}
+	/* Start by clearing the whole mft record to gives us a clean slate. */
+	memset(m, 0, vol->mft_record_size);
+	/* Aligned to 2-byte boundary. */
+	if (vol->major_ver < 3 || (vol->major_ver == 3 && !vol->minor_ver))
+		m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD_OLD) + 1) & ~1);
+	else {
+		m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1);
+		/*
+		 * Set the NTFS 3.1+ specific fields while we know that the
+		 * volume version is 3.1+.
+		 */
+		m->reserved = 0;
+		m->mft_record_number = cpu_to_le32((u32)mft_no);
+	}
+	m->magic = magic_FILE;
+	if (vol->mft_record_size >= NTFS_BLOCK_SIZE)
+		m->usa_count = cpu_to_le16(vol->mft_record_size /
+				NTFS_BLOCK_SIZE + 1);
+	else {
+		m->usa_count = cpu_to_le16(1);
+		ntfs_warning(vol->sb, "Sector size is bigger than mft record "
+				"size.  Setting usa_count to 1.  If chkdsk "
+				"reports this as corruption, please email "
+				"linux-ntfs-dev@lists.sourceforge.net stating "
+				"that you saw this message and that the "
+				"modified file system created was corrupt.  "
+				"Thank you.");
+	}
+	/* Set the update sequence number to 1. */
+	*(le16*)((u8*)m + le16_to_cpu(m->usa_ofs)) = cpu_to_le16(1);
+	m->lsn = 0;
+	m->sequence_number = cpu_to_le16(1);
+	m->link_count = 0;
+	/*
+	 * Place the attributes straight after the update sequence array,
+	 * aligned to 8-byte boundary.
+	 */
+	m->attrs_offset = cpu_to_le16((le16_to_cpu(m->usa_ofs) +
+			(le16_to_cpu(m->usa_count) << 1) + 7) & ~7);
+	m->flags = 0;
+	/*
+	 * Using attrs_offset plus eight bytes (for the termination attribute).
+	 * attrs_offset is already aligned to 8-byte boundary, so no need to
+	 * align again.
+	 */
+	m->bytes_in_use = cpu_to_le32(le16_to_cpu(m->attrs_offset) + 8);
+	m->bytes_allocated = cpu_to_le32(vol->mft_record_size);
+	m->base_mft_record = 0;
+	m->next_attr_instance = 0;
+	/* Add the termination attribute. */
+	a = (ATTR_RECORD*)((u8*)m + le16_to_cpu(m->attrs_offset));
+	a->type = AT_END;
+	a->length = 0;
+	ntfs_debug("Done.");
+	return 0;
+}
+
+/**
+ * ntfs_mft_record_format - format an mft record on an ntfs volume
+ * @vol:	volume on which to format the mft record
+ * @mft_no:	mft record number to format
+ *
+ * Format the mft record @mft_no in $MFT/$DATA, i.e. lay out an empty, unused
+ * mft record into the appropriate place of the mft data attribute.  This is
+ * used when extending the mft data attribute.
+ *
+ * Return 0 on success and -errno on error.
+ */
+static int ntfs_mft_record_format(const ntfs_volume *vol, const s64 mft_no)
+{
+	struct inode *mft_vi = vol->mft_ino;
+	struct page *page;
+	MFT_RECORD *m;
+	pgoff_t index, end_index;
+	unsigned int ofs;
+	int err;
+
+	ntfs_debug("Entering for mft record 0x%llx.", (long long)mft_no);
+	/*
+	 * The index into the page cache and the offset within the page cache
+	 * page of the wanted mft record.
+	 */
+	index = mft_no << vol->mft_record_size_bits >> PAGE_CACHE_SHIFT;
+	ofs = (mft_no << vol->mft_record_size_bits) & ~PAGE_CACHE_MASK;
+	/* The maximum valid index into the page cache for $MFT's data. */
+	end_index = mft_vi->i_size >> PAGE_CACHE_SHIFT;
+	if (unlikely(index >= end_index)) {
+		if (unlikely(index > end_index || ofs + vol->mft_record_size >=
+				(mft_vi->i_size & ~PAGE_CACHE_MASK))) {
+			ntfs_error(vol->sb, "Tried to format non-existing mft "
+					"record 0x%llx.", (long long)mft_no);
+			return -ENOENT;
 		}
-		/* The extent inode is not dirty, so do the next record. */
-		up(&ni->extent_lock);
-		iput(vi);
 	}
-	kunmap(page);
-	/* If a dirty mft record was found, redirty the page. */
-	if (is_dirty) {
-		ntfs_debug("Inode 0x%lx is dirty.  Redirtying the page "
-				"starting at inode 0x%lx.", mft_no,
-				page->index << (PAGE_CACHE_SHIFT -
-				vol->mft_record_size_bits));
-		redirty_page_for_writepage(wbc, page);
+	/* Read, map, and pin the page containing the mft record. */
+	page = ntfs_map_page(mft_vi->i_mapping, index);
+	if (unlikely(IS_ERR(page))) {
+		ntfs_error(vol->sb, "Failed to map page containing mft record "
+				"to format 0x%llx.", (long long)mft_no);
+		return PTR_ERR(page);
+	}
+	lock_page(page);
+	BUG_ON(!PageUptodate(page));
+	ClearPageUptodate(page);
+	m = (MFT_RECORD*)((u8*)page_address(page) + ofs);
+	err = ntfs_mft_record_layout(vol, mft_no, m);
+	if (unlikely(err)) {
+		ntfs_error(vol->sb, "Failed to layout mft record 0x%llx.",
+				(long long)mft_no);
+		SetPageUptodate(page);
 		unlock_page(page);
+		ntfs_unmap_page(page);
+		return err;
+	}
+	flush_dcache_page(page);
+	SetPageUptodate(page);
+	unlock_page(page);
+	/*
+	 * Make sure the mft record is written out to disk.  We could use
+	 * ilookup5() to check if an inode is in icache and so on but this is
+	 * unnecessary as ntfs_writepage() will write the dirty record anyway.
+	 */
+	mark_ntfs_record_dirty(page, ofs);
+	ntfs_unmap_page(page);
+	ntfs_debug("Done.");
+	return 0;
+}
+
+/**
+ * ntfs_mft_record_alloc - allocate an mft record on an ntfs volume
+ * @vol:	[IN]  volume on which to allocate the mft record
+ * @mode:	[IN]  mode if want a file or directory, i.e. base inode or 0
+ * @base_ni:	[IN]  open base inode if allocating an extent mft record or NULL
+ * @mrec:	[OUT] on successful return this is the mapped mft record
+ *
+ * Allocate an mft record in $MFT/$DATA of an open ntfs volume @vol.
+ *
+ * If @base_ni is NULL make the mft record a base mft record, i.e. a file or
+ * direvctory inode, and allocate it at the default allocator position.  In
+ * this case @mode is the file mode as given to us by the caller.  We in
+ * particular use @mode to distinguish whether a file or a directory is being
+ * created (S_IFDIR(mode) and S_IFREG(mode), respectively).
+ *
+ * If @base_ni is not NULL make the allocated mft record an extent record,
+ * allocate it starting at the mft record after the base mft record and attach
+ * the allocated and opened ntfs inode to the base inode @base_ni.  In this
+ * case @mode must be 0 as it is meaningless for extent inodes.
+ *
+ * You need to check the return value with IS_ERR().  If false, the function
+ * was successful and the return value is the now opened ntfs inode of the
+ * allocated mft record.  *@mrec is then set to the allocated, mapped, pinned,
+ * and locked mft record.  If IS_ERR() is true, the function failed and the
+ * error code is obtained from PTR_ERR(return value).  *@mrec is undefined in
+ * this case.
+ *
+ * Allocation strategy:
+ *
+ * To find a free mft record, we scan the mft bitmap for a zero bit.  To
+ * optimize this we start scanning at the place specified by @base_ni or if
+ * @base_ni is NULL we start where we last stopped and we perform wrap around
+ * when we reach the end.  Note, we do not try to allocate mft records below
+ * number 24 because numbers 0 to 15 are the defined system files anyway and 16
+ * to 24 are special in that they are used for storing extension mft records
+ * for the $DATA attribute of $MFT.  This is required to avoid the possibility
+ * of creating a runlist with a circular dependency which once written to disk
+ * can never be read in again.  Windows will only use records 16 to 24 for
+ * normal files if the volume is completely out of space.  We never use them
+ * which means that when the volume is really out of space we cannot create any
+ * more files while Windows can still create up to 8 small files.  We can start
+ * doing this at some later time, it does not matter much for now.
+ *
+ * When scanning the mft bitmap, we only search up to the last allocated mft
+ * record.  If there are no free records left in the range 24 to number of
+ * allocated mft records, then we extend the $MFT/$DATA attribute in order to
+ * create free mft records.  We extend the allocated size of $MFT/$DATA by 16
+ * records at a time or one cluster, if cluster size is above 16kiB.  If there
+ * is not sufficient space to do this, we try to extend by a single mft record
+ * or one cluster, if cluster size is above the mft record size.
+ *
+ * No matter how many mft records we allocate, we initialize only the first
+ * allocated mft record, incrementing mft data size and initialized size
+ * accordingly, open an ntfs_inode for it and return it to the caller, unless
+ * there are less than 24 mft records, in which case we allocate and initialize
+ * mft records until we reach record 24 which we consider as the first free mft
+ * record for use by normal files.
+ *
+ * If during any stage we overflow the initialized data in the mft bitmap, we
+ * extend the initialized size (and data size) by 8 bytes, allocating another
+ * cluster if required.  The bitmap data size has to be at least equal to the
+ * number of mft records in the mft, but it can be bigger, in which case the
+ * superflous bits are padded with zeroes.
+ *
+ * Thus, when we return successfully (IS_ERR() is false), we will have:
+ *	- initialized / extended the mft bitmap if necessary,
+ *	- initialized / extended the mft data if necessary,
+ *	- set the bit corresponding to the mft record being allocated in the
+ *	  mft bitmap,
+ *	- opened an ntfs_inode for the allocated mft record, and we will have
+ *	- returned the ntfs_inode as well as the allocated mapped, pinned, and
+ *	  locked mft record.
+ *
+ * On error, the volume will be left in a consistent state and no record will
+ * be allocated.  If rolling back a partial operation fails, we may leave some
+ * inconsistent metadata in which case we set NVolErrors() so the volume is
+ * left dirty when unmounted.
+ *
+ * Note, this function cannot make use of most of the normal functions, like
+ * for example for attribute resizing, etc, because when the run list overflows
+ * the base mft record and an attribute list is used, it is very important that
+ * the extension mft records used to store the $DATA attribute of $MFT can be
+ * reached without having to read the information contained inside them, as
+ * this would make it impossible to find them in the first place after the
+ * volume is unmounted.  $MFT/$BITMAP probably does not need to follow this
+ * rule because the bitmap is not essential for finding the mft records, but on
+ * the other hand, handling the bitmap in this special way would make life
+ * easier because otherwise there might be circular invocations of functions
+ * when reading the bitmap.
+ */
+ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode,
+		ntfs_inode *base_ni, MFT_RECORD **mrec)
+{
+	s64 ll, bit, old_data_initialized, old_data_size;
+	struct inode *vi;
+	struct page *page;
+	ntfs_inode *mft_ni, *mftbmp_ni, *ni;
+	ntfs_attr_search_ctx *ctx;
+	MFT_RECORD *m;
+	ATTR_RECORD *a;
+	pgoff_t index;
+	unsigned int ofs;
+	int err;
+	le16 seq_no, usn;
+	BOOL record_formatted = FALSE;
+
+	if (base_ni) {
+		ntfs_debug("Entering (allocating an extent mft record for "
+				"base mft record 0x%llx).",
+				(long long)base_ni->mft_no);
+		/* @mode and @base_ni are mutually exclusive. */
+		BUG_ON(mode);
+	} else
+		ntfs_debug("Entering (allocating a base mft record).");
+	if (mode) {
+		/* @mode and @base_ni are mutually exclusive. */
+		BUG_ON(base_ni);
+		/* We only support creation of normal files and directories. */
+		if (!S_ISREG(mode) && !S_ISDIR(mode))
+			return ERR_PTR(-EOPNOTSUPP);
+	}
+	BUG_ON(!mrec);
+	mft_ni = NTFS_I(vol->mft_ino);
+	mftbmp_ni = NTFS_I(vol->mftbmp_ino);
+	down_write(&vol->mftbmp_lock);
+	bit = ntfs_mft_bitmap_find_and_alloc_free_rec_nolock(vol, base_ni);
+	if (bit >= 0) {
+		ntfs_debug("Found and allocated free record (#1), bit 0x%llx.",
+				(long long)bit);
+		goto have_alloc_rec;
+	}
+	if (bit != -ENOSPC) {
+		up_write(&vol->mftbmp_lock);
+		return ERR_PTR(bit);
+	}
+	/*
+	 * No free mft records left.  If the mft bitmap already covers more
+	 * than the currently used mft records, the next records are all free,
+	 * so we can simply allocate the first unused mft record.
+	 * Note: We also have to make sure that the mft bitmap at least covers
+	 * the first 24 mft records as they are special and whilst they may not
+	 * be in use, we do not allocate from them.
+	 */
+	ll = mft_ni->initialized_size >> vol->mft_record_size_bits;
+	if (mftbmp_ni->initialized_size << 3 > ll &&
+			mftbmp_ni->initialized_size > 3) {
+		bit = ll;
+		if (bit < 24)
+			bit = 24;
+		if (unlikely(bit >= (1ll << 32)))
+			goto max_err_out;
+		ntfs_debug("Found free record (#2), bit 0x%llx.",
+				(long long)bit);
+		goto found_free_rec;
+	}
+	/*
+	 * The mft bitmap needs to be expanded until it covers the first unused
+	 * mft record that we can allocate.
+	 * Note: The smallest mft record we allocate is mft record 24.
+	 */
+	bit = mftbmp_ni->initialized_size << 3;
+	if (unlikely(bit >= (1ll << 32)))
+		goto max_err_out;
+	ntfs_debug("Status of mftbmp before extension: allocated_size 0x%llx, "
+			"data_size 0x%llx, initialized_size 0x%llx.",
+			(long long)mftbmp_ni->allocated_size,
+			(long long)vol->mftbmp_ino->i_size,
+			(long long)mftbmp_ni->initialized_size);
+	if (mftbmp_ni->initialized_size + 8 > mftbmp_ni->allocated_size) {
+		/* Need to extend bitmap by one more cluster. */
+		ntfs_debug("mftbmp: initialized_size + 8 > allocated_size.");
+		err = ntfs_mft_bitmap_extend_allocation_nolock(vol);
+		if (unlikely(err)) {
+			up_write(&vol->mftbmp_lock);
+			goto err_out;
+		}
+		ntfs_debug("Status of mftbmp after allocation extension: "
+				"allocated_size 0x%llx, data_size 0x%llx, "
+				"initialized_size 0x%llx.",
+				(long long)mftbmp_ni->allocated_size,
+				(long long)vol->mftbmp_ino->i_size,
+				(long long)mftbmp_ni->initialized_size);
+	}
+	/*
+	 * We now have sufficient allocated space, extend the initialized_size
+	 * as well as the data_size if necessary and fill the new space with
+	 * zeroes.
+	 */
+	err = ntfs_mft_bitmap_extend_initialized_nolock(vol);
+	if (unlikely(err)) {
+		up_write(&vol->mftbmp_lock);
+		goto err_out;
+	}
+	ntfs_debug("Status of mftbmp after initialized extention: "
+			"allocated_size 0x%llx, data_size 0x%llx, "
+			"initialized_size 0x%llx.",
+			(long long)mftbmp_ni->allocated_size,
+			(long long)vol->mftbmp_ino->i_size,
+			(long long)mftbmp_ni->initialized_size);
+	ntfs_debug("Found free record (#3), bit 0x%llx.", (long long)bit);
+found_free_rec:
+	/* @bit is the found free mft record, allocate it in the mft bitmap. */
+	ntfs_debug("At found_free_rec.");
+	err = ntfs_bitmap_set_bit(vol->mftbmp_ino, bit);
+	if (unlikely(err)) {
+		ntfs_error(vol->sb, "Failed to allocate bit in mft bitmap.");
+		up_write(&vol->mftbmp_lock);
+		goto err_out;
+	}
+	ntfs_debug("Set bit 0x%llx in mft bitmap.", (long long)bit);
+have_alloc_rec:
+	/*
+	 * The mft bitmap is now uptodate.  Deal with mft data attribute now.
+	 * Note, we keep hold of the mft bitmap lock for writing until all
+	 * modifications to the mft data attribute are complete, too, as they
+	 * will impact decisions for mft bitmap and mft record allocation done
+	 * by a parallel allocation and if the lock is not maintained a
+	 * parallel allocation could allocate the same mft record as this one.
+	 */
+	ll = (bit + 1) << vol->mft_record_size_bits;
+	if (ll <= mft_ni->initialized_size) {
+		ntfs_debug("Allocated mft record already initialized.");
+		goto mft_rec_already_initialized;
+	}
+	ntfs_debug("Initializing allocated mft record.");
+	/*
+	 * The mft record is outside the initialized data.  Extend the mft data
+	 * attribute until it covers the allocated record.  The loop is only
+	 * actually traversed more than once when a freshly formatted volume is
+	 * first written to so it optimizes away nicely in the common case.
+	 */
+	ntfs_debug("Status of mft data before extension: "
+			"allocated_size 0x%llx, data_size 0x%llx, "
+			"initialized_size 0x%llx.",
+			(long long)mft_ni->allocated_size,
+			(long long)vol->mft_ino->i_size,
+			(long long)mft_ni->initialized_size);
+	while (ll > mft_ni->allocated_size) {
+		err = ntfs_mft_data_extend_allocation_nolock(vol);
+		if (unlikely(err)) {
+			ntfs_error(vol->sb, "Failed to extend mft data "
+					"allocation.");
+			goto undo_mftbmp_alloc_nolock;
+		}
+		ntfs_debug("Status of mft data after allocation extension: "
+				"allocated_size 0x%llx, data_size 0x%llx, "
+				"initialized_size 0x%llx.",
+				(long long)mft_ni->allocated_size,
+				(long long)vol->mft_ino->i_size,
+				(long long)mft_ni->initialized_size);
+	}
+	/*
+	 * Extend mft data initialized size (and data size of course) to reach
+	 * the allocated mft record, formatting the mft records allong the way.
+	 * Note: We only modify the ntfs_inode structure as that is all that is
+	 * needed by ntfs_mft_record_format().  We will update the attribute
+	 * record itself in one fell swoop later on.
+	 */
+	old_data_initialized = mft_ni->initialized_size;
+	old_data_size = vol->mft_ino->i_size;
+	while (ll > mft_ni->initialized_size) {
+		s64 new_initialized_size, mft_no;
+		
+		new_initialized_size = mft_ni->initialized_size +
+				vol->mft_record_size;
+		mft_no = mft_ni->initialized_size >> vol->mft_record_size_bits;
+		if (new_initialized_size > vol->mft_ino->i_size)
+			vol->mft_ino->i_size = new_initialized_size;
+		ntfs_debug("Initializing mft record 0x%llx.",
+				(long long)mft_no);
+		err = ntfs_mft_record_format(vol, mft_no);
+		if (unlikely(err)) {
+			ntfs_error(vol->sb, "Failed to format mft record.");
+			goto undo_data_init;
+		}
+		mft_ni->initialized_size = new_initialized_size;
+	}
+	record_formatted = TRUE;
+	/* Update the mft data attribute record to reflect the new sizes. */
+	m = map_mft_record(mft_ni);
+	if (IS_ERR(m)) {
+		ntfs_error(vol->sb, "Failed to map mft record.");
+		err = PTR_ERR(m);
+		goto undo_data_init;
+	}
+	ctx = ntfs_attr_get_search_ctx(mft_ni, m);
+	if (unlikely(!ctx)) {
+		ntfs_error(vol->sb, "Failed to get search context.");
+		err = -ENOMEM;
+		unmap_mft_record(mft_ni);
+		goto undo_data_init;
+	}
+	err = ntfs_attr_lookup(mft_ni->type, mft_ni->name, mft_ni->name_len,
+			CASE_SENSITIVE, 0, NULL, 0, ctx);
+	if (unlikely(err)) {
+		ntfs_error(vol->sb, "Failed to find first attribute extent of "
+				"mft data attribute.");
+		ntfs_attr_put_search_ctx(ctx);
+		unmap_mft_record(mft_ni);
+		goto undo_data_init;
+	}
+	a = ctx->attr;
+	a->data.non_resident.initialized_size =
+			cpu_to_sle64(mft_ni->initialized_size);
+	a->data.non_resident.data_size = cpu_to_sle64(vol->mft_ino->i_size);
+	/* Ensure the changes make it to disk. */
+	flush_dcache_mft_record_page(ctx->ntfs_ino);
+	mark_mft_record_dirty(ctx->ntfs_ino);
+	ntfs_attr_put_search_ctx(ctx);
+	unmap_mft_record(mft_ni);
+	ntfs_debug("Status of mft data after mft record initialization: "
+			"allocated_size 0x%llx, data_size 0x%llx, "
+			"initialized_size 0x%llx.",
+			(long long)mft_ni->allocated_size,
+			(long long)vol->mft_ino->i_size,
+			(long long)mft_ni->initialized_size);
+	BUG_ON(vol->mft_ino->i_size > mft_ni->allocated_size);
+	BUG_ON(mft_ni->initialized_size > vol->mft_ino->i_size);
+mft_rec_already_initialized:
+	/*
+	 * We can finally drop the mft bitmap lock as the mft data attribute
+	 * has been fully updated.  The only disparity left is that the
+	 * allocated mft record still needs to be marked as in use to match the
+	 * set bit in the mft bitmap but this is actually not a problem since
+	 * this mft record is not referenced from anywhere yet and the fact
+	 * that it is allocated in the mft bitmap means that no-one will try to
+	 * allocate it either.
+	 */
+	up_write(&vol->mftbmp_lock);
+	/*
+	 * We now have allocated and initialized the mft record.  Calculate the
+	 * index of and the offset within the page cache page the record is in.
+	 */
+	index = bit << vol->mft_record_size_bits >> PAGE_CACHE_SHIFT;
+	ofs = (bit << vol->mft_record_size_bits) & ~PAGE_CACHE_MASK;
+	/* Read, map, and pin the page containing the mft record. */
+	page = ntfs_map_page(vol->mft_ino->i_mapping, index);
+	if (unlikely(IS_ERR(page))) {
+		ntfs_error(vol->sb, "Failed to map page containing allocated "
+				"mft record 0x%llx.", (long long)bit);
+		err = PTR_ERR(page);
+		goto undo_mftbmp_alloc;
+	}
+	lock_page(page);
+	BUG_ON(!PageUptodate(page));
+	ClearPageUptodate(page);
+	m = (MFT_RECORD*)((u8*)page_address(page) + ofs);
+	/* If we just formatted the mft record no need to do it again. */
+	if (!record_formatted) {
+		/* Sanity check that the mft record is really not in use. */
+		if (ntfs_is_file_record(m->magic) &&
+				(m->flags & MFT_RECORD_IN_USE)) {
+			ntfs_error(vol->sb, "Mft record 0x%llx was marked "
+					"free in mft bitmap but is marked "
+					"used itself.  Corrupt filesystem.  "
+					"Unmount and run chkdsk.",
+					(long long)bit);
+			err = -EIO;
+			SetPageUptodate(page);
+			unlock_page(page);
+			ntfs_unmap_page(page);
+			NVolSetErrors(vol);
+			goto undo_mftbmp_alloc;
+		}
+		/*
+		 * We need to (re-)format the mft record, preserving the
+		 * sequence number if it is not zero as well as the update
+		 * sequence number if it is not zero or -1 (0xffff).  This
+		 * means we do not need to care whether or not something went
+		 * wrong with the previous mft record.
+		 */
+		seq_no = m->sequence_number;
+		usn = *(le16*)((u8*)m + le16_to_cpu(m->usa_ofs));
+		err = ntfs_mft_record_layout(vol, bit, m);
+		if (unlikely(err)) {
+			ntfs_error(vol->sb, "Failed to layout allocated mft "
+					"record 0x%llx.", (long long)bit);
+			SetPageUptodate(page);
+			unlock_page(page);
+			ntfs_unmap_page(page);
+			goto undo_mftbmp_alloc;
+		}
+		if (seq_no)
+			m->sequence_number = seq_no;
+		if (usn && le16_to_cpu(usn) != 0xffff)
+			*(le16*)((u8*)m + le16_to_cpu(m->usa_ofs)) = usn;
+	}
+	/* Set the mft record itself in use. */
+	m->flags |= MFT_RECORD_IN_USE;
+	if (S_ISDIR(mode))
+		m->flags |= MFT_RECORD_IS_DIRECTORY;
+	flush_dcache_page(page);
+	SetPageUptodate(page);
+	if (base_ni) {
+		/*
+		 * Setup the base mft record in the extent mft record.  This
+		 * completes initialization of the allocated extent mft record
+		 * and we can simply use it with map_extent_mft_record().
+		 */
+		m->base_mft_record = MK_LE_MREF(base_ni->mft_no,
+				base_ni->seq_no);
+		/*
+		 * Allocate an extent inode structure for the new mft record,
+		 * attach it to the base inode @base_ni and map, pin, and lock
+		 * its, i.e. the allocated, mft record.
+		 */
+		m = map_extent_mft_record(base_ni, bit, &ni);
+		if (IS_ERR(m)) {
+			ntfs_error(vol->sb, "Failed to map allocated extent "
+					"mft record 0x%llx.", (long long)bit);
+			err = PTR_ERR(m);
+			/* Set the mft record itself not in use. */
+			m->flags &= cpu_to_le16(
+					~le16_to_cpu(MFT_RECORD_IN_USE));
+			flush_dcache_page(page);
+			/* Make sure the mft record is written out to disk. */
+			mark_ntfs_record_dirty(page, ofs);
+			unlock_page(page);
+			ntfs_unmap_page(page);
+			goto undo_mftbmp_alloc;
+		}
+		/*
+		 * Make sure the allocated mft record is written out to disk.
+		 * No need to set the inode dirty because the caller is going
+		 * to do that anyway after finishing with the new extent mft
+		 * record (e.g. at a minimum a new attribute will be added to
+		 * the mft record.
+		 */
+		mark_ntfs_record_dirty(page, ofs);
+		unlock_page(page);
+		/*
+		 * Need to unmap the page since map_extent_mft_record() mapped
+		 * it as well so we have it mapped twice at the moment.
+		 */
+		ntfs_unmap_page(page);
 	} else {
 		/*
-		 * Keep the VM happy.  This must be done otherwise the
-		 * radix-tree tag PAGECACHE_TAG_DIRTY remains set even though
-		 * the page is clean.
+		 * Allocate a new VFS inode and set it up.  NOTE: @vi->i_nlink
+		 * is set to 1 but the mft record->link_count is 0.  The caller
+		 * needs to bear this in mind.
+		 */
+		vi = new_inode(vol->sb);
+		if (unlikely(!vi)) {
+			err = -ENOMEM;
+			/* Set the mft record itself not in use. */
+			m->flags &= cpu_to_le16(
+					~le16_to_cpu(MFT_RECORD_IN_USE));
+			flush_dcache_page(page);
+			/* Make sure the mft record is written out to disk. */
+			mark_ntfs_record_dirty(page, ofs);
+			unlock_page(page);
+			ntfs_unmap_page(page);
+			goto undo_mftbmp_alloc;
+		}
+		vi->i_ino = bit;
+		/*
+		 * This is the optimal IO size (for stat), not the fs block
+		 * size.
+		 */
+		vi->i_blksize = PAGE_CACHE_SIZE;
+		/*
+		 * This is for checking whether an inode has changed w.r.t. a
+		 * file so that the file can be updated if necessary (compare
+		 * with f_version).
 		 */
-		BUG_ON(PageWriteback(page));
-		set_page_writeback(page);
+		vi->i_version = 1;
+
+		/* The owner and group come from the ntfs volume. */
+		vi->i_uid = vol->uid;
+		vi->i_gid = vol->gid;
+
+		/* Initialize the ntfs specific part of @vi. */
+		ntfs_init_big_inode(vi);
+		ni = NTFS_I(vi);
+		/*
+		 * Set the appropriate mode, attribute type, and name.  For
+		 * directories, also setup the index values to the defaults.
+		 */
+		if (S_ISDIR(mode)) {
+			vi->i_mode = S_IFDIR | S_IRWXUGO;
+			vi->i_mode &= ~vol->dmask;
+
+			NInoSetMstProtected(ni);
+			ni->type = AT_INDEX_ALLOCATION;
+			ni->name = I30;
+			ni->name_len = 4;
+
+			ni->itype.index.block_size = 4096;
+			ni->itype.index.block_size_bits = generic_ffs(4096) - 1;
+			ni->itype.index.collation_rule = COLLATION_FILE_NAME;
+			if (vol->cluster_size <= ni->itype.index.block_size) {
+				ni->itype.index.vcn_size = vol->cluster_size;
+				ni->itype.index.vcn_size_bits =
+						vol->cluster_size_bits;
+			} else {
+				ni->itype.index.vcn_size = vol->sector_size;
+				ni->itype.index.vcn_size_bits =
+						vol->sector_size_bits;
+			}
+		} else {
+			vi->i_mode = S_IFREG | S_IRWXUGO;
+			vi->i_mode &= ~vol->fmask;
+
+			ni->type = AT_DATA;
+			ni->name = NULL;
+			ni->name_len = 0;
+		}
+		if (IS_RDONLY(vi))
+			vi->i_mode &= ~S_IWUGO;
+
+		/* Set the inode times to the current time. */
+		vi->i_atime = vi->i_mtime = vi->i_ctime = current_kernel_time();
+		/*
+		 * Set the file size to 0, the ntfs inode sizes are set to 0 by
+		 * the call to ntfs_init_big_inode() below.
+		 */
+		vi->i_size = 0;
+		vi->i_blocks = 0;
+
+		/* Set the sequence number. */
+		vi->i_generation = ni->seq_no = le16_to_cpu(m->sequence_number);
+		/*
+		 * Manually map, pin, and lock the mft record as we already
+		 * have its page mapped and it is very easy to do.
+		 */
+		atomic_inc(&ni->count);
+		down(&ni->mrec_lock);
+		ni->page = page;
+		ni->page_ofs = ofs;
+		/*
+		 * Make sure the allocated mft record is written out to disk.
+		 * NOTE: We do not set the ntfs inode dirty because this would
+		 * fail in ntfs_write_inode() because the inode does not have a
+		 * standard information attribute yet.  Also, there is no need
+		 * to set the inode dirty because the caller is going to do
+		 * that anyway after finishing with the new mft record (e.g. at
+		 * a minimum some new attributes will be added to the mft
+		 * record.
+		 */
+		mark_ntfs_record_dirty(page, ofs);
 		unlock_page(page);
-		end_page_writeback(page);
+
+		/* Add the inode to the inode hash for the superblock. */
+		insert_inode_hash(vi);
+
+		/* Update the default mft allocation position. */
+		vol->mft_data_pos = bit + 1;
 	}
-	ntfs_debug("Done.");
-	return 0;
+	/*
+	 * Return the opened, allocated inode of the allocated mft record as
+	 * well as the mapped, pinned, and locked mft record.
+	 */
+	ntfs_debug("Returning opened, allocated %sinode 0x%llx.",
+			base_ni ? "extent " : "", (long long)bit);
+	*mrec = m;
+	return ni;
+undo_data_init:
+	mft_ni->initialized_size = old_data_initialized;
+	vol->mft_ino->i_size = old_data_size;
+	goto undo_mftbmp_alloc_nolock;
+undo_mftbmp_alloc:
+	down_write(&vol->mftbmp_lock);
+undo_mftbmp_alloc_nolock:
+	if (ntfs_bitmap_clear_bit(vol->mftbmp_ino, bit)) {
+		ntfs_error(vol->sb, "Failed to clear bit in mft bitmap.%s", es);
+		NVolSetErrors(vol);
+	}
+	up_write(&vol->mftbmp_lock);
+err_out:
+	return ERR_PTR(err);
+max_err_out:
+	ntfs_warning(vol->sb, "Cannot allocate mft record because the maximum "
+			"number of inodes (2^32) has already been reached.");
+	up_write(&vol->mftbmp_lock);
+	return ERR_PTR(-ENOSPC);
 }
 
+/**
+ * ntfs_extent_mft_record_free - free an extent mft record on an ntfs volume
+ * @ni:		ntfs inode of the mapped extent mft record to free
+ * @m:		mapped extent mft record of the ntfs inode @ni
+ *
+ * Free the mapped extent mft record @m of the extent ntfs inode @ni.
+ *
+ * Note that this function unmaps the mft record and closes and destroys @ni
+ * internally and hence you cannot use either @ni nor @m any more after this
+ * function returns success.
+ *
+ * On success return 0 and on error return -errno.  @ni and @m are still valid
+ * in this case and have not been freed.
+ *
+ * For some errors an error message is displayed and the success code 0 is
+ * returned and the volume is then left dirty on umount.  This makes sense in
+ * case we could not rollback the changes that were already done since the
+ * caller no longer wants to reference this mft record so it does not matter to
+ * the caller if something is wrong with it as long as it is properly detached
+ * from the base inode.
+ */
+int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m)
+{
+	unsigned long mft_no = ni->mft_no;
+	ntfs_volume *vol = ni->vol;
+	ntfs_inode *base_ni;
+	ntfs_inode **extent_nis;
+	int i, err;
+	le16 old_seq_no;
+	u16 seq_no;
+	
+	BUG_ON(NInoAttr(ni));
+	BUG_ON(ni->nr_extents != -1);
+
+	down(&ni->extent_lock);
+	base_ni = ni->ext.base_ntfs_ino;
+	up(&ni->extent_lock);
+
+	BUG_ON(base_ni->nr_extents <= 0);
+
+	ntfs_debug("Entering for extent inode 0x%lx, base inode 0x%lx.\n",
+			mft_no, base_ni->mft_no);
+
+	down(&base_ni->extent_lock);
+
+	/* Make sure we are holding the only reference to the extent inode. */
+	if (atomic_read(&ni->count) > 2) {
+		ntfs_error(vol->sb, "Tried to free busy extent inode 0x%lx, "
+				"not freeing.", base_ni->mft_no);
+		up(&base_ni->extent_lock);
+		return -EBUSY;
+	}
+
+	/* Dissociate the ntfs inode from the base inode. */
+	extent_nis = base_ni->ext.extent_ntfs_inos;
+	err = -ENOENT;
+	for (i = 0; i < base_ni->nr_extents; i++) {
+		if (ni != extent_nis[i])
+			continue;
+		extent_nis += i;
+		base_ni->nr_extents--;
+		memmove(extent_nis, extent_nis + 1, (base_ni->nr_extents - i) *
+				sizeof(ntfs_inode*));
+		err = 0;
+		break;
+	}
+
+	up(&base_ni->extent_lock);
+
+	if (unlikely(err)) {
+		ntfs_error(vol->sb, "Extent inode 0x%lx is not attached to "
+				"its base inode 0x%lx.", mft_no,
+				base_ni->mft_no);
+		BUG();
+	}
+
+	/*
+	 * The extent inode is no longer attached to the base inode so no one
+	 * can get a reference to it any more.
+	 */
+
+	/* Mark the mft record as not in use. */
+	m->flags &= const_cpu_to_le16(~const_le16_to_cpu(MFT_RECORD_IN_USE));
+
+	/* Increment the sequence number, skipping zero, if it is not zero. */
+	old_seq_no = m->sequence_number;
+	seq_no = le16_to_cpu(old_seq_no);
+	if (seq_no == 0xffff)
+		seq_no = 1;
+	else if (seq_no)
+		seq_no++;
+	m->sequence_number = cpu_to_le16(seq_no);
+
+	/*
+	 * Set the ntfs inode dirty and write it out.  We do not need to worry
+	 * about the base inode here since whatever caused the extent mft
+	 * record to be freed is guaranteed to do it already.
+	 */
+	NInoSetDirty(ni);
+	err = write_mft_record(ni, m, 0);
+	if (unlikely(err)) {
+		ntfs_error(vol->sb, "Failed to write mft record 0x%lx, not "
+				"freeing.", mft_no);
+		goto rollback;
+	}
+rollback_error:
+	/* Unmap and throw away the now freed extent inode. */
+	unmap_extent_mft_record(ni);
+	ntfs_clear_extent_inode(ni);
+
+	/* Clear the bit in the $MFT/$BITMAP corresponding to this record. */
+	down_write(&vol->mftbmp_lock);
+	err = ntfs_bitmap_clear_bit(vol->mftbmp_ino, mft_no);
+	up_write(&vol->mftbmp_lock);
+	if (unlikely(err)) {
+		/*
+		 * The extent inode is gone but we failed to deallocate it in
+		 * the mft bitmap.  Just emit a warning and leave the volume
+		 * dirty on umount.
+		 */
+		ntfs_error(vol->sb, "Failed to clear bit in mft bitmap.%s", es);
+		NVolSetErrors(vol);
+	}
+	return 0;
+rollback:
+	/* Rollback what we did... */
+	down(&base_ni->extent_lock);
+	extent_nis = base_ni->ext.extent_ntfs_inos;
+	if (!(base_ni->nr_extents & 3)) {
+		int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*);
+
+		extent_nis = (ntfs_inode**)kmalloc(new_size, GFP_NOFS);
+		if (unlikely(!extent_nis)) {
+			ntfs_error(vol->sb, "Failed to allocate internal "
+					"buffer during rollback.%s", es);
+			up(&base_ni->extent_lock);
+			NVolSetErrors(vol);
+			goto rollback_error;
+		}
+		if (base_ni->nr_extents) {
+			BUG_ON(!base_ni->ext.extent_ntfs_inos);
+			memcpy(extent_nis, base_ni->ext.extent_ntfs_inos,
+					new_size - 4 * sizeof(ntfs_inode*));
+			kfree(base_ni->ext.extent_ntfs_inos);
+		}
+		base_ni->ext.extent_ntfs_inos = extent_nis;
+	}
+	m->flags |= MFT_RECORD_IN_USE;
+	m->sequence_number = old_seq_no;
+	extent_nis[base_ni->nr_extents++] = ni;
+	up(&base_ni->extent_lock);
+	mark_mft_record_dirty(ni);
+	return err;
+}
 #endif /* NTFS_RW */
diff -Nru a/fs/ntfs/mft.h b/fs/ntfs/mft.h
--- a/fs/ntfs/mft.h	2004-12-24 13:36:19 -08:00
+++ b/fs/ntfs/mft.h	2004-12-24 13:36:19 -08:00
@@ -24,11 +24,11 @@
 #define _LINUX_NTFS_MFT_H
 
 #include <linux/fs.h>
+#include <linux/highmem.h>
+#include <linux/pagemap.h>
 
 #include "inode.h"
 
-extern int format_mft_record(ntfs_inode *ni, MFT_RECORD *m);
-
 extern MFT_RECORD *map_mft_record(ntfs_inode *ni);
 extern void unmap_mft_record(ntfs_inode *ni);
 
@@ -76,6 +76,9 @@
 		__mark_mft_record_dirty(ni);
 }
 
+extern int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no,
+		MFT_RECORD *m, int sync);
+
 extern int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync);
 
 /**
@@ -110,6 +113,14 @@
 	unlock_page(page);
 	return err;
 }
+
+extern BOOL ntfs_may_write_mft_record(ntfs_volume *vol,
+		const unsigned long mft_no, const MFT_RECORD *m,
+		ntfs_inode **locked_ni);
+
+extern ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode,
+		ntfs_inode *base_ni, MFT_RECORD **mrec);
+extern int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m);
 
 #endif /* NTFS_RW */
 
diff -Nru a/fs/ntfs/namei.c b/fs/ntfs/namei.c
--- a/fs/ntfs/namei.c	2004-12-24 13:37:17 -08:00
+++ b/fs/ntfs/namei.c	2004-12-24 13:37:17 -08:00
@@ -23,8 +23,11 @@
 #include <linux/dcache.h>
 #include <linux/security.h>
 
-#include "ntfs.h"
+#include "attrib.h"
+#include "debug.h"
 #include "dir.h"
+#include "mft.h"
+#include "ntfs.h"
 
 /**
  * ntfs_lookup - find the inode represented by a dentry in a directory inode
@@ -124,15 +127,16 @@
 		dent_inode = ntfs_iget(vol->sb, dent_ino);
 		if (likely(!IS_ERR(dent_inode))) {
 			/* Consistency check. */
-			if (MSEQNO(mref) == NTFS_I(dent_inode)->seq_no ||
+			if (is_bad_inode(dent_inode) || MSEQNO(mref) ==
+					NTFS_I(dent_inode)->seq_no ||
 					dent_ino == FILE_MFT) {
 				/* Perfect WIN32/POSIX match. -- Case 1. */
 				if (!name) {
-					ntfs_debug("Done.");
+					ntfs_debug("Done.  (Case 1.)");
 					return d_splice_alias(dent_inode, dent);
 				}
 				/*
-				 * We are too indented. Handle imperfect
+				 * We are too indented.  Handle imperfect
 				 * matches and short file names further below.
 				 */
 				goto handle_name;
@@ -178,6 +182,7 @@
 
 	nls_name.name = NULL;
 	if (name->type != FILE_NAME_DOS) {			/* Case 2. */
+		ntfs_debug("Case 2.");
 		nls_name.len = (unsigned)ntfs_ucstonls(vol,
 				(ntfschar*)&name->name, name->len,
 				(unsigned char**)&nls_name.name, 0);
@@ -185,6 +190,7 @@
 	} else /* if (name->type == FILE_NAME_DOS) */ {		/* Case 3. */
 		FILE_NAME_ATTR *fn;
 
+		ntfs_debug("Case 3.");
 		kfree(name);
 
 		/* Find the WIN32 name corresponding to the matched DOS name. */
@@ -268,12 +274,17 @@
 			dput(real_dent);
 		else
 			new_dent = real_dent;
+		ntfs_debug("Done.  (Created new dentry.)");
 		return new_dent;
 	}
 	kfree(nls_name.name);
 	/* Matching dentry exists, check if it is negative. */
 	if (real_dent->d_inode) {
-		BUG_ON(real_dent->d_inode != dent_inode);
+		if (unlikely(real_dent->d_inode != dent_inode)) {
+			/* This can happen because bad inodes are unhashed. */
+			BUG_ON(!is_bad_inode(dent_inode));
+			BUG_ON(!is_bad_inode(real_dent->d_inode));
+		}
 		/*
 		 * Already have the inode and the dentry attached, decrement
 		 * the reference count to balance the ntfs_iget() we did
@@ -282,6 +293,7 @@
 		 * about any NFS/disconnectedness issues here.
 		 */
 		iput(dent_inode);
+		ntfs_debug("Done.  (Already had inode and dentry.)");
 		return real_dent;
 	}
 	/*
@@ -292,6 +304,7 @@
 	if (!S_ISDIR(dent_inode->i_mode)) {
 		/* Not a directory; everything is easy. */
 		d_instantiate(real_dent, dent_inode);
+		ntfs_debug("Done.  (Already had negative file dentry.)");
 		return real_dent;
 	}
 	spin_lock(&dcache_lock);
@@ -305,6 +318,7 @@
 		real_dent->d_inode = dent_inode;
 		spin_unlock(&dcache_lock);
 		security_d_instantiate(real_dent, dent_inode);
+		ntfs_debug("Done.  (Already had negative directory dentry.)");
 		return real_dent;
 	}
 	/*
@@ -324,6 +338,8 @@
 	/* Throw away real_dent. */
 	dput(real_dent);
 	/* Use new_dent as the actual dentry. */
+	ntfs_debug("Done.  (Already had negative, disconnected directory "
+			"dentry.)");
 	return new_dent;
 
 eio_err_out:
@@ -335,6 +351,7 @@
 	if (m)
 		unmap_mft_record(ni);
 	iput(dent_inode);
+	ntfs_error(vol->sb, "Failed, returning error code %i.", err);
 	return ERR_PTR(err);
    }
 }
diff -Nru a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h
--- a/fs/ntfs/ntfs.h	2004-12-24 13:36:48 -08:00
+++ b/fs/ntfs/ntfs.h	2004-12-24 13:36:48 -08:00
@@ -29,21 +29,12 @@
 #include <linux/module.h>
 #include <linux/compiler.h>
 #include <linux/fs.h>
-#include <linux/buffer_head.h>
 #include <linux/nls.h>
-#include <linux/pagemap.h>
 #include <linux/smp.h>
-#include <asm/atomic.h>
 
 #include "types.h"
-#include "debug.h"
-#include "malloc.h"
-#include "endian.h"
 #include "volume.h"
-#include "inode.h"
 #include "layout.h"
-#include "attrib.h"
-#include "mft.h"
 
 typedef enum {
 	NTFS_BLOCK_SIZE		= 512,
@@ -62,10 +53,8 @@
 extern kmem_cache_t *ntfs_index_ctx_cache;
 
 /* The various operations structs defined throughout the driver files. */
-extern struct super_operations ntfs_sops;
 extern struct address_space_operations ntfs_aops;
 extern struct address_space_operations ntfs_mst_aops;
-extern struct address_space_operations ntfs_mft_aops;
 
 extern struct  file_operations ntfs_file_ops;
 extern struct inode_operations ntfs_file_inode_ops;
@@ -87,77 +76,15 @@
 	return sb->s_fs_info;
 }
 
-/**
- * ntfs_unmap_page - release a page that was mapped using ntfs_map_page()
- * @page:	the page to release
- *
- * Unpin, unmap and release a page that was obtained from ntfs_map_page().
- */
-static inline void ntfs_unmap_page(struct page *page)
-{
-	kunmap(page);
-	page_cache_release(page);
-}
-
-/**
- * ntfs_map_page - map a page into accessible memory, reading it if necessary
- * @mapping:	address space for which to obtain the page
- * @index:	index into the page cache for @mapping of the page to map
- *
- * Read a page from the page cache of the address space @mapping at position
- * @index, where @index is in units of PAGE_CACHE_SIZE, and not in bytes.
- *
- * If the page is not in memory it is loaded from disk first using the readpage
- * method defined in the address space operations of @mapping and the page is
- * added to the page cache of @mapping in the process.
- *
- * If the page is in high memory it is mapped into memory directly addressible
- * by the kernel.
- *
- * Finally the page count is incremented, thus pinning the page into place.
- *
- * The above means that page_address(page) can be used on all pages obtained
- * with ntfs_map_page() to get the kernel virtual address of the page.
- *
- * When finished with the page, the caller has to call ntfs_unmap_page() to
- * unpin, unmap and release the page.
- *
- * Note this does not grant exclusive access. If such is desired, the caller
- * must provide it independently of the ntfs_{un}map_page() calls by using
- * a {rw_}semaphore or other means of serialization. A spin lock cannot be
- * used as ntfs_map_page() can block.
- *
- * The unlocked and uptodate page is returned on success or an encoded error
- * on failure. Caller has to test for error using the IS_ERR() macro on the
- * return value. If that evaluates to TRUE, the negative error code can be
- * obtained using PTR_ERR() on the return value of ntfs_map_page().
- */
-static inline struct page *ntfs_map_page(struct address_space *mapping,
-		unsigned long index)
-{
-	struct page *page = read_cache_page(mapping, index,
-			(filler_t*)mapping->a_ops->readpage, NULL);
-
-	if (!IS_ERR(page)) {
-		wait_on_page_locked(page);
-		kmap(page);
-		if (PageUptodate(page) && !PageError(page))
-			return page;
-		ntfs_unmap_page(page);
-		return ERR_PTR(-EIO);
-	}
-	return page;
-}
-
 /* Declarations of functions and global variables. */
 
 /* From fs/ntfs/compress.c */
 extern int ntfs_read_compressed_block(struct page *page);
+extern int allocate_compression_buffers(void);
+extern void free_compression_buffers(void);
 
 /* From fs/ntfs/super.c */
 #define default_upcase_len 0x10000
-extern ntfschar *default_upcase;
-extern unsigned long ntfs_nr_upcase_users;
 extern struct semaphore ntfs_lock;
 
 typedef struct {
@@ -165,10 +92,6 @@
 	char *str;
 } option_t;
 extern const option_t on_errors_arr[];
-
-/* From fs/ntfs/compress.c */
-extern int allocate_compression_buffers(void);
-extern void free_compression_buffers(void);
 
 /* From fs/ntfs/mst.c */
 extern int post_read_mst_fixup(NTFS_RECORD *b, const u32 size);
diff -Nru a/fs/ntfs/quota.c b/fs/ntfs/quota.c
--- a/fs/ntfs/quota.c	2004-12-24 13:37:44 -08:00
+++ b/fs/ntfs/quota.c	2004-12-24 13:37:44 -08:00
@@ -22,9 +22,10 @@
 
 #ifdef NTFS_RW
 
-#include "ntfs.h"
 #include "index.h"
 #include "quota.h"
+#include "debug.h"
+#include "ntfs.h"
 
 /**
  * ntfs_mark_quotas_out_of_date - mark the quotas out of date on an ntfs volume
@@ -51,7 +52,7 @@
 	ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino));
 	if (!ictx) {
 		ntfs_error(vol->sb, "Failed to get index context.");
-		return FALSE;
+		goto err_out;
 	}
 	err = ntfs_index_lookup(&qid, sizeof(qid), ictx);
 	if (err) {
@@ -107,7 +108,8 @@
 	ntfs_debug("Done.");
 	return TRUE;
 err_out:
-	ntfs_index_ctx_put(ictx);
+	if (ictx)
+		ntfs_index_ctx_put(ictx);
 	up(&vol->quota_q_ino->i_sem);
 	return FALSE;
 }
diff -Nru a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/fs/ntfs/runlist.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1438 @@
+/**
+ * runlist.c - NTFS runlist handling code.  Part of the Linux-NTFS project.
+ *
+ * Copyright (c) 2001-2004 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
+ *
+ * This program/include file 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/include file 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 (in the main directory of the Linux-NTFS
+ * distribution in the file COPYING); if not, write to the Free Software
+ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "debug.h"
+#include "dir.h"
+#include "endian.h"
+#include "malloc.h"
+#include "ntfs.h"
+
+/**
+ * ntfs_rl_mm - runlist memmove
+ *
+ * It is up to the caller to serialize access to the runlist @base.
+ */
+static inline void ntfs_rl_mm(runlist_element *base, int dst, int src,
+		int size)
+{
+	if (likely((dst != src) && (size > 0)))
+		memmove(base + dst, base + src, size * sizeof (*base));
+}
+
+/**
+ * ntfs_rl_mc - runlist memory copy
+ *
+ * It is up to the caller to serialize access to the runlists @dstbase and
+ * @srcbase.
+ */
+static inline void ntfs_rl_mc(runlist_element *dstbase, int dst,
+		runlist_element *srcbase, int src, int size)
+{
+	if (likely(size > 0))
+		memcpy(dstbase + dst, srcbase + src, size * sizeof(*dstbase));
+}
+
+/**
+ * ntfs_rl_realloc - Reallocate memory for runlists
+ * @rl:		original runlist
+ * @old_size:	number of runlist elements in the original runlist @rl
+ * @new_size:	number of runlist elements we need space for
+ *
+ * As the runlists grow, more memory will be required.  To prevent the
+ * kernel having to allocate and reallocate large numbers of small bits of
+ * memory, this function returns and entire page of memory.
+ *
+ * It is up to the caller to serialize access to the runlist @rl.
+ *
+ * N.B.  If the new allocation doesn't require a different number of pages in
+ *       memory, the function will return the original pointer.
+ *
+ * On success, return a pointer to the newly allocated, or recycled, memory.
+ * On error, return -errno. The following error codes are defined:
+ *	-ENOMEM	- Not enough memory to allocate runlist array.
+ *	-EINVAL	- Invalid parameters were passed in.
+ */
+static inline runlist_element *ntfs_rl_realloc(runlist_element *rl,
+		int old_size, int new_size)
+{
+	runlist_element *new_rl;
+
+	old_size = PAGE_ALIGN(old_size * sizeof(*rl));
+	new_size = PAGE_ALIGN(new_size * sizeof(*rl));
+	if (old_size == new_size)
+		return rl;
+
+	new_rl = ntfs_malloc_nofs(new_size);
+	if (unlikely(!new_rl))
+		return ERR_PTR(-ENOMEM);
+
+	if (likely(rl != NULL)) {
+		if (unlikely(old_size > new_size))
+			old_size = new_size;
+		memcpy(new_rl, rl, old_size);
+		ntfs_free(rl);
+	}
+	return new_rl;
+}
+
+/**
+ * ntfs_are_rl_mergeable - test if two runlists can be joined together
+ * @dst:	original runlist
+ * @src:	new runlist to test for mergeability with @dst
+ *
+ * Test if two runlists can be joined together. For this, their VCNs and LCNs
+ * must be adjacent.
+ *
+ * It is up to the caller to serialize access to the runlists @dst and @src.
+ *
+ * Return: TRUE   Success, the runlists can be merged.
+ *	   FALSE  Failure, the runlists cannot be merged.
+ */
+static inline BOOL ntfs_are_rl_mergeable(runlist_element *dst,
+		runlist_element *src)
+{
+	BUG_ON(!dst);
+	BUG_ON(!src);
+
+	if ((dst->lcn < 0) || (src->lcn < 0))     /* Are we merging holes? */
+		return FALSE;
+	if ((dst->lcn + dst->length) != src->lcn) /* Are the runs contiguous? */
+		return FALSE;
+	if ((dst->vcn + dst->length) != src->vcn) /* Are the runs misaligned? */
+		return FALSE;
+
+	return TRUE;
+}
+
+/**
+ * __ntfs_rl_merge - merge two runlists without testing if they can be merged
+ * @dst:	original, destination runlist
+ * @src:	new runlist to merge with @dst
+ *
+ * Merge the two runlists, writing into the destination runlist @dst. The
+ * caller must make sure the runlists can be merged or this will corrupt the
+ * destination runlist.
+ *
+ * It is up to the caller to serialize access to the runlists @dst and @src.
+ */
+static inline void __ntfs_rl_merge(runlist_element *dst, runlist_element *src)
+{
+	dst->length += src->length;
+}
+
+/**
+ * ntfs_rl_append - append a runlist after a given element
+ * @dst:	original runlist to be worked on
+ * @dsize:	number of elements in @dst (including end marker)
+ * @src:	runlist to be inserted into @dst
+ * @ssize:	number of elements in @src (excluding end marker)
+ * @loc:	append the new runlist @src after this element in @dst
+ *
+ * Append the runlist @src after element @loc in @dst.  Merge the right end of
+ * the new runlist, if necessary. Adjust the size of the hole before the
+ * appended runlist.
+ *
+ * It is up to the caller to serialize access to the runlists @dst and @src.
+ *
+ * On success, return a pointer to the new, combined, runlist. Note, both
+ * runlists @dst and @src are deallocated before returning so you cannot use
+ * the pointers for anything any more. (Strictly speaking the returned runlist
+ * may be the same as @dst but this is irrelevant.)
+ *
+ * On error, return -errno. Both runlists are left unmodified. The following
+ * error codes are defined:
+ *	-ENOMEM	- Not enough memory to allocate runlist array.
+ *	-EINVAL	- Invalid parameters were passed in.
+ */
+static inline runlist_element *ntfs_rl_append(runlist_element *dst,
+		int dsize, runlist_element *src, int ssize, int loc)
+{
+	BOOL right;
+	int magic;
+
+	BUG_ON(!dst);
+	BUG_ON(!src);
+
+	/* First, check if the right hand end needs merging. */
+	right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
+
+	/* Space required: @dst size + @src size, less one if we merged. */
+	dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - right);
+	if (IS_ERR(dst))
+		return dst;
+	/*
+	 * We are guaranteed to succeed from here so can start modifying the
+	 * original runlists.
+	 */
+
+	/* First, merge the right hand end, if necessary. */
+	if (right)
+		__ntfs_rl_merge(src + ssize - 1, dst + loc + 1);
+
+	magic = loc + ssize;
+
+	/* Move the tail of @dst out of the way, then copy in @src. */
+	ntfs_rl_mm(dst, magic + 1, loc + 1 + right, dsize - loc - 1 - right);
+	ntfs_rl_mc(dst, loc + 1, src, 0, ssize);
+
+	/* Adjust the size of the preceding hole. */
+	dst[loc].length = dst[loc + 1].vcn - dst[loc].vcn;
+
+	/* We may have changed the length of the file, so fix the end marker */
+	if (dst[magic + 1].lcn == LCN_ENOENT)
+		dst[magic + 1].vcn = dst[magic].vcn + dst[magic].length;
+
+	return dst;
+}
+
+/**
+ * ntfs_rl_insert - insert a runlist into another
+ * @dst:	original runlist to be worked on
+ * @dsize:	number of elements in @dst (including end marker)
+ * @src:	new runlist to be inserted
+ * @ssize:	number of elements in @src (excluding end marker)
+ * @loc:	insert the new runlist @src before this element in @dst
+ *
+ * Insert the runlist @src before element @loc in the runlist @dst. Merge the
+ * left end of the new runlist, if necessary. Adjust the size of the hole
+ * after the inserted runlist.
+ *
+ * It is up to the caller to serialize access to the runlists @dst and @src.
+ *
+ * On success, return a pointer to the new, combined, runlist. Note, both
+ * runlists @dst and @src are deallocated before returning so you cannot use
+ * the pointers for anything any more. (Strictly speaking the returned runlist
+ * may be the same as @dst but this is irrelevant.)
+ *
+ * On error, return -errno. Both runlists are left unmodified. The following
+ * error codes are defined:
+ *	-ENOMEM	- Not enough memory to allocate runlist array.
+ *	-EINVAL	- Invalid parameters were passed in.
+ */
+static inline runlist_element *ntfs_rl_insert(runlist_element *dst,
+		int dsize, runlist_element *src, int ssize, int loc)
+{
+	BOOL left = FALSE;
+	BOOL disc = FALSE;	/* Discontinuity */
+	BOOL hole = FALSE;	/* Following a hole */
+	int magic;
+
+	BUG_ON(!dst);
+	BUG_ON(!src);
+
+	/* disc => Discontinuity between the end of @dst and the start of @src.
+	 *	   This means we might need to insert a hole.
+	 * hole => @dst ends with a hole or an unmapped region which we can
+	 *	   extend to match the discontinuity. */
+	if (loc == 0)
+		disc = (src[0].vcn > 0);
+	else {
+		s64 merged_length;
+
+		left = ntfs_are_rl_mergeable(dst + loc - 1, src);
+
+		merged_length = dst[loc - 1].length;
+		if (left)
+			merged_length += src->length;
+
+		disc = (src[0].vcn > dst[loc - 1].vcn + merged_length);
+		if (disc)
+			hole = (dst[loc - 1].lcn == LCN_HOLE);
+	}
+
+	/* Space required: @dst size + @src size, less one if we merged, plus
+	 * one if there was a discontinuity, less one for a trailing hole. */
+	dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left + disc - hole);
+	if (IS_ERR(dst))
+		return dst;
+	/*
+	 * We are guaranteed to succeed from here so can start modifying the
+	 * original runlist.
+	 */
+
+	if (left)
+		__ntfs_rl_merge(dst + loc - 1, src);
+
+	magic = loc + ssize - left + disc - hole;
+
+	/* Move the tail of @dst out of the way, then copy in @src. */
+	ntfs_rl_mm(dst, magic, loc, dsize - loc);
+	ntfs_rl_mc(dst, loc + disc - hole, src, left, ssize - left);
+
+	/* Adjust the VCN of the last run ... */
+	if (dst[magic].lcn <= LCN_HOLE)
+		dst[magic].vcn = dst[magic - 1].vcn + dst[magic - 1].length;
+	/* ... and the length. */
+	if (dst[magic].lcn == LCN_HOLE || dst[magic].lcn == LCN_RL_NOT_MAPPED)
+		dst[magic].length = dst[magic + 1].vcn - dst[magic].vcn;
+
+	/* Writing beyond the end of the file and there's a discontinuity. */
+	if (disc) {
+		if (hole)
+			dst[loc - 1].length = dst[loc].vcn - dst[loc - 1].vcn;
+		else {
+			if (loc > 0) {
+				dst[loc].vcn = dst[loc - 1].vcn +
+						dst[loc - 1].length;
+				dst[loc].length = dst[loc + 1].vcn -
+						dst[loc].vcn;
+			} else {
+				dst[loc].vcn = 0;
+				dst[loc].length = dst[loc + 1].vcn;
+			}
+			dst[loc].lcn = LCN_RL_NOT_MAPPED;
+		}
+
+		magic += hole;
+
+		if (dst[magic].lcn == LCN_ENOENT)
+			dst[magic].vcn = dst[magic - 1].vcn +
+					dst[magic - 1].length;
+	}
+	return dst;
+}
+
+/**
+ * ntfs_rl_replace - overwrite a runlist element with another runlist
+ * @dst:	original runlist to be worked on
+ * @dsize:	number of elements in @dst (including end marker)
+ * @src:	new runlist to be inserted
+ * @ssize:	number of elements in @src (excluding end marker)
+ * @loc:	index in runlist @dst to overwrite with @src
+ *
+ * Replace the runlist element @dst at @loc with @src. Merge the left and
+ * right ends of the inserted runlist, if necessary.
+ *
+ * It is up to the caller to serialize access to the runlists @dst and @src.
+ *
+ * On success, return a pointer to the new, combined, runlist. Note, both
+ * runlists @dst and @src are deallocated before returning so you cannot use
+ * the pointers for anything any more. (Strictly speaking the returned runlist
+ * may be the same as @dst but this is irrelevant.)
+ *
+ * On error, return -errno. Both runlists are left unmodified. The following
+ * error codes are defined:
+ *	-ENOMEM	- Not enough memory to allocate runlist array.
+ *	-EINVAL	- Invalid parameters were passed in.
+ */
+static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
+		int dsize, runlist_element *src, int ssize, int loc)
+{
+	BOOL left = FALSE;
+	BOOL right;
+	int magic;
+
+	BUG_ON(!dst);
+	BUG_ON(!src);
+
+	/* First, merge the left and right ends, if necessary. */
+	right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
+	if (loc > 0)
+		left = ntfs_are_rl_mergeable(dst + loc - 1, src);
+
+	/* Allocate some space. We'll need less if the left, right, or both
+	 * ends were merged. */
+	dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left - right);
+	if (IS_ERR(dst))
+		return dst;
+	/*
+	 * We are guaranteed to succeed from here so can start modifying the
+	 * original runlists.
+	 */
+	if (right)
+		__ntfs_rl_merge(src + ssize - 1, dst + loc + 1);
+	if (left)
+		__ntfs_rl_merge(dst + loc - 1, src);
+
+	/* FIXME: What does this mean? (AIA) */
+	magic = loc + ssize - left;
+
+	/* Move the tail of @dst out of the way, then copy in @src. */
+	ntfs_rl_mm(dst, magic, loc + right + 1, dsize - loc - right - 1);
+	ntfs_rl_mc(dst, loc, src, left, ssize - left);
+
+	/* We may have changed the length of the file, so fix the end marker */
+	if (dst[magic].lcn == LCN_ENOENT)
+		dst[magic].vcn = dst[magic - 1].vcn + dst[magic - 1].length;
+	return dst;
+}
+
+/**
+ * ntfs_rl_split - insert a runlist into the centre of a hole
+ * @dst:	original runlist to be worked on
+ * @dsize:	number of elements in @dst (including end marker)
+ * @src:	new runlist to be inserted
+ * @ssize:	number of elements in @src (excluding end marker)
+ * @loc:	index in runlist @dst at which to split and insert @src
+ *
+ * Split the runlist @dst at @loc into two and insert @new in between the two
+ * fragments. No merging of runlists is necessary. Adjust the size of the
+ * holes either side.
+ *
+ * It is up to the caller to serialize access to the runlists @dst and @src.
+ *
+ * On success, return a pointer to the new, combined, runlist. Note, both
+ * runlists @dst and @src are deallocated before returning so you cannot use
+ * the pointers for anything any more. (Strictly speaking the returned runlist
+ * may be the same as @dst but this is irrelevant.)
+ *
+ * On error, return -errno. Both runlists are left unmodified. The following
+ * error codes are defined:
+ *	-ENOMEM	- Not enough memory to allocate runlist array.
+ *	-EINVAL	- Invalid parameters were passed in.
+ */
+static inline runlist_element *ntfs_rl_split(runlist_element *dst, int dsize,
+		runlist_element *src, int ssize, int loc)
+{
+	BUG_ON(!dst);
+	BUG_ON(!src);
+
+	/* Space required: @dst size + @src size + one new hole. */
+	dst = ntfs_rl_realloc(dst, dsize, dsize + ssize + 1);
+	if (IS_ERR(dst))
+		return dst;
+	/*
+	 * We are guaranteed to succeed from here so can start modifying the
+	 * original runlists.
+	 */
+
+	/* Move the tail of @dst out of the way, then copy in @src. */
+	ntfs_rl_mm(dst, loc + 1 + ssize, loc, dsize - loc);
+	ntfs_rl_mc(dst, loc + 1, src, 0, ssize);
+
+	/* Adjust the size of the holes either size of @src. */
+	dst[loc].length		= dst[loc+1].vcn       - dst[loc].vcn;
+	dst[loc+ssize+1].vcn    = dst[loc+ssize].vcn   + dst[loc+ssize].length;
+	dst[loc+ssize+1].length = dst[loc+ssize+2].vcn - dst[loc+ssize+1].vcn;
+
+	return dst;
+}
+
+/**
+ * ntfs_runlists_merge - merge two runlists into one
+ * @drl:	original runlist to be worked on
+ * @srl:	new runlist to be merged into @drl
+ *
+ * First we sanity check the two runlists @srl and @drl to make sure that they
+ * are sensible and can be merged. The runlist @srl must be either after the
+ * runlist @drl or completely within a hole (or unmapped region) in @drl.
+ *
+ * It is up to the caller to serialize access to the runlists @drl and @srl.
+ *
+ * Merging of runlists is necessary in two cases:
+ *   1. When attribute lists are used and a further extent is being mapped.
+ *   2. When new clusters are allocated to fill a hole or extend a file.
+ *
+ * There are four possible ways @srl can be merged. It can:
+ *	- be inserted at the beginning of a hole,
+ *	- split the hole in two and be inserted between the two fragments,
+ *	- be appended at the end of a hole, or it can
+ *	- replace the whole hole.
+ * It can also be appended to the end of the runlist, which is just a variant
+ * of the insert case.
+ *
+ * On success, return a pointer to the new, combined, runlist. Note, both
+ * runlists @drl and @srl are deallocated before returning so you cannot use
+ * the pointers for anything any more. (Strictly speaking the returned runlist
+ * may be the same as @dst but this is irrelevant.)
+ *
+ * On error, return -errno. Both runlists are left unmodified. The following
+ * error codes are defined:
+ *	-ENOMEM	- Not enough memory to allocate runlist array.
+ *	-EINVAL	- Invalid parameters were passed in.
+ *	-ERANGE	- The runlists overlap and cannot be merged.
+ */
+runlist_element *ntfs_runlists_merge(runlist_element *drl,
+		runlist_element *srl)
+{
+	int di, si;		/* Current index into @[ds]rl. */
+	int sstart;		/* First index with lcn > LCN_RL_NOT_MAPPED. */
+	int dins;		/* Index into @drl at which to insert @srl. */
+	int dend, send;		/* Last index into @[ds]rl. */
+	int dfinal, sfinal;	/* The last index into @[ds]rl with
+				   lcn >= LCN_HOLE. */
+	int marker = 0;
+	VCN marker_vcn = 0;
+
+#ifdef DEBUG
+	ntfs_debug("dst:");
+	ntfs_debug_dump_runlist(drl);
+	ntfs_debug("src:");
+	ntfs_debug_dump_runlist(srl);
+#endif
+
+	/* Check for silly calling... */
+	if (unlikely(!srl))
+		return drl;
+	if (IS_ERR(srl) || IS_ERR(drl))
+		return ERR_PTR(-EINVAL);
+
+	/* Check for the case where the first mapping is being done now. */
+	if (unlikely(!drl)) {
+		drl = srl;
+		/* Complete the source runlist if necessary. */
+		if (unlikely(drl[0].vcn)) {
+			/* Scan to the end of the source runlist. */
+			for (dend = 0; likely(drl[dend].length); dend++)
+				;
+			drl = ntfs_rl_realloc(drl, dend, dend + 1);
+			if (IS_ERR(drl))
+				return drl;
+			/* Insert start element at the front of the runlist. */
+			ntfs_rl_mm(drl, 1, 0, dend);
+			drl[0].vcn = 0;
+			drl[0].lcn = LCN_RL_NOT_MAPPED;
+			drl[0].length = drl[1].vcn;
+		}
+		goto finished;
+	}
+
+	si = di = 0;
+
+	/* Skip any unmapped start element(s) in the source runlist. */
+	while (srl[si].length && srl[si].lcn < LCN_HOLE)
+		si++;
+
+	/* Can't have an entirely unmapped source runlist. */
+	BUG_ON(!srl[si].length);
+
+	/* Record the starting points. */
+	sstart = si;
+
+	/*
+	 * Skip forward in @drl until we reach the position where @srl needs to
+	 * be inserted. If we reach the end of @drl, @srl just needs to be
+	 * appended to @drl.
+	 */
+	for (; drl[di].length; di++) {
+		if (drl[di].vcn + drl[di].length > srl[sstart].vcn)
+			break;
+	}
+	dins = di;
+
+	/* Sanity check for illegal overlaps. */
+	if ((drl[di].vcn == srl[si].vcn) && (drl[di].lcn >= 0) &&
+			(srl[si].lcn >= 0)) {
+		ntfs_error(NULL, "Run lists overlap. Cannot merge!");
+		return ERR_PTR(-ERANGE);
+	}
+
+	/* Scan to the end of both runlists in order to know their sizes. */
+	for (send = si; srl[send].length; send++)
+		;
+	for (dend = di; drl[dend].length; dend++)
+		;
+
+	if (srl[send].lcn == LCN_ENOENT)
+		marker_vcn = srl[marker = send].vcn;
+
+	/* Scan to the last element with lcn >= LCN_HOLE. */
+	for (sfinal = send; sfinal >= 0 && srl[sfinal].lcn < LCN_HOLE; sfinal--)
+		;
+	for (dfinal = dend; dfinal >= 0 && drl[dfinal].lcn < LCN_HOLE; dfinal--)
+		;
+
+	{
+	BOOL start;
+	BOOL finish;
+	int ds = dend + 1;		/* Number of elements in drl & srl */
+	int ss = sfinal - sstart + 1;
+
+	start  = ((drl[dins].lcn <  LCN_RL_NOT_MAPPED) ||    /* End of file   */
+		  (drl[dins].vcn == srl[sstart].vcn));	     /* Start of hole */
+	finish = ((drl[dins].lcn >= LCN_RL_NOT_MAPPED) &&    /* End of file   */
+		 ((drl[dins].vcn + drl[dins].length) <=      /* End of hole   */
+		  (srl[send - 1].vcn + srl[send - 1].length)));
+
+	/* Or we'll lose an end marker */
+	if (start && finish && (drl[dins].length == 0))
+		ss++;
+	if (marker && (drl[dins].vcn + drl[dins].length > srl[send - 1].vcn))
+		finish = FALSE;
+#if 0
+	ntfs_debug("dfinal = %i, dend = %i", dfinal, dend);
+	ntfs_debug("sstart = %i, sfinal = %i, send = %i", sstart, sfinal, send);
+	ntfs_debug("start = %i, finish = %i", start, finish);
+	ntfs_debug("ds = %i, ss = %i, dins = %i", ds, ss, dins);
+#endif
+	if (start) {
+		if (finish)
+			drl = ntfs_rl_replace(drl, ds, srl + sstart, ss, dins);
+		else
+			drl = ntfs_rl_insert(drl, ds, srl + sstart, ss, dins);
+	} else {
+		if (finish)
+			drl = ntfs_rl_append(drl, ds, srl + sstart, ss, dins);
+		else
+			drl = ntfs_rl_split(drl, ds, srl + sstart, ss, dins);
+	}
+	if (IS_ERR(drl)) {
+		ntfs_error(NULL, "Merge failed.");
+		return drl;
+	}
+	ntfs_free(srl);
+	if (marker) {
+		ntfs_debug("Triggering marker code.");
+		for (ds = dend; drl[ds].length; ds++)
+			;
+		/* We only need to care if @srl ended after @drl. */
+		if (drl[ds].vcn <= marker_vcn) {
+			int slots = 0;
+
+			if (drl[ds].vcn == marker_vcn) {
+				ntfs_debug("Old marker = 0x%llx, replacing "
+						"with LCN_ENOENT.",
+						(unsigned long long)
+						drl[ds].lcn);
+				drl[ds].lcn = LCN_ENOENT;
+				goto finished;
+			}
+			/*
+			 * We need to create an unmapped runlist element in
+			 * @drl or extend an existing one before adding the
+			 * ENOENT terminator.
+			 */
+			if (drl[ds].lcn == LCN_ENOENT) {
+				ds--;
+				slots = 1;
+			}
+			if (drl[ds].lcn != LCN_RL_NOT_MAPPED) {
+				/* Add an unmapped runlist element. */
+				if (!slots) {
+					/* FIXME/TODO: We need to have the
+					 * extra memory already! (AIA) */
+					drl = ntfs_rl_realloc(drl, ds, ds + 2);
+					if (!drl)
+						goto critical_error;
+					slots = 2;
+				}
+				ds++;
+				/* Need to set vcn if it isn't set already. */
+				if (slots != 1)
+					drl[ds].vcn = drl[ds - 1].vcn +
+							drl[ds - 1].length;
+				drl[ds].lcn = LCN_RL_NOT_MAPPED;
+				/* We now used up a slot. */
+				slots--;
+			}
+			drl[ds].length = marker_vcn - drl[ds].vcn;
+			/* Finally add the ENOENT terminator. */
+			ds++;
+			if (!slots) {
+				/* FIXME/TODO: We need to have the extra
+				 * memory already! (AIA) */
+				drl = ntfs_rl_realloc(drl, ds, ds + 1);
+				if (!drl)
+					goto critical_error;
+			}
+			drl[ds].vcn = marker_vcn;
+			drl[ds].lcn = LCN_ENOENT;
+			drl[ds].length = (s64)0;
+		}
+	}
+	}
+
+finished:
+	/* The merge was completed successfully. */
+	ntfs_debug("Merged runlist:");
+	ntfs_debug_dump_runlist(drl);
+	return drl;
+
+critical_error:
+	/* Critical error! We cannot afford to fail here. */
+	ntfs_error(NULL, "Critical error! Not enough memory.");
+	panic("NTFS: Cannot continue.");
+}
+
+/**
+ * ntfs_mapping_pairs_decompress - convert mapping pairs array to runlist
+ * @vol:	ntfs volume on which the attribute resides
+ * @attr:	attribute record whose mapping pairs array to decompress
+ * @old_rl:	optional runlist in which to insert @attr's runlist
+ *
+ * It is up to the caller to serialize access to the runlist @old_rl.
+ *
+ * Decompress the attribute @attr's mapping pairs array into a runlist. On
+ * success, return the decompressed runlist.
+ *
+ * If @old_rl is not NULL, decompressed runlist is inserted into the
+ * appropriate place in @old_rl and the resultant, combined runlist is
+ * returned. The original @old_rl is deallocated.
+ *
+ * On error, return -errno. @old_rl is left unmodified in that case.
+ *
+ * The following error codes are defined:
+ *	-ENOMEM	- Not enough memory to allocate runlist array.
+ *	-EIO	- Corrupt runlist.
+ *	-EINVAL	- Invalid parameters were passed in.
+ *	-ERANGE	- The two runlists overlap.
+ *
+ * FIXME: For now we take the conceptionally simplest approach of creating the
+ * new runlist disregarding the already existing one and then splicing the
+ * two into one, if that is possible (we check for overlap and discard the new
+ * runlist if overlap present before returning ERR_PTR(-ERANGE)).
+ */
+runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol,
+		const ATTR_RECORD *attr, runlist_element *old_rl)
+{
+	VCN vcn;		/* Current vcn. */
+	LCN lcn;		/* Current lcn. */
+	s64 deltaxcn;		/* Change in [vl]cn. */
+	runlist_element *rl;	/* The output runlist. */
+	u8 *buf;		/* Current position in mapping pairs array. */
+	u8 *attr_end;		/* End of attribute. */
+	int rlsize;		/* Size of runlist buffer. */
+	u16 rlpos;		/* Current runlist position in units of
+				   runlist_elements. */
+	u8 b;			/* Current byte offset in buf. */
+
+#ifdef DEBUG
+	/* Make sure attr exists and is non-resident. */
+	if (!attr || !attr->non_resident || sle64_to_cpu(
+			attr->data.non_resident.lowest_vcn) < (VCN)0) {
+		ntfs_error(vol->sb, "Invalid arguments.");
+		return ERR_PTR(-EINVAL);
+	}
+#endif
+	/* Start at vcn = lowest_vcn and lcn 0. */
+	vcn = sle64_to_cpu(attr->data.non_resident.lowest_vcn);
+	lcn = 0;
+	/* Get start of the mapping pairs array. */
+	buf = (u8*)attr + le16_to_cpu(
+			attr->data.non_resident.mapping_pairs_offset);
+	attr_end = (u8*)attr + le32_to_cpu(attr->length);
+	if (unlikely(buf < (u8*)attr || buf > attr_end)) {
+		ntfs_error(vol->sb, "Corrupt attribute.");
+		return ERR_PTR(-EIO);
+	}
+	/* Current position in runlist array. */
+	rlpos = 0;
+	/* Allocate first page and set current runlist size to one page. */
+	rl = ntfs_malloc_nofs(rlsize = PAGE_SIZE);
+	if (unlikely(!rl))
+		return ERR_PTR(-ENOMEM);
+	/* Insert unmapped starting element if necessary. */
+	if (vcn) {
+		rl->vcn = 0;
+		rl->lcn = LCN_RL_NOT_MAPPED;
+		rl->length = vcn;
+		rlpos++;
+	}
+	while (buf < attr_end && *buf) {
+		/*
+		 * Allocate more memory if needed, including space for the
+		 * not-mapped and terminator elements. ntfs_malloc_nofs()
+		 * operates on whole pages only.
+		 */
+		if (((rlpos + 3) * sizeof(*old_rl)) > rlsize) {
+			runlist_element *rl2;
+
+			rl2 = ntfs_malloc_nofs(rlsize + (int)PAGE_SIZE);
+			if (unlikely(!rl2)) {
+				ntfs_free(rl);
+				return ERR_PTR(-ENOMEM);
+			}
+			memcpy(rl2, rl, rlsize);
+			ntfs_free(rl);
+			rl = rl2;
+			rlsize += PAGE_SIZE;
+		}
+		/* Enter the current vcn into the current runlist element. */
+		rl[rlpos].vcn = vcn;
+		/*
+		 * Get the change in vcn, i.e. the run length in clusters.
+		 * Doing it this way ensures that we signextend negative values.
+		 * A negative run length doesn't make any sense, but hey, I
+		 * didn't make up the NTFS specs and Windows NT4 treats the run
+		 * length as a signed value so that's how it is...
+		 */
+		b = *buf & 0xf;
+		if (b) {
+			if (unlikely(buf + b > attr_end))
+				goto io_error;
+			for (deltaxcn = (s8)buf[b--]; b; b--)
+				deltaxcn = (deltaxcn << 8) + buf[b];
+		} else { /* The length entry is compulsory. */
+			ntfs_error(vol->sb, "Missing length entry in mapping "
+					"pairs array.");
+			deltaxcn = (s64)-1;
+		}
+		/*
+		 * Assume a negative length to indicate data corruption and
+		 * hence clean-up and return NULL.
+		 */
+		if (unlikely(deltaxcn < 0)) {
+			ntfs_error(vol->sb, "Invalid length in mapping pairs "
+					"array.");
+			goto err_out;
+		}
+		/*
+		 * Enter the current run length into the current runlist
+		 * element.
+		 */
+		rl[rlpos].length = deltaxcn;
+		/* Increment the current vcn by the current run length. */
+		vcn += deltaxcn;
+		/*
+		 * There might be no lcn change at all, as is the case for
+		 * sparse clusters on NTFS 3.0+, in which case we set the lcn
+		 * to LCN_HOLE.
+		 */
+		if (!(*buf & 0xf0))
+			rl[rlpos].lcn = LCN_HOLE;
+		else {
+			/* Get the lcn change which really can be negative. */
+			u8 b2 = *buf & 0xf;
+			b = b2 + ((*buf >> 4) & 0xf);
+			if (buf + b > attr_end)
+				goto io_error;
+			for (deltaxcn = (s8)buf[b--]; b > b2; b--)
+				deltaxcn = (deltaxcn << 8) + buf[b];
+			/* Change the current lcn to its new value. */
+			lcn += deltaxcn;
+#ifdef DEBUG
+			/*
+			 * On NTFS 1.2-, apparently can have lcn == -1 to
+			 * indicate a hole. But we haven't verified ourselves
+			 * whether it is really the lcn or the deltaxcn that is
+			 * -1. So if either is found give us a message so we
+			 * can investigate it further!
+			 */
+			if (vol->major_ver < 3) {
+				if (unlikely(deltaxcn == (LCN)-1))
+					ntfs_error(vol->sb, "lcn delta == -1");
+				if (unlikely(lcn == (LCN)-1))
+					ntfs_error(vol->sb, "lcn == -1");
+			}
+#endif
+			/* Check lcn is not below -1. */
+			if (unlikely(lcn < (LCN)-1)) {
+				ntfs_error(vol->sb, "Invalid LCN < -1 in "
+						"mapping pairs array.");
+				goto err_out;
+			}
+			/* Enter the current lcn into the runlist element. */
+			rl[rlpos].lcn = lcn;
+		}
+		/* Get to the next runlist element. */
+		rlpos++;
+		/* Increment the buffer position to the next mapping pair. */
+		buf += (*buf & 0xf) + ((*buf >> 4) & 0xf) + 1;
+	}
+	if (unlikely(buf >= attr_end))
+		goto io_error;
+	/*
+	 * If there is a highest_vcn specified, it must be equal to the final
+	 * vcn in the runlist - 1, or something has gone badly wrong.
+	 */
+	deltaxcn = sle64_to_cpu(attr->data.non_resident.highest_vcn);
+	if (unlikely(deltaxcn && vcn - 1 != deltaxcn)) {
+mpa_err:
+		ntfs_error(vol->sb, "Corrupt mapping pairs array in "
+				"non-resident attribute.");
+		goto err_out;
+	}
+	/* Setup not mapped runlist element if this is the base extent. */
+	if (!attr->data.non_resident.lowest_vcn) {
+		VCN max_cluster;
+
+		max_cluster = (sle64_to_cpu(
+				attr->data.non_resident.allocated_size) +
+				vol->cluster_size - 1) >>
+				vol->cluster_size_bits;
+		/*
+		 * If there is a difference between the highest_vcn and the
+		 * highest cluster, the runlist is either corrupt or, more
+		 * likely, there are more extents following this one.
+		 */
+		if (deltaxcn < --max_cluster) {
+			ntfs_debug("More extents to follow; deltaxcn = 0x%llx, "
+					"max_cluster = 0x%llx",
+					(unsigned long long)deltaxcn,
+					(unsigned long long)max_cluster);
+			rl[rlpos].vcn = vcn;
+			vcn += rl[rlpos].length = max_cluster - deltaxcn;
+			rl[rlpos].lcn = LCN_RL_NOT_MAPPED;
+			rlpos++;
+		} else if (unlikely(deltaxcn > max_cluster)) {
+			ntfs_error(vol->sb, "Corrupt attribute. deltaxcn = "
+					"0x%llx, max_cluster = 0x%llx",
+					(unsigned long long)deltaxcn,
+					(unsigned long long)max_cluster);
+			goto mpa_err;
+		}
+		rl[rlpos].lcn = LCN_ENOENT;
+	} else /* Not the base extent. There may be more extents to follow. */
+		rl[rlpos].lcn = LCN_RL_NOT_MAPPED;
+
+	/* Setup terminating runlist element. */
+	rl[rlpos].vcn = vcn;
+	rl[rlpos].length = (s64)0;
+	/* If no existing runlist was specified, we are done. */
+	if (!old_rl) {
+		ntfs_debug("Mapping pairs array successfully decompressed:");
+		ntfs_debug_dump_runlist(rl);
+		return rl;
+	}
+	/* Now combine the new and old runlists checking for overlaps. */
+	old_rl = ntfs_runlists_merge(old_rl, rl);
+	if (likely(!IS_ERR(old_rl)))
+		return old_rl;
+	ntfs_free(rl);
+	ntfs_error(vol->sb, "Failed to merge runlists.");
+	return old_rl;
+io_error:
+	ntfs_error(vol->sb, "Corrupt attribute.");
+err_out:
+	ntfs_free(rl);
+	return ERR_PTR(-EIO);
+}
+
+/**
+ * ntfs_rl_vcn_to_lcn - convert a vcn into a lcn given a runlist
+ * @rl:		runlist to use for conversion
+ * @vcn:	vcn to convert
+ *
+ * Convert the virtual cluster number @vcn of an attribute into a logical
+ * cluster number (lcn) of a device using the runlist @rl to map vcns to their
+ * corresponding lcns.
+ *
+ * It is up to the caller to serialize access to the runlist @rl.
+ *
+ * Since lcns must be >= 0, we use negative return values with special meaning:
+ *
+ * Return value			Meaning / Description
+ * ==================================================
+ *  -1 = LCN_HOLE		Hole / not allocated on disk.
+ *  -2 = LCN_RL_NOT_MAPPED	This is part of the runlist which has not been
+ *				inserted into the runlist yet.
+ *  -3 = LCN_ENOENT		There is no such vcn in the attribute.
+ *
+ * Locking: - The caller must have locked the runlist (for reading or writing).
+ *	    - This function does not touch the lock.
+ */
+LCN ntfs_rl_vcn_to_lcn(const runlist_element *rl, const VCN vcn)
+{
+	int i;
+
+	BUG_ON(vcn < 0);
+	/*
+	 * If rl is NULL, assume that we have found an unmapped runlist. The
+	 * caller can then attempt to map it and fail appropriately if
+	 * necessary.
+	 */
+	if (unlikely(!rl))
+		return LCN_RL_NOT_MAPPED;
+
+	/* Catch out of lower bounds vcn. */
+	if (unlikely(vcn < rl[0].vcn))
+		return LCN_ENOENT;
+
+	for (i = 0; likely(rl[i].length); i++) {
+		if (unlikely(vcn < rl[i+1].vcn)) {
+			if (likely(rl[i].lcn >= (LCN)0))
+				return rl[i].lcn + (vcn - rl[i].vcn);
+			return rl[i].lcn;
+		}
+	}
+	/*
+	 * The terminator element is setup to the correct value, i.e. one of
+	 * LCN_HOLE, LCN_RL_NOT_MAPPED, or LCN_ENOENT.
+	 */
+	if (likely(rl[i].lcn < (LCN)0))
+		return rl[i].lcn;
+	/* Just in case... We could replace this with BUG() some day. */
+	return LCN_ENOENT;
+}
+
+/**
+ * ntfs_get_nr_significant_bytes - get number of bytes needed to store a number
+ * @n:		number for which to get the number of bytes for
+ *
+ * Return the number of bytes required to store @n unambiguously as
+ * a signed number.
+ *
+ * This is used in the context of the mapping pairs array to determine how
+ * many bytes will be needed in the array to store a given logical cluster
+ * number (lcn) or a specific run length.
+ *
+ * Return the number of bytes written.  This function cannot fail.
+ */
+static inline int ntfs_get_nr_significant_bytes(const s64 n)
+{
+	s64 l = n;
+	int i;
+	s8 j;
+
+	i = 0;
+	do {
+		l >>= 8;
+		i++;
+	} while (l != 0 && l != -1);
+	j = (n >> 8 * (i - 1)) & 0xff;
+	/* If the sign bit is wrong, we need an extra byte. */
+	if ((n < 0 && j >= 0) || (n > 0 && j < 0))
+		i++;
+	return i;
+}
+
+/**
+ * ntfs_get_size_for_mapping_pairs - get bytes needed for mapping pairs array
+ * @vol:	ntfs volume (needed for the ntfs version)
+ * @rl:		locked runlist to determine the size of the mapping pairs of
+ * @start_vcn:	vcn at which to start the mapping pairs array
+ *
+ * Walk the locked runlist @rl and calculate the size in bytes of the mapping
+ * pairs array corresponding to the runlist @rl, starting at vcn @start_vcn.
+ * This for example allows us to allocate a buffer of the right size when
+ * building the mapping pairs array.
+ *
+ * If @rl is NULL, just return 1 (for the single terminator byte).
+ *
+ * Return the calculated size in bytes on success.  On error, return -errno.
+ * The following error codes are defined:
+ *	-EINVAL	- Run list contains unmapped elements.  Make sure to only pass
+ *		  fully mapped runlists to this function.
+ *	-EIO	- The runlist is corrupt.
+ *
+ * Locking: @rl must be locked on entry (either for reading or writing), it
+ *	    remains locked throughout, and is left locked upon return.
+ */
+int ntfs_get_size_for_mapping_pairs(const ntfs_volume *vol,
+		const runlist_element *rl, const VCN start_vcn)
+{
+	LCN prev_lcn;
+	int rls;
+
+	BUG_ON(start_vcn < 0);
+	if (!rl) {
+		BUG_ON(start_vcn);
+		return 1;
+	}
+	/* Skip to runlist element containing @start_vcn. */
+	while (rl->length && start_vcn >= rl[1].vcn)
+		rl++;
+	if ((!rl->length && start_vcn > rl->vcn) || start_vcn < rl->vcn)
+		return -EINVAL;
+	prev_lcn = 0;
+	/* Always need the termining zero byte. */
+	rls = 1;
+	/* Do the first partial run if present. */
+	if (start_vcn > rl->vcn) {
+		s64 delta;
+
+		/* We know rl->length != 0 already. */
+		if (rl->length < 0 || rl->lcn < LCN_HOLE)
+			goto err_out;
+		delta = start_vcn - rl->vcn;
+		/* Header byte + length. */
+		rls += 1 + ntfs_get_nr_significant_bytes(rl->length - delta);
+		/*
+		 * If the logical cluster number (lcn) denotes a hole and we
+		 * are on NTFS 3.0+, we don't store it at all, i.e. we need
+		 * zero space.  On earlier NTFS versions we just store the lcn.
+		 * Note: this assumes that on NTFS 1.2-, holes are stored with
+		 * an lcn of -1 and not a delta_lcn of -1 (unless both are -1).
+		 */
+		if (rl->lcn >= 0 || vol->major_ver < 3) {
+			prev_lcn = rl->lcn;
+			if (rl->lcn >= 0)
+				prev_lcn += delta;
+			/* Change in lcn. */
+			rls += ntfs_get_nr_significant_bytes(prev_lcn);
+		}
+		/* Go to next runlist element. */
+		rl++;
+	}
+	/* Do the full runs. */
+	for (; rl->length; rl++) {
+		if (rl->length < 0 || rl->lcn < LCN_HOLE)
+			goto err_out;
+		/* Header byte + length. */
+		rls += 1 + ntfs_get_nr_significant_bytes(rl->length);
+		/*
+		 * If the logical cluster number (lcn) denotes a hole and we
+		 * are on NTFS 3.0+, we don't store it at all, i.e. we need
+		 * zero space.  On earlier NTFS versions we just store the lcn.
+		 * Note: this assumes that on NTFS 1.2-, holes are stored with
+		 * an lcn of -1 and not a delta_lcn of -1 (unless both are -1).
+		 */
+		if (rl->lcn >= 0 || vol->major_ver < 3) {
+			/* Change in lcn. */
+			rls += ntfs_get_nr_significant_bytes(rl->lcn -
+					prev_lcn);
+			prev_lcn = rl->lcn;
+		}
+	}
+	return rls;
+err_out:
+	if (rl->lcn == LCN_RL_NOT_MAPPED)
+		rls = -EINVAL;
+	else
+		rls = -EIO;
+	return rls;
+}
+
+/**
+ * ntfs_write_significant_bytes - write the significant bytes of a number
+ * @dst:	destination buffer to write to
+ * @dst_max:	pointer to last byte of destination buffer for bounds checking
+ * @n:		number whose significant bytes to write
+ *
+ * Store in @dst, the minimum bytes of the number @n which are required to
+ * identify @n unambiguously as a signed number, taking care not to exceed
+ * @dest_max, the maximum position within @dst to which we are allowed to
+ * write.
+ *
+ * This is used when building the mapping pairs array of a runlist to compress
+ * a given logical cluster number (lcn) or a specific run length to the minumum
+ * size possible.
+ *
+ * Return the number of bytes written on success.  On error, i.e. the
+ * destination buffer @dst is too small, return -ENOSPC.
+ */
+static inline int ntfs_write_significant_bytes(s8 *dst, const s8 *dst_max,
+		const s64 n)
+{
+	s64 l = n;
+	int i;
+	s8 j;
+
+	i = 0;
+	do {
+		if (dst > dst_max)
+			goto err_out;
+		*dst++ = l & 0xffll;
+		l >>= 8;
+		i++;
+	} while (l != 0 && l != -1);
+	j = (n >> 8 * (i - 1)) & 0xff;
+	/* If the sign bit is wrong, we need an extra byte. */
+	if (n < 0 && j >= 0) {
+		if (dst > dst_max)
+			goto err_out;
+		i++;
+		*dst = (s8)-1;
+	} else if (n > 0 && j < 0) {
+		if (dst > dst_max)
+			goto err_out;
+		i++;
+		*dst = (s8)0;
+	}
+	return i;
+err_out:
+	return -ENOSPC;
+}
+
+/**
+ * ntfs_mapping_pairs_build - build the mapping pairs array from a runlist
+ * @vol:	ntfs volume (needed for the ntfs version)
+ * @dst:	destination buffer to which to write the mapping pairs array
+ * @dst_len:	size of destination buffer @dst in bytes
+ * @rl:		locked runlist for which to build the mapping pairs array
+ * @start_vcn:	vcn at which to start the mapping pairs array
+ * @stop_vcn:	first vcn outside destination buffer on success or -ENOSPC
+ *
+ * Create the mapping pairs array from the locked runlist @rl, starting at vcn
+ * @start_vcn and save the array in @dst.  @dst_len is the size of @dst in
+ * bytes and it should be at least equal to the value obtained by calling
+ * ntfs_get_size_for_mapping_pairs().
+ *
+ * If @rl is NULL, just write a single terminator byte to @dst.
+ *
+ * On success or -ENOSPC error, if @stop_vcn is not NULL, *@stop_vcn is set to
+ * the first vcn outside the destination buffer.  Note that on error, @dst has
+ * been filled with all the mapping pairs that will fit, thus it can be treated
+ * as partial success, in that a new attribute extent needs to be created or
+ * the next extent has to be used and the mapping pairs build has to be
+ * continued with @start_vcn set to *@stop_vcn.
+ *
+ * Return 0 on success and -errno on error.  The following error codes are
+ * defined:
+ *	-EINVAL	- Run list contains unmapped elements.  Make sure to only pass
+ *		  fully mapped runlists to this function.
+ *	-EIO	- The runlist is corrupt.
+ *	-ENOSPC	- The destination buffer is too small.
+ *
+ * Locking: @rl must be locked on entry (either for reading or writing), it
+ *	    remains locked throughout, and is left locked upon return.
+ */
+int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst,
+		const int dst_len, const runlist_element *rl,
+		const VCN start_vcn, VCN *const stop_vcn)
+{
+	LCN prev_lcn;
+	s8 *dst_max, *dst_next;
+	int err = -ENOSPC;
+	s8 len_len, lcn_len;
+
+	BUG_ON(start_vcn < 0);
+	BUG_ON(dst_len < 1);
+	if (!rl) {
+		BUG_ON(start_vcn);
+		if (stop_vcn)
+			*stop_vcn = 0;
+		/* Terminator byte. */
+		*dst = 0;
+		return 0;
+	}
+	/* Skip to runlist element containing @start_vcn. */
+	while (rl->length && start_vcn >= rl[1].vcn)
+		rl++;
+	if ((!rl->length && start_vcn > rl->vcn) || start_vcn < rl->vcn)
+		return -EINVAL;
+	/*
+	 * @dst_max is used for bounds checking in
+	 * ntfs_write_significant_bytes().
+	 */
+	dst_max = dst + dst_len - 1;
+	prev_lcn = 0;
+	/* Do the first partial run if present. */
+	if (start_vcn > rl->vcn) {
+		s64 delta;
+
+		/* We know rl->length != 0 already. */
+		if (rl->length < 0 || rl->lcn < LCN_HOLE)
+			goto err_out;
+		delta = start_vcn - rl->vcn;
+		/* Write length. */
+		len_len = ntfs_write_significant_bytes(dst + 1, dst_max,
+				rl->length - delta);
+		if (len_len < 0)
+			goto size_err;
+		/*
+		 * If the logical cluster number (lcn) denotes a hole and we
+		 * are on NTFS 3.0+, we don't store it at all, i.e. we need
+		 * zero space.  On earlier NTFS versions we just write the lcn
+		 * change.  FIXME: Do we need to write the lcn change or just
+		 * the lcn in that case?  Not sure as I have never seen this
+		 * case on NT4. - We assume that we just need to write the lcn
+		 * change until someone tells us otherwise... (AIA)
+		 */
+		if (rl->lcn >= 0 || vol->major_ver < 3) {
+			prev_lcn = rl->lcn;
+			if (rl->lcn >= 0)
+				prev_lcn += delta;
+			/* Write change in lcn. */
+			lcn_len = ntfs_write_significant_bytes(dst + 1 +
+					len_len, dst_max, prev_lcn);
+			if (lcn_len < 0)
+				goto size_err;
+		} else
+			lcn_len = 0;
+		dst_next = dst + len_len + lcn_len + 1;
+		if (dst_next > dst_max)
+			goto size_err;
+		/* Update header byte. */
+		*dst = lcn_len << 4 | len_len;
+		/* Position at next mapping pairs array element. */
+		dst = dst_next;
+		/* Go to next runlist element. */
+		rl++;
+	}
+	/* Do the full runs. */
+	for (; rl->length; rl++) {
+		if (rl->length < 0 || rl->lcn < LCN_HOLE)
+			goto err_out;
+		/* Write length. */
+		len_len = ntfs_write_significant_bytes(dst + 1, dst_max,
+				rl->length);
+		if (len_len < 0)
+			goto size_err;
+		/*
+		 * If the logical cluster number (lcn) denotes a hole and we
+		 * are on NTFS 3.0+, we don't store it at all, i.e. we need
+		 * zero space.  On earlier NTFS versions we just write the lcn
+		 * change.  FIXME: Do we need to write the lcn change or just
+		 * the lcn in that case?  Not sure as I have never seen this
+		 * case on NT4. - We assume that we just need to write the lcn
+		 * change until someone tells us otherwise... (AIA)
+		 */
+		if (rl->lcn >= 0 || vol->major_ver < 3) {
+			/* Write change in lcn. */
+			lcn_len = ntfs_write_significant_bytes(dst + 1 +
+					len_len, dst_max, rl->lcn - prev_lcn);
+			if (lcn_len < 0)
+				goto size_err;
+			prev_lcn = rl->lcn;
+		} else
+			lcn_len = 0;
+		dst_next = dst + len_len + lcn_len + 1;
+		if (dst_next > dst_max)
+			goto size_err;
+		/* Update header byte. */
+		*dst = lcn_len << 4 | len_len;
+		/* Position at next mapping pairs array element. */
+		dst = dst_next;
+	}
+	/* Success. */
+	err = 0;
+size_err:
+	/* Set stop vcn. */
+	if (stop_vcn)
+		*stop_vcn = rl->vcn;
+	/* Add terminator byte. */
+	*dst = 0;
+	return err;
+err_out:
+	if (rl->lcn == LCN_RL_NOT_MAPPED)
+		err = -EINVAL;
+	else
+		err = -EIO;
+	return err;
+}
+
+/**
+ * ntfs_rl_truncate_nolock - truncate a runlist starting at a specified vcn
+ * @runlist:	runlist to truncate
+ * @new_length:	the new length of the runlist in VCNs
+ *
+ * Truncate the runlist described by @runlist as well as the memory buffer
+ * holding the runlist elements to a length of @new_length VCNs.
+ *
+ * If @new_length lies within the runlist, the runlist elements with VCNs of
+ * @new_length and above are discarded.
+ *
+ * If @new_length lies beyond the runlist, a sparse runlist element is added to
+ * the end of the runlist @runlist or if the last runlist element is a sparse
+ * one already, this is extended.
+ *
+ * Return 0 on success and -errno on error.
+ *
+ * Locking: The caller must hold @runlist->lock for writing.
+ */
+int ntfs_rl_truncate_nolock(const ntfs_volume *vol, runlist *const runlist,
+		const s64 new_length)
+{
+	runlist_element *rl;
+	int old_size;
+
+	ntfs_debug("Entering for new_length 0x%llx.", (long long)new_length);
+	BUG_ON(!runlist);
+	BUG_ON(new_length < 0);
+	rl = runlist->rl;
+	if (unlikely(!rl)) {
+		/*
+		 * Create a runlist consisting of a sparse runlist element of
+		 * length @new_length followed by a terminator runlist element.
+		 */
+		rl = ntfs_malloc_nofs(PAGE_SIZE);
+		if (unlikely(!rl)) {
+			ntfs_error(vol->sb, "Not enough memory to allocate "
+					"runlist element buffer.");
+			return -ENOMEM;
+		}
+		runlist->rl = rl;
+		rl[1].length = rl->vcn = 0;
+		rl->lcn = LCN_HOLE;
+		rl[1].vcn = rl->length = new_length;
+		rl[1].lcn = LCN_ENOENT;
+		return 0;
+	}
+	BUG_ON(new_length < rl->vcn);
+	/* Find @new_length in the runlist. */
+	while (likely(rl->length && new_length >= rl[1].vcn))
+		rl++;
+	/*
+	 * If not at the end of the runlist we need to shrink it.
+	 * If at the end of the runlist we need to expand it.
+	 */
+	if (rl->length) {
+		runlist_element *trl;
+		BOOL is_end;
+
+		ntfs_debug("Shrinking runlist.");
+		/* Determine the runlist size. */
+		trl = rl + 1;
+		while (likely(trl->length))
+			trl++;
+		old_size = trl - runlist->rl + 1;
+		/* Truncate the run. */
+		rl->length = new_length - rl->vcn;
+		/*
+		 * If a run was partially truncated, make the following runlist
+		 * element a terminator.
+		 */
+		is_end = FALSE;
+		if (rl->length) {
+			rl++;
+			if (!rl->length)
+				is_end = TRUE;
+			rl->vcn = new_length;
+			rl->length = 0;
+		}
+		rl->lcn = LCN_ENOENT;
+		/* Reallocate memory if necessary. */
+		if (!is_end) {
+			int new_size = rl - runlist->rl + 1;
+			rl = ntfs_rl_realloc(runlist->rl, old_size, new_size);
+			if (IS_ERR(rl))
+				ntfs_warning(vol->sb, "Failed to shrink "
+						"runlist buffer.  This just "
+						"wastes a bit of memory "
+						"temporarily so we ignore it "
+						"and return success.");
+			else
+				runlist->rl = rl;
+		}
+	} else if (likely(/* !rl->length && */ new_length > rl->vcn)) {
+		ntfs_debug("Expanding runlist.");
+		/*
+		 * If there is a previous runlist element and it is a sparse
+		 * one, extend it.  Otherwise need to add a new, sparse runlist
+		 * element.
+		 */
+		if ((rl > runlist->rl) && ((rl - 1)->lcn == LCN_HOLE))
+			(rl - 1)->length = new_length - (rl - 1)->vcn;
+		else {
+			/* Determine the runlist size. */
+			old_size = rl - runlist->rl + 1;
+			/* Reallocate memory if necessary. */
+			rl = ntfs_rl_realloc(runlist->rl, old_size,
+					old_size + 1);
+			if (IS_ERR(rl)) {
+				ntfs_error(vol->sb, "Failed to expand runlist "
+						"buffer, aborting.");
+				return PTR_ERR(rl);
+			}
+			runlist->rl = rl;
+			/*
+			 * Set @rl to the same runlist element in the new
+			 * runlist as before in the old runlist.
+			 */
+			rl += old_size - 1;
+			/* Add a new, sparse runlist element. */
+			rl->lcn = LCN_HOLE;
+			rl->length = new_length - rl->vcn;
+			/* Add a new terminator runlist element. */
+			rl++;
+			rl->length = 0;
+		}
+		rl->vcn = new_length;
+		rl->lcn = LCN_ENOENT;
+	} else /* if (unlikely(!rl->length && new_length == rl->vcn)) */ {
+		/* Runlist already has same size as requested. */
+		rl->lcn = LCN_ENOENT;
+	}
+	ntfs_debug("Done.");
+	return 0;
+}
diff -Nru a/fs/ntfs/runlist.h b/fs/ntfs/runlist.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/fs/ntfs/runlist.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,89 @@
+/*
+ * runlist.h - Defines for runlist handling in NTFS Linux kernel driver.
+ *	       Part of the Linux-NTFS project.
+ *
+ * Copyright (c) 2001-2004 Anton Altaparmakov
+ * Copyright (c) 2002 Richard Russon
+ *
+ * This program/include file 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/include file 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 (in the main directory of the Linux-NTFS
+ * distribution in the file COPYING); if not, write to the Free Software
+ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _LINUX_NTFS_RUNLIST_H
+#define _LINUX_NTFS_RUNLIST_H
+
+#include "types.h"
+#include "layout.h"
+#include "volume.h"
+
+/**
+ * runlist_element - in memory vcn to lcn mapping array element
+ * @vcn:	starting vcn of the current array element
+ * @lcn:	starting lcn of the current array element
+ * @length:	length in clusters of the current array element
+ *
+ * The last vcn (in fact the last vcn + 1) is reached when length == 0.
+ *
+ * When lcn == -1 this means that the count vcns starting at vcn are not
+ * physically allocated (i.e. this is a hole / data is sparse).
+ */
+typedef struct {	/* In memory vcn to lcn mapping structure element. */
+	VCN vcn;	/* vcn = Starting virtual cluster number. */
+	LCN lcn;	/* lcn = Starting logical cluster number. */
+	s64 length;	/* Run length in clusters. */
+} runlist_element;
+
+/**
+ * runlist - in memory vcn to lcn mapping array including a read/write lock
+ * @rl:		pointer to an array of runlist elements
+ * @lock:	read/write spinlock for serializing access to @rl
+ *
+ */
+typedef struct {
+	runlist_element *rl;
+	struct rw_semaphore lock;
+} runlist;
+
+static inline void ntfs_init_runlist(runlist *rl)
+{
+	rl->rl = NULL;
+	init_rwsem(&rl->lock);
+}
+
+typedef enum {
+	LCN_HOLE		= -1,	/* Keep this as highest value or die! */
+	LCN_RL_NOT_MAPPED	= -2,
+	LCN_ENOENT		= -3,
+} LCN_SPECIAL_VALUES;
+
+extern runlist_element *ntfs_runlists_merge(runlist_element *drl,
+		runlist_element *srl);
+
+extern runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol,
+		const ATTR_RECORD *attr, runlist_element *old_rl);
+
+extern LCN ntfs_rl_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
+
+extern int ntfs_get_size_for_mapping_pairs(const ntfs_volume *vol,
+		const runlist_element *rl, const VCN start_vcn);
+
+extern int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst,
+		const int dst_len, const runlist_element *rl,
+		const VCN start_vcn, VCN *const stop_vcn);
+
+extern int ntfs_rl_truncate_nolock(const ntfs_volume *vol,
+		runlist *const runlist, const s64 new_length);
+
+#endif /* _LINUX_NTFS_RUNLIST_H */
diff -Nru a/fs/ntfs/super.c b/fs/ntfs/super.c
--- a/fs/ntfs/super.c	2004-12-24 13:37:02 -08:00
+++ b/fs/ntfs/super.c	2004-12-24 13:37:02 -08:00
@@ -31,16 +31,23 @@
 #include <linux/moduleparam.h>
 #include <linux/smp_lock.h>
 
-#include "ntfs.h"
 #include "sysctl.h"
 #include "logfile.h"
 #include "quota.h"
 #include "dir.h"
+#include "debug.h"
 #include "index.h"
+#include "aops.h"
+#include "malloc.h"
+#include "ntfs.h"
 
 /* Number of mounted file systems which have compression enabled. */
 static unsigned long ntfs_nr_compression_users;
 
+/* A global default upcase table and a corresponding reference count. */
+static ntfschar *default_upcase = NULL;
+static unsigned long ntfs_nr_upcase_users = 0;
+
 /* Error constants/strings used in inode.c::ntfs_show_options(). */
 typedef enum {
 	/* One of these must be present, default is ON_ERRORS_CONTINUE. */
@@ -677,7 +684,7 @@
  * @b:		boot sector to parse
  *
  * Parse the ntfs boot sector @b and store all imporant information therein in
- * the ntfs super block @vol. Return TRUE on success and FALSE on error.
+ * the ntfs super block @vol.  Return TRUE on success and FALSE on error.
  */
 static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b)
 {
@@ -710,12 +717,12 @@
 			vol->cluster_size_bits, vol->cluster_size_bits);
 	if (vol->sector_size > vol->cluster_size) {
 		ntfs_error(vol->sb, "Sector sizes above the cluster size are "
-				"not supported. Sorry.");
+				"not supported.  Sorry.");
 		return FALSE;
 	}
 	if (vol->sb->s_blocksize > vol->cluster_size) {
 		ntfs_error(vol->sb, "Cluster sizes smaller than the device "
-				"sector size are not supported. Sorry.");
+				"sector size are not supported.  Sorry.");
 		return FALSE;
 	}
 	clusters_per_mft_record = b->clusters_per_mft_record;
@@ -739,6 +746,18 @@
 			vol->mft_record_size_mask);
 	ntfs_debug("vol->mft_record_size_bits = %i (0x%x)",
 			vol->mft_record_size_bits, vol->mft_record_size_bits);
+	/*
+	 * We cannot support mft record sizes above the PAGE_CACHE_SIZE since
+	 * we store $MFT/$DATA, the table of mft records in the page cache.
+	 */
+	if (vol->mft_record_size > PAGE_CACHE_SIZE) {
+		ntfs_error(vol->sb, "Mft record size %i (0x%x) exceeds the "
+				"page cache size on your system %lu (0x%lx).  "
+				"This is not supported.  Sorry.",
+				vol->mft_record_size, vol->mft_record_size,
+				PAGE_CACHE_SIZE, PAGE_CACHE_SIZE);
+		return FALSE;
+	}
 	clusters_per_index_record = b->clusters_per_index_record;
 	ntfs_debug("clusters_per_index_record = %i (0x%x)",
 			clusters_per_index_record, clusters_per_index_record);
@@ -769,7 +788,7 @@
 	 */
 	ll = sle64_to_cpu(b->number_of_sectors) >> sectors_per_cluster_bits;
 	if ((u64)ll >= 1ULL << 32) {
-		ntfs_error(vol->sb, "Cannot handle 64-bit clusters. Sorry.");
+		ntfs_error(vol->sb, "Cannot handle 64-bit clusters.  Sorry.");
 		return FALSE;
 	}
 	vol->nr_clusters = ll;
@@ -782,8 +801,8 @@
 	if (sizeof(unsigned long) < 8) {
 		if ((ll << vol->cluster_size_bits) >= (1ULL << 41)) {
 			ntfs_error(vol->sb, "Volume size (%lluTiB) is too "
-					"large for this architecture. Maximum "
-					"supported is 2TiB. Sorry.",
+					"large for this architecture.  "
+					"Maximum supported is 2TiB.  Sorry.",
 					(unsigned long long)ll >> (40 -
 					vol->cluster_size_bits));
 			return FALSE;
@@ -791,14 +810,14 @@
 	}
 	ll = sle64_to_cpu(b->mft_lcn);
 	if (ll >= vol->nr_clusters) {
-		ntfs_error(vol->sb, "MFT LCN is beyond end of volume. Weird.");
+		ntfs_error(vol->sb, "MFT LCN is beyond end of volume.  Weird.");
 		return FALSE;
 	}
 	vol->mft_lcn = ll;
 	ntfs_debug("vol->mft_lcn = 0x%llx", (long long)vol->mft_lcn);
 	ll = sle64_to_cpu(b->mftmirr_lcn);
 	if (ll >= vol->nr_clusters) {
-		ntfs_error(vol->sb, "MFTMirr LCN is beyond end of volume. "
+		ntfs_error(vol->sb, "MFTMirr LCN is beyond end of volume.  "
 				"Weird.");
 		return FALSE;
 	}
@@ -827,12 +846,12 @@
 }
 
 /**
- * setup_lcn_allocator - initialize the cluster allocator
- * @vol:	volume structure for which to setup the lcn allocator
+ * ntfs_setup_allocators - initialize the cluster and mft allocators
+ * @vol:	volume structure for which to setup the allocators
  *
- * Setup the cluster (lcn) allocator to the starting values.
+ * Setup the cluster (lcn) and mft allocators to the starting values.
  */
-static void setup_lcn_allocator(ntfs_volume *vol)
+static void ntfs_setup_allocators(ntfs_volume *vol)
 {
 #ifdef NTFS_RW
 	LCN mft_zone_size, mft_lcn;
@@ -902,6 +921,11 @@
 	vol->data2_zone_pos = 0;
 	ntfs_debug("vol->data2_zone_pos = 0x%llx",
 			(unsigned long long)vol->data2_zone_pos);
+
+	/* Set the mft data allocation position to mft record 24. */
+	vol->mft_data_pos = 24;
+	ntfs_debug("vol->mft_data_pos = 0x%llx",
+			(unsigned long long)vol->mft_data_pos);
 #endif /* NTFS_RW */
 }
 
@@ -938,8 +962,8 @@
 	/* No VFS initiated operations allowed for $MFTMirr. */
 	tmp_ino->i_op = &ntfs_empty_inode_ops;
 	tmp_ino->i_fop = &ntfs_empty_file_ops;
-	/* Put back our special address space operations. */
-	tmp_ino->i_mapping->a_ops = &ntfs_mft_aops;
+	/* Put in our special address space operations. */
+	tmp_ino->i_mapping->a_ops = &ntfs_mst_aops;
 	tmp_ni = NTFS_I(tmp_ino);
 	/* The $MFTMirr, like the $MFT is multi sector transfer protected. */
 	NInoSetMstProtected(tmp_ni);
@@ -959,6 +983,10 @@
  * @vol:	ntfs super block describing device whose mft mirror to check
  *
  * Return TRUE on success or FALSE on error.
+ *
+ * Note, this function also results in the mft mirror runlist being completely
+ * mapped into memory.  The mft mirror write code requires this and will BUG()
+ * should it find an unmapped runlist element.
  */
 static BOOL check_mft_mirror(ntfs_volume *vol)
 {
@@ -2155,7 +2183,7 @@
 /**
  * The complete super operations.
  */
-struct super_operations ntfs_sops = {
+static struct super_operations ntfs_sops = {
 	.alloc_inode	= ntfs_alloc_big_inode,	  /* VFS: Allocate new inode. */
 	.destroy_inode	= ntfs_destroy_big_inode, /* VFS: Deallocate inode. */
 	.put_inode	= ntfs_put_inode,	  /* VFS: Called just before
@@ -2334,8 +2362,8 @@
 	 */
 	result = parse_ntfs_boot_sector(vol, (NTFS_BOOT_SECTOR*)bh->b_data);
 
-	/* Initialize the cluster allocator. */
-	setup_lcn_allocator(vol);
+	/* Initialize the cluster and mft allocators. */
+	ntfs_setup_allocators(vol);
 
 	brelse(bh);
 
@@ -2573,10 +2601,6 @@
 kmem_cache_t *ntfs_attr_ctx_cache;
 kmem_cache_t *ntfs_index_ctx_cache;
 
-/* A global default upcase table and a corresponding reference count. */
-ntfschar *default_upcase = NULL;
-unsigned long ntfs_nr_upcase_users = 0;
-
 /* Driver wide semaphore. */
 DECLARE_MUTEX(ntfs_lock);
 
@@ -2734,6 +2758,7 @@
 
 MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>");
 MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2004 Anton Altaparmakov");
+MODULE_VERSION(NTFS_VERSION);
 MODULE_LICENSE("GPL");
 #ifdef DEBUG
 module_param(debug_msgs, bool, 0);
diff -Nru a/fs/ntfs/types.h b/fs/ntfs/types.h
--- a/fs/ntfs/types.h	2004-12-24 13:37:18 -08:00
+++ b/fs/ntfs/types.h	2004-12-24 13:37:18 -08:00
@@ -53,34 +53,6 @@
 typedef s64 LSN;
 typedef sle64 leLSN;
 
-/**
- * runlist_element - in memory vcn to lcn mapping array element
- * @vcn:	starting vcn of the current array element
- * @lcn:	starting lcn of the current array element
- * @length:	length in clusters of the current array element
- *
- * The last vcn (in fact the last vcn + 1) is reached when length == 0.
- *
- * When lcn == -1 this means that the count vcns starting at vcn are not
- * physically allocated (i.e. this is a hole / data is sparse).
- */
-typedef struct {	/* In memory vcn to lcn mapping structure element. */
-	VCN vcn;	/* vcn = Starting virtual cluster number. */
-	LCN lcn;	/* lcn = Starting logical cluster number. */
-	s64 length;	/* Run length in clusters. */
-} runlist_element;
-
-/**
- * runlist - in memory vcn to lcn mapping array including a read/write lock
- * @rl:		pointer to an array of runlist elements
- * @lock:	read/write spinlock for serializing access to @rl
- *
- */
-typedef struct {
-	runlist_element *rl;
-	struct rw_semaphore lock;
-} runlist;
-
 typedef enum {
 	FALSE = 0,
 	TRUE = 1
diff -Nru a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c
--- a/fs/ntfs/unistr.c	2004-12-24 13:37:01 -08:00
+++ b/fs/ntfs/unistr.c	2004-12-24 13:37:01 -08:00
@@ -19,6 +19,8 @@
  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "types.h"
+#include "debug.h"
 #include "ntfs.h"
 
 /*
diff -Nru a/fs/ntfs/upcase.c b/fs/ntfs/upcase.c
--- a/fs/ntfs/upcase.c	2004-12-24 13:36:17 -08:00
+++ b/fs/ntfs/upcase.c	2004-12-24 13:36:17 -08:00
@@ -24,6 +24,7 @@
  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "malloc.h"
 #include "ntfs.h"
 
 ntfschar *generate_default_upcase(void)
diff -Nru a/fs/ntfs/volume.h b/fs/ntfs/volume.h
--- a/fs/ntfs/volume.h	2004-12-24 13:36:18 -08:00
+++ b/fs/ntfs/volume.h	2004-12-24 13:36:18 -08:00
@@ -24,6 +24,8 @@
 #ifndef _LINUX_NTFS_VOLUME_H
 #define _LINUX_NTFS_VOLUME_H
 
+#include <linux/rwsem.h>
+
 #include "types.h"
 #include "layout.h"
 
@@ -81,6 +83,8 @@
 
 #ifdef NTFS_RW
 	/* Variables used by the cluster and mft allocators. */
+	s64 mft_data_pos;		/* Mft record number at which to
+					   allocate the next mft record. */
 	LCN mft_zone_start;		/* First cluster of the mft zone. */
 	LCN mft_zone_end;		/* First cluster beyond the mft zone. */
 	LCN mft_zone_pos;		/* Current position in the mft zone. */
diff -Nru a/fs/open.c b/fs/open.c
--- a/fs/open.c	2004-12-24 13:36:17 -08:00
+++ b/fs/open.c	2004-12-24 13:36:17 -08:00
@@ -22,6 +22,7 @@
 #include <asm/uaccess.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
+#include <linux/syscalls.h>
 
 #include <asm/unistd.h>
 
@@ -852,7 +853,7 @@
 	 * N.B. For clone tasks sharing a files structure, this test
 	 * will limit the total number of files that can be opened.
 	 */
-	if (fd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
+	if (fd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
 		goto out;
 
 	/* Do we need to expand the fdset array? */
diff -Nru a/fs/partitions/Kconfig b/fs/partitions/Kconfig
--- a/fs/partitions/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/fs/partitions/Kconfig	2004-12-24 13:37:19 -08:00
@@ -16,31 +16,31 @@
 
 config ACORN_PARTITION
 	bool "Acorn partition support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && ARCH_ACORN
+	default y if ARCH_ACORN
 	help
 	  Support hard disks partitioned under Acorn operating systems.
 
 config ACORN_PARTITION_CUMANA
 	bool "Cumana partition support" if PARTITION_ADVANCED && ACORN_PARTITION
-	default y if !PARTITION_ADVANCED && ARCH_ACORN
+	default y if ARCH_ACORN
 	help
 	  Say Y here if you would like to use hard disks under Linux which
 	  were partitioned using the Cumana interface on Acorn machines.
 
 config ACORN_PARTITION_EESOX
 	bool "EESOX partition support" if PARTITION_ADVANCED && ACORN_PARTITION
-	default y if !PARTITION_ADVANCED && ARCH_ACORN
+	default y if ARCH_ACORN
 
 config ACORN_PARTITION_ICS
 	bool "ICS partition support" if PARTITION_ADVANCED && ACORN_PARTITION
-	default y if !PARTITION_ADVANCED && ARCH_ACORN
+	default y if ARCH_ACORN
 	help
 	  Say Y here if you would like to use hard disks under Linux which
 	  were partitioned using the ICS interface on Acorn machines.
 
 config ACORN_PARTITION_ADFS
 	bool "Native filecore partition support" if PARTITION_ADVANCED && ACORN_PARTITION
-	default y if !PARTITION_ADVANCED && ARCH_ACORN
+	default y if ARCH_ACORN
 	help
 	  The Acorn Disc Filing System is the standard file system of the
 	  RiscOS operating system which runs on Acorn's ARM-based Risc PC
@@ -49,14 +49,14 @@
 
 config ACORN_PARTITION_POWERTEC
 	bool "PowerTec partition support" if PARTITION_ADVANCED && ACORN_PARTITION
-	default y if !PARTITION_ADVANCED && ARCH_ACORN
+	default y if ARCH_ACORN
 	help
 	  Support reading partition tables created on Acorn machines using
 	  the PowerTec SCSI drive.
 
 config ACORN_PARTITION_RISCIX
 	bool "RISCiX partition support" if PARTITION_ADVANCED && ACORN_PARTITION
-	default y if !PARTITION_ADVANCED && ARCH_ACORN
+	default y if ARCH_ACORN
 	help
 	  Once upon a time, there was a native Unix port for the Acorn series
 	  of machines called RISCiX.  If you say 'Y' here, Linux will be able
@@ -64,21 +64,21 @@
 
 config OSF_PARTITION
 	bool "Alpha OSF partition support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && ALPHA
+	default y if ALPHA
 	help
 	  Say Y here if you would like to use hard disks under Linux which
 	  were partitioned on an Alpha machine.
 
 config AMIGA_PARTITION
 	bool "Amiga partition table support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && (AMIGA || AFFS_FS=y)
+	default y if (AMIGA || AFFS_FS=y)
 	help
 	  Say Y here if you would like to use hard disks under Linux which
 	  were partitioned under AmigaOS.
 
 config ATARI_PARTITION
 	bool "Atari partition table support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && ATARI
+	default y if ATARI
 	help
 	  Say Y here if you would like to use hard disks under Linux which
 	  were partitioned under the Atari OS.
@@ -93,17 +93,16 @@
 
 config MAC_PARTITION
 	bool "Macintosh partition map support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && MAC
+	default y if MAC
 	help
 	  Say Y here if you would like to use hard disks under Linux which
 	  were partitioned on a Macintosh.
 
 config MSDOS_PARTITION
 	bool "PC BIOS (MSDOS partition tables) support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && !AMIGA && !ATARI && !MAC && !SGI_IP22 && !ARM && !SGI_IP27
+	default y
 	help
-	  Say Y here if you would like to use hard disks under Linux which
-	  were partitioned on an x86 PC (not necessarily by DOS).
+	  Say Y here.
 
 config BSD_DISKLABEL
 	bool "BSD disklabel (FreeBSD partition tables) support"
@@ -189,14 +188,14 @@
 
 config SGI_PARTITION
 	bool "SGI partition support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && (SGI_IP22 || SGI_IP27)
+	default y if (SGI_IP22 || SGI_IP27)
 	help
 	  Say Y here if you would like to be able to read the hard disk
 	  partition table format used by SGI machines.
 
 config ULTRIX_PARTITION
 	bool "Ultrix partition table support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && DECSTATION
+	default y if DECSTATION
 	help
 	  Say Y here if you would like to be able to read the hard disk
 	  partition table format used by DEC (now Compaq) Ultrix machines.
@@ -204,7 +203,7 @@
 
 config SUN_PARTITION
 	bool "Sun partition tables support" if PARTITION_ADVANCED
-	default y if !PARTITION_ADVANCED && (SPARC32 || SPARC64)
+	default y if (SPARC32 || SPARC64)
 	---help---
 	  Like most systems, SunOS uses its own hard disk partition table
 	  format, incompatible with all others. Saying Y here allows you to
diff -Nru a/fs/partitions/check.c b/fs/partitions/check.c
--- a/fs/partitions/check.c	2004-12-24 13:37:19 -08:00
+++ b/fs/partitions/check.c	2004-12-24 13:37:19 -08:00
@@ -325,10 +325,8 @@
 /* Not exported, helper to add_disk(). */
 void register_disk(struct gendisk *disk)
 {
-	struct parsed_partitions *state;
 	struct block_device *bdev;
 	char *s;
-	int j;
 	int err;
 
 	strlcpy(disk->kobj.name,disk->disk_name,KOBJ_NAME_LEN);
@@ -358,24 +356,9 @@
 	if (!bdev)
 		return;
 
+	bdev->bd_invalidated = 1;
 	if (blkdev_get(bdev, FMODE_READ, 0) < 0)
 		return;
-	state = check_partition(disk, bdev);
-	if (state) {
-		for (j = 1; j < state->limit; j++) {
-			sector_t size = state->parts[j].size;
-			sector_t from = state->parts[j].from;
-			if (!size)
-				continue;
-			add_partition(disk, j, from, size);
-#ifdef CONFIG_BLK_DEV_MD
-			if (!state->parts[j].flags)
-				continue;
-			md_autodetect_dev(bdev->bd_dev+j);
-#endif
-		}
-		kfree(state);
-	}
 	blkdev_put(bdev);
 }
 
@@ -395,7 +378,7 @@
 	if (disk->fops->revalidate_disk)
 		disk->fops->revalidate_disk(disk);
 	if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
-		return -EIO;
+		return 0;
 	for (p = 1; p < state->limit; p++) {
 		sector_t size = state->parts[p].size;
 		sector_t from = state->parts[p].from;
diff -Nru a/fs/partitions/devfs.c b/fs/partitions/devfs.c
--- a/fs/partitions/devfs.c	2004-12-24 13:37:33 -08:00
+++ b/fs/partitions/devfs.c	2004-12-24 13:37:33 -08:00
@@ -5,7 +5,7 @@
 #include <linux/devfs_fs_kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/genhd.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/semaphore.h>
 
 
diff -Nru a/fs/partitions/efi.c b/fs/partitions/efi.c
--- a/fs/partitions/efi.c	2004-12-24 13:36:55 -08:00
+++ b/fs/partitions/efi.c	2004-12-24 13:36:55 -08:00
@@ -3,7 +3,7 @@
  * Per Intel EFI Specification v1.02
  * http://developer.intel.com/technology/efi/efi.htm
  * efi.[ch] by Matt Domsch <Matt_Domsch@dell.com>
- *   Copyright 2000,2001,2002 Dell Inc.
+ *   Copyright 2000,2001,2002,2004 Dell 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
@@ -23,6 +23,11 @@
  * TODO:
  *
  * Changelog:
+ * Mon Nov 09 2004 Matt Domsch <Matt_Domsch@dell.com>
+ * - test for valid PMBR and valid PGPT before ever reading
+ *   AGPT, allow override with 'gpt' kernel command line option.
+ * - check for first/last_usable_lba outside of size of disk
+ *
  * Tue  Mar 26 2002 Matt Domsch <Matt_Domsch@dell.com>
  * - Ported to 2.5.7-pre1 and 2.5.7-dj2
  * - Applied patch to avoid fault in alternate header handling
@@ -131,32 +136,6 @@
 }
 
 /**
- * is_pmbr_valid(): test Protective MBR for validity
- * @mbr: pointer to a legacy mbr structure
- *
- * Description: Returns 1 if PMBR is valid, 0 otherwise.
- * Validity depends on two things:
- *  1) MSDOS signature is in the last two bytes of the MBR
- *  2) One partition of type 0xEE is found
- */
-static int
-is_pmbr_valid(legacy_mbr *mbr)
-{
-	int i, found = 0, signature = 0;
-	if (!mbr)
-		return 0;
-	signature = (le16_to_cpu(mbr->signature) == MSDOS_MBR_SIGNATURE);
-	for (i = 0; signature && i < 4; i++) {
-		if (mbr->partition_record[i].sys_ind ==
-                    EFI_PMBR_OSTYPE_EFI_GPT) {
-			found = 1;
-			break;
-		}
-	}
-	return (signature && found);
-}
-
-/**
  * last_lba(): return number of last logical block of device
  * @bdev: block device
  * 
@@ -168,7 +147,40 @@
 static u64
 last_lba(struct block_device *bdev)
 {
-	return (bdev->bd_inode->i_size >> 9) - 1;
+	if (!bdev || !bdev->bd_inode)
+		return 0;
+	return (bdev->bd_inode->i_size >> 9) - 1ULL;
+}
+
+static inline int
+pmbr_part_valid(struct partition *part, u64 lastlba)
+{
+        if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT &&
+            le32_to_cpu(part->start_sect) == 1UL)
+                return 1;
+        return 0;
+}
+
+/**
+ * is_pmbr_valid(): test Protective MBR for validity
+ * @mbr: pointer to a legacy mbr structure
+ * @lastlba: last_lba for the whole device
+ *
+ * Description: Returns 1 if PMBR is valid, 0 otherwise.
+ * Validity depends on two things:
+ *  1) MSDOS signature is in the last two bytes of the MBR
+ *  2) One partition of type 0xEE is found
+ */
+static int
+is_pmbr_valid(legacy_mbr *mbr, u64 lastlba)
+{
+	int i;
+	if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE)
+                return 0;
+	for (i = 0; i < 4; i++)
+		if (pmbr_part_valid(&mbr->partition_record[i], lastlba))
+                        return 1;
+	return 0;
 }
 
 /**
@@ -186,8 +198,8 @@
 {
 	size_t totalreadcount = 0;
 
-	if (!bdev || !buffer)
-		return 0;
+	if (!bdev || !buffer || lba > last_lba(bdev))
+                return 0;
 
 	while (count) {
 		int copied = 512;
@@ -206,7 +218,6 @@
 	return totalreadcount;
 }
 
-
 /**
  * alloc_read_gpt_entries(): reads partition entries from disk
  * @bdev
@@ -289,6 +300,7 @@
 	     gpt_header **gpt, gpt_entry **ptes)
 {
 	u32 crc, origcrc;
+	u64 lastlba;
 
 	if (!bdev || !gpt || !ptes)
 		return 0;
@@ -301,9 +313,7 @@
 			"%lld != %lld\n",
 			(unsigned long long)le64_to_cpu((*gpt)->signature),
 			(unsigned long long)GPT_HEADER_SIGNATURE);
-		kfree(*gpt);
-		*gpt = NULL;
-		return 0;
+		goto fail;
 	}
 
 	/* Check the GUID Partition Table CRC */
@@ -315,9 +325,7 @@
 		Dprintk
 		    ("GUID Partition Table Header CRC is wrong: %x != %x\n",
 		     crc, origcrc);
-		kfree(*gpt);
-		*gpt = NULL;
-		return 0;
+		goto fail;
 	}
 	(*gpt)->header_crc32 = cpu_to_le32(origcrc);
 
@@ -327,16 +335,28 @@
 		Dprintk("GPT my_lba incorrect: %lld != %lld\n",
 			(unsigned long long)le64_to_cpu((*gpt)->my_lba),
 			(unsigned long long)lba);
-		kfree(*gpt);
-		*gpt = NULL;
-		return 0;
+		goto fail;
 	}
 
-	if (!(*ptes = alloc_read_gpt_entries(bdev, *gpt))) {
-		kfree(*gpt);
-		*gpt = NULL;
-		return 0;
+	/* Check the first_usable_lba and last_usable_lba are
+	 * within the disk.
+	 */
+	lastlba = last_lba(bdev);
+	if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) {
+		Dprintk("GPT: first_usable_lba incorrect: %lld > %lld\n",
+			(unsigned long long)le64_to_cpu((*gpt)->first_usable_lba),
+			(unsigned long long)lastlba);
+		goto fail;
 	}
+	if (le64_to_cpu((*gpt)->last_usable_lba) > lastlba) {
+		Dprintk("GPT: last_usable_lba incorrect: %lld > %lld\n",
+			(unsigned long long)le64_to_cpu((*gpt)->last_usable_lba),
+			(unsigned long long)lastlba);
+		goto fail;
+	}
+
+	if (!(*ptes = alloc_read_gpt_entries(bdev, *gpt)))
+		goto fail;
 
 	/* Check the GUID Partition Entry Array CRC */
 	crc = efi_crc32((const unsigned char *) (*ptes),
@@ -345,15 +365,36 @@
 
 	if (crc != le32_to_cpu((*gpt)->partition_entry_array_crc32)) {
 		Dprintk("GUID Partitition Entry Array CRC check failed.\n");
-		kfree(*gpt);
-		*gpt = NULL;
-		kfree(*ptes);
-		*ptes = NULL;
-		return 0;
+		goto fail_ptes;
 	}
 
 	/* We're done, all's well */
 	return 1;
+
+ fail_ptes:
+	kfree(*ptes);
+	*ptes = NULL;
+ fail:
+	kfree(*gpt);
+	*gpt = NULL;
+	return 0;
+}
+
+/**
+ * is_pte_valid() - tests one PTE for validity
+ * @pte is the pte to check
+ * @lastlba is last lba of the disk
+ *
+ * Description: returns 1 if valid,  0 on error.
+ */
+static inline int
+is_pte_valid(const gpt_entry *pte, const u64 lastlba)
+{
+	if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) ||
+	    le64_to_cpu(pte->starting_lba) > lastlba         ||
+	    le64_to_cpu(pte->ending_lba)   > lastlba)
+		return 0;
+	return 1;
 }
 
 /**
@@ -464,8 +505,13 @@
  * @ptes is a PTEs ptr, filled on return.
  * Description: Returns 1 if valid, 0 on error.
  * If valid, returns pointers to newly allocated GPT header and PTEs.
- * Validity depends on finding either the Primary GPT header and PTEs valid,
- * or the Alternate GPT header and PTEs valid, and the PMBR valid.
+ * Validity depends on PMBR being valid (or being overridden by the
+ * 'gpt' kernel command line option) and finding either the Primary
+ * GPT header and PTEs valid, or the Alternate GPT header and PTEs
+ * valid.  If the Primary GPT header is not valid, the Alternate GPT header
+ * is not checked unless the 'gpt' kernel command line option is passed.
+ * This protects against devices which misreport their size, and forces
+ * the user to decide to use the Alternate GPT.
  */
 static int
 find_valid_gpt(struct block_device *bdev, gpt_header **gpt, gpt_entry **ptes)
@@ -479,70 +525,43 @@
 		return 0;
 
 	lastlba = last_lba(bdev);
+        if (!force_gpt) {
+                /* This will be added to the EFI Spec. per Intel after v1.02. */
+                legacymbr = kmalloc(sizeof (*legacymbr), GFP_KERNEL);
+                if (legacymbr) {
+                        memset(legacymbr, 0, sizeof (*legacymbr));
+                        read_lba(bdev, 0, (u8 *) legacymbr,
+                                 sizeof (*legacymbr));
+                        good_pmbr = is_pmbr_valid(legacymbr, lastlba);
+                        kfree(legacymbr);
+                        legacymbr=NULL;
+                }
+                if (!good_pmbr)
+                        goto fail;
+        }
+
 	good_pgpt = is_gpt_valid(bdev, GPT_PRIMARY_PARTITION_TABLE_LBA,
 				 &pgpt, &pptes);
-        if (good_pgpt) {
+        if (good_pgpt)
 		good_agpt = is_gpt_valid(bdev,
-                                         le64_to_cpu(pgpt->alternate_lba),
+					 le64_to_cpu(pgpt->alternate_lba),
 					 &agpt, &aptes);
-                if (!good_agpt) {
-                        good_agpt = is_gpt_valid(bdev, lastlba,
-                                                 &agpt, &aptes);
-                }
-        }
-        else {
+        if (!good_agpt && force_gpt)
                 good_agpt = is_gpt_valid(bdev, lastlba,
                                          &agpt, &aptes);
-        }
 
         /* The obviously unsuccessful case */
-        if (!good_pgpt && !good_agpt) {
-                goto fail;
-        }
-
-	/* This will be added to the EFI Spec. per Intel after v1.02. */
-        legacymbr = kmalloc(sizeof (*legacymbr), GFP_KERNEL);
-        if (legacymbr) {
-                memset(legacymbr, 0, sizeof (*legacymbr));
-                read_lba(bdev, 0, (u8 *) legacymbr,
-                         sizeof (*legacymbr));
-                good_pmbr = is_pmbr_valid(legacymbr);
-                kfree(legacymbr);
-                legacymbr=NULL;
-        }
-
-        /* Failure due to bad PMBR */
-        if ((good_pgpt || good_agpt) && !good_pmbr && !force_gpt) {
-                printk(KERN_WARNING 
-                       "  Warning: Disk has a valid GPT signature "
-                       "but invalid PMBR.\n");
-                printk(KERN_WARNING
-                       "  Assuming this disk is *not* a GPT disk anymore.\n");
-                printk(KERN_WARNING
-                       "  Use gpt kernel option to override.  "
-                       "Use GNU Parted to correct disk.\n");
+        if (!good_pgpt && !good_agpt)
                 goto fail;
-        }
-
-        /* Would fail due to bad PMBR, but force GPT anyhow */
-        if ((good_pgpt || good_agpt) && !good_pmbr && force_gpt) {
-                printk(KERN_WARNING
-                       "  Warning: Disk has a valid GPT signature but "
-                       "invalid PMBR.\n");
-                printk(KERN_WARNING
-                       "  Use GNU Parted to correct disk.\n");
-                printk(KERN_WARNING
-                       "  gpt option taken, disk treated as GPT.\n");
-        }
 
         compare_gpts(pgpt, agpt, lastlba);
 
         /* The good cases */
-        if (good_pgpt && (good_pmbr || force_gpt)) {
+        if (good_pgpt) {
                 *gpt  = pgpt;
                 *ptes = pptes;
-                if (agpt)  { kfree(agpt);   agpt = NULL; }
-                if (aptes) { kfree(aptes); aptes = NULL; }
+                kfree(agpt);
+                kfree(aptes);
                 if (!good_agpt) {
                         printk(KERN_WARNING 
 			       "Alternate GPT is invalid, "
@@ -550,21 +569,21 @@
                 }
                 return 1;
         }
-        else if (good_agpt && (good_pmbr || force_gpt)) {
+        else if (good_agpt) {
                 *gpt  = agpt;
                 *ptes = aptes;
-                if (pgpt)  { kfree(pgpt);   pgpt = NULL; }
-                if (pptes) { kfree(pptes); pptes = NULL; }
+                kfree(pgpt);
+                kfree(pptes);
                 printk(KERN_WARNING 
                        "Primary GPT is invalid, using alternate GPT.\n");
                 return 1;
         }
 
  fail:
-        if (pgpt)  { kfree(pgpt);   pgpt=NULL; }
-        if (agpt)  { kfree(agpt);   agpt=NULL; }
-        if (pptes) { kfree(pptes); pptes=NULL; }
-        if (aptes) { kfree(aptes); aptes=NULL; }
+        kfree(pgpt);
+        kfree(agpt);
+        kfree(pptes);
+        kfree(aptes);
         *gpt = NULL;
         *ptes = NULL;
         return 0;
@@ -606,15 +625,15 @@
 	Dprintk("GUID Partition Table is valid!  Yea!\n");
 
 	for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) {
-		if (!efi_guidcmp(ptes[i].partition_type_guid, NULL_GUID))
+		if (!is_pte_valid(&ptes[i], last_lba(bdev)))
 			continue;
 
 		put_partition(state, i+1, le64_to_cpu(ptes[i].starting_lba),
 				 (le64_to_cpu(ptes[i].ending_lba) -
                                   le64_to_cpu(ptes[i].starting_lba) +
-				  1));
+				  1ULL));
 
-		/* If there's this is a RAID volume, tell md */
+		/* If this is a RAID volume, tell md */
 		if (!efi_guidcmp(ptes[i].partition_type_guid,
 				 PARTITION_LINUX_RAID_GUID))
 			state->parts[i+1].flags = 1;
@@ -624,22 +643,3 @@
 	printk("\n");
 	return 1;
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-indent-level: 4
- * c-brace-imaginary-offset: 0
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * c-continued-statement-offset: 4
- * c-continued-brace-offset: 0
- * indent-tabs-mode: nil
- * tab-width: 8
- * End:
- */
diff -Nru a/fs/partitions/msdos.c b/fs/partitions/msdos.c
--- a/fs/partitions/msdos.c	2004-12-24 13:37:00 -08:00
+++ b/fs/partitions/msdos.c	2004-12-24 13:37:00 -08:00
@@ -374,6 +374,7 @@
 	{MINIX_PARTITION, parse_minix},
 	{UNIXWARE_PARTITION, parse_unixware},
 	{SOLARIS_X86_PARTITION, parse_solaris_x86},
+	{NEW_SOLARIS_X86_PARTITION, parse_solaris_x86},
 	{0, NULL},
 };
  
diff -Nru a/fs/pipe.c b/fs/pipe.c
--- a/fs/pipe.c	2004-12-24 13:36:55 -08:00
+++ b/fs/pipe.c	2004-12-24 13:36:55 -08:00
@@ -718,5 +718,5 @@
 	mntput(pipe_mnt);
 }
 
-module_init(init_pipe_fs)
-module_exit(exit_pipe_fs)
+fs_initcall(init_pipe_fs);
+module_exit(exit_pipe_fs);
diff -Nru a/fs/posix_acl.c b/fs/posix_acl.c
--- a/fs/posix_acl.c	2004-12-24 13:37:29 -08:00
+++ b/fs/posix_acl.c	2004-12-24 13:37:29 -08:00
@@ -29,7 +29,6 @@
 EXPORT_SYMBOL(posix_acl_from_mode);
 EXPORT_SYMBOL(posix_acl_create_masq);
 EXPORT_SYMBOL(posix_acl_chmod_masq);
-EXPORT_SYMBOL(posix_acl_masq_nfs_mode);
 EXPORT_SYMBOL(posix_acl_permission);
 
 /*
@@ -377,47 +376,6 @@
 			return -EIO;
 		group_obj->e_perm = (mode & S_IRWXG) >> 3;
 	}
-
-	return 0;
-}
-
-/*
- * Adjust the mode parameter so that NFSv2 grants nobody permissions
- * that may not be granted by the ACL. This is necessary because NFSv2
- * may compute access permissions on the client side, and may serve cached
- * data whenever it assumes access would be granted.  Since ACLs may also
- * be used to deny access to specific users, the minimal permissions
- * for secure operation over NFSv2 are very restrictive. Permissions
- * granted to users via Access Control Lists will not be effective over
- * NFSv2.
- *
- * Privilege escalation can only happen for read operations, as writes are
- * always carried out on the NFS server, where the proper access checks are
- * implemented.
- */
-int
-posix_acl_masq_nfs_mode(struct posix_acl *acl, mode_t *mode_p)
-{
-	struct posix_acl_entry *pa, *pe; int min_perm = S_IRWXO;
-
-	FOREACH_ACL_ENTRY(pa, acl, pe) {
-                switch(pa->e_tag) {
-			case ACL_USER_OBJ:
-				break;
-
-			case ACL_USER:
-			case ACL_GROUP_OBJ:
-			case ACL_GROUP:
-			case ACL_MASK:
-			case ACL_OTHER:
-				min_perm &= pa->e_perm;
-				break;
-
-			default:
-				return -EIO;
-		}
-	}
-	*mode_p = (*mode_p & ~(S_IRWXG|S_IRWXO)) | (min_perm << 3) | min_perm;
 
 	return 0;
 }
diff -Nru a/fs/proc/array.c b/fs/proc/array.c
--- a/fs/proc/array.c	2004-12-24 13:37:00 -08:00
+++ b/fs/proc/array.c	2004-12-24 13:37:00 -08:00
@@ -137,13 +137,13 @@
 
 static inline const char * get_task_state(struct task_struct *tsk)
 {
-	unsigned int state = tsk->state & (TASK_RUNNING |
-					   TASK_INTERRUPTIBLE |
-					   TASK_UNINTERRUPTIBLE |
-					   TASK_ZOMBIE |
-					   TASK_DEAD |
-					   TASK_STOPPED |
-					   TASK_TRACED);
+	unsigned int state = (tsk->state & (TASK_RUNNING |
+					    TASK_INTERRUPTIBLE |
+					    TASK_UNINTERRUPTIBLE |
+					    TASK_STOPPED |
+					    TASK_TRACED)) |
+			(tsk->exit_state & (EXIT_ZOMBIE |
+					    EXIT_DEAD));
 	const char **p = &task_state_array[0];
 
 	while (state) {
@@ -171,8 +171,8 @@
 		get_task_state(p),
 		(p->sleep_avg/1024)*100/(1020000000/1024),
 	       	p->tgid,
-		p->pid, p->pid ? p->real_parent->pid : 0,
-		p->pid && p->ptrace ? p->parent->pid : 0,
+		p->pid, pid_alive(p) ? p->group_leader->real_parent->tgid : 0,
+		pid_alive(p) && p->ptrace ? p->parent->pid : 0,
 		p->uid, p->euid, p->suid, p->fsuid,
 		p->gid, p->egid, p->sgid, p->fsgid);
 	read_unlock(&tasklist_lock);
@@ -300,9 +300,9 @@
 	return buffer - orig;
 }
 
-int proc_pid_stat(struct task_struct *task, char * buffer)
+static int do_task_stat(struct task_struct *task, char * buffer, int whole)
 {
-	unsigned long vsize, eip, esp, wchan;
+	unsigned long vsize, eip, esp, wchan = ~0UL;
 	long priority, nice;
 	int tty_pgrp = -1, tty_nr = 0;
 	sigset_t sigign, sigcatch;
@@ -313,6 +313,9 @@
 	struct mm_struct *mm;
 	unsigned long long start_time;
 	unsigned long cmin_flt = 0, cmaj_flt = 0, cutime = 0, cstime = 0;
+	unsigned long  min_flt = 0,  maj_flt = 0,  utime = 0,  stime = 0;
+	unsigned long rsslim = 0;
+	struct task_struct *t;
 	char tcomm[sizeof(task->comm)];
 
 	state = *get_task_state(task);
@@ -325,7 +328,6 @@
 	}
 
 	get_task_comm(tcomm, task);
-	wchan = get_wchan(task);
 
 	sigemptyset(&sigign);
 	sigemptyset(&sigcatch);
@@ -334,6 +336,19 @@
 		spin_lock_irq(&task->sighand->siglock);
 		num_threads = atomic_read(&task->signal->count);
 		collect_sigign_sigcatch(task, &sigign, &sigcatch);
+
+		/* add up live thread stats at the group level */
+		if (whole) {
+			t = task;
+			do {
+				min_flt += t->min_flt;
+				maj_flt += t->maj_flt;
+				utime += t->utime;
+				stime += t->stime;
+				t = next_thread(t);
+			} while (t != task);
+		}
+
 		spin_unlock_irq(&task->sighand->siglock);
 	}
 	if (task->signal) {
@@ -347,18 +362,31 @@
 		cmaj_flt = task->signal->cmaj_flt;
 		cutime = task->signal->cutime;
 		cstime = task->signal->cstime;
+		rsslim = task->signal->rlim[RLIMIT_RSS].rlim_cur;
+		if (whole) {
+			min_flt += task->signal->min_flt;
+			maj_flt += task->signal->maj_flt;
+			utime += task->signal->utime;
+			stime += task->signal->stime;
+		}
 	}
+	ppid = pid_alive(task) ? task->group_leader->real_parent->tgid : 0;
 	read_unlock(&tasklist_lock);
 
+	if (!whole || num_threads<2)
+		wchan = get_wchan(task);
+	if (!whole) {
+		min_flt = task->min_flt;
+		maj_flt = task->maj_flt;
+		utime = task->utime;
+		stime = task->stime;
+	}
+
 	/* scale priority and nice values from timeslices to -20..20 */
 	/* to make it look like a "normal" Unix priority/nice value  */
 	priority = task_prio(task);
 	nice = task_nice(task);
 
-	read_lock(&tasklist_lock);
-	ppid = task->pid ? task->real_parent->pid : 0;
-	read_unlock(&tasklist_lock);
-
 	/* Temporary variable needed for gcc-2.96 */
 	/* convert timespec -> nsec*/
 	start_time = (unsigned long long)task->start_time.tv_sec * NSEC_PER_SEC
@@ -378,12 +406,12 @@
 		tty_nr,
 		tty_pgrp,
 		task->flags,
-		task->min_flt,
+		min_flt,
 		cmin_flt,
-		task->maj_flt,
+		maj_flt,
 		cmaj_flt,
-		jiffies_to_clock_t(task->utime),
-		jiffies_to_clock_t(task->stime),
+		jiffies_to_clock_t(utime),
+		jiffies_to_clock_t(stime),
 		jiffies_to_clock_t(cutime),
 		jiffies_to_clock_t(cstime),
 		priority,
@@ -393,7 +421,7 @@
 		start_time,
 		vsize,
 		mm ? mm->rss : 0, /* you might want to shift this left 3 */
-		task->rlim[RLIMIT_RSS].rlim_cur,
+	        rsslim,
 		mm ? mm->start_code : 0,
 		mm ? mm->end_code : 0,
 		mm ? mm->start_stack : 0,
@@ -417,6 +445,16 @@
 	if(mm)
 		mmput(mm);
 	return res;
+}
+
+int proc_tid_stat(struct task_struct *task, char * buffer)
+{
+	return do_task_stat(task, buffer, 0);
+}
+
+int proc_tgid_stat(struct task_struct *task, char * buffer)
+{
+	return do_task_stat(task, buffer, 1);
 }
 
 int proc_pid_statm(struct task_struct *task, char *buffer)
diff -Nru a/fs/proc/base.c b/fs/proc/base.c
--- a/fs/proc/base.c	2004-12-24 13:37:00 -08:00
+++ b/fs/proc/base.c	2004-12-24 13:37:00 -08:00
@@ -189,7 +189,8 @@
 	return PROC_I(inode)->type;
 }
 
-int proc_pid_stat(struct task_struct*,char*);
+int proc_tid_stat(struct task_struct*,char*);
+int proc_tgid_stat(struct task_struct*,char*);
 int proc_pid_status(struct task_struct*,char*);
 int proc_pid_statm(struct task_struct*,char*);
 
@@ -342,7 +343,7 @@
 	if (!mm)
 		goto out;
 	if (!mm->arg_end)
-		goto out;	/* Shh! No looking before we're done */
+		goto out_mm;	/* Shh! No looking before we're done */
 
  	len = mm->arg_end - mm->arg_start;
  
@@ -365,8 +366,8 @@
 			res = strnlen(buffer, res);
 		}
 	}
+out_mm:
 	mmput(mm);
-
 out:
 	return res;
 }
@@ -472,7 +473,7 @@
 
 static int proc_permission(struct inode *inode, int mask, struct nameidata *nd)
 {
-	if (vfs_permission(inode, mask) != 0)
+	if (generic_permission(inode, mask, NULL) != 0)
 		return -EACCES;
 	return proc_check_root(inode);
 }
@@ -779,11 +780,6 @@
 	.follow_link	= proc_pid_follow_link
 };
 
-static inline int pid_alive(struct task_struct *p)
-{
-	return p->pids[PIDTYPE_PID].nr != 0;
-}
-
 #define NUMBUF 10
 
 static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir)
@@ -1315,9 +1311,12 @@
 			ei->op.proc_read = proc_pid_status;
 			break;
 		case PROC_TID_STAT:
+			inode->i_fop = &proc_info_file_operations;
+			ei->op.proc_read = proc_tid_stat;
+			break;
 		case PROC_TGID_STAT:
 			inode->i_fop = &proc_info_file_operations;
-			ei->op.proc_read = proc_pid_stat;
+			ei->op.proc_read = proc_tgid_stat;
 			break;
 		case PROC_TID_CMDLINE:
 		case PROC_TGID_CMDLINE:
diff -Nru a/fs/proc/generic.c b/fs/proc/generic.c
--- a/fs/proc/generic.c	2004-12-24 13:37:31 -08:00
+++ b/fs/proc/generic.c	2004-12-24 13:37:31 -08:00
@@ -18,8 +18,8 @@
 #include <linux/init.h>
 #include <linux/idr.h>
 #include <linux/namei.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
-#include <asm/bitops.h>
 
 static ssize_t proc_file_read(struct file *file, char __user *buf,
 			      size_t nbytes, loff_t *ppos);
diff -Nru a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
--- a/fs/proc/proc_misc.c	2004-12-24 13:36:18 -08:00
+++ b/fs/proc/proc_misc.c	2004-12-24 13:36:18 -08:00
@@ -153,12 +153,14 @@
 				 int count, int *eof, void *data)
 {
 	struct sysinfo i;
-	int len, committed;
+	int len;
 	struct page_state ps;
 	unsigned long inactive;
 	unsigned long active;
 	unsigned long free;
 	unsigned long vmtot;
+	unsigned long committed;
+	unsigned long allowed;
 	struct vmalloc_info vmi;
 
 	get_page_state(&ps);
@@ -171,6 +173,8 @@
 	si_meminfo(&i);
 	si_swapinfo(&i);
 	committed = atomic_read(&vm_committed_space);
+	allowed = ((totalram_pages - hugetlb_total_pages())
+		* sysctl_overcommit_ratio / 100) + total_swap_pages;
 
 	vmtot = (VMALLOC_END-VMALLOC_START)>>10;
 	vmi = get_vmalloc_info();
@@ -198,7 +202,8 @@
 		"Writeback:    %8lu kB\n"
 		"Mapped:       %8lu kB\n"
 		"Slab:         %8lu kB\n"
-		"Committed_AS: %8u kB\n"
+		"CommitLimit:  %8lu kB\n"
+		"Committed_AS: %8lu kB\n"
 		"PageTables:   %8lu kB\n"
 		"VmallocTotal: %8lu kB\n"
 		"VmallocUsed:  %8lu kB\n"
@@ -220,6 +225,7 @@
 		K(ps.nr_writeback),
 		K(ps.nr_mapped),
 		K(ps.nr_slab),
+		K(allowed),
 		K(committed),
 		K(ps.nr_page_table_pages),
 		vmtot,
diff -Nru a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c
--- a/fs/proc/proc_tty.c	2004-12-24 13:36:47 -08:00
+++ b/fs/proc/proc_tty.c	2004-12-24 13:36:47 -08:00
@@ -13,7 +13,7 @@
 #include <linux/stat.h>
 #include <linux/tty.h>
 #include <linux/seq_file.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 static int tty_ldiscs_read_proc(char *page, char **start, off_t off,
 				int count, int *eof, void *data);
diff -Nru a/fs/proc/root.c b/fs/proc/root.c
--- a/fs/proc/root.c	2004-12-24 13:37:18 -08:00
+++ b/fs/proc/root.c	2004-12-24 13:37:18 -08:00
@@ -15,7 +15,7 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/smp_lock.h>
 
 struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
@@ -149,9 +149,6 @@
 	.parent		= &proc_root,
 };
 
-#ifdef CONFIG_SYSCTL
-EXPORT_SYMBOL(proc_sys_root);
-#endif
 EXPORT_SYMBOL(proc_symlink);
 EXPORT_SYMBOL(proc_mkdir);
 EXPORT_SYMBOL(create_proc_entry);
diff -Nru a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
--- a/fs/proc/task_mmu.c	2004-12-24 13:36:18 -08:00
+++ b/fs/proc/task_mmu.c	2004-12-24 13:36:18 -08:00
@@ -9,7 +9,7 @@
 	unsigned long data, text, lib;
 
 	data = mm->total_vm - mm->shared_vm - mm->stack_vm;
-	text = (mm->end_code - mm->start_code) >> 10;
+	text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) >> 10;
 	lib = (mm->exec_vm << (PAGE_SHIFT-10)) - text;
 	buffer += sprintf(buffer,
 		"VmSize:\t%8lu kB\n"
@@ -18,12 +18,14 @@
 		"VmData:\t%8lu kB\n"
 		"VmStk:\t%8lu kB\n"
 		"VmExe:\t%8lu kB\n"
-		"VmLib:\t%8lu kB\n",
+		"VmLib:\t%8lu kB\n"
+		"VmPTE:\t%8lu kB\n",
 		(mm->total_vm - mm->reserved_vm) << (PAGE_SHIFT-10),
 		mm->locked_vm << (PAGE_SHIFT-10),
 		mm->rss << (PAGE_SHIFT-10),
 		data << (PAGE_SHIFT-10),
-		mm->stack_vm << (PAGE_SHIFT-10), text, lib);
+		mm->stack_vm << (PAGE_SHIFT-10), text, lib,
+		(PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10);
 	return buffer;
 }
 
@@ -35,9 +37,10 @@
 int task_statm(struct mm_struct *mm, int *shared, int *text,
 	       int *data, int *resident)
 {
-	*shared = mm->shared_vm;
-	*text = (mm->end_code - mm->start_code) >> PAGE_SHIFT;
-	*data = mm->total_vm - mm->shared_vm - *text;
+	*shared = mm->rss - mm->anon_rss;
+	*text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
+								>> PAGE_SHIFT;
+	*data = mm->total_vm - mm->shared_vm;
 	*resident = mm->rss;
 	return mm->total_vm;
 }
diff -Nru a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c
--- a/fs/qnx4/bitmap.c	2004-12-24 13:37:43 -08:00
+++ b/fs/qnx4/bitmap.c	2004-12-24 13:37:43 -08:00
@@ -21,8 +21,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/buffer_head.h>
-
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 int qnx4_new_block(struct super_block *sb)
 {
diff -Nru a/fs/quota.c b/fs/quota.c
--- a/fs/quota.c	2004-12-24 13:37:29 -08:00
+++ b/fs/quota.c	2004-12-24 13:37:29 -08:00
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/smp_lock.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 
 /* Check validity of quotactl */
 static int check_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
diff -Nru a/fs/read_write.c b/fs/read_write.c
--- a/fs/read_write.c	2004-12-24 13:37:00 -08:00
+++ b/fs/read_write.c	2004-12-24 13:37:00 -08:00
@@ -13,6 +13,7 @@
 #include <linux/dnotify.h>
 #include <linux/security.h>
 #include <linux/module.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -145,7 +146,6 @@
 bad:
 	return retval;
 }
-EXPORT_SYMBOL_GPL(sys_lseek);
 
 #ifdef __ARCH_WANT_SYS_LLSEEK
 asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high,
diff -Nru a/fs/readdir.c b/fs/readdir.c
--- a/fs/readdir.c	2004-12-24 13:36:49 -08:00
+++ b/fs/readdir.c	2004-12-24 13:36:49 -08:00
@@ -14,6 +14,7 @@
 #include <linux/fs.h>
 #include <linux/dirent.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 #include <linux/unistd.h>
 
 #include <asm/uaccess.h>
diff -Nru a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
--- a/fs/reiserfs/bitmap.c	2004-12-24 13:37:01 -08:00
+++ b/fs/reiserfs/bitmap.c	2004-12-24 13:37:01 -08:00
@@ -137,6 +137,8 @@
     int end, next;
     int org = *beg;
 
+    BUG_ON (!th->t_trans_id);
+
     RFALSE(bmap_n >= SB_BMAP_NR (s), "Bitmap %d is out of range (0..%d)",bmap_n, SB_BMAP_NR (s) - 1);
     PROC_INFO_INC( s, scan_bitmap.bmap );
 /* this is unclear and lacks comments, explain how journal bitmaps
@@ -236,6 +238,9 @@
 	if (!bm)
 	    bm = 1;
     }
+    /* this can only be true when SB_BMAP_NR = 1 */
+    if (bm >= SB_BMAP_NR(s))
+    	bm = 0;
     return bm;
 }
 
@@ -287,12 +292,18 @@
     int end_bm, end_off;
     int off_max = s->s_blocksize << 3;
 
+    BUG_ON (!th->t_trans_id);
+
     PROC_INFO_INC( s, scan_bitmap.call ); 
     if ( SB_FREE_BLOCKS(s) <= 0)
 	return 0; // No point in looking for more free blocks
 
     get_bit_address (s, *start, &bm, &off);
     get_bit_address (s, finish, &end_bm, &end_off);
+    if (bm > SB_BMAP_NR(s))
+        return 0;
+    if (end_bm > SB_BMAP_NR(s))
+        end_bm = SB_BMAP_NR(s);
 
     /* When the bitmap is more than 10% free, anyone can allocate.
      * When it's less than 10% free, only files that already use the
@@ -313,6 +324,7 @@
 	    if (nr_allocated)
 		goto ret;
         }
+	/* we know from above that start is a reasonable number */
 	get_bit_address (s, *start, &bm, &off);
     }
 
@@ -340,6 +352,8 @@
     struct reiserfs_bitmap_info *apbi;
     int nr, offset;
 
+    BUG_ON (!th->t_trans_id);
+
     PROC_INFO_INC( s, free_block );
 
     rs = SB_DISK_SUPER_BLOCK (s);
@@ -381,6 +395,8 @@
 {
     struct super_block * s = th->t_super;
 
+    BUG_ON (!th->t_trans_id);
+
     RFALSE(!s, "vs-4061: trying to free block on nonexistent device");
     RFALSE(is_reusable (s, block, 1) == 0, "vs-4071: can not free such block");
     /* mark it before we clear it, just in case */
@@ -393,6 +409,7 @@
 			  struct inode *inode, b_blocknr_t block) {
     RFALSE(!th->t_super, "vs-4060: trying to free block on nonexistent device");
     RFALSE(is_reusable (th->t_super, block, 1) == 0, "vs-4070: can not free such block");
+    BUG_ON (!th->t_trans_id);
     _reiserfs_free_block(th, inode, block, 1) ;
 }
 
@@ -402,6 +419,7 @@
     unsigned long save = ei->i_prealloc_block ;
     int dirty = 0;
     struct inode *inode = &ei->vfs_inode;
+    BUG_ON (!th->t_trans_id);
 #ifdef CONFIG_REISERFS_CHECK
     if (ei->i_prealloc_count < 0)
 	reiserfs_warning (th->t_super, "zam-4001:%s: inode has negative prealloc blocks count.", __FUNCTION__ );
@@ -423,6 +441,7 @@
 				struct inode *inode)
 {
     struct reiserfs_inode_info *ei = REISERFS_I(inode);
+    BUG_ON (!th->t_trans_id);
     if (ei->i_prealloc_count)
 	__discard_prealloc(th, ei);
 }
@@ -431,6 +450,8 @@
 {
     struct list_head * plist = &SB_JOURNAL(th->t_super)->j_prealloc_list;
 
+    BUG_ON (!th->t_trans_id);
+
     while (!list_empty(plist)) {
 	struct reiserfs_inode_info *ei;
 	ei = list_entry(plist->next, struct reiserfs_inode_info, i_prealloc_list);
@@ -715,7 +736,7 @@
 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
 static inline void displace_new_packing_locality (reiserfs_blocknr_hint_t *hint)
 {
-    struct key * key = &hint->key;
+    struct reiserfs_key * key = &hint->key;
 
     hint->th->displace_new_blocks = 0;
     hint->search_start = hint->beg + keyed_hash((char*)(&key->k_objectid),4) % (hint->end - hint->beg);
@@ -756,7 +777,7 @@
 
 static inline void hundredth_slices (reiserfs_blocknr_hint_t * hint)
 {
-    struct key * key = &hint->key;
+    struct reiserfs_key * key = &hint->key;
     b_blocknr_t slice_start;
 
     slice_start = (keyed_hash((char*)(&key->k_dir_id),4) % 100) * (hint->end / 100);
@@ -1050,9 +1071,10 @@
 {
     int initial_amount_needed = amount_needed;
     int ret;
+    struct super_block *s = hint->th->t_super;
 
     /* Check if there is enough space, taking into account reserved space */
-    if ( SB_FREE_BLOCKS(hint->th->t_super) - REISERFS_SB(hint->th->t_super)->reserved_blocks <
+    if ( SB_FREE_BLOCKS(s) - REISERFS_SB(s)->reserved_blocks <
 	 amount_needed - reserved_by_us)
         return NO_DISK_SPACE;
     /* should this be if !hint->inode &&  hint->preallocate? */
@@ -1072,6 +1094,8 @@
 
     /* find search start and save it in hint structure */
     determine_search_start(hint, amount_needed);
+    if (hint->search_start >= SB_BLOCK_COUNT(s))
+        hint->search_start = SB_BLOCK_COUNT(s) - 1;
 
     /* allocation itself; fill new_blocknrs and preallocation arrays */
     ret = blocknrs_and_prealloc_arrays_from_search_start
diff -Nru a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
--- a/fs/reiserfs/dir.c	2004-12-24 13:36:56 -08:00
+++ b/fs/reiserfs/dir.c	2004-12-24 13:36:56 -08:00
@@ -12,7 +12,7 @@
 #include <linux/buffer_head.h>
 #include <asm/uaccess.h>
 
-extern struct key  MIN_KEY;
+extern struct reiserfs_key  MIN_KEY;
 
 static int reiserfs_readdir (struct file *, void *, filldir_t);
 int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, int datasync) ;
@@ -26,10 +26,13 @@
 
 int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, int datasync) {
   struct inode *inode = dentry->d_inode;
+  int err;
   reiserfs_write_lock(inode->i_sb);
-  reiserfs_commit_for_inode(inode) ;
+  err = reiserfs_commit_for_inode(inode) ;
   reiserfs_write_unlock(inode->i_sb) ;
-  return 0 ;
+  if (err < 0)
+      return err;
+  return 0;
 }
 
 
@@ -43,7 +46,7 @@
     INITIALIZE_PATH (path_to_entry);
     struct buffer_head * bh;
     int item_num, entry_num;
-    const struct key * rkey;
+    const struct reiserfs_key * rkey;
     struct item_head * ih, tmp_ih;
     int search_res;
     char * local_buf;
diff -Nru a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
--- a/fs/reiserfs/do_balan.c	2004-12-24 13:36:19 -08:00
+++ b/fs/reiserfs/do_balan.c	2004-12-24 13:36:19 -08:00
@@ -1341,7 +1341,7 @@
 
 static int locked_or_not_in_tree (struct buffer_head * bh, char * which)
 {
-  if ( (!reiserfs_buffer_prepared(bh) && buffer_locked (bh)) ||
+  if ( (!buffer_journal_prepared (bh) && buffer_locked (bh)) ||
         !B_IS_IN_TREE (bh) ) {
     reiserfs_warning (NULL, "vs-12339: locked_or_not_in_tree: %s (%b)",
                       which, bh);
diff -Nru a/fs/reiserfs/file.c b/fs/reiserfs/file.c
--- a/fs/reiserfs/file.c	2004-12-24 13:36:17 -08:00
+++ b/fs/reiserfs/file.c	2004-12-24 13:36:17 -08:00
@@ -35,6 +35,8 @@
 {
 
     struct reiserfs_transaction_handle th ;
+    int err;
+    int jbegin_failure = 0;
 
     if (!S_ISREG (inode->i_mode))
 	BUG ();
@@ -49,26 +51,58 @@
     
     reiserfs_write_lock(inode->i_sb);
     down (&inode->i_sem); 
-    journal_begin(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3) ;
+    /* freeing preallocation only involves relogging blocks that
+     * are already in the current transaction.  preallocation gets
+     * freed at the end of each transaction, so it is impossible for
+     * us to log any additional blocks
+     */
+    err = journal_begin(&th, inode->i_sb, 1);
+    if (err) {
+	/* uh oh, we can't allow the inode to go away while there
+	 * is still preallocation blocks pending.  Try to join the
+	 * aborted transaction
+	 */
+	jbegin_failure = err;
+	err = journal_join_abort(&th, inode->i_sb, 1);
+
+	if (err) {
+	    /* hmpf, our choices here aren't good.  We can pin the inode
+	     * which will disallow unmount from every happening, we can
+	     * do nothing, which will corrupt random memory on unmount,
+	     * or we can forcibly remove the file from the preallocation
+	     * list, which will leak blocks on disk.  Lets pin the inode
+	     * and let the admin know what is going on.
+	     */
+	    igrab(inode);
+	    reiserfs_warning(inode->i_sb, "pinning inode %lu because the "
+	                     "preallocation can't be freed");
+	    goto out;
+	}
+    }
     reiserfs_update_inode_transaction(inode) ;
 
 #ifdef REISERFS_PREALLOCATE
     reiserfs_discard_prealloc (&th, inode);
 #endif
-    journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3) ;
+    err = journal_end(&th, inode->i_sb, 1);
 
-    if (atomic_read(&inode->i_count) <= 1 &&
+    /* copy back the error code from journal_begin */
+    if (!err)
+        err = jbegin_failure;
+
+    if (!err && atomic_read(&inode->i_count) <= 1 &&
 	(REISERFS_I(inode)->i_flags & i_pack_on_close_mask) &&
         tail_has_to_be_packed (inode)) {
 	/* if regular file is released by last holder and it has been
 	   appended (we append by unformatted node only) or its direct
 	   item(s) had to be converted, then it may have to be
 	   indirect2direct converted */
-	reiserfs_truncate_file(inode, 0) ;
+	err = reiserfs_truncate_file(inode, 0) ;
     }
+out:
     up (&inode->i_sem); 
     reiserfs_write_unlock(inode->i_sb);
-    return 0;
+    return err;
 }
 
 static void reiserfs_vfs_truncate_file(struct inode *inode) {
@@ -99,6 +133,8 @@
   reiserfs_write_unlock(p_s_inode->i_sb);
   if (barrier_done != 1)
       blkdev_issue_flush(p_s_inode->i_sb->s_bdev, NULL);
+  if (barrier_done < 0)
+    return barrier_done;
   return ( n_err < 0 ) ? -EIO : 0;
 }
 
@@ -146,7 +182,6 @@
 				 // of the fact that we already prepared
 				 // current block for journal
     int will_prealloc = 0;
-
     RFALSE(!blocks_to_allocate, "green-9004: tried to allocate zero blocks?");
 
     /* only preallocate if this is a small write */
@@ -166,7 +201,9 @@
     /* If we came here, it means we absolutely need to open a transaction,
        since we need to allocate some blocks */
     reiserfs_write_lock(inode->i_sb); // Journaling stuff and we need that.
-    journal_begin(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1); // Wish I know if this number enough
+    res = journal_begin(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1); // Wish I know if this number enough
+    if (res)
+        goto error_exit;
     reiserfs_update_inode_transaction(inode) ;
 
     /* Look for the in-tree position of our write, need path for block allocator */
@@ -194,7 +231,9 @@
 	    /* We flush the transaction in case of no space. This way some
 	       blocks might become free */
 	    SB_JOURNAL(inode->i_sb)->j_must_wait = 1;
-	    restart_transaction(th, inode, &path);
+	    res = restart_transaction(th, inode, &path);
+            if (res)
+                goto error_exit;
 
 	    /* We might have scheduled, so search again */
 	    res = search_for_position_by_key(inode->i_sb, &key, &path);
@@ -322,8 +361,14 @@
 		}
 		/* Now we want to check if transaction is too full, and if it is
 		   we restart it. This will also free the path. */
-		if (journal_transaction_should_end(th, th->t_blocks_allocated))
-		    restart_transaction(th, inode, &path);
+		if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
+		    res = restart_transaction(th, inode, &path);
+                    if (res) {
+                        pathrelse (&path);
+                        kfree(zeros);
+                        goto error_exit;
+                    }
+                }
 
 		/* Well, need to recalculate path and stuff */
 		set_cpu_key_k_offset( &key, cpu_key_k_offset(&key) + (to_paste << inode->i_blkbits));
@@ -349,6 +394,7 @@
     // we are going to overwrite, so there is nothing to scan through for holes.
     for ( curr_block = 0, itempos = path.pos_in_item ; curr_block < blocks_to_allocate && res == POSITION_FOUND ; ) {
 retry:
+
 	if ( itempos >= ih_item_len(ih)/UNFM_P_SIZE ) {
 	    /* We run out of data in this indirect item, let's look for another
 	       one. */
@@ -526,8 +572,14 @@
 	reiserfs_free_block(th, inode, le32_to_cpu(allocated_blocks[i]), 1);
 
 error_exit:
-    reiserfs_update_sd(th, inode); // update any changes we made to blk count
-    journal_end(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1);
+    if (th->t_trans_id) {
+        int err;
+        // update any changes we made to blk count
+        reiserfs_update_sd(th, inode);
+        err = journal_end(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1);
+        if (err)
+            res = err;
+    }
     reiserfs_write_unlock(inode->i_sb);
     kfree(allocated_blocks);
 
@@ -602,13 +654,16 @@
     struct super_block *s = inode->i_sb;
     int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
     struct reiserfs_transaction_handle th;
-    th.t_trans_id = 0;
+    int ret = 0;
 
+    th.t_trans_id = 0;
     blocksize = 1 << inode->i_blkbits;
 
     if (logit) {
 	reiserfs_write_lock(s);
-	journal_begin(&th, s, bh_per_page + 1);
+	ret = journal_begin(&th, s, bh_per_page + 1);
+	if (ret)
+	    goto drop_write_lock;
 	reiserfs_update_inode_transaction(inode);
     }
     for(bh = head = page_buffers(page), block_start = 0;
@@ -640,7 +695,8 @@
 	}
     }
     if (logit) {
-	journal_end(&th, s, bh_per_page + 1);
+	ret = journal_end(&th, s, bh_per_page + 1);
+drop_write_lock:
 	reiserfs_write_unlock(s);
     }
     /*
@@ -651,7 +707,7 @@
      */
     if (!partial)
 	SetPageUptodate(page);
-    return 0;
+    return ret;
 }
 
 
@@ -717,7 +773,9 @@
 	reiserfs_write_lock(inode->i_sb);
 	if (!sd_update)
 	    reiserfs_update_sd(th, inode);
-	journal_end(th, th->t_super, th->t_blocks_allocated);
+	status = journal_end(th, th->t_super, th->t_blocks_allocated);
+        if (status)
+            retval = status;
 	reiserfs_write_unlock(inode->i_sb);
     }
     th->t_trans_id = 0;
@@ -1100,6 +1158,7 @@
     size_t already_written = 0; // Number of bytes already written to the file.
     loff_t pos; // Current position in the file.
     ssize_t res; // return value of various functions that we call.
+    int err = 0;
     struct inode *inode = file->f_dentry->d_inode; // Inode of the file that we are writing to.
 				/* To simplify coding at this time, we store
 				   locked pages in array for now */
@@ -1114,24 +1173,40 @@
 	       If we will crash while doing direct io, finish_unfinished will
 	       cut the garbage from the file end. */
 	    reiserfs_write_lock(inode->i_sb);
-	    journal_begin(&th, inode->i_sb,  JOURNAL_PER_BALANCE_CNT );
+	    err = journal_begin(&th, inode->i_sb,  JOURNAL_PER_BALANCE_CNT );
+            if (err) {
+		reiserfs_write_unlock (inode->i_sb);
+		return err;
+	    }
 	    reiserfs_update_inode_transaction(inode);
 	    add_save_link (&th, inode, 1 /* Truncate */);
-	    journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT );
-	    reiserfs_write_unlock(inode->i_sb);
 	    after_file_end = 1;
+	    err = journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT );
+            reiserfs_write_unlock(inode->i_sb);
+	    if (err)
+		return err;
 	}
 	result = generic_file_write(file, buf, count, ppos);
 
 	if ( after_file_end ) { /* Now update i_size and remove the savelink */
 	    struct reiserfs_transaction_handle th;
 	    reiserfs_write_lock(inode->i_sb);
-	    journal_begin(&th, inode->i_sb, 1);
+	    err = journal_begin(&th, inode->i_sb, 1);
+            if (err) {
+                reiserfs_write_unlock (inode->i_sb);
+                return err;
+            }
 	    reiserfs_update_inode_transaction(inode);
 	    reiserfs_update_sd(&th, inode);
-	    journal_end(&th, inode->i_sb, 1);
-	    remove_save_link (inode, 1/* truncate */);
+	    err = journal_end(&th, inode->i_sb, 1);
+            if (err) {
+                reiserfs_write_unlock (inode->i_sb);
+                return err;
+            }
+	    err = remove_save_link (inode, 1/* truncate */);
 	    reiserfs_write_unlock(inode->i_sb);
+            if (err)
+                return err;
 	}
 
 	return result;
@@ -1280,8 +1355,12 @@
     /* this is only true on error */
     if (th.t_trans_id) {
         reiserfs_write_lock(inode->i_sb);
-	journal_end(&th, th.t_super, th.t_blocks_allocated);
+        err = journal_end(&th, th.t_super, th.t_blocks_allocated);
         reiserfs_write_unlock(inode->i_sb);
+        if (err) {
+            res = err;
+            goto out;
+        }
     }
 
     if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
diff -Nru a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
--- a/fs/reiserfs/fix_node.c	2004-12-24 13:36:32 -08:00
+++ b/fs/reiserfs/fix_node.c	2004-12-24 13:36:32 -08:00
@@ -163,7 +163,7 @@
   
     /* set right merge flag we take right delimiting key and check whether it is a mergeable item */
     if (tb->CFR[0]) {
-	struct key * key;
+	struct reiserfs_key * key;
 
 	key = B_N_PDELIM_KEY (tb->CFR[0], tb->rkey[0]);
 	if (op_is_left_mergeable (key, Sh->b_size) && (vn->vn_mode != M_DELETE ||
@@ -820,7 +820,7 @@
     RFALSE (p_s_tb->FEB[p_s_tb->cur_blknum],
 	    "PAP-8141: busy slot for new buffer");
 
-    mark_buffer_journal_new(p_s_new_bh) ;
+    set_buffer_journal_new (p_s_new_bh);
     p_s_tb->FEB[p_s_tb->cur_blknum++] = p_s_new_bh;
   }
 
@@ -1140,7 +1140,7 @@
     struct buffer_head * Sh = PATH_H_PBUFFER (tb->tb_path, h);
     int levbytes = tb->insert_size[h];
     struct item_head * ih;
-    struct key * r_key = NULL;
+    struct reiserfs_key * r_key = NULL;
 
     ih = B_N_PITEM_HEAD (Sh, 0);
     if ( tb->CFR[h] )
diff -Nru a/fs/reiserfs/ibalance.c b/fs/reiserfs/ibalance.c
--- a/fs/reiserfs/ibalance.c	2004-12-24 13:36:59 -08:00
+++ b/fs/reiserfs/ibalance.c	2004-12-24 13:36:59 -08:00
@@ -133,7 +133,7 @@
     struct buffer_head * cur = cur_bi->bi_bh;
     struct block_head * blkh;
     int nr;
-    struct key * ih;
+    struct reiserfs_key * ih;
     struct disk_child new_dc[2];
     struct disk_child * dc;
     int i;
@@ -209,7 +209,7 @@
   struct buffer_head * cur = cur_bi->bi_bh;
   int nr;
   struct block_head * blkh;
-  struct key * key;
+  struct reiserfs_key * key;
   struct disk_child * dc;
 
   RFALSE( cur == NULL, "buffer is 0");
@@ -300,7 +300,7 @@
   int nr_dest, nr_src;
   int dest_order, src_order;
   struct block_head * blkh;
-  struct key * key;
+  struct reiserfs_key * key;
   struct disk_child * dc;
 
   nr_src = B_NR_ITEMS (src);
@@ -409,7 +409,7 @@
     struct buffer_head * dest = dest_bi->bi_bh;
     int nr;
     struct block_head * blkh;
-    struct key * key;
+    struct reiserfs_key * key;
 
     RFALSE( dest == NULL || src == NULL,
 	    "source(%p) or dest(%p) buffer is 0", src, dest);
diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
--- a/fs/reiserfs/inode.c	2004-12-24 13:36:34 -08:00
+++ b/fs/reiserfs/inode.c	2004-12-24 13:36:34 -08:00
@@ -47,21 +47,32 @@
 
 	reiserfs_delete_xattrs (inode);
 
-	journal_begin(&th, inode->i_sb, jbegin_count) ;
+	if (journal_begin(&th, inode->i_sb, jbegin_count)) {
+	    up (&inode->i_sem);
+	    goto out;
+	}
 	reiserfs_update_inode_transaction(inode) ;
 
-	reiserfs_delete_object (&th, inode);
+	if (reiserfs_delete_object (&th, inode)) {
+	    up (&inode->i_sem);
+	    goto out;
+	}
 
-	journal_end(&th, inode->i_sb, jbegin_count) ;
+	if (journal_end(&th, inode->i_sb, jbegin_count)) {
+	    up (&inode->i_sem);
+	    goto out;
+	}
 
         up (&inode->i_sem);
 
         /* all items of file are deleted, so we can remove "save" link */
-	remove_save_link (inode, 0/* not truncate */);
+	remove_save_link (inode, 0/* not truncate */); /* we can't do anything
+                                                        * about an error here */
     } else {
 	/* no object items are in the tree */
 	;
     }
+out:
     clear_inode (inode); /* note this must go after the journal_end to prevent deadlock */
     inode->i_blocks = 0;
     reiserfs_write_unlock(inode->i_sb);
@@ -201,20 +212,28 @@
     return 0;
 }
 
-/*static*/ void restart_transaction(struct reiserfs_transaction_handle *th,
+/*static*/ int restart_transaction(struct reiserfs_transaction_handle *th,
 				struct inode *inode, struct path *path) {
   struct super_block *s = th->t_super ;
   int len = th->t_blocks_allocated ;
+  int err;
+
+  BUG_ON (!th->t_trans_id);
+  BUG_ON (!th->t_refcount);
 
   /* we cannot restart while nested */
   if (th->t_refcount > 1) {
-      return  ;
+      return 0  ;
   }
   pathrelse(path) ;
   reiserfs_update_sd(th, inode) ;
-  journal_end(th, s, len) ;
-  journal_begin(th, s, JOURNAL_PER_BALANCE_CNT * 6) ;
-  reiserfs_update_inode_transaction(inode) ;
+  err = journal_end(th, s, len) ;
+  if (!err) {
+      err = journal_begin(th, s, JOURNAL_PER_BALANCE_CNT * 6) ;
+      if (!err)
+        reiserfs_update_inode_transaction(inode) ;
+  }
+  return err;
 }
 
 // it is called by get_block when create == 0. Returns block number
@@ -443,9 +462,11 @@
 
     ret = reiserfs_get_block(inode, iblock, bh_result,
                              create | GET_BLOCK_NO_DANGLE) ;
+    if (ret)
+        goto out;
 
     /* don't allow direct io onto tail pages */
-    if (ret == 0 && buffer_mapped(bh_result) && bh_result->b_blocknr == 0) {
+    if (buffer_mapped(bh_result) && bh_result->b_blocknr == 0) {
         /* make sure future calls to the direct io funcs for this offset
         ** in the file fail by unmapping the buffer
         */
@@ -455,11 +476,15 @@
     /* Possible unpacked tail. Flush the data before pages have
        disappeared */
     if (REISERFS_I(inode)->i_flags & i_pack_on_close_mask) {
+        int err;
         lock_kernel();
-        reiserfs_commit_for_inode(inode);
+        err = reiserfs_commit_for_inode(inode);
         REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
         unlock_kernel();
+        if (err < 0)
+            ret = err;
     }
+out:
     return ret ;
 }
 
@@ -539,6 +564,7 @@
 			   b_blocknr_t *allocated_block_nr, 
 			   struct path * path,
 			   int flags) {
+    BUG_ON (!th->t_trans_id);
   
 #ifdef REISERFS_PREALLOCATE
     if (!(flags & GET_BLOCK_NO_ISEM)) {
@@ -551,7 +577,7 @@
 int reiserfs_get_block (struct inode * inode, sector_t block,
 			struct buffer_head * bh_result, int create)
 {
-    int repeat, retval;
+    int repeat, retval = 0;
     b_blocknr_t allocated_block_nr = 0;// b_blocknr_t is (unsigned) 32 bit int
     INITIALIZE_PATH(path);
     int pos_in_item;
@@ -655,7 +681,9 @@
 	    ** research if we succeed on the second try
 	    */
 	    SB_JOURNAL(inode->i_sb)->j_next_async_flush = 1;
-	    restart_transaction(th, inode, &path) ;
+	    retval = restart_transaction(th, inode, &path) ;
+            if (retval)
+                goto failure;
 	    repeat = _allocate_block(th, block, inode, &allocated_block_nr, NULL, create);
 
 	    if (repeat != NO_DISK_SPACE && repeat != QUOTA_EXCEEDED) {
@@ -696,8 +724,9 @@
 	}
 	set_block_dev_mapped(bh_result, unfm_ptr, inode);
 	pathrelse (&path);
+        retval = 0;
 	if (!dangle && th)
-	    reiserfs_end_persistent_transaction(th);
+	    retval = reiserfs_end_persistent_transaction(th);
 
 	reiserfs_write_unlock(inode->i_sb);
 	 
@@ -705,7 +734,7 @@
 	** there is no need to make sure the inode is updated with this 
 	** transaction
 	*/
-	return 0;
+	return retval;
     }
 
     if (!th) {
@@ -766,9 +795,12 @@
 		 * ugly, but we can only end the transaction if
 		 * we aren't nested
 		 */
+		BUG_ON (!th->t_refcount);
 		if (th->t_refcount == 1) {
-		    reiserfs_end_persistent_transaction(th);
+		    retval = reiserfs_end_persistent_transaction(th);
 		    th = NULL;
+		    if (retval)
+			goto failure;
 		}
 
 		retval = convert_tail_for_hole(inode, bh_result, tail_offset) ;
@@ -898,7 +930,9 @@
 	** ending their transaction will be able to continue.
 	*/
 	if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
-	  restart_transaction(th, inode, &path) ;
+	  retval = restart_transaction(th, inode, &path) ;
+	  if (retval)
+	    goto failure;
 	}
 	/* inserting indirect pointers for a hole can take a 
 	** long time.  reschedule if needed
@@ -929,10 +963,15 @@
     retval = 0;
 
  failure:
-    if (th && !dangle) {
-      reiserfs_update_sd(th, inode) ;
-      reiserfs_end_persistent_transaction(th);
+    if (th && (!dangle || (retval && !th->t_trans_id))) {
+        int err;
+        if (th->t_trans_id)
+            reiserfs_update_sd(th, inode);
+        err = reiserfs_end_persistent_transaction(th);
+        if (err)
+            retval = err;
     }
+
     reiserfs_write_unlock(inode->i_sb);
     reiserfs_check_path(&path) ;
     return retval;
@@ -1215,6 +1254,8 @@
     struct item_head *ih, tmp_ih ;
     int retval;
 
+    BUG_ON (!th->t_trans_id);
+
     make_cpu_key (&key, inode, SD_OFFSET, TYPE_STAT_DATA, 3);//key type is unimportant
     
     for(;;) {
@@ -1408,12 +1449,14 @@
     
     key.on_disk_key.k_objectid = data[0] ;
     key.on_disk_key.k_dir_id = data[1] ;
+    reiserfs_write_lock(sb);
     inode = reiserfs_iget(sb, &key) ;
     if (inode && !IS_ERR(inode) && data[2] != 0 &&
 	data[2] != inode->i_generation) {
 	    iput(inode) ;
 	    inode = NULL ;
     }
+    reiserfs_write_unlock(sb);
     if (!inode)
 	    inode = ERR_PTR(-ESTALE);
     if (IS_ERR(inode))
@@ -1508,12 +1551,8 @@
     struct reiserfs_transaction_handle th ;
     int jbegin_count = 1 ;
 
-    if (inode->i_sb->s_flags & MS_RDONLY) {
-        reiserfs_warning (inode->i_sb,
-			  "clm-6005: writing inode %lu on readonly FS",
-			  inode->i_ino) ;
+    if (inode->i_sb->s_flags & MS_RDONLY)
         return -EROFS;
-    }
     /* memory pressure can sometimes initiate write_inode calls with sync == 1,
     ** these cases are just when the system needs ram, not when the 
     ** inode needs to reach disk for safety, and they can safely be
@@ -1521,9 +1560,10 @@
     */
     if (do_sync && !(current->flags & PF_MEMALLOC)) {
 	reiserfs_write_lock(inode->i_sb);
-	journal_begin(&th, inode->i_sb, jbegin_count) ;
-	reiserfs_update_sd (&th, inode);
-	journal_end_sync(&th, inode->i_sb, jbegin_count) ;
+	if (!journal_begin(&th, inode->i_sb, jbegin_count)) {
+            reiserfs_update_sd (&th, inode);
+            journal_end_sync(&th, inode->i_sb, jbegin_count) ;
+        }
 	reiserfs_write_unlock(inode->i_sb);
     }
     return 0;
@@ -1551,6 +1591,8 @@
     char * body = empty_dir;
     struct cpu_key key;
     int retval;
+
+    BUG_ON (!th->t_trans_id);
     
     _make_cpu_key (&key, KEY_FORMAT_3_5, le32_to_cpu (ih->ih_key.k_dir_id),
 		   le32_to_cpu (ih->ih_key.k_objectid), DOT_OFFSET, TYPE_DIRENTRY, 3/*key length*/);
@@ -1602,6 +1644,8 @@
     struct cpu_key key;
     int retval;
 
+    BUG_ON (!th->t_trans_id);
+
     _make_cpu_key (&key, KEY_FORMAT_3_5, 
 		   le32_to_cpu (ih->ih_key.k_dir_id), 
 		   le32_to_cpu (ih->ih_key.k_objectid),
@@ -1652,6 +1696,8 @@
     struct stat_data sd;
     int retval;
     int err;
+
+    BUG_ON (!th->t_trans_id);
   
     if (!dir || !dir->i_nlink) {
 	err = -EPERM;
@@ -1926,7 +1972,7 @@
 **
 ** some code taken from block_truncate_page
 */
-void reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) {
+int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) {
     struct reiserfs_transaction_handle th ;
     /* we want the offset for the first byte after the end of the file */
     unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1) ;
@@ -1962,18 +2008,28 @@
     /* it is enough to reserve space in transaction for 2 balancings:
        one for "save" link adding and another for the first
        cut_from_item. 1 is for update_sd */
-    journal_begin(&th, p_s_inode->i_sb,  JOURNAL_PER_BALANCE_CNT * 2 + 1 ) ;
+    error = journal_begin (&th, p_s_inode->i_sb,
+                           JOURNAL_PER_BALANCE_CNT * 2 + 1);
+    if (error)
+        goto out;
     reiserfs_update_inode_transaction(p_s_inode) ;
     if (update_timestamps)
 	    /* we are doing real truncate: if the system crashes before the last
 	       transaction of truncating gets committed - on reboot the file
 	       either appears truncated properly or not truncated at all */
 	add_save_link (&th, p_s_inode, 1);
-    reiserfs_do_truncate (&th, p_s_inode, page, update_timestamps) ;
-    journal_end(&th, p_s_inode->i_sb,  JOURNAL_PER_BALANCE_CNT * 2 + 1 ) ;
+    error = reiserfs_do_truncate (&th, p_s_inode, page, update_timestamps) ;
+    if (error)
+        goto out;
+    error = journal_end (&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1);
+    if (error)
+        goto out;
 
-    if (update_timestamps)
-	remove_save_link (p_s_inode, 1/* truncate */);
+    if (update_timestamps) {
+	error = remove_save_link (p_s_inode, 1/* truncate */);
+        if (error)
+            goto out;
+    }
 
     if (page) {
         length = offset & (blocksize - 1) ;
@@ -1995,6 +2051,14 @@
     }
 
     reiserfs_write_unlock(p_s_inode->i_sb);
+    return 0;
+out:
+    if (page) {
+        unlock_page (page);
+        page_cache_release (page);
+    }
+    reiserfs_write_unlock(p_s_inode->i_sb);
+    return error;
 }
 
 static int map_block_for_writepage(struct inode *inode, 
@@ -2064,7 +2128,9 @@
 
 	if (!trans_running) {
 	    /* vs-3050 is gone, no need to drop the path */
-	    journal_begin(&th, inode->i_sb, jbegin_count) ;
+	    retval = journal_begin(&th, inode->i_sb, jbegin_count) ;
+            if (retval)
+                goto out;
 	    reiserfs_update_inode_transaction(inode) ;
 	    trans_running = 1;
 	    if (fs_changed(fs_gen, inode->i_sb) && item_moved(&tmp_ih, &path)) {
@@ -2104,7 +2170,9 @@
 out:
     pathrelse(&path) ;
     if (trans_running) {
-	journal_end(&th, inode->i_sb, jbegin_count) ;
+        int err = journal_end(&th, inode->i_sb, jbegin_count) ;
+        if (err)
+            retval = err;
 	trans_running = 0;
     }
     reiserfs_write_unlock(inode->i_sb);
@@ -2210,7 +2278,11 @@
     if (checked) {
 	ClearPageChecked(page);
 	reiserfs_write_lock(s);
-	journal_begin(&th, s, bh_per_page + 1);
+	error = journal_begin(&th, s, bh_per_page + 1);
+	if (error) {
+	    reiserfs_write_unlock(s);
+	    goto fail;
+	}
 	reiserfs_update_inode_transaction(inode);
     }
     /* now go through and lock any dirty buffers on the page */
@@ -2245,8 +2317,10 @@
     } while((bh = bh->b_this_page) != head);
 
     if (checked) {
-	journal_end(&th, s, bh_per_page + 1);
+	error = journal_end(&th, s, bh_per_page + 1);
 	reiserfs_write_unlock(s);
+	if (error)
+	    goto fail;
     }
     BUG_ON(PageWriteback(page));
     set_page_writeback(page);
@@ -2352,7 +2426,9 @@
     fix_tail_page_for_writing(page) ;
     if (reiserfs_transaction_running(inode->i_sb)) {
 	struct reiserfs_transaction_handle *th;
-        th = (struct reiserfs_transaction_handle *)current->journal_info;
+	th = (struct reiserfs_transaction_handle *)current->journal_info;
+        BUG_ON (!th->t_refcount);
+        BUG_ON (!th->t_trans_id);
 	old_ref = th->t_refcount;
 	th->t_refcount++;
     }
@@ -2374,9 +2450,12 @@
 	    if (old_ref)
 	    	th->t_refcount--;
 	    else {
+                int err;
 		reiserfs_write_lock(inode->i_sb);
-		reiserfs_end_persistent_transaction(th);
+		err = reiserfs_end_persistent_transaction(th);
 		reiserfs_write_unlock(inode->i_sb);
+                if (err)
+                    ret = err;
 	    }
 	}
     }
@@ -2417,20 +2496,28 @@
 	     (have_small_tails (inode->i_sb) && inode->i_size > i_block_size(inode)) )
 	    REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask ;
 
-	journal_begin(&myth, inode->i_sb, 1) ;
+	ret = journal_begin(&myth, inode->i_sb, 1) ;
+	if (ret) {
+	    reiserfs_write_unlock(inode->i_sb);
+	    goto journal_error;
+	}
 	reiserfs_update_inode_transaction(inode) ;
 	inode->i_size = pos ;
 	reiserfs_update_sd(&myth, inode) ;
 	update_sd = 1;
-	journal_end(&myth, inode->i_sb, 1) ;
+	ret = journal_end(&myth, inode->i_sb, 1) ;
 	reiserfs_write_unlock(inode->i_sb);
+	if (ret)
+	    goto journal_error;
     }
     if (th) {
 	reiserfs_write_lock(inode->i_sb);
 	if (!update_sd)
 	    reiserfs_update_sd(th, inode) ;
-        reiserfs_end_persistent_transaction(th);
+	ret = reiserfs_end_persistent_transaction(th);
 	reiserfs_write_unlock(inode->i_sb);
+	if (ret)
+	    goto out;
     }
  
     /* we test for O_SYNC here so we can commit the transaction
@@ -2438,10 +2525,22 @@
     */
     if (f && (f->f_flags & O_SYNC)) {
 	reiserfs_write_lock(inode->i_sb);
- 	reiserfs_commit_for_inode(inode) ;
+ 	ret = reiserfs_commit_for_inode(inode) ;
 	reiserfs_write_unlock(inode->i_sb);
     }
+out:
     return ret ;
+
+journal_error:
+    if (th) {
+	reiserfs_write_lock(inode->i_sb);
+	if (!update_sd)
+	    reiserfs_update_sd(th, inode) ;
+        ret = reiserfs_end_persistent_transaction(th);
+	reiserfs_write_unlock(inode->i_sb);
+    }
+
+    return ret;
 }
 
 void sd_attrs_to_i_attrs( __u16 sd_attrs, struct inode *inode )
@@ -2667,11 +2766,16 @@
         if (attr->ia_size > inode->i_size) {
 	    error = generic_cont_expand(inode, attr->ia_size) ;
 	    if (REISERFS_I(inode)->i_prealloc_count > 0) {
+		int err;
 		struct reiserfs_transaction_handle th ;
 		/* we're changing at most 2 bitmaps, inode + super */
-		journal_begin(&th, inode->i_sb, 4) ;
-		reiserfs_discard_prealloc (&th, inode);
-		journal_end(&th, inode->i_sb, 4) ;
+		err = journal_begin(&th, inode->i_sb, 4) ;
+		if (!err) {
+		    reiserfs_discard_prealloc (&th, inode);
+		    err = journal_end(&th, inode->i_sb, 4) ;
+		}
+		if (err)
+		    error = err;
 	    }
 	    if (error)
 	        goto out;
diff -Nru a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
--- a/fs/reiserfs/item_ops.c	2004-12-24 13:37:02 -08:00
+++ b/fs/reiserfs/item_ops.c	2004-12-24 13:37:02 -08:00
@@ -26,7 +26,7 @@
     set_cpu_key_k_offset(key, (loff_t)(-1));
 }
 
-static int sd_is_left_mergeable (struct key * key, unsigned long bsize)
+static int sd_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
 {
     return 0;
 }
@@ -145,7 +145,7 @@
 }
 
 
-static int direct_is_left_mergeable (struct key * key, unsigned long bsize)
+static int direct_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
 {
     int version = le_key_version (key);
     return ((le_key_k_offset (version, key) & (bsize - 1)) != 1);
@@ -250,7 +250,7 @@
 
 
 // if it is not first item of the body, then it is mergeable
-static int indirect_is_left_mergeable (struct key * key, unsigned long bsize)
+static int indirect_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
 {
     int version = le_key_version (key);
     return (le_key_k_offset (version, key) != 1);
@@ -403,7 +403,7 @@
 }
 
 
-static int direntry_is_left_mergeable (struct key * key, unsigned long bsize)
+static int direntry_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
 {
     if (le32_to_cpu (key->u.k_offset_v1.k_offset) == DOT_OFFSET)
 	return 0;
@@ -691,7 +691,7 @@
 }
 
 
-static int errcatch_is_left_mergeable (struct key * key, unsigned long bsize)
+static int errcatch_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
 {
     reiserfs_warning (NULL, "green-16003: Invalid item type observed, run fsck ASAP");
     return 0;
diff -Nru a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
--- a/fs/reiserfs/journal.c	2004-12-24 13:37:00 -08:00
+++ b/fs/reiserfs/journal.c	2004-12-24 13:37:00 -08:00
@@ -93,12 +93,6 @@
 #define COMMIT_NOW  2		/* end and commit this transaction */
 #define WAIT        4		/* wait for the log blocks to hit the disk*/
 
-/* state bits for the journal */
-#define WRITERS_BLOCKED 1      /* set when new writers not allowed */
-#define WRITERS_QUEUED 2       /* set when log is full due to too many
-				* writers
-				*/
-
 static int do_journal_end(struct reiserfs_transaction_handle *,struct super_block *,unsigned long nblocks,int flags) ;
 static int flush_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall) ;
 static int flush_commit_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall)  ;
@@ -109,9 +103,22 @@
 static int dirty_one_transaction(struct super_block *s,
                                  struct reiserfs_journal_list *jl);
 static void flush_async_commits(void *p);
+static void queue_log_writer(struct super_block *s);
+
+/* values for join in do_journal_begin_r */
+enum {
+    JBEGIN_REG = 0, /* regular journal begin */
+    JBEGIN_JOIN = 1, /* join the running transaction if at all possible */
+    JBEGIN_ABORT = 2, /* called from cleanup code, ignores aborted flag */
+};
+
+static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
+                             struct super_block * p_s_sb,
+			     unsigned long nblocks,int join);
 
 static void init_journal_hash(struct super_block *p_s_sb) {
-  memset(SB_JOURNAL(p_s_sb)->j_hash_table, 0, JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)) ;
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
+  memset(journal->j_hash_table, 0, JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)) ;
 }
 
 /*
@@ -122,7 +129,7 @@
 static int reiserfs_clean_and_file_buffer(struct buffer_head *bh) {
   if (bh) {
     clear_buffer_dirty(bh);
-    clear_bit(BH_JTest, &bh->b_state);
+    clear_buffer_journal_test(bh);
   }
   return 0 ;
 }
@@ -155,17 +162,18 @@
 
 static struct reiserfs_bitmap_node *
 get_bitmap_node(struct super_block *p_s_sb) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_bitmap_node *bn = NULL;
-  struct list_head *entry = SB_JOURNAL(p_s_sb)->j_bitmap_nodes.next ;
+  struct list_head *entry = journal->j_bitmap_nodes.next ;
 
-  SB_JOURNAL(p_s_sb)->j_used_bitmap_nodes++ ;
+  journal->j_used_bitmap_nodes++ ;
 repeat:
 
-  if(entry != &SB_JOURNAL(p_s_sb)->j_bitmap_nodes) {
+  if(entry != &journal->j_bitmap_nodes) {
     bn = list_entry(entry, struct reiserfs_bitmap_node, list) ;
     list_del(entry) ;
     memset(bn->data, 0, p_s_sb->s_blocksize) ;
-    SB_JOURNAL(p_s_sb)->j_free_bitmap_nodes-- ;
+    journal->j_free_bitmap_nodes-- ;
     return bn ;
   }
   bn = allocate_bitmap_node(p_s_sb) ;
@@ -177,24 +185,26 @@
 }
 static inline void free_bitmap_node(struct super_block *p_s_sb,
                                     struct reiserfs_bitmap_node *bn) {
-  SB_JOURNAL(p_s_sb)->j_used_bitmap_nodes-- ;
-  if (SB_JOURNAL(p_s_sb)->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
+  journal->j_used_bitmap_nodes-- ;
+  if (journal->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) {
     reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb) ;
     reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb) ;
   } else {
-    list_add(&bn->list, &SB_JOURNAL(p_s_sb)->j_bitmap_nodes) ;
-    SB_JOURNAL(p_s_sb)->j_free_bitmap_nodes++ ;
+    list_add(&bn->list, &journal->j_bitmap_nodes) ;
+    journal->j_free_bitmap_nodes++ ;
   }
 }
 
 static void allocate_bitmap_nodes(struct super_block *p_s_sb) {
   int i ;
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_bitmap_node *bn = NULL ;
   for (i = 0 ; i < REISERFS_MIN_BITMAP_NODES ; i++) {
     bn = allocate_bitmap_node(p_s_sb) ;
     if (bn) {
-      list_add(&bn->list, &SB_JOURNAL(p_s_sb)->j_bitmap_nodes) ;
-      SB_JOURNAL(p_s_sb)->j_free_bitmap_nodes++ ;
+      list_add(&bn->list, &journal->j_bitmap_nodes) ;
+      journal->j_free_bitmap_nodes++ ;
     } else {
       break ; // this is ok, we'll try again when more are needed 
     }
@@ -245,16 +255,17 @@
 }
 
 static int free_bitmap_nodes(struct super_block *p_s_sb) {
-  struct list_head *next = SB_JOURNAL(p_s_sb)->j_bitmap_nodes.next ;
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
+  struct list_head *next = journal->j_bitmap_nodes.next ;
   struct reiserfs_bitmap_node *bn ;
 
-  while(next != &SB_JOURNAL(p_s_sb)->j_bitmap_nodes) {
+  while(next != &journal->j_bitmap_nodes) {
     bn = list_entry(next, struct reiserfs_bitmap_node, list) ;
     list_del(next) ;
     reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb) ;
     reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb) ;
-    next = SB_JOURNAL(p_s_sb)->j_bitmap_nodes.next ;
-    SB_JOURNAL(p_s_sb)->j_free_bitmap_nodes-- ;
+    next = journal->j_bitmap_nodes.next ;
+    journal->j_free_bitmap_nodes-- ;
   }
 
   return 0 ;
@@ -297,15 +308,16 @@
 static struct reiserfs_list_bitmap *
 get_list_bitmap(struct super_block *p_s_sb, struct reiserfs_journal_list *jl) {
   int i,j ; 
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_list_bitmap *jb = NULL ;
 
   for (j = 0 ; j < (JOURNAL_NUM_BITMAPS * 3) ; j++) {
-    i = SB_JOURNAL(p_s_sb)->j_list_bitmap_index ;
-    SB_JOURNAL(p_s_sb)->j_list_bitmap_index = (i + 1) % JOURNAL_NUM_BITMAPS ;
-    jb = SB_JOURNAL(p_s_sb)->j_list_bitmap + i ;
-    if (SB_JOURNAL(p_s_sb)->j_list_bitmap[i].journal_list) {
-      flush_commit_list(p_s_sb, SB_JOURNAL(p_s_sb)->j_list_bitmap[i].journal_list, 1) ;
-      if (!SB_JOURNAL(p_s_sb)->j_list_bitmap[i].journal_list) {
+    i = journal->j_list_bitmap_index ;
+    journal->j_list_bitmap_index = (i + 1) % JOURNAL_NUM_BITMAPS ;
+    jb = journal->j_list_bitmap + i ;
+    if (journal->j_list_bitmap[i].journal_list) {
+      flush_commit_list(p_s_sb, journal->j_list_bitmap[i].journal_list, 1) ;
+      if (!journal->j_list_bitmap[i].journal_list) {
 	break ;
       }
     } else {
@@ -350,22 +362,23 @@
 */
 static struct reiserfs_journal_cnode *get_cnode(struct super_block *p_s_sb) {
   struct reiserfs_journal_cnode *cn ;
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
 
   reiserfs_check_lock_depth(p_s_sb, "get_cnode") ;
 
-  if (SB_JOURNAL(p_s_sb)->j_cnode_free <= 0) {
+  if (journal->j_cnode_free <= 0) {
     return NULL ;
   }
-  SB_JOURNAL(p_s_sb)->j_cnode_used++ ;
-  SB_JOURNAL(p_s_sb)->j_cnode_free-- ;
-  cn = SB_JOURNAL(p_s_sb)->j_cnode_free_list ;
+  journal->j_cnode_used++ ;
+  journal->j_cnode_free-- ;
+  cn = journal->j_cnode_free_list ;
   if (!cn) {
     return cn ;
   }
   if (cn->next) {
     cn->next->prev = NULL ;
   }
-  SB_JOURNAL(p_s_sb)->j_cnode_free_list = cn->next ;
+  journal->j_cnode_free_list = cn->next ;
   memset(cn, 0, sizeof(struct reiserfs_journal_cnode)) ;
   return cn ;
 }
@@ -374,55 +387,24 @@
 ** returns a cnode to the free list 
 */
 static void free_cnode(struct super_block *p_s_sb, struct reiserfs_journal_cnode *cn) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
 
   reiserfs_check_lock_depth(p_s_sb, "free_cnode") ;
 
-  SB_JOURNAL(p_s_sb)->j_cnode_used-- ;
-  SB_JOURNAL(p_s_sb)->j_cnode_free++ ;
+  journal->j_cnode_used-- ;
+  journal->j_cnode_free++ ;
   /* memset(cn, 0, sizeof(struct reiserfs_journal_cnode)) ; */
-  cn->next = SB_JOURNAL(p_s_sb)->j_cnode_free_list ;
-  if (SB_JOURNAL(p_s_sb)->j_cnode_free_list) {
-    SB_JOURNAL(p_s_sb)->j_cnode_free_list->prev = cn ;
+  cn->next = journal->j_cnode_free_list ;
+  if (journal->j_cnode_free_list) {
+    journal->j_cnode_free_list->prev = cn ;
   }
   cn->prev = NULL ; /* not needed with the memset, but I might kill the memset, and forget to do this */
-  SB_JOURNAL(p_s_sb)->j_cnode_free_list = cn ;
-}
-
-static int clear_prepared_bits(struct buffer_head *bh) {
-  clear_bit(BH_JPrepared, &bh->b_state) ;
-  clear_bit(BH_JRestore_dirty, &bh->b_state) ;
-  return 0 ;
-}
-
-/* buffer is in current transaction */
-inline int buffer_journaled(const struct buffer_head *bh) {
-  if (bh)
-    return test_bit(BH_JDirty, &bh->b_state) ;
-  else
-    return 0 ;
-}
-
-/* disk block was taken off free list before being in a finished transation, or written to disk
-** journal_new blocks can be reused immediately, for any purpose
-*/ 
-inline int buffer_journal_new(const struct buffer_head *bh) {
-  if (bh) 
-    return test_bit(BH_JNew, &bh->b_state) ;
-  else
-    return 0 ;
+  journal->j_cnode_free_list = cn ;
 }
 
-inline int mark_buffer_journal_new(struct buffer_head *bh) {
-  if (bh) {
-    set_bit(BH_JNew, &bh->b_state) ;
-  }
-  return 0 ;
-}
-
-inline int mark_buffer_not_journaled(struct buffer_head *bh) {
-  if (bh) 
-    clear_bit(BH_JDirty, &bh->b_state) ;
-  return 0 ;
+static void clear_prepared_bits(struct buffer_head *bh) {
+  clear_buffer_journal_prepared (bh);
+  clear_buffer_journal_restore_dirty (bh);
 }
 
 /* utility function to force a BUG if it is called without the big
@@ -456,9 +438,10 @@
 
 /* returns a cnode with same size, block number and dev as bh in the current transaction hash.  NULL if not found */
 static inline struct reiserfs_journal_cnode *get_journal_hash(struct super_block *p_s_sb, struct buffer_head *bh) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_cnode *cn ;
   if (bh) {
-    cn =  get_journal_hash_dev(p_s_sb, SB_JOURNAL(p_s_sb)->j_hash_table, bh->b_blocknr);
+    cn =  get_journal_hash_dev(p_s_sb, journal->j_hash_table, bh->b_blocknr);
   }
   else {
     return (struct reiserfs_journal_cnode *)0 ;
@@ -487,6 +470,7 @@
 int reiserfs_in_journal(struct super_block *p_s_sb,
                         int bmap_nr, int bit_nr, int search_all, 
 			b_blocknr_t *next_zero_bit) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_cnode *cn ;
   struct reiserfs_list_bitmap *jb ;
   int i ;
@@ -502,7 +486,7 @@
   if (search_all) {
     for (i = 0 ; i < JOURNAL_NUM_BITMAPS ; i++) {
       PROC_INFO_INC( p_s_sb, journal.in_journal_bitmap );
-      jb = SB_JOURNAL(p_s_sb)->j_list_bitmap + i ;
+      jb = journal->j_list_bitmap + i ;
       if (jb->journal_list && jb->bitmaps[bmap_nr] &&
           test_bit(bit_nr, (unsigned long *)jb->bitmaps[bmap_nr]->data)) {
 	*next_zero_bit = find_next_zero_bit((unsigned long *)
@@ -515,12 +499,12 @@
 
   bl = bmap_nr * (p_s_sb->s_blocksize << 3) + bit_nr;
   /* is it in any old transactions? */
-  if (search_all && (cn = get_journal_hash_dev(p_s_sb, SB_JOURNAL(p_s_sb)->j_list_hash_table, bl))) {
+  if (search_all && (cn = get_journal_hash_dev(p_s_sb, journal->j_list_hash_table, bl))) {
     return 1; 
   }
 
   /* is it in the current transaction.  This should never happen */
-  if ((cn = get_journal_hash_dev(p_s_sb, SB_JOURNAL(p_s_sb)->j_hash_table, bl))) {
+  if ((cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, bl))) {
     BUG();
     return 1; 
   }
@@ -589,7 +573,8 @@
 static int journal_list_still_alive(struct super_block *s,
                                     unsigned long trans_id)
 {
-    struct list_head *entry = &SB_JOURNAL(s)->j_journal_list;
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
+    struct list_head *entry = &journal->j_journal_list;
     struct reiserfs_journal_list *jl;
 
     if (!list_empty(entry)) {
@@ -628,9 +613,9 @@
 static void submit_logged_buffer(struct buffer_head *bh) {
     get_bh(bh) ;
     bh->b_end_io = reiserfs_end_buffer_io_sync ;
-    mark_buffer_notjournal_new(bh) ;
+    clear_buffer_journal_new (bh);
     clear_buffer_dirty(bh) ;
-    if (!test_and_clear_bit(BH_JTest, &bh->b_state))
+    if (!test_clear_buffer_journal_test (bh))
         BUG();
     if (!buffer_uptodate(bh))
         BUG();
@@ -792,7 +777,7 @@
 {
     struct buffer_head *bh;
     struct reiserfs_jh *jh;
-    int ret = 0;
+    int ret = j->j_errno;
     struct buffer_chunk chunk;
     struct list_head tmp;
     INIT_LIST_HEAD(&tmp);
@@ -816,11 +801,11 @@
 	    cond_resched();
 	    spin_lock(lock);
 	    goto loop_next;
-	}
+        }
 	if (buffer_dirty(bh)) {
 	    list_del_init(&jh->list);
 	    list_add(&jh->list, &tmp);
-	    add_to_chunk(&chunk, bh, lock, write_ordered_chunk);
+            add_to_chunk(&chunk, bh, lock, write_ordered_chunk);
 	} else {
 	    reiserfs_free_jh(bh);
 	    unlock_buffer(bh);
@@ -845,8 +830,9 @@
 	    wait_on_buffer(bh);
 	    spin_lock(lock);
 	}
-	if (!buffer_uptodate(bh))
+	if (!buffer_uptodate(bh)) {
 	    ret = -EIO;
+        }
 	put_bh(bh);
 	cond_resched_lock(lock);
     }
@@ -855,6 +841,7 @@
 }
 
 static int flush_older_commits(struct super_block *s, struct reiserfs_journal_list *jl) {
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
     struct reiserfs_journal_list *other_jl;
     struct reiserfs_journal_list *first_jl;
     struct list_head *entry;
@@ -870,7 +857,7 @@
     entry = jl->j_list.prev;
     while(1) {
 	other_jl = JOURNAL_LIST_ENTRY(entry);
-	if (entry == &SB_JOURNAL(s)->j_journal_list ||
+	if (entry == &journal->j_journal_list ||
 	    atomic_read(&other_jl->j_older_commits_done))
 	    break;
 
@@ -907,7 +894,7 @@
 		}
 	    }
 	    entry = entry->next;
-	    if (entry == &SB_JOURNAL(s)->j_journal_list)
+	    if (entry == &journal->j_journal_list)
 		return 0;
 	} else {
 	    return 0;
@@ -935,7 +922,9 @@
   int bn ;
   struct buffer_head *tbh = NULL ;
   unsigned long trans_id = jl->j_trans_id;
+  struct reiserfs_journal *journal = SB_JOURNAL (s);
   int barrier = 0;
+  int retval = 0;
 
   reiserfs_check_lock_depth(s, "flush_commit_list") ;
 
@@ -946,10 +935,8 @@
   /* before we can put our commit blocks on disk, we have to make sure everyone older than
   ** us is on disk too
   */
-  if (jl->j_len <= 0)
-    BUG();
-  if (trans_id == SB_JOURNAL(s)->j_trans_id)
-    BUG();
+  BUG_ON (jl->j_len <= 0);
+  BUG_ON (trans_id == journal->j_trans_id);
 
   get_journal_list(jl);
   if (flushall) {
@@ -965,8 +952,7 @@
     up(&jl->j_commit_lock);
     goto put_jl;
   }
-  if (jl->j_trans_id == 0)
-    BUG();
+  BUG_ON (jl->j_trans_id == 0);
 
   /* this commit is done, exit */
   if (atomic_read(&(jl->j_commit_left)) <= 0) {
@@ -979,26 +965,25 @@
 
   if (!list_empty(&jl->j_bh_list)) {
       unlock_kernel();
-      write_ordered_buffers(&SB_JOURNAL(s)->j_dirty_buffers_lock,
-                            SB_JOURNAL(s), jl, &jl->j_bh_list);
+      write_ordered_buffers(&journal->j_dirty_buffers_lock,
+                            journal, jl, &jl->j_bh_list);
       lock_kernel();
   }
-  if (!list_empty(&jl->j_bh_list))
-      BUG();
+  BUG_ON (!list_empty(&jl->j_bh_list));
   /*
    * for the description block and all the log blocks, submit any buffers
    * that haven't already reached the disk
    */
-  atomic_inc(&SB_JOURNAL(s)->j_async_throttle);
+  atomic_inc(&journal->j_async_throttle);
   for (i = 0 ; i < (jl->j_len + 1) ; i++) {
     bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) + (jl->j_start+i) %
          SB_ONDISK_JOURNAL_SIZE(s);
     tbh = journal_find_get_block(s, bn) ;
-    if (buffer_dirty(tbh))
+    if (buffer_dirty(tbh)) /* redundant, ll_rw_block() checks */
 	ll_rw_block(WRITE, 1, &tbh) ;
     put_bh(tbh) ;
   }
-  atomic_dec(&SB_JOURNAL(s)->j_async_throttle);
+  atomic_dec(&journal->j_async_throttle);
 
   /* wait on everything written so far before writing the commit
    * if we are in barrier mode, send the commit down now
@@ -1022,18 +1007,20 @@
     // since we're using ll_rw_blk above, it might have skipped over
     // a locked buffer.  Double check here
     //
-    if (buffer_dirty(tbh))
+    if (buffer_dirty(tbh)) /* redundant, sync_dirty_buffer() checks */
       sync_dirty_buffer(tbh);
-    if (!buffer_uptodate(tbh)) {
-      reiserfs_panic(s, "journal-601, buffer write failed\n") ;
+    if (unlikely (!buffer_uptodate(tbh))) {
+#ifdef CONFIG_REISERFS_CHECK
+      reiserfs_warning(s, "journal-601, buffer write failed") ;
+#endif
+      retval = -EIO;
     }
     put_bh(tbh) ; /* once for journal_find_get_block */
     put_bh(tbh) ;    /* once due to original getblk in do_journal_end */
     atomic_dec(&(jl->j_commit_left)) ;
   }
 
-  if (atomic_read(&(jl->j_commit_left)) != 1)
-    BUG();
+  BUG_ON (atomic_read(&(jl->j_commit_left)) != 1);
 
   if (!barrier) {
       if (buffer_dirty(jl->j_commit_bh))
@@ -1044,23 +1031,33 @@
       wait_on_buffer(jl->j_commit_bh);
 
   check_barrier_completion(s, jl->j_commit_bh);
-  if (!buffer_uptodate(jl->j_commit_bh)) {
-    reiserfs_panic(s, "journal-615: buffer write failed\n") ;
+
+  /* If there was a write error in the journal - we can't commit this
+   * transaction - it will be invalid and, if successful, will just end
+   * up propogating the write error out to the filesystem. */
+  if (unlikely (!buffer_uptodate(jl->j_commit_bh))) {
+#ifdef CONFIG_REISERFS_CHECK
+    reiserfs_warning(s, "journal-615: buffer write failed") ;
+#endif
+    retval = -EIO;
   }
   bforget(jl->j_commit_bh) ;
-  if (SB_JOURNAL(s)->j_last_commit_id != 0 &&
-     (jl->j_trans_id - SB_JOURNAL(s)->j_last_commit_id) != 1) {
+  if (journal->j_last_commit_id != 0 &&
+     (jl->j_trans_id - journal->j_last_commit_id) != 1) {
       reiserfs_warning(s, "clm-2200: last commit %lu, current %lu",
-                       SB_JOURNAL(s)->j_last_commit_id,
+                       journal->j_last_commit_id,
 		       jl->j_trans_id);
   }
-  SB_JOURNAL(s)->j_last_commit_id = jl->j_trans_id;
+  journal->j_last_commit_id = jl->j_trans_id;
 
   /* now, every commit block is on the disk.  It is safe to allow blocks freed during this transaction to be reallocated */
   cleanup_freed_for_journal_list(s, jl) ;
 
+  retval = retval ? retval : journal->j_errno;
+
   /* mark the metadata dirty */
-  dirty_one_transaction(s, jl);
+  if (!retval)
+    dirty_one_transaction(s, jl);
   atomic_dec(&(jl->j_commit_left)) ;
 
   if (flushall) {
@@ -1069,7 +1066,10 @@
   up(&jl->j_commit_lock);
 put_jl:
   put_journal_list(s, jl);
-  return 0 ;
+
+  if (retval)
+    reiserfs_abort (s, retval, "Journal write error in %s", __FUNCTION__);
+  return retval;
 }
 
 /*
@@ -1099,6 +1099,7 @@
 ** block to be reallocated for data blocks if it had been deleted.
 */
 static void remove_all_from_journal_list(struct super_block *p_s_sb, struct reiserfs_journal_list *jl, int debug) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_cnode *cn, *last ;
   cn = jl->j_realblock ;
 
@@ -1112,7 +1113,7 @@
                          cn->bh ? 1: 0, cn->state) ;
       }
       cn->state = 0 ;
-      remove_journal_hash(p_s_sb, SB_JOURNAL(p_s_sb)->j_list_hash_table, jl, cn->blocknr, 1) ;
+      remove_journal_hash(p_s_sb, journal->j_list_hash_table, jl, cn->blocknr, 1) ;
     }
     last = cn ;
     cn = cn->next ;
@@ -1130,37 +1131,45 @@
 */
 static int _update_journal_header_block(struct super_block *p_s_sb, unsigned long offset, unsigned long trans_id) {
   struct reiserfs_journal_header *jh ;
-  if (trans_id >= SB_JOURNAL(p_s_sb)->j_last_flush_trans_id) {
-    if (buffer_locked((SB_JOURNAL(p_s_sb)->j_header_bh)))  {
-      wait_on_buffer((SB_JOURNAL(p_s_sb)->j_header_bh)) ;
-      if (!buffer_uptodate(SB_JOURNAL(p_s_sb)->j_header_bh)) {
-        reiserfs_panic(p_s_sb, "journal-699: buffer write failed\n") ;
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
+
+  if (reiserfs_is_journal_aborted (journal))
+    return -EIO;
+
+  if (trans_id >= journal->j_last_flush_trans_id) {
+    if (buffer_locked((journal->j_header_bh)))  {
+      wait_on_buffer((journal->j_header_bh)) ;
+      if (unlikely (!buffer_uptodate(journal->j_header_bh))) {
+#ifdef CONFIG_REISERFS_CHECK
+        reiserfs_warning (p_s_sb, "journal-699: buffer write failed") ;
+#endif
+        return -EIO;
       }
     }
-    SB_JOURNAL(p_s_sb)->j_last_flush_trans_id = trans_id ;
-    SB_JOURNAL(p_s_sb)->j_first_unflushed_offset = offset ;
-    jh = (struct reiserfs_journal_header *)(SB_JOURNAL(p_s_sb)->j_header_bh->b_data) ;
+    journal->j_last_flush_trans_id = trans_id ;
+    journal->j_first_unflushed_offset = offset ;
+    jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data) ;
     jh->j_last_flush_trans_id = cpu_to_le32(trans_id) ;
     jh->j_first_unflushed_offset = cpu_to_le32(offset) ;
-    jh->j_mount_id = cpu_to_le32(SB_JOURNAL(p_s_sb)->j_mount_id) ;
+    jh->j_mount_id = cpu_to_le32(journal->j_mount_id) ;
 
     if (reiserfs_barrier_flush(p_s_sb)) {
 	int ret;
-	lock_buffer(SB_JOURNAL(p_s_sb)->j_header_bh);
-	ret = submit_barrier_buffer(SB_JOURNAL(p_s_sb)->j_header_bh);
+	lock_buffer(journal->j_header_bh);
+	ret = submit_barrier_buffer(journal->j_header_bh);
 	if (ret == -EOPNOTSUPP) {
-	    set_buffer_uptodate(SB_JOURNAL(p_s_sb)->j_header_bh);
+	    set_buffer_uptodate(journal->j_header_bh);
 	    disable_barrier(p_s_sb);
 	    goto sync;
 	}
-	wait_on_buffer(SB_JOURNAL(p_s_sb)->j_header_bh);
-	check_barrier_completion(p_s_sb, SB_JOURNAL(p_s_sb)->j_header_bh);
+	wait_on_buffer(journal->j_header_bh);
+	check_barrier_completion(p_s_sb, journal->j_header_bh);
     } else {
 sync:
-	set_buffer_dirty(SB_JOURNAL(p_s_sb)->j_header_bh) ;
-	sync_dirty_buffer(SB_JOURNAL(p_s_sb)->j_header_bh) ;
+	set_buffer_dirty(journal->j_header_bh) ;
+	sync_dirty_buffer(journal->j_header_bh) ;
     }
-    if (!buffer_uptodate(SB_JOURNAL(p_s_sb)->j_header_bh)) {
+    if (!buffer_uptodate(journal->j_header_bh)) {
       reiserfs_warning (p_s_sb, "journal-837: IO error during journal replay");
       return -EIO ;
     }
@@ -1171,10 +1180,7 @@
 static int update_journal_header_block(struct super_block *p_s_sb, 
                                        unsigned long offset, 
 				       unsigned long trans_id) {
-    if (_update_journal_header_block(p_s_sb, offset, trans_id)) {
-	reiserfs_panic(p_s_sb, "journal-712: buffer write failed\n") ;
-    }
-    return 0 ;
+    return _update_journal_header_block(p_s_sb, offset, trans_id);
 }
 /* 
 ** flush any and all journal lists older than you are 
@@ -1185,15 +1191,20 @@
 {
     struct list_head *entry;
     struct reiserfs_journal_list *other_jl ;
+    struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
     unsigned long trans_id = jl->j_trans_id;
 
     /* we know we are the only ones flushing things, no extra race
      * protection is required.
      */
 restart:
-    entry = SB_JOURNAL(p_s_sb)->j_journal_list.next;
+    entry = journal->j_journal_list.next;
+    /* Did we wrap? */
+    if (entry == &journal->j_journal_list)
+        return 0;
     other_jl = JOURNAL_LIST_ENTRY(entry);
     if (other_jl->j_trans_id < trans_id) {
+        BUG_ON (other_jl->j_refcount <= 0);
 	/* do not flush all */
 	flush_journal_list(p_s_sb, other_jl, 0) ;
 
@@ -1205,9 +1216,10 @@
 
 static void del_from_work_list(struct super_block *s,
                                struct reiserfs_journal_list *jl) {
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
     if (!list_empty(&jl->j_working_list)) {
 	list_del_init(&jl->j_working_list);
-	SB_JOURNAL(s)->j_num_work_lists--;
+	journal->j_num_work_lists--;
     }
 }
 
@@ -1229,27 +1241,26 @@
   int was_dirty = 0 ;
   struct buffer_head *saved_bh ; 
   unsigned long j_len_saved = jl->j_len ;
+  struct reiserfs_journal *journal = SB_JOURNAL (s);
+  int err = 0;
 
-  if (j_len_saved <= 0) {
-    BUG();
-  }
+  BUG_ON (j_len_saved <= 0);
 
-  if (atomic_read(&SB_JOURNAL(s)->j_wcount) != 0) {
+  if (atomic_read(&journal->j_wcount) != 0) {
     reiserfs_warning(s, "clm-2048: flush_journal_list called with wcount %d",
-                      atomic_read(&SB_JOURNAL(s)->j_wcount)) ;
+                      atomic_read(&journal->j_wcount)) ;
   }
-  if (jl->j_trans_id == 0)
-    BUG();
+  BUG_ON (jl->j_trans_id == 0);
 
   /* if flushall == 0, the lock is already held */
   if (flushall) {
-      down(&SB_JOURNAL(s)->j_flush_sem);
-  } else if (!down_trylock(&SB_JOURNAL(s)->j_flush_sem)) {
+      down(&journal->j_flush_sem);
+  } else if (!down_trylock(&journal->j_flush_sem)) {
       BUG();
   }
 
   count = 0 ;
-  if (j_len_saved > SB_JOURNAL_TRANS_MAX(s)) {
+  if (j_len_saved > journal->j_trans_max) {
     reiserfs_panic(s, "journal-715: flush_journal_list, length is %lu, trans id %lu\n", j_len_saved, jl->j_trans_id);
     return 0 ;
   }
@@ -1265,7 +1276,7 @@
   */
   flush_commit_list(s, jl, 1) ;
 
-  if (!(jl->j_state & LIST_DIRTY))
+  if (!(jl->j_state & LIST_DIRTY) && !reiserfs_is_journal_aborted (journal))
       BUG();
 
   /* are we done now? */
@@ -1277,7 +1288,7 @@
   /* loop through each cnode, see if we need to write it, 
   ** or wait on a more recent transaction, or just ignore it 
   */
-  if (atomic_read(&(SB_JOURNAL(s)->j_wcount)) != 0) {
+  if (atomic_read(&(journal->j_wcount)) != 0) {
     reiserfs_panic(s, "journal-844: panic journal list is flushing, wcount is not 0\n") ;
   }
   cn = jl->j_realblock ;
@@ -1289,6 +1300,11 @@
     if (cn->blocknr == 0) {
       goto free_cnode ;
     }
+
+    /* This transaction failed commit. Don't write out to the disk */
+    if (!(jl->j_state & LIST_DIRTY))
+        goto free_cnode;
+
     pjl = find_newer_jl_for_cn(cn) ;
     /* the order is important here.  We check pjl to make sure we
     ** don't clear BH_JDirty_wait if we aren't the one writing this
@@ -1303,8 +1319,7 @@
       get_bh(saved_bh) ;
 
       if (buffer_journal_dirty(saved_bh)) {
-	if (!can_dirty(cn))
-	  BUG();
+        BUG_ON (!can_dirty (cn));
         was_jwait = 1 ;
         was_dirty = 1 ;
       } else if (can_dirty(cn)) {
@@ -1344,8 +1359,7 @@
       get_bh(saved_bh) ;
       set_bit(BLOCK_NEEDS_FLUSH, &cn->state) ;
       lock_buffer(saved_bh);
-      if (cn->blocknr != saved_bh->b_blocknr)
-        BUG();
+      BUG_ON (cn->blocknr != saved_bh->b_blocknr);
       if (buffer_dirty(saved_bh))
         submit_logged_buffer(saved_bh) ;
       else
@@ -1377,14 +1391,16 @@
 	if (!cn->bh) {
 	  reiserfs_panic(s, "journal-1012: cn->bh is NULL\n") ;
 	}
-	if (!buffer_uptodate(cn->bh)) {
-	  reiserfs_panic(s, "journal-949: buffer write failed\n") ;
-	}
+	if (unlikely (!buffer_uptodate(cn->bh))) {
+#ifdef CONFIG_REISERFS_CHECK
+	  reiserfs_warning(s, "journal-949: buffer write failed\n") ;
+#endif
+          err = -EIO;
+  	}
 	/* note, we must clear the JDirty_wait bit after the up to date
 	** check, otherwise we race against our flushpage routine
 	*/
-	if (!test_and_clear_bit(BH_JDirty_wait, &cn->bh->b_state))
-	    BUG();
+        BUG_ON (!test_clear_buffer_journal_dirty (cn->bh));
 
         /* undo the inc from journal_mark_dirty */
 	put_bh(cn->bh) ;
@@ -1394,7 +1410,11 @@
     }
   }
 
+  if (err)
+    reiserfs_abort (s, -EIO, "Write error while pushing transaction to disk in %s", __FUNCTION__);
 flush_older_and_return:
+
+
   /* before we can update the journal header block, we _must_ flush all 
   ** real blocks from all older transactions to disk.  This is because
   ** once the header block is updated, this transaction will not be
@@ -1404,6 +1424,7 @@
     flush_older_journal_lists(s, jl);
   } 
   
+  err = journal->j_errno;
   /* before we can remove everything from the hash tables for this 
   ** transaction, we must make sure it can never be replayed
   **
@@ -1412,21 +1433,23 @@
   ** we only need to update the journal header block for the last list
   ** being flushed
   */
-  if (flushall) {
-    update_journal_header_block(s, (jl->j_start + jl->j_len + 2) % SB_ONDISK_JOURNAL_SIZE(s), jl->j_trans_id) ;
+  if (!err && flushall) {
+    err = update_journal_header_block(s, (jl->j_start + jl->j_len + 2) % SB_ONDISK_JOURNAL_SIZE(s), jl->j_trans_id) ;
+    if (err)
+        reiserfs_abort (s, -EIO, "Write error while updating journal header in %s", __FUNCTION__);
   }
   remove_all_from_journal_list(s, jl, 0) ;
-  list_del(&jl->j_list);
-  SB_JOURNAL(s)->j_num_lists--;
+  list_del_init(&jl->j_list);
+  journal->j_num_lists--;
   del_from_work_list(s, jl);
 
-  if (SB_JOURNAL(s)->j_last_flush_id != 0 &&
-     (jl->j_trans_id - SB_JOURNAL(s)->j_last_flush_id) != 1) {
+  if (journal->j_last_flush_id != 0 &&
+     (jl->j_trans_id - journal->j_last_flush_id) != 1) {
       reiserfs_warning(s, "clm-2201: last flush %lu, current %lu",
-                       SB_JOURNAL(s)->j_last_flush_id,
+                       journal->j_last_flush_id,
 		       jl->j_trans_id);
   }
-  SB_JOURNAL(s)->j_last_flush_id = jl->j_trans_id;
+  journal->j_last_flush_id = jl->j_trans_id;
 
   /* not strictly required since we are freeing the list, but it should
    * help find code using dead lists later on
@@ -1440,8 +1463,8 @@
   jl->j_state = 0;
   put_journal_list(s, jl);
   if (flushall)
-    up(&SB_JOURNAL(s)->j_flush_sem);
-  return 0 ;
+    up(&journal->j_flush_sem);
+  return err ;
 } 
 
 static int write_one_transaction(struct super_block *s,
@@ -1476,7 +1499,7 @@
 	    lock_buffer(tmp_bh);
 	    if (cn->bh && can_dirty(cn) && buffer_dirty(tmp_bh)) {
 		if (!buffer_journal_dirty(tmp_bh) ||
-		    reiserfs_buffer_prepared(tmp_bh))
+		    buffer_journal_prepared(tmp_bh))
 		    BUG();
 		add_to_chunk(chunk, tmp_bh, NULL, write_chunk);
 		ret++;
@@ -1511,17 +1534,16 @@
 	pjl = find_newer_jl_for_cn(cn) ;
         if (!pjl && cn->blocknr && cn->bh && buffer_journal_dirty(cn->bh))
 	{
-	    if (!can_dirty(cn))
-	        BUG();
+	    BUG_ON (!can_dirty(cn));
 	    /* if the buffer is prepared, it will either be logged
 	     * or restored.  If restored, we need to make sure
 	     * it actually gets marked dirty
 	     */
-	    mark_buffer_notjournal_new(cn->bh) ;
-	    if (test_bit(BH_JPrepared, &cn->bh->b_state)) {
-	        set_bit(BH_JRestore_dirty, &cn->bh->b_state);
+            clear_buffer_journal_new (cn->bh);
+            if (buffer_journal_prepared (cn->bh)) {
+                set_buffer_journal_restore_dirty (cn->bh);
 	    } else {
-	        set_bit(BH_JTest, &cn->bh->b_state);
+                set_buffer_journal_test (cn->bh);
 	        mark_buffer_dirty(cn->bh);
 	    }
         } 
@@ -1542,9 +1564,10 @@
     unsigned long orig_trans_id = jl->j_trans_id;
     struct buffer_chunk chunk;
     struct list_head *entry;
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
     chunk.nr = 0;
 
-    down(&SB_JOURNAL(s)->j_flush_sem);
+    down(&journal->j_flush_sem);
     if (!journal_list_still_alive(s, orig_trans_id)) {
 	goto done;
     }
@@ -1556,7 +1579,7 @@
           (!num_trans && written < num_blocks)) {
 
 	if (jl->j_len == 0 || (jl->j_state & LIST_TOUCHED) ||
-	    atomic_read(&jl->j_commit_left))
+	    atomic_read(&jl->j_commit_left) || !(jl->j_state & LIST_DIRTY))
 	{
 	    del_from_work_list(s, jl);
 	    break;
@@ -1570,7 +1593,7 @@
 	entry = jl->j_list.next;
 
 	/* did we wrap? */
-	if (entry == &SB_JOURNAL(s)->j_journal_list) {
+	if (entry == &journal->j_journal_list) {
 	    break;
         }
 	jl = JOURNAL_LIST_ENTRY(entry);
@@ -1584,7 +1607,7 @@
     }
 
 done:
-    up(&SB_JOURNAL(s)->j_flush_sem);
+    up(&journal->j_flush_sem);
     return ret;
 }
 
@@ -1607,6 +1630,7 @@
     struct reiserfs_journal_list *tjl;
     struct reiserfs_journal_list *flush_jl;
     unsigned long trans_id;
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
 
     flush_jl = tjl = jl;
 
@@ -1625,7 +1649,7 @@
 	}
 	len += cur_len;
 	flush_jl = tjl;
-	if (tjl->j_list.next == &SB_JOURNAL(s)->j_journal_list)
+	if (tjl->j_list.next == &journal->j_journal_list)
 	    break;
 	tjl = JOURNAL_LIST_ENTRY(tjl->j_list.next);
     }
@@ -1681,21 +1705,22 @@
 }
 
 static void free_journal_ram(struct super_block *p_s_sb) {
-  reiserfs_kfree(SB_JOURNAL(p_s_sb)->j_current_jl,
+  struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+  reiserfs_kfree(journal->j_current_jl,
                  sizeof(struct reiserfs_journal_list), p_s_sb);
-  SB_JOURNAL(p_s_sb)->j_num_lists--;
+  journal->j_num_lists--;
 
-  vfree(SB_JOURNAL(p_s_sb)->j_cnode_free_orig) ;
-  free_list_bitmaps(p_s_sb, SB_JOURNAL(p_s_sb)->j_list_bitmap) ;
+  vfree(journal->j_cnode_free_orig) ;
+  free_list_bitmaps(p_s_sb, journal->j_list_bitmap) ;
   free_bitmap_nodes(p_s_sb) ; /* must be after free_list_bitmaps */
-  if (SB_JOURNAL(p_s_sb)->j_header_bh) {
-    brelse(SB_JOURNAL(p_s_sb)->j_header_bh) ;
+  if (journal->j_header_bh) {
+    brelse(journal->j_header_bh) ;
   }
   /* j_header_bh is on the journal dev, make sure not to release the journal
    * dev until we brelse j_header_bh
    */
-  release_journal_dev(p_s_sb, SB_JOURNAL(p_s_sb));
-  vfree(SB_JOURNAL(p_s_sb)) ;
+  release_journal_dev(p_s_sb, journal);
+  vfree(journal) ;
 }
 
 /*
@@ -1704,18 +1729,33 @@
 */
 static int do_journal_release(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, int error) {
   struct reiserfs_transaction_handle myth ;
+  int flushed = 0;
+  struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
 
   /* we only want to flush out transactions if we were called with error == 0
   */
   if (!error && !(p_s_sb->s_flags & MS_RDONLY)) {
     /* end the current trans */
+    BUG_ON (!th->t_trans_id);
     do_journal_end(th, p_s_sb,10, FLUSH_ALL) ;
 
     /* make sure something gets logged to force our way into the flush code */
-    journal_join(&myth, p_s_sb, 1) ;
-    reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
-    journal_mark_dirty(&myth, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
-    do_journal_end(&myth, p_s_sb,1, FLUSH_ALL) ;
+    if (!journal_join(&myth, p_s_sb, 1)) {
+        reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
+        journal_mark_dirty(&myth, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
+        do_journal_end(&myth, p_s_sb,1, FLUSH_ALL) ;
+        flushed = 1;
+    }
+  }
+
+  /* this also catches errors during the do_journal_end above */
+  if (!error && reiserfs_is_journal_aborted(journal)) {
+      memset(&myth, 0, sizeof(myth));
+      if (!journal_join_abort(&myth, p_s_sb, 1)) {
+	  reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
+	  journal_mark_dirty(&myth, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
+          do_journal_end(&myth, p_s_sb, 1, FLUSH_ALL) ;
+      }
   }
 
   reiserfs_mounted_fs_count-- ;
@@ -1750,7 +1790,7 @@
 			               struct reiserfs_journal_commit *commit) {
   if (get_commit_trans_id (commit) != get_desc_trans_id (desc) || 
       get_commit_trans_len (commit) != get_desc_trans_len (desc) || 
-      get_commit_trans_len (commit) > SB_JOURNAL_TRANS_MAX(p_s_sb) || 
+      get_commit_trans_len (commit) > SB_JOURNAL(p_s_sb)->j_trans_max ||
       get_commit_trans_len (commit) <= 0 
   ) {
     return 1 ;
@@ -1786,7 +1826,7 @@
 		     *newest_mount_id) ;
       return -1 ;
     }
-    if ( get_desc_trans_len(desc) > SB_JOURNAL_TRANS_MAX(p_s_sb) ) {
+    if ( get_desc_trans_len(desc) > SB_JOURNAL(p_s_sb)->j_trans_max ) {
       reiserfs_warning(p_s_sb, "journal-2018: Bad transaction length %d encountered, ignoring transaction", get_desc_trans_len(desc));
       return -1 ;
     }
@@ -1839,6 +1879,7 @@
 */
 static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cur_dblock, unsigned long oldest_start, 
 				    unsigned long oldest_trans_id, unsigned long newest_mount_id) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_desc *desc ;
   struct reiserfs_journal_commit *commit ;
   unsigned long trans_id = 0 ;
@@ -1971,9 +2012,9 @@
 		 cur_dblock -  SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb)) ;
   
   /* init starting values for the first transaction, in case this is the last transaction to be replayed. */
-  SB_JOURNAL(p_s_sb)->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
-  SB_JOURNAL(p_s_sb)->j_last_flush_trans_id = trans_id ;
-  SB_JOURNAL(p_s_sb)->j_trans_id = trans_id + 1;
+  journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
+  journal->j_last_flush_trans_id = trans_id ;
+  journal->j_trans_id = trans_id + 1;
   brelse(c_bh) ;
   brelse(d_bh) ;
   reiserfs_kfree(log_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
@@ -2033,6 +2074,7 @@
 ** On exit, it sets things up so the first transaction will work correctly.
 */
 static int journal_read(struct super_block *p_s_sb) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_desc *desc ;
   unsigned long oldest_trans_id = 0;
   unsigned long oldest_invalid_trans_id = 0 ;
@@ -2050,20 +2092,20 @@
 
   cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
   reiserfs_info (p_s_sb, "checking transaction log (%s)\n",
-	 bdevname(SB_JOURNAL(p_s_sb)->j_dev_bd, b));
+	 bdevname(journal->j_dev_bd, b));
   start = get_seconds();
 
   /* step 1, read in the journal header block.  Check the transaction it says 
   ** is the first unflushed, and if that transaction is not valid, 
   ** replay is done
   */
-  SB_JOURNAL(p_s_sb)->j_header_bh = journal_bread(p_s_sb,
+  journal->j_header_bh = journal_bread(p_s_sb,
 					   SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 
 					   SB_ONDISK_JOURNAL_SIZE(p_s_sb));
-  if (!SB_JOURNAL(p_s_sb)->j_header_bh) {
+  if (!journal->j_header_bh) {
     return 1 ;
   }
-  jh = (struct reiserfs_journal_header *)(SB_JOURNAL(p_s_sb)->j_header_bh->b_data) ;
+  jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data) ;
   if (le32_to_cpu(jh->j_first_unflushed_offset) >= 0 && 
       le32_to_cpu(jh->j_first_unflushed_offset) < SB_ONDISK_JOURNAL_SIZE(p_s_sb) && 
       le32_to_cpu(jh->j_last_flush_trans_id) > 0) {
@@ -2102,7 +2144,7 @@
   while(continue_replay && cur_dblock < (SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb))) {
     /* Note that it is required for blocksize of primary fs device and journal
        device to be the same */
-    d_bh = reiserfs_breada(SB_JOURNAL(p_s_sb)->j_dev_bd, cur_dblock, p_s_sb->s_blocksize,
+    d_bh = reiserfs_breada(journal->j_dev_bd, cur_dblock, p_s_sb->s_blocksize,
 			   SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb)) ;
     ret = journal_transaction_is_valid(p_s_sb, d_bh, &oldest_invalid_trans_id, &newest_mount_id) ;
     if (ret == 1) {
@@ -2153,7 +2195,7 @@
     } else if (ret != 0) {
       break ;
     }
-    cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_JOURNAL(p_s_sb)->j_start ;
+    cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + journal->j_start ;
     replay_count++ ;
    if (cur_dblock == oldest_start)
         break;
@@ -2168,23 +2210,23 @@
   ** copy the trans_id from the header
   */
   if (valid_journal_header && replay_count == 0) { 
-    SB_JOURNAL(p_s_sb)->j_start = le32_to_cpu(jh->j_first_unflushed_offset) ;
-    SB_JOURNAL(p_s_sb)->j_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) + 1;
-    SB_JOURNAL(p_s_sb)->j_last_flush_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) ;
-    SB_JOURNAL(p_s_sb)->j_mount_id = le32_to_cpu(jh->j_mount_id) + 1;
+    journal->j_start = le32_to_cpu(jh->j_first_unflushed_offset) ;
+    journal->j_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) + 1;
+    journal->j_last_flush_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) ;
+    journal->j_mount_id = le32_to_cpu(jh->j_mount_id) + 1;
   } else {
-    SB_JOURNAL(p_s_sb)->j_mount_id = newest_mount_id + 1 ;
+    journal->j_mount_id = newest_mount_id + 1 ;
   }
   reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1299: Setting "
-                 "newest_mount_id to %lu", SB_JOURNAL(p_s_sb)->j_mount_id) ;
-  SB_JOURNAL(p_s_sb)->j_first_unflushed_offset = SB_JOURNAL(p_s_sb)->j_start ; 
+                 "newest_mount_id to %lu", journal->j_mount_id) ;
+  journal->j_first_unflushed_offset = journal->j_start ;
   if (replay_count > 0) {
     reiserfs_info (p_s_sb, "replayed %d transactions in %lu seconds\n",
 		   replay_count, get_seconds() - start) ;
   }
   if (!bdev_read_only(p_s_sb->s_bdev) && 
-       _update_journal_header_block(p_s_sb, SB_JOURNAL(p_s_sb)->j_start, 
-                                   SB_JOURNAL(p_s_sb)->j_last_flush_trans_id))
+       _update_journal_header_block(p_s_sb, journal->j_start,
+                                   journal->j_last_flush_trans_id))
   {
       /* replay failed, caller must call free_journal_ram and abort
       ** the mount
@@ -2319,12 +2361,13 @@
 	return 1 ;
     }
     memset(journal, 0, sizeof(struct reiserfs_journal)) ;
-    INIT_LIST_HEAD(&SB_JOURNAL(p_s_sb)->j_bitmap_nodes) ;
-    INIT_LIST_HEAD (&SB_JOURNAL(p_s_sb)->j_prealloc_list);
-    INIT_LIST_HEAD(&SB_JOURNAL(p_s_sb)->j_working_list);
-    INIT_LIST_HEAD(&SB_JOURNAL(p_s_sb)->j_journal_list);
+    INIT_LIST_HEAD(&journal->j_bitmap_nodes) ;
+    INIT_LIST_HEAD (&journal->j_prealloc_list);
+    INIT_LIST_HEAD(&journal->j_working_list);
+    INIT_LIST_HEAD(&journal->j_journal_list);
+    journal->j_persistent_trans = 0;
     if (reiserfs_allocate_list_bitmaps(p_s_sb,
-				       SB_JOURNAL(p_s_sb)->j_list_bitmap,
+				       journal->j_list_bitmap,
  				       SB_BMAP_NR(p_s_sb)))
 	goto free_and_return ;
     allocate_bitmap_nodes(p_s_sb) ;
@@ -2369,108 +2412,108 @@
 			   "(device %s) does not match to magic found in super "
 			   "block %x",
 			   jh->jh_journal.jp_journal_magic,
-			   bdevname( SB_JOURNAL(p_s_sb)->j_dev_bd, b),
+			   bdevname( journal->j_dev_bd, b),
 			   sb_jp_journal_magic(rs));
 	 brelse (bhjh);
 	 goto free_and_return;
   }
      
-  SB_JOURNAL_TRANS_MAX(p_s_sb)      = le32_to_cpu (jh->jh_journal.jp_journal_trans_max);
-  SB_JOURNAL_MAX_BATCH(p_s_sb)      = le32_to_cpu (jh->jh_journal.jp_journal_max_batch);
-  SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb) = le32_to_cpu (jh->jh_journal.jp_journal_max_commit_age);
-  SB_JOURNAL_MAX_TRANS_AGE(p_s_sb)  = JOURNAL_MAX_TRANS_AGE;
+  journal->j_trans_max      = le32_to_cpu (jh->jh_journal.jp_journal_trans_max);
+  journal->j_max_batch      = le32_to_cpu (jh->jh_journal.jp_journal_max_batch);
+  journal->j_max_commit_age = le32_to_cpu (jh->jh_journal.jp_journal_max_commit_age);
+  journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
 
-  if (SB_JOURNAL_TRANS_MAX(p_s_sb)) {
+  if (journal->j_trans_max) {
     /* make sure these parameters are available, assign it if they are not */
-    __u32 initial = SB_JOURNAL_TRANS_MAX(p_s_sb);
+    __u32 initial = journal->j_trans_max;
     __u32 ratio = 1;
     
     if (p_s_sb->s_blocksize < 4096)
       ratio = 4096 / p_s_sb->s_blocksize;
     
-    if (SB_ONDISK_JOURNAL_SIZE(p_s_sb)/SB_JOURNAL_TRANS_MAX(p_s_sb) < JOURNAL_MIN_RATIO)
-      SB_JOURNAL_TRANS_MAX(p_s_sb) = SB_ONDISK_JOURNAL_SIZE(p_s_sb) / JOURNAL_MIN_RATIO;
-    if (SB_JOURNAL_TRANS_MAX(p_s_sb) > JOURNAL_TRANS_MAX_DEFAULT / ratio)
-      SB_JOURNAL_TRANS_MAX(p_s_sb) = JOURNAL_TRANS_MAX_DEFAULT / ratio;
-    if (SB_JOURNAL_TRANS_MAX(p_s_sb) < JOURNAL_TRANS_MIN_DEFAULT / ratio)
-      SB_JOURNAL_TRANS_MAX(p_s_sb) = JOURNAL_TRANS_MIN_DEFAULT / ratio;
+    if (SB_ONDISK_JOURNAL_SIZE(p_s_sb)/journal->j_trans_max < JOURNAL_MIN_RATIO)
+      journal->j_trans_max = SB_ONDISK_JOURNAL_SIZE(p_s_sb) / JOURNAL_MIN_RATIO;
+    if (journal->j_trans_max > JOURNAL_TRANS_MAX_DEFAULT / ratio)
+      journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT / ratio;
+    if (journal->j_trans_max < JOURNAL_TRANS_MIN_DEFAULT / ratio)
+      journal->j_trans_max = JOURNAL_TRANS_MIN_DEFAULT / ratio;
     
-    if (SB_JOURNAL_TRANS_MAX(p_s_sb) != initial)
+    if (journal->j_trans_max != initial)
       reiserfs_warning (p_s_sb, "sh-461: journal_init: wrong transaction max size (%u). Changed to %u",
-	      initial, SB_JOURNAL_TRANS_MAX(p_s_sb));
+	      initial, journal->j_trans_max);
 
-    SB_JOURNAL_MAX_BATCH(p_s_sb) = SB_JOURNAL_TRANS_MAX(p_s_sb)*
+    journal->j_max_batch = journal->j_trans_max*
       JOURNAL_MAX_BATCH_DEFAULT/JOURNAL_TRANS_MAX_DEFAULT;
   }  
   
-  if (!SB_JOURNAL_TRANS_MAX(p_s_sb)) {
+  if (!journal->j_trans_max) {
     /*we have the file system was created by old version of mkreiserfs 
       so this field contains zero value */
-    SB_JOURNAL_TRANS_MAX(p_s_sb)      = JOURNAL_TRANS_MAX_DEFAULT ;
-    SB_JOURNAL_MAX_BATCH(p_s_sb)      = JOURNAL_MAX_BATCH_DEFAULT ;  
-    SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb) = JOURNAL_MAX_COMMIT_AGE ;
+    journal->j_trans_max      = JOURNAL_TRANS_MAX_DEFAULT ;
+    journal->j_max_batch      = JOURNAL_MAX_BATCH_DEFAULT ;
+    journal->j_max_commit_age = JOURNAL_MAX_COMMIT_AGE ;
     
     /* for blocksize >= 4096 - max transaction size is 1024. For block size < 4096
        trans max size is decreased proportionally */
     if (p_s_sb->s_blocksize < 4096) {
-      SB_JOURNAL_TRANS_MAX(p_s_sb) /= (4096 / p_s_sb->s_blocksize) ;
-      SB_JOURNAL_MAX_BATCH(p_s_sb) = (SB_JOURNAL_TRANS_MAX(p_s_sb)) * 9 / 10 ;
+      journal->j_trans_max /= (4096 / p_s_sb->s_blocksize) ;
+      journal->j_max_batch = (journal->j_trans_max) * 9 / 10 ;
     }
   }
 
-  SB_JOURNAL_DEFAULT_MAX_COMMIT_AGE(p_s_sb) = SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb);
+  journal->j_default_max_commit_age = journal->j_max_commit_age;
 
   if (commit_max_age != 0) {
-      SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb) = commit_max_age;
-      SB_JOURNAL_MAX_TRANS_AGE(p_s_sb) = commit_max_age;
+      journal->j_max_commit_age = commit_max_age;
+      journal->j_max_trans_age = commit_max_age;
   }
 
   reiserfs_info (p_s_sb, "journal params: device %s, size %u, "
 		 "journal first block %u, max trans len %u, max batch %u, "
 		 "max commit age %u, max trans age %u\n",
-		 bdevname( SB_JOURNAL(p_s_sb)->j_dev_bd, b),
+		 bdevname( journal->j_dev_bd, b),
 		 SB_ONDISK_JOURNAL_SIZE(p_s_sb),
 		 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
-		 SB_JOURNAL_TRANS_MAX(p_s_sb),
-		 SB_JOURNAL_MAX_BATCH(p_s_sb),
-		 SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb),
-		 SB_JOURNAL_MAX_TRANS_AGE(p_s_sb));
+		 journal->j_trans_max,
+		 journal->j_max_batch,
+		 journal->j_max_commit_age,
+		 journal->j_max_trans_age);
 
   brelse (bhjh);
      
-  SB_JOURNAL(p_s_sb)->j_list_bitmap_index = 0 ;
+  journal->j_list_bitmap_index = 0 ;
   journal_list_init(p_s_sb) ;
 
-  memset(SB_JOURNAL(p_s_sb)->j_list_hash_table, 0, JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)) ;
+  memset(journal->j_list_hash_table, 0, JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)) ;
 
-  INIT_LIST_HEAD(&SB_JOURNAL(p_s_sb)->j_dirty_buffers) ;
-  spin_lock_init(&SB_JOURNAL(p_s_sb)->j_dirty_buffers_lock) ;
+  INIT_LIST_HEAD(&journal->j_dirty_buffers) ;
+  spin_lock_init(&journal->j_dirty_buffers_lock) ;
 
-  SB_JOURNAL(p_s_sb)->j_start = 0 ;
-  SB_JOURNAL(p_s_sb)->j_len = 0 ;
-  SB_JOURNAL(p_s_sb)->j_len_alloc = 0 ;
-  atomic_set(&(SB_JOURNAL(p_s_sb)->j_wcount), 0) ;
-  atomic_set(&(SB_JOURNAL(p_s_sb)->j_async_throttle), 0) ;
-  SB_JOURNAL(p_s_sb)->j_bcount = 0 ;	  
-  SB_JOURNAL(p_s_sb)->j_trans_start_time = 0 ;	  
-  SB_JOURNAL(p_s_sb)->j_last = NULL ;	  
-  SB_JOURNAL(p_s_sb)->j_first = NULL ;     
-  init_waitqueue_head(&(SB_JOURNAL(p_s_sb)->j_join_wait)) ;
-  sema_init(&SB_JOURNAL(p_s_sb)->j_lock, 1);
-  sema_init(&SB_JOURNAL(p_s_sb)->j_flush_sem, 1);
-
-  SB_JOURNAL(p_s_sb)->j_trans_id = 10 ;  
-  SB_JOURNAL(p_s_sb)->j_mount_id = 10 ; 
-  SB_JOURNAL(p_s_sb)->j_state = 0 ;
-  atomic_set(&(SB_JOURNAL(p_s_sb)->j_jlock), 0) ;
-  SB_JOURNAL(p_s_sb)->j_cnode_free_list = allocate_cnodes(num_cnodes) ;
-  SB_JOURNAL(p_s_sb)->j_cnode_free_orig = SB_JOURNAL(p_s_sb)->j_cnode_free_list ;
-  SB_JOURNAL(p_s_sb)->j_cnode_free = SB_JOURNAL(p_s_sb)->j_cnode_free_list ? num_cnodes : 0 ;
-  SB_JOURNAL(p_s_sb)->j_cnode_used = 0 ;
-  SB_JOURNAL(p_s_sb)->j_must_wait = 0 ;
+  journal->j_start = 0 ;
+  journal->j_len = 0 ;
+  journal->j_len_alloc = 0 ;
+  atomic_set(&(journal->j_wcount), 0) ;
+  atomic_set(&(journal->j_async_throttle), 0) ;
+  journal->j_bcount = 0 ;
+  journal->j_trans_start_time = 0 ;
+  journal->j_last = NULL ;
+  journal->j_first = NULL ;
+  init_waitqueue_head(&(journal->j_join_wait)) ;
+  sema_init(&journal->j_lock, 1);
+  sema_init(&journal->j_flush_sem, 1);
+
+  journal->j_trans_id = 10 ;
+  journal->j_mount_id = 10 ;
+  journal->j_state = 0 ;
+  atomic_set(&(journal->j_jlock), 0) ;
+  journal->j_cnode_free_list = allocate_cnodes(num_cnodes) ;
+  journal->j_cnode_free_orig = journal->j_cnode_free_list ;
+  journal->j_cnode_free = journal->j_cnode_free_list ? num_cnodes : 0 ;
+  journal->j_cnode_used = 0 ;
+  journal->j_must_wait = 0 ;
 
   init_journal_hash(p_s_sb) ;
-  jl = SB_JOURNAL(p_s_sb)->j_current_jl;
+  jl = journal->j_current_jl;
   jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
   if (!jl->j_list_bitmap) {
     reiserfs_warning(p_s_sb, "journal-2005, get_list_bitmap failed for journal list 0") ;
@@ -2498,15 +2541,17 @@
 ** transaction
 */
 int journal_transaction_should_end(struct reiserfs_transaction_handle *th, int new_alloc) {
+  struct reiserfs_journal *journal = SB_JOURNAL (th->t_super);
   time_t now = get_seconds() ;
   /* cannot restart while nested */
+  BUG_ON (!th->t_trans_id);
   if (th->t_refcount > 1)
     return 0 ;
-  if ( SB_JOURNAL(th->t_super)->j_must_wait > 0 ||
-       (SB_JOURNAL(th->t_super)->j_len_alloc + new_alloc) >= SB_JOURNAL_MAX_BATCH(th->t_super) || 
-       atomic_read(&(SB_JOURNAL(th->t_super)->j_jlock)) ||
-      (now - SB_JOURNAL(th->t_super)->j_trans_start_time) > SB_JOURNAL_MAX_TRANS_AGE(th->t_super) ||
-       SB_JOURNAL(th->t_super)->j_cnode_free < (SB_JOURNAL_TRANS_MAX(th->t_super) * 3)) { 
+  if ( journal->j_must_wait > 0 ||
+       (journal->j_len_alloc + new_alloc) >= journal->j_max_batch ||
+       atomic_read(&(journal->j_jlock)) ||
+      (now - journal->j_trans_start_time) > journal->j_max_trans_age ||
+       journal->j_cnode_free < (journal->j_trans_max * 3)) {
     return 1 ;
   }
   return 0 ;
@@ -2516,9 +2561,10 @@
 ** kernel_lock to be held
 */
 void reiserfs_block_writes(struct reiserfs_transaction_handle *th) {
-    struct super_block *s = th->t_super ;
-    SB_JOURNAL(s)->j_must_wait = 1 ;
-    set_bit(WRITERS_BLOCKED, &SB_JOURNAL(s)->j_state) ;
+    struct reiserfs_journal *journal = SB_JOURNAL (th->t_super);
+    BUG_ON (!th->t_trans_id);
+    journal->j_must_wait = 1 ;
+    set_bit(J_WRITERS_BLOCKED, &journal->j_state) ;
     return ;
 }
 
@@ -2526,58 +2572,63 @@
 ** require BKL
 */
 void reiserfs_allow_writes(struct super_block *s) {
-    clear_bit(WRITERS_BLOCKED, &SB_JOURNAL(s)->j_state) ;
-    wake_up(&SB_JOURNAL(s)->j_join_wait) ;
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
+    clear_bit(J_WRITERS_BLOCKED, &journal->j_state) ;
+    wake_up(&journal->j_join_wait) ;
 }
 
 /* this must be called without a transaction started, and does not
 ** require BKL
 */
 void reiserfs_wait_on_write_block(struct super_block *s) {
-    wait_event(SB_JOURNAL(s)->j_join_wait, 
-               !test_bit(WRITERS_BLOCKED, &SB_JOURNAL(s)->j_state)) ;
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
+    wait_event(journal->j_join_wait,
+               !test_bit(J_WRITERS_BLOCKED, &journal->j_state)) ;
 }
 
 static void queue_log_writer(struct super_block *s) {
     wait_queue_t wait;
-    set_bit(WRITERS_QUEUED, &SB_JOURNAL(s)->j_state);
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
+    set_bit(J_WRITERS_QUEUED, &journal->j_state);
 
     /*
      * we don't want to use wait_event here because
      * we only want to wait once.
      */
     init_waitqueue_entry(&wait, current);
-    add_wait_queue(&SB_JOURNAL(s)->j_join_wait, &wait);
+    add_wait_queue(&journal->j_join_wait, &wait);
     set_current_state(TASK_UNINTERRUPTIBLE);
-    if (test_bit(WRITERS_QUEUED, &SB_JOURNAL(s)->j_state))
+    if (test_bit(J_WRITERS_QUEUED, &journal->j_state))
         schedule();
     current->state = TASK_RUNNING;
-    remove_wait_queue(&SB_JOURNAL(s)->j_join_wait, &wait);
+    remove_wait_queue(&journal->j_join_wait, &wait);
 }
 
 static void wake_queued_writers(struct super_block *s) {
-    if (test_and_clear_bit(WRITERS_QUEUED, &SB_JOURNAL(s)->j_state))
-        wake_up(&SB_JOURNAL(s)->j_join_wait);
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
+    if (test_and_clear_bit(J_WRITERS_QUEUED, &journal->j_state))
+        wake_up(&journal->j_join_wait);
 }
 
 static void let_transaction_grow(struct super_block *sb,
                                  unsigned long trans_id)
 {
-    unsigned long bcount = SB_JOURNAL(sb)->j_bcount;
+    struct reiserfs_journal *journal = SB_JOURNAL (sb);
+    unsigned long bcount = journal->j_bcount;
     while(1) {
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout(1);
-	SB_JOURNAL(sb)->j_current_jl->j_state |= LIST_COMMIT_PENDING;
-        while ((atomic_read(&SB_JOURNAL(sb)->j_wcount) > 0 ||
-	        atomic_read(&SB_JOURNAL(sb)->j_jlock)) &&
-	       SB_JOURNAL(sb)->j_trans_id == trans_id) {
+	journal->j_current_jl->j_state |= LIST_COMMIT_PENDING;
+        while ((atomic_read(&journal->j_wcount) > 0 ||
+	        atomic_read(&journal->j_jlock)) &&
+	       journal->j_trans_id == trans_id) {
 	    queue_log_writer(sb);
 	}
-	if (SB_JOURNAL(sb)->j_trans_id != trans_id)
+	if (journal->j_trans_id != trans_id)
 	    break;
-	if (bcount == SB_JOURNAL(sb)->j_bcount)
+	if (bcount == journal->j_bcount)
 	    break;
-	bcount = SB_JOURNAL(sb)->j_bcount;
+	bcount = journal->j_bcount;
     }
 }
 
@@ -2593,10 +2644,9 @@
   struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
   struct reiserfs_transaction_handle myth;
   int sched_count = 0;
+  int retval;
 
   reiserfs_check_lock_depth(p_s_sb, "journal_begin") ;
-  RFALSE( p_s_sb->s_flags & MS_RDONLY, 
-	  "clm-2078: calling journal_begin on readonly FS") ;
 
   PROC_INFO_INC( p_s_sb, journal.journal_being );
   /* set here for journal_join */
@@ -2605,9 +2655,14 @@
 
 relock:
   lock_journal(p_s_sb) ;
+  if (join != JBEGIN_ABORT && reiserfs_is_journal_aborted (journal)) {
+    unlock_journal (p_s_sb);
+    retval = journal->j_errno;
+    goto out_fail;
+  }
   journal->j_bcount++;
 
-  if (test_bit(WRITERS_BLOCKED, &journal->j_state)) {
+  if (test_bit(J_WRITERS_BLOCKED, &journal->j_state)) {
     unlock_journal(p_s_sb) ;
     reiserfs_wait_on_write_block(p_s_sb) ;
     PROC_INFO_INC( p_s_sb, journal.journal_relock_writers );
@@ -2621,17 +2676,17 @@
   */
 
   if ( (!join && journal->j_must_wait > 0) ||
-     ( !join && (journal->j_len_alloc + nblocks + 2) >= SB_JOURNAL_MAX_BATCH(p_s_sb)) ||
+     ( !join && (journal->j_len_alloc + nblocks + 2) >= journal->j_max_batch) ||
      (!join && atomic_read(&journal->j_wcount) > 0 && journal->j_trans_start_time > 0 &&
-      (now - journal->j_trans_start_time) > SB_JOURNAL_MAX_TRANS_AGE(p_s_sb)) ||
+      (now - journal->j_trans_start_time) > journal->j_max_trans_age) ||
      (!join && atomic_read(&journal->j_jlock)) ||
-     (!join && journal->j_cnode_free < (SB_JOURNAL_TRANS_MAX(p_s_sb) * 3))) {
+     (!join && journal->j_cnode_free < (journal->j_trans_max * 3))) {
 
     old_trans_id = journal->j_trans_id;
     unlock_journal(p_s_sb) ; /* allow others to finish this transaction */
 
     if (!join && (journal->j_len_alloc + nblocks + 2) >=
-        SB_JOURNAL_MAX_BATCH(p_s_sb) &&
+        journal->j_max_batch &&
 	((journal->j_len + nblocks + 2) * 100) < (journal->j_len_alloc * 75))
     {
 	if (atomic_read(&journal->j_wcount) > 10) {
@@ -2650,15 +2705,20 @@
         }
 	goto relock;
     }
-    journal_join(&myth, p_s_sb, 1) ;
+    retval = journal_join(&myth, p_s_sb, 1) ;
+    if (retval)
+        goto out_fail;
 
     /* someone might have ended the transaction while we joined */
-    if (old_trans_id != SB_JOURNAL(p_s_sb)->j_trans_id) {
-        do_journal_end(&myth, p_s_sb, 1, 0) ;
+    if (old_trans_id != journal->j_trans_id) {
+        retval = do_journal_end(&myth, p_s_sb, 1, 0) ;
     } else {
-        do_journal_end(&myth, p_s_sb, 1, COMMIT_NOW) ;
+        retval = do_journal_end(&myth, p_s_sb, 1, COMMIT_NOW) ;
     }
 
+    if (retval)
+        goto out_fail;
+
     PROC_INFO_INC( p_s_sb, journal.journal_relock_wcount );
     goto relock ;
   }
@@ -2672,7 +2732,16 @@
   th->t_blocks_allocated = nblocks ;
   th->t_trans_id = journal->j_trans_id ;
   unlock_journal(p_s_sb) ;
+  INIT_LIST_HEAD (&th->t_list);
   return 0 ;
+
+out_fail:
+  memset (th, 0, sizeof (*th));
+  /* Re-set th->t_super, so we can properly keep track of how many
+   * persistent transactions there are. We need to do this so if this
+   * call is part of a failed restart_transaction, we can free it later */
+  th->t_super = p_s_sb;
+  return retval;
 }
 
 struct reiserfs_transaction_handle *
@@ -2699,16 +2768,23 @@
 	reiserfs_kfree(th, sizeof(struct reiserfs_transaction_handle), s) ;
         return NULL;
     }
+
+    SB_JOURNAL(s)->j_persistent_trans++;
     return th ;
 }
 
 int
 reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *th) {
     struct super_block *s = th->t_super;
-    int ret;
-    ret = journal_end(th, th->t_super, th->t_blocks_allocated);
-    if (th->t_refcount == 0)
+    int ret = 0;
+    if (th->t_trans_id)
+        ret = journal_end(th, th->t_super, th->t_blocks_allocated);
+    else
+        ret = -EIO;
+    if (th->t_refcount == 0) {
+        SB_JOURNAL(s)->j_persistent_trans--;
 	reiserfs_kfree(th, sizeof(struct reiserfs_transaction_handle), s) ;
+    }
     return ret;
 }
 
@@ -2722,7 +2798,20 @@
   if (cur_th && cur_th->t_refcount > 1) {
       BUG() ;
   }
-  return do_journal_begin_r(th, p_s_sb, nblocks, 1) ;
+  return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_JOIN) ;
+}
+
+int journal_join_abort(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {
+  struct reiserfs_transaction_handle *cur_th = current->journal_info;
+
+  /* this keeps do_journal_end from NULLing out the current->journal_info
+  ** pointer
+  */
+  th->t_handle_save = cur_th ;
+  if (cur_th && cur_th->t_refcount > 1) {
+      BUG() ;
+  }
+  return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_ABORT) ;
 }
 
 int journal_begin(struct reiserfs_transaction_handle *th, struct super_block  * p_s_sb, unsigned long nblocks) {
@@ -2733,6 +2822,7 @@
     if (cur_th) {
 	/* we are nesting into the current transaction */
 	if (cur_th->t_super == p_s_sb) {
+              BUG_ON (!cur_th->t_refcount);
 	      cur_th->t_refcount++ ;
 	      memcpy(th, cur_th, sizeof(*th));
 	      if (th->t_refcount <= 1)
@@ -2750,9 +2840,18 @@
     } else {
 	current->journal_info = th;
     }
-    ret = do_journal_begin_r(th, p_s_sb, nblocks, 0) ;
+    ret = do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_REG) ;
     if (current->journal_info != th)
         BUG() ;
+
+    /* I guess this boils down to being the reciprocal of clm-2100 above.
+     * If do_journal_begin_r fails, we need to put it back, since journal_end
+     * won't be called to do it. */
+    if (ret)
+        current->journal_info = th->t_handle_save;
+    else
+        BUG_ON (!th->t_refcount);
+
     return ret ;
 }
 
@@ -2766,19 +2865,22 @@
 ** if j_len, is bigger than j_len_alloc, it pushes j_len_alloc to 10 + j_len.
 */
 int journal_mark_dirty(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, struct buffer_head *bh) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_cnode *cn = NULL;
   int count_already_incd = 0 ;
   int prepared = 0 ;
+  BUG_ON (!th->t_trans_id);
 
   PROC_INFO_INC( p_s_sb, journal.mark_dirty );
-  if (th->t_trans_id != SB_JOURNAL(p_s_sb)->j_trans_id) {
+  if (th->t_trans_id != journal->j_trans_id) {
     reiserfs_panic(th->t_super, "journal-1577: handle trans id %ld != current trans id %ld\n", 
-                   th->t_trans_id, SB_JOURNAL(p_s_sb)->j_trans_id);
+                   th->t_trans_id, journal->j_trans_id);
   }
+
   p_s_sb->s_dirt = 1;
 
-  prepared = test_and_clear_bit(BH_JPrepared, &bh->b_state) ;
-  clear_bit(BH_JRestore_dirty, &bh->b_state);
+  prepared = test_clear_buffer_journal_prepared (bh);
+  clear_buffer_journal_restore_dirty (bh);
   /* already in this transaction, we are done */
   if (buffer_journaled(bh)) {
     PROC_INFO_INC( p_s_sb, journal.mark_dirty_already );
@@ -2798,28 +2900,28 @@
 			    buffer_journal_dirty(bh) ? ' ' : '!') ;
   }
 
-  if (atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount)) <= 0) {
-    reiserfs_warning (p_s_sb, "journal-1409: journal_mark_dirty returning because j_wcount was %d", atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount))) ;
+  if (atomic_read(&(journal->j_wcount)) <= 0) {
+    reiserfs_warning (p_s_sb, "journal-1409: journal_mark_dirty returning because j_wcount was %d", atomic_read(&(journal->j_wcount))) ;
     return 1 ;
   }
   /* this error means I've screwed up, and we've overflowed the transaction.  
   ** Nothing can be done here, except make the FS readonly or panic.
   */ 
-  if (SB_JOURNAL(p_s_sb)->j_len >= SB_JOURNAL_TRANS_MAX(p_s_sb)) { 
-    reiserfs_panic(th->t_super, "journal-1413: journal_mark_dirty: j_len (%lu) is too big\n", SB_JOURNAL(p_s_sb)->j_len) ;
+  if (journal->j_len >= journal->j_trans_max) {
+    reiserfs_panic(th->t_super, "journal-1413: journal_mark_dirty: j_len (%lu) is too big\n", journal->j_len) ;
   }
 
   if (buffer_journal_dirty(bh)) {
     count_already_incd = 1 ;
     PROC_INFO_INC( p_s_sb, journal.mark_dirty_notjournal );
-    mark_buffer_notjournal_dirty(bh) ;
+    clear_buffer_journal_dirty (bh);
   }
 
-  if (SB_JOURNAL(p_s_sb)->j_len > SB_JOURNAL(p_s_sb)->j_len_alloc) {
-    SB_JOURNAL(p_s_sb)->j_len_alloc = SB_JOURNAL(p_s_sb)->j_len + JOURNAL_PER_BALANCE_CNT ;
+  if (journal->j_len > journal->j_len_alloc) {
+    journal->j_len_alloc = journal->j_len + JOURNAL_PER_BALANCE_CNT ;
   }
 
-  set_bit(BH_JDirty, &bh->b_state) ;
+  set_buffer_journaled (bh);
 
   /* now put this guy on the end */
   if (!cn) {
@@ -2830,29 +2932,29 @@
 
     if (th->t_blocks_logged == th->t_blocks_allocated) {
       th->t_blocks_allocated += JOURNAL_PER_BALANCE_CNT ;
-      SB_JOURNAL(p_s_sb)->j_len_alloc += JOURNAL_PER_BALANCE_CNT ;
+      journal->j_len_alloc += JOURNAL_PER_BALANCE_CNT ;
     }
     th->t_blocks_logged++ ;
-    SB_JOURNAL(p_s_sb)->j_len++ ;
+    journal->j_len++ ;
 
     cn->bh = bh ;
     cn->blocknr = bh->b_blocknr ;
     cn->sb = p_s_sb;
     cn->jlist = NULL ;
-    insert_journal_hash(SB_JOURNAL(p_s_sb)->j_hash_table, cn) ;
+    insert_journal_hash(journal->j_hash_table, cn) ;
     if (!count_already_incd) {
       get_bh(bh) ;
     }
   }
   cn->next = NULL ;
-  cn->prev = SB_JOURNAL(p_s_sb)->j_last ;
+  cn->prev = journal->j_last ;
   cn->bh = bh ;
-  if (SB_JOURNAL(p_s_sb)->j_last) {
-    SB_JOURNAL(p_s_sb)->j_last->next = cn ;
-    SB_JOURNAL(p_s_sb)->j_last = cn ;
+  if (journal->j_last) {
+    journal->j_last->next = cn ;
+    journal->j_last = cn ;
   } else {
-    SB_JOURNAL(p_s_sb)->j_first = cn ;
-    SB_JOURNAL(p_s_sb)->j_last = cn ;
+    journal->j_first = cn ;
+    journal->j_last = cn ;
   }
   return 0 ;
 }
@@ -2862,6 +2964,11 @@
     reiserfs_warning (p_s_sb, "REISER-NESTING: th NULL, refcount %d",
                       th->t_refcount);
 
+  if (!th->t_trans_id) {
+    WARN_ON (1);
+    return -EIO;
+  }
+
   th->t_refcount--;
   if (th->t_refcount > 0) {
     struct reiserfs_transaction_handle *cur_th = current->journal_info ;
@@ -2892,9 +2999,10 @@
 static int remove_from_transaction(struct super_block *p_s_sb, b_blocknr_t blocknr, int already_cleaned) {
   struct buffer_head *bh ;
   struct reiserfs_journal_cnode *cn ;
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   int ret = 0;
 
-  cn = get_journal_hash_dev(p_s_sb, SB_JOURNAL(p_s_sb)->j_hash_table, blocknr) ;
+  cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, blocknr) ;
   if (!cn || !cn->bh) {
     return ret ;
   }
@@ -2905,26 +3013,26 @@
   if (cn->next) {
     cn->next->prev = cn->prev ;
   }
-  if (cn == SB_JOURNAL(p_s_sb)->j_first) {
-    SB_JOURNAL(p_s_sb)->j_first = cn->next ;  
+  if (cn == journal->j_first) {
+    journal->j_first = cn->next ;
   }
-  if (cn == SB_JOURNAL(p_s_sb)->j_last) {
-    SB_JOURNAL(p_s_sb)->j_last = cn->prev ;
+  if (cn == journal->j_last) {
+    journal->j_last = cn->prev ;
   }
   if (bh)
-	remove_journal_hash(p_s_sb, SB_JOURNAL(p_s_sb)->j_hash_table, NULL, bh->b_blocknr, 0) ; 
-  mark_buffer_not_journaled(bh) ; /* don't log this one */
+	remove_journal_hash(p_s_sb, journal->j_hash_table, NULL, bh->b_blocknr, 0) ;
+  clear_buffer_journaled  (bh); /* don't log this one */
 
   if (!already_cleaned) {
-    mark_buffer_notjournal_dirty(bh) ; 
+    clear_buffer_journal_dirty (bh);
     put_bh(bh) ;
     if (atomic_read(&(bh->b_count)) < 0) {
       reiserfs_warning (p_s_sb, "journal-1752: remove from trans, b_count < 0");
     }
     ret = 1 ;
   }
-  SB_JOURNAL(p_s_sb)->j_len-- ;
-  SB_JOURNAL(p_s_sb)->j_len_alloc-- ;
+  journal->j_len-- ;
+  journal->j_len_alloc-- ;
   free_cnode(p_s_sb, cn) ;
   return ret ;
 }
@@ -2975,12 +3083,14 @@
 ** will wait until the current transaction is done/commited before returning 
 */
 int journal_end_sync(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
 
+  BUG_ON (!th->t_trans_id);
   /* you can sync while nested, very, very bad */
   if (th->t_refcount > 1) {
     BUG() ;
   }
-  if (SB_JOURNAL(p_s_sb)->j_len == 0) {
+  if (journal->j_len == 0) {
     reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
     journal_mark_dirty(th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
   }
@@ -2992,13 +3102,14 @@
 */
 static void flush_async_commits(void *p) {
   struct super_block *p_s_sb = p;
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_list *jl;
   struct list_head *entry;
 
   lock_kernel();
-  if (!list_empty(&SB_JOURNAL(p_s_sb)->j_journal_list)) {
+  if (!list_empty(&journal->j_journal_list)) {
       /* last entry is the youngest, commit it and you get everything */
-      entry = SB_JOURNAL(p_s_sb)->j_journal_list.prev;
+      entry = journal->j_journal_list.prev;
       jl = JOURNAL_LIST_ENTRY(entry);
       flush_commit_list(p_s_sb, jl, 1);
   }
@@ -3007,10 +3118,10 @@
    * this is a little racey, but there's no harm in missing
    * the filemap_fdata_write
    */
-  if (!atomic_read(&SB_JOURNAL(p_s_sb)->j_async_throttle)) {
-      atomic_inc(&SB_JOURNAL(p_s_sb)->j_async_throttle);
+  if (!atomic_read(&journal->j_async_throttle) && !reiserfs_is_journal_aborted (journal)) {
+      atomic_inc(&journal->j_async_throttle);
       filemap_fdatawrite(p_s_sb->s_bdev->bd_inode->i_mapping);
-      atomic_dec(&SB_JOURNAL(p_s_sb)->j_async_throttle);
+      atomic_dec(&journal->j_async_throttle);
   }
 }
 
@@ -3021,32 +3132,33 @@
 int reiserfs_flush_old_commits(struct super_block *p_s_sb) {
     time_t now ;
     struct reiserfs_transaction_handle th ;
+    struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
 
     now = get_seconds();
     /* safety check so we don't flush while we are replaying the log during
      * mount
      */
-    if (list_empty(&SB_JOURNAL(p_s_sb)->j_journal_list)) {
+    if (list_empty(&journal->j_journal_list)) {
 	return 0  ;
     }
 
     /* check the current transaction.  If there are no writers, and it is
      * too old, finish it, and force the commit blocks to disk
      */
-    if (atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount)) <= 0 &&
-        SB_JOURNAL(p_s_sb)->j_trans_start_time > 0 &&
-        SB_JOURNAL(p_s_sb)->j_len > 0 &&
-        (now - SB_JOURNAL(p_s_sb)->j_trans_start_time) >
-	SB_JOURNAL_MAX_TRANS_AGE(p_s_sb))
+    if (atomic_read(&journal->j_wcount) <= 0 &&
+        journal->j_trans_start_time > 0 &&
+        journal->j_len > 0 &&
+        (now - journal->j_trans_start_time) > journal->j_max_trans_age)
     {
-	journal_join(&th, p_s_sb, 1) ;
-	reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
-	journal_mark_dirty(&th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
-
-	/* we're only being called from kreiserfsd, it makes no sense to do
-	** an async commit so that kreiserfsd can do it later
-	*/
-	do_journal_end(&th, p_s_sb,1, COMMIT_NOW | WAIT) ;
+	if (!journal_join(&th, p_s_sb, 1)) {
+            reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
+            journal_mark_dirty(&th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
+
+            /* we're only being called from kreiserfsd, it makes no sense to do
+            ** an async commit so that kreiserfsd can do it later
+            */
+            do_journal_end(&th, p_s_sb,1, COMMIT_NOW | WAIT) ;
+        }
     }
     return p_s_sb->s_dirt;
 }
@@ -3070,22 +3182,25 @@
   int commit_now = flags & COMMIT_NOW ;
   int wait_on_commit = flags & WAIT ;
   struct reiserfs_journal_list *jl;
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
+
+  BUG_ON (!th->t_trans_id);
 
-  if (th->t_trans_id != SB_JOURNAL(p_s_sb)->j_trans_id) {
+  if (th->t_trans_id != journal->j_trans_id) {
     reiserfs_panic(th->t_super, "journal-1577: handle trans id %ld != current trans id %ld\n", 
-                   th->t_trans_id, SB_JOURNAL(p_s_sb)->j_trans_id);
+                   th->t_trans_id, journal->j_trans_id);
   }
 
-  SB_JOURNAL(p_s_sb)->j_len_alloc -= (th->t_blocks_allocated - th->t_blocks_logged) ;
-  if (atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount)) > 0) { /* <= 0 is allowed.  unmounting might not call begin */
-    atomic_dec(&(SB_JOURNAL(p_s_sb)->j_wcount)) ;
+  journal->j_len_alloc -= (th->t_blocks_allocated - th->t_blocks_logged) ;
+  if (atomic_read(&(journal->j_wcount)) > 0) { /* <= 0 is allowed.  unmounting might not call begin */
+    atomic_dec(&(journal->j_wcount)) ;
   }
 
   /* BUG, deal with case where j_len is 0, but people previously freed blocks need to be released 
   ** will be dealt with by next transaction that actually writes something, but should be taken
   ** care of in this trans
   */
-  if (SB_JOURNAL(p_s_sb)->j_len == 0) {
+  if (journal->j_len == 0) {
     BUG();
   }
   /* if wcount > 0, and we are called to with flush or commit_now,
@@ -3094,33 +3209,33 @@
   ** Then, we flush the commit or journal list, and just return 0 
   ** because the rest of journal end was already done for this transaction.
   */
-  if (atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount)) > 0) {
+  if (atomic_read(&(journal->j_wcount)) > 0) {
     if (flush || commit_now) {
       unsigned trans_id ;
 
-      jl = SB_JOURNAL(p_s_sb)->j_current_jl;
+      jl = journal->j_current_jl;
       trans_id = jl->j_trans_id;
       if (wait_on_commit)
         jl->j_state |= LIST_COMMIT_PENDING;
-      atomic_set(&(SB_JOURNAL(p_s_sb)->j_jlock), 1) ;
+      atomic_set(&(journal->j_jlock), 1) ;
       if (flush) {
-        SB_JOURNAL(p_s_sb)->j_next_full_flush = 1 ;
+        journal->j_next_full_flush = 1 ;
       }
       unlock_journal(p_s_sb) ;
 
       /* sleep while the current transaction is still j_jlocked */
-      while(SB_JOURNAL(p_s_sb)->j_trans_id == trans_id) {
-	if (atomic_read(&SB_JOURNAL(p_s_sb)->j_jlock)) {
+      while(journal->j_trans_id == trans_id) {
+	if (atomic_read(&journal->j_jlock)) {
 	    queue_log_writer(p_s_sb);
         } else {
 	    lock_journal(p_s_sb);
-	    if (SB_JOURNAL(p_s_sb)->j_trans_id == trans_id) {
-	        atomic_set(&(SB_JOURNAL(p_s_sb)->j_jlock), 1) ;
+	    if (journal->j_trans_id == trans_id) {
+	        atomic_set(&(journal->j_jlock), 1) ;
 	    }
 	    unlock_journal(p_s_sb);
 	}
       }
-      if (SB_JOURNAL(p_s_sb)->j_trans_id == trans_id) {
+      if (journal->j_trans_id == trans_id) {
           BUG();
       }
       if (commit_now && journal_list_still_alive(p_s_sb, trans_id) &&
@@ -3136,22 +3251,22 @@
 
   /* deal with old transactions where we are the last writers */
   now = get_seconds();
-  if ((now - SB_JOURNAL(p_s_sb)->j_trans_start_time) > SB_JOURNAL_MAX_TRANS_AGE(p_s_sb)) {
+  if ((now - journal->j_trans_start_time) > journal->j_max_trans_age) {
     commit_now = 1 ;
-    SB_JOURNAL(p_s_sb)->j_next_async_flush = 1 ;
+    journal->j_next_async_flush = 1 ;
   }
   /* don't batch when someone is waiting on j_join_wait */
   /* don't batch when syncing the commit or flushing the whole trans */
-  if (!(SB_JOURNAL(p_s_sb)->j_must_wait > 0) && !(atomic_read(&(SB_JOURNAL(p_s_sb)->j_jlock))) && !flush && !commit_now && 
-      (SB_JOURNAL(p_s_sb)->j_len < SB_JOURNAL_MAX_BATCH(p_s_sb))  && 
-      SB_JOURNAL(p_s_sb)->j_len_alloc < SB_JOURNAL_MAX_BATCH(p_s_sb) && SB_JOURNAL(p_s_sb)->j_cnode_free > (SB_JOURNAL_TRANS_MAX(p_s_sb) * 3)) {
-    SB_JOURNAL(p_s_sb)->j_bcount++ ;
+  if (!(journal->j_must_wait > 0) && !(atomic_read(&(journal->j_jlock))) && !flush && !commit_now &&
+      (journal->j_len < journal->j_max_batch)  &&
+      journal->j_len_alloc < journal->j_max_batch && journal->j_cnode_free > (journal->j_trans_max * 3)) {
+    journal->j_bcount++ ;
     unlock_journal(p_s_sb) ;
     return 0 ;
   }
 
-  if (SB_JOURNAL(p_s_sb)->j_start > SB_ONDISK_JOURNAL_SIZE(p_s_sb)) {
-    reiserfs_panic(p_s_sb, "journal-003: journal_end: j_start (%ld) is too high\n", SB_JOURNAL(p_s_sb)->j_start) ;
+  if (journal->j_start > SB_ONDISK_JOURNAL_SIZE(p_s_sb)) {
+    reiserfs_panic(p_s_sb, "journal-003: journal_end: j_start (%ld) is too high\n", journal->j_start) ;
   }
   return 1 ;
 }
@@ -3171,25 +3286,27 @@
 ** Then remove it from the current transaction, decrementing any counters and filing it on the clean list.
 */
 int journal_mark_freed(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, b_blocknr_t blocknr) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_cnode *cn = NULL ;
   struct buffer_head *bh = NULL ;
   struct reiserfs_list_bitmap *jb = NULL ;
   int cleaned = 0 ;
+  BUG_ON (!th->t_trans_id);
 
-  cn = get_journal_hash_dev(p_s_sb, SB_JOURNAL(p_s_sb)->j_hash_table, blocknr);
+  cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, blocknr);
   if (cn && cn->bh) {
       bh = cn->bh ;
       get_bh(bh) ;
   }
   /* if it is journal new, we just remove it from this transaction */
   if (bh && buffer_journal_new(bh)) {
-    mark_buffer_notjournal_new(bh) ;
+    clear_buffer_journal_new (bh);
     clear_prepared_bits(bh) ;
     reiserfs_clean_and_file_buffer(bh) ;
     cleaned = remove_from_transaction(p_s_sb, blocknr, cleaned) ;
   } else {
     /* set the bit for this block in the journal bitmap for this transaction */
-    jb = SB_JOURNAL(p_s_sb)->j_current_jl->j_list_bitmap;
+    jb = journal->j_current_jl->j_list_bitmap;
     if (!jb) {
       reiserfs_panic(p_s_sb, "journal-1702: journal_mark_freed, journal_list_bitmap is NULL\n") ;
     }
@@ -3204,7 +3321,7 @@
     cleaned = remove_from_transaction(p_s_sb, blocknr, cleaned) ;
 
     /* find all older transactions with this block, make sure they don't try to write it out */
-    cn = get_journal_hash_dev(p_s_sb,SB_JOURNAL(p_s_sb)->j_list_hash_table,  blocknr) ;
+    cn = get_journal_hash_dev(p_s_sb,journal->j_list_hash_table,  blocknr) ;
     while (cn) {
       if (p_s_sb == cn->sb && blocknr == cn->blocknr) {
 	set_bit(BLOCK_FREED, &cn->state) ;
@@ -3213,7 +3330,7 @@
 	    /* remove_from_transaction will brelse the buffer if it was 
 	    ** in the current trans
 	    */
-	    mark_buffer_notjournal_dirty(cn->bh) ;
+            clear_buffer_journal_dirty (cn->bh);
 	    cleaned = 1 ;
 	    put_bh(cn->bh) ;
 	    if (atomic_read(&(cn->bh->b_count)) < 0) {
@@ -3240,8 +3357,9 @@
 }
 
 void reiserfs_update_inode_transaction(struct inode *inode) {
-  REISERFS_I(inode)->i_jl = SB_JOURNAL(inode->i_sb)->j_current_jl;
-  REISERFS_I(inode)->i_trans_id = SB_JOURNAL(inode->i_sb)->j_trans_id ;
+  struct reiserfs_journal *journal = SB_JOURNAL (inode->i_sb);
+  REISERFS_I(inode)->i_jl = journal->j_current_jl;
+  REISERFS_I(inode)->i_trans_id = journal->j_trans_id ;
 }
 
 /*
@@ -3253,29 +3371,33 @@
 {
     struct reiserfs_transaction_handle th ;
     struct super_block *sb = inode->i_sb ;
+    struct reiserfs_journal *journal = SB_JOURNAL (sb);
     int ret = 0;
 
     /* is it from the current transaction, or from an unknown transaction? */
-    if (id == SB_JOURNAL(sb)->j_trans_id) {
-	jl = SB_JOURNAL(sb)->j_current_jl;
+    if (id == journal->j_trans_id) {
+	jl = journal->j_current_jl;
 	/* try to let other writers come in and grow this transaction */
 	let_transaction_grow(sb, id);
-	if (SB_JOURNAL(sb)->j_trans_id != id) {
+	if (journal->j_trans_id != id) {
 	    goto flush_commit_only;
 	}
 
-	journal_begin(&th, sb, 1) ;
+	ret = journal_begin(&th, sb, 1) ;
+	if (ret)
+	    return ret;
 
 	/* someone might have ended this transaction while we joined */
-	if (SB_JOURNAL(sb)->j_trans_id != id) {
+	if (journal->j_trans_id != id) {
 	    reiserfs_prepare_for_journal(sb, SB_BUFFER_WITH_SB(sb), 1) ;
 	    journal_mark_dirty(&th, sb, SB_BUFFER_WITH_SB(sb)) ;
-	    journal_end(&th, sb, 1) ;
+	    ret = journal_end(&th, sb, 1) ;
 	    goto flush_commit_only;
 	}
 
-	journal_end_sync(&th, sb, 1) ;
-	ret = 1;
+	ret = journal_end_sync(&th, sb, 1) ;
+	if (!ret)
+	    ret = 1;
 
     } else {
 	/* this gets tricky, we have to make sure the journal list in
@@ -3292,6 +3414,8 @@
 	    if (atomic_read(&jl->j_commit_left) > 1)
 	        ret = 1;
 	    flush_commit_list(sb, jl, 1) ;
+	    if (journal->j_errno)
+		ret = journal->j_errno;
 	}
     }
     /* otherwise the list is gone, and long since committed */
@@ -3316,22 +3440,23 @@
 
 void reiserfs_restore_prepared_buffer(struct super_block *p_s_sb, 
                                       struct buffer_head *bh) {
+    struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
     PROC_INFO_INC( p_s_sb, journal.restore_prepared );
     if (!bh) {
 	return ;
     }
-    if (test_and_clear_bit(BH_JRestore_dirty, &bh->b_state) &&
+    if (test_clear_buffer_journal_restore_dirty (bh) &&
 	buffer_journal_dirty(bh)) {
 	struct reiserfs_journal_cnode *cn;
 	cn = get_journal_hash_dev(p_s_sb,
-	                          SB_JOURNAL(p_s_sb)->j_list_hash_table,
+	                          journal->j_list_hash_table,
 				  bh->b_blocknr);
 	if (cn && can_dirty(cn)) {
-	    set_bit(BH_JTest, &bh->b_state);
+            set_buffer_journal_test (bh);
 	    mark_buffer_dirty(bh);
         }
     }
-    clear_bit(BH_JPrepared, &bh->b_state) ;
+    clear_buffer_journal_prepared (bh);
 }
 
 extern struct tree_balance *cur_tb ;
@@ -3351,22 +3476,23 @@
 	    return 0;
 	lock_buffer(bh);
     }
-    set_bit(BH_JPrepared, &bh->b_state);
+    set_buffer_journal_prepared (bh);
     if (test_clear_buffer_dirty(bh) && buffer_journal_dirty(bh))  {
-	clear_bit(BH_JTest, &bh->b_state);
-	set_bit(BH_JRestore_dirty, &bh->b_state);
+        clear_buffer_journal_test (bh);
+        set_buffer_journal_restore_dirty (bh);
     }
     unlock_buffer(bh);
     return 1;
 }
 
 static void flush_old_journal_lists(struct super_block *s) {
+    struct reiserfs_journal *journal = SB_JOURNAL (s);
     struct reiserfs_journal_list *jl;
     struct list_head *entry;
     time_t now = get_seconds();
 
-    while(!list_empty(&SB_JOURNAL(s)->j_journal_list)) {
-        entry = SB_JOURNAL(s)->j_journal_list.next;
+    while(!list_empty(&journal->j_journal_list)) {
+        entry = journal->j_journal_list.next;
 	jl = JOURNAL_LIST_ENTRY(entry);
 	/* this check should always be run, to send old lists to disk */
 	if (jl->j_timestamp < (now - (JOURNAL_MAX_TRANS_AGE * 4))) {
@@ -3383,9 +3509,13 @@
 ** If no_async, won't return until all commit blocks are on disk.
 **
 ** keep reading, there are comments as you go along
+**
+** If the journal is aborted, we just clean up. Things like flushing
+** journal lists, etc just won't happen.
 */
 static int do_journal_end(struct reiserfs_transaction_handle *th, struct super_block  * p_s_sb, unsigned long nblocks, 
 		          int flags) {
+  struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
   struct reiserfs_journal_cnode *cn, *next, *jl_cn; 
   struct reiserfs_journal_cnode *last_cn = NULL;
   struct reiserfs_journal_desc *desc ; 
@@ -3403,22 +3533,22 @@
   unsigned long commit_trans_id;
   int trans_half;
 
-  if (th->t_refcount > 1)
-    BUG() ;
+  BUG_ON (th->t_refcount > 1);
+  BUG_ON (!th->t_trans_id);
 
   current->journal_info = th->t_handle_save;
   reiserfs_check_lock_depth(p_s_sb, "journal end");
-  if (SB_JOURNAL(p_s_sb)->j_len == 0) {
+  if (journal->j_len == 0) {
       reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
       journal_mark_dirty(th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
   }
 
   lock_journal(p_s_sb) ;
-  if (SB_JOURNAL(p_s_sb)->j_next_full_flush) {
+  if (journal->j_next_full_flush) {
     flags |= FLUSH_ALL ;
     flush = 1 ;
   }
-  if (SB_JOURNAL(p_s_sb)->j_next_async_flush) {
+  if (journal->j_next_async_flush) {
     flags |= COMMIT_NOW | WAIT;
     wait_on_commit = 1;
   }
@@ -3434,7 +3564,7 @@
   }
 
   /* check_journal_end might set these, check again */
-  if (SB_JOURNAL(p_s_sb)->j_next_full_flush) {
+  if (journal->j_next_full_flush) {
     flush = 1 ;
   }
 
@@ -3442,7 +3572,7 @@
   ** j must wait means we have to flush the log blocks, and the real blocks for
   ** this transaction
   */
-  if (SB_JOURNAL(p_s_sb)->j_must_wait > 0) {
+  if (journal->j_must_wait > 0) {
     flush = 1 ;
   }
 
@@ -3455,23 +3585,23 @@
 #endif
   
   /* setup description block */
-  d_bh = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_JOURNAL(p_s_sb)->j_start) ; 
+  d_bh = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + journal->j_start) ;
   set_buffer_uptodate(d_bh);
   desc = (struct reiserfs_journal_desc *)(d_bh)->b_data ;
   memset(d_bh->b_data, 0, d_bh->b_size) ;
   memcpy(get_journal_desc_magic (d_bh), JOURNAL_DESC_MAGIC, 8) ;
-  set_desc_trans_id(desc, SB_JOURNAL(p_s_sb)->j_trans_id) ;
+  set_desc_trans_id(desc, journal->j_trans_id) ;
 
   /* setup commit block.  Don't write (keep it clean too) this one until after everyone else is written */
   c_bh =  journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 
-		 ((SB_JOURNAL(p_s_sb)->j_start + SB_JOURNAL(p_s_sb)->j_len + 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
+		 ((journal->j_start + journal->j_len + 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
   commit = (struct reiserfs_journal_commit *)c_bh->b_data ;
   memset(c_bh->b_data, 0, c_bh->b_size) ;
-  set_commit_trans_id(commit, SB_JOURNAL(p_s_sb)->j_trans_id) ;
+  set_commit_trans_id(commit, journal->j_trans_id) ;
   set_buffer_uptodate(c_bh) ;
 
   /* init this journal list */
-  jl = SB_JOURNAL(p_s_sb)->j_current_jl;
+  jl = journal->j_current_jl;
 
   /* we lock the commit before doing anything because
    * we want to make sure nobody tries to run flush_commit_list until
@@ -3484,13 +3614,13 @@
   commit_trans_id = jl->j_trans_id;
 
   atomic_set(&jl->j_older_commits_done, 0) ;
-  jl->j_trans_id = SB_JOURNAL(p_s_sb)->j_trans_id ;
-  jl->j_timestamp = SB_JOURNAL(p_s_sb)->j_trans_start_time ;
+  jl->j_trans_id = journal->j_trans_id ;
+  jl->j_timestamp = journal->j_trans_start_time ;
   jl->j_commit_bh = c_bh ;
-  jl->j_start = SB_JOURNAL(p_s_sb)->j_start ;
-  jl->j_len = SB_JOURNAL(p_s_sb)->j_len ;
-  atomic_set(&jl->j_nonzerolen, SB_JOURNAL(p_s_sb)->j_len) ;
-  atomic_set(&jl->j_commit_left, SB_JOURNAL(p_s_sb)->j_len + 2);
+  jl->j_start = journal->j_start ;
+  jl->j_len = journal->j_len ;
+  atomic_set(&jl->j_nonzerolen, journal->j_len) ;
+  atomic_set(&jl->j_commit_left, journal->j_len + 2);
   jl->j_realblock = NULL ;
 
   /* The ENTIRE FOR LOOP MUST not cause schedule to occur.
@@ -3498,8 +3628,8 @@
   ** copy into real block index array in the commit or desc block
   */
   trans_half = journal_trans_half(p_s_sb->s_blocksize);
-  for (i = 0, cn = SB_JOURNAL(p_s_sb)->j_first ; cn ; cn = cn->next, i++) {
-    if (test_bit(BH_JDirty, &cn->bh->b_state) ) {
+  for (i = 0, cn = journal->j_first ; cn ; cn = cn->next, i++) {
+    if (buffer_journaled (cn->bh)) {
       jl_cn = get_cnode(p_s_sb) ;
       if (!jl_cn) {
         reiserfs_panic(p_s_sb, "journal-1676, get_cnode returned NULL\n") ;
@@ -3524,7 +3654,7 @@
       jl_cn->sb = p_s_sb;
       jl_cn->bh = cn->bh ;
       jl_cn->jlist = jl;
-      insert_journal_hash(SB_JOURNAL(p_s_sb)->j_list_hash_table, jl_cn) ; 
+      insert_journal_hash(journal->j_list_hash_table, jl_cn) ;
       if (i < trans_half) {
 	desc->j_realblock[i] = cpu_to_le32(cn->bh->b_blocknr) ;
       } else {
@@ -3534,13 +3664,13 @@
       i-- ;
     }
   }
-  set_desc_trans_len(desc, SB_JOURNAL(p_s_sb)->j_len) ;
-  set_desc_mount_id(desc, SB_JOURNAL(p_s_sb)->j_mount_id) ;
-  set_desc_trans_id(desc, SB_JOURNAL(p_s_sb)->j_trans_id) ;
-  set_commit_trans_len(commit, SB_JOURNAL(p_s_sb)->j_len);
+  set_desc_trans_len(desc, journal->j_len) ;
+  set_desc_mount_id(desc, journal->j_mount_id) ;
+  set_desc_trans_id(desc, journal->j_trans_id) ;
+  set_commit_trans_len(commit, journal->j_len);
 
   /* special check in case all buffers in the journal were marked for not logging */
-  if (SB_JOURNAL(p_s_sb)->j_len == 0) {
+  if (journal->j_len == 0) {
     BUG();
   }
 
@@ -3551,13 +3681,13 @@
   mark_buffer_dirty(d_bh);
 
   /* first data block is j_start + 1, so add one to cur_write_start wherever you use it */
-  cur_write_start = SB_JOURNAL(p_s_sb)->j_start ;
-  cn = SB_JOURNAL(p_s_sb)->j_first ;
+  cur_write_start = journal->j_start ;
+  cn = journal->j_first ;
   jindex = 1 ; /* start at one so we don't get the desc again */
   while(cn) {
-    clear_bit(BH_JNew, &(cn->bh->b_state)) ;
+    clear_buffer_journal_new (cn->bh);
     /* copy all the real blocks into log area.  dirty log blocks */
-    if (test_bit(BH_JDirty, &cn->bh->b_state)) {
+    if (buffer_journaled (cn->bh)) {
       struct buffer_head *tmp_bh ;
       char *addr;
       struct page *page;
@@ -3571,8 +3701,8 @@
       kunmap(page);
       mark_buffer_dirty(tmp_bh);
       jindex++ ;
-      set_bit(BH_JDirty_wait, &(cn->bh->b_state)) ; 
-      clear_bit(BH_JDirty, &(cn->bh->b_state)) ;
+      set_buffer_journal_dirty (cn->bh);
+      clear_buffer_journaled (cn->bh);
     } else {
       /* JDirty cleared sometime during transaction.  don't log this one */
       reiserfs_warning(p_s_sb, "journal-2048: do_journal_end: BAD, buffer in journal hash, but not JDirty!") ;
@@ -3589,28 +3719,28 @@
   ** so we dirty/relse c_bh in flush_commit_list, with commit_left <= 1.
   */
 
-  SB_JOURNAL(p_s_sb)->j_current_jl = alloc_journal_list(p_s_sb);
+  journal->j_current_jl = alloc_journal_list(p_s_sb);
 
   /* now it is safe to insert this transaction on the main list */
-  list_add_tail(&jl->j_list, &SB_JOURNAL(p_s_sb)->j_journal_list);
-  list_add_tail(&jl->j_working_list, &SB_JOURNAL(p_s_sb)->j_working_list);
-  SB_JOURNAL(p_s_sb)->j_num_work_lists++;
+  list_add_tail(&jl->j_list, &journal->j_journal_list);
+  list_add_tail(&jl->j_working_list, &journal->j_working_list);
+  journal->j_num_work_lists++;
 
   /* reset journal values for the next transaction */
-  old_start = SB_JOURNAL(p_s_sb)->j_start ;
-  SB_JOURNAL(p_s_sb)->j_start = (SB_JOURNAL(p_s_sb)->j_start + SB_JOURNAL(p_s_sb)->j_len + 2) % SB_ONDISK_JOURNAL_SIZE(p_s_sb);
-  atomic_set(&(SB_JOURNAL(p_s_sb)->j_wcount), 0) ;
-  SB_JOURNAL(p_s_sb)->j_bcount = 0 ;
-  SB_JOURNAL(p_s_sb)->j_last = NULL ;
-  SB_JOURNAL(p_s_sb)->j_first = NULL ;
-  SB_JOURNAL(p_s_sb)->j_len = 0 ;
-  SB_JOURNAL(p_s_sb)->j_trans_start_time = 0 ;
-  SB_JOURNAL(p_s_sb)->j_trans_id++ ;
-  SB_JOURNAL(p_s_sb)->j_current_jl->j_trans_id = SB_JOURNAL(p_s_sb)->j_trans_id;
-  SB_JOURNAL(p_s_sb)->j_must_wait = 0 ;
-  SB_JOURNAL(p_s_sb)->j_len_alloc = 0 ;
-  SB_JOURNAL(p_s_sb)->j_next_full_flush = 0 ;
-  SB_JOURNAL(p_s_sb)->j_next_async_flush = 0 ;
+  old_start = journal->j_start ;
+  journal->j_start = (journal->j_start + journal->j_len + 2) % SB_ONDISK_JOURNAL_SIZE(p_s_sb);
+  atomic_set(&(journal->j_wcount), 0) ;
+  journal->j_bcount = 0 ;
+  journal->j_last = NULL ;
+  journal->j_first = NULL ;
+  journal->j_len = 0 ;
+  journal->j_trans_start_time = 0 ;
+  journal->j_trans_id++ ;
+  journal->j_current_jl->j_trans_id = journal->j_trans_id;
+  journal->j_must_wait = 0 ;
+  journal->j_len_alloc = 0 ;
+  journal->j_next_full_flush = 0 ;
+  journal->j_next_async_flush = 0 ;
   init_journal_hash(p_s_sb) ; 
 
   // make sure reiserfs_add_jh sees the new current_jl before we
@@ -3625,8 +3755,8 @@
    */
   if (!list_empty(&jl->j_tail_bh_list)) {
       unlock_kernel();
-      write_ordered_buffers(&SB_JOURNAL(p_s_sb)->j_dirty_buffers_lock,
-			    SB_JOURNAL(p_s_sb), jl, &jl->j_tail_bh_list);
+      write_ordered_buffers(&journal->j_dirty_buffers_lock,
+			    journal, jl, &jl->j_tail_bh_list);
       lock_kernel();
   }
   if (!list_empty(&jl->j_tail_bh_list))
@@ -3644,7 +3774,7 @@
     flush_commit_list(p_s_sb, jl, 1) ;
     flush_journal_list(p_s_sb, jl, 1) ;
   } else if (!(jl->j_state & LIST_COMMIT_PENDING))
-    queue_delayed_work(commit_wq, &SB_JOURNAL(p_s_sb)->j_work, HZ/10);
+    queue_delayed_work(commit_wq, &journal->j_work, HZ/10);
 
 
   /* if the next transaction has any chance of wrapping, flush 
@@ -3652,16 +3782,16 @@
   ** old flush them as well.  
   */
 first_jl:
-  list_for_each_safe(entry, safe, &SB_JOURNAL(p_s_sb)->j_journal_list) {
+  list_for_each_safe(entry, safe, &journal->j_journal_list) {
     temp_jl = JOURNAL_LIST_ENTRY(entry);
-    if (SB_JOURNAL(p_s_sb)->j_start <= temp_jl->j_start) {
-      if ((SB_JOURNAL(p_s_sb)->j_start + SB_JOURNAL_TRANS_MAX(p_s_sb) + 1) >=
+    if (journal->j_start <= temp_jl->j_start) {
+      if ((journal->j_start + journal->j_trans_max + 1) >=
           temp_jl->j_start)
       {
 	flush_used_journal_lists(p_s_sb, temp_jl);
 	goto first_jl;
-      } else if ((SB_JOURNAL(p_s_sb)->j_start +
-                  SB_JOURNAL_TRANS_MAX(p_s_sb) + 1) <
+      } else if ((journal->j_start +
+                  journal->j_trans_max + 1) <
 		  SB_ONDISK_JOURNAL_SIZE(p_s_sb))
       {
           /* if we don't cross into the next transaction and we don't
@@ -3670,11 +3800,11 @@
 	   */
 	  break;
       }
-    } else if ((SB_JOURNAL(p_s_sb)->j_start +
-                SB_JOURNAL_TRANS_MAX(p_s_sb) + 1) >
+    } else if ((journal->j_start +
+                journal->j_trans_max + 1) >
 		SB_ONDISK_JOURNAL_SIZE(p_s_sb))
     {
-      if (((SB_JOURNAL(p_s_sb)->j_start + SB_JOURNAL_TRANS_MAX(p_s_sb) + 1) %
+      if (((journal->j_start + journal->j_trans_max + 1) %
             SB_ONDISK_JOURNAL_SIZE(p_s_sb)) >= temp_jl->j_start)
       {
 	flush_used_journal_lists(p_s_sb, temp_jl);
@@ -3690,17 +3820,17 @@
   }
   flush_old_journal_lists(p_s_sb);
 
-  SB_JOURNAL(p_s_sb)->j_current_jl->j_list_bitmap = get_list_bitmap(p_s_sb, SB_JOURNAL(p_s_sb)->j_current_jl) ;
+  journal->j_current_jl->j_list_bitmap = get_list_bitmap(p_s_sb, journal->j_current_jl) ;
 
-  if (!(SB_JOURNAL(p_s_sb)->j_current_jl->j_list_bitmap)) {
+  if (!(journal->j_current_jl->j_list_bitmap)) {
     reiserfs_panic(p_s_sb, "journal-1996: do_journal_end, could not get a list bitmap\n") ;
   }
 
-  atomic_set(&(SB_JOURNAL(p_s_sb)->j_jlock), 0) ;
+  atomic_set(&(journal->j_jlock), 0) ;
   unlock_journal(p_s_sb) ;
   /* wake up any body waiting to join. */
-  clear_bit(WRITERS_QUEUED, &SB_JOURNAL(p_s_sb)->j_state);
-  wake_up(&(SB_JOURNAL(p_s_sb)->j_join_wait)) ;
+  clear_bit(J_WRITERS_QUEUED, &journal->j_state);
+  wake_up(&(journal->j_join_wait)) ;
 
   if (!flush && wait_on_commit &&
       journal_list_still_alive(p_s_sb, commit_trans_id)) {
@@ -3708,6 +3838,49 @@
   }
 out:
   reiserfs_check_lock_depth(p_s_sb, "journal end2");
-  th->t_trans_id = 0;
-  return 0 ;
+
+  memset (th, 0, sizeof (*th));
+  /* Re-set th->t_super, so we can properly keep track of how many
+   * persistent transactions there are. We need to do this so if this
+   * call is part of a failed restart_transaction, we can free it later */
+  th->t_super = p_s_sb;
+
+  return journal->j_errno;
+}
+
+void
+__reiserfs_journal_abort_hard (struct super_block *sb)
+{
+    struct reiserfs_journal *journal = SB_JOURNAL (sb);
+    if (test_bit (J_ABORTED, &journal->j_state))
+        return;
+
+    printk (KERN_CRIT "REISERFS: Aborting journal for filesystem on %s\n",
+                      reiserfs_bdevname (sb));
+
+    sb->s_flags |= MS_RDONLY;
+    set_bit (J_ABORTED, &journal->j_state);
+
+#ifdef CONFIG_REISERFS_CHECK
+    dump_stack();
+#endif
+}
+
+void
+__reiserfs_journal_abort_soft (struct super_block *sb, int errno)
+{
+    struct reiserfs_journal *journal = SB_JOURNAL (sb);
+    if (test_bit (J_ABORTED, &journal->j_state))
+        return;
+
+    if (!journal->j_errno)
+        journal->j_errno = errno;
+
+    __reiserfs_journal_abort_hard (sb);
+}
+
+void
+reiserfs_journal_abort (struct super_block *sb, int errno)
+{
+    return __reiserfs_journal_abort_soft (sb, errno);
 }
diff -Nru a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
--- a/fs/reiserfs/namei.c	2004-12-24 13:36:59 -08:00
+++ b/fs/reiserfs/namei.c	2004-12-24 13:36:59 -08:00
@@ -341,6 +341,7 @@
             REISERFS_SB(dir->i_sb)->priv_root &&
             REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
 	    de.de_objectid == le32_to_cpu (INODE_PKEY(REISERFS_SB(dir->i_sb)->priv_root->d_inode)->k_objectid)) {
+	  reiserfs_write_unlock (dir->i_sb);
 	  return ERR_PTR (-EACCES);
 	}
 
@@ -430,6 +431,7 @@
     int buflen, paste_size;
     int retval;
 
+    BUG_ON (!th->t_trans_id);
 
     /* cannot allow items to be added into a busy deleted directory */
     if (!namelen)
@@ -606,16 +608,21 @@
     if (locked)
         reiserfs_write_lock_xattrs (dir->i_sb);
 
-    journal_begin(&th, dir->i_sb, jbegin_count) ;
-    retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
-
-    if (locked)
-        reiserfs_write_unlock_xattrs (dir->i_sb);
-
+    retval = journal_begin(&th, dir->i_sb, jbegin_count);
     if (retval) {
+        drop_new_inode (inode);
         goto out_failed;
     }
+
+    retval = reiserfs_new_inode (&th, dir, mode, 0, 0/*i_size*/, dentry, inode);
+    if (retval)
+        goto out_failed;
 	
+    if (locked) {
+        reiserfs_write_unlock_xattrs (dir->i_sb);
+        locked = 0;
+    }
+
     inode->i_op = &reiserfs_file_inode_operations;
     inode->i_fop = &reiserfs_file_operations;
     inode->i_mapping->a_ops = &reiserfs_address_space_operations ;
@@ -623,9 +630,12 @@
     retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len, 
 				inode, 1/*visible*/);
     if (retval) {
+        int err;
 	inode->i_nlink--;
 	reiserfs_update_sd (&th, inode);
-	journal_end(&th, dir->i_sb, jbegin_count) ;
+	err = journal_end(&th, dir->i_sb, jbegin_count) ;
+        if (err)
+            retval = err;
 	iput (inode);
 	goto out_failed;
     }
@@ -633,9 +643,11 @@
     reiserfs_update_inode_transaction(dir) ;
 
     d_instantiate(dentry, inode);
-    journal_end(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_end(&th, dir->i_sb, jbegin_count) ;
 
 out_failed:
+    if (locked)
+        reiserfs_write_unlock_xattrs (dir->i_sb);
     reiserfs_write_unlock(dir->i_sb);
     return retval;
 }
@@ -666,17 +678,23 @@
     if (locked)
         reiserfs_write_lock_xattrs (dir->i_sb);
 
-    journal_begin(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
+    if (retval) {
+        drop_new_inode (inode);
+        goto out_failed;
+    }
 
     retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
-
-    if (locked)
-        reiserfs_write_unlock_xattrs (dir->i_sb);
-
     if (retval) {
         goto out_failed;
     }
 
+    if (locked) {
+        reiserfs_write_unlock_xattrs (dir->i_sb);
+        locked = 0;
+    }
+
+
     inode->i_op = &reiserfs_special_inode_operations;
     init_special_inode(inode, inode->i_mode, rdev) ;
 
@@ -689,17 +707,22 @@
     retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len, 
 				 inode, 1/*visible*/);
     if (retval) {
+        int err;
 	inode->i_nlink--;
 	reiserfs_update_sd (&th, inode);
-	journal_end(&th, dir->i_sb, jbegin_count) ;
+	err = journal_end(&th, dir->i_sb, jbegin_count) ;
+        if (err)
+	    retval = err;
 	iput (inode);
 	goto out_failed;
     }
 
     d_instantiate(dentry, inode);
-    journal_end(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_end(&th, dir->i_sb, jbegin_count) ;
 
 out_failed:
+    if (locked)
+        reiserfs_write_unlock_xattrs (dir->i_sb);
     reiserfs_write_unlock(dir->i_sb);
     return retval;
 }
@@ -730,7 +753,13 @@
     reiserfs_write_lock(dir->i_sb);
     if (locked)
         reiserfs_write_lock_xattrs (dir->i_sb);
-    journal_begin(&th, dir->i_sb, jbegin_count) ;
+
+    retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
+    if (retval) {
+        drop_new_inode (inode);
+        goto out_failed;
+    }
+
 
     /* inc the link count now, so another writer doesn't overflow it while
     ** we sleep later on.
@@ -741,13 +770,16 @@
 				old_format_only (dir->i_sb) ? 
 				EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
 				dentry, inode);
-    if (locked)
-        reiserfs_write_unlock_xattrs (dir->i_sb);
-
     if (retval) {
 	dir->i_nlink-- ;
 	goto out_failed;
     }
+
+    if (locked) {
+	reiserfs_write_unlock_xattrs (dir->i_sb);
+	locked = 0;
+    }
+
     reiserfs_update_inode_transaction(inode) ;
     reiserfs_update_inode_transaction(dir) ;
 
@@ -758,10 +790,13 @@
     retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len, 
 				inode, 1/*visible*/);
     if (retval) {
+	int err;
 	inode->i_nlink = 0;
 	DEC_DIR_INODE_NLINK(dir);
 	reiserfs_update_sd (&th, inode);
-	journal_end(&th, dir->i_sb, jbegin_count) ;
+	err = journal_end(&th, dir->i_sb, jbegin_count) ;
+	if (err)
+	    retval = err;
 	iput (inode);
 	goto out_failed;
     }
@@ -770,8 +805,10 @@
     reiserfs_update_sd (&th, dir);
 
     d_instantiate(dentry, inode);
-    journal_end(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_end(&th, dir->i_sb, jbegin_count) ;
 out_failed:
+    if (locked)
+        reiserfs_write_unlock_xattrs (dir->i_sb);
     reiserfs_write_unlock(dir->i_sb);
     return retval;
 }
@@ -791,7 +828,7 @@
 
 static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry)
 {
-    int retval;
+    int retval, err;
     struct inode * inode;
     struct reiserfs_transaction_handle th ;
     int jbegin_count; 
@@ -803,7 +840,9 @@
     jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2;
 
     reiserfs_write_lock(dir->i_sb);
-    journal_begin(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
+    if (retval)
+        goto out_rmdir;
 
     de.de_gen_number_bit_string = NULL;
     if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
@@ -852,24 +891,25 @@
     /* prevent empty directory from getting lost */
     add_save_link (&th, inode, 0/* not truncate */);
 
-    journal_end(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_end(&th, dir->i_sb, jbegin_count) ;
     reiserfs_check_path(&path) ;
+out_rmdir:
     reiserfs_write_unlock(dir->i_sb);
-    return 0;
+    return retval;
 	
  end_rmdir:
     /* we must release path, because we did not call
        reiserfs_cut_from_item, or reiserfs_cut_from_item does not
        release path if operation was not complete */
     pathrelse (&path);
-    journal_end(&th, dir->i_sb, jbegin_count) ;
+    err = journal_end(&th, dir->i_sb, jbegin_count) ;
     reiserfs_write_unlock(dir->i_sb);
-    return retval;	
+    return err ? err : retval;
 }
 
 static int reiserfs_unlink (struct inode * dir, struct dentry *dentry)
 {
-    int retval;
+    int retval, err;
     struct inode * inode;
     struct reiserfs_dir_entry de;
     INITIALIZE_PATH (path);
@@ -884,7 +924,9 @@
     jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2;
 
     reiserfs_write_lock(dir->i_sb);
-    journal_begin(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
+    if (retval)
+        goto out_unlink;
 	
     de.de_gen_number_bit_string = NULL;
     if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
@@ -938,15 +980,18 @@
        /* prevent file from getting lost */
        add_save_link (&th, inode, 0/* not truncate */);
 
-    journal_end(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_end(&th, dir->i_sb, jbegin_count) ;
     reiserfs_check_path(&path) ;
     reiserfs_write_unlock(dir->i_sb);
-    return 0;
+    return retval;
 
  end_unlink:
     pathrelse (&path);
-    journal_end(&th, dir->i_sb, jbegin_count) ;
+    err = journal_end(&th, dir->i_sb, jbegin_count) ;
     reiserfs_check_path(&path) ;
+    if (err)
+        retval = err;
+out_unlink:
     reiserfs_write_unlock(dir->i_sb);
     return retval;
 }
@@ -989,7 +1034,12 @@
 
     /* We would inherit the default ACL here, but symlinks don't get ACLs */
 
-    journal_begin(&th, parent_dir->i_sb, jbegin_count) ;
+    retval = journal_begin(&th, parent_dir->i_sb, jbegin_count) ;
+    if (retval) {
+        drop_new_inode (inode);
+        reiserfs_kfree (name, item_len, parent_dir->i_sb);
+        goto out_failed;
+    }
 
     retval = reiserfs_new_inode (&th, parent_dir, mode, name, strlen (symname), 
                                  dentry, inode);
@@ -1011,15 +1061,18 @@
     retval = reiserfs_add_entry (&th, parent_dir, dentry->d_name.name, 
                                  dentry->d_name.len, inode, 1/*visible*/);
     if (retval) {
+	int err;
 	inode->i_nlink--;
 	reiserfs_update_sd (&th, inode);
-	journal_end(&th, parent_dir->i_sb, jbegin_count) ;
+	err = journal_end(&th, parent_dir->i_sb, jbegin_count) ;
+	if (err)
+	    retval = err;
 	iput (inode);
 	goto out_failed;
     }
 
     d_instantiate(dentry, inode);
-    journal_end(&th, parent_dir->i_sb, jbegin_count) ;
+    retval = journal_end(&th, parent_dir->i_sb, jbegin_count) ;
 out_failed:
     reiserfs_write_unlock(parent_dir->i_sb);
     return retval;
@@ -1039,13 +1092,19 @@
 	return -EMLINK;
     }
     if (inode->i_nlink == 0) {
+        reiserfs_write_unlock(dir->i_sb);
         return -ENOENT;
     }
 
     /* inc before scheduling so reiserfs_unlink knows we are here */
     inode->i_nlink++;
 
-    journal_begin(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
+    if (retval) {
+        inode->i_nlink--;
+        reiserfs_write_unlock (dir->i_sb);
+        return retval;
+    }
 
     /* create new entry */
     retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
@@ -1055,10 +1114,11 @@
     reiserfs_update_inode_transaction(dir) ;
 
     if (retval) {
+	int err;
 	inode->i_nlink--;
-	journal_end(&th, dir->i_sb, jbegin_count) ;
+	err = journal_end(&th, dir->i_sb, jbegin_count) ;
 	reiserfs_write_unlock(dir->i_sb);
-	return retval;
+	return err ? err : retval;
     }
 
     inode->i_ctime = CURRENT_TIME;
@@ -1066,9 +1126,9 @@
 
     atomic_inc(&inode->i_count) ;
     d_instantiate(dentry, inode);
-    journal_end(&th, dir->i_sb, jbegin_count) ;
+    retval = journal_end(&th, dir->i_sb, jbegin_count) ;
     reiserfs_write_unlock(dir->i_sb);
-    return 0;
+    return retval;
 }
 
 
@@ -1106,7 +1166,7 @@
 
 
 /* sets key of objectid the entry has to point to */
-static void set_ino_in_dir_entry (struct reiserfs_dir_entry * de, struct key * key)
+static void set_ino_in_dir_entry (struct reiserfs_dir_entry * de, struct reiserfs_key * key)
 {
     /* JDM These operations are endian safe - both are le */
     de->de_deh[de->de_entry_num].deh_dir_id = key->k_dir_id;
@@ -1195,7 +1255,12 @@
 	}
     }
 
-    journal_begin(&th, old_dir->i_sb, jbegin_count) ;
+    retval = journal_begin(&th, old_dir->i_sb, jbegin_count) ;
+    if (retval) {
+        reiserfs_write_unlock (old_dir->i_sb);
+        return retval;
+    }
+
 
     /* add new entry (or find the existing one) */
     retval = reiserfs_add_entry (&th, new_dir, new_dentry->d_name.name, new_dentry->d_name.len, 
@@ -1206,9 +1271,9 @@
 			    "vs-7050: new entry is found, new inode == 0\n");
 	}
     } else if (retval) {
-	journal_end(&th, old_dir->i_sb, jbegin_count) ;
+	int err = journal_end(&th, old_dir->i_sb, jbegin_count) ;
 	reiserfs_write_unlock(old_dir->i_sb);
-	return retval;
+	return err ? err : retval;
     }
 
     reiserfs_update_inode_transaction(old_dir) ;
@@ -1289,7 +1354,7 @@
 	}
 
 	RFALSE( S_ISDIR(old_inode_mode) && 
-		 !reiserfs_buffer_prepared(dot_dot_de.de_bh), "" );
+		 !buffer_journal_prepared(dot_dot_de.de_bh), "" );
 
 	break;
     }
@@ -1357,9 +1422,9 @@
 	reiserfs_update_sd (&th, new_dentry_inode);
     }
 
-    journal_end(&th, old_dir->i_sb, jbegin_count) ;
+    retval = journal_end(&th, old_dir->i_sb, jbegin_count) ;
     reiserfs_write_unlock(old_dir->i_sb);
-    return 0;
+    return retval;
 }
 
 /*
@@ -1414,5 +1479,3 @@
     .permission     = reiserfs_permission,
 
 };
-
-
diff -Nru a/fs/reiserfs/objectid.c b/fs/reiserfs/objectid.c
--- a/fs/reiserfs/objectid.c	2004-12-24 13:36:48 -08:00
+++ b/fs/reiserfs/objectid.c	2004-12-24 13:36:48 -08:00
@@ -55,6 +55,7 @@
     __u32 * map = objectid_map (s, rs);
     __u32 unused_objectid;
 
+    BUG_ON (!th->t_trans_id);
 
     check_objectid_map (s, map);
 
@@ -99,6 +100,7 @@
     __u32 * map = objectid_map (s, rs);
     int i = 0;
 
+    BUG_ON (!th->t_trans_id);
     //return;
     check_objectid_map (s, map);
 
diff -Nru a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
--- a/fs/reiserfs/prints.c	2004-12-24 13:37:00 -08:00
+++ b/fs/reiserfs/prints.c	2004-12-24 13:37:00 -08:00
@@ -28,7 +28,7 @@
 }
 
 
-static char * le_offset (struct key * key)
+static char * le_offset (struct reiserfs_key * key)
 {
   int version;
 
@@ -57,7 +57,7 @@
 }
 
 
-static char * le_type (struct key * key)
+static char * le_type (struct reiserfs_key * key)
 {
     int version;
     
@@ -76,7 +76,7 @@
 
 
 /* %k */
-static void sprintf_le_key (char * buf, struct key * key)
+static void sprintf_le_key (char * buf, struct reiserfs_key * key)
 {
   if (key)
     sprintf (buf, "[%d %d %s %s]", le32_to_cpu (key->k_dir_id),
@@ -213,7 +213,7 @@
 
         switch (what) {
         case 'k':
-            sprintf_le_key (p, va_arg(args, struct key *));
+            sprintf_le_key (p, va_arg(args, struct reiserfs_key *));
             break;
         case 'K':
             sprintf_cpu_key (p, va_arg(args, struct cpu_key *));
@@ -366,6 +366,49 @@
 	 reiserfs_bdevname (sb), error_buf);
 }
 
+static void
+do_handle_error (struct super_block *sb, int errno)
+{
+    if (reiserfs_error_panic (sb)) {
+        panic ("REISERFS: panic (device %s): Panic forced after error\n",
+               reiserfs_bdevname (sb));
+    }
+
+    if (reiserfs_error_ro (sb)) {
+        printk (KERN_CRIT "REISERFS: error (device %s): Re-mounting fs "
+                "readonly\n", reiserfs_bdevname (sb));
+        reiserfs_journal_abort (sb, errno);
+    }
+}
+
+void
+reiserfs_error (struct super_block * sb, int errno, const char *fmt, ...)
+{
+    do_reiserfs_warning (fmt);
+    printk (KERN_CRIT "REISERFS: error (device %s): %s\n",
+            reiserfs_bdevname (sb), error_buf);
+    do_handle_error (sb, errno);
+}
+
+void
+reiserfs_abort (struct super_block *sb, int errno, const char *fmt, ...)
+{
+    do_reiserfs_warning (fmt);
+
+    if (reiserfs_error_panic (sb)) {
+        panic (KERN_CRIT "REISERFS: panic (device %s): %s\n",
+               reiserfs_bdevname (sb), error_buf);
+    }
+
+    if (sb->s_flags & MS_RDONLY)
+        return;
+
+    printk (KERN_CRIT "REISERFS: abort (device %s): %s\n",
+            reiserfs_bdevname (sb), error_buf);
+
+    sb->s_flags |= MS_RDONLY;
+    reiserfs_journal_abort (sb, errno);
+}
 
 void print_virtual_node (struct virtual_node * vn)
 {
@@ -419,7 +462,7 @@
    dc_size)...*/
 static int print_internal (struct buffer_head * bh, int first, int last)
 {
-    struct key * key;
+    struct reiserfs_key * key;
     struct disk_child * dc;
     int i;
     int from, to;
diff -Nru a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
--- a/fs/reiserfs/procfs.c	2004-12-24 13:36:31 -08:00
+++ b/fs/reiserfs/procfs.c	2004-12-24 13:36:31 -08:00
@@ -399,7 +399,7 @@
                         DJP( jp_journal_trans_max ),
                         DJP( jp_journal_magic ),
                         DJP( jp_journal_max_batch ),
-                        SB_JOURNAL_MAX_COMMIT_AGE(sb),
+			SB_JOURNAL(sb)->j_max_commit_age,
                         DJP( jp_journal_max_trans_age ),
 
 			JF( j_1st_reserved_block ),			
diff -Nru a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c
--- a/fs/reiserfs/resize.c	2004-12-24 13:36:47 -08:00
+++ b/fs/reiserfs/resize.c	2004-12-24 13:36:47 -08:00
@@ -19,8 +19,10 @@
 
 int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
 {
+        int err = 0;
 	struct reiserfs_super_block * sb;
         struct reiserfs_bitmap_info *bitmap;
+	struct reiserfs_bitmap_info *old_bitmap = SB_AP_BITMAP(s);
 	struct buffer_head * bh;
 	struct reiserfs_transaction_handle th;
 	unsigned int bmap_nr_new, bmap_nr;
@@ -107,12 +109,19 @@
 	     * block pointers */
 	    bitmap = vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
 	    if (!bitmap) {
+		/* Journal bitmaps are still supersized, but the memory isn't
+		 * leaked, so I guess it's ok */
 		printk("reiserfs_resize: unable to allocate memory.\n");
 		return -ENOMEM;
 	    }
 	    memset (bitmap, 0, sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
 	    for (i = 0; i < bmap_nr; i++)
-		bitmap[i] = SB_AP_BITMAP(s)[i];
+		bitmap[i] = old_bitmap[i];
+
+	    /* This doesn't go through the journal, but it doesn't have to.
+	     * The changes are still atomic: We're synced up when the journal
+	     * transaction begins, and the new bitmaps don't matter if the
+	     * transaction fails. */
 	    for (i = bmap_nr; i < bmap_nr_new; i++) {
 		bitmap[i].bh = sb_getblk(s, i * s->s_blocksize * 8);
 		memset(bitmap[i].bh->b_data, 0, sb_blocksize(sb));
@@ -126,12 +135,16 @@
 		bitmap[i].free_count = sb_blocksize(sb) * 8 - 1;
 	    }	
 	    /* free old bitmap blocks array */
-	    vfree(SB_AP_BITMAP(s));
 	    SB_AP_BITMAP(s) = bitmap;
+	    vfree (old_bitmap);
 	}
 	
-	/* begin transaction */
-	journal_begin(&th, s, 10);
+	/* begin transaction, if there was an error, it's fine. Yes, we have
+	 * incorrect bitmaps now, but none of it is ever going to touch the
+	 * disk anyway. */
+	err = journal_begin(&th, s, 10);
+	if (err)
+	    return err;
 
 	/* correct last bitmap blocks in old and new disk layout */
 	reiserfs_prepare_for_journal(s, SB_AP_BITMAP(s)[bmap_nr - 1].bh, 1);
@@ -165,8 +178,5 @@
 	journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
 	
 	SB_JOURNAL(s)->j_must_wait = 1;
-	journal_end(&th, s, 10);
-
-	return 0;
+	return journal_end(&th, s, 10);
 }
-
diff -Nru a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
--- a/fs/reiserfs/stree.c	2004-12-24 13:37:02 -08:00
+++ b/fs/reiserfs/stree.c	2004-12-24 13:37:02 -08:00
@@ -93,7 +93,7 @@
    Returns: -1 if key1 < key2 
    0 if key1 == key2
    1 if key1 > key2 */
-inline int  comp_short_keys (const struct key * le_key, 
+inline int  comp_short_keys (const struct reiserfs_key * le_key,
 			     const struct cpu_key * cpu_key)
 {
   __u32 * p_s_le_u32, * p_s_cpu_u32;
@@ -117,7 +117,7 @@
    Compare keys using all 4 key fields.
    Returns: -1 if key1 < key2 0
    if key1 = key2 1 if key1 > key2 */
-inline int  comp_keys (const struct key * le_key, const struct cpu_key * cpu_key)
+inline int  comp_keys (const struct reiserfs_key * le_key, const struct cpu_key * cpu_key)
 {
   int retval;
 
@@ -174,7 +174,7 @@
     return 0;
 }
 
-inline int comp_short_le_keys (const struct key * key1, const struct key * key2)
+inline int comp_short_le_keys (const struct reiserfs_key * key1, const struct reiserfs_key * key2)
 {
   __u32 * p_s_1_u32, * p_s_2_u32;
   int n_key_length = REISERFS_SHORT_KEY_LEN;
@@ -216,7 +216,7 @@
 }
 
 
-inline void le_key2cpu_key (struct cpu_key * to, const struct key * from)
+inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from)
 {
     to->on_disk_key.k_dir_id = le32_to_cpu (from->k_dir_id);
     to->on_disk_key.k_objectid = le32_to_cpu (from->k_objectid);
@@ -236,9 +236,9 @@
 
 // this does not say which one is bigger, it only returns 1 if keys
 // are not equal, 0 otherwise
-inline int comp_le_keys (const struct key * k1, const struct key * k2)
+inline int comp_le_keys (const struct reiserfs_key * k1, const struct reiserfs_key * k2)
 {
-    return memcmp (k1, k2, sizeof (struct key));
+    return memcmp (k1, k2, sizeof (struct reiserfs_key));
 }
 
 /**************************************************************************
@@ -272,7 +272,7 @@
     int   n_rbound, n_lbound, n_j;
 
    for ( n_j = ((n_rbound = p_n_num - 1) + (n_lbound = 0))/2; n_lbound <= n_rbound; n_j = (n_rbound + n_lbound)/2 )
-     switch( COMP_KEYS((struct key *)((char * )p_v_base + n_j * p_n_width), (struct cpu_key *)p_v_key) )  {
+     switch( COMP_KEYS((struct reiserfs_key *)((char * )p_v_base + n_j * p_n_width), (struct cpu_key *)p_v_key) )  {
      case -1: n_lbound = n_j + 1; continue;
      case  1: n_rbound = n_j - 1; continue;
      case  0: *p_n_pos = n_j;     return ITEM_FOUND; /* Key found in the array.  */
@@ -291,17 +291,17 @@
 
 
 /* Minimal possible key. It is never in the tree. */
-const struct key  MIN_KEY = {0, 0, {{0, 0},}};
+const struct reiserfs_key  MIN_KEY = {0, 0, {{0, 0},}};
 
 /* Maximal possible key. It is never in the tree. */
-const struct key  MAX_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}};
+const struct reiserfs_key  MAX_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}};
 
 
 /* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom
    of the path, and going upwards.  We must check the path's validity at each step.  If the key is not in
    the path, there is no delimiting key in the tree (buffer is first or last buffer in tree), and in this
    case we return a special key, either MIN_KEY or MAX_KEY. */
-inline	const struct  key * get_lkey  (
+inline	const struct  reiserfs_key * get_lkey  (
 	                const struct path         * p_s_chk_path,
                         const struct super_block  * p_s_sb
                       ) {
@@ -340,7 +340,7 @@
 
 
 /* Get delimiting key of the buffer at the path and its right neighbor. */
-inline	const struct  key * get_rkey  (
+inline	const struct  reiserfs_key * get_rkey  (
 	                const struct path         * p_s_chk_path,
                         const struct super_block  * p_s_sb
                       ) {
@@ -802,7 +802,7 @@
 	{
 	    int pos = p_s_last_element->pe_position;
 	    int limit = B_NR_ITEMS(p_s_bh);
-	    struct key *le_key;
+	    struct reiserfs_key *le_key;
 
 	    if (p_s_search_path->reada & PATH_READA_BACK)
 		limit = 0;
@@ -1036,6 +1036,8 @@
     struct item_head    * p_le_ih = PATH_PITEM_HEAD(p_s_path);
     struct buffer_head  * p_s_bh = PATH_PLAST_BUFFER(p_s_path);
 
+    BUG_ON (!th->t_trans_id);
+
     /* Stat_data item. */
     if ( is_statdata_le_ih (p_le_ih) ) {
 
@@ -1222,6 +1224,9 @@
     struct path         * p_s_path,
     int                   n_size
     ) {
+
+    BUG_ON (!th->t_trans_id);
+
     memset (p_s_tb,'\0',sizeof(struct tree_balance));
     p_s_tb->transaction_handle = th ;
     p_s_tb->tb_sb = p_s_sb;
@@ -1242,7 +1247,7 @@
 }
 
 #ifdef REISERQUOTA_DEBUG
-char key2type(struct key *ih)
+char key2type(struct reiserfs_key *ih)
 {
   if (is_direntry_le_key(2, ih))
     return 'd';
@@ -1290,6 +1295,8 @@
     int			n_iter = 0;
 #endif
 
+    BUG_ON (!th->t_trans_id);
+
     init_tb_struct(th, &s_del_balance, p_s_sb, p_s_path, 0/*size is unknown*/);
 
     while ( 1 ) {
@@ -1410,7 +1417,7 @@
 /* this deletes item which never gets split */
 void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
 				 struct inode *inode,
-				 struct key * key)
+				 struct reiserfs_key * key)
 {
     struct tree_balance tb;
     INITIALIZE_PATH (path);
@@ -1419,6 +1426,8 @@
     struct cpu_key cpu_key;
     int retval;
     int quota_cut_bytes = 0;
+
+    BUG_ON (!th->t_trans_id);
     
     le_key2cpu_key (&cpu_key, key);
     
@@ -1474,12 +1483,16 @@
 }
 
 
-void reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * inode)
+int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * inode)
 {
+    int err;
     inode->i_size = 0;
+    BUG_ON (!th->t_trans_id);
 
     /* for directory this deletes item containing "." and ".." */
-    reiserfs_do_truncate (th, inode, NULL, 0/*no timestamp updates*/);
+    err = reiserfs_do_truncate (th, inode, NULL, 0/*no timestamp updates*/);
+    if (err)
+        return err;
     
 #if defined( USE_INODE_GENERATION_COUNTER )
     if( !old_format_only ( th -> t_super ) )
@@ -1493,6 +1506,8 @@
 /* USE_INODE_GENERATION_COUNTER */
 #endif
     reiserfs_delete_solid_item (th, inode, INODE_PKEY (inode));
+
+    return err;
 }
 
 static void
@@ -1542,6 +1557,7 @@
     struct super_block * p_s_sb = p_s_inode->i_sb;
     int n_block_size = p_s_sb->s_blocksize;
     int cut_bytes;
+    BUG_ON (!th->t_trans_id);
 
     if (n_new_file_size != p_s_inode->i_size)
 	BUG ();
@@ -1574,6 +1590,7 @@
     struct cpu_key tail_key;
     int tail_len;
     int removed;
+    BUG_ON (!th->t_trans_id);
 
     make_cpu_key (&tail_key, inode, inode->i_size + 1, TYPE_DIRECT, 4);// !!!!
     tail_key.key_length = 4;
@@ -1623,6 +1640,8 @@
     int retval2 = -1;
     int quota_cut_bytes;
     loff_t tail_pos = 0;
+
+    BUG_ON (!th->t_trans_id);
     
     init_tb_struct(th, &s_cut_balance, p_s_inode->i_sb, p_s_path, n_cut_size);
 
@@ -1775,6 +1794,7 @@
 
 static void truncate_directory (struct reiserfs_transaction_handle *th, struct inode * inode)
 {
+    BUG_ON (!th->t_trans_id);
     if (inode->i_nlink)
 	reiserfs_warning (inode->i_sb,
 			  "vs-5655: truncate_directory: link count != 0");
@@ -1792,7 +1812,7 @@
 
 /* Truncate file to the new size. Note, this must be called with a transaction
    already started */
-void reiserfs_do_truncate (struct reiserfs_transaction_handle *th, 
+int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
 			   struct  inode * p_s_inode, /* ->i_size contains new
                                                          size */
 			   struct page *page, /* up to date for last block */
@@ -1808,14 +1828,16 @@
 	n_new_file_size;/* New file size. */
     int                   n_deleted;      /* Number of deleted or truncated bytes. */
     int retval;
+    int err = 0;
 
+    BUG_ON (!th->t_trans_id);
     if ( ! (S_ISREG(p_s_inode->i_mode) || S_ISDIR(p_s_inode->i_mode) || S_ISLNK(p_s_inode->i_mode)) )
-	return;
+	return 0;
 
     if (S_ISDIR(p_s_inode->i_mode)) {
 	// deletion of directory - no need to update timestamps
 	truncate_directory (th, p_s_inode);
-	return;
+	return 0;
     }
 
     /* Get new file size. */
@@ -1828,13 +1850,15 @@
     if (retval == IO_ERROR) {
 	reiserfs_warning (p_s_inode->i_sb, "vs-5657: reiserfs_do_truncate: "
 			  "i/o failure occurred trying to truncate %K", &s_item_key);
-	return;
+        err = -EIO;
+        goto out;
     }
     if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) {
-	pathrelse (&s_search_path);
 	reiserfs_warning (p_s_inode->i_sb, "PAP-5660: reiserfs_do_truncate: "
 			  "wrong result %d of search for %K", retval, &s_item_key);
-	return;
+
+        err = -EIO;
+        goto out;
     }
 
     s_search_path.pos_in_item --;
@@ -1872,7 +1896,7 @@
 	if (n_deleted < 0) {
 	    reiserfs_warning (p_s_inode->i_sb, "vs-5665: reiserfs_do_truncate: reiserfs_cut_from_item failed");
 	    reiserfs_check_path(&s_search_path) ;
-	    return;
+	    return 0;
 	}
 
 	RFALSE( n_deleted > n_file_size,
@@ -1902,8 +1926,13 @@
 	  } 
 	  reiserfs_update_sd(th, p_s_inode) ;
 
-	  journal_end(th, p_s_inode->i_sb, orig_len_alloc) ;
-	  journal_begin(th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 6) ;
+	  err = journal_end(th, p_s_inode->i_sb, orig_len_alloc) ;
+	  if (err)
+	    goto out;
+	  err = journal_begin (th, p_s_inode->i_sb,
+                               JOURNAL_PER_BALANCE_CNT * 6);
+	  if (err)
+	    goto out;
 	  reiserfs_update_inode_transaction(p_s_inode) ;
 	}
     } while ( n_file_size > ROUND_UP (n_new_file_size) &&
@@ -1920,7 +1949,9 @@
     }
     reiserfs_update_sd (th, p_s_inode);
 
+out:
     pathrelse(&s_search_path) ;
+    return err;
 }
 
 
@@ -1963,6 +1994,8 @@
     int                 retval;
     int			fs_gen;
 
+    BUG_ON (!th->t_trans_id);
+
     fs_gen = get_generation(inode->i_sb) ;
 
 #ifdef REISERQUOTA_DEBUG
@@ -2034,6 +2067,8 @@
     int                 retval;
     int fs_gen = 0 ;
     int quota_bytes = 0 ;
+
+    BUG_ON (!th->t_trans_id);
 
     if (inode) {      /* Do we count quotas for item? */
 	fs_gen = get_generation(inode->i_sb);
diff -Nru a/fs/reiserfs/super.c b/fs/reiserfs/super.c
--- a/fs/reiserfs/super.c	2004-12-24 13:36:48 -08:00
+++ b/fs/reiserfs/super.c	2004-12-24 13:36:48 -08:00
@@ -24,6 +24,7 @@
 #include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/vfs.h>
+#include <linux/namespace.h>
 
 struct file_system_type reiserfs_fs_type;
 
@@ -66,11 +67,14 @@
     if (!(s->s_flags & MS_RDONLY)) {
         struct reiserfs_transaction_handle th;
 	reiserfs_write_lock(s);
-	journal_begin(&th, s, 1);
-	journal_end_sync(&th, s, 1);
-	reiserfs_flush_old_commits(s);
-	s->s_dirt = 0;
+	if (!journal_begin(&th, s, 1))
+            if (!journal_end_sync(&th, s, 1))
+                reiserfs_flush_old_commits(s);
+	s->s_dirt = 0; /* Even if it's not true.
+                        * We'll loop forever in sync_supers otherwise */
 	reiserfs_write_unlock(s);
+    } else {
+        s->s_dirt = 0;
     }
 }
 
@@ -84,11 +88,15 @@
   struct reiserfs_transaction_handle th ;
   reiserfs_write_lock(s);
   if (!(s->s_flags & MS_RDONLY)) {
-    journal_begin(&th, s, 1) ;
-    reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
-    journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
-    reiserfs_block_writes(&th) ;
-    journal_end_sync(&th, s, 1) ;
+    int err = journal_begin(&th, s, 1) ;
+    if (err) {
+        reiserfs_block_writes(&th) ;
+    } else {
+        reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
+        journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
+        reiserfs_block_writes(&th) ;
+        journal_end_sync(&th, s, 1) ;
+    }
   }
   s->s_dirt = 0;
   reiserfs_write_unlock(s);
@@ -98,7 +106,7 @@
   reiserfs_allow_writes(s) ;
 }
 
-extern const struct key  MAX_KEY;
+extern const struct reiserfs_key  MAX_KEY;
 
 
 /* this is used to delete "save link" when there are no items of a
@@ -108,29 +116,32 @@
    protecting unlink is bigger that a key lf "save link" which
    protects truncate), so there left no items to make truncate
    completion on */
-static void remove_save_link_only (struct super_block * s, struct key * key, int oid_free)
+static int remove_save_link_only (struct super_block * s, struct reiserfs_key * key, int oid_free)
 {
     struct reiserfs_transaction_handle th;
+    int err;
 
      /* we are going to do one balancing */
-     journal_begin (&th, s, JOURNAL_PER_BALANCE_CNT);
+     err = journal_begin (&th, s, JOURNAL_PER_BALANCE_CNT);
+     if (err)
+        return err;
  
      reiserfs_delete_solid_item (&th, NULL, key);
      if (oid_free)
         /* removals are protected by direct items */
         reiserfs_release_objectid (&th, le32_to_cpu (key->k_objectid));
 
-     journal_end (&th, s, JOURNAL_PER_BALANCE_CNT);
+     return journal_end (&th, s, JOURNAL_PER_BALANCE_CNT);
 }
  
  
 /* look for uncompleted unlinks and truncates and complete them */
-static void finish_unfinished (struct super_block * s)
+static int finish_unfinished (struct super_block * s)
 {
     INITIALIZE_PATH (path);
     struct cpu_key max_cpu_key, obj_key;
-    struct key save_link_key;
-    int retval;
+    struct reiserfs_key save_link_key;
+    int retval = 0;
     struct item_head * ih;
     struct buffer_head * bh;
     int item_pos;
@@ -147,7 +158,7 @@
  
     done = 0;
     REISERFS_SB(s)->s_is_unlinked_ok = 1;
-    while (1) {
+    while (!retval) {
         retval = search_item (s, &max_cpu_key, &path);
         if (retval != ITEM_NOT_FOUND) {
             reiserfs_warning (s, "vs-2140: finish_unfinished: search_by_key returned %d",
@@ -189,7 +200,7 @@
 	       "save" link and release objectid */
             reiserfs_warning (s, "vs-2180: finish_unfinished: iget failed for %K",
                               &obj_key);
-            remove_save_link_only (s, &save_link_key, 1);
+            retval = remove_save_link_only (s, &save_link_key, 1);
             continue;
         }
 
@@ -197,7 +208,7 @@
 	    /* file is not unlinked */
             reiserfs_warning (s, "vs-2185: finish_unfinished: file %K is not unlinked",
                               &obj_key);
-            remove_save_link_only (s, &save_link_key, 0);
+            retval = remove_save_link_only (s, &save_link_key, 0);
             continue;
 	}
 
@@ -207,7 +218,7 @@
 	       then boot into old kernel, remove the file and create dir with
 	       the same key. */
 	    reiserfs_warning(s, "green-2101: impossible truncate on a directory %k. Please report", INODE_PKEY (inode));
-	    remove_save_link_only (s, &save_link_key, 0);
+	    retval = remove_save_link_only (s, &save_link_key, 0);
 	    truncate = 0;
 	    iput (inode); 
 	    continue;
@@ -220,12 +231,13 @@
             reiserfs_info (s, "Truncating %k to %Ld ..",
                               INODE_PKEY (inode), inode->i_size);
             reiserfs_truncate_file (inode, 0/*don't update modification time*/);
-            remove_save_link (inode, truncate);
+            retval = remove_save_link (inode, truncate);
         } else {
             REISERFS_I(inode) -> i_flags |= i_link_saved_unlink_mask;
             /* not completed unlink (rmdir) found */
             reiserfs_info (s, "Removing %k..", INODE_PKEY (inode));
             /* removal gets completed in iput */
+            retval = 0;
         }
  
         iput (inode);
@@ -238,6 +250,7 @@
     if (done)
         reiserfs_info (s, "There were %d uncompleted unlinks/truncates. "
                           "Completed\n", done);
+    return retval;
 }
  
 /* to protect file being unlinked from getting lost we "safe" link files
@@ -253,6 +266,8 @@
     struct item_head ih;
     __u32 link;
 
+    BUG_ON (!th->t_trans_id);
+
     /* file can only get one "save link" of each kind */
     RFALSE( truncate && 
 	    ( REISERFS_I(inode) -> i_flags & i_link_saved_truncate_mask ),
@@ -317,14 +332,16 @@
 
 
 /* this opens transaction unlike add_save_link */
-void remove_save_link (struct inode * inode, int truncate)
+int remove_save_link (struct inode * inode, int truncate)
 {
     struct reiserfs_transaction_handle th;
-    struct key key;
- 
+    struct reiserfs_key key;
+    int err;
  
     /* we are going to do one balancing only */
-    journal_begin (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
+    err = journal_begin (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
+    if (err)
+        return err;
  
     /* setup key of "save" link */
     key.k_dir_id = cpu_to_le32 (MAX_KEY_OBJECTID);
@@ -352,7 +369,7 @@
     } else
 	REISERFS_I(inode) -> i_flags &= ~i_link_saved_truncate_mask;
  
-    journal_end (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
+    return journal_end (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
 }
 
 
@@ -360,6 +377,7 @@
 {
   int i;
   struct reiserfs_transaction_handle th ;
+  th.t_trans_id = 0;
 
   if (REISERFS_SB(s)->xattr_root) {
     d_invalidate (REISERFS_SB(s)->xattr_root);
@@ -373,10 +391,11 @@
 
   /* change file system state to current state if it was mounted with read-write permissions */
   if (!(s->s_flags & MS_RDONLY)) {
-    journal_begin(&th, s, 10) ;
-    reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
-    set_sb_umount_state( SB_DISK_SUPER_BLOCK(s), REISERFS_SB(s)->s_mount_state );
-    journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
+    if (!journal_begin(&th, s, 10)) {
+        reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
+        set_sb_umount_state( SB_DISK_SUPER_BLOCK(s), REISERFS_SB(s)->s_mount_state );
+        journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
+    }
   }
 
   /* note, journal_release checks for readonly mount, and can decide not
@@ -461,6 +480,7 @@
 static void reiserfs_dirty_inode (struct inode * inode) {
     struct reiserfs_transaction_handle th ;
 
+    int err = 0;
     if (inode->i_sb->s_flags & MS_RDONLY) {
         reiserfs_warning(inode->i_sb, "clm-6006: writing inode %lu on readonly FS",
 	                  inode->i_ino) ;
@@ -471,7 +491,11 @@
     /* this is really only used for atime updates, so they don't have
     ** to be included in O_SYNC or fsync
     */
-    journal_begin(&th, inode->i_sb, 1) ;
+    err = journal_begin(&th, inode->i_sb, 1) ;
+    if (err) {
+        reiserfs_write_unlock (inode->i_sb);
+        return;
+    }
     reiserfs_update_sd (&th, inode);
     journal_end(&th, inode->i_sb, 1) ;
     reiserfs_write_unlock(inode->i_sb);
@@ -575,6 +599,18 @@
     {NULL, 0, 0}
 };
 
+static const arg_desc_t error_actions[] = {
+    {"panic", 1 << REISERFS_ERROR_PANIC,
+              (1 << REISERFS_ERROR_RO | 1 << REISERFS_ERROR_CONTINUE)},
+    {"ro-remount", 1 << REISERFS_ERROR_RO,
+              (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_CONTINUE)},
+#ifdef REISERFS_JOURNAL_ERROR_ALLOWS_NO_LOG
+    {"continue", 1 << REISERFS_ERROR_CONTINUE,
+              (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_RO)},
+#endif
+    {NULL, 0, 0},
+};
+
 int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 128k.
 					      There might be broken applications that are
 					      confused by this. Use nolargeio mount option
@@ -626,8 +662,14 @@
     for (opt = opts; opt->option_name; opt ++) {
 	if (!strncmp (p, opt->option_name, strlen (opt->option_name))) {
 	    if (bit_flags) {
-		*bit_flags &= ~opt->clrmask;
-		*bit_flags |= opt->setmask;
+                if (opt->clrmask == (1 << REISERFS_UNSUPPORTED_OPT))
+                    reiserfs_warning (s, "%s not supported.", p);
+                else
+                    *bit_flags &= ~opt->clrmask;
+                if (opt->setmask == (1 << REISERFS_UNSUPPORTED_OPT))
+                    reiserfs_warning (s, "%s not supported.", p);
+                else
+                    *bit_flags |= opt->setmask;
 	    }
 	    break;
 	}
@@ -708,11 +750,19 @@
 	{"conv",	.setmask = 1<<REISERFS_CONVERT},
 	{"attrs",	.setmask = 1<<REISERFS_ATTRS},
 	{"noattrs",	.clrmask = 1<<REISERFS_ATTRS},
+#ifdef CONFIG_REISERFS_FS_XATTR
 	{"user_xattr",	.setmask = 1<<REISERFS_XATTRS_USER},
 	{"nouser_xattr",.clrmask = 1<<REISERFS_XATTRS_USER},
+#else
+	{"user_xattr",	.setmask = 1<<REISERFS_UNSUPPORTED_OPT},
+	{"nouser_xattr",.clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
+#endif
 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
 	{"acl",		.setmask = 1<<REISERFS_POSIXACL},
 	{"noacl",	.clrmask = 1<<REISERFS_POSIXACL},
+#else
+	{"acl",		.setmask = 1<<REISERFS_UNSUPPORTED_OPT},
+	{"noacl",	.clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
 #endif
 	{"nolog",},	 /* This is unsupported */
 	{"replayonly",	.setmask = 1<<REPLAYONLY},
@@ -725,6 +775,7 @@
 	{"commit",	.arg_required = 'c', .values = NULL},
 	{"usrquota",},
 	{"grpquota",},
+	{"errors", 	.arg_required = 'e', .values = error_actions},
 	{NULL,}
     };
 	
@@ -861,6 +912,8 @@
   unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
   unsigned long safe_mask = 0;
   unsigned int commit_max_age = (unsigned int)-1;
+  struct reiserfs_journal *journal = SB_JOURNAL(s);
+  int err;
 
   rs = SB_DISK_SUPER_BLOCK (s);
 
@@ -881,20 +934,23 @@
   safe_mask |= 1 << REISERFS_POSIXACL;
   safe_mask |= 1 << REISERFS_BARRIER_FLUSH;
   safe_mask |= 1 << REISERFS_BARRIER_NONE;
+  safe_mask |= 1 << REISERFS_ERROR_RO;
+  safe_mask |= 1 << REISERFS_ERROR_CONTINUE;
+  safe_mask |= 1 << REISERFS_ERROR_PANIC;
 
   /* Update the bitmask, taking care to keep
    * the bits we're not allowed to change here */
   REISERFS_SB(s)->s_mount_opt = (REISERFS_SB(s)->s_mount_opt & ~safe_mask) |  (mount_options & safe_mask);
 
   if(commit_max_age != 0 && commit_max_age != (unsigned int)-1) {
-    SB_JOURNAL_MAX_COMMIT_AGE(s) = commit_max_age;
-    SB_JOURNAL_MAX_TRANS_AGE(s) = commit_max_age;
+    journal->j_max_commit_age = commit_max_age;
+    journal->j_max_trans_age = commit_max_age;
   }
   else if(commit_max_age == 0)
   {
     /* 0 means restore defaults. */
-    SB_JOURNAL_MAX_COMMIT_AGE(s) = SB_JOURNAL_DEFAULT_MAX_COMMIT_AGE(s);
-    SB_JOURNAL_MAX_TRANS_AGE(s) = JOURNAL_MAX_TRANS_AGE;
+    journal->j_max_commit_age = journal->j_default_max_commit_age;
+    journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
   }
 
   if(blocks) {
@@ -914,7 +970,10 @@
       return 0;
     }
 
-    journal_begin(&th, s, 10) ;
+    err = journal_begin(&th, s, 10) ;
+    if (err)
+        return err;
+
     /* Mounting a rw partition read-only. */
     reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
     set_sb_umount_state( rs, REISERFS_SB(s)->s_mount_state );
@@ -926,11 +985,16 @@
 	return 0; /* We are read-write already */
     }
 
+    if (reiserfs_is_journal_aborted (journal))
+	return journal->j_errno;
+
     handle_data_mode(s, mount_options);
     handle_barrier_mode(s, mount_options);
     REISERFS_SB(s)->s_mount_state = sb_umount_state(rs) ;
     s->s_flags &= ~MS_RDONLY ; /* now it is safe to call journal_begin */
-    journal_begin(&th, s, 10) ;
+    err = journal_begin(&th, s, 10) ;
+    if (err)
+	return err;
     
     /* Mount a partition which is read-only, read-write */
     reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
@@ -943,7 +1007,9 @@
   }
   /* this will force a full flush of all journal lists */
   SB_JOURNAL(s)->j_must_wait = 1 ;
-  journal_end(&th, s, 10) ;
+  err = journal_end(&th, s, 10) ;
+  if (err)
+    return err;
   s->s_dirt = 0;
 
   if (!( *mount_flags & MS_RDONLY ) ) {
@@ -1371,8 +1437,9 @@
     }
     s->s_fs_info = sbi;
     memset (sbi, 0, sizeof (struct reiserfs_sb_info));
-    /* Set default values for options: non-aggressive tails */
-    REISERFS_SB(s)->s_mount_opt = ( 1 << REISERFS_SMALLTAIL );
+    /* Set default values for options: non-aggressive tails, RO on errors */
+    REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
+    REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
     /* no preallocation minimum, be smart in
        reiserfs_file_write instead */
     REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
@@ -1500,7 +1567,12 @@
     
     if (!(s->s_flags & MS_RDONLY)) {
 
-	journal_begin(&th, s, 1) ;
+	errval = journal_begin(&th, s, 1) ;
+        if (errval) {
+	    dput (s->s_root);
+	    s->s_root = NULL;
+	    goto error;
+        }
 	reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
 
         set_sb_umount_state( rs, REISERFS_ERROR_FS );
@@ -1530,9 +1602,14 @@
 	}
 
 	journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
-	journal_end(&th, s, 1) ;
+	errval = journal_end(&th, s, 1) ;
+	if (errval) {
+	    dput (s->s_root);
+	    s->s_root = NULL;
+	    goto error;
+	}
 
-	if (reiserfs_xattr_init (s, s->s_flags)) {
+	if ((errval = reiserfs_xattr_init (s, s->s_flags))) {
 	    dput (s->s_root);
 	    s->s_root = NULL;
 	    goto error;
@@ -1545,7 +1622,7 @@
 	    reiserfs_info (s, "using 3.5.x disk format\n") ;
 	}
 
-	if (reiserfs_xattr_init (s, s->s_flags)) {
+	if ((errval = reiserfs_xattr_init (s, s->s_flags))) {
 	    dput (s->s_root);
 	    s->s_root = NULL;
 	    goto error;
diff -Nru a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c
--- a/fs/reiserfs/tail_conversion.c	2004-12-24 13:37:43 -08:00
+++ b/fs/reiserfs/tail_conversion.c	2004-12-24 13:37:43 -08:00
@@ -34,6 +34,7 @@
 				       that will be inserted in the
 				       tree. */
 
+    BUG_ON (!th->t_trans_id);
 
     REISERFS_SB(sb)->s_direct2indirect ++;
 
@@ -183,6 +184,8 @@
     int tail_len, round_tail_len;
     loff_t pos, pos1; /* position of first byte of the tail */
     struct cpu_key key;
+
+    BUG_ON (!th->t_trans_id);
 
     REISERFS_SB(p_s_sb)->s_indirect2direct ++;
 
diff -Nru a/fs/select.c b/fs/select.c
--- a/fs/select.c	2004-12-24 13:36:17 -08:00
+++ b/fs/select.c	2004-12-24 13:36:17 -08:00
@@ -14,6 +14,7 @@
  *     of fds to overcome nfds < 16390 descriptors limit (Tigran Aivazian).
  */
 
+#include <linux/syscalls.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
@@ -266,8 +267,6 @@
 	*timeout = __timeout;
 	return retval;
 }
-
-EXPORT_SYMBOL(do_select);
 
 static void *select_bits_alloc(int size)
 {
diff -Nru a/fs/smbfs/inode.c b/fs/smbfs/inode.c
--- a/fs/smbfs/inode.c	2004-12-24 13:36:18 -08:00
+++ b/fs/smbfs/inode.c	2004-12-24 13:36:18 -08:00
@@ -368,7 +368,6 @@
 				&optopt, &optarg, &flags, &value)) > 0) {
 
 		VERBOSE("'%s' -> '%s'\n", optopt, optarg ? optarg : "<none>");
-
 		switch (c) {
 		case 1:
 			/* got a "flag" option */
@@ -383,15 +382,19 @@
 			break;
 		case 'u':
 			mnt->uid = value;
+			flags |= SMB_MOUNT_UID;
 			break;
 		case 'g':
 			mnt->gid = value;
+			flags |= SMB_MOUNT_GID;
 			break;
 		case 'f':
 			mnt->file_mode = (value & S_IRWXUGO) | S_IFREG;
+			flags |= SMB_MOUNT_FMODE;
 			break;
 		case 'd':
 			mnt->dir_mode = (value & S_IRWXUGO) | S_IFDIR;
+			flags |= SMB_MOUNT_DMODE;
 			break;
 		case 'i':
 			strlcpy(mnt->codepage.local_name, optarg, 
@@ -429,9 +432,9 @@
 		if (mnt->flags & opts[i].flag)
 			seq_printf(s, ",%s", opts[i].name);
 
-	if (mnt->uid != 0)
+	if (mnt->flags & SMB_MOUNT_UID)
 		seq_printf(s, ",uid=%d", mnt->uid);
-	if (mnt->gid != 0)
+	if (mnt->flags & SMB_MOUNT_GID)
 		seq_printf(s, ",gid=%d", mnt->gid);
 	if (mnt->mounted_uid != 0)
 		seq_printf(s, ",mounted_uid=%d", mnt->mounted_uid);
@@ -440,8 +443,10 @@
 	 * Defaults for file_mode and dir_mode are unknown to us; they
 	 * depend on the current umask of the user doing the mount.
 	 */
-	seq_printf(s, ",file_mode=%04o", mnt->file_mode & S_IRWXUGO);
-	seq_printf(s, ",dir_mode=%04o", mnt->dir_mode & S_IRWXUGO);
+	if (mnt->flags & SMB_MOUNT_FMODE)
+		seq_printf(s, ",file_mode=%04o", mnt->file_mode & S_IRWXUGO);
+	if (mnt->flags & SMB_MOUNT_DMODE)
+		seq_printf(s, ",dir_mode=%04o", mnt->dir_mode & S_IRWXUGO);
 
 	if (strcmp(mnt->codepage.local_name, CONFIG_NLS_DEFAULT))
 		seq_printf(s, ",iocharset=%s", mnt->codepage.local_name);
@@ -566,8 +571,13 @@
 		mnt->file_mode = (oldmnt->file_mode & S_IRWXUGO) | S_IFREG;
 		mnt->dir_mode = (oldmnt->dir_mode & S_IRWXUGO) | S_IFDIR;
 
-		mnt->flags = (oldmnt->file_mode >> 9);
+		mnt->flags = (oldmnt->file_mode >> 9) | SMB_MOUNT_UID |
+			SMB_MOUNT_GID | SMB_MOUNT_FMODE | SMB_MOUNT_DMODE;
 	} else {
+		mnt->file_mode = S_IRWXU | S_IRGRP | S_IXGRP |
+				S_IROTH | S_IXOTH | S_IFREG;
+		mnt->dir_mode = S_IRWXU | S_IRGRP | S_IXGRP |
+				S_IROTH | S_IXOTH | S_IFDIR;
 		if (parse_options(mnt, raw_data))
 			goto out_bad_option;
 	}
@@ -599,6 +609,7 @@
 	sb->s_root = d_alloc_root(root_inode);
 	if (!sb->s_root)
 		goto out_no_root;
+
 	smb_new_dentry(sb->s_root);
 
 	return 0;
diff -Nru a/fs/smbfs/proc.c b/fs/smbfs/proc.c
--- a/fs/smbfs/proc.c	2004-12-24 13:36:18 -08:00
+++ b/fs/smbfs/proc.c	2004-12-24 13:36:18 -08:00
@@ -2074,7 +2074,7 @@
 	return result;
 }
 
-void smb_decode_unix_basic(struct smb_fattr *fattr, char *p)
+void smb_decode_unix_basic(struct smb_fattr *fattr, struct smb_sb_info *server, char *p)
 {
 	u64 size, disk_bytes;
 
@@ -2111,8 +2111,17 @@
 	fattr->f_ctime = smb_ntutc2unixutc(LVAL(p, 16));
 	fattr->f_atime = smb_ntutc2unixutc(LVAL(p, 24));
 	fattr->f_mtime = smb_ntutc2unixutc(LVAL(p, 32));
-	fattr->f_uid = LVAL(p, 40); 
-	fattr->f_gid = LVAL(p, 48); 
+
+	if (server->mnt->flags & SMB_MOUNT_UID)
+		fattr->f_uid = server->mnt->uid;
+	else
+		fattr->f_uid = LVAL(p, 40);
+
+	if (server->mnt->flags & SMB_MOUNT_GID)
+		fattr->f_gid = server->mnt->gid;
+	else
+		fattr->f_gid = LVAL(p, 48);
+
 	fattr->f_mode |= smb_filetype_to_mode(WVAL(p, 56));
 
 	if (S_ISBLK(fattr->f_mode) || S_ISCHR(fattr->f_mode)) {
@@ -2121,10 +2130,20 @@
 
 		fattr->f_rdev = MKDEV(major & 0xffffffff, minor & 0xffffffff);
 		if (MAJOR(fattr->f_rdev) != (major & 0xffffffff) ||
-		    MINOR(fattr->f_rdev) != (minor & 0xffffffff))
+	    	MINOR(fattr->f_rdev) != (minor & 0xffffffff))
 			fattr->f_rdev = 0;
 	}
+
 	fattr->f_mode |= LVAL(p, 84);
+
+	if ( (server->mnt->flags & SMB_MOUNT_DMODE) &&
+	     (S_ISDIR(fattr->f_mode)) )
+		fattr->f_mode = (server->mnt->dir_mode & S_IRWXUGO) | S_IFDIR;
+	else if ( (server->mnt->flags & SMB_MOUNT_FMODE) &&
+	          !(S_ISDIR(fattr->f_mode)) )
+		fattr->f_mode = (server->mnt->file_mode & S_IRWXUGO) |
+				(fattr->f_mode & S_IFMT);
+
 }
 
 /*
@@ -2210,7 +2229,7 @@
 		/* FIXME: should we check the length?? */
 
 		p += 8;
-		smb_decode_unix_basic(fattr, p);
+		smb_decode_unix_basic(fattr, server, p);
 		VERBOSE("info SMB_FIND_FILE_UNIX at %p, len=%d, name=%.*s\n",
 			p, len, len, qname->name);
 		break;
@@ -2769,7 +2788,7 @@
 	if (result < 0)
 		goto out_free;
 
-	smb_decode_unix_basic(attr, req->rq_data);
+	smb_decode_unix_basic(attr, server, req->rq_data);
 
 out_free:
 	smb_rput(req);
diff -Nru a/fs/smbfs/proto.h b/fs/smbfs/proto.h
--- a/fs/smbfs/proto.h	2004-12-24 13:37:00 -08:00
+++ b/fs/smbfs/proto.h	2004-12-24 13:37:00 -08:00
@@ -24,7 +24,7 @@
 extern int smb_proc_unlink(struct dentry *dentry);
 extern int smb_proc_flush(struct smb_sb_info *server, __u16 fileid);
 extern void smb_init_root_dirent(struct smb_sb_info *server, struct smb_fattr *fattr);
-extern void smb_decode_unix_basic(struct smb_fattr *fattr, char *p);
+extern void smb_decode_unix_basic(struct smb_fattr *fattr, struct smb_sb_info *server, char *p);
 extern int smb_proc_getattr(struct dentry *dir, struct smb_fattr *fattr);
 extern int smb_proc_setattr(struct dentry *dir, struct smb_fattr *fattr);
 extern int smb_proc_setattr_unix(struct dentry *d, struct iattr *attr, unsigned int major, unsigned int minor);
diff -Nru a/fs/smbfs/request.c b/fs/smbfs/request.c
--- a/fs/smbfs/request.c	2004-12-24 13:37:32 -08:00
+++ b/fs/smbfs/request.c	2004-12-24 13:37:32 -08:00
@@ -634,6 +634,7 @@
 		req->rq_trans2buffer = smb_kmalloc(buf_len, GFP_NOFS);
 		if (!req->rq_trans2buffer)
 			goto out_no_mem;
+		memset(req->rq_trans2buffer, 0, buf_len);
 
 		req->rq_parm = req->rq_trans2buffer;
 		req->rq_data = req->rq_trans2buffer + parm_tot;
@@ -657,8 +658,11 @@
 	 * Check whether we've received all of the data. Note that
 	 * we use the packet totals -- total lengths might shrink!
 	 */
-	if (req->rq_ldata >= data_tot && req->rq_lparm >= parm_tot)
+	if (req->rq_ldata >= data_tot && req->rq_lparm >= parm_tot) {
+		req->rq_ldata = data_tot;
+		req->rq_lparm = parm_tot;
 		return 0;
+	}
 	return 1;
 
 out_too_long:
diff -Nru a/fs/stat.c b/fs/stat.c
--- a/fs/stat.c	2004-12-24 13:36:19 -08:00
+++ b/fs/stat.c	2004-12-24 13:36:19 -08:00
@@ -14,6 +14,7 @@
 #include <linux/fs.h>
 #include <linux/namei.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
diff -Nru a/fs/super.c b/fs/super.c
--- a/fs/super.c	2004-12-24 13:36:48 -08:00
+++ b/fs/super.c	2004-12-24 13:36:48 -08:00
@@ -32,9 +32,11 @@
 #include <linux/buffer_head.h>		/* for fsync_super() */
 #include <linux/mount.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 #include <linux/vfs.h>
 #include <linux/writeback.h>		/* for the emergency remount stuff */
 #include <linux/idr.h>
+#include <linux/kobject.h>
 #include <asm/uaccess.h>
 
 
@@ -655,6 +657,16 @@
 	return (void *)s->s_bdev == data;
 }
 
+static void bdev_uevent(struct block_device *bdev, enum kobject_action action)
+{
+	if (bdev->bd_disk) {
+		if (bdev->bd_part)
+			kobject_uevent(&bdev->bd_part->kobj, action, NULL);
+		else
+			kobject_uevent(&bdev->bd_disk->kobj, action, NULL);
+	}
+}
+
 struct super_block *get_sb_bdev(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data,
 	int (*fill_super)(struct super_block *, void *, int))
@@ -697,8 +709,10 @@
 			up_write(&s->s_umount);
 			deactivate_super(s);
 			s = ERR_PTR(error);
-		} else
+		} else {
 			s->s_flags |= MS_ACTIVE;
+			bdev_uevent(bdev, KOBJ_MOUNT);
+		}
 	}
 
 	return s;
@@ -713,6 +727,8 @@
 void kill_block_super(struct super_block *sb)
 {
 	struct block_device *bdev = sb->s_bdev;
+
+	bdev_uevent(bdev, KOBJ_UMOUNT);
 	generic_shutdown_super(sb);
 	set_blocksize(bdev, sb->s_old_blocksize);
 	close_bdev_excl(bdev);
diff -Nru a/fs/sysfs/bin.c b/fs/sysfs/bin.c
--- a/fs/sysfs/bin.c	2004-12-24 13:36:49 -08:00
+++ b/fs/sysfs/bin.c	2004-12-24 13:36:49 -08:00
@@ -17,8 +17,8 @@
 static int
 fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count)
 {
-	struct bin_attribute * attr = dentry->d_fsdata;
-	struct kobject * kobj = dentry->d_parent->d_fsdata;
+	struct bin_attribute * attr = to_bin_attr(dentry);
+	struct kobject * kobj = to_kobj(dentry->d_parent);
 
 	return attr->read(kobj, buffer, off, count);
 }
@@ -60,8 +60,8 @@
 static int
 flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count)
 {
-	struct bin_attribute *attr = dentry->d_fsdata;
-	struct kobject *kobj = dentry->d_parent->d_fsdata;
+	struct bin_attribute *attr = to_bin_attr(dentry);
+	struct kobject *kobj = to_kobj(dentry->d_parent);
 
 	return attr->write(kobj, buffer, offset, count);
 }
@@ -95,7 +95,7 @@
 static int open(struct inode * inode, struct file * file)
 {
 	struct kobject *kobj = sysfs_get_kobject(file->f_dentry->d_parent);
-	struct bin_attribute * attr = file->f_dentry->d_fsdata;
+	struct bin_attribute * attr = to_bin_attr(file->f_dentry);
 	int error = -EINVAL;
 
 	if (!kobj || !attr)
@@ -130,8 +130,8 @@
 
 static int release(struct inode * inode, struct file * file)
 {
-	struct kobject * kobj = file->f_dentry->d_parent->d_fsdata;
-	struct bin_attribute * attr = file->f_dentry->d_fsdata;
+	struct kobject * kobj = to_kobj(file->f_dentry->d_parent);
+	struct bin_attribute * attr = to_bin_attr(file->f_dentry);
 	u8 * buffer = file->private_data;
 
 	if (kobj) 
@@ -141,7 +141,7 @@
 	return 0;
 }
 
-static struct file_operations bin_fops = {
+struct file_operations bin_fops = {
 	.read		= read,
 	.write		= write,
 	.llseek		= generic_file_llseek,
@@ -158,31 +158,9 @@
 
 int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
 {
-	struct dentry * dentry;
-	struct dentry * parent;
-	int error = 0;
+	BUG_ON(!kobj || !kobj->dentry || !attr);
 
-	if (!kobj || !attr)
-		return -EINVAL;
-
-	parent = kobj->dentry;
-
-	down(&parent->d_inode->i_sem);
-	dentry = sysfs_get_dentry(parent,attr->attr.name);
-	if (!IS_ERR(dentry)) {
-		dentry->d_fsdata = (void *)attr;
-		error = sysfs_create(dentry,
-				     (attr->attr.mode & S_IALLUGO) | S_IFREG,
-				     NULL);
-		if (!error) {
-			dentry->d_inode->i_size = attr->size;
-			dentry->d_inode->i_fop = &bin_fops;
-		}
-		dput(dentry);
-	} else
-		error = PTR_ERR(dentry);
-	up(&parent->d_inode->i_sem);
-	return error;
+	return sysfs_add_file(kobj->dentry, &attr->attr, SYSFS_KOBJ_BIN_ATTR);
 }
 
 
@@ -199,5 +177,5 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(sysfs_create_bin_file);
-EXPORT_SYMBOL(sysfs_remove_bin_file);
+EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
+EXPORT_SYMBOL_GPL(sysfs_remove_bin_file);
diff -Nru a/fs/sysfs/dir.c b/fs/sysfs/dir.c
--- a/fs/sysfs/dir.c	2004-12-24 13:36:48 -08:00
+++ b/fs/sysfs/dir.c	2004-12-24 13:36:48 -08:00
@@ -12,32 +12,107 @@
 
 DECLARE_RWSEM(sysfs_rename_sem);
 
+static void sysfs_d_iput(struct dentry * dentry, struct inode * inode)
+{
+	struct sysfs_dirent * sd = dentry->d_fsdata;
+
+	if (sd) {
+		BUG_ON(sd->s_dentry != dentry);
+		sd->s_dentry = NULL;
+		sysfs_put(sd);
+	}
+	iput(inode);
+}
+
+static struct dentry_operations sysfs_dentry_ops = {
+	.d_iput		= sysfs_d_iput,
+};
+
+/*
+ * Allocates a new sysfs_dirent and links it to the parent sysfs_dirent
+ */
+static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd,
+						void * element)
+{
+	struct sysfs_dirent * sd;
+
+	sd = kmalloc(sizeof(*sd), GFP_KERNEL);
+	if (!sd)
+		return NULL;
+
+	memset(sd, 0, sizeof(*sd));
+	atomic_set(&sd->s_count, 1);
+	INIT_LIST_HEAD(&sd->s_children);
+	list_add(&sd->s_sibling, &parent_sd->s_children);
+	sd->s_element = element;
+
+	return sd;
+}
+
+int sysfs_make_dirent(struct sysfs_dirent * parent_sd, struct dentry * dentry,
+			void * element, umode_t mode, int type)
+{
+	struct sysfs_dirent * sd;
+
+	sd = sysfs_new_dirent(parent_sd, element);
+	if (!sd)
+		return -ENOMEM;
+
+	sd->s_mode = mode;
+	sd->s_type = type;
+	sd->s_dentry = dentry;
+	if (dentry) {
+		dentry->d_fsdata = sysfs_get(sd);
+		dentry->d_op = &sysfs_dentry_ops;
+	}
+
+	return 0;
+}
+
 static int init_dir(struct inode * inode)
 {
-	inode->i_op = &simple_dir_inode_operations;
-	inode->i_fop = &simple_dir_operations;
+	inode->i_op = &sysfs_dir_inode_operations;
+	inode->i_fop = &sysfs_dir_operations;
 
 	/* directory inodes start off with i_nlink == 2 (for "." entry) */
 	inode->i_nlink++;
 	return 0;
 }
 
+static int init_file(struct inode * inode)
+{
+	inode->i_size = PAGE_SIZE;
+	inode->i_fop = &sysfs_file_operations;
+	return 0;
+}
+
+static int init_symlink(struct inode * inode)
+{
+	inode->i_op = &sysfs_symlink_inode_operations;
+	return 0;
+}
 
 static int create_dir(struct kobject * k, struct dentry * p,
 		      const char * n, struct dentry ** d)
 {
 	int error;
+	umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
 
 	down(&p->d_inode->i_sem);
 	*d = sysfs_get_dentry(p,n);
 	if (!IS_ERR(*d)) {
-		error = sysfs_create(*d,
-					 S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO,
-					 init_dir);
+		error = sysfs_create(*d, mode, init_dir);
 		if (!error) {
-			(*d)->d_fsdata = k;
-			p->d_inode->i_nlink++;
+			error = sysfs_make_dirent(p->d_fsdata, *d, k, mode,
+						SYSFS_DIR);
+			if (!error) {
+				p->d_inode->i_nlink++;
+				(*d)->d_op = &sysfs_dentry_ops;
+				d_rehash(*d);
+			}
 		}
+		if (error && (error != -EEXIST))
+			d_drop(*d);
 		dput(*d);
 	} else
 		error = PTR_ERR(*d);
@@ -63,8 +138,7 @@
 	struct dentry * parent;
 	int error = 0;
 
-	if (!kobj)
-		return -EINVAL;
+	BUG_ON(!kobj);
 
 	if (kobj->parent)
 		parent = kobj->parent->dentry;
@@ -79,12 +153,93 @@
 	return error;
 }
 
+/* attaches attribute's sysfs_dirent to the dentry corresponding to the
+ * attribute file
+ */
+static int sysfs_attach_attr(struct sysfs_dirent * sd, struct dentry * dentry)
+{
+	struct attribute * attr = NULL;
+	struct bin_attribute * bin_attr = NULL;
+	int (* init) (struct inode *) = NULL;
+	int error = 0;
+
+        if (sd->s_type & SYSFS_KOBJ_BIN_ATTR) {
+                bin_attr = sd->s_element;
+                attr = &bin_attr->attr;
+        } else {
+                attr = sd->s_element;
+                init = init_file;
+        }
+
+	error = sysfs_create(dentry, (attr->mode & S_IALLUGO) | S_IFREG, init);
+	if (error)
+		return error;
+
+        if (bin_attr) {
+		dentry->d_inode->i_size = bin_attr->size;
+		dentry->d_inode->i_fop = &bin_fops;
+	}
+	dentry->d_op = &sysfs_dentry_ops;
+	dentry->d_fsdata = sysfs_get(sd);
+	sd->s_dentry = dentry;
+	d_rehash(dentry);
+
+	return 0;
+}
+
+static int sysfs_attach_link(struct sysfs_dirent * sd, struct dentry * dentry)
+{
+	int err = 0;
+
+	err = sysfs_create(dentry, S_IFLNK|S_IRWXUGO, init_symlink);
+	if (!err) {
+		dentry->d_op = &sysfs_dentry_ops;
+		dentry->d_fsdata = sysfs_get(sd);
+		sd->s_dentry = dentry;
+		d_rehash(dentry);
+	}
+	return err;
+}
+
+static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
+				struct nameidata *nd)
+{
+	struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata;
+	struct sysfs_dirent * sd;
+	int err = 0;
+
+	list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
+		if (sd->s_type & SYSFS_NOT_PINNED) {
+			const unsigned char * name = sysfs_get_name(sd);
+
+			if (strcmp(name, dentry->d_name.name))
+				continue;
+
+			if (sd->s_type & SYSFS_KOBJ_LINK)
+				err = sysfs_attach_link(sd, dentry);
+			else
+				err = sysfs_attach_attr(sd, dentry);
+			break;
+		}
+	}
+
+	return ERR_PTR(err);
+}
+
+struct inode_operations sysfs_dir_inode_operations = {
+	.lookup		= sysfs_lookup,
+};
 
 static void remove_dir(struct dentry * d)
 {
 	struct dentry * parent = dget(d->d_parent);
+	struct sysfs_dirent * sd;
+
 	down(&parent->d_inode->i_sem);
 	d_delete(d);
+	sd = d->d_fsdata;
+ 	list_del_init(&sd->s_sibling);
+	sysfs_put(sd);
 	if (d->d_inode)
 		simple_rmdir(parent->d_inode,d);
 
@@ -112,47 +267,23 @@
 
 void sysfs_remove_dir(struct kobject * kobj)
 {
-	struct list_head * node;
 	struct dentry * dentry = dget(kobj->dentry);
+	struct sysfs_dirent * parent_sd;
+	struct sysfs_dirent * sd, * tmp;
 
 	if (!dentry)
 		return;
 
 	pr_debug("sysfs %s: removing dir\n",dentry->d_name.name);
 	down(&dentry->d_inode->i_sem);
-
-	spin_lock(&dcache_lock);
-restart:
-	node = dentry->d_subdirs.next;
-	while (node != &dentry->d_subdirs) {
-		struct dentry * d = list_entry(node,struct dentry,d_child);
-
-		node = node->next;
-		pr_debug(" o %s (%d): ",d->d_name.name,atomic_read(&d->d_count));
-		if (!d_unhashed(d) && (d->d_inode)) {
-			d = dget_locked(d);
-			pr_debug("removing");
-
-			/**
-			 * Unlink and unhash.
-			 */
-			__d_drop(d);
-			spin_unlock(&dcache_lock);
-			/* release the target kobject in case of 
-			 * a symlink
-			 */
-			if (S_ISLNK(d->d_inode->i_mode))
-				kobject_put(d->d_fsdata);
-			
-			simple_unlink(dentry->d_inode,d);
-			dput(d);
-			pr_debug(" done\n");
-			spin_lock(&dcache_lock);
-			/* re-acquired dcache_lock, need to restart */
-			goto restart;
-		}
+	parent_sd = dentry->d_fsdata;
+	list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) {
+		if (!sd->s_element || !(sd->s_type & SYSFS_NOT_PINNED))
+			continue;
+		list_del_init(&sd->s_sibling);
+		sysfs_drop_dentry(sd, dentry);
+		sysfs_put(sd);
 	}
-	spin_unlock(&dcache_lock);
 	up(&dentry->d_inode->i_sem);
 
 	remove_dir(dentry);
@@ -181,10 +312,15 @@
 	new_dentry = sysfs_get_dentry(parent, new_name);
 	if (!IS_ERR(new_dentry)) {
   		if (!new_dentry->d_inode) {
-			error = kobject_set_name(kobj,new_name);
-			if (!error)
+			error = kobject_set_name(kobj, "%s", new_name);
+			if (!error) {
+				d_add(new_dentry, NULL);
 				d_move(kobj->dentry, new_dentry);
-		}
+			}
+			else
+				d_drop(new_dentry);
+		} else
+			error = -EEXIST;
 		dput(new_dentry);
 	}
 	up(&parent->d_inode->i_sem);	
@@ -193,7 +329,147 @@
 	return error;
 }
 
-EXPORT_SYMBOL(sysfs_create_dir);
-EXPORT_SYMBOL(sysfs_remove_dir);
-EXPORT_SYMBOL(sysfs_rename_dir);
+static int sysfs_dir_open(struct inode *inode, struct file *file)
+{
+	struct dentry * dentry = file->f_dentry;
+	struct sysfs_dirent * parent_sd = dentry->d_fsdata;
+
+	down(&dentry->d_inode->i_sem);
+	file->private_data = sysfs_new_dirent(parent_sd, NULL);
+	up(&dentry->d_inode->i_sem);
+
+	return file->private_data ? 0 : -ENOMEM;
+
+}
+
+static int sysfs_dir_close(struct inode *inode, struct file *file)
+{
+	struct dentry * dentry = file->f_dentry;
+	struct sysfs_dirent * cursor = file->private_data;
+
+	down(&dentry->d_inode->i_sem);
+	list_del_init(&cursor->s_sibling);
+	up(&dentry->d_inode->i_sem);
+
+	release_sysfs_dirent(cursor);
+
+	return 0;
+}
+
+/* Relationship between s_mode and the DT_xxx types */
+static inline unsigned char dt_type(struct sysfs_dirent *sd)
+{
+	return (sd->s_mode >> 12) & 15;
+}
+
+static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
+{
+	struct dentry *dentry = filp->f_dentry;
+	struct sysfs_dirent * parent_sd = dentry->d_fsdata;
+	struct sysfs_dirent *cursor = filp->private_data;
+	struct list_head *p, *q = &cursor->s_sibling;
+	ino_t ino;
+	int i = filp->f_pos;
+
+	switch (i) {
+		case 0:
+			ino = dentry->d_inode->i_ino;
+			if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
+				break;
+			filp->f_pos++;
+			i++;
+			/* fallthrough */
+		case 1:
+			ino = parent_ino(dentry);
+			if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)
+				break;
+			filp->f_pos++;
+			i++;
+			/* fallthrough */
+		default:
+			if (filp->f_pos == 2) {
+				list_del(q);
+				list_add(q, &parent_sd->s_children);
+			}
+			for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
+				struct sysfs_dirent *next;
+				const char * name;
+				int len;
+
+				next = list_entry(p, struct sysfs_dirent,
+						   s_sibling);
+				if (!next->s_element)
+					continue;
+
+				name = sysfs_get_name(next);
+				len = strlen(name);
+				if (next->s_dentry)
+					ino = next->s_dentry->d_inode->i_ino;
+				else
+					ino = iunique(sysfs_sb, 2);
+
+				if (filldir(dirent, name, len, filp->f_pos, ino,
+						 dt_type(next)) < 0)
+					return 0;
+
+				list_del(q);
+				list_add(q, p);
+				p = q;
+				filp->f_pos++;
+			}
+	}
+	return 0;
+}
+
+static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
+{
+	struct dentry * dentry = file->f_dentry;
+
+	down(&dentry->d_inode->i_sem);
+	switch (origin) {
+		case 1:
+			offset += file->f_pos;
+		case 0:
+			if (offset >= 0)
+				break;
+		default:
+			up(&file->f_dentry->d_inode->i_sem);
+			return -EINVAL;
+	}
+	if (offset != file->f_pos) {
+		file->f_pos = offset;
+		if (file->f_pos >= 2) {
+			struct sysfs_dirent *sd = dentry->d_fsdata;
+			struct sysfs_dirent *cursor = file->private_data;
+			struct list_head *p;
+			loff_t n = file->f_pos - 2;
+
+			list_del(&cursor->s_sibling);
+			p = sd->s_children.next;
+			while (n && p != &sd->s_children) {
+				struct sysfs_dirent *next;
+				next = list_entry(p, struct sysfs_dirent,
+						   s_sibling);
+				if (next->s_element)
+					n--;
+				p = p->next;
+			}
+			list_add_tail(&cursor->s_sibling, p);
+		}
+	}
+	up(&dentry->d_inode->i_sem);
+	return offset;
+}
+
+struct file_operations sysfs_dir_operations = {
+	.open		= sysfs_dir_open,
+	.release	= sysfs_dir_close,
+	.llseek		= sysfs_dir_lseek,
+	.read		= generic_read_dir,
+	.readdir	= sysfs_readdir,
+};
+
+EXPORT_SYMBOL_GPL(sysfs_create_dir);
+EXPORT_SYMBOL_GPL(sysfs_remove_dir);
+EXPORT_SYMBOL_GPL(sysfs_rename_dir);
 
diff -Nru a/fs/sysfs/file.c b/fs/sysfs/file.c
--- a/fs/sysfs/file.c	2004-12-24 13:36:17 -08:00
+++ b/fs/sysfs/file.c	2004-12-24 13:36:17 -08:00
@@ -6,18 +6,10 @@
 #include <linux/dnotify.h>
 #include <linux/kobject.h>
 #include <asm/uaccess.h>
+#include <asm/semaphore.h>
 
 #include "sysfs.h"
 
-static struct file_operations sysfs_file_operations;
-
-static int init_file(struct inode * inode)
-{
-	inode->i_size = PAGE_SIZE;
-	inode->i_fop = &sysfs_file_operations;
-	return 0;
-}
-
 #define to_subsys(k) container_of(k,struct subsystem,kset.kobj)
 #define to_sattr(a) container_of(a,struct subsys_attribute,attr)
 
@@ -62,12 +54,14 @@
 	loff_t			pos;
 	char			* page;
 	struct sysfs_ops	* ops;
+	struct semaphore	sem;
+	int			needs_read_fill;
 };
 
 
 /**
  *	fill_read_buffer - allocate and fill buffer from object.
- *	@file:		file pointer.
+ *	@dentry:	dentry pointer.
  *	@buffer:	data buffer for file.
  *
  *	Allocate @buffer->page, if it hasn't been already, then call the
@@ -75,10 +69,10 @@
  *	data. 
  *	This is called only once, on the file's first read. 
  */
-static int fill_read_buffer(struct file * file, struct sysfs_buffer * buffer)
+static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer)
 {
-	struct attribute * attr = file->f_dentry->d_fsdata;
-	struct kobject * kobj = file->f_dentry->d_parent->d_fsdata;
+	struct attribute * attr = to_attr(dentry);
+	struct kobject * kobj = to_kobj(dentry->d_parent);
 	struct sysfs_ops * ops = buffer->ops;
 	int ret = 0;
 	ssize_t count;
@@ -89,6 +83,7 @@
 		return -ENOMEM;
 
 	count = ops->show(kobj,attr,buffer->page);
+	buffer->needs_read_fill = 0;
 	BUG_ON(count > (ssize_t)PAGE_SIZE);
 	if (count >= 0)
 		buffer->count = count;
@@ -115,6 +110,9 @@
 {
 	int error;
 
+	if (*ppos > buffer->count)
+		return 0;
+
 	if (count > (buffer->count - *ppos))
 		count = buffer->count - *ppos;
 
@@ -149,13 +147,17 @@
 	struct sysfs_buffer * buffer = file->private_data;
 	ssize_t retval = 0;
 
-	if (!*ppos) {
-		if ((retval = fill_read_buffer(file,buffer)))
-			return retval;
+	down(&buffer->sem);
+	if (buffer->needs_read_fill) {
+		if ((retval = fill_read_buffer(file->f_dentry,buffer)))
+			goto out;
 	}
 	pr_debug("%s: count = %d, ppos = %lld, buf = %s\n",
 		 __FUNCTION__,count,*ppos,buffer->page);
-	return flush_read_buffer(buffer,buf,count,ppos);
+	retval = flush_read_buffer(buffer,buf,count,ppos);
+out:
+	up(&buffer->sem);
+	return retval;
 }
 
 
@@ -182,6 +184,7 @@
 	if (count >= PAGE_SIZE)
 		count = PAGE_SIZE - 1;
 	error = copy_from_user(buffer->page,buf,count);
+	buffer->needs_read_fill = 1;
 	return error ? -EFAULT : count;
 }
 
@@ -197,10 +200,10 @@
  */
 
 static int 
-flush_write_buffer(struct file * file, struct sysfs_buffer * buffer, size_t count)
+flush_write_buffer(struct dentry * dentry, struct sysfs_buffer * buffer, size_t count)
 {
-	struct attribute * attr = file->f_dentry->d_fsdata;
-	struct kobject * kobj = file->f_dentry->d_parent->d_fsdata;
+	struct attribute * attr = to_attr(dentry);
+	struct kobject * kobj = to_kobj(dentry->d_parent);
 	struct sysfs_ops * ops = buffer->ops;
 
 	return ops->store(kobj,attr,buffer->page,count);
@@ -229,18 +232,20 @@
 {
 	struct sysfs_buffer * buffer = file->private_data;
 
+	down(&buffer->sem);
 	count = fill_write_buffer(buffer,buf,count);
 	if (count > 0)
-		count = flush_write_buffer(file,buffer,count);
+		count = flush_write_buffer(file->f_dentry,buffer,count);
 	if (count > 0)
 		*ppos += count;
+	up(&buffer->sem);
 	return count;
 }
 
 static int check_perm(struct inode * inode, struct file * file)
 {
 	struct kobject *kobj = sysfs_get_kobject(file->f_dentry->d_parent);
-	struct attribute * attr = file->f_dentry->d_fsdata;
+	struct attribute * attr = to_attr(file->f_dentry);
 	struct sysfs_buffer * buffer;
 	struct sysfs_ops * ops = NULL;
 	int error = 0;
@@ -296,6 +301,8 @@
 	buffer = kmalloc(sizeof(struct sysfs_buffer),GFP_KERNEL);
 	if (buffer) {
 		memset(buffer,0,sizeof(struct sysfs_buffer));
+		init_MUTEX(&buffer->sem);
+		buffer->needs_read_fill = 1;
 		buffer->ops = ops;
 		file->private_data = buffer;
 	} else
@@ -321,13 +328,15 @@
 
 static int sysfs_release(struct inode * inode, struct file * filp)
 {
-	struct kobject * kobj = filp->f_dentry->d_parent->d_fsdata;
-	struct attribute * attr = filp->f_dentry->d_fsdata;
+	struct kobject * kobj = to_kobj(filp->f_dentry->d_parent);
+	struct attribute * attr = to_attr(filp->f_dentry);
+	struct module * owner = attr->owner;
 	struct sysfs_buffer * buffer = filp->private_data;
 
 	if (kobj) 
 		kobject_put(kobj);
-	module_put(attr->owner);
+	/* After this point, attr should not be accessed. */
+	module_put(owner);
 
 	if (buffer) {
 		if (buffer->page)
@@ -337,7 +346,7 @@
 	return 0;
 }
 
-static struct file_operations sysfs_file_operations = {
+struct file_operations sysfs_file_operations = {
 	.read		= sysfs_read_file,
 	.write		= sysfs_write_file,
 	.llseek		= generic_file_llseek,
@@ -346,23 +355,16 @@
 };
 
 
-int sysfs_add_file(struct dentry * dir, const struct attribute * attr)
+int sysfs_add_file(struct dentry * dir, const struct attribute * attr, int type)
 {
-	struct dentry * dentry;
-	int error;
+	struct sysfs_dirent * parent_sd = dir->d_fsdata;
+	umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG;
+	int error = 0;
 
 	down(&dir->d_inode->i_sem);
-	dentry = sysfs_get_dentry(dir,attr->name);
-	if (!IS_ERR(dentry)) {
-		error = sysfs_create(dentry,
-				     (attr->mode & S_IALLUGO) | S_IFREG,
-				     init_file);
-		if (!error)
-			dentry->d_fsdata = (void *)attr;
-		dput(dentry);
-	} else
-		error = PTR_ERR(dentry);
+	error = sysfs_make_dirent(parent_sd, NULL, (void *) attr, mode, type);
 	up(&dir->d_inode->i_sem);
+
 	return error;
 }
 
@@ -375,9 +377,10 @@
 
 int sysfs_create_file(struct kobject * kobj, const struct attribute * attr)
 {
-	if (kobj && attr)
-		return sysfs_add_file(kobj->dentry,attr);
-	return -EINVAL;
+	BUG_ON(!kobj || !kobj->dentry || !attr);
+
+	return sysfs_add_file(kobj->dentry, attr, SYSFS_KOBJ_ATTR);
+
 }
 
 
@@ -409,7 +412,8 @@
 			 */
 			dput(victim);
 			res = 0;
-		}
+		} else
+			d_drop(victim);
 		
 		/**
 		 * Drop the reference acquired from sysfs_get_dentry() above.
@@ -436,7 +440,7 @@
 }
 
 
-EXPORT_SYMBOL(sysfs_create_file);
-EXPORT_SYMBOL(sysfs_remove_file);
-EXPORT_SYMBOL(sysfs_update_file);
+EXPORT_SYMBOL_GPL(sysfs_create_file);
+EXPORT_SYMBOL_GPL(sysfs_remove_file);
+EXPORT_SYMBOL_GPL(sysfs_update_file);
 
diff -Nru a/fs/sysfs/group.c b/fs/sysfs/group.c
--- a/fs/sysfs/group.c	2004-12-24 13:36:56 -08:00
+++ b/fs/sysfs/group.c	2004-12-24 13:36:56 -08:00
@@ -31,7 +31,7 @@
 	int error = 0;
 
 	for (attr = grp->attrs; *attr && !error; attr++) {
-		error = sysfs_add_file(dir,*attr);
+		error = sysfs_add_file(dir, *attr, SYSFS_KOBJ_ATTR);
 	}
 	if (error)
 		remove_files(dir,grp);
@@ -45,6 +45,8 @@
 	struct dentry * dir;
 	int error;
 
+	BUG_ON(!kobj || !kobj->dentry);
+
 	if (grp->name) {
 		error = sysfs_create_subdir(kobj,grp->name,&dir);
 		if (error)
@@ -78,5 +80,5 @@
 }
 
 
-EXPORT_SYMBOL(sysfs_create_group);
-EXPORT_SYMBOL(sysfs_remove_group);
+EXPORT_SYMBOL_GPL(sysfs_create_group);
+EXPORT_SYMBOL_GPL(sysfs_remove_group);
diff -Nru a/fs/sysfs/inode.c b/fs/sysfs/inode.c
--- a/fs/sysfs/inode.c	2004-12-24 13:37:18 -08:00
+++ b/fs/sysfs/inode.c	2004-12-24 13:37:18 -08:00
@@ -11,6 +11,8 @@
 #include <linux/pagemap.h>
 #include <linux/namei.h>
 #include <linux/backing-dev.h>
+#include "sysfs.h"
+
 extern struct super_block * sysfs_sb;
 
 static struct address_space_operations sysfs_aops = {
@@ -29,8 +31,8 @@
 	struct inode * inode = new_inode(sysfs_sb);
 	if (inode) {
 		inode->i_mode = mode;
-		inode->i_uid = current->fsuid;
-		inode->i_gid = current->fsgid;
+		inode->i_uid = 0;
+		inode->i_gid = 0;
 		inode->i_blksize = PAGE_CACHE_SIZE;
 		inode->i_blocks = 0;
 		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
@@ -66,18 +68,14 @@
 		error = init(inode);
 	if (!error) {
 		d_instantiate(dentry, inode);
-		dget(dentry); /* Extra count - pin the dentry in core */
+		if (S_ISDIR(mode))
+			dget(dentry);  /* pin only directory dentry in core */
 	} else
 		iput(inode);
  Done:
 	return error;
 }
 
-int sysfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
-{
-	return sysfs_create(dentry, mode, NULL);
-}
-
 struct dentry * sysfs_get_dentry(struct dentry * parent, const char * name)
 {
 	struct qstr qstr;
@@ -88,31 +86,74 @@
 	return lookup_hash(&qstr,parent);
 }
 
+/*
+ * Get the name for corresponding element represented by the given sysfs_dirent
+ */
+const unsigned char * sysfs_get_name(struct sysfs_dirent *sd)
+{
+	struct attribute * attr;
+	struct bin_attribute * bin_attr;
+	struct sysfs_symlink  * sl;
+
+	if (!sd || !sd->s_element)
+		BUG();
+
+	switch (sd->s_type) {
+		case SYSFS_DIR:
+			/* Always have a dentry so use that */
+			return sd->s_dentry->d_name.name;
+
+		case SYSFS_KOBJ_ATTR:
+			attr = sd->s_element;
+			return attr->name;
+
+		case SYSFS_KOBJ_BIN_ATTR:
+			bin_attr = sd->s_element;
+			return bin_attr->attr.name;
+
+		case SYSFS_KOBJ_LINK:
+			sl = sd->s_element;
+			return sl->link_name;
+	}
+	return NULL;
+}
+
+
+/*
+ * Unhashes the dentry corresponding to given sysfs_dirent
+ * Called with parent inode's i_sem held.
+ */
+void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
+{
+	struct dentry * dentry = sd->s_dentry;
+
+	if (dentry) {
+		spin_lock(&dcache_lock);
+		if (!(d_unhashed(dentry) && dentry->d_inode)) {
+			dget_locked(dentry);
+			__d_drop(dentry);
+			spin_unlock(&dcache_lock);
+			simple_unlink(parent->d_inode, dentry);
+		} else
+			spin_unlock(&dcache_lock);
+	}
+}
+
 void sysfs_hash_and_remove(struct dentry * dir, const char * name)
 {
-	struct dentry * victim;
+	struct sysfs_dirent * sd;
+	struct sysfs_dirent * parent_sd = dir->d_fsdata;
 
 	down(&dir->d_inode->i_sem);
-	victim = sysfs_get_dentry(dir,name);
-	if (!IS_ERR(victim)) {
-		/* make sure dentry is really there */
-		if (victim->d_inode && 
-		    (victim->d_parent->d_inode == dir->d_inode)) {
-			pr_debug("sysfs: Removing %s (%d)\n", victim->d_name.name,
-				 atomic_read(&victim->d_count));
-
-			d_drop(victim);
-			/* release the target kobject in case of 
-			 * a symlink
-			 */
-			if (S_ISLNK(victim->d_inode->i_mode))
-				kobject_put(victim->d_fsdata);
-			simple_unlink(dir->d_inode,victim);
+	list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
+		if (!sd->s_element)
+			continue;
+		if (!strcmp(sysfs_get_name(sd), name)) {
+			list_del_init(&sd->s_sibling);
+			sysfs_drop_dentry(sd, dir);
+			sysfs_put(sd);
+			break;
 		}
-		/*
-		 * Drop reference from sysfs_get_dentry() above.
-		 */
-		dput(victim);
 	}
 	up(&dir->d_inode->i_sem);
 }
diff -Nru a/fs/sysfs/mount.c b/fs/sysfs/mount.c
--- a/fs/sysfs/mount.c	2004-12-24 13:37:18 -08:00
+++ b/fs/sysfs/mount.c	2004-12-24 13:37:18 -08:00
@@ -22,6 +22,13 @@
 	.drop_inode	= generic_delete_inode,
 };
 
+static struct sysfs_dirent sysfs_root = {
+	.s_sibling	= LIST_HEAD_INIT(sysfs_root.s_sibling),
+	.s_children	= LIST_HEAD_INIT(sysfs_root.s_children),
+	.s_element	= NULL,
+	.s_type		= SYSFS_ROOT,
+};
+
 static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct inode *inode;
@@ -35,8 +42,8 @@
 
 	inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO);
 	if (inode) {
-		inode->i_op = &simple_dir_inode_operations;
-		inode->i_fop = &simple_dir_operations;
+		inode->i_op = &sysfs_dir_inode_operations;
+		inode->i_fop = &sysfs_dir_operations;
 		/* directory inodes start off with i_nlink == 2 (for "." entry) */
 		inode->i_nlink++;	
 	} else {
@@ -50,6 +57,7 @@
 		iput(inode);
 		return -ENOMEM;
 	}
+	root->d_fsdata = &sysfs_root;
 	sb->s_root = root;
 	return 0;
 }
diff -Nru a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
--- a/fs/sysfs/symlink.c	2004-12-24 13:36:48 -08:00
+++ b/fs/sysfs/symlink.c	2004-12-24 13:36:48 -08:00
@@ -9,18 +9,6 @@
 
 #include "sysfs.h"
 
-static struct inode_operations sysfs_symlink_inode_operations = {
-	.readlink = generic_readlink,
-	.follow_link = sysfs_follow_link,
-	.put_link = sysfs_put_link,
-};
-
-static int init_symlink(struct inode * inode)
-{
-	inode->i_op = &sysfs_symlink_inode_operations;
-	return 0;
-}
-
 static int object_depth(struct kobject * kobj)
 {
 	struct kobject * p = kobj;
@@ -55,6 +43,36 @@
 	}
 }
 
+static int sysfs_add_link(struct dentry * parent, char * name, struct kobject * target)
+{
+	struct sysfs_dirent * parent_sd = parent->d_fsdata;
+	struct sysfs_symlink * sl;
+	int error = 0;
+
+	error = -ENOMEM;
+	sl = kmalloc(sizeof(*sl), GFP_KERNEL);
+	if (!sl)
+		goto exit1;
+
+	sl->link_name = kmalloc(strlen(name) + 1, GFP_KERNEL);
+	if (!sl->link_name)
+		goto exit2;
+
+	strcpy(sl->link_name, name);
+	sl->target_kobj = kobject_get(target);
+
+	error = sysfs_make_dirent(parent_sd, NULL, sl, S_IFLNK|S_IRWXUGO,
+				SYSFS_KOBJ_LINK);
+	if (!error)
+		return 0;
+
+	kfree(sl->link_name);
+exit2:
+	kfree(sl);
+exit1:
+	return error;
+}
+
 /**
  *	sysfs_create_link - create symlink between two objects.
  *	@kobj:	object whose directory we're creating the link in.
@@ -64,21 +82,12 @@
 int sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name)
 {
 	struct dentry * dentry = kobj->dentry;
-	struct dentry * d;
 	int error = 0;
 
+	BUG_ON(!kobj || !kobj->dentry || !name);
+
 	down(&dentry->d_inode->i_sem);
-	d = sysfs_get_dentry(dentry,name);
-	if (!IS_ERR(d)) {
-		error = sysfs_create(d, S_IFLNK|S_IRWXUGO, init_symlink);
-		if (!error)
-			/* 
-			 * associate the link dentry with the target kobject 
-			 */
-			d->d_fsdata = kobject_get(target);
-		dput(d);
-	} else 
-		error = PTR_ERR(d);
+	error = sysfs_add_link(dentry, name, target);
 	up(&dentry->d_inode->i_sem);
 	return error;
 }
@@ -142,7 +151,7 @@
 
 }
 
-int sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
+static int sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
 	int error = -ENOMEM;
 	unsigned long page = get_zeroed_page(GFP_KERNEL);
@@ -152,13 +161,20 @@
 	return 0;
 }
 
-void sysfs_put_link(struct dentry *dentry, struct nameidata *nd)
+static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd)
 {
 	char *page = nd_get_link(nd);
 	if (!IS_ERR(page))
 		free_page((unsigned long)page);
 }
 
-EXPORT_SYMBOL(sysfs_create_link);
-EXPORT_SYMBOL(sysfs_remove_link);
+struct inode_operations sysfs_symlink_inode_operations = {
+	.readlink = generic_readlink,
+	.follow_link = sysfs_follow_link,
+	.put_link = sysfs_put_link,
+};
+
+
+EXPORT_SYMBOL_GPL(sysfs_create_link);
+EXPORT_SYMBOL_GPL(sysfs_remove_link);
 
diff -Nru a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
--- a/fs/sysfs/sysfs.h	2004-12-24 13:37:18 -08:00
+++ b/fs/sysfs/sysfs.h	2004-12-24 13:37:18 -08:00
@@ -4,26 +4,91 @@
 extern struct inode * sysfs_new_inode(mode_t mode);
 extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
 
+extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
+				umode_t, int);
 extern struct dentry * sysfs_get_dentry(struct dentry *, const char *);
 
-extern int sysfs_add_file(struct dentry * dir, const struct attribute * attr);
+extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
 extern void sysfs_hash_and_remove(struct dentry * dir, const char * name);
 
 extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
 extern void sysfs_remove_subdir(struct dentry *);
 
-extern int sysfs_follow_link(struct dentry *, struct nameidata *);
-extern void sysfs_put_link(struct dentry *, struct nameidata *);
+extern const unsigned char * sysfs_get_name(struct sysfs_dirent *sd);
+extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent);
+
 extern struct rw_semaphore sysfs_rename_sem;
+extern struct super_block * sysfs_sb;
+extern struct file_operations sysfs_dir_operations;
+extern struct file_operations sysfs_file_operations;
+extern struct file_operations bin_fops;
+extern struct inode_operations sysfs_dir_inode_operations;
+extern struct inode_operations sysfs_symlink_inode_operations;
+
+struct sysfs_symlink {
+	char * link_name;
+	struct kobject * target_kobj;
+};
+
+static inline struct kobject * to_kobj(struct dentry * dentry)
+{
+	struct sysfs_dirent * sd = dentry->d_fsdata;
+	return ((struct kobject *) sd->s_element);
+}
+
+static inline struct attribute * to_attr(struct dentry * dentry)
+{
+	struct sysfs_dirent * sd = dentry->d_fsdata;
+	return ((struct attribute *) sd->s_element);
+}
+
+static inline struct bin_attribute * to_bin_attr(struct dentry * dentry)
+{
+	struct sysfs_dirent * sd = dentry->d_fsdata;
+	return ((struct bin_attribute *) sd->s_element);
+}
 
 static inline struct kobject *sysfs_get_kobject(struct dentry *dentry)
 {
 	struct kobject * kobj = NULL;
 
 	spin_lock(&dcache_lock);
-	if (!d_unhashed(dentry))
-		kobj = kobject_get(dentry->d_fsdata);
+	if (!d_unhashed(dentry)) {
+		struct sysfs_dirent * sd = dentry->d_fsdata;
+		if (sd->s_type & SYSFS_KOBJ_LINK) {
+			struct sysfs_symlink * sl = sd->s_element;
+			kobj = kobject_get(sl->target_kobj);
+		} else
+			kobj = kobject_get(sd->s_element);
+	}
 	spin_unlock(&dcache_lock);
 
 	return kobj;
 }
+
+static inline void release_sysfs_dirent(struct sysfs_dirent * sd)
+{
+	if (sd->s_type & SYSFS_KOBJ_LINK) {
+		struct sysfs_symlink * sl = sd->s_element;
+		kfree(sl->link_name);
+		kobject_put(sl->target_kobj);
+		kfree(sl);
+	}
+	kfree(sd);
+}
+
+static inline struct sysfs_dirent * sysfs_get(struct sysfs_dirent * sd)
+{
+	if (sd) {
+		WARN_ON(!atomic_read(&sd->s_count));
+		atomic_inc(&sd->s_count);
+	}
+	return sd;
+}
+
+static inline void sysfs_put(struct sysfs_dirent * sd)
+{
+	if (atomic_dec_and_test(&sd->s_count))
+		release_sysfs_dirent(sd);
+}
+
diff -Nru a/fs/sysv/CHANGES b/fs/sysv/CHANGES
--- a/fs/sysv/CHANGES	2004-12-24 13:36:17 -08:00
+++ b/fs/sysv/CHANGES	2004-12-24 13:36:17 -08:00
@@ -19,7 +19,7 @@
 	*    namei.c: removed static subdir(); is_subdir() from dcache.c
 		      is used instead. Cosmetic changes.
 
-Thu, 3 Dec 1998   Al Viro (viro@math.psu.edu)
+Thu, 3 Dec 1998   Al Viro (viro@parcelfarce.linux.theplanet.co.uk)
 	*    namei.c (sysv_rmdir):
 		      Bugectomy: old check for victim being busy
 		      (inode->i_count) wasn't replaced (with checking
diff -Nru a/fs/sysv/ChangeLog b/fs/sysv/ChangeLog
--- a/fs/sysv/ChangeLog	2004-12-24 13:36:17 -08:00
+++ b/fs/sysv/ChangeLog	2004-12-24 13:36:17 -08:00
@@ -4,7 +4,7 @@
 	  waitfor_one_page() for IS_SYNC directories, so that we
 	  actually do sync the directory. (forward-port from 2.4).
 
-Thu Feb  7 2002  Alexander Viro  <viro@math.psu.edu>
+Thu Feb  7 2002  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
 
 	* super.c: switched to ->get_sb()
 	* ChangeLog: fixed dates ;-)
@@ -13,7 +13,7 @@
 
 	* inode.c: Include linux/init.h
 
-Mon Jan 21 2002  Alexander Viro  <viro@math.psu.edu>
+Mon Jan 21 2002  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
 	* ialloc.c (sysv_new_inode): zero SYSV_I(inode)->i_data out.
 	* i_vnode renamed to vfs_inode.  Sorry, but let's keep that
 	  consistent.
@@ -43,7 +43,7 @@
 	* symlink.c (sysv_readlink): Likewise.
 	(sysv_follow_link): Likewise.
 
-Fri Jan  4 2002  Alexander Viro  <viro@math.psu.edu>
+Fri Jan  4 2002  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
 
 	* ialloc.c (sysv_free_inode): Use sb->s_id instead of bdevname().
 	* inode.c (sysv_read_inode): Likewise.
@@ -59,16 +59,16 @@
 	* dir.c (dir_commit_chunk): Do not set dir->i_version.
 	(sysv_readdir): Likewise.
 
-Thu Dec 27 2001  Alexander Viro  <viro@math.psu.edu>
+Thu Dec 27 2001  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
 
 	* itree.c (get_block): Use map_bh() to fill out bh_result.
 
-Tue Dec 25 2001  Alexander Viro  <viro@math.psu.edu>
+Tue Dec 25 2001  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
 
 	* super.c (sysv_read_super): Use sb_set_blocksize() to set blocksize.
 	  (v7_read_super): Likewise.
 
-Tue Nov 27 2001  Alexander Viro  <viro@math.psu.edu>
+Tue Nov 27 2001  Alexander Viro  <viro@parcelfarce.linux.theplanet.co.uk>
 
 	* itree.c (get_block): Change type for iblock argument to sector_t.
 	* super.c (sysv_read_super): Set s_blocksize early.
diff -Nru a/fs/udf/balloc.c b/fs/udf/balloc.c
--- a/fs/udf/balloc.c	2004-12-24 13:36:32 -08:00
+++ b/fs/udf/balloc.c	2004-12-24 13:36:32 -08:00
@@ -28,7 +28,7 @@
 
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 #include "udf_i.h"
 #include "udf_sb.h"
diff -Nru a/fs/udf/file.c b/fs/udf/file.c
--- a/fs/udf/file.c	2004-12-24 13:37:00 -08:00
+++ b/fs/udf/file.c	2004-12-24 13:37:00 -08:00
@@ -254,30 +254,10 @@
 	return 0;
 }
 
-/*
- * udf_open_file
- *
- * PURPOSE
- *  Called when an inode is about to be open.
- *
- * DESCRIPTION
- *  Use this to disallow opening RW large files on 32 bit systems.
- *  On 64 bit systems we force on O_LARGEFILE in sys_open.
- *
- * HISTORY
- *
- */
-static int udf_open_file(struct inode * inode, struct file * filp)
-{
-	if ((inode->i_size & 0xFFFFFFFF80000000ULL) && !(filp->f_flags & O_LARGEFILE))
-		return -EFBIG;
-	return 0;
-}
-
 struct file_operations udf_file_operations = {
 	.read			= generic_file_read,
 	.ioctl			= udf_ioctl,
-	.open			= udf_open_file,
+	.open			= generic_file_open,
 	.mmap			= generic_file_mmap,
 	.write			= udf_file_write,
 	.release		= udf_release_file,
diff -Nru a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c
--- a/fs/udf/lowlevel.c	2004-12-24 13:37:00 -08:00
+++ b/fs/udf/lowlevel.c	2004-12-24 13:37:00 -08:00
@@ -27,12 +27,6 @@
 #include <linux/blkdev.h>
 #include <linux/cdrom.h>
 #include <asm/uaccess.h>
-#include <scsi/scsi.h>
-
-typedef struct scsi_device Scsi_Device;
-typedef struct scsi_cmnd   Scsi_Cmnd;
-
-#include <scsi/scsi_ioctl.h>
 
 #include <linux/udf_fs.h>
 #include "udf_sb.h"
diff -Nru a/fs/ufs/balloc.c b/fs/ufs/balloc.c
--- a/fs/ufs/balloc.c	2004-12-24 13:37:00 -08:00
+++ b/fs/ufs/balloc.c	2004-12-24 13:37:00 -08:00
@@ -14,7 +14,7 @@
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
 #include <linux/sched.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/byteorder.h>
 
 #include "swab.h"
diff -Nru a/fs/ufs/cylinder.c b/fs/ufs/cylinder.c
--- a/fs/ufs/cylinder.c	2004-12-24 13:37:04 -08:00
+++ b/fs/ufs/cylinder.c	2004-12-24 13:37:04 -08:00
@@ -13,8 +13,8 @@
 #include <linux/time.h>
 #include <linux/stat.h>
 #include <linux/string.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
 
 #include "swab.h"
diff -Nru a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
--- a/fs/ufs/ialloc.c	2004-12-24 13:37:19 -08:00
+++ b/fs/ufs/ialloc.c	2004-12-24 13:37:19 -08:00
@@ -28,7 +28,7 @@
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
 #include <linux/sched.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/byteorder.h>
 
 #include "swab.h"
diff -Nru a/fs/ufs/inode.c b/fs/ufs/inode.c
--- a/fs/ufs/inode.c	2004-12-24 13:36:30 -08:00
+++ b/fs/ufs/inode.c	2004-12-24 13:36:30 -08:00
@@ -629,7 +629,7 @@
 		}
 	} else
 		init_special_inode(inode, inode->i_mode,
-			old_decode_dev(fs32_to_cpu(sb, ufsi->i_u1.i_data[0])));
+			ufs_get_inode_dev(sb, ufsi));
 
 	brelse (bh);
 
@@ -705,7 +705,7 @@
 		}
 	} else   /* TODO  : here ...*/
 		init_special_inode(inode, inode->i_mode,
-			old_decode_dev(fs32_to_cpu(sb, ufsi->i_u1.i_data[0])));
+			ufs_get_inode_dev(sb, ufsi));
 
 	brelse(bh);
 
diff -Nru a/fs/ufs/namei.c b/fs/ufs/namei.c
--- a/fs/ufs/namei.c	2004-12-24 13:37:33 -08:00
+++ b/fs/ufs/namei.c	2004-12-24 13:37:33 -08:00
@@ -30,6 +30,7 @@
 #include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
 #include "swab.h"	/* will go away - see comment in mknod() */
+#include "util.h"
 
 /*
 #undef UFS_NAMEI_DEBUG
@@ -125,8 +126,7 @@
 	if (!IS_ERR(inode)) {
 		init_special_inode(inode, mode, rdev);
 		/* NOTE: that'll go when we get wide dev_t */
-		UFS_I(inode)->i_u1.i_data[0] = cpu_to_fs32(inode->i_sb,
-							old_encode_dev(rdev));
+		ufs_set_inode_dev(inode->i_sb, UFS_I(inode), rdev);
 		mark_inode_dirty(inode);
 		lock_kernel();
 		err = ufs_add_nondir(dentry, inode);
diff -Nru a/fs/ufs/super.c b/fs/ufs/super.c
--- a/fs/ufs/super.c	2004-12-24 13:36:16 -08:00
+++ b/fs/ufs/super.c	2004-12-24 13:36:16 -08:00
@@ -66,10 +66,10 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/bitops.h>
 
 #include <stdarg.h>
 
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
diff -Nru a/fs/ufs/util.c b/fs/ufs/util.c
--- a/fs/ufs/util.c	2004-12-24 13:36:48 -08:00
+++ b/fs/ufs/util.c	2004-12-24 13:36:48 -08:00
@@ -202,3 +202,56 @@
 		bhno++;
 	}
 }
+
+dev_t
+ufs_get_inode_dev(struct super_block *sb, struct ufs_inode_info *ufsi)
+{
+	__fs32 fs32;
+	dev_t dev;
+
+	if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86)
+		fs32 = ufsi->i_u1.i_data[1];
+	else
+		fs32 = ufsi->i_u1.i_data[0];
+	fs32 = fs32_to_cpu(sb, fs32);
+	switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
+	case UFS_ST_SUNx86:
+	case UFS_ST_SUN:
+		if ((fs32 & 0xffff0000) == 0 ||
+		    (fs32 & 0xffff0000) == 0xffff0000)
+			dev = old_decode_dev(fs32 & 0x7fff);
+		else
+			dev = MKDEV(sysv_major(fs32), sysv_minor(fs32));
+		break;
+
+	default:
+		dev = old_decode_dev(fs32);
+		break;
+	}
+	return dev;
+}
+
+void
+ufs_set_inode_dev(struct super_block *sb, struct ufs_inode_info *ufsi, dev_t dev)
+{
+	__fs32 fs32;
+
+	switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
+	case UFS_ST_SUNx86:
+	case UFS_ST_SUN:
+		fs32 = sysv_encode_dev(dev);
+		if ((fs32 & 0xffff8000) == 0) {
+			fs32 = old_encode_dev(dev);
+		}
+		break;
+
+	default:
+		fs32 = old_encode_dev(dev);
+		break;
+	}
+	fs32 = cpu_to_fs32(sb, fs32);
+	if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86)
+		ufsi->i_u1.i_data[1] = fs32;
+	else
+		ufsi->i_u1.i_data[0] = fs32;
+}
diff -Nru a/fs/ufs/util.h b/fs/ufs/util.h
--- a/fs/ufs/util.h	2004-12-24 13:36:55 -08:00
+++ b/fs/ufs/util.h	2004-12-24 13:36:55 -08:00
@@ -223,6 +223,8 @@
 	inode->ui_u1.oldids.ui_sgid =  cpu_to_fs16(sb, value);
 }
 
+extern dev_t ufs_get_inode_dev(struct super_block *, struct ufs_inode_info *);
+extern void ufs_set_inode_dev(struct super_block *, struct ufs_inode_info *, dev_t);
 
 /*
  * These functions manipulate ufs buffers
diff -Nru a/fs/xattr.c b/fs/xattr.c
--- a/fs/xattr.c	2004-12-24 13:36:48 -08:00
+++ b/fs/xattr.c	2004-12-24 13:36:48 -08:00
@@ -5,6 +5,7 @@
 
   Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
   Copyright (C) 2001 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
+  Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
  */
 #include <linux/fs.h>
 #include <linux/slab.h>
@@ -13,6 +14,8 @@
 #include <linux/xattr.h>
 #include <linux/namei.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
+#include <linux/module.h>
 #include <asm/uaccess.h>
 
 /*
@@ -347,3 +350,131 @@
 	fput(f);
 	return error;
 }
+
+
+static const char *
+strcmp_prefix(const char *a, const char *a_prefix)
+{
+	while (*a_prefix && *a == *a_prefix) {
+		a++;
+		a_prefix++;
+	}
+	return *a_prefix ? NULL : a;
+}
+
+/*
+ * In order to implement different sets of xattr operations for each xattr
+ * prefix with the generic xattr API, a filesystem should create a
+ * null-terminated array of struct xattr_handler (one for each prefix) and
+ * hang a pointer to it off of the s_xattr field of the superblock.
+ *
+ * The generic_fooxattr() functions will use this list to dispatch xattr
+ * operations to the correct xattr_handler.
+ */
+#define for_each_xattr_handler(handlers, handler)		\
+		for ((handler) = *(handlers)++;			\
+			(handler) != NULL;			\
+			(handler) = *(handlers)++)
+
+/*
+ * Find the xattr_handler with the matching prefix.
+ */
+static struct xattr_handler *
+xattr_resolve_name(struct xattr_handler **handlers, const char **name)
+{
+	struct xattr_handler *handler;
+
+	if (!*name)
+		return NULL;
+
+	for_each_xattr_handler(handlers, handler) {
+		const char *n = strcmp_prefix(*name, handler->prefix);
+		if (n) {
+			*name = n;
+			break;
+		}
+	}
+	return handler;
+}
+
+/*
+ * Find the handler for the prefix and dispatch its get() operation.
+ */
+ssize_t
+generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size)
+{
+	struct xattr_handler *handler;
+	struct inode *inode = dentry->d_inode;
+
+	handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
+	if (!handler)
+		return -EOPNOTSUPP;
+	return handler->get(inode, name, buffer, size);
+}
+
+/*
+ * Combine the results of the list() operation from every xattr_handler in the
+ * list.
+ */
+ssize_t
+generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
+{
+	struct inode *inode = dentry->d_inode;
+	struct xattr_handler *handler, **handlers = inode->i_sb->s_xattr;
+	unsigned int size = 0;
+
+	if (!buffer) {
+		for_each_xattr_handler(handlers, handler)
+			size += handler->list(inode, NULL, 0, NULL, 0);
+	} else {
+		char *buf = buffer;
+
+		for_each_xattr_handler(handlers, handler) {
+			size = handler->list(inode, buf, buffer_size, NULL, 0);
+			if (size > buffer_size)
+				return -ERANGE;
+			buf += size;
+			buffer_size -= size;
+		}
+		size = buf - buffer;
+	}
+	return size;
+}
+
+/*
+ * Find the handler for the prefix and dispatch its set() operation.
+ */
+int
+generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
+{
+	struct xattr_handler *handler;
+	struct inode *inode = dentry->d_inode;
+
+	if (size == 0)
+		value = "";  /* empty EA, do not remove */
+	handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
+	if (!handler)
+		return -EOPNOTSUPP;
+	return handler->set(inode, name, value, size, flags);
+}
+
+/*
+ * Find the handler for the prefix and dispatch its set() operation to remove
+ * any associated extended attribute.
+ */
+int
+generic_removexattr(struct dentry *dentry, const char *name)
+{
+	struct xattr_handler *handler;
+	struct inode *inode = dentry->d_inode;
+
+	handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
+	if (!handler)
+		return -EOPNOTSUPP;
+	return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
+}
+
+EXPORT_SYMBOL(generic_getxattr);
+EXPORT_SYMBOL(generic_listxattr);
+EXPORT_SYMBOL(generic_setxattr);
+EXPORT_SYMBOL(generic_removexattr);
diff -Nru a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
--- a/fs/xfs/linux-2.6/kmem.c	2004-12-24 13:36:55 -08:00
+++ b/fs/xfs/linux-2.6/kmem.c	2004-12-24 13:36:55 -08:00
@@ -35,6 +35,7 @@
 #include <linux/vmalloc.h>
 #include <linux/highmem.h>
 #include <linux/swap.h>
+#include <linux/blkdev.h>
 
 #include "time.h"
 #include "kmem.h"
@@ -46,7 +47,8 @@
 void *
 kmem_alloc(size_t size, int flags)
 {
-	int	retries = 0, lflags = kmem_flags_convert(flags);
+	int	retries = 0;
+	int	lflags = kmem_flags_convert(flags);
 	void	*ptr;
 
 	do {
@@ -57,8 +59,10 @@
 		if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
 			return ptr;
 		if (!(++retries % 100))
-			printk(KERN_ERR "possible deadlock in %s (mode:0x%x)\n",
+			printk(KERN_ERR "XFS: possible memory allocation "
+					"deadlock in %s (mode:0x%x)\n",
 					__FUNCTION__, lflags);
+		blk_congestion_wait(WRITE, HZ/50);
 	} while (1);
 }
 
@@ -102,7 +106,8 @@
 void *
 kmem_zone_alloc(kmem_zone_t *zone, int flags)
 {
-	int	retries = 0, lflags = kmem_flags_convert(flags);
+	int	retries = 0;
+	int	lflags = kmem_flags_convert(flags);
 	void	*ptr;
 
 	do {
@@ -110,8 +115,10 @@
 		if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
 			return ptr;
 		if (!(++retries % 100))
-			printk(KERN_ERR "possible deadlock in %s (mode:0x%x)\n",
+			printk(KERN_ERR "XFS: possible memory allocation "
+					"deadlock in %s (mode:0x%x)\n",
 					__FUNCTION__, lflags);
+		blk_congestion_wait(WRITE, HZ/50);
 	} while (1);
 }
 
diff -Nru a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
--- a/fs/xfs/linux-2.6/kmem.h	2004-12-24 13:37:43 -08:00
+++ b/fs/xfs/linux-2.6/kmem.h	2004-12-24 13:37:43 -08:00
@@ -83,7 +83,7 @@
 
 static __inline unsigned int kmem_flags_convert(int flags)
 {
-	int lflags;
+	int	lflags = __GFP_NOWARN;	/* we'll report problems, if need be */
 
 #ifdef DEBUG
 	if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
diff -Nru a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
--- a/fs/xfs/linux-2.6/xfs_buf.c	2004-12-24 13:36:17 -08:00
+++ b/fs/xfs/linux-2.6/xfs_buf.c	2004-12-24 13:36:17 -08:00
@@ -53,13 +53,10 @@
 #include <linux/workqueue.h>
 #include <linux/suspend.h>
 #include <linux/percpu.h>
+#include <linux/blkdev.h>
 
 #include "xfs_linux.h"
 
-#ifndef GFP_READAHEAD
-#define GFP_READAHEAD	(__GFP_NOWARN|__GFP_NORETRY)
-#endif
-
 /*
  * File wide globals
  */
@@ -118,8 +115,8 @@
  */
 
 #define pb_to_gfp(flags) \
-	(((flags) & PBF_READ_AHEAD) ? GFP_READAHEAD : \
-	 ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL)
+	((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \
+	  ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN)
 
 #define pb_to_km(flags) \
 	 (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP)
@@ -387,13 +384,13 @@
 			 */
 			if (!(++retries % 100))
 				printk(KERN_ERR
-					"possible deadlock in %s (mode:0x%x)\n",
+					"XFS: possible memory allocation "
+					"deadlock in %s (mode:0x%x)\n",
 					__FUNCTION__, gfp_mask);
 
 			XFS_STATS_INC(pb_page_retries);
 			pagebuf_daemon_wakeup(0, gfp_mask);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(10);
+			blk_congestion_wait(WRITE, HZ/50);
 			goto retry;
 		}
 
@@ -486,7 +483,7 @@
  *	which may imply that this call will block until those buffers
  *	are unlocked.  No I/O is implied by this call.
  */
-STATIC xfs_buf_t *
+xfs_buf_t *
 _pagebuf_find(				/* find buffer for block	*/
 	xfs_buftarg_t		*target,/* target for block		*/
 	loff_t			ioff,	/* starting offset of range	*/
@@ -578,39 +575,14 @@
 	return (pb);
 }
 
-
-/*
- *	pagebuf_find
- *
- *	pagebuf_find returns a buffer matching the specified range of
- *	data for the specified target, if any of the relevant blocks
- *	are in memory.  The buffer may have unallocated holes, if
- *	some, but not all, of the blocks are in memory.  Even where
- *	pages are present in the buffer, not all of every page may be
- *	valid.
- */
-xfs_buf_t *
-pagebuf_find(				/* find buffer for block	*/
-					/* if the block is in memory	*/
-	xfs_buftarg_t		*target,/* target for block		*/
-	loff_t			ioff,	/* starting offset of range	*/
-	size_t			isize,	/* length of range		*/
-	page_buf_flags_t	flags)	/* PBF_TRYLOCK			*/
-{
-	return _pagebuf_find(target, ioff, isize, flags, NULL);
-}
-
 /*
- *	pagebuf_get
+ *	xfs_buf_get_flags assembles a buffer covering the specified range.
  *
- *	pagebuf_get assembles a buffer covering the specified range.
- *	Some or all of the blocks in the range may be valid.  Storage
- *	in memory for all portions of the buffer will be allocated,
- *	although backing storage may not be.  If PBF_READ is set in
- *	flags, pagebuf_iostart is called also.
+ *	Storage in memory for all portions of the buffer will be allocated,
+ *	although backing storage may not be.
  */
 xfs_buf_t *
-pagebuf_get(				/* allocate a buffer		*/
+xfs_buf_get_flags(			/* allocate a buffer		*/
 	xfs_buftarg_t		*target,/* target for buffer		*/
 	loff_t			ioff,	/* starting offset of range	*/
 	size_t			isize,	/* length of range		*/
@@ -640,8 +612,8 @@
 	if (!(pb->pb_flags & PBF_MAPPED)) {
 		error = _pagebuf_map_pages(pb, flags);
 		if (unlikely(error)) {
-			printk(KERN_WARNING
-			       "pagebuf_get: failed to map pages\n");
+			printk(KERN_WARNING "%s: failed to map pages\n",
+					__FUNCTION__);
 			goto no_buffer;
 		}
 	}
@@ -655,30 +627,50 @@
 	pb->pb_bn = ioff;
 	pb->pb_count_desired = pb->pb_buffer_length;
 
-	if (flags & PBF_READ) {
+	PB_TRACE(pb, "get", (unsigned long)flags);
+	return pb;
+
+ no_buffer:
+	if (flags & (PBF_LOCK | PBF_TRYLOCK))
+		pagebuf_unlock(pb);
+	pagebuf_rele(pb);
+	return NULL;
+}
+
+xfs_buf_t *
+xfs_buf_read_flags(
+	xfs_buftarg_t		*target,
+	loff_t			ioff,
+	size_t			isize,
+	page_buf_flags_t	flags)
+{
+	xfs_buf_t		*pb;
+
+	flags |= PBF_READ;
+
+	pb = xfs_buf_get_flags(target, ioff, isize, flags);
+	if (pb) {
 		if (PBF_NOT_DONE(pb)) {
-			PB_TRACE(pb, "get_read", (unsigned long)flags);
+			PB_TRACE(pb, "read", (unsigned long)flags);
 			XFS_STATS_INC(pb_get_read);
 			pagebuf_iostart(pb, flags);
 		} else if (flags & PBF_ASYNC) {
-			PB_TRACE(pb, "get_read_async", (unsigned long)flags);
+			PB_TRACE(pb, "read_async", (unsigned long)flags);
 			/*
 			 * Read ahead call which is already satisfied,
 			 * drop the buffer
 			 */
 			goto no_buffer;
 		} else {
-			PB_TRACE(pb, "get_read_done", (unsigned long)flags);
+			PB_TRACE(pb, "read_done", (unsigned long)flags);
 			/* We do not want read in the flags */
 			pb->pb_flags &= ~PBF_READ;
 		}
-	} else {
-		PB_TRACE(pb, "get_write", (unsigned long)flags);
 	}
 
 	return pb;
 
-no_buffer:
+ no_buffer:
 	if (flags & (PBF_LOCK | PBF_TRYLOCK))
 		pagebuf_unlock(pb);
 	pagebuf_rele(pb);
@@ -723,8 +715,8 @@
 	if (bdi_write_congested(bdi))
 		return;
 
-	flags |= (PBF_TRYLOCK|PBF_READ|PBF_ASYNC|PBF_READ_AHEAD);
-	pagebuf_get(target, ioff, isize, flags);
+	flags |= (PBF_TRYLOCK|PBF_ASYNC|PBF_READ_AHEAD);
+	xfs_buf_read_flags(target, ioff, isize, flags);
 }
 
 xfs_buf_t *
@@ -1084,7 +1076,7 @@
  *	done with respect to that I/O.	The pb_iodone routine, if
  *	present, will be called as a side-effect.
  */
-void
+STATIC void
 pagebuf_iodone_work(
 	void			*v)
 {
@@ -1263,7 +1255,7 @@
 	return 0;
 }
 
-void
+STATIC void
 _pagebuf_ioapply(
 	xfs_buf_t		*pb)
 {
@@ -1472,6 +1464,34 @@
 /*
  *	Handling of buftargs.
  */
+
+/*
+ * Wait for any bufs with callbacks that have been submitted but
+ * have not yet returned... walk the hash list for the target.
+ */
+void
+xfs_wait_buftarg(
+	xfs_buftarg_t *target)
+{
+	xfs_buf_t	*pb, *n;
+	pb_hash_t	*h;
+	int		i;
+
+	for (i = 0; i < NHASH; i++) {
+		h = &pbhash[i];
+again:
+		spin_lock(&h->pb_hash_lock);
+		list_for_each_entry_safe(pb, n, &h->pb_hash, pb_hash_list) {
+			if (pb->pb_target == target &&
+					!(pb->pb_flags & PBF_FS_MANAGED)) {
+				spin_unlock(&h->pb_hash_lock);
+				delay(100);
+				goto again;
+			}
+		}
+		spin_unlock(&h->pb_hash_lock);
+	}
+}
 
 void
 xfs_free_buftarg(
diff -Nru a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
--- a/fs/xfs/linux-2.6/xfs_buf.h	2004-12-24 13:37:00 -08:00
+++ b/fs/xfs/linux-2.6/xfs_buf.h	2004-12-24 13:37:00 -08:00
@@ -168,20 +168,36 @@
 
 /* Finding and Reading Buffers */
 
-extern xfs_buf_t *pagebuf_find(	/* find buffer for block if	*/
+extern xfs_buf_t *_pagebuf_find(	/* find buffer for block if	*/
 					/* the block is in memory	*/
 		xfs_buftarg_t *,	/* inode for block		*/
 		loff_t,			/* starting offset of range	*/
 		size_t,			/* length of range		*/
-		page_buf_flags_t);	/* PBF_LOCK			*/
+		page_buf_flags_t,	/* PBF_LOCK			*/
+	        xfs_buf_t *);		/* newly allocated buffer	*/
 
-extern xfs_buf_t *pagebuf_get(		/* allocate a buffer		*/
+#define xfs_incore(buftarg,blkno,len,lockit) \
+	_pagebuf_find(buftarg, blkno ,len, lockit, NULL)
+
+extern xfs_buf_t *xfs_buf_get_flags(	/* allocate a buffer		*/
 		xfs_buftarg_t *,	/* inode for buffer		*/
 		loff_t,			/* starting offset of range     */
 		size_t,			/* length of range              */
 		page_buf_flags_t);	/* PBF_LOCK, PBF_READ,		*/
 					/* PBF_ASYNC			*/
 
+#define xfs_buf_get(target, blkno, len, flags) \
+	xfs_buf_get_flags((target), (blkno), (len), PBF_LOCK | PBF_MAPPED)
+
+extern xfs_buf_t *xfs_buf_read_flags(	/* allocate and read a buffer	*/
+		xfs_buftarg_t *,	/* inode for buffer		*/
+		loff_t,			/* starting offset of range	*/
+		size_t,			/* length of range		*/
+		page_buf_flags_t);	/* PBF_LOCK, PBF_ASYNC		*/
+
+#define xfs_buf_read(target, blkno, len, flags) \
+	xfs_buf_read_flags((target), (blkno), (len), PBF_LOCK | PBF_MAPPED)
+
 extern xfs_buf_t *pagebuf_lookup(
 		xfs_buftarg_t *,
 		loff_t,			/* starting offset of range	*/
@@ -472,18 +488,6 @@
 #define XFS_BUF_SET_VTYPE(bp, type)
 #define XFS_BUF_SET_REF(bp, ref)
 
-#define xfs_buf_read(target, blkno, len, flags) \
-		pagebuf_get((target), (blkno), (len), \
-			PBF_LOCK | PBF_READ | PBF_MAPPED)
-#define xfs_buf_get(target, blkno, len, flags) \
-		pagebuf_get((target), (blkno), (len), \
-			PBF_LOCK | PBF_MAPPED)
-
-#define xfs_buf_read_flags(target, blkno, len, flags) \
-		pagebuf_get((target), (blkno), (len), PBF_READ | (flags))
-#define xfs_buf_get_flags(target, blkno, len, flags) \
-		pagebuf_get((target), (blkno), (len), (flags))
-
 static inline int	xfs_bawrite(void *mp, xfs_buf_t *bp)
 {
 	bp->pb_fspriv3 = mp;
@@ -508,10 +512,6 @@
 #define xfs_biodone(pb)		    \
 	    pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0)
 
-#define xfs_incore(buftarg,blkno,len,lockit) \
-	    pagebuf_find(buftarg, blkno ,len, lockit)
-
-
 #define xfs_biomove(pb, off, len, data, rw) \
 	    pagebuf_iomove((pb), (off), (len), (data), \
 		((rw) == XFS_B_WRITE) ? PBRW_WRITE : PBRW_READ)
@@ -566,6 +566,7 @@
 
 extern xfs_buftarg_t *xfs_alloc_buftarg(struct block_device *);
 extern void xfs_free_buftarg(xfs_buftarg_t *, int);
+extern void xfs_wait_buftarg(xfs_buftarg_t *);
 extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int);
 extern void xfs_incore_relse(xfs_buftarg_t *, int, int);
 extern int xfs_flush_buftarg(xfs_buftarg_t *, int);
diff -Nru a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
--- a/fs/xfs/linux-2.6/xfs_file.c	2004-12-24 13:36:55 -08:00
+++ b/fs/xfs/linux-2.6/xfs_file.c	2004-12-24 13:36:55 -08:00
@@ -398,7 +398,7 @@
 	vattr_t		va = { .va_mask = XFS_AT_UPDATIME };
 	int		error;
 
-	if ((vp->v_type == VREG) && (vp->v_vfsp->vfs_flag & VFS_DMI)) {
+	if (vp->v_vfsp->vfs_flag & VFS_DMI) {
 		xfs_mount_t	*mp = XFS_VFSTOM(vp->v_vfsp);
 
 		error = -XFS_SEND_MMAP(mp, vma, 0);
@@ -473,7 +473,7 @@
 	vnode_t		*vp = LINVFS_GET_VP(vma->vm_file->f_dentry->d_inode);
 	int		error = 0;
 
-	if ((vp->v_type == VREG) && (vp->v_vfsp->vfs_flag & VFS_DMI)) {
+	if (vp->v_vfsp->vfs_flag & VFS_DMI) {
 		if ((vma->vm_flags & VM_MAYSHARE) &&
 		    (newflags & VM_WRITE) && !(vma->vm_flags & VM_WRITE)) {
 			xfs_mount_t	*mp = XFS_VFSTOM(vp->v_vfsp);
diff -Nru a/fs/xfs/linux-2.6/xfs_globals.c b/fs/xfs/linux-2.6/xfs_globals.c
--- a/fs/xfs/linux-2.6/xfs_globals.c	2004-12-24 13:37:00 -08:00
+++ b/fs/xfs/linux-2.6/xfs_globals.c	2004-12-24 13:37:00 -08:00
@@ -64,6 +64,7 @@
 	.xfs_buf_timer	= {	100/2,		1*100,		30*100	},
 	.xfs_buf_age	= {	1*100,		15*100,		7200*100},
 	.inherit_nosym	= {	0,		0,		1	},
+	.rotorstep	= {	1,		1,		255	},
 };
 
 /*
diff -Nru a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
--- a/fs/xfs/linux-2.6/xfs_ioctl.c	2004-12-24 13:37:43 -08:00
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c	2004-12-24 13:37:44 -08:00
@@ -270,7 +270,7 @@
 	/*
 	 * Get the XFS inode, building a vnode to go with it.
 	 */
-	error = xfs_iget(mp, NULL, ino, XFS_ILOCK_SHARED, &ip, 0);
+	error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0);
 	if (error)
 		return error;
 	if (ip == NULL)
diff -Nru a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
--- a/fs/xfs/linux-2.6/xfs_linux.h	2004-12-24 13:36:16 -08:00
+++ b/fs/xfs/linux-2.6/xfs_linux.h	2004-12-24 13:36:16 -08:00
@@ -142,6 +142,7 @@
 #define xfs_buf_timer_centisecs	xfs_params.xfs_buf_timer.val
 #define xfs_buf_age_centisecs	xfs_params.xfs_buf_age.val
 #define xfs_inherit_nosymlinks	xfs_params.inherit_nosym.val
+#define xfs_rotorstep		xfs_params.rotorstep.val
 
 #define current_cpu()		smp_processor_id()
 #define current_pid()		(current->pid)
diff -Nru a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
--- a/fs/xfs/linux-2.6/xfs_lrw.c	2004-12-24 13:36:16 -08:00
+++ b/fs/xfs/linux-2.6/xfs_lrw.c	2004-12-24 13:36:16 -08:00
@@ -244,6 +244,7 @@
 	cred_t			*credp)
 {
 	struct file		*file = iocb->ki_filp;
+	struct inode		*inode = file->f_mapping->host;
 	size_t			size = 0;
 	ssize_t			ret;
 	xfs_fsize_t		n;
@@ -272,7 +273,7 @@
 	}
 	/* END copy & waste from filemap.c */
 
-	if (ioflags & IO_ISDIRECT) {
+	if (unlikely(ioflags & IO_ISDIRECT)) {
 		xfs_buftarg_t	*target =
 			(ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
 				mp->m_rtdev_targp : mp->m_ddev_targp;
@@ -296,18 +297,20 @@
 		return -EIO;
 	}
 
+	if (unlikely(ioflags & IO_ISDIRECT))
+		down(&inode->i_sem);
 	xfs_ilock(ip, XFS_IOLOCK_SHARED);
 
 	if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
 	    !(ioflags & IO_INVIS)) {
 		vrwlock_t locktype = VRWLOCK_READ;
 
-		ret = XFS_SEND_DATA(mp, DM_EVENT_READ,
+		ret = -XFS_SEND_DATA(mp, DM_EVENT_READ,
 					BHV_TO_VNODE(bdp), *offset, size,
 					FILP_DELAY_FLAG(file), &locktype);
 		if (ret) {
 			xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-			return -ret;
+			goto unlock_isem;
 		}
 	}
 
@@ -316,15 +319,17 @@
 	ret = __generic_file_aio_read(iocb, iovp, segs, offset);
 	if (ret == -EIOCBQUEUED)
 		ret = wait_on_sync_kiocb(iocb);
-
-	xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-
 	if (ret > 0)
 		XFS_STATS_ADD(xs_read_bytes, ret);
 
+	xfs_iunlock(ip, XFS_IOLOCK_SHARED);
+
 	if (likely(!(ioflags & IO_INVIS)))
 		xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
 
+unlock_isem:
+	if (unlikely(ioflags & IO_ISDIRECT))
+		up(&inode->i_sem);
 	return ret;
 }
 
diff -Nru a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
--- a/fs/xfs/linux-2.6/xfs_super.c	2004-12-24 13:37:19 -08:00
+++ b/fs/xfs/linux-2.6/xfs_super.c	2004-12-24 13:37:19 -08:00
@@ -234,6 +234,10 @@
 		vp->v_type = IFTOVT(ip->i_d.di_mode);
 		xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
 		xfs_set_inodeops(inode);
+	
+		ip->i_flags &= ~XFS_INEW;
+		barrier();
+
 		unlock_new_inode(inode);
 	}
 }
@@ -284,7 +288,7 @@
 	kmem_cache_free(linvfs_inode_zone, LINVFS_GET_VP(inode));
 }
 
-int
+STATIC int
 xfs_inode_shake(
 	int		priority,
 	unsigned int	gfp_mask)
diff -Nru a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c
--- a/fs/xfs/linux-2.6/xfs_sysctl.c	2004-12-24 13:37:43 -08:00
+++ b/fs/xfs/linux-2.6/xfs_sysctl.c	2004-12-24 13:37:43 -08:00
@@ -134,6 +134,11 @@
 	&sysctl_intvec, NULL,
 	&xfs_params.inherit_nosym.min, &xfs_params.inherit_nosym.max},
 
+	{XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val,
+	sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+	&sysctl_intvec, NULL, 
+	&xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
+
 	/* please keep this the last entry */
 #ifdef CONFIG_PROC_FS
 	{XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
diff -Nru a/fs/xfs/linux-2.6/xfs_sysctl.h b/fs/xfs/linux-2.6/xfs_sysctl.h
--- a/fs/xfs/linux-2.6/xfs_sysctl.h	2004-12-24 13:36:16 -08:00
+++ b/fs/xfs/linux-2.6/xfs_sysctl.h	2004-12-24 13:36:16 -08:00
@@ -60,6 +60,7 @@
 	xfs_sysctl_val_t xfs_buf_timer;	/* Interval between xfsbufd wakeups. */
 	xfs_sysctl_val_t xfs_buf_age;	/* Metadata buffer age before flush. */
 	xfs_sysctl_val_t inherit_nosym;	/* Inherit the "nosymlinks" flag. */
+	xfs_sysctl_val_t rotorstep;	/* inode32 AG rotoring control knob */
 } xfs_param_t;
 
 /*
@@ -97,6 +98,7 @@
 	XFS_BUF_AGE = 17,
 	/* XFS_IO_BYPASS = 18 */
 	XFS_INHERIT_NOSYM = 19,
+	XFS_ROTORSTEP = 20,
 };
 
 extern xfs_param_t	xfs_params;
diff -Nru a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
--- a/fs/xfs/quota/xfs_qm.c	2004-12-24 13:36:17 -08:00
+++ b/fs/xfs/quota/xfs_qm.c	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -85,7 +85,6 @@
 
 STATIC void	xfs_qm_list_init(xfs_dqlist_t *, char *, int);
 STATIC void	xfs_qm_list_destroy(xfs_dqlist_t *);
-STATIC int	xfs_qm_quotacheck(xfs_mount_t *);
 
 STATIC int	xfs_qm_init_quotainos(xfs_mount_t *);
 STATIC int	xfs_qm_shake(int, unsigned int);
@@ -349,7 +348,8 @@
  */
 int
 xfs_qm_mount_quotas(
-	xfs_mount_t	*mp)
+	xfs_mount_t	*mp,
+	int		mfsi_flags)
 {
 	unsigned long	s;
 	int		error = 0;
@@ -398,22 +398,16 @@
 	/*
 	 * If any of the quotas are not consistent, do a quotacheck.
 	 */
-	if (XFS_QM_NEED_QUOTACHECK(mp)) {
+	if (XFS_QM_NEED_QUOTACHECK(mp) &&
+		!(mfsi_flags & XFS_MFSI_NO_QUOTACHECK)) {
 #ifdef DEBUG
 		cmn_err(CE_NOTE, "Doing a quotacheck. Please wait.");
 #endif
 		if ((error = xfs_qm_quotacheck(mp))) {
-			cmn_err(CE_WARN, "Quotacheck unsuccessful (Error %d): "
-				"Disabling quotas.",
-				error);
-			/*
-			 * We must turn off quotas.
+			/* Quotacheck has failed and quotas have
+			 * been disabled.
 			 */
-			ASSERT(mp->m_quotainfo != NULL);
-			ASSERT(xfs_Gqm != NULL);
-			xfs_qm_destroy_quotainfo(mp);
-			mp->m_qflags = 0;
-			goto write_changes;
+			return XFS_ERROR(error);
 		}
 #ifdef DEBUG
 		cmn_err(CE_NOTE, "Done quotacheck.");
@@ -1788,7 +1782,7 @@
 	 * the case in all other instances. It's OK that we do this because
 	 * quotacheck is done only at mount time.
 	 */
-	if ((error = xfs_iget(mp, NULL, ino, XFS_ILOCK_EXCL, &ip, bno))) {
+	if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) {
 		*res = BULKSTAT_RV_NOTHING;
 		return (error);
 	}
@@ -1875,9 +1869,9 @@
 
 /*
  * Walk thru all the filesystem inodes and construct a consistent view
- * of the disk quota world.
+ * of the disk quota world. If the quotacheck fails, disable quotas.
  */
-STATIC int
+int
 xfs_qm_quotacheck(
 	xfs_mount_t	*mp)
 {
@@ -1973,7 +1967,20 @@
 	XQM_LIST_PRINT(&(XFS_QI_MPL_LIST(mp)), MPL_NEXT, "++++ Mp list +++");
 
  error_return:
-	cmn_err(CE_NOTE, "XFS quotacheck %s: Done.", mp->m_fsname);
+	if (error) {
+		cmn_err(CE_WARN, "XFS quotacheck %s: Unsuccessful (Error %d): "
+			"Disabling quotas.",
+			mp->m_fsname, error);
+		/*
+		 * We must turn off quotas.
+		 */
+		ASSERT(mp->m_quotainfo != NULL);
+		ASSERT(xfs_Gqm != NULL);
+		xfs_qm_destroy_quotainfo(mp);
+		xfs_mount_reset_sbqflags(mp);
+	} else {
+		cmn_err(CE_NOTE, "XFS quotacheck %s: Done.", mp->m_fsname);
+	}
 	return (error);
 }
 
@@ -2003,14 +2010,14 @@
 		    mp->m_sb.sb_uquotino != NULLFSINO) {
 			ASSERT(mp->m_sb.sb_uquotino > 0);
 			if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
-					     0, &uip, 0)))
+					     0, 0, &uip, 0)))
 				return XFS_ERROR(error);
 		}
 		if (XFS_IS_GQUOTA_ON(mp) &&
 		    mp->m_sb.sb_gquotino != NULLFSINO) {
 			ASSERT(mp->m_sb.sb_gquotino > 0);
 			if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
-					     0, &gip, 0))) {
+					     0, 0, &gip, 0))) {
 				if (uip)
 					VN_RELE(XFS_ITOV(uip));
 				return XFS_ERROR(error);
diff -Nru a/fs/xfs/quota/xfs_qm.h b/fs/xfs/quota/xfs_qm.h
--- a/fs/xfs/quota/xfs_qm.h	2004-12-24 13:36:32 -08:00
+++ b/fs/xfs/quota/xfs_qm.h	2004-12-24 13:36:32 -08:00
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -182,10 +182,13 @@
 #define XFS_QM_HOLD(xqm)	((xqm)->qm_nrefs++)
 #define XFS_QM_RELE(xqm)	((xqm)->qm_nrefs--)
 
+extern void		xfs_mount_reset_sbqflags(xfs_mount_t *);
+
 extern int		xfs_qm_init_quotainfo(xfs_mount_t *);
 extern void		xfs_qm_destroy_quotainfo(xfs_mount_t *);
-extern int		xfs_qm_mount_quotas(xfs_mount_t *);
+extern int		xfs_qm_mount_quotas(xfs_mount_t *, int);
 extern void		xfs_qm_mount_quotainit(xfs_mount_t *, uint);
+extern int		xfs_qm_quotacheck(xfs_mount_t *);
 extern void		xfs_qm_unmount_quotadestroy(xfs_mount_t *);
 extern int		xfs_qm_unmount_quotas(xfs_mount_t *);
 extern int		xfs_qm_write_sb_changes(xfs_mount_t *, __int64_t);
diff -Nru a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c
--- a/fs/xfs/quota/xfs_qm_bhv.c	2004-12-24 13:36:17 -08:00
+++ b/fs/xfs/quota/xfs_qm_bhv.c	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -207,10 +207,9 @@
 }
 
 /*
- * When xfsquotas isn't installed and the superblock had quotas, we need to
- * clear the quotaflags from superblock.
+ * Clear the quotaflags in memory and in the superblock.
  */
-STATIC void
+void
 xfs_mount_reset_sbqflags(
 	xfs_mount_t		*mp)
 {
@@ -241,6 +240,8 @@
 	if (xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
 				      XFS_DEFAULT_LOG_COUNT)) {
 		xfs_trans_cancel(tp, 0);
+		xfs_fs_cmn_err(CE_ALERT, mp,
+			"xfs_mount_reset_sbqflags: Superblock update failed!");
 		return;
 	}
 	xfs_mod_sb(tp, XFS_SB_QFLAGS);
@@ -294,15 +295,12 @@
 		 */
 		if (quotaondisk && !XFS_QM_NEED_QUOTACHECK(mp)) {
 			/*
-			 * If the xfs quota code isn't installed,
-			 * we have to reset the quotachk'd bit.
 			 * If an error occured, qm_mount_quotas code
 			 * has already disabled quotas. So, just finish
 			 * mounting, and get on with the boring life
 			 * without disk quotas.
 			 */
-			if (xfs_qm_mount_quotas(mp))
-				xfs_mount_reset_sbqflags(mp);
+			xfs_qm_mount_quotas(mp, 0);
 		} else {
 			/*
 			 * Clear the quota flags, but remember them. This
@@ -324,13 +322,13 @@
 xfs_qm_endmount(
 	xfs_mount_t	*mp,
 	uint		needquotamount,
-	uint		quotaflags)
+	uint		quotaflags,
+	int		mfsi_flags)
 {
 	if (needquotamount) {
 		ASSERT(mp->m_qflags == 0);
 		mp->m_qflags = quotaflags;
-		if (xfs_qm_mount_quotas(mp))
-			xfs_mount_reset_sbqflags(mp);
+		xfs_qm_mount_quotas(mp, mfsi_flags);
 	}
 
 #if defined(DEBUG) && defined(XFS_LOUD_RECOVERY)
diff -Nru a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
--- a/fs/xfs/quota/xfs_qm_syscalls.c	2004-12-24 13:37:01 -08:00
+++ b/fs/xfs/quota/xfs_qm_syscalls.c	2004-12-24 13:37:01 -08:00
@@ -404,7 +404,7 @@
 	}
 
 	if ((flags & XFS_DQ_USER) && mp->m_sb.sb_uquotino != NULLFSINO) {
-		error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, &qip, 0);
+		error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, 0, &qip, 0);
 		if (! error) {
 			(void) xfs_truncate_file(mp, qip);
 			VN_RELE(XFS_ITOV(qip));
@@ -412,7 +412,7 @@
 	}
 
 	if ((flags & XFS_DQ_GROUP) && mp->m_sb.sb_gquotino != NULLFSINO) {
-		error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, &qip, 0);
+		error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip, 0);
 		if (! error) {
 			(void) xfs_truncate_file(mp, qip);
 			VN_RELE(XFS_ITOV(qip));
@@ -555,11 +555,13 @@
 		gip = mp->m_quotainfo->qi_gquotaip;
 	}
 	if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) {
-		if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, &uip, 0) == 0)
+		if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
+					0, 0, &uip, 0) == 0)
 			tempuqip = B_TRUE;
 	}
 	if (!gip && mp->m_sb.sb_gquotino != NULLFSINO) {
-		if (xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, &gip, 0) == 0)
+		if (xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
+					0, 0, &gip, 0) == 0)
 			tempgqip = B_TRUE;
 	}
 	if (uip) {
@@ -1338,7 +1340,7 @@
 	ipreleased = B_FALSE;
  again:
 	lock_flags = XFS_ILOCK_SHARED;
-	if ((error = xfs_iget(mp, NULL, ino, lock_flags, &ip, bno))) {
+	if ((error = xfs_iget(mp, NULL, ino, 0, lock_flags, &ip, bno))) {
 		*res = BULKSTAT_RV_NOTHING;
 		return (error);
 	}
diff -Nru a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
--- a/fs/xfs/xfs_alloc.c	2004-12-24 13:36:31 -08:00
+++ b/fs/xfs/xfs_alloc.c	2004-12-24 13:36:31 -08:00
@@ -2247,6 +2247,7 @@
 	xfs_alloctype_t	type;	/* input allocation type */
 	int		bump_rotor = 0;
 	int		no_min = 0;
+	xfs_agnumber_t	rotorstep = xfs_rotorstep; /* inode32 agf stepper */
 
 	mp = args->mp;
 	type = args->otype = args->type;
@@ -2310,7 +2311,9 @@
 		 */
 		if ((args->userdata  == XFS_ALLOC_INITIAL_USER_DATA) &&
 		    (mp->m_flags & XFS_MOUNT_32BITINODES)) {
-			args->fsbno = XFS_AGB_TO_FSB(mp, mp->m_agfrotor, 0);
+			args->fsbno = XFS_AGB_TO_FSB(mp,
+					((mp->m_agfrotor / rotorstep) %
+					mp->m_sb.sb_agcount), 0);
 			bump_rotor = 1;
 		}
 		args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno);
@@ -2326,7 +2329,8 @@
 			/*
 			 * Start with the last place we left off.
 			 */
-			args->agno = sagno = mp->m_agfrotor;
+			args->agno = sagno = (mp->m_agfrotor / rotorstep) %
+					mp->m_sb.sb_agcount;
 			args->type = XFS_ALLOCTYPE_THIS_AG;
 			flags = XFS_ALLOC_FLAG_TRYLOCK;
 		} else if (type == XFS_ALLOCTYPE_FIRST_AG) {
@@ -2400,8 +2404,14 @@
 			}
 		}
 		up_read(&mp->m_peraglock);
-		if (bump_rotor || (type == XFS_ALLOCTYPE_ANY_AG))
-			mp->m_agfrotor = (args->agno + 1) % mp->m_sb.sb_agcount;
+		if (bump_rotor || (type == XFS_ALLOCTYPE_ANY_AG)) {
+			if (args->agno == sagno)
+				mp->m_agfrotor = (mp->m_agfrotor + 1) %
+					(mp->m_sb.sb_agcount * rotorstep);
+			else
+				mp->m_agfrotor = (args->agno * rotorstep + 1) %
+					(mp->m_sb.sb_agcount * rotorstep);
+		}
 		break;
 	default:
 		ASSERT(0);
diff -Nru a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
--- a/fs/xfs/xfs_iget.c	2004-12-24 13:37:29 -08:00
+++ b/fs/xfs/xfs_iget.c	2004-12-24 13:37:29 -08:00
@@ -169,6 +169,7 @@
 	xfs_mount_t	*mp,
 	xfs_trans_t	*tp,
 	xfs_ino_t	ino,
+	uint		flags,
 	uint		lock_flags,
 	xfs_inode_t	**ipp,
 	xfs_daddr_t	bno)
@@ -180,7 +181,6 @@
 	ulong		version;
 	int		error;
 	/* REFERENCED */
-	int		newnode;
 	xfs_chash_t	*ch;
 	xfs_chashlist_t	*chl, *chlnew;
 	SPLDECL(s);
@@ -193,11 +193,22 @@
 
 	for (ip = ih->ih_next; ip != NULL; ip = ip->i_next) {
 		if (ip->i_ino == ino) {
+			/*
+			 * If INEW is set this inode is being set up
+			 * we need to pause and try again.
+			 */
+			if (ip->i_flags & XFS_INEW) {
+				read_unlock(&ih->ih_lock);
+				delay(1);
+				XFS_STATS_INC(xs_ig_frecycle);
 
-			inode_vp = XFS_ITOV_NULL(ip);
+				goto again;
+			}
 
+			inode_vp = XFS_ITOV_NULL(ip);
 			if (inode_vp == NULL) {
-				/* If IRECLAIM is set this inode is
+				/*
+				 * If IRECLAIM is set this inode is
 				 * on its way out of the system,
 				 * we need to pause and try again.
 				 */
@@ -250,14 +261,15 @@
 			XFS_STATS_INC(xs_ig_found);
 
 finish_inode:
-			if (lock_flags != 0) {
-				xfs_ilock(ip, lock_flags);
-			}
-
-			newnode = (ip->i_d.di_mode == 0);
-			if (newnode) {
+			if (ip->i_d.di_mode == 0) {
+				if (!(flags & IGET_CREATE))
+					return ENOENT;
 				xfs_iocore_inode_reinit(ip);
 			}
+	
+			if (lock_flags != 0)
+				xfs_ilock(ip, lock_flags);
+
 			ip->i_flags &= ~XFS_ISTALE;
 
 			vn_trace_exit(vp, "xfs_iget.found",
@@ -293,6 +305,11 @@
 	if (lock_flags != 0) {
 		xfs_ilock(ip, lock_flags);
 	}
+		
+	if ((ip->i_d.di_mode == 0) && !(flags & IGET_CREATE)) {
+		xfs_idestroy(ip);
+		return ENOENT;
+	}
 
 	/*
 	 * Put ip on its hash chain, unless someone else hashed a duplicate
@@ -324,6 +341,7 @@
 	ih->ih_next = ip;
 	ip->i_udquot = ip->i_gdquot = NULL;
 	ih->ih_version++;
+	ip->i_flags |= XFS_INEW;
 
 	write_unlock(&ih->ih_lock);
 
@@ -404,8 +422,6 @@
 
 	XFS_MOUNT_IUNLOCK(mp);
 
-	newnode = 1;
-
  return_ip:
 	ASSERT(ip->i_df.if_ext_max ==
 	       XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t));
@@ -434,6 +450,7 @@
 	xfs_mount_t	*mp,
 	xfs_trans_t	*tp,
 	xfs_ino_t	ino,
+	uint		flags,
 	uint		lock_flags,
 	xfs_inode_t	**ipp,
 	xfs_daddr_t	bno)
@@ -454,8 +471,8 @@
 		if (inode->i_state & I_NEW) {
 inode_allocate:
 			vn_initialize(inode);
-			error = xfs_iget_core(vp, mp, tp, ino,
-						lock_flags, ipp, bno);
+			error = xfs_iget_core(vp, mp, tp, ino, flags,
+					lock_flags, ipp, bno);
 			if (error) {
 				vn_mark_bad(vp);
 				if (inode->i_state & I_NEW)
@@ -576,6 +593,10 @@
 
 	vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address);
 
+	if ((ip->i_d.di_mode == 0)) {
+		ASSERT(!(ip->i_flags & XFS_IRECLAIMABLE));
+		vn_mark_bad(vp);
+	}
 	if (inode->i_state & I_NEW)
 		unlock_new_inode(inode);
 	if (lock_flags)
diff -Nru a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
--- a/fs/xfs/xfs_inode.c	2004-12-24 13:37:29 -08:00
+++ b/fs/xfs/xfs_inode.c	2004-12-24 13:37:29 -08:00
@@ -1163,7 +1163,8 @@
 	 * This is because we're setting fields here we need
 	 * to prevent others from looking at until we're done.
 	 */
-	error = xfs_trans_iget(tp->t_mountp, tp, ino, XFS_ILOCK_EXCL, &ip);
+	error = xfs_trans_iget(tp->t_mountp, tp, ino,
+			IGET_CREATE, XFS_ILOCK_EXCL, &ip);
 	if (error != 0) {
 		return error;
 	}
diff -Nru a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
--- a/fs/xfs/xfs_inode.h	2004-12-24 13:37:03 -08:00
+++ b/fs/xfs/xfs_inode.h	2004-12-24 13:37:03 -08:00
@@ -381,6 +381,7 @@
 #define XFS_IRECLAIM    0x0008  /* we have started reclaiming this inode    */
 #define XFS_ISTALE	0x0010	/* inode has been staled */
 #define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */
+#define XFS_INEW	0x0040
 
 /*
  * Flags for inode locking.
@@ -465,6 +466,9 @@
 /*
  * xfs_iget.c prototypes.
  */
+
+#define IGET_CREATE	1
+
 void		xfs_ihash_init(struct xfs_mount *);
 void		xfs_ihash_free(struct xfs_mount *);
 void		xfs_chash_init(struct xfs_mount *);
@@ -473,7 +477,7 @@
 				  struct xfs_trans *);
 void            xfs_inode_lock_init(xfs_inode_t *, struct vnode *);
 int		xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
-			 uint, xfs_inode_t **, xfs_daddr_t);
+			 uint, uint, xfs_inode_t **, xfs_daddr_t);
 void		xfs_iput(xfs_inode_t *, uint);
 void		xfs_iput_new(xfs_inode_t *, uint);
 void		xfs_ilock(xfs_inode_t *, uint);
diff -Nru a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
--- a/fs/xfs/xfs_itable.c	2004-12-24 13:36:18 -08:00
+++ b/fs/xfs/xfs_itable.c	2004-12-24 13:36:18 -08:00
@@ -102,7 +102,7 @@
 		/* We're not being passed a pointer to a dinode.  This happens
 		 * if BULKSTAT_FG_IGET is selected.  Do the iget.
 		 */
-		error = xfs_iget(mp, NULL, ino, XFS_ILOCK_SHARED, &ip, bno);
+		error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, bno);
 		if (error) {
 			*stat = BULKSTAT_RV_NOTHING;
 			return error;
diff -Nru a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
--- a/fs/xfs/xfs_log.c	2004-12-24 13:37:32 -08:00
+++ b/fs/xfs/xfs_log.c	2004-12-24 13:37:32 -08:00
@@ -902,20 +902,15 @@
 	} else {
 		/*
 		 * The reservation head is behind the tail.
-		 * This can only happen when the AIL is empty so the tail
-		 * is equal to the head and the l_roundoff value in the
-		 * log structure is taking up the difference between the
-		 * reservation head and the tail.  The bytes accounted for
-		 * by the l_roundoff field are temporarily 'lost' to the
-		 * reservation mechanism, but they are cleaned up when the
-		 * log buffers that created them are reused.  These lost
-		 * bytes are what allow the reservation head to fall behind
-		 * the tail in the case that the log is 'empty'.
 		 * In this case we just want to return the size of the
 		 * log as the amount of space left.
 		 */
-		ASSERT((tail_cycle == (cycle + 1)) ||
-		       ((bytes + log->l_roundoff) >= tail_bytes));
+		xfs_fs_cmn_err(CE_ALERT, log->l_mp,
+			"xlog_space_left: head behind tail\n"
+			"  tail_cycle = %d, tail_bytes = %d\n"
+			"  GH   cycle = %d, GH   bytes = %d",
+			tail_cycle, tail_bytes, cycle, bytes);
+		ASSERT(0);
 		free_bytes = log->l_logsize;
 	}
 	return free_bytes;
@@ -1355,8 +1350,8 @@
 
 
 /*
- * Flush out the in-core log (iclog) to the on-disk log in a synchronous or
- * asynchronous fashion.  Previously, we should have moved the current iclog
+ * Flush out the in-core log (iclog) to the on-disk log in an asynchronous 
+ * fashion.  Previously, we should have moved the current iclog
  * ptr in the log to point to the next available iclog.  This allows further
  * write to continue while this code syncs out an iclog ready to go.
  * Before an in-core log can be written out, the data section must be scanned
@@ -1388,8 +1383,11 @@
 	int		i, ops;
 	uint		count;		/* byte count of bwrite */
 	uint		count_init;	/* initial count before roundup */
+	int		roundoff;       /* roundoff to BB or stripe */
 	int		split = 0;	/* split write into two regions */
 	int		error;
+	SPLDECL(s);
+	int		v2 = XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb);
 
 	XFS_STATS_INC(xs_log_writes);
 	ASSERT(iclog->ic_refcnt == 0);
@@ -1398,23 +1396,34 @@
 	count_init = log->l_iclog_hsize + iclog->ic_offset;
 
 	/* Round out the log write size */
-	if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) &&
-	    log->l_mp->m_sb.sb_logsunit > 1) {
+	if (v2 && log->l_mp->m_sb.sb_logsunit > 1) {
 		/* we have a v2 stripe unit to use */
 		count = XLOG_LSUNITTOB(log, XLOG_BTOLSUNIT(log, count_init));
 	} else {
 		count = BBTOB(BTOBB(count_init));
 	}
-	iclog->ic_roundoff = count - count_init;
-	log->l_roundoff += iclog->ic_roundoff;
+	roundoff = count - count_init;
+	ASSERT(roundoff >= 0);
+	ASSERT((v2 && log->l_mp->m_sb.sb_logsunit > 1 && 
+                roundoff < log->l_mp->m_sb.sb_logsunit)
+		|| 
+		(log->l_mp->m_sb.sb_logsunit <= 1 && 
+		 roundoff < BBTOB(1)));
 
-	xlog_pack_data(log, iclog);       /* put cycle number in every block */
+	/* move grant heads by roundoff in sync */
+	s = GRANT_LOCK(log);
+	XLOG_GRANT_ADD_SPACE(log, roundoff, 'w');
+	XLOG_GRANT_ADD_SPACE(log, roundoff, 'r');
+	GRANT_UNLOCK(log, s);
+
+	/* put cycle number in every block */
+	xlog_pack_data(log, iclog, roundoff); 
 
 	/* real byte length */
-	if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
+	if (v2) {
 		INT_SET(iclog->ic_header.h_len, 
 			ARCH_CONVERT,
-			iclog->ic_offset + iclog->ic_roundoff);
+			iclog->ic_offset + roundoff);
 	} else {
 		INT_SET(iclog->ic_header.h_len, ARCH_CONVERT, iclog->ic_offset);
 	}
@@ -2278,11 +2287,6 @@
 		INT_SET(head->h_cycle, ARCH_CONVERT, log->l_curr_cycle);
 		ASSIGN_LSN(head->h_lsn, log, ARCH_CONVERT);
 		ASSERT(log->l_curr_block >= 0);
-
-		/* round off error from last write with this iclog */
-		ticket->t_curr_res -= iclog->ic_roundoff;
-		log->l_roundoff -= iclog->ic_roundoff;
-		iclog->ic_roundoff = 0;
 	}
 
 	/* If there is enough room to write everything, then do it.  Otherwise,
@@ -2853,7 +2857,6 @@
 				 * has already taken care of the roundoff from
 				 * the previous sync.
 				 */
-				ASSERT(iclog->ic_roundoff == 0);
 				iclog->ic_refcnt++;
 				lsn = INT_GET(iclog->ic_header.h_lsn, ARCH_CONVERT);
 				xlog_state_switch_iclogs(log, iclog, 0);
diff -Nru a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
--- a/fs/xfs/xfs_log_priv.h	2004-12-24 13:36:18 -08:00
+++ b/fs/xfs/xfs_log_priv.h	2004-12-24 13:36:18 -08:00
@@ -430,7 +430,6 @@
 	int			ic_size;
 	int			ic_offset;
 	int			ic_refcnt;
-	int			ic_roundoff;
 	int			ic_bwritecnt;
 	ushort_t		ic_state;
 	char			*ic_datap;	/* pointer to iclog data */
@@ -462,7 +461,6 @@
 #define	ic_size		hic_fields.ic_size
 #define	ic_offset	hic_fields.ic_offset
 #define	ic_refcnt	hic_fields.ic_refcnt
-#define	ic_roundoff	hic_fields.ic_roundoff
 #define	ic_bwritecnt	hic_fields.ic_bwritecnt
 #define	ic_state	hic_fields.ic_state
 #define ic_datap	hic_fields.ic_datap
@@ -498,7 +496,6 @@
 	xfs_daddr_t		l_logBBstart;   /* start block of log */
 	int			l_logsize;      /* size of log in bytes */
 	int			l_logBBsize;    /* size of log in BB chunks */
-	int			l_roundoff;	/* round off error of iclogs */
 	int			l_curr_cycle;   /* Cycle number of log writes */
 	int			l_prev_cycle;   /* Cycle number before last
 						 * block increment */
@@ -545,7 +542,7 @@
 				int readonly);
 extern int	 xlog_recover(xlog_t *log, int readonly);
 extern int	 xlog_recover_finish(xlog_t *log, int mfsi_flags);
-extern void	 xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog);
+extern void	 xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog, int);
 extern void	 xlog_recover_process_iunlinks(xlog_t *log);
 
 extern struct xfs_buf *xlog_get_bp(xlog_t *, int);
diff -Nru a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
--- a/fs/xfs/xfs_log_recover.c	2004-12-24 13:36:55 -08:00
+++ b/fs/xfs/xfs_log_recover.c	2004-12-24 13:36:55 -08:00
@@ -3262,7 +3262,7 @@
 				xfs_buf_relse(agibp);
 
 				ino = XFS_AGINO_TO_INO(mp, agno, agino);
-				error = xfs_iget(mp, NULL, ino, 0, &ip, 0);
+				error = xfs_iget(mp, NULL, ino, 0, 0, &ip, 0);
 				ASSERT(error || (ip != NULL));
 
 				if (!error) {
@@ -3384,10 +3384,11 @@
 void
 xlog_pack_data(
 	xlog_t			*log,
-	xlog_in_core_t		*iclog)
+	xlog_in_core_t		*iclog,
+	int			roundoff)
 {
 	int			i, j, k;
-	int			size = iclog->ic_offset + iclog->ic_roundoff;
+	int			size = iclog->ic_offset + roundoff;
 	uint			cycle_lsn;
 	xfs_caddr_t		dp;
 	xlog_in_core_2_t	*xhdr;
diff -Nru a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
--- a/fs/xfs/xfs_mount.c	2004-12-24 13:36:47 -08:00
+++ b/fs/xfs/xfs_mount.c	2004-12-24 13:36:47 -08:00
@@ -975,7 +975,7 @@
 	 * Get and sanity-check the root inode.
 	 * Save the pointer to it in the mount structure.
 	 */
-	error = xfs_iget(mp, NULL, sbp->sb_rootino, XFS_ILOCK_EXCL, &rip, 0);
+	error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip, 0);
 	if (error) {
 		cmn_err(CE_WARN, "XFS: failed to read root inode");
 		goto error3;
@@ -1036,7 +1036,7 @@
 	/*
 	 * Complete the quota initialisation, post-log-replay component.
 	 */
-	if ((error = XFS_QM_MOUNT(mp, quotamount, quotaflags)))
+	if ((error = XFS_QM_MOUNT(mp, quotamount, quotaflags, mfsi_flags)))
 		goto error4;
 
 	return 0;
@@ -1098,6 +1098,8 @@
 
 	xfs_unmountfs_writesb(mp);
 
+	xfs_unmountfs_wait(mp); 		/* wait for async bufs */
+
 	xfs_log_unmount(mp);			/* Done! No more fs ops. */
 
 	xfs_freesb(mp);
@@ -1140,6 +1142,16 @@
 	if (mp->m_rtdev_targp)
 		xfs_free_buftarg(mp->m_rtdev_targp, 1);
 	xfs_free_buftarg(mp->m_ddev_targp, 0);
+}
+
+void
+xfs_unmountfs_wait(xfs_mount_t *mp)
+{
+	if (mp->m_logdev_targp != mp->m_ddev_targp)
+		xfs_wait_buftarg(mp->m_logdev_targp);
+	if (mp->m_rtdev_targp)
+		xfs_wait_buftarg(mp->m_rtdev_targp);
+	xfs_wait_buftarg(mp->m_ddev_targp);
 }
 
 int
diff -Nru a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
--- a/fs/xfs/xfs_mount.h	2004-12-24 13:36:16 -08:00
+++ b/fs/xfs/xfs_mount.h	2004-12-24 13:36:16 -08:00
@@ -133,7 +133,7 @@
 struct xfs_quotainfo;
 
 typedef int	(*xfs_qminit_t)(struct xfs_mount *, uint *, uint *);
-typedef int	(*xfs_qmmount_t)(struct xfs_mount *, uint, uint);
+typedef int	(*xfs_qmmount_t)(struct xfs_mount *, uint, uint, int);
 typedef int	(*xfs_qmunmount_t)(struct xfs_mount *);
 typedef void	(*xfs_qmdone_t)(struct xfs_mount *);
 typedef void	(*xfs_dqrele_t)(struct xfs_dquot *);
@@ -171,8 +171,8 @@
 
 #define XFS_QM_INIT(mp, mnt, fl) \
 	(*(mp)->m_qm_ops.xfs_qminit)(mp, mnt, fl)
-#define XFS_QM_MOUNT(mp, mnt, fl) \
-	(*(mp)->m_qm_ops.xfs_qmmount)(mp, mnt, fl)
+#define XFS_QM_MOUNT(mp, mnt, fl, mfsi_flags) \
+	(*(mp)->m_qm_ops.xfs_qmmount)(mp, mnt, fl, mfsi_flags)
 #define XFS_QM_UNMOUNT(mp) \
 	(*(mp)->m_qm_ops.xfs_qmunmount)(mp)
 #define XFS_QM_DONE(mp) \
@@ -466,6 +466,7 @@
 #define XFS_MFSI_CLIENT		0x02	/* Is a client -- skip lots of stuff */
 #define XFS_MFSI_NOUNLINK	0x08	/* Skip unlinked inode processing in */
 					/* log recovery */
+#define XFS_MFSI_NO_QUOTACHECK	0x10	/* Skip quotacheck processing */
 
 /*
  * Macros for getting from mount to vfs and back.
@@ -540,6 +541,7 @@
 extern int	xfs_mountfs(struct vfs *, xfs_mount_t *mp, int);
 
 extern int	xfs_unmountfs(xfs_mount_t *, struct cred *);
+extern void	xfs_unmountfs_wait(xfs_mount_t *);
 extern void	xfs_unmountfs_close(xfs_mount_t *, struct cred *);
 extern int	xfs_unmountfs_writesb(xfs_mount_t *);
 extern int	xfs_unmount_flush(xfs_mount_t *, int);
diff -Nru a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
--- a/fs/xfs/xfs_rtalloc.c	2004-12-24 13:36:19 -08:00
+++ b/fs/xfs/xfs_rtalloc.c	2004-12-24 13:36:19 -08:00
@@ -149,7 +149,7 @@
 		/*
 		 * Lock the inode.
 		 */
-		if ((error = xfs_trans_iget(mp, tp, ino, XFS_ILOCK_EXCL, &ip)))
+		if ((error = xfs_trans_iget(mp, tp, ino, 0, XFS_ILOCK_EXCL, &ip)))
 			goto error_exit;
 		XFS_BMAP_INIT(&flist, &firstblock);
 		/*
@@ -189,7 +189,7 @@
 			/*
 			 * Lock the bitmap inode.
 			 */
-			if ((error = xfs_trans_iget(mp, tp, ino, XFS_ILOCK_EXCL,
+			if ((error = xfs_trans_iget(mp, tp, ino, 0, XFS_ILOCK_EXCL,
 					&ip)))
 				goto error_exit;
 			/*
@@ -2042,7 +2042,7 @@
 		/*
 		 * Lock out other callers by grabbing the bitmap inode lock.
 		 */
-		if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino,
+		if ((error = xfs_trans_iget(mp, tp, 0, mp->m_sb.sb_rbmino,
 				XFS_ILOCK_EXCL, &ip)))
 			goto error_exit;
 		ASSERT(ip == mp->m_rbmip);
@@ -2057,7 +2057,7 @@
 		 * Get the summary inode into the transaction.
 		 */
 		if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino,
-				XFS_ILOCK_EXCL, &ip)))
+				0, XFS_ILOCK_EXCL, &ip)))
 			goto error_exit;
 		ASSERT(ip == mp->m_rsumip);
 		/*
@@ -2177,7 +2177,7 @@
 	/*
 	 * Lock out other callers by grabbing the bitmap inode lock.
 	 */
-	error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, XFS_ILOCK_EXCL, &ip);
+	error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, XFS_ILOCK_EXCL, &ip);
 	if (error) {
 		return error;
 	}
@@ -2240,7 +2240,7 @@
 	/*
 	 * Synchronize by locking the bitmap inode.
 	 */
-	error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, XFS_ILOCK_EXCL, &ip);
+	error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, XFS_ILOCK_EXCL, &ip);
 	if (error) {
 		return error;
 	}
@@ -2348,12 +2348,12 @@
 	sbp = &mp->m_sb;
 	if (sbp->sb_rbmino == NULLFSINO)
 		return 0;
-	error = xfs_iget(mp, NULL, sbp->sb_rbmino, 0, &mp->m_rbmip, 0);
+	error = xfs_iget(mp, NULL, sbp->sb_rbmino, 0, 0, &mp->m_rbmip, 0);
 	if (error)
 		return error;
 	ASSERT(mp->m_rbmip != NULL);
 	ASSERT(sbp->sb_rsumino != NULLFSINO);
-	error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, &mp->m_rsumip, 0);
+	error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip, 0);
 	if (error) {
 		VN_RELE(XFS_ITOV(mp->m_rbmip));
 		return error;
@@ -2384,7 +2384,7 @@
 	__uint64_t	seq;		/* sequence number of file creation */
 	__uint64_t	*seqp;		/* pointer to seqno in inode */
 
-	error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, XFS_ILOCK_EXCL, &ip);
+	error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, XFS_ILOCK_EXCL, &ip);
 	if (error)
 		return error;
 	ASSERT(ip == mp->m_rbmip);
diff -Nru a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
--- a/fs/xfs/xfs_trans.h	2004-12-24 13:37:43 -08:00
+++ b/fs/xfs/xfs_trans.h	2004-12-24 13:37:43 -08:00
@@ -1007,7 +1007,7 @@
 void		xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint);
 void		xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *);
 int		xfs_trans_iget(struct xfs_mount *, xfs_trans_t *,
-			       xfs_ino_t , uint, struct xfs_inode **);
+			       xfs_ino_t , uint, uint, struct xfs_inode **);
 void		xfs_trans_ijoin(xfs_trans_t *, struct xfs_inode *, uint);
 void		xfs_trans_ihold(xfs_trans_t *, struct xfs_inode *);
 void		xfs_trans_ihold_release(xfs_trans_t *, struct xfs_inode *);
diff -Nru a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c
--- a/fs/xfs/xfs_trans_inode.c	2004-12-24 13:36:17 -08:00
+++ b/fs/xfs/xfs_trans_inode.c	2004-12-24 13:36:17 -08:00
@@ -95,6 +95,7 @@
 	xfs_mount_t	*mp,
 	xfs_trans_t	*tp,
 	xfs_ino_t	ino,
+	uint		flags,
 	uint		lock_flags,
 	xfs_inode_t	**ipp)
 {
@@ -106,9 +107,8 @@
 	 * If the transaction pointer is NULL, just call the normal
 	 * xfs_iget().
 	 */
-	if (tp == NULL) {
-		return (xfs_iget(mp, NULL, ino, lock_flags, ipp, 0));
-	}
+	if (tp == NULL)
+		return xfs_iget(mp, NULL, ino, flags, lock_flags, ipp, 0);
 
 	/*
 	 * If we find the inode in core with this transaction
@@ -148,7 +148,7 @@
 	}
 
 	ASSERT(lock_flags & XFS_ILOCK_EXCL);
-	error = xfs_iget(tp->t_mountp, tp, ino, lock_flags, &ip, 0);
+	error = xfs_iget(tp->t_mountp, tp, ino, flags, lock_flags, &ip, 0);
 	if (error) {
 		return error;
 	}
@@ -185,7 +185,6 @@
 	*ipp = ip;
 	return 0;
 }
-
 
 /*
  * Add the locked inode to the transaction.
diff -Nru a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
--- a/fs/xfs/xfs_utils.c	2004-12-24 13:37:31 -08:00
+++ b/fs/xfs/xfs_utils.c	2004-12-24 13:37:31 -08:00
@@ -110,7 +110,7 @@
 		 * reservation in the inactive routine.
 		 */
 		xfs_iunlock(dp, lock_mode);
-		error = xfs_iget(dp->i_mount, NULL, *inum, 0, ipp, 0);
+		error = xfs_iget(dp->i_mount, NULL, *inum, 0, 0, ipp, 0);
 		xfs_ilock(dp, lock_mode);
 
 		if (error) {
diff -Nru a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
--- a/fs/xfs/xfs_vfsops.c	2004-12-24 13:36:30 -08:00
+++ b/fs/xfs/xfs_vfsops.c	2004-12-24 13:36:30 -08:00
@@ -1610,7 +1610,7 @@
 	if (ino == 0)
 		return XFS_ERROR(ESTALE);
 
-	error = xfs_iget(mp, NULL, ino, XFS_ILOCK_SHARED, &ip, 0);
+	error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0);
 	if (error) {
 		*vpp = NULL;
 		return error;
diff -Nru a/include/acpi/acconfig.h b/include/acpi/acconfig.h
--- a/include/acpi/acconfig.h	2004-12-24 13:37:04 -08:00
+++ b/include/acpi/acconfig.h	2004-12-24 13:37:04 -08:00
@@ -64,7 +64,7 @@
 
 /* Version string */
 
-#define ACPI_CA_VERSION                 0x20040816
+#define ACPI_CA_VERSION                 0x20041105
 
 /*
  * OS name, used for the _OS object.  The _OS object is essentially obsolete,
diff -Nru a/include/acpi/acdebug.h b/include/acpi/acdebug.h
--- a/include/acpi/acdebug.h	2004-12-24 13:36:19 -08:00
+++ b/include/acpi/acdebug.h	2004-12-24 13:36:19 -08:00
@@ -386,11 +386,6 @@
 acpi_db_execute_thread (
 	void                            *context);
 
-acpi_status
-acpi_db_user_commands (
-	char                            prompt,
-	union acpi_parse_object         *op);
-
 void
 acpi_db_display_help (
 	char                            *help_type);
diff -Nru a/include/acpi/acdispat.h b/include/acpi/acdispat.h
--- a/include/acpi/acdispat.h	2004-12-24 13:37:03 -08:00
+++ b/include/acpi/acdispat.h	2004-12-24 13:37:03 -08:00
@@ -62,10 +62,12 @@
 	u32                             pop_count,
 	struct acpi_walk_state          *walk_state);
 
+#ifdef ACPI_FUTURE_USAGE
 void *
 acpi_ds_obj_stack_get_value (
 	u32                             index,
 	struct acpi_walk_state          *walk_state);
+#endif
 
 acpi_status
 acpi_ds_obj_stack_pop_object (
@@ -248,11 +250,13 @@
 acpi_ds_is_method_value (
 	union acpi_operand_object       *obj_desc);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_object_type
 acpi_ds_method_data_get_type (
 	u16                             opcode,
 	u32                             index,
 	struct acpi_walk_state          *walk_state);
+#endif
 
 acpi_status
 acpi_ds_method_data_get_value (
@@ -440,9 +444,11 @@
 	struct acpi_parameter_info      *info,
 	u32                             pass_number);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_ds_obj_stack_delete_all (
 	struct acpi_walk_state          *walk_state);
+#endif
 
 acpi_status
 acpi_ds_obj_stack_pop_and_delete (
@@ -482,6 +488,7 @@
 acpi_ds_delete_walk_state_cache (
 	void);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_ds_result_insert (
 	void                            *object,
@@ -493,6 +500,7 @@
 	union acpi_operand_object       **object,
 	u32                             index,
 	struct acpi_walk_state          *walk_state);
+#endif
 
 acpi_status
 acpi_ds_result_pop (
diff -Nru a/include/acpi/acglobal.h b/include/acpi/acglobal.h
--- a/include/acpi/acglobal.h	2004-12-24 13:36:16 -08:00
+++ b/include/acpi/acglobal.h	2004-12-24 13:36:16 -08:00
@@ -92,7 +92,10 @@
 /*
  * Enable "slack" in the AML interpreter?  Default is FALSE, and the
  * interpreter strictly follows the ACPI specification.  Setting to TRUE
- * allows the interpreter to forgive certain bad AML constructs.
+ * allows the interpreter to forgive certain bad AML constructs.  Currently:
+ * 1) Allow "implicit return" of last value in a control method
+ * 2) Allow access beyond end of operation region
+ * 3) Allow access to uninitialized locals/args (auto-init to integer 0)
  */
 ACPI_EXTERN u8       ACPI_INIT_GLOBAL (acpi_gbl_enable_interpreter_slack, FALSE);
 
@@ -180,6 +183,7 @@
 ACPI_EXTERN struct acpi_memory_list             acpi_gbl_memory_lists[ACPI_NUM_MEM_LISTS];
 ACPI_EXTERN struct acpi_object_notify_handler   acpi_gbl_device_notify;
 ACPI_EXTERN struct acpi_object_notify_handler   acpi_gbl_system_notify;
+ACPI_EXTERN acpi_exception_handler              acpi_gbl_exception_handler;
 ACPI_EXTERN acpi_init_handler                   acpi_gbl_init_handler;
 ACPI_EXTERN struct acpi_walk_state             *acpi_gbl_breakpoint_walk;
 ACPI_EXTERN acpi_handle                         acpi_gbl_global_lock_semaphore;
diff -Nru a/include/acpi/achware.h b/include/acpi/achware.h
--- a/include/acpi/achware.h	2004-12-24 13:37:00 -08:00
+++ b/include/acpi/achware.h	2004-12-24 13:37:00 -08:00
@@ -131,10 +131,12 @@
 	struct acpi_gpe_xrupt_info      *gpe_xrupt_info,
 	struct acpi_gpe_block_info      *gpe_block);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_hw_get_gpe_status (
 	struct acpi_gpe_event_info      *gpe_event_info,
 	acpi_event_status               *event_status);
+#endif
 
 acpi_status
 acpi_hw_disable_all_gpes (
@@ -161,6 +163,7 @@
 
 /* ACPI Timer prototypes */
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_get_timer_resolution (
 	u32                             *resolution);
@@ -174,6 +177,6 @@
 	u32                             start_ticks,
 	u32                             end_ticks,
 	u32                             *time_elapsed);
-
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 #endif /* __ACHWARE_H__ */
diff -Nru a/include/acpi/acinterp.h b/include/acpi/acinterp.h
--- a/include/acpi/acinterp.h	2004-12-24 13:37:19 -08:00
+++ b/include/acpi/acinterp.h	2004-12-24 13:37:19 -08:00
@@ -83,21 +83,25 @@
 acpi_ex_convert_to_integer (
 	union acpi_operand_object       *obj_desc,
 	union acpi_operand_object       **result_desc,
-	struct acpi_walk_state          *walk_state);
+	u32                             flags);
 
 acpi_status
 acpi_ex_convert_to_buffer (
 	union acpi_operand_object       *obj_desc,
-	union acpi_operand_object       **result_desc,
-	struct acpi_walk_state          *walk_state);
+	union acpi_operand_object       **result_desc);
 
 acpi_status
 acpi_ex_convert_to_string (
 	union acpi_operand_object       *obj_desc,
 	union acpi_operand_object       **result_desc,
-	u32                             base,
-	u32                             max_length,
-	struct acpi_walk_state          *walk_state);
+	u32                             type);
+
+/* Types for ->String conversion */
+
+#define ACPI_EXPLICIT_BYTE_COPY         0x00000000
+#define ACPI_EXPLICIT_CONVERT_HEX       0x00000001
+#define ACPI_IMPLICIT_CONVERT_HEX       0x00000002
+#define ACPI_EXPLICIT_CONVERT_DECIMAL   0x00000003
 
 acpi_status
 acpi_ex_convert_to_target_type (
@@ -109,7 +113,7 @@
 u32
 acpi_ex_convert_to_ascii (
 	acpi_integer                    integer,
-	u32                             base,
+	u16                             base,
 	u8                              *string,
 	u8                              max_length);
 
@@ -243,11 +247,19 @@
 	union acpi_operand_object       **actual_return_desc,
 	struct acpi_walk_state          *walk_state);
 
-u8
+acpi_status
+acpi_ex_do_logical_numeric_op (
+	u16                             opcode,
+	acpi_integer                    integer0,
+	acpi_integer                    integer1,
+	u8                              *logical_result);
+
+acpi_status
 acpi_ex_do_logical_op (
 	u16                             opcode,
-	union acpi_operand_object       *obj_desc,
-	union acpi_operand_object       *obj_desc2);
+	union acpi_operand_object       *operand0,
+	union acpi_operand_object       *operand1,
+	u8                              *logical_result);
 
 acpi_integer
 acpi_ex_do_math_op (
@@ -374,7 +386,7 @@
 
 acpi_status
 acpi_ex_system_do_suspend(
-	u32                             time);
+	acpi_integer                    time);
 
 acpi_status
 acpi_ex_system_do_stall (
@@ -413,6 +425,10 @@
  */
 
 acpi_status
+acpi_ex_opcode_0A_0T_1R (
+	struct acpi_walk_state          *walk_state);
+
+acpi_status
 acpi_ex_opcode_1A_0T_0R (
 	struct acpi_walk_state          *walk_state);
 
@@ -470,12 +486,13 @@
 
 
 /*
- * exdump - Scanner debug output routines
+ * exdump - Interpreter debug output routines
  */
 
 void
 acpi_ex_dump_operand (
-	union acpi_operand_object       *entry_desc);
+	union acpi_operand_object       *obj_desc,
+	u32                             depth);
 
 void
 acpi_ex_dump_operands (
@@ -487,6 +504,7 @@
 	char                            *module_name,
 	u32                             line_number);
 
+#ifdef ACPI_FUTURE_USAGE
 void
 acpi_ex_dump_object_descriptor (
 	union acpi_operand_object       *object,
@@ -516,7 +534,7 @@
 acpi_ex_out_address (
 	char                            *title,
 	acpi_physical_address           value);
-
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 /*
  * exnames - interpreter/scanner name load/execute
diff -Nru a/include/acpi/aclocal.h b/include/acpi/aclocal.h
--- a/include/acpi/aclocal.h	2004-12-24 13:37:00 -08:00
+++ b/include/acpi/aclocal.h	2004-12-24 13:37:00 -08:00
@@ -53,7 +53,7 @@
 
 /* Total number of aml opcodes defined */
 
-#define AML_NUM_OPCODES                 0x7E
+#define AML_NUM_OPCODES                 0x7F
 
 
 /*****************************************************************************
diff -Nru a/include/acpi/acmacros.h b/include/acpi/acmacros.h
--- a/include/acpi/acmacros.h	2004-12-24 13:36:56 -08:00
+++ b/include/acpi/acmacros.h	2004-12-24 13:36:56 -08:00
@@ -533,12 +533,16 @@
 
 /* Stack and buffer dumping */
 
-#define ACPI_DUMP_STACK_ENTRY(a)        acpi_ex_dump_operand(a)
+#define ACPI_DUMP_STACK_ENTRY(a)        acpi_ex_dump_operand((a),0)
 #define ACPI_DUMP_OPERANDS(a,b,c,d,e)   acpi_ex_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__)
 
 
 #define ACPI_DUMP_ENTRY(a,b)            acpi_ns_dump_entry (a,b)
+
+#ifdef ACPI_FUTURE_USAGE
 #define ACPI_DUMP_TABLES(a,b)           acpi_ns_dump_tables(a,b)
+#endif
+
 #define ACPI_DUMP_PATHNAME(a,b,c,d)     acpi_ns_dump_pathname(a,b,c,d)
 #define ACPI_DUMP_RESOURCE_LIST(a)      acpi_rs_dump_resource_list(a)
 #define ACPI_DUMP_BUFFER(a,b)           acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
@@ -591,7 +595,11 @@
 #define ACPI_DUMP_STACK_ENTRY(a)
 #define ACPI_DUMP_OPERANDS(a,b,c,d,e)
 #define ACPI_DUMP_ENTRY(a,b)
+
+#ifdef ACPI_FUTURE_USAGE
 #define ACPI_DUMP_TABLES(a,b)
+#endif
+
 #define ACPI_DUMP_PATHNAME(a,b,c,d)
 #define ACPI_DUMP_RESOURCE_LIST(a)
 #define ACPI_DUMP_BUFFER(a,b)
diff -Nru a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h
--- a/include/acpi/acnamesp.h	2004-12-24 13:36:18 -08:00
+++ b/include/acpi/acnamesp.h	2004-12-24 13:36:18 -08:00
@@ -210,6 +210,7 @@
  * Namespace modification - nsmodify
  */
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_ns_unload_namespace (
 	acpi_handle                     handle);
@@ -217,16 +218,19 @@
 acpi_status
 acpi_ns_delete_subtree (
 	acpi_handle                     start_handle);
+#endif
 
 
 /*
  * Namespace dump/print utilities - nsdump
  */
 
+#ifdef ACPI_FUTURE_USAGE
 void
 acpi_ns_dump_tables (
 	acpi_handle                     search_base,
 	u32                             max_depth);
+#endif
 
 void
 acpi_ns_dump_entry (
@@ -245,6 +249,7 @@
 	u32                             num_segments,
 	char                            *pathname);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_ns_dump_one_device (
 	acpi_handle                     obj_handle,
@@ -255,6 +260,7 @@
 void
 acpi_ns_dump_root_devices (
 	void);
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 acpi_status
 acpi_ns_dump_one_object (
@@ -263,6 +269,7 @@
 	void                            *context,
 	void                            **return_value);
 
+#ifdef ACPI_FUTURE_USAGE
 void
 acpi_ns_dump_objects (
 	acpi_object_type                type,
@@ -270,6 +277,7 @@
 	u32                             max_depth,
 	u32                             ownder_id,
 	acpi_handle                     start_handle);
+#endif
 
 
 /*
@@ -303,9 +311,11 @@
  * Parent/Child/Peer utility functions
  */
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_name
 acpi_ns_find_parent_name (
 	struct acpi_namespace_node      *node_to_search);
+#endif
 
 
 /*
diff -Nru a/include/acpi/acobject.h b/include/acpi/acobject.h
--- a/include/acpi/acobject.h	2004-12-24 13:36:18 -08:00
+++ b/include/acpi/acobject.h	2004-12-24 13:36:18 -08:00
@@ -135,7 +135,10 @@
 	acpi_integer                            value;
 };
 
-
+/*
+ * Note: The String and Buffer object must be identical through the Pointer
+ * element.  There is code that depends on this.
+ */
 struct acpi_object_string           /* Null terminated, ASCII characters only */
 {
 	ACPI_OBJECT_COMMON_HEADER
diff -Nru a/include/acpi/acparser.h b/include/acpi/acparser.h
--- a/include/acpi/acparser.h	2004-12-24 13:37:01 -08:00
+++ b/include/acpi/acparser.h	2004-12-24 13:37:01 -08:00
@@ -247,6 +247,7 @@
 	union acpi_parse_object         *op,
 	u32                              argn);
 
+#ifdef ACPI_FUTURE_USAGE
 union acpi_parse_object *
 acpi_ps_get_child (
 	union acpi_parse_object         *op);
@@ -255,6 +256,7 @@
 acpi_ps_get_depth_next (
 	union acpi_parse_object         *origin,
 	union acpi_parse_object         *op);
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 
 /* pswalk - parse tree walk routines */
@@ -313,9 +315,11 @@
 acpi_ps_is_prefix_char (
 	u32                             c);
 
+#ifdef ACPI_FUTURE_USAGE
 u32
 acpi_ps_get_name(
 	union acpi_parse_object         *op);
+#endif
 
 void
 acpi_ps_set_name(
diff -Nru a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
--- a/include/acpi/acpi_bus.h	2004-12-24 13:37:43 -08:00
+++ b/include/acpi/acpi_bus.h	2004-12-24 13:37:43 -08:00
@@ -104,6 +104,8 @@
 typedef int (*acpi_op_resume)	(struct acpi_device *device, int state);
 typedef int (*acpi_op_scan)	(struct acpi_device *device);
 typedef int (*acpi_op_bind)	(struct acpi_device *device);
+typedef int (*acpi_op_match)	(struct acpi_device *device,
+				 struct acpi_driver *driver);
 
 struct acpi_device_ops {
 	acpi_op_add		add;
@@ -115,6 +117,7 @@
 	acpi_op_resume		resume;
 	acpi_op_scan		scan;
 	acpi_op_bind		bind;
+	acpi_op_match		match;
 };
 
 struct acpi_driver {
@@ -322,6 +325,7 @@
 int acpi_bus_register_driver (struct acpi_driver *driver);
 int acpi_bus_unregister_driver (struct acpi_driver *driver);
 
+int acpi_match_ids (struct acpi_device	*device, char	*ids);
 int acpi_create_dir(struct acpi_device *);
 void acpi_remove_dir(struct acpi_device *);
 
diff -Nru a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
--- a/include/acpi/acpiosxf.h	2004-12-24 13:36:17 -08:00
+++ b/include/acpi/acpiosxf.h	2004-12-24 13:36:17 -08:00
@@ -176,10 +176,12 @@
 	void __iomem                  *logical_address,
 	acpi_size                       size);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_os_get_physical_address (
 	void                            *logical_address,
 	acpi_physical_address           *physical_address);
+#endif
 
 
 /*
@@ -217,9 +219,12 @@
 	void * context);
 
 void
+acpi_os_wait_events_complete (
+	void                            *context);
+
+void
 acpi_os_sleep (
-	u32                             seconds,
-	u32                             milliseconds);
+	acpi_integer                    milliseconds);
 
 void
 acpi_os_stall (
@@ -299,12 +304,14 @@
 	void                            *pointer,
 	acpi_size                       length);
 
+#ifdef ACPI_FUTURE_USAGE
 u8
 acpi_os_writable (
 	void                            *pointer,
 	acpi_size                       length);
+#endif
 
-u32
+u64
 acpi_os_get_timer (
 	void);
 
@@ -336,9 +343,11 @@
  * Debug input
  */
 
+#ifdef ACPI_FUTURE_USAGE
 u32
 acpi_os_get_line (
 	char                            *buffer);
+#endif
 
 
 /*
diff -Nru a/include/acpi/acpixf.h b/include/acpi/acpixf.h
--- a/include/acpi/acpixf.h	2004-12-24 13:36:16 -08:00
+++ b/include/acpi/acpixf.h	2004-12-24 13:36:16 -08:00
@@ -70,9 +70,11 @@
 acpi_terminate (
 	void);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_subsystem_status (
 	void);
+#endif
 
 acpi_status
 acpi_enable (
@@ -82,9 +84,11 @@
 acpi_disable (
 	void);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_get_system_info (
 	struct acpi_buffer              *ret_buffer);
+#endif
 
 const char *
 acpi_format_exception (
@@ -94,10 +98,12 @@
 acpi_purge_cached_objects (
 	void);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_install_initialization_handler (
 	acpi_init_handler               handler,
 	u32                             function);
+#endif
 
 /*
  * ACPI Memory manager
@@ -129,6 +135,7 @@
 acpi_load_tables (
 	void);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_load_table (
 	struct acpi_table_header        *table_ptr);
@@ -142,6 +149,7 @@
 	acpi_table_type                 table_type,
 	u32                             instance,
 	struct acpi_table_header        *out_table_header);
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 acpi_status
 acpi_get_table (
@@ -218,6 +226,7 @@
 	struct acpi_object_list         *parameter_objects,
 	struct acpi_buffer              *return_object_buffer);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_evaluate_object_typed (
 	acpi_handle                     object,
@@ -225,6 +234,7 @@
 	struct acpi_object_list         *external_params,
 	struct acpi_buffer              *return_buffer,
 	acpi_object_type                return_type);
+#endif
 
 acpi_status
 acpi_get_object_info (
@@ -299,6 +309,17 @@
 	acpi_event_handler              address,
 	void                            *context);
 
+#ifdef ACPI_FUTURE_USAGE
+acpi_status
+acpi_install_exception_handler (
+	acpi_exception_handler          handler);
+#endif
+
+
+/*
+ * Event interfaces
+ */
+
 acpi_status
 acpi_acquire_global_lock (
 	u16                             timeout,
@@ -324,6 +345,7 @@
 	u32                             event,
 	u32                             flags);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_clear_event (
 	u32                             event);
@@ -332,6 +354,7 @@
 acpi_get_event_status (
 	u32                             event,
 	acpi_event_status               *event_status);
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 acpi_status
 acpi_set_gpe_type (
@@ -357,12 +380,14 @@
 	u32                             gpe_number,
 	u32                             flags);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_get_gpe_status (
 	acpi_handle                     gpe_device,
 	u32                             gpe_number,
 	u32                             flags,
 	acpi_event_status               *event_status);
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 acpi_status
 acpi_install_gpe_block (
@@ -391,10 +416,12 @@
 	acpi_handle                     device_handle,
 	struct acpi_buffer              *ret_buffer);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_get_possible_resources(
 	acpi_handle                     device_handle,
 	struct acpi_buffer              *ret_buffer);
+#endif
 
 acpi_status
 acpi_walk_resources (
@@ -438,9 +465,11 @@
 acpi_set_firmware_waking_vector (
 	acpi_physical_address           physical_address);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_get_firmware_waking_vector (
 	acpi_physical_address           *physical_address);
+#endif
 
 acpi_status
 acpi_get_sleep_type_data (
diff -Nru a/include/acpi/acresrc.h b/include/acpi/acresrc.h
--- a/include/acpi/acresrc.h	2004-12-24 13:36:18 -08:00
+++ b/include/acpi/acresrc.h	2004-12-24 13:36:18 -08:00
@@ -60,10 +60,12 @@
 	acpi_handle                     handle,
 	struct acpi_buffer              *ret_buffer);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_rs_get_prs_method_data (
 	acpi_handle                     handle,
 	struct acpi_buffer              *ret_buffer);
+#endif
 
 acpi_status
 acpi_rs_get_method_data (
@@ -95,6 +97,7 @@
 /*
  * Function prototypes called from acpi_rs_create*
  */
+#ifdef ACPI_FUTURE_USAGE
 void
 acpi_rs_dump_irq (
 	union acpi_resource_data        *data);
@@ -154,6 +157,7 @@
 void
 acpi_rs_dump_irq_list (
 	u8                              *route_table);
+#endif  /*  ACPI_FUTURE_USAGE  */
 
 acpi_status
 acpi_rs_get_byte_stream_start (
diff -Nru a/include/acpi/actables.h b/include/acpi/actables.h
--- a/include/acpi/actables.h	2004-12-24 13:36:31 -08:00
+++ b/include/acpi/actables.h	2004-12-24 13:36:31 -08:00
@@ -50,10 +50,12 @@
 #define SIZE_IN_HEADER          0
 
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_tb_handle_to_object (
 	u16                             table_id,
 	struct acpi_table_desc          **table_desc);
+#endif
 
 /*
  * tbconvrt - Table conversion routines
diff -Nru a/include/acpi/actbl.h b/include/acpi/actbl.h
--- a/include/acpi/actbl.h	2004-12-24 13:36:49 -08:00
+++ b/include/acpi/actbl.h	2004-12-24 13:36:49 -08:00
@@ -330,6 +330,8 @@
 #include "actbl1.h"   /* Acpi 1.0 table definitions */
 #include "actbl2.h"   /* Acpi 2.0 table definitions */
 
+extern u8 acpi_fadt_is_v1; /* is set to 1 if FADT is revision 1,
+			    * needed for certain workarounds */
 
 #pragma pack(1)
 /*
diff -Nru a/include/acpi/actbl2.h b/include/acpi/actbl2.h
--- a/include/acpi/actbl2.h	2004-12-24 13:37:00 -08:00
+++ b/include/acpi/actbl2.h	2004-12-24 13:37:00 -08:00
@@ -62,6 +62,7 @@
 #define BAF_8042_KEYBOARD_CONTROLLER    0x0002
 
 #define FADT2_REVISION_ID               3
+#define FADT2_MINUS_REVISION_ID         2
 
 
 #pragma pack(1)
@@ -119,48 +120,51 @@
 };
 
 
+#define FADT_REV2_COMMON \
+	u32                             V1_firmware_ctrl;   /* 32-bit physical address of FACS */ \
+	u32                             V1_dsdt;            /* 32-bit physical address of DSDT */ \
+	u8                              reserved1;          /* System Interrupt Model isn't used in ACPI 2.0*/ \
+	u8                              prefer_PM_profile;  /* Conveys preferred power management profile to OSPM. */ \
+	u16                             sci_int;            /* System vector of SCI interrupt */ \
+	u32                             smi_cmd;            /* Port address of SMI command port */ \
+	u8                              acpi_enable;        /* Value to write to smi_cmd to enable ACPI */ \
+	u8                              acpi_disable;       /* Value to write to smi_cmd to disable ACPI */ \
+	u8                              S4bios_req;         /* Value to write to SMI CMD to enter S4BIOS state */ \
+	u8                              pstate_cnt;         /* Processor performance state control*/ \
+	u32                             V1_pm1a_evt_blk;    /* Port address of Power Mgt 1a acpi_event Reg Blk */ \
+	u32                             V1_pm1b_evt_blk;    /* Port address of Power Mgt 1b acpi_event Reg Blk */ \
+	u32                             V1_pm1a_cnt_blk;    /* Port address of Power Mgt 1a Control Reg Blk */ \
+	u32                             V1_pm1b_cnt_blk;    /* Port address of Power Mgt 1b Control Reg Blk */ \
+	u32                             V1_pm2_cnt_blk;     /* Port address of Power Mgt 2 Control Reg Blk */ \
+	u32                             V1_pm_tmr_blk;      /* Port address of Power Mgt Timer Ctrl Reg Blk */ \
+	u32                             V1_gpe0_blk;        /* Port addr of General Purpose acpi_event 0 Reg Blk */ \
+	u32                             V1_gpe1_blk;        /* Port addr of General Purpose acpi_event 1 Reg Blk */ \
+	u8                              pm1_evt_len;        /* Byte length of ports at pm1_x_evt_blk */ \
+	u8                              pm1_cnt_len;        /* Byte length of ports at pm1_x_cnt_blk */ \
+	u8                              pm2_cnt_len;        /* Byte Length of ports at pm2_cnt_blk */ \
+	u8                              pm_tm_len;          /* Byte Length of ports at pm_tm_blk */ \
+	u8                              gpe0_blk_len;       /* Byte Length of ports at gpe0_blk */ \
+	u8                              gpe1_blk_len;       /* Byte Length of ports at gpe1_blk */ \
+	u8                              gpe1_base;          /* Offset in gpe model where gpe1 events start */ \
+	u8                              cst_cnt;            /* Support for the _CST object and C States change notification.*/ \
+	u16                             plvl2_lat;          /* Worst case HW latency to enter/exit C2 state */ \
+	u16                             plvl3_lat;          /* Worst case HW latency to enter/exit C3 state */ \
+	u16                             flush_size;         /* Number of flush strides that need to be read */ \
+	u16                             flush_stride;       /* Processor's memory cache line width, in bytes */ \
+	u8                              duty_offset;        /* Processor's duty cycle index in processor's P_CNT reg*/ \
+	u8                              duty_width;         /* Processor's duty cycle value bit width in P_CNT register.*/ \
+	u8                              day_alrm;           /* Index to day-of-month alarm in RTC CMOS RAM */ \
+	u8                              mon_alrm;           /* Index to month-of-year alarm in RTC CMOS RAM */ \
+	u8                              century;            /* Index to century in RTC CMOS RAM */ \
+	u16                             iapc_boot_arch;     /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/
+
 /*
  * ACPI 2.0 Fixed ACPI Description Table (FADT)
  */
 struct fadt_descriptor_rev2
 {
 	ACPI_TABLE_HEADER_DEF                       /* ACPI common table header */
-	u32                             V1_firmware_ctrl;   /* 32-bit physical address of FACS */
-	u32                             V1_dsdt;            /* 32-bit physical address of DSDT */
-	u8                              reserved1;          /* System Interrupt Model isn't used in ACPI 2.0*/
-	u8                              prefer_PM_profile;  /* Conveys preferred power management profile to OSPM. */
-	u16                             sci_int;            /* System vector of SCI interrupt */
-	u32                             smi_cmd;            /* Port address of SMI command port */
-	u8                              acpi_enable;        /* Value to write to smi_cmd to enable ACPI */
-	u8                              acpi_disable;       /* Value to write to smi_cmd to disable ACPI */
-	u8                              S4bios_req;         /* Value to write to SMI CMD to enter S4BIOS state */
-	u8                              pstate_cnt;         /* Processor performance state control*/
-	u32                             V1_pm1a_evt_blk;    /* Port address of Power Mgt 1a acpi_event Reg Blk */
-	u32                             V1_pm1b_evt_blk;    /* Port address of Power Mgt 1b acpi_event Reg Blk */
-	u32                             V1_pm1a_cnt_blk;    /* Port address of Power Mgt 1a Control Reg Blk */
-	u32                             V1_pm1b_cnt_blk;    /* Port address of Power Mgt 1b Control Reg Blk */
-	u32                             V1_pm2_cnt_blk;     /* Port address of Power Mgt 2 Control Reg Blk */
-	u32                             V1_pm_tmr_blk;      /* Port address of Power Mgt Timer Ctrl Reg Blk */
-	u32                             V1_gpe0_blk;        /* Port addr of General Purpose acpi_event 0 Reg Blk */
-	u32                             V1_gpe1_blk;        /* Port addr of General Purpose acpi_event 1 Reg Blk */
-	u8                              pm1_evt_len;        /* Byte length of ports at pm1_x_evt_blk */
-	u8                              pm1_cnt_len;        /* Byte length of ports at pm1_x_cnt_blk */
-	u8                              pm2_cnt_len;        /* Byte Length of ports at pm2_cnt_blk */
-	u8                              pm_tm_len;          /* Byte Length of ports at pm_tm_blk */
-	u8                              gpe0_blk_len;       /* Byte Length of ports at gpe0_blk */
-	u8                              gpe1_blk_len;       /* Byte Length of ports at gpe1_blk */
-	u8                              gpe1_base;          /* Offset in gpe model where gpe1 events start */
-	u8                              cst_cnt;            /* Support for the _CST object and C States change notification.*/
-	u16                             plvl2_lat;          /* Worst case HW latency to enter/exit C2 state */
-	u16                             plvl3_lat;          /* Worst case HW latency to enter/exit C3 state */
-	u16                             flush_size;         /* Number of flush strides that need to be read */
-	u16                             flush_stride;       /* Processor's memory cache line width, in bytes */
-	u8                              duty_offset;        /* Processor's duty cycle index in processor's P_CNT reg*/
-	u8                              duty_width;         /* Processor's duty cycle value bit width in P_CNT register.*/
-	u8                              day_alrm;           /* Index to day-of-month alarm in RTC CMOS RAM */
-	u8                              mon_alrm;           /* Index to month-of-year alarm in RTC CMOS RAM */
-	u8                              century;            /* Index to century in RTC CMOS RAM */
-	u16                             iapc_boot_arch;     /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/
+	FADT_REV2_COMMON
 	u8                              reserved2;          /* Reserved */
 	u32                             wb_invd     : 1;    /* The wbinvd instruction works properly */
 	u32                             wb_invd_flush : 1;  /* The wbinvd flushes but does not invalidate */
@@ -192,6 +196,20 @@
 	struct acpi_generic_address     xpm_tmr_blk;        /* Extended Power Mgt Timer Ctrl Reg Blk address */
 	struct acpi_generic_address     xgpe0_blk;          /* Extended General Purpose acpi_event 0 Reg Blk address */
 	struct acpi_generic_address     xgpe1_blk;          /* Extended General Purpose acpi_event 1 Reg Blk address */
+};
+
+
+/* "Downrevved" ACPI 2.0 FADT descriptor */
+
+struct fadt_descriptor_rev2_minus
+{
+	ACPI_TABLE_HEADER_DEF                       /* ACPI common table header */
+	FADT_REV2_COMMON
+	u8                              reserved2;          /* Reserved */
+	u32                             flags;
+	struct acpi_generic_address     reset_register;     /* Reset register address in GAS format */
+	u8                              reset_value;        /* Value to write to the reset_register port to reset the system. */
+	u8                              reserved7[3];       /* These three bytes must be zero */
 };
 
 
diff -Nru a/include/acpi/actypes.h b/include/acpi/actypes.h
--- a/include/acpi/actypes.h	2004-12-24 13:36:59 -08:00
+++ b/include/acpi/actypes.h	2004-12-24 13:36:59 -08:00
@@ -303,7 +303,7 @@
 typedef u32                                     acpi_integer;
 #define ACPI_INTEGER_MAX                ACPI_UINT32_MAX
 #define ACPI_INTEGER_BIT_SIZE           32
-#define ACPI_MAX_DECIMAL_DIGITS         10
+#define ACPI_MAX_DECIMAL_DIGITS         10  /* 2^32 = 4,294,967,296 */
 
 #define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 32-bit divide */
 
@@ -315,13 +315,18 @@
 typedef u64                                     acpi_integer;
 #define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
 #define ACPI_INTEGER_BIT_SIZE           64
-#define ACPI_MAX_DECIMAL_DIGITS         19
+#define ACPI_MAX_DECIMAL_DIGITS         20  /* 2^64 = 18,446,744,073,709,551,616 */
+
 
 #if ACPI_MACHINE_WIDTH == 64
 #define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 64-bit divide */
 #endif
 #endif
 
+#define ACPI_MAX64_DECIMAL_DIGITS       20
+#define ACPI_MAX32_DECIMAL_DIGITS       10
+#define ACPI_MAX16_DECIMAL_DIGITS        5
+#define ACPI_MAX8_DECIMAL_DIGITS         3
 
 /*
  * Constants with special meanings
@@ -830,6 +835,14 @@
 	u32                                 function);
 
 #define ACPI_INIT_DEVICE_INI        1
+
+typedef
+acpi_status (*acpi_exception_handler) (
+	acpi_status                     aml_status,
+	acpi_name                       name,
+	u16                             opcode,
+	u32                             aml_offset,
+	void                            *context);
 
 
 /* Address Spaces (For Operation Regions) */
diff -Nru a/include/acpi/acutils.h b/include/acpi/acutils.h
--- a/include/acpi/acutils.h	2004-12-24 13:36:17 -08:00
+++ b/include/acpi/acutils.h	2004-12-24 13:36:17 -08:00
@@ -178,6 +178,12 @@
 	acpi_size                       count);
 
 int
+acpi_ut_memcmp (
+	const char                      *buffer1,
+	const char                      *buffer2,
+	acpi_size                       count);
+
+int
 acpi_ut_strncmp (
 	const char                      *string1,
 	const char                      *string2,
@@ -577,6 +583,10 @@
 acpi_ut_create_buffer_object (
 	acpi_size                       buffer_size);
 
+union acpi_operand_object *
+acpi_ut_create_string_object (
+	acpi_size                       string_size);
+
 
 /*
  * ut_ref_cnt - Object reference count management
@@ -656,12 +666,14 @@
 	u16                             action,
 	union acpi_generic_state        **state_list);
 
+#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_ut_create_pkg_state_and_push (
 	void                            *internal_object,
 	void                            *external_object,
 	u16                             index,
 	union acpi_generic_state        **state_list);
+#endif
 
 union acpi_generic_state *
 acpi_ut_create_control_state (
@@ -690,14 +702,14 @@
 
 acpi_status
 acpi_ut_divide (
-	acpi_integer                    *in_dividend,
-	acpi_integer                    *in_divisor,
+	acpi_integer                    in_dividend,
+	acpi_integer                    in_divisor,
 	acpi_integer                    *out_quotient,
 	acpi_integer                    *out_remainder);
 
 acpi_status
 acpi_ut_short_divide (
-	acpi_integer                    *in_dividend,
+	acpi_integer                    in_dividend,
 	u32                             divisor,
 	acpi_integer                    *out_quotient,
 	u32                             *out_remainder);
@@ -716,9 +728,15 @@
 	u32                             base,
 	acpi_integer                    *ret_integer);
 
+/* Values for Base above (16=Hex, 10=Decimal) */
+
+#define ACPI_ANY_BASE        0
+
+#ifdef ACPI_FUTURE_USAGE
 char *
 acpi_ut_strupr (
 	char                            *src_string);
+#endif
 
 u8 *
 acpi_ut_get_resource_end_tag (
@@ -837,9 +855,11 @@
 	char                            *module,
 	u32                             line);
 
+#ifdef ACPI_FUTURE_USAGE
 void
 acpi_ut_dump_allocation_info (
 	void);
+#endif
 
 void
 acpi_ut_dump_allocations (
diff -Nru a/include/acpi/amlcode.h b/include/acpi/amlcode.h
--- a/include/acpi/amlcode.h	2004-12-24 13:37:01 -08:00
+++ b/include/acpi/amlcode.h	2004-12-24 13:37:01 -08:00
@@ -170,6 +170,7 @@
 #define AML_REVISION_OP             (u16) 0x5b30
 #define AML_DEBUG_OP                (u16) 0x5b31
 #define AML_FATAL_OP                (u16) 0x5b32
+#define AML_TIMER_OP                (u16) 0x5b33     /* ACPI 3.0 */
 #define AML_REGION_OP               (u16) 0x5b80
 #define AML_FIELD_OP                (u16) 0x5b81
 #define AML_DEVICE_OP               (u16) 0x5b82
@@ -305,22 +306,24 @@
 
 /* Opcode flags */
 
-#define AML_HAS_ARGS                0x0800
-#define AML_HAS_TARGET              0x0400
-#define AML_HAS_RETVAL              0x0200
-#define AML_NSOBJECT                0x0100
-#define AML_NSOPCODE                0x0080
-#define AML_NSNODE                  0x0040
-#define AML_NAMED                   0x0020
-#define AML_DEFER                   0x0010
-#define AML_FIELD                   0x0008
-#define AML_CREATE                  0x0004
-#define AML_MATH                    0x0002
 #define AML_LOGICAL                 0x0001
-#define AML_CONSTANT                0x1000
+#define AML_LOGICAL_NUMERIC         0x0002
+#define AML_MATH                    0x0004
+#define AML_CREATE                  0x0008
+#define AML_FIELD                   0x0010
+#define AML_DEFER                   0x0020
+#define AML_NAMED                   0x0040
+#define AML_NSNODE                  0x0080
+#define AML_NSOPCODE                0x0100
+#define AML_NSOBJECT                0x0200
+#define AML_HAS_RETVAL              0x0400
+#define AML_HAS_TARGET              0x0800
+#define AML_HAS_ARGS                0x1000
+#define AML_CONSTANT                0x2000
 
 /* Convenient flag groupings */
 
+#define AML_FLAGS_EXEC_0A_0T_1R                                     AML_HAS_RETVAL
 #define AML_FLAGS_EXEC_1A_0T_0R     AML_HAS_ARGS                                   /* Monadic1  */
 #define AML_FLAGS_EXEC_1A_0T_1R     AML_HAS_ARGS |                  AML_HAS_RETVAL /* Monadic2  */
 #define AML_FLAGS_EXEC_1A_1T_0R     AML_HAS_ARGS | AML_HAS_TARGET
@@ -338,17 +341,18 @@
  * The opcode Type is used in a dispatch table, do not change
  * without updating the table.
  */
-#define AML_TYPE_EXEC_1A_0T_0R      0x00 /* Monadic1  */
-#define AML_TYPE_EXEC_1A_0T_1R      0x01 /* Monadic2  */
-#define AML_TYPE_EXEC_1A_1T_0R      0x02
-#define AML_TYPE_EXEC_1A_1T_1R      0x03 /* monadic2_r */
-#define AML_TYPE_EXEC_2A_0T_0R      0x04 /* Dyadic1   */
-#define AML_TYPE_EXEC_2A_0T_1R      0x05 /* Dyadic2   */
-#define AML_TYPE_EXEC_2A_1T_1R      0x06 /* dyadic2_r  */
-#define AML_TYPE_EXEC_2A_2T_1R      0x07
-#define AML_TYPE_EXEC_3A_0T_0R      0x08
-#define AML_TYPE_EXEC_3A_1T_1R      0x09
-#define AML_TYPE_EXEC_6A_0T_1R      0x0A
+#define AML_TYPE_EXEC_0A_0T_1R      0x00
+#define AML_TYPE_EXEC_1A_0T_0R      0x01 /* Monadic1  */
+#define AML_TYPE_EXEC_1A_0T_1R      0x02 /* Monadic2  */
+#define AML_TYPE_EXEC_1A_1T_0R      0x03
+#define AML_TYPE_EXEC_1A_1T_1R      0x04 /* monadic2_r */
+#define AML_TYPE_EXEC_2A_0T_0R      0x05 /* Dyadic1   */
+#define AML_TYPE_EXEC_2A_0T_1R      0x06 /* Dyadic2   */
+#define AML_TYPE_EXEC_2A_1T_1R      0x07 /* dyadic2_r  */
+#define AML_TYPE_EXEC_2A_2T_1R      0x08
+#define AML_TYPE_EXEC_3A_0T_0R      0x09
+#define AML_TYPE_EXEC_3A_1T_1R      0x0A
+#define AML_TYPE_EXEC_6A_0T_1R      0x0B
 /* End of types used in dispatch table */
 
 #define AML_TYPE_LITERAL            0x0B
diff -Nru a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h
--- a/include/acpi/amlresrc.h	2004-12-24 13:37:29 -08:00
+++ b/include/acpi/amlresrc.h	2004-12-24 13:37:29 -08:00
@@ -99,7 +99,7 @@
 /*
  * Resource descriptors defined in the ACPI specification.
  *
- * Alignment must be BYTE because these descriptors
+ * Packing/alignment must be BYTE because these descriptors
  * are used to overlay the AML byte stream.
  */
 #pragma pack(1)
@@ -297,7 +297,7 @@
 
 #pragma pack()
 
-/* Union of all resource descriptors, sow we can allocate the worst case */
+/* Union of all resource descriptors, so we can allocate the worst case */
 
 union asl_resource_desc
 {
diff -Nru a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
--- a/include/acpi/platform/acenv.h	2004-12-24 13:36:31 -08:00
+++ b/include/acpi/platform/acenv.h	2004-12-24 13:36:31 -08:00
@@ -223,7 +223,11 @@
  */
 
 #define ACPI_STRSTR(s1,s2)      strstr((s1), (s2))
+
+#ifdef ACPI_FUTURE_USAGE
 #define ACPI_STRUPR(s)          (void) acpi_ut_strupr ((s))
+#endif
+
 #define ACPI_STRLEN(s)          (acpi_size) strlen((s))
 #define ACPI_STRCPY(d,s)        (void) strcpy((d), (s))
 #define ACPI_STRNCPY(d,s,n)     (void) strncpy((d), (s), (acpi_size)(n))
@@ -232,6 +236,7 @@
 #define ACPI_STRCAT(d,s)        (void) strcat((d), (s))
 #define ACPI_STRNCAT(d,s,n)     strncat((d), (s), (acpi_size)(n))
 #define ACPI_STRTOUL(d,s,n)     strtoul((d), (s), (acpi_size)(n))
+#define ACPI_MEMCMP(s1,s2,n)    memcmp((s1), (s2), (acpi_size)(n))
 #define ACPI_MEMCPY(d,s,n)      (void) memcpy((d), (s), (acpi_size)(n))
 #define ACPI_MEMSET(d,s,n)      (void) memset((d), (s), (acpi_size)(n))
 
@@ -286,7 +291,11 @@
 
 
 #define ACPI_STRSTR(s1,s2)      acpi_ut_strstr ((s1), (s2))
+
+#ifdef ACPI_FUTURE_USAGE
 #define ACPI_STRUPR(s)          (void) acpi_ut_strupr ((s))
+#endif
+
 #define ACPI_STRLEN(s)          (acpi_size) acpi_ut_strlen ((s))
 #define ACPI_STRCPY(d,s)        (void) acpi_ut_strcpy ((d), (s))
 #define ACPI_STRNCPY(d,s,n)     (void) acpi_ut_strncpy ((d), (s), (acpi_size)(n))
@@ -295,6 +304,7 @@
 #define ACPI_STRCAT(d,s)        (void) acpi_ut_strcat ((d), (s))
 #define ACPI_STRNCAT(d,s,n)     acpi_ut_strncat ((d), (s), (acpi_size)(n))
 #define ACPI_STRTOUL(d,s,n)     acpi_ut_strtoul ((d), (s), (acpi_size)(n))
+#define ACPI_MEMCMP(s1,s2,n)    acpi_ut_memcmp((s1), (s2), (acpi_size)(n))
 #define ACPI_MEMCPY(d,s,n)      (void) acpi_ut_memcpy ((d), (s), (acpi_size)(n))
 #define ACPI_MEMSET(d,v,n)      (void) acpi_ut_memset ((d), (v), (acpi_size)(n))
 #define ACPI_TOUPPER            acpi_ut_to_upper
diff -Nru a/include/acpi/processor.h b/include/acpi/processor.h
--- a/include/acpi/processor.h	2004-12-24 13:36:48 -08:00
+++ b/include/acpi/processor.h	2004-12-24 13:36:48 -08:00
@@ -17,7 +17,7 @@
 
 struct acpi_processor_cx_policy {
 	u32			count;
-	int			state;
+	u32			state;
 	struct {
 		u32			time;
 		u32			ticks;
@@ -38,8 +38,8 @@
 };
 
 struct acpi_processor_power {
-	int			state;
-	int			default_state;
+	u32			state;
+	u32			default_state;
 	u32			bm_activity;
 	struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
 };
@@ -139,5 +139,9 @@
 extern void acpi_processor_unregister_performance (
 	struct acpi_processor_performance * performance,
 	unsigned int cpu);
+
+/* note: this locks both the calling module and the processor module
+         if a _PPC object exists, rmmod is disallowed then */
+int acpi_processor_notify_smm(struct module *calling_module);
 
 #endif
diff -Nru a/include/asm-alpha/core_cia.h b/include/asm-alpha/core_cia.h
--- a/include/asm-alpha/core_cia.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-alpha/core_cia.h	2004-12-24 13:36:55 -08:00
@@ -347,14 +347,14 @@
 	unsigned long addr = (unsigned long) xaddr;
 	unsigned long result, base_and_type;
 
-	/* We can use CIA_MEM_R1_MASK for io ports too, since it is large
-	   enough to cover all io ports, and smaller than CIA_IO.  */
-	addr &= CIA_MEM_R1_MASK;
 	if (addr >= CIA_DENSE_MEM)
 		base_and_type = CIA_SPARSE_MEM + 0x00;
 	else
 		base_and_type = CIA_IO + 0x00;
 
+	/* We can use CIA_MEM_R1_MASK for io ports too, since it is large
+	   enough to cover all io ports, and smaller than CIA_IO.  */
+	addr &= CIA_MEM_R1_MASK;
 	result = *(vip) ((addr << 5) + base_and_type);
 	return __kernel_extbl(result, addr & 3);
 }
@@ -364,12 +364,12 @@
 	unsigned long addr = (unsigned long) xaddr;
 	unsigned long w, base_and_type;
 
-	addr &= CIA_MEM_R1_MASK;
 	if (addr >= CIA_DENSE_MEM)
 		base_and_type = CIA_SPARSE_MEM + 0x00;
 	else
 		base_and_type = CIA_IO + 0x00;
 
+	addr &= CIA_MEM_R1_MASK;
 	w = __kernel_insbl(b, addr & 3);
 	*(vuip) ((addr << 5) + base_and_type) = w;
 }
@@ -379,12 +379,12 @@
 	unsigned long addr = (unsigned long) xaddr;
 	unsigned long result, base_and_type;
 
-	addr &= CIA_MEM_R1_MASK;
 	if (addr >= CIA_DENSE_MEM)
 		base_and_type = CIA_SPARSE_MEM + 0x08;
 	else
 		base_and_type = CIA_IO + 0x08;
 
+	addr &= CIA_MEM_R1_MASK;
 	result = *(vip) ((addr << 5) + base_and_type);
 	return __kernel_extwl(result, addr & 3);
 }
@@ -394,12 +394,12 @@
 	unsigned long addr = (unsigned long) xaddr;
 	unsigned long w, base_and_type;
 
-	addr &= CIA_MEM_R1_MASK;
 	if (addr >= CIA_DENSE_MEM)
 		base_and_type = CIA_SPARSE_MEM + 0x08;
 	else
 		base_and_type = CIA_IO + 0x08;
 
+	addr &= CIA_MEM_R1_MASK;
 	w = __kernel_inswl(b, addr & 3);
 	*(vuip) ((addr << 5) + base_and_type) = w;
 }
diff -Nru a/include/asm-alpha/errno.h b/include/asm-alpha/errno.h
--- a/include/asm-alpha/errno.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-alpha/errno.h	2004-12-24 13:36:47 -08:00
@@ -110,5 +110,10 @@
 
 #define ENOMEDIUM	129	/* No medium found */
 #define EMEDIUMTYPE	130	/* Wrong medium type */
+#define	ECANCELED	131	/* Operation Cancelled */
+#define	ENOKEY		132	/* Required key not available */
+#define	EKEYEXPIRED	133	/* Key has expired */
+#define	EKEYREVOKED	134	/* Key has been revoked */
+#define	EKEYREJECTED	135	/* Key was rejected by service */
 
 #endif
diff -Nru a/include/asm-alpha/hardirq.h b/include/asm-alpha/hardirq.h
--- a/include/asm-alpha/hardirq.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-alpha/hardirq.h	2004-12-24 13:37:00 -08:00
@@ -16,28 +16,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-27 are the hardirq count (max # of hardirqs: 4096)
- *
- * - ( bit 30 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x0fff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	12
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have
diff -Nru a/include/asm-alpha/io.h b/include/asm-alpha/io.h
--- a/include/asm-alpha/io.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-alpha/io.h	2004-12-24 13:37:19 -08:00
@@ -282,6 +282,12 @@
 	return IO_CONCAT(__IO_PREFIX,ioremap) (port, size);
 }
 
+static inline void __iomem *__ioremap(unsigned long port, unsigned long size,
+				      unsigned long flags)
+{
+	return ioremap(port, size);
+}
+
 static inline void __iomem * ioremap_nocache(unsigned long offset,
 					     unsigned long size)
 {
@@ -489,6 +495,8 @@
 #define readl_relaxed(addr) __raw_readl(addr)
 #define readq_relaxed(addr) __raw_readq(addr)
 
+#define mmiowb()
+
 /*
  * String version of IO memory access ops:
  */
@@ -623,16 +631,6 @@
 	iounmap(addr);
 }
 
-static inline int
-isa_check_signature(unsigned long offset, const unsigned char *sig, long len)
-{
-	void __iomem *addr = ioremap(offset, len);
-	int ret = check_signature(addr, sig, len);
-	iounmap(addr);
-	return ret;
-}
-
-
 /*
  * The Alpha Jensen hardware for some rather strange reason puts
  * the RTC clock at 0x170 instead of 0x70. Probably due to some
@@ -657,6 +655,16 @@
 #define dma_cache_inv(_start,_size)		do { } while (0)
 #define dma_cache_wback(_start,_size)		do { } while (0)
 #define dma_cache_wback_inv(_start,_size)	do { } while (0)
+
+/*
+ * Some mucking forons use if[n]def writeq to check if platform has it.
+ * It's a bloody bad idea and we probably want ARCH_HAS_WRITEQ for them
+ * to play with; for now just use cpp anti-recursion logics and make sure
+ * that damn thing is defined and expands to itself.
+ */
+
+#define writeq writeq
+#define readq readq
 
 #endif /* __KERNEL__ */
 
diff -Nru a/include/asm-alpha/mmzone.h b/include/asm-alpha/mmzone.h
--- a/include/asm-alpha/mmzone.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-alpha/mmzone.h	2004-12-24 13:37:19 -08:00
@@ -107,7 +107,7 @@
 
 #define pfn_to_page(pfn)						\
 ({									\
- 	unsigned long kaddr = (unsigned long)__va(pfn << PAGE_SHIFT);	\
+ 	unsigned long kaddr = (unsigned long)__va((pfn) << PAGE_SHIFT);	\
 	(node_mem_map(kvaddr_to_nid(kaddr)) + local_mapnr(kaddr));	\
 })
 
@@ -119,7 +119,7 @@
 	((( (page) - page_zone(page)->zone_mem_map )			\
 	+ page_zone(page)->zone_start_pfn) << PAGE_SHIFT)
 
-#define pfn_to_nid(pfn)		pa_to_nid(((u64)pfn << PAGE_SHIFT))
+#define pfn_to_nid(pfn)		pa_to_nid(((u64)(pfn) << PAGE_SHIFT))
 #define pfn_valid(pfn)							\
 	(((pfn) - node_start_pfn(pfn_to_nid(pfn))) <			\
 	 node_spanned_pages(pfn_to_nid(pfn)))					\
diff -Nru a/include/asm-alpha/pgtable.h b/include/asm-alpha/pgtable.h
--- a/include/asm-alpha/pgtable.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-alpha/pgtable.h	2004-12-24 13:36:31 -08:00
@@ -327,8 +327,12 @@
 #define kern_addr_valid(addr)	(1)
 #endif
 
-#define io_remap_page_range(vma, start, busaddr, size, prot) \
-    remap_page_range(vma, start, virt_to_phys((void *)__ioremap(busaddr, size)), size, prot)
+#define io_remap_page_range(vma, start, busaddr, size, prot)	\
+({								\
+	void *va = (void __force *)ioremap(busaddr, size);	\
+	unsigned long pfn = virt_to_phys(va) >> PAGE_SHIFT;	\
+	remap_pfn_range(vma, start, pfn, size, prot);		\
+})
 
 #define pte_ERROR(e) \
 	printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
diff -Nru a/include/asm-alpha/topology.h b/include/asm-alpha/topology.h
--- a/include/asm-alpha/topology.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-alpha/topology.h	2004-12-24 13:36:31 -08:00
@@ -39,9 +39,6 @@
 	return node_cpu_mask;
 }
 
-/* Cross-node load balancing interval. */
-# define NODE_BALANCE_RATE 10
-
 #define pcibus_to_cpumask(bus)	(cpu_online_map)
 
 #else /* CONFIG_NUMA */
diff -Nru a/include/asm-arm/arch-cl7500/serial.h b/include/asm-arm/arch-cl7500/serial.h
--- a/include/asm-arm/arch-cl7500/serial.h	2004-12-24 13:36:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,47 +0,0 @@
-/*
- * linux/include/asm-arm/arch-cl7500/serial.h
- *
- * Copyright (c) 1996 Russell King.
- * Copyright (C) 1999 Nexus Electronics Ltd.
- *
- * Changelog:
- *  15-10-1996	RMK	Created
- *  10-08-1999	PJB	Added COM3/COM4 for CL7500
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-#include <asm/arch/hardware.h>
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1843200 / 16)
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-	{ 0, BASE_BAUD, 0x3F8, 10, STD_COM_FLAGS },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0x2F8,  0, STD_COM_FLAGS },	/* ttyS1 */     \
-        /* ISA Slot Serial ports */ \
-	{ 0, BASE_BAUD, ISASLOT_IO + 0x2e8,  41, STD_COM_FLAGS },	/* ttyS2 */	\
-	{ 0, BASE_BAUD, ISASLOT_IO + 0x3e8,  40, STD_COM_FLAGS },	/* ttyS3 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS }, 	/* ttyS4 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS5 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS6 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS7 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS8 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS9 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS10 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS11 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS12 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS13 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
diff -Nru a/include/asm-arm/arch-clps711x/io.h b/include/asm-arm/arch-clps711x/io.h
--- a/include/asm-arm/arch-clps711x/io.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-arm/arch-clps711x/io.h	2004-12-24 13:37:02 -08:00
@@ -22,9 +22,9 @@
 
 #define IO_SPACE_LIMIT 0xffffffff
 
-#define __io(a)			((a))
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		((unsigned long)(a))
+#define __io(a)			((void __iomem *)(a))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		(a)
 
 /*
  * We don't support ins[lb]/outs[lb].  Make them fault.
diff -Nru a/include/asm-arm/arch-clps711x/time.h b/include/asm-arm/arch-clps711x/time.h
--- a/include/asm-arm/arch-clps711x/time.h	2004-12-24 13:37:32 -08:00
+++ b/include/asm-arm/arch-clps711x/time.h	2004-12-24 13:37:32 -08:00
@@ -30,6 +30,9 @@
 {
 	do_leds();
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	do_profile(regs);
 	return IRQ_HANDLED;
 }
diff -Nru a/include/asm-arm/arch-ebsa110/io.h b/include/asm-arm/arch-ebsa110/io.h
--- a/include/asm-arm/arch-ebsa110/io.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-arm/arch-ebsa110/io.h	2004-12-24 13:37:01 -08:00
@@ -27,13 +27,13 @@
 u32 __inl(unsigned int port);
 void __outl(u32 val, unsigned int port);
 
-u8  __readb(void *addr);
-u16 __readw(void *addr);
-u32 __readl(void *addr);
-
-void __writeb(u8  val, void *addr);
-void __writew(u16 val, void *addr);
-void __writel(u32 val, void *addr);
+u8  __readb(void __iomem *addr);
+u16 __readw(void __iomem *addr);
+u32 __readl(void __iomem *addr);
+
+void __writeb(u8  val, void __iomem *addr);
+void __writew(u16 val, void __iomem *addr);
+void __writel(u32 val, void __iomem *addr);
 
 /*
  * Argh, someone forgot the IOCS16 line.  We therefore have to handle
@@ -64,7 +64,7 @@
 #define writew(v,b)		__writew(v,b)
 #define writel(v,b)		__writel(v,b)
 
-#define __arch_ioremap(cookie,sz,c,a)	((void *)(cookie))
+#define __arch_ioremap(cookie,sz,c,a)	((void __iomem *)(cookie))
 #define __arch_iounmap(cookie)		do { } while (0)
 
 extern void insb(unsigned int port, void *buf, int sz);
diff -Nru a/include/asm-arm/arch-ebsa110/serial.h b/include/asm-arm/arch-ebsa110/serial.h
--- a/include/asm-arm/arch-ebsa110/serial.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,35 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-ebsa110/serial.h
- *
- *  Copyright (C) 1996,1997,1998 Russell King.
- *
- * 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.
- *
- *  Changelog:
- *   15-10-1996	RMK	Created
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1843200 / 16)
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-	{ 0, BASE_BAUD, 0x3F8,  1, STD_COM_FLAGS },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0x2F8,  2, STD_COM_FLAGS }	/* ttyS1 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
-
diff -Nru a/include/asm-arm/arch-ebsa285/io.h b/include/asm-arm/arch-ebsa285/io.h
--- a/include/asm-arm/arch-ebsa285/io.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-arm/arch-ebsa285/io.h	2004-12-24 13:36:31 -08:00
@@ -19,25 +19,27 @@
 /*
  * Translation of various region addresses to virtual addresses
  */
-#define __io(a)			(PCIO_BASE + (a))
+#define __io(a)			((void __iomem *)(PCIO_BASE + (a)))
 #if 1
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		(PCIMEM_BASE + (unsigned long)(a))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		((a) + PCIMEM_BASE)
 #else
 
-static inline unsigned long ___mem_pci(unsigned long a)
+static inline void __iomem *___mem_pci(void __iomem *p)
 {
+	unsigned long a = (unsigned long)p;
 	BUG_ON(a <= 0xc0000000 || a >= 0xe0000000);
-	return a;
+	return p;
 }
 
-static inline unsigned long ___mem_isa(unsigned long a)
+static inline void __iomem *___mem_isa(void __iomem *p)
 {
+	unsigned long a = (unsigned long)p;
 	BUG_ON(a >= 16*1048576);
-	return PCIMEM_BASE + a;
+	return p + PCIMEM_BASE;
 }
-#define __mem_pci(a)		___mem_pci((unsigned long)(a))
-#define __mem_isa(a)		___mem_isa((unsigned long)(a))
+#define __mem_pci(a)		___mem_pci(a)
+#define __mem_isa(a)		___mem_isa(a)
 #endif
 
 #endif
diff -Nru a/include/asm-arm/arch-ebsa285/serial.h b/include/asm-arm/arch-ebsa285/serial.h
--- a/include/asm-arm/arch-ebsa285/serial.h	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,40 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-ebsa285/serial.h
- *
- *  Copyright (C) 1996,1997,1998 Russell King.
- *
- * 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.
- *
- *  Changelog:
- *   15-10-1996	RMK	Created
- *   25-05-1998	PJB	CATS support
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-#include <asm/irq.h>
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1843200 / 16)
-
-#define _SER_IRQ0	IRQ_ISA_UART
-#define _SER_IRQ1	IRQ_ISA_UART2
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-	{ 0, BASE_BAUD, 0x3F8, _SER_IRQ0, STD_COM_FLAGS },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0x2F8, _SER_IRQ1, STD_COM_FLAGS },	/* ttyS1 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
diff -Nru a/include/asm-arm/arch-epxa10db/io.h b/include/asm-arm/arch-epxa10db/io.h
--- a/include/asm-arm/arch-epxa10db/io.h	2004-12-24 13:37:30 -08:00
+++ b/include/asm-arm/arch-epxa10db/io.h	2004-12-24 13:37:30 -08:00
@@ -33,7 +33,7 @@
 #define insw    __arch_readsw
 #define insl    __arch_readsl*/
 
-#define __io(a)			(a)
+#define __io(a)			((void __iomem *)(a))
 #define __mem_pci(a)            (a) 
 
 #endif
diff -Nru a/include/asm-arm/arch-epxa10db/serial.h b/include/asm-arm/arch-epxa10db/serial.h
--- a/include/asm-arm/arch-epxa10db/serial.h	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,48 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-epxa10db/serial.h
- *
- *  Copyright (C) 1999 ARM Limited
- *  Copyright (C) 2001 Altera Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-#include <asm/arch/platform.h>
-#include <asm/irq.h>
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1 / 16)
-
-#define _SER_IRQ0	IRQ_UARTINT0
-#define _SER_IRQ1	IRQ_UARTINT1
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-	{ 0, BASE_BAUD, 0x3F8, _SER_IRQ0, STD_COM_FLAGS },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0x2F8, _SER_IRQ1, STD_COM_FLAGS },	/* ttyS1 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
diff -Nru a/include/asm-arm/arch-h720x/io.h b/include/asm-arm/arch-h720x/io.h
--- a/include/asm-arm/arch-h720x/io.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-h720x/io.h	2004-12-24 13:36:17 -08:00
@@ -18,7 +18,7 @@
 
 #define IO_SPACE_LIMIT 0xffffffff
 
-#define __io(a) (a)
-#define __mem_pci(a) (a)
+#define __io(a)		((void __iomem *)(a))
+#define __mem_pci(a)	(a)
 
 #endif
diff -Nru a/include/asm-arm/arch-h720x/serial.h b/include/asm-arm/arch-h720x/serial.h
--- a/include/asm-arm/arch-h720x/serial.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,101 +0,0 @@
-/*
- * linux/include/asm-arm/arch-h72x/serial.h
- *
- * Copyright (C) 2003 Thomas Gleixner <tglx@linutronix.de>
- *               2003 Robert Schwebel <r.schwebel@pengutronix.de>
- *
- * Serial port setup for Hynix boards
- *
- * 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.
- *
- */
-
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-#include <asm/arch/irqs.h>
-
-/*
- * Standard COM flags
- */
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-#define RS_TABLE_SIZE
-
-/* Base clock is 3.6864 MHz */
-#define BASE_BAUD       (115200*2)
-#define EXTRA_SERIAL_PORT_DEFNS
-
-/*
- * Board dependend defines
- */
-#if defined (CONFIG_CPU_H7201)
-#define BASE_BAUD_P3C 	(115200)
-
-#define STD_SERIAL_PORT_DEFNS \
-	{ \
-	.baud_base	= BASE_BAUD, \
-	.port		= SERIAL0_BASE, \
-	.iomem_base     = (u8*)SERIAL0_BASE, \
-	.io_type        = UPIO_MEM, \
-	.irq		= IRQ_UART0, \
-	.flags		= STD_COM_FLAGS, \
-	.iomem_reg_shift = 2,\
-	}, \
-	{ \
-	.baud_base	= BASE_BAUD, \
-	.port		= SERIAL1_BASE, \
-	.iomem_base     = (u8*)SERIAL1_BASE, \
-	.io_type        = UPIO_MEM, \
-	.irq		= IRQ_UART1, \
-	.flags		= STD_COM_FLAGS, \
-	.iomem_reg_shift = 2,\
-	}
-
-#elif defined (CONFIG_CPU_H7202)
-
-#define STD_SERIAL_PORT_DEFNS \
-	{ \
-	.baud_base	= BASE_BAUD, \
-	.port		= SERIAL0_BASE, \
-	.iomem_base     = (u8*)SERIAL0_BASE, \
-	.io_type        = UPIO_MEM, \
-	.irq		= IRQ_UART0, \
-	.flags		= STD_COM_FLAGS, \
-	.iomem_reg_shift = 2,\
-	}, \
-	{ \
-	.baud_base	= BASE_BAUD, \
-	.port		= SERIAL1_BASE, \
-	.iomem_base     = (u8*)SERIAL1_BASE, \
-	.io_type        = UPIO_MEM, \
-	.irq		= IRQ_UART1, \
-	.flags		= STD_COM_FLAGS, \
-	.iomem_reg_shift = 2,\
-	}, \
-	{ \
-	.baud_base	= BASE_BAUD, \
-	.port		= SERIAL2_BASE, \
-	.iomem_base     = (u8*)SERIAL2_BASE, \
-	.io_type        = UPIO_MEM, \
-	.irq		= IRQ_UART2, \
-	.flags		= STD_COM_FLAGS, \
-	.iomem_reg_shift = 2,\
-	}, \
-	{ \
-	.baud_base	= BASE_BAUD, \
-	.port		= SERIAL3_BASE, \
-	.iomem_base     = (u8*)SERIAL3_BASE, \
-	.io_type        = UPIO_MEM, \
-	.irq		= IRQ_UART3, \
-	.flags		= STD_COM_FLAGS, \
-	.iomem_reg_shift = 2,\
-	}
-
-#else
-#error machine definition mismatch
-#endif
-
-/* __ASM_ARCH_SERIAL_H */
-#endif
diff -Nru a/include/asm-arm/arch-imx/io.h b/include/asm-arm/arch-imx/io.h
--- a/include/asm-arm/arch-imx/io.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-arm/arch-imx/io.h	2004-12-24 13:37:04 -08:00
@@ -22,7 +22,7 @@
 
 #define IO_SPACE_LIMIT 0xffffffff
 
-#define __io(a)       (a)
-#define __mem_pci(a)  (a)
+#define __io(a)		((void __iomem *)(a))
+#define __mem_pci(a)	(a)
 
 #endif
diff -Nru a/include/asm-arm/arch-imx/serial.h b/include/asm-arm/arch-imx/serial.h
--- a/include/asm-arm/arch-imx/serial.h	2004-12-24 13:36:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,26 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-imx/serial.h
- *
- *  Copyright (C) 1999 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-#define STD_SERIAL_PORT_DEFNS
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif /* __ASM_ARCH_SERIAL_H */
diff -Nru a/include/asm-arm/arch-integrator/io.h b/include/asm-arm/arch-integrator/io.h
--- a/include/asm-arm/arch-integrator/io.h	2004-12-24 13:36:33 -08:00
+++ b/include/asm-arm/arch-integrator/io.h	2004-12-24 13:36:33 -08:00
@@ -22,8 +22,8 @@
 
 #define IO_SPACE_LIMIT 0xffff
 
-#define __io(a)			(PCI_IO_VADDR + (a))
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		(PCI_MEMORY_VADDR + (unsigned long)(a))
+#define __io(a)			((void __iomem *)(PCI_IO_VADDR + (a)))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		((a) + PCI_MEMORY_VADDR)
 
 #endif
diff -Nru a/include/asm-arm/arch-integrator/platform.h b/include/asm-arm/arch-integrator/platform.h
--- a/include/asm-arm/arch-integrator/platform.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-arm/arch-integrator/platform.h	2004-12-24 13:36:55 -08:00
@@ -457,10 +457,6 @@
 #define mSEC_25                         (mSEC_1 * 25)
 #define SEC_1                           (mSEC_1 * 1000)
 
-#ifndef __ASSEMBLY__
-extern void integrator_time_init(unsigned long, unsigned int);
-#endif
-
 #define INTEGRATOR_CSR_BASE             0x10000000
 #define INTEGRATOR_CSR_SIZE             0x10000000
 
diff -Nru a/include/asm-arm/arch-integrator/serial.h b/include/asm-arm/arch-integrator/serial.h
--- a/include/asm-arm/arch-integrator/serial.h	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,47 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-integrator/serial.h
- *
- *  Copyright (C) 1999 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-#include <asm/arch/platform.h>
-#include <asm/irq.h>
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1843200 / 16)
-
-#define _SER_IRQ0	IRQ_UARTINT0
-#define _SER_IRQ1	IRQ_UARTINT1
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-	{ 0, BASE_BAUD, 0x3F8, _SER_IRQ0, STD_COM_FLAGS },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0x2F8, _SER_IRQ1, STD_COM_FLAGS },	/* ttyS1 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
diff -Nru a/include/asm-arm/arch-integrator/time.h b/include/asm-arm/arch-integrator/time.h
--- a/include/asm-arm/arch-integrator/time.h	2004-12-24 13:37:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,156 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-integrator/time.h
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include <asm/system.h>
-#include <asm/leds.h>
-#include <asm/mach-types.h>
-
-/*
- * Where is the timer (VA)?
- */
-#define TIMER0_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000000)
-#define TIMER1_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000100)
-#define TIMER2_VA_BASE (IO_ADDRESS(INTEGRATOR_CT_BASE)+0x00000200)
-#define VA_IC_BASE     IO_ADDRESS(INTEGRATOR_IC_BASE) 
-
-/*
- * How long is the timer interval?
- */
-#define TIMER_INTERVAL	(TICKS_PER_uSEC * mSEC_10)
-#if TIMER_INTERVAL >= 0x100000
-#define TICKS2USECS(x)	(256 * (x) / TICKS_PER_uSEC)
-#elif TIMER_INTERVAL >= 0x10000
-#define TICKS2USECS(x)	(16 * (x) / TICKS_PER_uSEC)
-#else
-#define TICKS2USECS(x)	((x) / TICKS_PER_uSEC)
-#endif
-
-#define TIMER_CTRL_IE	(1 << 5)			/* Interrupt Enable */
-
-/*
- * What does it look like?
- */
-typedef struct TimerStruct {
-	unsigned long TimerLoad;
-	unsigned long TimerValue;
-	unsigned long TimerControl;
-	unsigned long TimerClear;
-} TimerStruct_t;
-
-extern unsigned long (*gettimeoffset)(void);
-
-static unsigned long timer_reload;
-
-/*
- * Returns number of ms since last clock interrupt.  Note that interrupts
- * will have been disabled by do_gettimeoffset()
- */
-static unsigned long integrator_gettimeoffset(void)
-{
-	volatile TimerStruct_t *timer1 = (TimerStruct_t *)TIMER1_VA_BASE;
-	unsigned long ticks1, ticks2, status;
-
-	/*
-	 * Get the current number of ticks.  Note that there is a race
-	 * condition between us reading the timer and checking for
-	 * an interrupt.  We get around this by ensuring that the
-	 * counter has not reloaded between our two reads.
-	 */
-	ticks2 = timer1->TimerValue & 0xffff;
-	do {
-		ticks1 = ticks2;
-		status = __raw_readl(VA_IC_BASE + IRQ_RAW_STATUS);
-		ticks2 = timer1->TimerValue & 0xffff;
-	} while (ticks2 > ticks1);
-
-	/*
-	 * Number of ticks since last interrupt.
-	 */
-	ticks1 = timer_reload - ticks2;
-
-	/*
-	 * Interrupt pending?  If so, we've reloaded once already.
-	 */
-	if (status & (1 << IRQ_TIMERINT1))
-		ticks1 += timer_reload;
-
-	/*
-	 * Convert the ticks to usecs
-	 */
-	return TICKS2USECS(ticks1);
-}
-
-/*
- * IRQ handler for the timer
- */
-static irqreturn_t
-integrator_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-	volatile TimerStruct_t *timer1 = (volatile TimerStruct_t *)TIMER1_VA_BASE;
-
-	// ...clear the interrupt
-	timer1->TimerClear = 1;
-
-	do_leds();
-	do_timer(regs);
-	do_profile(regs);
-
-	return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-void __init time_init(void)
-{
-	volatile TimerStruct_t *timer0 = (volatile TimerStruct_t *)TIMER0_VA_BASE;
-	volatile TimerStruct_t *timer1 = (volatile TimerStruct_t *)TIMER1_VA_BASE;
-	volatile TimerStruct_t *timer2 = (volatile TimerStruct_t *)TIMER2_VA_BASE;
-	unsigned int timer_ctrl = 0x80 | 0x40;	/* periodic */
-
-	if (machine_is_integrator()) {
-		timer_reload = 1000000 * TICKS_PER_uSEC / HZ;
-	} else if (machine_is_cintegrator()) {
-		timer_reload = 1000000 / HZ;
-		timer_ctrl |= TIMER_CTRL_IE;
-	}
-	if (timer_reload > 0x100000) {
-		timer_reload >>= 8;
-		timer_ctrl |= 0x08; /* /256 */
-	} else if (timer_reload > 0x010000) {
-		timer_reload >>= 4;
-		timer_ctrl |= 0x04; /* /16 */
-	}
-
-	/*
-	 * Initialise to a known state (all timers off)
-	 */
-	timer0->TimerControl = 0;
-	timer1->TimerControl = 0;
-	timer2->TimerControl = 0;
-
-	timer1->TimerLoad    = timer_reload;
-	timer1->TimerValue   = timer_reload;
-	timer1->TimerControl = timer_ctrl;
-
-	/* 
-	 * Make irqs happen for the system timer
-	 */
-	timer_irq.handler = integrator_timer_interrupt;
-	setup_irq(IRQ_TIMERINT1, &timer_irq);
-	gettimeoffset = integrator_gettimeoffset;
-}
diff -Nru a/include/asm-arm/arch-iop3xx/io.h b/include/asm-arm/arch-iop3xx/io.h
--- a/include/asm-arm/arch-iop3xx/io.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-arm/arch-iop3xx/io.h	2004-12-24 13:36:31 -08:00
@@ -13,8 +13,8 @@
 
 #define IO_SPACE_LIMIT 0xffffffff
 
-#define __io(p)			((p))
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		((unsigned long)(a))
+#define __io(p)			((void __iomem *)(p))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		(a)
 
 #endif
diff -Nru a/include/asm-arm/arch-iop3xx/serial.h b/include/asm-arm/arch-iop3xx/serial.h
--- a/include/asm-arm/arch-iop3xx/serial.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,76 +0,0 @@
-/*
- * include/asm-arm/arch-iop3xx/serial.h
- */
-#include <linux/config.h>
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD ( 1843200 / 16 )
-
-/* Standard COM flags */
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-#ifdef CONFIG_ARCH_IQ80321
-
-#define IRQ_UART1	IRQ_IQ80321_UART
-
-#define RS_TABLE_SIZE 1
-
-#define STD_SERIAL_PORT_DEFNS			\
-       /* UART CLK      PORT        IRQ        FLAGS        */			\
-	{ 0, BASE_BAUD, 0xfe800000, IRQ_UART1, STD_COM_FLAGS },  /* ttyS0 */
-#endif // CONFIG_ARCH_IQ80321
-
-#ifdef CONFIG_ARCH_IQ31244
-
-#define IRQ_UART1	IRQ_IQ31244_UART
-
-#define RS_TABLE_SIZE 1
-
-#define STD_SERIAL_PORT_DEFNS			\
-       /* UART CLK      PORT        IRQ        FLAGS        */			\
-	{ 0, BASE_BAUD, 0xfe800000, IRQ_UART1, STD_COM_FLAGS },  /* ttyS0 */
-#endif // CONFIG_ARCH_IQ31244
-
-#ifdef CONFIG_ARCH_IQ80331
-
-#undef BASE_BAUD
-
-#define BASE_BAUD ( 33334000 / 16 )
-
-#define IRQ_UART0	IRQ_IQ80331_UART0
-#define IRQ_UART1	IRQ_IQ80331_UART1
-
-#define RS_TABLE_SIZE 2
-
-#define STD_SERIAL_PORT_DEFNS				\
-	{						\
-	  /*type: PORT_XSCALE,*/			\
-	  /*xmit_fifo_size: 32,*/			\
-	  baud_base: BASE_BAUD,				\
-	  irq: IRQ_UART0,			  	\
-	  flags: STD_COM_FLAGS,				\
-	  iomem_base: IQ80331_UART0_VIRT,		\
-	  io_type: SERIAL_IO_MEM,			\
-	  iomem_reg_shift: 2				\
-	}, /* ttyS0 */					\
-	{						\
-	  /*type: PORT_XSCALE,*/			\
-	  /*xmit_fifo_size: 32,*/			\
-	  baud_base: BASE_BAUD,				\
-	  irq: IRQ_UART1,			  	\
-	  flags: STD_COM_FLAGS,				\
-	  iomem_base: IQ80331_UART1_VIRT,		\
-	  io_type: SERIAL_IO_MEM,			\
-	  iomem_reg_shift: 2				\
-	} /* ttyS1 */
-#endif // CONFIG_ARCH_IQ80331
-
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
diff -Nru a/include/asm-arm/arch-ixp2000/dma.h b/include/asm-arm/arch-ixp2000/dma.h
--- a/include/asm-arm/arch-ixp2000/dma.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-arm/arch-ixp2000/dma.h	2004-12-24 13:37:19 -08:00
@@ -1,5 +1,5 @@
 /*
- * linux/include/asm-arm/arch-ixdp2400/dma.h
+ * linux/include/asm-arm/arch-ixp2000/dma.h
  *
  * Copyright (C) 2002 Intel Corp.
  *
diff -Nru a/include/asm-arm/arch-ixp2000/io.h b/include/asm-arm/arch-ixp2000/io.h
--- a/include/asm-arm/arch-ixp2000/io.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-ixp2000/io.h	2004-12-24 13:36:17 -08:00
@@ -16,7 +16,7 @@
 #define __ASM_ARM_ARCH_IO_H
 
 #define IO_SPACE_LIMIT		0xffffffff
-#define __mem_pci(a)		((unsigned long)(a))
+#define __mem_pci(a)		(a)
 
 /*
  * Pick up VMALLOC_END
@@ -24,7 +24,7 @@
 #define ___io(p)		((unsigned long)((p)+IXP2000_PCI_IO_VIRT_BASE))
 
 /*
- * IXP200 does not do proper byte-lane conversion for PCI addresses,
+ * IXP2000 does not do proper byte-lane conversion for PCI addresses,
  * so we need to override standard functions.
  */
 #define alignb(addr)		((addr & ~3) + (3 - (addr & 3)))
diff -Nru a/include/asm-arm/arch-ixp2000/irqs.h b/include/asm-arm/arch-ixp2000/irqs.h
--- a/include/asm-arm/arch-ixp2000/irqs.h	2004-12-24 13:37:31 -08:00
+++ b/include/asm-arm/arch-ixp2000/irqs.h	2004-12-24 13:37:31 -08:00
@@ -28,7 +28,7 @@
  * shift operation instead of having to map the IRQ number to
  * a HW IRQ number.
  */
-#define	IRQ_IXP2000_SWI			0 /* soft interrupt */
+#define	IRQ_IXP2000_SOFT_INT		0 /* soft interrupt */
 #define	IRQ_IXP2000_ERRSUM		1 /* OR of all bits in ErrorStatus reg*/
 #define	IRQ_IXP2000_UART		2
 #define	IRQ_IXP2000_GPIO		3
@@ -46,13 +46,12 @@
 #define	IRQ_IXP2000_PCI   		15 /* PCI INTA or INTB */
 #define	IRQ_IXP2000_THDA0   		16 /* thread 0-31A */
 #define	IRQ_IXP2000_THDA1  		17 /* thread 32-63A */
-#define	IRQ_IXP2000_THDA2		18 /* thread 64-95A */
-#define	IRQ_IXP2000_THDA3 		19 /* thread 96-127A */
-#define	IRQ_IXP2000_THDB0		24 /* thread 0-31 B */
+#define	IRQ_IXP2000_THDA2		18 /* thread 64-95A, IXP2800 only */
+#define	IRQ_IXP2000_THDA3 		19 /* thread 96-127A, IXP2800 only */
+#define	IRQ_IXP2000_THDB0		24 /* thread 0-31B */
 #define	IRQ_IXP2000_THDB1		25 /* thread 32-63B */
-/* only 64 threads supported for IXP2400, rest or for IXP2800*/
-#define	IRQ_IXP2000_THDB2		26 /* thread 64-95B */
-#define	IRQ_IXP2000_THDB3		27 /* thread 96-127B */
+#define	IRQ_IXP2000_THDB2		26 /* thread 64-95B, IXP2800 only */
+#define	IRQ_IXP2000_THDB3		27 /* thread 96-127B, IXP2800 only */
 
 /* define generic GPIOs */
 #define IRQ_IXP2000_GPIO0		32
@@ -68,22 +67,7 @@
 #define IRQ_IXP2000_PCIA		40
 #define IRQ_IXP2000_PCIB		41
 
-/* Int sources from IRQ_ERROR_STATUS */
-#define IRQ_IXP2000_DRAM0_MIN_ERR	42
-#define IRQ_IXP2000_DRAM0_MAJ_ERR	43
-#define IRQ_IXP2000_DRAM1_MIN_ERR	44
-#define IRQ_IXP2000_DRAM1_MAJ_ERR	45
-#define IRQ_IXP2000_DRAM2_MIN_ERR	46
-#define IRQ_IXP2000_DRAM2_MAJ_ERR	47
-#define IRQ_IXP2000_SRAM0_ERR		48
-#define IRQ_IXP2000_SRAM1_ERR		49
-#define IRQ_IXP2000_SRAM2_ERR           50
-#define IRQ_IXP2000_SRAM3_ERR		51
-#define IRQ_IXP2000_MEDIA_ERR		52
-#define IRQ_IXP2000_PCI_ERR		53
-#define IRQ_IXP2000_SP_INT		54
-
-#define NR_IXP2000_IRQS                 55
+#define NR_IXP2000_IRQS                 42
 
 #define	IXP2000_BOARD_IRQ(x)		(NR_IXP2000_IRQS + (x))
 
diff -Nru a/include/asm-arm/arch-ixp2000/ixdp2x00.h b/include/asm-arm/arch-ixp2000/ixdp2x00.h
--- a/include/asm-arm/arch-ixp2000/ixdp2x00.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-ixp2000/ixdp2x00.h	2004-12-24 13:36:17 -08:00
@@ -53,7 +53,7 @@
 
 /*
  * PCI devfns for on-board devices. We need these to be able to
- * properly translte IRQs and for device removal.
+ * properly translate IRQs and for device removal.
  */
 #define	IXDP2400_SLAVE_ENET_DEVFN	0x18	/* Bus 1 */
 #define	IXDP2400_MASTER_ENET_DEVFN	0x20	/* Bus 1 */
diff -Nru a/include/asm-arm/arch-ixp2000/ixdp2x01.h b/include/asm-arm/arch-ixp2000/ixdp2x01.h
--- a/include/asm-arm/arch-ixp2000/ixdp2x01.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-ixp2000/ixdp2x01.h	2004-12-24 13:36:17 -08:00
@@ -50,4 +50,8 @@
 
 #define	IXDP2X01_UART_CLK		1843200
 
+#define	IXDP2X01_GPIO_I2C_ENABLE	0x02
+#define	IXDP2X01_GPIO_SCL		0x07
+#define	IXDP2X01_GPIO_SDA		0x06
+
 #endif /* __IXDP2x01_H__ */
diff -Nru a/include/asm-arm/arch-ixp2000/ixp2000-regs.h b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
--- a/include/asm-arm/arch-ixp2000/ixp2000-regs.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-arm/arch-ixp2000/ixp2000-regs.h	2004-12-24 13:36:16 -08:00
@@ -115,7 +115,7 @@
 
 /*
  * Mask of valid IRQs in the 32-bit IRQ register. We use
- * this to mark certain IRQs as being in-valid.
+ * this to mark certain IRQs as being invalid.
  */
 #define	IXP2000_VALID_IRQ_MASK	0x0f0fffff
 
@@ -251,7 +251,7 @@
 #define	SLOWPORT_CCR_DIV_30		0x0f
 
 /*
- * PCR values.  PCR configure the mode of the interfac3
+ * PCR values.  PCR configure the mode of the interface.
  */
 #define	SLOWPORT_MODE_FLASH		0x00
 #define	SLOWPORT_MODE_LUCENT		0x01
@@ -260,7 +260,7 @@
 #define	SLOWPORT_MODE_MOTOROLA_UP	0x04
 
 /*
- * ADC values.  Defines data and address bus widths
+ * ADC values.  Defines data and address bus widths.
  */
 #define	SLOWPORT_ADDR_WIDTH_8		0x00
 #define	SLOWPORT_ADDR_WIDTH_16		0x01
@@ -272,7 +272,7 @@
 #define	SLOWPORT_DATA_WIDTH_32		0x30
 
 /*
- * Masks and shifts for various fields in the WTC and RTC registers
+ * Masks and shifts for various fields in the WTC and RTC registers.
  */
 #define	SLOWPORT_WRTC_MASK_HD		0x0003
 #define	SLOWPORT_WRTC_MASK_SU		0x003c
@@ -284,7 +284,7 @@
 
 
 /*
- * GPIO registers & GPIO interface
+ * GPIO registers & GPIO interface.
  */
 #define IXP2000_GPIO_REG(x)		((volatile unsigned long*)(IXP2000_GPIO_VIRT_BASE+(x)))
 #define IXP2000_GPIO_PLR		IXP2000_GPIO_REG(0x00)
diff -Nru a/include/asm-arm/arch-ixp2000/platform.h b/include/asm-arm/arch-ixp2000/platform.h
--- a/include/asm-arm/arch-ixp2000/platform.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/arch-ixp2000/platform.h	2004-12-24 13:36:18 -08:00
@@ -16,10 +16,10 @@
 #ifndef __ASSEMBLY__
 
 /*
- * The IXP2400 B0 silicon contains an errata that causes writes to 
- * on-chip I/O register to not complete fully. What this means is
+ * The IXP2400 B0 silicon contains an erratum (#66) that causes writes
+ * to on-chip I/O register to not complete fully. What this means is
  * that if you have a write to on-chip I/O followed by a back-to-back
- * read or write, the first write will happend twice. OR...if it's
+ * read or write, the first write will happen twice. OR...if it's
  * not a back-to-back trasaction, the read or write will generate 
  * incorrect data.
  *
@@ -117,6 +117,7 @@
 void ixp2000_map_io(void);
 void ixp2000_init_irq(void);
 void ixp2000_init_time(unsigned long);
+unsigned long ixp2000_gettimeoffset(void);
 
 struct pci_sys_data;
 
diff -Nru a/include/asm-arm/arch-ixp2000/serial.h b/include/asm-arm/arch-ixp2000/serial.h
--- a/include/asm-arm/arch-ixp2000/serial.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,27 +0,0 @@
-/*
- * include/asm-arm/arch-ixp2000/serial.h
- *
- * Serial port defn for ixp2000 based systems.
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- *
- * Copyright (c) 2002-2004 MontaVista Software, Inc.
- *
- * We do not register serial ports staticly b/c there is no easy way
- * to autodetect an XScale port. Instead we register them at runtime
- * via early_serial_init().
- */
-
-#ifndef _ARCH_SERIAL_H_
-#define _ARCH_SERIAL_H_
-
-#define BASE_BAUD (50000000/ 16)
-
-/*
- * Currently no IXP2000 systems with > 3 serial ports.
- * If you add a system that does, just up this.
- */
-#define	STD_SERIAL_PORT_DEFNS
-#define	EXTRA_SERIAL_PORT_DEFNS
-
-#endif  // __ARCH_SERIAL_H_
diff -Nru a/include/asm-arm/arch-ixp2000/system.h b/include/asm-arm/arch-ixp2000/system.h
--- a/include/asm-arm/arch-ixp2000/system.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-arm/arch-ixp2000/system.h	2004-12-24 13:36:47 -08:00
@@ -1,5 +1,5 @@
 /*
- * linux/include/asm-arm/arch-ixp2400/system.h
+ * linux/include/asm-arm/arch-ixp2000/system.h
  *
  * Copyright (C) 2002 Intel Corp.
  *
diff -Nru a/include/asm-arm/arch-ixp4xx/io.h b/include/asm-arm/arch-ixp4xx/io.h
--- a/include/asm-arm/arch-ixp4xx/io.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-arm/arch-ixp4xx/io.h	2004-12-24 13:37:04 -08:00
@@ -46,7 +46,7 @@
  */
 #ifndef	CONFIG_IXP4XX_INDIRECT_PCI
 
-#define __mem_pci(a)		((unsigned long)(a))
+#define __mem_pci(a)		(a)
 
 #else
 
@@ -58,10 +58,10 @@
  * access registers. If something outside of PCI is ioremap'd, we
  * fallback to the default.
  */
-static inline void *
+static inline void __iomem *
 __ixp4xx_ioremap(unsigned long addr, size_t size, unsigned long flags, unsigned long align)
 {
-	extern void * __ioremap(unsigned long, size_t, unsigned long, unsigned long);
+	extern void __iomem * __ioremap(unsigned long, size_t, unsigned long, unsigned long);
 	if((addr < 0x48000000) || (addr > 0x4fffffff))
 		return __ioremap(addr, size, flags, align);
 
@@ -69,9 +69,9 @@
 }
 
 static inline void
-__ixp4xx_iounmap(void *addr)
+__ixp4xx_iounmap(void __iomem *addr)
 {
-	extern void __iounmap(void *addr);
+	extern void __iounmap(void __iomem *addr);
 
 	if ((u32)addr >= VMALLOC_START)
 		__iounmap(addr);
@@ -292,7 +292,7 @@
 }
 
 static inline void 
-__ixp4xx_outsb(u32 io_addr, u8 *vaddr, u32 count)
+__ixp4xx_outsb(u32 io_addr, const u8 *vaddr, u32 count)
 {
 	while (count--)
 		outb(*vaddr++, io_addr);
@@ -309,7 +309,7 @@
 }
 
 static inline void 
-__ixp4xx_outsw(u32 io_addr, u16 *vaddr, u32 count)
+__ixp4xx_outsw(u32 io_addr, const u16 *vaddr, u32 count)
 {
 	while (count--)
 		outw(cpu_to_le16(*vaddr++), io_addr);
@@ -322,7 +322,7 @@
 }
 
 static inline void 
-__ixp4xx_outsl(u32 io_addr, u32 *vaddr, u32 count)
+__ixp4xx_outsl(u32 io_addr, const u32 *vaddr, u32 count)
 {
 	while (count--)
 		outl(*vaddr++, io_addr);
diff -Nru a/include/asm-arm/arch-ixp4xx/ixp4xx-regs.h b/include/asm-arm/arch-ixp4xx/ixp4xx-regs.h
--- a/include/asm-arm/arch-ixp4xx/ixp4xx-regs.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-arm/arch-ixp4xx/ixp4xx-regs.h	2004-12-24 13:36:19 -08:00
@@ -55,7 +55,7 @@
  * PCI Config registers
  */
 #define IXP4XX_PCI_CFG_BASE_PHYS	(0xC0000000)
-#define	IXP4XX_PCI_CFG_BASE_VIRT	(0xFFBFD000)
+#define	IXP4XX_PCI_CFG_BASE_VIRT	(0xFFBFE000)
 #define IXP4XX_PCI_CFG_REGION_SIZE	(0x00001000)
 
 /*
diff -Nru a/include/asm-arm/arch-ixp4xx/platform.h b/include/asm-arm/arch-ixp4xx/platform.h
--- a/include/asm-arm/arch-ixp4xx/platform.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-ixp4xx/platform.h	2004-12-24 13:36:17 -08:00
@@ -53,12 +53,14 @@
 };
 
 
+struct sys_timer;
+
 /*
  * Functions used by platform-level setup code
  */
 extern void ixp4xx_map_io(void);
 extern void ixp4xx_init_irq(void);
-extern void ixp4xx_init_time(void);
+extern struct sys_timer ixp4xx_timer;
 extern void ixp4xx_pci_preinit(void);
 struct pci_sys_data;
 extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
diff -Nru a/include/asm-arm/arch-ixp4xx/serial.h b/include/asm-arm/arch-ixp4xx/serial.h
--- a/include/asm-arm/arch-ixp4xx/serial.h	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,27 +0,0 @@
-/*
- * include/asm-arm/arch-ixp4xx/serial.h
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- *
- * Copyright (C) 2002-2004 MontaVista Software, Inc.
- * 
- */
-
-#ifndef _ARCH_SERIAL_H_
-#define _ARCH_SERIAL_H_
-
-/*
- * We don't hardcode our serial port information but instead
- * fill it in dynamically based on our platform in arch->map_io.
- * This allows for per-board serial ports w/o a bunch of
- * #ifdefs in this file.
- */
-#define	STD_SERIAL_PORT_DEFNS
-#define	EXTRA_SERIAL_PORT_DEFNS
-
-/*
- * IXP4XX uses 15.6MHz clock for uart
- */
-#define BASE_BAUD ( IXP4XX_UART_XTAL / 16 )
-
-#endif // _ARCH_SERIAL_H_
diff -Nru a/include/asm-arm/arch-l7200/io.h b/include/asm-arm/arch-l7200/io.h
--- a/include/asm-arm/arch-l7200/io.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/arch-l7200/io.h	2004-12-24 13:36:18 -08:00
@@ -17,9 +17,9 @@
 /*
  * There are not real ISA nor PCI buses, so we fake it.
  */
-#define __io_pci(a)             (PCIO_BASE + (a))
-#define __mem_pci(a)            ((unsigned long)(a))
-#define __mem_isa(a)            ((unsigned long)(a))
+#define __io_pci(a)		((void __iomem *)(PCIO_BASE + (a)))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		(a)
 
 #define __ioaddr(p)             __io_pci(p)
 
diff -Nru a/include/asm-arm/arch-l7200/time.h b/include/asm-arm/arch-l7200/time.h
--- a/include/asm-arm/arch-l7200/time.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-arm/arch-l7200/time.h	2004-12-24 13:37:00 -08:00
@@ -46,6 +46,9 @@
 timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 	do_profile(regs);
 	RTC_RTCC = 0;				/* Clear interrupt */
 
diff -Nru a/include/asm-arm/arch-lh7a40x/io.h b/include/asm-arm/arch-lh7a40x/io.h
--- a/include/asm-arm/arch-lh7a40x/io.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-arm/arch-lh7a40x/io.h	2004-12-24 13:36:31 -08:00
@@ -14,8 +14,8 @@
 #define IO_SPACE_LIMIT 0xffffffff
 
 /* No ISA or PCI bus on this machine. */
-#define __io(a)			(a)
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		((unsigned long)(a))
+#define __io(a)			((void __iomem *)(a))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		(a)
 
 #endif /* __ASM_ARCH_IO_H */
diff -Nru a/include/asm-arm/arch-lh7a40x/serial.h b/include/asm-arm/arch-lh7a40x/serial.h
--- a/include/asm-arm/arch-lh7a40x/serial.h	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,25 +0,0 @@
-/* include/asm-arm/arch-lh7a40x/serial.h
- *
- *  Copyright (C) 2004 Coastal Environmental Systems
- *
- *  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.
- *
- */
-
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-#include <asm/arch/registers.h>
-
-#define UART_R_DATA	(0x00)
-#define UART_R_FCON	(0x04)
-#define UART_R_BRCON	(0x08)
-#define UART_R_CON	(0x0c)
-#define UART_R_STATUS	(0x10)
-#define UART_R_RAWISR	(0x14)
-#define UART_R_INTEN	(0x18)
-#define UART_R_ISR	(0x1c)
-
-#endif  /* _ASM_ARCH_SERIAL_H */
diff -Nru a/include/asm-arm/arch-lh7a40x/timex.h b/include/asm-arm/arch-lh7a40x/timex.h
--- a/include/asm-arm/arch-lh7a40x/timex.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-lh7a40x/timex.h	2004-12-24 13:36:17 -08:00
@@ -14,5 +14,4 @@
 
 /*
 #define CLOCK_TICK_RATE		3686400
-#define CLOCK_TICK_FACTOR	80
 */
diff -Nru a/include/asm-arm/arch-omap/board-h2.h b/include/asm-arm/arch-omap/board-h2.h
--- a/include/asm-arm/arch-omap/board-h2.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-arm/arch-omap/board-h2.h	2004-12-24 13:37:02 -08:00
@@ -36,10 +36,14 @@
 #define OMAP1610_ETHR_SIZE		SZ_4K
 #define OMAP1610_ETHR_START		0x04000000
 
-/* Intel STRATA NOR flash at CS3 */
-#define OMAP1610_NOR_FLASH_BASE		0xD8000000
-#define OMAP1610_NOR_FLASH_SIZE		SZ_32M
-#define OMAP1610_NOR_FLASH_START	0x0C000000
+/* Intel STRATA NOR flash at CS3 or CS2B(NAND Boot) */
+#define OMAP_NOR_FLASH_SIZE             SZ_32M
+#define OMAP_NOR_FLASH_START1           0x0C000000 /* CS3 */
+#define OMAP_NOR_FLASH_START2           0x0A000000 /* CS2B */
+
+/* Samsung NAND flash at CS2B or CS3(NAND Boot) */
+#define OMAP_NAND_FLASH_START1           0x0A000000 /* CS2B */
+#define OMAP_NAND_FLASH_START2           0x0C000000 /* CS3 */
 
 #endif /*  __ASM_ARCH_OMAP_H2_H */
 
diff -Nru a/include/asm-arm/arch-omap/board-h3.h b/include/asm-arm/arch-omap/board-h3.h
--- a/include/asm-arm/arch-omap/board-h3.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-arm/arch-omap/board-h3.h	2004-12-24 13:37:29 -08:00
@@ -32,10 +32,14 @@
 #define OMAP1710_ETHR_SIZE		SZ_4K
 #define OMAP1710_ETHR_START		0x04000000
 
-/* Intel STRATA NOR flash at CS3 */
-#define OMAP_NOR_FLASH_BASE		0xD8000000
-#define OMAP_NOR_FLASH_SIZE		SZ_32M
-#define OMAP_NOR_FLASH_START		0x00000000
+/* Intel STRATA NOR flash at CS3 or CS2B(NAND Boot) */
+#define OMAP_NOR_FLASH_SIZE             SZ_32M
+#define OMAP_NOR_FLASH_START1 		0x0C000000 /* CS3 */
+#define OMAP_NOR_FLASH_START2 		0x0A000000 /* CS2B */
+
+/* Samsung NAND flash at CS2B or CS3(NAND Boot) */
+#define OMAP_NAND_FLASH_START1           0x0A000000 /* CS2B */
+#define OMAP_NAND_FLASH_START2           0x0C000000 /* CS3 */
 
 #define MAXIRQNUM			(IH_BOARD_BASE)
 #define MAXFIQNUM			MAXIRQNUM
@@ -43,65 +47,5 @@
 
 #define NR_IRQS				(MAXIRQNUM + 1)
 
-#define OMAP_MCBSP1_BASE		OMAP1610_MCBSP1_BASE
-#define AUDIO_DRR2  (OMAP_MCBSP1_BASE + 0x00)
-#define AUDIO_DRR1  (OMAP_MCBSP1_BASE + 0x02)
-#define AUDIO_DXR2  (OMAP_MCBSP1_BASE + 0x04)
-#define AUDIO_DXR1  (OMAP_MCBSP1_BASE + 0x06)
-#define AUDIO_SPCR2 (OMAP_MCBSP1_BASE + 0x08)
-#define AUDIO_SPCR1 (OMAP_MCBSP1_BASE + 0x0a)
-#define AUDIO_RCR2  (OMAP_MCBSP1_BASE + 0x0c)
-#define AUDIO_RCR1  (OMAP_MCBSP1_BASE + 0x0e)
-#define AUDIO_XCR2  (OMAP_MCBSP1_BASE + 0x10)
-#define AUDIO_XCR1  (OMAP_MCBSP1_BASE + 0x12)
-#define AUDIO_SRGR2 (OMAP_MCBSP1_BASE + 0x14)
-#define AUDIO_SRGR1 (OMAP_MCBSP1_BASE + 0x16)
-#define AUDIO_MCR2  (OMAP_MCBSP1_BASE + 0x18)
-#define AUDIO_MCR1  (OMAP_MCBSP1_BASE + 0x1a)
-#define AUDIO_RCERA (OMAP_MCBSP1_BASE + 0x1c)
-#define AUDIO_RCERB (OMAP_MCBSP1_BASE + 0x1e)
-#define AUDIO_XCERA (OMAP_MCBSP1_BASE + 0x20)
-#define AUDIO_XCERB (OMAP_MCBSP1_BASE + 0x22)
-#define AUDIO_PCR0  (OMAP_MCBSP1_BASE + 0x24)
-
-/* UART3 Registers Maping through MPU bus */
-#define OMAP_MPU_UART3_BASE     0xFFFB9800      /* UART3 through MPU bus */
-#define UART3_RHR               (OMAP_MPU_UART3_BASE + 0)
-#define UART3_THR               (OMAP_MPU_UART3_BASE + 0)
-#define UART3_DLL               (OMAP_MPU_UART3_BASE + 0)
-#define UART3_IER               (OMAP_MPU_UART3_BASE + 4)
-#define UART3_DLH               (OMAP_MPU_UART3_BASE + 4)
-#define UART3_IIR               (OMAP_MPU_UART3_BASE + 8)
-#define UART3_FCR               (OMAP_MPU_UART3_BASE + 8)
-#define UART3_EFR               (OMAP_MPU_UART3_BASE + 8)
-#define UART3_LCR               (OMAP_MPU_UART3_BASE + 0x0C)
-#define UART3_MCR               (OMAP_MPU_UART3_BASE + 0x10)
-#define UART3_XON1_ADDR1        (OMAP_MPU_UART3_BASE + 0x10)
-#define UART3_XON2_ADDR2        (OMAP_MPU_UART3_BASE + 0x14)
-#define UART3_LSR               (OMAP_MPU_UART3_BASE + 0x14)
-#define UART3_TCR               (OMAP_MPU_UART3_BASE + 0x18)
-#define UART3_MSR               (OMAP_MPU_UART3_BASE + 0x18)
-#define UART3_XOFF1             (OMAP_MPU_UART3_BASE + 0x18)
-#define UART3_XOFF2             (OMAP_MPU_UART3_BASE + 0x1C)
-#define UART3_SPR               (OMAP_MPU_UART3_BASE + 0x1C)
-#define UART3_TLR               (OMAP_MPU_UART3_BASE + 0x1C)
-#define UART3_MDR1              (OMAP_MPU_UART3_BASE + 0x20)
-#define UART3_MDR2              (OMAP_MPU_UART3_BASE + 0x24)
-#define UART3_SFLSR             (OMAP_MPU_UART3_BASE + 0x28)
-#define UART3_TXFLL             (OMAP_MPU_UART3_BASE + 0x28)
-#define UART3_RESUME            (OMAP_MPU_UART3_BASE + 0x2C)
-#define UART3_TXFLH             (OMAP_MPU_UART3_BASE + 0x2C)
-#define UART3_SFREGL            (OMAP_MPU_UART3_BASE + 0x30)
-#define UART3_RXFLL             (OMAP_MPU_UART3_BASE + 0x30)
-#define UART3_SFREGH            (OMAP_MPU_UART3_BASE + 0x34)
-#define UART3_RXFLH             (OMAP_MPU_UART3_BASE + 0x34)
-#define UART3_BLR               (OMAP_MPU_UART3_BASE + 0x38)
-#define UART3_ACREG             (OMAP_MPU_UART3_BASE + 0x3C)
-#define UART3_DIV16             (OMAP_MPU_UART3_BASE + 0x3C)
-#define UART3_SCR               (OMAP_MPU_UART3_BASE + 0x40)
-#define UART3_SSR               (OMAP_MPU_UART3_BASE + 0x44)
-#define UART3_EBLR              (OMAP_MPU_UART3_BASE + 0x48)
-#define UART3_OSC_12M_SEL       (OMAP_MPU_UART3_BASE + 0x4C)
-#define UART3_MVR               (OMAP_MPU_UART3_BASE + 0x50)
 
 #endif /*  __ASM_ARCH_OMAP_H3_H */
diff -Nru a/include/asm-arm/arch-omap/board-innovator.h b/include/asm-arm/arch-omap/board-innovator.h
--- a/include/asm-arm/arch-omap/board-innovator.h	2004-12-24 13:37:44 -08:00
+++ b/include/asm-arm/arch-omap/board-innovator.h	2004-12-24 13:37:44 -08:00
@@ -71,17 +71,11 @@
 
 #endif /* CONFIG_ARCH_OMAP1510 */
 
-#if defined (CONFIG_ARCH_OMAP1610)
+#if defined (CONFIG_ARCH_OMAP16XX)
 
 /* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
-#define OMAP1610_ETHR_BASE		0xE8000000
-#define OMAP1610_ETHR_SIZE		SZ_4K
-#define OMAP1610_ETHR_START		0x04000000
-
-/* Intel STRATA NOR flash at CS3 */
-#define OMAP1610_NOR_FLASH_BASE		0xD8000000
-#define OMAP1610_NOR_FLASH_SIZE		SZ_32M
-#define OMAP1610_NOR_FLASH_START	0x0C000000
+#define INNOVATOR1610_ETHR_START	0x04000000
+#define INNOVATOR1610_ETHR_SIZE		SZ_4K
 
 #endif /* CONFIG_ARCH_OMAP1610 */
 #endif /* __ASM_ARCH_OMAP_INNOVATOR_H */
diff -Nru a/include/asm-arm/arch-omap/board.h b/include/asm-arm/arch-omap/board.h
--- a/include/asm-arm/arch-omap/board.h	2004-12-24 13:36:57 -08:00
+++ b/include/asm-arm/arch-omap/board.h	2004-12-24 13:36:57 -08:00
@@ -17,7 +17,12 @@
 #define OMAP_TAG_CLOCK		0x4f01
 #define OMAP_TAG_MMC		0x4f02
 #define OMAP_TAG_UART		0x4f03
-#define OMAP_TAG_USB            0x4f04
+#define OMAP_TAG_USB		0x4f04
+#define OMAP_TAG_LCD		0x4f05
+#define OMAP_TAG_GPIO_SWITCH	0x4f06
+
+#define OMAP_TAG_BOOT_REASON    0x4f80
+#define OMAP_TAG_FLASH_PART	0x4f81
 
 struct omap_clock_config {
 	/* 0 for 12 MHz, 1 for 13 MHz and 2 for 19.2 MHz */
@@ -26,8 +31,8 @@
 
 struct omap_mmc_config {
 	u8 mmc_blocks;
-	s8 mmc1_power_pin, mmc2_power_pin;
-	s8 mmc1_switch_pin, mmc2_switch_pin;
+	s16 mmc1_power_pin, mmc2_power_pin;
+	s16 mmc1_switch_pin, mmc2_switch_pin;
 };
 
 struct omap_uart_config {
@@ -63,6 +68,38 @@
 	u8		pins[3];
 };
 
+struct omap_lcd_config {
+	char panel_name[16];
+	char ctrl_name[16];
+};
+
+/* Cover:
+ *      high -> closed
+ *      low  -> open
+ * Connection:
+ *      high -> connected
+ *      low  -> disconnected
+ */
+#define OMAP_GPIO_SWITCH_TYPE_COVER		0x0000
+#define OMAP_GPIO_SWITCH_TYPE_CONNECTION	0x0001
+#define OMAP_GPIO_SWITCH_FLAG_INVERTED          0x0001
+struct omap_gpio_switch_config {
+	char name[12];
+	u16 gpio;
+	int flags:4;
+	int type:4;
+	int key_code:24; /* Linux key code */
+};
+
+struct omap_flash_part_config {
+	char part_table[0];
+};
+
+struct omap_boot_reason_config {
+	char reason_str[12];
+};
+
+
 struct omap_board_config_entry {
 	u16 tag;
 	u16 len;
@@ -74,10 +111,14 @@
 	const void *data;
 };
 
-extern const void *__omap_get_config(u16 tag, size_t len);
+extern const void *__omap_get_config(u16 tag, size_t len, int nr);
 
 #define omap_get_config(tag, type) \
-	((const type *) __omap_get_config((tag), sizeof(type)))
+	((const type *) __omap_get_config((tag), sizeof(type), 0))
+#define omap_get_nr_config(tag, type, nr) \
+	((const type *) __omap_get_config((tag), sizeof(type), (nr)))
+
+extern const void *omap_get_var_config(u16 tag, size_t *len);
 
 extern struct omap_board_config_kernel *omap_board_config;
 extern int omap_board_config_size;
diff -Nru a/include/asm-arm/arch-omap/cpu.h b/include/asm-arm/arch-omap/cpu.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/arch-omap/cpu.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,183 @@
+/*
+ * linux/include/asm-arm/arch-omap/cpu.h
+ *
+ * OMAP cpu type detection
+ *
+ * Copyright (C) 2004 Nokia Corporation
+ *
+ * Written by Tony Lindgren <tony.lindgren@nokia.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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __ASM_ARCH_OMAP_CPU_H
+#define __ASM_ARCH_OMAP_CPU_H
+
+extern unsigned int system_rev;
+
+#define OMAP_DIE_ID_0		0xfffe1800
+#define OMAP_DIE_ID_1		0xfffe1804
+#define OMAP_PRODUCTION_ID_0	0xfffe2000
+#define OMAP_PRODUCTION_ID_1	0xfffe2004
+#define OMAP32_ID_0		0xfffed400
+#define OMAP32_ID_1		0xfffed404
+
+/*
+ * Test if multicore OMAP support is needed
+ */
+#undef MULTI_OMAP
+#undef OMAP_NAME
+
+#ifdef CONFIG_ARCH_OMAP730
+# ifdef OMAP_NAME
+#  undef  MULTI_OMAP
+#  define MULTI_OMAP
+# else
+#  define OMAP_NAME omap730
+# endif
+#endif
+#ifdef CONFIG_ARCH_OMAP1510
+# ifdef OMAP_NAME
+#  undef  MULTI_OMAP
+#  define MULTI_OMAP
+# else
+#  define OMAP_NAME omap1510
+# endif
+#endif
+#ifdef CONFIG_ARCH_OMAP16XX
+# ifdef OMAP_NAME
+#  undef  MULTI_OMAP
+#  define MULTI_OMAP
+# else
+#  define OMAP_NAME omap1610
+# endif
+#endif
+#ifdef CONFIG_ARCH_OMAP16XX
+# ifdef OMAP_NAME
+#  undef  MULTI_OMAP
+#  define MULTI_OMAP
+# else
+#  define OMAP_NAME omap1710
+# endif
+#endif
+
+/*
+ * Generate various OMAP cpu specific macros, and cpu class
+ * specific macros
+ */
+#define GET_OMAP_TYPE	((system_rev >> 24) & 0xff)
+#define GET_OMAP_CLASS	(system_rev & 0xff)
+
+#define IS_OMAP_TYPE(type, id)				\
+static inline int is_omap ##type (void)			\
+{							\
+	return (GET_OMAP_TYPE == (id)) ? 1 : 0;		\
+}
+
+#define IS_OMAP_CLASS(class, id)			\
+static inline int is_omap ##class (void)		\
+{							\
+	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
+}
+
+IS_OMAP_TYPE(730, 0x07)
+IS_OMAP_TYPE(1510, 0x15)
+IS_OMAP_TYPE(1610, 0x16)
+IS_OMAP_TYPE(5912, 0x16)
+IS_OMAP_TYPE(1710, 0x17)
+IS_OMAP_TYPE(2420, 0x24)
+
+IS_OMAP_CLASS(7xx, 0x07)
+IS_OMAP_CLASS(15xx, 0x15)
+IS_OMAP_CLASS(16xx, 0x16)
+IS_OMAP_CLASS(24xx, 0x24)
+
+/*
+ * Macros to group OMAP types into cpu classes.
+ * These can be used in most places.
+ * cpu_is_omap15xx():	True for 1510 and 5910
+ * cpu_is_omap16xx():	True for 1610, 5912 and 1710
+ */
+#if defined(MULTI_OMAP)
+# define cpu_is_omap7xx()		is_omap7xx()
+# define cpu_is_omap15xx()		is_omap15xx()
+# if !(defined(CONFIG_ARCH_OMAP1510) || defined(CONFIG_ARCH_OMAP730))
+#  define cpu_is_omap16xx()		1
+# else
+#  define cpu_is_omap16xx()		is_omap16xx()
+# endif
+#else
+# if defined(CONFIG_ARCH_OMAP730)
+#  define cpu_is_omap7xx()		1
+# else
+#  define cpu_is_omap7xx()		0
+# endif
+# if defined(CONFIG_ARCH_OMAP1510)
+#  define cpu_is_omap15xx()		1
+# else
+#  define cpu_is_omap15xx()		0
+# endif
+# if defined(CONFIG_ARCH_OMAP16XX)
+#  define cpu_is_omap16xx()		1
+# else
+#  define cpu_is_omap16xx()		0
+# endif
+#endif
+
+#if defined(MULTI_OMAP)
+# define cpu_is_omap730()		is_omap730()
+# define cpu_is_omap1510()		is_omap1510()
+# define cpu_is_omap1610()		is_omap1610()
+# define cpu_is_omap5912()		is_omap5912()
+# define cpu_is_omap1710()		is_omap1710()
+#else
+# if defined(CONFIG_ARCH_OMAP730)
+#  define cpu_is_omap730()		1
+# else
+#  define cpu_is_omap730()		0
+# endif
+# if defined(CONFIG_ARCH_OMAP1510)
+#  define cpu_is_omap1510()		1
+# else
+#  define cpu_is_omap1510()		0
+# endif
+# if defined(CONFIG_ARCH_OMAP16XX)
+#  define cpu_is_omap1610()		1
+# else
+#  define cpu_is_omap1610()		0
+# endif
+# if defined(CONFIG_ARCH_OMAP16XX)
+#  define cpu_is_omap5912()		1
+# else
+#  define cpu_is_omap5912()		0
+# endif
+# if defined(CONFIG_ARCH_OMAP16XX)
+# define cpu_is_omap1610()		is_omap1610()
+# define cpu_is_omap5912()		is_omap5912()
+# define cpu_is_omap1710()		is_omap1710()
+# else
+# define cpu_is_omap1610()		0
+# define cpu_is_omap5912()		0
+# define cpu_is_omap1710()		0
+# endif
+# if defined(CONFIG_ARCH_OMAP2420)
+#  define cpu_is_omap2420()		1
+# else
+#  define cpu_is_omap2420()		0
+# endif
+#endif
+
+#endif
diff -Nru a/include/asm-arm/arch-omap/dma.h b/include/asm-arm/arch-omap/dma.h
--- a/include/asm-arm/arch-omap/dma.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/arch-omap/dma.h	2004-12-24 13:36:18 -08:00
@@ -194,11 +194,19 @@
 	OMAP_LCD_DMA_B2_BOTTOM
 };
 
-enum {
+enum omap_dma_burst_mode {
+	OMAP_DMA_DATA_BURST_DIS = 0,
 	OMAP_DMA_DATA_BURST_4,
 	OMAP_DMA_DATA_BURST_8
 };
 
+enum omap_dma_color_mode {
+	OMAP_DMA_COLOR_DIS = 0,
+	OMAP_DMA_CONSTANT_FILL,
+	OMAP_DMA_TRANSPARENT_COPY
+};
+
+extern void omap_set_dma_priority(int dst_port, int priority);
 extern int omap_request_dma(int dev_id, const char *dev_name,
 			    void (* callback)(int lch, u16 ch_status, void *data),
 			    void *data, int *dma_ch);
@@ -210,20 +218,22 @@
 extern void omap_set_dma_transfer_params(int lch, int data_type,
 					 int elem_count, int frame_count,
 					 int sync_mode);
-extern void omap_set_dma_constant_fill(int lch, u32 color);
-extern void omap_set_dma_transparent_copy(int lch, u32 color);
+extern void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode,
+				    u32 color);
 
 extern void omap_set_dma_src_params(int lch, int src_port, int src_amode,
 				    unsigned long src_start);
 extern void omap_set_dma_src_index(int lch, int eidx, int fidx);
 extern void omap_set_dma_src_data_pack(int lch, int enable);
-extern void omap_set_dma_src_burst_mode(int lch, int burst_mode);
+extern void omap_set_dma_src_burst_mode(int lch,
+					enum omap_dma_burst_mode burst_mode);
 
 extern void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,
 				     unsigned long dest_start);
 extern void omap_set_dma_dest_index(int lch, int eidx, int fidx);
 extern void omap_set_dma_dest_data_pack(int lch, int enable);
-extern void omap_set_dma_dest_burst_mode(int lch, int burst_mode);
+extern void omap_set_dma_dest_burst_mode(int lch,
+					 enum omap_dma_burst_mode burst_mode);
 
 extern void omap_dma_link_lch (int lch_head, int lch_queue);
 extern void omap_dma_unlink_lch (int lch_head, int lch_queue);
@@ -235,10 +245,16 @@
 extern int omap_request_lcd_dma(void (* callback)(u16 status, void *data),
 				void *data);
 extern void omap_free_lcd_dma(void);
-extern void omap_start_lcd_dma(void);
+extern void omap_setup_lcd_dma(void);
+extern void omap_enable_lcd_dma(void);
 extern void omap_stop_lcd_dma(void);
+extern void omap_set_lcd_dma_ext_controller(int external);
+extern void omap_set_lcd_dma_single_transfer(int single);
 extern void omap_set_lcd_dma_b1(unsigned long addr, u16 fb_xres, u16 fb_yres,
 				int data_type);
 extern void omap_set_lcd_dma_b1_rotation(int rotate);
+extern void omap_set_lcd_dma_b1_vxres(unsigned long vxres);
+extern void omap_set_lcd_dma_b1_mirror(int mirror);
+extern void omap_set_lcd_dma_b1_scale(unsigned int xscale, unsigned int yscale);
 
 #endif /* __ASM_ARCH_DMA_H */
diff -Nru a/include/asm-arm/arch-omap/hardware.h b/include/asm-arm/arch-omap/hardware.h
--- a/include/asm-arm/arch-omap/hardware.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/arch-omap/hardware.h	2004-12-24 13:36:18 -08:00
@@ -40,6 +40,7 @@
 #include <linux/config.h>
 #ifndef __ASSEMBLER__
 #include <asm/types.h>
+#include <asm/arch/cpu.h>
 #endif
 #include <asm/arch/io.h>
 
@@ -64,6 +65,7 @@
 #define ARM_RSTCT1		(CLKGEN_REG_BASE + 0x10)
 #define ARM_RSTCT2		(CLKGEN_REG_BASE + 0x14)
 #define ARM_SYSST		(CLKGEN_REG_BASE + 0x18)
+#define ARM_IDLECT3		(CLKGEN_REG_BASE + 0x24)
 
 #define CK_RATEF		1
 #define CK_IDLEF		2
@@ -140,12 +142,12 @@
 #define MPUTIM_AR		(1<<1)
 #define MPUTIM_ST		(1<<0)
 
-/* Watchdog */
-#define OMAP_WATCHDOG_BASE	(0xfffec800)
-#define OMAP_WDT_TIMER		(OMAP_WATCHDOG_BASE + 0x0)
-#define OMAP_WDT_LOAD_TIM	(OMAP_WATCHDOG_BASE + 0x4)
-#define OMAP_WDT_READ_TIM	(OMAP_WATCHDOG_BASE + 0x4)
-#define OMAP_WDT_TIMER_MODE	(OMAP_WATCHDOG_BASE + 0x8)
+/* Watchdog timer within the OMAP3.2 gigacell */
+#define OMAP_MPU_WATCHDOG_BASE	(0xfffec800)
+#define OMAP_WDT_TIMER		(OMAP_MPU_WATCHDOG_BASE + 0x0)
+#define OMAP_WDT_LOAD_TIM	(OMAP_MPU_WATCHDOG_BASE + 0x4)
+#define OMAP_WDT_READ_TIM	(OMAP_MPU_WATCHDOG_BASE + 0x4)
+#define OMAP_WDT_TIMER_MODE	(OMAP_MPU_WATCHDOG_BASE + 0x8)
 
 /*
  * ---------------------------------------------------------------------------
@@ -186,22 +188,22 @@
  * ---------------------------------------------------------------------------
  */
 #define TCMIF_BASE		0xfffecc00
-#define IMIF_PRIO_REG		__REG32(TCMIF_BASE + 0x00)
-#define EMIFS_PRIO_REG		__REG32(TCMIF_BASE + 0x04)
-#define EMIFF_PRIO_REG		__REG32(TCMIF_BASE + 0x08)
-#define EMIFS_CONFIG_REG	__REG32(TCMIF_BASE + 0x0c)
-#define EMIFS_CS0_CONFIG_REG	__REG32(TCMIF_BASE + 0x10)
-#define EMIFS_CS1_CONFIG_REG	__REG32(TCMIF_BASE + 0x14)
-#define EMIFS_CS2_CONFIG_REG	__REG32(TCMIF_BASE + 0x18)
-#define EMIFS_CS3_CONFIG_REG	__REG32(TCMIF_BASE + 0x1c)
-#define EMIFF_SDRAM_CONFIG_REG	__REG32(TCMIF_BASE + 0x20)
-#define EMIFF_MRS_REG		__REG32(TCMIF_BASE + 0x24)
-#define TC_TIMEOUT1_REG		__REG32(TCMIF_BASE + 0x28)
-#define TC_TIMEOUT2_REG		__REG32(TCMIF_BASE + 0x2c)
-#define TC_TIMEOUT3_REG		__REG32(TCMIF_BASE + 0x30)
-#define TC_ENDIANISM_REG	__REG32(TCMIF_BASE + 0x34)
-#define EMIFF_SDRAM_CONFIG_2_REG __REG32(TCMIF_BASE + 0x3c)
-#define EMIF_CFG_DYNAMIC_WS_REG	__REG32(TCMIF_BASE + 0x40)
+#define IMIF_PRIO		(TCMIF_BASE + 0x00)
+#define EMIFS_PRIO		(TCMIF_BASE + 0x04)
+#define EMIFF_PRIO		(TCMIF_BASE + 0x08)
+#define EMIFS_CONFIG		(TCMIF_BASE + 0x0c)
+#define EMIFS_CS0_CONFIG	(TCMIF_BASE + 0x10)
+#define EMIFS_CS1_CONFIG	(TCMIF_BASE + 0x14)
+#define EMIFS_CS2_CONFIG	(TCMIF_BASE + 0x18)
+#define EMIFS_CS3_CONFIG	(TCMIF_BASE + 0x1c)
+#define EMIFF_SDRAM_CONFIG	(TCMIF_BASE + 0x20)
+#define EMIFF_MRS		(TCMIF_BASE + 0x24)
+#define TC_TIMEOUT1		(TCMIF_BASE + 0x28)
+#define TC_TIMEOUT2		(TCMIF_BASE + 0x2c)
+#define TC_TIMEOUT3		(TCMIF_BASE + 0x30)
+#define TC_ENDIANISM		(TCMIF_BASE + 0x34)
+#define EMIFF_SDRAM_CONFIG_2	(TCMIF_BASE + 0x3c)
+#define EMIF_CFG_DYNAMIC_WS	(TCMIF_BASE + 0x40)
 
 /*
  * ----------------------------------------------------------------------------
@@ -235,6 +237,7 @@
 #define PULL_DWN_CTRL_1		0xfffe1044
 #define PULL_DWN_CTRL_2		0xfffe1048
 #define PULL_DWN_CTRL_3		0xfffe104c
+#define PULL_DWN_CTRL_4		0xfffe10ac
 
 /* OMAP-1610 specific multiplexing registers */
 #define FUNC_MUX_CTRL_E		0xfffe1090
@@ -248,6 +251,9 @@
 #define PU_PD_SEL_3		0xfffe10c0
 #define PU_PD_SEL_4		0xfffe10c4
 
+/* Timer32K for 1610 and 1710*/
+#define OMAP_TIMER32K_BASE	0xFFFBC400
+
 /*
  * ---------------------------------------------------------------------------
  * TIPB bus interface
@@ -277,62 +283,44 @@
 
 /*
  * ---------------------------------------------------------------------------
- * Processor differentiation
+ * Serial ports
  * ---------------------------------------------------------------------------
  */
-#define OMAP_ID_BASE		(0xfffed400)
-#define OMAP_ID_REG		__REG32(OMAP_ID_BASE +  0x04)
-
-#define ID_SHIFT		12
-#define ID_MASK			0x7fff
+#define OMAP_UART1_BASE		(unsigned char *)0xfffb0000
+#define OMAP_UART2_BASE		(unsigned char *)0xfffb0800
+#define OMAP_UART3_BASE		(unsigned char *)0xfffb9800
+#define OMAP_MAX_NR_PORTS	3
+#define OMAP1510_BASE_BAUD	(12000000/16)
+#define OMAP16XX_BASE_BAUD	(48000000/16)
 
-/* See also uncompress.h */
-#define OMAP_ID_730		0x355F
-#define OMAP_ID_1510		0x3470
-#define OMAP_ID_1610		0x3576
-#define OMAP_ID_1710		0x35F7
-#define OMAP_ID_5912		0x358C
-#define OMAP_ID_1611            0x358C
+#define is_omap_port(p)	({int __ret = 0;				\
+			if (p == (char*)IO_ADDRESS(OMAP_UART1_BASE) ||	\
+			    p == (char*)IO_ADDRESS(OMAP_UART2_BASE) ||	\
+			    p == (char*)IO_ADDRESS(OMAP_UART3_BASE))	\
+				__ret = 1;				\
+			__ret;						\
+			})
 
+/*
+ * ---------------------------------------------------------------------------
+ * Processor specific defines
+ * ---------------------------------------------------------------------------
+ */
 #ifdef CONFIG_ARCH_OMAP730
 #include "omap730.h"
-#define cpu_is_omap730()	(((OMAP_ID_REG >> ID_SHIFT) & ID_MASK) == OMAP_ID_730)
-#else
-#define cpu_is_omap730()	0
 #endif
 
 #ifdef CONFIG_ARCH_OMAP1510
 #include "omap1510.h"
-#define cpu_is_omap1510()	(((OMAP_ID_REG >> ID_SHIFT) & ID_MASK) == OMAP_ID_1510)
-#else
-#define cpu_is_omap1510()	0
-#endif
-
-#ifdef CONFIG_ARCH_OMAP1610
-#include "omap1610.h"
-#define cpu_is_omap1610()	(((OMAP_ID_REG >> ID_SHIFT) & ID_MASK) == OMAP_ID_1610) || \
-				(((OMAP_ID_REG >> ID_SHIFT) & ID_MASK) == OMAP_ID_1611)
-#else
-#define cpu_is_omap1610()	0
-#endif
-
-#ifdef CONFIG_ARCH_OMAP1710
-#include "omap1610.h"
-#define cpu_is_omap1710()       (((OMAP_ID_REG >> ID_SHIFT) & ID_MASK) == OMAP_ID_1710)
-#else
-#define cpu_is_omap1710()	0
 #endif
 
-#ifdef CONFIG_ARCH_OMAP5912
-#include "omap5912.h"
-#define cpu_is_omap5912()	(((OMAP_ID_REG >> ID_SHIFT) & ID_MASK) == OMAP_ID_5912)
-#else
-#define cpu_is_omap5912()	0
+#ifdef CONFIG_ARCH_OMAP16XX
+#include "omap16xx.h"
 #endif
 
 /*
  * ---------------------------------------------------------------------------
- * Board differentiation
+ * Board specific defines
  * ---------------------------------------------------------------------------
  */
 
diff -Nru a/include/asm-arm/arch-omap/io.h b/include/asm-arm/arch-omap/io.h
--- a/include/asm-arm/arch-omap/io.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/arch-omap/io.h	2004-12-24 13:36:18 -08:00
@@ -40,9 +40,9 @@
  * We don't actually have real ISA nor PCI buses, but there is so many
  * drivers out there that might just work if we fake them...
  */
-#define __io(a)			(PCIO_BASE + (a))
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		((unsigned long)(a))
+#define __io(a)			((void __iomem *)(PCIO_BASE + (a)))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		(a)
 
 /*
  * ----------------------------------------------------------------------------
diff -Nru a/include/asm-arm/arch-omap/irqs.h b/include/asm-arm/arch-omap/irqs.h
--- a/include/asm-arm/arch-omap/irqs.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-arm/arch-omap/irqs.h	2004-12-24 13:36:16 -08:00
@@ -192,8 +192,6 @@
 #define INT_730_TIMER32K	(22 + IH2_BASE)
 #define INT_730_MMC_SDIO	(23 + IH2_BASE)
 #define INT_730_UPLD		(24 + IH2_BASE)
-#define INT_730_RTC_TIMER	(25 + IH2_BASE)
-#define INT_730_RTC_ALARM	(26 + IH2_BASE)
 #define INT_730_USB_HHC_1	(27 + IH2_BASE)
 #define INT_730_USB_HHC_2	(28 + IH2_BASE)
 #define INT_730_USB_GENI	(29 + IH2_BASE)
@@ -224,24 +222,6 @@
 #define INT_730_DMA_CH15	(62 + IH2_BASE)
 #define INT_730_NAND		(63 + IH2_BASE)
 
-/* OMAP-730 differences */
-#ifdef CONFIG_ARCH_OMAP730
-#undef	INT_IH2_IRQ
-#define INT_IH2_IRQ		INT_730_IH2_IRQ
-#undef	INT_KEYBOARD
-#define INT_KEYBOARD		INT_730_MPUIO_KEYPAD
-#undef	INT_UART1
-#define INT_UART1		INT_730_UART_MODEM_1
-#undef	INT_UART2
-#define INT_UART2		INT_730_UART_MODEM_IRDA_2
-#undef	INT_MPUIO
-#define INT_MPUIO		INT_730_MPUIO
-#undef	INT_RTC_TIMER
-#define INT_RTC_TIMER		INT_730_RTC_TIMER
-#undef	INT_RTC_ALARM
-#define INT_RTC_ALARM		INT_730_RTC_ALARM
-#endif
-
 /* Max. 128 level 2 IRQs (OMAP1610), 192 GPIOs (OMAP730) and
  * 16 MPUIO lines */
 #define OMAP_MAX_GPIO_LINES	192
@@ -260,7 +240,7 @@
 #include <asm/arch/hardware.h>
 
 #ifndef NR_IRQS
-#define NR_IRQS                 256
+#define NR_IRQS                 IH_BOARD_BASE
 #endif
 
 #endif
diff -Nru a/include/asm-arm/arch-omap/mcbsp.h b/include/asm-arm/arch-omap/mcbsp.h
--- a/include/asm-arm/arch-omap/mcbsp.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-arm/arch-omap/mcbsp.h	2004-12-24 13:36:47 -08:00
@@ -29,7 +29,7 @@
 #define OMAP730_MCBSP1_BASE	0xfffb1000
 #define OMAP730_MCBSP2_BASE	0xfffb1800
 
-#define OMAP1510_MCBSP1_BASE	0xe1011000
+#define OMAP1510_MCBSP1_BASE	0xe1011800
 #define OMAP1510_MCBSP2_BASE	0xfffb1000
 #define OMAP1510_MCBSP3_BASE	0xe1017000
 
diff -Nru a/include/asm-arm/arch-omap/memory.h b/include/asm-arm/arch-omap/memory.h
--- a/include/asm-arm/arch-omap/memory.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-arm/arch-omap/memory.h	2004-12-24 13:36:48 -08:00
@@ -59,12 +59,14 @@
  * OMAP-1510 bus address is translated into a Local Bus address if the
  * OMAP bus type is lbus. We do the address translation based on the
  * device overriding the defaults used in the dma-mapping API.
+ * Note that the is_lbus_device() test is not very efficient on 1510
+ * because of the strncmp().
  */
 #ifdef CONFIG_ARCH_OMAP1510
 
 #define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
 #define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
-#define is_lbus_device(dev)	(cpu_is_omap1510() && dev && dev->coherent_dma_mask == 0x0fffffff)
+#define is_lbus_device(dev)	(cpu_is_omap1510() && dev && (strncmp(dev->bus_id, "ohci", 4) == 0))
 
 #define __arch_page_to_dma(dev, page)	({is_lbus_device(dev) ? \
 					(dma_addr_t)virt_to_lbus(page_address(page)) : \
diff -Nru a/include/asm-arm/arch-omap/mux.h b/include/asm-arm/arch-omap/mux.h
--- a/include/asm-arm/arch-omap/mux.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-arm/arch-omap/mux.h	2004-12-24 13:36:47 -08:00
@@ -43,9 +43,7 @@
 #define PU_PD_SEL_NA		0	/* No pu_pd reg available */
 #define PULL_DWN_CTRL_NA	0	/* No pull-down control needed */
 
-#define DEBUG_MUX
-
-#ifdef DEBUG_MUX
+#ifdef	CONFIG_OMAP_MUX_DEBUG
 #define MUX_REG(reg, mode_offset, mode) .mux_reg_name = "FUNC_MUX_CTRL_"#reg, \
 					.mux_reg = FUNC_MUX_CTRL_##reg, \
 					.mask_offset = mode_offset, \
@@ -73,7 +71,7 @@
 #define PU_PD_REG(reg, status)		.pu_pd_reg = PU_PD_SEL_##reg, \
 					.pu_pd_val = status,
 
-#endif // DEBUG_MUX
+#endif /* CONFIG_OMAP_MUX_DEBUG */
 
 #define MUX_CFG(desc, mux_reg, mode_offset, mode,	\
 		pull_reg, pull_bit, pull_status,	\
@@ -134,6 +132,7 @@
 	UART3_RTS,
 	UART3_CLKREQ,
 	UART3_BCLK,	/* 12MHz clock out */
+	Y15_1610_UART3_RTS,
 
 	/* PWT & PWL */
 	PWT,
@@ -174,8 +173,13 @@
 	R19_1510_GPIO1,
 	M14_1510_GPIO2,
 
+	/* OMAP1610 GPIO */
+	Y15_1610_GPIO17,
+
 	/* OMAP-1710 GPIO */
 	R18_1710_GPIO0,
+	V2_1710_GPIO10,
+	N21_1710_GPIO14,
 	W15_1710_GPIO40,
 
 	/* MPUIO */
@@ -244,6 +248,10 @@
 	P15_1610_UWIRE_CS0,
 	N15_1610_UWIRE_CS1,
 
+	/* OMAP-1610 Flash */
+	L3_1610_FLASH_CS2B_OE,
+	M8_1610_FLASH_CS2B_WE,
+
 	/* First MMC */
 	MMC_CMD,
 	MMC_DAT1,
@@ -310,7 +318,8 @@
  * Table of various FUNC_MUX and PULL_DWN combinations for each device.
  * See also reg_cfg_t above for the lookup table.
  */
-static reg_cfg_set reg_cfg_table[] = {
+static reg_cfg_set __initdata_or_module
+reg_cfg_table[] = {
 /*
  *	 description		mux  mode   mux	 pull pull  pull  pu_pd	 pu  dbg
  *				reg  offset mode reg  bit   ena	  reg
@@ -331,6 +340,7 @@
 MUX_CFG("UART3_RTS",		 5,   15,    2,	  0,  25,   0,	 NA,	 0,  0)
 MUX_CFG("UART3_CLKREQ",		 9,   27,    0,	  2,   5,   0,	 NA,	 0,  0)
 MUX_CFG("UART3_BCLK",		 A,    0,    0,	  2,   6,   0,	 NA,	 0,  0)
+MUX_CFG("Y15_1610_UART3_RTS",	 A,    0,    1,	  2,   6,   0,	 NA,	 0,  0)
 
 /* PWT & PWL, conflicts with UART3 */
 MUX_CFG("PWT",		 	 6,    0,    2,	  0,  30,   0,	 NA,	 0,  0)
@@ -371,9 +381,14 @@
 MUX_CFG("R19_1510_GPIO1",	 7,    6,    0,   1,  10,   1,    0,     0,  1)
 MUX_CFG("M14_1510_GPIO2",	 7,    3,    0,   1,   9,   1,    0,     0,  1)
 
+/* OMAP1610 GPIO */
+MUX_CFG("Y15_1610_GPIO17",	 A,    0,    7,   2,   6,   0,   NA,     0,  1)
+
 /* OMAP-1710 GPIO */
-MUX_CFG("R18_1710_GPIO0",	 7,    9,    0,   1,  11,   1,    1,     1,  1)
-MUX_CFG("W15_1710_GPIO40",	 9,   27,    7,   2,   5,   1,    2,     1,  1)
+MUX_CFG("R18_1710_GPIO0",        7,    9,    0,   1,  11,   1,    1,     1,  1)
+MUX_CFG("V2_1710_GPIO10",        F,   27,    1,   4,   3,   1,    4,     1,  1)
+MUX_CFG("N21_1710_GPIO14",       6,    9,    0,   1,   1,   1,    1,     1,  1)
+MUX_CFG("W15_1710_GPIO40",       9,   27,    7,   2,   5,   1,    2,     1,  1)
 
 /* MPUIO */
 MUX_CFG("MPUIO2",		 7,   18,    0,	  1,   1,   1,	 NA,	 0,  1)
@@ -442,6 +457,10 @@
 MUX_CFG("P15_1610_UWIRE_CS3",	 8,   12,    1,	  1,  22,   0,	  1,	 1,  1)
 MUX_CFG("N15_1610_UWIRE_CS1",	 7,   18,    2,	  1,  14,   0,	 NA,	 0,  1)
 
+/* OMAP-1610 Flash */
+MUX_CFG("L3_1610_FLASH_CS2B_OE",10,    6,    1,	 NA,   0,   0,	 NA,	 0,  1)
+MUX_CFG("M8_1610_FLASH_CS2B_WE",10,    3,    1,	 NA,   0,   0,	 NA,	 0,  1)
+
 /* First MMC interface, same on 1510, 1610 and 1710 */
 MUX_CFG("MMC_CMD",		 A,   27,    0,	  2,  15,   1,	  2,	 1,  1)
 MUX_CFG("MMC_DAT1",		 A,   24,    0,	  2,  14,   1,	  2,	 1,  1)
@@ -501,6 +520,12 @@
 
 #endif	/* __MUX_C__ */
 
+#ifdef	CONFIG_OMAP_MUX
+/* setup pin muxing in Linux */
 extern int omap_cfg_reg(reg_cfg_t reg_cfg);
+#else
+/* boot loader does it all (no warnings from CONFIG_OMAP_MUX_WARNINGS) */
+static inline int omap_cfg_reg(reg_cfg_t reg_cfg) { return 0; }
+#endif
 
 #endif
diff -Nru a/include/asm-arm/arch-omap/omap1610.h b/include/asm-arm/arch-omap/omap1610.h
--- a/include/asm-arm/arch-omap/omap1610.h	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,129 +0,0 @@
-/* linux/include/asm-arm/arch-omap/omap1610.h
- *
- * Hardware definitions for TI OMAP1610 processor.
- *
- * Cleanup for Linux-2.6 by Dirk Behme <dirk.behme@de.bosch.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.
- */
-
-#ifndef __ASM_ARCH_OMAP1610_H
-#define __ASM_ARCH_OMAP1610_H
-
-/*
- * ----------------------------------------------------------------------------
- * Base addresses
- * ----------------------------------------------------------------------------
- */
-
-/* Syntax: XX_BASE = Virtual base address, XX_START = Physical base address */
-
-#define OMAP1610_SRAM_BASE	0xD0000000
-#define OMAP1610_SRAM_SIZE	(SZ_16K)
-#define OMAP1610_SRAM_START	0x20000000
-
-#define OMAP1610_DSP_BASE	0xE0000000
-#define OMAP1610_DSP_SIZE	0x28000
-#define OMAP1610_DSP_START	0xE0000000
-
-#define OMAP1610_DSPREG_BASE	0xE1000000
-#define OMAP1610_DSPREG_SIZE	SZ_128K
-#define OMAP1610_DSPREG_START	0xE1000000
-
-/*
- * ----------------------------------------------------------------------------
- * Memory used by power management
- * ----------------------------------------------------------------------------
- */
-
-#define OMAP1610_SRAM_IDLE_SUSPEND	(OMAP1610_SRAM_BASE + OMAP1610_SRAM_SIZE - 0x200)
-#define OMAP1610_SRAM_API_SUSPEND	(OMAP1610_SRAM_IDLE_SUSPEND + 0x100)
-
-/*
- * ---------------------------------------------------------------------------
- * Interrupts
- * ---------------------------------------------------------------------------
- */
-#define OMAP_IH2_0_BASE		(0xfffe0000)
-#define OMAP_IH2_1_BASE		(0xfffe0100)
-#define OMAP_IH2_2_BASE		(0xfffe0200)
-#define OMAP_IH2_3_BASE		(0xfffe0300)
-
-#define OMAP_IH2_0_ITR		(OMAP_IH2_0_BASE + 0x00)
-#define OMAP_IH2_0_MIR		(OMAP_IH2_0_BASE + 0x04)
-#define OMAP_IH2_0_SIR_IRQ	(OMAP_IH2_0_BASE + 0x10)
-#define OMAP_IH2_0_SIR_FIQ	(OMAP_IH2_0_BASE + 0x14)
-#define OMAP_IH2_0_CONTROL	(OMAP_IH2_0_BASE + 0x18)
-#define OMAP_IH2_0_ILR0		(OMAP_IH2_0_BASE + 0x1c)
-#define OMAP_IH2_0_ISR		(OMAP_IH2_0_BASE + 0x9c)
-
-#define OMAP_IH2_1_ITR		(OMAP_IH2_1_BASE + 0x00)
-#define OMAP_IH2_1_MIR		(OMAP_IH2_1_BASE + 0x04)
-#define OMAP_IH2_1_SIR_IRQ	(OMAP_IH2_1_BASE + 0x10)
-#define OMAP_IH2_1_SIR_FIQ	(OMAP_IH2_1_BASE + 0x14)
-#define OMAP_IH2_1_CONTROL	(OMAP_IH2_1_BASE + 0x18)
-#define OMAP_IH2_1_ILR1		(OMAP_IH2_1_BASE + 0x1c)
-#define OMAP_IH2_1_ISR		(OMAP_IH2_1_BASE + 0x9c)
-
-#define OMAP_IH2_2_ITR		(OMAP_IH2_2_BASE + 0x00)
-#define OMAP_IH2_2_MIR		(OMAP_IH2_2_BASE + 0x04)
-#define OMAP_IH2_2_SIR_IRQ	(OMAP_IH2_2_BASE + 0x10)
-#define OMAP_IH2_2_SIR_FIQ	(OMAP_IH2_2_BASE + 0x14)
-#define OMAP_IH2_2_CONTROL	(OMAP_IH2_2_BASE + 0x18)
-#define OMAP_IH2_2_ILR2		(OMAP_IH2_2_BASE + 0x1c)
-#define OMAP_IH2_2_ISR		(OMAP_IH2_2_BASE + 0x9c)
-
-#define OMAP_IH2_3_ITR		(OMAP_IH2_3_BASE + 0x00)
-#define OMAP_IH2_3_MIR		(OMAP_IH2_3_BASE + 0x04)
-#define OMAP_IH2_3_SIR_IRQ	(OMAP_IH2_3_BASE + 0x10)
-#define OMAP_IH2_3_SIR_FIQ	(OMAP_IH2_3_BASE + 0x14)
-#define OMAP_IH2_3_CONTROL	(OMAP_IH2_3_BASE + 0x18)
-#define OMAP_IH2_3_ILR3		(OMAP_IH2_3_BASE + 0x1c)
-#define OMAP_IH2_3_ISR		(OMAP_IH2_3_BASE + 0x9c)
-
-/*
- * ----------------------------------------------------------------------------
- * Clocks
- * ----------------------------------------------------------------------------
- */
-#define OMAP1610_ARM_IDLECT3	(CLKGEN_REG_BASE + 0x24)
-
-/*
- * ----------------------------------------------------------------------------
- * Pin configuration registers
- * ----------------------------------------------------------------------------
- */
-#define OMAP1610_CONF_VOLTAGE_VDDSHV6	(1 << 8)
-#define OMAP1610_CONF_VOLTAGE_VDDSHV7	(1 << 9)
-#define OMAP1610_CONF_VOLTAGE_VDDSHV8	(1 << 10)
-#define OMAP1610_CONF_VOLTAGE_VDDSHV9	(1 << 11)
-#define OMAP1610_SUBLVDS_CONF_VALID	(1 << 13)
-
-/*
- * ---------------------------------------------------------------------------
- * TIPB bus interface
- * ---------------------------------------------------------------------------
- */
-#define TIPB_SWITCH_BASE		 (0xfffbc800)
-#define OMAP1610_MMCSD2_SSW_MPU_CONF	(TIPB_SWITCH_BASE + 0x160)
-
-#endif /*  __ASM_ARCH_OMAP1610_H */
-
diff -Nru a/include/asm-arm/arch-omap/omap16xx.h b/include/asm-arm/arch-omap/omap16xx.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/arch-omap/omap16xx.h	2004-12-24 13:36:17 -08:00
@@ -0,0 +1,179 @@
+/* linux/include/asm-arm/arch-omap/omap16xx.h
+ *
+ * Hardware definitions for TI OMAP1610/5912/1710 processors.
+ *
+ * Cleanup for Linux-2.6 by Dirk Behme <dirk.behme@de.bosch.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.
+ */
+
+#ifndef __ASM_ARCH_OMAP16XX_H
+#define __ASM_ARCH_OMAP16XX_H
+
+/*
+ * ----------------------------------------------------------------------------
+ * Base addresses
+ * ----------------------------------------------------------------------------
+ */
+
+/* Syntax: XX_BASE = Virtual base address, XX_START = Physical base address */
+
+#define OMAP16XX_SRAM_BASE	0xD0000000
+#define OMAP1610_SRAM_SIZE	(SZ_16K)
+#define OMAP5912_SRAM_SIZE	0x3E800
+#define OMAP16XX_SRAM_START	0x20000000
+
+#define OMAP16XX_DSP_BASE	0xE0000000
+#define OMAP16XX_DSP_SIZE	0x28000
+#define OMAP16XX_DSP_START	0xE0000000
+
+#define OMAP16XX_DSPREG_BASE	0xE1000000
+#define OMAP16XX_DSPREG_SIZE	SZ_128K
+#define OMAP16XX_DSPREG_START	0xE1000000
+
+/*
+ * ----------------------------------------------------------------------------
+ * Memory used by power management
+ * ----------------------------------------------------------------------------
+ */
+
+#define OMAP1610_SRAM_IDLE_SUSPEND	(OMAP16XX_SRAM_BASE + OMAP1610_SRAM_SIZE - 0x200)
+#define OMAP5912_SRAM_IDLE_SUSPEND	(OMAP16XX_SRAM_BASE + OMAP5912_SRAM_SIZE - 0x200)
+#define OMAP1610_SRAM_API_SUSPEND	(OMAP1610_SRAM_IDLE_SUSPEND + 0x100)
+
+/*
+ * ---------------------------------------------------------------------------
+ * Interrupts
+ * ---------------------------------------------------------------------------
+ */
+#define OMAP_IH2_0_BASE		(0xfffe0000)
+#define OMAP_IH2_1_BASE		(0xfffe0100)
+#define OMAP_IH2_2_BASE		(0xfffe0200)
+#define OMAP_IH2_3_BASE		(0xfffe0300)
+
+#define OMAP_IH2_0_ITR		(OMAP_IH2_0_BASE + 0x00)
+#define OMAP_IH2_0_MIR		(OMAP_IH2_0_BASE + 0x04)
+#define OMAP_IH2_0_SIR_IRQ	(OMAP_IH2_0_BASE + 0x10)
+#define OMAP_IH2_0_SIR_FIQ	(OMAP_IH2_0_BASE + 0x14)
+#define OMAP_IH2_0_CONTROL	(OMAP_IH2_0_BASE + 0x18)
+#define OMAP_IH2_0_ILR0		(OMAP_IH2_0_BASE + 0x1c)
+#define OMAP_IH2_0_ISR		(OMAP_IH2_0_BASE + 0x9c)
+
+#define OMAP_IH2_1_ITR		(OMAP_IH2_1_BASE + 0x00)
+#define OMAP_IH2_1_MIR		(OMAP_IH2_1_BASE + 0x04)
+#define OMAP_IH2_1_SIR_IRQ	(OMAP_IH2_1_BASE + 0x10)
+#define OMAP_IH2_1_SIR_FIQ	(OMAP_IH2_1_BASE + 0x14)
+#define OMAP_IH2_1_CONTROL	(OMAP_IH2_1_BASE + 0x18)
+#define OMAP_IH2_1_ILR1		(OMAP_IH2_1_BASE + 0x1c)
+#define OMAP_IH2_1_ISR		(OMAP_IH2_1_BASE + 0x9c)
+
+#define OMAP_IH2_2_ITR		(OMAP_IH2_2_BASE + 0x00)
+#define OMAP_IH2_2_MIR		(OMAP_IH2_2_BASE + 0x04)
+#define OMAP_IH2_2_SIR_IRQ	(OMAP_IH2_2_BASE + 0x10)
+#define OMAP_IH2_2_SIR_FIQ	(OMAP_IH2_2_BASE + 0x14)
+#define OMAP_IH2_2_CONTROL	(OMAP_IH2_2_BASE + 0x18)
+#define OMAP_IH2_2_ILR2		(OMAP_IH2_2_BASE + 0x1c)
+#define OMAP_IH2_2_ISR		(OMAP_IH2_2_BASE + 0x9c)
+
+#define OMAP_IH2_3_ITR		(OMAP_IH2_3_BASE + 0x00)
+#define OMAP_IH2_3_MIR		(OMAP_IH2_3_BASE + 0x04)
+#define OMAP_IH2_3_SIR_IRQ	(OMAP_IH2_3_BASE + 0x10)
+#define OMAP_IH2_3_SIR_FIQ	(OMAP_IH2_3_BASE + 0x14)
+#define OMAP_IH2_3_CONTROL	(OMAP_IH2_3_BASE + 0x18)
+#define OMAP_IH2_3_ILR3		(OMAP_IH2_3_BASE + 0x1c)
+#define OMAP_IH2_3_ISR		(OMAP_IH2_3_BASE + 0x9c)
+
+/*
+ * ----------------------------------------------------------------------------
+ * Clocks
+ * ----------------------------------------------------------------------------
+ */
+#define OMAP16XX_ARM_IDLECT3	(CLKGEN_REG_BASE + 0x24)
+
+/*
+ * ----------------------------------------------------------------------------
+ * Pin configuration registers
+ * ----------------------------------------------------------------------------
+ */
+#define OMAP16XX_CONF_VOLTAGE_VDDSHV6	(1 << 8)
+#define OMAP16XX_CONF_VOLTAGE_VDDSHV7	(1 << 9)
+#define OMAP16XX_CONF_VOLTAGE_VDDSHV8	(1 << 10)
+#define OMAP16XX_CONF_VOLTAGE_VDDSHV9	(1 << 11)
+#define OMAP16XX_SUBLVDS_CONF_VALID	(1 << 13)
+
+/*
+ * ---------------------------------------------------------------------------
+ * TIPB bus interface
+ * ---------------------------------------------------------------------------
+ */
+#define TIPB_SWITCH_BASE		 (0xfffbc800)
+#define OMAP16XX_MMCSD2_SSW_MPU_CONF	(TIPB_SWITCH_BASE + 0x160)
+
+/* UART3 Registers Maping through MPU bus */
+#define UART3_RHR               (OMAP_UART3_BASE + 0)
+#define UART3_THR               (OMAP_UART3_BASE + 0)
+#define UART3_DLL               (OMAP_UART3_BASE + 0)
+#define UART3_IER               (OMAP_UART3_BASE + 4)
+#define UART3_DLH               (OMAP_UART3_BASE + 4)
+#define UART3_IIR               (OMAP_UART3_BASE + 8)
+#define UART3_FCR               (OMAP_UART3_BASE + 8)
+#define UART3_EFR               (OMAP_UART3_BASE + 8)
+#define UART3_LCR               (OMAP_UART3_BASE + 0x0C)
+#define UART3_MCR               (OMAP_UART3_BASE + 0x10)
+#define UART3_XON1_ADDR1        (OMAP_UART3_BASE + 0x10)
+#define UART3_XON2_ADDR2        (OMAP_UART3_BASE + 0x14)
+#define UART3_LSR               (OMAP_UART3_BASE + 0x14)
+#define UART3_TCR               (OMAP_UART3_BASE + 0x18)
+#define UART3_MSR               (OMAP_UART3_BASE + 0x18)
+#define UART3_XOFF1             (OMAP_UART3_BASE + 0x18)
+#define UART3_XOFF2             (OMAP_UART3_BASE + 0x1C)
+#define UART3_SPR               (OMAP_UART3_BASE + 0x1C)
+#define UART3_TLR               (OMAP_UART3_BASE + 0x1C)
+#define UART3_MDR1              (OMAP_UART3_BASE + 0x20)
+#define UART3_MDR2              (OMAP_UART3_BASE + 0x24)
+#define UART3_SFLSR             (OMAP_UART3_BASE + 0x28)
+#define UART3_TXFLL             (OMAP_UART3_BASE + 0x28)
+#define UART3_RESUME            (OMAP_UART3_BASE + 0x2C)
+#define UART3_TXFLH             (OMAP_UART3_BASE + 0x2C)
+#define UART3_SFREGL            (OMAP_UART3_BASE + 0x30)
+#define UART3_RXFLL             (OMAP_UART3_BASE + 0x30)
+#define UART3_SFREGH            (OMAP_UART3_BASE + 0x34)
+#define UART3_RXFLH             (OMAP_UART3_BASE + 0x34)
+#define UART3_BLR               (OMAP_UART3_BASE + 0x38)
+#define UART3_ACREG             (OMAP_UART3_BASE + 0x3C)
+#define UART3_DIV16             (OMAP_UART3_BASE + 0x3C)
+#define UART3_SCR               (OMAP_UART3_BASE + 0x40)
+#define UART3_SSR               (OMAP_UART3_BASE + 0x44)
+#define UART3_EBLR              (OMAP_UART3_BASE + 0x48)
+#define UART3_OSC_12M_SEL       (OMAP_UART3_BASE + 0x4C)
+#define UART3_MVR               (OMAP_UART3_BASE + 0x50)
+
+/*
+ * ----------------------------------------------------------------------------
+ * Pulse-Width Light
+ * ----------------------------------------------------------------------------
+ */
+#define OMAP16XX_PWL_BASE	(0xfffb5800)
+#define OMAP16XX_PWL_ENABLE	(OMAP16XX_PWL_BASE + 0x00)
+#define OMAP16XX_PWL_CLK_ENABLE	(OMAP16XX_PWL_BASE + 0x04)
+
+#endif /*  __ASM_ARCH_OMAP16XX_H */
+
diff -Nru a/include/asm-arm/arch-omap/omap5912.h b/include/asm-arm/arch-omap/omap5912.h
--- a/include/asm-arm/arch-omap/omap5912.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,112 +0,0 @@
-/* linux/include/asm-arm/arch-omap/omap5912.h
- *
- * Hardware definitions for TI OMAP5912 processor.
- *
- * Written by Dirk Behme <dirk.behme@de.bosch.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.
- */
-
-#ifndef __ASM_ARCH_OMAP5912_H
-#define __ASM_ARCH_OMAP5912_H
-
-/*
- * ----------------------------------------------------------------------------
- * Base addresses
- * ----------------------------------------------------------------------------
- */
-
-/* Syntax: XX_BASE = Virtual base address, XX_START = Physical base address */
-
-/* OMAP5912 internal SRAM size is 250kByte */
-#define OMAP5912_SRAM_BASE	0xD0000000
-#define OMAP5912_SRAM_SIZE	0x3E800
-#define OMAP5912_SRAM_START	0x20000000
-
-#define OMAP5912_DSP_BASE	0xE0000000
-#define OMAP5912_DSP_SIZE	0x50000
-#define OMAP5912_DSP_START	0xE0000000
-
-#define OMAP5912_DSPREG_BASE	0xE1000000
-#define OMAP5912_DSPREG_SIZE	SZ_128K
-#define OMAP5912_DSPREG_START	0xE1000000
-
-/*
- * ----------------------------------------------------------------------------
- * Memory used by power management
- * ----------------------------------------------------------------------------
- */
-
-#define OMAP5912_SRAM_IDLE_SUSPEND	(OMAP5912_SRAM_BASE + OMAP5912_SRAM_SIZE - 0x200)
-#define OMAP5912_SRAM_API_SUSPEND	(OMAP5912_SRAM_IDLE_SUSPEND + 0x100)
-
-/*
- * ---------------------------------------------------------------------------
- * Interrupts
- * ---------------------------------------------------------------------------
- */
-#define OMAP_IH2_0_BASE		(0xfffe0000)
-#define OMAP_IH2_1_BASE		(0xfffe0100)
-#define OMAP_IH2_2_BASE		(0xfffe0200)
-#define OMAP_IH2_3_BASE		(0xfffe0300)
-
-#define OMAP_IH2_0_ITR		(OMAP_IH2_0_BASE + 0x00)
-#define OMAP_IH2_0_MIR		(OMAP_IH2_0_BASE + 0x04)
-#define OMAP_IH2_0_SIR_IRQ	(OMAP_IH2_0_BASE + 0x10)
-#define OMAP_IH2_0_SIR_FIQ	(OMAP_IH2_0_BASE + 0x14)
-#define OMAP_IH2_0_CONTROL	(OMAP_IH2_0_BASE + 0x18)
-#define OMAP_IH2_0_ILR0		(OMAP_IH2_0_BASE + 0x1c)
-#define OMAP_IH2_0_ISR		(OMAP_IH2_0_BASE + 0x9c)
-
-#define OMAP_IH2_1_ITR		(OMAP_IH2_1_BASE + 0x00)
-#define OMAP_IH2_1_MIR		(OMAP_IH2_1_BASE + 0x04)
-#define OMAP_IH2_1_SIR_IRQ	(OMAP_IH2_1_BASE + 0x10)
-#define OMAP_IH2_1_SIR_FIQ	(OMAP_IH2_1_BASE + 0x14)
-#define OMAP_IH2_1_CONTROL	(OMAP_IH2_1_BASE + 0x18)
-#define OMAP_IH2_1_ILR1		(OMAP_IH2_1_BASE + 0x1c)
-#define OMAP_IH2_1_ISR		(OMAP_IH2_1_BASE + 0x9c)
-
-#define OMAP_IH2_2_ITR		(OMAP_IH2_2_BASE + 0x00)
-#define OMAP_IH2_2_MIR		(OMAP_IH2_2_BASE + 0x04)
-#define OMAP_IH2_2_SIR_IRQ	(OMAP_IH2_2_BASE + 0x10)
-#define OMAP_IH2_2_SIR_FIQ	(OMAP_IH2_2_BASE + 0x14)
-#define OMAP_IH2_2_CONTROL	(OMAP_IH2_2_BASE + 0x18)
-#define OMAP_IH2_2_ILR2		(OMAP_IH2_2_BASE + 0x1c)
-#define OMAP_IH2_2_ISR		(OMAP_IH2_2_BASE + 0x9c)
-
-#define OMAP_IH2_3_ITR		(OMAP_IH2_3_BASE + 0x00)
-#define OMAP_IH2_3_MIR		(OMAP_IH2_3_BASE + 0x04)
-#define OMAP_IH2_3_SIR_IRQ	(OMAP_IH2_3_BASE + 0x10)
-#define OMAP_IH2_3_SIR_FIQ	(OMAP_IH2_3_BASE + 0x14)
-#define OMAP_IH2_3_CONTROL	(OMAP_IH2_3_BASE + 0x18)
-#define OMAP_IH2_3_ILR3		(OMAP_IH2_3_BASE + 0x1c)
-#define OMAP_IH2_3_ISR		(OMAP_IH2_3_BASE + 0x9c)
-
-/*
- * ----------------------------------------------------------------------------
- * System control registers
- * ----------------------------------------------------------------------------
- */
-
-#define OMAP5912_ARM_IDLECT3	(CLKGEN_REG_BASE + 0x24)
-
-#endif /*  __ASM_ARCH_OMAP5912_H */
-
diff -Nru a/include/asm-arm/arch-omap/pm.h b/include/asm-arm/arch-omap/pm.h
--- a/include/asm-arm/arch-omap/pm.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-arm/arch-omap/pm.h	2004-12-24 13:36:16 -08:00
@@ -1,13 +1,15 @@
 /*
- * FILE NAME include/asm/arch-omap/pm.h
+ * linux/include/asm/arch-omap/pm.h
  *
- * BRIEF MODULE DESCRIPTION
+ * Header file for OMAP Power Management Routines
  *
  * Author: MontaVista Software, Inc.
  *	   support@mvista.com
  *
  * Copyright 2002 MontaVista Software Inc.
  *
+ * Cleanup 2004 for Linux 2.6 by Dirk Behme <dirk.behme@de.bosch.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
@@ -29,158 +31,199 @@
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-/*
- * List of global OMAP registers to preserve.  All registers are 16 bits
- * and must be accessed with 16 read/writes.
- * More ones like CP and general purpose register values are preserved
- * with the stack pointer in sleep.S.
- */
 #ifndef __ASM_ARCH_OMAP_PM_H
 #define __ASM_ARCH_OMAP_PM_H
 
-#define ARM_REG_BASE		(0xfffece00)
-#define ARM_ASM_IDLECT1		(ARM_REG_BASE + 0x4)
-#define ARM_ASM_IDLECT2		(ARM_REG_BASE + 0x8)
-#define ARM_ASM_RSTCT1		(ARM_REG_BASE + 0x10)
-#define ARM_ASM_RSTCT2		(ARM_REG_BASE + 0x14)
-#define ARM_ASM_SYSST		(ARM_REG_BASE + 0x18)
 /*
- * Traffic Controller Memory Interface Registers
+ * ----------------------------------------------------------------------------
+ * Register and offset definitions to be used in PM assembler code
+ * ----------------------------------------------------------------------------
  */
-#define TCMIF_BASE		0xfffecc00
-#define EMIFS_ASM_CONFIG_REG	(TCMIF_BASE + 0x0c)
-#define EMIFF_ASM_SDRAM_CONFIG	(TCMIF_BASE + 0x20)
-#define IRQ_MIR1		(OMAP_IH1_BASE + IRQ_MIR)
-
-#ifdef CONFIG_ARCH_OMAP1510
-#define IRQ_MIR2		(OMAP_IH2_BASE + IRQ_MIR)
-#else /* CONFIG_ARCH_OMAP1610 */
-#define IRQ_MIR2_0		(OMAP_IH2_0_BASE + IRQ_MIR)
-#define IRQ_MIR2_1		(OMAP_IH2_1_BASE + IRQ_MIR)
-#define IRQ_MIR2_2		(OMAP_IH2_2_BASE + IRQ_MIR)
-#define IRQ_MIR2_3		(OMAP_IH2_3_BASE + IRQ_MIR)
-#endif
+#define CLKGEN_REG_ASM_BASE		io_p2v(0xfffece00)
+#define ARM_IDLECT1_ASM_OFFSET		0x04
+#define ARM_IDLECT2_ASM_OFFSET		0x08
+
+#define TCMIF_ASM_BASE			io_p2v(0xfffecc00)
+#define EMIFS_CONFIG_ASM_OFFSET		0x0c
+#define EMIFF_SDRAM_CONFIG_ASM_OFFSET	0x20
 
+/*
+ * ----------------------------------------------------------------------------
+ * Powermanagement bitmasks
+ * ----------------------------------------------------------------------------
+ */
 #define IDLE_WAIT_CYCLES		0x00000fff
 #define PERIPHERAL_ENABLE		0x2
 
-#ifdef CONFIG_ARCH_OMAP1510
-#define DEEP_SLEEP_REQUEST		0x0ec7
-#define BIG_SLEEP_REQUEST		0x0cc5
-#define IDLE_LOOP_REQUEST		0x0c00
-#define IDLE_CLOCK_DOMAINS		0x2
-#else /* CONFIG_ARCH_OMAP1610 */
-#define DEEP_SLEEP_REQUEST		0x17c7
-#define BIG_SLEEP_REQUEST		TBD
-#define IDLE_LOOP_REQUEST		0x0400
-#define IDLE_CLOCK_DOMAINS		0x09c7
-#endif
-
 #define SELF_REFRESH_MODE		0x0c000001
 #define IDLE_EMIFS_REQUEST		0xc
 #define MODEM_32K_EN			0x1
+#define PER_EN				0x1
 
-#ifndef __ASSEMBLER__
-extern void omap_pm_idle(void);
-extern void omap_pm_suspend(void);
-extern int omap_cpu_suspend(unsigned short, unsigned short);
-extern int omap_idle_loop_suspend(void);
-
-#ifdef CONFIG_ARCH_OMAP1510
-#define OMAP_SRAM_IDLE_SUSPEND	0xd002F000
-#define OMAP_SRAM_API_SUSPEND	0xd002F200
-#else /* CONFIG_ARCH_OMAP1610 */
-#define OMAP_SRAM_IDLE_SUSPEND	0xd0000400
-#define OMAP_SRAM_API_SUSPEND	0xd0000600
-#endif
-
-#define CPU_SUSPEND_SIZE	200
-#define ARM_REG_BASE		(0xfffece00)
-#define ARM_ASM_IDLECT1		(ARM_REG_BASE + 0x4)
-#define ARM_ASM_IDLECT2		(ARM_REG_BASE + 0x8)
-#define ARM_ASM_RSTCT1		(ARM_REG_BASE + 0x10)
-#define ARM_ASM_RSTCT2		(ARM_REG_BASE + 0x14)
-#define ARM_ASM_SYSST		(ARM_REG_BASE + 0x18)
-
-#define TCMIF_BASE		0xfffecc00
-#define PM_EMIFS_CONFIG_REG	(TCMIF_BASE + 0x0c)
-#define PM_EMIFF_SDRAM_CONFIG	(TCMIF_BASE + 0x20)
-#define FUNC_MUX_CTRL_LOW_PWR	(0xfffe1020)
-
-#ifdef CONFIG_ARCH_OMAP1510
-#define ULPD_LOW_POWER_REQ             0x0001
-#else /* CONFIG_ARCH_OMAP1610 */
-#define ULPD_LOW_POWER_REQ             0x3
-#endif
-#define ULPD_LOW_PWR                   0x1000
-#define ULPD_LOW_POWER_EN              0x0001
+#define CPU_SUSPEND_SIZE		200
+#define ULPD_LOW_POWER_EN		0x0001
 
 #define DSP_IDLE_DELAY			10
 #define DSP_IDLE			0x0040
+#define DSP_RST				0x0004
 #define DSP_ENABLE			0x0002
 #define SUFFICIENT_DSP_RESET_TIME	1000
 #define DEFAULT_MPUI_CONFIG		0x05cf
 #define ENABLE_XORCLK			0x2
-#define DSP_RESET			0x2000
+#define DSP_CLOCK_ENABLE		0x2000
+#define DSP_IDLE_MODE			0x2
 #define TC_IDLE_REQUEST			(0x0000000c)
-#define EMIFF_CONFIG_REG		EMIFF_SDRAM_CONFIG
 
+#define IRQ_LEVEL2			(1<<0)
+#define IRQ_KEYBOARD			(1<<1)
+#define IRQ_UART2			(1<<15)
+
+#define PDE_BIT				0x08
+#define PWD_EN_BIT			0x04
+#define EN_PERCK_BIT			0x04
+
+#define OMAP1510_DEEP_SLEEP_REQUEST	0x0ec7
+#define OMAP1510_BIG_SLEEP_REQUEST	0x0cc5
+#define OMAP1510_IDLE_LOOP_REQUEST	0x0c00
+#define OMAP1510_IDLE_CLOCK_DOMAINS	0x2
+#define OMAP1510_ULPD_LOW_POWER_REQ	0x0001
+
+#define OMAP1610_DEEP_SLEEP_REQUEST	0x17c7
+#define OMAP1610_BIG_SLEEP_REQUEST	TBD
+#define OMAP1610_IDLE_LOOP_REQUEST	0x0400
+#define OMAP1610_IDLE_CLOCK_DOMAINS	0x09c7
+#define OMAP1610_ULPD_LOW_POWER_REQ	0x3
 
-#define ARM_SAVE(x) arm_sleep_save[ARM_SLEEP_SAVE_##x] = omap_readw(x)
-#define ARM_RESTORE(x) omap_writew((unsigned short)arm_sleep_save[ARM_SLEEP_SAVE_##x], x)
+#ifndef OMAP1510_SRAM_IDLE_SUSPEND
+#define OMAP1510_SRAM_IDLE_SUSPEND 0
+#endif
+#ifndef OMAP1610_SRAM_IDLE_SUSPEND
+#define OMAP1610_SRAM_IDLE_SUSPEND 0
+#endif
+#ifndef OMAP5912_SRAM_IDLE_SUSPEND
+#define OMAP5912_SRAM_IDLE_SUSPEND 0
+#endif
+
+#ifndef OMAP1510_SRAM_API_SUSPEND
+#define OMAP1510_SRAM_API_SUSPEND 0
+#endif
+#ifndef OMAP1610_SRAM_API_SUSPEND
+#define OMAP1610_SRAM_API_SUSPEND 0
+#endif
+#ifndef OMAP5912_SRAM_API_SUSPEND
+#define OMAP5912_SRAM_API_SUSPEND 0
+#endif
+
+#if     !defined(CONFIG_ARCH_OMAP1510) && \
+	!defined(CONFIG_ARCH_OMAP16XX)
+#error "Power management for this processor not implemented yet"
+#endif
+
+#ifndef __ASSEMBLER__
+extern void omap_pm_idle(void);
+extern void omap_pm_suspend(void);
+extern int omap1510_cpu_suspend(unsigned short, unsigned short);
+extern int omap1610_cpu_suspend(unsigned short, unsigned short);
+extern int omap1510_idle_loop_suspend(void);
+extern int omap1610_idle_loop_suspend(void);
+extern unsigned int omap1510_cpu_suspend_sz;
+extern unsigned int omap1510_idle_loop_suspend_sz;
+extern unsigned int omap1610_cpu_suspend_sz;
+extern unsigned int omap1610_idle_loop_suspend_sz;
+
+#define ARM_SAVE(x) arm_sleep_save[ARM_SLEEP_SAVE_##x] = omap_readl(x)
+#define ARM_RESTORE(x) omap_writel((arm_sleep_save[ARM_SLEEP_SAVE_##x]), (x))
 #define ARM_SHOW(x) arm_sleep_save[ARM_SLEEP_SAVE_##x]
 
 #define ULPD_SAVE(x) ulpd_sleep_save[ULPD_SLEEP_SAVE_##x] = omap_readw(x)
-#define ULPD_RESTORE(x) omap_writew((unsigned short)ulpd_sleep_save[ULPD_SLEEP_SAVE_##x], x)
+#define ULPD_RESTORE(x) omap_writew((ulpd_sleep_save[ULPD_SLEEP_SAVE_##x]), (x))
 #define ULPD_SHOW(x) ulpd_sleep_save[ULPD_SLEEP_SAVE_##x]
 
-#define MPUI_SAVE(x) mpui_sleep_save[MPUI_SLEEP_SAVE_##x] = omap_readl(x)
-#define MPUI_RESTORE(x) omap_writel((unsigned int)mpui_sleep_save[MPUI_SLEEP_SAVE_##x], x)
-#define MPUI_SHOW(x) (unsigned int)mpui_sleep_save[MPUI_SLEEP_SAVE_##x]
+#define MPUI1510_SAVE(x) mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_##x] = omap_readl(x)
+#define MPUI1510_RESTORE(x) omap_writel((mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_##x]), (x))
+#define MPUI1510_SHOW(x) mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_##x]
+
+#define MPUI1610_SAVE(x) mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_##x] = omap_readl(x)
+#define MPUI1610_RESTORE(x) omap_writel((mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_##x]), (x))
+#define MPUI1610_SHOW(x) mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_##x]
+
+/*
+ * List of global OMAP registers to preserve.
+ * More ones like CP and general purpose register values are preserved
+ * with the stack pointer in sleep.S.
+ */
 
 enum arm_save_state {
 	ARM_SLEEP_SAVE_START = 0,
 	/*
-	 * 9 MPU control registers, all 16 bits
+	 * MPU control registers 32 bits
 	 */
-	ARM_SLEEP_SAVE_ARM_CKCTL, ARM_SLEEP_SAVE_ARM_IDLECT1,
-	ARM_SLEEP_SAVE_ARM_IDLECT2, ARM_SLEEP_SAVE_ARM_EWUPCT,
-	ARM_SLEEP_SAVE_ARM_RSTCT1, ARM_SLEEP_SAVE_ARM_RSTCT2,
+	ARM_SLEEP_SAVE_ARM_CKCTL,
+	ARM_SLEEP_SAVE_ARM_IDLECT1,
+	ARM_SLEEP_SAVE_ARM_IDLECT2,
+	ARM_SLEEP_SAVE_ARM_EWUPCT,
+	ARM_SLEEP_SAVE_ARM_RSTCT1,
+	ARM_SLEEP_SAVE_ARM_RSTCT2,
 	ARM_SLEEP_SAVE_ARM_SYSST,
-
 	ARM_SLEEP_SAVE_SIZE
 };
 
 enum ulpd_save_state {
 	ULPD_SLEEP_SAVE_START = 0,
-	ULPD_SLEEP_SAVE_ULPD_IT_STATUS_REG, ULPD_SLEEP_SAVE_ULPD_CLOCK_CTRL_REG,
-	ULPD_SLEEP_SAVE_ULPD_SOFT_REQ_REG, ULPD_SLEEP_SAVE_ULPD_STATUS_REQ_REG,
-	ULPD_SLEEP_SAVE_ULPD_DPLL_CTRL_REG, ULPD_SLEEP_SAVE_ULPD_POWER_CTRL_REG,
+	/*
+	 * ULPD registers 16 bits
+	 */
+	ULPD_SLEEP_SAVE_ULPD_IT_STATUS,
+	ULPD_SLEEP_SAVE_ULPD_CLOCK_CTRL,
+	ULPD_SLEEP_SAVE_ULPD_SOFT_REQ,
+	ULPD_SLEEP_SAVE_ULPD_STATUS_REQ,
+	ULPD_SLEEP_SAVE_ULPD_DPLL_CTRL,
+	ULPD_SLEEP_SAVE_ULPD_POWER_CTRL,
 	ULPD_SLEEP_SAVE_SIZE
 };
 
-enum mpui_save_state {
+enum mpui1510_save_state {
+	MPUI1510_SLEEP_SAVE_START = 0,
 	/*
 	 * MPUI registers 32 bits
 	 */
-	MPUI_SLEEP_SAVE_MPUI_CTRL_REG, MPUI_SLEEP_SAVE_MPUI_DSP_BOOT_CONFIG,
-	MPUI_SLEEP_SAVE_MPUI_DSP_API_CONFIG,
-	MPUI_SLEEP_SAVE_MPUI_DSP_STATUS_REG,
-	MPUI_SLEEP_SAVE_PM_EMIFF_SDRAM_CONFIG,
-	MPUI_SLEEP_SAVE_PM_EMIFS_CONFIG_REG,
-	MPUI_SLEEP_SAVE_IRQ_MIR1,
-#ifdef CONFIG_ARCH_OMAP1510
-	MPUI_SLEEP_SAVE_IRQ_MIR2,
-#else /* CONFIG_ARCH_OMAP1610 */
-	MPUI_SLEEP_SAVE_IRQ_MIR2_0,
-	MPUI_SLEEP_SAVE_IRQ_MIR2_1,
-	MPUI_SLEEP_SAVE_IRQ_MIR2_2,
-	MPUI_SLEEP_SAVE_IRQ_MIR2_3,
+	MPUI1510_SLEEP_SAVE_MPUI_CTRL,
+	MPUI1510_SLEEP_SAVE_MPUI_DSP_BOOT_CONFIG,
+	MPUI1510_SLEEP_SAVE_MPUI_DSP_API_CONFIG,
+	MPUI1510_SLEEP_SAVE_MPUI_DSP_STATUS,
+	MPUI1510_SLEEP_SAVE_EMIFF_SDRAM_CONFIG,
+	MPUI1510_SLEEP_SAVE_EMIFS_CONFIG,
+	MPUI1510_SLEEP_SAVE_OMAP_IH1_MIR,
+	MPUI1510_SLEEP_SAVE_OMAP_IH2_MIR,
+#if defined(CONFIG_ARCH_OMAP1510)
+	MPUI1510_SLEEP_SAVE_SIZE
+#else
+	MPUI1510_SLEEP_SAVE_SIZE = 0
 #endif
-
-	MPUI_SLEEP_SAVE_SIZE
 };
 
-
-#endif	/* ASSEMBLER */
+enum mpui1610_save_state {
+	MPUI1610_SLEEP_SAVE_START = 0,
+	/*
+	 * MPUI registers 32 bits
+	 */
+	MPUI1610_SLEEP_SAVE_MPUI_CTRL,
+	MPUI1610_SLEEP_SAVE_MPUI_DSP_BOOT_CONFIG,
+	MPUI1610_SLEEP_SAVE_MPUI_DSP_API_CONFIG,
+	MPUI1610_SLEEP_SAVE_MPUI_DSP_STATUS,
+	MPUI1610_SLEEP_SAVE_EMIFF_SDRAM_CONFIG,
+	MPUI1610_SLEEP_SAVE_EMIFS_CONFIG,
+	MPUI1610_SLEEP_SAVE_OMAP_IH1_MIR,
+	MPUI1610_SLEEP_SAVE_OMAP_IH2_0_MIR,
+	MPUI1610_SLEEP_SAVE_OMAP_IH2_1_MIR,
+	MPUI1610_SLEEP_SAVE_OMAP_IH2_2_MIR,
+	MPUI1610_SLEEP_SAVE_OMAP_IH2_3_MIR,
+#if defined(CONFIG_ARCH_OMAP16XX)
+	MPUI1610_SLEEP_SAVE_SIZE
+#else
+	MPUI1610_SLEEP_SAVE_SIZE = 0
 #endif
+};
+
+#endif /* ASSEMBLER */
+#endif /* __ASM_ARCH_OMAP_PM_H */
diff -Nru a/include/asm-arm/arch-omap/serial.h b/include/asm-arm/arch-omap/serial.h
--- a/include/asm-arm/arch-omap/serial.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,52 +0,0 @@
-/*
- * linux/include/asm-arm/arch-omap/serial.h
- *
- * BRIEF MODULE DESCRIPTION
- * serial definitions
- *
- */
-
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-#define OMAP_UART1_BASE		(unsigned char *)0xfffb0000
-#define OMAP_UART2_BASE		(unsigned char *)0xfffb0800
-#define OMAP_UART3_BASE		(unsigned char *)0xfffb9800
-
-#ifndef __ASSEMBLY__
-
-#include <asm/arch/hardware.h>
-#include <asm/irq.h>
-
-#define OMAP1510_BASE_BAUD	(12000000/16)
-#define OMAP1610_BASE_BAUD	(48000000/16)
-
-/* OMAP FCR trigger  redefinitions */
-#define UART_FCR_R_TRIGGER_8	0x00	/* Mask for receive trigger set at 8 */
-#define UART_FCR_R_TRIGGER_16	0x40	/* Mask for receive trigger set at 16 */
-#define UART_FCR_R_TRIGGER_56	0x80	/* Mask for receive trigger set at 56 */
-#define UART_FCR_R_TRIGGER_60	0xC0	/* Mask for receive trigger set at 60 */
-
-/* There is an error in the description of the transmit trigger levels of
-   OMAP5910 TRM from January 2003. The transmit trigger level 56 is not
-   56 but 32, the transmit trigger level 60 is not 60 but 56!
-   Additionally, the descritption of these trigger levels is
-   a little bit unclear. The trigger level define the number of EMPTY
-   entries in the FIFO. Thus, if TRIGGER_8 is used, an interrupt is requested
-   if 8 FIFO entries are empty (and 56 entries are still filled [the FIFO
-   size is 64]). Or: If TRIGGER_56 is selected, everytime there are less than
-   8 characters in the FIFO, an interrrupt is spawned. In other words: The
-   trigger number is equal the number of characters which can be
-   written without FIFO overrun */
-
-#define UART_FCR_T_TRIGGER_8	0x00	/* Mask for transmit trigger set at 8 */
-#define UART_FCR_T_TRIGGER_16	0x10	/* Mask for transmit trigger set at 16 */
-#define UART_FCR_T_TRIGGER_32	0x20	/* Mask for transmit trigger set at 32 */
-#define UART_FCR_T_TRIGGER_56	0x30	/* Mask for transmit trigger set at 56 */
-
-#define STD_SERIAL_PORT_DEFNS
-#define EXTRA_SERIAL_PORT_DEFNS
-#define BASE_BAUD 0
-
-#endif	/* __ASSEMBLY__ */
-#endif	/* __ASM_ARCH_SERIAL_H */
diff -Nru a/include/asm-arm/arch-omap/tc.h b/include/asm-arm/arch-omap/tc.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/arch-omap/tc.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,64 @@
+/*
+ * linux/include/asm-arm/arch-omap/tc.h
+ *
+ * OMAP Traffic Controller
+ *
+ * Copyright (C) 2004 Nokia Corporation
+ * Author: Imre Deak <imre.deak@nokia.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 program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef __ASM_ARCH_TC_H
+#define __ASM_ARCH_TC_H
+
+#define OMAP_TC_OCPT1_PRIOR	0xFFFECC00
+#define OMAP_TC_EMIFS_PRIOR	0xFFFECC04
+#define OMAP_TC_EMIFF_PRIOR	0xFFFECC08
+#define OMAP_TC_OCPT2_PRIOR	0xFFFECCD0
+
+
+/* EMIF Slow Interface Configuration Register */
+#define	OMAP_EMIFS_CONFIG_REG	__REG32(EMIFS_CONFIG)
+
+#define OMAP_EMIFS_CONFIG_FR		(1 << 4)
+#define OMAP_EMIFS_CONFIG_PDE		(1 << 3)
+#define OMAP_EMIFS_CONFIG_PWD_EN	(1 << 2)
+#define OMAP_EMIFS_CONFIG_BM		(1 << 1)
+#define OMAP_EMIFS_CONFIG_WP		(1 << 0)
+
+/* external EMIFS chipselect regions */
+#define	OMAP_CS1_PHYS		0x04000000
+#define	OMAP_CS1_SIZE		SZ_64M
+
+#define	OMAP_CS1A_PHYS		OMAP_CS1_PHYS
+#define	OMAP_CS1A_SIZE		SZ_32M
+
+#define	OMAP_CS1B_PHYS		(OMAP_CS1A_PHYS + OMAP_CS1A_SIZE)
+#define	OMAP_CS1B_SIZE		SZ_32M
+
+#define	OMAP_CS2_PHYS		0x08000000
+#define	OMAP_CS2_SIZE		SZ_64M
+
+#define	OMAP_CS2A_PHYS		OMAP_CS2_PHYS
+#define	OMAP_CS2A_SIZE		SZ_32M
+
+#define	OMAP_CS2B_PHYS		(OMAP_CS2A_PHYS + OMAP_CS2A_SIZE)
+#define	OMAP_CS2B_SIZE		SZ_32M
+
+#define	OMAP_CS3_PHYS		0x0c000000
+#define	OMAP_CS3_SIZE		SZ_64M
+
+#endif	/* __ASM_ARCH_TC_H */
diff -Nru a/include/asm-arm/arch-omap/timex.h b/include/asm-arm/arch-omap/timex.h
--- a/include/asm-arm/arch-omap/timex.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-omap/timex.h	2004-12-24 13:36:17 -08:00
@@ -28,8 +28,6 @@
 #if !defined(__ASM_ARCH_OMAP_TIMEX_H)
 #define __ASM_ARCH_OMAP_TIMEX_H
 
-#include <asm/arch/clocks.h>
-/* TC clock */
-#define CLOCK_TICK_RATE		((OMAP_CK_MAX_RATE*1000000)/2)
+#define CLOCK_TICK_RATE		(HZ * 100000UL)
 
 #endif /* __ASM_ARCH_OMAP_TIMEX_H */
diff -Nru a/include/asm-arm/arch-omap/uncompress.h b/include/asm-arm/arch-omap/uncompress.h
--- a/include/asm-arm/arch-omap/uncompress.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-arm/arch-omap/uncompress.h	2004-12-24 13:37:19 -08:00
@@ -20,10 +20,13 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/serial_reg.h>
-#include <asm/hardware.h>
-#include <asm/arch/serial.h>
+#include <asm/arch/hardware.h>
+
+unsigned int system_rev;
 
 #define UART_OMAP_MDR1		0x08	/* mode definition register */
+#define OMAP_ID_730		0x355F
+#define ID_MASK			0x7fff
 #define check_port(base, shift) ((base[UART_OMAP_MDR1 << shift] & 7) == 0)
 #define omap_get_id() ((*(volatile unsigned int *)(0xfffed404)) >> 12) & ID_MASK
 
@@ -31,7 +34,7 @@
 putstr(const char *s)
 {
 	volatile u8 * uart = 0;
-	int shift = 0;
+	int shift;
 
 #ifdef	CONFIG_OMAP_LL_DEBUG_UART3
 	uart = (volatile u8 *)(OMAP_UART3_BASE);
@@ -46,21 +49,11 @@
 		/* MMU is not on, so cpu_is_omapXXXX() won't work here */
 		unsigned int omap_id = omap_get_id();
 
-		if (omap_id == OMAP_ID_1510 || omap_id == OMAP_ID_1610 ||
-		    omap_id == OMAP_ID_1710 || omap_id == OMAP_ID_5912) {
-			shift = 2;
-		} else if (omap_id == OMAP_ID_730) {
+		if (omap_id == OMAP_ID_730)
 			shift = 0;
-		} else {
-			/* Assume nothing for unknown OMAP processors.
-			 * Add an entry for your OMAP type to select
-			 * the default serial console here. If the
-			 * serial port is enabled, we'll use it to
-			 * display status messages. Else we'll be
-			 * quiet.
-			 */
-			return;
-		}
+		else
+			shift = 2;
+
 		if (check_port(uart, shift))
 			break;
 		/* Silent boot if no serial ports are enabled. */
diff -Nru a/include/asm-arm/arch-pxa/io.h b/include/asm-arm/arch-pxa/io.h
--- a/include/asm-arm/arch-pxa/io.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/arch-pxa/io.h	2004-12-24 13:36:18 -08:00
@@ -12,8 +12,8 @@
  * We don't actually have real ISA nor PCI buses, but there is so many
  * drivers out there that might just work if we fake them...
  */
-#define __io(a)			(a)
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		((unsigned long)(a))
+#define __io(a)			((void __iomem *)(a))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		(a)
 
 #endif
diff -Nru a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
--- a/include/asm-arm/arch-pxa/pxa-regs.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-arm/arch-pxa/pxa-regs.h	2004-12-24 13:37:00 -08:00
@@ -169,12 +169,16 @@
 #define DRCMRTXPCDR	DRCMR12
 #define DRCMRRXSSDR	DRCMR13
 #define DRCMRTXSSDR	DRCMR14
+#define DRCMRRXSS2DR   DRCMR15
+#define DRCMRTXSS2DR   DRCMR16
 #define DRCMRRXICDR	DRCMR17
 #define DRCMRTXICDR	DRCMR18
 #define DRCMRRXSTRBR	DRCMR19
 #define DRCMRTXSTTHR	DRCMR20
 #define DRCMRRXMMC	DRCMR21
 #define DRCMRTXMMC	DRCMR22
+#define DRCMRRXSS3DR   DRCMR66
+#define DRCMRTXSS3DR   DRCMR67
 #define DRCMRUDC(x)	DRCMR((x) + 24)
 
 #define DRCMR_MAPVLD	(1 << 7)	/* Map Valid (read / write) */
@@ -455,6 +459,43 @@
 #define SADR		__REG(0x40400080)  /* Serial Audio Data Register (TX and RX FIFO access Register). */
 #endif
 
+#define SACR0_RFTH(x)	(x << 12)		/* Rx FIFO Interrupt or DMA Trigger Threshold */
+#define SACR0_TFTH(x)	(x << 8)		/* Tx FIFO Interrupt or DMA Trigger Threshold */
+#define SACR0_STRF		(1 << 5)		/* FIFO Select for EFWR Special Function */
+#define SACR0_EFWR		(1 << 4)		/* Enable EFWR Function  */
+#define SACR0_RST		(1 << 3)		/* FIFO, i2s Register Reset */
+#define SACR0_BCKD		(1 << 2) 		/* Bit Clock Direction */
+#define SACR0_ENB		(1 << 0)		/* Enable I2S Link */
+
+#define SACR1_ENLBF		(1 << 5)		/* Enable Loopback */
+#define SACR1_DRPL		(1 << 4) 		/* Disable Replaying Function */
+#define SACR1_DREC		(1 << 3)		/* Disable Recording Function */
+#define SACR1_AMSL		(1 << 1)		/* Specify Alternate Mode */
+
+#define SASR0_I2SOFF	(1 << 7)		/* Controller Status */
+#define SASR0_ROR		(1 << 6)		/* Rx FIFO Overrun */
+#define SASR0_TUR		(1 << 5)		/* Tx FIFO Underrun */
+#define SASR0_RFS		(1 << 4)		/* Rx FIFO Service Request */
+#define SASR0_TFS		(1 << 3)		/* Tx FIFO Service Request */
+#define SASR0_BSY		(1 << 2)		/* I2S Busy */
+#define SASR0_RNE		(1 << 1)		/* Rx FIFO Not Empty */
+#define SASR0_TNF		(1 << 0) 		/* Tx FIFO Not Empty */
+
+#define SADIV_3_058M	0x0c			/* Serial Clock Divider 3.058MHz */
+#define SADIV_2_836M	0x0d			/* 2.836 MHz */
+#define SADIV_1_405M	0x1a			/* 1.405 MHz */
+#define SADIV_1_026M	0x24			/* 1.026 MHz */
+#define SADIV_702K		0x34			/* 702 kHz */
+#define SADIV_513K		0x48			/* 513 kHz */
+
+#define SAICR_ROR		(1 << 6)		/* Clear Rx FIFO Overrun Interrupt */
+#define SAICR_TUR		(1 << 5)		/* Clear Tx FIFO Underrun Interrupt */
+
+#define SAIMR_ROR		(1 << 6)		/* Enable Rx FIFO Overrun Condition Interrupt */
+#define SAIMR_TUR		(1 << 5)		/* Enable Tx FIFO Underrun Condition Interrupt */
+#define SAIMR_RFS		(1 << 4)		/* Enable Rx FIFO Service Interrupt */
+#define SAIMR_TFS		(1 << 3)		/* Enable Tx FIFO Service Interrupt */
+
 
 /*
  * AC97 Controller registers
@@ -1190,6 +1231,7 @@
 #define GPIO43_BTTXD		43	/* BTUART transmit data */
 #define GPIO44_BTCTS		44	/* BTUART clear to send */
 #define GPIO45_BTRTS		45	/* BTUART request to send */
+#define GPIO45_AC97_SYSCLK	45	/* AC97 System Clock */
 #define GPIO46_ICPRXD		46	/* ICP receive data */
 #define GPIO46_STRXD		46	/* STD_UART receive data */
 #define GPIO47_ICPTXD		47	/* ICP transmit data */
@@ -1238,6 +1280,10 @@
 #define GPIO78_nCS_2		78	/* chip select 2 */
 #define GPIO79_nCS_3		79	/* chip select 3 */
 #define GPIO80_nCS_4		80	/* chip select 4 */
+#define GPIO81_NSCLK		81	/* NSSP clock */
+#define GPIO82_NSFRM		82	/* NSSP Frame */
+#define GPIO83_NSTXD		83	/* NSSP transmit */
+#define GPIO84_NSRXD		84	/* NSSP receive */
 #define GPIO85_nPCE_1		85	/* Card Enable for Card Space (PXA27x) */
 #define GPIO92_MMCDAT0		92	/* MMC DAT0 (PXA27x) */
 #define GPIO109_MMCDAT1		109	/* MMC DAT1 (PXA27x) */
@@ -1261,6 +1307,8 @@
 #define GPIO_MD_MASK_NR		0x07f
 #define GPIO_MD_MASK_DIR	0x080
 #define GPIO_MD_MASK_FN		0x300
+#define GPIO_DFLT_LOW		0x400
+#define GPIO_DFLT_HIGH		0x800
 
 #define GPIO1_RTS_MD		( 1 | GPIO_ALT_FN_1_IN)
 #define GPIO6_MMCCLK_MD		( 6 | GPIO_ALT_FN_1_OUT)
@@ -1308,6 +1356,7 @@
 #define GPIO43_BTTXD_MD		(43 | GPIO_ALT_FN_2_OUT)
 #define GPIO44_BTCTS_MD		(44 | GPIO_ALT_FN_1_IN)
 #define GPIO45_BTRTS_MD		(45 | GPIO_ALT_FN_2_OUT)
+#define GPIO45_SYSCLK_AC97_MD		(45 | GPIO_ALT_FN_1_OUT)
 #define GPIO46_ICPRXD_MD	(46 | GPIO_ALT_FN_1_IN)
 #define GPIO46_STRXD_MD		(46 | GPIO_ALT_FN_2_IN)
 #define GPIO47_ICPTXD_MD	(47 | GPIO_ALT_FN_2_OUT)
@@ -1357,6 +1406,14 @@
 #define GPIO79_nCS_3_MD		(79 | GPIO_ALT_FN_2_OUT)
 #define GPIO79_pSKTSEL_MD	(79 | GPIO_ALT_FN_1_OUT)
 #define GPIO80_nCS_4_MD		(80 | GPIO_ALT_FN_2_OUT)
+#define GPIO81_NSSP_CLK_OUT 	(81 | GPIO_ALT_FN_1_OUT)
+#define GPIO81_NSSP_CLK_IN  	(81 | GPIO_ALT_FN_1_IN)
+#define GPIO82_NSSP_FRM_OUT 	(82 | GPIO_ALT_FN_1_OUT)
+#define GPIO82_NSSP_FRM_IN  	(82 | GPIO_ALT_FN_1_IN)
+#define GPIO83_NSSP_TX      	(83 | GPIO_ALT_FN_1_OUT)
+#define GPIO83_NSSP_RX      	(83 | GPIO_ALT_FN_2_IN)
+#define GPIO84_NSSP_TX      	(84 | GPIO_ALT_FN_1_OUT)
+#define GPIO84_NSSP_RX      	(84 | GPIO_ALT_FN_2_IN)
 #define GPIO85_nPCE_1_MD	(85 | GPIO_ALT_FN_1_OUT)
 #define GPIO92_MMCDAT0_MD	(92 | GPIO_ALT_FN_1_OUT)
 #define GPIO109_MMCDAT1_MD	(109 | GPIO_ALT_FN_1_OUT)
@@ -1366,7 +1423,8 @@
 #define GPIO110_MMCCS1_MD	(111 | GPIO_ALT_FN_1_OUT)
 #define GPIO112_MMCCMD_MD	(112 | GPIO_ALT_FN_1_OUT)
 #define GPIO113_AC97_RESET_N_MD	(113 | GPIO_ALT_FN_2_OUT)
-
+#define GPIO117_I2CSCL_MD	(117 | GPIO_ALT_FN_1_OUT)
+#define GPIO118_I2CSDA_MD	(118 | GPIO_ALT_FN_1_IN)
 
 /*
  * Power Manager
@@ -1436,7 +1494,7 @@
 #define PVCR_CommandDelay (0xf80)
 #define PCFR_PI2C_EN	(0x1 << 6)
 
-#define PSSR_OTGPH	(1 << 7)	/* OTG Peripheral control Hold */
+#define PSSR_OTGPH	(1 << 6)	/* OTG Peripheral control Hold */
 #define PSSR_RDH	(1 << 5)	/* Read Disable Hold */
 #define PSSR_PH		(1 << 4)	/* Peripheral Control Hold */
 #define PSSR_VFS	(1 << 2)	/* VDD Fault Status */
@@ -1460,17 +1518,33 @@
 #define RCSR_WDR	(1 << 1)	/* Watchdog Reset */
 #define RCSR_HWR	(1 << 0)	/* Hardware Reset */
 
+#define PWER_GPIO(Nb)	(1 << Nb)	/* GPIO [0..15] wake-up enable     */
+#define PWER_GPIO0	PWER_GPIO (0)	/* GPIO  [0] wake-up enable        */
+#define PWER_GPIO1	PWER_GPIO (1)	/* GPIO  [1] wake-up enable        */
+#define PWER_GPIO2	PWER_GPIO (2)	/* GPIO  [2] wake-up enable        */
+#define PWER_GPIO3	PWER_GPIO (3)	/* GPIO  [3] wake-up enable        */
+#define PWER_GPIO4	PWER_GPIO (4)	/* GPIO  [4] wake-up enable        */
+#define PWER_GPIO5	PWER_GPIO (5)	/* GPIO  [5] wake-up enable        */
+#define PWER_GPIO6	PWER_GPIO (6)	/* GPIO  [6] wake-up enable        */
+#define PWER_GPIO7	PWER_GPIO (7)	/* GPIO  [7] wake-up enable        */
+#define PWER_GPIO8	PWER_GPIO (8)	/* GPIO  [8] wake-up enable        */
+#define PWER_GPIO9	PWER_GPIO (9)	/* GPIO  [9] wake-up enable        */
+#define PWER_GPIO10	PWER_GPIO (10)	/* GPIO [10] wake-up enable        */
+#define PWER_GPIO11	PWER_GPIO (11)	/* GPIO [11] wake-up enable        */
+#define PWER_GPIO12	PWER_GPIO (12)	/* GPIO [12] wake-up enable        */
+#define PWER_GPIO13	PWER_GPIO (13)	/* GPIO [13] wake-up enable        */
+#define PWER_GPIO14	PWER_GPIO (14)	/* GPIO [14] wake-up enable        */
+#define PWER_GPIO15	PWER_GPIO (15)	/* GPIO [15] wake-up enable        */
+#define PWER_RTC	0x80000000	/* RTC alarm wake-up enable        */
+
 
 /*
  * SSP Serial Port Registers
+ * PXA250, PXA255, PXA26x and PXA27x SSP controllers are all slightly different.
+ * PXA255, PXA26x and PXA27x have extra ports, registers and bits.
  */
 
-#define SSCR0		__REG(0x41000000)  /* SSP Control Register 0 */
-#define SSCR1		__REG(0x41000004)  /* SSP Control Register 1 */
-#define SSSR		__REG(0x41000008)  /* SSP Status Register */
-#define SSITR		__REG(0x4100000C)  /* SSP Interrupt Test Register */
-#define SSDR		__REG(0x41000010)  /* (Write / Read) SSP Data Write Register/SSP Data Read Register */
-
+ /* Common PXA2xx bits first */
 #define SSCR0_DSS	(0x0000000f)	/* Data Size Select (mask) */
 #define SSCR0_DataSize(x)  ((x) - 1)	/* Data Size Select [4..16] */
 #define SSCR0_FRF	(0x00000030)	/* FRame Format (mask) */
@@ -1500,6 +1574,103 @@
 #define SSSR_RFS	(1 << 6)	/* Receive FIFO Service Request */
 #define SSSR_ROR	(1 << 7)	/* Receive FIFO Overrun */
 
+#define SSCR0_TIM		(1 << 23)	/* Transmit FIFO Under Run Interrupt Mask */
+#define SSCR0_RIM		(1 << 22)	/* Receive FIFO Over Run interrupt Mask */
+#define SSCR0_NCS		(1 << 21)	/* Network Clock Select */
+#define SSCR0_EDSS		(1 << 20)	/* Extended Data Size Select */
+
+/* extra bits in PXA255, PXA26x and PXA27x SSP ports */
+#define SSCR1_TTELP		(1 << 31)	/* TXD Tristate Enable Last Phase */
+#define SSCR1_TTE		(1 << 30)	/* TXD Tristate Enable */
+#define SSCR1_EBCEI		(1 << 29)	/* Enable Bit Count Error interrupt */
+#define SSCR1_SCFR		(1 << 28)	/* Slave Clock free Running */
+#define SSCR1_ECRA		(1 << 27)	/* Enable Clock Request A */
+#define SSCR1_ECRB		(1 << 26)	/* Enable Clock request B */
+#define SSCR1_SCLKDIR	(1 << 25)	/* Serial Bit Rate Clock Direction */
+#define SSCR1_SFRMDIR	(1 << 24)	/* Frame Direction */
+#define SSCR1_RWOT		(1 << 23)	/* Receive Without Transmit */
+#define SSCR1_TRAIL		(1 << 22)	/* Trailing Byte */
+#define SSCR1_TSRE		(1 << 21)	/* Transmit Service Request Enable */
+#define SSCR1_RSRE		(1 << 20)	/* Receive Service Request Enable */
+#define SSCR1_TINTE		(1 << 19)	/* Receiver Time-out Interrupt enable */
+#define SSCR1_PINTE		(1 << 18)	/* Peripheral Trailing Byte Interupt Enable */
+#define SSCR1_STRF		(1 << 15)	/* Select FIFO or EFWR */
+#define SSCR1_EFWR		(1 << 14)	/* Enable FIFO Write/Read */
+
+#define SSSR_BCE		(1 << 23)	/* Bit Count Error */
+#define SSSR_CSS		(1 << 22)	/* Clock Synchronisation Status */
+#define SSSR_TUR		(1 << 21)	/* Transmit FIFO Under Run */
+#define SSSR_EOC		(1 << 20)	/* End Of Chain */
+#define SSSR_TINT		(1 << 19)	/* Receiver Time-out Interrupt */
+#define SSSR_PINT		(1 << 18)	/* Peripheral Trailing Byte Interrupt */
+
+#define SSPSP_DMYSTOP(x)	(x << 23)	/* Dummy Stop */
+#define SSPSP_SFRMWDTH(x)	(x << 16)	/* Serial Frame Width */
+#define SSPSP_SFRMDLY(x)	(x << 9)	/* Serial Frame Delay */
+#define SSPSP_DMYSTRT(x)	(x << 7)	/* Dummy Start */
+#define SSPSP_STRTDLY(x)	(x << 4)	/* Start Delay */
+#define SSPSP_ETDS			(1 << 3)	/* End of Transfer data State */
+#define SSPSP_SFRMP			(1 << 2)	/* Serial Frame Polarity */
+#define SSPSP_SCMODE(x)		(x << 0)	/* Serial Bit Rate Clock Mode */
+
+
+#define SSCR0_P1	__REG(0x41000000)  /* SSP Port 1 Control Register 0 */
+#define SSCR1_P1	__REG(0x41000004)  /* SSP Port 1 Control Register 1 */
+#define SSSR_P1		__REG(0x41000008)  /* SSP Port 1 Status Register */
+#define SSITR_P1	__REG(0x4100000C)  /* SSP Port 1 Interrupt Test Register */
+#define SSDR_P1		__REG(0x41000010)  /* (Write / Read) SSP Port 1 Data Write Register/SSP Data Read Register */
+
+/* Support existing PXA25x drivers */
+#define SSCR0		SSCR0_P1  /* SSP Control Register 0 */
+#define SSCR1		SSCR1_P1  /* SSP Control Register 1 */
+#define SSSR		SSSR_P1	  /* SSP Status Register */
+#define SSITR		SSITR_P1  /* SSP Interrupt Test Register */
+#define SSDR		SSDR_P1	  /* (Write / Read) SSP Data Write Register/SSP Data Read Register */
+
+/* PXA27x ports */
+#if defined (CONFIG_PXA27x)
+#define SSTO_P1		__REG(0x41000028)  /* SSP Port 1 Time Out Register */
+#define SSPSP_P1	__REG(0x4100002C)  /* SSP Port 1 Programmable Serial Protocol */
+#define SSCR0_P2	__REG(0x41700000)  /* SSP Port 2 Control Register 0 */
+#define SSCR1_P2	__REG(0x41700004)  /* SSP Port 2 Control Register 1 */
+#define SSSR_P2		__REG(0x41700008)  /* SSP Port 2 Status Register */
+#define SSITR_P2	__REG(0x4170000C)  /* SSP Port 2 Interrupt Test Register */
+#define SSDR_P2		__REG(0x41700010)  /* (Write / Read) SSP Port 2 Data Write Register/SSP Data Read Register */
+#define SSTO_P2		__REG(0x41700028)  /* SSP Port 2 Time Out Register */
+#define SSPSP_P2	__REG(0x4170002C)  /* SSP Port 2 Programmable Serial Protocol */
+#define SSCR0_P3	__REG(0x41900000)  /* SSP Port 3 Control Register 0 */
+#define SSCR1_P3	__REG(0x41900004)  /* SSP Port 3 Control Register 1 */
+#define SSSR_P3		__REG(0x41900008)  /* SSP Port 3 Status Register */
+#define SSITR_P3	__REG(0x4190000C)  /* SSP Port 3 Interrupt Test Register */
+#define SSDR_P3		__REG(0x41900010)  /* (Write / Read) SSP Port 3 Data Write Register/SSP Data Read Register */
+#define SSTO_P3		__REG(0x41900028)  /* SSP Port 3 Time Out Register */
+#define SSPSP_P3	__REG(0x4190002C)  /* SSP Port 3 Programmable Serial Protocol */
+#else /* PXA255 (only port 2) and PXA26x ports*/
+#define SSTO_P1		__REG(0x41000028)  /* SSP Port 1 Time Out Register */
+#define SSPSP_P1	__REG(0x4100002C)  /* SSP Port 1 Programmable Serial Protocol */
+#define SSCR0_P2	__REG(0x41400000)  /* SSP Port 2 Control Register 0 */
+#define SSCR1_P2	__REG(0x41400004)  /* SSP Port 2 Control Register 1 */
+#define SSSR_P2		__REG(0x41400008)  /* SSP Port 2 Status Register */
+#define SSITR_P2	__REG(0x4140000C)  /* SSP Port 2 Interrupt Test Register */
+#define SSDR_P2		__REG(0x41400010)  /* (Write / Read) SSP Port 2 Data Write Register/SSP Data Read Register */
+#define SSTO_P2		__REG(0x41400028)  /* SSP Port 2 Time Out Register */
+#define SSPSP_P2	__REG(0x4140002C)  /* SSP Port 2 Programmable Serial Protocol */
+#define SSCR0_P3	__REG(0x41500000)  /* SSP Port 3 Control Register 0 */
+#define SSCR1_P3	__REG(0x41500004)  /* SSP Port 3 Control Register 1 */
+#define SSSR_P3		__REG(0x41500008)  /* SSP Port 3 Status Register */
+#define SSITR_P3	__REG(0x4150000C)  /* SSP Port 3 Interrupt Test Register */
+#define SSDR_P3		__REG(0x41500010)  /* (Write / Read) SSP Port 3 Data Write Register/SSP Data Read Register */
+#define SSTO_P3		__REG(0x41500028)  /* SSP Port 3 Time Out Register */
+#define SSPSP_P3	__REG(0x4150002C)  /* SSP Port 3 Programmable Serial Protocol */
+#endif
+
+#define SSCR0_P(x) (*(((x) == 1) ? &SSCR0_P1 : ((x) == 2) ? &SSCR0_P2 : ((x) == 3) ? &SSCR0_P3 : NULL))
+#define SSCR1_P(x) (*(((x) == 1) ? &SSCR1_P1 : ((x) == 2) ? &SSCR1_P2 : ((x) == 3) ? &SSCR1_P3 : NULL))
+#define SSSR_P(x) (*(((x) == 1) ? &SSSR_P1 : ((x) == 2) ? &SSSR_P2 : ((x) == 3) ? &SSSR_P3 : NULL))
+#define SSITR_P(x) (*(((x) == 1) ? &SSITR_P1 : ((x) == 2) ? &SSITR_P2 : ((x) == 3) ? &SSITR_P3 : NULL))
+#define SSDR_P(x) (*(((x) == 1) ? &SSDR_P1 : ((x) == 2) ? &SSDR_P2 : ((x) == 3) ? &SSDR_P3 : NULL))
+#define SSTO_P(x) (*(((x) == 1) ? &SSTO_P1 : ((x) == 2) ? &SSTO_P2 : ((x) == 3) ? &SSTO_P3 : NULL))
+#define SSPSP_P(x) (*(((x) == 1) ? &SSPSP_P1 : ((x) == 2) ? &SSPSP_P2 : ((x) == 3) ? &SSPSP_P3 : NULL))
 
 /*
  * MultiMediaCard (MMC) controller
@@ -1552,8 +1723,10 @@
 #define CKEN13_FICP	(1 << 13)	/* FICP Unit Clock Enable */
 #define CKEN12_MMC	(1 << 12)	/* MMC Unit Clock Enable */
 #define CKEN11_USB	(1 << 11)	/* USB Unit Clock Enable */
+#define CKEN10_ASSP	(1 << 10)	/* ASSP (SSP3) Clock Enable */
 #define CKEN10_USBHOST	(1 << 10)	/* USB Host Unit Clock Enable */
 #define CKEN9_OSTIMER	(1 << 9)	/* OS Timer Unit Clock Enable */
+#define CKEN9_NSSP	(1 << 9)	/* NSSP (SSP2) Clock Enable */
 #define CKEN8_I2S	(1 << 8)	/* I2S Unit Clock Enable */
 #define CKEN7_BTUART	(1 << 7)	/* BTUART Unit Clock Enable */
 #define CKEN6_FFUART	(1 << 6)	/* FFUART Unit Clock Enable */
diff -Nru a/include/asm-arm/arch-pxa/serial.h b/include/asm-arm/arch-pxa/serial.h
--- a/include/asm-arm/arch-pxa/serial.h	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,50 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-pxa/serial.h
- *
- * Author:	Nicolas Pitre
- * Copyright:	(C) 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 version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <asm/arch/pxa-regs.h>
-
-#define BAUD_BASE	921600
-
-/* Standard COM flags */
-#define STD_COM_FLAGS (ASYNC_SKIP_TEST)
-
-#define STD_SERIAL_PORT_DEFNS	\
-	{	\
-		type:			PORT_PXA,	\
-		xmit_fifo_size:		64,		\
-		baud_base:		BAUD_BASE,	\
-		iomem_base:		&FFUART,	\
-		iomem_reg_shift:	2,		\
-		io_type:		SERIAL_IO_MEM,	\
-		irq:			IRQ_FFUART,	\
-		flags:			STD_COM_FLAGS,	\
-	}, {	\
-		type:			PORT_PXA,	\
-		xmit_fifo_size:		64,		\
-		baud_base:		BAUD_BASE,	\
-		iomem_base:		&STUART,	\
-		iomem_reg_shift:	2,		\
-		io_type:		SERIAL_IO_MEM,	\
-		irq:			IRQ_STUART,	\
-		flags:			STD_COM_FLAGS,	\
-	}, {	\
-		type:			PORT_PXA,	\
-		xmit_fifo_size:		64,		\
-		baud_base:		BAUD_BASE,	\
-		iomem_base:		&BTUART,	\
-		iomem_reg_shift:	2,		\
-		io_type:		SERIAL_IO_MEM,	\
-		irq:			IRQ_BTUART,	\
-		flags:			STD_COM_FLAGS,	\
-	}
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
diff -Nru a/include/asm-arm/arch-pxa/ssp.h b/include/asm-arm/arch-pxa/ssp.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/arch-pxa/ssp.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,47 @@
+/*
+ *  ssp.h
+ *
+ *  Copyright (C) 2003 Russell King, 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 version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This driver supports the following PXA CPU/SSP ports:-
+ *
+ *       PXA250     SSP
+ *       PXA255     SSP, NSSP
+ *       PXA26x     SSP, NSSP, ASSP
+ *       PXA27x     SSP1, SSP2, SSP3
+ */
+
+#ifndef SSP_H
+#define SSP_H
+
+struct ssp_state {
+	u32	cr0;
+	u32 cr1;
+	u32 to;
+	u32 psp;
+};
+
+struct ssp_dev {
+	u32 port;
+	u32 mode;
+	u32 flags;
+	u32 psp_flags;
+	u32 speed;
+};
+
+int ssp_write_word(struct ssp_dev *dev, u32 data);
+int ssp_read_word(struct ssp_dev *dev);
+void ssp_flush(struct ssp_dev *dev);
+void ssp_enable(struct ssp_dev *dev);
+void ssp_disable(struct ssp_dev *dev);
+void ssp_save_state(struct ssp_dev *dev, struct ssp_state *ssp);
+void ssp_restore_state(struct ssp_dev *dev, struct ssp_state *ssp);
+int ssp_init(struct ssp_dev *dev, u32 port, u32 mode, u32 flags, u32 psp_flags,
+						u32 speed);
+void ssp_exit(struct ssp_dev *dev);
+
+#endif
diff -Nru a/include/asm-arm/arch-rpc/io.h b/include/asm-arm/arch-rpc/io.h
--- a/include/asm-arm/arch-rpc/io.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-arm/arch-rpc/io.h	2004-12-24 13:37:00 -08:00
@@ -250,6 +250,6 @@
 /*
  * 1:1 mapping for ioremapped regions.
  */
-#define __mem_pci(x)	((unsigned long)(x))
+#define __mem_pci(x)	(x)
 
 #endif
diff -Nru a/include/asm-arm/arch-rpc/serial.h b/include/asm-arm/arch-rpc/serial.h
--- a/include/asm-arm/arch-rpc/serial.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,46 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-rpc/serial.h
- *
- *  Copyright (C) 1996 Russell King.
- *
- * 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.
- *
- *  Changelog:
- *   15-10-1996	RMK	Created
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1843200 / 16)
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-	{ 0, BASE_BAUD, 0x3F8, 10, STD_COM_FLAGS },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS1 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS2 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS3 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS }, 	/* ttyS4 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS5 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS6 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS7 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS8 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS9 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS10 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS11 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS },	/* ttyS12 */	\
-	{ 0, BASE_BAUD, 0    ,  0, STD_COM_FLAGS }	/* ttyS13 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
diff -Nru a/include/asm-arm/arch-s3c2410/bast-pmu.h b/include/asm-arm/arch-s3c2410/bast-pmu.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/arch-s3c2410/bast-pmu.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,43 @@
+/* linux/include/asm-arm/arch-s3c2410/bast-pmu.h
+ *
+ * (c) 2003,2004 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
+ *	Vincent Sanders <vince@simtec.co.uk>
+ *
+ * Machine BAST - Power Management chip
+ *
+ * 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.
+ *
+ * Changelog:
+ *	08-Oct-2003	BJD	Initial creation
+*/
+
+#ifndef __ASM_ARCH_BASTPMU_H
+#define __ASM_ARCH_BASTPMU_H "08_OCT_2004"
+
+#define BASTPMU_REG_IDENT	(0x00)
+#define BASTPMU_REG_VERSION	(0x01)
+#define BASTPMU_REG_DDCCTRL	(0x02)
+#define BASTPMU_REG_POWER	(0x03)
+#define BASTPMU_REG_RESET	(0x04)
+#define BASTPMU_REG_GWO		(0x05)
+#define BASTPMU_REG_WOL		(0x06)
+#define BASTPMU_REG_WOR		(0x07)
+#define BASTPMU_REG_UID		(0x09)
+
+#define BASTPMU_EEPROM		(0xC0)
+
+#define BASTPMU_EEP_UID		(BASTPMU_EEPROM + 0)
+#define BASTPMU_EEP_WOL		(BASTPMU_EEPROM + 8)
+#define BASTPMU_EEP_WOR		(BASTPMU_EEPROM + 9)
+
+#define BASTPMU_IDENT_0		0x53
+#define BASTPMU_IDENT_1		0x42
+#define BASTPMU_IDENT_2		0x50
+#define BASTPMU_IDENT_3		0x4d
+
+#define BASTPMU_RESET_GUARD	(0x55)
+
+#endif /* __ASM_ARCH_BASTPMU_H */
diff -Nru a/include/asm-arm/arch-s3c2410/dma.h b/include/asm-arm/arch-s3c2410/dma.h
--- a/include/asm-arm/arch-s3c2410/dma.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-arm/arch-s3c2410/dma.h	2004-12-24 13:36:47 -08:00
@@ -1,7 +1,7 @@
 /* linux/include/asm-arm/arch-bast/dma.h
  *
- * Copyright (C) 2003 Simtec Electronics
- *  Ben Dooks <ben@simtec.co.uk>
+ * Copyright (C) 2003,2004 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
  *
  * Samsung S3C2410X DMA support
  *
@@ -12,13 +12,14 @@
  * Changelog:
  *  ??-May-2003 BJD   Created file
  *  ??-Jun-2003 BJD   Added more dma functionality to go with arch
+ *  10-Nov-2004 BJD   Added sys_device support
 */
 
-
 #ifndef __ASM_ARCH_DMA_H
-#define __ASM_ARCH_DMA_H
+#define __ASM_ARCH_DMA_H __FILE__
 
 #include <linux/config.h>
+#include <linux/sysdev.h>
 #include "hardware.h"
 
 
@@ -198,9 +199,9 @@
 	unsigned int           flags;        /* channel flags */
 
 	/* channel's hardware position and configuration */
-	unsigned long          regs;         /* channels registers */
+	void __iomem           *regs;        /* channels registers */
+	void __iomem           *addr_reg;    /* data address register */
 	unsigned int           irq;          /* channel irq */
-	unsigned long          addr_reg;     /* data address register */
 	unsigned long          dcon;         /* default value of DCON */
 
 	/* driver handles */
@@ -215,6 +216,9 @@
 	s3c2410_dma_buf_t      *curr;        /* current dma buffer */
 	s3c2410_dma_buf_t      *next;        /* next buffer to load */
 	s3c2410_dma_buf_t      *end;         /* end of queue */
+
+	/* system device */
+	struct sys_device	dev;
 };
 
 /* the currently allocated channel information */
@@ -296,18 +300,46 @@
 #define S3C2410_DMA_DCDST       (0x1C)
 #define S3C2410_DMA_DMASKTRIG   (0x20)
 
+#define S3C2410_DISRCC_INC	(1<<0)
+#define S3C2410_DISRCC_APB	(1<<1)
+
 #define S3C2410_DMASKTRIG_STOP   (1<<2)
 #define S3C2410_DMASKTRIG_ON     (1<<1)
 #define S3C2410_DMASKTRIG_SWTRIG (1<<0)
 
-#define S3C2410_DCOM_DEMAND     (0<<31)
+#define S3C2410_DCON_DEMAND     (0<<31)
 #define S3C2410_DCON_HANDSHAKE  (1<<31)
 #define S3C2410_DCON_SYNC_PCLK  (0<<30)
 #define S3C2410_DCON_SYNC_HCLK  (1<<30)
 
 #define S3C2410_DCON_INTREQ     (1<<29)
 
+#define S3C2410_DCON_CH0_XDREQ0	(0<<24)
+#define S3C2410_DCON_CH0_UART0	(1<<24)
+#define S3C2410_DCON_CH0_SDI	(2<<24)
+#define S3C2410_DCON_CH0_TIMER	(3<<24)
+#define S3C2410_DCON_CH0_USBEP1	(4<<24)
+
+#define S3C2410_DCON_CH1_XDREQ1	(0<<24)
+#define S3C2410_DCON_CH1_UART1	(1<<24)
+#define S3C2410_DCON_CH1_I2SSDI	(2<<24)
+#define S3C2410_DCON_CH1_SPI	(3<<24)
+#define S3C2410_DCON_CH1_USBEP2	(4<<24)
+
+#define S3C2410_DCON_CH2_I2SSDO	(0<<24)
+#define S3C2410_DCON_CH2_I2SSDI	(1<<24)
+#define S3C2410_DCON_CH2_SDI	(2<<24)
+#define S3C2410_DCON_CH2_TIMER	(3<<24)
+#define S3C2410_DCON_CH2_USBEP3	(4<<24)
+
+#define S3C2410_DCON_CH3_UART2	(0<<24)
+#define S3C2410_DCON_CH3_SDI	(1<<24)
+#define S3C2410_DCON_CH3_SPI	(2<<24)
+#define S3C2410_DCON_CH3_TIMER	(3<<24)
+#define S3C2410_DCON_CH3_USBEP4	(4<<24)
+
 #define S3C2410_DCON_SRCSHIFT   (24)
+#define S3C2410_DCON_SRCMASK	(7<<24)
 
 #define S3C2410_DCON_BYTE       (0<<20)
 #define S3C2410_DCON_HALFWORD   (1<<20)
@@ -316,5 +348,21 @@
 #define S3C2410_DCON_AUTORELOAD (0<<22)
 #define S3C2410_DCON_NORELOAD   (1<<22)
 #define S3C2410_DCON_HWTRIG     (1<<23)
+
+#ifdef CONFIG_CPU_S3C2440
+#define S3C2440_DIDSTC_CHKINT	(1<<2)
+
+#define S3C2440_DCON_CH0_I2SSDO	(5<<24)
+#define S3C2440_DCON_CH0_PCMIN	(6<<24)
+
+#define S3C2440_DCON_CH1_PCMOUT	(5<<24)
+#define S3C2440_DCON_CH1_SDI	(6<<24)
+
+#define S3C2440_DCON_CH2_PCMIN	(5<<24)
+#define S3C2440_DCON_CH2_MICIN	(6<<24)
+
+#define S3C2440_DCON_CH3_MICIN	(5<<24)
+#define S3C2440_DCON_CH3_PCMOUT	(6<<24)
+#endif
 
 #endif /* __ASM_ARCH_DMA_H */
diff -Nru a/include/asm-arm/arch-s3c2410/hardware.h b/include/asm-arm/arch-s3c2410/hardware.h
--- a/include/asm-arm/arch-s3c2410/hardware.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-arm/arch-s3c2410/hardware.h	2004-12-24 13:36:48 -08:00
@@ -16,17 +16,13 @@
  *  12-Mar-2004 BJD  Fixed include protection, fixed type of clock vars
  *  14-Sep-2004 BJD  Added misccr and getpin to gpio
  *  01-Oct-2004 BJD  Added the new gpio functions
+ *  16-Oct-2004 BJD  Removed the clock variables
 */
 
 #ifndef __ASM_ARCH_HARDWARE_H
 #define __ASM_ARCH_HARDWARE_H
 
 #ifndef __ASSEMBLY__
-
-/* processor clock settings, in Hz */
-extern unsigned long s3c2410_pclk;
-extern unsigned long s3c2410_hclk;
-extern unsigned long s3c2410_fclk;
 
 /* external functions for GPIO support
  *
diff -Nru a/include/asm-arm/arch-s3c2410/idle.h b/include/asm-arm/arch-s3c2410/idle.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/arch-s3c2410/idle.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,28 @@
+/* linux/include/asm-arm/arch-s3c2410/idle.h
+ *
+ * Copyright (c) 2004 Simtec Electronics <linux@simtec.co.uk>
+ *		http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * S3C2410 CPU Idle controls
+ *
+ *  Changelog:
+ *	28-Oct-2004  BJD  Initial version
+ *
+*/
+
+#ifndef __ASM_ARCH_IDLE_H
+#define __ASM_ARCH_IDLE_H __FILE__
+
+/* This allows the over-ride of the default idle code, in case there
+ * is any other things to be done over idle (like DVS)
+*/
+
+extern void (*s3c24xx_idle)(void);
+
+extern void s3c24xx_default_idle(void);
+
+#endif /* __ASM_ARCH_IDLE_H */
diff -Nru a/include/asm-arm/arch-s3c2410/iic.h b/include/asm-arm/arch-s3c2410/iic.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/arch-s3c2410/iic.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,36 @@
+/* linux/include/asm-arm/arch-s3c2410/iic.h
+ *
+ * (c) 2004 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C2410 - I2C Controller platfrom_device info
+ *
+ * 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.
+ *
+ * Changelog:
+ *	05-Oct-2004 BJD  Created file
+ *	19-Oct-2004 BJD	 Updated for s3c2440
+*/
+
+#ifndef __ASM_ARCH_IIC_H
+#define __ASM_ARCH_IIC_H __FILE__
+
+#define S3C_IICFLG_FILTER	(1<<0)	/* enable s3c2440 filter */
+
+/* Notes:
+ *	1) All frequencies are expressed in Hz
+ *	2) A value of zero is `do not care`
+*/
+
+struct s3c2410_platform_i2c {
+	unsigned int	flags;
+	unsigned int	slave_addr;	/* slave address for controller */
+	unsigned long	bus_freq;	/* standard bus frequency */
+	unsigned long	max_freq;	/* max frequency for the bus */
+	unsigned long	min_freq;	/* min frequency for the bus */
+	unsigned int	sda_delay;	/* pclks (s3c2440 only) */
+};
+
+#endif /* __ASM_ARCH_IIC_H */
diff -Nru a/include/asm-arm/arch-s3c2410/regs-dsc.h b/include/asm-arm/arch-s3c2410/regs-dsc.h
--- a/include/asm-arm/arch-s3c2410/regs-dsc.h	2004-12-24 13:36:32 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-dsc.h	2004-12-24 13:36:32 -08:00
@@ -20,15 +20,15 @@
 
 #ifdef CONFIG_CPU_S3C2440
 
-#define S3C2440_DSC0	   S3C2410_GPIOREG(0xc0)
-#define S3C2440_DSC1	   S3C2410_GPIOREG(0xc4)
+#define S3C2440_DSC0	   S3C2410_GPIOREG(0xc4)
+#define S3C2440_DSC1	   S3C2410_GPIOREG(0xc8)
 
 #define S3C2440_SELECT_DSC0 (0)
 #define S3C2440_SELECT_DSC1 (1<<31)
 
 #define S3C2440_DSC_GETSHIFT(x) ((x) & 31)
 
-#define S3C2440_DSC0_ENABLE     (1<<31)
+#define S3C2440_DSC0_DISABLE	(1<<31)
 
 #define S3C2440_DSC0_ADDR       (S3C2440_SELECT_DSC0 | 8)
 #define S3C2440_DSC0_ADDR_12mA  (0<<8)
@@ -69,19 +69,19 @@
 #define S3C2440_DSC0_DATA0_6mA  (3<<0)
 #define S3C2440_DSC0_DATA0_MASK (3<<0)
 
-#define S3C2440_DSC1_SCK0       (S3C2440_SELECT_DSC1 | 28)
-#define S3C2440_DSC1_SCK0_12mA  (0<<28)
-#define S3C2440_DSC1_SCK0_10mA  (1<<28)
-#define S3C2440_DSC1_SCK0_8mA   (2<<28)
-#define S3C2440_DSC1_SCK0_6mA   (3<<28)
-#define S3C2440_DSC1_SCK0_MASK  (3<<28)
-
-#define S3C2440_DSC1_SCK1       (S3C2440_SELECT_DSC1 | 26)
-#define S3C2440_DSC1_SCK1_12mA  (0<<26)
-#define S3C2440_DSC1_SCK1_10mA  (1<<26)
-#define S3C2440_DSC1_SCK1_8mA   (2<<26)
-#define S3C2440_DSC1_SCK1_6mA   (3<<26)
-#define S3C2440_DSC1_SCK1_MASK  (3<<26)
+#define S3C2440_DSC1_SCK1       (S3C2440_SELECT_DSC1 | 28)
+#define S3C2440_DSC1_SCK1_12mA  (0<<28)
+#define S3C2440_DSC1_SCK1_10mA  (1<<28)
+#define S3C2440_DSC1_SCK1_8mA   (2<<28)
+#define S3C2440_DSC1_SCK1_6mA   (3<<28)
+#define S3C2440_DSC1_SCK1_MASK  (3<<28)
+
+#define S3C2440_DSC1_SCK0       (S3C2440_SELECT_DSC1 | 26)
+#define S3C2440_DSC1_SCK0_12mA  (0<<26)
+#define S3C2440_DSC1_SCK0_10mA  (1<<26)
+#define S3C2440_DSC1_SCK0_8mA   (2<<26)
+#define S3C2440_DSC1_SCK0_6mA   (3<<26)
+#define S3C2440_DSC1_SCK0_MASK  (3<<26)
 
 #define S3C2440_DSC1_SCKE       (S3C2440_SELECT_DSC1 | 24)
 #define S3C2440_DSC1_SCKE_10mA  (0<<24)
diff -Nru a/include/asm-arm/arch-s3c2410/regs-gpio.h b/include/asm-arm/arch-s3c2410/regs-gpio.h
--- a/include/asm-arm/arch-s3c2410/regs-gpio.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-gpio.h	2004-12-24 13:37:02 -08:00
@@ -1,4 +1,4 @@
-/* linux/include/asm/hardware/s3c2410/
+/* linux/include/asm/hardware/s3c2410/regs-gpio.h
  *
  * Copyright (c) 2003,2004 Simtec Electronics <linux@simtec.co.uk>
  *		           http://www.simtec.co.uk/products/SWLINUX/
@@ -15,6 +15,9 @@
  *    12-03-2004     BJD     Updated include protection
  *    20-07-2004     BJD     Added GPIO pin numbers, added Port A definitions
  *    04-10-2004     BJD     Fixed number of bugs, added EXT IRQ filter defs
+ *    17-10-2004     BJD     Added GSTATUS1 register definitions
+ *    18-11-2004     BJD     Fixed definitions of GPE3, GPE4, GPE5 and GPE6
+ *    18-11-2004     BJD     Added S3C2440 AC97 controls
 */
 
 
@@ -423,12 +426,14 @@
 #define S3C2410_GPE3_INP       (0x00 << 6)
 #define S3C2410_GPE3_OUTP      (0x01 << 6)
 #define S3C2410_GPE3_I2SSDI    (0x02 << 6)
+#define S3C2410_GPE3_nSS0      (0x03 << 6)
 #define S3C2410_GPE3_MASK      (0x03 << 6)
 
 #define S3C2410_GPE4           S3C2410_GPIONO(S3C2410_GPIO_BANKE, 4)
 #define S3C2410_GPE4_INP       (0x00 << 8)
 #define S3C2410_GPE4_OUTP      (0x01 << 8)
 #define S3C2410_GPE4_I2SSDO    (0x02 << 8)
+#define S3C2410_GPE4_I2SSDI    (0x03 << 8)
 #define S3C2410_GPE4_MASK      (0x03 << 8)
 
 #define S3C2410_GPE5           S3C2410_GPIONO(S3C2410_GPIO_BANKE, 5)
@@ -439,12 +444,12 @@
 #define S3C2410_GPE6           S3C2410_GPIONO(S3C2410_GPIO_BANKE, 6)
 #define S3C2410_GPE6_INP       (0x00 << 12)
 #define S3C2410_GPE6_OUTP      (0x01 << 12)
-#define S3C2410_GPE6_SDCLK     (0x02 << 12)
+#define S3C2410_GPE6_SDCMD     (0x02 << 12)
 
 #define S3C2410_GPE7           S3C2410_GPIONO(S3C2410_GPIO_BANKE, 7)
 #define S3C2410_GPE7_INP       (0x00 << 14)
 #define S3C2410_GPE7_OUTP      (0x01 << 14)
-#define S3C2410_GPE7_SDCMD     (0x02 << 14)
+#define S3C2410_GPE7_SDDAT0    (0x02 << 14)
 
 #define S3C2410_GPE8           S3C2410_GPIONO(S3C2410_GPIO_BANKE, 8)
 #define S3C2410_GPE8_INP       (0x00 << 16)
@@ -488,6 +493,12 @@
 #define S3C2410_GPE15_IICSDA   (0x02 << 30)
 #define S3C2410_GPE15_MASK     (0x03 << 30)
 
+#define S3C2440_GPE0_ACSYNC    (0x03 << 0)
+#define S3C2440_GPE1_ACBITCLK  (0x03 << 2)
+#define S3C2440_GPE2_ACRESET   (0x03 << 4)
+#define S3C2440_GPE3_ACIN      (0x03 << 6)
+#define S3C2440_GPE4_ACOUT     (0x03 << 8)
+
 #define S3C2410_GPE_PUPDIS(x)  (1<<(x))
 
 /* Port F consists of 8 GPIO/Special function
@@ -806,8 +817,12 @@
 #define S3C2410_GSTATUS0_RnB	   (1<<1)
 #define S3C2410_GSTATUS0_nBATTFLT  (1<<0)
 
+#define S3C2410_GSTATUS1_IDMASK	   (0xffff0000)
+#define S3C2410_GSTATUS1_2410	   (0x32410000)
+#define S3C2410_GSTATUS1_2440	   (0x32440000)
+
 #define S3C2410_GSTATUS2_WTRESET   (1<<2)
-#define S3C2410_GSTATUs2_OFFRESET  (1<<1)
+#define S3C2410_GSTATUS2_OFFRESET  (1<<1)
 #define S3C2410_GSTATUS2_PONRESET  (1<<0)
 
 #endif	/* __ASM_ARCH_REGS_GPIO_H */
diff -Nru a/include/asm-arm/arch-s3c2410/regs-iic.h b/include/asm-arm/arch-s3c2410/regs-iic.h
--- a/include/asm-arm/arch-s3c2410/regs-iic.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-iic.h	2004-12-24 13:36:17 -08:00
@@ -11,10 +11,11 @@
  *
  *  Changelog:
  *	03-Oct-2004  BJD  Initial include for Linux
+ *	08-Nov-2004  BJD  Added S3C2440 filter register
 */
 
-#ifndef __ASM_ARCH_IIC_H
-#define __ASM_ARCH_IIC_H __FILE__
+#ifndef __ASM_ARCH_REGS_IIC_H
+#define __ASM_ARCH_REGS_IIC_H __FILE__
 
 /* see s3c2410x user guide, v1.1, section 9 (p447) for more info */
 
@@ -24,6 +25,7 @@
 #define S3C2410_IICSTAT   S3C2410_IICREG(0x04)
 #define S3C2410_IICADD    S3C2410_IICREG(0x08)
 #define S3C2410_IICDS     S3C2410_IICREG(0x0C)
+#define S3C2440_IICLC	  S3C2410_IICREG(0x10)
 
 #define S3C2410_IICCON_ACKEN		(1<<7)
 #define S3C2410_IICCON_TXDIV_16		(0<<6)
@@ -47,4 +49,12 @@
 #define S3C2410_IICSTAT_ADDR0		(1<<1)
 #define S3C2410_IICSTAT_LASTBIT		(1<<0)
 
-#endif /* __ASM_ARCH_IIC_H */
+#define S3C2410_IICLC_SDA_DELAY0	(0 << 0)
+#define S3C2410_IICLC_SDA_DELAY5	(1 << 0)
+#define S3C2410_IICLC_SDA_DELAY10	(2 << 0)
+#define S3C2410_IICLC_SDA_DELAY15	(3 << 0)
+#define S3C2410_IICLC_SDA_DELAY_MASK	(3 << 0)
+
+#define S3C2410_IICLC_FILTER_ON		(1<<2)
+
+#endif /* __ASM_ARCH_REGS_IIC_H */
diff -Nru a/include/asm-arm/arch-s3c2410/regs-lcd.h b/include/asm-arm/arch-s3c2410/regs-lcd.h
--- a/include/asm-arm/arch-s3c2410/regs-lcd.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-lcd.h	2004-12-24 13:37:43 -08:00
@@ -29,7 +29,7 @@
 #define S3C2410_LCDCON5	    S3C2410_LCDREG(0x10)
 
 #define S3C2410_LCDCON1_CLKVAL(x)  ((x) << 8)
-#define S3C2410_LCDCON1_MMODE	   (1<<6)
+#define S3C2410_LCDCON1_MMODE	   (1<<7)
 #define S3C2410_LCDCON1_DSCAN4	   (0<<5)
 #define S3C2410_LCDCON1_STN4	   (1<<5)
 #define S3C2410_LCDCON1_STN8	   (2<<5)
@@ -48,15 +48,15 @@
 #define S3C2410_LCDCON1_TFT16BPP   (12<<1)
 #define S3C2410_LCDCON1_TFT24BPP   (13<<1)
 
-#define S3C2410_LCDCON1_ENVDI	   (1)
+#define S3C2410_LCDCON1_ENVID	   (1)
 
 #define S3C2410_LCDCON2_VBPD(x)	    ((x) << 24)
 #define S3C2410_LCDCON2_LINEVAL(x)  ((x) << 14)
 #define S3C2410_LCDCON2_VFPD(x)	    ((x) << 6)
 #define S3C2410_LCDCON2_VSPW(x)	    ((x) << 0)
 
-#define S3C2410_LCDCON3_HBPD(x)	    ((x) << 25)
-#define S3C2410_LCDCON3_WDLY(x)	    ((x) << 25)
+#define S3C2410_LCDCON3_HBPD(x)	    ((x) << 19)
+#define S3C2410_LCDCON3_WDLY(x)	    ((x) << 19)
 #define S3C2410_LCDCON3_HOZVAL(x)   ((x) << 8)
 #define S3C2410_LCDCON3_HFPD(x)	    ((x) << 0)
 #define S3C2410_LCDCON3_LINEBLANK(x)((x) << 0)
@@ -83,6 +83,12 @@
 #define S3C2410_LCDSADDR1   S3C2410_LCDREG(0x14)
 #define S3C2410_LCDSADDR2   S3C2410_LCDREG(0x18)
 #define S3C2410_LCDSADDR3   S3C2410_LCDREG(0x1C)
+
+#define S3C2410_LCDBANK(x)	((x) << 21)
+#define S3C2410_LCDBASEU(x)	(x)
+
+#define S3C2410_OFFSIZE(x)	((x) << 11)
+#define S3C2410_PAGEWIDTH(x)	(x)
 
 /* colour lookup and miscellaneous controls */
 
diff -Nru a/include/asm-arm/arch-s3c2410/regs-rtc.h b/include/asm-arm/arch-s3c2410/regs-rtc.h
--- a/include/asm-arm/arch-s3c2410/regs-rtc.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-rtc.h	2004-12-24 13:37:19 -08:00
@@ -21,6 +21,8 @@
 
 #define S3C2410_RTCCON	      S3C2410_RTCREG(0x40)
 #define S3C2410_RTCCON_RTCEN  (1<<0)
+#define S3C2410_RTCCON_CLKSEL (1<<1)
+#define S3C2410_RTCCON_CNTSEL (1<<2)
 #define S3C2410_RTCCON_CLKRST (1<<3)
 
 #define S3C2410_TICNT	      S3C2410_RTCREG(0x44)
diff -Nru a/include/asm-arm/arch-s3c2410/regs-sdi.h b/include/asm-arm/arch-s3c2410/regs-sdi.h
--- a/include/asm-arm/arch-s3c2410/regs-sdi.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-sdi.h	2004-12-24 13:36:17 -08:00
@@ -11,6 +11,8 @@
  *
  *  Changelog:
  *    18-Aug-2004 Ben Dooks      Created initial file
+ *    29-Nov-2004 Koen Martens   Added some missing defines, fixed duplicates
+ *    29-Nov-2004 Ben Dooks	 Updated Koen's patch
 */
 
 #ifndef __ASM_ARM_REGS_SDI
@@ -62,8 +64,10 @@
 #define S3C2410_SDIDCON_WIDEBUS       (1<<16)
 #define S3C2410_SDIDCON_DMAEN         (1<<15)
 #define S3C2410_SDIDCON_STOP          (1<<14)
+#define S3C2410_SDIDCON_DATMODE	      (3<<12)
+#define S3C2410_SDIDCON_BLKNUM        (0x7ff)
 
-#define S3C2410_SDIDCON_XFER_MASK     (3<<12)
+/* constants for S3C2410_SDIDCON_DATMODE */
 #define S3C2410_SDIDCON_XFER_READY    (0<<12)
 #define S3C2410_SDIDCON_XFER_CHKSTART (1<<12)
 #define S3C2410_SDIDCON_XFER_RXSTART  (2<<12)
@@ -73,22 +77,23 @@
 
 #define S3C2410_SDIDSTA_RDYWAITREQ    (1<<10)
 #define S3C2410_SDIDSTA_SDIOIRQDETECT (1<<9)
-#define S3C2410_SDIDSTA_FIFOFAIL      (1<<8)
+#define S3C2410_SDIDSTA_FIFOFAIL      (1<<8)	/* reserved on 2440 */
 #define S3C2410_SDIDSTA_CRCFAIL       (1<<7)
 #define S3C2410_SDIDSTA_RXCRCFAIL     (1<<6)
 #define S3C2410_SDIDSTA_DATATIMEOUT   (1<<5)
 #define S3C2410_SDIDSTA_XFERFINISH    (1<<4)
 #define S3C2410_SDIDSTA_BUSYFINISH    (1<<3)
+#define S3C2410_SDIDSTA_SBITERR       (1<<2)	/* reserved on 2410a/2440 */
 #define S3C2410_SDIDSTA_TXDATAON      (1<<1)
 #define S3C2410_SDIDSTA_RXDATAON      (1<<0)
 
-#define S3C2410_SDIFSTA_TXFULL         (1<<13)
-#define S3C2410_SDIFSTA_RXFULL         (1<<12)
+#define S3C2410_SDIFSTA_TFDET          (1<<13)
+#define S3C2410_SDIFSTA_RFDET          (1<<12)
 #define S3C2410_SDIFSTA_TXHALF         (1<<11)
 #define S3C2410_SDIFSTA_TXEMPTY        (1<<10)
-#define S3C2410_SDIFSTA_RXLAST         (1<<9)
-#define S3C2410_SDIFSTA_RXFULL         (1<<8)
-#define S3C2410_SDIFSTA_RXHALF         (1<<7)
+#define S3C2410_SDIFSTA_RFLAST         (1<<9)
+#define S3C2410_SDIFSTA_RFFULL         (1<<8)
+#define S3C2410_SDIFSTA_RFHALF         (1<<7)
 #define S3C2410_SDIFSTA_COUNTMASK      (0x7f)
 
 #define S3C2410_SDIIMSK_RESPONSECRC    (1<<17)
@@ -103,6 +108,7 @@
 #define S3C2410_SDIIMSK_DATATIMEOUT    (1<<8)
 #define S3C2410_SDIIMSK_DATAFINISH     (1<<7)
 #define S3C2410_SDIIMSK_BUSYFINISH     (1<<6)
+#define S3C2410_SDIIMSK_SBITERR        (1<<5)	/* reserved 2440/2410a */
 #define S3C2410_SDIIMSK_TXFIFOHALF     (1<<4)
 #define S3C2410_SDIIMSK_TXFIFOEMPTY    (1<<3)
 #define S3C2410_SDIIMSK_RXFIFOLAST     (1<<2)
diff -Nru a/include/asm-arm/arch-s3c2410/regs-serial.h b/include/asm-arm/arch-s3c2410/regs-serial.h
--- a/include/asm-arm/arch-s3c2410/regs-serial.h	2004-12-24 13:36:56 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-serial.h	2004-12-24 13:36:56 -08:00
@@ -66,6 +66,13 @@
 #define S3C2410_LCON_PMASK	  (0x7 << 3)
 
 #define S3C2410_LCON_STOPB	  (1<<2)
+#define S3C2410_LCON_IRM          (1<<6)
+
+#define S3C2440_UCON_CLKMASK	  (3<<10)
+#define S3C2440_UCON_PCLK	  (0<<10)
+#define S3C2440_UCON_UCLK	  (1<<10)
+#define S3C2440_UCON_PCLK2	  (2<<10)
+#define S3C2440_UCON_FCLK	  (3<<10)
 
 #define S3C2410_UCON_UCLK	  (1<<10)
 #define S3C2410_UCON_SBREAK	  (1<<4)
@@ -76,19 +83,35 @@
 #define S3C2410_UCON_RXIRQMODE	  (1<<0)
 #define S3C2410_UCON_RXFIFO_TOI	  (1<<7)
 
-#define S3C2410_UCON_DEFAULT	  (S3C2410_UCON_TXILEVEL | S3C2410_UCON_RXILEVEL \
-				   | S3C2410_UCON_TXIRQMODE | S3C2410_UCON_RXIRQMODE \
-				   | S3C2410_UCON_RXFIFO_TOI)
+#define S3C2410_UCON_DEFAULT	  (S3C2410_UCON_TXILEVEL  | \
+				   S3C2410_UCON_RXILEVEL  | \
+				   S3C2410_UCON_TXIRQMODE | \
+				   S3C2410_UCON_RXIRQMODE | \
+				   S3C2410_UCON_RXFIFO_TOI)
 
 #define S3C2410_UFCON_FIFOMODE	  (1<<0)
 #define S3C2410_UFCON_TXTRIG0	  (0<<6)
 #define S3C2410_UFCON_RXTRIG8	  (1<<4)
 #define S3C2410_UFCON_RXTRIG12	  (2<<4)
 
+/* S3C2440 FIFO trigger levels */
+#define S3C2440_UFCON_RXTRIG1	  (0<<4)
+#define S3C2440_UFCON_RXTRIG8	  (1<<4)
+#define S3C2440_UFCON_RXTRIG16	  (2<<4)
+#define S3C2440_UFCON_RXTRIG32	  (3<<4)
+
+#define S3C2440_UFCON_TXTRIG0	  (0<<6)
+#define S3C2440_UFCON_TXTRIG16	  (1<<6)
+#define S3C2440_UFCON_TXTRIG32	  (2<<6)
+#define S3C2440_UFCON_TXTRIG48	  (3<<6)
+
 #define S3C2410_UFCON_RESETBOTH	  (3<<1)
+#define S3C2410_UFCON_RESETTX	  (1<<2)
+#define S3C2410_UFCON_RESETRX	  (1<<1)
 
-#define S3C2410_UFCON_DEFAULT	  (S3C2410_UFCON_FIFOMODE | S3C2410_UFCON_TXTRIG0 \
-				  | S3C2410_UFCON_RXTRIG8 )
+#define S3C2410_UFCON_DEFAULT	  (S3C2410_UFCON_FIFOMODE | \
+				   S3C2410_UFCON_TXTRIG0  | \
+				   S3C2410_UFCON_RXTRIG8 )
 
 #define S3C2410_UFSTAT_TXFULL	  (1<<9)
 #define S3C2410_UFSTAT_RXFULL	  (1<<8)
@@ -97,37 +120,49 @@
 #define S3C2410_UFSTAT_RXMASK	  (15<<0)
 #define S3C2410_UFSTAT_RXSHIFT	  (0)
 
+#define S3C2440_UFSTAT_TXFULL	  (1<<14)
+#define S3C2440_UFSTAT_RXFULL	  (1<<6)
+#define S3C2440_UFSTAT_TXSHIFT	  (8)
+#define S3C2440_UFSTAT_RXSHIFT	  (0)
+#define S3C2440_UFSTAT_TXMASK	  (63<<8)
+#define S3C2440_UFSTAT_RXMASK	  (63)
+
+#define S3C2410_UTRSTAT_TXE	  (1<<2)
 #define S3C2410_UTRSTAT_TXFE	  (1<<1)
 #define S3C2410_UTRSTAT_RXDR	  (1<<0)
 
 #define S3C2410_UERSTAT_OVERRUN	  (1<<0)
 #define S3C2410_UERSTAT_FRAME	  (1<<2)
-#define S3C2410_UERSTAT_ANY	  (S3C2410_UERSTAT_OVERRUN | S3C2410_UERSTAT_FRAME)
-
-/* fifo size information */
-
-#ifndef __ASSEMBLY__
-static inline int S3C2410_UFCON_RXC(int fcon)
-{
-	if (fcon & S3C2410_UFSTAT_RXFULL)
-		return 16;
-
-	return ((fcon) & S3C2410_UFSTAT_RXMASK) >> S3C2410_UFSTAT_RXSHIFT;
-}
-
-static inline int S3C2410_UFCON_TXC(int fcon)
-{
-	if (fcon & S3C2410_UFSTAT_TXFULL)
-		return 16;
-
-	return ((fcon) & S3C2410_UFSTAT_TXMASK) >> S3C2410_UFSTAT_TXSHIFT;
-}
-#endif /* __ASSEMBLY__ */
+#define S3C2410_UERSTAT_BREAK	  (1<<3)
+#define S3C2410_UERSTAT_ANY	  (S3C2410_UERSTAT_OVERRUN | \
+				   S3C2410_UERSTAT_FRAME | \
+				   S3C2410_UERSTAT_BREAK)
 
 #define S3C2410_UMSTAT_CTS	  (1<<0)
 #define S3C2410_UMSTAT_DeltaCTS	  (1<<2)
 
 #ifndef __ASSEMBLY__
+
+/* struct s3c24xx_uart_clksrc
+ *
+ * this structure defines a named clock source that can be used for the
+ * uart, so that the best clock can be selected for the requested baud
+ * rate.
+ *
+ * min_baud and max_baud define the range of baud-rates this clock is
+ * acceptable for, if they are both zero, it is assumed any baud rate that
+ * can be generated from this clock will be used.
+ *
+ * divisor gives the divisor from the clock to the one seen by the uart
+*/
+
+struct s3c24xx_uart_clksrc {
+	const char	*name;
+	unsigned int	 divisor;
+	unsigned int	 min_baud;
+	unsigned int	 max_baud;
+};
+
 /* configuration structure for per-machine configurations for the
  * serial port
  *
@@ -139,15 +174,23 @@
 	unsigned char	   hwport;	 /* hardware port number */
 	unsigned char	   unused;
 	unsigned short	   flags;
-
-	unsigned long	  *clock;	 /* pointer to clock rate */
+	unsigned long	   uart_flags;	 /* default uart flags */
 
 	unsigned long	   ucon;	 /* value of ucon for port */
 	unsigned long	   ulcon;	 /* value of ulcon for port */
 	unsigned long	   ufcon;	 /* value of ufcon for port */
+
+	struct s3c24xx_uart_clksrc *clocks;
+	unsigned int		    clocks_size;
 };
 
-extern struct s3c2410_uartcfg *s3c2410_uartcfgs;
+/* s3c24xx_uart_devs
+ *
+ * this is exported from the core as we cannot use driver_register(),
+ * or platform_add_device() before the console_initcall()
+*/
+
+extern struct platform_device *s3c24xx_uart_devs[3];
 
 #endif /* __ASSEMBLY__ */
 
diff -Nru a/include/asm-arm/arch-s3c2410/regs-udc.h b/include/asm-arm/arch-s3c2410/regs-udc.h
--- a/include/asm-arm/arch-s3c2410/regs-udc.h	2004-12-24 13:36:30 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-udc.h	2004-12-24 13:36:30 -08:00
@@ -8,8 +8,9 @@
  * the License, or (at your option) any later version.
  *
  *  Changelog:
- *    01-08-2004	initial creation
- *    12-09-2004	cleanup for submission
+ *    01-08-2004	Initial creation
+ *    12-09-2004	Cleanup for submission
+ *    24-10-2004	Fixed S3C2410_UDC_MAXP_REG definition
  */
 
 #ifndef __ASM_ARCH_REGS_UDC_H
@@ -68,7 +69,7 @@
 
 /* indexed registers */
 
-#define S3C2410_UDC_MAXP_REG		S3C2410_USBDREG(0x018c)
+#define S3C2410_UDC_MAXP_REG		S3C2410_USBDREG(0x0180)
 
 #define S3C2410_UDC_EP0_CSR_REG		S3C2410_USBDREG(0x0184)
 
diff -Nru a/include/asm-arm/arch-s3c2410/regs-watchdog.h b/include/asm-arm/arch-s3c2410/regs-watchdog.h
--- a/include/asm-arm/arch-s3c2410/regs-watchdog.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-s3c2410/regs-watchdog.h	2004-12-24 13:36:17 -08:00
@@ -38,6 +38,7 @@
 #define S3C2410_WTCON_DIV128  (3<<3)
 
 #define S3C2410_WTCON_PRESCALE(x) ((x) << 8)
+#define S3C2410_WTCON_PRESCALE_MASK (0xff00)
 
 #endif /* __ASM_ARCH_REGS_WATCHDOG_H */
 
diff -Nru a/include/asm-arm/arch-s3c2410/serial.h b/include/asm-arm/arch-s3c2410/serial.h
--- a/include/asm-arm/arch-s3c2410/serial.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,28 +0,0 @@
-/* linux/include/asm-arm/arch-s3c2410/serial.h
- *
- * (c) 2003 Simtec Electronics
- *  Ben Dooks <ben@simtec.co.uk>
- *
- * S3C2410 - serial port definitions
- *
- * 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.
- *
- * Changelog:
- *  03-Sep-2003 BJD  Created file
- *  19-Mar-2004 BJD  Removed serial port definitions, inserted elsewhere
-*/
-
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-/* Standard COM flags */
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-#define BASE_BAUD ( 1843200 / 16 )
-
-#define STD_SERIAL_PORT_DEFNS
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif /* __ASM_ARCH_SERIAL_H */
diff -Nru a/include/asm-arm/arch-s3c2410/system.h b/include/asm-arm/arch-s3c2410/system.h
--- a/include/asm-arm/arch-s3c2410/system.h	2004-12-24 13:36:59 -08:00
+++ b/include/asm-arm/arch-s3c2410/system.h	2004-12-24 13:36:59 -08:00
@@ -14,44 +14,50 @@
  *  14-May-2003 BJD  Removed idle to aid debugging
  *  12-Jun-2003 BJD  Added reset via watchdog
  *  04-Sep-2003 BJD  Moved to v2.6
+ *  28-Oct-2004 BJD  Added over-ride for idle, and fixed reset panic()
  */
 
 #include <asm/hardware.h>
 #include <asm/io.h>
 
 #include <asm/arch/map.h>
+#include <asm/arch/idle.h>
 
 #include <asm/arch/regs-watchdog.h>
 #include <asm/arch/regs-clock.h>
 
-extern void printascii(const char *);
+void (*s3c24xx_idle)(void);
 
-void
-arch_idle(void)
+void s3c24xx_default_idle(void)
 {
-	//unsigned long reg = S3C2410_CLKCON;
-
-	//printascii("arch_idle:\n");
+	unsigned long reg = S3C2410_CLKCON;
+	unsigned long tmp;
+	int i;
 
 	/* idle the system by using the idle mode which will wait for an
 	 * interrupt to happen before restarting the system.
 	 */
 
-	/* going into idle state upsets the jtag, so don't do it
-	 * at the moment */
+	/* Warning: going into idle state upsets jtag scanning */
 
-#if 0
 	__raw_writel(__raw_readl(reg) | (1<<2), reg);
 
 	/* the samsung port seems to do a loop and then unset idle.. */
 	for (i = 0; i < 50; i++) {
-		tmp = __raw_readl(reg); /* ensure loop not optimised out */
+		tmp += __raw_readl(reg); /* ensure loop not optimised out */
 	}
 
-	//printascii("arch_idle: done\n");
+	/* this bit is not cleared on re-start... */
 
 	__raw_writel(__raw_readl(reg) & ~(1<<2), reg);
-#endif
+}
+
+static void arch_idle(void)
+{
+	if (s3c24xx_idle != NULL)
+		(s3c24xx_idle)();
+	else
+		s3c24xx_default_idle();
 }
 
 
@@ -77,7 +83,7 @@
 	/* wait for reset to assert... */
 	mdelay(5000);
 
-	panic("Watchdog reset failed to assert reset\n");
+	printk(KERN_ERR "Watchdog reset failed to assert reset\n");
 
 	/* we'll take a jump through zero as a poor second */
 	cpu_reset(0);
diff -Nru a/include/asm-arm/arch-s3c2410/timex.h b/include/asm-arm/arch-s3c2410/timex.h
--- a/include/asm-arm/arch-s3c2410/timex.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-arm/arch-s3c2410/timex.h	2004-12-24 13:37:18 -08:00
@@ -1,6 +1,6 @@
 /* linux/include/asm-arm/arch-s3c2410/timex.h
  *
- * (c) 2003 Simtec Electronics
+ * (c) 2003,2004 Simtec Electronics
  *  Ben Dooks <ben@simtec.co.uk>
  *
  * S3C2410 - time parameters
@@ -12,6 +12,7 @@
  * Changelog:
  *  02-Sep-2003 BJD  Created file
  *  05-Jan-2004 BJD  Updated for Linux 2.6.0
+ *  22-Nov-2004 BJD  Fixed CLOCK_TICK_RATE
 */
 
 #ifndef __ASM_ARCH_TIMEX_H
@@ -26,8 +27,8 @@
 #define CLOCK_TICK_RATE (s3c2410_clock_tick_rate)
 #endif
 
-/* currently, the BAST uses 24MHz as a base clock rate */
-#define CLOCK_TICK_RATE 24000000
+/* currently, the BAST uses 12MHz as a base clock rate */
+#define CLOCK_TICK_RATE 12000000
 
 
 #endif /* __ASM_ARCH_TIMEX_H */
diff -Nru a/include/asm-arm/arch-s3c2410/uncompress.h b/include/asm-arm/arch-s3c2410/uncompress.h
--- a/include/asm-arm/arch-s3c2410/uncompress.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-arm/arch-s3c2410/uncompress.h	2004-12-24 13:37:43 -08:00
@@ -13,24 +13,29 @@
  *  22-May-2003 BJD  Created
  *  08-Sep-2003 BJD  Moved to linux v2.6
  *  12-Mar-2004 BJD  Updated header protection
+ *  12-Oct-2004 BJD  Take account of debug uart configuration
+ *  15-Nov-2004 BJD  Fixed uart configuration
 */
 
 #ifndef __ASM_ARCH_UNCOMPRESS_H
 #define __ASM_ARCH_UNCOMPRESS_H
 
+#include <linux/config.h>
+
 /* defines for UART registers */
 #include "asm/arch/regs-serial.h"
+#include "asm/arch/regs-gpio.h"
 
 #include <asm/arch/map.h>
 
+/* working in physical space... */
+#undef S3C2410_GPIOREG
+#define S3C2410_GPIOREG(x) ((S3C2410_PA_GPIO + (x)))
+
 /* how many bytes we allow into the FIFO at a time in FIFO mode */
 #define FIFO_MAX	 (14)
 
-#if 1
-#define uart_base S3C2410_PA_UART
-#else
-static unsigned int uart_base = S3C2410_PA_UART;
-#endif
+#define uart_base S3C2410_PA_UART + (0x4000*CONFIG_S3C2410_LOWLEVEL_UART_PORT)
 
 static __inline__ void
 uart_wr(unsigned int reg, unsigned int val)
@@ -74,6 +79,10 @@
 static void
 putc(char ch)
 {
+	int cpuid = *((volatile unsigned int *)S3C2410_GSTATUS1);
+
+	cpuid &= S3C2410_GSTATUS1_IDMASK;
+
 	if (ch == '\n')
 		putc('\r');    /* expand newline to \r\n */
 
@@ -82,8 +91,14 @@
 
 		while (1) {
 			level = uart_rd(S3C2410_UFSTAT);
-			level &= S3C2410_UFSTAT_TXMASK;
-			level >>= S3C2410_UFSTAT_TXSHIFT;
+
+			if (cpuid == S3C2410_GSTATUS1_2440) {
+				level &= S3C2440_UFSTAT_TXMASK;
+				level >>= S3C2440_UFSTAT_TXSHIFT;
+			} else {
+				level &= S3C2410_UFSTAT_TXMASK;
+				level >>= S3C2410_UFSTAT_TXSHIFT;
+			}
 
 			if (level < FIFO_MAX)
 				break;
@@ -92,7 +107,7 @@
 	} else {
 		/* not using fifos */
 
-		while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE) != S3C2410_UTRSTAT_TXFE);
+		while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE);
 	}
 
 	/* write byte to transmission register */
diff -Nru a/include/asm-arm/arch-sa1100/adsbitsy.h b/include/asm-arm/arch-sa1100/adsbitsy.h
--- a/include/asm-arm/arch-sa1100/adsbitsy.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,14 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/adsbitsy.h
- *
- * Created 7/3/01 by Woojung <whuh@applieddata.net>
- *
- * This file contains the hardware specific definitions for the
- * ADS Bitsy Board
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-#define	SA1111_BASE		(0x18000000)
diff -Nru a/include/asm-arm/arch-sa1100/flexanet.h b/include/asm-arm/arch-sa1100/flexanet.h
--- a/include/asm-arm/arch-sa1100/flexanet.h	2004-12-24 13:36:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,100 +0,0 @@
-/*
- * include/asm-arm/arch-sa1100/flexanet.h
- *
- * Created 2001/05/04 by Jordi Colomer <jco@ict.es>
- *
- * This file contains the hardware specific definitions for FlexaNet
- *
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-/* Board Control Register (virtual address) */
-#define FHH_BCR_PHYS  0x10000000
-#define FHH_BCR_VIRT  0xf0000000
-#define FHH_BCR (*(volatile unsigned int *)(FHH_BCR_VIRT))
-
-/* Power-up value */
-#define FHH_BCR_POWERUP	0x00000000
-
-/* Mandatory bits */
-#define FHH_BCR_LED_GREEN  (1<<0)  /* General-purpose green LED (1 = on) */
-#define FHH_BCR_SPARE_1    (1<<1)  /* Not defined */
-#define FHH_BCR_CF1_RST    (1<<2)  /* Compact Flash Slot #1 Reset (1 = reset) */
-#define FHH_BCR_CF2_RST    (1<<3)  /* Compact Flash Slot #2 Reset (1 = reset) */
-#define FHH_BCR_GUI_NRST   (1<<4)  /* GUI board reset (0 = reset) */
-#define FHH_BCR_RTS1       (1<<5)  /* RS232 RTS for UART-1 */
-#define FHH_BCR_RTS3       (1<<6)  /* RS232 RTS for UART-3 */
-#define FHH_BCR_XCDBG0     (1<<7)  /* Not defined. Wired to XPLA3 for debug */
-
-/* BCR extension, only required by L3-bus in some audio codecs */
-#define FHH_BCR_L3MOD      (1<<8)  /* L3-bus MODE signal */
-#define FHH_BCR_L3DAT      (1<<9)  /* L3-bus DATA signal */
-#define FHH_BCR_L3CLK      (1<<10) /* L3-bus CLK signal */
-#define FHH_BCR_SPARE_11   (1<<11) /* Not defined */
-#define FHH_BCR_SPARE_12   (1<<12) /* Not defined */
-#define FHH_BCR_SPARE_13   (1<<13) /* Not defined */
-#define FHH_BCR_SPARE_14   (1<<14) /* Not defined */
-#define FHH_BCR_SPARE_15   (1<<15) /* Not defined */
-
- /* Board Status Register (virtual address) */
-#define FHH_BSR_BASE  FHH_BCR_VIRT
-#define FHH_BSR (*(volatile unsigned int *)(FHH_BSR_BASE))
-
-#define FHH_BSR_CTS1       (1<<0)  /* RS232 CTS for UART-1 */
-#define FHH_BSR_CTS3       (1<<1)  /* RS232 CTS for UART-3 */
-#define FHH_BSR_DSR1       (1<<2)  /* RS232 DSR for UART-1 */
-#define FHH_BSR_DSR3       (1<<3)  /* RS232 DSR for UART-3 */
-#define FHH_BSR_ID0        (1<<4)  /* Board identification */
-#define FHH_BSR_ID1        (1<<5)
-#define FHH_BSR_CFG0       (1<<6)  /* Board configuration options */
-#define FHH_BSR_CFG1       (1<<7)
-
-#ifndef __ASSEMBLY__
-extern unsigned long flexanet_BCR;	/* Image of the BCR */
-#define FLEXANET_BCR_set( x )    FHH_BCR = (flexanet_BCR |= (x))
-#define FLEXANET_BCR_clear( x )  FHH_BCR = (flexanet_BCR &= ~(x))
-#endif
-
-/* GPIOs for which the generic definition doesn't say much */
-#define GPIO_CF1_NCD       GPIO_GPIO (14)  /* Card Detect from CF slot #1 */
-#define GPIO_CF2_NCD       GPIO_GPIO (15)  /* Card Detect from CF slot #2 */
-#define GPIO_CF1_IRQ       GPIO_GPIO (16)  /* IRQ from CF slot #1 */
-#define GPIO_CF2_IRQ       GPIO_GPIO (17)  /* IRQ from CF slot #2 */
-#define GPIO_APP_IRQ       GPIO_GPIO (18)  /* Extra IRQ from application bus */
-#define GPIO_RADIO_REF     GPIO_GPIO (20)  /* Ref. clock for UART3 (Radio) */
-#define GPIO_CF1_BVD1      GPIO_GPIO (21)  /* BVD1 from CF slot #1 */
-#define GPIO_CF2_BVD1      GPIO_GPIO (22)  /* BVD1 from CF slot #2 */
-#define GPIO_GUI_IRQ       GPIO_GPIO (23)  /* IRQ from GUI board (i.e., UCB1300) */
-#define GPIO_ETH_IRQ       GPIO_GPIO (24)  /* IRQ from Ethernet controller */
-#define GPIO_INTIP_IRQ     GPIO_GPIO (25)  /* Measurement IRQ (INTIP) */
-#define GPIO_LED_RED       GPIO_GPIO (26)  /* General-purpose red LED */
-
-/* IRQ sources from GPIOs */
-#define IRQ_GPIO_CF1_CD    IRQ_GPIO14
-#define IRQ_GPIO_CF2_CD    IRQ_GPIO15
-#define IRQ_GPIO_CF1_IRQ   IRQ_GPIO16
-#define IRQ_GPIO_CF2_IRQ   IRQ_GPIO17
-#define IRQ_GPIO_APP       IRQ_GPIO18
-#define IRQ_GPIO_CF1_BVD1  IRQ_GPIO21
-#define IRQ_GPIO_CF2_BVD1  IRQ_GPIO22
-#define IRQ_GPIO_GUI       IRQ_GPIO23
-#define IRQ_GPIO_ETH       IRQ_GPIO24
-#define IRQ_GPIO_INTIP     IRQ_GPIO25
-
-
-/* On-Board Ethernet */
-#define _FHH_ETH_IOBASE		0x18000000	/* I/O base (physical addr) */
-#define _FHH_ETH_MMBASE		0x18800000	/* Attribute-memory base */
-#define FHH_ETH_SIZE		0x01000000	/* total size */
-#define FHH_ETH_VIRT		0xF1000000	/* Ethernet virtual address */
-
-#define FHH_ETH_p2v( x )	((x) - _FHH_ETH_IOBASE + FHH_ETH_VIRT)
-#define FHH_ETH_v2p( x )	((x) - FHH_ETH_VIRT + _FHH_ETH_IOBASE)
-
-#define FHH_ETH_IOBASE		FHH_ETH_p2v(_FHH_ETH_IOBASE) /* Virtual base addr */
-#define FHH_ETH_MMBASE		FHH_ETH_p2v(_FHH_ETH_MMBASE)
-
-
diff -Nru a/include/asm-arm/arch-sa1100/freebird.h b/include/asm-arm/arch-sa1100/freebird.h
--- a/include/asm-arm/arch-sa1100/freebird.h	2004-12-24 13:36:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,69 +0,0 @@
-/*
- *
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-
-/* Board Control Register */
-
-#define BCR_BASE  0xf0000000
-#define BCR (*(volatile unsigned int *)(BCR_BASE))
-
-#define BCR_DB1110	(0x00A07410)
-
-
-#define BCR_FREEBIRD_AUDIO_PWR	(1<<0)	/* Audio Power (1 = on, 0 = off) */
-#define BCR_FREEBIRD_LCD_PWR		(1<<1)	/* LCD Power (1 = on) */
-#define BCR_FREEBIRD_CODEC_RST	(1<<2)	/* 0 = Holds UCB1300, ADI7171, and UDA1341 in reset */
-#define BCR_FREEBIRD_IRDA_FSEL	(1<<3)	/* IRDA Frequency select (0 = SIR, 1 = MIR/ FIR) */
-#define BCR_FREEBIRD_IRDA_MD0	(1<<4)	/* Range/Power select */
-#define BCR_FREEBIRD_IRDA_MD1	(1<<5)	/* Range/Power select */
-#define BCR_FREEBIRD_LCD_DISP	(1<<7)	/* LCD display (1 = on, 0 = off */
-#define BCR_FREEBIRD_LCD_BACKLIGHT	(1<<16)	/* LCD backlight ,1=on */
-#define BCR_FREEBIRD_LCD_LIGHT_INC	(1<<17)	/* LCD backlight brightness */
-#define BCR_FREEBIRD_LCD_LIGHT_DU	(1<<18)	/* LCD backlight brightness */
-#define BCR_FREEBIRD_LCD_INC			(1<<19)	/* LCD contrast  */
-#define BCR_FREEBIRD_LCD_DU			(1<<20)	/* LCD contrast */
-#define BCR_FREEBIRD_QMUTE			(1<<21)	/* Quick Mute */
-#define BCR_FREEBIRD_ALARM_LED		(1<<22)	/* ALARM LED control */
-#define BCR_FREEBIRD_SPK_OFF	(1<<23)	/* 1 = Speaker amplifier power off */
-
-#ifndef __ASSEMBLY__
-extern unsigned long BCR_value;
-#define BCR_set( x )	BCR = (BCR_value |= (x))
-#define BCR_clear( x )	BCR = (BCR_value &= ~(x))
-#endif
-
-
-/* GPIOs for which the generic definition doesn't say much */
-#define GPIO_FREEBIRD_NPOWER_BUTTON		GPIO_GPIO(0)
-#define GPIO_FREEBIRD_APP1_BUTTON		GPIO_GPIO(1)
-#define GPIO_FREEBIRD_APP2_BUTTON		GPIO_GPIO(2)
-#define GPIO_FREEBIRD_APP3_BUTTOM		GPIO_GPIO(3)
-#define GPIO_FREEBIRD_UCB1300			GPIO_GPIO(4)
-
-#define GPIO_FREEBIRD_EXPWR				GPIO_GPIO(8)
-#define GPIO_FREEBIRD_CHARGING			GPIO_GPIO(9)
-#define GPIO_FREEBIRD_RAMD				GPIO_GPIO(14)
-#define GPIO_FREEBIRD_L3_DATA			GPIO_GPIO(15)
-#define GPIO_FREEBIRD_L3_MODE			GPIO_GPIO(17)
-#define GPIO_FREEBIRD_L3_CLOCK			GPIO_GPIO(18)
-#define GPIO_FREEBIRD_STEREO_64FS_CLK	GPIO_GPIO(10)
-
-#define GPIO_FREEBIRD_CF_CD				GPIO_GPIO(22)
-#define GPIO_FREEBIRD_CF_IRQ			GPIO_GPIO(21)
-#define GPIO_FREEBIRD_CF_BVD			GPIO_GPIO(25)
-
-#define IRQ_GPIO_FREEBIRD_NPOWER_BUTTON	IRQ_GPIO0
-#define IRQ_GPIO_FREEBIRD_APP1_BUTTON	IRQ_GPIO1
-#define IRQ_GPIO_FREEBIRD_APP2_BUTTON	IRQ_GPIO2
-#define IRQ_GPIO_FREEBIRD_APP3_BUTTON	IRQ_GPIO3
-#define IRQ_GPIO_FREEBIRD_UCB1300_IRQ	IRQ_GPIO4
-
-#define IRQ_GPIO_FREEBIRD_CF_IRQ		IRQ_GPIO21
-#define IRQ_GPIO_FREEBIRD_CF_CD			IRQ_GPIO22
-#define IRQ_GPIO_FREEBIRD_CF_BVD		IRQ_GPIO25
-
diff -Nru a/include/asm-arm/arch-sa1100/graphicsclient.h b/include/asm-arm/arch-sa1100/graphicsclient.h
--- a/include/asm-arm/arch-sa1100/graphicsclient.h	2004-12-24 13:37:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,100 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/graphicsclient.h
- *
- * Created 2000/06/11 by Nicolas Pitre <nico@cam.org>
- * Modified 7/27/00 by Woojung <whuh@applieddata.net>
- *
- * This file contains the hardware specific definitions for the 
- * ADS GraphicsClient/ThinClient boards.
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-
-#define ADS_CPLD_BASE		(0x10000000)
-#define ADS_p2v( x )		((x) - ADS_CPLD_BASE + 0xf0000000)
-#define ADS_v2p( x )		((x) - 0xf0000000 + ADS_CPLD_BASE)
-
-
-/* Parallel Port */
-
-#define _ADS_PPDR		0x10020000	/* parallel port data reg */
-#define _ADS_PPSR		0x10020004	/* parallel port status reg */
-
-
-/* PCMCIA */
-
-#define _ADS_CS_STATUS		0x10040000	/* PCMCIA status reg */
-#define ADS_CS_ST_A_READY	(1 << 0)	/* Socket A Card Ready */
-#define ADS_CS_ST_A_CD		(1 << 2)	/* Socket A Card Detect */
-#define ADS_CS_ST_A_BUSY	(1 << 4)	/* Socket A Card Busy */
-#define ADS_CS_ST_A_STS		(1 << 6)	/* Socket A Card STS */
-
-#define _ADS_CS_PR		0x10040004	/* PCMCIA Power/Reset */
-#define ADS_CS_PR_A_5V_POWER	(1 << 0)	/* Socket A Enable 5V Power */
-#define ADS_CS_PR_A_3V_POWER	(1 << 0)	/* Socket A Enable 3.3V Power */
-#define ADS_CS_PR_A_RESET		(1 << 2)	/* Socket A Reset */
-
-
-#define _ADS_SW_SWITCHES	0x10060000	/* Software Switches */
-
-
-/* Extra IRQ Controller */
-
-#define _ADS_INT_ST1		0x10080000	/* IRQ Status #1 */
-#define _ADS_INT_ST2		0x10080004	/* IRQ Status #2 */
-#define _ADS_INT_EN1		0x10080008	/* IRQ Enable #1 */
-#define _ADS_INT_EN2		0x1008000c	/* IRQ Enable #2 */
-
-/* Discrete Controller (AVR:Atmel AT90LS8535) */
-#define _ADS_AVR_REG		0x10080018
-
-/* On-Board Ethernet */
-
-#define _ADS_ETHERNET		0x100e0000	/* Ethernet */
-
-
-/* Extra UARTs */
-
-#define _ADS_UARTA		0x10100000	/* UART A */
-#define _ADS_UARTB		0x10120000	/* UART B */
-#define _ADS_UARTC		0x10140000	/* UART C */
-#define _ADS_UARTD		0x10160000	/* UART D */
-
-/* UART control lines GPIOs */
-#define GPIO_GC_UART0_RTS       GPIO_GPIO15
-#define GPIO_GC_UART1_RTS	    GPIO_GPIO17
-#define GPIO_GC_UART2_RTS	    GPIO_GPIO19
-#define GPIO_GC_UART0_CTS       GPIO_GPIO14
-#define GPIO_GC_UART1_CTS       GPIO_GPIO16
-#define GPIO_GC_UART2_CTS       GPIO_GPIO17
-
-/* UART control lines IRQs */
-#define IRQ_GC_UART0_CTS       IRQ_GPIO14
-#define IRQ_GC_UART1_CTS       IRQ_GPIO16
-#define IRQ_GC_UART2_CTS       IRQ_GPIO17
-
-/* LEDs */
-
-#define ADS_LED0	GPIO_GPIO20		/* on-board D22 */
-#define ADS_LED1	GPIO_GPIO21		/* on-board D21 */
-#define ADS_LED2	GPIO_GPIO22		/* on-board D20 */
-#define ADS_LED3	GPIO_GPIO23		/* external */
-#define ADS_LED4	GPIO_GPIO24		/* external */
-#define ADS_LED5	GPIO_GPIO25		/* external */
-#define ADS_LED6	GPIO_GPIO26		/* external */
-#define ADS_LED7	GPIO_GPIO27		/* external */
-
-
-/* Virtual register addresses */
-
-#ifndef __ASSEMBLY__
-#define ADS_INT_ST1	(*((volatile u_char *) ADS_p2v(_ADS_INT_ST1)))
-#define ADS_INT_ST2	(*((volatile u_char *) ADS_p2v(_ADS_INT_ST2)))
-#define ADS_INT_EN1	(*((volatile u_char *) ADS_p2v(_ADS_INT_EN1)))
-#define ADS_INT_EN2	(*((volatile u_char *) ADS_p2v(_ADS_INT_EN2)))
-#define ADS_ETHERNET	((int) ADS_p2v(_ADS_ETHERNET))
-#define ADS_AVR_REG	(*((volatile u_char *) ADS_p2v(_ADS_AVR_REG)))
-#endif
diff -Nru a/include/asm-arm/arch-sa1100/graphicsmaster.h b/include/asm-arm/arch-sa1100/graphicsmaster.h
--- a/include/asm-arm/arch-sa1100/graphicsmaster.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,64 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/graphicsmaster.h
- *
- * Created 2000/12/18 by Woojung Huh <whuh@applieddata.net>
- *
- * This file comes from graphicsclient.h of Nicolas Pitre <nico@cam.org>
- *
- * This file contains the hardware specific definitions for the
- * ADS GraphicsMaster
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-#define ADS_CPLD_BASE		(0x10000000)
-#define ADS_p2v( x )		((x) - ADS_CPLD_BASE + 0xf0000000)
-#define ADS_v2p( x )		((x) - 0xf0000000 + ADS_CPLD_BASE)
-
-
-#define _ADS_SW_SWITCHES	0x10060000	/* Software Switches */
-
-/* Extra IRQ Controller */
-#define _ADS_INT_ST1		0x10080000	/* IRQ Status #1 */
-#define _ADS_INT_ST2		0x10080004	/* IRQ Status #2 */
-#define _ADS_INT_EN1		0x10080008	/* IRQ Enable #1 */
-#define _ADS_INT_EN2		0x1008000c	/* IRQ Enable #2 */
-#define _ADS_DCR			0x10080018	/* Discrete Control Reg */
-
-/* Discrete Controller (AVR:Atmel AT90LS8535) */
-#define _ADS_AVR_REG		0x10080018
-
-/* On-Board Ethernet */
-#define _ADS_ETHERNET		0x100e0000	/* Ethernet */
-
-/* On-Board Quad UART 16C554 */
-#define	ADS_QUAD_UART1		0x10100000
-#define	ADS_QUAD_UART2		0x10120000
-#define	ADS_QUAD_UART3		0x10140000
-#define	ADS_QUAD_UART4		0x10160000
-
-/* LEDs */
-#define ADS_LED0	GPIO_GPIO20		/* on-board Green */
-#define ADS_LED1	GPIO_GPIO25		/* on-board Yellow */
-#define ADS_LED2	GPIO_GPIO26		/* on-board Red */
-
-/* DCR */
-#define DCR_AVR_RESET		0x01
-#define DCR_SA1111_RESET	0x02
-#define	DCR_BACKLITE_ON		0x04
-
-/* Virtual register addresses */
-
-#ifndef __ASSEMBLY__
-#define ADS_INT_ST1	(*((volatile u_char *) ADS_p2v(_ADS_INT_ST1)))
-#define ADS_INT_ST2	(*((volatile u_char *) ADS_p2v(_ADS_INT_ST2)))
-#define ADS_INT_EN1	(*((volatile u_char *) ADS_p2v(_ADS_INT_EN1)))
-#define ADS_INT_EN2	(*((volatile u_char *) ADS_p2v(_ADS_INT_EN2)))
-#define ADS_ETHERNET	((int) ADS_p2v(_ADS_ETHERNET))
-#define ADS_AVR_REG	(*((volatile u_char *) ADS_p2v(_ADS_AVR_REG)))
-#define ADS_DCR		(*((volatile u_char *) ADS_p2v(_ADS_DCR)))
-#endif
-
-#define	SA1111_BASE	(0x18000000)
diff -Nru a/include/asm-arm/arch-sa1100/huw_webpanel.h b/include/asm-arm/arch-sa1100/huw_webpanel.h
--- a/include/asm-arm/arch-sa1100/huw_webpanel.h	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,49 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/huw_webpanel.h
- *
- * based of assabet.h
- *
- * This file contains the hardware specific definitions for HUW_Webpanel
- *
- * 2000/11/13 Roman Jordan <jor@hoeft-wessel.de>
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-/* System Configuration Register flags */
-
-#define SCR_SDRAM_LOW	(1<<2)	/* SDRAM size (low bit) */
-#define SCR_SDRAM_HIGH	(1<<3)	/* SDRAM size (high bit) */
-#define SCR_FLASH_LOW	(1<<4)	/* Flash size (low bit) */
-#define SCR_FLASH_HIGH	(1<<5)	/* Flash size (high bit) */
-#define SCR_GFX		(1<<8)	/* Graphics Accelerator (0 = present) */
-#define SCR_SA1111	(1<<9)	/* Neponset (0 = present) */
-
-#define SCR_INIT	-1
-
-
-/* Board Control Register */
-
-#define BCR_BASE  0xf1000000
-#define BCR (*(volatile unsigned int *)(BCR_BASE))
-
-#define BCR_PSIO_DTR1      (1<<29)
-#define BCR_TFT_NPWR       (1<<28)
-#define BCR_PSIO_DTR3      (1<<27)
-#define BCR_TFT_ENA        (1<<26)
-#define BCR_CCFL_POW       (1<<25)
-#define BCR_PSIO_RTS1      (1<<24)
-#define BCR_PWM_BACKLIGHT  (1<<23)
-
-
-#ifndef __ASSEMBLY__
-extern unsigned long SCR_value;
-extern unsigned long BCR_value;
-#define BCR_set( x )	BCR = (BCR_value |= (x))
-#define BCR_clear( x )	BCR = (BCR_value &= ~(x))
-#endif
-
-
-
diff -Nru a/include/asm-arm/arch-sa1100/ide.h b/include/asm-arm/arch-sa1100/ide.h
--- a/include/asm-arm/arch-sa1100/ide.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/arch-sa1100/ide.h	2004-12-24 13:36:17 -08:00
@@ -14,6 +14,8 @@
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
 
+#error "This code is broken and needs update to match with current ide support"
+
 
 /*
  * Set up a hw structure for a specified data port, control port and IRQ.
@@ -47,10 +49,6 @@
 		*irq = 0;
 }
 
-#ifdef CONFIG_SA1100_TRIZEPS
-#include <asm/arch/trizeps.h>
-#endif
-
 /*
  * This registers the standard ports for this architecture with the IDE
  * driver.
@@ -58,55 +56,7 @@
 static __inline__ void
 ide_init_default_hwifs(void)
 {
-    if( machine_is_empeg() ){
-#ifdef CONFIG_SA1100_EMPEG
-	hw_regs_t hw;
-
-	/* First, do the SA1100 setup */
-
-	/* PCMCIA IO space */
-	MECR=0x21062106;
-
-        /* Issue 3 is much neater than issue 2 */
-	GPDR&=~(EMPEG_IDE1IRQ|EMPEG_IDE2IRQ);
-
-	/* Interrupts on rising edge: lines are inverted before they get to
-           the SA */
-	set_GPIO_IRQ_edge( (EMPEG_IDE1IRQ|EMPEG_IDE2IRQ), GPIO_FALLING_EDGE );
-
-	/* Take hard drives out of reset */
-	GPSR=(EMPEG_IDERESET);
-
-	/* Sonja and her successors have two IDE ports. */
-	/* MAC 23/4/1999, swap these round so that the left hand
-	   hard disk is hda when viewed from the front. This
-	   doesn't match the silkscreen however. */
-	ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x40, PCMCIA_IO_0_BASE + 0x78, NULL);
-	hw.irq = EMPEG_IRQ_IDE2;
-	ide_register_hw(&hw);
-	ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x00, PCMCIA_IO_0_BASE + 0x38, NULL);
-	hw.irq = ,EMPEG_IRQ_IDE1;
-	ide_register_hw(&hw);
-#endif
-    }
-
-    else if( machine_is_victor() ){
-#ifdef CONFIG_SA1100_VICTOR
-	hw_regs_t hw;
-
-	/* Enable appropriate GPIOs as interrupt lines */
-	GPDR &= ~GPIO_GPIO7;
-	set_GPIO_IRQ_edge( GPIO_GPIO7, GPIO_RISING_EDGE );
-
-	/* set the pcmcia interface timing */
-	MECR = 0x00060006;
-
-	ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x1f0, PCMCIA_IO_0_BASE + 0x3f6, NULL);
-	hw.irq = IRQ_GPIO7;
-	ide_register_hw(&hw);
-#endif
-    }
-    else if (machine_is_lart()) {
+    if (machine_is_lart()) {
 #ifdef CONFIG_SA1100_LART
         hw_regs_t hw;
 
@@ -121,25 +71,6 @@
 	ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x0000, PCMCIA_IO_0_BASE + 0x1000, NULL);
         hw.irq = LART_IRQ_IDE;
         ide_register_hw(&hw);
-#endif
-    }
-    else if( machine_is_trizeps() ){
-#ifdef CONFIG_SA1100_TRIZEPS
-	hw_regs_t hw;
-
-	/* Enable appropriate GPIOs as interrupt lines */
-	GPDR &= ~GPIO_GPIO(TRIZEPS_IRQ_IDE);
-	set_irq_type( TRIZEPS_IRQ_IDE, IRQT_RISING );
-
-	/* set the pcmcia interface timing */
-	//MECR = 0x00060006; // Done on trizeps init
-
-	/* Take hard drives out of reset */
-	GPSR = GPIO_GPIO(TRIZEPS_IRQ_IDE);
-
-	ide_init_hwif_ports(&hw, TRIZEPS_IDE_CS0 + 0, TRIZEPS_IDE_CS1 + 6, NULL);
-	hw.irq = TRIZEPS_IRQ_IDE;
-	ide_register_hw(&hw, NULL);
 #endif
     }
 }
diff -Nru a/include/asm-arm/arch-sa1100/io.h b/include/asm-arm/arch-sa1100/io.h
--- a/include/asm-arm/arch-sa1100/io.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-arm/arch-sa1100/io.h	2004-12-24 13:36:19 -08:00
@@ -16,8 +16,8 @@
  * We don't actually have real ISA nor PCI buses, but there is so many 
  * drivers out there that might just work if we fake them...
  */
-#define __io(a)			(PCIO_BASE + (a))
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		((unsigned long)(a))
+#define __io(a)			((void __iomem *)(PCIO_BASE + (a)))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		(a)
 
 #endif
diff -Nru a/include/asm-arm/arch-sa1100/irqs.h b/include/asm-arm/arch-sa1100/irqs.h
--- a/include/asm-arm/arch-sa1100/irqs.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-arm/arch-sa1100/irqs.h	2004-12-24 13:36:16 -08:00
@@ -150,14 +150,11 @@
  *
  * If we have an SA1111, the max IRQ is S1_BVD1_STSCHG+1.
  * If we have an LoCoMo, the max IRQ is IRQ_LOCOMO_SPI_TEND+1
- * If graphicsclient or graphicsmaster, we don't have a SA1111.
  * Otherwise, we have the standard IRQs only.
  */
 #ifdef CONFIG_SA1111
 #define NR_IRQS			(IRQ_S1_BVD1_STSCHG + 1)
-#elif defined(CONFIG_SA1100_GRAPHICSCLIENT) || \
-      defined(CONFIG_SA1100_GRAPHICSMASTER) || \
-      defined(CONFIG_SA1100_H3800)
+#elif defined(CONFIG_SA1100_H3800)
 #define NR_IRQS			(IRQ_BOARD_END)
 #elif defined(CONFIG_SHARP_LOCOMO)
 #define NR_IRQS			(IRQ_LOCOMO_SPI_TEND + 1)
@@ -172,10 +169,6 @@
 #define IRQ_NEPONSET_SMC9196	(IRQ_BOARD_START + 0)
 #define IRQ_NEPONSET_USAR	(IRQ_BOARD_START + 1)
 #define IRQ_NEPONSET_SA1111	(IRQ_BOARD_START + 2)
-
-/* PT Digital Board Interrupts (CONFIG_SA1100_PT_SYSTEM3) */
-#define IRQ_SYSTEM3_SA1111	(IRQ_BOARD_START + 0)
-#define IRQ_SYSTEM3_SMC9196	(IRQ_BOARD_START + 1)
 
 /* LoCoMo Interrupts (CONFIG_SHARP_LOCOMO) */
 #define IRQ_LOCOMO_KEY_BASE	(IRQ_BOARD_START + 0)
diff -Nru a/include/asm-arm/arch-sa1100/itsy.h b/include/asm-arm/arch-sa1100/itsy.h
--- a/include/asm-arm/arch-sa1100/itsy.h	2004-12-24 13:37:04 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,5 +0,0 @@
-#ifndef _INCLUDE_ITSY_H_
-#define _INCLUDE_ITSY_H_
-
-
-#endif
diff -Nru a/include/asm-arm/arch-sa1100/mftb2.h b/include/asm-arm/arch-sa1100/mftb2.h
--- a/include/asm-arm/arch-sa1100/mftb2.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,210 +0,0 @@
-#ifndef _ARCH_ARM_MFTB2_h_
-#define _ARCH_ARM_MFTB2_h_
-
-// Defines for arch/arm/mm/mm-sa1100.h
-#define TRIZEPS_PHYS_VIRT_MAP_SIZE   0x00800000l
-
-// physical address (only for mm-sa1100.h)
-#define TRIZEPS_PHYS_IO_BASE         0x30000000l
-#define TRIZEPS_PHYS_MEM_BASE        0x38000000l
-
-// virtual
-#define TRIZEPS_IO_BASE		     0xF0000000l
-#define TRIZEPS_MEM_BASE             0xF2000000l
-
-// Offsets for phys and virtual
-#define TRIZEPS_OFFSET_REG0          0x00300000l
-#define TRIZEPS_OFFSET_REG1          0x00380000l
-#define TRIZEPS_OFFSET_IDE_CS0       0x00000000l
-#define TRIZEPS_OFFSET_IDE_CS1       0x00080000l
-#define TRIZEPS_OFFSET_UART5         0x00100000l
-#define TRIZEPS_OFFSET_UART6         0x00180000l
-#define TRIZEPS_PHYS_REG0            (TRIZEPS_PHYS_IO_BASE + TRIZEPS_OFFSET_REG0)
-#define TRIZEPS_PHYS_REG1            (TRIZEPS_PHYS_IO_BASE + TRIZEPS_OFFSET_REG1)
-#define TRIZEPS_PHYS_IDE_CS0         (TRIZEPS_PHYS_IO_BASE + TRIZEPS_OFFSET_IDE_CS0)
-#define TRIZEPS_PHYS_IDE_CS1         (TRIZEPS_PHYS_IO_BASE + TRIZEPS_OFFSET_IDE_CS1)
-#define TRIZEPS_PHYS_UART5           (TRIZEPS_PHYS_IO_BASE + TRIZEPS_OFFSET_UART5)
-#define TRIZEPS_PHYS_UART6           (TRIZEPS_PHYS_IO_BASE + TRIZEPS_OFFSET_UART6)
-
-// Use follow defines in devices
-// virtual address
-#define TRIZEPS_REG0    (TRIZEPS_IO_BASE + TRIZEPS_OFFSET_REG0)
-#define TRIZEPS_REG1    (TRIZEPS_IO_BASE + TRIZEPS_OFFSET_REG1)
-#define TRIZEPS_IDE_CS0 (TRIZEPS_IO_BASE + TRIZEPS_OFFSET_IDE_CS0)
-#define TRIZEPS_IDE_CS1 (TRIZEPS_IO_BASE + TRIZEPS_OFFSET_IDE_CS1)
-#define TRIZEPS_UART5   (TRIZEPS_IO_BASE + TRIZEPS_OFFSET_UART5)
-#define TRIZEPS_UART6   (TRIZEPS_IO_BASE + TRIZEPS_OFFSET_UART6)
-
-#define TRIZEPS_BAUD_BASE 1500000
-
-//#if 0 //temporarily disabled
-#ifndef __ASSEMBLY__
-struct tri_uart_cts_data_t {
-    int cts_gpio;
-    int cts_prev_state;
-    struct uart_info *info;
-    struct uart_port *port;
-    const char *name;
-};
-#endif /* __ASSEMBLY__ */
-
-/* Defines for MFTB2 serial_sa1100.c hardware handshaking lines */
-#define SERIAL_FULL
-#define NOT_CONNECTED	0
-#ifdef SERIAL_FULL
-#define TRIZEPS_GPIO_UART1_RTS	GPIO_GPIO14
-#define TRIZEPS_GPIO_UART1_DTR	NOT_CONNECTED //GPIO_GPIO9
-#define TRIZEPS_GPIO_UART1_CTS	GPIO_GPIO15
-#define TRIZEPS_GPIO_UART1_DCD	NOT_CONNECTED //GPIO_GPIO2
-#define TRIZEPS_GPIO_UART1_DSR	NOT_CONNECTED //GPIO_GPIO3
-#define TRIZEPS_GPIO_UART3_RTS	NOT_CONNECTED //GPIO_GPIO7
-#define TRIZEPS_GPIO_UART3_DTR	NOT_CONNECTED //GPIO_GPIO8
-#define TRIZEPS_GPIO_UART3_CTS	NOT_CONNECTED //GPIO_GPIO4
-#define TRIZEPS_GPIO_UART3_DCD	NOT_CONNECTED //GPIO_GPIO5
-#define TRIZEPS_GPIO_UART3_DSR	NOT_CONNECTED //GPIO_GPIO6
-
-#define TRIZEPS_GPIO_UART2_RTS	NOT_CONNECTED //GPIO_GPIO7
-#define TRIZEPS_GPIO_UART2_DTR	NOT_CONNECTED //GPIO_GPIO8
-#define TRIZEPS_GPIO_UART2_CTS	NOT_CONNECTED //GPIO_GPIO4
-#define TRIZEPS_GPIO_UART2_DCD	NOT_CONNECTED //GPIO_GPIO5
-#define TRIZEPS_GPIO_UART2_DSR	NOT_CONNECTED //GPIO_GPIO6
-
-#define TRIZEPS_IRQ_UART1_CTS	IRQ_GPIO15
-#define TRIZEPS_IRQ_UART1_DCD	NO_IRQ //IRQ_GPIO2
-#define TRIZEPS_IRQ_UART1_DSR	NO_IRQ //IRQ_GPIO3
-#define TRIZEPS_IRQ_UART3_CTS	NO_IRQ //IRQ_GPIO4
-#define TRIZEPS_IRQ_UART3_DCD	NO_IRQ //IRQ_GPIO5
-#define TRIZEPS_IRQ_UART3_DSR	NO_IRQ //IRQ_GPIO6
-
-#define TRIZEPS_IRQ_UART2_CTS	NO_IRQ //IRQ_GPIO4
-#define TRIZEPS_IRQ_UART2_DCD	NO_IRQ //IRQ_GPIO5
-#define TRIZEPS_IRQ_UART2_DSR	NO_IRQ //IRQ_GPIO6
-
-#endif /* SERIAL_FULL */
-//#endif //0
-
-/*
- * This section contains the defines for the MFTB2 implementation
- * of drivers/ide/hd.c. HD_IOBASE_0 and HD_IOBASE_1 have to be
- * adjusted if hardware changes.
- */
-#define TRIZEPS_IRQ_IDE 10		/* MFTB2 specific */
-
-/*---   ROOT   ---*/
-#define TRIZEPS_GPIO_ROOT_NFS       0
-#define TRIZEPS_GPIO_ROOT_HD        21
-/*---  PCMCIA  ---*/
-#define TRIZEPS_GPIO_PCMCIA_IRQ0 1
-#define TRIZEPS_GPIO_PCMCIA_CD0  24
-#define TRIZEPS_IRQ_PCMCIA_IRQ0  TRIZEPS_GPIO_PCMCIA_IRQ0
-#define TRIZEPS_IRQ_PCMCIA_CD0   TRIZEPS_GPIO_PCMCIA_CD0 + 32 - 11
-
-// REGISTER 0 -> 0x0XXXX (16bit access)
-// read only
-#define TRIZEPS_A_STAT             0x8000l
-#define TRIZEPS_F_STAT             0x4000l
-#define TRIZEPS_BATT_FAULT_EN      0x2000l
-#define TRIZEPS_nDQ                0x1000l
-#define TRIZEPS_MFT_OFF            0x0800l
-#define TRIZEPS_D_APWOFF           0x0400l
-#define TRIZEPS_F_CTRL             0x0200l
-#define TRIZEPS_F_STOP             0x0100l
-
-// read / write
-#define TRIZEPS_KP_IR_EN           0x0080l
-#define TRIZEPS_FIR                0x0040l
-#define TRIZEPS_BAR_ON             0x0020l
-#define TRIZEPS_VCI_ON             0x0010l
-#define TRIZEPS_LED4               0x0008l
-#define TRIZEPS_LED3               0x0004l
-#define TRIZEPS_LED2               0x0002l
-#define TRIZEPS_LED1               0x0001l
-
-// REGISTER 1 -> 0x1XXXX (16bit access)
-// read only
-#define TRIZEPS_nVCI2              0x8000l
-#define TRIZEPS_nAB_LOW            0x4000l
-#define TRIZEPS_nMB_DEAD           0x2000l
-#define TRIZEPS_nMB_LOW            0x1000l
-#define TRIZEPS_nPCM_VS2           0x0800l
-#define TRIZEPS_nPCM_VS1           0x0400l
-#define TRIZEPS_PCM_BVD2           0x0200l
-#define TRIZEPS_PCM_BVD1           0x0100l
-
-// read / write
-#define TRIZEPS_nROOT_NFS          0x0080l
-#define TRIZEPS_nROOT_HD           0x0040l
-#define TRIZEPS_nPCM_ENA_REG       0x0020l
-#define TRIZEPS_nPCM_RESET_DISABLE 0x0010l
-#define TRIZEPS_PCM_EN0_REG        0x0008l
-#define TRIZEPS_PCM_EN1_REG        0x0004l
-#define TRIZEPS_PCM_V3_EN_REG      0x0002l
-#define TRIZEPS_PCM_V5_EN_REG      0x0001l
-
-/* Access to Board Control Register */
-#define TRIZEPS_BCR0 (*(volatile unsigned short *)(TRIZEPS_REG0))
-#define TRIZEPS_BCR1 (*(volatile unsigned short *)(TRIZEPS_REG1))
-
-#define TRIZEPS_BCR_set( reg, x ) do { \
-	unsigned long flags; \
-	local_irq_save(flags); \
-	(reg) |= (x); \
-	local_irq_restore(flags); \
-} while (0)
-
-#define TRIZEPS_BCR_clear( reg, x ) do { \
-	unsigned long flags; \
-	local_irq_save(flags); \
-	(reg) &= ~(x); \
-	local_irq_restore(flags); \
-} while (0)
-
-#define TRIZEPS_OFFSET_KP_REG      0x00200000l
-#define TRIZEPS_OFFSET_VCI2        0x00280000l
-#define TRIZEPS_OFFSET_VCI4        0x00400000l
-
-#define TRIZEPS_OFFSET_VCI2_1_DPR  (TRIZEPS_OFFSET_VCI2 + 0x00010000l)
-#define TRIZEPS_OFFSET_VCI2_2_DPR  (TRIZEPS_OFFSET_VCI2 + 0x00018000l)
-#define TRIZEPS_OFFSET_VCI2_1_SEMA (TRIZEPS_OFFSET_VCI2 + 0x00020000l)
-#define TRIZEPS_OFFSET_VCI2_2_SEMA (TRIZEPS_OFFSET_VCI2 + 0x00028000l)
-
-#define TRIZEPS_OFFSET_VCI4_1_DPR  (TRIZEPS_OFFSET_VCI4 + 0x00000000l)
-#define TRIZEPS_OFFSET_VCI4_2_DPR  (TRIZEPS_OFFSET_VCI4 + 0x00008000l)
-#define TRIZEPS_OFFSET_VCI4_1_SEMA (TRIZEPS_OFFSET_VCI4 + 0x00000380l)
-#define TRIZEPS_OFFSET_VCI4_2_SEMA (TRIZEPS_OFFSET_VCI4 + 0x00000388l)
-#define TRIZEPS_OFFSET_VCI4_1_CNTR (TRIZEPS_OFFSET_VCI4 + 0x00000390l)
-#define TRIZEPS_OFFSET_VCI4_2_CNTR (TRIZEPS_OFFSET_VCI4 + 0x00000392l)
-
-#define TRIZEPS_PHYS_KP_REG        (PHYS_TRIZEPS_IO_BASE + TRIZEPS_OFFSET_KP_REG)
-
-// VCI address
-#define TRIZEPS_PHYS_VCI2_1_DPR    (TRIZEPS_PHYS_MEM_BASE + TRIZEPS_OFFSET_VCI2_1_DPR)
-#define TRIZEPS_PHYS_VCI2_2_DPR    (TRIZEPS_PHYS_MEM_BASE + TRIZEPS_OFFSET_VCI2_2_DPR)
-#define TRIZEPS_PHYS_VCI2_1_SEMA   (TRIZEPS_PHYS_MEM_BASE + TRIZEPS_OFFSET_VCI2_1_SEMA)
-#define TRIZEPS_PHYS_VCI2_2_SEMA   (TRIZEPS_PHYS_MEM_BASE + TRIZEPS_OFFSET_VCI2_2_SEMA)
-
-// VCI4 address
-#define TRIZEPS_PHYS_VCI4_1_DPR    (TRIZEPS_PHYS_MEM_BASE + TRIZEPS_OFFSET_VCI4_1_DPR)
-#define TRIZEPS_PHYS_VCI4_2_DPR    (TRIZEPS_PHYS_MEM_BASE + TRIZEPS_OFFSET_VCI4_2_DPR)
-#define TRIZEPS_PHYS_VCI4_1_SEMA   (TRIZEPS_PHYS_IO_BASE  + TRIZEPS_OFFSET_VCI4_1_SEMA)
-#define TRIZEPS_PHYS_VCI4_2_SEMA   (TRIZEPS_PHYS_IO_BASE  + TRIZEPS_OFFSET_VCI4_2_SEMA)
-#define TRIZEPS_PHYS_VCI4_1_CNTR   (TRIZEPS_PHYS_IO_BASE  + TRIZEPS_OFFSET_VCI4_1_CNTR)
-#define TRIZEPS_PHYS_VCI4_2_CNTR   (TRIZEPS_PHYS_IO_BASE  + TRIZEPS_OFFSET_VCI4_2_CNTR)
-
-#define TRIZEPS_KP_REG               (TRIZEPS_IO_BASE  + TRIZEPS_OFFSET_KP_REG)
-
-// VCI address
-#define TRIZEPS_VCI2_1_DPR           (TRIZEPS_MEM_BASE + TRIZEPS_OFFSET_VCI2_1_DPR)
-#define TRIZEPS_VCI2_2_DPR           (TRIZEPS_MEM_BASE + TRIZEPS_OFFSET_VCI2_2_DPR)
-#define TRIZEPS_VCI2_1_SEMA          (TRIZEPS_MEM_BASE + TRIZEPS_OFFSET_VCI2_1_SEMA)
-#define TRIZEPS_VCI2_2_SEMA          (TRIZEPS_MEM_BASE + TRIZEPS_OFFSET_VCI2_2_SEMA)
-
-// VCI4 address
-#define TRIZEPS_VCI4_1_DPR           (TRIZEPS_MEM_BASE + TRIZEPS_OFFSET_VCI4_1_DPR)
-#define TRIZEPS_VCI4_2_DPR           (TRIZEPS_MEM_BASE + TRIZEPS_OFFSET_VCI4_2_DPR)
-#define TRIZEPS_VCI4_1_SEMA          (TRIZEPS_IO_BASE  + TRIZEPS_OFFSET_VCI4_1_SEMA)
-#define TRIZEPS_VCI4_2_SEMA          (TRIZEPS_IO_BASE  + TRIZEPS_OFFSET_VCI4_2_SEMA)
-#define TRIZEPS_VCI4_1_CNTR          (TRIZEPS_IO_BASE  + TRIZEPS_OFFSET_VCI4_1_CNTR)
-#define TRIZEPS_VCI4_2_CNTR          (TRIZEPS_IO_BASE  + TRIZEPS_OFFSET_VCI4_2_CNTR)
-
-#endif
diff -Nru a/include/asm-arm/arch-sa1100/omnimeter.h b/include/asm-arm/arch-sa1100/omnimeter.h
--- a/include/asm-arm/arch-sa1100/omnimeter.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,84 +0,0 @@
-/* -*- Mode: c++ -*-
- *
- *  Copyright 2000 Massachusetts Institute of Technology
- *
- *  Permission to use, copy, modify, distribute, and sell this software and its
- *  documentation for any purpose is hereby granted without fee, provided that
- *  the above copyright notice appear in all copies and that both that
- *  copyright notice and this permission notice appear in supporting
- *  documentation, and that the name of M.I.T. not be used in advertising or
- *  publicity pertaining to distribution of the software without specific,
- *  written prior permission.  M.I.T. makes no representations about the
- *  suitability of this software for any purpose.  It is provided "as is"
- *  without express or implied warranty.
- *
- */
-
-#ifndef OMNIMETER_H
-#define OMNIMETER_H
-// use the address of the second socket for both sockets
-// (divide address space in half and use offsets to wrap second card accesses back to start of address space)
-// Following values for programming Cirrus Logic chip
-#define Socket1Base 0x40
-
-#define SocketMemoryWindowLen    (0x00400000)
-#define Socket0MemoryWindowStart (0x00800000)
-#define Socket1MemoryWindowStart (Socket0MemoryWindowStart + SocketMemoryWindowLen)
-
-#define SocketIOWindowLen        (0x00008000)
-#define Socket1IOWindowStart     (SocketIOWindowLen)
-#define Socket1IOWindowOffset    (0x00010000 - Socket1IOWindowStart)
-
-// Following values for run-time access
-
-//#define PCCardBase     (0xe4000000) //jca (0x30000000)
-//#define PCCardBase     (0x30000000)
-#define PCCardBase     (0xe0000000)  //jag
-
-#define PCCard0IOBase (PCCardBase)
-//#define PCCard0AttrBase (0xec000000) //jca (PCCardBase + 0x08000000)
-#define PCCard0AttrBase (0xe8000000)
-//#define PCCard0AttrBase (PCCardBase + 0x08000000)
-//#define PCCard0MemBase (0xf4000000) //jca (PCCardBase + 0x0C000000)
-//#define PCCard0MemBase (PCCardBase + 0x0C000000)
-#define PCCard0MemBase (0xf0000000)
-
-//#define PCCard1IOBase (PCCardBase + SocketIOWindowLen)  //jag
-#define PCCard1IOBase (0xe4000000)
-//#define PCCard1AttrBase (0xec000000 + SocketMemoryWindowLen)  //jag
-#define PCCard1AttrBase (0xec000000)
-//#define PCCard1MemBase (0xf4000000 + SocketMemoryWindowLen)  //jag
-#define PCCard1MemBase (0xf4000000)
-
-#define PCCardIndexRegister (PCCard0IOBase + 0x000003E0) //altered
-#define PCCardDataRegister  (PCCardIndexRegister + 1)
-
-/* interrupts */
-#define PIN_cardInt2	13
-#define PIN_cardInt1	5
-
-void SMBOn(unsigned char SMBaddress);
-void SetSMB(unsigned char SMBaddress, unsigned int dacValue);
-
-#define GPIO_key6	0x00040000
-#define GPIO_scl	0x01000000  // output,   SMB clock
-#define GPIO_sda	0x02000000  // bidirect, SMB data
-#define SMB_LCDVEE 0x2C
-#define DefaultLCDContrast	16
-
-#define LEDBacklightOn()	ClearGPIOpin(GPIO_key6)
-#define LEDBacklightOff()	SetGPIOpin(GPIO_key6)
-#define LCDPowerOn()			SMBOn(SMB_LCDVEE)
-#define LCDPowerOff()			SMBOff(SMB_LCDVEE)
-#define SetLCDContrast(d)		SetSMB(SMB_LCDVEE, d)
-#define WritePort32(port,value) (port = (value))
-#define ReadPort32(port) (port)
-#define SetGPIOpin(pin)		WritePort32(GPSR,pin)
-#define ClearGPIOpin(pin)	WritePort32(GPCR,pin)
-
-void jcaoutb(long p, unsigned char data);
-unsigned char jcainb(long p);
-void jcaoutw(long p, unsigned short data);
-unsigned short jcainw_p(long p);
-
-#endif
diff -Nru a/include/asm-arm/arch-sa1100/pangolin.h b/include/asm-arm/arch-sa1100/pangolin.h
--- a/include/asm-arm/arch-sa1100/pangolin.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,62 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/pangolin.h
- *
- * Created 2000/08/25 by Murphy Chen <murphy@mail.dialogue.com.tw>
- *
- * This file contains the hardware specific definitions for Pangolin
- *
- */
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-#include <linux/config.h>
-
-#ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
-
-/* GPIOs for which the generic definition doesn't say much */
-#define GPIO_CF_BUS_ON		GPIO_GPIO (3)
-#define GPIO_CF_RESET		GPIO_GPIO (2)
-#define GPIO_CF_CD		GPIO_GPIO (22)
-#define GPIO_CF_IRQ		GPIO_GPIO (21)
-
-#define IRQ_GPIO_CF_IRQ		IRQ_GPIO21
-#define IRQ_GPIO_CF_CD		IRQ_GPIO22
-
-#else
-/*
- *  These definitions are for PCMCIA/IDE card
- *
- *  PSKTSEL = 0 ---> PCMCIA
- *  PCMCIA_RESET = GPIO_7        ( output )( 0: normal   1: reset )
- *  PCMCIA_IRQ = GPIO_24         ( input )
- *  PCMCIA_CD = GPIO_25          ( input )
- *
- *  PSKTSEL = 1 ---> IDE port
- *  IDE_IRQ = GPIO_23            ( input )
- *
- *  !!WARNING!!
- *  When the PCMCIA/IDE card is inserted, the CF slot
- *  should not have any card inserted!!
- *
- */
-
-#define GPIO_PCMCIA_RESET       GPIO_GPIO (7)
-#define GPIO_PCMCIA_IRQ         GPIO_GPIO (24)
-#define GPIO_PCMCIA_CD          GPIO_GPIO (25)
-#define GPIO_IDE_IRQ            GPIO_GPIO (8)
-
-#define IRQ_PCMCIA_IRQ          IRQ_GPIO24
-#define IRQ_PCMCIA_CD           IRQ_GPIO25
-#define IRQ_IDE_IRQ             IRQ_GPIO8
-
-#endif
-
-/*
- * On board LAN chip
- */
-#define PANGOLIN_LAN_ADDR      0x32000000
-#define PANGOLIN_LAN_RESET     GPIO_GPIO (8)
-#define PANGOLIN_LAN_IRQ       GPIO_GPIO (26)
-#define PANGOLIN_IRQ_LAN_IRQ   IRQ_GPIO26
-
diff -Nru a/include/asm-arm/arch-sa1100/pfs168.h b/include/asm-arm/arch-sa1100/pfs168.h
--- a/include/asm-arm/arch-sa1100/pfs168.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,75 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/pfs168.h
- *
- * Created 2000/06/05 by Nicolas Pitre <nico@cam.org>
- *
- * This file contains the hardware specific definitions for PFS-168
- *
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-
-/* GPIOs for which the generic definition doesn't say much */
-#define GPIO_RADIO_IRQ		GPIO_GPIO (14)	/* Radio interrupt request  */
-#define GPIO_L3_I2C_SDA		GPIO_GPIO (15)	/* L3 and SMB control ports */
-#define GPIO_PS_MODE_SYNC	GPIO_GPIO (16)	/* Power supply mode/sync   */
-#define GPIO_L3_MODE		GPIO_GPIO (17)	/* L3 mode signal with LED  */
-#define GPIO_L3_I2C_SCL		GPIO_GPIO (18)	/* L3 and I2C control ports */
-#define GPIO_STEREO_64FS_CLK	GPIO_GPIO (19)	/* SSP UDA1341 clock input  */
-#define GPIO_CF_IRQ		GPIO_GPIO (21)	/* CF IRQ   */
-#define GPIO_MBGNT		GPIO_GPIO (21)	/* 1111 MBGNT */
-#define GPIO_CF_CD		GPIO_GPIO (22)	/* CF CD */
-#define GPIO_MBREQ		GPIO_GPIO (22)	/* 1111 MBREQ */
-#define GPIO_UCB1300_IRQ	GPIO_GPIO (23)	/* UCB GPIO and touchscreen */
-#define GPIO_CF_BVD2		GPIO_GPIO (24)	/* CF BVD */
-#define GPIO_GFX_IRQ		GPIO_GPIO (24)	/* Graphics IRQ */
-#define GPIO_CF_BVD1		GPIO_GPIO (25)	/* CF BVD */
-#define GPIO_NEP_IRQ		GPIO_GPIO (25)	/* Neponset IRQ */
-#define GPIO_BATT_LOW		GPIO_GPIO (26)	/* Low battery */
-#define GPIO_RCLK		GPIO_GPIO (26)	/* CCLK/2  */
-
-#define IRQ_GPIO_CF_IRQ		IRQ_GPIO21
-#define IRQ_GPIO_CF_CD		IRQ_GPIO22
-#define IRQ_GPIO_MBREQ		IRQ_GPIO22
-#define IRQ_GPIO_UCB1300_IRQ	IRQ_GPIO23
-#define IRQ_GPIO_CF_BVD2	IRQ_GPIO24
-#define IRQ_GPIO_CF_BVD1	IRQ_GPIO25
-#define IRQ_GPIO_NEP_IRQ	IRQ_GPIO25
-
-
-/*
- * PFS-168 definitions:
- */
-
-#define SA1111_BASE             (0x40000000)
-
-#ifndef __ASSEMBLY__
-#define PFS168_COM5_VBASE		(*((volatile unsigned char *)(0xf0000000UL)))
-#define PFS168_COM6_VBASE		(*((volatile unsigned char *)(0xf0001000UL)))
-#define PFS168_SYSC1RTS			(*((volatile unsigned char *)(0xf0002000UL)))
-#define PFS168_SYSLED			(*((volatile unsigned char *)(0xf0003000UL)))
-#define PFS168_SYSDTMF			(*((volatile unsigned char *)(0xf0004000UL)))
-#define PFS168_SYSLCDDE			(*((volatile unsigned char *)(0xf0005000UL)))
-#define PFS168_SYSC1DSR			(*((volatile unsigned char *)(0xf0006000UL)))
-#define PFS168_SYSC3TEN			(*((volatile unsigned char *)(0xf0007000UL)))
-#define PFS168_SYSCTLA			(*((volatile unsigned char *)(0xf0008000UL)))
-#define PFS168_SYSCTLB			(*((volatile unsigned char *)(0xf0009000UL)))
-#define PFS168_ETH_VBASE		(*((volatile unsigned char *)(0xf000a000UL)))
-#endif
-
-#define PFS168_SYSLCDDE_STNDE		(1<<0)	/* CSTN display enable/disable (1/0) */
-#define PFS168_SYSLCDDE_DESEL		(1<<0)	/* Active/Passive (1/0) display enable mode */
-
-#define PFS168_SYSCTLA_BKLT		(1<<0)	/* LCD backlight invert on/off (1/0) */
-#define PFS168_SYSCTLA_RLY		(1<<1)	/* Relay on/off (1/0) */
-#define PFS168_SYSCTLA_PXON		(1<<2)	/* Opto relay connect/disconnect 1/0) */
-#define PFS168_SYSCTLA_IRDA_FSEL	(1<<3)	/* IRDA Frequency select (0 = SIR, 1 = MIR/ FIR) */
-
-#define PFS168_SYSCTLB_MG1		(1<<0)	/* Motion detector gain select */
-#define PFS168_SYSCTLB_MG0		(1<<1)	/* Motion detector gain select */
-#define PFS168_SYSCTLB_IRDA_MD1		(1<<2)	/* Range/Power select */
-#define PFS168_SYSCTLB_IRDA_MD0		(1<<3)	/* Range/Power select */
-#define PFS168_SYSCTLB_IRDA_MD_MASK	(PFS168_SYSCTLB_IRDA_MD1|PFS168_SYSCTLB_IRDA_MD0)
diff -Nru a/include/asm-arm/arch-sa1100/pleb.h b/include/asm-arm/arch-sa1100/pleb.h
--- a/include/asm-arm/arch-sa1100/pleb.h	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,21 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/pleb.h
- *
- * Created 2000/12/08 by Daniel Potts <danielp@cse.unsw.edu.au>
- *
- * This file contains the hardware specific definitions for the
- * PLEB board. http://www.cse.unsw.edu.au/~pleb
- */
-
-#ifndef _INCLUDE_PLEB_H_
-#define _INCLUDE_PLEB_H_
-
-#define PLEB_ETH0_P		(0x20000300)	/* Ethernet 0 in PCMCIA0 IO */
-#define PLEB_ETH0_V		(0xf6000300)
-
-#define GPIO_ETH0_IRQ		GPIO_GPIO (21)
-#define GPIO_ETH0_EN		GPIO_GPIO (26)
-
-#define IRQ_GPIO_ETH0_IRQ	IRQ_GPIO21
-
-#endif
diff -Nru a/include/asm-arm/arch-sa1100/serial.h b/include/asm-arm/arch-sa1100/serial.h
--- a/include/asm-arm/arch-sa1100/serial.h	2004-12-24 13:36:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,47 +0,0 @@
-/*
- * include/asm-arm/arch-sa1100/serial.h
- * (C) 1999 Nicolas Pitre <nico@cam.org>
- *
- * All this is intended to be used with a 16550-like UART on the SA1100's 
- * PCMCIA bus.  It has nothing to do with the SA1100's internal serial ports.
- * This is included by serial.c -- serial_sa1100.c makes no use of it.
- */
-
-#include <linux/config.h>
-
-/* Standard COM flags */
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-/*
- * Rather empty table...
- * Hardwired serial ports should be defined here.
- * PCMCIA will fill it dynamically.
- */
-#ifdef CONFIG_SA1100_TRIZEPS
-
-#define STD_SERIAL_PORT_DEFNS	\
-       /* UART	CLK     	PORT		IRQ		FLAGS		*/ \
-	{ 0,	1500000,	TRIZEPS_UART5,	IRQ_GPIO16,	STD_COM_FLAGS },   \
-	{ 0,	1500000,	TRIZEPS_UART6,	IRQ_GPIO17,	STD_COM_FLAGS }
-
-#else
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD ( 1843200 / 16 )
-
-#define STD_SERIAL_PORT_DEFNS	\
-       /* UART	CLK     	PORT		IRQ	FLAGS		*/ \
-	{ 0,	BASE_BAUD,	0, 		0,	STD_COM_FLAGS },   \
-	{ 0,	BASE_BAUD,	0, 		0,	STD_COM_FLAGS },   \
-	{ 0,	BASE_BAUD,	0, 		0,	STD_COM_FLAGS },   \
-	{ 0,	BASE_BAUD,	0, 		0,	STD_COM_FLAGS }
-
-#endif
-
-#define EXTRA_SERIAL_PORT_DEFNS
diff -Nru a/include/asm-arm/arch-sa1100/stork.h b/include/asm-arm/arch-sa1100/stork.h
--- a/include/asm-arm/arch-sa1100/stork.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,164 +0,0 @@
-/*
-	stork.h
-
-*/
-
-#ifndef STORK_SA1100_H
-#define STORK_SA1100_H
-
-/* ugly - this will make sure we build sa1100fb for the Nec display not the Kyocera */
-#define STORK_TFT	1
-
-
-#define GPIO_STORK_SWITCH_1		(1 << 0)    /* Switch 1 - input */
-#define GPIO_STORK_SWITCH_2		(1 << 1)    /* Switch 2 - input */
-#define GPIO_STORK_TOUCH_SCREEN_BUSY	(1 << 10)   /* TOUCH_SCREEN_BUSY - input */
-#define GPIO_STORK_TOUCH_SCREEN_DATA	(1 << 11)   /* TOUCH_SCREEN_DATA - input */
-#define GPIO_STORK_CODEC_AGCSTAT	(1 << 12)   /* CODEC_AGCSTAT -input */
-#define GPIO_STORK_RS232_ON		(1 << 13)   /* enable RS232 (UART1) */
-#define GPIO_STORK_TEST_POINT		(1 << 14)   /* to test point */
-#define GPIO_STORK_L3_I2C_SDA		(1 << 15)   /* L3_I2C_SDA - bidirectional */
-#define GPIO_STORK_PSU_SYNC_MODE	(1 << 16)   /* PSU_SYNC_MODE - output */
-#define GPIO_STORK_L3_MODE		(1 << 17)   /* L3 mode - output (??) */
-#define GPIO_STORK_L3_I2C_SCL		(1 << 18)   /* L3_I2C_SCL - bidirectional */
-#define GPIO_STORK_AUDIO_CLK		(1 << 19)   /* SSP external clock (Audio clock) - input */
-#define GPIO_STORK_PCMCIA_A_CARD_DETECT	(1 << 20)   /* PCMCIA_A_CARD_DETECT - input */
-#define GPIO_STORK_PCMCIA_B_CARD_DETECT	(1 << 21)   /* PCMCIA_B_CARD_DETECT - input */
-#define GPIO_STORK_PCMCIA_A_RDY		(1 << 22)   /* PCMCIA_A_RDY - input */
-#define GPIO_STORK_PCMCIA_B_RDY		(1 << 23)   /* PCMCIA_B_RDY - input */
-#define GPIO_STORK_SWITCH_EXTRA_IRQ	(1 << 24)   /* Extra IRQ from switch detect logic - input  */
-#define GPIO_STORK_SWITCH_IRQ		(1 << 25)   /* Sitch irq - input */
-#define GPIO_STORK_BATTERY_LOW_IRQ	(1 << 26)   /* BATTERY_LOW_IRQ - input */
-#define GPIO_STORK_TOUCH_SCREEN_PEN_IRQ	(1 << 27)   /* TOUCH_SCREEN_PEN_IRQ -input */
-
-#define IRQ_GPIO_STORK_PCMCIA_A_CARD_DETECT	IRQ_GPIO20   /* PCMCIA_A_CARD_DETECT - input */
-#define IRQ_GPIO_STORK_PCMCIA_B_CARD_DETECT	IRQ_GPIO21   /* PCMCIA_B_CARD_DETECT - input */
-
-#define IRQ_GPIO_STORK_SWITCH_1			IRQ_GPIO0    /* Switch 1 - input - active low */
-#define IRQ_GPIO_STORK_SWITCH_2			IRQ_GPIO1    /* Switch 2 - input - active low */
-#define IRQ_GPIO_STORK_SWITCH_EXTRA_IRQ		IRQ_GPIO24   /* Extra IRQ from switch detect logic - input - active low  */
-#define IRQ_GPIO_STORK_SWITCH_IRQ		IRQ_GPIO25   /* Switch irq - input- active low  */
-#define IRQ_GPIO_STORK_BATTERY_LOW_IRQ		IRQ_GPIO26   /* BATTERY_LOW_IRQ - input - active low */
-#define IRQ_GPIO_STORK_TOUCH_SCREEN_PEN_IRQ	IRQ_GPIO27   /* TOUCH_SCREEN_PEN_IRQ -input - goes low when it happens */
-
-/* this may be bogus - no it's not the RDY line becomes the IRQ line when we're up as an IO device */
-#define IRQ_GPIO_STORK_PCMCIA_A_RDY		IRQ_GPIO22   /* PCMCIA_A_RDY - input */
-#define IRQ_GPIO_STORK_PCMCIA_B_RDY		IRQ_GPIO23   /* PCMCIA_B_RDY - input */
-
-/* the default outputs, others are optional - I'll set these in the bootldr for now */
-#define GPIO_STORK_OUTPUT_BITS (GPIO_STORK_RS232_ON | GPIO_STORK_PSU_SYNC_MODE | GPIO_STORK_L3_MODE)
-
-#define STORK_LATCH_A_ADDR		0x08000000  /* cs1 A5 = 0 */
-#define STORK_LATCH_B_ADDR		0x08000020  /* cs1 A5 = 1 */
-
-#define STORK_LCDCPLD_BASE_ADDR		0x10000000  /* cs2 A5 = 0 */
-
-/* bit defs for latch A - these are write only and will need to be mirrored!  */
-
-#define STORK_TEMP_IC_POWER_ON		(1 << 0)
-#define STORK_SED1386_POWER_ON		(1 << 1)
-#define STORK_LCD_3V3_POWER_ON		(1 << 2)
-#define STORK_LCD_5V_POWER_ON		(1 << 3)
-#define STORK_LCD_BACKLIGHT_INVERTER_ON	(1 << 4)
-#define STORK_PCMCIA_PULL_UPS_POWER_ON	(1 << 5)
-#define STORK_PCMCIA_A_POWER_ON		(1 << 6)
-#define STORK_PCMCIA_B_POWER_ON		(1 << 7)
-#define STORK_AUDIO_POWER_ON		(1 << 8)
-#define STORK_AUDIO_AMP_ON		(1 << 9)
-#define STORK_BAR_CODE_POWER_ON		(1 << 10)
-#define STORK_BATTERY_CHARGER_ON	(1 << 11)
-#define STORK_SED1386_RESET		(1 << 12)
-#define STORK_IRDA_FREQUENCY_SELECT	(1 << 13)
-#define STORK_IRDA_MODE_0		(1 << 14)
-#define STORK_IRDA_MODE_1		(1 << 15)
-
-/* and for B */
-
-#define STORK_AUX_AD_SEL_0		(1 << 0)
-#define STORK_AUX_AD_SEL_1		(1 << 1)
-#define STORK_TOUCH_SCREEN_DCLK		(1 << 2)
-#define STORK_TOUCH_SCREEN_DIN		(1 << 3)
-#define STORK_TOUCH_SCREEN_CS		(1 << 4)
-#define STORK_DA_CS			(1 << 5)
-#define STORK_DA_LD			(1 << 6)
-#define STORK_RED_LED			(1 << 7)	/* active LOW */
-#define STORK_GREEN_LED			(1 << 8)	/* active LOW */
-#define STORK_YELLOW_LED		(1 << 9)	/* active LOW */
-#define STORK_PCMCIA_B_RESET		(1 << 10)
-#define STORK_PCMCIA_A_RESET		(1 << 11)
-#define STORK_AUDIO_CODEC_RESET		(1 << 12)
-#define STORK_CODEC_QMUTE		(1 << 13)
-#define STORK_AUDIO_CLOCK_SEL0		(1 << 14)
-#define STORK_AUDIO_CLOCK_SEL1		(1 << 15)
-
-
-/*
-
-    There are 8 control bits in the touch screen controller (AD7873)
-
-    S A2 A1 A0 MODE SER/DFR# PD1 PD0
-
-    S 		Start bit, always one.
-    A2 - A0	Channel select bits
-    MODE	0 => 12 bit resolution, 1 => 8 bit
-    SER/DFR#	Single ender/Differential Reference Select bit
-    PD1, PD0	Power management bits (usually 10)
-
-
-From Table 1.
-
-	A2-A0
-
-  	0 Temp0 (SER must be 1)
-	1 X+ (is this a typo? - is this X- really?)
-	2 VBAT,
-	3 read X+ (Z1),
-	4 read Y- (Z2), 5 => read Y+,
-
-*/
-
-#define AD7873_START		0x80		/* all commands need this to be set */
-#define AD7873_ADDR_BITS	4		/* ie shift by this */
-#define AD7873_8BITMODE		0x08		/* 0 => 12 bit convertions */
-#define AD7873_SER_DFR		0x04
-#define AD7873_PD1		0x02
-#define AD7873_PD0		0x01
-
-#define AD7873_TEMP0		AD7873_SER_DFR
-#define AD7873_X		(1 << AD7873_ADDR_BITS)
-#define AD7873_VBAT		((2 << AD7873_ADDR_BITS) | AD7873_SER_DFR)
-#define AD7873_X_Z1		(3 << AD7873_ADDR_BITS)
-#define AD7873_Y_Z2		(4 << AD7873_ADDR_BITS)
-#define AD7873_Y		(5 << AD7873_ADDR_BITS)
-#define AD7873_AUX		((6 << AD7873_ADDR_BITS) | AD7873_SER_DFR)
-#define AD7873_TEMP1		((7 << AD7873_ADDR_BITS) | AD7873_SER_DFR)
-
-#ifndef __ASSEMBLY__
-
-extern int storkSetLatchA(int bits);
-extern int storkClearLatchA(int bits);
-
-extern int storkSetLatchB(int bits);
-extern int storkClearLatchB(int bits);
-
-extern int storkSetLCDCPLD(int which, int bits);
-extern int storkClearLCDCPLD(int which, int bits);
-
-extern void storkSetGPIO(int bits);
-extern void storkClearGPIO(int bits);
-
-extern int storkGetGPIO(void);
-
-extern void storkClockShortToDtoA(int word);
-extern int storkClockByteToTS(int byte);
-
-
-/* this will return the current state of the hardware ANDED with the given bits
-   so NE => at least one bit was set, but maybe not all of them! */
-
-extern int storkTestGPIO(int bits);
-
-
-#endif
-
-#endif
diff -Nru a/include/asm-arm/arch-sa1100/system.h b/include/asm-arm/arch-sa1100/system.h
--- a/include/asm-arm/arch-sa1100/system.h	2004-12-24 13:37:30 -08:00
+++ b/include/asm-arm/arch-sa1100/system.h	2004-12-24 13:37:30 -08:00
@@ -10,13 +10,6 @@
 	cpu_do_idle();
 }
 
-#ifdef CONFIG_SA1100_VICTOR
-
-/* power off unconditionally */
-#define arch_reset(x) machine_power_off()
-
-#else
-
 static inline void arch_reset(char mode)
 {
 	if (mode == 's') {
@@ -27,5 +20,3 @@
 		RSRR = RSRR_SWR;
 	}
 }
-
-#endif
diff -Nru a/include/asm-arm/arch-sa1100/system3.h b/include/asm-arm/arch-sa1100/system3.h
--- a/include/asm-arm/arch-sa1100/system3.h	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,113 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/system3.h
- *
- * Copyright (C) 2001 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
- *
- * $Id: system3.h,v 1.2.4.2 2001/12/04 14:58:50 seletz Exp $
- *
- * 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.
- *
- * $Log: system3.h,v $
- * Revision 1.2.4.2  2001/12/04 14:58:50  seletz
- * - removed neponset hack
- * - removed irq definitions (now in irqs.h)
- *
- * Revision 1.2.4.1  2001/12/04 12:51:18  seletz
- * - re-added from linux_2_4_8_ac12_rmk1_np1_pt1
- *
- * Revision 1.2.2.2  2001/11/16 13:58:43  seletz
- * - simplified cpld register access
- *
- * Revision 1.2.2.1  2001/10/15 16:17:20  seletz
- * - first revision
- *
- *
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#error "include <asm/hardware.h> instead"
-#endif
-
-/* System 3 LCD */
-#define SYS3LCD			SKPEN0
-#define SYS3LCDBACKL	SKPEN1
-#define SYS3LCDBRIGHT	SKPWM0
-#define SYS3LCDCONTR	SKPWM1
-
-#define PT_CPLD_BASE		(0x10000000)
-#define PT_SMC_BASE			(0x18000000)
-#define PT_SA1111_BASE		(0x40000000)
-
-#define SA1111_BASE			PT_SA1111_BASE
-
-#define Ptcpld_p2v( x )	((x) - PT_CPLD_BASE + 0xf3000000)
-#define Ptcpld_v2p( x )	((x) - 0xf3000000 + PT_CPLD_BASE)
-
-#define _PT_SYSID	( PT_CPLD_BASE + 0x00 )
-#define _PT_IRQSR	( PT_CPLD_BASE + 0x24 )
-#define _PT_CTRL0	( PT_CPLD_BASE + 0x90 )
-#define _PT_CTRL1	( PT_CPLD_BASE + 0xA0 )
-#define _PT_CTRL2	( PT_CPLD_BASE + 0xB0 )
-
-#define PT_SYSID	(*((volatile u_char *)Ptcpld_p2v( _PT_SYSID )))
-#define PT_IRQSR	(*((volatile u_char *)Ptcpld_p2v( _PT_IRQSR )))
-#define PT_CTRL0	(*((volatile u_char *)Ptcpld_p2v( _PT_CTRL0 )))
-#define PT_CTRL1	(*((volatile u_char *)Ptcpld_p2v( _PT_CTRL1 )))
-#define PT_CTRL2	(*((volatile u_char *)Ptcpld_p2v( _PT_CTRL2 )))
-
-#define PTCTRL0_set( x )	PT_CTRL0 |= (x)
-#define PTCTRL1_set( x )	PT_CTRL1 |= (x)
-#define PTCTRL2_set( x )	PT_CTRL2 |= (x)
-#define PTCTRL0_clear( x )	PT_CTRL0 &= ~(x)
-#define PTCTRL1_clear( x )	PT_CTRL1 &= ~(x)
-#define PTCTRL2_clear( x )	PT_CTRL2 &= ~(x)
-
-/* System ID register */
-
-/* IRQ Source Register */
-#define PT_IRR_LAN		( 1<<0 )
-#define PT_IRR_X		( 1<<1 )
-#define PT_IRR_SA1111	( 1<<2 )
-#define PT_IRR_RS1		( 1<<3 )
-#define PT_IRR_RS1_RING	( 1<<4 )
-#define PT_IRR_RS1_DCD	( 1<<5 )
-#define PT_IRR_RS1_DSR	( 1<<6 )
-#define PT_IRR_RS2		( 1<<7 )
-
-/* FIXME */
-#define PT_IRR_USAR		( 1<<1 )
-
-/* CTRL 0 */
-#define PT_CTRL0_USBSLAVE	( 1<<0 )
-#define PT_CTRL0_USBHOST	( 1<<1 )
-#define PT_CTRL0_LCD_BL		( 1<<2 )
-#define PT_CTRL0_LAN_EN		( 1<<3 )	/* active low */
-#define PT_CTRL0_IRDA_M(x)	( (((u_char)x)&0x03)<<4 )
-#define PT_CTRL0_IRDA_M0	( 1<<4 )
-#define PT_CTRL0_IRDA_M1	( 1<<5 )
-#define PT_CTRL0_IRDA_FSEL	( 1<<6 )
-#define PT_CTRL0_LCD_EN		( 1<<7 )
-
-#define PT_CTRL0_INIT	( PT_CTRL0_USBSLAVE | PT_CTRL0_USBHOST | \
-						PT_CTRL0_LCD_BL | PT_CTRL0_LAN_EN | PT_CTRL0_LCD_EN )
-
-/* CTRL 1 */
-#define PT_CTRL1_RS3_MUX(x) ( (((u_char)x)&0x03)<<0 )
-#define PT_CTRL1_RS3_MUX0	( 1<<0 )
-#define PT_CTRL1_RS3_MUX1	( 1<<1 )
-#define PT_CTRL1_RS3_RST	( 1<<2 )
-#define PT_CTRL1_RS3_RS485_TERM	( 1<<4 )
-#define PT_CTRL1_X			( 1<<4 )
-#define PT_CTRL1_PCMCIA_A0VPP	( 1<<6 )
-#define PT_CTRL1_PCMCIA_A1VPP	( 1<<7 )
-
-#define PT_RS3_MUX_ALIRS	( 0 )
-#define PT_RS3_MUX_IDATA	( 1 )
-#define PT_RS3_MUX_RADIO	( 2 )
-#define PT_RS3_MUX_RS485	( 3 )
-
-/* CTRL 2 */
-#define PT_CTRL2_RS1_RTS	( 1<<0 )
-#define PT_CTRL2_RS1_DTR	( 1<<1 )
diff -Nru a/include/asm-arm/arch-sa1100/timex.h b/include/asm-arm/arch-sa1100/timex.h
--- a/include/asm-arm/arch-sa1100/timex.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-arm/arch-sa1100/timex.h	2004-12-24 13:37:00 -08:00
@@ -10,4 +10,3 @@
  * SA1100 timer
  */
 #define CLOCK_TICK_RATE		3686400
-#define CLOCK_TICK_FACTOR	80
diff -Nru a/include/asm-arm/arch-sa1100/trizeps.h b/include/asm-arm/arch-sa1100/trizeps.h
--- a/include/asm-arm/arch-sa1100/trizeps.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,22 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/trizeps.h
- *
- * This file contains the hardware specific definitions for Trizeps
- *
- * Authors:
- * Andreas Hofer <ho@dsa-ac.de>,
- * Peter Lueg <pl@dsa-ac.de>,
- * Guennadi Liakhovetski <gl@dsa-ac.de>
- *
- */
-
-#ifndef _ASM_ARCH_TRIZEPS_H_
-#define _ASM_ARCH_TRIZEPS_H_
-
-#include <linux/config.h>
-
-#ifdef CONFIG_TRIZEPS_MFTB2
-#include "mftb2.h"
-#endif
-
-#endif // _INCLUDE_TRIZEPS_
diff -Nru a/include/asm-arm/arch-sa1100/yopy.h b/include/asm-arm/arch-sa1100/yopy.h
--- a/include/asm-arm/arch-sa1100/yopy.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,127 +0,0 @@
-#ifndef __ASM_ARCH_YOPY_H__
-#define __ASM_ARCH_YOPY_H__
-
-/******************************************************************************
- * Memory mappings
- ******************************************************************************/
-
-/* Flash memories */
-#define YOPY_FLASH0_BASE_P	(0x00000000)	/* CS0 */
-#define YOPY_FLASH0_BASE_V	(0xe8000000)
-#define YOPY_FLASH0_BASE	YOPY_FLASH0_BASE_V
-#define YOPY_FLASH0_SIZE	(0x04000000)	/* map 64MB */
-
-#define YOPY_FLASH1_BASE_P	(0x08000000)	/* CS1 */
-#define YOPY_FLASH1_BASE_V	(YOPY_FLASH0_BASE_V + YOPY_FLASH0_SIZE)
-#define YOPY_FLASH1_BASE	YOPY_FLASH1_BASE_V
-#define YOPY_FLASH1_SIZE	(0x04000000)	/* map 64MB */
-
-/* LCD Controller */
-#define YOPY_LCD_IO_BASE_P	(0x48000000)	/* CS5 */
-#define YOPY_LCD_IO_BASE_V	(0xf0000000)
-
-#define YOPY_LCD_IO_BASE	YOPY_LCD_IO_BASE_V
-#define YOPY_LCD_IO_RANGE	(0x00208000)
-
-/* Extended GPIO */
-#define YOPY_EGPIO_BASE_P	(0x10000000)	/* CS2 */
-#define YOPY_EGPIO_BASE_V	(0xf1000000)
-
-#define YOPY_EGPIO_BASE		YOPY_EGPIO_BASE_V
-#define YOPY_EGPIO_RANGE	4
-
-#define YOPY_EGPIO		(*((volatile Word *)YOPY_EGPIO_BASE))
-
-
-/******************************************************************************
- * GPIO assignements
- ******************************************************************************/
-
-#define GPIO_UCB1200_IRQ	GPIO_GPIO0
-#define GPIO_UCB1200_RESET	GPIO_GPIO22
-
-#define GPIO_CF_IREQ		GPIO_GPIO2
-#define GPIO_CF_CD		GPIO_GPIO3
-#define GPIO_CF_BVD1		GPIO_GPIO4
-#define GPIO_CF_BVD2		GPIO_GPIO5
-#define GPIO_CF_CSEL		GPIO_GPIO6
-#define GPIO_CF_READY		GPIO_CF_IREQ
-#define GPIO_CF_STSCHG		GPIO_CF_BVD1
-#define GPIO_CF_SPKR		GPIO_CF_BVD2
-
-#define GPIO_MASK(io)		(1 << (io))
-
-#define GPIO_YOPY_PLL_ML	PPC_LDD7
-#define GPIO_YOPY_PLL_MC	PPC_L_LCLK
-#define GPIO_YOPY_PLL_MD	PPC_L_FCLK
-
-#define GPIO_YOPY_L3_MODE	PPC_LDD4
-#define GPIO_YOPY_L3_CLOCK	PPC_LDD5
-#define GPIO_YOPY_L3_DATA	PPC_LDD6
-
-#define GPIO_CF_RESET		0
-#define GPIO_CLKDIV_CLR1	1
-#define GPIO_CLKDIV_CLR2	2
-#define GPIO_SPEAKER_MUTE	5
-#define GPIO_CF_POWER		8
-#define GPIO_AUDIO_OPAMP_POWER	11
-#define GPIO_AUDIO_CODEC_POWER	12
-#define GPIO_AUDIO_POWER	13
-
-#define GPIO_IRDA_POWER		PPC_L_PCLK
-#define GPIO_IRDA_FIR		PPC_LDD0
-
-#ifndef __ASSEMBLY__
-extern int yopy_gpio_test(unsigned int gpio);
-extern void yopy_gpio_set(unsigned int gpio, int level);
-#endif
-
-
-/******************************************************************************
- * IRQ assignements
- ******************************************************************************/
-
-/* for our old drivers */
-#define IRQ_SP0_UDC	13
-#define IRQ_SP1_SDLC	14
-#define IRQ_SP1_UART	15
-#define IRQ_SP2_ICP	16
-#define IRQ_SP2_UART	16
-#define IRQ_SP3_UART	17
-#define IRQ_SP4_MCP	18
-#define IRQ_SP4_SSP	19
-#define IRQ_RTC_HZ	30
-#define IRQ_RTC_ALARM	31
-
-/* GPIO interrupts */
-#define IRQ_GPIO_UCB1200_IRQ	IRQ_GPIO0
-
-#define IRQ_CF_IREQ		IRQ_GPIO2
-#define IRQ_CF_CD		IRQ_GPIO3
-#define IRQ_CF_BVD1		IRQ_GPIO4
-#define IRQ_CF_BVD2		IRQ_GPIO5
-
-#define IRQ_UART_CTS		IRQ_GPIO7
-#define IRQ_UART_DCD		IRQ_GPIO8
-#define IRQ_UART_DSR		IRQ_GPIO9
-
-#define IRQ_FLASH_STATUS	IRQ_GPIO23
-
-#define IRQ_BUTTON_POWER	IRQ_GPIO1
-#define IRQ_BUTTON_UP		IRQ_GPIO14
-#define IRQ_BUTTON_DOWN		IRQ_GPIO15
-#define IRQ_BUTTON_LEFT		IRQ_GPIO16
-#define IRQ_BUTTON_RIGHT	IRQ_GPIO17
-#define IRQ_BUTTON_SHOT0	IRQ_GPIO18
-#define IRQ_BUTTON_SHOT1	IRQ_GPIO20
-#define IRQ_BUTTON_PIMS		IRQ_UCB1200_IO1
-#define IRQ_BUTTON_MP3		IRQ_UCB1200_IO2
-#define IRQ_BUTTON_RECORD	IRQ_UCB1200_IO3
-#define IRQ_BUTTON_PREV		IRQ_UCB1200_IO4
-#define IRQ_BUTTON_SELECT	IRQ_UCB1200_IO5
-#define IRQ_BUTTON_NEXT		IRQ_UCB1200_IO6
-#define IRQ_BUTTON_CANCEL	IRQ_UCB1200_IO7
-#define IRQ_BUTTON_REMOTE	IRQ_UCB1200_IO8
-
-
-#endif
diff -Nru a/include/asm-arm/arch-shark/io.h b/include/asm-arm/arch-shark/io.h
--- a/include/asm-arm/arch-shark/io.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-arm/arch-shark/io.h	2004-12-24 13:37:19 -08:00
@@ -170,7 +170,7 @@
 	addr;									\
 })
 
-#define __mem_pci(addr) addr
+#define __mem_pci(addr) (addr)
 
 #define inb(p)	 	(__builtin_constant_p((p)) ? __inbc(p)    : __inb(p))
 #define inw(p)	 	(__builtin_constant_p((p)) ? __inwc(p)    : __inw(p))
diff -Nru a/include/asm-arm/arch-shark/serial.h b/include/asm-arm/arch-shark/serial.h
--- a/include/asm-arm/arch-shark/serial.h	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,31 +0,0 @@
-/*
- * linux/include/asm-arm/arch-ebsa110/serial.h
- *
- * Copyright (c) 1996,1997,1998 Russell King.
- *
- * Changelog:
- *  15-10-1996	RMK	Created
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1843200 / 16)
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-	{ 0, BASE_BAUD, 0x3F8,  4, STD_COM_FLAGS },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0x2F8,  3, STD_COM_FLAGS },	/* ttyS1 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
-
diff -Nru a/include/asm-arm/arch-versatile/hardware.h b/include/asm-arm/arch-versatile/hardware.h
--- a/include/asm-arm/arch-versatile/hardware.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-arm/arch-versatile/hardware.h	2004-12-24 13:36:55 -08:00
@@ -1,7 +1,7 @@
 /*
  *  linux/include/asm-arm/arch-versatile/hardware.h
  *
- *  This file contains the hardware definitions of the Versatile PB board.
+ *  This file contains the hardware definitions of the Versatile boards.
  *
  *  Copyright (C) 2003 ARM Limited.
  *
diff -Nru a/include/asm-arm/arch-versatile/io.h b/include/asm-arm/arch-versatile/io.h
--- a/include/asm-arm/arch-versatile/io.h	2004-12-24 13:37:32 -08:00
+++ b/include/asm-arm/arch-versatile/io.h	2004-12-24 13:37:32 -08:00
@@ -22,8 +22,8 @@
 
 #define IO_SPACE_LIMIT 0xffff
 
-#define __io(a)			((a))
-#define __mem_pci(a)		((unsigned long)(a))
-#define __mem_isa(a)		((unsigned long)(a))
+#define __io(a)			((void __iomem *)(a))
+#define __mem_pci(a)		(a)
+#define __mem_isa(a)		(a)
 
 #endif
diff -Nru a/include/asm-arm/arch-versatile/platform.h b/include/asm-arm/arch-versatile/platform.h
--- a/include/asm-arm/arch-versatile/platform.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-arm/arch-versatile/platform.h	2004-12-24 13:37:01 -08:00
@@ -47,7 +47,7 @@
 
 
 /* ------------------------------------------------------------------------
- *  Versatile PB Registers
+ *  Versatile Registers
  * ------------------------------------------------------------------------
  * 
  */
@@ -55,10 +55,16 @@
 #define VERSATILE_SYS_SW_OFFSET               0x04
 #define VERSATILE_SYS_LED_OFFSET              0x08
 #define VERSATILE_SYS_OSC0_OFFSET             0x0C
+
+#if defined(CONFIG_ARCH_VERSATILE_PB)
 #define VERSATILE_SYS_OSC1_OFFSET             0x10
 #define VERSATILE_SYS_OSC2_OFFSET             0x14
 #define VERSATILE_SYS_OSC3_OFFSET             0x18
 #define VERSATILE_SYS_OSC4_OFFSET             0x1C
+#elif defined(CONFIG_MACH_VERSATILE_AB)
+#define VERSATILE_SYS_OSC1_OFFSET             0x1C
+#endif
+
 #define VERSATILE_SYS_LOCK_OFFSET             0x20
 #define VERSATILE_SYS_100HZ_OFFSET            0x24
 #define VERSATILE_SYS_CFGDATA1_OFFSET         0x28
@@ -90,9 +96,13 @@
 #define VERSATILE_SYS_LED                     (VERSATILE_SYS_BASE + VERSATILE_SYS_LED_OFFSET)
 #define VERSATILE_SYS_OSC0                    (VERSATILE_SYS_BASE + VERSATILE_SYS_OSC0_OFFSET)
 #define VERSATILE_SYS_OSC1                    (VERSATILE_SYS_BASE + VERSATILE_SYS_OSC1_OFFSET)
+
+#if defined(CONFIG_ARCH_VERSATILE_PB)
 #define VERSATILE_SYS_OSC2                    (VERSATILE_SYS_BASE + VERSATILE_SYS_OSC2_OFFSET)
 #define VERSATILE_SYS_OSC3                    (VERSATILE_SYS_BASE + VERSATILE_SYS_OSC3_OFFSET)
 #define VERSATILE_SYS_OSC4                    (VERSATILE_SYS_BASE + VERSATILE_SYS_OSC4_OFFSET)
+#endif
+
 #define VERSATILE_SYS_LOCK                    (VERSATILE_SYS_BASE + VERSATILE_SYS_LOCK_OFFSET)
 #define VERSATILE_SYS_100HZ                   (VERSATILE_SYS_BASE + VERSATILE_SYS_100HZ_OFFSET)
 #define VERSATILE_SYS_CFGDATA1                (VERSATILE_SYS_BASE + VERSATILE_SYS_CFGDATA1_OFFSET)
@@ -132,7 +142,7 @@
 
 
 /* ------------------------------------------------------------------------
- *  Versatile PB control registers
+ *  Versatile control registers
  * ------------------------------------------------------------------------
  */
 
@@ -213,6 +223,7 @@
 #define VERSATILE_SSP_BASE             0x101F4000	/* Synchronous Serial Port */
 
 #define VERSATILE_SSMC_BASE            0x20000000	/* SSMC */
+#define VERSATILE_IB2_BASE             0x24000000	/* IB2 module */
 #define VERSATILE_MBX_BASE             0x40000000	/* MBX */
 #define VERSATILE_PCI_BASE             0x41000000	/* PCI Interface */
 #define VERSATILE_SDRAM67_BASE         0x70000000	/* SDRAM banks 6 and 7 */
@@ -255,7 +266,7 @@
 
 
 /* ------------------------------------------------------------------------
- *  Versatile PB Interrupt Controller - control registers
+ *  Versatile Interrupt Controller - control registers
  * ------------------------------------------------------------------------
  * 
  *  Offsets from interrupt controller base 
@@ -482,6 +493,17 @@
 
 #define VERSATILE_CSR_BASE             0x10000000
 #define VERSATILE_CSR_SIZE             0x10000000
+
+#ifdef CONFIG_MACH_VERSATILE_AB
+/*
+ * IB2 Versatile/AB expansion board definitions
+ */
+#define VERSATILE_IB2_CAMERA_BANK	0x24000000
+#define VERSATILE_IB2_KBD_DATAREG	0x25000000
+#define VERSATILE_IB2_IER		0x26000000	/* for VICINTSOURCE27 */
+#define VERSATILE_IB2_CTRL		0x27000000
+#define VERSATILE_IB2_STAT		0x27000004
+#endif
 
 #endif
 
diff -Nru a/include/asm-arm/arch-versatile/serial.h b/include/asm-arm/arch-versatile/serial.h
--- a/include/asm-arm/arch-versatile/serial.h	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,37 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-versatile/serial.h
- *
- *  Copyright (C) 2003 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-/*
- * This assumes you have a 14.7456 MHz clock UART.
- */
-#define BASE_BAUD 115200
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-	{ 0, BASE_BAUD, 0, 0, ASYNC_SKIP_TEST },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0, 0, ASYNC_SKIP_TEST },	/* ttyS1 */     \
-	{ 0, BASE_BAUD, 0, 0, ASYNC_SKIP_TEST },	/* ttyS2 */	\
-	{ 0, BASE_BAUD, 0, 0, ASYNC_SKIP_TEST },	/* ttyS3 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
diff -Nru a/include/asm-arm/arch-versatile/timex.h b/include/asm-arm/arch-versatile/timex.h
--- a/include/asm-arm/arch-versatile/timex.h	2004-12-24 13:36:32 -08:00
+++ b/include/asm-arm/arch-versatile/timex.h	2004-12-24 13:36:32 -08:00
@@ -1,7 +1,7 @@
 /*
  *  linux/include/asm-arm/arch-versatile/timex.h
  *
- *  Versatile PB architecture timex specifications
+ *  Versatile architecture timex specifications
  *
  *  Copyright (C) 2003 ARM Limited
  *
diff -Nru a/include/asm-arm/atomic.h b/include/asm-arm/atomic.h
--- a/include/asm-arm/atomic.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/atomic.h	2004-12-24 13:36:18 -08:00
@@ -149,6 +149,8 @@
 
 #define atomic_inc_and_test(v)	(atomic_add_return(1, v) == 0)
 #define atomic_dec_and_test(v)	(atomic_sub_return(1, v) == 0)
+#define atomic_inc_return(v)    (atomic_add_return(1, v))
+#define atomic_dec_return(v)    (atomic_sub_return(1, v))
 
 #define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
 
diff -Nru a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
--- a/include/asm-arm/bitops.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-arm/bitops.h	2004-12-24 13:36:17 -08:00
@@ -342,7 +342,7 @@
  * the clz instruction for much better code efficiency.
  */
 
-extern __inline__ int generic_fls(int x);
+static __inline__ int generic_fls(int x);
 #define fls(x) \
 	( __builtin_constant_p(x) ? generic_fls(x) : \
 	  ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) )
diff -Nru a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h
--- a/include/asm-arm/cacheflush.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-arm/cacheflush.h	2004-12-24 13:37:19 -08:00
@@ -256,14 +256,14 @@
 
 static inline void flush_cache_mm(struct mm_struct *mm)
 {
-	if (current->active_mm == mm)
+	if (cpu_isset(smp_processor_id(), mm->cpu_vm_mask))
 		__cpuc_flush_user_all();
 }
 
 static inline void
 flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
 {
-	if (current->active_mm == vma->vm_mm)
+	if (cpu_isset(smp_processor_id(), vma->vm_mm->cpu_vm_mask))
 		__cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
 					vma->vm_flags);
 }
@@ -271,7 +271,7 @@
 static inline void
 flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr)
 {
-	if (current->active_mm == vma->vm_mm) {
+	if (cpu_isset(smp_processor_id(), vma->vm_mm->cpu_vm_mask)) {
 		unsigned long addr = user_addr & PAGE_MASK;
 		__cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
 	}
@@ -324,5 +324,64 @@
  * duplicate cache flushing elsewhere performed by flush_dcache_page().
  */
 #define flush_icache_page(vma,page)	do { } while (0)
+
+#define __cacheid_present(val)		(val != read_cpuid(CPUID_ID))
+#define __cacheid_vivt(val)		((val & (15 << 25)) != (14 << 25))
+#define __cacheid_vipt(val)		((val & (15 << 25)) == (14 << 25))
+#define __cacheid_vipt_nonaliasing(val)	((val & (15 << 25 | 1 << 23)) == (14 << 25))
+#define __cacheid_vipt_aliasing(val)	((val & (15 << 25 | 1 << 23)) == (14 << 25 | 1 << 23))
+
+#if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT)
+
+#define cache_is_vivt()			1
+#define cache_is_vipt()			0
+#define cache_is_vipt_nonaliasing()	0
+#define cache_is_vipt_aliasing()	0
+
+#elif defined(CONFIG_CPU_CACHE_VIPT)
+
+#define cache_is_vivt()			0
+#define cache_is_vipt()			1
+#define cache_is_vipt_nonaliasing()					\
+	({								\
+		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
+		__cacheid_vipt_nonaliasing(__val);			\
+	})
+
+#define cache_is_vipt_aliasing()					\
+	({								\
+		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
+		__cacheid_vipt_aliasing(__val);				\
+	})
+
+#else
+
+#define cache_is_vivt()							\
+	({								\
+		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
+		(!__cacheid_present(__val)) || __cacheid_vivt(__val);	\
+	})
+		
+#define cache_is_vipt()							\
+	({								\
+		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
+		__cacheid_present(__val) && __cacheid_vipt(__val);	\
+	})
+
+#define cache_is_vipt_nonaliasing()					\
+	({								\
+		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
+		__cacheid_present(__val) &&				\
+		 __cacheid_vipt_nonaliasing(__val);			\
+	})
+
+#define cache_is_vipt_aliasing()					\
+	({								\
+		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
+		__cacheid_present(__val) &&				\
+		 __cacheid_vipt_aliasing(__val);			\
+	})
+
+#endif
 
 #endif
diff -Nru a/include/asm-arm/delay.h b/include/asm-arm/delay.h
--- a/include/asm-arm/delay.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-arm/delay.h	2004-12-24 13:36:16 -08:00
@@ -1,15 +1,23 @@
-#ifndef __ASM_ARM_DELAY_H
-#define __ASM_ARM_DELAY_H
-
 /*
- * Copyright (C) 1995 Russell King
+ * Copyright (C) 1995-2004 Russell King
  *
  * Delay routines, using a pre-computed "loops_per_second" value.
  */
+#ifndef __ASM_ARM_DELAY_H
+#define __ASM_ARM_DELAY_H
 
 extern void __delay(int loops);
 
 /*
+ * This function intentionally does not exist; if you see references to
+ * it, it means that you're calling udelay() with an out of range value.
+ *
+ * With currently imposed limits, this means that we support a max delay
+ * of 2000us and 671 bogomips
+ */
+extern void __bad_udelay(void);
+
+/*
  * division by multiplication: you don't have to worry about
  * loss of precision.
  *
@@ -19,14 +27,16 @@
  * first constant multiplications gets optimized away if the delay is
  * a constant)
  */
-extern void udelay(unsigned long usecs);
+extern void __udelay(unsigned long usecs);
+extern void __const_udelay(unsigned long);
 
-static inline unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
-{
-	return a * b / c;
-}
+#define MAX_UDELAY_MS 2
 
-	
+#define udelay(n)						\
+	(__builtin_constant_p(n) ?				\
+	  ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() :	\
+			__const_udelay((n) * 0x68dbul)) :	\
+	  __udelay(n))
 
 #endif /* defined(_ARM_DELAY_H) */
 
diff -Nru a/include/asm-arm/ecard.h b/include/asm-arm/ecard.h
--- a/include/asm-arm/ecard.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-arm/ecard.h	2004-12-24 13:37:18 -08:00
@@ -143,6 +143,7 @@
 #define ecard_resource_end(ec,nr)	((ec)->resource[nr].end)
 #define ecard_resource_len(ec,nr)	((ec)->resource[nr].end - \
 					 (ec)->resource[nr].start + 1)
+#define ecard_resource_flags(ec,nr)	((ec)->resource[nr].flags)
 
 /*
  * This contains all the info needed on an expansion card
diff -Nru a/include/asm-arm/hardirq.h b/include/asm-arm/hardirq.h
--- a/include/asm-arm/hardirq.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-arm/hardirq.h	2004-12-24 13:37:00 -08:00
@@ -8,39 +8,16 @@
 
 typedef struct {
 	unsigned int __softirq_pending;
-	unsigned int __local_irq_count;
-	unsigned int __local_bh_count;
-	unsigned int __syscall_count;
-	struct task_struct * __ksoftirqd_task; /* waitqueue is too large */
 } ____cacheline_aligned irq_cpustat_t;
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter.  The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-24 are the hardirq count (max # of hardirqs: 512)
- * - bit 26 is the PREEMPT_ACTIVE flag
- *
- * We optimize HARDIRQ_BITS for immediate constant, and only
- * increase it if really needed.
- */
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
-
 #if NR_IRQS > 256
 #define HARDIRQ_BITS	9
 #else
 #define HARDIRQ_BITS	8
 #endif
 
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
-
 /*
  * The hardirq mask has to be large enough to have space
  * for potentially all IRQ sources in the system nesting
@@ -52,7 +29,6 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#ifndef CONFIG_SMP
 extern asmlinkage void __do_softirq(void);
 
 #define irq_exit()							\
@@ -62,6 +38,5 @@
 			__do_softirq();					\
 		preempt_enable_no_resched();				\
 	} while (0)
-#endif
 
 #endif /* __ASM_HARDIRQ_H */
diff -Nru a/include/asm-arm/hardware/amba_clcd.h b/include/asm-arm/hardware/amba_clcd.h
--- a/include/asm-arm/hardware/amba_clcd.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-arm/hardware/amba_clcd.h	2004-12-24 13:36:48 -08:00
@@ -22,7 +22,7 @@
 #define CLCD_UBAS 		0x00000010
 #define CLCD_LBAS 		0x00000014
 
-#ifndef CONFIG_ARCH_VERSATILE_PB
+#ifndef CONFIG_ARCH_VERSATILE
 #define CLCD_IENB 		0x00000018
 #define CLCD_CNTL 		0x0000001c
 #else
@@ -141,7 +141,7 @@
 	struct clcd_panel	*panel;
 	struct clcd_board	*board;
 	void			*board_data;
-	void			*regs;
+	void __iomem		*regs;
 	u32			clcd_cntl;
 	u32			cmap[16];
 };
diff -Nru a/include/asm-arm/hardware/icst307.h b/include/asm-arm/hardware/icst307.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/hardware/icst307.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,38 @@
+/*
+ *  linux/include/asm-arm/hardware/icst307.h
+ *
+ *  Copyright (C) 2003 Deep Blue Solutions, Ltd, 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 version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Support functions for calculating clocks/divisors for the ICS307
+ *  clock generators.  See http://www.icst.com/ for more information
+ *  on these devices.
+ *
+ *  This file is similar to the icst525.h file
+ */
+#ifndef ASMARM_HARDWARE_ICST307_H
+#define ASMARM_HARDWARE_ICST307_H
+
+struct icst307_params {
+	unsigned long	ref;
+	unsigned long	vco_max;	/* inclusive */
+	unsigned short	vd_min;		/* inclusive */
+	unsigned short	vd_max;		/* inclusive */
+	unsigned char	rd_min;		/* inclusive */
+	unsigned char	rd_max;		/* inclusive */
+};
+
+struct icst307_vco {
+	unsigned short	v;
+	unsigned char	r;
+	unsigned char	s;
+};
+
+unsigned long icst307_khz(const struct icst307_params *p, struct icst307_vco vco);
+struct icst307_vco icst307_khz_to_vco(const struct icst307_params *p, unsigned long freq);
+struct icst307_vco icst307_ps_to_vco(const struct icst307_params *p, unsigned long period);
+
+#endif
diff -Nru a/include/asm-arm/ide.h b/include/asm-arm/ide.h
--- a/include/asm-arm/ide.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-arm/ide.h	2004-12-24 13:36:48 -08:00
@@ -17,10 +17,6 @@
 #define MAX_HWIFS	4
 #endif
 
-#if defined(CONFIG_ARCH_SA1100)
-# include <asm/arch/ide.h>	/* obsolete + broken */
-#endif
-
 #if !defined(CONFIG_ARCH_L7200)
 # define IDE_ARCH_OBSOLETE_INIT
 # ifdef CONFIG_ARCH_CLPS7500
diff -Nru a/include/asm-arm/io.h b/include/asm-arm/io.h
--- a/include/asm-arm/io.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-arm/io.h	2004-12-24 13:36:47 -08:00
@@ -16,6 +16,7 @@
  *  04-Apr-1999	PJB	Added check_signature.
  *  12-Dec-1999	RMK	More cleanups
  *  18-Jun-2000 RMK	Removed virt_to_* and friends definitions
+ *  05-Oct-2004 BJD     Moved memory string functions to use void __iomem
  */
 #ifndef __ASM_ARM_IO_H
 #define __ASM_ARM_IO_H
@@ -38,21 +39,21 @@
  * Generic IO read/write.  These perform native-endian accesses.  Note
  * that some architectures will want to re-define __raw_{read,write}w.
  */
-extern void __raw_writesb(unsigned int addr, const void *data, int bytelen);
-extern void __raw_writesw(unsigned int addr, const void *data, int wordlen);
-extern void __raw_writesl(unsigned int addr, const void *data, int longlen);
-
-extern void __raw_readsb(unsigned int addr, void *data, int bytelen);
-extern void __raw_readsw(unsigned int addr, void *data, int wordlen);
-extern void __raw_readsl(unsigned int addr, void *data, int longlen);
-
-#define __raw_writeb(v,a)	(*(volatile unsigned char  *)(a) = (v))
-#define __raw_writew(v,a)	(*(volatile unsigned short *)(a) = (v))
-#define __raw_writel(v,a)	(*(volatile unsigned int   *)(a) = (v))
-
-#define __raw_readb(a)		(*(volatile unsigned char  *)(a))
-#define __raw_readw(a)		(*(volatile unsigned short *)(a))
-#define __raw_readl(a)		(*(volatile unsigned int   *)(a))
+extern void __raw_writesb(void __iomem *addr, const void *data, int bytelen);
+extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen);
+extern void __raw_writesl(void __iomem *addr, const void *data, int longlen);
+
+extern void __raw_readsb(void __iomem *addr, void *data, int bytelen);
+extern void __raw_readsw(void __iomem *addr, void *data, int wordlen);
+extern void __raw_readsl(void __iomem *addr, void *data, int longlen);
+
+#define __raw_writeb(v,a)	(*(volatile unsigned char __force  *)(a) = (v))
+#define __raw_writew(v,a)	(*(volatile unsigned short __force *)(a) = (v))
+#define __raw_writel(v,a)	(*(volatile unsigned int __force   *)(a) = (v))
+
+#define __raw_readb(a)		(*(volatile unsigned char __force  *)(a))
+#define __raw_readw(a)		(*(volatile unsigned short __force *)(a))
+#define __raw_readl(a)		(*(volatile unsigned int __force   *)(a))
 
 /*
  * Bad read/write accesses...
@@ -131,9 +132,11 @@
 /*
  * String version of IO memory access ops:
  */
-extern void _memcpy_fromio(void *, unsigned long, size_t);
-extern void _memcpy_toio(unsigned long, const void *, size_t);
-extern void _memset_io(unsigned long, int, size_t);
+extern void _memcpy_fromio(void *, void __iomem *, size_t);
+extern void _memcpy_toio(void __iomem *, const void *, size_t);
+extern void _memset_io(void __iomem *, int, size_t);
+
+#define mmiowb()
 
 /*
  *  Memory access primitives
@@ -153,17 +156,17 @@
 #define readw_relaxed(addr) readw(addr)
 #define readl_relaxed(addr) readl(addr)
 
-#define readsb(p,d,l)		__raw_readsb((unsigned int)__mem_pci(p),d,l)
-#define readsw(p,d,l)		__raw_readsw((unsigned int)__mem_pci(p),d,l)
-#define readsl(p,d,l)		__raw_readsl((unsigned int)__mem_pci(p),d,l)
+#define readsb(p,d,l)		__raw_readsb(__mem_pci(p),d,l)
+#define readsw(p,d,l)		__raw_readsw(__mem_pci(p),d,l)
+#define readsl(p,d,l)		__raw_readsl(__mem_pci(p),d,l)
 
 #define writeb(v,c)		__raw_writeb(v,__mem_pci(c))
 #define writew(v,c)		__raw_writew(cpu_to_le16(v),__mem_pci(c))
 #define writel(v,c)		__raw_writel(cpu_to_le32(v),__mem_pci(c))
 
-#define writesb(p,d,l)		__raw_writesb((unsigned int)__mem_pci(p),d,l)
-#define writesw(p,d,l)		__raw_writesw((unsigned int)__mem_pci(p),d,l)
-#define writesl(p,d,l)		__raw_writesl((unsigned int)__mem_pci(p),d,l)
+#define writesb(p,d,l)		__raw_writesb(__mem_pci(p),d,l)
+#define writesw(p,d,l)		__raw_writesw(__mem_pci(p),d,l)
+#define writesl(p,d,l)		__raw_writesl(__mem_pci(p),d,l)
 
 #define memset_io(c,v,l)	_memset_io(__mem_pci(c),(v),(l))
 #define memcpy_fromio(a,c,l)	_memcpy_fromio((a),__mem_pci(c),(l))
@@ -173,7 +176,7 @@
 				eth_copy_and_sum((s),__mem_pci(c),(l),(b))
 
 static inline int
-check_signature(unsigned long io_addr, const unsigned char *signature,
+check_signature(void __iomem *io_addr, const unsigned char *signature,
 		int length)
 {
 	int retval = 0;
@@ -223,23 +226,6 @@
 #define isa_eth_io_copy_and_sum(a,b,c,d) \
 				eth_copy_and_sum((a),__mem_isa(b),(c),(d))
 
-static inline int
-isa_check_signature(unsigned long io_addr, const unsigned char *signature,
-		    int length)
-{
-	int retval = 0;
-	do {
-		if (isa_readb(io_addr) != *signature)
-			goto out;
-		io_addr++;
-		signature++;
-		length--;
-	} while (length);
-	retval = 1;
-out:
-	return retval;
-}
-
 #else	/* __mem_isa */
 
 #define isa_readb(addr)			(__readwrite_bug("isa_readb"),0)
@@ -255,8 +241,6 @@
 #define isa_eth_io_copy_and_sum(a,b,c,d) \
 				__readwrite_bug("isa_eth_io_copy_and_sum")
 
-#define isa_check_signature(io,sig,len)	(0)
-
 #endif	/* __mem_isa */
 
 /*
@@ -265,8 +249,8 @@
  * ioremap takes a PCI memory address, as specified in
  * Documentation/IO-mapping.txt.
  */
-extern void * __ioremap(unsigned long, size_t, unsigned long, unsigned long);
-extern void __iounmap(void *addr);
+extern void __iomem * __ioremap(unsigned long, size_t, unsigned long, unsigned long);
+extern void __iounmap(void __iomem *addr);
 
 #ifndef __arch_ioremap
 #define ioremap(cookie,size)		__ioremap(cookie,size,0,1)
diff -Nru a/include/asm-arm/irq.h b/include/asm-arm/irq.h
--- a/include/asm-arm/irq.h	2004-12-24 13:37:34 -08:00
+++ b/include/asm-arm/irq.h	2004-12-24 13:37:34 -08:00
@@ -21,8 +21,7 @@
 
 struct irqaction;
 
-#define disable_irq_nosync(i) disable_irq(i)
-
+extern void disable_irq_nosync(unsigned int);
 extern void disable_irq(unsigned int);
 extern void enable_irq(unsigned int);
 
diff -Nru a/include/asm-arm/mach/arch.h b/include/asm-arm/mach/arch.h
--- a/include/asm-arm/mach/arch.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-arm/mach/arch.h	2004-12-24 13:37:19 -08:00
@@ -12,6 +12,7 @@
 
 struct tag;
 struct meminfo;
+struct sys_timer;
 
 struct machine_desc {
 	/*
@@ -39,7 +40,7 @@
 					 struct meminfo *);
 	void			(*map_io)(void);/* IO mapping function	*/
 	void			(*init_irq)(void);
-	void			(*init_time)(void);
+	struct sys_timer	*timer;		/* system tick timer	*/
 	void			(*init_machine)(void);
 };
 
@@ -81,9 +82,6 @@
 
 #define INITIRQ(_func)				\
 	.init_irq	= _func,
-
-#define INITTIME(_func)				\
-	.init_time	= _func,
 
 #define INIT_MACHINE(_func)			\
 	.init_machine	= _func,
diff -Nru a/include/asm-arm/mach/flash.h b/include/asm-arm/mach/flash.h
--- a/include/asm-arm/mach/flash.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-arm/mach/flash.h	2004-12-24 13:37:03 -08:00
@@ -2,18 +2,33 @@
  *  linux/include/asm-arm/mach/flash.h
  *
  *  Copyright (C) 2003 Russell King, 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 version 2 as
+ * published by the Free Software Foundation.
  */
 #ifndef ASMARM_MACH_FLASH_H
-#define ASMAMR_MACH_FLASH_H
+#define ASMARM_MACH_FLASH_H
 
 struct mtd_partition;
 
+/*
+ * map_name:	the map probe function name
+ * width:	width of mapped device
+ * init:	method called at driver/device initialisation
+ * exit:	method called at driver/device removal
+ * set_vpp:	method called to enable or disable VPP
+ * parts:	optional array of mtd_partitions for static partitioning
+ * nr_parts:	number of mtd_partitions for static partitoning
+ */
 struct flash_platform_data {
 	const char	*map_name;
-	int		width;
+	unsigned int	width;
 	int		(*init)(void);
 	void		(*exit)(void);
 	void		(*set_vpp)(int on);
+	struct mtd_partition *parts;
+	unsigned int	nr_parts;
 };
 
 #endif
diff -Nru a/include/asm-arm/mach/irda.h b/include/asm-arm/mach/irda.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/mach/irda.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,20 @@
+/*
+ *  linux/include/asm-arm/mach/irda.h
+ *
+ *  Copyright (C) 2004 Russell King.
+ *
+ * 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.
+ */
+#ifndef __ASM_ARM_MACH_IRDA_H
+#define __ASM_ARM_MACH_IRDA_H
+
+struct irda_platform_data {
+	int (*startup)(struct device *);
+	void (*shutdown)(struct device *);
+	int (*set_power)(struct device *, unsigned int state);
+	void (*set_speed)(struct device *, unsigned int speed);
+};
+
+#endif
diff -Nru a/include/asm-arm/mach/irq.h b/include/asm-arm/mach/irq.h
--- a/include/asm-arm/mach/irq.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-arm/mach/irq.h	2004-12-24 13:36:31 -08:00
@@ -97,23 +97,6 @@
 void set_irq_chip(unsigned int irq, struct irqchip *);
 void set_irq_flags(unsigned int irq, unsigned int flags);
 
-#ifdef not_yet
-/*
- * This is to be used by the top-level machine IRQ decoder only.
- */
-static inline void call_irq(struct pt_regs *regs, unsigned int irq)
-{
-	struct irqdesc *desc = irq_desc + irq;
-
-	spin_lock(&irq_controller_lock);
-	desc->handle(irq, desc, regs);
-	spin_unlock(&irq_controller_lock);
-
-	if (softirq_pending(smp_processor_id()))
-		do_softirq();
-}
-#endif
-
 #define IRQF_VALID	(1 << 0)
 #define IRQF_PROBE	(1 << 1)
 #define IRQF_NOAUTOEN	(1 << 2)
diff -Nru a/include/asm-arm/mach/map.h b/include/asm-arm/mach/map.h
--- a/include/asm-arm/mach/map.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-arm/mach/map.h	2004-12-24 13:37:01 -08:00
@@ -21,8 +21,10 @@
 #define MT_DEVICE	0
 #define MT_CACHECLEAN	1
 #define MT_MINICLEAN	2
-#define MT_VECTORS	3
-#define MT_MEMORY	4
+#define MT_LOW_VECTORS	3
+#define MT_HIGH_VECTORS	4
+#define MT_MEMORY	5
+#define MT_ROM		6
 
 extern void create_memmap_holes(struct meminfo *);
 extern void memtable_init(struct meminfo *);
diff -Nru a/include/asm-arm/mach/mmc.h b/include/asm-arm/mach/mmc.h
--- a/include/asm-arm/mach/mmc.h	2004-12-24 13:37:32 -08:00
+++ b/include/asm-arm/mach/mmc.h	2004-12-24 13:37:32 -08:00
@@ -7,7 +7,6 @@
 #include <linux/mmc/protocol.h>
 
 struct mmc_platform_data {
-	unsigned int mclk;			/* mmc base clock rate */
 	unsigned int ocr_mask;			/* available voltages */
 	u32 (*translate_vdd)(struct device *, unsigned int);
 	unsigned int (*status)(struct device *);
diff -Nru a/include/asm-arm/mach/time.h b/include/asm-arm/mach/time.h
--- a/include/asm-arm/mach/time.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-arm/mach/time.h	2004-12-24 13:36:49 -08:00
@@ -10,13 +10,44 @@
 #ifndef __ASM_ARM_MACH_TIME_H
 #define __ASM_ARM_MACH_TIME_H
 
-extern void (*init_arch_time)(void);
+#include <linux/sysdev.h>
 
-extern int (*set_rtc)(void);
-extern unsigned long (*gettimeoffset)(void);
+/*
+ * This is our kernel timer structure.
+ *
+ * - init
+ *   Initialise the kernels jiffy timer source, claim interrupt
+ *   using setup_irq.  This is called early on during initialisation
+ *   while interrupts are still disabled on the local CPU.
+ * - suspend
+ *   Suspend the kernel jiffy timer source, if necessary.  This
+ *   is called with interrupts disabled, after all normal devices
+ *   have been suspended.  If no action is required, set this to
+ *   NULL.
+ * - resume
+ *   Resume the kernel jiffy timer source, if necessary.  This
+ *   is called with interrupts disabled before any normal devices
+ *   are resumed.  If no action is required, set this to NULL.
+ * - offset
+ *   Return the timer offset in microseconds since the last timer
+ *   interrupt.  Note: this must take account of any unprocessed
+ *   timer interrupt which may be pending.
+ */
+struct sys_timer {
+	struct sys_device	dev;
+	void			(*init)(void);
+	void			(*suspend)(void);
+	void			(*resume)(void);
+	unsigned long		(*offset)(void);
+};
 
+extern struct sys_timer *system_timer;
 extern void timer_tick(struct pt_regs *);
 
+/*
+ * Kernel time keeping support.
+ */
+extern int (*set_rtc)(void);
 extern void save_time_delta(struct timespec *delta, struct timespec *rtc);
 extern void restore_time_delta(struct timespec *delta, struct timespec *rtc);
 
diff -Nru a/include/asm-arm/mmu_context.h b/include/asm-arm/mmu_context.h
--- a/include/asm-arm/mmu_context.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-arm/mmu_context.h	2004-12-24 13:36:48 -08:00
@@ -80,18 +80,17 @@
 switch_mm(struct mm_struct *prev, struct mm_struct *next,
 	  struct task_struct *tsk)
 {
+	unsigned int cpu = smp_processor_id();
+
 	if (prev != next) {
+		cpu_set(cpu, next->cpu_vm_mask);
 		check_context(next);
 		cpu_switch_mm(next->pgd, next);
+		cpu_clear(cpu, prev->cpu_vm_mask);
 	}
 }
 
 #define deactivate_mm(tsk,mm)	do { } while (0)
-
-static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
-{
-	check_context(next);
-	cpu_switch_mm(next->pgd, next);
-}
+#define activate_mm(prev,next)	switch_mm(prev, next, NULL)
 
 #endif
diff -Nru a/include/asm-arm/page.h b/include/asm-arm/page.h
--- a/include/asm-arm/page.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-arm/page.h	2004-12-24 13:36:19 -08:00
@@ -85,14 +85,10 @@
 #endif
 
 #ifdef CONFIG_CPU_COPY_V6
-# ifdef _USER
-#  define MULTI_USER 1
-# else
-#  define _USER v6
-# endif
+# define MULTI_USER 1
 #endif
 
-#ifndef _USER
+#if !defined(_USER) && !defined(MULTI_USER)
 #error Unknown user operations model
 #endif
 
diff -Nru a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
--- a/include/asm-arm/pgtable.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-arm/pgtable.h	2004-12-24 13:36:31 -08:00
@@ -412,7 +412,7 @@
  * into virtual address `from'
  */
 #define io_remap_page_range(vma,from,phys,size,prot) \
-		remap_page_range(vma,from,phys,size,prot)
+		remap_pfn_range(vma, from, (phys) >> PAGE_SHIFT, size, prot)
 
 #define pgtable_cache_init() do { } while (0)
 
diff -Nru a/include/asm-arm/posix_types.h b/include/asm-arm/posix_types.h
--- a/include/asm-arm/posix_types.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/posix_types.h	2004-12-24 13:36:18 -08:00
@@ -62,19 +62,19 @@
 
 #undef	__FD_SET
 #define __FD_SET(fd, fdsetp) \
-		(((fd_set *)fdsetp)->fds_bits[fd >> 5] |= (1<<(fd & 31)))
+		(((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1<<((fd) & 31)))
 
 #undef	__FD_CLR
 #define __FD_CLR(fd, fdsetp) \
-		(((fd_set *)fdsetp)->fds_bits[fd >> 5] &= ~(1<<(fd & 31)))
+		(((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1<<((fd) & 31)))
 
 #undef	__FD_ISSET
 #define __FD_ISSET(fd, fdsetp) \
-		((((fd_set *)fdsetp)->fds_bits[fd >> 5] & (1<<(fd & 31))) != 0)
+		((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1<<((fd) & 31))) != 0)
 
 #undef	__FD_ZERO
 #define __FD_ZERO(fdsetp) \
-		(memset (fdsetp, 0, sizeof (*(fd_set *)fdsetp)))
+		(memset (fdsetp, 0, sizeof (*(fd_set *)(fdsetp))))
 
 #endif
 
diff -Nru a/include/asm-arm/procinfo.h b/include/asm-arm/procinfo.h
--- a/include/asm-arm/procinfo.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-arm/procinfo.h	2004-12-24 13:36:19 -08:00
@@ -24,13 +24,13 @@
  *
  * NOTE! The following structure is defined by assembly
  * language, NOT C code.  For more information, check:
- *  arch/arm/mm/proc-*.S and arch/arm/kernel/head-armv.S
+ *  arch/arm/mm/proc-*.S and arch/arm/kernel/head.S
  */
 struct proc_info_list {
 	unsigned int		cpu_val;
 	unsigned int		cpu_mask;
-	unsigned long		__cpu_mmu_flags;	/* used by head-armv.S */
-	unsigned long		__cpu_flush;		/* used by head-armv.S */
+	unsigned long		__cpu_mmu_flags;	/* used by head.S */
+	unsigned long		__cpu_flush;		/* used by head.S */
 	const char		*arch_name;
 	const char		*elf_name;
 	unsigned int		elf_hwcap;
diff -Nru a/include/asm-arm/rtc.h b/include/asm-arm/rtc.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-arm/rtc.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,45 @@
+/*
+ *  linux/include/asm-arm/rtc.h
+ *
+ *  Copyright (C) 2003 Deep Blue Solutions Ltd.
+ *
+ * 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.
+ */
+#ifndef ASMARM_RTC_H
+#define ASMARM_RTC_H
+
+struct module;
+
+struct rtc_ops {
+	struct module	*owner;
+	int		(*open)(void);
+	void		(*release)(void);
+	int		(*ioctl)(unsigned int, unsigned long);
+
+	void		(*read_time)(struct rtc_time *);
+	int		(*set_time)(struct rtc_time *);
+	void		(*read_alarm)(struct rtc_wkalrm *);
+	int		(*set_alarm)(struct rtc_wkalrm *);
+	int		(*proc)(char *buf);
+};
+
+void rtc_time_to_tm(unsigned long, struct rtc_time *);
+int rtc_tm_to_time(struct rtc_time *, unsigned long *);
+void rtc_next_alarm_time(struct rtc_time *, struct rtc_time *, struct rtc_time *);
+void rtc_update(unsigned long, unsigned long);
+int register_rtc(struct rtc_ops *);
+void unregister_rtc(struct rtc_ops *);
+
+static inline int rtc_periodic_alarm(struct rtc_time *tm)
+{
+	return  (tm->tm_year == -1) ||
+		((unsigned)tm->tm_mon >= 12) ||
+		((unsigned)(tm->tm_mday - 1) >= 31) ||
+		((unsigned)tm->tm_hour > 23) ||
+		((unsigned)tm->tm_min > 59) ||
+		((unsigned)tm->tm_sec > 59);
+}
+
+#endif
diff -Nru a/include/asm-arm/serial.h b/include/asm-arm/serial.h
--- a/include/asm-arm/serial.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-arm/serial.h	2004-12-24 13:37:43 -08:00
@@ -14,10 +14,6 @@
 #ifndef __ASM_SERIAL_H
 #define __ASM_SERIAL_H
 
-#include <asm/arch/serial.h>
-
-#define SERIAL_PORT_DFNS		\
-	STD_SERIAL_PORT_DEFNS		\
-	EXTRA_SERIAL_PORT_DEFNS
+#define BASE_BAUD	(1843200 / 16)
 
 #endif
diff -Nru a/include/asm-arm/setup.h b/include/asm-arm/setup.h
--- a/include/asm-arm/setup.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-arm/setup.h	2004-12-24 13:36:49 -08:00
@@ -203,8 +203,6 @@
 	} bank[NR_BANKS];
 };
 
-extern struct meminfo meminfo;
-
 /*
  * Early command line parameters.
  */
diff -Nru a/include/asm-arm/system.h b/include/asm-arm/system.h
--- a/include/asm-arm/system.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm/system.h	2004-12-24 13:36:18 -08:00
@@ -57,44 +57,13 @@
 		__val;							\
 	})
 
-#define __cacheid_present(val)		(val != read_cpuid(CPUID_ID))
-#define __cacheid_vivt(val)		((val & (15 << 25)) != (14 << 25))
-#define __cacheid_vipt(val)		((val & (15 << 25)) == (14 << 25))
-#define __cacheid_vipt_nonaliasing(val)	((val & (15 << 25 | 1 << 23)) == (14 << 25))
-#define __cacheid_vipt_aliasing(val)	((val & (15 << 25 | 1 << 23)) == (14 << 25 | 1 << 23))
-
-#define cache_is_vivt()							\
-	({								\
-		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
-		(!__cacheid_present(__val)) || __cacheid_vivt(__val);	\
-	})
-		
-#define cache_is_vipt()							\
-	({								\
-		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
-		__cacheid_present(__val) && __cacheid_vipt(__val);	\
-	})
-
-#define cache_is_vipt_nonaliasing()					\
-	({								\
-		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
-		__cacheid_present(__val) &&				\
-		 __cacheid_vipt_nonaliasing(__val);			\
-	})
-
-#define cache_is_vipt_aliasing()					\
-	({								\
-		unsigned int __val = read_cpuid(CPUID_CACHETYPE);	\
-		__cacheid_present(__val) &&				\
-		 __cacheid_vipt_aliasing(__val);			\
-	})
-
 /*
  * This is used to ensure the compiler did actually allocate the register we
  * asked it for some inline assembly sequences.  Apparently we can't trust
  * the compiler from one version to another so a bit of paranoia won't hurt.
  * This string is meant to be concatenated with the inline asm string and
  * will cause compilation to stop on mismatch.
+ * (for details, see gcc PR 15089)
  */
 #define __asmeq(x, y)  ".ifnc " x "," y " ; .err ; .endif\n\t"
 
@@ -159,9 +128,9 @@
 extern unsigned int user_debug;
 
 #if __LINUX_ARM_ARCH__ >= 4
-#define vectors_base()	((cr_alignment & CR_V) ? 0xffff0000 : 0)
+#define vectors_high()	(cr_alignment & CR_V)
 #else
-#define vectors_base()	(0)
+#define vectors_high()	(0)
 #endif
 
 #define mb() __asm__ __volatile__ ("" : : : "memory")
@@ -282,7 +251,7 @@
 /*
  * Enable FIQs
  */
-#define __stf()							\
+#define local_fiq_enable()					\
 	({							\
 		unsigned long temp;				\
 	__asm__ __volatile__(					\
@@ -297,7 +266,7 @@
 /*
  * Disable FIQs
  */
-#define __clf()							\
+#define local_fiq_disable()					\
 	({							\
 		unsigned long temp;				\
 	__asm__ __volatile__(					\
@@ -331,6 +300,13 @@
 	: "r" (x)						\
 	: "memory", "cc")
 
+#define irqs_disabled()			\
+({					\
+	unsigned long flags;		\
+	local_save_flags(flags);	\
+	flags & PSR_I_BIT;		\
+})
+
 #ifdef CONFIG_SMP
 #error SMP not supported
 
@@ -345,16 +321,6 @@
 #define smp_rmb()		barrier()
 #define smp_wmb()		barrier()
 #define smp_read_barrier_depends()		do { } while(0)
-
-#define clf()			__clf()
-#define stf()			__stf()
-
-#define irqs_disabled()			\
-({					\
-	unsigned long flags;		\
-	local_save_flags(flags);	\
-	flags & PSR_I_BIT;		\
-})
 
 #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
 /*
diff -Nru a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
--- a/include/asm-arm/thread_info.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-arm/thread_info.h	2004-12-24 13:36:48 -08:00
@@ -76,6 +76,8 @@
 #define init_thread_info	(init_thread_union.thread_info)
 #define init_stack		(init_thread_union.stack)
 
+#define THREAD_SIZE		8192
+
 /*
  * how to get the thread information struct from C
  */
@@ -84,10 +86,8 @@
 static inline struct thread_info *current_thread_info(void)
 {
 	register unsigned long sp asm ("sp");
-	return (struct thread_info *)(sp & ~0x1fff);
+	return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
 }
-
-#define THREAD_SIZE		(8192)
 
 extern struct thread_info *alloc_thread_info(struct task_struct *task);
 extern void free_thread_info(struct thread_info *);
diff -Nru a/include/asm-arm/tlbflush.h b/include/asm-arm/tlbflush.h
--- a/include/asm-arm/tlbflush.h	2004-12-24 13:37:17 -08:00
+++ b/include/asm-arm/tlbflush.h	2004-12-24 13:37:17 -08:00
@@ -262,7 +262,7 @@
 	if (tlb_flag(TLB_WB))
 		asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
 
-	if (mm == current->active_mm) {
+	if (cpu_isset(smp_processor_id(), mm->cpu_vm_mask)) {
 		if (tlb_flag(TLB_V3_FULL))
 			asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (zero));
 		if (tlb_flag(TLB_V4_U_FULL))
@@ -292,7 +292,7 @@
 	if (tlb_flag(TLB_WB))
 		asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
 
-	if (vma->vm_mm == current->active_mm) {
+	if (cpu_isset(smp_processor_id(), vma->vm_mm->cpu_vm_mask)) {
 		if (tlb_flag(TLB_V3_PAGE))
 			asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (uaddr));
 		if (tlb_flag(TLB_V4_U_PAGE))
diff -Nru a/include/asm-arm/uaccess.h b/include/asm-arm/uaccess.h
--- a/include/asm-arm/uaccess.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-arm/uaccess.h	2004-12-24 13:37:00 -08:00
@@ -108,35 +108,35 @@
 extern int __get_user_8(void *);
 extern int __get_user_bad(void);
 
-#define __get_user_x(__r1,__p,__e,__s,__i...)				\
+#define __get_user_x(__r2,__p,__e,__s,__i...)				\
 	   __asm__ __volatile__ (					\
-		__asmeq("%0", "r0") __asmeq("%1", "r1")			\
+		__asmeq("%0", "r0") __asmeq("%1", "r2")			\
 		"bl	__get_user_" #__s				\
-		: "=&r" (__e), "=r" (__r1)				\
+		: "=&r" (__e), "=r" (__r2)				\
 		: "0" (__p)						\
 		: __i, "cc")
 
 #define get_user(x,p)							\
 	({								\
 		const register typeof(*(p)) __user *__p asm("r0") = (p);\
-		register typeof(*(p)) __r1 asm("r1");			\
+		register typeof(*(p)) __r2 asm("r2");			\
 		register int __e asm("r0");				\
 		switch (sizeof(*(__p))) {				\
 		case 1:							\
-			__get_user_x(__r1, __p, __e, 1, "lr");		\
+			__get_user_x(__r2, __p, __e, 1, "lr");		\
 	       		break;						\
 		case 2:							\
-			__get_user_x(__r1, __p, __e, 2, "r2", "lr");	\
+			__get_user_x(__r2, __p, __e, 2, "r3", "lr");	\
 			break;						\
 		case 4:							\
-	       		__get_user_x(__r1, __p, __e, 4, "lr");		\
+	       		__get_user_x(__r2, __p, __e, 4, "lr");		\
 			break;						\
 		case 8:							\
-			__get_user_x(__r1, __p, __e, 8, "lr");		\
+			__get_user_x(__r2, __p, __e, 8, "lr");		\
 	       		break;						\
 		default: __e = __get_user_bad(); break;			\
 		}							\
-		x = __r1;						\
+		x = __r2;						\
 		__e;							\
 	})
 
@@ -227,31 +227,31 @@
 extern int __put_user_8(void *, unsigned long long);
 extern int __put_user_bad(void);
 
-#define __put_user_x(__r1,__p,__e,__s)					\
+#define __put_user_x(__r2,__p,__e,__s)					\
 	   __asm__ __volatile__ (					\
-		__asmeq("%0", "r0") __asmeq("%2", "r1")			\
+		__asmeq("%0", "r0") __asmeq("%2", "r2")			\
 		"bl	__put_user_" #__s				\
 		: "=&r" (__e)						\
-		: "0" (__p), "r" (__r1)					\
+		: "0" (__p), "r" (__r2)					\
 		: "ip", "lr", "cc")
 
 #define put_user(x,p)							\
 	({								\
-		const register typeof(*(p)) __r1 asm("r1") = (x);	\
+		const register typeof(*(p)) __r2 asm("r2") = (x);	\
 		const register typeof(*(p)) __user *__p asm("r0") = (p);\
 		register int __e asm("r0");				\
 		switch (sizeof(*(__p))) {				\
 		case 1:							\
-			__put_user_x(__r1, __p, __e, 1);		\
+			__put_user_x(__r2, __p, __e, 1);		\
 			break;						\
 		case 2:							\
-			__put_user_x(__r1, __p, __e, 2);		\
+			__put_user_x(__r2, __p, __e, 2);		\
 			break;						\
 		case 4:							\
-			__put_user_x(__r1, __p, __e, 4);		\
+			__put_user_x(__r2, __p, __e, 4);		\
 			break;						\
 		case 8:							\
-			__put_user_x(__r1, __p, __e, 8);		\
+			__put_user_x(__r2, __p, __e, 8);		\
 			break;						\
 		default: __e = __put_user_bad(); break;			\
 		}							\
diff -Nru a/include/asm-arm26/atomic.h b/include/asm-arm26/atomic.h
--- a/include/asm-arm26/atomic.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-arm26/atomic.h	2004-12-24 13:36:48 -08:00
@@ -105,6 +105,27 @@
 	local_irq_restore(flags);
 }
 
+static inline int atomic_add_return(int i, volatile atomic_t *v)
+{
+	unsigned long flags;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter + i;
+	v->counter = val;
+	local_irq_restore(flags);
+
+	return val;
+}
+
+static inline int atomic_sub_return(int i, volatile atomic_t *v)
+{
+	return atomic_add_return(-i, v);
+}
+
+#define atomic_inc_return(v)  (atomic_add_return(1,v))
+#define atomic_dec_return(v)  (atomic_sub_return(1,v))
+
 /* Atomic operations are already serializing on ARM */
 #define smp_mb__before_atomic_dec()	barrier()
 #define smp_mb__after_atomic_dec()	barrier()
diff -Nru a/include/asm-arm26/hardirq.h b/include/asm-arm26/hardirq.h
--- a/include/asm-arm26/hardirq.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-arm26/hardirq.h	2004-12-24 13:36:47 -08:00
@@ -15,22 +15,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter.  The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- * - bit 26 is the PREEMPT_ACTIVE flag
- */
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have space
diff -Nru a/include/asm-arm26/io.h b/include/asm-arm26/io.h
--- a/include/asm-arm26/io.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-arm26/io.h	2004-12-24 13:37:00 -08:00
@@ -320,6 +320,8 @@
 #define writesw(p,d,l)                        __readwrite_bug("writesw")
 #define writesl(p,d,l)                        __readwrite_bug("writesl")
 
+#define mmiowb()
+
 /* the following macro is depreciated */
 #define ioaddr(port)                    __ioaddr((port))
 
diff -Nru a/include/asm-arm26/linux_logo.h b/include/asm-arm26/linux_logo.h
--- a/include/asm-arm26/linux_logo.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,19 +0,0 @@
-/*
- *  linux/include/asm-arm/linux_logo.h
- *
- *  Copyright (C) 1998 Russell King
- *
- * 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.
- *
- *  Linux console driver logo definitions for ARM
- */
-
-#include <linux/init.h>
-#include <linux/version.h>
-
-#define linux_logo_banner "ARM Linux version " UTS_RELEASE
-
-#include <linux/linux_logo.h>
-
diff -Nru a/include/asm-arm26/pgtable.h b/include/asm-arm26/pgtable.h
--- a/include/asm-arm26/pgtable.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-arm26/pgtable.h	2004-12-24 13:36:18 -08:00
@@ -288,7 +288,7 @@
  * into virtual address `from'
  */
 #define io_remap_page_range(vma,from,phys,size,prot) \
-		remap_page_range(vma,from,phys,size,prot)
+		remap_pfn_range(vma, from, (phys) >> PAGE_SHIFT, size, prot)
 
 #endif /* !__ASSEMBLY__ */
 
diff -Nru a/include/asm-cris/hardirq.h b/include/asm-cris/hardirq.h
--- a/include/asm-cris/hardirq.h	2004-12-24 13:36:34 -08:00
+++ b/include/asm-cris/hardirq.h	2004-12-24 13:36:34 -08:00
@@ -17,28 +17,7 @@
 
 #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have
diff -Nru a/include/asm-cris/io.h b/include/asm-cris/io.h
--- a/include/asm-cris/io.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-cris/io.h	2004-12-24 13:37:04 -08:00
@@ -56,6 +56,8 @@
 #define __raw_writew writew
 #define __raw_writel writel
 
+#define mmiowb()
+
 #define memset_io(a,b,c)	memset((void *)(a),(b),(c))
 #define memcpy_fromio(a,b,c)	memcpy((a),(void *)(b),(c))
 #define memcpy_toio(a,b,c)	memcpy((void *)(a),(b),(c))
diff -Nru a/include/asm-generic/dma-mapping-broken.h b/include/asm-generic/dma-mapping-broken.h
--- a/include/asm-generic/dma-mapping-broken.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-generic/dma-mapping-broken.h	2004-12-24 13:36:17 -08:00
@@ -9,7 +9,7 @@
 		   int flag)
 {
 	BUG();
-	return 0;
+	return NULL;
 }
 
 static inline void
diff -Nru a/include/asm-generic/errno.h b/include/asm-generic/errno.h
--- a/include/asm-generic/errno.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-generic/errno.h	2004-12-24 13:36:31 -08:00
@@ -96,5 +96,10 @@
 
 #define	ENOMEDIUM	123	/* No medium found */
 #define	EMEDIUMTYPE	124	/* Wrong medium type */
+#define	ECANCELED	125	/* Operation Canceled */
+#define	ENOKEY		126	/* Required key not available */
+#define	EKEYEXPIRED	127	/* Key has expired */
+#define	EKEYREVOKED	128	/* Key has been revoked */
+#define	EKEYREJECTED	129	/* Key was rejected by service */
 
 #endif
diff -Nru a/include/asm-generic/pci.h b/include/asm-generic/pci.h
--- a/include/asm-generic/pci.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-generic/pci.h	2004-12-24 13:36:49 -08:00
@@ -24,4 +24,11 @@
 
 #define pcibios_scan_all_fns(a, b)	0
 
+#ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
+static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
+{
+	return channel ? 15 : 14;
+}
+#endif /* HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ */
+
 #endif
diff -Nru a/include/asm-generic/topology.h b/include/asm-generic/topology.h
--- a/include/asm-generic/topology.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-generic/topology.h	2004-12-24 13:36:18 -08:00
@@ -45,9 +45,4 @@
 #define pcibus_to_cpumask(bus)	(cpu_online_map)
 #endif
 
-/* Cross-node load balancing interval. */
-#ifndef NODE_BALANCE_RATE
-#define NODE_BALANCE_RATE 10
-#endif
-
 #endif /* _ASM_GENERIC_TOPOLOGY_H */
diff -Nru a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
--- a/include/asm-generic/vmlinux.lds.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-generic/vmlinux.lds.h	2004-12-24 13:36:17 -08:00
@@ -18,12 +18,18 @@
 									\
 	/* PCI quirks */						\
 	.pci_fixup        : AT(ADDR(.pci_fixup) - LOAD_OFFSET) {	\
+		VMLINUX_SYMBOL(__start_pci_fixups_early) = .;		\
+		*(.pci_fixup_early)					\
+		VMLINUX_SYMBOL(__end_pci_fixups_early) = .;		\
 		VMLINUX_SYMBOL(__start_pci_fixups_header) = .;		\
 		*(.pci_fixup_header)					\
 		VMLINUX_SYMBOL(__end_pci_fixups_header) = .;		\
 		VMLINUX_SYMBOL(__start_pci_fixups_final) = .;		\
 		*(.pci_fixup_final)					\
 		VMLINUX_SYMBOL(__end_pci_fixups_final) = .;		\
+		VMLINUX_SYMBOL(__start_pci_fixups_enable) = .;		\
+		*(.pci_fixup_enable)					\
+		VMLINUX_SYMBOL(__end_pci_fixups_enable) = .;		\
 	}								\
 									\
 	/* Kernel symbol table: Normal symbols */			\
diff -Nru a/include/asm-h8300/bitops.h b/include/asm-h8300/bitops.h
--- a/include/asm-h8300/bitops.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-h8300/bitops.h	2004-12-24 13:36:47 -08:00
@@ -6,7 +6,6 @@
  * Copyright 2002, Yoshinori Sato
  */
 
-#include <linux/kernel.h>
 #include <linux/config.h>
 #include <linux/compiler.h>
 #include <asm/byteorder.h>	/* swab32 */
@@ -181,6 +180,8 @@
 #define find_first_zero_bit(addr, size) \
 	find_next_zero_bit((addr), (size), 0)
 
+#define ffs(x) generic_ffs(x)
+
 static __inline__ unsigned long __ffs(unsigned long word)
 {
 	unsigned long result;
@@ -195,9 +196,6 @@
 	return result;
 }
 
-#define ffs(x) generic_ffs(x)
-#define fls(x) generic_fls(x)
-
 static __inline__ int find_next_zero_bit (void * addr, int size, int offset)
 {
 	unsigned long *p = (unsigned long *)(((unsigned long)addr + (offset >> 3)) & ~3);
@@ -406,5 +404,7 @@
 #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
 
 #endif /* __KERNEL__ */
+
+#define fls(x) generic_fls(x)
 
 #endif /* _H8300_BITOPS_H */
diff -Nru a/include/asm-h8300/delay.h b/include/asm-h8300/delay.h
--- a/include/asm-h8300/delay.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-h8300/delay.h	2004-12-24 13:36:31 -08:00
@@ -11,11 +11,10 @@
 
 extern __inline__ void __delay(unsigned long loops)
 {
-	__asm__ __volatile__ ("mov.l %0,er0\n\t"
-			      "1:\n\t"
-			      "dec.l #1,er0\n\t"
+	__asm__ __volatile__ ("1:\n\t"
+			      "dec.l #1,%0\n\t"
 			      "bne 1b"
-			      ::"r" (loops):"er0");
+			      :"=r" (loops):"0"(loops));
 }
 
 /*
diff -Nru a/include/asm-h8300/hardirq.h b/include/asm-h8300/hardirq.h
--- a/include/asm-h8300/hardirq.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-h8300/hardirq.h	2004-12-24 13:36:55 -08:00
@@ -15,28 +15,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * HARDIRQ_MASK: 0x0000ff00
- * SOFTIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have
diff -Nru a/include/asm-h8300/io.h b/include/asm-h8300/io.h
--- a/include/asm-h8300/io.h	2004-12-24 13:36:59 -08:00
+++ b/include/asm-h8300/io.h	2004-12-24 13:36:59 -08:00
@@ -70,15 +70,24 @@
 }
 
 #define readb(addr) \
-    ({ unsigned char __v = (*(volatile unsigned char *) ((addr) & 0x00ffffff)); __v; })
+    ({ unsigned char __v = \
+     *(volatile unsigned char *)((unsigned long)(addr) & 0x00ffffff); \
+     __v; })
 #define readw(addr) \
-    ({ unsigned short __v = (*(volatile unsigned short *) ((addr) & 0x00ffffff)); __v; })
+    ({ unsigned short __v = \
+     *(volatile unsigned short *)((unsigned long)(addr) & 0x00ffffff); \
+     __v; })
 #define readl(addr) \
-    ({ unsigned int __v = (*(volatile unsigned int *) ((addr) & 0x00ffffff)); __v; })
-
-#define writeb(b,addr) (void)((*(volatile unsigned char *) ((addr) & 0x00ffffff)) = (b))
-#define writew(b,addr) (void)((*(volatile unsigned short *) ((addr) & 0x00ffffff)) = (b))
-#define writel(b,addr) (void)((*(volatile unsigned int *) ((addr) & 0x00ffffff)) = (b))
+    ({ unsigned long __v = \
+     *(volatile unsigned long *)((unsigned long)(addr) & 0x00ffffff); \
+     __v; })
+
+#define writeb(b,addr) (void)((*(volatile unsigned char *) \
+                             ((unsigned long)(addr) & 0x00ffffff)) = (b))
+#define writew(b,addr) (void)((*(volatile unsigned short *) \
+                             ((unsigned long)(addr) & 0x00ffffff)) = (b))
+#define writel(b,addr) (void)((*(volatile unsigned long *) \
+                             ((unsigned long)(addr) & 0x00ffffff)) = (b))
 #define readb_relaxed(addr) readb(addr)
 #define readw_relaxed(addr) readw(addr)
 #define readl_relaxed(addr) readl(addr)
@@ -199,6 +208,8 @@
 #define memset_io(a,b,c)	memset((void *)(a),(b),(c))
 #define memcpy_fromio(a,b,c)	memcpy((a),(void *)(b),(c))
 #define memcpy_toio(a,b,c)	memcpy((void *)(a),(b),(c))
+
+#define mmiowb()
 
 #define inb(addr)    ((h8300_buswidth(addr))?readw((addr) & ~1) & 0xff:readb(addr))
 #define inw(addr)    _swapw(readw(addr))
diff -Nru a/include/asm-h8300/linux_logo.h b/include/asm-h8300/linux_logo.h
--- a/include/asm-h8300/linux_logo.h	2004-12-24 13:36:59 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,11 +0,0 @@
-/*
- * include/asm-h8300/linux_logo.h: This is a linux logo
- *                                 to be displayed on boot.
- */
- 
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/version.h>
-
-#define linux_logo_banner "Linux/m68knommu version " UTS_RELEASE
-
diff -Nru a/include/asm-h8300/pgtable.h b/include/asm-h8300/pgtable.h
--- a/include/asm-h8300/pgtable.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-h8300/pgtable.h	2004-12-24 13:36:48 -08:00
@@ -50,7 +50,8 @@
  * No page table caches to initialise
  */
 #define pgtable_cache_init()   do { } while (0)
-#define io_remap_page_range	remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 /*
  * All 32bit addresses are effectively valid for vmalloc...
diff -Nru a/include/asm-h8300/sigcontext.h b/include/asm-h8300/sigcontext.h
--- a/include/asm-h8300/sigcontext.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-h8300/sigcontext.h	2004-12-24 13:36:31 -08:00
@@ -8,7 +8,9 @@
 	unsigned long  sc_er1;
 	unsigned long  sc_er2;
 	unsigned long  sc_er3;
+	unsigned long  sc_er4;
 	unsigned long  sc_er5;
+	unsigned long  sc_er6;
 	unsigned short sc_ccr;
 	unsigned long  sc_pc;
 };
diff -Nru a/include/asm-h8300/signal.h b/include/asm-h8300/signal.h
--- a/include/asm-h8300/signal.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-h8300/signal.h	2004-12-24 13:36:47 -08:00
@@ -96,6 +96,8 @@
 #define SA_ONESHOT	SA_RESETHAND
 #define SA_INTERRUPT	0x20000000 /* dummy -- ignored */
 
+#define SA_RESTORER	0x04000000
+
 /* 
  * sigaltstack controls
  */
diff -Nru a/include/asm-h8300/system.h b/include/asm-h8300/system.h
--- a/include/asm-h8300/system.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-h8300/system.h	2004-12-24 13:36:48 -08:00
@@ -2,7 +2,6 @@
 #define _H8300_SYSTEM_H
 
 #include <linux/config.h> /* get configuration macros */
-#include <linux/kernel.h>
 #include <linux/linkage.h>
 
 #define prepare_to_switch()	do { } while(0)
@@ -119,7 +118,7 @@
     __asm__ __volatile__
     ("mov.b %2,%0\n\t"
      "mov.b %1,%2"
-    : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "er0","memory");
+    : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
     break;
   case 2:
     __asm__ __volatile__
diff -Nru a/include/asm-h8300/timex.h b/include/asm-h8300/timex.h
--- a/include/asm-h8300/timex.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-h8300/timex.h	2004-12-24 13:36:49 -08:00
@@ -7,10 +7,6 @@
 #define _ASM_H8300_TIMEX_H
 
 #define CLOCK_TICK_RATE CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 typedef unsigned long cycles_t;
 extern short h8300_timer_count;
diff -Nru a/include/asm-h8300/ucontext.h b/include/asm-h8300/ucontext.h
--- a/include/asm-h8300/ucontext.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-h8300/ucontext.h	2004-12-24 13:36:55 -08:00
@@ -1,22 +1,11 @@
 #ifndef _H8300_UCONTEXT_H
 #define _H8300_UCONTEXT_H
 
-typedef int greg_t;
-#define NGREG 10
-typedef greg_t gregset_t[NGREG];
-
-struct mcontext {
-	int version;
-	gregset_t gregs;
-};
-
-#define MCONTEXT_VERSION 1
-
 struct ucontext {
 	unsigned long	  uc_flags;
 	struct ucontext  *uc_link;
 	stack_t		  uc_stack;
-	struct mcontext	  uc_mcontext;
+	struct sigcontext uc_mcontext;
 	sigset_t	  uc_sigmask;	/* mask last for extensibility */
 };
 
diff -Nru a/include/asm-h8300/unistd.h b/include/asm-h8300/unistd.h
--- a/include/asm-h8300/unistd.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-h8300/unistd.h	2004-12-24 13:36:49 -08:00
@@ -5,6 +5,7 @@
  * This file contains the system call numbers.
  */
 
+#define __NR_restart_syscall      0
 #define __NR_exit		  1
 #define __NR_fork		  2
 #define __NR_read		  3
diff -Nru a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h
--- a/include/asm-i386/acpi.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-i386/acpi.h	2004-12-24 13:37:19 -08:00
@@ -133,12 +133,13 @@
 #define FIX_ACPI_PAGES 4
 
 extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
-extern int (*platform_rename_gsi)(int ioapic, int gsi);
 
 #ifdef CONFIG_X86_IO_APIC
 extern int skip_ioapic_setup;
 extern int acpi_skip_timer_override;
 
+extern void check_acpi_pci(void);
+
 static inline void disable_ioapic_setup(void)
 {
 	skip_ioapic_setup = 1;
@@ -150,8 +151,8 @@
 }
 
 #else
-static inline void disable_ioapic_setup(void)
-{ }
+static inline void disable_ioapic_setup(void) { }
+static inline void check_acpi_pci(void) { }
 
 #endif
 
diff -Nru a/include/asm-i386/apic.h b/include/asm-i386/apic.h
--- a/include/asm-i386/apic.h	2004-12-24 13:37:30 -08:00
+++ b/include/asm-i386/apic.h	2004-12-24 13:37:30 -08:00
@@ -53,7 +53,8 @@
 
 static __inline__ void apic_wait_icr_idle(void)
 {
-	do { } while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY );
+	while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY )
+		cpu_relax();
 }
 
 int get_physical_broadcast(void);
@@ -88,6 +89,7 @@
 extern void connect_bsp_APIC (void);
 extern void disconnect_bsp_APIC (void);
 extern void disable_local_APIC (void);
+extern void lapic_shutdown (void);
 extern int verify_local_APIC (void);
 extern void cache_APIC_registers (void);
 extern void sync_Arb_IDs (void);
@@ -116,6 +118,9 @@
 #define NMI_LOCAL_APIC	2
 #define NMI_INVALID	3
 
-#endif /* CONFIG_X86_LOCAL_APIC */
+#else /* !CONFIG_X86_LOCAL_APIC */
+static inline void lapic_shutdown(void) { }
+
+#endif /* !CONFIG_X86_LOCAL_APIC */
 
 #endif /* __ASM_APIC_H */
diff -Nru a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h
--- a/include/asm-i386/atomic.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-i386/atomic.h	2004-12-24 13:36:31 -08:00
@@ -2,6 +2,8 @@
 #define __ARCH_I386_ATOMIC__
 
 #include <linux/config.h>
+#include <linux/compiler.h>
+#include <asm/processor.h>
 
 /*
  * Atomic operations that C can't guarantee us.  Useful for
@@ -175,6 +177,46 @@
 		:"ir" (i), "m" (v->counter) : "memory");
 	return c;
 }
+
+/**
+ * atomic_add_return - add and return
+ * @v: pointer of type atomic_t
+ * @i: integer value to add
+ *
+ * Atomically adds @i to @v and returns @i + @v
+ */
+static __inline__ int atomic_add_return(int i, atomic_t *v)
+{
+	int __i;
+#ifdef CONFIG_M386
+	if(unlikely(boot_cpu_data.x86==3))
+		goto no_xadd;
+#endif
+	/* Modern 486+ processor */
+	__i = i;
+	__asm__ __volatile__(
+		LOCK "xaddl %0, %1;"
+		:"=r"(i)
+		:"m"(v->counter), "0"(i));
+	return i + __i;
+
+#ifdef CONFIG_M386
+no_xadd: /* Legacy 386 processor */
+	local_irq_disable();
+	__i = atomic_read(v);
+	atomic_set(v, i + __i);
+	local_irq_enable();
+	return i + __i;
+#endif
+}
+
+static __inline__ int atomic_sub_return(int i, atomic_t *v)
+{
+	return atomic_add_return(-i,v);
+}
+
+#define atomic_inc_return(v)  (atomic_add_return(1,v))
+#define atomic_dec_return(v)  (atomic_sub_return(1,v))
 
 /* These are x86-specific, used by some header files */
 #define atomic_clear_mask(mask, addr) \
diff -Nru a/include/asm-i386/cpu.h b/include/asm-i386/cpu.h
--- a/include/asm-i386/cpu.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-i386/cpu.h	2004-12-24 13:37:01 -08:00
@@ -4,6 +4,7 @@
 #include <linux/device.h>
 #include <linux/cpu.h>
 #include <linux/topology.h>
+#include <linux/nodemask.h>
 
 #include <asm/node.h>
 
diff -Nru a/include/asm-i386/hardirq.h b/include/asm-i386/hardirq.h
--- a/include/asm-i386/hardirq.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-i386/hardirq.h	2004-12-24 13:37:04 -08:00
@@ -14,48 +14,6 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
-#define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
-
-/*
- * The hardirq mask has to be large enough to have
- * space for potentially all IRQ sources in the system
- * nesting on a single CPU:
- */
-#if (1 << HARDIRQ_BITS) < NR_IRQS
-# error HARDIRQ_BITS is too low!
-#endif
-
-#define nmi_enter()		(irq_enter())
-#define nmi_exit()		(preempt_count() -= HARDIRQ_OFFSET)
-
-#define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
-#define irq_exit()							\
-do {									\
-		preempt_count() -= IRQ_EXIT_OFFSET;			\
-		if (!in_interrupt() && softirq_pending(smp_processor_id())) \
-			do_softirq();					\
-		preempt_enable_no_resched();				\
-} while (0)
+void ack_bad_irq(unsigned int irq);
 
 #endif /* __ASM_HARDIRQ_H */
diff -Nru a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h
--- a/include/asm-i386/hpet.h	2004-12-24 13:36:56 -08:00
+++ b/include/asm-i386/hpet.h	2004-12-24 13:36:56 -08:00
@@ -96,6 +96,7 @@
 
 extern int hpet_rtc_timer_init(void);
 extern int hpet_enable(void);
+extern int hpet_reenable(void);
 extern int is_hpet_enabled(void);
 extern int is_hpet_capable(void);
 extern int hpet_readl(unsigned long a);
diff -Nru a/include/asm-i386/hw_irq.h b/include/asm-i386/hw_irq.h
--- a/include/asm-i386/hw_irq.h	2004-12-24 13:37:30 -08:00
+++ b/include/asm-i386/hw_irq.h	2004-12-24 13:37:30 -08:00
@@ -32,21 +32,19 @@
 extern void (*interrupt[NR_IRQS])(void);
 
 #ifdef CONFIG_SMP
-asmlinkage void reschedule_interrupt(void);
-asmlinkage void invalidate_interrupt(void);
-asmlinkage void call_function_interrupt(void);
+fastcall void reschedule_interrupt(void);
+fastcall void invalidate_interrupt(void);
+fastcall void call_function_interrupt(void);
 #endif
 
 #ifdef CONFIG_X86_LOCAL_APIC
-asmlinkage void apic_timer_interrupt(void);
-asmlinkage void error_interrupt(void);
-asmlinkage void spurious_interrupt(void);
-asmlinkage void thermal_interrupt(struct pt_regs);
+fastcall void apic_timer_interrupt(void);
+fastcall void error_interrupt(void);
+fastcall void spurious_interrupt(void);
+fastcall void thermal_interrupt(struct pt_regs *);
 #define platform_legacy_irq(irq)	((irq) < 16)
 #endif
 
-void mask_irq(unsigned int irq);
-void unmask_irq(unsigned int irq);
 void disable_8259A_irq(unsigned int irq);
 void enable_8259A_irq(unsigned int irq);
 int i8259A_irq_pending(unsigned int irq);
diff -Nru a/include/asm-i386/i387.h b/include/asm-i386/i387.h
--- a/include/asm-i386/i387.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-i386/i387.h	2004-12-24 13:37:04 -08:00
@@ -117,7 +117,5 @@
  */
 extern int dump_fpu( struct pt_regs *regs,
 		     struct user_i387_struct *fpu );
-extern int dump_extended_fpu( struct pt_regs *regs,
-			      struct user_fxsr_struct *fpu );
 
 #endif /* __ASM_I386_I387_H */
diff -Nru a/include/asm-i386/io.h b/include/asm-i386/io.h
--- a/include/asm-i386/io.h	2004-12-24 13:37:31 -08:00
+++ b/include/asm-i386/io.h	2004-12-24 13:37:31 -08:00
@@ -178,11 +178,13 @@
 #define __raw_writew writew
 #define __raw_writel writel
 
+#define mmiowb()
+
 static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
 {
 	memset((void __force *) addr, val, count);
 }
-static inline void memcpy_fromio(void *dst, volatile void __iomem *src, int count)
+static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
 {
 	__memcpy(dst, (void __force *) src, count);
 }
@@ -236,36 +238,6 @@
 	int retval = 0;
 	do {
 		if (readb(io_addr) != *signature)
-			goto out;
-		io_addr++;
-		signature++;
-		length--;
-	} while (length);
-	retval = 1;
-out:
-	return retval;
-}
-
-/**
- *	isa_check_signature		-	find BIOS signatures
- *	@io_addr: mmio address to check 
- *	@signature:  signature block
- *	@length: length of signature
- *
- *	Perform a signature comparison with the ISA mmio address io_addr.
- *	Returns 1 on a match.
- *
- *	This function is deprecated. New drivers should use ioremap and
- *	check_signature.
- */
- 
-
-static inline int isa_check_signature(unsigned long io_addr,
-	const unsigned char *signature, int length)
-{
-	int retval = 0;
-	do {
-		if (isa_readb(io_addr) != *signature)
 			goto out;
 		io_addr++;
 		signature++;
diff -Nru a/include/asm-i386/io_apic.h b/include/asm-i386/io_apic.h
--- a/include/asm-i386/io_apic.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-i386/io_apic.h	2004-12-24 13:37:01 -08:00
@@ -53,8 +53,6 @@
 #define end_edge_ioapic 	end_edge_ioapic_irq
 #endif
 
-#define APIC_MISMATCH_DEBUG
-
 #define IO_APIC_BASE(idx) \
 		((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
 		+ (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
@@ -195,7 +193,7 @@
  * If we use the IO-APIC for IRQ routing, disable automatic
  * assignment of PCI IRQ's.
  */
-#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup)
+#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
 
 #ifdef CONFIG_ACPI_BOOT
 extern int io_apic_get_unique_id (int ioapic, int apic_id);
@@ -203,6 +201,8 @@
 extern int io_apic_get_redir_entries (int ioapic);
 extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low);
 #endif /*CONFIG_ACPI_BOOT*/
+
+extern int (*ioapic_renumber_irq)(int ioapic, int irq);
 
 #else  /* !CONFIG_X86_IO_APIC */
 #define io_apic_assign_pci_irqs 0
diff -Nru a/include/asm-i386/irq.h b/include/asm-i386/irq.h
--- a/include/asm-i386/irq.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-i386/irq.h	2004-12-24 13:37:01 -08:00
@@ -21,38 +21,21 @@
 	return ((irq == 2) ? 9 : irq);
 }
 
-extern void disable_irq(unsigned int);
-extern void disable_irq_nosync(unsigned int);
-extern void enable_irq(unsigned int);
-extern void release_x86_irqs(struct task_struct *);
-extern int can_request_irq(unsigned int, unsigned long flags);
+extern void release_vm86_irqs(struct task_struct *);
 
 #ifdef CONFIG_X86_LOCAL_APIC
-#define ARCH_HAS_NMI_WATCHDOG		/* See include/linux/nmi.h */
+# define ARCH_HAS_NMI_WATCHDOG		/* See include/linux/nmi.h */
 #endif
 
 #ifdef CONFIG_4KSTACKS
-/*
- * per-CPU IRQ handling contexts (thread information and stack)
- */
-union irq_ctx {
-	struct thread_info      tinfo;
-	u32                     stack[THREAD_SIZE/sizeof(u32)];
-};
-
-extern union irq_ctx *hardirq_ctx[NR_CPUS];
-extern union irq_ctx *softirq_ctx[NR_CPUS];
-
-extern void irq_ctx_init(int cpu);
-
-#define __ARCH_HAS_DO_SOFTIRQ
+  extern void irq_ctx_init(int cpu);
+# define __ARCH_HAS_DO_SOFTIRQ
 #else
-#define irq_ctx_init(cpu) do { ; } while (0)
+# define irq_ctx_init(cpu) do { } while (0)
 #endif
 
-struct irqaction;
-struct pt_regs;
-asmlinkage int handle_IRQ_event(unsigned int, struct pt_regs *,
-				struct irqaction *);
+#ifdef CONFIG_IRQBALANCE
+extern int irqbalance_disable(char *str);
+#endif
 
 #endif /* _ASM_IRQ_H */
diff -Nru a/include/asm-i386/kprobes.h b/include/asm-i386/kprobes.h
--- a/include/asm-i386/kprobes.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-i386/kprobes.h	2004-12-24 13:37:00 -08:00
@@ -38,6 +38,13 @@
 	? (MAX_STACK_SIZE) \
 	: (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
 
+/* Architecture specific copy of original instruction*/
+struct arch_specific_insn {
+	/* copy of the original instruction */
+	kprobe_opcode_t insn[MAX_INSN_SIZE];
+};
+
+
 /* trap3/1 are intr gates for kprobes.  So, restore the status of IF,
  * if necessary, before executing the original int3/1 (trap) handler.
  */
diff -Nru a/include/asm-i386/mach-default/do_timer.h b/include/asm-i386/mach-default/do_timer.h
--- a/include/asm-i386/mach-default/do_timer.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-i386/mach-default/do_timer.h	2004-12-24 13:37:19 -08:00
@@ -16,6 +16,9 @@
 static inline void do_timer_interrupt_hook(struct pt_regs *regs)
 {
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 /*
  * In the SMP case we use the local APIC timer interrupt to do the
  * profiling, except when we simulate SMP mode on a uniprocessor
diff -Nru a/include/asm-i386/mach-summit/mach_mpparse.h b/include/asm-i386/mach-summit/mach_mpparse.h
--- a/include/asm-i386/mach-summit/mach_mpparse.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-i386/mach-summit/mach_mpparse.h	2004-12-24 13:36:48 -08:00
@@ -22,6 +22,7 @@
 {
 }
 
+extern int usb_early_handoff;
 static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 
 		char *productid)
 {
@@ -31,6 +32,7 @@
 			 || !strncmp(productid, "RUTHLESS SMP", 12))){
 		use_cyclone = 1; /*enable cyclone-timer*/
 		setup_summit();
+		usb_early_handoff = 1;
 		return 1;
 	}
 	return 0;
@@ -44,6 +46,7 @@
 	     || !strncmp(oem_table_id, "EXA", 3))){
 		use_cyclone = 1; /*enable cyclone-timer*/
 		setup_summit();
+		usb_early_handoff = 1;
 		return 1;
 	}
 	return 0;
diff -Nru a/include/asm-i386/mach-visws/do_timer.h b/include/asm-i386/mach-visws/do_timer.h
--- a/include/asm-i386/mach-visws/do_timer.h	2004-12-24 13:36:33 -08:00
+++ b/include/asm-i386/mach-visws/do_timer.h	2004-12-24 13:36:33 -08:00
@@ -9,6 +9,9 @@
 	co_cpu_write(CO_CPU_STAT,co_cpu_read(CO_CPU_STAT) & ~CO_STAT_TIMEINTR);
 
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 /*
  * In the SMP case we use the local APIC timer interrupt to do the
  * profiling, except when we simulate SMP mode on a uniprocessor
diff -Nru a/include/asm-i386/mach-voyager/do_timer.h b/include/asm-i386/mach-voyager/do_timer.h
--- a/include/asm-i386/mach-voyager/do_timer.h	2004-12-24 13:37:17 -08:00
+++ b/include/asm-i386/mach-voyager/do_timer.h	2004-12-24 13:37:17 -08:00
@@ -4,6 +4,9 @@
 static inline void do_timer_interrupt_hook(struct pt_regs *regs)
 {
 	do_timer(regs);
+#ifndef CONFIG_SMP
+	update_process_times(user_mode(regs));
+#endif
 
 	voyager_timer_interrupt(regs);
 }
diff -Nru a/include/asm-i386/module.h b/include/asm-i386/module.h
--- a/include/asm-i386/module.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-i386/module.h	2004-12-24 13:36:18 -08:00
@@ -40,6 +40,8 @@
 #define MODULE_PROC_FAMILY "ELAN "
 #elif defined CONFIG_MCRUSOE
 #define MODULE_PROC_FAMILY "CRUSOE "
+#elif defined CONFIG_MEFFICEON
+#define MODULE_PROC_FAMILY "EFFICEON "
 #elif defined CONFIG_MWINCHIPC6
 #define MODULE_PROC_FAMILY "WINCHIPC6 "
 #elif defined CONFIG_MWINCHIP2
diff -Nru a/include/asm-i386/mpspec.h b/include/asm-i386/mpspec.h
--- a/include/asm-i386/mpspec.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-i386/mpspec.h	2004-12-24 13:36:16 -08:00
@@ -33,7 +33,7 @@
 extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base);
 extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi);
 extern void mp_config_acpi_legacy_irqs (void);
-extern void mp_register_gsi (u32 gsi, int edge_level, int active_high_low);
+extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low);
 #endif /*CONFIG_ACPI_BOOT*/
 
 #define PHYSID_ARRAY_SIZE	BITS_TO_LONGS(MAX_APICS)
diff -Nru a/include/asm-i386/node.h b/include/asm-i386/node.h
--- a/include/asm-i386/node.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-i386/node.h	2004-12-24 13:36:31 -08:00
@@ -5,6 +5,7 @@
 #include <linux/mmzone.h>
 #include <linux/node.h>
 #include <linux/topology.h>
+#include <linux/nodemask.h>
 
 struct i386_node {
 	struct node node;
diff -Nru a/include/asm-i386/page.h b/include/asm-i386/page.h
--- a/include/asm-i386/page.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-i386/page.h	2004-12-24 13:36:19 -08:00
@@ -39,9 +39,9 @@
 /*
  * These are used to make use of C type-checking..
  */
+extern int nx_enabled;
 #ifdef CONFIG_X86_PAE
 extern unsigned long long __supported_pte_mask;
-extern int nx_enabled;
 typedef struct { unsigned long pte_low, pte_high; } pte_t;
 typedef struct { unsigned long long pmd; } pmd_t;
 typedef struct { unsigned long long pgd; } pgd_t;
@@ -49,7 +49,6 @@
 #define pte_val(x)	((x).pte_low | ((unsigned long long)(x).pte_high << 32))
 #define HPAGE_SHIFT	21
 #else
-#define nx_enabled 0
 typedef struct { unsigned long pte_low; } pte_t;
 typedef struct { unsigned long pmd; } pmd_t;
 typedef struct { unsigned long pgd; } pgd_t;
@@ -64,6 +63,7 @@
 #define HPAGE_SIZE	((1UL) << HPAGE_SHIFT)
 #define HPAGE_MASK	(~(HPAGE_SIZE - 1))
 #define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
+#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
 #endif
 
 
diff -Nru a/include/asm-i386/pci-direct.h b/include/asm-i386/pci-direct.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-i386/pci-direct.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1 @@
+#include "asm-x86_64/pci-direct.h"
diff -Nru a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
--- a/include/asm-i386/pgtable.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-i386/pgtable.h	2004-12-24 13:37:04 -08:00
@@ -404,7 +404,8 @@
 #define kern_addr_valid(addr)	(1)
 #endif /* !CONFIG_DISCONTIGMEM */
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
diff -Nru a/include/asm-i386/processor.h b/include/asm-i386/processor.h
--- a/include/asm-i386/processor.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-i386/processor.h	2004-12-24 13:36:17 -08:00
@@ -100,6 +100,7 @@
 
 extern void identify_cpu(struct cpuinfo_x86 *);
 extern void print_cpu_info(struct cpuinfo_x86 *);
+extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
 extern void dodgy_tsc(void);
 
 /*
@@ -656,5 +657,7 @@
 extern void select_idle_routine(const struct cpuinfo_x86 *c);
 
 #define cache_line_size() (boot_cpu_data.x86_cache_alignment)
+
+extern unsigned long boot_option_idle_override;
 
 #endif /* __ASM_I386_PROCESSOR_H */
diff -Nru a/include/asm-i386/semaphore.h b/include/asm-i386/semaphore.h
--- a/include/asm-i386/semaphore.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-i386/semaphore.h	2004-12-24 13:36:31 -08:00
@@ -87,15 +87,15 @@
 	sema_init(sem, 0);
 }
 
-asmlinkage void __down_failed(void /* special register calling convention */);
-asmlinkage int  __down_failed_interruptible(void  /* params in registers */);
-asmlinkage int  __down_failed_trylock(void  /* params in registers */);
-asmlinkage void __up_wakeup(void /* special register calling convention */);
-
-asmlinkage void __down(struct semaphore * sem);
-asmlinkage int  __down_interruptible(struct semaphore * sem);
-asmlinkage int  __down_trylock(struct semaphore * sem);
-asmlinkage void __up(struct semaphore * sem);
+fastcall void __down_failed(void /* special register calling convention */);
+fastcall int  __down_failed_interruptible(void  /* params in registers */);
+fastcall int  __down_failed_trylock(void  /* params in registers */);
+fastcall void __up_wakeup(void /* special register calling convention */);
+
+fastcall void __down(struct semaphore * sem);
+fastcall int  __down_interruptible(struct semaphore * sem);
+fastcall int  __down_trylock(struct semaphore * sem);
+fastcall void __up(struct semaphore * sem);
 
 /*
  * This is ugly, but we want the default case to fall through.
@@ -111,12 +111,13 @@
 		"js 2f\n"
 		"1:\n"
 		LOCK_SECTION_START("")
-		"2:\tcall __down_failed\n\t"
+		"2:\tlea %0,%%eax\n\t"
+		"call __down_failed\n\t"
 		"jmp 1b\n"
 		LOCK_SECTION_END
 		:"=m" (sem->count)
-		:"c" (sem)
-		:"memory");
+		:
+		:"memory","ax");
 }
 
 /*
@@ -135,11 +136,12 @@
 		"xorl %0,%0\n"
 		"1:\n"
 		LOCK_SECTION_START("")
-		"2:\tcall __down_failed_interruptible\n\t"
+		"2:\tlea %1,%%eax\n\t"
+		"call __down_failed_interruptible\n\t"
 		"jmp 1b\n"
 		LOCK_SECTION_END
 		:"=a" (result), "=m" (sem->count)
-		:"c" (sem)
+		:
 		:"memory");
 	return result;
 }
@@ -159,11 +161,12 @@
 		"xorl %0,%0\n"
 		"1:\n"
 		LOCK_SECTION_START("")
-		"2:\tcall __down_failed_trylock\n\t"
+		"2:\tlea %1,%%eax\n\t"
+		"call __down_failed_trylock\n\t"
 		"jmp 1b\n"
 		LOCK_SECTION_END
 		:"=a" (result), "=m" (sem->count)
-		:"c" (sem)
+		:
 		:"memory");
 	return result;
 }
@@ -182,13 +185,14 @@
 		"jle 2f\n"
 		"1:\n"
 		LOCK_SECTION_START("")
-		"2:\tcall __up_wakeup\n\t"
+		"2:\tlea %0,%%eax\n\t"
+		"call __up_wakeup\n\t"
 		"jmp 1b\n"
 		LOCK_SECTION_END
 		".subsection 0\n"
 		:"=m" (sem->count)
-		:"c" (sem)
-		:"memory");
+		:
+		:"memory","ax");
 }
 
 #endif
diff -Nru a/include/asm-i386/setup.h b/include/asm-i386/setup.h
--- a/include/asm-i386/setup.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-i386/setup.h	2004-12-24 13:37:01 -08:00
@@ -55,7 +55,7 @@
 #define KERNEL_START (*(unsigned long *) (PARAM+0x214))
 #define INITRD_START (*(unsigned long *) (PARAM+0x218))
 #define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
-#define EDID_INFO   (*(struct edid_info *) (PARAM+0x440))
+#define EDID_INFO   (*(struct edid_info *) (PARAM+0x140))
 #define EDD_NR     (*(unsigned char *) (PARAM+EDDNR))
 #define EDD_MBR_SIG_NR (*(unsigned char *) (PARAM+EDD_MBR_SIG_NR_BUF))
 #define EDD_MBR_SIGNATURE ((unsigned int *) (PARAM+EDD_MBR_SIG_BUF))
diff -Nru a/include/asm-i386/suspend.h b/include/asm-i386/suspend.h
--- a/include/asm-i386/suspend.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-i386/suspend.h	2004-12-24 13:37:18 -08:00
@@ -9,6 +9,9 @@
 static inline int
 arch_prepare_suspend(void)
 {
+	/* If you want to make non-PSE machine work, turn off paging
+           in do_magic. swsusp_pg_dir should have identity mapping, so
+           it could work...  */
 	if (!cpu_has_pse)
 		return -EPERM;
 	return 0;
diff -Nru a/include/asm-i386/system.h b/include/asm-i386/system.h
--- a/include/asm-i386/system.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-i386/system.h	2004-12-24 13:36:16 -08:00
@@ -321,7 +321,7 @@
  * If you use variable sized constraints like "m" or "g" in the 
  * replacement maake sure to pad to the worst case length.
  */
-#define alternative_input(oldinstr, newinstr, feature, input)			\
+#define alternative_input(oldinstr, newinstr, feature, input...)		\
 	asm volatile ("661:\n\t" oldinstr "\n662:\n"				\
 		      ".section .altinstructions,\"a\"\n"			\
 		      "  .align 4\n"						\
@@ -333,7 +333,7 @@
 		      ".previous\n"						\
 		      ".section .altinstr_replacement,\"ax\"\n"			\
 		      "663:\n\t" newinstr "\n664:\n"   /* replacement */ 	\
-		      ".previous" :: "i" (feature), input)  
+		      ".previous" :: "i" (feature), ##input)
 
 /*
  * Force strict CPU ordering.
diff -Nru a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
--- a/include/asm-i386/thread_info.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-i386/thread_info.h	2004-12-24 13:36:18 -08:00
@@ -10,6 +10,7 @@
 #ifdef __KERNEL__
 
 #include <linux/config.h>
+#include <linux/compiler.h>
 #include <asm/page.h>
 
 #ifndef __ASSEMBLY__
@@ -51,7 +52,7 @@
 
 #endif
 
-#define PREEMPT_ACTIVE		0x4000000
+#define PREEMPT_ACTIVE		0x10000000
 #ifdef CONFIG_4KSTACKS
 #define THREAD_SIZE            (4096)
 #else
@@ -92,12 +93,7 @@
 }
 
 /* how to get the current stack pointer from C */
-static inline unsigned long current_stack_pointer(void)
-{
-	unsigned long ti;
-	__asm__("movl %%esp,%0; ":"=r" (ti) : );
-	return ti;
-}
+register unsigned long current_stack_pointer asm("esp") __attribute_used__;
 
 /* thread information allocation */
 #ifdef CONFIG_DEBUG_STACK_USAGE
diff -Nru a/include/asm-i386/timer.h b/include/asm-i386/timer.h
--- a/include/asm-i386/timer.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-i386/timer.h	2004-12-24 13:36:31 -08:00
@@ -1,5 +1,6 @@
 #ifndef _ASMi386_TIMER_H
 #define _ASMi386_TIMER_H
+#include <linux/init.h>
 
 /**
  * struct timer_ops - used to define a timer source
@@ -15,18 +16,22 @@
  *                   timer.
  * @delay: delays this many clock cycles.
  */
-struct timer_opts{
+struct timer_opts {
 	char* name;
-	int (*init)(char *override);
 	void (*mark_offset)(void);
 	unsigned long (*get_offset)(void);
 	unsigned long long (*monotonic_clock)(void);
 	void (*delay)(unsigned long);
 };
 
+struct init_timer_opts {
+	int (*init)(char *override);
+	struct timer_opts *opts;
+};
+
 #define TICK_SIZE (tick_nsec / 1000)
 
-extern struct timer_opts* select_timer(void);
+extern struct timer_opts* __init select_timer(void);
 extern void clock_fallback(void);
 void setup_pit_timer(void);
 
@@ -40,19 +45,20 @@
 /* list of externed timers */
 extern struct timer_opts timer_none;
 extern struct timer_opts timer_pit;
-extern struct timer_opts timer_tsc;
+extern struct init_timer_opts timer_pit_init;
+extern struct init_timer_opts timer_tsc_init;
 #ifdef CONFIG_X86_CYCLONE_TIMER
-extern struct timer_opts timer_cyclone;
+extern struct init_timer_opts timer_cyclone_init;
 #endif
 
 extern unsigned long calibrate_tsc(void);
 extern void init_cpu_khz(void);
 #ifdef CONFIG_HPET_TIMER
-extern struct timer_opts timer_hpet;
+extern struct init_timer_opts timer_hpet_init;
 extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr);
 #endif
 
 #ifdef CONFIG_X86_PM_TIMER
-extern struct timer_opts timer_pmtmr;
+extern struct init_timer_opts timer_pmtmr_init;
 #endif
 #endif
diff -Nru a/include/asm-i386/timex.h b/include/asm-i386/timex.h
--- a/include/asm-i386/timex.h	2004-12-24 13:36:33 -08:00
+++ b/include/asm-i386/timex.h	2004-12-24 13:36:33 -08:00
@@ -15,10 +15,6 @@
 #  define CLOCK_TICK_RATE 1193182 /* Underlying HZ */
 #endif
 
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 /*
  * Standard way to access the cycle counter on i586+ CPUs.
diff -Nru a/include/asm-i386/topology.h b/include/asm-i386/topology.h
--- a/include/asm-i386/topology.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-i386/topology.h	2004-12-24 13:36:19 -08:00
@@ -69,8 +69,25 @@
 /* Node-to-Node distance */
 #define node_distance(from, to) ((from) != (to))
 
-/* Cross-node load balancing interval. */
-#define NODE_BALANCE_RATE 100
+/* sched_domains SD_NODE_INIT for NUMAQ machines */
+#define SD_NODE_INIT (struct sched_domain) {		\
+	.span			= CPU_MASK_NONE,	\
+	.parent			= NULL,			\
+	.groups			= NULL,			\
+	.min_interval		= 8,			\
+	.max_interval		= 32,			\
+	.busy_factor		= 32,			\
+	.imbalance_pct		= 125,			\
+	.cache_hot_time		= (10*1000),		\
+	.cache_nice_tries	= 1,			\
+	.per_cpu_gain		= 100,			\
+	.flags			= SD_LOAD_BALANCE	\
+				| SD_BALANCE_EXEC	\
+				| SD_WAKE_BALANCE,	\
+	.last_balance		= jiffies,		\
+	.balance_interval	= 1,			\
+	.nr_balance_failed	= 0,			\
+}
 
 #else /* !CONFIG_NUMA */
 /*
diff -Nru a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
--- a/include/asm-i386/unistd.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-i386/unistd.h	2004-12-24 13:37:01 -08:00
@@ -290,14 +290,20 @@
 #define __NR_mq_getsetattr	(__NR_mq_open+5)
 #define __NR_sys_kexec_load	283
 #define __NR_waitid		284
+/* #define __NR_sys_setaltroot	285 */
+#define __NR_add_key		286
+#define __NR_request_key	287
+#define __NR_keyctl		288
 
-#define NR_syscalls 285
-
-/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
+#define NR_syscalls 289
 
+/*
+ * user-visible error numbers are in the range -1 - -128: see
+ * <asm-i386/errno.h>
+ */
 #define __syscall_return(type, res) \
 do { \
-	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+	if ((unsigned long)(res) >= (unsigned long)(-(128 + 1))) { \
 		errno = -(res); \
 		res = -1; \
 	} \
diff -Nru a/include/asm-ia64/delay.h b/include/asm-ia64/delay.h
--- a/include/asm-ia64/delay.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-ia64/delay.h	2004-12-24 13:36:17 -08:00
@@ -91,7 +91,7 @@
 	unsigned long cycles = usecs*local_cpu_data->cyc_per_usec;
 
 	while (ia64_get_itc() - start < cycles)
-		/* skip */;
+		cpu_relax();
 }
 
 #endif /* _ASM_IA64_DELAY_H */
diff -Nru a/include/asm-ia64/hardirq.h b/include/asm-ia64/hardirq.h
--- a/include/asm-ia64/hardirq.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-ia64/hardirq.h	2004-12-24 13:36:31 -08:00
@@ -20,37 +20,9 @@
 #define __ARCH_IRQ_STAT	1
 
 #define softirq_pending(cpu)		(cpu_data(cpu)->softirq_pending)
-#define syscall_count(cpu)		/* unused on IA-64 */
-#define ksoftirqd_task(cpu)		(cpu_data(cpu)->ksoftirqd)
-#define nmi_count(cpu)			0
-
 #define local_softirq_pending()		(local_cpu_data->softirq_pending)
-#define local_syscall_count()		/* unused on IA-64 */
-#define local_ksoftirqd_task()		(local_cpu_data->ksoftirqd)
-#define local_nmi_count()		0
-
-/*
- * We put the hardirq and softirq counter into the preemption counter. The bitmask has the
- * following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-29 are the hardirq count (max # of hardirqs: 16384)
- *
- * - (bit 63 is the PREEMPT_ACTIVE flag---not currently implemented.)
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x3fff0000
- */
 
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	14
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have space for potentially all IRQ sources
diff -Nru a/include/asm-ia64/io.h b/include/asm-ia64/io.h
--- a/include/asm-ia64/io.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-ia64/io.h	2004-12-24 13:36:17 -08:00
@@ -32,7 +32,8 @@
  */
 #define IO_SPACE_LIMIT		0xffffffffffffffffUL
 
-#define MAX_IO_SPACES			16
+#define MAX_IO_SPACES_BITS		4
+#define MAX_IO_SPACES			(1UL << MAX_IO_SPACES_BITS)
 #define IO_SPACE_BITS			24
 #define IO_SPACE_SIZE			(1UL << IO_SPACE_BITS)
 
@@ -52,10 +53,24 @@
 
 # ifdef __KERNEL__
 
+/*
+ * All MMIO iomem cookies are in region 6; anything less is a PIO cookie:
+ *	0xCxxxxxxxxxxxxxxx	MMIO cookie (return from ioremap)
+ *	0x000000001SPPPPPP	PIO cookie (S=space number, P..P=port)
+ *
+ * ioread/writeX() uses the leading 1 in PIO cookies (PIO_OFFSET) to catch
+ * code that uses bare port numbers without the prerequisite pci_iomap().
+ */
+#define PIO_OFFSET		(1UL << (MAX_IO_SPACES_BITS + IO_SPACE_BITS))
+#define PIO_MASK		(PIO_OFFSET - 1)
+#define PIO_RESERVED		__IA64_UNCACHED_OFFSET
+#define HAVE_ARCH_PIO_SIZE
+
 #include <asm/intrinsics.h>
 #include <asm/machvec.h>
 #include <asm/page.h>
 #include <asm/system.h>
+#include <asm-generic/iomap.h>
 
 /*
  * Change virtual addresses to physical addresses and vv.
@@ -91,6 +106,20 @@
  */
 #define __ia64_mf_a()	ia64_mfa()
 
+/**
+ * ___ia64_mmiowb - I/O write barrier
+ *
+ * Ensure ordering of I/O space writes.  This will make sure that writes
+ * following the barrier will arrive after all previous writes.  For most
+ * ia64 platforms, this is a simple 'mf.a' instruction.
+ *
+ * See Documentation/DocBook/deviceiobook.tmpl for more information.
+ */
+static inline void ___ia64_mmiowb(void)
+{
+	ia64_mfa();
+}
+
 static inline const unsigned long
 __ia64_get_io_port_base (void)
 {
@@ -133,6 +162,7 @@
 #define __ia64_writew	___ia64_writew
 #define __ia64_writel	___ia64_writel
 #define __ia64_writeq	___ia64_writeq
+#define __ia64_mmiowb	___ia64_mmiowb
 
 /*
  * For the in/out routines, we need to do "mf.a" _after_ doing the I/O access to ensure
@@ -267,6 +297,7 @@
 #define __outb		platform_outb
 #define __outw		platform_outw
 #define __outl		platform_outl
+#define __mmiowb	platform_mmiowb
 
 #define inb(p)		__inb(p)
 #define inw(p)		__inw(p)
@@ -280,6 +311,7 @@
 #define outsb(p,s,c)	__outsb(p,s,c)
 #define outsw(p,s,c)	__outsw(p,s,c)
 #define outsl(p,s,c)	__outsl(p,s,c)
+#define mmiowb()	__mmiowb()
 
 /*
  * The address passed to these functions are ioremap()ped already.
diff -Nru a/include/asm-ia64/machvec.h b/include/asm-ia64/machvec.h
--- a/include/asm-ia64/machvec.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-ia64/machvec.h	2004-12-24 13:36:55 -08:00
@@ -62,14 +62,15 @@
 typedef void ia64_mv_outb_t (unsigned char, unsigned long);
 typedef void ia64_mv_outw_t (unsigned short, unsigned long);
 typedef void ia64_mv_outl_t (unsigned int, unsigned long);
-typedef unsigned char ia64_mv_readb_t (void *);
-typedef unsigned short ia64_mv_readw_t (void *);
-typedef unsigned int ia64_mv_readl_t (void *);
-typedef unsigned long ia64_mv_readq_t (void *);
-typedef unsigned char ia64_mv_readb_relaxed_t (void *);
-typedef unsigned short ia64_mv_readw_relaxed_t (void *);
-typedef unsigned int ia64_mv_readl_relaxed_t (void *);
-typedef unsigned long ia64_mv_readq_relaxed_t (void *);
+typedef void ia64_mv_mmiowb_t (void);
+typedef unsigned char ia64_mv_readb_t (const volatile void __iomem *);
+typedef unsigned short ia64_mv_readw_t (const volatile void __iomem *);
+typedef unsigned int ia64_mv_readl_t (const volatile void __iomem *);
+typedef unsigned long ia64_mv_readq_t (const volatile void __iomem *);
+typedef unsigned char ia64_mv_readb_relaxed_t (const volatile void __iomem *);
+typedef unsigned short ia64_mv_readw_relaxed_t (const volatile void __iomem *);
+typedef unsigned int ia64_mv_readl_relaxed_t (const volatile void __iomem *);
+typedef unsigned long ia64_mv_readq_relaxed_t (const volatile void __iomem *);
 
 static inline void
 machvec_noop (void)
@@ -130,6 +131,7 @@
 #  define platform_outb		ia64_mv.outb
 #  define platform_outw		ia64_mv.outw
 #  define platform_outl		ia64_mv.outl
+#  define platform_mmiowb	ia64_mv.mmiowb
 #  define platform_readb        ia64_mv.readb
 #  define platform_readw        ia64_mv.readw
 #  define platform_readl        ia64_mv.readl
@@ -176,6 +178,7 @@
 	ia64_mv_outb_t *outb;
 	ia64_mv_outw_t *outw;
 	ia64_mv_outl_t *outl;
+	ia64_mv_mmiowb_t *mmiowb;
 	ia64_mv_readb_t *readb;
 	ia64_mv_readw_t *readw;
 	ia64_mv_readl_t *readl;
@@ -218,6 +221,7 @@
 	platform_outb,				\
 	platform_outw,				\
 	platform_outl,				\
+	platform_mmiowb,			\
 	platform_readb,				\
 	platform_readw,				\
 	platform_readl,				\
@@ -343,6 +347,9 @@
 #endif
 #ifndef platform_outl
 # define platform_outl		__ia64_outl
+#endif
+#ifndef platform_mmiowb
+# define platform_mmiowb	__ia64_mmiowb
 #endif
 #ifndef platform_readb
 # define platform_readb		__ia64_readb
diff -Nru a/include/asm-ia64/machvec_init.h b/include/asm-ia64/machvec_init.h
--- a/include/asm-ia64/machvec_init.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-ia64/machvec_init.h	2004-12-24 13:37:43 -08:00
@@ -12,6 +12,7 @@
 extern ia64_mv_outb_t __ia64_outb;
 extern ia64_mv_outw_t __ia64_outw;
 extern ia64_mv_outl_t __ia64_outl;
+extern ia64_mv_mmiowb_t __ia64_mmiowb;
 extern ia64_mv_readb_t __ia64_readb;
 extern ia64_mv_readw_t __ia64_readw;
 extern ia64_mv_readl_t __ia64_readl;
diff -Nru a/include/asm-ia64/machvec_sn2.h b/include/asm-ia64/machvec_sn2.h
--- a/include/asm-ia64/machvec_sn2.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-ia64/machvec_sn2.h	2004-12-24 13:36:47 -08:00
@@ -49,6 +49,7 @@
 extern ia64_mv_outb_t __sn_outb;
 extern ia64_mv_outw_t __sn_outw;
 extern ia64_mv_outl_t __sn_outl;
+extern ia64_mv_mmiowb_t __sn_mmiowb;
 extern ia64_mv_readb_t __sn_readb;
 extern ia64_mv_readw_t __sn_readw;
 extern ia64_mv_readl_t __sn_readl;
@@ -92,6 +93,7 @@
 #define platform_outb			__sn_outb
 #define platform_outw			__sn_outw
 #define platform_outl			__sn_outl
+#define platform_mmiowb			__sn_mmiowb
 #define platform_readb			__sn_readb
 #define platform_readw			__sn_readw
 #define platform_readl			__sn_readl
@@ -117,6 +119,6 @@
 #define platform_dma_mapping_error		sn_dma_mapping_error
 #define platform_dma_supported		sn_dma_supported
 
-#include <asm/sn/sn2/io.h>
+#include <asm/sn/io.h>
 
 #endif /* _ASM_IA64_MACHVEC_SN2_H */
diff -Nru a/include/asm-ia64/pal.h b/include/asm-ia64/pal.h
--- a/include/asm-ia64/pal.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-ia64/pal.h	2004-12-24 13:37:01 -08:00
@@ -1531,7 +1531,7 @@
 ia64_pal_tr_read (u64 reg_num, u64 tr_type, u64 *tr_buffer, pal_tr_valid_u_t *tr_valid)
 {
 	struct ia64_pal_retval iprv;
-	PAL_CALL_PHYS_STK(iprv, PAL_VM_TR_READ, reg_num, tr_type,(u64)__pa(tr_buffer));
+	PAL_CALL_PHYS_STK(iprv, PAL_VM_TR_READ, reg_num, tr_type,(u64)ia64_tpa(tr_buffer));
 	if (tr_valid)
 		tr_valid->piv_val = iprv.v0;
 	return iprv.status;
diff -Nru a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
--- a/include/asm-ia64/pci.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-ia64/pci.h	2004-12-24 13:37:19 -08:00
@@ -105,6 +105,8 @@
 #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
 #define pci_domain_nr(busdev)    (PCI_CONTROLLER(busdev)->segment)
 
+extern struct pci_ops pci_root_ops;
+
 static inline int pci_name_bus(char *name, struct pci_bus *bus)
 {
 	if (pci_domain_nr(bus) == 0) {
@@ -119,7 +121,12 @@
 {
 }
 
-/* generic pci stuff */
-#include <asm-generic/pci.h>
+extern void pcibios_resource_to_bus(struct pci_dev *dev,
+		struct pci_bus_region *region, struct resource *res);
+
+extern void pcibios_bus_to_resource(struct pci_dev *dev,
+		struct resource *res, struct pci_bus_region *region);
+
+#define pcibios_scan_all_fns(a, b)	0
 
 #endif /* _ASM_IA64_PCI_H */
diff -Nru a/include/asm-ia64/pgtable.h b/include/asm-ia64/pgtable.h
--- a/include/asm-ia64/pgtable.h	2004-12-24 13:36:32 -08:00
+++ b/include/asm-ia64/pgtable.h	2004-12-24 13:36:32 -08:00
@@ -6,7 +6,7 @@
  * the IA-64 page table tree.
  *
  * This hopefully works with any (fixed) IA-64 page-size, as defined
- * in <asm/page.h> (currently 8192).
+ * in <asm/page.h>.
  *
  * Copyright (C) 1998-2004 Hewlett-Packard Co
  *	David Mosberger-Tang <davidm@hpl.hp.com>
@@ -309,15 +309,15 @@
 }
 
 /* The offset in the 1-level directory is given by the 3 region bits
-   (61..63) and the seven level-1 bits (33-39).  */
+   (61..63) and the level-1 bits.  */
 static inline pgd_t*
 pgd_offset (struct mm_struct *mm, unsigned long address)
 {
 	return mm->pgd + pgd_index(address);
 }
 
-/* In the kernel's mapped region we have a full 43 bit space available and completely
-   ignore the region number (since we know its in region number 5). */
+/* In the kernel's mapped region we completely ignore the region number
+   (since we know it's in region number 5). */
 #define pgd_offset_k(addr) \
 	(init_mm.pgd + (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)))
 
@@ -452,7 +452,9 @@
 #define pte_to_pgoff(pte)		((pte_val(pte) << 1) >> 3)
 #define pgoff_to_pte(off)		((pte_t) { ((off) << 2) | _PAGE_FILE })
 
-#define io_remap_page_range remap_page_range	/* XXX is this right? */
+/* XXX is this right? */
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 /*
  * ZERO_PAGE is a global shared page that is always zero: used
diff -Nru a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
--- a/include/asm-ia64/processor.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-ia64/processor.h	2004-12-24 13:36:47 -08:00
@@ -20,6 +20,9 @@
 #include <asm/ptrace.h>
 #include <asm/ustack.h>
 
+/* Our arch specific arch_init_sched_domain is in arch/ia64/kernel/domain.c */
+#define ARCH_HAS_SCHED_DOMAIN
+
 #define IA64_NUM_DBG_REGS	8
 /*
  * Limits for PMC and PMD are set to less than maximum architected values
@@ -334,26 +337,6 @@
 /* Prepare to copy thread state - unlazy all lazy status */
 #define prepare_to_copy(tsk)	do { } while (0)
 
-#ifdef CONFIG_NUMA
-#define SD_NODE_INIT (struct sched_domain) {		\
-	.span			= CPU_MASK_NONE,	\
-	.parent			= NULL,			\
-	.groups			= NULL,			\
-	.min_interval		= 80,			\
-	.max_interval		= 320,			\
-	.busy_factor		= 320,			\
-	.imbalance_pct		= 125,			\
-	.cache_hot_time		= (10*1000000),		\
-	.cache_nice_tries	= 1,			\
-	.per_cpu_gain		= 100,			\
-	.flags			= SD_BALANCE_EXEC	\
-				| SD_WAKE_BALANCE,	\
-	.last_balance		= jiffies,		\
-	.balance_interval	= 10,			\
-	.nr_balance_failed	= 0,			\
-}
-#endif
-
 /*
  * This is the mechanism for creating a new kernel thread.
  *
@@ -707,6 +690,8 @@
 }
 
 #define spin_lock_prefetch(x)	prefetchw(x)
+
+extern unsigned long boot_option_idle_override;
 
 #endif /* !__ASSEMBLY__ */
 
diff -Nru a/include/asm-ia64/ptrace.h b/include/asm-ia64/ptrace.h
--- a/include/asm-ia64/ptrace.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-ia64/ptrace.h	2004-12-24 13:37:01 -08:00
@@ -2,7 +2,7 @@
 #define _ASM_IA64_PTRACE_H
 
 /*
- * Copyright (C) 1998-2003 Hewlett-Packard Co
+ * Copyright (C) 1998-2004 Hewlett-Packard Co
  *	David Mosberger-Tang <davidm@hpl.hp.com>
  *	Stephane Eranian <eranian@hpl.hp.com>
  * Copyright (C) 2003 Intel Co
@@ -110,7 +110,11 @@
 
 	unsigned long cr_ipsr;		/* interrupted task's psr */
 	unsigned long cr_iip;		/* interrupted task's instruction pointer */
-	unsigned long cr_ifs;		/* interrupted task's function state */
+	/*
+	 * interrupted task's function state; if bit 63 is cleared, it
+	 * contains syscall's ar.pfs.pfm:
+	 */
+	unsigned long cr_ifs;
 
 	unsigned long ar_unat;		/* interrupted task's NaT register (preserved) */
 	unsigned long ar_pfs;		/* prev function state  */
diff -Nru a/include/asm-ia64/sn/addrs.h b/include/asm-ia64/sn/addrs.h
--- a/include/asm-ia64/sn/addrs.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-ia64/sn/addrs.h	2004-12-24 13:37:43 -08:00
@@ -3,21 +3,193 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 1992-1999,2001-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (c) 1992-1999,2001-2004 Silicon Graphics, Inc. All rights reserved.
  */
 
 #ifndef _ASM_IA64_SN_ADDRS_H
 #define _ASM_IA64_SN_ADDRS_H
 
-#include <asm/sn/sn2/addrs.h>
+
+/* McKinley Address Format:
+ *
+ *   4 4       3 3  3 3
+ *   9 8       8 7  6 5             0
+ *  +-+---------+----+--------------+
+ *  |0| Node ID | AS | Node Offset  |
+ *  +-+---------+----+--------------+
+ *
+ *   Node ID: If bit 38 = 1, is ICE, else is SHUB
+ *   AS: Address Space Identifier. Used only if bit 38 = 0.
+ *     b'00: Local Resources and MMR space
+ *           bit 35
+ *               0: Local resources space
+ *                  node id:
+ *                        0: IA64/NT compatibility space
+ *                        2: Local MMR Space
+ *                        4: Local memory, regardless of local node id
+ *               1: Global MMR space
+ *     b'01: GET space.
+ *     b'10: AMO space.
+ *     b'11: Cacheable memory space.
+ *
+ *   NodeOffset: byte offset
+ */
+
+/* TIO address format:
+ *  4 4        3 3 3 3 3             0
+ *  9 8        8 7 6 5 4
+ * +-+----------+-+---+--------------+
+ * |0| Node ID  |0|CID| Node offset  |
+ * +-+----------+-+---+--------------+
+ *
+ * Node ID: if bit 38 == 1, is ICE.
+ * Bit 37: Must be zero.
+ * CID: Chiplet ID:
+ *     b'01: TIO LB (Indicates TIO MMR access.)
+ *     b'11: TIO ICE (indicates coretalk space access.)
+ * Node offset: byte offest.
+ */
+
+/*
+ * Note that in both of the above address formats, bit
+ * 35 set indicates that the reference is to the 
+ * shub or tio MMRs.
+ */
 
 #ifndef __ASSEMBLY__
-#include <asm/sn/types.h>
-#endif 
+typedef union ia64_sn2_pa {
+	struct {
+		unsigned long off  : 36;
+		unsigned long as   : 2;
+		unsigned long nasid: 11;
+		unsigned long fill : 15;
+	} f;
+	unsigned long l;
+	void *p;
+} ia64_sn2_pa_t;
+#endif
+
+#define TO_PHYS_MASK		0x0001ffcfffffffffUL	/* Note - clear AS bits */
+
+
+/* Regions determined by AS */
+#define LOCAL_MMR_SPACE		0xc000008000000000UL	/* Local MMR space */
+#define LOCAL_PHYS_MMR_SPACE	0x8000008000000000UL	/* Local PhysicalMMR space */
+#define LOCAL_MEM_SPACE		0xc000010000000000UL	/* Local Memory space */
+/* It so happens that setting bit 35 indicates a reference to the SHUB or TIO
+ * MMR space.  
+ */
+#define GLOBAL_MMR_SPACE	0xc000000800000000UL	/* Global MMR space */
+#define TIO_MMR_SPACE		0xc000000800000000UL	/* TIO MMR space */
+#define ICE_MMR_SPACE		0xc000000000000000UL	/* ICE MMR space */
+#define GLOBAL_PHYS_MMR_SPACE	0x0000000800000000UL	/* Global Physical MMR space */
+#define GET_SPACE		0xe000001000000000UL	/* GET space */
+#define AMO_SPACE		0xc000002000000000UL	/* AMO space */
+#define CACHEABLE_MEM_SPACE	0xe000003000000000UL	/* Cacheable memory space */
+#define UNCACHED                0xc000000000000000UL	/* UnCacheable memory space */
+#define UNCACHED_PHYS           0x8000000000000000UL	/* UnCacheable physical memory space */
+
+#define PHYS_MEM_SPACE		0x0000003000000000UL	/* physical memory space */
+
+/* SN2 address macros */
+/* NID_SHFT has the right value for both SHUB and TIO addresses.*/
+#define NID_SHFT		38
+#define LOCAL_MMR_ADDR(a)	(UNCACHED | LOCAL_MMR_SPACE | (a))
+#define LOCAL_MMR_PHYS_ADDR(a)	(UNCACHED_PHYS | LOCAL_PHYS_MMR_SPACE | (a))
+#define LOCAL_MEM_ADDR(a)	(LOCAL_MEM_SPACE | (a))
+#define REMOTE_ADDR(n,a)	((((unsigned long)(n))<<NID_SHFT) | (a))
+#define GLOBAL_MMR_ADDR(n,a)	(UNCACHED | GLOBAL_MMR_SPACE | REMOTE_ADDR(n,a))
+#define GLOBAL_MMR_PHYS_ADDR(n,a) (UNCACHED_PHYS | GLOBAL_PHYS_MMR_SPACE | REMOTE_ADDR(n,a))
+#define GET_ADDR(n,a)		(GET_SPACE | REMOTE_ADDR(n,a))
+#define AMO_ADDR(n,a)		(UNCACHED | AMO_SPACE | REMOTE_ADDR(n,a))
+#define GLOBAL_MEM_ADDR(n,a)	(CACHEABLE_MEM_SPACE | REMOTE_ADDR(n,a))
+
+/* non-II mmr's start at top of big window space (4G) */
+#define BWIN_TOP		0x0000000100000000UL
+
+/*
+ * general address defines - for code common to SN0/SN1/SN2
+ */
+#define CAC_BASE		CACHEABLE_MEM_SPACE			/* cacheable memory space */
+#define IO_BASE			(UNCACHED | GLOBAL_MMR_SPACE)		/* lower 4G maps II's XIO space */
+#define TIO_BASE		(UNCACHED | ICE_MMR_SPACE)		/* lower 4G maps TIO space */
+#define AMO_BASE		(UNCACHED | AMO_SPACE)			/* fetch & op space */
+#define MSPEC_BASE		AMO_BASE				/* fetch & op space */
+#define UNCAC_BASE		(UNCACHED | CACHEABLE_MEM_SPACE)	/* uncached global memory */
+#define GET_BASE		GET_SPACE				/* momentarily coherent remote mem. */
+#define CALIAS_BASE             LOCAL_CACHEABLE_BASE			/* cached node-local memory */
+#define UALIAS_BASE             (UNCACHED | LOCAL_CACHEABLE_BASE)	/* uncached node-local memory */
+
+#define TO_PHYS(x)              (              ((x) & TO_PHYS_MASK))
+#define TO_CAC(x)               (CAC_BASE    | ((x) & TO_PHYS_MASK))
+#define TO_UNCAC(x)             (UNCAC_BASE  | ((x) & TO_PHYS_MASK))
+#define TO_MSPEC(x)             (MSPEC_BASE  | ((x) & TO_PHYS_MASK))
+#define TO_GET(x)		(GET_BASE    | ((x) & TO_PHYS_MASK))
+#define TO_CALIAS(x)            (CALIAS_BASE | TO_NODE_ADDRSPACE(x))
+#define TO_UALIAS(x)            (UALIAS_BASE | TO_NODE_ADDRSPACE(x))
+#define NODE_SIZE_BITS		36	/* node offset : bits <35:0> */
+#define BWIN_SIZE_BITS		29	/* big window size: 512M */
+#define TIO_BWIN_SIZE_BITS	30	/* big window size: 1G */
+#define NASID_BITS		11	/* bits <48:38> */
+#define NASID_BITMASK		(0x7ffULL)
+#define NASID_SHFT		NID_SHFT
+#define NASID_META_BITS		0	/* ???? */
+#define NASID_LOCAL_BITS	7	/* same router as SN1 */
+
+#define NODE_ADDRSPACE_SIZE     (1UL << NODE_SIZE_BITS)
+#define NASID_MASK              ((uint64_t) NASID_BITMASK << NASID_SHFT)
+#define NASID_GET(_pa)          (int) (((uint64_t) (_pa) >>            \
+                                        NASID_SHFT) & NASID_BITMASK)
+#define PHYS_TO_DMA(x)          ( ((x & NASID_MASK) >> 2) |             \
+                                  (x & (NODE_ADDRSPACE_SIZE - 1)) )
+
+/*
+ * This address requires a chiplet id in bits 38-39.  For DMA to memory,
+ * the chiplet id is zero.  If we implement TIO-TIO dma, we might need
+ * to insert a chiplet id into this macro.  However, it is our belief
+ * right now that this chiplet id will be ICE, which is also zero.
+ */
+#define PHYS_TO_TIODMA(x)     ( ((x & NASID_MASK) << 2) |             \
+                                 (x & (NODE_ADDRSPACE_SIZE - 1)) )
 
-#define HUBREG_CAST		(volatile mmr_t *)
+#define CHANGE_NASID(n,x)	({ia64_sn2_pa_t _v; _v.l = (long) (x); _v.f.nasid = n; _v.p;})
 
 
+#ifndef __ASSEMBLY__
+#define NODE_SWIN_BASE(nasid, widget)                                   \
+        ((widget == 0) ? NODE_BWIN_BASE((nasid), SWIN0_BIGWIN)          \
+        : RAW_NODE_SWIN_BASE(nasid, widget))
+#else
+#define NODE_SWIN_BASE(nasid, widget) \
+     (NODE_IO_BASE(nasid) + ((uint64_t) (widget) << SWIN_SIZE_BITS))
+#define LOCAL_SWIN_BASE(widget) \
+	(UNCACHED | LOCAL_MMR_SPACE | (((uint64_t) (widget) << SWIN_SIZE_BITS)))
+#endif /* __ASSEMBLY__ */
+
+/*
+ * The following definitions pertain to the IO special address
+ * space.  They define the location of the big and little windows
+ * of any given node.
+ */
+
+#define BWIN_SIZE               (1UL << BWIN_SIZE_BITS)
+#define BWIN_SIZEMASK           (BWIN_SIZE - 1)
+#define BWIN_WIDGET_MASK        0x7
+#define NODE_BWIN_BASE0(nasid)  (NODE_IO_BASE(nasid) + BWIN_SIZE)
+#define NODE_BWIN_BASE(nasid, bigwin)   (NODE_BWIN_BASE0(nasid) +       \
+                        ((uint64_t) (bigwin) << BWIN_SIZE_BITS))
+
+#define BWIN_WIDGETADDR(addr)   ((addr) & BWIN_SIZEMASK)
+#define BWIN_WINDOWNUM(addr)    (((addr) >> BWIN_SIZE_BITS) & BWIN_WIDGET_MASK)
+
+#define TIO_BWIN_WINDOW_SELECT_MASK 0x7
+#define TIO_BWIN_WINDOWNUM(addr)    (((addr) >> TIO_BWIN_SIZE_BITS) & TIO_BWIN_WINDOW_SELECT_MASK)
+
+
+#ifndef __ASSEMBLY__
+#include <asm/sn/types.h>
+#endif 
+
 /*
  * The following macros are used to index to the beginning of a specific
  * node's address space.
@@ -31,17 +203,11 @@
 #define NODE_MSPEC_BASE(_n)	(MSPEC_BASE + NODE_OFFSET(_n))
 #define NODE_UNCAC_BASE(_n)	(UNCAC_BASE + NODE_OFFSET(_n))
 
-#define TO_NODE(_n, _x)		(NODE_OFFSET(_n)     | ((_x)		   ))
 #define TO_NODE_CAC(_n, _x)	(NODE_CAC_BASE(_n) | ((_x) & TO_PHYS_MASK))
-#define TO_NODE_UNCAC(_n, _x)	(NODE_UNCAC_BASE(_n) | ((_x) & TO_PHYS_MASK))
-#define TO_NODE_MSPEC(_n, _x)	(NODE_MSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))
-#define TO_NODE_HSPEC(_n, _x)	(NODE_HSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))
-
 
 #define RAW_NODE_SWIN_BASE(nasid, widget)				\
 	(NODE_IO_BASE(nasid) + ((uint64_t) (widget) << SWIN_SIZE_BITS))
 
-#define WIDGETID_GET(addr)	((unsigned char)((addr >> SWIN_SIZE_BITS) & 0xff))
 
 /*
  * The following definitions pertain to the IO special address
@@ -54,43 +220,20 @@
 #define	SWIN_SIZEMASK		(SWIN_SIZE - 1)
 #define	SWIN_WIDGET_MASK	0xF
 
+#define TIO_SWIN_SIZE_BITS	28
+#define TIO_SWIN_SIZE		(1UL << 28)
+#define TIO_SWIN_SIZEMASK	(SWIN_SIZE - 1)
+#define TIO_SWIN_WIDGET_MASK	0x3
+
 /*
  * Convert smallwindow address to xtalk address.
  *
  * 'addr' can be physical or virtual address, but will be converted
  * to Xtalk address in the range 0 -> SWINZ_SIZEMASK
  */
-#define	SWIN_WIDGETADDR(addr)	((addr) & SWIN_SIZEMASK)
 #define	SWIN_WIDGETNUM(addr)	(((addr)  >> SWIN_SIZE_BITS) & SWIN_WIDGET_MASK)
-/*
- * Verify if addr belongs to small window address on node with "nasid"
- *
- *
- * NOTE: "addr" is expected to be XKPHYS address, and NOT physical
- * address
- *
- *
- */
-#define	NODE_SWIN_ADDR(nasid, addr)	\
-		(((addr) >= NODE_SWIN_BASE(nasid, 0))  && \
-		 ((addr) <  (NODE_SWIN_BASE(nasid, HUB_NUM_WIDGET) + SWIN_SIZE)\
-		 ))
-
-/*
- * The following define the major position-independent aliases used
- * in SN.
- *	LBOOT  -- 256MB in size, reads in the LBOOT area result in
- *			uncached references to the local hub's boot prom and
- *			other directory-bus connected devices.
- *	IALIAS -- 8MB in size, reads in the IALIAS result in uncached
- *			references to the local hub's registers.
- */
-
-#define	HUB_REGISTER_WIDGET	1
-#define IALIAS_BASE		LOCAL_SWIN_BASE(HUB_REGISTER_WIDGET)
-#define IALIAS_SIZE		0x800000	/* 8 Megabytes */
-#define IS_IALIAS(_a)		(((_a) >= IALIAS_BASE) &&		\
-				 ((_a) < (IALIAS_BASE + IALIAS_SIZE)))
+
+#define TIO_SWIN_WIDGETNUM(addr)	(((addr)  >> TIO_SWIN_SIZE_BITS) & TIO_SWIN_WIDGET_MASK)
 
 /*
  * The following macros produce the correct base virtual address for
@@ -107,15 +250,13 @@
  * As all other non-II mmr's located at the top of big window
  * space.
  */
-#define LOCAL_HUB_BASE(_x)	(LOCAL_MMR_ADDR(_x) | (((~(_x)) & BWIN_TOP)>>8))
 #define REMOTE_HUB_BASE(_x)						\
         (UNCACHED | GLOBAL_MMR_SPACE |                                  \
         (((~(_x)) & BWIN_TOP)>>8)    |                                       \
         (((~(_x)) & BWIN_TOP)>>9)    | (_x))
 
-#define LOCAL_HUB(_x) (HUBREG_CAST LOCAL_HUB_BASE(_x))
 #define REMOTE_HUB(_n, _x)						\
-	(HUBREG_CAST (REMOTE_HUB_BASE(_x) | ((((long)(_n))<<NASID_SHFT))))
+	((uint64_t *)(REMOTE_HUB_BASE(_x) | ((((long)(_n))<<NASID_SHFT))))
 
 
 /*
@@ -126,12 +267,20 @@
  *	Otherwise, the recommended approach is to use *_HUB_L() and *_HUB_S().
  *	They're always safe.
  */
+/*
+ * LOCAL_HUB_ADDR doesn't need to be changed for TIO, since, by definition,
+ * there are no "local" TIOs.
+ */
 #define LOCAL_HUB_ADDR(_x)							\
-	(((_x) & BWIN_TOP) ? (HUBREG_CAST (LOCAL_MMR_ADDR(_x)))		\
-	: (HUBREG_CAST (IALIAS_BASE + (_x))))
+	(((_x) & BWIN_TOP) ? ((volatile uint64_t *)(LOCAL_MMR_ADDR(_x)))		\
+	: ((volatile uint64_t *)(IALIAS_BASE + (_x))))
 #define REMOTE_HUB_ADDR(_n, _x)						\
-	(((_x) & BWIN_TOP) ? (HUBREG_CAST (GLOBAL_MMR_ADDR(_n, _x)))	\
-	: (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + 0x800000 + (_x))))
+	((_n & 1) ?							\
+	/* TIO: */							\
+	((volatile uint64_t *)(GLOBAL_MMR_ADDR(_n, _x)))				\
+	: /* SHUB: */							\
+	(((_x) & BWIN_TOP) ? ((volatile uint64_t *)(GLOBAL_MMR_ADDR(_n, _x)))	\
+	: ((volatile uint64_t *)(NODE_SWIN_BASE(_n, 1) + 0x800000 + (_x)))))
 
 #ifndef __ASSEMBLY__
 
@@ -152,78 +301,12 @@
  * the base of the register space.
  */
 #define HUB_REG_PTR(_base, _off)	\
-	(HUBREG_CAST ((unsigned long)(_base) + (__psunsigned_t)(_off)))
+	(volatile uint64_t *)((unsigned long)(_base) + (__psunsigned_t)(_off)))
 
 #define HUB_REG_PTR_L(_base, _off)	\
 	HUB_L(HUB_REG_PTR((_base), (_off)))
 
 #define HUB_REG_PTR_S(_base, _off, _data)	\
 	HUB_S(HUB_REG_PTR((_base), (_off)), (_data))
-
-/*
- * Software structure locations -- permanently fixed
- *    See diagram in kldir.h
- */
-
-#define PHYS_RAMBASE		0x0
-#define K0_RAMBASE		PHYS_TO_K0(PHYS_RAMBASE)
-
-#define ARCS_SPB_OFFSET		0x1000
-#define ARCS_SPB_ADDR(nasid)						\
-	PHYS_TO_K0(NODE_OFFSET(nasid) | ARCS_SPB_OFFSET)
-#define ARCS_SPB_SIZE		0x0400
-
-#define KLDIR_OFFSET		0x2000
-#define KLDIR_ADDR(nasid)						\
-	TO_NODE_CAC((nasid), KLDIR_OFFSET)
-#define KLDIR_SIZE		0x0400
-
-
-/*
- * Software structure locations -- indirected through KLDIR
- *    See diagram in kldir.h
- *
- * Important:	All low memory structures must only be accessed
- *		uncached, except for the symmon stacks.
- */
-
-#define KLI_LAUNCH		0		/* Dir. entries */
-#define KLI_KLCONFIG		1
-#define	KLI_NMI			2
-#define KLI_GDA			3
-#define KLI_FREEMEM		4
-#define	KLI_SYMMON_STK		5
-#define KLI_PI_ERROR		6
-#define KLI_KERN_VARS		7
-#define	KLI_KERN_XP		8
-#define	KLI_KERN_PARTID		9
-
-#ifndef __ASSEMBLY__
-
-#define KLD_BASE(nasid)		((kldir_ent_t *) KLDIR_ADDR(nasid))
-#define KLD_LAUNCH(nasid)	(KLD_BASE(nasid) + KLI_LAUNCH)
-#define KLD_NMI(nasid)		(KLD_BASE(nasid) + KLI_NMI)
-#define KLD_KLCONFIG(nasid)	(KLD_BASE(nasid) + KLI_KLCONFIG)
-#define KLD_PI_ERROR(nasid)	(KLD_BASE(nasid) + KLI_PI_ERROR)
-#define KLD_GDA(nasid)		(KLD_BASE(nasid) + KLI_GDA)
-#define KLD_SYMMON_STK(nasid)	(KLD_BASE(nasid) + KLI_SYMMON_STK)
-#define KLD_FREEMEM(nasid)	(KLD_BASE(nasid) + KLI_FREEMEM)
-#define KLD_KERN_VARS(nasid)	(KLD_BASE(nasid) + KLI_KERN_VARS)
-#define	KLD_KERN_XP(nasid)	(KLD_BASE(nasid) + KLI_KERN_XP)
-#define	KLD_KERN_PARTID(nasid)	(KLD_BASE(nasid) + KLI_KERN_PARTID)
-
-#define KLCONFIG_OFFSET(nasid)  ia64_sn_get_klconfig_addr(nasid)
-
-#define KLCONFIG_ADDR(nasid)						\
-	TO_NODE_CAC((nasid), KLCONFIG_OFFSET(nasid))
-#define KLCONFIG_SIZE(nasid)	KLD_KLCONFIG(nasid)->size
-
-#define GDA_ADDR(nasid)		KLD_GDA(nasid)->pointer
-#define GDA_SIZE(nasid)		KLD_GDA(nasid)->size
-
-#define NODE_OFFSET_TO_K0(_nasid, _off)					\
-	(CACHEABLE_MEM_SPACE | NODE_OFFSET(_nasid) | (_off))
-
-#endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_IA64_SN_ADDRS_H */
diff -Nru a/include/asm-ia64/sn/arch.h b/include/asm-ia64/sn/arch.h
--- a/include/asm-ia64/sn/arch.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-ia64/sn/arch.h	2004-12-24 13:36:47 -08:00
@@ -5,7 +5,7 @@
  *
  * SGI specific setup.
  *
- * Copyright (C) 1995-1997,1999,2001-2003 Silicon Graphics, Inc.  All rights reserved.
+ * Copyright (C) 1995-1997,1999,2001-2004 Silicon Graphics, Inc.  All rights reserved.
  * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
  */
 #ifndef _ASM_IA64_SN_ARCH_H
@@ -15,20 +15,13 @@
 #include <asm/sn/types.h>
 #include <asm/sn/sn_cpuid.h>
 
-typedef u64	shubreg_t;
-typedef u64	hubreg_t;
-typedef u64	mmr_t;
-typedef u64	nic_t;
-
-#define INVALID_NASID		((nasid_t)-1)
-#define INVALID_CNODEID		((cnodeid_t)-1)
-#define INVALID_PNODEID		((pnodeid_t)-1)
-#define INVALID_SLAB            (slabid_t)-1
-#define INVALID_MODULE		((moduleid_t)-1)
-#define	INVALID_PARTID		((partid_t)-1)
+/*
+ * This is the maximum number of nodes that can be part of a kernel.
+ * Effectively, it's the maximum number of compact node ids (cnodeid_t).
+ * This is not necessarily the same as MAX_NASIDS.
+ */
+#define MAX_COMPACT_NODES       2048
 
-extern cpuid_t cnodetocpu(cnodeid_t);
 extern void sn_flush_all_caches(long addr, long bytes);
-extern int is_fine_dirmode(void);
 
 #endif /* _ASM_IA64_SN_ARCH_H */
diff -Nru a/include/asm-ia64/sn/bte.h b/include/asm-ia64/sn/bte.h
--- a/include/asm-ia64/sn/bte.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-ia64/sn/bte.h	2004-12-24 13:36:49 -08:00
@@ -55,7 +55,9 @@
 /* macro to force the IBCT0 value valid */
 #define BTE_VALID_MODE(x) ((x) & (IBCT_NOTIFY | IBCT_ZFIL_MODE))
 
-#define BTE_ACTIVE	(IBLS_BUSY | IBLS_ERROR)
+#define BTE_ACTIVE		(IBLS_BUSY | IBLS_ERROR)
+#define BTE_WORD_AVAILABLE	(IBLS_BUSY << 1)
+#define BTE_WORD_BUSY		(~BTE_WORD_AVAILABLE)
 
 /*
  * Some macros to simplify reading.
diff -Nru a/include/asm-ia64/sn/cdl.h b/include/asm-ia64/sn/cdl.h
--- a/include/asm-ia64/sn/cdl.h	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,42 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_CDL_H
-#define _ASM_IA64_SN_CDL_H
-
-#ifdef __KERNEL__
-#include <asm/sn/sgi.h>
-#endif
-
-struct cdl {
-	int part_num;			/* Part part number */
-	int mfg_num;			/* Part MFG number */
-	int (*attach)(vertex_hdl_t);	/* Attach routine */
-};
-
-
-/*
- *	cdl: connection/driver list
- *
- *	support code for bus infrastructure for busses
- *	that have self-identifying devices; initially
- *	constructed for xtalk, pciio and gioio modules.
- */
-typedef struct cdl     *cdl_p;
-
-/*
- *	cdl_add_connpt: add a connection point
- *
- *	Calls the attach routines of all the drivers on
- *	the list that match this connection point, in
- *	the order that they were added to the list.
- */
-extern int		cdl_add_connpt(int key1,
-				       int key2,
-				       vertex_hdl_t conn,
-				       int drv_flags);
-#endif /* _ASM_IA64_SN_CDL_H */
diff -Nru a/include/asm-ia64/sn/clksupport.h b/include/asm-ia64/sn/clksupport.h
--- a/include/asm-ia64/sn/clksupport.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-ia64/sn/clksupport.h	2004-12-24 13:37:01 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
 
 /*
@@ -14,39 +14,15 @@
  * 
  *	RTC_COUNTER_ADDR - contains the address of the counter 
  *
- *	GET_RTC_COUNTER() - macro to read the value of the clock
- *
- *	RTC_CYCLES_PER_SEC - clock frequency in ticks per second	
- *
  */
 
 #ifndef _ASM_IA64_SN_CLKSUPPORT_H
 #define _ASM_IA64_SN_CLKSUPPORT_H
 
-#include <asm/sn/arch.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/sn2/addrs.h>
-#include <asm/sn/sn2/shubio.h>
-#include <asm/sn/sn2/shub_mmr.h>
-
-typedef long clkreg_t;
-
 extern unsigned long sn_rtc_cycles_per_second;
-extern unsigned long sn_rtc_per_itc;
-
-#define RTC_MASK		SH_RTC_MASK
-#define RTC_COUNTER_ADDR	((clkreg_t*)LOCAL_MMR_ADDR(SH_RTC))
-#define RTC_COMPARE_A_ADDR      ((clkreg_t*)LOCAL_MMR_ADDR(SH_RTC))
-#define RTC_COMPARE_B_ADDR      ((clkreg_t*)LOCAL_MMR_ADDR(SH_RTC))
-#define RTC_INT_PENDING_A_ADDR  ((clkreg_t*)LOCAL_MMR_ADDR(SH_RTC))
-#define RTC_INT_PENDING_B_ADDR  ((clkreg_t*)LOCAL_MMR_ADDR(SH_RTC))
-#define RTC_INT_ENABLED_A_ADDR  ((clkreg_t*)LOCAL_MMR_ADDR(SH_RTC))
-#define RTC_INT_ENABLED_B_ADDR  ((clkreg_t*)LOCAL_MMR_ADDR(SH_RTC))
 
-#define SN_RTC_PER_ITC_SHIFT	34
-#define GET_RTC_COUNTER()	(*RTC_COUNTER_ADDR)
-#define rtc_time()		GET_RTC_COUNTER()
+#define RTC_COUNTER_ADDR	((long *)LOCAL_MMR_ADDR(SH_RTC))
 
-#define RTC_CYCLES_PER_SEC	sn_rtc_cycles_per_second
+#define rtc_time()		(*RTC_COUNTER_ADDR)
 
 #endif /* _ASM_IA64_SN_CLKSUPPORT_H */
diff -Nru a/include/asm-ia64/sn/dmamap.h b/include/asm-ia64/sn/dmamap.h
--- a/include/asm-ia64/sn/dmamap.h	2004-12-24 13:37:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,50 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_DMAMAP_H
-#define _ASM_IA64_SN_DMAMAP_H
-
-/*
- * Definitions for allocating, freeing, and using DMA maps
- */
-
-/*
- * DMA map types
- */
-#define	DMA_SCSI	0
-#define	DMA_A24VME	1		/* Challenge/Onyx only 	*/
-#define	DMA_A32VME	2		/* Challenge/Onyx only 	*/
-#define	DMA_A64VME	3		/* SN0/Racer */
-
-#define	DMA_EISA	4
-
-#define	DMA_PCI32	5		/* SN0/Racer 	*/
-#define	DMA_PCI64	6		/* SN0/Racer 	*/
-
-/*
- * DMA map structure as returned by dma_mapalloc()
- */
-typedef struct dmamap {
-	int		dma_type;	/* Map type (see above) */
-	int		dma_adap;	/* I/O adapter */
-	int		dma_index;	/* Beginning map register to use */
-	int		dma_size;	/* Number of map registers to use */
-	paddr_t		dma_addr;	/* Corresponding bus addr for A24/A32 */
-	unsigned long	dma_virtaddr;	/* Beginning virtual address that is mapped */
-} dmamap_t;
-
-/* standard flags values for pio_map routines,
- * including {xtalk,pciio}_dmamap calls.
- * NOTE: try to keep these in step with PIOMAP flags.
- */
-#define DMAMAP_FIXED	0x1
-#define DMAMAP_NOSLEEP	0x2
-#define	DMAMAP_INPLACE	0x4
-
-#define	DMAMAP_FLAGS	0x7
-
-#endif /* _ASM_IA64_SN_DMAMAP_H */
diff -Nru a/include/asm-ia64/sn/driver.h b/include/asm-ia64/sn/driver.h
--- a/include/asm-ia64/sn/driver.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,91 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_DRIVER_H
-#define _ASM_IA64_SN_DRIVER_H
-
-#include <asm/sn/sgi.h>
-#include <asm/types.h>
-
-/*
-** Interface for device driver handle management.
-**
-** These functions are mostly for use by the loadable driver code, and
-** for use by I/O bus infrastructure code.
-*/
-
-typedef struct device_driver_s *device_driver_t;
-
-/* == Driver thread priority support == */
-typedef int ilvl_t;
-
-struct eframe_s;
-struct piomap;
-struct dmamap;
-
-typedef unsigned long iobush_t;
-
-/* interrupt function */
-typedef void	       *intr_arg_t;
-typedef void		intr_func_f(intr_arg_t);
-typedef intr_func_f    *intr_func_t;
-
-#define	INTR_ARG(n)	((intr_arg_t)(__psunsigned_t)(n))
-
-/* system interrupt resource handle -- returned from intr_alloc */
-typedef struct intr_s *intr_t;
-#define INTR_HANDLE_NONE ((intr_t)0)
-
-/*
- * restore interrupt level value, returned from intr_block_level
- * for use with intr_unblock_level.
- */
-typedef void *rlvl_t;
-
-
-/* 
- * A basic, platform-independent description of I/O requirements for
- * a device. This structure is usually formed by lboot based on information 
- * in configuration files.  It contains information about PIO, DMA, and
- * interrupt requirements for a specific instance of a device.
- *
- * The pio description is currently unused.
- *
- * The dma description describes bandwidth characteristics and bandwidth
- * allocation requirements. (TBD)
- *
- * The Interrupt information describes the priority of interrupt, desired 
- * destination, policy (TBD), whether this is an error interrupt, etc.  
- * For now, interrupts are targeted to specific CPUs.
- */
-
-typedef struct device_desc_s {
-	/* pio description (currently none) */
-
-	/* dma description */
-	/* TBD: allocated badwidth requirements */
-
-	/* interrupt description */
-	vertex_hdl_t	intr_target;	/* Hardware locator string */
-	int 		intr_policy;	/* TBD */
-	ilvl_t		intr_swlevel;	/* software level for blocking intr */
-	char		*intr_name;	/* name of interrupt, if any */
-
-	int		flags;
-} *device_desc_t;
-
-/* flag values */
-#define	D_INTR_ISERR	0x1		/* interrupt is for error handling */
-#define D_IS_ASSOC	0x2		/* descriptor is associated with a dev */
-#define D_INTR_NOTHREAD	0x4		/* Interrupt handler isn't threaded. */
-
-#define INTR_SWLEVEL_NOTHREAD_DEFAULT 	0	/* Default
-						 * Interrupt level in case of
-						 * non-threaded interrupt 
-						 * handlers
-						 */
-#endif /* _ASM_IA64_SN_DRIVER_H */
diff -Nru a/include/asm-ia64/sn/fetchop.h b/include/asm-ia64/sn/fetchop.h
--- a/include/asm-ia64/sn/fetchop.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-ia64/sn/fetchop.h	2004-12-24 13:37:00 -08:00
@@ -4,7 +4,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
+ * Copyright (c) 2001-2004 Silicon Graphics, Inc.  All rights reserved.
  */
 
 #ifndef _ASM_IA64_SN_FETCHOP_H
diff -Nru a/include/asm-ia64/sn/geo.h b/include/asm-ia64/sn/geo.h
--- a/include/asm-ia64/sn/geo.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-ia64/sn/geo.h	2004-12-24 13:37:00 -08:00
@@ -3,43 +3,122 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
 
 #ifndef _ASM_IA64_SN_GEO_H
 #define _ASM_IA64_SN_GEO_H
 
-/* Include a platform-specific geo.h.  It must define at least:
- *   geoid_t:		Geographic identifier data type
- *   geo_type_t:	Data type for the kind of geoid this is
- *   GEO_TYPE_xxx:	Values for geo_type_t vars, eg. GEO_TYPE_NODE
- *   GEO_MAX_LEN:	The maximum length of a geoid, formatted for printing
- */
+/* The geoid_t implementation below is based loosely on the pcfg_t
+   implementation in sys/SN/promcfg.h. */
 
-#include <asm/sn/sn2/geo.h>
+/* Type declaractions */
 
-/* Declarations applicable to all platforms */
+/* Size of a geoid_t structure (must be before decl. of geoid_u) */
+#define GEOID_SIZE	8	/* Would 16 be better?  The size can
+				   be different on different platforms. */
+
+#define MAX_SLABS	0xe	/* slabs per module */
+
+typedef unsigned char	geo_type_t;
+
+/* Fields common to all substructures */
+typedef struct geo_any_s {
+    moduleid_t	module;		/* The module (box) this h/w lives in */
+    geo_type_t	type;		/* What type of h/w is named by this geoid_t */
+    slabid_t	slab;		/* The logical assembly within the module */
+} geo_any_t;
+
+/* Additional fields for particular types of hardware */
+typedef struct geo_node_s {
+    geo_any_t	any;		/* No additional fields needed */
+} geo_node_t;
+
+typedef struct geo_rtr_s {
+    geo_any_t	any;		/* No additional fields needed */
+} geo_rtr_t;
+
+typedef struct geo_iocntl_s {
+    geo_any_t	any;		/* No additional fields needed */
+} geo_iocntl_t;
+
+typedef struct geo_pcicard_s {
+    geo_iocntl_t	any;
+    char		bus;	/* Bus/widget number */
+    char		slot;	/* PCI slot number */
+} geo_pcicard_t;
+
+/* Subcomponents of a node */
+typedef struct geo_cpu_s {
+    geo_node_t	node;
+    char	slice;		/* Which CPU on the node */
+} geo_cpu_t;
+
+typedef struct geo_mem_s {
+    geo_node_t	node;
+    char	membus;		/* The memory bus on the node */
+    char	memslot;	/* The memory slot on the bus */
+} geo_mem_t;
+
+
+typedef union geoid_u {
+    geo_any_t	any;
+    geo_node_t	node;
+    geo_iocntl_t	iocntl;
+    geo_pcicard_t	pcicard;
+    geo_rtr_t	rtr;
+    geo_cpu_t	cpu;
+    geo_mem_t	mem;
+    char	padsize[GEOID_SIZE];
+} geoid_t;
+
+
+/* Preprocessor macros */
+
+#define GEO_MAX_LEN	48	/* max. formatted length, plus some pad:
+				   module/001c07/slab/5/node/memory/2/slot/4 */
+
+/* Values for geo_type_t */
+#define GEO_TYPE_INVALID	0
+#define GEO_TYPE_MODULE		1
+#define GEO_TYPE_NODE		2
+#define GEO_TYPE_RTR		3
+#define GEO_TYPE_IOCNTL		4
+#define GEO_TYPE_IOCARD		5
+#define GEO_TYPE_CPU		6
+#define GEO_TYPE_MEM		7
+#define GEO_TYPE_MAX		(GEO_TYPE_MEM+1)
+
+/* Parameter for hwcfg_format_geoid_compt() */
+#define GEO_COMPT_MODULE	1
+#define GEO_COMPT_SLAB		2
+#define GEO_COMPT_IOBUS		3
+#define GEO_COMPT_IOSLOT	4
+#define GEO_COMPT_CPU		5
+#define GEO_COMPT_MEMBUS	6
+#define GEO_COMPT_MEMSLOT	7
+
+#define GEO_INVALID_STR		"<invalid>"
+
+#define INVALID_NASID           ((nasid_t)-1)
+#define INVALID_CNODEID         ((cnodeid_t)-1)
+#define INVALID_PNODEID         ((pnodeid_t)-1)
+#define INVALID_SLAB            (slabid_t)-1
+#define INVALID_MODULE          ((moduleid_t)-1)
+#define INVALID_PARTID          ((partid_t)-1)
+
+static inline slabid_t geo_slab(geoid_t g)
+{
+	return (g.any.type == GEO_TYPE_INVALID) ?
+		INVALID_SLAB : g.any.slab;
+}
+
+static inline moduleid_t geo_module(geoid_t g)
+{
+	return (g.any.type == GEO_TYPE_INVALID) ?
+		INVALID_MODULE : g.any.module;
+}
 
-/* parameter for hwcfg_format_geoid() */
-#define GEO_FORMAT_HWGRAPH	1
-#define GEO_FORMAT_BRIEF	2
-
-/* (the parameter for hwcfg_format_geoid_compt() is defined in the
- * platform-specific geo.h file) */
-
-/* Routines for manipulating geoid_t values */
-
-extern moduleid_t geo_module(geoid_t g);
-extern slabid_t geo_slab(geoid_t g);
-extern geo_type_t geo_type(geoid_t g);
-extern int geo_valid(geoid_t g);
-extern int geo_cmp(geoid_t g0, geoid_t g1);
-extern geoid_t geo_new(geo_type_t type, ...);
-
-extern geoid_t hwcfg_parse_geoid(char *buffer);
-extern void hwcfg_format_geoid(char *buffer, geoid_t m, int fmt);
-extern void hwcfg_format_geoid_compt(char *buffer, geoid_t m, int compt);
-extern geoid_t hwcfg_geo_get_self(geo_type_t type);
-extern geoid_t hwcfg_geo_get_by_nasid(geo_type_t type, nasid_t nasid);
+extern geoid_t cnodeid_get_geoid(cnodeid_t cnode);
 
 #endif /* _ASM_IA64_SN_GEO_H */
diff -Nru a/include/asm-ia64/sn/hcl.h b/include/asm-ia64/sn/hcl.h
--- a/include/asm-ia64/sn/hcl.h	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,107 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_HCL_H
-#define _ASM_IA64_SN_HCL_H
-
-#include <linux/fs.h>
-#include <asm/sn/sgi.h>
-
-extern vertex_hdl_t hwgraph_root;
-extern vertex_hdl_t linux_busnum;
-
-void hwgraph_debug(char *, const char *, int, vertex_hdl_t, vertex_hdl_t, char *, ...);
-
-#if 1
-#define HWGRAPH_DEBUG(args...) hwgraph_debug(args)
-#else   
-#define HWGRAPH_DEBUG(args)
-#endif  
-
-typedef long            labelcl_info_place_t;
-typedef long            arbitrary_info_t;
-typedef long            arb_info_desc_t;
-
-
-/* 
- * Reserve room in every vertex for 2 pieces of fast access indexed information 
- * Note that we do not save a pointer to the bdevsw or cdevsw[] tables anymore.
- */
-#define HWGRAPH_NUM_INDEX_INFO	2	/* MAX Entries */
-#define HWGRAPH_CONNECTPT	0	/* connect point (aprent) */
-#define HWGRAPH_FASTINFO	1	/* callee's private handle */
-
-/*
- * Reserved edge_place_t values, used as the "place" parameter to edge_get_next.
- * Every vertex in the hwgraph has up to 2 *implicit* edges.  There is an implicit
- * edge called "." that points to the current vertex.  There is an implicit edge
- * called ".." that points to the vertex' connect point.
- */
-#define EDGE_PLACE_WANT_CURRENT 0	/* "." */
-#define EDGE_PLACE_WANT_CONNECTPT 1	/* ".." */
-#define EDGE_PLACE_WANT_REAL_EDGES 2	/* Get the first real edge */
-#define HWGRAPH_RESERVED_PLACES 2
-
-
-/*
- * Special pre-defined edge labels.
- */
-#define HWGRAPH_EDGELBL_HW 	"hw"
-#define HWGRAPH_EDGELBL_DOT 	"."
-#define HWGRAPH_EDGELBL_DOTDOT 	".."
-
-#include <asm/sn/labelcl.h>
-#define hwgraph_fastinfo_set(a,b) labelcl_info_replace_IDX(a, HWGRAPH_FASTINFO, b, NULL)
-#define hwgraph_connectpt_set labelcl_info_connectpt_set
-#define hwgraph_generate_path hwgfs_generate_path
-#define hwgraph_path_to_vertex(a) hwgfs_find_handle(NULL, a, 0, 0, 0, 1)
-#define hwgraph_vertex_unref(a)
-
-/*
- * External declarations of EXPORTED SYMBOLS in hcl.c
- */
-extern vertex_hdl_t hwgraph_register(vertex_hdl_t, const char *,
-	unsigned int, unsigned int, unsigned int, unsigned int,
-	umode_t, uid_t, gid_t, struct file_operations *, void *);
-
-extern int hwgraph_mk_symlink(vertex_hdl_t, const char *, unsigned int,
-	unsigned int, const char *, unsigned int, vertex_hdl_t *, void *);
-
-extern int hwgraph_vertex_destroy(vertex_hdl_t);
-
-extern int hwgraph_edge_add(vertex_hdl_t, vertex_hdl_t, char *);
-extern int hwgraph_edge_get(vertex_hdl_t, char *, vertex_hdl_t *);
-
-extern arbitrary_info_t hwgraph_fastinfo_get(vertex_hdl_t);
-extern vertex_hdl_t hwgraph_mk_dir(vertex_hdl_t, const char *, unsigned int, void *);
-
-extern int hwgraph_connectpt_set(vertex_hdl_t, vertex_hdl_t);
-extern vertex_hdl_t hwgraph_connectpt_get(vertex_hdl_t);
-extern int hwgraph_edge_get_next(vertex_hdl_t, char *, vertex_hdl_t *, unsigned int *);
-
-extern graph_error_t hwgraph_traverse(vertex_hdl_t, char *, vertex_hdl_t *);
-
-extern int hwgraph_vertex_get_next(vertex_hdl_t *, vertex_hdl_t *);
-extern int hwgraph_path_add(vertex_hdl_t, char *, vertex_hdl_t *);
-extern vertex_hdl_t hwgraph_path_to_dev(char *);
-extern vertex_hdl_t hwgraph_block_device_get(vertex_hdl_t);
-extern vertex_hdl_t hwgraph_char_device_get(vertex_hdl_t);
-extern graph_error_t hwgraph_char_device_add(vertex_hdl_t, char *, char *, vertex_hdl_t *);
-extern int hwgraph_path_add(vertex_hdl_t, char *, vertex_hdl_t *);
-extern int hwgraph_info_add_LBL(vertex_hdl_t, char *, arbitrary_info_t);
-extern int hwgraph_info_get_LBL(vertex_hdl_t, char *, arbitrary_info_t *);
-extern int hwgraph_info_replace_LBL(vertex_hdl_t, char *, arbitrary_info_t,
-				    arbitrary_info_t *);
-extern int hwgraph_info_get_exported_LBL(vertex_hdl_t, char *, int *, arbitrary_info_t *);
-extern int hwgraph_info_get_next_LBL(vertex_hdl_t, char *, arbitrary_info_t *,
-                                labelcl_info_place_t *);
-extern int hwgraph_info_export_LBL(vertex_hdl_t, char *, int);
-extern int hwgraph_info_unexport_LBL(vertex_hdl_t, char *);
-extern int hwgraph_info_remove_LBL(vertex_hdl_t, char *, arbitrary_info_t *);
-extern char *vertex_to_name(vertex_hdl_t, char *, unsigned int);
-
-#endif /* _ASM_IA64_SN_HCL_H */
diff -Nru a/include/asm-ia64/sn/hcl_util.h b/include/asm-ia64/sn/hcl_util.h
--- a/include/asm-ia64/sn/hcl_util.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,21 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#ifndef _ASM_IA64_SN_HCL_UTIL_H
-#define _ASM_IA64_SN_HCL_UTIL_H
-
-#include <asm/sn/sgi.h>
-
-extern char * dev_to_name(vertex_hdl_t, char *, unsigned int);
-extern int device_master_set(vertex_hdl_t, vertex_hdl_t);
-extern vertex_hdl_t device_master_get(vertex_hdl_t);
-extern cnodeid_t master_node_get(vertex_hdl_t);
-extern cnodeid_t nodevertex_to_cnodeid(vertex_hdl_t);
-extern void mark_nodevertex_as_node(vertex_hdl_t, cnodeid_t);
-
-#endif /* _ASM_IA64_SN_HCL_UTIL_H */
diff -Nru a/include/asm-ia64/sn/hwgfs.h b/include/asm-ia64/sn/hwgfs.h
--- a/include/asm-ia64/sn/hwgfs.h	2004-12-24 13:36:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,36 +0,0 @@
-#ifndef _ASM_IA64_SN_HWGFS_H
-#define _ASM_IA64_SN_HWGFS_H
-
-/*
- * 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 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <asm/types.h>
-
-typedef struct dentry *hwgfs_handle_t;
-
-extern hwgfs_handle_t hwgfs_register(hwgfs_handle_t dir, const char *name,
-				     unsigned int flags,
-				     unsigned int major, unsigned int minor,
-				     umode_t mode, void *ops, void *info);
-extern int hwgfs_mk_symlink(hwgfs_handle_t dir, const char *name,
-			     unsigned int flags, const char *link,
-			     hwgfs_handle_t *handle, void *info);
-extern hwgfs_handle_t hwgfs_mk_dir(hwgfs_handle_t dir, const char *name,
-				    void *info);
-extern void hwgfs_unregister(hwgfs_handle_t de);
-
-extern hwgfs_handle_t hwgfs_find_handle(hwgfs_handle_t dir, const char *name,
-					unsigned int major,unsigned int minor,
-					char type, int traverse_symlinks);
-extern hwgfs_handle_t hwgfs_get_parent(hwgfs_handle_t de);
-extern int hwgfs_generate_path(hwgfs_handle_t de, char *path, int buflen);
-
-extern void *hwgfs_get_info(hwgfs_handle_t de);
-extern int hwgfs_set_info(hwgfs_handle_t de, void *info);
-
-#endif	/* _ASM_IA64_SN_HWGFS_H */
diff -Nru a/include/asm-ia64/sn/ifconfig_net.h b/include/asm-ia64/sn/ifconfig_net.h
--- a/include/asm-ia64/sn/ifconfig_net.h	2004-12-24 13:36:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,32 +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) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#ifndef _ASM_IA64_SN_IFCONFIG_NET_H
-#define _ASM_IA64_SN_IFCONFIG_NET_H
-
-#define NETCONFIG_FILE "/tmp/ifconfig_net"
-#define POUND_CHAR                   '#'
-#define MAX_LINE_LEN 128
-#define MAXPATHLEN 128
-
-struct ifname_num {
-	long next_eth;
-	long next_fddi;
-	long next_hip;
-	long next_tr;
-	long next_fc;
-	long size;
-};
-
-struct ifname_MAC {
-	char name[16];
-	unsigned char           dev_addr[7];
-	unsigned char           addr_len;       /* hardware address length      */
-};
-
-#endif /* _ASM_IA64_SN_IFCONFIG_NET_H */
diff -Nru a/include/asm-ia64/sn/intr.h b/include/asm-ia64/sn/intr.h
--- a/include/asm-ia64/sn/intr.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-ia64/sn/intr.h	2004-12-24 13:36:31 -08:00
@@ -3,19 +3,54 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
+
 #ifndef _ASM_IA64_SN_INTR_H
 #define _ASM_IA64_SN_INTR_H
 
-#include <asm/sn/types.h>
-#include <asm/sn/sn2/intr.h>
+#define SGI_UART_VECTOR		(0xe9)
+#define SGI_PCIBR_ERROR		(0x33)
+
+/* Reserved IRQs : Note, not to exceed IA64_SN2_FIRST_DEVICE_VECTOR */
+#define SGI_XPC_ACTIVATE                (0x30)
+#define SGI_II_ERROR                    (0x31)
+#define SGI_XBOW_ERROR                  (0x32)
+#define SGI_PCIBR_ERROR                 (0x33)
+#define SGI_ACPI_SCI_INT                (0x34)
+#define SGI_TIOCA_ERROR                 (0x35)
+#define SGI_TIO_ERROR                   (0x36)
+#define SGI_TIOCX_ERROR                 (0x37)
+#define SGI_MMTIMER_VECTOR              (0x38)
+#define SGI_XPC_NOTIFY                  (0xe7)
+
+#define IA64_SN2_FIRST_DEVICE_VECTOR    (0x3c)
+#define IA64_SN2_LAST_DEVICE_VECTOR     (0xe6)
+
+#define SN2_IRQ_RESERVED        (0x1)
+#define SN2_IRQ_CONNECTED       (0x2)
+#define SN2_IRQ_SHARED          (0x4)
+
+// The SN PROM irq struct
+struct sn_irq_info {
+	struct sn_irq_info *irq_next;	/* sharing irq list	     */
+	short		irq_nasid;	/* Nasid IRQ is assigned to  */
+	int		irq_slice;	/* slice IRQ is assigned to  */
+	int		irq_cpuid;	/* kernel logical cpuid	     */
+	int		irq_irq;	/* the IRQ number */
+	int		irq_int_bit;	/* Bridge interrupt pin */
+	uint64_t	irq_xtalkaddr;	/* xtalkaddr IRQ is sent to  */
+	int		irq_bridge_type;/* pciio asic type (pciio.h) */
+	void	       *irq_bridge;	/* bridge generating irq     */
+	void	       *irq_pciioinfo;	/* associated pciio_info_t   */
+	int		irq_last_intr;	/* For Shub lb lost intr WAR */
+	int		irq_cookie;	/* unique cookie 	     */
+	int		irq_flags;	/* flags */
+	int		irq_share_cnt;	/* num devices sharing IRQ   */
+};
 
-extern void sn_send_IPI_phys(long, int, int);
-extern void intr_init_vecblk(cnodeid_t node);
+extern void sn_send_IPI_phys(int, long, int, int);
 
 #define CPU_VECTOR_TO_IRQ(cpuid,vector) (vector)
-#define SN_CPU_FROM_IRQ(irq)	(0)
-#define SN_IVEC_FROM_IRQ(irq)	(irq)
 
 #endif /* _ASM_IA64_SN_INTR_H */
diff -Nru a/include/asm-ia64/sn/io.h b/include/asm-ia64/sn/io.h
--- a/include/asm-ia64/sn/io.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-ia64/sn/io.h	2004-12-24 13:37:44 -08:00
@@ -1,65 +1,265 @@
-/*
+/* 
  * 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-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * Copyright (C) 2000 Ralf Baechle
+ * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
-#ifndef _ASM_IA64_SN_IO_H
-#define _ASM_IA64_SN_IO_H
 
-#include <asm/sn/addrs.h>
+#ifndef _ASM_SN_IO_H
+#define _ASM_SN_IO_H
+#include <linux/compiler.h>
+#include <asm/intrinsics.h>
+
+extern void * sn_io_addr(unsigned long port) __attribute_const__; /* Forward definition */
+extern void __sn_mmiowb(void); /* Forward definition */
+
+extern int numionodes;
+
+#define __sn_mf_a()   ia64_mfa()
+
+extern void sn_dma_flush(unsigned long);
+
+#define __sn_inb ___sn_inb
+#define __sn_inw ___sn_inw
+#define __sn_inl ___sn_inl
+#define __sn_outb ___sn_outb
+#define __sn_outw ___sn_outw
+#define __sn_outl ___sn_outl
+#define __sn_readb ___sn_readb
+#define __sn_readw ___sn_readw
+#define __sn_readl ___sn_readl
+#define __sn_readq ___sn_readq
+#define __sn_readb_relaxed ___sn_readb_relaxed
+#define __sn_readw_relaxed ___sn_readw_relaxed
+#define __sn_readl_relaxed ___sn_readl_relaxed
+#define __sn_readq_relaxed ___sn_readq_relaxed
 
-/* Because we only have PCI I/O ports.  */
-#define IIO_ITTE_BASE	0x400160	/* base of translation table entries */
-#define IIO_ITTE(bigwin)	(IIO_ITTE_BASE + 8*(bigwin))
-
-#define IIO_ITTE_OFFSET_BITS	5	/* size of offset field */
-#define IIO_ITTE_OFFSET_MASK	((1<<IIO_ITTE_OFFSET_BITS)-1)
-#define IIO_ITTE_OFFSET_SHIFT	0
-
-#define IIO_ITTE_WIDGET_BITS	4	/* size of widget field */
-#define IIO_ITTE_WIDGET_MASK	((1<<IIO_ITTE_WIDGET_BITS)-1)
-#define IIO_ITTE_WIDGET_SHIFT	8
-
-#define IIO_ITTE_IOSP		1	/* I/O Space bit */
-#define IIO_ITTE_IOSP_MASK	1
-#define IIO_ITTE_IOSP_SHIFT	12
-#define HUB_PIO_MAP_TO_MEM	0
-#define HUB_PIO_MAP_TO_IO	1
-
-#define IIO_ITTE_INVALID_WIDGET	3	/* an invalid widget  */
-
-#define IIO_ITTE_PUT(nasid, bigwin, io_or_mem, widget, addr) \
-	REMOTE_HUB_S((nasid), IIO_ITTE(bigwin), \
-		(((((addr) >> BWIN_SIZE_BITS) & \
-		   IIO_ITTE_OFFSET_MASK) << IIO_ITTE_OFFSET_SHIFT) | \
-		(io_or_mem << IIO_ITTE_IOSP_SHIFT) | \
-		(((widget) & IIO_ITTE_WIDGET_MASK) << IIO_ITTE_WIDGET_SHIFT)))
-
-#define IIO_ITTE_DISABLE(nasid, bigwin) \
-	IIO_ITTE_PUT((nasid), (bigwin), HUB_PIO_MAP_TO_MEM, \
-		IIO_ITTE_INVALID_WIDGET, 0)
+/*
+ * The following routines are SN Platform specific, called when
+ * a reference is made to inX/outX set macros.  SN Platform
+ * inX set of macros ensures that Posted DMA writes on the
+ * Bridge is flushed.
+ *
+ * The routines should be self explainatory.
+ */
 
-#define IIO_ITTE_GET(nasid, bigwin) REMOTE_HUB_ADDR((nasid), IIO_ITTE(bigwin))
+static inline unsigned int
+___sn_inb (unsigned long port)
+{
+	volatile unsigned char *addr;
+	unsigned char ret = -1;
+
+	if ((addr = sn_io_addr(port))) {
+		ret = *addr;
+		__sn_mf_a();
+		sn_dma_flush((unsigned long)addr);
+	}
+	return ret;
+}
+
+static inline unsigned int
+___sn_inw (unsigned long port)
+{
+	volatile unsigned short *addr;
+	unsigned short ret = -1;
+
+	if ((addr = sn_io_addr(port))) {
+		ret = *addr;
+		__sn_mf_a();
+		sn_dma_flush((unsigned long)addr);
+	}
+	return ret;
+}
+
+static inline unsigned int
+___sn_inl (unsigned long port)
+{
+	volatile unsigned int *addr;
+	unsigned int ret = -1;
+
+	if ((addr = sn_io_addr(port))) {
+		ret = *addr;
+		__sn_mf_a();
+		sn_dma_flush((unsigned long)addr);
+	}
+	return ret;
+}
+
+static inline void
+___sn_outb (unsigned char val, unsigned long port)
+{
+	volatile unsigned char *addr;
+
+	if ((addr = sn_io_addr(port))) {
+		*addr = val;
+		__sn_mmiowb();
+	}
+}
+
+static inline void
+___sn_outw (unsigned short val, unsigned long port)
+{
+	volatile unsigned short *addr;
+
+	if ((addr = sn_io_addr(port))) {
+		*addr = val;
+		__sn_mmiowb();
+	}
+}
+
+static inline void
+___sn_outl (unsigned int val, unsigned long port)
+{
+	volatile unsigned int *addr;
+
+	if ((addr = sn_io_addr(port))) {
+		*addr = val;
+		__sn_mmiowb();
+	}
+}
 
 /*
- * Macro which takes the widget number, and returns the
- * IO PRB address of that widget.
- * value _x is expected to be a widget number in the range
- * 0, 8 - 0xF
+ * The following routines are SN Platform specific, called when 
+ * a reference is made to readX/writeX set macros.  SN Platform 
+ * readX set of macros ensures that Posted DMA writes on the 
+ * Bridge is flushed.
+ * 
+ * The routines should be self explainatory.
  */
-#define	IIO_IOPRB(_x)	(IIO_IOPRB_0 + ( ( (_x) < HUB_WIDGET_ID_MIN ? \
-			(_x) : \
-			(_x) - (HUB_WIDGET_ID_MIN-1)) << 3) )
 
-#include <asm/sn/sn2/shub.h>
-#include <asm/sn/sn2/shubio.h>
+static inline unsigned char
+___sn_readb (const volatile void __iomem *addr)
+{
+	unsigned char val;
+
+	val = *(volatile unsigned char __force *)addr;
+	__sn_mf_a();
+	sn_dma_flush((unsigned long)addr);
+        return val;
+}
+
+static inline unsigned short
+___sn_readw (const volatile void __iomem *addr)
+{
+	unsigned short val;
+
+	val = *(volatile unsigned short __force *)addr;
+	__sn_mf_a();
+	sn_dma_flush((unsigned long)addr);
+        return val;
+}
+
+static inline unsigned int
+___sn_readl (const volatile void __iomem *addr)
+{
+	unsigned int val;
+
+	val = *(volatile unsigned int __force *)addr;
+	__sn_mf_a();
+	sn_dma_flush((unsigned long)addr);
+        return val;
+}
+
+static inline unsigned long
+___sn_readq (const volatile void __iomem *addr)
+{
+	unsigned long val;
+
+	val = *(volatile unsigned long __force *)addr;
+	__sn_mf_a();
+	sn_dma_flush((unsigned long)addr);
+        return val;
+}
 
 /*
- * Used to ensure write ordering (like mb(), but for I/O space)
+ * For generic and SN2 kernels, we have a set of fast access
+ * PIO macros.	These macros are provided on SN Platform
+ * because the normal inX and readX macros perform an
+ * additional task of flushing Post DMA request on the Bridge.
+ *
+ * These routines should be self explainatory.
  */
-extern void sn_mmiob(void);
 
-#endif /* _ASM_IA64_SN_IO_H */
+static inline unsigned int
+sn_inb_fast (unsigned long port)
+{
+	volatile unsigned char *addr = (unsigned char *)port;
+	unsigned char ret;
+
+	ret = *addr;
+	__sn_mf_a();
+	return ret;
+}
+
+static inline unsigned int
+sn_inw_fast (unsigned long port)
+{
+	volatile unsigned short *addr = (unsigned short *)port;
+	unsigned short ret;
+
+	ret = *addr;
+	__sn_mf_a();
+	return ret;
+}
+
+static inline unsigned int
+sn_inl_fast (unsigned long port)
+{
+	volatile unsigned int *addr = (unsigned int *)port;
+	unsigned int ret;
+
+	ret = *addr;
+	__sn_mf_a();
+	return ret;
+}
+
+static inline unsigned char
+___sn_readb_relaxed (const volatile void __iomem *addr)
+{
+	return *(volatile unsigned char __force *)addr;
+}
+
+static inline unsigned short
+___sn_readw_relaxed (const volatile void __iomem *addr)
+{
+	return *(volatile unsigned short __force *)addr;
+}
+
+static inline unsigned int
+___sn_readl_relaxed (const volatile void __iomem *addr)
+{
+	return *(volatile unsigned int __force *) addr;
+}
+
+static inline unsigned long
+___sn_readq_relaxed (const volatile void __iomem *addr)
+{
+	return *(volatile unsigned long __force *) addr;
+}
+
+struct pci_dev;
+
+static inline int
+sn_pci_set_vchan(struct pci_dev *pci_dev, unsigned long *addr, int vchan)
+{
+
+	if (vchan > 1) {
+		return -1;
+	}
+
+	if (!(*addr >> 32))	/* Using a mask here would be cleaner */
+		return 0;	/* but this generates better code */
+
+	if (vchan == 1) {
+		/* Set Bit 57 */
+		*addr |= (1UL << 57);
+	} else {
+		/* Clear Bit 57 */
+		*addr &= ~(1UL << 57);
+	}
+
+	return 0;
+}
+
+#endif	/* _ASM_SN_IO_H */
diff -Nru a/include/asm-ia64/sn/ioc4.h b/include/asm-ia64/sn/ioc4.h
--- a/include/asm-ia64/sn/ioc4.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,20 +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) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-
-#ifndef _ASM_IA64_SN_IOC4_H
-#define _ASM_IA64_SN_IOC4_H
-
-/*
- * Bytebus device space
- */
-#define IOC4_BYTEBUS_DEV0	0x80000L  /* Addressed using pci_bar0 */ 
-#define IOC4_BYTEBUS_DEV1	0xA0000L  /* Addressed using pci_bar0 */
-#define IOC4_BYTEBUS_DEV2	0xC0000L  /* Addressed using pci_bar0 */
-#define IOC4_BYTEBUS_DEV3	0xE0000L  /* Addressed using pci_bar0 */
-
-#endif	/* _ASM_IA64_SN_IOC4_H */
diff -Nru a/include/asm-ia64/sn/ioconfig_bus.h b/include/asm-ia64/sn/ioconfig_bus.h
--- a/include/asm-ia64/sn/ioconfig_bus.h	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,27 +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) 2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-
-#ifndef _ASM_IA64_SN_IOCONFIG_BUS_H
-#define _ASM_IA64_SN_IOCONFIG_BUS_H
-
-#define IOCONFIG_PCIBUS	"/boot/efi/ioconfig_pcibus"
-#define POUND_CHAR	'#'
-#define MAX_LINE_LEN	128
-#define MAXPATHLEN	128
-
-struct ioconfig_parm {
-	unsigned long ioconfig_activated;
-	unsigned long number;
-	void *buffer;
-};
-
-struct ascii_moduleid {
-	unsigned char   io_moduleid[8]; /* pci path name */
-};
-
-#endif	/* _ASM_IA64_SN_IOCONFIG_BUS_H */
diff -Nru a/include/asm-ia64/sn/ioerror.h b/include/asm-ia64/sn/ioerror.h
--- a/include/asm-ia64/sn/ioerror.h	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,193 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_IOERROR_H
-#define _ASM_IA64_SN_IOERROR_H
-
-#ifndef __ASSEMBLY__
-
-#include <linux/types.h>
-#include <asm/sn/types.h>
-
-/*
- * Macros defining the various Errors to be handled as part of
- * IO Error handling.
- */
-
-/*
- * List of errors to be handled by each subsystem.
- * "error_code" field will take one of these values.
- * The error code is built up of single bits expressing
- * our confidence that the error was that type; note
- * that it is possible to have a PIO or DMA error where
- * we don't know whether it was a READ or a WRITE, or
- * even a READ or WRITE error that we're not sure whether
- * to call a PIO or DMA.
- *
- * It is also possible to set both PIO and DMA, and possible
- * to set both READ and WRITE; the first may be nonsensical
- * but the second *could* be used to designate an access
- * that is known to be a read-modify-write cycle. It is
- * quite possible that nobody will ever use PIO|DMA or
- * READ|WRITE ... but being flexible is good.
- */
-#define	IOECODE_UNSPEC		0
-#define	IOECODE_READ		1
-#define	IOECODE_WRITE		2
-#define	IOECODE_PIO		4
-#define	IOECODE_DMA		8
-
-#define	IOECODE_PIO_READ	(IOECODE_PIO|IOECODE_READ)
-#define	IOECODE_PIO_WRITE	(IOECODE_PIO|IOECODE_WRITE)
-#define	IOECODE_DMA_READ	(IOECODE_DMA|IOECODE_READ)
-#define	IOECODE_DMA_WRITE	(IOECODE_DMA|IOECODE_WRITE)
-
-/* support older names, but try to move everything
- * to using new names that identify which package
- * controls their values ...
- */
-#define	PIO_READ_ERROR		IOECODE_PIO_READ
-#define	PIO_WRITE_ERROR		IOECODE_PIO_WRITE
-#define	DMA_READ_ERROR		IOECODE_DMA_READ
-#define	DMA_WRITE_ERROR		IOECODE_DMA_WRITE
-
-/*
- * List of error numbers returned by error handling sub-system.
- */
-
-#define	IOERROR_HANDLED		0	/* Error Properly handled.        */
-#define	IOERROR_NODEV		0x1	/* No such device attached        */
-#define	IOERROR_BADHANDLE	0x2	/* Received bad handle            */
-#define	IOERROR_BADWIDGETNUM	0x3	/* Bad widget number              */
-#define	IOERROR_BADERRORCODE	0x4	/* Bad error code passed in       */
-#define	IOERROR_INVALIDADDR	0x5	/* Invalid address specified      */
-
-#define	IOERROR_WIDGETLEVEL	0x6	/* Some failure at widget level    */
-#define	IOERROR_XTALKLEVEL	0x7
-
-#define	IOERROR_HWGRAPH_LOOKUP	0x8	/* hwgraph lookup failed for path  */
-#define	IOERROR_UNHANDLED	0x9	/* handler rejected error          */
-
-#define	IOERROR_PANIC		0xA	/* subsidiary handler has already
-					 * started decode: continue error
-					 * data dump, and panic from top
-					 * caller in error chain.
-					 */
-
-/*
- * IO errors at the bus/device driver level
- */
-
-#define	IOERROR_DEV_NOTFOUND	0x10	/* Device matching bus addr not found */
-#define	IOERROR_DEV_SHUTDOWN	0x11	/* Device has been shutdown        */
-
-/*
- * Type of address.
- * Indicates the direction of transfer that caused the error.
- */
-#define	IOERROR_ADDR_PIO	1	/* Error Address generated due to PIO */
-#define	IOERROR_ADDR_DMA	2	/* Error address generated due to DMA */
-
-/*
- * IO error structure.
- *
- * This structure would expand to hold the information retrieved from
- * all IO related error registers.
- *
- * This structure is defined to hold all system specific
- * information related to a single error.
- *
- * This serves a couple of purpose.
- *      - Error handling often involves translating one form of address to other
- *        form. So, instead of having different data structures at each level,
- *        we have a single structure, and the appropriate fields get filled in
- *        at each layer.
- *      - This provides a way to dump all error related information in any layer
- *        of erorr handling (debugging aid).
- *
- * A second possibility is to allow each layer to define its own error
- * data structure, and fill in the proper fields. This has the advantage
- * of isolating the layers.
- * A big concern is the potential stack usage (and overflow), if each layer
- * defines these structures on stack (assuming we don't want to do kmalloc.
- *
- * Any layer wishing to pass extra information to a layer next to it in
- * error handling hierarchy, can do so as a separate parameter.
- */
-
-typedef struct io_error_s {
-    /* Bit fields indicating which structure fields are valid */
-    union {
-	struct {
-	    unsigned                ievb_errortype:1;
-	    unsigned                ievb_widgetnum:1;
-	    unsigned                ievb_widgetdev:1;
-	    unsigned                ievb_srccpu:1;
-	    unsigned                ievb_srcnode:1;
-	    unsigned                ievb_errnode:1;
-	    unsigned                ievb_sysioaddr:1;
-	    unsigned                ievb_xtalkaddr:1;
-	    unsigned                ievb_busspace:1;
-	    unsigned                ievb_busaddr:1;
-	    unsigned                ievb_vaddr:1;
-	    unsigned                ievb_memaddr:1;
-	    unsigned		    ievb_epc:1;
-	    unsigned		    ievb_ef:1;
-	    unsigned		    ievb_tnum:1;
-	} iev_b;
-	unsigned                iev_a;
-    } ie_v;
-
-    short                   ie_errortype;	/* error type: extra info about error */
-    short                   ie_widgetnum;	/* Widget number that's in error */
-    short                   ie_widgetdev;	/* Device within widget in error */
-    cpuid_t                 ie_srccpu;	/* CPU on srcnode generating error */
-    cnodeid_t               ie_srcnode;		/* Node which caused the error   */
-    cnodeid_t               ie_errnode;		/* Node where error was noticed  */
-    iopaddr_t               ie_sysioaddr;	/* Sys specific IO address       */
-    iopaddr_t               ie_xtalkaddr;	/* Xtalk (48bit) addr of Error   */
-    iopaddr_t               ie_busspace;	/* Bus specific address space    */
-    iopaddr_t               ie_busaddr;		/* Bus specific address          */
-    caddr_t                 ie_vaddr;	/* Virtual address of error      */
-    paddr_t                 ie_memaddr;		/* Physical memory address       */
-    caddr_t		    ie_epc;		/* pc when error reported	 */
-    caddr_t		    ie_ef;		/* eframe when error reported	 */
-    short		    ie_tnum;		/* Xtalk TNUM field */
-} ioerror_t;
-
-#define	IOERROR_INIT(e)		do { (e)->ie_v.iev_a = 0; } while (0)
-#define	IOERROR_SETVALUE(e,f,v)	do { (e)->ie_ ## f = (v); (e)->ie_v.iev_b.ievb_ ## f = 1; } while (0)
-#define	IOERROR_FIELDVALID(e,f)	((unsigned long long)((e)->ie_v.iev_b.ievb_ ## f) != (unsigned long long) 0)
-#define	IOERROR_NOGETVALUE(e,f)	(ASSERT(IOERROR_FIELDVALID(e,f)), ((e)->ie_ ## f))
-#define	IOERROR_GETVALUE(p,e,f)	ASSERT(IOERROR_FIELDVALID(e,f)); p=((e)->ie_ ## f)
-
-/* hub code likes to call the SysAD address "hubaddr" ... */
-#define	ie_hubaddr	ie_sysioaddr
-#define	ievb_hubaddr	ievb_sysioaddr
-#endif
-
-/*
- * Error handling Modes.
- */
-typedef enum {
-    MODE_DEVPROBE,		/* Probing mode. Errors not fatal */
-    MODE_DEVERROR,		/* Error while system is running */
-    MODE_DEVUSERERROR,		/* Device Error created due to user mode access */
-    MODE_DEVREENABLE		/* Reenable pass                */
-} ioerror_mode_t;
-
-
-typedef int             error_handler_f(void *, int, ioerror_mode_t, ioerror_t *);
-typedef void           *error_handler_arg_t;
-
-#ifdef	ERROR_DEBUG
-#define	IOERR_PRINTF(x)	(x)
-#else
-#define	IOERR_PRINTF(x)
-#endif				/* ERROR_DEBUG */
-
-#endif /* _ASM_IA64_SN_IOERROR_H */
diff -Nru a/include/asm-ia64/sn/ioerror_handling.h b/include/asm-ia64/sn/ioerror_handling.h
--- a/include/asm-ia64/sn/ioerror_handling.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,159 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_IOERROR_HANDLING_H
-#define _ASM_IA64_SN_IOERROR_HANDLING_H
-
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-
-#ifdef __KERNEL__
-
-/*
- * Basic types required for io error handling interfaces.
- */
-
-/*
- * Return code from the io error handling interfaces.
- */
-
-enum error_return_code_e {
-	/* Success */
-	ERROR_RETURN_CODE_SUCCESS,
-
-	/* Unknown failure */
-	ERROR_RETURN_CODE_GENERAL_FAILURE,
-
-	/* Nth error noticed while handling the first error */
-	ERROR_RETURN_CODE_NESTED_CALL,
-
-	/* State of the vertex is invalid */
-	ERROR_RETURN_CODE_INVALID_STATE,
-
-	/* Invalid action */
-	ERROR_RETURN_CODE_INVALID_ACTION,
-
-	/* Valid action but not cannot set it */
-	ERROR_RETURN_CODE_CANNOT_SET_ACTION,
-
-	/* Valid action but not possible for the current state */
-	ERROR_RETURN_CODE_CANNOT_PERFORM_ACTION,
-
-	/* Valid state but cannot change the state of the vertex to it */
-	ERROR_RETURN_CODE_CANNOT_SET_STATE,
-
-	/* ??? */
-	ERROR_RETURN_CODE_DUPLICATE,
-
-	/* Reached the root of the system critical graph */
-	ERROR_RETURN_CODE_SYS_CRITICAL_GRAPH_BEGIN,
-
-	/* Reached the leaf of the system critical graph */
-	ERROR_RETURN_CODE_SYS_CRITICAL_GRAPH_ADD,
-
-	/* Cannot shutdown the device in hw/sw */
-	ERROR_RETURN_CODE_SHUTDOWN_FAILED,
-
-	/* Cannot restart the device in hw/sw */
-	ERROR_RETURN_CODE_RESET_FAILED,
-
-	/* Cannot failover the io subsystem */
-	ERROR_RETURN_CODE_FAILOVER_FAILED,
-
-	/* No Jump Buffer exists */
-	ERROR_RETURN_CODE_NO_JUMP_BUFFER
-};
-
-typedef uint64_t  error_return_code_t;
-
-/*
- * State of the vertex during error handling.
- */
-enum error_state_e {
-	/* Ignore state */
-	ERROR_STATE_IGNORE,
-
-	/* Invalid state */
-	ERROR_STATE_NONE,
-
-	/* Trying to decipher the error bits */
-	ERROR_STATE_LOOKUP,
-
-	/* Trying to carryout the action decided upon after
-	 * looking at the error bits 
-	 */
-	ERROR_STATE_ACTION,
-
-	/* Donot allow any other operations to this vertex from
-	 * other parts of the kernel. This is also used to indicate
-	 * that the device has been software shutdown.
-	 */
-	ERROR_STATE_SHUTDOWN,
-
-	/* This is a transitory state when no new requests are accepted
-	 * on behalf of the device. This is usually used when trying to
-	 * quiesce all the outstanding operations and preparing the
-	 * device for a failover / shutdown etc.
-	 */
-	ERROR_STATE_SHUTDOWN_IN_PROGRESS,
-
-	/* This is the state when there is absolutely no activity going
-	 * on wrt device.
-	 */
-	ERROR_STATE_SHUTDOWN_COMPLETE,
-	
-	/* This is the state when the device has issued a retry. */
-	ERROR_STATE_RETRY,
-
-	/* This is the normal state. This can also be used to indicate
-	 * that the device has been software-enabled after software-
-	 * shutting down previously.
-	 */
-	ERROR_STATE_NORMAL
-	
-};
-
-typedef uint64_t  error_state_t;
-
-/*
- * Generic error classes. This is used to classify errors after looking
- * at the error bits and helpful in deciding on the action.
- */
-enum error_class_e {
-	/* Unclassified error */
-	ERROR_CLASS_UNKNOWN,
-
-	/* LLP transmit error */
-	ERROR_CLASS_LLP_XMIT,
-
-	/* LLP receive error */
-	ERROR_CLASS_LLP_RECV,
-
-	/* Credit error */
-	ERROR_CLASS_CREDIT,
-
-	/* Timeout error */
-	ERROR_CLASS_TIMEOUT,
-
-	/* Access error */
-	ERROR_CLASS_ACCESS,
-
-	/* System coherency error */
-	ERROR_CLASS_SYS_COHERENCY,
-
-	/* Bad data error (ecc / parity etc) */
-	ERROR_CLASS_BAD_DATA,
-
-	/* Illegal request packet */
-	ERROR_CLASS_BAD_REQ_PKT,
-	
-	/* Illegal response packet */
-	ERROR_CLASS_BAD_RESP_PKT
-};
-
-#endif /* __KERNEL__ */
-#endif /* _ASM_IA64_SN_IOERROR_HANDLING_H */
diff -Nru a/include/asm-ia64/sn/iograph.h b/include/asm-ia64/sn/iograph.h
--- a/include/asm-ia64/sn/iograph.h	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,137 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_IOGRAPH_H
-#define _ASM_IA64_SN_IOGRAPH_H
-
-#include <asm/sn/xtalk/xbow.h>	/* For get MAX_PORT_NUM */
-
-/*
- * During initialization, platform-dependent kernel code establishes some
- * basic elements of the hardware graph.  This file contains edge and
- * info labels that are used across various platforms -- it serves as an
- * ad-hoc registry.
- */
-
-/* edges names */
-#define EDGE_LBL_BUS			"bus"
-#define EDGE_LBL_CONN			".connection"
-#define EDGE_LBL_GUEST			".guest"	/* For IOC3 */
-#define EDGE_LBL_HOST			".host"		/* For IOC3 */
-#define EDGE_LBL_PERFMON		"mon"
-#define EDGE_LBL_USRPCI			"usrpci"
-#define EDGE_LBL_BLOCK			"block"
-#define EDGE_LBL_BOARD			"board"
-#define EDGE_LBL_CHAR			"char"
-#define EDGE_LBL_CONTROLLER		"controller"
-#define EDGE_LBL_CPU			"cpu"
-#define EDGE_LBL_CPUNUM			"cpunum"
-#define EDGE_LBL_DIRECT			"direct"
-#define EDGE_LBL_DISABLED		"disabled"
-#define EDGE_LBL_DISK			"disk"
-#define EDGE_LBL_HUB			"hub"		/* For SN0 */
-#define EDGE_LBL_HW			"hw"
-#define EDGE_LBL_INTERCONNECT		"link"
-#define EDGE_LBL_IO			"io"
-#define EDGE_LBL_LUN                    "lun"
-#define EDGE_LBL_LINUX                  "linux"
-#define EDGE_LBL_LINUX_BUS              EDGE_LBL_LINUX "/bus/pci-x"
-#define EDGE_LBL_MACHDEP                "machdep"       /* Platform depedent devices */
-#define EDGE_LBL_MASTER			".master"
-#define EDGE_LBL_MEMORY			"memory"
-#define EDGE_LBL_META_ROUTER		"metarouter"
-#define EDGE_LBL_MIDPLANE		"midplane"
-#define EDGE_LBL_MODULE			"module"
-#define EDGE_LBL_NODE			"node"
-#define EDGE_LBL_NODENUM		"nodenum"
-#define EDGE_LBL_NVRAM			"nvram"
-#define EDGE_LBL_PARTITION		"partition"
-#define EDGE_LBL_PCI			"pci"
-#define EDGE_LBL_PCIX			"pci-x"
-#define EDGE_LBL_PCIX_0			EDGE_LBL_PCIX "/0"
-#define EDGE_LBL_PCIX_1			EDGE_LBL_PCIX "/1"
-#define EDGE_LBL_AGP			"agp"
-#define EDGE_LBL_AGP_0			EDGE_LBL_AGP "/0"
-#define EDGE_LBL_AGP_1			EDGE_LBL_AGP "/1"
-#define EDGE_LBL_PORT			"port"
-#define EDGE_LBL_PROM			"prom"
-#define EDGE_LBL_RACK			"rack"
-#define EDGE_LBL_RDISK			"rdisk"
-#define EDGE_LBL_REPEATER_ROUTER	"repeaterrouter"
-#define EDGE_LBL_ROUTER			"router"
-#define EDGE_LBL_RPOS			"bay"		/* Position in rack */
-#define EDGE_LBL_SCSI			"scsi"
-#define EDGE_LBL_SCSI_CTLR		"scsi_ctlr"
-#define EDGE_LBL_SLOT			"slot"
-#define EDGE_LBL_TARGET                 "target"
-#define EDGE_LBL_UNKNOWN		"unknown"
-#define EDGE_LBL_XBOW			"xbow"
-#define	EDGE_LBL_XIO			"xio"
-#define EDGE_LBL_XSWITCH		".xswitch"
-#define EDGE_LBL_XTALK			"xtalk"
-#define EDGE_LBL_XWIDGET		"xwidget"
-#define EDGE_LBL_ELSC			"elsc"
-#define EDGE_LBL_L1			"L1"
-#define EDGE_LBL_XPLINK			"xplink" 	/* Cross partition */
-#define	EDGE_LBL_XPLINK_NET		"net" 		/* XP network devs */
-#define	EDGE_LBL_XPLINK_RAW		"raw"		/* XP Raw devs */
-#define EDGE_LBL_SLAB			"slab"		/* Slab of a module */
-#define	EDGE_LBL_XPLINK_KERNEL		"kernel"	/* XP kernel devs */
-#define	EDGE_LBL_XPLINK_ADMIN		"admin"	   	/* Partition admin */
-#define EDGE_LBL_IOBRICK		"iobrick"
-#define EDGE_LBL_PXBRICK		"PXbrick"
-#define EDGE_LBL_OPUSBRICK		"onboardio"
-#define EDGE_LBL_IXBRICK		"IXbrick"
-#define EDGE_LBL_CGBRICK		"CGbrick"
-#define EDGE_LBL_CPUBUS			"cpubus"	/* CPU Interfaces (SysAd) */
-
-/* vertex info labels in hwgraph */
-#define INFO_LBL_CNODEID		"_cnodeid"
-#define INFO_LBL_CONTROLLER_NAME	"_controller_name"
-#define INFO_LBL_CPUBUS			"_cpubus"
-#define INFO_LBL_CPUID			"_cpuid"
-#define INFO_LBL_CPU_INFO		"_cpu"
-#define INFO_LBL_DETAIL_INVENT		"_detail_invent" /* inventory data*/
-#define INFO_LBL_DIAGVAL		"_diag_reason"   /* Reason disabled */
-#define INFO_LBL_DRIVER			"_driver"	/* points to attached device_driver_t */
-#define INFO_LBL_ELSC			"_elsc"
-#define	INFO_LBL_SUBCH			"_subch"	/* system controller subchannel */
-#define INFO_LBL_HUB_INFO		"_hubinfo"
-#define INFO_LBL_HWGFSLIST		"_hwgfs_list"
-#define INFO_LBL_TRAVERSE		"_hwg_traverse" /* hwgraph traverse function */
-#define INFO_LBL_MODULE_INFO		"_module"	/* module data ptr */
-#define INFO_LBL_MDPERF_DATA		"_mdperf"	/* mdperf monitoring*/
-#define INFO_LBL_NODE_INFO		"_node"
-#define	INFO_LBL_PCIBR_HINTS		"_pcibr_hints"
-#define INFO_LBL_PCIIO			"_pciio"
-#define INFO_LBL_PFUNCS			"_pciio_ops"	/* ops vector for gio providers */
-#define INFO_LBL_PERMISSIONS		"_permissions"	/* owner, uid, gid */
-#define INFO_LBL_ROUTER_INFO		"_router"
-#define INFO_LBL_SUBDEVS		"_subdevs"	/* subdevice enable bits */
-#define INFO_LBL_XSWITCH		"_xswitch"
-#define INFO_LBL_XSWITCH_ID		"_xswitch_id"
-#define INFO_LBL_XSWITCH_VOL		"_xswitch_volunteer"
-#define INFO_LBL_XFUNCS			"_xtalk_ops"	/* ops vector for gio providers */
-#define INFO_LBL_XWIDGET		"_xwidget"
-
-
-#ifdef __KERNEL__
-void init_all_devices(void);
-#endif /* __KERNEL__ */
-
-int io_brick_map_widget(int, int);
-
-/*
- * Map a brick's widget number to a meaningful int
- */
-
-struct io_brick_map_s {
-    int                 ibm_type;                  /* brick type */
-    int                 ibm_map_wid[MAX_PORT_NUM]; /* wid to int map */
-};
-
-#endif /* _ASM_IA64_SN_IOGRAPH_H */
diff -Nru a/include/asm-ia64/sn/klconfig.h b/include/asm-ia64/sn/klconfig.h
--- a/include/asm-ia64/sn/klconfig.h	2004-12-24 13:36:33 -08:00
+++ b/include/asm-ia64/sn/klconfig.h	2004-12-24 13:37:44 -08:00
@@ -5,7 +5,7 @@
  *
  * Derived from IRIX <sys/SN/klconfig.h>.
  *
- * Copyright (C) 1992-1997,1999,2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (C) 1992-1997,1999,2001-2004 Silicon Graphics, Inc.  All Rights Reserved.
  * Copyright (C) 1999 by Ralf Baechle
  */
 #ifndef _ASM_IA64_SN_KLCONFIG_H
@@ -17,145 +17,20 @@
  * components found on the BOARDs.
  */
 
-/*
- * WARNING:
- *	Certain assembly language routines (notably xxxxx.s) in the IP27PROM 
- *	will depend on the format of the data structures in this file.  In 
- *      most cases, rearranging the fields can seriously break things.   
- *      Adding fields in the beginning or middle can also break things.
- *      Add fields if necessary, to the end of a struct in such a way
- *      that offsets of existing fields do not change.
- */
-
-#include <linux/types.h>
-#include <asm/sn/types.h>
-#include <asm/sn/slotnum.h>
-#include <asm/sn/router.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/vector.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/kldir.h>
-#include <asm/sn/sn_fru.h>
-#include <asm/sn/sn2/shub_md.h>
-#include <asm/sn/geo.h>
-
-#define KLCFGINFO_MAGIC	0xbeedbabe
-
 typedef s32 klconf_off_t;
 
-#define	MAX_MODULE_ID		255
-#define SIZE_PAD		4096 /* 4k padding for structures */
-/* 
- * 1 NODE brick, 3 Router bricks (1 local, 1 meta, 1 repeater),
- * 6 XIO Widgets, 1 Xbow, 1 gfx
- */
-#define MAX_SLOTS_PER_NODE	(1 + 3 + 6 + 1 + 1) 
-
-/* XXX if each node is guranteed to have some memory */
-
-#define MAX_PCI_DEVS		8
-
-/* lboard_t->brd_flags fields */
-/* All bits in this field are currently used. Try the pad fields if
-   you need more flag bits */
-
-#define ENABLE_BOARD 		0x01
-#define FAILED_BOARD  		0x02
-#define DUPLICATE_BOARD 	0x04    /* Boards like midplanes/routers which
-                                   	   are discovered twice. Use one of them */
-#define VISITED_BOARD		0x08	/* Used for compact hub numbering. */
-#define LOCAL_MASTER_IO6	0x10    /* master io6 for that node */
-#define KLTYPE_IOBRICK_XBOW	(KLCLASS_MIDPLANE | 0x2)
-
-/* klinfo->flags fields */
-
-#define KLINFO_ENABLE 		0x01    /* This component is enabled */
-#define KLINFO_FAILED   	0x02 	/* This component failed */
-#define KLINFO_DEVICE   	0x04 	/* This component is a device */
-#define KLINFO_VISITED  	0x08 	/* This component has been visited */
-#define KLINFO_CONTROLLER   	0x10 	/* This component is a device controller */
-#define KLINFO_INSTALL   	0x20  	/* Install a driver */
-#define	KLINFO_HEADLESS		0x40	/* Headless (or hubless) component */
-
-/* Structures to manage various data storage areas */
-/* The numbers must be contiguous since the array index i
-   is used in the code to allocate various areas. 
-*/
-
-#define BOARD_STRUCT 		0
-#define COMPONENT_STRUCT 	1
-#define ERRINFO_STRUCT 		2
-#define KLMALLOC_TYPE_MAX 	(ERRINFO_STRUCT + 1)
-#define DEVICE_STRUCT 		3
-
-
-typedef struct console_s {
-	unsigned long 	uart_base;
-	unsigned long 	config_base;
-	unsigned long 	memory_base;
-	short		baud;
-	short		flag;
-	int		type;
-	nasid_t		nasid;
-	char		wid;
-	char 		npci;
-	nic_t		baseio_nic;
-} console_t;
-
-typedef struct klc_malloc_hdr {
-        klconf_off_t km_base;
-        klconf_off_t km_limit;
-        klconf_off_t km_current;
-} klc_malloc_hdr_t;
 
 /* Functions/macros needed to use this structure */
 
 typedef struct kl_config_hdr {
-	u64		ch_magic;	/* set this to KLCFGINFO_MAGIC */
-	u32		ch_version;    /* structure version number */
-	klconf_off_t	ch_malloc_hdr_off; /* offset of ch_malloc_hdr */
-	klconf_off_t	ch_cons_off;       /* offset of ch_cons */
+	char		pad[20];
 	klconf_off_t	ch_board_info;	/* the link list of boards */
-	console_t	ch_cons_info;	/* address info of the console */
-	klc_malloc_hdr_t ch_malloc_hdr[KLMALLOC_TYPE_MAX];
-	confidence_t	ch_sw_belief;	/* confidence that software is bad*/
-	confidence_t	ch_sn0net_belief; /* confidence that sn0net is bad */
+	char		pad0[88];
 } kl_config_hdr_t;
 
 
-#define KL_CONFIG_HDR(_nasid) 	((kl_config_hdr_t *)(KLCONFIG_ADDR(_nasid)))
-
 #define NODE_OFFSET_TO_LBOARD(nasid,off)        (lboard_t*)(NODE_CAC_BASE(nasid) + (off))
 
-#define KL_CONFIG_INFO(_nasid) root_lboard[nasid_to_cnodeid(_nasid)]
-
-/* --- New Macros for the changed kl_config_hdr_t structure --- */
-
-#define PTR_CH_CONS_INFO(_k)	((console_t *)\
-			((unsigned long)_k + (_k->ch_cons_off)))
-
-#define KL_CONFIG_CH_CONS_INFO(_n)   PTR_CH_CONS_INFO(KL_CONFIG_HDR(_n))
-
-/* ------------------------------------------------------------- */
-
-#define KL_CONFIG_DUPLICATE_BOARD(_brd)	((_brd)->brd_flags & DUPLICATE_BOARD)
-
-#define XBOW_PORT_TYPE_HUB(_xbowp, _link) 	\
-               ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_HUB)
-#define XBOW_PORT_TYPE_IO(_xbowp, _link) 	\
-               ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_IO)
-
-#define XBOW_PORT_IS_ENABLED(_xbowp, _link) 	\
-               ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_ENABLE)
-#define XBOW_PORT_NASID(_xbowp, _link) 	\
-               ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_nasid)
-
-#define XBOW_PORT_IO     0x1
-#define XBOW_PORT_HUB    0x2
-#define XBOW_PORT_ENABLE 0x4
-
 /*
  * The KLCONFIG area is organized as a LINKED LIST of BOARDs. A BOARD
  * can be either 'LOCAL' or 'REMOTE'. LOCAL means it is attached to 
@@ -248,6 +123,7 @@
  * The data structures below define the above concepts.
  */
 
+
 /*
  * BOARD classes
  */
@@ -261,54 +137,40 @@
 #define KLCLASS_ROUTER	0x30             /* Router board */
 #define KLCLASS_MIDPLANE 0x40            /* We need to treat this as a board
                                             so that we can record error info */
-#define KLCLASS_GFX	0x50		/* graphics boards */
-
-#define KLCLASS_PSEUDO_GFX	0x60	/* HDTV type cards that use a gfx
-					 * hw ifc to xtalk and are not gfx
-					 * class for sw purposes */
-
 #define KLCLASS_IOBRICK	0x70		/* IP35 iobrick */
-
 #define KLCLASS_MAX	8		/* Bump this if a new CLASS is added */
-#define KLTYPE_MAX	11		/* Bump this if a new CLASS is added */
-
-#define KLCLASS_UNKNOWN	0xf0
 
 #define KLCLASS(_x) ((_x) & KLCLASS_MASK)
 
+
 /*
  * board types
  */
 
 #define KLTYPE_MASK	0x0f
-#define KLTYPE_NONE	0x00
-#define KLTYPE_EMPTY	0x00
+#define KLTYPE(_x)      ((_x) & KLTYPE_MASK)
 
-#define KLTYPE_WEIRDCPU (KLCLASS_CPU | 0x0)
 #define KLTYPE_SNIA	(KLCLASS_CPU | 0x1)
+#define KLTYPE_TIO	(KLCLASS_CPU | 0x2)
 
 #define KLTYPE_ROUTER     (KLCLASS_ROUTER | 0x1)
 #define KLTYPE_META_ROUTER (KLCLASS_ROUTER | 0x3)
 #define KLTYPE_REPEATER_ROUTER (KLCLASS_ROUTER | 0x4)
 
+#define KLTYPE_IOBRICK_XBOW	(KLCLASS_MIDPLANE | 0x2)
+
 #define KLTYPE_IOBRICK		(KLCLASS_IOBRICK | 0x0)
 #define KLTYPE_NBRICK		(KLCLASS_IOBRICK | 0x4)
 #define KLTYPE_PXBRICK		(KLCLASS_IOBRICK | 0x6)
 #define KLTYPE_IXBRICK		(KLCLASS_IOBRICK | 0x7)
 #define KLTYPE_CGBRICK		(KLCLASS_IOBRICK | 0x8)
 #define KLTYPE_OPUSBRICK	(KLCLASS_IOBRICK | 0x9)
+#define KLTYPE_SABRICK          (KLCLASS_IOBRICK | 0xa)
+#define KLTYPE_IABRICK		(KLCLASS_IOBRICK | 0xb)
+#define KLTYPE_PABRICK          (KLCLASS_IOBRICK | 0xc)
+#define KLTYPE_GABRICK		(KLCLASS_IOBRICK | 0xd)
 
 
-/* The value of type should be more than 8 so that hinv prints
- * out the board name from the NIC string. For values less than
- * 8 the name of the board needs to be hard coded in a few places.
- * When bringup started nic names had not standardized and so we
- * had to hard code. (For people interested in history.) 
- */
-#define KLTYPE_UNKNOWN	(KLCLASS_UNKNOWN | 0xf)
-
-#define KLTYPE(_x) 	((_x) & KLTYPE_MASK)
-
 /* 
  * board structures
  */
@@ -337,7 +199,7 @@
 	klconf_off_t 	brd_errinfo;      /* Board's error information */
 	struct lboard_s *brd_parent;	  /* Logical parent for this brd */
 	char            pad0[4];
-	confidence_t	brd_confidence;	  /* confidence that the board is bad */
+	unsigned char	brd_confidence;	  /* confidence that the board is bad */
 	nasid_t		brd_owner;        /* who owns this board */
 	unsigned char 	brd_nic_flags;    /* To handle 8 more NICs */
 	char		pad1[24];	  /* future expansion */
@@ -346,18 +208,7 @@
 	klconf_off_t	brd_next_same;    /* Next BOARD with same nasid */
 } lboard_t;
 
-/*
- *	Make sure we pass back the calias space address for local boards.
- *	klconfig board traversal and error structure extraction defines.
- */
-
-#define BOARD_SLOT(_brd)	((_brd)->brd_slot)
-
-#define KLCF_CLASS(_brd)	KLCLASS((_brd)->brd_type)
-#define KLCF_TYPE(_brd)		KLTYPE((_brd)->brd_type)
 #define KLCF_NUM_COMPS(_brd)	((_brd)->brd_numcompts)
-#define KLCF_MODULE_ID(_brd)	((_brd)->brd_module)
-
 #define NODE_OFFSET_TO_KLINFO(n,off)    ((klinfo_t*) TO_NODE_CAC(n,off))
 #define KLCF_NEXT(_brd)         \
         ((_brd)->brd_next_same ?     \
@@ -369,10 +220,6 @@
                 ((((_brd)->brd_compts[(_ndx)]) == 0) ? 0 : \
 			(NODE_OFFSET_TO_KLINFO(NASID_GET(_brd), (_brd)->brd_compts[(_ndx)])))
 
-#define KLCF_COMP_TYPE(_comp)	((_comp)->struct_type)
-#define KLCF_BRIDGE_W_ID(_comp)	((_comp)->physid)	/* Widget ID */
-
-
 
 /*
  * Generic info structure. This stores common info about a 
@@ -401,302 +248,25 @@
         unsigned short  pad4;             /* klbri_t */
 } klinfo_t ;
 
-#define KLCONFIG_INFO_ENABLED(_i)	((_i)->flags & KLINFO_ENABLE)
-/*
- * Component structures.
- * Following are the currently identified components:
- * 	CPU, HUB, MEM_BANK, 
- * 	XBOW(consists of 16 WIDGETs, each of which can be HUB or GRAPHICS or BRIDGE)
- * 	BRIDGE, IOC3, SuperIO, SCSI, FDDI 
- * 	ROUTER
- * 	GRAPHICS
- */
-#define KLSTRUCT_UNKNOWN	0
-#define KLSTRUCT_CPU  		1
-#define KLSTRUCT_HUB  		2
-#define KLSTRUCT_MEMBNK 	3
-#define KLSTRUCT_XBOW 		4
-#define KLSTRUCT_BRI 		5
-#define KLSTRUCT_ROU		9
-#define KLSTRUCT_GFX 		10
-#define KLSTRUCT_SCSI 		11
-#define KLSTRUCT_DISK 		14
-#define KLSTRUCT_CDROM 		16
-
-#define KLSTRUCT_FIBERCHANNEL 	25
-#define KLSTRUCT_MOD_SERIAL_NUM 26
-#define KLSTRUCT_QLFIBRE        32
-#define KLSTRUCT_1394           33
-#define KLSTRUCT_USB		34
-#define KLSTRUCT_USBKBD		35
-#define KLSTRUCT_USBMS		36
-#define KLSTRUCT_SCSI_CTLR	37
-#define KLSTRUCT_PEBRICK	38
-#define KLSTRUCT_GIGE           39
-#define KLSTRUCT_IDE		40
-#define KLSTRUCT_IOC4		41
-#define KLSTRUCT_IOC4UART	42
-#define KLSTRUCT_IOC4_TTY	43
-#define KLSTRUCT_IOC4PCKM	44
-#define KLSTRUCT_IOC4MS		45
-#define KLSTRUCT_IOC4_ATA	46
-#define KLSTRUCT_PCIGFX		47
-
-
-/*
- * The port info in ip27_cfg area translates to a lboart_t in the 
- * KLCONFIG area. But since KLCONFIG does not use pointers, lboart_t
- * is stored in terms of a nasid and a offset from start of KLCONFIG 
- * area  on that nasid.
- */
-typedef struct klport_s {
-	nasid_t		port_nasid;
-	unsigned char	port_flag;
-	klconf_off_t	port_offset;
-	short		port_num;
-} klport_t;
-
-typedef struct klcpu_s {                          /* CPU */
-	klinfo_t 	cpu_info;
-	unsigned short 	cpu_prid;	/* Processor PRID value */
-	unsigned short 	cpu_fpirr;	/* FPU IRR value */
-    	unsigned short 	cpu_speed;	/* Speed in MHZ */
-    	unsigned short 	cpu_scachesz;	/* secondary cache size in MB */
-    	unsigned short 	cpu_scachespeed;/* secondary cache speed in MHz */
-	unsigned long	pad;
-} klcpu_t ;
-
-#define CPU_STRUCT_VERSION   2
-
-typedef struct klhub_s {			/* HUB */
-	klinfo_t 	hub_info;
-	unsigned int 	hub_flags;		/* PCFG_HUB_xxx flags */
-#define MAX_NI_PORTS                    2
-	klport_t	hub_port[MAX_NI_PORTS + 1];/* hub is connected to this */
-	nic_t		hub_box_nic;		/* nic of containing box */
-	klconf_off_t	hub_mfg_nic;		/* MFG NIC string */
-	u64		hub_speed;		/* Speed of hub in HZ */
-	moduleid_t	hub_io_module;		/* attached io module */
-	unsigned long	pad;
-} klhub_t ;
-
-typedef struct klhub_uart_s {			/* HUB */
-	klinfo_t 	hubuart_info;
-	unsigned int 	hubuart_flags;		/* PCFG_HUB_xxx flags */
-	nic_t		hubuart_box_nic;	/* nic of containing box */
-	unsigned long	pad;
-} klhub_uart_t ;
-
-#define MEMORY_STRUCT_VERSION   2
-
-typedef struct klmembnk_s {			/* MEMORY BANK */
-	klinfo_t 	membnk_info;
-    	short 		membnk_memsz;		/* Total memory in megabytes */
-	short		membnk_dimm_select; /* bank to physical addr mapping*/
-	short		membnk_bnksz[MD_MEM_BANKS]; /* Memory bank sizes */
-	short		membnk_attr;
-	unsigned long	pad;
-} klmembnk_t ;
-
-#define MAX_SERIAL_NUM_SIZE 10
-
-typedef struct klmod_serial_num_s {
-      klinfo_t        snum_info;
-      union {
-              char snum_str[MAX_SERIAL_NUM_SIZE];
-              unsigned long long       snum_int;
-      } snum;
-      unsigned long   pad;
-} klmod_serial_num_t;
-
-/* Macros needed to access serial number structure in lboard_t.
-   Hard coded values are necessary since we cannot treat 
-   serial number struct as a component without losing compatibility
-   between prom versions. */
-
-#define GET_SNUM_COMP(_l) 	((klmod_serial_num_t *)\
-				KLCF_COMP(_l, _l->brd_numcompts))
-
-#define MAX_XBOW_LINKS 16
-
-typedef struct klxbow_s {                          /* XBOW */
-	klinfo_t 	xbow_info ;
-    	klport_t	xbow_port_info[MAX_XBOW_LINKS] ; /* Module number */
-        int		xbow_master_hub_link;
-        /* type of brd connected+component struct ptr+flags */
-	unsigned long	pad;
-} klxbow_t ;
-
-#define MAX_PCI_SLOTS 8
-
-typedef struct klpci_device_s {
-	s32	pci_device_id;	/* 32 bits of vendor/device ID. */
-	s32	pci_device_pad;	/* 32 bits of padding. */
-} klpci_device_t;
-
-#define BRIDGE_STRUCT_VERSION	2
-
-typedef struct klbri_s {                          /* BRIDGE */
-	klinfo_t 	bri_info ;
-    	unsigned char	bri_eprominfo ;    /* IO6prom connected to bridge */
-    	unsigned char	bri_bustype ;      /* PCI/VME BUS bridge/GIO */
-    	u64	    	*pci_specific  ;    /* PCI Board config info */
-	klpci_device_t	bri_devices[MAX_PCI_DEVS] ;	/* PCI IDs */
-	klconf_off_t	bri_mfg_nic ;
-	unsigned long	pad;
-} klbri_t ;
-
-#define ROUTER_VECTOR_VERS	2
-
-/* XXX - Don't we need the number of ports here?!? */
-typedef struct klrou_s {                          /* ROUTER */
-	klinfo_t 	rou_info ;
-	unsigned int	rou_flags ;           /* PCFG_ROUTER_xxx flags */
-	nic_t		rou_box_nic ;         /* nic of the containing module */
-    	klport_t 	rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */
-	klconf_off_t	rou_mfg_nic ;     /* MFG NIC string */
-	u64	rou_vector;	  /* vector from master node */
-	unsigned long   pad;
-} klrou_t ;
-
-/*
- *  Graphics Controller/Device
- *
- *  (IP27/IO6) Prom versions 6.13 (and 6.5.1 kernels) and earlier
- *  used a couple different structures to store graphics information.
- *  For compatibility reasons, the newer data structure preserves some
- *  of the layout so that fields that are used in the old versions remain
- *  in the same place (with the same info).  Determination of what version
- *  of this structure we have is done by checking the cookie field.
- */
-#define KLGFX_COOKIE	0x0c0de000
-
-typedef struct klgfx_s {		/* GRAPHICS Device */
-	klinfo_t 	gfx_info;
-	klconf_off_t    old_gndevs;	/* for compatibility with older proms */
-	klconf_off_t    old_gdoff0;	/* for compatibility with older proms */
-	unsigned int	cookie;		/* for compatibility with older proms */
-	unsigned int	moduleslot;
-	struct klgfx_s	*gfx_next_pipe;
-	u64		*gfx_specific;
-	klconf_off_t    pad0;		/* for compatibility with older proms */
-	klconf_off_t    gfx_mfg_nic;
-	unsigned long	pad;
-} klgfx_t;
 
-#define MAX_SCSI_DEVS 16
+static inline lboard_t *find_lboard_any(lboard_t * start, unsigned char brd_type)
+{
+        /* Search all boards stored on this node. */
+
+        while (start) {
+                if (start->brd_type == brd_type)
+                        return start;
+                start = KLCF_NEXT_ANY(start);
+        }
+        /* Didn't find it. */
+        return (lboard_t *) NULL;
+}
 
-/*
- * NOTE: THis is the max sized kl* structure and is used in klmalloc.c
- * to allocate space of type COMPONENT. Make sure that if the size of
- * any other component struct becomes more than this, then redefine
- * that as the size to be klmalloced.
- */
-
-typedef struct klscsi_s {                          /* SCSI Bus */
-	klinfo_t 	scsi_info ;
-    	u64       	*scsi_specific   ; 
-	unsigned char 	scsi_numdevs ;
-	klconf_off_t	scsi_devinfo[MAX_SCSI_DEVS] ; 
-	unsigned long	pad;
-} klscsi_t ;
-
-typedef struct klscctl_s {                          /* SCSI Controller */
-	klinfo_t 	scsi_info ;
-	unsigned int	type;
-	unsigned int	scsi_buscnt;                        /* # busses this cntlr */
-	void		*scsi_bus[2];                       /* Pointer to 2 klscsi_t's */
-	unsigned long	pad;
-} klscctl_t ;
-
-typedef struct klscdev_s {                          /* SCSI device */
-	klinfo_t 	scdev_info ;
-	struct scsidisk_data *scdev_cfg ; /* driver fills up this */
-	unsigned long	pad;
-} klscdev_t ;
-
-typedef struct klttydev_s {                          /* TTY device */
-	klinfo_t 	ttydev_info ;
-	struct terminal_data *ttydev_cfg ; /* driver fills up this */
-	unsigned long	pad;
-} klttydev_t ;
-
-typedef struct klpcigfx_s {                          /* PCI GFX */
-        klinfo_t        gfx_info ;
-} klpcigfx_t ;
-
-typedef struct klkbddev_s {                          /* KBD device */
-	klinfo_t 	kbddev_info ;
-	struct keyboard_data *kbddev_cfg ; /* driver fills up this */
-	unsigned long	pad;
-} klkbddev_t ;
-
-typedef struct klmsdev_s {                          /* mouse device */
-        klinfo_t        msdev_info ;
-        void 		*msdev_cfg ; 
-	unsigned long	pad;
-} klmsdev_t ;
-
-/*
- * USB info
- */
-
-typedef struct klusb_s {
-	klinfo_t	usb_info;	/* controller info */
-	void		*usb_bus;	/* handle to usb_bus_t */
-	uint64_t	usb_controller;	/* ptr to controller info */
-	unsigned long	pad;
-} klusb_t ; 
-
-typedef union klcomp_s {
-	klcpu_t		kc_cpu;
-	klhub_t		kc_hub;
-	klmembnk_t 	kc_mem;
-	klxbow_t  	kc_xbow;
-	klbri_t		kc_bri;
-	klrou_t		kc_rou;
-	klgfx_t		kc_gfx;
-	klscsi_t	kc_scsi;
-	klscctl_t	kc_scsi_ctl;
-	klscdev_t	kc_scsi_dev;
-	klmod_serial_num_t kc_snum ;
-	klusb_t		kc_usb;
-} klcomp_t;
-
-typedef union kldev_s {      /* for device structure allocation */
-	klscdev_t	kc_scsi_dev ;
-	klttydev_t	kc_tty_dev ;
-	klkbddev_t 	kc_kbd_dev ;
-} kldev_t ;
 
 /* external declarations of Linux kernel functions. */
 
 extern lboard_t *root_lboard[];
-extern lboard_t *find_lboard_any(lboard_t *start, unsigned char type);
-extern lboard_t *find_lboard_nasid(lboard_t *start, nasid_t, unsigned char type);
 extern klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char type);
 extern klinfo_t *find_first_component(lboard_t *brd, unsigned char type);
-extern klcpu_t *nasid_slice_to_cpuinfo(nasid_t, int);
-
-
-extern lboard_t *find_gfxpipe(int pipenum);
-extern lboard_t *find_lboard_class_any(lboard_t *start, unsigned char brd_class);
-extern lboard_t *find_lboard_class_nasid(lboard_t *start, nasid_t, unsigned char brd_class);
-extern lboard_t *find_nic_lboard(lboard_t *, nic_t);
-extern lboard_t *find_nic_type_lboard(nasid_t, unsigned char, nic_t);
-extern lboard_t *find_lboard_modslot(lboard_t *start, geoid_t geoid);
-extern int	config_find_nic_router(nasid_t, nic_t, lboard_t **, klrou_t**);
-extern int	config_find_nic_hub(nasid_t, nic_t, lboard_t **, klhub_t**);
-extern int	config_find_xbow(nasid_t, lboard_t **, klxbow_t**);
-extern int 	update_klcfg_cpuinfo(nasid_t, int);
-extern void 	board_to_path(lboard_t *brd, char *path);
-extern void 	nic_name_convert(char *old_name, char *new_name);
-extern int 	module_brds(nasid_t nasid, lboard_t **module_brds, int n);
-extern lboard_t *brd_from_key(uint64_t key);
-extern void 	device_component_canonical_name_get(lboard_t *,klinfo_t *,
-						    char *);
-extern int	board_serial_number_get(lboard_t *,char *);
-extern nasid_t	get_actual_nasid(lboard_t *brd) ;
-extern net_vec_t klcfg_discover_route(lboard_t *, lboard_t *, int);
 
 #endif /* _ASM_IA64_SN_KLCONFIG_H */
diff -Nru a/include/asm-ia64/sn/kldir.h b/include/asm-ia64/sn/kldir.h
--- a/include/asm-ia64/sn/kldir.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,363 +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.
- *
- * Derived from IRIX <sys/SN/kldir.h>, revision 1.21.
- *
- * Copyright (C) 1992-1997,1999,2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * Copyright (C) 1999 by Ralf Baechle
- */
-#ifndef _ASM_IA64_SN_KLDIR_H
-#define _ASM_IA64_SN_KLDIR_H
-
-#include <linux/types.h>
-
-/*
- * The kldir memory area resides at a fixed place in each node's memory and
- * provides pointers to most other IP27 memory areas.  This allows us to
- * resize and/or relocate memory areas at a later time without breaking all
- * firmware and kernels that use them.  Indices in the array are
- * permanently dedicated to areas listed below.  Some memory areas (marked
- * below) reside at a permanently fixed location, but are included in the
- * directory for completeness.
- */
-
-#define KLDIR_MAGIC		0x434d5f53505f5357
-
-/*
- * The upper portion of the memory map applies during boot
- * only and is overwritten by IRIX/SYMMON.
- *
- *                                    MEMORY MAP PER NODE
- *
- * 0x2000000 (32M)         +-----------------------------------------+
- *                         |      IO6 BUFFERS FOR FLASH ENET IOC3    |
- * 0x1F80000 (31.5M)       +-----------------------------------------+
- *                         |      IO6 TEXT/DATA/BSS/stack            |
- * 0x1C00000 (30M)         +-----------------------------------------+
- *                         |      IO6 PROM DEBUG TEXT/DATA/BSS/stack |
- * 0x0800000 (28M)         +-----------------------------------------+
- *                         |      IP27 PROM TEXT/DATA/BSS/stack      |
- * 0x1B00000 (27M)         +-----------------------------------------+
- *                         |      IP27 CFG                           |
- * 0x1A00000 (26M)         +-----------------------------------------+
- *                         |      Graphics PROM                      |
- * 0x1800000 (24M)         +-----------------------------------------+
- *                         |      3rd Party PROM drivers             |
- * 0x1600000 (22M)         +-----------------------------------------+
- *                         |                                         |
- *                         |      Free                               |
- *                         |                                         |
- *                         +-----------------------------------------+
- *                         |      UNIX DEBUG Version                 |
- * 0x190000 (2M--)         +-----------------------------------------+
- *                         |      SYMMON                             |
- *                         |      (For UNIX Debug only)              |
- * 0x34000 (208K)          +-----------------------------------------+
- *                         |      SYMMON STACK [NUM_CPU_PER_NODE]    |
- *                         |      (For UNIX Debug only)              |
- * 0x25000 (148K)          +-----------------------------------------+
- *                         |      KLCONFIG - II (temp)               |
- *                         |                                         |
- *                         |    ----------------------------         |
- *                         |                                         |
- *                         |      UNIX NON-DEBUG Version             |
- * 0x19000 (100K)          +-----------------------------------------+
- *
- *
- * The lower portion of the memory map contains information that is
- * permanent and is used by the IP27PROM, IO6PROM and IRIX.
- *
- * 0x19000 (100K)          +-----------------------------------------+
- *                         |                                         |
- *                         |      PI Error Spools (32K)              |
- *                         |                                         |
- * 0x12000 (72K)           +-----------------------------------------+
- *                         |      Unused                             |
- * 0x11c00 (71K)           +-----------------------------------------+
- *                         |      CPU 1 NMI Eframe area       	     |
- * 0x11a00 (70.5K)         +-----------------------------------------+
- *                         |      CPU 0 NMI Eframe area       	     |
- * 0x11800 (70K)           +-----------------------------------------+
- *                         |      CPU 1 NMI Register save area       |
- * 0x11600 (69.5K)         +-----------------------------------------+
- *                         |      CPU 0 NMI Register save area       |
- * 0x11400 (69K)           +-----------------------------------------+
- *                         |      GDA (1k)                           |
- * 0x11000 (68K)           +-----------------------------------------+
- *                         |      Early cache Exception stack        |
- *                         |             and/or                      |
- *			   |      kernel/io6prom nmi registers	     |
- * 0x10800  (66k)	   +-----------------------------------------+
- *			   |      cache error eframe   	 	     |
- * 0x10400 (65K)           +-----------------------------------------+
- *                         |      Exception Handlers (UALIAS copy)   |
- * 0x10000 (64K)           +-----------------------------------------+
- *                         |                                         |
- *                         |                                         |
- *                         |      KLCONFIG - I (permanent) (48K)     |
- *                         |                                         |
- *                         |                                         |
- *                         |                                         |
- * 0x4000 (16K)            +-----------------------------------------+
- *                         |      NMI Handler (Protected Page)       |
- * 0x3000 (12K)            +-----------------------------------------+
- *                         |      ARCS PVECTORS (master node only)   |
- * 0x2c00 (11K)            +-----------------------------------------+
- *                         |      ARCS TVECTORS (master node only)   |
- * 0x2800 (10K)            +-----------------------------------------+
- *                         |      LAUNCH [NUM_CPU]                   |
- * 0x2400 (9K)             +-----------------------------------------+
- *                         |      Low memory directory (KLDIR)       |
- * 0x2000 (8K)             +-----------------------------------------+
- *                         |      ARCS SPB (1K)                      |
- * 0x1000 (4K)             +-----------------------------------------+
- *                         |      Early cache Exception stack        |
- *                         |             and/or                      |
- *			   |      kernel/io6prom nmi registers	     |
- * 0x800  (2k)	           +-----------------------------------------+
- *			   |      cache error eframe   	 	     |
- * 0x400 (1K)              +-----------------------------------------+
- *                         |      Exception Handlers                 |
- * 0x0   (0K)              +-----------------------------------------+
- */
-
-#ifdef __ASSEMBLY__
-#define KLDIR_OFF_MAGIC			0x00
-#define KLDIR_OFF_OFFSET		0x08
-#define KLDIR_OFF_POINTER		0x10
-#define KLDIR_OFF_SIZE			0x18
-#define KLDIR_OFF_COUNT			0x20
-#define KLDIR_OFF_STRIDE		0x28
-#endif /* __ASSEMBLY__ */
-
-#ifndef __ASSEMBLY__
-typedef struct kldir_ent_s {
-	u64		magic;		/* Indicates validity of entry      */
-	off_t		offset;		/* Offset from start of node space  */
-	unsigned long	pointer;	/* Pointer to area in some cases    */
-	size_t		size;		/* Size in bytes 		    */
-	u64		count;		/* Repeat count if array, 1 if not  */
-	size_t		stride;		/* Stride if array, 0 if not        */
-	char		rsvd[16];	/* Pad entry to 0x40 bytes          */
-	/* NOTE: These 16 bytes are used in the Partition KLDIR
-	   entry to store partition info. Refer to klpart.h for this. */
-} kldir_ent_t;
-#endif /* __ASSEMBLY__ */
-
-
-#define KLDIR_ENT_SIZE			0x40
-#define KLDIR_MAX_ENTRIES		(0x400 / 0x40)
-
-
-
-/*
- * The upper portion of the memory map applies during boot
- * only and is overwritten by IRIX/SYMMON.  The minimum memory bank
- * size on IP35 is 64M, which provides a limit on the amount of space
- * the PROM can assume it has available.
- *
- * Most of the addresses below are defined as macros in this file, or
- * in SN/addrs.h or SN/SN1/addrs.h.
- *
- *                                    MEMORY MAP PER NODE
- *
- * 0x4000000 (64M)         +-----------------------------------------+
- *                         |                                         |
- *                         |                                         |
- *                         |      IO7 TEXT/DATA/BSS/stack            |
- * 0x3000000 (48M)         +-----------------------------------------+
- *                         |      Free                               |
- * 0x2102000 (>33M)        +-----------------------------------------+
- *                         |      IP35 Topology (PCFG) + misc data   |
- * 0x2000000 (32M)         +-----------------------------------------+
- *                         |      IO7 BUFFERS FOR FLASH ENET IOC3    |
- * 0x1F80000 (31.5M)       +-----------------------------------------+
- *                         |      Free                               |
- * 0x1C00000 (28M)         +-----------------------------------------+
- *                         |      IP35 PROM TEXT/DATA/BSS/stack      |
- * 0x1A00000 (26M)         +-----------------------------------------+
- *                         |      Routing temp. space                |
- * 0x1800000 (24M)         +-----------------------------------------+
- *                         |      Diagnostics temp. space            |
- * 0x1500000 (21M)         +-----------------------------------------+
- *                         |      Free                               |
- * 0x1400000 (20M)         +-----------------------------------------+
- *                         |      IO7 PROM temporary copy            |
- * 0x1300000 (19M)         +-----------------------------------------+
- *                         |                                         |
- *                         |      Free                               |
- *                         |      (UNIX DATA starts above 0x1000000) |
- *                         |                                         |
- *                         +-----------------------------------------+
- *                         |      UNIX DEBUG Version                 |
- * 0x0310000 (3.1M)        +-----------------------------------------+
- *                         |      SYMMON, loaded just below UNIX     |
- *                         |      (For UNIX Debug only)              |
- *                         |                                         |
- *                         |                                         |
- * 0x006C000 (432K)        +-----------------------------------------+
- *                         |      SYMMON STACK [NUM_CPU_PER_NODE]    |
- *                         |      (For UNIX Debug only)              |
- * 0x004C000 (304K)        +-----------------------------------------+
- *                         |                                         |
- *                         |                                         |
- *                         |      UNIX NON-DEBUG Version             |
- * 0x0040000 (256K)        +-----------------------------------------+
- *
- *
- * The lower portion of the memory map contains information that is
- * permanent and is used by the IP35PROM, IO7PROM and IRIX.
- *
- * 0x40000 (256K)          +-----------------------------------------+
- *                         |                                         |
- *                         |      KLCONFIG (64K)                     |
- *                         |                                         |
- * 0x30000 (192K)          +-----------------------------------------+
- *                         |                                         |
- *                         |      PI Error Spools (64K)              |
- *                         |                                         |
- * 0x20000 (128K)          +-----------------------------------------+
- *                         |                                         |
- *                         |      Unused                             |
- *                         |                                         |
- * 0x19000 (100K)          +-----------------------------------------+
- *                         |      Early cache Exception stack (CPU 3)|
- * 0x18800 (98K)           +-----------------------------------------+
- *			   |      cache error eframe (CPU 3)	     |
- * 0x18400 (97K)           +-----------------------------------------+
- *                         |      Exception Handlers (CPU 3)         |
- * 0x18000 (96K)           +-----------------------------------------+
- *                         |                                         |
- *                         |      Unused                             |
- *                         |                                         |
- * 0x13c00 (79K)           +-----------------------------------------+
- *                         |      GPDA (8k)                          |
- * 0x11c00 (71K)           +-----------------------------------------+
- *                         |      Early cache Exception stack (CPU 2)|
- * 0x10800 (66k)	   +-----------------------------------------+
- *			   |      cache error eframe (CPU 2)	     |
- * 0x10400 (65K)           +-----------------------------------------+
- *                         |      Exception Handlers (CPU 2)         |
- * 0x10000 (64K)           +-----------------------------------------+
- *                         |                                         |
- *                         |      Unused                             |
- *                         |                                         |
- * 0x0b400 (45K)           +-----------------------------------------+
- *                         |      GDA (1k)                           |
- * 0x0b000 (44K)           +-----------------------------------------+
- *                         |      NMI Eframe areas (4)       	     |
- * 0x0a000 (40K)           +-----------------------------------------+
- *                         |      NMI Register save areas (4)        |
- * 0x09000 (36K)           +-----------------------------------------+
- *                         |      Early cache Exception stack (CPU 1)|
- * 0x08800 (34K)           +-----------------------------------------+
- *			   |      cache error eframe (CPU 1)	     |
- * 0x08400 (33K)           +-----------------------------------------+
- *                         |      Exception Handlers (CPU 1)         |
- * 0x08000 (32K)           +-----------------------------------------+
- *                         |                                         |
- *                         |                                         |
- *                         |      Unused                             |
- *                         |                                         |
- *                         |                                         |
- * 0x04000 (16K)           +-----------------------------------------+
- *                         |      NMI Handler (Protected Page)       |
- * 0x03000 (12K)           +-----------------------------------------+
- *                         |      ARCS PVECTORS (master node only)   |
- * 0x02c00 (11K)           +-----------------------------------------+
- *                         |      ARCS TVECTORS (master node only)   |
- * 0x02800 (10K)           +-----------------------------------------+
- *                         |      LAUNCH [NUM_CPU]                   |
- * 0x02400 (9K)            +-----------------------------------------+
- *                         |      Low memory directory (KLDIR)       |
- * 0x02000 (8K)            +-----------------------------------------+
- *                         |      ARCS SPB (1K)                      |
- * 0x01000 (4K)            +-----------------------------------------+
- *                         |      Early cache Exception stack (CPU 0)|
- * 0x00800 (2k)	           +-----------------------------------------+
- *			   |      cache error eframe (CPU 0)	     |
- * 0x00400 (1K)            +-----------------------------------------+
- *                         |      Exception Handlers (CPU 0)         |
- * 0x00000 (0K)            +-----------------------------------------+
- */
-
-/*
- * NOTE:  To change the kernel load address, you must update:
- *  - the appropriate elspec files in irix/kern/master.d
- *  - NODEBUGUNIX_ADDR in SN/SN1/addrs.h
- *  - IP27_FREEMEM_OFFSET below
- *  - KERNEL_START_OFFSET below (if supporting cells)
- */
-
-
-/*
- * This is defined here because IP27_SYMMON_STK_SIZE must be at least what
- * we define here.  Since it's set up in the prom.  We can't redefine it later
- * and expect more space to be allocated.  The way to find out the true size
- * of the symmon stacks is to divide SYMMON_STK_SIZE by SYMMON_STK_STRIDE
- * for a particular node.
- */
-#define SYMMON_STACK_SIZE		0x8000
-
-#if defined (PROM) || defined (SABLE)
-
-/*
- * These defines are prom version dependent.  No code other than the IP35
- * prom should attempt to use these values.
- */
-#define IP27_LAUNCH_OFFSET		0x2400
-#define IP27_LAUNCH_SIZE		0x400
-#define IP27_LAUNCH_COUNT		4
-#define IP27_LAUNCH_STRIDE		0x100 /* could be as small as 0x80 */
-
-#define IP27_KLCONFIG_OFFSET		0x30000
-#define IP27_KLCONFIG_SIZE		0x10000
-#define IP27_KLCONFIG_COUNT		1
-#define IP27_KLCONFIG_STRIDE		0
-
-#define IP27_NMI_OFFSET			0x3000
-#define IP27_NMI_SIZE			0x100
-#define IP27_NMI_COUNT			4
-#define IP27_NMI_STRIDE			0x40
-
-#define IP27_PI_ERROR_OFFSET		0x20000
-#define IP27_PI_ERROR_SIZE		0x10000
-#define IP27_PI_ERROR_COUNT		1
-#define IP27_PI_ERROR_STRIDE		0
-
-#define IP27_SYMMON_STK_OFFSET		0x4c000
-#define IP27_SYMMON_STK_SIZE		0x20000
-#define IP27_SYMMON_STK_COUNT		4
-/* IP27_SYMMON_STK_STRIDE must be >= SYMMON_STACK_SIZE */
-#define IP27_SYMMON_STK_STRIDE		0x8000
-
-#define IP27_FREEMEM_OFFSET		0x40000
-#define IP27_FREEMEM_SIZE		(-1)
-#define IP27_FREEMEM_COUNT		1
-#define IP27_FREEMEM_STRIDE		0
-
-#endif /* PROM || SABLE*/
-/*
- * There will be only one of these in a partition so the IO7 must set it up.
- */
-#define IO6_GDA_OFFSET			0xb000
-#define IO6_GDA_SIZE			0x400
-#define IO6_GDA_COUNT			1
-#define IO6_GDA_STRIDE			0
-
-/*
- * save area of kernel nmi regs in the prom format
- */
-#define IP27_NMI_KREGS_OFFSET		0x9000
-#define IP27_NMI_KREGS_CPU_SIZE		0x400
-/*
- * save area of kernel nmi regs in eframe format 
- */
-#define IP27_NMI_EFRAME_OFFSET		0xa000
-#define IP27_NMI_EFRAME_SIZE		0x400
-
-#define GPDA_OFFSET			0x11c00
-
-#endif /* _ASM_IA64_SN_KLDIR_H */
diff -Nru a/include/asm-ia64/sn/ksys/elsc.h b/include/asm-ia64/sn/ksys/elsc.h
--- a/include/asm-ia64/sn/ksys/elsc.h	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,39 +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) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-#ifndef _ASM_IA64_SN_KSYS_ELSC_H
-#define _ASM_IA64_SN_KSYS_ELSC_H
-
-/*
- * Error codes
- *
- *   The possible ELSC error codes are a superset of the I2C error codes,
- *   so ELSC error codes begin at -100.
- */
-
-#define ELSC_ERROR_NONE			0
-
-#define ELSC_ERROR_CMD_SEND	       (-100)	/* Error sending command    */
-#define ELSC_ERROR_CMD_CHECKSUM	       (-101)	/* Command checksum bad     */
-#define ELSC_ERROR_CMD_UNKNOWN	       (-102)	/* Unknown command          */
-#define ELSC_ERROR_CMD_ARGS	       (-103)	/* Invalid argument(s)      */
-#define ELSC_ERROR_CMD_PERM	       (-104)	/* Permission denied	    */
-#define ELSC_ERROR_CMD_STATE	       (-105)	/* not allowed in this state*/
-
-#define ELSC_ERROR_RESP_TIMEOUT	       (-110)	/* ELSC response timeout    */
-#define ELSC_ERROR_RESP_CHECKSUM       (-111)	/* Response checksum bad    */
-#define ELSC_ERROR_RESP_FORMAT	       (-112)	/* Response format error    */
-#define ELSC_ERROR_RESP_DIR	       (-113)	/* Response direction error */
-
-#define ELSC_ERROR_MSG_LOST	       (-120)	/* Queue full; msg. lost    */
-#define ELSC_ERROR_LOCK_TIMEOUT	       (-121)	/* ELSC response timeout    */
-#define ELSC_ERROR_DATA_SEND	       (-122)	/* Error sending data       */
-#define ELSC_ERROR_NIC		       (-123)	/* NIC processing error     */
-#define ELSC_ERROR_NVMAGIC	       (-124)	/* Bad magic no. in NVRAM   */
-#define ELSC_ERROR_MODULE	       (-125)	/* Moduleid processing err  */
-
-#endif /* _ASM_IA64_SN_KSYS_ELSC_H */
diff -Nru a/include/asm-ia64/sn/ksys/l1.h b/include/asm-ia64/sn/ksys/l1.h
--- a/include/asm-ia64/sn/ksys/l1.h	2004-12-24 13:36:33 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,141 +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) 1992-1997,2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-
-#ifndef _ASM_IA64_SN_KSYS_L1_H
-#define _ASM_IA64_SN_KSYS_L1_H
-
-#include <asm/sn/types.h>
-
-/* L1 Target Addresses */
-/*
- * L1 commands and responses use source/target addresses that are
- * 32 bits long.  These are broken up into multiple bitfields that
- * specify the type of the target controller (could actually be L2
- * L3, not just L1), the rack and bay of the target, and the task
- * id (L1 functionality is divided into several independent "tasks"
- * that can each receive command requests and transmit responses)
- */
-#define L1_ADDR_TYPE_L1		0x00	/* L1 system controller */
-#define L1_ADDR_TYPE_L2		0x01	/* L2 system controller */
-#define L1_ADDR_TYPE_L3		0x02	/* L3 system controller */
-#define L1_ADDR_TYPE_CBRICK	0x03	/* attached C brick	*/
-#define L1_ADDR_TYPE_IOBRICK	0x04	/* attached I/O brick	*/
-#define L1_ADDR_TASK_SHFT	0
-#define L1_ADDR_TASK_MASK	0x0000001F
-#define L1_ADDR_TASK_INVALID	0x00	/* invalid task 	*/
-#define	L1_ADDR_TASK_IROUTER	0x01	/* iRouter		*/
-#define L1_ADDR_TASK_SYS_MGMT	0x02	/* system management port */
-#define L1_ADDR_TASK_CMD	0x03	/* command interpreter	*/
-#define L1_ADDR_TASK_ENV	0x04	/* environmental monitor */
-#define L1_ADDR_TASK_BEDROCK	0x05	/* bedrock		*/
-#define L1_ADDR_TASK_GENERAL	0x06	/* general requests	*/
-
-/* response argument types */
-#define L1_ARG_INT		0x00	/* 4-byte integer (big-endian)	*/
-#define L1_ARG_ASCII		0x01	/* null-terminated ASCII string */
-#define L1_ARG_UNKNOWN		0x80	/* unknown data type.  The low
-					 * 7 bits will contain the data
-					 * length.			*/
-
-/* response codes */
-#define L1_RESP_OK	    0	/* no problems encountered      */
-#define L1_RESP_IROUTER	(-  1)	/* iRouter error	        */
-#define L1_RESP_ARGC	(-100)	/* arg count mismatch	        */
-#define L1_RESP_REQC	(-101)	/* bad request code	        */
-#define L1_RESP_NAVAIL	(-104)	/* requested data not available */
-#define L1_RESP_ARGVAL	(-105)  /* arg value out of range       */
-#define L1_RESP_INVAL   (-107)  /* requested data invalid       */
-
-/* L1 general requests */
-
-/* request codes */
-#define	L1_REQ_RDBG		0x0001	/* read debug switches	*/
-#define L1_REQ_RRACK		0x0002	/* read brick rack & bay */
-#define L1_REQ_RRBT		0x0003  /* read brick rack, bay & type */
-#define L1_REQ_SER_NUM		0x0004  /* read brick serial number */
-#define L1_REQ_FW_REV		0x0005  /* read L1 firmware revision */
-#define L1_REQ_EEPROM		0x0006  /* read EEPROM info */
-#define L1_REQ_EEPROM_FMT	0x0007  /* get EEPROM data format & size */
-#define L1_REQ_SYS_SERIAL	0x0008	/* read system serial number */
-#define L1_REQ_PARTITION_GET	0x0009	/* read partition id */
-#define L1_REQ_PORTSPEED	0x000a	/* get ioport speed */
-
-#define L1_REQ_CONS_SUBCH	0x1002  /* select this node's console 
-					   subchannel */
-#define L1_REQ_CONS_NODE	0x1003  /* volunteer to be the master 
-					   (console-hosting) node */
-#define L1_REQ_DISP1		0x1004  /* write line 1 of L1 display */
-#define L1_REQ_DISP2		0x1005  /* write line 2 of L1 display */
-#define L1_REQ_PARTITION_SET	0x1006	/* set partition id */
-#define L1_REQ_EVENT_SUBCH	0x1007	/* set the subchannel for system
-					   controller event transmission */
-
-#define L1_REQ_RESET		0x2000	/* request a full system reset */
-#define L1_REQ_PCI_UP		0x2001  /* power up pci slot or bus */
-#define L1_REQ_PCI_DOWN		0x2002  /* power down pci slot or bus */
-#define L1_REQ_PCI_RESET	0x2003  /* reset pci bus or slot */
-
-/* L1 command interpreter requests */
-
-/* request codes */
-#define L1_REQ_EXEC_CMD		0x0000	/* interpret and execute an ASCII
-					   command string */
-
-/* brick type response codes */
-#define L1_BRICKTYPE_PX         0x23            /* # */
-#define L1_BRICKTYPE_PE         0x25            /* % */
-#define L1_BRICKTYPE_N_p0       0x26            /* & */
-#define L1_BRICKTYPE_IP45       0x34            /* 4 */
-#define L1_BRICKTYPE_IP41       0x35            /* 5 */
-#define L1_BRICKTYPE_TWISTER    0x36            /* 6 */ /* IP53 & ROUTER */
-#define L1_BRICKTYPE_IX         0x3d            /* = */
-#define L1_BRICKTYPE_IP34       0x61            /* a */
-#define L1_BRICKTYPE_C          0x63            /* c */
-#define L1_BRICKTYPE_I          0x69            /* i */
-#define L1_BRICKTYPE_N          0x6e            /* n */
-#define L1_BRICKTYPE_OPUS       0x6f		/* o */
-#define L1_BRICKTYPE_P          0x70            /* p */
-#define L1_BRICKTYPE_R          0x72            /* r */
-#define L1_BRICKTYPE_CHI_CG     0x76            /* v */
-#define L1_BRICKTYPE_X          0x78            /* x */
-#define L1_BRICKTYPE_X2         0x79            /* y */
-
-/* EEPROM codes (for the "read EEPROM" request) */
-/* c brick */
-#define L1_EEP_NODE		0x00	/* node board */
-#define L1_EEP_PIMM0		0x01
-#define L1_EEP_PIMM(x)		(L1_EEP_PIMM0+(x))
-#define L1_EEP_DIMM0		0x03
-#define L1_EEP_DIMM(x)		(L1_EEP_DIMM0+(x))
-
-/* other brick types */
-#define L1_EEP_POWER		0x00	/* power board */
-#define L1_EEP_LOGIC		0x01	/* logic board */
-
-/* info area types */
-#define L1_EEP_CHASSIS		1	/* chassis info area */
-#define L1_EEP_BOARD		2	/* board info area */
-#define L1_EEP_IUSE		3	/* internal use area */
-#define L1_EEP_SPD		4	/* serial presence detect record */
-
-#define L1_DISPLAY_LINE_LENGTH	12	/* L1 display characters/line */
-
-#ifdef L1_DISP_2LINES
-#define L1_DISPLAY_LINES	2	/* number of L1 display lines */
-#else
-#define L1_DISPLAY_LINES	1	/* number of L1 display lines available
-					 * to system software */
-#endif
-
-int	elsc_display_line(nasid_t nasid, char *line, int lnum);
-int	iobrick_rack_bay_type_get( nasid_t nasid, unsigned int *rack,
-				   unsigned int *bay, unsigned int *brick_type );
-int	iomoduleid_get( nasid_t nasid );
-
-
-#endif /* _ASM_IA64_SN_KSYS_L1_H */
diff -Nru a/include/asm-ia64/sn/l1.h b/include/asm-ia64/sn/l1.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-ia64/sn/l1.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,36 @@
+/*
+ * 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-1997,2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ */
+
+#ifndef _ASM_IA64_SN_L1_H
+#define _ASM_IA64_SN_L1_H
+
+/* brick type response codes */
+#define L1_BRICKTYPE_PX         0x23            /* # */
+#define L1_BRICKTYPE_PE         0x25            /* % */
+#define L1_BRICKTYPE_N_p0       0x26            /* & */
+#define L1_BRICKTYPE_IP45       0x34            /* 4 */
+#define L1_BRICKTYPE_IP41       0x35            /* 5 */
+#define L1_BRICKTYPE_TWISTER    0x36            /* 6 */ /* IP53 & ROUTER */
+#define L1_BRICKTYPE_IX         0x3d            /* = */
+#define L1_BRICKTYPE_IP34       0x61            /* a */
+#define L1_BRICKTYPE_GA		0x62            /* b */
+#define L1_BRICKTYPE_C          0x63            /* c */
+#define L1_BRICKTYPE_OPUS_TIO	0x66		/* f */
+#define L1_BRICKTYPE_I          0x69            /* i */
+#define L1_BRICKTYPE_N          0x6e            /* n */
+#define L1_BRICKTYPE_OPUS       0x6f		/* o */
+#define L1_BRICKTYPE_P          0x70            /* p */
+#define L1_BRICKTYPE_R          0x72            /* r */
+#define L1_BRICKTYPE_CHI_CG     0x76            /* v */
+#define L1_BRICKTYPE_X          0x78            /* x */
+#define L1_BRICKTYPE_X2         0x79            /* y */
+#define L1_BRICKTYPE_SA		0x5e            /* ^ */ /* TIO bringup brick */
+#define L1_BRICKTYPE_PA		0x6a            /* j */
+#define L1_BRICKTYPE_IA		0x6b            /* k */
+
+#endif /* _ASM_IA64_SN_L1_H */
diff -Nru a/include/asm-ia64/sn/labelcl.h b/include/asm-ia64/sn/labelcl.h
--- a/include/asm-ia64/sn/labelcl.h	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,76 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_LABELCL_H
-#define _ASM_IA64_SN_LABELCL_H
-
-#define LABELCL_MAGIC 0x4857434c	/* 'HWLC' */
-#define LABEL_LENGTH_MAX 256		/* Includes NULL char */
-#define INFO_DESC_PRIVATE (-1)      	/* default */
-#define INFO_DESC_EXPORT  0       	/* export info itself */
-
-/*
- * Description of a label entry.
- */
-typedef struct label_info_s {
-        char			*name;
-        arb_info_desc_t		desc;
-        arbitrary_info_t	info;
-} label_info_t;
-
-/*
- * Definition of the data structure that provides the link to 
- * the hwgraph fastinfo and the label entries associated with a 
- * particular hwgraph entry.
- */
-typedef struct labelcl_info_s {
-	unsigned long	hwcl_magic;
-	unsigned long	num_labels;
-	void		*label_list;
-	arbitrary_info_t IDX_list[HWGRAPH_NUM_INDEX_INFO];
-} labelcl_info_t;
-
-/*
- * Definitions for the string table that holds the actual names 
- * of the labels.
- */
-struct string_table_item {
-        struct string_table_item        *next;
-        char                            string[1];
-};
-
-struct string_table {
-        struct string_table_item        *string_table_head;
-        long                            string_table_generation;
-};
-
-
-#define STRTBL_BASIC_SIZE ((size_t)(((struct string_table_item *)0)->string))
-#define STRTBL_ITEM_SIZE(str_length) (STRTBL_BASIC_SIZE + (str_length) + 1)
-
-#define STRTBL_ALLOC(str_length) \
-        ((struct string_table_item *)kmalloc(STRTBL_ITEM_SIZE(str_length), GFP_KERNEL))
-
-#define STRTBL_FREE(ptr) kfree(ptr)
-
-
-extern labelcl_info_t *labelcl_info_create(void);
-extern int labelcl_info_destroy(labelcl_info_t *);
-extern int labelcl_info_add_LBL(vertex_hdl_t, char *, arb_info_desc_t, arbitrary_info_t);
-extern int labelcl_info_remove_LBL(vertex_hdl_t, char *, arb_info_desc_t *, arbitrary_info_t *);
-extern int labelcl_info_replace_LBL(vertex_hdl_t, char *, arb_info_desc_t,
-                        arbitrary_info_t, arb_info_desc_t *, arbitrary_info_t *);
-extern int labelcl_info_get_LBL(vertex_hdl_t, char *, arb_info_desc_t *,
-                      arbitrary_info_t *);
-extern int labelcl_info_get_next_LBL(vertex_hdl_t, char *, arb_info_desc_t *,
-                           arbitrary_info_t *, labelcl_info_place_t *);
-extern int labelcl_info_replace_IDX(vertex_hdl_t, int, arbitrary_info_t, 
-			arbitrary_info_t *);
-extern int labelcl_info_connectpt_set(vertex_hdl_t, vertex_hdl_t);
-extern int labelcl_info_get_IDX(vertex_hdl_t, int, arbitrary_info_t *);
-
-#endif /* _ASM_IA64_SN_LABELCL_H */
diff -Nru a/include/asm-ia64/sn/leds.h b/include/asm-ia64/sn/leds.h
--- a/include/asm-ia64/sn/leds.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-ia64/sn/leds.h	2004-12-24 13:36:18 -08:00
@@ -1,16 +1,14 @@
-#ifndef _ASM_IA64_SN_LEDS_H
-#define _ASM_IA64_SN_LEDS_H
-
 /*
  * 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-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
+#ifndef _ASM_IA64_SN_LEDS_H
+#define _ASM_IA64_SN_LEDS_H
 
 #include <asm/sn/addrs.h>
 #include <asm/sn/pda.h>
-#include <asm/sn/sn2/shub.h>
 
 #define LED0		(LOCAL_MMR_ADDR(SH_REAL_JUNK_BUS_LED0))
 #define LED_CPU_SHIFT	16
diff -Nru a/include/asm-ia64/sn/module.h b/include/asm-ia64/sn/module.h
--- a/include/asm-ia64/sn/module.h	2004-12-24 13:36:34 -08:00
+++ b/include/asm-ia64/sn/module.h	2004-12-24 13:37:44 -08:00
@@ -3,24 +3,11 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
 #ifndef _ASM_IA64_SN_MODULE_H
 #define _ASM_IA64_SN_MODULE_H
 
-#include <asm/sn/klconfig.h>
-#include <asm/sn/ksys/elsc.h>
-
-#define MODULE_MAX			128
-#define MODULE_MAX_NODES		2
-#define MODULE_HIST_CNT			16
-#define MAX_MODULE_LEN			16
-
-/* Well-known module IDs */
-#define MODULE_UNKNOWN		(-2) /* initial value of klconfig brd_module */
-/* #define INVALID_MODULE	(-1) ** generic invalid moduleid_t (arch.h) */
-#define MODULE_NOT_SET		0    /* module ID not set in sys ctlrs. */
-
 /* parameter for format_module_id() */
 #define MODULE_FORMAT_BRIEF	1
 #define MODULE_FORMAT_LONG	2
@@ -59,13 +46,6 @@
 #define MODULE_GET_BPOS(_m)	(((_m) & MODULE_BPOS_MASK) >> MODULE_BPOS_SHFT)
 
 /*
- * Macros for constructing moduleid_t's
- */
-#define RBT_TO_MODULE(_r, _b, _t) ((_r) << MODULE_RACK_SHFT | \
-				   (_b) << MODULE_BPOS_SHFT | \
-				   (_t) << MODULE_BTYPE_SHFT)
-
-/*
  * Macros for encoding and decoding rack IDs
  * A rack number consists of three parts:
  *   class (0==CPU/mixed, 1==I/O), group, number
@@ -73,12 +53,12 @@
  * Rack number is stored just as it is displayed on the screen:
  * a 3-decimal-digit number.
  */
-#define RACK_CLASS_DVDR		100
-#define RACK_GROUP_DVDR		10
-#define RACK_NUM_DVDR		1
+#define RACK_CLASS_DVDR         100
+#define RACK_GROUP_DVDR         10
+#define RACK_NUM_DVDR           1
 
-#define RACK_CREATE_RACKID(_c, _g, _n)	((_c) * RACK_CLASS_DVDR +	\
-	(_g) * RACK_GROUP_DVDR + (_n) * RACK_NUM_DVDR)
+#define RACK_CREATE_RACKID(_c, _g, _n)  ((_c) * RACK_CLASS_DVDR +       \
+        (_g) * RACK_GROUP_DVDR + (_n) * RACK_NUM_DVDR)
 
 #define RACK_GET_CLASS(_r)              ((_r) / RACK_CLASS_DVDR)
 #define RACK_GET_GROUP(_r)              (((_r) - RACK_GET_CLASS(_r) *   \
@@ -90,29 +70,29 @@
 /*
  * Macros for encoding and decoding rack IDs
  * A rack number consists of three parts:
- *   class	1 bit, 0==CPU/mixed, 1==I/O
- *   group	2 bits for CPU/mixed, 3 bits for I/O
- *   number	3 bits for CPU/mixed, 2 bits for I/O (1 based)
- */
-#define RACK_GROUP_BITS(_r)	(RACK_GET_CLASS(_r) ? 3 : 2)
-#define RACK_NUM_BITS(_r)	(RACK_GET_CLASS(_r) ? 2 : 3)
-
-#define RACK_CLASS_MASK(_r)	0x20
-#define RACK_CLASS_SHFT(_r)	5
-#define RACK_ADD_CLASS(_r, _c)	\
-	((_r) |= (_c) << RACK_CLASS_SHFT(_r) & RACK_CLASS_MASK(_r))
-
-#define RACK_GROUP_SHFT(_r)	RACK_NUM_BITS(_r)
-#define RACK_GROUP_MASK(_r)	\
-	( (((unsigned)1<<RACK_GROUP_BITS(_r)) - 1) << RACK_GROUP_SHFT(_r) )
-#define RACK_ADD_GROUP(_r, _g)	\
-	((_r) |= (_g) << RACK_GROUP_SHFT(_r) & RACK_GROUP_MASK(_r))
-
-#define RACK_NUM_SHFT(_r)	0
-#define RACK_NUM_MASK(_r)	\
-	( (((unsigned)1<<RACK_NUM_BITS(_r)) - 1) << RACK_NUM_SHFT(_r) )
-#define RACK_ADD_NUM(_r, _n)	\
-	((_r) |= ((_n) - 1) << RACK_NUM_SHFT(_r) & RACK_NUM_MASK(_r))
+ *   class      1 bit, 0==CPU/mixed, 1==I/O
+ *   group      2 bits for CPU/mixed, 3 bits for I/O
+ *   number     3 bits for CPU/mixed, 2 bits for I/O (1 based)
+ */
+#define RACK_GROUP_BITS(_r)     (RACK_GET_CLASS(_r) ? 3 : 2)
+#define RACK_NUM_BITS(_r)       (RACK_GET_CLASS(_r) ? 2 : 3)
+
+#define RACK_CLASS_MASK(_r)     0x20
+#define RACK_CLASS_SHFT(_r)     5
+#define RACK_ADD_CLASS(_r, _c)  \
+        ((_r) |= (_c) << RACK_CLASS_SHFT(_r) & RACK_CLASS_MASK(_r))
+
+#define RACK_GROUP_SHFT(_r)     RACK_NUM_BITS(_r)
+#define RACK_GROUP_MASK(_r)     \
+        ( (((unsigned)1<<RACK_GROUP_BITS(_r)) - 1) << RACK_GROUP_SHFT(_r) )
+#define RACK_ADD_GROUP(_r, _g)  \
+        ((_r) |= (_g) << RACK_GROUP_SHFT(_r) & RACK_GROUP_MASK(_r))
+
+#define RACK_NUM_SHFT(_r)       0
+#define RACK_NUM_MASK(_r)       \
+        ( (((unsigned)1<<RACK_NUM_BITS(_r)) - 1) << RACK_NUM_SHFT(_r) )
+#define RACK_ADD_NUM(_r, _n)    \
+        ((_r) |= ((_n) - 1) << RACK_NUM_SHFT(_r) & RACK_NUM_MASK(_r))
 
 
 /*
@@ -135,60 +115,13 @@
 #define MODULE_IXBRICK          10
 #define MODULE_CGBRICK		11
 #define MODULE_OPUSBRICK        12
+#define MODULE_SABRICK		13	/* TIO BringUp Brick */
+#define MODULE_IABRICK		14
+#define MODULE_PABRICK		15
+#define MODULE_GABRICK		16
+#define MODULE_OPUS_TIO		17	/* OPUS TIO Riser */
 
-/*
- * Moduleid_t comparison macros
- */
-/* Don't compare the brick type:  only the position is significant */
-#define MODULE_CMP(_m1, _m2)    (((_m1)&(MODULE_RACK_MASK|MODULE_BPOS_MASK)) -\
-                                 ((_m2)&(MODULE_RACK_MASK|MODULE_BPOS_MASK)))
-#define MODULE_MATCH(_m1, _m2)  (MODULE_CMP((_m1),(_m2)) == 0)
-
-typedef struct module_s module_t;
-
-struct module_s {
-    moduleid_t		id;		/* Module ID of this module        */
-
-    spinlock_t		lock;		/* Lock for this structure	   */
-
-    /* List of nodes in this module */
-    cnodeid_t		nodes[MAX_SLABS + 1];
-    geoid_t		geoid[MAX_SLABS + 1];
-
-    /* Fields for Module System Controller */
-    int			mesgpend;	/* Message pending                 */
-    int			shutdown;	/* Shutdown in progress            */
-    time_t		intrhist[MODULE_HIST_CNT];
-    int			histptr;
-
-    int			hbt_active;	/* MSC heartbeat monitor active    */
-    uint64_t		hbt_last;	/* RTC when last heartbeat sent    */
-
-    /* Module serial number info */
-    union {
-	char		snum_str[MAX_SERIAL_NUM_SIZE];	 /* used by CONFIG_SGI_IP27    */
-	uint64_t	snum_int;			 /* used by speedo */
-    } snum;
-    int			snum_valid;
-
-    int			disable_alert;
-    int			count_down;
-
-    /* System serial number info (used by SN1) */
-    char		sys_snum[MAX_SERIAL_NUM_SIZE];
-    int			sys_snum_valid;
-};
-
-/* module.c */
-extern module_t	       *sn_modules[MODULE_MAX];	/* Indexed by cmoduleid_t   */
-extern int		nummodules;
-
-extern module_t	       *module_lookup(moduleid_t id);
-extern void		format_module_id(char *buffer, moduleid_t m, int fmt);
-extern int		parse_module_id(char *buffer);
-
-#ifdef	__cplusplus
-}
-#endif
+extern char brick_types[];
+extern void format_module_id(char *, moduleid_t, int);
 
 #endif /* _ASM_IA64_SN_MODULE_H */
diff -Nru a/include/asm-ia64/sn/nodepda.h b/include/asm-ia64/sn/nodepda.h
--- a/include/asm-ia64/sn/nodepda.h	2004-12-24 13:36:30 -08:00
+++ b/include/asm-ia64/sn/nodepda.h	2004-12-24 13:36:30 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
 #ifndef _ASM_IA64_SN_NODEPDA_H
 #define _ASM_IA64_SN_NODEPDA_H
@@ -14,9 +14,7 @@
 #include <asm/sn/intr.h>
 #include <asm/sn/router.h>
 #include <asm/sn/pda.h>
-#include <asm/sn/module.h>
 #include <asm/sn/bte.h>
-#include <asm/sn/sn2/arch.h>
 
 /*
  * NUMA Node-Specific Data structures are defined in this file.
@@ -32,32 +30,14 @@
  * This structure provides a convenient way of keeping together 
  * all per-node data structures. 
  */
-
-
+struct phys_cpuid {
+	short			nasid;
+	char			subnode;
+	char			slice;
+};
 
 struct nodepda_s {
-	vertex_hdl_t 	xbow_vhdl;
-	nasid_t		xbow_peer;	/* NASID of our peer hub on xbow */
-	struct semaphore xbow_sema;	/* Sema for xbow synchronization */
-	slotid_t	slotdesc;
-	geoid_t		geoid;
-	module_t	*module;	/* Pointer to containing module */
-	xwidgetnum_t 	basew_id;
-	vertex_hdl_t 	basew_xc;
-	int		hubticks;
-	int		num_routers;	/* XXX not setup! Total routers in the system */
-
-	
-	char		*hwg_node_name;	/* hwgraph node name */
-	vertex_hdl_t	node_vertex;	/* Hwgraph vertex for this node */
-
 	void 		*pdinfo;	/* Platform-dependent per-node info */
-
-
-	nodepda_router_info_t	*npda_rip_first;
-	nodepda_router_info_t	**npda_rip_last;
-
-
 	spinlock_t		bist_lock;
 
 	/*
@@ -72,21 +52,14 @@
 	 */
 	struct nodepda_s	*pernode_pdaindr[MAX_COMPACT_NODES]; 
 
+	/*
+	 * Array of physical cpu identifiers. Indexed by cpuid.
+	 */
+	struct phys_cpuid	phys_cpuid[NR_CPUS];
 };
 
 typedef struct nodepda_s nodepda_t;
 
-struct irqpda_s {
-	int num_irq_used;
-	char irq_flags[NR_IRQS];
-	struct pci_dev *device_dev[NR_IRQS];
-	char share_count[NR_IRQS];
-	struct pci_dev *curr;
-};
-
-typedef struct irqpda_s irqpda_t;
-
-
 /*
  * Access Functions for node PDA.
  * Since there is one nodepda for each node, we need a convenient mechanism
@@ -104,32 +77,10 @@
 #define	nodepda		pda->p_nodepda		/* Ptr to this node's PDA */
 #define	NODEPDA(cnode)		(nodepda->pernode_pdaindr[cnode])
 
-
-/*
- * Macros to access data structures inside nodepda 
- */
-#define NODE_MODULEID(cnode)    geo_module((NODEPDA(cnode)->geoid))
-#define NODE_SLOTID(cnode)	(NODEPDA(cnode)->slotdesc)
-
-
-/*
- * Quickly convert a compact node ID into a hwgraph vertex
- */
-#define cnodeid_to_vertex(cnodeid) (NODEPDA(cnodeid)->node_vertex)
-
-
 /*
  * Check if given a compact node id the corresponding node has all the
  * cpus disabled. 
  */
 #define is_headless_node(cnode)		(nr_cpus_node(cnode) == 0)
-
-/*
- * Check if given a node vertex handle the corresponding node has all the
- * cpus disabled. 
- */
-#define is_headless_node_vertex(_nodevhdl) \
-			is_headless_node(nodevertex_to_cnodeid(_nodevhdl))
-
 
 #endif /* _ASM_IA64_SN_NODEPDA_H */
diff -Nru a/include/asm-ia64/sn/pci/bridge.h b/include/asm-ia64/sn/pci/bridge.h
--- a/include/asm-ia64/sn/pci/bridge.h	2004-12-24 13:36:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,1895 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_SN_PCI_BRIDGE_H
-#define _ASM_SN_PCI_BRIDGE_H
-
-
-/*
- * bridge.h - header file for bridge chip and bridge portion of xbridge chip
- *
- * Also including offsets for unique PIC registers.
- * The PIC asic is a follow-on to Xbridge and most of its registers are
- * identical to those of Xbridge.  PIC is different than Xbridge in that
- * it will accept 64 bit register access and that, in some cases, data
- * is kept in bits 63:32.   PIC registers that are identical to Xbridge
- * may be accessed identically to the Xbridge registers, allowing for lots
- * of code reuse.  Here are the access rules as described in the PIC
- * manual:
- * 
- * 	o Read a word on a DW boundary returns D31:00 of reg.
- * 	o Read a DW on a DW boundary returns D63:00 of reg.
- * 	o Write a word on a DW boundary loads D31:00 of reg.
- * 	o Write a DW on a DW boundary loads D63:00 of reg.
- * 	o No support for word boundary access that is not double word
- *           aligned.
- * 
- * So we can reuse a lot of bridge_s for PIC.  In bridge_s are included
- * #define tags and unions for 64 bit access to PIC registers.
- * For a detailed PIC register layout see pic.h.
- */
-
-#include <linux/config.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/pic.h>
-
-#define BRIDGE_REG_GET32(reg) \
-                __swab32( *(volatile uint32_t *) (((uint64_t)reg)^4) )
-
-#define BRIDGE_REG_SET32(reg) \
-                *(volatile uint32_t *) (((uint64_t)reg)^4)
-
-/* I/O page size */
-
-#if PAGE_SIZE == 4096
-#define IOPFNSHIFT		12	/* 4K per mapped page */
-#else
-#define IOPFNSHIFT		14	/* 16K per mapped page */
-#endif				/* PAGE_SIZE */
-
-#define IOPGSIZE		(1 << IOPFNSHIFT)
-#define IOPG(x)			((x) >> IOPFNSHIFT)
-#define IOPGOFF(x)		((x) & (IOPGSIZE-1))
-
-/* Bridge RAM sizes */
-
-#define BRIDGE_INTERNAL_ATES	128
-#define XBRIDGE_INTERNAL_ATES	1024
-
-#define BRIDGE_ATE_RAM_SIZE     (BRIDGE_INTERNAL_ATES<<3)	/* 1kB ATE */
-#define XBRIDGE_ATE_RAM_SIZE    (XBRIDGE_INTERNAL_ATES<<3)	/* 8kB ATE */
-
-#define PIC_WR_REQ_BUFSIZE      256
-
-#define BRIDGE_CONFIG_BASE	0x20000		/* start of bridge's */
-						/* map to each device's */
-						/* config space */
-#define BRIDGE_CONFIG1_BASE	0x28000		/* type 1 device config space */
-#define BRIDGE_CONFIG_END	0x30000
-#define BRIDGE_CONFIG_SLOT_SIZE 0x1000		/* each map == 4k */
-
-#define BRIDGE_SSRAM_512K	0x00080000	/* 512kB */
-#define BRIDGE_SSRAM_128K	0x00020000	/* 128kB */
-#define BRIDGE_SSRAM_64K	0x00010000	/* 64kB */
-#define BRIDGE_SSRAM_0K		0x00000000	/* 0kB */
-
-/* ========================================================================
- *    Bridge address map
- */
-
-#ifndef __ASSEMBLY__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * All accesses to bridge hardware registers must be done
- * using 32-bit loads and stores.
- */
-typedef uint32_t	bridgereg_t;
-
-typedef uint64_t	bridge_ate_t;
-
-/* pointers to bridge ATEs
- * are always "pointer to volatile"
- */
-typedef volatile bridge_ate_t  *bridge_ate_p;
-
-/*
- * It is generally preferred that hardware registers on the bridge
- * are located from C code via this structure.
- *
- * Generated from Bridge spec dated 04oct95
- */
-
-
-/*
- * pic_widget_cfg_s is a local definition of widget_cfg_t but with
- * a union of 64bit & 32bit registers, since PIC has 64bit widget
- * registers but BRIDGE and XBRIDGE have 32bit.	 PIC registers that
- * have valid bits (ie. not just reserved) in the upper 32bits are
- * defined as a union so we can access them as 64bit for PIC and
- * as 32bit for BRIDGE and XBRIDGE.
- */ 
-typedef volatile struct pic_widget_cfg_s {
-    bridgereg_t		    _b_wid_id;		    /* 0x000004 */
-    bridgereg_t		    _pad_000000;
-
-    union {
-	picreg_t	    _p_wid_stat;	    /* 0x000008 */
-	struct {
-	    bridgereg_t	    _b_wid_stat;	    /* 0x00000C */
-	    bridgereg_t	    _b_pad_000008;
-	} _b;
-    } u_wid_stat;
-    #define __p_wid_stat_64 u_wid_stat._p_wid_stat
-    #define __b_wid_stat u_wid_stat._b._b_wid_stat
-
-    bridgereg_t		    _b_wid_err_upper;	    /* 0x000014 */
-    bridgereg_t		    _pad_000010;
-
-    union {
-	picreg_t	    _p_wid_err_lower;	    /* 0x000018 */
-	struct {
-	    bridgereg_t	    _b_wid_err_lower;	    /* 0x00001C */
-	    bridgereg_t	    _b_pad_000018;
-	} _b;
-    } u_wid_err_lower;
-    #define __p_wid_err_64 u_wid_err_lower._p_wid_err_lower
-    #define __b_wid_err_lower u_wid_err_lower._b._b_wid_err_lower
-
-    union {
-	picreg_t	    _p_wid_control;	    /* 0x000020 */
-	struct {
-	    bridgereg_t	    _b_wid_control;	    /* 0x000024 */
-	    bridgereg_t	    _b_pad_000020;
-	} _b;
-    } u_wid_control;
-    #define __p_wid_control_64 u_wid_control._p_wid_control
-    #define __b_wid_control u_wid_control._b._b_wid_control
-
-    bridgereg_t		    _b_wid_req_timeout;	    /* 0x00002C */
-    bridgereg_t		    _pad_000028;
-
-    bridgereg_t		    _b_wid_int_upper;	    /* 0x000034 */
-    bridgereg_t		    _pad_000030;
-
-    union {
-	picreg_t	    _p_wid_int_lower;	    /* 0x000038 */
-	struct {
-	    bridgereg_t	    _b_wid_int_lower;	    /* 0x00003C */
-	    bridgereg_t	    _b_pad_000038;
-	} _b;
-    } u_wid_int_lower;
-    #define __p_wid_int_64 u_wid_int_lower._p_wid_int_lower
-    #define __b_wid_int_lower u_wid_int_lower._b._b_wid_int_lower
-
-    bridgereg_t		    _b_wid_err_cmdword;	    /* 0x000044 */
-    bridgereg_t		    _pad_000040;
-
-    bridgereg_t		    _b_wid_llp;		    /* 0x00004C */
-    bridgereg_t		    _pad_000048;
-
-    bridgereg_t		    _b_wid_tflush;	    /* 0x000054 */
-    bridgereg_t		    _pad_000050;
-} pic_widget_cfg_t;
-
-/*
- * BRIDGE, XBRIDGE, PIC register definitions.  NOTE: Prior to PIC, registers
- * were a 32bit quantity and double word aligned (and only accessible as a
- * 32bit word.  PIC registers are 64bits and accessible as words or double
- * words.  PIC registers that have valid bits (ie. not just reserved) in the
- * upper 32bits are defined as a union of one 64bit picreg_t and two 32bit
- * bridgereg_t so we can access them both ways.
- *
- * It is generally preferred that hardware registers on the bridge are
- * located from C code via this structure.
- *
- * Generated from Bridge spec dated 04oct95
- */
-
-typedef volatile struct bridge_s {
-
-    /* 0x000000-0x00FFFF -- Local Registers */
-
-    /* 0x000000-0x000057 -- Standard Widget Configuration */
-    union {
-	widget_cfg_t	    xtalk_widget_def;	    /* 0x000000 */
-	pic_widget_cfg_t    local_widget_def;	    /* 0x000000 */
-    } u_wid;
-
-    /* 32bit widget register access via the widget_cfg_t */
-    #define b_widget u_wid.xtalk_widget_def
-
-    /* 32bit widget register access via the pic_widget_cfg_t */
-    #define b_wid_id u_wid.local_widget_def._b_wid_id
-    #define b_wid_stat u_wid.local_widget_def.__b_wid_stat
-    #define b_wid_err_upper u_wid.local_widget_def._b_wid_err_upper
-    #define b_wid_err_lower u_wid.local_widget_def.__b_wid_err_lower
-    #define b_wid_control u_wid.local_widget_def.__b_wid_control
-    #define b_wid_req_timeout u_wid.local_widget_def._b_wid_req_timeout
-    #define b_wid_int_upper u_wid.local_widget_def._b_wid_int_upper
-    #define b_wid_int_lower u_wid.local_widget_def.__b_wid_int_lower
-    #define b_wid_err_cmdword u_wid.local_widget_def._b_wid_err_cmdword
-    #define b_wid_llp u_wid.local_widget_def._b_wid_llp
-    #define b_wid_tflush u_wid.local_widget_def._b_wid_tflush
-
-    /* 64bit widget register access via the pic_widget_cfg_t */
-    #define p_wid_stat_64 u_wid.local_widget_def.__p_wid_stat_64
-    #define p_wid_err_64 u_wid.local_widget_def.__p_wid_err_64
-    #define p_wid_control_64 u_wid.local_widget_def.__p_wid_control_64
-    #define p_wid_int_64 u_wid.local_widget_def.__p_wid_int_64
-
-    /* 0x000058-0x00007F -- Bridge-specific Widget Configuration */
-    bridgereg_t             b_wid_aux_err;          /* 0x00005C */
-    bridgereg_t             _pad_000058;
-
-    bridgereg_t             b_wid_resp_upper;       /* 0x000064 */
-    bridgereg_t             _pad_000060;
-
-    union {
-        picreg_t            _p_wid_resp_lower;      /* 0x000068 */
-        struct {
-            bridgereg_t     _b_wid_resp_lower;      /* 0x00006C */
-            bridgereg_t     _b_pad_000068;
-        } _b;
-    } u_wid_resp_lower;
-    #define p_wid_resp_64 u_wid_resp_lower._p_wid_resp_lower
-    #define b_wid_resp_lower u_wid_resp_lower._b._b_wid_resp_lower
-
-    bridgereg_t             b_wid_tst_pin_ctrl;     /* 0x000074 */
-    bridgereg_t             _pad_000070;
-
-    union {
-        picreg_t            _p_addr_lkerr;          /* 0x000078 */
-        struct {
-            bridgereg_t     _b_pad_00007C;
-            bridgereg_t     _b_pad_000078;
-        } _b;
-    } u_addr_lkerr;
-    #define p_addr_lkerr_64 u_addr_lkerr._p_addr_lkerr
-
-    /* 0x000080-0x00008F -- PMU */
-    bridgereg_t		    b_dir_map;		    /* 0x000084 */
-    bridgereg_t		    _pad_000080;
-
-    bridgereg_t		    _pad_00008C;
-    bridgereg_t		    _pad_000088;
-
-    /* 0x000090-0x00009F -- SSRAM */
-    bridgereg_t             b_ram_perr_or_map_fault;/* 0x000094 */
-    bridgereg_t		    _pad_000090;
-    #define b_ram_perr  b_ram_perr_or_map_fault     /* Bridge */
-    #define b_map_fault b_ram_perr_or_map_fault     /* Xbridge & PIC */
-
-    bridgereg_t		    _pad_00009C;
-    bridgereg_t		    _pad_000098;
-
-    /* 0x0000A0-0x0000AF -- Arbitration */
-    bridgereg_t		    b_arb;		    /* 0x0000A4 */
-    bridgereg_t		    _pad_0000A0;
-
-    bridgereg_t		    _pad_0000AC;
-    bridgereg_t		    _pad_0000A8;
-
-    /* 0x0000B0-0x0000BF -- Number In A Can or ATE Parity Error */
-    union {
-	picreg_t	    _p_ate_parity_err;	    /* 0x0000B0 */
-	struct {
-	    bridgereg_t	    _b_nic;		    /* 0x0000B4 */
-	    bridgereg_t	    _b_pad_0000B0;
-	} _b;
-    } u_ate_parity_err_or_nic;
-    #define p_ate_parity_err_64 u_ate_parity_err_or_nic._p_ate_parity_err
-    #define b_nic u_ate_parity_err_or_nic._b._b_nic
-
-    bridgereg_t		    _pad_0000BC;
-    bridgereg_t		    _pad_0000B8;
-
-    /* 0x0000C0-0x0000FF -- PCI/GIO */
-    bridgereg_t		    b_bus_timeout;	    /* 0x0000C4 */
-    bridgereg_t		    _pad_0000C0;
-    #define b_pci_bus_timeout b_bus_timeout
-
-    bridgereg_t		    b_pci_cfg;		    /* 0x0000CC */
-    bridgereg_t		    _pad_0000C8;
-
-    bridgereg_t		    b_pci_err_upper;	    /* 0x0000D4 */
-    bridgereg_t		    _pad_0000D0;
-    #define b_gio_err_upper b_pci_err_upper
-
-    union {
-	picreg_t	    _p_pci_err_lower;	    /* 0x0000D8 */
-	struct {
-	    bridgereg_t	    _b_pci_err_lower;	    /* 0x0000DC */
-	    bridgereg_t	    _b_pad_0000D8;
-	} _b;
-    } u_pci_err_lower;
-    #define p_pci_err_64 u_pci_err_lower._p_pci_err_lower
-    #define b_pci_err_lower u_pci_err_lower._b._b_pci_err_lower
-    #define b_gio_err_lower b_pci_err_lower
-
-    bridgereg_t		    _pad_0000E0[8];
-
-    /* 0x000100-0x0001FF -- Interrupt */
-    union {
-	picreg_t	    _p_int_status;	    /* 0x000100 */		
-	struct {
-	    bridgereg_t	    _b_int_status;	    /* 0x000104 */
-	    bridgereg_t	    _b_pad_000100;
-	} _b;
-    } u_int_status;
-    #define p_int_status_64 u_int_status._p_int_status
-    #define b_int_status u_int_status._b._b_int_status
-
-    union {
-	picreg_t	    _p_int_enable;	    /* 0x000108 */		
-	struct {
-	    bridgereg_t	    _b_int_enable;	    /* 0x00010C */
-	    bridgereg_t	    _b_pad_000108;
-	} _b;
-    } u_int_enable;
-    #define p_int_enable_64 u_int_enable._p_int_enable
-    #define b_int_enable u_int_enable._b._b_int_enable
-
-    union {
-	picreg_t	    _p_int_rst_stat;	    /* 0x000110 */		
-	struct {
-	    bridgereg_t	    _b_int_rst_stat;	    /* 0x000114 */
-	    bridgereg_t	    _b_pad_000110;
-	} _b;
-    } u_int_rst_stat;
-    #define p_int_rst_stat_64 u_int_rst_stat._p_int_rst_stat
-    #define b_int_rst_stat u_int_rst_stat._b._b_int_rst_stat
-
-    bridgereg_t		    b_int_mode;		    /* 0x00011C */
-    bridgereg_t		    _pad_000118;
-
-    bridgereg_t		    b_int_device;	    /* 0x000124 */
-    bridgereg_t		    _pad_000120;
-
-    bridgereg_t		    b_int_host_err;	    /* 0x00012C */
-    bridgereg_t		    _pad_000128;
-
-    union {
-	picreg_t	    _p_int_addr[8];	    /* 0x0001{30,,,68} */
-	struct {
-	    bridgereg_t	    addr;		    /* 0x0001{34,,,6C} */
-	    bridgereg_t	    _b_pad;
-	} _b[8];
-    } u_int_addr;
-    #define p_int_addr_64 u_int_addr._p_int_addr
-    #define b_int_addr u_int_addr._b
-
-    union {
-	picreg_t	    _p_err_int_view;	    /* 0x000170 */
-	struct {
-	    bridgereg_t	    _b_err_int_view;	    /* 0x000174 */
-	    bridgereg_t	    _b_pad_000170;
-	} _b;
-    } u_err_int_view;
-    #define p_err_int_view_64 u_err_int_view._p_err_int_view
-    #define b_err_int_view u_err_int_view._b._b_err_int_view
-
-    union {
-	picreg_t	    _p_mult_int;	    /* 0x000178 */
-	struct {
-	    bridgereg_t	    _b_mult_int;	    /* 0x00017C */
-	    bridgereg_t	    _b_pad_000178;
-	} _b;
-    } u_mult_int;
-    #define p_mult_int_64 u_mult_int._p_mult_int
-    #define b_mult_int u_mult_int._b._b_mult_int
-
-    struct {
-	bridgereg_t	    intr;		    /* 0x0001{84,,,BC} */
-	bridgereg_t	    __pad;
-    } b_force_always[8];
-
-    struct {
-	bridgereg_t	    intr;		    /* 0x0001{C4,,,FC} */
-	bridgereg_t	    __pad;
-    } b_force_pin[8];
-
-    /* 0x000200-0x0003FF -- Device */
-    struct {
-	bridgereg_t	    reg;		    /* 0x0002{04,,,3C} */
-	bridgereg_t	    __pad;
-    } b_device[8];
-
-    struct {
-	bridgereg_t	    reg;		    /* 0x0002{44,,,7C} */
-	bridgereg_t	    __pad;
-    } b_wr_req_buf[8];
-
-    struct {
-	bridgereg_t	    reg;		    /* 0x0002{84,,,8C} */
-	bridgereg_t	    __pad;
-    } b_rrb_map[2];
-    #define b_even_resp	b_rrb_map[0].reg	    /* 0x000284 */
-    #define b_odd_resp	b_rrb_map[1].reg	    /* 0x00028C */
-
-    bridgereg_t		    b_resp_status;	    /* 0x000294 */
-    bridgereg_t		    _pad_000290;
-
-    bridgereg_t		    b_resp_clear;	    /* 0x00029C */
-    bridgereg_t		    _pad_000298;
-
-    bridgereg_t		    _pad_0002A0[24];
-
-    /* Xbridge/PIC only */
-    union {
-	struct {
-	    picreg_t	    lower;		    /* 0x0003{08,,,F8} */
-	    picreg_t	    upper;		    /* 0x0003{00,,,F0} */
-	} _p[16];
-	struct {
-	    bridgereg_t	    upper;		    /* 0x0003{04,,,F4} */
-	    bridgereg_t	    _b_pad1;
-	    bridgereg_t	    lower;		    /* 0x0003{0C,,,FC} */
-	    bridgereg_t	    _b_pad2;
-	} _b[16];
-    } u_buf_addr_match;
-    #define p_buf_addr_match_64 u_buf_addr_match._p
-    #define b_buf_addr_match u_buf_addr_match._b
-
-    /* 0x000400-0x0005FF -- Performance Monitor Registers (even only) */
-    struct {
-	bridgereg_t	    flush_w_touch;	    /* 0x000{404,,,5C4} */
-	bridgereg_t	    __pad1;
-	bridgereg_t	    flush_wo_touch;	    /* 0x000{40C,,,5CC} */
-	bridgereg_t	    __pad2;
-	bridgereg_t	    inflight;		    /* 0x000{414,,,5D4} */
-	bridgereg_t	    __pad3;
-	bridgereg_t	    prefetch;		    /* 0x000{41C,,,5DC} */
-	bridgereg_t	    __pad4;
-	bridgereg_t	    total_pci_retry;	    /* 0x000{424,,,5E4} */
-	bridgereg_t	    __pad5;
-	bridgereg_t	    max_pci_retry;	    /* 0x000{42C,,,5EC} */
-	bridgereg_t	    __pad6;
-	bridgereg_t	    max_latency;	    /* 0x000{434,,,5F4} */
-	bridgereg_t	    __pad7;
-	bridgereg_t	    clear_all;		    /* 0x000{43C,,,5FC} */
-	bridgereg_t	    __pad8;
-    } b_buf_count[8];
-
-    /*
-     * "PCI/X registers that are specific to PIC".   See pic.h.
-     */
-
-    /* 0x000600-0x0009FF -- PCI/X registers */
-    picreg_t		    p_pcix_bus_err_addr_64;     /* 0x000600 */
-    picreg_t		    p_pcix_bus_err_attr_64;     /* 0x000608 */
-    picreg_t		    p_pcix_bus_err_data_64;     /* 0x000610 */
-    picreg_t		    p_pcix_pio_split_addr_64;	/* 0x000618 */
-    picreg_t		    p_pcix_pio_split_attr_64;	/* 0x000620 */
-    picreg_t		    p_pcix_dma_req_err_attr_64; /* 0x000628 */
-    picreg_t		    p_pcix_dma_req_err_addr_64;	/* 0x000630 */
-    picreg_t		    p_pcix_timeout_64;		/* 0x000638 */
-
-    picreg_t		    _pad_000600[120];
-
-    /* 0x000A00-0x000BFF -- PCI/X Read&Write Buffer */
-    struct {
-    	picreg_t	    p_buf_attr;		    /* 0X000{A08,,,AF8} */
-    	picreg_t	    p_buf_addr;		    /* 0x000{A00,,,AF0} */
-    } p_pcix_read_buf_64[16];
-
-    struct {
-	picreg_t	    p_buf_attr;		    /* 0x000{B08,,,BE8} */
-	picreg_t	    p_buf_addr;		    /* 0x000{B00,,,BE0} */
-	picreg_t	    __pad1;		    /* 0x000{B18,,,BF8} */
-	picreg_t	    p_buf_valid;	    /* 0x000{B10,,,BF0} */
-    } p_pcix_write_buf_64[8];
-
-    /* 
-     * end "PCI/X registers that are specific to PIC"
-     */
-
-    char		    _pad_000c00[0x010000 - 0x000c00];
-
-    /* 0x010000-0x011fff -- Internal Address Translation Entry RAM */
-    /*
-     * Xbridge and PIC have 1024 internal ATE's and the Bridge has 128.
-     * Make enough room for the Xbridge/PIC ATE's and depend on runtime
-     * checks to limit access to bridge ATE's.
-     *
-     * In [X]bridge the internal ATE Ram is writen as double words only,
-     * but due to internal design issues it is read back as single words. 
-     * i.e:
-     *   b_int_ate_ram[index].hi.rd << 32 | xb_int_ate_ram_lo[index].rd
-     */
-    union {
-	bridge_ate_t	    wr;	/* write-only */    /* 0x01{0000,,,1FF8} */
-	struct {
-	    bridgereg_t	    rd; /* read-only */     /* 0x01{0004,,,1FFC} */
-	    bridgereg_t	    _p_pad;
-	} hi;
-    } b_int_ate_ram[XBRIDGE_INTERNAL_ATES];
-    #define b_int_ate_ram_lo(idx) b_int_ate_ram[idx+512].hi.rd
-
-    /* 0x012000-0x013fff -- Internal Address Translation Entry RAM LOW */
-    struct {
-	bridgereg_t	    rd; /* read-only */	    /* 0x01{2004,,,3FFC} */
-	bridgereg_t	    _p_pad;
-    } xb_int_ate_ram_lo[XBRIDGE_INTERNAL_ATES];
-
-    char		    _pad_014000[0x18000 - 0x014000];
-
-    /* 0x18000-0x197F8 -- PIC Write Request Ram */
-				/* 0x18000 - 0x187F8 */
-    picreg_t		    p_wr_req_lower[PIC_WR_REQ_BUFSIZE];
-				/* 0x18800 - 0x18FF8 */
-    picreg_t		    p_wr_req_upper[PIC_WR_REQ_BUFSIZE];
-				/* 0x19000 - 0x197F8 */
-    picreg_t		    p_wr_req_parity[PIC_WR_REQ_BUFSIZE];
-
-    char		    _pad_019800[0x20000 - 0x019800];
-
-    /* 0x020000-0x027FFF -- PCI Device Configuration Spaces */
-    union {				/* make all access sizes available. */
-	unsigned char		    c[0x1000 / 1];	    /* 0x02{0000,,,7FFF} */
-	uint16_t	    s[0x1000 / 2];	    /* 0x02{0000,,,7FFF} */
-	uint32_t	    l[0x1000 / 4];	    /* 0x02{0000,,,7FFF} */
-	uint64_t	    d[0x1000 / 8];	    /* 0x02{0000,,,7FFF} */
-	union {
-	    unsigned char	    c[0x100 / 1];
-	    uint16_t	    s[0x100 / 2];
-	    uint32_t	    l[0x100 / 4];
-	    uint64_t	    d[0x100 / 8];
-	} f[8];
-    } b_type0_cfg_dev[8];			    /* 0x02{0000,,,7FFF} */
-
-    /* 0x028000-0x028FFF -- PCI Type 1 Configuration Space */
-    union {				/* make all access sizes available. */
-	unsigned char		    c[0x1000 / 1];
-	uint16_t	    s[0x1000 / 2];
-	uint32_t	    l[0x1000 / 4];
-	uint64_t	    d[0x1000 / 8];
-        union {
-            unsigned char         c[0x100 / 1];
-            uint16_t        s[0x100 / 2];
-            uint32_t        l[0x100 / 4];
-            uint64_t        d[0x100 / 8];
-	} f[8];
-    } b_type1_cfg;				    /* 0x028000-0x029000 */
-
-    char		    _pad_029000[0x007000];  /* 0x029000-0x030000 */
-
-    /* 0x030000-0x030007 -- PCI Interrupt Acknowledge Cycle */
-    union {
-	unsigned char		    c[8 / 1];
-	uint16_t	    s[8 / 2];
-	uint32_t	    l[8 / 4];
-	uint64_t	    d[8 / 8];
-    } b_pci_iack;				    /* 0x030000-0x030007 */
-
-    unsigned char		    _pad_030007[0x04fff8];  /* 0x030008-0x07FFFF */
-
-    /* 0x080000-0x0FFFFF -- External Address Translation Entry RAM */
-    bridge_ate_t	    b_ext_ate_ram[0x10000];
-
-    /* 0x100000-0x1FFFFF -- Reserved */
-    char		    _pad_100000[0x200000-0x100000];
-
-    /* 0x200000-0xBFFFFF -- PCI/GIO Device Spaces */
-    union {				/* make all access sizes available. */
-	unsigned char		    c[0x100000 / 1];
-	uint16_t	    s[0x100000 / 2];
-	uint32_t	    l[0x100000 / 4];
-	uint64_t	    d[0x100000 / 8];
-    } b_devio_raw[10];
-
-    /* b_devio macro is a bit strange; it reflects the
-     * fact that the Bridge ASIC provides 2M for the
-     * first two DevIO windows and 1M for the other six.
-     */
-    #define b_devio(n)	b_devio_raw[((n)<2)?(n*2):(n+2)]
-
-    /* 0xC00000-0xFFFFFF -- External Flash Proms 1,0 */
-    union {				/* make all access sizes available. */
-	unsigned char		    c[0x400000 / 1];	/* read-only */
-	uint16_t	    s[0x400000 / 2];	/* read-write */
-	uint32_t	    l[0x400000 / 4];	/* read-only */
-	uint64_t	    d[0x400000 / 8];	/* read-only */
-    } b_external_flash;
-} bridge_t;
-
-#define berr_field	berr_un.berr_st
-#endif				/* __ASSEMBLY__ */
-
-/*
- * The values of these macros can and should be crosschecked
- * regularly against the offsets of the like-named fields
- * within the "bridge_t" structure above.
- */
-
-/* Byte offset macros for Bridge internal registers */
-
-#define BRIDGE_WID_ID		WIDGET_ID
-#define BRIDGE_WID_STAT		WIDGET_STATUS
-#define BRIDGE_WID_ERR_UPPER	WIDGET_ERR_UPPER_ADDR
-#define BRIDGE_WID_ERR_LOWER	WIDGET_ERR_LOWER_ADDR
-#define BRIDGE_WID_CONTROL	WIDGET_CONTROL
-#define BRIDGE_WID_REQ_TIMEOUT	WIDGET_REQ_TIMEOUT
-#define BRIDGE_WID_INT_UPPER	WIDGET_INTDEST_UPPER_ADDR
-#define BRIDGE_WID_INT_LOWER	WIDGET_INTDEST_LOWER_ADDR
-#define BRIDGE_WID_ERR_CMDWORD	WIDGET_ERR_CMD_WORD
-#define BRIDGE_WID_LLP		WIDGET_LLP_CFG
-#define BRIDGE_WID_TFLUSH	WIDGET_TFLUSH
-
-#define BRIDGE_WID_AUX_ERR	0x00005C	/* Aux Error Command Word */
-#define BRIDGE_WID_RESP_UPPER	0x000064	/* Response Buf Upper Addr */
-#define BRIDGE_WID_RESP_LOWER	0x00006C	/* Response Buf Lower Addr */
-#define BRIDGE_WID_TST_PIN_CTRL 0x000074	/* Test pin control */
-
-#define BRIDGE_DIR_MAP		0x000084	/* Direct Map reg */
-
-/* Bridge has SSRAM Parity Error and Xbridge has Map Fault here */
-#define BRIDGE_RAM_PERR 	0x000094	/* SSRAM Parity Error */
-#define BRIDGE_MAP_FAULT	0x000094	/* Map Fault */
-
-#define BRIDGE_ARB		0x0000A4	/* Arbitration Priority reg */
-
-#define BRIDGE_NIC		0x0000B4	/* Number In A Can */
-
-#define BRIDGE_BUS_TIMEOUT	0x0000C4	/* Bus Timeout Register */
-#define BRIDGE_PCI_BUS_TIMEOUT	BRIDGE_BUS_TIMEOUT
-#define BRIDGE_PCI_CFG		0x0000CC	/* PCI Type 1 Config reg */
-#define BRIDGE_PCI_ERR_UPPER	0x0000D4	/* PCI error Upper Addr */
-#define BRIDGE_PCI_ERR_LOWER	0x0000DC	/* PCI error Lower Addr */
-
-#define BRIDGE_INT_STATUS	0x000104	/* Interrupt Status */
-#define BRIDGE_INT_ENABLE	0x00010C	/* Interrupt Enables */
-#define BRIDGE_INT_RST_STAT	0x000114	/* Reset Intr Status */
-#define BRIDGE_INT_MODE		0x00011C	/* Interrupt Mode */
-#define BRIDGE_INT_DEVICE	0x000124	/* Interrupt Device */
-#define BRIDGE_INT_HOST_ERR	0x00012C	/* Host Error Field */
-
-#define BRIDGE_INT_ADDR0	0x000134	/* Host Address Reg */
-#define BRIDGE_INT_ADDR_OFF	0x000008	/* Host Addr offset (1..7) */
-#define BRIDGE_INT_ADDR(x)	(BRIDGE_INT_ADDR0+(x)*BRIDGE_INT_ADDR_OFF)
-
-#define BRIDGE_INT_VIEW		0x000174	/* Interrupt view */
-#define BRIDGE_MULTIPLE_INT	0x00017c	/* Multiple interrupt occurred */
-
-#define BRIDGE_FORCE_ALWAYS0	0x000184	/* Force an interrupt (always)*/
-#define BRIDGE_FORCE_ALWAYS_OFF 0x000008	/* Force Always offset */
-#define BRIDGE_FORCE_ALWAYS(x)  (BRIDGE_FORCE_ALWAYS0+(x)*BRIDGE_FORCE_ALWAYS_OFF)
-
-#define BRIDGE_FORCE_PIN0	0x0001c4	/* Force an interrupt */
-#define BRIDGE_FORCE_PIN_OFF 	0x000008	/* Force Pin offset */
-#define BRIDGE_FORCE_PIN(x)  (BRIDGE_FORCE_PIN0+(x)*BRIDGE_FORCE_PIN_OFF)
-
-#define BRIDGE_DEVICE0		0x000204	/* Device 0 */
-#define BRIDGE_DEVICE_OFF	0x000008	/* Device offset (1..7) */
-#define BRIDGE_DEVICE(x)	(BRIDGE_DEVICE0+(x)*BRIDGE_DEVICE_OFF)
-
-#define BRIDGE_WR_REQ_BUF0	0x000244	/* Write Request Buffer 0 */
-#define BRIDGE_WR_REQ_BUF_OFF	0x000008	/* Buffer Offset (1..7) */
-#define BRIDGE_WR_REQ_BUF(x)	(BRIDGE_WR_REQ_BUF0+(x)*BRIDGE_WR_REQ_BUF_OFF)
-
-#define BRIDGE_EVEN_RESP	0x000284	/* Even Device Response Buf */
-#define BRIDGE_ODD_RESP		0x00028C	/* Odd Device Response Buf */
-
-#define BRIDGE_RESP_STATUS	0x000294	/* Read Response Status reg */
-#define BRIDGE_RESP_CLEAR	0x00029C	/* Read Response Clear reg */
-
-#define BRIDGE_BUF_ADDR_UPPER0	0x000304
-#define BRIDGE_BUF_ADDR_UPPER_OFF 0x000010	/* PCI Buffer Upper Offset */
-#define BRIDGE_BUF_ADDR_UPPER(x) (BRIDGE_BUF_ADDR_UPPER0+(x)*BRIDGE_BUF_ADDR_UPPER_OFF)
-
-#define BRIDGE_BUF_ADDR_LOWER0	0x00030c
-#define BRIDGE_BUF_ADDR_LOWER_OFF 0x000010	/* PCI Buffer Upper Offset */
-#define BRIDGE_BUF_ADDR_LOWER(x) (BRIDGE_BUF_ADDR_LOWER0+(x)*BRIDGE_BUF_ADDR_LOWER_OFF)
-
-/* 
- * Performance Monitor Registers.
- *
- * The Performance registers are those registers which are associated with
- * monitoring the performance of PCI generated reads to the host environ
- * ment. Because of the size of the register file only the even registers
- * were instrumented.
- */
-
-#define BRIDGE_BUF_OFF 0x40
-#define BRIDGE_BUF_NEXT(base, off) (base+((off)*BRIDGE_BUF_OFF))
-
-/*
- * Buffer (x) Flush Count with Data Touch Register.
- *
- * This counter is incremented each time the corresponding response buffer
- * is flushed after at least a single data element in the buffer is used.
- * A word write to this address clears the count.
- */
-
-#define BRIDGE_BUF_0_FLUSH_TOUCH  0x000404
-#define BRIDGE_BUF_2_FLUSH_TOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_TOUCH, 1)
-#define BRIDGE_BUF_4_FLUSH_TOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_TOUCH, 2)
-#define BRIDGE_BUF_6_FLUSH_TOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_TOUCH, 3)
-#define BRIDGE_BUF_8_FLUSH_TOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_TOUCH, 4)
-#define BRIDGE_BUF_10_FLUSH_TOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_TOUCH, 5)
-#define BRIDGE_BUF_12_FLUSH_TOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_TOUCH, 6)
-#define BRIDGE_BUF_14_FLUSH_TOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_TOUCH, 7)
-
-/*
- * Buffer (x) Flush Count w/o Data Touch Register
- *
- * This counter is incremented each time the corresponding response buffer
- * is flushed without any data element in the buffer being used. A word
- * write to this address clears the count.
- */
-
-
-#define BRIDGE_BUF_0_FLUSH_NOTOUCH  0x00040c
-#define BRIDGE_BUF_2_FLUSH_NOTOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_NOTOUCH, 1)
-#define BRIDGE_BUF_4_FLUSH_NOTOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_NOTOUCH, 2)
-#define BRIDGE_BUF_6_FLUSH_NOTOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_NOTOUCH, 3)
-#define BRIDGE_BUF_8_FLUSH_NOTOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_NOTOUCH, 4)
-#define BRIDGE_BUF_10_FLUSH_NOTOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_NOTOUCH, 5)
-#define BRIDGE_BUF_12_FLUSH_NOTOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_NOTOUCH, 6)
-#define BRIDGE_BUF_14_FLUSH_NOTOUCH  BRIDGE_BUF_NEXT(BRIDGE_BUF_0_FLUSH_NOTOUCH, 7)
-
-/*
- * Buffer (x) Request in Flight Count Register
- *
- * This counter is incremented on each bus clock while the request is in
- * flight. A word write to this address clears the count.
- */
-
-#define BRIDGE_BUF_0_INFLIGHT	 0x000414
-#define BRIDGE_BUF_2_INFLIGHT    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_INFLIGHT, 1)
-#define BRIDGE_BUF_4_INFLIGHT    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_INFLIGHT, 2)
-#define BRIDGE_BUF_6_INFLIGHT    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_INFLIGHT, 3)
-#define BRIDGE_BUF_8_INFLIGHT    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_INFLIGHT, 4)
-#define BRIDGE_BUF_10_INFLIGHT   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_INFLIGHT, 5)
-#define BRIDGE_BUF_12_INFLIGHT   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_INFLIGHT, 6)
-#define BRIDGE_BUF_14_INFLIGHT   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_INFLIGHT, 7)
-
-/*
- * Buffer (x) Prefetch Request Count Register
- *
- * This counter is incremented each time the request using this buffer was
- * generated from the prefetcher. A word write to this address clears the
- * count.
- */
-
-#define BRIDGE_BUF_0_PREFETCH	 0x00041C
-#define BRIDGE_BUF_2_PREFETCH    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PREFETCH, 1)
-#define BRIDGE_BUF_4_PREFETCH    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PREFETCH, 2)
-#define BRIDGE_BUF_6_PREFETCH    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PREFETCH, 3)
-#define BRIDGE_BUF_8_PREFETCH    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PREFETCH, 4)
-#define BRIDGE_BUF_10_PREFETCH   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PREFETCH, 5)
-#define BRIDGE_BUF_12_PREFETCH   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PREFETCH, 6)
-#define BRIDGE_BUF_14_PREFETCH   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PREFETCH, 7)
-
-/*
- * Buffer (x) Total PCI Retry Count Register
- *
- * This counter is incremented each time a PCI bus retry occurs and the ad
- * dress matches the tag for the selected buffer. The buffer must also has
- * this request in-flight. A word write to this address clears the count.
- */
-
-#define BRIDGE_BUF_0_PCI_RETRY	 0x000424
-#define BRIDGE_BUF_2_PCI_RETRY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PCI_RETRY, 1)
-#define BRIDGE_BUF_4_PCI_RETRY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PCI_RETRY, 2)
-#define BRIDGE_BUF_6_PCI_RETRY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PCI_RETRY, 3)
-#define BRIDGE_BUF_8_PCI_RETRY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PCI_RETRY, 4)
-#define BRIDGE_BUF_10_PCI_RETRY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PCI_RETRY, 5)
-#define BRIDGE_BUF_12_PCI_RETRY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PCI_RETRY, 6)
-#define BRIDGE_BUF_14_PCI_RETRY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_PCI_RETRY, 7)
-
-/*
- * Buffer (x) Max PCI Retry Count Register
- *
- * This counter is contains the maximum retry count for a single request
- * which was in-flight for this buffer. A word write to this address
- * clears the count.
- */
-
-#define BRIDGE_BUF_0_MAX_PCI_RETRY	 0x00042C
-#define BRIDGE_BUF_2_MAX_PCI_RETRY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_PCI_RETRY, 1)
-#define BRIDGE_BUF_4_MAX_PCI_RETRY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_PCI_RETRY, 2)
-#define BRIDGE_BUF_6_MAX_PCI_RETRY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_PCI_RETRY, 3)
-#define BRIDGE_BUF_8_MAX_PCI_RETRY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_PCI_RETRY, 4)
-#define BRIDGE_BUF_10_MAX_PCI_RETRY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_PCI_RETRY, 5)
-#define BRIDGE_BUF_12_MAX_PCI_RETRY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_PCI_RETRY, 6)
-#define BRIDGE_BUF_14_MAX_PCI_RETRY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_PCI_RETRY, 7)
-
-/*
- * Buffer (x) Max Latency Count Register
- *
- * This counter is contains the maximum count (in bus clocks) for a single
- * request which was in-flight for this buffer. A word write to this
- * address clears the count.
- */
-
-#define BRIDGE_BUF_0_MAX_LATENCY	 0x000434
-#define BRIDGE_BUF_2_MAX_LATENCY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_LATENCY, 1)
-#define BRIDGE_BUF_4_MAX_LATENCY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_LATENCY, 2)
-#define BRIDGE_BUF_6_MAX_LATENCY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_LATENCY, 3)
-#define BRIDGE_BUF_8_MAX_LATENCY    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_LATENCY, 4)
-#define BRIDGE_BUF_10_MAX_LATENCY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_LATENCY, 5)
-#define BRIDGE_BUF_12_MAX_LATENCY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_LATENCY, 6)
-#define BRIDGE_BUF_14_MAX_LATENCY   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_MAX_LATENCY, 7)
-
-/*
- * Buffer (x) Clear All Register
- *
- * Any access to this register clears all the count values for the (x)
- * registers.
- */
-
-#define BRIDGE_BUF_0_CLEAR_ALL	 0x00043C
-#define BRIDGE_BUF_2_CLEAR_ALL    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_CLEAR_ALL, 1)
-#define BRIDGE_BUF_4_CLEAR_ALL    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_CLEAR_ALL, 2)
-#define BRIDGE_BUF_6_CLEAR_ALL    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_CLEAR_ALL, 3)
-#define BRIDGE_BUF_8_CLEAR_ALL    BRIDGE_BUF_NEXT(BRIDGE_BUF_0_CLEAR_ALL, 4)
-#define BRIDGE_BUF_10_CLEAR_ALL   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_CLEAR_ALL, 5)
-#define BRIDGE_BUF_12_CLEAR_ALL   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_CLEAR_ALL, 6)
-#define BRIDGE_BUF_14_CLEAR_ALL   BRIDGE_BUF_NEXT(BRIDGE_BUF_0_CLEAR_ALL, 7)
-
-/* end of Performance Monitor Registers */
-
-/* Byte offset macros for Bridge I/O space.
- *
- * NOTE: Where applicable please use the PCIBR_xxx or PCIBRIDGE_xxx
- * macros (below) as they will handle [X]Bridge and PIC. For example,
- * PCIBRIDGE_TYPE0_CFG_DEV0() vs BRIDGE_TYPE0_CFG_DEV0
- */
-
-#define BRIDGE_ATE_RAM		0x00010000	/* Internal Addr Xlat Ram */
-
-#define BRIDGE_TYPE0_CFG_DEV0	0x00020000	/* Type 0 Cfg, Device 0 */
-#define BRIDGE_TYPE0_CFG_SLOT_OFF	0x00001000	/* Type 0 Cfg Slot Offset (1..7) */
-#define BRIDGE_TYPE0_CFG_FUNC_OFF	0x00000100	/* Type 0 Cfg Func Offset (1..7) */
-#define BRIDGE_TYPE0_CFG_DEV(s)		(BRIDGE_TYPE0_CFG_DEV0+\
-					 (s)*BRIDGE_TYPE0_CFG_SLOT_OFF)
-#define BRIDGE_TYPE0_CFG_DEVF(s,f)	(BRIDGE_TYPE0_CFG_DEV0+\
-					 (s)*BRIDGE_TYPE0_CFG_SLOT_OFF+\
-					 (f)*BRIDGE_TYPE0_CFG_FUNC_OFF)
-
-#define BRIDGE_TYPE1_CFG	0x00028000	/* Type 1 Cfg space */
-
-#define BRIDGE_PCI_IACK		0x00030000	/* PCI Interrupt Ack */
-#define BRIDGE_EXT_SSRAM	0x00080000	/* Extern SSRAM (ATE) */
-
-/* Byte offset macros for Bridge device IO spaces */
-
-#define BRIDGE_DEV_CNT		8	/* Up to 8 devices per bridge */
-#define BRIDGE_DEVIO0		0x00200000	/* Device IO 0 Addr */
-#define BRIDGE_DEVIO1		0x00400000	/* Device IO 1 Addr */
-#define BRIDGE_DEVIO2		0x00600000	/* Device IO 2 Addr */
-#define BRIDGE_DEVIO_OFF	0x00100000	/* Device IO Offset (3..7) */
-
-#define BRIDGE_DEVIO_2MB	0x00200000	/* Device IO Offset (0..1) */
-#define BRIDGE_DEVIO_1MB	0x00100000	/* Device IO Offset (2..7) */
-
-#ifndef __ASSEMBLY__
-
-#define BRIDGE_DEVIO(x)		((x)<=1 ? BRIDGE_DEVIO0+(x)*BRIDGE_DEVIO_2MB : BRIDGE_DEVIO2+((x)-2)*BRIDGE_DEVIO_1MB)
-
-/*
- * The device space macros for PIC are more complicated because the PIC has
- * two PCI/X bridges under the same widget.  For PIC bus 0, the addresses are
- * basically the same as for the [X]Bridge.  For PIC bus 1, the addresses are
- * offset by 0x800000.   Here are two sets of macros.  They are 
- * "PCIBRIDGE_xxx" that return the address based on the supplied bus number
- * and also equivalent "PCIBR_xxx" macros that may be used with a
- * pcibr_soft_s structure.   Both should work with all bridges.
- */
-#define PIC_BUS1_OFFSET 0x800000
-
-#define PCIBRIDGE_TYPE0_CFG_DEV0(busnum) \
-    ((busnum) ? BRIDGE_TYPE0_CFG_DEV0 + PIC_BUS1_OFFSET : \
-                    BRIDGE_TYPE0_CFG_DEV0)
-#define PCIBRIDGE_TYPE1_CFG(busnum) \
-    ((busnum) ? BRIDGE_TYPE1_CFG + PIC_BUS1_OFFSET : BRIDGE_TYPE1_CFG)
-#define PCIBRIDGE_TYPE0_CFG_DEV(busnum, s) \
-        (PCIBRIDGE_TYPE0_CFG_DEV0(busnum)+\
-        (s)*BRIDGE_TYPE0_CFG_SLOT_OFF)
-#define PCIBRIDGE_TYPE0_CFG_DEVF(busnum, s, f) \
-        (PCIBRIDGE_TYPE0_CFG_DEV0(busnum)+\
-        (s)*BRIDGE_TYPE0_CFG_SLOT_OFF+\
-        (f)*BRIDGE_TYPE0_CFG_FUNC_OFF)
-#define PCIBRIDGE_DEVIO0(busnum) ((busnum) ? \
-        (BRIDGE_DEVIO0 + PIC_BUS1_OFFSET) : BRIDGE_DEVIO0)
-#define PCIBRIDGE_DEVIO1(busnum) ((busnum) ? \
-        (BRIDGE_DEVIO1 + PIC_BUS1_OFFSET) : BRIDGE_DEVIO1)
-#define PCIBRIDGE_DEVIO2(busnum) ((busnum) ? \
-        (BRIDGE_DEVIO2 + PIC_BUS1_OFFSET) : BRIDGE_DEVIO2)
-#define PCIBRIDGE_DEVIO(busnum, x) \
-    ((x)<=1 ? PCIBRIDGE_DEVIO0(busnum)+(x)*BRIDGE_DEVIO_2MB : \
-        PCIBRIDGE_DEVIO2(busnum)+((x)-2)*BRIDGE_DEVIO_1MB)
-
-#define PCIBR_BRIDGE_DEVIO0(ps)     PCIBRIDGE_DEVIO0((ps)->bs_busnum)
-#define PCIBR_BRIDGE_DEVIO1(ps)     PCIBRIDGE_DEVIO1((ps)->bs_busnum)
-#define PCIBR_BRIDGE_DEVIO2(ps)     PCIBRIDGE_DEVIO2((ps)->bs_busnum)
-#define PCIBR_BRIDGE_DEVIO(ps, s)   PCIBRIDGE_DEVIO((ps)->bs_busnum, s)
-
-#define PCIBR_TYPE1_CFG(ps)         PCIBRIDGE_TYPE1_CFG((ps)->bs_busnum)
-#define PCIBR_BUS_TYPE0_CFG_DEV0(ps) PCIBR_TYPE0_CFG_DEV(ps, 0)
-#define PCIBR_TYPE0_CFG_DEV(ps, s) PCIBRIDGE_TYPE0_CFG_DEV((ps)->bs_busnum, s+1)
-#define PCIBR_BUS_TYPE0_CFG_DEVF(ps,s,f) PCIBRIDGE_TYPE0_CFG_DEVF((ps)->bs_busnum,(s+1),f)
-
-/* NOTE: 's' is the internal device number, not the external slot number */
-#define PCIBR_BUS_TYPE0_CFG_DEV(ps, s) \
-		PCIBRIDGE_TYPE0_CFG_DEV((ps)->bs_busnum, s+1)
-
-#endif				/* LANGUAGE_C */
-
-#define BRIDGE_EXTERNAL_FLASH	0x00C00000	/* External Flash PROMS */
-
-/* ========================================================================
- *    Bridge register bit field definitions
- */
-
-/* Widget part number of bridge */
-#define BRIDGE_WIDGET_PART_NUM		0xc002
-#define XBRIDGE_WIDGET_PART_NUM		0xd002
-
-/* Manufacturer of bridge */
-#define BRIDGE_WIDGET_MFGR_NUM		0x036
-#define XBRIDGE_WIDGET_MFGR_NUM		0x024
-
-/* Revision numbers for known [X]Bridge revisions */
-#define BRIDGE_REV_A			0x1
-#define BRIDGE_REV_B			0x2
-#define BRIDGE_REV_C			0x3
-#define	BRIDGE_REV_D			0x4
-#define XBRIDGE_REV_A			0x1
-#define XBRIDGE_REV_B			0x2
-
-/* macros to determine bridge type. 'wid' == widget identification */
-#define IS_PIC_BUS0(wid) (XWIDGET_PART_NUM(wid) == PIC_WIDGET_PART_NUM_BUS0 && \
-			XWIDGET_MFG_NUM(wid) == PIC_WIDGET_MFGR_NUM)
-#define IS_PIC_BUS1(wid) (XWIDGET_PART_NUM(wid) == PIC_WIDGET_PART_NUM_BUS1 && \
-			XWIDGET_MFG_NUM(wid) == PIC_WIDGET_MFGR_NUM)
-#define IS_PIC_BRIDGE(wid) (IS_PIC_BUS0(wid) || IS_PIC_BUS1(wid))
-
-/* Part + Rev numbers allows distinction and acscending sequence */
-#define BRIDGE_PART_REV_A	(BRIDGE_WIDGET_PART_NUM << 4 | BRIDGE_REV_A)
-#define BRIDGE_PART_REV_B	(BRIDGE_WIDGET_PART_NUM << 4 | BRIDGE_REV_B)
-#define BRIDGE_PART_REV_C	(BRIDGE_WIDGET_PART_NUM << 4 | BRIDGE_REV_C)
-#define	BRIDGE_PART_REV_D	(BRIDGE_WIDGET_PART_NUM << 4 | BRIDGE_REV_D)
-#define XBRIDGE_PART_REV_A	(XBRIDGE_WIDGET_PART_NUM << 4 | XBRIDGE_REV_A)
-#define XBRIDGE_PART_REV_B	(XBRIDGE_WIDGET_PART_NUM << 4 | XBRIDGE_REV_B)
-
-/* Bridge widget status register bits definition */
-#define PIC_STAT_PCIX_SPEED             (0x3ull << 34)
-#define PIC_STAT_PCIX_ACTIVE            (0x1ull << 33)
-#define BRIDGE_STAT_LLP_REC_CNT		(0xFFu << 24)
-#define BRIDGE_STAT_LLP_TX_CNT		(0xFF << 16)
-#define BRIDGE_STAT_FLASH_SELECT	(0x1 << 6)
-#define BRIDGE_STAT_PCI_GIO_N		(0x1 << 5)
-#define BRIDGE_STAT_PENDING		(0x1F << 0)
-
-/* Bridge widget control register bits definition */
-#define PIC_CTRL_NO_SNOOP		(0x1ull << 62)
-#define PIC_CTRL_RELAX_ORDER		(0x1ull << 61)
-#define PIC_CTRL_BUS_NUM(x)		((unsigned long long)(x) << 48)
-#define PIC_CTRL_BUS_NUM_MASK		(PIC_CTRL_BUS_NUM(0xff))
-#define PIC_CTRL_DEV_NUM(x)		((unsigned long long)(x) << 43)
-#define PIC_CTRL_DEV_NUM_MASK		(PIC_CTRL_DEV_NUM(0x1f))
-#define PIC_CTRL_FUN_NUM(x)		((unsigned long long)(x) << 40)
-#define PIC_CTRL_FUN_NUM_MASK		(PIC_CTRL_FUN_NUM(0x7))
-#define PIC_CTRL_PAR_EN_REQ		(0x1ull << 29)
-#define PIC_CTRL_PAR_EN_RESP		(0x1ull << 30)
-#define PIC_CTRL_PAR_EN_ATE		(0x1ull << 31)
-#define BRIDGE_CTRL_FLASH_WR_EN		(0x1ul << 31)   /* bridge only */
-#define BRIDGE_CTRL_EN_CLK50		(0x1 << 30)
-#define BRIDGE_CTRL_EN_CLK40		(0x1 << 29)
-#define BRIDGE_CTRL_EN_CLK33		(0x1 << 28)
-#define BRIDGE_CTRL_RST(n)		((n) << 24)
-#define BRIDGE_CTRL_RST_MASK		(BRIDGE_CTRL_RST(0xF))
-#define BRIDGE_CTRL_RST_PIN(x)		(BRIDGE_CTRL_RST(0x1 << (x)))
-#define BRIDGE_CTRL_IO_SWAP		(0x1 << 23)
-#define BRIDGE_CTRL_MEM_SWAP		(0x1 << 22)
-#define BRIDGE_CTRL_PAGE_SIZE		(0x1 << 21)
-#define BRIDGE_CTRL_SS_PAR_BAD		(0x1 << 20)
-#define BRIDGE_CTRL_SS_PAR_EN		(0x1 << 19)
-#define BRIDGE_CTRL_SSRAM_SIZE(n)	((n) << 17)
-#define BRIDGE_CTRL_SSRAM_SIZE_MASK	(BRIDGE_CTRL_SSRAM_SIZE(0x3))
-#define BRIDGE_CTRL_SSRAM_512K		(BRIDGE_CTRL_SSRAM_SIZE(0x3))
-#define BRIDGE_CTRL_SSRAM_128K		(BRIDGE_CTRL_SSRAM_SIZE(0x2))
-#define BRIDGE_CTRL_SSRAM_64K		(BRIDGE_CTRL_SSRAM_SIZE(0x1))
-#define BRIDGE_CTRL_SSRAM_1K		(BRIDGE_CTRL_SSRAM_SIZE(0x0))
-#define BRIDGE_CTRL_F_BAD_PKT		(0x1 << 16)
-#define BRIDGE_CTRL_LLP_XBAR_CRD(n)	((n) << 12)
-#define BRIDGE_CTRL_LLP_XBAR_CRD_MASK	(BRIDGE_CTRL_LLP_XBAR_CRD(0xf))
-#define BRIDGE_CTRL_CLR_RLLP_CNT	(0x1 << 11)
-#define BRIDGE_CTRL_CLR_TLLP_CNT	(0x1 << 10)
-#define BRIDGE_CTRL_SYS_END		(0x1 << 9)
-#define BRIDGE_CTRL_PCI_SPEED		(0x3 << 4)
-
-#define BRIDGE_CTRL_BUS_SPEED(n)        ((n) << 4)
-#define BRIDGE_CTRL_BUS_SPEED_MASK      (BRIDGE_CTRL_BUS_SPEED(0x3))
-#define BRIDGE_CTRL_BUS_SPEED_33        0x00
-#define BRIDGE_CTRL_BUS_SPEED_66        0x10
-#define BRIDGE_CTRL_MAX_TRANS(n)	((n) << 4)
-#define BRIDGE_CTRL_MAX_TRANS_MASK	(BRIDGE_CTRL_MAX_TRANS(0x1f))
-#define BRIDGE_CTRL_WIDGET_ID(n)	((n) << 0)
-#define BRIDGE_CTRL_WIDGET_ID_MASK	(BRIDGE_CTRL_WIDGET_ID(0xf))
-
-/* Bridge Response buffer Error Upper Register bit fields definition */
-#define BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT (20)
-#define BRIDGE_RESP_ERRUPPR_DEVNUM_MASK (0x7 << BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT)
-#define BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT (16)
-#define BRIDGE_RESP_ERRUPPR_BUFNUM_MASK (0xF << BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT)
-#define BRIDGE_RESP_ERRRUPPR_BUFMASK	(0xFFFF)
-
-#define BRIDGE_RESP_ERRUPPR_BUFNUM(x)	\
-			(((x) & BRIDGE_RESP_ERRUPPR_BUFNUM_MASK) >> \
-				BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT)
-
-#define BRIDGE_RESP_ERRUPPR_DEVICE(x)	\
-			(((x) &	 BRIDGE_RESP_ERRUPPR_DEVNUM_MASK) >> \
-				 BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT)
-
-/* Bridge direct mapping register bits definition */
-#define BRIDGE_DIRMAP_W_ID_SHFT		20
-#define BRIDGE_DIRMAP_W_ID		(0xf << BRIDGE_DIRMAP_W_ID_SHFT)
-#define BRIDGE_DIRMAP_RMF_64		(0x1 << 18)
-#define BRIDGE_DIRMAP_ADD512		(0x1 << 17)
-#define BRIDGE_DIRMAP_OFF		(0x1ffff << 0)
-#define BRIDGE_DIRMAP_OFF_ADDRSHFT	(31)	/* lsbit of DIRMAP_OFF is xtalk address bit 31 */
-
-/* Bridge Arbitration register bits definition */
-#define BRIDGE_ARB_REQ_WAIT_TICK(x)	((x) << 16)
-#define BRIDGE_ARB_REQ_WAIT_TICK_MASK	BRIDGE_ARB_REQ_WAIT_TICK(0x3)
-#define BRIDGE_ARB_REQ_WAIT_EN(x)	((x) << 8)
-#define BRIDGE_ARB_REQ_WAIT_EN_MASK	BRIDGE_ARB_REQ_WAIT_EN(0xff)
-#define BRIDGE_ARB_FREEZE_GNT		(1 << 6)
-#define BRIDGE_ARB_HPRI_RING_B2		(1 << 5)
-#define BRIDGE_ARB_HPRI_RING_B1		(1 << 4)
-#define BRIDGE_ARB_HPRI_RING_B0		(1 << 3)
-#define BRIDGE_ARB_LPRI_RING_B2		(1 << 2)
-#define BRIDGE_ARB_LPRI_RING_B1		(1 << 1)
-#define BRIDGE_ARB_LPRI_RING_B0		(1 << 0)
-
-/* Bridge Bus time-out register bits definition */
-#define BRIDGE_BUS_PCI_RETRY_HLD(x)	((x) << 16)
-#define BRIDGE_BUS_PCI_RETRY_HLD_MASK	BRIDGE_BUS_PCI_RETRY_HLD(0x1f)
-#define BRIDGE_BUS_GIO_TIMEOUT		(1 << 12)
-#define BRIDGE_BUS_PCI_RETRY_CNT(x)	((x) << 0)
-#define BRIDGE_BUS_PCI_RETRY_MASK	BRIDGE_BUS_PCI_RETRY_CNT(0x3ff)
-
-/* Bridge interrupt status register bits definition */
-#define PIC_ISR_PCIX_SPLIT_MSG_PE	(0x1ull << 45)
-#define PIC_ISR_PCIX_SPLIT_EMSG		(0x1ull << 44)
-#define PIC_ISR_PCIX_SPLIT_TO		(0x1ull << 43)
-#define PIC_ISR_PCIX_UNEX_COMP		(0x1ull << 42)
-#define PIC_ISR_INT_RAM_PERR		(0x1ull << 41)
-#define PIC_ISR_PCIX_ARB_ERR		(0x1ull << 40)
-#define PIC_ISR_PCIX_REQ_TOUT		(0x1ull << 39)
-#define PIC_ISR_PCIX_TABORT		(0x1ull << 38)
-#define PIC_ISR_PCIX_PERR		(0x1ull << 37)
-#define PIC_ISR_PCIX_SERR		(0x1ull << 36)
-#define PIC_ISR_PCIX_MRETRY		(0x1ull << 35)
-#define PIC_ISR_PCIX_MTOUT		(0x1ull << 34)
-#define PIC_ISR_PCIX_DA_PARITY		(0x1ull << 33)
-#define PIC_ISR_PCIX_AD_PARITY		(0x1ull << 32)
-#define BRIDGE_ISR_MULTI_ERR		(0x1u << 31)	/* bridge only */
-#define BRIDGE_ISR_PMU_ESIZE_FAULT	(0x1 << 30)	/* bridge only */
-#define BRIDGE_ISR_PAGE_FAULT		(0x1 << 30)	/* xbridge only */
-#define BRIDGE_ISR_UNEXP_RESP		(0x1 << 29)
-#define BRIDGE_ISR_BAD_XRESP_PKT	(0x1 << 28)
-#define BRIDGE_ISR_BAD_XREQ_PKT		(0x1 << 27)
-#define BRIDGE_ISR_RESP_XTLK_ERR	(0x1 << 26)
-#define BRIDGE_ISR_REQ_XTLK_ERR		(0x1 << 25)
-#define BRIDGE_ISR_INVLD_ADDR		(0x1 << 24)
-#define BRIDGE_ISR_UNSUPPORTED_XOP	(0x1 << 23)
-#define BRIDGE_ISR_XREQ_FIFO_OFLOW	(0x1 << 22)
-#define BRIDGE_ISR_LLP_REC_SNERR	(0x1 << 21)
-#define BRIDGE_ISR_LLP_REC_CBERR	(0x1 << 20)
-#define BRIDGE_ISR_LLP_RCTY		(0x1 << 19)
-#define BRIDGE_ISR_LLP_TX_RETRY		(0x1 << 18)
-#define BRIDGE_ISR_LLP_TCTY		(0x1 << 17)
-#define BRIDGE_ISR_SSRAM_PERR		(0x1 << 16)
-#define BRIDGE_ISR_PCI_ABORT		(0x1 << 15)
-#define BRIDGE_ISR_PCI_PARITY		(0x1 << 14)
-#define BRIDGE_ISR_PCI_SERR		(0x1 << 13)
-#define BRIDGE_ISR_PCI_PERR		(0x1 << 12)
-#define BRIDGE_ISR_PCI_MST_TIMEOUT	(0x1 << 11)
-#define BRIDGE_ISR_GIO_MST_TIMEOUT	BRIDGE_ISR_PCI_MST_TIMEOUT
-#define BRIDGE_ISR_PCI_RETRY_CNT	(0x1 << 10)
-#define BRIDGE_ISR_XREAD_REQ_TIMEOUT	(0x1 << 9)
-#define BRIDGE_ISR_GIO_B_ENBL_ERR	(0x1 << 8)
-#define BRIDGE_ISR_INT_MSK		(0xff << 0)
-#define BRIDGE_ISR_INT(x)		(0x1 << (x))
-
-#define BRIDGE_ISR_LINK_ERROR		\
-		(BRIDGE_ISR_LLP_REC_SNERR|BRIDGE_ISR_LLP_REC_CBERR|	\
-		 BRIDGE_ISR_LLP_RCTY|BRIDGE_ISR_LLP_TX_RETRY|		\
-		 BRIDGE_ISR_LLP_TCTY)
-
-#define BRIDGE_ISR_PCIBUS_PIOERR	\
-		(BRIDGE_ISR_PCI_MST_TIMEOUT|BRIDGE_ISR_PCI_ABORT|	\
-		 PIC_ISR_PCIX_MTOUT|PIC_ISR_PCIX_TABORT)
-
-#define BRIDGE_ISR_PCIBUS_ERROR		\
-		(BRIDGE_ISR_PCIBUS_PIOERR|BRIDGE_ISR_PCI_PERR|		\
-		 BRIDGE_ISR_PCI_SERR|BRIDGE_ISR_PCI_RETRY_CNT|		\
-		 BRIDGE_ISR_PCI_PARITY|PIC_ISR_PCIX_PERR|		\
-		 PIC_ISR_PCIX_SERR|PIC_ISR_PCIX_MRETRY|			\
-		 PIC_ISR_PCIX_AD_PARITY|PIC_ISR_PCIX_DA_PARITY|		\
-		 PIC_ISR_PCIX_REQ_TOUT|PIC_ISR_PCIX_UNEX_COMP|		\
-		 PIC_ISR_PCIX_SPLIT_TO|PIC_ISR_PCIX_SPLIT_EMSG|		\
-		 PIC_ISR_PCIX_SPLIT_MSG_PE)
-
-#define BRIDGE_ISR_XTALK_ERROR		\
-		(BRIDGE_ISR_XREAD_REQ_TIMEOUT|BRIDGE_ISR_XREQ_FIFO_OFLOW|\
-		 BRIDGE_ISR_UNSUPPORTED_XOP|BRIDGE_ISR_INVLD_ADDR|	\
-		 BRIDGE_ISR_REQ_XTLK_ERR|BRIDGE_ISR_RESP_XTLK_ERR|	\
-		 BRIDGE_ISR_BAD_XREQ_PKT|BRIDGE_ISR_BAD_XRESP_PKT|	\
-		 BRIDGE_ISR_UNEXP_RESP)
-
-#define BRIDGE_ISR_ERRORS		\
-		(BRIDGE_ISR_LINK_ERROR|BRIDGE_ISR_PCIBUS_ERROR|		\
-		 BRIDGE_ISR_XTALK_ERROR|BRIDGE_ISR_SSRAM_PERR|		\
-		 BRIDGE_ISR_PMU_ESIZE_FAULT|PIC_ISR_INT_RAM_PERR)
-
-/*
- * List of Errors which are fatal and kill the sytem
- */
-#define BRIDGE_ISR_ERROR_FATAL		\
-		((BRIDGE_ISR_XTALK_ERROR & ~BRIDGE_ISR_XREAD_REQ_TIMEOUT)|\
-		 BRIDGE_ISR_PCI_SERR|BRIDGE_ISR_PCI_PARITY|		  \
-		 PIC_ISR_PCIX_SERR|PIC_ISR_PCIX_AD_PARITY|		  \
-		 PIC_ISR_PCIX_DA_PARITY|				  \
-		 PIC_ISR_INT_RAM_PERR|PIC_ISR_PCIX_SPLIT_MSG_PE )
-
-#define BRIDGE_ISR_ERROR_DUMP		\
-		(BRIDGE_ISR_PCIBUS_ERROR|BRIDGE_ISR_PMU_ESIZE_FAULT|	\
-		 BRIDGE_ISR_XTALK_ERROR|BRIDGE_ISR_SSRAM_PERR|		\
-		 PIC_ISR_PCIX_ARB_ERR|PIC_ISR_INT_RAM_PERR)
-
-/* Bridge interrupt enable register bits definition */
-#define PIC_IMR_PCIX_SPLIT_MSG_PE	PIC_ISR_PCIX_SPLIT_MSG_PE
-#define PIC_IMR_PCIX_SPLIT_EMSG		PIC_ISR_PCIX_SPLIT_EMSG
-#define PIC_IMR_PCIX_SPLIT_TO		PIC_ISR_PCIX_SPLIT_TO
-#define PIC_IMR_PCIX_UNEX_COMP		PIC_ISR_PCIX_UNEX_COMP
-#define PIC_IMR_INT_RAM_PERR		PIC_ISR_INT_RAM_PERR
-#define PIC_IMR_PCIX_ARB_ERR		PIC_ISR_PCIX_ARB_ERR
-#define PIC_IMR_PCIX_REQ_TOUR		PIC_ISR_PCIX_REQ_TOUT
-#define PIC_IMR_PCIX_TABORT		PIC_ISR_PCIX_TABORT
-#define PIC_IMR_PCIX_PERR		PIC_ISR_PCIX_PERR
-#define PIC_IMR_PCIX_SERR		PIC_ISR_PCIX_SERR
-#define PIC_IMR_PCIX_MRETRY		PIC_ISR_PCIX_MRETRY
-#define PIC_IMR_PCIX_MTOUT		PIC_ISR_PCIX_MTOUT
-#define PIC_IMR_PCIX_DA_PARITY		PIC_ISR_PCIX_DA_PARITY
-#define PIC_IMR_PCIX_AD_PARITY		PIC_ISR_PCIX_AD_PARITY
-#define BRIDGE_IMR_UNEXP_RESP		BRIDGE_ISR_UNEXP_RESP
-#define BRIDGE_IMR_PMU_ESIZE_FAULT	BRIDGE_ISR_PMU_ESIZE_FAULT
-#define BRIDGE_IMR_BAD_XRESP_PKT	BRIDGE_ISR_BAD_XRESP_PKT
-#define BRIDGE_IMR_BAD_XREQ_PKT		BRIDGE_ISR_BAD_XREQ_PKT
-#define BRIDGE_IMR_RESP_XTLK_ERR	BRIDGE_ISR_RESP_XTLK_ERR
-#define BRIDGE_IMR_REQ_XTLK_ERR		BRIDGE_ISR_REQ_XTLK_ERR
-#define BRIDGE_IMR_INVLD_ADDR		BRIDGE_ISR_INVLD_ADDR
-#define BRIDGE_IMR_UNSUPPORTED_XOP	BRIDGE_ISR_UNSUPPORTED_XOP
-#define BRIDGE_IMR_XREQ_FIFO_OFLOW	BRIDGE_ISR_XREQ_FIFO_OFLOW
-#define BRIDGE_IMR_LLP_REC_SNERR	BRIDGE_ISR_LLP_REC_SNERR
-#define BRIDGE_IMR_LLP_REC_CBERR	BRIDGE_ISR_LLP_REC_CBERR
-#define BRIDGE_IMR_LLP_RCTY		BRIDGE_ISR_LLP_RCTY
-#define BRIDGE_IMR_LLP_TX_RETRY		BRIDGE_ISR_LLP_TX_RETRY
-#define BRIDGE_IMR_LLP_TCTY		BRIDGE_ISR_LLP_TCTY
-#define BRIDGE_IMR_SSRAM_PERR		BRIDGE_ISR_SSRAM_PERR
-#define BRIDGE_IMR_PCI_ABORT		BRIDGE_ISR_PCI_ABORT
-#define BRIDGE_IMR_PCI_PARITY		BRIDGE_ISR_PCI_PARITY
-#define BRIDGE_IMR_PCI_SERR		BRIDGE_ISR_PCI_SERR
-#define BRIDGE_IMR_PCI_PERR		BRIDGE_ISR_PCI_PERR
-#define BRIDGE_IMR_PCI_MST_TIMEOUT	BRIDGE_ISR_PCI_MST_TIMEOUT
-#define BRIDGE_IMR_GIO_MST_TIMEOUT	BRIDGE_ISR_GIO_MST_TIMEOUT
-#define BRIDGE_IMR_PCI_RETRY_CNT	BRIDGE_ISR_PCI_RETRY_CNT
-#define BRIDGE_IMR_XREAD_REQ_TIMEOUT	BRIDGE_ISR_XREAD_REQ_TIMEOUT
-#define BRIDGE_IMR_GIO_B_ENBL_ERR	BRIDGE_ISR_GIO_B_ENBL_ERR
-#define BRIDGE_IMR_INT_MSK		BRIDGE_ISR_INT_MSK
-#define BRIDGE_IMR_INT(x)		BRIDGE_ISR_INT(x)
-
-/* 
- * Bridge interrupt reset register bits definition.  Note, PIC can
- * reset indiviual error interrupts, BRIDGE & XBRIDGE can only do 
- * groups of them.
- */
-#define PIC_IRR_PCIX_SPLIT_MSG_PE	PIC_ISR_PCIX_SPLIT_MSG_PE
-#define PIC_IRR_PCIX_SPLIT_EMSG		PIC_ISR_PCIX_SPLIT_EMSG
-#define PIC_IRR_PCIX_SPLIT_TO		PIC_ISR_PCIX_SPLIT_TO
-#define PIC_IRR_PCIX_UNEX_COMP		PIC_ISR_PCIX_UNEX_COMP
-#define PIC_IRR_INT_RAM_PERR		PIC_ISR_INT_RAM_PERR
-#define PIC_IRR_PCIX_ARB_ERR		PIC_ISR_PCIX_ARB_ERR
-#define PIC_IRR_PCIX_REQ_TOUT		PIC_ISR_PCIX_REQ_TOUT
-#define PIC_IRR_PCIX_TABORT		PIC_ISR_PCIX_TABORT
-#define PIC_IRR_PCIX_PERR		PIC_ISR_PCIX_PERR
-#define PIC_IRR_PCIX_SERR		PIC_ISR_PCIX_SERR
-#define PIC_IRR_PCIX_MRETRY		PIC_ISR_PCIX_MRETRY
-#define PIC_IRR_PCIX_MTOUT		PIC_ISR_PCIX_MTOUT
-#define PIC_IRR_PCIX_DA_PARITY		PIC_ISR_PCIX_DA_PARITY
-#define PIC_IRR_PCIX_AD_PARITY		PIC_ISR_PCIX_AD_PARITY
-#define PIC_IRR_PAGE_FAULT		BRIDGE_ISR_PAGE_FAULT
-#define PIC_IRR_UNEXP_RESP		BRIDGE_ISR_UNEXP_RESP
-#define PIC_IRR_BAD_XRESP_PKT		BRIDGE_ISR_BAD_XRESP_PKT
-#define PIC_IRR_BAD_XREQ_PKT		BRIDGE_ISR_BAD_XREQ_PKT
-#define PIC_IRR_RESP_XTLK_ERR		BRIDGE_ISR_RESP_XTLK_ERR
-#define PIC_IRR_REQ_XTLK_ERR		BRIDGE_ISR_REQ_XTLK_ERR
-#define PIC_IRR_INVLD_ADDR		BRIDGE_ISR_INVLD_ADDR
-#define PIC_IRR_UNSUPPORTED_XOP		BRIDGE_ISR_UNSUPPORTED_XOP
-#define PIC_IRR_XREQ_FIFO_OFLOW		BRIDGE_ISR_XREQ_FIFO_OFLOW
-#define PIC_IRR_LLP_REC_SNERR		BRIDGE_ISR_LLP_REC_SNERR
-#define PIC_IRR_LLP_REC_CBERR		BRIDGE_ISR_LLP_REC_CBERR
-#define PIC_IRR_LLP_RCTY		BRIDGE_ISR_LLP_RCTY
-#define PIC_IRR_LLP_TX_RETRY		BRIDGE_ISR_LLP_TX_RETRY
-#define PIC_IRR_LLP_TCTY		BRIDGE_ISR_LLP_TCTY
-#define PIC_IRR_PCI_ABORT		BRIDGE_ISR_PCI_ABORT
-#define PIC_IRR_PCI_PARITY		BRIDGE_ISR_PCI_PARITY
-#define PIC_IRR_PCI_SERR		BRIDGE_ISR_PCI_SERR
-#define PIC_IRR_PCI_PERR		BRIDGE_ISR_PCI_PERR
-#define PIC_IRR_PCI_MST_TIMEOUT		BRIDGE_ISR_PCI_MST_TIMEOUT
-#define PIC_IRR_PCI_RETRY_CNT		BRIDGE_ISR_PCI_RETRY_CNT
-#define PIC_IRR_XREAD_REQ_TIMEOUT	BRIDGE_ISR_XREAD_REQ_TIMEOUT
-#define BRIDGE_IRR_MULTI_CLR		(0x1 << 6)
-#define BRIDGE_IRR_CRP_GRP_CLR		(0x1 << 5)
-#define BRIDGE_IRR_RESP_BUF_GRP_CLR	(0x1 << 4)
-#define BRIDGE_IRR_REQ_DSP_GRP_CLR	(0x1 << 3)
-#define BRIDGE_IRR_LLP_GRP_CLR		(0x1 << 2)
-#define BRIDGE_IRR_SSRAM_GRP_CLR	(0x1 << 1)
-#define BRIDGE_IRR_PCI_GRP_CLR		(0x1 << 0)
-#define BRIDGE_IRR_GIO_GRP_CLR		(0x1 << 0)
-#define BRIDGE_IRR_ALL_CLR		0x7f
-
-#define BRIDGE_IRR_CRP_GRP		(BRIDGE_ISR_UNEXP_RESP | \
-					 BRIDGE_ISR_XREQ_FIFO_OFLOW)
-#define BRIDGE_IRR_RESP_BUF_GRP		(BRIDGE_ISR_BAD_XRESP_PKT | \
-					 BRIDGE_ISR_RESP_XTLK_ERR | \
-					 BRIDGE_ISR_XREAD_REQ_TIMEOUT)
-#define BRIDGE_IRR_REQ_DSP_GRP		(BRIDGE_ISR_UNSUPPORTED_XOP | \
-					 BRIDGE_ISR_BAD_XREQ_PKT | \
-					 BRIDGE_ISR_REQ_XTLK_ERR | \
-					 BRIDGE_ISR_INVLD_ADDR)
-#define BRIDGE_IRR_LLP_GRP		(BRIDGE_ISR_LLP_REC_SNERR | \
-					 BRIDGE_ISR_LLP_REC_CBERR | \
-					 BRIDGE_ISR_LLP_RCTY | \
-					 BRIDGE_ISR_LLP_TX_RETRY | \
-					 BRIDGE_ISR_LLP_TCTY)
-#define BRIDGE_IRR_SSRAM_GRP		(BRIDGE_ISR_SSRAM_PERR | \
-					 BRIDGE_ISR_PMU_ESIZE_FAULT)
-#define BRIDGE_IRR_PCI_GRP		(BRIDGE_ISR_PCI_ABORT | \
-					 BRIDGE_ISR_PCI_PARITY | \
-					 BRIDGE_ISR_PCI_SERR | \
-					 BRIDGE_ISR_PCI_PERR | \
-					 BRIDGE_ISR_PCI_MST_TIMEOUT | \
-					 BRIDGE_ISR_PCI_RETRY_CNT)
-
-#define BRIDGE_IRR_GIO_GRP		(BRIDGE_ISR_GIO_B_ENBL_ERR | \
-					 BRIDGE_ISR_GIO_MST_TIMEOUT)
-
-#define PIC_IRR_RAM_GRP			PIC_ISR_INT_RAM_PERR
-
-#define PIC_PCIX_GRP_CLR		(PIC_IRR_PCIX_AD_PARITY | \
-					 PIC_IRR_PCIX_DA_PARITY | \
-					 PIC_IRR_PCIX_MTOUT | \
-					 PIC_IRR_PCIX_MRETRY | \
-					 PIC_IRR_PCIX_SERR | \
-					 PIC_IRR_PCIX_PERR | \
-					 PIC_IRR_PCIX_TABORT | \
-					 PIC_ISR_PCIX_REQ_TOUT | \
-					 PIC_ISR_PCIX_UNEX_COMP | \
-					 PIC_ISR_PCIX_SPLIT_TO | \
-					 PIC_ISR_PCIX_SPLIT_EMSG | \
-					 PIC_ISR_PCIX_SPLIT_MSG_PE)
-
-/* Bridge INT_DEV register bits definition */
-#define BRIDGE_INT_DEV_SHFT(n)		((n)*3)
-#define BRIDGE_INT_DEV_MASK(n)		(0x7 << BRIDGE_INT_DEV_SHFT(n))
-#define BRIDGE_INT_DEV_SET(_dev, _line) (_dev << BRIDGE_INT_DEV_SHFT(_line))	
-
-/* Bridge interrupt(x) register bits definition */
-#define BRIDGE_INT_ADDR_HOST		0x0003FF00
-#define BRIDGE_INT_ADDR_FLD		0x000000FF
-
-/* PIC interrupt(x) register bits definition */
-#define PIC_INT_ADDR_FLD                0x00FF000000000000
-#define PIC_INT_ADDR_HOST               0x0000FFFFFFFFFFFF
-
-#define BRIDGE_TMO_PCI_RETRY_HLD_MASK	0x1f0000
-#define BRIDGE_TMO_GIO_TIMEOUT_MASK	0x001000
-#define BRIDGE_TMO_PCI_RETRY_CNT_MASK	0x0003ff
-
-#define BRIDGE_TMO_PCI_RETRY_CNT_MAX	0x3ff
-
-/* Bridge device(x) register bits definition */
-#define BRIDGE_DEV_ERR_LOCK_EN		(1ull << 28)
-#define BRIDGE_DEV_PAGE_CHK_DIS		(1ull << 27)
-#define BRIDGE_DEV_FORCE_PCI_PAR	(1ull << 26)
-#define BRIDGE_DEV_VIRTUAL_EN		(1ull << 25)
-#define BRIDGE_DEV_PMU_WRGA_EN		(1ull << 24)
-#define BRIDGE_DEV_DIR_WRGA_EN		(1ull << 23)
-#define BRIDGE_DEV_DEV_SIZE		(1ull << 22)
-#define BRIDGE_DEV_RT			(1ull << 21)
-#define BRIDGE_DEV_SWAP_PMU		(1ull << 20)
-#define BRIDGE_DEV_SWAP_DIR		(1ull << 19)
-#define BRIDGE_DEV_PREF			(1ull << 18)
-#define BRIDGE_DEV_PRECISE		(1ull << 17)
-#define BRIDGE_DEV_COH			(1ull << 16)
-#define BRIDGE_DEV_BARRIER		(1ull << 15)
-#define BRIDGE_DEV_GBR			(1ull << 14)
-#define BRIDGE_DEV_DEV_SWAP		(1ull << 13)
-#define BRIDGE_DEV_DEV_IO_MEM		(1ull << 12)
-#define BRIDGE_DEV_OFF_MASK		0x00000fff
-#define BRIDGE_DEV_OFF_ADDR_SHFT	20
-
-#define XBRIDGE_DEV_PMU_BITS		BRIDGE_DEV_PMU_WRGA_EN
-#define BRIDGE_DEV_PMU_BITS		(BRIDGE_DEV_PMU_WRGA_EN		| \
-					 BRIDGE_DEV_SWAP_PMU)
-#define BRIDGE_DEV_D32_BITS		(BRIDGE_DEV_DIR_WRGA_EN		| \
-					 BRIDGE_DEV_SWAP_DIR		| \
-					 BRIDGE_DEV_PREF		| \
-					 BRIDGE_DEV_PRECISE		| \
-					 BRIDGE_DEV_COH			| \
-					 BRIDGE_DEV_BARRIER)
-#define XBRIDGE_DEV_D64_BITS		(BRIDGE_DEV_DIR_WRGA_EN		| \
-					 BRIDGE_DEV_COH			| \
-					 BRIDGE_DEV_BARRIER)
-#define BRIDGE_DEV_D64_BITS		(BRIDGE_DEV_DIR_WRGA_EN		| \
-					 BRIDGE_DEV_SWAP_DIR		| \
-					 BRIDGE_DEV_COH			| \
-					 BRIDGE_DEV_BARRIER)
-
-/* Bridge Error Upper register bit field definition */
-#define BRIDGE_ERRUPPR_DEVMASTER	(0x1 << 20)	/* Device was master */
-#define BRIDGE_ERRUPPR_PCIVDEV		(0x1 << 19)	/* Virtual Req value */
-#define BRIDGE_ERRUPPR_DEVNUM_SHFT	(16)
-#define BRIDGE_ERRUPPR_DEVNUM_MASK	(0x7 << BRIDGE_ERRUPPR_DEVNUM_SHFT)
-#define BRIDGE_ERRUPPR_DEVICE(err)	(((err) >> BRIDGE_ERRUPPR_DEVNUM_SHFT) & 0x7)
-#define BRIDGE_ERRUPPR_ADDRMASK		(0xFFFF)
-
-/* Bridge interrupt mode register bits definition */
-#define BRIDGE_INTMODE_CLR_PKT_EN(x)	(0x1 << (x))
-
-/* this should be written to the xbow's link_control(x) register */
-#define BRIDGE_CREDIT	3
-
-/* RRB assignment register */
-#define	BRIDGE_RRB_EN	0x8	/* after shifting down */
-#define	BRIDGE_RRB_DEV	0x7	/* after shifting down */
-#define	BRIDGE_RRB_VDEV	0x4	/* after shifting down, 2 virtual channels */
-#define	BRIDGE_RRB_PDEV	0x3	/* after shifting down, 8 devices */
-
-#define	PIC_RRB_EN	0x8	/* after shifting down */
-#define	PIC_RRB_DEV	0x7	/* after shifting down */
-#define	PIC_RRB_VDEV	0x6	/* after shifting down, 4 virtual channels */
-#define	PIC_RRB_PDEV	0x1	/* after shifting down, 4 devices */
-
-/* RRB status register */
-#define	BRIDGE_RRB_VALID(r)	(0x00010000<<(r))
-#define	BRIDGE_RRB_INUSE(r)	(0x00000001<<(r))
-
-/* RRB clear register */
-#define	BRIDGE_RRB_CLEAR(r)	(0x00000001<<(r))
-
-/* Defines for the virtual channels so we don't hardcode 0-3 within code */
-#define VCHAN0	0	/* virtual channel 0 (ie. the "normal" channel) */
-#define VCHAN1	1	/* virtual channel 1 */
-#define VCHAN2	2	/* virtual channel 2 - PIC only */
-#define VCHAN3	3	/* virtual channel 3 - PIC only */
-
-/* PIC: PCI-X Read Buffer Attribute Register (RBAR) */
-#define NUM_RBAR 16	/* number of RBAR registers */
-
-/* xbox system controller declarations */
-#define XBOX_BRIDGE_WID         8
-#define FLASH_PROM1_BASE        0xE00000 /* To read the xbox sysctlr status */
-#define XBOX_RPS_EXISTS		1 << 6	 /* RPS bit in status register */
-#define XBOX_RPS_FAIL		1 << 4	 /* RPS status bit in register */
-
-/* ========================================================================
- */
-/*
- * Macros for Xtalk to Bridge bus (PCI/GIO) PIO
- * refer to section 4.2.1 of Bridge Spec for xtalk to PCI/GIO PIO mappings
- */
-/* XTALK addresses that map into Bridge Bus addr space */
-#define BRIDGE_PIO32_XTALK_ALIAS_BASE	0x000040000000L
-#define BRIDGE_PIO32_XTALK_ALIAS_LIMIT	0x00007FFFFFFFL
-#define BRIDGE_PIO64_XTALK_ALIAS_BASE	0x000080000000L
-#define BRIDGE_PIO64_XTALK_ALIAS_LIMIT	0x0000BFFFFFFFL
-#define BRIDGE_PCIIO_XTALK_ALIAS_BASE	0x000100000000L
-#define BRIDGE_PCIIO_XTALK_ALIAS_LIMIT	0x0001FFFFFFFFL
-
-/* Ranges of PCI bus space that can be accessed via PIO from xtalk */
-#define BRIDGE_MIN_PIO_ADDR_MEM		0x00000000	/* 1G PCI memory space */
-#define BRIDGE_MAX_PIO_ADDR_MEM		0x3fffffff
-#define BRIDGE_MIN_PIO_ADDR_IO		0x00000000	/* 4G PCI IO space */
-#define BRIDGE_MAX_PIO_ADDR_IO		0xffffffff
-
-/* XTALK addresses that map into PCI addresses */
-#define BRIDGE_PCI_MEM32_BASE		BRIDGE_PIO32_XTALK_ALIAS_BASE
-#define BRIDGE_PCI_MEM32_LIMIT		BRIDGE_PIO32_XTALK_ALIAS_LIMIT
-#define BRIDGE_PCI_MEM64_BASE		BRIDGE_PIO64_XTALK_ALIAS_BASE
-#define BRIDGE_PCI_MEM64_LIMIT		BRIDGE_PIO64_XTALK_ALIAS_LIMIT
-#define BRIDGE_PCI_IO_BASE		BRIDGE_PCIIO_XTALK_ALIAS_BASE
-#define BRIDGE_PCI_IO_LIMIT		BRIDGE_PCIIO_XTALK_ALIAS_LIMIT
-
-/*
- * Macros for Xtalk to Bridge bus (PCI) PIO
- * refer to section 5.2.1 Figure 4 of the "PCI Interface Chip (PIC) Volume II
- * Programmer's Reference" (Revision 0.8 as of this writing).
- *
- * These are PIC bridge specific.  A separate set of macros was defined
- * because PIC deviates from Bridge/Xbridge by not supporting a big-window
- * alias for PCI I/O space, and also redefines XTALK addresses
- * 0x0000C0000000L and 0x000100000000L to be PCI MEM aliases for the second
- * bus.
- */
-
-/* XTALK addresses that map into PIC Bridge Bus addr space */
-#define PICBRIDGE0_PIO32_XTALK_ALIAS_BASE	0x000040000000L
-#define PICBRIDGE0_PIO32_XTALK_ALIAS_LIMIT	0x00007FFFFFFFL
-#define PICBRIDGE0_PIO64_XTALK_ALIAS_BASE	0x000080000000L
-#define PICBRIDGE0_PIO64_XTALK_ALIAS_LIMIT	0x0000BFFFFFFFL
-#define PICBRIDGE1_PIO32_XTALK_ALIAS_BASE	0x0000C0000000L
-#define PICBRIDGE1_PIO32_XTALK_ALIAS_LIMIT	0x0000FFFFFFFFL
-#define PICBRIDGE1_PIO64_XTALK_ALIAS_BASE	0x000100000000L
-#define PICBRIDGE1_PIO64_XTALK_ALIAS_LIMIT	0x00013FFFFFFFL
-
-/* XTALK addresses that map into PCI addresses */
-#define PICBRIDGE0_PCI_MEM32_BASE	PICBRIDGE0_PIO32_XTALK_ALIAS_BASE
-#define PICBRIDGE0_PCI_MEM32_LIMIT	PICBRIDGE0_PIO32_XTALK_ALIAS_LIMIT
-#define PICBRIDGE0_PCI_MEM64_BASE	PICBRIDGE0_PIO64_XTALK_ALIAS_BASE
-#define PICBRIDGE0_PCI_MEM64_LIMIT	PICBRIDGE0_PIO64_XTALK_ALIAS_LIMIT
-#define PICBRIDGE1_PCI_MEM32_BASE	PICBRIDGE1_PIO32_XTALK_ALIAS_BASE
-#define PICBRIDGE1_PCI_MEM32_LIMIT	PICBRIDGE1_PIO32_XTALK_ALIAS_LIMIT
-#define PICBRIDGE1_PCI_MEM64_BASE	PICBRIDGE1_PIO64_XTALK_ALIAS_BASE
-#define PICBRIDGE1_PCI_MEM64_LIMIT	PICBRIDGE1_PIO64_XTALK_ALIAS_LIMIT
-
-/*
- * Macros for Bridge bus (PCI/GIO) to Xtalk DMA
- */
-/* Bridge Bus DMA addresses */
-#define BRIDGE_LOCAL_BASE		0
-#define BRIDGE_DMA_MAPPED_BASE		0x40000000
-#define BRIDGE_DMA_MAPPED_SIZE		0x40000000	/* 1G Bytes */
-#define BRIDGE_DMA_DIRECT_BASE		0x80000000
-#define BRIDGE_DMA_DIRECT_SIZE		0x80000000	/* 2G Bytes */
-
-#define PCI32_LOCAL_BASE		BRIDGE_LOCAL_BASE
-
-/* PCI addresses of regions decoded by Bridge for DMA */
-#define PCI32_MAPPED_BASE		BRIDGE_DMA_MAPPED_BASE
-#define PCI32_DIRECT_BASE		BRIDGE_DMA_DIRECT_BASE
-
-#ifndef __ASSEMBLY__
-
-#define IS_PCI32_LOCAL(x)	((uint64_t)(x) < PCI32_MAPPED_BASE)
-#define IS_PCI32_MAPPED(x)	((uint64_t)(x) < PCI32_DIRECT_BASE && \
-					(uint64_t)(x) >= PCI32_MAPPED_BASE)
-#define IS_PCI32_DIRECT(x)	((uint64_t)(x) >= PCI32_MAPPED_BASE)
-#define IS_PCI64(x)		((uint64_t)(x) >= PCI64_BASE)
-#endif				/* __ASSEMBLY__ */
-
-/*
- * The GIO address space.
- */
-/* Xtalk to GIO PIO */
-#define BRIDGE_GIO_MEM32_BASE		BRIDGE_PIO32_XTALK_ALIAS_BASE
-#define BRIDGE_GIO_MEM32_LIMIT		BRIDGE_PIO32_XTALK_ALIAS_LIMIT
-
-#define GIO_LOCAL_BASE			BRIDGE_LOCAL_BASE
-
-/* GIO addresses of regions decoded by Bridge for DMA */
-#define GIO_MAPPED_BASE			BRIDGE_DMA_MAPPED_BASE
-#define GIO_DIRECT_BASE			BRIDGE_DMA_DIRECT_BASE
-
-#ifndef __ASSEMBLY__
-
-#define IS_GIO_LOCAL(x)		((uint64_t)(x) < GIO_MAPPED_BASE)
-#define IS_GIO_MAPPED(x)	((uint64_t)(x) < GIO_DIRECT_BASE && \
-					(uint64_t)(x) >= GIO_MAPPED_BASE)
-#define IS_GIO_DIRECT(x)	((uint64_t)(x) >= GIO_MAPPED_BASE)
-#endif				/* __ASSEMBLY__ */
-
-/* PCI to xtalk mapping */
-
-/* given a DIR_OFF value and a pci/gio 32 bits direct address, determine
- * which xtalk address is accessed
- */
-#define BRIDGE_DIRECT_32_SEG_SIZE	BRIDGE_DMA_DIRECT_SIZE
-#define BRIDGE_DIRECT_32_TO_XTALK(dir_off,adr)		\
-	((dir_off) * BRIDGE_DIRECT_32_SEG_SIZE +	\
-		((adr) & (BRIDGE_DIRECT_32_SEG_SIZE - 1)) + PHYS_RAMBASE)
-
-/* 64-bit address attribute masks */
-#define PCI64_ATTR_TARG_MASK	0xf000000000000000
-#define PCI64_ATTR_TARG_SHFT	60
-#define PCI64_ATTR_PREF		(1ull << 59)
-#define PCI64_ATTR_PREC		(1ull << 58)
-#define PCI64_ATTR_VIRTUAL	(1ull << 57)
-#define PCI64_ATTR_BAR		(1ull << 56)
-#define PCI64_ATTR_SWAP		(1ull << 55)
-#define PCI64_ATTR_RMF_MASK	0x00ff000000000000
-#define PCI64_ATTR_RMF_SHFT	48
-
-#ifndef __ASSEMBLY__
-/* Address translation entry for mapped pci32 accesses */
-typedef union ate_u {
-    uint64_t		    ent;
-    struct xb_ate_s {					/* xbridge */
-	uint64_t		:16;
-	uint64_t		addr:36;
-	uint64_t		targ:4;
-	uint64_t		reserved:2;
-        uint64_t		swap:1;
-	uint64_t		barrier:1;
-	uint64_t		prefetch:1;
-	uint64_t		precise:1;
-	uint64_t		coherent:1;
-	uint64_t		valid:1;
-    } xb_field;
-    struct ate_s {					/* bridge */
-	uint64_t		rmf:16;
-	uint64_t		addr:36;
-	uint64_t		targ:4;
-	uint64_t		reserved:3;
-	uint64_t		barrier:1;
-	uint64_t		prefetch:1;
-	uint64_t		precise:1;
-	uint64_t		coherent:1;
-	uint64_t		valid:1;
-    } field;
-} ate_t;
-#endif				/* __ASSEMBLY__ */
-
-#define ATE_V		(1 << 0)
-#define ATE_CO		(1 << 1)
-#define ATE_PREC	(1 << 2)
-#define ATE_PREF	(1 << 3)
-#define ATE_BAR		(1 << 4)
-#define ATE_SWAP        (1 << 5)
-
-#define ATE_PFNSHIFT		12
-#define ATE_TIDSHIFT		8
-#define ATE_RMFSHIFT		48
-
-#define mkate(xaddr, xid, attr) ((xaddr) & 0x0000fffffffff000ULL) | \
-				((xid)<<ATE_TIDSHIFT) | \
-				(attr)
-
-/*
- * for xbridge, bit 29 of the pci address is the swap bit */
-#define ATE_SWAPSHIFT		29
-#define ATE_SWAP_ON(x)		((x) |= (1 << ATE_SWAPSHIFT))
-#define ATE_SWAP_OFF(x)		((x) &= ~(1 << ATE_SWAPSHIFT))
-
-/* extern declarations */
-
-#ifndef __ASSEMBLY__
-
-/* ========================================================================
- */
-
-#ifdef	MACROFIELD_LINE
-/*
- * This table forms a relation between the byte offset macros normally
- * used for ASM coding and the calculated byte offsets of the fields
- * in the C structure.
- *
- * See bridge_check.c and bridge_html.c for further details.
- */
-#ifndef MACROFIELD_LINE_BITFIELD
-#define MACROFIELD_LINE_BITFIELD(m)	/* ignored */
-#endif
-
-struct macrofield_s	bridge_macrofield[] =
-{
-
-    MACROFIELD_LINE(BRIDGE_WID_ID, b_wid_id)
-    MACROFIELD_LINE_BITFIELD(WIDGET_REV_NUM)
-    MACROFIELD_LINE_BITFIELD(WIDGET_PART_NUM)
-    MACROFIELD_LINE_BITFIELD(WIDGET_MFG_NUM)
-    MACROFIELD_LINE(BRIDGE_WID_STAT, b_wid_stat)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_STAT_LLP_REC_CNT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_STAT_LLP_TX_CNT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_STAT_FLASH_SELECT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_STAT_PCI_GIO_N)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_STAT_PENDING)
-    MACROFIELD_LINE(BRIDGE_WID_ERR_UPPER, b_wid_err_upper)
-    MACROFIELD_LINE(BRIDGE_WID_ERR_LOWER, b_wid_err_lower)
-    MACROFIELD_LINE(BRIDGE_WID_CONTROL, b_wid_control)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_FLASH_WR_EN)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_EN_CLK50)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_EN_CLK40)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_EN_CLK33)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_RST_MASK)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_IO_SWAP)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_MEM_SWAP)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_PAGE_SIZE)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_SS_PAR_BAD)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_SS_PAR_EN)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_SSRAM_SIZE_MASK)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_F_BAD_PKT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_LLP_XBAR_CRD_MASK)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_CLR_RLLP_CNT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_CLR_TLLP_CNT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_SYS_END)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_MAX_TRANS_MASK)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_CTRL_WIDGET_ID_MASK)
-    MACROFIELD_LINE(BRIDGE_WID_REQ_TIMEOUT, b_wid_req_timeout)
-    MACROFIELD_LINE(BRIDGE_WID_INT_UPPER, b_wid_int_upper)
-    MACROFIELD_LINE_BITFIELD(WIDGET_INT_VECTOR)
-    MACROFIELD_LINE_BITFIELD(WIDGET_TARGET_ID)
-    MACROFIELD_LINE_BITFIELD(WIDGET_UPP_ADDR)
-    MACROFIELD_LINE(BRIDGE_WID_INT_LOWER, b_wid_int_lower)
-    MACROFIELD_LINE(BRIDGE_WID_ERR_CMDWORD, b_wid_err_cmdword)
-    MACROFIELD_LINE_BITFIELD(WIDGET_DIDN)
-    MACROFIELD_LINE_BITFIELD(WIDGET_SIDN)
-    MACROFIELD_LINE_BITFIELD(WIDGET_PACTYP)
-    MACROFIELD_LINE_BITFIELD(WIDGET_TNUM)
-    MACROFIELD_LINE_BITFIELD(WIDGET_COHERENT)
-    MACROFIELD_LINE_BITFIELD(WIDGET_DS)
-    MACROFIELD_LINE_BITFIELD(WIDGET_GBR)
-    MACROFIELD_LINE_BITFIELD(WIDGET_VBPM)
-    MACROFIELD_LINE_BITFIELD(WIDGET_ERROR)
-    MACROFIELD_LINE_BITFIELD(WIDGET_BARRIER)
-    MACROFIELD_LINE(BRIDGE_WID_LLP, b_wid_llp)
-    MACROFIELD_LINE_BITFIELD(WIDGET_LLP_MAXRETRY)
-    MACROFIELD_LINE_BITFIELD(WIDGET_LLP_NULLTIMEOUT)
-    MACROFIELD_LINE_BITFIELD(WIDGET_LLP_MAXBURST)
-    MACROFIELD_LINE(BRIDGE_WID_TFLUSH, b_wid_tflush)
-    MACROFIELD_LINE(BRIDGE_WID_AUX_ERR, b_wid_aux_err)
-    MACROFIELD_LINE(BRIDGE_WID_RESP_UPPER, b_wid_resp_upper)
-    MACROFIELD_LINE(BRIDGE_WID_RESP_LOWER, b_wid_resp_lower)
-    MACROFIELD_LINE(BRIDGE_WID_TST_PIN_CTRL, b_wid_tst_pin_ctrl)
-    MACROFIELD_LINE(BRIDGE_DIR_MAP, b_dir_map)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DIRMAP_W_ID)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DIRMAP_RMF_64)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DIRMAP_ADD512)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DIRMAP_OFF)
-    MACROFIELD_LINE(BRIDGE_RAM_PERR, b_ram_perr)
-    MACROFIELD_LINE(BRIDGE_ARB, b_arb)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_REQ_WAIT_TICK_MASK)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_REQ_WAIT_EN_MASK)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_FREEZE_GNT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_HPRI_RING_B2)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_HPRI_RING_B1)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_HPRI_RING_B0)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_LPRI_RING_B2)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_LPRI_RING_B1)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ARB_LPRI_RING_B0)
-    MACROFIELD_LINE(BRIDGE_NIC, b_nic)
-    MACROFIELD_LINE(BRIDGE_PCI_BUS_TIMEOUT, b_pci_bus_timeout)
-    MACROFIELD_LINE(BRIDGE_PCI_CFG, b_pci_cfg)
-    MACROFIELD_LINE(BRIDGE_PCI_ERR_UPPER, b_pci_err_upper)
-    MACROFIELD_LINE(BRIDGE_PCI_ERR_LOWER, b_pci_err_lower)
-    MACROFIELD_LINE(BRIDGE_INT_STATUS, b_int_status)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_MULTI_ERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_PMU_ESIZE_FAULT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_UNEXP_RESP)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_BAD_XRESP_PKT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_BAD_XREQ_PKT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_RESP_XTLK_ERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_REQ_XTLK_ERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_INVLD_ADDR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_UNSUPPORTED_XOP)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_XREQ_FIFO_OFLOW)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_LLP_REC_SNERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_LLP_REC_CBERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_LLP_RCTY)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_LLP_TX_RETRY)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_LLP_TCTY)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_SSRAM_PERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_PCI_ABORT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_PCI_PARITY)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_PCI_SERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_PCI_PERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_PCI_MST_TIMEOUT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_PCI_RETRY_CNT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_XREAD_REQ_TIMEOUT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_GIO_B_ENBL_ERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_ISR_INT_MSK)
-    MACROFIELD_LINE(BRIDGE_INT_ENABLE, b_int_enable)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_UNEXP_RESP)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_PMU_ESIZE_FAULT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_BAD_XRESP_PKT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_BAD_XREQ_PKT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_RESP_XTLK_ERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_REQ_XTLK_ERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_INVLD_ADDR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_UNSUPPORTED_XOP)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_XREQ_FIFO_OFLOW)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_LLP_REC_SNERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_LLP_REC_CBERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_LLP_RCTY)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_LLP_TX_RETRY)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_LLP_TCTY)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_SSRAM_PERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_PCI_ABORT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_PCI_PARITY)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_PCI_SERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_PCI_PERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_PCI_MST_TIMEOUT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_PCI_RETRY_CNT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_XREAD_REQ_TIMEOUT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_GIO_B_ENBL_ERR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IMR_INT_MSK)
-    MACROFIELD_LINE(BRIDGE_INT_RST_STAT, b_int_rst_stat)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IRR_ALL_CLR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IRR_MULTI_CLR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IRR_CRP_GRP_CLR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IRR_RESP_BUF_GRP_CLR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IRR_REQ_DSP_GRP_CLR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IRR_LLP_GRP_CLR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IRR_SSRAM_GRP_CLR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_IRR_PCI_GRP_CLR)
-    MACROFIELD_LINE(BRIDGE_INT_MODE, b_int_mode)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INTMODE_CLR_PKT_EN(7))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INTMODE_CLR_PKT_EN(6))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INTMODE_CLR_PKT_EN(5))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INTMODE_CLR_PKT_EN(4))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INTMODE_CLR_PKT_EN(3))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INTMODE_CLR_PKT_EN(2))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INTMODE_CLR_PKT_EN(1))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INTMODE_CLR_PKT_EN(0))
-    MACROFIELD_LINE(BRIDGE_INT_DEVICE, b_int_device)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_DEV_MASK(7))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_DEV_MASK(6))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_DEV_MASK(5))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_DEV_MASK(4))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_DEV_MASK(3))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_DEV_MASK(2))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_DEV_MASK(1))
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_DEV_MASK(0))
-    MACROFIELD_LINE(BRIDGE_INT_HOST_ERR, b_int_host_err)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_ADDR_HOST)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_INT_ADDR_FLD)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR0, b_int_addr[0].addr)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR(0), b_int_addr[0].addr)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR(1), b_int_addr[1].addr)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR(2), b_int_addr[2].addr)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR(3), b_int_addr[3].addr)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR(4), b_int_addr[4].addr)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR(5), b_int_addr[5].addr)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR(6), b_int_addr[6].addr)
-    MACROFIELD_LINE(BRIDGE_INT_ADDR(7), b_int_addr[7].addr)
-    MACROFIELD_LINE(BRIDGE_DEVICE0, b_device[0].reg)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_ERR_LOCK_EN)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_PAGE_CHK_DIS)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_FORCE_PCI_PAR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_VIRTUAL_EN)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_PMU_WRGA_EN)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_DIR_WRGA_EN)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_DEV_SIZE)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_RT)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_SWAP_PMU)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_SWAP_DIR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_PREF)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_PRECISE)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_COH)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_BARRIER)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_GBR)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_DEV_SWAP)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_DEV_IO_MEM)
-    MACROFIELD_LINE_BITFIELD(BRIDGE_DEV_OFF_MASK)
-    MACROFIELD_LINE(BRIDGE_DEVICE(0), b_device[0].reg)
-    MACROFIELD_LINE(BRIDGE_DEVICE(1), b_device[1].reg)
-    MACROFIELD_LINE(BRIDGE_DEVICE(2), b_device[2].reg)
-    MACROFIELD_LINE(BRIDGE_DEVICE(3), b_device[3].reg)
-    MACROFIELD_LINE(BRIDGE_DEVICE(4), b_device[4].reg)
-    MACROFIELD_LINE(BRIDGE_DEVICE(5), b_device[5].reg)
-    MACROFIELD_LINE(BRIDGE_DEVICE(6), b_device[6].reg)
-    MACROFIELD_LINE(BRIDGE_DEVICE(7), b_device[7].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF0, b_wr_req_buf[0].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF(0), b_wr_req_buf[0].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF(1), b_wr_req_buf[1].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF(2), b_wr_req_buf[2].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF(3), b_wr_req_buf[3].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF(4), b_wr_req_buf[4].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF(5), b_wr_req_buf[5].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF(6), b_wr_req_buf[6].reg)
-    MACROFIELD_LINE(BRIDGE_WR_REQ_BUF(7), b_wr_req_buf[7].reg)
-    MACROFIELD_LINE(BRIDGE_EVEN_RESP, b_even_resp)
-    MACROFIELD_LINE(BRIDGE_ODD_RESP, b_odd_resp)
-    MACROFIELD_LINE(BRIDGE_RESP_STATUS, b_resp_status)
-    MACROFIELD_LINE(BRIDGE_RESP_CLEAR, b_resp_clear)
-    MACROFIELD_LINE(BRIDGE_ATE_RAM, b_int_ate_ram)
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV0, b_type0_cfg_dev[0])
-
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV(0), b_type0_cfg_dev[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(0,0), b_type0_cfg_dev[0].f[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(0,1), b_type0_cfg_dev[0].f[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(0,2), b_type0_cfg_dev[0].f[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(0,3), b_type0_cfg_dev[0].f[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(0,4), b_type0_cfg_dev[0].f[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(0,5), b_type0_cfg_dev[0].f[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(0,6), b_type0_cfg_dev[0].f[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(0,7), b_type0_cfg_dev[0].f[7])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV(1), b_type0_cfg_dev[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(1,0), b_type0_cfg_dev[1].f[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(1,1), b_type0_cfg_dev[1].f[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(1,2), b_type0_cfg_dev[1].f[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(1,3), b_type0_cfg_dev[1].f[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(1,4), b_type0_cfg_dev[1].f[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(1,5), b_type0_cfg_dev[1].f[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(1,6), b_type0_cfg_dev[1].f[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(1,7), b_type0_cfg_dev[1].f[7])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV(2), b_type0_cfg_dev[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(2,0), b_type0_cfg_dev[2].f[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(2,1), b_type0_cfg_dev[2].f[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(2,2), b_type0_cfg_dev[2].f[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(2,3), b_type0_cfg_dev[2].f[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(2,4), b_type0_cfg_dev[2].f[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(2,5), b_type0_cfg_dev[2].f[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(2,6), b_type0_cfg_dev[2].f[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(2,7), b_type0_cfg_dev[2].f[7])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV(3), b_type0_cfg_dev[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(3,0), b_type0_cfg_dev[3].f[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(3,1), b_type0_cfg_dev[3].f[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(3,2), b_type0_cfg_dev[3].f[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(3,3), b_type0_cfg_dev[3].f[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(3,4), b_type0_cfg_dev[3].f[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(3,5), b_type0_cfg_dev[3].f[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(3,6), b_type0_cfg_dev[3].f[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(3,7), b_type0_cfg_dev[3].f[7])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV(4), b_type0_cfg_dev[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(4,0), b_type0_cfg_dev[4].f[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(4,1), b_type0_cfg_dev[4].f[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(4,2), b_type0_cfg_dev[4].f[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(4,3), b_type0_cfg_dev[4].f[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(4,4), b_type0_cfg_dev[4].f[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(4,5), b_type0_cfg_dev[4].f[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(4,6), b_type0_cfg_dev[4].f[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(4,7), b_type0_cfg_dev[4].f[7])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV(5), b_type0_cfg_dev[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(5,0), b_type0_cfg_dev[5].f[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(5,1), b_type0_cfg_dev[5].f[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(5,2), b_type0_cfg_dev[5].f[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(5,3), b_type0_cfg_dev[5].f[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(5,4), b_type0_cfg_dev[5].f[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(5,5), b_type0_cfg_dev[5].f[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(5,6), b_type0_cfg_dev[5].f[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(5,7), b_type0_cfg_dev[5].f[7])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV(6), b_type0_cfg_dev[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(6,0), b_type0_cfg_dev[6].f[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(6,1), b_type0_cfg_dev[6].f[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(6,2), b_type0_cfg_dev[6].f[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(6,3), b_type0_cfg_dev[6].f[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(6,4), b_type0_cfg_dev[6].f[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(6,5), b_type0_cfg_dev[6].f[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(6,6), b_type0_cfg_dev[6].f[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(6,7), b_type0_cfg_dev[6].f[7])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEV(7), b_type0_cfg_dev[7])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(7,0), b_type0_cfg_dev[7].f[0])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(7,1), b_type0_cfg_dev[7].f[1])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(7,2), b_type0_cfg_dev[7].f[2])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(7,3), b_type0_cfg_dev[7].f[3])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(7,4), b_type0_cfg_dev[7].f[4])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(7,5), b_type0_cfg_dev[7].f[5])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(7,6), b_type0_cfg_dev[7].f[6])
-    MACROFIELD_LINE(BRIDGE_TYPE0_CFG_DEVF(7,7), b_type0_cfg_dev[7].f[7])
-
-    MACROFIELD_LINE(BRIDGE_TYPE1_CFG, b_type1_cfg)
-    MACROFIELD_LINE(BRIDGE_PCI_IACK, b_pci_iack)
-    MACROFIELD_LINE(BRIDGE_EXT_SSRAM, b_ext_ate_ram)
-    MACROFIELD_LINE(BRIDGE_DEVIO0, b_devio(0))
-    MACROFIELD_LINE(BRIDGE_DEVIO(0), b_devio(0))
-    MACROFIELD_LINE(BRIDGE_DEVIO(1), b_devio(1))
-    MACROFIELD_LINE(BRIDGE_DEVIO(2), b_devio(2))
-    MACROFIELD_LINE(BRIDGE_DEVIO(3), b_devio(3))
-    MACROFIELD_LINE(BRIDGE_DEVIO(4), b_devio(4))
-    MACROFIELD_LINE(BRIDGE_DEVIO(5), b_devio(5))
-    MACROFIELD_LINE(BRIDGE_DEVIO(6), b_devio(6))
-    MACROFIELD_LINE(BRIDGE_DEVIO(7), b_devio(7))
-    MACROFIELD_LINE(BRIDGE_EXTERNAL_FLASH, b_external_flash)
-};
-#endif
-
-#ifdef __cplusplus
-};
-#endif
-#endif				/* C or C++ */ 
-
-#endif                          /* _ASM_SN_PCI_BRIDGE_H */
diff -Nru a/include/asm-ia64/sn/pci/pci_bus_cvlink.h b/include/asm-ia64/sn/pci/pci_bus_cvlink.h
--- a/include/asm-ia64/sn/pci/pci_bus_cvlink.h	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,70 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PCI_CVLINK_H
-#define _ASM_IA64_SN_PCI_CVLINK_H
-
-#include <asm/sn/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/iograph.h>
-#include <asm/param.h>
-#include <asm/sn/pio.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/xtalk/xtalkaddrs.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/io.h>
-
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-
-#define MAX_PCI_XWIDGET 256
-#define MAX_ATE_MAPS 1024
-
-#define SN_DEVICE_SYSDATA(dev) \
-	((struct sn_device_sysdata *) \
-	(((struct pci_controller *) ((dev)->sysdata))->platform_data))
-
-#define IS_PCI32G(dev)	((dev)->dma_mask >= 0xffffffff)
-#define IS_PCI32L(dev)	((dev)->dma_mask < 0xffffffff)
-
-#define PCIDEV_VERTEX(pci_dev) \
-	((SN_DEVICE_SYSDATA(pci_dev))->vhdl)
-
-struct sn_widget_sysdata {
-        vertex_hdl_t  vhdl;
-};
-
-struct sn_device_sysdata {
-        vertex_hdl_t		vhdl;
-	pciio_provider_t	*pci_provider;
-	pciio_intr_t		intr_handle;
-	struct sn_flush_device_list *dma_flush_list;
-        pciio_piomap_t		pio_map[PCI_ROM_RESOURCE];
-};
-
-struct ioports_to_tlbs_s {
-	unsigned long	p:1,
-			rv_1:1,
-			ma:3,
-			a:1,
-			d:1,
-			pl:2,
-			ar:3,
-			ppn:38,
-			rv_2:2,
-			ed:1,
-			ig:11;
-};
-
-#endif				/* _ASM_IA64_SN_PCI_CVLINK_H */
diff -Nru a/include/asm-ia64/sn/pci/pci_defs.h b/include/asm-ia64/sn/pci/pci_defs.h
--- a/include/asm-ia64/sn/pci/pci_defs.h	2004-12-24 13:36:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,414 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PCI_PCI_DEFS_H
-#define _ASM_IA64_SN_PCI_PCI_DEFS_H
-
-/* defines for the PCI bus architecture */
-
-/* Bit layout of address fields for Type-1
- * Configuration Space cycles.
- */
-#define	PCI_TYPE0_SLOT_MASK	0xFFFFF800
-#define	PCI_TYPE0_FUNC_MASK	0x00000700
-#define	PCI_TYPE0_REG_MASK	0x000000FF
-
-#define	PCI_TYPE0_SLOT_SHFT	11
-#define	PCI_TYPE0_FUNC_SHFT	8
-#define	PCI_TYPE0_REG_SHFT	0
-
-#define	PCI_TYPE0_FUNC(a)	(((a) & PCI_TYPE0_FUNC_MASK) >> PCI_TYPE0_FUNC_SHFT)
-#define	PCI_TYPE0_REG(a)	(((a) & PCI_TYPE0_REG_MASK) >> PCI_TYPE0_REG_SHFT)
-
-#define	PCI_TYPE0(s,f,r)	((((1<<(s)) << PCI_TYPE0_SLOT_SHFT) & PCI_TYPE0_SLOT_MASK) |\
-				 (((f) << PCI_TYPE0_FUNC_SHFT) & PCI_TYPE0_FUNC_MASK) |\
-				 (((r) << PCI_TYPE0_REG_SHFT) & PCI_TYPE0_REG_MASK))
-
-/* Bit layout of address fields for Type-1
- * Configuration Space cycles.
- * NOTE: I'm including the byte offset within
- * the 32-bit word as part of the register
- * number as an extension of the layout in
- * the PCI spec.
- */
-#define	PCI_TYPE1_BUS_MASK	0x00FF0000
-#define	PCI_TYPE1_SLOT_MASK	0x0000F800
-#define	PCI_TYPE1_FUNC_MASK	0x00000700
-#define	PCI_TYPE1_REG_MASK	0x000000FF
-
-#define	PCI_TYPE1_BUS_SHFT	16
-#define	PCI_TYPE1_SLOT_SHFT	11
-#define	PCI_TYPE1_FUNC_SHFT	8
-#define	PCI_TYPE1_REG_SHFT	0
-
-#define	PCI_TYPE1_BUS(a)	(((a) & PCI_TYPE1_BUS_MASK) >> PCI_TYPE1_BUS_SHFT)
-#define	PCI_TYPE1_SLOT(a)	(((a) & PCI_TYPE1_SLOT_MASK) >> PCI_TYPE1_SLOT_SHFT)
-#define	PCI_TYPE1_FUNC(a)	(((a) & PCI_TYPE1_FUNC_MASK) >> PCI_TYPE1_FUNC_SHFT)
-#define	PCI_TYPE1_REG(a)	(((a) & PCI_TYPE1_REG_MASK) >> PCI_TYPE1_REG_SHFT)
-
-#define	PCI_TYPE1(b,s,f,r)	((((b) << PCI_TYPE1_BUS_SHFT) & PCI_TYPE1_BUS_MASK) |\
-				 (((s) << PCI_TYPE1_SLOT_SHFT) & PCI_TYPE1_SLOT_MASK) |\
-				 (((f) << PCI_TYPE1_FUNC_SHFT) & PCI_TYPE1_FUNC_MASK) |\
-				 (((r) << PCI_TYPE1_REG_SHFT) & PCI_TYPE1_REG_MASK))
-
-/* Byte offsets of registers in CFG space
- */
-#define	PCI_CFG_VENDOR_ID	0x00		/* Vendor ID (2 bytes) */
-#define	PCI_CFG_DEVICE_ID	0x02		/* Device ID (2 bytes) */
-
-#define	PCI_CFG_COMMAND		0x04		/* Command (2 bytes) */
-#define	PCI_CFG_STATUS		0x06		/* Status (2 bytes) */
-
-/* NOTE: if you are using a C "switch" statement to
- * differentiate between the Config space registers, be
- * aware that PCI_CFG_CLASS_CODE and PCI_CFG_PROG_IF
- * are the same offset.
- */
-#define	PCI_CFG_REV_ID		0x08		/* Revision Id (1 byte) */
-#define	PCI_CFG_CLASS_CODE	0x09		/* Class Code (3 bytes) */
-#define	PCI_CFG_PROG_IF		0x09		/* Prog Interface (1 byte) */
-#define	PCI_CFG_SUB_CLASS	0x0A		/* Sub Class (1 byte) */
-#define	PCI_CFG_BASE_CLASS	0x0B		/* Base Class (1 byte) */
-
-#define	PCI_CFG_CACHE_LINE	0x0C		/* Cache line size (1 byte) */
-#define	PCI_CFG_LATENCY_TIMER	0x0D		/* Latency Timer (1 byte) */
-#define	PCI_CFG_HEADER_TYPE	0x0E		/* Header Type (1 byte) */
-#define	PCI_CFG_BIST		0x0F		/* Built In Self Test */
-
-#define	PCI_CFG_BASE_ADDR_0	0x10		/* Base Address (4 bytes) */
-#define	PCI_CFG_BASE_ADDR_1	0x14		/* Base Address (4 bytes) */
-#define	PCI_CFG_BASE_ADDR_2	0x18		/* Base Address (4 bytes) */
-#define	PCI_CFG_BASE_ADDR_3	0x1C		/* Base Address (4 bytes) */
-#define	PCI_CFG_BASE_ADDR_4	0x20		/* Base Address (4 bytes) */
-#define	PCI_CFG_BASE_ADDR_5	0x24		/* Base Address (4 bytes) */
-
-#define	PCI_CFG_BASE_ADDR_OFF	0x04		/* Base Address Offset (1..5)*/
-#define	PCI_CFG_BASE_ADDR(n)	(PCI_CFG_BASE_ADDR_0 + (n)*PCI_CFG_BASE_ADDR_OFF)
-#define	PCI_CFG_BASE_ADDRS	6		/* up to this many BASE regs */
-
-#define	PCI_CFG_CARDBUS_CIS	0x28		/* Cardbus CIS Pointer (4B) */
-
-#define	PCI_CFG_SUBSYS_VEND_ID	0x2C		/* Subsystem Vendor ID (2B) */
-#define	PCI_CFG_SUBSYS_ID	0x2E		/* Subsystem ID */
-
-#define	PCI_EXPANSION_ROM	0x30		/* Expansion Rom Base (4B) */
-#define	PCI_CAPABILITIES_PTR	0x34		/* Capabilities Pointer */
-
-#define	PCI_INTR_LINE		0x3C		/* Interrupt Line (1B) */
-#define	PCI_INTR_PIN		0x3D		/* Interrupt Pin (1B) */
-
-#define PCI_CFG_VEND_SPECIFIC	0x40		/* first vendor specific reg */
-
-/* layout for Type 0x01 headers */
-
-#define	PCI_CFG_PPB_BUS_PRI		0x18	/* immediate upstream bus # */
-#define	PCI_CFG_PPB_BUS_SEC		0x19	/* immediate downstream bus # */
-#define	PCI_CFG_PPB_BUS_SUB		0x1A	/* last downstream bus # */
-#define	PCI_CFG_PPB_SEC_LAT		0x1B	/* latency timer for SEC bus */
-#define PCI_CFG_PPB_IOBASE		0x1C	/* IO Base Addr bits 12..15 */
-#define PCI_CFG_PPB_IOLIM		0x1D	/* IO Limit Addr bits 12..15 */
-#define	PCI_CFG_PPB_SEC_STAT		0x1E	/* Secondary Status */
-#define PCI_CFG_PPB_MEMBASE		0x20	/* MEM Base Addr bits 16..31 */
-#define PCI_CFG_PPB_MEMLIM		0x22	/* MEM Limit Addr bits 16..31 */
-#define PCI_CFG_PPB_MEMPFBASE		0x24	/* PfMEM Base Addr bits 16..31 */
-#define PCI_CFG_PPB_MEMPFLIM		0x26	/* PfMEM Limit Addr bits 16..31 */
-#define PCI_CFG_PPB_MEMPFBASEHI		0x28	/* PfMEM Base Addr bits 32..63 */
-#define PCI_CFG_PPB_MEMPFLIMHI		0x2C	/* PfMEM Limit Addr bits 32..63 */
-#define PCI_CFG_PPB_IOBASEHI		0x30	/* IO Base Addr bits 16..31 */
-#define PCI_CFG_PPB_IOLIMHI		0x32	/* IO Limit Addr bits 16..31 */
-#define	PCI_CFG_PPB_SUB_VENDOR		0x34	/* Subsystem Vendor ID */
-#define	PCI_CFG_PPB_SUB_DEVICE		0x36	/* Subsystem Device ID */
-#define	PCI_CFG_PPB_ROM_BASE		0x38	/* ROM base address */
-#define	PCI_CFG_PPB_INT_LINE		0x3C	/* Interrupt Line */
-#define	PCI_CFG_PPB_INT_PIN		0x3D	/* Interrupt Pin */
-#define	PCI_CFG_PPB_BRIDGE_CTRL		0x3E	/* Bridge Control */
-     /* XXX- these might be DEC 21152 specific */
-#define	PCI_CFG_PPB_CHIP_CTRL		0x40
-#define	PCI_CFG_PPB_DIAG_CTRL		0x41
-#define	PCI_CFG_PPB_ARB_CTRL		0x42
-#define	PCI_CFG_PPB_SERR_DISABLE	0x64
-#define	PCI_CFG_PPB_CLK2_CTRL		0x68
-#define	PCI_CFG_PPB_SERR_STATUS		0x6A
-
-/* Command Register layout (0x04) */
-#define	PCI_CMD_IO_SPACE	0x001		/* I/O Space device */
-#define	PCI_CMD_MEM_SPACE	0x002		/* Memory Space */
-#define	PCI_CMD_BUS_MASTER	0x004		/* Bus Master */
-#define	PCI_CMD_SPEC_CYCLES	0x008		/* Special Cycles */
-#define	PCI_CMD_MEMW_INV_ENAB	0x010		/* Memory Write Inv Enable */
-#define	PCI_CMD_VGA_PALETTE_SNP	0x020		/* VGA Palette Snoop */
-#define	PCI_CMD_PAR_ERR_RESP	0x040		/* Parity Error Response */
-#define	PCI_CMD_WAIT_CYCLE_CTL	0x080		/* Wait Cycle Control */
-#define	PCI_CMD_SERR_ENABLE	0x100		/* SERR# Enable */
-#define	PCI_CMD_F_BK_BK_ENABLE	0x200		/* Fast Back-to-Back Enable */
-
-/* Status Register Layout (0x06) */
-#define	PCI_STAT_PAR_ERR_DET	0x8000		/* Detected Parity Error */
-#define	PCI_STAT_SYS_ERR	0x4000		/* Signaled System Error */
-#define	PCI_STAT_RCVD_MSTR_ABT	0x2000		/* Received Master Abort */
-#define	PCI_STAT_RCVD_TGT_ABT	0x1000		/* Received Target Abort */
-#define	PCI_STAT_SGNL_TGT_ABT	0x0800		/* Signaled Target Abort */
-
-#define	PCI_STAT_DEVSEL_TIMING	0x0600		/* DEVSEL Timing Mask */
-#define	DEVSEL_TIMING(_x)	(((_x) >> 9) & 3)	/* devsel tim macro */
-#define	DEVSEL_FAST		0		/* Fast timing */
-#define	DEVSEL_MEDIUM		1		/* Medium timing */
-#define	DEVSEL_SLOW		2		/* Slow timing */
-
-#define	PCI_STAT_DATA_PAR_ERR	0x0100		/* Data Parity Err Detected */
-#define	PCI_STAT_F_BK_BK_CAP	0x0080		/* Fast Back-to-Back Capable */
-#define	PCI_STAT_UDF_SUPP	0x0040		/* UDF Supported */
-#define	PCI_STAT_66MHZ_CAP	0x0020		/* 66 MHz Capable */
-#define	PCI_STAT_CAP_LIST	0x0010		/* Capabilities List */
-
-/* BIST Register Layout (0x0F) */
-#define	PCI_BIST_BIST_CAP	0x80		/* BIST Capable */
-#define	PCI_BIST_START_BIST	0x40		/* Start BIST */
-#define	PCI_BIST_CMPLTION_MASK	0x0F		/* COMPLETION MASK */
-#define	PCI_BIST_CMPL_OK	0x00		/* 0 value is completion OK */
-
-/* Base Address Register 0x10 */
-#define PCI_BA_IO_CODEMASK	0x3		/* bottom 2 bits encode I/O BAR type */
-#define	PCI_BA_IO_SPACE		0x1		/* I/O Space Marker */
-
-#define PCI_BA_MEM_CODEMASK	0xf		/* bottom 4 bits encode MEM BAR type */
-#define	PCI_BA_MEM_LOCATION	0x6		/* 2 bits for location avail */
-#define	PCI_BA_MEM_32BIT	0x0		/* Anywhere in 32bit space */
-#define	PCI_BA_MEM_1MEG		0x2		/* Locate below 1 Meg */
-#define	PCI_BA_MEM_64BIT	0x4		/* Anywhere in 64bit space */
-#define	PCI_BA_PREFETCH		0x8		/* Prefetchable, no side effect */
-
-#define PCI_BA_ROM_CODEMASK	0x1		/* bottom bit control expansion ROM enable */
-#define PCI_BA_ROM_ENABLE	0x1		/* enable expansion ROM */
-
-/* Bridge Control Register 0x3e */
-#define PCI_BCTRL_DTO_SERR	0x0800		/* Discard Timer timeout generates SERR on primary bus */
-#define PCI_BCTRL_DTO		0x0400		/* Discard Timer timeout status */
-#define PCI_BCTRL_DTO_SEC	0x0200		/* Secondary Discard Timer: 0 => 2^15 PCI clock cycles, 1 => 2^10 */
-#define PCI_BCTRL_DTO_PRI	0x0100		/* Primary Discard Timer: 0 => 2^15 PCI clock cycles, 1 => 2^10 */
-#define PCI_BCTRL_F_BK_BK_ENABLE 0x0080		/* Enable Fast Back-to-Back on secondary bus */
-#define PCI_BCTRL_RESET_SEC	0x0040		/* Reset Secondary bus */
-#define PCI_BCTRL_MSTR_ABT_MODE	0x0020		/* Master Abort Mode: 0 => do not report Master-Aborts */
-#define PCI_BCTRL_VGA_AF_ENABLE	0x0008		/* Enable VGA Address Forwarding */
-#define PCI_BCTRL_ISA_AF_ENABLE	0x0004		/* Enable ISA Address Forwarding */
-#define PCI_BCTRL_SERR_ENABLE	0x0002		/* Enable forwarding of SERR from secondary bus to primary bus */
-#define PCI_BCTRL_PAR_ERR_RESP	0x0001		/* Enable Parity Error Response reporting on secondary interface */
-
-/*
- * PCI 2.2 introduces the concept of ``capability lists.''  Capability lists
- * provide a flexible mechanism for a device or bridge to advertise one or
- * more standardized capabilities such as the presense of a power management
- * interface, etc.  The presense of a capability list is indicated by
- * PCI_STAT_CAP_LIST being non-zero in the PCI_CFG_STATUS register.  If
- * PCI_STAT_CAP_LIST is set, then PCI_CFG_CAP_PTR is a ``pointer'' into the
- * device-specific portion of the configuration header where the first
- * capability block is stored.  This ``pointer'' is a single byte which
- * contains an offset from the beginning of the configuration header.  The
- * bottom two bits of the pointer are reserved and should be masked off to
- * determine the offset.  Each capability block contains a capability ID, a
- * ``pointer'' to the next capability (another offset where a zero terminates
- * the list) and capability-specific data.  Each capability block starts with
- * the capability ID and the ``next capability pointer.''  All data following
- * this are capability-dependent.
- */
-#define PCI_CAP_ID		0x00		/* Capability ID (1B) */
-#define PCI_CAP_PTR		0x01		/* Capability ``pointer'' (1B) */
-
-/* PCI Capability IDs */
-#define	PCI_CAP_PM		0x01		/* PCI Power Management */
-#define	PCI_CAP_AGP		0x02		/* Accelerated Graphics Port */
-#define	PCI_CAP_VPD		0x03		/* Vital Product Data (VPD) */
-#define	PCI_CAP_SID		0x04		/* Slot Identification */
-#define PCI_CAP_MSI		0x05		/* Message Signaled Intr */
-#define	PCI_CAP_HS		0x06		/* CompactPCI Hot Swap */
-#define	PCI_CAP_PCIX		0x07		/* PCI-X */
-#define PCI_CAP_ID_HT		0x08		/* HyperTransport */
-
-
-/* PIO interface macros */
-
-#ifndef IOC3_EMULATION
-
-#define PCI_INB(x)          (*((volatile char*)x))
-#define PCI_INH(x)          (*((volatile short*)x))
-#define PCI_INW(x)          (*((volatile int*)x))
-#define PCI_OUTB(x,y)       (*((volatile char*)x) = y)
-#define PCI_OUTH(x,y)       (*((volatile short*)x) = y)
-#define PCI_OUTW(x,y)       (*((volatile int*)x) = y)
-
-#else
-
-extern unsigned int pci_read(void * address, int type);
-extern void pci_write(void * address, int data, int type);
-
-#define BYTE   1
-#define HALF   2
-#define WORD   4
-
-#define PCI_INB(x)          pci_read((void *)(x),BYTE)
-#define PCI_INH(x)          pci_read((void *)(x),HALF)
-#define PCI_INW(x)          pci_read((void *)(x),WORD)
-#define PCI_OUTB(x,y)       pci_write((void *)(x),(y),BYTE)
-#define PCI_OUTH(x,y)       pci_write((void *)(x),(y),HALF)
-#define PCI_OUTW(x,y)       pci_write((void *)(x),(y),WORD)
-
-#endif /* !IOC3_EMULATION */
-						/* effects on reads, merges */
-
-/*
- * Definition of address layouts for PCI Config mechanism #1
- * XXX- These largely duplicate PCI_TYPE1 constants at the top
- * of the file; the two groups should probably be combined.
- */
-
-#define CFG1_ADDR_REGISTER_MASK		0x000000fc
-#define CFG1_ADDR_FUNCTION_MASK		0x00000700
-#define CFG1_ADDR_DEVICE_MASK		0x0000f800
-#define CFG1_ADDR_BUS_MASK		0x00ff0000
-
-#define CFG1_REGISTER_SHIFT		2
-#define CFG1_FUNCTION_SHIFT		8
-#define CFG1_DEVICE_SHIFT		11
-#define CFG1_BUS_SHIFT			16
-
-/*
- * Class codes
- */
-#define PCI_CFG_CLASS_PRE20	0x00
-#define PCI_CFG_CLASS_STORAGE	0x01
-#define PCI_CFG_CLASS_NETWORK	0x02
-#define PCI_CFG_CLASS_DISPLAY	0x03
-#define PCI_CFG_CLASS_MMEDIA	0x04
-#define PCI_CFG_CLASS_MEMORY	0x05
-#define PCI_CFG_CLASS_BRIDGE	0x06
-#define PCI_CFG_CLASS_COMM	0x07
-#define PCI_CFG_CLASS_BASE	0x08
-#define PCI_CFG_CLASS_INPUT	0x09
-#define PCI_CFG_CLASS_DOCK	0x0A
-#define PCI_CFG_CLASS_PROC	0x0B
-#define PCI_CFG_CLASS_SERIALBUS	0x0C
-#define PCI_CFG_CLASS_OTHER	0xFF
-
-/*
- * Important Subclasses
- */
-#define PCI_CFG_SUBCLASS_BRIDGE_HOST	0x00
-#define PCI_CFG_SUBCLASS_BRIDGE_ISA	0x01
-#define PCI_CFG_SUBCLASS_BRIDGE_EISA	0x02
-#define PCI_CFG_SUBCLASS_BRIDGE_MC	0x03
-#define PCI_CFG_SUBCLASS_BRIDGE_PCI	0x04
-#define PCI_CFG_SUBCLASS_BRIDGE_PCMCIA	0x05
-#define PCI_CFG_SUBCLASS_BRIDGE_NUBUS	0x06
-#define PCI_CFG_SUBCLASS_BRIDGE_CARDBUS	0x07
-#define PCI_CFG_SUBCLASS_BRIDGE_OTHER	0x80
-
-#ifndef __ASSEMBLY__
-
-/*
- * PCI config space definition
- */
-typedef volatile struct pci_cfg_s {
-	uint16_t	vendor_id;
-	uint16_t	dev_id;
-	uint16_t	cmd;
-	uint16_t	status;
-	uint8_t		rev;
-	uint8_t         prog_if;
-	uint8_t		sub_class;
-	uint8_t		class;
-	uint8_t		line_size;
-	uint8_t		lt;
-	uint8_t		hdr_type;
-	uint8_t		bist;
-	uint32_t	bar[6];
-	uint32_t	cardbus;
-	uint16_t	subsys_vendor_id;
-	uint16_t	subsys_dev_id;
-	uint32_t	exp_rom;
-	uint32_t	res[2];
-	uint8_t		int_line;
-	uint8_t		int_pin;
-	uint8_t		min_gnt;
-	uint8_t		max_lat;
-} pci_cfg_t;
-
-/*
- * PCI Type 1 config space definition for PCI to PCI Bridges (PPBs)
- */
-typedef volatile struct pci_cfg1_s {
-	uint16_t	vendor_id;
-	uint16_t	dev_id;
-	uint16_t	cmd;
-	uint16_t	status;
-	uint8_t		rev;
-	uint8_t		prog_if;
-	uint8_t		sub_class;
-	uint8_t		class;
-	uint8_t		line_size;
-	uint8_t		lt;
-	uint8_t		hdr_type;
-	uint8_t		bist;
-	uint32_t	bar[2];
-	uint8_t		pri_bus_num;
-	uint8_t		snd_bus_num;
-	uint8_t		sub_bus_num;
-	uint8_t		slt;
-	uint8_t		io_base;
-	uint8_t		io_limit;
-	uint16_t	snd_status;
-	uint16_t	mem_base;
-	uint16_t	mem_limit;
-	uint16_t	pmem_base;
-	uint16_t	pmem_limit;
-	uint32_t	pmem_base_upper;
-	uint32_t	pmem_limit_upper;
-	uint16_t	io_base_upper;
-	uint16_t	io_limit_upper;
-	uint32_t	res;
-	uint32_t	exp_rom;
-	uint8_t		int_line;
-	uint8_t		int_pin;
-	uint16_t	ppb_control;
-
-} pci_cfg1_t;
-
-/*
- * PCI-X Capability
- */
-typedef volatile struct cap_pcix_cmd_reg_s {
-	uint16_t	data_parity_enable:	1,
-			enable_relaxed_order:	1,
-			max_mem_read_cnt:	2,
-			max_split:		3,
-			reserved1:		9;
-} cap_pcix_cmd_reg_t;
-
-typedef volatile struct cap_pcix_stat_reg_s {
-	uint32_t	func_num:		3,
-			dev_num:		5,
-			bus_num:		8,
-			bit64_device:		1,
-			mhz133_capable:		1,
-			split_complt_discard:	1,
-			unexpect_split_complt:	1,
-			device_complex:		1,
-			max_mem_read_cnt:	2,
-			max_out_split:		3,
-			max_cum_read:		3,
-			split_complt_err:	1,
-			reserved1:		2;
-} cap_pcix_stat_reg_t;
-
-typedef volatile struct cap_pcix_type0_s {
-	uint8_t			pcix_cap_id;
-	uint8_t			pcix_cap_nxt;
-	cap_pcix_cmd_reg_t	pcix_type0_command;
-	cap_pcix_stat_reg_t	pcix_type0_status;
-} cap_pcix_type0_t;
-
-#endif	/* __ASSEMBLY__ */
-#endif /* _ASM_IA64_SN_PCI_PCI_DEFS_H */
diff -Nru a/include/asm-ia64/sn/pci/pcibr.h b/include/asm-ia64/sn/pci/pcibr.h
--- a/include/asm-ia64/sn/pci/pcibr.h	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,535 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PCI_PCIBR_H
-#define _ASM_IA64_SN_PCI_PCIBR_H
-
-#if defined(__KERNEL__)
-
-#include <linux/config.h>
-#include <asm/sn/dmamap.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/pio.h>
-
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/bridge.h>
-
-/* =====================================================================
- *    symbolic constants used by pcibr's xtalk bus provider
- */
-
-#define PCIBR_PIOMAP_BUSY		0x80000000
-
-#define PCIBR_DMAMAP_BUSY		0x80000000
-#define	PCIBR_DMAMAP_SSRAM		0x40000000
-
-#define PCIBR_INTR_BLOCKED		0x40000000
-#define PCIBR_INTR_BUSY			0x80000000
-
-#ifndef __ASSEMBLY__
-
-/* =====================================================================
- *    opaque types used by pcibr's xtalk bus provider
- */
-
-typedef struct pcibr_piomap_s *pcibr_piomap_t;
-typedef struct pcibr_dmamap_s *pcibr_dmamap_t;
-typedef struct pcibr_intr_s *pcibr_intr_t;
-
-/* =====================================================================
- *    bus provider function table
- *
- *	Normally, this table is only handed off explicitly
- *	during provider initialization, and the PCI generic
- *	layer will stash a pointer to it in the vertex; however,
- *	exporting it explicitly enables a performance hack in
- *	the generic PCI provider where if we know at compile
- *	time that the only possible PCI provider is a
- *	pcibr, we can go directly to this ops table.
- */
-
-extern pciio_provider_t pci_pic_provider;
-
-/* =====================================================================
- *    secondary entry points: pcibr PCI bus provider
- *
- *	These functions are normally exported explicitly by
- *	a direct call from the pcibr initialization routine
- *	into the generic crosstalk provider; they are included
- *	here to enable a more aggressive performance hack in
- *	the generic crosstalk layer, where if we know that the
- *	only possible crosstalk provider is pcibr, and we can
- *	guarantee that all entry points are properly named, and
- *	we can deal with the implicit casting properly, then
- *	we can turn many of the generic provider routines into
- *	plain brances, or even eliminate them (given sufficient
- *	smarts on the part of the compilation system).
- */
-
-extern pcibr_piomap_t	pcibr_piomap_alloc(vertex_hdl_t dev,
-					   device_desc_t dev_desc,
-					   pciio_space_t space,
-					   iopaddr_t pci_addr,
-					   size_t byte_count,
-					   size_t byte_count_max,
-					   unsigned flags);
-
-extern void		pcibr_piomap_free(pcibr_piomap_t piomap);
-
-extern caddr_t		pcibr_piomap_addr(pcibr_piomap_t piomap,
-					  iopaddr_t xtalk_addr,
-					  size_t byte_count);
-
-extern void		pcibr_piomap_done(pcibr_piomap_t piomap);
-
-extern int		pcibr_piomap_probe(pcibr_piomap_t piomap,
-					   off_t offset,
-					   int len,
-					   void *valp);
-
-extern caddr_t		pcibr_piotrans_addr(vertex_hdl_t dev,
-					    device_desc_t dev_desc,
-					    pciio_space_t space,
-					    iopaddr_t pci_addr,
-					    size_t byte_count,
-					    unsigned flags);
-
-extern iopaddr_t	pcibr_piospace_alloc(vertex_hdl_t dev,
-					     device_desc_t dev_desc,
-					     pciio_space_t space,
-					     size_t byte_count,
-					     size_t alignment);
-extern void		pcibr_piospace_free(vertex_hdl_t dev,
-					    pciio_space_t space,
-					    iopaddr_t pciaddr,
-					    size_t byte_count);
-
-extern pcibr_dmamap_t	pcibr_dmamap_alloc(vertex_hdl_t dev,
-					   device_desc_t dev_desc,
-					   size_t byte_count_max,
-					   unsigned flags);
-
-extern void		pcibr_dmamap_free(pcibr_dmamap_t dmamap);
-
-extern iopaddr_t	pcibr_dmamap_addr(pcibr_dmamap_t dmamap,
-					  paddr_t paddr,
-					  size_t byte_count);
-
-extern void		pcibr_dmamap_done(pcibr_dmamap_t dmamap);
-
-/*
- * pcibr_get_dmatrans_node() will return the compact node id to which  
- * all 32-bit Direct Mapping memory accesses will be directed.
- * (This node id can be different for each PCI bus.) 
- */
-
-extern cnodeid_t	pcibr_get_dmatrans_node(vertex_hdl_t pconn_vhdl);
-
-extern iopaddr_t	pcibr_dmatrans_addr(vertex_hdl_t dev,
-					    device_desc_t dev_desc,
-					    paddr_t paddr,
-					    size_t byte_count,
-					    unsigned flags);
-
-extern void		pcibr_dmamap_drain(pcibr_dmamap_t map);
-
-extern void		pcibr_dmaaddr_drain(vertex_hdl_t vhdl,
-					    paddr_t addr,
-					    size_t bytes);
-
-typedef unsigned	pcibr_intr_ibit_f(pciio_info_t info,
-					  pciio_intr_line_t lines);
-
-extern void		pcibr_intr_ibit_set(vertex_hdl_t, pcibr_intr_ibit_f *);
-
-extern pcibr_intr_t	pcibr_intr_alloc(vertex_hdl_t dev,
-					 device_desc_t dev_desc,
-					 pciio_intr_line_t lines,
-					 vertex_hdl_t owner_dev);
-
-extern void		pcibr_intr_free(pcibr_intr_t intr);
-
-extern int		pcibr_intr_connect(pcibr_intr_t intr, intr_func_t, intr_arg_t);
-
-extern void		pcibr_intr_disconnect(pcibr_intr_t intr);
-
-extern vertex_hdl_t	pcibr_intr_cpu_get(pcibr_intr_t intr);
-
-extern void		pcibr_provider_startup(vertex_hdl_t pcibr);
-
-extern void		pcibr_provider_shutdown(vertex_hdl_t pcibr);
-
-extern int		pcibr_reset(vertex_hdl_t dev);
-
-extern pciio_endian_t	pcibr_endian_set(vertex_hdl_t dev,
-					 pciio_endian_t device_end,
-					 pciio_endian_t desired_end);
-
-extern uint64_t		pcibr_config_get(vertex_hdl_t conn,
-					 unsigned reg,
-					 unsigned size);
-
-extern void		pcibr_config_set(vertex_hdl_t conn,
-					 unsigned reg,
-					 unsigned size,
-					 uint64_t value);
-
-extern pciio_slot_t	pcibr_error_extract(vertex_hdl_t pcibr_vhdl,
-					    pciio_space_t *spacep,
-					    iopaddr_t *addrp);
-
-extern int		pcibr_wrb_flush(vertex_hdl_t pconn_vhdl);
-extern int		pcibr_rrb_check(vertex_hdl_t pconn_vhdl,
-					int *count_vchan0,
-					int *count_vchan1,
-					int *count_reserved,
-					int *count_pool);
-
-extern int		pcibr_alloc_all_rrbs(vertex_hdl_t vhdl, int even_odd,
-					     int dev_1_rrbs, int virt1,
-					     int dev_2_rrbs, int virt2,
-					     int dev_3_rrbs, int virt3,
-					     int dev_4_rrbs, int virt4);
-
-typedef void
-rrb_alloc_funct_f	(vertex_hdl_t xconn_vhdl,
-			 int *vendor_list);
-
-typedef rrb_alloc_funct_f      *rrb_alloc_funct_t;
-
-void			pcibr_set_rrb_callback(vertex_hdl_t xconn_vhdl,
-					       rrb_alloc_funct_f *func);
-
-extern int		pcibr_device_unregister(vertex_hdl_t);
-extern void             pcibr_driver_reg_callback(vertex_hdl_t, int, int, int);
-extern void             pcibr_driver_unreg_callback(vertex_hdl_t,
-                                                    int, int, int);
-
-
-extern void *		pcibr_bridge_ptr_get(vertex_hdl_t, int);
-
-/*
- * Bridge-specific flags that can be set via pcibr_device_flags_set
- * and cleared via pcibr_device_flags_clear.  Other flags are
- * more generic and are maniuplated through PCI-generic interfaces.
- *
- * Note that all PCI implementation-specific flags (Bridge flags, in
- * this case) are in bits 15-31.  The lower 15 bits are reserved
- * for PCI-generic flags.
- *
- * Some of these flags have been "promoted" to the
- * generic layer, so they can be used without having
- * to "know" that the PCI bus is hosted by a Bridge.
- *
- * PCIBR_NO_ATE_ROUNDUP: Request that no rounding up be done when 
- * allocating ATE's. ATE count computation will assume that the
- * address to be mapped will start on a page boundary.
- */
-#define PCIBR_NO_ATE_ROUNDUP    0x00008000
-#define PCIBR_WRITE_GATHER	0x00010000	/* please use PCIIO version */
-#define PCIBR_NOWRITE_GATHER	0x00020000	/* please use PCIIO version */
-#define PCIBR_PREFETCH		0x00040000	/* please use PCIIO version */
-#define PCIBR_NOPREFETCH	0x00080000	/* please use PCIIO version */
-#define PCIBR_PRECISE		0x00100000
-#define PCIBR_NOPRECISE		0x00200000
-#define PCIBR_BARRIER		0x00400000
-#define PCIBR_NOBARRIER		0x00800000
-#define PCIBR_VCHAN0		0x01000000
-#define PCIBR_VCHAN1		0x02000000
-#define PCIBR_64BIT		0x04000000
-#define PCIBR_NO64BIT		0x08000000
-#define PCIBR_SWAP		0x10000000
-#define PCIBR_NOSWAP		0x20000000
-
-#define	PCIBR_EXTERNAL_ATES	0x40000000	/* uses external ATEs */
-#define	PCIBR_ACTIVE		0x80000000	/* need a "done" */
-
-/* Flags that have meaning to pcibr_device_flags_{set,clear} */
-#define PCIBR_DEVICE_FLAGS (	\
-	PCIBR_WRITE_GATHER	|\
-	PCIBR_NOWRITE_GATHER	|\
-	PCIBR_PREFETCH		|\
-	PCIBR_NOPREFETCH	|\
-	PCIBR_PRECISE		|\
-	PCIBR_NOPRECISE		|\
-	PCIBR_BARRIER		|\
-	PCIBR_NOBARRIER		\
-)
-
-/* Flags that have meaning to *_dmamap_alloc, *_dmatrans_{addr,list} */
-#define PCIBR_DMA_FLAGS (	\
-	PCIBR_PREFETCH		|\
-	PCIBR_NOPREFETCH	|\
-	PCIBR_PRECISE		|\
-	PCIBR_NOPRECISE		|\
-	PCIBR_BARRIER		|\
-	PCIBR_NOBARRIER		|\
-	PCIBR_VCHAN0		|\
-	PCIBR_VCHAN1		\
-)
-
-typedef int		pcibr_device_flags_t;
-
-#define MINIMAL_ATES_REQUIRED(addr, size) \
-	(IOPG(IOPGOFF(addr) + (size) - 1) == IOPG((size) - 1))
-
-#define MINIMAL_ATE_FLAG(addr, size) \
-	(MINIMAL_ATES_REQUIRED((u_long)addr, size) ? PCIBR_NO_ATE_ROUNDUP : 0)
-
-/*
- * Set bits in the Bridge Device(x) register for this device.
- * "flags" are defined above. NOTE: this includes turning
- * things *OFF* as well as turning them *ON* ...
- */
-extern int		pcibr_device_flags_set(vertex_hdl_t dev,
-					     pcibr_device_flags_t flags);
-
-/*
- * Allocate Read Response Buffers for use by the specified device.
- * count_vchan0 is the total number of buffers desired for the
- * "normal" channel.  count_vchan1 is the total number of buffers
- * desired for the "virtual" channel.  Returns 0 on success, or
- * <0 on failure, which occurs when we're unable to allocate any
- * buffers to a channel that desires at least one buffer.
- */
-extern int		pcibr_rrb_alloc(vertex_hdl_t pconn_vhdl,
-					int *count_vchan0,
-					int *count_vchan1);
-
-/*
- * Get the starting PCIbus address out of the given DMA map.
- * This function is supposed to be used by a close friend of PCI bridge
- * since it relies on the fact that the starting address of the map is fixed at
- * the allocation time in the current implementation of PCI bridge.
- */
-extern iopaddr_t	pcibr_dmamap_pciaddr_get(pcibr_dmamap_t);
-extern void		pcibr_hints_fix_rrbs(vertex_hdl_t);
-extern void		pcibr_hints_dualslot(vertex_hdl_t, pciio_slot_t, pciio_slot_t);
-extern void		pcibr_hints_subdevs(vertex_hdl_t, pciio_slot_t, ulong);
-extern void		pcibr_hints_handsoff(vertex_hdl_t);
-
-typedef unsigned	pcibr_intr_bits_f(pciio_info_t, pciio_intr_line_t, int);
-extern void		pcibr_hints_intr_bits(vertex_hdl_t, pcibr_intr_bits_f *);
-
-extern int		pcibr_asic_rev(vertex_hdl_t);
-
-#endif 	/* __ASSEMBLY__ */
-#endif	/* #if defined(__KERNEL__) */
-/* 
- * Some useful ioctls into the pcibr driver
- */
-#define PCIBR			'p'
-#define _PCIBR(x)		((PCIBR << 8) | (x))
-
-/*
- * Bit defintions for variable slot_status in struct
- * pcibr_soft_slot_s.  They are here so that the user
- * hot-plug utility can interpret the slot's power
- * status.
- */
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-#define PCI_SLOT_ENABLE_CMPLT       0x01    
-#define PCI_SLOT_ENABLE_INCMPLT     0x02    
-#define PCI_SLOT_DISABLE_CMPLT      0x04    
-#define PCI_SLOT_DISABLE_INCMPLT    0x08    
-#define PCI_SLOT_POWER_ON           0x10    
-#define PCI_SLOT_POWER_OFF          0x20    
-#define PCI_SLOT_IS_SYS_CRITICAL    0x40    
-#define PCI_SLOT_PCIBA_LOADED       0x80    
-
-#define PCI_SLOT_STATUS_MASK        (PCI_SLOT_ENABLE_CMPLT | \
-				     PCI_SLOT_ENABLE_INCMPLT | \
-                                     PCI_SLOT_DISABLE_CMPLT | \
-				     PCI_SLOT_DISABLE_INCMPLT)
-#define PCI_SLOT_POWER_MASK         (PCI_SLOT_POWER_ON | PCI_SLOT_POWER_OFF)
-
-/*
- * Bit defintions for variable slot_status in struct
- * pcibr_soft_slot_s.  They are here so that both
- * the pcibr driver and the pciconfig command can
- * reference them.
- */
-#define SLOT_STARTUP_CMPLT      0x01
-#define SLOT_STARTUP_INCMPLT    0x02
-#define SLOT_SHUTDOWN_CMPLT     0x04
-#define SLOT_SHUTDOWN_INCMPLT   0x08
-#define SLOT_POWER_UP           0x10
-#define SLOT_POWER_DOWN         0x20
-#define SLOT_IS_SYS_CRITICAL    0x40
-
-#define SLOT_STATUS_MASK        (SLOT_STARTUP_CMPLT | SLOT_STARTUP_INCMPLT | \
-                                 SLOT_SHUTDOWN_CMPLT | SLOT_SHUTDOWN_INCMPLT)
-#define SLOT_POWER_MASK         (SLOT_POWER_UP | SLOT_POWER_DOWN)
-
-/*
- * Bit definitions for variable resp_f_staus.
- * They are here so that both the pcibr driver
- * and the pciconfig command can reference them.
- */
-#define FUNC_IS_VALID           0x01
-#define FUNC_IS_SYS_CRITICAL    0x02
-
-/*
- * L1 slot power operations for PCI hot-plug
- */
-#define PCI_REQ_SLOT_POWER_ON       1
-#define PCI_L1_QSIZE                128      /* our L1 message buffer size */
-
-
-#define L1_QSIZE                128      /* our L1 message buffer size */
-
-enum pcibr_slot_disable_action_e {
-    PCI_REQ_SLOT_ELIGIBLE,
-    PCI_REQ_SLOT_DISABLE
-};
-
-
-struct pcibr_slot_up_resp_s {
-    int                     resp_sub_errno;
-    char                    resp_l1_msg[L1_QSIZE + 1];
-};
-
-struct pcibr_slot_down_resp_s {
-    int                     resp_sub_errno;
-    char                    resp_l1_msg[L1_QSIZE + 1];
-};
-
-struct pcibr_slot_info_resp_s {
-    short		    resp_bs_bridge_type;
-    short		    resp_bs_bridge_mode;
-    int                     resp_has_host;
-    char                    resp_host_slot;
-    vertex_hdl_t            resp_slot_conn;
-    char                    resp_slot_conn_name[MAXDEVNAME];
-    int                     resp_slot_status;
-    int                     resp_l1_bus_num;
-    int                     resp_bss_ninfo;
-    char                    resp_bss_devio_bssd_space[16];
-    iopaddr_t               resp_bss_devio_bssd_base; 
-    uint64_t		    resp_bss_device;
-    int                     resp_bss_pmu_uctr;
-    int                     resp_bss_d32_uctr;
-    int                     resp_bss_d64_uctr;
-    iopaddr_t               resp_bss_d64_base;
-    unsigned                resp_bss_d64_flags;
-    iopaddr_t               resp_bss_d32_base;
-    unsigned                resp_bss_d32_flags;
-    volatile unsigned      *resp_bss_cmd_pointer;
-    unsigned                resp_bss_cmd_shadow;
-    int                     resp_bs_rrb_valid;
-    int                     resp_bs_rrb_valid_v1;
-    int                     resp_bs_rrb_valid_v2;
-    int                     resp_bs_rrb_valid_v3;
-    int                     resp_bs_rrb_res;
-    uint64_t		    resp_b_resp;
-    uint64_t		    resp_b_int_device;
-    uint64_t		    resp_b_int_enable;
-    uint64_t		    resp_b_int_host;
-    struct pcibr_slot_func_info_resp_s {
-        int                     resp_f_status;
-        char                    resp_f_slot_name[MAXDEVNAME];
-        char                    resp_f_bus;
-        char                    resp_f_slot;
-        char                    resp_f_func;
-        char                    resp_f_master_name[MAXDEVNAME];
-        void                   *resp_f_pops;
-        error_handler_f        *resp_f_efunc;
-        error_handler_arg_t     resp_f_einfo;
-        int                     resp_f_vendor;
-        int                     resp_f_device;
-
-        struct {
-            char                    resp_w_space[16];
-            iopaddr_t               resp_w_base;
-            size_t                  resp_w_size;
-        } resp_f_window[6];
-
-        unsigned                resp_f_rbase;
-        unsigned                resp_f_rsize;
-        int                     resp_f_ibit[4];
-        int                     resp_f_att_det_error;
-
-    } resp_func[8];
-};
-
-struct pcibr_slot_req_s {
-    int                      req_slot;
-    union {
-        enum pcibr_slot_disable_action_e up;
-        struct pcibr_slot_down_resp_s *down;
-        struct pcibr_slot_info_resp_s *query;
-        void                    *any;
-    }                       req_respp;
-    int                     req_size;
-};
-
-struct pcibr_slot_enable_resp_s {
-    int                     resp_sub_errno;
-    char                    resp_l1_msg[PCI_L1_QSIZE + 1];
-};
-
-struct pcibr_slot_disable_resp_s {
-    int                     resp_sub_errno;
-    char                    resp_l1_msg[PCI_L1_QSIZE + 1];
-};
-
-struct pcibr_slot_enable_req_s {
-    pciio_slot_t              	     req_device;
-    struct pcibr_slot_enable_resp_s  req_resp;
-};
-
-struct pcibr_slot_disable_req_s {
-    pciio_slot_t                     req_device;
-    enum pcibr_slot_disable_action_e req_action;
-    struct pcibr_slot_disable_resp_s req_resp;
-};
-
-struct pcibr_slot_info_req_s {
-    pciio_slot_t              	     req_device;
-    struct pcibr_slot_info_resp_s    req_resp;
-};
-
-#endif	/* CONFIG_HOTPLUG_PCI_SGI */
-
-
-/*
- * PCI specific errors, interpreted by pciconfig command
- */
-
-/* EPERM                          1    */
-#define PCI_SLOT_ALREADY_UP       2     /* slot already up */
-#define PCI_SLOT_ALREADY_DOWN     3     /* slot already down */
-#define PCI_IS_SYS_CRITICAL       4     /* slot is system critical */
-/* EIO                            5    */
-/* ENXIO                          6    */
-#define PCI_L1_ERR                7     /* L1 console command error */
-#define PCI_NOT_A_BRIDGE          8     /* device is not a bridge */
-#define PCI_SLOT_IN_SHOEHORN      9     /* slot is in a shorhorn */
-#define PCI_NOT_A_SLOT           10     /* slot is invalid */
-#define PCI_RESP_AREA_TOO_SMALL  11     /* slot is invalid */
-/* ENOMEM                        12    */
-#define PCI_NO_DRIVER            13     /* no driver for device */
-/* EFAULT                        14    */
-#define PCI_EMPTY_33MHZ          15     /* empty 33 MHz bus */
-/* EBUSY                         16    */
-#define PCI_SLOT_RESET_ERR       17     /* slot reset error */
-#define PCI_SLOT_INFO_INIT_ERR   18     /* slot info init error */
-/* ENODEV                        19    */
-#define PCI_SLOT_ADDR_INIT_ERR   20     /* slot addr space init error */
-#define PCI_SLOT_DEV_INIT_ERR    21     /* slot device init error */
-/* EINVAL                        22    */
-#define PCI_SLOT_GUEST_INIT_ERR  23     /* slot guest info init error */
-#define PCI_SLOT_RRB_ALLOC_ERR   24     /* slot initial rrb alloc error */
-#define PCI_SLOT_DRV_ATTACH_ERR  25     /* driver attach error */
-#define PCI_SLOT_DRV_DETACH_ERR  26     /* driver detach error */
-/* EFBIG                         27    */
-#define PCI_MULTI_FUNC_ERR       28     /* multi-function card error */
-#define PCI_SLOT_RBAR_ALLOC_ERR  29     /* slot PCI-X RBAR alloc error */
-/* ERANGE                        34    */
-/* EUNATCH                       42    */
-
-#endif				/* _ASM_IA64_SN_PCI_PCIBR_H */
diff -Nru a/include/asm-ia64/sn/pci/pcibr_private.h b/include/asm-ia64/sn/pci/pcibr_private.h
--- a/include/asm-ia64/sn/pci/pcibr_private.h	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,811 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PCI_PCIBR_PRIVATE_H
-#define _ASM_IA64_SN_PCI_PCIBR_PRIVATE_H
-
-/*
- * pcibr_private.h -- private definitions for pcibr
- * only the pcibr driver (and its closest friends)
- * should ever peek into this file.
- */
-
-#include <linux/pci.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pciio_private.h>
-
-/*
- * convenience typedefs
- */
-
-typedef uint64_t pcibr_DMattr_t;
-typedef uint32_t pcibr_ATEattr_t;
-
-typedef struct pcibr_info_s *pcibr_info_t, **pcibr_info_h;
-typedef struct pcibr_soft_s *pcibr_soft_t;
-typedef struct pcibr_soft_slot_s *pcibr_soft_slot_t;
-typedef struct pcibr_hints_s *pcibr_hints_t;
-typedef struct pcibr_intr_list_s *pcibr_intr_list_t;
-typedef struct pcibr_intr_wrap_s *pcibr_intr_wrap_t;
-typedef struct pcibr_intr_cbuf_s *pcibr_intr_cbuf_t;
-
-typedef volatile unsigned int *cfg_p;
-typedef volatile bridgereg_t *reg_p;
-
-/*
- * extern functions
- */
-cfg_p pcibr_slot_config_addr(pcibr_soft_t, pciio_slot_t, int);
-cfg_p pcibr_func_config_addr(pcibr_soft_t, pciio_bus_t bus, pciio_slot_t, pciio_function_t, int);
-void pcibr_debug(uint32_t, vertex_hdl_t, char *, ...);
-void pcibr_func_config_set(pcibr_soft_t, pciio_slot_t, pciio_function_t, int, unsigned);
-/*
- * pcireg_ externs
- */
-
-extern uint64_t		pcireg_id_get(pcibr_soft_t);
-extern uint64_t		pcireg_bridge_id_get(void *);
-extern uint64_t		pcireg_bus_err_get(pcibr_soft_t);
-extern uint64_t		pcireg_control_get(pcibr_soft_t);
-extern uint64_t		pcireg_bridge_control_get(void *);
-extern void		pcireg_control_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_control_bit_clr(pcibr_soft_t, uint64_t);
-extern void		pcireg_control_bit_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_req_timeout_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_intr_dst_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_intr_dst_target_id_get(pcibr_soft_t);
-extern void		pcireg_intr_dst_target_id_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_intr_dst_addr_get(pcibr_soft_t);
-extern void		pcireg_intr_dst_addr_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_cmdword_err_get(pcibr_soft_t);
-extern uint64_t		pcireg_llp_cfg_get(pcibr_soft_t);
-extern void		pcireg_llp_cfg_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_tflush_get(pcibr_soft_t);
-extern uint64_t		pcireg_linkside_err_get(pcibr_soft_t);
-extern uint64_t		pcireg_resp_err_get(pcibr_soft_t);
-extern uint64_t		pcireg_resp_err_addr_get(pcibr_soft_t);
-extern uint64_t		pcireg_resp_err_buf_get(pcibr_soft_t);
-extern uint64_t		pcireg_resp_err_dev_get(pcibr_soft_t);
-extern uint64_t		pcireg_linkside_err_addr_get(pcibr_soft_t);
-extern uint64_t		pcireg_dirmap_get(pcibr_soft_t);
-extern void		pcireg_dirmap_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_dirmap_wid_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_dirmap_diroff_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_dirmap_add512_set(pcibr_soft_t);
-extern void		pcireg_dirmap_add512_clr(pcibr_soft_t);
-extern uint64_t		pcireg_map_fault_get(pcibr_soft_t);
-extern uint64_t		pcireg_arbitration_get(pcibr_soft_t);
-extern void		pcireg_arbitration_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_arbitration_bit_clr(pcibr_soft_t, uint64_t);
-extern void		pcireg_arbitration_bit_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_parity_err_get(pcibr_soft_t);
-extern uint64_t		pcireg_type1_cntr_get(pcibr_soft_t);
-extern void		pcireg_type1_cntr_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_timeout_get(pcibr_soft_t);
-extern void		pcireg_timeout_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_timeout_bit_clr(pcibr_soft_t, uint64_t);
-extern void		pcireg_timeout_bit_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_pci_bus_addr_get(pcibr_soft_t);
-extern uint64_t		pcireg_pci_bus_addr_addr_get(pcibr_soft_t);
-extern uint64_t		pcireg_intr_status_get(pcibr_soft_t);
-extern uint64_t		pcireg_intr_enable_get(pcibr_soft_t);
-extern void		pcireg_intr_enable_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_intr_enable_bit_clr(pcibr_soft_t, uint64_t);
-extern void		pcireg_intr_enable_bit_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_intr_reset_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_intr_reset_bit_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_intr_mode_get(pcibr_soft_t);
-extern void		pcireg_intr_mode_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_intr_mode_bit_clr(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_intr_device_get(pcibr_soft_t);
-extern void		pcireg_intr_device_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_intr_device_bit_set(pcibr_soft_t, uint64_t);
-extern void		pcireg_bridge_intr_device_bit_set(void *, uint64_t);
-extern void		pcireg_intr_device_bit_clr(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_intr_host_err_get(pcibr_soft_t);
-extern void		pcireg_intr_host_err_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_intr_addr_get(pcibr_soft_t, int);
-extern void		pcireg_intr_addr_set(pcibr_soft_t, int, uint64_t);
-extern void		pcireg_bridge_intr_addr_set(void *, int, uint64_t);
-extern void *		pcireg_intr_addr_addr(pcibr_soft_t, int);
-extern void		pcireg_intr_addr_vect_set(pcibr_soft_t, int, uint64_t);
-extern void		pcireg_bridge_intr_addr_vect_set(void *, int, uint64_t);
-extern uint64_t		pcireg_intr_addr_addr_get(pcibr_soft_t, int);
-extern void		pcireg_intr_addr_addr_set(pcibr_soft_t, int, uint64_t);
-extern void		pcireg_bridge_intr_addr_addr_set(void *, int, uint64_t);
-extern uint64_t		pcireg_intr_view_get(pcibr_soft_t);
-extern uint64_t		pcireg_intr_multiple_get(pcibr_soft_t);
-extern void		pcireg_force_always_set(pcibr_soft_t, int);
-extern void *		pcireg_bridge_force_always_addr_get(void *, int);
-extern void *		pcireg_force_always_addr_get(pcibr_soft_t, int);
-extern void		pcireg_force_intr_set(pcibr_soft_t, int);
-extern uint64_t		pcireg_device_get(pcibr_soft_t, int);
-extern void		pcireg_device_set(pcibr_soft_t, int, uint64_t);
-extern void		pcireg_device_bit_set(pcibr_soft_t, int, uint64_t);
-extern void		pcireg_device_bit_clr(pcibr_soft_t, int, uint64_t);
-extern uint64_t		pcireg_rrb_get(pcibr_soft_t, int);
-extern void		pcireg_rrb_set(pcibr_soft_t, int, uint64_t);
-extern void		pcireg_rrb_bit_set(pcibr_soft_t, int, uint64_t);
-extern void		pcireg_rrb_bit_clr(pcibr_soft_t, int, uint64_t);
-extern uint64_t		pcireg_rrb_status_get(pcibr_soft_t);
-extern void		pcireg_rrb_clear_set(pcibr_soft_t, uint64_t);
-extern uint64_t		pcireg_wrb_flush_get(pcibr_soft_t, int);
-extern uint64_t		pcireg_pcix_bus_err_addr_get(pcibr_soft_t);
-extern uint64_t		pcireg_pcix_bus_err_attr_get(pcibr_soft_t);
-extern uint64_t		pcireg_pcix_bus_err_data_get(pcibr_soft_t);
-extern uint64_t		pcireg_pcix_req_err_attr_get(pcibr_soft_t);
-extern uint64_t		pcireg_pcix_req_err_addr_get(pcibr_soft_t);
-extern uint64_t		pcireg_pcix_pio_split_addr_get(pcibr_soft_t);
-extern uint64_t		pcireg_pcix_pio_split_attr_get(pcibr_soft_t);
-extern cfg_p		pcireg_type1_cfg_addr(pcibr_soft_t, pciio_function_t,
-					      int);
-extern cfg_p		pcireg_type0_cfg_addr(pcibr_soft_t, pciio_slot_t,
-					      pciio_function_t, int);
-extern bridge_ate_t	pcireg_int_ate_get(pcibr_soft_t, int);
-extern void		pcireg_int_ate_set(pcibr_soft_t, int, bridge_ate_t);
-extern bridge_ate_p	pcireg_int_ate_addr(pcibr_soft_t, int);
-
-extern uint64_t		pcireg_speed_get(pcibr_soft_t);
-extern uint64_t		pcireg_mode_get(pcibr_soft_t);
-
-/*
- * PCIBR_DEBUG() macro and debug bitmask defines
- */
-/* low freqency debug events (ie. initialization, resource allocation,...) */
-#define PCIBR_DEBUG_INIT	0x00000001  /* bridge init */
-#define PCIBR_DEBUG_HINTS	0x00000002  /* bridge hints */
-#define PCIBR_DEBUG_ATTACH	0x00000004  /* bridge attach */
-#define PCIBR_DEBUG_DETACH	0x00000008  /* bridge detach */
-#define PCIBR_DEBUG_ATE		0x00000010  /* bridge ATE allocation */
-#define PCIBR_DEBUG_RRB		0x00000020  /* bridge RRB allocation */
-#define PCIBR_DEBUG_RBAR	0x00000040  /* bridge RBAR allocation */
-#define PCIBR_DEBUG_PROBE	0x00000080  /* bridge device probing */
-#define PCIBR_DEBUG_INTR_ERROR  0x00000100  /* bridge error interrupt */
-#define PCIBR_DEBUG_ERROR_HDLR  0x00000200  /* bridge error handler */
-#define PCIBR_DEBUG_CONFIG	0x00000400  /* device's config space */
-#define PCIBR_DEBUG_BAR		0x00000800  /* device's BAR allocations */
-#define PCIBR_DEBUG_INTR_ALLOC	0x00001000  /* device's intr allocation */
-#define PCIBR_DEBUG_DEV_ATTACH	0x00002000  /* device's attach */
-#define PCIBR_DEBUG_DEV_DETACH	0x00004000  /* device's detach */
-#define PCIBR_DEBUG_HOTPLUG	0x00008000
-
-/* high freqency debug events (ie. map allocation, direct translation,...) */
-#define PCIBR_DEBUG_DEVREG	0x04000000  /* bridges device reg sets */
-#define PCIBR_DEBUG_PIOMAP	0x08000000  /* pcibr_piomap */
-#define PCIBR_DEBUG_PIODIR	0x10000000  /* pcibr_piotrans */
-#define PCIBR_DEBUG_DMAMAP	0x20000000  /* pcibr_dmamap */
-#define PCIBR_DEBUG_DMADIR	0x40000000  /* pcibr_dmatrans */
-#define PCIBR_DEBUG_INTR	0x80000000  /* interrupts */
-
-extern char	 *pcibr_debug_module;
-extern int	  pcibr_debug_widget;
-extern int	  pcibr_debug_slot;
-extern uint32_t pcibr_debug_mask;
-
-/* For low frequency events (ie. initialization, resource allocation,...) */
-#define PCIBR_DEBUG_ALWAYS(args) pcibr_debug args ;
-
-/* XXX: habeck: maybe make PCIBR_DEBUG() always available?  Even in non-
- * debug kernels?  If tracing isn't enabled (i.e pcibr_debug_mask isn't
- * set, then the overhead for this macro is just an extra 'if' check.
- */
-/* For high frequency events (ie. map allocation, direct translation,...) */
-#if DEBUG
-#define PCIBR_DEBUG(args) PCIBR_DEBUG_ALWAYS(args)
-#else	/* DEBUG */
-#define PCIBR_DEBUG(args)
-#endif	/* DEBUG */
-
-/*
- * Bridge sets up PIO using this information.
- */
-struct pcibr_piomap_s {
-    struct pciio_piomap_s   bp_pp;	/* generic stuff */
-
-#define	bp_flags	bp_pp.pp_flags	/* PCIBR_PIOMAP flags */
-#define	bp_dev		bp_pp.pp_dev	/* associated pci card */
-#define	bp_slot		bp_pp.pp_slot	/* which slot the card is in */
-#define	bp_space	bp_pp.pp_space	/* which address space */
-#define	bp_pciaddr	bp_pp.pp_pciaddr	/* starting offset of mapping */
-#define	bp_mapsz	bp_pp.pp_mapsz	/* size of this mapping */
-#define	bp_kvaddr	bp_pp.pp_kvaddr	/* kernel virtual address to use */
-
-    iopaddr_t               bp_xtalk_addr;	/* corresponding xtalk address */
-    xtalk_piomap_t          bp_xtalk_pio;	/* corresponding xtalk resource */
-    pcibr_piomap_t	    bp_next;	/* Next piomap on the list */
-    pcibr_soft_t	    bp_soft;	/* backpointer to bridge soft data */
-    atomic_t		    bp_toc;	/* PCI timeout counter */
-
-};
-
-/*
- * Bridge sets up DMA using this information.
- */
-struct pcibr_dmamap_s {
-    struct pciio_dmamap_s   bd_pd;
-#define	bd_flags	bd_pd.pd_flags	/* PCIBR_DMAMAP flags */
-#define	bd_dev		bd_pd.pd_dev	/* associated pci card */
-#define	bd_slot		bd_pd.pd_slot	/* which slot the card is in */
-    struct pcibr_soft_s    *bd_soft;	/* pcibr soft state backptr */
-    xtalk_dmamap_t          bd_xtalk;	/* associated xtalk resources */
-
-    size_t                  bd_max_size;	/* maximum size of mapping */
-    xwidgetnum_t            bd_xio_port;	/* target XIO port */
-    iopaddr_t               bd_xio_addr;	/* target XIO address */
-    iopaddr_t               bd_pci_addr;	/* via PCI address */
-
-    int                     bd_ate_index;	/* Address Translation Entry Index */
-    int                     bd_ate_count;	/* number of ATE's allocated */
-    bridge_ate_p            bd_ate_ptr;		/* where to write first ATE */
-    bridge_ate_t            bd_ate_proto;	/* prototype ATE (for xioaddr=0) */
-    bridge_ate_t            bd_ate_prime;	/* value of 1st ATE written */
-    dma_addr_t		    bd_dma_addr;	/* Linux dma handle */
-    struct resource	    resource;
-};
-
-#define	IBUFSIZE	5		/* size of circular buffer (holds 4) */
-
-/*
- * Circular buffer used for interrupt processing
- */
-struct pcibr_intr_cbuf_s {
-    spinlock_t		ib_lock;		/* cbuf 'put' lock */
-    int			ib_in;			/* index of next free entry */
-    int			ib_out;			/* index of next full entry */
-    pcibr_intr_wrap_t   ib_cbuf[IBUFSIZE];	/* circular buffer of wrap  */
-};
-
-/*
- * Bridge sets up interrupts using this information.
- */
-
-struct pcibr_intr_s {
-    struct pciio_intr_s     bi_pi;
-#define	bi_flags	bi_pi.pi_flags	/* PCIBR_INTR flags */
-#define	bi_dev		bi_pi.pi_dev	/* associated pci card */
-#define	bi_lines	bi_pi.pi_lines	/* which PCI interrupt line(s) */
-#define	bi_func		bi_pi.pi_func	/* handler function (when connected) */
-#define	bi_arg		bi_pi.pi_arg	/* handler parameter (when connected) */
-#define bi_mustruncpu	bi_pi.pi_mustruncpu /* Where we must run. */
-#define bi_irq		bi_pi.pi_irq	/* IRQ assigned. */
-#define bi_cpu		bi_pi.pi_cpu	/* cpu assigned. */
-    unsigned int                bi_ibits;	/* which Bridge interrupt bit(s) */
-    pcibr_soft_t            bi_soft;	/* shortcut to soft info */
-    struct pcibr_intr_cbuf_s bi_ibuf;	/* circular buffer of wrap ptrs */
-    unsigned		bi_last_intr;	/* For Shub lb lost intr. bug */
-};
-
-
-/* 
- * PCIBR_INFO_SLOT_GET_EXT returns the external slot number that the card
- * resides in.  (i.e the slot number silk screened on the back of the I/O 
- * brick).  PCIBR_INFO_SLOT_GET_INT returns the internal slot (or device)
- * number used by the pcibr code to represent that external slot (i.e to 
- * set bit patterns in BRIDGE/PIC registers to represent the device, or to
- * offset into an array, or ...).
- *
- * In BRIDGE and XBRIDGE the external slot and internal device numbering 
- * are the same.  (0->0, 1->1, 2->2,... 7->7)  BUT in the PIC the external
- * slot number is always 1 greater than the internal device number (1->0, 
- * 2->1, 3->2, 4->3).  This is due to the fact that the PCI-X spec requires
- * that the 'bridge' (i.e PIC) be designated as 'device 0', thus external
- * slot numbering can't start at zero.
- *
- * PCIBR_DEVICE_TO_SLOT converts an internal device number to an external
- * slot number.  NOTE: PCIIO_SLOT_NONE stays as PCIIO_SLOT_NONE.
- *
- * PCIBR_SLOT_TO_DEVICE converts an external slot number to an internal
- * device number.  NOTE: PCIIO_SLOT_NONE stays as PCIIO_SLOT_NONE.
- */
-#define PCIBR_INFO_SLOT_GET_EXT(info)	    (((pcibr_info_t)info)->f_slot)
-#define PCIBR_INFO_SLOT_GET_INT(info)	    (((pcibr_info_t)info)->f_dev)
-
-#define PCIBR_DEVICE_TO_SLOT(pcibr_soft, dev_num) \
-	(((dev_num) != PCIIO_SLOT_NONE) ? ((dev_num) + 1) : PCIIO_SLOT_NONE)
-
-#define PCIBR_SLOT_TO_DEVICE(pcibr_soft, slot) \
-        (((slot) != PCIIO_SLOT_NONE) ? ((slot) - 1) : PCIIO_SLOT_NONE)
-
-/*
- * per-connect point pcibr data, including standard pciio data in-line:
- */
-struct pcibr_info_s {
-    struct pciio_info_s	    f_c;	/* MUST BE FIRST. */
-#define	f_vertex	f_c.c_vertex	/* back pointer to vertex */
-#define	f_bus		f_c.c_bus	/* which bus the card is in */
-#define	f_slot		f_c.c_slot	/* which slot the card is in */
-#define	f_func		f_c.c_func	/* which func (on multi-func cards) */
-#define	f_vendor	f_c.c_vendor	/* PCI card "vendor" code */
-#define	f_device	f_c.c_device	/* PCI card "device" code */
-#define	f_master	f_c.c_master	/* PCI bus provider */
-#define	f_mfast		f_c.c_mfast	/* cached fastinfo from c_master */
-#define	f_pops		f_c.c_pops	/* cached provider from c_master */
-#define	f_efunc		f_c.c_efunc	/* error handling function */
-#define	f_einfo		f_c.c_einfo	/* first parameter for efunc */
-#define	f_window	f_c.c_window	/* state of BASE regs */
-#define	f_rwindow	f_c.c_rwindow	/* expansion ROM BASE regs */
-#define	f_rbase		f_c.c_rbase	/* expansion ROM base */
-#define	f_rsize		f_c.c_rsize	/* expansion ROM size */
-#define	f_piospace	f_c.c_piospace	/* additional I/O spaces allocated */
-
-    /* pcibr-specific connection state */
-    int			    f_ibit[4];	/* Bridge bit for each INTx */
-    pcibr_piomap_t	    f_piomap;
-    int                     f_att_det_error;
-    pciio_slot_t	    f_dev;	/* which device the card represents */
-    cap_pcix_type0_t	   *f_pcix_cap;	/* pointer to the pcix capability */
-};
-
-/* =====================================================================
- *          Shared Interrupt Information
- */
-
-struct pcibr_intr_list_s {
-    pcibr_intr_list_t       il_next;
-    pcibr_intr_t            il_intr;
-    pcibr_soft_t	    il_soft;
-    pciio_slot_t	    il_slot;
-};
-
-/* =====================================================================
- *          Interrupt Wrapper Data
- */
-struct pcibr_intr_wrap_s {
-    pcibr_soft_t            iw_soft;	/* which bridge */
-    volatile bridgereg_t   *iw_stat;	/* ptr to b_int_status */
-    bridgereg_t             iw_ibit;	/* bit in b_int_status */
-    pcibr_intr_list_t       iw_list;	/* ghostbusters! */
-    int			    iw_hdlrcnt;	/* running handler count */
-    int			    iw_shared;  /* if Bridge bit is shared */
-    int			    iw_connected; /* if already connected */
-};
-
-#define	PCIBR_ISR_ERR_START		8
-#define PCIBR_ISR_MAX_ERRS_BRIDGE 	32
-#define PCIBR_ISR_MAX_ERRS_PIC		45
-#define PCIBR_ISR_MAX_ERRS	PCIBR_ISR_MAX_ERRS_PIC
-
-/*
- * PCI Base Address Register window allocation constants.
- * To reduce the size of the internal resource mapping structures, do
- * not use the entire PCI bus I/O address space
- */ 
-#define PCIBR_BUS_IO_BASE      0x200000
-#define PCIBR_BUS_IO_MAX       0x0FFFFFFF
-#define PCIBR_BUS_IO_PAGE      0x100000
-
-#define PCIBR_BUS_SWIN_BASE    PAGE_SIZE
-#define PCIBR_BUS_SWIN_MAX     0x000FFFFF
-#define PCIBR_BUS_SWIN_PAGE    PAGE_SIZE
-
-#define PCIBR_BUS_MEM_BASE     0x200000
-#define PCIBR_BUS_MEM_MAX      0x3FFFFFFF
-#define PCIBR_BUS_MEM_PAGE     0x100000
-
-/* defines for pcibr_soft_s->bs_bridge_type */
-#define PCIBR_BRIDGETYPE_PIC		2
-#define IS_PIC_BUSNUM_SOFT(ps, bus)	((ps)->bs_busnum == (bus))
-
-/*
- * Runtime checks for workarounds.
- */
-#define PCIBR_WAR_ENABLED(pv, pcibr_soft) \
-	((1 << XWIDGET_PART_REV_NUM_REV(pcibr_soft->bs_rev_num)) & pv)
-
-/* defines for pcibr_soft_s->bs_bridge_mode */
-#define PCIBR_BRIDGEMODE_PCI_33		0x0
-#define PCIBR_BRIDGEMODE_PCI_66		0x2
-#define PCIBR_BRIDGEMODE_PCIX_66	0x3
-#define PCIBR_BRIDGEMODE_PCIX_100	0x5
-#define PCIBR_BRIDGEMODE_PCIX_133	0x7
-#define BUSSPEED_MASK			0x6
-#define BUSTYPE_MASK			0x1
-
-#define IS_PCI(ps)	(!IS_PCIX(ps))
-#define IS_PCIX(ps)	((ps)->bs_bridge_mode & BUSTYPE_MASK)
-
-#define IS_33MHZ(ps)	((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCI_33)
-#define IS_66MHZ(ps)	(((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCI_66) || \
-			 ((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCIX_66))
-#define IS_100MHZ(ps)	((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCIX_100)
-#define IS_133MHZ(ps)	((ps)->bs_bridge_mode == PCIBR_BRIDGEMODE_PCIX_133)
-
-
-/* Number of PCI slots.   NOTE: this works as long as the first slot
- * is zero.  Otherwise use ((ps->bs_max_slot+1) - ps->bs_min_slot)
- */
-#define PCIBR_NUM_SLOTS(ps) (ps->bs_max_slot+1)
-
-/* =====================================================================
- *            Bridge Device State structure
- *
- *      one instance of this structure is kept for each
- *      Bridge ASIC in the system.
- */
-
-struct pcibr_soft_s {
-    vertex_hdl_t          bs_conn;		/* xtalk connection point */
-    vertex_hdl_t          bs_vhdl;		/* vertex owned by pcibr */
-    uint64_t                bs_int_enable;	/* Mask of enabled intrs */
-    void               *bs_base;		/* PIO pointer to Bridge chip */
-    char                   *bs_name;		/* hw graph name */
-    char		    bs_asic_name[16];	/* ASIC name */
-    xwidgetnum_t            bs_xid;		/* Bridge's xtalk ID number */
-    vertex_hdl_t          bs_master;		/* xtalk master vertex */
-    xwidgetnum_t            bs_mxid;		/* master's xtalk ID number */
-    pciio_slot_t            bs_first_slot;      /* first existing slot */
-    pciio_slot_t            bs_last_slot;       /* last existing slot */
-    pciio_slot_t            bs_last_reset;      /* last slot to reset */
-    uint32_t		    bs_unused_slot;	/* unavailable slots bitmask */
-    pciio_slot_t	    bs_min_slot;	/* lowest possible slot */
-    pciio_slot_t	    bs_max_slot;	/* highest possible slot */
-    pcibr_soft_t	    bs_peers_soft;	/* PICs other bus's soft */
-    int			    bs_busnum;		/* PIC has two pci busses */
-
-    iopaddr_t               bs_dir_xbase;	/* xtalk address for 32-bit PCI direct map */
-    xwidgetnum_t	    bs_dir_xport;	/* xtalk port for 32-bit PCI direct map */
-
-    struct resource	    bs_int_ate_resource;/* root resource for internal ATEs */
-    struct resource	    bs_ext_ate_resource;/* root resource for external ATEs */
-    void	 	    *bs_allocated_ate_res;/* resource struct allocated */
-    short		    bs_int_ate_size;	/* number of internal ates */
-    short		    bs_bridge_type;	/* see defines above */
-    short		    bs_bridge_mode;	/* see defines above */
-
-    int                     bs_rev_num;	/* revision number of Bridge */
-
-    /* bs_dma_flags are the forced dma flags used on all DMAs. Used for
-     * working around ASIC rev issues and protocol specific requirements
-     */
-    unsigned int            bs_dma_flags;	/* forced DMA flags */
-
-    nasid_t		    bs_nasid;		/* nasid this bus is on */
-    moduleid_t		    bs_moduleid;	/* io brick moduleid */
-    short		    bs_bricktype;	/* io brick type */
-
-    /*
-     * Lock used primarily to get mutual exclusion while managing any
-     * bridge resources..
-     */
-    spinlock_t              bs_lock;
-    
-    vertex_hdl_t	    bs_noslot_conn;	/* NO-SLOT connection point */
-    pcibr_info_t	    bs_noslot_info;
-
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-    /* Linux PCI bus structure pointer */
-    struct pci_bus         *bs_pci_bus;
-#endif
-
-    struct pcibr_soft_slot_s {
-	/* information we keep about each CFG slot */
-
-	/* some devices (ioc3 in non-slotted
-	 * configurations, sometimes) make use
-	 * of more than one REQ/GNT/INT* signal
-	 * sets. The slot corresponding to the
-	 * IDSEL that the device responds to is
-	 * called the host slot; the slot
-	 * numbers that the device is stealing
-	 * REQ/GNT/INT bits from are known as
-	 * the guest slots.
-	 */
-	int                     has_host;
-	pciio_slot_t            host_slot;
-	vertex_hdl_t		slot_conn;
-
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-        /* PCI Hot-Plug status word */
-        int 			slot_status;
-
-	/* PCI Hot-Plug core structure pointer */
-	struct hotplug_slot    *bss_hotplug_slot;
-#endif	/* CONFIG_HOTPLUG_PCI_SGI */
-
-	/* Potentially several connection points
-	 * for this slot. bss_ninfo is how many,
-	 * and bss_infos is a pointer to
-	 * an array pcibr_info_t values (which are
-	 * pointers to pcibr_info structs, stored
-	 * as device_info in connection ponts).
-	 */
-	int			bss_ninfo;
-	pcibr_info_h	        bss_infos;
-
-	/* Temporary Compatibility Macros, for
-	 * stuff that has moved out of bs_slot
-	 * and into the info structure. These
-	 * will go away when their users have
-	 * converted over to multifunction-
-	 * friendly use of bss_{ninfo,infos}.
-	 */
-#define	bss_vendor_id	bss_infos[0]->f_vendor
-#define	bss_device_id	bss_infos[0]->f_device
-#define	bss_window	bss_infos[0]->f_window
-#define	bssw_space	w_space
-#define	bssw_base	w_base
-#define	bssw_size	w_size
-
-	/* Where is DevIO(x) pointing? */
-	/* bssd_space is NONE if it is not assigned. */
-	struct {
-	    pciio_space_t           bssd_space;
-	    iopaddr_t               bssd_base;
-            int                     bssd_ref_cnt;
-	} bss_devio;
-
-	/* Shadow value for Device(x) register,
-	 * so we don't have to go to the chip.
-	 */
-	uint64_t		bss_device;
-
-	/* Number of sets on GBR/REALTIME bit outstanding
-	 * Used by Priority I/O for tracking reservations
-	 */
-	int                     bss_pri_uctr;
-
-	/* Number of "uses" of PMU, 32-bit direct,
-	 * and 64-bit direct DMA (0:none, <0: trans,
-	 * >0: how many dmamaps). Device(x) bits
-	 * controlling attribute of each kind of
-	 * channel can't be changed by dmamap_alloc
-	 * or dmatrans if the controlling counter
-	 * is nonzero. dmatrans is forever.
-	 */
-	int                     bss_pmu_uctr;
-	int                     bss_d32_uctr;
-	int                     bss_d64_uctr;
-
-	/* When the contents of mapping configuration
-	 * information is locked down by dmatrans,
-	 * repeated checks of the same flags should
-	 * be shortcircuited for efficiency.
-	 */
-	iopaddr_t		bss_d64_base;
-	unsigned		bss_d64_flags;
-	iopaddr_t		bss_d32_base;
-	unsigned		bss_d32_flags;
-    } bs_slot[8];
-
-    pcibr_intr_bits_f	       *bs_intr_bits;
-
-    /* PIC PCI-X Read Buffer Management :
-     * bs_pcix_num_funcs: the total number of PCI-X functions
-     *  on the bus
-     * bs_pcix_split_tot: total number of outstanding split
-     *  transactions requested by all functions on the bus
-     * bs_pcix_rbar_percent_allowed: the percentage of the
-     *  total number of buffers a function requested that are 
-     *  available to it, not including the 1 RBAR guaranteed 
-     *  to it.
-     * bs_pcix_rbar_inuse: number of RBARs in use.
-     * bs_pcix_rbar_avail: number of RBARs available.  NOTE:
-     *  this value can go negative if we oversubscribe the 
-     *  RBARs.  (i.e.  We have 16 RBARs but 17 functions).
-     */
-    int			    bs_pcix_num_funcs;
-    int			    bs_pcix_split_tot;
-    int			    bs_pcix_rbar_percent_allowed;
-
-    int			    bs_pcix_rbar_inuse;
-    int			    bs_pcix_rbar_avail;
-
-
-    /* RRB MANAGEMENT
-     * bs_rrb_fixed: bitmap of slots whose RRB
-     *	allocations we should not "automatically" change
-     * bs_rrb_avail: number of RRBs that have not
-     *  been allocated or reserved for {even,odd} slots
-     * bs_rrb_res: number of RRBs currently reserved for the
-     *	use of the index slot number
-     * bs_rrb_res_dflt: number of RRBs reserved at boot
-     *  time for the use of the index slot number
-     * bs_rrb_valid: number of RRBs currently marked valid
-     *	for the indexed slot/vchan number; array[slot][vchan]
-     * bs_rrb_valid_dflt: number of RRBs marked valid at boot
-     *  time for the indexed slot/vchan number; array[slot][vchan]
-     */
-    int                     bs_rrb_fixed;
-    int			    bs_rrb_avail[2];
-    int			    bs_rrb_res[8];
-    int			    bs_rrb_res_dflt[8];
-    int			    bs_rrb_valid[8][4];
-    int			    bs_rrb_valid_dflt[8][4];
-    struct {
-	/* Each Bridge interrupt bit has a single XIO
-	 * interrupt channel allocated.
-	 */
-	xtalk_intr_t            bsi_xtalk_intr;
-	/*
-	 * A wrapper structure is associated with each
-	 * Bridge interrupt bit.
-	 */
-	struct pcibr_intr_wrap_s  bsi_pcibr_intr_wrap;
-	/* The bus and interrupt bit, used for pcibr_setpciint().
-	 * The pci busnum is bit3, int_bits bit2:0
-	 */
-	uint32_t		bsi_int_bit;
-
-    } bs_intr[8];
-
-    xtalk_intr_t		bsi_err_intr;
-
-    /*
-     * We stash away some information in this structure on getting
-     * an error interrupt. This information is used during PIO read/
-     * write error handling.
-     *
-     * As it stands now, we do not re-enable the error interrupt
-     * till the error is resolved. Error resolution happens either at
-     * bus error time for PIO Read errors (~100 microseconds), or at
-     * the scheduled timeout time for PIO write errors (~milliseconds).
-     * If this delay causes problems, we may need to move towards
-     * a different scheme..
-     *
-     * Note that there is no locking while looking at this data structure.
-     * There should not be any race between bus error code and
-     * error interrupt code.. will look into this if needed.
-     *
-     * NOTE: The above discussion of error interrupt processing is
-     *       no longer true. Whether it should again be true, is
-     *       being looked into.
-     */
-    struct br_errintr_info {
-	int                     bserr_toutcnt;
-	iopaddr_t               bserr_addr;	/* Address where error occured */
-	uint64_t		bserr_intstat;	/* interrupts active at error dump */
-    } bs_errinfo;
-
-    /*
-     * PCI Bus Space allocation data structure.
-     *
-     * The resource mapping functions rmalloc() and rmfree() are used
-     * to manage the PCI bus I/O, small window, and memory  address 
-     * spaces.
-     *
-     * This info is used to assign PCI bus space addresses to cards
-     * via their BARs and to the callers of the pcibr_piospace_alloc()
-     * interface.
-     *
-     * Users of the pcibr_piospace_alloc() interface, such as the VME
-     * Universe chip, need PCI bus space that is not acquired by BARs.
-     * Most of these users need "large" amounts of PIO space (typically
-     * in Megabytes), and they generally tend to take once and never
-     * release. 
-     */
-    struct pciio_win_map_s	bs_io_win_map;	/* I/O addr space */
-    struct pciio_win_map_s	bs_swin_map;	/* Small window addr space */
-    struct pciio_win_map_s	bs_mem_win_map;	/* Memory addr space */
-
-    struct resource		bs_io_win_root_resource; /* I/O addr space */
-    struct resource		bs_swin_root_resource; /* Small window addr space */
-    struct resource		bs_mem_win_root_resource; /* Memory addr space */
-
-    int                   bs_bus_addr_status;    /* Bus space status */
-
-#define PCIBR_BUS_ADDR_MEM_FREED       1  /* Reserved PROM mem addr freed */
-#define PCIBR_BUS_ADDR_IO_FREED        2  /* Reserved PROM I/O addr freed */
-
-    struct bs_errintr_stat_s {
-	uint32_t		bs_errcount_total;
-	uint32_t		bs_lasterr_timestamp;
-	uint32_t		bs_lasterr_snapshot;
-    } bs_errintr_stat[PCIBR_ISR_MAX_ERRS];
-
-    /*
-     * Bridge-wide endianness control for
-     * large-window PIO mappings
-     *
-     * These fields are set to PCIIO_BYTE_SWAP
-     * or PCIIO_WORD_VALUES once the swapper
-     * has been configured, one way or the other,
-     * for the direct windows. If they are zero,
-     * nobody has a PIO mapping through that window,
-     * and the swapper can be set either way.
-     */
-    unsigned		bs_pio_end_io;
-    unsigned		bs_pio_end_mem;
-};
-
-#define	PCIBR_ERRTIME_THRESHOLD		(100)
-#define	PCIBR_ERRRATE_THRESHOLD		(100)
-
-/*
- * pcibr will respond to hints dropped in its vertex
- * using the following structure.
- */
-struct pcibr_hints_s {
-    /* ph_host_slot is actually +1 so "0" means "no host" */
-    pciio_slot_t            ph_host_slot[8];	/* REQ/GNT/INT in use by ... */
-    unsigned int            ph_rrb_fixed;	/* do not change RRB allocations */
-    unsigned int            ph_hands_off;	/* prevent further pcibr operations */
-    rrb_alloc_funct_t       rrb_alloc_funct;	/* do dynamic rrb allocation */
-    pcibr_intr_bits_f	   *ph_intr_bits;	/* map PCI INT[ABCD] to Bridge Int(n) */
-};
-
-/*
- * Number of bridge non-fatal error interrupts we can see before
- * we decide to disable that interrupt.
- */
-#define	PCIBR_ERRINTR_DISABLE_LEVEL	10000
-
-/* =====================================================================
- *    Bridge (pcibr) state management functions
- *
- *      pcibr_soft_get is here because we do it in a lot
- *      of places and I want to make sure they all stay
- *      in step with each other.
- *
- *      pcibr_soft_set is here because I want it to be
- *      closely associated with pcibr_soft_get, even
- *      though it is only called in one place.
- */
-
-#define pcibr_soft_get(v)       ((pcibr_soft_t)hwgraph_fastinfo_get((v)))
-#define pcibr_soft_set(v,i)     (hwgraph_fastinfo_set((v), (arbitrary_info_t)(i)))
-
-/*
- * Additional PIO spaces per slot are
- * recorded in this structure.
- */
-struct pciio_piospace_s {
-    pciio_piospace_t        next;	/* another space for this device */
-    char                    free;	/* 1 if free, 0 if in use */
-    pciio_space_t           space;	/* Which space is in use */
-    iopaddr_t               start;	/* Starting address of the PIO space */
-    size_t                  count;	/* size of PIO space */
-};
-
-/* 
- * pcibr_soft structure locking macros
- */
-inline static unsigned long
-pcibr_lock(pcibr_soft_t pcibr_soft)
-{
-        unsigned long flag;
-        spin_lock_irqsave(&pcibr_soft->bs_lock, flag);
-        return(flag);
-}
-#define pcibr_unlock(pcibr_soft, flag)  spin_unlock_irqrestore(&pcibr_soft->bs_lock, flag)
-
-#define PCIBR_VALID_SLOT(ps, s)     (s < PCIBR_NUM_SLOTS(ps))
-#define PCIBR_D64_BASE_UNSET    (0xFFFFFFFFFFFFFFFF)
-#define PCIBR_D32_BASE_UNSET    (0xFFFFFFFF)
-#define INFO_LBL_PCIBR_ASIC_REV "_pcibr_asic_rev"
-
-#define PCIBR_SOFT_LIST 1
-#if PCIBR_SOFT_LIST
-typedef struct pcibr_list_s *pcibr_list_p;
-struct pcibr_list_s {
-    pcibr_list_p            bl_next;
-    pcibr_soft_t            bl_soft;
-    vertex_hdl_t            bl_vhdl;
-};
-#endif /* PCIBR_SOFT_LIST */
-
-/* Devices per widget: 2 buses, 2 slots per bus, 8 functions per slot. */
-#define DEV_PER_WIDGET (2*2*8)
-
-struct sn_flush_device_list {
-	int bus;
-	int slot;
-	int pin;
-	struct bar_list {
-		unsigned long start;
-		unsigned long end;
-	} bar_list[PCI_ROM_RESOURCE];
-	unsigned long force_int_addr;
-	volatile unsigned long flush_addr;
-	spinlock_t flush_lock;
-};
-
-struct sn_flush_nasid_entry  {
-        struct sn_flush_device_list **widget_p;
-        unsigned long        iio_itte[8];
-};
-
-#endif				/* _ASM_SN_PCI_PCIBR_PRIVATE_H */
diff -Nru a/include/asm-ia64/sn/pci/pciio.h b/include/asm-ia64/sn/pci/pciio.h
--- a/include/asm-ia64/sn/pci/pciio.h	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,746 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PCI_PCIIO_H
-#define _ASM_IA64_SN_PCI_PCIIO_H
-
-/*
- * pciio.h -- platform-independent PCI interface
- */
-
-#ifdef __KERNEL__
-#include <linux/ioport.h>
-#include <asm/sn/ioerror.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/hcl.h>
-#else
-#include <linux/ioport.h>
-#include <ioerror.h>
-#include <driver.h>
-#include <hcl.h>
-#endif
-
-#ifndef __ASSEMBLY__
-
-#ifdef __KERNEL__
-#include <asm/sn/dmamap.h>
-#else
-#include <dmamap.h>
-#endif
-
-typedef int pciio_vendor_id_t;
-
-#define PCIIO_VENDOR_ID_NONE	(-1)
-
-typedef int pciio_device_id_t;
-
-#define PCIIO_DEVICE_ID_NONE	(-1)
-
-typedef uint8_t pciio_bus_t;       /* PCI bus number (0..255) */
-typedef uint8_t pciio_slot_t;      /* PCI slot number (0..31, 255) */
-typedef uint8_t pciio_function_t;  /* PCI func number (0..7, 255) */
-
-#define	PCIIO_SLOTS		((pciio_slot_t)32)
-#define	PCIIO_FUNCS		((pciio_function_t)8)
-
-#define	PCIIO_SLOT_NONE		((pciio_slot_t)255)
-#define	PCIIO_FUNC_NONE		((pciio_function_t)255)
-
-typedef int pciio_intr_line_t;		/* PCI interrupt line(s) */
-
-#define PCIIO_INTR_LINE(n)      (0x1 << (n))
-#define PCIIO_INTR_LINE_A	(0x1)
-#define PCIIO_INTR_LINE_B	(0x2)
-#define PCIIO_INTR_LINE_C	(0x4)
-#define PCIIO_INTR_LINE_D	(0x8)
-
-typedef int pciio_space_t;		/* PCI address space designation */
-
-#define PCIIO_SPACE_NONE	(0)
-#define	PCIIO_SPACE_ROM		(1)
-#define PCIIO_SPACE_IO		(2)
-/*	PCIIO_SPACE_		(3) */
-#define PCIIO_SPACE_MEM		(4)
-#define PCIIO_SPACE_MEM32	(5)
-#define PCIIO_SPACE_MEM64	(6)
-#define PCIIO_SPACE_CFG		(7)
-#define PCIIO_SPACE_WIN0	(8)
-#define PCIIO_SPACE_WIN(n)	(PCIIO_SPACE_WIN0+(n))	/* 8..13 */
-/*	PCIIO_SPACE_		(14) */
-#define PCIIO_SPACE_BAD		(15)
-
-#if 1	/* does anyone really use these? */
-#define PCIIO_SPACE_USER0	(20)
-#define PCIIO_SPACE_USER(n)	(PCIIO_SPACE_USER0+(n))	/* 20 .. ? */
-#endif
-
-/*
- * PCI_NOWHERE is the error value returned in
- * place of a PCI address when there is no
- * corresponding address.
- */
-#define	PCI_NOWHERE		(0)
-
-/*
- *    Acceptable flag bits for pciio service calls
- *
- * PCIIO_FIXED: require that mappings be established
- *	using fixed sharable resources; address
- *	translation results will be permanently
- *	available. (PIOMAP_FIXED and DMAMAP_FIXED are
- *	the same numeric value and are acceptable).
- * PCIIO_NOSLEEP: if any part of the operation would
- *	sleep waiting for resoruces, return an error
- *	instead. (PIOMAP_NOSLEEP and DMAMAP_NOSLEEP are
- *	the same numeric value and are acceptable).
- *
- * PCIIO_DMA_CMD: configure this stream as a
- *	generic "command" stream. Generally this
- *	means turn off prefetchers and write
- *	gatherers, and whatever else might be
- *	necessary to make command ring DMAs
- *	work as expected.
- * PCIIO_DMA_DATA: configure this stream as a
- *	generic "data" stream. Generally, this
- *	means turning on prefetchers and write
- *	gatherers, and anything else that might
- *	increase the DMA throughput (short of
- *	using "high priority" or "real time"
- *	resources that may lower overall system
- *	performance).
- * PCIIO_DMA_A64: this device is capable of
- *	using 64-bit DMA addresses. Unless this
- *	flag is specified, it is assumed that
- *	the DMA address must be in the low 4G
- *	of PCI space.
- * PCIIO_PREFETCH: if there are prefetchers
- *	available, they can be turned on.
- * PCIIO_NOPREFETCH: any prefetchers along
- *	the dma path should be turned off.
- * PCIIO_WRITE_GATHER: if there are write gatherers
- *	available, they can be turned on.
- * PCIIO_NOWRITE_GATHER: any write gatherers along
- *	the dma path should be turned off.
- *
- * PCIIO_BYTE_STREAM: the DMA stream represents a group
- *	of ordered bytes. Arrange all byte swapping
- *	hardware so that the bytes land in the correct
- *	order. This is a common setting for data
- *	channels, but is NOT implied by PCIIO_DMA_DATA.
- * PCIIO_WORD_VALUES: the DMA stream is used to
- *	communicate quantities stored in multiple bytes,
- *	and the device doing the DMA is little-endian;
- *	arrange any swapping hardware so that
- *	32-bit-wide values are maintained. This is a
- *	common setting for command rings that contain
- *	DMA addresses and counts, but is NOT implied by
- *	PCIIO_DMA_CMD. CPU Accesses to 16-bit fields
- *	must have their address xor-ed with 2, and
- *	accesses to individual bytes must have their
- *	addresses xor-ed with 3 relative to what the
- *	device expects.
- *
- * NOTE: any "provider specific" flags that
- * conflict with the generic flags will
- * override the generic flags, locally
- * at that provider.
- *
- * Also, note that PCI-generic flags (PCIIO_) are
- * in bits 0-14. The upper bits, 15-31, are reserved
- * for PCI implementation-specific flags.
- */
-
-#define	PCIIO_FIXED		DMAMAP_FIXED
-#define	PCIIO_NOSLEEP		DMAMAP_NOSLEEP
-
-#define PCIIO_DMA_CMD		0x0010
-#define PCIIO_DMA_DATA		0x0020
-#define PCIIO_DMA_A64		0x0040
-
-#define PCIIO_WRITE_GATHER	0x0100
-#define PCIIO_NOWRITE_GATHER	0x0200
-#define PCIIO_PREFETCH		0x0400
-#define PCIIO_NOPREFETCH	0x0800
-
-/* Requesting an endianness setting that the
- * underlieing hardware can not support
- * WILL result in a failure to allocate
- * dmamaps or complete a dmatrans.
- */
-#define	PCIIO_BYTE_STREAM	0x1000	/* set BYTE SWAP for "byte stream" */
-#define	PCIIO_WORD_VALUES	0x2000	/* set BYTE SWAP for "word values" */
-
-/*
- * Interface to deal with PCI endianness.
- * The driver calls pciio_endian_set once, supplying the actual endianness of
- * the device and the desired endianness.  On SGI systems, only use LITTLE if
- * dealing with a driver that does software swizzling.  Most of the time,
- * it's preferable to request BIG.  The return value indicates the endianness
- * that is actually achieved.  On systems that support hardware swizzling,
- * the achieved endianness will be the desired endianness.  On systems without
- * swizzle hardware, the achieved endianness will be the device's endianness.
- */
-typedef enum pciio_endian_e {
-    PCIDMA_ENDIAN_BIG,
-    PCIDMA_ENDIAN_LITTLE
-} pciio_endian_t;
-
-/*
- * Generic PCI bus information
- */
-typedef enum pciio_asic_type_e {
-    PCIIO_ASIC_TYPE_UNKNOWN, 
-    PCIIO_ASIC_TYPE_MACE,
-    PCIIO_ASIC_TYPE_BRIDGE, 
-    PCIIO_ASIC_TYPE_XBRIDGE,
-    PCIIO_ASIC_TYPE_PIC,
-} pciio_asic_type_t;
-
-typedef enum pciio_bus_type_e {
-    PCIIO_BUS_TYPE_UNKNOWN,
-    PCIIO_BUS_TYPE_PCI,
-    PCIIO_BUS_TYPE_PCIX 
-} pciio_bus_type_t; 
-
-typedef enum pciio_bus_speed_e {
-    PCIIO_BUS_SPEED_UNKNOWN,
-    PCIIO_BUS_SPEED_33,
-    PCIIO_BUS_SPEED_66,
-    PCIIO_BUS_SPEED_100,
-    PCIIO_BUS_SPEED_133
-} pciio_bus_speed_t;
-
-/*
- * Interface to set PCI arbitration priority for devices that require
- * realtime characteristics.  pciio_priority_set is used to switch a
- * device between the PCI high-priority arbitration ring and the low
- * priority arbitration ring.
- *
- * (Note: this is strictly for the PCI arbitrary priority.  It has
- * no direct relationship to GBR.)
- */
-typedef enum pciio_priority_e {
-    PCI_PRIO_LOW,
-    PCI_PRIO_HIGH
-} pciio_priority_t;
-
-/*
- * handles of various sorts
- */
-typedef struct pciio_piomap_s *pciio_piomap_t;
-typedef struct pciio_dmamap_s *pciio_dmamap_t;
-typedef struct pciio_intr_s *pciio_intr_t;
-typedef struct pciio_info_s *pciio_info_t;
-typedef struct pciio_piospace_s *pciio_piospace_t;
-typedef struct pciio_win_info_s *pciio_win_info_t;
-typedef struct pciio_win_map_s *pciio_win_map_t;
-typedef struct pciio_win_alloc_s *pciio_win_alloc_t;
-typedef struct pciio_bus_map_s *pciio_bus_map_t;
-typedef struct pciio_businfo_s *pciio_businfo_t;
-
-
-/* PIO MANAGEMENT */
-
-/*
- *    A NOTE ON PCI PIO ADDRESSES
- *
- *      PCI supports three different address spaces: CFG
- *      space, MEM space and I/O space. Further, each
- *      card always accepts CFG accesses at an address
- *      based on which slot it is attached to, but can
- *      decode up to six address ranges.
- *
- *      Assignment of the base address registers for all
- *      PCI devices is handled centrally; most commonly,
- *      device drivers will want to talk to offsets
- *      within one or another of the address ranges. In
- *      order to do this, which of these "address
- *      spaces" the PIO is directed into must be encoded
- *      in the flag word.
- *
- *      We reserve the right to defer allocation of PCI
- *      address space for a device window until the
- *      driver makes a piomap_alloc or piotrans_addr
- *      request.
- *
- *      If a device driver mucks with its device's base
- *      registers through a PIO mapping to CFG space,
- *      results of further PIO through the corresponding
- *      window are UNDEFINED.
- *
- *      Windows are named by the index in the base
- *      address register set for the device of the
- *      desired register; IN THE CASE OF 64 BIT base
- *      registers, the index should be to the word of
- *      the register that contains the mapping type
- *      bits; since the PCI CFG space is natively
- *      organized little-endian fashion, this is the
- *      first of the two words.
- *
- *      AT THE MOMENT, any required corrections for
- *      endianness are the responsibility of the device
- *      driver; not all platforms support control in
- *      hardware of byteswapping hardware. We anticipate
- *      providing flag bits to the PIO and DMA
- *      management interfaces to request different
- *      configurations of byteswapping hardware.
- *
- *      PIO Accesses to CFG space via the "Bridge" ASIC
- *      used in IP30 platforms preserve the native byte
- *      significance within the 32-bit word; byte
- *      addresses for single byte accesses need to be
- *      XORed with 3, and addresses for 16-bit accesses
- *      need to be XORed with 2.
- *
- *      The IOC3 used on IP30, and other SGI PCI devices
- *      as well, require use of 32-bit accesses to their
- *      configuration space registers. Any potential PCI
- *      bus providers need to be aware of this requirement.
- */
-
-#define PCIIO_PIOMAP_CFG	(0x1)
-#define PCIIO_PIOMAP_MEM	(0x2)
-#define PCIIO_PIOMAP_IO		(0x4)
-#define PCIIO_PIOMAP_WIN(n)	(0x8+(n))
-
-typedef pciio_piomap_t
-pciio_piomap_alloc_f    (vertex_hdl_t dev,	/* set up mapping for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 pciio_space_t space,	/* which address space */
-			 iopaddr_t pcipio_addr,		/* starting address */
-			 size_t byte_count,
-			 size_t byte_count_max,		/* maximum size of a mapping */
-			 unsigned int flags);	/* defined in sys/pio.h */
-
-typedef void
-pciio_piomap_free_f     (pciio_piomap_t pciio_piomap);
-
-typedef caddr_t
-pciio_piomap_addr_f     (pciio_piomap_t pciio_piomap,	/* mapping resources */
-			 iopaddr_t pciio_addr,	/* map for this pcipio address */
-			 size_t byte_count);	/* map this many bytes */
-
-typedef void
-pciio_piomap_done_f     (pciio_piomap_t pciio_piomap);
-
-typedef caddr_t
-pciio_piotrans_addr_f   (vertex_hdl_t dev,	/* translate for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 pciio_space_t space,	/* which address space */
-			 iopaddr_t pciio_addr,	/* starting address */
-			 size_t byte_count,	/* map this many bytes */
-			 unsigned int flags);
-
-typedef caddr_t
-pciio_pio_addr_f        (vertex_hdl_t dev,	/* translate for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 pciio_space_t space,	/* which address space */
-			 iopaddr_t pciio_addr,	/* starting address */
-			 size_t byte_count,	/* map this many bytes */
-			 pciio_piomap_t *mapp,	/* in case a piomap was needed */
-			 unsigned int flags);
-
-typedef iopaddr_t
-pciio_piospace_alloc_f  (vertex_hdl_t dev,	/* PIO space for this device */
-			 device_desc_t dev_desc,	/* Device descriptor   */
-			 pciio_space_t space,	/* which address space  */
-			 size_t byte_count,	/* Number of bytes of space */
-			 size_t alignment);	/* Alignment of allocation  */
-
-typedef void
-pciio_piospace_free_f   (vertex_hdl_t dev,	/* Device freeing space */
-			 pciio_space_t space,	/* Which space is freed */
-			 iopaddr_t pci_addr,	/* Address being freed */
-			 size_t size);	/* Size freed           */
-
-/* DMA MANAGEMENT */
-
-typedef pciio_dmamap_t
-pciio_dmamap_alloc_f    (vertex_hdl_t dev,	/* set up mappings for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 size_t byte_count_max,		/* max size of a mapping */
-			 unsigned int flags);	/* defined in dma.h */
-
-typedef void
-pciio_dmamap_free_f     (pciio_dmamap_t dmamap);
-
-typedef iopaddr_t
-pciio_dmamap_addr_f     (pciio_dmamap_t dmamap,		/* use these mapping resources */
-			 paddr_t paddr,	/* map for this address */
-			 size_t byte_count);	/* map this many bytes */
-
-typedef void
-pciio_dmamap_done_f     (pciio_dmamap_t dmamap);
-
-typedef iopaddr_t
-pciio_dmatrans_addr_f   (vertex_hdl_t dev,	/* translate for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 paddr_t paddr,	/* system physical address */
-			 size_t byte_count,	/* length */
-			 unsigned int flags);	/* defined in dma.h */
-
-typedef void
-pciio_dmamap_drain_f	(pciio_dmamap_t map);
-
-typedef void
-pciio_dmaaddr_drain_f	(vertex_hdl_t vhdl,
-			 paddr_t addr,
-			 size_t bytes);
-
-
-/* INTERRUPT MANAGEMENT */
-
-typedef pciio_intr_t
-pciio_intr_alloc_f      (vertex_hdl_t dev,	/* which PCI device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 pciio_intr_line_t lines,	/* which line(s) will be used */
-			 vertex_hdl_t owner_dev);	/* owner of this intr */
-
-typedef void
-pciio_intr_free_f       (pciio_intr_t intr_hdl);
-
-typedef int
-pciio_intr_connect_f    (pciio_intr_t intr_hdl, intr_func_t intr_func, intr_arg_t intr_arg);	/* pciio intr resource handle */
-
-typedef void
-pciio_intr_disconnect_f (pciio_intr_t intr_hdl);
-
-typedef vertex_hdl_t
-pciio_intr_cpu_get_f    (pciio_intr_t intr_hdl);	/* pciio intr resource handle */
-
-/* CONFIGURATION MANAGEMENT */
-
-typedef void
-pciio_provider_startup_f (vertex_hdl_t pciio_provider);
-
-typedef void
-pciio_provider_shutdown_f (vertex_hdl_t pciio_provider);
-
-typedef int	
-pciio_reset_f		(vertex_hdl_t conn);	/* pci connection point */
-
-typedef pciio_endian_t			/* actual endianness */
-pciio_endian_set_f      (vertex_hdl_t dev,	/* specify endianness for this device */
-			 pciio_endian_t device_end,	/* endianness of device */
-			 pciio_endian_t desired_end);	/* desired endianness */
-
-typedef uint64_t
-pciio_config_get_f	(vertex_hdl_t conn,	/* pci connection point */
-			 unsigned int reg,		/* register byte offset */
-			 unsigned int size);	/* width in bytes (1..4) */
-
-typedef void
-pciio_config_set_f	(vertex_hdl_t conn,	/* pci connection point */
-			 unsigned int reg,		/* register byte offset */
-			 unsigned int size,		/* width in bytes (1..4) */
-			 uint64_t value);	/* value to store */
-
-typedef pciio_slot_t
-pciio_error_extract_f	(vertex_hdl_t vhdl,
-			 pciio_space_t *spacep,
-			 iopaddr_t *addrp);
-
-typedef void
-pciio_driver_reg_callback_f	(vertex_hdl_t conn,
-				int key1,
-				int key2,
-				int error);
-
-typedef void
-pciio_driver_unreg_callback_f	(vertex_hdl_t conn, /* pci connection point */
-				 int key1,
-				 int key2,
-				 int error);
-
-typedef int
-pciio_device_unregister_f	(vertex_hdl_t conn);
-
-
-/*
- * Adapters that provide a PCI interface adhere to this software interface.
- */
-typedef struct pciio_provider_s {
-    /* ASIC PROVIDER ID */
-    pciio_asic_type_t	   provider_asic;
-
-    /* PIO MANAGEMENT */
-    pciio_piomap_alloc_f   *piomap_alloc;
-    pciio_piomap_free_f    *piomap_free;
-    pciio_piomap_addr_f    *piomap_addr;
-    pciio_piomap_done_f    *piomap_done;
-    pciio_piotrans_addr_f  *piotrans_addr;
-    pciio_piospace_alloc_f *piospace_alloc;
-    pciio_piospace_free_f  *piospace_free;
-
-    /* DMA MANAGEMENT */
-    pciio_dmamap_alloc_f   *dmamap_alloc;
-    pciio_dmamap_free_f    *dmamap_free;
-    pciio_dmamap_addr_f    *dmamap_addr;
-    pciio_dmamap_done_f    *dmamap_done;
-    pciio_dmatrans_addr_f  *dmatrans_addr;
-    pciio_dmamap_drain_f   *dmamap_drain;
-    pciio_dmaaddr_drain_f  *dmaaddr_drain;
-
-    /* INTERRUPT MANAGEMENT */
-    pciio_intr_alloc_f     *intr_alloc;
-    pciio_intr_free_f      *intr_free;
-    pciio_intr_connect_f   *intr_connect;
-    pciio_intr_disconnect_f *intr_disconnect;
-    pciio_intr_cpu_get_f   *intr_cpu_get;
-
-    /* CONFIGURATION MANAGEMENT */
-    pciio_provider_startup_f *provider_startup;
-    pciio_provider_shutdown_f *provider_shutdown;
-    pciio_reset_f	   *reset;
-    pciio_endian_set_f     *endian_set;
-    pciio_config_get_f	   *config_get;
-    pciio_config_set_f	   *config_set;
-
-    /* Error handling interface */
-    pciio_error_extract_f *error_extract;
-
-    /* Callback support */
-    pciio_driver_reg_callback_f *driver_reg_callback;
-    pciio_driver_unreg_callback_f *driver_unreg_callback;
-    pciio_device_unregister_f 	*device_unregister;
-} pciio_provider_t;
-
-/* PCI devices use these standard PCI provider interfaces */
-extern pciio_piomap_alloc_f pciio_piomap_alloc;
-extern pciio_piomap_free_f pciio_piomap_free;
-extern pciio_piomap_addr_f pciio_piomap_addr;
-extern pciio_piomap_done_f pciio_piomap_done;
-extern pciio_piotrans_addr_f pciio_piotrans_addr;
-extern pciio_pio_addr_f pciio_pio_addr;
-extern pciio_piospace_alloc_f pciio_piospace_alloc;
-extern pciio_piospace_free_f pciio_piospace_free;
-extern pciio_dmamap_alloc_f pciio_dmamap_alloc;
-extern pciio_dmamap_free_f pciio_dmamap_free;
-extern pciio_dmamap_addr_f pciio_dmamap_addr;
-extern pciio_dmamap_done_f pciio_dmamap_done;
-extern pciio_dmatrans_addr_f pciio_dmatrans_addr;
-extern pciio_dmamap_drain_f pciio_dmamap_drain;
-extern pciio_dmaaddr_drain_f pciio_dmaaddr_drain;
-extern pciio_intr_alloc_f pciio_intr_alloc;
-extern pciio_intr_free_f pciio_intr_free;
-extern pciio_intr_connect_f pciio_intr_connect;
-extern pciio_intr_disconnect_f pciio_intr_disconnect;
-extern pciio_intr_cpu_get_f pciio_intr_cpu_get;
-extern pciio_provider_startup_f pciio_provider_startup;
-extern pciio_provider_shutdown_f pciio_provider_shutdown;
-extern pciio_reset_f pciio_reset;
-extern pciio_endian_set_f pciio_endian_set;
-extern pciio_config_get_f pciio_config_get;
-extern pciio_config_set_f pciio_config_set;
-
-/* Widgetdev in the IOERROR structure is encoded as follows.
- *	+---------------------------+
- *	| slot (7:3) | function(2:0)|
- *	+---------------------------+
- * Following are the convenience interfaces to get at form
- * a widgetdev or to break it into its constituents.
- */
-
-#define PCIIO_WIDGETDEV_SLOT_SHFT		3
-#define PCIIO_WIDGETDEV_SLOT_MASK		0x1f
-#define PCIIO_WIDGETDEV_FUNC_MASK		0x7
-
-#define pciio_widgetdev_create(slot,func)       \
-        (((slot) << PCIIO_WIDGETDEV_SLOT_SHFT) + (func))
-
-#define pciio_widgetdev_slot_get(wdev)		\
-	(((wdev) >> PCIIO_WIDGETDEV_SLOT_SHFT) & PCIIO_WIDGETDEV_SLOT_MASK)
-
-#define pciio_widgetdev_func_get(wdev)		\
-	((wdev) & PCIIO_WIDGETDEV_FUNC_MASK)
-
-
-/* Generic PCI card initialization interface
- */
-
-extern int
-pciio_driver_register  (pciio_vendor_id_t vendor_id,	/* card's vendor number */
-			pciio_device_id_t device_id,	/* card's device number */
-			char *driver_prefix,	/* driver prefix */
-			unsigned int flags);
-
-extern void
-pciio_error_register   (vertex_hdl_t pconn,	/* which slot */
-			error_handler_f *efunc,	/* function to call */
-			error_handler_arg_t einfo);	/* first parameter */
-
-extern void             pciio_driver_unregister(char *driver_prefix);
-
-typedef void		pciio_iter_f(vertex_hdl_t pconn);	/* a connect point */
-
-/* Interfaces used by PCI Bus Providers to talk to
- * the Generic PCI layer.
- */
-extern vertex_hdl_t
-pciio_device_register  (vertex_hdl_t connectpt,	/* vertex at center of bus */
-			vertex_hdl_t master,	/* card's master ASIC (pci provider) */
-			pciio_slot_t slot,	/* card's slot (0..?) */
-			pciio_function_t func,	/* card's func (0..?) */
-			pciio_vendor_id_t vendor,	/* card's vendor number */
-			pciio_device_id_t device);	/* card's device number */
-
-extern void
-pciio_device_unregister(vertex_hdl_t connectpt);
-
-extern pciio_info_t
-pciio_device_info_new  (pciio_info_t pciio_info,	/* preallocated info struct */
-			vertex_hdl_t master,	/* card's master ASIC (pci provider) */
-			pciio_slot_t slot,	/* card's slot (0..?) */
-			pciio_function_t func,	/* card's func (0..?) */
-			pciio_vendor_id_t vendor,	/* card's vendor number */
-			pciio_device_id_t device);	/* card's device number */
-
-extern void
-pciio_device_info_free(pciio_info_t pciio_info);
-
-extern vertex_hdl_t
-pciio_device_info_register(
-			vertex_hdl_t connectpt,	/* vertex at center of bus */
-			pciio_info_t pciio_info);	/* details about conn point */
-
-extern void
-pciio_device_info_unregister(
-			vertex_hdl_t connectpt,	/* vertex at center of bus */
-			pciio_info_t pciio_info);	/* details about conn point */
-
-
-extern int              
-pciio_device_attach(
-			vertex_hdl_t pcicard,   /* vertex created by pciio_device_register */
-			int drv_flags);
-extern int
-pciio_device_detach(
-			vertex_hdl_t pcicard,   /* vertex created by pciio_device_register */
-                        int drv_flags);
-
-
-/* create and initialize empty window mapping resource */
-extern pciio_win_map_t
-pciio_device_win_map_new(pciio_win_map_t win_map,	/* preallocated win map structure */
-			 size_t region_size,		/* size of region to be tracked */
-			 size_t page_size);		/* allocation page size */
-
-/* destroy window mapping resource freeing up ancillary resources */
-extern void
-pciio_device_win_map_free(pciio_win_map_t win_map);	/* preallocated win map structure */
-
-/* populate window mapping with free range of addresses */
-extern void
-pciio_device_win_populate(pciio_win_map_t win_map,	/* win map */
-			  iopaddr_t ioaddr,		/* base address of free range */
-			  size_t size);			/* size of free range */
-
-/* allocate window from mapping resource */
-extern iopaddr_t
-pciio_device_win_alloc(struct resource * res,
-		       pciio_win_alloc_t win_alloc,	/* opaque allocation cookie */
-		       size_t start,			/* start unit, or 0 */
-		       size_t size,			/* size of allocation */
-		       size_t align);			/* alignment of allocation */
-
-/* free previously allocated window */
-extern void
-pciio_device_win_free(pciio_win_alloc_t win_alloc);	/* opaque allocation cookie */
-
-
-/*
- * Generic PCI interface, for use with all PCI providers
- * and all PCI devices.
- */
-
-/* Generic PCI interrupt interfaces */
-extern vertex_hdl_t     pciio_intr_dev_get(pciio_intr_t pciio_intr);
-extern vertex_hdl_t     pciio_intr_cpu_get(pciio_intr_t pciio_intr);
-
-/* Generic PCI pio interfaces */
-extern vertex_hdl_t     pciio_pio_dev_get(pciio_piomap_t pciio_piomap);
-extern pciio_slot_t     pciio_pio_slot_get(pciio_piomap_t pciio_piomap);
-extern pciio_space_t    pciio_pio_space_get(pciio_piomap_t pciio_piomap);
-extern iopaddr_t        pciio_pio_pciaddr_get(pciio_piomap_t pciio_piomap);
-extern ulong            pciio_pio_mapsz_get(pciio_piomap_t pciio_piomap);
-extern caddr_t          pciio_pio_kvaddr_get(pciio_piomap_t pciio_piomap);
-
-/* Generic PCI dma interfaces */
-extern vertex_hdl_t     pciio_dma_dev_get(pciio_dmamap_t pciio_dmamap);
-
-/* Register/unregister PCI providers and get implementation handle */
-extern void             pciio_provider_register(vertex_hdl_t provider, pciio_provider_t *pciio_fns);
-extern void             pciio_provider_unregister(vertex_hdl_t provider);
-extern pciio_provider_t *pciio_provider_fns_get(vertex_hdl_t provider);
-
-/* Generic pci slot information access interface */
-extern pciio_info_t     pciio_info_chk(vertex_hdl_t vhdl);
-extern pciio_info_t     pciio_info_get(vertex_hdl_t vhdl);
-extern void             pciio_info_set(vertex_hdl_t vhdl, pciio_info_t widget_info);
-extern vertex_hdl_t     pciio_info_dev_get(pciio_info_t pciio_info);
-extern pciio_bus_t	pciio_info_bus_get(pciio_info_t pciio_info);
-extern pciio_slot_t     pciio_info_slot_get(pciio_info_t pciio_info);
-extern pciio_function_t	pciio_info_function_get(pciio_info_t pciio_info);
-extern pciio_vendor_id_t pciio_info_vendor_id_get(pciio_info_t pciio_info);
-extern pciio_device_id_t pciio_info_device_id_get(pciio_info_t pciio_info);
-extern vertex_hdl_t     pciio_info_master_get(pciio_info_t pciio_info);
-extern arbitrary_info_t pciio_info_mfast_get(pciio_info_t pciio_info);
-extern pciio_provider_t *pciio_info_pops_get(pciio_info_t pciio_info);
-extern error_handler_f *pciio_info_efunc_get(pciio_info_t);
-extern error_handler_arg_t *pciio_info_einfo_get(pciio_info_t);
-extern pciio_space_t	pciio_info_bar_space_get(pciio_info_t, int);
-extern iopaddr_t	pciio_info_bar_base_get(pciio_info_t, int);
-extern size_t		pciio_info_bar_size_get(pciio_info_t, int);
-extern iopaddr_t	pciio_info_rom_base_get(pciio_info_t);
-extern size_t		pciio_info_rom_size_get(pciio_info_t);
-extern int		pciio_info_type1_get(pciio_info_t);
-extern int              pciio_error_handler(vertex_hdl_t, int, ioerror_mode_t, ioerror_t *);
-
-/**
- * sn_pci_set_vchan - Set the requested Virtual Channel bits into the mapped DMA
- *                    address.
- * @pci_dev: pci device pointer
- * @addr: mapped dma address
- * @vchan: Virtual Channel to use 0 or 1.
- *
- * Set the Virtual Channel bit in the mapped dma address.
- */
-
-static inline int
-sn_pci_set_vchan(struct pci_dev *pci_dev,
-		 dma_addr_t *addr,
-		 int vchan)
-{
-	if (vchan > 1) {
-		return -1;
-	}
-
-	if (!(*addr >> 32))     /* Using a mask here would be cleaner */
-		return 0;       /* but this generates better code */
-
-	if (vchan == 1) {
-		/* Set Bit 57 */
-		*addr |= (1UL << 57);
-	} else {
-		/* Clear Bit 57 */
-		*addr &= ~(1UL << 57);
-	}
-
-	return 0;
-}
-
-#endif				/* C or C++ */
-
-
-/*
- * Prototypes
- */
-
-int snia_badaddr_val(volatile void *addr, int len, volatile void *ptr);
-nasid_t snia_get_console_nasid(void);
-nasid_t snia_get_master_baseio_nasid(void);
-#endif				/* _ASM_IA64_SN_PCI_PCIIO_H */
diff -Nru a/include/asm-ia64/sn/pci/pciio_private.h b/include/asm-ia64/sn/pci/pciio_private.h
--- a/include/asm-ia64/sn/pci/pciio_private.h	2004-12-24 13:36:56 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,145 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PCI_PCIIO_PRIVATE_H
-#define _ASM_IA64_SN_PCI_PCIIO_PRIVATE_H
-
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pci_defs.h>
-
-/*
- * pciio_private.h -- private definitions for pciio
- * PCI drivers should NOT include this file.
- */
-
-/*
- * All PCI providers set up PIO using this information.
- */
-struct pciio_piomap_s {
-    unsigned int            pp_flags;	/* PCIIO_PIOMAP flags */
-    vertex_hdl_t            pp_dev;	/* associated pci card */
-    pciio_slot_t            pp_slot;	/* which slot the card is in */
-    pciio_space_t           pp_space;	/* which address space */
-    iopaddr_t               pp_pciaddr;		/* starting offset of mapping */
-    size_t                  pp_mapsz;	/* size of this mapping */
-    caddr_t                 pp_kvaddr;	/* kernel virtual address to use */
-};
-
-/*
- * All PCI providers set up DMA using this information.
- */
-struct pciio_dmamap_s {
-    unsigned int            pd_flags;	/* PCIIO_DMAMAP flags */
-    vertex_hdl_t            pd_dev;	/* associated pci card */
-    pciio_slot_t            pd_slot;	/* which slot the card is in */
-};
-
-/*
- * All PCI providers set up interrupts using this information.
- */
-
-struct pciio_intr_s {
-    unsigned int            pi_flags;	/* PCIIO_INTR flags */
-    vertex_hdl_t            pi_dev;	/* associated pci card */
-    device_desc_t	    pi_dev_desc;	/* override device descriptor */
-    pciio_intr_line_t       pi_lines;	/* which interrupt line(s) */
-    intr_func_t             pi_func;	/* handler function (when connected) */
-    intr_arg_t              pi_arg;	/* handler parameter (when connected) */
-    cpuid_t                 pi_mustruncpu; /* Where we must run. */
-    int                     pi_irq;     /* IRQ assigned */
-    int                     pi_cpu;     /* cpu assigned */
-};
-
-/* PCIIO_INTR (pi_flags) flags */
-#define PCIIO_INTR_CONNECTED	1	/* interrupt handler/thread has been connected */
-#define PCIIO_INTR_NOTHREAD	2	/* interrupt handler wants to be called at interrupt level */
-
-/*
- * Generic PCI bus information
- */
-struct pciio_businfo_s {
-    int                 bi_multi_master;/* Bus provider supports multiple */
-                                        /* dma masters behind a single slot. */
-                                        /* Needed to work around a thrashing */
-                                        /* issue in SGI Bridge ASIC and */
-                                        /* its derivatives. */
-    pciio_asic_type_t   bi_asic_type;   /* PCI ASIC type */
-    pciio_bus_type_t    bi_bus_type;    /* PCI bus type */
-    pciio_bus_speed_t   bi_bus_speed;   /* PCI bus speed */
-}; 
-
-/*
- * Some PCI provider implementations keep track of PCI window Base Address
- * Register (BAR) address range assignment via the rmalloc()/rmfree() arena
- * management routines.  These implementations use the following data
- * structure for each allocation address space (e.g. memory, I/O, small
- * window, etc.).
- *
- * The ``page size'' encodes the minimum allocation unit and must be a power
- * of 2.  The main use of this allocation ``page size'' is to control the
- * number of free address ranges that the mapping allocation software will
- * need to track.  Smaller values will allow more efficient use of the address
- * ranges but will result in much larger allocation map structures ...  For
- * instance, if we want to manage allocations for a 256MB address range,
- * choosing a 1MB allocation page size will result in up to 1MB being wasted
- * for allocation requests smaller than 1MB.  The worst case allocation
- * pattern for the allocation software to track would be a pattern of 1MB
- * allocated, 1MB free.  This results in the need to track up to 128 free
- * ranges.
- */
-struct pciio_win_map_s {
-	struct map	*wm_map;	/* window address map */
-	int		wm_page_size;	/* allocation ``page size'' */
-};
-
-/*
- * Opaque structure used to keep track of window allocation information.
- */
-struct pciio_win_alloc_s {
-	struct resource *wa_resource;   /* window map allocation resource */
-	unsigned long	wa_base;	/* allocation starting page number */
-	size_t		wa_pages;	/* number of pages in allocation */
-};
-
-/*
- * Each PCI Card has one of these.
- */
-
-struct pciio_info_s {
-    char                   *c_fingerprint;
-    vertex_hdl_t            c_vertex;	/* back pointer to vertex */
-    vertex_hdl_t	    c_hostvertex;/* top most device in tree */
-    pciio_bus_t             c_bus;	/* which bus the card is in */
-    pciio_slot_t            c_slot;	/* which slot the card is in */
-    pciio_function_t        c_func;	/* which func (on multi-func cards) */
-    pciio_vendor_id_t       c_vendor;	/* PCI card "vendor" code */
-    pciio_device_id_t       c_device;	/* PCI card "device" code */
-    vertex_hdl_t            c_master;	/* PCI bus provider */
-    arbitrary_info_t        c_mfast;	/* cached fastinfo from c_master */
-    pciio_provider_t       *c_pops;	/* cached provider from c_master */
-    error_handler_f        *c_efunc;	/* error handling function */
-    error_handler_arg_t     c_einfo;	/* first parameter for efunc */
-
-    struct pciio_win_info_s {           /* state of BASE regs */
-        pciio_space_t           w_space;
-        char                    w_code;		/* low 4 bits of MEM BAR */
-						/* low 2 bits of IO BAR */
-        iopaddr_t               w_base;
-        size_t                  w_size;
-        int                     w_devio_index;   /* DevIO[] register used to
-                                                    access this window */
-	struct pciio_win_alloc_s w_win_alloc;    /* window allocation cookie */
-    }                       c_window[PCI_CFG_BASE_ADDRS + 1];
-#define c_rwindow	c_window[PCI_CFG_BASE_ADDRS]	/* EXPANSION ROM window */
-#define c_rbase		c_rwindow.w_base		/* EXPANSION ROM base addr */
-#define c_rsize		c_rwindow.w_size		/* EXPANSION ROM size (bytes) */
-    pciio_piospace_t	    c_piospace;	/* additional I/O spaces allocated */
-    int			    c_type1;	/* use type1 addressing */
-};
-
-extern char             pciio_info_fingerprint[];
-#endif				/* _ASM_IA64_SN_PCI_PCIIO_PRIVATE_H */
diff -Nru a/include/asm-ia64/sn/pci/pic.h b/include/asm-ia64/sn/pci/pic.h
--- a/include/asm-ia64/sn/pci/pic.h	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,451 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PCI_PIC_H
-#define _ASM_IA64_SN_PCI_PIC_H
-
-/*
- * PIC AS DEVICE ZERO
- * ------------------
- *
- * PIC handles PCI/X busses.  PCI/X requires that the 'bridge' (i.e. PIC)
- * be designated as 'device 0'.   That is a departure from earlier SGI
- * PCI bridges.  Because of that we use config space 1 to access the
- * config space of the first actual PCI device on the bus. 
- * Here's what the PIC manual says:
- *
- *     The current PCI-X bus specification now defines that the parent
- *     hosts bus bridge (PIC for example) must be device 0 on bus 0. PIC
- *     reduced the total number of devices from 8 to 4 and removed the
- *     device registers and windows, now only supporting devices 0,1,2, and
- *     3. PIC did leave all 8 configuration space windows. The reason was
- *     there was nothing to gain by removing them. Here in lies the problem.
- *     The device numbering we do using 0 through 3 is unrelated to the device
- *     numbering which PCI-X requires in configuration space. In the past we
- *     correlated Configs pace and our device space 0 <-> 0, 1 <-> 1, etc.
- *     PCI-X requires we start a 1, not 0 and currently the PX brick
- *     does associate our:
- * 
- *         device 0 with configuration space window 1,
- *         device 1 with configuration space window 2, 
- *         device 2 with configuration space window 3,
- *         device 3 with configuration space window 4.
- *
- * The net effect is that all config space access are off-by-one with 
- * relation to other per-slot accesses on the PIC.   
- * Here is a table that shows some of that:
- *
- *                               Internal Slot#
- *           |
- *           |     0         1        2         3
- * ----------|---------------------------------------
- * config    |  0x21000   0x22000  0x23000   0x24000
- *           |
- * even rrb  |  0[0]      n/a      1[0]      n/a	[] == implied even/odd
- *           |
- * odd rrb   |  n/a       0[1]     n/a       1[1]
- *           |
- * int dev   |  00       01        10        11
- *           |
- * ext slot# |  1        2         3         4
- * ----------|---------------------------------------
- */
-
-
-#ifdef __KERNEL__
-#include <linux/types.h>
-#include <asm/sn/xtalk/xwidget.h>	/* generic widget header */
-#else
-#include <xtalk/xwidget.h>
-#endif
-
-#include <asm/sn/pci/pciio.h>
-
-
-/*
- *    bus provider function table
- *
- *	Normally, this table is only handed off explicitly
- *	during provider initialization, and the PCI generic
- *	layer will stash a pointer to it in the vertex; however,
- *	exporting it explicitly enables a performance hack in
- *	the generic PCI provider where if we know at compile
- *	time that the only possible PCI provider is a
- *	pcibr, we can go directly to this ops table.
- */
-
-extern pciio_provider_t pci_pic_provider;
-
-
-/*
- * misc defines
- *
- */
-
-#define PIC_WIDGET_PART_NUM_BUS0 0xd102
-#define PIC_WIDGET_PART_NUM_BUS1 0xd112
-#define PIC_WIDGET_MFGR_NUM 0x24
-#define PIC_WIDGET_REV_A  0x1
-#define PIC_WIDGET_REV_B  0x2
-#define PIC_WIDGET_REV_C  0x3
-
-#define PIC_XTALK_ADDR_MASK                     0x0000FFFFFFFFFFFF
-#define PIC_INTERNAL_ATES                       1024
-
-
-#define IS_PIC_PART_REV_A(rev) \
-	((rev == (PIC_WIDGET_PART_NUM_BUS0 << 4 | PIC_WIDGET_REV_A)) || \
-	(rev == (PIC_WIDGET_PART_NUM_BUS1 << 4 | PIC_WIDGET_REV_A)))
-#define IS_PIC_PART_REV_B(rev) \
-        ((rev == (PIC_WIDGET_PART_NUM_BUS0 << 4 | PIC_WIDGET_REV_B)) || \
-        (rev == (PIC_WIDGET_PART_NUM_BUS1 << 4 | PIC_WIDGET_REV_B)))
-#define IS_PIC_PART_REV_C(rev) \
-        ((rev == (PIC_WIDGET_PART_NUM_BUS0 << 4 | PIC_WIDGET_REV_C)) || \
-        (rev == (PIC_WIDGET_PART_NUM_BUS1 << 4 | PIC_WIDGET_REV_C)))
-
-
-/*
- * misc typedefs
- *
- */
-typedef uint64_t picreg_t;
-typedef uint64_t picate_t;
-
-/*
- * PIC Bridge MMR defines
- */
-
-/*
- * PIC STATUS register          offset 0x00000008
- */
-
-#define PIC_STAT_PCIX_ACTIVE_SHFT       33
-
-/*
- * PIC CONTROL register         offset 0x00000020
- */
-
-#define PIC_CTRL_PCI_SPEED_SHFT         4
-#define PIC_CTRL_PCI_SPEED              (0x3 << PIC_CTRL_PCI_SPEED_SHFT)
-#define PIC_CTRL_PAGE_SIZE_SHFT         21
-#define PIC_CTRL_PAGE_SIZE              (0x1 << PIC_CTRL_PAGE_SIZE_SHFT)
-
-
-/*
- * PIC Intr Destination Addr    offset 0x00000038
- */
-
-#define PIC_INTR_DEST_ADDR              0x0000FFFFFFFFFFFF
-#define PIC_INTR_DEST_TID_SHFT          48
-#define PIC_INTR_DEST_TID               (0xFull << PIC_INTR_DEST_TID_SHFT)
-
-/*
- * PIC PCI Responce Buffer      offset 0x00000068
- */
-#define PIC_RSP_BUF_ADDR                0x0000FFFFFFFFFFFF
-#define PIC_RSP_BUF_NUM_SHFT            48
-#define PIC_RSP_BUF_NUM                 (0xFull << PIC_RSP_BUF_NUM_SHFT)
-#define PIC_RSP_BUF_DEV_NUM_SHFT        52
-#define PIC_RSP_BUF_DEV_NUM             (0x3ull << PIC_RSP_BUF_DEV_NUM_SHFT)
-
-/*
- * PIC PCI DIRECT MAP register  offset 0x00000080
- */
-#define PIC_DIRMAP_DIROFF_SHFT          0
-#define PIC_DIRMAP_DIROFF               (0x1FFFF << PIC_DIRMAP_DIROFF_SHFT)
-#define PIC_DIRMAP_ADD512_SHFT          17
-#define PIC_DIRMAP_ADD512               (0x1 << PIC_DIRMAP_ADD512_SHFT)
-#define PIC_DIRMAP_WID_SHFT             20
-#define PIC_DIRMAP_WID                  (0xF << PIC_DIRMAP_WID_SHFT)
-
-#define PIC_DIRMAP_OFF_ADDRSHFT         31
-
-/*
- * Interrupt Status register            offset 0x00000100
- */
-#define PIC_ISR_PCIX_SPLIT_MSG_PE     (0x1ull << 45)
-#define PIC_ISR_PCIX_SPLIT_EMSG       (0x1ull << 44)
-#define PIC_ISR_PCIX_SPLIT_TO         (0x1ull << 43)
-#define PIC_ISR_PCIX_UNEX_COMP        (0x1ull << 42)
-#define PIC_ISR_INT_RAM_PERR          (0x1ull << 41)
-#define PIC_ISR_PCIX_ARB_ERR          (0x1ull << 40)
-#define PIC_ISR_PCIX_REQ_TOUT         (0x1ull << 39)
-#define PIC_ISR_PCIX_TABORT           (0x1ull << 38)
-#define PIC_ISR_PCIX_PERR             (0x1ull << 37)
-#define PIC_ISR_PCIX_SERR             (0x1ull << 36)
-#define PIC_ISR_PCIX_MRETRY           (0x1ull << 35)
-#define PIC_ISR_PCIX_MTOUT            (0x1ull << 34)
-#define PIC_ISR_PCIX_DA_PARITY        (0x1ull << 33)
-#define PIC_ISR_PCIX_AD_PARITY        (0x1ull << 32)
-#define PIC_ISR_PMU_PAGE_FAULT        (0x1ull << 30)
-#define PIC_ISR_UNEXP_RESP            (0x1ull << 29)
-#define PIC_ISR_BAD_XRESP_PKT         (0x1ull << 28)
-#define PIC_ISR_BAD_XREQ_PKT          (0x1ull << 27)
-#define PIC_ISR_RESP_XTLK_ERR         (0x1ull << 26)
-#define PIC_ISR_REQ_XTLK_ERR          (0x1ull << 25)
-#define PIC_ISR_INVLD_ADDR            (0x1ull << 24)
-#define PIC_ISR_UNSUPPORTED_XOP       (0x1ull << 23)
-#define PIC_ISR_XREQ_FIFO_OFLOW       (0x1ull << 22)
-#define PIC_ISR_LLP_REC_SNERR         (0x1ull << 21)
-#define PIC_ISR_LLP_REC_CBERR         (0x1ull << 20)
-#define PIC_ISR_LLP_RCTY              (0x1ull << 19)
-#define PIC_ISR_LLP_TX_RETRY          (0x1ull << 18)
-#define PIC_ISR_LLP_TCTY              (0x1ull << 17)
-#define PIC_ISR_PCI_ABORT             (0x1ull << 15)
-#define PIC_ISR_PCI_PARITY            (0x1ull << 14)
-#define PIC_ISR_PCI_SERR              (0x1ull << 13)
-#define PIC_ISR_PCI_PERR              (0x1ull << 12)
-#define PIC_ISR_PCI_MST_TIMEOUT       (0x1ull << 11)
-#define PIC_ISR_PCI_RETRY_CNT         (0x1ull << 10)
-#define PIC_ISR_XREAD_REQ_TIMEOUT     (0x1ull << 9)
-#define PIC_ISR_INT_MSK               (0xffull << 0)
-#define PIC_ISR_INT(x)                (0x1ull << (x))
-
-#define PIC_ISR_LINK_ERROR            \
-                (PIC_ISR_LLP_REC_SNERR|PIC_ISR_LLP_REC_CBERR|       \
-                 PIC_ISR_LLP_RCTY|PIC_ISR_LLP_TX_RETRY|             \
-                 PIC_ISR_LLP_TCTY)
-
-#define PIC_ISR_PCIBUS_PIOERR         \
-                (PIC_ISR_PCI_MST_TIMEOUT|PIC_ISR_PCI_ABORT|         \
-                 PIC_ISR_PCIX_MTOUT|PIC_ISR_PCIX_TABORT)
-
-#define PIC_ISR_PCIBUS_ERROR          \
-                (PIC_ISR_PCIBUS_PIOERR|PIC_ISR_PCI_PERR|            \
-                 PIC_ISR_PCI_SERR|PIC_ISR_PCI_RETRY_CNT|            \
-                 PIC_ISR_PCI_PARITY|PIC_ISR_PCIX_PERR|              \
-                 PIC_ISR_PCIX_SERR|PIC_ISR_PCIX_MRETRY|             \
-                 PIC_ISR_PCIX_AD_PARITY|PIC_ISR_PCIX_DA_PARITY|     \
-                 PIC_ISR_PCIX_REQ_TOUT|PIC_ISR_PCIX_UNEX_COMP|      \
-                 PIC_ISR_PCIX_SPLIT_TO|PIC_ISR_PCIX_SPLIT_EMSG|     \
-                 PIC_ISR_PCIX_SPLIT_MSG_PE)
-
-#define PIC_ISR_XTALK_ERROR           \
-                (PIC_ISR_XREAD_REQ_TIMEOUT|PIC_ISR_XREQ_FIFO_OFLOW| \
-                 PIC_ISR_UNSUPPORTED_XOP|PIC_ISR_INVLD_ADDR|        \
-                 PIC_ISR_REQ_XTLK_ERR|PIC_ISR_RESP_XTLK_ERR|        \
-                 PIC_ISR_BAD_XREQ_PKT|PIC_ISR_BAD_XRESP_PKT|        \
-                 PIC_ISR_UNEXP_RESP)
-
-#define PIC_ISR_ERRORS                \
-                (PIC_ISR_LINK_ERROR|PIC_ISR_PCIBUS_ERROR|           \
-                 PIC_ISR_XTALK_ERROR|                                 \
-                 PIC_ISR_PMU_PAGE_FAULT|PIC_ISR_INT_RAM_PERR)
-
-/*
- * PIC RESET INTR register      offset 0x00000110
- */
-
-#define PIC_IRR_ALL_CLR                 0xffffffffffffffff
-
-/*
- * PIC PCI Host Intr Addr       offset 0x00000130 - 0x00000168
- */
-#define PIC_HOST_INTR_ADDR              0x0000FFFFFFFFFFFF
-#define PIC_HOST_INTR_FLD_SHFT          48
-#define PIC_HOST_INTR_FLD               (0xFFull << PIC_HOST_INTR_FLD_SHFT)
-
-
-/*
- * PIC MMR structure mapping
- */
-
-/* NOTE: PIC WAR. PV#854697.  PIC does not allow writes just to [31:0]
- * of a 64-bit register.  When writing PIC registers, always write the 
- * entire 64 bits.
- */
-
-typedef volatile struct pic_s {
-
-    /* 0x000000-0x00FFFF -- Local Registers */
-
-    /* 0x000000-0x000057 -- Standard Widget Configuration */
-    picreg_t		p_wid_id;			/* 0x000000 */
-    picreg_t		p_wid_stat;			/* 0x000008 */
-    picreg_t		p_wid_err_upper;		/* 0x000010 */
-    picreg_t		p_wid_err_lower;		/* 0x000018 */
-    #define p_wid_err p_wid_err_lower
-    picreg_t		p_wid_control;			/* 0x000020 */
-    picreg_t		p_wid_req_timeout;		/* 0x000028 */
-    picreg_t		p_wid_int_upper;		/* 0x000030 */
-    picreg_t		p_wid_int_lower;		/* 0x000038 */
-    #define p_wid_int p_wid_int_lower
-    picreg_t		p_wid_err_cmdword;		/* 0x000040 */
-    picreg_t		p_wid_llp;			/* 0x000048 */
-    picreg_t		p_wid_tflush;			/* 0x000050 */
-
-    /* 0x000058-0x00007F -- Bridge-specific Widget Configuration */
-    picreg_t		p_wid_aux_err;			/* 0x000058 */
-    picreg_t		p_wid_resp_upper;		/* 0x000060 */
-    picreg_t		p_wid_resp_lower;		/* 0x000068 */
-    #define p_wid_resp p_wid_resp_lower
-    picreg_t		p_wid_tst_pin_ctrl;		/* 0x000070 */
-    picreg_t		p_wid_addr_lkerr;		/* 0x000078 */
-
-    /* 0x000080-0x00008F -- PMU & MAP */
-    picreg_t		p_dir_map;			/* 0x000080 */
-    picreg_t		_pad_000088;			/* 0x000088 */
-
-    /* 0x000090-0x00009F -- SSRAM */
-    picreg_t		p_map_fault;			/* 0x000090 */
-    picreg_t		_pad_000098;			/* 0x000098 */
-
-    /* 0x0000A0-0x0000AF -- Arbitration */
-    picreg_t		p_arb;				/* 0x0000A0 */
-    picreg_t		_pad_0000A8;			/* 0x0000A8 */
-
-    /* 0x0000B0-0x0000BF -- Number In A Can or ATE Parity Error */
-    picreg_t		p_ate_parity_err;		/* 0x0000B0 */
-    picreg_t		_pad_0000B8;			/* 0x0000B8 */
-
-    /* 0x0000C0-0x0000FF -- PCI/GIO */
-    picreg_t		p_bus_timeout;			/* 0x0000C0 */
-    picreg_t		p_pci_cfg;			/* 0x0000C8 */
-    picreg_t		p_pci_err_upper;		/* 0x0000D0 */
-    picreg_t		p_pci_err_lower;		/* 0x0000D8 */
-    #define p_pci_err p_pci_err_lower
-    picreg_t		_pad_0000E0[4];			/* 0x0000{E0..F8} */
-
-    /* 0x000100-0x0001FF -- Interrupt */
-    picreg_t		p_int_status;			/* 0x000100 */
-    picreg_t		p_int_enable;			/* 0x000108 */
-    picreg_t		p_int_rst_stat;			/* 0x000110 */
-    picreg_t		p_int_mode;			/* 0x000118 */
-    picreg_t		p_int_device;			/* 0x000120 */
-    picreg_t		p_int_host_err;			/* 0x000128 */
-    picreg_t		p_int_addr[8];			/* 0x0001{30,,,68} */
-    picreg_t		p_err_int_view;			/* 0x000170 */
-    picreg_t		p_mult_int;			/* 0x000178 */
-    picreg_t		p_force_always[8];		/* 0x0001{80,,,B8} */
-    picreg_t		p_force_pin[8];			/* 0x0001{C0,,,F8} */
-
-    /* 0x000200-0x000298 -- Device */
-    picreg_t		p_device[4];			/* 0x0002{00,,,18} */
-    picreg_t		_pad_000220[4];			/* 0x0002{20,,,38} */
-    picreg_t		p_wr_req_buf[4];		/* 0x0002{40,,,58} */
-    picreg_t		_pad_000260[4];			/* 0x0002{60,,,78} */
-    picreg_t		p_rrb_map[2];			/* 0x0002{80,,,88} */
-    #define p_even_resp p_rrb_map[0]			/* 0x000280 */
-    #define p_odd_resp  p_rrb_map[1]			/* 0x000288 */
-    picreg_t		p_resp_status;			/* 0x000290 */
-    picreg_t		p_resp_clear;			/* 0x000298 */
-
-    picreg_t		_pad_0002A0[12];		/* 0x0002{A0..F8} */
-
-    /* 0x000300-0x0003F8 -- Buffer Address Match Registers */
-    struct {
-	picreg_t	upper;				/* 0x0003{00,,,F0} */
-	picreg_t	lower;				/* 0x0003{08,,,F8} */
-    } p_buf_addr_match[16];
-
-    /* 0x000400-0x0005FF -- Performance Monitor Registers (even only) */
-    struct {
-	picreg_t	flush_w_touch;			/* 0x000{400,,,5C0} */
-	picreg_t	flush_wo_touch;			/* 0x000{408,,,5C8} */
-	picreg_t	inflight;			/* 0x000{410,,,5D0} */
-	picreg_t	prefetch;			/* 0x000{418,,,5D8} */
-	picreg_t	total_pci_retry;		/* 0x000{420,,,5E0} */
-	picreg_t	max_pci_retry;			/* 0x000{428,,,5E8} */
-	picreg_t	max_latency;			/* 0x000{430,,,5F0} */
-	picreg_t	clear_all;			/* 0x000{438,,,5F8} */
-    } p_buf_count[8];
-
-    
-    /* 0x000600-0x0009FF -- PCI/X registers */
-    picreg_t		p_pcix_bus_err_addr;		/* 0x000600 */
-    picreg_t		p_pcix_bus_err_attr;		/* 0x000608 */
-    picreg_t		p_pcix_bus_err_data;		/* 0x000610 */
-    picreg_t		p_pcix_pio_split_addr;		/* 0x000618 */
-    picreg_t		p_pcix_pio_split_attr;		/* 0x000620 */
-    picreg_t		p_pcix_dma_req_err_attr;	/* 0x000628 */
-    picreg_t		p_pcix_dma_req_err_addr;	/* 0x000630 */
-    picreg_t		p_pcix_timeout;			/* 0x000638 */
-
-    picreg_t		_pad_000640[120];		/* 0x000{640,,,9F8} */
-
-    /* 0x000A00-0x000BFF -- PCI/X Read&Write Buffer */
-    struct {
-	picreg_t	p_buf_addr;			/* 0x000{A00,,,AF0} */
-	picreg_t	p_buf_attr;			/* 0X000{A08,,,AF8} */
-    } p_pcix_read_buf_64[16];
-
-    struct {
-	picreg_t	p_buf_addr;			/* 0x000{B00,,,BE0} */
-	picreg_t	p_buf_attr;			/* 0x000{B08,,,BE8} */
-	picreg_t	p_buf_valid;			/* 0x000{B10,,,BF0} */
-	picreg_t	__pad1;				/* 0x000{B18,,,BF8} */
-    } p_pcix_write_buf_64[8];
-
-    /* End of Local Registers -- Start of Address Map space */
-
-    char		_pad_000c00[0x010000 - 0x000c00];
-
-    /* 0x010000-0x011fff -- Internal ATE RAM (Auto Parity Generation) */
-    picate_t		p_int_ate_ram[1024];		/* 0x010000-0x011fff */
-
-    /* 0x012000-0x013fff -- Internal ATE RAM (Manual Parity Generation) */
-    picate_t		p_int_ate_ram_mp[1024];		/* 0x012000-0x013fff */
-
-    char		_pad_014000[0x18000 - 0x014000];
-
-    /* 0x18000-0x197F8 -- PIC Write Request Ram */
-    picreg_t		p_wr_req_lower[256];		/* 0x18000 - 0x187F8 */
-    picreg_t		p_wr_req_upper[256];		/* 0x18800 - 0x18FF8 */
-    picreg_t		p_wr_req_parity[256];		/* 0x19000 - 0x197F8 */
-
-    char		_pad_019800[0x20000 - 0x019800];
-
-    /* 0x020000-0x027FFF -- PCI Device Configuration Spaces */
-    union {
-	uint8_t		c[0x1000 / 1];			/* 0x02{0000,,,7FFF} */
-	uint16_t	s[0x1000 / 2];			/* 0x02{0000,,,7FFF} */
-	uint32_t	l[0x1000 / 4];			/* 0x02{0000,,,7FFF} */
-	uint64_t	d[0x1000 / 8];			/* 0x02{0000,,,7FFF} */
-	union {
-	    uint8_t	c[0x100 / 1];
-	    uint16_t	s[0x100 / 2];
-	    uint32_t	l[0x100 / 4];
-	    uint64_t	d[0x100 / 8];
-	} f[8];
-    } p_type0_cfg_dev[8];				/* 0x02{0000,,,7FFF} */
-
-    /* 0x028000-0x028FFF -- PCI Type 1 Configuration Space */
-    union {
-	uint8_t		c[0x1000 / 1];			/* 0x028000-0x029000 */
-	uint16_t	s[0x1000 / 2];			/* 0x028000-0x029000 */
-	uint32_t	l[0x1000 / 4];			/* 0x028000-0x029000 */
-	uint64_t	d[0x1000 / 8];			/* 0x028000-0x029000 */
-	union {
-	    uint8_t	c[0x100 / 1];
-	    uint16_t	s[0x100 / 2];
-	    uint32_t	l[0x100 / 4];
-	    uint64_t	d[0x100 / 8];
-	} f[8];
-    } p_type1_cfg;					/* 0x028000-0x029000 */
-
-    char		_pad_029000[0x030000-0x029000];
-
-    /* 0x030000-0x030007 -- PCI Interrupt Acknowledge Cycle */
-    union {
-	uint8_t		c[8 / 1];
-	uint16_t	s[8 / 2];
-	uint32_t	l[8 / 4];
-	uint64_t	d[8 / 8];
-    } p_pci_iack;					/* 0x030000-0x030007 */
-
-    char		_pad_030007[0x040000-0x030008];
-
-    /* 0x040000-0x030007 -- PCIX Special Cycle */
-    union {
-	uint8_t		c[8 / 1];
-	uint16_t	s[8 / 2];
-	uint32_t	l[8 / 4];
-	uint64_t	d[8 / 8];
-    } p_pcix_cycle;					/* 0x040000-0x040007 */
-} pic_t;
-
-#endif                          /* _ASM_IA64_SN_PCI_PIC_H */
diff -Nru a/include/asm-ia64/sn/pda.h b/include/asm-ia64/sn/pda.h
--- a/include/asm-ia64/sn/pda.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-ia64/sn/pda.h	2004-12-24 13:37:19 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
 #ifndef _ASM_IA64_SN_PDA_H
 #define _ASM_IA64_SN_PDA_H
@@ -49,13 +49,14 @@
 	volatile unsigned long *pio_shub_war_cam_addr;
 	volatile unsigned long *mem_write_status_addr;
 
+	struct bteinfo_s *cpu_bte_if[BTES_PER_NODE];	/* cpu interface order */
+
 	unsigned long	sn_soft_irr[4];
 	unsigned long	sn_in_service_ivecs[4];
 	short		cnodeid_to_nasid_table[MAX_NUMNODES];
 	int		sn_lb_int_war_ticks;
 	int		sn_last_irq;
 	int		sn_first_irq;
-	int		sn_num_irqs;			/* number of irqs targeted for this cpu */
 } pda_t;
 
 
diff -Nru a/include/asm-ia64/sn/pio.h b/include/asm-ia64/sn/pio.h
--- a/include/asm-ia64/sn/pio.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,99 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PIO_H
-#define _ASM_IA64_SN_PIO_H
-
-#include <asm/sn/types.h>
-
-/*
- * pioaddr_t	- The kernel virtual address that a PIO can be done upon.
- *		  Should probably be (volatile void*) but EVEREST would do PIO
- *		  to long mostly, just cast for other sizes.
- */
-
-typedef volatile unsigned long*	pioaddr_t;
-
-/*
- * iopaddr_t	- the physical io space relative address (e.g. VME A16S 0x0800).
- * iosapce_t	- specifies the io address space to be mapped/accessed.
- * piomap_t	- the handle returned by pio_alloc() and used with all the pio
- *		  access functions.
- */
-
-
-typedef struct piomap {
-	unsigned int	pio_bus;
-	unsigned int	pio_adap;
-	int		pio_flag;
-	int		pio_reg;
-	char		pio_name[7];	/* to identify the mapped device */
-	struct piomap	*pio_next;	/* dlist to link active piomap's */
-	struct piomap	*pio_prev;	/* for debug and error reporting */
-	iopaddr_t	pio_iopmask;	/* valid iop address bit mask */
-	iobush_t	pio_bushandle;	/* bus-level handle */
-} piomap_t;
-
-#define pio_type	pio_iospace.ios_type
-#define pio_iopaddr	pio_iospace.ios_iopaddr
-#define pio_size	pio_iospace.ios_size
-#define pio_vaddr	pio_iospace.ios_vaddr
-
-/* Macro to get/set PIO error function */
-#define	pio_seterrf(p,f)	(p)->pio_errfunc = (f)
-#define	pio_geterrf(p)		(p)->pio_errfunc
-
-
-/*
- * piomap_t type defines
- */
-
-#define PIOMAP_NTYPES	7
-
-#define PIOMAP_A16N	VME_A16NP
-#define PIOMAP_A16S	VME_A16S
-#define PIOMAP_A24N	VME_A24NP
-#define PIOMAP_A24S	VME_A24S
-#define PIOMAP_A32N	VME_A32NP
-#define PIOMAP_A32S	VME_A32S
-#define PIOMAP_A64	6
-
-#define PIOMAP_EISA_IO	0
-#define PIOMAP_EISA_MEM	1
-
-#define PIOMAP_PCI_IO	0
-#define PIOMAP_PCI_MEM	1
-#define PIOMAP_PCI_CFG	2
-#define PIOMAP_PCI_ID	3
-
-/* IBUS piomap types */
-#define PIOMAP_FCI	0
-
-/* dang gio piomap types */
-
-#define	PIOMAP_GIO32	0
-#define	PIOMAP_GIO64	1
-
-#define ET_MEM         	0
-#define ET_IO          	1
-#define LAN_RAM         2
-#define LAN_IO          3
-
-#define PIOREG_NULL	(-1)
-
-/* standard flags values for pio_map routines,
- * including {xtalk,pciio}_piomap calls.
- * NOTE: try to keep these in step with DMAMAP flags.
- */
-#define PIOMAP_UNFIXED	0x0
-#define PIOMAP_FIXED	0x1
-#define PIOMAP_NOSLEEP	0x2
-#define	PIOMAP_INPLACE	0x4
-
-#define	PIOMAP_FLAGS	0x7
-
-#endif	/* _ASM_IA64_SN_PIO_H */
diff -Nru a/include/asm-ia64/sn/prio.h b/include/asm-ia64/sn/prio.h
--- a/include/asm-ia64/sn/prio.h	2004-12-24 13:36:49 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,38 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_PRIO_H
-#define _ASM_IA64_SN_PRIO_H
-
-#include <linux/types.h>
-
-/*
- * Priority I/O function prototypes and macro definitions
- */
-
-typedef long long bandwidth_t;
-
-/* These should be the same as FREAD/FWRITE */
-#define PRIO_READ_ALLOCATE	0x1
-#define PRIO_WRITE_ALLOCATE	0x2
-#define PRIO_READWRITE_ALLOCATE	(PRIO_READ_ALLOCATE | PRIO_WRITE_ALLOCATE)
-
-extern int prioSetBandwidth (int		/* fd */,
-                             int		/* alloc_type */,
-                             bandwidth_t	/* bytes_per_sec */,
-                             pid_t *		/* pid */);
-extern int prioGetBandwidth (int		/* fd */,
-                             bandwidth_t *	/* read_bw */,
-                             bandwidth_t *	/* write_bw */);
-extern int prioLock (pid_t *);
-extern int prioUnlock (void);
-
-/* Error returns */
-#define PRIO_SUCCESS     0
-#define PRIO_FAIL       (-1) 
-
-#endif /* _ASM_IA64_SN_PRIO_H */
diff -Nru a/include/asm-ia64/sn/router.h b/include/asm-ia64/sn/router.h
--- a/include/asm-ia64/sn/router.h	2004-12-24 13:36:33 -08:00
+++ b/include/asm-ia64/sn/router.h	2004-12-24 13:36:33 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
 
 #ifndef _ASM_IA64_SN_ROUTER_H
@@ -17,10 +17,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <asm/sn/vector.h>
-#include <asm/sn/slotnum.h>
 #include <asm/sn/arch.h>
-#include <asm/sn/sgi.h>
 
 typedef uint64_t	router_reg_t;
 
@@ -411,7 +408,7 @@
 typedef struct router_map_ent_s {
 	uint64_t	nic;
 	moduleid_t	module;
-	slotid_t	slot;
+	char		slot;
 } router_map_ent_t;
 
 struct rr_status_error_fmt {
@@ -479,16 +476,16 @@
 	char		ri_leds;	/* Current LED bitmap		    */
 	char		ri_portmask;	/* Active port bitmap		    */
 	router_reg_t	ri_stat_rev_id;	/* Status rev ID value		    */
-	net_vec_t	ri_vector;	/* vector from guardian to router   */
+	uint64_t	ri_vector;	/* vector from guardian to router   */
 	int		ri_writeid;	/* router's vector write ID	    */
 	int64_t	ri_timebase;	/* Time of first sample		    */
 	int64_t	ri_timestamp;	/* Time of last sample		    */
 	router_port_info_t ri_port[MAX_ROUTER_PORTS]; /* per port info      */
 	moduleid_t	ri_module;	/* Which module are we in?	    */
-	slotid_t	ri_slotnum;	/* Which slot are we in?	    */
+	char		ri_slotnum;	/* Which slot are we in?	    */
 	router_reg_t	ri_glbl_parms[GLBL_PARMS_REGS];
 					/* Global parms0&1 register contents*/
-	vertex_hdl_t	ri_vertex;	/* hardware graph vertex            */
+	void *		ri_vertex;	/* hardware graph vertex            */
 	router_reg_t	ri_prot_conf;	/* protection config. register	    */
 	int64_t	ri_per_minute;	/* Ticks per minute		    */
 
@@ -500,7 +497,7 @@
  	 * the bottom of the structure, below the user stuff.
 	 */
 	char		ri_hist_type;   /* histogram type		    */
-	vertex_hdl_t	ri_guardian;	/* guardian node for the router	    */
+	void *		ri_guardian;	/* guardian node for the router	    */
 	int64_t	ri_last_print;	/* When did we last print	    */
 	char		ri_print;	/* Should we print 		    */
 	char 		ri_just_blink;	/* Should we blink the LEDs         */
@@ -509,7 +506,7 @@
 	int64_t	ri_deltatime;	/* Time it took to sample	    */
 #endif
 	spinlock_t	ri_lock;	/* Lock for access to router info   */
-	net_vec_t	*ri_vecarray;	/* Pointer to array of vectors	    */
+	uint64_t	*ri_vecarray;	/* Pointer to array of vectors	    */
 	struct lboard_s	*ri_brd;	/* Pointer to board structure	    */
 	char *		ri_name;	/* This board's hwg path 	    */
         unsigned char	ri_port_maint[MAX_ROUTER_PORTS]; /* should we send a 
@@ -526,13 +523,13 @@
  * Router info hanging in the nodepda 
  */
 typedef struct nodepda_router_info_s {
-	vertex_hdl_t 	router_vhdl;	/* vertex handle of the router 	    */
+	void *	 	router_vhdl;	/* vertex handle of the router 	    */
 	short		router_port;	/* port thru which we entered       */
 	short		router_portmask;
 	moduleid_t	router_module;	/* module in which router is there  */
-	slotid_t	router_slot;	/* router slot			    */
+	char		router_slot;	/* router slot			    */
 	unsigned char	router_type;	/* kind of router 		    */
-	net_vec_t	router_vector;	/* vector from the guardian node    */
+	uint64_t	router_vector;	/* vector from the guardian node    */
 
 	router_info_t	*router_infop;	/* info hanging off the hwg vertex  */
 	struct nodepda_router_info_s *router_next;
@@ -560,7 +557,7 @@
 			/* vector route from the master hub to 
 			 * this router.
 			 */
-			net_vec_t	vec;	
+			uint64_t	vec;	
 			/* port status */
 			uint64_t	status;	
 			char		port_status[MAX_ROUTER_PORTS + 1];
@@ -570,11 +567,11 @@
 		 */
 		struct {
 			/* vertex handle for the router */
-			vertex_hdl_t	vhdl;
+			void *		vhdl;
 			/* guardian for this router */
-			vertex_hdl_t	guard;	
+			void *		guard;	
 			/* vector router from the guardian to the router */
-			net_vec_t	vec;
+			uint64_t	vec;
 		} k_elt;
 	} u;
 	                        /* easy to use port status interpretation */
@@ -617,25 +614,5 @@
 
 #define RTABLE_SHFT(_L)		(4 * ((_L) - 1))
 #define RTABLE_MASK(_L)		(0x7UL << RTABLE_SHFT(_L))
-
-
-#define	ROUTERINFO_STKSZ	4096
-
-#ifndef __ASSEMBLY__
-
-int router_reg_read(router_info_t *rip, int regno, router_reg_t *val);
-int router_reg_write(router_info_t *rip, int regno, router_reg_t val);
-int router_get_info(vertex_hdl_t routerv, router_info_t *, int);
-int router_set_leds(router_info_t *rip);
-void router_print_state(router_info_t *rip, int level,
-		   void (*pf)(int, char *, ...),int print_where);
-void capture_router_stats(router_info_t *rip);
-
-
-int 	probe_routers(void);
-void 	get_routername(unsigned char brd_type,char *rtrname);
-void 	router_guardians_set(vertex_hdl_t hwgraph_root);
-int 	router_hist_reselect(router_info_t *, int64_t);
-#endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_IA64_SN_ROUTER_H */
diff -Nru a/include/asm-ia64/sn/rw_mmr.h b/include/asm-ia64/sn/rw_mmr.h
--- a/include/asm-ia64/sn/rw_mmr.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-ia64/sn/rw_mmr.h	2004-12-24 13:36:17 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (C) 2002-2004 Silicon Graphics, Inc.  All Rights Reserved.
  */
 #ifndef _ASM_IA64_SN_RW_MMR_H
 #define _ASM_IA64_SN_RW_MMR_H
diff -Nru a/include/asm-ia64/sn/sgi.h b/include/asm-ia64/sn/sgi.h
--- a/include/asm-ia64/sn/sgi.h	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,83 +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) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-
-#ifndef _ASM_IA64_SN_SGI_H
-#define _ASM_IA64_SN_SGI_H
-
-#include <linux/config.h>
-
-#include <asm/sn/types.h>
-#include <asm/sn/hwgfs.h>
-
-typedef hwgfs_handle_t vertex_hdl_t;
-
-/* Nice general name length that lots of people like to use */
-#ifndef MAXDEVNAME
-#define MAXDEVNAME 256
-#endif
-
-
-/*
- * Possible return values from graph routines.
- */
-typedef enum graph_error_e {
-	GRAPH_SUCCESS,		/* 0 */
-	GRAPH_DUP,		/* 1 */
-	GRAPH_NOT_FOUND,	/* 2 */
-	GRAPH_BAD_PARAM,	/* 3 */
-	GRAPH_HIT_LIMIT,	/* 4 */
-	GRAPH_CANNOT_ALLOC,	/* 5 */
-	GRAPH_ILLEGAL_REQUEST,	/* 6 */
-	GRAPH_IN_USE		/* 7 */
-} graph_error_t;
-
-#define CNODEID_NONE ((cnodeid_t)-1)
-#define CPU_NONE		(-1)
-#define GRAPH_VERTEX_NONE ((vertex_hdl_t)-1)
-
-/*
- * Defines for individual WARs. Each is a bitmask of applicable
- * part revision numbers. (1 << 1) == rev A, (1 << 2) == rev B,
- * (3 << 1) == (rev A or rev B), etc
- */
-#define PV854697 (~0)     /* PIC: write 64bit regs as 64bits. permanent */
-#define PV854827 (~0UL)   /* PIC: fake widget 0xf presence bit. permanent */
-#define PV855271 (1 << 1) /* PIC: use virt chan iff 64-bit device. */
-#define PV878674 (~0)     /* PIC: Dont allow 64bit PIOs.  permanent */
-#define PV855272 (1 << 1) /* PIC: runaway interrupt WAR */
-#define PV856155 (1 << 1) /* PIC: arbitration WAR */
-#define PV856864 (1 << 1) /* PIC: lower timeout to free TNUMs quicker */
-#define PV856866 (1 << 1) /* PIC: avoid rrb's 0/1/8/9. */
-#define PV862253 (1 << 1) /* PIC: don't enable write req RAM parity checking */
-#define PV867308 (3 << 1) /* PIC: make LLP error interrupts FATAL for PIC */
-
-/*
- * No code is complete without an Assertion macro
- */
-
-#if defined(DISABLE_ASSERT)
-#define ASSERT(expr)
-#define ASSERT_ALWAYS(expr)
-#else
-#define ASSERT(expr)  do {	\
-        if(!(expr)) { \
-		printk( "Assertion [%s] failed! %s:%s(line=%d)\n",\
-			#expr,__FILE__,__FUNCTION__,__LINE__); \
-		panic("Assertion panic\n"); 	\
-        } } while(0)
-
-#define ASSERT_ALWAYS(expr)	do {\
-        if(!(expr)) { \
-		printk( "Assertion [%s] failed! %s:%s(line=%d)\n",\
-			#expr,__FILE__,__FUNCTION__,__LINE__); \
-		panic("Assertion always panic\n"); 	\
-        } } while(0)
-#endif	/* DISABLE_ASSERT */
-
-#endif /* _ASM_IA64_SN_SGI_H */
diff -Nru a/include/asm-ia64/sn/shub_mmr.h b/include/asm-ia64/sn/shub_mmr.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-ia64/sn/shub_mmr.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,404 @@
+/*
+ *
+ * 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-2004 Silicon Graphics, Inc.  All rights reserved.
+ */
+
+#ifndef _ASM_IA64_SN_SHUB_MMR_H
+#define _ASM_IA64_SN_SHUB_MMR_H
+
+/* ==================================================================== */
+/*                        Register "SH_IPI_INT"                         */
+/*               SHub Inter-Processor Interrupt Registers               */
+/* ==================================================================== */
+#define SH_IPI_INT                               0x0000000110000380UL
+#define SH_IPI_INT_MASK                          0x8ff3ffffffefffffUL
+#define SH_IPI_INT_INIT                          0x0000000000000000UL
+
+/*   SH_IPI_INT_TYPE                                                    */
+/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
+#define SH_IPI_INT_TYPE_SHFT                     0
+#define SH_IPI_INT_TYPE_MASK                     0x0000000000000007UL
+
+/*   SH_IPI_INT_AGT                                                     */
+/*   Description:  Agent, must be 0 for SHub                            */
+#define SH_IPI_INT_AGT_SHFT                      3
+#define SH_IPI_INT_AGT_MASK                      0x0000000000000008UL
+
+/*   SH_IPI_INT_PID                                                     */
+/*   Description:  Processor ID, same setting as on targeted McKinley  */
+#define SH_IPI_INT_PID_SHFT                      4
+#define SH_IPI_INT_PID_MASK                      0x00000000000ffff0UL
+
+/*   SH_IPI_INT_BASE                                                    */
+/*   Description:  Optional interrupt vector area, 2MB aligned          */
+#define SH_IPI_INT_BASE_SHFT                     21
+#define SH_IPI_INT_BASE_MASK                     0x0003ffffffe00000UL
+
+/*   SH_IPI_INT_IDX                                                     */
+/*   Description:  Targeted McKinley interrupt vector                   */
+#define SH_IPI_INT_IDX_SHFT                      52
+#define SH_IPI_INT_IDX_MASK                      0x0ff0000000000000UL
+
+/*   SH_IPI_INT_SEND                                                    */
+/*   Description:  Send Interrupt Message to PI, This generates a puls  */
+#define SH_IPI_INT_SEND_SHFT                     63
+#define SH_IPI_INT_SEND_MASK                     0x8000000000000000UL
+
+/* ==================================================================== */
+/*                     Register "SH_EVENT_OCCURRED"                     */
+/*                    SHub Interrupt Event Occurred                     */
+/* ==================================================================== */
+#define SH_EVENT_OCCURRED                        0x0000000110010000UL
+#define SH_EVENT_OCCURRED_ALIAS                  0x0000000110010008UL
+
+/* ==================================================================== */
+/*                     Register "SH_PI_CAM_CONTROL"                     */
+/*                      CRB CAM MMR Access Control                      */
+/* ==================================================================== */
+#ifndef __ASSEMBLY__
+#define SH_PI_CAM_CONTROL                        0x0000000120050300UL
+#else
+#define SH_PI_CAM_CONTROL                        0x0000000120050300
+#endif
+
+/* ==================================================================== */
+/*                        Register "SH_SHUB_ID"                         */
+/*                            SHub ID Number                            */
+/* ==================================================================== */
+#define SH_SHUB_ID                               0x0000000110060580UL
+#define SH_SHUB_ID_REVISION_SHFT                 28
+#define SH_SHUB_ID_REVISION_MASK                 0x00000000f0000000
+
+/* ==================================================================== */
+/*                         Register "SH_PTC_0"                          */
+/*       Puge Translation Cache Message Configuration Information       */
+/* ==================================================================== */
+#define SH_PTC_0                                 0x00000001101a0000UL
+#define SH_PTC_1                                 0x00000001101a0080UL
+
+/* ==================================================================== */
+/*                          Register "SH_RTC"                           */
+/*                           Real-time Clock                            */
+/* ==================================================================== */
+#define SH_RTC                                   0x00000001101c0000UL
+#define SH_RTC_MASK                              0x007fffffffffffffUL
+
+/* ==================================================================== */
+/*                 Register "SH_MEMORY_WRITE_STATUS_0|1"                */
+/*                    Memory Write Status for CPU 0 & 1                 */
+/* ==================================================================== */
+#define SH_MEMORY_WRITE_STATUS_0                 0x0000000120070000UL
+#define SH_MEMORY_WRITE_STATUS_1                 0x0000000120070080UL
+
+/* ==================================================================== */
+/*                   Register "SH_PIO_WRITE_STATUS_0|1"                 */
+/*                      PIO Write Status for CPU 0 & 1                  */
+/* ==================================================================== */
+#ifndef __ASSEMBLY__
+#define SH_PIO_WRITE_STATUS_0                    0x0000000120070200UL
+#define SH_PIO_WRITE_STATUS_1                    0x0000000120070280UL
+
+/*   SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK                               */
+/*   Description:  Deadlock response detected                           */
+#define SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK_SHFT 1
+#define SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK_MASK 0x0000000000000002
+
+/*   SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT                          */
+/*   Description:  Count of currently pending PIO writes                */
+#define SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_SHFT 56
+#define SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK 0x3f00000000000000UL
+#else
+#define SH_PIO_WRITE_STATUS_0                    0x0000000120070200
+#define SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_SHFT 56
+#define SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK_SHFT 1
+#endif
+
+/* ==================================================================== */
+/*                Register "SH_PIO_WRITE_STATUS_0_ALIAS"                */
+/* ==================================================================== */
+#ifndef __ASSEMBLY__
+#define SH_PIO_WRITE_STATUS_0_ALIAS              0x0000000120070208UL
+#else
+#define SH_PIO_WRITE_STATUS_0_ALIAS              0x0000000120070208
+#endif
+
+/* ==================================================================== */
+/*                     Register "SH_EVENT_OCCURRED"                     */
+/*                    SHub Interrupt Event Occurred                     */
+/* ==================================================================== */
+/*   SH_EVENT_OCCURRED_UART_INT                                         */
+/*   Description:  Pending Junk Bus UART Interrupt                      */
+#define SH_EVENT_OCCURRED_UART_INT_SHFT          20
+#define SH_EVENT_OCCURRED_UART_INT_MASK          0x0000000000100000
+
+/*   SH_EVENT_OCCURRED_IPI_INT                                          */
+/*   Description:  Pending IPI Interrupt                                */
+#define SH_EVENT_OCCURRED_IPI_INT_SHFT           28
+#define SH_EVENT_OCCURRED_IPI_INT_MASK           0x0000000010000000
+
+/*   SH_EVENT_OCCURRED_II_INT0                                          */
+/*   Description:  Pending II 0 Interrupt                               */
+#define SH_EVENT_OCCURRED_II_INT0_SHFT           29
+#define SH_EVENT_OCCURRED_II_INT0_MASK           0x0000000020000000
+
+/*   SH_EVENT_OCCURRED_II_INT1                                          */
+/*   Description:  Pending II 1 Interrupt                               */
+#define SH_EVENT_OCCURRED_II_INT1_SHFT           30
+#define SH_EVENT_OCCURRED_II_INT1_MASK           0x0000000040000000
+
+/* ==================================================================== */
+/*                         Register "SH_PTC_0"                          */
+/*       Puge Translation Cache Message Configuration Information       */
+/* ==================================================================== */
+#define SH_PTC_0                                 0x00000001101a0000UL
+#define SH_PTC_0_MASK                            0x80000000fffffffd
+#define SH_PTC_0_INIT                            0x0000000000000000
+
+/*   SH_PTC_0_A                                                         */
+/*   Description:  Type                                                 */
+#define SH_PTC_0_A_SHFT                          0
+#define SH_PTC_0_A_MASK                          0x0000000000000001
+
+/*   SH_PTC_0_PS                                                        */
+/*   Description:  Page Size                                            */
+#define SH_PTC_0_PS_SHFT                         2
+#define SH_PTC_0_PS_MASK                         0x00000000000000fc
+
+/*   SH_PTC_0_RID                                                       */
+/*   Description:  Region ID                                            */
+#define SH_PTC_0_RID_SHFT                        8
+#define SH_PTC_0_RID_MASK                        0x00000000ffffff00
+
+/*   SH_PTC_0_START                                                     */
+/*   Description:  Start                                                */
+#define SH_PTC_0_START_SHFT                      63
+#define SH_PTC_0_START_MASK                      0x8000000000000000
+
+/* ==================================================================== */
+/*                         Register "SH_PTC_1"                          */
+/*       Puge Translation Cache Message Configuration Information       */
+/* ==================================================================== */
+#define SH_PTC_1                                 0x00000001101a0080UL
+#define SH_PTC_1_MASK                            0x9ffffffffffff000
+#define SH_PTC_1_INIT                            0x0000000000000000
+
+/*   SH_PTC_1_VPN                                                       */
+/*   Description:  Virtual page number                                  */
+#define SH_PTC_1_VPN_SHFT                        12
+#define SH_PTC_1_VPN_MASK                        0x1ffffffffffff000
+
+/*   SH_PTC_1_START                                                     */
+/*   Description:  PTC_1 Start                                          */
+#define SH_PTC_1_START_SHFT                      63
+#define SH_PTC_1_START_MASK                      0x8000000000000000
+
+/*
+ * Register definitions
+ */
+
+/* ==================================================================== */
+/*                    Register "SH_RTC1_INT_CONFIG"                     */
+/*                SHub RTC 1 Interrupt Config Registers                 */
+/* ==================================================================== */
+
+#define SH_RTC1_INT_CONFIG                       0x0000000110001480
+#define SH_RTC1_INT_CONFIG_MASK                  0x0ff3ffffffefffff
+#define SH_RTC1_INT_CONFIG_INIT                  0x0000000000000000
+
+/*   SH_RTC1_INT_CONFIG_TYPE                                            */
+/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
+#define SH_RTC1_INT_CONFIG_TYPE_SHFT             0
+#define SH_RTC1_INT_CONFIG_TYPE_MASK             0x0000000000000007
+
+/*   SH_RTC1_INT_CONFIG_AGT                                             */
+/*   Description:  Agent, must be 0 for SHub                            */
+#define SH_RTC1_INT_CONFIG_AGT_SHFT              3
+#define SH_RTC1_INT_CONFIG_AGT_MASK              0x0000000000000008
+
+/*   SH_RTC1_INT_CONFIG_PID                                             */
+/*   Description:  Processor ID, same setting as on targeted McKinley  */
+#define SH_RTC1_INT_CONFIG_PID_SHFT              4
+#define SH_RTC1_INT_CONFIG_PID_MASK              0x00000000000ffff0
+
+/*   SH_RTC1_INT_CONFIG_BASE                                            */
+/*   Description:  Optional interrupt vector area, 2MB aligned          */
+#define SH_RTC1_INT_CONFIG_BASE_SHFT             21
+#define SH_RTC1_INT_CONFIG_BASE_MASK             0x0003ffffffe00000
+
+/*   SH_RTC1_INT_CONFIG_IDX                                             */
+/*   Description:  Targeted McKinley interrupt vector                   */
+#define SH_RTC1_INT_CONFIG_IDX_SHFT              52
+#define SH_RTC1_INT_CONFIG_IDX_MASK              0x0ff0000000000000
+
+/* ==================================================================== */
+/*                    Register "SH_RTC1_INT_ENABLE"                     */
+/*                SHub RTC 1 Interrupt Enable Registers                 */
+/* ==================================================================== */
+
+#define SH_RTC1_INT_ENABLE                       0x0000000110001500
+#define SH_RTC1_INT_ENABLE_MASK                  0x0000000000000001
+#define SH_RTC1_INT_ENABLE_INIT                  0x0000000000000000
+
+/*   SH_RTC1_INT_ENABLE_RTC1_ENABLE                                     */
+/*   Description:  Enable RTC 1 Interrupt                               */
+#define SH_RTC1_INT_ENABLE_RTC1_ENABLE_SHFT      0
+#define SH_RTC1_INT_ENABLE_RTC1_ENABLE_MASK      0x0000000000000001
+
+/* ==================================================================== */
+/*                    Register "SH_RTC2_INT_CONFIG"                     */
+/*                SHub RTC 2 Interrupt Config Registers                 */
+/* ==================================================================== */
+
+#define SH_RTC2_INT_CONFIG                       0x0000000110001580
+#define SH_RTC2_INT_CONFIG_MASK                  0x0ff3ffffffefffff
+#define SH_RTC2_INT_CONFIG_INIT                  0x0000000000000000
+
+/*   SH_RTC2_INT_CONFIG_TYPE                                            */
+/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
+#define SH_RTC2_INT_CONFIG_TYPE_SHFT             0
+#define SH_RTC2_INT_CONFIG_TYPE_MASK             0x0000000000000007
+
+/*   SH_RTC2_INT_CONFIG_AGT                                             */
+/*   Description:  Agent, must be 0 for SHub                            */
+#define SH_RTC2_INT_CONFIG_AGT_SHFT              3
+#define SH_RTC2_INT_CONFIG_AGT_MASK              0x0000000000000008
+
+/*   SH_RTC2_INT_CONFIG_PID                                             */
+/*   Description:  Processor ID, same setting as on targeted McKinley  */
+#define SH_RTC2_INT_CONFIG_PID_SHFT              4
+#define SH_RTC2_INT_CONFIG_PID_MASK              0x00000000000ffff0
+
+/*   SH_RTC2_INT_CONFIG_BASE                                            */
+/*   Description:  Optional interrupt vector area, 2MB aligned          */
+#define SH_RTC2_INT_CONFIG_BASE_SHFT             21
+#define SH_RTC2_INT_CONFIG_BASE_MASK             0x0003ffffffe00000
+
+/*   SH_RTC2_INT_CONFIG_IDX                                             */
+/*   Description:  Targeted McKinley interrupt vector                   */
+#define SH_RTC2_INT_CONFIG_IDX_SHFT              52
+#define SH_RTC2_INT_CONFIG_IDX_MASK              0x0ff0000000000000
+
+/* ==================================================================== */
+/*                    Register "SH_RTC2_INT_ENABLE"                     */
+/*                SHub RTC 2 Interrupt Enable Registers                 */
+/* ==================================================================== */
+
+#define SH_RTC2_INT_ENABLE                       0x0000000110001600
+#define SH_RTC2_INT_ENABLE_MASK                  0x0000000000000001
+#define SH_RTC2_INT_ENABLE_INIT                  0x0000000000000000
+
+/*   SH_RTC2_INT_ENABLE_RTC2_ENABLE                                     */
+/*   Description:  Enable RTC 2 Interrupt                               */
+#define SH_RTC2_INT_ENABLE_RTC2_ENABLE_SHFT      0
+#define SH_RTC2_INT_ENABLE_RTC2_ENABLE_MASK      0x0000000000000001
+
+/* ==================================================================== */
+/*                    Register "SH_RTC3_INT_CONFIG"                     */
+/*                SHub RTC 3 Interrupt Config Registers                 */
+/* ==================================================================== */
+
+#define SH_RTC3_INT_CONFIG                       0x0000000110001680
+#define SH_RTC3_INT_CONFIG_MASK                  0x0ff3ffffffefffff
+#define SH_RTC3_INT_CONFIG_INIT                  0x0000000000000000
+
+/*   SH_RTC3_INT_CONFIG_TYPE                                            */
+/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
+#define SH_RTC3_INT_CONFIG_TYPE_SHFT             0
+#define SH_RTC3_INT_CONFIG_TYPE_MASK             0x0000000000000007
+
+/*   SH_RTC3_INT_CONFIG_AGT                                             */
+/*   Description:  Agent, must be 0 for SHub                            */
+#define SH_RTC3_INT_CONFIG_AGT_SHFT              3
+#define SH_RTC3_INT_CONFIG_AGT_MASK              0x0000000000000008
+
+/*   SH_RTC3_INT_CONFIG_PID                                             */
+/*   Description:  Processor ID, same setting as on targeted McKinley  */
+#define SH_RTC3_INT_CONFIG_PID_SHFT              4
+#define SH_RTC3_INT_CONFIG_PID_MASK              0x00000000000ffff0
+
+/*   SH_RTC3_INT_CONFIG_BASE                                            */
+/*   Description:  Optional interrupt vector area, 2MB aligned          */
+#define SH_RTC3_INT_CONFIG_BASE_SHFT             21
+#define SH_RTC3_INT_CONFIG_BASE_MASK             0x0003ffffffe00000
+
+/*   SH_RTC3_INT_CONFIG_IDX                                             */
+/*   Description:  Targeted McKinley interrupt vector                   */
+#define SH_RTC3_INT_CONFIG_IDX_SHFT              52
+#define SH_RTC3_INT_CONFIG_IDX_MASK              0x0ff0000000000000
+
+/* ==================================================================== */
+/*                    Register "SH_RTC3_INT_ENABLE"                     */
+/*                SHub RTC 3 Interrupt Enable Registers                 */
+/* ==================================================================== */
+
+#define SH_RTC3_INT_ENABLE                       0x0000000110001700
+#define SH_RTC3_INT_ENABLE_MASK                  0x0000000000000001
+#define SH_RTC3_INT_ENABLE_INIT                  0x0000000000000000
+
+/*   SH_RTC3_INT_ENABLE_RTC3_ENABLE                                     */
+/*   Description:  Enable RTC 3 Interrupt                               */
+#define SH_RTC3_INT_ENABLE_RTC3_ENABLE_SHFT      0
+#define SH_RTC3_INT_ENABLE_RTC3_ENABLE_MASK      0x0000000000000001
+
+/*   SH_EVENT_OCCURRED_RTC1_INT                                         */
+/*   Description:  Pending RTC 1 Interrupt                              */
+#define SH_EVENT_OCCURRED_RTC1_INT_SHFT          24
+#define SH_EVENT_OCCURRED_RTC1_INT_MASK          0x0000000001000000
+
+/*   SH_EVENT_OCCURRED_RTC2_INT                                         */
+/*   Description:  Pending RTC 2 Interrupt                              */
+#define SH_EVENT_OCCURRED_RTC2_INT_SHFT          25
+#define SH_EVENT_OCCURRED_RTC2_INT_MASK          0x0000000002000000
+
+/*   SH_EVENT_OCCURRED_RTC3_INT                                         */
+/*   Description:  Pending RTC 3 Interrupt                              */
+#define SH_EVENT_OCCURRED_RTC3_INT_SHFT          26
+#define SH_EVENT_OCCURRED_RTC3_INT_MASK          0x0000000004000000
+
+/* ==================================================================== */
+/*                        Register "SH_INT_CMPB"                        */
+/*                  RTC Compare Value for Processor B                   */
+/* ==================================================================== */
+
+#define SH_INT_CMPB                              0x00000001101b0080
+#define SH_INT_CMPB_MASK                         0x007fffffffffffff
+#define SH_INT_CMPB_INIT                         0x0000000000000000
+
+/*   SH_INT_CMPB_REAL_TIME_CMPB                                         */
+/*   Description:  Real Time Clock Compare                              */
+#define SH_INT_CMPB_REAL_TIME_CMPB_SHFT          0
+#define SH_INT_CMPB_REAL_TIME_CMPB_MASK          0x007fffffffffffff
+
+/* ==================================================================== */
+/*                        Register "SH_INT_CMPC"                        */
+/*                  RTC Compare Value for Processor C                   */
+/* ==================================================================== */
+
+#define SH_INT_CMPC                              0x00000001101b0100
+#define SH_INT_CMPC_MASK                         0x007fffffffffffff
+#define SH_INT_CMPC_INIT                         0x0000000000000000
+
+/*   SH_INT_CMPC_REAL_TIME_CMPC                                         */
+/*   Description:  Real Time Clock Compare                              */
+#define SH_INT_CMPC_REAL_TIME_CMPC_SHFT          0
+#define SH_INT_CMPC_REAL_TIME_CMPC_MASK          0x007fffffffffffff
+
+/* ==================================================================== */
+/*                        Register "SH_INT_CMPD"                        */
+/*                  RTC Compare Value for Processor D                   */
+/* ==================================================================== */
+
+#define SH_INT_CMPD                              0x00000001101b0180
+#define SH_INT_CMPD_MASK                         0x007fffffffffffff
+#define SH_INT_CMPD_INIT                         0x0000000000000000
+
+/*   SH_INT_CMPD_REAL_TIME_CMPD                                         */
+/*   Description:  Real Time Clock Compare                              */
+#define SH_INT_CMPD_REAL_TIME_CMPD_SHFT          0
+#define SH_INT_CMPD_REAL_TIME_CMPD_MASK          0x007fffffffffffff
+
+#endif /* _ASM_IA64_SN_SHUB_MMR_H */
diff -Nru a/include/asm-ia64/sn/simulator.h b/include/asm-ia64/sn/simulator.h
--- a/include/asm-ia64/sn/simulator.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-ia64/sn/simulator.h	2004-12-24 13:37:43 -08:00
@@ -1,12 +1,12 @@
-#ifndef _ASM_IA64_SN_SIMULATOR_H
-#define _ASM_IA64_SN_SIMULATOR_H
-
 /*
  * 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-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
  */
+
+#ifndef _ASM_IA64_SN_SIMULATOR_H
+#define _ASM_IA64_SN_SIMULATOR_H
 
 #include <linux/config.h>
 
diff -Nru a/include/asm-ia64/sn/slotnum.h b/include/asm-ia64/sn/slotnum.h
--- a/include/asm-ia64/sn/slotnum.h	2004-12-24 13:37:30 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,16 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_SLOTNUM_H
-#define _ASM_IA64_SN_SLOTNUM_H
-
-
-typedef	unsigned char slotid_t;
-
-#include <asm/sn/sn2/slotnum.h>
-
-#endif /* _ASM_IA64_SN_SLOTNUM_H */
diff -Nru a/include/asm-ia64/sn/sn2/addrs.h b/include/asm-ia64/sn/sn2/addrs.h
--- a/include/asm-ia64/sn/sn2/addrs.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,169 +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) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
- */
-
-#ifndef _ASM_IA64_SN_SN2_ADDRS_H
-#define _ASM_IA64_SN_SN2_ADDRS_H
-
-/* McKinley Address Format:
- *
- *   4 4       3 3  3 3
- *   9 8       8 7  6 5             0
- *  +-+---------+----+--------------+
- *  |0| Node ID | AS | Node Offset  |
- *  +-+---------+----+--------------+
- *
- *   Node ID: If bit 38 = 1, is ICE, else is SHUB
- *   AS: Address Space Identifier. Used only if bit 38 = 0.
- *     b'00: Local Resources and MMR space
- *           bit 35
- *               0: Local resources space
- *                  node id:
- *                        0: IA64/NT compatibility space
- *                        2: Local MMR Space
- *                        4: Local memory, regardless of local node id
- *               1: Global MMR space
- *     b'01: GET space.
- *     b'10: AMO space.
- *     b'11: Cacheable memory space.
- *
- *   NodeOffset: byte offset
- */
-
-#ifndef __ASSEMBLY__
-typedef union ia64_sn2_pa {
-	struct {
-		unsigned long off  : 36;
-		unsigned long as   : 2;
-		unsigned long nasid: 11;
-		unsigned long fill : 15;
-	} f;
-	unsigned long l;
-	void *p;
-} ia64_sn2_pa_t;
-#endif
-
-#define TO_PHYS_MASK		0x0001ffcfffffffff	/* Note - clear AS bits */
-
-
-/* Regions determined by AS */
-#define LOCAL_MMR_SPACE		0xc000008000000000	/* Local MMR space */
-#define LOCAL_PHYS_MMR_SPACE	0x8000008000000000	/* Local PhysicalMMR space */
-#define LOCAL_MEM_SPACE		0xc000010000000000	/* Local Memory space */
-#define GLOBAL_MMR_SPACE	0xc000000800000000	/* Global MMR space */
-#define GLOBAL_PHYS_MMR_SPACE	0x0000000800000000	/* Global Physical MMR space */
-#define GET_SPACE		0xe000001000000000	/* GET space */
-#define AMO_SPACE		0xc000002000000000	/* AMO space */
-#define CACHEABLE_MEM_SPACE	0xe000003000000000	/* Cacheable memory space */
-#define UNCACHED                0xc000000000000000      /* UnCacheable memory space */
-#define UNCACHED_PHYS           0x8000000000000000      /* UnCacheable physical memory space */
-
-#define PHYS_MEM_SPACE		0x0000003000000000	/* physical memory space */
-
-/* SN2 address macros */
-#define NID_SHFT		38
-#define LOCAL_MMR_ADDR(a)	(UNCACHED | LOCAL_MMR_SPACE | (a))
-#define LOCAL_MMR_PHYS_ADDR(a)	(UNCACHED_PHYS | LOCAL_PHYS_MMR_SPACE | (a))
-#define LOCAL_MEM_ADDR(a)	(LOCAL_MEM_SPACE | (a))
-#define REMOTE_ADDR(n,a)	((((unsigned long)(n))<<NID_SHFT) | (a))
-#define GLOBAL_MMR_ADDR(n,a)	(UNCACHED | GLOBAL_MMR_SPACE | REMOTE_ADDR(n,a))
-#define GLOBAL_MMR_PHYS_ADDR(n,a) (UNCACHED_PHYS | GLOBAL_PHYS_MMR_SPACE | REMOTE_ADDR(n,a))
-#define GET_ADDR(n,a)		(GET_SPACE | REMOTE_ADDR(n,a))
-#define AMO_ADDR(n,a)		(UNCACHED | AMO_SPACE | REMOTE_ADDR(n,a))
-#define GLOBAL_MEM_ADDR(n,a)	(CACHEABLE_MEM_SPACE | REMOTE_ADDR(n,a))
-
-/* non-II mmr's start at top of big window space (4G) */
-#define BWIN_TOP		0x0000000100000000
-
-/*
- * general address defines - for code common to SN0/SN1/SN2
- */
-#define CAC_BASE		CACHEABLE_MEM_SPACE			/* cacheable memory space */
-#define IO_BASE			(UNCACHED | GLOBAL_MMR_SPACE)		/* lower 4G maps II's XIO space */
-#define AMO_BASE		(UNCACHED | AMO_SPACE)			/* fetch & op space */
-#define MSPEC_BASE		AMO_BASE				/* fetch & op space */
-#define UNCAC_BASE		(UNCACHED | CACHEABLE_MEM_SPACE)	/* uncached global memory */
-#define GET_BASE		GET_SPACE				/* momentarily coherent remote mem. */
-#define CALIAS_BASE             LOCAL_CACHEABLE_BASE			/* cached node-local memory */
-#define UALIAS_BASE             (UNCACHED | LOCAL_CACHEABLE_BASE)	/* uncached node-local memory */
-
-#define TO_PHYS(x)              (              ((x) & TO_PHYS_MASK))
-#define TO_CAC(x)               (CAC_BASE    | ((x) & TO_PHYS_MASK))
-#define TO_UNCAC(x)             (UNCAC_BASE  | ((x) & TO_PHYS_MASK))
-#define TO_MSPEC(x)             (MSPEC_BASE  | ((x) & TO_PHYS_MASK))
-#define TO_GET(x)		(GET_BASE    | ((x) & TO_PHYS_MASK))
-#define TO_CALIAS(x)            (CALIAS_BASE | TO_NODE_ADDRSPACE(x))
-#define TO_UALIAS(x)            (UALIAS_BASE | TO_NODE_ADDRSPACE(x))
-#define NODE_SIZE_BITS		36	/* node offset : bits <35:0> */
-#define BWIN_SIZE_BITS		29	/* big window size: 512M */
-#define NASID_BITS		11	/* bits <48:38> */
-#define NASID_BITMASK		(0x7ffULL)
-#define NASID_SHFT		NID_SHFT
-#define NASID_META_BITS		0	/* ???? */
-#define NASID_LOCAL_BITS	7	/* same router as SN1 */
-
-#define NODE_ADDRSPACE_SIZE     (1UL << NODE_SIZE_BITS)
-#define NASID_MASK              ((uint64_t) NASID_BITMASK << NASID_SHFT)
-#define NASID_GET(_pa)          (int) (((uint64_t) (_pa) >>            \
-                                        NASID_SHFT) & NASID_BITMASK)
-#define PHYS_TO_DMA(x)          ( ((x & NASID_MASK) >> 2) |             \
-                                  (x & (NODE_ADDRSPACE_SIZE - 1)) )
-
-#define CHANGE_NASID(n,x)	({ia64_sn2_pa_t _v; _v.l = (long) (x); _v.f.nasid = n; _v.p;})
-
-/*
- * Determine if a physical address should be referenced as cached or uncached. 
- * For now, assume all memory is cached and everything else is noncached.
- * (Later, we may need to special case areas of memory to be reference uncached).
- */
-#define IS_CACHED_ADDRESS(x)	(((x) & PHYS_MEM_SPACE) == PHYS_MEM_SPACE)
-
-
-#ifndef __ASSEMBLY__
-#define NODE_SWIN_BASE(nasid, widget)                                   \
-        ((widget == 0) ? NODE_BWIN_BASE((nasid), SWIN0_BIGWIN)          \
-        : RAW_NODE_SWIN_BASE(nasid, widget))
-#else
-#define NODE_SWIN_BASE(nasid, widget) \
-     (NODE_IO_BASE(nasid) + ((uint64_t) (widget) << SWIN_SIZE_BITS))
-#define LOCAL_SWIN_BASE(widget) \
-	(UNCACHED | LOCAL_MMR_SPACE | (((uint64_t) (widget) << SWIN_SIZE_BITS)))
-#endif /* __ASSEMBLY__ */
-
-/*
- * The following definitions pertain to the IO special address
- * space.  They define the location of the big and little windows
- * of any given node.
- */
-
-#define BWIN_INDEX_BITS         3
-#define BWIN_SIZE               (1UL << BWIN_SIZE_BITS)
-#define BWIN_SIZEMASK           (BWIN_SIZE - 1)
-#define BWIN_WIDGET_MASK        0x7
-#define NODE_BWIN_BASE0(nasid)  (NODE_IO_BASE(nasid) + BWIN_SIZE)
-#define NODE_BWIN_BASE(nasid, bigwin)   (NODE_BWIN_BASE0(nasid) +       \
-                        ((uint64_t) (bigwin) << BWIN_SIZE_BITS))
-
-#define BWIN_WIDGETADDR(addr)   ((addr) & BWIN_SIZEMASK)
-#define BWIN_WINDOWNUM(addr)    (((addr) >> BWIN_SIZE_BITS) & BWIN_WIDGET_MASK)
-
-/*
- * Verify if addr belongs to large window address of node with "nasid"
- *
- *
- * NOTE: "addr" is expected to be XKPHYS address, and NOT physical
- * address
- *
- *
- */
-
-#define NODE_BWIN_ADDR(nasid, addr)     \
-                (((addr) >= NODE_BWIN_BASE0(nasid)) && \
-                 ((addr) < (NODE_BWIN_BASE(nasid, HUB_NUM_BIG_WINDOW) + \
-                                BWIN_SIZE)))
-
-#endif	/* _ASM_IA64_SN_SN2_ADDRS_H */
diff -Nru a/include/asm-ia64/sn/sn2/arch.h b/include/asm-ia64/sn/sn2/arch.h
--- a/include/asm-ia64/sn/sn2/arch.h	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,61 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_SN2_ARCH_H
-#define _ASM_IA64_SN_SN2_ARCH_H
-
-#define CPUS_PER_NODE           4       /* CPUs on a single hub */
-#define CPUS_PER_SUBNODE        4       /* CPUs on a single hub PI */
-
-
-/*
- * This is the maximum number of NASIDS that can be present in a system.
- * (Highest NASID plus one.)
- */
-#define MAX_NASIDS              2048
-
-
-/*
- * This is the maximum number of nodes that can be part of a kernel.
- * Effectively, it's the maximum number of compact node ids (cnodeid_t).
- * This is not necessarily the same as MAX_NASIDS.
- */
-#define MAX_COMPACT_NODES       2048
-
-/*
- * MAX_REGIONS refers to the maximum number of hardware partitioned regions.
- */
-#define	MAX_REGIONS		64
-#define MAX_NONPREMIUM_REGIONS  16
-#define MAX_PREMIUM_REGIONS     MAX_REGIONS
-
-
-/*
- * MAX_PARITIONS refers to the maximum number of logically defined 
- * partitions the system can support.
- */
-#define MAX_PARTITIONS		MAX_REGIONS
-
-
-#define NASID_MASK_BYTES	((MAX_NASIDS + 7) / 8)
-#define CNASID_MASK_BYTES	(NASID_MASK_BYTES / 2)
-
-
-/*
- * 1 FSB per SHUB, with up to 4 cpus per FSB.
- */
-#define NUM_SUBNODES	1
-#define SUBNODE_SHFT	0
-#define SUBNODE_MASK	(0x0 << SUBNODE_SHFT)
-#define LOCALCPU_SHFT	0
-#define LOCALCPU_MASK	(0x3 << LOCALCPU_SHFT)
-#define SUBNODE(slice)	(((slice) & SUBNODE_MASK) >> SUBNODE_SHFT)
-#define LOCALCPU(slice)	(((slice) & LOCALCPU_MASK) >> LOCALCPU_SHFT)
-#define TO_SLICE(subn, local)	(((subn) << SUBNODE_SHFT) | \
-				 ((local) << LOCALCPU_SHFT))
-
-#endif /* _ASM_IA64_SN_SN2_ARCH_H */
diff -Nru a/include/asm-ia64/sn/sn2/geo.h b/include/asm-ia64/sn/sn2/geo.h
--- a/include/asm-ia64/sn/sn2/geo.h	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,108 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#ifndef _ASM_IA64_SN_SN2_GEO_H
-#define _ASM_IA64_SN_SN2_GEO_H
-
-/* Headers required by declarations in this file */
-
-#include <asm/sn/slotnum.h>
-
-
-/* The geoid_t implementation below is based loosely on the pcfg_t
-   implementation in sys/SN/promcfg.h. */
-
-/* Type declaractions */
-
-/* Size of a geoid_t structure (must be before decl. of geoid_u) */
-#define GEOID_SIZE	8	/* Would 16 be better?  The size can
-				   be different on different platforms. */
-
-#define MAX_SLABS	0xe	/* slabs per module */
-
-typedef unsigned char	geo_type_t;
-
-/* Fields common to all substructures */
-typedef struct geo_any_s {
-    moduleid_t	module;		/* The module (box) this h/w lives in */
-    geo_type_t	type;		/* What type of h/w is named by this geoid_t */
-    slabid_t	slab;		/* The logical assembly within the module */
-} geo_any_t;
-
-/* Additional fields for particular types of hardware */
-typedef struct geo_node_s {
-    geo_any_t	any;		/* No additional fields needed */
-} geo_node_t;
-
-typedef struct geo_rtr_s {
-    geo_any_t	any;		/* No additional fields needed */
-} geo_rtr_t;
-
-typedef struct geo_iocntl_s {
-    geo_any_t	any;		/* No additional fields needed */
-} geo_iocntl_t;
-
-typedef struct geo_pcicard_s {
-    geo_iocntl_t	any;
-    char		bus;	/* Bus/widget number */
-    slotid_t		slot;	/* PCI slot number */
-} geo_pcicard_t;
-
-/* Subcomponents of a node */
-typedef struct geo_cpu_s {
-    geo_node_t	node;
-    char	slice;		/* Which CPU on the node */
-} geo_cpu_t;
-
-typedef struct geo_mem_s {
-    geo_node_t	node;
-    char	membus;		/* The memory bus on the node */
-    char	memslot;	/* The memory slot on the bus */
-} geo_mem_t;
-
-
-typedef union geoid_u {
-    geo_any_t	any;
-    geo_node_t	node;
-    geo_iocntl_t	iocntl;
-    geo_pcicard_t	pcicard;
-    geo_rtr_t	rtr;
-    geo_cpu_t	cpu;
-    geo_mem_t	mem;
-    char	padsize[GEOID_SIZE];
-} geoid_t;
-
-
-/* Preprocessor macros */
-
-#define GEO_MAX_LEN	48	/* max. formatted length, plus some pad:
-				   module/001c07/slab/5/node/memory/2/slot/4 */
-
-/* Values for geo_type_t */
-#define GEO_TYPE_INVALID	0
-#define GEO_TYPE_MODULE		1
-#define GEO_TYPE_NODE		2
-#define GEO_TYPE_RTR		3
-#define GEO_TYPE_IOCNTL		4
-#define GEO_TYPE_IOCARD		5
-#define GEO_TYPE_CPU		6
-#define GEO_TYPE_MEM		7
-#define GEO_TYPE_MAX		(GEO_TYPE_MEM+1)
-
-/* Parameter for hwcfg_format_geoid_compt() */
-#define GEO_COMPT_MODULE	1
-#define GEO_COMPT_SLAB		2
-#define GEO_COMPT_IOBUS		3
-#define GEO_COMPT_IOSLOT	4
-#define GEO_COMPT_CPU		5
-#define GEO_COMPT_MEMBUS	6
-#define GEO_COMPT_MEMSLOT	7
-
-#define GEO_INVALID_STR		"<invalid>"
-
-#endif /* _ASM_IA64_SN_SN2_GEO_H */
diff -Nru a/include/asm-ia64/sn/sn2/intr.h b/include/asm-ia64/sn/sn2/intr.h
--- a/include/asm-ia64/sn/sn2/intr.h	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,31 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_SN2_INTR_H
-#define _ASM_IA64_SN_SN2_INTR_H
-
-#define SGI_UART_VECTOR (0xe9)
-#define SGI_SHUB_ERROR_VECTOR   (0xea)
-
-// These two IRQ's are used by partitioning.
-#define SGI_XPC_ACTIVATE		(0x30)
-#define SGI_II_ERROR			(0x31)
-#define SGI_XBOW_ERROR			(0x32)
-#define SGI_PCIBR_ERROR			(0x33)
-#define SGI_ACPI_SCI_INT		(0x34)
-#define SGI_XPC_NOTIFY			(0xe7)
-
-#define IA64_SN2_FIRST_DEVICE_VECTOR	(0x37)
-#define IA64_SN2_LAST_DEVICE_VECTOR	(0xe6)
-
-#define SN2_IRQ_RESERVED        (0x1)
-#define SN2_IRQ_CONNECTED       (0x2)
-#define SN2_IRQ_SHARED		(0x4)
-
-#define SN2_IRQ_PER_HUB         (2048)
-
-#endif /* _ASM_IA64_SN_SN2_INTR_H */
diff -Nru a/include/asm-ia64/sn/sn2/io.h b/include/asm-ia64/sn/sn2/io.h
--- a/include/asm-ia64/sn/sn2/io.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,239 +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) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#ifndef _ASM_SN_SN2_IO_H
-#define _ASM_SN_SN2_IO_H
-#include <linux/compiler.h>
-#include <asm/intrinsics.h>
-
-extern void * sn_io_addr(unsigned long port) __attribute_const__; /* Forward definition */
-extern void sn_mmiob(void); /* Forward definition */
-
-#define __sn_mf_a()   ia64_mfa()
-
-extern void sn_dma_flush(unsigned long);
-
-#define __sn_inb ___sn_inb
-#define __sn_inw ___sn_inw
-#define __sn_inl ___sn_inl
-#define __sn_outb ___sn_outb
-#define __sn_outw ___sn_outw
-#define __sn_outl ___sn_outl
-#define __sn_readb ___sn_readb
-#define __sn_readw ___sn_readw
-#define __sn_readl ___sn_readl
-#define __sn_readq ___sn_readq
-#define __sn_readb_relaxed ___sn_readb_relaxed
-#define __sn_readw_relaxed ___sn_readw_relaxed
-#define __sn_readl_relaxed ___sn_readl_relaxed
-#define __sn_readq_relaxed ___sn_readq_relaxed
-
-/*
- * The following routines are SN Platform specific, called when
- * a reference is made to inX/outX set macros.  SN Platform
- * inX set of macros ensures that Posted DMA writes on the
- * Bridge is flushed.
- *
- * The routines should be self explainatory.
- */
-
-static inline unsigned int
-___sn_inb (unsigned long port)
-{
-	volatile unsigned char *addr;
-	unsigned char ret = -1;
-
-	if ((addr = sn_io_addr(port))) {
-		ret = *addr;
-		__sn_mf_a();
-		sn_dma_flush((unsigned long)addr);
-	}
-	return ret;
-}
-
-static inline unsigned int
-___sn_inw (unsigned long port)
-{
-	volatile unsigned short *addr;
-	unsigned short ret = -1;
-
-	if ((addr = sn_io_addr(port))) {
-		ret = *addr;
-		__sn_mf_a();
-		sn_dma_flush((unsigned long)addr);
-	}
-	return ret;
-}
-
-static inline unsigned int
-___sn_inl (unsigned long port)
-{
-	volatile unsigned int *addr;
-	unsigned int ret = -1;
-
-	if ((addr = sn_io_addr(port))) {
-		ret = *addr;
-		__sn_mf_a();
-		sn_dma_flush((unsigned long)addr);
-	}
-	return ret;
-}
-
-static inline void
-___sn_outb (unsigned char val, unsigned long port)
-{
-	volatile unsigned char *addr;
-
-	if ((addr = sn_io_addr(port))) {
-		*addr = val;
-		sn_mmiob();
-	}
-}
-
-static inline void
-___sn_outw (unsigned short val, unsigned long port)
-{
-	volatile unsigned short *addr;
-
-	if ((addr = sn_io_addr(port))) {
-		*addr = val;
-		sn_mmiob();
-	}
-}
-
-static inline void
-___sn_outl (unsigned int val, unsigned long port)
-{
-	volatile unsigned int *addr;
-
-	if ((addr = sn_io_addr(port))) {
-		*addr = val;
-		sn_mmiob();
-	}
-}
-
-/*
- * The following routines are SN Platform specific, called when 
- * a reference is made to readX/writeX set macros.  SN Platform 
- * readX set of macros ensures that Posted DMA writes on the 
- * Bridge is flushed.
- * 
- * The routines should be self explainatory.
- */
-
-static inline unsigned char
-___sn_readb (void *addr)
-{
-	unsigned char val;
-
-	val = *(volatile unsigned char *)addr;
-	__sn_mf_a();
-	sn_dma_flush((unsigned long)addr);
-        return val;
-}
-
-static inline unsigned short
-___sn_readw (void *addr)
-{
-	unsigned short val;
-
-	val = *(volatile unsigned short *)addr;
-	__sn_mf_a();
-	sn_dma_flush((unsigned long)addr);
-        return val;
-}
-
-static inline unsigned int
-___sn_readl (void *addr)
-{
-	unsigned int val;
-
-	val = *(volatile unsigned int *) addr;
-	__sn_mf_a();
-	sn_dma_flush((unsigned long)addr);
-        return val;
-}
-
-static inline unsigned long
-___sn_readq (void *addr)
-{
-	unsigned long val;
-
-	val = *(volatile unsigned long *) addr;
-	__sn_mf_a();
-	sn_dma_flush((unsigned long)addr);
-        return val;
-}
-
-/*
- * For generic and SN2 kernels, we have a set of fast access
- * PIO macros.	These macros are provided on SN Platform
- * because the normal inX and readX macros perform an
- * additional task of flushing Post DMA request on the Bridge.
- *
- * These routines should be self explainatory.
- */
-
-static inline unsigned int
-sn_inb_fast (unsigned long port)
-{
-	volatile unsigned char *addr = (unsigned char *)port;
-	unsigned char ret;
-
-	ret = *addr;
-	__sn_mf_a();
-	return ret;
-}
-
-static inline unsigned int
-sn_inw_fast (unsigned long port)
-{
-	volatile unsigned short *addr = (unsigned short *)port;
-	unsigned short ret;
-
-	ret = *addr;
-	__sn_mf_a();
-	return ret;
-}
-
-static inline unsigned int
-sn_inl_fast (unsigned long port)
-{
-	volatile unsigned int *addr = (unsigned int *)port;
-	unsigned int ret;
-
-	ret = *addr;
-	__sn_mf_a();
-	return ret;
-}
-
-static inline unsigned char
-___sn_readb_relaxed (void *addr)
-{
-	return *(volatile unsigned char *)addr;
-}
-
-static inline unsigned short
-___sn_readw_relaxed (void *addr)
-{
-	return *(volatile unsigned short *)addr;
-}
-
-static inline unsigned int
-___sn_readl_relaxed (void *addr)
-{
-	return *(volatile unsigned int *) addr;
-}
-
-static inline unsigned long
-___sn_readq_relaxed (void *addr)
-{
-	return *(volatile unsigned long *) addr;
-}
-
-#endif
diff -Nru a/include/asm-ia64/sn/sn2/shub.h b/include/asm-ia64/sn/sn2/shub.h
--- a/include/asm-ia64/sn/sn2/shub.h	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,36 +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) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
- */
-
-
-#ifndef _ASM_IA64_SN_SN2_SHUB_H
-#define _ASM_IA64_SN_SN2_SHUB_H
-
-/*
- * Junk Bus Address Space
- *   The junk bus is used to access the PROM, LED's, and UART. It's 
- *   accessed through the local block MMR space. The data path is
- *   16 bits wide. This space requires address bits 31-27 to be set, and
- *   is further divided by address bits 26:15.
- *   The LED addresses are write-only. To read the LEDs, you need to use
- *   SH_JUNK_BUS_LED0-3, defined in shub_mmr.h
- *		
- */
-#define SH_REAL_JUNK_BUS_LED0           0x7fed00000
-#define SH_REAL_JUNK_BUS_LED1           0x7fed10000
-#define SH_REAL_JUNK_BUS_LED2           0x7fed20000
-#define SH_REAL_JUNK_BUS_LED3           0x7fed30000
-#define SH_JUNK_BUS_UART0               0x7fed40000
-#define SH_JUNK_BUS_UART1               0x7fed40008
-#define SH_JUNK_BUS_UART2               0x7fed40010
-#define SH_JUNK_BUS_UART3               0x7fed40018
-#define SH_JUNK_BUS_UART4               0x7fed40020
-#define SH_JUNK_BUS_UART5               0x7fed40028
-#define SH_JUNK_BUS_UART6               0x7fed40030
-#define SH_JUNK_BUS_UART7               0x7fed40038
-
-#endif /* _ASM_IA64_SN_SN2_SHUB_H */
diff -Nru a/include/asm-ia64/sn/sn2/shub_md.h b/include/asm-ia64/sn/sn2/shub_md.h
--- a/include/asm-ia64/sn/sn2/shub_md.h	2004-12-24 13:37:29 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,275 +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) 2001, 2002-2003 Silicon Graphics, Inc.  All rights reserved.
- */
-
-
-#ifndef _ASM_IA64_SN_SN2_SHUB_MD_H
-#define _ASM_IA64_SN_SN2_SHUB_MD_H
-
-/* SN2 supports a mostly-flat address space with 4 CPU-visible, evenly spaced, 
-   contiguous regions, or "software banks".  On SN2, software bank n begins at 
-   addresses n * 16GB, 0 <= n < 4.  Each bank has a 16GB address space.  If 
-   the 4 dimms do not use up this space there will be holes between the 
-   banks.  Even with these holes the whole memory space within a bank is
-   not addressable address space.  The top 1/32 of each bank is directory
-   memory space and is accessible through bist only.
-
-   Physically a SN2 node board contains 2 daughter cards with 8 dimm sockets
-   each.  A total of 16 dimm sockets arranged as 4 "DIMM banks" of 4 dimms 
-   each.  The data is stripped across the 4 memory busses so all dimms within 
-   a dimm bank must have identical capacity dimms.  Memory is increased or 
-   decreased in sets of 4.  Each dimm bank has 2 dimms on each side.
-
-             Physical Dimm Bank layout.
-                  DTR Card0
-                 ------------
-   Dimm Bank 3   |  MemYL3  |   CS 3
-                 |  MemXL3  |
-                 |----------|
-   Dimm Bank 2   |  MemYL2  |   CS 2
-                 |  MemXL2  |
-                 |----------|
-   Dimm Bank 1   |  MemYL1  |   CS 1
-                 |  MemXL1  |
-                 |----------|
-   Dimm Bank 0   |  MemYL0  |   CS 0 
-                 |  MemXL0  |
-                 ------------
-                  |       |
-                  BUS     BUS
-                  XL      YL
-                  |       |
-                 ------------
-                 |   SHUB   |
-                 |    MD    |
-                 ------------
-                  |       |
-                  BUS     BUS
-                  XR      YR
-                  |       |
-                 ------------
-   Dimm Bank 0   |  MemXR0  |   CS 0
-                 |  MemYR0  |
-                 |----------|
-   Dimm Bank 1   |  MemXR1  |   CS 1
-                 |  MemYR1  |
-                 |----------|
-   Dimm Bank 2   |  MemXR2  |   CS 2
-                 |  MemYR2  |
-                 |----------|
-   Dimm Bank 3   |  MemXR3  |   CS 3
-                 |  MemYR3  |
-                 ------------
-                  DTR Card1
-
-   The dimms can be 1 or 2 sided dimms.  The size and bankness is defined  
-   separately for each dimm bank in the sh_[x,y,jnr]_dimm_cfg MMR register.
-
-   Normally software bank 0 would map directly to physical dimm bank 0.  The 
-   software banks can map to the different physical dimm banks via the 
-   DIMM[0-3]_CS field in SH_[x,y,jnr]_DIMM_CFG for each dimm slot.   
-
-   All the PROM's data structures (promlog variables, klconfig, etc.)
-   track memory by the physical dimm bank number.  The kernel usually
-   tracks memory by the software bank number.
-
- */
-
-
-/* Preprocessor macros */
-#define MD_MEM_BANKS		4
-#define MD_PHYS_BANKS_PER_DIMM  2                  /* dimms may be 2 sided. */
-#define MD_NUM_PHYS_BANKS       (MD_MEM_BANKS * MD_PHYS_BANKS_PER_DIMM)
-#define MD_DIMMS_IN_SLOT	4  /* 4 dimms in each dimm bank.  aka slot */
-
-/* Address bits 35,34 control dimm bank access. */
-#define MD_BANK_SHFT       	34     
-#define MD_BANK_MASK       	(UINT64_CAST 0x3 << MD_BANK_SHFT )
-#define MD_BANK_GET(addr)  	(((addr) & MD_BANK_MASK) >> MD_BANK_SHFT)
-#define MD_BANK_SIZE       	(UINT64_CAST 0x1 << MD_BANK_SHFT ) /* 16 gb */
-#define MD_BANK_OFFSET(_b) 	(UINT64_CAST (_b) << MD_BANK_SHFT)
-
-/*Address bit 12 selects side of dimm if 2bnk dimms present. */
-#define MD_PHYS_BANK_SEL_SHFT   12
-#define MD_PHYS_BANK_SEL_MASK   (UINT64_CAST 0x1 << MD_PHYS_BANK_SEL_SHFT)
-
-/* Address bit 7 determines if data resides on X or Y memory system. 
- * If addr Bit 7 is set the data resides on Y memory system and
- * the corresponing directory entry reside on the X. 
- */
-#define MD_X_OR_Y_SEL_SHFT	7	
-#define MD_X_OR_Y_SEL_MASK	(1 << MD_X_OR_Y_SEL_SHFT)	
-
-/* Address bit 8 determines which directory entry of the pair the address
- * corresponds to.  If addr Bit 8 is set DirB corresponds to the memory address.
- */
-#define MD_DIRA_OR_DIRB_SEL_SHFT	8
-#define MD_DIRA_OR_DIRB_SEL_MASK  	(1 << MD_DIRA_OR_DIRB_SEL_SHFT)	
-
-/* Address bit 11 determines if corresponding directory entry resides 
- * on Left or Right memory bus.  If addr Bit 11 is set the corresponding 
- * directory entry resides on Right memory bus.
- */
-#define MD_L_OR_R_SEL_SHFT	11
-#define MD_L_OR_R_SEL_MASK	(1 << MD_L_OR_R_SEL_SHFT)	
-
-/* DRAM sizes. */
-#define MD_SZ_64_Mb		0x0
-#define MD_SZ_128_Mb		0x1
-#define MD_SZ_256_Mb		0x2
-#define MD_SZ_512_Mb		0x3
-#define MD_SZ_1024_Mb		0x4
-#define MD_SZ_2048_Mb	 	0x5
-#define MD_SZ_UNUSED		0x7
-
-#define MD_DIMM_SIZE_BYTES(_size, _2bk) (				 \
-		( (_size) == 7 ? 0 : ( 0x4000000L << (_size)) << (_2bk)))\
-
-#define MD_DIMM_SIZE_MBYTES(_size, _2bk) (				 \
-	 	( (_size) == 7 ? 0 : ( 0x40L << (_size) ) << (_2bk)))  	 \
-
-/* The top 1/32 of each bank is directory memory, and not accessible
- * via normal reads and writes */
-#define MD_DIMM_USER_SIZE(_size)	((_size) * 31 / 32)
-
-/* Minimum size of a populated bank is 64M (62M usable) */
-#define MIN_BANK_SIZE		MD_DIMM_USER_SIZE((64 * 0x100000))
-#define MIN_BANK_STRING		"62"
-
-
-/*Possible values for FREQ field in sh_[x,y,jnr]_dimm_cfg regs */
-#define MD_DIMM_100_CL2_0 	0x0
-#define MD_DIMM_133_CL2_0 	0x1
-#define MD_DIMM_133_CL2_5 	0x2
-#define MD_DIMM_160_CL2_0 	0x3
-#define MD_DIMM_160_CL2_5 	0x4
-#define MD_DIMM_160_CL3_0 	0x5
-#define MD_DIMM_200_CL2_0 	0x6
-#define MD_DIMM_200_CL2_5 	0x7
-#define MD_DIMM_200_CL3_0 	0x8
-
-/* DIMM_CFG fields */
-#define MD_DIMM_SHFT(_dimm)	((_dimm) << 3)
-#define MD_DIMM_SIZE_MASK(_dimm)					\
-		(SH_JNR_DIMM_CFG_DIMM0_SIZE_MASK << 			\
-		(MD_DIMM_SHFT(_dimm)))
-
-#define MD_DIMM_2BK_MASK(_dimm)						\
-		(SH_JNR_DIMM_CFG_DIMM0_2BK_MASK << 			\
-		MD_DIMM_SHFT(_dimm))
-
-#define MD_DIMM_REV_MASK(_dimm)						\
-		(SH_JNR_DIMM_CFG_DIMM0_REV_MASK << 			\
-		MD_DIMM_SHFT(_dimm))
-
-#define MD_DIMM_CS_MASK(_dimm)						\
-		(SH_JNR_DIMM_CFG_DIMM0_CS_MASK << 			\
-		MD_DIMM_SHFT(_dimm))
-
-#define MD_DIMM_SIZE(_dimm, _cfg)					\
-		(((_cfg) & MD_DIMM_SIZE_MASK(_dimm))			\
-		>> (MD_DIMM_SHFT(_dimm)+SH_JNR_DIMM_CFG_DIMM0_SIZE_SHFT))
-
-#define MD_DIMM_TWO_SIDED(_dimm,_cfg)					\
-		( ((_cfg) & MD_DIMM_2BK_MASK(_dimm))			\
-		>> (MD_DIMM_SHFT(_dimm)+SH_JNR_DIMM_CFG_DIMM0_2BK_SHFT))
-
-#define MD_DIMM_REVERSED(_dimm,_cfg) 					\
-		(((_cfg) & MD_DIMM_REV_MASK(_dimm))			\
-		>> (MD_DIMM_SHFT(_dimm)+SH_JNR_DIMM_CFG_DIMM0_REV_SHFT))
-
-#define MD_DIMM_CS(_dimm,_cfg)						\
-		(((_cfg) & MD_DIMM_CS_MASK(_dimm))			\
-		>> (MD_DIMM_SHFT(_dimm)+SH_JNR_DIMM_CFG_DIMM0_CS_SHFT))
-
-
-
-/* Macros to set MMRs that must be set identically to others. */
-#define MD_SET_DIMM_CFG(_n, _value) {					\
-		REMOTE_HUB_S(_n, SH_X_DIMM_CFG,_value);			\
-                REMOTE_HUB_S(_n, SH_Y_DIMM_CFG, _value);		\
-                REMOTE_HUB_S(_n, SH_JNR_DIMM_CFG, _value);}
-
-#define MD_SET_DQCT_CFG(_n, _value) {					\
-		REMOTE_HUB_S(_n, SH_X_DQCT_CFG,_value);			\
-		REMOTE_HUB_S(_n, SH_Y_DQCT_CFG,_value); }
-
-#define MD_SET_CFG(_n, _value) {					\
-		REMOTE_HUB_S(_n, SH_X_CFG,_value);			\
-		REMOTE_HUB_S(_n, SH_Y_CFG,_value);} 
-
-#define MD_SET_REFRESH_CONTROL(_n, _value) {				\
-		REMOTE_HUB_S(_n, SH_X_REFRESH_CONTROL, _value);		\
-		REMOTE_HUB_S(_n, SH_Y_REFRESH_CONTROL, _value);}
-
-#define MD_SET_DQ_MMR_DIR_COFIG(_n, _value) {				\
-		REMOTE_HUB_S(_n, SH_MD_DQLP_MMR_DIR_CONFIG, _value);	\
-                REMOTE_HUB_S(_n, SH_MD_DQRP_MMR_DIR_CONFIG, _value);}
-
-#define MD_SET_PIOWD_DIR_ENTRYS(_n, _value) {				\
-		REMOTE_HUB_S(_n, SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY, _value);\
-		REMOTE_HUB_S(_n, SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY, _value);}
-
-/* 
- * There are 12 Node Presence MMRs, 4 in each primary DQ and 4 in the
- * LB.  The data in the left and right DQ MMRs and the LB must match.
- */
-#define MD_SET_PRESENT_VEC(_n, _vec, _value) {				   \
-		REMOTE_HUB_S(_n, SH_MD_DQLP_MMR_DIR_PRESVEC0+((_vec)*0x10),\
-			 _value);					   \
-		REMOTE_HUB_S(_n, SH_MD_DQRP_MMR_DIR_PRESVEC0+((_vec)*0x10),\
-			 _value);					   \
-		REMOTE_HUB_S(_n, SH_SHUBS_PRESENT0+((_vec)*0x80), _value);}
-/*
- * There are 16 Privilege Vector MMRs, 8 in each primary DQ.  The data
- * in the corresponding left and right DQ MMRs must match.  Each MMR
- * pair is used for a single partition.
- */
-#define MD_SET_PRI_VEC(_n, _vec, _value) {				  \
-		REMOTE_HUB_S(_n, SH_MD_DQLP_MMR_DIR_PRIVEC0+((_vec)*0x10),\
-			 _value);					  \
-		REMOTE_HUB_S(_n, SH_MD_DQRP_MMR_DIR_PRIVEC0+((_vec)*0x10),\
-			 _value);}
-/*
- * There are 16 Local/Remote MMRs, 8 in each primary DQ.  The data in
- * the corresponding left and right DQ MMRs must match.  Each MMR pair
- * is used for a single partition.
- */
-#define MD_SET_LOC_VEC(_n, _vec, _value) {				\
-		REMOTE_HUB_S(_n, SH_MD_DQLP_MMR_DIR_LOCVEC0+((_vec)*0x10),\
-			 _value);					\
-		REMOTE_HUB_S(_n, SH_MD_DQRP_MMR_DIR_LOCVEC0+((_vec)*0x10),\
-			 _value);}
-
-/* Memory BIST CMDS */
-#define MD_DIMM_INIT_MODE_SET	0x0
-#define MD_DIMM_INIT_REFRESH	0x1
-#define MD_DIMM_INIT_PRECHARGE	0x2
-#define MD_DIMM_INIT_BURST_TERM	0x6
-#define MD_DIMM_INIT_NOP	0x7
-#define MD_DIMM_BIST_READ	0x10
-#define MD_FILL_DIR		0x20
-#define MD_FILL_DATA		0x30
-#define MD_FILL_DIR_ACCESS	0X40
-#define MD_READ_DIR_PAIR	0x50
-#define MD_READ_DIR_TAG		0x60
-
-/* SH_MMRBIST_CTL macros */
-#define MD_BIST_FAIL(_n) (REMOTE_HUB_L(_n, SH_MMRBIST_CTL) &		\
-                SH_MMRBIST_CTL_FAIL_MASK)
-
-#define MD_BIST_IN_PROGRESS(_n) (REMOTE_HUB_L(_n, SH_MMRBIST_CTL) & 	\
-                SH_MMRBIST_CTL_IN_PROGRESS_MASK)
-
-#define MD_BIST_MEM_IDLE(_n); (REMOTE_HUB_L(_n, SH_MMRBIST_CTL) & 	\
-                SH_MMRBIST_CTL_MEM_IDLE_MASK)
-
-/* SH_MMRBIST_ERR macros */
-#define MD_BIST_MISCOMPARE(_n) (REMOTE_HUB_L(_n, SH_MMRBIST_ERR) &	\
-		SH_MMRBIST_ERR_DETECTED_MASK)
-
-#endif	/* _ASM_IA64_SN_SN2_SHUB_MD_H */
diff -Nru a/include/asm-ia64/sn/sn2/shub_mmr.h b/include/asm-ia64/sn/sn2/shub_mmr.h
--- a/include/asm-ia64/sn/sn2/shub_mmr.h	2004-12-24 13:37:03 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,31597 +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) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
- */
-
-
-#ifndef _ASM_IA64_SN_SN2_SHUB_MMR_H
-#define _ASM_IA64_SN_SN2_SHUB_MMR_H
-
-/* ==================================================================== */
-/*                   Register "SH_FSB_BINIT_CONTROL"                    */
-/*                          FSB BINIT# Control                          */
-/* ==================================================================== */
-
-#define SH_FSB_BINIT_CONTROL                     0x0000000120010000
-#define SH_FSB_BINIT_CONTROL_MASK                0x0000000000000001
-#define SH_FSB_BINIT_CONTROL_INIT                0x0000000000000000
-
-/*   SH_FSB_BINIT_CONTROL_BINIT                                         */
-/*   Description:  Assert the FSB's BINIT# Signal                       */
-#define SH_FSB_BINIT_CONTROL_BINIT_SHFT          0
-#define SH_FSB_BINIT_CONTROL_BINIT_MASK          0x0000000000000001
-
-/* ==================================================================== */
-/*                   Register "SH_FSB_RESET_CONTROL"                    */
-/*                          FSB Reset Control                           */
-/* ==================================================================== */
-
-#define SH_FSB_RESET_CONTROL                     0x0000000120010080
-#define SH_FSB_RESET_CONTROL_MASK                0x0000000000000001
-#define SH_FSB_RESET_CONTROL_INIT                0x0000000000000000
-
-/*   SH_FSB_RESET_CONTROL_RESET                                         */
-/*   Description:  Assert the FSB's RESET# Signal                       */
-#define SH_FSB_RESET_CONTROL_RESET_SHFT          0
-#define SH_FSB_RESET_CONTROL_RESET_MASK          0x0000000000000001
-
-/* ==================================================================== */
-/*                Register "SH_FSB_SYSTEM_AGENT_CONFIG"                 */
-/*                    FSB System Agent Configuration                    */
-/* ==================================================================== */
-
-#define SH_FSB_SYSTEM_AGENT_CONFIG               0x0000000120010100
-#define SH_FSB_SYSTEM_AGENT_CONFIG_MASK          0x00003fff0187fff9
-#define SH_FSB_SYSTEM_AGENT_CONFIG_INIT          0x0000000000000000
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_RCNT_SCNT_EN                            */
-/*   Description:  RCNT/SCNT Assertion Enabled                          */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_RCNT_SCNT_EN_SHFT 0
-#define SH_FSB_SYSTEM_AGENT_CONFIG_RCNT_SCNT_EN_MASK 0x0000000000000001
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_BERR_ASSERT_EN                          */
-/*   Description:  BERR Assertion Enabled for Bus Errors                */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BERR_ASSERT_EN_SHFT 3
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BERR_ASSERT_EN_MASK 0x0000000000000008
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_BERR_SAMPLING_EN                        */
-/*   Description:  BERR Sampling Enabled                                */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BERR_SAMPLING_EN_SHFT 4
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BERR_SAMPLING_EN_MASK 0x0000000000000010
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_BINIT_ASSERT_EN                         */
-/*   Description:  BINIT Assertion Enabled                              */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BINIT_ASSERT_EN_SHFT 5
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BINIT_ASSERT_EN_MASK 0x0000000000000020
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_BNR_THROTTLING_EN                       */
-/*   Description:  stutter FSB request assertion                        */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BNR_THROTTLING_EN_SHFT 6
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BNR_THROTTLING_EN_MASK 0x0000000000000040
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_SHORT_HANG_EN                           */
-/*   Description:  use short duration hang timeout                      */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_SHORT_HANG_EN_SHFT 7
-#define SH_FSB_SYSTEM_AGENT_CONFIG_SHORT_HANG_EN_MASK 0x0000000000000080
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_INTA_RSP_DATA                           */
-/*   Description:  Interrupt Acknowledge Response Data                  */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_INTA_RSP_DATA_SHFT 8
-#define SH_FSB_SYSTEM_AGENT_CONFIG_INTA_RSP_DATA_MASK 0x000000000000ff00
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_IO_TRANS_RSP                            */
-/*   Description:  IO Transaction Response                              */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_IO_TRANS_RSP_SHFT 16
-#define SH_FSB_SYSTEM_AGENT_CONFIG_IO_TRANS_RSP_MASK 0x0000000000010000
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_XTPR_TRANS_RSP                          */
-/*   Description:  External Task Priority Register (xTPR) Transaction   */
-/*  Response                                                            */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_XTPR_TRANS_RSP_SHFT 17
-#define SH_FSB_SYSTEM_AGENT_CONFIG_XTPR_TRANS_RSP_MASK 0x0000000000020000
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_INTA_TRANS_RSP                          */
-/*   Description:  Interrupt Acknowledge Transaction Response           */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_INTA_TRANS_RSP_SHFT 18
-#define SH_FSB_SYSTEM_AGENT_CONFIG_INTA_TRANS_RSP_MASK 0x0000000000040000
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_TDOT                                    */
-/*   Description:  Throttle Data-bus Ownership Transitions              */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_TDOT_SHFT     23
-#define SH_FSB_SYSTEM_AGENT_CONFIG_TDOT_MASK     0x0000000000800000
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_SERIALIZE_FSB_EN                        */
-/*   Description:  serialize processor transactions                     */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_SERIALIZE_FSB_EN_SHFT 24
-#define SH_FSB_SYSTEM_AGENT_CONFIG_SERIALIZE_FSB_EN_MASK 0x0000000001000000
-
-/*   SH_FSB_SYSTEM_AGENT_CONFIG_BINIT_EVENT_ENABLES                     */
-/*   Description:  FSB error binit enables                              */
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BINIT_EVENT_ENABLES_SHFT 32
-#define SH_FSB_SYSTEM_AGENT_CONFIG_BINIT_EVENT_ENABLES_MASK 0x00003fff00000000
-
-/* ==================================================================== */
-/*                     Register "SH_FSB_VGA_REMAP"                      */
-/*                     FSB VGA Address Space Remap                      */
-/* ==================================================================== */
-
-#define SH_FSB_VGA_REMAP                         0x0000000120010180
-#define SH_FSB_VGA_REMAP_MASK                    0x4001fffffffe0000
-#define SH_FSB_VGA_REMAP_INIT                    0x0000000000000000
-
-/*   SH_FSB_VGA_REMAP_OFFSET                                            */
-/*   Description:  VGA Remap Node Offset                                */
-#define SH_FSB_VGA_REMAP_OFFSET_SHFT             17
-#define SH_FSB_VGA_REMAP_OFFSET_MASK             0x0000000ffffe0000
-
-/*   SH_FSB_VGA_REMAP_ASID                                              */
-/*   Description:  VGA Remap Address Space ID                           */
-#define SH_FSB_VGA_REMAP_ASID_SHFT               36
-#define SH_FSB_VGA_REMAP_ASID_MASK               0x0000003000000000
-
-/*   SH_FSB_VGA_REMAP_NID                                               */
-/*   Description:  VGA Remap Node ID                                    */
-#define SH_FSB_VGA_REMAP_NID_SHFT                38
-#define SH_FSB_VGA_REMAP_NID_MASK                0x0001ffc000000000
-
-/*   SH_FSB_VGA_REMAP_VGA_REMAPPING_ENABLED                             */
-/*   Description:  VGA Remapping Enabled                                */
-#define SH_FSB_VGA_REMAP_VGA_REMAPPING_ENABLED_SHFT 62
-#define SH_FSB_VGA_REMAP_VGA_REMAPPING_ENABLED_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_FSB_RESET_STATUS"                    */
-/*                           FSB Reset Status                           */
-/* ==================================================================== */
-
-#define SH_FSB_RESET_STATUS                      0x0000000120020000
-#define SH_FSB_RESET_STATUS_MASK                 0x0000000000000001
-#define SH_FSB_RESET_STATUS_INIT                 0x0000000000000000
-
-/*   SH_FSB_RESET_STATUS_RESET_IN_PROGRESS                              */
-/*   Description:  Reset in Progress                                    */
-#define SH_FSB_RESET_STATUS_RESET_IN_PROGRESS_SHFT 0
-#define SH_FSB_RESET_STATUS_RESET_IN_PROGRESS_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*               Register "SH_FSB_SYMMETRIC_AGENT_STATUS"               */
-/*                      FSB Symmetric Agent Status                      */
-/* ==================================================================== */
-
-#define SH_FSB_SYMMETRIC_AGENT_STATUS            0x0000000120020080
-#define SH_FSB_SYMMETRIC_AGENT_STATUS_MASK       0x0000000000000007
-#define SH_FSB_SYMMETRIC_AGENT_STATUS_INIT       0x0000000000000000
-
-/*   SH_FSB_SYMMETRIC_AGENT_STATUS_CPU_0_ACTIVE                         */
-/*   Description:  CPU 0 Active.                                        */
-#define SH_FSB_SYMMETRIC_AGENT_STATUS_CPU_0_ACTIVE_SHFT 0
-#define SH_FSB_SYMMETRIC_AGENT_STATUS_CPU_0_ACTIVE_MASK 0x0000000000000001
-
-/*   SH_FSB_SYMMETRIC_AGENT_STATUS_CPU_1_ACTIVE                         */
-/*   Description:  CPU 1 Active.                                        */
-#define SH_FSB_SYMMETRIC_AGENT_STATUS_CPU_1_ACTIVE_SHFT 1
-#define SH_FSB_SYMMETRIC_AGENT_STATUS_CPU_1_ACTIVE_MASK 0x0000000000000002
-
-/*   SH_FSB_SYMMETRIC_AGENT_STATUS_CPUS_READY                           */
-/*   Description:  The Processors are Ready                             */
-#define SH_FSB_SYMMETRIC_AGENT_STATUS_CPUS_READY_SHFT 2
-#define SH_FSB_SYMMETRIC_AGENT_STATUS_CPUS_READY_MASK 0x0000000000000004
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_CREDIT_COUNT_0"                   */
-/*                Graphics-write Credit Count for CPU 0                 */
-/* ==================================================================== */
-
-#define SH_GFX_CREDIT_COUNT_0                    0x0000000120030000
-#define SH_GFX_CREDIT_COUNT_0_MASK               0x80000000000fffff
-#define SH_GFX_CREDIT_COUNT_0_INIT               0x000000000000003f
-
-/*   SH_GFX_CREDIT_COUNT_0_COUNT                                        */
-/*   Description:  Credit Count                                         */
-#define SH_GFX_CREDIT_COUNT_0_COUNT_SHFT         0
-#define SH_GFX_CREDIT_COUNT_0_COUNT_MASK         0x00000000000fffff
-
-/*   SH_GFX_CREDIT_COUNT_0_RESET_GFX_STATE                              */
-/*   Description:  Reset GFX state                                      */
-#define SH_GFX_CREDIT_COUNT_0_RESET_GFX_STATE_SHFT 63
-#define SH_GFX_CREDIT_COUNT_0_RESET_GFX_STATE_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_CREDIT_COUNT_1"                   */
-/*                Graphics-write Credit Count for CPU 1                 */
-/* ==================================================================== */
-
-#define SH_GFX_CREDIT_COUNT_1                    0x0000000120030080
-#define SH_GFX_CREDIT_COUNT_1_MASK               0x80000000000fffff
-#define SH_GFX_CREDIT_COUNT_1_INIT               0x000000000000003f
-
-/*   SH_GFX_CREDIT_COUNT_1_COUNT                                        */
-/*   Description:  Credit Count                                         */
-#define SH_GFX_CREDIT_COUNT_1_COUNT_SHFT         0
-#define SH_GFX_CREDIT_COUNT_1_COUNT_MASK         0x00000000000fffff
-
-/*   SH_GFX_CREDIT_COUNT_1_RESET_GFX_STATE                              */
-/*   Description:  Reset GFX state                                      */
-#define SH_GFX_CREDIT_COUNT_1_RESET_GFX_STATE_SHFT 63
-#define SH_GFX_CREDIT_COUNT_1_RESET_GFX_STATE_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_GFX_MODE_CNTRL_0"                    */
-/*         Graphics credit mode amd message ordering for CPU 0          */
-/* ==================================================================== */
-
-#define SH_GFX_MODE_CNTRL_0                      0x0000000120030100
-#define SH_GFX_MODE_CNTRL_0_MASK                 0x0000000000000007
-#define SH_GFX_MODE_CNTRL_0_INIT                 0x0000000000000003
-
-/*   SH_GFX_MODE_CNTRL_0_DWORD_CREDITS                                  */
-/*   Description:  GFX credits are tracked by D-words                   */
-#define SH_GFX_MODE_CNTRL_0_DWORD_CREDITS_SHFT   0
-#define SH_GFX_MODE_CNTRL_0_DWORD_CREDITS_MASK   0x0000000000000001
-
-/*   SH_GFX_MODE_CNTRL_0_MIXED_MODE_CREDITS                             */
-/*   Description:  GFX credits are tracked by D-words and messages      */
-#define SH_GFX_MODE_CNTRL_0_MIXED_MODE_CREDITS_SHFT 1
-#define SH_GFX_MODE_CNTRL_0_MIXED_MODE_CREDITS_MASK 0x0000000000000002
-
-/*   SH_GFX_MODE_CNTRL_0_RELAXED_ORDERING                               */
-/*   Description:  GFX message routing order                            */
-#define SH_GFX_MODE_CNTRL_0_RELAXED_ORDERING_SHFT 2
-#define SH_GFX_MODE_CNTRL_0_RELAXED_ORDERING_MASK 0x0000000000000004
-
-/* ==================================================================== */
-/*                    Register "SH_GFX_MODE_CNTRL_1"                    */
-/*         Graphics credit mode amd message ordering for CPU 1          */
-/* ==================================================================== */
-
-#define SH_GFX_MODE_CNTRL_1                      0x0000000120030180
-#define SH_GFX_MODE_CNTRL_1_MASK                 0x0000000000000007
-#define SH_GFX_MODE_CNTRL_1_INIT                 0x0000000000000003
-
-/*   SH_GFX_MODE_CNTRL_1_DWORD_CREDITS                                  */
-/*   Description:  GFX credits are tracked by D-words                   */
-#define SH_GFX_MODE_CNTRL_1_DWORD_CREDITS_SHFT   0
-#define SH_GFX_MODE_CNTRL_1_DWORD_CREDITS_MASK   0x0000000000000001
-
-/*   SH_GFX_MODE_CNTRL_1_MIXED_MODE_CREDITS                             */
-/*   Description:  GFX credits are tracked by D-words and messages      */
-#define SH_GFX_MODE_CNTRL_1_MIXED_MODE_CREDITS_SHFT 1
-#define SH_GFX_MODE_CNTRL_1_MIXED_MODE_CREDITS_MASK 0x0000000000000002
-
-/*   SH_GFX_MODE_CNTRL_1_RELAXED_ORDERING                               */
-/*   Description:  GFX message routing order                            */
-#define SH_GFX_MODE_CNTRL_1_RELAXED_ORDERING_SHFT 2
-#define SH_GFX_MODE_CNTRL_1_RELAXED_ORDERING_MASK 0x0000000000000004
-
-/* ==================================================================== */
-/*                Register "SH_GFX_SKID_CREDIT_COUNT_0"                 */
-/*              Graphics-write Skid Credit Count for CPU 0              */
-/* ==================================================================== */
-
-#define SH_GFX_SKID_CREDIT_COUNT_0               0x0000000120030200
-#define SH_GFX_SKID_CREDIT_COUNT_0_MASK          0x00000000000fffff
-#define SH_GFX_SKID_CREDIT_COUNT_0_INIT          0x0000000000000030
-
-/*   SH_GFX_SKID_CREDIT_COUNT_0_SKID                                    */
-/*   Description:  Skid Credit Count                                    */
-#define SH_GFX_SKID_CREDIT_COUNT_0_SKID_SHFT     0
-#define SH_GFX_SKID_CREDIT_COUNT_0_SKID_MASK     0x00000000000fffff
-
-/* ==================================================================== */
-/*                Register "SH_GFX_SKID_CREDIT_COUNT_1"                 */
-/*              Graphics-write Skid Credit Count for CPU 1              */
-/* ==================================================================== */
-
-#define SH_GFX_SKID_CREDIT_COUNT_1               0x0000000120030280
-#define SH_GFX_SKID_CREDIT_COUNT_1_MASK          0x00000000000fffff
-#define SH_GFX_SKID_CREDIT_COUNT_1_INIT          0x0000000000000030
-
-/*   SH_GFX_SKID_CREDIT_COUNT_1_SKID                                    */
-/*   Description:  Skid Credit Count                                    */
-#define SH_GFX_SKID_CREDIT_COUNT_1_SKID_SHFT     0
-#define SH_GFX_SKID_CREDIT_COUNT_1_SKID_MASK     0x00000000000fffff
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_STALL_LIMIT_0"                    */
-/*                 Graphics-write Stall Limit for CPU 0                 */
-/* ==================================================================== */
-
-#define SH_GFX_STALL_LIMIT_0                     0x0000000120030300
-#define SH_GFX_STALL_LIMIT_0_MASK                0x0000000003ffffff
-#define SH_GFX_STALL_LIMIT_0_INIT                0x0000000000010000
-
-/*   SH_GFX_STALL_LIMIT_0_LIMIT                                         */
-/*   Description:  Graphics Stall Limit for CPU 0                       */
-#define SH_GFX_STALL_LIMIT_0_LIMIT_SHFT          0
-#define SH_GFX_STALL_LIMIT_0_LIMIT_MASK          0x0000000003ffffff
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_STALL_LIMIT_1"                    */
-/*                 Graphics-write Stall Limit for CPU 1                 */
-/* ==================================================================== */
-
-#define SH_GFX_STALL_LIMIT_1                     0x0000000120030380
-#define SH_GFX_STALL_LIMIT_1_MASK                0x0000000003ffffff
-#define SH_GFX_STALL_LIMIT_1_INIT                0x0000000000010000
-
-/*   SH_GFX_STALL_LIMIT_1_LIMIT                                         */
-/*   Description:  Graphics Stall Limit for CPU 1                       */
-#define SH_GFX_STALL_LIMIT_1_LIMIT_SHFT          0
-#define SH_GFX_STALL_LIMIT_1_LIMIT_MASK          0x0000000003ffffff
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_STALL_TIMER_0"                    */
-/*                 Graphics-write Stall Timer for CPU 0                 */
-/* ==================================================================== */
-
-#define SH_GFX_STALL_TIMER_0                     0x0000000120030400
-#define SH_GFX_STALL_TIMER_0_MASK                0x0000000003ffffff
-#define SH_GFX_STALL_TIMER_0_INIT                0x0000000000000000
-
-/*   SH_GFX_STALL_TIMER_0_TIMER_VALUE                                   */
-/*   Description:  Timer Value                                          */
-#define SH_GFX_STALL_TIMER_0_TIMER_VALUE_SHFT    0
-#define SH_GFX_STALL_TIMER_0_TIMER_VALUE_MASK    0x0000000003ffffff
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_STALL_TIMER_1"                    */
-/*                 Graphics-write Stall Timer for CPU 1                 */
-/* ==================================================================== */
-
-#define SH_GFX_STALL_TIMER_1                     0x0000000120030480
-#define SH_GFX_STALL_TIMER_1_MASK                0x0000000003ffffff
-#define SH_GFX_STALL_TIMER_1_INIT                0x0000000000000000
-
-/*   SH_GFX_STALL_TIMER_1_TIMER_VALUE                                   */
-/*   Description:  Timer Value                                          */
-#define SH_GFX_STALL_TIMER_1_TIMER_VALUE_SHFT    0
-#define SH_GFX_STALL_TIMER_1_TIMER_VALUE_MASK    0x0000000003ffffff
-
-/* ==================================================================== */
-/*                      Register "SH_GFX_WINDOW_0"                      */
-/*                   Graphics-write Window for CPU 0                    */
-/* ==================================================================== */
-
-#define SH_GFX_WINDOW_0                          0x0000000120030500
-#define SH_GFX_WINDOW_0_MASK                     0x8000000fff000000
-#define SH_GFX_WINDOW_0_INIT                     0x0000000000000000
-
-/*   SH_GFX_WINDOW_0_BASE_ADDR                                          */
-/*   Description:  Base Address for CPU 0's 16 MB Graphics Window       */
-#define SH_GFX_WINDOW_0_BASE_ADDR_SHFT           24
-#define SH_GFX_WINDOW_0_BASE_ADDR_MASK           0x0000000fff000000
-
-/*   SH_GFX_WINDOW_0_GFX_WINDOW_EN                                      */
-/*   Description:  Graphics Window Enabled                              */
-#define SH_GFX_WINDOW_0_GFX_WINDOW_EN_SHFT       63
-#define SH_GFX_WINDOW_0_GFX_WINDOW_EN_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                      Register "SH_GFX_WINDOW_1"                      */
-/*                   Graphics-write Window for CPU 1                    */
-/* ==================================================================== */
-
-#define SH_GFX_WINDOW_1                          0x0000000120030580
-#define SH_GFX_WINDOW_1_MASK                     0x8000000fff000000
-#define SH_GFX_WINDOW_1_INIT                     0x0000000000000000
-
-/*   SH_GFX_WINDOW_1_BASE_ADDR                                          */
-/*   Description:  Base Address for CPU 1's 16 MB Graphics Window       */
-#define SH_GFX_WINDOW_1_BASE_ADDR_SHFT           24
-#define SH_GFX_WINDOW_1_BASE_ADDR_MASK           0x0000000fff000000
-
-/*   SH_GFX_WINDOW_1_GFX_WINDOW_EN                                      */
-/*   Description:  Graphics Window Enabled                              */
-#define SH_GFX_WINDOW_1_GFX_WINDOW_EN_SHFT       63
-#define SH_GFX_WINDOW_1_GFX_WINDOW_EN_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*              Register "SH_GFX_INTERRUPT_TIMER_LIMIT_0"               */
-/*               Graphics-write Interrupt Limit for CPU 0               */
-/* ==================================================================== */
-
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_0           0x0000000120030600
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_0_MASK      0x00000000000000ff
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_0_INIT      0x0000000000000040
-
-/*   SH_GFX_INTERRUPT_TIMER_LIMIT_0_INTERRUPT_TIMER_LIMIT               */
-/*   Description:  GFX Interrupt Timer Limit                            */
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_0_INTERRUPT_TIMER_LIMIT_SHFT 0
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_0_INTERRUPT_TIMER_LIMIT_MASK 0x00000000000000ff
-
-/* ==================================================================== */
-/*              Register "SH_GFX_INTERRUPT_TIMER_LIMIT_1"               */
-/*               Graphics-write Interrupt Limit for CPU 1               */
-/* ==================================================================== */
-
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_1           0x0000000120030680
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_1_MASK      0x00000000000000ff
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_1_INIT      0x0000000000000040
-
-/*   SH_GFX_INTERRUPT_TIMER_LIMIT_1_INTERRUPT_TIMER_LIMIT               */
-/*   Description:  GFX Interrupt Timer Limit                            */
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_1_INTERRUPT_TIMER_LIMIT_SHFT 0
-#define SH_GFX_INTERRUPT_TIMER_LIMIT_1_INTERRUPT_TIMER_LIMIT_MASK 0x00000000000000ff
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_WRITE_STATUS_0"                   */
-/*                   Graphics Write Status for CPU 0                    */
-/* ==================================================================== */
-
-#define SH_GFX_WRITE_STATUS_0                    0x0000000120040000
-#define SH_GFX_WRITE_STATUS_0_MASK               0x8000000000000001
-#define SH_GFX_WRITE_STATUS_0_INIT               0x0000000000000000
-
-/*   SH_GFX_WRITE_STATUS_0_BUSY                                         */
-/*   Description:  Busy                                                 */
-#define SH_GFX_WRITE_STATUS_0_BUSY_SHFT          0
-#define SH_GFX_WRITE_STATUS_0_BUSY_MASK          0x0000000000000001
-
-/*   SH_GFX_WRITE_STATUS_0_RE_ENABLE_GFX_STALL                          */
-/*   Description:  Re-enable GFX stall logic for this processor         */
-#define SH_GFX_WRITE_STATUS_0_RE_ENABLE_GFX_STALL_SHFT 63
-#define SH_GFX_WRITE_STATUS_0_RE_ENABLE_GFX_STALL_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_WRITE_STATUS_1"                   */
-/*                   Graphics Write Status for CPU 1                    */
-/* ==================================================================== */
-
-#define SH_GFX_WRITE_STATUS_1                    0x0000000120040080
-#define SH_GFX_WRITE_STATUS_1_MASK               0x8000000000000001
-#define SH_GFX_WRITE_STATUS_1_INIT               0x0000000000000000
-
-/*   SH_GFX_WRITE_STATUS_1_BUSY                                         */
-/*   Description:  Busy                                                 */
-#define SH_GFX_WRITE_STATUS_1_BUSY_SHFT          0
-#define SH_GFX_WRITE_STATUS_1_BUSY_MASK          0x0000000000000001
-
-/*   SH_GFX_WRITE_STATUS_1_RE_ENABLE_GFX_STALL                          */
-/*   Description:  Re-enable GFX stall logic for this processor         */
-#define SH_GFX_WRITE_STATUS_1_RE_ENABLE_GFX_STALL_SHFT 63
-#define SH_GFX_WRITE_STATUS_1_RE_ENABLE_GFX_STALL_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                        Register "SH_II_INT0"                         */
-/*                    SHub II Interrupt 0 Registers                     */
-/* ==================================================================== */
-
-#define SH_II_INT0                               0x0000000110000000
-#define SH_II_INT0_MASK                          0x00000000000001ff
-#define SH_II_INT0_INIT                          0x0000000000000000
-
-/*   SH_II_INT0_IDX                                                     */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_II_INT0_IDX_SHFT                      0
-#define SH_II_INT0_IDX_MASK                      0x00000000000000ff
-
-/*   SH_II_INT0_SEND                                                    */
-/*   Description:  Send Interrupt Message to PI, This generates a puls  */
-#define SH_II_INT0_SEND_SHFT                     8
-#define SH_II_INT0_SEND_MASK                     0x0000000000000100
-
-/* ==================================================================== */
-/*                     Register "SH_II_INT0_CONFIG"                     */
-/*                 SHub II Interrupt 0 Config Registers                 */
-/* ==================================================================== */
-
-#define SH_II_INT0_CONFIG                        0x0000000110000080
-#define SH_II_INT0_CONFIG_MASK                   0x0003ffffffefffff
-#define SH_II_INT0_CONFIG_INIT                   0x0000000000000000
-
-/*   SH_II_INT0_CONFIG_TYPE                                             */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_II_INT0_CONFIG_TYPE_SHFT              0
-#define SH_II_INT0_CONFIG_TYPE_MASK              0x0000000000000007
-
-/*   SH_II_INT0_CONFIG_AGT                                              */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_II_INT0_CONFIG_AGT_SHFT               3
-#define SH_II_INT0_CONFIG_AGT_MASK               0x0000000000000008
-
-/*   SH_II_INT0_CONFIG_PID                                              */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_II_INT0_CONFIG_PID_SHFT               4
-#define SH_II_INT0_CONFIG_PID_MASK               0x00000000000ffff0
-
-/*   SH_II_INT0_CONFIG_BASE                                             */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_II_INT0_CONFIG_BASE_SHFT              21
-#define SH_II_INT0_CONFIG_BASE_MASK              0x0003ffffffe00000
-
-/* ==================================================================== */
-/*                     Register "SH_II_INT0_ENABLE"                     */
-/*                 SHub II Interrupt 0 Enable Registers                 */
-/* ==================================================================== */
-
-#define SH_II_INT0_ENABLE                        0x0000000110000200
-#define SH_II_INT0_ENABLE_MASK                   0x0000000000000001
-#define SH_II_INT0_ENABLE_INIT                   0x0000000000000000
-
-/*   SH_II_INT0_ENABLE_II_ENABLE                                        */
-/*   Description:  Enable II Interrupt                                  */
-#define SH_II_INT0_ENABLE_II_ENABLE_SHFT         0
-#define SH_II_INT0_ENABLE_II_ENABLE_MASK         0x0000000000000001
-
-/* ==================================================================== */
-/*                        Register "SH_II_INT1"                         */
-/*                    SHub II Interrupt 1 Registers                     */
-/* ==================================================================== */
-
-#define SH_II_INT1                               0x0000000110000100
-#define SH_II_INT1_MASK                          0x00000000000001ff
-#define SH_II_INT1_INIT                          0x0000000000000000
-
-/*   SH_II_INT1_IDX                                                     */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_II_INT1_IDX_SHFT                      0
-#define SH_II_INT1_IDX_MASK                      0x00000000000000ff
-
-/*   SH_II_INT1_SEND                                                    */
-/*   Description:  Send Interrupt Message to PI, This generates a puls  */
-#define SH_II_INT1_SEND_SHFT                     8
-#define SH_II_INT1_SEND_MASK                     0x0000000000000100
-
-/* ==================================================================== */
-/*                     Register "SH_II_INT1_CONFIG"                     */
-/*                 SHub II Interrupt 1 Config Registers                 */
-/* ==================================================================== */
-
-#define SH_II_INT1_CONFIG                        0x0000000110000180
-#define SH_II_INT1_CONFIG_MASK                   0x0003ffffffefffff
-#define SH_II_INT1_CONFIG_INIT                   0x0000000000000000
-
-/*   SH_II_INT1_CONFIG_TYPE                                             */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_II_INT1_CONFIG_TYPE_SHFT              0
-#define SH_II_INT1_CONFIG_TYPE_MASK              0x0000000000000007
-
-/*   SH_II_INT1_CONFIG_AGT                                              */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_II_INT1_CONFIG_AGT_SHFT               3
-#define SH_II_INT1_CONFIG_AGT_MASK               0x0000000000000008
-
-/*   SH_II_INT1_CONFIG_PID                                              */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_II_INT1_CONFIG_PID_SHFT               4
-#define SH_II_INT1_CONFIG_PID_MASK               0x00000000000ffff0
-
-/*   SH_II_INT1_CONFIG_BASE                                             */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_II_INT1_CONFIG_BASE_SHFT              21
-#define SH_II_INT1_CONFIG_BASE_MASK              0x0003ffffffe00000
-
-/* ==================================================================== */
-/*                     Register "SH_II_INT1_ENABLE"                     */
-/*                 SHub II Interrupt 1 Enable Registers                 */
-/* ==================================================================== */
-
-#define SH_II_INT1_ENABLE                        0x0000000110000280
-#define SH_II_INT1_ENABLE_MASK                   0x0000000000000001
-#define SH_II_INT1_ENABLE_INIT                   0x0000000000000000
-
-/*   SH_II_INT1_ENABLE_II_ENABLE                                        */
-/*   Description:  Enable II 1 Interrupt                                */
-#define SH_II_INT1_ENABLE_II_ENABLE_SHFT         0
-#define SH_II_INT1_ENABLE_II_ENABLE_MASK         0x0000000000000001
-
-/* ==================================================================== */
-/*                   Register "SH_INT_NODE_ID_CONFIG"                   */
-/*                 SHub Interrupt Node ID Configuration                 */
-/* ==================================================================== */
-
-#define SH_INT_NODE_ID_CONFIG                    0x0000000110000300
-#define SH_INT_NODE_ID_CONFIG_MASK               0x0000000000000fff
-#define SH_INT_NODE_ID_CONFIG_INIT               0x0000000000000000
-
-/*   SH_INT_NODE_ID_CONFIG_NODE_ID                                      */
-/*   Description:  Node ID for interrupt messages                       */
-#define SH_INT_NODE_ID_CONFIG_NODE_ID_SHFT       0
-#define SH_INT_NODE_ID_CONFIG_NODE_ID_MASK       0x00000000000007ff
-
-/*   SH_INT_NODE_ID_CONFIG_ID_SEL                                       */
-/*   Description:  Select node id for interrupt messages                */
-#define SH_INT_NODE_ID_CONFIG_ID_SEL_SHFT        11
-#define SH_INT_NODE_ID_CONFIG_ID_SEL_MASK        0x0000000000000800
-
-/* ==================================================================== */
-/*                        Register "SH_IPI_INT"                         */
-/*               SHub Inter-Processor Interrupt Registers               */
-/* ==================================================================== */
-
-#define SH_IPI_INT                               0x0000000110000380
-#define SH_IPI_INT_MASK                          0x8ff3ffffffefffff
-#define SH_IPI_INT_INIT                          0x0000000000000000
-
-/*   SH_IPI_INT_TYPE                                                    */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_IPI_INT_TYPE_SHFT                     0
-#define SH_IPI_INT_TYPE_MASK                     0x0000000000000007
-
-/*   SH_IPI_INT_AGT                                                     */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_IPI_INT_AGT_SHFT                      3
-#define SH_IPI_INT_AGT_MASK                      0x0000000000000008
-
-/*   SH_IPI_INT_PID                                                     */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_IPI_INT_PID_SHFT                      4
-#define SH_IPI_INT_PID_MASK                      0x00000000000ffff0
-
-/*   SH_IPI_INT_BASE                                                    */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_IPI_INT_BASE_SHFT                     21
-#define SH_IPI_INT_BASE_MASK                     0x0003ffffffe00000
-
-/*   SH_IPI_INT_IDX                                                     */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_IPI_INT_IDX_SHFT                      52
-#define SH_IPI_INT_IDX_MASK                      0x0ff0000000000000
-
-/*   SH_IPI_INT_SEND                                                    */
-/*   Description:  Send Interrupt Message to PI, This generates a puls  */
-#define SH_IPI_INT_SEND_SHFT                     63
-#define SH_IPI_INT_SEND_MASK                     0x8000000000000000
-
-/* ==================================================================== */
-/*                     Register "SH_IPI_INT_ENABLE"                     */
-/*           SHub Inter-Processor Interrupt Enable Registers            */
-/* ==================================================================== */
-
-#define SH_IPI_INT_ENABLE                        0x0000000110000400
-#define SH_IPI_INT_ENABLE_MASK                   0x0000000000000001
-#define SH_IPI_INT_ENABLE_INIT                   0x0000000000000000
-
-/*   SH_IPI_INT_ENABLE_PIO_ENABLE                                       */
-/*   Description:  Enable PIO Interrupt                                 */
-#define SH_IPI_INT_ENABLE_PIO_ENABLE_SHFT        0
-#define SH_IPI_INT_ENABLE_PIO_ENABLE_MASK        0x0000000000000001
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT0_CONFIG"                    */
-/*                   SHub Local Interrupt 0 Registers                   */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT0_CONFIG                     0x0000000110000480
-#define SH_LOCAL_INT0_CONFIG_MASK                0x0ff3ffffffefffff
-#define SH_LOCAL_INT0_CONFIG_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT0_CONFIG_TYPE                                          */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_LOCAL_INT0_CONFIG_TYPE_SHFT           0
-#define SH_LOCAL_INT0_CONFIG_TYPE_MASK           0x0000000000000007
-
-/*   SH_LOCAL_INT0_CONFIG_AGT                                           */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_LOCAL_INT0_CONFIG_AGT_SHFT            3
-#define SH_LOCAL_INT0_CONFIG_AGT_MASK            0x0000000000000008
-
-/*   SH_LOCAL_INT0_CONFIG_PID                                           */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_LOCAL_INT0_CONFIG_PID_SHFT            4
-#define SH_LOCAL_INT0_CONFIG_PID_MASK            0x00000000000ffff0
-
-/*   SH_LOCAL_INT0_CONFIG_BASE                                          */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_LOCAL_INT0_CONFIG_BASE_SHFT           21
-#define SH_LOCAL_INT0_CONFIG_BASE_MASK           0x0003ffffffe00000
-
-/*   SH_LOCAL_INT0_CONFIG_IDX                                           */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_LOCAL_INT0_CONFIG_IDX_SHFT            52
-#define SH_LOCAL_INT0_CONFIG_IDX_MASK            0x0ff0000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT0_ENABLE"                    */
-/*                    SHub Local Interrupt 0 Enable                     */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT0_ENABLE                     0x0000000110000500
-#define SH_LOCAL_INT0_ENABLE_MASK                0x000000000000f7ff
-#define SH_LOCAL_INT0_ENABLE_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT0_ENABLE_PI_HW_INT                                     */
-/*   Description:  Enable PI Hardware interrupt                         */
-#define SH_LOCAL_INT0_ENABLE_PI_HW_INT_SHFT      0
-#define SH_LOCAL_INT0_ENABLE_PI_HW_INT_MASK      0x0000000000000001
-
-/*   SH_LOCAL_INT0_ENABLE_MD_HW_INT                                     */
-/*   Description:  Enable MD Hardware interrupt                         */
-#define SH_LOCAL_INT0_ENABLE_MD_HW_INT_SHFT      1
-#define SH_LOCAL_INT0_ENABLE_MD_HW_INT_MASK      0x0000000000000002
-
-/*   SH_LOCAL_INT0_ENABLE_XN_HW_INT                                     */
-/*   Description:  Enable XN Hardware interrupt                         */
-#define SH_LOCAL_INT0_ENABLE_XN_HW_INT_SHFT      2
-#define SH_LOCAL_INT0_ENABLE_XN_HW_INT_MASK      0x0000000000000004
-
-/*   SH_LOCAL_INT0_ENABLE_LB_HW_INT                                     */
-/*   Description:  Enable LB Hardware interrupt                         */
-#define SH_LOCAL_INT0_ENABLE_LB_HW_INT_SHFT      3
-#define SH_LOCAL_INT0_ENABLE_LB_HW_INT_MASK      0x0000000000000008
-
-/*   SH_LOCAL_INT0_ENABLE_II_HW_INT                                     */
-/*   Description:  Enable II wrapper Hardware interrupt                 */
-#define SH_LOCAL_INT0_ENABLE_II_HW_INT_SHFT      4
-#define SH_LOCAL_INT0_ENABLE_II_HW_INT_MASK      0x0000000000000010
-
-/*   SH_LOCAL_INT0_ENABLE_PI_CE_INT                                     */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT0_ENABLE_PI_CE_INT_SHFT      5
-#define SH_LOCAL_INT0_ENABLE_PI_CE_INT_MASK      0x0000000000000020
-
-/*   SH_LOCAL_INT0_ENABLE_MD_CE_INT                                     */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT0_ENABLE_MD_CE_INT_SHFT      6
-#define SH_LOCAL_INT0_ENABLE_MD_CE_INT_MASK      0x0000000000000040
-
-/*   SH_LOCAL_INT0_ENABLE_XN_CE_INT                                     */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT0_ENABLE_XN_CE_INT_SHFT      7
-#define SH_LOCAL_INT0_ENABLE_XN_CE_INT_MASK      0x0000000000000080
-
-/*   SH_LOCAL_INT0_ENABLE_PI_UCE_INT                                    */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT0_ENABLE_PI_UCE_INT_SHFT     8
-#define SH_LOCAL_INT0_ENABLE_PI_UCE_INT_MASK     0x0000000000000100
-
-/*   SH_LOCAL_INT0_ENABLE_MD_UCE_INT                                    */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT0_ENABLE_MD_UCE_INT_SHFT     9
-#define SH_LOCAL_INT0_ENABLE_MD_UCE_INT_MASK     0x0000000000000200
-
-/*   SH_LOCAL_INT0_ENABLE_XN_UCE_INT                                    */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT0_ENABLE_XN_UCE_INT_SHFT     10
-#define SH_LOCAL_INT0_ENABLE_XN_UCE_INT_MASK     0x0000000000000400
-
-/*   SH_LOCAL_INT0_ENABLE_SYSTEM_SHUTDOWN_INT                           */
-/*   Description:  Enable System Shutdown Interrupt                     */
-#define SH_LOCAL_INT0_ENABLE_SYSTEM_SHUTDOWN_INT_SHFT 12
-#define SH_LOCAL_INT0_ENABLE_SYSTEM_SHUTDOWN_INT_MASK 0x0000000000001000
-
-/*   SH_LOCAL_INT0_ENABLE_UART_INT                                      */
-/*   Description:  Enable Junk Bus UART Interrupt                       */
-#define SH_LOCAL_INT0_ENABLE_UART_INT_SHFT       13
-#define SH_LOCAL_INT0_ENABLE_UART_INT_MASK       0x0000000000002000
-
-/*   SH_LOCAL_INT0_ENABLE_L1_NMI_INT                                    */
-/*   Description:  Enable L1 Controller NMI Interrupt                   */
-#define SH_LOCAL_INT0_ENABLE_L1_NMI_INT_SHFT     14
-#define SH_LOCAL_INT0_ENABLE_L1_NMI_INT_MASK     0x0000000000004000
-
-/*   SH_LOCAL_INT0_ENABLE_STOP_CLOCK                                    */
-/*   Description:  Stop Clock Interrupt                                 */
-#define SH_LOCAL_INT0_ENABLE_STOP_CLOCK_SHFT     15
-#define SH_LOCAL_INT0_ENABLE_STOP_CLOCK_MASK     0x0000000000008000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT1_CONFIG"                    */
-/*                   SHub Local Interrupt 1 Registers                   */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT1_CONFIG                     0x0000000110000580
-#define SH_LOCAL_INT1_CONFIG_MASK                0x0ff3ffffffefffff
-#define SH_LOCAL_INT1_CONFIG_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT1_CONFIG_TYPE                                          */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_LOCAL_INT1_CONFIG_TYPE_SHFT           0
-#define SH_LOCAL_INT1_CONFIG_TYPE_MASK           0x0000000000000007
-
-/*   SH_LOCAL_INT1_CONFIG_AGT                                           */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_LOCAL_INT1_CONFIG_AGT_SHFT            3
-#define SH_LOCAL_INT1_CONFIG_AGT_MASK            0x0000000000000008
-
-/*   SH_LOCAL_INT1_CONFIG_PID                                           */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_LOCAL_INT1_CONFIG_PID_SHFT            4
-#define SH_LOCAL_INT1_CONFIG_PID_MASK            0x00000000000ffff0
-
-/*   SH_LOCAL_INT1_CONFIG_BASE                                          */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_LOCAL_INT1_CONFIG_BASE_SHFT           21
-#define SH_LOCAL_INT1_CONFIG_BASE_MASK           0x0003ffffffe00000
-
-/*   SH_LOCAL_INT1_CONFIG_IDX                                           */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_LOCAL_INT1_CONFIG_IDX_SHFT            52
-#define SH_LOCAL_INT1_CONFIG_IDX_MASK            0x0ff0000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT1_ENABLE"                    */
-/*                    SHub Local Interrupt 1 Enable                     */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT1_ENABLE                     0x0000000110000600
-#define SH_LOCAL_INT1_ENABLE_MASK                0x000000000000f7ff
-#define SH_LOCAL_INT1_ENABLE_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT1_ENABLE_PI_HW_INT                                     */
-/*   Description:  Enable PI Hardware interrupt                         */
-#define SH_LOCAL_INT1_ENABLE_PI_HW_INT_SHFT      0
-#define SH_LOCAL_INT1_ENABLE_PI_HW_INT_MASK      0x0000000000000001
-
-/*   SH_LOCAL_INT1_ENABLE_MD_HW_INT                                     */
-/*   Description:  Enable MD Hardware interrupt                         */
-#define SH_LOCAL_INT1_ENABLE_MD_HW_INT_SHFT      1
-#define SH_LOCAL_INT1_ENABLE_MD_HW_INT_MASK      0x0000000000000002
-
-/*   SH_LOCAL_INT1_ENABLE_XN_HW_INT                                     */
-/*   Description:  Enable XN Hardware interrupt                         */
-#define SH_LOCAL_INT1_ENABLE_XN_HW_INT_SHFT      2
-#define SH_LOCAL_INT1_ENABLE_XN_HW_INT_MASK      0x0000000000000004
-
-/*   SH_LOCAL_INT1_ENABLE_LB_HW_INT                                     */
-/*   Description:  Enable LB Hardware interrupt                         */
-#define SH_LOCAL_INT1_ENABLE_LB_HW_INT_SHFT      3
-#define SH_LOCAL_INT1_ENABLE_LB_HW_INT_MASK      0x0000000000000008
-
-/*   SH_LOCAL_INT1_ENABLE_II_HW_INT                                     */
-/*   Description:  Enable II wrapper Hardware interrupt                 */
-#define SH_LOCAL_INT1_ENABLE_II_HW_INT_SHFT      4
-#define SH_LOCAL_INT1_ENABLE_II_HW_INT_MASK      0x0000000000000010
-
-/*   SH_LOCAL_INT1_ENABLE_PI_CE_INT                                     */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT1_ENABLE_PI_CE_INT_SHFT      5
-#define SH_LOCAL_INT1_ENABLE_PI_CE_INT_MASK      0x0000000000000020
-
-/*   SH_LOCAL_INT1_ENABLE_MD_CE_INT                                     */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT1_ENABLE_MD_CE_INT_SHFT      6
-#define SH_LOCAL_INT1_ENABLE_MD_CE_INT_MASK      0x0000000000000040
-
-/*   SH_LOCAL_INT1_ENABLE_XN_CE_INT                                     */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT1_ENABLE_XN_CE_INT_SHFT      7
-#define SH_LOCAL_INT1_ENABLE_XN_CE_INT_MASK      0x0000000000000080
-
-/*   SH_LOCAL_INT1_ENABLE_PI_UCE_INT                                    */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT1_ENABLE_PI_UCE_INT_SHFT     8
-#define SH_LOCAL_INT1_ENABLE_PI_UCE_INT_MASK     0x0000000000000100
-
-/*   SH_LOCAL_INT1_ENABLE_MD_UCE_INT                                    */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT1_ENABLE_MD_UCE_INT_SHFT     9
-#define SH_LOCAL_INT1_ENABLE_MD_UCE_INT_MASK     0x0000000000000200
-
-/*   SH_LOCAL_INT1_ENABLE_XN_UCE_INT                                    */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT1_ENABLE_XN_UCE_INT_SHFT     10
-#define SH_LOCAL_INT1_ENABLE_XN_UCE_INT_MASK     0x0000000000000400
-
-/*   SH_LOCAL_INT1_ENABLE_SYSTEM_SHUTDOWN_INT                           */
-/*   Description:  Enable System Shutdown Interrupt                     */
-#define SH_LOCAL_INT1_ENABLE_SYSTEM_SHUTDOWN_INT_SHFT 12
-#define SH_LOCAL_INT1_ENABLE_SYSTEM_SHUTDOWN_INT_MASK 0x0000000000001000
-
-/*   SH_LOCAL_INT1_ENABLE_UART_INT                                      */
-/*   Description:  Enable Junk Bus UART Interrupt                       */
-#define SH_LOCAL_INT1_ENABLE_UART_INT_SHFT       13
-#define SH_LOCAL_INT1_ENABLE_UART_INT_MASK       0x0000000000002000
-
-/*   SH_LOCAL_INT1_ENABLE_L1_NMI_INT                                    */
-/*   Description:  Enable L1 Controller NMI Interrupt                   */
-#define SH_LOCAL_INT1_ENABLE_L1_NMI_INT_SHFT     14
-#define SH_LOCAL_INT1_ENABLE_L1_NMI_INT_MASK     0x0000000000004000
-
-/*   SH_LOCAL_INT1_ENABLE_STOP_CLOCK                                    */
-/*   Description:  Stop Clock Interrupt                                 */
-#define SH_LOCAL_INT1_ENABLE_STOP_CLOCK_SHFT     15
-#define SH_LOCAL_INT1_ENABLE_STOP_CLOCK_MASK     0x0000000000008000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT2_CONFIG"                    */
-/*                   SHub Local Interrupt 2 Registers                   */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT2_CONFIG                     0x0000000110000680
-#define SH_LOCAL_INT2_CONFIG_MASK                0x0ff3ffffffefffff
-#define SH_LOCAL_INT2_CONFIG_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT2_CONFIG_TYPE                                          */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_LOCAL_INT2_CONFIG_TYPE_SHFT           0
-#define SH_LOCAL_INT2_CONFIG_TYPE_MASK           0x0000000000000007
-
-/*   SH_LOCAL_INT2_CONFIG_AGT                                           */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_LOCAL_INT2_CONFIG_AGT_SHFT            3
-#define SH_LOCAL_INT2_CONFIG_AGT_MASK            0x0000000000000008
-
-/*   SH_LOCAL_INT2_CONFIG_PID                                           */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_LOCAL_INT2_CONFIG_PID_SHFT            4
-#define SH_LOCAL_INT2_CONFIG_PID_MASK            0x00000000000ffff0
-
-/*   SH_LOCAL_INT2_CONFIG_BASE                                          */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_LOCAL_INT2_CONFIG_BASE_SHFT           21
-#define SH_LOCAL_INT2_CONFIG_BASE_MASK           0x0003ffffffe00000
-
-/*   SH_LOCAL_INT2_CONFIG_IDX                                           */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_LOCAL_INT2_CONFIG_IDX_SHFT            52
-#define SH_LOCAL_INT2_CONFIG_IDX_MASK            0x0ff0000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT2_ENABLE"                    */
-/*                    SHub Local Interrupt 2 Enable                     */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT2_ENABLE                     0x0000000110000700
-#define SH_LOCAL_INT2_ENABLE_MASK                0x000000000000f7ff
-#define SH_LOCAL_INT2_ENABLE_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT2_ENABLE_PI_HW_INT                                     */
-/*   Description:  Enable PI Hardware interrupt                         */
-#define SH_LOCAL_INT2_ENABLE_PI_HW_INT_SHFT      0
-#define SH_LOCAL_INT2_ENABLE_PI_HW_INT_MASK      0x0000000000000001
-
-/*   SH_LOCAL_INT2_ENABLE_MD_HW_INT                                     */
-/*   Description:  Enable MD Hardware interrupt                         */
-#define SH_LOCAL_INT2_ENABLE_MD_HW_INT_SHFT      1
-#define SH_LOCAL_INT2_ENABLE_MD_HW_INT_MASK      0x0000000000000002
-
-/*   SH_LOCAL_INT2_ENABLE_XN_HW_INT                                     */
-/*   Description:  Enable XN Hardware interrupt                         */
-#define SH_LOCAL_INT2_ENABLE_XN_HW_INT_SHFT      2
-#define SH_LOCAL_INT2_ENABLE_XN_HW_INT_MASK      0x0000000000000004
-
-/*   SH_LOCAL_INT2_ENABLE_LB_HW_INT                                     */
-/*   Description:  Enable LB Hardware interrupt                         */
-#define SH_LOCAL_INT2_ENABLE_LB_HW_INT_SHFT      3
-#define SH_LOCAL_INT2_ENABLE_LB_HW_INT_MASK      0x0000000000000008
-
-/*   SH_LOCAL_INT2_ENABLE_II_HW_INT                                     */
-/*   Description:  Enable II wrapper Hardware interrupt                 */
-#define SH_LOCAL_INT2_ENABLE_II_HW_INT_SHFT      4
-#define SH_LOCAL_INT2_ENABLE_II_HW_INT_MASK      0x0000000000000010
-
-/*   SH_LOCAL_INT2_ENABLE_PI_CE_INT                                     */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT2_ENABLE_PI_CE_INT_SHFT      5
-#define SH_LOCAL_INT2_ENABLE_PI_CE_INT_MASK      0x0000000000000020
-
-/*   SH_LOCAL_INT2_ENABLE_MD_CE_INT                                     */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT2_ENABLE_MD_CE_INT_SHFT      6
-#define SH_LOCAL_INT2_ENABLE_MD_CE_INT_MASK      0x0000000000000040
-
-/*   SH_LOCAL_INT2_ENABLE_XN_CE_INT                                     */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT2_ENABLE_XN_CE_INT_SHFT      7
-#define SH_LOCAL_INT2_ENABLE_XN_CE_INT_MASK      0x0000000000000080
-
-/*   SH_LOCAL_INT2_ENABLE_PI_UCE_INT                                    */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT2_ENABLE_PI_UCE_INT_SHFT     8
-#define SH_LOCAL_INT2_ENABLE_PI_UCE_INT_MASK     0x0000000000000100
-
-/*   SH_LOCAL_INT2_ENABLE_MD_UCE_INT                                    */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT2_ENABLE_MD_UCE_INT_SHFT     9
-#define SH_LOCAL_INT2_ENABLE_MD_UCE_INT_MASK     0x0000000000000200
-
-/*   SH_LOCAL_INT2_ENABLE_XN_UCE_INT                                    */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT2_ENABLE_XN_UCE_INT_SHFT     10
-#define SH_LOCAL_INT2_ENABLE_XN_UCE_INT_MASK     0x0000000000000400
-
-/*   SH_LOCAL_INT2_ENABLE_SYSTEM_SHUTDOWN_INT                           */
-/*   Description:  Enable System Shutdown Interrupt                     */
-#define SH_LOCAL_INT2_ENABLE_SYSTEM_SHUTDOWN_INT_SHFT 12
-#define SH_LOCAL_INT2_ENABLE_SYSTEM_SHUTDOWN_INT_MASK 0x0000000000001000
-
-/*   SH_LOCAL_INT2_ENABLE_UART_INT                                      */
-/*   Description:  Enable Junk Bus UART Interrupt                       */
-#define SH_LOCAL_INT2_ENABLE_UART_INT_SHFT       13
-#define SH_LOCAL_INT2_ENABLE_UART_INT_MASK       0x0000000000002000
-
-/*   SH_LOCAL_INT2_ENABLE_L1_NMI_INT                                    */
-/*   Description:  Enable L1 Controller NMI Interrupt                   */
-#define SH_LOCAL_INT2_ENABLE_L1_NMI_INT_SHFT     14
-#define SH_LOCAL_INT2_ENABLE_L1_NMI_INT_MASK     0x0000000000004000
-
-/*   SH_LOCAL_INT2_ENABLE_STOP_CLOCK                                    */
-/*   Description:  Stop Clock Interrupt                                 */
-#define SH_LOCAL_INT2_ENABLE_STOP_CLOCK_SHFT     15
-#define SH_LOCAL_INT2_ENABLE_STOP_CLOCK_MASK     0x0000000000008000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT3_CONFIG"                    */
-/*                   SHub Local Interrupt 3 Registers                   */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT3_CONFIG                     0x0000000110000780
-#define SH_LOCAL_INT3_CONFIG_MASK                0x0ff3ffffffefffff
-#define SH_LOCAL_INT3_CONFIG_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT3_CONFIG_TYPE                                          */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_LOCAL_INT3_CONFIG_TYPE_SHFT           0
-#define SH_LOCAL_INT3_CONFIG_TYPE_MASK           0x0000000000000007
-
-/*   SH_LOCAL_INT3_CONFIG_AGT                                           */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_LOCAL_INT3_CONFIG_AGT_SHFT            3
-#define SH_LOCAL_INT3_CONFIG_AGT_MASK            0x0000000000000008
-
-/*   SH_LOCAL_INT3_CONFIG_PID                                           */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_LOCAL_INT3_CONFIG_PID_SHFT            4
-#define SH_LOCAL_INT3_CONFIG_PID_MASK            0x00000000000ffff0
-
-/*   SH_LOCAL_INT3_CONFIG_BASE                                          */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_LOCAL_INT3_CONFIG_BASE_SHFT           21
-#define SH_LOCAL_INT3_CONFIG_BASE_MASK           0x0003ffffffe00000
-
-/*   SH_LOCAL_INT3_CONFIG_IDX                                           */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_LOCAL_INT3_CONFIG_IDX_SHFT            52
-#define SH_LOCAL_INT3_CONFIG_IDX_MASK            0x0ff0000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT3_ENABLE"                    */
-/*                    SHub Local Interrupt 3 Enable                     */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT3_ENABLE                     0x0000000110000800
-#define SH_LOCAL_INT3_ENABLE_MASK                0x000000000000f7ff
-#define SH_LOCAL_INT3_ENABLE_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT3_ENABLE_PI_HW_INT                                     */
-/*   Description:  Enable PI Hardware interrupt                         */
-#define SH_LOCAL_INT3_ENABLE_PI_HW_INT_SHFT      0
-#define SH_LOCAL_INT3_ENABLE_PI_HW_INT_MASK      0x0000000000000001
-
-/*   SH_LOCAL_INT3_ENABLE_MD_HW_INT                                     */
-/*   Description:  Enable MD Hardware interrupt                         */
-#define SH_LOCAL_INT3_ENABLE_MD_HW_INT_SHFT      1
-#define SH_LOCAL_INT3_ENABLE_MD_HW_INT_MASK      0x0000000000000002
-
-/*   SH_LOCAL_INT3_ENABLE_XN_HW_INT                                     */
-/*   Description:  Enable XN Hardware interrupt                         */
-#define SH_LOCAL_INT3_ENABLE_XN_HW_INT_SHFT      2
-#define SH_LOCAL_INT3_ENABLE_XN_HW_INT_MASK      0x0000000000000004
-
-/*   SH_LOCAL_INT3_ENABLE_LB_HW_INT                                     */
-/*   Description:  Enable LB Hardware interrupt                         */
-#define SH_LOCAL_INT3_ENABLE_LB_HW_INT_SHFT      3
-#define SH_LOCAL_INT3_ENABLE_LB_HW_INT_MASK      0x0000000000000008
-
-/*   SH_LOCAL_INT3_ENABLE_II_HW_INT                                     */
-/*   Description:  Enable II wrapper Hardware interrupt                 */
-#define SH_LOCAL_INT3_ENABLE_II_HW_INT_SHFT      4
-#define SH_LOCAL_INT3_ENABLE_II_HW_INT_MASK      0x0000000000000010
-
-/*   SH_LOCAL_INT3_ENABLE_PI_CE_INT                                     */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT3_ENABLE_PI_CE_INT_SHFT      5
-#define SH_LOCAL_INT3_ENABLE_PI_CE_INT_MASK      0x0000000000000020
-
-/*   SH_LOCAL_INT3_ENABLE_MD_CE_INT                                     */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT3_ENABLE_MD_CE_INT_SHFT      6
-#define SH_LOCAL_INT3_ENABLE_MD_CE_INT_MASK      0x0000000000000040
-
-/*   SH_LOCAL_INT3_ENABLE_XN_CE_INT                                     */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT3_ENABLE_XN_CE_INT_SHFT      7
-#define SH_LOCAL_INT3_ENABLE_XN_CE_INT_MASK      0x0000000000000080
-
-/*   SH_LOCAL_INT3_ENABLE_PI_UCE_INT                                    */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT3_ENABLE_PI_UCE_INT_SHFT     8
-#define SH_LOCAL_INT3_ENABLE_PI_UCE_INT_MASK     0x0000000000000100
-
-/*   SH_LOCAL_INT3_ENABLE_MD_UCE_INT                                    */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT3_ENABLE_MD_UCE_INT_SHFT     9
-#define SH_LOCAL_INT3_ENABLE_MD_UCE_INT_MASK     0x0000000000000200
-
-/*   SH_LOCAL_INT3_ENABLE_XN_UCE_INT                                    */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT3_ENABLE_XN_UCE_INT_SHFT     10
-#define SH_LOCAL_INT3_ENABLE_XN_UCE_INT_MASK     0x0000000000000400
-
-/*   SH_LOCAL_INT3_ENABLE_SYSTEM_SHUTDOWN_INT                           */
-/*   Description:  Enable System Shutdown Interrupt                     */
-#define SH_LOCAL_INT3_ENABLE_SYSTEM_SHUTDOWN_INT_SHFT 12
-#define SH_LOCAL_INT3_ENABLE_SYSTEM_SHUTDOWN_INT_MASK 0x0000000000001000
-
-/*   SH_LOCAL_INT3_ENABLE_UART_INT                                      */
-/*   Description:  Enable Junk Bus UART Interrupt                       */
-#define SH_LOCAL_INT3_ENABLE_UART_INT_SHFT       13
-#define SH_LOCAL_INT3_ENABLE_UART_INT_MASK       0x0000000000002000
-
-/*   SH_LOCAL_INT3_ENABLE_L1_NMI_INT                                    */
-/*   Description:  Enable L1 Controller NMI Interrupt                   */
-#define SH_LOCAL_INT3_ENABLE_L1_NMI_INT_SHFT     14
-#define SH_LOCAL_INT3_ENABLE_L1_NMI_INT_MASK     0x0000000000004000
-
-/*   SH_LOCAL_INT3_ENABLE_STOP_CLOCK                                    */
-/*   Description:  Stop Clock Interrupt                                 */
-#define SH_LOCAL_INT3_ENABLE_STOP_CLOCK_SHFT     15
-#define SH_LOCAL_INT3_ENABLE_STOP_CLOCK_MASK     0x0000000000008000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT4_CONFIG"                    */
-/*                   SHub Local Interrupt 4 Registers                   */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT4_CONFIG                     0x0000000110000880
-#define SH_LOCAL_INT4_CONFIG_MASK                0x0ff3ffffffefffff
-#define SH_LOCAL_INT4_CONFIG_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT4_CONFIG_TYPE                                          */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_LOCAL_INT4_CONFIG_TYPE_SHFT           0
-#define SH_LOCAL_INT4_CONFIG_TYPE_MASK           0x0000000000000007
-
-/*   SH_LOCAL_INT4_CONFIG_AGT                                           */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_LOCAL_INT4_CONFIG_AGT_SHFT            3
-#define SH_LOCAL_INT4_CONFIG_AGT_MASK            0x0000000000000008
-
-/*   SH_LOCAL_INT4_CONFIG_PID                                           */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_LOCAL_INT4_CONFIG_PID_SHFT            4
-#define SH_LOCAL_INT4_CONFIG_PID_MASK            0x00000000000ffff0
-
-/*   SH_LOCAL_INT4_CONFIG_BASE                                          */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_LOCAL_INT4_CONFIG_BASE_SHFT           21
-#define SH_LOCAL_INT4_CONFIG_BASE_MASK           0x0003ffffffe00000
-
-/*   SH_LOCAL_INT4_CONFIG_IDX                                           */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_LOCAL_INT4_CONFIG_IDX_SHFT            52
-#define SH_LOCAL_INT4_CONFIG_IDX_MASK            0x0ff0000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT4_ENABLE"                    */
-/*                    SHub Local Interrupt 4 Enable                     */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT4_ENABLE                     0x0000000110000900
-#define SH_LOCAL_INT4_ENABLE_MASK                0x000000000000f7ff
-#define SH_LOCAL_INT4_ENABLE_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT4_ENABLE_PI_HW_INT                                     */
-/*   Description:  Enable PI Hardware interrupt                         */
-#define SH_LOCAL_INT4_ENABLE_PI_HW_INT_SHFT      0
-#define SH_LOCAL_INT4_ENABLE_PI_HW_INT_MASK      0x0000000000000001
-
-/*   SH_LOCAL_INT4_ENABLE_MD_HW_INT                                     */
-/*   Description:  Enable MD Hardware interrupt                         */
-#define SH_LOCAL_INT4_ENABLE_MD_HW_INT_SHFT      1
-#define SH_LOCAL_INT4_ENABLE_MD_HW_INT_MASK      0x0000000000000002
-
-/*   SH_LOCAL_INT4_ENABLE_XN_HW_INT                                     */
-/*   Description:  Enable XN Hardware interrupt                         */
-#define SH_LOCAL_INT4_ENABLE_XN_HW_INT_SHFT      2
-#define SH_LOCAL_INT4_ENABLE_XN_HW_INT_MASK      0x0000000000000004
-
-/*   SH_LOCAL_INT4_ENABLE_LB_HW_INT                                     */
-/*   Description:  Enable LB Hardware interrupt                         */
-#define SH_LOCAL_INT4_ENABLE_LB_HW_INT_SHFT      3
-#define SH_LOCAL_INT4_ENABLE_LB_HW_INT_MASK      0x0000000000000008
-
-/*   SH_LOCAL_INT4_ENABLE_II_HW_INT                                     */
-/*   Description:  Enable II wrapper Hardware interrupt                 */
-#define SH_LOCAL_INT4_ENABLE_II_HW_INT_SHFT      4
-#define SH_LOCAL_INT4_ENABLE_II_HW_INT_MASK      0x0000000000000010
-
-/*   SH_LOCAL_INT4_ENABLE_PI_CE_INT                                     */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT4_ENABLE_PI_CE_INT_SHFT      5
-#define SH_LOCAL_INT4_ENABLE_PI_CE_INT_MASK      0x0000000000000020
-
-/*   SH_LOCAL_INT4_ENABLE_MD_CE_INT                                     */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT4_ENABLE_MD_CE_INT_SHFT      6
-#define SH_LOCAL_INT4_ENABLE_MD_CE_INT_MASK      0x0000000000000040
-
-/*   SH_LOCAL_INT4_ENABLE_XN_CE_INT                                     */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT4_ENABLE_XN_CE_INT_SHFT      7
-#define SH_LOCAL_INT4_ENABLE_XN_CE_INT_MASK      0x0000000000000080
-
-/*   SH_LOCAL_INT4_ENABLE_PI_UCE_INT                                    */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT4_ENABLE_PI_UCE_INT_SHFT     8
-#define SH_LOCAL_INT4_ENABLE_PI_UCE_INT_MASK     0x0000000000000100
-
-/*   SH_LOCAL_INT4_ENABLE_MD_UCE_INT                                    */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT4_ENABLE_MD_UCE_INT_SHFT     9
-#define SH_LOCAL_INT4_ENABLE_MD_UCE_INT_MASK     0x0000000000000200
-
-/*   SH_LOCAL_INT4_ENABLE_XN_UCE_INT                                    */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT4_ENABLE_XN_UCE_INT_SHFT     10
-#define SH_LOCAL_INT4_ENABLE_XN_UCE_INT_MASK     0x0000000000000400
-
-/*   SH_LOCAL_INT4_ENABLE_SYSTEM_SHUTDOWN_INT                           */
-/*   Description:  Enable System Shutdown Interrupt                     */
-#define SH_LOCAL_INT4_ENABLE_SYSTEM_SHUTDOWN_INT_SHFT 12
-#define SH_LOCAL_INT4_ENABLE_SYSTEM_SHUTDOWN_INT_MASK 0x0000000000001000
-
-/*   SH_LOCAL_INT4_ENABLE_UART_INT                                      */
-/*   Description:  Enable Junk Bus UART Interrupt                       */
-#define SH_LOCAL_INT4_ENABLE_UART_INT_SHFT       13
-#define SH_LOCAL_INT4_ENABLE_UART_INT_MASK       0x0000000000002000
-
-/*   SH_LOCAL_INT4_ENABLE_L1_NMI_INT                                    */
-/*   Description:  Enable L1 Controller NMI Interrupt                   */
-#define SH_LOCAL_INT4_ENABLE_L1_NMI_INT_SHFT     14
-#define SH_LOCAL_INT4_ENABLE_L1_NMI_INT_MASK     0x0000000000004000
-
-/*   SH_LOCAL_INT4_ENABLE_STOP_CLOCK                                    */
-/*   Description:  Stop Clock Interrupt                                 */
-#define SH_LOCAL_INT4_ENABLE_STOP_CLOCK_SHFT     15
-#define SH_LOCAL_INT4_ENABLE_STOP_CLOCK_MASK     0x0000000000008000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT5_CONFIG"                    */
-/*                   SHub Local Interrupt 5 Registers                   */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT5_CONFIG                     0x0000000110000980
-#define SH_LOCAL_INT5_CONFIG_MASK                0x0ff3ffffffefffff
-#define SH_LOCAL_INT5_CONFIG_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT5_CONFIG_TYPE                                          */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_LOCAL_INT5_CONFIG_TYPE_SHFT           0
-#define SH_LOCAL_INT5_CONFIG_TYPE_MASK           0x0000000000000007
-
-/*   SH_LOCAL_INT5_CONFIG_AGT                                           */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_LOCAL_INT5_CONFIG_AGT_SHFT            3
-#define SH_LOCAL_INT5_CONFIG_AGT_MASK            0x0000000000000008
-
-/*   SH_LOCAL_INT5_CONFIG_PID                                           */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_LOCAL_INT5_CONFIG_PID_SHFT            4
-#define SH_LOCAL_INT5_CONFIG_PID_MASK            0x00000000000ffff0
-
-/*   SH_LOCAL_INT5_CONFIG_BASE                                          */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_LOCAL_INT5_CONFIG_BASE_SHFT           21
-#define SH_LOCAL_INT5_CONFIG_BASE_MASK           0x0003ffffffe00000
-
-/*   SH_LOCAL_INT5_CONFIG_IDX                                           */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_LOCAL_INT5_CONFIG_IDX_SHFT            52
-#define SH_LOCAL_INT5_CONFIG_IDX_MASK            0x0ff0000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT5_ENABLE"                    */
-/*                    SHub Local Interrupt 5 Enable                     */
-/* ==================================================================== */
-
-#define SH_LOCAL_INT5_ENABLE                     0x0000000110000a00
-#define SH_LOCAL_INT5_ENABLE_MASK                0x000000000000f7ff
-#define SH_LOCAL_INT5_ENABLE_INIT                0x0000000000000000
-
-/*   SH_LOCAL_INT5_ENABLE_PI_HW_INT                                     */
-/*   Description:  Enable PI Hardware interrupt                         */
-#define SH_LOCAL_INT5_ENABLE_PI_HW_INT_SHFT      0
-#define SH_LOCAL_INT5_ENABLE_PI_HW_INT_MASK      0x0000000000000001
-
-/*   SH_LOCAL_INT5_ENABLE_MD_HW_INT                                     */
-/*   Description:  Enable MD Hardware interrupt                         */
-#define SH_LOCAL_INT5_ENABLE_MD_HW_INT_SHFT      1
-#define SH_LOCAL_INT5_ENABLE_MD_HW_INT_MASK      0x0000000000000002
-
-/*   SH_LOCAL_INT5_ENABLE_XN_HW_INT                                     */
-/*   Description:  Enable XN Hardware interrupt                         */
-#define SH_LOCAL_INT5_ENABLE_XN_HW_INT_SHFT      2
-#define SH_LOCAL_INT5_ENABLE_XN_HW_INT_MASK      0x0000000000000004
-
-/*   SH_LOCAL_INT5_ENABLE_LB_HW_INT                                     */
-/*   Description:  Enable LB Hardware interrupt                         */
-#define SH_LOCAL_INT5_ENABLE_LB_HW_INT_SHFT      3
-#define SH_LOCAL_INT5_ENABLE_LB_HW_INT_MASK      0x0000000000000008
-
-/*   SH_LOCAL_INT5_ENABLE_II_HW_INT                                     */
-/*   Description:  Enable II wrapper Hardware interrupt                 */
-#define SH_LOCAL_INT5_ENABLE_II_HW_INT_SHFT      4
-#define SH_LOCAL_INT5_ENABLE_II_HW_INT_MASK      0x0000000000000010
-
-/*   SH_LOCAL_INT5_ENABLE_PI_CE_INT                                     */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT5_ENABLE_PI_CE_INT_SHFT      5
-#define SH_LOCAL_INT5_ENABLE_PI_CE_INT_MASK      0x0000000000000020
-
-/*   SH_LOCAL_INT5_ENABLE_MD_CE_INT                                     */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT5_ENABLE_MD_CE_INT_SHFT      6
-#define SH_LOCAL_INT5_ENABLE_MD_CE_INT_MASK      0x0000000000000040
-
-/*   SH_LOCAL_INT5_ENABLE_XN_CE_INT                                     */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT5_ENABLE_XN_CE_INT_SHFT      7
-#define SH_LOCAL_INT5_ENABLE_XN_CE_INT_MASK      0x0000000000000080
-
-/*   SH_LOCAL_INT5_ENABLE_PI_UCE_INT                                    */
-/*   Description:  Enable PI Correctable Error Interrupt                */
-#define SH_LOCAL_INT5_ENABLE_PI_UCE_INT_SHFT     8
-#define SH_LOCAL_INT5_ENABLE_PI_UCE_INT_MASK     0x0000000000000100
-
-/*   SH_LOCAL_INT5_ENABLE_MD_UCE_INT                                    */
-/*   Description:  Enable MD Correctable Error Interrupt                */
-#define SH_LOCAL_INT5_ENABLE_MD_UCE_INT_SHFT     9
-#define SH_LOCAL_INT5_ENABLE_MD_UCE_INT_MASK     0x0000000000000200
-
-/*   SH_LOCAL_INT5_ENABLE_XN_UCE_INT                                    */
-/*   Description:  Enable XN Correctable Error Interrupt                */
-#define SH_LOCAL_INT5_ENABLE_XN_UCE_INT_SHFT     10
-#define SH_LOCAL_INT5_ENABLE_XN_UCE_INT_MASK     0x0000000000000400
-
-/*   SH_LOCAL_INT5_ENABLE_SYSTEM_SHUTDOWN_INT                           */
-/*   Description:  Enable System Shutdown Interrupt                     */
-#define SH_LOCAL_INT5_ENABLE_SYSTEM_SHUTDOWN_INT_SHFT 12
-#define SH_LOCAL_INT5_ENABLE_SYSTEM_SHUTDOWN_INT_MASK 0x0000000000001000
-
-/*   SH_LOCAL_INT5_ENABLE_UART_INT                                      */
-/*   Description:  Enable Junk Bus UART Interrupt                       */
-#define SH_LOCAL_INT5_ENABLE_UART_INT_SHFT       13
-#define SH_LOCAL_INT5_ENABLE_UART_INT_MASK       0x0000000000002000
-
-/*   SH_LOCAL_INT5_ENABLE_L1_NMI_INT                                    */
-/*   Description:  Enable L1 Controller NMI Interrupt                   */
-#define SH_LOCAL_INT5_ENABLE_L1_NMI_INT_SHFT     14
-#define SH_LOCAL_INT5_ENABLE_L1_NMI_INT_MASK     0x0000000000004000
-
-/*   SH_LOCAL_INT5_ENABLE_STOP_CLOCK                                    */
-/*   Description:  Stop Clock Interrupt                                 */
-#define SH_LOCAL_INT5_ENABLE_STOP_CLOCK_SHFT     15
-#define SH_LOCAL_INT5_ENABLE_STOP_CLOCK_MASK     0x0000000000008000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ERR_INT_CONFIG"                  */
-/*              SHub Processor 0 Error Interrupt Registers              */
-/* ==================================================================== */
-
-#define SH_PROC0_ERR_INT_CONFIG                  0x0000000110000a80
-#define SH_PROC0_ERR_INT_CONFIG_MASK             0x0ff3ffffffefffff
-#define SH_PROC0_ERR_INT_CONFIG_INIT             0x0000000000000000
-
-/*   SH_PROC0_ERR_INT_CONFIG_TYPE                                       */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROC0_ERR_INT_CONFIG_TYPE_SHFT        0
-#define SH_PROC0_ERR_INT_CONFIG_TYPE_MASK        0x0000000000000007
-
-/*   SH_PROC0_ERR_INT_CONFIG_AGT                                        */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROC0_ERR_INT_CONFIG_AGT_SHFT         3
-#define SH_PROC0_ERR_INT_CONFIG_AGT_MASK         0x0000000000000008
-
-/*   SH_PROC0_ERR_INT_CONFIG_PID                                        */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROC0_ERR_INT_CONFIG_PID_SHFT         4
-#define SH_PROC0_ERR_INT_CONFIG_PID_MASK         0x00000000000ffff0
-
-/*   SH_PROC0_ERR_INT_CONFIG_BASE                                       */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROC0_ERR_INT_CONFIG_BASE_SHFT        21
-#define SH_PROC0_ERR_INT_CONFIG_BASE_MASK        0x0003ffffffe00000
-
-/*   SH_PROC0_ERR_INT_CONFIG_IDX                                        */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROC0_ERR_INT_CONFIG_IDX_SHFT         52
-#define SH_PROC0_ERR_INT_CONFIG_IDX_MASK         0x0ff0000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ERR_INT_CONFIG"                  */
-/*              SHub Processor 1 Error Interrupt Registers              */
-/* ==================================================================== */
-
-#define SH_PROC1_ERR_INT_CONFIG                  0x0000000110000b00
-#define SH_PROC1_ERR_INT_CONFIG_MASK             0x0ff3ffffffefffff
-#define SH_PROC1_ERR_INT_CONFIG_INIT             0x0000000000000000
-
-/*   SH_PROC1_ERR_INT_CONFIG_TYPE                                       */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROC1_ERR_INT_CONFIG_TYPE_SHFT        0
-#define SH_PROC1_ERR_INT_CONFIG_TYPE_MASK        0x0000000000000007
-
-/*   SH_PROC1_ERR_INT_CONFIG_AGT                                        */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROC1_ERR_INT_CONFIG_AGT_SHFT         3
-#define SH_PROC1_ERR_INT_CONFIG_AGT_MASK         0x0000000000000008
-
-/*   SH_PROC1_ERR_INT_CONFIG_PID                                        */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROC1_ERR_INT_CONFIG_PID_SHFT         4
-#define SH_PROC1_ERR_INT_CONFIG_PID_MASK         0x00000000000ffff0
-
-/*   SH_PROC1_ERR_INT_CONFIG_BASE                                       */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROC1_ERR_INT_CONFIG_BASE_SHFT        21
-#define SH_PROC1_ERR_INT_CONFIG_BASE_MASK        0x0003ffffffe00000
-
-/*   SH_PROC1_ERR_INT_CONFIG_IDX                                        */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROC1_ERR_INT_CONFIG_IDX_SHFT         52
-#define SH_PROC1_ERR_INT_CONFIG_IDX_MASK         0x0ff0000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ERR_INT_CONFIG"                  */
-/*              SHub Processor 2 Error Interrupt Registers              */
-/* ==================================================================== */
-
-#define SH_PROC2_ERR_INT_CONFIG                  0x0000000110000b80
-#define SH_PROC2_ERR_INT_CONFIG_MASK             0x0ff3ffffffefffff
-#define SH_PROC2_ERR_INT_CONFIG_INIT             0x0000000000000000
-
-/*   SH_PROC2_ERR_INT_CONFIG_TYPE                                       */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROC2_ERR_INT_CONFIG_TYPE_SHFT        0
-#define SH_PROC2_ERR_INT_CONFIG_TYPE_MASK        0x0000000000000007
-
-/*   SH_PROC2_ERR_INT_CONFIG_AGT                                        */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROC2_ERR_INT_CONFIG_AGT_SHFT         3
-#define SH_PROC2_ERR_INT_CONFIG_AGT_MASK         0x0000000000000008
-
-/*   SH_PROC2_ERR_INT_CONFIG_PID                                        */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROC2_ERR_INT_CONFIG_PID_SHFT         4
-#define SH_PROC2_ERR_INT_CONFIG_PID_MASK         0x00000000000ffff0
-
-/*   SH_PROC2_ERR_INT_CONFIG_BASE                                       */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROC2_ERR_INT_CONFIG_BASE_SHFT        21
-#define SH_PROC2_ERR_INT_CONFIG_BASE_MASK        0x0003ffffffe00000
-
-/*   SH_PROC2_ERR_INT_CONFIG_IDX                                        */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROC2_ERR_INT_CONFIG_IDX_SHFT         52
-#define SH_PROC2_ERR_INT_CONFIG_IDX_MASK         0x0ff0000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ERR_INT_CONFIG"                  */
-/*              SHub Processor 3 Error Interrupt Registers              */
-/* ==================================================================== */
-
-#define SH_PROC3_ERR_INT_CONFIG                  0x0000000110000c00
-#define SH_PROC3_ERR_INT_CONFIG_MASK             0x0ff3ffffffefffff
-#define SH_PROC3_ERR_INT_CONFIG_INIT             0x0000000000000000
-
-/*   SH_PROC3_ERR_INT_CONFIG_TYPE                                       */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROC3_ERR_INT_CONFIG_TYPE_SHFT        0
-#define SH_PROC3_ERR_INT_CONFIG_TYPE_MASK        0x0000000000000007
-
-/*   SH_PROC3_ERR_INT_CONFIG_AGT                                        */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROC3_ERR_INT_CONFIG_AGT_SHFT         3
-#define SH_PROC3_ERR_INT_CONFIG_AGT_MASK         0x0000000000000008
-
-/*   SH_PROC3_ERR_INT_CONFIG_PID                                        */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROC3_ERR_INT_CONFIG_PID_SHFT         4
-#define SH_PROC3_ERR_INT_CONFIG_PID_MASK         0x00000000000ffff0
-
-/*   SH_PROC3_ERR_INT_CONFIG_BASE                                       */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROC3_ERR_INT_CONFIG_BASE_SHFT        21
-#define SH_PROC3_ERR_INT_CONFIG_BASE_MASK        0x0003ffffffe00000
-
-/*   SH_PROC3_ERR_INT_CONFIG_IDX                                        */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROC3_ERR_INT_CONFIG_IDX_SHFT         52
-#define SH_PROC3_ERR_INT_CONFIG_IDX_MASK         0x0ff0000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ADV_INT_CONFIG"                  */
-/*            SHub Processor 0 Advisory Interrupt Registers             */
-/* ==================================================================== */
-
-#define SH_PROC0_ADV_INT_CONFIG                  0x0000000110000c80
-#define SH_PROC0_ADV_INT_CONFIG_MASK             0x0ff3ffffffefffff
-#define SH_PROC0_ADV_INT_CONFIG_INIT             0x0000000000000000
-
-/*   SH_PROC0_ADV_INT_CONFIG_TYPE                                       */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROC0_ADV_INT_CONFIG_TYPE_SHFT        0
-#define SH_PROC0_ADV_INT_CONFIG_TYPE_MASK        0x0000000000000007
-
-/*   SH_PROC0_ADV_INT_CONFIG_AGT                                        */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROC0_ADV_INT_CONFIG_AGT_SHFT         3
-#define SH_PROC0_ADV_INT_CONFIG_AGT_MASK         0x0000000000000008
-
-/*   SH_PROC0_ADV_INT_CONFIG_PID                                        */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROC0_ADV_INT_CONFIG_PID_SHFT         4
-#define SH_PROC0_ADV_INT_CONFIG_PID_MASK         0x00000000000ffff0
-
-/*   SH_PROC0_ADV_INT_CONFIG_BASE                                       */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROC0_ADV_INT_CONFIG_BASE_SHFT        21
-#define SH_PROC0_ADV_INT_CONFIG_BASE_MASK        0x0003ffffffe00000
-
-/*   SH_PROC0_ADV_INT_CONFIG_IDX                                        */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROC0_ADV_INT_CONFIG_IDX_SHFT         52
-#define SH_PROC0_ADV_INT_CONFIG_IDX_MASK         0x0ff0000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ADV_INT_CONFIG"                  */
-/*            SHub Processor 1 Advisory Interrupt Registers             */
-/* ==================================================================== */
-
-#define SH_PROC1_ADV_INT_CONFIG                  0x0000000110000d00
-#define SH_PROC1_ADV_INT_CONFIG_MASK             0x0ff3ffffffefffff
-#define SH_PROC1_ADV_INT_CONFIG_INIT             0x0000000000000000
-
-/*   SH_PROC1_ADV_INT_CONFIG_TYPE                                       */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROC1_ADV_INT_CONFIG_TYPE_SHFT        0
-#define SH_PROC1_ADV_INT_CONFIG_TYPE_MASK        0x0000000000000007
-
-/*   SH_PROC1_ADV_INT_CONFIG_AGT                                        */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROC1_ADV_INT_CONFIG_AGT_SHFT         3
-#define SH_PROC1_ADV_INT_CONFIG_AGT_MASK         0x0000000000000008
-
-/*   SH_PROC1_ADV_INT_CONFIG_PID                                        */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROC1_ADV_INT_CONFIG_PID_SHFT         4
-#define SH_PROC1_ADV_INT_CONFIG_PID_MASK         0x00000000000ffff0
-
-/*   SH_PROC1_ADV_INT_CONFIG_BASE                                       */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROC1_ADV_INT_CONFIG_BASE_SHFT        21
-#define SH_PROC1_ADV_INT_CONFIG_BASE_MASK        0x0003ffffffe00000
-
-/*   SH_PROC1_ADV_INT_CONFIG_IDX                                        */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROC1_ADV_INT_CONFIG_IDX_SHFT         52
-#define SH_PROC1_ADV_INT_CONFIG_IDX_MASK         0x0ff0000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ADV_INT_CONFIG"                  */
-/*            SHub Processor 2 Advisory Interrupt Registers             */
-/* ==================================================================== */
-
-#define SH_PROC2_ADV_INT_CONFIG                  0x0000000110000d80
-#define SH_PROC2_ADV_INT_CONFIG_MASK             0x0ff3ffffffefffff
-#define SH_PROC2_ADV_INT_CONFIG_INIT             0x0000000000000000
-
-/*   SH_PROC2_ADV_INT_CONFIG_TYPE                                       */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROC2_ADV_INT_CONFIG_TYPE_SHFT        0
-#define SH_PROC2_ADV_INT_CONFIG_TYPE_MASK        0x0000000000000007
-
-/*   SH_PROC2_ADV_INT_CONFIG_AGT                                        */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROC2_ADV_INT_CONFIG_AGT_SHFT         3
-#define SH_PROC2_ADV_INT_CONFIG_AGT_MASK         0x0000000000000008
-
-/*   SH_PROC2_ADV_INT_CONFIG_PID                                        */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROC2_ADV_INT_CONFIG_PID_SHFT         4
-#define SH_PROC2_ADV_INT_CONFIG_PID_MASK         0x00000000000ffff0
-
-/*   SH_PROC2_ADV_INT_CONFIG_BASE                                       */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROC2_ADV_INT_CONFIG_BASE_SHFT        21
-#define SH_PROC2_ADV_INT_CONFIG_BASE_MASK        0x0003ffffffe00000
-
-/*   SH_PROC2_ADV_INT_CONFIG_IDX                                        */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROC2_ADV_INT_CONFIG_IDX_SHFT         52
-#define SH_PROC2_ADV_INT_CONFIG_IDX_MASK         0x0ff0000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ADV_INT_CONFIG"                  */
-/*            SHub Processor 3 Advisory Interrupt Registers             */
-/* ==================================================================== */
-
-#define SH_PROC3_ADV_INT_CONFIG                  0x0000000110000e00
-#define SH_PROC3_ADV_INT_CONFIG_MASK             0x0ff3ffffffefffff
-#define SH_PROC3_ADV_INT_CONFIG_INIT             0x0000000000000000
-
-/*   SH_PROC3_ADV_INT_CONFIG_TYPE                                       */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROC3_ADV_INT_CONFIG_TYPE_SHFT        0
-#define SH_PROC3_ADV_INT_CONFIG_TYPE_MASK        0x0000000000000007
-
-/*   SH_PROC3_ADV_INT_CONFIG_AGT                                        */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROC3_ADV_INT_CONFIG_AGT_SHFT         3
-#define SH_PROC3_ADV_INT_CONFIG_AGT_MASK         0x0000000000000008
-
-/*   SH_PROC3_ADV_INT_CONFIG_PID                                        */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROC3_ADV_INT_CONFIG_PID_SHFT         4
-#define SH_PROC3_ADV_INT_CONFIG_PID_MASK         0x00000000000ffff0
-
-/*   SH_PROC3_ADV_INT_CONFIG_BASE                                       */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROC3_ADV_INT_CONFIG_BASE_SHFT        21
-#define SH_PROC3_ADV_INT_CONFIG_BASE_MASK        0x0003ffffffe00000
-
-/*   SH_PROC3_ADV_INT_CONFIG_IDX                                        */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROC3_ADV_INT_CONFIG_IDX_SHFT         52
-#define SH_PROC3_ADV_INT_CONFIG_IDX_MASK         0x0ff0000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ERR_INT_ENABLE"                  */
-/*          SHub Processor 0 Error Interrupt Enable Registers           */
-/* ==================================================================== */
-
-#define SH_PROC0_ERR_INT_ENABLE                  0x0000000110000e80
-#define SH_PROC0_ERR_INT_ENABLE_MASK             0x0000000000000001
-#define SH_PROC0_ERR_INT_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PROC0_ERR_INT_ENABLE_PROC0_ERR_ENABLE                           */
-/*   Description:  Enable Processor 0 Error Interrupt                   */
-#define SH_PROC0_ERR_INT_ENABLE_PROC0_ERR_ENABLE_SHFT 0
-#define SH_PROC0_ERR_INT_ENABLE_PROC0_ERR_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ERR_INT_ENABLE"                  */
-/*          SHub Processor 1 Error Interrupt Enable Registers           */
-/* ==================================================================== */
-
-#define SH_PROC1_ERR_INT_ENABLE                  0x0000000110000f00
-#define SH_PROC1_ERR_INT_ENABLE_MASK             0x0000000000000001
-#define SH_PROC1_ERR_INT_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PROC1_ERR_INT_ENABLE_PROC1_ERR_ENABLE                           */
-/*   Description:  Enable Processor 1 Error Interrupt                   */
-#define SH_PROC1_ERR_INT_ENABLE_PROC1_ERR_ENABLE_SHFT 0
-#define SH_PROC1_ERR_INT_ENABLE_PROC1_ERR_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ERR_INT_ENABLE"                  */
-/*          SHub Processor 2 Error Interrupt Enable Registers           */
-/* ==================================================================== */
-
-#define SH_PROC2_ERR_INT_ENABLE                  0x0000000110000f80
-#define SH_PROC2_ERR_INT_ENABLE_MASK             0x0000000000000001
-#define SH_PROC2_ERR_INT_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PROC2_ERR_INT_ENABLE_PROC2_ERR_ENABLE                           */
-/*   Description:  Enable Processor 2 Error Interrupt                   */
-#define SH_PROC2_ERR_INT_ENABLE_PROC2_ERR_ENABLE_SHFT 0
-#define SH_PROC2_ERR_INT_ENABLE_PROC2_ERR_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ERR_INT_ENABLE"                  */
-/*          SHub Processor 3 Error Interrupt Enable Registers           */
-/* ==================================================================== */
-
-#define SH_PROC3_ERR_INT_ENABLE                  0x0000000110001000
-#define SH_PROC3_ERR_INT_ENABLE_MASK             0x0000000000000001
-#define SH_PROC3_ERR_INT_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PROC3_ERR_INT_ENABLE_PROC3_ERR_ENABLE                           */
-/*   Description:  Enable Processor 3 Error Interrupt                   */
-#define SH_PROC3_ERR_INT_ENABLE_PROC3_ERR_ENABLE_SHFT 0
-#define SH_PROC3_ERR_INT_ENABLE_PROC3_ERR_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ADV_INT_ENABLE"                  */
-/*         SHub Processor 0 Advisory Interrupt Enable Registers         */
-/* ==================================================================== */
-
-#define SH_PROC0_ADV_INT_ENABLE                  0x0000000110001080
-#define SH_PROC0_ADV_INT_ENABLE_MASK             0x0000000000000001
-#define SH_PROC0_ADV_INT_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PROC0_ADV_INT_ENABLE_PROC0_ADV_ENABLE                           */
-/*   Description:  Enable Processor 0 Advisory Interrupt                */
-#define SH_PROC0_ADV_INT_ENABLE_PROC0_ADV_ENABLE_SHFT 0
-#define SH_PROC0_ADV_INT_ENABLE_PROC0_ADV_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ADV_INT_ENABLE"                  */
-/*         SHub Processor 1 Advisory Interrupt Enable Registers         */
-/* ==================================================================== */
-
-#define SH_PROC1_ADV_INT_ENABLE                  0x0000000110001100
-#define SH_PROC1_ADV_INT_ENABLE_MASK             0x0000000000000001
-#define SH_PROC1_ADV_INT_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PROC1_ADV_INT_ENABLE_PROC1_ADV_ENABLE                           */
-/*   Description:  Enable Processor 1 Advisory Interrupt                */
-#define SH_PROC1_ADV_INT_ENABLE_PROC1_ADV_ENABLE_SHFT 0
-#define SH_PROC1_ADV_INT_ENABLE_PROC1_ADV_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ADV_INT_ENABLE"                  */
-/*         SHub Processor 2 Advisory Interrupt Enable Registers         */
-/* ==================================================================== */
-
-#define SH_PROC2_ADV_INT_ENABLE                  0x0000000110001180
-#define SH_PROC2_ADV_INT_ENABLE_MASK             0x0000000000000001
-#define SH_PROC2_ADV_INT_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PROC2_ADV_INT_ENABLE_PROC2_ADV_ENABLE                           */
-/*   Description:  Enable Processor 2 Advisory Interrupt                */
-#define SH_PROC2_ADV_INT_ENABLE_PROC2_ADV_ENABLE_SHFT 0
-#define SH_PROC2_ADV_INT_ENABLE_PROC2_ADV_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ADV_INT_ENABLE"                  */
-/*         SHub Processor 3 Advisory Interrupt Enable Registers         */
-/* ==================================================================== */
-
-#define SH_PROC3_ADV_INT_ENABLE                  0x0000000110001200
-#define SH_PROC3_ADV_INT_ENABLE_MASK             0x0000000000000001
-#define SH_PROC3_ADV_INT_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PROC3_ADV_INT_ENABLE_PROC3_ADV_ENABLE                           */
-/*   Description:  Enable Processor 3 Advisory Interrupt                */
-#define SH_PROC3_ADV_INT_ENABLE_PROC3_ADV_ENABLE_SHFT 0
-#define SH_PROC3_ADV_INT_ENABLE_PROC3_ADV_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                   Register "SH_PROFILE_INT_CONFIG"                   */
-/*            SHub Profile Interrupt Configuration Registers            */
-/* ==================================================================== */
-
-#define SH_PROFILE_INT_CONFIG                    0x0000000110001280
-#define SH_PROFILE_INT_CONFIG_MASK               0x0ff3ffffffefffff
-#define SH_PROFILE_INT_CONFIG_INIT               0x0000000000000000
-
-/*   SH_PROFILE_INT_CONFIG_TYPE                                         */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_PROFILE_INT_CONFIG_TYPE_SHFT          0
-#define SH_PROFILE_INT_CONFIG_TYPE_MASK          0x0000000000000007
-
-/*   SH_PROFILE_INT_CONFIG_AGT                                          */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_PROFILE_INT_CONFIG_AGT_SHFT           3
-#define SH_PROFILE_INT_CONFIG_AGT_MASK           0x0000000000000008
-
-/*   SH_PROFILE_INT_CONFIG_PID                                          */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_PROFILE_INT_CONFIG_PID_SHFT           4
-#define SH_PROFILE_INT_CONFIG_PID_MASK           0x00000000000ffff0
-
-/*   SH_PROFILE_INT_CONFIG_BASE                                         */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_PROFILE_INT_CONFIG_BASE_SHFT          21
-#define SH_PROFILE_INT_CONFIG_BASE_MASK          0x0003ffffffe00000
-
-/*   SH_PROFILE_INT_CONFIG_IDX                                          */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_PROFILE_INT_CONFIG_IDX_SHFT           52
-#define SH_PROFILE_INT_CONFIG_IDX_MASK           0x0ff0000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_PROFILE_INT_ENABLE"                   */
-/*               SHub Profile Interrupt Enable Registers                */
-/* ==================================================================== */
-
-#define SH_PROFILE_INT_ENABLE                    0x0000000110001300
-#define SH_PROFILE_INT_ENABLE_MASK               0x0000000000000001
-#define SH_PROFILE_INT_ENABLE_INIT               0x0000000000000000
-
-/*   SH_PROFILE_INT_ENABLE_PROFILE_ENABLE                               */
-/*   Description:  Enable Profile Interrupt                             */
-#define SH_PROFILE_INT_ENABLE_PROFILE_ENABLE_SHFT 0
-#define SH_PROFILE_INT_ENABLE_PROFILE_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                    Register "SH_RTC0_INT_CONFIG"                     */
-/*                SHub RTC 0 Interrupt Config Registers                 */
-/* ==================================================================== */
-
-#define SH_RTC0_INT_CONFIG                       0x0000000110001380
-#define SH_RTC0_INT_CONFIG_MASK                  0x0ff3ffffffefffff
-#define SH_RTC0_INT_CONFIG_INIT                  0x0000000000000000
-
-/*   SH_RTC0_INT_CONFIG_TYPE                                            */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_RTC0_INT_CONFIG_TYPE_SHFT             0
-#define SH_RTC0_INT_CONFIG_TYPE_MASK             0x0000000000000007
-
-/*   SH_RTC0_INT_CONFIG_AGT                                             */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_RTC0_INT_CONFIG_AGT_SHFT              3
-#define SH_RTC0_INT_CONFIG_AGT_MASK              0x0000000000000008
-
-/*   SH_RTC0_INT_CONFIG_PID                                             */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_RTC0_INT_CONFIG_PID_SHFT              4
-#define SH_RTC0_INT_CONFIG_PID_MASK              0x00000000000ffff0
-
-/*   SH_RTC0_INT_CONFIG_BASE                                            */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_RTC0_INT_CONFIG_BASE_SHFT             21
-#define SH_RTC0_INT_CONFIG_BASE_MASK             0x0003ffffffe00000
-
-/*   SH_RTC0_INT_CONFIG_IDX                                             */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_RTC0_INT_CONFIG_IDX_SHFT              52
-#define SH_RTC0_INT_CONFIG_IDX_MASK              0x0ff0000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_RTC0_INT_ENABLE"                     */
-/*                SHub RTC 0 Interrupt Enable Registers                 */
-/* ==================================================================== */
-
-#define SH_RTC0_INT_ENABLE                       0x0000000110001400
-#define SH_RTC0_INT_ENABLE_MASK                  0x0000000000000001
-#define SH_RTC0_INT_ENABLE_INIT                  0x0000000000000000
-
-/*   SH_RTC0_INT_ENABLE_RTC0_ENABLE                                     */
-/*   Description:  Enable RTC 0 Interrupt                               */
-#define SH_RTC0_INT_ENABLE_RTC0_ENABLE_SHFT      0
-#define SH_RTC0_INT_ENABLE_RTC0_ENABLE_MASK      0x0000000000000001
-
-/* ==================================================================== */
-/*                    Register "SH_RTC1_INT_CONFIG"                     */
-/*                SHub RTC 1 Interrupt Config Registers                 */
-/* ==================================================================== */
-
-#define SH_RTC1_INT_CONFIG                       0x0000000110001480
-#define SH_RTC1_INT_CONFIG_MASK                  0x0ff3ffffffefffff
-#define SH_RTC1_INT_CONFIG_INIT                  0x0000000000000000
-
-/*   SH_RTC1_INT_CONFIG_TYPE                                            */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_RTC1_INT_CONFIG_TYPE_SHFT             0
-#define SH_RTC1_INT_CONFIG_TYPE_MASK             0x0000000000000007
-
-/*   SH_RTC1_INT_CONFIG_AGT                                             */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_RTC1_INT_CONFIG_AGT_SHFT              3
-#define SH_RTC1_INT_CONFIG_AGT_MASK              0x0000000000000008
-
-/*   SH_RTC1_INT_CONFIG_PID                                             */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_RTC1_INT_CONFIG_PID_SHFT              4
-#define SH_RTC1_INT_CONFIG_PID_MASK              0x00000000000ffff0
-
-/*   SH_RTC1_INT_CONFIG_BASE                                            */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_RTC1_INT_CONFIG_BASE_SHFT             21
-#define SH_RTC1_INT_CONFIG_BASE_MASK             0x0003ffffffe00000
-
-/*   SH_RTC1_INT_CONFIG_IDX                                             */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_RTC1_INT_CONFIG_IDX_SHFT              52
-#define SH_RTC1_INT_CONFIG_IDX_MASK              0x0ff0000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_RTC1_INT_ENABLE"                     */
-/*                SHub RTC 1 Interrupt Enable Registers                 */
-/* ==================================================================== */
-
-#define SH_RTC1_INT_ENABLE                       0x0000000110001500
-#define SH_RTC1_INT_ENABLE_MASK                  0x0000000000000001
-#define SH_RTC1_INT_ENABLE_INIT                  0x0000000000000000
-
-/*   SH_RTC1_INT_ENABLE_RTC1_ENABLE                                     */
-/*   Description:  Enable RTC 1 Interrupt                               */
-#define SH_RTC1_INT_ENABLE_RTC1_ENABLE_SHFT      0
-#define SH_RTC1_INT_ENABLE_RTC1_ENABLE_MASK      0x0000000000000001
-
-/* ==================================================================== */
-/*                    Register "SH_RTC2_INT_CONFIG"                     */
-/*                SHub RTC 2 Interrupt Config Registers                 */
-/* ==================================================================== */
-
-#define SH_RTC2_INT_CONFIG                       0x0000000110001580
-#define SH_RTC2_INT_CONFIG_MASK                  0x0ff3ffffffefffff
-#define SH_RTC2_INT_CONFIG_INIT                  0x0000000000000000
-
-/*   SH_RTC2_INT_CONFIG_TYPE                                            */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_RTC2_INT_CONFIG_TYPE_SHFT             0
-#define SH_RTC2_INT_CONFIG_TYPE_MASK             0x0000000000000007
-
-/*   SH_RTC2_INT_CONFIG_AGT                                             */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_RTC2_INT_CONFIG_AGT_SHFT              3
-#define SH_RTC2_INT_CONFIG_AGT_MASK              0x0000000000000008
-
-/*   SH_RTC2_INT_CONFIG_PID                                             */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_RTC2_INT_CONFIG_PID_SHFT              4
-#define SH_RTC2_INT_CONFIG_PID_MASK              0x00000000000ffff0
-
-/*   SH_RTC2_INT_CONFIG_BASE                                            */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_RTC2_INT_CONFIG_BASE_SHFT             21
-#define SH_RTC2_INT_CONFIG_BASE_MASK             0x0003ffffffe00000
-
-/*   SH_RTC2_INT_CONFIG_IDX                                             */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_RTC2_INT_CONFIG_IDX_SHFT              52
-#define SH_RTC2_INT_CONFIG_IDX_MASK              0x0ff0000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_RTC2_INT_ENABLE"                     */
-/*                SHub RTC 2 Interrupt Enable Registers                 */
-/* ==================================================================== */
-
-#define SH_RTC2_INT_ENABLE                       0x0000000110001600
-#define SH_RTC2_INT_ENABLE_MASK                  0x0000000000000001
-#define SH_RTC2_INT_ENABLE_INIT                  0x0000000000000000
-
-/*   SH_RTC2_INT_ENABLE_RTC2_ENABLE                                     */
-/*   Description:  Enable RTC 2 Interrupt                               */
-#define SH_RTC2_INT_ENABLE_RTC2_ENABLE_SHFT      0
-#define SH_RTC2_INT_ENABLE_RTC2_ENABLE_MASK      0x0000000000000001
-
-/* ==================================================================== */
-/*                    Register "SH_RTC3_INT_CONFIG"                     */
-/*                SHub RTC 3 Interrupt Config Registers                 */
-/* ==================================================================== */
-
-#define SH_RTC3_INT_CONFIG                       0x0000000110001680
-#define SH_RTC3_INT_CONFIG_MASK                  0x0ff3ffffffefffff
-#define SH_RTC3_INT_CONFIG_INIT                  0x0000000000000000
-
-/*   SH_RTC3_INT_CONFIG_TYPE                                            */
-/*   Description:  Type of Interrupt: 0=INT, 2=PMI, 4=NMI, 5=INIT       */
-#define SH_RTC3_INT_CONFIG_TYPE_SHFT             0
-#define SH_RTC3_INT_CONFIG_TYPE_MASK             0x0000000000000007
-
-/*   SH_RTC3_INT_CONFIG_AGT                                             */
-/*   Description:  Agent, must be 0 for SHub                            */
-#define SH_RTC3_INT_CONFIG_AGT_SHFT              3
-#define SH_RTC3_INT_CONFIG_AGT_MASK              0x0000000000000008
-
-/*   SH_RTC3_INT_CONFIG_PID                                             */
-/*   Description:  Processor ID, same setting as on targeted McKinley  */
-#define SH_RTC3_INT_CONFIG_PID_SHFT              4
-#define SH_RTC3_INT_CONFIG_PID_MASK              0x00000000000ffff0
-
-/*   SH_RTC3_INT_CONFIG_BASE                                            */
-/*   Description:  Optional interrupt vector area, 2MB aligned          */
-#define SH_RTC3_INT_CONFIG_BASE_SHFT             21
-#define SH_RTC3_INT_CONFIG_BASE_MASK             0x0003ffffffe00000
-
-/*   SH_RTC3_INT_CONFIG_IDX                                             */
-/*   Description:  Targeted McKinley interrupt vector                   */
-#define SH_RTC3_INT_CONFIG_IDX_SHFT              52
-#define SH_RTC3_INT_CONFIG_IDX_MASK              0x0ff0000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_RTC3_INT_ENABLE"                     */
-/*                SHub RTC 3 Interrupt Enable Registers                 */
-/* ==================================================================== */
-
-#define SH_RTC3_INT_ENABLE                       0x0000000110001700
-#define SH_RTC3_INT_ENABLE_MASK                  0x0000000000000001
-#define SH_RTC3_INT_ENABLE_INIT                  0x0000000000000000
-
-/*   SH_RTC3_INT_ENABLE_RTC3_ENABLE                                     */
-/*   Description:  Enable RTC 3 Interrupt                               */
-#define SH_RTC3_INT_ENABLE_RTC3_ENABLE_SHFT      0
-#define SH_RTC3_INT_ENABLE_RTC3_ENABLE_MASK      0x0000000000000001
-
-/* ==================================================================== */
-/*                     Register "SH_EVENT_OCCURRED"                     */
-/*                    SHub Interrupt Event Occurred                     */
-/* ==================================================================== */
-
-#define SH_EVENT_OCCURRED                        0x0000000110010000
-#define SH_EVENT_OCCURRED_MASK                   0x000000007fffffff
-#define SH_EVENT_OCCURRED_INIT                   0x0000000000000000
-
-/*   SH_EVENT_OCCURRED_PI_HW_INT                                        */
-/*   Description:  Pending PI Hardware interrupt                        */
-#define SH_EVENT_OCCURRED_PI_HW_INT_SHFT         0
-#define SH_EVENT_OCCURRED_PI_HW_INT_MASK         0x0000000000000001
-
-/*   SH_EVENT_OCCURRED_MD_HW_INT                                        */
-/*   Description:  Pending MD Hardware interrupt                        */
-#define SH_EVENT_OCCURRED_MD_HW_INT_SHFT         1
-#define SH_EVENT_OCCURRED_MD_HW_INT_MASK         0x0000000000000002
-
-/*   SH_EVENT_OCCURRED_XN_HW_INT                                        */
-/*   Description:  Pending XN Hardware interrupt                        */
-#define SH_EVENT_OCCURRED_XN_HW_INT_SHFT         2
-#define SH_EVENT_OCCURRED_XN_HW_INT_MASK         0x0000000000000004
-
-/*   SH_EVENT_OCCURRED_LB_HW_INT                                        */
-/*   Description:  Pending LB Hardware interrupt                        */
-#define SH_EVENT_OCCURRED_LB_HW_INT_SHFT         3
-#define SH_EVENT_OCCURRED_LB_HW_INT_MASK         0x0000000000000008
-
-/*   SH_EVENT_OCCURRED_II_HW_INT                                        */
-/*   Description:  Pending II wrapper Hardware interrupt                */
-#define SH_EVENT_OCCURRED_II_HW_INT_SHFT         4
-#define SH_EVENT_OCCURRED_II_HW_INT_MASK         0x0000000000000010
-
-/*   SH_EVENT_OCCURRED_PI_CE_INT                                        */
-/*   Description:  Pending PI Correctable Error Interrupt               */
-#define SH_EVENT_OCCURRED_PI_CE_INT_SHFT         5
-#define SH_EVENT_OCCURRED_PI_CE_INT_MASK         0x0000000000000020
-
-/*   SH_EVENT_OCCURRED_MD_CE_INT                                        */
-/*   Description:  Pending MD Correctable Error Interrupt               */
-#define SH_EVENT_OCCURRED_MD_CE_INT_SHFT         6
-#define SH_EVENT_OCCURRED_MD_CE_INT_MASK         0x0000000000000040
-
-/*   SH_EVENT_OCCURRED_XN_CE_INT                                        */
-/*   Description:  Pending XN Correctable Error Interrupt               */
-#define SH_EVENT_OCCURRED_XN_CE_INT_SHFT         7
-#define SH_EVENT_OCCURRED_XN_CE_INT_MASK         0x0000000000000080
-
-/*   SH_EVENT_OCCURRED_PI_UCE_INT                                       */
-/*   Description:  Pending PI Correctable Error Interrupt               */
-#define SH_EVENT_OCCURRED_PI_UCE_INT_SHFT        8
-#define SH_EVENT_OCCURRED_PI_UCE_INT_MASK        0x0000000000000100
-
-/*   SH_EVENT_OCCURRED_MD_UCE_INT                                       */
-/*   Description:  Pending MD Correctable Error Interrupt               */
-#define SH_EVENT_OCCURRED_MD_UCE_INT_SHFT        9
-#define SH_EVENT_OCCURRED_MD_UCE_INT_MASK        0x0000000000000200
-
-/*   SH_EVENT_OCCURRED_XN_UCE_INT                                       */
-/*   Description:  Pending XN Correctable Error Interrupt               */
-#define SH_EVENT_OCCURRED_XN_UCE_INT_SHFT        10
-#define SH_EVENT_OCCURRED_XN_UCE_INT_MASK        0x0000000000000400
-
-/*   SH_EVENT_OCCURRED_PROC0_ADV_INT                                    */
-/*   Description:  Pending Processor 0 Advisory Interrupt               */
-#define SH_EVENT_OCCURRED_PROC0_ADV_INT_SHFT     11
-#define SH_EVENT_OCCURRED_PROC0_ADV_INT_MASK     0x0000000000000800
-
-/*   SH_EVENT_OCCURRED_PROC1_ADV_INT                                    */
-/*   Description:  Pending Processor 1 Advisory Interrupt               */
-#define SH_EVENT_OCCURRED_PROC1_ADV_INT_SHFT     12
-#define SH_EVENT_OCCURRED_PROC1_ADV_INT_MASK     0x0000000000001000
-
-/*   SH_EVENT_OCCURRED_PROC2_ADV_INT                                    */
-/*   Description:  Pending Processor 2 Advisory Interrupt               */
-#define SH_EVENT_OCCURRED_PROC2_ADV_INT_SHFT     13
-#define SH_EVENT_OCCURRED_PROC2_ADV_INT_MASK     0x0000000000002000
-
-/*   SH_EVENT_OCCURRED_PROC3_ADV_INT                                    */
-/*   Description:  Pending Processor 3 Advisory Interrupt               */
-#define SH_EVENT_OCCURRED_PROC3_ADV_INT_SHFT     14
-#define SH_EVENT_OCCURRED_PROC3_ADV_INT_MASK     0x0000000000004000
-
-/*   SH_EVENT_OCCURRED_PROC0_ERR_INT                                    */
-/*   Description:  Pending Processor 0 Error Interrupt                  */
-#define SH_EVENT_OCCURRED_PROC0_ERR_INT_SHFT     15
-#define SH_EVENT_OCCURRED_PROC0_ERR_INT_MASK     0x0000000000008000
-
-/*   SH_EVENT_OCCURRED_PROC1_ERR_INT                                    */
-/*   Description:  Pending Processor 1 Error Interrupt                  */
-#define SH_EVENT_OCCURRED_PROC1_ERR_INT_SHFT     16
-#define SH_EVENT_OCCURRED_PROC1_ERR_INT_MASK     0x0000000000010000
-
-/*   SH_EVENT_OCCURRED_PROC2_ERR_INT                                    */
-/*   Description:  Pending Processor 2 Error Interrupt                  */
-#define SH_EVENT_OCCURRED_PROC2_ERR_INT_SHFT     17
-#define SH_EVENT_OCCURRED_PROC2_ERR_INT_MASK     0x0000000000020000
-
-/*   SH_EVENT_OCCURRED_PROC3_ERR_INT                                    */
-/*   Description:  Pending Processor 3 Error Interrupt                  */
-#define SH_EVENT_OCCURRED_PROC3_ERR_INT_SHFT     18
-#define SH_EVENT_OCCURRED_PROC3_ERR_INT_MASK     0x0000000000040000
-
-/*   SH_EVENT_OCCURRED_SYSTEM_SHUTDOWN_INT                              */
-/*   Description:  Pending System Shutdown Interrupt                    */
-#define SH_EVENT_OCCURRED_SYSTEM_SHUTDOWN_INT_SHFT 19
-#define SH_EVENT_OCCURRED_SYSTEM_SHUTDOWN_INT_MASK 0x0000000000080000
-
-/*   SH_EVENT_OCCURRED_UART_INT                                         */
-/*   Description:  Pending Junk Bus UART Interrupt                      */
-#define SH_EVENT_OCCURRED_UART_INT_SHFT          20
-#define SH_EVENT_OCCURRED_UART_INT_MASK          0x0000000000100000
-
-/*   SH_EVENT_OCCURRED_L1_NMI_INT                                       */
-/*   Description:  Pending L1 Controller NMI Interrupt                  */
-#define SH_EVENT_OCCURRED_L1_NMI_INT_SHFT        21
-#define SH_EVENT_OCCURRED_L1_NMI_INT_MASK        0x0000000000200000
-
-/*   SH_EVENT_OCCURRED_STOP_CLOCK                                       */
-/*   Description:  Pending Stop Clock Interrupt                         */
-#define SH_EVENT_OCCURRED_STOP_CLOCK_SHFT        22
-#define SH_EVENT_OCCURRED_STOP_CLOCK_MASK        0x0000000000400000
-
-/*   SH_EVENT_OCCURRED_RTC0_INT                                         */
-/*   Description:  Pending RTC 0 Interrupt                              */
-#define SH_EVENT_OCCURRED_RTC0_INT_SHFT          23
-#define SH_EVENT_OCCURRED_RTC0_INT_MASK          0x0000000000800000
-
-/*   SH_EVENT_OCCURRED_RTC1_INT                                         */
-/*   Description:  Pending RTC 1 Interrupt                              */
-#define SH_EVENT_OCCURRED_RTC1_INT_SHFT          24
-#define SH_EVENT_OCCURRED_RTC1_INT_MASK          0x0000000001000000
-
-/*   SH_EVENT_OCCURRED_RTC2_INT                                         */
-/*   Description:  Pending RTC 2 Interrupt                              */
-#define SH_EVENT_OCCURRED_RTC2_INT_SHFT          25
-#define SH_EVENT_OCCURRED_RTC2_INT_MASK          0x0000000002000000
-
-/*   SH_EVENT_OCCURRED_RTC3_INT                                         */
-/*   Description:  Pending RTC 3 Interrupt                              */
-#define SH_EVENT_OCCURRED_RTC3_INT_SHFT          26
-#define SH_EVENT_OCCURRED_RTC3_INT_MASK          0x0000000004000000
-
-/*   SH_EVENT_OCCURRED_PROFILE_INT                                      */
-/*   Description:  Pending Profile Interrupt                            */
-#define SH_EVENT_OCCURRED_PROFILE_INT_SHFT       27
-#define SH_EVENT_OCCURRED_PROFILE_INT_MASK       0x0000000008000000
-
-/*   SH_EVENT_OCCURRED_IPI_INT                                          */
-/*   Description:  Pending IPI Interrupt                                */
-#define SH_EVENT_OCCURRED_IPI_INT_SHFT           28
-#define SH_EVENT_OCCURRED_IPI_INT_MASK           0x0000000010000000
-
-/*   SH_EVENT_OCCURRED_II_INT0                                          */
-/*   Description:  Pending II 0 Interrupt                               */
-#define SH_EVENT_OCCURRED_II_INT0_SHFT           29
-#define SH_EVENT_OCCURRED_II_INT0_MASK           0x0000000020000000
-
-/*   SH_EVENT_OCCURRED_II_INT1                                          */
-/*   Description:  Pending II 1 Interrupt                               */
-#define SH_EVENT_OCCURRED_II_INT1_SHFT           30
-#define SH_EVENT_OCCURRED_II_INT1_MASK           0x0000000040000000
-
-/* ==================================================================== */
-/*                  Register "SH_EVENT_OCCURRED_ALIAS"                  */
-/*                 SHub Interrupt Event Occurred Alias                  */
-/* ==================================================================== */
-
-#define SH_EVENT_OCCURRED_ALIAS                  0x0000000110010008
-
-/* ==================================================================== */
-/*                     Register "SH_EVENT_OVERFLOW"                     */
-/*                SHub Interrupt Event Occurred Overflow                */
-/* ==================================================================== */
-
-#define SH_EVENT_OVERFLOW                        0x0000000110010080
-#define SH_EVENT_OVERFLOW_MASK                   0x000000000fffffff
-#define SH_EVENT_OVERFLOW_INIT                   0x0000000000000000
-
-/*   SH_EVENT_OVERFLOW_PI_HW_INT                                        */
-/*   Description:  Pending PI Hardware interrupt                        */
-#define SH_EVENT_OVERFLOW_PI_HW_INT_SHFT         0
-#define SH_EVENT_OVERFLOW_PI_HW_INT_MASK         0x0000000000000001
-
-/*   SH_EVENT_OVERFLOW_MD_HW_INT                                        */
-/*   Description:  Pending MD Hardware interrupt                        */
-#define SH_EVENT_OVERFLOW_MD_HW_INT_SHFT         1
-#define SH_EVENT_OVERFLOW_MD_HW_INT_MASK         0x0000000000000002
-
-/*   SH_EVENT_OVERFLOW_XN_HW_INT                                        */
-/*   Description:  Pending XN Hardware interrupt                        */
-#define SH_EVENT_OVERFLOW_XN_HW_INT_SHFT         2
-#define SH_EVENT_OVERFLOW_XN_HW_INT_MASK         0x0000000000000004
-
-/*   SH_EVENT_OVERFLOW_LB_HW_INT                                        */
-/*   Description:  Pending LB Hardware interrupt                        */
-#define SH_EVENT_OVERFLOW_LB_HW_INT_SHFT         3
-#define SH_EVENT_OVERFLOW_LB_HW_INT_MASK         0x0000000000000008
-
-/*   SH_EVENT_OVERFLOW_II_HW_INT                                        */
-/*   Description:  Pending II wrapper Hardware interrupt                */
-#define SH_EVENT_OVERFLOW_II_HW_INT_SHFT         4
-#define SH_EVENT_OVERFLOW_II_HW_INT_MASK         0x0000000000000010
-
-/*   SH_EVENT_OVERFLOW_PI_CE_INT                                        */
-/*   Description:  Pending PI Correctable Error Interrupt               */
-#define SH_EVENT_OVERFLOW_PI_CE_INT_SHFT         5
-#define SH_EVENT_OVERFLOW_PI_CE_INT_MASK         0x0000000000000020
-
-/*   SH_EVENT_OVERFLOW_MD_CE_INT                                        */
-/*   Description:  Pending MD Correctable Error Interrupt               */
-#define SH_EVENT_OVERFLOW_MD_CE_INT_SHFT         6
-#define SH_EVENT_OVERFLOW_MD_CE_INT_MASK         0x0000000000000040
-
-/*   SH_EVENT_OVERFLOW_XN_CE_INT                                        */
-/*   Description:  Pending XN Correctable Error Interrupt               */
-#define SH_EVENT_OVERFLOW_XN_CE_INT_SHFT         7
-#define SH_EVENT_OVERFLOW_XN_CE_INT_MASK         0x0000000000000080
-
-/*   SH_EVENT_OVERFLOW_PI_UCE_INT                                       */
-/*   Description:  Pending PI Correctable Error Interrupt               */
-#define SH_EVENT_OVERFLOW_PI_UCE_INT_SHFT        8
-#define SH_EVENT_OVERFLOW_PI_UCE_INT_MASK        0x0000000000000100
-
-/*   SH_EVENT_OVERFLOW_MD_UCE_INT                                       */
-/*   Description:  Pending MD Correctable Error Interrupt               */
-#define SH_EVENT_OVERFLOW_MD_UCE_INT_SHFT        9
-#define SH_EVENT_OVERFLOW_MD_UCE_INT_MASK        0x0000000000000200
-
-/*   SH_EVENT_OVERFLOW_XN_UCE_INT                                       */
-/*   Description:  Pending XN Correctable Error Interrupt               */
-#define SH_EVENT_OVERFLOW_XN_UCE_INT_SHFT        10
-#define SH_EVENT_OVERFLOW_XN_UCE_INT_MASK        0x0000000000000400
-
-/*   SH_EVENT_OVERFLOW_PROC0_ADV_INT                                    */
-/*   Description:  Pending Processor 0 Advisory Interrupt               */
-#define SH_EVENT_OVERFLOW_PROC0_ADV_INT_SHFT     11
-#define SH_EVENT_OVERFLOW_PROC0_ADV_INT_MASK     0x0000000000000800
-
-/*   SH_EVENT_OVERFLOW_PROC1_ADV_INT                                    */
-/*   Description:  Pending Processor 1 Advisory Interrupt               */
-#define SH_EVENT_OVERFLOW_PROC1_ADV_INT_SHFT     12
-#define SH_EVENT_OVERFLOW_PROC1_ADV_INT_MASK     0x0000000000001000
-
-/*   SH_EVENT_OVERFLOW_PROC2_ADV_INT                                    */
-/*   Description:  Pending Processor 2 Advisory Interrupt               */
-#define SH_EVENT_OVERFLOW_PROC2_ADV_INT_SHFT     13
-#define SH_EVENT_OVERFLOW_PROC2_ADV_INT_MASK     0x0000000000002000
-
-/*   SH_EVENT_OVERFLOW_PROC3_ADV_INT                                    */
-/*   Description:  Pending Processor 3 Advisory Interrupt               */
-#define SH_EVENT_OVERFLOW_PROC3_ADV_INT_SHFT     14
-#define SH_EVENT_OVERFLOW_PROC3_ADV_INT_MASK     0x0000000000004000
-
-/*   SH_EVENT_OVERFLOW_PROC0_ERR_INT                                    */
-/*   Description:  Pending Processor 0 Error Interrupt                  */
-#define SH_EVENT_OVERFLOW_PROC0_ERR_INT_SHFT     15
-#define SH_EVENT_OVERFLOW_PROC0_ERR_INT_MASK     0x0000000000008000
-
-/*   SH_EVENT_OVERFLOW_PROC1_ERR_INT                                    */
-/*   Description:  Pending Processor 1 Error Interrupt                  */
-#define SH_EVENT_OVERFLOW_PROC1_ERR_INT_SHFT     16
-#define SH_EVENT_OVERFLOW_PROC1_ERR_INT_MASK     0x0000000000010000
-
-/*   SH_EVENT_OVERFLOW_PROC2_ERR_INT                                    */
-/*   Description:  Pending Processor 2 Error Interrupt                  */
-#define SH_EVENT_OVERFLOW_PROC2_ERR_INT_SHFT     17
-#define SH_EVENT_OVERFLOW_PROC2_ERR_INT_MASK     0x0000000000020000
-
-/*   SH_EVENT_OVERFLOW_PROC3_ERR_INT                                    */
-/*   Description:  Pending Processor 3 Error Interrupt                  */
-#define SH_EVENT_OVERFLOW_PROC3_ERR_INT_SHFT     18
-#define SH_EVENT_OVERFLOW_PROC3_ERR_INT_MASK     0x0000000000040000
-
-/*   SH_EVENT_OVERFLOW_SYSTEM_SHUTDOWN_INT                              */
-/*   Description:  Pending System Shutdown Interrupt                    */
-#define SH_EVENT_OVERFLOW_SYSTEM_SHUTDOWN_INT_SHFT 19
-#define SH_EVENT_OVERFLOW_SYSTEM_SHUTDOWN_INT_MASK 0x0000000000080000
-
-/*   SH_EVENT_OVERFLOW_UART_INT                                         */
-/*   Description:  Pending Junk Bus UART Interrupt                      */
-#define SH_EVENT_OVERFLOW_UART_INT_SHFT          20
-#define SH_EVENT_OVERFLOW_UART_INT_MASK          0x0000000000100000
-
-/*   SH_EVENT_OVERFLOW_L1_NMI_INT                                       */
-/*   Description:  Pending L1 Controller NMI Interrupt                  */
-#define SH_EVENT_OVERFLOW_L1_NMI_INT_SHFT        21
-#define SH_EVENT_OVERFLOW_L1_NMI_INT_MASK        0x0000000000200000
-
-/*   SH_EVENT_OVERFLOW_STOP_CLOCK                                       */
-/*   Description:  Pending Stop Clock Interrupt                         */
-#define SH_EVENT_OVERFLOW_STOP_CLOCK_SHFT        22
-#define SH_EVENT_OVERFLOW_STOP_CLOCK_MASK        0x0000000000400000
-
-/*   SH_EVENT_OVERFLOW_RTC0_INT                                         */
-/*   Description:  Pending RTC 0 Interrupt                              */
-#define SH_EVENT_OVERFLOW_RTC0_INT_SHFT          23
-#define SH_EVENT_OVERFLOW_RTC0_INT_MASK          0x0000000000800000
-
-/*   SH_EVENT_OVERFLOW_RTC1_INT                                         */
-/*   Description:  Pending RTC 1 Interrupt                              */
-#define SH_EVENT_OVERFLOW_RTC1_INT_SHFT          24
-#define SH_EVENT_OVERFLOW_RTC1_INT_MASK          0x0000000001000000
-
-/*   SH_EVENT_OVERFLOW_RTC2_INT                                         */
-/*   Description:  Pending RTC 2 Interrupt                              */
-#define SH_EVENT_OVERFLOW_RTC2_INT_SHFT          25
-#define SH_EVENT_OVERFLOW_RTC2_INT_MASK          0x0000000002000000
-
-/*   SH_EVENT_OVERFLOW_RTC3_INT                                         */
-/*   Description:  Pending RTC 3 Interrupt                              */
-#define SH_EVENT_OVERFLOW_RTC3_INT_SHFT          26
-#define SH_EVENT_OVERFLOW_RTC3_INT_MASK          0x0000000004000000
-
-/*   SH_EVENT_OVERFLOW_PROFILE_INT                                      */
-/*   Description:  Pending Profile Interrupt                            */
-#define SH_EVENT_OVERFLOW_PROFILE_INT_SHFT       27
-#define SH_EVENT_OVERFLOW_PROFILE_INT_MASK       0x0000000008000000
-
-/* ==================================================================== */
-/*                  Register "SH_EVENT_OVERFLOW_ALIAS"                  */
-/*             SHub Interrupt Event Occurred Overflow Alias             */
-/* ==================================================================== */
-
-#define SH_EVENT_OVERFLOW_ALIAS                  0x0000000110010088
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_TIME"                      */
-/*                           Junk Bus Timing                            */
-/* ==================================================================== */
-
-#define SH_JUNK_BUS_TIME                         0x0000000110020000
-#define SH_JUNK_BUS_TIME_MASK                    0x00000000ffffffff
-#define SH_JUNK_BUS_TIME_INIT                    0x0000000040404040
-
-/*   SH_JUNK_BUS_TIME_FPROM_SETUP_HOLD                                  */
-/*   Description:  Fprom_Setup_Hold                                     */
-#define SH_JUNK_BUS_TIME_FPROM_SETUP_HOLD_SHFT   0
-#define SH_JUNK_BUS_TIME_FPROM_SETUP_HOLD_MASK   0x00000000000000ff
-
-/*   SH_JUNK_BUS_TIME_FPROM_ENABLE                                      */
-/*   Description:  Fprom_Enable                                         */
-#define SH_JUNK_BUS_TIME_FPROM_ENABLE_SHFT       8
-#define SH_JUNK_BUS_TIME_FPROM_ENABLE_MASK       0x000000000000ff00
-
-/*   SH_JUNK_BUS_TIME_UART_SETUP_HOLD                                   */
-/*   Description:  Uart_Setup_Hold                                      */
-#define SH_JUNK_BUS_TIME_UART_SETUP_HOLD_SHFT    16
-#define SH_JUNK_BUS_TIME_UART_SETUP_HOLD_MASK    0x0000000000ff0000
-
-/*   SH_JUNK_BUS_TIME_UART_ENABLE                                       */
-/*   Description:  Uart_Enable                                          */
-#define SH_JUNK_BUS_TIME_UART_ENABLE_SHFT        24
-#define SH_JUNK_BUS_TIME_UART_ENABLE_MASK        0x00000000ff000000
-
-/* ==================================================================== */
-/*                    Register "SH_JUNK_LATCH_TIME"                     */
-/*                        Junk Bus Latch Timing                         */
-/* ==================================================================== */
-
-#define SH_JUNK_LATCH_TIME                       0x0000000110020080
-#define SH_JUNK_LATCH_TIME_MASK                  0x0000000000000007
-#define SH_JUNK_LATCH_TIME_INIT                  0x0000000000000002
-
-/*   SH_JUNK_LATCH_TIME_SETUP_HOLD                                      */
-/*   Description:  Setup and Hold Time                                  */
-#define SH_JUNK_LATCH_TIME_SETUP_HOLD_SHFT       0
-#define SH_JUNK_LATCH_TIME_SETUP_HOLD_MASK       0x0000000000000007
-
-/* ==================================================================== */
-/*                    Register "SH_JUNK_NACK_RESET"                     */
-/*                     Junk Bus Nack Counter Reset                      */
-/* ==================================================================== */
-
-#define SH_JUNK_NACK_RESET                       0x0000000110020100
-#define SH_JUNK_NACK_RESET_MASK                  0x0000000000000001
-#define SH_JUNK_NACK_RESET_INIT                  0x0000000000000000
-
-/*   SH_JUNK_NACK_RESET_PULSE                                           */
-/*   Description:  Junk bus nack counter reset                          */
-#define SH_JUNK_NACK_RESET_PULSE_SHFT            0
-#define SH_JUNK_NACK_RESET_PULSE_MASK            0x0000000000000001
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_LED0"                      */
-/*                            Junk Bus LED0                             */
-/* ==================================================================== */
-
-#define SH_JUNK_BUS_LED0                         0x0000000110030000
-#define SH_JUNK_BUS_LED0_MASK                    0x00000000000000ff
-#define SH_JUNK_BUS_LED0_INIT                    0x0000000000000000
-
-/*   SH_JUNK_BUS_LED0_LED0_DATA                                         */
-/*   Description:  LED0_data                                            */
-#define SH_JUNK_BUS_LED0_LED0_DATA_SHFT          0
-#define SH_JUNK_BUS_LED0_LED0_DATA_MASK          0x00000000000000ff
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_LED1"                      */
-/*                            Junk Bus LED1                             */
-/* ==================================================================== */
-
-#define SH_JUNK_BUS_LED1                         0x0000000110030080
-#define SH_JUNK_BUS_LED1_MASK                    0x00000000000000ff
-#define SH_JUNK_BUS_LED1_INIT                    0x0000000000000000
-
-/*   SH_JUNK_BUS_LED1_LED1_DATA                                         */
-/*   Description:  LED1_data                                            */
-#define SH_JUNK_BUS_LED1_LED1_DATA_SHFT          0
-#define SH_JUNK_BUS_LED1_LED1_DATA_MASK          0x00000000000000ff
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_LED2"                      */
-/*                            Junk Bus LED2                             */
-/* ==================================================================== */
-
-#define SH_JUNK_BUS_LED2                         0x0000000110030100
-#define SH_JUNK_BUS_LED2_MASK                    0x00000000000000ff
-#define SH_JUNK_BUS_LED2_INIT                    0x0000000000000000
-
-/*   SH_JUNK_BUS_LED2_LED2_DATA                                         */
-/*   Description:  LED2_data                                            */
-#define SH_JUNK_BUS_LED2_LED2_DATA_SHFT          0
-#define SH_JUNK_BUS_LED2_LED2_DATA_MASK          0x00000000000000ff
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_LED3"                      */
-/*                            Junk Bus LED3                             */
-/* ==================================================================== */
-
-#define SH_JUNK_BUS_LED3                         0x0000000110030180
-#define SH_JUNK_BUS_LED3_MASK                    0x00000000000000ff
-#define SH_JUNK_BUS_LED3_INIT                    0x0000000000000000
-
-/*   SH_JUNK_BUS_LED3_LED3_DATA                                         */
-/*   Description:  LED3_data                                            */
-#define SH_JUNK_BUS_LED3_LED3_DATA_SHFT          0
-#define SH_JUNK_BUS_LED3_LED3_DATA_MASK          0x00000000000000ff
-
-/* ==================================================================== */
-/*                   Register "SH_JUNK_ERROR_STATUS"                    */
-/*                        Junk Bus Error Status                         */
-/* ==================================================================== */
-
-#define SH_JUNK_ERROR_STATUS                     0x0000000110030200
-#define SH_JUNK_ERROR_STATUS_MASK                0x1fff7fffffffffff
-#define SH_JUNK_ERROR_STATUS_INIT                0x0000000000000000
-
-/*   SH_JUNK_ERROR_STATUS_ADDRESS                                       */
-/*   Description:  Failing junk bus address                             */
-#define SH_JUNK_ERROR_STATUS_ADDRESS_SHFT        0
-#define SH_JUNK_ERROR_STATUS_ADDRESS_MASK        0x00007fffffffffff
-
-/*   SH_JUNK_ERROR_STATUS_CMD                                           */
-/*   Description:  Junk bus command                                     */
-#define SH_JUNK_ERROR_STATUS_CMD_SHFT            48
-#define SH_JUNK_ERROR_STATUS_CMD_MASK            0x00ff000000000000
-
-/*   SH_JUNK_ERROR_STATUS_MODE                                          */
-/*   Description:  Mode                                                 */
-#define SH_JUNK_ERROR_STATUS_MODE_SHFT           56
-#define SH_JUNK_ERROR_STATUS_MODE_MASK           0x0100000000000000
-
-/*   SH_JUNK_ERROR_STATUS_STATUS                                        */
-/*   Description:  Status                                               */
-#define SH_JUNK_ERROR_STATUS_STATUS_SHFT         57
-#define SH_JUNK_ERROR_STATUS_STATUS_MASK         0x1e00000000000000
-
-/* ==================================================================== */
-/*                      Register "SH_NI0_LLP_STAT"                      */
-/*               This register describes the LLP status.                */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_STAT                          0x0000000150000000
-#define SH_NI0_LLP_STAT_MASK                     0x000000000000000f
-#define SH_NI0_LLP_STAT_INIT                     0x0000000000000000
-
-/*   SH_NI0_LLP_STAT_LINK_RESET_STATE                                   */
-/*   Description:  Status of LLP link.                                  */
-#define SH_NI0_LLP_STAT_LINK_RESET_STATE_SHFT    0
-#define SH_NI0_LLP_STAT_LINK_RESET_STATE_MASK    0x000000000000000f
-
-/* ==================================================================== */
-/*                     Register "SH_NI0_LLP_RESET"                      */
-/*           Writing issues a reset to the network interface            */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_RESET                         0x0000000150000008
-#define SH_NI0_LLP_RESET_MASK                    0x0000000000000003
-#define SH_NI0_LLP_RESET_INIT                    0x0000000000000000
-
-/*   SH_NI0_LLP_RESET_LINK                                              */
-/*   Description:  Send Link Reset. Generates a pulse.                  */
-#define SH_NI0_LLP_RESET_LINK_SHFT               0
-#define SH_NI0_LLP_RESET_LINK_MASK               0x0000000000000001
-
-/*   SH_NI0_LLP_RESET_WARM                                              */
-/*   Description:  Send Warm Reset. Generates a pulse.                  */
-#define SH_NI0_LLP_RESET_WARM_SHFT               1
-#define SH_NI0_LLP_RESET_WARM_MASK               0x0000000000000002
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LLP_RESET_EN"                    */
-/*                 Controls LLP warm reset propagation                  */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_RESET_EN                      0x0000000150000010
-#define SH_NI0_LLP_RESET_EN_MASK                 0x0000000000000001
-#define SH_NI0_LLP_RESET_EN_INIT                 0x0000000000000001
-
-/*   SH_NI0_LLP_RESET_EN_OK                                             */
-/*   Description:  Allow LLP warm reset to reset SHUB                   */
-#define SH_NI0_LLP_RESET_EN_OK_SHFT              0
-#define SH_NI0_LLP_RESET_EN_OK_MASK              0x0000000000000001
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_LLP_CHAN_MODE"                    */
-/*              Sets the signaling mode of LLP and channel              */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_CHAN_MODE                     0x0000000150000018
-#define SH_NI0_LLP_CHAN_MODE_MASK                0x000000000000001f
-#define SH_NI0_LLP_CHAN_MODE_INIT                0x0000000000000000
-
-/*   SH_NI0_LLP_CHAN_MODE_BITMODE32                                     */
-/*   Description:  Enables 32-bit (plus sideband) channel phits         */
-#define SH_NI0_LLP_CHAN_MODE_BITMODE32_SHFT      0
-#define SH_NI0_LLP_CHAN_MODE_BITMODE32_MASK      0x0000000000000001
-
-/*   SH_NI0_LLP_CHAN_MODE_AC_ENCODE                                     */
-/*   Description:  Enables nearly dc-free encoding for AC-coupling      */
-#define SH_NI0_LLP_CHAN_MODE_AC_ENCODE_SHFT      1
-#define SH_NI0_LLP_CHAN_MODE_AC_ENCODE_MASK      0x0000000000000002
-
-/*   SH_NI0_LLP_CHAN_MODE_ENABLE_TUNING                                 */
-/*   Description:  Enables automatic tuning of channel skew.            */
-#define SH_NI0_LLP_CHAN_MODE_ENABLE_TUNING_SHFT  2
-#define SH_NI0_LLP_CHAN_MODE_ENABLE_TUNING_MASK  0x0000000000000004
-
-/*   SH_NI0_LLP_CHAN_MODE_ENABLE_RMT_FT_UPD                             */
-/*   Description:  Enables remote fine tune updates                     */
-#define SH_NI0_LLP_CHAN_MODE_ENABLE_RMT_FT_UPD_SHFT 3
-#define SH_NI0_LLP_CHAN_MODE_ENABLE_RMT_FT_UPD_MASK 0x0000000000000008
-
-/*   SH_NI0_LLP_CHAN_MODE_ENABLE_CLKQUAD                                */
-/*   Description:  Enables quadrature clock in the pfssd                */
-#define SH_NI0_LLP_CHAN_MODE_ENABLE_CLKQUAD_SHFT 4
-#define SH_NI0_LLP_CHAN_MODE_ENABLE_CLKQUAD_MASK 0x0000000000000010
-
-/* ==================================================================== */
-/*                     Register "SH_NI0_LLP_CONFIG"                     */
-/*              Sets the configuration of LLP and channel               */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_CONFIG                        0x0000000150000020
-#define SH_NI0_LLP_CONFIG_MASK                   0x0000003fffffffff
-#define SH_NI0_LLP_CONFIG_INIT                   0x00000007fc6ffd00
-
-/*   SH_NI0_LLP_CONFIG_MAXBURST                                         */
-#define SH_NI0_LLP_CONFIG_MAXBURST_SHFT          0
-#define SH_NI0_LLP_CONFIG_MAXBURST_MASK          0x00000000000003ff
-
-/*   SH_NI0_LLP_CONFIG_MAXRETRY                                         */
-#define SH_NI0_LLP_CONFIG_MAXRETRY_SHFT          10
-#define SH_NI0_LLP_CONFIG_MAXRETRY_MASK          0x00000000000ffc00
-
-/*   SH_NI0_LLP_CONFIG_NULLTIMEOUT                                      */
-#define SH_NI0_LLP_CONFIG_NULLTIMEOUT_SHFT       20
-#define SH_NI0_LLP_CONFIG_NULLTIMEOUT_MASK       0x0000000003f00000
-
-/*   SH_NI0_LLP_CONFIG_FTU_TIME                                         */
-#define SH_NI0_LLP_CONFIG_FTU_TIME_SHFT          26
-#define SH_NI0_LLP_CONFIG_FTU_TIME_MASK          0x0000003ffc000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LLP_TEST_CTL"                    */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_TEST_CTL                      0x0000000150000028
-#define SH_NI0_LLP_TEST_CTL_MASK                 0x7ff3f3ffffffffff
-#define SH_NI0_LLP_TEST_CTL_INIT                 0x000000000a5fffff
-
-/*   SH_NI0_LLP_TEST_CTL_PATTERN                                        */
-/*   Description:  Send channel data pattern                            */
-#define SH_NI0_LLP_TEST_CTL_PATTERN_SHFT         0
-#define SH_NI0_LLP_TEST_CTL_PATTERN_MASK         0x000000ffffffffff
-
-/*   SH_NI0_LLP_TEST_CTL_SEND_TEST_MODE                                 */
-/*   Description:  Enables continuous send of data                      */
-#define SH_NI0_LLP_TEST_CTL_SEND_TEST_MODE_SHFT  40
-#define SH_NI0_LLP_TEST_CTL_SEND_TEST_MODE_MASK  0x0000030000000000
-
-/*   SH_NI0_LLP_TEST_CTL_WIRE_SEL                                       */
-#define SH_NI0_LLP_TEST_CTL_WIRE_SEL_SHFT        44
-#define SH_NI0_LLP_TEST_CTL_WIRE_SEL_MASK        0x0003f00000000000
-
-/*   SH_NI0_LLP_TEST_CTL_LFSR_MODE                                      */
-#define SH_NI0_LLP_TEST_CTL_LFSR_MODE_SHFT       52
-#define SH_NI0_LLP_TEST_CTL_LFSR_MODE_MASK       0x0030000000000000
-
-/*   SH_NI0_LLP_TEST_CTL_NOISE_MODE                                     */
-#define SH_NI0_LLP_TEST_CTL_NOISE_MODE_SHFT      54
-#define SH_NI0_LLP_TEST_CTL_NOISE_MODE_MASK      0x00c0000000000000
-
-/*   SH_NI0_LLP_TEST_CTL_ARMCAPTURE                                     */
-/*   Description:  Enable Capture of Next MicroPacket                   */
-#define SH_NI0_LLP_TEST_CTL_ARMCAPTURE_SHFT      56
-#define SH_NI0_LLP_TEST_CTL_ARMCAPTURE_MASK      0x0100000000000000
-
-/*   SH_NI0_LLP_TEST_CTL_CAPTURECBONLY                                  */
-/*   Description:  Only capture a micropacket with a Check Byte error  */
-#define SH_NI0_LLP_TEST_CTL_CAPTURECBONLY_SHFT   57
-#define SH_NI0_LLP_TEST_CTL_CAPTURECBONLY_MASK   0x0200000000000000
-
-/*   SH_NI0_LLP_TEST_CTL_SENDCBERROR                                    */
-/*   Description:  Sends a single error                                 */
-#define SH_NI0_LLP_TEST_CTL_SENDCBERROR_SHFT     58
-#define SH_NI0_LLP_TEST_CTL_SENDCBERROR_MASK     0x0400000000000000
-
-/*   SH_NI0_LLP_TEST_CTL_SENDSNERROR                                    */
-/*   Description:  Sends a single sequence number error                 */
-#define SH_NI0_LLP_TEST_CTL_SENDSNERROR_SHFT     59
-#define SH_NI0_LLP_TEST_CTL_SENDSNERROR_MASK     0x0800000000000000
-
-/*   SH_NI0_LLP_TEST_CTL_FAKESNERROR                                    */
-/*   Description:  Causes receiver to pretend it saw a sn error         */
-#define SH_NI0_LLP_TEST_CTL_FAKESNERROR_SHFT     60
-#define SH_NI0_LLP_TEST_CTL_FAKESNERROR_MASK     0x1000000000000000
-
-/*   SH_NI0_LLP_TEST_CTL_CAPTURED                                       */
-/*   Description:  Indicates a Valid Micropacket was captured           */
-#define SH_NI0_LLP_TEST_CTL_CAPTURED_SHFT        61
-#define SH_NI0_LLP_TEST_CTL_CAPTURED_MASK        0x2000000000000000
-
-/*   SH_NI0_LLP_TEST_CTL_CBERROR                                        */
-/*   Description:  Indicates a Micropacket with a CB error was capture  */
-#define SH_NI0_LLP_TEST_CTL_CBERROR_SHFT         62
-#define SH_NI0_LLP_TEST_CTL_CBERROR_MASK         0x4000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LLP_CAPT_WD1"                    */
-/*                    low order 64-bit captured word                    */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_CAPT_WD1                      0x0000000150000030
-#define SH_NI0_LLP_CAPT_WD1_MASK                 0xffffffffffffffff
-#define SH_NI0_LLP_CAPT_WD1_INIT                 0x0000000000000000
-
-/*   SH_NI0_LLP_CAPT_WD1_DATA                                           */
-/*   Description:  low order 64-bit captured word                       */
-#define SH_NI0_LLP_CAPT_WD1_DATA_SHFT            0
-#define SH_NI0_LLP_CAPT_WD1_DATA_MASK            0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LLP_CAPT_WD2"                    */
-/*                   high order 64-bit captured word                    */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_CAPT_WD2                      0x0000000150000038
-#define SH_NI0_LLP_CAPT_WD2_MASK                 0xffffffffffffffff
-#define SH_NI0_LLP_CAPT_WD2_INIT                 0x0000000000000000
-
-/*   SH_NI0_LLP_CAPT_WD2_DATA                                           */
-/*   Description:  high order 64-bit captured word                      */
-#define SH_NI0_LLP_CAPT_WD2_DATA_SHFT            0
-#define SH_NI0_LLP_CAPT_WD2_DATA_MASK            0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_LLP_CAPT_SBCB"                    */
-/*                 captured sideband, sequence, and CRC                 */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_CAPT_SBCB                     0x0000000150000040
-#define SH_NI0_LLP_CAPT_SBCB_MASK                0x0000001fffffffff
-#define SH_NI0_LLP_CAPT_SBCB_INIT                0x0000000000000000
-
-/*   SH_NI0_LLP_CAPT_SBCB_CAPTUREDRCVSBSN                               */
-/*   Description:  sideband and sequence                                */
-#define SH_NI0_LLP_CAPT_SBCB_CAPTUREDRCVSBSN_SHFT 0
-#define SH_NI0_LLP_CAPT_SBCB_CAPTUREDRCVSBSN_MASK 0x000000000000ffff
-
-/*   SH_NI0_LLP_CAPT_SBCB_CAPTUREDRCVCRC                                */
-/*   Description:  CRC                                                  */
-#define SH_NI0_LLP_CAPT_SBCB_CAPTUREDRCVCRC_SHFT 16
-#define SH_NI0_LLP_CAPT_SBCB_CAPTUREDRCVCRC_MASK 0x00000000ffff0000
-
-/*   SH_NI0_LLP_CAPT_SBCB_SENTALLCBERRORS                               */
-/*   Description:  All CB errors have been sent                         */
-#define SH_NI0_LLP_CAPT_SBCB_SENTALLCBERRORS_SHFT 32
-#define SH_NI0_LLP_CAPT_SBCB_SENTALLCBERRORS_MASK 0x0000000100000000
-
-/*   SH_NI0_LLP_CAPT_SBCB_SENTALLSNERRORS                               */
-/*   Description:  All SN errors have been sent                         */
-#define SH_NI0_LLP_CAPT_SBCB_SENTALLSNERRORS_SHFT 33
-#define SH_NI0_LLP_CAPT_SBCB_SENTALLSNERRORS_MASK 0x0000000200000000
-
-/*   SH_NI0_LLP_CAPT_SBCB_FAKEDALLSNERRORS                              */
-/*   Description:  All faked SN errors have been sent                   */
-#define SH_NI0_LLP_CAPT_SBCB_FAKEDALLSNERRORS_SHFT 34
-#define SH_NI0_LLP_CAPT_SBCB_FAKEDALLSNERRORS_MASK 0x0000000400000000
-
-/*   SH_NI0_LLP_CAPT_SBCB_CHARGEOVERFLOW                                */
-/*   Description:  wire charge counter overflowed, valid if llp_mode e  */
-#define SH_NI0_LLP_CAPT_SBCB_CHARGEOVERFLOW_SHFT 35
-#define SH_NI0_LLP_CAPT_SBCB_CHARGEOVERFLOW_MASK 0x0000000800000000
-
-/*   SH_NI0_LLP_CAPT_SBCB_CHARGEUNDERFLOW                               */
-/*   Description:  wire charge counter underflowed, valid if llp_mode   */
-/*  enabled                                                             */
-#define SH_NI0_LLP_CAPT_SBCB_CHARGEUNDERFLOW_SHFT 36
-#define SH_NI0_LLP_CAPT_SBCB_CHARGEUNDERFLOW_MASK 0x0000001000000000
-
-/* ==================================================================== */
-/*                      Register "SH_NI0_LLP_ERR"                       */
-/* ==================================================================== */
-
-#define SH_NI0_LLP_ERR                           0x0000000150000048
-#define SH_NI0_LLP_ERR_MASK                      0x001fffffffffffff
-#define SH_NI0_LLP_ERR_INIT                      0x0000000000000000
-
-/*   SH_NI0_LLP_ERR_RX_SN_ERR_COUNT                                     */
-/*   Description:  Counts the sequence number errors received           */
-#define SH_NI0_LLP_ERR_RX_SN_ERR_COUNT_SHFT      0
-#define SH_NI0_LLP_ERR_RX_SN_ERR_COUNT_MASK      0x00000000000000ff
-
-/*   SH_NI0_LLP_ERR_RX_CB_ERR_COUNT                                     */
-/*   Description:  Counts the check byte errors received                */
-#define SH_NI0_LLP_ERR_RX_CB_ERR_COUNT_SHFT      8
-#define SH_NI0_LLP_ERR_RX_CB_ERR_COUNT_MASK      0x000000000000ff00
-
-/*   SH_NI0_LLP_ERR_RETRY_COUNT                                         */
-/*   Description:  Counts the retries                                   */
-#define SH_NI0_LLP_ERR_RETRY_COUNT_SHFT          16
-#define SH_NI0_LLP_ERR_RETRY_COUNT_MASK          0x0000000000ff0000
-
-/*   SH_NI0_LLP_ERR_RETRY_TIMEOUT                                       */
-/*   Description:  Indicates a retry timeout has occurred               */
-#define SH_NI0_LLP_ERR_RETRY_TIMEOUT_SHFT        24
-#define SH_NI0_LLP_ERR_RETRY_TIMEOUT_MASK        0x0000000001000000
-
-/*   SH_NI0_LLP_ERR_RCV_LINK_RESET                                      */
-/*   Description:  Indicates a link reset has been received             */
-#define SH_NI0_LLP_ERR_RCV_LINK_RESET_SHFT       25
-#define SH_NI0_LLP_ERR_RCV_LINK_RESET_MASK       0x0000000002000000
-
-/*   SH_NI0_LLP_ERR_SQUASH                                              */
-/*   Description:  Indicates a micropacket was squashed                 */
-#define SH_NI0_LLP_ERR_SQUASH_SHFT               26
-#define SH_NI0_LLP_ERR_SQUASH_MASK               0x0000000004000000
-
-/*   SH_NI0_LLP_ERR_POWER_NOT_OK                                        */
-/*   Description:  Detects and traps a loss of power_OK                 */
-#define SH_NI0_LLP_ERR_POWER_NOT_OK_SHFT         27
-#define SH_NI0_LLP_ERR_POWER_NOT_OK_MASK         0x0000000008000000
-
-/*   SH_NI0_LLP_ERR_WIRE_CNT                                            */
-/*   Description:  counts the errors detected on a single wire test     */
-#define SH_NI0_LLP_ERR_WIRE_CNT_SHFT             28
-#define SH_NI0_LLP_ERR_WIRE_CNT_MASK             0x000ffffff0000000
-
-/*   SH_NI0_LLP_ERR_WIRE_OVERFLOW                                       */
-/*   Description:  wire_error_cnt has overflowed                        */
-#define SH_NI0_LLP_ERR_WIRE_OVERFLOW_SHFT        52
-#define SH_NI0_LLP_ERR_WIRE_OVERFLOW_MASK        0x0010000000000000
-
-/* ==================================================================== */
-/*                      Register "SH_NI1_LLP_STAT"                      */
-/*               This register describes the LLP status.                */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_STAT                          0x0000000150002000
-#define SH_NI1_LLP_STAT_MASK                     0x000000000000000f
-#define SH_NI1_LLP_STAT_INIT                     0x0000000000000000
-
-/*   SH_NI1_LLP_STAT_LINK_RESET_STATE                                   */
-/*   Description:  Status of LLP link.                                  */
-#define SH_NI1_LLP_STAT_LINK_RESET_STATE_SHFT    0
-#define SH_NI1_LLP_STAT_LINK_RESET_STATE_MASK    0x000000000000000f
-
-/* ==================================================================== */
-/*                     Register "SH_NI1_LLP_RESET"                      */
-/*           Writing issues a reset to the network interface            */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_RESET                         0x0000000150002008
-#define SH_NI1_LLP_RESET_MASK                    0x0000000000000003
-#define SH_NI1_LLP_RESET_INIT                    0x0000000000000000
-
-/*   SH_NI1_LLP_RESET_LINK                                              */
-/*   Description:  Send Link Reset. Generates a pulse.                  */
-#define SH_NI1_LLP_RESET_LINK_SHFT               0
-#define SH_NI1_LLP_RESET_LINK_MASK               0x0000000000000001
-
-/*   SH_NI1_LLP_RESET_WARM                                              */
-/*   Description:  Send Warm Reset. Generates a pulse.                  */
-#define SH_NI1_LLP_RESET_WARM_SHFT               1
-#define SH_NI1_LLP_RESET_WARM_MASK               0x0000000000000002
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LLP_RESET_EN"                    */
-/*                 Controls LLP warm reset propagation                  */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_RESET_EN                      0x0000000150002010
-#define SH_NI1_LLP_RESET_EN_MASK                 0x0000000000000001
-#define SH_NI1_LLP_RESET_EN_INIT                 0x0000000000000001
-
-/*   SH_NI1_LLP_RESET_EN_OK                                             */
-/*   Description:  Allow LLP warm reset to reset SHUB                   */
-#define SH_NI1_LLP_RESET_EN_OK_SHFT              0
-#define SH_NI1_LLP_RESET_EN_OK_MASK              0x0000000000000001
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_LLP_CHAN_MODE"                    */
-/*              Sets the signaling mode of LLP and channel              */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_CHAN_MODE                     0x0000000150002018
-#define SH_NI1_LLP_CHAN_MODE_MASK                0x000000000000001f
-#define SH_NI1_LLP_CHAN_MODE_INIT                0x0000000000000000
-
-/*   SH_NI1_LLP_CHAN_MODE_BITMODE32                                     */
-/*   Description:  Enables 32-bit (plus sideband) channel phits         */
-#define SH_NI1_LLP_CHAN_MODE_BITMODE32_SHFT      0
-#define SH_NI1_LLP_CHAN_MODE_BITMODE32_MASK      0x0000000000000001
-
-/*   SH_NI1_LLP_CHAN_MODE_AC_ENCODE                                     */
-/*   Description:  Enables nearly dc-free encoding for AC-coupling      */
-#define SH_NI1_LLP_CHAN_MODE_AC_ENCODE_SHFT      1
-#define SH_NI1_LLP_CHAN_MODE_AC_ENCODE_MASK      0x0000000000000002
-
-/*   SH_NI1_LLP_CHAN_MODE_ENABLE_TUNING                                 */
-/*   Description:  Enables automatic tuning of channel skew.            */
-#define SH_NI1_LLP_CHAN_MODE_ENABLE_TUNING_SHFT  2
-#define SH_NI1_LLP_CHAN_MODE_ENABLE_TUNING_MASK  0x0000000000000004
-
-/*   SH_NI1_LLP_CHAN_MODE_ENABLE_RMT_FT_UPD                             */
-/*   Description:  Enables remote fine tune updates                     */
-#define SH_NI1_LLP_CHAN_MODE_ENABLE_RMT_FT_UPD_SHFT 3
-#define SH_NI1_LLP_CHAN_MODE_ENABLE_RMT_FT_UPD_MASK 0x0000000000000008
-
-/*   SH_NI1_LLP_CHAN_MODE_ENABLE_CLKQUAD                                */
-/*   Description:  Enables quadrature clock in the pfssd                */
-#define SH_NI1_LLP_CHAN_MODE_ENABLE_CLKQUAD_SHFT 4
-#define SH_NI1_LLP_CHAN_MODE_ENABLE_CLKQUAD_MASK 0x0000000000000010
-
-/* ==================================================================== */
-/*                     Register "SH_NI1_LLP_CONFIG"                     */
-/*              Sets the configuration of LLP and channel               */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_CONFIG                        0x0000000150002020
-#define SH_NI1_LLP_CONFIG_MASK                   0x0000003fffffffff
-#define SH_NI1_LLP_CONFIG_INIT                   0x00000007fc6ffd00
-
-/*   SH_NI1_LLP_CONFIG_MAXBURST                                         */
-#define SH_NI1_LLP_CONFIG_MAXBURST_SHFT          0
-#define SH_NI1_LLP_CONFIG_MAXBURST_MASK          0x00000000000003ff
-
-/*   SH_NI1_LLP_CONFIG_MAXRETRY                                         */
-#define SH_NI1_LLP_CONFIG_MAXRETRY_SHFT          10
-#define SH_NI1_LLP_CONFIG_MAXRETRY_MASK          0x00000000000ffc00
-
-/*   SH_NI1_LLP_CONFIG_NULLTIMEOUT                                      */
-#define SH_NI1_LLP_CONFIG_NULLTIMEOUT_SHFT       20
-#define SH_NI1_LLP_CONFIG_NULLTIMEOUT_MASK       0x0000000003f00000
-
-/*   SH_NI1_LLP_CONFIG_FTU_TIME                                         */
-#define SH_NI1_LLP_CONFIG_FTU_TIME_SHFT          26
-#define SH_NI1_LLP_CONFIG_FTU_TIME_MASK          0x0000003ffc000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LLP_TEST_CTL"                    */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_TEST_CTL                      0x0000000150002028
-#define SH_NI1_LLP_TEST_CTL_MASK                 0x7ff3f3ffffffffff
-#define SH_NI1_LLP_TEST_CTL_INIT                 0x000000000a5fffff
-
-/*   SH_NI1_LLP_TEST_CTL_PATTERN                                        */
-/*   Description:  Send channel data pattern                            */
-#define SH_NI1_LLP_TEST_CTL_PATTERN_SHFT         0
-#define SH_NI1_LLP_TEST_CTL_PATTERN_MASK         0x000000ffffffffff
-
-/*   SH_NI1_LLP_TEST_CTL_SEND_TEST_MODE                                 */
-/*   Description:  Enables continuous send of data                      */
-#define SH_NI1_LLP_TEST_CTL_SEND_TEST_MODE_SHFT  40
-#define SH_NI1_LLP_TEST_CTL_SEND_TEST_MODE_MASK  0x0000030000000000
-
-/*   SH_NI1_LLP_TEST_CTL_WIRE_SEL                                       */
-#define SH_NI1_LLP_TEST_CTL_WIRE_SEL_SHFT        44
-#define SH_NI1_LLP_TEST_CTL_WIRE_SEL_MASK        0x0003f00000000000
-
-/*   SH_NI1_LLP_TEST_CTL_LFSR_MODE                                      */
-#define SH_NI1_LLP_TEST_CTL_LFSR_MODE_SHFT       52
-#define SH_NI1_LLP_TEST_CTL_LFSR_MODE_MASK       0x0030000000000000
-
-/*   SH_NI1_LLP_TEST_CTL_NOISE_MODE                                     */
-#define SH_NI1_LLP_TEST_CTL_NOISE_MODE_SHFT      54
-#define SH_NI1_LLP_TEST_CTL_NOISE_MODE_MASK      0x00c0000000000000
-
-/*   SH_NI1_LLP_TEST_CTL_ARMCAPTURE                                     */
-/*   Description:  Enable Capture of Next MicroPacket                   */
-#define SH_NI1_LLP_TEST_CTL_ARMCAPTURE_SHFT      56
-#define SH_NI1_LLP_TEST_CTL_ARMCAPTURE_MASK      0x0100000000000000
-
-/*   SH_NI1_LLP_TEST_CTL_CAPTURECBONLY                                  */
-/*   Description:  Only capture a micropacket with a Check Byte error  */
-#define SH_NI1_LLP_TEST_CTL_CAPTURECBONLY_SHFT   57
-#define SH_NI1_LLP_TEST_CTL_CAPTURECBONLY_MASK   0x0200000000000000
-
-/*   SH_NI1_LLP_TEST_CTL_SENDCBERROR                                    */
-/*   Description:  Sends a single error                                 */
-#define SH_NI1_LLP_TEST_CTL_SENDCBERROR_SHFT     58
-#define SH_NI1_LLP_TEST_CTL_SENDCBERROR_MASK     0x0400000000000000
-
-/*   SH_NI1_LLP_TEST_CTL_SENDSNERROR                                    */
-/*   Description:  Sends a single sequence number error                 */
-#define SH_NI1_LLP_TEST_CTL_SENDSNERROR_SHFT     59
-#define SH_NI1_LLP_TEST_CTL_SENDSNERROR_MASK     0x0800000000000000
-
-/*   SH_NI1_LLP_TEST_CTL_FAKESNERROR                                    */
-/*   Description:  Causes receiver to pretend it saw a sn error         */
-#define SH_NI1_LLP_TEST_CTL_FAKESNERROR_SHFT     60
-#define SH_NI1_LLP_TEST_CTL_FAKESNERROR_MASK     0x1000000000000000
-
-/*   SH_NI1_LLP_TEST_CTL_CAPTURED                                       */
-/*   Description:  Indicates a Valid Micropacket was captured           */
-#define SH_NI1_LLP_TEST_CTL_CAPTURED_SHFT        61
-#define SH_NI1_LLP_TEST_CTL_CAPTURED_MASK        0x2000000000000000
-
-/*   SH_NI1_LLP_TEST_CTL_CBERROR                                        */
-/*   Description:  Indicates a Micropacket with a CB error was capture  */
-#define SH_NI1_LLP_TEST_CTL_CBERROR_SHFT         62
-#define SH_NI1_LLP_TEST_CTL_CBERROR_MASK         0x4000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LLP_CAPT_WD1"                    */
-/*                    low order 64-bit captured word                    */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_CAPT_WD1                      0x0000000150002030
-#define SH_NI1_LLP_CAPT_WD1_MASK                 0xffffffffffffffff
-#define SH_NI1_LLP_CAPT_WD1_INIT                 0x0000000000000000
-
-/*   SH_NI1_LLP_CAPT_WD1_DATA                                           */
-/*   Description:  low order 64-bit captured word                       */
-#define SH_NI1_LLP_CAPT_WD1_DATA_SHFT            0
-#define SH_NI1_LLP_CAPT_WD1_DATA_MASK            0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LLP_CAPT_WD2"                    */
-/*                   high order 64-bit captured word                    */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_CAPT_WD2                      0x0000000150002038
-#define SH_NI1_LLP_CAPT_WD2_MASK                 0xffffffffffffffff
-#define SH_NI1_LLP_CAPT_WD2_INIT                 0x0000000000000000
-
-/*   SH_NI1_LLP_CAPT_WD2_DATA                                           */
-/*   Description:  high order 64-bit captured word                      */
-#define SH_NI1_LLP_CAPT_WD2_DATA_SHFT            0
-#define SH_NI1_LLP_CAPT_WD2_DATA_MASK            0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_LLP_CAPT_SBCB"                    */
-/*                 captured sideband, sequence, and CRC                 */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_CAPT_SBCB                     0x0000000150002040
-#define SH_NI1_LLP_CAPT_SBCB_MASK                0x0000001fffffffff
-#define SH_NI1_LLP_CAPT_SBCB_INIT                0x0000000000000000
-
-/*   SH_NI1_LLP_CAPT_SBCB_CAPTUREDRCVSBSN                               */
-/*   Description:  sideband and sequence                                */
-#define SH_NI1_LLP_CAPT_SBCB_CAPTUREDRCVSBSN_SHFT 0
-#define SH_NI1_LLP_CAPT_SBCB_CAPTUREDRCVSBSN_MASK 0x000000000000ffff
-
-/*   SH_NI1_LLP_CAPT_SBCB_CAPTUREDRCVCRC                                */
-/*   Description:  CRC                                                  */
-#define SH_NI1_LLP_CAPT_SBCB_CAPTUREDRCVCRC_SHFT 16
-#define SH_NI1_LLP_CAPT_SBCB_CAPTUREDRCVCRC_MASK 0x00000000ffff0000
-
-/*   SH_NI1_LLP_CAPT_SBCB_SENTALLCBERRORS                               */
-/*   Description:  All CB errors have been sent                         */
-#define SH_NI1_LLP_CAPT_SBCB_SENTALLCBERRORS_SHFT 32
-#define SH_NI1_LLP_CAPT_SBCB_SENTALLCBERRORS_MASK 0x0000000100000000
-
-/*   SH_NI1_LLP_CAPT_SBCB_SENTALLSNERRORS                               */
-/*   Description:  All SN errors have been sent                         */
-#define SH_NI1_LLP_CAPT_SBCB_SENTALLSNERRORS_SHFT 33
-#define SH_NI1_LLP_CAPT_SBCB_SENTALLSNERRORS_MASK 0x0000000200000000
-
-/*   SH_NI1_LLP_CAPT_SBCB_FAKEDALLSNERRORS                              */
-/*   Description:  All faked SN errors have been sent                   */
-#define SH_NI1_LLP_CAPT_SBCB_FAKEDALLSNERRORS_SHFT 34
-#define SH_NI1_LLP_CAPT_SBCB_FAKEDALLSNERRORS_MASK 0x0000000400000000
-
-/*   SH_NI1_LLP_CAPT_SBCB_CHARGEOVERFLOW                                */
-/*   Description:  wire charge counter overflowed, valid if llp_mode e  */
-#define SH_NI1_LLP_CAPT_SBCB_CHARGEOVERFLOW_SHFT 35
-#define SH_NI1_LLP_CAPT_SBCB_CHARGEOVERFLOW_MASK 0x0000000800000000
-
-/*   SH_NI1_LLP_CAPT_SBCB_CHARGEUNDERFLOW                               */
-/*   Description:  wire charge counter underflowed, valid if llp_mode   */
-/*  enabled                                                             */
-#define SH_NI1_LLP_CAPT_SBCB_CHARGEUNDERFLOW_SHFT 36
-#define SH_NI1_LLP_CAPT_SBCB_CHARGEUNDERFLOW_MASK 0x0000001000000000
-
-/* ==================================================================== */
-/*                      Register "SH_NI1_LLP_ERR"                       */
-/* ==================================================================== */
-
-#define SH_NI1_LLP_ERR                           0x0000000150002048
-#define SH_NI1_LLP_ERR_MASK                      0x001fffffffffffff
-#define SH_NI1_LLP_ERR_INIT                      0x0000000000000000
-
-/*   SH_NI1_LLP_ERR_RX_SN_ERR_COUNT                                     */
-/*   Description:  Counts the sequence number errors received           */
-#define SH_NI1_LLP_ERR_RX_SN_ERR_COUNT_SHFT      0
-#define SH_NI1_LLP_ERR_RX_SN_ERR_COUNT_MASK      0x00000000000000ff
-
-/*   SH_NI1_LLP_ERR_RX_CB_ERR_COUNT                                     */
-/*   Description:  Counts the check byte errors received                */
-#define SH_NI1_LLP_ERR_RX_CB_ERR_COUNT_SHFT      8
-#define SH_NI1_LLP_ERR_RX_CB_ERR_COUNT_MASK      0x000000000000ff00
-
-/*   SH_NI1_LLP_ERR_RETRY_COUNT                                         */
-/*   Description:  Counts the retries                                   */
-#define SH_NI1_LLP_ERR_RETRY_COUNT_SHFT          16
-#define SH_NI1_LLP_ERR_RETRY_COUNT_MASK          0x0000000000ff0000
-
-/*   SH_NI1_LLP_ERR_RETRY_TIMEOUT                                       */
-/*   Description:  Indicates a retry timeout has occurred               */
-#define SH_NI1_LLP_ERR_RETRY_TIMEOUT_SHFT        24
-#define SH_NI1_LLP_ERR_RETRY_TIMEOUT_MASK        0x0000000001000000
-
-/*   SH_NI1_LLP_ERR_RCV_LINK_RESET                                      */
-/*   Description:  Indicates a link reset has been received             */
-#define SH_NI1_LLP_ERR_RCV_LINK_RESET_SHFT       25
-#define SH_NI1_LLP_ERR_RCV_LINK_RESET_MASK       0x0000000002000000
-
-/*   SH_NI1_LLP_ERR_SQUASH                                              */
-/*   Description:  Indicates a micropacket was squashed                 */
-#define SH_NI1_LLP_ERR_SQUASH_SHFT               26
-#define SH_NI1_LLP_ERR_SQUASH_MASK               0x0000000004000000
-
-/*   SH_NI1_LLP_ERR_POWER_NOT_OK                                        */
-/*   Description:  Detects and traps a loss of power_OK                 */
-#define SH_NI1_LLP_ERR_POWER_NOT_OK_SHFT         27
-#define SH_NI1_LLP_ERR_POWER_NOT_OK_MASK         0x0000000008000000
-
-/*   SH_NI1_LLP_ERR_WIRE_CNT                                            */
-/*   Description:  counts the errors detected on a single wire test     */
-#define SH_NI1_LLP_ERR_WIRE_CNT_SHFT             28
-#define SH_NI1_LLP_ERR_WIRE_CNT_MASK             0x000ffffff0000000
-
-/*   SH_NI1_LLP_ERR_WIRE_OVERFLOW                                       */
-/*   Description:  wire_error_cnt has overflowed                        */
-#define SH_NI1_LLP_ERR_WIRE_OVERFLOW_SHFT        52
-#define SH_NI1_LLP_ERR_WIRE_OVERFLOW_MASK        0x0010000000000000
-
-/* ==================================================================== */
-/*                Register "SH_XNNI0_LLP_TO_FIFO02_FLOW"                */
-/* ==================================================================== */
-
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW              0x0000000150001010
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_MASK         0x3f3f003f3f00bfbf
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_INIT         0x0000000000000000
-
-/*   SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC0_WITHHOLD                     */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC0_FORCE_CRED                   */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC2_WITHHOLD                     */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC2_FORCE_CRED                   */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC0_DYN                         */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC0_CAP                         */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC2_DYN                         */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC2_CAP                         */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNNI0_LLP_TO_FIFO02_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*                Register "SH_XNNI0_LLP_TO_FIFO13_FLOW"                */
-/* ==================================================================== */
-
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW              0x0000000150001020
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_MASK         0x3f3f003f3f00bfbf
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_INIT         0x0000000000000000
-
-/*   SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC0_WITHHOLD                     */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC0_FORCE_CRED                   */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC2_WITHHOLD                     */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC2_FORCE_CRED                   */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC0_DYN                         */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC0_CAP                         */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC2_DYN                         */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC2_CAP                         */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNNI0_LLP_TO_FIFO13_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_LLP_DEBIT_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI0_LLP_DEBIT_FLOW                  0x0000000150001030
-#define SH_XNNI0_LLP_DEBIT_FLOW_MASK             0x1f1f1f1f1f1f1f1f
-#define SH_XNNI0_LLP_DEBIT_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC0_DYN                              */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC0_DYN_SHFT 0
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC0_DYN_MASK 0x000000000000001f
-
-/*   SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC0_CAP                              */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC0_CAP_SHFT 8
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC0_CAP_MASK 0x0000000000001f00
-
-/*   SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC1_DYN                              */
-/*   Description:  vc1 debit dynamic value                              */
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC1_DYN_SHFT 16
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC1_DYN_MASK 0x00000000001f0000
-
-/*   SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC1_CAP                              */
-/*   Description:  vc1 debit captured value                             */
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC1_CAP_SHFT 24
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC1_CAP_MASK 0x000000001f000000
-
-/*   SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC2_DYN                              */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC2_DYN_SHFT 32
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC2_DYN_MASK 0x0000001f00000000
-
-/*   SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC2_CAP                              */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC2_CAP_SHFT 40
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC2_CAP_MASK 0x00001f0000000000
-
-/*   SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC3_DYN                              */
-/*   Description:  vc3 debit dynamic value                              */
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC3_DYN_SHFT 48
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC3_DYN_MASK 0x001f000000000000
-
-/*   SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC3_CAP                              */
-/*   Description:  vc3 debit captured value                             */
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC3_CAP_SHFT 56
-#define SH_XNNI0_LLP_DEBIT_FLOW_DEBIT_VC3_CAP_MASK 0x1f00000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_LINK_0_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI0_LINK_0_FLOW                     0x0000000150001040
-#define SH_XNNI0_LINK_0_FLOW_MASK                0x000000007f7f7fbf
-#define SH_XNNI0_LINK_0_FLOW_INIT                0x0000000000001800
-
-/*   SH_XNNI0_LINK_0_FLOW_DEBIT_VC0_WITHHOLD                            */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI0_LINK_0_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI0_LINK_0_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_LINK_0_FLOW_DEBIT_VC0_FORCE_CRED                          */
-/*   Description:  Force Credit on vc0 from debit cntr                  */
-#define SH_XNNI0_LINK_0_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI0_LINK_0_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_TEST                               */
-/*   Description:  vc0 Limit Test                                       */
-#define SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_TEST_SHFT 8
-#define SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_TEST_MASK 0x0000000000007f00
-
-/*   SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_DYN                                */
-/*   Description:  Dynamic vc0 credit value                             */
-#define SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_DYN_SHFT 16
-#define SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_DYN_MASK 0x00000000007f0000
-
-/*   SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_CAP                                */
-/*   Description:  Captured vc0 credit                                  */
-#define SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_CAP_SHFT 24
-#define SH_XNNI0_LINK_0_FLOW_CREDIT_VC0_CAP_MASK 0x000000007f000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_LINK_1_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI0_LINK_1_FLOW                     0x0000000150001050
-#define SH_XNNI0_LINK_1_FLOW_MASK                0x000000007f7f7fbf
-#define SH_XNNI0_LINK_1_FLOW_INIT                0x0000000000001800
-
-/*   SH_XNNI0_LINK_1_FLOW_DEBIT_VC1_WITHHOLD                            */
-/*   Description:  vc1 withhold                                         */
-#define SH_XNNI0_LINK_1_FLOW_DEBIT_VC1_WITHHOLD_SHFT 0
-#define SH_XNNI0_LINK_1_FLOW_DEBIT_VC1_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_LINK_1_FLOW_DEBIT_VC1_FORCE_CRED                          */
-/*   Description:  Force Credit on vc1 from debit cntr                  */
-#define SH_XNNI0_LINK_1_FLOW_DEBIT_VC1_FORCE_CRED_SHFT 7
-#define SH_XNNI0_LINK_1_FLOW_DEBIT_VC1_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_TEST                               */
-/*   Description:  vc1 Limit Test                                       */
-#define SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_TEST_SHFT 8
-#define SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_TEST_MASK 0x0000000000007f00
-
-/*   SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_DYN                                */
-/*   Description:  Dynamic vc1 credit value                             */
-#define SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_DYN_SHFT 16
-#define SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_DYN_MASK 0x00000000007f0000
-
-/*   SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_CAP                                */
-/*   Description:  Captured vc1 credit                                  */
-#define SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_CAP_SHFT 24
-#define SH_XNNI0_LINK_1_FLOW_CREDIT_VC1_CAP_MASK 0x000000007f000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_LINK_2_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI0_LINK_2_FLOW                     0x0000000150001060
-#define SH_XNNI0_LINK_2_FLOW_MASK                0x000000007f7f7fbf
-#define SH_XNNI0_LINK_2_FLOW_INIT                0x0000000000001800
-
-/*   SH_XNNI0_LINK_2_FLOW_DEBIT_VC2_WITHHOLD                            */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI0_LINK_2_FLOW_DEBIT_VC2_WITHHOLD_SHFT 0
-#define SH_XNNI0_LINK_2_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_LINK_2_FLOW_DEBIT_VC2_FORCE_CRED                          */
-/*   Description:  Force Credit on vc2 from debit cntr                  */
-#define SH_XNNI0_LINK_2_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 7
-#define SH_XNNI0_LINK_2_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_TEST                               */
-/*   Description:  vc2 Limit Test                                       */
-#define SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_TEST_SHFT 8
-#define SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_TEST_MASK 0x0000000000007f00
-
-/*   SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_DYN                                */
-/*   Description:  Dynamic vc2 credit value                             */
-#define SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_DYN_SHFT 16
-#define SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_DYN_MASK 0x00000000007f0000
-
-/*   SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_CAP                                */
-/*   Description:  Captured vc2 credit                                  */
-#define SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_CAP_SHFT 24
-#define SH_XNNI0_LINK_2_FLOW_CREDIT_VC2_CAP_MASK 0x000000007f000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_LINK_3_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI0_LINK_3_FLOW                     0x0000000150001070
-#define SH_XNNI0_LINK_3_FLOW_MASK                0x000000007f7f7fbf
-#define SH_XNNI0_LINK_3_FLOW_INIT                0x0000000000001800
-
-/*   SH_XNNI0_LINK_3_FLOW_DEBIT_VC3_WITHHOLD                            */
-/*   Description:  vc3 withhold                                         */
-#define SH_XNNI0_LINK_3_FLOW_DEBIT_VC3_WITHHOLD_SHFT 0
-#define SH_XNNI0_LINK_3_FLOW_DEBIT_VC3_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_LINK_3_FLOW_DEBIT_VC3_FORCE_CRED                          */
-/*   Description:  Force Credit on vc3 from debit cntr                  */
-#define SH_XNNI0_LINK_3_FLOW_DEBIT_VC3_FORCE_CRED_SHFT 7
-#define SH_XNNI0_LINK_3_FLOW_DEBIT_VC3_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_TEST                               */
-/*   Description:  vc3 Limit Test                                       */
-#define SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_TEST_SHFT 8
-#define SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_TEST_MASK 0x0000000000007f00
-
-/*   SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_DYN                                */
-/*   Description:  Dynamic vc3 credit value                             */
-#define SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_DYN_SHFT 16
-#define SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_DYN_MASK 0x00000000007f0000
-
-/*   SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_CAP                                */
-/*   Description:  Captured vc3 credit                                  */
-#define SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_CAP_SHFT 24
-#define SH_XNNI0_LINK_3_FLOW_CREDIT_VC3_CAP_MASK 0x000000007f000000
-
-/* ==================================================================== */
-/*                Register "SH_XNNI1_LLP_TO_FIFO02_FLOW"                */
-/* ==================================================================== */
-
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW              0x0000000150003010
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_MASK         0x3f3f003f3f00bfbf
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_INIT         0x0000000000000000
-
-/*   SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC0_WITHHOLD                     */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC0_FORCE_CRED                   */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC2_WITHHOLD                     */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC2_FORCE_CRED                   */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC0_DYN                         */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC0_CAP                         */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC2_DYN                         */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC2_CAP                         */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNNI1_LLP_TO_FIFO02_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*                Register "SH_XNNI1_LLP_TO_FIFO13_FLOW"                */
-/* ==================================================================== */
-
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW              0x0000000150003020
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_MASK         0x3f3f003f3f00bfbf
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_INIT         0x0000000000000000
-
-/*   SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC0_WITHHOLD                     */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC0_FORCE_CRED                   */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC2_WITHHOLD                     */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC2_FORCE_CRED                   */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC0_DYN                         */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC0_CAP                         */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC2_DYN                         */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC2_CAP                         */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNNI1_LLP_TO_FIFO13_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_LLP_DEBIT_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI1_LLP_DEBIT_FLOW                  0x0000000150003030
-#define SH_XNNI1_LLP_DEBIT_FLOW_MASK             0x1f1f1f1f1f1f1f1f
-#define SH_XNNI1_LLP_DEBIT_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC0_DYN                              */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC0_DYN_SHFT 0
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC0_DYN_MASK 0x000000000000001f
-
-/*   SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC0_CAP                              */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC0_CAP_SHFT 8
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC0_CAP_MASK 0x0000000000001f00
-
-/*   SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC1_DYN                              */
-/*   Description:  vc1 debit dynamic value                              */
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC1_DYN_SHFT 16
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC1_DYN_MASK 0x00000000001f0000
-
-/*   SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC1_CAP                              */
-/*   Description:  vc1 debit captured value                             */
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC1_CAP_SHFT 24
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC1_CAP_MASK 0x000000001f000000
-
-/*   SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC2_DYN                              */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC2_DYN_SHFT 32
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC2_DYN_MASK 0x0000001f00000000
-
-/*   SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC2_CAP                              */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC2_CAP_SHFT 40
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC2_CAP_MASK 0x00001f0000000000
-
-/*   SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC3_DYN                              */
-/*   Description:  vc3 debit dynamic value                              */
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC3_DYN_SHFT 48
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC3_DYN_MASK 0x001f000000000000
-
-/*   SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC3_CAP                              */
-/*   Description:  vc3 debit captured value                             */
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC3_CAP_SHFT 56
-#define SH_XNNI1_LLP_DEBIT_FLOW_DEBIT_VC3_CAP_MASK 0x1f00000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_LINK_0_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI1_LINK_0_FLOW                     0x0000000150003040
-#define SH_XNNI1_LINK_0_FLOW_MASK                0x000000007f7f7fbf
-#define SH_XNNI1_LINK_0_FLOW_INIT                0x0000000000001800
-
-/*   SH_XNNI1_LINK_0_FLOW_DEBIT_VC0_WITHHOLD                            */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI1_LINK_0_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI1_LINK_0_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_LINK_0_FLOW_DEBIT_VC0_FORCE_CRED                          */
-/*   Description:  Force Credit on vc0 from debit cntr                  */
-#define SH_XNNI1_LINK_0_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI1_LINK_0_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_TEST                               */
-/*   Description:  vc0 Limit Test                                       */
-#define SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_TEST_SHFT 8
-#define SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_TEST_MASK 0x0000000000007f00
-
-/*   SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_DYN                                */
-/*   Description:  Dynamic vc0 credit value                             */
-#define SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_DYN_SHFT 16
-#define SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_DYN_MASK 0x00000000007f0000
-
-/*   SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_CAP                                */
-/*   Description:  Captured vc0 credit                                  */
-#define SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_CAP_SHFT 24
-#define SH_XNNI1_LINK_0_FLOW_CREDIT_VC0_CAP_MASK 0x000000007f000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_LINK_1_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI1_LINK_1_FLOW                     0x0000000150003050
-#define SH_XNNI1_LINK_1_FLOW_MASK                0x000000007f7f7fbf
-#define SH_XNNI1_LINK_1_FLOW_INIT                0x0000000000001800
-
-/*   SH_XNNI1_LINK_1_FLOW_DEBIT_VC1_WITHHOLD                            */
-/*   Description:  vc1 withhold                                         */
-#define SH_XNNI1_LINK_1_FLOW_DEBIT_VC1_WITHHOLD_SHFT 0
-#define SH_XNNI1_LINK_1_FLOW_DEBIT_VC1_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_LINK_1_FLOW_DEBIT_VC1_FORCE_CRED                          */
-/*   Description:  Force Credit on vc1 from debit cntr                  */
-#define SH_XNNI1_LINK_1_FLOW_DEBIT_VC1_FORCE_CRED_SHFT 7
-#define SH_XNNI1_LINK_1_FLOW_DEBIT_VC1_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_TEST                               */
-/*   Description:  vc1 Limit Test                                       */
-#define SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_TEST_SHFT 8
-#define SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_TEST_MASK 0x0000000000007f00
-
-/*   SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_DYN                                */
-/*   Description:  Dynamic vc1 credit value                             */
-#define SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_DYN_SHFT 16
-#define SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_DYN_MASK 0x00000000007f0000
-
-/*   SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_CAP                                */
-/*   Description:  Captured vc1 credit                                  */
-#define SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_CAP_SHFT 24
-#define SH_XNNI1_LINK_1_FLOW_CREDIT_VC1_CAP_MASK 0x000000007f000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_LINK_2_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI1_LINK_2_FLOW                     0x0000000150003060
-#define SH_XNNI1_LINK_2_FLOW_MASK                0x000000007f7f7fbf
-#define SH_XNNI1_LINK_2_FLOW_INIT                0x0000000000001800
-
-/*   SH_XNNI1_LINK_2_FLOW_DEBIT_VC2_WITHHOLD                            */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI1_LINK_2_FLOW_DEBIT_VC2_WITHHOLD_SHFT 0
-#define SH_XNNI1_LINK_2_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_LINK_2_FLOW_DEBIT_VC2_FORCE_CRED                          */
-/*   Description:  Force Credit on vc2 from debit cntr                  */
-#define SH_XNNI1_LINK_2_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 7
-#define SH_XNNI1_LINK_2_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_TEST                               */
-/*   Description:  vc2 Limit Test                                       */
-#define SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_TEST_SHFT 8
-#define SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_TEST_MASK 0x0000000000007f00
-
-/*   SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_DYN                                */
-/*   Description:  Dynamic vc2 credit value                             */
-#define SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_DYN_SHFT 16
-#define SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_DYN_MASK 0x00000000007f0000
-
-/*   SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_CAP                                */
-/*   Description:  Captured vc2 credit                                  */
-#define SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_CAP_SHFT 24
-#define SH_XNNI1_LINK_2_FLOW_CREDIT_VC2_CAP_MASK 0x000000007f000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_LINK_3_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI1_LINK_3_FLOW                     0x0000000150003070
-#define SH_XNNI1_LINK_3_FLOW_MASK                0x000000007f7f7fbf
-#define SH_XNNI1_LINK_3_FLOW_INIT                0x0000000000001800
-
-/*   SH_XNNI1_LINK_3_FLOW_DEBIT_VC3_WITHHOLD                            */
-/*   Description:  vc3 withhold                                         */
-#define SH_XNNI1_LINK_3_FLOW_DEBIT_VC3_WITHHOLD_SHFT 0
-#define SH_XNNI1_LINK_3_FLOW_DEBIT_VC3_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_LINK_3_FLOW_DEBIT_VC3_FORCE_CRED                          */
-/*   Description:  Force Credit on vc3 from debit cntr                  */
-#define SH_XNNI1_LINK_3_FLOW_DEBIT_VC3_FORCE_CRED_SHFT 7
-#define SH_XNNI1_LINK_3_FLOW_DEBIT_VC3_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_TEST                               */
-/*   Description:  vc3 Limit Test                                       */
-#define SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_TEST_SHFT 8
-#define SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_TEST_MASK 0x0000000000007f00
-
-/*   SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_DYN                                */
-/*   Description:  Dynamic vc3 credit value                             */
-#define SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_DYN_SHFT 16
-#define SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_DYN_MASK 0x00000000007f0000
-
-/*   SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_CAP                                */
-/*   Description:  Captured vc3 credit                                  */
-#define SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_CAP_SHFT 24
-#define SH_XNNI1_LINK_3_FLOW_CREDIT_VC3_CAP_MASK 0x000000007f000000
-
-/* ==================================================================== */
-/*                    Register "SH_IILB_LOCAL_TABLE"                    */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-#define SH_IILB_LOCAL_TABLE                      0x0000000150020000
-#define SH_IILB_LOCAL_TABLE_MASK                 0x800000000000003f
-#define SH_IILB_LOCAL_TABLE_MEMDEPTH             128
-#define SH_IILB_LOCAL_TABLE_INIT                 0x0000000000000000
-
-/*   SH_IILB_LOCAL_TABLE_DIR0                                           */
-/*   Description:  Direction field for next chip                        */
-#define SH_IILB_LOCAL_TABLE_DIR0_SHFT            0
-#define SH_IILB_LOCAL_TABLE_DIR0_MASK            0x000000000000000f
-
-/*   SH_IILB_LOCAL_TABLE_V0                                             */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_IILB_LOCAL_TABLE_V0_SHFT              4
-#define SH_IILB_LOCAL_TABLE_V0_MASK              0x0000000000000010
-
-/*   SH_IILB_LOCAL_TABLE_NI_SEL0                                        */
-/*   Description:  ni select for requests                               */
-#define SH_IILB_LOCAL_TABLE_NI_SEL0_SHFT         5
-#define SH_IILB_LOCAL_TABLE_NI_SEL0_MASK         0x0000000000000020
-
-/*   SH_IILB_LOCAL_TABLE_VALID                                          */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_IILB_LOCAL_TABLE_VALID_SHFT           63
-#define SH_IILB_LOCAL_TABLE_VALID_MASK           0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_IILB_GLOBAL_TABLE"                    */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-#define SH_IILB_GLOBAL_TABLE                     0x0000000150020400
-#define SH_IILB_GLOBAL_TABLE_MASK                0x800000000000003f
-#define SH_IILB_GLOBAL_TABLE_MEMDEPTH            16
-#define SH_IILB_GLOBAL_TABLE_INIT                0x0000000000000000
-
-/*   SH_IILB_GLOBAL_TABLE_DIR0                                          */
-/*   Description:  Direction field for next chip                        */
-#define SH_IILB_GLOBAL_TABLE_DIR0_SHFT           0
-#define SH_IILB_GLOBAL_TABLE_DIR0_MASK           0x000000000000000f
-
-/*   SH_IILB_GLOBAL_TABLE_V0                                            */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_IILB_GLOBAL_TABLE_V0_SHFT             4
-#define SH_IILB_GLOBAL_TABLE_V0_MASK             0x0000000000000010
-
-/*   SH_IILB_GLOBAL_TABLE_NI_SEL0                                       */
-/*   Description:  ni select for requests                               */
-#define SH_IILB_GLOBAL_TABLE_NI_SEL0_SHFT        5
-#define SH_IILB_GLOBAL_TABLE_NI_SEL0_MASK        0x0000000000000020
-
-/*   SH_IILB_GLOBAL_TABLE_VALID                                         */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_IILB_GLOBAL_TABLE_VALID_SHFT          63
-#define SH_IILB_GLOBAL_TABLE_VALID_MASK          0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_IILB_OVER_RIDE_TABLE"                  */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-#define SH_IILB_OVER_RIDE_TABLE                  0x0000000150020480
-#define SH_IILB_OVER_RIDE_TABLE_MASK             0x800000000000003f
-#define SH_IILB_OVER_RIDE_TABLE_INIT             0x8000000000000000
-
-/*   SH_IILB_OVER_RIDE_TABLE_DIR0                                       */
-/*   Description:  Direction field for next chip                        */
-#define SH_IILB_OVER_RIDE_TABLE_DIR0_SHFT        0
-#define SH_IILB_OVER_RIDE_TABLE_DIR0_MASK        0x000000000000000f
-
-/*   SH_IILB_OVER_RIDE_TABLE_V0                                         */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_IILB_OVER_RIDE_TABLE_V0_SHFT          4
-#define SH_IILB_OVER_RIDE_TABLE_V0_MASK          0x0000000000000010
-
-/*   SH_IILB_OVER_RIDE_TABLE_NI_SEL0                                    */
-/*   Description:  ni select                                            */
-#define SH_IILB_OVER_RIDE_TABLE_NI_SEL0_SHFT     5
-#define SH_IILB_OVER_RIDE_TABLE_NI_SEL0_MASK     0x0000000000000020
-
-/*   SH_IILB_OVER_RIDE_TABLE_ENABLE                                     */
-/*   Description:  Indicates that this entry is enabled                 */
-#define SH_IILB_OVER_RIDE_TABLE_ENABLE_SHFT      63
-#define SH_IILB_OVER_RIDE_TABLE_ENABLE_MASK      0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_IILB_RSP_PLANE_HINT"                   */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-#define SH_IILB_RSP_PLANE_HINT                   0x0000000150020488
-#define SH_IILB_RSP_PLANE_HINT_MASK              0x0000000000000000
-#define SH_IILB_RSP_PLANE_HINT_INIT              0x0000000000000000
-
-/* ==================================================================== */
-/*                     Register "SH_PI_LOCAL_TABLE"                     */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-#define SH_PI_LOCAL_TABLE                        0x0000000150021000
-#define SH_PI_LOCAL_TABLE_MASK                   0x8000000000003f3f
-#define SH_PI_LOCAL_TABLE_MEMDEPTH               128
-#define SH_PI_LOCAL_TABLE_INIT                   0x0000000000000000
-
-/*   SH_PI_LOCAL_TABLE_DIR0                                             */
-/*   Description:  Direction field for next chip                        */
-#define SH_PI_LOCAL_TABLE_DIR0_SHFT              0
-#define SH_PI_LOCAL_TABLE_DIR0_MASK              0x000000000000000f
-
-/*   SH_PI_LOCAL_TABLE_V0                                               */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_PI_LOCAL_TABLE_V0_SHFT                4
-#define SH_PI_LOCAL_TABLE_V0_MASK                0x0000000000000010
-
-/*   SH_PI_LOCAL_TABLE_NI_SEL0                                          */
-/*   Description:  ni select for requests                               */
-#define SH_PI_LOCAL_TABLE_NI_SEL0_SHFT           5
-#define SH_PI_LOCAL_TABLE_NI_SEL0_MASK           0x0000000000000020
-
-/*   SH_PI_LOCAL_TABLE_DIR1                                             */
-#define SH_PI_LOCAL_TABLE_DIR1_SHFT              8
-#define SH_PI_LOCAL_TABLE_DIR1_MASK              0x0000000000000f00
-
-/*   SH_PI_LOCAL_TABLE_V1                                               */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_PI_LOCAL_TABLE_V1_SHFT                12
-#define SH_PI_LOCAL_TABLE_V1_MASK                0x0000000000001000
-
-/*   SH_PI_LOCAL_TABLE_NI_SEL1                                          */
-/*   Description:  ni select for plane-hint 1                           */
-#define SH_PI_LOCAL_TABLE_NI_SEL1_SHFT           13
-#define SH_PI_LOCAL_TABLE_NI_SEL1_MASK           0x0000000000002000
-
-/*   SH_PI_LOCAL_TABLE_VALID                                            */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_PI_LOCAL_TABLE_VALID_SHFT             63
-#define SH_PI_LOCAL_TABLE_VALID_MASK             0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_PI_GLOBAL_TABLE"                     */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-#define SH_PI_GLOBAL_TABLE                       0x0000000150021400
-#define SH_PI_GLOBAL_TABLE_MASK                  0x8000000000003f3f
-#define SH_PI_GLOBAL_TABLE_MEMDEPTH              16
-#define SH_PI_GLOBAL_TABLE_INIT                  0x0000000000000000
-
-/*   SH_PI_GLOBAL_TABLE_DIR0                                            */
-/*   Description:  Direction field for next chip                        */
-#define SH_PI_GLOBAL_TABLE_DIR0_SHFT             0
-#define SH_PI_GLOBAL_TABLE_DIR0_MASK             0x000000000000000f
-
-/*   SH_PI_GLOBAL_TABLE_V0                                              */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_PI_GLOBAL_TABLE_V0_SHFT               4
-#define SH_PI_GLOBAL_TABLE_V0_MASK               0x0000000000000010
-
-/*   SH_PI_GLOBAL_TABLE_NI_SEL0                                         */
-/*   Description:  ni select for requests                               */
-#define SH_PI_GLOBAL_TABLE_NI_SEL0_SHFT          5
-#define SH_PI_GLOBAL_TABLE_NI_SEL0_MASK          0x0000000000000020
-
-/*   SH_PI_GLOBAL_TABLE_DIR1                                            */
-#define SH_PI_GLOBAL_TABLE_DIR1_SHFT             8
-#define SH_PI_GLOBAL_TABLE_DIR1_MASK             0x0000000000000f00
-
-/*   SH_PI_GLOBAL_TABLE_V1                                              */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_PI_GLOBAL_TABLE_V1_SHFT               12
-#define SH_PI_GLOBAL_TABLE_V1_MASK               0x0000000000001000
-
-/*   SH_PI_GLOBAL_TABLE_NI_SEL1                                         */
-/*   Description:  ni select for plane-hint 1                           */
-#define SH_PI_GLOBAL_TABLE_NI_SEL1_SHFT          13
-#define SH_PI_GLOBAL_TABLE_NI_SEL1_MASK          0x0000000000002000
-
-/*   SH_PI_GLOBAL_TABLE_VALID                                           */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_PI_GLOBAL_TABLE_VALID_SHFT            63
-#define SH_PI_GLOBAL_TABLE_VALID_MASK            0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_PI_OVER_RIDE_TABLE"                   */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-#define SH_PI_OVER_RIDE_TABLE                    0x0000000150021480
-#define SH_PI_OVER_RIDE_TABLE_MASK               0x8000000000003f3f
-#define SH_PI_OVER_RIDE_TABLE_INIT               0x8000000000002000
-
-/*   SH_PI_OVER_RIDE_TABLE_DIR0                                         */
-/*   Description:  Direction field for next chip                        */
-#define SH_PI_OVER_RIDE_TABLE_DIR0_SHFT          0
-#define SH_PI_OVER_RIDE_TABLE_DIR0_MASK          0x000000000000000f
-
-/*   SH_PI_OVER_RIDE_TABLE_V0                                           */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_PI_OVER_RIDE_TABLE_V0_SHFT            4
-#define SH_PI_OVER_RIDE_TABLE_V0_MASK            0x0000000000000010
-
-/*   SH_PI_OVER_RIDE_TABLE_NI_SEL0                                      */
-/*   Description:  ni select                                            */
-#define SH_PI_OVER_RIDE_TABLE_NI_SEL0_SHFT       5
-#define SH_PI_OVER_RIDE_TABLE_NI_SEL0_MASK       0x0000000000000020
-
-/*   SH_PI_OVER_RIDE_TABLE_DIR1                                         */
-#define SH_PI_OVER_RIDE_TABLE_DIR1_SHFT          8
-#define SH_PI_OVER_RIDE_TABLE_DIR1_MASK          0x0000000000000f00
-
-/*   SH_PI_OVER_RIDE_TABLE_V1                                           */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_PI_OVER_RIDE_TABLE_V1_SHFT            12
-#define SH_PI_OVER_RIDE_TABLE_V1_MASK            0x0000000000001000
-
-/*   SH_PI_OVER_RIDE_TABLE_NI_SEL1                                      */
-/*   Description:  ni select                                            */
-#define SH_PI_OVER_RIDE_TABLE_NI_SEL1_SHFT       13
-#define SH_PI_OVER_RIDE_TABLE_NI_SEL1_MASK       0x0000000000002000
-
-/*   SH_PI_OVER_RIDE_TABLE_ENABLE                                       */
-/*   Description:  Indicates that this entry is enabled                 */
-#define SH_PI_OVER_RIDE_TABLE_ENABLE_SHFT        63
-#define SH_PI_OVER_RIDE_TABLE_ENABLE_MASK        0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_PI_RSP_PLANE_HINT"                    */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-#define SH_PI_RSP_PLANE_HINT                     0x0000000150021488
-#define SH_PI_RSP_PLANE_HINT_MASK                0x0000000000000001
-#define SH_PI_RSP_PLANE_HINT_INIT                0x0000000000000000
-
-/*   SH_PI_RSP_PLANE_HINT_INVERT                                        */
-/*   Description:  Invert Response Plane Hint                           */
-#define SH_PI_RSP_PLANE_HINT_INVERT_SHFT         0
-#define SH_PI_RSP_PLANE_HINT_INVERT_MASK         0x0000000000000001
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LOCAL_TABLE"                     */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-#define SH_NI0_LOCAL_TABLE                       0x0000000150022000
-#define SH_NI0_LOCAL_TABLE_MASK                  0x800000000000001f
-#define SH_NI0_LOCAL_TABLE_MEMDEPTH              128
-#define SH_NI0_LOCAL_TABLE_INIT                  0x0000000000000000
-
-/*   SH_NI0_LOCAL_TABLE_DIR0                                            */
-/*   Description:  Direction field for next chip                        */
-#define SH_NI0_LOCAL_TABLE_DIR0_SHFT             0
-#define SH_NI0_LOCAL_TABLE_DIR0_MASK             0x000000000000000f
-
-/*   SH_NI0_LOCAL_TABLE_V0                                              */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_NI0_LOCAL_TABLE_V0_SHFT               4
-#define SH_NI0_LOCAL_TABLE_V0_MASK               0x0000000000000010
-
-/*   SH_NI0_LOCAL_TABLE_VALID                                           */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_NI0_LOCAL_TABLE_VALID_SHFT            63
-#define SH_NI0_LOCAL_TABLE_VALID_MASK            0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_GLOBAL_TABLE"                    */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-#define SH_NI0_GLOBAL_TABLE                      0x0000000150022400
-#define SH_NI0_GLOBAL_TABLE_MASK                 0x800000000000001f
-#define SH_NI0_GLOBAL_TABLE_MEMDEPTH             16
-#define SH_NI0_GLOBAL_TABLE_INIT                 0x0000000000000000
-
-/*   SH_NI0_GLOBAL_TABLE_DIR0                                           */
-/*   Description:  Direction field for next chip                        */
-#define SH_NI0_GLOBAL_TABLE_DIR0_SHFT            0
-#define SH_NI0_GLOBAL_TABLE_DIR0_MASK            0x000000000000000f
-
-/*   SH_NI0_GLOBAL_TABLE_V0                                             */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_NI0_GLOBAL_TABLE_V0_SHFT              4
-#define SH_NI0_GLOBAL_TABLE_V0_MASK              0x0000000000000010
-
-/*   SH_NI0_GLOBAL_TABLE_VALID                                          */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_NI0_GLOBAL_TABLE_VALID_SHFT           63
-#define SH_NI0_GLOBAL_TABLE_VALID_MASK           0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_OVER_RIDE_TABLE"                   */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-#define SH_NI0_OVER_RIDE_TABLE                   0x0000000150022480
-#define SH_NI0_OVER_RIDE_TABLE_MASK              0x800000000000001f
-#define SH_NI0_OVER_RIDE_TABLE_INIT              0x8000000000000000
-
-/*   SH_NI0_OVER_RIDE_TABLE_DIR0                                        */
-/*   Description:  Direction field for next chip                        */
-#define SH_NI0_OVER_RIDE_TABLE_DIR0_SHFT         0
-#define SH_NI0_OVER_RIDE_TABLE_DIR0_MASK         0x000000000000000f
-
-/*   SH_NI0_OVER_RIDE_TABLE_V0                                          */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_NI0_OVER_RIDE_TABLE_V0_SHFT           4
-#define SH_NI0_OVER_RIDE_TABLE_V0_MASK           0x0000000000000010
-
-/*   SH_NI0_OVER_RIDE_TABLE_ENABLE                                      */
-/*   Description:  Indicates that this entry is enabled                 */
-#define SH_NI0_OVER_RIDE_TABLE_ENABLE_SHFT       63
-#define SH_NI0_OVER_RIDE_TABLE_ENABLE_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_RSP_PLANE_HINT"                   */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-#define SH_NI0_RSP_PLANE_HINT                    0x0000000150022488
-#define SH_NI0_RSP_PLANE_HINT_MASK               0x0000000000000000
-#define SH_NI0_RSP_PLANE_HINT_INIT               0x0000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LOCAL_TABLE"                     */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-#define SH_NI1_LOCAL_TABLE                       0x0000000150023000
-#define SH_NI1_LOCAL_TABLE_MASK                  0x800000000000001f
-#define SH_NI1_LOCAL_TABLE_MEMDEPTH              128
-#define SH_NI1_LOCAL_TABLE_INIT                  0x0000000000000000
-
-/*   SH_NI1_LOCAL_TABLE_DIR0                                            */
-/*   Description:  Direction field for next chip                        */
-#define SH_NI1_LOCAL_TABLE_DIR0_SHFT             0
-#define SH_NI1_LOCAL_TABLE_DIR0_MASK             0x000000000000000f
-
-/*   SH_NI1_LOCAL_TABLE_V0                                              */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_NI1_LOCAL_TABLE_V0_SHFT               4
-#define SH_NI1_LOCAL_TABLE_V0_MASK               0x0000000000000010
-
-/*   SH_NI1_LOCAL_TABLE_VALID                                           */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_NI1_LOCAL_TABLE_VALID_SHFT            63
-#define SH_NI1_LOCAL_TABLE_VALID_MASK            0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_GLOBAL_TABLE"                    */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-#define SH_NI1_GLOBAL_TABLE                      0x0000000150023400
-#define SH_NI1_GLOBAL_TABLE_MASK                 0x800000000000001f
-#define SH_NI1_GLOBAL_TABLE_MEMDEPTH             16
-#define SH_NI1_GLOBAL_TABLE_INIT                 0x0000000000000000
-
-/*   SH_NI1_GLOBAL_TABLE_DIR0                                           */
-/*   Description:  Direction field for next chip                        */
-#define SH_NI1_GLOBAL_TABLE_DIR0_SHFT            0
-#define SH_NI1_GLOBAL_TABLE_DIR0_MASK            0x000000000000000f
-
-/*   SH_NI1_GLOBAL_TABLE_V0                                             */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_NI1_GLOBAL_TABLE_V0_SHFT              4
-#define SH_NI1_GLOBAL_TABLE_V0_MASK              0x0000000000000010
-
-/*   SH_NI1_GLOBAL_TABLE_VALID                                          */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_NI1_GLOBAL_TABLE_VALID_SHFT           63
-#define SH_NI1_GLOBAL_TABLE_VALID_MASK           0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_OVER_RIDE_TABLE"                   */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-#define SH_NI1_OVER_RIDE_TABLE                   0x0000000150023480
-#define SH_NI1_OVER_RIDE_TABLE_MASK              0x800000000000001f
-#define SH_NI1_OVER_RIDE_TABLE_INIT              0x8000000000000000
-
-/*   SH_NI1_OVER_RIDE_TABLE_DIR0                                        */
-/*   Description:  Direction field for next chip                        */
-#define SH_NI1_OVER_RIDE_TABLE_DIR0_SHFT         0
-#define SH_NI1_OVER_RIDE_TABLE_DIR0_MASK         0x000000000000000f
-
-/*   SH_NI1_OVER_RIDE_TABLE_V0                                          */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_NI1_OVER_RIDE_TABLE_V0_SHFT           4
-#define SH_NI1_OVER_RIDE_TABLE_V0_MASK           0x0000000000000010
-
-/*   SH_NI1_OVER_RIDE_TABLE_ENABLE                                      */
-/*   Description:  Indicates that this entry is enabled                 */
-#define SH_NI1_OVER_RIDE_TABLE_ENABLE_SHFT       63
-#define SH_NI1_OVER_RIDE_TABLE_ENABLE_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_RSP_PLANE_HINT"                   */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-#define SH_NI1_RSP_PLANE_HINT                    0x0000000150023488
-#define SH_NI1_RSP_PLANE_HINT_MASK               0x0000000000000000
-#define SH_NI1_RSP_PLANE_HINT_INIT               0x0000000000000000
-
-/* ==================================================================== */
-/*                     Register "SH_MD_LOCAL_TABLE"                     */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-#define SH_MD_LOCAL_TABLE                        0x0000000150024000
-#define SH_MD_LOCAL_TABLE_MASK                   0x8000000000003f3f
-#define SH_MD_LOCAL_TABLE_MEMDEPTH               128
-#define SH_MD_LOCAL_TABLE_INIT                   0x0000000000000000
-
-/*   SH_MD_LOCAL_TABLE_DIR0                                             */
-/*   Description:  Direction field for next chip                        */
-#define SH_MD_LOCAL_TABLE_DIR0_SHFT              0
-#define SH_MD_LOCAL_TABLE_DIR0_MASK              0x000000000000000f
-
-/*   SH_MD_LOCAL_TABLE_V0                                               */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_MD_LOCAL_TABLE_V0_SHFT                4
-#define SH_MD_LOCAL_TABLE_V0_MASK                0x0000000000000010
-
-/*   SH_MD_LOCAL_TABLE_NI_SEL0                                          */
-/*   Description:  ni select for requests                               */
-#define SH_MD_LOCAL_TABLE_NI_SEL0_SHFT           5
-#define SH_MD_LOCAL_TABLE_NI_SEL0_MASK           0x0000000000000020
-
-/*   SH_MD_LOCAL_TABLE_DIR1                                             */
-#define SH_MD_LOCAL_TABLE_DIR1_SHFT              8
-#define SH_MD_LOCAL_TABLE_DIR1_MASK              0x0000000000000f00
-
-/*   SH_MD_LOCAL_TABLE_V1                                               */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_MD_LOCAL_TABLE_V1_SHFT                12
-#define SH_MD_LOCAL_TABLE_V1_MASK                0x0000000000001000
-
-/*   SH_MD_LOCAL_TABLE_NI_SEL1                                          */
-/*   Description:  ni select for plane-hint 1                           */
-#define SH_MD_LOCAL_TABLE_NI_SEL1_SHFT           13
-#define SH_MD_LOCAL_TABLE_NI_SEL1_MASK           0x0000000000002000
-
-/*   SH_MD_LOCAL_TABLE_VALID                                            */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_MD_LOCAL_TABLE_VALID_SHFT             63
-#define SH_MD_LOCAL_TABLE_VALID_MASK             0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_MD_GLOBAL_TABLE"                     */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-#define SH_MD_GLOBAL_TABLE                       0x0000000150024400
-#define SH_MD_GLOBAL_TABLE_MASK                  0x8000000000003f3f
-#define SH_MD_GLOBAL_TABLE_MEMDEPTH              16
-#define SH_MD_GLOBAL_TABLE_INIT                  0x0000000000000000
-
-/*   SH_MD_GLOBAL_TABLE_DIR0                                            */
-/*   Description:  Direction field for next chip                        */
-#define SH_MD_GLOBAL_TABLE_DIR0_SHFT             0
-#define SH_MD_GLOBAL_TABLE_DIR0_MASK             0x000000000000000f
-
-/*   SH_MD_GLOBAL_TABLE_V0                                              */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_MD_GLOBAL_TABLE_V0_SHFT               4
-#define SH_MD_GLOBAL_TABLE_V0_MASK               0x0000000000000010
-
-/*   SH_MD_GLOBAL_TABLE_NI_SEL0                                         */
-/*   Description:  ni select for requests                               */
-#define SH_MD_GLOBAL_TABLE_NI_SEL0_SHFT          5
-#define SH_MD_GLOBAL_TABLE_NI_SEL0_MASK          0x0000000000000020
-
-/*   SH_MD_GLOBAL_TABLE_DIR1                                            */
-#define SH_MD_GLOBAL_TABLE_DIR1_SHFT             8
-#define SH_MD_GLOBAL_TABLE_DIR1_MASK             0x0000000000000f00
-
-/*   SH_MD_GLOBAL_TABLE_V1                                              */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_MD_GLOBAL_TABLE_V1_SHFT               12
-#define SH_MD_GLOBAL_TABLE_V1_MASK               0x0000000000001000
-
-/*   SH_MD_GLOBAL_TABLE_NI_SEL1                                         */
-/*   Description:  ni select for plane-hint 1                           */
-#define SH_MD_GLOBAL_TABLE_NI_SEL1_SHFT          13
-#define SH_MD_GLOBAL_TABLE_NI_SEL1_MASK          0x0000000000002000
-
-/*   SH_MD_GLOBAL_TABLE_VALID                                           */
-/*   Description:  Indicates that this entry is valid                   */
-#define SH_MD_GLOBAL_TABLE_VALID_SHFT            63
-#define SH_MD_GLOBAL_TABLE_VALID_MASK            0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_OVER_RIDE_TABLE"                   */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-#define SH_MD_OVER_RIDE_TABLE                    0x0000000150024480
-#define SH_MD_OVER_RIDE_TABLE_MASK               0x8000000000003f3f
-#define SH_MD_OVER_RIDE_TABLE_INIT               0x8000000000002000
-
-/*   SH_MD_OVER_RIDE_TABLE_DIR0                                         */
-/*   Description:  Direction field for next chip                        */
-#define SH_MD_OVER_RIDE_TABLE_DIR0_SHFT          0
-#define SH_MD_OVER_RIDE_TABLE_DIR0_MASK          0x000000000000000f
-
-/*   SH_MD_OVER_RIDE_TABLE_V0                                           */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_MD_OVER_RIDE_TABLE_V0_SHFT            4
-#define SH_MD_OVER_RIDE_TABLE_V0_MASK            0x0000000000000010
-
-/*   SH_MD_OVER_RIDE_TABLE_NI_SEL0                                      */
-/*   Description:  ni select                                            */
-#define SH_MD_OVER_RIDE_TABLE_NI_SEL0_SHFT       5
-#define SH_MD_OVER_RIDE_TABLE_NI_SEL0_MASK       0x0000000000000020
-
-/*   SH_MD_OVER_RIDE_TABLE_DIR1                                         */
-#define SH_MD_OVER_RIDE_TABLE_DIR1_SHFT          8
-#define SH_MD_OVER_RIDE_TABLE_DIR1_MASK          0x0000000000000f00
-
-/*   SH_MD_OVER_RIDE_TABLE_V1                                           */
-/*   Description:  Low bit of virtual channel for next chip             */
-#define SH_MD_OVER_RIDE_TABLE_V1_SHFT            12
-#define SH_MD_OVER_RIDE_TABLE_V1_MASK            0x0000000000001000
-
-/*   SH_MD_OVER_RIDE_TABLE_NI_SEL1                                      */
-/*   Description:  ni select                                            */
-#define SH_MD_OVER_RIDE_TABLE_NI_SEL1_SHFT       13
-#define SH_MD_OVER_RIDE_TABLE_NI_SEL1_MASK       0x0000000000002000
-
-/*   SH_MD_OVER_RIDE_TABLE_ENABLE                                       */
-/*   Description:  Indicates that this entry is enabled                 */
-#define SH_MD_OVER_RIDE_TABLE_ENABLE_SHFT        63
-#define SH_MD_OVER_RIDE_TABLE_ENABLE_MASK        0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_RSP_PLANE_HINT"                    */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-#define SH_MD_RSP_PLANE_HINT                     0x0000000150024488
-#define SH_MD_RSP_PLANE_HINT_MASK                0x0000000000000001
-#define SH_MD_RSP_PLANE_HINT_INIT                0x0000000000000000
-
-/*   SH_MD_RSP_PLANE_HINT_INVERT                                        */
-/*   Description:  Invert Response Plane Hint                           */
-#define SH_MD_RSP_PLANE_HINT_INVERT_SHFT         0
-#define SH_MD_RSP_PLANE_HINT_INVERT_MASK         0x0000000000000001
-
-/* ==================================================================== */
-/*                       Register "SH_LB_LIQ_CTL"                       */
-/*                       Local Block LIQ Control                        */
-/* ==================================================================== */
-
-#define SH_LB_LIQ_CTL                            0x0000000110040000
-#define SH_LB_LIQ_CTL_MASK                       0x0000000000070f1f
-#define SH_LB_LIQ_CTL_INIT                       0x0000000000000000
-
-/*   SH_LB_LIQ_CTL_LIQ_REQ_CTL                                          */
-/*   Description:  LIQ Request Control                                  */
-#define SH_LB_LIQ_CTL_LIQ_REQ_CTL_SHFT           0
-#define SH_LB_LIQ_CTL_LIQ_REQ_CTL_MASK           0x000000000000001f
-
-/*   SH_LB_LIQ_CTL_LIQ_RPL_CTL                                          */
-/*   Description:  LIQ Reply Control                                    */
-#define SH_LB_LIQ_CTL_LIQ_RPL_CTL_SHFT           8
-#define SH_LB_LIQ_CTL_LIQ_RPL_CTL_MASK           0x0000000000000f00
-
-/*   SH_LB_LIQ_CTL_FORCE_RQ_CREDIT                                      */
-/*   Description:  Force request credit                                 */
-#define SH_LB_LIQ_CTL_FORCE_RQ_CREDIT_SHFT       16
-#define SH_LB_LIQ_CTL_FORCE_RQ_CREDIT_MASK       0x0000000000010000
-
-/*   SH_LB_LIQ_CTL_FORCE_RP_CREDIT                                      */
-/*   Description:  Force reply credit                                   */
-#define SH_LB_LIQ_CTL_FORCE_RP_CREDIT_SHFT       17
-#define SH_LB_LIQ_CTL_FORCE_RP_CREDIT_MASK       0x0000000000020000
-
-/*   SH_LB_LIQ_CTL_FORCE_LINVV_CREDIT                                   */
-/*   Description:  Force linvv credit                                   */
-#define SH_LB_LIQ_CTL_FORCE_LINVV_CREDIT_SHFT    18
-#define SH_LB_LIQ_CTL_FORCE_LINVV_CREDIT_MASK    0x0000000000040000
-
-/* ==================================================================== */
-/*                       Register "SH_LB_LOQ_CTL"                       */
-/*                       Local Block LOQ Control                        */
-/* ==================================================================== */
-
-#define SH_LB_LOQ_CTL                            0x0000000110040080
-#define SH_LB_LOQ_CTL_MASK                       0x0000000000000003
-#define SH_LB_LOQ_CTL_INIT                       0x0000000000000000
-
-/*   SH_LB_LOQ_CTL_LOQ_REQ_CTL                                          */
-/*   Description:  LOQ Request Control                                  */
-#define SH_LB_LOQ_CTL_LOQ_REQ_CTL_SHFT           0
-#define SH_LB_LOQ_CTL_LOQ_REQ_CTL_MASK           0x0000000000000001
-
-/*   SH_LB_LOQ_CTL_LOQ_RPL_CTL                                          */
-/*   Description:  LOQ Reply Control                                    */
-#define SH_LB_LOQ_CTL_LOQ_RPL_CTL_SHFT           1
-#define SH_LB_LOQ_CTL_LOQ_RPL_CTL_MASK           0x0000000000000002
-
-/* ==================================================================== */
-/*                 Register "SH_LB_MAX_REP_CREDIT_CNT"                  */
-/*               Maximum number of reply credits from XN                */
-/* ==================================================================== */
-
-#define SH_LB_MAX_REP_CREDIT_CNT                 0x0000000110040100
-#define SH_LB_MAX_REP_CREDIT_CNT_MASK            0x000000000000001f
-#define SH_LB_MAX_REP_CREDIT_CNT_INIT            0x000000000000001f
-
-/*   SH_LB_MAX_REP_CREDIT_CNT_MAX_CNT                                   */
-/*   Description:  Max reply credits                                    */
-#define SH_LB_MAX_REP_CREDIT_CNT_MAX_CNT_SHFT    0
-#define SH_LB_MAX_REP_CREDIT_CNT_MAX_CNT_MASK    0x000000000000001f
-
-/* ==================================================================== */
-/*                 Register "SH_LB_MAX_REQ_CREDIT_CNT"                  */
-/*              Maximum number of request credits from XN               */
-/* ==================================================================== */
-
-#define SH_LB_MAX_REQ_CREDIT_CNT                 0x0000000110040180
-#define SH_LB_MAX_REQ_CREDIT_CNT_MASK            0x000000000000001f
-#define SH_LB_MAX_REQ_CREDIT_CNT_INIT            0x000000000000001f
-
-/*   SH_LB_MAX_REQ_CREDIT_CNT_MAX_CNT                                   */
-/*   Description:  Max request credits                                  */
-#define SH_LB_MAX_REQ_CREDIT_CNT_MAX_CNT_SHFT    0
-#define SH_LB_MAX_REQ_CREDIT_CNT_MAX_CNT_MASK    0x000000000000001f
-
-/* ==================================================================== */
-/*                      Register "SH_PIO_TIME_OUT"                      */
-/*                    Local Block PIO time out value                    */
-/* ==================================================================== */
-
-#define SH_PIO_TIME_OUT                          0x0000000110040200
-#define SH_PIO_TIME_OUT_MASK                     0x000000000000ffff
-#define SH_PIO_TIME_OUT_INIT                     0x0000000000000400
-
-/*   SH_PIO_TIME_OUT_VALUE                                              */
-/*   Description:  PIO time out value                                   */
-#define SH_PIO_TIME_OUT_VALUE_SHFT               0
-#define SH_PIO_TIME_OUT_VALUE_MASK               0x000000000000ffff
-
-/* ==================================================================== */
-/*                     Register "SH_PIO_NACK_RESET"                     */
-/*               Local Block PIO Reset for nack counters                */
-/* ==================================================================== */
-
-#define SH_PIO_NACK_RESET                        0x0000000110040280
-#define SH_PIO_NACK_RESET_MASK                   0x0000000000000001
-#define SH_PIO_NACK_RESET_INIT                   0x0000000000000000
-
-/*   SH_PIO_NACK_RESET_PULSE                                            */
-/*   Description:  PIO nack counter reset                               */
-#define SH_PIO_NACK_RESET_PULSE_SHFT             0
-#define SH_PIO_NACK_RESET_PULSE_MASK             0x0000000000000001
-
-/* ==================================================================== */
-/*                 Register "SH_CONVEYOR_BELT_TIME_OUT"                 */
-/*               Local Block conveyor belt time out value               */
-/* ==================================================================== */
-
-#define SH_CONVEYOR_BELT_TIME_OUT                0x0000000110040300
-#define SH_CONVEYOR_BELT_TIME_OUT_MASK           0x0000000000000fff
-#define SH_CONVEYOR_BELT_TIME_OUT_INIT           0x0000000000000000
-
-/*   SH_CONVEYOR_BELT_TIME_OUT_VALUE                                    */
-/*   Description:  Conveyor belt time out value                         */
-#define SH_CONVEYOR_BELT_TIME_OUT_VALUE_SHFT     0
-#define SH_CONVEYOR_BELT_TIME_OUT_VALUE_MASK     0x0000000000000fff
-
-/* ==================================================================== */
-/*                    Register "SH_LB_CREDIT_STATUS"                    */
-/*                    Credit Counter Status Register                    */
-/* ==================================================================== */
-
-#define SH_LB_CREDIT_STATUS                      0x0000000110050000
-#define SH_LB_CREDIT_STATUS_MASK                 0x000000000ffff3df
-#define SH_LB_CREDIT_STATUS_INIT                 0x0000000000000000
-
-/*   SH_LB_CREDIT_STATUS_LIQ_RQ_CREDIT                                  */
-/*   Description:  LIQ request queue credit counter                     */
-#define SH_LB_CREDIT_STATUS_LIQ_RQ_CREDIT_SHFT   0
-#define SH_LB_CREDIT_STATUS_LIQ_RQ_CREDIT_MASK   0x000000000000001f
-
-/*   SH_LB_CREDIT_STATUS_LIQ_RP_CREDIT                                  */
-/*   Description:  LIQ reply queue credit counter                       */
-#define SH_LB_CREDIT_STATUS_LIQ_RP_CREDIT_SHFT   6
-#define SH_LB_CREDIT_STATUS_LIQ_RP_CREDIT_MASK   0x00000000000003c0
-
-/*   SH_LB_CREDIT_STATUS_LINVV_CREDIT                                   */
-/*   Description:  LINVV credit counter                                 */
-#define SH_LB_CREDIT_STATUS_LINVV_CREDIT_SHFT    12
-#define SH_LB_CREDIT_STATUS_LINVV_CREDIT_MASK    0x000000000003f000
-
-/*   SH_LB_CREDIT_STATUS_LOQ_RQ_CREDIT                                  */
-/*   Description:  LOQ request queue credit counter                     */
-#define SH_LB_CREDIT_STATUS_LOQ_RQ_CREDIT_SHFT   18
-#define SH_LB_CREDIT_STATUS_LOQ_RQ_CREDIT_MASK   0x00000000007c0000
-
-/*   SH_LB_CREDIT_STATUS_LOQ_RP_CREDIT                                  */
-/*   Description:  LOQ reply queue credit counter                       */
-#define SH_LB_CREDIT_STATUS_LOQ_RP_CREDIT_SHFT   23
-#define SH_LB_CREDIT_STATUS_LOQ_RP_CREDIT_MASK   0x000000000f800000
-
-/* ==================================================================== */
-/*                   Register "SH_LB_DEBUG_LOCAL_SEL"                   */
-/*                         LB Debug Port Select                         */
-/* ==================================================================== */
-
-#define SH_LB_DEBUG_LOCAL_SEL                    0x0000000110050080
-#define SH_LB_DEBUG_LOCAL_SEL_MASK               0xf777777777777777
-#define SH_LB_DEBUG_LOCAL_SEL_INIT               0x0000000000000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE0_CHIPLET_SEL                          */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE0_CHIPLET_SEL_SHFT 0
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE0_NIBBLE_SEL                           */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE1_CHIPLET_SEL                          */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE1_CHIPLET_SEL_SHFT 8
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE1_NIBBLE_SEL                           */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE2_CHIPLET_SEL                          */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE2_CHIPLET_SEL_SHFT 16
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE2_NIBBLE_SEL                           */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE3_CHIPLET_SEL                          */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE3_CHIPLET_SEL_SHFT 24
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE3_NIBBLE_SEL                           */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE4_CHIPLET_SEL                          */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE4_CHIPLET_SEL_SHFT 32
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE4_NIBBLE_SEL                           */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE5_CHIPLET_SEL                          */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE5_CHIPLET_SEL_SHFT 40
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE5_NIBBLE_SEL                           */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE6_CHIPLET_SEL                          */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE6_CHIPLET_SEL_SHFT 48
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE6_NIBBLE_SEL                           */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE7_CHIPLET_SEL                          */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE7_CHIPLET_SEL_SHFT 56
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_NIBBLE7_NIBBLE_SEL                           */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_LB_DEBUG_LOCAL_SEL_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/*   SH_LB_DEBUG_LOCAL_SEL_TRIGGER_ENABLE                               */
-/*   Description:  Enable trigger on bit 32 of Analyzer data            */
-#define SH_LB_DEBUG_LOCAL_SEL_TRIGGER_ENABLE_SHFT 63
-#define SH_LB_DEBUG_LOCAL_SEL_TRIGGER_ENABLE_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LB_DEBUG_PERF_SEL"                    */
-/*                   LB Debug Port Performance Select                   */
-/* ==================================================================== */
-
-#define SH_LB_DEBUG_PERF_SEL                     0x0000000110050100
-#define SH_LB_DEBUG_PERF_SEL_MASK                0x7777777777777777
-#define SH_LB_DEBUG_PERF_SEL_INIT                0x0000000000000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE0_CHIPLET_SEL                           */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE0_CHIPLET_SEL_SHFT 0
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE0_NIBBLE_SEL                            */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE1_CHIPLET_SEL                           */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE1_CHIPLET_SEL_SHFT 8
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE1_NIBBLE_SEL                            */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE2_CHIPLET_SEL                           */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE2_CHIPLET_SEL_SHFT 16
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE2_NIBBLE_SEL                            */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE3_CHIPLET_SEL                           */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE3_CHIPLET_SEL_SHFT 24
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE3_NIBBLE_SEL                            */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE4_CHIPLET_SEL                           */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE4_CHIPLET_SEL_SHFT 32
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE4_NIBBLE_SEL                            */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE5_CHIPLET_SEL                           */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE5_CHIPLET_SEL_SHFT 40
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE5_NIBBLE_SEL                            */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE6_CHIPLET_SEL                           */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE6_CHIPLET_SEL_SHFT 48
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE6_NIBBLE_SEL                            */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE7_CHIPLET_SEL                           */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE7_CHIPLET_SEL_SHFT 56
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_LB_DEBUG_PERF_SEL_NIBBLE7_NIBBLE_SEL                            */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_LB_DEBUG_PERF_SEL_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LB_DEBUG_TRIG_SEL"                    */
-/*                       LB Debug Trigger Select                        */
-/* ==================================================================== */
-
-#define SH_LB_DEBUG_TRIG_SEL                     0x0000000110050180
-#define SH_LB_DEBUG_TRIG_SEL_MASK                0x7777777777777777
-#define SH_LB_DEBUG_TRIG_SEL_INIT                0x0000000000000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER0_CHIPLET_SEL                          */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER0_CHIPLET_SEL_SHFT 0
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER0_NIBBLE_SEL                           */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER0_NIBBLE_SEL_SHFT 4
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER1_CHIPLET_SEL                          */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER1_CHIPLET_SEL_SHFT 8
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER1_NIBBLE_SEL                           */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER1_NIBBLE_SEL_SHFT 12
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER2_CHIPLET_SEL                          */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER2_CHIPLET_SEL_SHFT 16
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER2_NIBBLE_SEL                           */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER2_NIBBLE_SEL_SHFT 20
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER3_CHIPLET_SEL                          */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER3_CHIPLET_SEL_SHFT 24
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER3_NIBBLE_SEL                           */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER3_NIBBLE_SEL_SHFT 28
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER4_CHIPLET_SEL                          */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER4_CHIPLET_SEL_SHFT 32
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER4_NIBBLE_SEL                           */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER4_NIBBLE_SEL_SHFT 36
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER5_CHIPLET_SEL                          */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER5_CHIPLET_SEL_SHFT 40
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER5_NIBBLE_SEL                           */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER5_NIBBLE_SEL_SHFT 44
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER6_CHIPLET_SEL                          */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER6_CHIPLET_SEL_SHFT 48
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER6_NIBBLE_SEL                           */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER6_NIBBLE_SEL_SHFT 52
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER7_CHIPLET_SEL                          */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER7_CHIPLET_SEL_SHFT 56
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_LB_DEBUG_TRIG_SEL_TRIGGER7_NIBBLE_SEL                           */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER7_NIBBLE_SEL_SHFT 60
-#define SH_LB_DEBUG_TRIG_SEL_TRIGGER7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_1"                    */
-/*                  LB Error capture information: HDR1                  */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_DETAIL_1                     0x0000000110050200
-#define SH_LB_ERROR_DETAIL_1_MASK                0x8003073fff3fffff
-#define SH_LB_ERROR_DETAIL_1_INIT                0x0000000000000000
-
-/*   SH_LB_ERROR_DETAIL_1_COMMAND                                       */
-/*   Description:  COMMAND                                              */
-#define SH_LB_ERROR_DETAIL_1_COMMAND_SHFT        0
-#define SH_LB_ERROR_DETAIL_1_COMMAND_MASK        0x00000000000000ff
-
-/*   SH_LB_ERROR_DETAIL_1_SUPPL                                         */
-/*   Description:  SUPPLMENTAL                                          */
-#define SH_LB_ERROR_DETAIL_1_SUPPL_SHFT          8
-#define SH_LB_ERROR_DETAIL_1_SUPPL_MASK          0x00000000003fff00
-
-/*   SH_LB_ERROR_DETAIL_1_SOURCE                                        */
-/*   Description:  SOURCE                                               */
-#define SH_LB_ERROR_DETAIL_1_SOURCE_SHFT         24
-#define SH_LB_ERROR_DETAIL_1_SOURCE_MASK         0x0000003fff000000
-
-/*   SH_LB_ERROR_DETAIL_1_DEST                                          */
-/*   Description:  DEST                                                 */
-#define SH_LB_ERROR_DETAIL_1_DEST_SHFT           40
-#define SH_LB_ERROR_DETAIL_1_DEST_MASK           0x0000070000000000
-
-/*   SH_LB_ERROR_DETAIL_1_HDR_ERR                                       */
-/*   Description:  HDR_ERR                                              */
-#define SH_LB_ERROR_DETAIL_1_HDR_ERR_SHFT        48
-#define SH_LB_ERROR_DETAIL_1_HDR_ERR_MASK        0x0001000000000000
-
-/*   SH_LB_ERROR_DETAIL_1_DATA_ERR                                      */
-/*   Description:  DATA_ERR                                             */
-#define SH_LB_ERROR_DETAIL_1_DATA_ERR_SHFT       49
-#define SH_LB_ERROR_DETAIL_1_DATA_ERR_MASK       0x0002000000000000
-
-/*   SH_LB_ERROR_DETAIL_1_VALID                                         */
-/*   Description:  VALID                                                */
-#define SH_LB_ERROR_DETAIL_1_VALID_SHFT          63
-#define SH_LB_ERROR_DETAIL_1_VALID_MASK          0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_2"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_DETAIL_2                     0x0000000110050280
-#define SH_LB_ERROR_DETAIL_2_MASK                0x00007fffffffffff
-#define SH_LB_ERROR_DETAIL_2_INIT                0x0000000000000000
-
-/*   SH_LB_ERROR_DETAIL_2_ADDRESS                                       */
-/*   Description:  ADDRESS                                              */
-#define SH_LB_ERROR_DETAIL_2_ADDRESS_SHFT        0
-#define SH_LB_ERROR_DETAIL_2_ADDRESS_MASK        0x00007fffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_3"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_DETAIL_3                     0x0000000110050300
-#define SH_LB_ERROR_DETAIL_3_MASK                0xffffffffffffffff
-#define SH_LB_ERROR_DETAIL_3_INIT                0x0000000000000000
-
-/*   SH_LB_ERROR_DETAIL_3_DATA                                          */
-/*   Description:  DATA                                                 */
-#define SH_LB_ERROR_DETAIL_3_DATA_SHFT           0
-#define SH_LB_ERROR_DETAIL_3_DATA_MASK           0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_4"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_DETAIL_4                     0x0000000110050380
-#define SH_LB_ERROR_DETAIL_4_MASK                0xffffffffffffffff
-#define SH_LB_ERROR_DETAIL_4_INIT                0x0000000000000000
-
-/*   SH_LB_ERROR_DETAIL_4_ROUTE                                         */
-/*   Description:  ROUTE                                                */
-#define SH_LB_ERROR_DETAIL_4_ROUTE_SHFT          0
-#define SH_LB_ERROR_DETAIL_4_ROUTE_MASK          0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_5"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_DETAIL_5                     0x0000000110050400
-#define SH_LB_ERROR_DETAIL_5_MASK                0x000000000000007f
-#define SH_LB_ERROR_DETAIL_5_INIT                0x0000000000000000
-
-/*   SH_LB_ERROR_DETAIL_5_READ_RETRY                                    */
-/*   Description:  Read retry error                                     */
-#define SH_LB_ERROR_DETAIL_5_READ_RETRY_SHFT     0
-#define SH_LB_ERROR_DETAIL_5_READ_RETRY_MASK     0x0000000000000001
-
-/*   SH_LB_ERROR_DETAIL_5_PTC1_WRITE                                    */
-/*   Description:  PTC1 write error                                     */
-#define SH_LB_ERROR_DETAIL_5_PTC1_WRITE_SHFT     1
-#define SH_LB_ERROR_DETAIL_5_PTC1_WRITE_MASK     0x0000000000000002
-
-/*   SH_LB_ERROR_DETAIL_5_WRITE_RETRY                                   */
-/*   Description:  Write retry error                                    */
-#define SH_LB_ERROR_DETAIL_5_WRITE_RETRY_SHFT    2
-#define SH_LB_ERROR_DETAIL_5_WRITE_RETRY_MASK    0x0000000000000004
-
-/*   SH_LB_ERROR_DETAIL_5_COUNT_A_OVERFLOW                              */
-/*   Description:  Nack A counter overflow error                        */
-#define SH_LB_ERROR_DETAIL_5_COUNT_A_OVERFLOW_SHFT 3
-#define SH_LB_ERROR_DETAIL_5_COUNT_A_OVERFLOW_MASK 0x0000000000000008
-
-/*   SH_LB_ERROR_DETAIL_5_COUNT_B_OVERFLOW                              */
-/*   Description:  Nack B counter overflow error                        */
-#define SH_LB_ERROR_DETAIL_5_COUNT_B_OVERFLOW_SHFT 4
-#define SH_LB_ERROR_DETAIL_5_COUNT_B_OVERFLOW_MASK 0x0000000000000010
-
-/*   SH_LB_ERROR_DETAIL_5_NACK_A_TIMEOUT                                */
-/*   Description:  Nack A counter timeout error                         */
-#define SH_LB_ERROR_DETAIL_5_NACK_A_TIMEOUT_SHFT 5
-#define SH_LB_ERROR_DETAIL_5_NACK_A_TIMEOUT_MASK 0x0000000000000020
-
-/*   SH_LB_ERROR_DETAIL_5_NACK_B_TIMEOUT                                */
-/*   Description:  Nack B counter timeout error                         */
-#define SH_LB_ERROR_DETAIL_5_NACK_B_TIMEOUT_SHFT 6
-#define SH_LB_ERROR_DETAIL_5_NACK_B_TIMEOUT_MASK 0x0000000000000040
-
-/* ==================================================================== */
-/*                     Register "SH_LB_ERROR_MASK"                      */
-/*                            LB Error Mask                             */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_MASK                         0x0000000110050480
-#define SH_LB_ERROR_MASK_MASK                    0x00000000007fffff
-#define SH_LB_ERROR_MASK_INIT                    0x00000000007fffff
-
-/*   SH_LB_ERROR_MASK_RQ_BAD_CMD                                        */
-/*   Description:  RQ_BAD_CMD                                           */
-#define SH_LB_ERROR_MASK_RQ_BAD_CMD_SHFT         0
-#define SH_LB_ERROR_MASK_RQ_BAD_CMD_MASK         0x0000000000000001
-
-/*   SH_LB_ERROR_MASK_RP_BAD_CMD                                        */
-/*   Description:  RP_BAD_CMD                                           */
-#define SH_LB_ERROR_MASK_RP_BAD_CMD_SHFT         1
-#define SH_LB_ERROR_MASK_RP_BAD_CMD_MASK         0x0000000000000002
-
-/*   SH_LB_ERROR_MASK_RQ_SHORT                                          */
-/*   Description:  RQ_SHORT                                             */
-#define SH_LB_ERROR_MASK_RQ_SHORT_SHFT           2
-#define SH_LB_ERROR_MASK_RQ_SHORT_MASK           0x0000000000000004
-
-/*   SH_LB_ERROR_MASK_RP_SHORT                                          */
-/*   Description:  RP_SHORT                                             */
-#define SH_LB_ERROR_MASK_RP_SHORT_SHFT           3
-#define SH_LB_ERROR_MASK_RP_SHORT_MASK           0x0000000000000008
-
-/*   SH_LB_ERROR_MASK_RQ_LONG                                           */
-/*   Description:  RQ_LONG                                              */
-#define SH_LB_ERROR_MASK_RQ_LONG_SHFT            4
-#define SH_LB_ERROR_MASK_RQ_LONG_MASK            0x0000000000000010
-
-/*   SH_LB_ERROR_MASK_RP_LONG                                           */
-/*   Description:  RP_LONG                                              */
-#define SH_LB_ERROR_MASK_RP_LONG_SHFT            5
-#define SH_LB_ERROR_MASK_RP_LONG_MASK            0x0000000000000020
-
-/*   SH_LB_ERROR_MASK_RQ_BAD_DATA                                       */
-/*   Description:  RQ_BAD_DATA                                          */
-#define SH_LB_ERROR_MASK_RQ_BAD_DATA_SHFT        6
-#define SH_LB_ERROR_MASK_RQ_BAD_DATA_MASK        0x0000000000000040
-
-/*   SH_LB_ERROR_MASK_RP_BAD_DATA                                       */
-/*   Description:  RP_BAD_DATA                                          */
-#define SH_LB_ERROR_MASK_RP_BAD_DATA_SHFT        7
-#define SH_LB_ERROR_MASK_RP_BAD_DATA_MASK        0x0000000000000080
-
-/*   SH_LB_ERROR_MASK_RQ_BAD_ADDR                                       */
-/*   Description:  RQ_BAD_ADDR                                          */
-#define SH_LB_ERROR_MASK_RQ_BAD_ADDR_SHFT        8
-#define SH_LB_ERROR_MASK_RQ_BAD_ADDR_MASK        0x0000000000000100
-
-/*   SH_LB_ERROR_MASK_RQ_TIME_OUT                                       */
-/*   Description:  RQ_TIME_OUT                                          */
-#define SH_LB_ERROR_MASK_RQ_TIME_OUT_SHFT        9
-#define SH_LB_ERROR_MASK_RQ_TIME_OUT_MASK        0x0000000000000200
-
-/*   SH_LB_ERROR_MASK_LINVV_OVERFLOW                                    */
-/*   Description:  LINVV_OVERFLOW                                       */
-#define SH_LB_ERROR_MASK_LINVV_OVERFLOW_SHFT     10
-#define SH_LB_ERROR_MASK_LINVV_OVERFLOW_MASK     0x0000000000000400
-
-/*   SH_LB_ERROR_MASK_UNEXPECTED_LINV                                   */
-/*   Description:  UNEXPECTED_LINV                                      */
-#define SH_LB_ERROR_MASK_UNEXPECTED_LINV_SHFT    11
-#define SH_LB_ERROR_MASK_UNEXPECTED_LINV_MASK    0x0000000000000800
-
-/*   SH_LB_ERROR_MASK_PTC_1_TIMEOUT                                     */
-/*   Description:  PTC_1 Time out                                       */
-#define SH_LB_ERROR_MASK_PTC_1_TIMEOUT_SHFT      12
-#define SH_LB_ERROR_MASK_PTC_1_TIMEOUT_MASK      0x0000000000001000
-
-/*   SH_LB_ERROR_MASK_JUNK_BUS_ERR                                      */
-/*   Description:  Junk Bus error                                       */
-#define SH_LB_ERROR_MASK_JUNK_BUS_ERR_SHFT       13
-#define SH_LB_ERROR_MASK_JUNK_BUS_ERR_MASK       0x0000000000002000
-
-/*   SH_LB_ERROR_MASK_PIO_CB_ERR                                        */
-/*   Description:  PIO Conveyor Belt operation error                    */
-#define SH_LB_ERROR_MASK_PIO_CB_ERR_SHFT         14
-#define SH_LB_ERROR_MASK_PIO_CB_ERR_MASK         0x0000000000004000
-
-/*   SH_LB_ERROR_MASK_VECTOR_RQ_ROUTE_ERROR                             */
-/*   Description:  Vector request Route data was invalid                */
-#define SH_LB_ERROR_MASK_VECTOR_RQ_ROUTE_ERROR_SHFT 15
-#define SH_LB_ERROR_MASK_VECTOR_RQ_ROUTE_ERROR_MASK 0x0000000000008000
-
-/*   SH_LB_ERROR_MASK_VECTOR_RP_ROUTE_ERROR                             */
-/*   Description:  Vector reply Route data was invalid                  */
-#define SH_LB_ERROR_MASK_VECTOR_RP_ROUTE_ERROR_SHFT 16
-#define SH_LB_ERROR_MASK_VECTOR_RP_ROUTE_ERROR_MASK 0x0000000000010000
-
-/*   SH_LB_ERROR_MASK_GCLK_DROP                                         */
-/*   Description:  Gclk drop error                                      */
-#define SH_LB_ERROR_MASK_GCLK_DROP_SHFT          17
-#define SH_LB_ERROR_MASK_GCLK_DROP_MASK          0x0000000000020000
-
-/*   SH_LB_ERROR_MASK_RQ_FIFO_ERROR                                     */
-/*   Description:  Request queue FIFO error                             */
-#define SH_LB_ERROR_MASK_RQ_FIFO_ERROR_SHFT      18
-#define SH_LB_ERROR_MASK_RQ_FIFO_ERROR_MASK      0x0000000000040000
-
-/*   SH_LB_ERROR_MASK_RP_FIFO_ERROR                                     */
-/*   Description:  Reply queue FIFO error                               */
-#define SH_LB_ERROR_MASK_RP_FIFO_ERROR_SHFT      19
-#define SH_LB_ERROR_MASK_RP_FIFO_ERROR_MASK      0x0000000000080000
-
-/*   SH_LB_ERROR_MASK_UNEXP_VALID                                       */
-/*   Description:  Unexpected valid error                               */
-#define SH_LB_ERROR_MASK_UNEXP_VALID_SHFT        20
-#define SH_LB_ERROR_MASK_UNEXP_VALID_MASK        0x0000000000100000
-
-/*   SH_LB_ERROR_MASK_RQ_CREDIT_OVERFLOW                                */
-/*   Description:  Request queue credit overflow                        */
-#define SH_LB_ERROR_MASK_RQ_CREDIT_OVERFLOW_SHFT 21
-#define SH_LB_ERROR_MASK_RQ_CREDIT_OVERFLOW_MASK 0x0000000000200000
-
-/*   SH_LB_ERROR_MASK_RP_CREDIT_OVERFLOW                                */
-/*   Description:  Reply queue credit overflow                          */
-#define SH_LB_ERROR_MASK_RP_CREDIT_OVERFLOW_SHFT 22
-#define SH_LB_ERROR_MASK_RP_CREDIT_OVERFLOW_MASK 0x0000000000400000
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_OVERFLOW"                    */
-/*                          LB Error Overflow                           */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_OVERFLOW                     0x0000000110050500
-#define SH_LB_ERROR_OVERFLOW_MASK                0x00000000007fffff
-#define SH_LB_ERROR_OVERFLOW_INIT                0x0000000000000000
-
-/*   SH_LB_ERROR_OVERFLOW_RQ_BAD_CMD_OVRFL                              */
-/*   Description:  RQ_BAD_CMD_OVRFL                                     */
-#define SH_LB_ERROR_OVERFLOW_RQ_BAD_CMD_OVRFL_SHFT 0
-#define SH_LB_ERROR_OVERFLOW_RQ_BAD_CMD_OVRFL_MASK 0x0000000000000001
-
-/*   SH_LB_ERROR_OVERFLOW_RP_BAD_CMD_OVRFL                              */
-/*   Description:  RP_BAD_CMD_OVRFL                                     */
-#define SH_LB_ERROR_OVERFLOW_RP_BAD_CMD_OVRFL_SHFT 1
-#define SH_LB_ERROR_OVERFLOW_RP_BAD_CMD_OVRFL_MASK 0x0000000000000002
-
-/*   SH_LB_ERROR_OVERFLOW_RQ_SHORT_OVRFL                                */
-/*   Description:  RQ_SHORT_OVRFL                                       */
-#define SH_LB_ERROR_OVERFLOW_RQ_SHORT_OVRFL_SHFT 2
-#define SH_LB_ERROR_OVERFLOW_RQ_SHORT_OVRFL_MASK 0x0000000000000004
-
-/*   SH_LB_ERROR_OVERFLOW_RP_SHORT_OVRFL                                */
-/*   Description:  RP_SHORT_OVRFL                                       */
-#define SH_LB_ERROR_OVERFLOW_RP_SHORT_OVRFL_SHFT 3
-#define SH_LB_ERROR_OVERFLOW_RP_SHORT_OVRFL_MASK 0x0000000000000008
-
-/*   SH_LB_ERROR_OVERFLOW_RQ_LONG_OVRFL                                 */
-/*   Description:  RQ_LONG_OVRFL                                        */
-#define SH_LB_ERROR_OVERFLOW_RQ_LONG_OVRFL_SHFT  4
-#define SH_LB_ERROR_OVERFLOW_RQ_LONG_OVRFL_MASK  0x0000000000000010
-
-/*   SH_LB_ERROR_OVERFLOW_RP_LONG_OVRFL                                 */
-/*   Description:  RP_LONG_OVRFL                                        */
-#define SH_LB_ERROR_OVERFLOW_RP_LONG_OVRFL_SHFT  5
-#define SH_LB_ERROR_OVERFLOW_RP_LONG_OVRFL_MASK  0x0000000000000020
-
-/*   SH_LB_ERROR_OVERFLOW_RQ_BAD_DATA_OVRFL                             */
-/*   Description:  RQ_BAD_DATA_OVRFL                                    */
-#define SH_LB_ERROR_OVERFLOW_RQ_BAD_DATA_OVRFL_SHFT 6
-#define SH_LB_ERROR_OVERFLOW_RQ_BAD_DATA_OVRFL_MASK 0x0000000000000040
-
-/*   SH_LB_ERROR_OVERFLOW_RP_BAD_DATA_OVRFL                             */
-/*   Description:  RP_BAD_DATA_OVRFL                                    */
-#define SH_LB_ERROR_OVERFLOW_RP_BAD_DATA_OVRFL_SHFT 7
-#define SH_LB_ERROR_OVERFLOW_RP_BAD_DATA_OVRFL_MASK 0x0000000000000080
-
-/*   SH_LB_ERROR_OVERFLOW_RQ_BAD_ADDR_OVRFL                             */
-/*   Description:  RQ_BAD_ADDR_OVRFL                                    */
-#define SH_LB_ERROR_OVERFLOW_RQ_BAD_ADDR_OVRFL_SHFT 8
-#define SH_LB_ERROR_OVERFLOW_RQ_BAD_ADDR_OVRFL_MASK 0x0000000000000100
-
-/*   SH_LB_ERROR_OVERFLOW_RQ_TIME_OUT_OVRFL                             */
-/*   Description:  RQ_TIME_OUT_OVRFL                                    */
-#define SH_LB_ERROR_OVERFLOW_RQ_TIME_OUT_OVRFL_SHFT 9
-#define SH_LB_ERROR_OVERFLOW_RQ_TIME_OUT_OVRFL_MASK 0x0000000000000200
-
-/*   SH_LB_ERROR_OVERFLOW_LINVV_OVERFLOW_OVRFL                          */
-/*   Description:  LINVV_OVERFLOW_OVRFL                                 */
-#define SH_LB_ERROR_OVERFLOW_LINVV_OVERFLOW_OVRFL_SHFT 10
-#define SH_LB_ERROR_OVERFLOW_LINVV_OVERFLOW_OVRFL_MASK 0x0000000000000400
-
-/*   SH_LB_ERROR_OVERFLOW_UNEXPECTED_LINV_OVRFL                         */
-/*   Description:  UNEXPECTED_LINV_OVRFL                                */
-#define SH_LB_ERROR_OVERFLOW_UNEXPECTED_LINV_OVRFL_SHFT 11
-#define SH_LB_ERROR_OVERFLOW_UNEXPECTED_LINV_OVRFL_MASK 0x0000000000000800
-
-/*   SH_LB_ERROR_OVERFLOW_PTC_1_TIMEOUT_OVRFL                           */
-/*   Description:  PTC_1 Time out overflow                              */
-#define SH_LB_ERROR_OVERFLOW_PTC_1_TIMEOUT_OVRFL_SHFT 12
-#define SH_LB_ERROR_OVERFLOW_PTC_1_TIMEOUT_OVRFL_MASK 0x0000000000001000
-
-/*   SH_LB_ERROR_OVERFLOW_JUNK_BUS_ERR_OVRFL                            */
-/*   Description:  Junk Bus error overflow                              */
-#define SH_LB_ERROR_OVERFLOW_JUNK_BUS_ERR_OVRFL_SHFT 13
-#define SH_LB_ERROR_OVERFLOW_JUNK_BUS_ERR_OVRFL_MASK 0x0000000000002000
-
-/*   SH_LB_ERROR_OVERFLOW_PIO_CB_ERR_OVRFL                              */
-/*   Description:  PIO Conveyor Belt operation error overflow           */
-#define SH_LB_ERROR_OVERFLOW_PIO_CB_ERR_OVRFL_SHFT 14
-#define SH_LB_ERROR_OVERFLOW_PIO_CB_ERR_OVRFL_MASK 0x0000000000004000
-
-/*   SH_LB_ERROR_OVERFLOW_VECTOR_RQ_ROUTE_ERROR_OVRFL                   */
-/*   Description:  Vector request Route data was invalid overflow       */
-#define SH_LB_ERROR_OVERFLOW_VECTOR_RQ_ROUTE_ERROR_OVRFL_SHFT 15
-#define SH_LB_ERROR_OVERFLOW_VECTOR_RQ_ROUTE_ERROR_OVRFL_MASK 0x0000000000008000
-
-/*   SH_LB_ERROR_OVERFLOW_VECTOR_RP_ROUTE_ERROR_OVRFL                   */
-/*   Description:  Vector reply Route data was invalid overflow         */
-#define SH_LB_ERROR_OVERFLOW_VECTOR_RP_ROUTE_ERROR_OVRFL_SHFT 16
-#define SH_LB_ERROR_OVERFLOW_VECTOR_RP_ROUTE_ERROR_OVRFL_MASK 0x0000000000010000
-
-/*   SH_LB_ERROR_OVERFLOW_GCLK_DROP_OVRFL                               */
-/*   Description:  Gclk drop error overflow                             */
-#define SH_LB_ERROR_OVERFLOW_GCLK_DROP_OVRFL_SHFT 17
-#define SH_LB_ERROR_OVERFLOW_GCLK_DROP_OVRFL_MASK 0x0000000000020000
-
-/*   SH_LB_ERROR_OVERFLOW_RQ_FIFO_ERROR_OVRFL                           */
-/*   Description:  Request queue FIFO error overflow                    */
-#define SH_LB_ERROR_OVERFLOW_RQ_FIFO_ERROR_OVRFL_SHFT 18
-#define SH_LB_ERROR_OVERFLOW_RQ_FIFO_ERROR_OVRFL_MASK 0x0000000000040000
-
-/*   SH_LB_ERROR_OVERFLOW_RP_FIFO_ERROR_OVRFL                           */
-/*   Description:  Reply queue FIFO error overflow                      */
-#define SH_LB_ERROR_OVERFLOW_RP_FIFO_ERROR_OVRFL_SHFT 19
-#define SH_LB_ERROR_OVERFLOW_RP_FIFO_ERROR_OVRFL_MASK 0x0000000000080000
-
-/*   SH_LB_ERROR_OVERFLOW_UNEXP_VALID_OVRFL                             */
-/*   Description:  Unexpected valid error overflow                      */
-#define SH_LB_ERROR_OVERFLOW_UNEXP_VALID_OVRFL_SHFT 20
-#define SH_LB_ERROR_OVERFLOW_UNEXP_VALID_OVRFL_MASK 0x0000000000100000
-
-/*   SH_LB_ERROR_OVERFLOW_RQ_CREDIT_OVERFLOW_OVRFL                      */
-/*   Description:  Request queue credit overflow                        */
-#define SH_LB_ERROR_OVERFLOW_RQ_CREDIT_OVERFLOW_OVRFL_SHFT 21
-#define SH_LB_ERROR_OVERFLOW_RQ_CREDIT_OVERFLOW_OVRFL_MASK 0x0000000000200000
-
-/*   SH_LB_ERROR_OVERFLOW_RP_CREDIT_OVERFLOW_OVRFL                      */
-/*   Description:  Reply queue credit overflow                          */
-#define SH_LB_ERROR_OVERFLOW_RP_CREDIT_OVERFLOW_OVRFL_SHFT 22
-#define SH_LB_ERROR_OVERFLOW_RP_CREDIT_OVERFLOW_OVRFL_MASK 0x0000000000400000
-
-/* ==================================================================== */
-/*                Register "SH_LB_ERROR_OVERFLOW_ALIAS"                 */
-/*                          LB Error Overflow                           */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_OVERFLOW_ALIAS               0x0000000110050508
-
-/* ==================================================================== */
-/*                    Register "SH_LB_ERROR_SUMMARY"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_SUMMARY                      0x0000000110050580
-#define SH_LB_ERROR_SUMMARY_MASK                 0x00000000007fffff
-#define SH_LB_ERROR_SUMMARY_INIT                 0x0000000000000000
-
-/*   SH_LB_ERROR_SUMMARY_RQ_BAD_CMD                                     */
-/*   Description:  RQ_BAD_CMD                                           */
-#define SH_LB_ERROR_SUMMARY_RQ_BAD_CMD_SHFT      0
-#define SH_LB_ERROR_SUMMARY_RQ_BAD_CMD_MASK      0x0000000000000001
-
-/*   SH_LB_ERROR_SUMMARY_RP_BAD_CMD                                     */
-/*   Description:  RP_BAD_CMD                                           */
-#define SH_LB_ERROR_SUMMARY_RP_BAD_CMD_SHFT      1
-#define SH_LB_ERROR_SUMMARY_RP_BAD_CMD_MASK      0x0000000000000002
-
-/*   SH_LB_ERROR_SUMMARY_RQ_SHORT                                       */
-/*   Description:  RQ_SHORT                                             */
-#define SH_LB_ERROR_SUMMARY_RQ_SHORT_SHFT        2
-#define SH_LB_ERROR_SUMMARY_RQ_SHORT_MASK        0x0000000000000004
-
-/*   SH_LB_ERROR_SUMMARY_RP_SHORT                                       */
-/*   Description:  RP_SHORT                                             */
-#define SH_LB_ERROR_SUMMARY_RP_SHORT_SHFT        3
-#define SH_LB_ERROR_SUMMARY_RP_SHORT_MASK        0x0000000000000008
-
-/*   SH_LB_ERROR_SUMMARY_RQ_LONG                                        */
-/*   Description:  RQ_LONG                                              */
-#define SH_LB_ERROR_SUMMARY_RQ_LONG_SHFT         4
-#define SH_LB_ERROR_SUMMARY_RQ_LONG_MASK         0x0000000000000010
-
-/*   SH_LB_ERROR_SUMMARY_RP_LONG                                        */
-/*   Description:  RP_LONG                                              */
-#define SH_LB_ERROR_SUMMARY_RP_LONG_SHFT         5
-#define SH_LB_ERROR_SUMMARY_RP_LONG_MASK         0x0000000000000020
-
-/*   SH_LB_ERROR_SUMMARY_RQ_BAD_DATA                                    */
-/*   Description:  RQ_BAD_DATA                                          */
-#define SH_LB_ERROR_SUMMARY_RQ_BAD_DATA_SHFT     6
-#define SH_LB_ERROR_SUMMARY_RQ_BAD_DATA_MASK     0x0000000000000040
-
-/*   SH_LB_ERROR_SUMMARY_RP_BAD_DATA                                    */
-/*   Description:  RP_BAD_DATA                                          */
-#define SH_LB_ERROR_SUMMARY_RP_BAD_DATA_SHFT     7
-#define SH_LB_ERROR_SUMMARY_RP_BAD_DATA_MASK     0x0000000000000080
-
-/*   SH_LB_ERROR_SUMMARY_RQ_BAD_ADDR                                    */
-/*   Description:  RQ_BAD_ADDR                                          */
-#define SH_LB_ERROR_SUMMARY_RQ_BAD_ADDR_SHFT     8
-#define SH_LB_ERROR_SUMMARY_RQ_BAD_ADDR_MASK     0x0000000000000100
-
-/*   SH_LB_ERROR_SUMMARY_RQ_TIME_OUT                                    */
-/*   Description:  RQ_TIME_OUT                                          */
-#define SH_LB_ERROR_SUMMARY_RQ_TIME_OUT_SHFT     9
-#define SH_LB_ERROR_SUMMARY_RQ_TIME_OUT_MASK     0x0000000000000200
-
-/*   SH_LB_ERROR_SUMMARY_LINVV_OVERFLOW                                 */
-/*   Description:  LINVV_OVERFLOW                                       */
-#define SH_LB_ERROR_SUMMARY_LINVV_OVERFLOW_SHFT  10
-#define SH_LB_ERROR_SUMMARY_LINVV_OVERFLOW_MASK  0x0000000000000400
-
-/*   SH_LB_ERROR_SUMMARY_UNEXPECTED_LINV                                */
-/*   Description:  UNEXPECTED_LINV                                      */
-#define SH_LB_ERROR_SUMMARY_UNEXPECTED_LINV_SHFT 11
-#define SH_LB_ERROR_SUMMARY_UNEXPECTED_LINV_MASK 0x0000000000000800
-
-/*   SH_LB_ERROR_SUMMARY_PTC_1_TIMEOUT                                  */
-/*   Description:  PTC_1 Time out                                       */
-#define SH_LB_ERROR_SUMMARY_PTC_1_TIMEOUT_SHFT   12
-#define SH_LB_ERROR_SUMMARY_PTC_1_TIMEOUT_MASK   0x0000000000001000
-
-/*   SH_LB_ERROR_SUMMARY_JUNK_BUS_ERR                                   */
-/*   Description:  Junk Bus error                                       */
-#define SH_LB_ERROR_SUMMARY_JUNK_BUS_ERR_SHFT    13
-#define SH_LB_ERROR_SUMMARY_JUNK_BUS_ERR_MASK    0x0000000000002000
-
-/*   SH_LB_ERROR_SUMMARY_PIO_CB_ERR                                     */
-/*   Description:  PIO Conveyor Belt operation error                    */
-#define SH_LB_ERROR_SUMMARY_PIO_CB_ERR_SHFT      14
-#define SH_LB_ERROR_SUMMARY_PIO_CB_ERR_MASK      0x0000000000004000
-
-/*   SH_LB_ERROR_SUMMARY_VECTOR_RQ_ROUTE_ERROR                          */
-/*   Description:  Vector request Route data was invalid                */
-#define SH_LB_ERROR_SUMMARY_VECTOR_RQ_ROUTE_ERROR_SHFT 15
-#define SH_LB_ERROR_SUMMARY_VECTOR_RQ_ROUTE_ERROR_MASK 0x0000000000008000
-
-/*   SH_LB_ERROR_SUMMARY_VECTOR_RP_ROUTE_ERROR                          */
-/*   Description:  Vector reply Route data was invalid                  */
-#define SH_LB_ERROR_SUMMARY_VECTOR_RP_ROUTE_ERROR_SHFT 16
-#define SH_LB_ERROR_SUMMARY_VECTOR_RP_ROUTE_ERROR_MASK 0x0000000000010000
-
-/*   SH_LB_ERROR_SUMMARY_GCLK_DROP                                      */
-/*   Description:  Gclk drop error                                      */
-#define SH_LB_ERROR_SUMMARY_GCLK_DROP_SHFT       17
-#define SH_LB_ERROR_SUMMARY_GCLK_DROP_MASK       0x0000000000020000
-
-/*   SH_LB_ERROR_SUMMARY_RQ_FIFO_ERROR                                  */
-/*   Description:  Request queue FIFO error                             */
-#define SH_LB_ERROR_SUMMARY_RQ_FIFO_ERROR_SHFT   18
-#define SH_LB_ERROR_SUMMARY_RQ_FIFO_ERROR_MASK   0x0000000000040000
-
-/*   SH_LB_ERROR_SUMMARY_RP_FIFO_ERROR                                  */
-/*   Description:  Reply queue FIFO error                               */
-#define SH_LB_ERROR_SUMMARY_RP_FIFO_ERROR_SHFT   19
-#define SH_LB_ERROR_SUMMARY_RP_FIFO_ERROR_MASK   0x0000000000080000
-
-/*   SH_LB_ERROR_SUMMARY_UNEXP_VALID                                    */
-/*   Description:  Unexpected valid error                               */
-#define SH_LB_ERROR_SUMMARY_UNEXP_VALID_SHFT     20
-#define SH_LB_ERROR_SUMMARY_UNEXP_VALID_MASK     0x0000000000100000
-
-/*   SH_LB_ERROR_SUMMARY_RQ_CREDIT_OVERFLOW                             */
-/*   Description:  Request queue credit overflow                        */
-#define SH_LB_ERROR_SUMMARY_RQ_CREDIT_OVERFLOW_SHFT 21
-#define SH_LB_ERROR_SUMMARY_RQ_CREDIT_OVERFLOW_MASK 0x0000000000200000
-
-/*   SH_LB_ERROR_SUMMARY_RP_CREDIT_OVERFLOW                             */
-/*   Description:  Reply queue credit overflow                          */
-#define SH_LB_ERROR_SUMMARY_RP_CREDIT_OVERFLOW_SHFT 22
-#define SH_LB_ERROR_SUMMARY_RP_CREDIT_OVERFLOW_MASK 0x0000000000400000
-
-/* ==================================================================== */
-/*                 Register "SH_LB_ERROR_SUMMARY_ALIAS"                 */
-/*                         LB Error Bits Alias                          */
-/* ==================================================================== */
-
-#define SH_LB_ERROR_SUMMARY_ALIAS                0x0000000110050588
-
-/* ==================================================================== */
-/*                     Register "SH_LB_FIRST_ERROR"                     */
-/*                            LB First Error                            */
-/* ==================================================================== */
-
-#define SH_LB_FIRST_ERROR                        0x0000000110050600
-#define SH_LB_FIRST_ERROR_MASK                   0x00000000007fffff
-#define SH_LB_FIRST_ERROR_INIT                   0x0000000000000000
-
-/*   SH_LB_FIRST_ERROR_RQ_BAD_CMD                                       */
-/*   Description:  RQ_BAD_CMD                                           */
-#define SH_LB_FIRST_ERROR_RQ_BAD_CMD_SHFT        0
-#define SH_LB_FIRST_ERROR_RQ_BAD_CMD_MASK        0x0000000000000001
-
-/*   SH_LB_FIRST_ERROR_RP_BAD_CMD                                       */
-/*   Description:  RP_BAD_CMD                                           */
-#define SH_LB_FIRST_ERROR_RP_BAD_CMD_SHFT        1
-#define SH_LB_FIRST_ERROR_RP_BAD_CMD_MASK        0x0000000000000002
-
-/*   SH_LB_FIRST_ERROR_RQ_SHORT                                         */
-/*   Description:  RQ_SHORT                                             */
-#define SH_LB_FIRST_ERROR_RQ_SHORT_SHFT          2
-#define SH_LB_FIRST_ERROR_RQ_SHORT_MASK          0x0000000000000004
-
-/*   SH_LB_FIRST_ERROR_RP_SHORT                                         */
-/*   Description:  RP_SHORT                                             */
-#define SH_LB_FIRST_ERROR_RP_SHORT_SHFT          3
-#define SH_LB_FIRST_ERROR_RP_SHORT_MASK          0x0000000000000008
-
-/*   SH_LB_FIRST_ERROR_RQ_LONG                                          */
-/*   Description:  RQ_LONG                                              */
-#define SH_LB_FIRST_ERROR_RQ_LONG_SHFT           4
-#define SH_LB_FIRST_ERROR_RQ_LONG_MASK           0x0000000000000010
-
-/*   SH_LB_FIRST_ERROR_RP_LONG                                          */
-/*   Description:  RP_LONG                                              */
-#define SH_LB_FIRST_ERROR_RP_LONG_SHFT           5
-#define SH_LB_FIRST_ERROR_RP_LONG_MASK           0x0000000000000020
-
-/*   SH_LB_FIRST_ERROR_RQ_BAD_DATA                                      */
-/*   Description:  RQ_BAD_DATA                                          */
-#define SH_LB_FIRST_ERROR_RQ_BAD_DATA_SHFT       6
-#define SH_LB_FIRST_ERROR_RQ_BAD_DATA_MASK       0x0000000000000040
-
-/*   SH_LB_FIRST_ERROR_RP_BAD_DATA                                      */
-/*   Description:  RP_BAD_DATA                                          */
-#define SH_LB_FIRST_ERROR_RP_BAD_DATA_SHFT       7
-#define SH_LB_FIRST_ERROR_RP_BAD_DATA_MASK       0x0000000000000080
-
-/*   SH_LB_FIRST_ERROR_RQ_BAD_ADDR                                      */
-/*   Description:  RQ_BAD_ADDR                                          */
-#define SH_LB_FIRST_ERROR_RQ_BAD_ADDR_SHFT       8
-#define SH_LB_FIRST_ERROR_RQ_BAD_ADDR_MASK       0x0000000000000100
-
-/*   SH_LB_FIRST_ERROR_RQ_TIME_OUT                                      */
-/*   Description:  RQ_TIME_OUT                                          */
-#define SH_LB_FIRST_ERROR_RQ_TIME_OUT_SHFT       9
-#define SH_LB_FIRST_ERROR_RQ_TIME_OUT_MASK       0x0000000000000200
-
-/*   SH_LB_FIRST_ERROR_LINVV_OVERFLOW                                   */
-/*   Description:  LINVV_OVERFLOW                                       */
-#define SH_LB_FIRST_ERROR_LINVV_OVERFLOW_SHFT    10
-#define SH_LB_FIRST_ERROR_LINVV_OVERFLOW_MASK    0x0000000000000400
-
-/*   SH_LB_FIRST_ERROR_UNEXPECTED_LINV                                  */
-/*   Description:  UNEXPECTED_LINV                                      */
-#define SH_LB_FIRST_ERROR_UNEXPECTED_LINV_SHFT   11
-#define SH_LB_FIRST_ERROR_UNEXPECTED_LINV_MASK   0x0000000000000800
-
-/*   SH_LB_FIRST_ERROR_PTC_1_TIMEOUT                                    */
-/*   Description:  PTC_1 Time out                                       */
-#define SH_LB_FIRST_ERROR_PTC_1_TIMEOUT_SHFT     12
-#define SH_LB_FIRST_ERROR_PTC_1_TIMEOUT_MASK     0x0000000000001000
-
-/*   SH_LB_FIRST_ERROR_JUNK_BUS_ERR                                     */
-/*   Description:  Junk Bus error                                       */
-#define SH_LB_FIRST_ERROR_JUNK_BUS_ERR_SHFT      13
-#define SH_LB_FIRST_ERROR_JUNK_BUS_ERR_MASK      0x0000000000002000
-
-/*   SH_LB_FIRST_ERROR_PIO_CB_ERR                                       */
-/*   Description:  PIO Conveyor Belt operation error                    */
-#define SH_LB_FIRST_ERROR_PIO_CB_ERR_SHFT        14
-#define SH_LB_FIRST_ERROR_PIO_CB_ERR_MASK        0x0000000000004000
-
-/*   SH_LB_FIRST_ERROR_VECTOR_RQ_ROUTE_ERROR                            */
-/*   Description:  Vector request Route data was invalid                */
-#define SH_LB_FIRST_ERROR_VECTOR_RQ_ROUTE_ERROR_SHFT 15
-#define SH_LB_FIRST_ERROR_VECTOR_RQ_ROUTE_ERROR_MASK 0x0000000000008000
-
-/*   SH_LB_FIRST_ERROR_VECTOR_RP_ROUTE_ERROR                            */
-/*   Description:  Vector reply Route data was invalid                  */
-#define SH_LB_FIRST_ERROR_VECTOR_RP_ROUTE_ERROR_SHFT 16
-#define SH_LB_FIRST_ERROR_VECTOR_RP_ROUTE_ERROR_MASK 0x0000000000010000
-
-/*   SH_LB_FIRST_ERROR_GCLK_DROP                                        */
-/*   Description:  Gclk drop error                                      */
-#define SH_LB_FIRST_ERROR_GCLK_DROP_SHFT         17
-#define SH_LB_FIRST_ERROR_GCLK_DROP_MASK         0x0000000000020000
-
-/*   SH_LB_FIRST_ERROR_RQ_FIFO_ERROR                                    */
-/*   Description:  Request queue FIFO error                             */
-#define SH_LB_FIRST_ERROR_RQ_FIFO_ERROR_SHFT     18
-#define SH_LB_FIRST_ERROR_RQ_FIFO_ERROR_MASK     0x0000000000040000
-
-/*   SH_LB_FIRST_ERROR_RP_FIFO_ERROR                                    */
-/*   Description:  Reply queue FIFO error                               */
-#define SH_LB_FIRST_ERROR_RP_FIFO_ERROR_SHFT     19
-#define SH_LB_FIRST_ERROR_RP_FIFO_ERROR_MASK     0x0000000000080000
-
-/*   SH_LB_FIRST_ERROR_UNEXP_VALID                                      */
-/*   Description:  Unexpected valid error                               */
-#define SH_LB_FIRST_ERROR_UNEXP_VALID_SHFT       20
-#define SH_LB_FIRST_ERROR_UNEXP_VALID_MASK       0x0000000000100000
-
-/*   SH_LB_FIRST_ERROR_RQ_CREDIT_OVERFLOW                               */
-/*   Description:  Request queue credit overflow                        */
-#define SH_LB_FIRST_ERROR_RQ_CREDIT_OVERFLOW_SHFT 21
-#define SH_LB_FIRST_ERROR_RQ_CREDIT_OVERFLOW_MASK 0x0000000000200000
-
-/*   SH_LB_FIRST_ERROR_RP_CREDIT_OVERFLOW                               */
-/*   Description:  Reply queue credit overflow                          */
-#define SH_LB_FIRST_ERROR_RP_CREDIT_OVERFLOW_SHFT 22
-#define SH_LB_FIRST_ERROR_RP_CREDIT_OVERFLOW_MASK 0x0000000000400000
-
-/* ==================================================================== */
-/*                     Register "SH_LB_LAST_CREDIT"                     */
-/*                    Credit counter status register                    */
-/* ==================================================================== */
-
-#define SH_LB_LAST_CREDIT                        0x0000000110050680
-#define SH_LB_LAST_CREDIT_MASK                   0x000000000ffff3df
-#define SH_LB_LAST_CREDIT_INIT                   0x0000000000000000
-
-/*   SH_LB_LAST_CREDIT_LIQ_RQ_CREDIT                                    */
-/*   Description:  LIQ request queue credit counter                     */
-#define SH_LB_LAST_CREDIT_LIQ_RQ_CREDIT_SHFT     0
-#define SH_LB_LAST_CREDIT_LIQ_RQ_CREDIT_MASK     0x000000000000001f
-
-/*   SH_LB_LAST_CREDIT_LIQ_RP_CREDIT                                    */
-/*   Description:  LIQ reply queue credit counter                       */
-#define SH_LB_LAST_CREDIT_LIQ_RP_CREDIT_SHFT     6
-#define SH_LB_LAST_CREDIT_LIQ_RP_CREDIT_MASK     0x00000000000003c0
-
-/*   SH_LB_LAST_CREDIT_LINVV_CREDIT                                     */
-/*   Description:  LINVV credit counter                                 */
-#define SH_LB_LAST_CREDIT_LINVV_CREDIT_SHFT      12
-#define SH_LB_LAST_CREDIT_LINVV_CREDIT_MASK      0x000000000003f000
-
-/*   SH_LB_LAST_CREDIT_LOQ_RQ_CREDIT                                    */
-/*   Description:  LOQ request queue credit counter                     */
-#define SH_LB_LAST_CREDIT_LOQ_RQ_CREDIT_SHFT     18
-#define SH_LB_LAST_CREDIT_LOQ_RQ_CREDIT_MASK     0x00000000007c0000
-
-/*   SH_LB_LAST_CREDIT_LOQ_RP_CREDIT                                    */
-/*   Description:  LOQ reply queue credit counter                       */
-#define SH_LB_LAST_CREDIT_LOQ_RP_CREDIT_SHFT     23
-#define SH_LB_LAST_CREDIT_LOQ_RP_CREDIT_MASK     0x000000000f800000
-
-/* ==================================================================== */
-/*                     Register "SH_LB_NACK_STATUS"                     */
-/*                     Nack Counter Status Register                     */
-/* ==================================================================== */
-
-#define SH_LB_NACK_STATUS                        0x0000000110050700
-#define SH_LB_NACK_STATUS_MASK                   0x3fffffff0fff0fff
-#define SH_LB_NACK_STATUS_INIT                   0x0000000000000000
-
-/*   SH_LB_NACK_STATUS_PIO_NACK_A                                       */
-/*   Description:  PIO nackA counter                                    */
-#define SH_LB_NACK_STATUS_PIO_NACK_A_SHFT        0
-#define SH_LB_NACK_STATUS_PIO_NACK_A_MASK        0x0000000000000fff
-
-/*   SH_LB_NACK_STATUS_PIO_NACK_B                                       */
-/*   Description:  PIO nackA counter                                    */
-#define SH_LB_NACK_STATUS_PIO_NACK_B_SHFT        16
-#define SH_LB_NACK_STATUS_PIO_NACK_B_MASK        0x000000000fff0000
-
-/*   SH_LB_NACK_STATUS_JUNK_NACK                                        */
-/*   Description:  Junk bus nack counter                                */
-#define SH_LB_NACK_STATUS_JUNK_NACK_SHFT         32
-#define SH_LB_NACK_STATUS_JUNK_NACK_MASK         0x0000ffff00000000
-
-/*   SH_LB_NACK_STATUS_CB_TIMEOUT_COUNT                                 */
-/*   Description:  Conveyor belt time out counter                       */
-#define SH_LB_NACK_STATUS_CB_TIMEOUT_COUNT_SHFT  48
-#define SH_LB_NACK_STATUS_CB_TIMEOUT_COUNT_MASK  0x0fff000000000000
-
-/*   SH_LB_NACK_STATUS_CB_STATE                                         */
-/*   Description:  Conveyor belt state                                  */
-#define SH_LB_NACK_STATUS_CB_STATE_SHFT          60
-#define SH_LB_NACK_STATUS_CB_STATE_MASK          0x3000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_LB_TRIGGER_COMPARE"                   */
-/*                    LB Test-point Trigger Compare                     */
-/* ==================================================================== */
-
-#define SH_LB_TRIGGER_COMPARE                    0x0000000110050780
-#define SH_LB_TRIGGER_COMPARE_MASK               0x00000000ffffffff
-#define SH_LB_TRIGGER_COMPARE_INIT               0x0000000000000000
-
-/*   SH_LB_TRIGGER_COMPARE_MASK                                         */
-/*   Description:  Mask to select Debug bits for trigger generation     */
-#define SH_LB_TRIGGER_COMPARE_MASK_SHFT          0
-#define SH_LB_TRIGGER_COMPARE_MASK_MASK          0x00000000ffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_LB_TRIGGER_DATA"                     */
-/*                  LB Test-point Trigger Compare Data                  */
-/* ==================================================================== */
-
-#define SH_LB_TRIGGER_DATA                       0x0000000110050800
-#define SH_LB_TRIGGER_DATA_MASK                  0x00000000ffffffff
-#define SH_LB_TRIGGER_DATA_INIT                  0x00000000ffffffff
-
-/*   SH_LB_TRIGGER_DATA_COMPARE_PATTERN                                 */
-/*   Description:  debug bit pattern for trigger generation             */
-#define SH_LB_TRIGGER_DATA_COMPARE_PATTERN_SHFT  0
-#define SH_LB_TRIGGER_DATA_COMPARE_PATTERN_MASK  0x00000000ffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_PI_AEC_CONFIG"                      */
-/*              PI Adaptive Error Correction Configuration              */
-/* ==================================================================== */
-
-#define SH_PI_AEC_CONFIG                         0x0000000120050000
-#define SH_PI_AEC_CONFIG_MASK                    0x0000000000000007
-#define SH_PI_AEC_CONFIG_INIT                    0x0000000000000000
-
-/*   SH_PI_AEC_CONFIG_MODE                                              */
-/*   Description:  AEC Operation Mode                                   */
-#define SH_PI_AEC_CONFIG_MODE_SHFT               0
-#define SH_PI_AEC_CONFIG_MODE_MASK               0x0000000000000007
-
-/* ==================================================================== */
-/*                   Register "SH_PI_AFI_ERROR_MASK"                    */
-/*                          PI AFI Error Mask                           */
-/* ==================================================================== */
-
-#define SH_PI_AFI_ERROR_MASK                     0x0000000120050080
-#define SH_PI_AFI_ERROR_MASK_MASK                0x00000007ffe00000
-#define SH_PI_AFI_ERROR_MASK_INIT                0x00000007ffe00000
-
-/*   SH_PI_AFI_ERROR_MASK_HUNG_BUS                                      */
-/*   Description:  FSB is hung                                          */
-#define SH_PI_AFI_ERROR_MASK_HUNG_BUS_SHFT       21
-#define SH_PI_AFI_ERROR_MASK_HUNG_BUS_MASK       0x0000000000200000
-
-/*   SH_PI_AFI_ERROR_MASK_RSP_PARITY                                    */
-/*   Description:  Parity error detecte during response phase           */
-#define SH_PI_AFI_ERROR_MASK_RSP_PARITY_SHFT     22
-#define SH_PI_AFI_ERROR_MASK_RSP_PARITY_MASK     0x0000000000400000
-
-/*   SH_PI_AFI_ERROR_MASK_IOQ_OVERRUN                                   */
-/*   Description:  Over run error detected on IOQ                       */
-#define SH_PI_AFI_ERROR_MASK_IOQ_OVERRUN_SHFT    23
-#define SH_PI_AFI_ERROR_MASK_IOQ_OVERRUN_MASK    0x0000000000800000
-
-/*   SH_PI_AFI_ERROR_MASK_REQ_FORMAT                                    */
-/*   Description:  FSB request format not supported                     */
-#define SH_PI_AFI_ERROR_MASK_REQ_FORMAT_SHFT     24
-#define SH_PI_AFI_ERROR_MASK_REQ_FORMAT_MASK     0x0000000001000000
-
-/*   SH_PI_AFI_ERROR_MASK_ADDR_ACCESS                                   */
-/*   Description:  Access to Address is not supported                   */
-#define SH_PI_AFI_ERROR_MASK_ADDR_ACCESS_SHFT    25
-#define SH_PI_AFI_ERROR_MASK_ADDR_ACCESS_MASK    0x0000000002000000
-
-/*   SH_PI_AFI_ERROR_MASK_REQ_PARITY                                    */
-/*   Description:  Parity error detected during request phase           */
-#define SH_PI_AFI_ERROR_MASK_REQ_PARITY_SHFT     26
-#define SH_PI_AFI_ERROR_MASK_REQ_PARITY_MASK     0x0000000004000000
-
-/*   SH_PI_AFI_ERROR_MASK_ADDR_PARITY                                   */
-/*   Description:  Parity error detected on address                     */
-#define SH_PI_AFI_ERROR_MASK_ADDR_PARITY_SHFT    27
-#define SH_PI_AFI_ERROR_MASK_ADDR_PARITY_MASK    0x0000000008000000
-
-/*   SH_PI_AFI_ERROR_MASK_SHUB_FSB_DQE                                  */
-/*   Description:  SHUB_FSB_DQE                                         */
-#define SH_PI_AFI_ERROR_MASK_SHUB_FSB_DQE_SHFT   28
-#define SH_PI_AFI_ERROR_MASK_SHUB_FSB_DQE_MASK   0x0000000010000000
-
-/*   SH_PI_AFI_ERROR_MASK_SHUB_FSB_UCE                                  */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_AFI_ERROR_MASK_SHUB_FSB_UCE_SHFT   29
-#define SH_PI_AFI_ERROR_MASK_SHUB_FSB_UCE_MASK   0x0000000020000000
-
-/*   SH_PI_AFI_ERROR_MASK_SHUB_FSB_CE                                   */
-/*   Description:  An correctable ECC error was detected                */
-#define SH_PI_AFI_ERROR_MASK_SHUB_FSB_CE_SHFT    30
-#define SH_PI_AFI_ERROR_MASK_SHUB_FSB_CE_MASK    0x0000000040000000
-
-/*   SH_PI_AFI_ERROR_MASK_LIVELOCK                                      */
-/*   Description:  AFI livelock error was detected                      */
-#define SH_PI_AFI_ERROR_MASK_LIVELOCK_SHFT       31
-#define SH_PI_AFI_ERROR_MASK_LIVELOCK_MASK       0x0000000080000000
-
-/*   SH_PI_AFI_ERROR_MASK_BAD_SNOOP                                     */
-/*   Description:  AFI bad snoop error was detected                     */
-#define SH_PI_AFI_ERROR_MASK_BAD_SNOOP_SHFT      32
-#define SH_PI_AFI_ERROR_MASK_BAD_SNOOP_MASK      0x0000000100000000
-
-/*   SH_PI_AFI_ERROR_MASK_FSB_TBL_MISS                                  */
-/*   Description:  AFI FSB request table miss error was detected        */
-#define SH_PI_AFI_ERROR_MASK_FSB_TBL_MISS_SHFT   33
-#define SH_PI_AFI_ERROR_MASK_FSB_TBL_MISS_MASK   0x0000000200000000
-
-/*   SH_PI_AFI_ERROR_MASK_MSG_LEN                                       */
-/*   Description:  Runt or Obese message received from SIC              */
-#define SH_PI_AFI_ERROR_MASK_MSG_LEN_SHFT        34
-#define SH_PI_AFI_ERROR_MASK_MSG_LEN_MASK        0x0000000400000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_AFI_TEST_POINT_COMPARE"                */
-/*                      PI AFI Test Point Compare                       */
-/* ==================================================================== */
-
-#define SH_PI_AFI_TEST_POINT_COMPARE             0x0000000120050100
-#define SH_PI_AFI_TEST_POINT_COMPARE_MASK        0xffffffffffffffff
-#define SH_PI_AFI_TEST_POINT_COMPARE_INIT        0xffffffff00000000
-
-/*   SH_PI_AFI_TEST_POINT_COMPARE_COMPARE_MASK                          */
-/*   Description:  Mask to select Debug bits for trigger generation     */
-#define SH_PI_AFI_TEST_POINT_COMPARE_COMPARE_MASK_SHFT 0
-#define SH_PI_AFI_TEST_POINT_COMPARE_COMPARE_MASK_MASK 0x00000000ffffffff
-
-/*   SH_PI_AFI_TEST_POINT_COMPARE_COMPARE_PATTERN                       */
-/*   Description:  debug bit pattern for trigger generation             */
-#define SH_PI_AFI_TEST_POINT_COMPARE_COMPARE_PATTERN_SHFT 32
-#define SH_PI_AFI_TEST_POINT_COMPARE_COMPARE_PATTERN_MASK 0xffffffff00000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_AFI_TEST_POINT_SELECT"                */
-/*                       PI AFI Test Point Select                       */
-/* ==================================================================== */
-
-#define SH_PI_AFI_TEST_POINT_SELECT              0x0000000120050180
-#define SH_PI_AFI_TEST_POINT_SELECT_MASK         0xff7f7f7f7f7f7f7f
-#define SH_PI_AFI_TEST_POINT_SELECT_INIT         0x0000000000000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL                    */
-/*   Description:  Nibble 0: Word Select                                */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL_SHFT 0
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL_MASK 0x000000000000000f
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL                     */
-/*   Description:  Nibble 0: Nibble Select                              */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL                    */
-/*   Description:  Nibble 1: Word Select                                */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL_SHFT 8
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL_MASK 0x0000000000000f00
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL                     */
-/*   Description:  Nibble 1: Nibble Select                              */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL                    */
-/*   Description:  Nibble 2: Word Select                                */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL_SHFT 16
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL_MASK 0x00000000000f0000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL                     */
-/*   Description:  Nibble 2: Nibble Select                              */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL                    */
-/*   Description:  Nibble 3: Word Select                                */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL_SHFT 24
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL_MASK 0x000000000f000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL                     */
-/*   Description:  Nibble 3: Nibble Select                              */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL                    */
-/*   Description:  Nibble 4: Word Select                                */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL_SHFT 32
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL_MASK 0x0000000f00000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL                     */
-/*   Description:  Nibble 4: Nibble Select                              */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL                    */
-/*   Description:  Nibble 5: Word Select                                */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL_SHFT 40
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL_MASK 0x00000f0000000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL                     */
-/*   Description:  Nibble 5: Nibble Select                              */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL                    */
-/*   Description:  Nibble 6: Word Select                                */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL_SHFT 48
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL_MASK 0x000f000000000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL                     */
-/*   Description:  Nibble 6: Nibble Select                              */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL                    */
-/*   Description:  Nibble 7: Word Select                                */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL_SHFT 56
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL_MASK 0x0f00000000000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL                     */
-/*   Description:  Nibble 7: Nibble Select                              */
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_PI_AFI_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/*   SH_PI_AFI_TEST_POINT_SELECT_TRIGGER_ENABLE                         */
-/*   Description:  Trigger Enabled                                      */
-#define SH_PI_AFI_TEST_POINT_SELECT_TRIGGER_ENABLE_SHFT 63
-#define SH_PI_AFI_TEST_POINT_SELECT_TRIGGER_ENABLE_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*            Register "SH_PI_AFI_TEST_POINT_TRIGGER_SELECT"            */
-/*                  PI CRBC Test Point Trigger Select                   */
-/* ==================================================================== */
-
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT      0x0000000120050200
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_MASK 0x7f7f7f7f7f7f7f7f
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_INIT 0x0000000000000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL           */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL_SHFT 0
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL_MASK 0x000000000000000f
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL            */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL_SHFT 4
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL           */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL_SHFT 8
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL_MASK 0x0000000000000f00
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL            */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL_SHFT 12
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL           */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL_SHFT 16
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL_MASK 0x00000000000f0000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL            */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL_SHFT 20
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL           */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL_SHFT 24
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL_MASK 0x000000000f000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL            */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL_SHFT 28
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL           */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL_SHFT 32
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL_MASK 0x0000000f00000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL            */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL_SHFT 36
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL           */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL_SHFT 40
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL_MASK 0x00000f0000000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL            */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL_SHFT 44
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL           */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL_SHFT 48
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL_MASK 0x000f000000000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL            */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL_SHFT 52
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL           */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL_SHFT 56
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL_MASK 0x0f00000000000000
-
-/*   SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL            */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL_SHFT 60
-#define SH_PI_AFI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PI_AUTO_REPLY_ENABLE"                  */
-/*                         PI Auto Reply Enable                         */
-/* ==================================================================== */
-
-#define SH_PI_AUTO_REPLY_ENABLE                  0x0000000120050280
-#define SH_PI_AUTO_REPLY_ENABLE_MASK             0x0000000000000001
-#define SH_PI_AUTO_REPLY_ENABLE_INIT             0x0000000000000000
-
-/*   SH_PI_AUTO_REPLY_ENABLE_AUTO_REPLY_ENABLE                          */
-/*   Description:  Auto Reply Enabled                                   */
-#define SH_PI_AUTO_REPLY_ENABLE_AUTO_REPLY_ENABLE_SHFT 0
-#define SH_PI_AUTO_REPLY_ENABLE_AUTO_REPLY_ENABLE_MASK 0x0000000000000001
-
-/* ==================================================================== */
-/*                     Register "SH_PI_CAM_CONTROL"                     */
-/*                      CRB CAM MMR Access Control                      */
-/* ==================================================================== */
-
-#define SH_PI_CAM_CONTROL                        0x0000000120050300
-#define SH_PI_CAM_CONTROL_MASK                   0x800000000000037f
-#define SH_PI_CAM_CONTROL_INIT                   0x0000000000000000
-
-/*   SH_PI_CAM_CONTROL_CAM_INDX                                         */
-/*   Description:  CRB CAM Index to perform read/write on.              */
-#define SH_PI_CAM_CONTROL_CAM_INDX_SHFT          0
-#define SH_PI_CAM_CONTROL_CAM_INDX_MASK          0x000000000000007f
-
-/*   SH_PI_CAM_CONTROL_CAM_WRITE                                        */
-/*   Description:  Is CRB CAM MMR function a write.                     */
-#define SH_PI_CAM_CONTROL_CAM_WRITE_SHFT         8
-#define SH_PI_CAM_CONTROL_CAM_WRITE_MASK         0x0000000000000100
-
-/*   SH_PI_CAM_CONTROL_RRB_RD_XFER_CLEAR                                */
-/*   Description:  Clear RRB read tranfer pending.                      */
-#define SH_PI_CAM_CONTROL_RRB_RD_XFER_CLEAR_SHFT 9
-#define SH_PI_CAM_CONTROL_RRB_RD_XFER_CLEAR_MASK 0x0000000000000200
-
-/*   SH_PI_CAM_CONTROL_START                                            */
-/*   Description:  Start CRB CAM read/write operation                   */
-#define SH_PI_CAM_CONTROL_START_SHFT             63
-#define SH_PI_CAM_CONTROL_START_MASK             0x8000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBC_TEST_POINT_COMPARE"               */
-/*                      PI CRBC Test Point Compare                      */
-/* ==================================================================== */
-
-#define SH_PI_CRBC_TEST_POINT_COMPARE            0x0000000120050380
-#define SH_PI_CRBC_TEST_POINT_COMPARE_MASK       0xffffffffffffffff
-#define SH_PI_CRBC_TEST_POINT_COMPARE_INIT       0xffffffff00000000
-
-/*   SH_PI_CRBC_TEST_POINT_COMPARE_COMPARE_MASK                         */
-/*   Description:  Mask to select Debug bits for trigger generation     */
-#define SH_PI_CRBC_TEST_POINT_COMPARE_COMPARE_MASK_SHFT 0
-#define SH_PI_CRBC_TEST_POINT_COMPARE_COMPARE_MASK_MASK 0x00000000ffffffff
-
-/*   SH_PI_CRBC_TEST_POINT_COMPARE_COMPARE_PATTERN                      */
-/*   Description:  debug bit pattern for trigger generation             */
-#define SH_PI_CRBC_TEST_POINT_COMPARE_COMPARE_PATTERN_SHFT 32
-#define SH_PI_CRBC_TEST_POINT_COMPARE_COMPARE_PATTERN_MASK 0xffffffff00000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBC_TEST_POINT_SELECT"                */
-/*                      PI CRBC Test Point Select                       */
-/* ==================================================================== */
-
-#define SH_PI_CRBC_TEST_POINT_SELECT             0x0000000120050400
-#define SH_PI_CRBC_TEST_POINT_SELECT_MASK        0xf777777777777777
-#define SH_PI_CRBC_TEST_POINT_SELECT_INIT        0x0000000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL                   */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL_SHFT 0
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL                    */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL                   */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL_SHFT 8
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL                    */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL                   */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL_SHFT 16
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL                    */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL                   */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL_SHFT 24
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL                    */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL                   */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL_SHFT 32
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL                    */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL                   */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL_SHFT 40
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL                    */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL                   */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL_SHFT 48
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL                    */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL                   */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL_SHFT 56
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL                    */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_PI_CRBC_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_SELECT_TRIGGER_ENABLE                        */
-/*   Description:  Enable trigger on bit 32 of Analyzer data            */
-#define SH_PI_CRBC_TEST_POINT_SELECT_TRIGGER_ENABLE_SHFT 63
-#define SH_PI_CRBC_TEST_POINT_SELECT_TRIGGER_ENABLE_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*           Register "SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT"            */
-/*                  PI CRBC Test Point Trigger Select                   */
-/* ==================================================================== */
-
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT     0x0000000120050480
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_MASK 0x7777777777777777
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_INIT 0x0000000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL          */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL_SHFT 0
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL           */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL_SHFT 4
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL          */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL_SHFT 8
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL           */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL_SHFT 12
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL          */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL_SHFT 16
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL           */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL_SHFT 20
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL          */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL_SHFT 24
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL           */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL_SHFT 28
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL          */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL_SHFT 32
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL           */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL_SHFT 36
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL          */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL_SHFT 40
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL           */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL_SHFT 44
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL          */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL_SHFT 48
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL           */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL_SHFT 52
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL          */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL_SHFT 56
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL           */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL_SHFT 60
-#define SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_PI_CRBP_ERROR_MASK"                   */
-/*                          PI CRBP Error Mask                          */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_ERROR_MASK                    0x0000000120050500
-#define SH_PI_CRBP_ERROR_MASK_MASK               0x00000000001fffff
-#define SH_PI_CRBP_ERROR_MASK_INIT               0x00000000001fffff
-
-/*   SH_PI_CRBP_ERROR_MASK_FSB_PROTO_ERR                                */
-/*   Description:  Mask detection internal protocol table misses        */
-#define SH_PI_CRBP_ERROR_MASK_FSB_PROTO_ERR_SHFT 0
-#define SH_PI_CRBP_ERROR_MASK_FSB_PROTO_ERR_MASK 0x0000000000000001
-
-/*   SH_PI_CRBP_ERROR_MASK_GFX_RP_ERR                                   */
-/*   Description:  Mask graphic reply error detection                   */
-#define SH_PI_CRBP_ERROR_MASK_GFX_RP_ERR_SHFT    1
-#define SH_PI_CRBP_ERROR_MASK_GFX_RP_ERR_MASK    0x0000000000000002
-
-/*   SH_PI_CRBP_ERROR_MASK_XB_PROTO_ERR                                 */
-/*   Description:  Mask detection of external protocol table misses     */
-#define SH_PI_CRBP_ERROR_MASK_XB_PROTO_ERR_SHFT  2
-#define SH_PI_CRBP_ERROR_MASK_XB_PROTO_ERR_MASK  0x0000000000000004
-
-/*   SH_PI_CRBP_ERROR_MASK_MEM_RP_ERR                                   */
-/*   Description:  Mask memory error reply message detection            */
-#define SH_PI_CRBP_ERROR_MASK_MEM_RP_ERR_SHFT    3
-#define SH_PI_CRBP_ERROR_MASK_MEM_RP_ERR_MASK    0x0000000000000008
-
-/*   SH_PI_CRBP_ERROR_MASK_PIO_RP_ERR                                   */
-/*   Description:  Mask PIO reply error message detection               */
-#define SH_PI_CRBP_ERROR_MASK_PIO_RP_ERR_SHFT    4
-#define SH_PI_CRBP_ERROR_MASK_PIO_RP_ERR_MASK    0x0000000000000010
-
-/*   SH_PI_CRBP_ERROR_MASK_MEM_TO_ERR                                   */
-/*   Description:  Mask memory time-out detection                       */
-#define SH_PI_CRBP_ERROR_MASK_MEM_TO_ERR_SHFT    5
-#define SH_PI_CRBP_ERROR_MASK_MEM_TO_ERR_MASK    0x0000000000000020
-
-/*   SH_PI_CRBP_ERROR_MASK_PIO_TO_ERR                                   */
-/*   Description:  Mask PIO time-out detection                          */
-#define SH_PI_CRBP_ERROR_MASK_PIO_TO_ERR_SHFT    6
-#define SH_PI_CRBP_ERROR_MASK_PIO_TO_ERR_MASK    0x0000000000000040
-
-/*   SH_PI_CRBP_ERROR_MASK_FSB_SHUB_UCE                                 */
-/*   Description:  Mask un-correctable ECC error detection              */
-#define SH_PI_CRBP_ERROR_MASK_FSB_SHUB_UCE_SHFT  7
-#define SH_PI_CRBP_ERROR_MASK_FSB_SHUB_UCE_MASK  0x0000000000000080
-
-/*   SH_PI_CRBP_ERROR_MASK_FSB_SHUB_CE                                  */
-/*   Description:  Mask correctable ECC error detection                 */
-#define SH_PI_CRBP_ERROR_MASK_FSB_SHUB_CE_SHFT   8
-#define SH_PI_CRBP_ERROR_MASK_FSB_SHUB_CE_MASK   0x0000000000000100
-
-/*   SH_PI_CRBP_ERROR_MASK_MSG_COLOR_ERR                                */
-/*   Description:  Mask detection of color errors                       */
-#define SH_PI_CRBP_ERROR_MASK_MSG_COLOR_ERR_SHFT 9
-#define SH_PI_CRBP_ERROR_MASK_MSG_COLOR_ERR_MASK 0x0000000000000200
-
-/*   SH_PI_CRBP_ERROR_MASK_MD_RQ_Q_OFLOW                                */
-/*   Description:  Mask MD Request input buffer over flow error         */
-#define SH_PI_CRBP_ERROR_MASK_MD_RQ_Q_OFLOW_SHFT 10
-#define SH_PI_CRBP_ERROR_MASK_MD_RQ_Q_OFLOW_MASK 0x0000000000000400
-
-/*   SH_PI_CRBP_ERROR_MASK_MD_RP_Q_OFLOW                                */
-/*   Description:  Mask MD Reply input buffer over flow error           */
-#define SH_PI_CRBP_ERROR_MASK_MD_RP_Q_OFLOW_SHFT 11
-#define SH_PI_CRBP_ERROR_MASK_MD_RP_Q_OFLOW_MASK 0x0000000000000800
-
-/*   SH_PI_CRBP_ERROR_MASK_XN_RQ_Q_OFLOW                                */
-/*   Description:  Mask XN Request input buffer over flow error         */
-#define SH_PI_CRBP_ERROR_MASK_XN_RQ_Q_OFLOW_SHFT 12
-#define SH_PI_CRBP_ERROR_MASK_XN_RQ_Q_OFLOW_MASK 0x0000000000001000
-
-/*   SH_PI_CRBP_ERROR_MASK_XN_RP_Q_OFLOW                                */
-/*   Description:  Mask XN Reply input buffer over flow error           */
-#define SH_PI_CRBP_ERROR_MASK_XN_RP_Q_OFLOW_SHFT 13
-#define SH_PI_CRBP_ERROR_MASK_XN_RP_Q_OFLOW_MASK 0x0000000000002000
-
-/*   SH_PI_CRBP_ERROR_MASK_NACK_OFLOW                                   */
-/*   Description:  Mask NACK over flow error                            */
-#define SH_PI_CRBP_ERROR_MASK_NACK_OFLOW_SHFT    14
-#define SH_PI_CRBP_ERROR_MASK_NACK_OFLOW_MASK    0x0000000000004000
-
-/*   SH_PI_CRBP_ERROR_MASK_GFX_INT_0                                    */
-/*   Description:  Mask GFX transfer interrupt for CPU 0                */
-#define SH_PI_CRBP_ERROR_MASK_GFX_INT_0_SHFT     15
-#define SH_PI_CRBP_ERROR_MASK_GFX_INT_0_MASK     0x0000000000008000
-
-/*   SH_PI_CRBP_ERROR_MASK_GFX_INT_1                                    */
-/*   Description:  Mask GFX transfer interrupt for CPU 1                */
-#define SH_PI_CRBP_ERROR_MASK_GFX_INT_1_SHFT     16
-#define SH_PI_CRBP_ERROR_MASK_GFX_INT_1_MASK     0x0000000000010000
-
-/*   SH_PI_CRBP_ERROR_MASK_MD_RQ_CRD_OFLOW                              */
-/*   Description:  Mask MD Request Credit Overflow Error                */
-#define SH_PI_CRBP_ERROR_MASK_MD_RQ_CRD_OFLOW_SHFT 17
-#define SH_PI_CRBP_ERROR_MASK_MD_RQ_CRD_OFLOW_MASK 0x0000000000020000
-
-/*   SH_PI_CRBP_ERROR_MASK_MD_RP_CRD_OFLOW                              */
-/*   Description:  Mask MD Reply Credit Overflow Error                  */
-#define SH_PI_CRBP_ERROR_MASK_MD_RP_CRD_OFLOW_SHFT 18
-#define SH_PI_CRBP_ERROR_MASK_MD_RP_CRD_OFLOW_MASK 0x0000000000040000
-
-/*   SH_PI_CRBP_ERROR_MASK_XN_RQ_CRD_OFLOW                              */
-/*   Description:  Mask XN Request Credit Overflow Error                */
-#define SH_PI_CRBP_ERROR_MASK_XN_RQ_CRD_OFLOW_SHFT 19
-#define SH_PI_CRBP_ERROR_MASK_XN_RQ_CRD_OFLOW_MASK 0x0000000000080000
-
-/*   SH_PI_CRBP_ERROR_MASK_XN_RP_CRD_OFLOW                              */
-/*   Description:  Mask XN Reply Credit Overflow Error                  */
-#define SH_PI_CRBP_ERROR_MASK_XN_RP_CRD_OFLOW_SHFT 20
-#define SH_PI_CRBP_ERROR_MASK_XN_RP_CRD_OFLOW_MASK 0x0000000000100000
-
-/* ==================================================================== */
-/*                Register "SH_PI_CRBP_FSB_PIPE_COMPARE"                */
-/*                        CRBP FSB Pipe Compare                         */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_FSB_PIPE_COMPARE              0x0000000120050580
-#define SH_PI_CRBP_FSB_PIPE_COMPARE_MASK         0x001fffffffffffff
-#define SH_PI_CRBP_FSB_PIPE_COMPARE_INIT         0x0000000000000000
-
-/*   SH_PI_CRBP_FSB_PIPE_COMPARE_COMPARE_ADDRESS                        */
-/*   Description:  Address A or B to compare against                    */
-#define SH_PI_CRBP_FSB_PIPE_COMPARE_COMPARE_ADDRESS_SHFT 0
-#define SH_PI_CRBP_FSB_PIPE_COMPARE_COMPARE_ADDRESS_MASK 0x00007fffffffffff
-
-/*   SH_PI_CRBP_FSB_PIPE_COMPARE_COMPARE_REQ                            */
-/*   Description:  REQa or REQb value to compare against                */
-#define SH_PI_CRBP_FSB_PIPE_COMPARE_COMPARE_REQ_SHFT 47
-#define SH_PI_CRBP_FSB_PIPE_COMPARE_COMPARE_REQ_MASK 0x001f800000000000
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CRBP_FSB_PIPE_MASK"                  */
-/*                          CRBP Compare Mask                           */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_FSB_PIPE_MASK                 0x0000000120050600
-#define SH_PI_CRBP_FSB_PIPE_MASK_MASK            0x001fffffffffffff
-#define SH_PI_CRBP_FSB_PIPE_MASK_INIT            0x0000000000000000
-
-/*   SH_PI_CRBP_FSB_PIPE_MASK_COMPARE_ADDRESS_MASK                      */
-/*   Description:  Address A or B mask values                           */
-#define SH_PI_CRBP_FSB_PIPE_MASK_COMPARE_ADDRESS_MASK_SHFT 0
-#define SH_PI_CRBP_FSB_PIPE_MASK_COMPARE_ADDRESS_MASK_MASK 0x00007fffffffffff
-
-/*   SH_PI_CRBP_FSB_PIPE_MASK_COMPARE_REQ_MASK                          */
-/*   Description:  REQa or REQb mask values                             */
-#define SH_PI_CRBP_FSB_PIPE_MASK_COMPARE_REQ_MASK_SHFT 47
-#define SH_PI_CRBP_FSB_PIPE_MASK_COMPARE_REQ_MASK_MASK 0x001f800000000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBP_TEST_POINT_COMPARE"               */
-/*                      PI CRBP Test Point Compare                      */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_TEST_POINT_COMPARE            0x0000000120050680
-#define SH_PI_CRBP_TEST_POINT_COMPARE_MASK       0xffffffffffffffff
-#define SH_PI_CRBP_TEST_POINT_COMPARE_INIT       0xffffffff00000000
-
-/*   SH_PI_CRBP_TEST_POINT_COMPARE_COMPARE_MASK                         */
-/*   Description:  Mask to select Debug bits for trigger generation     */
-#define SH_PI_CRBP_TEST_POINT_COMPARE_COMPARE_MASK_SHFT 0
-#define SH_PI_CRBP_TEST_POINT_COMPARE_COMPARE_MASK_MASK 0x00000000ffffffff
-
-/*   SH_PI_CRBP_TEST_POINT_COMPARE_COMPARE_PATTERN                      */
-/*   Description:  debug bit pattern for trigger generation             */
-#define SH_PI_CRBP_TEST_POINT_COMPARE_COMPARE_PATTERN_SHFT 32
-#define SH_PI_CRBP_TEST_POINT_COMPARE_COMPARE_PATTERN_MASK 0xffffffff00000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBP_TEST_POINT_SELECT"                */
-/*                      PI CRBP Test Point Select                       */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_TEST_POINT_SELECT             0x0000000120050700
-#define SH_PI_CRBP_TEST_POINT_SELECT_MASK        0xf777777777777777
-#define SH_PI_CRBP_TEST_POINT_SELECT_INIT        0x0000000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL                   */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL_SHFT 0
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL                    */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL                   */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL_SHFT 8
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL                    */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL                   */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL_SHFT 16
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL                    */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL                   */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL_SHFT 24
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL                    */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL                   */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL_SHFT 32
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL                    */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL                   */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL_SHFT 40
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL                    */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL                   */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL_SHFT 48
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL                    */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL                   */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL_SHFT 56
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL                    */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_PI_CRBP_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_SELECT_TRIGGER_ENABLE                        */
-/*   Description:  Enable trigger on bit 32 of Analyzer data            */
-#define SH_PI_CRBP_TEST_POINT_SELECT_TRIGGER_ENABLE_SHFT 63
-#define SH_PI_CRBP_TEST_POINT_SELECT_TRIGGER_ENABLE_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*           Register "SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT"            */
-/*                  PI CRBP Test Point Trigger Select                   */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT     0x0000000120050780
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_MASK 0x7777777777777777
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_INIT 0x0000000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL          */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL_SHFT 0
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL           */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL_SHFT 4
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL          */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL_SHFT 8
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL           */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL_SHFT 12
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL          */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL_SHFT 16
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL           */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL_SHFT 20
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL          */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL_SHFT 24
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL           */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL_SHFT 28
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL          */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL_SHFT 32
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL           */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL_SHFT 36
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL          */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL_SHFT 40
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL           */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL_SHFT 44
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL          */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL_SHFT 48
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL           */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL_SHFT 52
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL          */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL_SHFT 56
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL           */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL_SHFT 60
-#define SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBP_XB_PIPE_COMPARE_0"                */
-/*                         CRBP XB Pipe Compare                         */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_XB_PIPE_COMPARE_0             0x0000000120050800
-#define SH_PI_CRBP_XB_PIPE_COMPARE_0_MASK        0x007fffffffffffff
-#define SH_PI_CRBP_XB_PIPE_COMPARE_0_INIT        0x0000000000000000
-
-/*   SH_PI_CRBP_XB_PIPE_COMPARE_0_COMPARE_ADDRESS                       */
-/*   Description:  Address to compare against                           */
-#define SH_PI_CRBP_XB_PIPE_COMPARE_0_COMPARE_ADDRESS_SHFT 0
-#define SH_PI_CRBP_XB_PIPE_COMPARE_0_COMPARE_ADDRESS_MASK 0x00007fffffffffff
-
-/*   SH_PI_CRBP_XB_PIPE_COMPARE_0_COMPARE_COMMAND                       */
-/*   Description:  SN2NET Command to compare against                    */
-#define SH_PI_CRBP_XB_PIPE_COMPARE_0_COMPARE_COMMAND_SHFT 47
-#define SH_PI_CRBP_XB_PIPE_COMPARE_0_COMPARE_COMMAND_MASK 0x007f800000000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBP_XB_PIPE_COMPARE_1"                */
-/*                         CRBP XB Pipe Compare                         */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1             0x0000000120050880
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1_MASK        0x000001ff3fff3fff
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1_INIT        0x0000000000000000
-
-/*   SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_SOURCE                        */
-/*   Description:  Source to compare against                            */
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_SOURCE_SHFT 0
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_SOURCE_MASK 0x0000000000003fff
-
-/*   SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_SUPPLEMENTAL                  */
-/*   Description:  Supplemental to compare against                      */
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_SUPPLEMENTAL_SHFT 16
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_SUPPLEMENTAL_MASK 0x000000003fff0000
-
-/*   SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_ECHO                          */
-/*   Description:  Echo to compare against                              */
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_ECHO_SHFT 32
-#define SH_PI_CRBP_XB_PIPE_COMPARE_1_COMPARE_ECHO_MASK 0x000001ff00000000
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CRBP_XB_PIPE_MASK_0"                 */
-/*                     CRBP Compare Mask Register 1                     */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_XB_PIPE_MASK_0                0x0000000120050900
-#define SH_PI_CRBP_XB_PIPE_MASK_0_MASK           0x007fffffffffffff
-#define SH_PI_CRBP_XB_PIPE_MASK_0_INIT           0x0000000000000000
-
-/*   SH_PI_CRBP_XB_PIPE_MASK_0_COMPARE_ADDRESS_MASK                     */
-/*   Description:  Address to compare against                           */
-#define SH_PI_CRBP_XB_PIPE_MASK_0_COMPARE_ADDRESS_MASK_SHFT 0
-#define SH_PI_CRBP_XB_PIPE_MASK_0_COMPARE_ADDRESS_MASK_MASK 0x00007fffffffffff
-
-/*   SH_PI_CRBP_XB_PIPE_MASK_0_COMPARE_COMMAND_MASK                     */
-/*   Description:  SN2NET Command to compare against                    */
-#define SH_PI_CRBP_XB_PIPE_MASK_0_COMPARE_COMMAND_MASK_SHFT 47
-#define SH_PI_CRBP_XB_PIPE_MASK_0_COMPARE_COMMAND_MASK_MASK 0x007f800000000000
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CRBP_XB_PIPE_MASK_1"                 */
-/*                 CRBP XB Pipe Compare Mask Register 1                 */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_XB_PIPE_MASK_1                0x0000000120050980
-#define SH_PI_CRBP_XB_PIPE_MASK_1_MASK           0x000001ff3fff3fff
-#define SH_PI_CRBP_XB_PIPE_MASK_1_INIT           0x0000000000000000
-
-/*   SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_SOURCE_MASK                      */
-/*   Description:  Source to compare against                            */
-#define SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_SOURCE_MASK_SHFT 0
-#define SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_SOURCE_MASK_MASK 0x0000000000003fff
-
-/*   SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_SUPPLEMENTAL_MASK                */
-/*   Description:  Supplemental to compare against                      */
-#define SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_SUPPLEMENTAL_MASK_SHFT 16
-#define SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_SUPPLEMENTAL_MASK_MASK 0x000000003fff0000
-
-/*   SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_ECHO_MASK                        */
-/*   Description:  Echo to compare against                              */
-#define SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_ECHO_MASK_SHFT 32
-#define SH_PI_CRBP_XB_PIPE_MASK_1_COMPARE_ECHO_MASK_MASK 0x000001ff00000000
-
-/* ==================================================================== */
-/*                  Register "SH_PI_DPC_QUEUE_CONFIG"                   */
-/*                       DPC Queue Configuration                        */
-/* ==================================================================== */
-
-#define SH_PI_DPC_QUEUE_CONFIG                   0x0000000120050a00
-#define SH_PI_DPC_QUEUE_CONFIG_MASK              0x000000001f1f1f1f
-#define SH_PI_DPC_QUEUE_CONFIG_INIT              0x000000000c010c01
-
-/*   SH_PI_DPC_QUEUE_CONFIG_DWCQ_AE_LEVEL                               */
-/*   Description:  DXB WTL Command Queue Almost Empty Level             */
-#define SH_PI_DPC_QUEUE_CONFIG_DWCQ_AE_LEVEL_SHFT 0
-#define SH_PI_DPC_QUEUE_CONFIG_DWCQ_AE_LEVEL_MASK 0x000000000000001f
-
-/*   SH_PI_DPC_QUEUE_CONFIG_DWCQ_AF_THRESH                              */
-/*   Description:  DXB WTL Command Queue Almost Full Threshold          */
-#define SH_PI_DPC_QUEUE_CONFIG_DWCQ_AF_THRESH_SHFT 8
-#define SH_PI_DPC_QUEUE_CONFIG_DWCQ_AF_THRESH_MASK 0x0000000000001f00
-
-/*   SH_PI_DPC_QUEUE_CONFIG_FWCQ_AE_LEVEL                               */
-/*   Description:  FSB WTL Command Queue Almost Empty Level             */
-#define SH_PI_DPC_QUEUE_CONFIG_FWCQ_AE_LEVEL_SHFT 16
-#define SH_PI_DPC_QUEUE_CONFIG_FWCQ_AE_LEVEL_MASK 0x00000000001f0000
-
-/*   SH_PI_DPC_QUEUE_CONFIG_FWCQ_AF_THRESH                              */
-/*   Description:  FSB WTL Command Queue Almost Full Threshold          */
-#define SH_PI_DPC_QUEUE_CONFIG_FWCQ_AF_THRESH_SHFT 24
-#define SH_PI_DPC_QUEUE_CONFIG_FWCQ_AF_THRESH_MASK 0x000000001f000000
-
-/* ==================================================================== */
-/*                     Register "SH_PI_ERROR_MASK"                      */
-/*                            PI Error Mask                             */
-/* ==================================================================== */
-
-#define SH_PI_ERROR_MASK                         0x0000000120050a80
-#define SH_PI_ERROR_MASK_MASK                    0x00000007ffffffff
-#define SH_PI_ERROR_MASK_INIT                    0x00000007ffffffff
-
-/*   SH_PI_ERROR_MASK_FSB_PROTO_ERR                                     */
-/*   Description:  Mask detection of internal protocol table misses     */
-#define SH_PI_ERROR_MASK_FSB_PROTO_ERR_SHFT      0
-#define SH_PI_ERROR_MASK_FSB_PROTO_ERR_MASK      0x0000000000000001
-
-/*   SH_PI_ERROR_MASK_GFX_RP_ERR                                        */
-/*   Description:  Mask graphic reply error message error detection     */
-#define SH_PI_ERROR_MASK_GFX_RP_ERR_SHFT         1
-#define SH_PI_ERROR_MASK_GFX_RP_ERR_MASK         0x0000000000000002
-
-/*   SH_PI_ERROR_MASK_XB_PROTO_ERR                                      */
-/*   Description:  Mask detection of external protocol table misses     */
-#define SH_PI_ERROR_MASK_XB_PROTO_ERR_SHFT       2
-#define SH_PI_ERROR_MASK_XB_PROTO_ERR_MASK       0x0000000000000004
-
-/*   SH_PI_ERROR_MASK_MEM_RP_ERR                                        */
-/*   Description:  Mask memory reply error detection                    */
-#define SH_PI_ERROR_MASK_MEM_RP_ERR_SHFT         3
-#define SH_PI_ERROR_MASK_MEM_RP_ERR_MASK         0x0000000000000008
-
-/*   SH_PI_ERROR_MASK_PIO_RP_ERR                                        */
-/*   Description:  Mask PIO reply error detection                       */
-#define SH_PI_ERROR_MASK_PIO_RP_ERR_SHFT         4
-#define SH_PI_ERROR_MASK_PIO_RP_ERR_MASK         0x0000000000000010
-
-/*   SH_PI_ERROR_MASK_MEM_TO_ERR                                        */
-/*   Description:  Mask CRB time-out errors                             */
-#define SH_PI_ERROR_MASK_MEM_TO_ERR_SHFT         5
-#define SH_PI_ERROR_MASK_MEM_TO_ERR_MASK         0x0000000000000020
-
-/*   SH_PI_ERROR_MASK_PIO_TO_ERR                                        */
-/*   Description:  Mask PIO time-out errors                             */
-#define SH_PI_ERROR_MASK_PIO_TO_ERR_SHFT         6
-#define SH_PI_ERROR_MASK_PIO_TO_ERR_MASK         0x0000000000000040
-
-/*   SH_PI_ERROR_MASK_FSB_SHUB_UCE                                      */
-/*   Description:  Mask un-correctable ECC error detection              */
-#define SH_PI_ERROR_MASK_FSB_SHUB_UCE_SHFT       7
-#define SH_PI_ERROR_MASK_FSB_SHUB_UCE_MASK       0x0000000000000080
-
-/*   SH_PI_ERROR_MASK_FSB_SHUB_CE                                       */
-/*   Description:  Mask correctable ECC error detection                 */
-#define SH_PI_ERROR_MASK_FSB_SHUB_CE_SHFT        8
-#define SH_PI_ERROR_MASK_FSB_SHUB_CE_MASK        0x0000000000000100
-
-/*   SH_PI_ERROR_MASK_MSG_COLOR_ERR                                     */
-/*   Description:  Mask message color error detection                   */
-#define SH_PI_ERROR_MASK_MSG_COLOR_ERR_SHFT      9
-#define SH_PI_ERROR_MASK_MSG_COLOR_ERR_MASK      0x0000000000000200
-
-/*   SH_PI_ERROR_MASK_MD_RQ_Q_OFLOW                                     */
-/*   Description:  Mask MD Request input buffer over flow error         */
-#define SH_PI_ERROR_MASK_MD_RQ_Q_OFLOW_SHFT      10
-#define SH_PI_ERROR_MASK_MD_RQ_Q_OFLOW_MASK      0x0000000000000400
-
-/*   SH_PI_ERROR_MASK_MD_RP_Q_OFLOW                                     */
-/*   Description:  Mask MD Reply input buffer over flow error           */
-#define SH_PI_ERROR_MASK_MD_RP_Q_OFLOW_SHFT      11
-#define SH_PI_ERROR_MASK_MD_RP_Q_OFLOW_MASK      0x0000000000000800
-
-/*   SH_PI_ERROR_MASK_XN_RQ_Q_OFLOW                                     */
-/*   Description:  Mask XN Request input buffer over flow error         */
-#define SH_PI_ERROR_MASK_XN_RQ_Q_OFLOW_SHFT      12
-#define SH_PI_ERROR_MASK_XN_RQ_Q_OFLOW_MASK      0x0000000000001000
-
-/*   SH_PI_ERROR_MASK_XN_RP_Q_OFLOW                                     */
-/*   Description:  Mask XN Reply input buffer over flow error           */
-#define SH_PI_ERROR_MASK_XN_RP_Q_OFLOW_SHFT      13
-#define SH_PI_ERROR_MASK_XN_RP_Q_OFLOW_MASK      0x0000000000002000
-
-/*   SH_PI_ERROR_MASK_NACK_OFLOW                                        */
-/*   Description:  Mask NACK over flow error                            */
-#define SH_PI_ERROR_MASK_NACK_OFLOW_SHFT         14
-#define SH_PI_ERROR_MASK_NACK_OFLOW_MASK         0x0000000000004000
-
-/*   SH_PI_ERROR_MASK_GFX_INT_0                                         */
-/*   Description:  Mask GFX transfer interrupt for CPU 0                */
-#define SH_PI_ERROR_MASK_GFX_INT_0_SHFT          15
-#define SH_PI_ERROR_MASK_GFX_INT_0_MASK          0x0000000000008000
-
-/*   SH_PI_ERROR_MASK_GFX_INT_1                                         */
-/*   Description:  Mask GFX transfer interrupt for CPU 1                */
-#define SH_PI_ERROR_MASK_GFX_INT_1_SHFT          16
-#define SH_PI_ERROR_MASK_GFX_INT_1_MASK          0x0000000000010000
-
-/*   SH_PI_ERROR_MASK_MD_RQ_CRD_OFLOW                                   */
-/*   Description:  Mask MD Request Credit Overflow Error                */
-#define SH_PI_ERROR_MASK_MD_RQ_CRD_OFLOW_SHFT    17
-#define SH_PI_ERROR_MASK_MD_RQ_CRD_OFLOW_MASK    0x0000000000020000
-
-/*   SH_PI_ERROR_MASK_MD_RP_CRD_OFLOW                                   */
-/*   Description:  Mask MD Reply Credit Overflow Error                  */
-#define SH_PI_ERROR_MASK_MD_RP_CRD_OFLOW_SHFT    18
-#define SH_PI_ERROR_MASK_MD_RP_CRD_OFLOW_MASK    0x0000000000040000
-
-/*   SH_PI_ERROR_MASK_XN_RQ_CRD_OFLOW                                   */
-/*   Description:  Mask XN Request Credit Overflow Error                */
-#define SH_PI_ERROR_MASK_XN_RQ_CRD_OFLOW_SHFT    19
-#define SH_PI_ERROR_MASK_XN_RQ_CRD_OFLOW_MASK    0x0000000000080000
-
-/*   SH_PI_ERROR_MASK_XN_RP_CRD_OFLOW                                   */
-/*   Description:  Mask XN Reply Credit Overflow Error                  */
-#define SH_PI_ERROR_MASK_XN_RP_CRD_OFLOW_SHFT    20
-#define SH_PI_ERROR_MASK_XN_RP_CRD_OFLOW_MASK    0x0000000000100000
-
-/*   SH_PI_ERROR_MASK_HUNG_BUS                                          */
-/*   Description:  Mask FSB hung error                                  */
-#define SH_PI_ERROR_MASK_HUNG_BUS_SHFT           21
-#define SH_PI_ERROR_MASK_HUNG_BUS_MASK           0x0000000000200000
-
-/*   SH_PI_ERROR_MASK_RSP_PARITY                                        */
-/*   Description:  Parity error detecte during response phase           */
-#define SH_PI_ERROR_MASK_RSP_PARITY_SHFT         22
-#define SH_PI_ERROR_MASK_RSP_PARITY_MASK         0x0000000000400000
-
-/*   SH_PI_ERROR_MASK_IOQ_OVERRUN                                       */
-/*   Description:  Over run error detected on IOQ                       */
-#define SH_PI_ERROR_MASK_IOQ_OVERRUN_SHFT        23
-#define SH_PI_ERROR_MASK_IOQ_OVERRUN_MASK        0x0000000000800000
-
-/*   SH_PI_ERROR_MASK_REQ_FORMAT                                        */
-/*   Description:  FSB request format not supported                     */
-#define SH_PI_ERROR_MASK_REQ_FORMAT_SHFT         24
-#define SH_PI_ERROR_MASK_REQ_FORMAT_MASK         0x0000000001000000
-
-/*   SH_PI_ERROR_MASK_ADDR_ACCESS                                       */
-/*   Description:  Access to Address is not supported                   */
-#define SH_PI_ERROR_MASK_ADDR_ACCESS_SHFT        25
-#define SH_PI_ERROR_MASK_ADDR_ACCESS_MASK        0x0000000002000000
-
-/*   SH_PI_ERROR_MASK_REQ_PARITY                                        */
-/*   Description:  Parity error detected during request phase           */
-#define SH_PI_ERROR_MASK_REQ_PARITY_SHFT         26
-#define SH_PI_ERROR_MASK_REQ_PARITY_MASK         0x0000000004000000
-
-/*   SH_PI_ERROR_MASK_ADDR_PARITY                                       */
-/*   Description:  Parity error detected on address                     */
-#define SH_PI_ERROR_MASK_ADDR_PARITY_SHFT        27
-#define SH_PI_ERROR_MASK_ADDR_PARITY_MASK        0x0000000008000000
-
-/*   SH_PI_ERROR_MASK_SHUB_FSB_DQE                                      */
-/*   Description:  SHUB_FSB_DQE                                         */
-#define SH_PI_ERROR_MASK_SHUB_FSB_DQE_SHFT       28
-#define SH_PI_ERROR_MASK_SHUB_FSB_DQE_MASK       0x0000000010000000
-
-/*   SH_PI_ERROR_MASK_SHUB_FSB_UCE                                      */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_ERROR_MASK_SHUB_FSB_UCE_SHFT       29
-#define SH_PI_ERROR_MASK_SHUB_FSB_UCE_MASK       0x0000000020000000
-
-/*   SH_PI_ERROR_MASK_SHUB_FSB_CE                                       */
-/*   Description:  An correctable ECC error was detected                */
-#define SH_PI_ERROR_MASK_SHUB_FSB_CE_SHFT        30
-#define SH_PI_ERROR_MASK_SHUB_FSB_CE_MASK        0x0000000040000000
-
-/*   SH_PI_ERROR_MASK_LIVELOCK                                          */
-/*   Description:  AFI livelock error was detected                      */
-#define SH_PI_ERROR_MASK_LIVELOCK_SHFT           31
-#define SH_PI_ERROR_MASK_LIVELOCK_MASK           0x0000000080000000
-
-/*   SH_PI_ERROR_MASK_BAD_SNOOP                                         */
-/*   Description:  AFI bad snoop error was detected                     */
-#define SH_PI_ERROR_MASK_BAD_SNOOP_SHFT          32
-#define SH_PI_ERROR_MASK_BAD_SNOOP_MASK          0x0000000100000000
-
-/*   SH_PI_ERROR_MASK_FSB_TBL_MISS                                      */
-/*   Description:  AFI FSB request table miss error was detected        */
-#define SH_PI_ERROR_MASK_FSB_TBL_MISS_SHFT       33
-#define SH_PI_ERROR_MASK_FSB_TBL_MISS_MASK       0x0000000200000000
-
-/*   SH_PI_ERROR_MASK_MSG_LENGTH                                        */
-/*   Description:  Message length error on received message from SIC    */
-#define SH_PI_ERROR_MASK_MSG_LENGTH_SHFT         34
-#define SH_PI_ERROR_MASK_MSG_LENGTH_MASK         0x0000000400000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_EXPRESS_REPLY_CONFIG"                 */
-/*                    PI Express Reply Configuration                    */
-/* ==================================================================== */
-
-#define SH_PI_EXPRESS_REPLY_CONFIG               0x0000000120050b00
-#define SH_PI_EXPRESS_REPLY_CONFIG_MASK          0x0000000000000007
-#define SH_PI_EXPRESS_REPLY_CONFIG_INIT          0x0000000000000001
-
-/*   SH_PI_EXPRESS_REPLY_CONFIG_MODE                                    */
-/*   Description:  Express Reply Mode                                   */
-#define SH_PI_EXPRESS_REPLY_CONFIG_MODE_SHFT     0
-#define SH_PI_EXPRESS_REPLY_CONFIG_MODE_MASK     0x0000000000000007
-
-/* ==================================================================== */
-/*                  Register "SH_PI_FSB_COMPARE_VALUE"                  */
-/*                          FSB Compare Value                           */
-/* ==================================================================== */
-
-#define SH_PI_FSB_COMPARE_VALUE                  0x0000000120050c00
-#define SH_PI_FSB_COMPARE_VALUE_MASK             0xffffffffffffffff
-#define SH_PI_FSB_COMPARE_VALUE_INIT             0x0000000000000000
-
-/*   SH_PI_FSB_COMPARE_VALUE_COMPARE_VALUE                              */
-/*   Description:  Compare value                                        */
-#define SH_PI_FSB_COMPARE_VALUE_COMPARE_VALUE_SHFT 0
-#define SH_PI_FSB_COMPARE_VALUE_COMPARE_VALUE_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PI_FSB_COMPARE_MASK"                   */
-/*                           FSB Compare Mask                           */
-/* ==================================================================== */
-
-#define SH_PI_FSB_COMPARE_MASK                   0x0000000120050b80
-#define SH_PI_FSB_COMPARE_MASK_MASK              0xffffffffffffffff
-#define SH_PI_FSB_COMPARE_MASK_INIT              0x0000000000000000
-
-/*   SH_PI_FSB_COMPARE_MASK_MASK_VALUE                                  */
-/*   Description:  Mask value                                           */
-#define SH_PI_FSB_COMPARE_MASK_MASK_VALUE_SHFT   0
-#define SH_PI_FSB_COMPARE_MASK_MASK_VALUE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_PI_FSB_ERROR_INJECTION"                 */
-/*                     Inject an Error onto the FSB                     */
-/* ==================================================================== */
-
-#define SH_PI_FSB_ERROR_INJECTION                0x0000000120050c80
-#define SH_PI_FSB_ERROR_INJECTION_MASK           0x000000070fff03ff
-#define SH_PI_FSB_ERROR_INJECTION_INIT           0x0000000000000000
-
-/*   SH_PI_FSB_ERROR_INJECTION_RP_PE_TO_FSB                             */
-/*   Description:  Inject a RP# Parity Error onto the FSB               */
-#define SH_PI_FSB_ERROR_INJECTION_RP_PE_TO_FSB_SHFT 0
-#define SH_PI_FSB_ERROR_INJECTION_RP_PE_TO_FSB_MASK 0x0000000000000001
-
-/*   SH_PI_FSB_ERROR_INJECTION_AP0_PE_TO_FSB                            */
-/*   Description:  Inject an AP[0]# Parity Error onto the FSB           */
-#define SH_PI_FSB_ERROR_INJECTION_AP0_PE_TO_FSB_SHFT 1
-#define SH_PI_FSB_ERROR_INJECTION_AP0_PE_TO_FSB_MASK 0x0000000000000002
-
-/*   SH_PI_FSB_ERROR_INJECTION_AP1_PE_TO_FSB                            */
-/*   Description:  Inject an AP[1]# Parity Error onto the FSB           */
-#define SH_PI_FSB_ERROR_INJECTION_AP1_PE_TO_FSB_SHFT 2
-#define SH_PI_FSB_ERROR_INJECTION_AP1_PE_TO_FSB_MASK 0x0000000000000004
-
-/*   SH_PI_FSB_ERROR_INJECTION_RSP_PE_TO_FSB                            */
-/*   Description:  Inject a RSP# Parity Error onto the FSB              */
-#define SH_PI_FSB_ERROR_INJECTION_RSP_PE_TO_FSB_SHFT 3
-#define SH_PI_FSB_ERROR_INJECTION_RSP_PE_TO_FSB_MASK 0x0000000000000008
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW0_CE_TO_FSB                            */
-/*   Description:  Inject a Correctable Error in Doubleword 0 onto the  */
-#define SH_PI_FSB_ERROR_INJECTION_DW0_CE_TO_FSB_SHFT 4
-#define SH_PI_FSB_ERROR_INJECTION_DW0_CE_TO_FSB_MASK 0x0000000000000010
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW0_UCE_TO_FSB                           */
-/*   Description:  Inject an Uncorrectable Error in Doubleword 0 onto   */
-/*  the FSB                                                             */
-#define SH_PI_FSB_ERROR_INJECTION_DW0_UCE_TO_FSB_SHFT 5
-#define SH_PI_FSB_ERROR_INJECTION_DW0_UCE_TO_FSB_MASK 0x0000000000000020
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW1_CE_TO_FSB                            */
-/*   Description:  Inject a Correctable Error in Doubleword 1 onto the  */
-#define SH_PI_FSB_ERROR_INJECTION_DW1_CE_TO_FSB_SHFT 6
-#define SH_PI_FSB_ERROR_INJECTION_DW1_CE_TO_FSB_MASK 0x0000000000000040
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW1_UCE_TO_FSB                           */
-/*   Description:  Inject an Uncorrectable Error in Doubleword 1 onto   */
-/*  the FSB                                                             */
-#define SH_PI_FSB_ERROR_INJECTION_DW1_UCE_TO_FSB_SHFT 7
-#define SH_PI_FSB_ERROR_INJECTION_DW1_UCE_TO_FSB_MASK 0x0000000000000080
-
-/*   SH_PI_FSB_ERROR_INJECTION_IP0_PE_TO_FSB                            */
-/*   Description:  Inject an IP[0]# Parity Error onto the FSB           */
-#define SH_PI_FSB_ERROR_INJECTION_IP0_PE_TO_FSB_SHFT 8
-#define SH_PI_FSB_ERROR_INJECTION_IP0_PE_TO_FSB_MASK 0x0000000000000100
-
-/*   SH_PI_FSB_ERROR_INJECTION_IP1_PE_TO_FSB                            */
-/*   Description:  Inject an IP[1]# Parity Error onto the FSB           */
-#define SH_PI_FSB_ERROR_INJECTION_IP1_PE_TO_FSB_SHFT 9
-#define SH_PI_FSB_ERROR_INJECTION_IP1_PE_TO_FSB_MASK 0x0000000000000200
-
-/*   SH_PI_FSB_ERROR_INJECTION_RP_PE_FROM_FSB                           */
-/*   Description:  Inject a RP# Parity Error When Sampling the FSB      */
-#define SH_PI_FSB_ERROR_INJECTION_RP_PE_FROM_FSB_SHFT 16
-#define SH_PI_FSB_ERROR_INJECTION_RP_PE_FROM_FSB_MASK 0x0000000000010000
-
-/*   SH_PI_FSB_ERROR_INJECTION_AP0_PE_FROM_FSB                          */
-/*   Description:  Inject an AP[0]# Parity Error When Sampling the FSB  */
-#define SH_PI_FSB_ERROR_INJECTION_AP0_PE_FROM_FSB_SHFT 17
-#define SH_PI_FSB_ERROR_INJECTION_AP0_PE_FROM_FSB_MASK 0x0000000000020000
-
-/*   SH_PI_FSB_ERROR_INJECTION_AP1_PE_FROM_FSB                          */
-/*   Description:  Inject an AP[1]# Parity Error When Sampling the FSB  */
-#define SH_PI_FSB_ERROR_INJECTION_AP1_PE_FROM_FSB_SHFT 18
-#define SH_PI_FSB_ERROR_INJECTION_AP1_PE_FROM_FSB_MASK 0x0000000000040000
-
-/*   SH_PI_FSB_ERROR_INJECTION_RSP_PE_FROM_FSB                          */
-/*   Description:  Inject a RSP# Parity Error When Sampling the FSB     */
-#define SH_PI_FSB_ERROR_INJECTION_RSP_PE_FROM_FSB_SHFT 19
-#define SH_PI_FSB_ERROR_INJECTION_RSP_PE_FROM_FSB_MASK 0x0000000000080000
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW0_CE_FROM_FSB                          */
-/*   Description:  Inject a Correctable Error in Doubleword 0 of SIC D  */
-/*  ata Packet 0                                                        */
-#define SH_PI_FSB_ERROR_INJECTION_DW0_CE_FROM_FSB_SHFT 20
-#define SH_PI_FSB_ERROR_INJECTION_DW0_CE_FROM_FSB_MASK 0x0000000000100000
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW0_UCE_FROM_FSB                         */
-/*   Description:  Inject a Uncorrectable Error in Doubleword 0 of SIC  */
-/*   Data Packet 0                                                      */
-#define SH_PI_FSB_ERROR_INJECTION_DW0_UCE_FROM_FSB_SHFT 21
-#define SH_PI_FSB_ERROR_INJECTION_DW0_UCE_FROM_FSB_MASK 0x0000000000200000
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW1_CE_FROM_FSB                          */
-/*   Description:  Inject a Correctable Error in Doubleword 0 of SIC D  */
-/*  ata Packet 0                                                        */
-#define SH_PI_FSB_ERROR_INJECTION_DW1_CE_FROM_FSB_SHFT 22
-#define SH_PI_FSB_ERROR_INJECTION_DW1_CE_FROM_FSB_MASK 0x0000000000400000
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW1_UCE_FROM_FSB                         */
-/*   Description:  Inject a Uncorrectable Error in Doubleword 0 of SIC  */
-/*   Data Packet 0                                                      */
-#define SH_PI_FSB_ERROR_INJECTION_DW1_UCE_FROM_FSB_SHFT 23
-#define SH_PI_FSB_ERROR_INJECTION_DW1_UCE_FROM_FSB_MASK 0x0000000000800000
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW2_CE_FROM_FSB                          */
-/*   Description:  Inject a Correctable Error in Doubleword 0 of SIC D  */
-/*  ata Packet 0                                                        */
-#define SH_PI_FSB_ERROR_INJECTION_DW2_CE_FROM_FSB_SHFT 24
-#define SH_PI_FSB_ERROR_INJECTION_DW2_CE_FROM_FSB_MASK 0x0000000001000000
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW2_UCE_FROM_FSB                         */
-/*   Description:  Inject a Uncorrectable Error in Doubleword 0 of SIC  */
-/*   Data Packet 0                                                      */
-#define SH_PI_FSB_ERROR_INJECTION_DW2_UCE_FROM_FSB_SHFT 25
-#define SH_PI_FSB_ERROR_INJECTION_DW2_UCE_FROM_FSB_MASK 0x0000000002000000
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW3_CE_FROM_FSB                          */
-/*   Description:  Inject a Correctable Error in Doubleword 0 of SIC D  */
-/*  ata Packet 0                                                        */
-#define SH_PI_FSB_ERROR_INJECTION_DW3_CE_FROM_FSB_SHFT 26
-#define SH_PI_FSB_ERROR_INJECTION_DW3_CE_FROM_FSB_MASK 0x0000000004000000
-
-/*   SH_PI_FSB_ERROR_INJECTION_DW3_UCE_FROM_FSB                         */
-/*   Description:  Inject a Uncorrectable Error in Doubleword 0 of SIC  */
-/*   Data Packet 0                                                      */
-#define SH_PI_FSB_ERROR_INJECTION_DW3_UCE_FROM_FSB_SHFT 27
-#define SH_PI_FSB_ERROR_INJECTION_DW3_UCE_FROM_FSB_MASK 0x0000000008000000
-
-/*   SH_PI_FSB_ERROR_INJECTION_IOQ_OVERRUN                              */
-/*   Description:  Inject an ioq overrun Error on the FSB               */
-#define SH_PI_FSB_ERROR_INJECTION_IOQ_OVERRUN_SHFT 32
-#define SH_PI_FSB_ERROR_INJECTION_IOQ_OVERRUN_MASK 0x0000000100000000
-
-/*   SH_PI_FSB_ERROR_INJECTION_LIVELOCK                                 */
-/*   Description:  Inject a livelock Error on the FSB                   */
-#define SH_PI_FSB_ERROR_INJECTION_LIVELOCK_SHFT  33
-#define SH_PI_FSB_ERROR_INJECTION_LIVELOCK_MASK  0x0000000200000000
-
-/*   SH_PI_FSB_ERROR_INJECTION_BUS_HANG                                 */
-/*   Description:  Inject an bus hang on the FSB                        */
-#define SH_PI_FSB_ERROR_INJECTION_BUS_HANG_SHFT  34
-#define SH_PI_FSB_ERROR_INJECTION_BUS_HANG_MASK  0x0000000400000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_MD2PI_REPLY_VC_CONFIG"                */
-/*             MD-to-PI Reply Virtual Channel Configuration             */
-/* ==================================================================== */
-
-#define SH_PI_MD2PI_REPLY_VC_CONFIG              0x0000000120050d00
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_MASK         0xc000000000003fff
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_INIT         0x000000000000088c
-
-/*   SH_PI_MD2PI_REPLY_VC_CONFIG_HDR_DEPTH                              */
-/*   Description:  Depth of header Buffer                               */
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_HDR_DEPTH_SHFT 0
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_HDR_DEPTH_MASK 0x000000000000000f
-
-/*   SH_PI_MD2PI_REPLY_VC_CONFIG_DATA_DEPTH                             */
-/*   Description:  Number of data buffers Available                     */
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_DATA_DEPTH_SHFT 4
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_DATA_DEPTH_MASK 0x00000000000000f0
-
-/*   SH_PI_MD2PI_REPLY_VC_CONFIG_MAX_CREDITS                            */
-/*   Description:  Maximum credits from sender                          */
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_MAX_CREDITS_SHFT 8
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_MAX_CREDITS_MASK 0x0000000000003f00
-
-/*   SH_PI_MD2PI_REPLY_VC_CONFIG_FORCE_CREDIT                           */
-/*   Description:  Send an extra credit to sender                       */
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_FORCE_CREDIT_SHFT 62
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_FORCE_CREDIT_MASK 0x4000000000000000
-
-/*   SH_PI_MD2PI_REPLY_VC_CONFIG_CAPTURE_CREDIT_STATUS                  */
-/*   Description:  Capture credit and status information                */
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_CAPTURE_CREDIT_STATUS_SHFT 63
-#define SH_PI_MD2PI_REPLY_VC_CONFIG_CAPTURE_CREDIT_STATUS_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_MD2PI_REQUEST_VC_CONFIG"               */
-/*            MD-to-PI Request Virtual Channel Configuration            */
-/* ==================================================================== */
-
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG            0x0000000120050d80
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_MASK       0xc000000000003fff
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_INIT       0x000000000000088c
-
-/*   SH_PI_MD2PI_REQUEST_VC_CONFIG_HDR_DEPTH                            */
-/*   Description:  Depth of header Buffer                               */
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_HDR_DEPTH_SHFT 0
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_HDR_DEPTH_MASK 0x000000000000000f
-
-/*   SH_PI_MD2PI_REQUEST_VC_CONFIG_DATA_DEPTH                           */
-/*   Description:  Number of data buffers Available                     */
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_DATA_DEPTH_SHFT 4
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_DATA_DEPTH_MASK 0x00000000000000f0
-
-/*   SH_PI_MD2PI_REQUEST_VC_CONFIG_MAX_CREDITS                          */
-/*   Description:  Maximum credits from sender                          */
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_MAX_CREDITS_SHFT 8
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_MAX_CREDITS_MASK 0x0000000000003f00
-
-/*   SH_PI_MD2PI_REQUEST_VC_CONFIG_FORCE_CREDIT                         */
-/*   Description:  Send an extra credit to sender                       */
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_FORCE_CREDIT_SHFT 62
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_FORCE_CREDIT_MASK 0x4000000000000000
-
-/*   SH_PI_MD2PI_REQUEST_VC_CONFIG_CAPTURE_CREDIT_STATUS                */
-/*   Description:  Capture credit and status information                */
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_CAPTURE_CREDIT_STATUS_SHFT 63
-#define SH_PI_MD2PI_REQUEST_VC_CONFIG_CAPTURE_CREDIT_STATUS_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_QUEUE_ERROR_INJECTION"                */
-/*                       PI Queue Error Injection                       */
-/* ==================================================================== */
-
-#define SH_PI_QUEUE_ERROR_INJECTION              0x0000000120050e00
-#define SH_PI_QUEUE_ERROR_INJECTION_MASK         0x00000000000000ff
-#define SH_PI_QUEUE_ERROR_INJECTION_INIT         0x0000000000000000
-
-/*   SH_PI_QUEUE_ERROR_INJECTION_DAT_DFR_Q                              */
-#define SH_PI_QUEUE_ERROR_INJECTION_DAT_DFR_Q_SHFT 0
-#define SH_PI_QUEUE_ERROR_INJECTION_DAT_DFR_Q_MASK 0x0000000000000001
-
-/*   SH_PI_QUEUE_ERROR_INJECTION_DXB_WTL_CMND_Q                         */
-#define SH_PI_QUEUE_ERROR_INJECTION_DXB_WTL_CMND_Q_SHFT 1
-#define SH_PI_QUEUE_ERROR_INJECTION_DXB_WTL_CMND_Q_MASK 0x0000000000000002
-
-/*   SH_PI_QUEUE_ERROR_INJECTION_FSB_WTL_CMND_Q                         */
-#define SH_PI_QUEUE_ERROR_INJECTION_FSB_WTL_CMND_Q_SHFT 2
-#define SH_PI_QUEUE_ERROR_INJECTION_FSB_WTL_CMND_Q_MASK 0x0000000000000004
-
-/*   SH_PI_QUEUE_ERROR_INJECTION_MDPI_RPY_BFR                           */
-#define SH_PI_QUEUE_ERROR_INJECTION_MDPI_RPY_BFR_SHFT 3
-#define SH_PI_QUEUE_ERROR_INJECTION_MDPI_RPY_BFR_MASK 0x0000000000000008
-
-/*   SH_PI_QUEUE_ERROR_INJECTION_PTC_INTR                               */
-#define SH_PI_QUEUE_ERROR_INJECTION_PTC_INTR_SHFT 4
-#define SH_PI_QUEUE_ERROR_INJECTION_PTC_INTR_MASK 0x0000000000000010
-
-/*   SH_PI_QUEUE_ERROR_INJECTION_RXL_KILL_Q                             */
-#define SH_PI_QUEUE_ERROR_INJECTION_RXL_KILL_Q_SHFT 5
-#define SH_PI_QUEUE_ERROR_INJECTION_RXL_KILL_Q_MASK 0x0000000000000020
-
-/*   SH_PI_QUEUE_ERROR_INJECTION_RXL_RDY_Q                              */
-#define SH_PI_QUEUE_ERROR_INJECTION_RXL_RDY_Q_SHFT 6
-#define SH_PI_QUEUE_ERROR_INJECTION_RXL_RDY_Q_MASK 0x0000000000000040
-
-/*   SH_PI_QUEUE_ERROR_INJECTION_XNPI_RPY_BFR                           */
-#define SH_PI_QUEUE_ERROR_INJECTION_XNPI_RPY_BFR_SHFT 7
-#define SH_PI_QUEUE_ERROR_INJECTION_XNPI_RPY_BFR_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                 Register "SH_PI_TEST_POINT_COMPARE"                  */
-/*                        PI Test Point Compare                         */
-/* ==================================================================== */
-
-#define SH_PI_TEST_POINT_COMPARE                 0x0000000120050e80
-#define SH_PI_TEST_POINT_COMPARE_MASK            0xffffffffffffffff
-#define SH_PI_TEST_POINT_COMPARE_INIT            0xffffffff00000000
-
-/*   SH_PI_TEST_POINT_COMPARE_COMPARE_MASK                              */
-/*   Description:  Mask to select test point data for trigger generati  */
-#define SH_PI_TEST_POINT_COMPARE_COMPARE_MASK_SHFT 0
-#define SH_PI_TEST_POINT_COMPARE_COMPARE_MASK_MASK 0x00000000ffffffff
-
-/*   SH_PI_TEST_POINT_COMPARE_COMPARE_PATTERN                           */
-/*   Description:  Pattern of test point data to cause trigger          */
-#define SH_PI_TEST_POINT_COMPARE_COMPARE_PATTERN_SHFT 32
-#define SH_PI_TEST_POINT_COMPARE_COMPARE_PATTERN_MASK 0xffffffff00000000
-
-/* ==================================================================== */
-/*                  Register "SH_PI_TEST_POINT_SELECT"                  */
-/*                         PI Test Point Select                         */
-/* ==================================================================== */
-
-#define SH_PI_TEST_POINT_SELECT                  0x0000000120050f00
-#define SH_PI_TEST_POINT_SELECT_MASK             0xf777777777777777
-#define SH_PI_TEST_POINT_SELECT_INIT             0x0000000000000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL                        */
-/*   Description:  Nibble 0 data is from Chiplet X                      */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL_SHFT 0
-#define SH_PI_TEST_POINT_SELECT_NIBBLE0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL                         */
-/*   Description:  Nibble X is routed to Nibble 0                       */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_PI_TEST_POINT_SELECT_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL                        */
-/*   Description:  Nibble 1 data is from Chiplet X                      */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL_SHFT 8
-#define SH_PI_TEST_POINT_SELECT_NIBBLE1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL                         */
-/*   Description:  Nibble X is routed to Nibble 1                       */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_PI_TEST_POINT_SELECT_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL                        */
-/*   Description:  Nibble 2 data is from Chiplet X                      */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL_SHFT 16
-#define SH_PI_TEST_POINT_SELECT_NIBBLE2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL                         */
-/*   Description:  Nibble X is routed to Nibble 2                       */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_PI_TEST_POINT_SELECT_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL                        */
-/*   Description:  Nibble 3 data is from Chiplet X                      */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL_SHFT 24
-#define SH_PI_TEST_POINT_SELECT_NIBBLE3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL                         */
-/*   Description:  Nibble X is routed to Nibble 3                       */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_PI_TEST_POINT_SELECT_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL                        */
-/*   Description:  Nibble 4 data is from Chiplet X                      */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL_SHFT 32
-#define SH_PI_TEST_POINT_SELECT_NIBBLE4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL                         */
-/*   Description:  Nibble X is routed to Nibble 4                       */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_PI_TEST_POINT_SELECT_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL                        */
-/*   Description:  Nibble 5 data is from Chiplet X                      */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL_SHFT 40
-#define SH_PI_TEST_POINT_SELECT_NIBBLE5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL                         */
-/*   Description:  Nibble X is routed to Nibble 5                       */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_PI_TEST_POINT_SELECT_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL                        */
-/*   Description:  Nibble 6 data is from Chiplet X                      */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL_SHFT 48
-#define SH_PI_TEST_POINT_SELECT_NIBBLE6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL                         */
-/*   Description:  Nibble X is routed to Nibble 6                       */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_PI_TEST_POINT_SELECT_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL                        */
-/*   Description:  Nibble 7 data is from Chiplet X                      */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL_SHFT 56
-#define SH_PI_TEST_POINT_SELECT_NIBBLE7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_PI_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL                         */
-/*   Description:  Nibble X is routed to Nibble 7                       */
-#define SH_PI_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_PI_TEST_POINT_SELECT_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/*   SH_PI_TEST_POINT_SELECT_TRIGGER_ENABLE                             */
-/*   Description:  Enable trigger on bit 32 of Analyzer data            */
-#define SH_PI_TEST_POINT_SELECT_TRIGGER_ENABLE_SHFT 63
-#define SH_PI_TEST_POINT_SELECT_TRIGGER_ENABLE_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*              Register "SH_PI_TEST_POINT_TRIGGER_SELECT"              */
-/*                     PI Test Point Trigger Select                     */
-/* ==================================================================== */
-
-#define SH_PI_TEST_POINT_TRIGGER_SELECT          0x0000000120050f80
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_MASK     0x7777777777777777
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_INIT     0x0000000000000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL               */
-/*   Description:  Nibble 0 Chiplet select                              */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL_SHFT 0
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_CHIPLET_SEL_MASK 0x0000000000000007
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL                */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL_SHFT 4
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL               */
-/*   Description:  Nibble 1 Chiplet select                              */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL_SHFT 8
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_CHIPLET_SEL_MASK 0x0000000000000700
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL                */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL_SHFT 12
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL               */
-/*   Description:  Nibble 2 Chiplet select                              */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL_SHFT 16
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_CHIPLET_SEL_MASK 0x0000000000070000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL                */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL_SHFT 20
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL               */
-/*   Description:  Nibble 3 Chiplet select                              */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL_SHFT 24
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_CHIPLET_SEL_MASK 0x0000000007000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL                */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL_SHFT 28
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL               */
-/*   Description:  Nibble 4 Chiplet select                              */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL_SHFT 32
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_CHIPLET_SEL_MASK 0x0000000700000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL                */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL_SHFT 36
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL               */
-/*   Description:  Nibble 5 Chiplet select                              */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL_SHFT 40
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_CHIPLET_SEL_MASK 0x0000070000000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL                */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL_SHFT 44
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL               */
-/*   Description:  Nibble 6 Chiplet select                              */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL_SHFT 48
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_CHIPLET_SEL_MASK 0x0007000000000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL                */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL_SHFT 52
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL               */
-/*   Description:  Nibble 7 Chiplet select                              */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL_SHFT 56
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_CHIPLET_SEL_MASK 0x0700000000000000
-
-/*   SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL                */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL_SHFT 60
-#define SH_PI_TEST_POINT_TRIGGER_SELECT_TRIGGER7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_XN2PI_REPLY_VC_CONFIG"                */
-/*             XN-to-PI Reply Virtual Channel Configuration             */
-/* ==================================================================== */
-
-#define SH_PI_XN2PI_REPLY_VC_CONFIG              0x0000000120051000
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_MASK         0xc000000000003fff
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_INIT         0x000000000000068c
-
-/*   SH_PI_XN2PI_REPLY_VC_CONFIG_HDR_DEPTH                              */
-/*   Description:  Depth of header Buffer                               */
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_HDR_DEPTH_SHFT 0
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_HDR_DEPTH_MASK 0x000000000000000f
-
-/*   SH_PI_XN2PI_REPLY_VC_CONFIG_DATA_DEPTH                             */
-/*   Description:  Number of data buffers Available                     */
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_DATA_DEPTH_SHFT 4
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_DATA_DEPTH_MASK 0x00000000000000f0
-
-/*   SH_PI_XN2PI_REPLY_VC_CONFIG_MAX_CREDITS                            */
-/*   Description:  Maximum credits from sender                          */
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_MAX_CREDITS_SHFT 8
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_MAX_CREDITS_MASK 0x0000000000003f00
-
-/*   SH_PI_XN2PI_REPLY_VC_CONFIG_FORCE_CREDIT                           */
-/*   Description:  Send an extra credit to sender                       */
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_FORCE_CREDIT_SHFT 62
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_FORCE_CREDIT_MASK 0x4000000000000000
-
-/*   SH_PI_XN2PI_REPLY_VC_CONFIG_CAPTURE_CREDIT_STATUS                  */
-/*   Description:  Capture credit and status information                */
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_CAPTURE_CREDIT_STATUS_SHFT 63
-#define SH_PI_XN2PI_REPLY_VC_CONFIG_CAPTURE_CREDIT_STATUS_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_PI_XN2PI_REQUEST_VC_CONFIG"               */
-/*            XN-to-PI Request Virtual Channel Configuration            */
-/* ==================================================================== */
-
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG            0x0000000120051080
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_MASK       0xc000000000003fff
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_INIT       0x000000000000068c
-
-/*   SH_PI_XN2PI_REQUEST_VC_CONFIG_HDR_DEPTH                            */
-/*   Description:  Depth of header Buffer                               */
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_HDR_DEPTH_SHFT 0
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_HDR_DEPTH_MASK 0x000000000000000f
-
-/*   SH_PI_XN2PI_REQUEST_VC_CONFIG_DATA_DEPTH                           */
-/*   Description:  Number of data buffers Available                     */
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_DATA_DEPTH_SHFT 4
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_DATA_DEPTH_MASK 0x00000000000000f0
-
-/*   SH_PI_XN2PI_REQUEST_VC_CONFIG_MAX_CREDITS                          */
-/*   Description:  Maximum credits from sender                          */
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_MAX_CREDITS_SHFT 8
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_MAX_CREDITS_MASK 0x0000000000003f00
-
-/*   SH_PI_XN2PI_REQUEST_VC_CONFIG_FORCE_CREDIT                         */
-/*   Description:  Send an extra credit to sender                       */
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_FORCE_CREDIT_SHFT 62
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_FORCE_CREDIT_MASK 0x4000000000000000
-
-/*   SH_PI_XN2PI_REQUEST_VC_CONFIG_CAPTURE_CREDIT_STATUS                */
-/*   Description:  Capture credit and status information                */
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_CAPTURE_CREDIT_STATUS_SHFT 63
-#define SH_PI_XN2PI_REQUEST_VC_CONFIG_CAPTURE_CREDIT_STATUS_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                     Register "SH_PI_AEC_STATUS"                      */
-/*                 PI Adaptive Error Correction Status                  */
-/* ==================================================================== */
-
-#define SH_PI_AEC_STATUS                         0x0000000120060000
-#define SH_PI_AEC_STATUS_MASK                    0x0000000000000007
-#define SH_PI_AEC_STATUS_INIT                    0x0000000000000000
-
-/*   SH_PI_AEC_STATUS_STATE                                             */
-/*   Description:  AEC State                                            */
-#define SH_PI_AEC_STATUS_STATE_SHFT              0
-#define SH_PI_AEC_STATUS_STATE_MASK              0x0000000000000007
-
-/* ==================================================================== */
-/*                   Register "SH_PI_AFI_FIRST_ERROR"                   */
-/*                          PI AFI First Error                          */
-/* ==================================================================== */
-
-#define SH_PI_AFI_FIRST_ERROR                    0x0000000120060080
-#define SH_PI_AFI_FIRST_ERROR_MASK               0x00000007ffe00180
-#define SH_PI_AFI_FIRST_ERROR_INIT               0x0000000000000000
-
-/*   SH_PI_AFI_FIRST_ERROR_FSB_SHUB_UCE                                 */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_AFI_FIRST_ERROR_FSB_SHUB_UCE_SHFT  7
-#define SH_PI_AFI_FIRST_ERROR_FSB_SHUB_UCE_MASK  0x0000000000000080
-
-/*   SH_PI_AFI_FIRST_ERROR_FSB_SHUB_CE                                  */
-/*   Description:  A correctable ECC error was detected                 */
-#define SH_PI_AFI_FIRST_ERROR_FSB_SHUB_CE_SHFT   8
-#define SH_PI_AFI_FIRST_ERROR_FSB_SHUB_CE_MASK   0x0000000000000100
-
-/*   SH_PI_AFI_FIRST_ERROR_HUNG_BUS                                     */
-/*   Description:  FSB is hung                                          */
-#define SH_PI_AFI_FIRST_ERROR_HUNG_BUS_SHFT      21
-#define SH_PI_AFI_FIRST_ERROR_HUNG_BUS_MASK      0x0000000000200000
-
-/*   SH_PI_AFI_FIRST_ERROR_RSP_PARITY                                   */
-/*   Description:  Parity error detecte during response phase           */
-#define SH_PI_AFI_FIRST_ERROR_RSP_PARITY_SHFT    22
-#define SH_PI_AFI_FIRST_ERROR_RSP_PARITY_MASK    0x0000000000400000
-
-/*   SH_PI_AFI_FIRST_ERROR_IOQ_OVERRUN                                  */
-/*   Description:  Over run error detected on IOQ                       */
-#define SH_PI_AFI_FIRST_ERROR_IOQ_OVERRUN_SHFT   23
-#define SH_PI_AFI_FIRST_ERROR_IOQ_OVERRUN_MASK   0x0000000000800000
-
-/*   SH_PI_AFI_FIRST_ERROR_REQ_FORMAT                                   */
-/*   Description:  FSB request format not supported                     */
-#define SH_PI_AFI_FIRST_ERROR_REQ_FORMAT_SHFT    24
-#define SH_PI_AFI_FIRST_ERROR_REQ_FORMAT_MASK    0x0000000001000000
-
-/*   SH_PI_AFI_FIRST_ERROR_ADDR_ACCESS                                  */
-/*   Description:  Access to Address is not supported                   */
-#define SH_PI_AFI_FIRST_ERROR_ADDR_ACCESS_SHFT   25
-#define SH_PI_AFI_FIRST_ERROR_ADDR_ACCESS_MASK   0x0000000002000000
-
-/*   SH_PI_AFI_FIRST_ERROR_REQ_PARITY                                   */
-/*   Description:  Parity error detected during request phase           */
-#define SH_PI_AFI_FIRST_ERROR_REQ_PARITY_SHFT    26
-#define SH_PI_AFI_FIRST_ERROR_REQ_PARITY_MASK    0x0000000004000000
-
-/*   SH_PI_AFI_FIRST_ERROR_ADDR_PARITY                                  */
-/*   Description:  Parity error detected on address                     */
-#define SH_PI_AFI_FIRST_ERROR_ADDR_PARITY_SHFT   27
-#define SH_PI_AFI_FIRST_ERROR_ADDR_PARITY_MASK   0x0000000008000000
-
-/*   SH_PI_AFI_FIRST_ERROR_SHUB_FSB_DQE                                 */
-/*   Description:  SHUB_FSB_DQE                                         */
-#define SH_PI_AFI_FIRST_ERROR_SHUB_FSB_DQE_SHFT  28
-#define SH_PI_AFI_FIRST_ERROR_SHUB_FSB_DQE_MASK  0x0000000010000000
-
-/*   SH_PI_AFI_FIRST_ERROR_SHUB_FSB_UCE                                 */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_AFI_FIRST_ERROR_SHUB_FSB_UCE_SHFT  29
-#define SH_PI_AFI_FIRST_ERROR_SHUB_FSB_UCE_MASK  0x0000000020000000
-
-/*   SH_PI_AFI_FIRST_ERROR_SHUB_FSB_CE                                  */
-/*   Description:  An correctable ECC error was detected                */
-#define SH_PI_AFI_FIRST_ERROR_SHUB_FSB_CE_SHFT   30
-#define SH_PI_AFI_FIRST_ERROR_SHUB_FSB_CE_MASK   0x0000000040000000
-
-/*   SH_PI_AFI_FIRST_ERROR_LIVELOCK                                     */
-/*   Description:  AFI livelock error was detected                      */
-#define SH_PI_AFI_FIRST_ERROR_LIVELOCK_SHFT      31
-#define SH_PI_AFI_FIRST_ERROR_LIVELOCK_MASK      0x0000000080000000
-
-/*   SH_PI_AFI_FIRST_ERROR_BAD_SNOOP                                    */
-/*   Description:  AFI bad snoop error was detected                     */
-#define SH_PI_AFI_FIRST_ERROR_BAD_SNOOP_SHFT     32
-#define SH_PI_AFI_FIRST_ERROR_BAD_SNOOP_MASK     0x0000000100000000
-
-/*   SH_PI_AFI_FIRST_ERROR_FSB_TBL_MISS                                 */
-/*   Description:  AFI FSB request table miss error was detected        */
-#define SH_PI_AFI_FIRST_ERROR_FSB_TBL_MISS_SHFT  33
-#define SH_PI_AFI_FIRST_ERROR_FSB_TBL_MISS_MASK  0x0000000200000000
-
-/*   SH_PI_AFI_FIRST_ERROR_MSG_LEN                                      */
-/*   Description:  Runt or Obese message received from SIC              */
-#define SH_PI_AFI_FIRST_ERROR_MSG_LEN_SHFT       34
-#define SH_PI_AFI_FIRST_ERROR_MSG_LEN_MASK       0x0000000400000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_CAM_ADDRESS_READ_DATA"                */
-/*                    CRB CAM MMR Address Read Data                     */
-/* ==================================================================== */
-
-#define SH_PI_CAM_ADDRESS_READ_DATA              0x0000000120060100
-#define SH_PI_CAM_ADDRESS_READ_DATA_MASK         0x8000ffffffffffff
-#define SH_PI_CAM_ADDRESS_READ_DATA_INIT         0x0000000000000000
-
-/*   SH_PI_CAM_ADDRESS_READ_DATA_CAM_ADDR                               */
-/*   Description:  CRB CAM Address Read Data.                           */
-#define SH_PI_CAM_ADDRESS_READ_DATA_CAM_ADDR_SHFT 0
-#define SH_PI_CAM_ADDRESS_READ_DATA_CAM_ADDR_MASK 0x0000ffffffffffff
-
-/*   SH_PI_CAM_ADDRESS_READ_DATA_CAM_ADDR_VAL                           */
-/*   Description:  CRB CAM Address Read Data Valid.                     */
-#define SH_PI_CAM_ADDRESS_READ_DATA_CAM_ADDR_VAL_SHFT 63
-#define SH_PI_CAM_ADDRESS_READ_DATA_CAM_ADDR_VAL_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CAM_LPRA_READ_DATA"                  */
-/*                      CRB CAM MMR LPRA Read Data                      */
-/* ==================================================================== */
-
-#define SH_PI_CAM_LPRA_READ_DATA                 0x0000000120060180
-#define SH_PI_CAM_LPRA_READ_DATA_MASK            0xffffffffffffffff
-#define SH_PI_CAM_LPRA_READ_DATA_INIT            0x0000000000000000
-
-/*   SH_PI_CAM_LPRA_READ_DATA_CAM_LPRA                                  */
-/*   Description:  CRB CAM LPRA read data.                              */
-#define SH_PI_CAM_LPRA_READ_DATA_CAM_LPRA_SHFT   0
-#define SH_PI_CAM_LPRA_READ_DATA_CAM_LPRA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CAM_STATE_READ_DATA"                 */
-/*                     CRB CAM MMR State Read Data                      */
-/* ==================================================================== */
-
-#define SH_PI_CAM_STATE_READ_DATA                0x0000000120060200
-#define SH_PI_CAM_STATE_READ_DATA_MASK           0x8003ffff0000003f
-#define SH_PI_CAM_STATE_READ_DATA_INIT           0x0000000000000000
-
-/*   SH_PI_CAM_STATE_READ_DATA_CAM_STATE                                */
-/*   Description:  CRB CAM State read data.                             */
-#define SH_PI_CAM_STATE_READ_DATA_CAM_STATE_SHFT 0
-#define SH_PI_CAM_STATE_READ_DATA_CAM_STATE_MASK 0x000000000000000f
-
-/*   SH_PI_CAM_STATE_READ_DATA_CAM_TO                                   */
-/*   Description:  CRB CAM Time-out Status.                             */
-#define SH_PI_CAM_STATE_READ_DATA_CAM_TO_SHFT    4
-#define SH_PI_CAM_STATE_READ_DATA_CAM_TO_MASK    0x0000000000000010
-
-/*   SH_PI_CAM_STATE_READ_DATA_CAM_STATE_RD_PEND                        */
-/*   Description:  CRB CAM State Read Pending.                          */
-#define SH_PI_CAM_STATE_READ_DATA_CAM_STATE_RD_PEND_SHFT 5
-#define SH_PI_CAM_STATE_READ_DATA_CAM_STATE_RD_PEND_MASK 0x0000000000000020
-
-/*   SH_PI_CAM_STATE_READ_DATA_CAM_LPRA                                 */
-/*   Description:  CRB LPRA Overflow Data.                              */
-#define SH_PI_CAM_STATE_READ_DATA_CAM_LPRA_SHFT  32
-#define SH_PI_CAM_STATE_READ_DATA_CAM_LPRA_MASK  0x0003ffff00000000
-
-/*   SH_PI_CAM_STATE_READ_DATA_CAM_RD_DATA_VAL                          */
-/*   Description:  CRB CAM MMR read data is valid.                      */
-#define SH_PI_CAM_STATE_READ_DATA_CAM_RD_DATA_VAL_SHFT 63
-#define SH_PI_CAM_STATE_READ_DATA_CAM_RD_DATA_VAL_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CORRECTED_DETAIL_1"                  */
-/*                      PI Corrected Error Detail                       */
-/* ==================================================================== */
-
-#define SH_PI_CORRECTED_DETAIL_1                 0x0000000120060280
-#define SH_PI_CORRECTED_DETAIL_1_MASK            0xffffffffffffffff
-#define SH_PI_CORRECTED_DETAIL_1_INIT            0x0000000000000000
-
-/*   SH_PI_CORRECTED_DETAIL_1_ADDRESS                                   */
-/*   Description:  Address of Message that logged Correctable Error     */
-#define SH_PI_CORRECTED_DETAIL_1_ADDRESS_SHFT    0
-#define SH_PI_CORRECTED_DETAIL_1_ADDRESS_MASK    0x0000ffffffffffff
-
-/*   SH_PI_CORRECTED_DETAIL_1_SYNDROME                                  */
-/*   Description:  Syndrome for double word data with Correctable Erro  */
-#define SH_PI_CORRECTED_DETAIL_1_SYNDROME_SHFT   48
-#define SH_PI_CORRECTED_DETAIL_1_SYNDROME_MASK   0x00ff000000000000
-
-/*   SH_PI_CORRECTED_DETAIL_1_DEP                                       */
-/*   Description:  DEP code for Double word in error                    */
-#define SH_PI_CORRECTED_DETAIL_1_DEP_SHFT        56
-#define SH_PI_CORRECTED_DETAIL_1_DEP_MASK        0xff00000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CORRECTED_DETAIL_2"                  */
-/*                     PI Corrected Error Detail 2                      */
-/* ==================================================================== */
-
-#define SH_PI_CORRECTED_DETAIL_2                 0x0000000120060300
-#define SH_PI_CORRECTED_DETAIL_2_MASK            0xffffffffffffffff
-#define SH_PI_CORRECTED_DETAIL_2_INIT            0x0000000000000000
-
-/*   SH_PI_CORRECTED_DETAIL_2_DATA                                      */
-/*   Description:  Double word data in error                            */
-#define SH_PI_CORRECTED_DETAIL_2_DATA_SHFT       0
-#define SH_PI_CORRECTED_DETAIL_2_DATA_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CORRECTED_DETAIL_3"                  */
-/*                     PI Corrected Error Detail 3                      */
-/* ==================================================================== */
-
-#define SH_PI_CORRECTED_DETAIL_3                 0x0000000120060380
-#define SH_PI_CORRECTED_DETAIL_3_MASK            0xffffffffffffffff
-#define SH_PI_CORRECTED_DETAIL_3_INIT            0x0000000000000000
-
-/*   SH_PI_CORRECTED_DETAIL_3_ADDRESS                                   */
-/*   Description:  Address of Message that logged Correctable Error     */
-#define SH_PI_CORRECTED_DETAIL_3_ADDRESS_SHFT    0
-#define SH_PI_CORRECTED_DETAIL_3_ADDRESS_MASK    0x0000ffffffffffff
-
-/*   SH_PI_CORRECTED_DETAIL_3_SYNDROME                                  */
-/*   Description:  Syndrome for double word data with Correctable Erro  */
-#define SH_PI_CORRECTED_DETAIL_3_SYNDROME_SHFT   48
-#define SH_PI_CORRECTED_DETAIL_3_SYNDROME_MASK   0x00ff000000000000
-
-/*   SH_PI_CORRECTED_DETAIL_3_DEP                                       */
-/*   Description:  DEP code for Double word in error                    */
-#define SH_PI_CORRECTED_DETAIL_3_DEP_SHFT        56
-#define SH_PI_CORRECTED_DETAIL_3_DEP_MASK        0xff00000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CORRECTED_DETAIL_4"                  */
-/*                     PI Corrected Error Detail 4                      */
-/* ==================================================================== */
-
-#define SH_PI_CORRECTED_DETAIL_4                 0x0000000120060400
-#define SH_PI_CORRECTED_DETAIL_4_MASK            0xffffffffffffffff
-#define SH_PI_CORRECTED_DETAIL_4_INIT            0x0000000000000000
-
-/*   SH_PI_CORRECTED_DETAIL_4_DATA                                      */
-/*   Description:  Double word data in error                            */
-#define SH_PI_CORRECTED_DETAIL_4_DATA_SHFT       0
-#define SH_PI_CORRECTED_DETAIL_4_DATA_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PI_CRBP_FIRST_ERROR"                   */
-/*                         PI CRBP First Error                          */
-/* ==================================================================== */
-
-#define SH_PI_CRBP_FIRST_ERROR                   0x0000000120060480
-#define SH_PI_CRBP_FIRST_ERROR_MASK              0x00000000001fffff
-#define SH_PI_CRBP_FIRST_ERROR_INIT              0x0000000000000000
-
-/*   SH_PI_CRBP_FIRST_ERROR_FSB_PROTO_ERR                               */
-/*   Description:  CRB's FSB pipe detected protocol table miss          */
-#define SH_PI_CRBP_FIRST_ERROR_FSB_PROTO_ERR_SHFT 0
-#define SH_PI_CRBP_FIRST_ERROR_FSB_PROTO_ERR_MASK 0x0000000000000001
-
-/*   SH_PI_CRBP_FIRST_ERROR_GFX_RP_ERR                                  */
-/*   Description:  CRB's XB pipe received a GFX error reply             */
-#define SH_PI_CRBP_FIRST_ERROR_GFX_RP_ERR_SHFT   1
-#define SH_PI_CRBP_FIRST_ERROR_GFX_RP_ERR_MASK   0x0000000000000002
-
-/*   SH_PI_CRBP_FIRST_ERROR_XB_PROTO_ERR                                */
-/*   Description:  CRB's XB pipe detected protocol table miss           */
-#define SH_PI_CRBP_FIRST_ERROR_XB_PROTO_ERR_SHFT 2
-#define SH_PI_CRBP_FIRST_ERROR_XB_PROTO_ERR_MASK 0x0000000000000004
-
-/*   SH_PI_CRBP_FIRST_ERROR_MEM_RP_ERR                                  */
-/*   Description:  CRB's XB pipe received a memory error reply message  */
-#define SH_PI_CRBP_FIRST_ERROR_MEM_RP_ERR_SHFT   3
-#define SH_PI_CRBP_FIRST_ERROR_MEM_RP_ERR_MASK   0x0000000000000008
-
-/*   SH_PI_CRBP_FIRST_ERROR_PIO_RP_ERR                                  */
-/*   Description:  CRB's XB pipe received a PIO error reply message     */
-#define SH_PI_CRBP_FIRST_ERROR_PIO_RP_ERR_SHFT   4
-#define SH_PI_CRBP_FIRST_ERROR_PIO_RP_ERR_MASK   0x0000000000000010
-
-/*   SH_PI_CRBP_FIRST_ERROR_MEM_TO_ERR                                  */
-/*   Description:  CRB's XB pipe detected a CRB time-out                */
-#define SH_PI_CRBP_FIRST_ERROR_MEM_TO_ERR_SHFT   5
-#define SH_PI_CRBP_FIRST_ERROR_MEM_TO_ERR_MASK   0x0000000000000020
-
-/*   SH_PI_CRBP_FIRST_ERROR_PIO_TO_ERR                                  */
-/*   Description:  CRB's XB pipe detected a PIO time-out                */
-#define SH_PI_CRBP_FIRST_ERROR_PIO_TO_ERR_SHFT   6
-#define SH_PI_CRBP_FIRST_ERROR_PIO_TO_ERR_MASK   0x0000000000000040
-
-/*   SH_PI_CRBP_FIRST_ERROR_FSB_SHUB_UCE                                */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_CRBP_FIRST_ERROR_FSB_SHUB_UCE_SHFT 7
-#define SH_PI_CRBP_FIRST_ERROR_FSB_SHUB_UCE_MASK 0x0000000000000080
-
-/*   SH_PI_CRBP_FIRST_ERROR_FSB_SHUB_CE                                 */
-/*   Description:  A correctable ECC error was detected                 */
-#define SH_PI_CRBP_FIRST_ERROR_FSB_SHUB_CE_SHFT  8
-#define SH_PI_CRBP_FIRST_ERROR_FSB_SHUB_CE_MASK  0x0000000000000100
-
-/*   SH_PI_CRBP_FIRST_ERROR_MSG_COLOR_ERR                               */
-/*   Description:  Message color was wrong                              */
-#define SH_PI_CRBP_FIRST_ERROR_MSG_COLOR_ERR_SHFT 9
-#define SH_PI_CRBP_FIRST_ERROR_MSG_COLOR_ERR_MASK 0x0000000000000200
-
-/*   SH_PI_CRBP_FIRST_ERROR_MD_RQ_Q_OFLOW                               */
-/*   Description:  MD Request input buffer over flow error              */
-#define SH_PI_CRBP_FIRST_ERROR_MD_RQ_Q_OFLOW_SHFT 10
-#define SH_PI_CRBP_FIRST_ERROR_MD_RQ_Q_OFLOW_MASK 0x0000000000000400
-
-/*   SH_PI_CRBP_FIRST_ERROR_MD_RP_Q_OFLOW                               */
-/*   Description:  MD Reply input buffer over flow error                */
-#define SH_PI_CRBP_FIRST_ERROR_MD_RP_Q_OFLOW_SHFT 11
-#define SH_PI_CRBP_FIRST_ERROR_MD_RP_Q_OFLOW_MASK 0x0000000000000800
-
-/*   SH_PI_CRBP_FIRST_ERROR_XN_RQ_Q_OFLOW                               */
-/*   Description:  XN Request input buffer over flow error              */
-#define SH_PI_CRBP_FIRST_ERROR_XN_RQ_Q_OFLOW_SHFT 12
-#define SH_PI_CRBP_FIRST_ERROR_XN_RQ_Q_OFLOW_MASK 0x0000000000001000
-
-/*   SH_PI_CRBP_FIRST_ERROR_XN_RP_Q_OFLOW                               */
-/*   Description:  XN Reply input buffer over flow error                */
-#define SH_PI_CRBP_FIRST_ERROR_XN_RP_Q_OFLOW_SHFT 13
-#define SH_PI_CRBP_FIRST_ERROR_XN_RP_Q_OFLOW_MASK 0x0000000000002000
-
-/*   SH_PI_CRBP_FIRST_ERROR_NACK_OFLOW                                  */
-/*   Description:  NACK over flow error                                 */
-#define SH_PI_CRBP_FIRST_ERROR_NACK_OFLOW_SHFT   14
-#define SH_PI_CRBP_FIRST_ERROR_NACK_OFLOW_MASK   0x0000000000004000
-
-/*   SH_PI_CRBP_FIRST_ERROR_GFX_INT_0                                   */
-/*   Description:  GFX transfer interrupt for CPU 0                     */
-#define SH_PI_CRBP_FIRST_ERROR_GFX_INT_0_SHFT    15
-#define SH_PI_CRBP_FIRST_ERROR_GFX_INT_0_MASK    0x0000000000008000
-
-/*   SH_PI_CRBP_FIRST_ERROR_GFX_INT_1                                   */
-/*   Description:  GFX transfer interrupt for CPU 1                     */
-#define SH_PI_CRBP_FIRST_ERROR_GFX_INT_1_SHFT    16
-#define SH_PI_CRBP_FIRST_ERROR_GFX_INT_1_MASK    0x0000000000010000
-
-/*   SH_PI_CRBP_FIRST_ERROR_MD_RQ_CRD_OFLOW                             */
-/*   Description:  MD Request Credit Overflow Error                     */
-#define SH_PI_CRBP_FIRST_ERROR_MD_RQ_CRD_OFLOW_SHFT 17
-#define SH_PI_CRBP_FIRST_ERROR_MD_RQ_CRD_OFLOW_MASK 0x0000000000020000
-
-/*   SH_PI_CRBP_FIRST_ERROR_MD_RP_CRD_OFLOW                             */
-/*   Description:  MD Reply Credit Overflow Error                       */
-#define SH_PI_CRBP_FIRST_ERROR_MD_RP_CRD_OFLOW_SHFT 18
-#define SH_PI_CRBP_FIRST_ERROR_MD_RP_CRD_OFLOW_MASK 0x0000000000040000
-
-/*   SH_PI_CRBP_FIRST_ERROR_XN_RQ_CRD_OFLOW                             */
-/*   Description:  XN Request Credit Overflow Error                     */
-#define SH_PI_CRBP_FIRST_ERROR_XN_RQ_CRD_OFLOW_SHFT 19
-#define SH_PI_CRBP_FIRST_ERROR_XN_RQ_CRD_OFLOW_MASK 0x0000000000080000
-
-/*   SH_PI_CRBP_FIRST_ERROR_XN_RP_CRD_OFLOW                             */
-/*   Description:  XN Reply Credit Overflow Error                       */
-#define SH_PI_CRBP_FIRST_ERROR_XN_RP_CRD_OFLOW_SHFT 20
-#define SH_PI_CRBP_FIRST_ERROR_XN_RP_CRD_OFLOW_MASK 0x0000000000100000
-
-/* ==================================================================== */
-/*                   Register "SH_PI_ERROR_DETAIL_1"                    */
-/*                          PI Error Detail 1                           */
-/* ==================================================================== */
-
-#define SH_PI_ERROR_DETAIL_1                     0x0000000120060500
-#define SH_PI_ERROR_DETAIL_1_MASK                0xffffffffffffffff
-#define SH_PI_ERROR_DETAIL_1_INIT                0x0000000000000000
-
-/*   SH_PI_ERROR_DETAIL_1_STATUS                                        */
-/*   Description:  Error Detail 1                                       */
-#define SH_PI_ERROR_DETAIL_1_STATUS_SHFT         0
-#define SH_PI_ERROR_DETAIL_1_STATUS_MASK         0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_PI_ERROR_DETAIL_2"                    */
-/*                          PI Error Detail 2                           */
-/* ==================================================================== */
-
-#define SH_PI_ERROR_DETAIL_2                     0x0000000120060580
-#define SH_PI_ERROR_DETAIL_2_MASK                0xffffffffffffffff
-#define SH_PI_ERROR_DETAIL_2_INIT                0x0000000000000000
-
-/*   SH_PI_ERROR_DETAIL_2_STATUS                                        */
-/*   Description:  Error Status                                         */
-#define SH_PI_ERROR_DETAIL_2_STATUS_SHFT         0
-#define SH_PI_ERROR_DETAIL_2_STATUS_MASK         0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_PI_ERROR_OVERFLOW"                    */
-/*                          PI Error Overflow                           */
-/* ==================================================================== */
-
-#define SH_PI_ERROR_OVERFLOW                     0x0000000120060600
-#define SH_PI_ERROR_OVERFLOW_MASK                0x00000007ffffffff
-#define SH_PI_ERROR_OVERFLOW_INIT                0x0000000000000000
-
-/*   SH_PI_ERROR_OVERFLOW_FSB_PROTO_ERR                                 */
-/*   Description:  CRB's FSB pipe detected protocol table miss          */
-#define SH_PI_ERROR_OVERFLOW_FSB_PROTO_ERR_SHFT  0
-#define SH_PI_ERROR_OVERFLOW_FSB_PROTO_ERR_MASK  0x0000000000000001
-
-/*   SH_PI_ERROR_OVERFLOW_GFX_RP_ERR                                    */
-/*   Description:  CRB's XB pipe received another GFX reply error mess  */
-#define SH_PI_ERROR_OVERFLOW_GFX_RP_ERR_SHFT     1
-#define SH_PI_ERROR_OVERFLOW_GFX_RP_ERR_MASK     0x0000000000000002
-
-/*   SH_PI_ERROR_OVERFLOW_XB_PROTO_ERR                                  */
-/*   Description:  CRB's XB pipe detected another protocol table miss  */
-#define SH_PI_ERROR_OVERFLOW_XB_PROTO_ERR_SHFT   2
-#define SH_PI_ERROR_OVERFLOW_XB_PROTO_ERR_MASK   0x0000000000000004
-
-/*   SH_PI_ERROR_OVERFLOW_MEM_RP_ERR                                    */
-/*   Description:  CRB's XB pipe received another memory reply error m  */
-#define SH_PI_ERROR_OVERFLOW_MEM_RP_ERR_SHFT     3
-#define SH_PI_ERROR_OVERFLOW_MEM_RP_ERR_MASK     0x0000000000000008
-
-/*   SH_PI_ERROR_OVERFLOW_PIO_RP_ERR                                    */
-/*   Description:  CRB's XB pipe received another PIO reply error mess  */
-#define SH_PI_ERROR_OVERFLOW_PIO_RP_ERR_SHFT     4
-#define SH_PI_ERROR_OVERFLOW_PIO_RP_ERR_MASK     0x0000000000000010
-
-/*   SH_PI_ERROR_OVERFLOW_MEM_TO_ERR                                    */
-/*   Description:  CRB's XB pipe detected a CRB time-out                */
-#define SH_PI_ERROR_OVERFLOW_MEM_TO_ERR_SHFT     5
-#define SH_PI_ERROR_OVERFLOW_MEM_TO_ERR_MASK     0x0000000000000020
-
-/*   SH_PI_ERROR_OVERFLOW_PIO_TO_ERR                                    */
-/*   Description:  CRB's XB pipe detected a PIO time-out                */
-#define SH_PI_ERROR_OVERFLOW_PIO_TO_ERR_SHFT     6
-#define SH_PI_ERROR_OVERFLOW_PIO_TO_ERR_MASK     0x0000000000000040
-
-/*   SH_PI_ERROR_OVERFLOW_FSB_SHUB_UCE                                  */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_ERROR_OVERFLOW_FSB_SHUB_UCE_SHFT   7
-#define SH_PI_ERROR_OVERFLOW_FSB_SHUB_UCE_MASK   0x0000000000000080
-
-/*   SH_PI_ERROR_OVERFLOW_FSB_SHUB_CE                                   */
-/*   Description:  An correctable ECC error was detected                */
-#define SH_PI_ERROR_OVERFLOW_FSB_SHUB_CE_SHFT    8
-#define SH_PI_ERROR_OVERFLOW_FSB_SHUB_CE_MASK    0x0000000000000100
-
-/*   SH_PI_ERROR_OVERFLOW_MSG_COLOR_ERR                                 */
-/*   Description:  Message color was not correct                        */
-#define SH_PI_ERROR_OVERFLOW_MSG_COLOR_ERR_SHFT  9
-#define SH_PI_ERROR_OVERFLOW_MSG_COLOR_ERR_MASK  0x0000000000000200
-
-/*   SH_PI_ERROR_OVERFLOW_MD_RQ_Q_OFLOW                                 */
-/*   Description:  MD Request input buffer over flow error              */
-#define SH_PI_ERROR_OVERFLOW_MD_RQ_Q_OFLOW_SHFT  10
-#define SH_PI_ERROR_OVERFLOW_MD_RQ_Q_OFLOW_MASK  0x0000000000000400
-
-/*   SH_PI_ERROR_OVERFLOW_MD_RP_Q_OFLOW                                 */
-/*   Description:  MD Reply input buffer over flow error                */
-#define SH_PI_ERROR_OVERFLOW_MD_RP_Q_OFLOW_SHFT  11
-#define SH_PI_ERROR_OVERFLOW_MD_RP_Q_OFLOW_MASK  0x0000000000000800
-
-/*   SH_PI_ERROR_OVERFLOW_XN_RQ_Q_OFLOW                                 */
-/*   Description:  XN Request input buffer over flow error              */
-#define SH_PI_ERROR_OVERFLOW_XN_RQ_Q_OFLOW_SHFT  12
-#define SH_PI_ERROR_OVERFLOW_XN_RQ_Q_OFLOW_MASK  0x0000000000001000
-
-/*   SH_PI_ERROR_OVERFLOW_XN_RP_Q_OFLOW                                 */
-/*   Description:  XN Reply input buffer over flow error                */
-#define SH_PI_ERROR_OVERFLOW_XN_RP_Q_OFLOW_SHFT  13
-#define SH_PI_ERROR_OVERFLOW_XN_RP_Q_OFLOW_MASK  0x0000000000002000
-
-/*   SH_PI_ERROR_OVERFLOW_NACK_OFLOW                                    */
-/*   Description:  NACK over flow error                                 */
-#define SH_PI_ERROR_OVERFLOW_NACK_OFLOW_SHFT     14
-#define SH_PI_ERROR_OVERFLOW_NACK_OFLOW_MASK     0x0000000000004000
-
-/*   SH_PI_ERROR_OVERFLOW_GFX_INT_0                                     */
-/*   Description:  GFX transfer interrupt for CPU 0                     */
-#define SH_PI_ERROR_OVERFLOW_GFX_INT_0_SHFT      15
-#define SH_PI_ERROR_OVERFLOW_GFX_INT_0_MASK      0x0000000000008000
-
-/*   SH_PI_ERROR_OVERFLOW_GFX_INT_1                                     */
-/*   Description:  GFX transfer interrupt for CPU 1                     */
-#define SH_PI_ERROR_OVERFLOW_GFX_INT_1_SHFT      16
-#define SH_PI_ERROR_OVERFLOW_GFX_INT_1_MASK      0x0000000000010000
-
-/*   SH_PI_ERROR_OVERFLOW_MD_RQ_CRD_OFLOW                               */
-/*   Description:  MD Request Credit Overflow Error                     */
-#define SH_PI_ERROR_OVERFLOW_MD_RQ_CRD_OFLOW_SHFT 17
-#define SH_PI_ERROR_OVERFLOW_MD_RQ_CRD_OFLOW_MASK 0x0000000000020000
-
-/*   SH_PI_ERROR_OVERFLOW_MD_RP_CRD_OFLOW                               */
-/*   Description:  MD Reply Credit Overflow Error                       */
-#define SH_PI_ERROR_OVERFLOW_MD_RP_CRD_OFLOW_SHFT 18
-#define SH_PI_ERROR_OVERFLOW_MD_RP_CRD_OFLOW_MASK 0x0000000000040000
-
-/*   SH_PI_ERROR_OVERFLOW_XN_RQ_CRD_OFLOW                               */
-/*   Description:  XN Request Credit Overflow Error                     */
-#define SH_PI_ERROR_OVERFLOW_XN_RQ_CRD_OFLOW_SHFT 19
-#define SH_PI_ERROR_OVERFLOW_XN_RQ_CRD_OFLOW_MASK 0x0000000000080000
-
-/*   SH_PI_ERROR_OVERFLOW_XN_RP_CRD_OFLOW                               */
-/*   Description:  XN Reply Credit Overflow Error                       */
-#define SH_PI_ERROR_OVERFLOW_XN_RP_CRD_OFLOW_SHFT 20
-#define SH_PI_ERROR_OVERFLOW_XN_RP_CRD_OFLOW_MASK 0x0000000000100000
-
-/*   SH_PI_ERROR_OVERFLOW_HUNG_BUS                                      */
-/*   Description:  FSB is hung                                          */
-#define SH_PI_ERROR_OVERFLOW_HUNG_BUS_SHFT       21
-#define SH_PI_ERROR_OVERFLOW_HUNG_BUS_MASK       0x0000000000200000
-
-/*   SH_PI_ERROR_OVERFLOW_RSP_PARITY                                    */
-/*   Description:  Parity error detecte during response phase           */
-#define SH_PI_ERROR_OVERFLOW_RSP_PARITY_SHFT     22
-#define SH_PI_ERROR_OVERFLOW_RSP_PARITY_MASK     0x0000000000400000
-
-/*   SH_PI_ERROR_OVERFLOW_IOQ_OVERRUN                                   */
-/*   Description:  Over run error detected on IOQ                       */
-#define SH_PI_ERROR_OVERFLOW_IOQ_OVERRUN_SHFT    23
-#define SH_PI_ERROR_OVERFLOW_IOQ_OVERRUN_MASK    0x0000000000800000
-
-/*   SH_PI_ERROR_OVERFLOW_REQ_FORMAT                                    */
-/*   Description:  FSB request format not supported                     */
-#define SH_PI_ERROR_OVERFLOW_REQ_FORMAT_SHFT     24
-#define SH_PI_ERROR_OVERFLOW_REQ_FORMAT_MASK     0x0000000001000000
-
-/*   SH_PI_ERROR_OVERFLOW_ADDR_ACCESS                                   */
-/*   Description:  Access to Address is not supported                   */
-#define SH_PI_ERROR_OVERFLOW_ADDR_ACCESS_SHFT    25
-#define SH_PI_ERROR_OVERFLOW_ADDR_ACCESS_MASK    0x0000000002000000
-
-/*   SH_PI_ERROR_OVERFLOW_REQ_PARITY                                    */
-/*   Description:  Parity error detected during request phase           */
-#define SH_PI_ERROR_OVERFLOW_REQ_PARITY_SHFT     26
-#define SH_PI_ERROR_OVERFLOW_REQ_PARITY_MASK     0x0000000004000000
-
-/*   SH_PI_ERROR_OVERFLOW_ADDR_PARITY                                   */
-/*   Description:  Parity error detected on address                     */
-#define SH_PI_ERROR_OVERFLOW_ADDR_PARITY_SHFT    27
-#define SH_PI_ERROR_OVERFLOW_ADDR_PARITY_MASK    0x0000000008000000
-
-/*   SH_PI_ERROR_OVERFLOW_SHUB_FSB_DQE                                  */
-/*   Description:  SHUB_FSB_DQE                                         */
-#define SH_PI_ERROR_OVERFLOW_SHUB_FSB_DQE_SHFT   28
-#define SH_PI_ERROR_OVERFLOW_SHUB_FSB_DQE_MASK   0x0000000010000000
-
-/*   SH_PI_ERROR_OVERFLOW_SHUB_FSB_UCE                                  */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_ERROR_OVERFLOW_SHUB_FSB_UCE_SHFT   29
-#define SH_PI_ERROR_OVERFLOW_SHUB_FSB_UCE_MASK   0x0000000020000000
-
-/*   SH_PI_ERROR_OVERFLOW_SHUB_FSB_CE                                   */
-/*   Description:  An correctable ECC error was detected                */
-#define SH_PI_ERROR_OVERFLOW_SHUB_FSB_CE_SHFT    30
-#define SH_PI_ERROR_OVERFLOW_SHUB_FSB_CE_MASK    0x0000000040000000
-
-/*   SH_PI_ERROR_OVERFLOW_LIVELOCK                                      */
-/*   Description:  AFI livelock error was detected                      */
-#define SH_PI_ERROR_OVERFLOW_LIVELOCK_SHFT       31
-#define SH_PI_ERROR_OVERFLOW_LIVELOCK_MASK       0x0000000080000000
-
-/*   SH_PI_ERROR_OVERFLOW_BAD_SNOOP                                     */
-/*   Description:  AFI bad snoop error was detected                     */
-#define SH_PI_ERROR_OVERFLOW_BAD_SNOOP_SHFT      32
-#define SH_PI_ERROR_OVERFLOW_BAD_SNOOP_MASK      0x0000000100000000
-
-/*   SH_PI_ERROR_OVERFLOW_FSB_TBL_MISS                                  */
-/*   Description:  AFI FSB request table miss error was detected        */
-#define SH_PI_ERROR_OVERFLOW_FSB_TBL_MISS_SHFT   33
-#define SH_PI_ERROR_OVERFLOW_FSB_TBL_MISS_MASK   0x0000000200000000
-
-/*   SH_PI_ERROR_OVERFLOW_MSG_LENGTH                                    */
-/*   Description:  Message length error on received message from SIC    */
-#define SH_PI_ERROR_OVERFLOW_MSG_LENGTH_SHFT     34
-#define SH_PI_ERROR_OVERFLOW_MSG_LENGTH_MASK     0x0000000400000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_ERROR_OVERFLOW_ALIAS"                 */
-/*                       PI Error Overflow Alias                        */
-/* ==================================================================== */
-
-#define SH_PI_ERROR_OVERFLOW_ALIAS               0x0000000120060608
-
-/* ==================================================================== */
-/*                    Register "SH_PI_ERROR_SUMMARY"                    */
-/*                           PI Error Summary                           */
-/* ==================================================================== */
-
-#define SH_PI_ERROR_SUMMARY                      0x0000000120060680
-#define SH_PI_ERROR_SUMMARY_MASK                 0x00000007ffffffff
-#define SH_PI_ERROR_SUMMARY_INIT                 0x0000000000000000
-
-/*   SH_PI_ERROR_SUMMARY_FSB_PROTO_ERR                                  */
-/*   Description:  CRB's FSB pipe detected protocol table miss          */
-#define SH_PI_ERROR_SUMMARY_FSB_PROTO_ERR_SHFT   0
-#define SH_PI_ERROR_SUMMARY_FSB_PROTO_ERR_MASK   0x0000000000000001
-
-/*   SH_PI_ERROR_SUMMARY_GFX_RP_ERR                                     */
-/*   Description:  Graphic reply error message received                 */
-#define SH_PI_ERROR_SUMMARY_GFX_RP_ERR_SHFT      1
-#define SH_PI_ERROR_SUMMARY_GFX_RP_ERR_MASK      0x0000000000000002
-
-/*   SH_PI_ERROR_SUMMARY_XB_PROTO_ERR                                   */
-/*   Description:  CRB's XB pipe detected protocol table miss           */
-#define SH_PI_ERROR_SUMMARY_XB_PROTO_ERR_SHFT    2
-#define SH_PI_ERROR_SUMMARY_XB_PROTO_ERR_MASK    0x0000000000000004
-
-/*   SH_PI_ERROR_SUMMARY_MEM_RP_ERR                                     */
-/*   Description:  Memory reply error message received                  */
-#define SH_PI_ERROR_SUMMARY_MEM_RP_ERR_SHFT      3
-#define SH_PI_ERROR_SUMMARY_MEM_RP_ERR_MASK      0x0000000000000008
-
-/*   SH_PI_ERROR_SUMMARY_PIO_RP_ERR                                     */
-/*   Description:  PIO error reply message received                     */
-#define SH_PI_ERROR_SUMMARY_PIO_RP_ERR_SHFT      4
-#define SH_PI_ERROR_SUMMARY_PIO_RP_ERR_MASK      0x0000000000000010
-
-/*   SH_PI_ERROR_SUMMARY_MEM_TO_ERR                                     */
-/*   Description:  CRB's XB pipe detected a CRB time-out                */
-#define SH_PI_ERROR_SUMMARY_MEM_TO_ERR_SHFT      5
-#define SH_PI_ERROR_SUMMARY_MEM_TO_ERR_MASK      0x0000000000000020
-
-/*   SH_PI_ERROR_SUMMARY_PIO_TO_ERR                                     */
-/*   Description:  CRB's XB pipe detected a PIO time-out                */
-#define SH_PI_ERROR_SUMMARY_PIO_TO_ERR_SHFT      6
-#define SH_PI_ERROR_SUMMARY_PIO_TO_ERR_MASK      0x0000000000000040
-
-/*   SH_PI_ERROR_SUMMARY_FSB_SHUB_UCE                                   */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_ERROR_SUMMARY_FSB_SHUB_UCE_SHFT    7
-#define SH_PI_ERROR_SUMMARY_FSB_SHUB_UCE_MASK    0x0000000000000080
-
-/*   SH_PI_ERROR_SUMMARY_FSB_SHUB_CE                                    */
-/*   Description:  An correctable ECC error was detected                */
-#define SH_PI_ERROR_SUMMARY_FSB_SHUB_CE_SHFT     8
-#define SH_PI_ERROR_SUMMARY_FSB_SHUB_CE_MASK     0x0000000000000100
-
-/*   SH_PI_ERROR_SUMMARY_MSG_COLOR_ERR                                  */
-/*   Description:  Message color was wrong                              */
-#define SH_PI_ERROR_SUMMARY_MSG_COLOR_ERR_SHFT   9
-#define SH_PI_ERROR_SUMMARY_MSG_COLOR_ERR_MASK   0x0000000000000200
-
-/*   SH_PI_ERROR_SUMMARY_MD_RQ_Q_OFLOW                                  */
-/*   Description:  MD Request input buffer over flow error              */
-#define SH_PI_ERROR_SUMMARY_MD_RQ_Q_OFLOW_SHFT   10
-#define SH_PI_ERROR_SUMMARY_MD_RQ_Q_OFLOW_MASK   0x0000000000000400
-
-/*   SH_PI_ERROR_SUMMARY_MD_RP_Q_OFLOW                                  */
-/*   Description:  MD Reply input buffer over flow error                */
-#define SH_PI_ERROR_SUMMARY_MD_RP_Q_OFLOW_SHFT   11
-#define SH_PI_ERROR_SUMMARY_MD_RP_Q_OFLOW_MASK   0x0000000000000800
-
-/*   SH_PI_ERROR_SUMMARY_XN_RQ_Q_OFLOW                                  */
-/*   Description:  XN Request input buffer over flow error              */
-#define SH_PI_ERROR_SUMMARY_XN_RQ_Q_OFLOW_SHFT   12
-#define SH_PI_ERROR_SUMMARY_XN_RQ_Q_OFLOW_MASK   0x0000000000001000
-
-/*   SH_PI_ERROR_SUMMARY_XN_RP_Q_OFLOW                                  */
-/*   Description:  XN Reply input buffer over flow error                */
-#define SH_PI_ERROR_SUMMARY_XN_RP_Q_OFLOW_SHFT   13
-#define SH_PI_ERROR_SUMMARY_XN_RP_Q_OFLOW_MASK   0x0000000000002000
-
-/*   SH_PI_ERROR_SUMMARY_NACK_OFLOW                                     */
-/*   Description:  NACK over flow error                                 */
-#define SH_PI_ERROR_SUMMARY_NACK_OFLOW_SHFT      14
-#define SH_PI_ERROR_SUMMARY_NACK_OFLOW_MASK      0x0000000000004000
-
-/*   SH_PI_ERROR_SUMMARY_GFX_INT_0                                      */
-/*   Description:  GFX transfer interrupt for CPU 0                     */
-#define SH_PI_ERROR_SUMMARY_GFX_INT_0_SHFT       15
-#define SH_PI_ERROR_SUMMARY_GFX_INT_0_MASK       0x0000000000008000
-
-/*   SH_PI_ERROR_SUMMARY_GFX_INT_1                                      */
-/*   Description:  GFX transfer interrupt for CPU 1                     */
-#define SH_PI_ERROR_SUMMARY_GFX_INT_1_SHFT       16
-#define SH_PI_ERROR_SUMMARY_GFX_INT_1_MASK       0x0000000000010000
-
-/*   SH_PI_ERROR_SUMMARY_MD_RQ_CRD_OFLOW                                */
-/*   Description:  MD Request Credit Overflow Error                     */
-#define SH_PI_ERROR_SUMMARY_MD_RQ_CRD_OFLOW_SHFT 17
-#define SH_PI_ERROR_SUMMARY_MD_RQ_CRD_OFLOW_MASK 0x0000000000020000
-
-/*   SH_PI_ERROR_SUMMARY_MD_RP_CRD_OFLOW                                */
-/*   Description:  MD Reply Credit Overflow Error                       */
-#define SH_PI_ERROR_SUMMARY_MD_RP_CRD_OFLOW_SHFT 18
-#define SH_PI_ERROR_SUMMARY_MD_RP_CRD_OFLOW_MASK 0x0000000000040000
-
-/*   SH_PI_ERROR_SUMMARY_XN_RQ_CRD_OFLOW                                */
-/*   Description:  XN Request Credit Overflow Error                     */
-#define SH_PI_ERROR_SUMMARY_XN_RQ_CRD_OFLOW_SHFT 19
-#define SH_PI_ERROR_SUMMARY_XN_RQ_CRD_OFLOW_MASK 0x0000000000080000
-
-/*   SH_PI_ERROR_SUMMARY_XN_RP_CRD_OFLOW                                */
-/*   Description:  XN Reply Credit Overflow Error                       */
-#define SH_PI_ERROR_SUMMARY_XN_RP_CRD_OFLOW_SHFT 20
-#define SH_PI_ERROR_SUMMARY_XN_RP_CRD_OFLOW_MASK 0x0000000000100000
-
-/*   SH_PI_ERROR_SUMMARY_HUNG_BUS                                       */
-/*   Description:  FSB is hung                                          */
-#define SH_PI_ERROR_SUMMARY_HUNG_BUS_SHFT        21
-#define SH_PI_ERROR_SUMMARY_HUNG_BUS_MASK        0x0000000000200000
-
-/*   SH_PI_ERROR_SUMMARY_RSP_PARITY                                     */
-/*   Description:  Parity error detecte during response phase           */
-#define SH_PI_ERROR_SUMMARY_RSP_PARITY_SHFT      22
-#define SH_PI_ERROR_SUMMARY_RSP_PARITY_MASK      0x0000000000400000
-
-/*   SH_PI_ERROR_SUMMARY_IOQ_OVERRUN                                    */
-/*   Description:  Over run error detected on IOQ                       */
-#define SH_PI_ERROR_SUMMARY_IOQ_OVERRUN_SHFT     23
-#define SH_PI_ERROR_SUMMARY_IOQ_OVERRUN_MASK     0x0000000000800000
-
-/*   SH_PI_ERROR_SUMMARY_REQ_FORMAT                                     */
-/*   Description:  FSB request format not supported                     */
-#define SH_PI_ERROR_SUMMARY_REQ_FORMAT_SHFT      24
-#define SH_PI_ERROR_SUMMARY_REQ_FORMAT_MASK      0x0000000001000000
-
-/*   SH_PI_ERROR_SUMMARY_ADDR_ACCESS                                    */
-/*   Description:  Access to Address is not supported                   */
-#define SH_PI_ERROR_SUMMARY_ADDR_ACCESS_SHFT     25
-#define SH_PI_ERROR_SUMMARY_ADDR_ACCESS_MASK     0x0000000002000000
-
-/*   SH_PI_ERROR_SUMMARY_REQ_PARITY                                     */
-/*   Description:  Parity error detected during request phase           */
-#define SH_PI_ERROR_SUMMARY_REQ_PARITY_SHFT      26
-#define SH_PI_ERROR_SUMMARY_REQ_PARITY_MASK      0x0000000004000000
-
-/*   SH_PI_ERROR_SUMMARY_ADDR_PARITY                                    */
-/*   Description:  Parity error detected on address                     */
-#define SH_PI_ERROR_SUMMARY_ADDR_PARITY_SHFT     27
-#define SH_PI_ERROR_SUMMARY_ADDR_PARITY_MASK     0x0000000008000000
-
-/*   SH_PI_ERROR_SUMMARY_SHUB_FSB_DQE                                   */
-/*   Description:  SHUB_FSB_DQE error                                   */
-#define SH_PI_ERROR_SUMMARY_SHUB_FSB_DQE_SHFT    28
-#define SH_PI_ERROR_SUMMARY_SHUB_FSB_DQE_MASK    0x0000000010000000
-
-/*   SH_PI_ERROR_SUMMARY_SHUB_FSB_UCE                                   */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_ERROR_SUMMARY_SHUB_FSB_UCE_SHFT    29
-#define SH_PI_ERROR_SUMMARY_SHUB_FSB_UCE_MASK    0x0000000020000000
-
-/*   SH_PI_ERROR_SUMMARY_SHUB_FSB_CE                                    */
-/*   Description:  An correctable ECC error was detected                */
-#define SH_PI_ERROR_SUMMARY_SHUB_FSB_CE_SHFT     30
-#define SH_PI_ERROR_SUMMARY_SHUB_FSB_CE_MASK     0x0000000040000000
-
-/*   SH_PI_ERROR_SUMMARY_LIVELOCK                                       */
-/*   Description:  AFI livelock error was detected                      */
-#define SH_PI_ERROR_SUMMARY_LIVELOCK_SHFT        31
-#define SH_PI_ERROR_SUMMARY_LIVELOCK_MASK        0x0000000080000000
-
-/*   SH_PI_ERROR_SUMMARY_BAD_SNOOP                                      */
-/*   Description:  AFI bad snoop error was detected                     */
-#define SH_PI_ERROR_SUMMARY_BAD_SNOOP_SHFT       32
-#define SH_PI_ERROR_SUMMARY_BAD_SNOOP_MASK       0x0000000100000000
-
-/*   SH_PI_ERROR_SUMMARY_FSB_TBL_MISS                                   */
-/*   Description:  AFI FSB request table miss error was detected        */
-#define SH_PI_ERROR_SUMMARY_FSB_TBL_MISS_SHFT    33
-#define SH_PI_ERROR_SUMMARY_FSB_TBL_MISS_MASK    0x0000000200000000
-
-/*   SH_PI_ERROR_SUMMARY_MSG_LENGTH                                     */
-/*   Description:  Message length error on received message from SIC    */
-#define SH_PI_ERROR_SUMMARY_MSG_LENGTH_SHFT      34
-#define SH_PI_ERROR_SUMMARY_MSG_LENGTH_MASK      0x0000000400000000
-
-/* ==================================================================== */
-/*                 Register "SH_PI_ERROR_SUMMARY_ALIAS"                 */
-/*                        PI Error Summary Alias                        */
-/* ==================================================================== */
-
-#define SH_PI_ERROR_SUMMARY_ALIAS                0x0000000120060688
-
-/* ==================================================================== */
-/*                Register "SH_PI_EXPRESS_REPLY_STATUS"                 */
-/*                       PI Express Reply Status                        */
-/* ==================================================================== */
-
-#define SH_PI_EXPRESS_REPLY_STATUS               0x0000000120060700
-#define SH_PI_EXPRESS_REPLY_STATUS_MASK          0x0000000000000007
-#define SH_PI_EXPRESS_REPLY_STATUS_INIT          0x0000000000000000
-
-/*   SH_PI_EXPRESS_REPLY_STATUS_STATE                                   */
-/*   Description:  Express Reply State                                  */
-#define SH_PI_EXPRESS_REPLY_STATUS_STATE_SHFT    0
-#define SH_PI_EXPRESS_REPLY_STATUS_STATE_MASK    0x0000000000000007
-
-/* ==================================================================== */
-/*                     Register "SH_PI_FIRST_ERROR"                     */
-/*                            PI First Error                            */
-/* ==================================================================== */
-
-#define SH_PI_FIRST_ERROR                        0x0000000120060780
-#define SH_PI_FIRST_ERROR_MASK                   0x00000007ffffffff
-#define SH_PI_FIRST_ERROR_INIT                   0x0000000000000000
-
-/*   SH_PI_FIRST_ERROR_FSB_PROTO_ERR                                    */
-/*   Description:  CRB's FSB pipe detected protocol table miss          */
-#define SH_PI_FIRST_ERROR_FSB_PROTO_ERR_SHFT     0
-#define SH_PI_FIRST_ERROR_FSB_PROTO_ERR_MASK     0x0000000000000001
-
-/*   SH_PI_FIRST_ERROR_GFX_RP_ERR                                       */
-/*   Description:  Graphics error reply message received                */
-#define SH_PI_FIRST_ERROR_GFX_RP_ERR_SHFT        1
-#define SH_PI_FIRST_ERROR_GFX_RP_ERR_MASK        0x0000000000000002
-
-/*   SH_PI_FIRST_ERROR_XB_PROTO_ERR                                     */
-/*   Description:  CRB's XB pipe detected protocol table miss           */
-#define SH_PI_FIRST_ERROR_XB_PROTO_ERR_SHFT      2
-#define SH_PI_FIRST_ERROR_XB_PROTO_ERR_MASK      0x0000000000000004
-
-/*   SH_PI_FIRST_ERROR_MEM_RP_ERR                                       */
-/*   Description:  Memory reply error message received                  */
-#define SH_PI_FIRST_ERROR_MEM_RP_ERR_SHFT        3
-#define SH_PI_FIRST_ERROR_MEM_RP_ERR_MASK        0x0000000000000008
-
-/*   SH_PI_FIRST_ERROR_PIO_RP_ERR                                       */
-/*   Description:  PIO reply error message received                     */
-#define SH_PI_FIRST_ERROR_PIO_RP_ERR_SHFT        4
-#define SH_PI_FIRST_ERROR_PIO_RP_ERR_MASK        0x0000000000000010
-
-/*   SH_PI_FIRST_ERROR_MEM_TO_ERR                                       */
-/*   Description:  CRB's XB pipe detected a CRB time-out                */
-#define SH_PI_FIRST_ERROR_MEM_TO_ERR_SHFT        5
-#define SH_PI_FIRST_ERROR_MEM_TO_ERR_MASK        0x0000000000000020
-
-/*   SH_PI_FIRST_ERROR_PIO_TO_ERR                                       */
-/*   Description:  CRB's XB pipe detected a PIO time-out                */
-#define SH_PI_FIRST_ERROR_PIO_TO_ERR_SHFT        6
-#define SH_PI_FIRST_ERROR_PIO_TO_ERR_MASK        0x0000000000000040
-
-/*   SH_PI_FIRST_ERROR_FSB_SHUB_UCE                                     */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_FIRST_ERROR_FSB_SHUB_UCE_SHFT      7
-#define SH_PI_FIRST_ERROR_FSB_SHUB_UCE_MASK      0x0000000000000080
-
-/*   SH_PI_FIRST_ERROR_FSB_SHUB_CE                                      */
-/*   Description:  A correctable ECC error was detected                 */
-#define SH_PI_FIRST_ERROR_FSB_SHUB_CE_SHFT       8
-#define SH_PI_FIRST_ERROR_FSB_SHUB_CE_MASK       0x0000000000000100
-
-/*   SH_PI_FIRST_ERROR_MSG_COLOR_ERR                                    */
-/*   Description:  Message color was wrong                              */
-#define SH_PI_FIRST_ERROR_MSG_COLOR_ERR_SHFT     9
-#define SH_PI_FIRST_ERROR_MSG_COLOR_ERR_MASK     0x0000000000000200
-
-/*   SH_PI_FIRST_ERROR_MD_RQ_Q_OFLOW                                    */
-/*   Description:  MD Request input buffer over flow error              */
-#define SH_PI_FIRST_ERROR_MD_RQ_Q_OFLOW_SHFT     10
-#define SH_PI_FIRST_ERROR_MD_RQ_Q_OFLOW_MASK     0x0000000000000400
-
-/*   SH_PI_FIRST_ERROR_MD_RP_Q_OFLOW                                    */
-/*   Description:  MD Reply input buffer over flow error                */
-#define SH_PI_FIRST_ERROR_MD_RP_Q_OFLOW_SHFT     11
-#define SH_PI_FIRST_ERROR_MD_RP_Q_OFLOW_MASK     0x0000000000000800
-
-/*   SH_PI_FIRST_ERROR_XN_RQ_Q_OFLOW                                    */
-/*   Description:  XN Request input buffer over flow error              */
-#define SH_PI_FIRST_ERROR_XN_RQ_Q_OFLOW_SHFT     12
-#define SH_PI_FIRST_ERROR_XN_RQ_Q_OFLOW_MASK     0x0000000000001000
-
-/*   SH_PI_FIRST_ERROR_XN_RP_Q_OFLOW                                    */
-/*   Description:  XN Reply input buffer over flow error                */
-#define SH_PI_FIRST_ERROR_XN_RP_Q_OFLOW_SHFT     13
-#define SH_PI_FIRST_ERROR_XN_RP_Q_OFLOW_MASK     0x0000000000002000
-
-/*   SH_PI_FIRST_ERROR_NACK_OFLOW                                       */
-/*   Description:  NACK over flow error                                 */
-#define SH_PI_FIRST_ERROR_NACK_OFLOW_SHFT        14
-#define SH_PI_FIRST_ERROR_NACK_OFLOW_MASK        0x0000000000004000
-
-/*   SH_PI_FIRST_ERROR_GFX_INT_0                                        */
-/*   Description:  GFX transfer interrupt for CPU 0                     */
-#define SH_PI_FIRST_ERROR_GFX_INT_0_SHFT         15
-#define SH_PI_FIRST_ERROR_GFX_INT_0_MASK         0x0000000000008000
-
-/*   SH_PI_FIRST_ERROR_GFX_INT_1                                        */
-/*   Description:  GFX transfer interrupt for CPU 1                     */
-#define SH_PI_FIRST_ERROR_GFX_INT_1_SHFT         16
-#define SH_PI_FIRST_ERROR_GFX_INT_1_MASK         0x0000000000010000
-
-/*   SH_PI_FIRST_ERROR_MD_RQ_CRD_OFLOW                                  */
-/*   Description:  MD Request Credit Overflow Error                     */
-#define SH_PI_FIRST_ERROR_MD_RQ_CRD_OFLOW_SHFT   17
-#define SH_PI_FIRST_ERROR_MD_RQ_CRD_OFLOW_MASK   0x0000000000020000
-
-/*   SH_PI_FIRST_ERROR_MD_RP_CRD_OFLOW                                  */
-/*   Description:  MD Reply Credit Overflow Error                       */
-#define SH_PI_FIRST_ERROR_MD_RP_CRD_OFLOW_SHFT   18
-#define SH_PI_FIRST_ERROR_MD_RP_CRD_OFLOW_MASK   0x0000000000040000
-
-/*   SH_PI_FIRST_ERROR_XN_RQ_CRD_OFLOW                                  */
-/*   Description:  XN Request Credit Overflow Error                     */
-#define SH_PI_FIRST_ERROR_XN_RQ_CRD_OFLOW_SHFT   19
-#define SH_PI_FIRST_ERROR_XN_RQ_CRD_OFLOW_MASK   0x0000000000080000
-
-/*   SH_PI_FIRST_ERROR_XN_RP_CRD_OFLOW                                  */
-/*   Description:  XN Reply Credit Overflow Error                       */
-#define SH_PI_FIRST_ERROR_XN_RP_CRD_OFLOW_SHFT   20
-#define SH_PI_FIRST_ERROR_XN_RP_CRD_OFLOW_MASK   0x0000000000100000
-
-/*   SH_PI_FIRST_ERROR_HUNG_BUS                                         */
-/*   Description:  FSB is hung                                          */
-#define SH_PI_FIRST_ERROR_HUNG_BUS_SHFT          21
-#define SH_PI_FIRST_ERROR_HUNG_BUS_MASK          0x0000000000200000
-
-/*   SH_PI_FIRST_ERROR_RSP_PARITY                                       */
-/*   Description:  Parity error detecte during response phase           */
-#define SH_PI_FIRST_ERROR_RSP_PARITY_SHFT        22
-#define SH_PI_FIRST_ERROR_RSP_PARITY_MASK        0x0000000000400000
-
-/*   SH_PI_FIRST_ERROR_IOQ_OVERRUN                                      */
-/*   Description:  Over run error detected on IOQ                       */
-#define SH_PI_FIRST_ERROR_IOQ_OVERRUN_SHFT       23
-#define SH_PI_FIRST_ERROR_IOQ_OVERRUN_MASK       0x0000000000800000
-
-/*   SH_PI_FIRST_ERROR_REQ_FORMAT                                       */
-/*   Description:  FSB request format not supported                     */
-#define SH_PI_FIRST_ERROR_REQ_FORMAT_SHFT        24
-#define SH_PI_FIRST_ERROR_REQ_FORMAT_MASK        0x0000000001000000
-
-/*   SH_PI_FIRST_ERROR_ADDR_ACCESS                                      */
-/*   Description:  Access to Address is not supported                   */
-#define SH_PI_FIRST_ERROR_ADDR_ACCESS_SHFT       25
-#define SH_PI_FIRST_ERROR_ADDR_ACCESS_MASK       0x0000000002000000
-
-/*   SH_PI_FIRST_ERROR_REQ_PARITY                                       */
-/*   Description:  Parity error detected during request phase           */
-#define SH_PI_FIRST_ERROR_REQ_PARITY_SHFT        26
-#define SH_PI_FIRST_ERROR_REQ_PARITY_MASK        0x0000000004000000
-
-/*   SH_PI_FIRST_ERROR_ADDR_PARITY                                      */
-/*   Description:  Parity error detected on address                     */
-#define SH_PI_FIRST_ERROR_ADDR_PARITY_SHFT       27
-#define SH_PI_FIRST_ERROR_ADDR_PARITY_MASK       0x0000000008000000
-
-/*   SH_PI_FIRST_ERROR_SHUB_FSB_DQE                                     */
-/*   Description:  SHUB_FSB_DQE                                         */
-#define SH_PI_FIRST_ERROR_SHUB_FSB_DQE_SHFT      28
-#define SH_PI_FIRST_ERROR_SHUB_FSB_DQE_MASK      0x0000000010000000
-
-/*   SH_PI_FIRST_ERROR_SHUB_FSB_UCE                                     */
-/*   Description:  An un-correctable ECC error was detected             */
-#define SH_PI_FIRST_ERROR_SHUB_FSB_UCE_SHFT      29
-#define SH_PI_FIRST_ERROR_SHUB_FSB_UCE_MASK      0x0000000020000000
-
-/*   SH_PI_FIRST_ERROR_SHUB_FSB_CE                                      */
-/*   Description:  An correctable ECC error was detected                */
-#define SH_PI_FIRST_ERROR_SHUB_FSB_CE_SHFT       30
-#define SH_PI_FIRST_ERROR_SHUB_FSB_CE_MASK       0x0000000040000000
-
-/*   SH_PI_FIRST_ERROR_LIVELOCK                                         */
-/*   Description:  AFI livelock error was detected                      */
-#define SH_PI_FIRST_ERROR_LIVELOCK_SHFT          31
-#define SH_PI_FIRST_ERROR_LIVELOCK_MASK          0x0000000080000000
-
-/*   SH_PI_FIRST_ERROR_BAD_SNOOP                                        */
-/*   Description:  AFI bad snoop error was detected                     */
-#define SH_PI_FIRST_ERROR_BAD_SNOOP_SHFT         32
-#define SH_PI_FIRST_ERROR_BAD_SNOOP_MASK         0x0000000100000000
-
-/*   SH_PI_FIRST_ERROR_FSB_TBL_MISS                                     */
-/*   Description:  AFI FSB request table miss error was detected        */
-#define SH_PI_FIRST_ERROR_FSB_TBL_MISS_SHFT      33
-#define SH_PI_FIRST_ERROR_FSB_TBL_MISS_MASK      0x0000000200000000
-
-/*   SH_PI_FIRST_ERROR_MSG_LENGTH                                       */
-/*   Description:  Message length error on received message from SIC    */
-#define SH_PI_FIRST_ERROR_MSG_LENGTH_SHFT        34
-#define SH_PI_FIRST_ERROR_MSG_LENGTH_MASK        0x0000000400000000
-
-/* ==================================================================== */
-/*                  Register "SH_PI_FIRST_ERROR_ALIAS"                  */
-/*                         PI First Error Alias                         */
-/* ==================================================================== */
-
-#define SH_PI_FIRST_ERROR_ALIAS                  0x0000000120060788
-
-/* ==================================================================== */
-/*                Register "SH_PI_PI2MD_REPLY_VC_STATUS"                */
-/*                PI-to-MD Reply Virtual Channel Status                 */
-/* ==================================================================== */
-
-#define SH_PI_PI2MD_REPLY_VC_STATUS              0x0000000120060900
-#define SH_PI_PI2MD_REPLY_VC_STATUS_MASK         0x000000000000003f
-#define SH_PI_PI2MD_REPLY_VC_STATUS_INIT         0x0000000000000000
-
-/*   SH_PI_PI2MD_REPLY_VC_STATUS_OUTPUT_CRD_STAT                        */
-/*   Description:  Status of output credits                             */
-#define SH_PI_PI2MD_REPLY_VC_STATUS_OUTPUT_CRD_STAT_SHFT 0
-#define SH_PI_PI2MD_REPLY_VC_STATUS_OUTPUT_CRD_STAT_MASK 0x000000000000003f
-
-/* ==================================================================== */
-/*               Register "SH_PI_PI2MD_REQUEST_VC_STATUS"               */
-/*               PI-to-MD Request Virtual Channel Status                */
-/* ==================================================================== */
-
-#define SH_PI_PI2MD_REQUEST_VC_STATUS            0x0000000120060980
-#define SH_PI_PI2MD_REQUEST_VC_STATUS_MASK       0x000000000000003f
-#define SH_PI_PI2MD_REQUEST_VC_STATUS_INIT       0x0000000000000000
-
-/*   SH_PI_PI2MD_REQUEST_VC_STATUS_OUTPUT_CRD_STAT                      */
-/*   Description:  Status of output credits                             */
-#define SH_PI_PI2MD_REQUEST_VC_STATUS_OUTPUT_CRD_STAT_SHFT 0
-#define SH_PI_PI2MD_REQUEST_VC_STATUS_OUTPUT_CRD_STAT_MASK 0x000000000000003f
-
-/* ==================================================================== */
-/*                Register "SH_PI_PI2XN_REPLY_VC_STATUS"                */
-/*                PI-to-XN Reply Virtual Channel Status                 */
-/* ==================================================================== */
-
-#define SH_PI_PI2XN_REPLY_VC_STATUS              0x0000000120060a00
-#define SH_PI_PI2XN_REPLY_VC_STATUS_MASK         0x000000000000003f
-#define SH_PI_PI2XN_REPLY_VC_STATUS_INIT         0x0000000000000000
-
-/*   SH_PI_PI2XN_REPLY_VC_STATUS_OUTPUT_CRD_STAT                        */
-/*   Description:  Status of output credits                             */
-#define SH_PI_PI2XN_REPLY_VC_STATUS_OUTPUT_CRD_STAT_SHFT 0
-#define SH_PI_PI2XN_REPLY_VC_STATUS_OUTPUT_CRD_STAT_MASK 0x000000000000003f
-
-/* ==================================================================== */
-/*               Register "SH_PI_PI2XN_REQUEST_VC_STATUS"               */
-/*               PI-to-XN Request Virtual Channel Status                */
-/* ==================================================================== */
-
-#define SH_PI_PI2XN_REQUEST_VC_STATUS            0x0000000120060a80
-#define SH_PI_PI2XN_REQUEST_VC_STATUS_MASK       0x000000000000003f
-#define SH_PI_PI2XN_REQUEST_VC_STATUS_INIT       0x0000000000000000
-
-/*   SH_PI_PI2XN_REQUEST_VC_STATUS_OUTPUT_CRD_STAT                      */
-/*   Description:  Status of output credits                             */
-#define SH_PI_PI2XN_REQUEST_VC_STATUS_OUTPUT_CRD_STAT_SHFT 0
-#define SH_PI_PI2XN_REQUEST_VC_STATUS_OUTPUT_CRD_STAT_MASK 0x000000000000003f
-
-/* ==================================================================== */
-/*                Register "SH_PI_UNCORRECTED_DETAIL_1"                 */
-/*                    PI Uncorrected Error Detail 1                     */
-/* ==================================================================== */
-
-#define SH_PI_UNCORRECTED_DETAIL_1               0x0000000120060b00
-#define SH_PI_UNCORRECTED_DETAIL_1_MASK          0xffffffffffffffff
-#define SH_PI_UNCORRECTED_DETAIL_1_INIT          0x0000000000000000
-
-/*   SH_PI_UNCORRECTED_DETAIL_1_ADDRESS                                 */
-/*   Description:  Address of Message that logged Uncorrectable Error  */
-#define SH_PI_UNCORRECTED_DETAIL_1_ADDRESS_SHFT  0
-#define SH_PI_UNCORRECTED_DETAIL_1_ADDRESS_MASK  0x0000ffffffffffff
-
-/*   SH_PI_UNCORRECTED_DETAIL_1_SYNDROME                                */
-/*   Description:  Syndrome for double word data with Uncorrectable Er  */
-#define SH_PI_UNCORRECTED_DETAIL_1_SYNDROME_SHFT 48
-#define SH_PI_UNCORRECTED_DETAIL_1_SYNDROME_MASK 0x00ff000000000000
-
-/*   SH_PI_UNCORRECTED_DETAIL_1_DEP                                     */
-/*   Description:  DEP for Double word in error                         */
-#define SH_PI_UNCORRECTED_DETAIL_1_DEP_SHFT      56
-#define SH_PI_UNCORRECTED_DETAIL_1_DEP_MASK      0xff00000000000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_UNCORRECTED_DETAIL_2"                 */
-/*                    PI Uncorrected Error Detail 2                     */
-/* ==================================================================== */
-
-#define SH_PI_UNCORRECTED_DETAIL_2               0x0000000120060b80
-#define SH_PI_UNCORRECTED_DETAIL_2_MASK          0xffffffffffffffff
-#define SH_PI_UNCORRECTED_DETAIL_2_INIT          0x0000000000000000
-
-/*   SH_PI_UNCORRECTED_DETAIL_2_DATA                                    */
-/*   Description:  Double word data in error                            */
-#define SH_PI_UNCORRECTED_DETAIL_2_DATA_SHFT     0
-#define SH_PI_UNCORRECTED_DETAIL_2_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_PI_UNCORRECTED_DETAIL_3"                 */
-/*                    PI Uncorrected Error Detail 3                     */
-/* ==================================================================== */
-
-#define SH_PI_UNCORRECTED_DETAIL_3               0x0000000120060c00
-#define SH_PI_UNCORRECTED_DETAIL_3_MASK          0xffffffffffffffff
-#define SH_PI_UNCORRECTED_DETAIL_3_INIT          0x0000000000000000
-
-/*   SH_PI_UNCORRECTED_DETAIL_3_ADDRESS                                 */
-/*   Description:  Address of Message that logged Uncorrectable Error  */
-#define SH_PI_UNCORRECTED_DETAIL_3_ADDRESS_SHFT  0
-#define SH_PI_UNCORRECTED_DETAIL_3_ADDRESS_MASK  0x0000ffffffffffff
-
-/*   SH_PI_UNCORRECTED_DETAIL_3_SYNDROME                                */
-/*   Description:  Syndrome for double word data with Uncorrectable Er  */
-#define SH_PI_UNCORRECTED_DETAIL_3_SYNDROME_SHFT 48
-#define SH_PI_UNCORRECTED_DETAIL_3_SYNDROME_MASK 0x00ff000000000000
-
-/*   SH_PI_UNCORRECTED_DETAIL_3_DEP                                     */
-/*   Description:  DCP for Double word in error                         */
-#define SH_PI_UNCORRECTED_DETAIL_3_DEP_SHFT      56
-#define SH_PI_UNCORRECTED_DETAIL_3_DEP_MASK      0xff00000000000000
-
-/* ==================================================================== */
-/*                Register "SH_PI_UNCORRECTED_DETAIL_4"                 */
-/*                    PI Uncorrected Error Detail 4                     */
-/* ==================================================================== */
-
-#define SH_PI_UNCORRECTED_DETAIL_4               0x0000000120060c80
-#define SH_PI_UNCORRECTED_DETAIL_4_MASK          0xffffffffffffffff
-#define SH_PI_UNCORRECTED_DETAIL_4_INIT          0x0000000000000000
-
-/*   SH_PI_UNCORRECTED_DETAIL_4_DATA                                    */
-/*   Description:  Double word data in error                            */
-#define SH_PI_UNCORRECTED_DETAIL_4_DATA_SHFT     0
-#define SH_PI_UNCORRECTED_DETAIL_4_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_PI_MD2PI_REPLY_VC_STATUS"                */
-/*                MD-to-PI Reply Virtual Channel Status                 */
-/* ==================================================================== */
-
-#define SH_PI_MD2PI_REPLY_VC_STATUS              0x0000000120060800
-#define SH_PI_MD2PI_REPLY_VC_STATUS_MASK         0x0000000000000fff
-#define SH_PI_MD2PI_REPLY_VC_STATUS_INIT         0x0000000000000000
-
-/*   SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_HDR_CRD_STAT                     */
-/*   Description:  Status of input header credits                       */
-#define SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_HDR_CRD_STAT_SHFT 0
-#define SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_HDR_CRD_STAT_MASK 0x000000000000000f
-
-/*   SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_DAT_CRD_STAT                     */
-/*   Description:  Status of data credits                               */
-#define SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_DAT_CRD_STAT_SHFT 4
-#define SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_DAT_CRD_STAT_MASK 0x00000000000000f0
-
-/*   SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_QUEUE_STAT                       */
-/*   Description:  Status of MD Reply Input Queue                       */
-#define SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_QUEUE_STAT_SHFT 8
-#define SH_PI_MD2PI_REPLY_VC_STATUS_INPUT_QUEUE_STAT_MASK 0x0000000000000f00
-
-/* ==================================================================== */
-/*               Register "SH_PI_MD2PI_REQUEST_VC_STATUS"               */
-/*               MD-to-PI Request Virtual Channel Status                */
-/* ==================================================================== */
-
-#define SH_PI_MD2PI_REQUEST_VC_STATUS            0x0000000120060880
-#define SH_PI_MD2PI_REQUEST_VC_STATUS_MASK       0x0000000000000fff
-#define SH_PI_MD2PI_REQUEST_VC_STATUS_INIT       0x0000000000000000
-
-/*   SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_HDR_CRD_STAT                   */
-/*   Description:  Status of input header credits                       */
-#define SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_HDR_CRD_STAT_SHFT 0
-#define SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_HDR_CRD_STAT_MASK 0x000000000000000f
-
-/*   SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_DAT_CRD_STAT                   */
-/*   Description:  Status of input data credits                         */
-#define SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_DAT_CRD_STAT_SHFT 4
-#define SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_DAT_CRD_STAT_MASK 0x00000000000000f0
-
-/*   SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_QUEUE_STAT                     */
-/*   Description:  Status of MD Request Input Queue                     */
-#define SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_QUEUE_STAT_SHFT 8
-#define SH_PI_MD2PI_REQUEST_VC_STATUS_INPUT_QUEUE_STAT_MASK 0x0000000000000f00
-
-/* ==================================================================== */
-/*                Register "SH_PI_XN2PI_REPLY_VC_STATUS"                */
-/*                XN-to-PI Reply Virtual Channel Status                 */
-/* ==================================================================== */
-
-#define SH_PI_XN2PI_REPLY_VC_STATUS              0x0000000120060d00
-#define SH_PI_XN2PI_REPLY_VC_STATUS_MASK         0x0000000000000fff
-#define SH_PI_XN2PI_REPLY_VC_STATUS_INIT         0x0000000000000000
-
-/*   SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_HDR_CRD_STAT                     */
-/*   Description:  Status of input header credits                       */
-#define SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_HDR_CRD_STAT_SHFT 0
-#define SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_HDR_CRD_STAT_MASK 0x000000000000000f
-
-/*   SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_DAT_CRD_STAT                     */
-/*   Description:  Status of input data credits                         */
-#define SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_DAT_CRD_STAT_SHFT 4
-#define SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_DAT_CRD_STAT_MASK 0x00000000000000f0
-
-/*   SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_QUEUE_STAT                       */
-/*   Description:  Status of XN Reply Input Queue                       */
-#define SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_QUEUE_STAT_SHFT 8
-#define SH_PI_XN2PI_REPLY_VC_STATUS_INPUT_QUEUE_STAT_MASK 0x0000000000000f00
-
-/* ==================================================================== */
-/*               Register "SH_PI_XN2PI_REQUEST_VC_STATUS"               */
-/*               XN-to-PI Request Virtual Channel Status                */
-/* ==================================================================== */
-
-#define SH_PI_XN2PI_REQUEST_VC_STATUS            0x0000000120060d80
-#define SH_PI_XN2PI_REQUEST_VC_STATUS_MASK       0x0000000000000fff
-#define SH_PI_XN2PI_REQUEST_VC_STATUS_INIT       0x0000000000000000
-
-/*   SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_HDR_CRD_STAT                   */
-/*   Description:  Status of input header credits                       */
-#define SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_HDR_CRD_STAT_SHFT 0
-#define SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_HDR_CRD_STAT_MASK 0x000000000000000f
-
-/*   SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_DAT_CRD_STAT                   */
-/*   Description:  Status of input data credits                         */
-#define SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_DAT_CRD_STAT_SHFT 4
-#define SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_DAT_CRD_STAT_MASK 0x00000000000000f0
-
-/*   SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_QUEUE_STAT                     */
-/*   Description:  Status of XN Request Input Queue                     */
-#define SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_QUEUE_STAT_SHFT 8
-#define SH_PI_XN2PI_REQUEST_VC_STATUS_INPUT_QUEUE_STAT_MASK 0x0000000000000f00
-
-/* ==================================================================== */
-/*                     Register "SH_XNPI_SIC_FLOW"                      */
-/* ==================================================================== */
-
-#define SH_XNPI_SIC_FLOW                         0x0000000150030000
-#define SH_XNPI_SIC_FLOW_MASK                    0x9f1f1f1f1f1f9f9f
-#define SH_XNPI_SIC_FLOW_INIT                    0x0000080000080000
-
-/*   SH_XNPI_SIC_FLOW_DEBIT_VC0_WITHHOLD                                */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNPI_SIC_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNPI_SIC_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000001f
-
-/*   SH_XNPI_SIC_FLOW_DEBIT_VC0_FORCE_CRED                              */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNPI_SIC_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNPI_SIC_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNPI_SIC_FLOW_DEBIT_VC2_WITHHOLD                                */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNPI_SIC_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNPI_SIC_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000001f00
-
-/*   SH_XNPI_SIC_FLOW_DEBIT_VC2_FORCE_CRED                              */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNPI_SIC_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNPI_SIC_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNPI_SIC_FLOW_CREDIT_VC0_TEST                                   */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNPI_SIC_FLOW_CREDIT_VC0_TEST_SHFT    16
-#define SH_XNPI_SIC_FLOW_CREDIT_VC0_TEST_MASK    0x00000000001f0000
-
-/*   SH_XNPI_SIC_FLOW_CREDIT_VC0_DYN                                    */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNPI_SIC_FLOW_CREDIT_VC0_DYN_SHFT     24
-#define SH_XNPI_SIC_FLOW_CREDIT_VC0_DYN_MASK     0x000000001f000000
-
-/*   SH_XNPI_SIC_FLOW_CREDIT_VC0_CAP                                    */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNPI_SIC_FLOW_CREDIT_VC0_CAP_SHFT     32
-#define SH_XNPI_SIC_FLOW_CREDIT_VC0_CAP_MASK     0x0000001f00000000
-
-/*   SH_XNPI_SIC_FLOW_CREDIT_VC2_TEST                                   */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNPI_SIC_FLOW_CREDIT_VC2_TEST_SHFT    40
-#define SH_XNPI_SIC_FLOW_CREDIT_VC2_TEST_MASK    0x00001f0000000000
-
-/*   SH_XNPI_SIC_FLOW_CREDIT_VC2_DYN                                    */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNPI_SIC_FLOW_CREDIT_VC2_DYN_SHFT     48
-#define SH_XNPI_SIC_FLOW_CREDIT_VC2_DYN_MASK     0x001f000000000000
-
-/*   SH_XNPI_SIC_FLOW_CREDIT_VC2_CAP                                    */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNPI_SIC_FLOW_CREDIT_VC2_CAP_SHFT     56
-#define SH_XNPI_SIC_FLOW_CREDIT_VC2_CAP_MASK     0x1f00000000000000
-
-/*   SH_XNPI_SIC_FLOW_DISABLE_BYPASS_OUT                                */
-#define SH_XNPI_SIC_FLOW_DISABLE_BYPASS_OUT_SHFT 63
-#define SH_XNPI_SIC_FLOW_DISABLE_BYPASS_OUT_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_TO_NI0_PORT_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNPI_TO_NI0_PORT_FLOW                 0x0000000150030010
-#define SH_XNPI_TO_NI0_PORT_FLOW_MASK            0x3f3f003f3f00bfbf
-#define SH_XNPI_TO_NI0_PORT_FLOW_INIT            0x0000000000000000
-
-/*   SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC0_WITHHOLD                        */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC0_FORCE_CRED                      */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC2_WITHHOLD                        */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC2_FORCE_CRED                      */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNPI_TO_NI0_PORT_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC0_DYN                            */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC0_CAP                            */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC2_DYN                            */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC2_CAP                            */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNPI_TO_NI0_PORT_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_TO_NI1_PORT_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNPI_TO_NI1_PORT_FLOW                 0x0000000150030020
-#define SH_XNPI_TO_NI1_PORT_FLOW_MASK            0x3f3f003f3f00bfbf
-#define SH_XNPI_TO_NI1_PORT_FLOW_INIT            0x0000000000000000
-
-/*   SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC0_WITHHOLD                        */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC0_FORCE_CRED                      */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC2_WITHHOLD                        */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC2_FORCE_CRED                      */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNPI_TO_NI1_PORT_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC0_DYN                            */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC0_CAP                            */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC2_DYN                            */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC2_CAP                            */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNPI_TO_NI1_PORT_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_TO_IILB_PORT_FLOW"                 */
-/* ==================================================================== */
-
-#define SH_XNPI_TO_IILB_PORT_FLOW                0x0000000150030030
-#define SH_XNPI_TO_IILB_PORT_FLOW_MASK           0x3f3f003f3f00bfbf
-#define SH_XNPI_TO_IILB_PORT_FLOW_INIT           0x0000000000000000
-
-/*   SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC0_WITHHOLD                       */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC0_FORCE_CRED                     */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC2_WITHHOLD                       */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC2_FORCE_CRED                     */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNPI_TO_IILB_PORT_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC0_DYN                           */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC0_CAP                           */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC2_DYN                           */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC2_CAP                           */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNPI_TO_IILB_PORT_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*               Register "SH_XNPI_FR_NI0_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO            0x0000000150030040
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_MASK       0x00001f1f3f3f3f3f
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_INIT       0x00000c0c00000000
-
-/*   SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_DYN                        */
-/*   Description:  vc0 fifo entry dynamic value                         */
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_DYN_SHFT 0
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_DYN_MASK 0x000000000000003f
-
-/*   SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_CAP                        */
-/*   Description:  vc0 fifo entry captured value                        */
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_CAP_SHFT 8
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_CAP_MASK 0x0000000000003f00
-
-/*   SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_DYN                        */
-/*   Description:  vc2 fifo entry dynamic value                         */
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_DYN_SHFT 16
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_DYN_MASK 0x00000000003f0000
-
-/*   SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_CAP                        */
-/*   Description:  vc2 fifo entry  captured value                       */
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_CAP_SHFT 24
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_CAP_MASK 0x000000003f000000
-
-/*   SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_TEST                       */
-/*   Description:  vc0 test credits limit                               */
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_TEST_SHFT 32
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_TEST_MASK 0x0000001f00000000
-
-/*   SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_TEST                       */
-/*   Description:  vc2 test credits limit                               */
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_TEST_SHFT 40
-#define SH_XNPI_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_TEST_MASK 0x00001f0000000000
-
-/* ==================================================================== */
-/*               Register "SH_XNPI_FR_NI1_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO            0x0000000150030050
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_MASK       0x00001f1f3f3f3f3f
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_INIT       0x00000c0c00000000
-
-/*   SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_DYN                        */
-/*   Description:  vc0 fifo entry dynamic value                         */
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_DYN_SHFT 0
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_DYN_MASK 0x000000000000003f
-
-/*   SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_CAP                        */
-/*   Description:  vc0 fifo entry captured value                        */
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_CAP_SHFT 8
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_CAP_MASK 0x0000000000003f00
-
-/*   SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_DYN                        */
-/*   Description:  vc2 fifo entry dynamic value                         */
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_DYN_SHFT 16
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_DYN_MASK 0x00000000003f0000
-
-/*   SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_CAP                        */
-/*   Description:  vc2 fifo entry  captured value                       */
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_CAP_SHFT 24
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_CAP_MASK 0x000000003f000000
-
-/*   SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_TEST                       */
-/*   Description:  vc0 test credits limit                               */
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_TEST_SHFT 32
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_TEST_MASK 0x0000001f00000000
-
-/*   SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_TEST                       */
-/*   Description:  vc2 test credits limit                               */
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_TEST_SHFT 40
-#define SH_XNPI_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_TEST_MASK 0x00001f0000000000
-
-/* ==================================================================== */
-/*              Register "SH_XNPI_FR_IILB_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO           0x0000000150030060
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_MASK      0x00001f1f3f3f3f3f
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_INIT      0x00000c0c00000000
-
-/*   SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_DYN                       */
-/*   Description:  vc0 fifo entry dynamic value                         */
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_DYN_SHFT 0
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_DYN_MASK 0x000000000000003f
-
-/*   SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_CAP                       */
-/*   Description:  vc0 fifo entry captured value                        */
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_CAP_SHFT 8
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_CAP_MASK 0x0000000000003f00
-
-/*   SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_DYN                       */
-/*   Description:  vc2 fifo entry dynamic value                         */
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_DYN_SHFT 16
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_DYN_MASK 0x00000000003f0000
-
-/*   SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_CAP                       */
-/*   Description:  vc2 fifo entry  captured value                       */
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_CAP_SHFT 24
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_CAP_MASK 0x000000003f000000
-
-/*   SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_TEST                      */
-/*   Description:  vc0 test credits limit                               */
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_TEST_SHFT 32
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_TEST_MASK 0x0000001f00000000
-
-/*   SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_TEST                      */
-/*   Description:  vc2 test credits limit                               */
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_TEST_SHFT 40
-#define SH_XNPI_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_TEST_MASK 0x00001f0000000000
-
-/* ==================================================================== */
-/*                     Register "SH_XNMD_SIC_FLOW"                      */
-/* ==================================================================== */
-
-#define SH_XNMD_SIC_FLOW                         0x0000000150030100
-#define SH_XNMD_SIC_FLOW_MASK                    0x9f1f1f1f1f1f9f9f
-#define SH_XNMD_SIC_FLOW_INIT                    0x0000090000090000
-
-/*   SH_XNMD_SIC_FLOW_DEBIT_VC0_WITHHOLD                                */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNMD_SIC_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNMD_SIC_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000001f
-
-/*   SH_XNMD_SIC_FLOW_DEBIT_VC0_FORCE_CRED                              */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNMD_SIC_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNMD_SIC_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNMD_SIC_FLOW_DEBIT_VC2_WITHHOLD                                */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNMD_SIC_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNMD_SIC_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000001f00
-
-/*   SH_XNMD_SIC_FLOW_DEBIT_VC2_FORCE_CRED                              */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNMD_SIC_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNMD_SIC_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNMD_SIC_FLOW_CREDIT_VC0_TEST                                   */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNMD_SIC_FLOW_CREDIT_VC0_TEST_SHFT    16
-#define SH_XNMD_SIC_FLOW_CREDIT_VC0_TEST_MASK    0x00000000001f0000
-
-/*   SH_XNMD_SIC_FLOW_CREDIT_VC0_DYN                                    */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNMD_SIC_FLOW_CREDIT_VC0_DYN_SHFT     24
-#define SH_XNMD_SIC_FLOW_CREDIT_VC0_DYN_MASK     0x000000001f000000
-
-/*   SH_XNMD_SIC_FLOW_CREDIT_VC0_CAP                                    */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNMD_SIC_FLOW_CREDIT_VC0_CAP_SHFT     32
-#define SH_XNMD_SIC_FLOW_CREDIT_VC0_CAP_MASK     0x0000001f00000000
-
-/*   SH_XNMD_SIC_FLOW_CREDIT_VC2_TEST                                   */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNMD_SIC_FLOW_CREDIT_VC2_TEST_SHFT    40
-#define SH_XNMD_SIC_FLOW_CREDIT_VC2_TEST_MASK    0x00001f0000000000
-
-/*   SH_XNMD_SIC_FLOW_CREDIT_VC2_DYN                                    */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNMD_SIC_FLOW_CREDIT_VC2_DYN_SHFT     48
-#define SH_XNMD_SIC_FLOW_CREDIT_VC2_DYN_MASK     0x001f000000000000
-
-/*   SH_XNMD_SIC_FLOW_CREDIT_VC2_CAP                                    */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNMD_SIC_FLOW_CREDIT_VC2_CAP_SHFT     56
-#define SH_XNMD_SIC_FLOW_CREDIT_VC2_CAP_MASK     0x1f00000000000000
-
-/*   SH_XNMD_SIC_FLOW_DISABLE_BYPASS_OUT                                */
-#define SH_XNMD_SIC_FLOW_DISABLE_BYPASS_OUT_SHFT 63
-#define SH_XNMD_SIC_FLOW_DISABLE_BYPASS_OUT_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_TO_NI0_PORT_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNMD_TO_NI0_PORT_FLOW                 0x0000000150030110
-#define SH_XNMD_TO_NI0_PORT_FLOW_MASK            0x3f3f003f3f00bfbf
-#define SH_XNMD_TO_NI0_PORT_FLOW_INIT            0x0000000000000000
-
-/*   SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC0_WITHHOLD                        */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC0_FORCE_CRED                      */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC2_WITHHOLD                        */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC2_FORCE_CRED                      */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNMD_TO_NI0_PORT_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC0_DYN                            */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC0_CAP                            */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC2_DYN                            */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC2_CAP                            */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNMD_TO_NI0_PORT_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_TO_NI1_PORT_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNMD_TO_NI1_PORT_FLOW                 0x0000000150030120
-#define SH_XNMD_TO_NI1_PORT_FLOW_MASK            0x3f3f003f3f00bfbf
-#define SH_XNMD_TO_NI1_PORT_FLOW_INIT            0x0000000000000000
-
-/*   SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC0_WITHHOLD                        */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC0_FORCE_CRED                      */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC2_WITHHOLD                        */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC2_FORCE_CRED                      */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNMD_TO_NI1_PORT_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC0_DYN                            */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC0_CAP                            */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC2_DYN                            */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC2_CAP                            */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNMD_TO_NI1_PORT_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_TO_IILB_PORT_FLOW"                 */
-/* ==================================================================== */
-
-#define SH_XNMD_TO_IILB_PORT_FLOW                0x0000000150030130
-#define SH_XNMD_TO_IILB_PORT_FLOW_MASK           0x3f3f003f3f00bfbf
-#define SH_XNMD_TO_IILB_PORT_FLOW_INIT           0x0000000000000000
-
-/*   SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC0_WITHHOLD                       */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC0_FORCE_CRED                     */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC2_WITHHOLD                       */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC2_FORCE_CRED                     */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNMD_TO_IILB_PORT_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC0_DYN                           */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC0_DYN_SHFT 24
-#define SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC0_DYN_MASK 0x000000003f000000
-
-/*   SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC0_CAP                           */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC0_CAP_SHFT 32
-#define SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC0_CAP_MASK 0x0000003f00000000
-
-/*   SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC2_DYN                           */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC2_DYN_SHFT 48
-#define SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC2_DYN_MASK 0x003f000000000000
-
-/*   SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC2_CAP                           */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC2_CAP_SHFT 56
-#define SH_XNMD_TO_IILB_PORT_FLOW_CREDIT_VC2_CAP_MASK 0x3f00000000000000
-
-/* ==================================================================== */
-/*               Register "SH_XNMD_FR_NI0_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO            0x0000000150030140
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_MASK       0x00001f1f3f3f3f3f
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_INIT       0x00000c0c00000000
-
-/*   SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_DYN                        */
-/*   Description:  vc0 fifo entry dynamic value                         */
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_DYN_SHFT 0
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_DYN_MASK 0x000000000000003f
-
-/*   SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_CAP                        */
-/*   Description:  vc0 fifo entry captured value                        */
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_CAP_SHFT 8
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_CAP_MASK 0x0000000000003f00
-
-/*   SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_DYN                        */
-/*   Description:  vc2 fifo entry dynamic value                         */
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_DYN_SHFT 16
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_DYN_MASK 0x00000000003f0000
-
-/*   SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_CAP                        */
-/*   Description:  vc2 fifo entry  captured value                       */
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_CAP_SHFT 24
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_CAP_MASK 0x000000003f000000
-
-/*   SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_TEST                       */
-/*   Description:  vc0 test credits limit                               */
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_TEST_SHFT 32
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC0_TEST_MASK 0x0000001f00000000
-
-/*   SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_TEST                       */
-/*   Description:  vc2 test credits limit                               */
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_TEST_SHFT 40
-#define SH_XNMD_FR_NI0_PORT_FLOW_FIFO_ENTRY_VC2_TEST_MASK 0x00001f0000000000
-
-/* ==================================================================== */
-/*               Register "SH_XNMD_FR_NI1_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO            0x0000000150030150
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_MASK       0x00001f1f3f3f3f3f
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_INIT       0x00000c0c00000000
-
-/*   SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_DYN                        */
-/*   Description:  vc0 fifo entry dynamic value                         */
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_DYN_SHFT 0
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_DYN_MASK 0x000000000000003f
-
-/*   SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_CAP                        */
-/*   Description:  vc0 fifo entry captured value                        */
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_CAP_SHFT 8
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_CAP_MASK 0x0000000000003f00
-
-/*   SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_DYN                        */
-/*   Description:  vc2 fifo entry dynamic value                         */
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_DYN_SHFT 16
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_DYN_MASK 0x00000000003f0000
-
-/*   SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_CAP                        */
-/*   Description:  vc2 fifo entry  captured value                       */
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_CAP_SHFT 24
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_CAP_MASK 0x000000003f000000
-
-/*   SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_TEST                       */
-/*   Description:  vc0 test credits limit                               */
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_TEST_SHFT 32
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC0_TEST_MASK 0x0000001f00000000
-
-/*   SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_TEST                       */
-/*   Description:  vc2 test credits limit                               */
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_TEST_SHFT 40
-#define SH_XNMD_FR_NI1_PORT_FLOW_FIFO_ENTRY_VC2_TEST_MASK 0x00001f0000000000
-
-/* ==================================================================== */
-/*              Register "SH_XNMD_FR_IILB_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO           0x0000000150030160
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_MASK      0x00001f1f3f3f3f3f
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_INIT      0x00000c0c00000000
-
-/*   SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_DYN                       */
-/*   Description:  vc0 fifo entry dynamic value                         */
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_DYN_SHFT 0
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_DYN_MASK 0x000000000000003f
-
-/*   SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_CAP                       */
-/*   Description:  vc0 fifo entry captured value                        */
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_CAP_SHFT 8
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_CAP_MASK 0x0000000000003f00
-
-/*   SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_DYN                       */
-/*   Description:  vc2 fifo entry dynamic value                         */
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_DYN_SHFT 16
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_DYN_MASK 0x00000000003f0000
-
-/*   SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_CAP                       */
-/*   Description:  vc2 fifo entry  captured value                       */
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_CAP_SHFT 24
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_CAP_MASK 0x000000003f000000
-
-/*   SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_TEST                      */
-/*   Description:  vc0 test credits limit                               */
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_TEST_SHFT 32
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC0_TEST_MASK 0x0000001f00000000
-
-/*   SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_TEST                      */
-/*   Description:  vc2 test credits limit                               */
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_TEST_SHFT 40
-#define SH_XNMD_FR_IILB_PORT_FLOW_FIFO_ENTRY_VC2_TEST_MASK 0x00001f0000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNII_INTRA_FLOW"                     */
-/* ==================================================================== */
-
-#define SH_XNII_INTRA_FLOW                       0x0000000150030200
-#define SH_XNII_INTRA_FLOW_MASK                  0x7f7f7f7f7f7fbfbf
-#define SH_XNII_INTRA_FLOW_INIT                  0x00003f00003f0000
-
-/*   SH_XNII_INTRA_FLOW_DEBIT_VC0_WITHHOLD                              */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNII_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNII_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNII_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                            */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNII_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNII_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNII_INTRA_FLOW_DEBIT_VC2_WITHHOLD                              */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNII_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNII_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNII_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                            */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNII_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNII_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNII_INTRA_FLOW_CREDIT_VC0_TEST                                 */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNII_INTRA_FLOW_CREDIT_VC0_TEST_SHFT  16
-#define SH_XNII_INTRA_FLOW_CREDIT_VC0_TEST_MASK  0x00000000007f0000
-
-/*   SH_XNII_INTRA_FLOW_CREDIT_VC0_DYN                                  */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNII_INTRA_FLOW_CREDIT_VC0_DYN_SHFT   24
-#define SH_XNII_INTRA_FLOW_CREDIT_VC0_DYN_MASK   0x000000007f000000
-
-/*   SH_XNII_INTRA_FLOW_CREDIT_VC0_CAP                                  */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNII_INTRA_FLOW_CREDIT_VC0_CAP_SHFT   32
-#define SH_XNII_INTRA_FLOW_CREDIT_VC0_CAP_MASK   0x0000007f00000000
-
-/*   SH_XNII_INTRA_FLOW_CREDIT_VC2_TEST                                 */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNII_INTRA_FLOW_CREDIT_VC2_TEST_SHFT  40
-#define SH_XNII_INTRA_FLOW_CREDIT_VC2_TEST_MASK  0x00007f0000000000
-
-/*   SH_XNII_INTRA_FLOW_CREDIT_VC2_DYN                                  */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNII_INTRA_FLOW_CREDIT_VC2_DYN_SHFT   48
-#define SH_XNII_INTRA_FLOW_CREDIT_VC2_DYN_MASK   0x007f000000000000
-
-/*   SH_XNII_INTRA_FLOW_CREDIT_VC2_CAP                                  */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNII_INTRA_FLOW_CREDIT_VC2_CAP_SHFT   56
-#define SH_XNII_INTRA_FLOW_CREDIT_VC2_CAP_MASK   0x7f00000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNLB_INTRA_FLOW"                     */
-/* ==================================================================== */
-
-#define SH_XNLB_INTRA_FLOW                       0x0000000150030210
-#define SH_XNLB_INTRA_FLOW_MASK                  0xff7f7f7f7f7fbfbf
-#define SH_XNLB_INTRA_FLOW_INIT                  0x0000080000100000
-
-/*   SH_XNLB_INTRA_FLOW_DEBIT_VC0_WITHHOLD                              */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNLB_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNLB_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNLB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                            */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNLB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNLB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNLB_INTRA_FLOW_DEBIT_VC2_WITHHOLD                              */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNLB_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNLB_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNLB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                            */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNLB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNLB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNLB_INTRA_FLOW_CREDIT_VC0_TEST                                 */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC0_TEST_SHFT  16
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC0_TEST_MASK  0x00000000007f0000
-
-/*   SH_XNLB_INTRA_FLOW_CREDIT_VC0_DYN                                  */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC0_DYN_SHFT   24
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC0_DYN_MASK   0x000000007f000000
-
-/*   SH_XNLB_INTRA_FLOW_CREDIT_VC0_CAP                                  */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC0_CAP_SHFT   32
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC0_CAP_MASK   0x0000007f00000000
-
-/*   SH_XNLB_INTRA_FLOW_CREDIT_VC2_TEST                                 */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC2_TEST_SHFT  40
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC2_TEST_MASK  0x00007f0000000000
-
-/*   SH_XNLB_INTRA_FLOW_CREDIT_VC2_DYN                                  */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC2_DYN_SHFT   48
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC2_DYN_MASK   0x007f000000000000
-
-/*   SH_XNLB_INTRA_FLOW_CREDIT_VC2_CAP                                  */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC2_CAP_SHFT   56
-#define SH_XNLB_INTRA_FLOW_CREDIT_VC2_CAP_MASK   0x7f00000000000000
-
-/*   SH_XNLB_INTRA_FLOW_DISABLE_BYPASS_IN                               */
-#define SH_XNLB_INTRA_FLOW_DISABLE_BYPASS_IN_SHFT 63
-#define SH_XNLB_INTRA_FLOW_DISABLE_BYPASS_IN_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT        0x0000000150030220
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_MASK   0x7f7f007f7f00bfbf
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_INIT   0x0000000000000000
-
-/*   SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_WITHHOLD                     */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                   */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_WITHHOLD                     */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                   */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_DYN                          */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_CAP                          */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_DYN                          */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_CAP                          */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT        0x0000000150030230
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_MASK   0x7f7f007f7f00bfbf
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_INIT   0x0000000000000000
-
-/*   SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_WITHHOLD                     */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                   */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_WITHHOLD                     */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                   */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_DYN                          */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_CAP                          */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_DYN                          */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_CAP                          */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT         0x0000000150030240
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_MASK    0x7f7f007f7f00bfbf
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_INIT    0x0000000000000000
-
-/*   SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD                      */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                    */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD                      */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                    */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN                           */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP                           */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN                           */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP                           */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*            Register "SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT       0x0000000150030250
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_MASK  0x7f7f007f7f00bfbf
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_INIT  0x0000000000000000
-
-/*   SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD                    */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                  */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD                    */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                  */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN                         */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP                         */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN                         */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP                         */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT         0x0000000150030260
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_MASK    0x7f7f007f7f00bfbf
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_INIT    0x0000000000000000
-
-/*   SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD                      */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                    */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD                      */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                    */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN                           */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP                           */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN                           */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP                           */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*            Register "SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT       0x0000000150030270
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_MASK  0x00007f7f7f7f7f7f
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_INIT  0x000000000c00000c
-
-/*   SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_TEST                        */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_DYN                         */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_CAP                         */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_TEST                        */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_DYN                         */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_CAP                         */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*            Register "SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT       0x0000000150030280
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_MASK  0x00007f7f7f7f7f7f
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_INIT  0x000000000c00000c
-
-/*   SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_TEST                        */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_DYN                         */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_CAP                         */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_TEST                        */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_DYN                         */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_CAP                         */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT        0x0000000150030290
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_MASK   0x00007f7f7f7f7f7f
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_INIT   0x000000000c00000c
-
-/*   SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST                         */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN                          */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP                          */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST                         */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN                          */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP                          */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*            Register "SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT"            */
-/* ==================================================================== */
-
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT      0x00000001500302a0
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_MASK 0x00007f7f7f7f7f7f
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_INIT 0x000000000c00000c
-
-/*   SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST                       */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN                        */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP                        */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST                       */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN                        */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP                        */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT        0x00000001500302b0
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_MASK   0x00007f7f7f7f7f7f
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_INIT   0x000000000c00000c
-
-/*   SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST                         */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN                          */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP                          */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST                         */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN                          */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP                          */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*              Register "SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT          0x0000000150030300
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_MASK     0x7f7f007f7f00bfbf
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_INIT     0x0000000000000000
-
-/*   SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD                       */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                     */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD                       */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                     */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN                            */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP                            */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN                            */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP                            */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*              Register "SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT          0x0000000150030310
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_MASK     0x7f7f007f7f00bfbf
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_INIT     0x0000000000000000
-
-/*   SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD                       */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                     */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD                       */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                     */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN                            */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP                            */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN                            */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP                            */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT        0x0000000150030320
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_MASK   0x7f7f007f7f00bfbf
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_INIT   0x0000000000000000
-
-/*   SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD                     */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                   */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD                     */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                   */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN                          */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP                          */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN                          */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP                          */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT"              */
-/* ==================================================================== */
-
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT         0x0000000150030330
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_MASK    0x00007f7f7f7f7f7f
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_INIT    0x000000000c00000c
-
-/*   SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST                          */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN                           */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP                           */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST                          */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN                           */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP                           */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT"              */
-/* ==================================================================== */
-
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT         0x0000000150030340
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_MASK    0x00007f7f7f7f7f7f
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_INIT    0x000000000c00000c
-
-/*   SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST                          */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN                           */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP                           */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST                          */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN                           */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP                           */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*            Register "SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT       0x0000000150030350
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_MASK  0x00007f7f7f7f7f7f
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_INIT  0x000000000c00000c
-
-/*   SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST                        */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN                         */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP                         */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST                        */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN                         */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP                         */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_0_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI0_0_INTRANI_FLOW                  0x0000000150030360
-#define SH_XNNI0_0_INTRANI_FLOW_MASK             0x00000000000000bf
-#define SH_XNNI0_0_INTRANI_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI0_0_INTRANI_FLOW_DEBIT_VC0_WITHHOLD                         */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI0_0_INTRANI_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI0_0_INTRANI_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_0_INTRANI_FLOW_DEBIT_VC0_FORCE_CRED                       */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI0_0_INTRANI_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI0_0_INTRANI_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_1_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI0_1_INTRANI_FLOW                  0x0000000150030370
-#define SH_XNNI0_1_INTRANI_FLOW_MASK             0x00000000000000bf
-#define SH_XNNI0_1_INTRANI_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI0_1_INTRANI_FLOW_DEBIT_VC1_WITHHOLD                         */
-/*   Description:  vc1 withhold                                         */
-#define SH_XNNI0_1_INTRANI_FLOW_DEBIT_VC1_WITHHOLD_SHFT 0
-#define SH_XNNI0_1_INTRANI_FLOW_DEBIT_VC1_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_1_INTRANI_FLOW_DEBIT_VC1_FORCE_CRED                       */
-/*   Description:  Force Credit on VC1 from debit cntr                  */
-#define SH_XNNI0_1_INTRANI_FLOW_DEBIT_VC1_FORCE_CRED_SHFT 7
-#define SH_XNNI0_1_INTRANI_FLOW_DEBIT_VC1_FORCE_CRED_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_2_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI0_2_INTRANI_FLOW                  0x0000000150030380
-#define SH_XNNI0_2_INTRANI_FLOW_MASK             0x00000000000000bf
-#define SH_XNNI0_2_INTRANI_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI0_2_INTRANI_FLOW_DEBIT_VC2_WITHHOLD                         */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI0_2_INTRANI_FLOW_DEBIT_VC2_WITHHOLD_SHFT 0
-#define SH_XNNI0_2_INTRANI_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_2_INTRANI_FLOW_DEBIT_VC2_FORCE_CRED                       */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI0_2_INTRANI_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 7
-#define SH_XNNI0_2_INTRANI_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_3_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI0_3_INTRANI_FLOW                  0x0000000150030390
-#define SH_XNNI0_3_INTRANI_FLOW_MASK             0x00000000000000bf
-#define SH_XNNI0_3_INTRANI_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI0_3_INTRANI_FLOW_DEBIT_VC3_WITHHOLD                         */
-/*   Description:  vc3 withhold                                         */
-#define SH_XNNI0_3_INTRANI_FLOW_DEBIT_VC3_WITHHOLD_SHFT 0
-#define SH_XNNI0_3_INTRANI_FLOW_DEBIT_VC3_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI0_3_INTRANI_FLOW_DEBIT_VC3_FORCE_CRED                       */
-/*   Description:  Force Credit on VC3 from debit cntr                  */
-#define SH_XNNI0_3_INTRANI_FLOW_DEBIT_VC3_FORCE_CRED_SHFT 7
-#define SH_XNNI0_3_INTRANI_FLOW_DEBIT_VC3_FORCE_CRED_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_VCSWITCH_FLOW"                   */
-/* ==================================================================== */
-
-#define SH_XNNI0_VCSWITCH_FLOW                   0x00000001500303a0
-#define SH_XNNI0_VCSWITCH_FLOW_MASK              0x0000000701010101
-#define SH_XNNI0_VCSWITCH_FLOW_INIT              0x0000000000000000
-
-/*   SH_XNNI0_VCSWITCH_FLOW_NI_VCFIFO_DATELINE_SWITCH                   */
-/*   Description:  Swap VC0/2 with VC1/3                                */
-#define SH_XNNI0_VCSWITCH_FLOW_NI_VCFIFO_DATELINE_SWITCH_SHFT 0
-#define SH_XNNI0_VCSWITCH_FLOW_NI_VCFIFO_DATELINE_SWITCH_MASK 0x0000000000000001
-
-/*   SH_XNNI0_VCSWITCH_FLOW_PI_VCFIFO_SWITCH                            */
-/*   Description:  Swap VC0/2 with VC1/3                                */
-#define SH_XNNI0_VCSWITCH_FLOW_PI_VCFIFO_SWITCH_SHFT 8
-#define SH_XNNI0_VCSWITCH_FLOW_PI_VCFIFO_SWITCH_MASK 0x0000000000000100
-
-/*   SH_XNNI0_VCSWITCH_FLOW_MD_VCFIFO_SWITCH                            */
-/*   Description:  Swap VC0/2 with VC1/3                                */
-#define SH_XNNI0_VCSWITCH_FLOW_MD_VCFIFO_SWITCH_SHFT 16
-#define SH_XNNI0_VCSWITCH_FLOW_MD_VCFIFO_SWITCH_MASK 0x0000000000010000
-
-/*   SH_XNNI0_VCSWITCH_FLOW_IILB_VCFIFO_SWITCH                          */
-/*   Description:  Swap VC0/2 with VC1/3                                */
-#define SH_XNNI0_VCSWITCH_FLOW_IILB_VCFIFO_SWITCH_SHFT 24
-#define SH_XNNI0_VCSWITCH_FLOW_IILB_VCFIFO_SWITCH_MASK 0x0000000001000000
-
-/*   SH_XNNI0_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_IN                      */
-#define SH_XNNI0_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_IN_SHFT 32
-#define SH_XNNI0_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_IN_MASK 0x0000000100000000
-
-/*   SH_XNNI0_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_OUT                     */
-#define SH_XNNI0_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_OUT_SHFT 33
-#define SH_XNNI0_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_OUT_MASK 0x0000000200000000
-
-/*   SH_XNNI0_VCSWITCH_FLOW_ASYNC_FIFOES                                */
-#define SH_XNNI0_VCSWITCH_FLOW_ASYNC_FIFOES_SHFT 34
-#define SH_XNNI0_VCSWITCH_FLOW_ASYNC_FIFOES_MASK 0x0000000400000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI0_TIMER_REG"                     */
-/* ==================================================================== */
-
-#define SH_XNNI0_TIMER_REG                       0x00000001500303b0
-#define SH_XNNI0_TIMER_REG_MASK                  0x0000000100ffffff
-#define SH_XNNI0_TIMER_REG_INIT                  0x0000000000ffffff
-
-/*   SH_XNNI0_TIMER_REG_TIMEOUT_REG                                     */
-/*   Description:  Master Timeout Counter                               */
-#define SH_XNNI0_TIMER_REG_TIMEOUT_REG_SHFT      0
-#define SH_XNNI0_TIMER_REG_TIMEOUT_REG_MASK      0x0000000000ffffff
-
-/*   SH_XNNI0_TIMER_REG_LINKCLEANUP_REG                                 */
-/*   Description:  Link Clean Up                                        */
-#define SH_XNNI0_TIMER_REG_LINKCLEANUP_REG_SHFT  32
-#define SH_XNNI0_TIMER_REG_LINKCLEANUP_REG_MASK  0x0000000100000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_FIFO02_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI0_FIFO02_FLOW                     0x00000001500303c0
-#define SH_XNNI0_FIFO02_FLOW_MASK                0x00000f0f0f0f0f0f
-#define SH_XNNI0_FIFO02_FLOW_INIT                0x0000000000000000
-
-/*   SH_XNNI0_FIFO02_FLOW_COUNT_VC0_LIMIT                               */
-/*   Description:  limit reg zero disables functionality                */
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC0_LIMIT_SHFT 0
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC0_LIMIT_MASK 0x000000000000000f
-
-/*   SH_XNNI0_FIFO02_FLOW_COUNT_VC0_DYN                                 */
-/*   Description:  dynamic counter value                                */
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC0_DYN_SHFT  8
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC0_DYN_MASK  0x0000000000000f00
-
-/*   SH_XNNI0_FIFO02_FLOW_COUNT_VC0_CAP                                 */
-/*   Description:  captured counter value                               */
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC0_CAP_SHFT  16
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC0_CAP_MASK  0x00000000000f0000
-
-/*   SH_XNNI0_FIFO02_FLOW_COUNT_VC2_LIMIT                               */
-/*   Description:  limit reg zero disables functionality                */
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC2_LIMIT_SHFT 24
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC2_LIMIT_MASK 0x000000000f000000
-
-/*   SH_XNNI0_FIFO02_FLOW_COUNT_VC2_DYN                                 */
-/*   Description:  counter dynamic value                                */
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC2_DYN_SHFT  32
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC2_DYN_MASK  0x0000000f00000000
-
-/*   SH_XNNI0_FIFO02_FLOW_COUNT_VC2_CAP                                 */
-/*   Description:  captured counter value                               */
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC2_CAP_SHFT  40
-#define SH_XNNI0_FIFO02_FLOW_COUNT_VC2_CAP_MASK  0x00000f0000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_FIFO13_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI0_FIFO13_FLOW                     0x00000001500303d0
-#define SH_XNNI0_FIFO13_FLOW_MASK                0x00000f0f0f0f0f0f
-#define SH_XNNI0_FIFO13_FLOW_INIT                0x0000000000000000
-
-/*   SH_XNNI0_FIFO13_FLOW_COUNT_VC1_LIMIT                               */
-/*   Description:  limit reg zero disables functionality                */
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC1_LIMIT_SHFT 0
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC1_LIMIT_MASK 0x000000000000000f
-
-/*   SH_XNNI0_FIFO13_FLOW_COUNT_VC1_DYN                                 */
-/*   Description:  dynamic counter value                                */
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC1_DYN_SHFT  8
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC1_DYN_MASK  0x0000000000000f00
-
-/*   SH_XNNI0_FIFO13_FLOW_COUNT_VC1_CAP                                 */
-/*   Description:  captured counter value                               */
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC1_CAP_SHFT  16
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC1_CAP_MASK  0x00000000000f0000
-
-/*   SH_XNNI0_FIFO13_FLOW_COUNT_VC3_LIMIT                               */
-/*   Description:  limit reg zero disables functionality                */
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC3_LIMIT_SHFT 24
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC3_LIMIT_MASK 0x000000000f000000
-
-/*   SH_XNNI0_FIFO13_FLOW_COUNT_VC3_DYN                                 */
-/*   Description:  counter dynamic value                                */
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC3_DYN_SHFT  32
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC3_DYN_MASK  0x0000000f00000000
-
-/*   SH_XNNI0_FIFO13_FLOW_COUNT_VC3_CAP                                 */
-/*   Description:  captured counter value                               */
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC3_CAP_SHFT  40
-#define SH_XNNI0_FIFO13_FLOW_COUNT_VC3_CAP_MASK  0x00000f0000000000
-
-/* ==================================================================== */
-/*                     Register "SH_XNNI0_NI_FLOW"                      */
-/* ==================================================================== */
-
-#define SH_XNNI0_NI_FLOW                         0x00000001500303e0
-#define SH_XNNI0_NI_FLOW_MASK                    0xff0fff0fff0fff0f
-#define SH_XNNI0_NI_FLOW_INIT                    0x0000000000000000
-
-/*   SH_XNNI0_NI_FLOW_VC0_LIMIT                                         */
-/*   Description:  vc0 limit reg, zero disables functionality           */
-#define SH_XNNI0_NI_FLOW_VC0_LIMIT_SHFT          0
-#define SH_XNNI0_NI_FLOW_VC0_LIMIT_MASK          0x000000000000000f
-
-/*   SH_XNNI0_NI_FLOW_VC0_DYN                                           */
-/*   Description:  vc0 counter dynamic value                            */
-#define SH_XNNI0_NI_FLOW_VC0_DYN_SHFT            8
-#define SH_XNNI0_NI_FLOW_VC0_DYN_MASK            0x0000000000000f00
-
-/*   SH_XNNI0_NI_FLOW_VC0_CAP                                           */
-/*   Description:  vc0 counter captured value                           */
-#define SH_XNNI0_NI_FLOW_VC0_CAP_SHFT            12
-#define SH_XNNI0_NI_FLOW_VC0_CAP_MASK            0x000000000000f000
-
-/*   SH_XNNI0_NI_FLOW_VC1_LIMIT                                         */
-/*   Description:  vc1 limit reg, zero disables functionality           */
-#define SH_XNNI0_NI_FLOW_VC1_LIMIT_SHFT          16
-#define SH_XNNI0_NI_FLOW_VC1_LIMIT_MASK          0x00000000000f0000
-
-/*   SH_XNNI0_NI_FLOW_VC1_DYN                                           */
-/*   Description:  vc1 counter dynamic value                            */
-#define SH_XNNI0_NI_FLOW_VC1_DYN_SHFT            24
-#define SH_XNNI0_NI_FLOW_VC1_DYN_MASK            0x000000000f000000
-
-/*   SH_XNNI0_NI_FLOW_VC1_CAP                                           */
-/*   Description:  vc1 counter captured value                           */
-#define SH_XNNI0_NI_FLOW_VC1_CAP_SHFT            28
-#define SH_XNNI0_NI_FLOW_VC1_CAP_MASK            0x00000000f0000000
-
-/*   SH_XNNI0_NI_FLOW_VC2_LIMIT                                         */
-/*   Description:  vc2 limit reg, zero disables functionality           */
-#define SH_XNNI0_NI_FLOW_VC2_LIMIT_SHFT          32
-#define SH_XNNI0_NI_FLOW_VC2_LIMIT_MASK          0x0000000f00000000
-
-/*   SH_XNNI0_NI_FLOW_VC2_DYN                                           */
-/*   Description:  vc2 counter dynamic value                            */
-#define SH_XNNI0_NI_FLOW_VC2_DYN_SHFT            40
-#define SH_XNNI0_NI_FLOW_VC2_DYN_MASK            0x00000f0000000000
-
-/*   SH_XNNI0_NI_FLOW_VC2_CAP                                           */
-/*   Description:  vc2 counter captured value                           */
-#define SH_XNNI0_NI_FLOW_VC2_CAP_SHFT            44
-#define SH_XNNI0_NI_FLOW_VC2_CAP_MASK            0x0000f00000000000
-
-/*   SH_XNNI0_NI_FLOW_VC3_LIMIT                                         */
-/*   Description:  vc3 limit reg, zero disables functionality           */
-#define SH_XNNI0_NI_FLOW_VC3_LIMIT_SHFT          48
-#define SH_XNNI0_NI_FLOW_VC3_LIMIT_MASK          0x000f000000000000
-
-/*   SH_XNNI0_NI_FLOW_VC3_DYN                                           */
-/*   Description:  vc3 counter dynamic value                            */
-#define SH_XNNI0_NI_FLOW_VC3_DYN_SHFT            56
-#define SH_XNNI0_NI_FLOW_VC3_DYN_MASK            0x0f00000000000000
-
-/*   SH_XNNI0_NI_FLOW_VC3_CAP                                           */
-/*   Description:  vc3 counter captured value                           */
-#define SH_XNNI0_NI_FLOW_VC3_CAP_SHFT            60
-#define SH_XNNI0_NI_FLOW_VC3_CAP_MASK            0xf000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI0_DEAD_FLOW"                     */
-/* ==================================================================== */
-
-#define SH_XNNI0_DEAD_FLOW                       0x00000001500303f0
-#define SH_XNNI0_DEAD_FLOW_MASK                  0xff0fff0fff0fff0f
-#define SH_XNNI0_DEAD_FLOW_INIT                  0x0000000000000000
-
-/*   SH_XNNI0_DEAD_FLOW_VC0_LIMIT                                       */
-/*   Description:  vc0 limit reg, zero disables functionality           */
-#define SH_XNNI0_DEAD_FLOW_VC0_LIMIT_SHFT        0
-#define SH_XNNI0_DEAD_FLOW_VC0_LIMIT_MASK        0x000000000000000f
-
-/*   SH_XNNI0_DEAD_FLOW_VC0_DYN                                         */
-/*   Description:  vc0 counter dynamic value                            */
-#define SH_XNNI0_DEAD_FLOW_VC0_DYN_SHFT          8
-#define SH_XNNI0_DEAD_FLOW_VC0_DYN_MASK          0x0000000000000f00
-
-/*   SH_XNNI0_DEAD_FLOW_VC0_CAP                                         */
-/*   Description:  vc0 counter captured value                           */
-#define SH_XNNI0_DEAD_FLOW_VC0_CAP_SHFT          12
-#define SH_XNNI0_DEAD_FLOW_VC0_CAP_MASK          0x000000000000f000
-
-/*   SH_XNNI0_DEAD_FLOW_VC1_LIMIT                                       */
-/*   Description:  vc1 limit reg, zero disables functionality           */
-#define SH_XNNI0_DEAD_FLOW_VC1_LIMIT_SHFT        16
-#define SH_XNNI0_DEAD_FLOW_VC1_LIMIT_MASK        0x00000000000f0000
-
-/*   SH_XNNI0_DEAD_FLOW_VC1_DYN                                         */
-/*   Description:  vc1 counter dynamic value                            */
-#define SH_XNNI0_DEAD_FLOW_VC1_DYN_SHFT          24
-#define SH_XNNI0_DEAD_FLOW_VC1_DYN_MASK          0x000000000f000000
-
-/*   SH_XNNI0_DEAD_FLOW_VC1_CAP                                         */
-/*   Description:  vc1 counter captured value                           */
-#define SH_XNNI0_DEAD_FLOW_VC1_CAP_SHFT          28
-#define SH_XNNI0_DEAD_FLOW_VC1_CAP_MASK          0x00000000f0000000
-
-/*   SH_XNNI0_DEAD_FLOW_VC2_LIMIT                                       */
-/*   Description:  vc2 limit reg, zero disables functionality           */
-#define SH_XNNI0_DEAD_FLOW_VC2_LIMIT_SHFT        32
-#define SH_XNNI0_DEAD_FLOW_VC2_LIMIT_MASK        0x0000000f00000000
-
-/*   SH_XNNI0_DEAD_FLOW_VC2_DYN                                         */
-/*   Description:  vc2 counter dynamic value                            */
-#define SH_XNNI0_DEAD_FLOW_VC2_DYN_SHFT          40
-#define SH_XNNI0_DEAD_FLOW_VC2_DYN_MASK          0x00000f0000000000
-
-/*   SH_XNNI0_DEAD_FLOW_VC2_CAP                                         */
-/*   Description:  vc2 counter captured value                           */
-#define SH_XNNI0_DEAD_FLOW_VC2_CAP_SHFT          44
-#define SH_XNNI0_DEAD_FLOW_VC2_CAP_MASK          0x0000f00000000000
-
-/*   SH_XNNI0_DEAD_FLOW_VC3_LIMIT                                       */
-/*   Description:  vc3 limit reg, zero disables functionality           */
-#define SH_XNNI0_DEAD_FLOW_VC3_LIMIT_SHFT        48
-#define SH_XNNI0_DEAD_FLOW_VC3_LIMIT_MASK        0x000f000000000000
-
-/*   SH_XNNI0_DEAD_FLOW_VC3_DYN                                         */
-/*   Description:  vc3 counter dynamic value                            */
-#define SH_XNNI0_DEAD_FLOW_VC3_DYN_SHFT          56
-#define SH_XNNI0_DEAD_FLOW_VC3_DYN_MASK          0x0f00000000000000
-
-/*   SH_XNNI0_DEAD_FLOW_VC3_CAP                                         */
-/*   Description:  vc3 counter captured value                           */
-#define SH_XNNI0_DEAD_FLOW_VC3_CAP_SHFT          60
-#define SH_XNNI0_DEAD_FLOW_VC3_CAP_MASK          0xf000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI0_INJECT_AGE"                    */
-/* ==================================================================== */
-
-#define SH_XNNI0_INJECT_AGE                      0x0000000150030400
-#define SH_XNNI0_INJECT_AGE_MASK                 0x000000000000ffff
-#define SH_XNNI0_INJECT_AGE_INIT                 0x0000000000000000
-
-/*   SH_XNNI0_INJECT_AGE_REQUEST_INJECT                                 */
-/*   Description:  Value of AGE field for outgoing requests             */
-#define SH_XNNI0_INJECT_AGE_REQUEST_INJECT_SHFT  0
-#define SH_XNNI0_INJECT_AGE_REQUEST_INJECT_MASK  0x00000000000000ff
-
-/*   SH_XNNI0_INJECT_AGE_REPLY_INJECT                                   */
-/*   Description:  Value of AGE field for outgoing replies              */
-#define SH_XNNI0_INJECT_AGE_REPLY_INJECT_SHFT    8
-#define SH_XNNI0_INJECT_AGE_REPLY_INJECT_MASK    0x000000000000ff00
-
-/* ==================================================================== */
-/*              Register "SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT          0x0000000150030500
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_MASK     0x7f7f007f7f00bfbf
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_INIT     0x0000000000000000
-
-/*   SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD                       */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                     */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD                       */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                     */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN                            */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP                            */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN                            */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP                            */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*              Register "SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT          0x0000000150030510
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_MASK     0x7f7f007f7f00bfbf
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_INIT     0x0000000000000000
-
-/*   SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD                       */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                     */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD                       */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                     */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN                            */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP                            */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN                            */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP                            */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT        0x0000000150030520
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_MASK   0x7f7f007f7f00bfbf
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_INIT   0x0000000000000000
-
-/*   SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD                     */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED                   */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/*   SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD                     */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD_SHFT 8
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x0000000000003f00
-
-/*   SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED                   */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 15
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000008000
-
-/*   SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN                          */
-/*   Description:  vc0 debit dynamic value                              */
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN_SHFT 24
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_DYN_MASK 0x000000007f000000
-
-/*   SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP                          */
-/*   Description:  vc0 debit captured value                             */
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP_SHFT 32
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC0_CAP_MASK 0x0000007f00000000
-
-/*   SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN                          */
-/*   Description:  vc2 debit dynamic value                              */
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN_SHFT 48
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_DYN_MASK 0x007f000000000000
-
-/*   SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP                          */
-/*   Description:  vc2 debit captured value                             */
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP_SHFT 56
-#define SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT_VC2_CAP_MASK 0x7f00000000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT"              */
-/* ==================================================================== */
-
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT         0x0000000150030530
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_MASK    0x00007f7f7f7f7f7f
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_INIT    0x000000000c00000c
-
-/*   SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST                          */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN                           */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP                           */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST                          */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN                           */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP                           */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*             Register "SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT"              */
-/* ==================================================================== */
-
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT         0x0000000150030540
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_MASK    0x00007f7f7f7f7f7f
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_INIT    0x000000000c00000c
-
-/*   SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST                          */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN                           */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP                           */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST                          */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN                           */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP                           */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*            Register "SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT       0x0000000150030550
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_MASK  0x00007f7f7f7f7f7f
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_INIT  0x000000000c00000c
-
-/*   SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST                        */
-/*   Description:  vc0 credit_test                                      */
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST_SHFT 0
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_TEST_MASK 0x000000000000007f
-
-/*   SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN                         */
-/*   Description:  vc0 credit dynamic value                             */
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN_SHFT 8
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_DYN_MASK 0x0000000000007f00
-
-/*   SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP                         */
-/*   Description:  vc0 credit captured value                            */
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP_SHFT 16
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC0_CAP_MASK 0x00000000007f0000
-
-/*   SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST                        */
-/*   Description:  vc2 credit_test                                      */
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST_SHFT 24
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_TEST_MASK 0x000000007f000000
-
-/*   SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN                         */
-/*   Description:  vc2 credit dynamic value                             */
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN_SHFT 32
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_DYN_MASK 0x0000007f00000000
-
-/*   SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP                         */
-/*   Description:  vc2 credit captured value                            */
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP_SHFT 40
-#define SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT_VC2_CAP_MASK 0x00007f0000000000
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_0_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI1_0_INTRANI_FLOW                  0x0000000150030560
-#define SH_XNNI1_0_INTRANI_FLOW_MASK             0x00000000000000bf
-#define SH_XNNI1_0_INTRANI_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI1_0_INTRANI_FLOW_DEBIT_VC0_WITHHOLD                         */
-/*   Description:  vc0 withhold                                         */
-#define SH_XNNI1_0_INTRANI_FLOW_DEBIT_VC0_WITHHOLD_SHFT 0
-#define SH_XNNI1_0_INTRANI_FLOW_DEBIT_VC0_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_0_INTRANI_FLOW_DEBIT_VC0_FORCE_CRED                       */
-/*   Description:  Force Credit on VC0 from debit cntr                  */
-#define SH_XNNI1_0_INTRANI_FLOW_DEBIT_VC0_FORCE_CRED_SHFT 7
-#define SH_XNNI1_0_INTRANI_FLOW_DEBIT_VC0_FORCE_CRED_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_1_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI1_1_INTRANI_FLOW                  0x0000000150030570
-#define SH_XNNI1_1_INTRANI_FLOW_MASK             0x00000000000000bf
-#define SH_XNNI1_1_INTRANI_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI1_1_INTRANI_FLOW_DEBIT_VC1_WITHHOLD                         */
-/*   Description:  vc1 withhold                                         */
-#define SH_XNNI1_1_INTRANI_FLOW_DEBIT_VC1_WITHHOLD_SHFT 0
-#define SH_XNNI1_1_INTRANI_FLOW_DEBIT_VC1_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_1_INTRANI_FLOW_DEBIT_VC1_FORCE_CRED                       */
-/*   Description:  Force Credit on VC1 from debit cntr                  */
-#define SH_XNNI1_1_INTRANI_FLOW_DEBIT_VC1_FORCE_CRED_SHFT 7
-#define SH_XNNI1_1_INTRANI_FLOW_DEBIT_VC1_FORCE_CRED_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_2_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI1_2_INTRANI_FLOW                  0x0000000150030580
-#define SH_XNNI1_2_INTRANI_FLOW_MASK             0x00000000000000bf
-#define SH_XNNI1_2_INTRANI_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI1_2_INTRANI_FLOW_DEBIT_VC2_WITHHOLD                         */
-/*   Description:  vc2 withhold                                         */
-#define SH_XNNI1_2_INTRANI_FLOW_DEBIT_VC2_WITHHOLD_SHFT 0
-#define SH_XNNI1_2_INTRANI_FLOW_DEBIT_VC2_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_2_INTRANI_FLOW_DEBIT_VC2_FORCE_CRED                       */
-/*   Description:  Force Credit on VC2 from debit cntr                  */
-#define SH_XNNI1_2_INTRANI_FLOW_DEBIT_VC2_FORCE_CRED_SHFT 7
-#define SH_XNNI1_2_INTRANI_FLOW_DEBIT_VC2_FORCE_CRED_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_3_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNNI1_3_INTRANI_FLOW                  0x0000000150030590
-#define SH_XNNI1_3_INTRANI_FLOW_MASK             0x00000000000000bf
-#define SH_XNNI1_3_INTRANI_FLOW_INIT             0x0000000000000000
-
-/*   SH_XNNI1_3_INTRANI_FLOW_DEBIT_VC3_WITHHOLD                         */
-/*   Description:  vc3 withhold                                         */
-#define SH_XNNI1_3_INTRANI_FLOW_DEBIT_VC3_WITHHOLD_SHFT 0
-#define SH_XNNI1_3_INTRANI_FLOW_DEBIT_VC3_WITHHOLD_MASK 0x000000000000003f
-
-/*   SH_XNNI1_3_INTRANI_FLOW_DEBIT_VC3_FORCE_CRED                       */
-/*   Description:  Force Credit on VC3 from debit cntr                  */
-#define SH_XNNI1_3_INTRANI_FLOW_DEBIT_VC3_FORCE_CRED_SHFT 7
-#define SH_XNNI1_3_INTRANI_FLOW_DEBIT_VC3_FORCE_CRED_MASK 0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_VCSWITCH_FLOW"                   */
-/* ==================================================================== */
-
-#define SH_XNNI1_VCSWITCH_FLOW                   0x00000001500305a0
-#define SH_XNNI1_VCSWITCH_FLOW_MASK              0x0000000701010101
-#define SH_XNNI1_VCSWITCH_FLOW_INIT              0x0000000000000000
-
-/*   SH_XNNI1_VCSWITCH_FLOW_NI_VCFIFO_DATELINE_SWITCH                   */
-/*   Description:  Swap VC0/2 with VC1/3                                */
-#define SH_XNNI1_VCSWITCH_FLOW_NI_VCFIFO_DATELINE_SWITCH_SHFT 0
-#define SH_XNNI1_VCSWITCH_FLOW_NI_VCFIFO_DATELINE_SWITCH_MASK 0x0000000000000001
-
-/*   SH_XNNI1_VCSWITCH_FLOW_PI_VCFIFO_SWITCH                            */
-/*   Description:  Swap VC0/2 with VC1/3                                */
-#define SH_XNNI1_VCSWITCH_FLOW_PI_VCFIFO_SWITCH_SHFT 8
-#define SH_XNNI1_VCSWITCH_FLOW_PI_VCFIFO_SWITCH_MASK 0x0000000000000100
-
-/*   SH_XNNI1_VCSWITCH_FLOW_MD_VCFIFO_SWITCH                            */
-/*   Description:  Swap VC0/2 with VC1/3                                */
-#define SH_XNNI1_VCSWITCH_FLOW_MD_VCFIFO_SWITCH_SHFT 16
-#define SH_XNNI1_VCSWITCH_FLOW_MD_VCFIFO_SWITCH_MASK 0x0000000000010000
-
-/*   SH_XNNI1_VCSWITCH_FLOW_IILB_VCFIFO_SWITCH                          */
-/*   Description:  Swap VC0/2 with VC1/3                                */
-#define SH_XNNI1_VCSWITCH_FLOW_IILB_VCFIFO_SWITCH_SHFT 24
-#define SH_XNNI1_VCSWITCH_FLOW_IILB_VCFIFO_SWITCH_MASK 0x0000000001000000
-
-/*   SH_XNNI1_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_IN                      */
-#define SH_XNNI1_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_IN_SHFT 32
-#define SH_XNNI1_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_IN_MASK 0x0000000100000000
-
-/*   SH_XNNI1_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_OUT                     */
-#define SH_XNNI1_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_OUT_SHFT 33
-#define SH_XNNI1_VCSWITCH_FLOW_DISABLE_SYNC_BYPASS_OUT_MASK 0x0000000200000000
-
-/*   SH_XNNI1_VCSWITCH_FLOW_ASYNC_FIFOES                                */
-#define SH_XNNI1_VCSWITCH_FLOW_ASYNC_FIFOES_SHFT 34
-#define SH_XNNI1_VCSWITCH_FLOW_ASYNC_FIFOES_MASK 0x0000000400000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI1_TIMER_REG"                     */
-/* ==================================================================== */
-
-#define SH_XNNI1_TIMER_REG                       0x00000001500305b0
-#define SH_XNNI1_TIMER_REG_MASK                  0x0000000100ffffff
-#define SH_XNNI1_TIMER_REG_INIT                  0x0000000000ffffff
-
-/*   SH_XNNI1_TIMER_REG_TIMEOUT_REG                                     */
-/*   Description:  Master Timeout Counter                               */
-#define SH_XNNI1_TIMER_REG_TIMEOUT_REG_SHFT      0
-#define SH_XNNI1_TIMER_REG_TIMEOUT_REG_MASK      0x0000000000ffffff
-
-/*   SH_XNNI1_TIMER_REG_LINKCLEANUP_REG                                 */
-/*   Description:  Link Clean Up                                        */
-#define SH_XNNI1_TIMER_REG_LINKCLEANUP_REG_SHFT  32
-#define SH_XNNI1_TIMER_REG_LINKCLEANUP_REG_MASK  0x0000000100000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_FIFO02_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI1_FIFO02_FLOW                     0x00000001500305c0
-#define SH_XNNI1_FIFO02_FLOW_MASK                0x00000f0f0f0f0f0f
-#define SH_XNNI1_FIFO02_FLOW_INIT                0x0000000000000000
-
-/*   SH_XNNI1_FIFO02_FLOW_COUNT_VC0_LIMIT                               */
-/*   Description:  limit reg zero disables functionality                */
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC0_LIMIT_SHFT 0
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC0_LIMIT_MASK 0x000000000000000f
-
-/*   SH_XNNI1_FIFO02_FLOW_COUNT_VC0_DYN                                 */
-/*   Description:  dynamic counter value                                */
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC0_DYN_SHFT  8
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC0_DYN_MASK  0x0000000000000f00
-
-/*   SH_XNNI1_FIFO02_FLOW_COUNT_VC0_CAP                                 */
-/*   Description:  captured counter value                               */
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC0_CAP_SHFT  16
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC0_CAP_MASK  0x00000000000f0000
-
-/*   SH_XNNI1_FIFO02_FLOW_COUNT_VC2_LIMIT                               */
-/*   Description:  limit reg zero disables functionality                */
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC2_LIMIT_SHFT 24
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC2_LIMIT_MASK 0x000000000f000000
-
-/*   SH_XNNI1_FIFO02_FLOW_COUNT_VC2_DYN                                 */
-/*   Description:  counter dynamic value                                */
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC2_DYN_SHFT  32
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC2_DYN_MASK  0x0000000f00000000
-
-/*   SH_XNNI1_FIFO02_FLOW_COUNT_VC2_CAP                                 */
-/*   Description:  captured counter value                               */
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC2_CAP_SHFT  40
-#define SH_XNNI1_FIFO02_FLOW_COUNT_VC2_CAP_MASK  0x00000f0000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_FIFO13_FLOW"                    */
-/* ==================================================================== */
-
-#define SH_XNNI1_FIFO13_FLOW                     0x00000001500305d0
-#define SH_XNNI1_FIFO13_FLOW_MASK                0x00000f0f0f0f0f0f
-#define SH_XNNI1_FIFO13_FLOW_INIT                0x0000000000000000
-
-/*   SH_XNNI1_FIFO13_FLOW_COUNT_VC1_LIMIT                               */
-/*   Description:  limit reg zero disables functionality                */
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC1_LIMIT_SHFT 0
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC1_LIMIT_MASK 0x000000000000000f
-
-/*   SH_XNNI1_FIFO13_FLOW_COUNT_VC1_DYN                                 */
-/*   Description:  dynamic counter value                                */
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC1_DYN_SHFT  8
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC1_DYN_MASK  0x0000000000000f00
-
-/*   SH_XNNI1_FIFO13_FLOW_COUNT_VC1_CAP                                 */
-/*   Description:  captured counter value                               */
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC1_CAP_SHFT  16
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC1_CAP_MASK  0x00000000000f0000
-
-/*   SH_XNNI1_FIFO13_FLOW_COUNT_VC3_LIMIT                               */
-/*   Description:  limit reg zero disables functionality                */
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC3_LIMIT_SHFT 24
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC3_LIMIT_MASK 0x000000000f000000
-
-/*   SH_XNNI1_FIFO13_FLOW_COUNT_VC3_DYN                                 */
-/*   Description:  counter dynamic value                                */
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC3_DYN_SHFT  32
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC3_DYN_MASK  0x0000000f00000000
-
-/*   SH_XNNI1_FIFO13_FLOW_COUNT_VC3_CAP                                 */
-/*   Description:  captured counter value                               */
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC3_CAP_SHFT  40
-#define SH_XNNI1_FIFO13_FLOW_COUNT_VC3_CAP_MASK  0x00000f0000000000
-
-/* ==================================================================== */
-/*                     Register "SH_XNNI1_NI_FLOW"                      */
-/* ==================================================================== */
-
-#define SH_XNNI1_NI_FLOW                         0x00000001500305e0
-#define SH_XNNI1_NI_FLOW_MASK                    0xff0fff0fff0fff0f
-#define SH_XNNI1_NI_FLOW_INIT                    0x0000000000000000
-
-/*   SH_XNNI1_NI_FLOW_VC0_LIMIT                                         */
-/*   Description:  vc0 limit reg, zero disables functionality           */
-#define SH_XNNI1_NI_FLOW_VC0_LIMIT_SHFT          0
-#define SH_XNNI1_NI_FLOW_VC0_LIMIT_MASK          0x000000000000000f
-
-/*   SH_XNNI1_NI_FLOW_VC0_DYN                                           */
-/*   Description:  vc0 counter dynamic value                            */
-#define SH_XNNI1_NI_FLOW_VC0_DYN_SHFT            8
-#define SH_XNNI1_NI_FLOW_VC0_DYN_MASK            0x0000000000000f00
-
-/*   SH_XNNI1_NI_FLOW_VC0_CAP                                           */
-/*   Description:  vc0 counter captured value                           */
-#define SH_XNNI1_NI_FLOW_VC0_CAP_SHFT            12
-#define SH_XNNI1_NI_FLOW_VC0_CAP_MASK            0x000000000000f000
-
-/*   SH_XNNI1_NI_FLOW_VC1_LIMIT                                         */
-/*   Description:  vc1 limit reg, zero disables functionality           */
-#define SH_XNNI1_NI_FLOW_VC1_LIMIT_SHFT          16
-#define SH_XNNI1_NI_FLOW_VC1_LIMIT_MASK          0x00000000000f0000
-
-/*   SH_XNNI1_NI_FLOW_VC1_DYN                                           */
-/*   Description:  vc1 counter dynamic value                            */
-#define SH_XNNI1_NI_FLOW_VC1_DYN_SHFT            24
-#define SH_XNNI1_NI_FLOW_VC1_DYN_MASK            0x000000000f000000
-
-/*   SH_XNNI1_NI_FLOW_VC1_CAP                                           */
-/*   Description:  vc1 counter captured value                           */
-#define SH_XNNI1_NI_FLOW_VC1_CAP_SHFT            28
-#define SH_XNNI1_NI_FLOW_VC1_CAP_MASK            0x00000000f0000000
-
-/*   SH_XNNI1_NI_FLOW_VC2_LIMIT                                         */
-/*   Description:  vc2 limit reg, zero disables functionality           */
-#define SH_XNNI1_NI_FLOW_VC2_LIMIT_SHFT          32
-#define SH_XNNI1_NI_FLOW_VC2_LIMIT_MASK          0x0000000f00000000
-
-/*   SH_XNNI1_NI_FLOW_VC2_DYN                                           */
-/*   Description:  vc2 counter dynamic value                            */
-#define SH_XNNI1_NI_FLOW_VC2_DYN_SHFT            40
-#define SH_XNNI1_NI_FLOW_VC2_DYN_MASK            0x00000f0000000000
-
-/*   SH_XNNI1_NI_FLOW_VC2_CAP                                           */
-/*   Description:  vc2 counter captured value                           */
-#define SH_XNNI1_NI_FLOW_VC2_CAP_SHFT            44
-#define SH_XNNI1_NI_FLOW_VC2_CAP_MASK            0x0000f00000000000
-
-/*   SH_XNNI1_NI_FLOW_VC3_LIMIT                                         */
-/*   Description:  vc3 limit reg, zero disables functionality           */
-#define SH_XNNI1_NI_FLOW_VC3_LIMIT_SHFT          48
-#define SH_XNNI1_NI_FLOW_VC3_LIMIT_MASK          0x000f000000000000
-
-/*   SH_XNNI1_NI_FLOW_VC3_DYN                                           */
-/*   Description:  vc3 counter dynamic value                            */
-#define SH_XNNI1_NI_FLOW_VC3_DYN_SHFT            56
-#define SH_XNNI1_NI_FLOW_VC3_DYN_MASK            0x0f00000000000000
-
-/*   SH_XNNI1_NI_FLOW_VC3_CAP                                           */
-/*   Description:  vc3 counter captured value                           */
-#define SH_XNNI1_NI_FLOW_VC3_CAP_SHFT            60
-#define SH_XNNI1_NI_FLOW_VC3_CAP_MASK            0xf000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI1_DEAD_FLOW"                     */
-/* ==================================================================== */
-
-#define SH_XNNI1_DEAD_FLOW                       0x00000001500305f0
-#define SH_XNNI1_DEAD_FLOW_MASK                  0xff0fff0fff0fff0f
-#define SH_XNNI1_DEAD_FLOW_INIT                  0x0000000000000000
-
-/*   SH_XNNI1_DEAD_FLOW_VC0_LIMIT                                       */
-/*   Description:  vc0 limit reg, zero disables functionality           */
-#define SH_XNNI1_DEAD_FLOW_VC0_LIMIT_SHFT        0
-#define SH_XNNI1_DEAD_FLOW_VC0_LIMIT_MASK        0x000000000000000f
-
-/*   SH_XNNI1_DEAD_FLOW_VC0_DYN                                         */
-/*   Description:  vc0 counter dynamic value                            */
-#define SH_XNNI1_DEAD_FLOW_VC0_DYN_SHFT          8
-#define SH_XNNI1_DEAD_FLOW_VC0_DYN_MASK          0x0000000000000f00
-
-/*   SH_XNNI1_DEAD_FLOW_VC0_CAP                                         */
-/*   Description:  vc0 counter captured value                           */
-#define SH_XNNI1_DEAD_FLOW_VC0_CAP_SHFT          12
-#define SH_XNNI1_DEAD_FLOW_VC0_CAP_MASK          0x000000000000f000
-
-/*   SH_XNNI1_DEAD_FLOW_VC1_LIMIT                                       */
-/*   Description:  vc1 limit reg, zero disables functionality           */
-#define SH_XNNI1_DEAD_FLOW_VC1_LIMIT_SHFT        16
-#define SH_XNNI1_DEAD_FLOW_VC1_LIMIT_MASK        0x00000000000f0000
-
-/*   SH_XNNI1_DEAD_FLOW_VC1_DYN                                         */
-/*   Description:  vc1 counter dynamic value                            */
-#define SH_XNNI1_DEAD_FLOW_VC1_DYN_SHFT          24
-#define SH_XNNI1_DEAD_FLOW_VC1_DYN_MASK          0x000000000f000000
-
-/*   SH_XNNI1_DEAD_FLOW_VC1_CAP                                         */
-/*   Description:  vc1 counter captured value                           */
-#define SH_XNNI1_DEAD_FLOW_VC1_CAP_SHFT          28
-#define SH_XNNI1_DEAD_FLOW_VC1_CAP_MASK          0x00000000f0000000
-
-/*   SH_XNNI1_DEAD_FLOW_VC2_LIMIT                                       */
-/*   Description:  vc2 limit reg, zero disables functionality           */
-#define SH_XNNI1_DEAD_FLOW_VC2_LIMIT_SHFT        32
-#define SH_XNNI1_DEAD_FLOW_VC2_LIMIT_MASK        0x0000000f00000000
-
-/*   SH_XNNI1_DEAD_FLOW_VC2_DYN                                         */
-/*   Description:  vc2 counter dynamic value                            */
-#define SH_XNNI1_DEAD_FLOW_VC2_DYN_SHFT          40
-#define SH_XNNI1_DEAD_FLOW_VC2_DYN_MASK          0x00000f0000000000
-
-/*   SH_XNNI1_DEAD_FLOW_VC2_CAP                                         */
-/*   Description:  vc2 counter captured value                           */
-#define SH_XNNI1_DEAD_FLOW_VC2_CAP_SHFT          44
-#define SH_XNNI1_DEAD_FLOW_VC2_CAP_MASK          0x0000f00000000000
-
-/*   SH_XNNI1_DEAD_FLOW_VC3_LIMIT                                       */
-/*   Description:  vc3 limit reg, zero disables functionality           */
-#define SH_XNNI1_DEAD_FLOW_VC3_LIMIT_SHFT        48
-#define SH_XNNI1_DEAD_FLOW_VC3_LIMIT_MASK        0x000f000000000000
-
-/*   SH_XNNI1_DEAD_FLOW_VC3_DYN                                         */
-/*   Description:  vc3 counter dynamic value                            */
-#define SH_XNNI1_DEAD_FLOW_VC3_DYN_SHFT          56
-#define SH_XNNI1_DEAD_FLOW_VC3_DYN_MASK          0x0f00000000000000
-
-/*   SH_XNNI1_DEAD_FLOW_VC3_CAP                                         */
-/*   Description:  vc3 counter captured value                           */
-#define SH_XNNI1_DEAD_FLOW_VC3_CAP_SHFT          60
-#define SH_XNNI1_DEAD_FLOW_VC3_CAP_MASK          0xf000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI1_INJECT_AGE"                    */
-/* ==================================================================== */
-
-#define SH_XNNI1_INJECT_AGE                      0x0000000150030600
-#define SH_XNNI1_INJECT_AGE_MASK                 0x000000000000ffff
-#define SH_XNNI1_INJECT_AGE_INIT                 0x0000000000000000
-
-/*   SH_XNNI1_INJECT_AGE_REQUEST_INJECT                                 */
-/*   Description:  Value of AGE field for outgoing requests             */
-#define SH_XNNI1_INJECT_AGE_REQUEST_INJECT_SHFT  0
-#define SH_XNNI1_INJECT_AGE_REQUEST_INJECT_MASK  0x00000000000000ff
-
-/*   SH_XNNI1_INJECT_AGE_REPLY_INJECT                                   */
-/*   Description:  Value of AGE field for outgoing replies              */
-#define SH_XNNI1_INJECT_AGE_REPLY_INJECT_SHFT    8
-#define SH_XNNI1_INJECT_AGE_REPLY_INJECT_MASK    0x000000000000ff00
-
-/* ==================================================================== */
-/*                      Register "SH_XN_DEBUG_SEL"                      */
-/*                         XN Debug Port Select                         */
-/* ==================================================================== */
-
-#define SH_XN_DEBUG_SEL                          0x0000000150031000
-#define SH_XN_DEBUG_SEL_MASK                     0xf777777777777777
-#define SH_XN_DEBUG_SEL_INIT                     0x0000000000000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE0_RLM_SEL                                    */
-/*   Description:  Nibble 0 RLM select                                  */
-#define SH_XN_DEBUG_SEL_NIBBLE0_RLM_SEL_SHFT     0
-#define SH_XN_DEBUG_SEL_NIBBLE0_RLM_SEL_MASK     0x0000000000000007
-
-/*   SH_XN_DEBUG_SEL_NIBBLE0_NIBBLE_SEL                                 */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_XN_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_SHFT  4
-#define SH_XN_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_MASK  0x0000000000000070
-
-/*   SH_XN_DEBUG_SEL_NIBBLE1_RLM_SEL                                    */
-/*   Description:  Nibble 1 RLM select                                  */
-#define SH_XN_DEBUG_SEL_NIBBLE1_RLM_SEL_SHFT     8
-#define SH_XN_DEBUG_SEL_NIBBLE1_RLM_SEL_MASK     0x0000000000000700
-
-/*   SH_XN_DEBUG_SEL_NIBBLE1_NIBBLE_SEL                                 */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_XN_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_SHFT  12
-#define SH_XN_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_MASK  0x0000000000007000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE2_RLM_SEL                                    */
-/*   Description:  Nibble 2 RLM select                                  */
-#define SH_XN_DEBUG_SEL_NIBBLE2_RLM_SEL_SHFT     16
-#define SH_XN_DEBUG_SEL_NIBBLE2_RLM_SEL_MASK     0x0000000000070000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE2_NIBBLE_SEL                                 */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_XN_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_SHFT  20
-#define SH_XN_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_MASK  0x0000000000700000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE3_RLM_SEL                                    */
-/*   Description:  Nibble 3 RLM select                                  */
-#define SH_XN_DEBUG_SEL_NIBBLE3_RLM_SEL_SHFT     24
-#define SH_XN_DEBUG_SEL_NIBBLE3_RLM_SEL_MASK     0x0000000007000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE3_NIBBLE_SEL                                 */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_XN_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_SHFT  28
-#define SH_XN_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_MASK  0x0000000070000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE4_RLM_SEL                                    */
-/*   Description:  Nibble 4 RLM select                                  */
-#define SH_XN_DEBUG_SEL_NIBBLE4_RLM_SEL_SHFT     32
-#define SH_XN_DEBUG_SEL_NIBBLE4_RLM_SEL_MASK     0x0000000700000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE4_NIBBLE_SEL                                 */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_XN_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_SHFT  36
-#define SH_XN_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_MASK  0x0000007000000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE5_RLM_SEL                                    */
-/*   Description:  Nibble 5 RLM select                                  */
-#define SH_XN_DEBUG_SEL_NIBBLE5_RLM_SEL_SHFT     40
-#define SH_XN_DEBUG_SEL_NIBBLE5_RLM_SEL_MASK     0x0000070000000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE5_NIBBLE_SEL                                 */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_XN_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_SHFT  44
-#define SH_XN_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_MASK  0x0000700000000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE6_RLM_SEL                                    */
-/*   Description:  Nibble 6 RLM select                                  */
-#define SH_XN_DEBUG_SEL_NIBBLE6_RLM_SEL_SHFT     48
-#define SH_XN_DEBUG_SEL_NIBBLE6_RLM_SEL_MASK     0x0007000000000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE6_NIBBLE_SEL                                 */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_XN_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_SHFT  52
-#define SH_XN_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_MASK  0x0070000000000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE7_RLM_SEL                                    */
-/*   Description:  Nibble 7 RLM select                                  */
-#define SH_XN_DEBUG_SEL_NIBBLE7_RLM_SEL_SHFT     56
-#define SH_XN_DEBUG_SEL_NIBBLE7_RLM_SEL_MASK     0x0700000000000000
-
-/*   SH_XN_DEBUG_SEL_NIBBLE7_NIBBLE_SEL                                 */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_XN_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_SHFT  60
-#define SH_XN_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_MASK  0x7000000000000000
-
-/*   SH_XN_DEBUG_SEL_TRIGGER_ENABLE                                     */
-/*   Description:  Enable trigger on bit 32 of Analyzer data            */
-#define SH_XN_DEBUG_SEL_TRIGGER_ENABLE_SHFT      63
-#define SH_XN_DEBUG_SEL_TRIGGER_ENABLE_MASK      0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XN_DEBUG_TRIG_SEL"                    */
-/*                       XN Debug trigger Select                        */
-/* ==================================================================== */
-
-#define SH_XN_DEBUG_TRIG_SEL                     0x0000000150031020
-#define SH_XN_DEBUG_TRIG_SEL_MASK                0x7777777777777777
-#define SH_XN_DEBUG_TRIG_SEL_INIT                0x0000000000000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER0_RLM_SEL                              */
-/*   Description:  Nibble 0 RLM select                                  */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER0_RLM_SEL_SHFT 0
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER0_RLM_SEL_MASK 0x0000000000000007
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER0_NIBBLE_SEL                           */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER0_NIBBLE_SEL_SHFT 4
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER1_RLM_SEL                              */
-/*   Description:  Nibble 1 RLM select                                  */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER1_RLM_SEL_SHFT 8
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER1_RLM_SEL_MASK 0x0000000000000700
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER1_NIBBLE_SEL                           */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER1_NIBBLE_SEL_SHFT 12
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER2_RLM_SEL                              */
-/*   Description:  Nibble 2 RLM select                                  */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER2_RLM_SEL_SHFT 16
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER2_RLM_SEL_MASK 0x0000000000070000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER2_NIBBLE_SEL                           */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER2_NIBBLE_SEL_SHFT 20
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER3_RLM_SEL                              */
-/*   Description:  Nibble 3 RLM select                                  */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER3_RLM_SEL_SHFT 24
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER3_RLM_SEL_MASK 0x0000000007000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER3_NIBBLE_SEL                           */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER3_NIBBLE_SEL_SHFT 28
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER4_RLM_SEL                              */
-/*   Description:  Nibble 4 RLM select                                  */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER4_RLM_SEL_SHFT 32
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER4_RLM_SEL_MASK 0x0000000700000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER4_NIBBLE_SEL                           */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER4_NIBBLE_SEL_SHFT 36
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER5_RLM_SEL                              */
-/*   Description:  Nibble 5 RLM select                                  */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER5_RLM_SEL_SHFT 40
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER5_RLM_SEL_MASK 0x0000070000000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER5_NIBBLE_SEL                           */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER5_NIBBLE_SEL_SHFT 44
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER6_RLM_SEL                              */
-/*   Description:  Nibble 6 RLM select                                  */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER6_RLM_SEL_SHFT 48
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER6_RLM_SEL_MASK 0x0007000000000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER6_NIBBLE_SEL                           */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER6_NIBBLE_SEL_SHFT 52
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER7_RLM_SEL                              */
-/*   Description:  Nibble 7 RLM select                                  */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER7_RLM_SEL_SHFT 56
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER7_RLM_SEL_MASK 0x0700000000000000
-
-/*   SH_XN_DEBUG_TRIG_SEL_TRIGGER7_NIBBLE_SEL                           */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER7_NIBBLE_SEL_SHFT 60
-#define SH_XN_DEBUG_TRIG_SEL_TRIGGER7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XN_TRIGGER_COMPARE"                   */
-/*                           XN Debug Compare                           */
-/* ==================================================================== */
-
-#define SH_XN_TRIGGER_COMPARE                    0x0000000150031040
-#define SH_XN_TRIGGER_COMPARE_MASK               0x00000000ffffffff
-#define SH_XN_TRIGGER_COMPARE_INIT               0x0000000000000000
-
-/*   SH_XN_TRIGGER_COMPARE_MASK                                         */
-/*   Description:  Mask to select Debug bits for trigger generation     */
-#define SH_XN_TRIGGER_COMPARE_MASK_SHFT          0
-#define SH_XN_TRIGGER_COMPARE_MASK_MASK          0x00000000ffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_XN_TRIGGER_DATA"                     */
-/*                        XN Debug Compare Data                         */
-/* ==================================================================== */
-
-#define SH_XN_TRIGGER_DATA                       0x0000000150031050
-#define SH_XN_TRIGGER_DATA_MASK                  0x00000000ffffffff
-#define SH_XN_TRIGGER_DATA_INIT                  0x00000000ffffffff
-
-/*   SH_XN_TRIGGER_DATA_COMPARE_PATTERN                                 */
-/*   Description:  debug bit pattern for trigger generation             */
-#define SH_XN_TRIGGER_DATA_COMPARE_PATTERN_SHFT  0
-#define SH_XN_TRIGGER_DATA_COMPARE_PATTERN_MASK  0x00000000ffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_XN_IILB_DEBUG_SEL"                    */
-/*                      XN IILB Debug Port Select                       */
-/* ==================================================================== */
-
-#define SH_XN_IILB_DEBUG_SEL                     0x0000000150031060
-#define SH_XN_IILB_DEBUG_SEL_MASK                0x7777777777777777
-#define SH_XN_IILB_DEBUG_SEL_INIT                0x0000000000000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE0_INPUT_SEL                             */
-/*   Description:  Nibble 0 input select                                */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE0_INPUT_SEL_SHFT 0
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE0_INPUT_SEL_MASK 0x0000000000000007
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE0_NIBBLE_SEL                            */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE1_INPUT_SEL                             */
-/*   Description:  Nibble 1 input select                                */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE1_INPUT_SEL_SHFT 8
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE1_INPUT_SEL_MASK 0x0000000000000700
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE1_NIBBLE_SEL                            */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE2_INPUT_SEL                             */
-/*   Description:  Nibble 2 input select                                */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE2_INPUT_SEL_SHFT 16
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE2_INPUT_SEL_MASK 0x0000000000070000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE2_NIBBLE_SEL                            */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE3_INPUT_SEL                             */
-/*   Description:  Nibble 3 input select                                */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE3_INPUT_SEL_SHFT 24
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE3_INPUT_SEL_MASK 0x0000000007000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE3_NIBBLE_SEL                            */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE4_INPUT_SEL                             */
-/*   Description:  Nibble 4 input select                                */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE4_INPUT_SEL_SHFT 32
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE4_INPUT_SEL_MASK 0x0000000700000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE4_NIBBLE_SEL                            */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE5_INPUT_SEL                             */
-/*   Description:  Nibble 5 input select                                */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE5_INPUT_SEL_SHFT 40
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE5_INPUT_SEL_MASK 0x0000070000000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE5_NIBBLE_SEL                            */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE6_INPUT_SEL                             */
-/*   Description:  Nibble 6 input select                                */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE6_INPUT_SEL_SHFT 48
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE6_INPUT_SEL_MASK 0x0007000000000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE6_NIBBLE_SEL                            */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE7_INPUT_SEL                             */
-/*   Description:  Nibble 7 input select                                */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE7_INPUT_SEL_SHFT 56
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE7_INPUT_SEL_MASK 0x0700000000000000
-
-/*   SH_XN_IILB_DEBUG_SEL_NIBBLE7_NIBBLE_SEL                            */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_XN_IILB_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XN_PI_DEBUG_SEL"                     */
-/*                       XN PI Debug Port Select                        */
-/* ==================================================================== */
-
-#define SH_XN_PI_DEBUG_SEL                       0x00000001500310a0
-#define SH_XN_PI_DEBUG_SEL_MASK                  0x7777777777777777
-#define SH_XN_PI_DEBUG_SEL_INIT                  0x0000000000000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE0_INPUT_SEL                               */
-/*   Description:  Nibble 0 input select                                */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE0_INPUT_SEL_SHFT 0
-#define SH_XN_PI_DEBUG_SEL_NIBBLE0_INPUT_SEL_MASK 0x0000000000000007
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE0_NIBBLE_SEL                              */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_XN_PI_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE1_INPUT_SEL                               */
-/*   Description:  Nibble 1 input select                                */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE1_INPUT_SEL_SHFT 8
-#define SH_XN_PI_DEBUG_SEL_NIBBLE1_INPUT_SEL_MASK 0x0000000000000700
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE1_NIBBLE_SEL                              */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_XN_PI_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE2_INPUT_SEL                               */
-/*   Description:  Nibble 2 input select                                */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE2_INPUT_SEL_SHFT 16
-#define SH_XN_PI_DEBUG_SEL_NIBBLE2_INPUT_SEL_MASK 0x0000000000070000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE2_NIBBLE_SEL                              */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_XN_PI_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE3_INPUT_SEL                               */
-/*   Description:  Nibble 3 input select                                */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE3_INPUT_SEL_SHFT 24
-#define SH_XN_PI_DEBUG_SEL_NIBBLE3_INPUT_SEL_MASK 0x0000000007000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE3_NIBBLE_SEL                              */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_XN_PI_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE4_INPUT_SEL                               */
-/*   Description:  Nibble 4 input select                                */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE4_INPUT_SEL_SHFT 32
-#define SH_XN_PI_DEBUG_SEL_NIBBLE4_INPUT_SEL_MASK 0x0000000700000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE4_NIBBLE_SEL                              */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_XN_PI_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE5_INPUT_SEL                               */
-/*   Description:  Nibble 5 input select                                */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE5_INPUT_SEL_SHFT 40
-#define SH_XN_PI_DEBUG_SEL_NIBBLE5_INPUT_SEL_MASK 0x0000070000000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE5_NIBBLE_SEL                              */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_XN_PI_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE6_INPUT_SEL                               */
-/*   Description:  Nibble 6 input select                                */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE6_INPUT_SEL_SHFT 48
-#define SH_XN_PI_DEBUG_SEL_NIBBLE6_INPUT_SEL_MASK 0x0007000000000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE6_NIBBLE_SEL                              */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_XN_PI_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE7_INPUT_SEL                               */
-/*   Description:  Nibble 7 input select                                */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE7_INPUT_SEL_SHFT 56
-#define SH_XN_PI_DEBUG_SEL_NIBBLE7_INPUT_SEL_MASK 0x0700000000000000
-
-/*   SH_XN_PI_DEBUG_SEL_NIBBLE7_NIBBLE_SEL                              */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_XN_PI_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_XN_PI_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XN_MD_DEBUG_SEL"                     */
-/*                       XN MD Debug Port Select                        */
-/* ==================================================================== */
-
-#define SH_XN_MD_DEBUG_SEL                       0x0000000150031080
-#define SH_XN_MD_DEBUG_SEL_MASK                  0x7777777777777777
-#define SH_XN_MD_DEBUG_SEL_INIT                  0x0000000000000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE0_INPUT_SEL                               */
-/*   Description:  Nibble 0 input select                                */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE0_INPUT_SEL_SHFT 0
-#define SH_XN_MD_DEBUG_SEL_NIBBLE0_INPUT_SEL_MASK 0x0000000000000007
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE0_NIBBLE_SEL                              */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_XN_MD_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE1_INPUT_SEL                               */
-/*   Description:  Nibble 1 input select                                */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE1_INPUT_SEL_SHFT 8
-#define SH_XN_MD_DEBUG_SEL_NIBBLE1_INPUT_SEL_MASK 0x0000000000000700
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE1_NIBBLE_SEL                              */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_XN_MD_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE2_INPUT_SEL                               */
-/*   Description:  Nibble 2 input select                                */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE2_INPUT_SEL_SHFT 16
-#define SH_XN_MD_DEBUG_SEL_NIBBLE2_INPUT_SEL_MASK 0x0000000000070000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE2_NIBBLE_SEL                              */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_XN_MD_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE3_INPUT_SEL                               */
-/*   Description:  Nibble 3 input select                                */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE3_INPUT_SEL_SHFT 24
-#define SH_XN_MD_DEBUG_SEL_NIBBLE3_INPUT_SEL_MASK 0x0000000007000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE3_NIBBLE_SEL                              */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_XN_MD_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE4_INPUT_SEL                               */
-/*   Description:  Nibble 4 input select                                */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE4_INPUT_SEL_SHFT 32
-#define SH_XN_MD_DEBUG_SEL_NIBBLE4_INPUT_SEL_MASK 0x0000000700000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE4_NIBBLE_SEL                              */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_XN_MD_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE5_INPUT_SEL                               */
-/*   Description:  Nibble 5 input select                                */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE5_INPUT_SEL_SHFT 40
-#define SH_XN_MD_DEBUG_SEL_NIBBLE5_INPUT_SEL_MASK 0x0000070000000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE5_NIBBLE_SEL                              */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_XN_MD_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE6_INPUT_SEL                               */
-/*   Description:  Nibble 6 input select                                */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE6_INPUT_SEL_SHFT 48
-#define SH_XN_MD_DEBUG_SEL_NIBBLE6_INPUT_SEL_MASK 0x0007000000000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE6_NIBBLE_SEL                              */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_XN_MD_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE7_INPUT_SEL                               */
-/*   Description:  Nibble 7 input select                                */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE7_INPUT_SEL_SHFT 56
-#define SH_XN_MD_DEBUG_SEL_NIBBLE7_INPUT_SEL_MASK 0x0700000000000000
-
-/*   SH_XN_MD_DEBUG_SEL_NIBBLE7_NIBBLE_SEL                              */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_XN_MD_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_XN_MD_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XN_NI0_DEBUG_SEL"                    */
-/*                       XN NI0 Debug Port Select                       */
-/* ==================================================================== */
-
-#define SH_XN_NI0_DEBUG_SEL                      0x00000001500310c0
-#define SH_XN_NI0_DEBUG_SEL_MASK                 0x7777777777777777
-#define SH_XN_NI0_DEBUG_SEL_INIT                 0x0000000000000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE0_INPUT_SEL                              */
-/*   Description:  Nibble 0 input select                                */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE0_INPUT_SEL_SHFT 0
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE0_INPUT_SEL_MASK 0x0000000000000007
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE0_NIBBLE_SEL                             */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE1_INPUT_SEL                              */
-/*   Description:  Nibble 1 input select                                */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE1_INPUT_SEL_SHFT 8
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE1_INPUT_SEL_MASK 0x0000000000000700
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE1_NIBBLE_SEL                             */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE2_INPUT_SEL                              */
-/*   Description:  Nibble 2 input select                                */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE2_INPUT_SEL_SHFT 16
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE2_INPUT_SEL_MASK 0x0000000000070000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE2_NIBBLE_SEL                             */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE3_INPUT_SEL                              */
-/*   Description:  Nibble 3 input select                                */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE3_INPUT_SEL_SHFT 24
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE3_INPUT_SEL_MASK 0x0000000007000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE3_NIBBLE_SEL                             */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE4_INPUT_SEL                              */
-/*   Description:  Nibble 4 input select                                */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE4_INPUT_SEL_SHFT 32
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE4_INPUT_SEL_MASK 0x0000000700000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE4_NIBBLE_SEL                             */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE5_INPUT_SEL                              */
-/*   Description:  Nibble 5 input select                                */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE5_INPUT_SEL_SHFT 40
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE5_INPUT_SEL_MASK 0x0000070000000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE5_NIBBLE_SEL                             */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE6_INPUT_SEL                              */
-/*   Description:  Nibble 6 input select                                */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE6_INPUT_SEL_SHFT 48
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE6_INPUT_SEL_MASK 0x0007000000000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE6_NIBBLE_SEL                             */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE7_INPUT_SEL                              */
-/*   Description:  Nibble 7 input select                                */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE7_INPUT_SEL_SHFT 56
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE7_INPUT_SEL_MASK 0x0700000000000000
-
-/*   SH_XN_NI0_DEBUG_SEL_NIBBLE7_NIBBLE_SEL                             */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_XN_NI0_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XN_NI1_DEBUG_SEL"                    */
-/*                       XN NI1 Debug Port Select                       */
-/* ==================================================================== */
-
-#define SH_XN_NI1_DEBUG_SEL                      0x00000001500310e0
-#define SH_XN_NI1_DEBUG_SEL_MASK                 0x7777777777777777
-#define SH_XN_NI1_DEBUG_SEL_INIT                 0x0000000000000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE0_INPUT_SEL                              */
-/*   Description:  Nibble 0 input select                                */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE0_INPUT_SEL_SHFT 0
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE0_INPUT_SEL_MASK 0x0000000000000007
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE0_NIBBLE_SEL                             */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_SHFT 4
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE0_NIBBLE_SEL_MASK 0x0000000000000070
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE1_INPUT_SEL                              */
-/*   Description:  Nibble 1 input select                                */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE1_INPUT_SEL_SHFT 8
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE1_INPUT_SEL_MASK 0x0000000000000700
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE1_NIBBLE_SEL                             */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_SHFT 12
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE1_NIBBLE_SEL_MASK 0x0000000000007000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE2_INPUT_SEL                              */
-/*   Description:  Nibble 2 input select                                */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE2_INPUT_SEL_SHFT 16
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE2_INPUT_SEL_MASK 0x0000000000070000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE2_NIBBLE_SEL                             */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_SHFT 20
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE2_NIBBLE_SEL_MASK 0x0000000000700000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE3_INPUT_SEL                              */
-/*   Description:  Nibble 3 input select                                */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE3_INPUT_SEL_SHFT 24
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE3_INPUT_SEL_MASK 0x0000000007000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE3_NIBBLE_SEL                             */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_SHFT 28
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE3_NIBBLE_SEL_MASK 0x0000000070000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE4_INPUT_SEL                              */
-/*   Description:  Nibble 4 input select                                */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE4_INPUT_SEL_SHFT 32
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE4_INPUT_SEL_MASK 0x0000000700000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE4_NIBBLE_SEL                             */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_SHFT 36
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE4_NIBBLE_SEL_MASK 0x0000007000000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE5_INPUT_SEL                              */
-/*   Description:  Nibble 5 input select                                */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE5_INPUT_SEL_SHFT 40
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE5_INPUT_SEL_MASK 0x0000070000000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE5_NIBBLE_SEL                             */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_SHFT 44
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE5_NIBBLE_SEL_MASK 0x0000700000000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE6_INPUT_SEL                              */
-/*   Description:  Nibble 6 input select                                */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE6_INPUT_SEL_SHFT 48
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE6_INPUT_SEL_MASK 0x0007000000000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE6_NIBBLE_SEL                             */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_SHFT 52
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE6_NIBBLE_SEL_MASK 0x0070000000000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE7_INPUT_SEL                              */
-/*   Description:  Nibble 7 input select                                */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE7_INPUT_SEL_SHFT 56
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE7_INPUT_SEL_MASK 0x0700000000000000
-
-/*   SH_XN_NI1_DEBUG_SEL_NIBBLE7_NIBBLE_SEL                             */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_SHFT 60
-#define SH_XN_NI1_DEBUG_SEL_NIBBLE7_NIBBLE_SEL_MASK 0x7000000000000000
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_LB_CMP_EXP_DATA0"                */
-/*                 IILB compare LB input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_LB_CMP_EXP_DATA0              0x0000000150031100
-#define SH_XN_IILB_LB_CMP_EXP_DATA0_MASK         0xffffffffffffffff
-#define SH_XN_IILB_LB_CMP_EXP_DATA0_INIT         0x0000000000000000
-
-/*   SH_XN_IILB_LB_CMP_EXP_DATA0_DATA                                   */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_IILB_LB_CMP_EXP_DATA0_DATA_SHFT    0
-#define SH_XN_IILB_LB_CMP_EXP_DATA0_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_LB_CMP_EXP_DATA1"                */
-/*                 IILB compare LB input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_LB_CMP_EXP_DATA1              0x0000000150031110
-#define SH_XN_IILB_LB_CMP_EXP_DATA1_MASK         0xffffffffffffffff
-#define SH_XN_IILB_LB_CMP_EXP_DATA1_INIT         0x0000000000000000
-
-/*   SH_XN_IILB_LB_CMP_EXP_DATA1_DATA                                   */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_IILB_LB_CMP_EXP_DATA1_DATA_SHFT    0
-#define SH_XN_IILB_LB_CMP_EXP_DATA1_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_LB_CMP_ENABLE0"                 */
-/*                    IILB compare LB input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_IILB_LB_CMP_ENABLE0                0x0000000150031120
-#define SH_XN_IILB_LB_CMP_ENABLE0_MASK           0xffffffffffffffff
-#define SH_XN_IILB_LB_CMP_ENABLE0_INIT           0x0000000000000000
-
-/*   SH_XN_IILB_LB_CMP_ENABLE0_ENABLE                                   */
-/*   Description:  Enable0                                              */
-#define SH_XN_IILB_LB_CMP_ENABLE0_ENABLE_SHFT    0
-#define SH_XN_IILB_LB_CMP_ENABLE0_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_LB_CMP_ENABLE1"                 */
-/*                    IILB compare LB input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_IILB_LB_CMP_ENABLE1                0x0000000150031130
-#define SH_XN_IILB_LB_CMP_ENABLE1_MASK           0xffffffffffffffff
-#define SH_XN_IILB_LB_CMP_ENABLE1_INIT           0x0000000000000000
-
-/*   SH_XN_IILB_LB_CMP_ENABLE1_ENABLE                                   */
-/*   Description:  Enable1                                              */
-#define SH_XN_IILB_LB_CMP_ENABLE1_ENABLE_SHFT    0
-#define SH_XN_IILB_LB_CMP_ENABLE1_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_II_CMP_EXP_DATA0"                */
-/*                 IILB compare II input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_II_CMP_EXP_DATA0              0x0000000150031140
-#define SH_XN_IILB_II_CMP_EXP_DATA0_MASK         0xffffffffffffffff
-#define SH_XN_IILB_II_CMP_EXP_DATA0_INIT         0x0000000000000000
-
-/*   SH_XN_IILB_II_CMP_EXP_DATA0_DATA                                   */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_IILB_II_CMP_EXP_DATA0_DATA_SHFT    0
-#define SH_XN_IILB_II_CMP_EXP_DATA0_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_II_CMP_EXP_DATA1"                */
-/*                 IILB compare II input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_II_CMP_EXP_DATA1              0x0000000150031150
-#define SH_XN_IILB_II_CMP_EXP_DATA1_MASK         0xffffffffffffffff
-#define SH_XN_IILB_II_CMP_EXP_DATA1_INIT         0x0000000000000000
-
-/*   SH_XN_IILB_II_CMP_EXP_DATA1_DATA                                   */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_IILB_II_CMP_EXP_DATA1_DATA_SHFT    0
-#define SH_XN_IILB_II_CMP_EXP_DATA1_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_II_CMP_ENABLE0"                 */
-/*                    IILB compare II input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_IILB_II_CMP_ENABLE0                0x0000000150031160
-#define SH_XN_IILB_II_CMP_ENABLE0_MASK           0xffffffffffffffff
-#define SH_XN_IILB_II_CMP_ENABLE0_INIT           0x0000000000000000
-
-/*   SH_XN_IILB_II_CMP_ENABLE0_ENABLE                                   */
-/*   Description:  Enable0                                              */
-#define SH_XN_IILB_II_CMP_ENABLE0_ENABLE_SHFT    0
-#define SH_XN_IILB_II_CMP_ENABLE0_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_II_CMP_ENABLE1"                 */
-/*                    IILB compare II input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_IILB_II_CMP_ENABLE1                0x0000000150031170
-#define SH_XN_IILB_II_CMP_ENABLE1_MASK           0xffffffffffffffff
-#define SH_XN_IILB_II_CMP_ENABLE1_INIT           0x0000000000000000
-
-/*   SH_XN_IILB_II_CMP_ENABLE1_ENABLE                                   */
-/*   Description:  Enable1                                              */
-#define SH_XN_IILB_II_CMP_ENABLE1_ENABLE_SHFT    0
-#define SH_XN_IILB_II_CMP_ENABLE1_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_MD_CMP_EXP_DATA0"                */
-/*                 IILB compare MD input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_MD_CMP_EXP_DATA0              0x0000000150031180
-#define SH_XN_IILB_MD_CMP_EXP_DATA0_MASK         0xffffffffffffffff
-#define SH_XN_IILB_MD_CMP_EXP_DATA0_INIT         0x0000000000000000
-
-/*   SH_XN_IILB_MD_CMP_EXP_DATA0_DATA                                   */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_IILB_MD_CMP_EXP_DATA0_DATA_SHFT    0
-#define SH_XN_IILB_MD_CMP_EXP_DATA0_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_MD_CMP_EXP_DATA1"                */
-/*                 IILB compare MD input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_MD_CMP_EXP_DATA1              0x0000000150031190
-#define SH_XN_IILB_MD_CMP_EXP_DATA1_MASK         0xffffffffffffffff
-#define SH_XN_IILB_MD_CMP_EXP_DATA1_INIT         0x0000000000000000
-
-/*   SH_XN_IILB_MD_CMP_EXP_DATA1_DATA                                   */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_IILB_MD_CMP_EXP_DATA1_DATA_SHFT    0
-#define SH_XN_IILB_MD_CMP_EXP_DATA1_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_MD_CMP_ENABLE0"                 */
-/*                    IILB compare MD input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_IILB_MD_CMP_ENABLE0                0x00000001500311a0
-#define SH_XN_IILB_MD_CMP_ENABLE0_MASK           0xffffffffffffffff
-#define SH_XN_IILB_MD_CMP_ENABLE0_INIT           0x0000000000000000
-
-/*   SH_XN_IILB_MD_CMP_ENABLE0_ENABLE                                   */
-/*   Description:  Enable0                                              */
-#define SH_XN_IILB_MD_CMP_ENABLE0_ENABLE_SHFT    0
-#define SH_XN_IILB_MD_CMP_ENABLE0_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_MD_CMP_ENABLE1"                 */
-/*                    IILB compare MD input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_IILB_MD_CMP_ENABLE1                0x00000001500311b0
-#define SH_XN_IILB_MD_CMP_ENABLE1_MASK           0xffffffffffffffff
-#define SH_XN_IILB_MD_CMP_ENABLE1_INIT           0x0000000000000000
-
-/*   SH_XN_IILB_MD_CMP_ENABLE1_ENABLE                                   */
-/*   Description:  Enable1                                              */
-#define SH_XN_IILB_MD_CMP_ENABLE1_ENABLE_SHFT    0
-#define SH_XN_IILB_MD_CMP_ENABLE1_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_PI_CMP_EXP_DATA0"                */
-/*                 IILB compare PI input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_PI_CMP_EXP_DATA0              0x00000001500311c0
-#define SH_XN_IILB_PI_CMP_EXP_DATA0_MASK         0xffffffffffffffff
-#define SH_XN_IILB_PI_CMP_EXP_DATA0_INIT         0x0000000000000000
-
-/*   SH_XN_IILB_PI_CMP_EXP_DATA0_DATA                                   */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_IILB_PI_CMP_EXP_DATA0_DATA_SHFT    0
-#define SH_XN_IILB_PI_CMP_EXP_DATA0_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_PI_CMP_EXP_DATA1"                */
-/*                 IILB compare PI input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_PI_CMP_EXP_DATA1              0x00000001500311d0
-#define SH_XN_IILB_PI_CMP_EXP_DATA1_MASK         0xffffffffffffffff
-#define SH_XN_IILB_PI_CMP_EXP_DATA1_INIT         0x0000000000000000
-
-/*   SH_XN_IILB_PI_CMP_EXP_DATA1_DATA                                   */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_IILB_PI_CMP_EXP_DATA1_DATA_SHFT    0
-#define SH_XN_IILB_PI_CMP_EXP_DATA1_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_PI_CMP_ENABLE0"                 */
-/*                    IILB compare PI input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_IILB_PI_CMP_ENABLE0                0x00000001500311e0
-#define SH_XN_IILB_PI_CMP_ENABLE0_MASK           0xffffffffffffffff
-#define SH_XN_IILB_PI_CMP_ENABLE0_INIT           0x0000000000000000
-
-/*   SH_XN_IILB_PI_CMP_ENABLE0_ENABLE                                   */
-/*   Description:  Enable0                                              */
-#define SH_XN_IILB_PI_CMP_ENABLE0_ENABLE_SHFT    0
-#define SH_XN_IILB_PI_CMP_ENABLE0_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_PI_CMP_ENABLE1"                 */
-/*                    IILB compare PI input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_IILB_PI_CMP_ENABLE1                0x00000001500311f0
-#define SH_XN_IILB_PI_CMP_ENABLE1_MASK           0xffffffffffffffff
-#define SH_XN_IILB_PI_CMP_ENABLE1_INIT           0x0000000000000000
-
-/*   SH_XN_IILB_PI_CMP_ENABLE1_ENABLE                                   */
-/*   Description:  Enable1                                              */
-#define SH_XN_IILB_PI_CMP_ENABLE1_ENABLE_SHFT    0
-#define SH_XN_IILB_PI_CMP_ENABLE1_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_IILB_NI0_CMP_EXP_DATA0"                */
-/*                IILB compare NI0 input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_NI0_CMP_EXP_DATA0             0x0000000150031200
-#define SH_XN_IILB_NI0_CMP_EXP_DATA0_MASK        0xffffffffffffffff
-#define SH_XN_IILB_NI0_CMP_EXP_DATA0_INIT        0x0000000000000000
-
-/*   SH_XN_IILB_NI0_CMP_EXP_DATA0_DATA                                  */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_IILB_NI0_CMP_EXP_DATA0_DATA_SHFT   0
-#define SH_XN_IILB_NI0_CMP_EXP_DATA0_DATA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_IILB_NI0_CMP_EXP_DATA1"                */
-/*                IILB compare NI0 input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_NI0_CMP_EXP_DATA1             0x0000000150031210
-#define SH_XN_IILB_NI0_CMP_EXP_DATA1_MASK        0xffffffffffffffff
-#define SH_XN_IILB_NI0_CMP_EXP_DATA1_INIT        0x0000000000000000
-
-/*   SH_XN_IILB_NI0_CMP_EXP_DATA1_DATA                                  */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_IILB_NI0_CMP_EXP_DATA1_DATA_SHFT   0
-#define SH_XN_IILB_NI0_CMP_EXP_DATA1_DATA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_NI0_CMP_ENABLE0"                 */
-/*                    IILB compare NI0 input enable0                    */
-/* ==================================================================== */
-
-#define SH_XN_IILB_NI0_CMP_ENABLE0               0x0000000150031220
-#define SH_XN_IILB_NI0_CMP_ENABLE0_MASK          0xffffffffffffffff
-#define SH_XN_IILB_NI0_CMP_ENABLE0_INIT          0x0000000000000000
-
-/*   SH_XN_IILB_NI0_CMP_ENABLE0_ENABLE                                  */
-/*   Description:  Enable0                                              */
-#define SH_XN_IILB_NI0_CMP_ENABLE0_ENABLE_SHFT   0
-#define SH_XN_IILB_NI0_CMP_ENABLE0_ENABLE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_NI0_CMP_ENABLE1"                 */
-/*                    IILB compare NI0 input enable1                    */
-/* ==================================================================== */
-
-#define SH_XN_IILB_NI0_CMP_ENABLE1               0x0000000150031230
-#define SH_XN_IILB_NI0_CMP_ENABLE1_MASK          0xffffffffffffffff
-#define SH_XN_IILB_NI0_CMP_ENABLE1_INIT          0x0000000000000000
-
-/*   SH_XN_IILB_NI0_CMP_ENABLE1_ENABLE                                  */
-/*   Description:  Enable1                                              */
-#define SH_XN_IILB_NI0_CMP_ENABLE1_ENABLE_SHFT   0
-#define SH_XN_IILB_NI0_CMP_ENABLE1_ENABLE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_IILB_NI1_CMP_EXP_DATA0"                */
-/*                IILB compare NI1 input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_NI1_CMP_EXP_DATA0             0x0000000150031240
-#define SH_XN_IILB_NI1_CMP_EXP_DATA0_MASK        0xffffffffffffffff
-#define SH_XN_IILB_NI1_CMP_EXP_DATA0_INIT        0x0000000000000000
-
-/*   SH_XN_IILB_NI1_CMP_EXP_DATA0_DATA                                  */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_IILB_NI1_CMP_EXP_DATA0_DATA_SHFT   0
-#define SH_XN_IILB_NI1_CMP_EXP_DATA0_DATA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_IILB_NI1_CMP_EXP_DATA1"                */
-/*                IILB compare NI1 input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_IILB_NI1_CMP_EXP_DATA1             0x0000000150031250
-#define SH_XN_IILB_NI1_CMP_EXP_DATA1_MASK        0xffffffffffffffff
-#define SH_XN_IILB_NI1_CMP_EXP_DATA1_INIT        0x0000000000000000
-
-/*   SH_XN_IILB_NI1_CMP_EXP_DATA1_DATA                                  */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_IILB_NI1_CMP_EXP_DATA1_DATA_SHFT   0
-#define SH_XN_IILB_NI1_CMP_EXP_DATA1_DATA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_NI1_CMP_ENABLE0"                 */
-/*                    IILB compare NI1 input enable0                    */
-/* ==================================================================== */
-
-#define SH_XN_IILB_NI1_CMP_ENABLE0               0x0000000150031260
-#define SH_XN_IILB_NI1_CMP_ENABLE0_MASK          0xffffffffffffffff
-#define SH_XN_IILB_NI1_CMP_ENABLE0_INIT          0x0000000000000000
-
-/*   SH_XN_IILB_NI1_CMP_ENABLE0_ENABLE                                  */
-/*   Description:  Enable0                                              */
-#define SH_XN_IILB_NI1_CMP_ENABLE0_ENABLE_SHFT   0
-#define SH_XN_IILB_NI1_CMP_ENABLE0_ENABLE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_NI1_CMP_ENABLE1"                 */
-/*                    IILB compare NI1 input enable1                    */
-/* ==================================================================== */
-
-#define SH_XN_IILB_NI1_CMP_ENABLE1               0x0000000150031270
-#define SH_XN_IILB_NI1_CMP_ENABLE1_MASK          0xffffffffffffffff
-#define SH_XN_IILB_NI1_CMP_ENABLE1_INIT          0x0000000000000000
-
-/*   SH_XN_IILB_NI1_CMP_ENABLE1_ENABLE                                  */
-/*   Description:  Enable1                                              */
-#define SH_XN_IILB_NI1_CMP_ENABLE1_ENABLE_SHFT   0
-#define SH_XN_IILB_NI1_CMP_ENABLE1_ENABLE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_IILB_CMP_EXP_DATA0"                */
-/*                 MD compare IILB input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_MD_IILB_CMP_EXP_DATA0              0x0000000150031500
-#define SH_XN_MD_IILB_CMP_EXP_DATA0_MASK         0xffffffffffffffff
-#define SH_XN_MD_IILB_CMP_EXP_DATA0_INIT         0x0000000000000000
-
-/*   SH_XN_MD_IILB_CMP_EXP_DATA0_DATA                                   */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_MD_IILB_CMP_EXP_DATA0_DATA_SHFT    0
-#define SH_XN_MD_IILB_CMP_EXP_DATA0_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_IILB_CMP_EXP_DATA1"                */
-/*                 MD compare IILB input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_MD_IILB_CMP_EXP_DATA1              0x0000000150031510
-#define SH_XN_MD_IILB_CMP_EXP_DATA1_MASK         0xffffffffffffffff
-#define SH_XN_MD_IILB_CMP_EXP_DATA1_INIT         0x0000000000000000
-
-/*   SH_XN_MD_IILB_CMP_EXP_DATA1_DATA                                   */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_MD_IILB_CMP_EXP_DATA1_DATA_SHFT    0
-#define SH_XN_MD_IILB_CMP_EXP_DATA1_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_IILB_CMP_ENABLE0"                 */
-/*                    MD compare IILB input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_MD_IILB_CMP_ENABLE0                0x0000000150031520
-#define SH_XN_MD_IILB_CMP_ENABLE0_MASK           0xffffffffffffffff
-#define SH_XN_MD_IILB_CMP_ENABLE0_INIT           0x0000000000000000
-
-/*   SH_XN_MD_IILB_CMP_ENABLE0_ENABLE                                   */
-/*   Description:  Enable0                                              */
-#define SH_XN_MD_IILB_CMP_ENABLE0_ENABLE_SHFT    0
-#define SH_XN_MD_IILB_CMP_ENABLE0_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_IILB_CMP_ENABLE1"                 */
-/*                    MD compare IILB input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_MD_IILB_CMP_ENABLE1                0x0000000150031530
-#define SH_XN_MD_IILB_CMP_ENABLE1_MASK           0xffffffffffffffff
-#define SH_XN_MD_IILB_CMP_ENABLE1_INIT           0x0000000000000000
-
-/*   SH_XN_MD_IILB_CMP_ENABLE1_ENABLE                                   */
-/*   Description:  Enable1                                              */
-#define SH_XN_MD_IILB_CMP_ENABLE1_ENABLE_SHFT    0
-#define SH_XN_MD_IILB_CMP_ENABLE1_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_NI0_CMP_EXP_DATA0"                 */
-/*                 MD compare NI0 input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_MD_NI0_CMP_EXP_DATA0               0x0000000150031540
-#define SH_XN_MD_NI0_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_MD_NI0_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_MD_NI0_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_MD_NI0_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_MD_NI0_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_NI0_CMP_EXP_DATA1"                 */
-/*                 MD compare NI0 input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_MD_NI0_CMP_EXP_DATA1               0x0000000150031550
-#define SH_XN_MD_NI0_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_MD_NI0_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_MD_NI0_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_MD_NI0_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_MD_NI0_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_NI0_CMP_ENABLE0"                  */
-/*                     MD compare NI0 input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_MD_NI0_CMP_ENABLE0                 0x0000000150031560
-#define SH_XN_MD_NI0_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_MD_NI0_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_MD_NI0_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_MD_NI0_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_MD_NI0_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_NI0_CMP_ENABLE1"                  */
-/*                     MD compare NI0 input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_MD_NI0_CMP_ENABLE1                 0x0000000150031570
-#define SH_XN_MD_NI0_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_MD_NI0_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_MD_NI0_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_MD_NI0_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_MD_NI0_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_NI1_CMP_EXP_DATA0"                 */
-/*                 MD compare NI1 input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_MD_NI1_CMP_EXP_DATA0               0x0000000150031580
-#define SH_XN_MD_NI1_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_MD_NI1_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_MD_NI1_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_MD_NI1_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_MD_NI1_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_NI1_CMP_EXP_DATA1"                 */
-/*                 MD compare NI1 input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_MD_NI1_CMP_EXP_DATA1               0x0000000150031590
-#define SH_XN_MD_NI1_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_MD_NI1_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_MD_NI1_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_MD_NI1_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_MD_NI1_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_NI1_CMP_ENABLE0"                  */
-/*                     MD compare NI1 input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_MD_NI1_CMP_ENABLE0                 0x00000001500315a0
-#define SH_XN_MD_NI1_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_MD_NI1_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_MD_NI1_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_MD_NI1_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_MD_NI1_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_NI1_CMP_ENABLE1"                  */
-/*                     MD compare NI1 input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_MD_NI1_CMP_ENABLE1                 0x00000001500315b0
-#define SH_XN_MD_NI1_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_MD_NI1_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_MD_NI1_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_MD_NI1_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_MD_NI1_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_SIC_CMP_EXP_HDR0"                 */
-/*                MD compare SIC input expected header0                 */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_EXP_HDR0                0x00000001500315c0
-#define SH_XN_MD_SIC_CMP_EXP_HDR0_MASK           0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_EXP_HDR0_INIT           0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_EXP_HDR0_DATA                                     */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_MD_SIC_CMP_EXP_HDR0_DATA_SHFT      0
-#define SH_XN_MD_SIC_CMP_EXP_HDR0_DATA_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_SIC_CMP_EXP_HDR1"                 */
-/*                MD compare SIC input expected header1                 */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_EXP_HDR1                0x00000001500315d0
-#define SH_XN_MD_SIC_CMP_EXP_HDR1_MASK           0x000003ffffffffff
-#define SH_XN_MD_SIC_CMP_EXP_HDR1_INIT           0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_EXP_HDR1_DATA                                     */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_MD_SIC_CMP_EXP_HDR1_DATA_SHFT      0
-#define SH_XN_MD_SIC_CMP_EXP_HDR1_DATA_MASK      0x000003ffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_HDR_ENABLE0"                */
-/*                    MD compare SIC header enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE0             0x00000001500315e0
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE0_MASK        0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE0_INIT        0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_HDR_ENABLE0_ENABLE                                */
-/*   Description:  Enable0                                              */
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE0_ENABLE_SHFT 0
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE0_ENABLE_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_HDR_ENABLE1"                */
-/*                    MD compare SIC header enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE1             0x00000001500315f0
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE1_MASK        0x000003ffffffffff
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE1_INIT        0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_HDR_ENABLE1_ENABLE                                */
-/*   Description:  Enable1                                              */
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE1_ENABLE_SHFT 0
-#define SH_XN_MD_SIC_CMP_HDR_ENABLE1_ENABLE_MASK 0x000003ffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XN_MD_SIC_CMP_DATA0"                   */
-/*                         MD compare SIC data0                         */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_DATA0                   0x0000000150031600
-#define SH_XN_MD_SIC_CMP_DATA0_MASK              0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_DATA0_INIT              0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_DATA0_DATA0                                       */
-/*   Description:  Data0                                                */
-#define SH_XN_MD_SIC_CMP_DATA0_DATA0_SHFT        0
-#define SH_XN_MD_SIC_CMP_DATA0_DATA0_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XN_MD_SIC_CMP_DATA1"                   */
-/*                         MD compare SIC data1                         */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_DATA1                   0x0000000150031610
-#define SH_XN_MD_SIC_CMP_DATA1_MASK              0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_DATA1_INIT              0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_DATA1_DATA1                                       */
-/*   Description:  Data1                                                */
-#define SH_XN_MD_SIC_CMP_DATA1_DATA1_SHFT        0
-#define SH_XN_MD_SIC_CMP_DATA1_DATA1_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XN_MD_SIC_CMP_DATA2"                   */
-/*                         MD compare SIC data2                         */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_DATA2                   0x0000000150031620
-#define SH_XN_MD_SIC_CMP_DATA2_MASK              0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_DATA2_INIT              0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_DATA2_DATA2                                       */
-/*   Description:  Data2                                                */
-#define SH_XN_MD_SIC_CMP_DATA2_DATA2_SHFT        0
-#define SH_XN_MD_SIC_CMP_DATA2_DATA2_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XN_MD_SIC_CMP_DATA3"                   */
-/*                         MD compare SIC data3                         */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_DATA3                   0x0000000150031630
-#define SH_XN_MD_SIC_CMP_DATA3_MASK              0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_DATA3_INIT              0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_DATA3_DATA3                                       */
-/*   Description:  Data3                                                */
-#define SH_XN_MD_SIC_CMP_DATA3_DATA3_SHFT        0
-#define SH_XN_MD_SIC_CMP_DATA3_DATA3_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_DATA_ENABLE0"               */
-/*                     MD enable compare SIC data0                      */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE0            0x0000000150031640
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE0_MASK       0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE0_INIT       0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_DATA_ENABLE0_DATA_ENABLE0                         */
-/*   Description:  Data0                                                */
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE0_DATA_ENABLE0_SHFT 0
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE0_DATA_ENABLE0_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_DATA_ENABLE1"               */
-/*                     MD enable compare SIC data1                      */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE1            0x0000000150031650
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE1_MASK       0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE1_INIT       0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_DATA_ENABLE1_DATA_ENABLE1                         */
-/*   Description:  Data1                                                */
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE1_DATA_ENABLE1_SHFT 0
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE1_DATA_ENABLE1_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_DATA_ENABLE2"               */
-/*                     MD enable compare SIC data2                      */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE2            0x0000000150031660
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE2_MASK       0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE2_INIT       0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_DATA_ENABLE2_DATA_ENABLE2                         */
-/*   Description:  Data2                                                */
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE2_DATA_ENABLE2_SHFT 0
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE2_DATA_ENABLE2_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_DATA_ENABLE3"               */
-/*                     MD enable compare SIC data3                      */
-/* ==================================================================== */
-
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE3            0x0000000150031670
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE3_MASK       0xffffffffffffffff
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE3_INIT       0x0000000000000000
-
-/*   SH_XN_MD_SIC_CMP_DATA_ENABLE3_DATA_ENABLE3                         */
-/*   Description:  Data3                                                */
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE3_DATA_ENABLE3_SHFT 0
-#define SH_XN_MD_SIC_CMP_DATA_ENABLE3_DATA_ENABLE3_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_IILB_CMP_EXP_DATA0"                */
-/*                 PI compare IILB input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_PI_IILB_CMP_EXP_DATA0              0x0000000150031300
-#define SH_XN_PI_IILB_CMP_EXP_DATA0_MASK         0xffffffffffffffff
-#define SH_XN_PI_IILB_CMP_EXP_DATA0_INIT         0x0000000000000000
-
-/*   SH_XN_PI_IILB_CMP_EXP_DATA0_DATA                                   */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_PI_IILB_CMP_EXP_DATA0_DATA_SHFT    0
-#define SH_XN_PI_IILB_CMP_EXP_DATA0_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_IILB_CMP_EXP_DATA1"                */
-/*                 PI compare IILB input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_PI_IILB_CMP_EXP_DATA1              0x0000000150031310
-#define SH_XN_PI_IILB_CMP_EXP_DATA1_MASK         0xffffffffffffffff
-#define SH_XN_PI_IILB_CMP_EXP_DATA1_INIT         0x0000000000000000
-
-/*   SH_XN_PI_IILB_CMP_EXP_DATA1_DATA                                   */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_PI_IILB_CMP_EXP_DATA1_DATA_SHFT    0
-#define SH_XN_PI_IILB_CMP_EXP_DATA1_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_IILB_CMP_ENABLE0"                 */
-/*                    PI compare IILB input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_PI_IILB_CMP_ENABLE0                0x0000000150031320
-#define SH_XN_PI_IILB_CMP_ENABLE0_MASK           0xffffffffffffffff
-#define SH_XN_PI_IILB_CMP_ENABLE0_INIT           0x0000000000000000
-
-/*   SH_XN_PI_IILB_CMP_ENABLE0_ENABLE                                   */
-/*   Description:  Enable0                                              */
-#define SH_XN_PI_IILB_CMP_ENABLE0_ENABLE_SHFT    0
-#define SH_XN_PI_IILB_CMP_ENABLE0_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_IILB_CMP_ENABLE1"                 */
-/*                    PI compare IILB input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_PI_IILB_CMP_ENABLE1                0x0000000150031330
-#define SH_XN_PI_IILB_CMP_ENABLE1_MASK           0xffffffffffffffff
-#define SH_XN_PI_IILB_CMP_ENABLE1_INIT           0x0000000000000000
-
-/*   SH_XN_PI_IILB_CMP_ENABLE1_ENABLE                                   */
-/*   Description:  Enable1                                              */
-#define SH_XN_PI_IILB_CMP_ENABLE1_ENABLE_SHFT    0
-#define SH_XN_PI_IILB_CMP_ENABLE1_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_NI0_CMP_EXP_DATA0"                 */
-/*                 PI compare NI0 input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_PI_NI0_CMP_EXP_DATA0               0x0000000150031340
-#define SH_XN_PI_NI0_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_PI_NI0_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_PI_NI0_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_PI_NI0_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_PI_NI0_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_NI0_CMP_EXP_DATA1"                 */
-/*                 PI compare NI0 input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_PI_NI0_CMP_EXP_DATA1               0x0000000150031350
-#define SH_XN_PI_NI0_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_PI_NI0_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_PI_NI0_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_PI_NI0_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_PI_NI0_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_NI0_CMP_ENABLE0"                  */
-/*                     PI compare NI0 input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_PI_NI0_CMP_ENABLE0                 0x0000000150031360
-#define SH_XN_PI_NI0_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_PI_NI0_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_PI_NI0_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_PI_NI0_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_PI_NI0_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_NI0_CMP_ENABLE1"                  */
-/*                     PI compare NI0 input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_PI_NI0_CMP_ENABLE1                 0x0000000150031370
-#define SH_XN_PI_NI0_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_PI_NI0_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_PI_NI0_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_PI_NI0_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_PI_NI0_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_NI1_CMP_EXP_DATA0"                 */
-/*                 PI compare NI1 input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_PI_NI1_CMP_EXP_DATA0               0x0000000150031380
-#define SH_XN_PI_NI1_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_PI_NI1_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_PI_NI1_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_PI_NI1_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_PI_NI1_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_NI1_CMP_EXP_DATA1"                 */
-/*                 PI compare NI1 input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_PI_NI1_CMP_EXP_DATA1               0x0000000150031390
-#define SH_XN_PI_NI1_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_PI_NI1_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_PI_NI1_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_PI_NI1_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_PI_NI1_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_NI1_CMP_ENABLE0"                  */
-/*                     PI compare NI1 input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_PI_NI1_CMP_ENABLE0                 0x00000001500313a0
-#define SH_XN_PI_NI1_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_PI_NI1_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_PI_NI1_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_PI_NI1_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_PI_NI1_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_NI1_CMP_ENABLE1"                  */
-/*                     PI compare NI1 input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_PI_NI1_CMP_ENABLE1                 0x00000001500313b0
-#define SH_XN_PI_NI1_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_PI_NI1_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_PI_NI1_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_PI_NI1_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_PI_NI1_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_SIC_CMP_EXP_HDR0"                 */
-/*                PI compare SIC input expected header0                 */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_EXP_HDR0                0x00000001500313c0
-#define SH_XN_PI_SIC_CMP_EXP_HDR0_MASK           0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_EXP_HDR0_INIT           0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_EXP_HDR0_DATA                                     */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_PI_SIC_CMP_EXP_HDR0_DATA_SHFT      0
-#define SH_XN_PI_SIC_CMP_EXP_HDR0_DATA_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_SIC_CMP_EXP_HDR1"                 */
-/*                PI compare SIC input expected header1                 */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_EXP_HDR1                0x00000001500313d0
-#define SH_XN_PI_SIC_CMP_EXP_HDR1_MASK           0x000003ffffffffff
-#define SH_XN_PI_SIC_CMP_EXP_HDR1_INIT           0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_EXP_HDR1_DATA                                     */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_PI_SIC_CMP_EXP_HDR1_DATA_SHFT      0
-#define SH_XN_PI_SIC_CMP_EXP_HDR1_DATA_MASK      0x000003ffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_HDR_ENABLE0"                */
-/*                    PI compare SIC header enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE0             0x00000001500313e0
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE0_MASK        0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE0_INIT        0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_HDR_ENABLE0_ENABLE                                */
-/*   Description:  Enable0                                              */
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE0_ENABLE_SHFT 0
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE0_ENABLE_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_HDR_ENABLE1"                */
-/*                    PI compare SIC header enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE1             0x00000001500313f0
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE1_MASK        0x000003ffffffffff
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE1_INIT        0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_HDR_ENABLE1_ENABLE                                */
-/*   Description:  Enable1                                              */
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE1_ENABLE_SHFT 0
-#define SH_XN_PI_SIC_CMP_HDR_ENABLE1_ENABLE_MASK 0x000003ffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XN_PI_SIC_CMP_DATA0"                   */
-/*                         PI compare SIC data0                         */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_DATA0                   0x0000000150031400
-#define SH_XN_PI_SIC_CMP_DATA0_MASK              0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_DATA0_INIT              0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_DATA0_DATA0                                       */
-/*   Description:  Data0                                                */
-#define SH_XN_PI_SIC_CMP_DATA0_DATA0_SHFT        0
-#define SH_XN_PI_SIC_CMP_DATA0_DATA0_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XN_PI_SIC_CMP_DATA1"                   */
-/*                         PI compare SIC data1                         */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_DATA1                   0x0000000150031410
-#define SH_XN_PI_SIC_CMP_DATA1_MASK              0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_DATA1_INIT              0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_DATA1_DATA1                                       */
-/*   Description:  Data1                                                */
-#define SH_XN_PI_SIC_CMP_DATA1_DATA1_SHFT        0
-#define SH_XN_PI_SIC_CMP_DATA1_DATA1_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XN_PI_SIC_CMP_DATA2"                   */
-/*                         PI compare SIC data2                         */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_DATA2                   0x0000000150031420
-#define SH_XN_PI_SIC_CMP_DATA2_MASK              0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_DATA2_INIT              0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_DATA2_DATA2                                       */
-/*   Description:  Data2                                                */
-#define SH_XN_PI_SIC_CMP_DATA2_DATA2_SHFT        0
-#define SH_XN_PI_SIC_CMP_DATA2_DATA2_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XN_PI_SIC_CMP_DATA3"                   */
-/*                         PI compare SIC data3                         */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_DATA3                   0x0000000150031430
-#define SH_XN_PI_SIC_CMP_DATA3_MASK              0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_DATA3_INIT              0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_DATA3_DATA3                                       */
-/*   Description:  Data3                                                */
-#define SH_XN_PI_SIC_CMP_DATA3_DATA3_SHFT        0
-#define SH_XN_PI_SIC_CMP_DATA3_DATA3_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_DATA_ENABLE0"               */
-/*                     PI enable compare SIC data0                      */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE0            0x0000000150031440
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE0_MASK       0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE0_INIT       0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_DATA_ENABLE0_DATA_ENABLE0                         */
-/*   Description:  Data0                                                */
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE0_DATA_ENABLE0_SHFT 0
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE0_DATA_ENABLE0_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_DATA_ENABLE1"               */
-/*                     PI enable compare SIC data1                      */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE1            0x0000000150031450
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE1_MASK       0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE1_INIT       0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_DATA_ENABLE1_DATA_ENABLE1                         */
-/*   Description:  Data1                                                */
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE1_DATA_ENABLE1_SHFT 0
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE1_DATA_ENABLE1_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_DATA_ENABLE2"               */
-/*                     PI enable compare SIC data2                      */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE2            0x0000000150031460
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE2_MASK       0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE2_INIT       0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_DATA_ENABLE2_DATA_ENABLE2                         */
-/*   Description:  Data2                                                */
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE2_DATA_ENABLE2_SHFT 0
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE2_DATA_ENABLE2_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_DATA_ENABLE3"               */
-/*                     PI enable compare SIC data3                      */
-/* ==================================================================== */
-
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE3            0x0000000150031470
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE3_MASK       0xffffffffffffffff
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE3_INIT       0x0000000000000000
-
-/*   SH_XN_PI_SIC_CMP_DATA_ENABLE3_DATA_ENABLE3                         */
-/*   Description:  Data3                                                */
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE3_DATA_ENABLE3_SHFT 0
-#define SH_XN_PI_SIC_CMP_DATA_ENABLE3_DATA_ENABLE3_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_NI0_IILB_CMP_EXP_DATA0"                */
-/*                NI0 compare IILB input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_NI0_IILB_CMP_EXP_DATA0             0x0000000150031700
-#define SH_XN_NI0_IILB_CMP_EXP_DATA0_MASK        0xffffffffffffffff
-#define SH_XN_NI0_IILB_CMP_EXP_DATA0_INIT        0x0000000000000000
-
-/*   SH_XN_NI0_IILB_CMP_EXP_DATA0_DATA                                  */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI0_IILB_CMP_EXP_DATA0_DATA_SHFT   0
-#define SH_XN_NI0_IILB_CMP_EXP_DATA0_DATA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_NI0_IILB_CMP_EXP_DATA1"                */
-/*                NI0 compare IILB input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_NI0_IILB_CMP_EXP_DATA1             0x0000000150031710
-#define SH_XN_NI0_IILB_CMP_EXP_DATA1_MASK        0xffffffffffffffff
-#define SH_XN_NI0_IILB_CMP_EXP_DATA1_INIT        0x0000000000000000
-
-/*   SH_XN_NI0_IILB_CMP_EXP_DATA1_DATA                                  */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI0_IILB_CMP_EXP_DATA1_DATA_SHFT   0
-#define SH_XN_NI0_IILB_CMP_EXP_DATA1_DATA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_IILB_CMP_ENABLE0"                 */
-/*                    NI0 compare IILB input enable0                    */
-/* ==================================================================== */
-
-#define SH_XN_NI0_IILB_CMP_ENABLE0               0x0000000150031720
-#define SH_XN_NI0_IILB_CMP_ENABLE0_MASK          0xffffffffffffffff
-#define SH_XN_NI0_IILB_CMP_ENABLE0_INIT          0x0000000000000000
-
-/*   SH_XN_NI0_IILB_CMP_ENABLE0_ENABLE                                  */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI0_IILB_CMP_ENABLE0_ENABLE_SHFT   0
-#define SH_XN_NI0_IILB_CMP_ENABLE0_ENABLE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_IILB_CMP_ENABLE1"                 */
-/*                    NI0 compare IILB input enable1                    */
-/* ==================================================================== */
-
-#define SH_XN_NI0_IILB_CMP_ENABLE1               0x0000000150031730
-#define SH_XN_NI0_IILB_CMP_ENABLE1_MASK          0xffffffffffffffff
-#define SH_XN_NI0_IILB_CMP_ENABLE1_INIT          0x0000000000000000
-
-/*   SH_XN_NI0_IILB_CMP_ENABLE1_ENABLE                                  */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI0_IILB_CMP_ENABLE1_ENABLE_SHFT   0
-#define SH_XN_NI0_IILB_CMP_ENABLE1_ENABLE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_PI_CMP_EXP_DATA0"                 */
-/*                 NI0 compare PI input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_NI0_PI_CMP_EXP_DATA0               0x0000000150031740
-#define SH_XN_NI0_PI_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_NI0_PI_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_NI0_PI_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI0_PI_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_NI0_PI_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_PI_CMP_EXP_DATA1"                 */
-/*                 NI0 compare PI input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_NI0_PI_CMP_EXP_DATA1               0x0000000150031750
-#define SH_XN_NI0_PI_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_NI0_PI_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_NI0_PI_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI0_PI_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_NI0_PI_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_PI_CMP_ENABLE0"                  */
-/*                     NI0 compare PI input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_NI0_PI_CMP_ENABLE0                 0x0000000150031760
-#define SH_XN_NI0_PI_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_NI0_PI_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_NI0_PI_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI0_PI_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_NI0_PI_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_PI_CMP_ENABLE1"                  */
-/*                     NI0 compare PI input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_NI0_PI_CMP_ENABLE1                 0x0000000150031770
-#define SH_XN_NI0_PI_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_NI0_PI_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_NI0_PI_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI0_PI_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_NI0_PI_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_MD_CMP_EXP_DATA0"                 */
-/*                 NI0 compare MD input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_NI0_MD_CMP_EXP_DATA0               0x0000000150031780
-#define SH_XN_NI0_MD_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_NI0_MD_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_NI0_MD_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI0_MD_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_NI0_MD_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_MD_CMP_EXP_DATA1"                 */
-/*                 NI0 compare MD input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_NI0_MD_CMP_EXP_DATA1               0x0000000150031790
-#define SH_XN_NI0_MD_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_NI0_MD_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_NI0_MD_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI0_MD_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_NI0_MD_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_MD_CMP_ENABLE0"                  */
-/*                     NI0 compare MD input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_NI0_MD_CMP_ENABLE0                 0x00000001500317a0
-#define SH_XN_NI0_MD_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_NI0_MD_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_NI0_MD_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI0_MD_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_NI0_MD_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_MD_CMP_ENABLE1"                  */
-/*                     NI0 compare MD input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_NI0_MD_CMP_ENABLE1                 0x00000001500317b0
-#define SH_XN_NI0_MD_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_NI0_MD_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_NI0_MD_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI0_MD_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_NI0_MD_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_NI_CMP_EXP_DATA0"                 */
-/*                 NI0 compare NI input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_NI0_NI_CMP_EXP_DATA0               0x00000001500317c0
-#define SH_XN_NI0_NI_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_NI0_NI_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_NI0_NI_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI0_NI_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_NI0_NI_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_NI_CMP_EXP_DATA1"                 */
-/*                 NI0 compare NI input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_NI0_NI_CMP_EXP_DATA1               0x00000001500317d0
-#define SH_XN_NI0_NI_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_NI0_NI_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_NI0_NI_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI0_NI_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_NI0_NI_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_NI_CMP_ENABLE0"                  */
-/*                     NI0 compare NI input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_NI0_NI_CMP_ENABLE0                 0x00000001500317e0
-#define SH_XN_NI0_NI_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_NI0_NI_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_NI0_NI_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI0_NI_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_NI0_NI_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_NI_CMP_ENABLE1"                  */
-/*                     NI0 compare NI input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_NI0_NI_CMP_ENABLE1                 0x00000001500317f0
-#define SH_XN_NI0_NI_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_NI0_NI_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_NI0_NI_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI0_NI_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_NI0_NI_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_LLP_CMP_EXP_DATA0"                */
-/*                 NI0 compare LLP input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_NI0_LLP_CMP_EXP_DATA0              0x0000000150031800
-#define SH_XN_NI0_LLP_CMP_EXP_DATA0_MASK         0xffffffffffffffff
-#define SH_XN_NI0_LLP_CMP_EXP_DATA0_INIT         0x0000000000000000
-
-/*   SH_XN_NI0_LLP_CMP_EXP_DATA0_DATA                                   */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI0_LLP_CMP_EXP_DATA0_DATA_SHFT    0
-#define SH_XN_NI0_LLP_CMP_EXP_DATA0_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_LLP_CMP_EXP_DATA1"                */
-/*                 NI0 compare LLP input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_NI0_LLP_CMP_EXP_DATA1              0x0000000150031810
-#define SH_XN_NI0_LLP_CMP_EXP_DATA1_MASK         0xffffffffffffffff
-#define SH_XN_NI0_LLP_CMP_EXP_DATA1_INIT         0x0000000000000000
-
-/*   SH_XN_NI0_LLP_CMP_EXP_DATA1_DATA                                   */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI0_LLP_CMP_EXP_DATA1_DATA_SHFT    0
-#define SH_XN_NI0_LLP_CMP_EXP_DATA1_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_LLP_CMP_ENABLE0"                 */
-/*                    NI0 compare LLP input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_NI0_LLP_CMP_ENABLE0                0x0000000150031820
-#define SH_XN_NI0_LLP_CMP_ENABLE0_MASK           0xffffffffffffffff
-#define SH_XN_NI0_LLP_CMP_ENABLE0_INIT           0x0000000000000000
-
-/*   SH_XN_NI0_LLP_CMP_ENABLE0_ENABLE                                   */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI0_LLP_CMP_ENABLE0_ENABLE_SHFT    0
-#define SH_XN_NI0_LLP_CMP_ENABLE0_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_LLP_CMP_ENABLE1"                 */
-/*                    NI0 compare LLP input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_NI0_LLP_CMP_ENABLE1                0x0000000150031830
-#define SH_XN_NI0_LLP_CMP_ENABLE1_MASK           0xffffffffffffffff
-#define SH_XN_NI0_LLP_CMP_ENABLE1_INIT           0x0000000000000000
-
-/*   SH_XN_NI0_LLP_CMP_ENABLE1_ENABLE                                   */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI0_LLP_CMP_ENABLE1_ENABLE_SHFT    0
-#define SH_XN_NI0_LLP_CMP_ENABLE1_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_NI1_IILB_CMP_EXP_DATA0"                */
-/*                NI1 compare IILB input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_NI1_IILB_CMP_EXP_DATA0             0x0000000150031900
-#define SH_XN_NI1_IILB_CMP_EXP_DATA0_MASK        0xffffffffffffffff
-#define SH_XN_NI1_IILB_CMP_EXP_DATA0_INIT        0x0000000000000000
-
-/*   SH_XN_NI1_IILB_CMP_EXP_DATA0_DATA                                  */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI1_IILB_CMP_EXP_DATA0_DATA_SHFT   0
-#define SH_XN_NI1_IILB_CMP_EXP_DATA0_DATA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*               Register "SH_XN_NI1_IILB_CMP_EXP_DATA1"                */
-/*                NI1 compare IILB input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_NI1_IILB_CMP_EXP_DATA1             0x0000000150031910
-#define SH_XN_NI1_IILB_CMP_EXP_DATA1_MASK        0xffffffffffffffff
-#define SH_XN_NI1_IILB_CMP_EXP_DATA1_INIT        0x0000000000000000
-
-/*   SH_XN_NI1_IILB_CMP_EXP_DATA1_DATA                                  */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI1_IILB_CMP_EXP_DATA1_DATA_SHFT   0
-#define SH_XN_NI1_IILB_CMP_EXP_DATA1_DATA_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_IILB_CMP_ENABLE0"                 */
-/*                    NI1 compare IILB input enable0                    */
-/* ==================================================================== */
-
-#define SH_XN_NI1_IILB_CMP_ENABLE0               0x0000000150031920
-#define SH_XN_NI1_IILB_CMP_ENABLE0_MASK          0xffffffffffffffff
-#define SH_XN_NI1_IILB_CMP_ENABLE0_INIT          0x0000000000000000
-
-/*   SH_XN_NI1_IILB_CMP_ENABLE0_ENABLE                                  */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI1_IILB_CMP_ENABLE0_ENABLE_SHFT   0
-#define SH_XN_NI1_IILB_CMP_ENABLE0_ENABLE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_IILB_CMP_ENABLE1"                 */
-/*                    NI1 compare IILB input enable1                    */
-/* ==================================================================== */
-
-#define SH_XN_NI1_IILB_CMP_ENABLE1               0x0000000150031930
-#define SH_XN_NI1_IILB_CMP_ENABLE1_MASK          0xffffffffffffffff
-#define SH_XN_NI1_IILB_CMP_ENABLE1_INIT          0x0000000000000000
-
-/*   SH_XN_NI1_IILB_CMP_ENABLE1_ENABLE                                  */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI1_IILB_CMP_ENABLE1_ENABLE_SHFT   0
-#define SH_XN_NI1_IILB_CMP_ENABLE1_ENABLE_MASK   0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_PI_CMP_EXP_DATA0"                 */
-/*                 NI1 compare PI input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_NI1_PI_CMP_EXP_DATA0               0x0000000150031940
-#define SH_XN_NI1_PI_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_NI1_PI_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_NI1_PI_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI1_PI_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_NI1_PI_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_PI_CMP_EXP_DATA1"                 */
-/*                 NI1 compare PI input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_NI1_PI_CMP_EXP_DATA1               0x0000000150031950
-#define SH_XN_NI1_PI_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_NI1_PI_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_NI1_PI_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI1_PI_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_NI1_PI_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_PI_CMP_ENABLE0"                  */
-/*                     NI1 compare PI input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_NI1_PI_CMP_ENABLE0                 0x0000000150031960
-#define SH_XN_NI1_PI_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_NI1_PI_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_NI1_PI_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI1_PI_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_NI1_PI_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_PI_CMP_ENABLE1"                  */
-/*                     NI1 compare PI input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_NI1_PI_CMP_ENABLE1                 0x0000000150031970
-#define SH_XN_NI1_PI_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_NI1_PI_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_NI1_PI_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI1_PI_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_NI1_PI_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_MD_CMP_EXP_DATA0"                 */
-/*                 NI1 compare MD input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_NI1_MD_CMP_EXP_DATA0               0x0000000150031980
-#define SH_XN_NI1_MD_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_NI1_MD_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_NI1_MD_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI1_MD_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_NI1_MD_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_MD_CMP_EXP_DATA1"                 */
-/*                 NI1 compare MD input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_NI1_MD_CMP_EXP_DATA1               0x0000000150031990
-#define SH_XN_NI1_MD_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_NI1_MD_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_NI1_MD_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI1_MD_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_NI1_MD_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_MD_CMP_ENABLE0"                  */
-/*                     NI1 compare MD input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_NI1_MD_CMP_ENABLE0                 0x00000001500319a0
-#define SH_XN_NI1_MD_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_NI1_MD_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_NI1_MD_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI1_MD_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_NI1_MD_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_MD_CMP_ENABLE1"                  */
-/*                     NI1 compare MD input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_NI1_MD_CMP_ENABLE1                 0x00000001500319b0
-#define SH_XN_NI1_MD_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_NI1_MD_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_NI1_MD_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI1_MD_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_NI1_MD_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_NI_CMP_EXP_DATA0"                 */
-/*                 NI1 compare NI input expected data0                  */
-/* ==================================================================== */
-
-#define SH_XN_NI1_NI_CMP_EXP_DATA0               0x00000001500319c0
-#define SH_XN_NI1_NI_CMP_EXP_DATA0_MASK          0xffffffffffffffff
-#define SH_XN_NI1_NI_CMP_EXP_DATA0_INIT          0x0000000000000000
-
-/*   SH_XN_NI1_NI_CMP_EXP_DATA0_DATA                                    */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI1_NI_CMP_EXP_DATA0_DATA_SHFT     0
-#define SH_XN_NI1_NI_CMP_EXP_DATA0_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_NI_CMP_EXP_DATA1"                 */
-/*                 NI1 compare NI input expected data1                  */
-/* ==================================================================== */
-
-#define SH_XN_NI1_NI_CMP_EXP_DATA1               0x00000001500319d0
-#define SH_XN_NI1_NI_CMP_EXP_DATA1_MASK          0xffffffffffffffff
-#define SH_XN_NI1_NI_CMP_EXP_DATA1_INIT          0x0000000000000000
-
-/*   SH_XN_NI1_NI_CMP_EXP_DATA1_DATA                                    */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI1_NI_CMP_EXP_DATA1_DATA_SHFT     0
-#define SH_XN_NI1_NI_CMP_EXP_DATA1_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_NI_CMP_ENABLE0"                  */
-/*                     NI1 compare NI input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_NI1_NI_CMP_ENABLE0                 0x00000001500319e0
-#define SH_XN_NI1_NI_CMP_ENABLE0_MASK            0xffffffffffffffff
-#define SH_XN_NI1_NI_CMP_ENABLE0_INIT            0x0000000000000000
-
-/*   SH_XN_NI1_NI_CMP_ENABLE0_ENABLE                                    */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI1_NI_CMP_ENABLE0_ENABLE_SHFT     0
-#define SH_XN_NI1_NI_CMP_ENABLE0_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_NI_CMP_ENABLE1"                  */
-/*                     NI1 compare NI input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_NI1_NI_CMP_ENABLE1                 0x00000001500319f0
-#define SH_XN_NI1_NI_CMP_ENABLE1_MASK            0xffffffffffffffff
-#define SH_XN_NI1_NI_CMP_ENABLE1_INIT            0x0000000000000000
-
-/*   SH_XN_NI1_NI_CMP_ENABLE1_ENABLE                                    */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI1_NI_CMP_ENABLE1_ENABLE_SHFT     0
-#define SH_XN_NI1_NI_CMP_ENABLE1_ENABLE_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_LLP_CMP_EXP_DATA0"                */
-/*                 NI1 compare LLP input expected data0                 */
-/* ==================================================================== */
-
-#define SH_XN_NI1_LLP_CMP_EXP_DATA0              0x0000000150031a00
-#define SH_XN_NI1_LLP_CMP_EXP_DATA0_MASK         0xffffffffffffffff
-#define SH_XN_NI1_LLP_CMP_EXP_DATA0_INIT         0x0000000000000000
-
-/*   SH_XN_NI1_LLP_CMP_EXP_DATA0_DATA                                   */
-/*   Description:  Expected data 0                                      */
-#define SH_XN_NI1_LLP_CMP_EXP_DATA0_DATA_SHFT    0
-#define SH_XN_NI1_LLP_CMP_EXP_DATA0_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_LLP_CMP_EXP_DATA1"                */
-/*                 NI1 compare LLP input expected data1                 */
-/* ==================================================================== */
-
-#define SH_XN_NI1_LLP_CMP_EXP_DATA1              0x0000000150031a10
-#define SH_XN_NI1_LLP_CMP_EXP_DATA1_MASK         0xffffffffffffffff
-#define SH_XN_NI1_LLP_CMP_EXP_DATA1_INIT         0x0000000000000000
-
-/*   SH_XN_NI1_LLP_CMP_EXP_DATA1_DATA                                   */
-/*   Description:  Expected data 1                                      */
-#define SH_XN_NI1_LLP_CMP_EXP_DATA1_DATA_SHFT    0
-#define SH_XN_NI1_LLP_CMP_EXP_DATA1_DATA_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_LLP_CMP_ENABLE0"                 */
-/*                    NI1 compare LLP input enable0                     */
-/* ==================================================================== */
-
-#define SH_XN_NI1_LLP_CMP_ENABLE0                0x0000000150031a20
-#define SH_XN_NI1_LLP_CMP_ENABLE0_MASK           0xffffffffffffffff
-#define SH_XN_NI1_LLP_CMP_ENABLE0_INIT           0x0000000000000000
-
-/*   SH_XN_NI1_LLP_CMP_ENABLE0_ENABLE                                   */
-/*   Description:  Enable0                                              */
-#define SH_XN_NI1_LLP_CMP_ENABLE0_ENABLE_SHFT    0
-#define SH_XN_NI1_LLP_CMP_ENABLE0_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_LLP_CMP_ENABLE1"                 */
-/*                    NI1 compare LLP input enable1                     */
-/* ==================================================================== */
-
-#define SH_XN_NI1_LLP_CMP_ENABLE1                0x0000000150031a30
-#define SH_XN_NI1_LLP_CMP_ENABLE1_MASK           0xffffffffffffffff
-#define SH_XN_NI1_LLP_CMP_ENABLE1_INIT           0x0000000000000000
-
-/*   SH_XN_NI1_LLP_CMP_ENABLE1_ENABLE                                   */
-/*   Description:  Enable1                                              */
-#define SH_XN_NI1_LLP_CMP_ENABLE1_ENABLE_SHFT    0
-#define SH_XN_NI1_LLP_CMP_ENABLE1_ENABLE_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_XNPI_ECC_INJ_REG"                    */
-/* ==================================================================== */
-
-#define SH_XNPI_ECC_INJ_REG                      0x0000000150032000
-#define SH_XNPI_ECC_INJ_REG_MASK                 0xf0fff0fff0fff0ff
-#define SH_XNPI_ECC_INJ_REG_INIT                 0x0000000000000000
-
-/*   SH_XNPI_ECC_INJ_REG_BYTE0                                          */
-/*   Description:  Replacement Checkbyte                                */
-#define SH_XNPI_ECC_INJ_REG_BYTE0_SHFT           0
-#define SH_XNPI_ECC_INJ_REG_BYTE0_MASK           0x00000000000000ff
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_1SHOT0                                    */
-/*   Description:  1 shot mask data                                     */
-#define SH_XNPI_ECC_INJ_REG_DATA_1SHOT0_SHFT     12
-#define SH_XNPI_ECC_INJ_REG_DATA_1SHOT0_MASK     0x0000000000001000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CONT0                                     */
-/*   Description:  toggle mask data                                     */
-#define SH_XNPI_ECC_INJ_REG_DATA_CONT0_SHFT      13
-#define SH_XNPI_ECC_INJ_REG_DATA_CONT0_MASK      0x0000000000002000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT0                                 */
-/*   Description:  Replace Checkbyte One Shot                           */
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT0_SHFT  14
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT0_MASK  0x0000000000004000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CB_CONT0                                  */
-/*   Description:  Replace Checkbyte Continuous                         */
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_CONT0_SHFT   15
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_CONT0_MASK   0x0000000000008000
-
-/*   SH_XNPI_ECC_INJ_REG_BYTE1                                          */
-/*   Description:  Replacement Checkbyte                                */
-#define SH_XNPI_ECC_INJ_REG_BYTE1_SHFT           16
-#define SH_XNPI_ECC_INJ_REG_BYTE1_MASK           0x0000000000ff0000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_1SHOT1                                    */
-/*   Description:  1 shot mask data                                     */
-#define SH_XNPI_ECC_INJ_REG_DATA_1SHOT1_SHFT     28
-#define SH_XNPI_ECC_INJ_REG_DATA_1SHOT1_MASK     0x0000000010000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CONT1                                     */
-/*   Description:  toggle mask data                                     */
-#define SH_XNPI_ECC_INJ_REG_DATA_CONT1_SHFT      29
-#define SH_XNPI_ECC_INJ_REG_DATA_CONT1_MASK      0x0000000020000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT1                                 */
-/*   Description:  Replace Checkbyte One Shot                           */
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT1_SHFT  30
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT1_MASK  0x0000000040000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CB_CONT1                                  */
-/*   Description:  Replace Checkbyte Continous                          */
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_CONT1_SHFT   31
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_CONT1_MASK   0x0000000080000000
-
-/*   SH_XNPI_ECC_INJ_REG_BYTE2                                          */
-/*   Description:  Replacement Checkbyte                                */
-#define SH_XNPI_ECC_INJ_REG_BYTE2_SHFT           32
-#define SH_XNPI_ECC_INJ_REG_BYTE2_MASK           0x000000ff00000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_1SHOT2                                    */
-/*   Description:  1 shot mask data                                     */
-#define SH_XNPI_ECC_INJ_REG_DATA_1SHOT2_SHFT     44
-#define SH_XNPI_ECC_INJ_REG_DATA_1SHOT2_MASK     0x0000100000000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CONT2                                     */
-/*   Description:  toggle mask data                                     */
-#define SH_XNPI_ECC_INJ_REG_DATA_CONT2_SHFT      45
-#define SH_XNPI_ECC_INJ_REG_DATA_CONT2_MASK      0x0000200000000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT2                                 */
-/*   Description:  Replace Checkbyte OneShot                            */
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT2_SHFT  46
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT2_MASK  0x0000400000000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CB_CONT2                                  */
-/*   Description:  Replace Checkbyte Continous                          */
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_CONT2_SHFT   47
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_CONT2_MASK   0x0000800000000000
-
-/*   SH_XNPI_ECC_INJ_REG_BYTE3                                          */
-/*   Description:  Replacement Checkbyte                                */
-#define SH_XNPI_ECC_INJ_REG_BYTE3_SHFT           48
-#define SH_XNPI_ECC_INJ_REG_BYTE3_MASK           0x00ff000000000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_1SHOT3                                    */
-/*   Description:  1 shot mask data                                     */
-#define SH_XNPI_ECC_INJ_REG_DATA_1SHOT3_SHFT     60
-#define SH_XNPI_ECC_INJ_REG_DATA_1SHOT3_MASK     0x1000000000000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CONT3                                     */
-/*   Description:  toggle mask data                                     */
-#define SH_XNPI_ECC_INJ_REG_DATA_CONT3_SHFT      61
-#define SH_XNPI_ECC_INJ_REG_DATA_CONT3_MASK      0x2000000000000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT3                                 */
-/*   Description:  Replace Checkbyte One-Shot                           */
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT3_SHFT  62
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_1SHOT3_MASK  0x4000000000000000
-
-/*   SH_XNPI_ECC_INJ_REG_DATA_CB_CONT3                                  */
-/*   Description:  Replace Checkbyte Continous                          */
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_CONT3_SHFT   63
-#define SH_XNPI_ECC_INJ_REG_DATA_CB_CONT3_MASK   0x8000000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_ECC0_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-#define SH_XNPI_ECC0_INJ_MASK_REG                0x0000000150032008
-#define SH_XNPI_ECC0_INJ_MASK_REG_MASK           0xffffffffffffffff
-#define SH_XNPI_ECC0_INJ_MASK_REG_INIT           0x0000000000000000
-
-/*   SH_XNPI_ECC0_INJ_MASK_REG_MASK_ECC0                                */
-/*   Description:  Replacement Data                                     */
-#define SH_XNPI_ECC0_INJ_MASK_REG_MASK_ECC0_SHFT 0
-#define SH_XNPI_ECC0_INJ_MASK_REG_MASK_ECC0_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_ECC1_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-#define SH_XNPI_ECC1_INJ_MASK_REG                0x0000000150032010
-#define SH_XNPI_ECC1_INJ_MASK_REG_MASK           0xffffffffffffffff
-#define SH_XNPI_ECC1_INJ_MASK_REG_INIT           0x0000000000000000
-
-/*   SH_XNPI_ECC1_INJ_MASK_REG_MASK_ECC1                                */
-/*   Description:  Replacement Data                                     */
-#define SH_XNPI_ECC1_INJ_MASK_REG_MASK_ECC1_SHFT 0
-#define SH_XNPI_ECC1_INJ_MASK_REG_MASK_ECC1_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_ECC2_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-#define SH_XNPI_ECC2_INJ_MASK_REG                0x0000000150032018
-#define SH_XNPI_ECC2_INJ_MASK_REG_MASK           0xffffffffffffffff
-#define SH_XNPI_ECC2_INJ_MASK_REG_INIT           0x0000000000000000
-
-/*   SH_XNPI_ECC2_INJ_MASK_REG_MASK_ECC2                                */
-/*   Description:  Replacement Data                                     */
-#define SH_XNPI_ECC2_INJ_MASK_REG_MASK_ECC2_SHFT 0
-#define SH_XNPI_ECC2_INJ_MASK_REG_MASK_ECC2_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_ECC3_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-#define SH_XNPI_ECC3_INJ_MASK_REG                0x0000000150032020
-#define SH_XNPI_ECC3_INJ_MASK_REG_MASK           0xffffffffffffffff
-#define SH_XNPI_ECC3_INJ_MASK_REG_INIT           0x0000000000000000
-
-/*   SH_XNPI_ECC3_INJ_MASK_REG_MASK_ECC3                                */
-/*   Description:  Replacement Data                                     */
-#define SH_XNPI_ECC3_INJ_MASK_REG_MASK_ECC3_SHFT 0
-#define SH_XNPI_ECC3_INJ_MASK_REG_MASK_ECC3_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_XNMD_ECC_INJ_REG"                    */
-/* ==================================================================== */
-
-#define SH_XNMD_ECC_INJ_REG                      0x0000000150032030
-#define SH_XNMD_ECC_INJ_REG_MASK                 0xf0fff0fff0fff0ff
-#define SH_XNMD_ECC_INJ_REG_INIT                 0x0000000000000000
-
-/*   SH_XNMD_ECC_INJ_REG_BYTE0                                          */
-/*   Description:  Replacement Checkbyte                                */
-#define SH_XNMD_ECC_INJ_REG_BYTE0_SHFT           0
-#define SH_XNMD_ECC_INJ_REG_BYTE0_MASK           0x00000000000000ff
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_1SHOT0                                    */
-/*   Description:  1 shot mask data                                     */
-#define SH_XNMD_ECC_INJ_REG_DATA_1SHOT0_SHFT     12
-#define SH_XNMD_ECC_INJ_REG_DATA_1SHOT0_MASK     0x0000000000001000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CONT0                                     */
-/*   Description:  toggle mask data                                     */
-#define SH_XNMD_ECC_INJ_REG_DATA_CONT0_SHFT      13
-#define SH_XNMD_ECC_INJ_REG_DATA_CONT0_MASK      0x0000000000002000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT0                                 */
-/*   Description:  Replace Checkbyte One Shot                           */
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT0_SHFT  14
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT0_MASK  0x0000000000004000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CB_CONT0                                  */
-/*   Description:  Replace Checkbyte Continuous                         */
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_CONT0_SHFT   15
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_CONT0_MASK   0x0000000000008000
-
-/*   SH_XNMD_ECC_INJ_REG_BYTE1                                          */
-/*   Description:  Replacement Checkbyte                                */
-#define SH_XNMD_ECC_INJ_REG_BYTE1_SHFT           16
-#define SH_XNMD_ECC_INJ_REG_BYTE1_MASK           0x0000000000ff0000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_1SHOT1                                    */
-/*   Description:  1 shot mask data                                     */
-#define SH_XNMD_ECC_INJ_REG_DATA_1SHOT1_SHFT     28
-#define SH_XNMD_ECC_INJ_REG_DATA_1SHOT1_MASK     0x0000000010000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CONT1                                     */
-/*   Description:  toggle mask data                                     */
-#define SH_XNMD_ECC_INJ_REG_DATA_CONT1_SHFT      29
-#define SH_XNMD_ECC_INJ_REG_DATA_CONT1_MASK      0x0000000020000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT1                                 */
-/*   Description:  Replace Checkbyte One Shot                           */
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT1_SHFT  30
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT1_MASK  0x0000000040000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CB_CONT1                                  */
-/*   Description:  Replace Checkbyte Continous                          */
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_CONT1_SHFT   31
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_CONT1_MASK   0x0000000080000000
-
-/*   SH_XNMD_ECC_INJ_REG_BYTE2                                          */
-/*   Description:  Replacement Checkbyte                                */
-#define SH_XNMD_ECC_INJ_REG_BYTE2_SHFT           32
-#define SH_XNMD_ECC_INJ_REG_BYTE2_MASK           0x000000ff00000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_1SHOT2                                    */
-/*   Description:  1 shot mask data                                     */
-#define SH_XNMD_ECC_INJ_REG_DATA_1SHOT2_SHFT     44
-#define SH_XNMD_ECC_INJ_REG_DATA_1SHOT2_MASK     0x0000100000000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CONT2                                     */
-/*   Description:  toggle mask data                                     */
-#define SH_XNMD_ECC_INJ_REG_DATA_CONT2_SHFT      45
-#define SH_XNMD_ECC_INJ_REG_DATA_CONT2_MASK      0x0000200000000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT2                                 */
-/*   Description:  Replace Checkbyte OneShot                            */
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT2_SHFT  46
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT2_MASK  0x0000400000000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CB_CONT2                                  */
-/*   Description:  Replace Checkbyte Continous                          */
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_CONT2_SHFT   47
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_CONT2_MASK   0x0000800000000000
-
-/*   SH_XNMD_ECC_INJ_REG_BYTE3                                          */
-/*   Description:  Replacement Checkbyte                                */
-#define SH_XNMD_ECC_INJ_REG_BYTE3_SHFT           48
-#define SH_XNMD_ECC_INJ_REG_BYTE3_MASK           0x00ff000000000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_1SHOT3                                    */
-/*   Description:  1 shot mask data                                     */
-#define SH_XNMD_ECC_INJ_REG_DATA_1SHOT3_SHFT     60
-#define SH_XNMD_ECC_INJ_REG_DATA_1SHOT3_MASK     0x1000000000000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CONT3                                     */
-/*   Description:  toggle mask data                                     */
-#define SH_XNMD_ECC_INJ_REG_DATA_CONT3_SHFT      61
-#define SH_XNMD_ECC_INJ_REG_DATA_CONT3_MASK      0x2000000000000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT3                                 */
-/*   Description:  Replace Checkbyte One-Shot                           */
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT3_SHFT  62
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_1SHOT3_MASK  0x4000000000000000
-
-/*   SH_XNMD_ECC_INJ_REG_DATA_CB_CONT3                                  */
-/*   Description:  Replace Checkbyte Continous                          */
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_CONT3_SHFT   63
-#define SH_XNMD_ECC_INJ_REG_DATA_CB_CONT3_MASK   0x8000000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_ECC0_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-#define SH_XNMD_ECC0_INJ_MASK_REG                0x0000000150032038
-#define SH_XNMD_ECC0_INJ_MASK_REG_MASK           0xffffffffffffffff
-#define SH_XNMD_ECC0_INJ_MASK_REG_INIT           0x0000000000000000
-
-/*   SH_XNMD_ECC0_INJ_MASK_REG_MASK_ECC0                                */
-/*   Description:  Replacement Data                                     */
-#define SH_XNMD_ECC0_INJ_MASK_REG_MASK_ECC0_SHFT 0
-#define SH_XNMD_ECC0_INJ_MASK_REG_MASK_ECC0_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_ECC1_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-#define SH_XNMD_ECC1_INJ_MASK_REG                0x0000000150032040
-#define SH_XNMD_ECC1_INJ_MASK_REG_MASK           0xffffffffffffffff
-#define SH_XNMD_ECC1_INJ_MASK_REG_INIT           0x0000000000000000
-
-/*   SH_XNMD_ECC1_INJ_MASK_REG_MASK_ECC1                                */
-/*   Description:  Replacement Data                                     */
-#define SH_XNMD_ECC1_INJ_MASK_REG_MASK_ECC1_SHFT 0
-#define SH_XNMD_ECC1_INJ_MASK_REG_MASK_ECC1_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_ECC2_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-#define SH_XNMD_ECC2_INJ_MASK_REG                0x0000000150032048
-#define SH_XNMD_ECC2_INJ_MASK_REG_MASK           0xffffffffffffffff
-#define SH_XNMD_ECC2_INJ_MASK_REG_INIT           0x0000000000000000
-
-/*   SH_XNMD_ECC2_INJ_MASK_REG_MASK_ECC2                                */
-/*   Description:  Replacement Data                                     */
-#define SH_XNMD_ECC2_INJ_MASK_REG_MASK_ECC2_SHFT 0
-#define SH_XNMD_ECC2_INJ_MASK_REG_MASK_ECC2_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_ECC3_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-#define SH_XNMD_ECC3_INJ_MASK_REG                0x0000000150032050
-#define SH_XNMD_ECC3_INJ_MASK_REG_MASK           0xffffffffffffffff
-#define SH_XNMD_ECC3_INJ_MASK_REG_INIT           0x0000000000000000
-
-/*   SH_XNMD_ECC3_INJ_MASK_REG_MASK_ECC3                                */
-/*   Description:  Replacement Data                                     */
-#define SH_XNMD_ECC3_INJ_MASK_REG_MASK_ECC3_SHFT 0
-#define SH_XNMD_ECC3_INJ_MASK_REG_MASK_ECC3_MASK 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_XNMD_ECC_ERR_REPORT"                   */
-/* ==================================================================== */
-
-#define SH_XNMD_ECC_ERR_REPORT                   0x0000000150032058
-#define SH_XNMD_ECC_ERR_REPORT_MASK              0x0001000100010001
-#define SH_XNMD_ECC_ERR_REPORT_INIT              0x0000000000000000
-
-/*   SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE0                                */
-/*   Description:  Disable Error Correction                             */
-#define SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE0_SHFT 0
-#define SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE0_MASK 0x0000000000000001
-
-/*   SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE1                                */
-/*   Description:  Disable Error Correction                             */
-#define SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE1_SHFT 16
-#define SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE1_MASK 0x0000000000010000
-
-/*   SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE2                                */
-/*   Description:  Disable Error Correction                             */
-#define SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE2_SHFT 32
-#define SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE2_MASK 0x0000000100000000
-
-/*   SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE3                                */
-/*   Description:  Disable Error Correction                             */
-#define SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE3_SHFT 48
-#define SH_XNMD_ECC_ERR_REPORT_ECC_DISABLE3_MASK 0x0001000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_ERROR_SUMMARY_1"                   */
-/*                       ni0  Error Summary Bits                        */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_SUMMARY_1                   0x0000000150040500
-#define SH_NI0_ERROR_SUMMARY_1_MASK              0xffffffffffffffff
-#define SH_NI0_ERROR_SUMMARY_1_INIT              0xffffffffffffffff
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT0                      */
-/*   Description:  Fifo 02 debit0 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT0_SHFT 0
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT2                      */
-/*   Description:  Fifo 02 debit2 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT2_SHFT 1
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT0                      */
-/*   Description:  Fifo 13 debit0 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT0_SHFT 2
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT2                      */
-/*   Description:  Fifo 13 debit2 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT2_SHFT 3
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_POP                     */
-/*   Description:  Fifo 02 vc0 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_POP                     */
-/*   Description:  Fifo 02 vc2 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_POP                     */
-/*   Description:  Fifo 13 vc1 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_POP                     */
-/*   Description:  Fifo 13 vc3 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_PUSH                    */
-/*   Description:  Fifo 02 vc0 push overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_PUSH                    */
-/*   Description:  Fifo 02 vc2 push overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_PUSH                    */
-/*   Description:  Fifo 13 vc1 push overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_PUSH                    */
-/*   Description:  Fifo 13 vc3 push overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_CREDIT                  */
-/*   Description:  Fifo 02 vc0 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_CREDIT                  */
-/*   Description:  Fifo 02 vc2 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC0_CREDIT                  */
-/*   Description:  Fifo 13 vc0 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC2_CREDIT                  */
-/*   Description:  Fifo 13 vc2 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW0_VC0_CREDIT                        */
-/*   Description:  VC0 credit overflow 0                                */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW1_VC0_CREDIT                        */
-/*   Description:  VC0 credit overflow 1                                */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW2_VC0_CREDIT                        */
-/*   Description:  VC0 credit overflow 2                                */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW0_VC2_CREDIT                        */
-/*   Description:  VC2 credit overflow 0                                */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW1_VC2_CREDIT                        */
-/*   Description:  VC2 credit overflow 1                                */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW2_VC2_CREDIT                        */
-/*   Description:  VC2 credit overflow 2                                */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT0                     */
-/*   Description:  PI Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT0_SHFT 22
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT0_MASK 0x0000000000400000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT2                     */
-/*   Description:  PI Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT2_SHFT 23
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT2_MASK 0x0000000000800000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT0                   */
-/*   Description:  IILB Fifo debit0 overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT0_SHFT 24
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT0_MASK 0x0000000001000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT2                   */
-/*   Description:  IILB Fifo debit2 overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT2_SHFT 25
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT2_MASK 0x0000000002000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT0                     */
-/*   Description:  MD Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT0_SHFT 26
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT0_MASK 0x0000000004000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT2                     */
-/*   Description:  MD Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT2_SHFT 27
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT2_MASK 0x0000000008000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT0                     */
-/*   Description:  NI Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT0_SHFT 28
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT0_MASK 0x0000000010000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT1                     */
-/*   Description:  NI Fifo debit1 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT1_SHFT 29
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT1_MASK 0x0000000020000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT2                     */
-/*   Description:  NI Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT2_SHFT 30
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT2_MASK 0x0000000040000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT3                     */
-/*   Description:  NI Fifo debit3 overflow                              */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT3_SHFT 31
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT3_MASK 0x0000000080000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_POP                    */
-/*   Description:  PI Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_POP                    */
-/*   Description:  PI Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_POP                  */
-/*   Description:  IILB Fifo vc0 pop overflow                           */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_POP                  */
-/*   Description:  IILB Fifo vc2 pop overflow                           */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_POP                    */
-/*   Description:  MD Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_POP                    */
-/*   Description:  MD Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_POP                    */
-/*   Description:  NI Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_POP                    */
-/*   Description:  NI Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_PUSH                   */
-/*   Description:  PI Fifo vc0 push overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_PUSH                   */
-/*   Description:  PI Fifo vc2 push overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_PUSH                 */
-/*   Description:  IILB Fifo vc0 push overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_PUSH                 */
-/*   Description:  IILB Fifo vc2 push overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_PUSH                   */
-/*   Description:  MD Fifo vc0 push overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_PUSH                   */
-/*   Description:  MD Fifo vc2 push overflow                            */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_CREDIT                 */
-/*   Description:  PI Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_CREDIT                 */
-/*   Description:  PI Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_CREDIT               */
-/*   Description:  IILB Fifo vc0 credit overflow                        */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_CREDIT               */
-/*   Description:  IILB Fifo vc2 credit overflow                        */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_CREDIT                 */
-/*   Description:  MD Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_CREDIT                 */
-/*   Description:  MD Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_CREDIT                 */
-/*   Description:  NI Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC1_CREDIT                 */
-/*   Description:  NI Fifo vc1 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_CREDIT                 */
-/*   Description:  NI Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC3_CREDIT                 */
-/*   Description:  NI Fifo vc3 credit overflow                          */
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI0_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC0                     */
-/*   Description:  Fifo02 vc0 tail timeout                              */
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC0_SHFT 56
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC0_MASK 0x0100000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC2                     */
-/*   Description:  Fifo02 vc2 tail timeout                              */
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC2_SHFT 57
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC2_MASK 0x0200000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC1                     */
-/*   Description:  Fifo13 vc1 tail timeout                              */
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC1_SHFT 58
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC1_MASK 0x0400000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC3                     */
-/*   Description:  Fifo13 vc3 tail timeout                              */
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC3_SHFT 59
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC3_MASK 0x0800000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC0                         */
-/*   Description:  NI vc0 tail timeout                                  */
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC0_SHFT 60
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC0_MASK 0x1000000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC1                         */
-/*   Description:  NI vc1 tail timeout                                  */
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC1_SHFT 61
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC1_MASK 0x2000000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC2                         */
-/*   Description:  NI vc2 tail timeout                                  */
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC2_SHFT 62
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC2_MASK 0x4000000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC3                         */
-/*   Description:  NI vc3 tail timeout                                  */
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC3_SHFT 63
-#define SH_NI0_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC3_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_NI0_ERROR_SUMMARY_1_ALIAS"                */
-/*                     ni0 Error Summary Bits Alias                     */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_SUMMARY_1_ALIAS             0x0000000150040508
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_ERROR_SUMMARY_2"                   */
-/*                       ni0  Error Summary Bits                        */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_SUMMARY_2                   0x0000000150040510
-#define SH_NI0_ERROR_SUMMARY_2_MASK              0x7fffffff003fffff
-#define SH_NI0_ERROR_SUMMARY_2_INIT              0x7fffffff003fffff
-
-/*   SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCNI                                */
-/*   Description:  Illegal VC NI                                        */
-#define SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCNI_SHFT 0
-#define SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCNI_MASK 0x0000000000000001
-
-/*   SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCPI                                */
-/*   Description:  Illegal VC PI                                        */
-#define SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCPI_SHFT 1
-#define SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCPI_MASK 0x0000000000000002
-
-/*   SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCMD                                */
-/*   Description:  Illegal VC MD                                        */
-#define SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCMD_SHFT 2
-#define SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCMD_MASK 0x0000000000000004
-
-/*   SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCIILB                              */
-/*   Description:  Illegal VC IILB                                      */
-#define SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCIILB_SHFT 3
-#define SH_NI0_ERROR_SUMMARY_2_ILLEGAL_VCIILB_MASK 0x0000000000000008
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_POP                    */
-/*   Description:  Fifo 02 vc0 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_POP                    */
-/*   Description:  Fifo 02 vc2 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_POP                    */
-/*   Description:  Fifo 13 vc1 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_POP                    */
-/*   Description:  Fifo 13 vc3 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_PUSH                   */
-/*   Description:  Fifo 02 vc0 push underflow                           */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_PUSH                   */
-/*   Description:  Fifo 02 vc2 push underflow                           */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_PUSH                   */
-/*   Description:  Fifo 13 vc1 push underflow                           */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_PUSH                   */
-/*   Description:  Fifo 13 vc3 push underflow                           */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_CREDIT                 */
-/*   Description:  Fifo 02 vc0 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_CREDIT                 */
-/*   Description:  Fifo 02 vc2 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC0_CREDIT                 */
-/*   Description:  Fifo 13 vc0 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC2_CREDIT                 */
-/*   Description:  Fifo 13 vc2 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW0_VC0_CREDIT                       */
-/*   Description:  VC0 credit underflow 0                               */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW1_VC0_CREDIT                       */
-/*   Description:  VC0 credit underflow 1                               */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW2_VC0_CREDIT                       */
-/*   Description:  VC0 credit underflow 2                               */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW0_VC2_CREDIT                       */
-/*   Description:  VC2 credit underflow 0                               */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW1_VC2_CREDIT                       */
-/*   Description:  VC2 credit underflow 1                               */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW2_VC2_CREDIT                       */
-/*   Description:  VC2 credit underflow 2                               */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_POP                   */
-/*   Description:  PI Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_POP                   */
-/*   Description:  PI Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_POP                 */
-/*   Description:  IILB Fifo vc0 pop underflow                          */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_POP                 */
-/*   Description:  IILB Fifo vc2 pop underflow                          */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_POP                   */
-/*   Description:  MD Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_POP                   */
-/*   Description:  MD Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_POP                   */
-/*   Description:  NI Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_POP                   */
-/*   Description:  NI Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_PUSH                  */
-/*   Description:  PI Fifo vc0 push underflow                           */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_PUSH                  */
-/*   Description:  PI Fifo vc2 push underflow                           */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_PUSH                */
-/*   Description:  IILB Fifo vc0 push underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_PUSH                */
-/*   Description:  IILB Fifo vc2 push underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_PUSH                  */
-/*   Description:  MD Fifo vc0 push underflow                           */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_PUSH                  */
-/*   Description:  MD Fifo vc2 push underflow                           */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_CREDIT                */
-/*   Description:  PI Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_CREDIT                */
-/*   Description:  PI Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT              */
-/*   Description:  IILB Fifo vc0 credit underflow                       */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT              */
-/*   Description:  IILB Fifo vc2 credit underflow                       */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_CREDIT                */
-/*   Description:  MD Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_CREDIT                */
-/*   Description:  MD Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_CREDIT                */
-/*   Description:  NI Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC1_CREDIT                */
-/*   Description:  NI Fifo vc1 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_CREDIT                */
-/*   Description:  NI Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC3_CREDIT                */
-/*   Description:  NI Fifo vc3 credit underflow                         */
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI0_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC0                            */
-/*   Description:  llp deadlock vc0                                     */
-#define SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC0_SHFT 56
-#define SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC0_MASK 0x0100000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC1                            */
-/*   Description:  llp deadlock vc1                                     */
-#define SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC1_SHFT 57
-#define SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC1_MASK 0x0200000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC2                            */
-/*   Description:  llp deadlock vc2                                     */
-#define SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC2_SHFT 58
-#define SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC2_MASK 0x0400000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC3                            */
-/*   Description:  llp deadlock vc3                                     */
-#define SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC3_SHFT 59
-#define SH_NI0_ERROR_SUMMARY_2_LLP_DEADLOCK_VC3_MASK 0x0800000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_CHIPLET_NOMATCH                             */
-/*   Description:  chiplet nomatch                                      */
-#define SH_NI0_ERROR_SUMMARY_2_CHIPLET_NOMATCH_SHFT 60
-#define SH_NI0_ERROR_SUMMARY_2_CHIPLET_NOMATCH_MASK 0x1000000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_LUT_READ_ERROR                              */
-/*   Description:  LUT Read Error                                       */
-#define SH_NI0_ERROR_SUMMARY_2_LUT_READ_ERROR_SHFT 61
-#define SH_NI0_ERROR_SUMMARY_2_LUT_READ_ERROR_MASK 0x2000000000000000
-
-/*   SH_NI0_ERROR_SUMMARY_2_RETRY_TIMEOUT_ERROR                         */
-/*   Description:  Retry Timeout Error                                  */
-#define SH_NI0_ERROR_SUMMARY_2_RETRY_TIMEOUT_ERROR_SHFT 62
-#define SH_NI0_ERROR_SUMMARY_2_RETRY_TIMEOUT_ERROR_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_NI0_ERROR_SUMMARY_2_ALIAS"                */
-/*                     ni0 Error Summary Bits Alias                     */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_SUMMARY_2_ALIAS             0x0000000150040518
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_ERROR_OVERFLOW_1"                  */
-/*                       ni0  Error Overflow Bits                       */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_OVERFLOW_1                  0x0000000150040520
-#define SH_NI0_ERROR_OVERFLOW_1_MASK             0xffffffffffffffff
-#define SH_NI0_ERROR_OVERFLOW_1_INIT             0xffffffffffffffff
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT0                     */
-/*   Description:  Fifo 02 debit0 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT0_SHFT 0
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT2                     */
-/*   Description:  Fifo 02 debit2 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT2_SHFT 1
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT0                     */
-/*   Description:  Fifo 13 debit0 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT0_SHFT 2
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT2                     */
-/*   Description:  Fifo 13 debit2 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT2_SHFT 3
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_POP                    */
-/*   Description:  Fifo 02 vc0 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_POP                    */
-/*   Description:  Fifo 02 vc2 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_POP                    */
-/*   Description:  Fifo 13 vc1 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_POP                    */
-/*   Description:  Fifo 13 vc3 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_PUSH                   */
-/*   Description:  Fifo 02 vc0 push overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_PUSH                   */
-/*   Description:  Fifo 02 vc2 push overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_PUSH                   */
-/*   Description:  Fifo 13 vc1 push overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_PUSH                   */
-/*   Description:  Fifo 13 vc3 push overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_CREDIT                 */
-/*   Description:  Fifo 02 vc0 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_CREDIT                 */
-/*   Description:  Fifo 02 vc2 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC0_CREDIT                 */
-/*   Description:  Fifo 13 vc0 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC2_CREDIT                 */
-/*   Description:  Fifo 13 vc2 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW0_VC0_CREDIT                       */
-/*   Description:  VC0 credit overflow 0                                */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW1_VC0_CREDIT                       */
-/*   Description:  VC0 credit overflow 1                                */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW2_VC0_CREDIT                       */
-/*   Description:  VC0 credit overflow 2                                */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW0_VC2_CREDIT                       */
-/*   Description:  VC2 credit overflow 0                                */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW1_VC2_CREDIT                       */
-/*   Description:  VC2 credit overflow 1                                */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW2_VC2_CREDIT                       */
-/*   Description:  VC2 credit overflow 2                                */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT0                    */
-/*   Description:  PI Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT0_SHFT 22
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT0_MASK 0x0000000000400000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT2                    */
-/*   Description:  PI Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT2_SHFT 23
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT2_MASK 0x0000000000800000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT0                  */
-/*   Description:  IILB Fifo debit0 overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT0_SHFT 24
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT0_MASK 0x0000000001000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT2                  */
-/*   Description:  IILB Fifo debit2 overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT2_SHFT 25
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT2_MASK 0x0000000002000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT0                    */
-/*   Description:  MD Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT0_SHFT 26
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT0_MASK 0x0000000004000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT2                    */
-/*   Description:  MD Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT2_SHFT 27
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT2_MASK 0x0000000008000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT0                    */
-/*   Description:  NI Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT0_SHFT 28
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT0_MASK 0x0000000010000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT1                    */
-/*   Description:  NI Fifo debit1 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT1_SHFT 29
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT1_MASK 0x0000000020000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT2                    */
-/*   Description:  NI Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT2_SHFT 30
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT2_MASK 0x0000000040000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT3                    */
-/*   Description:  NI Fifo debit3 overflow                              */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT3_SHFT 31
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT3_MASK 0x0000000080000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_POP                   */
-/*   Description:  PI Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_POP                   */
-/*   Description:  PI Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_POP                 */
-/*   Description:  IILB Fifo vc0 pop overflow                           */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_POP                 */
-/*   Description:  IILB Fifo vc2 pop overflow                           */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_POP                   */
-/*   Description:  MD Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_POP                   */
-/*   Description:  MD Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_POP                   */
-/*   Description:  NI Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_POP                   */
-/*   Description:  NI Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_PUSH                  */
-/*   Description:  PI Fifo vc0 push overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_PUSH                  */
-/*   Description:  PI Fifo vc2 push overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_PUSH                */
-/*   Description:  IILB Fifo vc0 push overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_PUSH                */
-/*   Description:  IILB Fifo vc2 push overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_PUSH                  */
-/*   Description:  MD Fifo vc0 push overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_PUSH                  */
-/*   Description:  MD Fifo vc2 push overflow                            */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_CREDIT                */
-/*   Description:  PI Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_CREDIT                */
-/*   Description:  PI Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_CREDIT              */
-/*   Description:  IILB Fifo vc0 credit overflow                        */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_CREDIT              */
-/*   Description:  IILB Fifo vc2 credit overflow                        */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_CREDIT                */
-/*   Description:  MD Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_CREDIT                */
-/*   Description:  MD Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_CREDIT                */
-/*   Description:  NI Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC1_CREDIT                */
-/*   Description:  NI Fifo vc1 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_CREDIT                */
-/*   Description:  NI Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC3_CREDIT                */
-/*   Description:  NI Fifo vc3 credit overflow                          */
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI0_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC0                    */
-/*   Description:  Fifo02 vc0 tail timeout                              */
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC0_SHFT 56
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC0_MASK 0x0100000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC2                    */
-/*   Description:  Fifo02 vc2 tail timeout                              */
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC2_SHFT 57
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC2_MASK 0x0200000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC1                    */
-/*   Description:  Fifo13 vc1 tail timeout                              */
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC1_SHFT 58
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC1_MASK 0x0400000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC3                    */
-/*   Description:  Fifo13 vc3 tail timeout                              */
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC3_SHFT 59
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC3_MASK 0x0800000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC0                        */
-/*   Description:  NI vc0 tail timeout                                  */
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC0_SHFT 60
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC0_MASK 0x1000000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC1                        */
-/*   Description:  NI vc1 tail timeout                                  */
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC1_SHFT 61
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC1_MASK 0x2000000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC2                        */
-/*   Description:  NI vc2 tail timeout                                  */
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC2_SHFT 62
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC2_MASK 0x4000000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC3                        */
-/*   Description:  NI vc3 tail timeout                                  */
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC3_SHFT 63
-#define SH_NI0_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC3_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_NI0_ERROR_OVERFLOW_1_ALIAS"               */
-/*                    ni0 Error Overflow Bits Alias                     */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_OVERFLOW_1_ALIAS            0x0000000150040528
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_ERROR_OVERFLOW_2"                  */
-/*                       ni0  Error Overflow Bits                       */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_OVERFLOW_2                  0x0000000150040530
-#define SH_NI0_ERROR_OVERFLOW_2_MASK             0x7fffffff003fffff
-#define SH_NI0_ERROR_OVERFLOW_2_INIT             0x7fffffff003fffff
-
-/*   SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCNI                               */
-/*   Description:  Illegal VC NI                                        */
-#define SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCNI_SHFT 0
-#define SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCNI_MASK 0x0000000000000001
-
-/*   SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCPI                               */
-/*   Description:  Illegal VC PI                                        */
-#define SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCPI_SHFT 1
-#define SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCPI_MASK 0x0000000000000002
-
-/*   SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCMD                               */
-/*   Description:  Illegal VC MD                                        */
-#define SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCMD_SHFT 2
-#define SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCMD_MASK 0x0000000000000004
-
-/*   SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCIILB                             */
-/*   Description:  Illegal VC IILB                                      */
-#define SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCIILB_SHFT 3
-#define SH_NI0_ERROR_OVERFLOW_2_ILLEGAL_VCIILB_MASK 0x0000000000000008
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_POP                   */
-/*   Description:  Fifo 02 vc0 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_POP                   */
-/*   Description:  Fifo 02 vc2 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_POP                   */
-/*   Description:  Fifo 13 vc1 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_POP                   */
-/*   Description:  Fifo 13 vc3 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_PUSH                  */
-/*   Description:  Fifo 02 vc0 push underflow                           */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_PUSH                  */
-/*   Description:  Fifo 02 vc2 push underflow                           */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_PUSH                  */
-/*   Description:  Fifo 13 vc1 push underflow                           */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_PUSH                  */
-/*   Description:  Fifo 13 vc3 push underflow                           */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_CREDIT                */
-/*   Description:  Fifo 02 vc0 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_CREDIT                */
-/*   Description:  Fifo 02 vc2 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC0_CREDIT                */
-/*   Description:  Fifo 13 vc0 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC2_CREDIT                */
-/*   Description:  Fifo 13 vc2 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW0_VC0_CREDIT                      */
-/*   Description:  VC0 credit underflow 0                               */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW1_VC0_CREDIT                      */
-/*   Description:  VC0 credit underflow 1                               */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW2_VC0_CREDIT                      */
-/*   Description:  VC0 credit underflow 2                               */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW0_VC2_CREDIT                      */
-/*   Description:  VC2 credit underflow 0                               */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW1_VC2_CREDIT                      */
-/*   Description:  VC2 credit underflow 1                               */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW2_VC2_CREDIT                      */
-/*   Description:  VC2 credit underflow 2                               */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_POP                  */
-/*   Description:  PI Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_POP                  */
-/*   Description:  PI Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_POP                */
-/*   Description:  IILB Fifo vc0 pop underflow                          */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_POP                */
-/*   Description:  IILB Fifo vc2 pop underflow                          */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_POP                  */
-/*   Description:  MD Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_POP                  */
-/*   Description:  MD Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_POP                  */
-/*   Description:  NI Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_POP                  */
-/*   Description:  NI Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_PUSH                 */
-/*   Description:  PI Fifo vc0 push underflow                           */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_PUSH                 */
-/*   Description:  PI Fifo vc2 push underflow                           */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_PUSH               */
-/*   Description:  IILB Fifo vc0 push underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_PUSH               */
-/*   Description:  IILB Fifo vc2 push underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_PUSH                 */
-/*   Description:  MD Fifo vc0 push underflow                           */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_PUSH                 */
-/*   Description:  MD Fifo vc2 push underflow                           */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_CREDIT               */
-/*   Description:  PI Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_CREDIT               */
-/*   Description:  PI Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT             */
-/*   Description:  IILB Fifo vc0 credit underflow                       */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT             */
-/*   Description:  IILB Fifo vc2 credit underflow                       */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_CREDIT               */
-/*   Description:  MD Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_CREDIT               */
-/*   Description:  MD Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_CREDIT               */
-/*   Description:  NI Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC1_CREDIT               */
-/*   Description:  NI Fifo vc1 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_CREDIT               */
-/*   Description:  NI Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC3_CREDIT               */
-/*   Description:  NI Fifo vc3 credit underflow                         */
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI0_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC0                           */
-/*   Description:  llp deadlock vc0                                     */
-#define SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC0_SHFT 56
-#define SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC0_MASK 0x0100000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC1                           */
-/*   Description:  llp deadlock vc1                                     */
-#define SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC1_SHFT 57
-#define SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC1_MASK 0x0200000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC2                           */
-/*   Description:  llp deadlock vc2                                     */
-#define SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC2_SHFT 58
-#define SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC2_MASK 0x0400000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC3                           */
-/*   Description:  llp deadlock vc3                                     */
-#define SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC3_SHFT 59
-#define SH_NI0_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC3_MASK 0x0800000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_CHIPLET_NOMATCH                            */
-/*   Description:  chiplet nomatch                                      */
-#define SH_NI0_ERROR_OVERFLOW_2_CHIPLET_NOMATCH_SHFT 60
-#define SH_NI0_ERROR_OVERFLOW_2_CHIPLET_NOMATCH_MASK 0x1000000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_LUT_READ_ERROR                             */
-/*   Description:  LUT Read Error                                       */
-#define SH_NI0_ERROR_OVERFLOW_2_LUT_READ_ERROR_SHFT 61
-#define SH_NI0_ERROR_OVERFLOW_2_LUT_READ_ERROR_MASK 0x2000000000000000
-
-/*   SH_NI0_ERROR_OVERFLOW_2_RETRY_TIMEOUT_ERROR                        */
-/*   Description:  Retry Timeout Error                                  */
-#define SH_NI0_ERROR_OVERFLOW_2_RETRY_TIMEOUT_ERROR_SHFT 62
-#define SH_NI0_ERROR_OVERFLOW_2_RETRY_TIMEOUT_ERROR_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_NI0_ERROR_OVERFLOW_2_ALIAS"               */
-/*                    ni0 Error Overflow Bits Alias                     */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_OVERFLOW_2_ALIAS            0x0000000150040538
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_ERROR_MASK_1"                    */
-/*                         ni0  Error Mask Bits                         */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_MASK_1                      0x0000000150040540
-#define SH_NI0_ERROR_MASK_1_MASK                 0xffffffffffffffff
-#define SH_NI0_ERROR_MASK_1_INIT                 0xffffffffffffffff
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT0                         */
-/*   Description:  Fifo 02 debit0 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT0_SHFT 0
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT2                         */
-/*   Description:  Fifo 02 debit2 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT2_SHFT 1
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT0                         */
-/*   Description:  Fifo 13 debit0 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT0_SHFT 2
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT2                         */
-/*   Description:  Fifo 13 debit2 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT2_SHFT 3
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_POP                        */
-/*   Description:  Fifo 02 vc0 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_POP                        */
-/*   Description:  Fifo 02 vc2 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_POP                        */
-/*   Description:  Fifo 13 vc1 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_POP                        */
-/*   Description:  Fifo 13 vc3 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_PUSH                       */
-/*   Description:  Fifo 02 vc0 push overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_PUSH                       */
-/*   Description:  Fifo 02 vc2 push overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_PUSH                       */
-/*   Description:  Fifo 13 vc1 push overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_PUSH                       */
-/*   Description:  Fifo 13 vc3 push overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_CREDIT                     */
-/*   Description:  Fifo 02 vc0 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_CREDIT                     */
-/*   Description:  Fifo 02 vc2 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC0_CREDIT                     */
-/*   Description:  Fifo 13 vc0 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC2_CREDIT                     */
-/*   Description:  Fifo 13 vc2 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW0_VC0_CREDIT                           */
-/*   Description:  VC0 credit overflow 0                                */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI0_ERROR_MASK_1_OVERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW1_VC0_CREDIT                           */
-/*   Description:  VC0 credit overflow 1                                */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI0_ERROR_MASK_1_OVERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW2_VC0_CREDIT                           */
-/*   Description:  VC0 credit overflow 2                                */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI0_ERROR_MASK_1_OVERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW0_VC2_CREDIT                           */
-/*   Description:  VC2 credit overflow 0                                */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI0_ERROR_MASK_1_OVERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW1_VC2_CREDIT                           */
-/*   Description:  VC2 credit overflow 1                                */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI0_ERROR_MASK_1_OVERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW2_VC2_CREDIT                           */
-/*   Description:  VC2 credit overflow 2                                */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI0_ERROR_MASK_1_OVERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT0                        */
-/*   Description:  PI Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT0_SHFT 22
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT0_MASK 0x0000000000400000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT2                        */
-/*   Description:  PI Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT2_SHFT 23
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT2_MASK 0x0000000000800000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT0                      */
-/*   Description:  IILB Fifo debit0 overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT0_SHFT 24
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT0_MASK 0x0000000001000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT2                      */
-/*   Description:  IILB Fifo debit2 overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT2_SHFT 25
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT2_MASK 0x0000000002000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT0                        */
-/*   Description:  MD Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT0_SHFT 26
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT0_MASK 0x0000000004000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT2                        */
-/*   Description:  MD Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT2_SHFT 27
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT2_MASK 0x0000000008000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT0                        */
-/*   Description:  NI Fifo debit0 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT0_SHFT 28
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT0_MASK 0x0000000010000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT1                        */
-/*   Description:  NI Fifo debit1 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT1_SHFT 29
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT1_MASK 0x0000000020000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT2                        */
-/*   Description:  NI Fifo debit2 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT2_SHFT 30
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT2_MASK 0x0000000040000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT3                        */
-/*   Description:  NI Fifo debit3 overflow                              */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT3_SHFT 31
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT3_MASK 0x0000000080000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_POP                       */
-/*   Description:  PI Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_POP                       */
-/*   Description:  PI Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_POP                     */
-/*   Description:  IILB Fifo vc0 pop overflow                           */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_POP                     */
-/*   Description:  IILB Fifo vc2 pop overflow                           */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_POP                       */
-/*   Description:  MD Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_POP                       */
-/*   Description:  MD Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_POP                       */
-/*   Description:  NI Fifo vc0 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_POP                       */
-/*   Description:  NI Fifo vc2 pop overflow                             */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_PUSH                      */
-/*   Description:  PI Fifo vc0 push overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_PUSH                      */
-/*   Description:  PI Fifo vc2 push overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_PUSH                    */
-/*   Description:  IILB Fifo vc0 push overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_PUSH                    */
-/*   Description:  IILB Fifo vc2 push overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_PUSH                      */
-/*   Description:  MD Fifo vc0 push overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_PUSH                      */
-/*   Description:  MD Fifo vc2 push overflow                            */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_CREDIT                    */
-/*   Description:  PI Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_CREDIT                    */
-/*   Description:  PI Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_CREDIT                  */
-/*   Description:  IILB Fifo vc0 credit overflow                        */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_CREDIT                  */
-/*   Description:  IILB Fifo vc2 credit overflow                        */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_CREDIT                    */
-/*   Description:  MD Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_CREDIT                    */
-/*   Description:  MD Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_CREDIT                    */
-/*   Description:  NI Fifo vc0 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC1_CREDIT                    */
-/*   Description:  NI Fifo vc1 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_CREDIT                    */
-/*   Description:  NI Fifo vc2 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC3_CREDIT                    */
-/*   Description:  NI Fifo vc3 credit overflow                          */
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI0_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC0                        */
-/*   Description:  Fifo02 vc0 tail timeout                              */
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC0_SHFT 56
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC0_MASK 0x0100000000000000
-
-/*   SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC2                        */
-/*   Description:  Fifo02 vc2 tail timeout                              */
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC2_SHFT 57
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC2_MASK 0x0200000000000000
-
-/*   SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC1                        */
-/*   Description:  Fifo13 vc1 tail timeout                              */
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC1_SHFT 58
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC1_MASK 0x0400000000000000
-
-/*   SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC3                        */
-/*   Description:  Fifo13 vc3 tail timeout                              */
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC3_SHFT 59
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC3_MASK 0x0800000000000000
-
-/*   SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC0                            */
-/*   Description:  NI vc0 tail timeout                                  */
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC0_SHFT 60
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC0_MASK 0x1000000000000000
-
-/*   SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC1                            */
-/*   Description:  NI vc1 tail timeout                                  */
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC1_SHFT 61
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC1_MASK 0x2000000000000000
-
-/*   SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC2                            */
-/*   Description:  NI vc2 tail timeout                                  */
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC2_SHFT 62
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC2_MASK 0x4000000000000000
-
-/*   SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC3                            */
-/*   Description:  NI vc3 tail timeout                                  */
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC3_SHFT 63
-#define SH_NI0_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC3_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_ERROR_MASK_2"                    */
-/*                         ni0  Error Mask Bits                         */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_MASK_2                      0x0000000150040550
-#define SH_NI0_ERROR_MASK_2_MASK                 0x7fffffff003fffff
-#define SH_NI0_ERROR_MASK_2_INIT                 0x7fffffff003fffff
-
-/*   SH_NI0_ERROR_MASK_2_ILLEGAL_VCNI                                   */
-/*   Description:  Illegal VC NI                                        */
-#define SH_NI0_ERROR_MASK_2_ILLEGAL_VCNI_SHFT    0
-#define SH_NI0_ERROR_MASK_2_ILLEGAL_VCNI_MASK    0x0000000000000001
-
-/*   SH_NI0_ERROR_MASK_2_ILLEGAL_VCPI                                   */
-/*   Description:  Illegal VC PI                                        */
-#define SH_NI0_ERROR_MASK_2_ILLEGAL_VCPI_SHFT    1
-#define SH_NI0_ERROR_MASK_2_ILLEGAL_VCPI_MASK    0x0000000000000002
-
-/*   SH_NI0_ERROR_MASK_2_ILLEGAL_VCMD                                   */
-/*   Description:  Illegal VC MD                                        */
-#define SH_NI0_ERROR_MASK_2_ILLEGAL_VCMD_SHFT    2
-#define SH_NI0_ERROR_MASK_2_ILLEGAL_VCMD_MASK    0x0000000000000004
-
-/*   SH_NI0_ERROR_MASK_2_ILLEGAL_VCIILB                                 */
-/*   Description:  Illegal VC IILB                                      */
-#define SH_NI0_ERROR_MASK_2_ILLEGAL_VCIILB_SHFT  3
-#define SH_NI0_ERROR_MASK_2_ILLEGAL_VCIILB_MASK  0x0000000000000008
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_POP                       */
-/*   Description:  Fifo 02 vc0 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_POP                       */
-/*   Description:  Fifo 02 vc2 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_POP                       */
-/*   Description:  Fifo 13 vc1 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_POP                       */
-/*   Description:  Fifo 13 vc3 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_PUSH                      */
-/*   Description:  Fifo 02 vc0 push underflow                           */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_PUSH                      */
-/*   Description:  Fifo 02 vc2 push underflow                           */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_PUSH                      */
-/*   Description:  Fifo 13 vc1 push underflow                           */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_PUSH                      */
-/*   Description:  Fifo 13 vc3 push underflow                           */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_CREDIT                    */
-/*   Description:  Fifo 02 vc0 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_CREDIT                    */
-/*   Description:  Fifo 02 vc2 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC0_CREDIT                    */
-/*   Description:  Fifo 13 vc0 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC2_CREDIT                    */
-/*   Description:  Fifo 13 vc2 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW0_VC0_CREDIT                          */
-/*   Description:  VC0 credit underflow 0                               */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW1_VC0_CREDIT                          */
-/*   Description:  VC0 credit underflow 1                               */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW2_VC0_CREDIT                          */
-/*   Description:  VC0 credit underflow 2                               */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW0_VC2_CREDIT                          */
-/*   Description:  VC2 credit underflow 0                               */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW1_VC2_CREDIT                          */
-/*   Description:  VC2 credit underflow 1                               */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW2_VC2_CREDIT                          */
-/*   Description:  VC2 credit underflow 2                               */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_POP                      */
-/*   Description:  PI Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_POP                      */
-/*   Description:  PI Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_POP                    */
-/*   Description:  IILB Fifo vc0 pop underflow                          */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_POP                    */
-/*   Description:  IILB Fifo vc2 pop underflow                          */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_POP                      */
-/*   Description:  MD Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_POP                      */
-/*   Description:  MD Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_POP                      */
-/*   Description:  NI Fifo vc0 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_POP                      */
-/*   Description:  NI Fifo vc2 pop underflow                            */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_PUSH                     */
-/*   Description:  PI Fifo vc0 push underflow                           */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_PUSH                     */
-/*   Description:  PI Fifo vc2 push underflow                           */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_PUSH                   */
-/*   Description:  IILB Fifo vc0 push underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_PUSH                   */
-/*   Description:  IILB Fifo vc2 push underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_PUSH                     */
-/*   Description:  MD Fifo vc0 push underflow                           */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_PUSH                     */
-/*   Description:  MD Fifo vc2 push underflow                           */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_CREDIT                   */
-/*   Description:  PI Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_CREDIT                   */
-/*   Description:  PI Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT                 */
-/*   Description:  IILB Fifo vc0 credit underflow                       */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT                 */
-/*   Description:  IILB Fifo vc2 credit underflow                       */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_CREDIT                   */
-/*   Description:  MD Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_CREDIT                   */
-/*   Description:  MD Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_CREDIT                   */
-/*   Description:  NI Fifo vc0 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC1_CREDIT                   */
-/*   Description:  NI Fifo vc1 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_CREDIT                   */
-/*   Description:  NI Fifo vc2 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC3_CREDIT                   */
-/*   Description:  NI Fifo vc3 credit underflow                         */
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI0_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC0                               */
-/*   Description:  llp deadlock vc0                                     */
-#define SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC0_SHFT 56
-#define SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC0_MASK 0x0100000000000000
-
-/*   SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC1                               */
-/*   Description:  llp deadlock vc1                                     */
-#define SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC1_SHFT 57
-#define SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC1_MASK 0x0200000000000000
-
-/*   SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC2                               */
-/*   Description:  llp deadlock vc2                                     */
-#define SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC2_SHFT 58
-#define SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC2_MASK 0x0400000000000000
-
-/*   SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC3                               */
-/*   Description:  llp deadlock vc3                                     */
-#define SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC3_SHFT 59
-#define SH_NI0_ERROR_MASK_2_LLP_DEADLOCK_VC3_MASK 0x0800000000000000
-
-/*   SH_NI0_ERROR_MASK_2_CHIPLET_NOMATCH                                */
-/*   Description:  chiplet nomatch                                      */
-#define SH_NI0_ERROR_MASK_2_CHIPLET_NOMATCH_SHFT 60
-#define SH_NI0_ERROR_MASK_2_CHIPLET_NOMATCH_MASK 0x1000000000000000
-
-/*   SH_NI0_ERROR_MASK_2_LUT_READ_ERROR                                 */
-/*   Description:  LUT Read Error                                       */
-#define SH_NI0_ERROR_MASK_2_LUT_READ_ERROR_SHFT  61
-#define SH_NI0_ERROR_MASK_2_LUT_READ_ERROR_MASK  0x2000000000000000
-
-/*   SH_NI0_ERROR_MASK_2_RETRY_TIMEOUT_ERROR                            */
-/*   Description:  Retry Timeout Error                                  */
-#define SH_NI0_ERROR_MASK_2_RETRY_TIMEOUT_ERROR_SHFT 62
-#define SH_NI0_ERROR_MASK_2_RETRY_TIMEOUT_ERROR_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_FIRST_ERROR_1"                    */
-/*                        ni0  First Error Bits                         */
-/* ==================================================================== */
-
-#define SH_NI0_FIRST_ERROR_1                     0x0000000150040560
-#define SH_NI0_FIRST_ERROR_1_MASK                0xffffffffffffffff
-#define SH_NI0_FIRST_ERROR_1_INIT                0xffffffffffffffff
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT0                        */
-/*   Description:  Fifo 02 debit0 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT0_SHFT 0
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT2                        */
-/*   Description:  Fifo 02 debit2 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT2_SHFT 1
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT0                        */
-/*   Description:  Fifo 13 debit0 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT0_SHFT 2
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT2                        */
-/*   Description:  Fifo 13 debit2 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT2_SHFT 3
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_POP                       */
-/*   Description:  Fifo 02 vc0 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_POP                       */
-/*   Description:  Fifo 02 vc2 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_POP                       */
-/*   Description:  Fifo 13 vc1 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_POP                       */
-/*   Description:  Fifo 13 vc3 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_PUSH                      */
-/*   Description:  Fifo 02 vc0 push overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_PUSH                      */
-/*   Description:  Fifo 02 vc2 push overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_PUSH                      */
-/*   Description:  Fifo 13 vc1 push overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_PUSH                      */
-/*   Description:  Fifo 13 vc3 push overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_CREDIT                    */
-/*   Description:  Fifo 02 vc0 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_CREDIT                    */
-/*   Description:  Fifo 02 vc2 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC0_CREDIT                    */
-/*   Description:  Fifo 13 vc0 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC2_CREDIT                    */
-/*   Description:  Fifo 13 vc2 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW0_VC0_CREDIT                          */
-/*   Description:  VC0 credit overflow 0                                */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW1_VC0_CREDIT                          */
-/*   Description:  VC0 credit overflow 1                                */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW2_VC0_CREDIT                          */
-/*   Description:  VC0 credit overflow 2                                */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW0_VC2_CREDIT                          */
-/*   Description:  VC2 credit overflow 0                                */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW1_VC2_CREDIT                          */
-/*   Description:  VC2 credit overflow 1                                */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW2_VC2_CREDIT                          */
-/*   Description:  VC2 credit overflow 2                                */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT0                       */
-/*   Description:  PI Fifo debit0 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT0_SHFT 22
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT0_MASK 0x0000000000400000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT2                       */
-/*   Description:  PI Fifo debit2 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT2_SHFT 23
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT2_MASK 0x0000000000800000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT0                     */
-/*   Description:  IILB Fifo debit0 overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT0_SHFT 24
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT0_MASK 0x0000000001000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT2                     */
-/*   Description:  IILB Fifo debit2 overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT2_SHFT 25
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT2_MASK 0x0000000002000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT0                       */
-/*   Description:  MD Fifo debit0 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT0_SHFT 26
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT0_MASK 0x0000000004000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT2                       */
-/*   Description:  MD Fifo debit2 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT2_SHFT 27
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT2_MASK 0x0000000008000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT0                       */
-/*   Description:  NI Fifo debit0 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT0_SHFT 28
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT0_MASK 0x0000000010000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT1                       */
-/*   Description:  NI Fifo debit1 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT1_SHFT 29
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT1_MASK 0x0000000020000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT2                       */
-/*   Description:  NI Fifo debit2 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT2_SHFT 30
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT2_MASK 0x0000000040000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT3                       */
-/*   Description:  NI Fifo debit3 overflow                              */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT3_SHFT 31
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT3_MASK 0x0000000080000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_POP                      */
-/*   Description:  PI Fifo vc0 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_POP                      */
-/*   Description:  PI Fifo vc2 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_POP                    */
-/*   Description:  IILB Fifo vc0 pop overflow                           */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_POP                    */
-/*   Description:  IILB Fifo vc2 pop overflow                           */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_POP                      */
-/*   Description:  MD Fifo vc0 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_POP                      */
-/*   Description:  MD Fifo vc2 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_POP                      */
-/*   Description:  NI Fifo vc0 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_POP                      */
-/*   Description:  NI Fifo vc2 pop overflow                             */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_PUSH                     */
-/*   Description:  PI Fifo vc0 push overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_PUSH                     */
-/*   Description:  PI Fifo vc2 push overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_PUSH                   */
-/*   Description:  IILB Fifo vc0 push overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_PUSH                   */
-/*   Description:  IILB Fifo vc2 push overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_PUSH                     */
-/*   Description:  MD Fifo vc0 push overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_PUSH                     */
-/*   Description:  MD Fifo vc2 push overflow                            */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_CREDIT                   */
-/*   Description:  PI Fifo vc0 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_CREDIT                   */
-/*   Description:  PI Fifo vc2 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_CREDIT                 */
-/*   Description:  IILB Fifo vc0 credit overflow                        */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_CREDIT                 */
-/*   Description:  IILB Fifo vc2 credit overflow                        */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_CREDIT                   */
-/*   Description:  MD Fifo vc0 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_CREDIT                   */
-/*   Description:  MD Fifo vc2 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_CREDIT                   */
-/*   Description:  NI Fifo vc0 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC1_CREDIT                   */
-/*   Description:  NI Fifo vc1 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_CREDIT                   */
-/*   Description:  NI Fifo vc2 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC3_CREDIT                   */
-/*   Description:  NI Fifo vc3 credit overflow                          */
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI0_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC0                       */
-/*   Description:  Fifo02 vc0 tail timeout                              */
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC0_SHFT 56
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC0_MASK 0x0100000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC2                       */
-/*   Description:  Fifo02 vc2 tail timeout                              */
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC2_SHFT 57
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC2_MASK 0x0200000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC1                       */
-/*   Description:  Fifo13 vc1 tail timeout                              */
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC1_SHFT 58
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC1_MASK 0x0400000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC3                       */
-/*   Description:  Fifo13 vc3 tail timeout                              */
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC3_SHFT 59
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC3_MASK 0x0800000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC0                           */
-/*   Description:  NI vc0 tail timeout                                  */
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC0_SHFT 60
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC0_MASK 0x1000000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC1                           */
-/*   Description:  NI vc1 tail timeout                                  */
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC1_SHFT 61
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC1_MASK 0x2000000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC2                           */
-/*   Description:  NI vc2 tail timeout                                  */
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC2_SHFT 62
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC2_MASK 0x4000000000000000
-
-/*   SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC3                           */
-/*   Description:  NI vc3 tail timeout                                  */
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC3_SHFT 63
-#define SH_NI0_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC3_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_FIRST_ERROR_2"                    */
-/*                         ni0 First Error Bits                         */
-/* ==================================================================== */
-
-#define SH_NI0_FIRST_ERROR_2                     0x0000000150040570
-#define SH_NI0_FIRST_ERROR_2_MASK                0x7fffffff003fffff
-#define SH_NI0_FIRST_ERROR_2_INIT                0x7fffffff003fffff
-
-/*   SH_NI0_FIRST_ERROR_2_ILLEGAL_VCNI                                  */
-/*   Description:  Illegal VC NI                                        */
-#define SH_NI0_FIRST_ERROR_2_ILLEGAL_VCNI_SHFT   0
-#define SH_NI0_FIRST_ERROR_2_ILLEGAL_VCNI_MASK   0x0000000000000001
-
-/*   SH_NI0_FIRST_ERROR_2_ILLEGAL_VCPI                                  */
-/*   Description:  Illegal VC PI                                        */
-#define SH_NI0_FIRST_ERROR_2_ILLEGAL_VCPI_SHFT   1
-#define SH_NI0_FIRST_ERROR_2_ILLEGAL_VCPI_MASK   0x0000000000000002
-
-/*   SH_NI0_FIRST_ERROR_2_ILLEGAL_VCMD                                  */
-/*   Description:  Illegal VC MD                                        */
-#define SH_NI0_FIRST_ERROR_2_ILLEGAL_VCMD_SHFT   2
-#define SH_NI0_FIRST_ERROR_2_ILLEGAL_VCMD_MASK   0x0000000000000004
-
-/*   SH_NI0_FIRST_ERROR_2_ILLEGAL_VCIILB                                */
-/*   Description:  Illegal VC IILB                                      */
-#define SH_NI0_FIRST_ERROR_2_ILLEGAL_VCIILB_SHFT 3
-#define SH_NI0_FIRST_ERROR_2_ILLEGAL_VCIILB_MASK 0x0000000000000008
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_POP                      */
-/*   Description:  Fifo 02 vc0 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_POP                      */
-/*   Description:  Fifo 02 vc2 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_POP                      */
-/*   Description:  Fifo 13 vc1 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_POP                      */
-/*   Description:  Fifo 13 vc3 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_PUSH                     */
-/*   Description:  Fifo 02 vc0 push underflow                           */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_PUSH                     */
-/*   Description:  Fifo 02 vc2 push underflow                           */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_PUSH                     */
-/*   Description:  Fifo 13 vc1 push underflow                           */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_PUSH                     */
-/*   Description:  Fifo 13 vc3 push underflow                           */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_CREDIT                   */
-/*   Description:  Fifo 02 vc0 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_CREDIT                   */
-/*   Description:  Fifo 02 vc2 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC0_CREDIT                   */
-/*   Description:  Fifo 13 vc0 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC2_CREDIT                   */
-/*   Description:  Fifo 13 vc2 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW0_VC0_CREDIT                         */
-/*   Description:  VC0 credit underflow 0                               */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW1_VC0_CREDIT                         */
-/*   Description:  VC0 credit underflow 1                               */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW2_VC0_CREDIT                         */
-/*   Description:  VC0 credit underflow 2                               */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW0_VC2_CREDIT                         */
-/*   Description:  VC2 credit underflow 0                               */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW1_VC2_CREDIT                         */
-/*   Description:  VC2 credit underflow 1                               */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW2_VC2_CREDIT                         */
-/*   Description:  VC2 credit underflow 2                               */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_POP                     */
-/*   Description:  PI Fifo vc0 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_POP                     */
-/*   Description:  PI Fifo vc2 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_POP                   */
-/*   Description:  IILB Fifo vc0 pop underflow                          */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_POP                   */
-/*   Description:  IILB Fifo vc2 pop underflow                          */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_POP                     */
-/*   Description:  MD Fifo vc0 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_POP                     */
-/*   Description:  MD Fifo vc2 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_POP                     */
-/*   Description:  NI Fifo vc0 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_POP                     */
-/*   Description:  NI Fifo vc2 pop underflow                            */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_PUSH                    */
-/*   Description:  PI Fifo vc0 push underflow                           */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_PUSH                    */
-/*   Description:  PI Fifo vc2 push underflow                           */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_PUSH                  */
-/*   Description:  IILB Fifo vc0 push underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_PUSH                  */
-/*   Description:  IILB Fifo vc2 push underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_PUSH                    */
-/*   Description:  MD Fifo vc0 push underflow                           */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_PUSH                    */
-/*   Description:  MD Fifo vc2 push underflow                           */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_CREDIT                  */
-/*   Description:  PI Fifo vc0 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_CREDIT                  */
-/*   Description:  PI Fifo vc2 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT                */
-/*   Description:  IILB Fifo vc0 credit underflow                       */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT                */
-/*   Description:  IILB Fifo vc2 credit underflow                       */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_CREDIT                  */
-/*   Description:  MD Fifo vc0 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_CREDIT                  */
-/*   Description:  MD Fifo vc2 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_CREDIT                  */
-/*   Description:  NI Fifo vc0 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC1_CREDIT                  */
-/*   Description:  NI Fifo vc1 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_CREDIT                  */
-/*   Description:  NI Fifo vc2 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC3_CREDIT                  */
-/*   Description:  NI Fifo vc3 credit underflow                         */
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI0_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC0                              */
-/*   Description:  llp deadlock vc0                                     */
-#define SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC0_SHFT 56
-#define SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC0_MASK 0x0100000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC1                              */
-/*   Description:  llp deadlock vc1                                     */
-#define SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC1_SHFT 57
-#define SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC1_MASK 0x0200000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC2                              */
-/*   Description:  llp deadlock vc2                                     */
-#define SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC2_SHFT 58
-#define SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC2_MASK 0x0400000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC3                              */
-/*   Description:  llp deadlock vc3                                     */
-#define SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC3_SHFT 59
-#define SH_NI0_FIRST_ERROR_2_LLP_DEADLOCK_VC3_MASK 0x0800000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_CHIPLET_NOMATCH                               */
-/*   Description:  chiplet nomatch                                      */
-#define SH_NI0_FIRST_ERROR_2_CHIPLET_NOMATCH_SHFT 60
-#define SH_NI0_FIRST_ERROR_2_CHIPLET_NOMATCH_MASK 0x1000000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_LUT_READ_ERROR                                */
-/*   Description:  LUT Read Error                                       */
-#define SH_NI0_FIRST_ERROR_2_LUT_READ_ERROR_SHFT 61
-#define SH_NI0_FIRST_ERROR_2_LUT_READ_ERROR_MASK 0x2000000000000000
-
-/*   SH_NI0_FIRST_ERROR_2_RETRY_TIMEOUT_ERROR                           */
-/*   Description:  Retry Timeout Error                                  */
-#define SH_NI0_FIRST_ERROR_2_RETRY_TIMEOUT_ERROR_SHFT 62
-#define SH_NI0_FIRST_ERROR_2_RETRY_TIMEOUT_ERROR_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_ERROR_DETAIL_1"                   */
-/*                ni0 Chiplet no match header bits 63:0                 */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_DETAIL_1                    0x0000000150040580
-#define SH_NI0_ERROR_DETAIL_1_MASK               0xffffffffffffffff
-#define SH_NI0_ERROR_DETAIL_1_INIT               0x0000000000000000
-
-/*   SH_NI0_ERROR_DETAIL_1_HEADER                                       */
-/*   Description:  Header bits 63:0                                     */
-#define SH_NI0_ERROR_DETAIL_1_HEADER_SHFT        0
-#define SH_NI0_ERROR_DETAIL_1_HEADER_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_ERROR_DETAIL_2"                   */
-/*               ni0 Chiplet no match header bits 127:64                */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_DETAIL_2                    0x0000000150040590
-#define SH_NI0_ERROR_DETAIL_2_MASK               0xffffffffffffffff
-#define SH_NI0_ERROR_DETAIL_2_INIT               0x0000000000000000
-
-/*   SH_NI0_ERROR_DETAIL_2_HEADER                                       */
-/*   Description:  Header bits 127:64                                   */
-#define SH_NI0_ERROR_DETAIL_2_HEADER_SHFT        0
-#define SH_NI0_ERROR_DETAIL_2_HEADER_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_ERROR_SUMMARY_1"                   */
-/*                       ni1  Error Summary Bits                        */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_SUMMARY_1                   0x0000000150040600
-#define SH_NI1_ERROR_SUMMARY_1_MASK              0xffffffffffffffff
-#define SH_NI1_ERROR_SUMMARY_1_INIT              0xffffffffffffffff
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT0                      */
-/*   Description:  Fifo 02 debit0 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT0_SHFT 0
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT2                      */
-/*   Description:  Fifo 02 debit2 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT2_SHFT 1
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT0                      */
-/*   Description:  Fifo 13 debit0 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT0_SHFT 2
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT2                      */
-/*   Description:  Fifo 13 debit2 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT2_SHFT 3
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_POP                     */
-/*   Description:  Fifo 02 vc0 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_POP                     */
-/*   Description:  Fifo 02 vc2 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_POP                     */
-/*   Description:  Fifo 13 vc1 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_POP                     */
-/*   Description:  Fifo 13 vc3 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_PUSH                    */
-/*   Description:  Fifo 02 vc0 push overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_PUSH                    */
-/*   Description:  Fifo 02 vc2 push overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_PUSH                    */
-/*   Description:  Fifo 13 vc1 push overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_PUSH                    */
-/*   Description:  Fifo 13 vc3 push overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_CREDIT                  */
-/*   Description:  Fifo 02 vc0 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_CREDIT                  */
-/*   Description:  Fifo 02 vc2 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC0_CREDIT                  */
-/*   Description:  Fifo 13 vc0 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC2_CREDIT                  */
-/*   Description:  Fifo 13 vc2 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW0_VC0_CREDIT                        */
-/*   Description:  VC0 credit overflow 0                                */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW1_VC0_CREDIT                        */
-/*   Description:  VC0 credit overflow 1                                */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW2_VC0_CREDIT                        */
-/*   Description:  VC0 credit overflow 2                                */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW0_VC2_CREDIT                        */
-/*   Description:  VC2 credit overflow 0                                */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW1_VC2_CREDIT                        */
-/*   Description:  VC2 credit overflow 1                                */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW2_VC2_CREDIT                        */
-/*   Description:  VC2 credit overflow 2                                */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT0                     */
-/*   Description:  PI Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT0_SHFT 22
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT0_MASK 0x0000000000400000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT2                     */
-/*   Description:  PI Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT2_SHFT 23
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_DEBIT2_MASK 0x0000000000800000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT0                   */
-/*   Description:  IILB Fifo debit0 overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT0_SHFT 24
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT0_MASK 0x0000000001000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT2                   */
-/*   Description:  IILB Fifo debit2 overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT2_SHFT 25
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_DEBIT2_MASK 0x0000000002000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT0                     */
-/*   Description:  MD Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT0_SHFT 26
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT0_MASK 0x0000000004000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT2                     */
-/*   Description:  MD Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT2_SHFT 27
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_DEBIT2_MASK 0x0000000008000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT0                     */
-/*   Description:  NI Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT0_SHFT 28
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT0_MASK 0x0000000010000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT1                     */
-/*   Description:  NI Fifo debit1 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT1_SHFT 29
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT1_MASK 0x0000000020000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT2                     */
-/*   Description:  NI Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT2_SHFT 30
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT2_MASK 0x0000000040000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT3                     */
-/*   Description:  NI Fifo debit3 overflow                              */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT3_SHFT 31
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_DEBIT3_MASK 0x0000000080000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_POP                    */
-/*   Description:  PI Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_POP                    */
-/*   Description:  PI Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_POP                  */
-/*   Description:  IILB Fifo vc0 pop overflow                           */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_POP                  */
-/*   Description:  IILB Fifo vc2 pop overflow                           */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_POP                    */
-/*   Description:  MD Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_POP                    */
-/*   Description:  MD Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_POP                    */
-/*   Description:  NI Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_POP                    */
-/*   Description:  NI Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_PUSH                   */
-/*   Description:  PI Fifo vc0 push overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_PUSH                   */
-/*   Description:  PI Fifo vc2 push overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_PUSH                 */
-/*   Description:  IILB Fifo vc0 push overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_PUSH                 */
-/*   Description:  IILB Fifo vc2 push overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_PUSH                   */
-/*   Description:  MD Fifo vc0 push overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_PUSH                   */
-/*   Description:  MD Fifo vc2 push overflow                            */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_CREDIT                 */
-/*   Description:  PI Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_CREDIT                 */
-/*   Description:  PI Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_CREDIT               */
-/*   Description:  IILB Fifo vc0 credit overflow                        */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_CREDIT               */
-/*   Description:  IILB Fifo vc2 credit overflow                        */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_CREDIT                 */
-/*   Description:  MD Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_CREDIT                 */
-/*   Description:  MD Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_CREDIT                 */
-/*   Description:  NI Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC1_CREDIT                 */
-/*   Description:  NI Fifo vc1 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_CREDIT                 */
-/*   Description:  NI Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC3_CREDIT                 */
-/*   Description:  NI Fifo vc3 credit overflow                          */
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI1_ERROR_SUMMARY_1_OVERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC0                     */
-/*   Description:  Fifo02 vc0 tail timeout                              */
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC0_SHFT 56
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC0_MASK 0x0100000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC2                     */
-/*   Description:  Fifo02 vc2 tail timeout                              */
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC2_SHFT 57
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO02_VC2_MASK 0x0200000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC1                     */
-/*   Description:  Fifo13 vc1 tail timeout                              */
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC1_SHFT 58
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC1_MASK 0x0400000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC3                     */
-/*   Description:  Fifo13 vc3 tail timeout                              */
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC3_SHFT 59
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_FIFO13_VC3_MASK 0x0800000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC0                         */
-/*   Description:  NI vc0 tail timeout                                  */
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC0_SHFT 60
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC0_MASK 0x1000000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC1                         */
-/*   Description:  NI vc1 tail timeout                                  */
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC1_SHFT 61
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC1_MASK 0x2000000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC2                         */
-/*   Description:  NI vc2 tail timeout                                  */
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC2_SHFT 62
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC2_MASK 0x4000000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC3                         */
-/*   Description:  NI vc3 tail timeout                                  */
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC3_SHFT 63
-#define SH_NI1_ERROR_SUMMARY_1_TAIL_TIMEOUT_NI_VC3_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_NI1_ERROR_SUMMARY_1_ALIAS"                */
-/*                     ni1 Error Summary Bits Alias                     */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_SUMMARY_1_ALIAS             0x0000000150040608
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_ERROR_SUMMARY_2"                   */
-/*                       ni1  Error Summary Bits                        */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_SUMMARY_2                   0x0000000150040610
-#define SH_NI1_ERROR_SUMMARY_2_MASK              0x7fffffff003fffff
-#define SH_NI1_ERROR_SUMMARY_2_INIT              0x7fffffff003fffff
-
-/*   SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCNI                                */
-/*   Description:  Illegal VC NI                                        */
-#define SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCNI_SHFT 0
-#define SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCNI_MASK 0x0000000000000001
-
-/*   SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCPI                                */
-/*   Description:  Illegal VC PI                                        */
-#define SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCPI_SHFT 1
-#define SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCPI_MASK 0x0000000000000002
-
-/*   SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCMD                                */
-/*   Description:  Illegal VC MD                                        */
-#define SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCMD_SHFT 2
-#define SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCMD_MASK 0x0000000000000004
-
-/*   SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCIILB                              */
-/*   Description:  Illegal VC IILB                                      */
-#define SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCIILB_SHFT 3
-#define SH_NI1_ERROR_SUMMARY_2_ILLEGAL_VCIILB_MASK 0x0000000000000008
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_POP                    */
-/*   Description:  Fifo 02 vc0 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_POP                    */
-/*   Description:  Fifo 02 vc2 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_POP                    */
-/*   Description:  Fifo 13 vc1 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_POP                    */
-/*   Description:  Fifo 13 vc3 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_PUSH                   */
-/*   Description:  Fifo 02 vc0 push underflow                           */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_PUSH                   */
-/*   Description:  Fifo 02 vc2 push underflow                           */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_PUSH                   */
-/*   Description:  Fifo 13 vc1 push underflow                           */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_PUSH                   */
-/*   Description:  Fifo 13 vc3 push underflow                           */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_CREDIT                 */
-/*   Description:  Fifo 02 vc0 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_CREDIT                 */
-/*   Description:  Fifo 02 vc2 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC0_CREDIT                 */
-/*   Description:  Fifo 13 vc0 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC2_CREDIT                 */
-/*   Description:  Fifo 13 vc2 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW0_VC0_CREDIT                       */
-/*   Description:  VC0 credit underflow 0                               */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW1_VC0_CREDIT                       */
-/*   Description:  VC0 credit underflow 1                               */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW2_VC0_CREDIT                       */
-/*   Description:  VC0 credit underflow 2                               */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW0_VC2_CREDIT                       */
-/*   Description:  VC2 credit underflow 0                               */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW1_VC2_CREDIT                       */
-/*   Description:  VC2 credit underflow 1                               */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW2_VC2_CREDIT                       */
-/*   Description:  VC2 credit underflow 2                               */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_POP                   */
-/*   Description:  PI Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_POP                   */
-/*   Description:  PI Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_POP                 */
-/*   Description:  IILB Fifo vc0 pop underflow                          */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_POP                 */
-/*   Description:  IILB Fifo vc2 pop underflow                          */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_POP                   */
-/*   Description:  MD Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_POP                   */
-/*   Description:  MD Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_POP                   */
-/*   Description:  NI Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_POP                   */
-/*   Description:  NI Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_PUSH                  */
-/*   Description:  PI Fifo vc0 push underflow                           */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_PUSH                  */
-/*   Description:  PI Fifo vc2 push underflow                           */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_PUSH                */
-/*   Description:  IILB Fifo vc0 push underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_PUSH                */
-/*   Description:  IILB Fifo vc2 push underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_PUSH                  */
-/*   Description:  MD Fifo vc0 push underflow                           */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_PUSH                  */
-/*   Description:  MD Fifo vc2 push underflow                           */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_CREDIT                */
-/*   Description:  PI Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_CREDIT                */
-/*   Description:  PI Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT              */
-/*   Description:  IILB Fifo vc0 credit underflow                       */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT              */
-/*   Description:  IILB Fifo vc2 credit underflow                       */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_CREDIT                */
-/*   Description:  MD Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_CREDIT                */
-/*   Description:  MD Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_CREDIT                */
-/*   Description:  NI Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC1_CREDIT                */
-/*   Description:  NI Fifo vc1 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_CREDIT                */
-/*   Description:  NI Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC3_CREDIT                */
-/*   Description:  NI Fifo vc3 credit underflow                         */
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI1_ERROR_SUMMARY_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC0                            */
-/*   Description:  llp deadlock vc0                                     */
-#define SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC0_SHFT 56
-#define SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC0_MASK 0x0100000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC1                            */
-/*   Description:  llp deadlock vc1                                     */
-#define SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC1_SHFT 57
-#define SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC1_MASK 0x0200000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC2                            */
-/*   Description:  llp deadlock vc2                                     */
-#define SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC2_SHFT 58
-#define SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC2_MASK 0x0400000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC3                            */
-/*   Description:  llp deadlock vc3                                     */
-#define SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC3_SHFT 59
-#define SH_NI1_ERROR_SUMMARY_2_LLP_DEADLOCK_VC3_MASK 0x0800000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_CHIPLET_NOMATCH                             */
-/*   Description:  chiplet nomatch                                      */
-#define SH_NI1_ERROR_SUMMARY_2_CHIPLET_NOMATCH_SHFT 60
-#define SH_NI1_ERROR_SUMMARY_2_CHIPLET_NOMATCH_MASK 0x1000000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_LUT_READ_ERROR                              */
-/*   Description:  LUT Read Error                                       */
-#define SH_NI1_ERROR_SUMMARY_2_LUT_READ_ERROR_SHFT 61
-#define SH_NI1_ERROR_SUMMARY_2_LUT_READ_ERROR_MASK 0x2000000000000000
-
-/*   SH_NI1_ERROR_SUMMARY_2_RETRY_TIMEOUT_ERROR                         */
-/*   Description:  Retry Timeout Error                                  */
-#define SH_NI1_ERROR_SUMMARY_2_RETRY_TIMEOUT_ERROR_SHFT 62
-#define SH_NI1_ERROR_SUMMARY_2_RETRY_TIMEOUT_ERROR_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_NI1_ERROR_SUMMARY_2_ALIAS"                */
-/*                     ni1 Error Summary Bits Alias                     */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_SUMMARY_2_ALIAS             0x0000000150040618
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_ERROR_OVERFLOW_1"                  */
-/*                       ni1  Error Overflow Bits                       */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_OVERFLOW_1                  0x0000000150040620
-#define SH_NI1_ERROR_OVERFLOW_1_MASK             0xffffffffffffffff
-#define SH_NI1_ERROR_OVERFLOW_1_INIT             0xffffffffffffffff
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT0                     */
-/*   Description:  Fifo 02 debit0 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT0_SHFT 0
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT2                     */
-/*   Description:  Fifo 02 debit2 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT2_SHFT 1
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT0                     */
-/*   Description:  Fifo 13 debit0 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT0_SHFT 2
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT2                     */
-/*   Description:  Fifo 13 debit2 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT2_SHFT 3
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_POP                    */
-/*   Description:  Fifo 02 vc0 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_POP                    */
-/*   Description:  Fifo 02 vc2 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_POP                    */
-/*   Description:  Fifo 13 vc1 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_POP                    */
-/*   Description:  Fifo 13 vc3 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_PUSH                   */
-/*   Description:  Fifo 02 vc0 push overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_PUSH                   */
-/*   Description:  Fifo 02 vc2 push overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_PUSH                   */
-/*   Description:  Fifo 13 vc1 push overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_PUSH                   */
-/*   Description:  Fifo 13 vc3 push overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_CREDIT                 */
-/*   Description:  Fifo 02 vc0 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_CREDIT                 */
-/*   Description:  Fifo 02 vc2 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC0_CREDIT                 */
-/*   Description:  Fifo 13 vc0 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC2_CREDIT                 */
-/*   Description:  Fifo 13 vc2 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW0_VC0_CREDIT                       */
-/*   Description:  VC0 credit overflow 0                                */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW1_VC0_CREDIT                       */
-/*   Description:  VC0 credit overflow 1                                */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW2_VC0_CREDIT                       */
-/*   Description:  VC0 credit overflow 2                                */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW0_VC2_CREDIT                       */
-/*   Description:  VC2 credit overflow 0                                */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW1_VC2_CREDIT                       */
-/*   Description:  VC2 credit overflow 1                                */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW2_VC2_CREDIT                       */
-/*   Description:  VC2 credit overflow 2                                */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT0                    */
-/*   Description:  PI Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT0_SHFT 22
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT0_MASK 0x0000000000400000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT2                    */
-/*   Description:  PI Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT2_SHFT 23
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_DEBIT2_MASK 0x0000000000800000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT0                  */
-/*   Description:  IILB Fifo debit0 overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT0_SHFT 24
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT0_MASK 0x0000000001000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT2                  */
-/*   Description:  IILB Fifo debit2 overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT2_SHFT 25
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_DEBIT2_MASK 0x0000000002000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT0                    */
-/*   Description:  MD Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT0_SHFT 26
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT0_MASK 0x0000000004000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT2                    */
-/*   Description:  MD Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT2_SHFT 27
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_DEBIT2_MASK 0x0000000008000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT0                    */
-/*   Description:  NI Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT0_SHFT 28
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT0_MASK 0x0000000010000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT1                    */
-/*   Description:  NI Fifo debit1 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT1_SHFT 29
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT1_MASK 0x0000000020000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT2                    */
-/*   Description:  NI Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT2_SHFT 30
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT2_MASK 0x0000000040000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT3                    */
-/*   Description:  NI Fifo debit3 overflow                              */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT3_SHFT 31
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_DEBIT3_MASK 0x0000000080000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_POP                   */
-/*   Description:  PI Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_POP                   */
-/*   Description:  PI Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_POP                 */
-/*   Description:  IILB Fifo vc0 pop overflow                           */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_POP                 */
-/*   Description:  IILB Fifo vc2 pop overflow                           */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_POP                   */
-/*   Description:  MD Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_POP                   */
-/*   Description:  MD Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_POP                   */
-/*   Description:  NI Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_POP                   */
-/*   Description:  NI Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_PUSH                  */
-/*   Description:  PI Fifo vc0 push overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_PUSH                  */
-/*   Description:  PI Fifo vc2 push overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_PUSH                */
-/*   Description:  IILB Fifo vc0 push overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_PUSH                */
-/*   Description:  IILB Fifo vc2 push overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_PUSH                  */
-/*   Description:  MD Fifo vc0 push overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_PUSH                  */
-/*   Description:  MD Fifo vc2 push overflow                            */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_CREDIT                */
-/*   Description:  PI Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_CREDIT                */
-/*   Description:  PI Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_CREDIT              */
-/*   Description:  IILB Fifo vc0 credit overflow                        */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_CREDIT              */
-/*   Description:  IILB Fifo vc2 credit overflow                        */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_CREDIT                */
-/*   Description:  MD Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_CREDIT                */
-/*   Description:  MD Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_CREDIT                */
-/*   Description:  NI Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC1_CREDIT                */
-/*   Description:  NI Fifo vc1 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_CREDIT                */
-/*   Description:  NI Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC3_CREDIT                */
-/*   Description:  NI Fifo vc3 credit overflow                          */
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI1_ERROR_OVERFLOW_1_OVERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC0                    */
-/*   Description:  Fifo02 vc0 tail timeout                              */
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC0_SHFT 56
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC0_MASK 0x0100000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC2                    */
-/*   Description:  Fifo02 vc2 tail timeout                              */
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC2_SHFT 57
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO02_VC2_MASK 0x0200000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC1                    */
-/*   Description:  Fifo13 vc1 tail timeout                              */
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC1_SHFT 58
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC1_MASK 0x0400000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC3                    */
-/*   Description:  Fifo13 vc3 tail timeout                              */
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC3_SHFT 59
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_FIFO13_VC3_MASK 0x0800000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC0                        */
-/*   Description:  NI vc0 tail timeout                                  */
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC0_SHFT 60
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC0_MASK 0x1000000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC1                        */
-/*   Description:  NI vc1 tail timeout                                  */
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC1_SHFT 61
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC1_MASK 0x2000000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC2                        */
-/*   Description:  NI vc2 tail timeout                                  */
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC2_SHFT 62
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC2_MASK 0x4000000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC3                        */
-/*   Description:  NI vc3 tail timeout                                  */
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC3_SHFT 63
-#define SH_NI1_ERROR_OVERFLOW_1_TAIL_TIMEOUT_NI_VC3_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_NI1_ERROR_OVERFLOW_1_ALIAS"               */
-/*                    ni1 Error Overflow Bits Alias                     */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_OVERFLOW_1_ALIAS            0x0000000150040628
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_ERROR_OVERFLOW_2"                  */
-/*                       ni1  Error Overflow Bits                       */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_OVERFLOW_2                  0x0000000150040630
-#define SH_NI1_ERROR_OVERFLOW_2_MASK             0x7fffffff003fffff
-#define SH_NI1_ERROR_OVERFLOW_2_INIT             0x7fffffff003fffff
-
-/*   SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCNI                               */
-/*   Description:  Illegal VC NI                                        */
-#define SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCNI_SHFT 0
-#define SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCNI_MASK 0x0000000000000001
-
-/*   SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCPI                               */
-/*   Description:  Illegal VC PI                                        */
-#define SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCPI_SHFT 1
-#define SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCPI_MASK 0x0000000000000002
-
-/*   SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCMD                               */
-/*   Description:  Illegal VC MD                                        */
-#define SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCMD_SHFT 2
-#define SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCMD_MASK 0x0000000000000004
-
-/*   SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCIILB                             */
-/*   Description:  Illegal VC IILB                                      */
-#define SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCIILB_SHFT 3
-#define SH_NI1_ERROR_OVERFLOW_2_ILLEGAL_VCIILB_MASK 0x0000000000000008
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_POP                   */
-/*   Description:  Fifo 02 vc0 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_POP                   */
-/*   Description:  Fifo 02 vc2 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_POP                   */
-/*   Description:  Fifo 13 vc1 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_POP                   */
-/*   Description:  Fifo 13 vc3 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_PUSH                  */
-/*   Description:  Fifo 02 vc0 push underflow                           */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_PUSH                  */
-/*   Description:  Fifo 02 vc2 push underflow                           */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_PUSH                  */
-/*   Description:  Fifo 13 vc1 push underflow                           */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_PUSH                  */
-/*   Description:  Fifo 13 vc3 push underflow                           */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_CREDIT                */
-/*   Description:  Fifo 02 vc0 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_CREDIT                */
-/*   Description:  Fifo 02 vc2 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC0_CREDIT                */
-/*   Description:  Fifo 13 vc0 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC2_CREDIT                */
-/*   Description:  Fifo 13 vc2 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW0_VC0_CREDIT                      */
-/*   Description:  VC0 credit underflow 0                               */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW1_VC0_CREDIT                      */
-/*   Description:  VC0 credit underflow 1                               */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW2_VC0_CREDIT                      */
-/*   Description:  VC0 credit underflow 2                               */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW0_VC2_CREDIT                      */
-/*   Description:  VC2 credit underflow 0                               */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW1_VC2_CREDIT                      */
-/*   Description:  VC2 credit underflow 1                               */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW2_VC2_CREDIT                      */
-/*   Description:  VC2 credit underflow 2                               */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_POP                  */
-/*   Description:  PI Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_POP                  */
-/*   Description:  PI Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_POP                */
-/*   Description:  IILB Fifo vc0 pop underflow                          */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_POP                */
-/*   Description:  IILB Fifo vc2 pop underflow                          */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_POP                  */
-/*   Description:  MD Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_POP                  */
-/*   Description:  MD Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_POP                  */
-/*   Description:  NI Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_POP                  */
-/*   Description:  NI Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_PUSH                 */
-/*   Description:  PI Fifo vc0 push underflow                           */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_PUSH                 */
-/*   Description:  PI Fifo vc2 push underflow                           */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_PUSH               */
-/*   Description:  IILB Fifo vc0 push underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_PUSH               */
-/*   Description:  IILB Fifo vc2 push underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_PUSH                 */
-/*   Description:  MD Fifo vc0 push underflow                           */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_PUSH                 */
-/*   Description:  MD Fifo vc2 push underflow                           */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_CREDIT               */
-/*   Description:  PI Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_CREDIT               */
-/*   Description:  PI Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT             */
-/*   Description:  IILB Fifo vc0 credit underflow                       */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT             */
-/*   Description:  IILB Fifo vc2 credit underflow                       */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_CREDIT               */
-/*   Description:  MD Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_CREDIT               */
-/*   Description:  MD Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_CREDIT               */
-/*   Description:  NI Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC1_CREDIT               */
-/*   Description:  NI Fifo vc1 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_CREDIT               */
-/*   Description:  NI Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC3_CREDIT               */
-/*   Description:  NI Fifo vc3 credit underflow                         */
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI1_ERROR_OVERFLOW_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC0                           */
-/*   Description:  llp deadlock vc0                                     */
-#define SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC0_SHFT 56
-#define SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC0_MASK 0x0100000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC1                           */
-/*   Description:  llp deadlock vc1                                     */
-#define SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC1_SHFT 57
-#define SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC1_MASK 0x0200000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC2                           */
-/*   Description:  llp deadlock vc2                                     */
-#define SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC2_SHFT 58
-#define SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC2_MASK 0x0400000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC3                           */
-/*   Description:  llp deadlock vc3                                     */
-#define SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC3_SHFT 59
-#define SH_NI1_ERROR_OVERFLOW_2_LLP_DEADLOCK_VC3_MASK 0x0800000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_CHIPLET_NOMATCH                            */
-/*   Description:  chiplet nomatch                                      */
-#define SH_NI1_ERROR_OVERFLOW_2_CHIPLET_NOMATCH_SHFT 60
-#define SH_NI1_ERROR_OVERFLOW_2_CHIPLET_NOMATCH_MASK 0x1000000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_LUT_READ_ERROR                             */
-/*   Description:  LUT Read Error                                       */
-#define SH_NI1_ERROR_OVERFLOW_2_LUT_READ_ERROR_SHFT 61
-#define SH_NI1_ERROR_OVERFLOW_2_LUT_READ_ERROR_MASK 0x2000000000000000
-
-/*   SH_NI1_ERROR_OVERFLOW_2_RETRY_TIMEOUT_ERROR                        */
-/*   Description:  Retry Timeout Error                                  */
-#define SH_NI1_ERROR_OVERFLOW_2_RETRY_TIMEOUT_ERROR_SHFT 62
-#define SH_NI1_ERROR_OVERFLOW_2_RETRY_TIMEOUT_ERROR_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*               Register "SH_NI1_ERROR_OVERFLOW_2_ALIAS"               */
-/*                    ni1 Error Overflow Bits Alias                     */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_OVERFLOW_2_ALIAS            0x0000000150040638
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_ERROR_MASK_1"                    */
-/*                         ni1  Error Mask Bits                         */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_MASK_1                      0x0000000150040640
-#define SH_NI1_ERROR_MASK_1_MASK                 0xffffffffffffffff
-#define SH_NI1_ERROR_MASK_1_INIT                 0xffffffffffffffff
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT0                         */
-/*   Description:  Fifo 02 debit0 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT0_SHFT 0
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT2                         */
-/*   Description:  Fifo 02 debit2 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT2_SHFT 1
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT0                         */
-/*   Description:  Fifo 13 debit0 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT0_SHFT 2
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT2                         */
-/*   Description:  Fifo 13 debit2 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT2_SHFT 3
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_POP                        */
-/*   Description:  Fifo 02 vc0 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_POP                        */
-/*   Description:  Fifo 02 vc2 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_POP                        */
-/*   Description:  Fifo 13 vc1 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_POP                        */
-/*   Description:  Fifo 13 vc3 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_PUSH                       */
-/*   Description:  Fifo 02 vc0 push overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_PUSH                       */
-/*   Description:  Fifo 02 vc2 push overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_PUSH                       */
-/*   Description:  Fifo 13 vc1 push overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_PUSH                       */
-/*   Description:  Fifo 13 vc3 push overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_CREDIT                     */
-/*   Description:  Fifo 02 vc0 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_CREDIT                     */
-/*   Description:  Fifo 02 vc2 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC0_CREDIT                     */
-/*   Description:  Fifo 13 vc0 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC2_CREDIT                     */
-/*   Description:  Fifo 13 vc2 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW0_VC0_CREDIT                           */
-/*   Description:  VC0 credit overflow 0                                */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI1_ERROR_MASK_1_OVERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW1_VC0_CREDIT                           */
-/*   Description:  VC0 credit overflow 1                                */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI1_ERROR_MASK_1_OVERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW2_VC0_CREDIT                           */
-/*   Description:  VC0 credit overflow 2                                */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI1_ERROR_MASK_1_OVERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW0_VC2_CREDIT                           */
-/*   Description:  VC2 credit overflow 0                                */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI1_ERROR_MASK_1_OVERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW1_VC2_CREDIT                           */
-/*   Description:  VC2 credit overflow 1                                */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI1_ERROR_MASK_1_OVERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW2_VC2_CREDIT                           */
-/*   Description:  VC2 credit overflow 2                                */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI1_ERROR_MASK_1_OVERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT0                        */
-/*   Description:  PI Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT0_SHFT 22
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT0_MASK 0x0000000000400000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT2                        */
-/*   Description:  PI Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT2_SHFT 23
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_DEBIT2_MASK 0x0000000000800000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT0                      */
-/*   Description:  IILB Fifo debit0 overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT0_SHFT 24
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT0_MASK 0x0000000001000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT2                      */
-/*   Description:  IILB Fifo debit2 overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT2_SHFT 25
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_DEBIT2_MASK 0x0000000002000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT0                        */
-/*   Description:  MD Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT0_SHFT 26
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT0_MASK 0x0000000004000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT2                        */
-/*   Description:  MD Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT2_SHFT 27
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_DEBIT2_MASK 0x0000000008000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT0                        */
-/*   Description:  NI Fifo debit0 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT0_SHFT 28
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT0_MASK 0x0000000010000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT1                        */
-/*   Description:  NI Fifo debit1 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT1_SHFT 29
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT1_MASK 0x0000000020000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT2                        */
-/*   Description:  NI Fifo debit2 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT2_SHFT 30
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT2_MASK 0x0000000040000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT3                        */
-/*   Description:  NI Fifo debit3 overflow                              */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT3_SHFT 31
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_DEBIT3_MASK 0x0000000080000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_POP                       */
-/*   Description:  PI Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_POP                       */
-/*   Description:  PI Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_POP                     */
-/*   Description:  IILB Fifo vc0 pop overflow                           */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_POP                     */
-/*   Description:  IILB Fifo vc2 pop overflow                           */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_POP                       */
-/*   Description:  MD Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_POP                       */
-/*   Description:  MD Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_POP                       */
-/*   Description:  NI Fifo vc0 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_POP                       */
-/*   Description:  NI Fifo vc2 pop overflow                             */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_PUSH                      */
-/*   Description:  PI Fifo vc0 push overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_PUSH                      */
-/*   Description:  PI Fifo vc2 push overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_PUSH                    */
-/*   Description:  IILB Fifo vc0 push overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_PUSH                    */
-/*   Description:  IILB Fifo vc2 push overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_PUSH                      */
-/*   Description:  MD Fifo vc0 push overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_PUSH                      */
-/*   Description:  MD Fifo vc2 push overflow                            */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_CREDIT                    */
-/*   Description:  PI Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_CREDIT                    */
-/*   Description:  PI Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_CREDIT                  */
-/*   Description:  IILB Fifo vc0 credit overflow                        */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_CREDIT                  */
-/*   Description:  IILB Fifo vc2 credit overflow                        */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_CREDIT                    */
-/*   Description:  MD Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_CREDIT                    */
-/*   Description:  MD Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_CREDIT                    */
-/*   Description:  NI Fifo vc0 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC1_CREDIT                    */
-/*   Description:  NI Fifo vc1 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_CREDIT                    */
-/*   Description:  NI Fifo vc2 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC3_CREDIT                    */
-/*   Description:  NI Fifo vc3 credit overflow                          */
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI1_ERROR_MASK_1_OVERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC0                        */
-/*   Description:  Fifo02 vc0 tail timeout                              */
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC0_SHFT 56
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC0_MASK 0x0100000000000000
-
-/*   SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC2                        */
-/*   Description:  Fifo02 vc2 tail timeout                              */
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC2_SHFT 57
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO02_VC2_MASK 0x0200000000000000
-
-/*   SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC1                        */
-/*   Description:  Fifo13 vc1 tail timeout                              */
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC1_SHFT 58
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC1_MASK 0x0400000000000000
-
-/*   SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC3                        */
-/*   Description:  Fifo13 vc3 tail timeout                              */
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC3_SHFT 59
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_FIFO13_VC3_MASK 0x0800000000000000
-
-/*   SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC0                            */
-/*   Description:  NI vc0 tail timeout                                  */
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC0_SHFT 60
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC0_MASK 0x1000000000000000
-
-/*   SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC1                            */
-/*   Description:  NI vc1 tail timeout                                  */
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC1_SHFT 61
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC1_MASK 0x2000000000000000
-
-/*   SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC2                            */
-/*   Description:  NI vc2 tail timeout                                  */
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC2_SHFT 62
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC2_MASK 0x4000000000000000
-
-/*   SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC3                            */
-/*   Description:  NI vc3 tail timeout                                  */
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC3_SHFT 63
-#define SH_NI1_ERROR_MASK_1_TAIL_TIMEOUT_NI_VC3_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_ERROR_MASK_2"                    */
-/*                         ni1  Error Mask Bits                         */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_MASK_2                      0x0000000150040650
-#define SH_NI1_ERROR_MASK_2_MASK                 0x7fffffff003fffff
-#define SH_NI1_ERROR_MASK_2_INIT                 0x7fffffff003fffff
-
-/*   SH_NI1_ERROR_MASK_2_ILLEGAL_VCNI                                   */
-/*   Description:  Illegal VC NI                                        */
-#define SH_NI1_ERROR_MASK_2_ILLEGAL_VCNI_SHFT    0
-#define SH_NI1_ERROR_MASK_2_ILLEGAL_VCNI_MASK    0x0000000000000001
-
-/*   SH_NI1_ERROR_MASK_2_ILLEGAL_VCPI                                   */
-/*   Description:  Illegal VC PI                                        */
-#define SH_NI1_ERROR_MASK_2_ILLEGAL_VCPI_SHFT    1
-#define SH_NI1_ERROR_MASK_2_ILLEGAL_VCPI_MASK    0x0000000000000002
-
-/*   SH_NI1_ERROR_MASK_2_ILLEGAL_VCMD                                   */
-/*   Description:  Illegal VC MD                                        */
-#define SH_NI1_ERROR_MASK_2_ILLEGAL_VCMD_SHFT    2
-#define SH_NI1_ERROR_MASK_2_ILLEGAL_VCMD_MASK    0x0000000000000004
-
-/*   SH_NI1_ERROR_MASK_2_ILLEGAL_VCIILB                                 */
-/*   Description:  Illegal VC IILB                                      */
-#define SH_NI1_ERROR_MASK_2_ILLEGAL_VCIILB_SHFT  3
-#define SH_NI1_ERROR_MASK_2_ILLEGAL_VCIILB_MASK  0x0000000000000008
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_POP                       */
-/*   Description:  Fifo 02 vc0 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_POP                       */
-/*   Description:  Fifo 02 vc2 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_POP                       */
-/*   Description:  Fifo 13 vc1 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_POP                       */
-/*   Description:  Fifo 13 vc3 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_PUSH                      */
-/*   Description:  Fifo 02 vc0 push underflow                           */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_PUSH                      */
-/*   Description:  Fifo 02 vc2 push underflow                           */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_PUSH                      */
-/*   Description:  Fifo 13 vc1 push underflow                           */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_PUSH                      */
-/*   Description:  Fifo 13 vc3 push underflow                           */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_CREDIT                    */
-/*   Description:  Fifo 02 vc0 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_CREDIT                    */
-/*   Description:  Fifo 02 vc2 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC0_CREDIT                    */
-/*   Description:  Fifo 13 vc0 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC2_CREDIT                    */
-/*   Description:  Fifo 13 vc2 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW0_VC0_CREDIT                          */
-/*   Description:  VC0 credit underflow 0                               */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW1_VC0_CREDIT                          */
-/*   Description:  VC0 credit underflow 1                               */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW2_VC0_CREDIT                          */
-/*   Description:  VC0 credit underflow 2                               */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW0_VC2_CREDIT                          */
-/*   Description:  VC2 credit underflow 0                               */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW1_VC2_CREDIT                          */
-/*   Description:  VC2 credit underflow 1                               */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW2_VC2_CREDIT                          */
-/*   Description:  VC2 credit underflow 2                               */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_POP                      */
-/*   Description:  PI Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_POP                      */
-/*   Description:  PI Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_POP                    */
-/*   Description:  IILB Fifo vc0 pop underflow                          */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_POP                    */
-/*   Description:  IILB Fifo vc2 pop underflow                          */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_POP                      */
-/*   Description:  MD Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_POP                      */
-/*   Description:  MD Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_POP                      */
-/*   Description:  NI Fifo vc0 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_POP                      */
-/*   Description:  NI Fifo vc2 pop underflow                            */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_PUSH                     */
-/*   Description:  PI Fifo vc0 push underflow                           */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_PUSH                     */
-/*   Description:  PI Fifo vc2 push underflow                           */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_PUSH                   */
-/*   Description:  IILB Fifo vc0 push underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_PUSH                   */
-/*   Description:  IILB Fifo vc2 push underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_PUSH                     */
-/*   Description:  MD Fifo vc0 push underflow                           */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_PUSH                     */
-/*   Description:  MD Fifo vc2 push underflow                           */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_CREDIT                   */
-/*   Description:  PI Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_CREDIT                   */
-/*   Description:  PI Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT                 */
-/*   Description:  IILB Fifo vc0 credit underflow                       */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT                 */
-/*   Description:  IILB Fifo vc2 credit underflow                       */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_CREDIT                   */
-/*   Description:  MD Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_CREDIT                   */
-/*   Description:  MD Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_CREDIT                   */
-/*   Description:  NI Fifo vc0 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC1_CREDIT                   */
-/*   Description:  NI Fifo vc1 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_CREDIT                   */
-/*   Description:  NI Fifo vc2 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC3_CREDIT                   */
-/*   Description:  NI Fifo vc3 credit underflow                         */
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI1_ERROR_MASK_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC0                               */
-/*   Description:  llp deadlock vc0                                     */
-#define SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC0_SHFT 56
-#define SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC0_MASK 0x0100000000000000
-
-/*   SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC1                               */
-/*   Description:  llp deadlock vc1                                     */
-#define SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC1_SHFT 57
-#define SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC1_MASK 0x0200000000000000
-
-/*   SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC2                               */
-/*   Description:  llp deadlock vc2                                     */
-#define SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC2_SHFT 58
-#define SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC2_MASK 0x0400000000000000
-
-/*   SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC3                               */
-/*   Description:  llp deadlock vc3                                     */
-#define SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC3_SHFT 59
-#define SH_NI1_ERROR_MASK_2_LLP_DEADLOCK_VC3_MASK 0x0800000000000000
-
-/*   SH_NI1_ERROR_MASK_2_CHIPLET_NOMATCH                                */
-/*   Description:  chiplet nomatch                                      */
-#define SH_NI1_ERROR_MASK_2_CHIPLET_NOMATCH_SHFT 60
-#define SH_NI1_ERROR_MASK_2_CHIPLET_NOMATCH_MASK 0x1000000000000000
-
-/*   SH_NI1_ERROR_MASK_2_LUT_READ_ERROR                                 */
-/*   Description:  LUT Read Error                                       */
-#define SH_NI1_ERROR_MASK_2_LUT_READ_ERROR_SHFT  61
-#define SH_NI1_ERROR_MASK_2_LUT_READ_ERROR_MASK  0x2000000000000000
-
-/*   SH_NI1_ERROR_MASK_2_RETRY_TIMEOUT_ERROR                            */
-/*   Description:  Retry Timeout Error                                  */
-#define SH_NI1_ERROR_MASK_2_RETRY_TIMEOUT_ERROR_SHFT 62
-#define SH_NI1_ERROR_MASK_2_RETRY_TIMEOUT_ERROR_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_FIRST_ERROR_1"                    */
-/*                        ni1  First Error Bits                         */
-/* ==================================================================== */
-
-#define SH_NI1_FIRST_ERROR_1                     0x0000000150040660
-#define SH_NI1_FIRST_ERROR_1_MASK                0xffffffffffffffff
-#define SH_NI1_FIRST_ERROR_1_INIT                0xffffffffffffffff
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT0                        */
-/*   Description:  Fifo 02 debit0 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT0_SHFT 0
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT2                        */
-/*   Description:  Fifo 02 debit2 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT2_SHFT 1
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT0                        */
-/*   Description:  Fifo 13 debit0 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT0_SHFT 2
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT2                        */
-/*   Description:  Fifo 13 debit2 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT2_SHFT 3
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_POP                       */
-/*   Description:  Fifo 02 vc0 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_POP                       */
-/*   Description:  Fifo 02 vc2 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_POP                       */
-/*   Description:  Fifo 13 vc1 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_POP                       */
-/*   Description:  Fifo 13 vc3 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_PUSH                      */
-/*   Description:  Fifo 02 vc0 push overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_PUSH                      */
-/*   Description:  Fifo 02 vc2 push overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_PUSH                      */
-/*   Description:  Fifo 13 vc1 push overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_PUSH                      */
-/*   Description:  Fifo 13 vc3 push overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_CREDIT                    */
-/*   Description:  Fifo 02 vc0 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_CREDIT                    */
-/*   Description:  Fifo 02 vc2 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC0_CREDIT                    */
-/*   Description:  Fifo 13 vc0 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC2_CREDIT                    */
-/*   Description:  Fifo 13 vc2 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW0_VC0_CREDIT                          */
-/*   Description:  VC0 credit overflow 0                                */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW1_VC0_CREDIT                          */
-/*   Description:  VC0 credit overflow 1                                */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW2_VC0_CREDIT                          */
-/*   Description:  VC0 credit overflow 2                                */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW0_VC2_CREDIT                          */
-/*   Description:  VC2 credit overflow 0                                */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW1_VC2_CREDIT                          */
-/*   Description:  VC2 credit overflow 1                                */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW2_VC2_CREDIT                          */
-/*   Description:  VC2 credit overflow 2                                */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT0                       */
-/*   Description:  PI Fifo debit0 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT0_SHFT 22
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT0_MASK 0x0000000000400000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT2                       */
-/*   Description:  PI Fifo debit2 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT2_SHFT 23
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_DEBIT2_MASK 0x0000000000800000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT0                     */
-/*   Description:  IILB Fifo debit0 overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT0_SHFT 24
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT0_MASK 0x0000000001000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT2                     */
-/*   Description:  IILB Fifo debit2 overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT2_SHFT 25
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_DEBIT2_MASK 0x0000000002000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT0                       */
-/*   Description:  MD Fifo debit0 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT0_SHFT 26
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT0_MASK 0x0000000004000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT2                       */
-/*   Description:  MD Fifo debit2 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT2_SHFT 27
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_DEBIT2_MASK 0x0000000008000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT0                       */
-/*   Description:  NI Fifo debit0 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT0_SHFT 28
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT0_MASK 0x0000000010000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT1                       */
-/*   Description:  NI Fifo debit1 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT1_SHFT 29
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT1_MASK 0x0000000020000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT2                       */
-/*   Description:  NI Fifo debit2 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT2_SHFT 30
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT2_MASK 0x0000000040000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT3                       */
-/*   Description:  NI Fifo debit3 overflow                              */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT3_SHFT 31
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_DEBIT3_MASK 0x0000000080000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_POP                      */
-/*   Description:  PI Fifo vc0 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_POP                      */
-/*   Description:  PI Fifo vc2 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_POP                    */
-/*   Description:  IILB Fifo vc0 pop overflow                           */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_POP                    */
-/*   Description:  IILB Fifo vc2 pop overflow                           */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_POP                      */
-/*   Description:  MD Fifo vc0 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_POP                      */
-/*   Description:  MD Fifo vc2 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_POP                      */
-/*   Description:  NI Fifo vc0 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_POP                      */
-/*   Description:  NI Fifo vc2 pop overflow                             */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_PUSH                     */
-/*   Description:  PI Fifo vc0 push overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_PUSH                     */
-/*   Description:  PI Fifo vc2 push overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_PUSH                   */
-/*   Description:  IILB Fifo vc0 push overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_PUSH                   */
-/*   Description:  IILB Fifo vc2 push overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_PUSH                     */
-/*   Description:  MD Fifo vc0 push overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_PUSH                     */
-/*   Description:  MD Fifo vc2 push overflow                            */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_CREDIT                   */
-/*   Description:  PI Fifo vc0 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_CREDIT                   */
-/*   Description:  PI Fifo vc2 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_CREDIT                 */
-/*   Description:  IILB Fifo vc0 credit overflow                        */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_CREDIT                 */
-/*   Description:  IILB Fifo vc2 credit overflow                        */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_CREDIT                   */
-/*   Description:  MD Fifo vc0 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_CREDIT                   */
-/*   Description:  MD Fifo vc2 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_CREDIT                   */
-/*   Description:  NI Fifo vc0 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC1_CREDIT                   */
-/*   Description:  NI Fifo vc1 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_CREDIT                   */
-/*   Description:  NI Fifo vc2 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC3_CREDIT                   */
-/*   Description:  NI Fifo vc3 credit overflow                          */
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI1_FIRST_ERROR_1_OVERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC0                       */
-/*   Description:  Fifo02 vc0 tail timeout                              */
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC0_SHFT 56
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC0_MASK 0x0100000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC2                       */
-/*   Description:  Fifo02 vc2 tail timeout                              */
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC2_SHFT 57
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO02_VC2_MASK 0x0200000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC1                       */
-/*   Description:  Fifo13 vc1 tail timeout                              */
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC1_SHFT 58
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC1_MASK 0x0400000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC3                       */
-/*   Description:  Fifo13 vc3 tail timeout                              */
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC3_SHFT 59
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_FIFO13_VC3_MASK 0x0800000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC0                           */
-/*   Description:  NI vc0 tail timeout                                  */
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC0_SHFT 60
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC0_MASK 0x1000000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC1                           */
-/*   Description:  NI vc1 tail timeout                                  */
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC1_SHFT 61
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC1_MASK 0x2000000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC2                           */
-/*   Description:  NI vc2 tail timeout                                  */
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC2_SHFT 62
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC2_MASK 0x4000000000000000
-
-/*   SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC3                           */
-/*   Description:  NI vc3 tail timeout                                  */
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC3_SHFT 63
-#define SH_NI1_FIRST_ERROR_1_TAIL_TIMEOUT_NI_VC3_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_FIRST_ERROR_2"                    */
-/*                         ni1 First Error Bits                         */
-/* ==================================================================== */
-
-#define SH_NI1_FIRST_ERROR_2                     0x0000000150040670
-#define SH_NI1_FIRST_ERROR_2_MASK                0x7fffffff003fffff
-#define SH_NI1_FIRST_ERROR_2_INIT                0x7fffffff003fffff
-
-/*   SH_NI1_FIRST_ERROR_2_ILLEGAL_VCNI                                  */
-/*   Description:  Illegal VC NI                                        */
-#define SH_NI1_FIRST_ERROR_2_ILLEGAL_VCNI_SHFT   0
-#define SH_NI1_FIRST_ERROR_2_ILLEGAL_VCNI_MASK   0x0000000000000001
-
-/*   SH_NI1_FIRST_ERROR_2_ILLEGAL_VCPI                                  */
-/*   Description:  Illegal VC PI                                        */
-#define SH_NI1_FIRST_ERROR_2_ILLEGAL_VCPI_SHFT   1
-#define SH_NI1_FIRST_ERROR_2_ILLEGAL_VCPI_MASK   0x0000000000000002
-
-/*   SH_NI1_FIRST_ERROR_2_ILLEGAL_VCMD                                  */
-/*   Description:  Illegal VC MD                                        */
-#define SH_NI1_FIRST_ERROR_2_ILLEGAL_VCMD_SHFT   2
-#define SH_NI1_FIRST_ERROR_2_ILLEGAL_VCMD_MASK   0x0000000000000004
-
-/*   SH_NI1_FIRST_ERROR_2_ILLEGAL_VCIILB                                */
-/*   Description:  Illegal VC IILB                                      */
-#define SH_NI1_FIRST_ERROR_2_ILLEGAL_VCIILB_SHFT 3
-#define SH_NI1_FIRST_ERROR_2_ILLEGAL_VCIILB_MASK 0x0000000000000008
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_POP                      */
-/*   Description:  Fifo 02 vc0 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_POP_SHFT 4
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_POP_MASK 0x0000000000000010
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_POP                      */
-/*   Description:  Fifo 02 vc2 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_POP_SHFT 5
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_POP_MASK 0x0000000000000020
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_POP                      */
-/*   Description:  Fifo 13 vc1 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_POP_SHFT 6
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_POP_MASK 0x0000000000000040
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_POP                      */
-/*   Description:  Fifo 13 vc3 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_POP_SHFT 7
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_POP_MASK 0x0000000000000080
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_PUSH                     */
-/*   Description:  Fifo 02 vc0 push underflow                           */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_PUSH_SHFT 8
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_PUSH_MASK 0x0000000000000100
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_PUSH                     */
-/*   Description:  Fifo 02 vc2 push underflow                           */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_PUSH_SHFT 9
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_PUSH_MASK 0x0000000000000200
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_PUSH                     */
-/*   Description:  Fifo 13 vc1 push underflow                           */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_PUSH_SHFT 10
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC1_PUSH_MASK 0x0000000000000400
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_PUSH                     */
-/*   Description:  Fifo 13 vc3 push underflow                           */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_PUSH_SHFT 11
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC3_PUSH_MASK 0x0000000000000800
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_CREDIT                   */
-/*   Description:  Fifo 02 vc0 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_CREDIT_SHFT 12
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_CREDIT                   */
-/*   Description:  Fifo 02 vc2 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_CREDIT_SHFT 13
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO02_VC2_CREDIT_MASK 0x0000000000002000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC0_CREDIT                   */
-/*   Description:  Fifo 13 vc0 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC0_CREDIT_SHFT 14
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC0_CREDIT_MASK 0x0000000000004000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC2_CREDIT                   */
-/*   Description:  Fifo 13 vc2 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC2_CREDIT_SHFT 15
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_FIFO13_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW0_VC0_CREDIT                         */
-/*   Description:  VC0 credit underflow 0                               */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW0_VC0_CREDIT_SHFT 16
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW0_VC0_CREDIT_MASK 0x0000000000010000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW1_VC0_CREDIT                         */
-/*   Description:  VC0 credit underflow 1                               */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW1_VC0_CREDIT_SHFT 17
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW1_VC0_CREDIT_MASK 0x0000000000020000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW2_VC0_CREDIT                         */
-/*   Description:  VC0 credit underflow 2                               */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW2_VC0_CREDIT_SHFT 18
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW2_VC0_CREDIT_MASK 0x0000000000040000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW0_VC2_CREDIT                         */
-/*   Description:  VC2 credit underflow 0                               */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW0_VC2_CREDIT_SHFT 19
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW0_VC2_CREDIT_MASK 0x0000000000080000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW1_VC2_CREDIT                         */
-/*   Description:  VC2 credit underflow 1                               */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW1_VC2_CREDIT_SHFT 20
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW1_VC2_CREDIT_MASK 0x0000000000100000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW2_VC2_CREDIT                         */
-/*   Description:  VC2 credit underflow 2                               */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW2_VC2_CREDIT_SHFT 21
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW2_VC2_CREDIT_MASK 0x0000000000200000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_POP                     */
-/*   Description:  PI Fifo vc0 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_POP_SHFT 32
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_POP_MASK 0x0000000100000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_POP                     */
-/*   Description:  PI Fifo vc2 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_POP_SHFT 33
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_POP_MASK 0x0000000200000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_POP                   */
-/*   Description:  IILB Fifo vc0 pop underflow                          */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_POP_SHFT 34
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_POP_MASK 0x0000000400000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_POP                   */
-/*   Description:  IILB Fifo vc2 pop underflow                          */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_POP_SHFT 35
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_POP_MASK 0x0000000800000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_POP                     */
-/*   Description:  MD Fifo vc0 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_POP_SHFT 36
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_POP_MASK 0x0000001000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_POP                     */
-/*   Description:  MD Fifo vc2 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_POP_SHFT 37
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_POP_MASK 0x0000002000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_POP                     */
-/*   Description:  NI Fifo vc0 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_POP_SHFT 38
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_POP_MASK 0x0000004000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_POP                     */
-/*   Description:  NI Fifo vc2 pop underflow                            */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_POP_SHFT 39
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_POP_MASK 0x0000008000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_PUSH                    */
-/*   Description:  PI Fifo vc0 push underflow                           */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_PUSH_SHFT 40
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_PUSH_MASK 0x0000010000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_PUSH                    */
-/*   Description:  PI Fifo vc2 push underflow                           */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_PUSH_SHFT 41
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_PUSH_MASK 0x0000020000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_PUSH                  */
-/*   Description:  IILB Fifo vc0 push underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_SHFT 42
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_PUSH_MASK 0x0000040000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_PUSH                  */
-/*   Description:  IILB Fifo vc2 push underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_SHFT 43
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_PUSH_MASK 0x0000080000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_PUSH                    */
-/*   Description:  MD Fifo vc0 push underflow                           */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_PUSH_SHFT 44
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_PUSH_MASK 0x0000100000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_PUSH                    */
-/*   Description:  MD Fifo vc2 push underflow                           */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_PUSH_SHFT 45
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_PUSH_MASK 0x0000200000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_CREDIT                  */
-/*   Description:  PI Fifo vc0 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_SHFT 46
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_CREDIT                  */
-/*   Description:  PI Fifo vc2 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_SHFT 47
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_PI_FIFO_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT                */
-/*   Description:  IILB Fifo vc0 credit underflow                       */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_SHFT 48
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC0_CREDIT_MASK 0x0001000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT                */
-/*   Description:  IILB Fifo vc2 credit underflow                       */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_SHFT 49
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_IILB_FIFO_VC2_CREDIT_MASK 0x0002000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_CREDIT                  */
-/*   Description:  MD Fifo vc0 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_SHFT 50
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC0_CREDIT_MASK 0x0004000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_CREDIT                  */
-/*   Description:  MD Fifo vc2 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_SHFT 51
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_MD_FIFO_VC2_CREDIT_MASK 0x0008000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_CREDIT                  */
-/*   Description:  NI Fifo vc0 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_SHFT 52
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC0_CREDIT_MASK 0x0010000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC1_CREDIT                  */
-/*   Description:  NI Fifo vc1 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_SHFT 53
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC1_CREDIT_MASK 0x0020000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_CREDIT                  */
-/*   Description:  NI Fifo vc2 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_SHFT 54
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC2_CREDIT_MASK 0x0040000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC3_CREDIT                  */
-/*   Description:  NI Fifo vc3 credit underflow                         */
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_SHFT 55
-#define SH_NI1_FIRST_ERROR_2_UNDERFLOW_NI_FIFO_VC3_CREDIT_MASK 0x0080000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC0                              */
-/*   Description:  llp deadlock vc0                                     */
-#define SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC0_SHFT 56
-#define SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC0_MASK 0x0100000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC1                              */
-/*   Description:  llp deadlock vc1                                     */
-#define SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC1_SHFT 57
-#define SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC1_MASK 0x0200000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC2                              */
-/*   Description:  llp deadlock vc2                                     */
-#define SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC2_SHFT 58
-#define SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC2_MASK 0x0400000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC3                              */
-/*   Description:  llp deadlock vc3                                     */
-#define SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC3_SHFT 59
-#define SH_NI1_FIRST_ERROR_2_LLP_DEADLOCK_VC3_MASK 0x0800000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_CHIPLET_NOMATCH                               */
-/*   Description:  chiplet nomatch                                      */
-#define SH_NI1_FIRST_ERROR_2_CHIPLET_NOMATCH_SHFT 60
-#define SH_NI1_FIRST_ERROR_2_CHIPLET_NOMATCH_MASK 0x1000000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_LUT_READ_ERROR                                */
-/*   Description:  LUT Read Error                                       */
-#define SH_NI1_FIRST_ERROR_2_LUT_READ_ERROR_SHFT 61
-#define SH_NI1_FIRST_ERROR_2_LUT_READ_ERROR_MASK 0x2000000000000000
-
-/*   SH_NI1_FIRST_ERROR_2_RETRY_TIMEOUT_ERROR                           */
-/*   Description:  Retry Timeout Error                                  */
-#define SH_NI1_FIRST_ERROR_2_RETRY_TIMEOUT_ERROR_SHFT 62
-#define SH_NI1_FIRST_ERROR_2_RETRY_TIMEOUT_ERROR_MASK 0x4000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_ERROR_DETAIL_1"                   */
-/*                ni1 Chiplet no match header bits 63:0                 */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_DETAIL_1                    0x0000000150040680
-#define SH_NI1_ERROR_DETAIL_1_MASK               0xffffffffffffffff
-#define SH_NI1_ERROR_DETAIL_1_INIT               0x0000000000000000
-
-/*   SH_NI1_ERROR_DETAIL_1_HEADER                                       */
-/*   Description:  Header bits 63:0                                     */
-#define SH_NI1_ERROR_DETAIL_1_HEADER_SHFT        0
-#define SH_NI1_ERROR_DETAIL_1_HEADER_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_ERROR_DETAIL_2"                   */
-/*               ni1 Chiplet no match header bits 127:64                */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_DETAIL_2                    0x0000000150040690
-#define SH_NI1_ERROR_DETAIL_2_MASK               0xffffffffffffffff
-#define SH_NI1_ERROR_DETAIL_2_INIT               0x0000000000000000
-
-/*   SH_NI1_ERROR_DETAIL_2_HEADER                                       */
-/*   Description:  Header bits 127:64                                   */
-#define SH_NI1_ERROR_DETAIL_2_HEADER_SHFT        0
-#define SH_NI1_ERROR_DETAIL_2_HEADER_MASK        0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_CORRECTED_DETAIL_1"                  */
-/*                       Corrected error details                        */
-/* ==================================================================== */
-
-#define SH_XN_CORRECTED_DETAIL_1                 0x0000000150040070
-#define SH_XN_CORRECTED_DETAIL_1_MASK            0x0fff0fff0fff0fff
-#define SH_XN_CORRECTED_DETAIL_1_INIT            0x0000000000000000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC0_SYNDROME                             */
-/*   Description:  ECC0 Syndrome                                        */
-#define SH_XN_CORRECTED_DETAIL_1_ECC0_SYNDROME_SHFT 0
-#define SH_XN_CORRECTED_DETAIL_1_ECC0_SYNDROME_MASK 0x00000000000000ff
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC0_WC                                   */
-/*   Description:  ECC0 Word Count                                      */
-#define SH_XN_CORRECTED_DETAIL_1_ECC0_WC_SHFT    8
-#define SH_XN_CORRECTED_DETAIL_1_ECC0_WC_MASK    0x0000000000000300
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC0_VC                                   */
-/*   Description:  ECC0 Virtual Channel                                 */
-#define SH_XN_CORRECTED_DETAIL_1_ECC0_VC_SHFT    10
-#define SH_XN_CORRECTED_DETAIL_1_ECC0_VC_MASK    0x0000000000000c00
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC1_SYNDROME                             */
-/*   Description:  ECC1 Syndrome                                        */
-#define SH_XN_CORRECTED_DETAIL_1_ECC1_SYNDROME_SHFT 16
-#define SH_XN_CORRECTED_DETAIL_1_ECC1_SYNDROME_MASK 0x0000000000ff0000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC1_WC                                   */
-/*   Description:  ECC1 Word Count                                      */
-#define SH_XN_CORRECTED_DETAIL_1_ECC1_WC_SHFT    24
-#define SH_XN_CORRECTED_DETAIL_1_ECC1_WC_MASK    0x0000000003000000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC1_VC                                   */
-/*   Description:  ECC1 Virtual Channel                                 */
-#define SH_XN_CORRECTED_DETAIL_1_ECC1_VC_SHFT    26
-#define SH_XN_CORRECTED_DETAIL_1_ECC1_VC_MASK    0x000000000c000000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC2_SYNDROME                             */
-/*   Description:  ECC2 Syndrome                                        */
-#define SH_XN_CORRECTED_DETAIL_1_ECC2_SYNDROME_SHFT 32
-#define SH_XN_CORRECTED_DETAIL_1_ECC2_SYNDROME_MASK 0x000000ff00000000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC2_WC                                   */
-/*   Description:  ECC2 Word Count                                      */
-#define SH_XN_CORRECTED_DETAIL_1_ECC2_WC_SHFT    40
-#define SH_XN_CORRECTED_DETAIL_1_ECC2_WC_MASK    0x0000030000000000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC2_VC                                   */
-/*   Description:  ECC2 Virtual Channel                                 */
-#define SH_XN_CORRECTED_DETAIL_1_ECC2_VC_SHFT    42
-#define SH_XN_CORRECTED_DETAIL_1_ECC2_VC_MASK    0x00000c0000000000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC3_SYNDROME                             */
-/*   Description:  ECC3 Syndrome                                        */
-#define SH_XN_CORRECTED_DETAIL_1_ECC3_SYNDROME_SHFT 48
-#define SH_XN_CORRECTED_DETAIL_1_ECC3_SYNDROME_MASK 0x00ff000000000000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC3_WC                                   */
-/*   Description:  ECC3 Word Count                                      */
-#define SH_XN_CORRECTED_DETAIL_1_ECC3_WC_SHFT    56
-#define SH_XN_CORRECTED_DETAIL_1_ECC3_WC_MASK    0x0300000000000000
-
-/*   SH_XN_CORRECTED_DETAIL_1_ECC3_VC                                   */
-/*   Description:  ECC3 Virtual Channel                                 */
-#define SH_XN_CORRECTED_DETAIL_1_ECC3_VC_SHFT    58
-#define SH_XN_CORRECTED_DETAIL_1_ECC3_VC_MASK    0x0c00000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_XN_CORRECTED_DETAIL_2"                  */
-/*                         Corrected error data                         */
-/* ==================================================================== */
-
-#define SH_XN_CORRECTED_DETAIL_2                 0x0000000150040080
-#define SH_XN_CORRECTED_DETAIL_2_MASK            0xffffffffffffffff
-#define SH_XN_CORRECTED_DETAIL_2_INIT            0x0000000000000000
-
-/*   SH_XN_CORRECTED_DETAIL_2_DATA                                      */
-/*   Description:  ECC data                                             */
-#define SH_XN_CORRECTED_DETAIL_2_DATA_SHFT       0
-#define SH_XN_CORRECTED_DETAIL_2_DATA_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_CORRECTED_DETAIL_3"                  */
-/*                       Corrected error header0                        */
-/* ==================================================================== */
-
-#define SH_XN_CORRECTED_DETAIL_3                 0x0000000150040090
-#define SH_XN_CORRECTED_DETAIL_3_MASK            0xffffffffffffffff
-#define SH_XN_CORRECTED_DETAIL_3_INIT            0x0000000000000000
-
-/*   SH_XN_CORRECTED_DETAIL_3_HEADER0                                   */
-/*   Description:  ECC header0 (bits 63 - 0)                            */
-#define SH_XN_CORRECTED_DETAIL_3_HEADER0_SHFT    0
-#define SH_XN_CORRECTED_DETAIL_3_HEADER0_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XN_CORRECTED_DETAIL_4"                  */
-/*                       Corrected error header1                        */
-/* ==================================================================== */
-
-#define SH_XN_CORRECTED_DETAIL_4                 0x00000001500400a0
-#define SH_XN_CORRECTED_DETAIL_4_MASK            0xc00003ffffffffff
-#define SH_XN_CORRECTED_DETAIL_4_INIT            0x0000000000000000
-
-/*   SH_XN_CORRECTED_DETAIL_4_HEADER1                                   */
-/*   Description:  ECC header1 (bits 104 - 64)                          */
-#define SH_XN_CORRECTED_DETAIL_4_HEADER1_SHFT    0
-#define SH_XN_CORRECTED_DETAIL_4_HEADER1_MASK    0x000003ffffffffff
-
-/*   SH_XN_CORRECTED_DETAIL_4_ERR_GROUP                                 */
-/*   Description:  Error group                                          */
-#define SH_XN_CORRECTED_DETAIL_4_ERR_GROUP_SHFT  62
-#define SH_XN_CORRECTED_DETAIL_4_ERR_GROUP_MASK  0xc000000000000000
-
-/* ==================================================================== */
-/*                Register "SH_XN_UNCORRECTED_DETAIL_1"                 */
-/*                      Uncorrected error details                       */
-/* ==================================================================== */
-
-#define SH_XN_UNCORRECTED_DETAIL_1               0x00000001500400b0
-#define SH_XN_UNCORRECTED_DETAIL_1_MASK          0x0fff0fff0fff0fff
-#define SH_XN_UNCORRECTED_DETAIL_1_INIT          0x0000000000000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC0_SYNDROME                           */
-/*   Description:  ECC0 Syndrome                                        */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC0_SYNDROME_SHFT 0
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC0_SYNDROME_MASK 0x00000000000000ff
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC0_WC                                 */
-/*   Description:  ECC0 Word Count                                      */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC0_WC_SHFT  8
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC0_WC_MASK  0x0000000000000300
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC0_VC                                 */
-/*   Description:  ECC0 Virtual Channel                                 */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC0_VC_SHFT  10
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC0_VC_MASK  0x0000000000000c00
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC1_SYNDROME                           */
-/*   Description:  ECC1 Syndrome                                        */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC1_SYNDROME_SHFT 16
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC1_SYNDROME_MASK 0x0000000000ff0000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC1_WC                                 */
-/*   Description:  ECC1 Word Count                                      */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC1_WC_SHFT  24
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC1_WC_MASK  0x0000000003000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC1_VC                                 */
-/*   Description:  ECC1 Virtual Channel                                 */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC1_VC_SHFT  26
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC1_VC_MASK  0x000000000c000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC2_SYNDROME                           */
-/*   Description:  ECC2 Syndrome                                        */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC2_SYNDROME_SHFT 32
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC2_SYNDROME_MASK 0x000000ff00000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC2_WC                                 */
-/*   Description:  ECC2 Word Count                                      */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC2_WC_SHFT  40
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC2_WC_MASK  0x0000030000000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC2_VC                                 */
-/*   Description:  ECC2 Virtual Channel                                 */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC2_VC_SHFT  42
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC2_VC_MASK  0x00000c0000000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC3_SYNDROME                           */
-/*   Description:  ECC3 Syndrome                                        */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC3_SYNDROME_SHFT 48
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC3_SYNDROME_MASK 0x00ff000000000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC3_WC                                 */
-/*   Description:  ECC3 Word Count                                      */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC3_WC_SHFT  56
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC3_WC_MASK  0x0300000000000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_1_ECC3_VC                                 */
-/*   Description:  ECC3 Virtual Channel                                 */
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC3_VC_SHFT  58
-#define SH_XN_UNCORRECTED_DETAIL_1_ECC3_VC_MASK  0x0c00000000000000
-
-/* ==================================================================== */
-/*                Register "SH_XN_UNCORRECTED_DETAIL_2"                 */
-/*                        Uncorrected error data                        */
-/* ==================================================================== */
-
-#define SH_XN_UNCORRECTED_DETAIL_2               0x00000001500400c0
-#define SH_XN_UNCORRECTED_DETAIL_2_MASK          0xffffffffffffffff
-#define SH_XN_UNCORRECTED_DETAIL_2_INIT          0x0000000000000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_2_DATA                                    */
-/*   Description:  ECC data                                             */
-#define SH_XN_UNCORRECTED_DETAIL_2_DATA_SHFT     0
-#define SH_XN_UNCORRECTED_DETAIL_2_DATA_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_UNCORRECTED_DETAIL_3"                 */
-/*                      Uncorrected error header0                       */
-/* ==================================================================== */
-
-#define SH_XN_UNCORRECTED_DETAIL_3               0x00000001500400d0
-#define SH_XN_UNCORRECTED_DETAIL_3_MASK          0xffffffffffffffff
-#define SH_XN_UNCORRECTED_DETAIL_3_INIT          0x0000000000000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_3_HEADER0                                 */
-/*   Description:  ECC header0 (bits 63 - 0)                            */
-#define SH_XN_UNCORRECTED_DETAIL_3_HEADER0_SHFT  0
-#define SH_XN_UNCORRECTED_DETAIL_3_HEADER0_MASK  0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_XN_UNCORRECTED_DETAIL_4"                 */
-/*                      Uncorrected error header1                       */
-/* ==================================================================== */
-
-#define SH_XN_UNCORRECTED_DETAIL_4               0x00000001500400e0
-#define SH_XN_UNCORRECTED_DETAIL_4_MASK          0xc00003ffffffffff
-#define SH_XN_UNCORRECTED_DETAIL_4_INIT          0x0000000000000000
-
-/*   SH_XN_UNCORRECTED_DETAIL_4_HEADER1                                 */
-/*   Description:  ECC header1 (bits 104 - 64)                          */
-#define SH_XN_UNCORRECTED_DETAIL_4_HEADER1_SHFT  0
-#define SH_XN_UNCORRECTED_DETAIL_4_HEADER1_MASK  0x000003ffffffffff
-
-/*   SH_XN_UNCORRECTED_DETAIL_4_ERR_GROUP                               */
-/*   Description:  Error group                                          */
-#define SH_XN_UNCORRECTED_DETAIL_4_ERR_GROUP_SHFT 62
-#define SH_XN_UNCORRECTED_DETAIL_4_ERR_GROUP_MASK 0xc000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_XNMD_ERROR_DETAIL_1"                   */
-/*                      Look Up Table Address (md)                      */
-/* ==================================================================== */
-
-#define SH_XNMD_ERROR_DETAIL_1                   0x00000001500400f0
-#define SH_XNMD_ERROR_DETAIL_1_MASK              0x00000000000007ff
-#define SH_XNMD_ERROR_DETAIL_1_INIT              0x0000000000000000
-
-/*   SH_XNMD_ERROR_DETAIL_1_LUT_ADDR                                    */
-/*   Description:  Look Up Table Read Address                           */
-#define SH_XNMD_ERROR_DETAIL_1_LUT_ADDR_SHFT     0
-#define SH_XNMD_ERROR_DETAIL_1_LUT_ADDR_MASK     0x00000000000007ff
-
-/* ==================================================================== */
-/*                  Register "SH_XNPI_ERROR_DETAIL_1"                   */
-/*                      Look Up Table Address (pi)                      */
-/* ==================================================================== */
-
-#define SH_XNPI_ERROR_DETAIL_1                   0x0000000150040100
-#define SH_XNPI_ERROR_DETAIL_1_MASK              0x00000000000007ff
-#define SH_XNPI_ERROR_DETAIL_1_INIT              0x0000000000000000
-
-/*   SH_XNPI_ERROR_DETAIL_1_LUT_ADDR                                    */
-/*   Description:  Look Up Table Read Address                           */
-#define SH_XNPI_ERROR_DETAIL_1_LUT_ADDR_SHFT     0
-#define SH_XNPI_ERROR_DETAIL_1_LUT_ADDR_MASK     0x00000000000007ff
-
-/* ==================================================================== */
-/*                 Register "SH_XNIILB_ERROR_DETAIL_1"                  */
-/*                    Chiplet NoMatch header [63:0]                     */
-/* ==================================================================== */
-
-#define SH_XNIILB_ERROR_DETAIL_1                 0x0000000150040110
-#define SH_XNIILB_ERROR_DETAIL_1_MASK            0xffffffffffffffff
-#define SH_XNIILB_ERROR_DETAIL_1_INIT            0x0000000000000000
-
-/*   SH_XNIILB_ERROR_DETAIL_1_HEADER                                    */
-/*   Description:  header bits [63:0]                                   */
-#define SH_XNIILB_ERROR_DETAIL_1_HEADER_SHFT     0
-#define SH_XNIILB_ERROR_DETAIL_1_HEADER_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XNIILB_ERROR_DETAIL_2"                  */
-/*                   Chiplet NoMatch header [127:64]                    */
-/* ==================================================================== */
-
-#define SH_XNIILB_ERROR_DETAIL_2                 0x0000000150040120
-#define SH_XNIILB_ERROR_DETAIL_2_MASK            0xffffffffffffffff
-#define SH_XNIILB_ERROR_DETAIL_2_INIT            0x0000000000000000
-
-/*   SH_XNIILB_ERROR_DETAIL_2_HEADER                                    */
-/*   Description:  header bits [127:64]                                 */
-#define SH_XNIILB_ERROR_DETAIL_2_HEADER_SHFT     0
-#define SH_XNIILB_ERROR_DETAIL_2_HEADER_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                 Register "SH_XNIILB_ERROR_DETAIL_3"                  */
-/*                     Look Up Table Address (iilb)                     */
-/* ==================================================================== */
-
-#define SH_XNIILB_ERROR_DETAIL_3                 0x0000000150040130
-#define SH_XNIILB_ERROR_DETAIL_3_MASK            0x00000000000007ff
-#define SH_XNIILB_ERROR_DETAIL_3_INIT            0x0000000000000000
-
-/*   SH_XNIILB_ERROR_DETAIL_3_LUT_ADDR                                  */
-/*   Description:  Look Up Table Read Address                           */
-#define SH_XNIILB_ERROR_DETAIL_3_LUT_ADDR_SHFT   0
-#define SH_XNIILB_ERROR_DETAIL_3_LUT_ADDR_MASK   0x00000000000007ff
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_ERROR_DETAIL_3"                   */
-/*                     Look Up Table Address (ni0)                      */
-/* ==================================================================== */
-
-#define SH_NI0_ERROR_DETAIL_3                    0x0000000150040140
-#define SH_NI0_ERROR_DETAIL_3_MASK               0x00000000000007ff
-#define SH_NI0_ERROR_DETAIL_3_INIT               0x0000000000000000
-
-/*   SH_NI0_ERROR_DETAIL_3_LUT_ADDR                                     */
-/*   Description:  Look Up Table Read Address                           */
-#define SH_NI0_ERROR_DETAIL_3_LUT_ADDR_SHFT      0
-#define SH_NI0_ERROR_DETAIL_3_LUT_ADDR_MASK      0x00000000000007ff
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_ERROR_DETAIL_3"                   */
-/*                     Look Up Table Address (ni1)                      */
-/* ==================================================================== */
-
-#define SH_NI1_ERROR_DETAIL_3                    0x0000000150040150
-#define SH_NI1_ERROR_DETAIL_3_MASK               0x00000000000007ff
-#define SH_NI1_ERROR_DETAIL_3_INIT               0x0000000000000000
-
-/*   SH_NI1_ERROR_DETAIL_3_LUT_ADDR                                     */
-/*   Description:  Look Up Table Read Address                           */
-#define SH_NI1_ERROR_DETAIL_3_LUT_ADDR_SHFT      0
-#define SH_NI1_ERROR_DETAIL_3_LUT_ADDR_MASK      0x00000000000007ff
-
-/* ==================================================================== */
-/*                    Register "SH_XN_ERROR_SUMMARY"                    */
-/* ==================================================================== */
-
-#define SH_XN_ERROR_SUMMARY                      0x0000000150040000
-#define SH_XN_ERROR_SUMMARY_MASK                 0x0000003fffffffff
-#define SH_XN_ERROR_SUMMARY_INIT                 0x0000003fffffffff
-
-/*   SH_XN_ERROR_SUMMARY_NI0_POP_OVERFLOW                               */
-/*   Description:  NI0 pop overflow                                     */
-#define SH_XN_ERROR_SUMMARY_NI0_POP_OVERFLOW_SHFT 0
-#define SH_XN_ERROR_SUMMARY_NI0_POP_OVERFLOW_MASK 0x0000000000000001
-
-/*   SH_XN_ERROR_SUMMARY_NI0_PUSH_OVERFLOW                              */
-/*   Description:  NI0 push overflow                                    */
-#define SH_XN_ERROR_SUMMARY_NI0_PUSH_OVERFLOW_SHFT 1
-#define SH_XN_ERROR_SUMMARY_NI0_PUSH_OVERFLOW_MASK 0x0000000000000002
-
-/*   SH_XN_ERROR_SUMMARY_NI0_CREDIT_OVERFLOW                            */
-/*   Description:  NI0 credit overflow                                  */
-#define SH_XN_ERROR_SUMMARY_NI0_CREDIT_OVERFLOW_SHFT 2
-#define SH_XN_ERROR_SUMMARY_NI0_CREDIT_OVERFLOW_MASK 0x0000000000000004
-
-/*   SH_XN_ERROR_SUMMARY_NI0_DEBIT_OVERFLOW                             */
-/*   Description:  NI0 debit overflow                                   */
-#define SH_XN_ERROR_SUMMARY_NI0_DEBIT_OVERFLOW_SHFT 3
-#define SH_XN_ERROR_SUMMARY_NI0_DEBIT_OVERFLOW_MASK 0x0000000000000008
-
-/*   SH_XN_ERROR_SUMMARY_NI0_POP_UNDERFLOW                              */
-/*   Description:  NI0 pop underflow                                    */
-#define SH_XN_ERROR_SUMMARY_NI0_POP_UNDERFLOW_SHFT 4
-#define SH_XN_ERROR_SUMMARY_NI0_POP_UNDERFLOW_MASK 0x0000000000000010
-
-/*   SH_XN_ERROR_SUMMARY_NI0_PUSH_UNDERFLOW                             */
-/*   Description:  NI0 push underflow                                   */
-#define SH_XN_ERROR_SUMMARY_NI0_PUSH_UNDERFLOW_SHFT 5
-#define SH_XN_ERROR_SUMMARY_NI0_PUSH_UNDERFLOW_MASK 0x0000000000000020
-
-/*   SH_XN_ERROR_SUMMARY_NI0_CREDIT_UNDERFLOW                           */
-/*   Description:  NI0 credit underflow                                 */
-#define SH_XN_ERROR_SUMMARY_NI0_CREDIT_UNDERFLOW_SHFT 6
-#define SH_XN_ERROR_SUMMARY_NI0_CREDIT_UNDERFLOW_MASK 0x0000000000000040
-
-/*   SH_XN_ERROR_SUMMARY_NI0_LLP_ERROR                                  */
-/*   Description:  NI0 llp error                                        */
-#define SH_XN_ERROR_SUMMARY_NI0_LLP_ERROR_SHFT   7
-#define SH_XN_ERROR_SUMMARY_NI0_LLP_ERROR_MASK   0x0000000000000080
-
-/*   SH_XN_ERROR_SUMMARY_NI0_PIPE_ERROR                                 */
-/*   Description:  NI0 Pipe in/out errors                               */
-#define SH_XN_ERROR_SUMMARY_NI0_PIPE_ERROR_SHFT  8
-#define SH_XN_ERROR_SUMMARY_NI0_PIPE_ERROR_MASK  0x0000000000000100
-
-/*   SH_XN_ERROR_SUMMARY_NI1_POP_OVERFLOW                               */
-/*   Description:  NI1 pop overflow                                     */
-#define SH_XN_ERROR_SUMMARY_NI1_POP_OVERFLOW_SHFT 9
-#define SH_XN_ERROR_SUMMARY_NI1_POP_OVERFLOW_MASK 0x0000000000000200
-
-/*   SH_XN_ERROR_SUMMARY_NI1_PUSH_OVERFLOW                              */
-/*   Description:  NI1 push overflow                                    */
-#define SH_XN_ERROR_SUMMARY_NI1_PUSH_OVERFLOW_SHFT 10
-#define SH_XN_ERROR_SUMMARY_NI1_PUSH_OVERFLOW_MASK 0x0000000000000400
-
-/*   SH_XN_ERROR_SUMMARY_NI1_CREDIT_OVERFLOW                            */
-/*   Description:  NI1 credit overflow                                  */
-#define SH_XN_ERROR_SUMMARY_NI1_CREDIT_OVERFLOW_SHFT 11
-#define SH_XN_ERROR_SUMMARY_NI1_CREDIT_OVERFLOW_MASK 0x0000000000000800
-
-/*   SH_XN_ERROR_SUMMARY_NI1_DEBIT_OVERFLOW                             */
-/*   Description:  NI1 debit overflow                                   */
-#define SH_XN_ERROR_SUMMARY_NI1_DEBIT_OVERFLOW_SHFT 12
-#define SH_XN_ERROR_SUMMARY_NI1_DEBIT_OVERFLOW_MASK 0x0000000000001000
-
-/*   SH_XN_ERROR_SUMMARY_NI1_POP_UNDERFLOW                              */
-/*   Description:  NI1 pop underflow                                    */
-#define SH_XN_ERROR_SUMMARY_NI1_POP_UNDERFLOW_SHFT 13
-#define SH_XN_ERROR_SUMMARY_NI1_POP_UNDERFLOW_MASK 0x0000000000002000
-
-/*   SH_XN_ERROR_SUMMARY_NI1_PUSH_UNDERFLOW                             */
-/*   Description:  NI1 push underflow                                   */
-#define SH_XN_ERROR_SUMMARY_NI1_PUSH_UNDERFLOW_SHFT 14
-#define SH_XN_ERROR_SUMMARY_NI1_PUSH_UNDERFLOW_MASK 0x0000000000004000
-
-/*   SH_XN_ERROR_SUMMARY_NI1_CREDIT_UNDERFLOW                           */
-/*   Description:  NI1 credit underflow                                 */
-#define SH_XN_ERROR_SUMMARY_NI1_CREDIT_UNDERFLOW_SHFT 15
-#define SH_XN_ERROR_SUMMARY_NI1_CREDIT_UNDERFLOW_MASK 0x0000000000008000
-
-/*   SH_XN_ERROR_SUMMARY_NI1_LLP_ERROR                                  */
-/*   Description:  NI1 llp error                                        */
-#define SH_XN_ERROR_SUMMARY_NI1_LLP_ERROR_SHFT   16
-#define SH_XN_ERROR_SUMMARY_NI1_LLP_ERROR_MASK   0x0000000000010000
-
-/*   SH_XN_ERROR_SUMMARY_NI1_PIPE_ERROR                                 */
-/*   Description:  NI1 pipe in/out error                                */
-#define SH_XN_ERROR_SUMMARY_NI1_PIPE_ERROR_SHFT  17
-#define SH_XN_ERROR_SUMMARY_NI1_PIPE_ERROR_MASK  0x0000000000020000
-
-/*   SH_XN_ERROR_SUMMARY_XNMD_CREDIT_OVERFLOW                           */
-/*   Description:  XNMD credit overflow                                 */
-#define SH_XN_ERROR_SUMMARY_XNMD_CREDIT_OVERFLOW_SHFT 18
-#define SH_XN_ERROR_SUMMARY_XNMD_CREDIT_OVERFLOW_MASK 0x0000000000040000
-
-/*   SH_XN_ERROR_SUMMARY_XNMD_DEBIT_OVERFLOW                            */
-/*   Description:  XNMD debit overflow                                  */
-#define SH_XN_ERROR_SUMMARY_XNMD_DEBIT_OVERFLOW_SHFT 19
-#define SH_XN_ERROR_SUMMARY_XNMD_DEBIT_OVERFLOW_MASK 0x0000000000080000
-
-/*   SH_XN_ERROR_SUMMARY_XNMD_DATA_BUFF_OVERFLOW                        */
-/*   Description:  XNMD data buffer overflow                            */
-#define SH_XN_ERROR_SUMMARY_XNMD_DATA_BUFF_OVERFLOW_SHFT 20
-#define SH_XN_ERROR_SUMMARY_XNMD_DATA_BUFF_OVERFLOW_MASK 0x0000000000100000
-
-/*   SH_XN_ERROR_SUMMARY_XNMD_CREDIT_UNDERFLOW                          */
-/*   Description:  XNMD credit underflow                                */
-#define SH_XN_ERROR_SUMMARY_XNMD_CREDIT_UNDERFLOW_SHFT 21
-#define SH_XN_ERROR_SUMMARY_XNMD_CREDIT_UNDERFLOW_MASK 0x0000000000200000
-
-/*   SH_XN_ERROR_SUMMARY_XNMD_SBE_ERROR                                 */
-/*   Description:  XNMD single bit error                                */
-#define SH_XN_ERROR_SUMMARY_XNMD_SBE_ERROR_SHFT  22
-#define SH_XN_ERROR_SUMMARY_XNMD_SBE_ERROR_MASK  0x0000000000400000
-
-/*   SH_XN_ERROR_SUMMARY_XNMD_UCE_ERROR                                 */
-/*   Description:  XNMD uncorrectable error                             */
-#define SH_XN_ERROR_SUMMARY_XNMD_UCE_ERROR_SHFT  23
-#define SH_XN_ERROR_SUMMARY_XNMD_UCE_ERROR_MASK  0x0000000000800000
-
-/*   SH_XN_ERROR_SUMMARY_XNMD_LUT_ERROR                                 */
-/*   Description:  XNMD look up table error                             */
-#define SH_XN_ERROR_SUMMARY_XNMD_LUT_ERROR_SHFT  24
-#define SH_XN_ERROR_SUMMARY_XNMD_LUT_ERROR_MASK  0x0000000001000000
-
-/*   SH_XN_ERROR_SUMMARY_XNPI_CREDIT_OVERFLOW                           */
-/*   Description:  XNMD credit overflow                                 */
-#define SH_XN_ERROR_SUMMARY_XNPI_CREDIT_OVERFLOW_SHFT 25
-#define SH_XN_ERROR_SUMMARY_XNPI_CREDIT_OVERFLOW_MASK 0x0000000002000000
-
-/*   SH_XN_ERROR_SUMMARY_XNPI_DEBIT_OVERFLOW                            */
-/*   Description:  XNPI debit overflow                                  */
-#define SH_XN_ERROR_SUMMARY_XNPI_DEBIT_OVERFLOW_SHFT 26
-#define SH_XN_ERROR_SUMMARY_XNPI_DEBIT_OVERFLOW_MASK 0x0000000004000000
-
-/*   SH_XN_ERROR_SUMMARY_XNPI_DATA_BUFF_OVERFLOW                        */
-/*   Description:  XNPI data buffer overflow                            */
-#define SH_XN_ERROR_SUMMARY_XNPI_DATA_BUFF_OVERFLOW_SHFT 27
-#define SH_XN_ERROR_SUMMARY_XNPI_DATA_BUFF_OVERFLOW_MASK 0x0000000008000000
-
-/*   SH_XN_ERROR_SUMMARY_XNPI_CREDIT_UNDERFLOW                          */
-/*   Description:  XNPI credit underflow                                */
-#define SH_XN_ERROR_SUMMARY_XNPI_CREDIT_UNDERFLOW_SHFT 28
-#define SH_XN_ERROR_SUMMARY_XNPI_CREDIT_UNDERFLOW_MASK 0x0000000010000000
-
-/*   SH_XN_ERROR_SUMMARY_XNPI_SBE_ERROR                                 */
-/*   Description:  XNPI single bit error                                */
-#define SH_XN_ERROR_SUMMARY_XNPI_SBE_ERROR_SHFT  29
-#define SH_XN_ERROR_SUMMARY_XNPI_SBE_ERROR_MASK  0x0000000020000000
-
-/*   SH_XN_ERROR_SUMMARY_XNPI_UCE_ERROR                                 */
-/*   Description:  XNPI uncorrectable error                             */
-#define SH_XN_ERROR_SUMMARY_XNPI_UCE_ERROR_SHFT  30
-#define SH_XN_ERROR_SUMMARY_XNPI_UCE_ERROR_MASK  0x0000000040000000
-
-/*   SH_XN_ERROR_SUMMARY_XNPI_LUT_ERROR                                 */
-/*   Description:  XNPI look up table error                             */
-#define SH_XN_ERROR_SUMMARY_XNPI_LUT_ERROR_SHFT  31
-#define SH_XN_ERROR_SUMMARY_XNPI_LUT_ERROR_MASK  0x0000000080000000
-
-/*   SH_XN_ERROR_SUMMARY_IILB_DEBIT_OVERFLOW                            */
-/*   Description:  IILB debit overflow                                  */
-#define SH_XN_ERROR_SUMMARY_IILB_DEBIT_OVERFLOW_SHFT 32
-#define SH_XN_ERROR_SUMMARY_IILB_DEBIT_OVERFLOW_MASK 0x0000000100000000
-
-/*   SH_XN_ERROR_SUMMARY_IILB_CREDIT_OVERFLOW                           */
-/*   Description:  IILB credit overflow                                 */
-#define SH_XN_ERROR_SUMMARY_IILB_CREDIT_OVERFLOW_SHFT 33
-#define SH_XN_ERROR_SUMMARY_IILB_CREDIT_OVERFLOW_MASK 0x0000000200000000
-
-/*   SH_XN_ERROR_SUMMARY_IILB_FIFO_OVERFLOW                             */
-/*   Description:  IILB fifo overflow                                   */
-#define SH_XN_ERROR_SUMMARY_IILB_FIFO_OVERFLOW_SHFT 34
-#define SH_XN_ERROR_SUMMARY_IILB_FIFO_OVERFLOW_MASK 0x0000000400000000
-
-/*   SH_XN_ERROR_SUMMARY_IILB_CREDIT_UNDERFLOW                          */
-/*   Description:  IILB credit underflow                                */
-#define SH_XN_ERROR_SUMMARY_IILB_CREDIT_UNDERFLOW_SHFT 35
-#define SH_XN_ERROR_SUMMARY_IILB_CREDIT_UNDERFLOW_MASK 0x0000000800000000
-
-/*   SH_XN_ERROR_SUMMARY_IILB_FIFO_UNDERFLOW                            */
-/*   Description:  IILB fifo underflow                                  */
-#define SH_XN_ERROR_SUMMARY_IILB_FIFO_UNDERFLOW_SHFT 36
-#define SH_XN_ERROR_SUMMARY_IILB_FIFO_UNDERFLOW_MASK 0x0000001000000000
-
-/*   SH_XN_ERROR_SUMMARY_IILB_CHIPLET_OR_LUT                            */
-/*   Description:  IILB chiplet nomatch or lut read error               */
-#define SH_XN_ERROR_SUMMARY_IILB_CHIPLET_OR_LUT_SHFT 37
-#define SH_XN_ERROR_SUMMARY_IILB_CHIPLET_OR_LUT_MASK 0x0000002000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XN_ERRORS_ALIAS"                     */
-/* ==================================================================== */
-
-#define SH_XN_ERRORS_ALIAS                       0x0000000150040008
-
-/* ==================================================================== */
-/*                   Register "SH_XN_ERROR_OVERFLOW"                    */
-/* ==================================================================== */
-
-#define SH_XN_ERROR_OVERFLOW                     0x0000000150040020
-#define SH_XN_ERROR_OVERFLOW_MASK                0x0000003fffffffff
-#define SH_XN_ERROR_OVERFLOW_INIT                0x0000003fffffffff
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_POP_OVERFLOW                              */
-/*   Description:  NI0 pop overflow                                     */
-#define SH_XN_ERROR_OVERFLOW_NI0_POP_OVERFLOW_SHFT 0
-#define SH_XN_ERROR_OVERFLOW_NI0_POP_OVERFLOW_MASK 0x0000000000000001
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_PUSH_OVERFLOW                             */
-/*   Description:  NI0 push overflow                                    */
-#define SH_XN_ERROR_OVERFLOW_NI0_PUSH_OVERFLOW_SHFT 1
-#define SH_XN_ERROR_OVERFLOW_NI0_PUSH_OVERFLOW_MASK 0x0000000000000002
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_CREDIT_OVERFLOW                           */
-/*   Description:  NI0 credit overflow                                  */
-#define SH_XN_ERROR_OVERFLOW_NI0_CREDIT_OVERFLOW_SHFT 2
-#define SH_XN_ERROR_OVERFLOW_NI0_CREDIT_OVERFLOW_MASK 0x0000000000000004
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_DEBIT_OVERFLOW                            */
-/*   Description:  NI0 debit overflow                                   */
-#define SH_XN_ERROR_OVERFLOW_NI0_DEBIT_OVERFLOW_SHFT 3
-#define SH_XN_ERROR_OVERFLOW_NI0_DEBIT_OVERFLOW_MASK 0x0000000000000008
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_POP_UNDERFLOW                             */
-/*   Description:  NI0 pop underflow                                    */
-#define SH_XN_ERROR_OVERFLOW_NI0_POP_UNDERFLOW_SHFT 4
-#define SH_XN_ERROR_OVERFLOW_NI0_POP_UNDERFLOW_MASK 0x0000000000000010
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_PUSH_UNDERFLOW                            */
-/*   Description:  NI0 push underflow                                   */
-#define SH_XN_ERROR_OVERFLOW_NI0_PUSH_UNDERFLOW_SHFT 5
-#define SH_XN_ERROR_OVERFLOW_NI0_PUSH_UNDERFLOW_MASK 0x0000000000000020
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_CREDIT_UNDERFLOW                          */
-/*   Description:  NI0 credit underflow                                 */
-#define SH_XN_ERROR_OVERFLOW_NI0_CREDIT_UNDERFLOW_SHFT 6
-#define SH_XN_ERROR_OVERFLOW_NI0_CREDIT_UNDERFLOW_MASK 0x0000000000000040
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_LLP_ERROR                                 */
-/*   Description:  NI0 llp error                                        */
-#define SH_XN_ERROR_OVERFLOW_NI0_LLP_ERROR_SHFT  7
-#define SH_XN_ERROR_OVERFLOW_NI0_LLP_ERROR_MASK  0x0000000000000080
-
-/*   SH_XN_ERROR_OVERFLOW_NI0_PIPE_ERROR                                */
-/*   Description:  NI0 Pipe in/out errors                               */
-#define SH_XN_ERROR_OVERFLOW_NI0_PIPE_ERROR_SHFT 8
-#define SH_XN_ERROR_OVERFLOW_NI0_PIPE_ERROR_MASK 0x0000000000000100
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_POP_OVERFLOW                              */
-/*   Description:  NI1 pop overflow                                     */
-#define SH_XN_ERROR_OVERFLOW_NI1_POP_OVERFLOW_SHFT 9
-#define SH_XN_ERROR_OVERFLOW_NI1_POP_OVERFLOW_MASK 0x0000000000000200
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_PUSH_OVERFLOW                             */
-/*   Description:  NI1 push overflow                                    */
-#define SH_XN_ERROR_OVERFLOW_NI1_PUSH_OVERFLOW_SHFT 10
-#define SH_XN_ERROR_OVERFLOW_NI1_PUSH_OVERFLOW_MASK 0x0000000000000400
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_CREDIT_OVERFLOW                           */
-/*   Description:  NI1 credit overflow                                  */
-#define SH_XN_ERROR_OVERFLOW_NI1_CREDIT_OVERFLOW_SHFT 11
-#define SH_XN_ERROR_OVERFLOW_NI1_CREDIT_OVERFLOW_MASK 0x0000000000000800
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_DEBIT_OVERFLOW                            */
-/*   Description:  NI1 debit overflow                                   */
-#define SH_XN_ERROR_OVERFLOW_NI1_DEBIT_OVERFLOW_SHFT 12
-#define SH_XN_ERROR_OVERFLOW_NI1_DEBIT_OVERFLOW_MASK 0x0000000000001000
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_POP_UNDERFLOW                             */
-/*   Description:  NI1 pop underflow                                    */
-#define SH_XN_ERROR_OVERFLOW_NI1_POP_UNDERFLOW_SHFT 13
-#define SH_XN_ERROR_OVERFLOW_NI1_POP_UNDERFLOW_MASK 0x0000000000002000
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_PUSH_UNDERFLOW                            */
-/*   Description:  NI1 push underflow                                   */
-#define SH_XN_ERROR_OVERFLOW_NI1_PUSH_UNDERFLOW_SHFT 14
-#define SH_XN_ERROR_OVERFLOW_NI1_PUSH_UNDERFLOW_MASK 0x0000000000004000
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_CREDIT_UNDERFLOW                          */
-/*   Description:  NI1 credit underflow                                 */
-#define SH_XN_ERROR_OVERFLOW_NI1_CREDIT_UNDERFLOW_SHFT 15
-#define SH_XN_ERROR_OVERFLOW_NI1_CREDIT_UNDERFLOW_MASK 0x0000000000008000
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_LLP_ERROR                                 */
-/*   Description:  NI1 llp error                                        */
-#define SH_XN_ERROR_OVERFLOW_NI1_LLP_ERROR_SHFT  16
-#define SH_XN_ERROR_OVERFLOW_NI1_LLP_ERROR_MASK  0x0000000000010000
-
-/*   SH_XN_ERROR_OVERFLOW_NI1_PIPE_ERROR                                */
-/*   Description:  NI1 pipe in/out error                                */
-#define SH_XN_ERROR_OVERFLOW_NI1_PIPE_ERROR_SHFT 17
-#define SH_XN_ERROR_OVERFLOW_NI1_PIPE_ERROR_MASK 0x0000000000020000
-
-/*   SH_XN_ERROR_OVERFLOW_XNMD_CREDIT_OVERFLOW                          */
-/*   Description:  XNMD credit overflow                                 */
-#define SH_XN_ERROR_OVERFLOW_XNMD_CREDIT_OVERFLOW_SHFT 18
-#define SH_XN_ERROR_OVERFLOW_XNMD_CREDIT_OVERFLOW_MASK 0x0000000000040000
-
-/*   SH_XN_ERROR_OVERFLOW_XNMD_DEBIT_OVERFLOW                           */
-/*   Description:  XNMD debit overflow                                  */
-#define SH_XN_ERROR_OVERFLOW_XNMD_DEBIT_OVERFLOW_SHFT 19
-#define SH_XN_ERROR_OVERFLOW_XNMD_DEBIT_OVERFLOW_MASK 0x0000000000080000
-
-/*   SH_XN_ERROR_OVERFLOW_XNMD_DATA_BUFF_OVERFLOW                       */
-/*   Description:  XNMD data buffer overflow                            */
-#define SH_XN_ERROR_OVERFLOW_XNMD_DATA_BUFF_OVERFLOW_SHFT 20
-#define SH_XN_ERROR_OVERFLOW_XNMD_DATA_BUFF_OVERFLOW_MASK 0x0000000000100000
-
-/*   SH_XN_ERROR_OVERFLOW_XNMD_CREDIT_UNDERFLOW                         */
-/*   Description:  XNMD credit underflow                                */
-#define SH_XN_ERROR_OVERFLOW_XNMD_CREDIT_UNDERFLOW_SHFT 21
-#define SH_XN_ERROR_OVERFLOW_XNMD_CREDIT_UNDERFLOW_MASK 0x0000000000200000
-
-/*   SH_XN_ERROR_OVERFLOW_XNMD_SBE_ERROR                                */
-/*   Description:  XNMD single bit error                                */
-#define SH_XN_ERROR_OVERFLOW_XNMD_SBE_ERROR_SHFT 22
-#define SH_XN_ERROR_OVERFLOW_XNMD_SBE_ERROR_MASK 0x0000000000400000
-
-/*   SH_XN_ERROR_OVERFLOW_XNMD_UCE_ERROR                                */
-/*   Description:  XNMD uncorrectable error                             */
-#define SH_XN_ERROR_OVERFLOW_XNMD_UCE_ERROR_SHFT 23
-#define SH_XN_ERROR_OVERFLOW_XNMD_UCE_ERROR_MASK 0x0000000000800000
-
-/*   SH_XN_ERROR_OVERFLOW_XNMD_LUT_ERROR                                */
-/*   Description:  XNMD look up table error                             */
-#define SH_XN_ERROR_OVERFLOW_XNMD_LUT_ERROR_SHFT 24
-#define SH_XN_ERROR_OVERFLOW_XNMD_LUT_ERROR_MASK 0x0000000001000000
-
-/*   SH_XN_ERROR_OVERFLOW_XNPI_CREDIT_OVERFLOW                          */
-/*   Description:  XNMD credit overflow                                 */
-#define SH_XN_ERROR_OVERFLOW_XNPI_CREDIT_OVERFLOW_SHFT 25
-#define SH_XN_ERROR_OVERFLOW_XNPI_CREDIT_OVERFLOW_MASK 0x0000000002000000
-
-/*   SH_XN_ERROR_OVERFLOW_XNPI_DEBIT_OVERFLOW                           */
-/*   Description:  XNPI debit overflow                                  */
-#define SH_XN_ERROR_OVERFLOW_XNPI_DEBIT_OVERFLOW_SHFT 26
-#define SH_XN_ERROR_OVERFLOW_XNPI_DEBIT_OVERFLOW_MASK 0x0000000004000000
-
-/*   SH_XN_ERROR_OVERFLOW_XNPI_DATA_BUFF_OVERFLOW                       */
-/*   Description:  XNPI data buffer overflow                            */
-#define SH_XN_ERROR_OVERFLOW_XNPI_DATA_BUFF_OVERFLOW_SHFT 27
-#define SH_XN_ERROR_OVERFLOW_XNPI_DATA_BUFF_OVERFLOW_MASK 0x0000000008000000
-
-/*   SH_XN_ERROR_OVERFLOW_XNPI_CREDIT_UNDERFLOW                         */
-/*   Description:  XNPI credit underflow                                */
-#define SH_XN_ERROR_OVERFLOW_XNPI_CREDIT_UNDERFLOW_SHFT 28
-#define SH_XN_ERROR_OVERFLOW_XNPI_CREDIT_UNDERFLOW_MASK 0x0000000010000000
-
-/*   SH_XN_ERROR_OVERFLOW_XNPI_SBE_ERROR                                */
-/*   Description:  XNPI single bit error                                */
-#define SH_XN_ERROR_OVERFLOW_XNPI_SBE_ERROR_SHFT 29
-#define SH_XN_ERROR_OVERFLOW_XNPI_SBE_ERROR_MASK 0x0000000020000000
-
-/*   SH_XN_ERROR_OVERFLOW_XNPI_UCE_ERROR                                */
-/*   Description:  XNPI uncorrectable error                             */
-#define SH_XN_ERROR_OVERFLOW_XNPI_UCE_ERROR_SHFT 30
-#define SH_XN_ERROR_OVERFLOW_XNPI_UCE_ERROR_MASK 0x0000000040000000
-
-/*   SH_XN_ERROR_OVERFLOW_XNPI_LUT_ERROR                                */
-/*   Description:  XNPI look up table error                             */
-#define SH_XN_ERROR_OVERFLOW_XNPI_LUT_ERROR_SHFT 31
-#define SH_XN_ERROR_OVERFLOW_XNPI_LUT_ERROR_MASK 0x0000000080000000
-
-/*   SH_XN_ERROR_OVERFLOW_IILB_DEBIT_OVERFLOW                           */
-/*   Description:  IILB debit overflow                                  */
-#define SH_XN_ERROR_OVERFLOW_IILB_DEBIT_OVERFLOW_SHFT 32
-#define SH_XN_ERROR_OVERFLOW_IILB_DEBIT_OVERFLOW_MASK 0x0000000100000000
-
-/*   SH_XN_ERROR_OVERFLOW_IILB_CREDIT_OVERFLOW                          */
-/*   Description:  IILB credit overflow                                 */
-#define SH_XN_ERROR_OVERFLOW_IILB_CREDIT_OVERFLOW_SHFT 33
-#define SH_XN_ERROR_OVERFLOW_IILB_CREDIT_OVERFLOW_MASK 0x0000000200000000
-
-/*   SH_XN_ERROR_OVERFLOW_IILB_FIFO_OVERFLOW                            */
-/*   Description:  IILB fifo overflow                                   */
-#define SH_XN_ERROR_OVERFLOW_IILB_FIFO_OVERFLOW_SHFT 34
-#define SH_XN_ERROR_OVERFLOW_IILB_FIFO_OVERFLOW_MASK 0x0000000400000000
-
-/*   SH_XN_ERROR_OVERFLOW_IILB_CREDIT_UNDERFLOW                         */
-/*   Description:  IILB credit underflow                                */
-#define SH_XN_ERROR_OVERFLOW_IILB_CREDIT_UNDERFLOW_SHFT 35
-#define SH_XN_ERROR_OVERFLOW_IILB_CREDIT_UNDERFLOW_MASK 0x0000000800000000
-
-/*   SH_XN_ERROR_OVERFLOW_IILB_FIFO_UNDERFLOW                           */
-/*   Description:  IILB fifo underflow                                  */
-#define SH_XN_ERROR_OVERFLOW_IILB_FIFO_UNDERFLOW_SHFT 36
-#define SH_XN_ERROR_OVERFLOW_IILB_FIFO_UNDERFLOW_MASK 0x0000001000000000
-
-/*   SH_XN_ERROR_OVERFLOW_IILB_CHIPLET_OR_LUT                           */
-/*   Description:  IILB chiplet nomatch or lut read error               */
-#define SH_XN_ERROR_OVERFLOW_IILB_CHIPLET_OR_LUT_SHFT 37
-#define SH_XN_ERROR_OVERFLOW_IILB_CHIPLET_OR_LUT_MASK 0x0000002000000000
-
-/* ==================================================================== */
-/*                Register "SH_XN_ERROR_OVERFLOW_ALIAS"                 */
-/* ==================================================================== */
-
-#define SH_XN_ERROR_OVERFLOW_ALIAS               0x0000000150040028
-
-/* ==================================================================== */
-/*                     Register "SH_XN_ERROR_MASK"                      */
-/* ==================================================================== */
-
-#define SH_XN_ERROR_MASK                         0x0000000150040040
-#define SH_XN_ERROR_MASK_MASK                    0x0000003fffffffff
-#define SH_XN_ERROR_MASK_INIT                    0x0000003fffffffff
-
-/*   SH_XN_ERROR_MASK_NI0_POP_OVERFLOW                                  */
-/*   Description:  NI0 pop overflow                                     */
-#define SH_XN_ERROR_MASK_NI0_POP_OVERFLOW_SHFT   0
-#define SH_XN_ERROR_MASK_NI0_POP_OVERFLOW_MASK   0x0000000000000001
-
-/*   SH_XN_ERROR_MASK_NI0_PUSH_OVERFLOW                                 */
-/*   Description:  NI0 push overflow                                    */
-#define SH_XN_ERROR_MASK_NI0_PUSH_OVERFLOW_SHFT  1
-#define SH_XN_ERROR_MASK_NI0_PUSH_OVERFLOW_MASK  0x0000000000000002
-
-/*   SH_XN_ERROR_MASK_NI0_CREDIT_OVERFLOW                               */
-/*   Description:  NI0 credit overflow                                  */
-#define SH_XN_ERROR_MASK_NI0_CREDIT_OVERFLOW_SHFT 2
-#define SH_XN_ERROR_MASK_NI0_CREDIT_OVERFLOW_MASK 0x0000000000000004
-
-/*   SH_XN_ERROR_MASK_NI0_DEBIT_OVERFLOW                                */
-/*   Description:  NI0 debit overflow                                   */
-#define SH_XN_ERROR_MASK_NI0_DEBIT_OVERFLOW_SHFT 3
-#define SH_XN_ERROR_MASK_NI0_DEBIT_OVERFLOW_MASK 0x0000000000000008
-
-/*   SH_XN_ERROR_MASK_NI0_POP_UNDERFLOW                                 */
-/*   Description:  NI0 pop underflow                                    */
-#define SH_XN_ERROR_MASK_NI0_POP_UNDERFLOW_SHFT  4
-#define SH_XN_ERROR_MASK_NI0_POP_UNDERFLOW_MASK  0x0000000000000010
-
-/*   SH_XN_ERROR_MASK_NI0_PUSH_UNDERFLOW                                */
-/*   Description:  NI0 push underflow                                   */
-#define SH_XN_ERROR_MASK_NI0_PUSH_UNDERFLOW_SHFT 5
-#define SH_XN_ERROR_MASK_NI0_PUSH_UNDERFLOW_MASK 0x0000000000000020
-
-/*   SH_XN_ERROR_MASK_NI0_CREDIT_UNDERFLOW                              */
-/*   Description:  NI0 credit underflow                                 */
-#define SH_XN_ERROR_MASK_NI0_CREDIT_UNDERFLOW_SHFT 6
-#define SH_XN_ERROR_MASK_NI0_CREDIT_UNDERFLOW_MASK 0x0000000000000040
-
-/*   SH_XN_ERROR_MASK_NI0_LLP_ERROR                                     */
-/*   Description:  NI0 llp error                                        */
-#define SH_XN_ERROR_MASK_NI0_LLP_ERROR_SHFT      7
-#define SH_XN_ERROR_MASK_NI0_LLP_ERROR_MASK      0x0000000000000080
-
-/*   SH_XN_ERROR_MASK_NI0_PIPE_ERROR                                    */
-/*   Description:  NI0 Pipe in/out errors                               */
-#define SH_XN_ERROR_MASK_NI0_PIPE_ERROR_SHFT     8
-#define SH_XN_ERROR_MASK_NI0_PIPE_ERROR_MASK     0x0000000000000100
-
-/*   SH_XN_ERROR_MASK_NI1_POP_OVERFLOW                                  */
-/*   Description:  NI1 pop overflow                                     */
-#define SH_XN_ERROR_MASK_NI1_POP_OVERFLOW_SHFT   9
-#define SH_XN_ERROR_MASK_NI1_POP_OVERFLOW_MASK   0x0000000000000200
-
-/*   SH_XN_ERROR_MASK_NI1_PUSH_OVERFLOW                                 */
-/*   Description:  NI1 push overflow                                    */
-#define SH_XN_ERROR_MASK_NI1_PUSH_OVERFLOW_SHFT  10
-#define SH_XN_ERROR_MASK_NI1_PUSH_OVERFLOW_MASK  0x0000000000000400
-
-/*   SH_XN_ERROR_MASK_NI1_CREDIT_OVERFLOW                               */
-/*   Description:  NI1 credit overflow                                  */
-#define SH_XN_ERROR_MASK_NI1_CREDIT_OVERFLOW_SHFT 11
-#define SH_XN_ERROR_MASK_NI1_CREDIT_OVERFLOW_MASK 0x0000000000000800
-
-/*   SH_XN_ERROR_MASK_NI1_DEBIT_OVERFLOW                                */
-/*   Description:  NI1 debit overflow                                   */
-#define SH_XN_ERROR_MASK_NI1_DEBIT_OVERFLOW_SHFT 12
-#define SH_XN_ERROR_MASK_NI1_DEBIT_OVERFLOW_MASK 0x0000000000001000
-
-/*   SH_XN_ERROR_MASK_NI1_POP_UNDERFLOW                                 */
-/*   Description:  NI1 pop underflow                                    */
-#define SH_XN_ERROR_MASK_NI1_POP_UNDERFLOW_SHFT  13
-#define SH_XN_ERROR_MASK_NI1_POP_UNDERFLOW_MASK  0x0000000000002000
-
-/*   SH_XN_ERROR_MASK_NI1_PUSH_UNDERFLOW                                */
-/*   Description:  NI1 push underflow                                   */
-#define SH_XN_ERROR_MASK_NI1_PUSH_UNDERFLOW_SHFT 14
-#define SH_XN_ERROR_MASK_NI1_PUSH_UNDERFLOW_MASK 0x0000000000004000
-
-/*   SH_XN_ERROR_MASK_NI1_CREDIT_UNDERFLOW                              */
-/*   Description:  NI1 credit underflow                                 */
-#define SH_XN_ERROR_MASK_NI1_CREDIT_UNDERFLOW_SHFT 15
-#define SH_XN_ERROR_MASK_NI1_CREDIT_UNDERFLOW_MASK 0x0000000000008000
-
-/*   SH_XN_ERROR_MASK_NI1_LLP_ERROR                                     */
-/*   Description:  NI1 llp error                                        */
-#define SH_XN_ERROR_MASK_NI1_LLP_ERROR_SHFT      16
-#define SH_XN_ERROR_MASK_NI1_LLP_ERROR_MASK      0x0000000000010000
-
-/*   SH_XN_ERROR_MASK_NI1_PIPE_ERROR                                    */
-/*   Description:  NI1 pipe in/out error                                */
-#define SH_XN_ERROR_MASK_NI1_PIPE_ERROR_SHFT     17
-#define SH_XN_ERROR_MASK_NI1_PIPE_ERROR_MASK     0x0000000000020000
-
-/*   SH_XN_ERROR_MASK_XNMD_CREDIT_OVERFLOW                              */
-/*   Description:  XNMD credit overflow                                 */
-#define SH_XN_ERROR_MASK_XNMD_CREDIT_OVERFLOW_SHFT 18
-#define SH_XN_ERROR_MASK_XNMD_CREDIT_OVERFLOW_MASK 0x0000000000040000
-
-/*   SH_XN_ERROR_MASK_XNMD_DEBIT_OVERFLOW                               */
-/*   Description:  XNMD debit overflow                                  */
-#define SH_XN_ERROR_MASK_XNMD_DEBIT_OVERFLOW_SHFT 19
-#define SH_XN_ERROR_MASK_XNMD_DEBIT_OVERFLOW_MASK 0x0000000000080000
-
-/*   SH_XN_ERROR_MASK_XNMD_DATA_BUFF_OVERFLOW                           */
-/*   Description:  XNMD data buffer overflow                            */
-#define SH_XN_ERROR_MASK_XNMD_DATA_BUFF_OVERFLOW_SHFT 20
-#define SH_XN_ERROR_MASK_XNMD_DATA_BUFF_OVERFLOW_MASK 0x0000000000100000
-
-/*   SH_XN_ERROR_MASK_XNMD_CREDIT_UNDERFLOW                             */
-/*   Description:  XNMD credit underflow                                */
-#define SH_XN_ERROR_MASK_XNMD_CREDIT_UNDERFLOW_SHFT 21
-#define SH_XN_ERROR_MASK_XNMD_CREDIT_UNDERFLOW_MASK 0x0000000000200000
-
-/*   SH_XN_ERROR_MASK_XNMD_SBE_ERROR                                    */
-/*   Description:  XNMD single bit error                                */
-#define SH_XN_ERROR_MASK_XNMD_SBE_ERROR_SHFT     22
-#define SH_XN_ERROR_MASK_XNMD_SBE_ERROR_MASK     0x0000000000400000
-
-/*   SH_XN_ERROR_MASK_XNMD_UCE_ERROR                                    */
-/*   Description:  XNMD uncorrectable error                             */
-#define SH_XN_ERROR_MASK_XNMD_UCE_ERROR_SHFT     23
-#define SH_XN_ERROR_MASK_XNMD_UCE_ERROR_MASK     0x0000000000800000
-
-/*   SH_XN_ERROR_MASK_XNMD_LUT_ERROR                                    */
-/*   Description:  XNMD look up table error                             */
-#define SH_XN_ERROR_MASK_XNMD_LUT_ERROR_SHFT     24
-#define SH_XN_ERROR_MASK_XNMD_LUT_ERROR_MASK     0x0000000001000000
-
-/*   SH_XN_ERROR_MASK_XNPI_CREDIT_OVERFLOW                              */
-/*   Description:  XNMD credit overflow                                 */
-#define SH_XN_ERROR_MASK_XNPI_CREDIT_OVERFLOW_SHFT 25
-#define SH_XN_ERROR_MASK_XNPI_CREDIT_OVERFLOW_MASK 0x0000000002000000
-
-/*   SH_XN_ERROR_MASK_XNPI_DEBIT_OVERFLOW                               */
-/*   Description:  XNPI debit overflow                                  */
-#define SH_XN_ERROR_MASK_XNPI_DEBIT_OVERFLOW_SHFT 26
-#define SH_XN_ERROR_MASK_XNPI_DEBIT_OVERFLOW_MASK 0x0000000004000000
-
-/*   SH_XN_ERROR_MASK_XNPI_DATA_BUFF_OVERFLOW                           */
-/*   Description:  XNPI data buffer overflow                            */
-#define SH_XN_ERROR_MASK_XNPI_DATA_BUFF_OVERFLOW_SHFT 27
-#define SH_XN_ERROR_MASK_XNPI_DATA_BUFF_OVERFLOW_MASK 0x0000000008000000
-
-/*   SH_XN_ERROR_MASK_XNPI_CREDIT_UNDERFLOW                             */
-/*   Description:  XNPI credit underflow                                */
-#define SH_XN_ERROR_MASK_XNPI_CREDIT_UNDERFLOW_SHFT 28
-#define SH_XN_ERROR_MASK_XNPI_CREDIT_UNDERFLOW_MASK 0x0000000010000000
-
-/*   SH_XN_ERROR_MASK_XNPI_SBE_ERROR                                    */
-/*   Description:  XNPI single bit error                                */
-#define SH_XN_ERROR_MASK_XNPI_SBE_ERROR_SHFT     29
-#define SH_XN_ERROR_MASK_XNPI_SBE_ERROR_MASK     0x0000000020000000
-
-/*   SH_XN_ERROR_MASK_XNPI_UCE_ERROR                                    */
-/*   Description:  XNPI uncorrectable error                             */
-#define SH_XN_ERROR_MASK_XNPI_UCE_ERROR_SHFT     30
-#define SH_XN_ERROR_MASK_XNPI_UCE_ERROR_MASK     0x0000000040000000
-
-/*   SH_XN_ERROR_MASK_XNPI_LUT_ERROR                                    */
-/*   Description:  XNPI look up table error                             */
-#define SH_XN_ERROR_MASK_XNPI_LUT_ERROR_SHFT     31
-#define SH_XN_ERROR_MASK_XNPI_LUT_ERROR_MASK     0x0000000080000000
-
-/*   SH_XN_ERROR_MASK_IILB_DEBIT_OVERFLOW                               */
-/*   Description:  IILB debit overflow                                  */
-#define SH_XN_ERROR_MASK_IILB_DEBIT_OVERFLOW_SHFT 32
-#define SH_XN_ERROR_MASK_IILB_DEBIT_OVERFLOW_MASK 0x0000000100000000
-
-/*   SH_XN_ERROR_MASK_IILB_CREDIT_OVERFLOW                              */
-/*   Description:  IILB credit overflow                                 */
-#define SH_XN_ERROR_MASK_IILB_CREDIT_OVERFLOW_SHFT 33
-#define SH_XN_ERROR_MASK_IILB_CREDIT_OVERFLOW_MASK 0x0000000200000000
-
-/*   SH_XN_ERROR_MASK_IILB_FIFO_OVERFLOW                                */
-/*   Description:  IILB fifo overflow                                   */
-#define SH_XN_ERROR_MASK_IILB_FIFO_OVERFLOW_SHFT 34
-#define SH_XN_ERROR_MASK_IILB_FIFO_OVERFLOW_MASK 0x0000000400000000
-
-/*   SH_XN_ERROR_MASK_IILB_CREDIT_UNDERFLOW                             */
-/*   Description:  IILB credit underflow                                */
-#define SH_XN_ERROR_MASK_IILB_CREDIT_UNDERFLOW_SHFT 35
-#define SH_XN_ERROR_MASK_IILB_CREDIT_UNDERFLOW_MASK 0x0000000800000000
-
-/*   SH_XN_ERROR_MASK_IILB_FIFO_UNDERFLOW                               */
-/*   Description:  IILB fifo underflow                                  */
-#define SH_XN_ERROR_MASK_IILB_FIFO_UNDERFLOW_SHFT 36
-#define SH_XN_ERROR_MASK_IILB_FIFO_UNDERFLOW_MASK 0x0000001000000000
-
-/*   SH_XN_ERROR_MASK_IILB_CHIPLET_OR_LUT                               */
-/*   Description:  IILB chiplet nomatch or lut read error               */
-#define SH_XN_ERROR_MASK_IILB_CHIPLET_OR_LUT_SHFT 37
-#define SH_XN_ERROR_MASK_IILB_CHIPLET_OR_LUT_MASK 0x0000002000000000
-
-/* ==================================================================== */
-/*                     Register "SH_XN_FIRST_ERROR"                     */
-/* ==================================================================== */
-
-#define SH_XN_FIRST_ERROR                        0x0000000150040060
-#define SH_XN_FIRST_ERROR_MASK                   0x0000003fffffffff
-#define SH_XN_FIRST_ERROR_INIT                   0x0000003fffffffff
-
-/*   SH_XN_FIRST_ERROR_NI0_POP_OVERFLOW                                 */
-/*   Description:  NI0 pop overflow                                     */
-#define SH_XN_FIRST_ERROR_NI0_POP_OVERFLOW_SHFT  0
-#define SH_XN_FIRST_ERROR_NI0_POP_OVERFLOW_MASK  0x0000000000000001
-
-/*   SH_XN_FIRST_ERROR_NI0_PUSH_OVERFLOW                                */
-/*   Description:  NI0 push overflow                                    */
-#define SH_XN_FIRST_ERROR_NI0_PUSH_OVERFLOW_SHFT 1
-#define SH_XN_FIRST_ERROR_NI0_PUSH_OVERFLOW_MASK 0x0000000000000002
-
-/*   SH_XN_FIRST_ERROR_NI0_CREDIT_OVERFLOW                              */
-/*   Description:  NI0 credit overflow                                  */
-#define SH_XN_FIRST_ERROR_NI0_CREDIT_OVERFLOW_SHFT 2
-#define SH_XN_FIRST_ERROR_NI0_CREDIT_OVERFLOW_MASK 0x0000000000000004
-
-/*   SH_XN_FIRST_ERROR_NI0_DEBIT_OVERFLOW                               */
-/*   Description:  NI0 debit overflow                                   */
-#define SH_XN_FIRST_ERROR_NI0_DEBIT_OVERFLOW_SHFT 3
-#define SH_XN_FIRST_ERROR_NI0_DEBIT_OVERFLOW_MASK 0x0000000000000008
-
-/*   SH_XN_FIRST_ERROR_NI0_POP_UNDERFLOW                                */
-/*   Description:  NI0 pop underflow                                    */
-#define SH_XN_FIRST_ERROR_NI0_POP_UNDERFLOW_SHFT 4
-#define SH_XN_FIRST_ERROR_NI0_POP_UNDERFLOW_MASK 0x0000000000000010
-
-/*   SH_XN_FIRST_ERROR_NI0_PUSH_UNDERFLOW                               */
-/*   Description:  NI0 push underflow                                   */
-#define SH_XN_FIRST_ERROR_NI0_PUSH_UNDERFLOW_SHFT 5
-#define SH_XN_FIRST_ERROR_NI0_PUSH_UNDERFLOW_MASK 0x0000000000000020
-
-/*   SH_XN_FIRST_ERROR_NI0_CREDIT_UNDERFLOW                             */
-/*   Description:  NI0 credit underflow                                 */
-#define SH_XN_FIRST_ERROR_NI0_CREDIT_UNDERFLOW_SHFT 6
-#define SH_XN_FIRST_ERROR_NI0_CREDIT_UNDERFLOW_MASK 0x0000000000000040
-
-/*   SH_XN_FIRST_ERROR_NI0_LLP_ERROR                                    */
-/*   Description:  NI0 llp error                                        */
-#define SH_XN_FIRST_ERROR_NI0_LLP_ERROR_SHFT     7
-#define SH_XN_FIRST_ERROR_NI0_LLP_ERROR_MASK     0x0000000000000080
-
-/*   SH_XN_FIRST_ERROR_NI0_PIPE_ERROR                                   */
-/*   Description:  NI0 Pipe in/out errors                               */
-#define SH_XN_FIRST_ERROR_NI0_PIPE_ERROR_SHFT    8
-#define SH_XN_FIRST_ERROR_NI0_PIPE_ERROR_MASK    0x0000000000000100
-
-/*   SH_XN_FIRST_ERROR_NI1_POP_OVERFLOW                                 */
-/*   Description:  NI1 pop overflow                                     */
-#define SH_XN_FIRST_ERROR_NI1_POP_OVERFLOW_SHFT  9
-#define SH_XN_FIRST_ERROR_NI1_POP_OVERFLOW_MASK  0x0000000000000200
-
-/*   SH_XN_FIRST_ERROR_NI1_PUSH_OVERFLOW                                */
-/*   Description:  NI1 push overflow                                    */
-#define SH_XN_FIRST_ERROR_NI1_PUSH_OVERFLOW_SHFT 10
-#define SH_XN_FIRST_ERROR_NI1_PUSH_OVERFLOW_MASK 0x0000000000000400
-
-/*   SH_XN_FIRST_ERROR_NI1_CREDIT_OVERFLOW                              */
-/*   Description:  NI1 credit overflow                                  */
-#define SH_XN_FIRST_ERROR_NI1_CREDIT_OVERFLOW_SHFT 11
-#define SH_XN_FIRST_ERROR_NI1_CREDIT_OVERFLOW_MASK 0x0000000000000800
-
-/*   SH_XN_FIRST_ERROR_NI1_DEBIT_OVERFLOW                               */
-/*   Description:  NI1 debit overflow                                   */
-#define SH_XN_FIRST_ERROR_NI1_DEBIT_OVERFLOW_SHFT 12
-#define SH_XN_FIRST_ERROR_NI1_DEBIT_OVERFLOW_MASK 0x0000000000001000
-
-/*   SH_XN_FIRST_ERROR_NI1_POP_UNDERFLOW                                */
-/*   Description:  NI1 pop underflow                                    */
-#define SH_XN_FIRST_ERROR_NI1_POP_UNDERFLOW_SHFT 13
-#define SH_XN_FIRST_ERROR_NI1_POP_UNDERFLOW_MASK 0x0000000000002000
-
-/*   SH_XN_FIRST_ERROR_NI1_PUSH_UNDERFLOW                               */
-/*   Description:  NI1 push underflow                                   */
-#define SH_XN_FIRST_ERROR_NI1_PUSH_UNDERFLOW_SHFT 14
-#define SH_XN_FIRST_ERROR_NI1_PUSH_UNDERFLOW_MASK 0x0000000000004000
-
-/*   SH_XN_FIRST_ERROR_NI1_CREDIT_UNDERFLOW                             */
-/*   Description:  NI1 credit underflow                                 */
-#define SH_XN_FIRST_ERROR_NI1_CREDIT_UNDERFLOW_SHFT 15
-#define SH_XN_FIRST_ERROR_NI1_CREDIT_UNDERFLOW_MASK 0x0000000000008000
-
-/*   SH_XN_FIRST_ERROR_NI1_LLP_ERROR                                    */
-/*   Description:  NI1 llp error                                        */
-#define SH_XN_FIRST_ERROR_NI1_LLP_ERROR_SHFT     16
-#define SH_XN_FIRST_ERROR_NI1_LLP_ERROR_MASK     0x0000000000010000
-
-/*   SH_XN_FIRST_ERROR_NI1_PIPE_ERROR                                   */
-/*   Description:  NI1 pipe in/out error                                */
-#define SH_XN_FIRST_ERROR_NI1_PIPE_ERROR_SHFT    17
-#define SH_XN_FIRST_ERROR_NI1_PIPE_ERROR_MASK    0x0000000000020000
-
-/*   SH_XN_FIRST_ERROR_XNMD_CREDIT_OVERFLOW                             */
-/*   Description:  XNMD credit overflow                                 */
-#define SH_XN_FIRST_ERROR_XNMD_CREDIT_OVERFLOW_SHFT 18
-#define SH_XN_FIRST_ERROR_XNMD_CREDIT_OVERFLOW_MASK 0x0000000000040000
-
-/*   SH_XN_FIRST_ERROR_XNMD_DEBIT_OVERFLOW                              */
-/*   Description:  XNMD debit overflow                                  */
-#define SH_XN_FIRST_ERROR_XNMD_DEBIT_OVERFLOW_SHFT 19
-#define SH_XN_FIRST_ERROR_XNMD_DEBIT_OVERFLOW_MASK 0x0000000000080000
-
-/*   SH_XN_FIRST_ERROR_XNMD_DATA_BUFF_OVERFLOW                          */
-/*   Description:  XNMD data buffer overflow                            */
-#define SH_XN_FIRST_ERROR_XNMD_DATA_BUFF_OVERFLOW_SHFT 20
-#define SH_XN_FIRST_ERROR_XNMD_DATA_BUFF_OVERFLOW_MASK 0x0000000000100000
-
-/*   SH_XN_FIRST_ERROR_XNMD_CREDIT_UNDERFLOW                            */
-/*   Description:  XNMD credit underflow                                */
-#define SH_XN_FIRST_ERROR_XNMD_CREDIT_UNDERFLOW_SHFT 21
-#define SH_XN_FIRST_ERROR_XNMD_CREDIT_UNDERFLOW_MASK 0x0000000000200000
-
-/*   SH_XN_FIRST_ERROR_XNMD_SBE_ERROR                                   */
-/*   Description:  XNMD single bit error                                */
-#define SH_XN_FIRST_ERROR_XNMD_SBE_ERROR_SHFT    22
-#define SH_XN_FIRST_ERROR_XNMD_SBE_ERROR_MASK    0x0000000000400000
-
-/*   SH_XN_FIRST_ERROR_XNMD_UCE_ERROR                                   */
-/*   Description:  XNMD uncorrectable error                             */
-#define SH_XN_FIRST_ERROR_XNMD_UCE_ERROR_SHFT    23
-#define SH_XN_FIRST_ERROR_XNMD_UCE_ERROR_MASK    0x0000000000800000
-
-/*   SH_XN_FIRST_ERROR_XNMD_LUT_ERROR                                   */
-/*   Description:  XNMD look up table error                             */
-#define SH_XN_FIRST_ERROR_XNMD_LUT_ERROR_SHFT    24
-#define SH_XN_FIRST_ERROR_XNMD_LUT_ERROR_MASK    0x0000000001000000
-
-/*   SH_XN_FIRST_ERROR_XNPI_CREDIT_OVERFLOW                             */
-/*   Description:  XNMD credit overflow                                 */
-#define SH_XN_FIRST_ERROR_XNPI_CREDIT_OVERFLOW_SHFT 25
-#define SH_XN_FIRST_ERROR_XNPI_CREDIT_OVERFLOW_MASK 0x0000000002000000
-
-/*   SH_XN_FIRST_ERROR_XNPI_DEBIT_OVERFLOW                              */
-/*   Description:  XNPI debit overflow                                  */
-#define SH_XN_FIRST_ERROR_XNPI_DEBIT_OVERFLOW_SHFT 26
-#define SH_XN_FIRST_ERROR_XNPI_DEBIT_OVERFLOW_MASK 0x0000000004000000
-
-/*   SH_XN_FIRST_ERROR_XNPI_DATA_BUFF_OVERFLOW                          */
-/*   Description:  XNPI data buffer overflow                            */
-#define SH_XN_FIRST_ERROR_XNPI_DATA_BUFF_OVERFLOW_SHFT 27
-#define SH_XN_FIRST_ERROR_XNPI_DATA_BUFF_OVERFLOW_MASK 0x0000000008000000
-
-/*   SH_XN_FIRST_ERROR_XNPI_CREDIT_UNDERFLOW                            */
-/*   Description:  XNPI credit underflow                                */
-#define SH_XN_FIRST_ERROR_XNPI_CREDIT_UNDERFLOW_SHFT 28
-#define SH_XN_FIRST_ERROR_XNPI_CREDIT_UNDERFLOW_MASK 0x0000000010000000
-
-/*   SH_XN_FIRST_ERROR_XNPI_SBE_ERROR                                   */
-/*   Description:  XNPI single bit error                                */
-#define SH_XN_FIRST_ERROR_XNPI_SBE_ERROR_SHFT    29
-#define SH_XN_FIRST_ERROR_XNPI_SBE_ERROR_MASK    0x0000000020000000
-
-/*   SH_XN_FIRST_ERROR_XNPI_UCE_ERROR                                   */
-/*   Description:  XNPI uncorrectable error                             */
-#define SH_XN_FIRST_ERROR_XNPI_UCE_ERROR_SHFT    30
-#define SH_XN_FIRST_ERROR_XNPI_UCE_ERROR_MASK    0x0000000040000000
-
-/*   SH_XN_FIRST_ERROR_XNPI_LUT_ERROR                                   */
-/*   Description:  XNPI look up table error                             */
-#define SH_XN_FIRST_ERROR_XNPI_LUT_ERROR_SHFT    31
-#define SH_XN_FIRST_ERROR_XNPI_LUT_ERROR_MASK    0x0000000080000000
-
-/*   SH_XN_FIRST_ERROR_IILB_DEBIT_OVERFLOW                              */
-/*   Description:  IILB debit overflow                                  */
-#define SH_XN_FIRST_ERROR_IILB_DEBIT_OVERFLOW_SHFT 32
-#define SH_XN_FIRST_ERROR_IILB_DEBIT_OVERFLOW_MASK 0x0000000100000000
-
-/*   SH_XN_FIRST_ERROR_IILB_CREDIT_OVERFLOW                             */
-/*   Description:  IILB credit overflow                                 */
-#define SH_XN_FIRST_ERROR_IILB_CREDIT_OVERFLOW_SHFT 33
-#define SH_XN_FIRST_ERROR_IILB_CREDIT_OVERFLOW_MASK 0x0000000200000000
-
-/*   SH_XN_FIRST_ERROR_IILB_FIFO_OVERFLOW                               */
-/*   Description:  IILB fifo overflow                                   */
-#define SH_XN_FIRST_ERROR_IILB_FIFO_OVERFLOW_SHFT 34
-#define SH_XN_FIRST_ERROR_IILB_FIFO_OVERFLOW_MASK 0x0000000400000000
-
-/*   SH_XN_FIRST_ERROR_IILB_CREDIT_UNDERFLOW                            */
-/*   Description:  IILB credit underflow                                */
-#define SH_XN_FIRST_ERROR_IILB_CREDIT_UNDERFLOW_SHFT 35
-#define SH_XN_FIRST_ERROR_IILB_CREDIT_UNDERFLOW_MASK 0x0000000800000000
-
-/*   SH_XN_FIRST_ERROR_IILB_FIFO_UNDERFLOW                              */
-/*   Description:  IILB fifo underflow                                  */
-#define SH_XN_FIRST_ERROR_IILB_FIFO_UNDERFLOW_SHFT 36
-#define SH_XN_FIRST_ERROR_IILB_FIFO_UNDERFLOW_MASK 0x0000001000000000
-
-/*   SH_XN_FIRST_ERROR_IILB_CHIPLET_OR_LUT                              */
-/*   Description:  IILB chiplet nomatch or lut read error               */
-#define SH_XN_FIRST_ERROR_IILB_CHIPLET_OR_LUT_SHFT 37
-#define SH_XN_FIRST_ERROR_IILB_CHIPLET_OR_LUT_MASK 0x0000002000000000
-
-/* ==================================================================== */
-/*                  Register "SH_XNIILB_ERROR_SUMMARY"                  */
-/* ==================================================================== */
-
-#define SH_XNIILB_ERROR_SUMMARY                  0x0000000150040200
-#define SH_XNIILB_ERROR_SUMMARY_MASK             0xffffffffffffffff
-#define SH_XNIILB_ERROR_SUMMARY_INIT             0xffffffffffffffff
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_DEBIT0                         */
-/*   Description:  II debit0 overflow                                   */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_DEBIT0_SHFT 0
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_DEBIT2                         */
-/*   Description:  II debit2 overflow                                   */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_DEBIT2_SHFT 1
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_DEBIT0                         */
-/*   Description:  LB debit0 overflow                                   */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_DEBIT0_SHFT 2
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_DEBIT2                         */
-/*   Description:  LB debit2 overflow                                   */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_DEBIT2_SHFT 3
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_VC0                            */
-/*   Description:  II VC0 fifo overflow                                 */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_VC0_SHFT 4
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_VC0_MASK 0x0000000000000010
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_VC2                            */
-/*   Description:  II VC2 fifo overflow                                 */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_VC2_SHFT 5
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_II_VC2_MASK 0x0000000000000020
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_II_VC0                           */
-/*   Description:  II VC0 fifo underflow                                */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_II_VC0_SHFT 6
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_II_VC0_MASK 0x0000000000000040
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_II_VC2                           */
-/*   Description:  II VC2 fifo underflow                                */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_II_VC2_SHFT 7
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_II_VC2_MASK 0x0000000000000080
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_VC0                            */
-/*   Description:  LB VC0 fifo overflow                                 */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_VC0_SHFT 8
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_VC2                            */
-/*   Description:  LB VC2 fifo overflow                                 */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_VC2_SHFT 9
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_LB_VC2_MASK 0x0000000000000200
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_LB_VC0                           */
-/*   Description:  LB VC0 fifo underflow                                */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_LB_VC0_SHFT 10
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_LB_VC0_MASK 0x0000000000000400
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_LB_VC2                           */
-/*   Description:  LB VC2 fifo underflow                                */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_LB_VC2_SHFT 11
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_LB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC0_CREDIT_IN                  */
-/*   Description:  PI VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC0_CREDIT_IN_SHFT 12
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC0_CREDIT_IN_MASK 0x0000000000001000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_IN                */
-/*   Description:  IILB VC0 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_IN_SHFT 13
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_IN_MASK 0x0000000000002000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC0_CREDIT_IN                  */
-/*   Description:  MD VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC0_CREDIT_IN_SHFT 14
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC0_CREDIT_IN_MASK 0x0000000000004000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_IN                 */
-/*   Description:  NI0 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_IN_SHFT 15
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_IN_MASK 0x0000000000008000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_IN                 */
-/*   Description:  NI1 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_IN_SHFT 16
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_IN_MASK 0x0000000000010000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC2_CREDIT_IN                  */
-/*   Description:  PI VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC2_CREDIT_IN_SHFT 17
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC2_CREDIT_IN_MASK 0x0000000000020000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_IN                */
-/*   Description:  IILB VC2 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_IN_SHFT 18
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_IN_MASK 0x0000000000040000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC2_CREDIT_IN                  */
-/*   Description:  MD VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC2_CREDIT_IN_SHFT 19
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC2_CREDIT_IN_MASK 0x0000000000080000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_IN                 */
-/*   Description:  NI0 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_IN_SHFT 20
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_IN_MASK 0x0000000000100000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_IN                 */
-/*   Description:  NI1 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_IN_SHFT 21
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_IN_MASK 0x0000000000200000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC0_CREDIT_IN                 */
-/*   Description:  PI VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC0_CREDIT_IN_SHFT 22
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC0_CREDIT_IN_MASK 0x0000000000400000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_IN               */
-/*   Description:  IILB VC0 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_IN_SHFT 23
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_IN_MASK 0x0000000000800000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC0_CREDIT_IN                 */
-/*   Description:  MD VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC0_CREDIT_IN_SHFT 24
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC0_CREDIT_IN_MASK 0x0000000001000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_IN                */
-/*   Description:  NI0 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_IN_SHFT 25
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_IN_MASK 0x0000000002000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_IN                */
-/*   Description:  NI1 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_IN_SHFT 26
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_IN_MASK 0x0000000004000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC2_CREDIT_IN                 */
-/*   Description:  PI VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC2_CREDIT_IN_SHFT 27
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC2_CREDIT_IN_MASK 0x0000000008000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_IN               */
-/*   Description:  IILB VC2 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_IN_SHFT 28
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_IN_MASK 0x0000000010000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC2_CREDIT_IN                 */
-/*   Description:  MD VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC2_CREDIT_IN_SHFT 29
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC2_CREDIT_IN_MASK 0x0000000020000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_IN                */
-/*   Description:  NI0 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_IN_SHFT 30
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_IN_MASK 0x0000000040000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_IN                */
-/*   Description:  NI1 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_IN_SHFT 31
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_IN_MASK 0x0000000080000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_DEBIT0                         */
-/*   Description:  PI Fifo Debit0 overflow                              */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_DEBIT0_SHFT 32
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_DEBIT0_MASK 0x0000000100000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_DEBIT2                         */
-/*   Description:  PI Fifo Debit2 overflow                              */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_DEBIT2_SHFT 33
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_DEBIT2_MASK 0x0000000200000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0                       */
-/*   Description:  IILB Fifo Debit0 overflow                            */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0_SHFT 34
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0_MASK 0x0000000400000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2                       */
-/*   Description:  IILB Fifo Debit2 overflow                            */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2_SHFT 35
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2_MASK 0x0000000800000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_DEBIT0                         */
-/*   Description:  MD Fifo Debit0 overflow                              */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_DEBIT0_SHFT 36
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_DEBIT0_MASK 0x0000001000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_DEBIT2                         */
-/*   Description:  MD Fifo Debit2 overflow                              */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_DEBIT2_SHFT 37
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_DEBIT2_MASK 0x0000002000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0                        */
-/*   Description:  NI0 Fifo Debit0 overflow                             */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0_SHFT 38
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0_MASK 0x0000004000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2                        */
-/*   Description:  NI0 Fifo Debit2 overflow                             */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2_SHFT 39
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2_MASK 0x0000008000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0                        */
-/*   Description:  NI1 Fifo Debit0 overflow                             */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0_SHFT 40
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0_MASK 0x0000010000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2                        */
-/*   Description:  NI1 Fifo Debit2 overflow                             */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2_SHFT 41
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2_MASK 0x0000020000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC0_CREDIT_OUT                 */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC0_CREDIT_OUT_SHFT 42
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC0_CREDIT_OUT_MASK 0x0000040000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC2_CREDIT_OUT                 */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC2_CREDIT_OUT_SHFT 43
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_PI_VC2_CREDIT_OUT_MASK 0x0000080000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC0_CREDIT_OUT                 */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC0_CREDIT_OUT_SHFT 44
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC0_CREDIT_OUT_MASK 0x0000100000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC2_CREDIT_OUT                 */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC2_CREDIT_OUT_SHFT 45
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_MD_VC2_CREDIT_OUT_MASK 0x0000200000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_OUT               */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_OUT_SHFT 46
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_OUT_MASK 0x0000400000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_OUT               */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_OUT_SHFT 47
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_OUT_MASK 0x0000800000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_OUT                */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_OUT_SHFT 48
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_OUT_MASK 0x0001000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_OUT                */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_OUT_SHFT 49
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_OUT_MASK 0x0002000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_OUT                */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_OUT_SHFT 50
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_OUT_MASK 0x0004000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_OUT                */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_OUT_SHFT 51
-#define SH_XNIILB_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_OUT_MASK 0x0008000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC0_CREDIT_OUT                */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC0_CREDIT_OUT_SHFT 52
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC0_CREDIT_OUT_MASK 0x0010000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC2_CREDIT_OUT                */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC2_CREDIT_OUT_SHFT 53
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_PI_VC2_CREDIT_OUT_MASK 0x0020000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC0_CREDIT_OUT                */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC0_CREDIT_OUT_SHFT 54
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC0_CREDIT_OUT_MASK 0x0040000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC2_CREDIT_OUT                */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC2_CREDIT_OUT_SHFT 55
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_MD_VC2_CREDIT_OUT_MASK 0x0080000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_OUT              */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_OUT_SHFT 56
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_OUT_MASK 0x0100000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_OUT              */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_OUT_SHFT 57
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_OUT_MASK 0x0200000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_OUT               */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_OUT_SHFT 58
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_OUT_MASK 0x0400000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_OUT               */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_OUT_SHFT 59
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_OUT_MASK 0x0800000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_OUT               */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_OUT_SHFT 60
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_OUT_MASK 0x1000000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_OUT               */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_OUT_SHFT 61
-#define SH_XNIILB_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_OUT_MASK 0x2000000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_CHIPLET_NOMATCH                            */
-/*   Description:  chiplet nomatch                                      */
-#define SH_XNIILB_ERROR_SUMMARY_CHIPLET_NOMATCH_SHFT 62
-#define SH_XNIILB_ERROR_SUMMARY_CHIPLET_NOMATCH_MASK 0x4000000000000000
-
-/*   SH_XNIILB_ERROR_SUMMARY_LUT_READ_ERROR                             */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNIILB_ERROR_SUMMARY_LUT_READ_ERROR_SHFT 63
-#define SH_XNIILB_ERROR_SUMMARY_LUT_READ_ERROR_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_XNIILB_ERRORS_ALIAS"                   */
-/* ==================================================================== */
-
-#define SH_XNIILB_ERRORS_ALIAS                   0x0000000150040208
-
-/* ==================================================================== */
-/*                 Register "SH_XNIILB_ERROR_OVERFLOW"                  */
-/* ==================================================================== */
-
-#define SH_XNIILB_ERROR_OVERFLOW                 0x0000000150040220
-#define SH_XNIILB_ERROR_OVERFLOW_MASK            0xffffffffffffffff
-#define SH_XNIILB_ERROR_OVERFLOW_INIT            0xffffffffffffffff
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_DEBIT0                        */
-/*   Description:  II debit0 overflow                                   */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_DEBIT0_SHFT 0
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_DEBIT2                        */
-/*   Description:  II debit2 overflow                                   */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_DEBIT2_SHFT 1
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_DEBIT0                        */
-/*   Description:  LB debit0 overflow                                   */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_DEBIT0_SHFT 2
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_DEBIT2                        */
-/*   Description:  LB debit2 overflow                                   */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_DEBIT2_SHFT 3
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_VC0                           */
-/*   Description:  II VC0 fifo overflow                                 */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_VC0_SHFT 4
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_VC0_MASK 0x0000000000000010
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_VC2                           */
-/*   Description:  II VC2 fifo overflow                                 */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_VC2_SHFT 5
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_II_VC2_MASK 0x0000000000000020
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_II_VC0                          */
-/*   Description:  II VC0 fifo underflow                                */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_II_VC0_SHFT 6
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_II_VC0_MASK 0x0000000000000040
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_II_VC2                          */
-/*   Description:  II VC2 fifo underflow                                */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_II_VC2_SHFT 7
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_II_VC2_MASK 0x0000000000000080
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_VC0                           */
-/*   Description:  LB VC0 fifo overflow                                 */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_VC0_SHFT 8
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_VC2                           */
-/*   Description:  LB VC2 fifo overflow                                 */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_VC2_SHFT 9
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_LB_VC2_MASK 0x0000000000000200
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_LB_VC0                          */
-/*   Description:  LB VC0 fifo underflow                                */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_LB_VC0_SHFT 10
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_LB_VC0_MASK 0x0000000000000400
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_LB_VC2                          */
-/*   Description:  LB VC2 fifo underflow                                */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_LB_VC2_SHFT 11
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_LB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC0_CREDIT_IN                 */
-/*   Description:  PI VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC0_CREDIT_IN_SHFT 12
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC0_CREDIT_IN_MASK 0x0000000000001000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_IN               */
-/*   Description:  IILB VC0 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_IN_SHFT 13
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_IN_MASK 0x0000000000002000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC0_CREDIT_IN                 */
-/*   Description:  MD VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC0_CREDIT_IN_SHFT 14
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC0_CREDIT_IN_MASK 0x0000000000004000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_IN                */
-/*   Description:  NI0 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_IN_SHFT 15
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_IN_MASK 0x0000000000008000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_IN                */
-/*   Description:  NI1 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_IN_SHFT 16
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_IN_MASK 0x0000000000010000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC2_CREDIT_IN                 */
-/*   Description:  PI VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC2_CREDIT_IN_SHFT 17
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC2_CREDIT_IN_MASK 0x0000000000020000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_IN               */
-/*   Description:  IILB VC2 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_IN_SHFT 18
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_IN_MASK 0x0000000000040000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC2_CREDIT_IN                 */
-/*   Description:  MD VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC2_CREDIT_IN_SHFT 19
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC2_CREDIT_IN_MASK 0x0000000000080000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_IN                */
-/*   Description:  NI0 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_IN_SHFT 20
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_IN_MASK 0x0000000000100000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_IN                */
-/*   Description:  NI1 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_IN_SHFT 21
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_IN_MASK 0x0000000000200000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC0_CREDIT_IN                */
-/*   Description:  PI VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC0_CREDIT_IN_SHFT 22
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC0_CREDIT_IN_MASK 0x0000000000400000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_IN              */
-/*   Description:  IILB VC0 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_IN_SHFT 23
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_IN_MASK 0x0000000000800000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC0_CREDIT_IN                */
-/*   Description:  MD VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC0_CREDIT_IN_SHFT 24
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC0_CREDIT_IN_MASK 0x0000000001000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_IN               */
-/*   Description:  NI0 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_IN_SHFT 25
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_IN_MASK 0x0000000002000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_IN               */
-/*   Description:  NI1 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_IN_SHFT 26
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_IN_MASK 0x0000000004000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC2_CREDIT_IN                */
-/*   Description:  PI VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC2_CREDIT_IN_SHFT 27
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC2_CREDIT_IN_MASK 0x0000000008000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_IN              */
-/*   Description:  IILB VC2 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_IN_SHFT 28
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_IN_MASK 0x0000000010000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC2_CREDIT_IN                */
-/*   Description:  MD VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC2_CREDIT_IN_SHFT 29
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC2_CREDIT_IN_MASK 0x0000000020000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_IN               */
-/*   Description:  NI0 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_IN_SHFT 30
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_IN_MASK 0x0000000040000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_IN               */
-/*   Description:  NI1 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_IN_SHFT 31
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_IN_MASK 0x0000000080000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_DEBIT0                        */
-/*   Description:  PI Fifo Debit0 overflow                              */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_DEBIT0_SHFT 32
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_DEBIT0_MASK 0x0000000100000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_DEBIT2                        */
-/*   Description:  PI Fifo Debit2 overflow                              */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_DEBIT2_SHFT 33
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_DEBIT2_MASK 0x0000000200000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0                      */
-/*   Description:  IILB Fifo Debit0 overflow                            */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0_SHFT 34
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0_MASK 0x0000000400000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2                      */
-/*   Description:  IILB Fifo Debit2 overflow                            */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2_SHFT 35
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2_MASK 0x0000000800000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_DEBIT0                        */
-/*   Description:  MD Fifo Debit0 overflow                              */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_DEBIT0_SHFT 36
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_DEBIT0_MASK 0x0000001000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_DEBIT2                        */
-/*   Description:  MD Fifo Debit2 overflow                              */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_DEBIT2_SHFT 37
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_DEBIT2_MASK 0x0000002000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0                       */
-/*   Description:  NI0 Fifo Debit0 overflow                             */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0_SHFT 38
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0_MASK 0x0000004000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2                       */
-/*   Description:  NI0 Fifo Debit2 overflow                             */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2_SHFT 39
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2_MASK 0x0000008000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0                       */
-/*   Description:  NI1 Fifo Debit0 overflow                             */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0_SHFT 40
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0_MASK 0x0000010000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2                       */
-/*   Description:  NI1 Fifo Debit2 overflow                             */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2_SHFT 41
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2_MASK 0x0000020000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC0_CREDIT_OUT                */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC0_CREDIT_OUT_SHFT 42
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC0_CREDIT_OUT_MASK 0x0000040000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC2_CREDIT_OUT                */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC2_CREDIT_OUT_SHFT 43
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_PI_VC2_CREDIT_OUT_MASK 0x0000080000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC0_CREDIT_OUT                */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC0_CREDIT_OUT_SHFT 44
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC0_CREDIT_OUT_MASK 0x0000100000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC2_CREDIT_OUT                */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC2_CREDIT_OUT_SHFT 45
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_MD_VC2_CREDIT_OUT_MASK 0x0000200000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_OUT              */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_OUT_SHFT 46
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_OUT_MASK 0x0000400000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_OUT              */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_OUT_SHFT 47
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_OUT_MASK 0x0000800000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_OUT               */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_OUT_SHFT 48
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_OUT_MASK 0x0001000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_OUT               */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_OUT_SHFT 49
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_OUT_MASK 0x0002000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_OUT               */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_OUT_SHFT 50
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_OUT_MASK 0x0004000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_OUT               */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_OUT_SHFT 51
-#define SH_XNIILB_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_OUT_MASK 0x0008000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC0_CREDIT_OUT               */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC0_CREDIT_OUT_SHFT 52
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC0_CREDIT_OUT_MASK 0x0010000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC2_CREDIT_OUT               */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC2_CREDIT_OUT_SHFT 53
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_PI_VC2_CREDIT_OUT_MASK 0x0020000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC0_CREDIT_OUT               */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC0_CREDIT_OUT_SHFT 54
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC0_CREDIT_OUT_MASK 0x0040000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC2_CREDIT_OUT               */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC2_CREDIT_OUT_SHFT 55
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_MD_VC2_CREDIT_OUT_MASK 0x0080000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_OUT             */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_OUT_SHFT 56
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_OUT_MASK 0x0100000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_OUT             */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_OUT_SHFT 57
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_OUT_MASK 0x0200000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_OUT              */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_OUT_SHFT 58
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_OUT_MASK 0x0400000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_OUT              */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_OUT_SHFT 59
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_OUT_MASK 0x0800000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_OUT              */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_OUT_SHFT 60
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_OUT_MASK 0x1000000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_OUT              */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_OUT_SHFT 61
-#define SH_XNIILB_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_OUT_MASK 0x2000000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_CHIPLET_NOMATCH                           */
-/*   Description:  chiplet nomatch                                      */
-#define SH_XNIILB_ERROR_OVERFLOW_CHIPLET_NOMATCH_SHFT 62
-#define SH_XNIILB_ERROR_OVERFLOW_CHIPLET_NOMATCH_MASK 0x4000000000000000
-
-/*   SH_XNIILB_ERROR_OVERFLOW_LUT_READ_ERROR                            */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNIILB_ERROR_OVERFLOW_LUT_READ_ERROR_SHFT 63
-#define SH_XNIILB_ERROR_OVERFLOW_LUT_READ_ERROR_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*              Register "SH_XNIILB_ERROR_OVERFLOW_ALIAS"               */
-/* ==================================================================== */
-
-#define SH_XNIILB_ERROR_OVERFLOW_ALIAS           0x0000000150040228
-
-/* ==================================================================== */
-/*                   Register "SH_XNIILB_ERROR_MASK"                    */
-/* ==================================================================== */
-
-#define SH_XNIILB_ERROR_MASK                     0x0000000150040240
-#define SH_XNIILB_ERROR_MASK_MASK                0xffffffffffffffff
-#define SH_XNIILB_ERROR_MASK_INIT                0xffffffffffffffff
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_II_DEBIT0                            */
-/*   Description:  II debit0 overflow                                   */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_II_DEBIT0_SHFT 0
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_II_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_II_DEBIT2                            */
-/*   Description:  II debit2 overflow                                   */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_II_DEBIT2_SHFT 1
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_II_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_LB_DEBIT0                            */
-/*   Description:  LB debit0 overflow                                   */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_LB_DEBIT0_SHFT 2
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_LB_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_LB_DEBIT2                            */
-/*   Description:  LB debit2 overflow                                   */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_LB_DEBIT2_SHFT 3
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_LB_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_II_VC0                               */
-/*   Description:  II VC0 fifo overflow                                 */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_II_VC0_SHFT 4
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_II_VC0_MASK 0x0000000000000010
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_II_VC2                               */
-/*   Description:  II VC2 fifo overflow                                 */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_II_VC2_SHFT 5
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_II_VC2_MASK 0x0000000000000020
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_II_VC0                              */
-/*   Description:  II VC0 fifo underflow                                */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_II_VC0_SHFT 6
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_II_VC0_MASK 0x0000000000000040
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_II_VC2                              */
-/*   Description:  II VC2 fifo underflow                                */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_II_VC2_SHFT 7
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_II_VC2_MASK 0x0000000000000080
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_LB_VC0                               */
-/*   Description:  LB VC0 fifo overflow                                 */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_LB_VC0_SHFT 8
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_LB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_LB_VC2                               */
-/*   Description:  LB VC2 fifo overflow                                 */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_LB_VC2_SHFT 9
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_LB_VC2_MASK 0x0000000000000200
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_LB_VC0                              */
-/*   Description:  LB VC0 fifo underflow                                */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_LB_VC0_SHFT 10
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_LB_VC0_MASK 0x0000000000000400
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_LB_VC2                              */
-/*   Description:  LB VC2 fifo underflow                                */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_LB_VC2_SHFT 11
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_LB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC0_CREDIT_IN                     */
-/*   Description:  PI VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC0_CREDIT_IN_SHFT 12
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC0_CREDIT_IN_MASK 0x0000000000001000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_IN                   */
-/*   Description:  IILB VC0 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_IN_SHFT 13
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_IN_MASK 0x0000000000002000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC0_CREDIT_IN                     */
-/*   Description:  MD VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC0_CREDIT_IN_SHFT 14
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC0_CREDIT_IN_MASK 0x0000000000004000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_IN                    */
-/*   Description:  NI0 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_IN_SHFT 15
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_IN_MASK 0x0000000000008000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_IN                    */
-/*   Description:  NI1 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_IN_SHFT 16
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_IN_MASK 0x0000000000010000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC2_CREDIT_IN                     */
-/*   Description:  PI VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC2_CREDIT_IN_SHFT 17
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC2_CREDIT_IN_MASK 0x0000000000020000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_IN                   */
-/*   Description:  IILB VC2 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_IN_SHFT 18
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_IN_MASK 0x0000000000040000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC2_CREDIT_IN                     */
-/*   Description:  MD VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC2_CREDIT_IN_SHFT 19
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC2_CREDIT_IN_MASK 0x0000000000080000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_IN                    */
-/*   Description:  NI0 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_IN_SHFT 20
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_IN_MASK 0x0000000000100000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_IN                    */
-/*   Description:  NI1 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_IN_SHFT 21
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_IN_MASK 0x0000000000200000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC0_CREDIT_IN                    */
-/*   Description:  PI VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC0_CREDIT_IN_SHFT 22
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC0_CREDIT_IN_MASK 0x0000000000400000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_IN                  */
-/*   Description:  IILB VC0 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_IN_SHFT 23
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_IN_MASK 0x0000000000800000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC0_CREDIT_IN                    */
-/*   Description:  MD VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC0_CREDIT_IN_SHFT 24
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC0_CREDIT_IN_MASK 0x0000000001000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_IN                   */
-/*   Description:  NI0 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_IN_SHFT 25
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_IN_MASK 0x0000000002000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_IN                   */
-/*   Description:  NI1 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_IN_SHFT 26
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_IN_MASK 0x0000000004000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC2_CREDIT_IN                    */
-/*   Description:  PI VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC2_CREDIT_IN_SHFT 27
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC2_CREDIT_IN_MASK 0x0000000008000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_IN                  */
-/*   Description:  IILB VC2 credit overflow Pipe In                     */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_IN_SHFT 28
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_IN_MASK 0x0000000010000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC2_CREDIT_IN                    */
-/*   Description:  MD VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC2_CREDIT_IN_SHFT 29
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC2_CREDIT_IN_MASK 0x0000000020000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_IN                   */
-/*   Description:  NI0 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_IN_SHFT 30
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_IN_MASK 0x0000000040000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_IN                   */
-/*   Description:  NI1 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_IN_SHFT 31
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_IN_MASK 0x0000000080000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_PI_DEBIT0                            */
-/*   Description:  PI Fifo Debit0 overflow                              */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_DEBIT0_SHFT 32
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_DEBIT0_MASK 0x0000000100000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_PI_DEBIT2                            */
-/*   Description:  PI Fifo Debit2 overflow                              */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_DEBIT2_SHFT 33
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_DEBIT2_MASK 0x0000000200000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_DEBIT0                          */
-/*   Description:  IILB Fifo Debit0 overflow                            */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_DEBIT0_SHFT 34
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_DEBIT0_MASK 0x0000000400000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_DEBIT2                          */
-/*   Description:  IILB Fifo Debit2 overflow                            */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_DEBIT2_SHFT 35
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_DEBIT2_MASK 0x0000000800000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_MD_DEBIT0                            */
-/*   Description:  MD Fifo Debit0 overflow                              */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_DEBIT0_SHFT 36
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_DEBIT0_MASK 0x0000001000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_MD_DEBIT2                            */
-/*   Description:  MD Fifo Debit2 overflow                              */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_DEBIT2_SHFT 37
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_DEBIT2_MASK 0x0000002000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_DEBIT0                           */
-/*   Description:  NI0 Fifo Debit0 overflow                             */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_DEBIT0_SHFT 38
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_DEBIT0_MASK 0x0000004000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_DEBIT2                           */
-/*   Description:  NI0 Fifo Debit2 overflow                             */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_DEBIT2_SHFT 39
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_DEBIT2_MASK 0x0000008000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_DEBIT0                           */
-/*   Description:  NI1 Fifo Debit0 overflow                             */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_DEBIT0_SHFT 40
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_DEBIT0_MASK 0x0000010000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_DEBIT2                           */
-/*   Description:  NI1 Fifo Debit2 overflow                             */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_DEBIT2_SHFT 41
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_DEBIT2_MASK 0x0000020000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC0_CREDIT_OUT                    */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC0_CREDIT_OUT_SHFT 42
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC0_CREDIT_OUT_MASK 0x0000040000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC2_CREDIT_OUT                    */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC2_CREDIT_OUT_SHFT 43
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_PI_VC2_CREDIT_OUT_MASK 0x0000080000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC0_CREDIT_OUT                    */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC0_CREDIT_OUT_SHFT 44
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC0_CREDIT_OUT_MASK 0x0000100000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC2_CREDIT_OUT                    */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC2_CREDIT_OUT_SHFT 45
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_MD_VC2_CREDIT_OUT_MASK 0x0000200000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_OUT                  */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_OUT_SHFT 46
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_OUT_MASK 0x0000400000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_OUT                  */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_OUT_SHFT 47
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_OUT_MASK 0x0000800000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_OUT                   */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_OUT_SHFT 48
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_OUT_MASK 0x0001000000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_OUT                   */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_OUT_SHFT 49
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_OUT_MASK 0x0002000000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_OUT                   */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_OUT_SHFT 50
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_OUT_MASK 0x0004000000000000
-
-/*   SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_OUT                   */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_OUT_SHFT 51
-#define SH_XNIILB_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_OUT_MASK 0x0008000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC0_CREDIT_OUT                   */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC0_CREDIT_OUT_SHFT 52
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC0_CREDIT_OUT_MASK 0x0010000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC2_CREDIT_OUT                   */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC2_CREDIT_OUT_SHFT 53
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_PI_VC2_CREDIT_OUT_MASK 0x0020000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC0_CREDIT_OUT                   */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC0_CREDIT_OUT_SHFT 54
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC0_CREDIT_OUT_MASK 0x0040000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC2_CREDIT_OUT                   */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC2_CREDIT_OUT_SHFT 55
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_MD_VC2_CREDIT_OUT_MASK 0x0080000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_OUT                 */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_OUT_SHFT 56
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_OUT_MASK 0x0100000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_OUT                 */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_OUT_SHFT 57
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_OUT_MASK 0x0200000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_OUT                  */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_OUT_SHFT 58
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_OUT_MASK 0x0400000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_OUT                  */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_OUT_SHFT 59
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_OUT_MASK 0x0800000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_OUT                  */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_OUT_SHFT 60
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_OUT_MASK 0x1000000000000000
-
-/*   SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_OUT                  */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_OUT_SHFT 61
-#define SH_XNIILB_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_OUT_MASK 0x2000000000000000
-
-/*   SH_XNIILB_ERROR_MASK_CHIPLET_NOMATCH                               */
-/*   Description:  chiplet nomatch                                      */
-#define SH_XNIILB_ERROR_MASK_CHIPLET_NOMATCH_SHFT 62
-#define SH_XNIILB_ERROR_MASK_CHIPLET_NOMATCH_MASK 0x4000000000000000
-
-/*   SH_XNIILB_ERROR_MASK_LUT_READ_ERROR                                */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNIILB_ERROR_MASK_LUT_READ_ERROR_SHFT 63
-#define SH_XNIILB_ERROR_MASK_LUT_READ_ERROR_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNIILB_FIRST_ERROR"                   */
-/* ==================================================================== */
-
-#define SH_XNIILB_FIRST_ERROR                    0x0000000150040260
-#define SH_XNIILB_FIRST_ERROR_MASK               0xffffffffffffffff
-#define SH_XNIILB_FIRST_ERROR_INIT               0xffffffffffffffff
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_II_DEBIT0                           */
-/*   Description:  II debit0 overflow                                   */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_II_DEBIT0_SHFT 0
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_II_DEBIT0_MASK 0x0000000000000001
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_II_DEBIT2                           */
-/*   Description:  II debit2 overflow                                   */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_II_DEBIT2_SHFT 1
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_II_DEBIT2_MASK 0x0000000000000002
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_DEBIT0                           */
-/*   Description:  LB debit0 overflow                                   */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_DEBIT0_SHFT 2
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_DEBIT0_MASK 0x0000000000000004
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_DEBIT2                           */
-/*   Description:  LB debit2 overflow                                   */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_DEBIT2_SHFT 3
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_DEBIT2_MASK 0x0000000000000008
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_II_VC0                              */
-/*   Description:  II VC0 fifo overflow                                 */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_II_VC0_SHFT 4
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_II_VC0_MASK 0x0000000000000010
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_II_VC2                              */
-/*   Description:  II VC2 fifo overflow                                 */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_II_VC2_SHFT 5
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_II_VC2_MASK 0x0000000000000020
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_II_VC0                             */
-/*   Description:  II VC0 fifo underflow                                */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_II_VC0_SHFT 6
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_II_VC0_MASK 0x0000000000000040
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_II_VC2                             */
-/*   Description:  II VC2 fifo underflow                                */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_II_VC2_SHFT 7
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_II_VC2_MASK 0x0000000000000080
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_VC0                              */
-/*   Description:  LB VC0 fifo overflow                                 */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_VC0_SHFT 8
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_VC2                              */
-/*   Description:  LB VC2 fifo overflow                                 */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_VC2_SHFT 9
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_LB_VC2_MASK 0x0000000000000200
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_LB_VC0                             */
-/*   Description:  LB VC0 fifo underflow                                */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_LB_VC0_SHFT 10
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_LB_VC0_MASK 0x0000000000000400
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_LB_VC2                             */
-/*   Description:  LB VC2 fifo underflow                                */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_LB_VC2_SHFT 11
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_LB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC0_CREDIT_IN                    */
-/*   Description:  PI VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC0_CREDIT_IN_SHFT 12
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC0_CREDIT_IN_MASK 0x0000000000001000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_IN                  */
-/*   Description:  IILB VC0 credit overflow Pipe In                     */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_IN_SHFT 13
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_IN_MASK 0x0000000000002000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC0_CREDIT_IN                    */
-/*   Description:  MD VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC0_CREDIT_IN_SHFT 14
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC0_CREDIT_IN_MASK 0x0000000000004000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_IN                   */
-/*   Description:  NI0 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_IN_SHFT 15
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_IN_MASK 0x0000000000008000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_IN                   */
-/*   Description:  NI1 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_IN_SHFT 16
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_IN_MASK 0x0000000000010000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC2_CREDIT_IN                    */
-/*   Description:  PI VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC2_CREDIT_IN_SHFT 17
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC2_CREDIT_IN_MASK 0x0000000000020000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_IN                  */
-/*   Description:  IILB VC2 credit overflow Pipe In                     */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_IN_SHFT 18
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_IN_MASK 0x0000000000040000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC2_CREDIT_IN                    */
-/*   Description:  MD VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC2_CREDIT_IN_SHFT 19
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC2_CREDIT_IN_MASK 0x0000000000080000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_IN                   */
-/*   Description:  NI0 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_IN_SHFT 20
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_IN_MASK 0x0000000000100000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_IN                   */
-/*   Description:  NI1 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_IN_SHFT 21
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_IN_MASK 0x0000000000200000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC0_CREDIT_IN                   */
-/*   Description:  PI VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC0_CREDIT_IN_SHFT 22
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC0_CREDIT_IN_MASK 0x0000000000400000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_IN                 */
-/*   Description:  IILB VC0 credit overflow Pipe In                     */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_IN_SHFT 23
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_IN_MASK 0x0000000000800000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC0_CREDIT_IN                   */
-/*   Description:  MD VC0 credit overflow Pipe In                       */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC0_CREDIT_IN_SHFT 24
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC0_CREDIT_IN_MASK 0x0000000001000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_IN                  */
-/*   Description:  NI0 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_IN_SHFT 25
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_IN_MASK 0x0000000002000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_IN                  */
-/*   Description:  NI1 VC0 credit overflow Pipe In                      */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_IN_SHFT 26
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_IN_MASK 0x0000000004000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC2_CREDIT_IN                   */
-/*   Description:  PI VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC2_CREDIT_IN_SHFT 27
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC2_CREDIT_IN_MASK 0x0000000008000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_IN                 */
-/*   Description:  IILB VC2 credit overflow Pipe In                     */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_IN_SHFT 28
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_IN_MASK 0x0000000010000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC2_CREDIT_IN                   */
-/*   Description:  MD VC2 credit overflow Pipe In                       */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC2_CREDIT_IN_SHFT 29
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC2_CREDIT_IN_MASK 0x0000000020000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_IN                  */
-/*   Description:  NI0 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_IN_SHFT 30
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_IN_MASK 0x0000000040000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_IN                  */
-/*   Description:  NI1 VC2 credit overflow Pipe In                      */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_IN_SHFT 31
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_IN_MASK 0x0000000080000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_DEBIT0                           */
-/*   Description:  PI Fifo Debit0 overflow                              */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_DEBIT0_SHFT 32
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_DEBIT0_MASK 0x0000000100000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_DEBIT2                           */
-/*   Description:  PI Fifo Debit2 overflow                              */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_DEBIT2_SHFT 33
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_DEBIT2_MASK 0x0000000200000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_DEBIT0                         */
-/*   Description:  IILB Fifo Debit0 overflow                            */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_DEBIT0_SHFT 34
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_DEBIT0_MASK 0x0000000400000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_DEBIT2                         */
-/*   Description:  IILB Fifo Debit2 overflow                            */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_DEBIT2_SHFT 35
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_DEBIT2_MASK 0x0000000800000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_DEBIT0                           */
-/*   Description:  MD Fifo Debit0 overflow                              */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_DEBIT0_SHFT 36
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_DEBIT0_MASK 0x0000001000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_DEBIT2                           */
-/*   Description:  MD Fifo Debit2 overflow                              */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_DEBIT2_SHFT 37
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_DEBIT2_MASK 0x0000002000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_DEBIT0                          */
-/*   Description:  NI0 Fifo Debit0 overflow                             */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_DEBIT0_SHFT 38
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_DEBIT0_MASK 0x0000004000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_DEBIT2                          */
-/*   Description:  NI0 Fifo Debit2 overflow                             */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_DEBIT2_SHFT 39
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_DEBIT2_MASK 0x0000008000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_DEBIT0                          */
-/*   Description:  NI1 Fifo Debit0 overflow                             */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_DEBIT0_SHFT 40
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_DEBIT0_MASK 0x0000010000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_DEBIT2                          */
-/*   Description:  NI1 Fifo Debit2 overflow                             */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_DEBIT2_SHFT 41
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_DEBIT2_MASK 0x0000020000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC0_CREDIT_OUT                   */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC0_CREDIT_OUT_SHFT 42
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC0_CREDIT_OUT_MASK 0x0000040000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC2_CREDIT_OUT                   */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC2_CREDIT_OUT_SHFT 43
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_PI_VC2_CREDIT_OUT_MASK 0x0000080000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC0_CREDIT_OUT                   */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC0_CREDIT_OUT_SHFT 44
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC0_CREDIT_OUT_MASK 0x0000100000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC2_CREDIT_OUT                   */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC2_CREDIT_OUT_SHFT 45
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_MD_VC2_CREDIT_OUT_MASK 0x0000200000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_OUT                 */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_OUT_SHFT 46
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_OUT_MASK 0x0000400000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_OUT                 */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_OUT_SHFT 47
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_OUT_MASK 0x0000800000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_OUT                  */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_OUT_SHFT 48
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_OUT_MASK 0x0001000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_OUT                  */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_OUT_SHFT 49
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_OUT_MASK 0x0002000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_OUT                  */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_OUT_SHFT 50
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_OUT_MASK 0x0004000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_OUT                  */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_OUT_SHFT 51
-#define SH_XNIILB_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_OUT_MASK 0x0008000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC0_CREDIT_OUT                  */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC0_CREDIT_OUT_SHFT 52
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC0_CREDIT_OUT_MASK 0x0010000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC2_CREDIT_OUT                  */
-/*   Description:  PI VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC2_CREDIT_OUT_SHFT 53
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_PI_VC2_CREDIT_OUT_MASK 0x0020000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC0_CREDIT_OUT                  */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC0_CREDIT_OUT_SHFT 54
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC0_CREDIT_OUT_MASK 0x0040000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC2_CREDIT_OUT                  */
-/*   Description:  MD VC0 Credit overflow Pipe Out                      */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC2_CREDIT_OUT_SHFT 55
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_MD_VC2_CREDIT_OUT_MASK 0x0080000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_OUT                */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_OUT_SHFT 56
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_OUT_MASK 0x0100000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_OUT                */
-/*   Description:  IILB VC0 Credit overflow Pipe Out                    */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_OUT_SHFT 57
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_OUT_MASK 0x0200000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_OUT                 */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_OUT_SHFT 58
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_OUT_MASK 0x0400000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_OUT                 */
-/*   Description:  NI0 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_OUT_SHFT 59
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_OUT_MASK 0x0800000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_OUT                 */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_OUT_SHFT 60
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_OUT_MASK 0x1000000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_OUT                 */
-/*   Description:  NI1 VC0 Credit overflow Pipe Out                     */
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_OUT_SHFT 61
-#define SH_XNIILB_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_OUT_MASK 0x2000000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_CHIPLET_NOMATCH                              */
-/*   Description:  chiplet nomatch                                      */
-#define SH_XNIILB_FIRST_ERROR_CHIPLET_NOMATCH_SHFT 62
-#define SH_XNIILB_FIRST_ERROR_CHIPLET_NOMATCH_MASK 0x4000000000000000
-
-/*   SH_XNIILB_FIRST_ERROR_LUT_READ_ERROR                               */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNIILB_FIRST_ERROR_LUT_READ_ERROR_SHFT 63
-#define SH_XNIILB_FIRST_ERROR_LUT_READ_ERROR_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNPI_ERROR_SUMMARY"                   */
-/* ==================================================================== */
-
-#define SH_XNPI_ERROR_SUMMARY                    0x0000000150040300
-#define SH_XNPI_ERROR_SUMMARY_MASK               0x0003ffffffffffff
-#define SH_XNPI_ERROR_SUMMARY_INIT               0x0003ffffffffffff
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC0                            */
-/*   Description:  NI0 VC0 fifo underflow                               */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_SHFT 0
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_MASK 0x0000000000000001
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC0                             */
-/*   Description:  NI0 VC0 fifo overflow                                */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC0_SHFT 1
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC0_MASK 0x0000000000000002
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC2                            */
-/*   Description:  NI0 VC2 fifo underflow                               */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_SHFT 2
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_MASK 0x0000000000000004
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC2                             */
-/*   Description:  NI0 VC2 fifo overflow                                */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC2_SHFT 3
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC2_MASK 0x0000000000000008
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC0                            */
-/*   Description:  NI1 VC0 fifo underflow                               */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_SHFT 4
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_MASK 0x0000000000000010
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC0                             */
-/*   Description:  NI1 VC0 fifo overflow                                */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC0_SHFT 5
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC0_MASK 0x0000000000000020
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC2                            */
-/*   Description:  NI1 VC2 fifo underflow                               */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_SHFT 6
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_MASK 0x0000000000000040
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC2                             */
-/*   Description:  NI1 VC2 fifo overflow                                */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC2_SHFT 7
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC2_MASK 0x0000000000000080
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC0                           */
-/*   Description:  IILB VC0 fifo underflow                              */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_SHFT 8
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC0                            */
-/*   Description:  IILB VC0 fifo overflow                               */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC0_SHFT 9
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC0_MASK 0x0000000000000200
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC2                           */
-/*   Description:  IILB VC2 fifo underflow                              */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_SHFT 10
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_MASK 0x0000000000000400
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC2                            */
-/*   Description:  IILB VC2 fifo overflow                               */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC2_SHFT 11
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_VC0_CREDIT                         */
-/*   Description:  VC0 Credit underflow                                 */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_VC0_CREDIT_SHFT 12
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_VC0_CREDIT                          */
-/*   Description:  VC0 Credit overflow                                  */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_VC0_CREDIT_SHFT 13
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_VC0_CREDIT_MASK 0x0000000000002000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_VC2_CREDIT                         */
-/*   Description:  VC2 Credit underflow                                 */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_VC2_CREDIT_SHFT 14
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_VC2_CREDIT_MASK 0x0000000000004000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_VC2_CREDIT                          */
-/*   Description:  VC2 Credit overflow                                  */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_VC2_CREDIT_SHFT 15
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC0                        */
-/*   Description:  VC0 Data Buffer overflow                             */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC0_SHFT 16
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC0_MASK 0x0000000000010000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC2                        */
-/*   Description:  VC2 Data Buffer overflow                             */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC2_SHFT 17
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC2_MASK 0x0000000000020000
-
-/*   SH_XNPI_ERROR_SUMMARY_LUT_READ_ERROR                               */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNPI_ERROR_SUMMARY_LUT_READ_ERROR_SHFT 18
-#define SH_XNPI_ERROR_SUMMARY_LUT_READ_ERROR_MASK 0x0000000000040000
-
-/*   SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR0                            */
-/*   Description:  Single Bit Error in Bits 63:0                        */
-#define SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR0_SHFT 19
-#define SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR0_MASK 0x0000000000080000
-
-/*   SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR1                            */
-/*   Description:  Single Bit Error in Bits 127:64                      */
-#define SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR1_SHFT 20
-#define SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR1_MASK 0x0000000000100000
-
-/*   SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR2                            */
-/*   Description:  Single Bit Error in Bits 191:128                     */
-#define SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR2_SHFT 21
-#define SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR2_MASK 0x0000000000200000
-
-/*   SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR3                            */
-/*   Description:  Single Bit Error in Bits 255:192                     */
-#define SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR3_SHFT 22
-#define SH_XNPI_ERROR_SUMMARY_SINGLE_BIT_ERROR3_MASK 0x0000000000400000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR0                                 */
-/*   Description:  Uncorrectable Error in Bits 63:0                     */
-#define SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR0_SHFT  23
-#define SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR0_MASK  0x0000000000800000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR1                                 */
-/*   Description:  Uncorrectable Error in Bits 127:64                   */
-#define SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR1_SHFT  24
-#define SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR1_MASK  0x0000000001000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR2                                 */
-/*   Description:  Uncorrectable Error in Bits 191:128                  */
-#define SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR2_SHFT  25
-#define SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR2_MASK  0x0000000002000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR3                                 */
-/*   Description:  Uncorrectable Error in Bits 255:192                  */
-#define SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR3_SHFT  26
-#define SH_XNPI_ERROR_SUMMARY_UNCOR_ERROR3_MASK  0x0000000004000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR0                          */
-/*   Description:  SIC Counter 0 Underflow                              */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR0_SHFT 27
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR0_MASK 0x0000000008000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_SIC_CNTR0                           */
-/*   Description:  SIC Counter 0 Overflow                               */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_SIC_CNTR0_SHFT 28
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_SIC_CNTR0_MASK 0x0000000010000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR2                          */
-/*   Description:  SIC Counter 2 Underflow                              */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR2_SHFT 29
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR2_MASK 0x0000000020000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_SIC_CNTR2                           */
-/*   Description:  SIC Counter 2 Overflow                               */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_SIC_CNTR2_SHFT 30
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_SIC_CNTR2_MASK 0x0000000040000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0                          */
-/*   Description:  NI0 Debit 0 Overflow                                 */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0_SHFT 31
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0_MASK 0x0000000080000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2                          */
-/*   Description:  NI0 Debit 2 Overflow                                 */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2_SHFT 32
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2_MASK 0x0000000100000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0                          */
-/*   Description:  NI1 Debit 0 Overflow                                 */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0_SHFT 33
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0_MASK 0x0000000200000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2                          */
-/*   Description:  NI1 Debit 2 Overflow                                 */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2_SHFT 34
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2_MASK 0x0000000400000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0                         */
-/*   Description:  IILB Debit 0 Overflow                                */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0_SHFT 35
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0_MASK 0x0000000800000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2                         */
-/*   Description:  IILB Debit 2 Overflow                                */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2_SHFT 36
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2_MASK 0x0000001000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT                     */
-/*   Description:  NI0 VC0 Credit Underflow                             */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_SHFT 37
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_MASK 0x0000002000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT                      */
-/*   Description:  NI0 VC0 Credit Overflow                              */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_SHFT 38
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_MASK 0x0000004000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT                     */
-/*   Description:  NI0 VC2 Credit Underflow                             */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_SHFT 39
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_MASK 0x0000008000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT                      */
-/*   Description:  NI0 VC2 Credit Overflow                              */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_SHFT 40
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_MASK 0x0000010000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT                     */
-/*   Description:  NI1 VC0 Credit Underflow                             */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_SHFT 41
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_MASK 0x0000020000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT                      */
-/*   Description:  NI1 VC0 Credit Overflow                              */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_SHFT 42
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_MASK 0x0000040000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT                     */
-/*   Description:  NI1 VC2 Credit Underflow                             */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_SHFT 43
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_MASK 0x0000080000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT                      */
-/*   Description:  NI1 VC2 Credit Overflow                              */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_SHFT 44
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_MASK 0x0000100000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT                    */
-/*   Description:  IILB VC0 Credit Underflow                            */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_SHFT 45
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_MASK 0x0000200000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT                     */
-/*   Description:  IILB VC0 Credit Overflow                             */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_SHFT 46
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT                    */
-/*   Description:  IILB VC2 Credit Underflow                            */
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_SHFT 47
-#define SH_XNPI_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT                     */
-/*   Description:  IILB VC2 Credit Overflow                             */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_SHFT 48
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_MASK 0x0001000000000000
-
-/*   SH_XNPI_ERROR_SUMMARY_OVERFLOW_HEADER_CANCEL_FIFO                  */
-/*   Description:  Header Cancel Fifo Overflow                          */
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_HEADER_CANCEL_FIFO_SHFT 49
-#define SH_XNPI_ERROR_SUMMARY_OVERFLOW_HEADER_CANCEL_FIFO_MASK 0x0002000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNPI_ERRORS_ALIAS"                    */
-/* ==================================================================== */
-
-#define SH_XNPI_ERRORS_ALIAS                     0x0000000150040308
-
-/* ==================================================================== */
-/*                  Register "SH_XNPI_ERROR_OVERFLOW"                   */
-/* ==================================================================== */
-
-#define SH_XNPI_ERROR_OVERFLOW                   0x0000000150040320
-#define SH_XNPI_ERROR_OVERFLOW_MASK              0x0003ffffffffffff
-#define SH_XNPI_ERROR_OVERFLOW_INIT              0x0003ffffffffffff
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0                           */
-/*   Description:  NI0 VC0 fifo underflow                               */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_SHFT 0
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_MASK 0x0000000000000001
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC0                            */
-/*   Description:  NI0 VC0 fifo overflow                                */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_SHFT 1
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_MASK 0x0000000000000002
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2                           */
-/*   Description:  NI0 VC2 fifo underflow                               */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_SHFT 2
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_MASK 0x0000000000000004
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC2                            */
-/*   Description:  NI0 VC2 fifo overflow                                */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_SHFT 3
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_MASK 0x0000000000000008
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0                           */
-/*   Description:  NI1 VC0 fifo underflow                               */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_SHFT 4
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_MASK 0x0000000000000010
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC0                            */
-/*   Description:  NI1 VC0 fifo overflow                                */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_SHFT 5
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_MASK 0x0000000000000020
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2                           */
-/*   Description:  NI1 VC2 fifo underflow                               */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_SHFT 6
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_MASK 0x0000000000000040
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC2                            */
-/*   Description:  NI1 VC2 fifo overflow                                */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_SHFT 7
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_MASK 0x0000000000000080
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0                          */
-/*   Description:  IILB VC0 fifo underflow                              */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_SHFT 8
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC0                           */
-/*   Description:  IILB VC0 fifo overflow                               */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_SHFT 9
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_MASK 0x0000000000000200
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2                          */
-/*   Description:  IILB VC2 fifo underflow                              */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_SHFT 10
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_MASK 0x0000000000000400
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC2                           */
-/*   Description:  IILB VC2 fifo overflow                               */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_SHFT 11
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_VC0_CREDIT                        */
-/*   Description:  VC0 Credit underflow                                 */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_VC0_CREDIT_SHFT 12
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_VC0_CREDIT                         */
-/*   Description:  VC0 Credit overflow                                  */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_VC0_CREDIT_SHFT 13
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_VC0_CREDIT_MASK 0x0000000000002000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_VC2_CREDIT                        */
-/*   Description:  VC2 Credit underflow                                 */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_VC2_CREDIT_SHFT 14
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_VC2_CREDIT_MASK 0x0000000000004000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_VC2_CREDIT                         */
-/*   Description:  VC2 Credit overflow                                  */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_VC2_CREDIT_SHFT 15
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC0                       */
-/*   Description:  VC0 Data Buffer overflow                             */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC0_SHFT 16
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC0_MASK 0x0000000000010000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC2                       */
-/*   Description:  VC2 Data Buffer overflow                             */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC2_SHFT 17
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC2_MASK 0x0000000000020000
-
-/*   SH_XNPI_ERROR_OVERFLOW_LUT_READ_ERROR                              */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNPI_ERROR_OVERFLOW_LUT_READ_ERROR_SHFT 18
-#define SH_XNPI_ERROR_OVERFLOW_LUT_READ_ERROR_MASK 0x0000000000040000
-
-/*   SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR0                           */
-/*   Description:  Single Bit Error in Bits 63:0                        */
-#define SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR0_SHFT 19
-#define SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR0_MASK 0x0000000000080000
-
-/*   SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR1                           */
-/*   Description:  Single Bit Error in Bits 127:64                      */
-#define SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR1_SHFT 20
-#define SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR1_MASK 0x0000000000100000
-
-/*   SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR2                           */
-/*   Description:  Single Bit Error in Bits 191:128                     */
-#define SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR2_SHFT 21
-#define SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR2_MASK 0x0000000000200000
-
-/*   SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR3                           */
-/*   Description:  Single Bit Error in Bits 255:192                     */
-#define SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR3_SHFT 22
-#define SH_XNPI_ERROR_OVERFLOW_SINGLE_BIT_ERROR3_MASK 0x0000000000400000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR0                                */
-/*   Description:  Uncorrectable Error in Bits 63:0                     */
-#define SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR0_SHFT 23
-#define SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR0_MASK 0x0000000000800000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR1                                */
-/*   Description:  Uncorrectable Error in Bits 127:64                   */
-#define SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR1_SHFT 24
-#define SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR1_MASK 0x0000000001000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR2                                */
-/*   Description:  Uncorrectable Error in Bits 191:128                  */
-#define SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR2_SHFT 25
-#define SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR2_MASK 0x0000000002000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR3                                */
-/*   Description:  Uncorrectable Error in Bits 255:192                  */
-#define SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR3_SHFT 26
-#define SH_XNPI_ERROR_OVERFLOW_UNCOR_ERROR3_MASK 0x0000000004000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR0                         */
-/*   Description:  SIC Counter 0 Underflow                              */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR0_SHFT 27
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR0_MASK 0x0000000008000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR0                          */
-/*   Description:  SIC Counter 0 Overflow                               */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR0_SHFT 28
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR0_MASK 0x0000000010000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR2                         */
-/*   Description:  SIC Counter 2 Underflow                              */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR2_SHFT 29
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR2_MASK 0x0000000020000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR2                          */
-/*   Description:  SIC Counter 2 Overflow                               */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR2_SHFT 30
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR2_MASK 0x0000000040000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0                         */
-/*   Description:  NI0 Debit 0 Overflow                                 */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0_SHFT 31
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0_MASK 0x0000000080000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2                         */
-/*   Description:  NI0 Debit 2 Overflow                                 */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2_SHFT 32
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2_MASK 0x0000000100000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0                         */
-/*   Description:  NI1 Debit 0 Overflow                                 */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0_SHFT 33
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0_MASK 0x0000000200000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2                         */
-/*   Description:  NI1 Debit 2 Overflow                                 */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2_SHFT 34
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2_MASK 0x0000000400000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0                        */
-/*   Description:  IILB Debit 0 Overflow                                */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0_SHFT 35
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0_MASK 0x0000000800000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2                        */
-/*   Description:  IILB Debit 2 Overflow                                */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2_SHFT 36
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2_MASK 0x0000001000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT                    */
-/*   Description:  NI0 VC0 Credit Underflow                             */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_SHFT 37
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_MASK 0x0000002000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT                     */
-/*   Description:  NI0 VC0 Credit Overflow                              */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_SHFT 38
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_MASK 0x0000004000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT                    */
-/*   Description:  NI0 VC2 Credit Underflow                             */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_SHFT 39
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_MASK 0x0000008000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT                     */
-/*   Description:  NI0 VC2 Credit Overflow                              */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_SHFT 40
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_MASK 0x0000010000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT                    */
-/*   Description:  NI1 VC0 Credit Underflow                             */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_SHFT 41
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_MASK 0x0000020000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT                     */
-/*   Description:  NI1 VC0 Credit Overflow                              */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_SHFT 42
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_MASK 0x0000040000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT                    */
-/*   Description:  NI1 VC2 Credit Underflow                             */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_SHFT 43
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_MASK 0x0000080000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT                     */
-/*   Description:  NI1 VC2 Credit Overflow                              */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_SHFT 44
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_MASK 0x0000100000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT                   */
-/*   Description:  IILB VC0 Credit Underflow                            */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_SHFT 45
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_MASK 0x0000200000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT                    */
-/*   Description:  IILB VC0 Credit Overflow                             */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_SHFT 46
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT                   */
-/*   Description:  IILB VC2 Credit Underflow                            */
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_SHFT 47
-#define SH_XNPI_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT                    */
-/*   Description:  IILB VC2 Credit Overflow                             */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_SHFT 48
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_MASK 0x0001000000000000
-
-/*   SH_XNPI_ERROR_OVERFLOW_OVERFLOW_HEADER_CANCEL_FIFO                 */
-/*   Description:  Header Cancel Fifo Overflow                          */
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_HEADER_CANCEL_FIFO_SHFT 49
-#define SH_XNPI_ERROR_OVERFLOW_OVERFLOW_HEADER_CANCEL_FIFO_MASK 0x0002000000000000
-
-/* ==================================================================== */
-/*               Register "SH_XNPI_ERROR_OVERFLOW_ALIAS"                */
-/* ==================================================================== */
-
-#define SH_XNPI_ERROR_OVERFLOW_ALIAS             0x0000000150040328
-
-/* ==================================================================== */
-/*                    Register "SH_XNPI_ERROR_MASK"                     */
-/* ==================================================================== */
-
-#define SH_XNPI_ERROR_MASK                       0x0000000150040340
-#define SH_XNPI_ERROR_MASK_MASK                  0x0003ffffffffffff
-#define SH_XNPI_ERROR_MASK_INIT                  0x0003ffffffffffff
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC0                               */
-/*   Description:  NI0 VC0 fifo underflow                               */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC0_SHFT 0
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC0_MASK 0x0000000000000001
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC0                                */
-/*   Description:  NI0 VC0 fifo overflow                                */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC0_SHFT 1
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC0_MASK 0x0000000000000002
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC2                               */
-/*   Description:  NI0 VC2 fifo underflow                               */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC2_SHFT 2
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC2_MASK 0x0000000000000004
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC2                                */
-/*   Description:  NI0 VC2 fifo overflow                                */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC2_SHFT 3
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC2_MASK 0x0000000000000008
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC0                               */
-/*   Description:  NI1 VC0 fifo underflow                               */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC0_SHFT 4
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC0_MASK 0x0000000000000010
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC0                                */
-/*   Description:  NI1 VC0 fifo overflow                                */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC0_SHFT 5
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC0_MASK 0x0000000000000020
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC2                               */
-/*   Description:  NI1 VC2 fifo underflow                               */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC2_SHFT 6
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC2_MASK 0x0000000000000040
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC2                                */
-/*   Description:  NI1 VC2 fifo overflow                                */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC2_SHFT 7
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC2_MASK 0x0000000000000080
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC0                              */
-/*   Description:  IILB VC0 fifo underflow                              */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC0_SHFT 8
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC0                               */
-/*   Description:  IILB VC0 fifo overflow                               */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC0_SHFT 9
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC0_MASK 0x0000000000000200
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC2                              */
-/*   Description:  IILB VC2 fifo underflow                              */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC2_SHFT 10
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC2_MASK 0x0000000000000400
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC2                               */
-/*   Description:  IILB VC2 fifo overflow                               */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC2_SHFT 11
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_VC0_CREDIT                            */
-/*   Description:  VC0 Credit underflow                                 */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_VC0_CREDIT_SHFT 12
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_VC0_CREDIT                             */
-/*   Description:  VC0 Credit overflow                                  */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_VC0_CREDIT_SHFT 13
-#define SH_XNPI_ERROR_MASK_OVERFLOW_VC0_CREDIT_MASK 0x0000000000002000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_VC2_CREDIT                            */
-/*   Description:  VC2 Credit underflow                                 */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_VC2_CREDIT_SHFT 14
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_VC2_CREDIT_MASK 0x0000000000004000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_VC2_CREDIT                             */
-/*   Description:  VC2 Credit overflow                                  */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_VC2_CREDIT_SHFT 15
-#define SH_XNPI_ERROR_MASK_OVERFLOW_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_DATABUFF_VC0                           */
-/*   Description:  VC0 Data Buffer overflow                             */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_DATABUFF_VC0_SHFT 16
-#define SH_XNPI_ERROR_MASK_OVERFLOW_DATABUFF_VC0_MASK 0x0000000000010000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_DATABUFF_VC2                           */
-/*   Description:  VC2 Data Buffer overflow                             */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_DATABUFF_VC2_SHFT 17
-#define SH_XNPI_ERROR_MASK_OVERFLOW_DATABUFF_VC2_MASK 0x0000000000020000
-
-/*   SH_XNPI_ERROR_MASK_LUT_READ_ERROR                                  */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNPI_ERROR_MASK_LUT_READ_ERROR_SHFT   18
-#define SH_XNPI_ERROR_MASK_LUT_READ_ERROR_MASK   0x0000000000040000
-
-/*   SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR0                               */
-/*   Description:  Single Bit Error in Bits 63:0                        */
-#define SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR0_SHFT 19
-#define SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR0_MASK 0x0000000000080000
-
-/*   SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR1                               */
-/*   Description:  Single Bit Error in Bits 127:64                      */
-#define SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR1_SHFT 20
-#define SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR1_MASK 0x0000000000100000
-
-/*   SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR2                               */
-/*   Description:  Single Bit Error in Bits 191:128                     */
-#define SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR2_SHFT 21
-#define SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR2_MASK 0x0000000000200000
-
-/*   SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR3                               */
-/*   Description:  Single Bit Error in Bits 255:192                     */
-#define SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR3_SHFT 22
-#define SH_XNPI_ERROR_MASK_SINGLE_BIT_ERROR3_MASK 0x0000000000400000
-
-/*   SH_XNPI_ERROR_MASK_UNCOR_ERROR0                                    */
-/*   Description:  Uncorrectable Error in Bits 63:0                     */
-#define SH_XNPI_ERROR_MASK_UNCOR_ERROR0_SHFT     23
-#define SH_XNPI_ERROR_MASK_UNCOR_ERROR0_MASK     0x0000000000800000
-
-/*   SH_XNPI_ERROR_MASK_UNCOR_ERROR1                                    */
-/*   Description:  Uncorrectable Error in Bits 127:64                   */
-#define SH_XNPI_ERROR_MASK_UNCOR_ERROR1_SHFT     24
-#define SH_XNPI_ERROR_MASK_UNCOR_ERROR1_MASK     0x0000000001000000
-
-/*   SH_XNPI_ERROR_MASK_UNCOR_ERROR2                                    */
-/*   Description:  Uncorrectable Error in Bits 191:128                  */
-#define SH_XNPI_ERROR_MASK_UNCOR_ERROR2_SHFT     25
-#define SH_XNPI_ERROR_MASK_UNCOR_ERROR2_MASK     0x0000000002000000
-
-/*   SH_XNPI_ERROR_MASK_UNCOR_ERROR3                                    */
-/*   Description:  Uncorrectable Error in Bits 255:192                  */
-#define SH_XNPI_ERROR_MASK_UNCOR_ERROR3_SHFT     26
-#define SH_XNPI_ERROR_MASK_UNCOR_ERROR3_MASK     0x0000000004000000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_SIC_CNTR0                             */
-/*   Description:  SIC Counter 0 Underflow                              */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_SIC_CNTR0_SHFT 27
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_SIC_CNTR0_MASK 0x0000000008000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_SIC_CNTR0                              */
-/*   Description:  SIC Counter 0 Overflow                               */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_SIC_CNTR0_SHFT 28
-#define SH_XNPI_ERROR_MASK_OVERFLOW_SIC_CNTR0_MASK 0x0000000010000000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_SIC_CNTR2                             */
-/*   Description:  SIC Counter 2 Underflow                              */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_SIC_CNTR2_SHFT 29
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_SIC_CNTR2_MASK 0x0000000020000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_SIC_CNTR2                              */
-/*   Description:  SIC Counter 2 Overflow                               */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_SIC_CNTR2_SHFT 30
-#define SH_XNPI_ERROR_MASK_OVERFLOW_SIC_CNTR2_MASK 0x0000000040000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI0_DEBIT0                             */
-/*   Description:  NI0 Debit 0 Overflow                                 */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_DEBIT0_SHFT 31
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_DEBIT0_MASK 0x0000000080000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI0_DEBIT2                             */
-/*   Description:  NI0 Debit 2 Overflow                                 */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_DEBIT2_SHFT 32
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_DEBIT2_MASK 0x0000000100000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI1_DEBIT0                             */
-/*   Description:  NI1 Debit 0 Overflow                                 */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_DEBIT0_SHFT 33
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_DEBIT0_MASK 0x0000000200000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI1_DEBIT2                             */
-/*   Description:  NI1 Debit 2 Overflow                                 */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_DEBIT2_SHFT 34
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_DEBIT2_MASK 0x0000000400000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_IILB_DEBIT0                            */
-/*   Description:  IILB Debit 0 Overflow                                */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_DEBIT0_SHFT 35
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_DEBIT0_MASK 0x0000000800000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_IILB_DEBIT2                            */
-/*   Description:  IILB Debit 2 Overflow                                */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_DEBIT2_SHFT 36
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_DEBIT2_MASK 0x0000001000000000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT                        */
-/*   Description:  NI0 VC0 Credit Underflow                             */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_SHFT 37
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_MASK 0x0000002000000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT                         */
-/*   Description:  NI0 VC0 Credit Overflow                              */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_SHFT 38
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_MASK 0x0000004000000000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT                        */
-/*   Description:  NI0 VC2 Credit Underflow                             */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_SHFT 39
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_MASK 0x0000008000000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT                         */
-/*   Description:  NI0 VC2 Credit Overflow                              */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_SHFT 40
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_MASK 0x0000010000000000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT                        */
-/*   Description:  NI1 VC0 Credit Underflow                             */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_SHFT 41
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_MASK 0x0000020000000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT                         */
-/*   Description:  NI1 VC0 Credit Overflow                              */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_SHFT 42
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_MASK 0x0000040000000000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT                        */
-/*   Description:  NI1 VC2 Credit Underflow                             */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_SHFT 43
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_MASK 0x0000080000000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT                         */
-/*   Description:  NI1 VC2 Credit Overflow                              */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_SHFT 44
-#define SH_XNPI_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_MASK 0x0000100000000000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT                       */
-/*   Description:  IILB VC0 Credit Underflow                            */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_SHFT 45
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_MASK 0x0000200000000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT                        */
-/*   Description:  IILB VC0 Credit Overflow                             */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_SHFT 46
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT                       */
-/*   Description:  IILB VC2 Credit Underflow                            */
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_SHFT 47
-#define SH_XNPI_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT                        */
-/*   Description:  IILB VC2 Credit Overflow                             */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_SHFT 48
-#define SH_XNPI_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_MASK 0x0001000000000000
-
-/*   SH_XNPI_ERROR_MASK_OVERFLOW_HEADER_CANCEL_FIFO                     */
-/*   Description:  Header Cancel Fifo Overflow                          */
-#define SH_XNPI_ERROR_MASK_OVERFLOW_HEADER_CANCEL_FIFO_SHFT 49
-#define SH_XNPI_ERROR_MASK_OVERFLOW_HEADER_CANCEL_FIFO_MASK 0x0002000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNPI_FIRST_ERROR"                    */
-/* ==================================================================== */
-
-#define SH_XNPI_FIRST_ERROR                      0x0000000150040360
-#define SH_XNPI_FIRST_ERROR_MASK                 0x0003ffffffffffff
-#define SH_XNPI_FIRST_ERROR_INIT                 0x0003ffffffffffff
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC0                              */
-/*   Description:  NI0 VC0 fifo underflow                               */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC0_SHFT 0
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC0_MASK 0x0000000000000001
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC0                               */
-/*   Description:  NI0 VC0 fifo overflow                                */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC0_SHFT 1
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC0_MASK 0x0000000000000002
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC2                              */
-/*   Description:  NI0 VC2 fifo underflow                               */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC2_SHFT 2
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC2_MASK 0x0000000000000004
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC2                               */
-/*   Description:  NI0 VC2 fifo overflow                                */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC2_SHFT 3
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC2_MASK 0x0000000000000008
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC0                              */
-/*   Description:  NI1 VC0 fifo underflow                               */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC0_SHFT 4
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC0_MASK 0x0000000000000010
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC0                               */
-/*   Description:  NI1 VC0 fifo overflow                                */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC0_SHFT 5
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC0_MASK 0x0000000000000020
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC2                              */
-/*   Description:  NI1 VC2 fifo underflow                               */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC2_SHFT 6
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC2_MASK 0x0000000000000040
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC2                               */
-/*   Description:  NI1 VC2 fifo overflow                                */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC2_SHFT 7
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC2_MASK 0x0000000000000080
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC0                             */
-/*   Description:  IILB VC0 fifo underflow                              */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC0_SHFT 8
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC0                              */
-/*   Description:  IILB VC0 fifo overflow                               */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC0_SHFT 9
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC0_MASK 0x0000000000000200
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC2                             */
-/*   Description:  IILB VC2 fifo underflow                              */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC2_SHFT 10
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC2_MASK 0x0000000000000400
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC2                              */
-/*   Description:  IILB VC2 fifo overflow                               */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC2_SHFT 11
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_VC0_CREDIT                           */
-/*   Description:  VC0 Credit underflow                                 */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_VC0_CREDIT_SHFT 12
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_VC0_CREDIT                            */
-/*   Description:  VC0 Credit overflow                                  */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_VC0_CREDIT_SHFT 13
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_VC0_CREDIT_MASK 0x0000000000002000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_VC2_CREDIT                           */
-/*   Description:  VC2 Credit underflow                                 */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_VC2_CREDIT_SHFT 14
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_VC2_CREDIT_MASK 0x0000000000004000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_VC2_CREDIT                            */
-/*   Description:  VC2 Credit overflow                                  */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_VC2_CREDIT_SHFT 15
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_DATABUFF_VC0                          */
-/*   Description:  VC0 Data Buffer overflow                             */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_DATABUFF_VC0_SHFT 16
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_DATABUFF_VC0_MASK 0x0000000000010000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_DATABUFF_VC2                          */
-/*   Description:  VC2 Data Buffer overflow                             */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_DATABUFF_VC2_SHFT 17
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_DATABUFF_VC2_MASK 0x0000000000020000
-
-/*   SH_XNPI_FIRST_ERROR_LUT_READ_ERROR                                 */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNPI_FIRST_ERROR_LUT_READ_ERROR_SHFT  18
-#define SH_XNPI_FIRST_ERROR_LUT_READ_ERROR_MASK  0x0000000000040000
-
-/*   SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR0                              */
-/*   Description:  Single Bit Error in Bits 63:0                        */
-#define SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR0_SHFT 19
-#define SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR0_MASK 0x0000000000080000
-
-/*   SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR1                              */
-/*   Description:  Single Bit Error in Bits 127:64                      */
-#define SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR1_SHFT 20
-#define SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR1_MASK 0x0000000000100000
-
-/*   SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR2                              */
-/*   Description:  Single Bit Error in Bits 191:128                     */
-#define SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR2_SHFT 21
-#define SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR2_MASK 0x0000000000200000
-
-/*   SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR3                              */
-/*   Description:  Single Bit Error in Bits 255:192                     */
-#define SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR3_SHFT 22
-#define SH_XNPI_FIRST_ERROR_SINGLE_BIT_ERROR3_MASK 0x0000000000400000
-
-/*   SH_XNPI_FIRST_ERROR_UNCOR_ERROR0                                   */
-/*   Description:  Uncorrectable Error in Bits 63:0                     */
-#define SH_XNPI_FIRST_ERROR_UNCOR_ERROR0_SHFT    23
-#define SH_XNPI_FIRST_ERROR_UNCOR_ERROR0_MASK    0x0000000000800000
-
-/*   SH_XNPI_FIRST_ERROR_UNCOR_ERROR1                                   */
-/*   Description:  Uncorrectable Error in Bits 127:64                   */
-#define SH_XNPI_FIRST_ERROR_UNCOR_ERROR1_SHFT    24
-#define SH_XNPI_FIRST_ERROR_UNCOR_ERROR1_MASK    0x0000000001000000
-
-/*   SH_XNPI_FIRST_ERROR_UNCOR_ERROR2                                   */
-/*   Description:  Uncorrectable Error in Bits 191:128                  */
-#define SH_XNPI_FIRST_ERROR_UNCOR_ERROR2_SHFT    25
-#define SH_XNPI_FIRST_ERROR_UNCOR_ERROR2_MASK    0x0000000002000000
-
-/*   SH_XNPI_FIRST_ERROR_UNCOR_ERROR3                                   */
-/*   Description:  Uncorrectable Error in Bits 255:192                  */
-#define SH_XNPI_FIRST_ERROR_UNCOR_ERROR3_SHFT    26
-#define SH_XNPI_FIRST_ERROR_UNCOR_ERROR3_MASK    0x0000000004000000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_SIC_CNTR0                            */
-/*   Description:  SIC Counter 0 Underflow                              */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_SIC_CNTR0_SHFT 27
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_SIC_CNTR0_MASK 0x0000000008000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_SIC_CNTR0                             */
-/*   Description:  SIC Counter 0 Overflow                               */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_SIC_CNTR0_SHFT 28
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_SIC_CNTR0_MASK 0x0000000010000000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_SIC_CNTR2                            */
-/*   Description:  SIC Counter 2 Underflow                              */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_SIC_CNTR2_SHFT 29
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_SIC_CNTR2_MASK 0x0000000020000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_SIC_CNTR2                             */
-/*   Description:  SIC Counter 2 Overflow                               */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_SIC_CNTR2_SHFT 30
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_SIC_CNTR2_MASK 0x0000000040000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_DEBIT0                            */
-/*   Description:  NI0 Debit 0 Overflow                                 */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_DEBIT0_SHFT 31
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_DEBIT0_MASK 0x0000000080000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_DEBIT2                            */
-/*   Description:  NI0 Debit 2 Overflow                                 */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_DEBIT2_SHFT 32
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_DEBIT2_MASK 0x0000000100000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_DEBIT0                            */
-/*   Description:  NI1 Debit 0 Overflow                                 */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_DEBIT0_SHFT 33
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_DEBIT0_MASK 0x0000000200000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_DEBIT2                            */
-/*   Description:  NI1 Debit 2 Overflow                                 */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_DEBIT2_SHFT 34
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_DEBIT2_MASK 0x0000000400000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_DEBIT0                           */
-/*   Description:  IILB Debit 0 Overflow                                */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_DEBIT0_SHFT 35
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_DEBIT0_MASK 0x0000000800000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_DEBIT2                           */
-/*   Description:  IILB Debit 2 Overflow                                */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_DEBIT2_SHFT 36
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_DEBIT2_MASK 0x0000001000000000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT                       */
-/*   Description:  NI0 VC0 Credit Underflow                             */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_SHFT 37
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_MASK 0x0000002000000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT                        */
-/*   Description:  NI0 VC0 Credit Overflow                              */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_SHFT 38
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_MASK 0x0000004000000000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT                       */
-/*   Description:  NI0 VC2 Credit Underflow                             */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_SHFT 39
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_MASK 0x0000008000000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT                        */
-/*   Description:  NI0 VC2 Credit Overflow                              */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_SHFT 40
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_MASK 0x0000010000000000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT                       */
-/*   Description:  NI1 VC0 Credit Underflow                             */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_SHFT 41
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_MASK 0x0000020000000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT                        */
-/*   Description:  NI1 VC0 Credit Overflow                              */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_SHFT 42
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_MASK 0x0000040000000000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT                       */
-/*   Description:  NI1 VC2 Credit Underflow                             */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_SHFT 43
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_MASK 0x0000080000000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT                        */
-/*   Description:  NI1 VC2 Credit Overflow                              */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_SHFT 44
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_MASK 0x0000100000000000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT                      */
-/*   Description:  IILB VC0 Credit Underflow                            */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_SHFT 45
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_MASK 0x0000200000000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT                       */
-/*   Description:  IILB VC0 Credit Overflow                             */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_SHFT 46
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT                      */
-/*   Description:  IILB VC2 Credit Underflow                            */
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_SHFT 47
-#define SH_XNPI_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT                       */
-/*   Description:  IILB VC2 Credit Overflow                             */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_SHFT 48
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_MASK 0x0001000000000000
-
-/*   SH_XNPI_FIRST_ERROR_OVERFLOW_HEADER_CANCEL_FIFO                    */
-/*   Description:  Header Cancel Fifo Overflow                          */
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_HEADER_CANCEL_FIFO_SHFT 49
-#define SH_XNPI_FIRST_ERROR_OVERFLOW_HEADER_CANCEL_FIFO_MASK 0x0002000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNMD_ERROR_SUMMARY"                   */
-/* ==================================================================== */
-
-#define SH_XNMD_ERROR_SUMMARY                    0x0000000150040400
-#define SH_XNMD_ERROR_SUMMARY_MASK               0x0003ffffffffffff
-#define SH_XNMD_ERROR_SUMMARY_INIT               0x0003ffffffffffff
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC0                            */
-/*   Description:  NI0 VC0 fifo underflow                               */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_SHFT 0
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_MASK 0x0000000000000001
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC0                             */
-/*   Description:  NI0 VC0 fifo overflow                                */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC0_SHFT 1
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC0_MASK 0x0000000000000002
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC2                            */
-/*   Description:  NI0 VC2 fifo underflow                               */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_SHFT 2
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_MASK 0x0000000000000004
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC2                             */
-/*   Description:  NI0 VC2 fifo overflow                                */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC2_SHFT 3
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC2_MASK 0x0000000000000008
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC0                            */
-/*   Description:  NI1 VC0 fifo underflow                               */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_SHFT 4
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_MASK 0x0000000000000010
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC0                             */
-/*   Description:  NI1 VC0 fifo overflow                                */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC0_SHFT 5
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC0_MASK 0x0000000000000020
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC2                            */
-/*   Description:  NI1 VC2 fifo underflow                               */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_SHFT 6
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_MASK 0x0000000000000040
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC2                             */
-/*   Description:  NI1 VC2 fifo overflow                                */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC2_SHFT 7
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC2_MASK 0x0000000000000080
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC0                           */
-/*   Description:  IILB VC0 fifo underflow                              */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_SHFT 8
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC0                            */
-/*   Description:  IILB VC0 fifo overflow                               */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC0_SHFT 9
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC0_MASK 0x0000000000000200
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC2                           */
-/*   Description:  IILB VC2 fifo underflow                              */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_SHFT 10
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_MASK 0x0000000000000400
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC2                            */
-/*   Description:  IILB VC2 fifo overflow                               */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC2_SHFT 11
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_VC0_CREDIT                         */
-/*   Description:  VC0 Credit underflow                                 */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_VC0_CREDIT_SHFT 12
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_VC0_CREDIT                          */
-/*   Description:  VC0 Credit overflow                                  */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_VC0_CREDIT_SHFT 13
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_VC0_CREDIT_MASK 0x0000000000002000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_VC2_CREDIT                         */
-/*   Description:  VC2 Credit underflow                                 */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_VC2_CREDIT_SHFT 14
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_VC2_CREDIT_MASK 0x0000000000004000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_VC2_CREDIT                          */
-/*   Description:  VC2 Credit overflow                                  */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_VC2_CREDIT_SHFT 15
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC0                        */
-/*   Description:  VC0 Data Buffer overflow                             */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC0_SHFT 16
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC0_MASK 0x0000000000010000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC2                        */
-/*   Description:  VC2 Data Buffer overflow                             */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC2_SHFT 17
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_DATABUFF_VC2_MASK 0x0000000000020000
-
-/*   SH_XNMD_ERROR_SUMMARY_LUT_READ_ERROR                               */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNMD_ERROR_SUMMARY_LUT_READ_ERROR_SHFT 18
-#define SH_XNMD_ERROR_SUMMARY_LUT_READ_ERROR_MASK 0x0000000000040000
-
-/*   SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR0                            */
-/*   Description:  Single Bit Error in Bits 63:0                        */
-#define SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR0_SHFT 19
-#define SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR0_MASK 0x0000000000080000
-
-/*   SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR1                            */
-/*   Description:  Single Bit Error in Bits 127:64                      */
-#define SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR1_SHFT 20
-#define SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR1_MASK 0x0000000000100000
-
-/*   SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR2                            */
-/*   Description:  Single Bit Error in Bits 191:128                     */
-#define SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR2_SHFT 21
-#define SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR2_MASK 0x0000000000200000
-
-/*   SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR3                            */
-/*   Description:  Single Bit Error in Bits 255:192                     */
-#define SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR3_SHFT 22
-#define SH_XNMD_ERROR_SUMMARY_SINGLE_BIT_ERROR3_MASK 0x0000000000400000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR0                                 */
-/*   Description:  Uncorrectable Error in Bits 63:0                     */
-#define SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR0_SHFT  23
-#define SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR0_MASK  0x0000000000800000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR1                                 */
-/*   Description:  Uncorrectable Error in Bits 127:64                   */
-#define SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR1_SHFT  24
-#define SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR1_MASK  0x0000000001000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR2                                 */
-/*   Description:  Uncorrectable Error in Bits 191:128                  */
-#define SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR2_SHFT  25
-#define SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR2_MASK  0x0000000002000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR3                                 */
-/*   Description:  Uncorrectable Error in Bits 255:192                  */
-#define SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR3_SHFT  26
-#define SH_XNMD_ERROR_SUMMARY_UNCOR_ERROR3_MASK  0x0000000004000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR0                          */
-/*   Description:  SIC Counter 0 Underflow                              */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR0_SHFT 27
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR0_MASK 0x0000000008000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_SIC_CNTR0                           */
-/*   Description:  SIC Counter 0 Overflow                               */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_SIC_CNTR0_SHFT 28
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_SIC_CNTR0_MASK 0x0000000010000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR2                          */
-/*   Description:  SIC Counter 2 Underflow                              */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR2_SHFT 29
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_SIC_CNTR2_MASK 0x0000000020000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_SIC_CNTR2                           */
-/*   Description:  SIC Counter 2 Overflow                               */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_SIC_CNTR2_SHFT 30
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_SIC_CNTR2_MASK 0x0000000040000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0                          */
-/*   Description:  NI0 Debit 0 Overflow                                 */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0_SHFT 31
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT0_MASK 0x0000000080000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2                          */
-/*   Description:  NI0 Debit 2 Overflow                                 */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2_SHFT 32
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_DEBIT2_MASK 0x0000000100000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0                          */
-/*   Description:  NI1 Debit 0 Overflow                                 */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0_SHFT 33
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT0_MASK 0x0000000200000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2                          */
-/*   Description:  NI1 Debit 2 Overflow                                 */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2_SHFT 34
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_DEBIT2_MASK 0x0000000400000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0                         */
-/*   Description:  IILB Debit 0 Overflow                                */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0_SHFT 35
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT0_MASK 0x0000000800000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2                         */
-/*   Description:  IILB Debit 2 Overflow                                */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2_SHFT 36
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_DEBIT2_MASK 0x0000001000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT                     */
-/*   Description:  NI0 VC0 Credit Underflow                             */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_SHFT 37
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC0_CREDIT_MASK 0x0000002000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT                      */
-/*   Description:  NI0 VC0 Credit Overflow                              */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_SHFT 38
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC0_CREDIT_MASK 0x0000004000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT                     */
-/*   Description:  NI0 VC2 Credit Underflow                             */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_SHFT 39
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI0_VC2_CREDIT_MASK 0x0000008000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT                      */
-/*   Description:  NI0 VC2 Credit Overflow                              */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_SHFT 40
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI0_VC2_CREDIT_MASK 0x0000010000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT                     */
-/*   Description:  NI1 VC0 Credit Underflow                             */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_SHFT 41
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC0_CREDIT_MASK 0x0000020000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT                      */
-/*   Description:  NI1 VC0 Credit Overflow                              */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_SHFT 42
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC0_CREDIT_MASK 0x0000040000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT                     */
-/*   Description:  NI1 VC2 Credit Underflow                             */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_SHFT 43
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_NI1_VC2_CREDIT_MASK 0x0000080000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT                      */
-/*   Description:  NI1 VC2 Credit Overflow                              */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_SHFT 44
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_NI1_VC2_CREDIT_MASK 0x0000100000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT                    */
-/*   Description:  IILB VC0 Credit Underflow                            */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_SHFT 45
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC0_CREDIT_MASK 0x0000200000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT                     */
-/*   Description:  IILB VC0 Credit Overflow                             */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_SHFT 46
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT                    */
-/*   Description:  IILB VC2 Credit Underflow                            */
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_SHFT 47
-#define SH_XNMD_ERROR_SUMMARY_UNDERFLOW_IILB_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT                     */
-/*   Description:  IILB VC2 Credit Overflow                             */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_SHFT 48
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_IILB_VC2_CREDIT_MASK 0x0001000000000000
-
-/*   SH_XNMD_ERROR_SUMMARY_OVERFLOW_HEADER_CANCEL_FIFO                  */
-/*   Description:  Header Cancel Fifo Overflow                          */
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_HEADER_CANCEL_FIFO_SHFT 49
-#define SH_XNMD_ERROR_SUMMARY_OVERFLOW_HEADER_CANCEL_FIFO_MASK 0x0002000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XNMD_ERRORS_ALIAS"                    */
-/* ==================================================================== */
-
-#define SH_XNMD_ERRORS_ALIAS                     0x0000000150040408
-
-/* ==================================================================== */
-/*                  Register "SH_XNMD_ERROR_OVERFLOW"                   */
-/* ==================================================================== */
-
-#define SH_XNMD_ERROR_OVERFLOW                   0x0000000150040420
-#define SH_XNMD_ERROR_OVERFLOW_MASK              0x0003ffffffffffff
-#define SH_XNMD_ERROR_OVERFLOW_INIT              0x0003ffffffffffff
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0                           */
-/*   Description:  NI0 VC0 fifo underflow                               */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_SHFT 0
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_MASK 0x0000000000000001
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC0                            */
-/*   Description:  NI0 VC0 fifo overflow                                */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_SHFT 1
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_MASK 0x0000000000000002
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2                           */
-/*   Description:  NI0 VC2 fifo underflow                               */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_SHFT 2
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_MASK 0x0000000000000004
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC2                            */
-/*   Description:  NI0 VC2 fifo overflow                                */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_SHFT 3
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_MASK 0x0000000000000008
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0                           */
-/*   Description:  NI1 VC0 fifo underflow                               */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_SHFT 4
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_MASK 0x0000000000000010
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC0                            */
-/*   Description:  NI1 VC0 fifo overflow                                */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_SHFT 5
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_MASK 0x0000000000000020
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2                           */
-/*   Description:  NI1 VC2 fifo underflow                               */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_SHFT 6
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_MASK 0x0000000000000040
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC2                            */
-/*   Description:  NI1 VC2 fifo overflow                                */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_SHFT 7
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_MASK 0x0000000000000080
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0                          */
-/*   Description:  IILB VC0 fifo underflow                              */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_SHFT 8
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC0                           */
-/*   Description:  IILB VC0 fifo overflow                               */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_SHFT 9
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_MASK 0x0000000000000200
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2                          */
-/*   Description:  IILB VC2 fifo underflow                              */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_SHFT 10
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_MASK 0x0000000000000400
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC2                           */
-/*   Description:  IILB VC2 fifo overflow                               */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_SHFT 11
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_VC0_CREDIT                        */
-/*   Description:  VC0 Credit underflow                                 */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_VC0_CREDIT_SHFT 12
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_VC0_CREDIT                         */
-/*   Description:  VC0 Credit overflow                                  */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_VC0_CREDIT_SHFT 13
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_VC0_CREDIT_MASK 0x0000000000002000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_VC2_CREDIT                        */
-/*   Description:  VC2 Credit underflow                                 */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_VC2_CREDIT_SHFT 14
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_VC2_CREDIT_MASK 0x0000000000004000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_VC2_CREDIT                         */
-/*   Description:  VC2 Credit overflow                                  */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_VC2_CREDIT_SHFT 15
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC0                       */
-/*   Description:  VC0 Data Buffer overflow                             */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC0_SHFT 16
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC0_MASK 0x0000000000010000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC2                       */
-/*   Description:  VC2 Data Buffer overflow                             */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC2_SHFT 17
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_DATABUFF_VC2_MASK 0x0000000000020000
-
-/*   SH_XNMD_ERROR_OVERFLOW_LUT_READ_ERROR                              */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNMD_ERROR_OVERFLOW_LUT_READ_ERROR_SHFT 18
-#define SH_XNMD_ERROR_OVERFLOW_LUT_READ_ERROR_MASK 0x0000000000040000
-
-/*   SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR0                           */
-/*   Description:  Single Bit Error in Bits 63:0                        */
-#define SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR0_SHFT 19
-#define SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR0_MASK 0x0000000000080000
-
-/*   SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR1                           */
-/*   Description:  Single Bit Error in Bits 127:64                      */
-#define SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR1_SHFT 20
-#define SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR1_MASK 0x0000000000100000
-
-/*   SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR2                           */
-/*   Description:  Single Bit Error in Bits 191:128                     */
-#define SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR2_SHFT 21
-#define SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR2_MASK 0x0000000000200000
-
-/*   SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR3                           */
-/*   Description:  Single Bit Error in Bits 255:192                     */
-#define SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR3_SHFT 22
-#define SH_XNMD_ERROR_OVERFLOW_SINGLE_BIT_ERROR3_MASK 0x0000000000400000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR0                                */
-/*   Description:  Uncorrectable Error in Bits 63:0                     */
-#define SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR0_SHFT 23
-#define SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR0_MASK 0x0000000000800000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR1                                */
-/*   Description:  Uncorrectable Error in Bits 127:64                   */
-#define SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR1_SHFT 24
-#define SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR1_MASK 0x0000000001000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR2                                */
-/*   Description:  Uncorrectable Error in Bits 191:128                  */
-#define SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR2_SHFT 25
-#define SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR2_MASK 0x0000000002000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR3                                */
-/*   Description:  Uncorrectable Error in Bits 255:192                  */
-#define SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR3_SHFT 26
-#define SH_XNMD_ERROR_OVERFLOW_UNCOR_ERROR3_MASK 0x0000000004000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR0                         */
-/*   Description:  SIC Counter 0 Underflow                              */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR0_SHFT 27
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR0_MASK 0x0000000008000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR0                          */
-/*   Description:  SIC Counter 0 Overflow                               */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR0_SHFT 28
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR0_MASK 0x0000000010000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR2                         */
-/*   Description:  SIC Counter 2 Underflow                              */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR2_SHFT 29
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_SIC_CNTR2_MASK 0x0000000020000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR2                          */
-/*   Description:  SIC Counter 2 Overflow                               */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR2_SHFT 30
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_SIC_CNTR2_MASK 0x0000000040000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0                         */
-/*   Description:  NI0 Debit 0 Overflow                                 */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0_SHFT 31
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT0_MASK 0x0000000080000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2                         */
-/*   Description:  NI0 Debit 2 Overflow                                 */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2_SHFT 32
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_DEBIT2_MASK 0x0000000100000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0                         */
-/*   Description:  NI1 Debit 0 Overflow                                 */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0_SHFT 33
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT0_MASK 0x0000000200000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2                         */
-/*   Description:  NI1 Debit 2 Overflow                                 */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2_SHFT 34
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_DEBIT2_MASK 0x0000000400000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0                        */
-/*   Description:  IILB Debit 0 Overflow                                */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0_SHFT 35
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT0_MASK 0x0000000800000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2                        */
-/*   Description:  IILB Debit 2 Overflow                                */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2_SHFT 36
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_DEBIT2_MASK 0x0000001000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT                    */
-/*   Description:  NI0 VC0 Credit Underflow                             */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_SHFT 37
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC0_CREDIT_MASK 0x0000002000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT                     */
-/*   Description:  NI0 VC0 Credit Overflow                              */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_SHFT 38
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC0_CREDIT_MASK 0x0000004000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT                    */
-/*   Description:  NI0 VC2 Credit Underflow                             */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_SHFT 39
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI0_VC2_CREDIT_MASK 0x0000008000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT                     */
-/*   Description:  NI0 VC2 Credit Overflow                              */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_SHFT 40
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI0_VC2_CREDIT_MASK 0x0000010000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT                    */
-/*   Description:  NI1 VC0 Credit Underflow                             */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_SHFT 41
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC0_CREDIT_MASK 0x0000020000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT                     */
-/*   Description:  NI1 VC0 Credit Overflow                              */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_SHFT 42
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC0_CREDIT_MASK 0x0000040000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT                    */
-/*   Description:  NI1 VC2 Credit Underflow                             */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_SHFT 43
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_NI1_VC2_CREDIT_MASK 0x0000080000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT                     */
-/*   Description:  NI1 VC2 Credit Overflow                              */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_SHFT 44
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_NI1_VC2_CREDIT_MASK 0x0000100000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT                   */
-/*   Description:  IILB VC0 Credit Underflow                            */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_SHFT 45
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC0_CREDIT_MASK 0x0000200000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT                    */
-/*   Description:  IILB VC0 Credit Overflow                             */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_SHFT 46
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT                   */
-/*   Description:  IILB VC2 Credit Underflow                            */
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_SHFT 47
-#define SH_XNMD_ERROR_OVERFLOW_UNDERFLOW_IILB_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT                    */
-/*   Description:  IILB VC2 Credit Overflow                             */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_SHFT 48
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_IILB_VC2_CREDIT_MASK 0x0001000000000000
-
-/*   SH_XNMD_ERROR_OVERFLOW_OVERFLOW_HEADER_CANCEL_FIFO                 */
-/*   Description:  Header Cancel Fifo Overflow                          */
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_HEADER_CANCEL_FIFO_SHFT 49
-#define SH_XNMD_ERROR_OVERFLOW_OVERFLOW_HEADER_CANCEL_FIFO_MASK 0x0002000000000000
-
-/* ==================================================================== */
-/*               Register "SH_XNMD_ERROR_OVERFLOW_ALIAS"                */
-/* ==================================================================== */
-
-#define SH_XNMD_ERROR_OVERFLOW_ALIAS             0x0000000150040428
-
-/* ==================================================================== */
-/*                    Register "SH_XNMD_ERROR_MASK"                     */
-/* ==================================================================== */
-
-#define SH_XNMD_ERROR_MASK                       0x0000000150040440
-#define SH_XNMD_ERROR_MASK_MASK                  0x0003ffffffffffff
-#define SH_XNMD_ERROR_MASK_INIT                  0x0003ffffffffffff
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC0                               */
-/*   Description:  NI0 VC0 fifo underflow                               */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC0_SHFT 0
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC0_MASK 0x0000000000000001
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC0                                */
-/*   Description:  NI0 VC0 fifo overflow                                */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC0_SHFT 1
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC0_MASK 0x0000000000000002
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC2                               */
-/*   Description:  NI0 VC2 fifo underflow                               */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC2_SHFT 2
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC2_MASK 0x0000000000000004
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC2                                */
-/*   Description:  NI0 VC2 fifo overflow                                */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC2_SHFT 3
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC2_MASK 0x0000000000000008
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC0                               */
-/*   Description:  NI1 VC0 fifo underflow                               */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC0_SHFT 4
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC0_MASK 0x0000000000000010
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC0                                */
-/*   Description:  NI1 VC0 fifo overflow                                */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC0_SHFT 5
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC0_MASK 0x0000000000000020
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC2                               */
-/*   Description:  NI1 VC2 fifo underflow                               */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC2_SHFT 6
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC2_MASK 0x0000000000000040
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC2                                */
-/*   Description:  NI1 VC2 fifo overflow                                */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC2_SHFT 7
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC2_MASK 0x0000000000000080
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC0                              */
-/*   Description:  IILB VC0 fifo underflow                              */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC0_SHFT 8
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC0                               */
-/*   Description:  IILB VC0 fifo overflow                               */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC0_SHFT 9
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC0_MASK 0x0000000000000200
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC2                              */
-/*   Description:  IILB VC2 fifo underflow                              */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC2_SHFT 10
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC2_MASK 0x0000000000000400
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC2                               */
-/*   Description:  IILB VC2 fifo overflow                               */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC2_SHFT 11
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_VC0_CREDIT                            */
-/*   Description:  VC0 Credit underflow                                 */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_VC0_CREDIT_SHFT 12
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_VC0_CREDIT                             */
-/*   Description:  VC0 Credit overflow                                  */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_VC0_CREDIT_SHFT 13
-#define SH_XNMD_ERROR_MASK_OVERFLOW_VC0_CREDIT_MASK 0x0000000000002000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_VC2_CREDIT                            */
-/*   Description:  VC2 Credit underflow                                 */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_VC2_CREDIT_SHFT 14
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_VC2_CREDIT_MASK 0x0000000000004000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_VC2_CREDIT                             */
-/*   Description:  VC2 Credit overflow                                  */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_VC2_CREDIT_SHFT 15
-#define SH_XNMD_ERROR_MASK_OVERFLOW_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_DATABUFF_VC0                           */
-/*   Description:  VC0 Data Buffer overflow                             */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_DATABUFF_VC0_SHFT 16
-#define SH_XNMD_ERROR_MASK_OVERFLOW_DATABUFF_VC0_MASK 0x0000000000010000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_DATABUFF_VC2                           */
-/*   Description:  VC2 Data Buffer overflow                             */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_DATABUFF_VC2_SHFT 17
-#define SH_XNMD_ERROR_MASK_OVERFLOW_DATABUFF_VC2_MASK 0x0000000000020000
-
-/*   SH_XNMD_ERROR_MASK_LUT_READ_ERROR                                  */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNMD_ERROR_MASK_LUT_READ_ERROR_SHFT   18
-#define SH_XNMD_ERROR_MASK_LUT_READ_ERROR_MASK   0x0000000000040000
-
-/*   SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR0                               */
-/*   Description:  Single Bit Error in Bits 63:0                        */
-#define SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR0_SHFT 19
-#define SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR0_MASK 0x0000000000080000
-
-/*   SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR1                               */
-/*   Description:  Single Bit Error in Bits 127:64                      */
-#define SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR1_SHFT 20
-#define SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR1_MASK 0x0000000000100000
-
-/*   SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR2                               */
-/*   Description:  Single Bit Error in Bits 191:128                     */
-#define SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR2_SHFT 21
-#define SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR2_MASK 0x0000000000200000
-
-/*   SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR3                               */
-/*   Description:  Single Bit Error in Bits 255:192                     */
-#define SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR3_SHFT 22
-#define SH_XNMD_ERROR_MASK_SINGLE_BIT_ERROR3_MASK 0x0000000000400000
-
-/*   SH_XNMD_ERROR_MASK_UNCOR_ERROR0                                    */
-/*   Description:  Uncorrectable Error in Bits 63:0                     */
-#define SH_XNMD_ERROR_MASK_UNCOR_ERROR0_SHFT     23
-#define SH_XNMD_ERROR_MASK_UNCOR_ERROR0_MASK     0x0000000000800000
-
-/*   SH_XNMD_ERROR_MASK_UNCOR_ERROR1                                    */
-/*   Description:  Uncorrectable Error in Bits 127:64                   */
-#define SH_XNMD_ERROR_MASK_UNCOR_ERROR1_SHFT     24
-#define SH_XNMD_ERROR_MASK_UNCOR_ERROR1_MASK     0x0000000001000000
-
-/*   SH_XNMD_ERROR_MASK_UNCOR_ERROR2                                    */
-/*   Description:  Uncorrectable Error in Bits 191:128                  */
-#define SH_XNMD_ERROR_MASK_UNCOR_ERROR2_SHFT     25
-#define SH_XNMD_ERROR_MASK_UNCOR_ERROR2_MASK     0x0000000002000000
-
-/*   SH_XNMD_ERROR_MASK_UNCOR_ERROR3                                    */
-/*   Description:  Uncorrectable Error in Bits 255:192                  */
-#define SH_XNMD_ERROR_MASK_UNCOR_ERROR3_SHFT     26
-#define SH_XNMD_ERROR_MASK_UNCOR_ERROR3_MASK     0x0000000004000000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_SIC_CNTR0                             */
-/*   Description:  SIC Counter 0 Underflow                              */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_SIC_CNTR0_SHFT 27
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_SIC_CNTR0_MASK 0x0000000008000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_SIC_CNTR0                              */
-/*   Description:  SIC Counter 0 Overflow                               */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_SIC_CNTR0_SHFT 28
-#define SH_XNMD_ERROR_MASK_OVERFLOW_SIC_CNTR0_MASK 0x0000000010000000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_SIC_CNTR2                             */
-/*   Description:  SIC Counter 2 Underflow                              */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_SIC_CNTR2_SHFT 29
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_SIC_CNTR2_MASK 0x0000000020000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_SIC_CNTR2                              */
-/*   Description:  SIC Counter 2 Overflow                               */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_SIC_CNTR2_SHFT 30
-#define SH_XNMD_ERROR_MASK_OVERFLOW_SIC_CNTR2_MASK 0x0000000040000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI0_DEBIT0                             */
-/*   Description:  NI0 Debit 0 Overflow                                 */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_DEBIT0_SHFT 31
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_DEBIT0_MASK 0x0000000080000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI0_DEBIT2                             */
-/*   Description:  NI0 Debit 2 Overflow                                 */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_DEBIT2_SHFT 32
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_DEBIT2_MASK 0x0000000100000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI1_DEBIT0                             */
-/*   Description:  NI1 Debit 0 Overflow                                 */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_DEBIT0_SHFT 33
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_DEBIT0_MASK 0x0000000200000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI1_DEBIT2                             */
-/*   Description:  NI1 Debit 2 Overflow                                 */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_DEBIT2_SHFT 34
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_DEBIT2_MASK 0x0000000400000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_IILB_DEBIT0                            */
-/*   Description:  IILB Debit 0 Overflow                                */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_DEBIT0_SHFT 35
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_DEBIT0_MASK 0x0000000800000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_IILB_DEBIT2                            */
-/*   Description:  IILB Debit 2 Overflow                                */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_DEBIT2_SHFT 36
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_DEBIT2_MASK 0x0000001000000000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT                        */
-/*   Description:  NI0 VC0 Credit Underflow                             */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_SHFT 37
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC0_CREDIT_MASK 0x0000002000000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT                         */
-/*   Description:  NI0 VC0 Credit Overflow                              */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_SHFT 38
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC0_CREDIT_MASK 0x0000004000000000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT                        */
-/*   Description:  NI0 VC2 Credit Underflow                             */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_SHFT 39
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI0_VC2_CREDIT_MASK 0x0000008000000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT                         */
-/*   Description:  NI0 VC2 Credit Overflow                              */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_SHFT 40
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI0_VC2_CREDIT_MASK 0x0000010000000000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT                        */
-/*   Description:  NI1 VC0 Credit Underflow                             */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_SHFT 41
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC0_CREDIT_MASK 0x0000020000000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT                         */
-/*   Description:  NI1 VC0 Credit Overflow                              */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_SHFT 42
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC0_CREDIT_MASK 0x0000040000000000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT                        */
-/*   Description:  NI1 VC2 Credit Underflow                             */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_SHFT 43
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_NI1_VC2_CREDIT_MASK 0x0000080000000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT                         */
-/*   Description:  NI1 VC2 Credit Overflow                              */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_SHFT 44
-#define SH_XNMD_ERROR_MASK_OVERFLOW_NI1_VC2_CREDIT_MASK 0x0000100000000000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT                       */
-/*   Description:  IILB VC0 Credit Underflow                            */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_SHFT 45
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC0_CREDIT_MASK 0x0000200000000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT                        */
-/*   Description:  IILB VC0 Credit Overflow                             */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_SHFT 46
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT                       */
-/*   Description:  IILB VC2 Credit Underflow                            */
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_SHFT 47
-#define SH_XNMD_ERROR_MASK_UNDERFLOW_IILB_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT                        */
-/*   Description:  IILB VC2 Credit Overflow                             */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_SHFT 48
-#define SH_XNMD_ERROR_MASK_OVERFLOW_IILB_VC2_CREDIT_MASK 0x0001000000000000
-
-/*   SH_XNMD_ERROR_MASK_OVERFLOW_HEADER_CANCEL_FIFO                     */
-/*   Description:  Header Cancel Fifo Overflow                          */
-#define SH_XNMD_ERROR_MASK_OVERFLOW_HEADER_CANCEL_FIFO_SHFT 49
-#define SH_XNMD_ERROR_MASK_OVERFLOW_HEADER_CANCEL_FIFO_MASK 0x0002000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XNMD_FIRST_ERROR"                    */
-/* ==================================================================== */
-
-#define SH_XNMD_FIRST_ERROR                      0x0000000150040460
-#define SH_XNMD_FIRST_ERROR_MASK                 0x0003ffffffffffff
-#define SH_XNMD_FIRST_ERROR_INIT                 0x0003ffffffffffff
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC0                              */
-/*   Description:  NI0 VC0 fifo underflow                               */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC0_SHFT 0
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC0_MASK 0x0000000000000001
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC0                               */
-/*   Description:  NI0 VC0 fifo overflow                                */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC0_SHFT 1
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC0_MASK 0x0000000000000002
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC2                              */
-/*   Description:  NI0 VC2 fifo underflow                               */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC2_SHFT 2
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC2_MASK 0x0000000000000004
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC2                               */
-/*   Description:  NI0 VC2 fifo overflow                                */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC2_SHFT 3
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC2_MASK 0x0000000000000008
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC0                              */
-/*   Description:  NI1 VC0 fifo underflow                               */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC0_SHFT 4
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC0_MASK 0x0000000000000010
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC0                               */
-/*   Description:  NI1 VC0 fifo overflow                                */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC0_SHFT 5
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC0_MASK 0x0000000000000020
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC2                              */
-/*   Description:  NI1 VC2 fifo underflow                               */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC2_SHFT 6
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC2_MASK 0x0000000000000040
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC2                               */
-/*   Description:  NI1 VC2 fifo overflow                                */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC2_SHFT 7
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC2_MASK 0x0000000000000080
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC0                             */
-/*   Description:  IILB VC0 fifo underflow                              */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC0_SHFT 8
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC0_MASK 0x0000000000000100
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC0                              */
-/*   Description:  IILB VC0 fifo overflow                               */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC0_SHFT 9
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC0_MASK 0x0000000000000200
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC2                             */
-/*   Description:  IILB VC2 fifo underflow                              */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC2_SHFT 10
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC2_MASK 0x0000000000000400
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC2                              */
-/*   Description:  IILB VC2 fifo overflow                               */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC2_SHFT 11
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC2_MASK 0x0000000000000800
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_VC0_CREDIT                           */
-/*   Description:  VC0 Credit underflow                                 */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_VC0_CREDIT_SHFT 12
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_VC0_CREDIT_MASK 0x0000000000001000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_VC0_CREDIT                            */
-/*   Description:  VC0 Credit overflow                                  */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_VC0_CREDIT_SHFT 13
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_VC0_CREDIT_MASK 0x0000000000002000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_VC2_CREDIT                           */
-/*   Description:  VC2 Credit underflow                                 */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_VC2_CREDIT_SHFT 14
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_VC2_CREDIT_MASK 0x0000000000004000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_VC2_CREDIT                            */
-/*   Description:  VC2 Credit overflow                                  */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_VC2_CREDIT_SHFT 15
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_VC2_CREDIT_MASK 0x0000000000008000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_DATABUFF_VC0                          */
-/*   Description:  VC0 Data Buffer overflow                             */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_DATABUFF_VC0_SHFT 16
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_DATABUFF_VC0_MASK 0x0000000000010000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_DATABUFF_VC2                          */
-/*   Description:  VC2 Data Buffer overflow                             */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_DATABUFF_VC2_SHFT 17
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_DATABUFF_VC2_MASK 0x0000000000020000
-
-/*   SH_XNMD_FIRST_ERROR_LUT_READ_ERROR                                 */
-/*   Description:  LUT Read Error                                       */
-#define SH_XNMD_FIRST_ERROR_LUT_READ_ERROR_SHFT  18
-#define SH_XNMD_FIRST_ERROR_LUT_READ_ERROR_MASK  0x0000000000040000
-
-/*   SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR0                              */
-/*   Description:  Single Bit Error in Bits 63:0                        */
-#define SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR0_SHFT 19
-#define SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR0_MASK 0x0000000000080000
-
-/*   SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR1                              */
-/*   Description:  Single Bit Error in Bits 127:64                      */
-#define SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR1_SHFT 20
-#define SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR1_MASK 0x0000000000100000
-
-/*   SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR2                              */
-/*   Description:  Single Bit Error in Bits 191:128                     */
-#define SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR2_SHFT 21
-#define SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR2_MASK 0x0000000000200000
-
-/*   SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR3                              */
-/*   Description:  Single Bit Error in Bits 255:192                     */
-#define SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR3_SHFT 22
-#define SH_XNMD_FIRST_ERROR_SINGLE_BIT_ERROR3_MASK 0x0000000000400000
-
-/*   SH_XNMD_FIRST_ERROR_UNCOR_ERROR0                                   */
-/*   Description:  Uncorrectable Error in Bits 63:0                     */
-#define SH_XNMD_FIRST_ERROR_UNCOR_ERROR0_SHFT    23
-#define SH_XNMD_FIRST_ERROR_UNCOR_ERROR0_MASK    0x0000000000800000
-
-/*   SH_XNMD_FIRST_ERROR_UNCOR_ERROR1                                   */
-/*   Description:  Uncorrectable Error in Bits 127:64                   */
-#define SH_XNMD_FIRST_ERROR_UNCOR_ERROR1_SHFT    24
-#define SH_XNMD_FIRST_ERROR_UNCOR_ERROR1_MASK    0x0000000001000000
-
-/*   SH_XNMD_FIRST_ERROR_UNCOR_ERROR2                                   */
-/*   Description:  Uncorrectable Error in Bits 191:128                  */
-#define SH_XNMD_FIRST_ERROR_UNCOR_ERROR2_SHFT    25
-#define SH_XNMD_FIRST_ERROR_UNCOR_ERROR2_MASK    0x0000000002000000
-
-/*   SH_XNMD_FIRST_ERROR_UNCOR_ERROR3                                   */
-/*   Description:  Uncorrectable Error in Bits 255:192                  */
-#define SH_XNMD_FIRST_ERROR_UNCOR_ERROR3_SHFT    26
-#define SH_XNMD_FIRST_ERROR_UNCOR_ERROR3_MASK    0x0000000004000000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_SIC_CNTR0                            */
-/*   Description:  SIC Counter 0 Underflow                              */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_SIC_CNTR0_SHFT 27
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_SIC_CNTR0_MASK 0x0000000008000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_SIC_CNTR0                             */
-/*   Description:  SIC Counter 0 Overflow                               */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_SIC_CNTR0_SHFT 28
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_SIC_CNTR0_MASK 0x0000000010000000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_SIC_CNTR2                            */
-/*   Description:  SIC Counter 2 Underflow                              */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_SIC_CNTR2_SHFT 29
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_SIC_CNTR2_MASK 0x0000000020000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_SIC_CNTR2                             */
-/*   Description:  SIC Counter 2 Overflow                               */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_SIC_CNTR2_SHFT 30
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_SIC_CNTR2_MASK 0x0000000040000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_DEBIT0                            */
-/*   Description:  NI0 Debit 0 Overflow                                 */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_DEBIT0_SHFT 31
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_DEBIT0_MASK 0x0000000080000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_DEBIT2                            */
-/*   Description:  NI0 Debit 2 Overflow                                 */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_DEBIT2_SHFT 32
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_DEBIT2_MASK 0x0000000100000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_DEBIT0                            */
-/*   Description:  NI1 Debit 0 Overflow                                 */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_DEBIT0_SHFT 33
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_DEBIT0_MASK 0x0000000200000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_DEBIT2                            */
-/*   Description:  NI1 Debit 2 Overflow                                 */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_DEBIT2_SHFT 34
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_DEBIT2_MASK 0x0000000400000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_DEBIT0                           */
-/*   Description:  IILB Debit 0 Overflow                                */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_DEBIT0_SHFT 35
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_DEBIT0_MASK 0x0000000800000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_DEBIT2                           */
-/*   Description:  IILB Debit 2 Overflow                                */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_DEBIT2_SHFT 36
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_DEBIT2_MASK 0x0000001000000000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT                       */
-/*   Description:  NI0 VC0 Credit Underflow                             */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_SHFT 37
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC0_CREDIT_MASK 0x0000002000000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT                        */
-/*   Description:  NI0 VC0 Credit Overflow                              */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_SHFT 38
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC0_CREDIT_MASK 0x0000004000000000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT                       */
-/*   Description:  NI0 VC2 Credit Underflow                             */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_SHFT 39
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI0_VC2_CREDIT_MASK 0x0000008000000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT                        */
-/*   Description:  NI0 VC2 Credit Overflow                              */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_SHFT 40
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI0_VC2_CREDIT_MASK 0x0000010000000000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT                       */
-/*   Description:  NI1 VC0 Credit Underflow                             */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_SHFT 41
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC0_CREDIT_MASK 0x0000020000000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT                        */
-/*   Description:  NI1 VC0 Credit Overflow                              */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_SHFT 42
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC0_CREDIT_MASK 0x0000040000000000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT                       */
-/*   Description:  NI1 VC2 Credit Underflow                             */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_SHFT 43
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_NI1_VC2_CREDIT_MASK 0x0000080000000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT                        */
-/*   Description:  NI1 VC2 Credit Overflow                              */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_SHFT 44
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_NI1_VC2_CREDIT_MASK 0x0000100000000000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT                      */
-/*   Description:  IILB VC0 Credit Underflow                            */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_SHFT 45
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC0_CREDIT_MASK 0x0000200000000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT                       */
-/*   Description:  IILB VC0 Credit Overflow                             */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_SHFT 46
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC0_CREDIT_MASK 0x0000400000000000
-
-/*   SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT                      */
-/*   Description:  IILB VC2 Credit Underflow                            */
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_SHFT 47
-#define SH_XNMD_FIRST_ERROR_UNDERFLOW_IILB_VC2_CREDIT_MASK 0x0000800000000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT                       */
-/*   Description:  IILB VC2 Credit Overflow                             */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_SHFT 48
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_IILB_VC2_CREDIT_MASK 0x0001000000000000
-
-/*   SH_XNMD_FIRST_ERROR_OVERFLOW_HEADER_CANCEL_FIFO                    */
-/*   Description:  Header Cancel Fifo Overflow                          */
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_HEADER_CANCEL_FIFO_SHFT 49
-#define SH_XNMD_FIRST_ERROR_OVERFLOW_HEADER_CANCEL_FIFO_MASK 0x0002000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_AUTO_REPLY_ENABLE0"                   */
-/*                 Automatic Maintenance Reply Enable 0                 */
-/* ==================================================================== */
-
-#define SH_AUTO_REPLY_ENABLE0                    0x0000000110061000
-#define SH_AUTO_REPLY_ENABLE0_MASK               0xffffffffffffffff
-#define SH_AUTO_REPLY_ENABLE0_INIT               0x0000000000000000
-
-/*   SH_AUTO_REPLY_ENABLE0_ENABLE0                                      */
-/*   Description:  Enable 0                                             */
-#define SH_AUTO_REPLY_ENABLE0_ENABLE0_SHFT       0
-#define SH_AUTO_REPLY_ENABLE0_ENABLE0_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_AUTO_REPLY_ENABLE1"                   */
-/*                 Automatic Maintenance Reply Enable 1                 */
-/* ==================================================================== */
-
-#define SH_AUTO_REPLY_ENABLE1                    0x0000000110061080
-#define SH_AUTO_REPLY_ENABLE1_MASK               0xffffffffffffffff
-#define SH_AUTO_REPLY_ENABLE1_INIT               0x0000000000000000
-
-/*   SH_AUTO_REPLY_ENABLE1_ENABLE1                                      */
-/*   Description:  Enable 1                                             */
-#define SH_AUTO_REPLY_ENABLE1_ENABLE1_SHFT       0
-#define SH_AUTO_REPLY_ENABLE1_ENABLE1_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_AUTO_REPLY_HEADER0"                   */
-/*                 Automatic Maintenance Reply Header 0                 */
-/* ==================================================================== */
-
-#define SH_AUTO_REPLY_HEADER0                    0x0000000110061100
-#define SH_AUTO_REPLY_HEADER0_MASK               0xffffffffffffffff
-#define SH_AUTO_REPLY_HEADER0_INIT               0x0000000000000000
-
-/*   SH_AUTO_REPLY_HEADER0_HEADER0                                      */
-/*   Description:  Header 0                                             */
-#define SH_AUTO_REPLY_HEADER0_HEADER0_SHFT       0
-#define SH_AUTO_REPLY_HEADER0_HEADER0_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_AUTO_REPLY_HEADER1"                   */
-/*                 Automatic Maintenance Reply Header 1                 */
-/* ==================================================================== */
-
-#define SH_AUTO_REPLY_HEADER1                    0x0000000110061180
-#define SH_AUTO_REPLY_HEADER1_MASK               0xffffffffffffffff
-#define SH_AUTO_REPLY_HEADER1_INIT               0x0000000000000000
-
-/*   SH_AUTO_REPLY_HEADER1_HEADER1                                      */
-/*   Description:  Header 1                                             */
-#define SH_AUTO_REPLY_HEADER1_HEADER1_SHFT       0
-#define SH_AUTO_REPLY_HEADER1_HEADER1_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_ENABLE_RP_AUTO_REPLY"                  */
-/*         Enable Automatic Maintenance Reply From Reply Queue          */
-/* ==================================================================== */
-
-#define SH_ENABLE_RP_AUTO_REPLY                  0x0000000110061200
-#define SH_ENABLE_RP_AUTO_REPLY_MASK             0x0000000000000001
-#define SH_ENABLE_RP_AUTO_REPLY_INIT             0x0000000000000000
-
-/*   SH_ENABLE_RP_AUTO_REPLY_ENABLE                                     */
-/*   Description:  Enable Reply Auto Reply                              */
-#define SH_ENABLE_RP_AUTO_REPLY_ENABLE_SHFT      0
-#define SH_ENABLE_RP_AUTO_REPLY_ENABLE_MASK      0x0000000000000001
-
-/* ==================================================================== */
-/*                  Register "SH_ENABLE_RQ_AUTO_REPLY"                  */
-/*        Enable Automatic Maintenance Reply From Request Queue         */
-/* ==================================================================== */
-
-#define SH_ENABLE_RQ_AUTO_REPLY                  0x0000000110061280
-#define SH_ENABLE_RQ_AUTO_REPLY_MASK             0x0000000000000001
-#define SH_ENABLE_RQ_AUTO_REPLY_INIT             0x0000000000000000
-
-/*   SH_ENABLE_RQ_AUTO_REPLY_ENABLE                                     */
-/*   Description:  Enable Request Auto Reply                            */
-#define SH_ENABLE_RQ_AUTO_REPLY_ENABLE_SHFT      0
-#define SH_ENABLE_RQ_AUTO_REPLY_ENABLE_MASK      0x0000000000000001
-
-/* ==================================================================== */
-/*                     Register "SH_REDIRECT_INVAL"                     */
-/*               Redirect invalidate to LB instead of PI                */
-/* ==================================================================== */
-
-#define SH_REDIRECT_INVAL                        0x0000000110061300
-#define SH_REDIRECT_INVAL_MASK                   0x0000000000000001
-#define SH_REDIRECT_INVAL_INIT                   0x0000000000000000
-
-/*   SH_REDIRECT_INVAL_REDIRECT                                         */
-/*   Description:  Redirect invalidates to LB instead of PI             */
-#define SH_REDIRECT_INVAL_REDIRECT_SHFT          0
-#define SH_REDIRECT_INVAL_REDIRECT_MASK          0x0000000000000001
-
-/* ==================================================================== */
-/*                     Register "SH_DIAG_MSG_CNTRL"                     */
-/*                 Diagnostic Message Control Register                  */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_CNTRL                        0x0000000110062000
-#define SH_DIAG_MSG_CNTRL_MASK                   0xc000000000003fff
-#define SH_DIAG_MSG_CNTRL_INIT                   0x0000000000000000
-
-/*   SH_DIAG_MSG_CNTRL_MSG_LENGTH                                       */
-/*   Description:  Message data payload length, 0 - 63                  */
-#define SH_DIAG_MSG_CNTRL_MSG_LENGTH_SHFT        0
-#define SH_DIAG_MSG_CNTRL_MSG_LENGTH_MASK        0x000000000000003f
-
-/*   SH_DIAG_MSG_CNTRL_ERROR_INJECT_POINT                               */
-/*   Description:  Point message that the error bit would be activated  */
-#define SH_DIAG_MSG_CNTRL_ERROR_INJECT_POINT_SHFT 6
-#define SH_DIAG_MSG_CNTRL_ERROR_INJECT_POINT_MASK 0x0000000000000fc0
-
-/*   SH_DIAG_MSG_CNTRL_ERROR_INJECT_ENABLE                              */
-/*   Description:  Enable ERROR_INJECT_POINT field                      */
-#define SH_DIAG_MSG_CNTRL_ERROR_INJECT_ENABLE_SHFT 12
-#define SH_DIAG_MSG_CNTRL_ERROR_INJECT_ENABLE_MASK 0x0000000000001000
-
-/*   SH_DIAG_MSG_CNTRL_PORT                                             */
-/*   Description:  0 = request port, 1 = reply port                     */
-#define SH_DIAG_MSG_CNTRL_PORT_SHFT              13
-#define SH_DIAG_MSG_CNTRL_PORT_MASK              0x0000000000002000
-
-/*   SH_DIAG_MSG_CNTRL_START                                            */
-/*   Description:  Start                                                */
-#define SH_DIAG_MSG_CNTRL_START_SHFT             62
-#define SH_DIAG_MSG_CNTRL_START_MASK             0x4000000000000000
-
-/*   SH_DIAG_MSG_CNTRL_BUSY                                             */
-/*   Description:  Busy                                                 */
-#define SH_DIAG_MSG_CNTRL_BUSY_SHFT              63
-#define SH_DIAG_MSG_CNTRL_BUSY_MASK              0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA0L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA0L                       0x0000000110062080
-#define SH_DIAG_MSG_DATA0L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA0L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA0L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA0L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA0L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA0U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA0U                       0x0000000110062100
-#define SH_DIAG_MSG_DATA0U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA0U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA0U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA0U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA0U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA1L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA1L                       0x0000000110062180
-#define SH_DIAG_MSG_DATA1L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA1L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA1L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA1L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA1L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA1U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA1U                       0x0000000110062200
-#define SH_DIAG_MSG_DATA1U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA1U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA1U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA1U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA1U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA2L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA2L                       0x0000000110062280
-#define SH_DIAG_MSG_DATA2L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA2L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA2L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA2L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA2L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA2U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA2U                       0x0000000110062300
-#define SH_DIAG_MSG_DATA2U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA2U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA2U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA2U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA2U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA3L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA3L                       0x0000000110062380
-#define SH_DIAG_MSG_DATA3L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA3L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA3L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA3L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA3L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA3U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA3U                       0x0000000110062400
-#define SH_DIAG_MSG_DATA3U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA3U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA3U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA3U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA3U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA4L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA4L                       0x0000000110062480
-#define SH_DIAG_MSG_DATA4L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA4L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA4L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA4L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA4L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA4U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA4U                       0x0000000110062500
-#define SH_DIAG_MSG_DATA4U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA4U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA4U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA4U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA4U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA5L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA5L                       0x0000000110062580
-#define SH_DIAG_MSG_DATA5L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA5L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA5L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA5L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA5L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA5U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA5U                       0x0000000110062600
-#define SH_DIAG_MSG_DATA5U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA5U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA5U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA5U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA5U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA6L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA6L                       0x0000000110062680
-#define SH_DIAG_MSG_DATA6L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA6L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA6L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA6L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA6L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA6U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA6U                       0x0000000110062700
-#define SH_DIAG_MSG_DATA6U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA6U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA6U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA6U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA6U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA7L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA7L                       0x0000000110062780
-#define SH_DIAG_MSG_DATA7L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA7L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA7L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA7L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA7L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA7U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA7U                       0x0000000110062800
-#define SH_DIAG_MSG_DATA7U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA7U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA7U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA7U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA7U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA8L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA8L                       0x0000000110062880
-#define SH_DIAG_MSG_DATA8L_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA8L_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA8L_DATA_LOWER                                      */
-/*   Description:  Lower 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA8L_DATA_LOWER_SHFT       0
-#define SH_DIAG_MSG_DATA8L_DATA_LOWER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA8U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_DATA8U                       0x0000000110062900
-#define SH_DIAG_MSG_DATA8U_MASK                  0xffffffffffffffff
-#define SH_DIAG_MSG_DATA8U_INIT                  0x0000000000000000
-
-/*   SH_DIAG_MSG_DATA8U_DATA_UPPER                                      */
-/*   Description:  Upper 64 bits of Diagnositic Message Data            */
-#define SH_DIAG_MSG_DATA8U_DATA_UPPER_SHFT       0
-#define SH_DIAG_MSG_DATA8U_DATA_UPPER_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_DIAG_MSG_HDR0"                      */
-/*              Diagnostice Data, lower 64 bits of header               */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_HDR0                         0x0000000110062980
-#define SH_DIAG_MSG_HDR0_MASK                    0xffffffffffffffff
-#define SH_DIAG_MSG_HDR0_INIT                    0x0000000000000000
-
-/*   SH_DIAG_MSG_HDR0_HEADER0                                           */
-/*   Description:  Lower 64 bits of Diagnositic Message Header          */
-#define SH_DIAG_MSG_HDR0_HEADER0_SHFT            0
-#define SH_DIAG_MSG_HDR0_HEADER0_MASK            0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_DIAG_MSG_HDR1"                      */
-/*              Diagnostice Data, upper 64 bits of header               */
-/* ==================================================================== */
-
-#define SH_DIAG_MSG_HDR1                         0x0000000110062a00
-#define SH_DIAG_MSG_HDR1_MASK                    0xffffffffffffffff
-#define SH_DIAG_MSG_HDR1_INIT                    0x0000000000000000
-
-/*   SH_DIAG_MSG_HDR1_HEADER1                                           */
-/*   Description:  Upper 64 bits of Diagnositic Message Header          */
-#define SH_DIAG_MSG_HDR1_HEADER1_SHFT            0
-#define SH_DIAG_MSG_HDR1_HEADER1_MASK            0xffffffffffffffff
-
-/* ==================================================================== */
-/*                      Register "SH_DEBUG_SELECT"                      */
-/*                        SHub Debug Port Select                        */
-/* ==================================================================== */
-
-#define SH_DEBUG_SELECT                          0x0000000110063000
-#define SH_DEBUG_SELECT_MASK                     0x8fffffffffffffff
-#define SH_DEBUG_SELECT_INIT                     0x0000e38e38e38e38
-
-/*   SH_DEBUG_SELECT_NIBBLE0_NIBBLE_SEL                                 */
-/*   Description:  Nibble0_nibble_select                                */
-#define SH_DEBUG_SELECT_NIBBLE0_NIBBLE_SEL_SHFT  0
-#define SH_DEBUG_SELECT_NIBBLE0_NIBBLE_SEL_MASK  0x0000000000000007
-
-/*   SH_DEBUG_SELECT_NIBBLE0_CHIPLET_SEL                                */
-/*   Description:  Nibble0_chiplet_select                               */
-#define SH_DEBUG_SELECT_NIBBLE0_CHIPLET_SEL_SHFT 3
-#define SH_DEBUG_SELECT_NIBBLE0_CHIPLET_SEL_MASK 0x0000000000000038
-
-/*   SH_DEBUG_SELECT_NIBBLE1_NIBBLE_SEL                                 */
-/*   Description:  Nibble1_nibble_select                                */
-#define SH_DEBUG_SELECT_NIBBLE1_NIBBLE_SEL_SHFT  6
-#define SH_DEBUG_SELECT_NIBBLE1_NIBBLE_SEL_MASK  0x00000000000001c0
-
-/*   SH_DEBUG_SELECT_NIBBLE1_CHIPLET_SEL                                */
-/*   Description:  Nibble1_chiplet_select                               */
-#define SH_DEBUG_SELECT_NIBBLE1_CHIPLET_SEL_SHFT 9
-#define SH_DEBUG_SELECT_NIBBLE1_CHIPLET_SEL_MASK 0x0000000000000e00
-
-/*   SH_DEBUG_SELECT_NIBBLE2_NIBBLE_SEL                                 */
-/*   Description:  Nibble2_nibble_select                                */
-#define SH_DEBUG_SELECT_NIBBLE2_NIBBLE_SEL_SHFT  12
-#define SH_DEBUG_SELECT_NIBBLE2_NIBBLE_SEL_MASK  0x0000000000007000
-
-/*   SH_DEBUG_SELECT_NIBBLE2_CHIPLET_SEL                                */
-/*   Description:  Nibble2_chiplet_select                               */
-#define SH_DEBUG_SELECT_NIBBLE2_CHIPLET_SEL_SHFT 15
-#define SH_DEBUG_SELECT_NIBBLE2_CHIPLET_SEL_MASK 0x0000000000038000
-
-/*   SH_DEBUG_SELECT_NIBBLE3_NIBBLE_SEL                                 */
-/*   Description:  Nibble3_nibble_select                                */
-#define SH_DEBUG_SELECT_NIBBLE3_NIBBLE_SEL_SHFT  18
-#define SH_DEBUG_SELECT_NIBBLE3_NIBBLE_SEL_MASK  0x00000000001c0000
-
-/*   SH_DEBUG_SELECT_NIBBLE3_CHIPLET_SEL                                */
-/*   Description:  Nibble3_chiplet_select                               */
-#define SH_DEBUG_SELECT_NIBBLE3_CHIPLET_SEL_SHFT 21
-#define SH_DEBUG_SELECT_NIBBLE3_CHIPLET_SEL_MASK 0x0000000000e00000
-
-/*   SH_DEBUG_SELECT_NIBBLE4_NIBBLE_SEL                                 */
-/*   Description:  Nibble4_nibble_select                                */
-#define SH_DEBUG_SELECT_NIBBLE4_NIBBLE_SEL_SHFT  24
-#define SH_DEBUG_SELECT_NIBBLE4_NIBBLE_SEL_MASK  0x0000000007000000
-
-/*   SH_DEBUG_SELECT_NIBBLE4_CHIPLET_SEL                                */
-/*   Description:  Nibble4_chiplet_select                               */
-#define SH_DEBUG_SELECT_NIBBLE4_CHIPLET_SEL_SHFT 27
-#define SH_DEBUG_SELECT_NIBBLE4_CHIPLET_SEL_MASK 0x0000000038000000
-
-/*   SH_DEBUG_SELECT_NIBBLE5_NIBBLE_SEL                                 */
-/*   Description:  Nibble5_nibble_select                                */
-#define SH_DEBUG_SELECT_NIBBLE5_NIBBLE_SEL_SHFT  30
-#define SH_DEBUG_SELECT_NIBBLE5_NIBBLE_SEL_MASK  0x00000001c0000000
-
-/*   SH_DEBUG_SELECT_NIBBLE5_CHIPLET_SEL                                */
-/*   Description:  Nibble5_chiplet_select                               */
-#define SH_DEBUG_SELECT_NIBBLE5_CHIPLET_SEL_SHFT 33
-#define SH_DEBUG_SELECT_NIBBLE5_CHIPLET_SEL_MASK 0x0000000e00000000
-
-/*   SH_DEBUG_SELECT_NIBBLE6_NIBBLE_SEL                                 */
-/*   Description:  Nibble6_nibble_select                                */
-#define SH_DEBUG_SELECT_NIBBLE6_NIBBLE_SEL_SHFT  36
-#define SH_DEBUG_SELECT_NIBBLE6_NIBBLE_SEL_MASK  0x0000007000000000
-
-/*   SH_DEBUG_SELECT_NIBBLE6_CHIPLET_SEL                                */
-/*   Description:  Nibble6_chiplet_select                               */
-#define SH_DEBUG_SELECT_NIBBLE6_CHIPLET_SEL_SHFT 39
-#define SH_DEBUG_SELECT_NIBBLE6_CHIPLET_SEL_MASK 0x0000038000000000
-
-/*   SH_DEBUG_SELECT_NIBBLE7_NIBBLE_SEL                                 */
-/*   Description:  Nibble7_nibble_select                                */
-#define SH_DEBUG_SELECT_NIBBLE7_NIBBLE_SEL_SHFT  42
-#define SH_DEBUG_SELECT_NIBBLE7_NIBBLE_SEL_MASK  0x00001c0000000000
-
-/*   SH_DEBUG_SELECT_NIBBLE7_CHIPLET_SEL                                */
-/*   Description:  Nibble7_chiplet_select                               */
-#define SH_DEBUG_SELECT_NIBBLE7_CHIPLET_SEL_SHFT 45
-#define SH_DEBUG_SELECT_NIBBLE7_CHIPLET_SEL_MASK 0x0000e00000000000
-
-/*   SH_DEBUG_SELECT_DEBUG_II_SEL                                       */
-/*   Description:  Select bits to II port                               */
-#define SH_DEBUG_SELECT_DEBUG_II_SEL_SHFT        48
-#define SH_DEBUG_SELECT_DEBUG_II_SEL_MASK        0x0007000000000000
-
-/*   SH_DEBUG_SELECT_SEL_II                                             */
-/*   Description:  Select II to debug port                              */
-#define SH_DEBUG_SELECT_SEL_II_SHFT              51
-#define SH_DEBUG_SELECT_SEL_II_MASK              0x0ff8000000000000
-
-/*   SH_DEBUG_SELECT_TRIGGER_ENABLE                                     */
-/*   Description:  Enable trigger on bit 32 of Analyzer data            */
-#define SH_DEBUG_SELECT_TRIGGER_ENABLE_SHFT      63
-#define SH_DEBUG_SELECT_TRIGGER_ENABLE_MASK      0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_TRIGGER_COMPARE_MASK"                  */
-/*                      SHub Trigger Compare Mask                       */
-/* ==================================================================== */
-
-#define SH_TRIGGER_COMPARE_MASK                  0x0000000110063080
-#define SH_TRIGGER_COMPARE_MASK_MASK             0x00000000ffffffff
-#define SH_TRIGGER_COMPARE_MASK_INIT             0x0000000000000000
-
-/*   SH_TRIGGER_COMPARE_MASK_MASK                                       */
-/*   Description:  SHub Trigger Compare Mask                            */
-#define SH_TRIGGER_COMPARE_MASK_MASK_SHFT        0
-#define SH_TRIGGER_COMPARE_MASK_MASK_MASK        0x00000000ffffffff
-
-/* ==================================================================== */
-/*                Register "SH_TRIGGER_COMPARE_PATTERN"                 */
-/*                     SHub Trigger Compare Pattern                     */
-/* ==================================================================== */
-
-#define SH_TRIGGER_COMPARE_PATTERN               0x0000000110063100
-#define SH_TRIGGER_COMPARE_PATTERN_MASK          0x00000000ffffffff
-#define SH_TRIGGER_COMPARE_PATTERN_INIT          0x0000000000000000
-
-/*   SH_TRIGGER_COMPARE_PATTERN_DATA                                    */
-/*   Description:  SHub Trigger Compare Pattern                         */
-#define SH_TRIGGER_COMPARE_PATTERN_DATA_SHFT     0
-#define SH_TRIGGER_COMPARE_PATTERN_DATA_MASK     0x00000000ffffffff
-
-/* ==================================================================== */
-/*                      Register "SH_TRIGGER_SEL"                       */
-/*                  Trigger select for SHUB debug port                  */
-/* ==================================================================== */
-
-#define SH_TRIGGER_SEL                           0x0000000110063180
-#define SH_TRIGGER_SEL_MASK                      0x7777777777777777
-#define SH_TRIGGER_SEL_INIT                      0x0000000000000000
-
-/*   SH_TRIGGER_SEL_NIBBLE0_INPUT_SEL                                   */
-/*   Description:  Nibble 0 input select                                */
-#define SH_TRIGGER_SEL_NIBBLE0_INPUT_SEL_SHFT    0
-#define SH_TRIGGER_SEL_NIBBLE0_INPUT_SEL_MASK    0x0000000000000007
-
-/*   SH_TRIGGER_SEL_NIBBLE0_NIBBLE_SEL                                  */
-/*   Description:  Nibble 0 Nibble select                               */
-#define SH_TRIGGER_SEL_NIBBLE0_NIBBLE_SEL_SHFT   4
-#define SH_TRIGGER_SEL_NIBBLE0_NIBBLE_SEL_MASK   0x0000000000000070
-
-/*   SH_TRIGGER_SEL_NIBBLE1_INPUT_SEL                                   */
-/*   Description:  Nibble 1 input select                                */
-#define SH_TRIGGER_SEL_NIBBLE1_INPUT_SEL_SHFT    8
-#define SH_TRIGGER_SEL_NIBBLE1_INPUT_SEL_MASK    0x0000000000000700
-
-/*   SH_TRIGGER_SEL_NIBBLE1_NIBBLE_SEL                                  */
-/*   Description:  Nibble 1 Nibble select                               */
-#define SH_TRIGGER_SEL_NIBBLE1_NIBBLE_SEL_SHFT   12
-#define SH_TRIGGER_SEL_NIBBLE1_NIBBLE_SEL_MASK   0x0000000000007000
-
-/*   SH_TRIGGER_SEL_NIBBLE2_INPUT_SEL                                   */
-/*   Description:  Nibble 2 input select                                */
-#define SH_TRIGGER_SEL_NIBBLE2_INPUT_SEL_SHFT    16
-#define SH_TRIGGER_SEL_NIBBLE2_INPUT_SEL_MASK    0x0000000000070000
-
-/*   SH_TRIGGER_SEL_NIBBLE2_NIBBLE_SEL                                  */
-/*   Description:  Nibble 2 Nibble select                               */
-#define SH_TRIGGER_SEL_NIBBLE2_NIBBLE_SEL_SHFT   20
-#define SH_TRIGGER_SEL_NIBBLE2_NIBBLE_SEL_MASK   0x0000000000700000
-
-/*   SH_TRIGGER_SEL_NIBBLE3_INPUT_SEL                                   */
-/*   Description:  Nibble 3 input select                                */
-#define SH_TRIGGER_SEL_NIBBLE3_INPUT_SEL_SHFT    24
-#define SH_TRIGGER_SEL_NIBBLE3_INPUT_SEL_MASK    0x0000000007000000
-
-/*   SH_TRIGGER_SEL_NIBBLE3_NIBBLE_SEL                                  */
-/*   Description:  Nibble 3 Nibble select                               */
-#define SH_TRIGGER_SEL_NIBBLE3_NIBBLE_SEL_SHFT   28
-#define SH_TRIGGER_SEL_NIBBLE3_NIBBLE_SEL_MASK   0x0000000070000000
-
-/*   SH_TRIGGER_SEL_NIBBLE4_INPUT_SEL                                   */
-/*   Description:  Nibble 4 input select                                */
-#define SH_TRIGGER_SEL_NIBBLE4_INPUT_SEL_SHFT    32
-#define SH_TRIGGER_SEL_NIBBLE4_INPUT_SEL_MASK    0x0000000700000000
-
-/*   SH_TRIGGER_SEL_NIBBLE4_NIBBLE_SEL                                  */
-/*   Description:  Nibble 4 Nibble select                               */
-#define SH_TRIGGER_SEL_NIBBLE4_NIBBLE_SEL_SHFT   36
-#define SH_TRIGGER_SEL_NIBBLE4_NIBBLE_SEL_MASK   0x0000007000000000
-
-/*   SH_TRIGGER_SEL_NIBBLE5_INPUT_SEL                                   */
-/*   Description:  Nibble 5 input select                                */
-#define SH_TRIGGER_SEL_NIBBLE5_INPUT_SEL_SHFT    40
-#define SH_TRIGGER_SEL_NIBBLE5_INPUT_SEL_MASK    0x0000070000000000
-
-/*   SH_TRIGGER_SEL_NIBBLE5_NIBBLE_SEL                                  */
-/*   Description:  Nibble 5 Nibble select                               */
-#define SH_TRIGGER_SEL_NIBBLE5_NIBBLE_SEL_SHFT   44
-#define SH_TRIGGER_SEL_NIBBLE5_NIBBLE_SEL_MASK   0x0000700000000000
-
-/*   SH_TRIGGER_SEL_NIBBLE6_INPUT_SEL                                   */
-/*   Description:  Nibble 6 input select                                */
-#define SH_TRIGGER_SEL_NIBBLE6_INPUT_SEL_SHFT    48
-#define SH_TRIGGER_SEL_NIBBLE6_INPUT_SEL_MASK    0x0007000000000000
-
-/*   SH_TRIGGER_SEL_NIBBLE6_NIBBLE_SEL                                  */
-/*   Description:  Nibble 6 Nibble select                               */
-#define SH_TRIGGER_SEL_NIBBLE6_NIBBLE_SEL_SHFT   52
-#define SH_TRIGGER_SEL_NIBBLE6_NIBBLE_SEL_MASK   0x0070000000000000
-
-/*   SH_TRIGGER_SEL_NIBBLE7_INPUT_SEL                                   */
-/*   Description:  Nibble 7 input select                                */
-#define SH_TRIGGER_SEL_NIBBLE7_INPUT_SEL_SHFT    56
-#define SH_TRIGGER_SEL_NIBBLE7_INPUT_SEL_MASK    0x0700000000000000
-
-/*   SH_TRIGGER_SEL_NIBBLE7_NIBBLE_SEL                                  */
-/*   Description:  Nibble 7 Nibble select                               */
-#define SH_TRIGGER_SEL_NIBBLE7_NIBBLE_SEL_SHFT   60
-#define SH_TRIGGER_SEL_NIBBLE7_NIBBLE_SEL_MASK   0x7000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_STOP_CLK_CONTROL"                    */
-/*                          Stop Clock Control                          */
-/* ==================================================================== */
-
-#define SH_STOP_CLK_CONTROL                      0x0000000110064000
-#define SH_STOP_CLK_CONTROL_MASK                 0x00000000000000ff
-#define SH_STOP_CLK_CONTROL_INIT                 0x00000000000000e0
-
-/*   SH_STOP_CLK_CONTROL_STIMULUS                                       */
-/*   Description:  Counter stimulus                                     */
-#define SH_STOP_CLK_CONTROL_STIMULUS_SHFT        0
-#define SH_STOP_CLK_CONTROL_STIMULUS_MASK        0x000000000000001f
-
-/*   SH_STOP_CLK_CONTROL_EVENT                                          */
-/*   Description:  Counter event select (0-greater than, 1-equal)       */
-#define SH_STOP_CLK_CONTROL_EVENT_SHFT           5
-#define SH_STOP_CLK_CONTROL_EVENT_MASK           0x0000000000000020
-
-/*   SH_STOP_CLK_CONTROL_POLARITY                                       */
-/*   Description:  Counter polarity select (0-negative edge, 1-positiv  */
-/*  e edge)                                                             */
-#define SH_STOP_CLK_CONTROL_POLARITY_SHFT        6
-#define SH_STOP_CLK_CONTROL_POLARITY_MASK        0x0000000000000040
-
-/*   SH_STOP_CLK_CONTROL_MODE                                           */
-/*   Description:  Counter mode select (0-internal, 1-external)         */
-#define SH_STOP_CLK_CONTROL_MODE_SHFT            7
-#define SH_STOP_CLK_CONTROL_MODE_MASK            0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_STOP_CLK_DELAY_PHASE"                  */
-/*                        Stop Clock Delay Phase                        */
-/* ==================================================================== */
-
-#define SH_STOP_CLK_DELAY_PHASE                  0x0000000110064080
-#define SH_STOP_CLK_DELAY_PHASE_MASK             0x00000000000000ff
-#define SH_STOP_CLK_DELAY_PHASE_INIT             0x0000000000000000
-
-/*   SH_STOP_CLK_DELAY_PHASE_DELAY                                      */
-/*   Description:  Delay phase                                          */
-#define SH_STOP_CLK_DELAY_PHASE_DELAY_SHFT       0
-#define SH_STOP_CLK_DELAY_PHASE_DELAY_MASK       0x00000000000000ff
-
-/* ==================================================================== */
-/*                      Register "SH_TSF_ARM_MASK"                      */
-/*                 Trigger sequencing facility arm mask                 */
-/* ==================================================================== */
-
-#define SH_TSF_ARM_MASK                          0x0000000110065000
-#define SH_TSF_ARM_MASK_MASK                     0xffffffffffffffff
-#define SH_TSF_ARM_MASK_INIT                     0x0000000000000000
-
-/*   SH_TSF_ARM_MASK_MASK                                               */
-/*   Description:  Trigger sequencing facility arm mask                 */
-#define SH_TSF_ARM_MASK_MASK_SHFT                0
-#define SH_TSF_ARM_MASK_MASK_MASK                0xffffffffffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_TSF_COUNTER_PRESETS"                   */
-/*             Trigger sequencing facility counter presets              */
-/* ==================================================================== */
-
-#define SH_TSF_COUNTER_PRESETS                   0x0000000110065080
-#define SH_TSF_COUNTER_PRESETS_MASK              0xffffffffffffffff
-#define SH_TSF_COUNTER_PRESETS_INIT              0x0000000000000000
-
-/*   SH_TSF_COUNTER_PRESETS_COUNT_32                                    */
-/*   Description:  Trigger sequencing facility counter 32               */
-#define SH_TSF_COUNTER_PRESETS_COUNT_32_SHFT     0
-#define SH_TSF_COUNTER_PRESETS_COUNT_32_MASK     0x00000000ffffffff
-
-/*   SH_TSF_COUNTER_PRESETS_COUNT_16                                    */
-/*   Description:  Trigger sequencing facility counter 16               */
-#define SH_TSF_COUNTER_PRESETS_COUNT_16_SHFT     32
-#define SH_TSF_COUNTER_PRESETS_COUNT_16_MASK     0x0000ffff00000000
-
-/*   SH_TSF_COUNTER_PRESETS_COUNT_8B                                    */
-/*   Description:  Trigger sequencing facility counter 8b               */
-#define SH_TSF_COUNTER_PRESETS_COUNT_8B_SHFT     48
-#define SH_TSF_COUNTER_PRESETS_COUNT_8B_MASK     0x00ff000000000000
-
-/*   SH_TSF_COUNTER_PRESETS_COUNT_8A                                    */
-/*   Description:  Trigger sequencing facility counter 8a               */
-#define SH_TSF_COUNTER_PRESETS_COUNT_8A_SHFT     56
-#define SH_TSF_COUNTER_PRESETS_COUNT_8A_MASK     0xff00000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_TSF_DECREMENT_CTL"                    */
-/*        Trigger sequencing facility counter decrement control         */
-/* ==================================================================== */
-
-#define SH_TSF_DECREMENT_CTL                     0x0000000110065100
-#define SH_TSF_DECREMENT_CTL_MASK                0x000000000000ffff
-#define SH_TSF_DECREMENT_CTL_INIT                0x0000000000000000
-
-/*   SH_TSF_DECREMENT_CTL_CTL                                           */
-/*   Description:  Trigger sequencing facility counter decrement contr  */
-#define SH_TSF_DECREMENT_CTL_CTL_SHFT            0
-#define SH_TSF_DECREMENT_CTL_CTL_MASK            0x000000000000ffff
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_DIAG_MSG_CTL"                    */
-/*        Trigger sequencing facility diagnostic message control        */
-/* ==================================================================== */
-
-#define SH_TSF_DIAG_MSG_CTL                      0x0000000110065180
-#define SH_TSF_DIAG_MSG_CTL_MASK                 0x00000000000000ff
-#define SH_TSF_DIAG_MSG_CTL_INIT                 0x0000000000000000
-
-/*   SH_TSF_DIAG_MSG_CTL_ENABLE                                         */
-/*   Description:  Trigger sequencing facility diagnostic message cont  */
-#define SH_TSF_DIAG_MSG_CTL_ENABLE_SHFT          0
-#define SH_TSF_DIAG_MSG_CTL_ENABLE_MASK          0x00000000000000ff
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_DISARM_MASK"                     */
-/*               Trigger sequencing facility disarm mask                */
-/* ==================================================================== */
-
-#define SH_TSF_DISARM_MASK                       0x0000000110065200
-#define SH_TSF_DISARM_MASK_MASK                  0xffffffffffffffff
-#define SH_TSF_DISARM_MASK_INIT                  0x0000000000000000
-
-/*   SH_TSF_DISARM_MASK_MASK                                            */
-/*   Description:  Trigger sequencing facility disarm mask              */
-#define SH_TSF_DISARM_MASK_MASK_SHFT             0
-#define SH_TSF_DISARM_MASK_MASK_MASK             0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_TSF_ENABLE_CTL"                     */
-/*          Trigger sequencing facility counter enable control          */
-/* ==================================================================== */
-
-#define SH_TSF_ENABLE_CTL                        0x0000000110065280
-#define SH_TSF_ENABLE_CTL_MASK                   0x000000000000ffff
-#define SH_TSF_ENABLE_CTL_INIT                   0x0000000000000000
-
-/*   SH_TSF_ENABLE_CTL_CTL                                              */
-/*   Description:  Trigger sequencing facility counter enable control  */
-#define SH_TSF_ENABLE_CTL_CTL_SHFT               0
-#define SH_TSF_ENABLE_CTL_CTL_MASK               0x000000000000ffff
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_SOFTWARE_ARM"                    */
-/*               Trigger sequencing facility software arm               */
-/* ==================================================================== */
-
-#define SH_TSF_SOFTWARE_ARM                      0x0000000110065300
-#define SH_TSF_SOFTWARE_ARM_MASK                 0x00000000000000ff
-#define SH_TSF_SOFTWARE_ARM_INIT                 0x0000000000000000
-
-/*   SH_TSF_SOFTWARE_ARM_BIT0                                           */
-/*   Description:  Trigger sequencing facility software arm bit 0       */
-#define SH_TSF_SOFTWARE_ARM_BIT0_SHFT            0
-#define SH_TSF_SOFTWARE_ARM_BIT0_MASK            0x0000000000000001
-
-/*   SH_TSF_SOFTWARE_ARM_BIT1                                           */
-/*   Description:  Trigger sequencing facility software arm bit 1       */
-#define SH_TSF_SOFTWARE_ARM_BIT1_SHFT            1
-#define SH_TSF_SOFTWARE_ARM_BIT1_MASK            0x0000000000000002
-
-/*   SH_TSF_SOFTWARE_ARM_BIT2                                           */
-/*   Description:  Trigger sequencing facility software arm bit 2       */
-#define SH_TSF_SOFTWARE_ARM_BIT2_SHFT            2
-#define SH_TSF_SOFTWARE_ARM_BIT2_MASK            0x0000000000000004
-
-/*   SH_TSF_SOFTWARE_ARM_BIT3                                           */
-/*   Description:  Trigger sequencing facility software arm bit 3       */
-#define SH_TSF_SOFTWARE_ARM_BIT3_SHFT            3
-#define SH_TSF_SOFTWARE_ARM_BIT3_MASK            0x0000000000000008
-
-/*   SH_TSF_SOFTWARE_ARM_BIT4                                           */
-/*   Description:  Trigger sequencing facility software arm bit 4       */
-#define SH_TSF_SOFTWARE_ARM_BIT4_SHFT            4
-#define SH_TSF_SOFTWARE_ARM_BIT4_MASK            0x0000000000000010
-
-/*   SH_TSF_SOFTWARE_ARM_BIT5                                           */
-/*   Description:  Trigger sequencing facility software arm bit 5       */
-#define SH_TSF_SOFTWARE_ARM_BIT5_SHFT            5
-#define SH_TSF_SOFTWARE_ARM_BIT5_MASK            0x0000000000000020
-
-/*   SH_TSF_SOFTWARE_ARM_BIT6                                           */
-/*   Description:  Trigger sequencing facility software arm bit 6       */
-#define SH_TSF_SOFTWARE_ARM_BIT6_SHFT            6
-#define SH_TSF_SOFTWARE_ARM_BIT6_MASK            0x0000000000000040
-
-/*   SH_TSF_SOFTWARE_ARM_BIT7                                           */
-/*   Description:  Trigger sequencing facility software arm bit 7       */
-#define SH_TSF_SOFTWARE_ARM_BIT7_SHFT            7
-#define SH_TSF_SOFTWARE_ARM_BIT7_MASK            0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_TSF_SOFTWARE_DISARM"                   */
-/*             Trigger sequencing facility software disarm              */
-/* ==================================================================== */
-
-#define SH_TSF_SOFTWARE_DISARM                   0x0000000110065380
-#define SH_TSF_SOFTWARE_DISARM_MASK              0x00000000000000ff
-#define SH_TSF_SOFTWARE_DISARM_INIT              0x0000000000000000
-
-/*   SH_TSF_SOFTWARE_DISARM_BIT0                                        */
-/*   Description:  Trigger sequencing facility software disarm bit 0    */
-#define SH_TSF_SOFTWARE_DISARM_BIT0_SHFT         0
-#define SH_TSF_SOFTWARE_DISARM_BIT0_MASK         0x0000000000000001
-
-/*   SH_TSF_SOFTWARE_DISARM_BIT1                                        */
-/*   Description:  Trigger sequencing facility software disarm bit 1    */
-#define SH_TSF_SOFTWARE_DISARM_BIT1_SHFT         1
-#define SH_TSF_SOFTWARE_DISARM_BIT1_MASK         0x0000000000000002
-
-/*   SH_TSF_SOFTWARE_DISARM_BIT2                                        */
-/*   Description:  Trigger sequencing facility software disarm bit 2    */
-#define SH_TSF_SOFTWARE_DISARM_BIT2_SHFT         2
-#define SH_TSF_SOFTWARE_DISARM_BIT2_MASK         0x0000000000000004
-
-/*   SH_TSF_SOFTWARE_DISARM_BIT3                                        */
-/*   Description:  Trigger sequencing facility software disarm bit 3    */
-#define SH_TSF_SOFTWARE_DISARM_BIT3_SHFT         3
-#define SH_TSF_SOFTWARE_DISARM_BIT3_MASK         0x0000000000000008
-
-/*   SH_TSF_SOFTWARE_DISARM_BIT4                                        */
-/*   Description:  Trigger sequencing facility software disarm bit 4    */
-#define SH_TSF_SOFTWARE_DISARM_BIT4_SHFT         4
-#define SH_TSF_SOFTWARE_DISARM_BIT4_MASK         0x0000000000000010
-
-/*   SH_TSF_SOFTWARE_DISARM_BIT5                                        */
-/*   Description:  Trigger sequencing facility software disarm bit 5    */
-#define SH_TSF_SOFTWARE_DISARM_BIT5_SHFT         5
-#define SH_TSF_SOFTWARE_DISARM_BIT5_MASK         0x0000000000000020
-
-/*   SH_TSF_SOFTWARE_DISARM_BIT6                                        */
-/*   Description:  Trigger sequencing facility software disarm bit 6    */
-#define SH_TSF_SOFTWARE_DISARM_BIT6_SHFT         6
-#define SH_TSF_SOFTWARE_DISARM_BIT6_MASK         0x0000000000000040
-
-/*   SH_TSF_SOFTWARE_DISARM_BIT7                                        */
-/*   Description:  Trigger sequencing facility software disarm bit 7    */
-#define SH_TSF_SOFTWARE_DISARM_BIT7_SHFT         7
-#define SH_TSF_SOFTWARE_DISARM_BIT7_MASK         0x0000000000000080
-
-/* ==================================================================== */
-/*                 Register "SH_TSF_SOFTWARE_TRIGGERED"                 */
-/*            Trigger sequencing facility software triggered            */
-/* ==================================================================== */
-
-#define SH_TSF_SOFTWARE_TRIGGERED                0x0000000110065400
-#define SH_TSF_SOFTWARE_TRIGGERED_MASK           0x00000000000000ff
-#define SH_TSF_SOFTWARE_TRIGGERED_INIT           0x0000000000000000
-
-/*   SH_TSF_SOFTWARE_TRIGGERED_BIT0                                     */
-/*   Description:  Trigger sequencing facility software triggered bit   */
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT0_SHFT      0
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT0_MASK      0x0000000000000001
-
-/*   SH_TSF_SOFTWARE_TRIGGERED_BIT1                                     */
-/*   Description:  Trigger sequencing facility software triggered bit   */
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT1_SHFT      1
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT1_MASK      0x0000000000000002
-
-/*   SH_TSF_SOFTWARE_TRIGGERED_BIT2                                     */
-/*   Description:  Trigger sequencing facility software triggered bit   */
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT2_SHFT      2
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT2_MASK      0x0000000000000004
-
-/*   SH_TSF_SOFTWARE_TRIGGERED_BIT3                                     */
-/*   Description:  Trigger sequencing facility software triggered bit   */
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT3_SHFT      3
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT3_MASK      0x0000000000000008
-
-/*   SH_TSF_SOFTWARE_TRIGGERED_BIT4                                     */
-/*   Description:  Trigger sequencing facility software triggered bit   */
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT4_SHFT      4
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT4_MASK      0x0000000000000010
-
-/*   SH_TSF_SOFTWARE_TRIGGERED_BIT5                                     */
-/*   Description:  Trigger sequencing facility software triggered bit   */
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT5_SHFT      5
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT5_MASK      0x0000000000000020
-
-/*   SH_TSF_SOFTWARE_TRIGGERED_BIT6                                     */
-/*   Description:  Trigger sequencing facility software triggered bit   */
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT6_SHFT      6
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT6_MASK      0x0000000000000040
-
-/*   SH_TSF_SOFTWARE_TRIGGERED_BIT7                                     */
-/*   Description:  Trigger sequencing facility software triggered bit   */
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT7_SHFT      7
-#define SH_TSF_SOFTWARE_TRIGGERED_BIT7_MASK      0x0000000000000080
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_TRIGGER_MASK"                    */
-/*               Trigger sequencing facility trigger mask               */
-/* ==================================================================== */
-
-#define SH_TSF_TRIGGER_MASK                      0x0000000110065480
-#define SH_TSF_TRIGGER_MASK_MASK                 0xffffffffffffffff
-#define SH_TSF_TRIGGER_MASK_INIT                 0x0000000000000000
-
-/*   SH_TSF_TRIGGER_MASK_MASK                                           */
-/*   Description:  Trigger sequencing facility trigger mask             */
-#define SH_TSF_TRIGGER_MASK_MASK_SHFT            0
-#define SH_TSF_TRIGGER_MASK_MASK_MASK            0xffffffffffffffff
-
-/* ==================================================================== */
-/*                        Register "SH_VEC_DATA"                        */
-/*                  Vector Write Request Message Data                   */
-/* ==================================================================== */
-
-#define SH_VEC_DATA                              0x0000000110066000
-#define SH_VEC_DATA_MASK                         0xffffffffffffffff
-#define SH_VEC_DATA_INIT                         0x0000000000000000
-
-/*   SH_VEC_DATA_DATA                                                   */
-/*   Description:  Data                                                 */
-#define SH_VEC_DATA_DATA_SHFT                    0
-#define SH_VEC_DATA_DATA_MASK                    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_PARMS"                        */
-/*                  Vector Message Parameters Register                  */
-/* ==================================================================== */
-
-#define SH_VEC_PARMS                             0x0000000110066080
-#define SH_VEC_PARMS_MASK                        0xc0003ffffffffffb
-#define SH_VEC_PARMS_INIT                        0x0000000000000000
-
-/*   SH_VEC_PARMS_TYPE                                                  */
-/*   Description:  Vector Request Message Type                          */
-#define SH_VEC_PARMS_TYPE_SHFT                   0
-#define SH_VEC_PARMS_TYPE_MASK                   0x0000000000000001
-
-/*   SH_VEC_PARMS_NI_PORT                                               */
-/*   Description:  Network Interface Port Select                        */
-#define SH_VEC_PARMS_NI_PORT_SHFT                1
-#define SH_VEC_PARMS_NI_PORT_MASK                0x0000000000000002
-
-/*   SH_VEC_PARMS_ADDRESS                                               */
-/*   Description:  Address[37:6]                                        */
-#define SH_VEC_PARMS_ADDRESS_SHFT                3
-#define SH_VEC_PARMS_ADDRESS_MASK                0x00000007fffffff8
-
-/*   SH_VEC_PARMS_PIO_ID                                                */
-/*   Description:  PIO ID                                               */
-#define SH_VEC_PARMS_PIO_ID_SHFT                 35
-#define SH_VEC_PARMS_PIO_ID_MASK                 0x00003ff800000000
-
-/*   SH_VEC_PARMS_START                                                 */
-/*   Description:  Start                                                */
-#define SH_VEC_PARMS_START_SHFT                  62
-#define SH_VEC_PARMS_START_MASK                  0x4000000000000000
-
-/*   SH_VEC_PARMS_BUSY                                                  */
-/*   Description:  Busy                                                 */
-#define SH_VEC_PARMS_BUSY_SHFT                   63
-#define SH_VEC_PARMS_BUSY_MASK                   0x8000000000000000
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_ROUTE"                        */
-/*                     Vector Request Message Route                     */
-/* ==================================================================== */
-
-#define SH_VEC_ROUTE                             0x0000000110066100
-#define SH_VEC_ROUTE_MASK                        0xffffffffffffffff
-#define SH_VEC_ROUTE_INIT                        0x0000000000000000
-
-/*   SH_VEC_ROUTE_ROUTE                                                 */
-/*   Description:  Route                                                */
-#define SH_VEC_ROUTE_ROUTE_SHFT                  0
-#define SH_VEC_ROUTE_ROUTE_MASK                  0xffffffffffffffff
-
-/* ==================================================================== */
-/*                        Register "SH_CPU_PERM"                        */
-/*                    CPU MMR Access Permission Bits                    */
-/* ==================================================================== */
-
-#define SH_CPU_PERM                              0x0000000110060000
-#define SH_CPU_PERM_MASK                         0xffffffffffffffff
-#define SH_CPU_PERM_INIT                         0xffffffffffffffff
-
-/*   SH_CPU_PERM_ACCESS_BITS                                            */
-/*   Description:  Access Bits                                          */
-#define SH_CPU_PERM_ACCESS_BITS_SHFT             0
-#define SH_CPU_PERM_ACCESS_BITS_MASK             0xffffffffffffffff
-
-/* ==================================================================== */
-/*                      Register "SH_CPU_PERM_OVR"                      */
-/*                  CPU MMR Access Permission Override                  */
-/* ==================================================================== */
-
-#define SH_CPU_PERM_OVR                          0x0000000110060080
-#define SH_CPU_PERM_OVR_MASK                     0xffffffffffffffff
-#define SH_CPU_PERM_OVR_INIT                     0x0000000000000000
-
-/*   SH_CPU_PERM_OVR_OVERRIDE                                           */
-/*   Description:  Override                                             */
-#define SH_CPU_PERM_OVR_OVERRIDE_SHFT            0
-#define SH_CPU_PERM_OVR_OVERRIDE_MASK            0xffffffffffffffff
-
-/* ==================================================================== */
-/*                      Register "SH_EXT_IO_PERM"                       */
-/*                External IO MMR Access Permission Bits                */
-/* ==================================================================== */
-
-#define SH_EXT_IO_PERM                           0x0000000110060100
-#define SH_EXT_IO_PERM_MASK                      0xffffffffffffffff
-#define SH_EXT_IO_PERM_INIT                      0x0000000000000000
-
-/*   SH_EXT_IO_PERM_ACCESS_BITS                                         */
-/*   Description:  Access Bits                                          */
-#define SH_EXT_IO_PERM_ACCESS_BITS_SHFT          0
-#define SH_EXT_IO_PERM_ACCESS_BITS_MASK          0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_EXT_IOI_ACCESS"                     */
-/*             External IO Interrupt Access Permission Bits             */
-/* ==================================================================== */
-
-#define SH_EXT_IOI_ACCESS                        0x0000000110060180
-#define SH_EXT_IOI_ACCESS_MASK                   0xffffffffffffffff
-#define SH_EXT_IOI_ACCESS_INIT                   0xffffffffffffffff
-
-/*   SH_EXT_IOI_ACCESS_ACCESS_BITS                                      */
-/*   Description:  Access Bits                                          */
-#define SH_EXT_IOI_ACCESS_ACCESS_BITS_SHFT       0
-#define SH_EXT_IOI_ACCESS_ACCESS_BITS_MASK       0xffffffffffffffff
-
-/* ==================================================================== */
-/*                      Register "SH_GC_FIL_CTRL"                       */
-/*                   SHub Global Clock Filter Control                   */
-/* ==================================================================== */
-
-#define SH_GC_FIL_CTRL                           0x0000000110060200
-#define SH_GC_FIL_CTRL_MASK                      0x03ff3ff3ff1fff1f
-#define SH_GC_FIL_CTRL_INIT                      0x0000000000000000
-
-/*   SH_GC_FIL_CTRL_OFFSET                                              */
-/*   Description:  Offset                                               */
-#define SH_GC_FIL_CTRL_OFFSET_SHFT               0
-#define SH_GC_FIL_CTRL_OFFSET_MASK               0x000000000000001f
-
-/*   SH_GC_FIL_CTRL_MASK_COUNTER                                        */
-/*   Description:  Mask Counter                                         */
-#define SH_GC_FIL_CTRL_MASK_COUNTER_SHFT         8
-#define SH_GC_FIL_CTRL_MASK_COUNTER_MASK         0x00000000000fff00
-
-/*   SH_GC_FIL_CTRL_MASK_ENABLE                                         */
-/*   Description:  Mask Enable                                          */
-#define SH_GC_FIL_CTRL_MASK_ENABLE_SHFT          20
-#define SH_GC_FIL_CTRL_MASK_ENABLE_MASK          0x0000000000100000
-
-/*   SH_GC_FIL_CTRL_DROPOUT_COUNTER                                     */
-/*   Description:  Dropout Counter                                      */
-#define SH_GC_FIL_CTRL_DROPOUT_COUNTER_SHFT      24
-#define SH_GC_FIL_CTRL_DROPOUT_COUNTER_MASK      0x00000003ff000000
-
-/*   SH_GC_FIL_CTRL_DROPOUT_THRESH                                      */
-/*   Description:  Dropout threshold                                    */
-#define SH_GC_FIL_CTRL_DROPOUT_THRESH_SHFT       36
-#define SH_GC_FIL_CTRL_DROPOUT_THRESH_MASK       0x00003ff000000000
-
-/*   SH_GC_FIL_CTRL_ERROR_COUNTER                                       */
-/*   Description:  Error counter                                        */
-#define SH_GC_FIL_CTRL_ERROR_COUNTER_SHFT        48
-#define SH_GC_FIL_CTRL_ERROR_COUNTER_MASK        0x03ff000000000000
-
-/* ==================================================================== */
-/*                      Register "SH_GC_SRC_CTRL"                       */
-/*                      SHub Global Clock Control                       */
-/* ==================================================================== */
-
-#define SH_GC_SRC_CTRL                           0x0000000110060280
-#define SH_GC_SRC_CTRL_MASK                      0x0000000313ff3ff1
-#define SH_GC_SRC_CTRL_INIT                      0x0000000100000000
-
-/*   SH_GC_SRC_CTRL_ENABLE_COUNTER                                      */
-/*   Description:  Enable Counter                                       */
-#define SH_GC_SRC_CTRL_ENABLE_COUNTER_SHFT       0
-#define SH_GC_SRC_CTRL_ENABLE_COUNTER_MASK       0x0000000000000001
-
-/*   SH_GC_SRC_CTRL_MAX_COUNT                                           */
-/*   Description:  Max Count                                            */
-#define SH_GC_SRC_CTRL_MAX_COUNT_SHFT            4
-#define SH_GC_SRC_CTRL_MAX_COUNT_MASK            0x0000000000003ff0
-
-/*   SH_GC_SRC_CTRL_COUNTER                                             */
-/*   Description:  Counter                                              */
-#define SH_GC_SRC_CTRL_COUNTER_SHFT              16
-#define SH_GC_SRC_CTRL_COUNTER_MASK              0x0000000003ff0000
-
-/*   SH_GC_SRC_CTRL_TOGGLE_BIT                                          */
-/*   Description:  Toggle bit                                           */
-#define SH_GC_SRC_CTRL_TOGGLE_BIT_SHFT           28
-#define SH_GC_SRC_CTRL_TOGGLE_BIT_MASK           0x0000000010000000
-
-/*   SH_GC_SRC_CTRL_SOURCE_SEL                                          */
-/*   Description:  Source select (0=ext., 1=Int., 2=SHUB)               */
-#define SH_GC_SRC_CTRL_SOURCE_SEL_SHFT           32
-#define SH_GC_SRC_CTRL_SOURCE_SEL_MASK           0x0000000300000000
-
-/* ==================================================================== */
-/*                       Register "SH_HARD_RESET"                       */
-/*                           SHub Hard Reset                            */
-/* ==================================================================== */
-
-#define SH_HARD_RESET                            0x0000000110060300
-#define SH_HARD_RESET_MASK                       0x0000000000000001
-#define SH_HARD_RESET_INIT                       0x0000000000000000
-
-/*   SH_HARD_RESET_HARD_RESET                                           */
-/*   Description:  Hard Reset                                           */
-#define SH_HARD_RESET_HARD_RESET_SHFT            0
-#define SH_HARD_RESET_HARD_RESET_MASK            0x0000000000000001
-
-/* ==================================================================== */
-/*                        Register "SH_IO_PERM"                         */
-/*                    II MMR Access Permission Bits                     */
-/* ==================================================================== */
-
-#define SH_IO_PERM                               0x0000000110060380
-#define SH_IO_PERM_MASK                          0xffffffffffffffff
-#define SH_IO_PERM_INIT                          0x0000000000000000
-
-/*   SH_IO_PERM_ACCESS_BITS                                             */
-/*   Description:  Access Bits                                          */
-#define SH_IO_PERM_ACCESS_BITS_SHFT              0
-#define SH_IO_PERM_ACCESS_BITS_MASK              0xffffffffffffffff
-
-/* ==================================================================== */
-/*                       Register "SH_IOI_ACCESS"                       */
-/*                 II Interrupt Access Permission Bits                  */
-/* ==================================================================== */
-
-#define SH_IOI_ACCESS                            0x0000000110060400
-#define SH_IOI_ACCESS_MASK                       0xffffffffffffffff
-#define SH_IOI_ACCESS_INIT                       0xffffffffffffffff
-
-/*   SH_IOI_ACCESS_ACCESS_BITS                                          */
-/*   Description:  Access Bits                                          */
-#define SH_IOI_ACCESS_ACCESS_BITS_SHFT           0
-#define SH_IOI_ACCESS_ACCESS_BITS_MASK           0xffffffffffffffff
-
-/* ==================================================================== */
-/*                       Register "SH_IPI_ACCESS"                       */
-/*                 CPU interrupt Access Permission Bits                 */
-/* ==================================================================== */
-
-#define SH_IPI_ACCESS                            0x0000000110060480
-#define SH_IPI_ACCESS_MASK                       0xffffffffffffffff
-#define SH_IPI_ACCESS_INIT                       0xffffffffffffffff
-
-/*   SH_IPI_ACCESS_ACCESS_BITS                                          */
-/*   Description:  Access Bits                                          */
-#define SH_IPI_ACCESS_ACCESS_BITS_SHFT           0
-#define SH_IPI_ACCESS_ACCESS_BITS_MASK           0xffffffffffffffff
-
-/* ==================================================================== */
-/*                      Register "SH_JTAG_CONFIG"                       */
-/*                       SHub JTAG configuration                        */
-/* ==================================================================== */
-
-#define SH_JTAG_CONFIG                           0x0000000110060500
-#define SH_JTAG_CONFIG_MASK                      0x00ffffffffffffff
-#define SH_JTAG_CONFIG_INIT                      0x0000000000000000
-
-/*   SH_JTAG_CONFIG_MD_CLK_SEL                                          */
-/*   Description:  Select divide freq of DRAMCLK                        */
-#define SH_JTAG_CONFIG_MD_CLK_SEL_SHFT           0
-#define SH_JTAG_CONFIG_MD_CLK_SEL_MASK           0x0000000000000003
-
-/*   SH_JTAG_CONFIG_NI_CLK_SEL                                          */
-/*   Description:  Selects clock source for NICLK domain                */
-#define SH_JTAG_CONFIG_NI_CLK_SEL_SHFT           2
-#define SH_JTAG_CONFIG_NI_CLK_SEL_MASK           0x0000000000000004
-
-/*   SH_JTAG_CONFIG_II_CLK_SEL                                          */
-/*   Description:  Selects clock source for IOCLK domain                */
-#define SH_JTAG_CONFIG_II_CLK_SEL_SHFT           3
-#define SH_JTAG_CONFIG_II_CLK_SEL_MASK           0x0000000000000018
-
-/*   SH_JTAG_CONFIG_WRT90_TARGET                                        */
-/*   Description:  wrt90_target                                         */
-#define SH_JTAG_CONFIG_WRT90_TARGET_SHFT         5
-#define SH_JTAG_CONFIG_WRT90_TARGET_MASK         0x000000000007ffe0
-
-/*   SH_JTAG_CONFIG_WRT90_OVERRIDER                                     */
-/*   Description:  wrt90_overrideR                                      */
-#define SH_JTAG_CONFIG_WRT90_OVERRIDER_SHFT      19
-#define SH_JTAG_CONFIG_WRT90_OVERRIDER_MASK      0x0000000000080000
-
-/*   SH_JTAG_CONFIG_WRT90_OVERRIDE                                      */
-/*   Description:  wrt90_override                                       */
-#define SH_JTAG_CONFIG_WRT90_OVERRIDE_SHFT       20
-#define SH_JTAG_CONFIG_WRT90_OVERRIDE_MASK       0x0000000000100000
-
-/*   SH_JTAG_CONFIG_JTAG_MCI_RESET_DELAY                                */
-/*   Description:  jtag_mci_reset_delay                                 */
-#define SH_JTAG_CONFIG_JTAG_MCI_RESET_DELAY_SHFT 21
-#define SH_JTAG_CONFIG_JTAG_MCI_RESET_DELAY_MASK 0x0000000001e00000
-
-/*   SH_JTAG_CONFIG_JTAG_MCI_TARGET                                     */
-/*   Description:  jtag_mci_target                                      */
-#define SH_JTAG_CONFIG_JTAG_MCI_TARGET_SHFT      25
-#define SH_JTAG_CONFIG_JTAG_MCI_TARGET_MASK      0x0000007ffe000000
-
-/*   SH_JTAG_CONFIG_JTAG_MCI_OVERRIDE                                   */
-/*   Description:  jtag_mci_override                                    */
-#define SH_JTAG_CONFIG_JTAG_MCI_OVERRIDE_SHFT    39
-#define SH_JTAG_CONFIG_JTAG_MCI_OVERRIDE_MASK    0x0000008000000000
-
-/*   SH_JTAG_CONFIG_FSB_CONFIG_IOQ_DEPTH                                */
-/*   Description:  0=depth 8, 1=depth1                                  */
-#define SH_JTAG_CONFIG_FSB_CONFIG_IOQ_DEPTH_SHFT 40
-#define SH_JTAG_CONFIG_FSB_CONFIG_IOQ_DEPTH_MASK 0x0000010000000000
-
-/*   SH_JTAG_CONFIG_FSB_CONFIG_SAMPLE_BINIT                             */
-/*   Description:  Enable sampling of BINIT                             */
-#define SH_JTAG_CONFIG_FSB_CONFIG_SAMPLE_BINIT_SHFT 41
-#define SH_JTAG_CONFIG_FSB_CONFIG_SAMPLE_BINIT_MASK 0x0000020000000000
-
-/*   SH_JTAG_CONFIG_FSB_CONFIG_ENABLE_BUS_PARKING                       */
-#define SH_JTAG_CONFIG_FSB_CONFIG_ENABLE_BUS_PARKING_SHFT 42
-#define SH_JTAG_CONFIG_FSB_CONFIG_ENABLE_BUS_PARKING_MASK 0x0000040000000000
-
-/*   SH_JTAG_CONFIG_FSB_CONFIG_CLOCK_RATIO                              */
-#define SH_JTAG_CONFIG_FSB_CONFIG_CLOCK_RATIO_SHFT 43
-#define SH_JTAG_CONFIG_FSB_CONFIG_CLOCK_RATIO_MASK 0x0000f80000000000
-
-/*   SH_JTAG_CONFIG_FSB_CONFIG_OUTPUT_TRISTATE                          */
-/*   Description:  Output tristate control                              */
-#define SH_JTAG_CONFIG_FSB_CONFIG_OUTPUT_TRISTATE_SHFT 48
-#define SH_JTAG_CONFIG_FSB_CONFIG_OUTPUT_TRISTATE_MASK 0x000f000000000000
-
-/*   SH_JTAG_CONFIG_FSB_CONFIG_ENABLE_BIST                              */
-/*   Description:  Enables BIST                                         */
-#define SH_JTAG_CONFIG_FSB_CONFIG_ENABLE_BIST_SHFT 52
-#define SH_JTAG_CONFIG_FSB_CONFIG_ENABLE_BIST_MASK 0x0010000000000000
-
-/*   SH_JTAG_CONFIG_FSB_CONFIG_AUX                                      */
-/*   Description:  Enables BIST                                         */
-#define SH_JTAG_CONFIG_FSB_CONFIG_AUX_SHFT       53
-#define SH_JTAG_CONFIG_FSB_CONFIG_AUX_MASK       0x0060000000000000
-
-/*   SH_JTAG_CONFIG_GTL_CONFIG_RE                                       */
-/*   Description:  Reference Enable selection for GTL io                */
-#define SH_JTAG_CONFIG_GTL_CONFIG_RE_SHFT        55
-#define SH_JTAG_CONFIG_GTL_CONFIG_RE_MASK        0x0080000000000000
-
-/* ==================================================================== */
-/*                        Register "SH_SHUB_ID"                         */
-/*                            SHub ID Number                            */
-/* ==================================================================== */
-
-#define SH_SHUB_ID                               0x0000000110060580
-#define SH_SHUB_ID_MASK                          0x011f37ffffffffff
-#define SH_SHUB_ID_INIT                          0x0010300000000000
-
-/*   SH_SHUB_ID_FORCE1                                                  */
-/*   Description:  Must be 1                                            */
-#define SH_SHUB_ID_FORCE1_SHFT                   0
-#define SH_SHUB_ID_FORCE1_MASK                   0x0000000000000001
-
-/*   SH_SHUB_ID_MANUFACTURER                                            */
-/*   Description:  Manufacturer                                         */
-#define SH_SHUB_ID_MANUFACTURER_SHFT             1
-#define SH_SHUB_ID_MANUFACTURER_MASK             0x0000000000000ffe
-
-/*   SH_SHUB_ID_PART_NUMBER                                             */
-/*   Description:  Part Number                                          */
-#define SH_SHUB_ID_PART_NUMBER_SHFT              12
-#define SH_SHUB_ID_PART_NUMBER_MASK              0x000000000ffff000
-
-/*   SH_SHUB_ID_REVISION                                                */
-/*   Description:  Revision                                             */
-#define SH_SHUB_ID_REVISION_SHFT                 28
-#define SH_SHUB_ID_REVISION_MASK                 0x00000000f0000000
-
-/*   SH_SHUB_ID_NODE_ID                                                 */
-/*   Description:  Node Identification                                  */
-#define SH_SHUB_ID_NODE_ID_SHFT                  32
-#define SH_SHUB_ID_NODE_ID_MASK                  0x000007ff00000000
-
-/*   SH_SHUB_ID_SHARING_MODE                                            */
-/*   Description:  Sharing mode (Coherency Domain Size)                 */
-#define SH_SHUB_ID_SHARING_MODE_SHFT             44
-#define SH_SHUB_ID_SHARING_MODE_MASK             0x0000300000000000
-
-/*   SH_SHUB_ID_NODES_PER_BIT                                           */
-/*   Description:  Nodes per bit definition for MMR access              */
-#define SH_SHUB_ID_NODES_PER_BIT_SHFT            48
-#define SH_SHUB_ID_NODES_PER_BIT_MASK            0x001f000000000000
-
-/*   SH_SHUB_ID_NI_PORT                                                 */
-/*   Description:  NI port of vector reference, 0 = NI0, 1 = NI1        */
-#define SH_SHUB_ID_NI_PORT_SHFT                  56
-#define SH_SHUB_ID_NI_PORT_MASK                  0x0100000000000000
-
-/* ==================================================================== */
-/*                     Register "SH_SHUBS_PRESENT0"                     */
-/*         Shubs 0 - 63 Present. Used for invalidate generation         */
-/* ==================================================================== */
-
-#define SH_SHUBS_PRESENT0                        0x0000000110060600
-#define SH_SHUBS_PRESENT0_MASK                   0xffffffffffffffff
-#define SH_SHUBS_PRESENT0_INIT                   0xffffffffffffffff
-
-/*   SH_SHUBS_PRESENT0_SHUBS_PRESENT0                                   */
-/*   Description:  Shubs 0 - 63 Present configuration                   */
-#define SH_SHUBS_PRESENT0_SHUBS_PRESENT0_SHFT    0
-#define SH_SHUBS_PRESENT0_SHUBS_PRESENT0_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_SHUBS_PRESENT1"                     */
-/*        Shubs 64 - 127 Present. Used for invalidate generation        */
-/* ==================================================================== */
-
-#define SH_SHUBS_PRESENT1                        0x0000000110060680
-#define SH_SHUBS_PRESENT1_MASK                   0xffffffffffffffff
-#define SH_SHUBS_PRESENT1_INIT                   0xffffffffffffffff
-
-/*   SH_SHUBS_PRESENT1_SHUBS_PRESENT1                                   */
-/*   Description:  Shubs 64 - 127 Present configuration                 */
-#define SH_SHUBS_PRESENT1_SHUBS_PRESENT1_SHFT    0
-#define SH_SHUBS_PRESENT1_SHUBS_PRESENT1_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_SHUBS_PRESENT2"                     */
-/*       Shubs 128 - 191 Present. Used for invalidate generation        */
-/* ==================================================================== */
-
-#define SH_SHUBS_PRESENT2                        0x0000000110060700
-#define SH_SHUBS_PRESENT2_MASK                   0xffffffffffffffff
-#define SH_SHUBS_PRESENT2_INIT                   0xffffffffffffffff
-
-/*   SH_SHUBS_PRESENT2_SHUBS_PRESENT2                                   */
-/*   Description:  Shubs 128 - 191 Present configuration                */
-#define SH_SHUBS_PRESENT2_SHUBS_PRESENT2_SHFT    0
-#define SH_SHUBS_PRESENT2_SHUBS_PRESENT2_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_SHUBS_PRESENT3"                     */
-/*       Shubs 192 - 255 Present. Used for invalidate generation        */
-/* ==================================================================== */
-
-#define SH_SHUBS_PRESENT3                        0x0000000110060780
-#define SH_SHUBS_PRESENT3_MASK                   0xffffffffffffffff
-#define SH_SHUBS_PRESENT3_INIT                   0xffffffffffffffff
-
-/*   SH_SHUBS_PRESENT3_SHUBS_PRESENT3                                   */
-/*   Description:  Shubs 192 - 255 Present configuration                */
-#define SH_SHUBS_PRESENT3_SHUBS_PRESENT3_SHFT    0
-#define SH_SHUBS_PRESENT3_SHUBS_PRESENT3_MASK    0xffffffffffffffff
-
-/* ==================================================================== */
-/*                       Register "SH_SOFT_RESET"                       */
-/*                           SHub Soft Reset                            */
-/* ==================================================================== */
-
-#define SH_SOFT_RESET                            0x0000000110060800
-#define SH_SOFT_RESET_MASK                       0x0000000000000001
-#define SH_SOFT_RESET_INIT                       0x0000000000000000
-
-/*   SH_SOFT_RESET_SOFT_RESET                                           */
-/*   Description:  Soft Reset                                           */
-#define SH_SOFT_RESET_SOFT_RESET_SHFT            0
-#define SH_SOFT_RESET_SOFT_RESET_MASK            0x0000000000000001
-
-/* ==================================================================== */
-/*                      Register "SH_FIRST_ERROR"                       */
-/*                    Shub Global First Error Flags                     */
-/* ==================================================================== */
-
-#define SH_FIRST_ERROR                           0x0000000110071000
-#define SH_FIRST_ERROR_MASK                      0x000000000007ffff
-#define SH_FIRST_ERROR_INIT                      0x0000000000000000
-
-/*   SH_FIRST_ERROR_FIRST_ERROR                                         */
-/*   Description:  Chiplet with first error                             */
-#define SH_FIRST_ERROR_FIRST_ERROR_SHFT          0
-#define SH_FIRST_ERROR_FIRST_ERROR_MASK          0x000000000007ffff
-
-/* ==================================================================== */
-/*                    Register "SH_II_HW_TIME_STAMP"                    */
-/*                     II hardware error time stamp                     */
-/* ==================================================================== */
-
-#define SH_II_HW_TIME_STAMP                      0x0000000110071080
-#define SH_II_HW_TIME_STAMP_MASK                 0xffffffffffffffff
-#define SH_II_HW_TIME_STAMP_INIT                 0x0000000000000000
-
-/*   SH_II_HW_TIME_STAMP_TIME                                           */
-/*   Description:  II hardware error time stamp                         */
-#define SH_II_HW_TIME_STAMP_TIME_SHFT            0
-#define SH_II_HW_TIME_STAMP_TIME_MASK            0x7fffffffffffffff
-
-/*   SH_II_HW_TIME_STAMP_VALID                                          */
-/*   Description:  II hardware error time stamp valid                   */
-#define SH_II_HW_TIME_STAMP_VALID_SHFT           63
-#define SH_II_HW_TIME_STAMP_VALID_MASK           0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_LB_HW_TIME_STAMP"                    */
-/*                     LB hardware error time stamp                     */
-/* ==================================================================== */
-
-#define SH_LB_HW_TIME_STAMP                      0x0000000110071100
-#define SH_LB_HW_TIME_STAMP_MASK                 0xffffffffffffffff
-#define SH_LB_HW_TIME_STAMP_INIT                 0x0000000000000000
-
-/*   SH_LB_HW_TIME_STAMP_TIME                                           */
-/*   Description:  LB hardware error time stamp                         */
-#define SH_LB_HW_TIME_STAMP_TIME_SHFT            0
-#define SH_LB_HW_TIME_STAMP_TIME_MASK            0x7fffffffffffffff
-
-/*   SH_LB_HW_TIME_STAMP_VALID                                          */
-/*   Description:  LB hardware error time stamp valid                   */
-#define SH_LB_HW_TIME_STAMP_VALID_SHFT           63
-#define SH_LB_HW_TIME_STAMP_VALID_MASK           0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_COR_TIME_STAMP"                    */
-/*                   MD correctable error time stamp                    */
-/* ==================================================================== */
-
-#define SH_MD_COR_TIME_STAMP                     0x0000000110071180
-#define SH_MD_COR_TIME_STAMP_MASK                0xffffffffffffffff
-#define SH_MD_COR_TIME_STAMP_INIT                0x0000000000000000
-
-/*   SH_MD_COR_TIME_STAMP_TIME                                          */
-/*   Description:  MD correctable error time stamp                      */
-#define SH_MD_COR_TIME_STAMP_TIME_SHFT           0
-#define SH_MD_COR_TIME_STAMP_TIME_MASK           0x7fffffffffffffff
-
-/*   SH_MD_COR_TIME_STAMP_VALID                                         */
-/*   Description:  MD correctable error time stamp valid                */
-#define SH_MD_COR_TIME_STAMP_VALID_SHFT          63
-#define SH_MD_COR_TIME_STAMP_VALID_MASK          0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_MD_HW_TIME_STAMP"                    */
-/*                     MD hardware error time stamp                     */
-/* ==================================================================== */
-
-#define SH_MD_HW_TIME_STAMP                      0x0000000110071200
-#define SH_MD_HW_TIME_STAMP_MASK                 0xffffffffffffffff
-#define SH_MD_HW_TIME_STAMP_INIT                 0x0000000000000000
-
-/*   SH_MD_HW_TIME_STAMP_TIME                                           */
-/*   Description:  MD hardware error time stamp                         */
-#define SH_MD_HW_TIME_STAMP_TIME_SHFT            0
-#define SH_MD_HW_TIME_STAMP_TIME_MASK            0x7fffffffffffffff
-
-/*   SH_MD_HW_TIME_STAMP_VALID                                          */
-/*   Description:  MD hardware error time stamp valid                   */
-#define SH_MD_HW_TIME_STAMP_VALID_SHFT           63
-#define SH_MD_HW_TIME_STAMP_VALID_MASK           0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_UNCOR_TIME_STAMP"                   */
-/*                  MD uncorrectable error time stamp                   */
-/* ==================================================================== */
-
-#define SH_MD_UNCOR_TIME_STAMP                   0x0000000110071280
-#define SH_MD_UNCOR_TIME_STAMP_MASK              0xffffffffffffffff
-#define SH_MD_UNCOR_TIME_STAMP_INIT              0x0000000000000000
-
-/*   SH_MD_UNCOR_TIME_STAMP_TIME                                        */
-/*   Description:  MD uncorrectable error time stamp                    */
-#define SH_MD_UNCOR_TIME_STAMP_TIME_SHFT         0
-#define SH_MD_UNCOR_TIME_STAMP_TIME_MASK         0x7fffffffffffffff
-
-/*   SH_MD_UNCOR_TIME_STAMP_VALID                                       */
-/*   Description:  MD uncorrectable error time stamp valid              */
-#define SH_MD_UNCOR_TIME_STAMP_VALID_SHFT        63
-#define SH_MD_UNCOR_TIME_STAMP_VALID_MASK        0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_PI_COR_TIME_STAMP"                    */
-/*                   PI correctable error time stamp                    */
-/* ==================================================================== */
-
-#define SH_PI_COR_TIME_STAMP                     0x0000000110071300
-#define SH_PI_COR_TIME_STAMP_MASK                0xffffffffffffffff
-#define SH_PI_COR_TIME_STAMP_INIT                0x0000000000000000
-
-/*   SH_PI_COR_TIME_STAMP_TIME                                          */
-/*   Description:  PI correctable error time stamp                      */
-#define SH_PI_COR_TIME_STAMP_TIME_SHFT           0
-#define SH_PI_COR_TIME_STAMP_TIME_MASK           0x7fffffffffffffff
-
-/*   SH_PI_COR_TIME_STAMP_VALID                                         */
-/*   Description:  PI correctable error time stamp valid                */
-#define SH_PI_COR_TIME_STAMP_VALID_SHFT          63
-#define SH_PI_COR_TIME_STAMP_VALID_MASK          0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_PI_HW_TIME_STAMP"                    */
-/*                     PI hardware error time stamp                     */
-/* ==================================================================== */
-
-#define SH_PI_HW_TIME_STAMP                      0x0000000110071380
-#define SH_PI_HW_TIME_STAMP_MASK                 0xffffffffffffffff
-#define SH_PI_HW_TIME_STAMP_INIT                 0x0000000000000000
-
-/*   SH_PI_HW_TIME_STAMP_TIME                                           */
-/*   Description:  PI hardware error time stamp                         */
-#define SH_PI_HW_TIME_STAMP_TIME_SHFT            0
-#define SH_PI_HW_TIME_STAMP_TIME_MASK            0x7fffffffffffffff
-
-/*   SH_PI_HW_TIME_STAMP_VALID                                          */
-/*   Description:  PI hardware error time stamp valid                   */
-#define SH_PI_HW_TIME_STAMP_VALID_SHFT           63
-#define SH_PI_HW_TIME_STAMP_VALID_MASK           0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PI_UNCOR_TIME_STAMP"                   */
-/*                  PI uncorrectable error time stamp                   */
-/* ==================================================================== */
-
-#define SH_PI_UNCOR_TIME_STAMP                   0x0000000110071400
-#define SH_PI_UNCOR_TIME_STAMP_MASK              0xffffffffffffffff
-#define SH_PI_UNCOR_TIME_STAMP_INIT              0x0000000000000000
-
-/*   SH_PI_UNCOR_TIME_STAMP_TIME                                        */
-/*   Description:  PI uncorrectable error time stamp                    */
-#define SH_PI_UNCOR_TIME_STAMP_TIME_SHFT         0
-#define SH_PI_UNCOR_TIME_STAMP_TIME_MASK         0x7fffffffffffffff
-
-/*   SH_PI_UNCOR_TIME_STAMP_VALID                                       */
-/*   Description:  PI uncorrectable error time stamp valid              */
-#define SH_PI_UNCOR_TIME_STAMP_VALID_SHFT        63
-#define SH_PI_UNCOR_TIME_STAMP_VALID_MASK        0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ADV_TIME_STAMP"                  */
-/*                      Proc 0 advisory time stamp                      */
-/* ==================================================================== */
-
-#define SH_PROC0_ADV_TIME_STAMP                  0x0000000110071480
-#define SH_PROC0_ADV_TIME_STAMP_MASK             0xffffffffffffffff
-#define SH_PROC0_ADV_TIME_STAMP_INIT             0x0000000000000000
-
-/*   SH_PROC0_ADV_TIME_STAMP_TIME                                       */
-/*   Description:  Processor 0 advisory time stamp                      */
-#define SH_PROC0_ADV_TIME_STAMP_TIME_SHFT        0
-#define SH_PROC0_ADV_TIME_STAMP_TIME_MASK        0x7fffffffffffffff
-
-/*   SH_PROC0_ADV_TIME_STAMP_VALID                                      */
-/*   Description:  Processor 0 advisory time stamp valid                */
-#define SH_PROC0_ADV_TIME_STAMP_VALID_SHFT       63
-#define SH_PROC0_ADV_TIME_STAMP_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ERR_TIME_STAMP"                  */
-/*                       Proc 0 error time stamp                        */
-/* ==================================================================== */
-
-#define SH_PROC0_ERR_TIME_STAMP                  0x0000000110071500
-#define SH_PROC0_ERR_TIME_STAMP_MASK             0xffffffffffffffff
-#define SH_PROC0_ERR_TIME_STAMP_INIT             0x0000000000000000
-
-/*   SH_PROC0_ERR_TIME_STAMP_TIME                                       */
-/*   Description:  Processor 0 error time stamp                         */
-#define SH_PROC0_ERR_TIME_STAMP_TIME_SHFT        0
-#define SH_PROC0_ERR_TIME_STAMP_TIME_MASK        0x7fffffffffffffff
-
-/*   SH_PROC0_ERR_TIME_STAMP_VALID                                      */
-/*   Description:  Processor 0 error time stamp valid                   */
-#define SH_PROC0_ERR_TIME_STAMP_VALID_SHFT       63
-#define SH_PROC0_ERR_TIME_STAMP_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ADV_TIME_STAMP"                  */
-/*                      Proc 1 advisory time stamp                      */
-/* ==================================================================== */
-
-#define SH_PROC1_ADV_TIME_STAMP                  0x0000000110071580
-#define SH_PROC1_ADV_TIME_STAMP_MASK             0xffffffffffffffff
-#define SH_PROC1_ADV_TIME_STAMP_INIT             0x0000000000000000
-
-/*   SH_PROC1_ADV_TIME_STAMP_TIME                                       */
-/*   Description:  Processor 1 advisory time stamp                      */
-#define SH_PROC1_ADV_TIME_STAMP_TIME_SHFT        0
-#define SH_PROC1_ADV_TIME_STAMP_TIME_MASK        0x7fffffffffffffff
-
-/*   SH_PROC1_ADV_TIME_STAMP_VALID                                      */
-/*   Description:  Processor 1 advisory time stamp valid                */
-#define SH_PROC1_ADV_TIME_STAMP_VALID_SHFT       63
-#define SH_PROC1_ADV_TIME_STAMP_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ERR_TIME_STAMP"                  */
-/*                       Proc 1 error time stamp                        */
-/* ==================================================================== */
-
-#define SH_PROC1_ERR_TIME_STAMP                  0x0000000110071600
-#define SH_PROC1_ERR_TIME_STAMP_MASK             0xffffffffffffffff
-#define SH_PROC1_ERR_TIME_STAMP_INIT             0x0000000000000000
-
-/*   SH_PROC1_ERR_TIME_STAMP_TIME                                       */
-/*   Description:  Processor 1 error time stamp                         */
-#define SH_PROC1_ERR_TIME_STAMP_TIME_SHFT        0
-#define SH_PROC1_ERR_TIME_STAMP_TIME_MASK        0x7fffffffffffffff
-
-/*   SH_PROC1_ERR_TIME_STAMP_VALID                                      */
-/*   Description:  Processor 1 error time stamp valid                   */
-#define SH_PROC1_ERR_TIME_STAMP_VALID_SHFT       63
-#define SH_PROC1_ERR_TIME_STAMP_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ADV_TIME_STAMP"                  */
-/*                      Proc 2 advisory time stamp                      */
-/* ==================================================================== */
-
-#define SH_PROC2_ADV_TIME_STAMP                  0x0000000110071680
-#define SH_PROC2_ADV_TIME_STAMP_MASK             0xffffffffffffffff
-#define SH_PROC2_ADV_TIME_STAMP_INIT             0x0000000000000000
-
-/*   SH_PROC2_ADV_TIME_STAMP_TIME                                       */
-/*   Description:  Processor 2 advisory time stamp                      */
-#define SH_PROC2_ADV_TIME_STAMP_TIME_SHFT        0
-#define SH_PROC2_ADV_TIME_STAMP_TIME_MASK        0x7fffffffffffffff
-
-/*   SH_PROC2_ADV_TIME_STAMP_VALID                                      */
-/*   Description:  Processor 2 advisory time stamp valid                */
-#define SH_PROC2_ADV_TIME_STAMP_VALID_SHFT       63
-#define SH_PROC2_ADV_TIME_STAMP_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ERR_TIME_STAMP"                  */
-/*                       Proc 2 error time stamp                        */
-/* ==================================================================== */
-
-#define SH_PROC2_ERR_TIME_STAMP                  0x0000000110071700
-#define SH_PROC2_ERR_TIME_STAMP_MASK             0xffffffffffffffff
-#define SH_PROC2_ERR_TIME_STAMP_INIT             0x0000000000000000
-
-/*   SH_PROC2_ERR_TIME_STAMP_TIME                                       */
-/*   Description:  Processor 2 error time stamp                         */
-#define SH_PROC2_ERR_TIME_STAMP_TIME_SHFT        0
-#define SH_PROC2_ERR_TIME_STAMP_TIME_MASK        0x7fffffffffffffff
-
-/*   SH_PROC2_ERR_TIME_STAMP_VALID                                      */
-/*   Description:  Processor 2 error time stamp valid                   */
-#define SH_PROC2_ERR_TIME_STAMP_VALID_SHFT       63
-#define SH_PROC2_ERR_TIME_STAMP_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ADV_TIME_STAMP"                  */
-/*                      Proc 3 advisory time stamp                      */
-/* ==================================================================== */
-
-#define SH_PROC3_ADV_TIME_STAMP                  0x0000000110071780
-#define SH_PROC3_ADV_TIME_STAMP_MASK             0xffffffffffffffff
-#define SH_PROC3_ADV_TIME_STAMP_INIT             0x0000000000000000
-
-/*   SH_PROC3_ADV_TIME_STAMP_TIME                                       */
-/*   Description:  Processor 3 advisory time stamp                      */
-#define SH_PROC3_ADV_TIME_STAMP_TIME_SHFT        0
-#define SH_PROC3_ADV_TIME_STAMP_TIME_MASK        0x7fffffffffffffff
-
-/*   SH_PROC3_ADV_TIME_STAMP_VALID                                      */
-/*   Description:  Processor 3 advisory time stamp valid                */
-#define SH_PROC3_ADV_TIME_STAMP_VALID_SHFT       63
-#define SH_PROC3_ADV_TIME_STAMP_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ERR_TIME_STAMP"                  */
-/*                       Proc 3 error time stamp                        */
-/* ==================================================================== */
-
-#define SH_PROC3_ERR_TIME_STAMP                  0x0000000110071800
-#define SH_PROC3_ERR_TIME_STAMP_MASK             0xffffffffffffffff
-#define SH_PROC3_ERR_TIME_STAMP_INIT             0x0000000000000000
-
-/*   SH_PROC3_ERR_TIME_STAMP_TIME                                       */
-/*   Description:  Processor 3 error time stamp                         */
-#define SH_PROC3_ERR_TIME_STAMP_TIME_SHFT        0
-#define SH_PROC3_ERR_TIME_STAMP_TIME_MASK        0x7fffffffffffffff
-
-/*   SH_PROC3_ERR_TIME_STAMP_VALID                                      */
-/*   Description:  Processor 3 error time stamp valid                   */
-#define SH_PROC3_ERR_TIME_STAMP_VALID_SHFT       63
-#define SH_PROC3_ERR_TIME_STAMP_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_XN_COR_TIME_STAMP"                    */
-/*                   XN correctable error time stamp                    */
-/* ==================================================================== */
-
-#define SH_XN_COR_TIME_STAMP                     0x0000000110071880
-#define SH_XN_COR_TIME_STAMP_MASK                0xffffffffffffffff
-#define SH_XN_COR_TIME_STAMP_INIT                0x0000000000000000
-
-/*   SH_XN_COR_TIME_STAMP_TIME                                          */
-/*   Description:  XN correctable error time stamp                      */
-#define SH_XN_COR_TIME_STAMP_TIME_SHFT           0
-#define SH_XN_COR_TIME_STAMP_TIME_MASK           0x7fffffffffffffff
-
-/*   SH_XN_COR_TIME_STAMP_VALID                                         */
-/*   Description:  XN correctable error time stamp valid                */
-#define SH_XN_COR_TIME_STAMP_VALID_SHFT          63
-#define SH_XN_COR_TIME_STAMP_VALID_MASK          0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_XN_HW_TIME_STAMP"                    */
-/*                     XN hardware error time stamp                     */
-/* ==================================================================== */
-
-#define SH_XN_HW_TIME_STAMP                      0x0000000110071900
-#define SH_XN_HW_TIME_STAMP_MASK                 0xffffffffffffffff
-#define SH_XN_HW_TIME_STAMP_INIT                 0x0000000000000000
-
-/*   SH_XN_HW_TIME_STAMP_TIME                                           */
-/*   Description:  XN hardware error time stamp                         */
-#define SH_XN_HW_TIME_STAMP_TIME_SHFT            0
-#define SH_XN_HW_TIME_STAMP_TIME_MASK            0x7fffffffffffffff
-
-/*   SH_XN_HW_TIME_STAMP_VALID                                          */
-/*   Description:  XN hardware error time stamp valid                   */
-#define SH_XN_HW_TIME_STAMP_VALID_SHFT           63
-#define SH_XN_HW_TIME_STAMP_VALID_MASK           0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_XN_UNCOR_TIME_STAMP"                   */
-/*                  XN uncorrectable error time stamp                   */
-/* ==================================================================== */
-
-#define SH_XN_UNCOR_TIME_STAMP                   0x0000000110071980
-#define SH_XN_UNCOR_TIME_STAMP_MASK              0xffffffffffffffff
-#define SH_XN_UNCOR_TIME_STAMP_INIT              0x0000000000000000
-
-/*   SH_XN_UNCOR_TIME_STAMP_TIME                                        */
-/*   Description:  XN uncorrectable error time stamp                    */
-#define SH_XN_UNCOR_TIME_STAMP_TIME_SHFT         0
-#define SH_XN_UNCOR_TIME_STAMP_TIME_MASK         0x7fffffffffffffff
-
-/*   SH_XN_UNCOR_TIME_STAMP_VALID                                       */
-/*   Description:  XN uncorrectable error time stamp valid              */
-#define SH_XN_UNCOR_TIME_STAMP_VALID_SHFT        63
-#define SH_XN_UNCOR_TIME_STAMP_VALID_MASK        0x8000000000000000
-
-/* ==================================================================== */
-/*                       Register "SH_DEBUG_PORT"                       */
-/*                           SHub Debug Port                            */
-/* ==================================================================== */
-
-#define SH_DEBUG_PORT                            0x0000000110072000
-#define SH_DEBUG_PORT_MASK                       0x00000000ffffffff
-#define SH_DEBUG_PORT_INIT                       0x0000000000000000
-
-/*   SH_DEBUG_PORT_DEBUG_NIBBLE0                                        */
-/*   Description:  Debug port nibble 0                                  */
-#define SH_DEBUG_PORT_DEBUG_NIBBLE0_SHFT         0
-#define SH_DEBUG_PORT_DEBUG_NIBBLE0_MASK         0x000000000000000f
-
-/*   SH_DEBUG_PORT_DEBUG_NIBBLE1                                        */
-/*   Description:  Debug port nibble 1                                  */
-#define SH_DEBUG_PORT_DEBUG_NIBBLE1_SHFT         4
-#define SH_DEBUG_PORT_DEBUG_NIBBLE1_MASK         0x00000000000000f0
-
-/*   SH_DEBUG_PORT_DEBUG_NIBBLE2                                        */
-/*   Description:  Debug port nibble 2                                  */
-#define SH_DEBUG_PORT_DEBUG_NIBBLE2_SHFT         8
-#define SH_DEBUG_PORT_DEBUG_NIBBLE2_MASK         0x0000000000000f00
-
-/*   SH_DEBUG_PORT_DEBUG_NIBBLE3                                        */
-/*   Description:  Debug port nibble 3                                  */
-#define SH_DEBUG_PORT_DEBUG_NIBBLE3_SHFT         12
-#define SH_DEBUG_PORT_DEBUG_NIBBLE3_MASK         0x000000000000f000
-
-/*   SH_DEBUG_PORT_DEBUG_NIBBLE4                                        */
-/*   Description:  Debug port nibble 4                                  */
-#define SH_DEBUG_PORT_DEBUG_NIBBLE4_SHFT         16
-#define SH_DEBUG_PORT_DEBUG_NIBBLE4_MASK         0x00000000000f0000
-
-/*   SH_DEBUG_PORT_DEBUG_NIBBLE5                                        */
-/*   Description:  Debug port nibble 5                                  */
-#define SH_DEBUG_PORT_DEBUG_NIBBLE5_SHFT         20
-#define SH_DEBUG_PORT_DEBUG_NIBBLE5_MASK         0x0000000000f00000
-
-/*   SH_DEBUG_PORT_DEBUG_NIBBLE6                                        */
-/*   Description:  Debug port nibble 6                                  */
-#define SH_DEBUG_PORT_DEBUG_NIBBLE6_SHFT         24
-#define SH_DEBUG_PORT_DEBUG_NIBBLE6_MASK         0x000000000f000000
-
-/*   SH_DEBUG_PORT_DEBUG_NIBBLE7                                        */
-/*   Description:  Debug port nibble 7                                  */
-#define SH_DEBUG_PORT_DEBUG_NIBBLE7_SHFT         28
-#define SH_DEBUG_PORT_DEBUG_NIBBLE7_MASK         0x00000000f0000000
-
-/* ==================================================================== */
-/*                     Register "SH_II_DEBUG_DATA"                      */
-/*                            II Debug Data                             */
-/* ==================================================================== */
-
-#define SH_II_DEBUG_DATA                         0x0000000110072080
-#define SH_II_DEBUG_DATA_MASK                    0x00000000ffffffff
-#define SH_II_DEBUG_DATA_INIT                    0x0000000000000000
-
-/*   SH_II_DEBUG_DATA_II_DATA                                           */
-/*   Description:  II debug data                                        */
-#define SH_II_DEBUG_DATA_II_DATA_SHFT            0
-#define SH_II_DEBUG_DATA_II_DATA_MASK            0x00000000ffffffff
-
-/* ==================================================================== */
-/*                   Register "SH_II_WRAP_DEBUG_DATA"                   */
-/*                      SHub II Wrapper Debug Data                      */
-/* ==================================================================== */
-
-#define SH_II_WRAP_DEBUG_DATA                    0x0000000110072100
-#define SH_II_WRAP_DEBUG_DATA_MASK               0x00000000ffffffff
-#define SH_II_WRAP_DEBUG_DATA_INIT               0x0000000000000000
-
-/*   SH_II_WRAP_DEBUG_DATA_II_WRAP_DATA                                 */
-/*   Description:  II wrapper debug data                                */
-#define SH_II_WRAP_DEBUG_DATA_II_WRAP_DATA_SHFT  0
-#define SH_II_WRAP_DEBUG_DATA_II_WRAP_DATA_MASK  0x00000000ffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_LB_DEBUG_DATA"                      */
-/*                          SHub LB Debug Data                          */
-/* ==================================================================== */
-
-#define SH_LB_DEBUG_DATA                         0x0000000110072180
-#define SH_LB_DEBUG_DATA_MASK                    0x00000000ffffffff
-#define SH_LB_DEBUG_DATA_INIT                    0x0000000000000000
-
-/*   SH_LB_DEBUG_DATA_LB_DATA                                           */
-/*   Description:  LB debug data                                        */
-#define SH_LB_DEBUG_DATA_LB_DATA_SHFT            0
-#define SH_LB_DEBUG_DATA_LB_DATA_MASK            0x00000000ffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_MD_DEBUG_DATA"                      */
-/*                          SHub MD Debug Data                          */
-/* ==================================================================== */
-
-#define SH_MD_DEBUG_DATA                         0x0000000110072200
-#define SH_MD_DEBUG_DATA_MASK                    0x00000000ffffffff
-#define SH_MD_DEBUG_DATA_INIT                    0x0000000000000000
-
-/*   SH_MD_DEBUG_DATA_MD_DATA                                           */
-/*   Description:  MD debug data                                        */
-#define SH_MD_DEBUG_DATA_MD_DATA_SHFT            0
-#define SH_MD_DEBUG_DATA_MD_DATA_MASK            0x00000000ffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_PI_DEBUG_DATA"                      */
-/*                          SHub PI Debug Data                          */
-/* ==================================================================== */
-
-#define SH_PI_DEBUG_DATA                         0x0000000110072280
-#define SH_PI_DEBUG_DATA_MASK                    0x00000000ffffffff
-#define SH_PI_DEBUG_DATA_INIT                    0x0000000000000000
-
-/*   SH_PI_DEBUG_DATA_PI_DATA                                           */
-/*   Description:  PI Debug Data                                        */
-#define SH_PI_DEBUG_DATA_PI_DATA_SHFT            0
-#define SH_PI_DEBUG_DATA_PI_DATA_MASK            0x00000000ffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_XN_DEBUG_DATA"                      */
-/*                          SHub XN Debug Data                          */
-/* ==================================================================== */
-
-#define SH_XN_DEBUG_DATA                         0x0000000110072300
-#define SH_XN_DEBUG_DATA_MASK                    0x00000000ffffffff
-#define SH_XN_DEBUG_DATA_INIT                    0x0000000000000000
-
-/*   SH_XN_DEBUG_DATA_XN_DATA                                           */
-/*   Description:  XN debug data                                        */
-#define SH_XN_DEBUG_DATA_XN_DATA_SHFT            0
-#define SH_XN_DEBUG_DATA_XN_DATA_MASK            0x00000000ffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_ARMED_STATE"                     */
-/*                Trigger sequencing facility arm state                 */
-/* ==================================================================== */
-
-#define SH_TSF_ARMED_STATE                       0x0000000110073000
-#define SH_TSF_ARMED_STATE_MASK                  0x00000000000000ff
-#define SH_TSF_ARMED_STATE_INIT                  0x0000000000000000
-
-/*   SH_TSF_ARMED_STATE_STATE                                           */
-/*   Description:  Trigger sequencing facility armed state              */
-#define SH_TSF_ARMED_STATE_STATE_SHFT            0
-#define SH_TSF_ARMED_STATE_STATE_MASK            0x00000000000000ff
-
-/* ==================================================================== */
-/*                   Register "SH_TSF_COUNTER_VALUE"                    */
-/*              Trigger sequencing facility counter value               */
-/* ==================================================================== */
-
-#define SH_TSF_COUNTER_VALUE                     0x0000000110073080
-#define SH_TSF_COUNTER_VALUE_MASK                0xffffffffffffffff
-#define SH_TSF_COUNTER_VALUE_INIT                0x0000000000000000
-
-/*   SH_TSF_COUNTER_VALUE_COUNT_32                                      */
-/*   Description:  Trigger sequencing facility counter 32               */
-#define SH_TSF_COUNTER_VALUE_COUNT_32_SHFT       0
-#define SH_TSF_COUNTER_VALUE_COUNT_32_MASK       0x00000000ffffffff
-
-/*   SH_TSF_COUNTER_VALUE_COUNT_16                                      */
-/*   Description:  Trigger sequencing facility counter 16               */
-#define SH_TSF_COUNTER_VALUE_COUNT_16_SHFT       32
-#define SH_TSF_COUNTER_VALUE_COUNT_16_MASK       0x0000ffff00000000
-
-/*   SH_TSF_COUNTER_VALUE_COUNT_8B                                      */
-/*   Description:  Trigger sequencing facility counter 8b               */
-#define SH_TSF_COUNTER_VALUE_COUNT_8B_SHFT       48
-#define SH_TSF_COUNTER_VALUE_COUNT_8B_MASK       0x00ff000000000000
-
-/*   SH_TSF_COUNTER_VALUE_COUNT_8A                                      */
-/*   Description:  Trigger sequencing facility counter 8a               */
-#define SH_TSF_COUNTER_VALUE_COUNT_8A_SHFT       56
-#define SH_TSF_COUNTER_VALUE_COUNT_8A_MASK       0xff00000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_TSF_TRIGGERED_STATE"                   */
-/*             Trigger sequencing facility triggered state              */
-/* ==================================================================== */
-
-#define SH_TSF_TRIGGERED_STATE                   0x0000000110073100
-#define SH_TSF_TRIGGERED_STATE_MASK              0x00000000000000ff
-#define SH_TSF_TRIGGERED_STATE_INIT              0x0000000000000000
-
-/*   SH_TSF_TRIGGERED_STATE_STATE                                       */
-/*   Description:  Trigger sequencing facility triggered state          */
-#define SH_TSF_TRIGGERED_STATE_STATE_SHFT        0
-#define SH_TSF_TRIGGERED_STATE_STATE_MASK        0x00000000000000ff
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_RDDATA"                       */
-/*                      Vector Reply Message Data                       */
-/* ==================================================================== */
-
-#define SH_VEC_RDDATA                            0x0000000110074000
-#define SH_VEC_RDDATA_MASK                       0xffffffffffffffff
-#define SH_VEC_RDDATA_INIT                       0x0000000000000000
-
-/*   SH_VEC_RDDATA_DATA                                                 */
-/*   Description:  Data                                                 */
-#define SH_VEC_RDDATA_DATA_SHFT                  0
-#define SH_VEC_RDDATA_DATA_MASK                  0xffffffffffffffff
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_RETURN"                       */
-/*                  Vector Reply Message Return Route                   */
-/* ==================================================================== */
-
-#define SH_VEC_RETURN                            0x0000000110074080
-#define SH_VEC_RETURN_MASK                       0xffffffffffffffff
-#define SH_VEC_RETURN_INIT                       0x0000000000000000
-
-/*   SH_VEC_RETURN_ROUTE                                                */
-/*   Description:  Route                                                */
-#define SH_VEC_RETURN_ROUTE_SHFT                 0
-#define SH_VEC_RETURN_ROUTE_MASK                 0xffffffffffffffff
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_STATUS"                       */
-/*                     Vector Reply Message Status                      */
-/* ==================================================================== */
-
-#define SH_VEC_STATUS                            0x0000000110074100
-#define SH_VEC_STATUS_MASK                       0xcfffffffffffffff
-#define SH_VEC_STATUS_INIT                       0x0000000000000000
-
-/*   SH_VEC_STATUS_TYPE                                                 */
-/*   Description:  Type                                                 */
-#define SH_VEC_STATUS_TYPE_SHFT                  0
-#define SH_VEC_STATUS_TYPE_MASK                  0x0000000000000007
-
-/*   SH_VEC_STATUS_ADDRESS                                              */
-/*   Description:  Address                                              */
-#define SH_VEC_STATUS_ADDRESS_SHFT               3
-#define SH_VEC_STATUS_ADDRESS_MASK               0x00000007fffffff8
-
-/*   SH_VEC_STATUS_PIO_ID                                               */
-/*   Description:  PIO ID                                               */
-#define SH_VEC_STATUS_PIO_ID_SHFT                35
-#define SH_VEC_STATUS_PIO_ID_MASK                0x00003ff800000000
-
-/*   SH_VEC_STATUS_SOURCE                                               */
-/*   Description:  Source                                               */
-#define SH_VEC_STATUS_SOURCE_SHFT                46
-#define SH_VEC_STATUS_SOURCE_MASK                0x0fffc00000000000
-
-/*   SH_VEC_STATUS_OVERRUN                                              */
-/*   Description:  Overrun                                              */
-#define SH_VEC_STATUS_OVERRUN_SHFT               62
-#define SH_VEC_STATUS_OVERRUN_MASK               0x4000000000000000
-
-/*   SH_VEC_STATUS_STATUS_VALID                                         */
-/*   Description:  Status_Valid                                         */
-#define SH_VEC_STATUS_STATUS_VALID_SHFT          63
-#define SH_VEC_STATUS_STATUS_VALID_MASK          0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_VEC_STATUS_ALIAS"                    */
-/*                  Vector Reply Message Status Alias                   */
-/* ==================================================================== */
-
-#define SH_VEC_STATUS_ALIAS                      0x0000000110074108
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT0_CONTROL"               */
-/*                    Performance Counter 0 Control                     */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNT0_CONTROL            0x0000000110080000
-#define SH_PERFORMANCE_COUNT0_CONTROL_MASK       0x000000000007ffff
-#define SH_PERFORMANCE_COUNT0_CONTROL_INIT       0x000000000000b8b8
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_UP_STIMULUS                          */
-/*   Description:  Counter 0 up stimulus                                */
-#define SH_PERFORMANCE_COUNT0_CONTROL_UP_STIMULUS_SHFT 0
-#define SH_PERFORMANCE_COUNT0_CONTROL_UP_STIMULUS_MASK 0x000000000000001f
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_UP_EVENT                             */
-/*   Description:  Counter 0 up event select (1-greater than, 0-equal)  */
-#define SH_PERFORMANCE_COUNT0_CONTROL_UP_EVENT_SHFT 5
-#define SH_PERFORMANCE_COUNT0_CONTROL_UP_EVENT_MASK 0x0000000000000020
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_UP_POLARITY                          */
-/*   Description:  Counter 0 up polarity select (1-negative edge, 0-po  */
-/*  sitive edge)                                                        */
-#define SH_PERFORMANCE_COUNT0_CONTROL_UP_POLARITY_SHFT 6
-#define SH_PERFORMANCE_COUNT0_CONTROL_UP_POLARITY_MASK 0x0000000000000040
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_UP_MODE                              */
-/*   Description:  Counter 0 up mode select (1-internal, 0-external)    */
-#define SH_PERFORMANCE_COUNT0_CONTROL_UP_MODE_SHFT 7
-#define SH_PERFORMANCE_COUNT0_CONTROL_UP_MODE_MASK 0x0000000000000080
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_DN_STIMULUS                          */
-/*   Description:  Counter 0 down stimulus                              */
-#define SH_PERFORMANCE_COUNT0_CONTROL_DN_STIMULUS_SHFT 8
-#define SH_PERFORMANCE_COUNT0_CONTROL_DN_STIMULUS_MASK 0x0000000000001f00
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_DN_EVENT                             */
-/*   Description:  Counter 0 down event select (1-greater than, 0-equa  */
-#define SH_PERFORMANCE_COUNT0_CONTROL_DN_EVENT_SHFT 13
-#define SH_PERFORMANCE_COUNT0_CONTROL_DN_EVENT_MASK 0x0000000000002000
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_DN_POLARITY                          */
-/*   Description:  Counter 0 down polarity select (1-negative edge, 0-  */
-/*  positive edge)                                                      */
-#define SH_PERFORMANCE_COUNT0_CONTROL_DN_POLARITY_SHFT 14
-#define SH_PERFORMANCE_COUNT0_CONTROL_DN_POLARITY_MASK 0x0000000000004000
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_DN_MODE                              */
-/*   Description:  Counter 0 down mode select (1-internal, 0-external)  */
-#define SH_PERFORMANCE_COUNT0_CONTROL_DN_MODE_SHFT 15
-#define SH_PERFORMANCE_COUNT0_CONTROL_DN_MODE_MASK 0x0000000000008000
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_INC_ENABLE                           */
-/*   Description:  Counter 0 enable increment                           */
-#define SH_PERFORMANCE_COUNT0_CONTROL_INC_ENABLE_SHFT 16
-#define SH_PERFORMANCE_COUNT0_CONTROL_INC_ENABLE_MASK 0x0000000000010000
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_DEC_ENABLE                           */
-/*   Description:  Counter 0 enable decrement                           */
-#define SH_PERFORMANCE_COUNT0_CONTROL_DEC_ENABLE_SHFT 17
-#define SH_PERFORMANCE_COUNT0_CONTROL_DEC_ENABLE_MASK 0x0000000000020000
-
-/*   SH_PERFORMANCE_COUNT0_CONTROL_PEAK_DET_ENABLE                      */
-/*   Description:  Counter 0 enable peak detection                      */
-#define SH_PERFORMANCE_COUNT0_CONTROL_PEAK_DET_ENABLE_SHFT 18
-#define SH_PERFORMANCE_COUNT0_CONTROL_PEAK_DET_ENABLE_MASK 0x0000000000040000
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT1_CONTROL"               */
-/*                    Performance Counter 1 Control                     */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNT1_CONTROL            0x0000000110090000
-#define SH_PERFORMANCE_COUNT1_CONTROL_MASK       0x000000000007ffff
-#define SH_PERFORMANCE_COUNT1_CONTROL_INIT       0x000000000000b8b8
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_UP_STIMULUS                          */
-/*   Description:  Counter 1 up stimulus                                */
-#define SH_PERFORMANCE_COUNT1_CONTROL_UP_STIMULUS_SHFT 0
-#define SH_PERFORMANCE_COUNT1_CONTROL_UP_STIMULUS_MASK 0x000000000000001f
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_UP_EVENT                             */
-/*   Description:  Counter 1 up event select (1-greater than, 0-equal)  */
-#define SH_PERFORMANCE_COUNT1_CONTROL_UP_EVENT_SHFT 5
-#define SH_PERFORMANCE_COUNT1_CONTROL_UP_EVENT_MASK 0x0000000000000020
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_UP_POLARITY                          */
-/*   Description:  Counter 1 up polarity select (1-negative edge, 0-po  */
-/*  sitive edge)                                                        */
-#define SH_PERFORMANCE_COUNT1_CONTROL_UP_POLARITY_SHFT 6
-#define SH_PERFORMANCE_COUNT1_CONTROL_UP_POLARITY_MASK 0x0000000000000040
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_UP_MODE                              */
-/*   Description:  Counter 1 up mode select (1-internal, 0-external)    */
-#define SH_PERFORMANCE_COUNT1_CONTROL_UP_MODE_SHFT 7
-#define SH_PERFORMANCE_COUNT1_CONTROL_UP_MODE_MASK 0x0000000000000080
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_DN_STIMULUS                          */
-/*   Description:  Counter 1 down stimulus                              */
-#define SH_PERFORMANCE_COUNT1_CONTROL_DN_STIMULUS_SHFT 8
-#define SH_PERFORMANCE_COUNT1_CONTROL_DN_STIMULUS_MASK 0x0000000000001f00
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_DN_EVENT                             */
-/*   Description:  Counter 1 down event select (1-greater than, 0-equa  */
-#define SH_PERFORMANCE_COUNT1_CONTROL_DN_EVENT_SHFT 13
-#define SH_PERFORMANCE_COUNT1_CONTROL_DN_EVENT_MASK 0x0000000000002000
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_DN_POLARITY                          */
-/*   Description:  Counter 1 down polarity select (1-negative edge, 0-  */
-/*  positive edge)                                                      */
-#define SH_PERFORMANCE_COUNT1_CONTROL_DN_POLARITY_SHFT 14
-#define SH_PERFORMANCE_COUNT1_CONTROL_DN_POLARITY_MASK 0x0000000000004000
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_DN_MODE                              */
-/*   Description:  Counter 1 down mode select (1-internal, 0-external)  */
-#define SH_PERFORMANCE_COUNT1_CONTROL_DN_MODE_SHFT 15
-#define SH_PERFORMANCE_COUNT1_CONTROL_DN_MODE_MASK 0x0000000000008000
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_INC_ENABLE                           */
-/*   Description:  Counter 1 enable increment                           */
-#define SH_PERFORMANCE_COUNT1_CONTROL_INC_ENABLE_SHFT 16
-#define SH_PERFORMANCE_COUNT1_CONTROL_INC_ENABLE_MASK 0x0000000000010000
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_DEC_ENABLE                           */
-/*   Description:  Counter 1 enable decrement                           */
-#define SH_PERFORMANCE_COUNT1_CONTROL_DEC_ENABLE_SHFT 17
-#define SH_PERFORMANCE_COUNT1_CONTROL_DEC_ENABLE_MASK 0x0000000000020000
-
-/*   SH_PERFORMANCE_COUNT1_CONTROL_PEAK_DET_ENABLE                      */
-/*   Description:  Counter 1 enable peak detection                      */
-#define SH_PERFORMANCE_COUNT1_CONTROL_PEAK_DET_ENABLE_SHFT 18
-#define SH_PERFORMANCE_COUNT1_CONTROL_PEAK_DET_ENABLE_MASK 0x0000000000040000
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT2_CONTROL"               */
-/*                    Performance Counter 2 Control                     */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNT2_CONTROL            0x00000001100a0000
-#define SH_PERFORMANCE_COUNT2_CONTROL_MASK       0x000000000007ffff
-#define SH_PERFORMANCE_COUNT2_CONTROL_INIT       0x000000000000b8b8
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_UP_STIMULUS                          */
-/*   Description:  Counter 2 up stimulus                                */
-#define SH_PERFORMANCE_COUNT2_CONTROL_UP_STIMULUS_SHFT 0
-#define SH_PERFORMANCE_COUNT2_CONTROL_UP_STIMULUS_MASK 0x000000000000001f
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_UP_EVENT                             */
-/*   Description:  Counter 2 up event select (1-greater than, 0-equal)  */
-#define SH_PERFORMANCE_COUNT2_CONTROL_UP_EVENT_SHFT 5
-#define SH_PERFORMANCE_COUNT2_CONTROL_UP_EVENT_MASK 0x0000000000000020
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_UP_POLARITY                          */
-/*   Description:  Counter 2 up polarity select (1-negative edge, 0-po  */
-/*  sitive edge)                                                        */
-#define SH_PERFORMANCE_COUNT2_CONTROL_UP_POLARITY_SHFT 6
-#define SH_PERFORMANCE_COUNT2_CONTROL_UP_POLARITY_MASK 0x0000000000000040
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_UP_MODE                              */
-/*   Description:  Counter 2 up mode select (1-internal, 0-external)    */
-#define SH_PERFORMANCE_COUNT2_CONTROL_UP_MODE_SHFT 7
-#define SH_PERFORMANCE_COUNT2_CONTROL_UP_MODE_MASK 0x0000000000000080
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_DN_STIMULUS                          */
-/*   Description:  Counter 2 down stimulus                              */
-#define SH_PERFORMANCE_COUNT2_CONTROL_DN_STIMULUS_SHFT 8
-#define SH_PERFORMANCE_COUNT2_CONTROL_DN_STIMULUS_MASK 0x0000000000001f00
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_DN_EVENT                             */
-/*   Description:  Counter 2 down event select (1-greater than, 0-equa  */
-#define SH_PERFORMANCE_COUNT2_CONTROL_DN_EVENT_SHFT 13
-#define SH_PERFORMANCE_COUNT2_CONTROL_DN_EVENT_MASK 0x0000000000002000
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_DN_POLARITY                          */
-/*   Description:  Counter 2 down polarity select (1-negative edge, 0-  */
-/*  positive edge)                                                      */
-#define SH_PERFORMANCE_COUNT2_CONTROL_DN_POLARITY_SHFT 14
-#define SH_PERFORMANCE_COUNT2_CONTROL_DN_POLARITY_MASK 0x0000000000004000
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_DN_MODE                              */
-/*   Description:  Counter 2 down mode select (1-internal, 0-external)  */
-#define SH_PERFORMANCE_COUNT2_CONTROL_DN_MODE_SHFT 15
-#define SH_PERFORMANCE_COUNT2_CONTROL_DN_MODE_MASK 0x0000000000008000
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_INC_ENABLE                           */
-/*   Description:  Counter 2 enable increment                           */
-#define SH_PERFORMANCE_COUNT2_CONTROL_INC_ENABLE_SHFT 16
-#define SH_PERFORMANCE_COUNT2_CONTROL_INC_ENABLE_MASK 0x0000000000010000
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_DEC_ENABLE                           */
-/*   Description:  Counter 2 enable decrement                           */
-#define SH_PERFORMANCE_COUNT2_CONTROL_DEC_ENABLE_SHFT 17
-#define SH_PERFORMANCE_COUNT2_CONTROL_DEC_ENABLE_MASK 0x0000000000020000
-
-/*   SH_PERFORMANCE_COUNT2_CONTROL_PEAK_DET_ENABLE                      */
-/*   Description:  Counter 2 enable peak detection                      */
-#define SH_PERFORMANCE_COUNT2_CONTROL_PEAK_DET_ENABLE_SHFT 18
-#define SH_PERFORMANCE_COUNT2_CONTROL_PEAK_DET_ENABLE_MASK 0x0000000000040000
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT3_CONTROL"               */
-/*                    Performance Counter 3 Control                     */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNT3_CONTROL            0x00000001100b0000
-#define SH_PERFORMANCE_COUNT3_CONTROL_MASK       0x000000000007ffff
-#define SH_PERFORMANCE_COUNT3_CONTROL_INIT       0x000000000000b8b8
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_UP_STIMULUS                          */
-/*   Description:  Counter 3 up stimulus                                */
-#define SH_PERFORMANCE_COUNT3_CONTROL_UP_STIMULUS_SHFT 0
-#define SH_PERFORMANCE_COUNT3_CONTROL_UP_STIMULUS_MASK 0x000000000000001f
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_UP_EVENT                             */
-/*   Description:  Counter 3 up event select (1-greater than, 0-equal)  */
-#define SH_PERFORMANCE_COUNT3_CONTROL_UP_EVENT_SHFT 5
-#define SH_PERFORMANCE_COUNT3_CONTROL_UP_EVENT_MASK 0x0000000000000020
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_UP_POLARITY                          */
-/*   Description:  Counter 3 up polarity select (1-negative edge, 0-po  */
-/*  sitive edge)                                                        */
-#define SH_PERFORMANCE_COUNT3_CONTROL_UP_POLARITY_SHFT 6
-#define SH_PERFORMANCE_COUNT3_CONTROL_UP_POLARITY_MASK 0x0000000000000040
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_UP_MODE                              */
-/*   Description:  Counter 3 up mode select (1-internal, 0-external)    */
-#define SH_PERFORMANCE_COUNT3_CONTROL_UP_MODE_SHFT 7
-#define SH_PERFORMANCE_COUNT3_CONTROL_UP_MODE_MASK 0x0000000000000080
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_DN_STIMULUS                          */
-/*   Description:  Counter 3 down stimulus                              */
-#define SH_PERFORMANCE_COUNT3_CONTROL_DN_STIMULUS_SHFT 8
-#define SH_PERFORMANCE_COUNT3_CONTROL_DN_STIMULUS_MASK 0x0000000000001f00
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_DN_EVENT                             */
-/*   Description:  Counter 3 down event select (1-greater than, 0-equa  */
-#define SH_PERFORMANCE_COUNT3_CONTROL_DN_EVENT_SHFT 13
-#define SH_PERFORMANCE_COUNT3_CONTROL_DN_EVENT_MASK 0x0000000000002000
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_DN_POLARITY                          */
-/*   Description:  Counter 3 down polarity select (1-negative edge, 0-  */
-/*  positive edge)                                                      */
-#define SH_PERFORMANCE_COUNT3_CONTROL_DN_POLARITY_SHFT 14
-#define SH_PERFORMANCE_COUNT3_CONTROL_DN_POLARITY_MASK 0x0000000000004000
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_DN_MODE                              */
-/*   Description:  Counter 3 down mode select (1-internal, 0-external)  */
-#define SH_PERFORMANCE_COUNT3_CONTROL_DN_MODE_SHFT 15
-#define SH_PERFORMANCE_COUNT3_CONTROL_DN_MODE_MASK 0x0000000000008000
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_INC_ENABLE                           */
-/*   Description:  Counter 3 enable increment                           */
-#define SH_PERFORMANCE_COUNT3_CONTROL_INC_ENABLE_SHFT 16
-#define SH_PERFORMANCE_COUNT3_CONTROL_INC_ENABLE_MASK 0x0000000000010000
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_DEC_ENABLE                           */
-/*   Description:  Counter 3 enable decrement                           */
-#define SH_PERFORMANCE_COUNT3_CONTROL_DEC_ENABLE_SHFT 17
-#define SH_PERFORMANCE_COUNT3_CONTROL_DEC_ENABLE_MASK 0x0000000000020000
-
-/*   SH_PERFORMANCE_COUNT3_CONTROL_PEAK_DET_ENABLE                      */
-/*   Description:  Counter 3 enable peak detection                      */
-#define SH_PERFORMANCE_COUNT3_CONTROL_PEAK_DET_ENABLE_SHFT 18
-#define SH_PERFORMANCE_COUNT3_CONTROL_PEAK_DET_ENABLE_MASK 0x0000000000040000
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT4_CONTROL"               */
-/*                    Performance Counter 4 Control                     */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNT4_CONTROL            0x00000001100c0000
-#define SH_PERFORMANCE_COUNT4_CONTROL_MASK       0x000000000007ffff
-#define SH_PERFORMANCE_COUNT4_CONTROL_INIT       0x000000000000b8b8
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_UP_STIMULUS                          */
-/*   Description:  Counter 4 up stimulus                                */
-#define SH_PERFORMANCE_COUNT4_CONTROL_UP_STIMULUS_SHFT 0
-#define SH_PERFORMANCE_COUNT4_CONTROL_UP_STIMULUS_MASK 0x000000000000001f
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_UP_EVENT                             */
-/*   Description:  Counter 4 up event select (1-greater than, 0-equal)  */
-#define SH_PERFORMANCE_COUNT4_CONTROL_UP_EVENT_SHFT 5
-#define SH_PERFORMANCE_COUNT4_CONTROL_UP_EVENT_MASK 0x0000000000000020
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_UP_POLARITY                          */
-/*   Description:  Counter 4 up polarity select (1-negative edge, 0-po  */
-/*  sitive edge)                                                        */
-#define SH_PERFORMANCE_COUNT4_CONTROL_UP_POLARITY_SHFT 6
-#define SH_PERFORMANCE_COUNT4_CONTROL_UP_POLARITY_MASK 0x0000000000000040
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_UP_MODE                              */
-/*   Description:  Counter 4 up mode select (1-internal, 0-external)    */
-#define SH_PERFORMANCE_COUNT4_CONTROL_UP_MODE_SHFT 7
-#define SH_PERFORMANCE_COUNT4_CONTROL_UP_MODE_MASK 0x0000000000000080
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_DN_STIMULUS                          */
-/*   Description:  Counter 4 down stimulus                              */
-#define SH_PERFORMANCE_COUNT4_CONTROL_DN_STIMULUS_SHFT 8
-#define SH_PERFORMANCE_COUNT4_CONTROL_DN_STIMULUS_MASK 0x0000000000001f00
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_DN_EVENT                             */
-/*   Description:  Counter 4 down event select (1-greater than, 0-equa  */
-#define SH_PERFORMANCE_COUNT4_CONTROL_DN_EVENT_SHFT 13
-#define SH_PERFORMANCE_COUNT4_CONTROL_DN_EVENT_MASK 0x0000000000002000
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_DN_POLARITY                          */
-/*   Description:  Counter 4 down polarity select (1-negative edge, 0-  */
-/*  positive edge)                                                      */
-#define SH_PERFORMANCE_COUNT4_CONTROL_DN_POLARITY_SHFT 14
-#define SH_PERFORMANCE_COUNT4_CONTROL_DN_POLARITY_MASK 0x0000000000004000
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_DN_MODE                              */
-/*   Description:  Counter 4 down mode select (1-internal, 0-external)  */
-#define SH_PERFORMANCE_COUNT4_CONTROL_DN_MODE_SHFT 15
-#define SH_PERFORMANCE_COUNT4_CONTROL_DN_MODE_MASK 0x0000000000008000
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_INC_ENABLE                           */
-/*   Description:  Counter 4 enable increment                           */
-#define SH_PERFORMANCE_COUNT4_CONTROL_INC_ENABLE_SHFT 16
-#define SH_PERFORMANCE_COUNT4_CONTROL_INC_ENABLE_MASK 0x0000000000010000
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_DEC_ENABLE                           */
-/*   Description:  Counter 4 enable decrement                           */
-#define SH_PERFORMANCE_COUNT4_CONTROL_DEC_ENABLE_SHFT 17
-#define SH_PERFORMANCE_COUNT4_CONTROL_DEC_ENABLE_MASK 0x0000000000020000
-
-/*   SH_PERFORMANCE_COUNT4_CONTROL_PEAK_DET_ENABLE                      */
-/*   Description:  Counter 4 enable peak detection                      */
-#define SH_PERFORMANCE_COUNT4_CONTROL_PEAK_DET_ENABLE_SHFT 18
-#define SH_PERFORMANCE_COUNT4_CONTROL_PEAK_DET_ENABLE_MASK 0x0000000000040000
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT5_CONTROL"               */
-/*                    Performance Counter 5 Control                     */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNT5_CONTROL            0x00000001100d0000
-#define SH_PERFORMANCE_COUNT5_CONTROL_MASK       0x000000000007ffff
-#define SH_PERFORMANCE_COUNT5_CONTROL_INIT       0x000000000000b8b8
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_UP_STIMULUS                          */
-/*   Description:  Counter 5 up stimulus                                */
-#define SH_PERFORMANCE_COUNT5_CONTROL_UP_STIMULUS_SHFT 0
-#define SH_PERFORMANCE_COUNT5_CONTROL_UP_STIMULUS_MASK 0x000000000000001f
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_UP_EVENT                             */
-/*   Description:  Counter 5 up event select (1-greater than, 0-equal)  */
-#define SH_PERFORMANCE_COUNT5_CONTROL_UP_EVENT_SHFT 5
-#define SH_PERFORMANCE_COUNT5_CONTROL_UP_EVENT_MASK 0x0000000000000020
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_UP_POLARITY                          */
-/*   Description:  Counter 5 up polarity select (1-negative edge, 0-po  */
-/*  sitive edge)                                                        */
-#define SH_PERFORMANCE_COUNT5_CONTROL_UP_POLARITY_SHFT 6
-#define SH_PERFORMANCE_COUNT5_CONTROL_UP_POLARITY_MASK 0x0000000000000040
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_UP_MODE                              */
-/*   Description:  Counter 5 up mode select (1-internal, 0-external)    */
-#define SH_PERFORMANCE_COUNT5_CONTROL_UP_MODE_SHFT 7
-#define SH_PERFORMANCE_COUNT5_CONTROL_UP_MODE_MASK 0x0000000000000080
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_DN_STIMULUS                          */
-/*   Description:  Counter 5 down stimulus                              */
-#define SH_PERFORMANCE_COUNT5_CONTROL_DN_STIMULUS_SHFT 8
-#define SH_PERFORMANCE_COUNT5_CONTROL_DN_STIMULUS_MASK 0x0000000000001f00
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_DN_EVENT                             */
-/*   Description:  Counter 5 down event select (1-greater than, 0-equa  */
-#define SH_PERFORMANCE_COUNT5_CONTROL_DN_EVENT_SHFT 13
-#define SH_PERFORMANCE_COUNT5_CONTROL_DN_EVENT_MASK 0x0000000000002000
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_DN_POLARITY                          */
-/*   Description:  Counter 5 down polarity select (1-negative edge, 0-  */
-/*  positive edge)                                                      */
-#define SH_PERFORMANCE_COUNT5_CONTROL_DN_POLARITY_SHFT 14
-#define SH_PERFORMANCE_COUNT5_CONTROL_DN_POLARITY_MASK 0x0000000000004000
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_DN_MODE                              */
-/*   Description:  Counter 5 down mode select (1-internal, 0-external)  */
-#define SH_PERFORMANCE_COUNT5_CONTROL_DN_MODE_SHFT 15
-#define SH_PERFORMANCE_COUNT5_CONTROL_DN_MODE_MASK 0x0000000000008000
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_INC_ENABLE                           */
-/*   Description:  Counter 5 enable increment                           */
-#define SH_PERFORMANCE_COUNT5_CONTROL_INC_ENABLE_SHFT 16
-#define SH_PERFORMANCE_COUNT5_CONTROL_INC_ENABLE_MASK 0x0000000000010000
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_DEC_ENABLE                           */
-/*   Description:  Counter 5 enable decrement                           */
-#define SH_PERFORMANCE_COUNT5_CONTROL_DEC_ENABLE_SHFT 17
-#define SH_PERFORMANCE_COUNT5_CONTROL_DEC_ENABLE_MASK 0x0000000000020000
-
-/*   SH_PERFORMANCE_COUNT5_CONTROL_PEAK_DET_ENABLE                      */
-/*   Description:  Counter 5 enable peak detection                      */
-#define SH_PERFORMANCE_COUNT5_CONTROL_PEAK_DET_ENABLE_SHFT 18
-#define SH_PERFORMANCE_COUNT5_CONTROL_PEAK_DET_ENABLE_MASK 0x0000000000040000
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT6_CONTROL"               */
-/*                    Performance Counter 6 Control                     */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNT6_CONTROL            0x00000001100e0000
-#define SH_PERFORMANCE_COUNT6_CONTROL_MASK       0x000000000007ffff
-#define SH_PERFORMANCE_COUNT6_CONTROL_INIT       0x000000000000b8b8
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_UP_STIMULUS                          */
-/*   Description:  Counter 6 up stimulus                                */
-#define SH_PERFORMANCE_COUNT6_CONTROL_UP_STIMULUS_SHFT 0
-#define SH_PERFORMANCE_COUNT6_CONTROL_UP_STIMULUS_MASK 0x000000000000001f
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_UP_EVENT                             */
-/*   Description:  Counter 6 up event select (1-greater than, 0-equal)  */
-#define SH_PERFORMANCE_COUNT6_CONTROL_UP_EVENT_SHFT 5
-#define SH_PERFORMANCE_COUNT6_CONTROL_UP_EVENT_MASK 0x0000000000000020
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_UP_POLARITY                          */
-/*   Description:  Counter 6 up polarity select (1-negative edge, 0-po  */
-/*  sitive edge)                                                        */
-#define SH_PERFORMANCE_COUNT6_CONTROL_UP_POLARITY_SHFT 6
-#define SH_PERFORMANCE_COUNT6_CONTROL_UP_POLARITY_MASK 0x0000000000000040
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_UP_MODE                              */
-/*   Description:  Counter 6 up mode select (1-internal, 0-external)    */
-#define SH_PERFORMANCE_COUNT6_CONTROL_UP_MODE_SHFT 7
-#define SH_PERFORMANCE_COUNT6_CONTROL_UP_MODE_MASK 0x0000000000000080
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_DN_STIMULUS                          */
-/*   Description:  Counter 6 down stimulus                              */
-#define SH_PERFORMANCE_COUNT6_CONTROL_DN_STIMULUS_SHFT 8
-#define SH_PERFORMANCE_COUNT6_CONTROL_DN_STIMULUS_MASK 0x0000000000001f00
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_DN_EVENT                             */
-/*   Description:  Counter 6 down event select (1-greater than, 0-equa  */
-#define SH_PERFORMANCE_COUNT6_CONTROL_DN_EVENT_SHFT 13
-#define SH_PERFORMANCE_COUNT6_CONTROL_DN_EVENT_MASK 0x0000000000002000
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_DN_POLARITY                          */
-/*   Description:  Counter 6 down polarity select (1-negative edge, 0-  */
-/*  positive edge)                                                      */
-#define SH_PERFORMANCE_COUNT6_CONTROL_DN_POLARITY_SHFT 14
-#define SH_PERFORMANCE_COUNT6_CONTROL_DN_POLARITY_MASK 0x0000000000004000
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_DN_MODE                              */
-/*   Description:  Counter 6 down mode select (1-internal, 0-external)  */
-#define SH_PERFORMANCE_COUNT6_CONTROL_DN_MODE_SHFT 15
-#define SH_PERFORMANCE_COUNT6_CONTROL_DN_MODE_MASK 0x0000000000008000
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_INC_ENABLE                           */
-/*   Description:  Counter 6 enable increment                           */
-#define SH_PERFORMANCE_COUNT6_CONTROL_INC_ENABLE_SHFT 16
-#define SH_PERFORMANCE_COUNT6_CONTROL_INC_ENABLE_MASK 0x0000000000010000
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_DEC_ENABLE                           */
-/*   Description:  Counter 6 enable decrement                           */
-#define SH_PERFORMANCE_COUNT6_CONTROL_DEC_ENABLE_SHFT 17
-#define SH_PERFORMANCE_COUNT6_CONTROL_DEC_ENABLE_MASK 0x0000000000020000
-
-/*   SH_PERFORMANCE_COUNT6_CONTROL_PEAK_DET_ENABLE                      */
-/*   Description:  Counter 6 enable peak detection                      */
-#define SH_PERFORMANCE_COUNT6_CONTROL_PEAK_DET_ENABLE_SHFT 18
-#define SH_PERFORMANCE_COUNT6_CONTROL_PEAK_DET_ENABLE_MASK 0x0000000000040000
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT7_CONTROL"               */
-/*                    Performance Counter 7 Control                     */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNT7_CONTROL            0x00000001100f0000
-#define SH_PERFORMANCE_COUNT7_CONTROL_MASK       0x000000000007ffff
-#define SH_PERFORMANCE_COUNT7_CONTROL_INIT       0x000000000000b8b8
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_UP_STIMULUS                          */
-/*   Description:  Counter 7 up stimulus                                */
-#define SH_PERFORMANCE_COUNT7_CONTROL_UP_STIMULUS_SHFT 0
-#define SH_PERFORMANCE_COUNT7_CONTROL_UP_STIMULUS_MASK 0x000000000000001f
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_UP_EVENT                             */
-/*   Description:  Counter 7 up event select (1-greater than, 0-equal)  */
-#define SH_PERFORMANCE_COUNT7_CONTROL_UP_EVENT_SHFT 5
-#define SH_PERFORMANCE_COUNT7_CONTROL_UP_EVENT_MASK 0x0000000000000020
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_UP_POLARITY                          */
-/*   Description:  Counter 7 up polarity select (1-negative edge, 0-po  */
-/*  sitive edge)                                                        */
-#define SH_PERFORMANCE_COUNT7_CONTROL_UP_POLARITY_SHFT 6
-#define SH_PERFORMANCE_COUNT7_CONTROL_UP_POLARITY_MASK 0x0000000000000040
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_UP_MODE                              */
-/*   Description:  Counter 7 up mode select (1-internal, 0-external)    */
-#define SH_PERFORMANCE_COUNT7_CONTROL_UP_MODE_SHFT 7
-#define SH_PERFORMANCE_COUNT7_CONTROL_UP_MODE_MASK 0x0000000000000080
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_DN_STIMULUS                          */
-/*   Description:  Counter 7 down stimulus                              */
-#define SH_PERFORMANCE_COUNT7_CONTROL_DN_STIMULUS_SHFT 8
-#define SH_PERFORMANCE_COUNT7_CONTROL_DN_STIMULUS_MASK 0x0000000000001f00
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_DN_EVENT                             */
-/*   Description:  Counter 7 down event select (1-greater than, 0-equa  */
-#define SH_PERFORMANCE_COUNT7_CONTROL_DN_EVENT_SHFT 13
-#define SH_PERFORMANCE_COUNT7_CONTROL_DN_EVENT_MASK 0x0000000000002000
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_DN_POLARITY                          */
-/*   Description:  Counter 7 down polarity select (1-negative edge, 0-  */
-/*  positive edge)                                                      */
-#define SH_PERFORMANCE_COUNT7_CONTROL_DN_POLARITY_SHFT 14
-#define SH_PERFORMANCE_COUNT7_CONTROL_DN_POLARITY_MASK 0x0000000000004000
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_DN_MODE                              */
-/*   Description:  Counter 7 down mode select (1-internal, 0-external)  */
-#define SH_PERFORMANCE_COUNT7_CONTROL_DN_MODE_SHFT 15
-#define SH_PERFORMANCE_COUNT7_CONTROL_DN_MODE_MASK 0x0000000000008000
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_INC_ENABLE                           */
-/*   Description:  Counter 7 enable increment                           */
-#define SH_PERFORMANCE_COUNT7_CONTROL_INC_ENABLE_SHFT 16
-#define SH_PERFORMANCE_COUNT7_CONTROL_INC_ENABLE_MASK 0x0000000000010000
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_DEC_ENABLE                           */
-/*   Description:  Counter 7 enable decrement                           */
-#define SH_PERFORMANCE_COUNT7_CONTROL_DEC_ENABLE_SHFT 17
-#define SH_PERFORMANCE_COUNT7_CONTROL_DEC_ENABLE_MASK 0x0000000000020000
-
-/*   SH_PERFORMANCE_COUNT7_CONTROL_PEAK_DET_ENABLE                      */
-/*   Description:  Counter 7 enable peak detection                      */
-#define SH_PERFORMANCE_COUNT7_CONTROL_PEAK_DET_ENABLE_SHFT 18
-#define SH_PERFORMANCE_COUNT7_CONTROL_PEAK_DET_ENABLE_MASK 0x0000000000040000
-
-/* ==================================================================== */
-/*                   Register "SH_PROFILE_DN_CONTROL"                   */
-/*                     Profile Counter Down Control                     */
-/* ==================================================================== */
-
-#define SH_PROFILE_DN_CONTROL                    0x0000000110100000
-#define SH_PROFILE_DN_CONTROL_MASK               0x00000000000000ff
-#define SH_PROFILE_DN_CONTROL_INIT               0x00000000000000b8
-
-/*   SH_PROFILE_DN_CONTROL_STIMULUS                                     */
-/*   Description:  Counter stimulus                                     */
-#define SH_PROFILE_DN_CONTROL_STIMULUS_SHFT      0
-#define SH_PROFILE_DN_CONTROL_STIMULUS_MASK      0x000000000000001f
-
-/*   SH_PROFILE_DN_CONTROL_EVENT                                        */
-/*   Description:  Counter event select (1-greater than, 0-equal)       */
-#define SH_PROFILE_DN_CONTROL_EVENT_SHFT         5
-#define SH_PROFILE_DN_CONTROL_EVENT_MASK         0x0000000000000020
-
-/*   SH_PROFILE_DN_CONTROL_POLARITY                                     */
-/*   Description:  Counter polarity select (1-negative edge, 0-positiv  */
-/*  e edge)                                                             */
-#define SH_PROFILE_DN_CONTROL_POLARITY_SHFT      6
-#define SH_PROFILE_DN_CONTROL_POLARITY_MASK      0x0000000000000040
-
-/*   SH_PROFILE_DN_CONTROL_MODE                                         */
-/*   Description:  Counter mode select (1-internal, 0-external)         */
-#define SH_PROFILE_DN_CONTROL_MODE_SHFT          7
-#define SH_PROFILE_DN_CONTROL_MODE_MASK          0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_PROFILE_PEAK_CONTROL"                  */
-/*                     Profile Counter Peak Control                     */
-/* ==================================================================== */
-
-#define SH_PROFILE_PEAK_CONTROL                  0x0000000110100080
-#define SH_PROFILE_PEAK_CONTROL_MASK             0x0000000000000068
-#define SH_PROFILE_PEAK_CONTROL_INIT             0x0000000000000060
-
-/*   SH_PROFILE_PEAK_CONTROL_STIMULUS                                   */
-/*   Description:  Counter stimulus                                     */
-#define SH_PROFILE_PEAK_CONTROL_STIMULUS_SHFT    3
-#define SH_PROFILE_PEAK_CONTROL_STIMULUS_MASK    0x0000000000000008
-
-/*   SH_PROFILE_PEAK_CONTROL_EVENT                                      */
-/*   Description:  Counter event select (0-greater than, 1-equal)       */
-#define SH_PROFILE_PEAK_CONTROL_EVENT_SHFT       5
-#define SH_PROFILE_PEAK_CONTROL_EVENT_MASK       0x0000000000000020
-
-/*   SH_PROFILE_PEAK_CONTROL_POLARITY                                   */
-/*   Description:  Counter polarity select (0-negative edge, 1-positiv  */
-/*  e edge)                                                             */
-#define SH_PROFILE_PEAK_CONTROL_POLARITY_SHFT    6
-#define SH_PROFILE_PEAK_CONTROL_POLARITY_MASK    0x0000000000000040
-
-/* ==================================================================== */
-/*                     Register "SH_PROFILE_RANGE"                      */
-/*                        Profile Counter Range                         */
-/* ==================================================================== */
-
-#define SH_PROFILE_RANGE                         0x0000000110100100
-#define SH_PROFILE_RANGE_MASK                    0xffffffffffffffff
-#define SH_PROFILE_RANGE_INIT                    0x0000000000000000
-
-/*   SH_PROFILE_RANGE_RANGE0                                            */
-/*   Description:  Profiling range 0                                    */
-#define SH_PROFILE_RANGE_RANGE0_SHFT             0
-#define SH_PROFILE_RANGE_RANGE0_MASK             0x00000000000000ff
-
-/*   SH_PROFILE_RANGE_RANGE1                                            */
-/*   Description:  Profiling range 1                                    */
-#define SH_PROFILE_RANGE_RANGE1_SHFT             8
-#define SH_PROFILE_RANGE_RANGE1_MASK             0x000000000000ff00
-
-/*   SH_PROFILE_RANGE_RANGE2                                            */
-/*   Description:  Profiling range 2                                    */
-#define SH_PROFILE_RANGE_RANGE2_SHFT             16
-#define SH_PROFILE_RANGE_RANGE2_MASK             0x0000000000ff0000
-
-/*   SH_PROFILE_RANGE_RANGE3                                            */
-/*   Description:  Profiling range 3                                    */
-#define SH_PROFILE_RANGE_RANGE3_SHFT             24
-#define SH_PROFILE_RANGE_RANGE3_MASK             0x00000000ff000000
-
-/*   SH_PROFILE_RANGE_RANGE4                                            */
-/*   Description:  Profiling range 4                                    */
-#define SH_PROFILE_RANGE_RANGE4_SHFT             32
-#define SH_PROFILE_RANGE_RANGE4_MASK             0x000000ff00000000
-
-/*   SH_PROFILE_RANGE_RANGE5                                            */
-/*   Description:  Profiling range 5                                    */
-#define SH_PROFILE_RANGE_RANGE5_SHFT             40
-#define SH_PROFILE_RANGE_RANGE5_MASK             0x0000ff0000000000
-
-/*   SH_PROFILE_RANGE_RANGE6                                            */
-/*   Description:  Profiling range 6                                    */
-#define SH_PROFILE_RANGE_RANGE6_SHFT             48
-#define SH_PROFILE_RANGE_RANGE6_MASK             0x00ff000000000000
-
-/*   SH_PROFILE_RANGE_RANGE7                                            */
-/*   Description:  Profiling range 7                                    */
-#define SH_PROFILE_RANGE_RANGE7_SHFT             56
-#define SH_PROFILE_RANGE_RANGE7_MASK             0xff00000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_PROFILE_UP_CONTROL"                   */
-/*                      Profile Counter Up Control                      */
-/* ==================================================================== */
-
-#define SH_PROFILE_UP_CONTROL                    0x0000000110100180
-#define SH_PROFILE_UP_CONTROL_MASK               0x00000000000000ff
-#define SH_PROFILE_UP_CONTROL_INIT               0x00000000000000b8
-
-/*   SH_PROFILE_UP_CONTROL_STIMULUS                                     */
-/*   Description:  Counter stimulus                                     */
-#define SH_PROFILE_UP_CONTROL_STIMULUS_SHFT      0
-#define SH_PROFILE_UP_CONTROL_STIMULUS_MASK      0x000000000000001f
-
-/*   SH_PROFILE_UP_CONTROL_EVENT                                        */
-/*   Description:  Counter event select (1-greater than, 0-equal)       */
-#define SH_PROFILE_UP_CONTROL_EVENT_SHFT         5
-#define SH_PROFILE_UP_CONTROL_EVENT_MASK         0x0000000000000020
-
-/*   SH_PROFILE_UP_CONTROL_POLARITY                                     */
-/*   Description:  Counter polarity select (1-negative edge, 0-positiv  */
-/*  e edge)                                                             */
-#define SH_PROFILE_UP_CONTROL_POLARITY_SHFT      6
-#define SH_PROFILE_UP_CONTROL_POLARITY_MASK      0x0000000000000040
-
-/*   SH_PROFILE_UP_CONTROL_MODE                                         */
-/*   Description:  Counter mode select (1-internal, 0-external)         */
-#define SH_PROFILE_UP_CONTROL_MODE_SHFT          7
-#define SH_PROFILE_UP_CONTROL_MODE_MASK          0x0000000000000080
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER0"                  */
-/*                        Performance Counter 0                         */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNTER0                  0x0000000110110000
-#define SH_PERFORMANCE_COUNTER0_MASK             0x00000000ffffffff
-#define SH_PERFORMANCE_COUNTER0_INIT             0x0000000000000000
-
-/*   SH_PERFORMANCE_COUNTER0_COUNT                                      */
-/*   Description:  Counter 0                                            */
-#define SH_PERFORMANCE_COUNTER0_COUNT_SHFT       0
-#define SH_PERFORMANCE_COUNTER0_COUNT_MASK       0x00000000ffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER1"                  */
-/*                        Performance Counter 1                         */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNTER1                  0x0000000110120000
-#define SH_PERFORMANCE_COUNTER1_MASK             0x00000000ffffffff
-#define SH_PERFORMANCE_COUNTER1_INIT             0x0000000000000000
-
-/*   SH_PERFORMANCE_COUNTER1_COUNT                                      */
-/*   Description:  Counter 1                                            */
-#define SH_PERFORMANCE_COUNTER1_COUNT_SHFT       0
-#define SH_PERFORMANCE_COUNTER1_COUNT_MASK       0x00000000ffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER2"                  */
-/*                        Performance Counter 2                         */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNTER2                  0x0000000110130000
-#define SH_PERFORMANCE_COUNTER2_MASK             0x00000000ffffffff
-#define SH_PERFORMANCE_COUNTER2_INIT             0x0000000000000000
-
-/*   SH_PERFORMANCE_COUNTER2_COUNT                                      */
-/*   Description:  Counter 2                                            */
-#define SH_PERFORMANCE_COUNTER2_COUNT_SHFT       0
-#define SH_PERFORMANCE_COUNTER2_COUNT_MASK       0x00000000ffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER3"                  */
-/*                        Performance Counter 3                         */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNTER3                  0x0000000110140000
-#define SH_PERFORMANCE_COUNTER3_MASK             0x00000000ffffffff
-#define SH_PERFORMANCE_COUNTER3_INIT             0x0000000000000000
-
-/*   SH_PERFORMANCE_COUNTER3_COUNT                                      */
-/*   Description:  Counter 3                                            */
-#define SH_PERFORMANCE_COUNTER3_COUNT_SHFT       0
-#define SH_PERFORMANCE_COUNTER3_COUNT_MASK       0x00000000ffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER4"                  */
-/*                        Performance Counter 4                         */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNTER4                  0x0000000110150000
-#define SH_PERFORMANCE_COUNTER4_MASK             0x00000000ffffffff
-#define SH_PERFORMANCE_COUNTER4_INIT             0x0000000000000000
-
-/*   SH_PERFORMANCE_COUNTER4_COUNT                                      */
-/*   Description:  Counter 4                                            */
-#define SH_PERFORMANCE_COUNTER4_COUNT_SHFT       0
-#define SH_PERFORMANCE_COUNTER4_COUNT_MASK       0x00000000ffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER5"                  */
-/*                        Performance Counter 5                         */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNTER5                  0x0000000110160000
-#define SH_PERFORMANCE_COUNTER5_MASK             0x00000000ffffffff
-#define SH_PERFORMANCE_COUNTER5_INIT             0x0000000000000000
-
-/*   SH_PERFORMANCE_COUNTER5_COUNT                                      */
-/*   Description:  Counter 5                                            */
-#define SH_PERFORMANCE_COUNTER5_COUNT_SHFT       0
-#define SH_PERFORMANCE_COUNTER5_COUNT_MASK       0x00000000ffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER6"                  */
-/*                        Performance Counter 6                         */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNTER6                  0x0000000110170000
-#define SH_PERFORMANCE_COUNTER6_MASK             0x00000000ffffffff
-#define SH_PERFORMANCE_COUNTER6_INIT             0x0000000000000000
-
-/*   SH_PERFORMANCE_COUNTER6_COUNT                                      */
-/*   Description:  Counter 6                                            */
-#define SH_PERFORMANCE_COUNTER6_COUNT_SHFT       0
-#define SH_PERFORMANCE_COUNTER6_COUNT_MASK       0x00000000ffffffff
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER7"                  */
-/*                        Performance Counter 7                         */
-/* ==================================================================== */
-
-#define SH_PERFORMANCE_COUNTER7                  0x0000000110180000
-#define SH_PERFORMANCE_COUNTER7_MASK             0x00000000ffffffff
-#define SH_PERFORMANCE_COUNTER7_INIT             0x0000000000000000
-
-/*   SH_PERFORMANCE_COUNTER7_COUNT                                      */
-/*   Description:  Counter 7                                            */
-#define SH_PERFORMANCE_COUNTER7_COUNT_SHFT       0
-#define SH_PERFORMANCE_COUNTER7_COUNT_MASK       0x00000000ffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_PROFILE_COUNTER"                     */
-/*                           Profile Counter                            */
-/* ==================================================================== */
-
-#define SH_PROFILE_COUNTER                       0x0000000110190000
-#define SH_PROFILE_COUNTER_MASK                  0x00000000000000ff
-#define SH_PROFILE_COUNTER_INIT                  0x0000000000000000
-
-/*   SH_PROFILE_COUNTER_COUNTER                                         */
-/*   Description:  Counter Value                                        */
-#define SH_PROFILE_COUNTER_COUNTER_SHFT          0
-#define SH_PROFILE_COUNTER_COUNTER_MASK          0x00000000000000ff
-
-/* ==================================================================== */
-/*                      Register "SH_PROFILE_PEAK"                      */
-/*                         Profile Peak Counter                         */
-/* ==================================================================== */
-
-#define SH_PROFILE_PEAK                          0x0000000110190080
-#define SH_PROFILE_PEAK_MASK                     0x00000000000000ff
-#define SH_PROFILE_PEAK_INIT                     0x0000000000000000
-
-/*   SH_PROFILE_PEAK_COUNTER                                            */
-/*   Description:  Counter Value                                        */
-#define SH_PROFILE_PEAK_COUNTER_SHFT             0
-#define SH_PROFILE_PEAK_COUNTER_MASK             0x00000000000000ff
-
-/* ==================================================================== */
-/*                         Register "SH_PTC_0"                          */
-/*       Puge Translation Cache Message Configuration Information       */
-/* ==================================================================== */
-
-#define SH_PTC_0                                 0x00000001101a0000
-#define SH_PTC_0_MASK                            0x80000000fffffffd
-#define SH_PTC_0_INIT                            0x0000000000000000
-
-/*   SH_PTC_0_A                                                         */
-/*   Description:  Type                                                 */
-#define SH_PTC_0_A_SHFT                          0
-#define SH_PTC_0_A_MASK                          0x0000000000000001
-
-/*   SH_PTC_0_PS                                                        */
-/*   Description:  Page Size                                            */
-#define SH_PTC_0_PS_SHFT                         2
-#define SH_PTC_0_PS_MASK                         0x00000000000000fc
-
-/*   SH_PTC_0_RID                                                       */
-/*   Description:  Region ID                                            */
-#define SH_PTC_0_RID_SHFT                        8
-#define SH_PTC_0_RID_MASK                        0x00000000ffffff00
-
-/*   SH_PTC_0_START                                                     */
-/*   Description:  Start                                                */
-#define SH_PTC_0_START_SHFT                      63
-#define SH_PTC_0_START_MASK                      0x8000000000000000
-
-/* ==================================================================== */
-/*                         Register "SH_PTC_1"                          */
-/*       Puge Translation Cache Message Configuration Information       */
-/* ==================================================================== */
-
-#define SH_PTC_1                                 0x00000001101a0080
-#define SH_PTC_1_MASK                            0x9ffffffffffff000
-#define SH_PTC_1_INIT                            0x0000000000000000
-
-/*   SH_PTC_1_VPN                                                       */
-/*   Description:  Virtual page number                                  */
-#define SH_PTC_1_VPN_SHFT                        12
-#define SH_PTC_1_VPN_MASK                        0x1ffffffffffff000
-
-/*   SH_PTC_1_START                                                     */
-/*   Description:  PTC_1 Start                                          */
-#define SH_PTC_1_START_SHFT                      63
-#define SH_PTC_1_START_MASK                      0x8000000000000000
-
-/* ==================================================================== */
-/*                       Register "SH_PTC_PARMS"                        */
-/*                       PTC Time-out parmaeters                        */
-/* ==================================================================== */
-
-#define SH_PTC_PARMS                             0x00000001101a0100
-#define SH_PTC_PARMS_MASK                        0x0000000fffffffff
-#define SH_PTC_PARMS_INIT                        0x00000007ffffffff
-
-/*   SH_PTC_PARMS_PTC_TO_WRAP                                           */
-/*   Description:  PTC time-out period                                  */
-#define SH_PTC_PARMS_PTC_TO_WRAP_SHFT            0
-#define SH_PTC_PARMS_PTC_TO_WRAP_MASK            0x0000000000ffffff
-
-/*   SH_PTC_PARMS_PTC_TO_VAL                                            */
-/*   Description:  PTC time-out valid                                   */
-#define SH_PTC_PARMS_PTC_TO_VAL_SHFT             24
-#define SH_PTC_PARMS_PTC_TO_VAL_MASK             0x0000000fff000000
-
-/* ==================================================================== */
-/*                        Register "SH_INT_CMPA"                        */
-/*                  RTC Compare Value for Processor A                   */
-/* ==================================================================== */
-
-#define SH_INT_CMPA                              0x00000001101b0000
-#define SH_INT_CMPA_MASK                         0x007fffffffffffff
-#define SH_INT_CMPA_INIT                         0x0000000000000000
-
-/*   SH_INT_CMPA_REAL_TIME_CMPA                                         */
-/*   Description:  Real Time Clock Compare                              */
-#define SH_INT_CMPA_REAL_TIME_CMPA_SHFT          0
-#define SH_INT_CMPA_REAL_TIME_CMPA_MASK          0x007fffffffffffff
-
-/* ==================================================================== */
-/*                        Register "SH_INT_CMPB"                        */
-/*                  RTC Compare Value for Processor B                   */
-/* ==================================================================== */
-
-#define SH_INT_CMPB                              0x00000001101b0080
-#define SH_INT_CMPB_MASK                         0x007fffffffffffff
-#define SH_INT_CMPB_INIT                         0x0000000000000000
-
-/*   SH_INT_CMPB_REAL_TIME_CMPB                                         */
-/*   Description:  Real Time Clock Compare                              */
-#define SH_INT_CMPB_REAL_TIME_CMPB_SHFT          0
-#define SH_INT_CMPB_REAL_TIME_CMPB_MASK          0x007fffffffffffff
-
-/* ==================================================================== */
-/*                        Register "SH_INT_CMPC"                        */
-/*                  RTC Compare Value for Processor C                   */
-/* ==================================================================== */
-
-#define SH_INT_CMPC                              0x00000001101b0100
-#define SH_INT_CMPC_MASK                         0x007fffffffffffff
-#define SH_INT_CMPC_INIT                         0x0000000000000000
-
-/*   SH_INT_CMPC_REAL_TIME_CMPC                                         */
-/*   Description:  Real Time Clock Compare                              */
-#define SH_INT_CMPC_REAL_TIME_CMPC_SHFT          0
-#define SH_INT_CMPC_REAL_TIME_CMPC_MASK          0x007fffffffffffff
-
-/* ==================================================================== */
-/*                        Register "SH_INT_CMPD"                        */
-/*                  RTC Compare Value for Processor D                   */
-/* ==================================================================== */
-
-#define SH_INT_CMPD                              0x00000001101b0180
-#define SH_INT_CMPD_MASK                         0x007fffffffffffff
-#define SH_INT_CMPD_INIT                         0x0000000000000000
-
-/*   SH_INT_CMPD_REAL_TIME_CMPD                                         */
-/*   Description:  Real Time Clock Compare                              */
-#define SH_INT_CMPD_REAL_TIME_CMPD_SHFT          0
-#define SH_INT_CMPD_REAL_TIME_CMPD_MASK          0x007fffffffffffff
-
-/* ==================================================================== */
-/*                        Register "SH_INT_PROF"                        */
-/*                      Profile Compare Registers                       */
-/* ==================================================================== */
-
-#define SH_INT_PROF                              0x00000001101b0200
-#define SH_INT_PROF_MASK                         0x00000000ffffffff
-#define SH_INT_PROF_INIT                         0x0000000000000000
-
-/*   SH_INT_PROF_PROFILE_COMPARE                                        */
-/*   Description:  Profile Compare                                      */
-#define SH_INT_PROF_PROFILE_COMPARE_SHFT         0
-#define SH_INT_PROF_PROFILE_COMPARE_MASK         0x00000000ffffffff
-
-/* ==================================================================== */
-/*                          Register "SH_RTC"                           */
-/*                           Real-time Clock                            */
-/* ==================================================================== */
-
-#define SH_RTC                                   0x00000001101c0000UL
-#define SH_RTC_MASK                              0x007fffffffffffffUL
-#define SH_RTC_INIT                              0x0000000000000000
-
-/*   SH_RTC_REAL_TIME_CLOCK                                             */
-/*   Description:  Real-time Clock                                      */
-#define SH_RTC_REAL_TIME_CLOCK_SHFT              0
-#define SH_RTC_REAL_TIME_CLOCK_MASK              0x007fffffffffffffUL
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH0"                        */
-/*                          Scratch Register 0                          */
-/* ==================================================================== */
-
-#define SH_SCRATCH0                              0x00000001101d0000
-#define SH_SCRATCH0_MASK                         0xffffffffffffffff
-#define SH_SCRATCH0_INIT                         0x0000000000000000
-
-/*   SH_SCRATCH0_SCRATCH0                                               */
-/*   Description:  Scratch register 0                                   */
-#define SH_SCRATCH0_SCRATCH0_SHFT                0
-#define SH_SCRATCH0_SCRATCH0_MASK                0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_SCRATCH0_ALIAS"                     */
-/*                   Scratch Register 0 Alias Address                   */
-/* ==================================================================== */
-
-#define SH_SCRATCH0_ALIAS                        0x00000001101d0008
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH1"                        */
-/*                          Scratch Register 1                          */
-/* ==================================================================== */
-
-#define SH_SCRATCH1                              0x00000001101d0080
-#define SH_SCRATCH1_MASK                         0xffffffffffffffff
-#define SH_SCRATCH1_INIT                         0x0000000000000000
-
-/*   SH_SCRATCH1_SCRATCH1                                               */
-/*   Description:  Scratch register 1                                   */
-#define SH_SCRATCH1_SCRATCH1_SHFT                0
-#define SH_SCRATCH1_SCRATCH1_MASK                0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_SCRATCH1_ALIAS"                     */
-/*                   Scratch Register 1 Alias Address                   */
-/* ==================================================================== */
-
-#define SH_SCRATCH1_ALIAS                        0x00000001101d0088
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH2"                        */
-/*                          Scratch Register 2                          */
-/* ==================================================================== */
-
-#define SH_SCRATCH2                              0x00000001101d0100
-#define SH_SCRATCH2_MASK                         0xffffffffffffffff
-#define SH_SCRATCH2_INIT                         0x0000000000000000
-
-/*   SH_SCRATCH2_SCRATCH2                                               */
-/*   Description:  Scratch register 2                                   */
-#define SH_SCRATCH2_SCRATCH2_SHFT                0
-#define SH_SCRATCH2_SCRATCH2_MASK                0xffffffffffffffff
-
-/* ==================================================================== */
-/*                     Register "SH_SCRATCH2_ALIAS"                     */
-/*                   Scratch Register 2 Alias Address                   */
-/* ==================================================================== */
-
-#define SH_SCRATCH2_ALIAS                        0x00000001101d0108
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH3"                        */
-/*                          Scratch Register 3                          */
-/* ==================================================================== */
-
-#define SH_SCRATCH3                              0x00000001101d0180
-#define SH_SCRATCH3_MASK                         0x0000000000000001
-#define SH_SCRATCH3_INIT                         0x0000000000000000
-
-/*   SH_SCRATCH3_SCRATCH3                                               */
-/*   Description:  Scratch register 3                                   */
-#define SH_SCRATCH3_SCRATCH3_SHFT                0
-#define SH_SCRATCH3_SCRATCH3_MASK                0x0000000000000001
-
-/* ==================================================================== */
-/*                     Register "SH_SCRATCH3_ALIAS"                     */
-/*                   Scratch Register 3 Alias Address                   */
-/* ==================================================================== */
-
-#define SH_SCRATCH3_ALIAS                        0x00000001101d0188
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH4"                        */
-/*                          Scratch Register 4                          */
-/* ==================================================================== */
-
-#define SH_SCRATCH4                              0x00000001101d0200
-#define SH_SCRATCH4_MASK                         0x0000000000000001
-#define SH_SCRATCH4_INIT                         0x0000000000000000
-
-/*   SH_SCRATCH4_SCRATCH4                                               */
-/*   Description:  Scratch register 4                                   */
-#define SH_SCRATCH4_SCRATCH4_SHFT                0
-#define SH_SCRATCH4_SCRATCH4_MASK                0x0000000000000001
-
-/* ==================================================================== */
-/*                     Register "SH_SCRATCH4_ALIAS"                     */
-/*                   Scratch Register 4 Alias Address                   */
-/* ==================================================================== */
-
-#define SH_SCRATCH4_ALIAS                        0x00000001101d0208
-
-/* ==================================================================== */
-/*                  Register "SH_CRB_MESSAGE_CONTROL"                   */
-/*               Coherent Request Buffer Message Control                */
-/* ==================================================================== */
-
-#define SH_CRB_MESSAGE_CONTROL                   0x0000000120000000
-#define SH_CRB_MESSAGE_CONTROL_MASK              0xffffffff00000fff
-#define SH_CRB_MESSAGE_CONTROL_INIT              0x0000000000000006
-
-/*   SH_CRB_MESSAGE_CONTROL_SYSTEM_COHERENCE_ENABLE                     */
-/*   Description:  System Coherence Enabled                             */
-#define SH_CRB_MESSAGE_CONTROL_SYSTEM_COHERENCE_ENABLE_SHFT 0
-#define SH_CRB_MESSAGE_CONTROL_SYSTEM_COHERENCE_ENABLE_MASK 0x0000000000000001
-
-/*   SH_CRB_MESSAGE_CONTROL_LOCAL_SPECULATIVE_MESSAGE_ENABLE            */
-/*   Description:  Speculative Read Requests to Local Memory Enabled    */
-#define SH_CRB_MESSAGE_CONTROL_LOCAL_SPECULATIVE_MESSAGE_ENABLE_SHFT 1
-#define SH_CRB_MESSAGE_CONTROL_LOCAL_SPECULATIVE_MESSAGE_ENABLE_MASK 0x0000000000000002
-
-/*   SH_CRB_MESSAGE_CONTROL_REMOTE_SPECULATIVE_MESSAGE_ENABLE           */
-/*   Description:  Speculative Read Requests to Remote Memory Enabled  */
-#define SH_CRB_MESSAGE_CONTROL_REMOTE_SPECULATIVE_MESSAGE_ENABLE_SHFT 2
-#define SH_CRB_MESSAGE_CONTROL_REMOTE_SPECULATIVE_MESSAGE_ENABLE_MASK 0x0000000000000004
-
-/*   SH_CRB_MESSAGE_CONTROL_MESSAGE_COLOR                               */
-/*   Description:  Define color of message                              */
-#define SH_CRB_MESSAGE_CONTROL_MESSAGE_COLOR_SHFT 3
-#define SH_CRB_MESSAGE_CONTROL_MESSAGE_COLOR_MASK 0x0000000000000008
-
-/*   SH_CRB_MESSAGE_CONTROL_MESSAGE_COLOR_ENABLE                        */
-/*   Description:  Enable color message processing                      */
-#define SH_CRB_MESSAGE_CONTROL_MESSAGE_COLOR_ENABLE_SHFT 4
-#define SH_CRB_MESSAGE_CONTROL_MESSAGE_COLOR_ENABLE_MASK 0x0000000000000010
-
-/*   SH_CRB_MESSAGE_CONTROL_RRB_ATTRIBUTE_MISMATCH_FSB_ENABLE           */
-/*   Description:  Enable FSB RRB Mismatch check                        */
-#define SH_CRB_MESSAGE_CONTROL_RRB_ATTRIBUTE_MISMATCH_FSB_ENABLE_SHFT 5
-#define SH_CRB_MESSAGE_CONTROL_RRB_ATTRIBUTE_MISMATCH_FSB_ENABLE_MASK 0x0000000000000020
-
-/*   SH_CRB_MESSAGE_CONTROL_WRB_ATTRIBUTE_MISMATCH_FSB_ENABLE           */
-/*   Description:  Enable FSB WRB Mismatch check                        */
-#define SH_CRB_MESSAGE_CONTROL_WRB_ATTRIBUTE_MISMATCH_FSB_ENABLE_SHFT 6
-#define SH_CRB_MESSAGE_CONTROL_WRB_ATTRIBUTE_MISMATCH_FSB_ENABLE_MASK 0x0000000000000040
-
-/*   SH_CRB_MESSAGE_CONTROL_IRB_ATTRIBUTE_MISMATCH_FSB_ENABLE           */
-/*   Description:  Enable FSB IRB Mismatch check                        */
-#define SH_CRB_MESSAGE_CONTROL_IRB_ATTRIBUTE_MISMATCH_FSB_ENABLE_SHFT 7
-#define SH_CRB_MESSAGE_CONTROL_IRB_ATTRIBUTE_MISMATCH_FSB_ENABLE_MASK 0x0000000000000080
-
-/*   SH_CRB_MESSAGE_CONTROL_RRB_ATTRIBUTE_MISMATCH_XB_ENABLE            */
-/*   Description:  Enable XB RRB Mismatch check                         */
-#define SH_CRB_MESSAGE_CONTROL_RRB_ATTRIBUTE_MISMATCH_XB_ENABLE_SHFT 8
-#define SH_CRB_MESSAGE_CONTROL_RRB_ATTRIBUTE_MISMATCH_XB_ENABLE_MASK 0x0000000000000100
-
-/*   SH_CRB_MESSAGE_CONTROL_WRB_ATTRIBUTE_MISMATCH_XB_ENABLE            */
-/*   Description:  Enable XB WRB Mismatch check                         */
-#define SH_CRB_MESSAGE_CONTROL_WRB_ATTRIBUTE_MISMATCH_XB_ENABLE_SHFT 9
-#define SH_CRB_MESSAGE_CONTROL_WRB_ATTRIBUTE_MISMATCH_XB_ENABLE_MASK 0x0000000000000200
-
-/*   SH_CRB_MESSAGE_CONTROL_SUPPRESS_BOGUS_WRITES                       */
-/*   Description:  ignor residual write data                            */
-#define SH_CRB_MESSAGE_CONTROL_SUPPRESS_BOGUS_WRITES_SHFT 10
-#define SH_CRB_MESSAGE_CONTROL_SUPPRESS_BOGUS_WRITES_MASK 0x0000000000000400
-
-/*   SH_CRB_MESSAGE_CONTROL_ENABLE_IVACK_CONSOLIDATION                  */
-/*   Description:  enable IVACK reply consolidation                     */
-#define SH_CRB_MESSAGE_CONTROL_ENABLE_IVACK_CONSOLIDATION_SHFT 11
-#define SH_CRB_MESSAGE_CONTROL_ENABLE_IVACK_CONSOLIDATION_MASK 0x0000000000000800
-
-/*   SH_CRB_MESSAGE_CONTROL_IVACK_STALL_COUNT                           */
-/*   Description:  IVACK stall counter                                  */
-#define SH_CRB_MESSAGE_CONTROL_IVACK_STALL_COUNT_SHFT 32
-#define SH_CRB_MESSAGE_CONTROL_IVACK_STALL_COUNT_MASK 0x0000ffff00000000
-
-/*   SH_CRB_MESSAGE_CONTROL_IVACK_THROTTLE_CONTROL                      */
-/*   Description:  IVACK throttling limit/timer control                 */
-#define SH_CRB_MESSAGE_CONTROL_IVACK_THROTTLE_CONTROL_SHFT 48
-#define SH_CRB_MESSAGE_CONTROL_IVACK_THROTTLE_CONTROL_MASK 0xffff000000000000
-
-/* ==================================================================== */
-/*                     Register "SH_CRB_NACK_LIMIT"                     */
-/*                            CRB Nack Limit                            */
-/* ==================================================================== */
-
-#define SH_CRB_NACK_LIMIT                        0x0000000120000080
-#define SH_CRB_NACK_LIMIT_MASK                   0x800000000000ffff
-#define SH_CRB_NACK_LIMIT_INIT                   0x0000000000000000
-
-/*   SH_CRB_NACK_LIMIT_LIMIT                                            */
-/*   Description:  Nack Count Limit                                     */
-#define SH_CRB_NACK_LIMIT_LIMIT_SHFT             0
-#define SH_CRB_NACK_LIMIT_LIMIT_MASK             0x0000000000000fff
-
-/*   SH_CRB_NACK_LIMIT_PRI_FREQ                                         */
-/*   Description:  Frequency at which priority count is incremented     */
-#define SH_CRB_NACK_LIMIT_PRI_FREQ_SHFT          12
-#define SH_CRB_NACK_LIMIT_PRI_FREQ_MASK          0x000000000000f000
-
-/*   SH_CRB_NACK_LIMIT_ENABLE                                           */
-/*   Description:  Enable NACK limit detection                          */
-#define SH_CRB_NACK_LIMIT_ENABLE_SHFT            63
-#define SH_CRB_NACK_LIMIT_ENABLE_MASK            0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_CRB_TIMEOUT_PRESCALE"                  */
-/*               Coherent Request Buffer Timeout Prescale               */
-/* ==================================================================== */
-
-#define SH_CRB_TIMEOUT_PRESCALE                  0x0000000120000100
-#define SH_CRB_TIMEOUT_PRESCALE_MASK             0x00000000ffffffff
-#define SH_CRB_TIMEOUT_PRESCALE_INIT             0x0000000000000000
-
-/*   SH_CRB_TIMEOUT_PRESCALE_SCALING_FACTOR                             */
-/*   Description:  CRB Time-out Prescale Factor                         */
-#define SH_CRB_TIMEOUT_PRESCALE_SCALING_FACTOR_SHFT 0
-#define SH_CRB_TIMEOUT_PRESCALE_SCALING_FACTOR_MASK 0x00000000ffffffff
-
-/* ==================================================================== */
-/*                    Register "SH_CRB_TIMEOUT_SKID"                    */
-/*              Coherent Request Buffer Timeout Skid Limit              */
-/* ==================================================================== */
-
-#define SH_CRB_TIMEOUT_SKID                      0x0000000120000180
-#define SH_CRB_TIMEOUT_SKID_MASK                 0x800000000000003f
-#define SH_CRB_TIMEOUT_SKID_INIT                 0x0000000000000007
-
-/*   SH_CRB_TIMEOUT_SKID_SKID                                           */
-/*   Description:  CRB Time-out Skid                                    */
-#define SH_CRB_TIMEOUT_SKID_SKID_SHFT            0
-#define SH_CRB_TIMEOUT_SKID_SKID_MASK            0x000000000000003f
-
-/*   SH_CRB_TIMEOUT_SKID_RESET_SKID_COUNT                               */
-/*   Description:  Reset Skid counter                                   */
-#define SH_CRB_TIMEOUT_SKID_RESET_SKID_COUNT_SHFT 63
-#define SH_CRB_TIMEOUT_SKID_RESET_SKID_COUNT_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_MEMORY_WRITE_STATUS_0"                  */
-/*                    Memory Write Status for CPU 0                     */
-/* ==================================================================== */
-
-#define SH_MEMORY_WRITE_STATUS_0                 0x0000000120070000
-#define SH_MEMORY_WRITE_STATUS_0_MASK            0x000000000000003f
-#define SH_MEMORY_WRITE_STATUS_0_INIT            0x0000000000000000
-
-/*   SH_MEMORY_WRITE_STATUS_0_PENDING_WRITE_COUNT                       */
-/*   Description:  Pending Write Count                                  */
-#define SH_MEMORY_WRITE_STATUS_0_PENDING_WRITE_COUNT_SHFT 0
-#define SH_MEMORY_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK 0x000000000000003f
-
-/* ==================================================================== */
-/*                 Register "SH_MEMORY_WRITE_STATUS_1"                  */
-/*                    Memory Write Status for CPU 1                     */
-/* ==================================================================== */
-
-#define SH_MEMORY_WRITE_STATUS_1                 0x0000000120070080
-#define SH_MEMORY_WRITE_STATUS_1_MASK            0x000000000000003f
-#define SH_MEMORY_WRITE_STATUS_1_INIT            0x0000000000000000
-
-/*   SH_MEMORY_WRITE_STATUS_1_PENDING_WRITE_COUNT                       */
-/*   Description:  Pending Write Count                                  */
-#define SH_MEMORY_WRITE_STATUS_1_PENDING_WRITE_COUNT_SHFT 0
-#define SH_MEMORY_WRITE_STATUS_1_PENDING_WRITE_COUNT_MASK 0x000000000000003f
-
-/* ==================================================================== */
-/*                   Register "SH_PIO_WRITE_STATUS_0"                   */
-/*                      PIO Write Status for CPU 0                      */
-/* ==================================================================== */
-
-#define SH_PIO_WRITE_STATUS_0                    0x0000000120070200
-#define SH_PIO_WRITE_STATUS_0_MASK               0xbf03ffffffffffff
-#define SH_PIO_WRITE_STATUS_0_INIT               0x8000000000000000
-
-/*   SH_PIO_WRITE_STATUS_0_MULTI_WRITE_ERROR                            */
-/*   Description:  More than one PIO write error occurred               */
-#define SH_PIO_WRITE_STATUS_0_MULTI_WRITE_ERROR_SHFT 0
-#define SH_PIO_WRITE_STATUS_0_MULTI_WRITE_ERROR_MASK 0x0000000000000001
-
-/*   SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK                               */
-/*   Description:  Deaklock response detected                           */
-#define SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK_SHFT 1
-#define SH_PIO_WRITE_STATUS_0_WRITE_DEADLOCK_MASK 0x0000000000000002
-
-/*   SH_PIO_WRITE_STATUS_0_WRITE_ERROR                                  */
-/*   Description:  Error response detected                              */
-#define SH_PIO_WRITE_STATUS_0_WRITE_ERROR_SHFT   2
-#define SH_PIO_WRITE_STATUS_0_WRITE_ERROR_MASK   0x0000000000000004
-
-/*   SH_PIO_WRITE_STATUS_0_WRITE_ERROR_ADDRESS                          */
-/*   Description:  Address associated with error response               */
-#define SH_PIO_WRITE_STATUS_0_WRITE_ERROR_ADDRESS_SHFT 3
-#define SH_PIO_WRITE_STATUS_0_WRITE_ERROR_ADDRESS_MASK 0x0003fffffffffff8
-
-/*   SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT                          */
-/*   Description:  Count of currently pending PIO writes                */
-#define SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_SHFT 56
-#define SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK 0x3f00000000000000
-
-/*   SH_PIO_WRITE_STATUS_0_WRITES_OK                                    */
-/*   Description:  No pending writes or errors                          */
-#define SH_PIO_WRITE_STATUS_0_WRITES_OK_SHFT     63
-#define SH_PIO_WRITE_STATUS_0_WRITES_OK_MASK     0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_PIO_WRITE_STATUS_1"                   */
-/*                      PIO Write Status for CPU 1                      */
-/* ==================================================================== */
-
-#define SH_PIO_WRITE_STATUS_1                    0x0000000120070280
-#define SH_PIO_WRITE_STATUS_1_MASK               0xbf03ffffffffffff
-#define SH_PIO_WRITE_STATUS_1_INIT               0x8000000000000000
-
-/*   SH_PIO_WRITE_STATUS_1_MULTI_WRITE_ERROR                            */
-/*   Description:  More than one PIO write error occurred               */
-#define SH_PIO_WRITE_STATUS_1_MULTI_WRITE_ERROR_SHFT 0
-#define SH_PIO_WRITE_STATUS_1_MULTI_WRITE_ERROR_MASK 0x0000000000000001
-
-/*   SH_PIO_WRITE_STATUS_1_WRITE_DEADLOCK                               */
-/*   Description:  Deaklock response detected                           */
-#define SH_PIO_WRITE_STATUS_1_WRITE_DEADLOCK_SHFT 1
-#define SH_PIO_WRITE_STATUS_1_WRITE_DEADLOCK_MASK 0x0000000000000002
-
-/*   SH_PIO_WRITE_STATUS_1_WRITE_ERROR                                  */
-/*   Description:  Error response detected                              */
-#define SH_PIO_WRITE_STATUS_1_WRITE_ERROR_SHFT   2
-#define SH_PIO_WRITE_STATUS_1_WRITE_ERROR_MASK   0x0000000000000004
-
-/*   SH_PIO_WRITE_STATUS_1_WRITE_ERROR_ADDRESS                          */
-/*   Description:  Address associated with error response               */
-#define SH_PIO_WRITE_STATUS_1_WRITE_ERROR_ADDRESS_SHFT 3
-#define SH_PIO_WRITE_STATUS_1_WRITE_ERROR_ADDRESS_MASK 0x0003fffffffffff8
-
-/*   SH_PIO_WRITE_STATUS_1_PENDING_WRITE_COUNT                          */
-/*   Description:  Count of currently pending PIO writes                */
-#define SH_PIO_WRITE_STATUS_1_PENDING_WRITE_COUNT_SHFT 56
-#define SH_PIO_WRITE_STATUS_1_PENDING_WRITE_COUNT_MASK 0x3f00000000000000
-
-/*   SH_PIO_WRITE_STATUS_1_WRITES_OK                                    */
-/*   Description:  No pending writes or errors                          */
-#define SH_PIO_WRITE_STATUS_1_WRITES_OK_SHFT     63
-#define SH_PIO_WRITE_STATUS_1_WRITES_OK_MASK     0x8000000000000000
-
-/* ==================================================================== */
-/*                Register "SH_PIO_WRITE_STATUS_0_ALIAS"                */
-/* ==================================================================== */
-
-#define SH_PIO_WRITE_STATUS_0_ALIAS              0x0000000120070208
-
-/* ==================================================================== */
-/*                Register "SH_PIO_WRITE_STATUS_1_ALIAS"                */
-/* ==================================================================== */
-
-#define SH_PIO_WRITE_STATUS_1_ALIAS              0x0000000120070288
-
-/* ==================================================================== */
-/*             Register "SH_MEMORY_WRITE_STATUS_NON_USER_0"             */
-/*            Memory Write Status for CPU 0. OS access only             */
-/* ==================================================================== */
-
-#define SH_MEMORY_WRITE_STATUS_NON_USER_0        0x0000000120070400
-#define SH_MEMORY_WRITE_STATUS_NON_USER_0_MASK   0x800000000000003f
-#define SH_MEMORY_WRITE_STATUS_NON_USER_0_INIT   0x0000000000000000
-
-/*   SH_MEMORY_WRITE_STATUS_NON_USER_0_PENDING_WRITE_COUNT              */
-/*   Description:  Pending Write Count                                  */
-#define SH_MEMORY_WRITE_STATUS_NON_USER_0_PENDING_WRITE_COUNT_SHFT 0
-#define SH_MEMORY_WRITE_STATUS_NON_USER_0_PENDING_WRITE_COUNT_MASK 0x000000000000003f
-
-/*   SH_MEMORY_WRITE_STATUS_NON_USER_0_CLEAR                            */
-/*   Description:  Clear pending write count                            */
-#define SH_MEMORY_WRITE_STATUS_NON_USER_0_CLEAR_SHFT 63
-#define SH_MEMORY_WRITE_STATUS_NON_USER_0_CLEAR_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*             Register "SH_MEMORY_WRITE_STATUS_NON_USER_1"             */
-/*            Memory Write Status for CPU 1. OS access only             */
-/* ==================================================================== */
-
-#define SH_MEMORY_WRITE_STATUS_NON_USER_1        0x0000000120070480
-#define SH_MEMORY_WRITE_STATUS_NON_USER_1_MASK   0x800000000000003f
-#define SH_MEMORY_WRITE_STATUS_NON_USER_1_INIT   0x0000000000000000
-
-/*   SH_MEMORY_WRITE_STATUS_NON_USER_1_PENDING_WRITE_COUNT              */
-/*   Description:  Pending Write Count                                  */
-#define SH_MEMORY_WRITE_STATUS_NON_USER_1_PENDING_WRITE_COUNT_SHFT 0
-#define SH_MEMORY_WRITE_STATUS_NON_USER_1_PENDING_WRITE_COUNT_MASK 0x000000000000003f
-
-/*   SH_MEMORY_WRITE_STATUS_NON_USER_1_CLEAR                            */
-/*   Description:  Clear pending write count                            */
-#define SH_MEMORY_WRITE_STATUS_NON_USER_1_CLEAR_SHFT 63
-#define SH_MEMORY_WRITE_STATUS_NON_USER_1_CLEAR_MASK 0x8000000000000000
-
-/* ==================================================================== */
-/*                      Register "SH_MMRBIST_ERR"                       */
-/*                  Error capture for bist read errors                  */
-/* ==================================================================== */
-
-#define SH_MMRBIST_ERR                           0x0000000100000080
-#define SH_MMRBIST_ERR_MASK                      0x00000071ffffffff
-#define SH_MMRBIST_ERR_INIT                      0x0000000000000000
-
-/*   SH_MMRBIST_ERR_ADDR                                                */
-/*   Description:  dword address of bist error                          */
-#define SH_MMRBIST_ERR_ADDR_SHFT                 0
-#define SH_MMRBIST_ERR_ADDR_MASK                 0x00000001ffffffff
-
-/*   SH_MMRBIST_ERR_DETECTED                                            */
-/*   Description:  error detected flag                                  */
-#define SH_MMRBIST_ERR_DETECTED_SHFT             36
-#define SH_MMRBIST_ERR_DETECTED_MASK             0x0000001000000000
-
-/*   SH_MMRBIST_ERR_MULTIPLE_DETECTED                                   */
-/*   Description:  multiple errors detected flag                        */
-#define SH_MMRBIST_ERR_MULTIPLE_DETECTED_SHFT    37
-#define SH_MMRBIST_ERR_MULTIPLE_DETECTED_MASK    0x0000002000000000
-
-/*   SH_MMRBIST_ERR_CANCELLED                                           */
-/*   Description:  mmr/bist was cancelled                               */
-#define SH_MMRBIST_ERR_CANCELLED_SHFT            38
-#define SH_MMRBIST_ERR_CANCELLED_MASK            0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MISC_ERR_HDR_LOWER"                   */
-/*                       Header capture register                        */
-/* ==================================================================== */
-
-#define SH_MISC_ERR_HDR_LOWER                    0x0000000100000088
-#define SH_MISC_ERR_HDR_LOWER_MASK               0x93fffffffffffff8
-#define SH_MISC_ERR_HDR_LOWER_INIT               0x0000000000000000
-
-/*   SH_MISC_ERR_HDR_LOWER_ADDR                                         */
-/*   Description:  upper bits of reference address                      */
-#define SH_MISC_ERR_HDR_LOWER_ADDR_SHFT          3
-#define SH_MISC_ERR_HDR_LOWER_ADDR_MASK          0x0000000ffffffff8
-
-/*   SH_MISC_ERR_HDR_LOWER_CMD                                          */
-/*   Description:  command of reference                                 */
-#define SH_MISC_ERR_HDR_LOWER_CMD_SHFT           36
-#define SH_MISC_ERR_HDR_LOWER_CMD_MASK           0x00000ff000000000
-
-/*   SH_MISC_ERR_HDR_LOWER_SRC                                          */
-/*   Description:  source node of reference                             */
-#define SH_MISC_ERR_HDR_LOWER_SRC_SHFT           44
-#define SH_MISC_ERR_HDR_LOWER_SRC_MASK           0x03fff00000000000
-
-/*   SH_MISC_ERR_HDR_LOWER_WRITE                                        */
-/*   Description:  reference is a write                                 */
-#define SH_MISC_ERR_HDR_LOWER_WRITE_SHFT         60
-#define SH_MISC_ERR_HDR_LOWER_WRITE_MASK         0x1000000000000000
-
-/*   SH_MISC_ERR_HDR_LOWER_VALID                                        */
-/*   Description:  set when capture occurs                              */
-#define SH_MISC_ERR_HDR_LOWER_VALID_SHFT         63
-#define SH_MISC_ERR_HDR_LOWER_VALID_MASK         0x8000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MISC_ERR_HDR_UPPER"                   */
-/*           Error header capture packet and protocol errors            */
-/* ==================================================================== */
-
-#define SH_MISC_ERR_HDR_UPPER                    0x0000000100000090
-#define SH_MISC_ERR_HDR_UPPER_MASK               0x000000001ff000ff
-#define SH_MISC_ERR_HDR_UPPER_INIT               0x0000000000000000
-
-/*   SH_MISC_ERR_HDR_UPPER_DIR_PROTOCOL                                 */
-/*   Description:  indicates a directory protocol error captured        */
-#define SH_MISC_ERR_HDR_UPPER_DIR_PROTOCOL_SHFT  0
-#define SH_MISC_ERR_HDR_UPPER_DIR_PROTOCOL_MASK  0x0000000000000001
-
-/*   SH_MISC_ERR_HDR_UPPER_ILLEGAL_CMD                                  */
-/*   Description:  indicates an illegal command error captured          */
-#define SH_MISC_ERR_HDR_UPPER_ILLEGAL_CMD_SHFT   1
-#define SH_MISC_ERR_HDR_UPPER_ILLEGAL_CMD_MASK   0x0000000000000002
-
-/*   SH_MISC_ERR_HDR_UPPER_NONEXIST_ADDR                                */
-/*   Description:  indicates a non-existent memory error captured       */
-#define SH_MISC_ERR_HDR_UPPER_NONEXIST_ADDR_SHFT 2
-#define SH_MISC_ERR_HDR_UPPER_NONEXIST_ADDR_MASK 0x0000000000000004
-
-/*   SH_MISC_ERR_HDR_UPPER_RMW_UC                                       */
-/*   Description:  indicates an uncorrectable store rmw                 */
-#define SH_MISC_ERR_HDR_UPPER_RMW_UC_SHFT        3
-#define SH_MISC_ERR_HDR_UPPER_RMW_UC_MASK        0x0000000000000008
-
-/*   SH_MISC_ERR_HDR_UPPER_RMW_COR                                      */
-/*   Description:  indicates a correctable store rmw                    */
-#define SH_MISC_ERR_HDR_UPPER_RMW_COR_SHFT       4
-#define SH_MISC_ERR_HDR_UPPER_RMW_COR_MASK       0x0000000000000010
-
-/*   SH_MISC_ERR_HDR_UPPER_DIR_ACC                                      */
-/*   Description:  indicates a data request to directory memory error   */
-/*  captured                                                            */
-#define SH_MISC_ERR_HDR_UPPER_DIR_ACC_SHFT       5
-#define SH_MISC_ERR_HDR_UPPER_DIR_ACC_MASK       0x0000000000000020
-
-/*   SH_MISC_ERR_HDR_UPPER_PI_PKT_SIZE                                  */
-/*   Description:  indicates a pkt size error from pi                   */
-#define SH_MISC_ERR_HDR_UPPER_PI_PKT_SIZE_SHFT   6
-#define SH_MISC_ERR_HDR_UPPER_PI_PKT_SIZE_MASK   0x0000000000000040
-
-/*   SH_MISC_ERR_HDR_UPPER_XN_PKT_SIZE                                  */
-/*   Description:  indicates a pkt size error from xn                   */
-#define SH_MISC_ERR_HDR_UPPER_XN_PKT_SIZE_SHFT   7
-#define SH_MISC_ERR_HDR_UPPER_XN_PKT_SIZE_MASK   0x0000000000000080
-
-/*   SH_MISC_ERR_HDR_UPPER_ECHO                                         */
-#define SH_MISC_ERR_HDR_UPPER_ECHO_SHFT          20
-#define SH_MISC_ERR_HDR_UPPER_ECHO_MASK          0x000000001ff00000
-
-/* ==================================================================== */
-/*                  Register "SH_DIR_UC_ERR_HDR_LOWER"                  */
-/*                       Header capture register                        */
-/* ==================================================================== */
-
-#define SH_DIR_UC_ERR_HDR_LOWER                  0x0000000100000098
-#define SH_DIR_UC_ERR_HDR_LOWER_MASK             0x93fffffffffffff8
-#define SH_DIR_UC_ERR_HDR_LOWER_INIT             0x0000000000000000
-
-/*   SH_DIR_UC_ERR_HDR_LOWER_ADDR                                       */
-/*   Description:  upper bits of reference address                      */
-#define SH_DIR_UC_ERR_HDR_LOWER_ADDR_SHFT        3
-#define SH_DIR_UC_ERR_HDR_LOWER_ADDR_MASK        0x0000000ffffffff8
-
-/*   SH_DIR_UC_ERR_HDR_LOWER_CMD                                        */
-/*   Description:  command of reference                                 */
-#define SH_DIR_UC_ERR_HDR_LOWER_CMD_SHFT         36
-#define SH_DIR_UC_ERR_HDR_LOWER_CMD_MASK         0x00000ff000000000
-
-/*   SH_DIR_UC_ERR_HDR_LOWER_SRC                                        */
-/*   Description:  source node of reference                             */
-#define SH_DIR_UC_ERR_HDR_LOWER_SRC_SHFT         44
-#define SH_DIR_UC_ERR_HDR_LOWER_SRC_MASK         0x03fff00000000000
-
-/*   SH_DIR_UC_ERR_HDR_LOWER_WRITE                                      */
-/*   Description:  reference is a write                                 */
-#define SH_DIR_UC_ERR_HDR_LOWER_WRITE_SHFT       60
-#define SH_DIR_UC_ERR_HDR_LOWER_WRITE_MASK       0x1000000000000000
-
-/*   SH_DIR_UC_ERR_HDR_LOWER_VALID                                      */
-/*   Description:  set when capture occurs                              */
-#define SH_DIR_UC_ERR_HDR_LOWER_VALID_SHFT       63
-#define SH_DIR_UC_ERR_HDR_LOWER_VALID_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_DIR_UC_ERR_HDR_UPPER"                  */
-/*           Error header capture packet and protocol errors            */
-/* ==================================================================== */
-
-#define SH_DIR_UC_ERR_HDR_UPPER                  0x00000001000000a0
-#define SH_DIR_UC_ERR_HDR_UPPER_MASK             0x000000001ff00008
-#define SH_DIR_UC_ERR_HDR_UPPER_INIT             0x0000000000000000
-
-/*   SH_DIR_UC_ERR_HDR_UPPER_DIR_UC                                     */
-/*   Description:  indicates uncorrectable directory error captured     */
-#define SH_DIR_UC_ERR_HDR_UPPER_DIR_UC_SHFT      3
-#define SH_DIR_UC_ERR_HDR_UPPER_DIR_UC_MASK      0x0000000000000008
-
-/*   SH_DIR_UC_ERR_HDR_UPPER_ECHO                                       */
-#define SH_DIR_UC_ERR_HDR_UPPER_ECHO_SHFT        20
-#define SH_DIR_UC_ERR_HDR_UPPER_ECHO_MASK        0x000000001ff00000
-
-/* ==================================================================== */
-/*                 Register "SH_DIR_COR_ERR_HDR_LOWER"                  */
-/*                       Header capture register                        */
-/* ==================================================================== */
-
-#define SH_DIR_COR_ERR_HDR_LOWER                 0x00000001000000a8
-#define SH_DIR_COR_ERR_HDR_LOWER_MASK            0x93fffffffffffff8
-#define SH_DIR_COR_ERR_HDR_LOWER_INIT            0x0000000000000000
-
-/*   SH_DIR_COR_ERR_HDR_LOWER_ADDR                                      */
-/*   Description:  upper bits of reference address                      */
-#define SH_DIR_COR_ERR_HDR_LOWER_ADDR_SHFT       3
-#define SH_DIR_COR_ERR_HDR_LOWER_ADDR_MASK       0x0000000ffffffff8
-
-/*   SH_DIR_COR_ERR_HDR_LOWER_CMD                                       */
-/*   Description:  command of reference                                 */
-#define SH_DIR_COR_ERR_HDR_LOWER_CMD_SHFT        36
-#define SH_DIR_COR_ERR_HDR_LOWER_CMD_MASK        0x00000ff000000000
-
-/*   SH_DIR_COR_ERR_HDR_LOWER_SRC                                       */
-/*   Description:  source node of reference                             */
-#define SH_DIR_COR_ERR_HDR_LOWER_SRC_SHFT        44
-#define SH_DIR_COR_ERR_HDR_LOWER_SRC_MASK        0x03fff00000000000
-
-/*   SH_DIR_COR_ERR_HDR_LOWER_WRITE                                     */
-/*   Description:  reference is a write                                 */
-#define SH_DIR_COR_ERR_HDR_LOWER_WRITE_SHFT      60
-#define SH_DIR_COR_ERR_HDR_LOWER_WRITE_MASK      0x1000000000000000
-
-/*   SH_DIR_COR_ERR_HDR_LOWER_VALID                                     */
-/*   Description:  set when capture occurs                              */
-#define SH_DIR_COR_ERR_HDR_LOWER_VALID_SHFT      63
-#define SH_DIR_COR_ERR_HDR_LOWER_VALID_MASK      0x8000000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_DIR_COR_ERR_HDR_UPPER"                  */
-/*           Error header capture packet and protocol errors            */
-/* ==================================================================== */
-
-#define SH_DIR_COR_ERR_HDR_UPPER                 0x00000001000000b0
-#define SH_DIR_COR_ERR_HDR_UPPER_MASK            0x000000001ff00100
-#define SH_DIR_COR_ERR_HDR_UPPER_INIT            0x0000000000000000
-
-/*   SH_DIR_COR_ERR_HDR_UPPER_DIR_COR                                   */
-/*   Description:  indicates correctable directory error captured       */
-#define SH_DIR_COR_ERR_HDR_UPPER_DIR_COR_SHFT    8
-#define SH_DIR_COR_ERR_HDR_UPPER_DIR_COR_MASK    0x0000000000000100
-
-/*   SH_DIR_COR_ERR_HDR_UPPER_ECHO                                      */
-#define SH_DIR_COR_ERR_HDR_UPPER_ECHO_SHFT       20
-#define SH_DIR_COR_ERR_HDR_UPPER_ECHO_MASK       0x000000001ff00000
-
-/* ==================================================================== */
-/*                   Register "SH_MEM_ERROR_SUMMARY"                    */
-/*                          Memory error flags                          */
-/* ==================================================================== */
-
-#define SH_MEM_ERROR_SUMMARY                     0x00000001000000b8
-#define SH_MEM_ERROR_SUMMARY_MASK                0x00000007f77777ff
-#define SH_MEM_ERROR_SUMMARY_INIT                0x0000000000000000
-
-/*   SH_MEM_ERROR_SUMMARY_ILLEGAL_CMD                                   */
-/*   Description:  illegal command error                                */
-#define SH_MEM_ERROR_SUMMARY_ILLEGAL_CMD_SHFT    0
-#define SH_MEM_ERROR_SUMMARY_ILLEGAL_CMD_MASK    0x0000000000000001
-
-/*   SH_MEM_ERROR_SUMMARY_NONEXIST_ADDR                                 */
-/*   Description:  non-existent memory error                            */
-#define SH_MEM_ERROR_SUMMARY_NONEXIST_ADDR_SHFT  1
-#define SH_MEM_ERROR_SUMMARY_NONEXIST_ADDR_MASK  0x0000000000000002
-
-/*   SH_MEM_ERROR_SUMMARY_DQLP_DIR_PERR                                 */
-/*   Description:  directory protocol error in dqlp                     */
-#define SH_MEM_ERROR_SUMMARY_DQLP_DIR_PERR_SHFT  2
-#define SH_MEM_ERROR_SUMMARY_DQLP_DIR_PERR_MASK  0x0000000000000004
-
-/*   SH_MEM_ERROR_SUMMARY_DQRP_DIR_PERR                                 */
-/*   Description:  directory protocol error in dqrp                     */
-#define SH_MEM_ERROR_SUMMARY_DQRP_DIR_PERR_SHFT  3
-#define SH_MEM_ERROR_SUMMARY_DQRP_DIR_PERR_MASK  0x0000000000000008
-
-/*   SH_MEM_ERROR_SUMMARY_DQLP_DIR_UC                                   */
-/*   Description:  uncorrectable directory error in dqlp                */
-#define SH_MEM_ERROR_SUMMARY_DQLP_DIR_UC_SHFT    4
-#define SH_MEM_ERROR_SUMMARY_DQLP_DIR_UC_MASK    0x0000000000000010
-
-/*   SH_MEM_ERROR_SUMMARY_DQLP_DIR_COR                                  */
-/*   Description:  correctable directory error in dqlp                  */
-#define SH_MEM_ERROR_SUMMARY_DQLP_DIR_COR_SHFT   5
-#define SH_MEM_ERROR_SUMMARY_DQLP_DIR_COR_MASK   0x0000000000000020
-
-/*   SH_MEM_ERROR_SUMMARY_DQRP_DIR_UC                                   */
-/*   Description:  uncorrectable directory error in dqrp                */
-#define SH_MEM_ERROR_SUMMARY_DQRP_DIR_UC_SHFT    6
-#define SH_MEM_ERROR_SUMMARY_DQRP_DIR_UC_MASK    0x0000000000000040
-
-/*   SH_MEM_ERROR_SUMMARY_DQRP_DIR_COR                                  */
-/*   Description:  correctable directory error in dqrp                  */
-#define SH_MEM_ERROR_SUMMARY_DQRP_DIR_COR_SHFT   7
-#define SH_MEM_ERROR_SUMMARY_DQRP_DIR_COR_MASK   0x0000000000000080
-
-/*   SH_MEM_ERROR_SUMMARY_ACX_INT_HW                                    */
-/*   Description:  hardware interrupt from acx                          */
-#define SH_MEM_ERROR_SUMMARY_ACX_INT_HW_SHFT     8
-#define SH_MEM_ERROR_SUMMARY_ACX_INT_HW_MASK     0x0000000000000100
-
-/*   SH_MEM_ERROR_SUMMARY_ACY_INT_HW                                    */
-/*   Description:  hardware interrupt from acy                          */
-#define SH_MEM_ERROR_SUMMARY_ACY_INT_HW_SHFT     9
-#define SH_MEM_ERROR_SUMMARY_ACY_INT_HW_MASK     0x0000000000000200
-
-/*   SH_MEM_ERROR_SUMMARY_DIR_ACC                                       */
-/*   Description:  directory memory access error                        */
-#define SH_MEM_ERROR_SUMMARY_DIR_ACC_SHFT        10
-#define SH_MEM_ERROR_SUMMARY_DIR_ACC_MASK        0x0000000000000400
-
-/*   SH_MEM_ERROR_SUMMARY_DQLP_INT_UC                                   */
-/*   Description:  uncorrectable interrupt from dqlp                    */
-#define SH_MEM_ERROR_SUMMARY_DQLP_INT_UC_SHFT    12
-#define SH_MEM_ERROR_SUMMARY_DQLP_INT_UC_MASK    0x0000000000001000
-
-/*   SH_MEM_ERROR_SUMMARY_DQLP_INT_COR                                  */
-/*   Description:  correctable interrupt from dqlp                      */
-#define SH_MEM_ERROR_SUMMARY_DQLP_INT_COR_SHFT   13
-#define SH_MEM_ERROR_SUMMARY_DQLP_INT_COR_MASK   0x0000000000002000
-
-/*   SH_MEM_ERROR_SUMMARY_DQLP_INT_HW                                   */
-/*   Description:  hardware interrupt from dqlp                         */
-#define SH_MEM_ERROR_SUMMARY_DQLP_INT_HW_SHFT    14
-#define SH_MEM_ERROR_SUMMARY_DQLP_INT_HW_MASK    0x0000000000004000
-
-/*   SH_MEM_ERROR_SUMMARY_DQLS_INT_UC                                   */
-/*   Description:  uncorrectable interrupt from dqls                    */
-#define SH_MEM_ERROR_SUMMARY_DQLS_INT_UC_SHFT    16
-#define SH_MEM_ERROR_SUMMARY_DQLS_INT_UC_MASK    0x0000000000010000
-
-/*   SH_MEM_ERROR_SUMMARY_DQLS_INT_COR                                  */
-/*   Description:  correctable interrupt from dqls                      */
-#define SH_MEM_ERROR_SUMMARY_DQLS_INT_COR_SHFT   17
-#define SH_MEM_ERROR_SUMMARY_DQLS_INT_COR_MASK   0x0000000000020000
-
-/*   SH_MEM_ERROR_SUMMARY_DQLS_INT_HW                                   */
-/*   Description:  hardware interrupt from dqls                         */
-#define SH_MEM_ERROR_SUMMARY_DQLS_INT_HW_SHFT    18
-#define SH_MEM_ERROR_SUMMARY_DQLS_INT_HW_MASK    0x0000000000040000
-
-/*   SH_MEM_ERROR_SUMMARY_DQRP_INT_UC                                   */
-/*   Description:  uncorrectable interrupt from dqrp                    */
-#define SH_MEM_ERROR_SUMMARY_DQRP_INT_UC_SHFT    20
-#define SH_MEM_ERROR_SUMMARY_DQRP_INT_UC_MASK    0x0000000000100000
-
-/*   SH_MEM_ERROR_SUMMARY_DQRP_INT_COR                                  */
-/*   Description:  correctable interrupt from dqrp                      */
-#define SH_MEM_ERROR_SUMMARY_DQRP_INT_COR_SHFT   21
-#define SH_MEM_ERROR_SUMMARY_DQRP_INT_COR_MASK   0x0000000000200000
-
-/*   SH_MEM_ERROR_SUMMARY_DQRP_INT_HW                                   */
-/*   Description:  hardware interrupt from dqrp                         */
-#define SH_MEM_ERROR_SUMMARY_DQRP_INT_HW_SHFT    22
-#define SH_MEM_ERROR_SUMMARY_DQRP_INT_HW_MASK    0x0000000000400000
-
-/*   SH_MEM_ERROR_SUMMARY_DQRS_INT_UC                                   */
-/*   Description:  uncorrectable interrupt from dqrs                    */
-#define SH_MEM_ERROR_SUMMARY_DQRS_INT_UC_SHFT    24
-#define SH_MEM_ERROR_SUMMARY_DQRS_INT_UC_MASK    0x0000000001000000
-
-/*   SH_MEM_ERROR_SUMMARY_DQRS_INT_COR                                  */
-/*   Description:  correctable interrupt from dqrs                      */
-#define SH_MEM_ERROR_SUMMARY_DQRS_INT_COR_SHFT   25
-#define SH_MEM_ERROR_SUMMARY_DQRS_INT_COR_MASK   0x0000000002000000
-
-/*   SH_MEM_ERROR_SUMMARY_DQRS_INT_HW                                   */
-/*   Description:  hardware interrupt from dqrs                         */
-#define SH_MEM_ERROR_SUMMARY_DQRS_INT_HW_SHFT    26
-#define SH_MEM_ERROR_SUMMARY_DQRS_INT_HW_MASK    0x0000000004000000
-
-/*   SH_MEM_ERROR_SUMMARY_PI_REPLY_OVERFLOW                             */
-/*   Description:  too many reply packets came from pi                  */
-#define SH_MEM_ERROR_SUMMARY_PI_REPLY_OVERFLOW_SHFT 28
-#define SH_MEM_ERROR_SUMMARY_PI_REPLY_OVERFLOW_MASK 0x0000000010000000
-
-/*   SH_MEM_ERROR_SUMMARY_XN_REPLY_OVERFLOW                             */
-/*   Description:  too many reply packets came from xn                  */
-#define SH_MEM_ERROR_SUMMARY_XN_REPLY_OVERFLOW_SHFT 29
-#define SH_MEM_ERROR_SUMMARY_XN_REPLY_OVERFLOW_MASK 0x0000000020000000
-
-/*   SH_MEM_ERROR_SUMMARY_PI_REQUEST_OVERFLOW                           */
-/*   Description:  too many request packets came from pi                */
-#define SH_MEM_ERROR_SUMMARY_PI_REQUEST_OVERFLOW_SHFT 30
-#define SH_MEM_ERROR_SUMMARY_PI_REQUEST_OVERFLOW_MASK 0x0000000040000000
-
-/*   SH_MEM_ERROR_SUMMARY_XN_REQUEST_OVERFLOW                           */
-/*   Description:  too many request packets came from xn                */
-#define SH_MEM_ERROR_SUMMARY_XN_REQUEST_OVERFLOW_SHFT 31
-#define SH_MEM_ERROR_SUMMARY_XN_REQUEST_OVERFLOW_MASK 0x0000000080000000
-
-/*   SH_MEM_ERROR_SUMMARY_RED_BLACK_ERR_TIMEOUT                         */
-/*   Description:  red black scheme did not clean up soon enough        */
-#define SH_MEM_ERROR_SUMMARY_RED_BLACK_ERR_TIMEOUT_SHFT 32
-#define SH_MEM_ERROR_SUMMARY_RED_BLACK_ERR_TIMEOUT_MASK 0x0000000100000000
-
-/*   SH_MEM_ERROR_SUMMARY_PI_PKT_SIZE                                   */
-/*   Description:  received data bearing packet from pi with wrong siz  */
-#define SH_MEM_ERROR_SUMMARY_PI_PKT_SIZE_SHFT    33
-#define SH_MEM_ERROR_SUMMARY_PI_PKT_SIZE_MASK    0x0000000200000000
-
-/*   SH_MEM_ERROR_SUMMARY_XN_PKT_SIZE                                   */
-/*   Description:  received data bearing packet from xn with wrong siz  */
-#define SH_MEM_ERROR_SUMMARY_XN_PKT_SIZE_SHFT    34
-#define SH_MEM_ERROR_SUMMARY_XN_PKT_SIZE_MASK    0x0000000400000000
-
-/* ==================================================================== */
-/*                Register "SH_MEM_ERROR_SUMMARY_ALIAS"                 */
-/*                    Memory error flags clear alias                    */
-/* ==================================================================== */
-
-#define SH_MEM_ERROR_SUMMARY_ALIAS               0x00000001000000c0
-
-/* ==================================================================== */
-/*                   Register "SH_MEM_ERROR_OVERFLOW"                   */
-/*                          Memory error flags                          */
-/* ==================================================================== */
-
-#define SH_MEM_ERROR_OVERFLOW                    0x00000001000000c8
-#define SH_MEM_ERROR_OVERFLOW_MASK               0x00000007f77777ff
-#define SH_MEM_ERROR_OVERFLOW_INIT               0x0000000000000000
-
-/*   SH_MEM_ERROR_OVERFLOW_ILLEGAL_CMD                                  */
-/*   Description:  illegal command error                                */
-#define SH_MEM_ERROR_OVERFLOW_ILLEGAL_CMD_SHFT   0
-#define SH_MEM_ERROR_OVERFLOW_ILLEGAL_CMD_MASK   0x0000000000000001
-
-/*   SH_MEM_ERROR_OVERFLOW_NONEXIST_ADDR                                */
-/*   Description:  non-existent memory error                            */
-#define SH_MEM_ERROR_OVERFLOW_NONEXIST_ADDR_SHFT 1
-#define SH_MEM_ERROR_OVERFLOW_NONEXIST_ADDR_MASK 0x0000000000000002
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLP_DIR_PERR                                */
-/*   Description:  directory protocol error in dqlp                     */
-#define SH_MEM_ERROR_OVERFLOW_DQLP_DIR_PERR_SHFT 2
-#define SH_MEM_ERROR_OVERFLOW_DQLP_DIR_PERR_MASK 0x0000000000000004
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRP_DIR_PERR                                */
-/*   Description:  directory protocol error in dqrp                     */
-#define SH_MEM_ERROR_OVERFLOW_DQRP_DIR_PERR_SHFT 3
-#define SH_MEM_ERROR_OVERFLOW_DQRP_DIR_PERR_MASK 0x0000000000000008
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLP_DIR_UC                                  */
-/*   Description:  uncorrectable directory error in dqlp                */
-#define SH_MEM_ERROR_OVERFLOW_DQLP_DIR_UC_SHFT   4
-#define SH_MEM_ERROR_OVERFLOW_DQLP_DIR_UC_MASK   0x0000000000000010
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLP_DIR_COR                                 */
-/*   Description:  correctable directory error in dqlp                  */
-#define SH_MEM_ERROR_OVERFLOW_DQLP_DIR_COR_SHFT  5
-#define SH_MEM_ERROR_OVERFLOW_DQLP_DIR_COR_MASK  0x0000000000000020
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRP_DIR_UC                                  */
-/*   Description:  uncorrectable directory error in dqrp                */
-#define SH_MEM_ERROR_OVERFLOW_DQRP_DIR_UC_SHFT   6
-#define SH_MEM_ERROR_OVERFLOW_DQRP_DIR_UC_MASK   0x0000000000000040
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRP_DIR_COR                                 */
-/*   Description:  correctable directory error in dqrp                  */
-#define SH_MEM_ERROR_OVERFLOW_DQRP_DIR_COR_SHFT  7
-#define SH_MEM_ERROR_OVERFLOW_DQRP_DIR_COR_MASK  0x0000000000000080
-
-/*   SH_MEM_ERROR_OVERFLOW_ACX_INT_HW                                   */
-/*   Description:  hardware interrupt from acx                          */
-#define SH_MEM_ERROR_OVERFLOW_ACX_INT_HW_SHFT    8
-#define SH_MEM_ERROR_OVERFLOW_ACX_INT_HW_MASK    0x0000000000000100
-
-/*   SH_MEM_ERROR_OVERFLOW_ACY_INT_HW                                   */
-/*   Description:  hardware interrupt from acy                          */
-#define SH_MEM_ERROR_OVERFLOW_ACY_INT_HW_SHFT    9
-#define SH_MEM_ERROR_OVERFLOW_ACY_INT_HW_MASK    0x0000000000000200
-
-/*   SH_MEM_ERROR_OVERFLOW_DIR_ACC                                      */
-/*   Description:  directory memory access error                        */
-#define SH_MEM_ERROR_OVERFLOW_DIR_ACC_SHFT       10
-#define SH_MEM_ERROR_OVERFLOW_DIR_ACC_MASK       0x0000000000000400
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLP_INT_UC                                  */
-/*   Description:  uncorrectable interrupt from dqlp                    */
-#define SH_MEM_ERROR_OVERFLOW_DQLP_INT_UC_SHFT   12
-#define SH_MEM_ERROR_OVERFLOW_DQLP_INT_UC_MASK   0x0000000000001000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLP_INT_COR                                 */
-/*   Description:  correctable interrupt from dqlp                      */
-#define SH_MEM_ERROR_OVERFLOW_DQLP_INT_COR_SHFT  13
-#define SH_MEM_ERROR_OVERFLOW_DQLP_INT_COR_MASK  0x0000000000002000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLP_INT_HW                                  */
-/*   Description:  hardware interrupt from dqlp                         */
-#define SH_MEM_ERROR_OVERFLOW_DQLP_INT_HW_SHFT   14
-#define SH_MEM_ERROR_OVERFLOW_DQLP_INT_HW_MASK   0x0000000000004000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLS_INT_UC                                  */
-/*   Description:  uncorrectable interrupt from dqls                    */
-#define SH_MEM_ERROR_OVERFLOW_DQLS_INT_UC_SHFT   16
-#define SH_MEM_ERROR_OVERFLOW_DQLS_INT_UC_MASK   0x0000000000010000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLS_INT_COR                                 */
-/*   Description:  correctable interrupt from dqls                      */
-#define SH_MEM_ERROR_OVERFLOW_DQLS_INT_COR_SHFT  17
-#define SH_MEM_ERROR_OVERFLOW_DQLS_INT_COR_MASK  0x0000000000020000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQLS_INT_HW                                  */
-/*   Description:  hardware interrupt from dqls                         */
-#define SH_MEM_ERROR_OVERFLOW_DQLS_INT_HW_SHFT   18
-#define SH_MEM_ERROR_OVERFLOW_DQLS_INT_HW_MASK   0x0000000000040000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRP_INT_UC                                  */
-/*   Description:  uncorrectable interrupt from dqrp                    */
-#define SH_MEM_ERROR_OVERFLOW_DQRP_INT_UC_SHFT   20
-#define SH_MEM_ERROR_OVERFLOW_DQRP_INT_UC_MASK   0x0000000000100000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRP_INT_COR                                 */
-/*   Description:  correctable interrupt from dqrp                      */
-#define SH_MEM_ERROR_OVERFLOW_DQRP_INT_COR_SHFT  21
-#define SH_MEM_ERROR_OVERFLOW_DQRP_INT_COR_MASK  0x0000000000200000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRP_INT_HW                                  */
-/*   Description:  hardware interrupt from dqrp                         */
-#define SH_MEM_ERROR_OVERFLOW_DQRP_INT_HW_SHFT   22
-#define SH_MEM_ERROR_OVERFLOW_DQRP_INT_HW_MASK   0x0000000000400000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRS_INT_UC                                  */
-/*   Description:  uncorrectable interrupt from dqrs                    */
-#define SH_MEM_ERROR_OVERFLOW_DQRS_INT_UC_SHFT   24
-#define SH_MEM_ERROR_OVERFLOW_DQRS_INT_UC_MASK   0x0000000001000000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRS_INT_COR                                 */
-/*   Description:  correctable interrupt from dqrs                      */
-#define SH_MEM_ERROR_OVERFLOW_DQRS_INT_COR_SHFT  25
-#define SH_MEM_ERROR_OVERFLOW_DQRS_INT_COR_MASK  0x0000000002000000
-
-/*   SH_MEM_ERROR_OVERFLOW_DQRS_INT_HW                                  */
-/*   Description:  hardware interrupt from dqrs                         */
-#define SH_MEM_ERROR_OVERFLOW_DQRS_INT_HW_SHFT   26
-#define SH_MEM_ERROR_OVERFLOW_DQRS_INT_HW_MASK   0x0000000004000000
-
-/*   SH_MEM_ERROR_OVERFLOW_PI_REPLY_OVERFLOW                            */
-/*   Description:  too many reply packets came from pi                  */
-#define SH_MEM_ERROR_OVERFLOW_PI_REPLY_OVERFLOW_SHFT 28
-#define SH_MEM_ERROR_OVERFLOW_PI_REPLY_OVERFLOW_MASK 0x0000000010000000
-
-/*   SH_MEM_ERROR_OVERFLOW_XN_REPLY_OVERFLOW                            */
-/*   Description:  too many reply packets came from xn                  */
-#define SH_MEM_ERROR_OVERFLOW_XN_REPLY_OVERFLOW_SHFT 29
-#define SH_MEM_ERROR_OVERFLOW_XN_REPLY_OVERFLOW_MASK 0x0000000020000000
-
-/*   SH_MEM_ERROR_OVERFLOW_PI_REQUEST_OVERFLOW                          */
-/*   Description:  too many request packets came from pi                */
-#define SH_MEM_ERROR_OVERFLOW_PI_REQUEST_OVERFLOW_SHFT 30
-#define SH_MEM_ERROR_OVERFLOW_PI_REQUEST_OVERFLOW_MASK 0x0000000040000000
-
-/*   SH_MEM_ERROR_OVERFLOW_XN_REQUEST_OVERFLOW                          */
-/*   Description:  too many request packets came from xn                */
-#define SH_MEM_ERROR_OVERFLOW_XN_REQUEST_OVERFLOW_SHFT 31
-#define SH_MEM_ERROR_OVERFLOW_XN_REQUEST_OVERFLOW_MASK 0x0000000080000000
-
-/*   SH_MEM_ERROR_OVERFLOW_RED_BLACK_ERR_TIMEOUT                        */
-/*   Description:  red black scheme did not clean up soon enough        */
-#define SH_MEM_ERROR_OVERFLOW_RED_BLACK_ERR_TIMEOUT_SHFT 32
-#define SH_MEM_ERROR_OVERFLOW_RED_BLACK_ERR_TIMEOUT_MASK 0x0000000100000000
-
-/*   SH_MEM_ERROR_OVERFLOW_PI_PKT_SIZE                                  */
-/*   Description:  received data bearing packet from pi with wrong siz  */
-#define SH_MEM_ERROR_OVERFLOW_PI_PKT_SIZE_SHFT   33
-#define SH_MEM_ERROR_OVERFLOW_PI_PKT_SIZE_MASK   0x0000000200000000
-
-/*   SH_MEM_ERROR_OVERFLOW_XN_PKT_SIZE                                  */
-/*   Description:  received data bearing packet from xn with wrong siz  */
-#define SH_MEM_ERROR_OVERFLOW_XN_PKT_SIZE_SHFT   34
-#define SH_MEM_ERROR_OVERFLOW_XN_PKT_SIZE_MASK   0x0000000400000000
-
-/* ==================================================================== */
-/*                Register "SH_MEM_ERROR_OVERFLOW_ALIAS"                */
-/*                    Memory error flags clear alias                    */
-/* ==================================================================== */
-
-#define SH_MEM_ERROR_OVERFLOW_ALIAS              0x00000001000000d0
-
-/* ==================================================================== */
-/*                     Register "SH_MEM_ERROR_MASK"                     */
-/*                          Memory error flags                          */
-/* ==================================================================== */
-
-#define SH_MEM_ERROR_MASK                        0x00000001000000d8
-#define SH_MEM_ERROR_MASK_MASK                   0x00000007f77777ff
-#define SH_MEM_ERROR_MASK_INIT                   0x00000007f77773ff
-
-/*   SH_MEM_ERROR_MASK_ILLEGAL_CMD                                      */
-/*   Description:  illegal command error                                */
-#define SH_MEM_ERROR_MASK_ILLEGAL_CMD_SHFT       0
-#define SH_MEM_ERROR_MASK_ILLEGAL_CMD_MASK       0x0000000000000001
-
-/*   SH_MEM_ERROR_MASK_NONEXIST_ADDR                                    */
-/*   Description:  non-existent memory error                            */
-#define SH_MEM_ERROR_MASK_NONEXIST_ADDR_SHFT     1
-#define SH_MEM_ERROR_MASK_NONEXIST_ADDR_MASK     0x0000000000000002
-
-/*   SH_MEM_ERROR_MASK_DQLP_DIR_PERR                                    */
-/*   Description:  directory protocol error in dqlp                     */
-#define SH_MEM_ERROR_MASK_DQLP_DIR_PERR_SHFT     2
-#define SH_MEM_ERROR_MASK_DQLP_DIR_PERR_MASK     0x0000000000000004
-
-/*   SH_MEM_ERROR_MASK_DQRP_DIR_PERR                                    */
-/*   Description:  directory protocol error in dqrp                     */
-#define SH_MEM_ERROR_MASK_DQRP_DIR_PERR_SHFT     3
-#define SH_MEM_ERROR_MASK_DQRP_DIR_PERR_MASK     0x0000000000000008
-
-/*   SH_MEM_ERROR_MASK_DQLP_DIR_UC                                      */
-/*   Description:  uncorrectable directory error in dqlp                */
-#define SH_MEM_ERROR_MASK_DQLP_DIR_UC_SHFT       4
-#define SH_MEM_ERROR_MASK_DQLP_DIR_UC_MASK       0x0000000000000010
-
-/*   SH_MEM_ERROR_MASK_DQLP_DIR_COR                                     */
-/*   Description:  correctable directory error in dqlp                  */
-#define SH_MEM_ERROR_MASK_DQLP_DIR_COR_SHFT      5
-#define SH_MEM_ERROR_MASK_DQLP_DIR_COR_MASK      0x0000000000000020
-
-/*   SH_MEM_ERROR_MASK_DQRP_DIR_UC                                      */
-/*   Description:  uncorrectable directory error in dqrp                */
-#define SH_MEM_ERROR_MASK_DQRP_DIR_UC_SHFT       6
-#define SH_MEM_ERROR_MASK_DQRP_DIR_UC_MASK       0x0000000000000040
-
-/*   SH_MEM_ERROR_MASK_DQRP_DIR_COR                                     */
-/*   Description:  correctable directory error in dqrp                  */
-#define SH_MEM_ERROR_MASK_DQRP_DIR_COR_SHFT      7
-#define SH_MEM_ERROR_MASK_DQRP_DIR_COR_MASK      0x0000000000000080
-
-/*   SH_MEM_ERROR_MASK_ACX_INT_HW                                       */
-/*   Description:  hardware interrupt from acx                          */
-#define SH_MEM_ERROR_MASK_ACX_INT_HW_SHFT        8
-#define SH_MEM_ERROR_MASK_ACX_INT_HW_MASK        0x0000000000000100
-
-/*   SH_MEM_ERROR_MASK_ACY_INT_HW                                       */
-/*   Description:  hardware interrupt from acy                          */
-#define SH_MEM_ERROR_MASK_ACY_INT_HW_SHFT        9
-#define SH_MEM_ERROR_MASK_ACY_INT_HW_MASK        0x0000000000000200
-
-/*   SH_MEM_ERROR_MASK_DIR_ACC                                          */
-/*   Description:  directory memory access error                        */
-#define SH_MEM_ERROR_MASK_DIR_ACC_SHFT           10
-#define SH_MEM_ERROR_MASK_DIR_ACC_MASK           0x0000000000000400
-
-/*   SH_MEM_ERROR_MASK_DQLP_INT_UC                                      */
-/*   Description:  uncorrectable interrupt from dqlp                    */
-#define SH_MEM_ERROR_MASK_DQLP_INT_UC_SHFT       12
-#define SH_MEM_ERROR_MASK_DQLP_INT_UC_MASK       0x0000000000001000
-
-/*   SH_MEM_ERROR_MASK_DQLP_INT_COR                                     */
-/*   Description:  correctable interrupt from dqlp                      */
-#define SH_MEM_ERROR_MASK_DQLP_INT_COR_SHFT      13
-#define SH_MEM_ERROR_MASK_DQLP_INT_COR_MASK      0x0000000000002000
-
-/*   SH_MEM_ERROR_MASK_DQLP_INT_HW                                      */
-/*   Description:  hardware interrupt from dqlp                         */
-#define SH_MEM_ERROR_MASK_DQLP_INT_HW_SHFT       14
-#define SH_MEM_ERROR_MASK_DQLP_INT_HW_MASK       0x0000000000004000
-
-/*   SH_MEM_ERROR_MASK_DQLS_INT_UC                                      */
-/*   Description:  uncorrectable interrupt from dqls                    */
-#define SH_MEM_ERROR_MASK_DQLS_INT_UC_SHFT       16
-#define SH_MEM_ERROR_MASK_DQLS_INT_UC_MASK       0x0000000000010000
-
-/*   SH_MEM_ERROR_MASK_DQLS_INT_COR                                     */
-/*   Description:  correctable interrupt from dqls                      */
-#define SH_MEM_ERROR_MASK_DQLS_INT_COR_SHFT      17
-#define SH_MEM_ERROR_MASK_DQLS_INT_COR_MASK      0x0000000000020000
-
-/*   SH_MEM_ERROR_MASK_DQLS_INT_HW                                      */
-/*   Description:  hardware interrupt from dqls                         */
-#define SH_MEM_ERROR_MASK_DQLS_INT_HW_SHFT       18
-#define SH_MEM_ERROR_MASK_DQLS_INT_HW_MASK       0x0000000000040000
-
-/*   SH_MEM_ERROR_MASK_DQRP_INT_UC                                      */
-/*   Description:  uncorrectable interrupt from dqrp                    */
-#define SH_MEM_ERROR_MASK_DQRP_INT_UC_SHFT       20
-#define SH_MEM_ERROR_MASK_DQRP_INT_UC_MASK       0x0000000000100000
-
-/*   SH_MEM_ERROR_MASK_DQRP_INT_COR                                     */
-/*   Description:  correctable interrupt from dqrp                      */
-#define SH_MEM_ERROR_MASK_DQRP_INT_COR_SHFT      21
-#define SH_MEM_ERROR_MASK_DQRP_INT_COR_MASK      0x0000000000200000
-
-/*   SH_MEM_ERROR_MASK_DQRP_INT_HW                                      */
-/*   Description:  hardware interrupt from dqrp                         */
-#define SH_MEM_ERROR_MASK_DQRP_INT_HW_SHFT       22
-#define SH_MEM_ERROR_MASK_DQRP_INT_HW_MASK       0x0000000000400000
-
-/*   SH_MEM_ERROR_MASK_DQRS_INT_UC                                      */
-/*   Description:  uncorrectable interrupt from dqrs                    */
-#define SH_MEM_ERROR_MASK_DQRS_INT_UC_SHFT       24
-#define SH_MEM_ERROR_MASK_DQRS_INT_UC_MASK       0x0000000001000000
-
-/*   SH_MEM_ERROR_MASK_DQRS_INT_COR                                     */
-/*   Description:  correctable interrupt from dqrs                      */
-#define SH_MEM_ERROR_MASK_DQRS_INT_COR_SHFT      25
-#define SH_MEM_ERROR_MASK_DQRS_INT_COR_MASK      0x0000000002000000
-
-/*   SH_MEM_ERROR_MASK_DQRS_INT_HW                                      */
-/*   Description:  hardware interrupt from dqrs                         */
-#define SH_MEM_ERROR_MASK_DQRS_INT_HW_SHFT       26
-#define SH_MEM_ERROR_MASK_DQRS_INT_HW_MASK       0x0000000004000000
-
-/*   SH_MEM_ERROR_MASK_PI_REPLY_OVERFLOW                                */
-/*   Description:  too many reply packets came from pi                  */
-#define SH_MEM_ERROR_MASK_PI_REPLY_OVERFLOW_SHFT 28
-#define SH_MEM_ERROR_MASK_PI_REPLY_OVERFLOW_MASK 0x0000000010000000
-
-/*   SH_MEM_ERROR_MASK_XN_REPLY_OVERFLOW                                */
-/*   Description:  too many reply packets came from xn                  */
-#define SH_MEM_ERROR_MASK_XN_REPLY_OVERFLOW_SHFT 29
-#define SH_MEM_ERROR_MASK_XN_REPLY_OVERFLOW_MASK 0x0000000020000000
-
-/*   SH_MEM_ERROR_MASK_PI_REQUEST_OVERFLOW                              */
-/*   Description:  too many request packets came from pi                */
-#define SH_MEM_ERROR_MASK_PI_REQUEST_OVERFLOW_SHFT 30
-#define SH_MEM_ERROR_MASK_PI_REQUEST_OVERFLOW_MASK 0x0000000040000000
-
-/*   SH_MEM_ERROR_MASK_XN_REQUEST_OVERFLOW                              */
-/*   Description:  too many request packets came from xn                */
-#define SH_MEM_ERROR_MASK_XN_REQUEST_OVERFLOW_SHFT 31
-#define SH_MEM_ERROR_MASK_XN_REQUEST_OVERFLOW_MASK 0x0000000080000000
-
-/*   SH_MEM_ERROR_MASK_RED_BLACK_ERR_TIMEOUT                            */
-/*   Description:  red black scheme did not clean up soon enough        */
-#define SH_MEM_ERROR_MASK_RED_BLACK_ERR_TIMEOUT_SHFT 32
-#define SH_MEM_ERROR_MASK_RED_BLACK_ERR_TIMEOUT_MASK 0x0000000100000000
-
-/*   SH_MEM_ERROR_MASK_PI_PKT_SIZE                                      */
-/*   Description:  received data bearing packet from pi with wrong siz  */
-#define SH_MEM_ERROR_MASK_PI_PKT_SIZE_SHFT       33
-#define SH_MEM_ERROR_MASK_PI_PKT_SIZE_MASK       0x0000000200000000
-
-/*   SH_MEM_ERROR_MASK_XN_PKT_SIZE                                      */
-/*   Description:  received data bearing packet from xn with wrong siz  */
-#define SH_MEM_ERROR_MASK_XN_PKT_SIZE_SHFT       34
-#define SH_MEM_ERROR_MASK_XN_PKT_SIZE_MASK       0x0000000400000000
-
-/* ==================================================================== */
-/*                       Register "SH_X_DIMM_CFG"                       */
-/*                       AC Mem Config Registers                        */
-/* ==================================================================== */
-
-#define SH_X_DIMM_CFG                            0x0000000100010000
-#define SH_X_DIMM_CFG_MASK                       0x0000000f7f7f7f7f
-#define SH_X_DIMM_CFG_INIT                       0x000000026f4f2f0f
-
-/*   SH_X_DIMM_CFG_DIMM0_SIZE                                           */
-/*   Description:  DIMM 0 DRAM size                                     */
-#define SH_X_DIMM_CFG_DIMM0_SIZE_SHFT            0
-#define SH_X_DIMM_CFG_DIMM0_SIZE_MASK            0x0000000000000007
-
-/*   SH_X_DIMM_CFG_DIMM0_2BK                                            */
-/*   Description:  DIMM 0 has two physical banks                        */
-#define SH_X_DIMM_CFG_DIMM0_2BK_SHFT             3
-#define SH_X_DIMM_CFG_DIMM0_2BK_MASK             0x0000000000000008
-
-/*   SH_X_DIMM_CFG_DIMM0_REV                                            */
-/*   Description:  DIMM 0 physical banks reversed                       */
-#define SH_X_DIMM_CFG_DIMM0_REV_SHFT             4
-#define SH_X_DIMM_CFG_DIMM0_REV_MASK             0x0000000000000010
-
-/*   SH_X_DIMM_CFG_DIMM0_CS                                             */
-/*   Description:  DIMM 0 chip select, addr[35:34] match                */
-#define SH_X_DIMM_CFG_DIMM0_CS_SHFT              5
-#define SH_X_DIMM_CFG_DIMM0_CS_MASK              0x0000000000000060
-
-/*   SH_X_DIMM_CFG_DIMM1_SIZE                                           */
-/*   Description:  DIMM 1 DRAM size                                     */
-#define SH_X_DIMM_CFG_DIMM1_SIZE_SHFT            8
-#define SH_X_DIMM_CFG_DIMM1_SIZE_MASK            0x0000000000000700
-
-/*   SH_X_DIMM_CFG_DIMM1_2BK                                            */
-/*   Description:  DIMM 1 has two physical banks                        */
-#define SH_X_DIMM_CFG_DIMM1_2BK_SHFT             11
-#define SH_X_DIMM_CFG_DIMM1_2BK_MASK             0x0000000000000800
-
-/*   SH_X_DIMM_CFG_DIMM1_REV                                            */
-/*   Description:  DIMM 1 physical banks reversed                       */
-#define SH_X_DIMM_CFG_DIMM1_REV_SHFT             12
-#define SH_X_DIMM_CFG_DIMM1_REV_MASK             0x0000000000001000
-
-/*   SH_X_DIMM_CFG_DIMM1_CS                                             */
-/*   Description:  DIMM 1 chip select, addr[35:34] match                */
-#define SH_X_DIMM_CFG_DIMM1_CS_SHFT              13
-#define SH_X_DIMM_CFG_DIMM1_CS_MASK              0x0000000000006000
-
-/*   SH_X_DIMM_CFG_DIMM2_SIZE                                           */
-/*   Description:  DIMM 2 DRAM size                                     */
-#define SH_X_DIMM_CFG_DIMM2_SIZE_SHFT            16
-#define SH_X_DIMM_CFG_DIMM2_SIZE_MASK            0x0000000000070000
-
-/*   SH_X_DIMM_CFG_DIMM2_2BK                                            */
-/*   Description:  DIMM 2 has two physical banks                        */
-#define SH_X_DIMM_CFG_DIMM2_2BK_SHFT             19
-#define SH_X_DIMM_CFG_DIMM2_2BK_MASK             0x0000000000080000
-
-/*   SH_X_DIMM_CFG_DIMM2_REV                                            */
-/*   Description:  DIMM 2 physical banks reversed                       */
-#define SH_X_DIMM_CFG_DIMM2_REV_SHFT             20
-#define SH_X_DIMM_CFG_DIMM2_REV_MASK             0x0000000000100000
-
-/*   SH_X_DIMM_CFG_DIMM2_CS                                             */
-/*   Description:  DIMM 2 chip select, addr[35:34] match                */
-#define SH_X_DIMM_CFG_DIMM2_CS_SHFT              21
-#define SH_X_DIMM_CFG_DIMM2_CS_MASK              0x0000000000600000
-
-/*   SH_X_DIMM_CFG_DIMM3_SIZE                                           */
-/*   Description:  DIMM 3 DRAM size                                     */
-#define SH_X_DIMM_CFG_DIMM3_SIZE_SHFT            24
-#define SH_X_DIMM_CFG_DIMM3_SIZE_MASK            0x0000000007000000
-
-/*   SH_X_DIMM_CFG_DIMM3_2BK                                            */
-/*   Description:  DIMM 3 has two physical banks                        */
-#define SH_X_DIMM_CFG_DIMM3_2BK_SHFT             27
-#define SH_X_DIMM_CFG_DIMM3_2BK_MASK             0x0000000008000000
-
-/*   SH_X_DIMM_CFG_DIMM3_REV                                            */
-/*   Description:  DIMM 3 physical banks reversed                       */
-#define SH_X_DIMM_CFG_DIMM3_REV_SHFT             28
-#define SH_X_DIMM_CFG_DIMM3_REV_MASK             0x0000000010000000
-
-/*   SH_X_DIMM_CFG_DIMM3_CS                                             */
-/*   Description:  DIMM 3 chip select, addr[35:34] match                */
-#define SH_X_DIMM_CFG_DIMM3_CS_SHFT              29
-#define SH_X_DIMM_CFG_DIMM3_CS_MASK              0x0000000060000000
-
-/*   SH_X_DIMM_CFG_FREQ                                                 */
-/*   Description:  DIMM frequency select                                */
-#define SH_X_DIMM_CFG_FREQ_SHFT                  32
-#define SH_X_DIMM_CFG_FREQ_MASK                  0x0000000f00000000
-
-/* ==================================================================== */
-/*                       Register "SH_Y_DIMM_CFG"                       */
-/*                       AC Mem Config Registers                        */
-/* ==================================================================== */
-
-#define SH_Y_DIMM_CFG                            0x0000000100010008
-#define SH_Y_DIMM_CFG_MASK                       0x0000000f7f7f7f7f
-#define SH_Y_DIMM_CFG_INIT                       0x000000026f4f2f0f
-
-/*   SH_Y_DIMM_CFG_DIMM0_SIZE                                           */
-/*   Description:  DIMM 0 DRAM size                                     */
-#define SH_Y_DIMM_CFG_DIMM0_SIZE_SHFT            0
-#define SH_Y_DIMM_CFG_DIMM0_SIZE_MASK            0x0000000000000007
-
-/*   SH_Y_DIMM_CFG_DIMM0_2BK                                            */
-/*   Description:  DIMM 0 has two physical banks                        */
-#define SH_Y_DIMM_CFG_DIMM0_2BK_SHFT             3
-#define SH_Y_DIMM_CFG_DIMM0_2BK_MASK             0x0000000000000008
-
-/*   SH_Y_DIMM_CFG_DIMM0_REV                                            */
-/*   Description:  DIMM 0 physical banks reversed                       */
-#define SH_Y_DIMM_CFG_DIMM0_REV_SHFT             4
-#define SH_Y_DIMM_CFG_DIMM0_REV_MASK             0x0000000000000010
-
-/*   SH_Y_DIMM_CFG_DIMM0_CS                                             */
-/*   Description:  DIMM 0 chip select, addr[35:34] match                */
-#define SH_Y_DIMM_CFG_DIMM0_CS_SHFT              5
-#define SH_Y_DIMM_CFG_DIMM0_CS_MASK              0x0000000000000060
-
-/*   SH_Y_DIMM_CFG_DIMM1_SIZE                                           */
-/*   Description:  DIMM 1 DRAM size                                     */
-#define SH_Y_DIMM_CFG_DIMM1_SIZE_SHFT            8
-#define SH_Y_DIMM_CFG_DIMM1_SIZE_MASK            0x0000000000000700
-
-/*   SH_Y_DIMM_CFG_DIMM1_2BK                                            */
-/*   Description:  DIMM 1 has two physical banks                        */
-#define SH_Y_DIMM_CFG_DIMM1_2BK_SHFT             11
-#define SH_Y_DIMM_CFG_DIMM1_2BK_MASK             0x0000000000000800
-
-/*   SH_Y_DIMM_CFG_DIMM1_REV                                            */
-/*   Description:  DIMM 1 physical banks reversed                       */
-#define SH_Y_DIMM_CFG_DIMM1_REV_SHFT             12
-#define SH_Y_DIMM_CFG_DIMM1_REV_MASK             0x0000000000001000
-
-/*   SH_Y_DIMM_CFG_DIMM1_CS                                             */
-/*   Description:  DIMM 1 chip select, addr[35:34] match                */
-#define SH_Y_DIMM_CFG_DIMM1_CS_SHFT              13
-#define SH_Y_DIMM_CFG_DIMM1_CS_MASK              0x0000000000006000
-
-/*   SH_Y_DIMM_CFG_DIMM2_SIZE                                           */
-/*   Description:  DIMM 2 DRAM size                                     */
-#define SH_Y_DIMM_CFG_DIMM2_SIZE_SHFT            16
-#define SH_Y_DIMM_CFG_DIMM2_SIZE_MASK            0x0000000000070000
-
-/*   SH_Y_DIMM_CFG_DIMM2_2BK                                            */
-/*   Description:  DIMM 2 has two physical banks                        */
-#define SH_Y_DIMM_CFG_DIMM2_2BK_SHFT             19
-#define SH_Y_DIMM_CFG_DIMM2_2BK_MASK             0x0000000000080000
-
-/*   SH_Y_DIMM_CFG_DIMM2_REV                                            */
-/*   Description:  DIMM 2 physical banks reversed                       */
-#define SH_Y_DIMM_CFG_DIMM2_REV_SHFT             20
-#define SH_Y_DIMM_CFG_DIMM2_REV_MASK             0x0000000000100000
-
-/*   SH_Y_DIMM_CFG_DIMM2_CS                                             */
-/*   Description:  DIMM 2 chip select, addr[35:34] match                */
-#define SH_Y_DIMM_CFG_DIMM2_CS_SHFT              21
-#define SH_Y_DIMM_CFG_DIMM2_CS_MASK              0x0000000000600000
-
-/*   SH_Y_DIMM_CFG_DIMM3_SIZE                                           */
-/*   Description:  DIMM 3 DRAM size                                     */
-#define SH_Y_DIMM_CFG_DIMM3_SIZE_SHFT            24
-#define SH_Y_DIMM_CFG_DIMM3_SIZE_MASK            0x0000000007000000
-
-/*   SH_Y_DIMM_CFG_DIMM3_2BK                                            */
-/*   Description:  DIMM 3 has two physical banks                        */
-#define SH_Y_DIMM_CFG_DIMM3_2BK_SHFT             27
-#define SH_Y_DIMM_CFG_DIMM3_2BK_MASK             0x0000000008000000
-
-/*   SH_Y_DIMM_CFG_DIMM3_REV                                            */
-/*   Description:  DIMM 3 physical banks reversed                       */
-#define SH_Y_DIMM_CFG_DIMM3_REV_SHFT             28
-#define SH_Y_DIMM_CFG_DIMM3_REV_MASK             0x0000000010000000
-
-/*   SH_Y_DIMM_CFG_DIMM3_CS                                             */
-/*   Description:  DIMM 3 chip select, addr[35:34] match                */
-#define SH_Y_DIMM_CFG_DIMM3_CS_SHFT              29
-#define SH_Y_DIMM_CFG_DIMM3_CS_MASK              0x0000000060000000
-
-/*   SH_Y_DIMM_CFG_FREQ                                                 */
-/*   Description:  DIMM frequency select                                */
-#define SH_Y_DIMM_CFG_FREQ_SHFT                  32
-#define SH_Y_DIMM_CFG_FREQ_MASK                  0x0000000f00000000
-
-/* ==================================================================== */
-/*                      Register "SH_JNR_DIMM_CFG"                      */
-/*                       AC Mem Config Registers                        */
-/* ==================================================================== */
-
-#define SH_JNR_DIMM_CFG                          0x0000000100010010
-#define SH_JNR_DIMM_CFG_MASK                     0x0000000f7f7f7f7f
-#define SH_JNR_DIMM_CFG_INIT                     0x000000026f4f2f0f
-
-/*   SH_JNR_DIMM_CFG_DIMM0_SIZE                                         */
-/*   Description:  DIMM 0 DRAM size                                     */
-#define SH_JNR_DIMM_CFG_DIMM0_SIZE_SHFT          0
-#define SH_JNR_DIMM_CFG_DIMM0_SIZE_MASK          0x0000000000000007
-
-/*   SH_JNR_DIMM_CFG_DIMM0_2BK                                          */
-/*   Description:  DIMM 0 has two physical banks                        */
-#define SH_JNR_DIMM_CFG_DIMM0_2BK_SHFT           3
-#define SH_JNR_DIMM_CFG_DIMM0_2BK_MASK           0x0000000000000008
-
-/*   SH_JNR_DIMM_CFG_DIMM0_REV                                          */
-/*   Description:  DIMM 0 physical banks reversed                       */
-#define SH_JNR_DIMM_CFG_DIMM0_REV_SHFT           4
-#define SH_JNR_DIMM_CFG_DIMM0_REV_MASK           0x0000000000000010
-
-/*   SH_JNR_DIMM_CFG_DIMM0_CS                                           */
-/*   Description:  DIMM 0 chip select, addr[35:34] match                */
-#define SH_JNR_DIMM_CFG_DIMM0_CS_SHFT            5
-#define SH_JNR_DIMM_CFG_DIMM0_CS_MASK            0x0000000000000060
-
-/*   SH_JNR_DIMM_CFG_DIMM1_SIZE                                         */
-/*   Description:  DIMM 1 DRAM size                                     */
-#define SH_JNR_DIMM_CFG_DIMM1_SIZE_SHFT          8
-#define SH_JNR_DIMM_CFG_DIMM1_SIZE_MASK          0x0000000000000700
-
-/*   SH_JNR_DIMM_CFG_DIMM1_2BK                                          */
-/*   Description:  DIMM 1 has two physical banks                        */
-#define SH_JNR_DIMM_CFG_DIMM1_2BK_SHFT           11
-#define SH_JNR_DIMM_CFG_DIMM1_2BK_MASK           0x0000000000000800
-
-/*   SH_JNR_DIMM_CFG_DIMM1_REV                                          */
-/*   Description:  DIMM 1 physical banks reversed                       */
-#define SH_JNR_DIMM_CFG_DIMM1_REV_SHFT           12
-#define SH_JNR_DIMM_CFG_DIMM1_REV_MASK           0x0000000000001000
-
-/*   SH_JNR_DIMM_CFG_DIMM1_CS                                           */
-/*   Description:  DIMM 1 chip select, addr[35:34] match                */
-#define SH_JNR_DIMM_CFG_DIMM1_CS_SHFT            13
-#define SH_JNR_DIMM_CFG_DIMM1_CS_MASK            0x0000000000006000
-
-/*   SH_JNR_DIMM_CFG_DIMM2_SIZE                                         */
-/*   Description:  DIMM 2 DRAM size                                     */
-#define SH_JNR_DIMM_CFG_DIMM2_SIZE_SHFT          16
-#define SH_JNR_DIMM_CFG_DIMM2_SIZE_MASK          0x0000000000070000
-
-/*   SH_JNR_DIMM_CFG_DIMM2_2BK                                          */
-/*   Description:  DIMM 2 has two physical banks                        */
-#define SH_JNR_DIMM_CFG_DIMM2_2BK_SHFT           19
-#define SH_JNR_DIMM_CFG_DIMM2_2BK_MASK           0x0000000000080000
-
-/*   SH_JNR_DIMM_CFG_DIMM2_REV                                          */
-/*   Description:  DIMM 2 physical banks reversed                       */
-#define SH_JNR_DIMM_CFG_DIMM2_REV_SHFT           20
-#define SH_JNR_DIMM_CFG_DIMM2_REV_MASK           0x0000000000100000
-
-/*   SH_JNR_DIMM_CFG_DIMM2_CS                                           */
-/*   Description:  DIMM 2 chip select, addr[35:34] match                */
-#define SH_JNR_DIMM_CFG_DIMM2_CS_SHFT            21
-#define SH_JNR_DIMM_CFG_DIMM2_CS_MASK            0x0000000000600000
-
-/*   SH_JNR_DIMM_CFG_DIMM3_SIZE                                         */
-/*   Description:  DIMM 3 DRAM size                                     */
-#define SH_JNR_DIMM_CFG_DIMM3_SIZE_SHFT          24
-#define SH_JNR_DIMM_CFG_DIMM3_SIZE_MASK          0x0000000007000000
-
-/*   SH_JNR_DIMM_CFG_DIMM3_2BK                                          */
-/*   Description:  DIMM 3 has two physical banks                        */
-#define SH_JNR_DIMM_CFG_DIMM3_2BK_SHFT           27
-#define SH_JNR_DIMM_CFG_DIMM3_2BK_MASK           0x0000000008000000
-
-/*   SH_JNR_DIMM_CFG_DIMM3_REV                                          */
-/*   Description:  DIMM 3 physical banks reversed                       */
-#define SH_JNR_DIMM_CFG_DIMM3_REV_SHFT           28
-#define SH_JNR_DIMM_CFG_DIMM3_REV_MASK           0x0000000010000000
-
-/*   SH_JNR_DIMM_CFG_DIMM3_CS                                           */
-/*   Description:  DIMM 3 chip select, addr[35:34] match                */
-#define SH_JNR_DIMM_CFG_DIMM3_CS_SHFT            29
-#define SH_JNR_DIMM_CFG_DIMM3_CS_MASK            0x0000000060000000
-
-/*   SH_JNR_DIMM_CFG_FREQ                                               */
-/*   Description:  DIMM frequency select                                */
-#define SH_JNR_DIMM_CFG_FREQ_SHFT                32
-#define SH_JNR_DIMM_CFG_FREQ_MASK                0x0000000f00000000
-
-/* ==================================================================== */
-/*                      Register "SH_X_PHASE_CFG"                       */
-/*                      AC Phase Config Registers                       */
-/* ==================================================================== */
-
-#define SH_X_PHASE_CFG                           0x0000000100010018
-#define SH_X_PHASE_CFG_MASK                      0x7fffffffffffffff
-#define SH_X_PHASE_CFG_INIT                      0x0000000000000000
-
-/*   SH_X_PHASE_CFG_LD_A                                                */
-/*   Description:  Address, control load core clock A latch             */
-#define SH_X_PHASE_CFG_LD_A_SHFT                 0
-#define SH_X_PHASE_CFG_LD_A_MASK                 0x000000000000001f
-
-/*   SH_X_PHASE_CFG_LD_B                                                */
-/*   Description:  Address, control load core clock B latch             */
-#define SH_X_PHASE_CFG_LD_B_SHFT                 5
-#define SH_X_PHASE_CFG_LD_B_MASK                 0x00000000000003e0
-
-/*   SH_X_PHASE_CFG_DQ_LD_A                                             */
-/*   Description:  DATA MCI load core clock A latch                     */
-#define SH_X_PHASE_CFG_DQ_LD_A_SHFT              10
-#define SH_X_PHASE_CFG_DQ_LD_A_MASK              0x0000000000007c00
-
-/*   SH_X_PHASE_CFG_DQ_LD_B                                             */
-/*   Description:  DATA MCI load core clock B latch                     */
-#define SH_X_PHASE_CFG_DQ_LD_B_SHFT              15
-#define SH_X_PHASE_CFG_DQ_LD_B_MASK              0x00000000000f8000
-
-/*   SH_X_PHASE_CFG_HOLD                                                */
-/*   Description:  Hold request on core clock phase                     */
-#define SH_X_PHASE_CFG_HOLD_SHFT                 20
-#define SH_X_PHASE_CFG_HOLD_MASK                 0x0000000001f00000
-
-/*   SH_X_PHASE_CFG_HOLD_REQ                                            */
-/*   Description:  Hold next request on core clock phase                */
-#define SH_X_PHASE_CFG_HOLD_REQ_SHFT             25
-#define SH_X_PHASE_CFG_HOLD_REQ_MASK             0x000000003e000000
-
-/*   SH_X_PHASE_CFG_ADD_CP                                              */
-/*   Description:  add delay clock period to dqct delay chain on phase  */
-#define SH_X_PHASE_CFG_ADD_CP_SHFT               30
-#define SH_X_PHASE_CFG_ADD_CP_MASK               0x00000007c0000000
-
-/*   SH_X_PHASE_CFG_BUBBLE_EN                                           */
-/*   Description:  bubble, idle core clock to wait for memory clock     */
-#define SH_X_PHASE_CFG_BUBBLE_EN_SHFT            35
-#define SH_X_PHASE_CFG_BUBBLE_EN_MASK            0x000000f800000000
-
-/*   SH_X_PHASE_CFG_PHA_BUBBLE                                          */
-/*   Description:  MMR phaseA bubble value                              */
-#define SH_X_PHASE_CFG_PHA_BUBBLE_SHFT           40
-#define SH_X_PHASE_CFG_PHA_BUBBLE_MASK           0x0000070000000000
-
-/*   SH_X_PHASE_CFG_PHB_BUBBLE                                          */
-/*   Description:  MMR phaseB bubble value                              */
-#define SH_X_PHASE_CFG_PHB_BUBBLE_SHFT           43
-#define SH_X_PHASE_CFG_PHB_BUBBLE_MASK           0x0000380000000000
-
-/*   SH_X_PHASE_CFG_PHC_BUBBLE                                          */
-/*   Description:  MMR phaseC bubble value                              */
-#define SH_X_PHASE_CFG_PHC_BUBBLE_SHFT           46
-#define SH_X_PHASE_CFG_PHC_BUBBLE_MASK           0x0001c00000000000
-
-/*   SH_X_PHASE_CFG_PHD_BUBBLE                                          */
-/*   Description:  MMR phaseD bubble value                              */
-#define SH_X_PHASE_CFG_PHD_BUBBLE_SHFT           49
-#define SH_X_PHASE_CFG_PHD_BUBBLE_MASK           0x000e000000000000
-
-/*   SH_X_PHASE_CFG_PHE_BUBBLE                                          */
-/*   Description:  MMR phaseE bubble value                              */
-#define SH_X_PHASE_CFG_PHE_BUBBLE_SHFT           52
-#define SH_X_PHASE_CFG_PHE_BUBBLE_MASK           0x0070000000000000
-
-/*   SH_X_PHASE_CFG_SEL_A                                               */
-/*   Description:  address,control select A memory clock latch          */
-#define SH_X_PHASE_CFG_SEL_A_SHFT                55
-#define SH_X_PHASE_CFG_SEL_A_MASK                0x0780000000000000
-
-/*   SH_X_PHASE_CFG_DQ_SEL_A                                            */
-/*   Description:  DATA MCI select A memory clock latch                 */
-#define SH_X_PHASE_CFG_DQ_SEL_A_SHFT             59
-#define SH_X_PHASE_CFG_DQ_SEL_A_MASK             0x7800000000000000
-
-/* ==================================================================== */
-/*                         Register "SH_X_CFG"                          */
-/*                         AC Config Registers                          */
-/* ==================================================================== */
-
-#define SH_X_CFG                                 0x0000000100010020
-#define SH_X_CFG_MASK                            0xffffffffffffffff
-#define SH_X_CFG_INIT                            0x108443103322100c
-
-/*   SH_X_CFG_MODE_SERIAL                                               */
-/*   Description:  Arbque arbitration in serial mode                    */
-#define SH_X_CFG_MODE_SERIAL_SHFT                0
-#define SH_X_CFG_MODE_SERIAL_MASK                0x0000000000000001
-
-/*   SH_X_CFG_DIRC_RANDOM_REPLACEMENT                                   */
-/*   Description:  Directory cache random replacement                   */
-#define SH_X_CFG_DIRC_RANDOM_REPLACEMENT_SHFT    1
-#define SH_X_CFG_DIRC_RANDOM_REPLACEMENT_MASK    0x0000000000000002
-
-/*   SH_X_CFG_DIR_COUNTER_INIT                                          */
-/*   Description:  Dir counter initial value                            */
-#define SH_X_CFG_DIR_COUNTER_INIT_SHFT           2
-#define SH_X_CFG_DIR_COUNTER_INIT_MASK           0x00000000000000fc
-
-/*   SH_X_CFG_TA_DLYS                                                   */
-/*   Description:  Turn around delays                                   */
-#define SH_X_CFG_TA_DLYS_SHFT                    8
-#define SH_X_CFG_TA_DLYS_MASK                    0x000000ffffffff00
-
-/*   SH_X_CFG_DA_BB_CLR                                                 */
-/*   Description:  Bank busy CPs for a data read request                */
-#define SH_X_CFG_DA_BB_CLR_SHFT                  40
-#define SH_X_CFG_DA_BB_CLR_MASK                  0x00000f0000000000
-
-/*   SH_X_CFG_DC_BB_CLR                                                 */
-/*   Description:  Bank busy CPs for a directory cache read request     */
-#define SH_X_CFG_DC_BB_CLR_SHFT                  44
-#define SH_X_CFG_DC_BB_CLR_MASK                  0x0000f00000000000
-
-/*   SH_X_CFG_WT_BB_CLR                                                 */
-/*   Description:  Bank busy CPs for all write request                  */
-#define SH_X_CFG_WT_BB_CLR_SHFT                  48
-#define SH_X_CFG_WT_BB_CLR_MASK                  0x000f000000000000
-
-/*   SH_X_CFG_SSO_WT_EN                                                 */
-/*   Description:  Simultaneous switching enabled on output data pins  */
-#define SH_X_CFG_SSO_WT_EN_SHFT                  52
-#define SH_X_CFG_SSO_WT_EN_MASK                  0x0010000000000000
-
-/*   SH_X_CFG_TRCD2_EN                                                  */
-/*   Description:  Trcd, ras to cas delay of 2 CPs enabled              */
-#define SH_X_CFG_TRCD2_EN_SHFT                   53
-#define SH_X_CFG_TRCD2_EN_MASK                   0x0020000000000000
-
-/*   SH_X_CFG_TRCD4_EN                                                  */
-/*   Description:  Trcd, ras to case delay of 4 CPs enabled             */
-#define SH_X_CFG_TRCD4_EN_SHFT                   54
-#define SH_X_CFG_TRCD4_EN_MASK                   0x0040000000000000
-
-/*   SH_X_CFG_REQ_CNTR_DIS                                              */
-/*   Description:  Request delay counter disabled                       */
-#define SH_X_CFG_REQ_CNTR_DIS_SHFT               55
-#define SH_X_CFG_REQ_CNTR_DIS_MASK               0x0080000000000000
-
-/*   SH_X_CFG_REQ_CNTR_VAL                                              */
-/*   Description:  Request counter delay value in CPs                   */
-#define SH_X_CFG_REQ_CNTR_VAL_SHFT               56
-#define SH_X_CFG_REQ_CNTR_VAL_MASK               0x3f00000000000000
-
-/*   SH_X_CFG_INV_CAS_ADDR                                              */
-/*   Description:  Invert cas address bits 3 to 7                       */
-#define SH_X_CFG_INV_CAS_ADDR_SHFT               62
-#define SH_X_CFG_INV_CAS_ADDR_MASK               0x4000000000000000
-
-/*   SH_X_CFG_CLR_DIR_CACHE                                             */
-/*   Description:  Clear directory cache tags                           */
-#define SH_X_CFG_CLR_DIR_CACHE_SHFT              63
-#define SH_X_CFG_CLR_DIR_CACHE_MASK              0x8000000000000000
-
-/* ==================================================================== */
-/*                       Register "SH_X_DQCT_CFG"                       */
-/*                         AC Config Registers                          */
-/* ==================================================================== */
-
-#define SH_X_DQCT_CFG                            0x0000000100010028
-#define SH_X_DQCT_CFG_MASK                       0x0000000000ffffff
-#define SH_X_DQCT_CFG_INIT                       0x0000000000585418
-
-/*   SH_X_DQCT_CFG_RD_SEL                                               */
-/*   Description:  Read data select                                     */
-#define SH_X_DQCT_CFG_RD_SEL_SHFT                0
-#define SH_X_DQCT_CFG_RD_SEL_MASK                0x000000000000000f
-
-/*   SH_X_DQCT_CFG_WT_SEL                                               */
-/*   Description:  Write data select                                    */
-#define SH_X_DQCT_CFG_WT_SEL_SHFT                4
-#define SH_X_DQCT_CFG_WT_SEL_MASK                0x00000000000000f0
-
-/*   SH_X_DQCT_CFG_DTA_RD_SEL                                           */
-/*   Description:  Data ready read select                               */
-#define SH_X_DQCT_CFG_DTA_RD_SEL_SHFT            8
-#define SH_X_DQCT_CFG_DTA_RD_SEL_MASK            0x0000000000000f00
-
-/*   SH_X_DQCT_CFG_DTA_WT_SEL                                           */
-/*   Description:  Data ready write select                              */
-#define SH_X_DQCT_CFG_DTA_WT_SEL_SHFT            12
-#define SH_X_DQCT_CFG_DTA_WT_SEL_MASK            0x000000000000f000
-
-/*   SH_X_DQCT_CFG_DIR_RD_SEL                                           */
-/*   Description:  Dir ready read select                                */
-#define SH_X_DQCT_CFG_DIR_RD_SEL_SHFT            16
-#define SH_X_DQCT_CFG_DIR_RD_SEL_MASK            0x00000000000f0000
-
-/*   SH_X_DQCT_CFG_MDIR_RD_SEL                                          */
-/*   Description:  Dir ready read select                                */
-#define SH_X_DQCT_CFG_MDIR_RD_SEL_SHFT           20
-#define SH_X_DQCT_CFG_MDIR_RD_SEL_MASK           0x0000000000f00000
-
-/* ==================================================================== */
-/*                   Register "SH_X_REFRESH_CONTROL"                    */
-/*                       Refresh Control Register                       */
-/* ==================================================================== */
-
-#define SH_X_REFRESH_CONTROL                     0x0000000100010030
-#define SH_X_REFRESH_CONTROL_MASK                0x000000000fffffff
-#define SH_X_REFRESH_CONTROL_INIT                0x00000000009cc300
-
-/*   SH_X_REFRESH_CONTROL_ENABLE                                        */
-/*   Description:  Refresh enable                                       */
-#define SH_X_REFRESH_CONTROL_ENABLE_SHFT         0
-#define SH_X_REFRESH_CONTROL_ENABLE_MASK         0x00000000000000ff
-
-/*   SH_X_REFRESH_CONTROL_INTERVAL                                      */
-/*   Description:  Refresh interval in core CPs                         */
-#define SH_X_REFRESH_CONTROL_INTERVAL_SHFT       8
-#define SH_X_REFRESH_CONTROL_INTERVAL_MASK       0x000000000001ff00
-
-/*   SH_X_REFRESH_CONTROL_HOLD                                          */
-/*   Description:  Refresh hold                                         */
-#define SH_X_REFRESH_CONTROL_HOLD_SHFT           17
-#define SH_X_REFRESH_CONTROL_HOLD_MASK           0x00000000007e0000
-
-/*   SH_X_REFRESH_CONTROL_INTERLEAVE                                    */
-/*   Description:  Refresh interleave                                   */
-#define SH_X_REFRESH_CONTROL_INTERLEAVE_SHFT     23
-#define SH_X_REFRESH_CONTROL_INTERLEAVE_MASK     0x0000000000800000
-
-/*   SH_X_REFRESH_CONTROL_HALF_RATE                                     */
-/*   Description:  Refresh half rate                                    */
-#define SH_X_REFRESH_CONTROL_HALF_RATE_SHFT      24
-#define SH_X_REFRESH_CONTROL_HALF_RATE_MASK      0x000000000f000000
-
-/* ==================================================================== */
-/*                      Register "SH_Y_PHASE_CFG"                       */
-/*                      AC Phase Config Registers                       */
-/* ==================================================================== */
-
-#define SH_Y_PHASE_CFG                           0x0000000100010038
-#define SH_Y_PHASE_CFG_MASK                      0x7fffffffffffffff
-#define SH_Y_PHASE_CFG_INIT                      0x0000000000000000
-
-/*   SH_Y_PHASE_CFG_LD_A                                                */
-/*   Description:  Address, control load core clock A latch             */
-#define SH_Y_PHASE_CFG_LD_A_SHFT                 0
-#define SH_Y_PHASE_CFG_LD_A_MASK                 0x000000000000001f
-
-/*   SH_Y_PHASE_CFG_LD_B                                                */
-/*   Description:  Address, control load core clock B latch             */
-#define SH_Y_PHASE_CFG_LD_B_SHFT                 5
-#define SH_Y_PHASE_CFG_LD_B_MASK                 0x00000000000003e0
-
-/*   SH_Y_PHASE_CFG_DQ_LD_A                                             */
-/*   Description:  DATA MCI load core clock A latch                     */
-#define SH_Y_PHASE_CFG_DQ_LD_A_SHFT              10
-#define SH_Y_PHASE_CFG_DQ_LD_A_MASK              0x0000000000007c00
-
-/*   SH_Y_PHASE_CFG_DQ_LD_B                                             */
-/*   Description:  DATA MCI load core clock B latch                     */
-#define SH_Y_PHASE_CFG_DQ_LD_B_SHFT              15
-#define SH_Y_PHASE_CFG_DQ_LD_B_MASK              0x00000000000f8000
-
-/*   SH_Y_PHASE_CFG_HOLD                                                */
-/*   Description:  Hold request on core clock phase                     */
-#define SH_Y_PHASE_CFG_HOLD_SHFT                 20
-#define SH_Y_PHASE_CFG_HOLD_MASK                 0x0000000001f00000
-
-/*   SH_Y_PHASE_CFG_HOLD_REQ                                            */
-/*   Description:  Hold next request on core clock phase                */
-#define SH_Y_PHASE_CFG_HOLD_REQ_SHFT             25
-#define SH_Y_PHASE_CFG_HOLD_REQ_MASK             0x000000003e000000
-
-/*   SH_Y_PHASE_CFG_ADD_CP                                              */
-/*   Description:  add delay clock period to dqct delay chain on phase  */
-#define SH_Y_PHASE_CFG_ADD_CP_SHFT               30
-#define SH_Y_PHASE_CFG_ADD_CP_MASK               0x00000007c0000000
-
-/*   SH_Y_PHASE_CFG_BUBBLE_EN                                           */
-/*   Description:  bubble, idle core clock to wait for memory clock     */
-#define SH_Y_PHASE_CFG_BUBBLE_EN_SHFT            35
-#define SH_Y_PHASE_CFG_BUBBLE_EN_MASK            0x000000f800000000
-
-/*   SH_Y_PHASE_CFG_PHA_BUBBLE                                          */
-/*   Description:  MMR phaseA bubble value                              */
-#define SH_Y_PHASE_CFG_PHA_BUBBLE_SHFT           40
-#define SH_Y_PHASE_CFG_PHA_BUBBLE_MASK           0x0000070000000000
-
-/*   SH_Y_PHASE_CFG_PHB_BUBBLE                                          */
-/*   Description:  MMR phaseB bubble value                              */
-#define SH_Y_PHASE_CFG_PHB_BUBBLE_SHFT           43
-#define SH_Y_PHASE_CFG_PHB_BUBBLE_MASK           0x0000380000000000
-
-/*   SH_Y_PHASE_CFG_PHC_BUBBLE                                          */
-/*   Description:  MMR phaseC bubble value                              */
-#define SH_Y_PHASE_CFG_PHC_BUBBLE_SHFT           46
-#define SH_Y_PHASE_CFG_PHC_BUBBLE_MASK           0x0001c00000000000
-
-/*   SH_Y_PHASE_CFG_PHD_BUBBLE                                          */
-/*   Description:  MMR phaseD bubble value                              */
-#define SH_Y_PHASE_CFG_PHD_BUBBLE_SHFT           49
-#define SH_Y_PHASE_CFG_PHD_BUBBLE_MASK           0x000e000000000000
-
-/*   SH_Y_PHASE_CFG_PHE_BUBBLE                                          */
-/*   Description:  MMR phaseE bubble value                              */
-#define SH_Y_PHASE_CFG_PHE_BUBBLE_SHFT           52
-#define SH_Y_PHASE_CFG_PHE_BUBBLE_MASK           0x0070000000000000
-
-/*   SH_Y_PHASE_CFG_SEL_A                                               */
-/*   Description:  address,control select A memory clock latch          */
-#define SH_Y_PHASE_CFG_SEL_A_SHFT                55
-#define SH_Y_PHASE_CFG_SEL_A_MASK                0x0780000000000000
-
-/*   SH_Y_PHASE_CFG_DQ_SEL_A                                            */
-/*   Description:  DATA MCI select A memory clock latch                 */
-#define SH_Y_PHASE_CFG_DQ_SEL_A_SHFT             59
-#define SH_Y_PHASE_CFG_DQ_SEL_A_MASK             0x7800000000000000
-
-/* ==================================================================== */
-/*                         Register "SH_Y_CFG"                          */
-/*                         AC Config Registers                          */
-/* ==================================================================== */
-
-#define SH_Y_CFG                                 0x0000000100010040
-#define SH_Y_CFG_MASK                            0xffffffffffffffff
-#define SH_Y_CFG_INIT                            0x108443103322100c
-
-/*   SH_Y_CFG_MODE_SERIAL                                               */
-/*   Description:  Arbque arbitration in serial mode                    */
-#define SH_Y_CFG_MODE_SERIAL_SHFT                0
-#define SH_Y_CFG_MODE_SERIAL_MASK                0x0000000000000001
-
-/*   SH_Y_CFG_DIRC_RANDOM_REPLACEMENT                                   */
-/*   Description:  Directory cache random replacement                   */
-#define SH_Y_CFG_DIRC_RANDOM_REPLACEMENT_SHFT    1
-#define SH_Y_CFG_DIRC_RANDOM_REPLACEMENT_MASK    0x0000000000000002
-
-/*   SH_Y_CFG_DIR_COUNTER_INIT                                          */
-/*   Description:  Dir counter initial value                            */
-#define SH_Y_CFG_DIR_COUNTER_INIT_SHFT           2
-#define SH_Y_CFG_DIR_COUNTER_INIT_MASK           0x00000000000000fc
-
-/*   SH_Y_CFG_TA_DLYS                                                   */
-/*   Description:  Turn around delays                                   */
-#define SH_Y_CFG_TA_DLYS_SHFT                    8
-#define SH_Y_CFG_TA_DLYS_MASK                    0x000000ffffffff00
-
-/*   SH_Y_CFG_DA_BB_CLR                                                 */
-/*   Description:  Bank busy CPs for a data read request                */
-#define SH_Y_CFG_DA_BB_CLR_SHFT                  40
-#define SH_Y_CFG_DA_BB_CLR_MASK                  0x00000f0000000000
-
-/*   SH_Y_CFG_DC_BB_CLR                                                 */
-/*   Description:  Bank busy CPs for a directory cache read request     */
-#define SH_Y_CFG_DC_BB_CLR_SHFT                  44
-#define SH_Y_CFG_DC_BB_CLR_MASK                  0x0000f00000000000
-
-/*   SH_Y_CFG_WT_BB_CLR                                                 */
-/*   Description:  Bank busy CPs for all write request                  */
-#define SH_Y_CFG_WT_BB_CLR_SHFT                  48
-#define SH_Y_CFG_WT_BB_CLR_MASK                  0x000f000000000000
-
-/*   SH_Y_CFG_SSO_WT_EN                                                 */
-/*   Description:  Simultaneous switching enabled on output data pins  */
-#define SH_Y_CFG_SSO_WT_EN_SHFT                  52
-#define SH_Y_CFG_SSO_WT_EN_MASK                  0x0010000000000000
-
-/*   SH_Y_CFG_TRCD2_EN                                                  */
-/*   Description:  Trcd, ras to cas delay of 2 CPs enabled              */
-#define SH_Y_CFG_TRCD2_EN_SHFT                   53
-#define SH_Y_CFG_TRCD2_EN_MASK                   0x0020000000000000
-
-/*   SH_Y_CFG_TRCD4_EN                                                  */
-/*   Description:  Trcd, ras to case delay of 4 CPs enabled             */
-#define SH_Y_CFG_TRCD4_EN_SHFT                   54
-#define SH_Y_CFG_TRCD4_EN_MASK                   0x0040000000000000
-
-/*   SH_Y_CFG_REQ_CNTR_DIS                                              */
-/*   Description:  Request delay counter disabled                       */
-#define SH_Y_CFG_REQ_CNTR_DIS_SHFT               55
-#define SH_Y_CFG_REQ_CNTR_DIS_MASK               0x0080000000000000
-
-/*   SH_Y_CFG_REQ_CNTR_VAL                                              */
-/*   Description:  Request counter delay value in CPs                   */
-#define SH_Y_CFG_REQ_CNTR_VAL_SHFT               56
-#define SH_Y_CFG_REQ_CNTR_VAL_MASK               0x3f00000000000000
-
-/*   SH_Y_CFG_INV_CAS_ADDR                                              */
-/*   Description:  Invert cas address bits 3 to 7                       */
-#define SH_Y_CFG_INV_CAS_ADDR_SHFT               62
-#define SH_Y_CFG_INV_CAS_ADDR_MASK               0x4000000000000000
-
-/*   SH_Y_CFG_CLR_DIR_CACHE                                             */
-/*   Description:  Clear directory cache tags                           */
-#define SH_Y_CFG_CLR_DIR_CACHE_SHFT              63
-#define SH_Y_CFG_CLR_DIR_CACHE_MASK              0x8000000000000000
-
-/* ==================================================================== */
-/*                       Register "SH_Y_DQCT_CFG"                       */
-/*                         AC Config Registers                          */
-/* ==================================================================== */
-
-#define SH_Y_DQCT_CFG                            0x0000000100010048
-#define SH_Y_DQCT_CFG_MASK                       0x0000000000ffffff
-#define SH_Y_DQCT_CFG_INIT                       0x0000000000585418
-
-/*   SH_Y_DQCT_CFG_RD_SEL                                               */
-/*   Description:  Read data select                                     */
-#define SH_Y_DQCT_CFG_RD_SEL_SHFT                0
-#define SH_Y_DQCT_CFG_RD_SEL_MASK                0x000000000000000f
-
-/*   SH_Y_DQCT_CFG_WT_SEL                                               */
-/*   Description:  Write data select                                    */
-#define SH_Y_DQCT_CFG_WT_SEL_SHFT                4
-#define SH_Y_DQCT_CFG_WT_SEL_MASK                0x00000000000000f0
-
-/*   SH_Y_DQCT_CFG_DTA_RD_SEL                                           */
-/*   Description:  Data ready read select                               */
-#define SH_Y_DQCT_CFG_DTA_RD_SEL_SHFT            8
-#define SH_Y_DQCT_CFG_DTA_RD_SEL_MASK            0x0000000000000f00
-
-/*   SH_Y_DQCT_CFG_DTA_WT_SEL                                           */
-/*   Description:  Data ready write select                              */
-#define SH_Y_DQCT_CFG_DTA_WT_SEL_SHFT            12
-#define SH_Y_DQCT_CFG_DTA_WT_SEL_MASK            0x000000000000f000
-
-/*   SH_Y_DQCT_CFG_DIR_RD_SEL                                           */
-/*   Description:  Dir ready read select                                */
-#define SH_Y_DQCT_CFG_DIR_RD_SEL_SHFT            16
-#define SH_Y_DQCT_CFG_DIR_RD_SEL_MASK            0x00000000000f0000
-
-/*   SH_Y_DQCT_CFG_MDIR_RD_SEL                                          */
-/*   Description:  Dir ready read select                                */
-#define SH_Y_DQCT_CFG_MDIR_RD_SEL_SHFT           20
-#define SH_Y_DQCT_CFG_MDIR_RD_SEL_MASK           0x0000000000f00000
-
-/* ==================================================================== */
-/*                   Register "SH_Y_REFRESH_CONTROL"                    */
-/*                       Refresh Control Register                       */
-/* ==================================================================== */
-
-#define SH_Y_REFRESH_CONTROL                     0x0000000100010050
-#define SH_Y_REFRESH_CONTROL_MASK                0x000000000fffffff
-#define SH_Y_REFRESH_CONTROL_INIT                0x00000000009cc300
-
-/*   SH_Y_REFRESH_CONTROL_ENABLE                                        */
-/*   Description:  Refresh enable                                       */
-#define SH_Y_REFRESH_CONTROL_ENABLE_SHFT         0
-#define SH_Y_REFRESH_CONTROL_ENABLE_MASK         0x00000000000000ff
-
-/*   SH_Y_REFRESH_CONTROL_INTERVAL                                      */
-/*   Description:  Refresh interval in core CPs                         */
-#define SH_Y_REFRESH_CONTROL_INTERVAL_SHFT       8
-#define SH_Y_REFRESH_CONTROL_INTERVAL_MASK       0x000000000001ff00
-
-/*   SH_Y_REFRESH_CONTROL_HOLD                                          */
-/*   Description:  Refresh hold                                         */
-#define SH_Y_REFRESH_CONTROL_HOLD_SHFT           17
-#define SH_Y_REFRESH_CONTROL_HOLD_MASK           0x00000000007e0000
-
-/*   SH_Y_REFRESH_CONTROL_INTERLEAVE                                    */
-/*   Description:  Refresh interleave                                   */
-#define SH_Y_REFRESH_CONTROL_INTERLEAVE_SHFT     23
-#define SH_Y_REFRESH_CONTROL_INTERLEAVE_MASK     0x0000000000800000
-
-/*   SH_Y_REFRESH_CONTROL_HALF_RATE                                     */
-/*   Description:  Refresh half rate                                    */
-#define SH_Y_REFRESH_CONTROL_HALF_RATE_SHFT      24
-#define SH_Y_REFRESH_CONTROL_HALF_RATE_MASK      0x000000000f000000
-
-/* ==================================================================== */
-/*                     Register "SH_MEM_RED_BLACK"                      */
-/*                     MD fairness watchdog timers                      */
-/* ==================================================================== */
-
-#define SH_MEM_RED_BLACK                         0x0000000100010058
-#define SH_MEM_RED_BLACK_MASK                    0x000fffffffffffff
-#define SH_MEM_RED_BLACK_INIT                    0x0000000040000400
-
-/*   SH_MEM_RED_BLACK_TIME                                              */
-/*   Description:  Clocks to tag references with a given color          */
-#define SH_MEM_RED_BLACK_TIME_SHFT               0
-#define SH_MEM_RED_BLACK_TIME_MASK               0x000000000000ffff
-
-/*   SH_MEM_RED_BLACK_ERR_TIME                                          */
-/*   Description:  Max clocks to wait after red/black change for old c  */
-/*  olor to clear.                                                      */
-#define SH_MEM_RED_BLACK_ERR_TIME_SHFT           16
-#define SH_MEM_RED_BLACK_ERR_TIME_MASK           0x000fffffffff0000
-
-/* ==================================================================== */
-/*                      Register "SH_MISC_MEM_CFG"                      */
-/* ==================================================================== */
-
-#define SH_MISC_MEM_CFG                          0x0000000100010060
-#define SH_MISC_MEM_CFG_MASK                     0x0013f1f1fff3f3ff
-#define SH_MISC_MEM_CFG_INIT                     0x0000000000010107
-
-/*   SH_MISC_MEM_CFG_EXPRESS_HEADER_ENABLE                              */
-/*   Description:  enables the use of express headers from md to pi     */
-#define SH_MISC_MEM_CFG_EXPRESS_HEADER_ENABLE_SHFT 0
-#define SH_MISC_MEM_CFG_EXPRESS_HEADER_ENABLE_MASK 0x0000000000000001
-
-/*   SH_MISC_MEM_CFG_SPEC_HEADER_ENABLE                                 */
-/*   Description:  enables the use of speculative headers from md to p  */
-#define SH_MISC_MEM_CFG_SPEC_HEADER_ENABLE_SHFT  1
-#define SH_MISC_MEM_CFG_SPEC_HEADER_ENABLE_MASK  0x0000000000000002
-
-/*   SH_MISC_MEM_CFG_JNR_BYPASS_ENABLE                                  */
-/*   Description:  enables bypass path for requests going through ac    */
-#define SH_MISC_MEM_CFG_JNR_BYPASS_ENABLE_SHFT   2
-#define SH_MISC_MEM_CFG_JNR_BYPASS_ENABLE_MASK   0x0000000000000004
-
-/*   SH_MISC_MEM_CFG_XN_RD_SAME_AS_PI                                   */
-/*   Description:  disables a one clock delay of XN read data           */
-#define SH_MISC_MEM_CFG_XN_RD_SAME_AS_PI_SHFT    3
-#define SH_MISC_MEM_CFG_XN_RD_SAME_AS_PI_MASK    0x0000000000000008
-
-/*   SH_MISC_MEM_CFG_LOW_WRITE_BUFFER_THRESHOLD                         */
-/*   Description:  point at which data writes get higher priority       */
-#define SH_MISC_MEM_CFG_LOW_WRITE_BUFFER_THRESHOLD_SHFT 4
-#define SH_MISC_MEM_CFG_LOW_WRITE_BUFFER_THRESHOLD_MASK 0x00000000000003f0
-
-/*   SH_MISC_MEM_CFG_LOW_VICTIM_BUFFER_THRESHOLD                        */
-/*   Description:  point at which dir cache writes get higher priority  */
-#define SH_MISC_MEM_CFG_LOW_VICTIM_BUFFER_THRESHOLD_SHFT 12
-#define SH_MISC_MEM_CFG_LOW_VICTIM_BUFFER_THRESHOLD_MASK 0x000000000003f000
-
-/*   SH_MISC_MEM_CFG_THROTTLE_CNT                                       */
-/*   Description:  number of clocks between accepting references        */
-#define SH_MISC_MEM_CFG_THROTTLE_CNT_SHFT        20
-#define SH_MISC_MEM_CFG_THROTTLE_CNT_MASK        0x000000000ff00000
-
-/*   SH_MISC_MEM_CFG_DISABLED_READ_TNUMS                                */
-/*   Description:  number of read tnums to take out of circulation      */
-#define SH_MISC_MEM_CFG_DISABLED_READ_TNUMS_SHFT 28
-#define SH_MISC_MEM_CFG_DISABLED_READ_TNUMS_MASK 0x00000001f0000000
-
-/*   SH_MISC_MEM_CFG_DISABLED_WRITE_TNUMS                               */
-/*   Description:  number of write tnums to take out of circulation     */
-#define SH_MISC_MEM_CFG_DISABLED_WRITE_TNUMS_SHFT 36
-#define SH_MISC_MEM_CFG_DISABLED_WRITE_TNUMS_MASK 0x000001f000000000
-
-/*   SH_MISC_MEM_CFG_DISABLED_VICTIMS                                   */
-/*   Description:  number of dir cache victim buffers to take out of c  */
-/*  irculation in each quadrant of the MD                               */
-#define SH_MISC_MEM_CFG_DISABLED_VICTIMS_SHFT    44
-#define SH_MISC_MEM_CFG_DISABLED_VICTIMS_MASK    0x0003f00000000000
-
-/*   SH_MISC_MEM_CFG_ALTERNATE_XN_RP_PLANE                              */
-/*   Description:  enables plane alternating for replies to XN          */
-#define SH_MISC_MEM_CFG_ALTERNATE_XN_RP_PLANE_SHFT 52
-#define SH_MISC_MEM_CFG_ALTERNATE_XN_RP_PLANE_MASK 0x0010000000000000
-
-/* ==================================================================== */
-/*                     Register "SH_PIO_RQ_CRD_CTL"                     */
-/*                  pio_rq Credit Circulation Control                   */
-/* ==================================================================== */
-
-#define SH_PIO_RQ_CRD_CTL                        0x0000000100010068
-#define SH_PIO_RQ_CRD_CTL_MASK                   0x000000000000003f
-#define SH_PIO_RQ_CRD_CTL_INIT                   0x0000000000000002
-
-/*   SH_PIO_RQ_CRD_CTL_DEPTH                                            */
-/*   Description:  Total depth of buffering (in sic packets)            */
-#define SH_PIO_RQ_CRD_CTL_DEPTH_SHFT             0
-#define SH_PIO_RQ_CRD_CTL_DEPTH_MASK             0x000000000000003f
-
-/* ==================================================================== */
-/*                    Register "SH_PI_MD_RQ_CRD_CTL"                    */
-/*                 pi_md_rq Credit Circulation Control                  */
-/* ==================================================================== */
-
-#define SH_PI_MD_RQ_CRD_CTL                      0x0000000100010070
-#define SH_PI_MD_RQ_CRD_CTL_MASK                 0x000000000000003f
-#define SH_PI_MD_RQ_CRD_CTL_INIT                 0x0000000000000008
-
-/*   SH_PI_MD_RQ_CRD_CTL_DEPTH                                          */
-/*   Description:  Total depth of buffering (in sic packets)            */
-#define SH_PI_MD_RQ_CRD_CTL_DEPTH_SHFT           0
-#define SH_PI_MD_RQ_CRD_CTL_DEPTH_MASK           0x000000000000003f
-
-/* ==================================================================== */
-/*                    Register "SH_PI_MD_RP_CRD_CTL"                    */
-/*                 pi_md_rp Credit Circulation Control                  */
-/* ==================================================================== */
-
-#define SH_PI_MD_RP_CRD_CTL                      0x0000000100010078
-#define SH_PI_MD_RP_CRD_CTL_MASK                 0x000000000000003f
-#define SH_PI_MD_RP_CRD_CTL_INIT                 0x0000000000000004
-
-/*   SH_PI_MD_RP_CRD_CTL_DEPTH                                          */
-/*   Description:  Total depth of buffering (in sic packets)            */
-#define SH_PI_MD_RP_CRD_CTL_DEPTH_SHFT           0
-#define SH_PI_MD_RP_CRD_CTL_DEPTH_MASK           0x000000000000003f
-
-/* ==================================================================== */
-/*                    Register "SH_XN_MD_RQ_CRD_CTL"                    */
-/*                 xn_md_rq Credit Circulation Control                  */
-/* ==================================================================== */
-
-#define SH_XN_MD_RQ_CRD_CTL                      0x0000000100010080
-#define SH_XN_MD_RQ_CRD_CTL_MASK                 0x000000000000003f
-#define SH_XN_MD_RQ_CRD_CTL_INIT                 0x0000000000000008
-
-/*   SH_XN_MD_RQ_CRD_CTL_DEPTH                                          */
-/*   Description:  Total depth of buffering (in sic packets)            */
-#define SH_XN_MD_RQ_CRD_CTL_DEPTH_SHFT           0
-#define SH_XN_MD_RQ_CRD_CTL_DEPTH_MASK           0x000000000000003f
-
-/* ==================================================================== */
-/*                    Register "SH_XN_MD_RP_CRD_CTL"                    */
-/*                 xn_md_rp Credit Circulation Control                  */
-/* ==================================================================== */
-
-#define SH_XN_MD_RP_CRD_CTL                      0x0000000100010088
-#define SH_XN_MD_RP_CRD_CTL_MASK                 0x000000000000003f
-#define SH_XN_MD_RP_CRD_CTL_INIT                 0x0000000000000004
-
-/*   SH_XN_MD_RP_CRD_CTL_DEPTH                                          */
-/*   Description:  Total depth of buffering (in sic packets)            */
-#define SH_XN_MD_RP_CRD_CTL_DEPTH_SHFT           0
-#define SH_XN_MD_RP_CRD_CTL_DEPTH_MASK           0x000000000000003f
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG0"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_X_TAG0                                0x0000000100020000
-#define SH_X_TAG0_MASK                           0x00000000000fffff
-#define SH_X_TAG0_INIT                           0x0000000000000000
-
-/*   SH_X_TAG0_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_X_TAG0_TAG_SHFT                       0
-#define SH_X_TAG0_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG1"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_X_TAG1                                0x0000000100020008
-#define SH_X_TAG1_MASK                           0x00000000000fffff
-#define SH_X_TAG1_INIT                           0x0000000000000000
-
-/*   SH_X_TAG1_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_X_TAG1_TAG_SHFT                       0
-#define SH_X_TAG1_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG2"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_X_TAG2                                0x0000000100020010
-#define SH_X_TAG2_MASK                           0x00000000000fffff
-#define SH_X_TAG2_INIT                           0x0000000000000000
-
-/*   SH_X_TAG2_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_X_TAG2_TAG_SHFT                       0
-#define SH_X_TAG2_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG3"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_X_TAG3                                0x0000000100020018
-#define SH_X_TAG3_MASK                           0x00000000000fffff
-#define SH_X_TAG3_INIT                           0x0000000000000000
-
-/*   SH_X_TAG3_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_X_TAG3_TAG_SHFT                       0
-#define SH_X_TAG3_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG4"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_X_TAG4                                0x0000000100020020
-#define SH_X_TAG4_MASK                           0x00000000000fffff
-#define SH_X_TAG4_INIT                           0x0000000000000000
-
-/*   SH_X_TAG4_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_X_TAG4_TAG_SHFT                       0
-#define SH_X_TAG4_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG5"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_X_TAG5                                0x0000000100020028
-#define SH_X_TAG5_MASK                           0x00000000000fffff
-#define SH_X_TAG5_INIT                           0x0000000000000000
-
-/*   SH_X_TAG5_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_X_TAG5_TAG_SHFT                       0
-#define SH_X_TAG5_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG6"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_X_TAG6                                0x0000000100020030
-#define SH_X_TAG6_MASK                           0x00000000000fffff
-#define SH_X_TAG6_INIT                           0x0000000000000000
-
-/*   SH_X_TAG6_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_X_TAG6_TAG_SHFT                       0
-#define SH_X_TAG6_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG7"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_X_TAG7                                0x0000000100020038
-#define SH_X_TAG7_MASK                           0x00000000000fffff
-#define SH_X_TAG7_INIT                           0x0000000000000000
-
-/*   SH_X_TAG7_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_X_TAG7_TAG_SHFT                       0
-#define SH_X_TAG7_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG0"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_Y_TAG0                                0x0000000100020040
-#define SH_Y_TAG0_MASK                           0x00000000000fffff
-#define SH_Y_TAG0_INIT                           0x0000000000000000
-
-/*   SH_Y_TAG0_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_Y_TAG0_TAG_SHFT                       0
-#define SH_Y_TAG0_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG1"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_Y_TAG1                                0x0000000100020048
-#define SH_Y_TAG1_MASK                           0x00000000000fffff
-#define SH_Y_TAG1_INIT                           0x0000000000000000
-
-/*   SH_Y_TAG1_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_Y_TAG1_TAG_SHFT                       0
-#define SH_Y_TAG1_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG2"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_Y_TAG2                                0x0000000100020050
-#define SH_Y_TAG2_MASK                           0x00000000000fffff
-#define SH_Y_TAG2_INIT                           0x0000000000000000
-
-/*   SH_Y_TAG2_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_Y_TAG2_TAG_SHFT                       0
-#define SH_Y_TAG2_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG3"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_Y_TAG3                                0x0000000100020058
-#define SH_Y_TAG3_MASK                           0x00000000000fffff
-#define SH_Y_TAG3_INIT                           0x0000000000000000
-
-/*   SH_Y_TAG3_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_Y_TAG3_TAG_SHFT                       0
-#define SH_Y_TAG3_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG4"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_Y_TAG4                                0x0000000100020060
-#define SH_Y_TAG4_MASK                           0x00000000000fffff
-#define SH_Y_TAG4_INIT                           0x0000000000000000
-
-/*   SH_Y_TAG4_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_Y_TAG4_TAG_SHFT                       0
-#define SH_Y_TAG4_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG5"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_Y_TAG5                                0x0000000100020068
-#define SH_Y_TAG5_MASK                           0x00000000000fffff
-#define SH_Y_TAG5_INIT                           0x0000000000000000
-
-/*   SH_Y_TAG5_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_Y_TAG5_TAG_SHFT                       0
-#define SH_Y_TAG5_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG6"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_Y_TAG6                                0x0000000100020070
-#define SH_Y_TAG6_MASK                           0x00000000000fffff
-#define SH_Y_TAG6_INIT                           0x0000000000000000
-
-/*   SH_Y_TAG6_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_Y_TAG6_TAG_SHFT                       0
-#define SH_Y_TAG6_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG7"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-#define SH_Y_TAG7                                0x0000000100020078
-#define SH_Y_TAG7_MASK                           0x00000000000fffff
-#define SH_Y_TAG7_INIT                           0x0000000000000000
-
-/*   SH_Y_TAG7_TAG                                                      */
-/*   Description:  Valid + Tag Address                                  */
-#define SH_Y_TAG7_TAG_SHFT                       0
-#define SH_Y_TAG7_TAG_MASK                       0x00000000000fffff
-
-/* ==================================================================== */
-/*                      Register "SH_MMRBIST_BASE"                      */
-/*                        mmr/bist base address                         */
-/* ==================================================================== */
-
-#define SH_MMRBIST_BASE                          0x0000000100020080
-#define SH_MMRBIST_BASE_MASK                     0x0003fffffffffff8
-#define SH_MMRBIST_BASE_INIT                     0x0000000000000000
-
-/*   SH_MMRBIST_BASE_DWORD_ADDR                                         */
-/*   Description:  bits 49:3 of the memory address                      */
-#define SH_MMRBIST_BASE_DWORD_ADDR_SHFT          3
-#define SH_MMRBIST_BASE_DWORD_ADDR_MASK          0x0003fffffffffff8
-
-/* ==================================================================== */
-/*                      Register "SH_MMRBIST_CTL"                       */
-/*                          Bist base address                           */
-/* ==================================================================== */
-
-#define SH_MMRBIST_CTL                           0x0000000100020088
-#define SH_MMRBIST_CTL_MASK                      0x0000177f7fffffff
-#define SH_MMRBIST_CTL_INIT                      0x0000000000000000
-
-/*   SH_MMRBIST_CTL_BLOCK_LENGTH                                        */
-/*   Description:  number of dwords in operation                        */
-#define SH_MMRBIST_CTL_BLOCK_LENGTH_SHFT         0
-#define SH_MMRBIST_CTL_BLOCK_LENGTH_MASK         0x000000007fffffff
-
-/*   SH_MMRBIST_CTL_CMD                                                 */
-/*   Description:  mmr/bist function                                    */
-#define SH_MMRBIST_CTL_CMD_SHFT                  32
-#define SH_MMRBIST_CTL_CMD_MASK                  0x0000007f00000000
-
-/*   SH_MMRBIST_CTL_IN_PROGRESS                                         */
-/*   Description:  writing a 1 starts operation, hardware clears on co  */
-/*  mpletion                                                            */
-#define SH_MMRBIST_CTL_IN_PROGRESS_SHFT          40
-#define SH_MMRBIST_CTL_IN_PROGRESS_MASK          0x0000010000000000
-
-/*   SH_MMRBIST_CTL_FAIL                                                */
-/*   Description:  mmr/bist had a data or address error                 */
-#define SH_MMRBIST_CTL_FAIL_SHFT                 41
-#define SH_MMRBIST_CTL_FAIL_MASK                 0x0000020000000000
-
-/*   SH_MMRBIST_CTL_MEM_IDLE                                            */
-/*   Description:  all memory activity is complete                      */
-#define SH_MMRBIST_CTL_MEM_IDLE_SHFT             42
-#define SH_MMRBIST_CTL_MEM_IDLE_MASK             0x0000040000000000
-
-/*   SH_MMRBIST_CTL_RESET_STATE                                         */
-/*   Description:  writing a 1 resets mmrbist hardware, hardware clear  */
-/*  s on completion                                                     */
-#define SH_MMRBIST_CTL_RESET_STATE_SHFT          44
-#define SH_MMRBIST_CTL_RESET_STATE_MASK          0x0000100000000000
-
-/* ==================================================================== */
-/*                    Register "SH_MD_DBUG_DATA_CFG"                    */
-/*                configuration for md debug data muxes                 */
-/* ==================================================================== */
-
-#define SH_MD_DBUG_DATA_CFG                      0x0000000100020100
-#define SH_MD_DBUG_DATA_CFG_MASK                 0x7777777777777777
-#define SH_MD_DBUG_DATA_CFG_INIT                 0x0000000000000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE0_CHIPLET                                */
-/*   Description:  selects which md chiplet drives nibble0              */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE0_CHIPLET_SHFT 0
-#define SH_MD_DBUG_DATA_CFG_NIBBLE0_CHIPLET_MASK 0x0000000000000007
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE0_NIBBLE                                 */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE0_NIBBLE_SHFT  4
-#define SH_MD_DBUG_DATA_CFG_NIBBLE0_NIBBLE_MASK  0x0000000000000070
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE1_CHIPLET                                */
-/*   Description:  selects which md chiplet drives nibble1              */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE1_CHIPLET_SHFT 8
-#define SH_MD_DBUG_DATA_CFG_NIBBLE1_CHIPLET_MASK 0x0000000000000700
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE1_NIBBLE                                 */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE1_NIBBLE_SHFT  12
-#define SH_MD_DBUG_DATA_CFG_NIBBLE1_NIBBLE_MASK  0x0000000000007000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE2_CHIPLET                                */
-/*   Description:  selects which md chiplet drives nibble2              */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE2_CHIPLET_SHFT 16
-#define SH_MD_DBUG_DATA_CFG_NIBBLE2_CHIPLET_MASK 0x0000000000070000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE2_NIBBLE                                 */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE2_NIBBLE_SHFT  20
-#define SH_MD_DBUG_DATA_CFG_NIBBLE2_NIBBLE_MASK  0x0000000000700000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE3_CHIPLET                                */
-/*   Description:  selects which md chiplet drives nibble3              */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE3_CHIPLET_SHFT 24
-#define SH_MD_DBUG_DATA_CFG_NIBBLE3_CHIPLET_MASK 0x0000000007000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE3_NIBBLE                                 */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE3_NIBBLE_SHFT  28
-#define SH_MD_DBUG_DATA_CFG_NIBBLE3_NIBBLE_MASK  0x0000000070000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE4_CHIPLET                                */
-/*   Description:  selects which md chiplet drives nibble4              */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE4_CHIPLET_SHFT 32
-#define SH_MD_DBUG_DATA_CFG_NIBBLE4_CHIPLET_MASK 0x0000000700000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE4_NIBBLE                                 */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE4_NIBBLE_SHFT  36
-#define SH_MD_DBUG_DATA_CFG_NIBBLE4_NIBBLE_MASK  0x0000007000000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE5_CHIPLET                                */
-/*   Description:  selects which md chiplet drives nibble5              */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE5_CHIPLET_SHFT 40
-#define SH_MD_DBUG_DATA_CFG_NIBBLE5_CHIPLET_MASK 0x0000070000000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE5_NIBBLE                                 */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE5_NIBBLE_SHFT  44
-#define SH_MD_DBUG_DATA_CFG_NIBBLE5_NIBBLE_MASK  0x0000700000000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE6_CHIPLET                                */
-/*   Description:  selects which md chiplet drives nibble6              */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE6_CHIPLET_SHFT 48
-#define SH_MD_DBUG_DATA_CFG_NIBBLE6_CHIPLET_MASK 0x0007000000000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE6_NIBBLE                                 */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE6_NIBBLE_SHFT  52
-#define SH_MD_DBUG_DATA_CFG_NIBBLE6_NIBBLE_MASK  0x0070000000000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE7_CHIPLET                                */
-/*   Description:  selects which md chiplet drives nibble7              */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE7_CHIPLET_SHFT 56
-#define SH_MD_DBUG_DATA_CFG_NIBBLE7_CHIPLET_MASK 0x0700000000000000
-
-/*   SH_MD_DBUG_DATA_CFG_NIBBLE7_NIBBLE                                 */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_DATA_CFG_NIBBLE7_NIBBLE_SHFT  60
-#define SH_MD_DBUG_DATA_CFG_NIBBLE7_NIBBLE_MASK  0x7000000000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DBUG_TRIGGER_CFG"                   */
-/*                 configuration for md debug triggers                  */
-/* ==================================================================== */
-
-#define SH_MD_DBUG_TRIGGER_CFG                   0x0000000100020108
-#define SH_MD_DBUG_TRIGGER_CFG_MASK              0xf777777777777777
-#define SH_MD_DBUG_TRIGGER_CFG_INIT              0x0000000000000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE0_CHIPLET                             */
-/*   Description:  selects which md chiplet drives nibble0              */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE0_CHIPLET_SHFT 0
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE0_CHIPLET_MASK 0x0000000000000007
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE0_NIBBLE                              */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE0_NIBBLE_SHFT 4
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE0_NIBBLE_MASK 0x0000000000000070
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE1_CHIPLET                             */
-/*   Description:  selects which md chiplet drives nibble1              */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE1_CHIPLET_SHFT 8
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE1_CHIPLET_MASK 0x0000000000000700
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE1_NIBBLE                              */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE1_NIBBLE_SHFT 12
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE1_NIBBLE_MASK 0x0000000000007000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE2_CHIPLET                             */
-/*   Description:  selects which md chiplet drives nibble2              */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE2_CHIPLET_SHFT 16
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE2_CHIPLET_MASK 0x0000000000070000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE2_NIBBLE                              */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE2_NIBBLE_SHFT 20
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE2_NIBBLE_MASK 0x0000000000700000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE3_CHIPLET                             */
-/*   Description:  selects which md chiplet drives nibble3              */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE3_CHIPLET_SHFT 24
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE3_CHIPLET_MASK 0x0000000007000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE3_NIBBLE                              */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE3_NIBBLE_SHFT 28
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE3_NIBBLE_MASK 0x0000000070000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE4_CHIPLET                             */
-/*   Description:  selects which md chiplet drives nibble4              */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE4_CHIPLET_SHFT 32
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE4_CHIPLET_MASK 0x0000000700000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE4_NIBBLE                              */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE4_NIBBLE_SHFT 36
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE4_NIBBLE_MASK 0x0000007000000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE5_CHIPLET                             */
-/*   Description:  selects which md chiplet drives nibble5              */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE5_CHIPLET_SHFT 40
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE5_CHIPLET_MASK 0x0000070000000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE5_NIBBLE                              */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE5_NIBBLE_SHFT 44
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE5_NIBBLE_MASK 0x0000700000000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE6_CHIPLET                             */
-/*   Description:  selects which md chiplet drives nibble6              */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE6_CHIPLET_SHFT 48
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE6_CHIPLET_MASK 0x0007000000000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE6_NIBBLE                              */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE6_NIBBLE_SHFT 52
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE6_NIBBLE_MASK 0x0070000000000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE7_CHIPLET                             */
-/*   Description:  selects which md chiplet drives nibble7              */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE7_CHIPLET_SHFT 56
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE7_CHIPLET_MASK 0x0700000000000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_NIBBLE7_NIBBLE                              */
-/*   Description:  selects which nibble from selected chiplet drives n  */
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE7_NIBBLE_SHFT 60
-#define SH_MD_DBUG_TRIGGER_CFG_NIBBLE7_NIBBLE_MASK 0x7000000000000000
-
-/*   SH_MD_DBUG_TRIGGER_CFG_ENABLE                                      */
-/*   Description:  enables triggering on pattern match                  */
-#define SH_MD_DBUG_TRIGGER_CFG_ENABLE_SHFT       63
-#define SH_MD_DBUG_TRIGGER_CFG_ENABLE_MASK       0x8000000000000000
-
-/* ==================================================================== */
-/*                    Register "SH_MD_DBUG_COMPARE"                     */
-/*                  md debug compare pattern and mask                   */
-/* ==================================================================== */
-
-#define SH_MD_DBUG_COMPARE                       0x0000000100020110
-#define SH_MD_DBUG_COMPARE_MASK                  0xffffffffffffffff
-#define SH_MD_DBUG_COMPARE_INIT                  0x0000000000000000
-
-/*   SH_MD_DBUG_COMPARE_PATTERN                                         */
-/*   Description:  pattern against which to compare dbug data for trig  */
-#define SH_MD_DBUG_COMPARE_PATTERN_SHFT          0
-#define SH_MD_DBUG_COMPARE_PATTERN_MASK          0x00000000ffffffff
-
-/*   SH_MD_DBUG_COMPARE_MASK                                            */
-/*   Description:  bits to include in compare of dbug data for trigger  */
-#define SH_MD_DBUG_COMPARE_MASK_SHFT             32
-#define SH_MD_DBUG_COMPARE_MASK_MASK             0xffffffff00000000
-
-/* ==================================================================== */
-/*                     Register "SH_X_MOD_DBUG_SEL"                     */
-/*                         MD acx debug select                          */
-/* ==================================================================== */
-
-#define SH_X_MOD_DBUG_SEL                        0x0000000100020118
-#define SH_X_MOD_DBUG_SEL_MASK                   0x03ffffffffffffff
-#define SH_X_MOD_DBUG_SEL_INIT                   0x0000000000000000
-
-/*   SH_X_MOD_DBUG_SEL_TAG_SEL                                          */
-/*   Description:  tagmgr select                                        */
-#define SH_X_MOD_DBUG_SEL_TAG_SEL_SHFT           0
-#define SH_X_MOD_DBUG_SEL_TAG_SEL_MASK           0x00000000000000ff
-
-/*   SH_X_MOD_DBUG_SEL_WBQ_SEL                                          */
-/*   Description:  wbqtg select                                         */
-#define SH_X_MOD_DBUG_SEL_WBQ_SEL_SHFT           8
-#define SH_X_MOD_DBUG_SEL_WBQ_SEL_MASK           0x000000000000ff00
-
-/*   SH_X_MOD_DBUG_SEL_ARB_SEL                                          */
-/*   Description:  arbque select                                        */
-#define SH_X_MOD_DBUG_SEL_ARB_SEL_SHFT           16
-#define SH_X_MOD_DBUG_SEL_ARB_SEL_MASK           0x0000000000ff0000
-
-/*   SH_X_MOD_DBUG_SEL_ATL_SEL                                          */
-/*   Description:  aintl select                                         */
-#define SH_X_MOD_DBUG_SEL_ATL_SEL_SHFT           24
-#define SH_X_MOD_DBUG_SEL_ATL_SEL_MASK           0x00000007ff000000
-
-/*   SH_X_MOD_DBUG_SEL_ATR_SEL                                          */
-/*   Description:  aintr select                                         */
-#define SH_X_MOD_DBUG_SEL_ATR_SEL_SHFT           35
-#define SH_X_MOD_DBUG_SEL_ATR_SEL_MASK           0x00003ff800000000
-
-/*   SH_X_MOD_DBUG_SEL_DQL_SEL                                          */
-/*   Description:  dqctr select                                         */
-#define SH_X_MOD_DBUG_SEL_DQL_SEL_SHFT           46
-#define SH_X_MOD_DBUG_SEL_DQL_SEL_MASK           0x000fc00000000000
-
-/*   SH_X_MOD_DBUG_SEL_DQR_SEL                                          */
-/*   Description:  dqctl select                                         */
-#define SH_X_MOD_DBUG_SEL_DQR_SEL_SHFT           52
-#define SH_X_MOD_DBUG_SEL_DQR_SEL_MASK           0x03f0000000000000
-
-/* ==================================================================== */
-/*                       Register "SH_X_DBUG_SEL"                       */
-/*                         MD acx debug select                          */
-/* ==================================================================== */
-
-#define SH_X_DBUG_SEL                            0x0000000100020120
-#define SH_X_DBUG_SEL_MASK                       0x0000000000ffffff
-#define SH_X_DBUG_SEL_INIT                       0x0000000000000000
-
-/*   SH_X_DBUG_SEL_DBG_SEL                                              */
-/*   Description:  debug select                                         */
-#define SH_X_DBUG_SEL_DBG_SEL_SHFT               0
-#define SH_X_DBUG_SEL_DBG_SEL_MASK               0x0000000000ffffff
-
-/* ==================================================================== */
-/*                      Register "SH_X_LADDR_CMP"                       */
-/*                        MD acx address compare                        */
-/* ==================================================================== */
-
-#define SH_X_LADDR_CMP                           0x0000000100020128
-#define SH_X_LADDR_CMP_MASK                      0x0fffffff0fffffff
-#define SH_X_LADDR_CMP_INIT                      0x0000000000000000
-
-/*   SH_X_LADDR_CMP_CMP_VAL                                             */
-/*   Description:  Compare value                                        */
-#define SH_X_LADDR_CMP_CMP_VAL_SHFT              0
-#define SH_X_LADDR_CMP_CMP_VAL_MASK              0x000000000fffffff
-
-/*   SH_X_LADDR_CMP_MASK_VAL                                            */
-/*   Description:  Mask value                                           */
-#define SH_X_LADDR_CMP_MASK_VAL_SHFT             32
-#define SH_X_LADDR_CMP_MASK_VAL_MASK             0x0fffffff00000000
-
-/* ==================================================================== */
-/*                      Register "SH_X_RADDR_CMP"                       */
-/*                        MD acx address compare                        */
-/* ==================================================================== */
-
-#define SH_X_RADDR_CMP                           0x0000000100020130
-#define SH_X_RADDR_CMP_MASK                      0x0fffffff0fffffff
-#define SH_X_RADDR_CMP_INIT                      0x0000000000000000
-
-/*   SH_X_RADDR_CMP_CMP_VAL                                             */
-/*   Description:  Compare value                                        */
-#define SH_X_RADDR_CMP_CMP_VAL_SHFT              0
-#define SH_X_RADDR_CMP_CMP_VAL_MASK              0x000000000fffffff
-
-/*   SH_X_RADDR_CMP_MASK_VAL                                            */
-/*   Description:  Mask value                                           */
-#define SH_X_RADDR_CMP_MASK_VAL_SHFT             32
-#define SH_X_RADDR_CMP_MASK_VAL_MASK             0x0fffffff00000000
-
-/* ==================================================================== */
-/*                       Register "SH_X_TAG_CMP"                        */
-/*                        MD acx tagmgr compare                         */
-/* ==================================================================== */
-
-#define SH_X_TAG_CMP                             0x0000000100020138
-#define SH_X_TAG_CMP_MASK                        0x007fffffffffffff
-#define SH_X_TAG_CMP_INIT                        0x0000000000000000
-
-/*   SH_X_TAG_CMP_CMD                                                   */
-/*   Description:  Command compare value                                */
-#define SH_X_TAG_CMP_CMD_SHFT                    0
-#define SH_X_TAG_CMP_CMD_MASK                    0x00000000000000ff
-
-/*   SH_X_TAG_CMP_ADDR                                                  */
-/*   Description:  Address compare value                                */
-#define SH_X_TAG_CMP_ADDR_SHFT                   8
-#define SH_X_TAG_CMP_ADDR_MASK                   0x000001ffffffff00
-
-/*   SH_X_TAG_CMP_SRC                                                   */
-/*   Description:  Source compare value                                 */
-#define SH_X_TAG_CMP_SRC_SHFT                    41
-#define SH_X_TAG_CMP_SRC_MASK                    0x007ffe0000000000
-
-/* ==================================================================== */
-/*                       Register "SH_X_TAG_MASK"                       */
-/*                          MD acx tagmgr mask                          */
-/* ==================================================================== */
-
-#define SH_X_TAG_MASK                            0x0000000100020140
-#define SH_X_TAG_MASK_MASK                       0x007fffffffffffff
-#define SH_X_TAG_MASK_INIT                       0x0000000000000000
-
-/*   SH_X_TAG_MASK_CMD                                                  */
-/*   Description:  Command compare value                                */
-#define SH_X_TAG_MASK_CMD_SHFT                   0
-#define SH_X_TAG_MASK_CMD_MASK                   0x00000000000000ff
-
-/*   SH_X_TAG_MASK_ADDR                                                 */
-/*   Description:  Address compare value                                */
-#define SH_X_TAG_MASK_ADDR_SHFT                  8
-#define SH_X_TAG_MASK_ADDR_MASK                  0x000001ffffffff00
-
-/*   SH_X_TAG_MASK_SRC                                                  */
-/*   Description:  Source compare value                                 */
-#define SH_X_TAG_MASK_SRC_SHFT                   41
-#define SH_X_TAG_MASK_SRC_MASK                   0x007ffe0000000000
-
-/* ==================================================================== */
-/*                     Register "SH_Y_MOD_DBUG_SEL"                     */
-/*                         MD acy debug select                          */
-/* ==================================================================== */
-
-#define SH_Y_MOD_DBUG_SEL                        0x0000000100020148
-#define SH_Y_MOD_DBUG_SEL_MASK                   0x03ffffffffffffff
-#define SH_Y_MOD_DBUG_SEL_INIT                   0x0000000000000000
-
-/*   SH_Y_MOD_DBUG_SEL_TAG_SEL                                          */
-/*   Description:  tagmgr select                                        */
-#define SH_Y_MOD_DBUG_SEL_TAG_SEL_SHFT           0
-#define SH_Y_MOD_DBUG_SEL_TAG_SEL_MASK           0x00000000000000ff
-
-/*   SH_Y_MOD_DBUG_SEL_WBQ_SEL                                          */
-/*   Description:  wbqtg select                                         */
-#define SH_Y_MOD_DBUG_SEL_WBQ_SEL_SHFT           8
-#define SH_Y_MOD_DBUG_SEL_WBQ_SEL_MASK           0x000000000000ff00
-
-/*   SH_Y_MOD_DBUG_SEL_ARB_SEL                                          */
-/*   Description:  arbque select                                        */
-#define SH_Y_MOD_DBUG_SEL_ARB_SEL_SHFT           16
-#define SH_Y_MOD_DBUG_SEL_ARB_SEL_MASK           0x0000000000ff0000
-
-/*   SH_Y_MOD_DBUG_SEL_ATL_SEL                                          */
-/*   Description:  aintl select                                         */
-#define SH_Y_MOD_DBUG_SEL_ATL_SEL_SHFT           24
-#define SH_Y_MOD_DBUG_SEL_ATL_SEL_MASK           0x00000007ff000000
-
-/*   SH_Y_MOD_DBUG_SEL_ATR_SEL                                          */
-/*   Description:  aintr select                                         */
-#define SH_Y_MOD_DBUG_SEL_ATR_SEL_SHFT           35
-#define SH_Y_MOD_DBUG_SEL_ATR_SEL_MASK           0x00003ff800000000
-
-/*   SH_Y_MOD_DBUG_SEL_DQL_SEL                                          */
-/*   Description:  dqctr select                                         */
-#define SH_Y_MOD_DBUG_SEL_DQL_SEL_SHFT           46
-#define SH_Y_MOD_DBUG_SEL_DQL_SEL_MASK           0x000fc00000000000
-
-/*   SH_Y_MOD_DBUG_SEL_DQR_SEL                                          */
-/*   Description:  dqctl select                                         */
-#define SH_Y_MOD_DBUG_SEL_DQR_SEL_SHFT           52
-#define SH_Y_MOD_DBUG_SEL_DQR_SEL_MASK           0x03f0000000000000
-
-/* ==================================================================== */
-/*                       Register "SH_Y_DBUG_SEL"                       */
-/*                         MD acy debug select                          */
-/* ==================================================================== */
-
-#define SH_Y_DBUG_SEL                            0x0000000100020150
-#define SH_Y_DBUG_SEL_MASK                       0x0000000000ffffff
-#define SH_Y_DBUG_SEL_INIT                       0x0000000000000000
-
-/*   SH_Y_DBUG_SEL_DBG_SEL                                              */
-/*   Description:  debug select                                         */
-#define SH_Y_DBUG_SEL_DBG_SEL_SHFT               0
-#define SH_Y_DBUG_SEL_DBG_SEL_MASK               0x0000000000ffffff
-
-/* ==================================================================== */
-/*                      Register "SH_Y_LADDR_CMP"                       */
-/*                        MD acy address compare                        */
-/* ==================================================================== */
-
-#define SH_Y_LADDR_CMP                           0x0000000100020158
-#define SH_Y_LADDR_CMP_MASK                      0x0fffffff0fffffff
-#define SH_Y_LADDR_CMP_INIT                      0x0000000000000000
-
-/*   SH_Y_LADDR_CMP_CMP_VAL                                             */
-/*   Description:  Compare value                                        */
-#define SH_Y_LADDR_CMP_CMP_VAL_SHFT              0
-#define SH_Y_LADDR_CMP_CMP_VAL_MASK              0x000000000fffffff
-
-/*   SH_Y_LADDR_CMP_MASK_VAL                                            */
-/*   Description:  Mask value                                           */
-#define SH_Y_LADDR_CMP_MASK_VAL_SHFT             32
-#define SH_Y_LADDR_CMP_MASK_VAL_MASK             0x0fffffff00000000
-
-/* ==================================================================== */
-/*                      Register "SH_Y_RADDR_CMP"                       */
-/*                        MD acy address compare                        */
-/* ==================================================================== */
-
-#define SH_Y_RADDR_CMP                           0x0000000100020160
-#define SH_Y_RADDR_CMP_MASK                      0x0fffffff0fffffff
-#define SH_Y_RADDR_CMP_INIT                      0x0000000000000000
-
-/*   SH_Y_RADDR_CMP_CMP_VAL                                             */
-/*   Description:  Compare value                                        */
-#define SH_Y_RADDR_CMP_CMP_VAL_SHFT              0
-#define SH_Y_RADDR_CMP_CMP_VAL_MASK              0x000000000fffffff
-
-/*   SH_Y_RADDR_CMP_MASK_VAL                                            */
-/*   Description:  Mask value                                           */
-#define SH_Y_RADDR_CMP_MASK_VAL_SHFT             32
-#define SH_Y_RADDR_CMP_MASK_VAL_MASK             0x0fffffff00000000
-
-/* ==================================================================== */
-/*                       Register "SH_Y_TAG_CMP"                        */
-/*                        MD acy tagmgr compare                         */
-/* ==================================================================== */
-
-#define SH_Y_TAG_CMP                             0x0000000100020168
-#define SH_Y_TAG_CMP_MASK                        0x007fffffffffffff
-#define SH_Y_TAG_CMP_INIT                        0x0000000000000000
-
-/*   SH_Y_TAG_CMP_CMD                                                   */
-/*   Description:  Command compare value                                */
-#define SH_Y_TAG_CMP_CMD_SHFT                    0
-#define SH_Y_TAG_CMP_CMD_MASK                    0x00000000000000ff
-
-/*   SH_Y_TAG_CMP_ADDR                                                  */
-/*   Description:  Address compare value                                */
-#define SH_Y_TAG_CMP_ADDR_SHFT                   8
-#define SH_Y_TAG_CMP_ADDR_MASK                   0x000001ffffffff00
-
-/*   SH_Y_TAG_CMP_SRC                                                   */
-/*   Description:  Source compare value                                 */
-#define SH_Y_TAG_CMP_SRC_SHFT                    41
-#define SH_Y_TAG_CMP_SRC_MASK                    0x007ffe0000000000
-
-/* ==================================================================== */
-/*                       Register "SH_Y_TAG_MASK"                       */
-/*                          MD acy tagmgr mask                          */
-/* ==================================================================== */
-
-#define SH_Y_TAG_MASK                            0x0000000100020170
-#define SH_Y_TAG_MASK_MASK                       0x007fffffffffffff
-#define SH_Y_TAG_MASK_INIT                       0x0000000000000000
-
-/*   SH_Y_TAG_MASK_CMD                                                  */
-/*   Description:  Command compare value                                */
-#define SH_Y_TAG_MASK_CMD_SHFT                   0
-#define SH_Y_TAG_MASK_CMD_MASK                   0x00000000000000ff
-
-/*   SH_Y_TAG_MASK_ADDR                                                 */
-/*   Description:  Address compare value                                */
-#define SH_Y_TAG_MASK_ADDR_SHFT                  8
-#define SH_Y_TAG_MASK_ADDR_MASK                  0x000001ffffffff00
-
-/*   SH_Y_TAG_MASK_SRC                                                  */
-/*   Description:  Source compare value                                 */
-#define SH_Y_TAG_MASK_SRC_SHFT                   41
-#define SH_Y_TAG_MASK_SRC_MASK                   0x007ffe0000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_JNR_DBUG_DATA_CFG"                  */
-/*              configuration for md jnr debug data muxes               */
-/* ==================================================================== */
-
-#define SH_MD_JNR_DBUG_DATA_CFG                  0x0000000100020178
-#define SH_MD_JNR_DBUG_DATA_CFG_MASK             0x0000000077777777
-#define SH_MD_JNR_DBUG_DATA_CFG_INIT             0x0000000000000000
-
-/*   SH_MD_JNR_DBUG_DATA_CFG_NIBBLE0_SEL                                */
-/*   Description:  selects which nibble drives nibble0                  */
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE0_SEL_SHFT 0
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE0_SEL_MASK 0x0000000000000007
-
-/*   SH_MD_JNR_DBUG_DATA_CFG_NIBBLE1_SEL                                */
-/*   Description:  selects which nibble drives nibble1                  */
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE1_SEL_SHFT 4
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE1_SEL_MASK 0x0000000000000070
-
-/*   SH_MD_JNR_DBUG_DATA_CFG_NIBBLE2_SEL                                */
-/*   Description:  selects which nibble drives nibble2                  */
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE2_SEL_SHFT 8
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE2_SEL_MASK 0x0000000000000700
-
-/*   SH_MD_JNR_DBUG_DATA_CFG_NIBBLE3_SEL                                */
-/*   Description:  selects which nibble drives nibble3                  */
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE3_SEL_SHFT 12
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE3_SEL_MASK 0x0000000000007000
-
-/*   SH_MD_JNR_DBUG_DATA_CFG_NIBBLE4_SEL                                */
-/*   Description:  selects which nibble drives nibble4                  */
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE4_SEL_SHFT 16
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE4_SEL_MASK 0x0000000000070000
-
-/*   SH_MD_JNR_DBUG_DATA_CFG_NIBBLE5_SEL                                */
-/*   Description:  selects which nibble drives nibble5                  */
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE5_SEL_SHFT 20
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE5_SEL_MASK 0x0000000000700000
-
-/*   SH_MD_JNR_DBUG_DATA_CFG_NIBBLE6_SEL                                */
-/*   Description:  selects which nibble drives nibble6                  */
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE6_SEL_SHFT 24
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE6_SEL_MASK 0x0000000007000000
-
-/*   SH_MD_JNR_DBUG_DATA_CFG_NIBBLE7_SEL                                */
-/*   Description:  selects which nibble drives nibble7                  */
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE7_SEL_SHFT 28
-#define SH_MD_JNR_DBUG_DATA_CFG_NIBBLE7_SEL_MASK 0x0000000070000000
-
-/* ==================================================================== */
-/*                     Register "SH_MD_LAST_CREDIT"                     */
-/*                 captures last credit values on reset                 */
-/* ==================================================================== */
-
-#define SH_MD_LAST_CREDIT                        0x0000000100020180
-#define SH_MD_LAST_CREDIT_MASK                   0x0000003f3f3f3f3f
-#define SH_MD_LAST_CREDIT_INIT                   0x0000000000000000
-
-/*   SH_MD_LAST_CREDIT_RQ_TO_PI                                         */
-/*   Description:  capture of request credits to pi                     */
-#define SH_MD_LAST_CREDIT_RQ_TO_PI_SHFT          0
-#define SH_MD_LAST_CREDIT_RQ_TO_PI_MASK          0x000000000000003f
-
-/*   SH_MD_LAST_CREDIT_RP_TO_PI                                         */
-/*   Description:  capture of reply credits to pi                       */
-#define SH_MD_LAST_CREDIT_RP_TO_PI_SHFT          8
-#define SH_MD_LAST_CREDIT_RP_TO_PI_MASK          0x0000000000003f00
-
-/*   SH_MD_LAST_CREDIT_RQ_TO_XN                                         */
-/*   Description:  capture of request credits to xn                     */
-#define SH_MD_LAST_CREDIT_RQ_TO_XN_SHFT          16
-#define SH_MD_LAST_CREDIT_RQ_TO_XN_MASK          0x00000000003f0000
-
-/*   SH_MD_LAST_CREDIT_RP_TO_XN                                         */
-/*   Description:  capture of reply credits to xn                       */
-#define SH_MD_LAST_CREDIT_RP_TO_XN_SHFT          24
-#define SH_MD_LAST_CREDIT_RP_TO_XN_MASK          0x000000003f000000
-
-/*   SH_MD_LAST_CREDIT_TO_LB                                            */
-/*   Description:  capture of credits to pi                             */
-#define SH_MD_LAST_CREDIT_TO_LB_SHFT             32
-#define SH_MD_LAST_CREDIT_TO_LB_MASK             0x0000003f00000000
-
-/* ==================================================================== */
-/*                    Register "SH_MEM_CAPTURE_ADDR"                    */
-/*                   Address capture address register                   */
-/* ==================================================================== */
-
-#define SH_MEM_CAPTURE_ADDR                      0x0000000100020300
-#define SH_MEM_CAPTURE_ADDR_MASK                 0x00000ffffffffff8
-#define SH_MEM_CAPTURE_ADDR_INIT                 0x0000000000000000
-
-/*   SH_MEM_CAPTURE_ADDR_ADDR                                           */
-/*   Description:  upper bits of address                                */
-#define SH_MEM_CAPTURE_ADDR_ADDR_SHFT            3
-#define SH_MEM_CAPTURE_ADDR_ADDR_MASK            0x0000000ffffffff8
-
-/*   SH_MEM_CAPTURE_ADDR_CMD                                            */
-/*   Description:  command of reference                                 */
-#define SH_MEM_CAPTURE_ADDR_CMD_SHFT             36
-#define SH_MEM_CAPTURE_ADDR_CMD_MASK             0x00000ff000000000
-
-/* ==================================================================== */
-/*                    Register "SH_MEM_CAPTURE_MASK"                    */
-/*                    Address capture mask register                     */
-/* ==================================================================== */
-
-#define SH_MEM_CAPTURE_MASK                      0x0000000100020308
-#define SH_MEM_CAPTURE_MASK_MASK                 0x00003ffffffffff8
-#define SH_MEM_CAPTURE_MASK_INIT                 0x0000000000000000
-
-/*   SH_MEM_CAPTURE_MASK_ADDR                                           */
-/*   Description:  upper bits of address                                */
-#define SH_MEM_CAPTURE_MASK_ADDR_SHFT            3
-#define SH_MEM_CAPTURE_MASK_ADDR_MASK            0x0000000ffffffff8
-
-/*   SH_MEM_CAPTURE_MASK_CMD                                            */
-/*   Description:  command of reference                                 */
-#define SH_MEM_CAPTURE_MASK_CMD_SHFT             36
-#define SH_MEM_CAPTURE_MASK_CMD_MASK             0x00000ff000000000
-
-/*   SH_MEM_CAPTURE_MASK_ENABLE_LOCAL                                   */
-/*   Description:  capture references originating locally               */
-#define SH_MEM_CAPTURE_MASK_ENABLE_LOCAL_SHFT    44
-#define SH_MEM_CAPTURE_MASK_ENABLE_LOCAL_MASK    0x0000100000000000
-
-/*   SH_MEM_CAPTURE_MASK_ENABLE_REMOTE                                  */
-/*   Description:  capture references originating remotely              */
-#define SH_MEM_CAPTURE_MASK_ENABLE_REMOTE_SHFT   45
-#define SH_MEM_CAPTURE_MASK_ENABLE_REMOTE_MASK   0x0000200000000000
-
-/* ==================================================================== */
-/*                    Register "SH_MEM_CAPTURE_HDR"                     */
-/*                   Address capture header register                    */
-/* ==================================================================== */
-
-#define SH_MEM_CAPTURE_HDR                       0x0000000100020310
-#define SH_MEM_CAPTURE_HDR_MASK                  0xfffffffffffffff8
-#define SH_MEM_CAPTURE_HDR_INIT                  0x0000000000000000
-
-/*   SH_MEM_CAPTURE_HDR_ADDR                                            */
-/*   Description:  upper bits of reference address                      */
-#define SH_MEM_CAPTURE_HDR_ADDR_SHFT             3
-#define SH_MEM_CAPTURE_HDR_ADDR_MASK             0x0000000ffffffff8
-
-/*   SH_MEM_CAPTURE_HDR_CMD                                             */
-/*   Description:  command of reference                                 */
-#define SH_MEM_CAPTURE_HDR_CMD_SHFT              36
-#define SH_MEM_CAPTURE_HDR_CMD_MASK              0x00000ff000000000
-
-/*   SH_MEM_CAPTURE_HDR_SRC                                             */
-/*   Description:  source node of reference                             */
-#define SH_MEM_CAPTURE_HDR_SRC_SHFT              44
-#define SH_MEM_CAPTURE_HDR_SRC_MASK              0x03fff00000000000
-
-/*   SH_MEM_CAPTURE_HDR_CNTR                                            */
-/*   Description:  increments on every capture                          */
-#define SH_MEM_CAPTURE_HDR_CNTR_SHFT             58
-#define SH_MEM_CAPTURE_HDR_CNTR_MASK             0xfc00000000000000
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQLP_MMR_DIR_CONFIG"                 */
-/*                     DQ directory config register                     */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_CONFIG                0x0000000100030000
-#define SH_MD_DQLP_MMR_DIR_CONFIG_MASK           0x000000000000001f
-#define SH_MD_DQLP_MMR_DIR_CONFIG_INIT           0x0000000000000010
-
-/*   SH_MD_DQLP_MMR_DIR_CONFIG_SYS_SIZE                                 */
-/*   Description:  system size code                                     */
-#define SH_MD_DQLP_MMR_DIR_CONFIG_SYS_SIZE_SHFT  0
-#define SH_MD_DQLP_MMR_DIR_CONFIG_SYS_SIZE_MASK  0x0000000000000007
-
-/*   SH_MD_DQLP_MMR_DIR_CONFIG_EN_DIRECC                                */
-/*   Description:  enable directory ecc correction                      */
-#define SH_MD_DQLP_MMR_DIR_CONFIG_EN_DIRECC_SHFT 3
-#define SH_MD_DQLP_MMR_DIR_CONFIG_EN_DIRECC_MASK 0x0000000000000008
-
-/*   SH_MD_DQLP_MMR_DIR_CONFIG_EN_DIRPOIS                               */
-/*   Description:  enable local poisoning for dir table fall-through    */
-#define SH_MD_DQLP_MMR_DIR_CONFIG_EN_DIRPOIS_SHFT 4
-#define SH_MD_DQLP_MMR_DIR_CONFIG_EN_DIRPOIS_MASK 0x0000000000000010
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRESVEC0"                */
-/*                      node [63:0] presence bits                       */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRESVEC0              0x0000000100030100
-#define SH_MD_DQLP_MMR_DIR_PRESVEC0_MASK         0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_PRESVEC0_INIT         0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRESVEC0_VEC                                    */
-/*   Description:  node presence bits, 1=present                        */
-#define SH_MD_DQLP_MMR_DIR_PRESVEC0_VEC_SHFT     0
-#define SH_MD_DQLP_MMR_DIR_PRESVEC0_VEC_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRESVEC1"                */
-/*                     node [127:64] presence bits                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRESVEC1              0x0000000100030110
-#define SH_MD_DQLP_MMR_DIR_PRESVEC1_MASK         0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_PRESVEC1_INIT         0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRESVEC1_VEC                                    */
-/*   Description:  node presence bits, 1=present                        */
-#define SH_MD_DQLP_MMR_DIR_PRESVEC1_VEC_SHFT     0
-#define SH_MD_DQLP_MMR_DIR_PRESVEC1_VEC_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRESVEC2"                */
-/*                     node [191:128] presence bits                     */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRESVEC2              0x0000000100030120
-#define SH_MD_DQLP_MMR_DIR_PRESVEC2_MASK         0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_PRESVEC2_INIT         0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRESVEC2_VEC                                    */
-/*   Description:  node presence bits, 1=present                        */
-#define SH_MD_DQLP_MMR_DIR_PRESVEC2_VEC_SHFT     0
-#define SH_MD_DQLP_MMR_DIR_PRESVEC2_VEC_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRESVEC3"                */
-/*                     node [255:192] presence bits                     */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRESVEC3              0x0000000100030130
-#define SH_MD_DQLP_MMR_DIR_PRESVEC3_MASK         0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_PRESVEC3_INIT         0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRESVEC3_VEC                                    */
-/*   Description:  node presence bits, 1=present                        */
-#define SH_MD_DQLP_MMR_DIR_PRESVEC3_VEC_SHFT     0
-#define SH_MD_DQLP_MMR_DIR_PRESVEC3_VEC_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC0"                 */
-/*                        local vector for acc=0                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_LOCVEC0               0x0000000100030200
-#define SH_MD_DQLP_MMR_DIR_LOCVEC0_MASK          0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_LOCVEC0_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_LOCVEC0_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQLP_MMR_DIR_LOCVEC0_VEC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_LOCVEC0_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC1"                 */
-/*                        local vector for acc=1                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_LOCVEC1               0x0000000100030210
-#define SH_MD_DQLP_MMR_DIR_LOCVEC1_MASK          0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_LOCVEC1_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_LOCVEC1_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQLP_MMR_DIR_LOCVEC1_VEC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_LOCVEC1_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC2"                 */
-/*                        local vector for acc=2                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_LOCVEC2               0x0000000100030220
-#define SH_MD_DQLP_MMR_DIR_LOCVEC2_MASK          0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_LOCVEC2_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_LOCVEC2_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQLP_MMR_DIR_LOCVEC2_VEC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_LOCVEC2_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC3"                 */
-/*                        local vector for acc=3                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_LOCVEC3               0x0000000100030230
-#define SH_MD_DQLP_MMR_DIR_LOCVEC3_MASK          0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_LOCVEC3_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_LOCVEC3_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQLP_MMR_DIR_LOCVEC3_VEC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_LOCVEC3_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC4"                 */
-/*                        local vector for acc=4                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_LOCVEC4               0x0000000100030240
-#define SH_MD_DQLP_MMR_DIR_LOCVEC4_MASK          0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_LOCVEC4_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_LOCVEC4_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQLP_MMR_DIR_LOCVEC4_VEC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_LOCVEC4_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC5"                 */
-/*                        local vector for acc=5                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_LOCVEC5               0x0000000100030250
-#define SH_MD_DQLP_MMR_DIR_LOCVEC5_MASK          0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_LOCVEC5_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_LOCVEC5_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQLP_MMR_DIR_LOCVEC5_VEC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_LOCVEC5_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC6"                 */
-/*                        local vector for acc=6                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_LOCVEC6               0x0000000100030260
-#define SH_MD_DQLP_MMR_DIR_LOCVEC6_MASK          0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_LOCVEC6_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_LOCVEC6_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQLP_MMR_DIR_LOCVEC6_VEC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_LOCVEC6_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC7"                 */
-/*                        local vector for acc=7                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_LOCVEC7               0x0000000100030270
-#define SH_MD_DQLP_MMR_DIR_LOCVEC7_MASK          0xffffffffffffffff
-#define SH_MD_DQLP_MMR_DIR_LOCVEC7_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_LOCVEC7_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQLP_MMR_DIR_LOCVEC7_VEC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_LOCVEC7_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC0"                 */
-/*                      privilege vector for acc=0                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRIVEC0               0x0000000100030300
-#define SH_MD_DQLP_MMR_DIR_PRIVEC0_MASK          0x000000000fffffff
-#define SH_MD_DQLP_MMR_DIR_PRIVEC0_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC0_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC0_IN_SHFT       0
-#define SH_MD_DQLP_MMR_DIR_PRIVEC0_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC0_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC0_OUT_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_PRIVEC0_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC1"                 */
-/*                      privilege vector for acc=1                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRIVEC1               0x0000000100030310
-#define SH_MD_DQLP_MMR_DIR_PRIVEC1_MASK          0x000000000fffffff
-#define SH_MD_DQLP_MMR_DIR_PRIVEC1_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC1_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC1_IN_SHFT       0
-#define SH_MD_DQLP_MMR_DIR_PRIVEC1_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC1_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC1_OUT_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_PRIVEC1_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC2"                 */
-/*                      privilege vector for acc=2                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRIVEC2               0x0000000100030320
-#define SH_MD_DQLP_MMR_DIR_PRIVEC2_MASK          0x000000000fffffff
-#define SH_MD_DQLP_MMR_DIR_PRIVEC2_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC2_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC2_IN_SHFT       0
-#define SH_MD_DQLP_MMR_DIR_PRIVEC2_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC2_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC2_OUT_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_PRIVEC2_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC3"                 */
-/*                      privilege vector for acc=3                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRIVEC3               0x0000000100030330
-#define SH_MD_DQLP_MMR_DIR_PRIVEC3_MASK          0x000000000fffffff
-#define SH_MD_DQLP_MMR_DIR_PRIVEC3_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC3_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC3_IN_SHFT       0
-#define SH_MD_DQLP_MMR_DIR_PRIVEC3_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC3_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC3_OUT_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_PRIVEC3_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC4"                 */
-/*                      privilege vector for acc=4                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRIVEC4               0x0000000100030340
-#define SH_MD_DQLP_MMR_DIR_PRIVEC4_MASK          0x000000000fffffff
-#define SH_MD_DQLP_MMR_DIR_PRIVEC4_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC4_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC4_IN_SHFT       0
-#define SH_MD_DQLP_MMR_DIR_PRIVEC4_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC4_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC4_OUT_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_PRIVEC4_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC5"                 */
-/*                      privilege vector for acc=5                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRIVEC5               0x0000000100030350
-#define SH_MD_DQLP_MMR_DIR_PRIVEC5_MASK          0x000000000fffffff
-#define SH_MD_DQLP_MMR_DIR_PRIVEC5_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC5_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC5_IN_SHFT       0
-#define SH_MD_DQLP_MMR_DIR_PRIVEC5_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC5_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC5_OUT_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_PRIVEC5_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC6"                 */
-/*                      privilege vector for acc=6                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRIVEC6               0x0000000100030360
-#define SH_MD_DQLP_MMR_DIR_PRIVEC6_MASK          0x000000000fffffff
-#define SH_MD_DQLP_MMR_DIR_PRIVEC6_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC6_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC6_IN_SHFT       0
-#define SH_MD_DQLP_MMR_DIR_PRIVEC6_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC6_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC6_OUT_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_PRIVEC6_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC7"                 */
-/*                      privilege vector for acc=7                      */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_PRIVEC7               0x0000000100030370
-#define SH_MD_DQLP_MMR_DIR_PRIVEC7_MASK          0x000000000fffffff
-#define SH_MD_DQLP_MMR_DIR_PRIVEC7_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC7_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC7_IN_SHFT       0
-#define SH_MD_DQLP_MMR_DIR_PRIVEC7_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_PRIVEC7_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQLP_MMR_DIR_PRIVEC7_OUT_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_PRIVEC7_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQLP_MMR_DIR_TIMER"                  */
-/*                            MD SXRO timer                             */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_TIMER                 0x0000000100030400
-#define SH_MD_DQLP_MMR_DIR_TIMER_MASK            0x00000000003fffff
-#define SH_MD_DQLP_MMR_DIR_TIMER_INIT            0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_TIMER_TIMER_DIV                                 */
-/*   Description:  timer divide register                                */
-#define SH_MD_DQLP_MMR_DIR_TIMER_TIMER_DIV_SHFT  0
-#define SH_MD_DQLP_MMR_DIR_TIMER_TIMER_DIV_MASK  0x0000000000000fff
-
-/*   SH_MD_DQLP_MMR_DIR_TIMER_TIMER_EN                                  */
-/*   Description:  timer enable                                         */
-#define SH_MD_DQLP_MMR_DIR_TIMER_TIMER_EN_SHFT   12
-#define SH_MD_DQLP_MMR_DIR_TIMER_TIMER_EN_MASK   0x0000000000001000
-
-/*   SH_MD_DQLP_MMR_DIR_TIMER_TIMER_CUR                                 */
-/*   Description:  value of current timer                               */
-#define SH_MD_DQLP_MMR_DIR_TIMER_TIMER_CUR_SHFT  13
-#define SH_MD_DQLP_MMR_DIR_TIMER_TIMER_CUR_MASK  0x00000000003fe000
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY"               */
-/*                       directory pio write data                       */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY           0x0000000100031000
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_MASK      0x03ffffffffffffff
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_INIT      0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_DIRA                                */
-/*   Description:  directory entry A                                    */
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_DIRA_SHFT 0
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_DIRA_MASK 0x0000000003ffffff
-
-/*   SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_DIRB                                */
-/*   Description:  directory entry B                                    */
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_DIRB_SHFT 26
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_DIRB_MASK 0x000ffffffc000000
-
-/*   SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_PRI                                 */
-/*   Description:  directory priority                                   */
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_PRI_SHFT  52
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_PRI_MASK  0x0070000000000000
-
-/*   SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_ACC                                 */
-/*   Description:  directory access bits                                */
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_ACC_SHFT  55
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY_ACC_MASK  0x0380000000000000
-
-/* ==================================================================== */
-/*               Register "SH_MD_DQLP_MMR_PIOWD_DIR_ECC"                */
-/*                        directory ecc register                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ECC             0x0000000100031010
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ECC_MASK        0x0000000000003fff
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ECC_INIT        0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_PIOWD_DIR_ECC_ECCA                                  */
-/*   Description:  XOR bits for directory ECC group 1                   */
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ECC_ECCA_SHFT   0
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ECC_ECCA_MASK   0x000000000000007f
-
-/*   SH_MD_DQLP_MMR_PIOWD_DIR_ECC_ECCB                                  */
-/*   Description:  XOR bits for directory ECC group 2                   */
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ECC_ECCB_SHFT   7
-#define SH_MD_DQLP_MMR_PIOWD_DIR_ECC_ECCB_MASK   0x0000000000003f80
-
-/* ==================================================================== */
-/*             Register "SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY"              */
-/*                      x directory pio read data                       */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY         0x0000000100032000
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_MASK    0x0fffffffffffffff
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_INIT    0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_DIRA                              */
-/*   Description:  directory entry A                                    */
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_DIRA_SHFT 0
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_DIRA_MASK 0x0000000003ffffff
-
-/*   SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_DIRB                              */
-/*   Description:  directory entry B                                    */
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_DIRB_SHFT 26
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_DIRB_MASK 0x000ffffffc000000
-
-/*   SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_PRI                               */
-/*   Description:  directory priority                                   */
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_PRI_SHFT 52
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_PRI_MASK 0x0070000000000000
-
-/*   SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_ACC                               */
-/*   Description:  directory access bits                                */
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_ACC_SHFT 55
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_ACC_MASK 0x0380000000000000
-
-/*   SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_COR                               */
-/*   Description:  correctable ecc error                                */
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_COR_SHFT 58
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_COR_MASK 0x0400000000000000
-
-/*   SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_UNC                               */
-/*   Description:  uncorrectable ecc error                              */
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_UNC_SHFT 59
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY_UNC_MASK 0x0800000000000000
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQLP_MMR_XPIORD_XDIR_ECC"               */
-/*                           x directory ecc                            */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ECC           0x0000000100032010
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ECC_MASK      0x0000000000003fff
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ECC_INIT      0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XPIORD_XDIR_ECC_ECCA                                */
-/*   Description:  group 1 ecc                                          */
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ECC_ECCA_SHFT 0
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ECC_ECCA_MASK 0x000000000000007f
-
-/*   SH_MD_DQLP_MMR_XPIORD_XDIR_ECC_ECCB                                */
-/*   Description:  group 2 ecc                                          */
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ECC_ECCB_SHFT 7
-#define SH_MD_DQLP_MMR_XPIORD_XDIR_ECC_ECCB_MASK 0x0000000000003f80
-
-/* ==================================================================== */
-/*             Register "SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY"              */
-/*                      y directory pio read data                       */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY         0x0000000100032800
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_MASK    0x0fffffffffffffff
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_INIT    0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_DIRA                              */
-/*   Description:  directory entry A                                    */
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_DIRA_SHFT 0
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_DIRA_MASK 0x0000000003ffffff
-
-/*   SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_DIRB                              */
-/*   Description:  directory entry B                                    */
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_DIRB_SHFT 26
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_DIRB_MASK 0x000ffffffc000000
-
-/*   SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_PRI                               */
-/*   Description:  directory priority                                   */
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_PRI_SHFT 52
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_PRI_MASK 0x0070000000000000
-
-/*   SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_ACC                               */
-/*   Description:  directory access bits                                */
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_ACC_SHFT 55
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_ACC_MASK 0x0380000000000000
-
-/*   SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_COR                               */
-/*   Description:  correctable ecc error                                */
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_COR_SHFT 58
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_COR_MASK 0x0400000000000000
-
-/*   SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_UNC                               */
-/*   Description:  uncorrectable ecc error                              */
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_UNC_SHFT 59
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY_UNC_MASK 0x0800000000000000
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQLP_MMR_YPIORD_YDIR_ECC"               */
-/*                           y directory ecc                            */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ECC           0x0000000100032810
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ECC_MASK      0x0000000000003fff
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ECC_INIT      0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YPIORD_YDIR_ECC_ECCA                                */
-/*   Description:  group 1 ecc                                          */
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ECC_ECCA_SHFT 0
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ECC_ECCA_MASK 0x000000000000007f
-
-/*   SH_MD_DQLP_MMR_YPIORD_YDIR_ECC_ECCB                                */
-/*   Description:  group 2 ecc                                          */
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ECC_ECCB_SHFT 7
-#define SH_MD_DQLP_MMR_YPIORD_YDIR_ECC_ECCB_MASK 0x0000000000003f80
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XCERR1"                   */
-/*              correctable dir ecc group 1 error register              */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XCERR1                    0x0000000100033000
-#define SH_MD_DQLP_MMR_XCERR1_MASK               0x0000007fffffffff
-#define SH_MD_DQLP_MMR_XCERR1_INIT               0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XCERR1_GRP1                                         */
-/*   Description:  ecc group 1 bits                                     */
-#define SH_MD_DQLP_MMR_XCERR1_GRP1_SHFT          0
-#define SH_MD_DQLP_MMR_XCERR1_GRP1_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQLP_MMR_XCERR1_VAL                                          */
-/*   Description:  correctable ecc error in group 1 bits                */
-#define SH_MD_DQLP_MMR_XCERR1_VAL_SHFT           36
-#define SH_MD_DQLP_MMR_XCERR1_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQLP_MMR_XCERR1_MORE                                         */
-/*   Description:  more than one correctable ecc error in group 1       */
-#define SH_MD_DQLP_MMR_XCERR1_MORE_SHFT          37
-#define SH_MD_DQLP_MMR_XCERR1_MORE_MASK          0x0000002000000000
-
-/*   SH_MD_DQLP_MMR_XCERR1_ARM                                          */
-/*   Description:  writing 1 arms uncorrectable ecc error capture       */
-#define SH_MD_DQLP_MMR_XCERR1_ARM_SHFT           38
-#define SH_MD_DQLP_MMR_XCERR1_ARM_MASK           0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XCERR2"                   */
-/*              correctable dir ecc group 2 error register              */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XCERR2                    0x0000000100033010
-#define SH_MD_DQLP_MMR_XCERR2_MASK               0x0000003fffffffff
-#define SH_MD_DQLP_MMR_XCERR2_INIT               0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XCERR2_GRP2                                         */
-/*   Description:  ecc group 2 bits                                     */
-#define SH_MD_DQLP_MMR_XCERR2_GRP2_SHFT          0
-#define SH_MD_DQLP_MMR_XCERR2_GRP2_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQLP_MMR_XCERR2_VAL                                          */
-/*   Description:  correctable ecc error in group 2 bits                */
-#define SH_MD_DQLP_MMR_XCERR2_VAL_SHFT           36
-#define SH_MD_DQLP_MMR_XCERR2_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQLP_MMR_XCERR2_MORE                                         */
-/*   Description:  more than one correctable ecc error in group 2       */
-#define SH_MD_DQLP_MMR_XCERR2_MORE_SHFT          37
-#define SH_MD_DQLP_MMR_XCERR2_MORE_MASK          0x0000002000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XUERR1"                   */
-/*             uncorrectable dir ecc group 1 error register             */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XUERR1                    0x0000000100033020
-#define SH_MD_DQLP_MMR_XUERR1_MASK               0x0000007fffffffff
-#define SH_MD_DQLP_MMR_XUERR1_INIT               0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XUERR1_GRP1                                         */
-/*   Description:  ecc group 1 bits                                     */
-#define SH_MD_DQLP_MMR_XUERR1_GRP1_SHFT          0
-#define SH_MD_DQLP_MMR_XUERR1_GRP1_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQLP_MMR_XUERR1_VAL                                          */
-/*   Description:  uncorrectable ecc error in group 1 bits              */
-#define SH_MD_DQLP_MMR_XUERR1_VAL_SHFT           36
-#define SH_MD_DQLP_MMR_XUERR1_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQLP_MMR_XUERR1_MORE                                         */
-/*   Description:  more than one uncorrectable ecc error in group 1     */
-#define SH_MD_DQLP_MMR_XUERR1_MORE_SHFT          37
-#define SH_MD_DQLP_MMR_XUERR1_MORE_MASK          0x0000002000000000
-
-/*   SH_MD_DQLP_MMR_XUERR1_ARM                                          */
-/*   Description:  writing 1 arms uncorrectable ecc error capture       */
-#define SH_MD_DQLP_MMR_XUERR1_ARM_SHFT           38
-#define SH_MD_DQLP_MMR_XUERR1_ARM_MASK           0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XUERR2"                   */
-/*             uncorrectable dir ecc group 2 error register             */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XUERR2                    0x0000000100033030
-#define SH_MD_DQLP_MMR_XUERR2_MASK               0x0000003fffffffff
-#define SH_MD_DQLP_MMR_XUERR2_INIT               0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XUERR2_GRP2                                         */
-/*   Description:  ecc group 2 bits                                     */
-#define SH_MD_DQLP_MMR_XUERR2_GRP2_SHFT          0
-#define SH_MD_DQLP_MMR_XUERR2_GRP2_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQLP_MMR_XUERR2_VAL                                          */
-/*   Description:  uncorrectable ecc error in group 2 bits              */
-#define SH_MD_DQLP_MMR_XUERR2_VAL_SHFT           36
-#define SH_MD_DQLP_MMR_XUERR2_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQLP_MMR_XUERR2_MORE                                         */
-/*   Description:  more than one uncorrectable ecc error in group 2     */
-#define SH_MD_DQLP_MMR_XUERR2_MORE_SHFT          37
-#define SH_MD_DQLP_MMR_XUERR2_MORE_MASK          0x0000002000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XPERR"                    */
-/*                       protocol error register                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XPERR                     0x0000000100033040
-#define SH_MD_DQLP_MMR_XPERR_MASK                0x7fffffffffffffff
-#define SH_MD_DQLP_MMR_XPERR_INIT                0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XPERR_DIR                                           */
-/*   Description:  directory entry                                      */
-#define SH_MD_DQLP_MMR_XPERR_DIR_SHFT            0
-#define SH_MD_DQLP_MMR_XPERR_DIR_MASK            0x0000000003ffffff
-
-/*   SH_MD_DQLP_MMR_XPERR_CMD                                           */
-/*   Description:  incoming command                                     */
-#define SH_MD_DQLP_MMR_XPERR_CMD_SHFT            26
-#define SH_MD_DQLP_MMR_XPERR_CMD_MASK            0x00000003fc000000
-
-/*   SH_MD_DQLP_MMR_XPERR_SRC                                           */
-/*   Description:  source node of dir operation                         */
-#define SH_MD_DQLP_MMR_XPERR_SRC_SHFT            34
-#define SH_MD_DQLP_MMR_XPERR_SRC_MASK            0x0000fffc00000000
-
-/*   SH_MD_DQLP_MMR_XPERR_PRIGE                                         */
-/*   Description:  priority was greater-equal                           */
-#define SH_MD_DQLP_MMR_XPERR_PRIGE_SHFT          48
-#define SH_MD_DQLP_MMR_XPERR_PRIGE_MASK          0x0001000000000000
-
-/*   SH_MD_DQLP_MMR_XPERR_PRIV                                          */
-/*   Description:  access privilege bit                                 */
-#define SH_MD_DQLP_MMR_XPERR_PRIV_SHFT           49
-#define SH_MD_DQLP_MMR_XPERR_PRIV_MASK           0x0002000000000000
-
-/*   SH_MD_DQLP_MMR_XPERR_COR                                           */
-/*   Description:  correctable ecc error                                */
-#define SH_MD_DQLP_MMR_XPERR_COR_SHFT            50
-#define SH_MD_DQLP_MMR_XPERR_COR_MASK            0x0004000000000000
-
-/*   SH_MD_DQLP_MMR_XPERR_UNC                                           */
-/*   Description:  uncorrectable ecc error                              */
-#define SH_MD_DQLP_MMR_XPERR_UNC_SHFT            51
-#define SH_MD_DQLP_MMR_XPERR_UNC_MASK            0x0008000000000000
-
-/*   SH_MD_DQLP_MMR_XPERR_MYBIT                                         */
-/*   Description:  ptreq,timeq,timlast,timspec,onlyme,anytim,ptrii,src  */
-#define SH_MD_DQLP_MMR_XPERR_MYBIT_SHFT          52
-#define SH_MD_DQLP_MMR_XPERR_MYBIT_MASK          0x0ff0000000000000
-
-/*   SH_MD_DQLP_MMR_XPERR_VAL                                           */
-/*   Description:  protocol error info valid                            */
-#define SH_MD_DQLP_MMR_XPERR_VAL_SHFT            60
-#define SH_MD_DQLP_MMR_XPERR_VAL_MASK            0x1000000000000000
-
-/*   SH_MD_DQLP_MMR_XPERR_MORE                                          */
-/*   Description:  more than one protocol error                         */
-#define SH_MD_DQLP_MMR_XPERR_MORE_SHFT           61
-#define SH_MD_DQLP_MMR_XPERR_MORE_MASK           0x2000000000000000
-
-/*   SH_MD_DQLP_MMR_XPERR_ARM                                           */
-/*   Description:  writing 1 arms error capture                         */
-#define SH_MD_DQLP_MMR_XPERR_ARM_SHFT            62
-#define SH_MD_DQLP_MMR_XPERR_ARM_MASK            0x4000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YCERR1"                   */
-/*              correctable dir ecc group 1 error register              */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YCERR1                    0x0000000100033800
-#define SH_MD_DQLP_MMR_YCERR1_MASK               0x0000007fffffffff
-#define SH_MD_DQLP_MMR_YCERR1_INIT               0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YCERR1_GRP1                                         */
-/*   Description:  ecc group 1 bits                                     */
-#define SH_MD_DQLP_MMR_YCERR1_GRP1_SHFT          0
-#define SH_MD_DQLP_MMR_YCERR1_GRP1_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQLP_MMR_YCERR1_VAL                                          */
-/*   Description:  correctable ecc error in group 1 bits                */
-#define SH_MD_DQLP_MMR_YCERR1_VAL_SHFT           36
-#define SH_MD_DQLP_MMR_YCERR1_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQLP_MMR_YCERR1_MORE                                         */
-/*   Description:  more than one correctable ecc error in group 1       */
-#define SH_MD_DQLP_MMR_YCERR1_MORE_SHFT          37
-#define SH_MD_DQLP_MMR_YCERR1_MORE_MASK          0x0000002000000000
-
-/*   SH_MD_DQLP_MMR_YCERR1_ARM                                          */
-/*   Description:  writing 1 arms uncorrectable ecc error capture       */
-#define SH_MD_DQLP_MMR_YCERR1_ARM_SHFT           38
-#define SH_MD_DQLP_MMR_YCERR1_ARM_MASK           0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YCERR2"                   */
-/*              correctable dir ecc group 2 error register              */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YCERR2                    0x0000000100033810
-#define SH_MD_DQLP_MMR_YCERR2_MASK               0x0000003fffffffff
-#define SH_MD_DQLP_MMR_YCERR2_INIT               0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YCERR2_GRP2                                         */
-/*   Description:  ecc group 2 bits                                     */
-#define SH_MD_DQLP_MMR_YCERR2_GRP2_SHFT          0
-#define SH_MD_DQLP_MMR_YCERR2_GRP2_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQLP_MMR_YCERR2_VAL                                          */
-/*   Description:  correctable ecc error in group 2 bits                */
-#define SH_MD_DQLP_MMR_YCERR2_VAL_SHFT           36
-#define SH_MD_DQLP_MMR_YCERR2_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQLP_MMR_YCERR2_MORE                                         */
-/*   Description:  more than one correctable ecc error in group 2       */
-#define SH_MD_DQLP_MMR_YCERR2_MORE_SHFT          37
-#define SH_MD_DQLP_MMR_YCERR2_MORE_MASK          0x0000002000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YUERR1"                   */
-/*             uncorrectable dir ecc group 1 error register             */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YUERR1                    0x0000000100033820
-#define SH_MD_DQLP_MMR_YUERR1_MASK               0x0000007fffffffff
-#define SH_MD_DQLP_MMR_YUERR1_INIT               0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YUERR1_GRP1                                         */
-/*   Description:  ecc group 1 bits                                     */
-#define SH_MD_DQLP_MMR_YUERR1_GRP1_SHFT          0
-#define SH_MD_DQLP_MMR_YUERR1_GRP1_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQLP_MMR_YUERR1_VAL                                          */
-/*   Description:  uncorrectable ecc error in group 1 bits              */
-#define SH_MD_DQLP_MMR_YUERR1_VAL_SHFT           36
-#define SH_MD_DQLP_MMR_YUERR1_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQLP_MMR_YUERR1_MORE                                         */
-/*   Description:  more than one uncorrectable ecc error in group 1     */
-#define SH_MD_DQLP_MMR_YUERR1_MORE_SHFT          37
-#define SH_MD_DQLP_MMR_YUERR1_MORE_MASK          0x0000002000000000
-
-/*   SH_MD_DQLP_MMR_YUERR1_ARM                                          */
-/*   Description:  writing 1 arms uncorrectable ecc error capture       */
-#define SH_MD_DQLP_MMR_YUERR1_ARM_SHFT           38
-#define SH_MD_DQLP_MMR_YUERR1_ARM_MASK           0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YUERR2"                   */
-/*             uncorrectable dir ecc group 2 error register             */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YUERR2                    0x0000000100033830
-#define SH_MD_DQLP_MMR_YUERR2_MASK               0x0000003fffffffff
-#define SH_MD_DQLP_MMR_YUERR2_INIT               0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YUERR2_GRP2                                         */
-/*   Description:  ecc group 2 bits                                     */
-#define SH_MD_DQLP_MMR_YUERR2_GRP2_SHFT          0
-#define SH_MD_DQLP_MMR_YUERR2_GRP2_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQLP_MMR_YUERR2_VAL                                          */
-/*   Description:  uncorrectable ecc error in group 2 bits              */
-#define SH_MD_DQLP_MMR_YUERR2_VAL_SHFT           36
-#define SH_MD_DQLP_MMR_YUERR2_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQLP_MMR_YUERR2_MORE                                         */
-/*   Description:  more than one uncorrectable ecc error in group 2     */
-#define SH_MD_DQLP_MMR_YUERR2_MORE_SHFT          37
-#define SH_MD_DQLP_MMR_YUERR2_MORE_MASK          0x0000002000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YPERR"                    */
-/*                       protocol error register                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YPERR                     0x0000000100033840
-#define SH_MD_DQLP_MMR_YPERR_MASK                0x7fffffffffffffff
-#define SH_MD_DQLP_MMR_YPERR_INIT                0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YPERR_DIR                                           */
-/*   Description:  directory entry                                      */
-#define SH_MD_DQLP_MMR_YPERR_DIR_SHFT            0
-#define SH_MD_DQLP_MMR_YPERR_DIR_MASK            0x0000000003ffffff
-
-/*   SH_MD_DQLP_MMR_YPERR_CMD                                           */
-/*   Description:  incoming command                                     */
-#define SH_MD_DQLP_MMR_YPERR_CMD_SHFT            26
-#define SH_MD_DQLP_MMR_YPERR_CMD_MASK            0x00000003fc000000
-
-/*   SH_MD_DQLP_MMR_YPERR_SRC                                           */
-/*   Description:  source node of dir operation                         */
-#define SH_MD_DQLP_MMR_YPERR_SRC_SHFT            34
-#define SH_MD_DQLP_MMR_YPERR_SRC_MASK            0x0000fffc00000000
-
-/*   SH_MD_DQLP_MMR_YPERR_PRIGE                                         */
-/*   Description:  priority was greater-equal                           */
-#define SH_MD_DQLP_MMR_YPERR_PRIGE_SHFT          48
-#define SH_MD_DQLP_MMR_YPERR_PRIGE_MASK          0x0001000000000000
-
-/*   SH_MD_DQLP_MMR_YPERR_PRIV                                          */
-/*   Description:  access privilege bit                                 */
-#define SH_MD_DQLP_MMR_YPERR_PRIV_SHFT           49
-#define SH_MD_DQLP_MMR_YPERR_PRIV_MASK           0x0002000000000000
-
-/*   SH_MD_DQLP_MMR_YPERR_COR                                           */
-/*   Description:  correctable ecc error                                */
-#define SH_MD_DQLP_MMR_YPERR_COR_SHFT            50
-#define SH_MD_DQLP_MMR_YPERR_COR_MASK            0x0004000000000000
-
-/*   SH_MD_DQLP_MMR_YPERR_UNC                                           */
-/*   Description:  uncorrectable ecc error                              */
-#define SH_MD_DQLP_MMR_YPERR_UNC_SHFT            51
-#define SH_MD_DQLP_MMR_YPERR_UNC_MASK            0x0008000000000000
-
-/*   SH_MD_DQLP_MMR_YPERR_MYBIT                                         */
-/*   Description:  ptreq,timeq,timlast,timspec,onlyme,anytim,ptrii,src  */
-#define SH_MD_DQLP_MMR_YPERR_MYBIT_SHFT          52
-#define SH_MD_DQLP_MMR_YPERR_MYBIT_MASK          0x0ff0000000000000
-
-/*   SH_MD_DQLP_MMR_YPERR_VAL                                           */
-/*   Description:  protocol error info valid                            */
-#define SH_MD_DQLP_MMR_YPERR_VAL_SHFT            60
-#define SH_MD_DQLP_MMR_YPERR_VAL_MASK            0x1000000000000000
-
-/*   SH_MD_DQLP_MMR_YPERR_MORE                                          */
-/*   Description:  more than one protocol error                         */
-#define SH_MD_DQLP_MMR_YPERR_MORE_SHFT           61
-#define SH_MD_DQLP_MMR_YPERR_MORE_MASK           0x2000000000000000
-
-/*   SH_MD_DQLP_MMR_YPERR_ARM                                           */
-/*   Description:  writing 1 arms error capture                         */
-#define SH_MD_DQLP_MMR_YPERR_ARM_SHFT            62
-#define SH_MD_DQLP_MMR_YPERR_ARM_MASK            0x4000000000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_CMDTRIG"                 */
-/*                             cmd triggers                             */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG               0x0000000100034000
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_MASK          0x00000000ffffffff
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD0                                    */
-/*   Description:  command trigger 0                                    */
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD0_SHFT     0
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD0_MASK     0x00000000000000ff
-
-/*   SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD1                                    */
-/*   Description:  command trigger 1                                    */
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD1_SHFT     8
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD1_MASK     0x000000000000ff00
-
-/*   SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD2                                    */
-/*   Description:  command trigger 2                                    */
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD2_SHFT     16
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD2_MASK     0x0000000000ff0000
-
-/*   SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD3                                    */
-/*   Description:  command trigger 3                                    */
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD3_SHFT     24
-#define SH_MD_DQLP_MMR_DIR_CMDTRIG_CMD3_MASK     0x00000000ff000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_TBLTRIG"                 */
-/*                          dir table trigger                           */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG               0x0000000100034010
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_MASK          0x000003ffffffffff
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLTRIG_SRC                                     */
-/*   Description:  source of request                                    */
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_SRC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_SRC_MASK      0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_TBLTRIG_CMD                                     */
-/*   Description:  incoming request                                     */
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_CMD_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_CMD_MASK      0x00000000003fc000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLTRIG_ACC                                     */
-/*   Description:  uncorrectable error, privilege bit                   */
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_ACC_SHFT      22
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_ACC_MASK      0x0000000000c00000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLTRIG_PRIGE                                   */
-/*   Description:  priority greater-equal                               */
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_PRIGE_SHFT    24
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_PRIGE_MASK    0x0000000001000000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLTRIG_DIRST                                   */
-/*   Description:  shrd,sxro,sub-state                                  */
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_DIRST_SHFT    25
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_DIRST_MASK    0x00000003fe000000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLTRIG_MYBIT                                   */
-/*   Description:  ptreq,timeq,timlast,timspec,onlyme,anytim,ptrii,src  */
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_MYBIT_SHFT    34
-#define SH_MD_DQLP_MMR_DIR_TBLTRIG_MYBIT_MASK    0x000003fc00000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_TBLMASK"                 */
-/*                        dir table trigger mask                        */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_DIR_TBLMASK               0x0000000100034020
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_MASK          0x000003ffffffffff
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLMASK_SRC                                     */
-/*   Description:  source of request                                    */
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_SRC_SHFT      0
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_SRC_MASK      0x0000000000003fff
-
-/*   SH_MD_DQLP_MMR_DIR_TBLMASK_CMD                                     */
-/*   Description:  incoming request                                     */
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_CMD_SHFT      14
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_CMD_MASK      0x00000000003fc000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLMASK_ACC                                     */
-/*   Description:  uncorrectable error, privilege bit                   */
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_ACC_SHFT      22
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_ACC_MASK      0x0000000000c00000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLMASK_PRIGE                                   */
-/*   Description:  priority greater-equal                               */
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_PRIGE_SHFT    24
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_PRIGE_MASK    0x0000000001000000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLMASK_DIRST                                   */
-/*   Description:  shrd,sxro,sub-state                                  */
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_DIRST_SHFT    25
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_DIRST_MASK    0x00000003fe000000
-
-/*   SH_MD_DQLP_MMR_DIR_TBLMASK_MYBIT                                   */
-/*   Description:  ptreq,timeq,timlast,timspec,onlyme,anytim,ptrii,src  */
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_MYBIT_SHFT    34
-#define SH_MD_DQLP_MMR_DIR_TBLMASK_MYBIT_MASK    0x000003fc00000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLP_MMR_XBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XBIST_H                   0x0000000100038000
-#define SH_MD_DQLP_MMR_XBIST_H_MASK              0x00000700ffffffff
-#define SH_MD_DQLP_MMR_XBIST_H_INIT              0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_H_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLP_MMR_XBIST_H_PAT_SHFT          0
-#define SH_MD_DQLP_MMR_XBIST_H_PAT_MASK          0x00000000ffffffff
-
-/*   SH_MD_DQLP_MMR_XBIST_H_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQLP_MMR_XBIST_H_INV_SHFT          40
-#define SH_MD_DQLP_MMR_XBIST_H_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_H_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQLP_MMR_XBIST_H_ROT_SHFT          41
-#define SH_MD_DQLP_MMR_XBIST_H_ROT_MASK          0x0000020000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_H_ARM                                         */
-/*   Description:  writing 1 arms data miscompare capture               */
-#define SH_MD_DQLP_MMR_XBIST_H_ARM_SHFT          42
-#define SH_MD_DQLP_MMR_XBIST_H_ARM_MASK          0x0000040000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLP_MMR_XBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XBIST_L                   0x0000000100038010
-#define SH_MD_DQLP_MMR_XBIST_L_MASK              0x00000300ffffffff
-#define SH_MD_DQLP_MMR_XBIST_L_INIT              0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_L_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLP_MMR_XBIST_L_PAT_SHFT          0
-#define SH_MD_DQLP_MMR_XBIST_L_PAT_MASK          0x00000000ffffffff
-
-/*   SH_MD_DQLP_MMR_XBIST_L_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQLP_MMR_XBIST_L_INV_SHFT          40
-#define SH_MD_DQLP_MMR_XBIST_L_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_L_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQLP_MMR_XBIST_L_ROT_SHFT          41
-#define SH_MD_DQLP_MMR_XBIST_L_ROT_MASK          0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_XBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XBIST_ERR_H               0x0000000100038020
-#define SH_MD_DQLP_MMR_XBIST_ERR_H_MASK          0x00000300ffffffff
-#define SH_MD_DQLP_MMR_XBIST_ERR_H_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_ERR_H_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLP_MMR_XBIST_ERR_H_PAT_SHFT      0
-#define SH_MD_DQLP_MMR_XBIST_ERR_H_PAT_MASK      0x00000000ffffffff
-
-/*   SH_MD_DQLP_MMR_XBIST_ERR_H_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQLP_MMR_XBIST_ERR_H_VAL_SHFT      40
-#define SH_MD_DQLP_MMR_XBIST_ERR_H_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_ERR_H_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQLP_MMR_XBIST_ERR_H_MORE_SHFT     41
-#define SH_MD_DQLP_MMR_XBIST_ERR_H_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_XBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_XBIST_ERR_L               0x0000000100038030
-#define SH_MD_DQLP_MMR_XBIST_ERR_L_MASK          0x00000300ffffffff
-#define SH_MD_DQLP_MMR_XBIST_ERR_L_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_ERR_L_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLP_MMR_XBIST_ERR_L_PAT_SHFT      0
-#define SH_MD_DQLP_MMR_XBIST_ERR_L_PAT_MASK      0x00000000ffffffff
-
-/*   SH_MD_DQLP_MMR_XBIST_ERR_L_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQLP_MMR_XBIST_ERR_L_VAL_SHFT      40
-#define SH_MD_DQLP_MMR_XBIST_ERR_L_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQLP_MMR_XBIST_ERR_L_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQLP_MMR_XBIST_ERR_L_MORE_SHFT     41
-#define SH_MD_DQLP_MMR_XBIST_ERR_L_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLP_MMR_YBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YBIST_H                   0x0000000100038800
-#define SH_MD_DQLP_MMR_YBIST_H_MASK              0x00000700ffffffff
-#define SH_MD_DQLP_MMR_YBIST_H_INIT              0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_H_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLP_MMR_YBIST_H_PAT_SHFT          0
-#define SH_MD_DQLP_MMR_YBIST_H_PAT_MASK          0x00000000ffffffff
-
-/*   SH_MD_DQLP_MMR_YBIST_H_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQLP_MMR_YBIST_H_INV_SHFT          40
-#define SH_MD_DQLP_MMR_YBIST_H_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_H_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQLP_MMR_YBIST_H_ROT_SHFT          41
-#define SH_MD_DQLP_MMR_YBIST_H_ROT_MASK          0x0000020000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_H_ARM                                         */
-/*   Description:  writing 1 arms data miscompare capture               */
-#define SH_MD_DQLP_MMR_YBIST_H_ARM_SHFT          42
-#define SH_MD_DQLP_MMR_YBIST_H_ARM_MASK          0x0000040000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLP_MMR_YBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YBIST_L                   0x0000000100038810
-#define SH_MD_DQLP_MMR_YBIST_L_MASK              0x00000300ffffffff
-#define SH_MD_DQLP_MMR_YBIST_L_INIT              0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_L_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLP_MMR_YBIST_L_PAT_SHFT          0
-#define SH_MD_DQLP_MMR_YBIST_L_PAT_MASK          0x00000000ffffffff
-
-/*   SH_MD_DQLP_MMR_YBIST_L_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQLP_MMR_YBIST_L_INV_SHFT          40
-#define SH_MD_DQLP_MMR_YBIST_L_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_L_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQLP_MMR_YBIST_L_ROT_SHFT          41
-#define SH_MD_DQLP_MMR_YBIST_L_ROT_MASK          0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_YBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YBIST_ERR_H               0x0000000100038820
-#define SH_MD_DQLP_MMR_YBIST_ERR_H_MASK          0x00000300ffffffff
-#define SH_MD_DQLP_MMR_YBIST_ERR_H_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_ERR_H_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLP_MMR_YBIST_ERR_H_PAT_SHFT      0
-#define SH_MD_DQLP_MMR_YBIST_ERR_H_PAT_MASK      0x00000000ffffffff
-
-/*   SH_MD_DQLP_MMR_YBIST_ERR_H_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQLP_MMR_YBIST_ERR_H_VAL_SHFT      40
-#define SH_MD_DQLP_MMR_YBIST_ERR_H_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_ERR_H_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQLP_MMR_YBIST_ERR_H_MORE_SHFT     41
-#define SH_MD_DQLP_MMR_YBIST_ERR_H_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_YBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLP_MMR_YBIST_ERR_L               0x0000000100038830
-#define SH_MD_DQLP_MMR_YBIST_ERR_L_MASK          0x00000300ffffffff
-#define SH_MD_DQLP_MMR_YBIST_ERR_L_INIT          0x0000000000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_ERR_L_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLP_MMR_YBIST_ERR_L_PAT_SHFT      0
-#define SH_MD_DQLP_MMR_YBIST_ERR_L_PAT_MASK      0x00000000ffffffff
-
-/*   SH_MD_DQLP_MMR_YBIST_ERR_L_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQLP_MMR_YBIST_ERR_L_VAL_SHFT      40
-#define SH_MD_DQLP_MMR_YBIST_ERR_L_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQLP_MMR_YBIST_ERR_L_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQLP_MMR_YBIST_ERR_L_MORE_SHFT     41
-#define SH_MD_DQLP_MMR_YBIST_ERR_L_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLS_MMR_XBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_XBIST_H                   0x0000000100048000
-#define SH_MD_DQLS_MMR_XBIST_H_MASK              0x000007ffffffffff
-#define SH_MD_DQLS_MMR_XBIST_H_INIT              0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_H_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLS_MMR_XBIST_H_PAT_SHFT          0
-#define SH_MD_DQLS_MMR_XBIST_H_PAT_MASK          0x000000ffffffffff
-
-/*   SH_MD_DQLS_MMR_XBIST_H_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQLS_MMR_XBIST_H_INV_SHFT          40
-#define SH_MD_DQLS_MMR_XBIST_H_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_H_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQLS_MMR_XBIST_H_ROT_SHFT          41
-#define SH_MD_DQLS_MMR_XBIST_H_ROT_MASK          0x0000020000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_H_ARM                                         */
-/*   Description:  writing 1 arms data miscompare capture               */
-#define SH_MD_DQLS_MMR_XBIST_H_ARM_SHFT          42
-#define SH_MD_DQLS_MMR_XBIST_H_ARM_MASK          0x0000040000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLS_MMR_XBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_XBIST_L                   0x0000000100048010
-#define SH_MD_DQLS_MMR_XBIST_L_MASK              0x000003ffffffffff
-#define SH_MD_DQLS_MMR_XBIST_L_INIT              0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_L_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLS_MMR_XBIST_L_PAT_SHFT          0
-#define SH_MD_DQLS_MMR_XBIST_L_PAT_MASK          0x000000ffffffffff
-
-/*   SH_MD_DQLS_MMR_XBIST_L_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQLS_MMR_XBIST_L_INV_SHFT          40
-#define SH_MD_DQLS_MMR_XBIST_L_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_L_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQLS_MMR_XBIST_L_ROT_SHFT          41
-#define SH_MD_DQLS_MMR_XBIST_L_ROT_MASK          0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLS_MMR_XBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_XBIST_ERR_H               0x0000000100048020
-#define SH_MD_DQLS_MMR_XBIST_ERR_H_MASK          0x000003ffffffffff
-#define SH_MD_DQLS_MMR_XBIST_ERR_H_INIT          0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_ERR_H_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLS_MMR_XBIST_ERR_H_PAT_SHFT      0
-#define SH_MD_DQLS_MMR_XBIST_ERR_H_PAT_MASK      0x000000ffffffffff
-
-/*   SH_MD_DQLS_MMR_XBIST_ERR_H_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQLS_MMR_XBIST_ERR_H_VAL_SHFT      40
-#define SH_MD_DQLS_MMR_XBIST_ERR_H_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_ERR_H_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQLS_MMR_XBIST_ERR_H_MORE_SHFT     41
-#define SH_MD_DQLS_MMR_XBIST_ERR_H_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLS_MMR_XBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_XBIST_ERR_L               0x0000000100048030
-#define SH_MD_DQLS_MMR_XBIST_ERR_L_MASK          0x000003ffffffffff
-#define SH_MD_DQLS_MMR_XBIST_ERR_L_INIT          0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_ERR_L_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLS_MMR_XBIST_ERR_L_PAT_SHFT      0
-#define SH_MD_DQLS_MMR_XBIST_ERR_L_PAT_MASK      0x000000ffffffffff
-
-/*   SH_MD_DQLS_MMR_XBIST_ERR_L_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQLS_MMR_XBIST_ERR_L_VAL_SHFT      40
-#define SH_MD_DQLS_MMR_XBIST_ERR_L_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQLS_MMR_XBIST_ERR_L_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQLS_MMR_XBIST_ERR_L_MORE_SHFT     41
-#define SH_MD_DQLS_MMR_XBIST_ERR_L_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLS_MMR_YBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_YBIST_H                   0x0000000100048800
-#define SH_MD_DQLS_MMR_YBIST_H_MASK              0x000007ffffffffff
-#define SH_MD_DQLS_MMR_YBIST_H_INIT              0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_H_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLS_MMR_YBIST_H_PAT_SHFT          0
-#define SH_MD_DQLS_MMR_YBIST_H_PAT_MASK          0x000000ffffffffff
-
-/*   SH_MD_DQLS_MMR_YBIST_H_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQLS_MMR_YBIST_H_INV_SHFT          40
-#define SH_MD_DQLS_MMR_YBIST_H_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_H_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQLS_MMR_YBIST_H_ROT_SHFT          41
-#define SH_MD_DQLS_MMR_YBIST_H_ROT_MASK          0x0000020000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_H_ARM                                         */
-/*   Description:  writing 1 arms data miscompare capture               */
-#define SH_MD_DQLS_MMR_YBIST_H_ARM_SHFT          42
-#define SH_MD_DQLS_MMR_YBIST_H_ARM_MASK          0x0000040000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLS_MMR_YBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_YBIST_L                   0x0000000100048810
-#define SH_MD_DQLS_MMR_YBIST_L_MASK              0x000003ffffffffff
-#define SH_MD_DQLS_MMR_YBIST_L_INIT              0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_L_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLS_MMR_YBIST_L_PAT_SHFT          0
-#define SH_MD_DQLS_MMR_YBIST_L_PAT_MASK          0x000000ffffffffff
-
-/*   SH_MD_DQLS_MMR_YBIST_L_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQLS_MMR_YBIST_L_INV_SHFT          40
-#define SH_MD_DQLS_MMR_YBIST_L_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_L_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQLS_MMR_YBIST_L_ROT_SHFT          41
-#define SH_MD_DQLS_MMR_YBIST_L_ROT_MASK          0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLS_MMR_YBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_YBIST_ERR_H               0x0000000100048820
-#define SH_MD_DQLS_MMR_YBIST_ERR_H_MASK          0x000003ffffffffff
-#define SH_MD_DQLS_MMR_YBIST_ERR_H_INIT          0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_ERR_H_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLS_MMR_YBIST_ERR_H_PAT_SHFT      0
-#define SH_MD_DQLS_MMR_YBIST_ERR_H_PAT_MASK      0x000000ffffffffff
-
-/*   SH_MD_DQLS_MMR_YBIST_ERR_H_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQLS_MMR_YBIST_ERR_H_VAL_SHFT      40
-#define SH_MD_DQLS_MMR_YBIST_ERR_H_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_ERR_H_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQLS_MMR_YBIST_ERR_H_MORE_SHFT     41
-#define SH_MD_DQLS_MMR_YBIST_ERR_H_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLS_MMR_YBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_YBIST_ERR_L               0x0000000100048830
-#define SH_MD_DQLS_MMR_YBIST_ERR_L_MASK          0x000003ffffffffff
-#define SH_MD_DQLS_MMR_YBIST_ERR_L_INIT          0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_ERR_L_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQLS_MMR_YBIST_ERR_L_PAT_SHFT      0
-#define SH_MD_DQLS_MMR_YBIST_ERR_L_PAT_MASK      0x000000ffffffffff
-
-/*   SH_MD_DQLS_MMR_YBIST_ERR_L_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQLS_MMR_YBIST_ERR_L_VAL_SHFT      40
-#define SH_MD_DQLS_MMR_YBIST_ERR_L_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQLS_MMR_YBIST_ERR_L_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQLS_MMR_YBIST_ERR_L_MORE_SHFT     41
-#define SH_MD_DQLS_MMR_YBIST_ERR_L_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQLS_MMR_JNR_DEBUG"                  */
-/*                    joiner/fct debug configuration                    */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_JNR_DEBUG                 0x0000000100049000
-#define SH_MD_DQLS_MMR_JNR_DEBUG_MASK            0x0000000000000003
-#define SH_MD_DQLS_MMR_JNR_DEBUG_INIT            0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_JNR_DEBUG_PX                                        */
-/*   Description:  select 0=pi 1=xn side                                */
-#define SH_MD_DQLS_MMR_JNR_DEBUG_PX_SHFT         0
-#define SH_MD_DQLS_MMR_JNR_DEBUG_PX_MASK         0x0000000000000001
-
-/*   SH_MD_DQLS_MMR_JNR_DEBUG_RW                                        */
-/*   Description:  select 0=read 1=write side                           */
-#define SH_MD_DQLS_MMR_JNR_DEBUG_RW_SHFT         1
-#define SH_MD_DQLS_MMR_JNR_DEBUG_RW_MASK         0x0000000000000002
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQLS_MMR_XAMOPW_ERR"                 */
-/*                  amo/partial rmw ecc error register                  */
-/* ==================================================================== */
-
-#define SH_MD_DQLS_MMR_XAMOPW_ERR                0x000000010004a000
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_MASK           0x0000000103ff03ff
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_INIT           0x0000000000000000
-
-/*   SH_MD_DQLS_MMR_XAMOPW_ERR_SSYN                                     */
-/*   Description:  store data syndrome                                  */
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_SSYN_SHFT      0
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_SSYN_MASK      0x00000000000000ff
-
-/*   SH_MD_DQLS_MMR_XAMOPW_ERR_SCOR                                     */
-/*   Description:  correctable ecc errror on store data                 */
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_SCOR_SHFT      8
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_SCOR_MASK      0x0000000000000100
-
-/*   SH_MD_DQLS_MMR_XAMOPW_ERR_SUNC                                     */
-/*   Description:  uncorrectable ecc errror on store data               */
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_SUNC_SHFT      9
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_SUNC_MASK      0x0000000000000200
-
-/*   SH_MD_DQLS_MMR_XAMOPW_ERR_RSYN                                     */
-/*   Description:  memory read data syndrome                            */
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_RSYN_SHFT      16
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_RSYN_MASK      0x0000000000ff0000
-
-/*   SH_MD_DQLS_MMR_XAMOPW_ERR_RCOR                                     */
-/*   Description:  correctable ecc errror on read data                  */
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_RCOR_SHFT      24
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_RCOR_MASK      0x0000000001000000
-
-/*   SH_MD_DQLS_MMR_XAMOPW_ERR_RUNC                                     */
-/*   Description:  uncorrectable ecc errror on read data                */
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_RUNC_SHFT      25
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_RUNC_MASK      0x0000000002000000
-
-/*   SH_MD_DQLS_MMR_XAMOPW_ERR_ARM                                      */
-/*   Description:  writing 1 arms ecc error capture                     */
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_ARM_SHFT       32
-#define SH_MD_DQLS_MMR_XAMOPW_ERR_ARM_MASK       0x0000000100000000
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQRP_MMR_DIR_CONFIG"                 */
-/*                     DQ directory config register                     */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_CONFIG                0x0000000100050000
-#define SH_MD_DQRP_MMR_DIR_CONFIG_MASK           0x000000000000001f
-#define SH_MD_DQRP_MMR_DIR_CONFIG_INIT           0x0000000000000010
-
-/*   SH_MD_DQRP_MMR_DIR_CONFIG_SYS_SIZE                                 */
-/*   Description:  system size code                                     */
-#define SH_MD_DQRP_MMR_DIR_CONFIG_SYS_SIZE_SHFT  0
-#define SH_MD_DQRP_MMR_DIR_CONFIG_SYS_SIZE_MASK  0x0000000000000007
-
-/*   SH_MD_DQRP_MMR_DIR_CONFIG_EN_DIRECC                                */
-/*   Description:  enable directory ecc correction                      */
-#define SH_MD_DQRP_MMR_DIR_CONFIG_EN_DIRECC_SHFT 3
-#define SH_MD_DQRP_MMR_DIR_CONFIG_EN_DIRECC_MASK 0x0000000000000008
-
-/*   SH_MD_DQRP_MMR_DIR_CONFIG_EN_DIRPOIS                               */
-/*   Description:  enable local poisoning for dir table fall-through    */
-#define SH_MD_DQRP_MMR_DIR_CONFIG_EN_DIRPOIS_SHFT 4
-#define SH_MD_DQRP_MMR_DIR_CONFIG_EN_DIRPOIS_MASK 0x0000000000000010
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRESVEC0"                */
-/*                      node [63:0] presence bits                       */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRESVEC0              0x0000000100050100
-#define SH_MD_DQRP_MMR_DIR_PRESVEC0_MASK         0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_PRESVEC0_INIT         0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRESVEC0_VEC                                    */
-/*   Description:  node presence bits, 1=present                        */
-#define SH_MD_DQRP_MMR_DIR_PRESVEC0_VEC_SHFT     0
-#define SH_MD_DQRP_MMR_DIR_PRESVEC0_VEC_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRESVEC1"                */
-/*                     node [127:64] presence bits                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRESVEC1              0x0000000100050110
-#define SH_MD_DQRP_MMR_DIR_PRESVEC1_MASK         0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_PRESVEC1_INIT         0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRESVEC1_VEC                                    */
-/*   Description:  node presence bits, 1=present                        */
-#define SH_MD_DQRP_MMR_DIR_PRESVEC1_VEC_SHFT     0
-#define SH_MD_DQRP_MMR_DIR_PRESVEC1_VEC_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRESVEC2"                */
-/*                     node [191:128] presence bits                     */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRESVEC2              0x0000000100050120
-#define SH_MD_DQRP_MMR_DIR_PRESVEC2_MASK         0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_PRESVEC2_INIT         0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRESVEC2_VEC                                    */
-/*   Description:  node presence bits, 1=present                        */
-#define SH_MD_DQRP_MMR_DIR_PRESVEC2_VEC_SHFT     0
-#define SH_MD_DQRP_MMR_DIR_PRESVEC2_VEC_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRESVEC3"                */
-/*                     node [255:192] presence bits                     */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRESVEC3              0x0000000100050130
-#define SH_MD_DQRP_MMR_DIR_PRESVEC3_MASK         0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_PRESVEC3_INIT         0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRESVEC3_VEC                                    */
-/*   Description:  node presence bits, 1=present                        */
-#define SH_MD_DQRP_MMR_DIR_PRESVEC3_VEC_SHFT     0
-#define SH_MD_DQRP_MMR_DIR_PRESVEC3_VEC_MASK     0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC0"                 */
-/*                        local vector for acc=0                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_LOCVEC0               0x0000000100050200
-#define SH_MD_DQRP_MMR_DIR_LOCVEC0_MASK          0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_LOCVEC0_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_LOCVEC0_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQRP_MMR_DIR_LOCVEC0_VEC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_LOCVEC0_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC1"                 */
-/*                        local vector for acc=1                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_LOCVEC1               0x0000000100050210
-#define SH_MD_DQRP_MMR_DIR_LOCVEC1_MASK          0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_LOCVEC1_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_LOCVEC1_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQRP_MMR_DIR_LOCVEC1_VEC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_LOCVEC1_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC2"                 */
-/*                        local vector for acc=2                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_LOCVEC2               0x0000000100050220
-#define SH_MD_DQRP_MMR_DIR_LOCVEC2_MASK          0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_LOCVEC2_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_LOCVEC2_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQRP_MMR_DIR_LOCVEC2_VEC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_LOCVEC2_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC3"                 */
-/*                        local vector for acc=3                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_LOCVEC3               0x0000000100050230
-#define SH_MD_DQRP_MMR_DIR_LOCVEC3_MASK          0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_LOCVEC3_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_LOCVEC3_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQRP_MMR_DIR_LOCVEC3_VEC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_LOCVEC3_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC4"                 */
-/*                        local vector for acc=4                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_LOCVEC4               0x0000000100050240
-#define SH_MD_DQRP_MMR_DIR_LOCVEC4_MASK          0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_LOCVEC4_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_LOCVEC4_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQRP_MMR_DIR_LOCVEC4_VEC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_LOCVEC4_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC5"                 */
-/*                        local vector for acc=5                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_LOCVEC5               0x0000000100050250
-#define SH_MD_DQRP_MMR_DIR_LOCVEC5_MASK          0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_LOCVEC5_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_LOCVEC5_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQRP_MMR_DIR_LOCVEC5_VEC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_LOCVEC5_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC6"                 */
-/*                        local vector for acc=6                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_LOCVEC6               0x0000000100050260
-#define SH_MD_DQRP_MMR_DIR_LOCVEC6_MASK          0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_LOCVEC6_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_LOCVEC6_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQRP_MMR_DIR_LOCVEC6_VEC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_LOCVEC6_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC7"                 */
-/*                        local vector for acc=7                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_LOCVEC7               0x0000000100050270
-#define SH_MD_DQRP_MMR_DIR_LOCVEC7_MASK          0xffffffffffffffff
-#define SH_MD_DQRP_MMR_DIR_LOCVEC7_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_LOCVEC7_VEC                                     */
-/*   Description:  1 node is local                                      */
-#define SH_MD_DQRP_MMR_DIR_LOCVEC7_VEC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_LOCVEC7_VEC_MASK      0xffffffffffffffff
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC0"                 */
-/*                      privilege vector for acc=0                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRIVEC0               0x0000000100050300
-#define SH_MD_DQRP_MMR_DIR_PRIVEC0_MASK          0x000000000fffffff
-#define SH_MD_DQRP_MMR_DIR_PRIVEC0_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC0_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC0_IN_SHFT       0
-#define SH_MD_DQRP_MMR_DIR_PRIVEC0_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC0_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC0_OUT_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_PRIVEC0_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC1"                 */
-/*                      privilege vector for acc=1                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRIVEC1               0x0000000100050310
-#define SH_MD_DQRP_MMR_DIR_PRIVEC1_MASK          0x000000000fffffff
-#define SH_MD_DQRP_MMR_DIR_PRIVEC1_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC1_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC1_IN_SHFT       0
-#define SH_MD_DQRP_MMR_DIR_PRIVEC1_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC1_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC1_OUT_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_PRIVEC1_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC2"                 */
-/*                      privilege vector for acc=2                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRIVEC2               0x0000000100050320
-#define SH_MD_DQRP_MMR_DIR_PRIVEC2_MASK          0x000000000fffffff
-#define SH_MD_DQRP_MMR_DIR_PRIVEC2_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC2_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC2_IN_SHFT       0
-#define SH_MD_DQRP_MMR_DIR_PRIVEC2_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC2_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC2_OUT_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_PRIVEC2_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC3"                 */
-/*                      privilege vector for acc=3                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRIVEC3               0x0000000100050330
-#define SH_MD_DQRP_MMR_DIR_PRIVEC3_MASK          0x000000000fffffff
-#define SH_MD_DQRP_MMR_DIR_PRIVEC3_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC3_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC3_IN_SHFT       0
-#define SH_MD_DQRP_MMR_DIR_PRIVEC3_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC3_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC3_OUT_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_PRIVEC3_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC4"                 */
-/*                      privilege vector for acc=4                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRIVEC4               0x0000000100050340
-#define SH_MD_DQRP_MMR_DIR_PRIVEC4_MASK          0x000000000fffffff
-#define SH_MD_DQRP_MMR_DIR_PRIVEC4_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC4_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC4_IN_SHFT       0
-#define SH_MD_DQRP_MMR_DIR_PRIVEC4_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC4_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC4_OUT_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_PRIVEC4_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC5"                 */
-/*                      privilege vector for acc=5                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRIVEC5               0x0000000100050350
-#define SH_MD_DQRP_MMR_DIR_PRIVEC5_MASK          0x000000000fffffff
-#define SH_MD_DQRP_MMR_DIR_PRIVEC5_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC5_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC5_IN_SHFT       0
-#define SH_MD_DQRP_MMR_DIR_PRIVEC5_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC5_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC5_OUT_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_PRIVEC5_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC6"                 */
-/*                      privilege vector for acc=6                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRIVEC6               0x0000000100050360
-#define SH_MD_DQRP_MMR_DIR_PRIVEC6_MASK          0x000000000fffffff
-#define SH_MD_DQRP_MMR_DIR_PRIVEC6_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC6_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC6_IN_SHFT       0
-#define SH_MD_DQRP_MMR_DIR_PRIVEC6_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC6_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC6_OUT_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_PRIVEC6_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC7"                 */
-/*                      privilege vector for acc=7                      */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_PRIVEC7               0x0000000100050370
-#define SH_MD_DQRP_MMR_DIR_PRIVEC7_MASK          0x000000000fffffff
-#define SH_MD_DQRP_MMR_DIR_PRIVEC7_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC7_IN                                      */
-/*   Description:  in partition privileges, locvec bit=1                */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC7_IN_SHFT       0
-#define SH_MD_DQRP_MMR_DIR_PRIVEC7_IN_MASK       0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_PRIVEC7_OUT                                     */
-/*   Description:  out of partition privileges, locvec bit=0            */
-#define SH_MD_DQRP_MMR_DIR_PRIVEC7_OUT_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_PRIVEC7_OUT_MASK      0x000000000fffc000
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQRP_MMR_DIR_TIMER"                  */
-/*                            MD SXRO timer                             */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_TIMER                 0x0000000100050400
-#define SH_MD_DQRP_MMR_DIR_TIMER_MASK            0x00000000003fffff
-#define SH_MD_DQRP_MMR_DIR_TIMER_INIT            0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_TIMER_TIMER_DIV                                 */
-/*   Description:  timer divide register                                */
-#define SH_MD_DQRP_MMR_DIR_TIMER_TIMER_DIV_SHFT  0
-#define SH_MD_DQRP_MMR_DIR_TIMER_TIMER_DIV_MASK  0x0000000000000fff
-
-/*   SH_MD_DQRP_MMR_DIR_TIMER_TIMER_EN                                  */
-/*   Description:  timer enable                                         */
-#define SH_MD_DQRP_MMR_DIR_TIMER_TIMER_EN_SHFT   12
-#define SH_MD_DQRP_MMR_DIR_TIMER_TIMER_EN_MASK   0x0000000000001000
-
-/*   SH_MD_DQRP_MMR_DIR_TIMER_TIMER_CUR                                 */
-/*   Description:  value of current timer                               */
-#define SH_MD_DQRP_MMR_DIR_TIMER_TIMER_CUR_SHFT  13
-#define SH_MD_DQRP_MMR_DIR_TIMER_TIMER_CUR_MASK  0x00000000003fe000
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY"               */
-/*                       directory pio write data                       */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY           0x0000000100051000
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_MASK      0x03ffffffffffffff
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_INIT      0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_DIRA                                */
-/*   Description:  directory entry A                                    */
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_DIRA_SHFT 0
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_DIRA_MASK 0x0000000003ffffff
-
-/*   SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_DIRB                                */
-/*   Description:  directory entry B                                    */
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_DIRB_SHFT 26
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_DIRB_MASK 0x000ffffffc000000
-
-/*   SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_PRI                                 */
-/*   Description:  directory priority                                   */
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_PRI_SHFT  52
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_PRI_MASK  0x0070000000000000
-
-/*   SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_ACC                                 */
-/*   Description:  directory access bits                                */
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_ACC_SHFT  55
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY_ACC_MASK  0x0380000000000000
-
-/* ==================================================================== */
-/*               Register "SH_MD_DQRP_MMR_PIOWD_DIR_ECC"                */
-/*                        directory ecc register                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ECC             0x0000000100051010
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ECC_MASK        0x0000000000003fff
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ECC_INIT        0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_PIOWD_DIR_ECC_ECCA                                  */
-/*   Description:  XOR bits for directory ECC group 1                   */
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ECC_ECCA_SHFT   0
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ECC_ECCA_MASK   0x000000000000007f
-
-/*   SH_MD_DQRP_MMR_PIOWD_DIR_ECC_ECCB                                  */
-/*   Description:  XOR bits for directory ECC group 2                   */
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ECC_ECCB_SHFT   7
-#define SH_MD_DQRP_MMR_PIOWD_DIR_ECC_ECCB_MASK   0x0000000000003f80
-
-/* ==================================================================== */
-/*             Register "SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY"              */
-/*                      x directory pio read data                       */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY         0x0000000100052000
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_MASK    0x0fffffffffffffff
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_INIT    0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_DIRA                              */
-/*   Description:  directory entry A                                    */
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_DIRA_SHFT 0
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_DIRA_MASK 0x0000000003ffffff
-
-/*   SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_DIRB                              */
-/*   Description:  directory entry B                                    */
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_DIRB_SHFT 26
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_DIRB_MASK 0x000ffffffc000000
-
-/*   SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_PRI                               */
-/*   Description:  directory priority                                   */
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_PRI_SHFT 52
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_PRI_MASK 0x0070000000000000
-
-/*   SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_ACC                               */
-/*   Description:  directory access bits                                */
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_ACC_SHFT 55
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_ACC_MASK 0x0380000000000000
-
-/*   SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_COR                               */
-/*   Description:  correctable ecc error                                */
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_COR_SHFT 58
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_COR_MASK 0x0400000000000000
-
-/*   SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_UNC                               */
-/*   Description:  uncorrectable ecc error                              */
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_UNC_SHFT 59
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY_UNC_MASK 0x0800000000000000
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQRP_MMR_XPIORD_XDIR_ECC"               */
-/*                           x directory ecc                            */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ECC           0x0000000100052010
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ECC_MASK      0x0000000000003fff
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ECC_INIT      0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XPIORD_XDIR_ECC_ECCA                                */
-/*   Description:  group 1 ecc                                          */
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ECC_ECCA_SHFT 0
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ECC_ECCA_MASK 0x000000000000007f
-
-/*   SH_MD_DQRP_MMR_XPIORD_XDIR_ECC_ECCB                                */
-/*   Description:  group 2 ecc                                          */
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ECC_ECCB_SHFT 7
-#define SH_MD_DQRP_MMR_XPIORD_XDIR_ECC_ECCB_MASK 0x0000000000003f80
-
-/* ==================================================================== */
-/*             Register "SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY"              */
-/*                      y directory pio read data                       */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY         0x0000000100052800
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_MASK    0x0fffffffffffffff
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_INIT    0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_DIRA                              */
-/*   Description:  directory entry A                                    */
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_DIRA_SHFT 0
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_DIRA_MASK 0x0000000003ffffff
-
-/*   SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_DIRB                              */
-/*   Description:  directory entry B                                    */
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_DIRB_SHFT 26
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_DIRB_MASK 0x000ffffffc000000
-
-/*   SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_PRI                               */
-/*   Description:  directory priority                                   */
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_PRI_SHFT 52
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_PRI_MASK 0x0070000000000000
-
-/*   SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_ACC                               */
-/*   Description:  directory access bits                                */
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_ACC_SHFT 55
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_ACC_MASK 0x0380000000000000
-
-/*   SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_COR                               */
-/*   Description:  correctable ecc error                                */
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_COR_SHFT 58
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_COR_MASK 0x0400000000000000
-
-/*   SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_UNC                               */
-/*   Description:  uncorrectable ecc error                              */
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_UNC_SHFT 59
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY_UNC_MASK 0x0800000000000000
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQRP_MMR_YPIORD_YDIR_ECC"               */
-/*                           y directory ecc                            */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ECC           0x0000000100052810
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ECC_MASK      0x0000000000003fff
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ECC_INIT      0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YPIORD_YDIR_ECC_ECCA                                */
-/*   Description:  group 1 ecc                                          */
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ECC_ECCA_SHFT 0
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ECC_ECCA_MASK 0x000000000000007f
-
-/*   SH_MD_DQRP_MMR_YPIORD_YDIR_ECC_ECCB                                */
-/*   Description:  group 2 ecc                                          */
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ECC_ECCB_SHFT 7
-#define SH_MD_DQRP_MMR_YPIORD_YDIR_ECC_ECCB_MASK 0x0000000000003f80
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XCERR1"                   */
-/*              correctable dir ecc group 1 error register              */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XCERR1                    0x0000000100053000
-#define SH_MD_DQRP_MMR_XCERR1_MASK               0x0000007fffffffff
-#define SH_MD_DQRP_MMR_XCERR1_INIT               0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XCERR1_GRP1                                         */
-/*   Description:  ecc group 1 bits                                     */
-#define SH_MD_DQRP_MMR_XCERR1_GRP1_SHFT          0
-#define SH_MD_DQRP_MMR_XCERR1_GRP1_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQRP_MMR_XCERR1_VAL                                          */
-/*   Description:  correctable ecc error in group 1 bits                */
-#define SH_MD_DQRP_MMR_XCERR1_VAL_SHFT           36
-#define SH_MD_DQRP_MMR_XCERR1_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQRP_MMR_XCERR1_MORE                                         */
-/*   Description:  more than one correctable ecc error in group 1       */
-#define SH_MD_DQRP_MMR_XCERR1_MORE_SHFT          37
-#define SH_MD_DQRP_MMR_XCERR1_MORE_MASK          0x0000002000000000
-
-/*   SH_MD_DQRP_MMR_XCERR1_ARM                                          */
-/*   Description:  writing 1 arms uncorrectable ecc error capture       */
-#define SH_MD_DQRP_MMR_XCERR1_ARM_SHFT           38
-#define SH_MD_DQRP_MMR_XCERR1_ARM_MASK           0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XCERR2"                   */
-/*              correctable dir ecc group 2 error register              */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XCERR2                    0x0000000100053010
-#define SH_MD_DQRP_MMR_XCERR2_MASK               0x0000003fffffffff
-#define SH_MD_DQRP_MMR_XCERR2_INIT               0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XCERR2_GRP2                                         */
-/*   Description:  ecc group 2 bits                                     */
-#define SH_MD_DQRP_MMR_XCERR2_GRP2_SHFT          0
-#define SH_MD_DQRP_MMR_XCERR2_GRP2_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQRP_MMR_XCERR2_VAL                                          */
-/*   Description:  correctable ecc error in group 2 bits                */
-#define SH_MD_DQRP_MMR_XCERR2_VAL_SHFT           36
-#define SH_MD_DQRP_MMR_XCERR2_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQRP_MMR_XCERR2_MORE                                         */
-/*   Description:  more than one correctable ecc error in group 2       */
-#define SH_MD_DQRP_MMR_XCERR2_MORE_SHFT          37
-#define SH_MD_DQRP_MMR_XCERR2_MORE_MASK          0x0000002000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XUERR1"                   */
-/*             uncorrectable dir ecc group 1 error register             */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XUERR1                    0x0000000100053020
-#define SH_MD_DQRP_MMR_XUERR1_MASK               0x0000007fffffffff
-#define SH_MD_DQRP_MMR_XUERR1_INIT               0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XUERR1_GRP1                                         */
-/*   Description:  ecc group 1 bits                                     */
-#define SH_MD_DQRP_MMR_XUERR1_GRP1_SHFT          0
-#define SH_MD_DQRP_MMR_XUERR1_GRP1_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQRP_MMR_XUERR1_VAL                                          */
-/*   Description:  uncorrectable ecc error in group 1 bits              */
-#define SH_MD_DQRP_MMR_XUERR1_VAL_SHFT           36
-#define SH_MD_DQRP_MMR_XUERR1_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQRP_MMR_XUERR1_MORE                                         */
-/*   Description:  more than one uncorrectable ecc error in group 1     */
-#define SH_MD_DQRP_MMR_XUERR1_MORE_SHFT          37
-#define SH_MD_DQRP_MMR_XUERR1_MORE_MASK          0x0000002000000000
-
-/*   SH_MD_DQRP_MMR_XUERR1_ARM                                          */
-/*   Description:  writing 1 arms uncorrectable ecc error capture       */
-#define SH_MD_DQRP_MMR_XUERR1_ARM_SHFT           38
-#define SH_MD_DQRP_MMR_XUERR1_ARM_MASK           0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XUERR2"                   */
-/*             uncorrectable dir ecc group 2 error register             */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XUERR2                    0x0000000100053030
-#define SH_MD_DQRP_MMR_XUERR2_MASK               0x0000003fffffffff
-#define SH_MD_DQRP_MMR_XUERR2_INIT               0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XUERR2_GRP2                                         */
-/*   Description:  ecc group 2 bits                                     */
-#define SH_MD_DQRP_MMR_XUERR2_GRP2_SHFT          0
-#define SH_MD_DQRP_MMR_XUERR2_GRP2_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQRP_MMR_XUERR2_VAL                                          */
-/*   Description:  uncorrectable ecc error in group 2 bits              */
-#define SH_MD_DQRP_MMR_XUERR2_VAL_SHFT           36
-#define SH_MD_DQRP_MMR_XUERR2_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQRP_MMR_XUERR2_MORE                                         */
-/*   Description:  more than one uncorrectable ecc error in group 2     */
-#define SH_MD_DQRP_MMR_XUERR2_MORE_SHFT          37
-#define SH_MD_DQRP_MMR_XUERR2_MORE_MASK          0x0000002000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XPERR"                    */
-/*                       protocol error register                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XPERR                     0x0000000100053040
-#define SH_MD_DQRP_MMR_XPERR_MASK                0x7fffffffffffffff
-#define SH_MD_DQRP_MMR_XPERR_INIT                0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XPERR_DIR                                           */
-/*   Description:  directory entry                                      */
-#define SH_MD_DQRP_MMR_XPERR_DIR_SHFT            0
-#define SH_MD_DQRP_MMR_XPERR_DIR_MASK            0x0000000003ffffff
-
-/*   SH_MD_DQRP_MMR_XPERR_CMD                                           */
-/*   Description:  incoming command                                     */
-#define SH_MD_DQRP_MMR_XPERR_CMD_SHFT            26
-#define SH_MD_DQRP_MMR_XPERR_CMD_MASK            0x00000003fc000000
-
-/*   SH_MD_DQRP_MMR_XPERR_SRC                                           */
-/*   Description:  source node of dir operation                         */
-#define SH_MD_DQRP_MMR_XPERR_SRC_SHFT            34
-#define SH_MD_DQRP_MMR_XPERR_SRC_MASK            0x0000fffc00000000
-
-/*   SH_MD_DQRP_MMR_XPERR_PRIGE                                         */
-/*   Description:  priority was greater-equal                           */
-#define SH_MD_DQRP_MMR_XPERR_PRIGE_SHFT          48
-#define SH_MD_DQRP_MMR_XPERR_PRIGE_MASK          0x0001000000000000
-
-/*   SH_MD_DQRP_MMR_XPERR_PRIV                                          */
-/*   Description:  access privilege bit                                 */
-#define SH_MD_DQRP_MMR_XPERR_PRIV_SHFT           49
-#define SH_MD_DQRP_MMR_XPERR_PRIV_MASK           0x0002000000000000
-
-/*   SH_MD_DQRP_MMR_XPERR_COR                                           */
-/*   Description:  correctable ecc error                                */
-#define SH_MD_DQRP_MMR_XPERR_COR_SHFT            50
-#define SH_MD_DQRP_MMR_XPERR_COR_MASK            0x0004000000000000
-
-/*   SH_MD_DQRP_MMR_XPERR_UNC                                           */
-/*   Description:  uncorrectable ecc error                              */
-#define SH_MD_DQRP_MMR_XPERR_UNC_SHFT            51
-#define SH_MD_DQRP_MMR_XPERR_UNC_MASK            0x0008000000000000
-
-/*   SH_MD_DQRP_MMR_XPERR_MYBIT                                         */
-/*   Description:  ptreq,timeq,timlast,timspec,onlyme,anytim,ptrii,src  */
-#define SH_MD_DQRP_MMR_XPERR_MYBIT_SHFT          52
-#define SH_MD_DQRP_MMR_XPERR_MYBIT_MASK          0x0ff0000000000000
-
-/*   SH_MD_DQRP_MMR_XPERR_VAL                                           */
-/*   Description:  protocol error info valid                            */
-#define SH_MD_DQRP_MMR_XPERR_VAL_SHFT            60
-#define SH_MD_DQRP_MMR_XPERR_VAL_MASK            0x1000000000000000
-
-/*   SH_MD_DQRP_MMR_XPERR_MORE                                          */
-/*   Description:  more than one protocol error                         */
-#define SH_MD_DQRP_MMR_XPERR_MORE_SHFT           61
-#define SH_MD_DQRP_MMR_XPERR_MORE_MASK           0x2000000000000000
-
-/*   SH_MD_DQRP_MMR_XPERR_ARM                                           */
-/*   Description:  writing 1 arms error capture                         */
-#define SH_MD_DQRP_MMR_XPERR_ARM_SHFT            62
-#define SH_MD_DQRP_MMR_XPERR_ARM_MASK            0x4000000000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YCERR1"                   */
-/*              correctable dir ecc group 1 error register              */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YCERR1                    0x0000000100053800
-#define SH_MD_DQRP_MMR_YCERR1_MASK               0x0000007fffffffff
-#define SH_MD_DQRP_MMR_YCERR1_INIT               0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YCERR1_GRP1                                         */
-/*   Description:  ecc group 1 bits                                     */
-#define SH_MD_DQRP_MMR_YCERR1_GRP1_SHFT          0
-#define SH_MD_DQRP_MMR_YCERR1_GRP1_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQRP_MMR_YCERR1_VAL                                          */
-/*   Description:  correctable ecc error in group 1 bits                */
-#define SH_MD_DQRP_MMR_YCERR1_VAL_SHFT           36
-#define SH_MD_DQRP_MMR_YCERR1_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQRP_MMR_YCERR1_MORE                                         */
-/*   Description:  more than one correctable ecc error in group 1       */
-#define SH_MD_DQRP_MMR_YCERR1_MORE_SHFT          37
-#define SH_MD_DQRP_MMR_YCERR1_MORE_MASK          0x0000002000000000
-
-/*   SH_MD_DQRP_MMR_YCERR1_ARM                                          */
-/*   Description:  writing 1 arms uncorrectable ecc error capture       */
-#define SH_MD_DQRP_MMR_YCERR1_ARM_SHFT           38
-#define SH_MD_DQRP_MMR_YCERR1_ARM_MASK           0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YCERR2"                   */
-/*              correctable dir ecc group 2 error register              */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YCERR2                    0x0000000100053810
-#define SH_MD_DQRP_MMR_YCERR2_MASK               0x0000003fffffffff
-#define SH_MD_DQRP_MMR_YCERR2_INIT               0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YCERR2_GRP2                                         */
-/*   Description:  ecc group 2 bits                                     */
-#define SH_MD_DQRP_MMR_YCERR2_GRP2_SHFT          0
-#define SH_MD_DQRP_MMR_YCERR2_GRP2_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQRP_MMR_YCERR2_VAL                                          */
-/*   Description:  correctable ecc error in group 2 bits                */
-#define SH_MD_DQRP_MMR_YCERR2_VAL_SHFT           36
-#define SH_MD_DQRP_MMR_YCERR2_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQRP_MMR_YCERR2_MORE                                         */
-/*   Description:  more than one correctable ecc error in group 2       */
-#define SH_MD_DQRP_MMR_YCERR2_MORE_SHFT          37
-#define SH_MD_DQRP_MMR_YCERR2_MORE_MASK          0x0000002000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YUERR1"                   */
-/*             uncorrectable dir ecc group 1 error register             */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YUERR1                    0x0000000100053820
-#define SH_MD_DQRP_MMR_YUERR1_MASK               0x0000007fffffffff
-#define SH_MD_DQRP_MMR_YUERR1_INIT               0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YUERR1_GRP1                                         */
-/*   Description:  ecc group 1 bits                                     */
-#define SH_MD_DQRP_MMR_YUERR1_GRP1_SHFT          0
-#define SH_MD_DQRP_MMR_YUERR1_GRP1_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQRP_MMR_YUERR1_VAL                                          */
-/*   Description:  uncorrectable ecc error in group 1 bits              */
-#define SH_MD_DQRP_MMR_YUERR1_VAL_SHFT           36
-#define SH_MD_DQRP_MMR_YUERR1_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQRP_MMR_YUERR1_MORE                                         */
-/*   Description:  more than one uncorrectable ecc error in group 1     */
-#define SH_MD_DQRP_MMR_YUERR1_MORE_SHFT          37
-#define SH_MD_DQRP_MMR_YUERR1_MORE_MASK          0x0000002000000000
-
-/*   SH_MD_DQRP_MMR_YUERR1_ARM                                          */
-/*   Description:  writing 1 arms uncorrectable ecc error capture       */
-#define SH_MD_DQRP_MMR_YUERR1_ARM_SHFT           38
-#define SH_MD_DQRP_MMR_YUERR1_ARM_MASK           0x0000004000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YUERR2"                   */
-/*             uncorrectable dir ecc group 2 error register             */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YUERR2                    0x0000000100053830
-#define SH_MD_DQRP_MMR_YUERR2_MASK               0x0000003fffffffff
-#define SH_MD_DQRP_MMR_YUERR2_INIT               0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YUERR2_GRP2                                         */
-/*   Description:  ecc group 2 bits                                     */
-#define SH_MD_DQRP_MMR_YUERR2_GRP2_SHFT          0
-#define SH_MD_DQRP_MMR_YUERR2_GRP2_MASK          0x0000000fffffffff
-
-/*   SH_MD_DQRP_MMR_YUERR2_VAL                                          */
-/*   Description:  uncorrectable ecc error in group 2 bits              */
-#define SH_MD_DQRP_MMR_YUERR2_VAL_SHFT           36
-#define SH_MD_DQRP_MMR_YUERR2_VAL_MASK           0x0000001000000000
-
-/*   SH_MD_DQRP_MMR_YUERR2_MORE                                         */
-/*   Description:  more than one uncorrectable ecc error in group 2     */
-#define SH_MD_DQRP_MMR_YUERR2_MORE_SHFT          37
-#define SH_MD_DQRP_MMR_YUERR2_MORE_MASK          0x0000002000000000
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YPERR"                    */
-/*                       protocol error register                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YPERR                     0x0000000100053840
-#define SH_MD_DQRP_MMR_YPERR_MASK                0x7fffffffffffffff
-#define SH_MD_DQRP_MMR_YPERR_INIT                0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YPERR_DIR                                           */
-/*   Description:  directory entry                                      */
-#define SH_MD_DQRP_MMR_YPERR_DIR_SHFT            0
-#define SH_MD_DQRP_MMR_YPERR_DIR_MASK            0x0000000003ffffff
-
-/*   SH_MD_DQRP_MMR_YPERR_CMD                                           */
-/*   Description:  incoming command                                     */
-#define SH_MD_DQRP_MMR_YPERR_CMD_SHFT            26
-#define SH_MD_DQRP_MMR_YPERR_CMD_MASK            0x00000003fc000000
-
-/*   SH_MD_DQRP_MMR_YPERR_SRC                                           */
-/*   Description:  source node of dir operation                         */
-#define SH_MD_DQRP_MMR_YPERR_SRC_SHFT            34
-#define SH_MD_DQRP_MMR_YPERR_SRC_MASK            0x0000fffc00000000
-
-/*   SH_MD_DQRP_MMR_YPERR_PRIGE                                         */
-/*   Description:  priority was greater-equal                           */
-#define SH_MD_DQRP_MMR_YPERR_PRIGE_SHFT          48
-#define SH_MD_DQRP_MMR_YPERR_PRIGE_MASK          0x0001000000000000
-
-/*   SH_MD_DQRP_MMR_YPERR_PRIV                                          */
-/*   Description:  access privilege bit                                 */
-#define SH_MD_DQRP_MMR_YPERR_PRIV_SHFT           49
-#define SH_MD_DQRP_MMR_YPERR_PRIV_MASK           0x0002000000000000
-
-/*   SH_MD_DQRP_MMR_YPERR_COR                                           */
-/*   Description:  correctable ecc error                                */
-#define SH_MD_DQRP_MMR_YPERR_COR_SHFT            50
-#define SH_MD_DQRP_MMR_YPERR_COR_MASK            0x0004000000000000
-
-/*   SH_MD_DQRP_MMR_YPERR_UNC                                           */
-/*   Description:  uncorrectable ecc error                              */
-#define SH_MD_DQRP_MMR_YPERR_UNC_SHFT            51
-#define SH_MD_DQRP_MMR_YPERR_UNC_MASK            0x0008000000000000
-
-/*   SH_MD_DQRP_MMR_YPERR_MYBIT                                         */
-/*   Description:  ptreq,timeq,timlast,timspec,onlyme,anytim,ptrii,src  */
-#define SH_MD_DQRP_MMR_YPERR_MYBIT_SHFT          52
-#define SH_MD_DQRP_MMR_YPERR_MYBIT_MASK          0x0ff0000000000000
-
-/*   SH_MD_DQRP_MMR_YPERR_VAL                                           */
-/*   Description:  protocol error info valid                            */
-#define SH_MD_DQRP_MMR_YPERR_VAL_SHFT            60
-#define SH_MD_DQRP_MMR_YPERR_VAL_MASK            0x1000000000000000
-
-/*   SH_MD_DQRP_MMR_YPERR_MORE                                          */
-/*   Description:  more than one protocol error                         */
-#define SH_MD_DQRP_MMR_YPERR_MORE_SHFT           61
-#define SH_MD_DQRP_MMR_YPERR_MORE_MASK           0x2000000000000000
-
-/*   SH_MD_DQRP_MMR_YPERR_ARM                                           */
-/*   Description:  writing 1 arms error capture                         */
-#define SH_MD_DQRP_MMR_YPERR_ARM_SHFT            62
-#define SH_MD_DQRP_MMR_YPERR_ARM_MASK            0x4000000000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_CMDTRIG"                 */
-/*                             cmd triggers                             */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG               0x0000000100054000
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_MASK          0x00000000ffffffff
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD0                                    */
-/*   Description:  command trigger 0                                    */
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD0_SHFT     0
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD0_MASK     0x00000000000000ff
-
-/*   SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD1                                    */
-/*   Description:  command trigger 1                                    */
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD1_SHFT     8
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD1_MASK     0x000000000000ff00
-
-/*   SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD2                                    */
-/*   Description:  command trigger 2                                    */
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD2_SHFT     16
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD2_MASK     0x0000000000ff0000
-
-/*   SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD3                                    */
-/*   Description:  command trigger 3                                    */
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD3_SHFT     24
-#define SH_MD_DQRP_MMR_DIR_CMDTRIG_CMD3_MASK     0x00000000ff000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_TBLTRIG"                 */
-/*                          dir table trigger                           */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG               0x0000000100054010
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_MASK          0x000003ffffffffff
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLTRIG_SRC                                     */
-/*   Description:  source of request                                    */
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_SRC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_SRC_MASK      0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_TBLTRIG_CMD                                     */
-/*   Description:  incoming request                                     */
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_CMD_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_CMD_MASK      0x00000000003fc000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLTRIG_ACC                                     */
-/*   Description:  uncorrectable error, privilege bit                   */
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_ACC_SHFT      22
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_ACC_MASK      0x0000000000c00000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLTRIG_PRIGE                                   */
-/*   Description:  priority greater-equal                               */
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_PRIGE_SHFT    24
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_PRIGE_MASK    0x0000000001000000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLTRIG_DIRST                                   */
-/*   Description:  shrd,sxro,sub-state                                  */
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_DIRST_SHFT    25
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_DIRST_MASK    0x00000003fe000000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLTRIG_MYBIT                                   */
-/*   Description:  ptreq,timeq,timlast,timspec,onlyme,anytim,ptrii,src  */
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_MYBIT_SHFT    34
-#define SH_MD_DQRP_MMR_DIR_TBLTRIG_MYBIT_MASK    0x000003fc00000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_TBLMASK"                 */
-/*                        dir table trigger mask                        */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_DIR_TBLMASK               0x0000000100054020
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_MASK          0x000003ffffffffff
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLMASK_SRC                                     */
-/*   Description:  source of request                                    */
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_SRC_SHFT      0
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_SRC_MASK      0x0000000000003fff
-
-/*   SH_MD_DQRP_MMR_DIR_TBLMASK_CMD                                     */
-/*   Description:  incoming request                                     */
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_CMD_SHFT      14
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_CMD_MASK      0x00000000003fc000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLMASK_ACC                                     */
-/*   Description:  uncorrectable error, privilege bit                   */
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_ACC_SHFT      22
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_ACC_MASK      0x0000000000c00000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLMASK_PRIGE                                   */
-/*   Description:  priority greater-equal                               */
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_PRIGE_SHFT    24
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_PRIGE_MASK    0x0000000001000000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLMASK_DIRST                                   */
-/*   Description:  shrd,sxro,sub-state                                  */
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_DIRST_SHFT    25
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_DIRST_MASK    0x00000003fe000000
-
-/*   SH_MD_DQRP_MMR_DIR_TBLMASK_MYBIT                                   */
-/*   Description:  ptreq,timeq,timlast,timspec,onlyme,anytim,ptrii,src  */
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_MYBIT_SHFT    34
-#define SH_MD_DQRP_MMR_DIR_TBLMASK_MYBIT_MASK    0x000003fc00000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRP_MMR_XBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XBIST_H                   0x0000000100058000
-#define SH_MD_DQRP_MMR_XBIST_H_MASK              0x00000700ffffffff
-#define SH_MD_DQRP_MMR_XBIST_H_INIT              0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_H_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRP_MMR_XBIST_H_PAT_SHFT          0
-#define SH_MD_DQRP_MMR_XBIST_H_PAT_MASK          0x00000000ffffffff
-
-/*   SH_MD_DQRP_MMR_XBIST_H_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQRP_MMR_XBIST_H_INV_SHFT          40
-#define SH_MD_DQRP_MMR_XBIST_H_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_H_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQRP_MMR_XBIST_H_ROT_SHFT          41
-#define SH_MD_DQRP_MMR_XBIST_H_ROT_MASK          0x0000020000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_H_ARM                                         */
-/*   Description:  writing 1 arms data miscompare capture               */
-#define SH_MD_DQRP_MMR_XBIST_H_ARM_SHFT          42
-#define SH_MD_DQRP_MMR_XBIST_H_ARM_MASK          0x0000040000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRP_MMR_XBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XBIST_L                   0x0000000100058010
-#define SH_MD_DQRP_MMR_XBIST_L_MASK              0x00000300ffffffff
-#define SH_MD_DQRP_MMR_XBIST_L_INIT              0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_L_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRP_MMR_XBIST_L_PAT_SHFT          0
-#define SH_MD_DQRP_MMR_XBIST_L_PAT_MASK          0x00000000ffffffff
-
-/*   SH_MD_DQRP_MMR_XBIST_L_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQRP_MMR_XBIST_L_INV_SHFT          40
-#define SH_MD_DQRP_MMR_XBIST_L_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_L_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQRP_MMR_XBIST_L_ROT_SHFT          41
-#define SH_MD_DQRP_MMR_XBIST_L_ROT_MASK          0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_XBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XBIST_ERR_H               0x0000000100058020
-#define SH_MD_DQRP_MMR_XBIST_ERR_H_MASK          0x00000300ffffffff
-#define SH_MD_DQRP_MMR_XBIST_ERR_H_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_ERR_H_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRP_MMR_XBIST_ERR_H_PAT_SHFT      0
-#define SH_MD_DQRP_MMR_XBIST_ERR_H_PAT_MASK      0x00000000ffffffff
-
-/*   SH_MD_DQRP_MMR_XBIST_ERR_H_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQRP_MMR_XBIST_ERR_H_VAL_SHFT      40
-#define SH_MD_DQRP_MMR_XBIST_ERR_H_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_ERR_H_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQRP_MMR_XBIST_ERR_H_MORE_SHFT     41
-#define SH_MD_DQRP_MMR_XBIST_ERR_H_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_XBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_XBIST_ERR_L               0x0000000100058030
-#define SH_MD_DQRP_MMR_XBIST_ERR_L_MASK          0x00000300ffffffff
-#define SH_MD_DQRP_MMR_XBIST_ERR_L_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_ERR_L_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRP_MMR_XBIST_ERR_L_PAT_SHFT      0
-#define SH_MD_DQRP_MMR_XBIST_ERR_L_PAT_MASK      0x00000000ffffffff
-
-/*   SH_MD_DQRP_MMR_XBIST_ERR_L_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQRP_MMR_XBIST_ERR_L_VAL_SHFT      40
-#define SH_MD_DQRP_MMR_XBIST_ERR_L_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQRP_MMR_XBIST_ERR_L_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQRP_MMR_XBIST_ERR_L_MORE_SHFT     41
-#define SH_MD_DQRP_MMR_XBIST_ERR_L_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRP_MMR_YBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YBIST_H                   0x0000000100058800
-#define SH_MD_DQRP_MMR_YBIST_H_MASK              0x00000700ffffffff
-#define SH_MD_DQRP_MMR_YBIST_H_INIT              0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_H_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRP_MMR_YBIST_H_PAT_SHFT          0
-#define SH_MD_DQRP_MMR_YBIST_H_PAT_MASK          0x00000000ffffffff
-
-/*   SH_MD_DQRP_MMR_YBIST_H_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQRP_MMR_YBIST_H_INV_SHFT          40
-#define SH_MD_DQRP_MMR_YBIST_H_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_H_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQRP_MMR_YBIST_H_ROT_SHFT          41
-#define SH_MD_DQRP_MMR_YBIST_H_ROT_MASK          0x0000020000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_H_ARM                                         */
-/*   Description:  writing 1 arms data miscompare capture               */
-#define SH_MD_DQRP_MMR_YBIST_H_ARM_SHFT          42
-#define SH_MD_DQRP_MMR_YBIST_H_ARM_MASK          0x0000040000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRP_MMR_YBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YBIST_L                   0x0000000100058810
-#define SH_MD_DQRP_MMR_YBIST_L_MASK              0x00000300ffffffff
-#define SH_MD_DQRP_MMR_YBIST_L_INIT              0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_L_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRP_MMR_YBIST_L_PAT_SHFT          0
-#define SH_MD_DQRP_MMR_YBIST_L_PAT_MASK          0x00000000ffffffff
-
-/*   SH_MD_DQRP_MMR_YBIST_L_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQRP_MMR_YBIST_L_INV_SHFT          40
-#define SH_MD_DQRP_MMR_YBIST_L_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_L_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQRP_MMR_YBIST_L_ROT_SHFT          41
-#define SH_MD_DQRP_MMR_YBIST_L_ROT_MASK          0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_YBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YBIST_ERR_H               0x0000000100058820
-#define SH_MD_DQRP_MMR_YBIST_ERR_H_MASK          0x00000300ffffffff
-#define SH_MD_DQRP_MMR_YBIST_ERR_H_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_ERR_H_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRP_MMR_YBIST_ERR_H_PAT_SHFT      0
-#define SH_MD_DQRP_MMR_YBIST_ERR_H_PAT_MASK      0x00000000ffffffff
-
-/*   SH_MD_DQRP_MMR_YBIST_ERR_H_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQRP_MMR_YBIST_ERR_H_VAL_SHFT      40
-#define SH_MD_DQRP_MMR_YBIST_ERR_H_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_ERR_H_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQRP_MMR_YBIST_ERR_H_MORE_SHFT     41
-#define SH_MD_DQRP_MMR_YBIST_ERR_H_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_YBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRP_MMR_YBIST_ERR_L               0x0000000100058830
-#define SH_MD_DQRP_MMR_YBIST_ERR_L_MASK          0x00000300ffffffff
-#define SH_MD_DQRP_MMR_YBIST_ERR_L_INIT          0x0000000000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_ERR_L_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRP_MMR_YBIST_ERR_L_PAT_SHFT      0
-#define SH_MD_DQRP_MMR_YBIST_ERR_L_PAT_MASK      0x00000000ffffffff
-
-/*   SH_MD_DQRP_MMR_YBIST_ERR_L_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQRP_MMR_YBIST_ERR_L_VAL_SHFT      40
-#define SH_MD_DQRP_MMR_YBIST_ERR_L_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQRP_MMR_YBIST_ERR_L_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQRP_MMR_YBIST_ERR_L_MORE_SHFT     41
-#define SH_MD_DQRP_MMR_YBIST_ERR_L_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRS_MMR_XBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_XBIST_H                   0x0000000100068000
-#define SH_MD_DQRS_MMR_XBIST_H_MASK              0x000007ffffffffff
-#define SH_MD_DQRS_MMR_XBIST_H_INIT              0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_H_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRS_MMR_XBIST_H_PAT_SHFT          0
-#define SH_MD_DQRS_MMR_XBIST_H_PAT_MASK          0x000000ffffffffff
-
-/*   SH_MD_DQRS_MMR_XBIST_H_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQRS_MMR_XBIST_H_INV_SHFT          40
-#define SH_MD_DQRS_MMR_XBIST_H_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_H_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQRS_MMR_XBIST_H_ROT_SHFT          41
-#define SH_MD_DQRS_MMR_XBIST_H_ROT_MASK          0x0000020000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_H_ARM                                         */
-/*   Description:  writing 1 arms data miscompare capture               */
-#define SH_MD_DQRS_MMR_XBIST_H_ARM_SHFT          42
-#define SH_MD_DQRS_MMR_XBIST_H_ARM_MASK          0x0000040000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRS_MMR_XBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_XBIST_L                   0x0000000100068010
-#define SH_MD_DQRS_MMR_XBIST_L_MASK              0x000003ffffffffff
-#define SH_MD_DQRS_MMR_XBIST_L_INIT              0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_L_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRS_MMR_XBIST_L_PAT_SHFT          0
-#define SH_MD_DQRS_MMR_XBIST_L_PAT_MASK          0x000000ffffffffff
-
-/*   SH_MD_DQRS_MMR_XBIST_L_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQRS_MMR_XBIST_L_INV_SHFT          40
-#define SH_MD_DQRS_MMR_XBIST_L_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_L_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQRS_MMR_XBIST_L_ROT_SHFT          41
-#define SH_MD_DQRS_MMR_XBIST_L_ROT_MASK          0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRS_MMR_XBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_XBIST_ERR_H               0x0000000100068020
-#define SH_MD_DQRS_MMR_XBIST_ERR_H_MASK          0x000003ffffffffff
-#define SH_MD_DQRS_MMR_XBIST_ERR_H_INIT          0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_ERR_H_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRS_MMR_XBIST_ERR_H_PAT_SHFT      0
-#define SH_MD_DQRS_MMR_XBIST_ERR_H_PAT_MASK      0x000000ffffffffff
-
-/*   SH_MD_DQRS_MMR_XBIST_ERR_H_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQRS_MMR_XBIST_ERR_H_VAL_SHFT      40
-#define SH_MD_DQRS_MMR_XBIST_ERR_H_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_ERR_H_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQRS_MMR_XBIST_ERR_H_MORE_SHFT     41
-#define SH_MD_DQRS_MMR_XBIST_ERR_H_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRS_MMR_XBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_XBIST_ERR_L               0x0000000100068030
-#define SH_MD_DQRS_MMR_XBIST_ERR_L_MASK          0x000003ffffffffff
-#define SH_MD_DQRS_MMR_XBIST_ERR_L_INIT          0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_ERR_L_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRS_MMR_XBIST_ERR_L_PAT_SHFT      0
-#define SH_MD_DQRS_MMR_XBIST_ERR_L_PAT_MASK      0x000000ffffffffff
-
-/*   SH_MD_DQRS_MMR_XBIST_ERR_L_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQRS_MMR_XBIST_ERR_L_VAL_SHFT      40
-#define SH_MD_DQRS_MMR_XBIST_ERR_L_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQRS_MMR_XBIST_ERR_L_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQRS_MMR_XBIST_ERR_L_MORE_SHFT     41
-#define SH_MD_DQRS_MMR_XBIST_ERR_L_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRS_MMR_YBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_YBIST_H                   0x0000000100068800
-#define SH_MD_DQRS_MMR_YBIST_H_MASK              0x000007ffffffffff
-#define SH_MD_DQRS_MMR_YBIST_H_INIT              0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_H_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRS_MMR_YBIST_H_PAT_SHFT          0
-#define SH_MD_DQRS_MMR_YBIST_H_PAT_MASK          0x000000ffffffffff
-
-/*   SH_MD_DQRS_MMR_YBIST_H_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQRS_MMR_YBIST_H_INV_SHFT          40
-#define SH_MD_DQRS_MMR_YBIST_H_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_H_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQRS_MMR_YBIST_H_ROT_SHFT          41
-#define SH_MD_DQRS_MMR_YBIST_H_ROT_MASK          0x0000020000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_H_ARM                                         */
-/*   Description:  writing 1 arms data miscompare capture               */
-#define SH_MD_DQRS_MMR_YBIST_H_ARM_SHFT          42
-#define SH_MD_DQRS_MMR_YBIST_H_ARM_MASK          0x0000040000000000
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRS_MMR_YBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_YBIST_L                   0x0000000100068810
-#define SH_MD_DQRS_MMR_YBIST_L_MASK              0x000003ffffffffff
-#define SH_MD_DQRS_MMR_YBIST_L_INIT              0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_L_PAT                                         */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRS_MMR_YBIST_L_PAT_SHFT          0
-#define SH_MD_DQRS_MMR_YBIST_L_PAT_MASK          0x000000ffffffffff
-
-/*   SH_MD_DQRS_MMR_YBIST_L_INV                                         */
-/*   Description:  invert data pattern in next cycle                    */
-#define SH_MD_DQRS_MMR_YBIST_L_INV_SHFT          40
-#define SH_MD_DQRS_MMR_YBIST_L_INV_MASK          0x0000010000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_L_ROT                                         */
-/*   Description:  rotate left data pattern in next cycle               */
-#define SH_MD_DQRS_MMR_YBIST_L_ROT_SHFT          41
-#define SH_MD_DQRS_MMR_YBIST_L_ROT_MASK          0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRS_MMR_YBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_YBIST_ERR_H               0x0000000100068820
-#define SH_MD_DQRS_MMR_YBIST_ERR_H_MASK          0x000003ffffffffff
-#define SH_MD_DQRS_MMR_YBIST_ERR_H_INIT          0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_ERR_H_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRS_MMR_YBIST_ERR_H_PAT_SHFT      0
-#define SH_MD_DQRS_MMR_YBIST_ERR_H_PAT_MASK      0x000000ffffffffff
-
-/*   SH_MD_DQRS_MMR_YBIST_ERR_H_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQRS_MMR_YBIST_ERR_H_VAL_SHFT      40
-#define SH_MD_DQRS_MMR_YBIST_ERR_H_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_ERR_H_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQRS_MMR_YBIST_ERR_H_MORE_SHFT     41
-#define SH_MD_DQRS_MMR_YBIST_ERR_H_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRS_MMR_YBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_YBIST_ERR_L               0x0000000100068830
-#define SH_MD_DQRS_MMR_YBIST_ERR_L_MASK          0x000003ffffffffff
-#define SH_MD_DQRS_MMR_YBIST_ERR_L_INIT          0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_ERR_L_PAT                                     */
-/*   Description:  data pattern                                         */
-#define SH_MD_DQRS_MMR_YBIST_ERR_L_PAT_SHFT      0
-#define SH_MD_DQRS_MMR_YBIST_ERR_L_PAT_MASK      0x000000ffffffffff
-
-/*   SH_MD_DQRS_MMR_YBIST_ERR_L_VAL                                     */
-/*   Description:  bist data miscompare                                 */
-#define SH_MD_DQRS_MMR_YBIST_ERR_L_VAL_SHFT      40
-#define SH_MD_DQRS_MMR_YBIST_ERR_L_VAL_MASK      0x0000010000000000
-
-/*   SH_MD_DQRS_MMR_YBIST_ERR_L_MORE                                    */
-/*   Description:  more than one bist data miscompare                   */
-#define SH_MD_DQRS_MMR_YBIST_ERR_L_MORE_SHFT     41
-#define SH_MD_DQRS_MMR_YBIST_ERR_L_MORE_MASK     0x0000020000000000
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQRS_MMR_JNR_DEBUG"                  */
-/*                    joiner/fct debug configuration                    */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_JNR_DEBUG                 0x0000000100069000
-#define SH_MD_DQRS_MMR_JNR_DEBUG_MASK            0x0000000000000003
-#define SH_MD_DQRS_MMR_JNR_DEBUG_INIT            0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_JNR_DEBUG_PX                                        */
-/*   Description:  select 0=pi 1=xn side                                */
-#define SH_MD_DQRS_MMR_JNR_DEBUG_PX_SHFT         0
-#define SH_MD_DQRS_MMR_JNR_DEBUG_PX_MASK         0x0000000000000001
-
-/*   SH_MD_DQRS_MMR_JNR_DEBUG_RW                                        */
-/*   Description:  select 0=read 1=write side                           */
-#define SH_MD_DQRS_MMR_JNR_DEBUG_RW_SHFT         1
-#define SH_MD_DQRS_MMR_JNR_DEBUG_RW_MASK         0x0000000000000002
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQRS_MMR_YAMOPW_ERR"                 */
-/*                  amo/partial rmw ecc error register                  */
-/* ==================================================================== */
-
-#define SH_MD_DQRS_MMR_YAMOPW_ERR                0x000000010006a000
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_MASK           0x0000000103ff03ff
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_INIT           0x0000000000000000
-
-/*   SH_MD_DQRS_MMR_YAMOPW_ERR_SSYN                                     */
-/*   Description:  store data syndrome                                  */
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_SSYN_SHFT      0
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_SSYN_MASK      0x00000000000000ff
-
-/*   SH_MD_DQRS_MMR_YAMOPW_ERR_SCOR                                     */
-/*   Description:  correctable ecc errror on store data                 */
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_SCOR_SHFT      8
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_SCOR_MASK      0x0000000000000100
-
-/*   SH_MD_DQRS_MMR_YAMOPW_ERR_SUNC                                     */
-/*   Description:  uncorrectable ecc errror on store data               */
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_SUNC_SHFT      9
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_SUNC_MASK      0x0000000000000200
-
-/*   SH_MD_DQRS_MMR_YAMOPW_ERR_RSYN                                     */
-/*   Description:  memory read data syndrome                            */
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_RSYN_SHFT      16
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_RSYN_MASK      0x0000000000ff0000
-
-/*   SH_MD_DQRS_MMR_YAMOPW_ERR_RCOR                                     */
-/*   Description:  correctable ecc errror on read data                  */
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_RCOR_SHFT      24
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_RCOR_MASK      0x0000000001000000
-
-/*   SH_MD_DQRS_MMR_YAMOPW_ERR_RUNC                                     */
-/*   Description:  uncorrectable ecc errror on read data                */
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_RUNC_SHFT      25
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_RUNC_MASK      0x0000000002000000
-
-/*   SH_MD_DQRS_MMR_YAMOPW_ERR_ARM                                      */
-/*   Description:  writing 1 arms ecc error capture                     */
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_ARM_SHFT       32
-#define SH_MD_DQRS_MMR_YAMOPW_ERR_ARM_MASK       0x0000000100000000
-
-
-#endif /* _ASM_IA64_SN_SN2_SHUB_MMR_H */
diff -Nru a/include/asm-ia64/sn/sn2/shub_mmr_t.h b/include/asm-ia64/sn/sn2/shub_mmr_t.h
--- a/include/asm-ia64/sn/sn2/shub_mmr_t.h	2004-12-24 13:36:17 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,14829 +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) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
- */
-
-#ifndef _ASM_IA64_SN_SN2_SHUB_MMR_T_H
-#define _ASM_IA64_SN_SN2_SHUB_MMR_T_H
-
-#include <asm/sn/arch.h>
-
-/* ==================================================================== */
-/*                   Register "SH_FSB_BINIT_CONTROL"                    */
-/*                          FSB BINIT# Control                          */
-/* ==================================================================== */
-
-typedef union sh_fsb_binit_control_u {
-	mmr_t	sh_fsb_binit_control_regval;
-	struct {
-		mmr_t	binit       : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_fsb_binit_control_s;
-} sh_fsb_binit_control_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_FSB_RESET_CONTROL"                    */
-/*                          FSB Reset Control                           */
-/* ==================================================================== */
-
-typedef union sh_fsb_reset_control_u {
-	mmr_t	sh_fsb_reset_control_regval;
-	struct {
-		mmr_t	reset       : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_fsb_reset_control_s;
-} sh_fsb_reset_control_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_FSB_SYSTEM_AGENT_CONFIG"                 */
-/*                    FSB System Agent Configuration                    */
-/* ==================================================================== */
-
-typedef union sh_fsb_system_agent_config_u {
-	mmr_t	sh_fsb_system_agent_config_regval;
-	struct {
-		mmr_t	rcnt_scnt_en        : 1;
-		mmr_t	reserved_0          : 2;
-		mmr_t	berr_assert_en      : 1;
-		mmr_t	berr_sampling_en    : 1;
-		mmr_t	binit_assert_en     : 1;
-		mmr_t	bnr_throttling_en   : 1;
-		mmr_t	short_hang_en       : 1;
-		mmr_t	inta_rsp_data       : 8;
-		mmr_t	io_trans_rsp        : 1;
-		mmr_t	xtpr_trans_rsp      : 1;
-		mmr_t	inta_trans_rsp      : 1;
-		mmr_t	reserved_1          : 4;
-		mmr_t	tdot                : 1;
-		mmr_t	serialize_fsb_en    : 1;
-		mmr_t	reserved_2          : 7;
-		mmr_t	binit_event_enables : 14;
-		mmr_t	reserved_3          : 18;
-	} sh_fsb_system_agent_config_s;
-} sh_fsb_system_agent_config_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_FSB_VGA_REMAP"                      */
-/*                     FSB VGA Address Space Remap                      */
-/* ==================================================================== */
-
-typedef union sh_fsb_vga_remap_u {
-	mmr_t	sh_fsb_vga_remap_regval;
-	struct {
-		mmr_t	reserved_0            : 17;
-		mmr_t	offset                : 19;
-		mmr_t	asid                  : 2;
-		mmr_t	nid                   : 11;
-		mmr_t	reserved_1            : 13;
-		mmr_t	vga_remapping_enabled : 1;
-		mmr_t	reserved_2            : 1;
-	} sh_fsb_vga_remap_s;
-} sh_fsb_vga_remap_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_FSB_RESET_STATUS"                    */
-/*                           FSB Reset Status                           */
-/* ==================================================================== */
-
-typedef union sh_fsb_reset_status_u {
-	mmr_t	sh_fsb_reset_status_regval;
-	struct {
-		mmr_t	reset_in_progress : 1;
-		mmr_t	reserved_0        : 63;
-	} sh_fsb_reset_status_s;
-} sh_fsb_reset_status_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_FSB_SYMMETRIC_AGENT_STATUS"               */
-/*                      FSB Symmetric Agent Status                      */
-/* ==================================================================== */
-
-typedef union sh_fsb_symmetric_agent_status_u {
-	mmr_t	sh_fsb_symmetric_agent_status_regval;
-	struct {
-		mmr_t	cpu_0_active : 1;
-		mmr_t	cpu_1_active : 1;
-		mmr_t	cpus_ready   : 1;
-		mmr_t	reserved_0   : 61;
-	} sh_fsb_symmetric_agent_status_s;
-} sh_fsb_symmetric_agent_status_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_CREDIT_COUNT_0"                   */
-/*                Graphics-write Credit Count for CPU 0                 */
-/* ==================================================================== */
-
-typedef union sh_gfx_credit_count_0_u {
-	mmr_t	sh_gfx_credit_count_0_regval;
-	struct {
-		mmr_t	count           : 20;
-		mmr_t	reserved_0      : 43;
-		mmr_t	reset_gfx_state : 1;
-	} sh_gfx_credit_count_0_s;
-} sh_gfx_credit_count_0_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_CREDIT_COUNT_1"                   */
-/*                Graphics-write Credit Count for CPU 1                 */
-/* ==================================================================== */
-
-typedef union sh_gfx_credit_count_1_u {
-	mmr_t	sh_gfx_credit_count_1_regval;
-	struct {
-		mmr_t	count           : 20;
-		mmr_t	reserved_0      : 43;
-		mmr_t	reset_gfx_state : 1;
-	} sh_gfx_credit_count_1_s;
-} sh_gfx_credit_count_1_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_GFX_MODE_CNTRL_0"                    */
-/*         Graphics credit mode amd message ordering for CPU 0          */
-/* ==================================================================== */
-
-typedef union sh_gfx_mode_cntrl_0_u {
-	mmr_t	sh_gfx_mode_cntrl_0_regval;
-	struct {
-		mmr_t	dword_credits      : 1;
-		mmr_t	mixed_mode_credits : 1;
-		mmr_t	relaxed_ordering   : 1;
-		mmr_t	reserved_0         : 61;
-	} sh_gfx_mode_cntrl_0_s;
-} sh_gfx_mode_cntrl_0_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_GFX_MODE_CNTRL_1"                    */
-/*         Graphics credit mode amd message ordering for CPU 1          */
-/* ==================================================================== */
-
-typedef union sh_gfx_mode_cntrl_1_u {
-	mmr_t	sh_gfx_mode_cntrl_1_regval;
-	struct {
-		mmr_t	dword_credits      : 1;
-		mmr_t	mixed_mode_credits : 1;
-		mmr_t	relaxed_ordering   : 1;
-		mmr_t	reserved_0         : 61;
-	} sh_gfx_mode_cntrl_1_s;
-} sh_gfx_mode_cntrl_1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_GFX_SKID_CREDIT_COUNT_0"                 */
-/*              Graphics-write Skid Credit Count for CPU 0              */
-/* ==================================================================== */
-
-typedef union sh_gfx_skid_credit_count_0_u {
-	mmr_t	sh_gfx_skid_credit_count_0_regval;
-	struct {
-		mmr_t	skid        : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_gfx_skid_credit_count_0_s;
-} sh_gfx_skid_credit_count_0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_GFX_SKID_CREDIT_COUNT_1"                 */
-/*              Graphics-write Skid Credit Count for CPU 1              */
-/* ==================================================================== */
-
-typedef union sh_gfx_skid_credit_count_1_u {
-	mmr_t	sh_gfx_skid_credit_count_1_regval;
-	struct {
-		mmr_t	skid        : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_gfx_skid_credit_count_1_s;
-} sh_gfx_skid_credit_count_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_STALL_LIMIT_0"                    */
-/*                 Graphics-write Stall Limit for CPU 0                 */
-/* ==================================================================== */
-
-typedef union sh_gfx_stall_limit_0_u {
-	mmr_t	sh_gfx_stall_limit_0_regval;
-	struct {
-		mmr_t	limit       : 26;
-		mmr_t	reserved_0  : 38;
-	} sh_gfx_stall_limit_0_s;
-} sh_gfx_stall_limit_0_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_STALL_LIMIT_1"                    */
-/*                 Graphics-write Stall Limit for CPU 1                 */
-/* ==================================================================== */
-
-typedef union sh_gfx_stall_limit_1_u {
-	mmr_t	sh_gfx_stall_limit_1_regval;
-	struct {
-		mmr_t	limit       : 26;
-		mmr_t	reserved_0  : 38;
-	} sh_gfx_stall_limit_1_s;
-} sh_gfx_stall_limit_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_STALL_TIMER_0"                    */
-/*                 Graphics-write Stall Timer for CPU 0                 */
-/* ==================================================================== */
-
-typedef union sh_gfx_stall_timer_0_u {
-	mmr_t	sh_gfx_stall_timer_0_regval;
-	struct {
-		mmr_t	timer_value : 26;
-		mmr_t	reserved_0  : 38;
-	} sh_gfx_stall_timer_0_s;
-} sh_gfx_stall_timer_0_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_STALL_TIMER_1"                    */
-/*                 Graphics-write Stall Timer for CPU 1                 */
-/* ==================================================================== */
-
-typedef union sh_gfx_stall_timer_1_u {
-	mmr_t	sh_gfx_stall_timer_1_regval;
-	struct {
-		mmr_t	timer_value : 26;
-		mmr_t	reserved_0  : 38;
-	} sh_gfx_stall_timer_1_s;
-} sh_gfx_stall_timer_1_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_GFX_WINDOW_0"                      */
-/*                   Graphics-write Window for CPU 0                    */
-/* ==================================================================== */
-
-typedef union sh_gfx_window_0_u {
-	mmr_t	sh_gfx_window_0_regval;
-	struct {
-		mmr_t	reserved_0    : 24;
-		mmr_t	base_addr     : 12;
-		mmr_t	reserved_1    : 27;
-		mmr_t	gfx_window_en : 1;
-	} sh_gfx_window_0_s;
-} sh_gfx_window_0_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_GFX_WINDOW_1"                      */
-/*                   Graphics-write Window for CPU 1                    */
-/* ==================================================================== */
-
-typedef union sh_gfx_window_1_u {
-	mmr_t	sh_gfx_window_1_regval;
-	struct {
-		mmr_t	reserved_0    : 24;
-		mmr_t	base_addr     : 12;
-		mmr_t	reserved_1    : 27;
-		mmr_t	gfx_window_en : 1;
-	} sh_gfx_window_1_s;
-} sh_gfx_window_1_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_GFX_INTERRUPT_TIMER_LIMIT_0"               */
-/*               Graphics-write Interrupt Limit for CPU 0               */
-/* ==================================================================== */
-
-typedef union sh_gfx_interrupt_timer_limit_0_u {
-	mmr_t	sh_gfx_interrupt_timer_limit_0_regval;
-	struct {
-		mmr_t	interrupt_timer_limit : 8;
-		mmr_t	reserved_0            : 56;
-	} sh_gfx_interrupt_timer_limit_0_s;
-} sh_gfx_interrupt_timer_limit_0_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_GFX_INTERRUPT_TIMER_LIMIT_1"               */
-/*               Graphics-write Interrupt Limit for CPU 1               */
-/* ==================================================================== */
-
-typedef union sh_gfx_interrupt_timer_limit_1_u {
-	mmr_t	sh_gfx_interrupt_timer_limit_1_regval;
-	struct {
-		mmr_t	interrupt_timer_limit : 8;
-		mmr_t	reserved_0            : 56;
-	} sh_gfx_interrupt_timer_limit_1_s;
-} sh_gfx_interrupt_timer_limit_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_WRITE_STATUS_0"                   */
-/*                   Graphics Write Status for CPU 0                    */
-/* ==================================================================== */
-
-typedef union sh_gfx_write_status_0_u {
-	mmr_t	sh_gfx_write_status_0_regval;
-	struct {
-		mmr_t	busy                : 1;
-		mmr_t	reserved_0          : 62;
-		mmr_t	re_enable_gfx_stall : 1;
-	} sh_gfx_write_status_0_s;
-} sh_gfx_write_status_0_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_GFX_WRITE_STATUS_1"                   */
-/*                   Graphics Write Status for CPU 1                    */
-/* ==================================================================== */
-
-typedef union sh_gfx_write_status_1_u {
-	mmr_t	sh_gfx_write_status_1_regval;
-	struct {
-		mmr_t	busy                : 1;
-		mmr_t	reserved_0          : 62;
-		mmr_t	re_enable_gfx_stall : 1;
-	} sh_gfx_write_status_1_s;
-} sh_gfx_write_status_1_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_II_INT0"                         */
-/*                    SHub II Interrupt 0 Registers                     */
-/* ==================================================================== */
-
-typedef union sh_ii_int0_u {
-	mmr_t	sh_ii_int0_regval;
-	struct {
-		mmr_t	idx         : 8;
-		mmr_t	send        : 1;
-		mmr_t	reserved_0  : 55;
-	} sh_ii_int0_s;
-} sh_ii_int0_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_II_INT0_CONFIG"                     */
-/*                 SHub II Interrupt 0 Config Registers                 */
-/* ==================================================================== */
-
-typedef union sh_ii_int0_config_u {
-	mmr_t	sh_ii_int0_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 14;
-	} sh_ii_int0_config_s;
-} sh_ii_int0_config_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_II_INT0_ENABLE"                     */
-/*                 SHub II Interrupt 0 Enable Registers                 */
-/* ==================================================================== */
-
-typedef union sh_ii_int0_enable_u {
-	mmr_t	sh_ii_int0_enable_regval;
-	struct {
-		mmr_t	ii_enable   : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_ii_int0_enable_s;
-} sh_ii_int0_enable_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_II_INT1"                         */
-/*                    SHub II Interrupt 1 Registers                     */
-/* ==================================================================== */
-
-typedef union sh_ii_int1_u {
-	mmr_t	sh_ii_int1_regval;
-	struct {
-		mmr_t	idx         : 8;
-		mmr_t	send        : 1;
-		mmr_t	reserved_0  : 55;
-	} sh_ii_int1_s;
-} sh_ii_int1_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_II_INT1_CONFIG"                     */
-/*                 SHub II Interrupt 1 Config Registers                 */
-/* ==================================================================== */
-
-typedef union sh_ii_int1_config_u {
-	mmr_t	sh_ii_int1_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 14;
-	} sh_ii_int1_config_s;
-} sh_ii_int1_config_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_II_INT1_ENABLE"                     */
-/*                 SHub II Interrupt 1 Enable Registers                 */
-/* ==================================================================== */
-
-typedef union sh_ii_int1_enable_u {
-	mmr_t	sh_ii_int1_enable_regval;
-	struct {
-		mmr_t	ii_enable   : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_ii_int1_enable_s;
-} sh_ii_int1_enable_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_INT_NODE_ID_CONFIG"                   */
-/*                 SHub Interrupt Node ID Configuration                 */
-/* ==================================================================== */
-
-typedef union sh_int_node_id_config_u {
-	mmr_t	sh_int_node_id_config_regval;
-	struct {
-		mmr_t	node_id     : 11;
-		mmr_t	id_sel      : 1;
-		mmr_t	reserved_0  : 52;
-	} sh_int_node_id_config_s;
-} sh_int_node_id_config_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_IPI_INT"                         */
-/*               SHub Inter-Processor Interrupt Registers               */
-/* ==================================================================== */
-
-typedef union sh_ipi_int_u {
-	mmr_t	sh_ipi_int_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 3;
-		mmr_t	send        : 1;
-	} sh_ipi_int_s;
-} sh_ipi_int_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_IPI_INT_ENABLE"                     */
-/*           SHub Inter-Processor Interrupt Enable Registers            */
-/* ==================================================================== */
-
-typedef union sh_ipi_int_enable_u {
-	mmr_t	sh_ipi_int_enable_regval;
-	struct {
-		mmr_t	pio_enable  : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_ipi_int_enable_s;
-} sh_ipi_int_enable_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT0_CONFIG"                    */
-/*                   SHub Local Interrupt 0 Registers                   */
-/* ==================================================================== */
-
-typedef union sh_local_int0_config_u {
-	mmr_t	sh_local_int0_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_local_int0_config_s;
-} sh_local_int0_config_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT0_ENABLE"                    */
-/*                    SHub Local Interrupt 0 Enable                     */
-/* ==================================================================== */
-
-typedef union sh_local_int0_enable_u {
-	mmr_t	sh_local_int0_enable_regval;
-	struct {
-		mmr_t	pi_hw_int           : 1;
-		mmr_t	md_hw_int           : 1;
-		mmr_t	xn_hw_int           : 1;
-		mmr_t	lb_hw_int           : 1;
-		mmr_t	ii_hw_int           : 1;
-		mmr_t	pi_ce_int           : 1;
-		mmr_t	md_ce_int           : 1;
-		mmr_t	xn_ce_int           : 1;
-		mmr_t	pi_uce_int          : 1;
-		mmr_t	md_uce_int          : 1;
-		mmr_t	xn_uce_int          : 1;
-		mmr_t	reserved_0          : 1;
-		mmr_t	system_shutdown_int : 1;
-		mmr_t	uart_int            : 1;
-		mmr_t	l1_nmi_int          : 1;
-		mmr_t	stop_clock          : 1;
-		mmr_t	reserved_1          : 48;
-	} sh_local_int0_enable_s;
-} sh_local_int0_enable_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT1_CONFIG"                    */
-/*                   SHub Local Interrupt 1 Registers                   */
-/* ==================================================================== */
-
-typedef union sh_local_int1_config_u {
-	mmr_t	sh_local_int1_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_local_int1_config_s;
-} sh_local_int1_config_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT1_ENABLE"                    */
-/*                    SHub Local Interrupt 1 Enable                     */
-/* ==================================================================== */
-
-typedef union sh_local_int1_enable_u {
-	mmr_t	sh_local_int1_enable_regval;
-	struct {
-		mmr_t	pi_hw_int           : 1;
-		mmr_t	md_hw_int           : 1;
-		mmr_t	xn_hw_int           : 1;
-		mmr_t	lb_hw_int           : 1;
-		mmr_t	ii_hw_int           : 1;
-		mmr_t	pi_ce_int           : 1;
-		mmr_t	md_ce_int           : 1;
-		mmr_t	xn_ce_int           : 1;
-		mmr_t	pi_uce_int          : 1;
-		mmr_t	md_uce_int          : 1;
-		mmr_t	xn_uce_int          : 1;
-		mmr_t	reserved_0          : 1;
-		mmr_t	system_shutdown_int : 1;
-		mmr_t	uart_int            : 1;
-		mmr_t	l1_nmi_int          : 1;
-		mmr_t	stop_clock          : 1;
-		mmr_t	reserved_1          : 48;
-	} sh_local_int1_enable_s;
-} sh_local_int1_enable_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT2_CONFIG"                    */
-/*                   SHub Local Interrupt 2 Registers                   */
-/* ==================================================================== */
-
-typedef union sh_local_int2_config_u {
-	mmr_t	sh_local_int2_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_local_int2_config_s;
-} sh_local_int2_config_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT2_ENABLE"                    */
-/*                    SHub Local Interrupt 2 Enable                     */
-/* ==================================================================== */
-
-typedef union sh_local_int2_enable_u {
-	mmr_t	sh_local_int2_enable_regval;
-	struct {
-		mmr_t	pi_hw_int           : 1;
-		mmr_t	md_hw_int           : 1;
-		mmr_t	xn_hw_int           : 1;
-		mmr_t	lb_hw_int           : 1;
-		mmr_t	ii_hw_int           : 1;
-		mmr_t	pi_ce_int           : 1;
-		mmr_t	md_ce_int           : 1;
-		mmr_t	xn_ce_int           : 1;
-		mmr_t	pi_uce_int          : 1;
-		mmr_t	md_uce_int          : 1;
-		mmr_t	xn_uce_int          : 1;
-		mmr_t	reserved_0          : 1;
-		mmr_t	system_shutdown_int : 1;
-		mmr_t	uart_int            : 1;
-		mmr_t	l1_nmi_int          : 1;
-		mmr_t	stop_clock          : 1;
-		mmr_t	reserved_1          : 48;
-	} sh_local_int2_enable_s;
-} sh_local_int2_enable_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT3_CONFIG"                    */
-/*                   SHub Local Interrupt 3 Registers                   */
-/* ==================================================================== */
-
-typedef union sh_local_int3_config_u {
-	mmr_t	sh_local_int3_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_local_int3_config_s;
-} sh_local_int3_config_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT3_ENABLE"                    */
-/*                    SHub Local Interrupt 3 Enable                     */
-/* ==================================================================== */
-
-typedef union sh_local_int3_enable_u {
-	mmr_t	sh_local_int3_enable_regval;
-	struct {
-		mmr_t	pi_hw_int           : 1;
-		mmr_t	md_hw_int           : 1;
-		mmr_t	xn_hw_int           : 1;
-		mmr_t	lb_hw_int           : 1;
-		mmr_t	ii_hw_int           : 1;
-		mmr_t	pi_ce_int           : 1;
-		mmr_t	md_ce_int           : 1;
-		mmr_t	xn_ce_int           : 1;
-		mmr_t	pi_uce_int          : 1;
-		mmr_t	md_uce_int          : 1;
-		mmr_t	xn_uce_int          : 1;
-		mmr_t	reserved_0          : 1;
-		mmr_t	system_shutdown_int : 1;
-		mmr_t	uart_int            : 1;
-		mmr_t	l1_nmi_int          : 1;
-		mmr_t	stop_clock          : 1;
-		mmr_t	reserved_1          : 48;
-	} sh_local_int3_enable_s;
-} sh_local_int3_enable_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT4_CONFIG"                    */
-/*                   SHub Local Interrupt 4 Registers                   */
-/* ==================================================================== */
-
-typedef union sh_local_int4_config_u {
-	mmr_t	sh_local_int4_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_local_int4_config_s;
-} sh_local_int4_config_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT4_ENABLE"                    */
-/*                    SHub Local Interrupt 4 Enable                     */
-/* ==================================================================== */
-
-typedef union sh_local_int4_enable_u {
-	mmr_t	sh_local_int4_enable_regval;
-	struct {
-		mmr_t	pi_hw_int           : 1;
-		mmr_t	md_hw_int           : 1;
-		mmr_t	xn_hw_int           : 1;
-		mmr_t	lb_hw_int           : 1;
-		mmr_t	ii_hw_int           : 1;
-		mmr_t	pi_ce_int           : 1;
-		mmr_t	md_ce_int           : 1;
-		mmr_t	xn_ce_int           : 1;
-		mmr_t	pi_uce_int          : 1;
-		mmr_t	md_uce_int          : 1;
-		mmr_t	xn_uce_int          : 1;
-		mmr_t	reserved_0          : 1;
-		mmr_t	system_shutdown_int : 1;
-		mmr_t	uart_int            : 1;
-		mmr_t	l1_nmi_int          : 1;
-		mmr_t	stop_clock          : 1;
-		mmr_t	reserved_1          : 48;
-	} sh_local_int4_enable_s;
-} sh_local_int4_enable_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT5_CONFIG"                    */
-/*                   SHub Local Interrupt 5 Registers                   */
-/* ==================================================================== */
-
-typedef union sh_local_int5_config_u {
-	mmr_t	sh_local_int5_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_local_int5_config_s;
-} sh_local_int5_config_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LOCAL_INT5_ENABLE"                    */
-/*                    SHub Local Interrupt 5 Enable                     */
-/* ==================================================================== */
-
-typedef union sh_local_int5_enable_u {
-	mmr_t	sh_local_int5_enable_regval;
-	struct {
-		mmr_t	pi_hw_int           : 1;
-		mmr_t	md_hw_int           : 1;
-		mmr_t	xn_hw_int           : 1;
-		mmr_t	lb_hw_int           : 1;
-		mmr_t	ii_hw_int           : 1;
-		mmr_t	pi_ce_int           : 1;
-		mmr_t	md_ce_int           : 1;
-		mmr_t	xn_ce_int           : 1;
-		mmr_t	pi_uce_int          : 1;
-		mmr_t	md_uce_int          : 1;
-		mmr_t	xn_uce_int          : 1;
-		mmr_t	reserved_0          : 1;
-		mmr_t	system_shutdown_int : 1;
-		mmr_t	uart_int            : 1;
-		mmr_t	l1_nmi_int          : 1;
-		mmr_t	stop_clock          : 1;
-		mmr_t	reserved_1          : 48;
-	} sh_local_int5_enable_s;
-} sh_local_int5_enable_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ERR_INT_CONFIG"                  */
-/*              SHub Processor 0 Error Interrupt Registers              */
-/* ==================================================================== */
-
-typedef union sh_proc0_err_int_config_u {
-	mmr_t	sh_proc0_err_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_proc0_err_int_config_s;
-} sh_proc0_err_int_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ERR_INT_CONFIG"                  */
-/*              SHub Processor 1 Error Interrupt Registers              */
-/* ==================================================================== */
-
-typedef union sh_proc1_err_int_config_u {
-	mmr_t	sh_proc1_err_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_proc1_err_int_config_s;
-} sh_proc1_err_int_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ERR_INT_CONFIG"                  */
-/*              SHub Processor 2 Error Interrupt Registers              */
-/* ==================================================================== */
-
-typedef union sh_proc2_err_int_config_u {
-	mmr_t	sh_proc2_err_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_proc2_err_int_config_s;
-} sh_proc2_err_int_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ERR_INT_CONFIG"                  */
-/*              SHub Processor 3 Error Interrupt Registers              */
-/* ==================================================================== */
-
-typedef union sh_proc3_err_int_config_u {
-	mmr_t	sh_proc3_err_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_proc3_err_int_config_s;
-} sh_proc3_err_int_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ADV_INT_CONFIG"                  */
-/*            SHub Processor 0 Advisory Interrupt Registers             */
-/* ==================================================================== */
-
-typedef union sh_proc0_adv_int_config_u {
-	mmr_t	sh_proc0_adv_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_proc0_adv_int_config_s;
-} sh_proc0_adv_int_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ADV_INT_CONFIG"                  */
-/*            SHub Processor 1 Advisory Interrupt Registers             */
-/* ==================================================================== */
-
-typedef union sh_proc1_adv_int_config_u {
-	mmr_t	sh_proc1_adv_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_proc1_adv_int_config_s;
-} sh_proc1_adv_int_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ADV_INT_CONFIG"                  */
-/*            SHub Processor 2 Advisory Interrupt Registers             */
-/* ==================================================================== */
-
-typedef union sh_proc2_adv_int_config_u {
-	mmr_t	sh_proc2_adv_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_proc2_adv_int_config_s;
-} sh_proc2_adv_int_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ADV_INT_CONFIG"                  */
-/*            SHub Processor 3 Advisory Interrupt Registers             */
-/* ==================================================================== */
-
-typedef union sh_proc3_adv_int_config_u {
-	mmr_t	sh_proc3_adv_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_proc3_adv_int_config_s;
-} sh_proc3_adv_int_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ERR_INT_ENABLE"                  */
-/*          SHub Processor 0 Error Interrupt Enable Registers           */
-/* ==================================================================== */
-
-typedef union sh_proc0_err_int_enable_u {
-	mmr_t	sh_proc0_err_int_enable_regval;
-	struct {
-		mmr_t	proc0_err_enable : 1;
-		mmr_t	reserved_0       : 63;
-	} sh_proc0_err_int_enable_s;
-} sh_proc0_err_int_enable_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ERR_INT_ENABLE"                  */
-/*          SHub Processor 1 Error Interrupt Enable Registers           */
-/* ==================================================================== */
-
-typedef union sh_proc1_err_int_enable_u {
-	mmr_t	sh_proc1_err_int_enable_regval;
-	struct {
-		mmr_t	proc1_err_enable : 1;
-		mmr_t	reserved_0       : 63;
-	} sh_proc1_err_int_enable_s;
-} sh_proc1_err_int_enable_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ERR_INT_ENABLE"                  */
-/*          SHub Processor 2 Error Interrupt Enable Registers           */
-/* ==================================================================== */
-
-typedef union sh_proc2_err_int_enable_u {
-	mmr_t	sh_proc2_err_int_enable_regval;
-	struct {
-		mmr_t	proc2_err_enable : 1;
-		mmr_t	reserved_0       : 63;
-	} sh_proc2_err_int_enable_s;
-} sh_proc2_err_int_enable_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ERR_INT_ENABLE"                  */
-/*          SHub Processor 3 Error Interrupt Enable Registers           */
-/* ==================================================================== */
-
-typedef union sh_proc3_err_int_enable_u {
-	mmr_t	sh_proc3_err_int_enable_regval;
-	struct {
-		mmr_t	proc3_err_enable : 1;
-		mmr_t	reserved_0       : 63;
-	} sh_proc3_err_int_enable_s;
-} sh_proc3_err_int_enable_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ADV_INT_ENABLE"                  */
-/*         SHub Processor 0 Advisory Interrupt Enable Registers         */
-/* ==================================================================== */
-
-typedef union sh_proc0_adv_int_enable_u {
-	mmr_t	sh_proc0_adv_int_enable_regval;
-	struct {
-		mmr_t	proc0_adv_enable : 1;
-		mmr_t	reserved_0       : 63;
-	} sh_proc0_adv_int_enable_s;
-} sh_proc0_adv_int_enable_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ADV_INT_ENABLE"                  */
-/*         SHub Processor 1 Advisory Interrupt Enable Registers         */
-/* ==================================================================== */
-
-typedef union sh_proc1_adv_int_enable_u {
-	mmr_t	sh_proc1_adv_int_enable_regval;
-	struct {
-		mmr_t	proc1_adv_enable : 1;
-		mmr_t	reserved_0       : 63;
-	} sh_proc1_adv_int_enable_s;
-} sh_proc1_adv_int_enable_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ADV_INT_ENABLE"                  */
-/*         SHub Processor 2 Advisory Interrupt Enable Registers         */
-/* ==================================================================== */
-
-typedef union sh_proc2_adv_int_enable_u {
-	mmr_t	sh_proc2_adv_int_enable_regval;
-	struct {
-		mmr_t	proc2_adv_enable : 1;
-		mmr_t	reserved_0       : 63;
-	} sh_proc2_adv_int_enable_s;
-} sh_proc2_adv_int_enable_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ADV_INT_ENABLE"                  */
-/*         SHub Processor 3 Advisory Interrupt Enable Registers         */
-/* ==================================================================== */
-
-typedef union sh_proc3_adv_int_enable_u {
-	mmr_t	sh_proc3_adv_int_enable_regval;
-	struct {
-		mmr_t	proc3_adv_enable : 1;
-		mmr_t	reserved_0       : 63;
-	} sh_proc3_adv_int_enable_s;
-} sh_proc3_adv_int_enable_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PROFILE_INT_CONFIG"                   */
-/*            SHub Profile Interrupt Configuration Registers            */
-/* ==================================================================== */
-
-typedef union sh_profile_int_config_u {
-	mmr_t	sh_profile_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_profile_int_config_s;
-} sh_profile_int_config_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PROFILE_INT_ENABLE"                   */
-/*               SHub Profile Interrupt Enable Registers                */
-/* ==================================================================== */
-
-typedef union sh_profile_int_enable_u {
-	mmr_t	sh_profile_int_enable_regval;
-	struct {
-		mmr_t	profile_enable : 1;
-		mmr_t	reserved_0     : 63;
-	} sh_profile_int_enable_s;
-} sh_profile_int_enable_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_RTC0_INT_CONFIG"                     */
-/*                SHub RTC 0 Interrupt Config Registers                 */
-/* ==================================================================== */
-
-typedef union sh_rtc0_int_config_u {
-	mmr_t	sh_rtc0_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_rtc0_int_config_s;
-} sh_rtc0_int_config_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_RTC0_INT_ENABLE"                     */
-/*                SHub RTC 0 Interrupt Enable Registers                 */
-/* ==================================================================== */
-
-typedef union sh_rtc0_int_enable_u {
-	mmr_t	sh_rtc0_int_enable_regval;
-	struct {
-		mmr_t	rtc0_enable : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_rtc0_int_enable_s;
-} sh_rtc0_int_enable_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_RTC1_INT_CONFIG"                     */
-/*                SHub RTC 1 Interrupt Config Registers                 */
-/* ==================================================================== */
-
-typedef union sh_rtc1_int_config_u {
-	mmr_t	sh_rtc1_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_rtc1_int_config_s;
-} sh_rtc1_int_config_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_RTC1_INT_ENABLE"                     */
-/*                SHub RTC 1 Interrupt Enable Registers                 */
-/* ==================================================================== */
-
-typedef union sh_rtc1_int_enable_u {
-	mmr_t	sh_rtc1_int_enable_regval;
-	struct {
-		mmr_t	rtc1_enable : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_rtc1_int_enable_s;
-} sh_rtc1_int_enable_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_RTC2_INT_CONFIG"                     */
-/*                SHub RTC 2 Interrupt Config Registers                 */
-/* ==================================================================== */
-
-typedef union sh_rtc2_int_config_u {
-	mmr_t	sh_rtc2_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_rtc2_int_config_s;
-} sh_rtc2_int_config_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_RTC2_INT_ENABLE"                     */
-/*                SHub RTC 2 Interrupt Enable Registers                 */
-/* ==================================================================== */
-
-typedef union sh_rtc2_int_enable_u {
-	mmr_t	sh_rtc2_int_enable_regval;
-	struct {
-		mmr_t	rtc2_enable : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_rtc2_int_enable_s;
-} sh_rtc2_int_enable_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_RTC3_INT_CONFIG"                     */
-/*                SHub RTC 3 Interrupt Config Registers                 */
-/* ==================================================================== */
-
-typedef union sh_rtc3_int_config_u {
-	mmr_t	sh_rtc3_int_config_regval;
-	struct {
-		mmr_t	type        : 3;
-		mmr_t	agt         : 1;
-		mmr_t	pid         : 16;
-		mmr_t	reserved_0  : 1;
-		mmr_t	base        : 29;
-		mmr_t	reserved_1  : 2;
-		mmr_t	idx         : 8;
-		mmr_t	reserved_2  : 4;
-	} sh_rtc3_int_config_s;
-} sh_rtc3_int_config_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_RTC3_INT_ENABLE"                     */
-/*                SHub RTC 3 Interrupt Enable Registers                 */
-/* ==================================================================== */
-
-typedef union sh_rtc3_int_enable_u {
-	mmr_t	sh_rtc3_int_enable_regval;
-	struct {
-		mmr_t	rtc3_enable : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_rtc3_int_enable_s;
-} sh_rtc3_int_enable_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_EVENT_OCCURRED"                     */
-/*                    SHub Interrupt Event Occurred                     */
-/* ==================================================================== */
-
-typedef union sh_event_occurred_u {
-	mmr_t	sh_event_occurred_regval;
-	struct {
-		mmr_t	pi_hw_int           : 1;
-		mmr_t	md_hw_int           : 1;
-		mmr_t	xn_hw_int           : 1;
-		mmr_t	lb_hw_int           : 1;
-		mmr_t	ii_hw_int           : 1;
-		mmr_t	pi_ce_int           : 1;
-		mmr_t	md_ce_int           : 1;
-		mmr_t	xn_ce_int           : 1;
-		mmr_t	pi_uce_int          : 1;
-		mmr_t	md_uce_int          : 1;
-		mmr_t	xn_uce_int          : 1;
-		mmr_t	proc0_adv_int       : 1;
-		mmr_t	proc1_adv_int       : 1;
-		mmr_t	proc2_adv_int       : 1;
-		mmr_t	proc3_adv_int       : 1;
-		mmr_t	proc0_err_int       : 1;
-		mmr_t	proc1_err_int       : 1;
-		mmr_t	proc2_err_int       : 1;
-		mmr_t	proc3_err_int       : 1;
-		mmr_t	system_shutdown_int : 1;
-		mmr_t	uart_int            : 1;
-		mmr_t	l1_nmi_int          : 1;
-		mmr_t	stop_clock          : 1;
-		mmr_t	rtc0_int            : 1;
-		mmr_t	rtc1_int            : 1;
-		mmr_t	rtc2_int            : 1;
-		mmr_t	rtc3_int            : 1;
-		mmr_t	profile_int         : 1;
-		mmr_t	ipi_int             : 1;
-		mmr_t	ii_int0             : 1;
-		mmr_t	ii_int1             : 1;
-		mmr_t	reserved_0          : 33;
-	} sh_event_occurred_s;
-} sh_event_occurred_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_EVENT_OVERFLOW"                     */
-/*                SHub Interrupt Event Occurred Overflow                */
-/* ==================================================================== */
-
-typedef union sh_event_overflow_u {
-	mmr_t	sh_event_overflow_regval;
-	struct {
-		mmr_t	pi_hw_int           : 1;
-		mmr_t	md_hw_int           : 1;
-		mmr_t	xn_hw_int           : 1;
-		mmr_t	lb_hw_int           : 1;
-		mmr_t	ii_hw_int           : 1;
-		mmr_t	pi_ce_int           : 1;
-		mmr_t	md_ce_int           : 1;
-		mmr_t	xn_ce_int           : 1;
-		mmr_t	pi_uce_int          : 1;
-		mmr_t	md_uce_int          : 1;
-		mmr_t	xn_uce_int          : 1;
-		mmr_t	proc0_adv_int       : 1;
-		mmr_t	proc1_adv_int       : 1;
-		mmr_t	proc2_adv_int       : 1;
-		mmr_t	proc3_adv_int       : 1;
-		mmr_t	proc0_err_int       : 1;
-		mmr_t	proc1_err_int       : 1;
-		mmr_t	proc2_err_int       : 1;
-		mmr_t	proc3_err_int       : 1;
-		mmr_t	system_shutdown_int : 1;
-		mmr_t	uart_int            : 1;
-		mmr_t	l1_nmi_int          : 1;
-		mmr_t	stop_clock          : 1;
-		mmr_t	rtc0_int            : 1;
-		mmr_t	rtc1_int            : 1;
-		mmr_t	rtc2_int            : 1;
-		mmr_t	rtc3_int            : 1;
-		mmr_t	profile_int         : 1;
-		mmr_t	reserved_0          : 36;
-	} sh_event_overflow_s;
-} sh_event_overflow_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_TIME"                      */
-/*                           Junk Bus Timing                            */
-/* ==================================================================== */
-
-typedef union sh_junk_bus_time_u {
-	mmr_t	sh_junk_bus_time_regval;
-	struct {
-		mmr_t	fprom_setup_hold : 8;
-		mmr_t	fprom_enable     : 8;
-		mmr_t	uart_setup_hold  : 8;
-		mmr_t	uart_enable      : 8;
-		mmr_t	reserved_0       : 32;
-	} sh_junk_bus_time_s;
-} sh_junk_bus_time_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_JUNK_LATCH_TIME"                     */
-/*                        Junk Bus Latch Timing                         */
-/* ==================================================================== */
-
-typedef union sh_junk_latch_time_u {
-	mmr_t	sh_junk_latch_time_regval;
-	struct {
-		mmr_t	setup_hold  : 3;
-		mmr_t	reserved_0  : 61;
-	} sh_junk_latch_time_s;
-} sh_junk_latch_time_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_JUNK_NACK_RESET"                     */
-/*                     Junk Bus Nack Counter Reset                      */
-/* ==================================================================== */
-
-typedef union sh_junk_nack_reset_u {
-	mmr_t	sh_junk_nack_reset_regval;
-	struct {
-		mmr_t	pulse       : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_junk_nack_reset_s;
-} sh_junk_nack_reset_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_LED0"                      */
-/*                            Junk Bus LED0                             */
-/* ==================================================================== */
-
-typedef union sh_junk_bus_led0_u {
-	mmr_t	sh_junk_bus_led0_regval;
-	struct {
-		mmr_t	led0_data   : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_junk_bus_led0_s;
-} sh_junk_bus_led0_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_LED1"                      */
-/*                            Junk Bus LED1                             */
-/* ==================================================================== */
-
-typedef union sh_junk_bus_led1_u {
-	mmr_t	sh_junk_bus_led1_regval;
-	struct {
-		mmr_t	led1_data   : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_junk_bus_led1_s;
-} sh_junk_bus_led1_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_LED2"                      */
-/*                            Junk Bus LED2                             */
-/* ==================================================================== */
-
-typedef union sh_junk_bus_led2_u {
-	mmr_t	sh_junk_bus_led2_regval;
-	struct {
-		mmr_t	led2_data   : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_junk_bus_led2_s;
-} sh_junk_bus_led2_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_JUNK_BUS_LED3"                      */
-/*                            Junk Bus LED3                             */
-/* ==================================================================== */
-
-typedef union sh_junk_bus_led3_u {
-	mmr_t	sh_junk_bus_led3_regval;
-	struct {
-		mmr_t	led3_data   : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_junk_bus_led3_s;
-} sh_junk_bus_led3_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_JUNK_ERROR_STATUS"                    */
-/*                        Junk Bus Error Status                         */
-/* ==================================================================== */
-
-typedef union sh_junk_error_status_u {
-	mmr_t	sh_junk_error_status_regval;
-	struct {
-		mmr_t	address     : 47;
-		mmr_t	reserved_0  : 1;
-		mmr_t	cmd         : 8;
-		mmr_t	mode        : 1;
-		mmr_t	status      : 4;
-		mmr_t	reserved_1  : 3;
-	} sh_junk_error_status_s;
-} sh_junk_error_status_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_NI0_LLP_STAT"                      */
-/*               This register describes the LLP status.                */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_stat_u {
-	mmr_t	sh_ni0_llp_stat_regval;
-	struct {
-		mmr_t	link_reset_state : 4;
-		mmr_t	reserved_0       : 60;
-	} sh_ni0_llp_stat_s;
-} sh_ni0_llp_stat_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_NI0_LLP_RESET"                      */
-/*           Writing issues a reset to the network interface            */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_reset_u {
-	mmr_t	sh_ni0_llp_reset_regval;
-	struct {
-		mmr_t	link        : 1;
-		mmr_t	warm        : 1;
-		mmr_t	reserved_0  : 62;
-	} sh_ni0_llp_reset_s;
-} sh_ni0_llp_reset_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LLP_RESET_EN"                    */
-/*                 Controls LLP warm reset propagation                  */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_reset_en_u {
-	mmr_t	sh_ni0_llp_reset_en_regval;
-	struct {
-		mmr_t	ok          : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_ni0_llp_reset_en_s;
-} sh_ni0_llp_reset_en_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_LLP_CHAN_MODE"                    */
-/*              Sets the signaling mode of LLP and channel              */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_chan_mode_u {
-	mmr_t	sh_ni0_llp_chan_mode_regval;
-	struct {
-		mmr_t	bitmode32         : 1;
-		mmr_t	ac_encode         : 1;
-		mmr_t	enable_tuning     : 1;
-		mmr_t	enable_rmt_ft_upd : 1;
-		mmr_t	enable_clkquad    : 1;
-		mmr_t	reserved_0        : 59;
-	} sh_ni0_llp_chan_mode_s;
-} sh_ni0_llp_chan_mode_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_NI0_LLP_CONFIG"                     */
-/*              Sets the configuration of LLP and channel               */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_config_u {
-	mmr_t	sh_ni0_llp_config_regval;
-	struct {
-		mmr_t	maxburst    : 10;
-		mmr_t	maxretry    : 10;
-		mmr_t	nulltimeout : 6;
-		mmr_t	ftu_time    : 12;
-		mmr_t	reserved_0  : 26;
-	} sh_ni0_llp_config_s;
-} sh_ni0_llp_config_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LLP_TEST_CTL"                    */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_test_ctl_u {
-	mmr_t	sh_ni0_llp_test_ctl_regval;
-	struct {
-		mmr_t	pattern        : 40;
-		mmr_t	send_test_mode : 2;
-		mmr_t	reserved_0     : 2;
-		mmr_t	wire_sel       : 6;
-		mmr_t	reserved_1     : 2;
-		mmr_t	lfsr_mode      : 2;
-		mmr_t	noise_mode     : 2;
-		mmr_t	armcapture     : 1;
-		mmr_t	capturecbonly  : 1;
-		mmr_t	sendcberror    : 1;
-		mmr_t	sendsnerror    : 1;
-		mmr_t	fakesnerror    : 1;
-		mmr_t	captured       : 1;
-		mmr_t	cberror        : 1;
-		mmr_t	reserved_2     : 1;
-	} sh_ni0_llp_test_ctl_s;
-} sh_ni0_llp_test_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LLP_CAPT_WD1"                    */
-/*                    low order 64-bit captured word                    */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_capt_wd1_u {
-	mmr_t	sh_ni0_llp_capt_wd1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_ni0_llp_capt_wd1_s;
-} sh_ni0_llp_capt_wd1_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LLP_CAPT_WD2"                    */
-/*                   high order 64-bit captured word                    */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_capt_wd2_u {
-	mmr_t	sh_ni0_llp_capt_wd2_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_ni0_llp_capt_wd2_s;
-} sh_ni0_llp_capt_wd2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_LLP_CAPT_SBCB"                    */
-/*                 captured sideband, sequence, and CRC                 */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_capt_sbcb_u {
-	mmr_t	sh_ni0_llp_capt_sbcb_regval;
-	struct {
-		mmr_t	capturedrcvsbsn  : 16;
-		mmr_t	capturedrcvcrc   : 16;
-		mmr_t	sentallcberrors  : 1;
-		mmr_t	sentallsnerrors  : 1;
-		mmr_t	fakedallsnerrors : 1;
-		mmr_t	chargeoverflow   : 1;
-		mmr_t	chargeunderflow  : 1;
-		mmr_t	reserved_0       : 27;
-	} sh_ni0_llp_capt_sbcb_s;
-} sh_ni0_llp_capt_sbcb_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_NI0_LLP_ERR"                       */
-/* ==================================================================== */
-
-typedef union sh_ni0_llp_err_u {
-	mmr_t	sh_ni0_llp_err_regval;
-	struct {
-		mmr_t	rx_sn_err_count : 8;
-		mmr_t	rx_cb_err_count : 8;
-		mmr_t	retry_count     : 8;
-		mmr_t	retry_timeout   : 1;
-		mmr_t	rcv_link_reset  : 1;
-		mmr_t	squash          : 1;
-		mmr_t	power_not_ok    : 1;
-		mmr_t	wire_cnt        : 24;
-		mmr_t	wire_overflow   : 1;
-		mmr_t	reserved_0      : 11;
-	} sh_ni0_llp_err_s;
-} sh_ni0_llp_err_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_NI1_LLP_STAT"                      */
-/*               This register describes the LLP status.                */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_stat_u {
-	mmr_t	sh_ni1_llp_stat_regval;
-	struct {
-		mmr_t	link_reset_state : 4;
-		mmr_t	reserved_0       : 60;
-	} sh_ni1_llp_stat_s;
-} sh_ni1_llp_stat_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_NI1_LLP_RESET"                      */
-/*           Writing issues a reset to the network interface            */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_reset_u {
-	mmr_t	sh_ni1_llp_reset_regval;
-	struct {
-		mmr_t	link        : 1;
-		mmr_t	warm        : 1;
-		mmr_t	reserved_0  : 62;
-	} sh_ni1_llp_reset_s;
-} sh_ni1_llp_reset_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LLP_RESET_EN"                    */
-/*                 Controls LLP warm reset propagation                  */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_reset_en_u {
-	mmr_t	sh_ni1_llp_reset_en_regval;
-	struct {
-		mmr_t	ok          : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_ni1_llp_reset_en_s;
-} sh_ni1_llp_reset_en_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_LLP_CHAN_MODE"                    */
-/*              Sets the signaling mode of LLP and channel              */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_chan_mode_u {
-	mmr_t	sh_ni1_llp_chan_mode_regval;
-	struct {
-		mmr_t	bitmode32         : 1;
-		mmr_t	ac_encode         : 1;
-		mmr_t	enable_tuning     : 1;
-		mmr_t	enable_rmt_ft_upd : 1;
-		mmr_t	enable_clkquad    : 1;
-		mmr_t	reserved_0        : 59;
-	} sh_ni1_llp_chan_mode_s;
-} sh_ni1_llp_chan_mode_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_NI1_LLP_CONFIG"                     */
-/*              Sets the configuration of LLP and channel               */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_config_u {
-	mmr_t	sh_ni1_llp_config_regval;
-	struct {
-		mmr_t	maxburst    : 10;
-		mmr_t	maxretry    : 10;
-		mmr_t	nulltimeout : 6;
-		mmr_t	ftu_time    : 12;
-		mmr_t	reserved_0  : 26;
-	} sh_ni1_llp_config_s;
-} sh_ni1_llp_config_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LLP_TEST_CTL"                    */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_test_ctl_u {
-	mmr_t	sh_ni1_llp_test_ctl_regval;
-	struct {
-		mmr_t	pattern        : 40;
-		mmr_t	send_test_mode : 2;
-		mmr_t	reserved_0     : 2;
-		mmr_t	wire_sel       : 6;
-		mmr_t	reserved_1     : 2;
-		mmr_t	lfsr_mode      : 2;
-		mmr_t	noise_mode     : 2;
-		mmr_t	armcapture     : 1;
-		mmr_t	capturecbonly  : 1;
-		mmr_t	sendcberror    : 1;
-		mmr_t	sendsnerror    : 1;
-		mmr_t	fakesnerror    : 1;
-		mmr_t	captured       : 1;
-		mmr_t	cberror        : 1;
-		mmr_t	reserved_2     : 1;
-	} sh_ni1_llp_test_ctl_s;
-} sh_ni1_llp_test_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LLP_CAPT_WD1"                    */
-/*                    low order 64-bit captured word                    */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_capt_wd1_u {
-	mmr_t	sh_ni1_llp_capt_wd1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_ni1_llp_capt_wd1_s;
-} sh_ni1_llp_capt_wd1_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LLP_CAPT_WD2"                    */
-/*                   high order 64-bit captured word                    */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_capt_wd2_u {
-	mmr_t	sh_ni1_llp_capt_wd2_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_ni1_llp_capt_wd2_s;
-} sh_ni1_llp_capt_wd2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_LLP_CAPT_SBCB"                    */
-/*                 captured sideband, sequence, and CRC                 */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_capt_sbcb_u {
-	mmr_t	sh_ni1_llp_capt_sbcb_regval;
-	struct {
-		mmr_t	capturedrcvsbsn  : 16;
-		mmr_t	capturedrcvcrc   : 16;
-		mmr_t	sentallcberrors  : 1;
-		mmr_t	sentallsnerrors  : 1;
-		mmr_t	fakedallsnerrors : 1;
-		mmr_t	chargeoverflow   : 1;
-		mmr_t	chargeunderflow  : 1;
-		mmr_t	reserved_0       : 27;
-	} sh_ni1_llp_capt_sbcb_s;
-} sh_ni1_llp_capt_sbcb_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_NI1_LLP_ERR"                       */
-/* ==================================================================== */
-
-typedef union sh_ni1_llp_err_u {
-	mmr_t	sh_ni1_llp_err_regval;
-	struct {
-		mmr_t	rx_sn_err_count : 8;
-		mmr_t	rx_cb_err_count : 8;
-		mmr_t	retry_count     : 8;
-		mmr_t	retry_timeout   : 1;
-		mmr_t	rcv_link_reset  : 1;
-		mmr_t	squash          : 1;
-		mmr_t	power_not_ok    : 1;
-		mmr_t	wire_cnt        : 24;
-		mmr_t	wire_overflow   : 1;
-		mmr_t	reserved_0      : 11;
-	} sh_ni1_llp_err_s;
-} sh_ni1_llp_err_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XNNI0_LLP_TO_FIFO02_FLOW"                */
-/* ==================================================================== */
-
-typedef union sh_xnni0_llp_to_fifo02_flow_u {
-	mmr_t	sh_xnni0_llp_to_fifo02_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnni0_llp_to_fifo02_flow_s;
-} sh_xnni0_llp_to_fifo02_flow_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XNNI0_LLP_TO_FIFO13_FLOW"                */
-/* ==================================================================== */
-
-typedef union sh_xnni0_llp_to_fifo13_flow_u {
-	mmr_t	sh_xnni0_llp_to_fifo13_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnni0_llp_to_fifo13_flow_s;
-} sh_xnni0_llp_to_fifo13_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_LLP_DEBIT_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni0_llp_debit_flow_u {
-	mmr_t	sh_xnni0_llp_debit_flow_regval;
-	struct {
-		mmr_t	debit_vc0_dyn : 5;
-		mmr_t	reserved_0    : 3;
-		mmr_t	debit_vc0_cap : 5;
-		mmr_t	reserved_1    : 3;
-		mmr_t	debit_vc1_dyn : 5;
-		mmr_t	reserved_2    : 3;
-		mmr_t	debit_vc1_cap : 5;
-		mmr_t	reserved_3    : 3;
-		mmr_t	debit_vc2_dyn : 5;
-		mmr_t	reserved_4    : 3;
-		mmr_t	debit_vc2_cap : 5;
-		mmr_t	reserved_5    : 3;
-		mmr_t	debit_vc3_dyn : 5;
-		mmr_t	reserved_6    : 3;
-		mmr_t	debit_vc3_cap : 5;
-		mmr_t	reserved_7    : 3;
-	} sh_xnni0_llp_debit_flow_s;
-} sh_xnni0_llp_debit_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_LINK_0_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni0_link_0_flow_u {
-	mmr_t	sh_xnni0_link_0_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	credit_vc0_test      : 7;
-		mmr_t	reserved_1           : 1;
-		mmr_t	credit_vc0_dyn       : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc0_cap       : 7;
-		mmr_t	reserved_3           : 33;
-	} sh_xnni0_link_0_flow_s;
-} sh_xnni0_link_0_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_LINK_1_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni0_link_1_flow_u {
-	mmr_t	sh_xnni0_link_1_flow_regval;
-	struct {
-		mmr_t	debit_vc1_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc1_force_cred : 1;
-		mmr_t	credit_vc1_test      : 7;
-		mmr_t	reserved_1           : 1;
-		mmr_t	credit_vc1_dyn       : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc1_cap       : 7;
-		mmr_t	reserved_3           : 33;
-	} sh_xnni0_link_1_flow_s;
-} sh_xnni0_link_1_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_LINK_2_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni0_link_2_flow_u {
-	mmr_t	sh_xnni0_link_2_flow_regval;
-	struct {
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	credit_vc2_test      : 7;
-		mmr_t	reserved_1           : 1;
-		mmr_t	credit_vc2_dyn       : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc2_cap       : 7;
-		mmr_t	reserved_3           : 33;
-	} sh_xnni0_link_2_flow_s;
-} sh_xnni0_link_2_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_LINK_3_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni0_link_3_flow_u {
-	mmr_t	sh_xnni0_link_3_flow_regval;
-	struct {
-		mmr_t	debit_vc3_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc3_force_cred : 1;
-		mmr_t	credit_vc3_test      : 7;
-		mmr_t	reserved_1           : 1;
-		mmr_t	credit_vc3_dyn       : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc3_cap       : 7;
-		mmr_t	reserved_3           : 33;
-	} sh_xnni0_link_3_flow_s;
-} sh_xnni0_link_3_flow_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XNNI1_LLP_TO_FIFO02_FLOW"                */
-/* ==================================================================== */
-
-typedef union sh_xnni1_llp_to_fifo02_flow_u {
-	mmr_t	sh_xnni1_llp_to_fifo02_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnni1_llp_to_fifo02_flow_s;
-} sh_xnni1_llp_to_fifo02_flow_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XNNI1_LLP_TO_FIFO13_FLOW"                */
-/* ==================================================================== */
-
-typedef union sh_xnni1_llp_to_fifo13_flow_u {
-	mmr_t	sh_xnni1_llp_to_fifo13_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnni1_llp_to_fifo13_flow_s;
-} sh_xnni1_llp_to_fifo13_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_LLP_DEBIT_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni1_llp_debit_flow_u {
-	mmr_t	sh_xnni1_llp_debit_flow_regval;
-	struct {
-		mmr_t	debit_vc0_dyn : 5;
-		mmr_t	reserved_0    : 3;
-		mmr_t	debit_vc0_cap : 5;
-		mmr_t	reserved_1    : 3;
-		mmr_t	debit_vc1_dyn : 5;
-		mmr_t	reserved_2    : 3;
-		mmr_t	debit_vc1_cap : 5;
-		mmr_t	reserved_3    : 3;
-		mmr_t	debit_vc2_dyn : 5;
-		mmr_t	reserved_4    : 3;
-		mmr_t	debit_vc2_cap : 5;
-		mmr_t	reserved_5    : 3;
-		mmr_t	debit_vc3_dyn : 5;
-		mmr_t	reserved_6    : 3;
-		mmr_t	debit_vc3_cap : 5;
-		mmr_t	reserved_7    : 3;
-	} sh_xnni1_llp_debit_flow_s;
-} sh_xnni1_llp_debit_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_LINK_0_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni1_link_0_flow_u {
-	mmr_t	sh_xnni1_link_0_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	credit_vc0_test      : 7;
-		mmr_t	reserved_1           : 1;
-		mmr_t	credit_vc0_dyn       : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc0_cap       : 7;
-		mmr_t	reserved_3           : 33;
-	} sh_xnni1_link_0_flow_s;
-} sh_xnni1_link_0_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_LINK_1_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni1_link_1_flow_u {
-	mmr_t	sh_xnni1_link_1_flow_regval;
-	struct {
-		mmr_t	debit_vc1_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc1_force_cred : 1;
-		mmr_t	credit_vc1_test      : 7;
-		mmr_t	reserved_1           : 1;
-		mmr_t	credit_vc1_dyn       : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc1_cap       : 7;
-		mmr_t	reserved_3           : 33;
-	} sh_xnni1_link_1_flow_s;
-} sh_xnni1_link_1_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_LINK_2_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni1_link_2_flow_u {
-	mmr_t	sh_xnni1_link_2_flow_regval;
-	struct {
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	credit_vc2_test      : 7;
-		mmr_t	reserved_1           : 1;
-		mmr_t	credit_vc2_dyn       : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc2_cap       : 7;
-		mmr_t	reserved_3           : 33;
-	} sh_xnni1_link_2_flow_s;
-} sh_xnni1_link_2_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_LINK_3_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni1_link_3_flow_u {
-	mmr_t	sh_xnni1_link_3_flow_regval;
-	struct {
-		mmr_t	debit_vc3_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc3_force_cred : 1;
-		mmr_t	credit_vc3_test      : 7;
-		mmr_t	reserved_1           : 1;
-		mmr_t	credit_vc3_dyn       : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc3_cap       : 7;
-		mmr_t	reserved_3           : 33;
-	} sh_xnni1_link_3_flow_s;
-} sh_xnni1_link_3_flow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_IILB_LOCAL_TABLE"                    */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_iilb_local_table_u {
-	mmr_t	sh_iilb_local_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 57;
-		mmr_t	valid       : 1;
-	} sh_iilb_local_table_s;
-} sh_iilb_local_table_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_IILB_GLOBAL_TABLE"                    */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_iilb_global_table_u {
-	mmr_t	sh_iilb_global_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 57;
-		mmr_t	valid       : 1;
-	} sh_iilb_global_table_s;
-} sh_iilb_global_table_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_IILB_OVER_RIDE_TABLE"                  */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-typedef union sh_iilb_over_ride_table_u {
-	mmr_t	sh_iilb_over_ride_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 57;
-		mmr_t	enable      : 1;
-	} sh_iilb_over_ride_table_s;
-} sh_iilb_over_ride_table_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_IILB_RSP_PLANE_HINT"                   */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-typedef union sh_iilb_rsp_plane_hint_u {
-	mmr_t	sh_iilb_rsp_plane_hint_regval;
-	struct {
-		mmr_t	reserved_0  : 64;
-	} sh_iilb_rsp_plane_hint_s;
-} sh_iilb_rsp_plane_hint_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PI_LOCAL_TABLE"                     */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_pi_local_table_u {
-	mmr_t	sh_pi_local_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 2;
-		mmr_t	dir1        : 4;
-		mmr_t	v1          : 1;
-		mmr_t	ni_sel1     : 1;
-		mmr_t	reserved_1  : 49;
-		mmr_t	valid       : 1;
-	} sh_pi_local_table_s;
-} sh_pi_local_table_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_PI_GLOBAL_TABLE"                     */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_pi_global_table_u {
-	mmr_t	sh_pi_global_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 2;
-		mmr_t	dir1        : 4;
-		mmr_t	v1          : 1;
-		mmr_t	ni_sel1     : 1;
-		mmr_t	reserved_1  : 49;
-		mmr_t	valid       : 1;
-	} sh_pi_global_table_s;
-} sh_pi_global_table_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_OVER_RIDE_TABLE"                   */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-typedef union sh_pi_over_ride_table_u {
-	mmr_t	sh_pi_over_ride_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 2;
-		mmr_t	dir1        : 4;
-		mmr_t	v1          : 1;
-		mmr_t	ni_sel1     : 1;
-		mmr_t	reserved_1  : 49;
-		mmr_t	enable      : 1;
-	} sh_pi_over_ride_table_s;
-} sh_pi_over_ride_table_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_RSP_PLANE_HINT"                    */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-typedef union sh_pi_rsp_plane_hint_u {
-	mmr_t	sh_pi_rsp_plane_hint_regval;
-	struct {
-		mmr_t	invert      : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_pi_rsp_plane_hint_s;
-} sh_pi_rsp_plane_hint_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_LOCAL_TABLE"                     */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_ni0_local_table_u {
-	mmr_t	sh_ni0_local_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	reserved_0  : 58;
-		mmr_t	valid       : 1;
-	} sh_ni0_local_table_s;
-} sh_ni0_local_table_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_GLOBAL_TABLE"                    */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_ni0_global_table_u {
-	mmr_t	sh_ni0_global_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	reserved_0  : 58;
-		mmr_t	valid       : 1;
-	} sh_ni0_global_table_s;
-} sh_ni0_global_table_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_OVER_RIDE_TABLE"                   */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-typedef union sh_ni0_over_ride_table_u {
-	mmr_t	sh_ni0_over_ride_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	reserved_0  : 58;
-		mmr_t	enable      : 1;
-	} sh_ni0_over_ride_table_s;
-} sh_ni0_over_ride_table_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_RSP_PLANE_HINT"                   */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-typedef union sh_ni0_rsp_plane_hint_u {
-	mmr_t	sh_ni0_rsp_plane_hint_regval;
-	struct {
-		mmr_t	reserved_0  : 64;
-	} sh_ni0_rsp_plane_hint_s;
-} sh_ni0_rsp_plane_hint_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_LOCAL_TABLE"                     */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_ni1_local_table_u {
-	mmr_t	sh_ni1_local_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	reserved_0  : 58;
-		mmr_t	valid       : 1;
-	} sh_ni1_local_table_s;
-} sh_ni1_local_table_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_GLOBAL_TABLE"                    */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_ni1_global_table_u {
-	mmr_t	sh_ni1_global_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	reserved_0  : 58;
-		mmr_t	valid       : 1;
-	} sh_ni1_global_table_s;
-} sh_ni1_global_table_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_OVER_RIDE_TABLE"                   */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-typedef union sh_ni1_over_ride_table_u {
-	mmr_t	sh_ni1_over_ride_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	reserved_0  : 58;
-		mmr_t	enable      : 1;
-	} sh_ni1_over_ride_table_s;
-} sh_ni1_over_ride_table_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_RSP_PLANE_HINT"                   */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-typedef union sh_ni1_rsp_plane_hint_u {
-	mmr_t	sh_ni1_rsp_plane_hint_regval;
-	struct {
-		mmr_t	reserved_0  : 64;
-	} sh_ni1_rsp_plane_hint_s;
-} sh_ni1_rsp_plane_hint_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_MD_LOCAL_TABLE"                     */
-/*                          local lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_md_local_table_u {
-	mmr_t	sh_md_local_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 2;
-		mmr_t	dir1        : 4;
-		mmr_t	v1          : 1;
-		mmr_t	ni_sel1     : 1;
-		mmr_t	reserved_1  : 49;
-		mmr_t	valid       : 1;
-	} sh_md_local_table_s;
-} sh_md_local_table_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_MD_GLOBAL_TABLE"                     */
-/*                         global lookup table                          */
-/* ==================================================================== */
-
-typedef union sh_md_global_table_u {
-	mmr_t	sh_md_global_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 2;
-		mmr_t	dir1        : 4;
-		mmr_t	v1          : 1;
-		mmr_t	ni_sel1     : 1;
-		mmr_t	reserved_1  : 49;
-		mmr_t	valid       : 1;
-	} sh_md_global_table_s;
-} sh_md_global_table_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_OVER_RIDE_TABLE"                   */
-/*              If enabled, bypass the Global/Local tables              */
-/* ==================================================================== */
-
-typedef union sh_md_over_ride_table_u {
-	mmr_t	sh_md_over_ride_table_regval;
-	struct {
-		mmr_t	dir0        : 4;
-		mmr_t	v0          : 1;
-		mmr_t	ni_sel0     : 1;
-		mmr_t	reserved_0  : 2;
-		mmr_t	dir1        : 4;
-		mmr_t	v1          : 1;
-		mmr_t	ni_sel1     : 1;
-		mmr_t	reserved_1  : 49;
-		mmr_t	enable      : 1;
-	} sh_md_over_ride_table_s;
-} sh_md_over_ride_table_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_RSP_PLANE_HINT"                    */
-/*  If enabled, invert incoming response only plane hint bit before lo  */
-/* ==================================================================== */
-
-typedef union sh_md_rsp_plane_hint_u {
-	mmr_t	sh_md_rsp_plane_hint_regval;
-	struct {
-		mmr_t	invert      : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_md_rsp_plane_hint_s;
-} sh_md_rsp_plane_hint_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_LB_LIQ_CTL"                       */
-/*                       Local Block LIQ Control                        */
-/* ==================================================================== */
-
-typedef union sh_lb_liq_ctl_u {
-	mmr_t	sh_lb_liq_ctl_regval;
-	struct {
-		mmr_t	liq_req_ctl        : 5;
-		mmr_t	reserved_0         : 3;
-		mmr_t	liq_rpl_ctl        : 4;
-		mmr_t	reserved_1         : 4;
-		mmr_t	force_rq_credit    : 1;
-		mmr_t	force_rp_credit    : 1;
-		mmr_t	force_linvv_credit : 1;
-		mmr_t	reserved_2         : 45;
-	} sh_lb_liq_ctl_s;
-} sh_lb_liq_ctl_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_LB_LOQ_CTL"                       */
-/*                       Local Block LOQ Control                        */
-/* ==================================================================== */
-
-typedef union sh_lb_loq_ctl_u {
-	mmr_t	sh_lb_loq_ctl_regval;
-	struct {
-		mmr_t	loq_req_ctl : 1;
-		mmr_t	loq_rpl_ctl : 1;
-		mmr_t	reserved_0  : 62;
-	} sh_lb_loq_ctl_s;
-} sh_lb_loq_ctl_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_LB_MAX_REP_CREDIT_CNT"                  */
-/*               Maximum number of reply credits from XN                */
-/* ==================================================================== */
-
-typedef union sh_lb_max_rep_credit_cnt_u {
-	mmr_t	sh_lb_max_rep_credit_cnt_regval;
-	struct {
-		mmr_t	max_cnt     : 5;
-		mmr_t	reserved_0  : 59;
-	} sh_lb_max_rep_credit_cnt_s;
-} sh_lb_max_rep_credit_cnt_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_LB_MAX_REQ_CREDIT_CNT"                  */
-/*              Maximum number of request credits from XN               */
-/* ==================================================================== */
-
-typedef union sh_lb_max_req_credit_cnt_u {
-	mmr_t	sh_lb_max_req_credit_cnt_regval;
-	struct {
-		mmr_t	max_cnt     : 5;
-		mmr_t	reserved_0  : 59;
-	} sh_lb_max_req_credit_cnt_s;
-} sh_lb_max_req_credit_cnt_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_PIO_TIME_OUT"                      */
-/*                    Local Block PIO time out value                    */
-/* ==================================================================== */
-
-typedef union sh_pio_time_out_u {
-	mmr_t	sh_pio_time_out_regval;
-	struct {
-		mmr_t	value       : 16;
-		mmr_t	reserved_0  : 48;
-	} sh_pio_time_out_s;
-} sh_pio_time_out_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PIO_NACK_RESET"                     */
-/*               Local Block PIO Reset for nack counters                */
-/* ==================================================================== */
-
-typedef union sh_pio_nack_reset_u {
-	mmr_t	sh_pio_nack_reset_regval;
-	struct {
-		mmr_t	pulse       : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_pio_nack_reset_s;
-} sh_pio_nack_reset_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_CONVEYOR_BELT_TIME_OUT"                 */
-/*               Local Block conveyor belt time out value               */
-/* ==================================================================== */
-
-typedef union sh_conveyor_belt_time_out_u {
-	mmr_t	sh_conveyor_belt_time_out_regval;
-	struct {
-		mmr_t	value       : 12;
-		mmr_t	reserved_0  : 52;
-	} sh_conveyor_belt_time_out_s;
-} sh_conveyor_belt_time_out_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_LB_CREDIT_STATUS"                    */
-/*                    Credit Counter Status Register                    */
-/* ==================================================================== */
-
-typedef union sh_lb_credit_status_u {
-	mmr_t	sh_lb_credit_status_regval;
-	struct {
-		mmr_t	liq_rq_credit : 5;
-		mmr_t	reserved_0    : 1;
-		mmr_t	liq_rp_credit : 4;
-		mmr_t	reserved_1    : 2;
-		mmr_t	linvv_credit  : 6;
-		mmr_t	loq_rq_credit : 5;
-		mmr_t	loq_rp_credit : 5;
-		mmr_t	reserved_2    : 36;
-	} sh_lb_credit_status_s;
-} sh_lb_credit_status_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_DEBUG_LOCAL_SEL"                   */
-/*                         LB Debug Port Select                         */
-/* ==================================================================== */
-
-typedef union sh_lb_debug_local_sel_u {
-	mmr_t	sh_lb_debug_local_sel_regval;
-	struct {
-		mmr_t	nibble0_chiplet_sel : 3;
-		mmr_t	reserved_0          : 1;
-		mmr_t	nibble0_nibble_sel  : 3;
-		mmr_t	reserved_1          : 1;
-		mmr_t	nibble1_chiplet_sel : 3;
-		mmr_t	reserved_2          : 1;
-		mmr_t	nibble1_nibble_sel  : 3;
-		mmr_t	reserved_3          : 1;
-		mmr_t	nibble2_chiplet_sel : 3;
-		mmr_t	reserved_4          : 1;
-		mmr_t	nibble2_nibble_sel  : 3;
-		mmr_t	reserved_5          : 1;
-		mmr_t	nibble3_chiplet_sel : 3;
-		mmr_t	reserved_6          : 1;
-		mmr_t	nibble3_nibble_sel  : 3;
-		mmr_t	reserved_7          : 1;
-		mmr_t	nibble4_chiplet_sel : 3;
-		mmr_t	reserved_8          : 1;
-		mmr_t	nibble4_nibble_sel  : 3;
-		mmr_t	reserved_9          : 1;
-		mmr_t	nibble5_chiplet_sel : 3;
-		mmr_t	reserved_10         : 1;
-		mmr_t	nibble5_nibble_sel  : 3;
-		mmr_t	reserved_11         : 1;
-		mmr_t	nibble6_chiplet_sel : 3;
-		mmr_t	reserved_12         : 1;
-		mmr_t	nibble6_nibble_sel  : 3;
-		mmr_t	reserved_13         : 1;
-		mmr_t	nibble7_chiplet_sel : 3;
-		mmr_t	reserved_14         : 1;
-		mmr_t	nibble7_nibble_sel  : 3;
-		mmr_t	trigger_enable      : 1;
-	} sh_lb_debug_local_sel_s;
-} sh_lb_debug_local_sel_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_DEBUG_PERF_SEL"                    */
-/*                   LB Debug Port Performance Select                   */
-/* ==================================================================== */
-
-typedef union sh_lb_debug_perf_sel_u {
-	mmr_t	sh_lb_debug_perf_sel_regval;
-	struct {
-		mmr_t	nibble0_chiplet_sel : 3;
-		mmr_t	reserved_0          : 1;
-		mmr_t	nibble0_nibble_sel  : 3;
-		mmr_t	reserved_1          : 1;
-		mmr_t	nibble1_chiplet_sel : 3;
-		mmr_t	reserved_2          : 1;
-		mmr_t	nibble1_nibble_sel  : 3;
-		mmr_t	reserved_3          : 1;
-		mmr_t	nibble2_chiplet_sel : 3;
-		mmr_t	reserved_4          : 1;
-		mmr_t	nibble2_nibble_sel  : 3;
-		mmr_t	reserved_5          : 1;
-		mmr_t	nibble3_chiplet_sel : 3;
-		mmr_t	reserved_6          : 1;
-		mmr_t	nibble3_nibble_sel  : 3;
-		mmr_t	reserved_7          : 1;
-		mmr_t	nibble4_chiplet_sel : 3;
-		mmr_t	reserved_8          : 1;
-		mmr_t	nibble4_nibble_sel  : 3;
-		mmr_t	reserved_9          : 1;
-		mmr_t	nibble5_chiplet_sel : 3;
-		mmr_t	reserved_10         : 1;
-		mmr_t	nibble5_nibble_sel  : 3;
-		mmr_t	reserved_11         : 1;
-		mmr_t	nibble6_chiplet_sel : 3;
-		mmr_t	reserved_12         : 1;
-		mmr_t	nibble6_nibble_sel  : 3;
-		mmr_t	reserved_13         : 1;
-		mmr_t	nibble7_chiplet_sel : 3;
-		mmr_t	reserved_14         : 1;
-		mmr_t	nibble7_nibble_sel  : 3;
-		mmr_t	reserved_15         : 1;
-	} sh_lb_debug_perf_sel_s;
-} sh_lb_debug_perf_sel_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_DEBUG_TRIG_SEL"                    */
-/*                       LB Debug Trigger Select                        */
-/* ==================================================================== */
-
-typedef union sh_lb_debug_trig_sel_u {
-	mmr_t	sh_lb_debug_trig_sel_regval;
-	struct {
-		mmr_t	trigger0_chiplet_sel : 3;
-		mmr_t	reserved_0           : 1;
-		mmr_t	trigger0_nibble_sel  : 3;
-		mmr_t	reserved_1           : 1;
-		mmr_t	trigger1_chiplet_sel : 3;
-		mmr_t	reserved_2           : 1;
-		mmr_t	trigger1_nibble_sel  : 3;
-		mmr_t	reserved_3           : 1;
-		mmr_t	trigger2_chiplet_sel : 3;
-		mmr_t	reserved_4           : 1;
-		mmr_t	trigger2_nibble_sel  : 3;
-		mmr_t	reserved_5           : 1;
-		mmr_t	trigger3_chiplet_sel : 3;
-		mmr_t	reserved_6           : 1;
-		mmr_t	trigger3_nibble_sel  : 3;
-		mmr_t	reserved_7           : 1;
-		mmr_t	trigger4_chiplet_sel : 3;
-		mmr_t	reserved_8           : 1;
-		mmr_t	trigger4_nibble_sel  : 3;
-		mmr_t	reserved_9           : 1;
-		mmr_t	trigger5_chiplet_sel : 3;
-		mmr_t	reserved_10          : 1;
-		mmr_t	trigger5_nibble_sel  : 3;
-		mmr_t	reserved_11          : 1;
-		mmr_t	trigger6_chiplet_sel : 3;
-		mmr_t	reserved_12          : 1;
-		mmr_t	trigger6_nibble_sel  : 3;
-		mmr_t	reserved_13          : 1;
-		mmr_t	trigger7_chiplet_sel : 3;
-		mmr_t	reserved_14          : 1;
-		mmr_t	trigger7_nibble_sel  : 3;
-		mmr_t	reserved_15          : 1;
-	} sh_lb_debug_trig_sel_s;
-} sh_lb_debug_trig_sel_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_1"                    */
-/*                  LB Error capture information: HDR1                  */
-/* ==================================================================== */
-
-typedef union sh_lb_error_detail_1_u {
-	mmr_t	sh_lb_error_detail_1_regval;
-	struct {
-		mmr_t	command     : 8;
-		mmr_t	suppl       : 14;
-		mmr_t	reserved_0  : 2;
-		mmr_t	source      : 14;
-		mmr_t	reserved_1  : 2;
-		mmr_t	dest        : 3;
-		mmr_t	reserved_2  : 5;
-		mmr_t	hdr_err     : 1;
-		mmr_t	data_err    : 1;
-		mmr_t	reserved_3  : 13;
-		mmr_t	valid       : 1;
-	} sh_lb_error_detail_1_s;
-} sh_lb_error_detail_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_2"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-typedef union sh_lb_error_detail_2_u {
-	mmr_t	sh_lb_error_detail_2_regval;
-	struct {
-		mmr_t	address     : 47;
-		mmr_t	reserved_0  : 17;
-	} sh_lb_error_detail_2_s;
-} sh_lb_error_detail_2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_3"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-typedef union sh_lb_error_detail_3_u {
-	mmr_t	sh_lb_error_detail_3_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_lb_error_detail_3_s;
-} sh_lb_error_detail_3_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_4"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-typedef union sh_lb_error_detail_4_u {
-	mmr_t	sh_lb_error_detail_4_regval;
-	struct {
-		mmr_t	route       : 64;
-	} sh_lb_error_detail_4_s;
-} sh_lb_error_detail_4_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_DETAIL_5"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-typedef union sh_lb_error_detail_5_u {
-	mmr_t	sh_lb_error_detail_5_regval;
-	struct {
-		mmr_t	read_retry       : 1;
-		mmr_t	ptc1_write       : 1;
-		mmr_t	write_retry      : 1;
-		mmr_t	count_a_overflow : 1;
-		mmr_t	count_b_overflow : 1;
-		mmr_t	nack_a_timeout   : 1;
-		mmr_t	nack_b_timeout   : 1;
-		mmr_t	reserved_0       : 57;
-	} sh_lb_error_detail_5_s;
-} sh_lb_error_detail_5_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_LB_ERROR_MASK"                      */
-/*                            LB Error Mask                             */
-/* ==================================================================== */
-
-typedef union sh_lb_error_mask_u {
-	mmr_t	sh_lb_error_mask_regval;
-	struct {
-		mmr_t	rq_bad_cmd            : 1;
-		mmr_t	rp_bad_cmd            : 1;
-		mmr_t	rq_short              : 1;
-		mmr_t	rp_short              : 1;
-		mmr_t	rq_long               : 1;
-		mmr_t	rp_long               : 1;
-		mmr_t	rq_bad_data           : 1;
-		mmr_t	rp_bad_data           : 1;
-		mmr_t	rq_bad_addr           : 1;
-		mmr_t	rq_time_out           : 1;
-		mmr_t	linvv_overflow        : 1;
-		mmr_t	unexpected_linv       : 1;
-		mmr_t	ptc_1_timeout         : 1;
-		mmr_t	junk_bus_err          : 1;
-		mmr_t	pio_cb_err            : 1;
-		mmr_t	vector_rq_route_error : 1;
-		mmr_t	vector_rp_route_error : 1;
-		mmr_t	gclk_drop             : 1;
-		mmr_t	rq_fifo_error         : 1;
-		mmr_t	rp_fifo_error         : 1;
-		mmr_t	unexp_valid           : 1;
-		mmr_t	rq_credit_overflow    : 1;
-		mmr_t	rp_credit_overflow    : 1;
-		mmr_t	reserved_0            : 41;
-	} sh_lb_error_mask_s;
-} sh_lb_error_mask_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_ERROR_OVERFLOW"                    */
-/*                          LB Error Overflow                           */
-/* ==================================================================== */
-
-typedef union sh_lb_error_overflow_u {
-	mmr_t	sh_lb_error_overflow_regval;
-	struct {
-		mmr_t	rq_bad_cmd_ovrfl            : 1;
-		mmr_t	rp_bad_cmd_ovrfl            : 1;
-		mmr_t	rq_short_ovrfl              : 1;
-		mmr_t	rp_short_ovrfl              : 1;
-		mmr_t	rq_long_ovrfl               : 1;
-		mmr_t	rp_long_ovrfl               : 1;
-		mmr_t	rq_bad_data_ovrfl           : 1;
-		mmr_t	rp_bad_data_ovrfl           : 1;
-		mmr_t	rq_bad_addr_ovrfl           : 1;
-		mmr_t	rq_time_out_ovrfl           : 1;
-		mmr_t	linvv_overflow_ovrfl        : 1;
-		mmr_t	unexpected_linv_ovrfl       : 1;
-		mmr_t	ptc_1_timeout_ovrfl         : 1;
-		mmr_t	junk_bus_err_ovrfl          : 1;
-		mmr_t	pio_cb_err_ovrfl            : 1;
-		mmr_t	vector_rq_route_error_ovrfl : 1;
-		mmr_t	vector_rp_route_error_ovrfl : 1;
-		mmr_t	gclk_drop_ovrfl             : 1;
-		mmr_t	rq_fifo_error_ovrfl         : 1;
-		mmr_t	rp_fifo_error_ovrfl         : 1;
-		mmr_t	unexp_valid_ovrfl           : 1;
-		mmr_t	rq_credit_overflow_ovrfl    : 1;
-		mmr_t	rp_credit_overflow_ovrfl    : 1;
-		mmr_t	reserved_0                  : 41;
-	} sh_lb_error_overflow_s;
-} sh_lb_error_overflow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_LB_ERROR_SUMMARY"                    */
-/*                            LB Error Bits                             */
-/* ==================================================================== */
-
-typedef union sh_lb_error_summary_u {
-	mmr_t	sh_lb_error_summary_regval;
-	struct {
-		mmr_t	rq_bad_cmd            : 1;
-		mmr_t	rp_bad_cmd            : 1;
-		mmr_t	rq_short              : 1;
-		mmr_t	rp_short              : 1;
-		mmr_t	rq_long               : 1;
-		mmr_t	rp_long               : 1;
-		mmr_t	rq_bad_data           : 1;
-		mmr_t	rp_bad_data           : 1;
-		mmr_t	rq_bad_addr           : 1;
-		mmr_t	rq_time_out           : 1;
-		mmr_t	linvv_overflow        : 1;
-		mmr_t	unexpected_linv       : 1;
-		mmr_t	ptc_1_timeout         : 1;
-		mmr_t	junk_bus_err          : 1;
-		mmr_t	pio_cb_err            : 1;
-		mmr_t	vector_rq_route_error : 1;
-		mmr_t	vector_rp_route_error : 1;
-		mmr_t	gclk_drop             : 1;
-		mmr_t	rq_fifo_error         : 1;
-		mmr_t	rp_fifo_error         : 1;
-		mmr_t	unexp_valid           : 1;
-		mmr_t	rq_credit_overflow    : 1;
-		mmr_t	rp_credit_overflow    : 1;
-		mmr_t	reserved_0            : 41;
-	} sh_lb_error_summary_s;
-} sh_lb_error_summary_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_LB_FIRST_ERROR"                     */
-/*                            LB First Error                            */
-/* ==================================================================== */
-
-typedef union sh_lb_first_error_u {
-	mmr_t	sh_lb_first_error_regval;
-	struct {
-		mmr_t	rq_bad_cmd            : 1;
-		mmr_t	rp_bad_cmd            : 1;
-		mmr_t	rq_short              : 1;
-		mmr_t	rp_short              : 1;
-		mmr_t	rq_long               : 1;
-		mmr_t	rp_long               : 1;
-		mmr_t	rq_bad_data           : 1;
-		mmr_t	rp_bad_data           : 1;
-		mmr_t	rq_bad_addr           : 1;
-		mmr_t	rq_time_out           : 1;
-		mmr_t	linvv_overflow        : 1;
-		mmr_t	unexpected_linv       : 1;
-		mmr_t	ptc_1_timeout         : 1;
-		mmr_t	junk_bus_err          : 1;
-		mmr_t	pio_cb_err            : 1;
-		mmr_t	vector_rq_route_error : 1;
-		mmr_t	vector_rp_route_error : 1;
-		mmr_t	gclk_drop             : 1;
-		mmr_t	rq_fifo_error         : 1;
-		mmr_t	rp_fifo_error         : 1;
-		mmr_t	unexp_valid           : 1;
-		mmr_t	rq_credit_overflow    : 1;
-		mmr_t	rp_credit_overflow    : 1;
-		mmr_t	reserved_0            : 41;
-	} sh_lb_first_error_s;
-} sh_lb_first_error_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_LB_LAST_CREDIT"                     */
-/*                    Credit counter status register                    */
-/* ==================================================================== */
-
-typedef union sh_lb_last_credit_u {
-	mmr_t	sh_lb_last_credit_regval;
-	struct {
-		mmr_t	liq_rq_credit : 5;
-		mmr_t	reserved_0    : 1;
-		mmr_t	liq_rp_credit : 4;
-		mmr_t	reserved_1    : 2;
-		mmr_t	linvv_credit  : 6;
-		mmr_t	loq_rq_credit : 5;
-		mmr_t	loq_rp_credit : 5;
-		mmr_t	reserved_2    : 36;
-	} sh_lb_last_credit_s;
-} sh_lb_last_credit_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_LB_NACK_STATUS"                     */
-/*                     Nack Counter Status Register                     */
-/* ==================================================================== */
-
-typedef union sh_lb_nack_status_u {
-	mmr_t	sh_lb_nack_status_regval;
-	struct {
-		mmr_t	pio_nack_a       : 12;
-		mmr_t	reserved_0       : 4;
-		mmr_t	pio_nack_b       : 12;
-		mmr_t	reserved_1       : 4;
-		mmr_t	junk_nack        : 16;
-		mmr_t	cb_timeout_count : 12;
-		mmr_t	cb_state         : 2;
-		mmr_t	reserved_2       : 2;
-	} sh_lb_nack_status_s;
-} sh_lb_nack_status_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_LB_TRIGGER_COMPARE"                   */
-/*                    LB Test-point Trigger Compare                     */
-/* ==================================================================== */
-
-typedef union sh_lb_trigger_compare_u {
-	mmr_t	sh_lb_trigger_compare_regval;
-	struct {
-		mmr_t	mask        : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_lb_trigger_compare_s;
-} sh_lb_trigger_compare_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_LB_TRIGGER_DATA"                     */
-/*                  LB Test-point Trigger Compare Data                  */
-/* ==================================================================== */
-
-typedef union sh_lb_trigger_data_u {
-	mmr_t	sh_lb_trigger_data_regval;
-	struct {
-		mmr_t	compare_pattern : 32;
-		mmr_t	reserved_0      : 32;
-	} sh_lb_trigger_data_s;
-} sh_lb_trigger_data_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PI_AEC_CONFIG"                      */
-/*              PI Adaptive Error Correction Configuration              */
-/* ==================================================================== */
-
-typedef union sh_pi_aec_config_u {
-	mmr_t	sh_pi_aec_config_regval;
-	struct {
-		mmr_t	mode        : 3;
-		mmr_t	reserved_0  : 61;
-	} sh_pi_aec_config_s;
-} sh_pi_aec_config_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_AFI_ERROR_MASK"                    */
-/*                          PI AFI Error Mask                           */
-/* ==================================================================== */
-
-typedef union sh_pi_afi_error_mask_u {
-	mmr_t	sh_pi_afi_error_mask_regval;
-	struct {
-		mmr_t	reserved_0   : 21;
-		mmr_t	hung_bus     : 1;
-		mmr_t	rsp_parity   : 1;
-		mmr_t	ioq_overrun  : 1;
-		mmr_t	req_format   : 1;
-		mmr_t	addr_access  : 1;
-		mmr_t	req_parity   : 1;
-		mmr_t	addr_parity  : 1;
-		mmr_t	shub_fsb_dqe : 1;
-		mmr_t	shub_fsb_uce : 1;
-		mmr_t	shub_fsb_ce  : 1;
-		mmr_t	livelock     : 1;
-		mmr_t	bad_snoop    : 1;
-		mmr_t	fsb_tbl_miss : 1;
-		mmr_t	msg_len      : 1;
-		mmr_t	reserved_1   : 29;
-	} sh_pi_afi_error_mask_s;
-} sh_pi_afi_error_mask_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_AFI_TEST_POINT_COMPARE"                */
-/*                      PI AFI Test Point Compare                       */
-/* ==================================================================== */
-
-typedef union sh_pi_afi_test_point_compare_u {
-	mmr_t	sh_pi_afi_test_point_compare_regval;
-	struct {
-		mmr_t	compare_mask    : 32;
-		mmr_t	compare_pattern : 32;
-	} sh_pi_afi_test_point_compare_s;
-} sh_pi_afi_test_point_compare_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_AFI_TEST_POINT_SELECT"                */
-/*                       PI AFI Test Point Select                       */
-/* ==================================================================== */
-
-typedef union sh_pi_afi_test_point_select_u {
-	mmr_t	sh_pi_afi_test_point_select_regval;
-	struct {
-		mmr_t	nibble0_chiplet_sel : 4;
-		mmr_t	nibble0_nibble_sel  : 3;
-		mmr_t	reserved_0          : 1;
-		mmr_t	nibble1_chiplet_sel : 4;
-		mmr_t	nibble1_nibble_sel  : 3;
-		mmr_t	reserved_1          : 1;
-		mmr_t	nibble2_chiplet_sel : 4;
-		mmr_t	nibble2_nibble_sel  : 3;
-		mmr_t	reserved_2          : 1;
-		mmr_t	nibble3_chiplet_sel : 4;
-		mmr_t	nibble3_nibble_sel  : 3;
-		mmr_t	reserved_3          : 1;
-		mmr_t	nibble4_chiplet_sel : 4;
-		mmr_t	nibble4_nibble_sel  : 3;
-		mmr_t	reserved_4          : 1;
-		mmr_t	nibble5_chiplet_sel : 4;
-		mmr_t	nibble5_nibble_sel  : 3;
-		mmr_t	reserved_5          : 1;
-		mmr_t	nibble6_chiplet_sel : 4;
-		mmr_t	nibble6_nibble_sel  : 3;
-		mmr_t	reserved_6          : 1;
-		mmr_t	nibble7_chiplet_sel : 4;
-		mmr_t	nibble7_nibble_sel  : 3;
-		mmr_t	trigger_enable      : 1;
-	} sh_pi_afi_test_point_select_s;
-} sh_pi_afi_test_point_select_u_t;
-
-/* ==================================================================== */
-/*            Register "SH_PI_AFI_TEST_POINT_TRIGGER_SELECT"            */
-/*                  PI CRBC Test Point Trigger Select                   */
-/* ==================================================================== */
-
-typedef union sh_pi_afi_test_point_trigger_select_u {
-	mmr_t	sh_pi_afi_test_point_trigger_select_regval;
-	struct {
-		mmr_t	trigger0_chiplet_sel : 4;
-		mmr_t	trigger0_nibble_sel  : 3;
-		mmr_t	reserved_0           : 1;
-		mmr_t	trigger1_chiplet_sel : 4;
-		mmr_t	trigger1_nibble_sel  : 3;
-		mmr_t	reserved_1           : 1;
-		mmr_t	trigger2_chiplet_sel : 4;
-		mmr_t	trigger2_nibble_sel  : 3;
-		mmr_t	reserved_2           : 1;
-		mmr_t	trigger3_chiplet_sel : 4;
-		mmr_t	trigger3_nibble_sel  : 3;
-		mmr_t	reserved_3           : 1;
-		mmr_t	trigger4_chiplet_sel : 4;
-		mmr_t	trigger4_nibble_sel  : 3;
-		mmr_t	reserved_4           : 1;
-		mmr_t	trigger5_chiplet_sel : 4;
-		mmr_t	trigger5_nibble_sel  : 3;
-		mmr_t	reserved_5           : 1;
-		mmr_t	trigger6_chiplet_sel : 4;
-		mmr_t	trigger6_nibble_sel  : 3;
-		mmr_t	reserved_6           : 1;
-		mmr_t	trigger7_chiplet_sel : 4;
-		mmr_t	trigger7_nibble_sel  : 3;
-		mmr_t	reserved_7           : 1;
-	} sh_pi_afi_test_point_trigger_select_s;
-} sh_pi_afi_test_point_trigger_select_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PI_AUTO_REPLY_ENABLE"                  */
-/*                         PI Auto Reply Enable                         */
-/* ==================================================================== */
-
-typedef union sh_pi_auto_reply_enable_u {
-	mmr_t	sh_pi_auto_reply_enable_regval;
-	struct {
-		mmr_t	auto_reply_enable : 1;
-		mmr_t	reserved_0        : 63;
-	} sh_pi_auto_reply_enable_s;
-} sh_pi_auto_reply_enable_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PI_CAM_CONTROL"                     */
-/*                      CRB CAM MMR Access Control                      */
-/* ==================================================================== */
-
-typedef union sh_pi_cam_control_u {
-	mmr_t	sh_pi_cam_control_regval;
-	struct {
-		mmr_t	cam_indx          : 7;
-		mmr_t	reserved_0        : 1;
-		mmr_t	cam_write         : 1;
-		mmr_t	rrb_rd_xfer_clear : 1;
-		mmr_t	reserved_1        : 53;
-		mmr_t	start             : 1;
-	} sh_pi_cam_control_s;
-} sh_pi_cam_control_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBC_TEST_POINT_COMPARE"               */
-/*                      PI CRBC Test Point Compare                      */
-/* ==================================================================== */
-
-typedef union sh_pi_crbc_test_point_compare_u {
-	mmr_t	sh_pi_crbc_test_point_compare_regval;
-	struct {
-		mmr_t	compare_mask    : 32;
-		mmr_t	compare_pattern : 32;
-	} sh_pi_crbc_test_point_compare_s;
-} sh_pi_crbc_test_point_compare_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBC_TEST_POINT_SELECT"                */
-/*                      PI CRBC Test Point Select                       */
-/* ==================================================================== */
-
-typedef union sh_pi_crbc_test_point_select_u {
-	mmr_t	sh_pi_crbc_test_point_select_regval;
-	struct {
-		mmr_t	nibble0_chiplet_sel : 3;
-		mmr_t	reserved_0          : 1;
-		mmr_t	nibble0_nibble_sel  : 3;
-		mmr_t	reserved_1          : 1;
-		mmr_t	nibble1_chiplet_sel : 3;
-		mmr_t	reserved_2          : 1;
-		mmr_t	nibble1_nibble_sel  : 3;
-		mmr_t	reserved_3          : 1;
-		mmr_t	nibble2_chiplet_sel : 3;
-		mmr_t	reserved_4          : 1;
-		mmr_t	nibble2_nibble_sel  : 3;
-		mmr_t	reserved_5          : 1;
-		mmr_t	nibble3_chiplet_sel : 3;
-		mmr_t	reserved_6          : 1;
-		mmr_t	nibble3_nibble_sel  : 3;
-		mmr_t	reserved_7          : 1;
-		mmr_t	nibble4_chiplet_sel : 3;
-		mmr_t	reserved_8          : 1;
-		mmr_t	nibble4_nibble_sel  : 3;
-		mmr_t	reserved_9          : 1;
-		mmr_t	nibble5_chiplet_sel : 3;
-		mmr_t	reserved_10         : 1;
-		mmr_t	nibble5_nibble_sel  : 3;
-		mmr_t	reserved_11         : 1;
-		mmr_t	nibble6_chiplet_sel : 3;
-		mmr_t	reserved_12         : 1;
-		mmr_t	nibble6_nibble_sel  : 3;
-		mmr_t	reserved_13         : 1;
-		mmr_t	nibble7_chiplet_sel : 3;
-		mmr_t	reserved_14         : 1;
-		mmr_t	nibble7_nibble_sel  : 3;
-		mmr_t	trigger_enable      : 1;
-	} sh_pi_crbc_test_point_select_s;
-} sh_pi_crbc_test_point_select_u_t;
-
-/* ==================================================================== */
-/*           Register "SH_PI_CRBC_TEST_POINT_TRIGGER_SELECT"            */
-/*                  PI CRBC Test Point Trigger Select                   */
-/* ==================================================================== */
-
-typedef union sh_pi_crbc_test_point_trigger_select_u {
-	mmr_t	sh_pi_crbc_test_point_trigger_select_regval;
-	struct {
-		mmr_t	trigger0_chiplet_sel : 3;
-		mmr_t	reserved_0           : 1;
-		mmr_t	trigger0_nibble_sel  : 3;
-		mmr_t	reserved_1           : 1;
-		mmr_t	trigger1_chiplet_sel : 3;
-		mmr_t	reserved_2           : 1;
-		mmr_t	trigger1_nibble_sel  : 3;
-		mmr_t	reserved_3           : 1;
-		mmr_t	trigger2_chiplet_sel : 3;
-		mmr_t	reserved_4           : 1;
-		mmr_t	trigger2_nibble_sel  : 3;
-		mmr_t	reserved_5           : 1;
-		mmr_t	trigger3_chiplet_sel : 3;
-		mmr_t	reserved_6           : 1;
-		mmr_t	trigger3_nibble_sel  : 3;
-		mmr_t	reserved_7           : 1;
-		mmr_t	trigger4_chiplet_sel : 3;
-		mmr_t	reserved_8           : 1;
-		mmr_t	trigger4_nibble_sel  : 3;
-		mmr_t	reserved_9           : 1;
-		mmr_t	trigger5_chiplet_sel : 3;
-		mmr_t	reserved_10          : 1;
-		mmr_t	trigger5_nibble_sel  : 3;
-		mmr_t	reserved_11          : 1;
-		mmr_t	trigger6_chiplet_sel : 3;
-		mmr_t	reserved_12          : 1;
-		mmr_t	trigger6_nibble_sel  : 3;
-		mmr_t	reserved_13          : 1;
-		mmr_t	trigger7_chiplet_sel : 3;
-		mmr_t	reserved_14          : 1;
-		mmr_t	trigger7_nibble_sel  : 3;
-		mmr_t	reserved_15          : 1;
-	} sh_pi_crbc_test_point_trigger_select_s;
-} sh_pi_crbc_test_point_trigger_select_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_CRBP_ERROR_MASK"                   */
-/*                          PI CRBP Error Mask                          */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_error_mask_u {
-	mmr_t	sh_pi_crbp_error_mask_regval;
-	struct {
-		mmr_t	fsb_proto_err   : 1;
-		mmr_t	gfx_rp_err      : 1;
-		mmr_t	xb_proto_err    : 1;
-		mmr_t	mem_rp_err      : 1;
-		mmr_t	pio_rp_err      : 1;
-		mmr_t	mem_to_err      : 1;
-		mmr_t	pio_to_err      : 1;
-		mmr_t	fsb_shub_uce    : 1;
-		mmr_t	fsb_shub_ce     : 1;
-		mmr_t	msg_color_err   : 1;
-		mmr_t	md_rq_q_oflow   : 1;
-		mmr_t	md_rp_q_oflow   : 1;
-		mmr_t	xn_rq_q_oflow   : 1;
-		mmr_t	xn_rp_q_oflow   : 1;
-		mmr_t	nack_oflow      : 1;
-		mmr_t	gfx_int_0       : 1;
-		mmr_t	gfx_int_1       : 1;
-		mmr_t	md_rq_crd_oflow : 1;
-		mmr_t	md_rp_crd_oflow : 1;
-		mmr_t	xn_rq_crd_oflow : 1;
-		mmr_t	xn_rp_crd_oflow : 1;
-		mmr_t	reserved_0      : 43;
-	} sh_pi_crbp_error_mask_s;
-} sh_pi_crbp_error_mask_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_CRBP_FSB_PIPE_COMPARE"                */
-/*                        CRBP FSB Pipe Compare                         */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_fsb_pipe_compare_u {
-	mmr_t	sh_pi_crbp_fsb_pipe_compare_regval;
-	struct {
-		mmr_t	compare_address : 47;
-		mmr_t	compare_req     : 6;
-		mmr_t	reserved_0      : 11;
-	} sh_pi_crbp_fsb_pipe_compare_s;
-} sh_pi_crbp_fsb_pipe_compare_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CRBP_FSB_PIPE_MASK"                  */
-/*                          CRBP Compare Mask                           */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_fsb_pipe_mask_u {
-	mmr_t	sh_pi_crbp_fsb_pipe_mask_regval;
-	struct {
-		mmr_t	compare_address_mask : 47;
-		mmr_t	compare_req_mask     : 6;
-		mmr_t	reserved_0           : 11;
-	} sh_pi_crbp_fsb_pipe_mask_s;
-} sh_pi_crbp_fsb_pipe_mask_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBP_TEST_POINT_COMPARE"               */
-/*                      PI CRBP Test Point Compare                      */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_test_point_compare_u {
-	mmr_t	sh_pi_crbp_test_point_compare_regval;
-	struct {
-		mmr_t	compare_mask    : 32;
-		mmr_t	compare_pattern : 32;
-	} sh_pi_crbp_test_point_compare_s;
-} sh_pi_crbp_test_point_compare_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBP_TEST_POINT_SELECT"                */
-/*                      PI CRBP Test Point Select                       */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_test_point_select_u {
-	mmr_t	sh_pi_crbp_test_point_select_regval;
-	struct {
-		mmr_t	nibble0_chiplet_sel : 3;
-		mmr_t	reserved_0          : 1;
-		mmr_t	nibble0_nibble_sel  : 3;
-		mmr_t	reserved_1          : 1;
-		mmr_t	nibble1_chiplet_sel : 3;
-		mmr_t	reserved_2          : 1;
-		mmr_t	nibble1_nibble_sel  : 3;
-		mmr_t	reserved_3          : 1;
-		mmr_t	nibble2_chiplet_sel : 3;
-		mmr_t	reserved_4          : 1;
-		mmr_t	nibble2_nibble_sel  : 3;
-		mmr_t	reserved_5          : 1;
-		mmr_t	nibble3_chiplet_sel : 3;
-		mmr_t	reserved_6          : 1;
-		mmr_t	nibble3_nibble_sel  : 3;
-		mmr_t	reserved_7          : 1;
-		mmr_t	nibble4_chiplet_sel : 3;
-		mmr_t	reserved_8          : 1;
-		mmr_t	nibble4_nibble_sel  : 3;
-		mmr_t	reserved_9          : 1;
-		mmr_t	nibble5_chiplet_sel : 3;
-		mmr_t	reserved_10         : 1;
-		mmr_t	nibble5_nibble_sel  : 3;
-		mmr_t	reserved_11         : 1;
-		mmr_t	nibble6_chiplet_sel : 3;
-		mmr_t	reserved_12         : 1;
-		mmr_t	nibble6_nibble_sel  : 3;
-		mmr_t	reserved_13         : 1;
-		mmr_t	nibble7_chiplet_sel : 3;
-		mmr_t	reserved_14         : 1;
-		mmr_t	nibble7_nibble_sel  : 3;
-		mmr_t	trigger_enable      : 1;
-	} sh_pi_crbp_test_point_select_s;
-} sh_pi_crbp_test_point_select_u_t;
-
-/* ==================================================================== */
-/*           Register "SH_PI_CRBP_TEST_POINT_TRIGGER_SELECT"            */
-/*                  PI CRBP Test Point Trigger Select                   */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_test_point_trigger_select_u {
-	mmr_t	sh_pi_crbp_test_point_trigger_select_regval;
-	struct {
-		mmr_t	trigger0_chiplet_sel : 3;
-		mmr_t	reserved_0           : 1;
-		mmr_t	trigger0_nibble_sel  : 3;
-		mmr_t	reserved_1           : 1;
-		mmr_t	trigger1_chiplet_sel : 3;
-		mmr_t	reserved_2           : 1;
-		mmr_t	trigger1_nibble_sel  : 3;
-		mmr_t	reserved_3           : 1;
-		mmr_t	trigger2_chiplet_sel : 3;
-		mmr_t	reserved_4           : 1;
-		mmr_t	trigger2_nibble_sel  : 3;
-		mmr_t	reserved_5           : 1;
-		mmr_t	trigger3_chiplet_sel : 3;
-		mmr_t	reserved_6           : 1;
-		mmr_t	trigger3_nibble_sel  : 3;
-		mmr_t	reserved_7           : 1;
-		mmr_t	trigger4_chiplet_sel : 3;
-		mmr_t	reserved_8           : 1;
-		mmr_t	trigger4_nibble_sel  : 3;
-		mmr_t	reserved_9           : 1;
-		mmr_t	trigger5_chiplet_sel : 3;
-		mmr_t	reserved_10          : 1;
-		mmr_t	trigger5_nibble_sel  : 3;
-		mmr_t	reserved_11          : 1;
-		mmr_t	trigger6_chiplet_sel : 3;
-		mmr_t	reserved_12          : 1;
-		mmr_t	trigger6_nibble_sel  : 3;
-		mmr_t	reserved_13          : 1;
-		mmr_t	trigger7_chiplet_sel : 3;
-		mmr_t	reserved_14          : 1;
-		mmr_t	trigger7_nibble_sel  : 3;
-		mmr_t	reserved_15          : 1;
-	} sh_pi_crbp_test_point_trigger_select_s;
-} sh_pi_crbp_test_point_trigger_select_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBP_XB_PIPE_COMPARE_0"                */
-/*                         CRBP XB Pipe Compare                         */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_xb_pipe_compare_0_u {
-	mmr_t	sh_pi_crbp_xb_pipe_compare_0_regval;
-	struct {
-		mmr_t	compare_address : 47;
-		mmr_t	compare_command : 8;
-		mmr_t	reserved_0      : 9;
-	} sh_pi_crbp_xb_pipe_compare_0_s;
-} sh_pi_crbp_xb_pipe_compare_0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_CRBP_XB_PIPE_COMPARE_1"                */
-/*                         CRBP XB Pipe Compare                         */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_xb_pipe_compare_1_u {
-	mmr_t	sh_pi_crbp_xb_pipe_compare_1_regval;
-	struct {
-		mmr_t	compare_source       : 14;
-		mmr_t	reserved_0           : 2;
-		mmr_t	compare_supplemental : 14;
-		mmr_t	reserved_1           : 2;
-		mmr_t	compare_echo         : 9;
-		mmr_t	reserved_2           : 23;
-	} sh_pi_crbp_xb_pipe_compare_1_s;
-} sh_pi_crbp_xb_pipe_compare_1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CRBP_XB_PIPE_MASK_0"                 */
-/*                     CRBP Compare Mask Register 1                     */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_xb_pipe_mask_0_u {
-	mmr_t	sh_pi_crbp_xb_pipe_mask_0_regval;
-	struct {
-		mmr_t	compare_address_mask : 47;
-		mmr_t	compare_command_mask : 8;
-		mmr_t	reserved_0           : 9;
-	} sh_pi_crbp_xb_pipe_mask_0_s;
-} sh_pi_crbp_xb_pipe_mask_0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CRBP_XB_PIPE_MASK_1"                 */
-/*                 CRBP XB Pipe Compare Mask Register 1                 */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_xb_pipe_mask_1_u {
-	mmr_t	sh_pi_crbp_xb_pipe_mask_1_regval;
-	struct {
-		mmr_t	compare_source_mask       : 14;
-		mmr_t	reserved_0                : 2;
-		mmr_t	compare_supplemental_mask : 14;
-		mmr_t	reserved_1                : 2;
-		mmr_t	compare_echo_mask         : 9;
-		mmr_t	reserved_2                : 23;
-	} sh_pi_crbp_xb_pipe_mask_1_s;
-} sh_pi_crbp_xb_pipe_mask_1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PI_DPC_QUEUE_CONFIG"                   */
-/*                       DPC Queue Configuration                        */
-/* ==================================================================== */
-
-typedef union sh_pi_dpc_queue_config_u {
-	mmr_t	sh_pi_dpc_queue_config_regval;
-	struct {
-		mmr_t	dwcq_ae_level  : 5;
-		mmr_t	reserved_0     : 3;
-		mmr_t	dwcq_af_thresh : 5;
-		mmr_t	reserved_1     : 3;
-		mmr_t	fwcq_ae_level  : 5;
-		mmr_t	reserved_2     : 3;
-		mmr_t	fwcq_af_thresh : 5;
-		mmr_t	reserved_3     : 35;
-	} sh_pi_dpc_queue_config_s;
-} sh_pi_dpc_queue_config_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PI_ERROR_MASK"                      */
-/*                            PI Error Mask                             */
-/* ==================================================================== */
-
-typedef union sh_pi_error_mask_u {
-	mmr_t	sh_pi_error_mask_regval;
-	struct {
-		mmr_t	fsb_proto_err   : 1;
-		mmr_t	gfx_rp_err      : 1;
-		mmr_t	xb_proto_err    : 1;
-		mmr_t	mem_rp_err      : 1;
-		mmr_t	pio_rp_err      : 1;
-		mmr_t	mem_to_err      : 1;
-		mmr_t	pio_to_err      : 1;
-		mmr_t	fsb_shub_uce    : 1;
-		mmr_t	fsb_shub_ce     : 1;
-		mmr_t	msg_color_err   : 1;
-		mmr_t	md_rq_q_oflow   : 1;
-		mmr_t	md_rp_q_oflow   : 1;
-		mmr_t	xn_rq_q_oflow   : 1;
-		mmr_t	xn_rp_q_oflow   : 1;
-		mmr_t	nack_oflow      : 1;
-		mmr_t	gfx_int_0       : 1;
-		mmr_t	gfx_int_1       : 1;
-		mmr_t	md_rq_crd_oflow : 1;
-		mmr_t	md_rp_crd_oflow : 1;
-		mmr_t	xn_rq_crd_oflow : 1;
-		mmr_t	xn_rp_crd_oflow : 1;
-		mmr_t	hung_bus        : 1;
-		mmr_t	rsp_parity      : 1;
-		mmr_t	ioq_overrun     : 1;
-		mmr_t	req_format      : 1;
-		mmr_t	addr_access     : 1;
-		mmr_t	req_parity      : 1;
-		mmr_t	addr_parity     : 1;
-		mmr_t	shub_fsb_dqe    : 1;
-		mmr_t	shub_fsb_uce    : 1;
-		mmr_t	shub_fsb_ce     : 1;
-		mmr_t	livelock        : 1;
-		mmr_t	bad_snoop       : 1;
-		mmr_t	fsb_tbl_miss    : 1;
-		mmr_t	msg_length      : 1;
-		mmr_t	reserved_0      : 29;
-	} sh_pi_error_mask_s;
-} sh_pi_error_mask_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_EXPRESS_REPLY_CONFIG"                 */
-/*                    PI Express Reply Configuration                    */
-/* ==================================================================== */
-
-typedef union sh_pi_express_reply_config_u {
-	mmr_t	sh_pi_express_reply_config_regval;
-	struct {
-		mmr_t	mode        : 3;
-		mmr_t	reserved_0  : 61;
-	} sh_pi_express_reply_config_s;
-} sh_pi_express_reply_config_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PI_FSB_COMPARE_VALUE"                  */
-/*                          FSB Compare Value                           */
-/* ==================================================================== */
-
-typedef union sh_pi_fsb_compare_value_u {
-	mmr_t	sh_pi_fsb_compare_value_regval;
-	struct {
-		mmr_t	compare_value : 64;
-	} sh_pi_fsb_compare_value_s;
-} sh_pi_fsb_compare_value_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PI_FSB_COMPARE_MASK"                   */
-/*                           FSB Compare Mask                           */
-/* ==================================================================== */
-
-typedef union sh_pi_fsb_compare_mask_u {
-	mmr_t	sh_pi_fsb_compare_mask_regval;
-	struct {
-		mmr_t	mask_value  : 64;
-	} sh_pi_fsb_compare_mask_s;
-} sh_pi_fsb_compare_mask_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_FSB_ERROR_INJECTION"                 */
-/*                     Inject an Error onto the FSB                     */
-/* ==================================================================== */
-
-typedef union sh_pi_fsb_error_injection_u {
-	mmr_t	sh_pi_fsb_error_injection_regval;
-	struct {
-		mmr_t	rp_pe_to_fsb     : 1;
-		mmr_t	ap0_pe_to_fsb    : 1;
-		mmr_t	ap1_pe_to_fsb    : 1;
-		mmr_t	rsp_pe_to_fsb    : 1;
-		mmr_t	dw0_ce_to_fsb    : 1;
-		mmr_t	dw0_uce_to_fsb   : 1;
-		mmr_t	dw1_ce_to_fsb    : 1;
-		mmr_t	dw1_uce_to_fsb   : 1;
-		mmr_t	ip0_pe_to_fsb    : 1;
-		mmr_t	ip1_pe_to_fsb    : 1;
-		mmr_t	reserved_0       : 6;
-		mmr_t	rp_pe_from_fsb   : 1;
-		mmr_t	ap0_pe_from_fsb  : 1;
-		mmr_t	ap1_pe_from_fsb  : 1;
-		mmr_t	rsp_pe_from_fsb  : 1;
-		mmr_t	dw0_ce_from_fsb  : 1;
-		mmr_t	dw0_uce_from_fsb : 1;
-		mmr_t	dw1_ce_from_fsb  : 1;
-		mmr_t	dw1_uce_from_fsb : 1;
-		mmr_t	dw2_ce_from_fsb  : 1;
-		mmr_t	dw2_uce_from_fsb : 1;
-		mmr_t	dw3_ce_from_fsb  : 1;
-		mmr_t	dw3_uce_from_fsb : 1;
-		mmr_t	reserved_1       : 4;
-		mmr_t	ioq_overrun      : 1;
-		mmr_t	livelock         : 1;
-		mmr_t	bus_hang         : 1;
-		mmr_t	reserved_2       : 29;
-	} sh_pi_fsb_error_injection_s;
-} sh_pi_fsb_error_injection_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_MD2PI_REPLY_VC_CONFIG"                */
-/*             MD-to-PI Reply Virtual Channel Configuration             */
-/* ==================================================================== */
-
-typedef union sh_pi_md2pi_reply_vc_config_u {
-	mmr_t	sh_pi_md2pi_reply_vc_config_regval;
-	struct {
-		mmr_t	hdr_depth             : 4;
-		mmr_t	data_depth            : 4;
-		mmr_t	max_credits           : 6;
-		mmr_t	reserved_0            : 48;
-		mmr_t	force_credit          : 1;
-		mmr_t	capture_credit_status : 1;
-	} sh_pi_md2pi_reply_vc_config_s;
-} sh_pi_md2pi_reply_vc_config_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_MD2PI_REQUEST_VC_CONFIG"               */
-/*            MD-to-PI Request Virtual Channel Configuration            */
-/* ==================================================================== */
-
-typedef union sh_pi_md2pi_request_vc_config_u {
-	mmr_t	sh_pi_md2pi_request_vc_config_regval;
-	struct {
-		mmr_t	hdr_depth             : 4;
-		mmr_t	data_depth            : 4;
-		mmr_t	max_credits           : 6;
-		mmr_t	reserved_0            : 48;
-		mmr_t	force_credit          : 1;
-		mmr_t	capture_credit_status : 1;
-	} sh_pi_md2pi_request_vc_config_s;
-} sh_pi_md2pi_request_vc_config_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_QUEUE_ERROR_INJECTION"                */
-/*                       PI Queue Error Injection                       */
-/* ==================================================================== */
-
-typedef union sh_pi_queue_error_injection_u {
-	mmr_t	sh_pi_queue_error_injection_regval;
-	struct {
-		mmr_t	dat_dfr_q      : 1;
-		mmr_t	dxb_wtl_cmnd_q : 1;
-		mmr_t	fsb_wtl_cmnd_q : 1;
-		mmr_t	mdpi_rpy_bfr   : 1;
-		mmr_t	ptc_intr       : 1;
-		mmr_t	rxl_kill_q     : 1;
-		mmr_t	rxl_rdy_q      : 1;
-		mmr_t	xnpi_rpy_bfr   : 1;
-		mmr_t	reserved_0     : 56;
-	} sh_pi_queue_error_injection_s;
-} sh_pi_queue_error_injection_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_TEST_POINT_COMPARE"                  */
-/*                        PI Test Point Compare                         */
-/* ==================================================================== */
-
-typedef union sh_pi_test_point_compare_u {
-	mmr_t	sh_pi_test_point_compare_regval;
-	struct {
-		mmr_t	compare_mask    : 32;
-		mmr_t	compare_pattern : 32;
-	} sh_pi_test_point_compare_s;
-} sh_pi_test_point_compare_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PI_TEST_POINT_SELECT"                  */
-/*                         PI Test Point Select                         */
-/* ==================================================================== */
-
-typedef union sh_pi_test_point_select_u {
-	mmr_t	sh_pi_test_point_select_regval;
-	struct {
-		mmr_t	nibble0_chiplet_sel : 3;
-		mmr_t	reserved_0          : 1;
-		mmr_t	nibble0_nibble_sel  : 3;
-		mmr_t	reserved_1          : 1;
-		mmr_t	nibble1_chiplet_sel : 3;
-		mmr_t	reserved_2          : 1;
-		mmr_t	nibble1_nibble_sel  : 3;
-		mmr_t	reserved_3          : 1;
-		mmr_t	nibble2_chiplet_sel : 3;
-		mmr_t	reserved_4          : 1;
-		mmr_t	nibble2_nibble_sel  : 3;
-		mmr_t	reserved_5          : 1;
-		mmr_t	nibble3_chiplet_sel : 3;
-		mmr_t	reserved_6          : 1;
-		mmr_t	nibble3_nibble_sel  : 3;
-		mmr_t	reserved_7          : 1;
-		mmr_t	nibble4_chiplet_sel : 3;
-		mmr_t	reserved_8          : 1;
-		mmr_t	nibble4_nibble_sel  : 3;
-		mmr_t	reserved_9          : 1;
-		mmr_t	nibble5_chiplet_sel : 3;
-		mmr_t	reserved_10         : 1;
-		mmr_t	nibble5_nibble_sel  : 3;
-		mmr_t	reserved_11         : 1;
-		mmr_t	nibble6_chiplet_sel : 3;
-		mmr_t	reserved_12         : 1;
-		mmr_t	nibble6_nibble_sel  : 3;
-		mmr_t	reserved_13         : 1;
-		mmr_t	nibble7_chiplet_sel : 3;
-		mmr_t	reserved_14         : 1;
-		mmr_t	nibble7_nibble_sel  : 3;
-		mmr_t	trigger_enable      : 1;
-	} sh_pi_test_point_select_s;
-} sh_pi_test_point_select_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_PI_TEST_POINT_TRIGGER_SELECT"              */
-/*                     PI Test Point Trigger Select                     */
-/* ==================================================================== */
-
-typedef union sh_pi_test_point_trigger_select_u {
-	mmr_t	sh_pi_test_point_trigger_select_regval;
-	struct {
-		mmr_t	trigger0_chiplet_sel : 3;
-		mmr_t	reserved_0           : 1;
-		mmr_t	trigger0_nibble_sel  : 3;
-		mmr_t	reserved_1           : 1;
-		mmr_t	trigger1_chiplet_sel : 3;
-		mmr_t	reserved_2           : 1;
-		mmr_t	trigger1_nibble_sel  : 3;
-		mmr_t	reserved_3           : 1;
-		mmr_t	trigger2_chiplet_sel : 3;
-		mmr_t	reserved_4           : 1;
-		mmr_t	trigger2_nibble_sel  : 3;
-		mmr_t	reserved_5           : 1;
-		mmr_t	trigger3_chiplet_sel : 3;
-		mmr_t	reserved_6           : 1;
-		mmr_t	trigger3_nibble_sel  : 3;
-		mmr_t	reserved_7           : 1;
-		mmr_t	trigger4_chiplet_sel : 3;
-		mmr_t	reserved_8           : 1;
-		mmr_t	trigger4_nibble_sel  : 3;
-		mmr_t	reserved_9           : 1;
-		mmr_t	trigger5_chiplet_sel : 3;
-		mmr_t	reserved_10          : 1;
-		mmr_t	trigger5_nibble_sel  : 3;
-		mmr_t	reserved_11          : 1;
-		mmr_t	trigger6_chiplet_sel : 3;
-		mmr_t	reserved_12          : 1;
-		mmr_t	trigger6_nibble_sel  : 3;
-		mmr_t	reserved_13          : 1;
-		mmr_t	trigger7_chiplet_sel : 3;
-		mmr_t	reserved_14          : 1;
-		mmr_t	trigger7_nibble_sel  : 3;
-		mmr_t	reserved_15          : 1;
-	} sh_pi_test_point_trigger_select_s;
-} sh_pi_test_point_trigger_select_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_XN2PI_REPLY_VC_CONFIG"                */
-/*             XN-to-PI Reply Virtual Channel Configuration             */
-/* ==================================================================== */
-
-typedef union sh_pi_xn2pi_reply_vc_config_u {
-	mmr_t	sh_pi_xn2pi_reply_vc_config_regval;
-	struct {
-		mmr_t	hdr_depth             : 4;
-		mmr_t	data_depth            : 4;
-		mmr_t	max_credits           : 6;
-		mmr_t	reserved_0            : 48;
-		mmr_t	force_credit          : 1;
-		mmr_t	capture_credit_status : 1;
-	} sh_pi_xn2pi_reply_vc_config_s;
-} sh_pi_xn2pi_reply_vc_config_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_XN2PI_REQUEST_VC_CONFIG"               */
-/*            XN-to-PI Request Virtual Channel Configuration            */
-/* ==================================================================== */
-
-typedef union sh_pi_xn2pi_request_vc_config_u {
-	mmr_t	sh_pi_xn2pi_request_vc_config_regval;
-	struct {
-		mmr_t	hdr_depth             : 4;
-		mmr_t	data_depth            : 4;
-		mmr_t	max_credits           : 6;
-		mmr_t	reserved_0            : 48;
-		mmr_t	force_credit          : 1;
-		mmr_t	capture_credit_status : 1;
-	} sh_pi_xn2pi_request_vc_config_s;
-} sh_pi_xn2pi_request_vc_config_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PI_AEC_STATUS"                      */
-/*                 PI Adaptive Error Correction Status                  */
-/* ==================================================================== */
-
-typedef union sh_pi_aec_status_u {
-	mmr_t	sh_pi_aec_status_regval;
-	struct {
-		mmr_t	state       : 3;
-		mmr_t	reserved_0  : 61;
-	} sh_pi_aec_status_s;
-} sh_pi_aec_status_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_AFI_FIRST_ERROR"                   */
-/*                          PI AFI First Error                          */
-/* ==================================================================== */
-
-typedef union sh_pi_afi_first_error_u {
-	mmr_t	sh_pi_afi_first_error_regval;
-	struct {
-		mmr_t	reserved_0   : 7;
-		mmr_t	fsb_shub_uce : 1;
-		mmr_t	fsb_shub_ce  : 1;
-		mmr_t	reserved_1   : 12;
-		mmr_t	hung_bus     : 1;
-		mmr_t	rsp_parity   : 1;
-		mmr_t	ioq_overrun  : 1;
-		mmr_t	req_format   : 1;
-		mmr_t	addr_access  : 1;
-		mmr_t	req_parity   : 1;
-		mmr_t	addr_parity  : 1;
-		mmr_t	shub_fsb_dqe : 1;
-		mmr_t	shub_fsb_uce : 1;
-		mmr_t	shub_fsb_ce  : 1;
-		mmr_t	livelock     : 1;
-		mmr_t	bad_snoop    : 1;
-		mmr_t	fsb_tbl_miss : 1;
-		mmr_t	msg_len      : 1;
-		mmr_t	reserved_2   : 29;
-	} sh_pi_afi_first_error_s;
-} sh_pi_afi_first_error_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_CAM_ADDRESS_READ_DATA"                */
-/*                    CRB CAM MMR Address Read Data                     */
-/* ==================================================================== */
-
-typedef union sh_pi_cam_address_read_data_u {
-	mmr_t	sh_pi_cam_address_read_data_regval;
-	struct {
-		mmr_t	cam_addr     : 48;
-		mmr_t	reserved_0   : 15;
-		mmr_t	cam_addr_val : 1;
-	} sh_pi_cam_address_read_data_s;
-} sh_pi_cam_address_read_data_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CAM_LPRA_READ_DATA"                  */
-/*                      CRB CAM MMR LPRA Read Data                      */
-/* ==================================================================== */
-
-typedef union sh_pi_cam_lpra_read_data_u {
-	mmr_t	sh_pi_cam_lpra_read_data_regval;
-	struct {
-		mmr_t	cam_lpra    : 64;
-	} sh_pi_cam_lpra_read_data_s;
-} sh_pi_cam_lpra_read_data_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CAM_STATE_READ_DATA"                 */
-/*                     CRB CAM MMR State Read Data                      */
-/* ==================================================================== */
-
-typedef union sh_pi_cam_state_read_data_u {
-	mmr_t	sh_pi_cam_state_read_data_regval;
-	struct {
-		mmr_t	cam_state         : 4;
-		mmr_t	cam_to            : 1;
-		mmr_t	cam_state_rd_pend : 1;
-		mmr_t	reserved_0        : 26;
-		mmr_t	cam_lpra          : 18;
-		mmr_t	reserved_1        : 13;
-		mmr_t	cam_rd_data_val   : 1;
-	} sh_pi_cam_state_read_data_s;
-} sh_pi_cam_state_read_data_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CORRECTED_DETAIL_1"                  */
-/*                      PI Corrected Error Detail                       */
-/* ==================================================================== */
-
-typedef union sh_pi_corrected_detail_1_u {
-	mmr_t	sh_pi_corrected_detail_1_regval;
-	struct {
-		mmr_t	address     : 48;
-		mmr_t	syndrome    : 8;
-		mmr_t	dep         : 8;
-	} sh_pi_corrected_detail_1_s;
-} sh_pi_corrected_detail_1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CORRECTED_DETAIL_2"                  */
-/*                     PI Corrected Error Detail 2                      */
-/* ==================================================================== */
-
-typedef union sh_pi_corrected_detail_2_u {
-	mmr_t	sh_pi_corrected_detail_2_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_pi_corrected_detail_2_s;
-} sh_pi_corrected_detail_2_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CORRECTED_DETAIL_3"                  */
-/*                     PI Corrected Error Detail 3                      */
-/* ==================================================================== */
-
-typedef union sh_pi_corrected_detail_3_u {
-	mmr_t	sh_pi_corrected_detail_3_regval;
-	struct {
-		mmr_t	address     : 48;
-		mmr_t	syndrome    : 8;
-		mmr_t	dep         : 8;
-	} sh_pi_corrected_detail_3_s;
-} sh_pi_corrected_detail_3_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_PI_CORRECTED_DETAIL_4"                  */
-/*                     PI Corrected Error Detail 4                      */
-/* ==================================================================== */
-
-typedef union sh_pi_corrected_detail_4_u {
-	mmr_t	sh_pi_corrected_detail_4_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_pi_corrected_detail_4_s;
-} sh_pi_corrected_detail_4_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PI_CRBP_FIRST_ERROR"                   */
-/*                         PI CRBP First Error                          */
-/* ==================================================================== */
-
-typedef union sh_pi_crbp_first_error_u {
-	mmr_t	sh_pi_crbp_first_error_regval;
-	struct {
-		mmr_t	fsb_proto_err   : 1;
-		mmr_t	gfx_rp_err      : 1;
-		mmr_t	xb_proto_err    : 1;
-		mmr_t	mem_rp_err      : 1;
-		mmr_t	pio_rp_err      : 1;
-		mmr_t	mem_to_err      : 1;
-		mmr_t	pio_to_err      : 1;
-		mmr_t	fsb_shub_uce    : 1;
-		mmr_t	fsb_shub_ce     : 1;
-		mmr_t	msg_color_err   : 1;
-		mmr_t	md_rq_q_oflow   : 1;
-		mmr_t	md_rp_q_oflow   : 1;
-		mmr_t	xn_rq_q_oflow   : 1;
-		mmr_t	xn_rp_q_oflow   : 1;
-		mmr_t	nack_oflow      : 1;
-		mmr_t	gfx_int_0       : 1;
-		mmr_t	gfx_int_1       : 1;
-		mmr_t	md_rq_crd_oflow : 1;
-		mmr_t	md_rp_crd_oflow : 1;
-		mmr_t	xn_rq_crd_oflow : 1;
-		mmr_t	xn_rp_crd_oflow : 1;
-		mmr_t	reserved_0      : 43;
-	} sh_pi_crbp_first_error_s;
-} sh_pi_crbp_first_error_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_ERROR_DETAIL_1"                    */
-/*                          PI Error Detail 1                           */
-/* ==================================================================== */
-
-typedef union sh_pi_error_detail_1_u {
-	mmr_t	sh_pi_error_detail_1_regval;
-	struct {
-		mmr_t	status      : 64;
-	} sh_pi_error_detail_1_s;
-} sh_pi_error_detail_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_ERROR_DETAIL_2"                    */
-/*                          PI Error Detail 2                           */
-/* ==================================================================== */
-
-typedef union sh_pi_error_detail_2_u {
-	mmr_t	sh_pi_error_detail_2_regval;
-	struct {
-		mmr_t	status      : 64;
-	} sh_pi_error_detail_2_s;
-} sh_pi_error_detail_2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_ERROR_OVERFLOW"                    */
-/*                          PI Error Overflow                           */
-/* ==================================================================== */
-
-typedef union sh_pi_error_overflow_u {
-	mmr_t	sh_pi_error_overflow_regval;
-	struct {
-		mmr_t	fsb_proto_err   : 1;
-		mmr_t	gfx_rp_err      : 1;
-		mmr_t	xb_proto_err    : 1;
-		mmr_t	mem_rp_err      : 1;
-		mmr_t	pio_rp_err      : 1;
-		mmr_t	mem_to_err      : 1;
-		mmr_t	pio_to_err      : 1;
-		mmr_t	fsb_shub_uce    : 1;
-		mmr_t	fsb_shub_ce     : 1;
-		mmr_t	msg_color_err   : 1;
-		mmr_t	md_rq_q_oflow   : 1;
-		mmr_t	md_rp_q_oflow   : 1;
-		mmr_t	xn_rq_q_oflow   : 1;
-		mmr_t	xn_rp_q_oflow   : 1;
-		mmr_t	nack_oflow      : 1;
-		mmr_t	gfx_int_0       : 1;
-		mmr_t	gfx_int_1       : 1;
-		mmr_t	md_rq_crd_oflow : 1;
-		mmr_t	md_rp_crd_oflow : 1;
-		mmr_t	xn_rq_crd_oflow : 1;
-		mmr_t	xn_rp_crd_oflow : 1;
-		mmr_t	hung_bus        : 1;
-		mmr_t	rsp_parity      : 1;
-		mmr_t	ioq_overrun     : 1;
-		mmr_t	req_format      : 1;
-		mmr_t	addr_access     : 1;
-		mmr_t	req_parity      : 1;
-		mmr_t	addr_parity     : 1;
-		mmr_t	shub_fsb_dqe    : 1;
-		mmr_t	shub_fsb_uce    : 1;
-		mmr_t	shub_fsb_ce     : 1;
-		mmr_t	livelock        : 1;
-		mmr_t	bad_snoop       : 1;
-		mmr_t	fsb_tbl_miss    : 1;
-		mmr_t	msg_length      : 1;
-		mmr_t	reserved_0      : 29;
-	} sh_pi_error_overflow_s;
-} sh_pi_error_overflow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_PI_ERROR_SUMMARY"                    */
-/*                           PI Error Summary                           */
-/* ==================================================================== */
-
-typedef union sh_pi_error_summary_u {
-	mmr_t	sh_pi_error_summary_regval;
-	struct {
-		mmr_t	fsb_proto_err   : 1;
-		mmr_t	gfx_rp_err      : 1;
-		mmr_t	xb_proto_err    : 1;
-		mmr_t	mem_rp_err      : 1;
-		mmr_t	pio_rp_err      : 1;
-		mmr_t	mem_to_err      : 1;
-		mmr_t	pio_to_err      : 1;
-		mmr_t	fsb_shub_uce    : 1;
-		mmr_t	fsb_shub_ce     : 1;
-		mmr_t	msg_color_err   : 1;
-		mmr_t	md_rq_q_oflow   : 1;
-		mmr_t	md_rp_q_oflow   : 1;
-		mmr_t	xn_rq_q_oflow   : 1;
-		mmr_t	xn_rp_q_oflow   : 1;
-		mmr_t	nack_oflow      : 1;
-		mmr_t	gfx_int_0       : 1;
-		mmr_t	gfx_int_1       : 1;
-		mmr_t	md_rq_crd_oflow : 1;
-		mmr_t	md_rp_crd_oflow : 1;
-		mmr_t	xn_rq_crd_oflow : 1;
-		mmr_t	xn_rp_crd_oflow : 1;
-		mmr_t	hung_bus        : 1;
-		mmr_t	rsp_parity      : 1;
-		mmr_t	ioq_overrun     : 1;
-		mmr_t	req_format      : 1;
-		mmr_t	addr_access     : 1;
-		mmr_t	req_parity      : 1;
-		mmr_t	addr_parity     : 1;
-		mmr_t	shub_fsb_dqe    : 1;
-		mmr_t	shub_fsb_uce    : 1;
-		mmr_t	shub_fsb_ce     : 1;
-		mmr_t	livelock        : 1;
-		mmr_t	bad_snoop       : 1;
-		mmr_t	fsb_tbl_miss    : 1;
-		mmr_t	msg_length      : 1;
-		mmr_t	reserved_0      : 29;
-	} sh_pi_error_summary_s;
-} sh_pi_error_summary_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_EXPRESS_REPLY_STATUS"                 */
-/*                       PI Express Reply Status                        */
-/* ==================================================================== */
-
-typedef union sh_pi_express_reply_status_u {
-	mmr_t	sh_pi_express_reply_status_regval;
-	struct {
-		mmr_t	state       : 3;
-		mmr_t	reserved_0  : 61;
-	} sh_pi_express_reply_status_s;
-} sh_pi_express_reply_status_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PI_FIRST_ERROR"                     */
-/*                            PI First Error                            */
-/* ==================================================================== */
-
-typedef union sh_pi_first_error_u {
-	mmr_t	sh_pi_first_error_regval;
-	struct {
-		mmr_t	fsb_proto_err   : 1;
-		mmr_t	gfx_rp_err      : 1;
-		mmr_t	xb_proto_err    : 1;
-		mmr_t	mem_rp_err      : 1;
-		mmr_t	pio_rp_err      : 1;
-		mmr_t	mem_to_err      : 1;
-		mmr_t	pio_to_err      : 1;
-		mmr_t	fsb_shub_uce    : 1;
-		mmr_t	fsb_shub_ce     : 1;
-		mmr_t	msg_color_err   : 1;
-		mmr_t	md_rq_q_oflow   : 1;
-		mmr_t	md_rp_q_oflow   : 1;
-		mmr_t	xn_rq_q_oflow   : 1;
-		mmr_t	xn_rp_q_oflow   : 1;
-		mmr_t	nack_oflow      : 1;
-		mmr_t	gfx_int_0       : 1;
-		mmr_t	gfx_int_1       : 1;
-		mmr_t	md_rq_crd_oflow : 1;
-		mmr_t	md_rp_crd_oflow : 1;
-		mmr_t	xn_rq_crd_oflow : 1;
-		mmr_t	xn_rp_crd_oflow : 1;
-		mmr_t	hung_bus        : 1;
-		mmr_t	rsp_parity      : 1;
-		mmr_t	ioq_overrun     : 1;
-		mmr_t	req_format      : 1;
-		mmr_t	addr_access     : 1;
-		mmr_t	req_parity      : 1;
-		mmr_t	addr_parity     : 1;
-		mmr_t	shub_fsb_dqe    : 1;
-		mmr_t	shub_fsb_uce    : 1;
-		mmr_t	shub_fsb_ce     : 1;
-		mmr_t	livelock        : 1;
-		mmr_t	bad_snoop       : 1;
-		mmr_t	fsb_tbl_miss    : 1;
-		mmr_t	msg_length      : 1;
-		mmr_t	reserved_0      : 29;
-	} sh_pi_first_error_s;
-} sh_pi_first_error_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_PI2MD_REPLY_VC_STATUS"                */
-/*                PI-to-MD Reply Virtual Channel Status                 */
-/* ==================================================================== */
-
-typedef union sh_pi_pi2md_reply_vc_status_u {
-	mmr_t	sh_pi_pi2md_reply_vc_status_regval;
-	struct {
-		mmr_t	output_crd_stat : 6;
-		mmr_t	reserved_0      : 58;
-	} sh_pi_pi2md_reply_vc_status_s;
-} sh_pi_pi2md_reply_vc_status_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_PI2MD_REQUEST_VC_STATUS"               */
-/*               PI-to-MD Request Virtual Channel Status                */
-/* ==================================================================== */
-
-typedef union sh_pi_pi2md_request_vc_status_u {
-	mmr_t	sh_pi_pi2md_request_vc_status_regval;
-	struct {
-		mmr_t	output_crd_stat : 6;
-		mmr_t	reserved_0      : 58;
-	} sh_pi_pi2md_request_vc_status_s;
-} sh_pi_pi2md_request_vc_status_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_PI2XN_REPLY_VC_STATUS"                */
-/*                PI-to-XN Reply Virtual Channel Status                 */
-/* ==================================================================== */
-
-typedef union sh_pi_pi2xn_reply_vc_status_u {
-	mmr_t	sh_pi_pi2xn_reply_vc_status_regval;
-	struct {
-		mmr_t	output_crd_stat : 6;
-		mmr_t	reserved_0      : 58;
-	} sh_pi_pi2xn_reply_vc_status_s;
-} sh_pi_pi2xn_reply_vc_status_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_PI2XN_REQUEST_VC_STATUS"               */
-/*               PI-to-XN Request Virtual Channel Status                */
-/* ==================================================================== */
-
-typedef union sh_pi_pi2xn_request_vc_status_u {
-	mmr_t	sh_pi_pi2xn_request_vc_status_regval;
-	struct {
-		mmr_t	output_crd_stat : 6;
-		mmr_t	reserved_0      : 58;
-	} sh_pi_pi2xn_request_vc_status_s;
-} sh_pi_pi2xn_request_vc_status_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_UNCORRECTED_DETAIL_1"                 */
-/*                    PI Uncorrected Error Detail 1                     */
-/* ==================================================================== */
-
-typedef union sh_pi_uncorrected_detail_1_u {
-	mmr_t	sh_pi_uncorrected_detail_1_regval;
-	struct {
-		mmr_t	address     : 48;
-		mmr_t	syndrome    : 8;
-		mmr_t	dep         : 8;
-	} sh_pi_uncorrected_detail_1_s;
-} sh_pi_uncorrected_detail_1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_UNCORRECTED_DETAIL_2"                 */
-/*                    PI Uncorrected Error Detail 2                     */
-/* ==================================================================== */
-
-typedef union sh_pi_uncorrected_detail_2_u {
-	mmr_t	sh_pi_uncorrected_detail_2_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_pi_uncorrected_detail_2_s;
-} sh_pi_uncorrected_detail_2_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_UNCORRECTED_DETAIL_3"                 */
-/*                    PI Uncorrected Error Detail 3                     */
-/* ==================================================================== */
-
-typedef union sh_pi_uncorrected_detail_3_u {
-	mmr_t	sh_pi_uncorrected_detail_3_regval;
-	struct {
-		mmr_t	address     : 48;
-		mmr_t	syndrome    : 8;
-		mmr_t	dep         : 8;
-	} sh_pi_uncorrected_detail_3_s;
-} sh_pi_uncorrected_detail_3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_UNCORRECTED_DETAIL_4"                 */
-/*                    PI Uncorrected Error Detail 4                     */
-/* ==================================================================== */
-
-typedef union sh_pi_uncorrected_detail_4_u {
-	mmr_t	sh_pi_uncorrected_detail_4_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_pi_uncorrected_detail_4_s;
-} sh_pi_uncorrected_detail_4_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_MD2PI_REPLY_VC_STATUS"                */
-/*                MD-to-PI Reply Virtual Channel Status                 */
-/* ==================================================================== */
-
-typedef union sh_pi_md2pi_reply_vc_status_u {
-	mmr_t	sh_pi_md2pi_reply_vc_status_regval;
-	struct {
-		mmr_t	input_hdr_crd_stat : 4;
-		mmr_t	input_dat_crd_stat : 4;
-		mmr_t	input_queue_stat   : 4;
-		mmr_t	reserved_0         : 52;
-	} sh_pi_md2pi_reply_vc_status_s;
-} sh_pi_md2pi_reply_vc_status_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_MD2PI_REQUEST_VC_STATUS"               */
-/*               MD-to-PI Request Virtual Channel Status                */
-/* ==================================================================== */
-
-typedef union sh_pi_md2pi_request_vc_status_u {
-	mmr_t	sh_pi_md2pi_request_vc_status_regval;
-	struct {
-		mmr_t	input_hdr_crd_stat : 4;
-		mmr_t	input_dat_crd_stat : 4;
-		mmr_t	input_queue_stat   : 4;
-		mmr_t	reserved_0         : 52;
-	} sh_pi_md2pi_request_vc_status_s;
-} sh_pi_md2pi_request_vc_status_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_PI_XN2PI_REPLY_VC_STATUS"                */
-/*                XN-to-PI Reply Virtual Channel Status                 */
-/* ==================================================================== */
-
-typedef union sh_pi_xn2pi_reply_vc_status_u {
-	mmr_t	sh_pi_xn2pi_reply_vc_status_regval;
-	struct {
-		mmr_t	input_hdr_crd_stat : 4;
-		mmr_t	input_dat_crd_stat : 4;
-		mmr_t	input_queue_stat   : 4;
-		mmr_t	reserved_0         : 52;
-	} sh_pi_xn2pi_reply_vc_status_s;
-} sh_pi_xn2pi_reply_vc_status_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PI_XN2PI_REQUEST_VC_STATUS"               */
-/*               XN-to-PI Request Virtual Channel Status                */
-/* ==================================================================== */
-
-typedef union sh_pi_xn2pi_request_vc_status_u {
-	mmr_t	sh_pi_xn2pi_request_vc_status_regval;
-	struct {
-		mmr_t	input_hdr_crd_stat : 4;
-		mmr_t	input_dat_crd_stat : 4;
-		mmr_t	input_queue_stat   : 4;
-		mmr_t	reserved_0         : 52;
-	} sh_pi_xn2pi_request_vc_status_s;
-} sh_pi_xn2pi_request_vc_status_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_XNPI_SIC_FLOW"                      */
-/* ==================================================================== */
-
-typedef union sh_xnpi_sic_flow_u {
-	mmr_t	sh_xnpi_sic_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 5;
-		mmr_t	reserved_0           : 2;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 5;
-		mmr_t	reserved_1           : 2;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	credit_vc0_test      : 5;
-		mmr_t	reserved_2           : 3;
-		mmr_t	credit_vc0_dyn       : 5;
-		mmr_t	reserved_3           : 3;
-		mmr_t	credit_vc0_cap       : 5;
-		mmr_t	reserved_4           : 3;
-		mmr_t	credit_vc2_test      : 5;
-		mmr_t	reserved_5           : 3;
-		mmr_t	credit_vc2_dyn       : 5;
-		mmr_t	reserved_6           : 3;
-		mmr_t	credit_vc2_cap       : 5;
-		mmr_t	reserved_7           : 2;
-		mmr_t	disable_bypass_out   : 1;
-	} sh_xnpi_sic_flow_s;
-} sh_xnpi_sic_flow_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_TO_NI0_PORT_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnpi_to_ni0_port_flow_u {
-	mmr_t	sh_xnpi_to_ni0_port_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnpi_to_ni0_port_flow_s;
-} sh_xnpi_to_ni0_port_flow_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_TO_NI1_PORT_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnpi_to_ni1_port_flow_u {
-	mmr_t	sh_xnpi_to_ni1_port_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnpi_to_ni1_port_flow_s;
-} sh_xnpi_to_ni1_port_flow_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_TO_IILB_PORT_FLOW"                 */
-/* ==================================================================== */
-
-typedef union sh_xnpi_to_iilb_port_flow_u {
-	mmr_t	sh_xnpi_to_iilb_port_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnpi_to_iilb_port_flow_s;
-} sh_xnpi_to_iilb_port_flow_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XNPI_FR_NI0_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-typedef union sh_xnpi_fr_ni0_port_flow_fifo_u {
-	mmr_t	sh_xnpi_fr_ni0_port_flow_fifo_regval;
-	struct {
-		mmr_t	entry_vc0_dyn  : 6;
-		mmr_t	reserved_0     : 2;
-		mmr_t	entry_vc0_cap  : 6;
-		mmr_t	reserved_1     : 2;
-		mmr_t	entry_vc2_dyn  : 6;
-		mmr_t	reserved_2     : 2;
-		mmr_t	entry_vc2_cap  : 6;
-		mmr_t	reserved_3     : 2;
-		mmr_t	entry_vc0_test : 5;
-		mmr_t	reserved_4     : 3;
-		mmr_t	entry_vc2_test : 5;
-		mmr_t	reserved_5     : 19;
-	} sh_xnpi_fr_ni0_port_flow_fifo_s;
-} sh_xnpi_fr_ni0_port_flow_fifo_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XNPI_FR_NI1_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-typedef union sh_xnpi_fr_ni1_port_flow_fifo_u {
-	mmr_t	sh_xnpi_fr_ni1_port_flow_fifo_regval;
-	struct {
-		mmr_t	entry_vc0_dyn  : 6;
-		mmr_t	reserved_0     : 2;
-		mmr_t	entry_vc0_cap  : 6;
-		mmr_t	reserved_1     : 2;
-		mmr_t	entry_vc2_dyn  : 6;
-		mmr_t	reserved_2     : 2;
-		mmr_t	entry_vc2_cap  : 6;
-		mmr_t	reserved_3     : 2;
-		mmr_t	entry_vc0_test : 5;
-		mmr_t	reserved_4     : 3;
-		mmr_t	entry_vc2_test : 5;
-		mmr_t	reserved_5     : 19;
-	} sh_xnpi_fr_ni1_port_flow_fifo_s;
-} sh_xnpi_fr_ni1_port_flow_fifo_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_XNPI_FR_IILB_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-typedef union sh_xnpi_fr_iilb_port_flow_fifo_u {
-	mmr_t	sh_xnpi_fr_iilb_port_flow_fifo_regval;
-	struct {
-		mmr_t	entry_vc0_dyn  : 6;
-		mmr_t	reserved_0     : 2;
-		mmr_t	entry_vc0_cap  : 6;
-		mmr_t	reserved_1     : 2;
-		mmr_t	entry_vc2_dyn  : 6;
-		mmr_t	reserved_2     : 2;
-		mmr_t	entry_vc2_cap  : 6;
-		mmr_t	reserved_3     : 2;
-		mmr_t	entry_vc0_test : 5;
-		mmr_t	reserved_4     : 3;
-		mmr_t	entry_vc2_test : 5;
-		mmr_t	reserved_5     : 19;
-	} sh_xnpi_fr_iilb_port_flow_fifo_s;
-} sh_xnpi_fr_iilb_port_flow_fifo_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_XNMD_SIC_FLOW"                      */
-/* ==================================================================== */
-
-typedef union sh_xnmd_sic_flow_u {
-	mmr_t	sh_xnmd_sic_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 5;
-		mmr_t	reserved_0           : 2;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 5;
-		mmr_t	reserved_1           : 2;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	credit_vc0_test      : 5;
-		mmr_t	reserved_2           : 3;
-		mmr_t	credit_vc0_dyn       : 5;
-		mmr_t	reserved_3           : 3;
-		mmr_t	credit_vc0_cap       : 5;
-		mmr_t	reserved_4           : 3;
-		mmr_t	credit_vc2_test      : 5;
-		mmr_t	reserved_5           : 3;
-		mmr_t	credit_vc2_dyn       : 5;
-		mmr_t	reserved_6           : 3;
-		mmr_t	credit_vc2_cap       : 5;
-		mmr_t	reserved_7           : 2;
-		mmr_t	disable_bypass_out   : 1;
-	} sh_xnmd_sic_flow_s;
-} sh_xnmd_sic_flow_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_TO_NI0_PORT_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnmd_to_ni0_port_flow_u {
-	mmr_t	sh_xnmd_to_ni0_port_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnmd_to_ni0_port_flow_s;
-} sh_xnmd_to_ni0_port_flow_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_TO_NI1_PORT_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnmd_to_ni1_port_flow_u {
-	mmr_t	sh_xnmd_to_ni1_port_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnmd_to_ni1_port_flow_s;
-} sh_xnmd_to_ni1_port_flow_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_TO_IILB_PORT_FLOW"                 */
-/* ==================================================================== */
-
-typedef union sh_xnmd_to_iilb_port_flow_u {
-	mmr_t	sh_xnmd_to_iilb_port_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_2           : 8;
-		mmr_t	credit_vc0_dyn       : 6;
-		mmr_t	reserved_3           : 2;
-		mmr_t	credit_vc0_cap       : 6;
-		mmr_t	reserved_4           : 10;
-		mmr_t	credit_vc2_dyn       : 6;
-		mmr_t	reserved_5           : 2;
-		mmr_t	credit_vc2_cap       : 6;
-		mmr_t	reserved_6           : 2;
-	} sh_xnmd_to_iilb_port_flow_s;
-} sh_xnmd_to_iilb_port_flow_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XNMD_FR_NI0_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-typedef union sh_xnmd_fr_ni0_port_flow_fifo_u {
-	mmr_t	sh_xnmd_fr_ni0_port_flow_fifo_regval;
-	struct {
-		mmr_t	entry_vc0_dyn  : 6;
-		mmr_t	reserved_0     : 2;
-		mmr_t	entry_vc0_cap  : 6;
-		mmr_t	reserved_1     : 2;
-		mmr_t	entry_vc2_dyn  : 6;
-		mmr_t	reserved_2     : 2;
-		mmr_t	entry_vc2_cap  : 6;
-		mmr_t	reserved_3     : 2;
-		mmr_t	entry_vc0_test : 5;
-		mmr_t	reserved_4     : 3;
-		mmr_t	entry_vc2_test : 5;
-		mmr_t	reserved_5     : 19;
-	} sh_xnmd_fr_ni0_port_flow_fifo_s;
-} sh_xnmd_fr_ni0_port_flow_fifo_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XNMD_FR_NI1_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-typedef union sh_xnmd_fr_ni1_port_flow_fifo_u {
-	mmr_t	sh_xnmd_fr_ni1_port_flow_fifo_regval;
-	struct {
-		mmr_t	entry_vc0_dyn  : 6;
-		mmr_t	reserved_0     : 2;
-		mmr_t	entry_vc0_cap  : 6;
-		mmr_t	reserved_1     : 2;
-		mmr_t	entry_vc2_dyn  : 6;
-		mmr_t	reserved_2     : 2;
-		mmr_t	entry_vc2_cap  : 6;
-		mmr_t	reserved_3     : 2;
-		mmr_t	entry_vc0_test : 5;
-		mmr_t	reserved_4     : 3;
-		mmr_t	entry_vc2_test : 5;
-		mmr_t	reserved_5     : 19;
-	} sh_xnmd_fr_ni1_port_flow_fifo_s;
-} sh_xnmd_fr_ni1_port_flow_fifo_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_XNMD_FR_IILB_PORT_FLOW_FIFO"               */
-/* ==================================================================== */
-
-typedef union sh_xnmd_fr_iilb_port_flow_fifo_u {
-	mmr_t	sh_xnmd_fr_iilb_port_flow_fifo_regval;
-	struct {
-		mmr_t	entry_vc0_dyn  : 6;
-		mmr_t	reserved_0     : 2;
-		mmr_t	entry_vc0_cap  : 6;
-		mmr_t	reserved_1     : 2;
-		mmr_t	entry_vc2_dyn  : 6;
-		mmr_t	reserved_2     : 2;
-		mmr_t	entry_vc2_cap  : 6;
-		mmr_t	reserved_3     : 2;
-		mmr_t	entry_vc0_test : 5;
-		mmr_t	reserved_4     : 3;
-		mmr_t	entry_vc2_test : 5;
-		mmr_t	reserved_5     : 19;
-	} sh_xnmd_fr_iilb_port_flow_fifo_s;
-} sh_xnmd_fr_iilb_port_flow_fifo_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNII_INTRA_FLOW"                     */
-/* ==================================================================== */
-
-typedef union sh_xnii_intra_flow_u {
-	mmr_t	sh_xnii_intra_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	credit_vc0_test      : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc0_dyn       : 7;
-		mmr_t	reserved_3           : 1;
-		mmr_t	credit_vc0_cap       : 7;
-		mmr_t	reserved_4           : 1;
-		mmr_t	credit_vc2_test      : 7;
-		mmr_t	reserved_5           : 1;
-		mmr_t	credit_vc2_dyn       : 7;
-		mmr_t	reserved_6           : 1;
-		mmr_t	credit_vc2_cap       : 7;
-		mmr_t	reserved_7           : 1;
-	} sh_xnii_intra_flow_s;
-} sh_xnii_intra_flow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNLB_INTRA_FLOW"                     */
-/* ==================================================================== */
-
-typedef union sh_xnlb_intra_flow_u {
-	mmr_t	sh_xnlb_intra_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_1           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	credit_vc0_test      : 7;
-		mmr_t	reserved_2           : 1;
-		mmr_t	credit_vc0_dyn       : 7;
-		mmr_t	reserved_3           : 1;
-		mmr_t	credit_vc0_cap       : 7;
-		mmr_t	reserved_4           : 1;
-		mmr_t	credit_vc2_test      : 7;
-		mmr_t	reserved_5           : 1;
-		mmr_t	credit_vc2_dyn       : 7;
-		mmr_t	reserved_6           : 1;
-		mmr_t	credit_vc2_cap       : 7;
-		mmr_t	disable_bypass_in    : 1;
-	} sh_xnlb_intra_flow_s;
-} sh_xnlb_intra_flow_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_TO_NI0_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-typedef union sh_xniilb_to_ni0_intra_flow_debit_u {
-	mmr_t	sh_xniilb_to_ni0_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xniilb_to_ni0_intra_flow_debit_s;
-} sh_xniilb_to_ni0_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_TO_NI1_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-typedef union sh_xniilb_to_ni1_intra_flow_debit_u {
-	mmr_t	sh_xniilb_to_ni1_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xniilb_to_ni1_intra_flow_debit_s;
-} sh_xniilb_to_ni1_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_TO_MD_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-typedef union sh_xniilb_to_md_intra_flow_debit_u {
-	mmr_t	sh_xniilb_to_md_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xniilb_to_md_intra_flow_debit_s;
-} sh_xniilb_to_md_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*            Register "SH_XNIILB_TO_IILB_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-typedef union sh_xniilb_to_iilb_intra_flow_debit_u {
-	mmr_t	sh_xniilb_to_iilb_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xniilb_to_iilb_intra_flow_debit_s;
-} sh_xniilb_to_iilb_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_TO_PI_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-typedef union sh_xniilb_to_pi_intra_flow_debit_u {
-	mmr_t	sh_xniilb_to_pi_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xniilb_to_pi_intra_flow_debit_s;
-} sh_xniilb_to_pi_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*            Register "SH_XNIILB_FR_NI0_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-typedef union sh_xniilb_fr_ni0_intra_flow_credit_u {
-	mmr_t	sh_xniilb_fr_ni0_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xniilb_fr_ni0_intra_flow_credit_s;
-} sh_xniilb_fr_ni0_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*            Register "SH_XNIILB_FR_NI1_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-typedef union sh_xniilb_fr_ni1_intra_flow_credit_u {
-	mmr_t	sh_xniilb_fr_ni1_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xniilb_fr_ni1_intra_flow_credit_s;
-} sh_xniilb_fr_ni1_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_FR_MD_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-typedef union sh_xniilb_fr_md_intra_flow_credit_u {
-	mmr_t	sh_xniilb_fr_md_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xniilb_fr_md_intra_flow_credit_s;
-} sh_xniilb_fr_md_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*            Register "SH_XNIILB_FR_IILB_INTRA_FLOW_CREDIT"            */
-/* ==================================================================== */
-
-typedef union sh_xniilb_fr_iilb_intra_flow_credit_u {
-	mmr_t	sh_xniilb_fr_iilb_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xniilb_fr_iilb_intra_flow_credit_s;
-} sh_xniilb_fr_iilb_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNIILB_FR_PI_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-typedef union sh_xniilb_fr_pi_intra_flow_credit_u {
-	mmr_t	sh_xniilb_fr_pi_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xniilb_fr_pi_intra_flow_credit_s;
-} sh_xniilb_fr_pi_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_XNNI0_TO_PI_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-typedef union sh_xnni0_to_pi_intra_flow_debit_u {
-	mmr_t	sh_xnni0_to_pi_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xnni0_to_pi_intra_flow_debit_s;
-} sh_xnni0_to_pi_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_XNNI0_TO_MD_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-typedef union sh_xnni0_to_md_intra_flow_debit_u {
-	mmr_t	sh_xnni0_to_md_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xnni0_to_md_intra_flow_debit_s;
-} sh_xnni0_to_md_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNNI0_TO_IILB_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-typedef union sh_xnni0_to_iilb_intra_flow_debit_u {
-	mmr_t	sh_xnni0_to_iilb_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xnni0_to_iilb_intra_flow_debit_s;
-} sh_xnni0_to_iilb_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNNI0_FR_PI_INTRA_FLOW_CREDIT"              */
-/* ==================================================================== */
-
-typedef union sh_xnni0_fr_pi_intra_flow_credit_u {
-	mmr_t	sh_xnni0_fr_pi_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xnni0_fr_pi_intra_flow_credit_s;
-} sh_xnni0_fr_pi_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNNI0_FR_MD_INTRA_FLOW_CREDIT"              */
-/* ==================================================================== */
-
-typedef union sh_xnni0_fr_md_intra_flow_credit_u {
-	mmr_t	sh_xnni0_fr_md_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xnni0_fr_md_intra_flow_credit_s;
-} sh_xnni0_fr_md_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*            Register "SH_XNNI0_FR_IILB_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-typedef union sh_xnni0_fr_iilb_intra_flow_credit_u {
-	mmr_t	sh_xnni0_fr_iilb_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xnni0_fr_iilb_intra_flow_credit_s;
-} sh_xnni0_fr_iilb_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_0_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni0_0_intrani_flow_u {
-	mmr_t	sh_xnni0_0_intrani_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	reserved_1           : 56;
-	} sh_xnni0_0_intrani_flow_s;
-} sh_xnni0_0_intrani_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_1_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni0_1_intrani_flow_u {
-	mmr_t	sh_xnni0_1_intrani_flow_regval;
-	struct {
-		mmr_t	debit_vc1_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc1_force_cred : 1;
-		mmr_t	reserved_1           : 56;
-	} sh_xnni0_1_intrani_flow_s;
-} sh_xnni0_1_intrani_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_2_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni0_2_intrani_flow_u {
-	mmr_t	sh_xnni0_2_intrani_flow_regval;
-	struct {
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_1           : 56;
-	} sh_xnni0_2_intrani_flow_s;
-} sh_xnni0_2_intrani_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_3_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni0_3_intrani_flow_u {
-	mmr_t	sh_xnni0_3_intrani_flow_regval;
-	struct {
-		mmr_t	debit_vc3_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc3_force_cred : 1;
-		mmr_t	reserved_1           : 56;
-	} sh_xnni0_3_intrani_flow_s;
-} sh_xnni0_3_intrani_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI0_VCSWITCH_FLOW"                   */
-/* ==================================================================== */
-
-typedef union sh_xnni0_vcswitch_flow_u {
-	mmr_t	sh_xnni0_vcswitch_flow_regval;
-	struct {
-		mmr_t	ni_vcfifo_dateline_switch : 1;
-		mmr_t	reserved_0                : 7;
-		mmr_t	pi_vcfifo_switch          : 1;
-		mmr_t	reserved_1                : 7;
-		mmr_t	md_vcfifo_switch          : 1;
-		mmr_t	reserved_2                : 7;
-		mmr_t	iilb_vcfifo_switch        : 1;
-		mmr_t	reserved_3                : 7;
-		mmr_t	disable_sync_bypass_in    : 1;
-		mmr_t	disable_sync_bypass_out   : 1;
-		mmr_t	async_fifoes              : 1;
-		mmr_t	reserved_4                : 29;
-	} sh_xnni0_vcswitch_flow_s;
-} sh_xnni0_vcswitch_flow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI0_TIMER_REG"                     */
-/* ==================================================================== */
-
-typedef union sh_xnni0_timer_reg_u {
-	mmr_t	sh_xnni0_timer_reg_regval;
-	struct {
-		mmr_t	timeout_reg     : 24;
-		mmr_t	reserved_0      : 8;
-		mmr_t	linkcleanup_reg : 1;
-		mmr_t	reserved_1      : 31;
-	} sh_xnni0_timer_reg_s;
-} sh_xnni0_timer_reg_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_FIFO02_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni0_fifo02_flow_u {
-	mmr_t	sh_xnni0_fifo02_flow_regval;
-	struct {
-		mmr_t	count_vc0_limit : 4;
-		mmr_t	reserved_0      : 4;
-		mmr_t	count_vc0_dyn   : 4;
-		mmr_t	reserved_1      : 4;
-		mmr_t	count_vc0_cap   : 4;
-		mmr_t	reserved_2      : 4;
-		mmr_t	count_vc2_limit : 4;
-		mmr_t	reserved_3      : 4;
-		mmr_t	count_vc2_dyn   : 4;
-		mmr_t	reserved_4      : 4;
-		mmr_t	count_vc2_cap   : 4;
-		mmr_t	reserved_5      : 20;
-	} sh_xnni0_fifo02_flow_s;
-} sh_xnni0_fifo02_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI0_FIFO13_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni0_fifo13_flow_u {
-	mmr_t	sh_xnni0_fifo13_flow_regval;
-	struct {
-		mmr_t	count_vc1_limit : 4;
-		mmr_t	reserved_0      : 4;
-		mmr_t	count_vc1_dyn   : 4;
-		mmr_t	reserved_1      : 4;
-		mmr_t	count_vc1_cap   : 4;
-		mmr_t	reserved_2      : 4;
-		mmr_t	count_vc3_limit : 4;
-		mmr_t	reserved_3      : 4;
-		mmr_t	count_vc3_dyn   : 4;
-		mmr_t	reserved_4      : 4;
-		mmr_t	count_vc3_cap   : 4;
-		mmr_t	reserved_5      : 20;
-	} sh_xnni0_fifo13_flow_s;
-} sh_xnni0_fifo13_flow_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_XNNI0_NI_FLOW"                      */
-/* ==================================================================== */
-
-typedef union sh_xnni0_ni_flow_u {
-	mmr_t	sh_xnni0_ni_flow_regval;
-	struct {
-		mmr_t	vc0_limit   : 4;
-		mmr_t	reserved_0  : 4;
-		mmr_t	vc0_dyn     : 4;
-		mmr_t	vc0_cap     : 4;
-		mmr_t	vc1_limit   : 4;
-		mmr_t	reserved_1  : 4;
-		mmr_t	vc1_dyn     : 4;
-		mmr_t	vc1_cap     : 4;
-		mmr_t	vc2_limit   : 4;
-		mmr_t	reserved_2  : 4;
-		mmr_t	vc2_dyn     : 4;
-		mmr_t	vc2_cap     : 4;
-		mmr_t	vc3_limit   : 4;
-		mmr_t	reserved_3  : 4;
-		mmr_t	vc3_dyn     : 4;
-		mmr_t	vc3_cap     : 4;
-	} sh_xnni0_ni_flow_s;
-} sh_xnni0_ni_flow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI0_DEAD_FLOW"                     */
-/* ==================================================================== */
-
-typedef union sh_xnni0_dead_flow_u {
-	mmr_t	sh_xnni0_dead_flow_regval;
-	struct {
-		mmr_t	vc0_limit   : 4;
-		mmr_t	reserved_0  : 4;
-		mmr_t	vc0_dyn     : 4;
-		mmr_t	vc0_cap     : 4;
-		mmr_t	vc1_limit   : 4;
-		mmr_t	reserved_1  : 4;
-		mmr_t	vc1_dyn     : 4;
-		mmr_t	vc1_cap     : 4;
-		mmr_t	vc2_limit   : 4;
-		mmr_t	reserved_2  : 4;
-		mmr_t	vc2_dyn     : 4;
-		mmr_t	vc2_cap     : 4;
-		mmr_t	vc3_limit   : 4;
-		mmr_t	reserved_3  : 4;
-		mmr_t	vc3_dyn     : 4;
-		mmr_t	vc3_cap     : 4;
-	} sh_xnni0_dead_flow_s;
-} sh_xnni0_dead_flow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI0_INJECT_AGE"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni0_inject_age_u {
-	mmr_t	sh_xnni0_inject_age_regval;
-	struct {
-		mmr_t	request_inject : 8;
-		mmr_t	reply_inject   : 8;
-		mmr_t	reserved_0     : 48;
-	} sh_xnni0_inject_age_s;
-} sh_xnni0_inject_age_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_XNNI1_TO_PI_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-typedef union sh_xnni1_to_pi_intra_flow_debit_u {
-	mmr_t	sh_xnni1_to_pi_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xnni1_to_pi_intra_flow_debit_s;
-} sh_xnni1_to_pi_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_XNNI1_TO_MD_INTRA_FLOW_DEBIT"              */
-/* ==================================================================== */
-
-typedef union sh_xnni1_to_md_intra_flow_debit_u {
-	mmr_t	sh_xnni1_to_md_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xnni1_to_md_intra_flow_debit_s;
-} sh_xnni1_to_md_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNNI1_TO_IILB_INTRA_FLOW_DEBIT"             */
-/* ==================================================================== */
-
-typedef union sh_xnni1_to_iilb_intra_flow_debit_u {
-	mmr_t	sh_xnni1_to_iilb_intra_flow_debit_regval;
-	struct {
-		mmr_t	vc0_withhold   : 6;
-		mmr_t	reserved_0     : 1;
-		mmr_t	vc0_force_cred : 1;
-		mmr_t	vc2_withhold   : 6;
-		mmr_t	reserved_1     : 1;
-		mmr_t	vc2_force_cred : 1;
-		mmr_t	reserved_2     : 8;
-		mmr_t	vc0_dyn        : 7;
-		mmr_t	reserved_3     : 1;
-		mmr_t	vc0_cap        : 7;
-		mmr_t	reserved_4     : 9;
-		mmr_t	vc2_dyn        : 7;
-		mmr_t	reserved_5     : 1;
-		mmr_t	vc2_cap        : 7;
-		mmr_t	reserved_6     : 1;
-	} sh_xnni1_to_iilb_intra_flow_debit_s;
-} sh_xnni1_to_iilb_intra_flow_debit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNNI1_FR_PI_INTRA_FLOW_CREDIT"              */
-/* ==================================================================== */
-
-typedef union sh_xnni1_fr_pi_intra_flow_credit_u {
-	mmr_t	sh_xnni1_fr_pi_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xnni1_fr_pi_intra_flow_credit_s;
-} sh_xnni1_fr_pi_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_XNNI1_FR_MD_INTRA_FLOW_CREDIT"              */
-/* ==================================================================== */
-
-typedef union sh_xnni1_fr_md_intra_flow_credit_u {
-	mmr_t	sh_xnni1_fr_md_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xnni1_fr_md_intra_flow_credit_s;
-} sh_xnni1_fr_md_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*            Register "SH_XNNI1_FR_IILB_INTRA_FLOW_CREDIT"             */
-/* ==================================================================== */
-
-typedef union sh_xnni1_fr_iilb_intra_flow_credit_u {
-	mmr_t	sh_xnni1_fr_iilb_intra_flow_credit_regval;
-	struct {
-		mmr_t	vc0_test    : 7;
-		mmr_t	reserved_0  : 1;
-		mmr_t	vc0_dyn     : 7;
-		mmr_t	reserved_1  : 1;
-		mmr_t	vc0_cap     : 7;
-		mmr_t	reserved_2  : 1;
-		mmr_t	vc2_test    : 7;
-		mmr_t	reserved_3  : 1;
-		mmr_t	vc2_dyn     : 7;
-		mmr_t	reserved_4  : 1;
-		mmr_t	vc2_cap     : 7;
-		mmr_t	reserved_5  : 17;
-	} sh_xnni1_fr_iilb_intra_flow_credit_s;
-} sh_xnni1_fr_iilb_intra_flow_credit_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_0_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni1_0_intrani_flow_u {
-	mmr_t	sh_xnni1_0_intrani_flow_regval;
-	struct {
-		mmr_t	debit_vc0_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc0_force_cred : 1;
-		mmr_t	reserved_1           : 56;
-	} sh_xnni1_0_intrani_flow_s;
-} sh_xnni1_0_intrani_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_1_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni1_1_intrani_flow_u {
-	mmr_t	sh_xnni1_1_intrani_flow_regval;
-	struct {
-		mmr_t	debit_vc1_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc1_force_cred : 1;
-		mmr_t	reserved_1           : 56;
-	} sh_xnni1_1_intrani_flow_s;
-} sh_xnni1_1_intrani_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_2_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni1_2_intrani_flow_u {
-	mmr_t	sh_xnni1_2_intrani_flow_regval;
-	struct {
-		mmr_t	debit_vc2_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc2_force_cred : 1;
-		mmr_t	reserved_1           : 56;
-	} sh_xnni1_2_intrani_flow_s;
-} sh_xnni1_2_intrani_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_3_INTRANI_FLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xnni1_3_intrani_flow_u {
-	mmr_t	sh_xnni1_3_intrani_flow_regval;
-	struct {
-		mmr_t	debit_vc3_withhold   : 6;
-		mmr_t	reserved_0           : 1;
-		mmr_t	debit_vc3_force_cred : 1;
-		mmr_t	reserved_1           : 56;
-	} sh_xnni1_3_intrani_flow_s;
-} sh_xnni1_3_intrani_flow_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNNI1_VCSWITCH_FLOW"                   */
-/* ==================================================================== */
-
-typedef union sh_xnni1_vcswitch_flow_u {
-	mmr_t	sh_xnni1_vcswitch_flow_regval;
-	struct {
-		mmr_t	ni_vcfifo_dateline_switch : 1;
-		mmr_t	reserved_0                : 7;
-		mmr_t	pi_vcfifo_switch          : 1;
-		mmr_t	reserved_1                : 7;
-		mmr_t	md_vcfifo_switch          : 1;
-		mmr_t	reserved_2                : 7;
-		mmr_t	iilb_vcfifo_switch        : 1;
-		mmr_t	reserved_3                : 7;
-		mmr_t	disable_sync_bypass_in    : 1;
-		mmr_t	disable_sync_bypass_out   : 1;
-		mmr_t	async_fifoes              : 1;
-		mmr_t	reserved_4                : 29;
-	} sh_xnni1_vcswitch_flow_s;
-} sh_xnni1_vcswitch_flow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI1_TIMER_REG"                     */
-/* ==================================================================== */
-
-typedef union sh_xnni1_timer_reg_u {
-	mmr_t	sh_xnni1_timer_reg_regval;
-	struct {
-		mmr_t	timeout_reg     : 24;
-		mmr_t	reserved_0      : 8;
-		mmr_t	linkcleanup_reg : 1;
-		mmr_t	reserved_1      : 31;
-	} sh_xnni1_timer_reg_s;
-} sh_xnni1_timer_reg_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_FIFO02_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni1_fifo02_flow_u {
-	mmr_t	sh_xnni1_fifo02_flow_regval;
-	struct {
-		mmr_t	count_vc0_limit : 4;
-		mmr_t	reserved_0      : 4;
-		mmr_t	count_vc0_dyn   : 4;
-		mmr_t	reserved_1      : 4;
-		mmr_t	count_vc0_cap   : 4;
-		mmr_t	reserved_2      : 4;
-		mmr_t	count_vc2_limit : 4;
-		mmr_t	reserved_3      : 4;
-		mmr_t	count_vc2_dyn   : 4;
-		mmr_t	reserved_4      : 4;
-		mmr_t	count_vc2_cap   : 4;
-		mmr_t	reserved_5      : 20;
-	} sh_xnni1_fifo02_flow_s;
-} sh_xnni1_fifo02_flow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNNI1_FIFO13_FLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni1_fifo13_flow_u {
-	mmr_t	sh_xnni1_fifo13_flow_regval;
-	struct {
-		mmr_t	count_vc1_limit : 4;
-		mmr_t	reserved_0      : 4;
-		mmr_t	count_vc1_dyn   : 4;
-		mmr_t	reserved_1      : 4;
-		mmr_t	count_vc1_cap   : 4;
-		mmr_t	reserved_2      : 4;
-		mmr_t	count_vc3_limit : 4;
-		mmr_t	reserved_3      : 4;
-		mmr_t	count_vc3_dyn   : 4;
-		mmr_t	reserved_4      : 4;
-		mmr_t	count_vc3_cap   : 4;
-		mmr_t	reserved_5      : 20;
-	} sh_xnni1_fifo13_flow_s;
-} sh_xnni1_fifo13_flow_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_XNNI1_NI_FLOW"                      */
-/* ==================================================================== */
-
-typedef union sh_xnni1_ni_flow_u {
-	mmr_t	sh_xnni1_ni_flow_regval;
-	struct {
-		mmr_t	vc0_limit   : 4;
-		mmr_t	reserved_0  : 4;
-		mmr_t	vc0_dyn     : 4;
-		mmr_t	vc0_cap     : 4;
-		mmr_t	vc1_limit   : 4;
-		mmr_t	reserved_1  : 4;
-		mmr_t	vc1_dyn     : 4;
-		mmr_t	vc1_cap     : 4;
-		mmr_t	vc2_limit   : 4;
-		mmr_t	reserved_2  : 4;
-		mmr_t	vc2_dyn     : 4;
-		mmr_t	vc2_cap     : 4;
-		mmr_t	vc3_limit   : 4;
-		mmr_t	reserved_3  : 4;
-		mmr_t	vc3_dyn     : 4;
-		mmr_t	vc3_cap     : 4;
-	} sh_xnni1_ni_flow_s;
-} sh_xnni1_ni_flow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI1_DEAD_FLOW"                     */
-/* ==================================================================== */
-
-typedef union sh_xnni1_dead_flow_u {
-	mmr_t	sh_xnni1_dead_flow_regval;
-	struct {
-		mmr_t	vc0_limit   : 4;
-		mmr_t	reserved_0  : 4;
-		mmr_t	vc0_dyn     : 4;
-		mmr_t	vc0_cap     : 4;
-		mmr_t	vc1_limit   : 4;
-		mmr_t	reserved_1  : 4;
-		mmr_t	vc1_dyn     : 4;
-		mmr_t	vc1_cap     : 4;
-		mmr_t	vc2_limit   : 4;
-		mmr_t	reserved_2  : 4;
-		mmr_t	vc2_dyn     : 4;
-		mmr_t	vc2_cap     : 4;
-		mmr_t	vc3_limit   : 4;
-		mmr_t	reserved_3  : 4;
-		mmr_t	vc3_dyn     : 4;
-		mmr_t	vc3_cap     : 4;
-	} sh_xnni1_dead_flow_s;
-} sh_xnni1_dead_flow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNNI1_INJECT_AGE"                    */
-/* ==================================================================== */
-
-typedef union sh_xnni1_inject_age_u {
-	mmr_t	sh_xnni1_inject_age_regval;
-	struct {
-		mmr_t	request_inject : 8;
-		mmr_t	reply_inject   : 8;
-		mmr_t	reserved_0     : 48;
-	} sh_xnni1_inject_age_s;
-} sh_xnni1_inject_age_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_XN_DEBUG_SEL"                      */
-/*                         XN Debug Port Select                         */
-/* ==================================================================== */
-
-typedef union sh_xn_debug_sel_u {
-	mmr_t	sh_xn_debug_sel_regval;
-	struct {
-		mmr_t	nibble0_rlm_sel    : 3;
-		mmr_t	reserved_0         : 1;
-		mmr_t	nibble0_nibble_sel : 3;
-		mmr_t	reserved_1         : 1;
-		mmr_t	nibble1_rlm_sel    : 3;
-		mmr_t	reserved_2         : 1;
-		mmr_t	nibble1_nibble_sel : 3;
-		mmr_t	reserved_3         : 1;
-		mmr_t	nibble2_rlm_sel    : 3;
-		mmr_t	reserved_4         : 1;
-		mmr_t	nibble2_nibble_sel : 3;
-		mmr_t	reserved_5         : 1;
-		mmr_t	nibble3_rlm_sel    : 3;
-		mmr_t	reserved_6         : 1;
-		mmr_t	nibble3_nibble_sel : 3;
-		mmr_t	reserved_7         : 1;
-		mmr_t	nibble4_rlm_sel    : 3;
-		mmr_t	reserved_8         : 1;
-		mmr_t	nibble4_nibble_sel : 3;
-		mmr_t	reserved_9         : 1;
-		mmr_t	nibble5_rlm_sel    : 3;
-		mmr_t	reserved_10        : 1;
-		mmr_t	nibble5_nibble_sel : 3;
-		mmr_t	reserved_11        : 1;
-		mmr_t	nibble6_rlm_sel    : 3;
-		mmr_t	reserved_12        : 1;
-		mmr_t	nibble6_nibble_sel : 3;
-		mmr_t	reserved_13        : 1;
-		mmr_t	nibble7_rlm_sel    : 3;
-		mmr_t	reserved_14        : 1;
-		mmr_t	nibble7_nibble_sel : 3;
-		mmr_t	trigger_enable     : 1;
-	} sh_xn_debug_sel_s;
-} sh_xn_debug_sel_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XN_DEBUG_TRIG_SEL"                    */
-/*                       XN Debug trigger Select                        */
-/* ==================================================================== */
-
-typedef union sh_xn_debug_trig_sel_u {
-	mmr_t	sh_xn_debug_trig_sel_regval;
-	struct {
-		mmr_t	trigger0_rlm_sel    : 3;
-		mmr_t	reserved_0          : 1;
-		mmr_t	trigger0_nibble_sel : 3;
-		mmr_t	reserved_1          : 1;
-		mmr_t	trigger1_rlm_sel    : 3;
-		mmr_t	reserved_2          : 1;
-		mmr_t	trigger1_nibble_sel : 3;
-		mmr_t	reserved_3          : 1;
-		mmr_t	trigger2_rlm_sel    : 3;
-		mmr_t	reserved_4          : 1;
-		mmr_t	trigger2_nibble_sel : 3;
-		mmr_t	reserved_5          : 1;
-		mmr_t	trigger3_rlm_sel    : 3;
-		mmr_t	reserved_6          : 1;
-		mmr_t	trigger3_nibble_sel : 3;
-		mmr_t	reserved_7          : 1;
-		mmr_t	trigger4_rlm_sel    : 3;
-		mmr_t	reserved_8          : 1;
-		mmr_t	trigger4_nibble_sel : 3;
-		mmr_t	reserved_9          : 1;
-		mmr_t	trigger5_rlm_sel    : 3;
-		mmr_t	reserved_10         : 1;
-		mmr_t	trigger5_nibble_sel : 3;
-		mmr_t	reserved_11         : 1;
-		mmr_t	trigger6_rlm_sel    : 3;
-		mmr_t	reserved_12         : 1;
-		mmr_t	trigger6_nibble_sel : 3;
-		mmr_t	reserved_13         : 1;
-		mmr_t	trigger7_rlm_sel    : 3;
-		mmr_t	reserved_14         : 1;
-		mmr_t	trigger7_nibble_sel : 3;
-		mmr_t	reserved_15         : 1;
-	} sh_xn_debug_trig_sel_s;
-} sh_xn_debug_trig_sel_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XN_TRIGGER_COMPARE"                   */
-/*                           XN Debug Compare                           */
-/* ==================================================================== */
-
-typedef union sh_xn_trigger_compare_u {
-	mmr_t	sh_xn_trigger_compare_regval;
-	struct {
-		mmr_t	mask        : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_xn_trigger_compare_s;
-} sh_xn_trigger_compare_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_TRIGGER_DATA"                     */
-/*                        XN Debug Compare Data                         */
-/* ==================================================================== */
-
-typedef union sh_xn_trigger_data_u {
-	mmr_t	sh_xn_trigger_data_regval;
-	struct {
-		mmr_t	compare_pattern : 32;
-		mmr_t	reserved_0      : 32;
-	} sh_xn_trigger_data_s;
-} sh_xn_trigger_data_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XN_IILB_DEBUG_SEL"                    */
-/*                      XN IILB Debug Port Select                       */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_debug_sel_u {
-	mmr_t	sh_xn_iilb_debug_sel_regval;
-	struct {
-		mmr_t	nibble0_input_sel  : 3;
-		mmr_t	reserved_0         : 1;
-		mmr_t	nibble0_nibble_sel : 3;
-		mmr_t	reserved_1         : 1;
-		mmr_t	nibble1_input_sel  : 3;
-		mmr_t	reserved_2         : 1;
-		mmr_t	nibble1_nibble_sel : 3;
-		mmr_t	reserved_3         : 1;
-		mmr_t	nibble2_input_sel  : 3;
-		mmr_t	reserved_4         : 1;
-		mmr_t	nibble2_nibble_sel : 3;
-		mmr_t	reserved_5         : 1;
-		mmr_t	nibble3_input_sel  : 3;
-		mmr_t	reserved_6         : 1;
-		mmr_t	nibble3_nibble_sel : 3;
-		mmr_t	reserved_7         : 1;
-		mmr_t	nibble4_input_sel  : 3;
-		mmr_t	reserved_8         : 1;
-		mmr_t	nibble4_nibble_sel : 3;
-		mmr_t	reserved_9         : 1;
-		mmr_t	nibble5_input_sel  : 3;
-		mmr_t	reserved_10        : 1;
-		mmr_t	nibble5_nibble_sel : 3;
-		mmr_t	reserved_11        : 1;
-		mmr_t	nibble6_input_sel  : 3;
-		mmr_t	reserved_12        : 1;
-		mmr_t	nibble6_nibble_sel : 3;
-		mmr_t	reserved_13        : 1;
-		mmr_t	nibble7_input_sel  : 3;
-		mmr_t	reserved_14        : 1;
-		mmr_t	nibble7_nibble_sel : 3;
-		mmr_t	reserved_15        : 1;
-	} sh_xn_iilb_debug_sel_s;
-} sh_xn_iilb_debug_sel_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_PI_DEBUG_SEL"                     */
-/*                       XN PI Debug Port Select                        */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_debug_sel_u {
-	mmr_t	sh_xn_pi_debug_sel_regval;
-	struct {
-		mmr_t	nibble0_input_sel  : 3;
-		mmr_t	reserved_0         : 1;
-		mmr_t	nibble0_nibble_sel : 3;
-		mmr_t	reserved_1         : 1;
-		mmr_t	nibble1_input_sel  : 3;
-		mmr_t	reserved_2         : 1;
-		mmr_t	nibble1_nibble_sel : 3;
-		mmr_t	reserved_3         : 1;
-		mmr_t	nibble2_input_sel  : 3;
-		mmr_t	reserved_4         : 1;
-		mmr_t	nibble2_nibble_sel : 3;
-		mmr_t	reserved_5         : 1;
-		mmr_t	nibble3_input_sel  : 3;
-		mmr_t	reserved_6         : 1;
-		mmr_t	nibble3_nibble_sel : 3;
-		mmr_t	reserved_7         : 1;
-		mmr_t	nibble4_input_sel  : 3;
-		mmr_t	reserved_8         : 1;
-		mmr_t	nibble4_nibble_sel : 3;
-		mmr_t	reserved_9         : 1;
-		mmr_t	nibble5_input_sel  : 3;
-		mmr_t	reserved_10        : 1;
-		mmr_t	nibble5_nibble_sel : 3;
-		mmr_t	reserved_11        : 1;
-		mmr_t	nibble6_input_sel  : 3;
-		mmr_t	reserved_12        : 1;
-		mmr_t	nibble6_nibble_sel : 3;
-		mmr_t	reserved_13        : 1;
-		mmr_t	nibble7_input_sel  : 3;
-		mmr_t	reserved_14        : 1;
-		mmr_t	nibble7_nibble_sel : 3;
-		mmr_t	reserved_15        : 1;
-	} sh_xn_pi_debug_sel_s;
-} sh_xn_pi_debug_sel_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_MD_DEBUG_SEL"                     */
-/*                       XN MD Debug Port Select                        */
-/* ==================================================================== */
-
-typedef union sh_xn_md_debug_sel_u {
-	mmr_t	sh_xn_md_debug_sel_regval;
-	struct {
-		mmr_t	nibble0_input_sel  : 3;
-		mmr_t	reserved_0         : 1;
-		mmr_t	nibble0_nibble_sel : 3;
-		mmr_t	reserved_1         : 1;
-		mmr_t	nibble1_input_sel  : 3;
-		mmr_t	reserved_2         : 1;
-		mmr_t	nibble1_nibble_sel : 3;
-		mmr_t	reserved_3         : 1;
-		mmr_t	nibble2_input_sel  : 3;
-		mmr_t	reserved_4         : 1;
-		mmr_t	nibble2_nibble_sel : 3;
-		mmr_t	reserved_5         : 1;
-		mmr_t	nibble3_input_sel  : 3;
-		mmr_t	reserved_6         : 1;
-		mmr_t	nibble3_nibble_sel : 3;
-		mmr_t	reserved_7         : 1;
-		mmr_t	nibble4_input_sel  : 3;
-		mmr_t	reserved_8         : 1;
-		mmr_t	nibble4_nibble_sel : 3;
-		mmr_t	reserved_9         : 1;
-		mmr_t	nibble5_input_sel  : 3;
-		mmr_t	reserved_10        : 1;
-		mmr_t	nibble5_nibble_sel : 3;
-		mmr_t	reserved_11        : 1;
-		mmr_t	nibble6_input_sel  : 3;
-		mmr_t	reserved_12        : 1;
-		mmr_t	nibble6_nibble_sel : 3;
-		mmr_t	reserved_13        : 1;
-		mmr_t	nibble7_input_sel  : 3;
-		mmr_t	reserved_14        : 1;
-		mmr_t	nibble7_nibble_sel : 3;
-		mmr_t	reserved_15        : 1;
-	} sh_xn_md_debug_sel_s;
-} sh_xn_md_debug_sel_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_NI0_DEBUG_SEL"                    */
-/*                       XN NI0 Debug Port Select                       */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_debug_sel_u {
-	mmr_t	sh_xn_ni0_debug_sel_regval;
-	struct {
-		mmr_t	nibble0_input_sel  : 3;
-		mmr_t	reserved_0         : 1;
-		mmr_t	nibble0_nibble_sel : 3;
-		mmr_t	reserved_1         : 1;
-		mmr_t	nibble1_input_sel  : 3;
-		mmr_t	reserved_2         : 1;
-		mmr_t	nibble1_nibble_sel : 3;
-		mmr_t	reserved_3         : 1;
-		mmr_t	nibble2_input_sel  : 3;
-		mmr_t	reserved_4         : 1;
-		mmr_t	nibble2_nibble_sel : 3;
-		mmr_t	reserved_5         : 1;
-		mmr_t	nibble3_input_sel  : 3;
-		mmr_t	reserved_6         : 1;
-		mmr_t	nibble3_nibble_sel : 3;
-		mmr_t	reserved_7         : 1;
-		mmr_t	nibble4_input_sel  : 3;
-		mmr_t	reserved_8         : 1;
-		mmr_t	nibble4_nibble_sel : 3;
-		mmr_t	reserved_9         : 1;
-		mmr_t	nibble5_input_sel  : 3;
-		mmr_t	reserved_10        : 1;
-		mmr_t	nibble5_nibble_sel : 3;
-		mmr_t	reserved_11        : 1;
-		mmr_t	nibble6_input_sel  : 3;
-		mmr_t	reserved_12        : 1;
-		mmr_t	nibble6_nibble_sel : 3;
-		mmr_t	reserved_13        : 1;
-		mmr_t	nibble7_input_sel  : 3;
-		mmr_t	reserved_14        : 1;
-		mmr_t	nibble7_nibble_sel : 3;
-		mmr_t	reserved_15        : 1;
-	} sh_xn_ni0_debug_sel_s;
-} sh_xn_ni0_debug_sel_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_NI1_DEBUG_SEL"                    */
-/*                       XN NI1 Debug Port Select                       */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_debug_sel_u {
-	mmr_t	sh_xn_ni1_debug_sel_regval;
-	struct {
-		mmr_t	nibble0_input_sel  : 3;
-		mmr_t	reserved_0         : 1;
-		mmr_t	nibble0_nibble_sel : 3;
-		mmr_t	reserved_1         : 1;
-		mmr_t	nibble1_input_sel  : 3;
-		mmr_t	reserved_2         : 1;
-		mmr_t	nibble1_nibble_sel : 3;
-		mmr_t	reserved_3         : 1;
-		mmr_t	nibble2_input_sel  : 3;
-		mmr_t	reserved_4         : 1;
-		mmr_t	nibble2_nibble_sel : 3;
-		mmr_t	reserved_5         : 1;
-		mmr_t	nibble3_input_sel  : 3;
-		mmr_t	reserved_6         : 1;
-		mmr_t	nibble3_nibble_sel : 3;
-		mmr_t	reserved_7         : 1;
-		mmr_t	nibble4_input_sel  : 3;
-		mmr_t	reserved_8         : 1;
-		mmr_t	nibble4_nibble_sel : 3;
-		mmr_t	reserved_9         : 1;
-		mmr_t	nibble5_input_sel  : 3;
-		mmr_t	reserved_10        : 1;
-		mmr_t	nibble5_nibble_sel : 3;
-		mmr_t	reserved_11        : 1;
-		mmr_t	nibble6_input_sel  : 3;
-		mmr_t	reserved_12        : 1;
-		mmr_t	nibble6_nibble_sel : 3;
-		mmr_t	reserved_13        : 1;
-		mmr_t	nibble7_input_sel  : 3;
-		mmr_t	reserved_14        : 1;
-		mmr_t	nibble7_nibble_sel : 3;
-		mmr_t	reserved_15        : 1;
-	} sh_xn_ni1_debug_sel_s;
-} sh_xn_ni1_debug_sel_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_LB_CMP_EXP_DATA0"                */
-/*                 IILB compare LB input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_lb_cmp_exp_data0_u {
-	mmr_t	sh_xn_iilb_lb_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_lb_cmp_exp_data0_s;
-} sh_xn_iilb_lb_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_LB_CMP_EXP_DATA1"                */
-/*                 IILB compare LB input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_lb_cmp_exp_data1_u {
-	mmr_t	sh_xn_iilb_lb_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_lb_cmp_exp_data1_s;
-} sh_xn_iilb_lb_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_LB_CMP_ENABLE0"                 */
-/*                    IILB compare LB input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_lb_cmp_enable0_u {
-	mmr_t	sh_xn_iilb_lb_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_lb_cmp_enable0_s;
-} sh_xn_iilb_lb_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_LB_CMP_ENABLE1"                 */
-/*                    IILB compare LB input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_lb_cmp_enable1_u {
-	mmr_t	sh_xn_iilb_lb_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_lb_cmp_enable1_s;
-} sh_xn_iilb_lb_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_II_CMP_EXP_DATA0"                */
-/*                 IILB compare II input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ii_cmp_exp_data0_u {
-	mmr_t	sh_xn_iilb_ii_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_ii_cmp_exp_data0_s;
-} sh_xn_iilb_ii_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_II_CMP_EXP_DATA1"                */
-/*                 IILB compare II input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ii_cmp_exp_data1_u {
-	mmr_t	sh_xn_iilb_ii_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_ii_cmp_exp_data1_s;
-} sh_xn_iilb_ii_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_II_CMP_ENABLE0"                 */
-/*                    IILB compare II input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ii_cmp_enable0_u {
-	mmr_t	sh_xn_iilb_ii_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_ii_cmp_enable0_s;
-} sh_xn_iilb_ii_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_II_CMP_ENABLE1"                 */
-/*                    IILB compare II input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ii_cmp_enable1_u {
-	mmr_t	sh_xn_iilb_ii_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_ii_cmp_enable1_s;
-} sh_xn_iilb_ii_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_MD_CMP_EXP_DATA0"                */
-/*                 IILB compare MD input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_md_cmp_exp_data0_u {
-	mmr_t	sh_xn_iilb_md_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_md_cmp_exp_data0_s;
-} sh_xn_iilb_md_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_MD_CMP_EXP_DATA1"                */
-/*                 IILB compare MD input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_md_cmp_exp_data1_u {
-	mmr_t	sh_xn_iilb_md_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_md_cmp_exp_data1_s;
-} sh_xn_iilb_md_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_MD_CMP_ENABLE0"                 */
-/*                    IILB compare MD input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_md_cmp_enable0_u {
-	mmr_t	sh_xn_iilb_md_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_md_cmp_enable0_s;
-} sh_xn_iilb_md_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_MD_CMP_ENABLE1"                 */
-/*                    IILB compare MD input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_md_cmp_enable1_u {
-	mmr_t	sh_xn_iilb_md_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_md_cmp_enable1_s;
-} sh_xn_iilb_md_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_PI_CMP_EXP_DATA0"                */
-/*                 IILB compare PI input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_pi_cmp_exp_data0_u {
-	mmr_t	sh_xn_iilb_pi_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_pi_cmp_exp_data0_s;
-} sh_xn_iilb_pi_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_PI_CMP_EXP_DATA1"                */
-/*                 IILB compare PI input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_pi_cmp_exp_data1_u {
-	mmr_t	sh_xn_iilb_pi_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_pi_cmp_exp_data1_s;
-} sh_xn_iilb_pi_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_PI_CMP_ENABLE0"                 */
-/*                    IILB compare PI input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_pi_cmp_enable0_u {
-	mmr_t	sh_xn_iilb_pi_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_pi_cmp_enable0_s;
-} sh_xn_iilb_pi_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_IILB_PI_CMP_ENABLE1"                 */
-/*                    IILB compare PI input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_pi_cmp_enable1_u {
-	mmr_t	sh_xn_iilb_pi_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_pi_cmp_enable1_s;
-} sh_xn_iilb_pi_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_IILB_NI0_CMP_EXP_DATA0"                */
-/*                IILB compare NI0 input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ni0_cmp_exp_data0_u {
-	mmr_t	sh_xn_iilb_ni0_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_ni0_cmp_exp_data0_s;
-} sh_xn_iilb_ni0_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_IILB_NI0_CMP_EXP_DATA1"                */
-/*                IILB compare NI0 input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ni0_cmp_exp_data1_u {
-	mmr_t	sh_xn_iilb_ni0_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_ni0_cmp_exp_data1_s;
-} sh_xn_iilb_ni0_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_NI0_CMP_ENABLE0"                 */
-/*                    IILB compare NI0 input enable0                    */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ni0_cmp_enable0_u {
-	mmr_t	sh_xn_iilb_ni0_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_ni0_cmp_enable0_s;
-} sh_xn_iilb_ni0_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_NI0_CMP_ENABLE1"                 */
-/*                    IILB compare NI0 input enable1                    */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ni0_cmp_enable1_u {
-	mmr_t	sh_xn_iilb_ni0_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_ni0_cmp_enable1_s;
-} sh_xn_iilb_ni0_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_IILB_NI1_CMP_EXP_DATA0"                */
-/*                IILB compare NI1 input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ni1_cmp_exp_data0_u {
-	mmr_t	sh_xn_iilb_ni1_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_ni1_cmp_exp_data0_s;
-} sh_xn_iilb_ni1_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_IILB_NI1_CMP_EXP_DATA1"                */
-/*                IILB compare NI1 input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ni1_cmp_exp_data1_u {
-	mmr_t	sh_xn_iilb_ni1_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_iilb_ni1_cmp_exp_data1_s;
-} sh_xn_iilb_ni1_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_NI1_CMP_ENABLE0"                 */
-/*                    IILB compare NI1 input enable0                    */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ni1_cmp_enable0_u {
-	mmr_t	sh_xn_iilb_ni1_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_ni1_cmp_enable0_s;
-} sh_xn_iilb_ni1_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_IILB_NI1_CMP_ENABLE1"                 */
-/*                    IILB compare NI1 input enable1                    */
-/* ==================================================================== */
-
-typedef union sh_xn_iilb_ni1_cmp_enable1_u {
-	mmr_t	sh_xn_iilb_ni1_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_iilb_ni1_cmp_enable1_s;
-} sh_xn_iilb_ni1_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_IILB_CMP_EXP_DATA0"                */
-/*                 MD compare IILB input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_md_iilb_cmp_exp_data0_u {
-	mmr_t	sh_xn_md_iilb_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_md_iilb_cmp_exp_data0_s;
-} sh_xn_md_iilb_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_IILB_CMP_EXP_DATA1"                */
-/*                 MD compare IILB input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_md_iilb_cmp_exp_data1_u {
-	mmr_t	sh_xn_md_iilb_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_md_iilb_cmp_exp_data1_s;
-} sh_xn_md_iilb_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_IILB_CMP_ENABLE0"                 */
-/*                    MD compare IILB input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_md_iilb_cmp_enable0_u {
-	mmr_t	sh_xn_md_iilb_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_md_iilb_cmp_enable0_s;
-} sh_xn_md_iilb_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_IILB_CMP_ENABLE1"                 */
-/*                    MD compare IILB input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_md_iilb_cmp_enable1_u {
-	mmr_t	sh_xn_md_iilb_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_md_iilb_cmp_enable1_s;
-} sh_xn_md_iilb_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_NI0_CMP_EXP_DATA0"                 */
-/*                 MD compare NI0 input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_md_ni0_cmp_exp_data0_u {
-	mmr_t	sh_xn_md_ni0_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_md_ni0_cmp_exp_data0_s;
-} sh_xn_md_ni0_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_NI0_CMP_EXP_DATA1"                 */
-/*                 MD compare NI0 input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_md_ni0_cmp_exp_data1_u {
-	mmr_t	sh_xn_md_ni0_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_md_ni0_cmp_exp_data1_s;
-} sh_xn_md_ni0_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_NI0_CMP_ENABLE0"                  */
-/*                     MD compare NI0 input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_md_ni0_cmp_enable0_u {
-	mmr_t	sh_xn_md_ni0_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_md_ni0_cmp_enable0_s;
-} sh_xn_md_ni0_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_NI0_CMP_ENABLE1"                  */
-/*                     MD compare NI0 input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_md_ni0_cmp_enable1_u {
-	mmr_t	sh_xn_md_ni0_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_md_ni0_cmp_enable1_s;
-} sh_xn_md_ni0_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_NI1_CMP_EXP_DATA0"                 */
-/*                 MD compare NI1 input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_md_ni1_cmp_exp_data0_u {
-	mmr_t	sh_xn_md_ni1_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_md_ni1_cmp_exp_data0_s;
-} sh_xn_md_ni1_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_MD_NI1_CMP_EXP_DATA1"                 */
-/*                 MD compare NI1 input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_md_ni1_cmp_exp_data1_u {
-	mmr_t	sh_xn_md_ni1_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_md_ni1_cmp_exp_data1_s;
-} sh_xn_md_ni1_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_NI1_CMP_ENABLE0"                  */
-/*                     MD compare NI1 input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_md_ni1_cmp_enable0_u {
-	mmr_t	sh_xn_md_ni1_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_md_ni1_cmp_enable0_s;
-} sh_xn_md_ni1_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_NI1_CMP_ENABLE1"                  */
-/*                     MD compare NI1 input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_md_ni1_cmp_enable1_u {
-	mmr_t	sh_xn_md_ni1_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_md_ni1_cmp_enable1_s;
-} sh_xn_md_ni1_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_SIC_CMP_EXP_HDR0"                 */
-/*                MD compare SIC input expected header0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_exp_hdr0_u {
-	mmr_t	sh_xn_md_sic_cmp_exp_hdr0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_md_sic_cmp_exp_hdr0_s;
-} sh_xn_md_sic_cmp_exp_hdr0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_MD_SIC_CMP_EXP_HDR1"                 */
-/*                MD compare SIC input expected header1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_exp_hdr1_u {
-	mmr_t	sh_xn_md_sic_cmp_exp_hdr1_regval;
-	struct {
-		mmr_t	data        : 42;
-		mmr_t	reserved_0  : 22;
-	} sh_xn_md_sic_cmp_exp_hdr1_s;
-} sh_xn_md_sic_cmp_exp_hdr1_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_HDR_ENABLE0"                */
-/*                    MD compare SIC header enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_hdr_enable0_u {
-	mmr_t	sh_xn_md_sic_cmp_hdr_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_md_sic_cmp_hdr_enable0_s;
-} sh_xn_md_sic_cmp_hdr_enable0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_HDR_ENABLE1"                */
-/*                    MD compare SIC header enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_hdr_enable1_u {
-	mmr_t	sh_xn_md_sic_cmp_hdr_enable1_regval;
-	struct {
-		mmr_t	enable      : 42;
-		mmr_t	reserved_0  : 22;
-	} sh_xn_md_sic_cmp_hdr_enable1_s;
-} sh_xn_md_sic_cmp_hdr_enable1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_MD_SIC_CMP_DATA0"                   */
-/*                         MD compare SIC data0                         */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_data0_u {
-	mmr_t	sh_xn_md_sic_cmp_data0_regval;
-	struct {
-		mmr_t	data0       : 64;
-	} sh_xn_md_sic_cmp_data0_s;
-} sh_xn_md_sic_cmp_data0_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_MD_SIC_CMP_DATA1"                   */
-/*                         MD compare SIC data1                         */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_data1_u {
-	mmr_t	sh_xn_md_sic_cmp_data1_regval;
-	struct {
-		mmr_t	data1       : 64;
-	} sh_xn_md_sic_cmp_data1_s;
-} sh_xn_md_sic_cmp_data1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_MD_SIC_CMP_DATA2"                   */
-/*                         MD compare SIC data2                         */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_data2_u {
-	mmr_t	sh_xn_md_sic_cmp_data2_regval;
-	struct {
-		mmr_t	data2       : 64;
-	} sh_xn_md_sic_cmp_data2_s;
-} sh_xn_md_sic_cmp_data2_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_MD_SIC_CMP_DATA3"                   */
-/*                         MD compare SIC data3                         */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_data3_u {
-	mmr_t	sh_xn_md_sic_cmp_data3_regval;
-	struct {
-		mmr_t	data3       : 64;
-	} sh_xn_md_sic_cmp_data3_s;
-} sh_xn_md_sic_cmp_data3_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_DATA_ENABLE0"               */
-/*                     MD enable compare SIC data0                      */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_data_enable0_u {
-	mmr_t	sh_xn_md_sic_cmp_data_enable0_regval;
-	struct {
-		mmr_t	data_enable0 : 64;
-	} sh_xn_md_sic_cmp_data_enable0_s;
-} sh_xn_md_sic_cmp_data_enable0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_DATA_ENABLE1"               */
-/*                     MD enable compare SIC data1                      */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_data_enable1_u {
-	mmr_t	sh_xn_md_sic_cmp_data_enable1_regval;
-	struct {
-		mmr_t	data_enable1 : 64;
-	} sh_xn_md_sic_cmp_data_enable1_s;
-} sh_xn_md_sic_cmp_data_enable1_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_DATA_ENABLE2"               */
-/*                     MD enable compare SIC data2                      */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_data_enable2_u {
-	mmr_t	sh_xn_md_sic_cmp_data_enable2_regval;
-	struct {
-		mmr_t	data_enable2 : 64;
-	} sh_xn_md_sic_cmp_data_enable2_s;
-} sh_xn_md_sic_cmp_data_enable2_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_MD_SIC_CMP_DATA_ENABLE3"               */
-/*                     MD enable compare SIC data3                      */
-/* ==================================================================== */
-
-typedef union sh_xn_md_sic_cmp_data_enable3_u {
-	mmr_t	sh_xn_md_sic_cmp_data_enable3_regval;
-	struct {
-		mmr_t	data_enable3 : 64;
-	} sh_xn_md_sic_cmp_data_enable3_s;
-} sh_xn_md_sic_cmp_data_enable3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_IILB_CMP_EXP_DATA0"                */
-/*                 PI compare IILB input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_iilb_cmp_exp_data0_u {
-	mmr_t	sh_xn_pi_iilb_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_pi_iilb_cmp_exp_data0_s;
-} sh_xn_pi_iilb_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_IILB_CMP_EXP_DATA1"                */
-/*                 PI compare IILB input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_iilb_cmp_exp_data1_u {
-	mmr_t	sh_xn_pi_iilb_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_pi_iilb_cmp_exp_data1_s;
-} sh_xn_pi_iilb_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_IILB_CMP_ENABLE0"                 */
-/*                    PI compare IILB input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_iilb_cmp_enable0_u {
-	mmr_t	sh_xn_pi_iilb_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_pi_iilb_cmp_enable0_s;
-} sh_xn_pi_iilb_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_IILB_CMP_ENABLE1"                 */
-/*                    PI compare IILB input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_iilb_cmp_enable1_u {
-	mmr_t	sh_xn_pi_iilb_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_pi_iilb_cmp_enable1_s;
-} sh_xn_pi_iilb_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_NI0_CMP_EXP_DATA0"                 */
-/*                 PI compare NI0 input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_ni0_cmp_exp_data0_u {
-	mmr_t	sh_xn_pi_ni0_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_pi_ni0_cmp_exp_data0_s;
-} sh_xn_pi_ni0_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_NI0_CMP_EXP_DATA1"                 */
-/*                 PI compare NI0 input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_ni0_cmp_exp_data1_u {
-	mmr_t	sh_xn_pi_ni0_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_pi_ni0_cmp_exp_data1_s;
-} sh_xn_pi_ni0_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_NI0_CMP_ENABLE0"                  */
-/*                     PI compare NI0 input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_ni0_cmp_enable0_u {
-	mmr_t	sh_xn_pi_ni0_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_pi_ni0_cmp_enable0_s;
-} sh_xn_pi_ni0_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_NI0_CMP_ENABLE1"                  */
-/*                     PI compare NI0 input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_ni0_cmp_enable1_u {
-	mmr_t	sh_xn_pi_ni0_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_pi_ni0_cmp_enable1_s;
-} sh_xn_pi_ni0_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_NI1_CMP_EXP_DATA0"                 */
-/*                 PI compare NI1 input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_ni1_cmp_exp_data0_u {
-	mmr_t	sh_xn_pi_ni1_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_pi_ni1_cmp_exp_data0_s;
-} sh_xn_pi_ni1_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_PI_NI1_CMP_EXP_DATA1"                 */
-/*                 PI compare NI1 input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_ni1_cmp_exp_data1_u {
-	mmr_t	sh_xn_pi_ni1_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_pi_ni1_cmp_exp_data1_s;
-} sh_xn_pi_ni1_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_NI1_CMP_ENABLE0"                  */
-/*                     PI compare NI1 input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_ni1_cmp_enable0_u {
-	mmr_t	sh_xn_pi_ni1_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_pi_ni1_cmp_enable0_s;
-} sh_xn_pi_ni1_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_NI1_CMP_ENABLE1"                  */
-/*                     PI compare NI1 input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_ni1_cmp_enable1_u {
-	mmr_t	sh_xn_pi_ni1_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_pi_ni1_cmp_enable1_s;
-} sh_xn_pi_ni1_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_SIC_CMP_EXP_HDR0"                 */
-/*                PI compare SIC input expected header0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_exp_hdr0_u {
-	mmr_t	sh_xn_pi_sic_cmp_exp_hdr0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_pi_sic_cmp_exp_hdr0_s;
-} sh_xn_pi_sic_cmp_exp_hdr0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_PI_SIC_CMP_EXP_HDR1"                 */
-/*                PI compare SIC input expected header1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_exp_hdr1_u {
-	mmr_t	sh_xn_pi_sic_cmp_exp_hdr1_regval;
-	struct {
-		mmr_t	data        : 42;
-		mmr_t	reserved_0  : 22;
-	} sh_xn_pi_sic_cmp_exp_hdr1_s;
-} sh_xn_pi_sic_cmp_exp_hdr1_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_HDR_ENABLE0"                */
-/*                    PI compare SIC header enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_hdr_enable0_u {
-	mmr_t	sh_xn_pi_sic_cmp_hdr_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_pi_sic_cmp_hdr_enable0_s;
-} sh_xn_pi_sic_cmp_hdr_enable0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_HDR_ENABLE1"                */
-/*                    PI compare SIC header enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_hdr_enable1_u {
-	mmr_t	sh_xn_pi_sic_cmp_hdr_enable1_regval;
-	struct {
-		mmr_t	enable      : 42;
-		mmr_t	reserved_0  : 22;
-	} sh_xn_pi_sic_cmp_hdr_enable1_s;
-} sh_xn_pi_sic_cmp_hdr_enable1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_PI_SIC_CMP_DATA0"                   */
-/*                         PI compare SIC data0                         */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_data0_u {
-	mmr_t	sh_xn_pi_sic_cmp_data0_regval;
-	struct {
-		mmr_t	data0       : 64;
-	} sh_xn_pi_sic_cmp_data0_s;
-} sh_xn_pi_sic_cmp_data0_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_PI_SIC_CMP_DATA1"                   */
-/*                         PI compare SIC data1                         */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_data1_u {
-	mmr_t	sh_xn_pi_sic_cmp_data1_regval;
-	struct {
-		mmr_t	data1       : 64;
-	} sh_xn_pi_sic_cmp_data1_s;
-} sh_xn_pi_sic_cmp_data1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_PI_SIC_CMP_DATA2"                   */
-/*                         PI compare SIC data2                         */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_data2_u {
-	mmr_t	sh_xn_pi_sic_cmp_data2_regval;
-	struct {
-		mmr_t	data2       : 64;
-	} sh_xn_pi_sic_cmp_data2_s;
-} sh_xn_pi_sic_cmp_data2_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_PI_SIC_CMP_DATA3"                   */
-/*                         PI compare SIC data3                         */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_data3_u {
-	mmr_t	sh_xn_pi_sic_cmp_data3_regval;
-	struct {
-		mmr_t	data3       : 64;
-	} sh_xn_pi_sic_cmp_data3_s;
-} sh_xn_pi_sic_cmp_data3_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_DATA_ENABLE0"               */
-/*                     PI enable compare SIC data0                      */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_data_enable0_u {
-	mmr_t	sh_xn_pi_sic_cmp_data_enable0_regval;
-	struct {
-		mmr_t	data_enable0 : 64;
-	} sh_xn_pi_sic_cmp_data_enable0_s;
-} sh_xn_pi_sic_cmp_data_enable0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_DATA_ENABLE1"               */
-/*                     PI enable compare SIC data1                      */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_data_enable1_u {
-	mmr_t	sh_xn_pi_sic_cmp_data_enable1_regval;
-	struct {
-		mmr_t	data_enable1 : 64;
-	} sh_xn_pi_sic_cmp_data_enable1_s;
-} sh_xn_pi_sic_cmp_data_enable1_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_DATA_ENABLE2"               */
-/*                     PI enable compare SIC data2                      */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_data_enable2_u {
-	mmr_t	sh_xn_pi_sic_cmp_data_enable2_regval;
-	struct {
-		mmr_t	data_enable2 : 64;
-	} sh_xn_pi_sic_cmp_data_enable2_s;
-} sh_xn_pi_sic_cmp_data_enable2_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_PI_SIC_CMP_DATA_ENABLE3"               */
-/*                     PI enable compare SIC data3                      */
-/* ==================================================================== */
-
-typedef union sh_xn_pi_sic_cmp_data_enable3_u {
-	mmr_t	sh_xn_pi_sic_cmp_data_enable3_regval;
-	struct {
-		mmr_t	data_enable3 : 64;
-	} sh_xn_pi_sic_cmp_data_enable3_s;
-} sh_xn_pi_sic_cmp_data_enable3_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_NI0_IILB_CMP_EXP_DATA0"                */
-/*                NI0 compare IILB input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_iilb_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni0_iilb_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_iilb_cmp_exp_data0_s;
-} sh_xn_ni0_iilb_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_NI0_IILB_CMP_EXP_DATA1"                */
-/*                NI0 compare IILB input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_iilb_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni0_iilb_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_iilb_cmp_exp_data1_s;
-} sh_xn_ni0_iilb_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_IILB_CMP_ENABLE0"                 */
-/*                    NI0 compare IILB input enable0                    */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_iilb_cmp_enable0_u {
-	mmr_t	sh_xn_ni0_iilb_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_iilb_cmp_enable0_s;
-} sh_xn_ni0_iilb_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_IILB_CMP_ENABLE1"                 */
-/*                    NI0 compare IILB input enable1                    */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_iilb_cmp_enable1_u {
-	mmr_t	sh_xn_ni0_iilb_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_iilb_cmp_enable1_s;
-} sh_xn_ni0_iilb_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_PI_CMP_EXP_DATA0"                 */
-/*                 NI0 compare PI input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_pi_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni0_pi_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_pi_cmp_exp_data0_s;
-} sh_xn_ni0_pi_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_PI_CMP_EXP_DATA1"                 */
-/*                 NI0 compare PI input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_pi_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni0_pi_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_pi_cmp_exp_data1_s;
-} sh_xn_ni0_pi_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_PI_CMP_ENABLE0"                  */
-/*                     NI0 compare PI input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_pi_cmp_enable0_u {
-	mmr_t	sh_xn_ni0_pi_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_pi_cmp_enable0_s;
-} sh_xn_ni0_pi_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_PI_CMP_ENABLE1"                  */
-/*                     NI0 compare PI input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_pi_cmp_enable1_u {
-	mmr_t	sh_xn_ni0_pi_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_pi_cmp_enable1_s;
-} sh_xn_ni0_pi_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_MD_CMP_EXP_DATA0"                 */
-/*                 NI0 compare MD input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_md_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni0_md_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_md_cmp_exp_data0_s;
-} sh_xn_ni0_md_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_MD_CMP_EXP_DATA1"                 */
-/*                 NI0 compare MD input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_md_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni0_md_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_md_cmp_exp_data1_s;
-} sh_xn_ni0_md_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_MD_CMP_ENABLE0"                  */
-/*                     NI0 compare MD input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_md_cmp_enable0_u {
-	mmr_t	sh_xn_ni0_md_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_md_cmp_enable0_s;
-} sh_xn_ni0_md_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_MD_CMP_ENABLE1"                  */
-/*                     NI0 compare MD input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_md_cmp_enable1_u {
-	mmr_t	sh_xn_ni0_md_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_md_cmp_enable1_s;
-} sh_xn_ni0_md_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_NI_CMP_EXP_DATA0"                 */
-/*                 NI0 compare NI input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_ni_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni0_ni_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_ni_cmp_exp_data0_s;
-} sh_xn_ni0_ni_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_NI_CMP_EXP_DATA1"                 */
-/*                 NI0 compare NI input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_ni_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni0_ni_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_ni_cmp_exp_data1_s;
-} sh_xn_ni0_ni_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_NI_CMP_ENABLE0"                  */
-/*                     NI0 compare NI input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_ni_cmp_enable0_u {
-	mmr_t	sh_xn_ni0_ni_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_ni_cmp_enable0_s;
-} sh_xn_ni0_ni_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_NI_CMP_ENABLE1"                  */
-/*                     NI0 compare NI input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_ni_cmp_enable1_u {
-	mmr_t	sh_xn_ni0_ni_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_ni_cmp_enable1_s;
-} sh_xn_ni0_ni_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_LLP_CMP_EXP_DATA0"                */
-/*                 NI0 compare LLP input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_llp_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni0_llp_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_llp_cmp_exp_data0_s;
-} sh_xn_ni0_llp_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI0_LLP_CMP_EXP_DATA1"                */
-/*                 NI0 compare LLP input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_llp_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni0_llp_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni0_llp_cmp_exp_data1_s;
-} sh_xn_ni0_llp_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_LLP_CMP_ENABLE0"                 */
-/*                    NI0 compare LLP input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_llp_cmp_enable0_u {
-	mmr_t	sh_xn_ni0_llp_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_llp_cmp_enable0_s;
-} sh_xn_ni0_llp_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI0_LLP_CMP_ENABLE1"                 */
-/*                    NI0 compare LLP input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni0_llp_cmp_enable1_u {
-	mmr_t	sh_xn_ni0_llp_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni0_llp_cmp_enable1_s;
-} sh_xn_ni0_llp_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_NI1_IILB_CMP_EXP_DATA0"                */
-/*                NI1 compare IILB input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_iilb_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni1_iilb_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_iilb_cmp_exp_data0_s;
-} sh_xn_ni1_iilb_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_XN_NI1_IILB_CMP_EXP_DATA1"                */
-/*                NI1 compare IILB input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_iilb_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni1_iilb_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_iilb_cmp_exp_data1_s;
-} sh_xn_ni1_iilb_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_IILB_CMP_ENABLE0"                 */
-/*                    NI1 compare IILB input enable0                    */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_iilb_cmp_enable0_u {
-	mmr_t	sh_xn_ni1_iilb_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_iilb_cmp_enable0_s;
-} sh_xn_ni1_iilb_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_IILB_CMP_ENABLE1"                 */
-/*                    NI1 compare IILB input enable1                    */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_iilb_cmp_enable1_u {
-	mmr_t	sh_xn_ni1_iilb_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_iilb_cmp_enable1_s;
-} sh_xn_ni1_iilb_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_PI_CMP_EXP_DATA0"                 */
-/*                 NI1 compare PI input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_pi_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni1_pi_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_pi_cmp_exp_data0_s;
-} sh_xn_ni1_pi_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_PI_CMP_EXP_DATA1"                 */
-/*                 NI1 compare PI input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_pi_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni1_pi_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_pi_cmp_exp_data1_s;
-} sh_xn_ni1_pi_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_PI_CMP_ENABLE0"                  */
-/*                     NI1 compare PI input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_pi_cmp_enable0_u {
-	mmr_t	sh_xn_ni1_pi_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_pi_cmp_enable0_s;
-} sh_xn_ni1_pi_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_PI_CMP_ENABLE1"                  */
-/*                     NI1 compare PI input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_pi_cmp_enable1_u {
-	mmr_t	sh_xn_ni1_pi_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_pi_cmp_enable1_s;
-} sh_xn_ni1_pi_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_MD_CMP_EXP_DATA0"                 */
-/*                 NI1 compare MD input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_md_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni1_md_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_md_cmp_exp_data0_s;
-} sh_xn_ni1_md_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_MD_CMP_EXP_DATA1"                 */
-/*                 NI1 compare MD input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_md_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni1_md_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_md_cmp_exp_data1_s;
-} sh_xn_ni1_md_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_MD_CMP_ENABLE0"                  */
-/*                     NI1 compare MD input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_md_cmp_enable0_u {
-	mmr_t	sh_xn_ni1_md_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_md_cmp_enable0_s;
-} sh_xn_ni1_md_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_MD_CMP_ENABLE1"                  */
-/*                     NI1 compare MD input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_md_cmp_enable1_u {
-	mmr_t	sh_xn_ni1_md_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_md_cmp_enable1_s;
-} sh_xn_ni1_md_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_NI_CMP_EXP_DATA0"                 */
-/*                 NI1 compare NI input expected data0                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_ni_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni1_ni_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_ni_cmp_exp_data0_s;
-} sh_xn_ni1_ni_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_NI_CMP_EXP_DATA1"                 */
-/*                 NI1 compare NI input expected data1                  */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_ni_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni1_ni_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_ni_cmp_exp_data1_s;
-} sh_xn_ni1_ni_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_NI_CMP_ENABLE0"                  */
-/*                     NI1 compare NI input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_ni_cmp_enable0_u {
-	mmr_t	sh_xn_ni1_ni_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_ni_cmp_enable0_s;
-} sh_xn_ni1_ni_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_NI_CMP_ENABLE1"                  */
-/*                     NI1 compare NI input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_ni_cmp_enable1_u {
-	mmr_t	sh_xn_ni1_ni_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_ni_cmp_enable1_s;
-} sh_xn_ni1_ni_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_LLP_CMP_EXP_DATA0"                */
-/*                 NI1 compare LLP input expected data0                 */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_llp_cmp_exp_data0_u {
-	mmr_t	sh_xn_ni1_llp_cmp_exp_data0_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_llp_cmp_exp_data0_s;
-} sh_xn_ni1_llp_cmp_exp_data0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_NI1_LLP_CMP_EXP_DATA1"                */
-/*                 NI1 compare LLP input expected data1                 */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_llp_cmp_exp_data1_u {
-	mmr_t	sh_xn_ni1_llp_cmp_exp_data1_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_ni1_llp_cmp_exp_data1_s;
-} sh_xn_ni1_llp_cmp_exp_data1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_LLP_CMP_ENABLE0"                 */
-/*                    NI1 compare LLP input enable0                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_llp_cmp_enable0_u {
-	mmr_t	sh_xn_ni1_llp_cmp_enable0_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_llp_cmp_enable0_s;
-} sh_xn_ni1_llp_cmp_enable0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_NI1_LLP_CMP_ENABLE1"                 */
-/*                    NI1 compare LLP input enable1                     */
-/* ==================================================================== */
-
-typedef union sh_xn_ni1_llp_cmp_enable1_u {
-	mmr_t	sh_xn_ni1_llp_cmp_enable1_regval;
-	struct {
-		mmr_t	enable      : 64;
-	} sh_xn_ni1_llp_cmp_enable1_s;
-} sh_xn_ni1_llp_cmp_enable1_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNPI_ECC_INJ_REG"                    */
-/* ==================================================================== */
-
-typedef union sh_xnpi_ecc_inj_reg_u {
-	mmr_t	sh_xnpi_ecc_inj_reg_regval;
-	struct {
-		mmr_t	byte0          : 8;
-		mmr_t	reserved_0     : 4;
-		mmr_t	data_1shot0    : 1;
-		mmr_t	data_cont0     : 1;
-		mmr_t	data_cb_1shot0 : 1;
-		mmr_t	data_cb_cont0  : 1;
-		mmr_t	byte1          : 8;
-		mmr_t	reserved_1     : 4;
-		mmr_t	data_1shot1    : 1;
-		mmr_t	data_cont1     : 1;
-		mmr_t	data_cb_1shot1 : 1;
-		mmr_t	data_cb_cont1  : 1;
-		mmr_t	byte2          : 8;
-		mmr_t	reserved_2     : 4;
-		mmr_t	data_1shot2    : 1;
-		mmr_t	data_cont2     : 1;
-		mmr_t	data_cb_1shot2 : 1;
-		mmr_t	data_cb_cont2  : 1;
-		mmr_t	byte3          : 8;
-		mmr_t	reserved_3     : 4;
-		mmr_t	data_1shot3    : 1;
-		mmr_t	data_cont3     : 1;
-		mmr_t	data_cb_1shot3 : 1;
-		mmr_t	data_cb_cont3  : 1;
-	} sh_xnpi_ecc_inj_reg_s;
-} sh_xnpi_ecc_inj_reg_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_ECC0_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-typedef union sh_xnpi_ecc0_inj_mask_reg_u {
-	mmr_t	sh_xnpi_ecc0_inj_mask_reg_regval;
-	struct {
-		mmr_t	mask_ecc0   : 64;
-	} sh_xnpi_ecc0_inj_mask_reg_s;
-} sh_xnpi_ecc0_inj_mask_reg_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_ECC1_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-typedef union sh_xnpi_ecc1_inj_mask_reg_u {
-	mmr_t	sh_xnpi_ecc1_inj_mask_reg_regval;
-	struct {
-		mmr_t	mask_ecc1   : 64;
-	} sh_xnpi_ecc1_inj_mask_reg_s;
-} sh_xnpi_ecc1_inj_mask_reg_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_ECC2_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-typedef union sh_xnpi_ecc2_inj_mask_reg_u {
-	mmr_t	sh_xnpi_ecc2_inj_mask_reg_regval;
-	struct {
-		mmr_t	mask_ecc2   : 64;
-	} sh_xnpi_ecc2_inj_mask_reg_s;
-} sh_xnpi_ecc2_inj_mask_reg_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNPI_ECC3_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-typedef union sh_xnpi_ecc3_inj_mask_reg_u {
-	mmr_t	sh_xnpi_ecc3_inj_mask_reg_regval;
-	struct {
-		mmr_t	mask_ecc3   : 64;
-	} sh_xnpi_ecc3_inj_mask_reg_s;
-} sh_xnpi_ecc3_inj_mask_reg_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNMD_ECC_INJ_REG"                    */
-/* ==================================================================== */
-
-typedef union sh_xnmd_ecc_inj_reg_u {
-	mmr_t	sh_xnmd_ecc_inj_reg_regval;
-	struct {
-		mmr_t	byte0          : 8;
-		mmr_t	reserved_0     : 4;
-		mmr_t	data_1shot0    : 1;
-		mmr_t	data_cont0     : 1;
-		mmr_t	data_cb_1shot0 : 1;
-		mmr_t	data_cb_cont0  : 1;
-		mmr_t	byte1          : 8;
-		mmr_t	reserved_1     : 4;
-		mmr_t	data_1shot1    : 1;
-		mmr_t	data_cont1     : 1;
-		mmr_t	data_cb_1shot1 : 1;
-		mmr_t	data_cb_cont1  : 1;
-		mmr_t	byte2          : 8;
-		mmr_t	reserved_2     : 4;
-		mmr_t	data_1shot2    : 1;
-		mmr_t	data_cont2     : 1;
-		mmr_t	data_cb_1shot2 : 1;
-		mmr_t	data_cb_cont2  : 1;
-		mmr_t	byte3          : 8;
-		mmr_t	reserved_3     : 4;
-		mmr_t	data_1shot3    : 1;
-		mmr_t	data_cont3     : 1;
-		mmr_t	data_cb_1shot3 : 1;
-		mmr_t	data_cb_cont3  : 1;
-	} sh_xnmd_ecc_inj_reg_s;
-} sh_xnmd_ecc_inj_reg_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_ECC0_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-typedef union sh_xnmd_ecc0_inj_mask_reg_u {
-	mmr_t	sh_xnmd_ecc0_inj_mask_reg_regval;
-	struct {
-		mmr_t	mask_ecc0   : 64;
-	} sh_xnmd_ecc0_inj_mask_reg_s;
-} sh_xnmd_ecc0_inj_mask_reg_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_ECC1_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-typedef union sh_xnmd_ecc1_inj_mask_reg_u {
-	mmr_t	sh_xnmd_ecc1_inj_mask_reg_regval;
-	struct {
-		mmr_t	mask_ecc1   : 64;
-	} sh_xnmd_ecc1_inj_mask_reg_s;
-} sh_xnmd_ecc1_inj_mask_reg_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_ECC2_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-typedef union sh_xnmd_ecc2_inj_mask_reg_u {
-	mmr_t	sh_xnmd_ecc2_inj_mask_reg_regval;
-	struct {
-		mmr_t	mask_ecc2   : 64;
-	} sh_xnmd_ecc2_inj_mask_reg_s;
-} sh_xnmd_ecc2_inj_mask_reg_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNMD_ECC3_INJ_MASK_REG"                 */
-/* ==================================================================== */
-
-typedef union sh_xnmd_ecc3_inj_mask_reg_u {
-	mmr_t	sh_xnmd_ecc3_inj_mask_reg_regval;
-	struct {
-		mmr_t	mask_ecc3   : 64;
-	} sh_xnmd_ecc3_inj_mask_reg_s;
-} sh_xnmd_ecc3_inj_mask_reg_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNMD_ECC_ERR_REPORT"                   */
-/* ==================================================================== */
-
-typedef union sh_xnmd_ecc_err_report_u {
-	mmr_t	sh_xnmd_ecc_err_report_regval;
-	struct {
-		mmr_t	ecc_disable0 : 1;
-		mmr_t	reserved_0   : 15;
-		mmr_t	ecc_disable1 : 1;
-		mmr_t	reserved_1   : 15;
-		mmr_t	ecc_disable2 : 1;
-		mmr_t	reserved_2   : 15;
-		mmr_t	ecc_disable3 : 1;
-		mmr_t	reserved_3   : 15;
-	} sh_xnmd_ecc_err_report_s;
-} sh_xnmd_ecc_err_report_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_ERROR_SUMMARY_1"                   */
-/*                       ni0  Error Summary Bits                        */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_summary_1_u {
-	mmr_t	sh_ni0_error_summary_1_regval;
-	struct {
-		mmr_t	overflow_fifo02_debit0        : 1;
-		mmr_t	overflow_fifo02_debit2        : 1;
-		mmr_t	overflow_fifo13_debit0        : 1;
-		mmr_t	overflow_fifo13_debit2        : 1;
-		mmr_t	overflow_fifo02_vc0_pop       : 1;
-		mmr_t	overflow_fifo02_vc2_pop       : 1;
-		mmr_t	overflow_fifo13_vc1_pop       : 1;
-		mmr_t	overflow_fifo13_vc3_pop       : 1;
-		mmr_t	overflow_fifo02_vc0_push      : 1;
-		mmr_t	overflow_fifo02_vc2_push      : 1;
-		mmr_t	overflow_fifo13_vc1_push      : 1;
-		mmr_t	overflow_fifo13_vc3_push      : 1;
-		mmr_t	overflow_fifo02_vc0_credit    : 1;
-		mmr_t	overflow_fifo02_vc2_credit    : 1;
-		mmr_t	overflow_fifo13_vc0_credit    : 1;
-		mmr_t	overflow_fifo13_vc2_credit    : 1;
-		mmr_t	overflow0_vc0_credit          : 1;
-		mmr_t	overflow1_vc0_credit          : 1;
-		mmr_t	overflow2_vc0_credit          : 1;
-		mmr_t	overflow0_vc2_credit          : 1;
-		mmr_t	overflow1_vc2_credit          : 1;
-		mmr_t	overflow2_vc2_credit          : 1;
-		mmr_t	overflow_pi_fifo_debit0       : 1;
-		mmr_t	overflow_pi_fifo_debit2       : 1;
-		mmr_t	overflow_iilb_fifo_debit0     : 1;
-		mmr_t	overflow_iilb_fifo_debit2     : 1;
-		mmr_t	overflow_md_fifo_debit0       : 1;
-		mmr_t	overflow_md_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit0       : 1;
-		mmr_t	overflow_ni_fifo_debit1       : 1;
-		mmr_t	overflow_ni_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit3       : 1;
-		mmr_t	overflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	overflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	overflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	overflow_md_fifo_vc0_pop      : 1;
-		mmr_t	overflow_md_fifo_vc2_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc0_push     : 1;
-		mmr_t	overflow_pi_fifo_vc2_push     : 1;
-		mmr_t	overflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	overflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	overflow_md_fifo_vc0_push     : 1;
-		mmr_t	overflow_md_fifo_vc2_push     : 1;
-		mmr_t	overflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	overflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	overflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	overflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	overflow_md_fifo_vc0_credit   : 1;
-		mmr_t	overflow_md_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	tail_timeout_fifo02_vc0       : 1;
-		mmr_t	tail_timeout_fifo02_vc2       : 1;
-		mmr_t	tail_timeout_fifo13_vc1       : 1;
-		mmr_t	tail_timeout_fifo13_vc3       : 1;
-		mmr_t	tail_timeout_ni_vc0           : 1;
-		mmr_t	tail_timeout_ni_vc1           : 1;
-		mmr_t	tail_timeout_ni_vc2           : 1;
-		mmr_t	tail_timeout_ni_vc3           : 1;
-	} sh_ni0_error_summary_1_s;
-} sh_ni0_error_summary_1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_ERROR_SUMMARY_2"                   */
-/*                       ni0  Error Summary Bits                        */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_summary_2_u {
-	mmr_t	sh_ni0_error_summary_2_regval;
-	struct {
-		mmr_t	illegal_vcni                   : 1;
-		mmr_t	illegal_vcpi                   : 1;
-		mmr_t	illegal_vcmd                   : 1;
-		mmr_t	illegal_vciilb                 : 1;
-		mmr_t	underflow_fifo02_vc0_pop       : 1;
-		mmr_t	underflow_fifo02_vc2_pop       : 1;
-		mmr_t	underflow_fifo13_vc1_pop       : 1;
-		mmr_t	underflow_fifo13_vc3_pop       : 1;
-		mmr_t	underflow_fifo02_vc0_push      : 1;
-		mmr_t	underflow_fifo02_vc2_push      : 1;
-		mmr_t	underflow_fifo13_vc1_push      : 1;
-		mmr_t	underflow_fifo13_vc3_push      : 1;
-		mmr_t	underflow_fifo02_vc0_credit    : 1;
-		mmr_t	underflow_fifo02_vc2_credit    : 1;
-		mmr_t	underflow_fifo13_vc0_credit    : 1;
-		mmr_t	underflow_fifo13_vc2_credit    : 1;
-		mmr_t	underflow0_vc0_credit          : 1;
-		mmr_t	underflow1_vc0_credit          : 1;
-		mmr_t	underflow2_vc0_credit          : 1;
-		mmr_t	underflow0_vc2_credit          : 1;
-		mmr_t	underflow1_vc2_credit          : 1;
-		mmr_t	underflow2_vc2_credit          : 1;
-		mmr_t	reserved_0                     : 10;
-		mmr_t	underflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	underflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	underflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	underflow_md_fifo_vc0_pop      : 1;
-		mmr_t	underflow_md_fifo_vc2_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc0_push     : 1;
-		mmr_t	underflow_pi_fifo_vc2_push     : 1;
-		mmr_t	underflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	underflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	underflow_md_fifo_vc0_push     : 1;
-		mmr_t	underflow_md_fifo_vc2_push     : 1;
-		mmr_t	underflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	underflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	underflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	underflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	underflow_md_fifo_vc0_credit   : 1;
-		mmr_t	underflow_md_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	llp_deadlock_vc0               : 1;
-		mmr_t	llp_deadlock_vc1               : 1;
-		mmr_t	llp_deadlock_vc2               : 1;
-		mmr_t	llp_deadlock_vc3               : 1;
-		mmr_t	chiplet_nomatch                : 1;
-		mmr_t	lut_read_error                 : 1;
-		mmr_t	retry_timeout_error            : 1;
-		mmr_t	reserved_1                     : 1;
-	} sh_ni0_error_summary_2_s;
-} sh_ni0_error_summary_2_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_ERROR_OVERFLOW_1"                  */
-/*                       ni0  Error Overflow Bits                       */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_overflow_1_u {
-	mmr_t	sh_ni0_error_overflow_1_regval;
-	struct {
-		mmr_t	overflow_fifo02_debit0        : 1;
-		mmr_t	overflow_fifo02_debit2        : 1;
-		mmr_t	overflow_fifo13_debit0        : 1;
-		mmr_t	overflow_fifo13_debit2        : 1;
-		mmr_t	overflow_fifo02_vc0_pop       : 1;
-		mmr_t	overflow_fifo02_vc2_pop       : 1;
-		mmr_t	overflow_fifo13_vc1_pop       : 1;
-		mmr_t	overflow_fifo13_vc3_pop       : 1;
-		mmr_t	overflow_fifo02_vc0_push      : 1;
-		mmr_t	overflow_fifo02_vc2_push      : 1;
-		mmr_t	overflow_fifo13_vc1_push      : 1;
-		mmr_t	overflow_fifo13_vc3_push      : 1;
-		mmr_t	overflow_fifo02_vc0_credit    : 1;
-		mmr_t	overflow_fifo02_vc2_credit    : 1;
-		mmr_t	overflow_fifo13_vc0_credit    : 1;
-		mmr_t	overflow_fifo13_vc2_credit    : 1;
-		mmr_t	overflow0_vc0_credit          : 1;
-		mmr_t	overflow1_vc0_credit          : 1;
-		mmr_t	overflow2_vc0_credit          : 1;
-		mmr_t	overflow0_vc2_credit          : 1;
-		mmr_t	overflow1_vc2_credit          : 1;
-		mmr_t	overflow2_vc2_credit          : 1;
-		mmr_t	overflow_pi_fifo_debit0       : 1;
-		mmr_t	overflow_pi_fifo_debit2       : 1;
-		mmr_t	overflow_iilb_fifo_debit0     : 1;
-		mmr_t	overflow_iilb_fifo_debit2     : 1;
-		mmr_t	overflow_md_fifo_debit0       : 1;
-		mmr_t	overflow_md_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit0       : 1;
-		mmr_t	overflow_ni_fifo_debit1       : 1;
-		mmr_t	overflow_ni_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit3       : 1;
-		mmr_t	overflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	overflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	overflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	overflow_md_fifo_vc0_pop      : 1;
-		mmr_t	overflow_md_fifo_vc2_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc0_push     : 1;
-		mmr_t	overflow_pi_fifo_vc2_push     : 1;
-		mmr_t	overflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	overflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	overflow_md_fifo_vc0_push     : 1;
-		mmr_t	overflow_md_fifo_vc2_push     : 1;
-		mmr_t	overflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	overflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	overflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	overflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	overflow_md_fifo_vc0_credit   : 1;
-		mmr_t	overflow_md_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	tail_timeout_fifo02_vc0       : 1;
-		mmr_t	tail_timeout_fifo02_vc2       : 1;
-		mmr_t	tail_timeout_fifo13_vc1       : 1;
-		mmr_t	tail_timeout_fifo13_vc3       : 1;
-		mmr_t	tail_timeout_ni_vc0           : 1;
-		mmr_t	tail_timeout_ni_vc1           : 1;
-		mmr_t	tail_timeout_ni_vc2           : 1;
-		mmr_t	tail_timeout_ni_vc3           : 1;
-	} sh_ni0_error_overflow_1_s;
-} sh_ni0_error_overflow_1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI0_ERROR_OVERFLOW_2"                  */
-/*                       ni0  Error Overflow Bits                       */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_overflow_2_u {
-	mmr_t	sh_ni0_error_overflow_2_regval;
-	struct {
-		mmr_t	illegal_vcni                   : 1;
-		mmr_t	illegal_vcpi                   : 1;
-		mmr_t	illegal_vcmd                   : 1;
-		mmr_t	illegal_vciilb                 : 1;
-		mmr_t	underflow_fifo02_vc0_pop       : 1;
-		mmr_t	underflow_fifo02_vc2_pop       : 1;
-		mmr_t	underflow_fifo13_vc1_pop       : 1;
-		mmr_t	underflow_fifo13_vc3_pop       : 1;
-		mmr_t	underflow_fifo02_vc0_push      : 1;
-		mmr_t	underflow_fifo02_vc2_push      : 1;
-		mmr_t	underflow_fifo13_vc1_push      : 1;
-		mmr_t	underflow_fifo13_vc3_push      : 1;
-		mmr_t	underflow_fifo02_vc0_credit    : 1;
-		mmr_t	underflow_fifo02_vc2_credit    : 1;
-		mmr_t	underflow_fifo13_vc0_credit    : 1;
-		mmr_t	underflow_fifo13_vc2_credit    : 1;
-		mmr_t	underflow0_vc0_credit          : 1;
-		mmr_t	underflow1_vc0_credit          : 1;
-		mmr_t	underflow2_vc0_credit          : 1;
-		mmr_t	underflow0_vc2_credit          : 1;
-		mmr_t	underflow1_vc2_credit          : 1;
-		mmr_t	underflow2_vc2_credit          : 1;
-		mmr_t	reserved_0                     : 10;
-		mmr_t	underflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	underflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	underflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	underflow_md_fifo_vc0_pop      : 1;
-		mmr_t	underflow_md_fifo_vc2_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc0_push     : 1;
-		mmr_t	underflow_pi_fifo_vc2_push     : 1;
-		mmr_t	underflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	underflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	underflow_md_fifo_vc0_push     : 1;
-		mmr_t	underflow_md_fifo_vc2_push     : 1;
-		mmr_t	underflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	underflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	underflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	underflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	underflow_md_fifo_vc0_credit   : 1;
-		mmr_t	underflow_md_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	llp_deadlock_vc0               : 1;
-		mmr_t	llp_deadlock_vc1               : 1;
-		mmr_t	llp_deadlock_vc2               : 1;
-		mmr_t	llp_deadlock_vc3               : 1;
-		mmr_t	chiplet_nomatch                : 1;
-		mmr_t	lut_read_error                 : 1;
-		mmr_t	retry_timeout_error            : 1;
-		mmr_t	reserved_1                     : 1;
-	} sh_ni0_error_overflow_2_s;
-} sh_ni0_error_overflow_2_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_ERROR_MASK_1"                    */
-/*                         ni0  Error Mask Bits                         */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_mask_1_u {
-	mmr_t	sh_ni0_error_mask_1_regval;
-	struct {
-		mmr_t	overflow_fifo02_debit0        : 1;
-		mmr_t	overflow_fifo02_debit2        : 1;
-		mmr_t	overflow_fifo13_debit0        : 1;
-		mmr_t	overflow_fifo13_debit2        : 1;
-		mmr_t	overflow_fifo02_vc0_pop       : 1;
-		mmr_t	overflow_fifo02_vc2_pop       : 1;
-		mmr_t	overflow_fifo13_vc1_pop       : 1;
-		mmr_t	overflow_fifo13_vc3_pop       : 1;
-		mmr_t	overflow_fifo02_vc0_push      : 1;
-		mmr_t	overflow_fifo02_vc2_push      : 1;
-		mmr_t	overflow_fifo13_vc1_push      : 1;
-		mmr_t	overflow_fifo13_vc3_push      : 1;
-		mmr_t	overflow_fifo02_vc0_credit    : 1;
-		mmr_t	overflow_fifo02_vc2_credit    : 1;
-		mmr_t	overflow_fifo13_vc0_credit    : 1;
-		mmr_t	overflow_fifo13_vc2_credit    : 1;
-		mmr_t	overflow0_vc0_credit          : 1;
-		mmr_t	overflow1_vc0_credit          : 1;
-		mmr_t	overflow2_vc0_credit          : 1;
-		mmr_t	overflow0_vc2_credit          : 1;
-		mmr_t	overflow1_vc2_credit          : 1;
-		mmr_t	overflow2_vc2_credit          : 1;
-		mmr_t	overflow_pi_fifo_debit0       : 1;
-		mmr_t	overflow_pi_fifo_debit2       : 1;
-		mmr_t	overflow_iilb_fifo_debit0     : 1;
-		mmr_t	overflow_iilb_fifo_debit2     : 1;
-		mmr_t	overflow_md_fifo_debit0       : 1;
-		mmr_t	overflow_md_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit0       : 1;
-		mmr_t	overflow_ni_fifo_debit1       : 1;
-		mmr_t	overflow_ni_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit3       : 1;
-		mmr_t	overflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	overflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	overflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	overflow_md_fifo_vc0_pop      : 1;
-		mmr_t	overflow_md_fifo_vc2_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc0_push     : 1;
-		mmr_t	overflow_pi_fifo_vc2_push     : 1;
-		mmr_t	overflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	overflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	overflow_md_fifo_vc0_push     : 1;
-		mmr_t	overflow_md_fifo_vc2_push     : 1;
-		mmr_t	overflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	overflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	overflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	overflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	overflow_md_fifo_vc0_credit   : 1;
-		mmr_t	overflow_md_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	tail_timeout_fifo02_vc0       : 1;
-		mmr_t	tail_timeout_fifo02_vc2       : 1;
-		mmr_t	tail_timeout_fifo13_vc1       : 1;
-		mmr_t	tail_timeout_fifo13_vc3       : 1;
-		mmr_t	tail_timeout_ni_vc0           : 1;
-		mmr_t	tail_timeout_ni_vc1           : 1;
-		mmr_t	tail_timeout_ni_vc2           : 1;
-		mmr_t	tail_timeout_ni_vc3           : 1;
-	} sh_ni0_error_mask_1_s;
-} sh_ni0_error_mask_1_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI0_ERROR_MASK_2"                    */
-/*                         ni0  Error Mask Bits                         */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_mask_2_u {
-	mmr_t	sh_ni0_error_mask_2_regval;
-	struct {
-		mmr_t	illegal_vcni                   : 1;
-		mmr_t	illegal_vcpi                   : 1;
-		mmr_t	illegal_vcmd                   : 1;
-		mmr_t	illegal_vciilb                 : 1;
-		mmr_t	underflow_fifo02_vc0_pop       : 1;
-		mmr_t	underflow_fifo02_vc2_pop       : 1;
-		mmr_t	underflow_fifo13_vc1_pop       : 1;
-		mmr_t	underflow_fifo13_vc3_pop       : 1;
-		mmr_t	underflow_fifo02_vc0_push      : 1;
-		mmr_t	underflow_fifo02_vc2_push      : 1;
-		mmr_t	underflow_fifo13_vc1_push      : 1;
-		mmr_t	underflow_fifo13_vc3_push      : 1;
-		mmr_t	underflow_fifo02_vc0_credit    : 1;
-		mmr_t	underflow_fifo02_vc2_credit    : 1;
-		mmr_t	underflow_fifo13_vc0_credit    : 1;
-		mmr_t	underflow_fifo13_vc2_credit    : 1;
-		mmr_t	underflow0_vc0_credit          : 1;
-		mmr_t	underflow1_vc0_credit          : 1;
-		mmr_t	underflow2_vc0_credit          : 1;
-		mmr_t	underflow0_vc2_credit          : 1;
-		mmr_t	underflow1_vc2_credit          : 1;
-		mmr_t	underflow2_vc2_credit          : 1;
-		mmr_t	reserved_0                     : 10;
-		mmr_t	underflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	underflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	underflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	underflow_md_fifo_vc0_pop      : 1;
-		mmr_t	underflow_md_fifo_vc2_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc0_push     : 1;
-		mmr_t	underflow_pi_fifo_vc2_push     : 1;
-		mmr_t	underflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	underflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	underflow_md_fifo_vc0_push     : 1;
-		mmr_t	underflow_md_fifo_vc2_push     : 1;
-		mmr_t	underflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	underflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	underflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	underflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	underflow_md_fifo_vc0_credit   : 1;
-		mmr_t	underflow_md_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	llp_deadlock_vc0               : 1;
-		mmr_t	llp_deadlock_vc1               : 1;
-		mmr_t	llp_deadlock_vc2               : 1;
-		mmr_t	llp_deadlock_vc3               : 1;
-		mmr_t	chiplet_nomatch                : 1;
-		mmr_t	lut_read_error                 : 1;
-		mmr_t	retry_timeout_error            : 1;
-		mmr_t	reserved_1                     : 1;
-	} sh_ni0_error_mask_2_s;
-} sh_ni0_error_mask_2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_FIRST_ERROR_1"                    */
-/*                        ni0  First Error Bits                         */
-/* ==================================================================== */
-
-typedef union sh_ni0_first_error_1_u {
-	mmr_t	sh_ni0_first_error_1_regval;
-	struct {
-		mmr_t	overflow_fifo02_debit0        : 1;
-		mmr_t	overflow_fifo02_debit2        : 1;
-		mmr_t	overflow_fifo13_debit0        : 1;
-		mmr_t	overflow_fifo13_debit2        : 1;
-		mmr_t	overflow_fifo02_vc0_pop       : 1;
-		mmr_t	overflow_fifo02_vc2_pop       : 1;
-		mmr_t	overflow_fifo13_vc1_pop       : 1;
-		mmr_t	overflow_fifo13_vc3_pop       : 1;
-		mmr_t	overflow_fifo02_vc0_push      : 1;
-		mmr_t	overflow_fifo02_vc2_push      : 1;
-		mmr_t	overflow_fifo13_vc1_push      : 1;
-		mmr_t	overflow_fifo13_vc3_push      : 1;
-		mmr_t	overflow_fifo02_vc0_credit    : 1;
-		mmr_t	overflow_fifo02_vc2_credit    : 1;
-		mmr_t	overflow_fifo13_vc0_credit    : 1;
-		mmr_t	overflow_fifo13_vc2_credit    : 1;
-		mmr_t	overflow0_vc0_credit          : 1;
-		mmr_t	overflow1_vc0_credit          : 1;
-		mmr_t	overflow2_vc0_credit          : 1;
-		mmr_t	overflow0_vc2_credit          : 1;
-		mmr_t	overflow1_vc2_credit          : 1;
-		mmr_t	overflow2_vc2_credit          : 1;
-		mmr_t	overflow_pi_fifo_debit0       : 1;
-		mmr_t	overflow_pi_fifo_debit2       : 1;
-		mmr_t	overflow_iilb_fifo_debit0     : 1;
-		mmr_t	overflow_iilb_fifo_debit2     : 1;
-		mmr_t	overflow_md_fifo_debit0       : 1;
-		mmr_t	overflow_md_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit0       : 1;
-		mmr_t	overflow_ni_fifo_debit1       : 1;
-		mmr_t	overflow_ni_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit3       : 1;
-		mmr_t	overflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	overflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	overflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	overflow_md_fifo_vc0_pop      : 1;
-		mmr_t	overflow_md_fifo_vc2_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc0_push     : 1;
-		mmr_t	overflow_pi_fifo_vc2_push     : 1;
-		mmr_t	overflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	overflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	overflow_md_fifo_vc0_push     : 1;
-		mmr_t	overflow_md_fifo_vc2_push     : 1;
-		mmr_t	overflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	overflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	overflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	overflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	overflow_md_fifo_vc0_credit   : 1;
-		mmr_t	overflow_md_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	tail_timeout_fifo02_vc0       : 1;
-		mmr_t	tail_timeout_fifo02_vc2       : 1;
-		mmr_t	tail_timeout_fifo13_vc1       : 1;
-		mmr_t	tail_timeout_fifo13_vc3       : 1;
-		mmr_t	tail_timeout_ni_vc0           : 1;
-		mmr_t	tail_timeout_ni_vc1           : 1;
-		mmr_t	tail_timeout_ni_vc2           : 1;
-		mmr_t	tail_timeout_ni_vc3           : 1;
-	} sh_ni0_first_error_1_s;
-} sh_ni0_first_error_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_FIRST_ERROR_2"                    */
-/*                         ni0 First Error Bits                         */
-/* ==================================================================== */
-
-typedef union sh_ni0_first_error_2_u {
-	mmr_t	sh_ni0_first_error_2_regval;
-	struct {
-		mmr_t	illegal_vcni                   : 1;
-		mmr_t	illegal_vcpi                   : 1;
-		mmr_t	illegal_vcmd                   : 1;
-		mmr_t	illegal_vciilb                 : 1;
-		mmr_t	underflow_fifo02_vc0_pop       : 1;
-		mmr_t	underflow_fifo02_vc2_pop       : 1;
-		mmr_t	underflow_fifo13_vc1_pop       : 1;
-		mmr_t	underflow_fifo13_vc3_pop       : 1;
-		mmr_t	underflow_fifo02_vc0_push      : 1;
-		mmr_t	underflow_fifo02_vc2_push      : 1;
-		mmr_t	underflow_fifo13_vc1_push      : 1;
-		mmr_t	underflow_fifo13_vc3_push      : 1;
-		mmr_t	underflow_fifo02_vc0_credit    : 1;
-		mmr_t	underflow_fifo02_vc2_credit    : 1;
-		mmr_t	underflow_fifo13_vc0_credit    : 1;
-		mmr_t	underflow_fifo13_vc2_credit    : 1;
-		mmr_t	underflow0_vc0_credit          : 1;
-		mmr_t	underflow1_vc0_credit          : 1;
-		mmr_t	underflow2_vc0_credit          : 1;
-		mmr_t	underflow0_vc2_credit          : 1;
-		mmr_t	underflow1_vc2_credit          : 1;
-		mmr_t	underflow2_vc2_credit          : 1;
-		mmr_t	reserved_0                     : 10;
-		mmr_t	underflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	underflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	underflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	underflow_md_fifo_vc0_pop      : 1;
-		mmr_t	underflow_md_fifo_vc2_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc0_push     : 1;
-		mmr_t	underflow_pi_fifo_vc2_push     : 1;
-		mmr_t	underflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	underflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	underflow_md_fifo_vc0_push     : 1;
-		mmr_t	underflow_md_fifo_vc2_push     : 1;
-		mmr_t	underflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	underflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	underflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	underflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	underflow_md_fifo_vc0_credit   : 1;
-		mmr_t	underflow_md_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	llp_deadlock_vc0               : 1;
-		mmr_t	llp_deadlock_vc1               : 1;
-		mmr_t	llp_deadlock_vc2               : 1;
-		mmr_t	llp_deadlock_vc3               : 1;
-		mmr_t	chiplet_nomatch                : 1;
-		mmr_t	lut_read_error                 : 1;
-		mmr_t	retry_timeout_error            : 1;
-		mmr_t	reserved_1                     : 1;
-	} sh_ni0_first_error_2_s;
-} sh_ni0_first_error_2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_ERROR_DETAIL_1"                   */
-/*                ni0 Chiplet no match header bits 63:0                 */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_detail_1_u {
-	mmr_t	sh_ni0_error_detail_1_regval;
-	struct {
-		mmr_t	header      : 64;
-	} sh_ni0_error_detail_1_s;
-} sh_ni0_error_detail_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_ERROR_DETAIL_2"                   */
-/*               ni0 Chiplet no match header bits 127:64                */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_detail_2_u {
-	mmr_t	sh_ni0_error_detail_2_regval;
-	struct {
-		mmr_t	header      : 64;
-	} sh_ni0_error_detail_2_s;
-} sh_ni0_error_detail_2_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_ERROR_SUMMARY_1"                   */
-/*                       ni1  Error Summary Bits                        */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_summary_1_u {
-	mmr_t	sh_ni1_error_summary_1_regval;
-	struct {
-		mmr_t	overflow_fifo02_debit0        : 1;
-		mmr_t	overflow_fifo02_debit2        : 1;
-		mmr_t	overflow_fifo13_debit0        : 1;
-		mmr_t	overflow_fifo13_debit2        : 1;
-		mmr_t	overflow_fifo02_vc0_pop       : 1;
-		mmr_t	overflow_fifo02_vc2_pop       : 1;
-		mmr_t	overflow_fifo13_vc1_pop       : 1;
-		mmr_t	overflow_fifo13_vc3_pop       : 1;
-		mmr_t	overflow_fifo02_vc0_push      : 1;
-		mmr_t	overflow_fifo02_vc2_push      : 1;
-		mmr_t	overflow_fifo13_vc1_push      : 1;
-		mmr_t	overflow_fifo13_vc3_push      : 1;
-		mmr_t	overflow_fifo02_vc0_credit    : 1;
-		mmr_t	overflow_fifo02_vc2_credit    : 1;
-		mmr_t	overflow_fifo13_vc0_credit    : 1;
-		mmr_t	overflow_fifo13_vc2_credit    : 1;
-		mmr_t	overflow0_vc0_credit          : 1;
-		mmr_t	overflow1_vc0_credit          : 1;
-		mmr_t	overflow2_vc0_credit          : 1;
-		mmr_t	overflow0_vc2_credit          : 1;
-		mmr_t	overflow1_vc2_credit          : 1;
-		mmr_t	overflow2_vc2_credit          : 1;
-		mmr_t	overflow_pi_fifo_debit0       : 1;
-		mmr_t	overflow_pi_fifo_debit2       : 1;
-		mmr_t	overflow_iilb_fifo_debit0     : 1;
-		mmr_t	overflow_iilb_fifo_debit2     : 1;
-		mmr_t	overflow_md_fifo_debit0       : 1;
-		mmr_t	overflow_md_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit0       : 1;
-		mmr_t	overflow_ni_fifo_debit1       : 1;
-		mmr_t	overflow_ni_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit3       : 1;
-		mmr_t	overflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	overflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	overflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	overflow_md_fifo_vc0_pop      : 1;
-		mmr_t	overflow_md_fifo_vc2_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc0_push     : 1;
-		mmr_t	overflow_pi_fifo_vc2_push     : 1;
-		mmr_t	overflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	overflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	overflow_md_fifo_vc0_push     : 1;
-		mmr_t	overflow_md_fifo_vc2_push     : 1;
-		mmr_t	overflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	overflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	overflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	overflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	overflow_md_fifo_vc0_credit   : 1;
-		mmr_t	overflow_md_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	tail_timeout_fifo02_vc0       : 1;
-		mmr_t	tail_timeout_fifo02_vc2       : 1;
-		mmr_t	tail_timeout_fifo13_vc1       : 1;
-		mmr_t	tail_timeout_fifo13_vc3       : 1;
-		mmr_t	tail_timeout_ni_vc0           : 1;
-		mmr_t	tail_timeout_ni_vc1           : 1;
-		mmr_t	tail_timeout_ni_vc2           : 1;
-		mmr_t	tail_timeout_ni_vc3           : 1;
-	} sh_ni1_error_summary_1_s;
-} sh_ni1_error_summary_1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_ERROR_SUMMARY_2"                   */
-/*                       ni1  Error Summary Bits                        */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_summary_2_u {
-	mmr_t	sh_ni1_error_summary_2_regval;
-	struct {
-		mmr_t	illegal_vcni                   : 1;
-		mmr_t	illegal_vcpi                   : 1;
-		mmr_t	illegal_vcmd                   : 1;
-		mmr_t	illegal_vciilb                 : 1;
-		mmr_t	underflow_fifo02_vc0_pop       : 1;
-		mmr_t	underflow_fifo02_vc2_pop       : 1;
-		mmr_t	underflow_fifo13_vc1_pop       : 1;
-		mmr_t	underflow_fifo13_vc3_pop       : 1;
-		mmr_t	underflow_fifo02_vc0_push      : 1;
-		mmr_t	underflow_fifo02_vc2_push      : 1;
-		mmr_t	underflow_fifo13_vc1_push      : 1;
-		mmr_t	underflow_fifo13_vc3_push      : 1;
-		mmr_t	underflow_fifo02_vc0_credit    : 1;
-		mmr_t	underflow_fifo02_vc2_credit    : 1;
-		mmr_t	underflow_fifo13_vc0_credit    : 1;
-		mmr_t	underflow_fifo13_vc2_credit    : 1;
-		mmr_t	underflow0_vc0_credit          : 1;
-		mmr_t	underflow1_vc0_credit          : 1;
-		mmr_t	underflow2_vc0_credit          : 1;
-		mmr_t	underflow0_vc2_credit          : 1;
-		mmr_t	underflow1_vc2_credit          : 1;
-		mmr_t	underflow2_vc2_credit          : 1;
-		mmr_t	reserved_0                     : 10;
-		mmr_t	underflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	underflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	underflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	underflow_md_fifo_vc0_pop      : 1;
-		mmr_t	underflow_md_fifo_vc2_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc0_push     : 1;
-		mmr_t	underflow_pi_fifo_vc2_push     : 1;
-		mmr_t	underflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	underflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	underflow_md_fifo_vc0_push     : 1;
-		mmr_t	underflow_md_fifo_vc2_push     : 1;
-		mmr_t	underflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	underflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	underflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	underflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	underflow_md_fifo_vc0_credit   : 1;
-		mmr_t	underflow_md_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	llp_deadlock_vc0               : 1;
-		mmr_t	llp_deadlock_vc1               : 1;
-		mmr_t	llp_deadlock_vc2               : 1;
-		mmr_t	llp_deadlock_vc3               : 1;
-		mmr_t	chiplet_nomatch                : 1;
-		mmr_t	lut_read_error                 : 1;
-		mmr_t	retry_timeout_error            : 1;
-		mmr_t	reserved_1                     : 1;
-	} sh_ni1_error_summary_2_s;
-} sh_ni1_error_summary_2_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_ERROR_OVERFLOW_1"                  */
-/*                       ni1  Error Overflow Bits                       */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_overflow_1_u {
-	mmr_t	sh_ni1_error_overflow_1_regval;
-	struct {
-		mmr_t	overflow_fifo02_debit0        : 1;
-		mmr_t	overflow_fifo02_debit2        : 1;
-		mmr_t	overflow_fifo13_debit0        : 1;
-		mmr_t	overflow_fifo13_debit2        : 1;
-		mmr_t	overflow_fifo02_vc0_pop       : 1;
-		mmr_t	overflow_fifo02_vc2_pop       : 1;
-		mmr_t	overflow_fifo13_vc1_pop       : 1;
-		mmr_t	overflow_fifo13_vc3_pop       : 1;
-		mmr_t	overflow_fifo02_vc0_push      : 1;
-		mmr_t	overflow_fifo02_vc2_push      : 1;
-		mmr_t	overflow_fifo13_vc1_push      : 1;
-		mmr_t	overflow_fifo13_vc3_push      : 1;
-		mmr_t	overflow_fifo02_vc0_credit    : 1;
-		mmr_t	overflow_fifo02_vc2_credit    : 1;
-		mmr_t	overflow_fifo13_vc0_credit    : 1;
-		mmr_t	overflow_fifo13_vc2_credit    : 1;
-		mmr_t	overflow0_vc0_credit          : 1;
-		mmr_t	overflow1_vc0_credit          : 1;
-		mmr_t	overflow2_vc0_credit          : 1;
-		mmr_t	overflow0_vc2_credit          : 1;
-		mmr_t	overflow1_vc2_credit          : 1;
-		mmr_t	overflow2_vc2_credit          : 1;
-		mmr_t	overflow_pi_fifo_debit0       : 1;
-		mmr_t	overflow_pi_fifo_debit2       : 1;
-		mmr_t	overflow_iilb_fifo_debit0     : 1;
-		mmr_t	overflow_iilb_fifo_debit2     : 1;
-		mmr_t	overflow_md_fifo_debit0       : 1;
-		mmr_t	overflow_md_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit0       : 1;
-		mmr_t	overflow_ni_fifo_debit1       : 1;
-		mmr_t	overflow_ni_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit3       : 1;
-		mmr_t	overflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	overflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	overflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	overflow_md_fifo_vc0_pop      : 1;
-		mmr_t	overflow_md_fifo_vc2_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc0_push     : 1;
-		mmr_t	overflow_pi_fifo_vc2_push     : 1;
-		mmr_t	overflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	overflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	overflow_md_fifo_vc0_push     : 1;
-		mmr_t	overflow_md_fifo_vc2_push     : 1;
-		mmr_t	overflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	overflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	overflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	overflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	overflow_md_fifo_vc0_credit   : 1;
-		mmr_t	overflow_md_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	tail_timeout_fifo02_vc0       : 1;
-		mmr_t	tail_timeout_fifo02_vc2       : 1;
-		mmr_t	tail_timeout_fifo13_vc1       : 1;
-		mmr_t	tail_timeout_fifo13_vc3       : 1;
-		mmr_t	tail_timeout_ni_vc0           : 1;
-		mmr_t	tail_timeout_ni_vc1           : 1;
-		mmr_t	tail_timeout_ni_vc2           : 1;
-		mmr_t	tail_timeout_ni_vc3           : 1;
-	} sh_ni1_error_overflow_1_s;
-} sh_ni1_error_overflow_1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_NI1_ERROR_OVERFLOW_2"                  */
-/*                       ni1  Error Overflow Bits                       */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_overflow_2_u {
-	mmr_t	sh_ni1_error_overflow_2_regval;
-	struct {
-		mmr_t	illegal_vcni                   : 1;
-		mmr_t	illegal_vcpi                   : 1;
-		mmr_t	illegal_vcmd                   : 1;
-		mmr_t	illegal_vciilb                 : 1;
-		mmr_t	underflow_fifo02_vc0_pop       : 1;
-		mmr_t	underflow_fifo02_vc2_pop       : 1;
-		mmr_t	underflow_fifo13_vc1_pop       : 1;
-		mmr_t	underflow_fifo13_vc3_pop       : 1;
-		mmr_t	underflow_fifo02_vc0_push      : 1;
-		mmr_t	underflow_fifo02_vc2_push      : 1;
-		mmr_t	underflow_fifo13_vc1_push      : 1;
-		mmr_t	underflow_fifo13_vc3_push      : 1;
-		mmr_t	underflow_fifo02_vc0_credit    : 1;
-		mmr_t	underflow_fifo02_vc2_credit    : 1;
-		mmr_t	underflow_fifo13_vc0_credit    : 1;
-		mmr_t	underflow_fifo13_vc2_credit    : 1;
-		mmr_t	underflow0_vc0_credit          : 1;
-		mmr_t	underflow1_vc0_credit          : 1;
-		mmr_t	underflow2_vc0_credit          : 1;
-		mmr_t	underflow0_vc2_credit          : 1;
-		mmr_t	underflow1_vc2_credit          : 1;
-		mmr_t	underflow2_vc2_credit          : 1;
-		mmr_t	reserved_0                     : 10;
-		mmr_t	underflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	underflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	underflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	underflow_md_fifo_vc0_pop      : 1;
-		mmr_t	underflow_md_fifo_vc2_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc0_push     : 1;
-		mmr_t	underflow_pi_fifo_vc2_push     : 1;
-		mmr_t	underflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	underflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	underflow_md_fifo_vc0_push     : 1;
-		mmr_t	underflow_md_fifo_vc2_push     : 1;
-		mmr_t	underflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	underflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	underflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	underflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	underflow_md_fifo_vc0_credit   : 1;
-		mmr_t	underflow_md_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	llp_deadlock_vc0               : 1;
-		mmr_t	llp_deadlock_vc1               : 1;
-		mmr_t	llp_deadlock_vc2               : 1;
-		mmr_t	llp_deadlock_vc3               : 1;
-		mmr_t	chiplet_nomatch                : 1;
-		mmr_t	lut_read_error                 : 1;
-		mmr_t	retry_timeout_error            : 1;
-		mmr_t	reserved_1                     : 1;
-	} sh_ni1_error_overflow_2_s;
-} sh_ni1_error_overflow_2_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_ERROR_MASK_1"                    */
-/*                         ni1  Error Mask Bits                         */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_mask_1_u {
-	mmr_t	sh_ni1_error_mask_1_regval;
-	struct {
-		mmr_t	overflow_fifo02_debit0        : 1;
-		mmr_t	overflow_fifo02_debit2        : 1;
-		mmr_t	overflow_fifo13_debit0        : 1;
-		mmr_t	overflow_fifo13_debit2        : 1;
-		mmr_t	overflow_fifo02_vc0_pop       : 1;
-		mmr_t	overflow_fifo02_vc2_pop       : 1;
-		mmr_t	overflow_fifo13_vc1_pop       : 1;
-		mmr_t	overflow_fifo13_vc3_pop       : 1;
-		mmr_t	overflow_fifo02_vc0_push      : 1;
-		mmr_t	overflow_fifo02_vc2_push      : 1;
-		mmr_t	overflow_fifo13_vc1_push      : 1;
-		mmr_t	overflow_fifo13_vc3_push      : 1;
-		mmr_t	overflow_fifo02_vc0_credit    : 1;
-		mmr_t	overflow_fifo02_vc2_credit    : 1;
-		mmr_t	overflow_fifo13_vc0_credit    : 1;
-		mmr_t	overflow_fifo13_vc2_credit    : 1;
-		mmr_t	overflow0_vc0_credit          : 1;
-		mmr_t	overflow1_vc0_credit          : 1;
-		mmr_t	overflow2_vc0_credit          : 1;
-		mmr_t	overflow0_vc2_credit          : 1;
-		mmr_t	overflow1_vc2_credit          : 1;
-		mmr_t	overflow2_vc2_credit          : 1;
-		mmr_t	overflow_pi_fifo_debit0       : 1;
-		mmr_t	overflow_pi_fifo_debit2       : 1;
-		mmr_t	overflow_iilb_fifo_debit0     : 1;
-		mmr_t	overflow_iilb_fifo_debit2     : 1;
-		mmr_t	overflow_md_fifo_debit0       : 1;
-		mmr_t	overflow_md_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit0       : 1;
-		mmr_t	overflow_ni_fifo_debit1       : 1;
-		mmr_t	overflow_ni_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit3       : 1;
-		mmr_t	overflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	overflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	overflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	overflow_md_fifo_vc0_pop      : 1;
-		mmr_t	overflow_md_fifo_vc2_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc0_push     : 1;
-		mmr_t	overflow_pi_fifo_vc2_push     : 1;
-		mmr_t	overflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	overflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	overflow_md_fifo_vc0_push     : 1;
-		mmr_t	overflow_md_fifo_vc2_push     : 1;
-		mmr_t	overflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	overflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	overflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	overflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	overflow_md_fifo_vc0_credit   : 1;
-		mmr_t	overflow_md_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	tail_timeout_fifo02_vc0       : 1;
-		mmr_t	tail_timeout_fifo02_vc2       : 1;
-		mmr_t	tail_timeout_fifo13_vc1       : 1;
-		mmr_t	tail_timeout_fifo13_vc3       : 1;
-		mmr_t	tail_timeout_ni_vc0           : 1;
-		mmr_t	tail_timeout_ni_vc1           : 1;
-		mmr_t	tail_timeout_ni_vc2           : 1;
-		mmr_t	tail_timeout_ni_vc3           : 1;
-	} sh_ni1_error_mask_1_s;
-} sh_ni1_error_mask_1_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_NI1_ERROR_MASK_2"                    */
-/*                         ni1  Error Mask Bits                         */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_mask_2_u {
-	mmr_t	sh_ni1_error_mask_2_regval;
-	struct {
-		mmr_t	illegal_vcni                   : 1;
-		mmr_t	illegal_vcpi                   : 1;
-		mmr_t	illegal_vcmd                   : 1;
-		mmr_t	illegal_vciilb                 : 1;
-		mmr_t	underflow_fifo02_vc0_pop       : 1;
-		mmr_t	underflow_fifo02_vc2_pop       : 1;
-		mmr_t	underflow_fifo13_vc1_pop       : 1;
-		mmr_t	underflow_fifo13_vc3_pop       : 1;
-		mmr_t	underflow_fifo02_vc0_push      : 1;
-		mmr_t	underflow_fifo02_vc2_push      : 1;
-		mmr_t	underflow_fifo13_vc1_push      : 1;
-		mmr_t	underflow_fifo13_vc3_push      : 1;
-		mmr_t	underflow_fifo02_vc0_credit    : 1;
-		mmr_t	underflow_fifo02_vc2_credit    : 1;
-		mmr_t	underflow_fifo13_vc0_credit    : 1;
-		mmr_t	underflow_fifo13_vc2_credit    : 1;
-		mmr_t	underflow0_vc0_credit          : 1;
-		mmr_t	underflow1_vc0_credit          : 1;
-		mmr_t	underflow2_vc0_credit          : 1;
-		mmr_t	underflow0_vc2_credit          : 1;
-		mmr_t	underflow1_vc2_credit          : 1;
-		mmr_t	underflow2_vc2_credit          : 1;
-		mmr_t	reserved_0                     : 10;
-		mmr_t	underflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	underflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	underflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	underflow_md_fifo_vc0_pop      : 1;
-		mmr_t	underflow_md_fifo_vc2_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc0_push     : 1;
-		mmr_t	underflow_pi_fifo_vc2_push     : 1;
-		mmr_t	underflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	underflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	underflow_md_fifo_vc0_push     : 1;
-		mmr_t	underflow_md_fifo_vc2_push     : 1;
-		mmr_t	underflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	underflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	underflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	underflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	underflow_md_fifo_vc0_credit   : 1;
-		mmr_t	underflow_md_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	llp_deadlock_vc0               : 1;
-		mmr_t	llp_deadlock_vc1               : 1;
-		mmr_t	llp_deadlock_vc2               : 1;
-		mmr_t	llp_deadlock_vc3               : 1;
-		mmr_t	chiplet_nomatch                : 1;
-		mmr_t	lut_read_error                 : 1;
-		mmr_t	retry_timeout_error            : 1;
-		mmr_t	reserved_1                     : 1;
-	} sh_ni1_error_mask_2_s;
-} sh_ni1_error_mask_2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_FIRST_ERROR_1"                    */
-/*                        ni1  First Error Bits                         */
-/* ==================================================================== */
-
-typedef union sh_ni1_first_error_1_u {
-	mmr_t	sh_ni1_first_error_1_regval;
-	struct {
-		mmr_t	overflow_fifo02_debit0        : 1;
-		mmr_t	overflow_fifo02_debit2        : 1;
-		mmr_t	overflow_fifo13_debit0        : 1;
-		mmr_t	overflow_fifo13_debit2        : 1;
-		mmr_t	overflow_fifo02_vc0_pop       : 1;
-		mmr_t	overflow_fifo02_vc2_pop       : 1;
-		mmr_t	overflow_fifo13_vc1_pop       : 1;
-		mmr_t	overflow_fifo13_vc3_pop       : 1;
-		mmr_t	overflow_fifo02_vc0_push      : 1;
-		mmr_t	overflow_fifo02_vc2_push      : 1;
-		mmr_t	overflow_fifo13_vc1_push      : 1;
-		mmr_t	overflow_fifo13_vc3_push      : 1;
-		mmr_t	overflow_fifo02_vc0_credit    : 1;
-		mmr_t	overflow_fifo02_vc2_credit    : 1;
-		mmr_t	overflow_fifo13_vc0_credit    : 1;
-		mmr_t	overflow_fifo13_vc2_credit    : 1;
-		mmr_t	overflow0_vc0_credit          : 1;
-		mmr_t	overflow1_vc0_credit          : 1;
-		mmr_t	overflow2_vc0_credit          : 1;
-		mmr_t	overflow0_vc2_credit          : 1;
-		mmr_t	overflow1_vc2_credit          : 1;
-		mmr_t	overflow2_vc2_credit          : 1;
-		mmr_t	overflow_pi_fifo_debit0       : 1;
-		mmr_t	overflow_pi_fifo_debit2       : 1;
-		mmr_t	overflow_iilb_fifo_debit0     : 1;
-		mmr_t	overflow_iilb_fifo_debit2     : 1;
-		mmr_t	overflow_md_fifo_debit0       : 1;
-		mmr_t	overflow_md_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit0       : 1;
-		mmr_t	overflow_ni_fifo_debit1       : 1;
-		mmr_t	overflow_ni_fifo_debit2       : 1;
-		mmr_t	overflow_ni_fifo_debit3       : 1;
-		mmr_t	overflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	overflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	overflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	overflow_md_fifo_vc0_pop      : 1;
-		mmr_t	overflow_md_fifo_vc2_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	overflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	overflow_pi_fifo_vc0_push     : 1;
-		mmr_t	overflow_pi_fifo_vc2_push     : 1;
-		mmr_t	overflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	overflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	overflow_md_fifo_vc0_push     : 1;
-		mmr_t	overflow_md_fifo_vc2_push     : 1;
-		mmr_t	overflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	overflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	overflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	overflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	overflow_md_fifo_vc0_credit   : 1;
-		mmr_t	overflow_md_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	overflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	tail_timeout_fifo02_vc0       : 1;
-		mmr_t	tail_timeout_fifo02_vc2       : 1;
-		mmr_t	tail_timeout_fifo13_vc1       : 1;
-		mmr_t	tail_timeout_fifo13_vc3       : 1;
-		mmr_t	tail_timeout_ni_vc0           : 1;
-		mmr_t	tail_timeout_ni_vc1           : 1;
-		mmr_t	tail_timeout_ni_vc2           : 1;
-		mmr_t	tail_timeout_ni_vc3           : 1;
-	} sh_ni1_first_error_1_s;
-} sh_ni1_first_error_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_FIRST_ERROR_2"                    */
-/*                         ni1 First Error Bits                         */
-/* ==================================================================== */
-
-typedef union sh_ni1_first_error_2_u {
-	mmr_t	sh_ni1_first_error_2_regval;
-	struct {
-		mmr_t	illegal_vcni                   : 1;
-		mmr_t	illegal_vcpi                   : 1;
-		mmr_t	illegal_vcmd                   : 1;
-		mmr_t	illegal_vciilb                 : 1;
-		mmr_t	underflow_fifo02_vc0_pop       : 1;
-		mmr_t	underflow_fifo02_vc2_pop       : 1;
-		mmr_t	underflow_fifo13_vc1_pop       : 1;
-		mmr_t	underflow_fifo13_vc3_pop       : 1;
-		mmr_t	underflow_fifo02_vc0_push      : 1;
-		mmr_t	underflow_fifo02_vc2_push      : 1;
-		mmr_t	underflow_fifo13_vc1_push      : 1;
-		mmr_t	underflow_fifo13_vc3_push      : 1;
-		mmr_t	underflow_fifo02_vc0_credit    : 1;
-		mmr_t	underflow_fifo02_vc2_credit    : 1;
-		mmr_t	underflow_fifo13_vc0_credit    : 1;
-		mmr_t	underflow_fifo13_vc2_credit    : 1;
-		mmr_t	underflow0_vc0_credit          : 1;
-		mmr_t	underflow1_vc0_credit          : 1;
-		mmr_t	underflow2_vc0_credit          : 1;
-		mmr_t	underflow0_vc2_credit          : 1;
-		mmr_t	underflow1_vc2_credit          : 1;
-		mmr_t	underflow2_vc2_credit          : 1;
-		mmr_t	reserved_0                     : 10;
-		mmr_t	underflow_pi_fifo_vc0_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc2_pop      : 1;
-		mmr_t	underflow_iilb_fifo_vc0_pop    : 1;
-		mmr_t	underflow_iilb_fifo_vc2_pop    : 1;
-		mmr_t	underflow_md_fifo_vc0_pop      : 1;
-		mmr_t	underflow_md_fifo_vc2_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc0_pop      : 1;
-		mmr_t	underflow_ni_fifo_vc2_pop      : 1;
-		mmr_t	underflow_pi_fifo_vc0_push     : 1;
-		mmr_t	underflow_pi_fifo_vc2_push     : 1;
-		mmr_t	underflow_iilb_fifo_vc0_push   : 1;
-		mmr_t	underflow_iilb_fifo_vc2_push   : 1;
-		mmr_t	underflow_md_fifo_vc0_push     : 1;
-		mmr_t	underflow_md_fifo_vc2_push     : 1;
-		mmr_t	underflow_pi_fifo_vc0_credit   : 1;
-		mmr_t	underflow_pi_fifo_vc2_credit   : 1;
-		mmr_t	underflow_iilb_fifo_vc0_credit : 1;
-		mmr_t	underflow_iilb_fifo_vc2_credit : 1;
-		mmr_t	underflow_md_fifo_vc0_credit   : 1;
-		mmr_t	underflow_md_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc0_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc1_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc2_credit   : 1;
-		mmr_t	underflow_ni_fifo_vc3_credit   : 1;
-		mmr_t	llp_deadlock_vc0               : 1;
-		mmr_t	llp_deadlock_vc1               : 1;
-		mmr_t	llp_deadlock_vc2               : 1;
-		mmr_t	llp_deadlock_vc3               : 1;
-		mmr_t	chiplet_nomatch                : 1;
-		mmr_t	lut_read_error                 : 1;
-		mmr_t	retry_timeout_error            : 1;
-		mmr_t	reserved_1                     : 1;
-	} sh_ni1_first_error_2_s;
-} sh_ni1_first_error_2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_ERROR_DETAIL_1"                   */
-/*                ni1 Chiplet no match header bits 63:0                 */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_detail_1_u {
-	mmr_t	sh_ni1_error_detail_1_regval;
-	struct {
-		mmr_t	header      : 64;
-	} sh_ni1_error_detail_1_s;
-} sh_ni1_error_detail_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_ERROR_DETAIL_2"                   */
-/*               ni1 Chiplet no match header bits 127:64                */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_detail_2_u {
-	mmr_t	sh_ni1_error_detail_2_regval;
-	struct {
-		mmr_t	header      : 64;
-	} sh_ni1_error_detail_2_s;
-} sh_ni1_error_detail_2_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_CORRECTED_DETAIL_1"                  */
-/*                       Corrected error details                        */
-/* ==================================================================== */
-
-typedef union sh_xn_corrected_detail_1_u {
-	mmr_t	sh_xn_corrected_detail_1_regval;
-	struct {
-		mmr_t	ecc0_syndrome : 8;
-		mmr_t	ecc0_wc       : 2;
-		mmr_t	ecc0_vc       : 2;
-		mmr_t	reserved_0    : 4;
-		mmr_t	ecc1_syndrome : 8;
-		mmr_t	ecc1_wc       : 2;
-		mmr_t	ecc1_vc       : 2;
-		mmr_t	reserved_1    : 4;
-		mmr_t	ecc2_syndrome : 8;
-		mmr_t	ecc2_wc       : 2;
-		mmr_t	ecc2_vc       : 2;
-		mmr_t	reserved_2    : 4;
-		mmr_t	ecc3_syndrome : 8;
-		mmr_t	ecc3_wc       : 2;
-		mmr_t	ecc3_vc       : 2;
-		mmr_t	reserved_3    : 4;
-	} sh_xn_corrected_detail_1_s;
-} sh_xn_corrected_detail_1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_CORRECTED_DETAIL_2"                  */
-/*                         Corrected error data                         */
-/* ==================================================================== */
-
-typedef union sh_xn_corrected_detail_2_u {
-	mmr_t	sh_xn_corrected_detail_2_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_corrected_detail_2_s;
-} sh_xn_corrected_detail_2_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_CORRECTED_DETAIL_3"                  */
-/*                       Corrected error header0                        */
-/* ==================================================================== */
-
-typedef union sh_xn_corrected_detail_3_u {
-	mmr_t	sh_xn_corrected_detail_3_regval;
-	struct {
-		mmr_t	header0     : 64;
-	} sh_xn_corrected_detail_3_s;
-} sh_xn_corrected_detail_3_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XN_CORRECTED_DETAIL_4"                  */
-/*                       Corrected error header1                        */
-/* ==================================================================== */
-
-typedef union sh_xn_corrected_detail_4_u {
-	mmr_t	sh_xn_corrected_detail_4_regval;
-	struct {
-		mmr_t	header1     : 42;
-		mmr_t	reserved_0  : 20;
-		mmr_t	err_group   : 2;
-	} sh_xn_corrected_detail_4_s;
-} sh_xn_corrected_detail_4_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_UNCORRECTED_DETAIL_1"                 */
-/*                      Uncorrected error details                       */
-/* ==================================================================== */
-
-typedef union sh_xn_uncorrected_detail_1_u {
-	mmr_t	sh_xn_uncorrected_detail_1_regval;
-	struct {
-		mmr_t	ecc0_syndrome : 8;
-		mmr_t	ecc0_wc       : 2;
-		mmr_t	ecc0_vc       : 2;
-		mmr_t	reserved_0    : 4;
-		mmr_t	ecc1_syndrome : 8;
-		mmr_t	ecc1_wc       : 2;
-		mmr_t	ecc1_vc       : 2;
-		mmr_t	reserved_1    : 4;
-		mmr_t	ecc2_syndrome : 8;
-		mmr_t	ecc2_wc       : 2;
-		mmr_t	ecc2_vc       : 2;
-		mmr_t	reserved_2    : 4;
-		mmr_t	ecc3_syndrome : 8;
-		mmr_t	ecc3_wc       : 2;
-		mmr_t	ecc3_vc       : 2;
-		mmr_t	reserved_3    : 4;
-	} sh_xn_uncorrected_detail_1_s;
-} sh_xn_uncorrected_detail_1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_UNCORRECTED_DETAIL_2"                 */
-/*                        Uncorrected error data                        */
-/* ==================================================================== */
-
-typedef union sh_xn_uncorrected_detail_2_u {
-	mmr_t	sh_xn_uncorrected_detail_2_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_xn_uncorrected_detail_2_s;
-} sh_xn_uncorrected_detail_2_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_UNCORRECTED_DETAIL_3"                 */
-/*                      Uncorrected error header0                       */
-/* ==================================================================== */
-
-typedef union sh_xn_uncorrected_detail_3_u {
-	mmr_t	sh_xn_uncorrected_detail_3_regval;
-	struct {
-		mmr_t	header0     : 64;
-	} sh_xn_uncorrected_detail_3_s;
-} sh_xn_uncorrected_detail_3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_XN_UNCORRECTED_DETAIL_4"                 */
-/*                      Uncorrected error header1                       */
-/* ==================================================================== */
-
-typedef union sh_xn_uncorrected_detail_4_u {
-	mmr_t	sh_xn_uncorrected_detail_4_regval;
-	struct {
-		mmr_t	header1     : 42;
-		mmr_t	reserved_0  : 20;
-		mmr_t	err_group   : 2;
-	} sh_xn_uncorrected_detail_4_s;
-} sh_xn_uncorrected_detail_4_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNMD_ERROR_DETAIL_1"                   */
-/*                      Look Up Table Address (md)                      */
-/* ==================================================================== */
-
-typedef union sh_xnmd_error_detail_1_u {
-	mmr_t	sh_xnmd_error_detail_1_regval;
-	struct {
-		mmr_t	lut_addr    : 11;
-		mmr_t	reserved_0  : 53;
-	} sh_xnmd_error_detail_1_s;
-} sh_xnmd_error_detail_1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNPI_ERROR_DETAIL_1"                   */
-/*                      Look Up Table Address (pi)                      */
-/* ==================================================================== */
-
-typedef union sh_xnpi_error_detail_1_u {
-	mmr_t	sh_xnpi_error_detail_1_regval;
-	struct {
-		mmr_t	lut_addr    : 11;
-		mmr_t	reserved_0  : 53;
-	} sh_xnpi_error_detail_1_s;
-} sh_xnpi_error_detail_1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNIILB_ERROR_DETAIL_1"                  */
-/*                    Chiplet NoMatch header [63:0]                     */
-/* ==================================================================== */
-
-typedef union sh_xniilb_error_detail_1_u {
-	mmr_t	sh_xniilb_error_detail_1_regval;
-	struct {
-		mmr_t	header      : 64;
-	} sh_xniilb_error_detail_1_s;
-} sh_xniilb_error_detail_1_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNIILB_ERROR_DETAIL_2"                  */
-/*                   Chiplet NoMatch header [127:64]                    */
-/* ==================================================================== */
-
-typedef union sh_xniilb_error_detail_2_u {
-	mmr_t	sh_xniilb_error_detail_2_regval;
-	struct {
-		mmr_t	header      : 64;
-	} sh_xniilb_error_detail_2_s;
-} sh_xniilb_error_detail_2_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNIILB_ERROR_DETAIL_3"                  */
-/*                     Look Up Table Address (iilb)                     */
-/* ==================================================================== */
-
-typedef union sh_xniilb_error_detail_3_u {
-	mmr_t	sh_xniilb_error_detail_3_regval;
-	struct {
-		mmr_t	lut_addr    : 11;
-		mmr_t	reserved_0  : 53;
-	} sh_xniilb_error_detail_3_s;
-} sh_xniilb_error_detail_3_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI0_ERROR_DETAIL_3"                   */
-/*                     Look Up Table Address (ni0)                      */
-/* ==================================================================== */
-
-typedef union sh_ni0_error_detail_3_u {
-	mmr_t	sh_ni0_error_detail_3_regval;
-	struct {
-		mmr_t	lut_addr    : 11;
-		mmr_t	reserved_0  : 53;
-	} sh_ni0_error_detail_3_s;
-} sh_ni0_error_detail_3_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_NI1_ERROR_DETAIL_3"                   */
-/*                     Look Up Table Address (ni1)                      */
-/* ==================================================================== */
-
-typedef union sh_ni1_error_detail_3_u {
-	mmr_t	sh_ni1_error_detail_3_regval;
-	struct {
-		mmr_t	lut_addr    : 11;
-		mmr_t	reserved_0  : 53;
-	} sh_ni1_error_detail_3_s;
-} sh_ni1_error_detail_3_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_ERROR_SUMMARY"                    */
-/* ==================================================================== */
-
-typedef union sh_xn_error_summary_u {
-	mmr_t	sh_xn_error_summary_regval;
-	struct {
-		mmr_t	ni0_pop_overflow        : 1;
-		mmr_t	ni0_push_overflow       : 1;
-		mmr_t	ni0_credit_overflow     : 1;
-		mmr_t	ni0_debit_overflow      : 1;
-		mmr_t	ni0_pop_underflow       : 1;
-		mmr_t	ni0_push_underflow      : 1;
-		mmr_t	ni0_credit_underflow    : 1;
-		mmr_t	ni0_llp_error           : 1;
-		mmr_t	ni0_pipe_error          : 1;
-		mmr_t	ni1_pop_overflow        : 1;
-		mmr_t	ni1_push_overflow       : 1;
-		mmr_t	ni1_credit_overflow     : 1;
-		mmr_t	ni1_debit_overflow      : 1;
-		mmr_t	ni1_pop_underflow       : 1;
-		mmr_t	ni1_push_underflow      : 1;
-		mmr_t	ni1_credit_underflow    : 1;
-		mmr_t	ni1_llp_error           : 1;
-		mmr_t	ni1_pipe_error          : 1;
-		mmr_t	xnmd_credit_overflow    : 1;
-		mmr_t	xnmd_debit_overflow     : 1;
-		mmr_t	xnmd_data_buff_overflow : 1;
-		mmr_t	xnmd_credit_underflow   : 1;
-		mmr_t	xnmd_sbe_error          : 1;
-		mmr_t	xnmd_uce_error          : 1;
-		mmr_t	xnmd_lut_error          : 1;
-		mmr_t	xnpi_credit_overflow    : 1;
-		mmr_t	xnpi_debit_overflow     : 1;
-		mmr_t	xnpi_data_buff_overflow : 1;
-		mmr_t	xnpi_credit_underflow   : 1;
-		mmr_t	xnpi_sbe_error          : 1;
-		mmr_t	xnpi_uce_error          : 1;
-		mmr_t	xnpi_lut_error          : 1;
-		mmr_t	iilb_debit_overflow     : 1;
-		mmr_t	iilb_credit_overflow    : 1;
-		mmr_t	iilb_fifo_overflow      : 1;
-		mmr_t	iilb_credit_underflow   : 1;
-		mmr_t	iilb_fifo_underflow     : 1;
-		mmr_t	iilb_chiplet_or_lut     : 1;
-		mmr_t	reserved_0              : 26;
-	} sh_xn_error_summary_s;
-} sh_xn_error_summary_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XN_ERROR_OVERFLOW"                    */
-/* ==================================================================== */
-
-typedef union sh_xn_error_overflow_u {
-	mmr_t	sh_xn_error_overflow_regval;
-	struct {
-		mmr_t	ni0_pop_overflow        : 1;
-		mmr_t	ni0_push_overflow       : 1;
-		mmr_t	ni0_credit_overflow     : 1;
-		mmr_t	ni0_debit_overflow      : 1;
-		mmr_t	ni0_pop_underflow       : 1;
-		mmr_t	ni0_push_underflow      : 1;
-		mmr_t	ni0_credit_underflow    : 1;
-		mmr_t	ni0_llp_error           : 1;
-		mmr_t	ni0_pipe_error          : 1;
-		mmr_t	ni1_pop_overflow        : 1;
-		mmr_t	ni1_push_overflow       : 1;
-		mmr_t	ni1_credit_overflow     : 1;
-		mmr_t	ni1_debit_overflow      : 1;
-		mmr_t	ni1_pop_underflow       : 1;
-		mmr_t	ni1_push_underflow      : 1;
-		mmr_t	ni1_credit_underflow    : 1;
-		mmr_t	ni1_llp_error           : 1;
-		mmr_t	ni1_pipe_error          : 1;
-		mmr_t	xnmd_credit_overflow    : 1;
-		mmr_t	xnmd_debit_overflow     : 1;
-		mmr_t	xnmd_data_buff_overflow : 1;
-		mmr_t	xnmd_credit_underflow   : 1;
-		mmr_t	xnmd_sbe_error          : 1;
-		mmr_t	xnmd_uce_error          : 1;
-		mmr_t	xnmd_lut_error          : 1;
-		mmr_t	xnpi_credit_overflow    : 1;
-		mmr_t	xnpi_debit_overflow     : 1;
-		mmr_t	xnpi_data_buff_overflow : 1;
-		mmr_t	xnpi_credit_underflow   : 1;
-		mmr_t	xnpi_sbe_error          : 1;
-		mmr_t	xnpi_uce_error          : 1;
-		mmr_t	xnpi_lut_error          : 1;
-		mmr_t	iilb_debit_overflow     : 1;
-		mmr_t	iilb_credit_overflow    : 1;
-		mmr_t	iilb_fifo_overflow      : 1;
-		mmr_t	iilb_credit_underflow   : 1;
-		mmr_t	iilb_fifo_underflow     : 1;
-		mmr_t	iilb_chiplet_or_lut     : 1;
-		mmr_t	reserved_0              : 26;
-	} sh_xn_error_overflow_s;
-} sh_xn_error_overflow_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_XN_ERROR_MASK"                      */
-/* ==================================================================== */
-
-typedef union sh_xn_error_mask_u {
-	mmr_t	sh_xn_error_mask_regval;
-	struct {
-		mmr_t	ni0_pop_overflow        : 1;
-		mmr_t	ni0_push_overflow       : 1;
-		mmr_t	ni0_credit_overflow     : 1;
-		mmr_t	ni0_debit_overflow      : 1;
-		mmr_t	ni0_pop_underflow       : 1;
-		mmr_t	ni0_push_underflow      : 1;
-		mmr_t	ni0_credit_underflow    : 1;
-		mmr_t	ni0_llp_error           : 1;
-		mmr_t	ni0_pipe_error          : 1;
-		mmr_t	ni1_pop_overflow        : 1;
-		mmr_t	ni1_push_overflow       : 1;
-		mmr_t	ni1_credit_overflow     : 1;
-		mmr_t	ni1_debit_overflow      : 1;
-		mmr_t	ni1_pop_underflow       : 1;
-		mmr_t	ni1_push_underflow      : 1;
-		mmr_t	ni1_credit_underflow    : 1;
-		mmr_t	ni1_llp_error           : 1;
-		mmr_t	ni1_pipe_error          : 1;
-		mmr_t	xnmd_credit_overflow    : 1;
-		mmr_t	xnmd_debit_overflow     : 1;
-		mmr_t	xnmd_data_buff_overflow : 1;
-		mmr_t	xnmd_credit_underflow   : 1;
-		mmr_t	xnmd_sbe_error          : 1;
-		mmr_t	xnmd_uce_error          : 1;
-		mmr_t	xnmd_lut_error          : 1;
-		mmr_t	xnpi_credit_overflow    : 1;
-		mmr_t	xnpi_debit_overflow     : 1;
-		mmr_t	xnpi_data_buff_overflow : 1;
-		mmr_t	xnpi_credit_underflow   : 1;
-		mmr_t	xnpi_sbe_error          : 1;
-		mmr_t	xnpi_uce_error          : 1;
-		mmr_t	xnpi_lut_error          : 1;
-		mmr_t	iilb_debit_overflow     : 1;
-		mmr_t	iilb_credit_overflow    : 1;
-		mmr_t	iilb_fifo_overflow      : 1;
-		mmr_t	iilb_credit_underflow   : 1;
-		mmr_t	iilb_fifo_underflow     : 1;
-		mmr_t	iilb_chiplet_or_lut     : 1;
-		mmr_t	reserved_0              : 26;
-	} sh_xn_error_mask_s;
-} sh_xn_error_mask_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_XN_FIRST_ERROR"                     */
-/* ==================================================================== */
-
-typedef union sh_xn_first_error_u {
-	mmr_t	sh_xn_first_error_regval;
-	struct {
-		mmr_t	ni0_pop_overflow        : 1;
-		mmr_t	ni0_push_overflow       : 1;
-		mmr_t	ni0_credit_overflow     : 1;
-		mmr_t	ni0_debit_overflow      : 1;
-		mmr_t	ni0_pop_underflow       : 1;
-		mmr_t	ni0_push_underflow      : 1;
-		mmr_t	ni0_credit_underflow    : 1;
-		mmr_t	ni0_llp_error           : 1;
-		mmr_t	ni0_pipe_error          : 1;
-		mmr_t	ni1_pop_overflow        : 1;
-		mmr_t	ni1_push_overflow       : 1;
-		mmr_t	ni1_credit_overflow     : 1;
-		mmr_t	ni1_debit_overflow      : 1;
-		mmr_t	ni1_pop_underflow       : 1;
-		mmr_t	ni1_push_underflow      : 1;
-		mmr_t	ni1_credit_underflow    : 1;
-		mmr_t	ni1_llp_error           : 1;
-		mmr_t	ni1_pipe_error          : 1;
-		mmr_t	xnmd_credit_overflow    : 1;
-		mmr_t	xnmd_debit_overflow     : 1;
-		mmr_t	xnmd_data_buff_overflow : 1;
-		mmr_t	xnmd_credit_underflow   : 1;
-		mmr_t	xnmd_sbe_error          : 1;
-		mmr_t	xnmd_uce_error          : 1;
-		mmr_t	xnmd_lut_error          : 1;
-		mmr_t	xnpi_credit_overflow    : 1;
-		mmr_t	xnpi_debit_overflow     : 1;
-		mmr_t	xnpi_data_buff_overflow : 1;
-		mmr_t	xnpi_credit_underflow   : 1;
-		mmr_t	xnpi_sbe_error          : 1;
-		mmr_t	xnpi_uce_error          : 1;
-		mmr_t	xnpi_lut_error          : 1;
-		mmr_t	iilb_debit_overflow     : 1;
-		mmr_t	iilb_credit_overflow    : 1;
-		mmr_t	iilb_fifo_overflow      : 1;
-		mmr_t	iilb_credit_underflow   : 1;
-		mmr_t	iilb_fifo_underflow     : 1;
-		mmr_t	iilb_chiplet_or_lut     : 1;
-		mmr_t	reserved_0              : 26;
-	} sh_xn_first_error_s;
-} sh_xn_first_error_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNIILB_ERROR_SUMMARY"                  */
-/* ==================================================================== */
-
-typedef union sh_xniilb_error_summary_u {
-	mmr_t	sh_xniilb_error_summary_regval;
-	struct {
-		mmr_t	overflow_ii_debit0            : 1;
-		mmr_t	overflow_ii_debit2            : 1;
-		mmr_t	overflow_lb_debit0            : 1;
-		mmr_t	overflow_lb_debit2            : 1;
-		mmr_t	overflow_ii_vc0               : 1;
-		mmr_t	overflow_ii_vc2               : 1;
-		mmr_t	underflow_ii_vc0              : 1;
-		mmr_t	underflow_ii_vc2              : 1;
-		mmr_t	overflow_lb_vc0               : 1;
-		mmr_t	overflow_lb_vc2               : 1;
-		mmr_t	underflow_lb_vc0              : 1;
-		mmr_t	underflow_lb_vc2              : 1;
-		mmr_t	overflow_pi_vc0_credit_in     : 1;
-		mmr_t	overflow_iilb_vc0_credit_in   : 1;
-		mmr_t	overflow_md_vc0_credit_in     : 1;
-		mmr_t	overflow_ni0_vc0_credit_in    : 1;
-		mmr_t	overflow_ni1_vc0_credit_in    : 1;
-		mmr_t	overflow_pi_vc2_credit_in     : 1;
-		mmr_t	overflow_iilb_vc2_credit_in   : 1;
-		mmr_t	overflow_md_vc2_credit_in     : 1;
-		mmr_t	overflow_ni0_vc2_credit_in    : 1;
-		mmr_t	overflow_ni1_vc2_credit_in    : 1;
-		mmr_t	underflow_pi_vc0_credit_in    : 1;
-		mmr_t	underflow_iilb_vc0_credit_in  : 1;
-		mmr_t	underflow_md_vc0_credit_in    : 1;
-		mmr_t	underflow_ni0_vc0_credit_in   : 1;
-		mmr_t	underflow_ni1_vc0_credit_in   : 1;
-		mmr_t	underflow_pi_vc2_credit_in    : 1;
-		mmr_t	underflow_iilb_vc2_credit_in  : 1;
-		mmr_t	underflow_md_vc2_credit_in    : 1;
-		mmr_t	underflow_ni0_vc2_credit_in   : 1;
-		mmr_t	underflow_ni1_vc2_credit_in   : 1;
-		mmr_t	overflow_pi_debit0            : 1;
-		mmr_t	overflow_pi_debit2            : 1;
-		mmr_t	overflow_iilb_debit0          : 1;
-		mmr_t	overflow_iilb_debit2          : 1;
-		mmr_t	overflow_md_debit0            : 1;
-		mmr_t	overflow_md_debit2            : 1;
-		mmr_t	overflow_ni0_debit0           : 1;
-		mmr_t	overflow_ni0_debit2           : 1;
-		mmr_t	overflow_ni1_debit0           : 1;
-		mmr_t	overflow_ni1_debit2           : 1;
-		mmr_t	overflow_pi_vc0_credit_out    : 1;
-		mmr_t	overflow_pi_vc2_credit_out    : 1;
-		mmr_t	overflow_md_vc0_credit_out    : 1;
-		mmr_t	overflow_md_vc2_credit_out    : 1;
-		mmr_t	overflow_iilb_vc0_credit_out  : 1;
-		mmr_t	overflow_iilb_vc2_credit_out  : 1;
-		mmr_t	overflow_ni0_vc0_credit_out   : 1;
-		mmr_t	overflow_ni0_vc2_credit_out   : 1;
-		mmr_t	overflow_ni1_vc0_credit_out   : 1;
-		mmr_t	overflow_ni1_vc2_credit_out   : 1;
-		mmr_t	underflow_pi_vc0_credit_out   : 1;
-		mmr_t	underflow_pi_vc2_credit_out   : 1;
-		mmr_t	underflow_md_vc0_credit_out   : 1;
-		mmr_t	underflow_md_vc2_credit_out   : 1;
-		mmr_t	underflow_iilb_vc0_credit_out : 1;
-		mmr_t	underflow_iilb_vc2_credit_out : 1;
-		mmr_t	underflow_ni0_vc0_credit_out  : 1;
-		mmr_t	underflow_ni0_vc2_credit_out  : 1;
-		mmr_t	underflow_ni1_vc0_credit_out  : 1;
-		mmr_t	underflow_ni1_vc2_credit_out  : 1;
-		mmr_t	chiplet_nomatch               : 1;
-		mmr_t	lut_read_error                : 1;
-	} sh_xniilb_error_summary_s;
-} sh_xniilb_error_summary_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_XNIILB_ERROR_OVERFLOW"                  */
-/* ==================================================================== */
-
-typedef union sh_xniilb_error_overflow_u {
-	mmr_t	sh_xniilb_error_overflow_regval;
-	struct {
-		mmr_t	overflow_ii_debit0            : 1;
-		mmr_t	overflow_ii_debit2            : 1;
-		mmr_t	overflow_lb_debit0            : 1;
-		mmr_t	overflow_lb_debit2            : 1;
-		mmr_t	overflow_ii_vc0               : 1;
-		mmr_t	overflow_ii_vc2               : 1;
-		mmr_t	underflow_ii_vc0              : 1;
-		mmr_t	underflow_ii_vc2              : 1;
-		mmr_t	overflow_lb_vc0               : 1;
-		mmr_t	overflow_lb_vc2               : 1;
-		mmr_t	underflow_lb_vc0              : 1;
-		mmr_t	underflow_lb_vc2              : 1;
-		mmr_t	overflow_pi_vc0_credit_in     : 1;
-		mmr_t	overflow_iilb_vc0_credit_in   : 1;
-		mmr_t	overflow_md_vc0_credit_in     : 1;
-		mmr_t	overflow_ni0_vc0_credit_in    : 1;
-		mmr_t	overflow_ni1_vc0_credit_in    : 1;
-		mmr_t	overflow_pi_vc2_credit_in     : 1;
-		mmr_t	overflow_iilb_vc2_credit_in   : 1;
-		mmr_t	overflow_md_vc2_credit_in     : 1;
-		mmr_t	overflow_ni0_vc2_credit_in    : 1;
-		mmr_t	overflow_ni1_vc2_credit_in    : 1;
-		mmr_t	underflow_pi_vc0_credit_in    : 1;
-		mmr_t	underflow_iilb_vc0_credit_in  : 1;
-		mmr_t	underflow_md_vc0_credit_in    : 1;
-		mmr_t	underflow_ni0_vc0_credit_in   : 1;
-		mmr_t	underflow_ni1_vc0_credit_in   : 1;
-		mmr_t	underflow_pi_vc2_credit_in    : 1;
-		mmr_t	underflow_iilb_vc2_credit_in  : 1;
-		mmr_t	underflow_md_vc2_credit_in    : 1;
-		mmr_t	underflow_ni0_vc2_credit_in   : 1;
-		mmr_t	underflow_ni1_vc2_credit_in   : 1;
-		mmr_t	overflow_pi_debit0            : 1;
-		mmr_t	overflow_pi_debit2            : 1;
-		mmr_t	overflow_iilb_debit0          : 1;
-		mmr_t	overflow_iilb_debit2          : 1;
-		mmr_t	overflow_md_debit0            : 1;
-		mmr_t	overflow_md_debit2            : 1;
-		mmr_t	overflow_ni0_debit0           : 1;
-		mmr_t	overflow_ni0_debit2           : 1;
-		mmr_t	overflow_ni1_debit0           : 1;
-		mmr_t	overflow_ni1_debit2           : 1;
-		mmr_t	overflow_pi_vc0_credit_out    : 1;
-		mmr_t	overflow_pi_vc2_credit_out    : 1;
-		mmr_t	overflow_md_vc0_credit_out    : 1;
-		mmr_t	overflow_md_vc2_credit_out    : 1;
-		mmr_t	overflow_iilb_vc0_credit_out  : 1;
-		mmr_t	overflow_iilb_vc2_credit_out  : 1;
-		mmr_t	overflow_ni0_vc0_credit_out   : 1;
-		mmr_t	overflow_ni0_vc2_credit_out   : 1;
-		mmr_t	overflow_ni1_vc0_credit_out   : 1;
-		mmr_t	overflow_ni1_vc2_credit_out   : 1;
-		mmr_t	underflow_pi_vc0_credit_out   : 1;
-		mmr_t	underflow_pi_vc2_credit_out   : 1;
-		mmr_t	underflow_md_vc0_credit_out   : 1;
-		mmr_t	underflow_md_vc2_credit_out   : 1;
-		mmr_t	underflow_iilb_vc0_credit_out : 1;
-		mmr_t	underflow_iilb_vc2_credit_out : 1;
-		mmr_t	underflow_ni0_vc0_credit_out  : 1;
-		mmr_t	underflow_ni0_vc2_credit_out  : 1;
-		mmr_t	underflow_ni1_vc0_credit_out  : 1;
-		mmr_t	underflow_ni1_vc2_credit_out  : 1;
-		mmr_t	chiplet_nomatch               : 1;
-		mmr_t	lut_read_error                : 1;
-	} sh_xniilb_error_overflow_s;
-} sh_xniilb_error_overflow_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNIILB_ERROR_MASK"                    */
-/* ==================================================================== */
-
-typedef union sh_xniilb_error_mask_u {
-	mmr_t	sh_xniilb_error_mask_regval;
-	struct {
-		mmr_t	overflow_ii_debit0            : 1;
-		mmr_t	overflow_ii_debit2            : 1;
-		mmr_t	overflow_lb_debit0            : 1;
-		mmr_t	overflow_lb_debit2            : 1;
-		mmr_t	overflow_ii_vc0               : 1;
-		mmr_t	overflow_ii_vc2               : 1;
-		mmr_t	underflow_ii_vc0              : 1;
-		mmr_t	underflow_ii_vc2              : 1;
-		mmr_t	overflow_lb_vc0               : 1;
-		mmr_t	overflow_lb_vc2               : 1;
-		mmr_t	underflow_lb_vc0              : 1;
-		mmr_t	underflow_lb_vc2              : 1;
-		mmr_t	overflow_pi_vc0_credit_in     : 1;
-		mmr_t	overflow_iilb_vc0_credit_in   : 1;
-		mmr_t	overflow_md_vc0_credit_in     : 1;
-		mmr_t	overflow_ni0_vc0_credit_in    : 1;
-		mmr_t	overflow_ni1_vc0_credit_in    : 1;
-		mmr_t	overflow_pi_vc2_credit_in     : 1;
-		mmr_t	overflow_iilb_vc2_credit_in   : 1;
-		mmr_t	overflow_md_vc2_credit_in     : 1;
-		mmr_t	overflow_ni0_vc2_credit_in    : 1;
-		mmr_t	overflow_ni1_vc2_credit_in    : 1;
-		mmr_t	underflow_pi_vc0_credit_in    : 1;
-		mmr_t	underflow_iilb_vc0_credit_in  : 1;
-		mmr_t	underflow_md_vc0_credit_in    : 1;
-		mmr_t	underflow_ni0_vc0_credit_in   : 1;
-		mmr_t	underflow_ni1_vc0_credit_in   : 1;
-		mmr_t	underflow_pi_vc2_credit_in    : 1;
-		mmr_t	underflow_iilb_vc2_credit_in  : 1;
-		mmr_t	underflow_md_vc2_credit_in    : 1;
-		mmr_t	underflow_ni0_vc2_credit_in   : 1;
-		mmr_t	underflow_ni1_vc2_credit_in   : 1;
-		mmr_t	overflow_pi_debit0            : 1;
-		mmr_t	overflow_pi_debit2            : 1;
-		mmr_t	overflow_iilb_debit0          : 1;
-		mmr_t	overflow_iilb_debit2          : 1;
-		mmr_t	overflow_md_debit0            : 1;
-		mmr_t	overflow_md_debit2            : 1;
-		mmr_t	overflow_ni0_debit0           : 1;
-		mmr_t	overflow_ni0_debit2           : 1;
-		mmr_t	overflow_ni1_debit0           : 1;
-		mmr_t	overflow_ni1_debit2           : 1;
-		mmr_t	overflow_pi_vc0_credit_out    : 1;
-		mmr_t	overflow_pi_vc2_credit_out    : 1;
-		mmr_t	overflow_md_vc0_credit_out    : 1;
-		mmr_t	overflow_md_vc2_credit_out    : 1;
-		mmr_t	overflow_iilb_vc0_credit_out  : 1;
-		mmr_t	overflow_iilb_vc2_credit_out  : 1;
-		mmr_t	overflow_ni0_vc0_credit_out   : 1;
-		mmr_t	overflow_ni0_vc2_credit_out   : 1;
-		mmr_t	overflow_ni1_vc0_credit_out   : 1;
-		mmr_t	overflow_ni1_vc2_credit_out   : 1;
-		mmr_t	underflow_pi_vc0_credit_out   : 1;
-		mmr_t	underflow_pi_vc2_credit_out   : 1;
-		mmr_t	underflow_md_vc0_credit_out   : 1;
-		mmr_t	underflow_md_vc2_credit_out   : 1;
-		mmr_t	underflow_iilb_vc0_credit_out : 1;
-		mmr_t	underflow_iilb_vc2_credit_out : 1;
-		mmr_t	underflow_ni0_vc0_credit_out  : 1;
-		mmr_t	underflow_ni0_vc2_credit_out  : 1;
-		mmr_t	underflow_ni1_vc0_credit_out  : 1;
-		mmr_t	underflow_ni1_vc2_credit_out  : 1;
-		mmr_t	chiplet_nomatch               : 1;
-		mmr_t	lut_read_error                : 1;
-	} sh_xniilb_error_mask_s;
-} sh_xniilb_error_mask_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNIILB_FIRST_ERROR"                   */
-/* ==================================================================== */
-
-typedef union sh_xniilb_first_error_u {
-	mmr_t	sh_xniilb_first_error_regval;
-	struct {
-		mmr_t	overflow_ii_debit0            : 1;
-		mmr_t	overflow_ii_debit2            : 1;
-		mmr_t	overflow_lb_debit0            : 1;
-		mmr_t	overflow_lb_debit2            : 1;
-		mmr_t	overflow_ii_vc0               : 1;
-		mmr_t	overflow_ii_vc2               : 1;
-		mmr_t	underflow_ii_vc0              : 1;
-		mmr_t	underflow_ii_vc2              : 1;
-		mmr_t	overflow_lb_vc0               : 1;
-		mmr_t	overflow_lb_vc2               : 1;
-		mmr_t	underflow_lb_vc0              : 1;
-		mmr_t	underflow_lb_vc2              : 1;
-		mmr_t	overflow_pi_vc0_credit_in     : 1;
-		mmr_t	overflow_iilb_vc0_credit_in   : 1;
-		mmr_t	overflow_md_vc0_credit_in     : 1;
-		mmr_t	overflow_ni0_vc0_credit_in    : 1;
-		mmr_t	overflow_ni1_vc0_credit_in    : 1;
-		mmr_t	overflow_pi_vc2_credit_in     : 1;
-		mmr_t	overflow_iilb_vc2_credit_in   : 1;
-		mmr_t	overflow_md_vc2_credit_in     : 1;
-		mmr_t	overflow_ni0_vc2_credit_in    : 1;
-		mmr_t	overflow_ni1_vc2_credit_in    : 1;
-		mmr_t	underflow_pi_vc0_credit_in    : 1;
-		mmr_t	underflow_iilb_vc0_credit_in  : 1;
-		mmr_t	underflow_md_vc0_credit_in    : 1;
-		mmr_t	underflow_ni0_vc0_credit_in   : 1;
-		mmr_t	underflow_ni1_vc0_credit_in   : 1;
-		mmr_t	underflow_pi_vc2_credit_in    : 1;
-		mmr_t	underflow_iilb_vc2_credit_in  : 1;
-		mmr_t	underflow_md_vc2_credit_in    : 1;
-		mmr_t	underflow_ni0_vc2_credit_in   : 1;
-		mmr_t	underflow_ni1_vc2_credit_in   : 1;
-		mmr_t	overflow_pi_debit0            : 1;
-		mmr_t	overflow_pi_debit2            : 1;
-		mmr_t	overflow_iilb_debit0          : 1;
-		mmr_t	overflow_iilb_debit2          : 1;
-		mmr_t	overflow_md_debit0            : 1;
-		mmr_t	overflow_md_debit2            : 1;
-		mmr_t	overflow_ni0_debit0           : 1;
-		mmr_t	overflow_ni0_debit2           : 1;
-		mmr_t	overflow_ni1_debit0           : 1;
-		mmr_t	overflow_ni1_debit2           : 1;
-		mmr_t	overflow_pi_vc0_credit_out    : 1;
-		mmr_t	overflow_pi_vc2_credit_out    : 1;
-		mmr_t	overflow_md_vc0_credit_out    : 1;
-		mmr_t	overflow_md_vc2_credit_out    : 1;
-		mmr_t	overflow_iilb_vc0_credit_out  : 1;
-		mmr_t	overflow_iilb_vc2_credit_out  : 1;
-		mmr_t	overflow_ni0_vc0_credit_out   : 1;
-		mmr_t	overflow_ni0_vc2_credit_out   : 1;
-		mmr_t	overflow_ni1_vc0_credit_out   : 1;
-		mmr_t	overflow_ni1_vc2_credit_out   : 1;
-		mmr_t	underflow_pi_vc0_credit_out   : 1;
-		mmr_t	underflow_pi_vc2_credit_out   : 1;
-		mmr_t	underflow_md_vc0_credit_out   : 1;
-		mmr_t	underflow_md_vc2_credit_out   : 1;
-		mmr_t	underflow_iilb_vc0_credit_out : 1;
-		mmr_t	underflow_iilb_vc2_credit_out : 1;
-		mmr_t	underflow_ni0_vc0_credit_out  : 1;
-		mmr_t	underflow_ni0_vc2_credit_out  : 1;
-		mmr_t	underflow_ni1_vc0_credit_out  : 1;
-		mmr_t	underflow_ni1_vc2_credit_out  : 1;
-		mmr_t	chiplet_nomatch               : 1;
-		mmr_t	lut_read_error                : 1;
-	} sh_xniilb_first_error_s;
-} sh_xniilb_first_error_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNPI_ERROR_SUMMARY"                   */
-/* ==================================================================== */
-
-typedef union sh_xnpi_error_summary_u {
-	mmr_t	sh_xnpi_error_summary_regval;
-	struct {
-		mmr_t	underflow_ni0_vc0           : 1;
-		mmr_t	overflow_ni0_vc0            : 1;
-		mmr_t	underflow_ni0_vc2           : 1;
-		mmr_t	overflow_ni0_vc2            : 1;
-		mmr_t	underflow_ni1_vc0           : 1;
-		mmr_t	overflow_ni1_vc0            : 1;
-		mmr_t	underflow_ni1_vc2           : 1;
-		mmr_t	overflow_ni1_vc2            : 1;
-		mmr_t	underflow_iilb_vc0          : 1;
-		mmr_t	overflow_iilb_vc0           : 1;
-		mmr_t	underflow_iilb_vc2          : 1;
-		mmr_t	overflow_iilb_vc2           : 1;
-		mmr_t	underflow_vc0_credit        : 1;
-		mmr_t	overflow_vc0_credit         : 1;
-		mmr_t	underflow_vc2_credit        : 1;
-		mmr_t	overflow_vc2_credit         : 1;
-		mmr_t	overflow_databuff_vc0       : 1;
-		mmr_t	overflow_databuff_vc2       : 1;
-		mmr_t	lut_read_error              : 1;
-		mmr_t	single_bit_error0           : 1;
-		mmr_t	single_bit_error1           : 1;
-		mmr_t	single_bit_error2           : 1;
-		mmr_t	single_bit_error3           : 1;
-		mmr_t	uncor_error0                : 1;
-		mmr_t	uncor_error1                : 1;
-		mmr_t	uncor_error2                : 1;
-		mmr_t	uncor_error3                : 1;
-		mmr_t	underflow_sic_cntr0         : 1;
-		mmr_t	overflow_sic_cntr0          : 1;
-		mmr_t	underflow_sic_cntr2         : 1;
-		mmr_t	overflow_sic_cntr2          : 1;
-		mmr_t	overflow_ni0_debit0         : 1;
-		mmr_t	overflow_ni0_debit2         : 1;
-		mmr_t	overflow_ni1_debit0         : 1;
-		mmr_t	overflow_ni1_debit2         : 1;
-		mmr_t	overflow_iilb_debit0        : 1;
-		mmr_t	overflow_iilb_debit2        : 1;
-		mmr_t	underflow_ni0_vc0_credit    : 1;
-		mmr_t	overflow_ni0_vc0_credit     : 1;
-		mmr_t	underflow_ni0_vc2_credit    : 1;
-		mmr_t	overflow_ni0_vc2_credit     : 1;
-		mmr_t	underflow_ni1_vc0_credit    : 1;
-		mmr_t	overflow_ni1_vc0_credit     : 1;
-		mmr_t	underflow_ni1_vc2_credit    : 1;
-		mmr_t	overflow_ni1_vc2_credit     : 1;
-		mmr_t	underflow_iilb_vc0_credit   : 1;
-		mmr_t	overflow_iilb_vc0_credit    : 1;
-		mmr_t	underflow_iilb_vc2_credit   : 1;
-		mmr_t	overflow_iilb_vc2_credit    : 1;
-		mmr_t	overflow_header_cancel_fifo : 1;
-		mmr_t	reserved_0                  : 14;
-	} sh_xnpi_error_summary_s;
-} sh_xnpi_error_summary_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNPI_ERROR_OVERFLOW"                   */
-/* ==================================================================== */
-
-typedef union sh_xnpi_error_overflow_u {
-	mmr_t	sh_xnpi_error_overflow_regval;
-	struct {
-		mmr_t	underflow_ni0_vc0           : 1;
-		mmr_t	overflow_ni0_vc0            : 1;
-		mmr_t	underflow_ni0_vc2           : 1;
-		mmr_t	overflow_ni0_vc2            : 1;
-		mmr_t	underflow_ni1_vc0           : 1;
-		mmr_t	overflow_ni1_vc0            : 1;
-		mmr_t	underflow_ni1_vc2           : 1;
-		mmr_t	overflow_ni1_vc2            : 1;
-		mmr_t	underflow_iilb_vc0          : 1;
-		mmr_t	overflow_iilb_vc0           : 1;
-		mmr_t	underflow_iilb_vc2          : 1;
-		mmr_t	overflow_iilb_vc2           : 1;
-		mmr_t	underflow_vc0_credit        : 1;
-		mmr_t	overflow_vc0_credit         : 1;
-		mmr_t	underflow_vc2_credit        : 1;
-		mmr_t	overflow_vc2_credit         : 1;
-		mmr_t	overflow_databuff_vc0       : 1;
-		mmr_t	overflow_databuff_vc2       : 1;
-		mmr_t	lut_read_error              : 1;
-		mmr_t	single_bit_error0           : 1;
-		mmr_t	single_bit_error1           : 1;
-		mmr_t	single_bit_error2           : 1;
-		mmr_t	single_bit_error3           : 1;
-		mmr_t	uncor_error0                : 1;
-		mmr_t	uncor_error1                : 1;
-		mmr_t	uncor_error2                : 1;
-		mmr_t	uncor_error3                : 1;
-		mmr_t	underflow_sic_cntr0         : 1;
-		mmr_t	overflow_sic_cntr0          : 1;
-		mmr_t	underflow_sic_cntr2         : 1;
-		mmr_t	overflow_sic_cntr2          : 1;
-		mmr_t	overflow_ni0_debit0         : 1;
-		mmr_t	overflow_ni0_debit2         : 1;
-		mmr_t	overflow_ni1_debit0         : 1;
-		mmr_t	overflow_ni1_debit2         : 1;
-		mmr_t	overflow_iilb_debit0        : 1;
-		mmr_t	overflow_iilb_debit2        : 1;
-		mmr_t	underflow_ni0_vc0_credit    : 1;
-		mmr_t	overflow_ni0_vc0_credit     : 1;
-		mmr_t	underflow_ni0_vc2_credit    : 1;
-		mmr_t	overflow_ni0_vc2_credit     : 1;
-		mmr_t	underflow_ni1_vc0_credit    : 1;
-		mmr_t	overflow_ni1_vc0_credit     : 1;
-		mmr_t	underflow_ni1_vc2_credit    : 1;
-		mmr_t	overflow_ni1_vc2_credit     : 1;
-		mmr_t	underflow_iilb_vc0_credit   : 1;
-		mmr_t	overflow_iilb_vc0_credit    : 1;
-		mmr_t	underflow_iilb_vc2_credit   : 1;
-		mmr_t	overflow_iilb_vc2_credit    : 1;
-		mmr_t	overflow_header_cancel_fifo : 1;
-		mmr_t	reserved_0                  : 14;
-	} sh_xnpi_error_overflow_s;
-} sh_xnpi_error_overflow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNPI_ERROR_MASK"                     */
-/* ==================================================================== */
-
-typedef union sh_xnpi_error_mask_u {
-	mmr_t	sh_xnpi_error_mask_regval;
-	struct {
-		mmr_t	underflow_ni0_vc0           : 1;
-		mmr_t	overflow_ni0_vc0            : 1;
-		mmr_t	underflow_ni0_vc2           : 1;
-		mmr_t	overflow_ni0_vc2            : 1;
-		mmr_t	underflow_ni1_vc0           : 1;
-		mmr_t	overflow_ni1_vc0            : 1;
-		mmr_t	underflow_ni1_vc2           : 1;
-		mmr_t	overflow_ni1_vc2            : 1;
-		mmr_t	underflow_iilb_vc0          : 1;
-		mmr_t	overflow_iilb_vc0           : 1;
-		mmr_t	underflow_iilb_vc2          : 1;
-		mmr_t	overflow_iilb_vc2           : 1;
-		mmr_t	underflow_vc0_credit        : 1;
-		mmr_t	overflow_vc0_credit         : 1;
-		mmr_t	underflow_vc2_credit        : 1;
-		mmr_t	overflow_vc2_credit         : 1;
-		mmr_t	overflow_databuff_vc0       : 1;
-		mmr_t	overflow_databuff_vc2       : 1;
-		mmr_t	lut_read_error              : 1;
-		mmr_t	single_bit_error0           : 1;
-		mmr_t	single_bit_error1           : 1;
-		mmr_t	single_bit_error2           : 1;
-		mmr_t	single_bit_error3           : 1;
-		mmr_t	uncor_error0                : 1;
-		mmr_t	uncor_error1                : 1;
-		mmr_t	uncor_error2                : 1;
-		mmr_t	uncor_error3                : 1;
-		mmr_t	underflow_sic_cntr0         : 1;
-		mmr_t	overflow_sic_cntr0          : 1;
-		mmr_t	underflow_sic_cntr2         : 1;
-		mmr_t	overflow_sic_cntr2          : 1;
-		mmr_t	overflow_ni0_debit0         : 1;
-		mmr_t	overflow_ni0_debit2         : 1;
-		mmr_t	overflow_ni1_debit0         : 1;
-		mmr_t	overflow_ni1_debit2         : 1;
-		mmr_t	overflow_iilb_debit0        : 1;
-		mmr_t	overflow_iilb_debit2        : 1;
-		mmr_t	underflow_ni0_vc0_credit    : 1;
-		mmr_t	overflow_ni0_vc0_credit     : 1;
-		mmr_t	underflow_ni0_vc2_credit    : 1;
-		mmr_t	overflow_ni0_vc2_credit     : 1;
-		mmr_t	underflow_ni1_vc0_credit    : 1;
-		mmr_t	overflow_ni1_vc0_credit     : 1;
-		mmr_t	underflow_ni1_vc2_credit    : 1;
-		mmr_t	overflow_ni1_vc2_credit     : 1;
-		mmr_t	underflow_iilb_vc0_credit   : 1;
-		mmr_t	overflow_iilb_vc0_credit    : 1;
-		mmr_t	underflow_iilb_vc2_credit   : 1;
-		mmr_t	overflow_iilb_vc2_credit    : 1;
-		mmr_t	overflow_header_cancel_fifo : 1;
-		mmr_t	reserved_0                  : 14;
-	} sh_xnpi_error_mask_s;
-} sh_xnpi_error_mask_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNPI_FIRST_ERROR"                    */
-/* ==================================================================== */
-
-typedef union sh_xnpi_first_error_u {
-	mmr_t	sh_xnpi_first_error_regval;
-	struct {
-		mmr_t	underflow_ni0_vc0           : 1;
-		mmr_t	overflow_ni0_vc0            : 1;
-		mmr_t	underflow_ni0_vc2           : 1;
-		mmr_t	overflow_ni0_vc2            : 1;
-		mmr_t	underflow_ni1_vc0           : 1;
-		mmr_t	overflow_ni1_vc0            : 1;
-		mmr_t	underflow_ni1_vc2           : 1;
-		mmr_t	overflow_ni1_vc2            : 1;
-		mmr_t	underflow_iilb_vc0          : 1;
-		mmr_t	overflow_iilb_vc0           : 1;
-		mmr_t	underflow_iilb_vc2          : 1;
-		mmr_t	overflow_iilb_vc2           : 1;
-		mmr_t	underflow_vc0_credit        : 1;
-		mmr_t	overflow_vc0_credit         : 1;
-		mmr_t	underflow_vc2_credit        : 1;
-		mmr_t	overflow_vc2_credit         : 1;
-		mmr_t	overflow_databuff_vc0       : 1;
-		mmr_t	overflow_databuff_vc2       : 1;
-		mmr_t	lut_read_error              : 1;
-		mmr_t	single_bit_error0           : 1;
-		mmr_t	single_bit_error1           : 1;
-		mmr_t	single_bit_error2           : 1;
-		mmr_t	single_bit_error3           : 1;
-		mmr_t	uncor_error0                : 1;
-		mmr_t	uncor_error1                : 1;
-		mmr_t	uncor_error2                : 1;
-		mmr_t	uncor_error3                : 1;
-		mmr_t	underflow_sic_cntr0         : 1;
-		mmr_t	overflow_sic_cntr0          : 1;
-		mmr_t	underflow_sic_cntr2         : 1;
-		mmr_t	overflow_sic_cntr2          : 1;
-		mmr_t	overflow_ni0_debit0         : 1;
-		mmr_t	overflow_ni0_debit2         : 1;
-		mmr_t	overflow_ni1_debit0         : 1;
-		mmr_t	overflow_ni1_debit2         : 1;
-		mmr_t	overflow_iilb_debit0        : 1;
-		mmr_t	overflow_iilb_debit2        : 1;
-		mmr_t	underflow_ni0_vc0_credit    : 1;
-		mmr_t	overflow_ni0_vc0_credit     : 1;
-		mmr_t	underflow_ni0_vc2_credit    : 1;
-		mmr_t	overflow_ni0_vc2_credit     : 1;
-		mmr_t	underflow_ni1_vc0_credit    : 1;
-		mmr_t	overflow_ni1_vc0_credit     : 1;
-		mmr_t	underflow_ni1_vc2_credit    : 1;
-		mmr_t	overflow_ni1_vc2_credit     : 1;
-		mmr_t	underflow_iilb_vc0_credit   : 1;
-		mmr_t	overflow_iilb_vc0_credit    : 1;
-		mmr_t	underflow_iilb_vc2_credit   : 1;
-		mmr_t	overflow_iilb_vc2_credit    : 1;
-		mmr_t	overflow_header_cancel_fifo : 1;
-		mmr_t	reserved_0                  : 14;
-	} sh_xnpi_first_error_s;
-} sh_xnpi_first_error_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XNMD_ERROR_SUMMARY"                   */
-/* ==================================================================== */
-
-typedef union sh_xnmd_error_summary_u {
-	mmr_t	sh_xnmd_error_summary_regval;
-	struct {
-		mmr_t	underflow_ni0_vc0           : 1;
-		mmr_t	overflow_ni0_vc0            : 1;
-		mmr_t	underflow_ni0_vc2           : 1;
-		mmr_t	overflow_ni0_vc2            : 1;
-		mmr_t	underflow_ni1_vc0           : 1;
-		mmr_t	overflow_ni1_vc0            : 1;
-		mmr_t	underflow_ni1_vc2           : 1;
-		mmr_t	overflow_ni1_vc2            : 1;
-		mmr_t	underflow_iilb_vc0          : 1;
-		mmr_t	overflow_iilb_vc0           : 1;
-		mmr_t	underflow_iilb_vc2          : 1;
-		mmr_t	overflow_iilb_vc2           : 1;
-		mmr_t	underflow_vc0_credit        : 1;
-		mmr_t	overflow_vc0_credit         : 1;
-		mmr_t	underflow_vc2_credit        : 1;
-		mmr_t	overflow_vc2_credit         : 1;
-		mmr_t	overflow_databuff_vc0       : 1;
-		mmr_t	overflow_databuff_vc2       : 1;
-		mmr_t	lut_read_error              : 1;
-		mmr_t	single_bit_error0           : 1;
-		mmr_t	single_bit_error1           : 1;
-		mmr_t	single_bit_error2           : 1;
-		mmr_t	single_bit_error3           : 1;
-		mmr_t	uncor_error0                : 1;
-		mmr_t	uncor_error1                : 1;
-		mmr_t	uncor_error2                : 1;
-		mmr_t	uncor_error3                : 1;
-		mmr_t	underflow_sic_cntr0         : 1;
-		mmr_t	overflow_sic_cntr0          : 1;
-		mmr_t	underflow_sic_cntr2         : 1;
-		mmr_t	overflow_sic_cntr2          : 1;
-		mmr_t	overflow_ni0_debit0         : 1;
-		mmr_t	overflow_ni0_debit2         : 1;
-		mmr_t	overflow_ni1_debit0         : 1;
-		mmr_t	overflow_ni1_debit2         : 1;
-		mmr_t	overflow_iilb_debit0        : 1;
-		mmr_t	overflow_iilb_debit2        : 1;
-		mmr_t	underflow_ni0_vc0_credit    : 1;
-		mmr_t	overflow_ni0_vc0_credit     : 1;
-		mmr_t	underflow_ni0_vc2_credit    : 1;
-		mmr_t	overflow_ni0_vc2_credit     : 1;
-		mmr_t	underflow_ni1_vc0_credit    : 1;
-		mmr_t	overflow_ni1_vc0_credit     : 1;
-		mmr_t	underflow_ni1_vc2_credit    : 1;
-		mmr_t	overflow_ni1_vc2_credit     : 1;
-		mmr_t	underflow_iilb_vc0_credit   : 1;
-		mmr_t	overflow_iilb_vc0_credit    : 1;
-		mmr_t	underflow_iilb_vc2_credit   : 1;
-		mmr_t	overflow_iilb_vc2_credit    : 1;
-		mmr_t	overflow_header_cancel_fifo : 1;
-		mmr_t	reserved_0                  : 14;
-	} sh_xnmd_error_summary_s;
-} sh_xnmd_error_summary_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XNMD_ERROR_OVERFLOW"                   */
-/* ==================================================================== */
-
-typedef union sh_xnmd_error_overflow_u {
-	mmr_t	sh_xnmd_error_overflow_regval;
-	struct {
-		mmr_t	underflow_ni0_vc0           : 1;
-		mmr_t	overflow_ni0_vc0            : 1;
-		mmr_t	underflow_ni0_vc2           : 1;
-		mmr_t	overflow_ni0_vc2            : 1;
-		mmr_t	underflow_ni1_vc0           : 1;
-		mmr_t	overflow_ni1_vc0            : 1;
-		mmr_t	underflow_ni1_vc2           : 1;
-		mmr_t	overflow_ni1_vc2            : 1;
-		mmr_t	underflow_iilb_vc0          : 1;
-		mmr_t	overflow_iilb_vc0           : 1;
-		mmr_t	underflow_iilb_vc2          : 1;
-		mmr_t	overflow_iilb_vc2           : 1;
-		mmr_t	underflow_vc0_credit        : 1;
-		mmr_t	overflow_vc0_credit         : 1;
-		mmr_t	underflow_vc2_credit        : 1;
-		mmr_t	overflow_vc2_credit         : 1;
-		mmr_t	overflow_databuff_vc0       : 1;
-		mmr_t	overflow_databuff_vc2       : 1;
-		mmr_t	lut_read_error              : 1;
-		mmr_t	single_bit_error0           : 1;
-		mmr_t	single_bit_error1           : 1;
-		mmr_t	single_bit_error2           : 1;
-		mmr_t	single_bit_error3           : 1;
-		mmr_t	uncor_error0                : 1;
-		mmr_t	uncor_error1                : 1;
-		mmr_t	uncor_error2                : 1;
-		mmr_t	uncor_error3                : 1;
-		mmr_t	underflow_sic_cntr0         : 1;
-		mmr_t	overflow_sic_cntr0          : 1;
-		mmr_t	underflow_sic_cntr2         : 1;
-		mmr_t	overflow_sic_cntr2          : 1;
-		mmr_t	overflow_ni0_debit0         : 1;
-		mmr_t	overflow_ni0_debit2         : 1;
-		mmr_t	overflow_ni1_debit0         : 1;
-		mmr_t	overflow_ni1_debit2         : 1;
-		mmr_t	overflow_iilb_debit0        : 1;
-		mmr_t	overflow_iilb_debit2        : 1;
-		mmr_t	underflow_ni0_vc0_credit    : 1;
-		mmr_t	overflow_ni0_vc0_credit     : 1;
-		mmr_t	underflow_ni0_vc2_credit    : 1;
-		mmr_t	overflow_ni0_vc2_credit     : 1;
-		mmr_t	underflow_ni1_vc0_credit    : 1;
-		mmr_t	overflow_ni1_vc0_credit     : 1;
-		mmr_t	underflow_ni1_vc2_credit    : 1;
-		mmr_t	overflow_ni1_vc2_credit     : 1;
-		mmr_t	underflow_iilb_vc0_credit   : 1;
-		mmr_t	overflow_iilb_vc0_credit    : 1;
-		mmr_t	underflow_iilb_vc2_credit   : 1;
-		mmr_t	overflow_iilb_vc2_credit    : 1;
-		mmr_t	overflow_header_cancel_fifo : 1;
-		mmr_t	reserved_0                  : 14;
-	} sh_xnmd_error_overflow_s;
-} sh_xnmd_error_overflow_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNMD_ERROR_MASK"                     */
-/* ==================================================================== */
-
-typedef union sh_xnmd_error_mask_u {
-	mmr_t	sh_xnmd_error_mask_regval;
-	struct {
-		mmr_t	underflow_ni0_vc0           : 1;
-		mmr_t	overflow_ni0_vc0            : 1;
-		mmr_t	underflow_ni0_vc2           : 1;
-		mmr_t	overflow_ni0_vc2            : 1;
-		mmr_t	underflow_ni1_vc0           : 1;
-		mmr_t	overflow_ni1_vc0            : 1;
-		mmr_t	underflow_ni1_vc2           : 1;
-		mmr_t	overflow_ni1_vc2            : 1;
-		mmr_t	underflow_iilb_vc0          : 1;
-		mmr_t	overflow_iilb_vc0           : 1;
-		mmr_t	underflow_iilb_vc2          : 1;
-		mmr_t	overflow_iilb_vc2           : 1;
-		mmr_t	underflow_vc0_credit        : 1;
-		mmr_t	overflow_vc0_credit         : 1;
-		mmr_t	underflow_vc2_credit        : 1;
-		mmr_t	overflow_vc2_credit         : 1;
-		mmr_t	overflow_databuff_vc0       : 1;
-		mmr_t	overflow_databuff_vc2       : 1;
-		mmr_t	lut_read_error              : 1;
-		mmr_t	single_bit_error0           : 1;
-		mmr_t	single_bit_error1           : 1;
-		mmr_t	single_bit_error2           : 1;
-		mmr_t	single_bit_error3           : 1;
-		mmr_t	uncor_error0                : 1;
-		mmr_t	uncor_error1                : 1;
-		mmr_t	uncor_error2                : 1;
-		mmr_t	uncor_error3                : 1;
-		mmr_t	underflow_sic_cntr0         : 1;
-		mmr_t	overflow_sic_cntr0          : 1;
-		mmr_t	underflow_sic_cntr2         : 1;
-		mmr_t	overflow_sic_cntr2          : 1;
-		mmr_t	overflow_ni0_debit0         : 1;
-		mmr_t	overflow_ni0_debit2         : 1;
-		mmr_t	overflow_ni1_debit0         : 1;
-		mmr_t	overflow_ni1_debit2         : 1;
-		mmr_t	overflow_iilb_debit0        : 1;
-		mmr_t	overflow_iilb_debit2        : 1;
-		mmr_t	underflow_ni0_vc0_credit    : 1;
-		mmr_t	overflow_ni0_vc0_credit     : 1;
-		mmr_t	underflow_ni0_vc2_credit    : 1;
-		mmr_t	overflow_ni0_vc2_credit     : 1;
-		mmr_t	underflow_ni1_vc0_credit    : 1;
-		mmr_t	overflow_ni1_vc0_credit     : 1;
-		mmr_t	underflow_ni1_vc2_credit    : 1;
-		mmr_t	overflow_ni1_vc2_credit     : 1;
-		mmr_t	underflow_iilb_vc0_credit   : 1;
-		mmr_t	overflow_iilb_vc0_credit    : 1;
-		mmr_t	underflow_iilb_vc2_credit   : 1;
-		mmr_t	overflow_iilb_vc2_credit    : 1;
-		mmr_t	overflow_header_cancel_fifo : 1;
-		mmr_t	reserved_0                  : 14;
-	} sh_xnmd_error_mask_s;
-} sh_xnmd_error_mask_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XNMD_FIRST_ERROR"                    */
-/* ==================================================================== */
-
-typedef union sh_xnmd_first_error_u {
-	mmr_t	sh_xnmd_first_error_regval;
-	struct {
-		mmr_t	underflow_ni0_vc0           : 1;
-		mmr_t	overflow_ni0_vc0            : 1;
-		mmr_t	underflow_ni0_vc2           : 1;
-		mmr_t	overflow_ni0_vc2            : 1;
-		mmr_t	underflow_ni1_vc0           : 1;
-		mmr_t	overflow_ni1_vc0            : 1;
-		mmr_t	underflow_ni1_vc2           : 1;
-		mmr_t	overflow_ni1_vc2            : 1;
-		mmr_t	underflow_iilb_vc0          : 1;
-		mmr_t	overflow_iilb_vc0           : 1;
-		mmr_t	underflow_iilb_vc2          : 1;
-		mmr_t	overflow_iilb_vc2           : 1;
-		mmr_t	underflow_vc0_credit        : 1;
-		mmr_t	overflow_vc0_credit         : 1;
-		mmr_t	underflow_vc2_credit        : 1;
-		mmr_t	overflow_vc2_credit         : 1;
-		mmr_t	overflow_databuff_vc0       : 1;
-		mmr_t	overflow_databuff_vc2       : 1;
-		mmr_t	lut_read_error              : 1;
-		mmr_t	single_bit_error0           : 1;
-		mmr_t	single_bit_error1           : 1;
-		mmr_t	single_bit_error2           : 1;
-		mmr_t	single_bit_error3           : 1;
-		mmr_t	uncor_error0                : 1;
-		mmr_t	uncor_error1                : 1;
-		mmr_t	uncor_error2                : 1;
-		mmr_t	uncor_error3                : 1;
-		mmr_t	underflow_sic_cntr0         : 1;
-		mmr_t	overflow_sic_cntr0          : 1;
-		mmr_t	underflow_sic_cntr2         : 1;
-		mmr_t	overflow_sic_cntr2          : 1;
-		mmr_t	overflow_ni0_debit0         : 1;
-		mmr_t	overflow_ni0_debit2         : 1;
-		mmr_t	overflow_ni1_debit0         : 1;
-		mmr_t	overflow_ni1_debit2         : 1;
-		mmr_t	overflow_iilb_debit0        : 1;
-		mmr_t	overflow_iilb_debit2        : 1;
-		mmr_t	underflow_ni0_vc0_credit    : 1;
-		mmr_t	overflow_ni0_vc0_credit     : 1;
-		mmr_t	underflow_ni0_vc2_credit    : 1;
-		mmr_t	overflow_ni0_vc2_credit     : 1;
-		mmr_t	underflow_ni1_vc0_credit    : 1;
-		mmr_t	overflow_ni1_vc0_credit     : 1;
-		mmr_t	underflow_ni1_vc2_credit    : 1;
-		mmr_t	overflow_ni1_vc2_credit     : 1;
-		mmr_t	underflow_iilb_vc0_credit   : 1;
-		mmr_t	overflow_iilb_vc0_credit    : 1;
-		mmr_t	underflow_iilb_vc2_credit   : 1;
-		mmr_t	overflow_iilb_vc2_credit    : 1;
-		mmr_t	overflow_header_cancel_fifo : 1;
-		mmr_t	reserved_0                  : 14;
-	} sh_xnmd_first_error_s;
-} sh_xnmd_first_error_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_AUTO_REPLY_ENABLE0"                   */
-/*                 Automatic Maintenance Reply Enable 0                 */
-/* ==================================================================== */
-
-typedef union sh_auto_reply_enable0_u {
-	mmr_t	sh_auto_reply_enable0_regval;
-	struct {
-		mmr_t	enable0     : 64;
-	} sh_auto_reply_enable0_s;
-} sh_auto_reply_enable0_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_AUTO_REPLY_ENABLE1"                   */
-/*                 Automatic Maintenance Reply Enable 1                 */
-/* ==================================================================== */
-
-typedef union sh_auto_reply_enable1_u {
-	mmr_t	sh_auto_reply_enable1_regval;
-	struct {
-		mmr_t	enable1     : 64;
-	} sh_auto_reply_enable1_s;
-} sh_auto_reply_enable1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_AUTO_REPLY_HEADER0"                   */
-/*                 Automatic Maintenance Reply Header 0                 */
-/* ==================================================================== */
-
-typedef union sh_auto_reply_header0_u {
-	mmr_t	sh_auto_reply_header0_regval;
-	struct {
-		mmr_t	header0     : 64;
-	} sh_auto_reply_header0_s;
-} sh_auto_reply_header0_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_AUTO_REPLY_HEADER1"                   */
-/*                 Automatic Maintenance Reply Header 1                 */
-/* ==================================================================== */
-
-typedef union sh_auto_reply_header1_u {
-	mmr_t	sh_auto_reply_header1_regval;
-	struct {
-		mmr_t	header1     : 64;
-	} sh_auto_reply_header1_s;
-} sh_auto_reply_header1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_ENABLE_RP_AUTO_REPLY"                  */
-/*         Enable Automatic Maintenance Reply From Reply Queue          */
-/* ==================================================================== */
-
-typedef union sh_enable_rp_auto_reply_u {
-	mmr_t	sh_enable_rp_auto_reply_regval;
-	struct {
-		mmr_t	enable      : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_enable_rp_auto_reply_s;
-} sh_enable_rp_auto_reply_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_ENABLE_RQ_AUTO_REPLY"                  */
-/*        Enable Automatic Maintenance Reply From Request Queue         */
-/* ==================================================================== */
-
-typedef union sh_enable_rq_auto_reply_u {
-	mmr_t	sh_enable_rq_auto_reply_regval;
-	struct {
-		mmr_t	enable      : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_enable_rq_auto_reply_s;
-} sh_enable_rq_auto_reply_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_REDIRECT_INVAL"                     */
-/*               Redirect invalidate to LB instead of PI                */
-/* ==================================================================== */
-
-typedef union sh_redirect_inval_u {
-	mmr_t	sh_redirect_inval_regval;
-	struct {
-		mmr_t	redirect    : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_redirect_inval_s;
-} sh_redirect_inval_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_DIAG_MSG_CNTRL"                     */
-/*                 Diagnostic Message Control Register                  */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_cntrl_u {
-	mmr_t	sh_diag_msg_cntrl_regval;
-	struct {
-		mmr_t	msg_length          : 6;
-		mmr_t	error_inject_point  : 6;
-		mmr_t	error_inject_enable : 1;
-		mmr_t	port                : 1;
-		mmr_t	reserved_0          : 48;
-		mmr_t	start               : 1;
-		mmr_t	busy                : 1;
-	} sh_diag_msg_cntrl_s;
-} sh_diag_msg_cntrl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA0L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data0l_u {
-	mmr_t	sh_diag_msg_data0l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data0l_s;
-} sh_diag_msg_data0l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA0U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data0u_u {
-	mmr_t	sh_diag_msg_data0u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data0u_s;
-} sh_diag_msg_data0u_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA1L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data1l_u {
-	mmr_t	sh_diag_msg_data1l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data1l_s;
-} sh_diag_msg_data1l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA1U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data1u_u {
-	mmr_t	sh_diag_msg_data1u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data1u_s;
-} sh_diag_msg_data1u_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA2L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data2l_u {
-	mmr_t	sh_diag_msg_data2l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data2l_s;
-} sh_diag_msg_data2l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA2U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data2u_u {
-	mmr_t	sh_diag_msg_data2u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data2u_s;
-} sh_diag_msg_data2u_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA3L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data3l_u {
-	mmr_t	sh_diag_msg_data3l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data3l_s;
-} sh_diag_msg_data3l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA3U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data3u_u {
-	mmr_t	sh_diag_msg_data3u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data3u_s;
-} sh_diag_msg_data3u_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA4L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data4l_u {
-	mmr_t	sh_diag_msg_data4l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data4l_s;
-} sh_diag_msg_data4l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA4U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data4u_u {
-	mmr_t	sh_diag_msg_data4u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data4u_s;
-} sh_diag_msg_data4u_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA5L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data5l_u {
-	mmr_t	sh_diag_msg_data5l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data5l_s;
-} sh_diag_msg_data5l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA5U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data5u_u {
-	mmr_t	sh_diag_msg_data5u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data5u_s;
-} sh_diag_msg_data5u_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA6L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data6l_u {
-	mmr_t	sh_diag_msg_data6l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data6l_s;
-} sh_diag_msg_data6l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA6U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data6u_u {
-	mmr_t	sh_diag_msg_data6u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data6u_s;
-} sh_diag_msg_data6u_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA7L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data7l_u {
-	mmr_t	sh_diag_msg_data7l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data7l_s;
-} sh_diag_msg_data7l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA7U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data7u_u {
-	mmr_t	sh_diag_msg_data7u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data7u_s;
-} sh_diag_msg_data7u_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA8L"                     */
-/*                    Diagnostic Data, lower 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data8l_u {
-	mmr_t	sh_diag_msg_data8l_regval;
-	struct {
-		mmr_t	data_lower  : 64;
-	} sh_diag_msg_data8l_s;
-} sh_diag_msg_data8l_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_DIAG_MSG_DATA8U"                     */
-/*                   Diagnostice Data, upper 64 bits                    */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_data8u_u {
-	mmr_t	sh_diag_msg_data8u_regval;
-	struct {
-		mmr_t	data_upper  : 64;
-	} sh_diag_msg_data8u_s;
-} sh_diag_msg_data8u_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_DIAG_MSG_HDR0"                      */
-/*              Diagnostice Data, lower 64 bits of header               */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_hdr0_u {
-	mmr_t	sh_diag_msg_hdr0_regval;
-	struct {
-		mmr_t	header0     : 64;
-	} sh_diag_msg_hdr0_s;
-} sh_diag_msg_hdr0_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_DIAG_MSG_HDR1"                      */
-/*              Diagnostice Data, upper 64 bits of header               */
-/* ==================================================================== */
-
-typedef union sh_diag_msg_hdr1_u {
-	mmr_t	sh_diag_msg_hdr1_regval;
-	struct {
-		mmr_t	header1     : 64;
-	} sh_diag_msg_hdr1_s;
-} sh_diag_msg_hdr1_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_DEBUG_SELECT"                      */
-/*                        SHub Debug Port Select                        */
-/* ==================================================================== */
-
-typedef union sh_debug_select_u {
-	mmr_t	sh_debug_select_regval;
-	struct {
-		mmr_t	nibble0_nibble_sel  : 3;
-		mmr_t	nibble0_chiplet_sel : 3;
-		mmr_t	nibble1_nibble_sel  : 3;
-		mmr_t	nibble1_chiplet_sel : 3;
-		mmr_t	nibble2_nibble_sel  : 3;
-		mmr_t	nibble2_chiplet_sel : 3;
-		mmr_t	nibble3_nibble_sel  : 3;
-		mmr_t	nibble3_chiplet_sel : 3;
-		mmr_t	nibble4_nibble_sel  : 3;
-		mmr_t	nibble4_chiplet_sel : 3;
-		mmr_t	nibble5_nibble_sel  : 3;
-		mmr_t	nibble5_chiplet_sel : 3;
-		mmr_t	nibble6_nibble_sel  : 3;
-		mmr_t	nibble6_chiplet_sel : 3;
-		mmr_t	nibble7_nibble_sel  : 3;
-		mmr_t	nibble7_chiplet_sel : 3;
-		mmr_t	debug_ii_sel        : 3;
-		mmr_t	sel_ii              : 9;
-		mmr_t	reserved_0          : 3;
-		mmr_t	trigger_enable      : 1;
-	} sh_debug_select_s;
-} sh_debug_select_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_TRIGGER_COMPARE_MASK"                  */
-/*                      SHub Trigger Compare Mask                       */
-/* ==================================================================== */
-
-typedef union sh_trigger_compare_mask_u {
-	mmr_t	sh_trigger_compare_mask_regval;
-	struct {
-		mmr_t	mask        : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_trigger_compare_mask_s;
-} sh_trigger_compare_mask_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_TRIGGER_COMPARE_PATTERN"                 */
-/*                     SHub Trigger Compare Pattern                     */
-/* ==================================================================== */
-
-typedef union sh_trigger_compare_pattern_u {
-	mmr_t	sh_trigger_compare_pattern_regval;
-	struct {
-		mmr_t	data        : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_trigger_compare_pattern_s;
-} sh_trigger_compare_pattern_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_TRIGGER_SEL"                       */
-/*                  Trigger select for SHUB debug port                  */
-/* ==================================================================== */
-
-typedef union sh_trigger_sel_u {
-	mmr_t	sh_trigger_sel_regval;
-	struct {
-		mmr_t	nibble0_input_sel  : 3;
-		mmr_t	reserved_0         : 1;
-		mmr_t	nibble0_nibble_sel : 3;
-		mmr_t	reserved_1         : 1;
-		mmr_t	nibble1_input_sel  : 3;
-		mmr_t	reserved_2         : 1;
-		mmr_t	nibble1_nibble_sel : 3;
-		mmr_t	reserved_3         : 1;
-		mmr_t	nibble2_input_sel  : 3;
-		mmr_t	reserved_4         : 1;
-		mmr_t	nibble2_nibble_sel : 3;
-		mmr_t	reserved_5         : 1;
-		mmr_t	nibble3_input_sel  : 3;
-		mmr_t	reserved_6         : 1;
-		mmr_t	nibble3_nibble_sel : 3;
-		mmr_t	reserved_7         : 1;
-		mmr_t	nibble4_input_sel  : 3;
-		mmr_t	reserved_8         : 1;
-		mmr_t	nibble4_nibble_sel : 3;
-		mmr_t	reserved_9         : 1;
-		mmr_t	nibble5_input_sel  : 3;
-		mmr_t	reserved_10        : 1;
-		mmr_t	nibble5_nibble_sel : 3;
-		mmr_t	reserved_11        : 1;
-		mmr_t	nibble6_input_sel  : 3;
-		mmr_t	reserved_12        : 1;
-		mmr_t	nibble6_nibble_sel : 3;
-		mmr_t	reserved_13        : 1;
-		mmr_t	nibble7_input_sel  : 3;
-		mmr_t	reserved_14        : 1;
-		mmr_t	nibble7_nibble_sel : 3;
-		mmr_t	reserved_15        : 1;
-	} sh_trigger_sel_s;
-} sh_trigger_sel_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_STOP_CLK_CONTROL"                    */
-/*                          Stop Clock Control                          */
-/* ==================================================================== */
-
-typedef union sh_stop_clk_control_u {
-	mmr_t	sh_stop_clk_control_regval;
-	struct {
-		mmr_t	stimulus    : 5;
-		mmr_t	event       : 1;
-		mmr_t	polarity    : 1;
-		mmr_t	mode        : 1;
-		mmr_t	reserved_0  : 56;
-	} sh_stop_clk_control_s;
-} sh_stop_clk_control_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_STOP_CLK_DELAY_PHASE"                  */
-/*                        Stop Clock Delay Phase                        */
-/* ==================================================================== */
-
-typedef union sh_stop_clk_delay_phase_u {
-	mmr_t	sh_stop_clk_delay_phase_regval;
-	struct {
-		mmr_t	delay       : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_stop_clk_delay_phase_s;
-} sh_stop_clk_delay_phase_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_TSF_ARM_MASK"                      */
-/*                 Trigger sequencing facility arm mask                 */
-/* ==================================================================== */
-
-typedef union sh_tsf_arm_mask_u {
-	mmr_t	sh_tsf_arm_mask_regval;
-	struct {
-		mmr_t	mask        : 64;
-	} sh_tsf_arm_mask_s;
-} sh_tsf_arm_mask_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_TSF_COUNTER_PRESETS"                   */
-/*             Trigger sequencing facility counter presets              */
-/* ==================================================================== */
-
-typedef union sh_tsf_counter_presets_u {
-	mmr_t	sh_tsf_counter_presets_regval;
-	struct {
-		mmr_t	count_32    : 32;
-		mmr_t	count_16    : 16;
-		mmr_t	count_8b    : 8;
-		mmr_t	count_8a    : 8;
-	} sh_tsf_counter_presets_s;
-} sh_tsf_counter_presets_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_TSF_DECREMENT_CTL"                    */
-/*        Trigger sequencing facility counter decrement control         */
-/* ==================================================================== */
-
-typedef union sh_tsf_decrement_ctl_u {
-	mmr_t	sh_tsf_decrement_ctl_regval;
-	struct {
-		mmr_t	ctl         : 16;
-		mmr_t	reserved_0  : 48;
-	} sh_tsf_decrement_ctl_s;
-} sh_tsf_decrement_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_DIAG_MSG_CTL"                    */
-/*        Trigger sequencing facility diagnostic message control        */
-/* ==================================================================== */
-
-typedef union sh_tsf_diag_msg_ctl_u {
-	mmr_t	sh_tsf_diag_msg_ctl_regval;
-	struct {
-		mmr_t	enable      : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_tsf_diag_msg_ctl_s;
-} sh_tsf_diag_msg_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_DISARM_MASK"                     */
-/*               Trigger sequencing facility disarm mask                */
-/* ==================================================================== */
-
-typedef union sh_tsf_disarm_mask_u {
-	mmr_t	sh_tsf_disarm_mask_regval;
-	struct {
-		mmr_t	mask        : 64;
-	} sh_tsf_disarm_mask_s;
-} sh_tsf_disarm_mask_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_TSF_ENABLE_CTL"                     */
-/*          Trigger sequencing facility counter enable control          */
-/* ==================================================================== */
-
-typedef union sh_tsf_enable_ctl_u {
-	mmr_t	sh_tsf_enable_ctl_regval;
-	struct {
-		mmr_t	ctl         : 16;
-		mmr_t	reserved_0  : 48;
-	} sh_tsf_enable_ctl_s;
-} sh_tsf_enable_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_SOFTWARE_ARM"                    */
-/*               Trigger sequencing facility software arm               */
-/* ==================================================================== */
-
-typedef union sh_tsf_software_arm_u {
-	mmr_t	sh_tsf_software_arm_regval;
-	struct {
-		mmr_t	bit0        : 1;
-		mmr_t	bit1        : 1;
-		mmr_t	bit2        : 1;
-		mmr_t	bit3        : 1;
-		mmr_t	bit4        : 1;
-		mmr_t	bit5        : 1;
-		mmr_t	bit6        : 1;
-		mmr_t	bit7        : 1;
-		mmr_t	reserved_0  : 56;
-	} sh_tsf_software_arm_s;
-} sh_tsf_software_arm_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_TSF_SOFTWARE_DISARM"                   */
-/*             Trigger sequencing facility software disarm              */
-/* ==================================================================== */
-
-typedef union sh_tsf_software_disarm_u {
-	mmr_t	sh_tsf_software_disarm_regval;
-	struct {
-		mmr_t	bit0        : 1;
-		mmr_t	bit1        : 1;
-		mmr_t	bit2        : 1;
-		mmr_t	bit3        : 1;
-		mmr_t	bit4        : 1;
-		mmr_t	bit5        : 1;
-		mmr_t	bit6        : 1;
-		mmr_t	bit7        : 1;
-		mmr_t	reserved_0  : 56;
-	} sh_tsf_software_disarm_s;
-} sh_tsf_software_disarm_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_TSF_SOFTWARE_TRIGGERED"                 */
-/*            Trigger sequencing facility software triggered            */
-/* ==================================================================== */
-
-typedef union sh_tsf_software_triggered_u {
-	mmr_t	sh_tsf_software_triggered_regval;
-	struct {
-		mmr_t	bit0        : 1;
-		mmr_t	bit1        : 1;
-		mmr_t	bit2        : 1;
-		mmr_t	bit3        : 1;
-		mmr_t	bit4        : 1;
-		mmr_t	bit5        : 1;
-		mmr_t	bit6        : 1;
-		mmr_t	bit7        : 1;
-		mmr_t	reserved_0  : 56;
-	} sh_tsf_software_triggered_s;
-} sh_tsf_software_triggered_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_TRIGGER_MASK"                    */
-/*               Trigger sequencing facility trigger mask               */
-/* ==================================================================== */
-
-typedef union sh_tsf_trigger_mask_u {
-	mmr_t	sh_tsf_trigger_mask_regval;
-	struct {
-		mmr_t	mask        : 64;
-	} sh_tsf_trigger_mask_s;
-} sh_tsf_trigger_mask_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_VEC_DATA"                        */
-/*                  Vector Write Request Message Data                   */
-/* ==================================================================== */
-
-typedef union sh_vec_data_u {
-	mmr_t	sh_vec_data_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_vec_data_s;
-} sh_vec_data_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_PARMS"                        */
-/*                  Vector Message Parameters Register                  */
-/* ==================================================================== */
-
-typedef union sh_vec_parms_u {
-	mmr_t	sh_vec_parms_regval;
-	struct {
-		mmr_t	type        : 1;
-		mmr_t	ni_port     : 1;
-		mmr_t	reserved_0  : 1;
-		mmr_t	address     : 32;
-		mmr_t	pio_id      : 11;
-		mmr_t	reserved_1  : 16;
-		mmr_t	start       : 1;
-		mmr_t	busy        : 1;
-	} sh_vec_parms_s;
-} sh_vec_parms_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_ROUTE"                        */
-/*                     Vector Request Message Route                     */
-/* ==================================================================== */
-
-typedef union sh_vec_route_u {
-	mmr_t	sh_vec_route_regval;
-	struct {
-		mmr_t	route       : 64;
-	} sh_vec_route_s;
-} sh_vec_route_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_CPU_PERM"                        */
-/*                    CPU MMR Access Permission Bits                    */
-/* ==================================================================== */
-
-typedef union sh_cpu_perm_u {
-	mmr_t	sh_cpu_perm_regval;
-	struct {
-		mmr_t	access_bits : 64;
-	} sh_cpu_perm_s;
-} sh_cpu_perm_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_CPU_PERM_OVR"                      */
-/*                  CPU MMR Access Permission Override                  */
-/* ==================================================================== */
-
-typedef union sh_cpu_perm_ovr_u {
-	mmr_t	sh_cpu_perm_ovr_regval;
-	struct {
-		mmr_t	override    : 64;
-	} sh_cpu_perm_ovr_s;
-} sh_cpu_perm_ovr_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_EXT_IO_PERM"                       */
-/*                External IO MMR Access Permission Bits                */
-/* ==================================================================== */
-
-typedef union sh_ext_io_perm_u {
-	mmr_t	sh_ext_io_perm_regval;
-	struct {
-		mmr_t	access_bits : 64;
-	} sh_ext_io_perm_s;
-} sh_ext_io_perm_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_EXT_IOI_ACCESS"                     */
-/*             External IO Interrupt Access Permission Bits             */
-/* ==================================================================== */
-
-typedef union sh_ext_ioi_access_u {
-	mmr_t	sh_ext_ioi_access_regval;
-	struct {
-		mmr_t	access_bits : 64;
-	} sh_ext_ioi_access_s;
-} sh_ext_ioi_access_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_GC_FIL_CTRL"                       */
-/*                   SHub Global Clock Filter Control                   */
-/* ==================================================================== */
-
-typedef union sh_gc_fil_ctrl_u {
-	mmr_t	sh_gc_fil_ctrl_regval;
-	struct {
-		mmr_t	offset          : 5;
-		mmr_t	reserved_0      : 3;
-		mmr_t	mask_counter    : 12;
-		mmr_t	mask_enable     : 1;
-		mmr_t	reserved_1      : 3;
-		mmr_t	dropout_counter : 10;
-		mmr_t	reserved_2      : 2;
-		mmr_t	dropout_thresh  : 10;
-		mmr_t	reserved_3      : 2;
-		mmr_t	error_counter   : 10;
-		mmr_t	reserved_4      : 6;
-	} sh_gc_fil_ctrl_s;
-} sh_gc_fil_ctrl_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_GC_SRC_CTRL"                       */
-/*                      SHub Global Clock Control                       */
-/* ==================================================================== */
-
-typedef union sh_gc_src_ctrl_u {
-	mmr_t	sh_gc_src_ctrl_regval;
-	struct {
-		mmr_t	enable_counter : 1;
-		mmr_t	reserved_0     : 3;
-		mmr_t	max_count      : 10;
-		mmr_t	reserved_1     : 2;
-		mmr_t	counter        : 10;
-		mmr_t	reserved_2     : 2;
-		mmr_t	toggle_bit     : 1;
-		mmr_t	reserved_3     : 3;
-		mmr_t	source_sel     : 2;
-		mmr_t	reserved_4     : 30;
-	} sh_gc_src_ctrl_s;
-} sh_gc_src_ctrl_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_HARD_RESET"                       */
-/*                           SHub Hard Reset                            */
-/* ==================================================================== */
-
-typedef union sh_hard_reset_u {
-	mmr_t	sh_hard_reset_regval;
-	struct {
-		mmr_t	hard_reset  : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_hard_reset_s;
-} sh_hard_reset_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_IO_PERM"                         */
-/*                    II MMR Access Permission Bits                     */
-/* ==================================================================== */
-
-typedef union sh_io_perm_u {
-	mmr_t	sh_io_perm_regval;
-	struct {
-		mmr_t	access_bits : 64;
-	} sh_io_perm_s;
-} sh_io_perm_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_IOI_ACCESS"                       */
-/*                 II Interrupt Access Permission Bits                  */
-/* ==================================================================== */
-
-typedef union sh_ioi_access_u {
-	mmr_t	sh_ioi_access_regval;
-	struct {
-		mmr_t	access_bits : 64;
-	} sh_ioi_access_s;
-} sh_ioi_access_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_IPI_ACCESS"                       */
-/*                 CPU interrupt Access Permission Bits                 */
-/* ==================================================================== */
-
-typedef union sh_ipi_access_u {
-	mmr_t	sh_ipi_access_regval;
-	struct {
-		mmr_t	access_bits : 64;
-	} sh_ipi_access_s;
-} sh_ipi_access_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_JTAG_CONFIG"                       */
-/*                       SHub JTAG configuration                        */
-/* ==================================================================== */
-
-typedef union sh_jtag_config_u {
-	mmr_t	sh_jtag_config_regval;
-	struct {
-		mmr_t	md_clk_sel                    : 2;
-		mmr_t	ni_clk_sel                    : 1;
-		mmr_t	ii_clk_sel                    : 2;
-		mmr_t	wrt90_target                  : 14;
-		mmr_t	wrt90_overrider               : 1;
-		mmr_t	wrt90_override                : 1;
-		mmr_t	jtag_mci_reset_delay          : 4;
-		mmr_t	jtag_mci_target               : 14;
-		mmr_t	jtag_mci_override             : 1;
-		mmr_t	fsb_config_ioq_depth          : 1;
-		mmr_t	fsb_config_sample_binit       : 1;
-		mmr_t	fsb_config_enable_bus_parking : 1;
-		mmr_t	fsb_config_clock_ratio        : 5;
-		mmr_t	fsb_config_output_tristate    : 4;
-		mmr_t	fsb_config_enable_bist        : 1;
-		mmr_t	fsb_config_aux                : 2;
-		mmr_t	gtl_config_re                 : 1;
-		mmr_t	reserved_0                    : 8;
-	} sh_jtag_config_s;
-} sh_jtag_config_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_SHUB_ID"                         */
-/*                            SHub ID Number                            */
-/* ==================================================================== */
-
-typedef union sh_shub_id_u {
-	mmr_t	sh_shub_id_regval;
-	struct {
-		mmr_t	force1        : 1;
-		mmr_t	manufacturer  : 11;
-		mmr_t	part_number   : 16;
-		mmr_t	revision      : 4;
-		mmr_t	node_id       : 11;
-		mmr_t	reserved_0    : 1;
-		mmr_t	sharing_mode  : 2;
-		mmr_t	reserved_1    : 2;
-		mmr_t	nodes_per_bit : 5;
-		mmr_t	reserved_2    : 3;
-		mmr_t	ni_port       : 1;
-		mmr_t	reserved_3    : 7;
-	} sh_shub_id_s;
-} sh_shub_id_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_SHUBS_PRESENT0"                     */
-/*         Shubs 0 - 63 Present. Used for invalidate generation         */
-/* ==================================================================== */
-
-typedef union sh_shubs_present0_u {
-	mmr_t	sh_shubs_present0_regval;
-	struct {
-		mmr_t	shubs_present0 : 64;
-	} sh_shubs_present0_s;
-} sh_shubs_present0_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_SHUBS_PRESENT1"                     */
-/*        Shubs 64 - 127 Present. Used for invalidate generation        */
-/* ==================================================================== */
-
-typedef union sh_shubs_present1_u {
-	mmr_t	sh_shubs_present1_regval;
-	struct {
-		mmr_t	shubs_present1 : 64;
-	} sh_shubs_present1_s;
-} sh_shubs_present1_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_SHUBS_PRESENT2"                     */
-/*       Shubs 128 - 191 Present. Used for invalidate generation        */
-/* ==================================================================== */
-
-typedef union sh_shubs_present2_u {
-	mmr_t	sh_shubs_present2_regval;
-	struct {
-		mmr_t	shubs_present2 : 64;
-	} sh_shubs_present2_s;
-} sh_shubs_present2_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_SHUBS_PRESENT3"                     */
-/*       Shubs 192 - 255 Present. Used for invalidate generation        */
-/* ==================================================================== */
-
-typedef union sh_shubs_present3_u {
-	mmr_t	sh_shubs_present3_regval;
-	struct {
-		mmr_t	shubs_present3 : 64;
-	} sh_shubs_present3_s;
-} sh_shubs_present3_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_SOFT_RESET"                       */
-/*                           SHub Soft Reset                            */
-/* ==================================================================== */
-
-typedef union sh_soft_reset_u {
-	mmr_t	sh_soft_reset_regval;
-	struct {
-		mmr_t	soft_reset  : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_soft_reset_s;
-} sh_soft_reset_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_FIRST_ERROR"                       */
-/*                    Shub Global First Error Flags                     */
-/* ==================================================================== */
-
-typedef union sh_first_error_u {
-	mmr_t	sh_first_error_regval;
-	struct {
-		mmr_t	first_error : 19;
-		mmr_t	reserved_0  : 45;
-	} sh_first_error_s;
-} sh_first_error_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_II_HW_TIME_STAMP"                    */
-/*                     II hardware error time stamp                     */
-/* ==================================================================== */
-
-typedef union sh_ii_hw_time_stamp_u {
-	mmr_t	sh_ii_hw_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_ii_hw_time_stamp_s;
-} sh_ii_hw_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_LB_HW_TIME_STAMP"                    */
-/*                     LB hardware error time stamp                     */
-/* ==================================================================== */
-
-typedef union sh_lb_hw_time_stamp_u {
-	mmr_t	sh_lb_hw_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_lb_hw_time_stamp_s;
-} sh_lb_hw_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_COR_TIME_STAMP"                    */
-/*                   MD correctable error time stamp                    */
-/* ==================================================================== */
-
-typedef union sh_md_cor_time_stamp_u {
-	mmr_t	sh_md_cor_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_md_cor_time_stamp_s;
-} sh_md_cor_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_MD_HW_TIME_STAMP"                    */
-/*                     MD hardware error time stamp                     */
-/* ==================================================================== */
-
-typedef union sh_md_hw_time_stamp_u {
-	mmr_t	sh_md_hw_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_md_hw_time_stamp_s;
-} sh_md_hw_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_UNCOR_TIME_STAMP"                   */
-/*                  MD uncorrectable error time stamp                   */
-/* ==================================================================== */
-
-typedef union sh_md_uncor_time_stamp_u {
-	mmr_t	sh_md_uncor_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_md_uncor_time_stamp_s;
-} sh_md_uncor_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PI_COR_TIME_STAMP"                    */
-/*                   PI correctable error time stamp                    */
-/* ==================================================================== */
-
-typedef union sh_pi_cor_time_stamp_u {
-	mmr_t	sh_pi_cor_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_pi_cor_time_stamp_s;
-} sh_pi_cor_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_PI_HW_TIME_STAMP"                    */
-/*                     PI hardware error time stamp                     */
-/* ==================================================================== */
-
-typedef union sh_pi_hw_time_stamp_u {
-	mmr_t	sh_pi_hw_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_pi_hw_time_stamp_s;
-} sh_pi_hw_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PI_UNCOR_TIME_STAMP"                   */
-/*                  PI uncorrectable error time stamp                   */
-/* ==================================================================== */
-
-typedef union sh_pi_uncor_time_stamp_u {
-	mmr_t	sh_pi_uncor_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_pi_uncor_time_stamp_s;
-} sh_pi_uncor_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ADV_TIME_STAMP"                  */
-/*                      Proc 0 advisory time stamp                      */
-/* ==================================================================== */
-
-typedef union sh_proc0_adv_time_stamp_u {
-	mmr_t	sh_proc0_adv_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_proc0_adv_time_stamp_s;
-} sh_proc0_adv_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC0_ERR_TIME_STAMP"                  */
-/*                       Proc 0 error time stamp                        */
-/* ==================================================================== */
-
-typedef union sh_proc0_err_time_stamp_u {
-	mmr_t	sh_proc0_err_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_proc0_err_time_stamp_s;
-} sh_proc0_err_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ADV_TIME_STAMP"                  */
-/*                      Proc 1 advisory time stamp                      */
-/* ==================================================================== */
-
-typedef union sh_proc1_adv_time_stamp_u {
-	mmr_t	sh_proc1_adv_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_proc1_adv_time_stamp_s;
-} sh_proc1_adv_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC1_ERR_TIME_STAMP"                  */
-/*                       Proc 1 error time stamp                        */
-/* ==================================================================== */
-
-typedef union sh_proc1_err_time_stamp_u {
-	mmr_t	sh_proc1_err_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_proc1_err_time_stamp_s;
-} sh_proc1_err_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ADV_TIME_STAMP"                  */
-/*                      Proc 2 advisory time stamp                      */
-/* ==================================================================== */
-
-typedef union sh_proc2_adv_time_stamp_u {
-	mmr_t	sh_proc2_adv_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_proc2_adv_time_stamp_s;
-} sh_proc2_adv_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC2_ERR_TIME_STAMP"                  */
-/*                       Proc 2 error time stamp                        */
-/* ==================================================================== */
-
-typedef union sh_proc2_err_time_stamp_u {
-	mmr_t	sh_proc2_err_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_proc2_err_time_stamp_s;
-} sh_proc2_err_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ADV_TIME_STAMP"                  */
-/*                      Proc 3 advisory time stamp                      */
-/* ==================================================================== */
-
-typedef union sh_proc3_adv_time_stamp_u {
-	mmr_t	sh_proc3_adv_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_proc3_adv_time_stamp_s;
-} sh_proc3_adv_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROC3_ERR_TIME_STAMP"                  */
-/*                       Proc 3 error time stamp                        */
-/* ==================================================================== */
-
-typedef union sh_proc3_err_time_stamp_u {
-	mmr_t	sh_proc3_err_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_proc3_err_time_stamp_s;
-} sh_proc3_err_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_XN_COR_TIME_STAMP"                    */
-/*                   XN correctable error time stamp                    */
-/* ==================================================================== */
-
-typedef union sh_xn_cor_time_stamp_u {
-	mmr_t	sh_xn_cor_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_xn_cor_time_stamp_s;
-} sh_xn_cor_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_HW_TIME_STAMP"                    */
-/*                     XN hardware error time stamp                     */
-/* ==================================================================== */
-
-typedef union sh_xn_hw_time_stamp_u {
-	mmr_t	sh_xn_hw_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_xn_hw_time_stamp_s;
-} sh_xn_hw_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_XN_UNCOR_TIME_STAMP"                   */
-/*                  XN uncorrectable error time stamp                   */
-/* ==================================================================== */
-
-typedef union sh_xn_uncor_time_stamp_u {
-	mmr_t	sh_xn_uncor_time_stamp_regval;
-	struct {
-		mmr_t	time        : 63;
-		mmr_t	valid       : 1;
-	} sh_xn_uncor_time_stamp_s;
-} sh_xn_uncor_time_stamp_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_DEBUG_PORT"                       */
-/*                           SHub Debug Port                            */
-/* ==================================================================== */
-
-typedef union sh_debug_port_u {
-	mmr_t	sh_debug_port_regval;
-	struct {
-		mmr_t	debug_nibble0 : 4;
-		mmr_t	debug_nibble1 : 4;
-		mmr_t	debug_nibble2 : 4;
-		mmr_t	debug_nibble3 : 4;
-		mmr_t	debug_nibble4 : 4;
-		mmr_t	debug_nibble5 : 4;
-		mmr_t	debug_nibble6 : 4;
-		mmr_t	debug_nibble7 : 4;
-		mmr_t	reserved_0    : 32;
-	} sh_debug_port_s;
-} sh_debug_port_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_II_DEBUG_DATA"                      */
-/*                            II Debug Data                             */
-/* ==================================================================== */
-
-typedef union sh_ii_debug_data_u {
-	mmr_t	sh_ii_debug_data_regval;
-	struct {
-		mmr_t	ii_data     : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_ii_debug_data_s;
-} sh_ii_debug_data_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_II_WRAP_DEBUG_DATA"                   */
-/*                      SHub II Wrapper Debug Data                      */
-/* ==================================================================== */
-
-typedef union sh_ii_wrap_debug_data_u {
-	mmr_t	sh_ii_wrap_debug_data_regval;
-	struct {
-		mmr_t	ii_wrap_data : 32;
-		mmr_t	reserved_0   : 32;
-	} sh_ii_wrap_debug_data_s;
-} sh_ii_wrap_debug_data_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_LB_DEBUG_DATA"                      */
-/*                          SHub LB Debug Data                          */
-/* ==================================================================== */
-
-typedef union sh_lb_debug_data_u {
-	mmr_t	sh_lb_debug_data_regval;
-	struct {
-		mmr_t	lb_data     : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_lb_debug_data_s;
-} sh_lb_debug_data_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_MD_DEBUG_DATA"                      */
-/*                          SHub MD Debug Data                          */
-/* ==================================================================== */
-
-typedef union sh_md_debug_data_u {
-	mmr_t	sh_md_debug_data_regval;
-	struct {
-		mmr_t	md_data     : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_md_debug_data_s;
-} sh_md_debug_data_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PI_DEBUG_DATA"                      */
-/*                          SHub PI Debug Data                          */
-/* ==================================================================== */
-
-typedef union sh_pi_debug_data_u {
-	mmr_t	sh_pi_debug_data_regval;
-	struct {
-		mmr_t	pi_data     : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_pi_debug_data_s;
-} sh_pi_debug_data_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_XN_DEBUG_DATA"                      */
-/*                          SHub XN Debug Data                          */
-/* ==================================================================== */
-
-typedef union sh_xn_debug_data_u {
-	mmr_t	sh_xn_debug_data_regval;
-	struct {
-		mmr_t	xn_data     : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_xn_debug_data_s;
-} sh_xn_debug_data_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_TSF_ARMED_STATE"                     */
-/*                Trigger sequencing facility arm state                 */
-/* ==================================================================== */
-
-typedef union sh_tsf_armed_state_u {
-	mmr_t	sh_tsf_armed_state_regval;
-	struct {
-		mmr_t	state       : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_tsf_armed_state_s;
-} sh_tsf_armed_state_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_TSF_COUNTER_VALUE"                    */
-/*              Trigger sequencing facility counter value               */
-/* ==================================================================== */
-
-typedef union sh_tsf_counter_value_u {
-	mmr_t	sh_tsf_counter_value_regval;
-	struct {
-		mmr_t	count_32    : 32;
-		mmr_t	count_16    : 16;
-		mmr_t	count_8b    : 8;
-		mmr_t	count_8a    : 8;
-	} sh_tsf_counter_value_s;
-} sh_tsf_counter_value_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_TSF_TRIGGERED_STATE"                   */
-/*             Trigger sequencing facility triggered state              */
-/* ==================================================================== */
-
-typedef union sh_tsf_triggered_state_u {
-	mmr_t	sh_tsf_triggered_state_regval;
-	struct {
-		mmr_t	state       : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_tsf_triggered_state_s;
-} sh_tsf_triggered_state_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_RDDATA"                       */
-/*                      Vector Reply Message Data                       */
-/* ==================================================================== */
-
-typedef union sh_vec_rddata_u {
-	mmr_t	sh_vec_rddata_regval;
-	struct {
-		mmr_t	data        : 64;
-	} sh_vec_rddata_s;
-} sh_vec_rddata_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_RETURN"                       */
-/*                  Vector Reply Message Return Route                   */
-/* ==================================================================== */
-
-typedef union sh_vec_return_u {
-	mmr_t	sh_vec_return_regval;
-	struct {
-		mmr_t	route       : 64;
-	} sh_vec_return_s;
-} sh_vec_return_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_VEC_STATUS"                       */
-/*                     Vector Reply Message Status                      */
-/* ==================================================================== */
-
-typedef union sh_vec_status_u {
-	mmr_t	sh_vec_status_regval;
-	struct {
-		mmr_t	type         : 3;
-		mmr_t	address      : 32;
-		mmr_t	pio_id       : 11;
-		mmr_t	source       : 14;
-		mmr_t	reserved_0   : 2;
-		mmr_t	overrun      : 1;
-		mmr_t	status_valid : 1;
-	} sh_vec_status_s;
-} sh_vec_status_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT0_CONTROL"               */
-/*                    Performance Counter 0 Control                     */
-/* ==================================================================== */
-
-typedef union sh_performance_count0_control_u {
-	mmr_t	sh_performance_count0_control_regval;
-	struct {
-		mmr_t	up_stimulus     : 5;
-		mmr_t	up_event        : 1;
-		mmr_t	up_polarity     : 1;
-		mmr_t	up_mode         : 1;
-		mmr_t	dn_stimulus     : 5;
-		mmr_t	dn_event        : 1;
-		mmr_t	dn_polarity     : 1;
-		mmr_t	dn_mode         : 1;
-		mmr_t	inc_enable      : 1;
-		mmr_t	dec_enable      : 1;
-		mmr_t	peak_det_enable : 1;
-		mmr_t	reserved_0      : 45;
-	} sh_performance_count0_control_s;
-} sh_performance_count0_control_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT1_CONTROL"               */
-/*                    Performance Counter 1 Control                     */
-/* ==================================================================== */
-
-typedef union sh_performance_count1_control_u {
-	mmr_t	sh_performance_count1_control_regval;
-	struct {
-		mmr_t	up_stimulus     : 5;
-		mmr_t	up_event        : 1;
-		mmr_t	up_polarity     : 1;
-		mmr_t	up_mode         : 1;
-		mmr_t	dn_stimulus     : 5;
-		mmr_t	dn_event        : 1;
-		mmr_t	dn_polarity     : 1;
-		mmr_t	dn_mode         : 1;
-		mmr_t	inc_enable      : 1;
-		mmr_t	dec_enable      : 1;
-		mmr_t	peak_det_enable : 1;
-		mmr_t	reserved_0      : 45;
-	} sh_performance_count1_control_s;
-} sh_performance_count1_control_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT2_CONTROL"               */
-/*                    Performance Counter 2 Control                     */
-/* ==================================================================== */
-
-typedef union sh_performance_count2_control_u {
-	mmr_t	sh_performance_count2_control_regval;
-	struct {
-		mmr_t	up_stimulus     : 5;
-		mmr_t	up_event        : 1;
-		mmr_t	up_polarity     : 1;
-		mmr_t	up_mode         : 1;
-		mmr_t	dn_stimulus     : 5;
-		mmr_t	dn_event        : 1;
-		mmr_t	dn_polarity     : 1;
-		mmr_t	dn_mode         : 1;
-		mmr_t	inc_enable      : 1;
-		mmr_t	dec_enable      : 1;
-		mmr_t	peak_det_enable : 1;
-		mmr_t	reserved_0      : 45;
-	} sh_performance_count2_control_s;
-} sh_performance_count2_control_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT3_CONTROL"               */
-/*                    Performance Counter 3 Control                     */
-/* ==================================================================== */
-
-typedef union sh_performance_count3_control_u {
-	mmr_t	sh_performance_count3_control_regval;
-	struct {
-		mmr_t	up_stimulus     : 5;
-		mmr_t	up_event        : 1;
-		mmr_t	up_polarity     : 1;
-		mmr_t	up_mode         : 1;
-		mmr_t	dn_stimulus     : 5;
-		mmr_t	dn_event        : 1;
-		mmr_t	dn_polarity     : 1;
-		mmr_t	dn_mode         : 1;
-		mmr_t	inc_enable      : 1;
-		mmr_t	dec_enable      : 1;
-		mmr_t	peak_det_enable : 1;
-		mmr_t	reserved_0      : 45;
-	} sh_performance_count3_control_s;
-} sh_performance_count3_control_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT4_CONTROL"               */
-/*                    Performance Counter 4 Control                     */
-/* ==================================================================== */
-
-typedef union sh_performance_count4_control_u {
-	mmr_t	sh_performance_count4_control_regval;
-	struct {
-		mmr_t	up_stimulus     : 5;
-		mmr_t	up_event        : 1;
-		mmr_t	up_polarity     : 1;
-		mmr_t	up_mode         : 1;
-		mmr_t	dn_stimulus     : 5;
-		mmr_t	dn_event        : 1;
-		mmr_t	dn_polarity     : 1;
-		mmr_t	dn_mode         : 1;
-		mmr_t	inc_enable      : 1;
-		mmr_t	dec_enable      : 1;
-		mmr_t	peak_det_enable : 1;
-		mmr_t	reserved_0      : 45;
-	} sh_performance_count4_control_s;
-} sh_performance_count4_control_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT5_CONTROL"               */
-/*                    Performance Counter 5 Control                     */
-/* ==================================================================== */
-
-typedef union sh_performance_count5_control_u {
-	mmr_t	sh_performance_count5_control_regval;
-	struct {
-		mmr_t	up_stimulus     : 5;
-		mmr_t	up_event        : 1;
-		mmr_t	up_polarity     : 1;
-		mmr_t	up_mode         : 1;
-		mmr_t	dn_stimulus     : 5;
-		mmr_t	dn_event        : 1;
-		mmr_t	dn_polarity     : 1;
-		mmr_t	dn_mode         : 1;
-		mmr_t	inc_enable      : 1;
-		mmr_t	dec_enable      : 1;
-		mmr_t	peak_det_enable : 1;
-		mmr_t	reserved_0      : 45;
-	} sh_performance_count5_control_s;
-} sh_performance_count5_control_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT6_CONTROL"               */
-/*                    Performance Counter 6 Control                     */
-/* ==================================================================== */
-
-typedef union sh_performance_count6_control_u {
-	mmr_t	sh_performance_count6_control_regval;
-	struct {
-		mmr_t	up_stimulus     : 5;
-		mmr_t	up_event        : 1;
-		mmr_t	up_polarity     : 1;
-		mmr_t	up_mode         : 1;
-		mmr_t	dn_stimulus     : 5;
-		mmr_t	dn_event        : 1;
-		mmr_t	dn_polarity     : 1;
-		mmr_t	dn_mode         : 1;
-		mmr_t	inc_enable      : 1;
-		mmr_t	dec_enable      : 1;
-		mmr_t	peak_det_enable : 1;
-		mmr_t	reserved_0      : 45;
-	} sh_performance_count6_control_s;
-} sh_performance_count6_control_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_PERFORMANCE_COUNT7_CONTROL"               */
-/*                    Performance Counter 7 Control                     */
-/* ==================================================================== */
-
-typedef union sh_performance_count7_control_u {
-	mmr_t	sh_performance_count7_control_regval;
-	struct {
-		mmr_t	up_stimulus     : 5;
-		mmr_t	up_event        : 1;
-		mmr_t	up_polarity     : 1;
-		mmr_t	up_mode         : 1;
-		mmr_t	dn_stimulus     : 5;
-		mmr_t	dn_event        : 1;
-		mmr_t	dn_polarity     : 1;
-		mmr_t	dn_mode         : 1;
-		mmr_t	inc_enable      : 1;
-		mmr_t	dec_enable      : 1;
-		mmr_t	peak_det_enable : 1;
-		mmr_t	reserved_0      : 45;
-	} sh_performance_count7_control_s;
-} sh_performance_count7_control_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PROFILE_DN_CONTROL"                   */
-/*                     Profile Counter Down Control                     */
-/* ==================================================================== */
-
-typedef union sh_profile_dn_control_u {
-	mmr_t	sh_profile_dn_control_regval;
-	struct {
-		mmr_t	stimulus    : 5;
-		mmr_t	event       : 1;
-		mmr_t	polarity    : 1;
-		mmr_t	mode        : 1;
-		mmr_t	reserved_0  : 56;
-	} sh_profile_dn_control_s;
-} sh_profile_dn_control_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PROFILE_PEAK_CONTROL"                  */
-/*                     Profile Counter Peak Control                     */
-/* ==================================================================== */
-
-typedef union sh_profile_peak_control_u {
-	mmr_t	sh_profile_peak_control_regval;
-	struct {
-		mmr_t	reserved_0  : 3;
-		mmr_t	stimulus    : 1;
-		mmr_t	reserved_1  : 1;
-		mmr_t	event       : 1;
-		mmr_t	polarity    : 1;
-		mmr_t	reserved_2  : 57;
-	} sh_profile_peak_control_s;
-} sh_profile_peak_control_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PROFILE_RANGE"                      */
-/*                        Profile Counter Range                         */
-/* ==================================================================== */
-
-typedef union sh_profile_range_u {
-	mmr_t	sh_profile_range_regval;
-	struct {
-		mmr_t	range0      : 8;
-		mmr_t	range1      : 8;
-		mmr_t	range2      : 8;
-		mmr_t	range3      : 8;
-		mmr_t	range4      : 8;
-		mmr_t	range5      : 8;
-		mmr_t	range6      : 8;
-		mmr_t	range7      : 8;
-	} sh_profile_range_s;
-} sh_profile_range_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PROFILE_UP_CONTROL"                   */
-/*                      Profile Counter Up Control                      */
-/* ==================================================================== */
-
-typedef union sh_profile_up_control_u {
-	mmr_t	sh_profile_up_control_regval;
-	struct {
-		mmr_t	stimulus    : 5;
-		mmr_t	event       : 1;
-		mmr_t	polarity    : 1;
-		mmr_t	mode        : 1;
-		mmr_t	reserved_0  : 56;
-	} sh_profile_up_control_s;
-} sh_profile_up_control_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER0"                  */
-/*                        Performance Counter 0                         */
-/* ==================================================================== */
-
-typedef union sh_performance_counter0_u {
-	mmr_t	sh_performance_counter0_regval;
-	struct {
-		mmr_t	count       : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_performance_counter0_s;
-} sh_performance_counter0_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER1"                  */
-/*                        Performance Counter 1                         */
-/* ==================================================================== */
-
-typedef union sh_performance_counter1_u {
-	mmr_t	sh_performance_counter1_regval;
-	struct {
-		mmr_t	count       : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_performance_counter1_s;
-} sh_performance_counter1_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER2"                  */
-/*                        Performance Counter 2                         */
-/* ==================================================================== */
-
-typedef union sh_performance_counter2_u {
-	mmr_t	sh_performance_counter2_regval;
-	struct {
-		mmr_t	count       : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_performance_counter2_s;
-} sh_performance_counter2_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER3"                  */
-/*                        Performance Counter 3                         */
-/* ==================================================================== */
-
-typedef union sh_performance_counter3_u {
-	mmr_t	sh_performance_counter3_regval;
-	struct {
-		mmr_t	count       : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_performance_counter3_s;
-} sh_performance_counter3_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER4"                  */
-/*                        Performance Counter 4                         */
-/* ==================================================================== */
-
-typedef union sh_performance_counter4_u {
-	mmr_t	sh_performance_counter4_regval;
-	struct {
-		mmr_t	count       : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_performance_counter4_s;
-} sh_performance_counter4_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER5"                  */
-/*                        Performance Counter 5                         */
-/* ==================================================================== */
-
-typedef union sh_performance_counter5_u {
-	mmr_t	sh_performance_counter5_regval;
-	struct {
-		mmr_t	count       : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_performance_counter5_s;
-} sh_performance_counter5_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER6"                  */
-/*                        Performance Counter 6                         */
-/* ==================================================================== */
-
-typedef union sh_performance_counter6_u {
-	mmr_t	sh_performance_counter6_regval;
-	struct {
-		mmr_t	count       : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_performance_counter6_s;
-} sh_performance_counter6_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_PERFORMANCE_COUNTER7"                  */
-/*                        Performance Counter 7                         */
-/* ==================================================================== */
-
-typedef union sh_performance_counter7_u {
-	mmr_t	sh_performance_counter7_regval;
-	struct {
-		mmr_t	count       : 32;
-		mmr_t	reserved_0  : 32;
-	} sh_performance_counter7_s;
-} sh_performance_counter7_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_PROFILE_COUNTER"                     */
-/*                           Profile Counter                            */
-/* ==================================================================== */
-
-typedef union sh_profile_counter_u {
-	mmr_t	sh_profile_counter_regval;
-	struct {
-		mmr_t	counter     : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_profile_counter_s;
-} sh_profile_counter_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_PROFILE_PEAK"                      */
-/*                         Profile Peak Counter                         */
-/* ==================================================================== */
-
-typedef union sh_profile_peak_u {
-	mmr_t	sh_profile_peak_regval;
-	struct {
-		mmr_t	counter     : 8;
-		mmr_t	reserved_0  : 56;
-	} sh_profile_peak_s;
-} sh_profile_peak_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_PTC_0"                          */
-/*       Puge Translation Cache Message Configuration Information       */
-/* ==================================================================== */
-
-typedef union sh_ptc_0_u {
-	mmr_t	sh_ptc_0_regval;
-	struct {
-		mmr_t	a           : 1;
-		mmr_t	reserved_0  : 1;
-		mmr_t	ps          : 6;
-		mmr_t	rid         : 24;
-		mmr_t	reserved_1  : 31;
-		mmr_t	start       : 1;
-	} sh_ptc_0_s;
-} sh_ptc_0_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_PTC_1"                          */
-/*       Puge Translation Cache Message Configuration Information       */
-/* ==================================================================== */
-
-typedef union sh_ptc_1_u {
-	mmr_t	sh_ptc_1_regval;
-	struct {
-		mmr_t	reserved_0  : 12;
-		mmr_t	vpn         : 49;
-		mmr_t	reserved_1  : 2;
-		mmr_t	start       : 1;
-	} sh_ptc_1_s;
-} sh_ptc_1_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_PTC_PARMS"                        */
-/*                       PTC Time-out parmaeters                        */
-/* ==================================================================== */
-
-typedef union sh_ptc_parms_u {
-	mmr_t	sh_ptc_parms_regval;
-	struct {
-		mmr_t	ptc_to_wrap : 24;
-		mmr_t	ptc_to_val  : 12;
-		mmr_t	reserved_0  : 28;
-	} sh_ptc_parms_s;
-} sh_ptc_parms_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_INT_CMPA"                        */
-/*                  RTC Compare Value for Processor A                   */
-/* ==================================================================== */
-
-typedef union sh_int_cmpa_u {
-	mmr_t	sh_int_cmpa_regval;
-	struct {
-		mmr_t	real_time_cmpa : 55;
-		mmr_t	reserved_0     : 9;
-	} sh_int_cmpa_s;
-} sh_int_cmpa_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_INT_CMPB"                        */
-/*                  RTC Compare Value for Processor B                   */
-/* ==================================================================== */
-
-typedef union sh_int_cmpb_u {
-	mmr_t	sh_int_cmpb_regval;
-	struct {
-		mmr_t	real_time_cmpb : 55;
-		mmr_t	reserved_0     : 9;
-	} sh_int_cmpb_s;
-} sh_int_cmpb_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_INT_CMPC"                        */
-/*                  RTC Compare Value for Processor C                   */
-/* ==================================================================== */
-
-typedef union sh_int_cmpc_u {
-	mmr_t	sh_int_cmpc_regval;
-	struct {
-		mmr_t	real_time_cmpc : 55;
-		mmr_t	reserved_0     : 9;
-	} sh_int_cmpc_s;
-} sh_int_cmpc_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_INT_CMPD"                        */
-/*                  RTC Compare Value for Processor D                   */
-/* ==================================================================== */
-
-typedef union sh_int_cmpd_u {
-	mmr_t	sh_int_cmpd_regval;
-	struct {
-		mmr_t	real_time_cmpd : 55;
-		mmr_t	reserved_0     : 9;
-	} sh_int_cmpd_s;
-} sh_int_cmpd_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_INT_PROF"                        */
-/*                      Profile Compare Registers                       */
-/* ==================================================================== */
-
-typedef union sh_int_prof_u {
-	mmr_t	sh_int_prof_regval;
-	struct {
-		mmr_t	profile_compare : 32;
-		mmr_t	reserved_0      : 32;
-	} sh_int_prof_s;
-} sh_int_prof_u_t;
-
-/* ==================================================================== */
-/*                          Register "SH_RTC"                           */
-/*                           Real-time Clock                            */
-/* ==================================================================== */
-
-typedef union sh_rtc_u {
-	mmr_t	sh_rtc_regval;
-	struct {
-		mmr_t	real_time_clock : 55;
-		mmr_t	reserved_0      : 9;
-	} sh_rtc_s;
-} sh_rtc_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH0"                        */
-/*                          Scratch Register 0                          */
-/* ==================================================================== */
-
-typedef union sh_scratch0_u {
-	mmr_t	sh_scratch0_regval;
-	struct {
-		mmr_t	scratch0    : 64;
-	} sh_scratch0_s;
-} sh_scratch0_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH1"                        */
-/*                          Scratch Register 1                          */
-/* ==================================================================== */
-
-typedef union sh_scratch1_u {
-	mmr_t	sh_scratch1_regval;
-	struct {
-		mmr_t	scratch1    : 64;
-	} sh_scratch1_s;
-} sh_scratch1_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH2"                        */
-/*                          Scratch Register 2                          */
-/* ==================================================================== */
-
-typedef union sh_scratch2_u {
-	mmr_t	sh_scratch2_regval;
-	struct {
-		mmr_t	scratch2    : 64;
-	} sh_scratch2_s;
-} sh_scratch2_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH3"                        */
-/*                          Scratch Register 3                          */
-/* ==================================================================== */
-
-typedef union sh_scratch3_u {
-	mmr_t	sh_scratch3_regval;
-	struct {
-		mmr_t	scratch3    : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_scratch3_s;
-} sh_scratch3_u_t;
-
-/* ==================================================================== */
-/*                        Register "SH_SCRATCH4"                        */
-/*                          Scratch Register 4                          */
-/* ==================================================================== */
-
-typedef union sh_scratch4_u {
-	mmr_t	sh_scratch4_regval;
-	struct {
-		mmr_t	scratch4    : 1;
-		mmr_t	reserved_0  : 63;
-	} sh_scratch4_s;
-} sh_scratch4_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_CRB_MESSAGE_CONTROL"                   */
-/*               Coherent Request Buffer Message Control                */
-/* ==================================================================== */
-
-typedef union sh_crb_message_control_u {
-	mmr_t	sh_crb_message_control_regval;
-	struct {
-		mmr_t	system_coherence_enable           : 1;
-		mmr_t	local_speculative_message_enable  : 1;
-		mmr_t	remote_speculative_message_enable : 1;
-		mmr_t	message_color                     : 1;
-		mmr_t	message_color_enable              : 1;
-		mmr_t	rrb_attribute_mismatch_fsb_enable : 1;
-		mmr_t	wrb_attribute_mismatch_fsb_enable : 1;
-		mmr_t	irb_attribute_mismatch_fsb_enable : 1;
-		mmr_t	rrb_attribute_mismatch_xb_enable  : 1;
-		mmr_t	wrb_attribute_mismatch_xb_enable  : 1;
-		mmr_t	suppress_bogus_writes             : 1;
-		mmr_t	enable_ivack_consolidation        : 1;
-		mmr_t	reserved_0                        : 20;
-		mmr_t	ivack_stall_count                 : 16;
-		mmr_t	ivack_throttle_control            : 16;
-	} sh_crb_message_control_s;
-} sh_crb_message_control_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_CRB_NACK_LIMIT"                     */
-/*                            CRB Nack Limit                            */
-/* ==================================================================== */
-
-typedef union sh_crb_nack_limit_u {
-	mmr_t	sh_crb_nack_limit_regval;
-	struct {
-		mmr_t	limit       : 12;
-		mmr_t	pri_freq    : 4;
-		mmr_t	reserved_0  : 47;
-		mmr_t	enable      : 1;
-	} sh_crb_nack_limit_s;
-} sh_crb_nack_limit_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_CRB_TIMEOUT_PRESCALE"                  */
-/*               Coherent Request Buffer Timeout Prescale               */
-/* ==================================================================== */
-
-typedef union sh_crb_timeout_prescale_u {
-	mmr_t	sh_crb_timeout_prescale_regval;
-	struct {
-		mmr_t	scaling_factor : 32;
-		mmr_t	reserved_0     : 32;
-	} sh_crb_timeout_prescale_s;
-} sh_crb_timeout_prescale_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_CRB_TIMEOUT_SKID"                    */
-/*              Coherent Request Buffer Timeout Skid Limit              */
-/* ==================================================================== */
-
-typedef union sh_crb_timeout_skid_u {
-	mmr_t	sh_crb_timeout_skid_regval;
-	struct {
-		mmr_t	skid             : 6;
-		mmr_t	reserved_0       : 57;
-		mmr_t	reset_skid_count : 1;
-	} sh_crb_timeout_skid_s;
-} sh_crb_timeout_skid_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MEMORY_WRITE_STATUS_0"                  */
-/*                    Memory Write Status for CPU 0                     */
-/* ==================================================================== */
-
-typedef union sh_memory_write_status_0_u {
-	mmr_t	sh_memory_write_status_0_regval;
-	struct {
-		mmr_t	pending_write_count : 6;
-		mmr_t	reserved_0          : 58;
-	} sh_memory_write_status_0_s;
-} sh_memory_write_status_0_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MEMORY_WRITE_STATUS_1"                  */
-/*                    Memory Write Status for CPU 1                     */
-/* ==================================================================== */
-
-typedef union sh_memory_write_status_1_u {
-	mmr_t	sh_memory_write_status_1_regval;
-	struct {
-		mmr_t	pending_write_count : 6;
-		mmr_t	reserved_0          : 58;
-	} sh_memory_write_status_1_s;
-} sh_memory_write_status_1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PIO_WRITE_STATUS_0"                   */
-/*                      PIO Write Status for CPU 0                      */
-/* ==================================================================== */
-
-typedef union sh_pio_write_status_0_u {
-	mmr_t	sh_pio_write_status_0_regval;
-	struct {
-		mmr_t	multi_write_error   : 1;
-		mmr_t	write_deadlock      : 1;
-		mmr_t	write_error         : 1;
-		mmr_t	write_error_address : 47;
-		mmr_t	reserved_0          : 6;
-		mmr_t	pending_write_count : 6;
-		mmr_t	reserved_1          : 1;
-		mmr_t	writes_ok           : 1;
-	} sh_pio_write_status_0_s;
-} sh_pio_write_status_0_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_PIO_WRITE_STATUS_1"                   */
-/*                      PIO Write Status for CPU 1                      */
-/* ==================================================================== */
-
-typedef union sh_pio_write_status_1_u {
-	mmr_t	sh_pio_write_status_1_regval;
-	struct {
-		mmr_t	multi_write_error   : 1;
-		mmr_t	write_deadlock      : 1;
-		mmr_t	write_error         : 1;
-		mmr_t	write_error_address : 47;
-		mmr_t	reserved_0          : 6;
-		mmr_t	pending_write_count : 6;
-		mmr_t	reserved_1          : 1;
-		mmr_t	writes_ok           : 1;
-	} sh_pio_write_status_1_s;
-} sh_pio_write_status_1_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_MEMORY_WRITE_STATUS_NON_USER_0"             */
-/*            Memory Write Status for CPU 0. OS access only             */
-/* ==================================================================== */
-
-typedef union sh_memory_write_status_non_user_0_u {
-	mmr_t	sh_memory_write_status_non_user_0_regval;
-	struct {
-		mmr_t	pending_write_count : 6;
-		mmr_t	reserved_0          : 57;
-		mmr_t	clear               : 1;
-	} sh_memory_write_status_non_user_0_s;
-} sh_memory_write_status_non_user_0_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_MEMORY_WRITE_STATUS_NON_USER_1"             */
-/*            Memory Write Status for CPU 1. OS access only             */
-/* ==================================================================== */
-
-typedef union sh_memory_write_status_non_user_1_u {
-	mmr_t	sh_memory_write_status_non_user_1_regval;
-	struct {
-		mmr_t	pending_write_count : 6;
-		mmr_t	reserved_0          : 57;
-		mmr_t	clear               : 1;
-	} sh_memory_write_status_non_user_1_s;
-} sh_memory_write_status_non_user_1_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_MMRBIST_ERR"                       */
-/*                  Error capture for bist read errors                  */
-/* ==================================================================== */
-
-typedef union sh_mmrbist_err_u {
-	mmr_t	sh_mmrbist_err_regval;
-	struct {
-		mmr_t	addr              : 33;
-		mmr_t	reserved_0        : 3;
-		mmr_t	detected          : 1;
-		mmr_t	multiple_detected : 1;
-		mmr_t	cancelled         : 1;
-		mmr_t	reserved_1        : 25;
-	} sh_mmrbist_err_s;
-} sh_mmrbist_err_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MISC_ERR_HDR_LOWER"                   */
-/*                       Header capture register                        */
-/* ==================================================================== */
-
-typedef union sh_misc_err_hdr_lower_u {
-	mmr_t	sh_misc_err_hdr_lower_regval;
-	struct {
-		mmr_t	reserved_0  : 3;
-		mmr_t	addr        : 33;
-		mmr_t	cmd         : 8;
-		mmr_t	src         : 14;
-		mmr_t	reserved_1  : 2;
-		mmr_t	write       : 1;
-		mmr_t	reserved_2  : 2;
-		mmr_t	valid       : 1;
-	} sh_misc_err_hdr_lower_s;
-} sh_misc_err_hdr_lower_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MISC_ERR_HDR_UPPER"                   */
-/*           Error header capture packet and protocol errors            */
-/* ==================================================================== */
-
-typedef union sh_misc_err_hdr_upper_u {
-	mmr_t	sh_misc_err_hdr_upper_regval;
-	struct {
-		mmr_t	dir_protocol  : 1;
-		mmr_t	illegal_cmd   : 1;
-		mmr_t	nonexist_addr : 1;
-		mmr_t	rmw_uc        : 1;
-		mmr_t	rmw_cor       : 1;
-		mmr_t	dir_acc       : 1;
-		mmr_t	pi_pkt_size   : 1;
-		mmr_t	xn_pkt_size   : 1;
-		mmr_t	reserved_0    : 12;
-		mmr_t	echo          : 9;
-		mmr_t	reserved_1    : 35;
-	} sh_misc_err_hdr_upper_s;
-} sh_misc_err_hdr_upper_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_DIR_UC_ERR_HDR_LOWER"                  */
-/*                       Header capture register                        */
-/* ==================================================================== */
-
-typedef union sh_dir_uc_err_hdr_lower_u {
-	mmr_t	sh_dir_uc_err_hdr_lower_regval;
-	struct {
-		mmr_t	reserved_0  : 3;
-		mmr_t	addr        : 33;
-		mmr_t	cmd         : 8;
-		mmr_t	src         : 14;
-		mmr_t	reserved_1  : 2;
-		mmr_t	write       : 1;
-		mmr_t	reserved_2  : 2;
-		mmr_t	valid       : 1;
-	} sh_dir_uc_err_hdr_lower_s;
-} sh_dir_uc_err_hdr_lower_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_DIR_UC_ERR_HDR_UPPER"                  */
-/*           Error header capture packet and protocol errors            */
-/* ==================================================================== */
-
-typedef union sh_dir_uc_err_hdr_upper_u {
-	mmr_t	sh_dir_uc_err_hdr_upper_regval;
-	struct {
-		mmr_t	reserved_0  : 3;
-		mmr_t	dir_uc      : 1;
-		mmr_t	reserved_1  : 16;
-		mmr_t	echo        : 9;
-		mmr_t	reserved_2  : 35;
-	} sh_dir_uc_err_hdr_upper_s;
-} sh_dir_uc_err_hdr_upper_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_DIR_COR_ERR_HDR_LOWER"                  */
-/*                       Header capture register                        */
-/* ==================================================================== */
-
-typedef union sh_dir_cor_err_hdr_lower_u {
-	mmr_t	sh_dir_cor_err_hdr_lower_regval;
-	struct {
-		mmr_t	reserved_0  : 3;
-		mmr_t	addr        : 33;
-		mmr_t	cmd         : 8;
-		mmr_t	src         : 14;
-		mmr_t	reserved_1  : 2;
-		mmr_t	write       : 1;
-		mmr_t	reserved_2  : 2;
-		mmr_t	valid       : 1;
-	} sh_dir_cor_err_hdr_lower_s;
-} sh_dir_cor_err_hdr_lower_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_DIR_COR_ERR_HDR_UPPER"                  */
-/*           Error header capture packet and protocol errors            */
-/* ==================================================================== */
-
-typedef union sh_dir_cor_err_hdr_upper_u {
-	mmr_t	sh_dir_cor_err_hdr_upper_regval;
-	struct {
-		mmr_t	reserved_0  : 8;
-		mmr_t	dir_cor     : 1;
-		mmr_t	reserved_1  : 11;
-		mmr_t	echo        : 9;
-		mmr_t	reserved_2  : 35;
-	} sh_dir_cor_err_hdr_upper_s;
-} sh_dir_cor_err_hdr_upper_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MEM_ERROR_SUMMARY"                    */
-/*                          Memory error flags                          */
-/* ==================================================================== */
-
-typedef union sh_mem_error_summary_u {
-	mmr_t	sh_mem_error_summary_regval;
-	struct {
-		mmr_t	illegal_cmd           : 1;
-		mmr_t	nonexist_addr         : 1;
-		mmr_t	dqlp_dir_perr         : 1;
-		mmr_t	dqrp_dir_perr         : 1;
-		mmr_t	dqlp_dir_uc           : 1;
-		mmr_t	dqlp_dir_cor          : 1;
-		mmr_t	dqrp_dir_uc           : 1;
-		mmr_t	dqrp_dir_cor          : 1;
-		mmr_t	acx_int_hw            : 1;
-		mmr_t	acy_int_hw            : 1;
-		mmr_t	dir_acc               : 1;
-		mmr_t	reserved_0            : 1;
-		mmr_t	dqlp_int_uc           : 1;
-		mmr_t	dqlp_int_cor          : 1;
-		mmr_t	dqlp_int_hw           : 1;
-		mmr_t	reserved_1            : 1;
-		mmr_t	dqls_int_uc           : 1;
-		mmr_t	dqls_int_cor          : 1;
-		mmr_t	dqls_int_hw           : 1;
-		mmr_t	reserved_2            : 1;
-		mmr_t	dqrp_int_uc           : 1;
-		mmr_t	dqrp_int_cor          : 1;
-		mmr_t	dqrp_int_hw           : 1;
-		mmr_t	reserved_3            : 1;
-		mmr_t	dqrs_int_uc           : 1;
-		mmr_t	dqrs_int_cor          : 1;
-		mmr_t	dqrs_int_hw           : 1;
-		mmr_t	reserved_4            : 1;
-		mmr_t	pi_reply_overflow     : 1;
-		mmr_t	xn_reply_overflow     : 1;
-		mmr_t	pi_request_overflow   : 1;
-		mmr_t	xn_request_overflow   : 1;
-		mmr_t	red_black_err_timeout : 1;
-		mmr_t	pi_pkt_size           : 1;
-		mmr_t	xn_pkt_size           : 1;
-		mmr_t	reserved_5            : 29;
-	} sh_mem_error_summary_s;
-} sh_mem_error_summary_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MEM_ERROR_OVERFLOW"                   */
-/*                          Memory error flags                          */
-/* ==================================================================== */
-
-typedef union sh_mem_error_overflow_u {
-	mmr_t	sh_mem_error_overflow_regval;
-	struct {
-		mmr_t	illegal_cmd           : 1;
-		mmr_t	nonexist_addr         : 1;
-		mmr_t	dqlp_dir_perr         : 1;
-		mmr_t	dqrp_dir_perr         : 1;
-		mmr_t	dqlp_dir_uc           : 1;
-		mmr_t	dqlp_dir_cor          : 1;
-		mmr_t	dqrp_dir_uc           : 1;
-		mmr_t	dqrp_dir_cor          : 1;
-		mmr_t	acx_int_hw            : 1;
-		mmr_t	acy_int_hw            : 1;
-		mmr_t	dir_acc               : 1;
-		mmr_t	reserved_0            : 1;
-		mmr_t	dqlp_int_uc           : 1;
-		mmr_t	dqlp_int_cor          : 1;
-		mmr_t	dqlp_int_hw           : 1;
-		mmr_t	reserved_1            : 1;
-		mmr_t	dqls_int_uc           : 1;
-		mmr_t	dqls_int_cor          : 1;
-		mmr_t	dqls_int_hw           : 1;
-		mmr_t	reserved_2            : 1;
-		mmr_t	dqrp_int_uc           : 1;
-		mmr_t	dqrp_int_cor          : 1;
-		mmr_t	dqrp_int_hw           : 1;
-		mmr_t	reserved_3            : 1;
-		mmr_t	dqrs_int_uc           : 1;
-		mmr_t	dqrs_int_cor          : 1;
-		mmr_t	dqrs_int_hw           : 1;
-		mmr_t	reserved_4            : 1;
-		mmr_t	pi_reply_overflow     : 1;
-		mmr_t	xn_reply_overflow     : 1;
-		mmr_t	pi_request_overflow   : 1;
-		mmr_t	xn_request_overflow   : 1;
-		mmr_t	red_black_err_timeout : 1;
-		mmr_t	pi_pkt_size           : 1;
-		mmr_t	xn_pkt_size           : 1;
-		mmr_t	reserved_5            : 29;
-	} sh_mem_error_overflow_s;
-} sh_mem_error_overflow_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_MEM_ERROR_MASK"                     */
-/*                          Memory error flags                          */
-/* ==================================================================== */
-
-typedef union sh_mem_error_mask_u {
-	mmr_t	sh_mem_error_mask_regval;
-	struct {
-		mmr_t	illegal_cmd           : 1;
-		mmr_t	nonexist_addr         : 1;
-		mmr_t	dqlp_dir_perr         : 1;
-		mmr_t	dqrp_dir_perr         : 1;
-		mmr_t	dqlp_dir_uc           : 1;
-		mmr_t	dqlp_dir_cor          : 1;
-		mmr_t	dqrp_dir_uc           : 1;
-		mmr_t	dqrp_dir_cor          : 1;
-		mmr_t	acx_int_hw            : 1;
-		mmr_t	acy_int_hw            : 1;
-		mmr_t	dir_acc               : 1;
-		mmr_t	reserved_0            : 1;
-		mmr_t	dqlp_int_uc           : 1;
-		mmr_t	dqlp_int_cor          : 1;
-		mmr_t	dqlp_int_hw           : 1;
-		mmr_t	reserved_1            : 1;
-		mmr_t	dqls_int_uc           : 1;
-		mmr_t	dqls_int_cor          : 1;
-		mmr_t	dqls_int_hw           : 1;
-		mmr_t	reserved_2            : 1;
-		mmr_t	dqrp_int_uc           : 1;
-		mmr_t	dqrp_int_cor          : 1;
-		mmr_t	dqrp_int_hw           : 1;
-		mmr_t	reserved_3            : 1;
-		mmr_t	dqrs_int_uc           : 1;
-		mmr_t	dqrs_int_cor          : 1;
-		mmr_t	dqrs_int_hw           : 1;
-		mmr_t	reserved_4            : 1;
-		mmr_t	pi_reply_overflow     : 1;
-		mmr_t	xn_reply_overflow     : 1;
-		mmr_t	pi_request_overflow   : 1;
-		mmr_t	xn_request_overflow   : 1;
-		mmr_t	red_black_err_timeout : 1;
-		mmr_t	pi_pkt_size           : 1;
-		mmr_t	xn_pkt_size           : 1;
-		mmr_t	reserved_5            : 29;
-	} sh_mem_error_mask_s;
-} sh_mem_error_mask_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_X_DIMM_CFG"                       */
-/*                       AC Mem Config Registers                        */
-/* ==================================================================== */
-
-typedef union sh_x_dimm_cfg_u {
-	mmr_t	sh_x_dimm_cfg_regval;
-	struct {
-		mmr_t	dimm0_size  : 3;
-		mmr_t	dimm0_2bk   : 1;
-		mmr_t	dimm0_rev   : 1;
-		mmr_t	dimm0_cs    : 2;
-		mmr_t	reserved_0  : 1;
-		mmr_t	dimm1_size  : 3;
-		mmr_t	dimm1_2bk   : 1;
-		mmr_t	dimm1_rev   : 1;
-		mmr_t	dimm1_cs    : 2;
-		mmr_t	reserved_1  : 1;
-		mmr_t	dimm2_size  : 3;
-		mmr_t	dimm2_2bk   : 1;
-		mmr_t	dimm2_rev   : 1;
-		mmr_t	dimm2_cs    : 2;
-		mmr_t	reserved_2  : 1;
-		mmr_t	dimm3_size  : 3;
-		mmr_t	dimm3_2bk   : 1;
-		mmr_t	dimm3_rev   : 1;
-		mmr_t	dimm3_cs    : 2;
-		mmr_t	reserved_3  : 1;
-		mmr_t	freq        : 4;
-		mmr_t	reserved_4  : 28;
-	} sh_x_dimm_cfg_s;
-} sh_x_dimm_cfg_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_Y_DIMM_CFG"                       */
-/*                       AC Mem Config Registers                        */
-/* ==================================================================== */
-
-typedef union sh_y_dimm_cfg_u {
-	mmr_t	sh_y_dimm_cfg_regval;
-	struct {
-		mmr_t	dimm0_size  : 3;
-		mmr_t	dimm0_2bk   : 1;
-		mmr_t	dimm0_rev   : 1;
-		mmr_t	dimm0_cs    : 2;
-		mmr_t	reserved_0  : 1;
-		mmr_t	dimm1_size  : 3;
-		mmr_t	dimm1_2bk   : 1;
-		mmr_t	dimm1_rev   : 1;
-		mmr_t	dimm1_cs    : 2;
-		mmr_t	reserved_1  : 1;
-		mmr_t	dimm2_size  : 3;
-		mmr_t	dimm2_2bk   : 1;
-		mmr_t	dimm2_rev   : 1;
-		mmr_t	dimm2_cs    : 2;
-		mmr_t	reserved_2  : 1;
-		mmr_t	dimm3_size  : 3;
-		mmr_t	dimm3_2bk   : 1;
-		mmr_t	dimm3_rev   : 1;
-		mmr_t	dimm3_cs    : 2;
-		mmr_t	reserved_3  : 1;
-		mmr_t	freq        : 4;
-		mmr_t	reserved_4  : 28;
-	} sh_y_dimm_cfg_s;
-} sh_y_dimm_cfg_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_JNR_DIMM_CFG"                      */
-/*                       AC Mem Config Registers                        */
-/* ==================================================================== */
-
-typedef union sh_jnr_dimm_cfg_u {
-	mmr_t	sh_jnr_dimm_cfg_regval;
-	struct {
-		mmr_t	dimm0_size  : 3;
-		mmr_t	dimm0_2bk   : 1;
-		mmr_t	dimm0_rev   : 1;
-		mmr_t	dimm0_cs    : 2;
-		mmr_t	reserved_0  : 1;
-		mmr_t	dimm1_size  : 3;
-		mmr_t	dimm1_2bk   : 1;
-		mmr_t	dimm1_rev   : 1;
-		mmr_t	dimm1_cs    : 2;
-		mmr_t	reserved_1  : 1;
-		mmr_t	dimm2_size  : 3;
-		mmr_t	dimm2_2bk   : 1;
-		mmr_t	dimm2_rev   : 1;
-		mmr_t	dimm2_cs    : 2;
-		mmr_t	reserved_2  : 1;
-		mmr_t	dimm3_size  : 3;
-		mmr_t	dimm3_2bk   : 1;
-		mmr_t	dimm3_rev   : 1;
-		mmr_t	dimm3_cs    : 2;
-		mmr_t	reserved_3  : 1;
-		mmr_t	freq        : 4;
-		mmr_t	reserved_4  : 28;
-	} sh_jnr_dimm_cfg_s;
-} sh_jnr_dimm_cfg_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_X_PHASE_CFG"                       */
-/*                      AC Phase Config Registers                       */
-/* ==================================================================== */
-
-typedef union sh_x_phase_cfg_u {
-	mmr_t	sh_x_phase_cfg_regval;
-	struct {
-		mmr_t	ld_a        : 5;
-		mmr_t	ld_b        : 5;
-		mmr_t	dq_ld_a     : 5;
-		mmr_t	dq_ld_b     : 5;
-		mmr_t	hold        : 5;
-		mmr_t	hold_req    : 5;
-		mmr_t	add_cp      : 5;
-		mmr_t	bubble_en   : 5;
-		mmr_t	pha_bubble  : 3;
-		mmr_t	phb_bubble  : 3;
-		mmr_t	phc_bubble  : 3;
-		mmr_t	phd_bubble  : 3;
-		mmr_t	phe_bubble  : 3;
-		mmr_t	sel_a       : 4;
-		mmr_t	dq_sel_a    : 4;
-		mmr_t	reserved_0  : 1;
-	} sh_x_phase_cfg_s;
-} sh_x_phase_cfg_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_CFG"                          */
-/*                         AC Config Registers                          */
-/* ==================================================================== */
-
-typedef union sh_x_cfg_u {
-	mmr_t	sh_x_cfg_regval;
-	struct {
-		mmr_t	mode_serial             : 1;
-		mmr_t	dirc_random_replacement : 1;
-		mmr_t	dir_counter_init        : 6;
-		mmr_t	ta_dlys                 : 32;
-		mmr_t	da_bb_clr               : 4;
-		mmr_t	dc_bb_clr               : 4;
-		mmr_t	wt_bb_clr               : 4;
-		mmr_t	sso_wt_en               : 1;
-		mmr_t	trcd2_en                : 1;
-		mmr_t	trcd4_en                : 1;
-		mmr_t	req_cntr_dis            : 1;
-		mmr_t	req_cntr_val            : 6;
-		mmr_t	inv_cas_addr            : 1;
-		mmr_t	clr_dir_cache           : 1;
-	} sh_x_cfg_s;
-} sh_x_cfg_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_X_DQCT_CFG"                       */
-/*                         AC Config Registers                          */
-/* ==================================================================== */
-
-typedef union sh_x_dqct_cfg_u {
-	mmr_t	sh_x_dqct_cfg_regval;
-	struct {
-		mmr_t	rd_sel      : 4;
-		mmr_t	wt_sel      : 4;
-		mmr_t	dta_rd_sel  : 4;
-		mmr_t	dta_wt_sel  : 4;
-		mmr_t	dir_rd_sel  : 4;
-		mmr_t	mdir_rd_sel : 4;
-		mmr_t	reserved_0  : 40;
-	} sh_x_dqct_cfg_s;
-} sh_x_dqct_cfg_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_X_REFRESH_CONTROL"                    */
-/*                       Refresh Control Register                       */
-/* ==================================================================== */
-
-typedef union sh_x_refresh_control_u {
-	mmr_t	sh_x_refresh_control_regval;
-	struct {
-		mmr_t	enable      : 8;
-		mmr_t	interval    : 9;
-		mmr_t	hold        : 6;
-		mmr_t	interleave  : 1;
-		mmr_t	half_rate   : 4;
-		mmr_t	reserved_0  : 36;
-	} sh_x_refresh_control_s;
-} sh_x_refresh_control_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_Y_PHASE_CFG"                       */
-/*                      AC Phase Config Registers                       */
-/* ==================================================================== */
-
-typedef union sh_y_phase_cfg_u {
-	mmr_t	sh_y_phase_cfg_regval;
-	struct {
-		mmr_t	ld_a        : 5;
-		mmr_t	ld_b        : 5;
-		mmr_t	dq_ld_a     : 5;
-		mmr_t	dq_ld_b     : 5;
-		mmr_t	hold        : 5;
-		mmr_t	hold_req    : 5;
-		mmr_t	add_cp      : 5;
-		mmr_t	bubble_en   : 5;
-		mmr_t	pha_bubble  : 3;
-		mmr_t	phb_bubble  : 3;
-		mmr_t	phc_bubble  : 3;
-		mmr_t	phd_bubble  : 3;
-		mmr_t	phe_bubble  : 3;
-		mmr_t	sel_a       : 4;
-		mmr_t	dq_sel_a    : 4;
-		mmr_t	reserved_0  : 1;
-	} sh_y_phase_cfg_s;
-} sh_y_phase_cfg_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_CFG"                          */
-/*                         AC Config Registers                          */
-/* ==================================================================== */
-
-typedef union sh_y_cfg_u {
-	mmr_t	sh_y_cfg_regval;
-	struct {
-		mmr_t	mode_serial             : 1;
-		mmr_t	dirc_random_replacement : 1;
-		mmr_t	dir_counter_init        : 6;
-		mmr_t	ta_dlys                 : 32;
-		mmr_t	da_bb_clr               : 4;
-		mmr_t	dc_bb_clr               : 4;
-		mmr_t	wt_bb_clr               : 4;
-		mmr_t	sso_wt_en               : 1;
-		mmr_t	trcd2_en                : 1;
-		mmr_t	trcd4_en                : 1;
-		mmr_t	req_cntr_dis            : 1;
-		mmr_t	req_cntr_val            : 6;
-		mmr_t	inv_cas_addr            : 1;
-		mmr_t	clr_dir_cache           : 1;
-	} sh_y_cfg_s;
-} sh_y_cfg_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_Y_DQCT_CFG"                       */
-/*                         AC Config Registers                          */
-/* ==================================================================== */
-
-typedef union sh_y_dqct_cfg_u {
-	mmr_t	sh_y_dqct_cfg_regval;
-	struct {
-		mmr_t	rd_sel      : 4;
-		mmr_t	wt_sel      : 4;
-		mmr_t	dta_rd_sel  : 4;
-		mmr_t	dta_wt_sel  : 4;
-		mmr_t	dir_rd_sel  : 4;
-		mmr_t	mdir_rd_sel : 4;
-		mmr_t	reserved_0  : 40;
-	} sh_y_dqct_cfg_s;
-} sh_y_dqct_cfg_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_Y_REFRESH_CONTROL"                    */
-/*                       Refresh Control Register                       */
-/* ==================================================================== */
-
-typedef union sh_y_refresh_control_u {
-	mmr_t	sh_y_refresh_control_regval;
-	struct {
-		mmr_t	enable      : 8;
-		mmr_t	interval    : 9;
-		mmr_t	hold        : 6;
-		mmr_t	interleave  : 1;
-		mmr_t	half_rate   : 4;
-		mmr_t	reserved_0  : 36;
-	} sh_y_refresh_control_s;
-} sh_y_refresh_control_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_MEM_RED_BLACK"                      */
-/*                     MD fairness watchdog timers                      */
-/* ==================================================================== */
-
-typedef union sh_mem_red_black_u {
-	mmr_t	sh_mem_red_black_regval;
-	struct {
-		mmr_t	time        : 16;
-		mmr_t	err_time    : 36;
-		mmr_t	reserved_0  : 12;
-	} sh_mem_red_black_s;
-} sh_mem_red_black_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_MISC_MEM_CFG"                      */
-/* ==================================================================== */
-
-typedef union sh_misc_mem_cfg_u {
-	mmr_t	sh_misc_mem_cfg_regval;
-	struct {
-		mmr_t	express_header_enable       : 1;
-		mmr_t	spec_header_enable          : 1;
-		mmr_t	jnr_bypass_enable           : 1;
-		mmr_t	xn_rd_same_as_pi            : 1;
-		mmr_t	low_write_buffer_threshold  : 6;
-		mmr_t	reserved_0                  : 2;
-		mmr_t	low_victim_buffer_threshold : 6;
-		mmr_t	reserved_1                  : 2;
-		mmr_t	throttle_cnt                : 8;
-		mmr_t	disabled_read_tnums         : 5;
-		mmr_t	reserved_2                  : 3;
-		mmr_t	disabled_write_tnums        : 5;
-		mmr_t	reserved_3                  : 3;
-		mmr_t	disabled_victims            : 6;
-		mmr_t	reserved_4                  : 2;
-		mmr_t	alternate_xn_rp_plane       : 1;
-		mmr_t	reserved_5                  : 11;
-	} sh_misc_mem_cfg_s;
-} sh_misc_mem_cfg_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_PIO_RQ_CRD_CTL"                     */
-/*                  pio_rq Credit Circulation Control                   */
-/* ==================================================================== */
-
-typedef union sh_pio_rq_crd_ctl_u {
-	mmr_t	sh_pio_rq_crd_ctl_regval;
-	struct {
-		mmr_t	depth       : 6;
-		mmr_t	reserved_0  : 58;
-	} sh_pio_rq_crd_ctl_s;
-} sh_pio_rq_crd_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_PI_MD_RQ_CRD_CTL"                    */
-/*                 pi_md_rq Credit Circulation Control                  */
-/* ==================================================================== */
-
-typedef union sh_pi_md_rq_crd_ctl_u {
-	mmr_t	sh_pi_md_rq_crd_ctl_regval;
-	struct {
-		mmr_t	depth       : 6;
-		mmr_t	reserved_0  : 58;
-	} sh_pi_md_rq_crd_ctl_s;
-} sh_pi_md_rq_crd_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_PI_MD_RP_CRD_CTL"                    */
-/*                 pi_md_rp Credit Circulation Control                  */
-/* ==================================================================== */
-
-typedef union sh_pi_md_rp_crd_ctl_u {
-	mmr_t	sh_pi_md_rp_crd_ctl_regval;
-	struct {
-		mmr_t	depth       : 6;
-		mmr_t	reserved_0  : 58;
-	} sh_pi_md_rp_crd_ctl_s;
-} sh_pi_md_rp_crd_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_MD_RQ_CRD_CTL"                    */
-/*                 xn_md_rq Credit Circulation Control                  */
-/* ==================================================================== */
-
-typedef union sh_xn_md_rq_crd_ctl_u {
-	mmr_t	sh_xn_md_rq_crd_ctl_regval;
-	struct {
-		mmr_t	depth       : 6;
-		mmr_t	reserved_0  : 58;
-	} sh_xn_md_rq_crd_ctl_s;
-} sh_xn_md_rq_crd_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_XN_MD_RP_CRD_CTL"                    */
-/*                 xn_md_rp Credit Circulation Control                  */
-/* ==================================================================== */
-
-typedef union sh_xn_md_rp_crd_ctl_u {
-	mmr_t	sh_xn_md_rp_crd_ctl_regval;
-	struct {
-		mmr_t	depth       : 6;
-		mmr_t	reserved_0  : 58;
-	} sh_xn_md_rp_crd_ctl_s;
-} sh_xn_md_rp_crd_ctl_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG0"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_x_tag0_u {
-	mmr_t	sh_x_tag0_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_x_tag0_s;
-} sh_x_tag0_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG1"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_x_tag1_u {
-	mmr_t	sh_x_tag1_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_x_tag1_s;
-} sh_x_tag1_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG2"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_x_tag2_u {
-	mmr_t	sh_x_tag2_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_x_tag2_s;
-} sh_x_tag2_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG3"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_x_tag3_u {
-	mmr_t	sh_x_tag3_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_x_tag3_s;
-} sh_x_tag3_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG4"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_x_tag4_u {
-	mmr_t	sh_x_tag4_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_x_tag4_s;
-} sh_x_tag4_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG5"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_x_tag5_u {
-	mmr_t	sh_x_tag5_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_x_tag5_s;
-} sh_x_tag5_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG6"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_x_tag6_u {
-	mmr_t	sh_x_tag6_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_x_tag6_s;
-} sh_x_tag6_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_X_TAG7"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_x_tag7_u {
-	mmr_t	sh_x_tag7_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_x_tag7_s;
-} sh_x_tag7_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG0"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_y_tag0_u {
-	mmr_t	sh_y_tag0_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_y_tag0_s;
-} sh_y_tag0_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG1"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_y_tag1_u {
-	mmr_t	sh_y_tag1_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_y_tag1_s;
-} sh_y_tag1_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG2"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_y_tag2_u {
-	mmr_t	sh_y_tag2_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_y_tag2_s;
-} sh_y_tag2_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG3"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_y_tag3_u {
-	mmr_t	sh_y_tag3_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_y_tag3_s;
-} sh_y_tag3_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG4"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_y_tag4_u {
-	mmr_t	sh_y_tag4_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_y_tag4_s;
-} sh_y_tag4_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG5"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_y_tag5_u {
-	mmr_t	sh_y_tag5_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_y_tag5_s;
-} sh_y_tag5_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG6"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_y_tag6_u {
-	mmr_t	sh_y_tag6_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_y_tag6_s;
-} sh_y_tag6_u_t;
-
-/* ==================================================================== */
-/*                         Register "SH_Y_TAG7"                         */
-/*                           AC tag Registers                           */
-/* ==================================================================== */
-
-typedef union sh_y_tag7_u {
-	mmr_t	sh_y_tag7_regval;
-	struct {
-		mmr_t	tag         : 20;
-		mmr_t	reserved_0  : 44;
-	} sh_y_tag7_s;
-} sh_y_tag7_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_MMRBIST_BASE"                      */
-/*                        mmr/bist base address                         */
-/* ==================================================================== */
-
-typedef union sh_mmrbist_base_u {
-	mmr_t	sh_mmrbist_base_regval;
-	struct {
-		mmr_t	reserved_0  : 3;
-		mmr_t	dword_addr  : 47;
-		mmr_t	reserved_1  : 14;
-	} sh_mmrbist_base_s;
-} sh_mmrbist_base_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_MMRBIST_CTL"                       */
-/*                          Bist base address                           */
-/* ==================================================================== */
-
-typedef union sh_mmrbist_ctl_u {
-	mmr_t	sh_mmrbist_ctl_regval;
-	struct {
-		mmr_t	block_length : 31;
-		mmr_t	reserved_0   : 1;
-		mmr_t	cmd          : 7;
-		mmr_t	reserved_1   : 1;
-		mmr_t	in_progress  : 1;
-		mmr_t	fail         : 1;
-		mmr_t	mem_idle     : 1;
-		mmr_t	reserved_2   : 1;
-		mmr_t	reset_state  : 1;
-		mmr_t	reserved_3   : 19;
-	} sh_mmrbist_ctl_s;
-} sh_mmrbist_ctl_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_MD_DBUG_DATA_CFG"                    */
-/*                configuration for md debug data muxes                 */
-/* ==================================================================== */
-
-typedef union sh_md_dbug_data_cfg_u {
-	mmr_t	sh_md_dbug_data_cfg_regval;
-	struct {
-		mmr_t	nibble0_chiplet : 3;
-		mmr_t	reserved_0      : 1;
-		mmr_t	nibble0_nibble  : 3;
-		mmr_t	reserved_1      : 1;
-		mmr_t	nibble1_chiplet : 3;
-		mmr_t	reserved_2      : 1;
-		mmr_t	nibble1_nibble  : 3;
-		mmr_t	reserved_3      : 1;
-		mmr_t	nibble2_chiplet : 3;
-		mmr_t	reserved_4      : 1;
-		mmr_t	nibble2_nibble  : 3;
-		mmr_t	reserved_5      : 1;
-		mmr_t	nibble3_chiplet : 3;
-		mmr_t	reserved_6      : 1;
-		mmr_t	nibble3_nibble  : 3;
-		mmr_t	reserved_7      : 1;
-		mmr_t	nibble4_chiplet : 3;
-		mmr_t	reserved_8      : 1;
-		mmr_t	nibble4_nibble  : 3;
-		mmr_t	reserved_9      : 1;
-		mmr_t	nibble5_chiplet : 3;
-		mmr_t	reserved_10     : 1;
-		mmr_t	nibble5_nibble  : 3;
-		mmr_t	reserved_11     : 1;
-		mmr_t	nibble6_chiplet : 3;
-		mmr_t	reserved_12     : 1;
-		mmr_t	nibble6_nibble  : 3;
-		mmr_t	reserved_13     : 1;
-		mmr_t	nibble7_chiplet : 3;
-		mmr_t	reserved_14     : 1;
-		mmr_t	nibble7_nibble  : 3;
-		mmr_t	reserved_15     : 1;
-	} sh_md_dbug_data_cfg_s;
-} sh_md_dbug_data_cfg_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DBUG_TRIGGER_CFG"                   */
-/*                 configuration for md debug triggers                  */
-/* ==================================================================== */
-
-typedef union sh_md_dbug_trigger_cfg_u {
-	mmr_t	sh_md_dbug_trigger_cfg_regval;
-	struct {
-		mmr_t	nibble0_chiplet : 3;
-		mmr_t	reserved_0      : 1;
-		mmr_t	nibble0_nibble  : 3;
-		mmr_t	reserved_1      : 1;
-		mmr_t	nibble1_chiplet : 3;
-		mmr_t	reserved_2      : 1;
-		mmr_t	nibble1_nibble  : 3;
-		mmr_t	reserved_3      : 1;
-		mmr_t	nibble2_chiplet : 3;
-		mmr_t	reserved_4      : 1;
-		mmr_t	nibble2_nibble  : 3;
-		mmr_t	reserved_5      : 1;
-		mmr_t	nibble3_chiplet : 3;
-		mmr_t	reserved_6      : 1;
-		mmr_t	nibble3_nibble  : 3;
-		mmr_t	reserved_7      : 1;
-		mmr_t	nibble4_chiplet : 3;
-		mmr_t	reserved_8      : 1;
-		mmr_t	nibble4_nibble  : 3;
-		mmr_t	reserved_9      : 1;
-		mmr_t	nibble5_chiplet : 3;
-		mmr_t	reserved_10     : 1;
-		mmr_t	nibble5_nibble  : 3;
-		mmr_t	reserved_11     : 1;
-		mmr_t	nibble6_chiplet : 3;
-		mmr_t	reserved_12     : 1;
-		mmr_t	nibble6_nibble  : 3;
-		mmr_t	reserved_13     : 1;
-		mmr_t	nibble7_chiplet : 3;
-		mmr_t	reserved_14     : 1;
-		mmr_t	nibble7_nibble  : 3;
-		mmr_t	enable          : 1;
-	} sh_md_dbug_trigger_cfg_s;
-} sh_md_dbug_trigger_cfg_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_MD_DBUG_COMPARE"                     */
-/*                  md debug compare pattern and mask                   */
-/* ==================================================================== */
-
-typedef union sh_md_dbug_compare_u {
-	mmr_t	sh_md_dbug_compare_regval;
-	struct {
-		mmr_t	pattern     : 32;
-		mmr_t	mask        : 32;
-	} sh_md_dbug_compare_s;
-} sh_md_dbug_compare_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_X_MOD_DBUG_SEL"                     */
-/*                         MD acx debug select                          */
-/* ==================================================================== */
-
-typedef union sh_x_mod_dbug_sel_u {
-	mmr_t	sh_x_mod_dbug_sel_regval;
-	struct {
-		mmr_t	tag_sel     : 8;
-		mmr_t	wbq_sel     : 8;
-		mmr_t	arb_sel     : 8;
-		mmr_t	atl_sel     : 11;
-		mmr_t	atr_sel     : 11;
-		mmr_t	dql_sel     : 6;
-		mmr_t	dqr_sel     : 6;
-		mmr_t	reserved_0  : 6;
-	} sh_x_mod_dbug_sel_s;
-} sh_x_mod_dbug_sel_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_X_DBUG_SEL"                       */
-/*                         MD acx debug select                          */
-/* ==================================================================== */
-
-typedef union sh_x_dbug_sel_u {
-	mmr_t	sh_x_dbug_sel_regval;
-	struct {
-		mmr_t	dbg_sel     : 24;
-		mmr_t	reserved_0  : 40;
-	} sh_x_dbug_sel_s;
-} sh_x_dbug_sel_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_X_LADDR_CMP"                       */
-/*                        MD acx address compare                        */
-/* ==================================================================== */
-
-typedef union sh_x_laddr_cmp_u {
-	mmr_t	sh_x_laddr_cmp_regval;
-	struct {
-		mmr_t	cmp_val     : 28;
-		mmr_t	reserved_0  : 4;
-		mmr_t	mask_val    : 28;
-		mmr_t	reserved_1  : 4;
-	} sh_x_laddr_cmp_s;
-} sh_x_laddr_cmp_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_X_RADDR_CMP"                       */
-/*                        MD acx address compare                        */
-/* ==================================================================== */
-
-typedef union sh_x_raddr_cmp_u {
-	mmr_t	sh_x_raddr_cmp_regval;
-	struct {
-		mmr_t	cmp_val     : 28;
-		mmr_t	reserved_0  : 4;
-		mmr_t	mask_val    : 28;
-		mmr_t	reserved_1  : 4;
-	} sh_x_raddr_cmp_s;
-} sh_x_raddr_cmp_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_X_TAG_CMP"                        */
-/*                        MD acx tagmgr compare                         */
-/* ==================================================================== */
-
-typedef union sh_x_tag_cmp_u {
-	mmr_t	sh_x_tag_cmp_regval;
-	struct {
-		mmr_t	cmd         : 8;
-		mmr_t	addr        : 33;
-		mmr_t	src         : 14;
-		mmr_t	reserved_0  : 9;
-	} sh_x_tag_cmp_s;
-} sh_x_tag_cmp_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_X_TAG_MASK"                       */
-/*                          MD acx tagmgr mask                          */
-/* ==================================================================== */
-
-typedef union sh_x_tag_mask_u {
-	mmr_t	sh_x_tag_mask_regval;
-	struct {
-		mmr_t	cmd         : 8;
-		mmr_t	addr        : 33;
-		mmr_t	src         : 14;
-		mmr_t	reserved_0  : 9;
-	} sh_x_tag_mask_s;
-} sh_x_tag_mask_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_Y_MOD_DBUG_SEL"                     */
-/*                         MD acy debug select                          */
-/* ==================================================================== */
-
-typedef union sh_y_mod_dbug_sel_u {
-	mmr_t	sh_y_mod_dbug_sel_regval;
-	struct {
-		mmr_t	tag_sel     : 8;
-		mmr_t	wbq_sel     : 8;
-		mmr_t	arb_sel     : 8;
-		mmr_t	atl_sel     : 11;
-		mmr_t	atr_sel     : 11;
-		mmr_t	dql_sel     : 6;
-		mmr_t	dqr_sel     : 6;
-		mmr_t	reserved_0  : 6;
-	} sh_y_mod_dbug_sel_s;
-} sh_y_mod_dbug_sel_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_Y_DBUG_SEL"                       */
-/*                         MD acy debug select                          */
-/* ==================================================================== */
-
-typedef union sh_y_dbug_sel_u {
-	mmr_t	sh_y_dbug_sel_regval;
-	struct {
-		mmr_t	dbg_sel     : 24;
-		mmr_t	reserved_0  : 40;
-	} sh_y_dbug_sel_s;
-} sh_y_dbug_sel_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_Y_LADDR_CMP"                       */
-/*                        MD acy address compare                        */
-/* ==================================================================== */
-
-typedef union sh_y_laddr_cmp_u {
-	mmr_t	sh_y_laddr_cmp_regval;
-	struct {
-		mmr_t	cmp_val     : 28;
-		mmr_t	reserved_0  : 4;
-		mmr_t	mask_val    : 28;
-		mmr_t	reserved_1  : 4;
-	} sh_y_laddr_cmp_s;
-} sh_y_laddr_cmp_u_t;
-
-/* ==================================================================== */
-/*                      Register "SH_Y_RADDR_CMP"                       */
-/*                        MD acy address compare                        */
-/* ==================================================================== */
-
-typedef union sh_y_raddr_cmp_u {
-	mmr_t	sh_y_raddr_cmp_regval;
-	struct {
-		mmr_t	cmp_val     : 28;
-		mmr_t	reserved_0  : 4;
-		mmr_t	mask_val    : 28;
-		mmr_t	reserved_1  : 4;
-	} sh_y_raddr_cmp_s;
-} sh_y_raddr_cmp_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_Y_TAG_CMP"                        */
-/*                        MD acy tagmgr compare                         */
-/* ==================================================================== */
-
-typedef union sh_y_tag_cmp_u {
-	mmr_t	sh_y_tag_cmp_regval;
-	struct {
-		mmr_t	cmd         : 8;
-		mmr_t	addr        : 33;
-		mmr_t	src         : 14;
-		mmr_t	reserved_0  : 9;
-	} sh_y_tag_cmp_s;
-} sh_y_tag_cmp_u_t;
-
-/* ==================================================================== */
-/*                       Register "SH_Y_TAG_MASK"                       */
-/*                          MD acy tagmgr mask                          */
-/* ==================================================================== */
-
-typedef union sh_y_tag_mask_u {
-	mmr_t	sh_y_tag_mask_regval;
-	struct {
-		mmr_t	cmd         : 8;
-		mmr_t	addr        : 33;
-		mmr_t	src         : 14;
-		mmr_t	reserved_0  : 9;
-	} sh_y_tag_mask_s;
-} sh_y_tag_mask_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_JNR_DBUG_DATA_CFG"                  */
-/*              configuration for md jnr debug data muxes               */
-/* ==================================================================== */
-
-typedef union sh_md_jnr_dbug_data_cfg_u {
-	mmr_t	sh_md_jnr_dbug_data_cfg_regval;
-	struct {
-		mmr_t	nibble0_sel : 3;
-		mmr_t	reserved_0  : 1;
-		mmr_t	nibble1_sel : 3;
-		mmr_t	reserved_1  : 1;
-		mmr_t	nibble2_sel : 3;
-		mmr_t	reserved_2  : 1;
-		mmr_t	nibble3_sel : 3;
-		mmr_t	reserved_3  : 1;
-		mmr_t	nibble4_sel : 3;
-		mmr_t	reserved_4  : 1;
-		mmr_t	nibble5_sel : 3;
-		mmr_t	reserved_5  : 1;
-		mmr_t	nibble6_sel : 3;
-		mmr_t	reserved_6  : 1;
-		mmr_t	nibble7_sel : 3;
-		mmr_t	reserved_7  : 33;
-	} sh_md_jnr_dbug_data_cfg_s;
-} sh_md_jnr_dbug_data_cfg_u_t;
-
-/* ==================================================================== */
-/*                     Register "SH_MD_LAST_CREDIT"                     */
-/*                 captures last credit values on reset                 */
-/* ==================================================================== */
-
-typedef union sh_md_last_credit_u {
-	mmr_t	sh_md_last_credit_regval;
-	struct {
-		mmr_t	rq_to_pi    : 6;
-		mmr_t	reserved_0  : 2;
-		mmr_t	rp_to_pi    : 6;
-		mmr_t	reserved_1  : 2;
-		mmr_t	rq_to_xn    : 6;
-		mmr_t	reserved_2  : 2;
-		mmr_t	rp_to_xn    : 6;
-		mmr_t	reserved_3  : 2;
-		mmr_t	to_lb       : 6;
-		mmr_t	reserved_4  : 26;
-	} sh_md_last_credit_s;
-} sh_md_last_credit_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_MEM_CAPTURE_ADDR"                    */
-/*                   Address capture address register                   */
-/* ==================================================================== */
-
-typedef union sh_mem_capture_addr_u {
-	mmr_t	sh_mem_capture_addr_regval;
-	struct {
-		mmr_t	reserved_0  : 3;
-		mmr_t	addr        : 33;
-		mmr_t	cmd         : 8;
-		mmr_t	reserved_1  : 20;
-	} sh_mem_capture_addr_s;
-} sh_mem_capture_addr_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_MEM_CAPTURE_MASK"                    */
-/*                    Address capture mask register                     */
-/* ==================================================================== */
-
-typedef union sh_mem_capture_mask_u {
-	mmr_t	sh_mem_capture_mask_regval;
-	struct {
-		mmr_t	reserved_0    : 3;
-		mmr_t	addr          : 33;
-		mmr_t	cmd           : 8;
-		mmr_t	enable_local  : 1;
-		mmr_t	enable_remote : 1;
-		mmr_t	reserved_1    : 18;
-	} sh_mem_capture_mask_s;
-} sh_mem_capture_mask_u_t;
-
-/* ==================================================================== */
-/*                    Register "SH_MEM_CAPTURE_HDR"                     */
-/*                   Address capture header register                    */
-/* ==================================================================== */
-
-typedef union sh_mem_capture_hdr_u {
-	mmr_t	sh_mem_capture_hdr_regval;
-	struct {
-		mmr_t	reserved_0  : 3;
-		mmr_t	addr        : 33;
-		mmr_t	cmd         : 8;
-		mmr_t	src         : 14;
-		mmr_t	cntr        : 6;
-	} sh_mem_capture_hdr_s;
-} sh_mem_capture_hdr_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQLP_MMR_DIR_CONFIG"                 */
-/*                     DQ directory config register                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_config_u {
-	mmr_t	sh_md_dqlp_mmr_dir_config_regval;
-	struct {
-		mmr_t	sys_size    : 3;
-		mmr_t	en_direcc   : 1;
-		mmr_t	en_dirpois  : 1;
-		mmr_t	reserved_0  : 59;
-	} sh_md_dqlp_mmr_dir_config_s;
-} sh_md_dqlp_mmr_dir_config_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRESVEC0"                */
-/*                      node [63:0] presence bits                       */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_presvec0_u {
-	mmr_t	sh_md_dqlp_mmr_dir_presvec0_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_presvec0_s;
-} sh_md_dqlp_mmr_dir_presvec0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRESVEC1"                */
-/*                     node [127:64] presence bits                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_presvec1_u {
-	mmr_t	sh_md_dqlp_mmr_dir_presvec1_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_presvec1_s;
-} sh_md_dqlp_mmr_dir_presvec1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRESVEC2"                */
-/*                     node [191:128] presence bits                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_presvec2_u {
-	mmr_t	sh_md_dqlp_mmr_dir_presvec2_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_presvec2_s;
-} sh_md_dqlp_mmr_dir_presvec2_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRESVEC3"                */
-/*                     node [255:192] presence bits                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_presvec3_u {
-	mmr_t	sh_md_dqlp_mmr_dir_presvec3_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_presvec3_s;
-} sh_md_dqlp_mmr_dir_presvec3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC0"                 */
-/*                        local vector for acc=0                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_locvec0_u {
-	mmr_t	sh_md_dqlp_mmr_dir_locvec0_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_locvec0_s;
-} sh_md_dqlp_mmr_dir_locvec0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC1"                 */
-/*                        local vector for acc=1                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_locvec1_u {
-	mmr_t	sh_md_dqlp_mmr_dir_locvec1_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_locvec1_s;
-} sh_md_dqlp_mmr_dir_locvec1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC2"                 */
-/*                        local vector for acc=2                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_locvec2_u {
-	mmr_t	sh_md_dqlp_mmr_dir_locvec2_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_locvec2_s;
-} sh_md_dqlp_mmr_dir_locvec2_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC3"                 */
-/*                        local vector for acc=3                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_locvec3_u {
-	mmr_t	sh_md_dqlp_mmr_dir_locvec3_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_locvec3_s;
-} sh_md_dqlp_mmr_dir_locvec3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC4"                 */
-/*                        local vector for acc=4                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_locvec4_u {
-	mmr_t	sh_md_dqlp_mmr_dir_locvec4_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_locvec4_s;
-} sh_md_dqlp_mmr_dir_locvec4_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC5"                 */
-/*                        local vector for acc=5                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_locvec5_u {
-	mmr_t	sh_md_dqlp_mmr_dir_locvec5_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_locvec5_s;
-} sh_md_dqlp_mmr_dir_locvec5_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC6"                 */
-/*                        local vector for acc=6                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_locvec6_u {
-	mmr_t	sh_md_dqlp_mmr_dir_locvec6_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_locvec6_s;
-} sh_md_dqlp_mmr_dir_locvec6_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_LOCVEC7"                 */
-/*                        local vector for acc=7                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_locvec7_u {
-	mmr_t	sh_md_dqlp_mmr_dir_locvec7_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqlp_mmr_dir_locvec7_s;
-} sh_md_dqlp_mmr_dir_locvec7_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC0"                 */
-/*                      privilege vector for acc=0                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_privec0_u {
-	mmr_t	sh_md_dqlp_mmr_dir_privec0_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqlp_mmr_dir_privec0_s;
-} sh_md_dqlp_mmr_dir_privec0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC1"                 */
-/*                      privilege vector for acc=1                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_privec1_u {
-	mmr_t	sh_md_dqlp_mmr_dir_privec1_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqlp_mmr_dir_privec1_s;
-} sh_md_dqlp_mmr_dir_privec1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC2"                 */
-/*                      privilege vector for acc=2                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_privec2_u {
-	mmr_t	sh_md_dqlp_mmr_dir_privec2_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqlp_mmr_dir_privec2_s;
-} sh_md_dqlp_mmr_dir_privec2_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC3"                 */
-/*                      privilege vector for acc=3                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_privec3_u {
-	mmr_t	sh_md_dqlp_mmr_dir_privec3_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqlp_mmr_dir_privec3_s;
-} sh_md_dqlp_mmr_dir_privec3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC4"                 */
-/*                      privilege vector for acc=4                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_privec4_u {
-	mmr_t	sh_md_dqlp_mmr_dir_privec4_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqlp_mmr_dir_privec4_s;
-} sh_md_dqlp_mmr_dir_privec4_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC5"                 */
-/*                      privilege vector for acc=5                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_privec5_u {
-	mmr_t	sh_md_dqlp_mmr_dir_privec5_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqlp_mmr_dir_privec5_s;
-} sh_md_dqlp_mmr_dir_privec5_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC6"                 */
-/*                      privilege vector for acc=6                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_privec6_u {
-	mmr_t	sh_md_dqlp_mmr_dir_privec6_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqlp_mmr_dir_privec6_s;
-} sh_md_dqlp_mmr_dir_privec6_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_PRIVEC7"                 */
-/*                      privilege vector for acc=7                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_privec7_u {
-	mmr_t	sh_md_dqlp_mmr_dir_privec7_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqlp_mmr_dir_privec7_s;
-} sh_md_dqlp_mmr_dir_privec7_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQLP_MMR_DIR_TIMER"                  */
-/*                            MD SXRO timer                             */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_timer_u {
-	mmr_t	sh_md_dqlp_mmr_dir_timer_regval;
-	struct {
-		mmr_t	timer_div   : 12;
-		mmr_t	timer_en    : 1;
-		mmr_t	timer_cur   : 9;
-		mmr_t	reserved_0  : 42;
-	} sh_md_dqlp_mmr_dir_timer_s;
-} sh_md_dqlp_mmr_dir_timer_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQLP_MMR_PIOWD_DIR_ENTRY"               */
-/*                       directory pio write data                       */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_piowd_dir_entry_u {
-	mmr_t	sh_md_dqlp_mmr_piowd_dir_entry_regval;
-	struct {
-		mmr_t	dira        : 26;
-		mmr_t	dirb        : 26;
-		mmr_t	pri         : 3;
-		mmr_t	acc         : 3;
-		mmr_t	reserved_0  : 6;
-	} sh_md_dqlp_mmr_piowd_dir_entry_s;
-} sh_md_dqlp_mmr_piowd_dir_entry_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_MD_DQLP_MMR_PIOWD_DIR_ECC"                */
-/*                        directory ecc register                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_piowd_dir_ecc_u {
-	mmr_t	sh_md_dqlp_mmr_piowd_dir_ecc_regval;
-	struct {
-		mmr_t	ecca        : 7;
-		mmr_t	eccb        : 7;
-		mmr_t	reserved_0  : 50;
-	} sh_md_dqlp_mmr_piowd_dir_ecc_s;
-} sh_md_dqlp_mmr_piowd_dir_ecc_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_MD_DQLP_MMR_XPIORD_XDIR_ENTRY"              */
-/*                      x directory pio read data                       */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xpiord_xdir_entry_u {
-	mmr_t	sh_md_dqlp_mmr_xpiord_xdir_entry_regval;
-	struct {
-		mmr_t	dira        : 26;
-		mmr_t	dirb        : 26;
-		mmr_t	pri         : 3;
-		mmr_t	acc         : 3;
-		mmr_t	cor         : 1;
-		mmr_t	unc         : 1;
-		mmr_t	reserved_0  : 4;
-	} sh_md_dqlp_mmr_xpiord_xdir_entry_s;
-} sh_md_dqlp_mmr_xpiord_xdir_entry_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQLP_MMR_XPIORD_XDIR_ECC"               */
-/*                           x directory ecc                            */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xpiord_xdir_ecc_u {
-	mmr_t	sh_md_dqlp_mmr_xpiord_xdir_ecc_regval;
-	struct {
-		mmr_t	ecca        : 7;
-		mmr_t	eccb        : 7;
-		mmr_t	reserved_0  : 50;
-	} sh_md_dqlp_mmr_xpiord_xdir_ecc_s;
-} sh_md_dqlp_mmr_xpiord_xdir_ecc_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_MD_DQLP_MMR_YPIORD_YDIR_ENTRY"              */
-/*                      y directory pio read data                       */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_ypiord_ydir_entry_u {
-	mmr_t	sh_md_dqlp_mmr_ypiord_ydir_entry_regval;
-	struct {
-		mmr_t	dira        : 26;
-		mmr_t	dirb        : 26;
-		mmr_t	pri         : 3;
-		mmr_t	acc         : 3;
-		mmr_t	cor         : 1;
-		mmr_t	unc         : 1;
-		mmr_t	reserved_0  : 4;
-	} sh_md_dqlp_mmr_ypiord_ydir_entry_s;
-} sh_md_dqlp_mmr_ypiord_ydir_entry_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQLP_MMR_YPIORD_YDIR_ECC"               */
-/*                           y directory ecc                            */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_ypiord_ydir_ecc_u {
-	mmr_t	sh_md_dqlp_mmr_ypiord_ydir_ecc_regval;
-	struct {
-		mmr_t	ecca        : 7;
-		mmr_t	eccb        : 7;
-		mmr_t	reserved_0  : 50;
-	} sh_md_dqlp_mmr_ypiord_ydir_ecc_s;
-} sh_md_dqlp_mmr_ypiord_ydir_ecc_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XCERR1"                   */
-/*              correctable dir ecc group 1 error register              */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xcerr1_u {
-	mmr_t	sh_md_dqlp_mmr_xcerr1_regval;
-	struct {
-		mmr_t	grp1        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 25;
-	} sh_md_dqlp_mmr_xcerr1_s;
-} sh_md_dqlp_mmr_xcerr1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XCERR2"                   */
-/*              correctable dir ecc group 2 error register              */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xcerr2_u {
-	mmr_t	sh_md_dqlp_mmr_xcerr2_regval;
-	struct {
-		mmr_t	grp2        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 26;
-	} sh_md_dqlp_mmr_xcerr2_s;
-} sh_md_dqlp_mmr_xcerr2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XUERR1"                   */
-/*             uncorrectable dir ecc group 1 error register             */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xuerr1_u {
-	mmr_t	sh_md_dqlp_mmr_xuerr1_regval;
-	struct {
-		mmr_t	grp1        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 25;
-	} sh_md_dqlp_mmr_xuerr1_s;
-} sh_md_dqlp_mmr_xuerr1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XUERR2"                   */
-/*             uncorrectable dir ecc group 2 error register             */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xuerr2_u {
-	mmr_t	sh_md_dqlp_mmr_xuerr2_regval;
-	struct {
-		mmr_t	grp2        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 26;
-	} sh_md_dqlp_mmr_xuerr2_s;
-} sh_md_dqlp_mmr_xuerr2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_XPERR"                    */
-/*                       protocol error register                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xperr_u {
-	mmr_t	sh_md_dqlp_mmr_xperr_regval;
-	struct {
-		mmr_t	dir         : 26;
-		mmr_t	cmd         : 8;
-		mmr_t	src         : 14;
-		mmr_t	prige       : 1;
-		mmr_t	priv        : 1;
-		mmr_t	cor         : 1;
-		mmr_t	unc         : 1;
-		mmr_t	mybit       : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 1;
-	} sh_md_dqlp_mmr_xperr_s;
-} sh_md_dqlp_mmr_xperr_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YCERR1"                   */
-/*              correctable dir ecc group 1 error register              */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_ycerr1_u {
-	mmr_t	sh_md_dqlp_mmr_ycerr1_regval;
-	struct {
-		mmr_t	grp1        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 25;
-	} sh_md_dqlp_mmr_ycerr1_s;
-} sh_md_dqlp_mmr_ycerr1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YCERR2"                   */
-/*              correctable dir ecc group 2 error register              */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_ycerr2_u {
-	mmr_t	sh_md_dqlp_mmr_ycerr2_regval;
-	struct {
-		mmr_t	grp2        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 26;
-	} sh_md_dqlp_mmr_ycerr2_s;
-} sh_md_dqlp_mmr_ycerr2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YUERR1"                   */
-/*             uncorrectable dir ecc group 1 error register             */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_yuerr1_u {
-	mmr_t	sh_md_dqlp_mmr_yuerr1_regval;
-	struct {
-		mmr_t	grp1        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 25;
-	} sh_md_dqlp_mmr_yuerr1_s;
-} sh_md_dqlp_mmr_yuerr1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YUERR2"                   */
-/*             uncorrectable dir ecc group 2 error register             */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_yuerr2_u {
-	mmr_t	sh_md_dqlp_mmr_yuerr2_regval;
-	struct {
-		mmr_t	grp2        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 26;
-	} sh_md_dqlp_mmr_yuerr2_s;
-} sh_md_dqlp_mmr_yuerr2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQLP_MMR_YPERR"                    */
-/*                       protocol error register                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_yperr_u {
-	mmr_t	sh_md_dqlp_mmr_yperr_regval;
-	struct {
-		mmr_t	dir         : 26;
-		mmr_t	cmd         : 8;
-		mmr_t	src         : 14;
-		mmr_t	prige       : 1;
-		mmr_t	priv        : 1;
-		mmr_t	cor         : 1;
-		mmr_t	unc         : 1;
-		mmr_t	mybit       : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 1;
-	} sh_md_dqlp_mmr_yperr_s;
-} sh_md_dqlp_mmr_yperr_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_CMDTRIG"                 */
-/*                             cmd triggers                             */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_cmdtrig_u {
-	mmr_t	sh_md_dqlp_mmr_dir_cmdtrig_regval;
-	struct {
-		mmr_t	cmd0        : 8;
-		mmr_t	cmd1        : 8;
-		mmr_t	cmd2        : 8;
-		mmr_t	cmd3        : 8;
-		mmr_t	reserved_0  : 32;
-	} sh_md_dqlp_mmr_dir_cmdtrig_s;
-} sh_md_dqlp_mmr_dir_cmdtrig_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_TBLTRIG"                 */
-/*                          dir table trigger                           */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_tbltrig_u {
-	mmr_t	sh_md_dqlp_mmr_dir_tbltrig_regval;
-	struct {
-		mmr_t	src         : 14;
-		mmr_t	cmd         : 8;
-		mmr_t	acc         : 2;
-		mmr_t	prige       : 1;
-		mmr_t	dirst       : 9;
-		mmr_t	mybit       : 8;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqlp_mmr_dir_tbltrig_s;
-} sh_md_dqlp_mmr_dir_tbltrig_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_DIR_TBLMASK"                 */
-/*                        dir table trigger mask                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_dir_tblmask_u {
-	mmr_t	sh_md_dqlp_mmr_dir_tblmask_regval;
-	struct {
-		mmr_t	src         : 14;
-		mmr_t	cmd         : 8;
-		mmr_t	acc         : 2;
-		mmr_t	prige       : 1;
-		mmr_t	dirst       : 9;
-		mmr_t	mybit       : 8;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqlp_mmr_dir_tblmask_s;
-} sh_md_dqlp_mmr_dir_tblmask_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLP_MMR_XBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xbist_h_u {
-	mmr_t	sh_md_dqlp_mmr_xbist_h_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_1  : 21;
-	} sh_md_dqlp_mmr_xbist_h_s;
-} sh_md_dqlp_mmr_xbist_h_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLP_MMR_XBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xbist_l_u {
-	mmr_t	sh_md_dqlp_mmr_xbist_l_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqlp_mmr_xbist_l_s;
-} sh_md_dqlp_mmr_xbist_l_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_XBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xbist_err_h_u {
-	mmr_t	sh_md_dqlp_mmr_xbist_err_h_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqlp_mmr_xbist_err_h_s;
-} sh_md_dqlp_mmr_xbist_err_h_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_XBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_xbist_err_l_u {
-	mmr_t	sh_md_dqlp_mmr_xbist_err_l_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqlp_mmr_xbist_err_l_s;
-} sh_md_dqlp_mmr_xbist_err_l_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLP_MMR_YBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_ybist_h_u {
-	mmr_t	sh_md_dqlp_mmr_ybist_h_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_1  : 21;
-	} sh_md_dqlp_mmr_ybist_h_s;
-} sh_md_dqlp_mmr_ybist_h_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLP_MMR_YBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_ybist_l_u {
-	mmr_t	sh_md_dqlp_mmr_ybist_l_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqlp_mmr_ybist_l_s;
-} sh_md_dqlp_mmr_ybist_l_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_YBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_ybist_err_h_u {
-	mmr_t	sh_md_dqlp_mmr_ybist_err_h_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqlp_mmr_ybist_err_h_s;
-} sh_md_dqlp_mmr_ybist_err_h_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLP_MMR_YBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqlp_mmr_ybist_err_l_u {
-	mmr_t	sh_md_dqlp_mmr_ybist_err_l_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqlp_mmr_ybist_err_l_s;
-} sh_md_dqlp_mmr_ybist_err_l_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLS_MMR_XBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_xbist_h_u {
-	mmr_t	sh_md_dqls_mmr_xbist_h_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 21;
-	} sh_md_dqls_mmr_xbist_h_s;
-} sh_md_dqls_mmr_xbist_h_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLS_MMR_XBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_xbist_l_u {
-	mmr_t	sh_md_dqls_mmr_xbist_l_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqls_mmr_xbist_l_s;
-} sh_md_dqls_mmr_xbist_l_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLS_MMR_XBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_xbist_err_h_u {
-	mmr_t	sh_md_dqls_mmr_xbist_err_h_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqls_mmr_xbist_err_h_s;
-} sh_md_dqls_mmr_xbist_err_h_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLS_MMR_XBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_xbist_err_l_u {
-	mmr_t	sh_md_dqls_mmr_xbist_err_l_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqls_mmr_xbist_err_l_s;
-} sh_md_dqls_mmr_xbist_err_l_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLS_MMR_YBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_ybist_h_u {
-	mmr_t	sh_md_dqls_mmr_ybist_h_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 21;
-	} sh_md_dqls_mmr_ybist_h_s;
-} sh_md_dqls_mmr_ybist_h_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQLS_MMR_YBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_ybist_l_u {
-	mmr_t	sh_md_dqls_mmr_ybist_l_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqls_mmr_ybist_l_s;
-} sh_md_dqls_mmr_ybist_l_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLS_MMR_YBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_ybist_err_h_u {
-	mmr_t	sh_md_dqls_mmr_ybist_err_h_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqls_mmr_ybist_err_h_s;
-} sh_md_dqls_mmr_ybist_err_h_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQLS_MMR_YBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_ybist_err_l_u {
-	mmr_t	sh_md_dqls_mmr_ybist_err_l_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqls_mmr_ybist_err_l_s;
-} sh_md_dqls_mmr_ybist_err_l_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQLS_MMR_JNR_DEBUG"                  */
-/*                    joiner/fct debug configuration                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_jnr_debug_u {
-	mmr_t	sh_md_dqls_mmr_jnr_debug_regval;
-	struct {
-		mmr_t	px          : 1;
-		mmr_t	rw          : 1;
-		mmr_t	reserved_0  : 62;
-	} sh_md_dqls_mmr_jnr_debug_s;
-} sh_md_dqls_mmr_jnr_debug_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQLS_MMR_XAMOPW_ERR"                 */
-/*                  amo/partial rmw ecc error register                  */
-/* ==================================================================== */
-
-typedef union sh_md_dqls_mmr_xamopw_err_u {
-	mmr_t	sh_md_dqls_mmr_xamopw_err_regval;
-	struct {
-		mmr_t	ssyn        : 8;
-		mmr_t	scor        : 1;
-		mmr_t	sunc        : 1;
-		mmr_t	reserved_0  : 6;
-		mmr_t	rsyn        : 8;
-		mmr_t	rcor        : 1;
-		mmr_t	runc        : 1;
-		mmr_t	reserved_1  : 6;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_2  : 31;
-	} sh_md_dqls_mmr_xamopw_err_s;
-} sh_md_dqls_mmr_xamopw_err_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQRP_MMR_DIR_CONFIG"                 */
-/*                     DQ directory config register                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_config_u {
-	mmr_t	sh_md_dqrp_mmr_dir_config_regval;
-	struct {
-		mmr_t	sys_size    : 3;
-		mmr_t	en_direcc   : 1;
-		mmr_t	en_dirpois  : 1;
-		mmr_t	reserved_0  : 59;
-	} sh_md_dqrp_mmr_dir_config_s;
-} sh_md_dqrp_mmr_dir_config_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRESVEC0"                */
-/*                      node [63:0] presence bits                       */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_presvec0_u {
-	mmr_t	sh_md_dqrp_mmr_dir_presvec0_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_presvec0_s;
-} sh_md_dqrp_mmr_dir_presvec0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRESVEC1"                */
-/*                     node [127:64] presence bits                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_presvec1_u {
-	mmr_t	sh_md_dqrp_mmr_dir_presvec1_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_presvec1_s;
-} sh_md_dqrp_mmr_dir_presvec1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRESVEC2"                */
-/*                     node [191:128] presence bits                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_presvec2_u {
-	mmr_t	sh_md_dqrp_mmr_dir_presvec2_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_presvec2_s;
-} sh_md_dqrp_mmr_dir_presvec2_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRESVEC3"                */
-/*                     node [255:192] presence bits                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_presvec3_u {
-	mmr_t	sh_md_dqrp_mmr_dir_presvec3_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_presvec3_s;
-} sh_md_dqrp_mmr_dir_presvec3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC0"                 */
-/*                        local vector for acc=0                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_locvec0_u {
-	mmr_t	sh_md_dqrp_mmr_dir_locvec0_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_locvec0_s;
-} sh_md_dqrp_mmr_dir_locvec0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC1"                 */
-/*                        local vector for acc=1                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_locvec1_u {
-	mmr_t	sh_md_dqrp_mmr_dir_locvec1_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_locvec1_s;
-} sh_md_dqrp_mmr_dir_locvec1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC2"                 */
-/*                        local vector for acc=2                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_locvec2_u {
-	mmr_t	sh_md_dqrp_mmr_dir_locvec2_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_locvec2_s;
-} sh_md_dqrp_mmr_dir_locvec2_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC3"                 */
-/*                        local vector for acc=3                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_locvec3_u {
-	mmr_t	sh_md_dqrp_mmr_dir_locvec3_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_locvec3_s;
-} sh_md_dqrp_mmr_dir_locvec3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC4"                 */
-/*                        local vector for acc=4                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_locvec4_u {
-	mmr_t	sh_md_dqrp_mmr_dir_locvec4_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_locvec4_s;
-} sh_md_dqrp_mmr_dir_locvec4_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC5"                 */
-/*                        local vector for acc=5                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_locvec5_u {
-	mmr_t	sh_md_dqrp_mmr_dir_locvec5_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_locvec5_s;
-} sh_md_dqrp_mmr_dir_locvec5_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC6"                 */
-/*                        local vector for acc=6                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_locvec6_u {
-	mmr_t	sh_md_dqrp_mmr_dir_locvec6_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_locvec6_s;
-} sh_md_dqrp_mmr_dir_locvec6_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_LOCVEC7"                 */
-/*                        local vector for acc=7                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_locvec7_u {
-	mmr_t	sh_md_dqrp_mmr_dir_locvec7_regval;
-	struct {
-		mmr_t	vec         : 64;
-	} sh_md_dqrp_mmr_dir_locvec7_s;
-} sh_md_dqrp_mmr_dir_locvec7_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC0"                 */
-/*                      privilege vector for acc=0                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_privec0_u {
-	mmr_t	sh_md_dqrp_mmr_dir_privec0_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqrp_mmr_dir_privec0_s;
-} sh_md_dqrp_mmr_dir_privec0_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC1"                 */
-/*                      privilege vector for acc=1                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_privec1_u {
-	mmr_t	sh_md_dqrp_mmr_dir_privec1_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqrp_mmr_dir_privec1_s;
-} sh_md_dqrp_mmr_dir_privec1_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC2"                 */
-/*                      privilege vector for acc=2                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_privec2_u {
-	mmr_t	sh_md_dqrp_mmr_dir_privec2_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqrp_mmr_dir_privec2_s;
-} sh_md_dqrp_mmr_dir_privec2_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC3"                 */
-/*                      privilege vector for acc=3                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_privec3_u {
-	mmr_t	sh_md_dqrp_mmr_dir_privec3_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqrp_mmr_dir_privec3_s;
-} sh_md_dqrp_mmr_dir_privec3_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC4"                 */
-/*                      privilege vector for acc=4                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_privec4_u {
-	mmr_t	sh_md_dqrp_mmr_dir_privec4_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqrp_mmr_dir_privec4_s;
-} sh_md_dqrp_mmr_dir_privec4_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC5"                 */
-/*                      privilege vector for acc=5                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_privec5_u {
-	mmr_t	sh_md_dqrp_mmr_dir_privec5_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqrp_mmr_dir_privec5_s;
-} sh_md_dqrp_mmr_dir_privec5_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC6"                 */
-/*                      privilege vector for acc=6                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_privec6_u {
-	mmr_t	sh_md_dqrp_mmr_dir_privec6_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqrp_mmr_dir_privec6_s;
-} sh_md_dqrp_mmr_dir_privec6_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_PRIVEC7"                 */
-/*                      privilege vector for acc=7                      */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_privec7_u {
-	mmr_t	sh_md_dqrp_mmr_dir_privec7_regval;
-	struct {
-		mmr_t	in          : 14;
-		mmr_t	out         : 14;
-		mmr_t	reserved_0  : 36;
-	} sh_md_dqrp_mmr_dir_privec7_s;
-} sh_md_dqrp_mmr_dir_privec7_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQRP_MMR_DIR_TIMER"                  */
-/*                            MD SXRO timer                             */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_timer_u {
-	mmr_t	sh_md_dqrp_mmr_dir_timer_regval;
-	struct {
-		mmr_t	timer_div   : 12;
-		mmr_t	timer_en    : 1;
-		mmr_t	timer_cur   : 9;
-		mmr_t	reserved_0  : 42;
-	} sh_md_dqrp_mmr_dir_timer_s;
-} sh_md_dqrp_mmr_dir_timer_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQRP_MMR_PIOWD_DIR_ENTRY"               */
-/*                       directory pio write data                       */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_piowd_dir_entry_u {
-	mmr_t	sh_md_dqrp_mmr_piowd_dir_entry_regval;
-	struct {
-		mmr_t	dira        : 26;
-		mmr_t	dirb        : 26;
-		mmr_t	pri         : 3;
-		mmr_t	acc         : 3;
-		mmr_t	reserved_0  : 6;
-	} sh_md_dqrp_mmr_piowd_dir_entry_s;
-} sh_md_dqrp_mmr_piowd_dir_entry_u_t;
-
-/* ==================================================================== */
-/*               Register "SH_MD_DQRP_MMR_PIOWD_DIR_ECC"                */
-/*                        directory ecc register                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_piowd_dir_ecc_u {
-	mmr_t	sh_md_dqrp_mmr_piowd_dir_ecc_regval;
-	struct {
-		mmr_t	ecca        : 7;
-		mmr_t	eccb        : 7;
-		mmr_t	reserved_0  : 50;
-	} sh_md_dqrp_mmr_piowd_dir_ecc_s;
-} sh_md_dqrp_mmr_piowd_dir_ecc_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_MD_DQRP_MMR_XPIORD_XDIR_ENTRY"              */
-/*                      x directory pio read data                       */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xpiord_xdir_entry_u {
-	mmr_t	sh_md_dqrp_mmr_xpiord_xdir_entry_regval;
-	struct {
-		mmr_t	dira        : 26;
-		mmr_t	dirb        : 26;
-		mmr_t	pri         : 3;
-		mmr_t	acc         : 3;
-		mmr_t	cor         : 1;
-		mmr_t	unc         : 1;
-		mmr_t	reserved_0  : 4;
-	} sh_md_dqrp_mmr_xpiord_xdir_entry_s;
-} sh_md_dqrp_mmr_xpiord_xdir_entry_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQRP_MMR_XPIORD_XDIR_ECC"               */
-/*                           x directory ecc                            */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xpiord_xdir_ecc_u {
-	mmr_t	sh_md_dqrp_mmr_xpiord_xdir_ecc_regval;
-	struct {
-		mmr_t	ecca        : 7;
-		mmr_t	eccb        : 7;
-		mmr_t	reserved_0  : 50;
-	} sh_md_dqrp_mmr_xpiord_xdir_ecc_s;
-} sh_md_dqrp_mmr_xpiord_xdir_ecc_u_t;
-
-/* ==================================================================== */
-/*             Register "SH_MD_DQRP_MMR_YPIORD_YDIR_ENTRY"              */
-/*                      y directory pio read data                       */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_ypiord_ydir_entry_u {
-	mmr_t	sh_md_dqrp_mmr_ypiord_ydir_entry_regval;
-	struct {
-		mmr_t	dira        : 26;
-		mmr_t	dirb        : 26;
-		mmr_t	pri         : 3;
-		mmr_t	acc         : 3;
-		mmr_t	cor         : 1;
-		mmr_t	unc         : 1;
-		mmr_t	reserved_0  : 4;
-	} sh_md_dqrp_mmr_ypiord_ydir_entry_s;
-} sh_md_dqrp_mmr_ypiord_ydir_entry_u_t;
-
-/* ==================================================================== */
-/*              Register "SH_MD_DQRP_MMR_YPIORD_YDIR_ECC"               */
-/*                           y directory ecc                            */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_ypiord_ydir_ecc_u {
-	mmr_t	sh_md_dqrp_mmr_ypiord_ydir_ecc_regval;
-	struct {
-		mmr_t	ecca        : 7;
-		mmr_t	eccb        : 7;
-		mmr_t	reserved_0  : 50;
-	} sh_md_dqrp_mmr_ypiord_ydir_ecc_s;
-} sh_md_dqrp_mmr_ypiord_ydir_ecc_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XCERR1"                   */
-/*              correctable dir ecc group 1 error register              */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xcerr1_u {
-	mmr_t	sh_md_dqrp_mmr_xcerr1_regval;
-	struct {
-		mmr_t	grp1        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 25;
-	} sh_md_dqrp_mmr_xcerr1_s;
-} sh_md_dqrp_mmr_xcerr1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XCERR2"                   */
-/*              correctable dir ecc group 2 error register              */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xcerr2_u {
-	mmr_t	sh_md_dqrp_mmr_xcerr2_regval;
-	struct {
-		mmr_t	grp2        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 26;
-	} sh_md_dqrp_mmr_xcerr2_s;
-} sh_md_dqrp_mmr_xcerr2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XUERR1"                   */
-/*             uncorrectable dir ecc group 1 error register             */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xuerr1_u {
-	mmr_t	sh_md_dqrp_mmr_xuerr1_regval;
-	struct {
-		mmr_t	grp1        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 25;
-	} sh_md_dqrp_mmr_xuerr1_s;
-} sh_md_dqrp_mmr_xuerr1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XUERR2"                   */
-/*             uncorrectable dir ecc group 2 error register             */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xuerr2_u {
-	mmr_t	sh_md_dqrp_mmr_xuerr2_regval;
-	struct {
-		mmr_t	grp2        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 26;
-	} sh_md_dqrp_mmr_xuerr2_s;
-} sh_md_dqrp_mmr_xuerr2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_XPERR"                    */
-/*                       protocol error register                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xperr_u {
-	mmr_t	sh_md_dqrp_mmr_xperr_regval;
-	struct {
-		mmr_t	dir         : 26;
-		mmr_t	cmd         : 8;
-		mmr_t	src         : 14;
-		mmr_t	prige       : 1;
-		mmr_t	priv        : 1;
-		mmr_t	cor         : 1;
-		mmr_t	unc         : 1;
-		mmr_t	mybit       : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 1;
-	} sh_md_dqrp_mmr_xperr_s;
-} sh_md_dqrp_mmr_xperr_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YCERR1"                   */
-/*              correctable dir ecc group 1 error register              */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_ycerr1_u {
-	mmr_t	sh_md_dqrp_mmr_ycerr1_regval;
-	struct {
-		mmr_t	grp1        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 25;
-	} sh_md_dqrp_mmr_ycerr1_s;
-} sh_md_dqrp_mmr_ycerr1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YCERR2"                   */
-/*              correctable dir ecc group 2 error register              */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_ycerr2_u {
-	mmr_t	sh_md_dqrp_mmr_ycerr2_regval;
-	struct {
-		mmr_t	grp2        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 26;
-	} sh_md_dqrp_mmr_ycerr2_s;
-} sh_md_dqrp_mmr_ycerr2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YUERR1"                   */
-/*             uncorrectable dir ecc group 1 error register             */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_yuerr1_u {
-	mmr_t	sh_md_dqrp_mmr_yuerr1_regval;
-	struct {
-		mmr_t	grp1        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 25;
-	} sh_md_dqrp_mmr_yuerr1_s;
-} sh_md_dqrp_mmr_yuerr1_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YUERR2"                   */
-/*             uncorrectable dir ecc group 2 error register             */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_yuerr2_u {
-	mmr_t	sh_md_dqrp_mmr_yuerr2_regval;
-	struct {
-		mmr_t	grp2        : 36;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 26;
-	} sh_md_dqrp_mmr_yuerr2_s;
-} sh_md_dqrp_mmr_yuerr2_u_t;
-
-/* ==================================================================== */
-/*                   Register "SH_MD_DQRP_MMR_YPERR"                    */
-/*                       protocol error register                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_yperr_u {
-	mmr_t	sh_md_dqrp_mmr_yperr_regval;
-	struct {
-		mmr_t	dir         : 26;
-		mmr_t	cmd         : 8;
-		mmr_t	src         : 14;
-		mmr_t	prige       : 1;
-		mmr_t	priv        : 1;
-		mmr_t	cor         : 1;
-		mmr_t	unc         : 1;
-		mmr_t	mybit       : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 1;
-	} sh_md_dqrp_mmr_yperr_s;
-} sh_md_dqrp_mmr_yperr_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_CMDTRIG"                 */
-/*                             cmd triggers                             */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_cmdtrig_u {
-	mmr_t	sh_md_dqrp_mmr_dir_cmdtrig_regval;
-	struct {
-		mmr_t	cmd0        : 8;
-		mmr_t	cmd1        : 8;
-		mmr_t	cmd2        : 8;
-		mmr_t	cmd3        : 8;
-		mmr_t	reserved_0  : 32;
-	} sh_md_dqrp_mmr_dir_cmdtrig_s;
-} sh_md_dqrp_mmr_dir_cmdtrig_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_TBLTRIG"                 */
-/*                          dir table trigger                           */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_tbltrig_u {
-	mmr_t	sh_md_dqrp_mmr_dir_tbltrig_regval;
-	struct {
-		mmr_t	src         : 14;
-		mmr_t	cmd         : 8;
-		mmr_t	acc         : 2;
-		mmr_t	prige       : 1;
-		mmr_t	dirst       : 9;
-		mmr_t	mybit       : 8;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqrp_mmr_dir_tbltrig_s;
-} sh_md_dqrp_mmr_dir_tbltrig_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_DIR_TBLMASK"                 */
-/*                        dir table trigger mask                        */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_dir_tblmask_u {
-	mmr_t	sh_md_dqrp_mmr_dir_tblmask_regval;
-	struct {
-		mmr_t	src         : 14;
-		mmr_t	cmd         : 8;
-		mmr_t	acc         : 2;
-		mmr_t	prige       : 1;
-		mmr_t	dirst       : 9;
-		mmr_t	mybit       : 8;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqrp_mmr_dir_tblmask_s;
-} sh_md_dqrp_mmr_dir_tblmask_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRP_MMR_XBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xbist_h_u {
-	mmr_t	sh_md_dqrp_mmr_xbist_h_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_1  : 21;
-	} sh_md_dqrp_mmr_xbist_h_s;
-} sh_md_dqrp_mmr_xbist_h_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRP_MMR_XBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xbist_l_u {
-	mmr_t	sh_md_dqrp_mmr_xbist_l_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqrp_mmr_xbist_l_s;
-} sh_md_dqrp_mmr_xbist_l_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_XBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xbist_err_h_u {
-	mmr_t	sh_md_dqrp_mmr_xbist_err_h_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqrp_mmr_xbist_err_h_s;
-} sh_md_dqrp_mmr_xbist_err_h_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_XBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_xbist_err_l_u {
-	mmr_t	sh_md_dqrp_mmr_xbist_err_l_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqrp_mmr_xbist_err_l_s;
-} sh_md_dqrp_mmr_xbist_err_l_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRP_MMR_YBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_ybist_h_u {
-	mmr_t	sh_md_dqrp_mmr_ybist_h_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_1  : 21;
-	} sh_md_dqrp_mmr_ybist_h_s;
-} sh_md_dqrp_mmr_ybist_h_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRP_MMR_YBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_ybist_l_u {
-	mmr_t	sh_md_dqrp_mmr_ybist_l_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqrp_mmr_ybist_l_s;
-} sh_md_dqrp_mmr_ybist_l_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_YBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_ybist_err_h_u {
-	mmr_t	sh_md_dqrp_mmr_ybist_err_h_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqrp_mmr_ybist_err_h_s;
-} sh_md_dqrp_mmr_ybist_err_h_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRP_MMR_YBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrp_mmr_ybist_err_l_u {
-	mmr_t	sh_md_dqrp_mmr_ybist_err_l_regval;
-	struct {
-		mmr_t	pat         : 32;
-		mmr_t	reserved_0  : 8;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_1  : 22;
-	} sh_md_dqrp_mmr_ybist_err_l_s;
-} sh_md_dqrp_mmr_ybist_err_l_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRS_MMR_XBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_xbist_h_u {
-	mmr_t	sh_md_dqrs_mmr_xbist_h_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 21;
-	} sh_md_dqrs_mmr_xbist_h_s;
-} sh_md_dqrs_mmr_xbist_h_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRS_MMR_XBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_xbist_l_u {
-	mmr_t	sh_md_dqrs_mmr_xbist_l_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqrs_mmr_xbist_l_s;
-} sh_md_dqrs_mmr_xbist_l_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRS_MMR_XBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_xbist_err_h_u {
-	mmr_t	sh_md_dqrs_mmr_xbist_err_h_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqrs_mmr_xbist_err_h_s;
-} sh_md_dqrs_mmr_xbist_err_h_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRS_MMR_XBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_xbist_err_l_u {
-	mmr_t	sh_md_dqrs_mmr_xbist_err_l_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqrs_mmr_xbist_err_l_s;
-} sh_md_dqrs_mmr_xbist_err_l_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRS_MMR_YBIST_H"                   */
-/*                    rising edge bist/fill pattern                     */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_ybist_h_u {
-	mmr_t	sh_md_dqrs_mmr_ybist_h_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_0  : 21;
-	} sh_md_dqrs_mmr_ybist_h_s;
-} sh_md_dqrs_mmr_ybist_h_u_t;
-
-/* ==================================================================== */
-/*                  Register "SH_MD_DQRS_MMR_YBIST_L"                   */
-/*                    falling edge bist/fill pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_ybist_l_u {
-	mmr_t	sh_md_dqrs_mmr_ybist_l_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	inv         : 1;
-		mmr_t	rot         : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqrs_mmr_ybist_l_s;
-} sh_md_dqrs_mmr_ybist_l_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRS_MMR_YBIST_ERR_H"                 */
-/*                    rising edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_ybist_err_h_u {
-	mmr_t	sh_md_dqrs_mmr_ybist_err_h_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqrs_mmr_ybist_err_h_s;
-} sh_md_dqrs_mmr_ybist_err_h_u_t;
-
-/* ==================================================================== */
-/*                Register "SH_MD_DQRS_MMR_YBIST_ERR_L"                 */
-/*                   falling edge bist error pattern                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_ybist_err_l_u {
-	mmr_t	sh_md_dqrs_mmr_ybist_err_l_regval;
-	struct {
-		mmr_t	pat         : 40;
-		mmr_t	val         : 1;
-		mmr_t	more        : 1;
-		mmr_t	reserved_0  : 22;
-	} sh_md_dqrs_mmr_ybist_err_l_s;
-} sh_md_dqrs_mmr_ybist_err_l_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQRS_MMR_JNR_DEBUG"                  */
-/*                    joiner/fct debug configuration                    */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_jnr_debug_u {
-	mmr_t	sh_md_dqrs_mmr_jnr_debug_regval;
-	struct {
-		mmr_t	px          : 1;
-		mmr_t	rw          : 1;
-		mmr_t	reserved_0  : 62;
-	} sh_md_dqrs_mmr_jnr_debug_s;
-} sh_md_dqrs_mmr_jnr_debug_u_t;
-
-/* ==================================================================== */
-/*                 Register "SH_MD_DQRS_MMR_YAMOPW_ERR"                 */
-/*                  amo/partial rmw ecc error register                  */
-/* ==================================================================== */
-
-typedef union sh_md_dqrs_mmr_yamopw_err_u {
-	mmr_t	sh_md_dqrs_mmr_yamopw_err_regval;
-	struct {
-		mmr_t	ssyn        : 8;
-		mmr_t	scor        : 1;
-		mmr_t	sunc        : 1;
-		mmr_t	reserved_0  : 6;
-		mmr_t	rsyn        : 8;
-		mmr_t	rcor        : 1;
-		mmr_t	runc        : 1;
-		mmr_t	reserved_1  : 6;
-		mmr_t	arm         : 1;
-		mmr_t	reserved_2  : 31;
-	} sh_md_dqrs_mmr_yamopw_err_s;
-} sh_md_dqrs_mmr_yamopw_err_u_t;
-
-#endif /* _ASM_IA64_SN_SN2_SHUB_MMR_T_H */
diff -Nru a/include/asm-ia64/sn/sn2/shubio.h b/include/asm-ia64/sn/sn2/shubio.h
--- a/include/asm-ia64/sn/sn2/shubio.h	2004-12-24 13:36:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,3609 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#ifndef _ASM_IA64_SN_SN2_SHUBIO_H
-#define _ASM_IA64_SN_SN2_SHUBIO_H
-
-#include <asm/sn/arch.h>
-
-#define HUB_WIDGET_ID_MAX 0xf
-#define IIO_NUM_ITTES   7
-#define HUB_NUM_BIG_WINDOW      (IIO_NUM_ITTES - 1)
-
-#define    IIO_WID                   0x00400000    /* Crosstalk Widget Identification */
-                                                   /* This register is also accessible from
-                                                    * Crosstalk at address 0x0.  */
-#define    IIO_WSTAT                 0x00400008    /* Crosstalk Widget Status */
-#define    IIO_WCR                   0x00400020    /* Crosstalk Widget Control Register */
-#define    IIO_ILAPR                 0x00400100    /* IO Local Access Protection Register */
-#define    IIO_ILAPO                 0x00400108    /* IO Local Access Protection Override */
-#define    IIO_IOWA                  0x00400110    /* IO Outbound Widget Access */
-#define    IIO_IIWA                  0x00400118    /* IO Inbound Widget Access */
-#define    IIO_IIDEM                 0x00400120    /* IO Inbound Device Error Mask */
-#define    IIO_ILCSR                 0x00400128    /* IO LLP Control and Status Register */
-#define    IIO_ILLR                  0x00400130    /* IO LLP Log Register    */
-#define    IIO_IIDSR                 0x00400138    /* IO Interrupt Destination */
-
-#define    IIO_IGFX0                 0x00400140    /* IO Graphics Node-Widget Map 0 */
-#define    IIO_IGFX1                 0x00400148    /* IO Graphics Node-Widget Map 1 */
-
-#define    IIO_ISCR0                 0x00400150    /* IO Scratch Register 0 */
-#define    IIO_ISCR1                 0x00400158    /* IO Scratch Register 1 */
-
-#define    IIO_ITTE1                 0x00400160    /* IO Translation Table Entry 1 */
-#define    IIO_ITTE2                 0x00400168    /* IO Translation Table Entry 2 */
-#define    IIO_ITTE3                 0x00400170    /* IO Translation Table Entry 3 */
-#define    IIO_ITTE4                 0x00400178    /* IO Translation Table Entry 4 */
-#define    IIO_ITTE5                 0x00400180    /* IO Translation Table Entry 5 */
-#define    IIO_ITTE6                 0x00400188    /* IO Translation Table Entry 6 */
-#define    IIO_ITTE7                 0x00400190    /* IO Translation Table Entry 7 */
-
-#define    IIO_IPRB0                 0x00400198    /* IO PRB Entry 0         */
-#define    IIO_IPRB8                 0x004001A0    /* IO PRB Entry 8         */
-#define    IIO_IPRB9                 0x004001A8    /* IO PRB Entry 9         */
-#define    IIO_IPRBA                 0x004001B0    /* IO PRB Entry A         */
-#define    IIO_IPRBB                 0x004001B8    /* IO PRB Entry B         */
-#define    IIO_IPRBC                 0x004001C0    /* IO PRB Entry C         */
-#define    IIO_IPRBD                 0x004001C8    /* IO PRB Entry D         */
-#define    IIO_IPRBE                 0x004001D0    /* IO PRB Entry E         */
-#define    IIO_IPRBF                 0x004001D8    /* IO PRB Entry F         */
-
-#define    IIO_IXCC                  0x004001E0    /* IO Crosstalk Credit Count Timeout */
-#define    IIO_IMEM                  0x004001E8    /* IO Miscellaneous Error Mask */
-#define    IIO_IXTT                  0x004001F0    /* IO Crosstalk Timeout Threshold */
-#define    IIO_IECLR                 0x004001F8    /* IO Error Clear Register */
-#define    IIO_IBCR                  0x00400200    /* IO BTE Control Register */
-
-#define    IIO_IXSM                  0x00400208    /* IO Crosstalk Spurious Message */
-#define    IIO_IXSS                  0x00400210    /* IO Crosstalk Spurious Sideband */
-
-#define    IIO_ILCT                  0x00400218    /* IO LLP Channel Test    */
-
-#define    IIO_IIEPH1                0x00400220    /* IO Incoming Error Packet Header, Part 1 */
-#define    IIO_IIEPH2                0x00400228    /* IO Incoming Error Packet Header, Part 2 */
-
-
-#define    IIO_ISLAPR                0x00400230    /* IO SXB Local Access Protection Regster */
-#define    IIO_ISLAPO                0x00400238    /* IO SXB Local Access Protection Override */
-
-#define    IIO_IWI                   0x00400240    /* IO Wrapper Interrupt Register */
-#define    IIO_IWEL                  0x00400248    /* IO Wrapper Error Log Register */
-#define    IIO_IWC                   0x00400250    /* IO Wrapper Control Register */
-#define    IIO_IWS                   0x00400258    /* IO Wrapper Status Register */
-#define    IIO_IWEIM                 0x00400260    /* IO Wrapper Error Interrupt Masking Register */
-
-#define    IIO_IPCA                  0x00400300    /* IO PRB Counter Adjust */
-
-#define    IIO_IPRTE0_A              0x00400308    /* IO PIO Read Address Table Entry 0, Part A */
-#define    IIO_IPRTE1_A              0x00400310    /* IO PIO Read Address Table Entry 1, Part A */
-#define    IIO_IPRTE2_A              0x00400318    /* IO PIO Read Address Table Entry 2, Part A */
-#define    IIO_IPRTE3_A               0x00400320    /* IO PIO Read Address Table Entry 3, Part A */
-#define    IIO_IPRTE4_A               0x00400328    /* IO PIO Read Address Table Entry 4, Part A */
-#define    IIO_IPRTE5_A               0x00400330    /* IO PIO Read Address Table Entry 5, Part A */
-#define    IIO_IPRTE6_A               0x00400338    /* IO PIO Read Address Table Entry 6, Part A */
-#define    IIO_IPRTE7_A               0x00400340    /* IO PIO Read Address Table Entry 7, Part A */
-
-#define    IIO_IPRTE0_B              0x00400348    /* IO PIO Read Address Table Entry 0, Part B */
-#define    IIO_IPRTE1_B              0x00400350    /* IO PIO Read Address Table Entry 1, Part B */
-#define    IIO_IPRTE2_B              0x00400358    /* IO PIO Read Address Table Entry 2, Part B */
-#define    IIO_IPRTE3_B               0x00400360    /* IO PIO Read Address Table Entry 3, Part B */
-#define    IIO_IPRTE4_B               0x00400368    /* IO PIO Read Address Table Entry 4, Part B */
-#define    IIO_IPRTE5_B               0x00400370    /* IO PIO Read Address Table Entry 5, Part B */
-#define    IIO_IPRTE6_B               0x00400378    /* IO PIO Read Address Table Entry 6, Part B */
-#define    IIO_IPRTE7_B               0x00400380    /* IO PIO Read Address Table Entry 7, Part B */
-
-#define    IIO_IPDR                  0x00400388    /* IO PIO Deallocation Register */
-#define    IIO_ICDR                  0x00400390    /* IO CRB Entry Deallocation Register */
-#define    IIO_IFDR                  0x00400398    /* IO IOQ FIFO Depth Register */
-#define    IIO_IIAP                  0x004003A0    /* IO IIQ Arbitration Parameters */
-#define    IIO_ICMR                  0x004003A8    /* IO CRB Management Register */
-#define    IIO_ICCR                  0x004003B0    /* IO CRB Control Register */
-#define    IIO_ICTO                  0x004003B8    /* IO CRB Timeout         */
-#define    IIO_ICTP                  0x004003C0    /* IO CRB Timeout Prescalar */
-
-#define    IIO_ICRB0_A               0x00400400    /* IO CRB Entry 0_A       */
-#define    IIO_ICRB0_B               0x00400408    /* IO CRB Entry 0_B       */
-#define    IIO_ICRB0_C               0x00400410    /* IO CRB Entry 0_C       */
-#define    IIO_ICRB0_D               0x00400418    /* IO CRB Entry 0_D       */
-#define    IIO_ICRB0_E               0x00400420    /* IO CRB Entry 0_E       */
-
-#define    IIO_ICRB1_A               0x00400430    /* IO CRB Entry 1_A       */
-#define    IIO_ICRB1_B               0x00400438    /* IO CRB Entry 1_B       */
-#define    IIO_ICRB1_C               0x00400440    /* IO CRB Entry 1_C       */
-#define    IIO_ICRB1_D               0x00400448    /* IO CRB Entry 1_D       */
-#define    IIO_ICRB1_E               0x00400450    /* IO CRB Entry 1_E       */
-
-#define    IIO_ICRB2_A               0x00400460    /* IO CRB Entry 2_A       */
-#define    IIO_ICRB2_B               0x00400468    /* IO CRB Entry 2_B       */
-#define    IIO_ICRB2_C               0x00400470    /* IO CRB Entry 2_C       */
-#define    IIO_ICRB2_D               0x00400478    /* IO CRB Entry 2_D       */
-#define    IIO_ICRB2_E               0x00400480    /* IO CRB Entry 2_E       */
-
-#define    IIO_ICRB3_A               0x00400490    /* IO CRB Entry 3_A       */
-#define    IIO_ICRB3_B               0x00400498    /* IO CRB Entry 3_B       */
-#define    IIO_ICRB3_C               0x004004a0    /* IO CRB Entry 3_C       */
-#define    IIO_ICRB3_D               0x004004a8    /* IO CRB Entry 3_D       */
-#define    IIO_ICRB3_E               0x004004b0    /* IO CRB Entry 3_E       */
-
-#define    IIO_ICRB4_A               0x004004c0    /* IO CRB Entry 4_A       */
-#define    IIO_ICRB4_B               0x004004c8    /* IO CRB Entry 4_B       */
-#define    IIO_ICRB4_C               0x004004d0    /* IO CRB Entry 4_C       */
-#define    IIO_ICRB4_D               0x004004d8    /* IO CRB Entry 4_D       */
-#define    IIO_ICRB4_E               0x004004e0    /* IO CRB Entry 4_E       */
-
-#define    IIO_ICRB5_A               0x004004f0    /* IO CRB Entry 5_A       */
-#define    IIO_ICRB5_B               0x004004f8    /* IO CRB Entry 5_B       */
-#define    IIO_ICRB5_C               0x00400500    /* IO CRB Entry 5_C       */
-#define    IIO_ICRB5_D               0x00400508    /* IO CRB Entry 5_D       */
-#define    IIO_ICRB5_E               0x00400510    /* IO CRB Entry 5_E       */
-
-#define    IIO_ICRB6_A               0x00400520    /* IO CRB Entry 6_A       */
-#define    IIO_ICRB6_B               0x00400528    /* IO CRB Entry 6_B       */
-#define    IIO_ICRB6_C               0x00400530    /* IO CRB Entry 6_C       */
-#define    IIO_ICRB6_D               0x00400538    /* IO CRB Entry 6_D       */
-#define    IIO_ICRB6_E               0x00400540    /* IO CRB Entry 6_E       */
-
-#define    IIO_ICRB7_A               0x00400550    /* IO CRB Entry 7_A       */
-#define    IIO_ICRB7_B               0x00400558    /* IO CRB Entry 7_B       */
-#define    IIO_ICRB7_C               0x00400560    /* IO CRB Entry 7_C       */
-#define    IIO_ICRB7_D               0x00400568    /* IO CRB Entry 7_D       */
-#define    IIO_ICRB7_E               0x00400570    /* IO CRB Entry 7_E       */
-
-#define    IIO_ICRB8_A               0x00400580    /* IO CRB Entry 8_A       */
-#define    IIO_ICRB8_B               0x00400588    /* IO CRB Entry 8_B       */
-#define    IIO_ICRB8_C               0x00400590    /* IO CRB Entry 8_C       */
-#define    IIO_ICRB8_D               0x00400598    /* IO CRB Entry 8_D       */
-#define    IIO_ICRB8_E               0x004005a0    /* IO CRB Entry 8_E       */
-
-#define    IIO_ICRB9_A               0x004005b0    /* IO CRB Entry 9_A       */
-#define    IIO_ICRB9_B               0x004005b8    /* IO CRB Entry 9_B       */
-#define    IIO_ICRB9_C               0x004005c0    /* IO CRB Entry 9_C       */
-#define    IIO_ICRB9_D               0x004005c8    /* IO CRB Entry 9_D       */
-#define    IIO_ICRB9_E               0x004005d0    /* IO CRB Entry 9_E       */
-
-#define    IIO_ICRBA_A               0x004005e0    /* IO CRB Entry A_A       */
-#define    IIO_ICRBA_B               0x004005e8    /* IO CRB Entry A_B       */
-#define    IIO_ICRBA_C               0x004005f0    /* IO CRB Entry A_C       */
-#define    IIO_ICRBA_D               0x004005f8    /* IO CRB Entry A_D       */
-#define    IIO_ICRBA_E               0x00400600    /* IO CRB Entry A_E       */
-
-#define    IIO_ICRBB_A               0x00400610    /* IO CRB Entry B_A       */
-#define    IIO_ICRBB_B               0x00400618    /* IO CRB Entry B_B       */
-#define    IIO_ICRBB_C               0x00400620    /* IO CRB Entry B_C       */
-#define    IIO_ICRBB_D               0x00400628    /* IO CRB Entry B_D       */
-#define    IIO_ICRBB_E               0x00400630    /* IO CRB Entry B_E       */
-
-#define    IIO_ICRBC_A               0x00400640    /* IO CRB Entry C_A       */
-#define    IIO_ICRBC_B               0x00400648    /* IO CRB Entry C_B       */
-#define    IIO_ICRBC_C               0x00400650    /* IO CRB Entry C_C       */
-#define    IIO_ICRBC_D               0x00400658    /* IO CRB Entry C_D       */
-#define    IIO_ICRBC_E               0x00400660    /* IO CRB Entry C_E       */
-
-#define    IIO_ICRBD_A               0x00400670    /* IO CRB Entry D_A       */
-#define    IIO_ICRBD_B               0x00400678    /* IO CRB Entry D_B       */
-#define    IIO_ICRBD_C               0x00400680    /* IO CRB Entry D_C       */
-#define    IIO_ICRBD_D               0x00400688    /* IO CRB Entry D_D       */
-#define    IIO_ICRBD_E               0x00400690    /* IO CRB Entry D_E       */
-
-#define    IIO_ICRBE_A               0x004006a0    /* IO CRB Entry E_A       */
-#define    IIO_ICRBE_B               0x004006a8    /* IO CRB Entry E_B       */
-#define    IIO_ICRBE_C               0x004006b0    /* IO CRB Entry E_C       */
-#define    IIO_ICRBE_D               0x004006b8    /* IO CRB Entry E_D       */
-#define    IIO_ICRBE_E               0x004006c0    /* IO CRB Entry E_E       */
-
-#define    IIO_ICSML                 0x00400700    /* IO CRB Spurious Message Low */
-#define    IIO_ICSMM                 0x00400708    /* IO CRB Spurious Message Middle */
-#define    IIO_ICSMH                 0x00400710    /* IO CRB Spurious Message High */
-
-#define    IIO_IDBSS                 0x00400718    /* IO Debug Submenu Select */
-
-#define    IIO_IBLS0                 0x00410000    /* IO BTE Length Status 0 */
-#define    IIO_IBSA0                 0x00410008    /* IO BTE Source Address 0 */
-#define    IIO_IBDA0                 0x00410010    /* IO BTE Destination Address 0 */
-#define    IIO_IBCT0                 0x00410018    /* IO BTE Control Terminate 0 */
-#define    IIO_IBNA0                 0x00410020    /* IO BTE Notification Address 0 */
-#define    IIO_IBIA0                 0x00410028    /* IO BTE Interrupt Address 0 */
-#define    IIO_IBLS1                 0x00420000    /* IO BTE Length Status 1 */
-#define    IIO_IBSA1                 0x00420008    /* IO BTE Source Address 1 */
-#define    IIO_IBDA1                 0x00420010    /* IO BTE Destination Address 1 */
-#define    IIO_IBCT1                 0x00420018    /* IO BTE Control Terminate 1 */
-#define    IIO_IBNA1                 0x00420020    /* IO BTE Notification Address 1 */
-#define    IIO_IBIA1                 0x00420028    /* IO BTE Interrupt Address 1 */
-
-#define    IIO_IPCR                  0x00430000    /* IO Performance Control */
-#define    IIO_IPPR                  0x00430008    /* IO Performance Profiling */
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This register echoes some information from the         *
- * LB_REV_ID register. It is available through Crosstalk as described   *
- * above. The REV_NUM and MFG_NUM fields receive their values from      *
- * the REVISION and MANUFACTURER fields in the LB_REV_ID register.      *
- * The PART_NUM field's value is the Crosstalk device ID number that    *
- * Steve Miller assigned to the SHub chip.                              *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_wid_u {
-	shubreg_t	ii_wid_regval;
-	struct	{
-		shubreg_t	w_rsvd_1		  :	 1;
-		shubreg_t	w_mfg_num		  :	11;
-		shubreg_t	w_part_num		  :	16;
-		shubreg_t	w_rev_num		  :	 4;
-		shubreg_t	w_rsvd			  :	32;
-	} ii_wid_fld_s;
-} ii_wid_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  The fields in this register are set upon detection of an error      *
- * and cleared by various mechanisms, as explained in the               *
- * description.                                                         *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_wstat_u {
-	shubreg_t	ii_wstat_regval;
-	struct	{
-		shubreg_t	w_pending		  :	 4;
-		shubreg_t	w_xt_crd_to		  :	 1;
-		shubreg_t	w_xt_tail_to		  :	 1;
-		shubreg_t	w_rsvd_3		  :	 3;
-		shubreg_t       w_tx_mx_rty               :      1;
-		shubreg_t	w_rsvd_2		  :	 6;
-		shubreg_t	w_llp_tx_cnt		  :	 8;
-		shubreg_t	w_rsvd_1		  :	 8;
-		shubreg_t	w_crazy			  :	 1;
-		shubreg_t	w_rsvd			  :	31;
-	} ii_wstat_fld_s;
-} ii_wstat_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This is a read-write enabled register. It controls     *
- * various aspects of the Crosstalk flow control.                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_wcr_u {
-	shubreg_t	ii_wcr_regval;
-	struct	{
-		shubreg_t	w_wid			  :	 4;
-		shubreg_t	w_tag			  :	 1;
-		shubreg_t	w_rsvd_1		  :	 8;
-		shubreg_t	w_dst_crd		  :	 3;
-		shubreg_t	w_f_bad_pkt		  :	 1;
-		shubreg_t	w_dir_con		  :	 1;
-		shubreg_t	w_e_thresh		  :	 5;
-		shubreg_t	w_rsvd			  :	41;
-	} ii_wcr_fld_s;
-} ii_wcr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This register's value is a bit vector that guards      *
- * access to local registers within the II as well as to external       *
- * Crosstalk widgets. Each bit in the register corresponds to a         *
- * particular region in the system; a region consists of one, two or    *
- * four nodes (depending on the value of the REGION_SIZE field in the   *
- * LB_REV_ID register, which is documented in Section 8.3.1.1). The     *
- * protection provided by this register applies to PIO read             *
- * operations as well as PIO write operations. The II will perform a    *
- * PIO read or write request only if the bit for the requestor's        *
- * region is set; otherwise, the II will not perform the requested      *
- * operation and will return an error response. When a PIO read or      *
- * write request targets an external Crosstalk widget, then not only    *
- * must the bit for the requestor's region be set in the ILAPR, but     *
- * also the target widget's bit in the IOWA register must be set in     *
- * order for the II to perform the requested operation; otherwise,      *
- * the II will return an error response. Hence, the protection          *
- * provided by the IOWA register supplements the protection provided    *
- * by the ILAPR for requests that target external Crosstalk widgets.    *
- * This register itself can be accessed only by the nodes whose         *
- * region ID bits are enabled in this same register. It can also be     *
- * accessed through the IAlias space by the local processors.           *
- * The reset value of this register allows access by all nodes.         *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ilapr_u {
-	shubreg_t	ii_ilapr_regval;
-	struct  {
-		shubreg_t	i_region                  :	64;
-	} ii_ilapr_fld_s;
-} ii_ilapr_u_t;
-
-
-
-
-/************************************************************************
- *                                                                      *
- * Description:  A write to this register of the 64-bit value           *
- * "SGIrules" in ASCII, will cause the bit in the ILAPR register        *
- * corresponding to the region of the requestor to be set (allow        *
- * access). A write of any other value will be ignored. Access          *
- * protection for this register is "SGIrules".                          *
- * This register can also be accessed through the IAlias space.         *
- * However, this access will not change the access permissions in the   *
- * ILAPR.                                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ilapo_u {
-	shubreg_t	ii_ilapo_regval;
-	struct	{
-		shubreg_t	i_io_ovrride            :	64;
-	} ii_ilapo_fld_s;
-} ii_ilapo_u_t;
-
-
-
-/************************************************************************
- *                                                                      *
- *  This register qualifies all the PIO and Graphics writes launched    *
- * from the SHUB towards a widget.                                      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iowa_u {
-	shubreg_t	ii_iowa_regval;
-	struct	{
-		shubreg_t	i_w0_oac		  :	 1;
-		shubreg_t	i_rsvd_1		  :	 7;
-                shubreg_t       i_wx_oac                  :      8;
-		shubreg_t	i_rsvd			  :	48;
-	} ii_iowa_fld_s;
-} ii_iowa_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This register qualifies all the requests launched      *
- * from a widget towards the Shub. This register is intended to be      *
- * used by software in case of misbehaving widgets.                     *
- *                                                                      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iiwa_u {
-	shubreg_t	ii_iiwa_regval;
-	struct  {
-		shubreg_t	i_w0_iac                  :	 1;
-		shubreg_t	i_rsvd_1		  :	 7;
-		shubreg_t	i_wx_iac		  :	 8;
-		shubreg_t	i_rsvd			  :	48;
-	} ii_iiwa_fld_s;
-} ii_iiwa_u_t;
-
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This register qualifies all the operations launched    *
- * from a widget towards the SHub. It allows individual access          *
- * control for up to 8 devices per widget. A device refers to           *
- * individual DMA master hosted by a widget.                            *
- * The bits in each field of this register are cleared by the Shub      *
- * upon detection of an error which requires the device to be           *
- * disabled. These fields assume that 0=TNUM=7 (i.e., Bridge-centric    *
- * Crosstalk). Whether or not a device has access rights to this        *
- * Shub is determined by an AND of the device enable bit in the         *
- * appropriate field of this register and the corresponding bit in      *
- * the Wx_IAC field (for the widget which this device belongs to).      *
- * The bits in this field are set by writing a 1 to them. Incoming      *
- * replies from Crosstalk are not subject to this access control        *
- * mechanism.                                                           *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iidem_u {
-	shubreg_t	ii_iidem_regval;
-	struct	{
-		shubreg_t	i_w8_dxs		  :	 8;
-		shubreg_t	i_w9_dxs		  :	 8;
-		shubreg_t	i_wa_dxs		  :	 8;
-		shubreg_t	i_wb_dxs		  :	 8;
-		shubreg_t	i_wc_dxs		  :	 8;
-		shubreg_t	i_wd_dxs		  :	 8;
-		shubreg_t	i_we_dxs		  :	 8;
-		shubreg_t	i_wf_dxs		  :	 8;
-	} ii_iidem_fld_s;
-} ii_iidem_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the various programmable fields necessary    *
- * for controlling and observing the LLP signals.                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ilcsr_u {
-	shubreg_t	ii_ilcsr_regval;
-	struct  {
-		shubreg_t	i_nullto                  :	 6;
-		shubreg_t	i_rsvd_4		  :	 2;
-		shubreg_t	i_wrmrst		  :	 1;
-		shubreg_t	i_rsvd_3		  :	 1;
-		shubreg_t	i_llp_en		  :	 1;
-		shubreg_t	i_bm8			  :	 1;
-		shubreg_t	i_llp_stat		  :	 2;
-		shubreg_t	i_remote_power		  :	 1;
-		shubreg_t	i_rsvd_2		  :	 1;
-		shubreg_t	i_maxrtry		  :	10;
-		shubreg_t	i_d_avail_sel		  :	 2;
-		shubreg_t	i_rsvd_1		  :	 4;
-		shubreg_t	i_maxbrst		  :	10;
-                shubreg_t       i_rsvd                    :     22;
-
-	} ii_ilcsr_fld_s;
-} ii_ilcsr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This is simply a status registers that monitors the LLP error       *
- * rate.                                                                *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_illr_u {
-	shubreg_t	ii_illr_regval;
-	struct	{
-		shubreg_t	i_sn_cnt		  :	16;
-		shubreg_t	i_cb_cnt		  :	16;
-		shubreg_t	i_rsvd			  :	32;
-	} ii_illr_fld_s;
-} ii_illr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  All II-detected non-BTE error interrupts are           *
- * specified via this register.                                         *
- * NOTE: The PI interrupt register address is hardcoded in the II. If   *
- * PI_ID==0, then the II sends an interrupt request (Duplonet PWRI      *
- * packet) to address offset 0x0180_0090 within the local register      *
- * address space of PI0 on the node specified by the NODE field. If     *
- * PI_ID==1, then the II sends the interrupt request to address         *
- * offset 0x01A0_0090 within the local register address space of PI1    *
- * on the node specified by the NODE field.                             *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iidsr_u {
-	shubreg_t	ii_iidsr_regval;
-	struct  {
-		shubreg_t	i_level                   :	 8;
-		shubreg_t	i_pi_id			  :	 1;
-		shubreg_t	i_node			  :	11;
-		shubreg_t       i_rsvd_3                  :      4;
-		shubreg_t	i_enable		  :	 1;
-		shubreg_t	i_rsvd_2		  :	 3;
-		shubreg_t	i_int_sent		  :	 2;
-		shubreg_t       i_rsvd_1                  :      2;
-		shubreg_t	i_pi0_forward_int	  :	 1;
-		shubreg_t	i_pi1_forward_int	  :	 1;
-		shubreg_t	i_rsvd			  :	30;
-	} ii_iidsr_fld_s;
-} ii_iidsr_u_t;
-
-
-
-/************************************************************************
- *                                                                      *
- *  There are two instances of this register. This register is used     *
- * for matching up the incoming responses from the graphics widget to   *
- * the processor that initiated the graphics operation. The             *
- * write-responses are converted to graphics credits and returned to    *
- * the processor so that the processor interface can manage the flow    *
- * control.                                                             *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_igfx0_u {
-	shubreg_t	ii_igfx0_regval;
-	struct	{
-		shubreg_t	i_w_num			  :	 4;
-		shubreg_t       i_pi_id                   :      1;
-		shubreg_t	i_n_num			  :	12;
-		shubreg_t       i_p_num                   :      1;
-		shubreg_t       i_rsvd                    :     46;
-	} ii_igfx0_fld_s;
-} ii_igfx0_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are two instances of this register. This register is used     *
- * for matching up the incoming responses from the graphics widget to   *
- * the processor that initiated the graphics operation. The             *
- * write-responses are converted to graphics credits and returned to    *
- * the processor so that the processor interface can manage the flow    *
- * control.                                                             *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_igfx1_u {
-	shubreg_t	ii_igfx1_regval;
-	struct  {
-		shubreg_t	i_w_num			  :	 4;
-		shubreg_t       i_pi_id                   :      1;
-		shubreg_t	i_n_num			  :	12;
-		shubreg_t       i_p_num                   :      1;
-		shubreg_t       i_rsvd                    :     46;
-	} ii_igfx1_fld_s;
-} ii_igfx1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are two instances of this registers. These registers are      *
- * used as scratch registers for software use.                          *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iscr0_u {
-	shubreg_t	ii_iscr0_regval;
-	struct  {
-		shubreg_t	i_scratch                 :	64;
-	} ii_iscr0_fld_s;
-} ii_iscr0_u_t;
-
-
-
-/************************************************************************
- *                                                                      *
- *  There are two instances of this registers. These registers are      *
- * used as scratch registers for software use.                          *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iscr1_u {
-	shubreg_t	ii_iscr1_regval;
-	struct  {
-		shubreg_t	i_scratch                 :	64;
-	} ii_iscr1_fld_s;
-} ii_iscr1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are seven instances of translation table entry   *
- * registers. Each register maps a Shub Big Window to a 48-bit          *
- * address on Crosstalk.                                                *
- * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
- * number) are used to select one of these 7 registers. The Widget      *
- * number field is then derived from the W_NUM field for synthesizing   *
- * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
- * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
- * are padded with zeros. Although the maximum Crosstalk space          *
- * addressable by the SHub is thus the lower 16 GBytes per widget       * 
- * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
- * space can be accessed.                                               *
- * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
- * Window number) are used to select one of these 7 registers. The      *
- * Widget number field is then derived from the W_NUM field for         *
- * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
- * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
- * field is used as Crosstalk[47], and remainder of the Crosstalk       *
- * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
- * Crosstalk space addressable by the Shub is thus the lower            *
- * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
- * of this space can be accessed.                                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_itte1_u {
-	shubreg_t	ii_itte1_regval;
-	struct  {
-		shubreg_t	i_offset                  :	 5;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t	i_w_num			  :	 4;
-		shubreg_t	i_iosp			  :	 1;
-		shubreg_t	i_rsvd			  :	51;
-	} ii_itte1_fld_s;
-} ii_itte1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are seven instances of translation table entry   *
- * registers. Each register maps a Shub Big Window to a 48-bit          *
- * address on Crosstalk.                                                *
- * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
- * number) are used to select one of these 7 registers. The Widget      *
- * number field is then derived from the W_NUM field for synthesizing   *
- * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
- * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
- * are padded with zeros. Although the maximum Crosstalk space          *
- * addressable by the Shub is thus the lower 16 GBytes per widget       *
- * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
- * space can be accessed.                                               *
- * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
- * Window number) are used to select one of these 7 registers. The      *
- * Widget number field is then derived from the W_NUM field for         *
- * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
- * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
- * field is used as Crosstalk[47], and remainder of the Crosstalk       *
- * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
- * Crosstalk space addressable by the Shub is thus the lower            *
- * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
- * of this space can be accessed.                                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_itte2_u {
-	shubreg_t	ii_itte2_regval;
-	struct	{
-		shubreg_t	i_offset		  :	 5;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t	i_w_num			  :	 4;
-		shubreg_t	i_iosp			  :	 1;
-		shubreg_t       i_rsvd                    :     51;
-	} ii_itte2_fld_s;
-} ii_itte2_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are seven instances of translation table entry   *
- * registers. Each register maps a Shub Big Window to a 48-bit          *
- * address on Crosstalk.                                                *
- * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
- * number) are used to select one of these 7 registers. The Widget      *
- * number field is then derived from the W_NUM field for synthesizing   *
- * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
- * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
- * are padded with zeros. Although the maximum Crosstalk space          *
- * addressable by the Shub is thus the lower 16 GBytes per widget       *
- * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
- * space can be accessed.                                               *
- * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
- * Window number) are used to select one of these 7 registers. The      *
- * Widget number field is then derived from the W_NUM field for         *
- * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
- * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
- * field is used as Crosstalk[47], and remainder of the Crosstalk       *
- * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
- * Crosstalk space addressable by the SHub is thus the lower            *
- * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
- * of this space can be accessed.                                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_itte3_u {
-	shubreg_t	ii_itte3_regval;
-	struct  {
-		shubreg_t	i_offset                  :	 5;
-		shubreg_t       i_rsvd_1                  :      3;
-		shubreg_t       i_w_num                   :      4;
-		shubreg_t       i_iosp                    :      1;
-		shubreg_t       i_rsvd                    :     51;
-	} ii_itte3_fld_s;
-} ii_itte3_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are seven instances of translation table entry   *
- * registers. Each register maps a SHub Big Window to a 48-bit          *
- * address on Crosstalk.                                                *
- * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
- * number) are used to select one of these 7 registers. The Widget      *
- * number field is then derived from the W_NUM field for synthesizing   *
- * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
- * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
- * are padded with zeros. Although the maximum Crosstalk space          *
- * addressable by the SHub is thus the lower 16 GBytes per widget       *
- * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
- * space can be accessed.                                               *
- * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
- * Window number) are used to select one of these 7 registers. The      *
- * Widget number field is then derived from the W_NUM field for         *
- * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
- * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
- * field is used as Crosstalk[47], and remainder of the Crosstalk       *
- * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
- * Crosstalk space addressable by the SHub is thus the lower            *
- * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
- * of this space can be accessed.                                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_itte4_u {
-	shubreg_t	ii_itte4_regval;
-	struct  {
-		shubreg_t	i_offset                  :	 5;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t       i_w_num                   :      4;
-		shubreg_t       i_iosp                    :      1;
-		shubreg_t       i_rsvd                    :     51;
-	} ii_itte4_fld_s;
-} ii_itte4_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are seven instances of translation table entry   *
- * registers. Each register maps a SHub Big Window to a 48-bit          *
- * address on Crosstalk.                                                *
- * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
- * number) are used to select one of these 7 registers. The Widget      *
- * number field is then derived from the W_NUM field for synthesizing   *
- * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
- * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
- * are padded with zeros. Although the maximum Crosstalk space          *
- * addressable by the Shub is thus the lower 16 GBytes per widget       *
- * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
- * space can be accessed.                                               *
- * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
- * Window number) are used to select one of these 7 registers. The      *
- * Widget number field is then derived from the W_NUM field for         *
- * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
- * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
- * field is used as Crosstalk[47], and remainder of the Crosstalk       *
- * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
- * Crosstalk space addressable by the Shub is thus the lower            *
- * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
- * of this space can be accessed.                                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_itte5_u {
-	shubreg_t	ii_itte5_regval;
-	struct  {
-		shubreg_t	i_offset                  :	 5;
-		shubreg_t       i_rsvd_1                  :      3;
-		shubreg_t       i_w_num                   :      4;
-		shubreg_t       i_iosp                    :      1;
-		shubreg_t       i_rsvd                    :     51;
-	} ii_itte5_fld_s;
-} ii_itte5_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are seven instances of translation table entry   *
- * registers. Each register maps a Shub Big Window to a 48-bit          *
- * address on Crosstalk.                                                *
- * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
- * number) are used to select one of these 7 registers. The Widget      *
- * number field is then derived from the W_NUM field for synthesizing   *
- * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
- * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
- * are padded with zeros. Although the maximum Crosstalk space          *
- * addressable by the Shub is thus the lower 16 GBytes per widget       *
- * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
- * space can be accessed.                                               *
- * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
- * Window number) are used to select one of these 7 registers. The      *
- * Widget number field is then derived from the W_NUM field for         *
- * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
- * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
- * field is used as Crosstalk[47], and remainder of the Crosstalk       *
- * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
- * Crosstalk space addressable by the Shub is thus the lower            *
- * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
- * of this space can be accessed.                                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_itte6_u {
-	shubreg_t	ii_itte6_regval;
-	struct  {
-		shubreg_t	i_offset                  :	 5;
-		shubreg_t       i_rsvd_1                  :      3;
-		shubreg_t       i_w_num                   :      4;
-		shubreg_t       i_iosp                    :      1;
-		shubreg_t       i_rsvd                    :     51;
-	} ii_itte6_fld_s;
-} ii_itte6_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are seven instances of translation table entry   *
- * registers. Each register maps a Shub Big Window to a 48-bit          *
- * address on Crosstalk.                                                *
- * For M-mode (128 nodes, 8 GBytes/node), SysAD[31:29] (Big Window      *
- * number) are used to select one of these 7 registers. The Widget      *
- * number field is then derived from the W_NUM field for synthesizing   *
- * a Crosstalk packet. The 5 bits of OFFSET are concatenated with       *
- * SysAD[28:0] to form Crosstalk[33:0]. The upper Crosstalk[47:34]      *
- * are padded with zeros. Although the maximum Crosstalk space          *
- * addressable by the Shub is thus the lower 16 GBytes per widget       *
- * (M-mode), however only <SUP >7</SUP>/<SUB >32nds</SUB> of this       *
- * space can be accessed.                                               *
- * For the N-mode (256 nodes, 4 GBytes/node), SysAD[30:28] (Big         *
- * Window number) are used to select one of these 7 registers. The      *
- * Widget number field is then derived from the W_NUM field for         *
- * synthesizing a Crosstalk packet. The 5 bits of OFFSET are            *
- * concatenated with SysAD[27:0] to form Crosstalk[33:0]. The IOSP      *
- * field is used as Crosstalk[47], and remainder of the Crosstalk       *
- * address bits (Crosstalk[46:34]) are always zero. While the maximum   *
- * Crosstalk space addressable by the SHub is thus the lower            *
- * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB>   *
- * of this space can be accessed.                                       *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_itte7_u {
-	shubreg_t	ii_itte7_regval;
-	struct  {
-		shubreg_t	i_offset                  :	 5;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t       i_w_num                   :      4;
-		shubreg_t       i_iosp                    :      1;
-		shubreg_t       i_rsvd                    :     51;
-	} ii_itte7_fld_s;
-} ii_itte7_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of SHub and Crossbow.           *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- * .                                                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprb0_u {
-	shubreg_t	ii_iprb0_regval;
-	struct  {
-		shubreg_t	i_c                       :	 8;
-		shubreg_t	i_na			  :	14;
-		shubreg_t       i_rsvd_2                  :      2;
-		shubreg_t	i_nb			  :	14;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_m			  :	 2;
-		shubreg_t	i_f			  :	 1;
-		shubreg_t	i_of_cnt		  :	 5;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rd_to			  :	 1;
-		shubreg_t	i_spur_wr		  :	 1;
-		shubreg_t	i_spur_rd		  :	 1;
-		shubreg_t	i_rsvd			  :	11;
-		shubreg_t	i_mult_err		  :	 1;
-	} ii_iprb0_fld_s;
-} ii_iprb0_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of SHub and Crossbow.           *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- * .                                                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprb8_u {
-	shubreg_t	ii_iprb8_regval;
-	struct  {
-		shubreg_t	i_c                       :	 8;
-		shubreg_t	i_na			  :	14;
-		shubreg_t       i_rsvd_2                  :      2;
-		shubreg_t	i_nb			  :	14;
-		shubreg_t       i_rsvd_1                  :      2;
-		shubreg_t       i_m                       :      2;
-		shubreg_t       i_f                       :      1;
-		shubreg_t       i_of_cnt                  :      5;
-		shubreg_t       i_error                   :      1;
-		shubreg_t       i_rd_to                   :      1;
-		shubreg_t       i_spur_wr                 :      1;
-		shubreg_t	i_spur_rd		  :	 1;
-		shubreg_t       i_rsvd                    :     11;
-		shubreg_t	i_mult_err		  :	 1;
-	} ii_iprb8_fld_s;
-} ii_iprb8_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of SHub and Crossbow.           *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- * .                                                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprb9_u {
-	shubreg_t	ii_iprb9_regval;
-	struct	{
-		shubreg_t	i_c			  :	 8;
-		shubreg_t	i_na			  :	14;
-		shubreg_t	i_rsvd_2		  :	 2;
-		shubreg_t	i_nb			  :	14;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_m			  :	 2;
-		shubreg_t	i_f			  :	 1;
-		shubreg_t	i_of_cnt		  :	 5;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rd_to			  :	 1;
-		shubreg_t	i_spur_wr		  :	 1;
-		shubreg_t	i_spur_rd		  :	 1;
-		shubreg_t	i_rsvd			  :	11;
-		shubreg_t	i_mult_err		  :	 1;
-	} ii_iprb9_fld_s;
-} ii_iprb9_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of SHub and Crossbow.        *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- *                                                                      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprba_u {
-	shubreg_t	ii_iprba_regval;
-	struct  {
-		shubreg_t	i_c                       :	 8;
-		shubreg_t	i_na			  :	14;
-		shubreg_t       i_rsvd_2                  :      2;
-		shubreg_t	i_nb			  :	14;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_m			  :	 2;
-		shubreg_t	i_f			  :	 1;
-		shubreg_t	i_of_cnt		  :	 5;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rd_to			  :	 1;
-		shubreg_t	i_spur_wr		  :	 1;
-		shubreg_t	i_spur_rd		  :	 1;
-		shubreg_t	i_rsvd			  :	11;
-		shubreg_t	i_mult_err		  :	 1;
-	} ii_iprba_fld_s;
-} ii_iprba_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of SHub and Crossbow.           *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- * .                                                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprbb_u {
-	shubreg_t	ii_iprbb_regval;
-	struct	{
-		shubreg_t	i_c			  :	 8;
-		shubreg_t	i_na			  :	14;
-		shubreg_t	i_rsvd_2		  :	 2;
-		shubreg_t	i_nb			  :	14;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_m			  :	 2;
-		shubreg_t	i_f			  :	 1;
-		shubreg_t	i_of_cnt		  :	 5;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rd_to			  :	 1;
-		shubreg_t	i_spur_wr		  :	 1;
-		shubreg_t	i_spur_rd		  :	 1;
-		shubreg_t	i_rsvd			  :	11;
-		shubreg_t	i_mult_err		  :	 1;
-	} ii_iprbb_fld_s;
-} ii_iprbb_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of SHub and Crossbow.           *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- * .                                                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprbc_u {
-	shubreg_t	ii_iprbc_regval;
-	struct	{
-		shubreg_t	i_c			  :	 8;
-		shubreg_t	i_na			  :	14;
-		shubreg_t	i_rsvd_2		  :	 2;
-		shubreg_t	i_nb			  :	14;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_m			  :	 2;
-		shubreg_t	i_f			  :	 1;
-		shubreg_t	i_of_cnt		  :	 5;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rd_to			  :	 1;
-		shubreg_t	i_spur_wr		  :	 1;
-		shubreg_t	i_spur_rd		  :	 1;
-		shubreg_t	i_rsvd			  :	11;
-		shubreg_t	i_mult_err		  :	 1;
-	} ii_iprbc_fld_s;
-} ii_iprbc_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of SHub and Crossbow.           *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- * .                                                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprbd_u {
-	shubreg_t	ii_iprbd_regval;
-	struct	{
-		shubreg_t	i_c			  :	 8;
-		shubreg_t	i_na			  :	14;
-		shubreg_t	i_rsvd_2		  :	 2;
-		shubreg_t	i_nb			  :	14;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_m			  :	 2;
-		shubreg_t	i_f			  :	 1;
-		shubreg_t	i_of_cnt		  :	 5;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rd_to			  :	 1;
-		shubreg_t	i_spur_wr		  :	 1;
-		shubreg_t	i_spur_rd		  :	 1;
-		shubreg_t	i_rsvd			  :	11;
-		shubreg_t	i_mult_err		  :	 1;
-	} ii_iprbd_fld_s;
-} ii_iprbd_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of SHub and Crossbow.           *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- * .                                                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprbe_u {
-	shubreg_t	ii_iprbe_regval;
-	struct	{
-		shubreg_t	i_c			  :	 8;
-		shubreg_t	i_na			  :	14;
-		shubreg_t	i_rsvd_2		  :	 2;
-		shubreg_t	i_nb			  :	14;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_m			  :	 2;
-		shubreg_t	i_f			  :	 1;
-		shubreg_t	i_of_cnt		  :	 5;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rd_to			  :	 1;
-		shubreg_t	i_spur_wr		  :	 1;
-		shubreg_t	i_spur_rd		  :	 1;
-		shubreg_t	i_rsvd			  :	11;
-		shubreg_t	i_mult_err		  :	 1;
-	} ii_iprbe_fld_s;
-} ii_iprbe_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 9 instances of this register, one per        *
- * actual widget in this implementation of Shub and Crossbow.           *
- * Note: Crossbow only has ports for Widgets 8 through F, widget 0      *
- * refers to Crossbow's internal space.                                 *
- * This register contains the state elements per widget that are        *
- * necessary to manage the PIO flow control on Crosstalk and on the     *
- * Router Network. See the PIO Flow Control chapter for a complete      *
- * description of this register                                         *
- * The SPUR_WR bit requires some explanation. When this register is     *
- * written, the new value of the C field is captured in an internal     *
- * register so the hardware can remember what the programmer wrote      *
- * into the credit counter. The SPUR_WR bit sets whenever the C field   *
- * increments above this stored value, which indicates that there       *
- * have been more responses received than requests sent. The SPUR_WR    *
- * bit cannot be cleared until a value is written to the IPRBx          *
- * register; the write will correct the C field and capture its new     *
- * value in the internal register. Even if IECLR[E_PRB_x] is set, the   *
- * SPUR_WR bit will persist if IPRBx hasn't yet been written.           *
- * .                                                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprbf_u {
-        shubreg_t       ii_iprbf_regval;
-        struct  {
-                shubreg_t       i_c                       :      8;
-                shubreg_t       i_na                      :     14;
-                shubreg_t       i_rsvd_2                  :      2;
-                shubreg_t       i_nb                      :     14;
-                shubreg_t       i_rsvd_1                  :      2;
-                shubreg_t       i_m                       :      2;
-                shubreg_t       i_f                       :      1;
-                shubreg_t       i_of_cnt                  :      5;
-                shubreg_t       i_error                   :      1;
-                shubreg_t       i_rd_to                   :      1;
-                shubreg_t       i_spur_wr                 :      1;
-                shubreg_t       i_spur_rd                 :      1;
-                shubreg_t       i_rsvd                    :     11;
-                shubreg_t       i_mult_err                :      1;
-        } ii_iprbe_fld_s;
-} ii_iprbf_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register specifies the timeout value to use for monitoring     *
- * Crosstalk credits which are used outbound to Crosstalk. An           *
- * internal counter called the Crosstalk Credit Timeout Counter         *
- * increments every 128 II clocks. The counter starts counting          *
- * anytime the credit count drops below a threshold, and resets to      *
- * zero (stops counting) anytime the credit count is at or above the    *
- * threshold. The threshold is 1 credit in direct connect mode and 2    *
- * in Crossbow connect mode. When the internal Crosstalk Credit         *
- * Timeout Counter reaches the value programmed in this register, a     *
- * Crosstalk Credit Timeout has occurred. The internal counter is not   *
- * readable from software, and stops counting at its maximum value,     *
- * so it cannot cause more than one interrupt.                          *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ixcc_u {
-	shubreg_t	ii_ixcc_regval;
-	struct  {
-		shubreg_t	i_time_out                :	26;
-		shubreg_t	i_rsvd			  :	38;
-	} ii_ixcc_fld_s;
-} ii_ixcc_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This register qualifies all the PIO and DMA            *
- * operations launched from widget 0 towards the SHub. In               *
- * addition, it also qualifies accesses by the BTE streams.             *
- * The bits in each field of this register are cleared by the SHub      *
- * upon detection of an error which requires widget 0 or the BTE        *
- * streams to be terminated. Whether or not widget x has access         *
- * rights to this SHub is determined by an AND of the device            *
- * enable bit in the appropriate field of this register and bit 0 in    *
- * the Wx_IAC field. The bits in this field are set by writing a 1 to   *
- * them. Incoming replies from Crosstalk are not subject to this        *
- * access control mechanism.                                            *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_imem_u {
-	shubreg_t	ii_imem_regval;
-	struct  {
-		shubreg_t	i_w0_esd                  :	 1;
-		shubreg_t	i_rsvd_3		  :	 3;
-		shubreg_t	i_b0_esd		  :	 1;
-		shubreg_t	i_rsvd_2		  :	 3;
-		shubreg_t	i_b1_esd		  :	 1;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t	i_clr_precise		  :	 1;
-		shubreg_t       i_rsvd                    :     51;
-	} ii_imem_fld_s;
-} ii_imem_u_t;
-
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This register specifies the timeout value to use for   *
- * monitoring Crosstalk tail flits coming into the Shub in the          *
- * TAIL_TO field. An internal counter associated with this register     *
- * is incremented every 128 II internal clocks (7 bits). The counter    *
- * starts counting anytime a header micropacket is received and stops   *
- * counting (and resets to zero) any time a micropacket with a Tail     *
- * bit is received. Once the counter reaches the threshold value        *
- * programmed in this register, it generates an interrupt to the        *
- * processor that is programmed into the IIDSR. The counter saturates   *
- * (does not roll over) at its maximum value, so it cannot cause        *
- * another interrupt until after it is cleared.                         *
- * The register also contains the Read Response Timeout values. The     *
- * Prescalar is 23 bits, and counts II clocks. An internal counter      *
- * increments on every II clock and when it reaches the value in the    *
- * Prescalar field, all IPRTE registers with their valid bits set       *
- * have their Read Response timers bumped. Whenever any of them match   *
- * the value in the RRSP_TO field, a Read Response Timeout has          *
- * occurred, and error handling occurs as described in the Error        *
- * Handling section of this document.                                   *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ixtt_u {
-	shubreg_t	ii_ixtt_regval;
-	struct  {
-		shubreg_t	i_tail_to                 :	26;
-		shubreg_t	i_rsvd_1		  :	 6;
-		shubreg_t	i_rrsp_ps		  :	23;
-		shubreg_t	i_rrsp_to		  :	 5;
-		shubreg_t	i_rsvd			  :	 4;
-	} ii_ixtt_fld_s;
-} ii_ixtt_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  Writing a 1 to the fields of this register clears the appropriate   *
- * error bits in other areas of SHub. Note that when the                *
- * E_PRB_x bits are used to clear error bits in PRB registers,          *
- * SPUR_RD and SPUR_WR may persist, because they require additional     *
- * action to clear them. See the IPRBx and IXSS Register                *
- * specifications.                                                      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ieclr_u {
-	shubreg_t	ii_ieclr_regval;
-	struct  {
-		shubreg_t	i_e_prb_0                 :	 1;
-		shubreg_t	i_rsvd			  :	 7;
-		shubreg_t	i_e_prb_8		  :	 1;
-		shubreg_t	i_e_prb_9		  :	 1;
-		shubreg_t	i_e_prb_a		  :	 1;
-		shubreg_t	i_e_prb_b		  :	 1;
-		shubreg_t	i_e_prb_c		  :	 1;
-		shubreg_t	i_e_prb_d		  :	 1;
-		shubreg_t	i_e_prb_e		  :	 1;
-		shubreg_t	i_e_prb_f		  :	 1;
-		shubreg_t	i_e_crazy		  :	 1;
-		shubreg_t	i_e_bte_0		  :	 1;
-		shubreg_t	i_e_bte_1		  :	 1;
-		shubreg_t	i_reserved_1		  :	10;
-		shubreg_t	i_spur_rd_hdr		  :	 1;
-		shubreg_t	i_cam_intr_to		  :	 1;
-		shubreg_t	i_cam_overflow		  :	 1;
-		shubreg_t	i_cam_read_miss		  :	 1;
-		shubreg_t	i_ioq_rep_underflow	  :	 1;
-		shubreg_t	i_ioq_req_underflow	  :	 1;
-		shubreg_t	i_ioq_rep_overflow	  :	 1;
-		shubreg_t	i_ioq_req_overflow	  :	 1;
-		shubreg_t	i_iiq_rep_overflow	  :	 1;
-		shubreg_t	i_iiq_req_overflow	  :	 1;
-		shubreg_t	i_ii_xn_rep_cred_overflow :	 1;
-		shubreg_t	i_ii_xn_req_cred_overflow :	 1;
-		shubreg_t	i_ii_xn_invalid_cmd	  :	 1;
-		shubreg_t	i_xn_ii_invalid_cmd	  :	 1;
-		shubreg_t	i_reserved_2		  :	21;
-	} ii_ieclr_fld_s;
-} ii_ieclr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register controls both BTEs. SOFT_RESET is intended for        *
- * recovery after an error. COUNT controls the total number of CRBs     *
- * that both BTEs (combined) can use, which affects total BTE           *
- * bandwidth.                                                           *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibcr_u {
-	shubreg_t	ii_ibcr_regval;
-	struct  {
-		shubreg_t	i_count                   :	 4;
-		shubreg_t	i_rsvd_1		  :	 4;
-		shubreg_t	i_soft_reset		  :	 1;
-		shubreg_t	i_rsvd			  :	55;
-	} ii_ibcr_fld_s;
-} ii_ibcr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the header of a spurious read response       *
- * received from Crosstalk. A spurious read response is defined as a    *
- * read response received by II from a widget for which (1) the SIDN    *
- * has a value between 1 and 7, inclusive (II never sends requests to   *
- * these widgets (2) there is no valid IPRTE register which             *
- * corresponds to the TNUM, or (3) the widget indicated in SIDN is      *
- * not the same as the widget recorded in the IPRTE register            *
- * referenced by the TNUM. If this condition is true, and if the        *
- * IXSS[VALID] bit is clear, then the header of the spurious read       *
- * response is capture in IXSM and IXSS, and IXSS[VALID] is set. The    *
- * errant header is thereby captured, and no further spurious read      *
- * respones are captured until IXSS[VALID] is cleared by setting the    *
- * appropriate bit in IECLR.Everytime a spurious read response is       *
- * detected, the SPUR_RD bit of the PRB corresponding to the incoming   *
- * message's SIDN field is set. This always happens, regarless of       *
- * whether a header is captured. The programmer should check            *
- * IXSM[SIDN] to determine which widget sent the spurious response,     *
- * because there may be more than one SPUR_RD bit set in the PRB        *
- * registers. The widget indicated by IXSM[SIDN] was the first          *
- * spurious read response to be received since the last time            *
- * IXSS[VALID] was clear. The SPUR_RD bit of the corresponding PRB      *
- * will be set. Any SPUR_RD bits in any other PRB registers indicate    *
- * spurious messages from other widets which were detected after the    *
- * header was captured..                                                *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ixsm_u {
-	shubreg_t	ii_ixsm_regval;
-	struct  {
-		shubreg_t	i_byte_en                 :	32;
-		shubreg_t	i_reserved		  :	 1;
-		shubreg_t	i_tag			  :	 3;
-		shubreg_t	i_alt_pactyp		  :	 4;
-		shubreg_t	i_bo			  :	 1;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_vbpm			  :	 1;
-		shubreg_t	i_gbr			  :	 1;
-		shubreg_t	i_ds			  :	 2;
-		shubreg_t	i_ct			  :	 1;
-		shubreg_t	i_tnum			  :	 5;
-		shubreg_t	i_pactyp		  :	 4;
-		shubreg_t	i_sidn			  :	 4;
-		shubreg_t	i_didn			  :	 4;
-	} ii_ixsm_fld_s;
-} ii_ixsm_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the sideband bits of a spurious read         *
- * response received from Crosstalk.                                    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ixss_u {
-	shubreg_t	ii_ixss_regval;
-	struct  {
-		shubreg_t	i_sideband                :	 8;
-		shubreg_t	i_rsvd			  :	55;
-		shubreg_t	i_valid			  :	 1;
-	} ii_ixss_fld_s;
-} ii_ixss_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register enables software to access the II LLP's test port.    *
- * Refer to the LLP 2.5 documentation for an explanation of the test    *
- * port. Software can write to this register to program the values      *
- * for the control fields (TestErrCapture, TestClear, TestFlit,         *
- * TestMask and TestSeed). Similarly, software can read from this       *
- * register to obtain the values of the test port's status outputs      *
- * (TestCBerr, TestValid and TestData).                                 *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ilct_u {
-	shubreg_t	ii_ilct_regval;
-	struct  {
-		shubreg_t	i_test_seed               :	20;
-		shubreg_t	i_test_mask               :	 8;
-		shubreg_t	i_test_data               :	20;
-		shubreg_t	i_test_valid              :	 1;
-		shubreg_t	i_test_cberr              :	 1;
-		shubreg_t	i_test_flit               :	 3;
-		shubreg_t	i_test_clear              :	 1;
-		shubreg_t	i_test_err_capture        :	 1;
-		shubreg_t	i_rsvd                    :	 9;
-	} ii_ilct_fld_s;
-} ii_ilct_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  If the II detects an illegal incoming Duplonet packet (request or   *
- * reply) when VALID==0 in the IIEPH1 register, then it saves the       *
- * contents of the packet's header flit in the IIEPH1 and IIEPH2        *
- * registers, sets the VALID bit in IIEPH1, clears the OVERRUN bit,     *
- * and assigns a value to the ERR_TYPE field which indicates the        *
- * specific nature of the error. The II recognizes four different       *
- * types of errors: short request packets (ERR_TYPE==2), short reply    *
- * packets (ERR_TYPE==3), long request packets (ERR_TYPE==4) and long   *
- * reply packets (ERR_TYPE==5). The encodings for these types of        *
- * errors were chosen to be consistent with the same types of errors    *
- * indicated by the ERR_TYPE field in the LB_ERROR_HDR1 register (in    *
- * the LB unit). If the II detects an illegal incoming Duplonet         *
- * packet when VALID==1 in the IIEPH1 register, then it merely sets     *
- * the OVERRUN bit to indicate that a subsequent error has happened,    *
- * and does nothing further.                                            *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iieph1_u {
-	shubreg_t	ii_iieph1_regval;
-	struct	{
-		shubreg_t	i_command		  :	 7;
-		shubreg_t	i_rsvd_5		  :	 1;
-		shubreg_t	i_suppl			  :	14;
-		shubreg_t	i_rsvd_4		  :	 1;
-		shubreg_t	i_source		  :	14;
-		shubreg_t	i_rsvd_3		  :	 1;
-		shubreg_t	i_err_type		  :	 4;
-		shubreg_t	i_rsvd_2		  :	 4;
-		shubreg_t	i_overrun		  :	 1;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t	i_valid			  :	 1;
-		shubreg_t	i_rsvd			  :	13;
-	} ii_iieph1_fld_s;
-} ii_iieph1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register holds the Address field from the header flit of an    *
- * incoming erroneous Duplonet packet, along with the tail bit which    *
- * accompanied this header flit. This register is essentially an        *
- * extension of IIEPH1. Two registers were necessary because the 64     *
- * bits available in only a single register were insufficient to        *
- * capture the entire header flit of an erroneous packet.               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iieph2_u {
-	shubreg_t	ii_iieph2_regval;
-	struct  {
-		shubreg_t	i_rsvd_0		  :	 3;
-		shubreg_t	i_address                 :	47;
-		shubreg_t	i_rsvd_1		  :	10;
-		shubreg_t	i_tail			  :	 1;
-		shubreg_t	i_rsvd			  :	 3;
-	} ii_iieph2_fld_s;
-} ii_iieph2_u_t;
-
-
-/******************************/
-
-
-
-/************************************************************************
- *                                                                      *
- *  This register's value is a bit vector that guards access from SXBs  *
- * to local registers within the II as well as to external Crosstalk    *
- * widgets								*
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_islapr_u {
-	shubreg_t	ii_islapr_regval;
-	struct  {
-		shubreg_t	i_region		  :	64;
-	} ii_islapr_fld_s;
-} ii_islapr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  A write to this register of the 56-bit value "Pup+Bun" will cause	*
- * the bit in the ISLAPR register corresponding to the region of the	*
- * requestor to be set (access allowed).				(
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_islapo_u {
-	shubreg_t	ii_islapo_regval;
-	struct  {
-		shubreg_t	i_io_sbx_ovrride	  :	56;
-		shubreg_t	i_rsvd			  :	 8;
-	} ii_islapo_fld_s;
-} ii_islapo_u_t;
-
-/************************************************************************
- *                                                                      *
- *  Determines how long the wrapper will wait aftr an interrupt is	*
- * initially issued from the II before it times out the outstanding	*
- * interrupt and drops it from the interrupt queue.			* 
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iwi_u {
-	shubreg_t	ii_iwi_regval;
-	struct  {
-		shubreg_t	i_prescale		  :	24;
-		shubreg_t	i_rsvd			  :	 8;
-		shubreg_t	i_timeout		  :	 8;
-		shubreg_t	i_rsvd1			  :	 8;
-		shubreg_t	i_intrpt_retry_period	  :	 8;
-		shubreg_t	i_rsvd2			  :	 8;
-	} ii_iwi_fld_s;
-} ii_iwi_u_t;
-
-/************************************************************************
- *                                                                      *
- *  Log errors which have occurred in the II wrapper. The errors are	*
- * cleared by writing to the IECLR register.				* 
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iwel_u {
-	shubreg_t	ii_iwel_regval;
-	struct  {
-		shubreg_t	i_intr_timed_out	  :	 1;
-		shubreg_t	i_rsvd			  :	 7;
-		shubreg_t	i_cam_overflow		  :	 1;
-		shubreg_t	i_cam_read_miss		  :	 1;
-		shubreg_t	i_rsvd1			  :	 2;
-		shubreg_t	i_ioq_rep_underflow	  :	 1;
-		shubreg_t	i_ioq_req_underflow	  :	 1;
-		shubreg_t	i_ioq_rep_overflow	  :	 1;
-		shubreg_t	i_ioq_req_overflow	  :	 1;
-		shubreg_t	i_iiq_rep_overflow	  :	 1;
-		shubreg_t	i_iiq_req_overflow	  :	 1;
-		shubreg_t	i_rsvd2			  :	 6;
-		shubreg_t	i_ii_xn_rep_cred_over_under:	 1;
-		shubreg_t	i_ii_xn_req_cred_over_under:	 1;
-		shubreg_t	i_rsvd3			  :	 6;
-		shubreg_t	i_ii_xn_invalid_cmd	  :	 1;
-		shubreg_t	i_xn_ii_invalid_cmd	  :	 1;
-		shubreg_t	i_rsvd4			  :	30;
-	} ii_iwel_fld_s;
-} ii_iwel_u_t;
-
-/************************************************************************
- *                                                                      *
- *  Controls the II wrapper.						* 
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iwc_u {
-	shubreg_t	ii_iwc_regval;
-	struct  {
-		shubreg_t	i_dma_byte_swap		  :	 1;
-		shubreg_t	i_rsvd			  :	 3;
-		shubreg_t	i_cam_read_lines_reset	  :	 1;
-		shubreg_t	i_rsvd1			  :	 3;
-		shubreg_t	i_ii_xn_cred_over_under_log:	 1;
-		shubreg_t	i_rsvd2			  :	19;
-		shubreg_t	i_xn_rep_iq_depth	  :	 5;
-		shubreg_t	i_rsvd3			  :	 3;
-		shubreg_t	i_xn_req_iq_depth	  :	 5;
-		shubreg_t	i_rsvd4			  :	 3;
-		shubreg_t	i_iiq_depth		  :	 6;
-		shubreg_t	i_rsvd5			  :	12;
-		shubreg_t	i_force_rep_cred	  :	 1;
-		shubreg_t	i_force_req_cred	  :	 1;
-	} ii_iwc_fld_s;
-} ii_iwc_u_t;
-
-/************************************************************************
- *                                                                      *
- *  Status in the II wrapper.						* 
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iws_u {
-	shubreg_t	ii_iws_regval;
-	struct  {
-		shubreg_t	i_xn_rep_iq_credits	  :	 5;
-		shubreg_t	i_rsvd			  :	 3;
-		shubreg_t	i_xn_req_iq_credits	  :	 5;
-		shubreg_t	i_rsvd1			  :	51;
-	} ii_iws_fld_s;
-} ii_iws_u_t;
-
-/************************************************************************
- *                                                                      *
- *  Masks errors in the IWEL register.					*
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iweim_u {
-	shubreg_t	ii_iweim_regval;
-	struct  {
-		shubreg_t	i_intr_timed_out	  :	 1;
-		shubreg_t	i_rsvd			  :	 7;
-		shubreg_t	i_cam_overflow		  :	 1;
-		shubreg_t	i_cam_read_miss		  :	 1;
-		shubreg_t	i_rsvd1			  :	 2;
-		shubreg_t	i_ioq_rep_underflow	  :	 1;
-		shubreg_t	i_ioq_req_underflow	  :	 1;
-		shubreg_t	i_ioq_rep_overflow	  :	 1;
-		shubreg_t	i_ioq_req_overflow	  :	 1;
-		shubreg_t	i_iiq_rep_overflow	  :	 1;
-		shubreg_t	i_iiq_req_overflow	  :	 1;
-		shubreg_t	i_rsvd2			  :	 6;
-		shubreg_t	i_ii_xn_rep_cred_overflow :	 1;
-		shubreg_t	i_ii_xn_req_cred_overflow :	 1;
-		shubreg_t	i_rsvd3			  :	 6;
-		shubreg_t	i_ii_xn_invalid_cmd	  :	 1;
-		shubreg_t	i_xn_ii_invalid_cmd	  :	 1;
-		shubreg_t	i_rsvd4			  :	30;
-	} ii_iweim_fld_s;
-} ii_iweim_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  A write to this register causes a particular field in the           *
- * corresponding widget's PRB entry to be adjusted up or down by 1.     *
- * This counter should be used when recovering from error and reset     *
- * conditions. Note that software would be capable of causing           *
- * inadvertent overflow or underflow of these counters.                 *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ipca_u {
-	shubreg_t	ii_ipca_regval;
-	struct  {
-		shubreg_t	i_wid                     :	 4;
-		shubreg_t	i_adjust		  :	 1;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t	i_field			  :	 2;
-		shubreg_t	i_rsvd			  :	54;
-	} ii_ipca_fld_s;
-} ii_ipca_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-
-typedef union ii_iprte0a_u {
-	shubreg_t	ii_iprte0a_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	54;
-		shubreg_t	i_widget		  :	 4;
-		shubreg_t	i_to_cnt		  :	 5;
-		shubreg_t       i_vld                     :      1;
-	} ii_iprte0a_fld_s;
-} ii_iprte0a_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte1a_u {
-	shubreg_t	ii_iprte1a_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	54;
-		shubreg_t	i_widget		  :	 4;
-		shubreg_t	i_to_cnt		  :	 5;
-		shubreg_t       i_vld                     :      1;
-	} ii_iprte1a_fld_s;
-} ii_iprte1a_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte2a_u {
-	shubreg_t	ii_iprte2a_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	54;
-		shubreg_t	i_widget		  :	 4;
-		shubreg_t	i_to_cnt		  :	 5;
-		shubreg_t       i_vld                     :      1;
-	} ii_iprte2a_fld_s;
-} ii_iprte2a_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte3a_u {
-	shubreg_t	ii_iprte3a_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	54;
-		shubreg_t	i_widget		  :	 4;
-		shubreg_t	i_to_cnt		  :	 5;
-		shubreg_t	i_vld			  :	 1;
-	} ii_iprte3a_fld_s;
-} ii_iprte3a_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte4a_u {
-	shubreg_t	ii_iprte4a_regval;
-	struct	{
-		shubreg_t	i_rsvd_1		  :	54;
-		shubreg_t	i_widget		  :	 4;
-		shubreg_t	i_to_cnt		  :	 5;
-		shubreg_t	i_vld			  :	 1;
-	} ii_iprte4a_fld_s;
-} ii_iprte4a_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte5a_u {
-	shubreg_t	ii_iprte5a_regval;
-	struct	{
-		shubreg_t	i_rsvd_1		  :	54;
-		shubreg_t	i_widget		  :	 4;
-		shubreg_t	i_to_cnt		  :	 5;
-		shubreg_t	i_vld			  :	 1;
-	} ii_iprte5a_fld_s;
-} ii_iprte5a_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte6a_u {
-	shubreg_t	ii_iprte6a_regval;
-	struct	{
-		shubreg_t	i_rsvd_1		  :	54;
-		shubreg_t	i_widget		  :	 4;
-		shubreg_t	i_to_cnt		  :	 5;
-		shubreg_t	i_vld			  :	 1;
-	} ii_iprte6a_fld_s;
-} ii_iprte6a_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte7a_u {
-        shubreg_t       ii_iprte7a_regval;
-        struct  {
-                shubreg_t       i_rsvd_1                  :     54;
-                shubreg_t       i_widget                  :      4;
-                shubreg_t       i_to_cnt                  :      5;
-                shubreg_t       i_vld                     :      1;
-        } ii_iprtea7_fld_s;
-} ii_iprte7a_u_t;
-
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-
-typedef union ii_iprte0b_u {
-	shubreg_t	ii_iprte0b_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_address		  :	47;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t       i_source                  :     11;
-	} ii_iprte0b_fld_s;
-} ii_iprte0b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte1b_u {
-	shubreg_t	ii_iprte1b_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_address		  :	47;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t       i_source                  :     11;
-	} ii_iprte1b_fld_s;
-} ii_iprte1b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte2b_u {
-	shubreg_t	ii_iprte2b_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_address		  :	47;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t       i_source                  :     11;
-	} ii_iprte2b_fld_s;
-} ii_iprte2b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte3b_u {
-	shubreg_t	ii_iprte3b_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_address		  :	47;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t       i_source                  :     11;
-	} ii_iprte3b_fld_s;
-} ii_iprte3b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte4b_u {
-	shubreg_t	ii_iprte4b_regval;
-	struct	{
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_address		  :	47;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t       i_source                  :     11;
-	} ii_iprte4b_fld_s;
-} ii_iprte4b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte5b_u {
-	shubreg_t	ii_iprte5b_regval;
-	struct	{
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_address		  :	47;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t       i_source                  :     11;
-	} ii_iprte5b_fld_s;
-} ii_iprte5b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte6b_u {
-	shubreg_t	ii_iprte6b_regval;
-	struct	{
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_address		  :	47;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t       i_source                  :     11;
-
-	} ii_iprte6b_fld_s;
-} ii_iprte6b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  There are 8 instances of this register. This register contains      *
- * the information that the II has to remember once it has launched a   *
- * PIO Read operation. The contents are used to form the correct        *
- * Router Network packet and direct the Crosstalk reply to the          *
- * appropriate processor.                                               *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iprte7b_u {
-        shubreg_t       ii_iprte7b_regval;
-        struct  {
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_address		  :	47;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t       i_source                  :     11;
-        } ii_iprte7b_fld_s;
-} ii_iprte7b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  SHub II contains a feature which did not exist in      *
- * the Hub which automatically cleans up after a Read Response          *
- * timeout, including deallocation of the IPRTE and recovery of IBuf    *
- * space. The inclusion of this register in SHub is for backward        *
- * compatibility                                                        *
- * A write to this register causes an entry from the table of           *
- * outstanding PIO Read Requests to be freed and returned to the        *
- * stack of free entries. This register is used in handling the         *
- * timeout errors that result in a PIO Reply never returning from       *
- * Crosstalk.                                                           *
- * Note that this register does not affect the contents of the IPRTE    *
- * registers. The Valid bits in those registers have to be              *
- * specifically turned off by software.                                 *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ipdr_u {
-	shubreg_t	ii_ipdr_regval;
-	struct  {
-		shubreg_t	i_te                      :	 3;
-		shubreg_t	i_rsvd_1		  :	 1;
-		shubreg_t	i_pnd			  :	 1;
-		shubreg_t	i_init_rpcnt		  :	 1;
-		shubreg_t	i_rsvd			  :	58;
-	} ii_ipdr_fld_s;
-} ii_ipdr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  A write to this register causes a CRB entry to be returned to the   *
- * queue of free CRBs. The entry should have previously been cleared    *
- * (mark bit) via backdoor access to the pertinent CRB entry. This      *
- * register is used in the last step of handling the errors that are    *
- * captured and marked in CRB entries.  Briefly: 1) first error for     *
- * DMA write from a particular device, and first error for a            *
- * particular BTE stream, lead to a marked CRB entry, and processor     *
- * interrupt, 2) software reads the error information captured in the   *
- * CRB entry, and presumably takes some corrective action, 3)           *
- * software clears the mark bit, and finally 4) software writes to      *
- * the ICDR register to return the CRB entry to the list of free CRB    *
- * entries.                                                             *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icdr_u {
-	shubreg_t	ii_icdr_regval;
-	struct  {
-		shubreg_t	i_crb_num                 :	 4;
-		shubreg_t	i_pnd			  :	 1;
-		shubreg_t       i_rsvd                    :     59;
-	} ii_icdr_fld_s;
-} ii_icdr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register provides debug access to two FIFOs inside of II.      *
- * Both IOQ_MAX* fields of this register contain the instantaneous      *
- * depth (in units of the number of available entries) of the           *
- * associated IOQ FIFO.  A read of this register will return the        *
- * number of free entries on each FIFO at the time of the read.  So     *
- * when a FIFO is idle, the associated field contains the maximum       *
- * depth of the FIFO.  This register is writable for debug reasons      *
- * and is intended to be written with the maximum desired FIFO depth    *
- * while the FIFO is idle. Software must assure that II is idle when    *
- * this register is written. If there are any active entries in any     *
- * of these FIFOs when this register is written, the results are        *
- * undefined.                                                           *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ifdr_u {
-	shubreg_t	ii_ifdr_regval;
-	struct  {
-		shubreg_t	i_ioq_max_rq              :	 7;
-		shubreg_t	i_set_ioq_rq		  :	 1;
-		shubreg_t	i_ioq_max_rp		  :	 7;
-		shubreg_t	i_set_ioq_rp		  :	 1;
-		shubreg_t	i_rsvd			  :	48;
-	} ii_ifdr_fld_s;
-} ii_ifdr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register allows the II to become sluggish in removing          *
- * messages from its inbound queue (IIQ). This will cause messages to   *
- * back up in either virtual channel. Disabling the "molasses" mode     *
- * subsequently allows the II to be tested under stress. In the         *
- * sluggish ("Molasses") mode, the localized effects of congestion      *
- * can be observed.                                                     *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iiap_u {
-        shubreg_t       ii_iiap_regval;
-        struct  {
-                shubreg_t       i_rq_mls                  :      6;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_rp_mls		  :	 6;
-		shubreg_t       i_rsvd                    :     50;
-        } ii_iiap_fld_s;
-} ii_iiap_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register allows several parameters of CRB operation to be      *
- * set. Note that writing to this register can have catastrophic side   *
- * effects, if the CRB is not quiescent, i.e. if the CRB is             *
- * processing protocol messages when the write occurs.                  *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icmr_u {
-	shubreg_t	ii_icmr_regval;
-	struct  {
-		shubreg_t	i_sp_msg                  :	 1;
-		shubreg_t	i_rd_hdr		  :	 1;
-		shubreg_t	i_rsvd_4		  :	 2;
-		shubreg_t	i_c_cnt			  :	 4;
-		shubreg_t	i_rsvd_3		  :	 4;
-		shubreg_t	i_clr_rqpd		  :	 1;
-		shubreg_t	i_clr_rppd		  :	 1;
-		shubreg_t	i_rsvd_2		  :	 2;
-		shubreg_t	i_fc_cnt		  :	 4;
-		shubreg_t	i_crb_vld		  :	15;
-		shubreg_t	i_crb_mark		  :	15;
-		shubreg_t	i_rsvd_1		  :	 2;
-		shubreg_t	i_precise		  :	 1;
-		shubreg_t	i_rsvd			  :	11;
-	} ii_icmr_fld_s;
-} ii_icmr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register allows control of the table portion of the CRB        *
- * logic via software. Control operations from this register have       *
- * priority over all incoming Crosstalk or BTE requests.                *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_iccr_u {
-	shubreg_t	ii_iccr_regval;
-	struct  {
-		shubreg_t	i_crb_num                 :	 4;
-		shubreg_t	i_rsvd_1		  :	 4;
-		shubreg_t	i_cmd			  :	 8;
-		shubreg_t	i_pending		  :	 1;
-		shubreg_t	i_rsvd			  :	47;
-	} ii_iccr_fld_s;
-} ii_iccr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register allows the maximum timeout value to be programmed.    *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icto_u {
-	shubreg_t	ii_icto_regval;
-	struct  {
-		shubreg_t	i_timeout                 :	 8;
-		shubreg_t	i_rsvd			  :	56;
-	} ii_icto_fld_s;
-} ii_icto_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register allows the timeout prescalar to be programmed. An     *
- * internal counter is associated with this register. When the          *
- * internal counter reaches the value of the PRESCALE field, the        *
- * timer registers in all valid CRBs are incremented (CRBx_D[TIMEOUT]   *
- * field). The internal counter resets to zero, and then continues      *
- * counting.                                                            *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ictp_u {
-	shubreg_t	ii_ictp_regval;
-	struct  {
-		shubreg_t	i_prescale                :	24;
-		shubreg_t	i_rsvd			  :	40;
-	} ii_ictp_fld_s;
-} ii_ictp_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
- * used for Crosstalk operations (both cacheline and partial            *
- * operations) or BTE/IO. Because the CRB entries are very wide, five   *
- * registers (_A to _E) are required to read and write each entry.      *
- * The CRB Entry registers can be conceptualized as rows and columns    *
- * (illustrated in the table above). Each row contains the 4            *
- * registers required for a single CRB Entry. The first doubleword      *
- * (column) for each entry is labeled A, and the second doubleword      *
- * (higher address) is labeled B, the third doubleword is labeled C,    *
- * the fourth doubleword is labeled D and the fifth doubleword is       *
- * labeled E. All CRB entries have their addresses on a quarter         *
- * cacheline aligned boundary.                   *
- * Upon reset, only the following fields are initialized: valid         *
- * (VLD), priority count, timeout, timeout valid, and context valid.    *
- * All other bits should be cleared by software before use (after       *
- * recovering any potential error state from before the reset).         *
- * The following four tables summarize the format for the four          *
- * registers that are used for each ICRB# Entry.                        *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icrb0_a_u {
-	shubreg_t	ii_icrb0_a_regval;
-	struct  {
-		shubreg_t	ia_iow                    :	 1;
-		shubreg_t	ia_vld			  :	 1;
-		shubreg_t	ia_addr			  :	47;
-		shubreg_t	ia_tnum			  :	 5;
-		shubreg_t	ia_sidn			  :	 4;
-		shubreg_t       ia_rsvd                   :      6;
-	} ii_icrb0_a_fld_s;
-} ii_icrb0_a_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
- * used for Crosstalk operations (both cacheline and partial            *
- * operations) or BTE/IO. Because the CRB entries are very wide, five   *
- * registers (_A to _E) are required to read and write each entry.      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icrb0_b_u {
-	shubreg_t	ii_icrb0_b_regval;
-	struct	{
-		shubreg_t	ib_xt_err		  :	 1;
-		shubreg_t	ib_mark			  :	 1;
-		shubreg_t	ib_ln_uce		  :	 1;
-		shubreg_t	ib_errcode		  :	 3;
-		shubreg_t	ib_error		  :	 1;
-		shubreg_t	ib_stall__bte_1		  :	 1;
-		shubreg_t	ib_stall__bte_0		  :	 1;
-		shubreg_t	ib_stall__intr		  :	 1;
-		shubreg_t	ib_stall_ib		  :	 1;
-		shubreg_t	ib_intvn		  :	 1;
-		shubreg_t	ib_wb			  :	 1;
-		shubreg_t	ib_hold			  :	 1;
-		shubreg_t	ib_ack			  :	 1;
-		shubreg_t	ib_resp			  :	 1;
-		shubreg_t	ib_ack_cnt		  :	11;
-		shubreg_t	ib_rsvd			  :	 7;
-		shubreg_t	ib_exc			  :	 5;
-		shubreg_t	ib_init			  :	 3;
-		shubreg_t	ib_imsg			  :	 8;
-		shubreg_t	ib_imsgtype		  :	 2;
-		shubreg_t	ib_use_old		  :	 1;
-		shubreg_t	ib_rsvd_1		  :	11;
-	} ii_icrb0_b_fld_s;
-} ii_icrb0_b_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
- * used for Crosstalk operations (both cacheline and partial            *
- * operations) or BTE/IO. Because the CRB entries are very wide, five   *
- * registers (_A to _E) are required to read and write each entry.      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icrb0_c_u {
-	shubreg_t	ii_icrb0_c_regval;
-	struct	{
-		shubreg_t	ic_source		  :	15;
-		shubreg_t	ic_size			  :	 2;
-		shubreg_t	ic_ct			  :	 1;
-		shubreg_t	ic_bte_num		  :	 1;
-		shubreg_t	ic_gbr			  :	 1;
-		shubreg_t	ic_resprqd		  :	 1;
-		shubreg_t	ic_bo			  :	 1;
-		shubreg_t	ic_suppl		  :	15;
-		shubreg_t	ic_rsvd			  :	27;
-	} ii_icrb0_c_fld_s;
-} ii_icrb0_c_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
- * used for Crosstalk operations (both cacheline and partial            *
- * operations) or BTE/IO. Because the CRB entries are very wide, five   *
- * registers (_A to _E) are required to read and write each entry.      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icrb0_d_u {
-	shubreg_t	ii_icrb0_d_regval;
-	struct  {
-		shubreg_t	id_pa_be                  :	43;
-		shubreg_t	id_bte_op		  :	 1;
-		shubreg_t	id_pr_psc		  :	 4;
-		shubreg_t	id_pr_cnt		  :	 4;
-		shubreg_t	id_sleep		  :	 1;
-		shubreg_t	id_rsvd			  :	11;
-	} ii_icrb0_d_fld_s;
-} ii_icrb0_d_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  There are 15 CRB Entries (ICRB0 to ICRBE) that are     *
- * used for Crosstalk operations (both cacheline and partial            *
- * operations) or BTE/IO. Because the CRB entries are very wide, five   *
- * registers (_A to _E) are required to read and write each entry.      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icrb0_e_u {
-	shubreg_t	ii_icrb0_e_regval;
-	struct  {
-		shubreg_t	ie_timeout                :	 8;
-		shubreg_t	ie_context		  :	15;
-		shubreg_t	ie_rsvd			  :	 1;
-		shubreg_t	ie_tvld			  :	 1;
-		shubreg_t	ie_cvld			  :	 1;
-		shubreg_t	ie_rsvd_0		  :	38;
-	} ii_icrb0_e_fld_s;
-} ii_icrb0_e_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the lower 64 bits of the header of the       *
- * spurious message captured by II. Valid when the SP_MSG bit in ICMR   *
- * register is set.                                                     *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icsml_u {
-	shubreg_t	ii_icsml_regval;
-	struct  {
-		shubreg_t	i_tt_addr                 :	47;
-		shubreg_t	i_newsuppl_ex		  :	14;
-		shubreg_t	i_reserved		  :	 2;
-		shubreg_t       i_overflow                :      1;
-	} ii_icsml_fld_s;
-} ii_icsml_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the middle 64 bits of the header of the      *
- * spurious message captured by II. Valid when the SP_MSG bit in ICMR   *
- * register is set.                                                     *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icsmm_u {
-	shubreg_t	ii_icsmm_regval;
-	struct  {
-		shubreg_t	i_tt_ack_cnt              :	11;
-		shubreg_t	i_reserved		  :	53;
-	} ii_icsmm_fld_s;
-} ii_icsmm_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the microscopic state, all the inputs to     *
- * the protocol table, captured with the spurious message. Valid when   *
- * the SP_MSG bit in the ICMR register is set.                          *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_icsmh_u {
-	shubreg_t	ii_icsmh_regval;
-	struct  {
-		shubreg_t	i_tt_vld                  :	 1;
-		shubreg_t	i_xerr			  :	 1;
-		shubreg_t	i_ft_cwact_o		  :	 1;
-		shubreg_t	i_ft_wact_o		  :	 1;
-		shubreg_t       i_ft_active_o             :      1;
-		shubreg_t	i_sync			  :	 1;
-		shubreg_t	i_mnusg			  :	 1;
-		shubreg_t	i_mnusz			  :	 1;
-		shubreg_t	i_plusz			  :	 1;
-		shubreg_t	i_plusg			  :	 1;
-		shubreg_t	i_tt_exc		  :	 5;
-		shubreg_t	i_tt_wb			  :	 1;
-		shubreg_t	i_tt_hold		  :	 1;
-		shubreg_t	i_tt_ack		  :	 1;
-		shubreg_t	i_tt_resp		  :	 1;
-		shubreg_t	i_tt_intvn		  :	 1;
-		shubreg_t	i_g_stall_bte1		  :	 1;
-		shubreg_t	i_g_stall_bte0		  :	 1;
-		shubreg_t	i_g_stall_il		  :	 1;
-		shubreg_t	i_g_stall_ib		  :	 1;
-		shubreg_t	i_tt_imsg		  :	 8;
-		shubreg_t	i_tt_imsgtype		  :	 2;
-		shubreg_t	i_tt_use_old		  :	 1;
-		shubreg_t	i_tt_respreqd		  :	 1;
-		shubreg_t	i_tt_bte_num		  :	 1;
-		shubreg_t	i_cbn			  :	 1;
-		shubreg_t	i_match			  :	 1;
-		shubreg_t	i_rpcnt_lt_34		  :	 1;
-		shubreg_t	i_rpcnt_ge_34		  :	 1;
-		shubreg_t	i_rpcnt_lt_18		  :	 1;
-		shubreg_t	i_rpcnt_ge_18		  :	 1;
-		shubreg_t       i_rpcnt_lt_2              :      1;
-		shubreg_t	i_rpcnt_ge_2		  :	 1;
-		shubreg_t	i_rqcnt_lt_18		  :	 1;
-		shubreg_t	i_rqcnt_ge_18		  :	 1;
-		shubreg_t	i_rqcnt_lt_2		  :	 1;
-		shubreg_t	i_rqcnt_ge_2		  :	 1;
-		shubreg_t	i_tt_device		  :	 7;
-		shubreg_t	i_tt_init		  :	 3;
-		shubreg_t	i_reserved		  :	 5;
-	} ii_icsmh_fld_s;
-} ii_icsmh_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  The Shub DEBUG unit provides a 3-bit selection signal to the        *
- * II core and a 3-bit selection signal to the fsbclk domain in the II  *
- * wrapper.                                                             *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_idbss_u {
-	shubreg_t	ii_idbss_regval;
-	struct  {
-		shubreg_t	i_iioclk_core_submenu     :	 3;
-		shubreg_t	i_rsvd			  :	 5;
-		shubreg_t	i_fsbclk_wrapper_submenu  :	 3;
-		shubreg_t	i_rsvd_1		  :	 5;
-		shubreg_t	i_iioclk_menu		  :	 5;
-		shubreg_t	i_rsvd_2		  :	43;
-	} ii_idbss_fld_s;
-} ii_idbss_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This register is used to set up the length for a       *
- * transfer and then to monitor the progress of that transfer. This     *
- * register needs to be initialized before a transfer is started. A     *
- * legitimate write to this register will set the Busy bit, clear the   *
- * Error bit, and initialize the length to the value desired.           *
- * While the transfer is in progress, hardware will decrement the       *
- * length field with each successful block that is copied. Once the     *
- * transfer completes, hardware will clear the Busy bit. The length     *
- * field will also contain the number of cache lines left to be         *
- * transferred.                                                         *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibls0_u {
-	shubreg_t	ii_ibls0_regval;
-	struct	{
-		shubreg_t	i_length		  :	16;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t	i_busy			  :	 1;
-		shubreg_t       i_rsvd                    :     43;
-	} ii_ibls0_fld_s;
-} ii_ibls0_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register should be loaded before a transfer is started. The    *
- * address to be loaded in bits 39:0 is the 40-bit TRex+ physical       *
- * address as described in Section 1.3, Figure2 and Figure3. Since      *
- * the bottom 7 bits of the address are always taken to be zero, BTE    *
- * transfers are always cacheline-aligned.                              *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibsa0_u {
-	shubreg_t	ii_ibsa0_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 7;
-		shubreg_t	i_addr			  :	42;
-		shubreg_t       i_rsvd                    :     15;
-	} ii_ibsa0_fld_s;
-} ii_ibsa0_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register should be loaded before a transfer is started. The    *
- * address to be loaded in bits 39:0 is the 40-bit TRex+ physical       *
- * address as described in Section 1.3, Figure2 and Figure3. Since      *
- * the bottom 7 bits of the address are always taken to be zero, BTE    *
- * transfers are always cacheline-aligned.                              *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibda0_u {
-	shubreg_t	ii_ibda0_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 7;
-		shubreg_t	i_addr			  :	42;
-		shubreg_t	i_rsvd			  :	15;
-	} ii_ibda0_fld_s;
-} ii_ibda0_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  Writing to this register sets up the attributes of the transfer     *
- * and initiates the transfer operation. Reading this register has      *
- * the side effect of terminating any transfer in progress. Note:       *
- * stopping a transfer midstream could have an adverse impact on the    *
- * other BTE. If a BTE stream has to be stopped (due to error           *
- * handling for example), both BTE streams should be stopped and        *
- * their transfers discarded.                                           *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibct0_u {
-	shubreg_t	ii_ibct0_regval;
-	struct  {
-		shubreg_t	i_zerofill                :	 1;
-		shubreg_t	i_rsvd_2		  :	 3;
-		shubreg_t	i_notify		  :	 1;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t       i_poison                  :      1;
-		shubreg_t       i_rsvd                    :     55;
-	} ii_ibct0_fld_s;
-} ii_ibct0_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the address to which the WINV is sent.       *
- * This address has to be cache line aligned.                           *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibna0_u {
-	shubreg_t	ii_ibna0_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 7;
-		shubreg_t	i_addr			  :	42;
-		shubreg_t	i_rsvd			  :	15;
-	} ii_ibna0_fld_s;
-} ii_ibna0_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the programmable level as well as the node   *
- * ID and PI unit of the processor to which the interrupt will be       *
- * sent.                                                                *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibia0_u {
-	shubreg_t	ii_ibia0_regval;
-	struct  {
-		shubreg_t	i_rsvd_2                   :	 1;
-		shubreg_t	i_node_id		  :	11;
-		shubreg_t	i_rsvd_1		  :	 4;
-		shubreg_t	i_level			  :	 7;
-		shubreg_t       i_rsvd                    :     41;
-	} ii_ibia0_fld_s;
-} ii_ibia0_u_t;
-
-
-/************************************************************************
- *                                                                      *
- * Description:  This register is used to set up the length for a       *
- * transfer and then to monitor the progress of that transfer. This     *
- * register needs to be initialized before a transfer is started. A     *
- * legitimate write to this register will set the Busy bit, clear the   *
- * Error bit, and initialize the length to the value desired.           *
- * While the transfer is in progress, hardware will decrement the       *
- * length field with each successful block that is copied. Once the     *
- * transfer completes, hardware will clear the Busy bit. The length     *
- * field will also contain the number of cache lines left to be         *
- * transferred.                                                         *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibls1_u {
-	shubreg_t	ii_ibls1_regval;
-	struct  {
-		shubreg_t	i_length                  :	16;
-		shubreg_t	i_error			  :	 1;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t	i_busy			  :	 1;
-		shubreg_t       i_rsvd                    :     43;
-	} ii_ibls1_fld_s;
-} ii_ibls1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register should be loaded before a transfer is started. The    *
- * address to be loaded in bits 39:0 is the 40-bit TRex+ physical       *
- * address as described in Section 1.3, Figure2 and Figure3. Since      *
- * the bottom 7 bits of the address are always taken to be zero, BTE    *
- * transfers are always cacheline-aligned.                              *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibsa1_u {
-	shubreg_t	ii_ibsa1_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 7;
-		shubreg_t	i_addr			  :	33;
-		shubreg_t	i_rsvd			  :	24;
-	} ii_ibsa1_fld_s;
-} ii_ibsa1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register should be loaded before a transfer is started. The    *
- * address to be loaded in bits 39:0 is the 40-bit TRex+ physical       *
- * address as described in Section 1.3, Figure2 and Figure3. Since      *
- * the bottom 7 bits of the address are always taken to be zero, BTE    *
- * transfers are always cacheline-aligned.                              *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibda1_u {
-	shubreg_t	ii_ibda1_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 7;
-		shubreg_t	i_addr			  :	33;
-		shubreg_t	i_rsvd			  :	24;
-	} ii_ibda1_fld_s;
-} ii_ibda1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  Writing to this register sets up the attributes of the transfer     *
- * and initiates the transfer operation. Reading this register has      *
- * the side effect of terminating any transfer in progress. Note:       *
- * stopping a transfer midstream could have an adverse impact on the    *
- * other BTE. If a BTE stream has to be stopped (due to error           *
- * handling for example), both BTE streams should be stopped and        *
- * their transfers discarded.                                           *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibct1_u {
-	shubreg_t	ii_ibct1_regval;
-	struct  {
-		shubreg_t	i_zerofill                :	 1;
-		shubreg_t	i_rsvd_2		  :	 3;
-		shubreg_t	i_notify		  :	 1;
-		shubreg_t	i_rsvd_1		  :	 3;
-		shubreg_t	i_poison		  :	 1;
-		shubreg_t	i_rsvd			  :	55;
-	} ii_ibct1_fld_s;
-} ii_ibct1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the address to which the WINV is sent.       *
- * This address has to be cache line aligned.                           *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibna1_u {
-	shubreg_t	ii_ibna1_regval;
-	struct  {
-		shubreg_t	i_rsvd_1                  :	 7;
-		shubreg_t	i_addr			  :	33;
-		shubreg_t       i_rsvd                    :     24;
-	} ii_ibna1_fld_s;
-} ii_ibna1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register contains the programmable level as well as the node   *
- * ID and PI unit of the processor to which the interrupt will be       *
- * sent.                                                                *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ibia1_u {
-	shubreg_t	ii_ibia1_regval;
-	struct  {
-		shubreg_t	i_pi_id                   :	 1;
-		shubreg_t	i_node_id		  :	 8;
-		shubreg_t	i_rsvd_1		  :	 7;
-		shubreg_t	i_level			  :	 7;
-		shubreg_t	i_rsvd			  :	41;
-	} ii_ibia1_fld_s;
-} ii_ibia1_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *  This register defines the resources that feed information into      *
- * the two performance counters located in the IO Performance           *
- * Profiling Register. There are 17 different quantities that can be    *
- * measured. Given these 17 different options, the two performance      *
- * counters have 15 of them in common; menu selections 0 through 0xE    *
- * are identical for each performance counter. As for the other two     *
- * options, one is available from one performance counter and the       *
- * other is available from the other performance counter. Hence, the    *
- * II supports all 17*16=272 possible combinations of quantities to     *
- * measure.                                                             *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ipcr_u {
-	shubreg_t	ii_ipcr_regval;
-	struct  {
-		shubreg_t	i_ippr0_c                 :	 4;
-		shubreg_t	i_ippr1_c		  :	 4;
-		shubreg_t	i_icct			  :	 8;
-		shubreg_t       i_rsvd                    :     48;
-	} ii_ipcr_fld_s;
-} ii_ipcr_u_t;
-
-
-/************************************************************************
- *                                                                      *
- *                                                                      *
- *                                                                      *
- ************************************************************************/
-
-typedef union ii_ippr_u {
-	shubreg_t	ii_ippr_regval;
-	struct  {
-		shubreg_t	i_ippr0                   :	32;
-		shubreg_t	i_ippr1			  :	32;
-	} ii_ippr_fld_s;
-} ii_ippr_u_t;
-
-
-/**************************************************************************
- *                                                                        *
- * The following defines which were not formed into structures are        *
- * probably indentical to another register, and the name of the           *
- * register is provided against each of these registers. This             *
- * information needs to be checked carefully                              *
- *                                                                        *
- *           IIO_ICRB1_A                IIO_ICRB0_A                       *
- *           IIO_ICRB1_B                IIO_ICRB0_B                       *
- *           IIO_ICRB1_C                IIO_ICRB0_C                       *
- *           IIO_ICRB1_D                IIO_ICRB0_D                       *
- *           IIO_ICRB1_E                IIO_ICRB0_E                       *
- *           IIO_ICRB2_A                IIO_ICRB0_A                       *
- *           IIO_ICRB2_B                IIO_ICRB0_B                       *
- *           IIO_ICRB2_C                IIO_ICRB0_C                       *
- *           IIO_ICRB2_D                IIO_ICRB0_D                       *
- *           IIO_ICRB2_E                IIO_ICRB0_E                       *
- *           IIO_ICRB3_A                IIO_ICRB0_A                       *
- *           IIO_ICRB3_B                IIO_ICRB0_B                       *
- *           IIO_ICRB3_C                IIO_ICRB0_C                       *
- *           IIO_ICRB3_D                IIO_ICRB0_D                       *
- *           IIO_ICRB3_E                IIO_ICRB0_E                       *
- *           IIO_ICRB4_A                IIO_ICRB0_A                       *
- *           IIO_ICRB4_B                IIO_ICRB0_B                       *
- *           IIO_ICRB4_C                IIO_ICRB0_C                       *
- *           IIO_ICRB4_D                IIO_ICRB0_D                       *
- *           IIO_ICRB4_E                IIO_ICRB0_E                       *
- *           IIO_ICRB5_A                IIO_ICRB0_A                       *
- *           IIO_ICRB5_B                IIO_ICRB0_B                       *
- *           IIO_ICRB5_C                IIO_ICRB0_C                       *
- *           IIO_ICRB5_D                IIO_ICRB0_D                       *
- *           IIO_ICRB5_E                IIO_ICRB0_E                       *
- *           IIO_ICRB6_A                IIO_ICRB0_A                       *
- *           IIO_ICRB6_B                IIO_ICRB0_B                       *
- *           IIO_ICRB6_C                IIO_ICRB0_C                       *
- *           IIO_ICRB6_D                IIO_ICRB0_D                       *
- *           IIO_ICRB6_E                IIO_ICRB0_E                       *
- *           IIO_ICRB7_A                IIO_ICRB0_A                       *
- *           IIO_ICRB7_B                IIO_ICRB0_B                       *
- *           IIO_ICRB7_C                IIO_ICRB0_C                       *
- *           IIO_ICRB7_D                IIO_ICRB0_D                       *
- *           IIO_ICRB7_E                IIO_ICRB0_E                       *
- *           IIO_ICRB8_A                IIO_ICRB0_A                       *
- *           IIO_ICRB8_B                IIO_ICRB0_B                       *
- *           IIO_ICRB8_C                IIO_ICRB0_C                       *
- *           IIO_ICRB8_D                IIO_ICRB0_D                       *
- *           IIO_ICRB8_E                IIO_ICRB0_E                       *
- *           IIO_ICRB9_A                IIO_ICRB0_A                       *
- *           IIO_ICRB9_B                IIO_ICRB0_B                       *
- *           IIO_ICRB9_C                IIO_ICRB0_C                       *
- *           IIO_ICRB9_D                IIO_ICRB0_D                       *
- *           IIO_ICRB9_E                IIO_ICRB0_E                       *
- *           IIO_ICRBA_A                IIO_ICRB0_A                       *
- *           IIO_ICRBA_B                IIO_ICRB0_B                       *
- *           IIO_ICRBA_C                IIO_ICRB0_C                       *
- *           IIO_ICRBA_D                IIO_ICRB0_D                       *
- *           IIO_ICRBA_E                IIO_ICRB0_E                       *
- *           IIO_ICRBB_A                IIO_ICRB0_A                       *
- *           IIO_ICRBB_B                IIO_ICRB0_B                       *
- *           IIO_ICRBB_C                IIO_ICRB0_C                       *
- *           IIO_ICRBB_D                IIO_ICRB0_D                       *
- *           IIO_ICRBB_E                IIO_ICRB0_E                       *
- *           IIO_ICRBC_A                IIO_ICRB0_A                       *
- *           IIO_ICRBC_B                IIO_ICRB0_B                       *
- *           IIO_ICRBC_C                IIO_ICRB0_C                       *
- *           IIO_ICRBC_D                IIO_ICRB0_D                       *
- *           IIO_ICRBC_E                IIO_ICRB0_E                       *
- *           IIO_ICRBD_A                IIO_ICRB0_A                       *
- *           IIO_ICRBD_B                IIO_ICRB0_B                       *
- *           IIO_ICRBD_C                IIO_ICRB0_C                       *
- *           IIO_ICRBD_D                IIO_ICRB0_D                       *
- *           IIO_ICRBD_E                IIO_ICRB0_E                       *
- *           IIO_ICRBE_A                IIO_ICRB0_A                       *
- *           IIO_ICRBE_B                IIO_ICRB0_B                       *
- *           IIO_ICRBE_C                IIO_ICRB0_C                       *
- *           IIO_ICRBE_D                IIO_ICRB0_D                       *
- *           IIO_ICRBE_E                IIO_ICRB0_E                       *
- *                                                                        *
- **************************************************************************/
-
-
-/*
- * Slightly friendlier names for some common registers.
- */
-#define IIO_WIDGET              IIO_WID      /* Widget identification */
-#define IIO_WIDGET_STAT         IIO_WSTAT    /* Widget status register */
-#define IIO_WIDGET_CTRL         IIO_WCR      /* Widget control register */
-#define IIO_PROTECT             IIO_ILAPR    /* IO interface protection */
-#define IIO_PROTECT_OVRRD       IIO_ILAPO    /* IO protect override */
-#define IIO_OUTWIDGET_ACCESS    IIO_IOWA     /* Outbound widget access */
-#define IIO_INWIDGET_ACCESS     IIO_IIWA     /* Inbound widget access */
-#define IIO_INDEV_ERR_MASK      IIO_IIDEM    /* Inbound device error mask */
-#define IIO_LLP_CSR             IIO_ILCSR    /* LLP control and status */
-#define IIO_LLP_LOG             IIO_ILLR     /* LLP log */
-#define IIO_XTALKCC_TOUT        IIO_IXCC     /* Xtalk credit count timeout*/
-#define IIO_XTALKTT_TOUT        IIO_IXTT     /* Xtalk tail timeout */
-#define IIO_IO_ERR_CLR          IIO_IECLR    /* IO error clear */
-#define IIO_IGFX_0 		IIO_IGFX0
-#define IIO_IGFX_1 		IIO_IGFX1
-#define IIO_IBCT_0		IIO_IBCT0
-#define IIO_IBCT_1		IIO_IBCT1
-#define IIO_IBLS_0		IIO_IBLS0
-#define IIO_IBLS_1		IIO_IBLS1
-#define IIO_IBSA_0		IIO_IBSA0
-#define IIO_IBSA_1		IIO_IBSA1
-#define IIO_IBDA_0		IIO_IBDA0
-#define IIO_IBDA_1		IIO_IBDA1
-#define IIO_IBNA_0		IIO_IBNA0
-#define IIO_IBNA_1		IIO_IBNA1
-#define IIO_IBIA_0		IIO_IBIA0
-#define IIO_IBIA_1		IIO_IBIA1
-#define IIO_IOPRB_0		IIO_IPRB0
-
-#define IIO_PRTE_A(_x)		(IIO_IPRTE0_A + (8 * (_x)))
-#define IIO_PRTE_B(_x)		(IIO_IPRTE0_B + (8 * (_x)))
-#define IIO_NUM_PRTES		8	/* Total number of PRB table entries */
-#define IIO_WIDPRTE_A(x)	IIO_PRTE_A(((x) - 8)) /* widget ID to its PRTE num */
-#define IIO_WIDPRTE_B(x)	IIO_PRTE_B(((x) - 8)) /* widget ID to its PRTE num */
-
-#define IIO_NUM_IPRBS 		(9) 
-
-#define IIO_LLP_CSR_IS_UP               0x00002000
-#define IIO_LLP_CSR_LLP_STAT_MASK       0x00003000
-#define IIO_LLP_CSR_LLP_STAT_SHFT       12
-
-#define IIO_LLP_CB_MAX  0xffff	/* in ILLR CB_CNT, Max Check Bit errors */
-#define IIO_LLP_SN_MAX  0xffff	/* in ILLR SN_CNT, Max Sequence Number errors */
-
-/* key to IIO_PROTECT_OVRRD */
-#define IIO_PROTECT_OVRRD_KEY   0x53474972756c6573ull   /* "SGIrules" */
-
-/* BTE register names */
-#define IIO_BTE_STAT_0          IIO_IBLS_0   /* Also BTE length/status 0 */
-#define IIO_BTE_SRC_0           IIO_IBSA_0   /* Also BTE source address  0 */
-#define IIO_BTE_DEST_0          IIO_IBDA_0   /* Also BTE dest. address 0 */
-#define IIO_BTE_CTRL_0          IIO_IBCT_0   /* Also BTE control/terminate 0 */
-#define IIO_BTE_NOTIFY_0        IIO_IBNA_0   /* Also BTE notification 0 */
-#define IIO_BTE_INT_0           IIO_IBIA_0   /* Also BTE interrupt 0 */
-#define IIO_BTE_OFF_0           0            /* Base offset from BTE 0 regs. */
-#define IIO_BTE_OFF_1   	(IIO_IBLS_1 - IIO_IBLS_0) /* Offset from base to BTE 1 */
-
-/* BTE register offsets from base */
-#define BTEOFF_STAT             0
-#define BTEOFF_SRC              (IIO_BTE_SRC_0 - IIO_BTE_STAT_0)
-#define BTEOFF_DEST             (IIO_BTE_DEST_0 - IIO_BTE_STAT_0)
-#define BTEOFF_CTRL             (IIO_BTE_CTRL_0 - IIO_BTE_STAT_0)
-#define BTEOFF_NOTIFY           (IIO_BTE_NOTIFY_0 - IIO_BTE_STAT_0)
-#define BTEOFF_INT              (IIO_BTE_INT_0 - IIO_BTE_STAT_0)
-
-
-/* names used in shub diags */
-#define IIO_BASE_BTE0   IIO_IBLS_0		
-#define IIO_BASE_BTE1   IIO_IBLS_1		
-
-/*
- * Macro which takes the widget number, and returns the
- * IO PRB address of that widget.
- * value _x is expected to be a widget number in the range
- * 0, 8 - 0xF
- */
-#define IIO_IOPRB(_x)   (IIO_IOPRB_0 + ( ( (_x) < HUB_WIDGET_ID_MIN ? \
-                        (_x) : \
-                        (_x) - (HUB_WIDGET_ID_MIN-1)) << 3) )
-
-
-/* GFX Flow Control Node/Widget Register */
-#define IIO_IGFX_W_NUM_BITS	4	/* size of widget num field */
-#define IIO_IGFX_W_NUM_MASK	((1<<IIO_IGFX_W_NUM_BITS)-1)
-#define IIO_IGFX_W_NUM_SHIFT	0
-#define IIO_IGFX_PI_NUM_BITS	1	/* size of PI num field */
-#define IIO_IGFX_PI_NUM_MASK	((1<<IIO_IGFX_PI_NUM_BITS)-1)
-#define IIO_IGFX_PI_NUM_SHIFT	4
-#define IIO_IGFX_N_NUM_BITS	8	/* size of node num field */
-#define IIO_IGFX_N_NUM_MASK	((1<<IIO_IGFX_N_NUM_BITS)-1)
-#define IIO_IGFX_N_NUM_SHIFT	5
-#define IIO_IGFX_P_NUM_BITS	1	/* size of processor num field */
-#define IIO_IGFX_P_NUM_MASK	((1<<IIO_IGFX_P_NUM_BITS)-1)
-#define IIO_IGFX_P_NUM_SHIFT	16
-#define IIO_IGFX_INIT(widget, pi, node, cpu)				(\
-	(((widget) & IIO_IGFX_W_NUM_MASK) << IIO_IGFX_W_NUM_SHIFT) |	 \
-	(((pi)     & IIO_IGFX_PI_NUM_MASK)<< IIO_IGFX_PI_NUM_SHIFT)|	 \
-	(((node)   & IIO_IGFX_N_NUM_MASK) << IIO_IGFX_N_NUM_SHIFT) |	 \
-	(((cpu)    & IIO_IGFX_P_NUM_MASK) << IIO_IGFX_P_NUM_SHIFT))
-
-
-/* Scratch registers (all bits available) */
-#define IIO_SCRATCH_REG0        IIO_ISCR0
-#define IIO_SCRATCH_REG1        IIO_ISCR1
-#define IIO_SCRATCH_MASK        0xffffffffffffffffUL
-
-#define IIO_SCRATCH_BIT0_0      0x0000000000000001UL
-#define IIO_SCRATCH_BIT0_1      0x0000000000000002UL
-#define IIO_SCRATCH_BIT0_2      0x0000000000000004UL
-#define IIO_SCRATCH_BIT0_3      0x0000000000000008UL
-#define IIO_SCRATCH_BIT0_4      0x0000000000000010UL
-#define IIO_SCRATCH_BIT0_5      0x0000000000000020UL
-#define IIO_SCRATCH_BIT0_6      0x0000000000000040UL
-#define IIO_SCRATCH_BIT0_7      0x0000000000000080UL
-#define IIO_SCRATCH_BIT0_8      0x0000000000000100UL
-#define IIO_SCRATCH_BIT0_9      0x0000000000000200UL
-#define IIO_SCRATCH_BIT0_A      0x0000000000000400UL
-
-#define IIO_SCRATCH_BIT1_0      0x0000000000000001UL
-#define IIO_SCRATCH_BIT1_1      0x0000000000000002UL
-/* IO Translation Table Entries */
-#define IIO_NUM_ITTES   7               /* ITTEs numbered 0..6 */
-                                        /* Hw manuals number them 1..7! */
-/*
- * IIO_IMEM Register fields.
- */
-#define IIO_IMEM_W0ESD  0x1UL             /* Widget 0 shut down due to error */
-#define IIO_IMEM_B0ESD  (1UL << 4)        /* BTE 0 shut down due to error */
-#define IIO_IMEM_B1ESD  (1UL << 8)        /* BTE 1 Shut down due to error */
-
-/*
- * As a permanent workaround for a bug in the PI side of the shub, we've
- * redefined big window 7 as small window 0.
- XXX does this still apply for SN1??
- */
-#define HUB_NUM_BIG_WINDOW      (IIO_NUM_ITTES - 1)
-
-/*
- * Use the top big window as a surrogate for the first small window
- */
-#define SWIN0_BIGWIN            HUB_NUM_BIG_WINDOW
-
-#define ILCSR_WARM_RESET        0x100
-
-/*
- * CRB manipulation macros
- *      The CRB macros are slightly complicated, since there are up to
- *      four registers associated with each CRB entry.
- */
-#define IIO_NUM_CRBS            15      /* Number of CRBs */
-#define IIO_NUM_PC_CRBS         4       /* Number of partial cache CRBs */
-#define IIO_ICRB_OFFSET         8
-#define IIO_ICRB_0              IIO_ICRB0_A
-#define IIO_ICRB_ADDR_SHFT	2	/* Shift to get proper address */
-/* XXX - This is now tuneable:
-        #define IIO_FIRST_PC_ENTRY 12
- */
-
-#define IIO_ICRB_A(_x)  ((u64)(IIO_ICRB_0 + (6 * IIO_ICRB_OFFSET * (_x))))
-#define IIO_ICRB_B(_x)  ((u64)((char *)IIO_ICRB_A(_x) + 1*IIO_ICRB_OFFSET))
-#define IIO_ICRB_C(_x)  ((u64)((char *)IIO_ICRB_A(_x) + 2*IIO_ICRB_OFFSET))
-#define IIO_ICRB_D(_x)  ((u64)((char *)IIO_ICRB_A(_x) + 3*IIO_ICRB_OFFSET))
-#define IIO_ICRB_E(_x)  ((u64)((char *)IIO_ICRB_A(_x) + 4*IIO_ICRB_OFFSET))
-
-#define TNUM_TO_WIDGET_DEV(_tnum)	(_tnum & 0x7)
-
-/*
- * values for "ecode" field
- */
-#define IIO_ICRB_ECODE_DERR     0       /* Directory error due to IIO access */
-#define IIO_ICRB_ECODE_PERR     1       /* Poison error on IO access */
-#define IIO_ICRB_ECODE_WERR     2       /* Write error by IIO access
-                                         * e.g. WINV to a Read only line. */
-#define IIO_ICRB_ECODE_AERR     3       /* Access error caused by IIO access */
-#define IIO_ICRB_ECODE_PWERR    4       /* Error on partial write       */
-#define IIO_ICRB_ECODE_PRERR    5       /* Error on partial read        */
-#define IIO_ICRB_ECODE_TOUT     6       /* CRB timeout before deallocating */
-#define IIO_ICRB_ECODE_XTERR    7       /* Incoming xtalk pkt had error bit */
-
-/*
- * Values for field imsgtype
- */
-#define IIO_ICRB_IMSGT_XTALK    0       /* Incoming Meessage from Xtalk */
-#define IIO_ICRB_IMSGT_BTE      1       /* Incoming message from BTE    */
-#define IIO_ICRB_IMSGT_SN1NET   2       /* Incoming message from SN1 net */
-#define IIO_ICRB_IMSGT_CRB      3       /* Incoming message from CRB ???  */
-
-/*
- * values for field initiator.
- */
-#define IIO_ICRB_INIT_XTALK     0       /* Message originated in xtalk  */
-#define IIO_ICRB_INIT_BTE0      0x1     /* Message originated in BTE 0  */
-#define IIO_ICRB_INIT_SN1NET    0x2     /* Message originated in SN1net */
-#define IIO_ICRB_INIT_CRB       0x3     /* Message originated in CRB ?  */
-#define IIO_ICRB_INIT_BTE1      0x5     /* MEssage originated in BTE 1  */
-
-/*
- * Number of credits Hub widget has while sending req/response to
- * xbow.
- * Value of 3 is required by Xbow 1.1
- * We may be able to increase this to 4 with Xbow 1.2.
- */
-#define       HUBII_XBOW_CREDIT       3
-#define       HUBII_XBOW_REV2_CREDIT  4
-
-/*
- * Number of credits that xtalk devices should use when communicating
- * with a SHub (depth of SHub's queue).
- */
-#define HUB_CREDIT 4
-
-/*
- * Some IIO_PRB fields
- */
-#define IIO_PRB_MULTI_ERR	(1LL << 63)
-#define IIO_PRB_SPUR_RD		(1LL << 51)
-#define IIO_PRB_SPUR_WR		(1LL << 50)
-#define IIO_PRB_RD_TO		(1LL << 49)
-#define IIO_PRB_ERROR		(1LL << 48)
-
-/*************************************************************************
-
- Some of the IIO field masks and shifts are defined here.
- This is in order to maintain compatibility in SN0 and SN1 code
- 
-**************************************************************************/
-
-/*
- * ICMR register fields
- * (Note: the IIO_ICMR_P_CNT and IIO_ICMR_PC_VLD from Hub are not
- * present in SHub)
- */
-
-#define IIO_ICMR_CRB_VLD_SHFT   20
-#define IIO_ICMR_CRB_VLD_MASK   (0x7fffUL << IIO_ICMR_CRB_VLD_SHFT)
-
-#define IIO_ICMR_FC_CNT_SHFT    16
-#define IIO_ICMR_FC_CNT_MASK    (0xf << IIO_ICMR_FC_CNT_SHFT)
-
-#define IIO_ICMR_C_CNT_SHFT     4
-#define IIO_ICMR_C_CNT_MASK     (0xf << IIO_ICMR_C_CNT_SHFT)
-
-#define IIO_ICMR_PRECISE        (1UL << 52)
-#define IIO_ICMR_CLR_RPPD       (1UL << 13)
-#define IIO_ICMR_CLR_RQPD       (1UL << 12)
-
-/*
- * IIO PIO Deallocation register field masks : (IIO_IPDR)
- XXX present but not needed in bedrock?  See the manual.
- */
-#define IIO_IPDR_PND    (1 << 4)
-
-/*
- * IIO CRB deallocation register field masks: (IIO_ICDR)
- */
-#define IIO_ICDR_PND    (1 << 4)
-
-/* 
- * IO BTE Length/Status (IIO_IBLS) register bit field definitions
- */
-#define IBLS_BUSY		(0x1UL << 20)
-#define IBLS_ERROR_SHFT		16
-#define IBLS_ERROR		(0x1UL << IBLS_ERROR_SHFT)
-#define IBLS_LENGTH_MASK	0xffff
-
-/*
- * IO BTE Control/Terminate register (IBCT) register bit field definitions
- */
-#define IBCT_POISON		(0x1UL << 8)
-#define IBCT_NOTIFY		(0x1UL << 4)
-#define IBCT_ZFIL_MODE		(0x1UL << 0)
-
-/*
- * IIO Incoming Error Packet Header (IIO_IIEPH1/IIO_IIEPH2)
- */
-#define IIEPH1_VALID		(1UL << 44)
-#define IIEPH1_OVERRUN		(1UL << 40)
-#define IIEPH1_ERR_TYPE_SHFT	32
-#define IIEPH1_ERR_TYPE_MASK	0xf
-#define IIEPH1_SOURCE_SHFT	20
-#define IIEPH1_SOURCE_MASK	11
-#define IIEPH1_SUPPL_SHFT	8
-#define IIEPH1_SUPPL_MASK	11
-#define IIEPH1_CMD_SHFT		0
-#define IIEPH1_CMD_MASK		7
-
-#define IIEPH2_TAIL		(1UL << 40)
-#define IIEPH2_ADDRESS_SHFT	0
-#define IIEPH2_ADDRESS_MASK	38
-
-#define IIEPH1_ERR_SHORT_REQ	2
-#define IIEPH1_ERR_SHORT_REPLY	3
-#define IIEPH1_ERR_LONG_REQ	4
-#define IIEPH1_ERR_LONG_REPLY	5
-
-/*
- * IO Error Clear register bit field definitions
- */
-#define IECLR_PI1_FWD_INT	(1UL << 31)  /* clear PI1_FORWARD_INT in iidsr */
-#define IECLR_PI0_FWD_INT	(1UL << 30)  /* clear PI0_FORWARD_INT in iidsr */
-#define IECLR_SPUR_RD_HDR	(1UL << 29)  /* clear valid bit in ixss reg */
-#define IECLR_BTE1		(1UL << 18)  /* clear bte error 1 */
-#define IECLR_BTE0		(1UL << 17)  /* clear bte error 0 */
-#define IECLR_CRAZY		(1UL << 16)  /* clear crazy bit in wstat reg */
-#define IECLR_PRB_F		(1UL << 15)  /* clear err bit in PRB_F reg */
-#define IECLR_PRB_E		(1UL << 14)  /* clear err bit in PRB_E reg */
-#define IECLR_PRB_D		(1UL << 13)  /* clear err bit in PRB_D reg */
-#define IECLR_PRB_C		(1UL << 12)  /* clear err bit in PRB_C reg */
-#define IECLR_PRB_B		(1UL << 11)  /* clear err bit in PRB_B reg */
-#define IECLR_PRB_A		(1UL << 10)  /* clear err bit in PRB_A reg */
-#define IECLR_PRB_9		(1UL << 9)   /* clear err bit in PRB_9 reg */
-#define IECLR_PRB_8		(1UL << 8)   /* clear err bit in PRB_8 reg */
-#define IECLR_PRB_0		(1UL << 0)   /* clear err bit in PRB_0 reg */
-
-/*
- * IIO CRB control register Fields: IIO_ICCR 
- */
-#define	IIO_ICCR_PENDING	(0x10000)
-#define	IIO_ICCR_CMD_MASK	(0xFF)
-#define	IIO_ICCR_CMD_SHFT	(7)
-#define	IIO_ICCR_CMD_NOP	(0x0)	/* No Op */
-#define	IIO_ICCR_CMD_WAKE	(0x100) /* Reactivate CRB entry and process */
-#define	IIO_ICCR_CMD_TIMEOUT	(0x200)	/* Make CRB timeout & mark invalid */
-#define	IIO_ICCR_CMD_EJECT	(0x400)	/* Contents of entry written to memory 
-					 * via a WB
-					 */
-#define	IIO_ICCR_CMD_FLUSH	(0x800)
-
-/*
- *
- * CRB Register description.
- *
- * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
- * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
- * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
- * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
- * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
- *
- * Many of the fields in CRB are status bits used by hardware
- * for implementation of the protocol. It's very dangerous to
- * mess around with the CRB registers.
- *
- * It's OK to read the CRB registers and try to make sense out of the
- * fields in CRB.
- *
- * Updating CRB requires all activities in Hub IIO to be quiesced.
- * otherwise, a write to CRB could corrupt other CRB entries.
- * CRBs are here only as a back door peek to shub IIO's status.
- * Quiescing implies  no dmas no PIOs
- * either directly from the cpu or from sn0net.
- * this is not something that can be done easily. So, AVOID updating
- * CRBs.
- */
-
-#ifndef __ASSEMBLY__
-
-/*
- * Easy access macros for CRBs, all 5 registers (A-E)
- */
-typedef ii_icrb0_a_u_t icrba_t;
-#define a_sidn          ii_icrb0_a_fld_s.ia_sidn
-#define a_tnum          ii_icrb0_a_fld_s.ia_tnum
-#define a_addr          ii_icrb0_a_fld_s.ia_addr
-#define a_valid         ii_icrb0_a_fld_s.ia_vld
-#define a_iow           ii_icrb0_a_fld_s.ia_iow
-#define a_regvalue	ii_icrb0_a_regval
-
-typedef ii_icrb0_b_u_t icrbb_t;
-#define b_use_old       ii_icrb0_b_fld_s.ib_use_old
-#define b_imsgtype      ii_icrb0_b_fld_s.ib_imsgtype
-#define b_imsg          ii_icrb0_b_fld_s.ib_imsg
-#define b_initiator     ii_icrb0_b_fld_s.ib_init
-#define b_exc           ii_icrb0_b_fld_s.ib_exc
-#define b_ackcnt        ii_icrb0_b_fld_s.ib_ack_cnt
-#define b_resp          ii_icrb0_b_fld_s.ib_resp
-#define b_ack           ii_icrb0_b_fld_s.ib_ack
-#define b_hold          ii_icrb0_b_fld_s.ib_hold
-#define b_wb            ii_icrb0_b_fld_s.ib_wb
-#define b_intvn         ii_icrb0_b_fld_s.ib_intvn
-#define b_stall_ib      ii_icrb0_b_fld_s.ib_stall_ib
-#define b_stall_int     ii_icrb0_b_fld_s.ib_stall__intr
-#define b_stall_bte_0   ii_icrb0_b_fld_s.ib_stall__bte_0
-#define b_stall_bte_1   ii_icrb0_b_fld_s.ib_stall__bte_1
-#define b_error         ii_icrb0_b_fld_s.ib_error
-#define b_ecode         ii_icrb0_b_fld_s.ib_errcode
-#define b_lnetuce       ii_icrb0_b_fld_s.ib_ln_uce
-#define b_mark          ii_icrb0_b_fld_s.ib_mark
-#define b_xerr          ii_icrb0_b_fld_s.ib_xt_err
-#define b_regvalue	ii_icrb0_b_regval
-
-typedef ii_icrb0_c_u_t icrbc_t;
-#define c_suppl         ii_icrb0_c_fld_s.ic_suppl
-#define c_barrop        ii_icrb0_c_fld_s.ic_bo
-#define c_doresp        ii_icrb0_c_fld_s.ic_resprqd
-#define c_gbr           ii_icrb0_c_fld_s.ic_gbr
-#define c_btenum        ii_icrb0_c_fld_s.ic_bte_num
-#define c_cohtrans      ii_icrb0_c_fld_s.ic_ct
-#define c_xtsize        ii_icrb0_c_fld_s.ic_size
-#define c_source        ii_icrb0_c_fld_s.ic_source
-#define c_regvalue	ii_icrb0_c_regval
-
-
-typedef ii_icrb0_d_u_t icrbd_t;
-#define d_sleep         ii_icrb0_d_fld_s.id_sleep
-#define d_pricnt        ii_icrb0_d_fld_s.id_pr_cnt
-#define d_pripsc        ii_icrb0_d_fld_s.id_pr_psc
-#define d_bteop         ii_icrb0_d_fld_s.id_bte_op
-#define d_bteaddr       ii_icrb0_d_fld_s.id_pa_be /* ic_pa_be fld has 2 names*/
-#define d_benable       ii_icrb0_d_fld_s.id_pa_be /* ic_pa_be fld has 2 names*/
-#define d_regvalue	ii_icrb0_d_regval
-
-typedef ii_icrb0_e_u_t icrbe_t;
-#define icrbe_ctxtvld   ii_icrb0_e_fld_s.ie_cvld
-#define icrbe_toutvld   ii_icrb0_e_fld_s.ie_tvld
-#define icrbe_context   ii_icrb0_e_fld_s.ie_context
-#define icrbe_timeout   ii_icrb0_e_fld_s.ie_timeout
-#define e_regvalue	ii_icrb0_e_regval
-
-#endif /* __ASSEMBLY__ */
-
-/* Number of widgets supported by shub */
-#define HUB_NUM_WIDGET          9
-#define HUB_WIDGET_ID_MIN       0x8
-#define HUB_WIDGET_ID_MAX       0xf
-
-#define HUB_WIDGET_PART_NUM     0xc120
-#define MAX_HUBS_PER_XBOW       2
-
-#ifndef __ASSEMBLY__
-/* A few more #defines for backwards compatibility */
-#define iprb_t          ii_iprb0_u_t
-#define iprb_regval     ii_iprb0_regval
-#define iprb_mult_err	ii_iprb0_fld_s.i_mult_err
-#define iprb_spur_rd	ii_iprb0_fld_s.i_spur_rd
-#define iprb_spur_wr	ii_iprb0_fld_s.i_spur_wr
-#define iprb_rd_to	ii_iprb0_fld_s.i_rd_to
-#define iprb_ovflow     ii_iprb0_fld_s.i_of_cnt
-#define iprb_error      ii_iprb0_fld_s.i_error
-#define iprb_ff         ii_iprb0_fld_s.i_f
-#define iprb_mode       ii_iprb0_fld_s.i_m
-#define iprb_bnakctr    ii_iprb0_fld_s.i_nb
-#define iprb_anakctr    ii_iprb0_fld_s.i_na
-#define iprb_xtalkctr   ii_iprb0_fld_s.i_c
-#endif
-
-#define LNK_STAT_WORKING        0x2		/* LLP is working */
-
-#define IIO_WSTAT_ECRAZY        (1ULL << 32)    /* Hub gone crazy */
-#define IIO_WSTAT_TXRETRY       (1ULL << 9)     /* Hub Tx Retry timeout */
-#define IIO_WSTAT_TXRETRY_MASK  (0x7F)   /* should be 0xFF?? */
-#define IIO_WSTAT_TXRETRY_SHFT  (16)
-#define IIO_WSTAT_TXRETRY_CNT(w)        (((w) >> IIO_WSTAT_TXRETRY_SHFT) & \
-                                          IIO_WSTAT_TXRETRY_MASK)
-
-/* Number of II perf. counters we can multiplex at once */
-
-#define IO_PERF_SETS	32
-
-#ifdef __KERNEL__
-#include <asm/sn/dmamap.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/xtalk/xtalk.h>
-
-/* Bit for the widget in inbound access register */
-#define IIO_IIWA_WIDGET(_w)     ((uint64_t)(1ULL << _w))
-/* Bit for the widget in outbound access register */
-#define IIO_IOWA_WIDGET(_w)     ((uint64_t)(1ULL << _w))
-
-/* NOTE: The following define assumes that we are going to get
- * widget numbers from 8 thru F and the device numbers within
- * widget from 0 thru 7.
- */
-#define IIO_IIDEM_WIDGETDEV_MASK(w, d)  ((uint64_t)(1ULL << (8 * ((w) - 8) + (d))))
-
-/* IO Interrupt Destination Register */
-#define IIO_IIDSR_SENT_SHIFT    28
-#define IIO_IIDSR_SENT_MASK     0x30000000
-#define IIO_IIDSR_ENB_SHIFT     24
-#define IIO_IIDSR_ENB_MASK      0x01000000
-#define IIO_IIDSR_NODE_SHIFT    9
-#define IIO_IIDSR_NODE_MASK     0x000ff700
-#define IIO_IIDSR_PI_ID_SHIFT   8
-#define IIO_IIDSR_PI_ID_MASK    0x00000100
-#define IIO_IIDSR_LVL_SHIFT     0
-#define IIO_IIDSR_LVL_MASK      0x000000ff
-
-/* Xtalk timeout threshhold register (IIO_IXTT) */
-#define IXTT_RRSP_TO_SHFT	55	   /* read response timeout */
-#define IXTT_RRSP_TO_MASK	(0x1FULL << IXTT_RRSP_TO_SHFT)
-#define IXTT_RRSP_PS_SHFT	32	   /* read responsed TO prescalar */
-#define IXTT_RRSP_PS_MASK	(0x7FFFFFULL << IXTT_RRSP_PS_SHFT)
-#define IXTT_TAIL_TO_SHFT	0	   /* tail timeout counter threshold */
-#define IXTT_TAIL_TO_MASK	(0x3FFFFFFULL << IXTT_TAIL_TO_SHFT)
-
-/*
- * The IO LLP control status register and widget control register
- */
-
-typedef union hubii_wcr_u {
-        uint64_t      wcr_reg_value;
-        struct {
-	  uint64_t	wcr_widget_id:   4,     /* LLP crossbar credit */
-			wcr_tag_mode:	 1,	/* Tag mode */
-			wcr_rsvd1:	 8,	/* Reserved */
-			wcr_xbar_crd:	 3,	/* LLP crossbar credit */
-			wcr_f_bad_pkt:	 1,	/* Force bad llp pkt enable */
-			wcr_dir_con:	 1,	/* widget direct connect */
-			wcr_e_thresh:	 5,	/* elasticity threshold */
-			wcr_rsvd:	41;	/* unused */
-        } wcr_fields_s;
-} hubii_wcr_t;
-
-#define iwcr_dir_con    wcr_fields_s.wcr_dir_con
-
-/* The structures below are defined to extract and modify the ii
-performance registers */
-
-/* io_perf_sel allows the caller to specify what tests will be
-   performed */
-
-typedef union io_perf_sel {
-        uint64_t perf_sel_reg;
-        struct {
-               uint64_t	perf_ippr0 :  4,
-				perf_ippr1 :  4,
-				perf_icct  :  8,
-				perf_rsvd  : 48;
-        } perf_sel_bits;
-} io_perf_sel_t;
-
-/* io_perf_cnt is to extract the count from the shub registers. Due to
-   hardware problems there is only one counter, not two. */
-
-typedef union io_perf_cnt {
-        uint64_t      perf_cnt;
-        struct {
-               uint64_t	perf_cnt   : 20,
-				perf_rsvd2 : 12,
-				perf_rsvd1 : 32;
-        } perf_cnt_bits;
-
-} io_perf_cnt_t;
-
-typedef union iprte_a {
-	shubreg_t	entry;
-	struct {
-		shubreg_t	i_rsvd_1                  :	 3;
-		shubreg_t	i_addr			  :	38;
-		shubreg_t	i_init			  :	 3;
-		shubreg_t	i_source		  :	 8;
-		shubreg_t	i_rsvd			  :	 2;
-		shubreg_t	i_widget		  :	 4;
-		shubreg_t	i_to_cnt		  :	 5;
-		shubreg_t       i_vld                     :      1;
-	} iprte_fields;
-} iprte_a_t;
-
-
-/* PIO MANAGEMENT */
-typedef struct hub_piomap_s *hub_piomap_t;
-
-extern hub_piomap_t
-hub_piomap_alloc(vertex_hdl_t dev,      /* set up mapping for this device */
-                device_desc_t dev_desc, /* device descriptor */
-                iopaddr_t xtalk_addr,   /* map for this xtalk_addr range */
-                size_t byte_count,
-                size_t byte_count_max,  /* maximum size of a mapping */
-                unsigned flags);                /* defined in sys/pio.h */
-
-extern void hub_piomap_free(hub_piomap_t hub_piomap);
-
-extern caddr_t
-hub_piomap_addr(hub_piomap_t hub_piomap,        /* mapping resources */
-                iopaddr_t xtalk_addr,           /* map for this xtalk addr */
-                size_t byte_count);             /* map this many bytes */
-
-extern void
-hub_piomap_done(hub_piomap_t hub_piomap);
-
-extern caddr_t
-hub_piotrans_addr(      vertex_hdl_t dev,       /* translate to this device */
-                        device_desc_t dev_desc, /* device descriptor */
-                        iopaddr_t xtalk_addr,   /* Crosstalk address */
-                        size_t byte_count,      /* map this many bytes */
-                        unsigned flags);        /* (currently unused) */
-
-/* DMA MANAGEMENT */
-typedef struct hub_dmamap_s *hub_dmamap_t;
-
-extern hub_dmamap_t
-hub_dmamap_alloc(       vertex_hdl_t dev,       /* set up mappings for dev */
-                        device_desc_t dev_desc, /* device descriptor */
-                        size_t byte_count_max,  /* max size of a mapping */
-                        unsigned flags);        /* defined in dma.h */
-
-extern void
-hub_dmamap_free(hub_dmamap_t dmamap);
-
-extern iopaddr_t
-hub_dmamap_addr(        hub_dmamap_t dmamap,    /* use mapping resources */
-                        paddr_t paddr,          /* map for this address */
-                        size_t byte_count);     /* map this many bytes */
-
-extern void
-hub_dmamap_done(        hub_dmamap_t dmamap);   /* done w/ mapping resources */
-
-extern iopaddr_t
-hub_dmatrans_addr(      vertex_hdl_t dev,       /* translate for this device */
-                        device_desc_t dev_desc, /* device descriptor */
-                        paddr_t paddr,          /* system physical address */
-                        size_t byte_count,      /* length */
-                        unsigned flags);                /* defined in dma.h */
-
-extern void
-hub_dmamap_drain(       hub_dmamap_t map);
-
-extern void
-hub_dmaaddr_drain(      vertex_hdl_t vhdl,
-                        paddr_t addr,
-                        size_t bytes);
-
-
-/* INTERRUPT MANAGEMENT */
-typedef struct hub_intr_s *hub_intr_t;
-
-extern hub_intr_t
-hub_intr_alloc( vertex_hdl_t dev,               /* which device */
-                device_desc_t dev_desc,         /* device descriptor */
-                vertex_hdl_t owner_dev);        /* owner of this interrupt */
-
-extern hub_intr_t
-hub_intr_alloc_nothd(vertex_hdl_t dev,          /* which device */
-                device_desc_t dev_desc,         /* device descriptor */
-                vertex_hdl_t owner_dev);        /* owner of this interrupt */
-
-extern void
-hub_intr_free(hub_intr_t intr_hdl);
-
-extern int
-hub_intr_connect(       hub_intr_t intr_hdl,    /* xtalk intr resource hndl */
-			intr_func_t intr_func,          /* xtalk intr handler */
-			void *intr_arg,                 /* arg to intr handler */
-                        xtalk_intr_setfunc_t setfunc, /* func to set intr hw */
-                        void *setfunc_arg);     /* arg to setfunc */
-
-extern void
-hub_intr_disconnect(hub_intr_t intr_hdl);
-
-
-/* CONFIGURATION MANAGEMENT */
-
-extern void
-hub_provider_startup(vertex_hdl_t hub);
-
-extern void
-hub_provider_shutdown(vertex_hdl_t hub);
-
-#define HUB_PIO_CONVEYOR        0x1     /* PIO in conveyor belt mode */
-#define HUB_PIO_FIRE_N_FORGET   0x2     /* PIO in fire-and-forget mode */
-
-/* Flags that make sense to hub_widget_flags_set */
-#define HUB_WIDGET_FLAGS        (                               \
-				 HUB_PIO_CONVEYOR       |       \
-				 HUB_PIO_FIRE_N_FORGET          \
-				)
-
-
-typedef int     hub_widget_flags_t;
-
-/* Set the PIO mode for a widget. */
-extern int      hub_widget_flags_set(nasid_t            nasid,
-                                     xwidgetnum_t       widget_num,
-                                     hub_widget_flags_t flags);
-
-/* Error Handling. */
-extern int hub_ioerror_handler(vertex_hdl_t, int, int, struct io_error_s *);
-extern int kl_ioerror_handler(cnodeid_t, cnodeid_t, cpuid_t,
-                              int, paddr_t, caddr_t, ioerror_mode_t);
-#endif /* _KERNEL */
-#endif /* _ASM_IA64_SN_SN2_SHUBIO_H */
-
diff -Nru a/include/asm-ia64/sn/sn2/slotnum.h b/include/asm-ia64/sn/sn2/slotnum.h
--- a/include/asm-ia64/sn/sn2/slotnum.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,41 +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) 1992-1997,2001-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#ifndef _ASM_IA64_SN_SN2_SLOTNUM_H
-#define _ASM_IA64_SN_SN2_SLOTNUM_H
-
-#define SLOTNUM_MAXLENGTH	16
-
-/*
- * This file defines IO widget to slot/device assignments.
- */
-
-
-/* This determines module to pnode mapping. */
-
-#define NODESLOTS_PER_MODULE		1
-#define NODESLOTS_PER_MODULE_SHFT	1
-
-#define SLOTNUM_NODE_CLASS	0x00	/* Node   */
-#define SLOTNUM_ROUTER_CLASS	0x10	/* Router */
-#define SLOTNUM_XTALK_CLASS	0x20	/* Xtalk  */
-#define SLOTNUM_MIDPLANE_CLASS	0x30	/* Midplane */
-#define SLOTNUM_XBOW_CLASS	0x40	/* Xbow  */
-#define SLOTNUM_KNODE_CLASS	0x50	/* Kego node */
-#define SLOTNUM_PCI_CLASS	0x60	/* PCI widgets on XBridge */
-#define SLOTNUM_INVALID_CLASS	0xf0	/* Invalid */
-
-#define SLOTNUM_CLASS_MASK	0xf0
-#define SLOTNUM_SLOT_MASK	0x0f
-
-#define SLOTNUM_GETCLASS(_sn)	((_sn) & SLOTNUM_CLASS_MASK)
-#define SLOTNUM_GETSLOT(_sn)	((_sn) & SLOTNUM_SLOT_MASK)
-
-
-#endif /* _ASM_IA64_SN_SN2_SLOTNUM_H */
diff -Nru a/include/asm-ia64/sn/sn2/sn_hwperf.h b/include/asm-ia64/sn/sn2/sn_hwperf.h
--- a/include/asm-ia64/sn/sn2/sn_hwperf.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-ia64/sn/sn2/sn_hwperf.h	2004-12-24 13:37:19 -08:00
@@ -41,7 +41,15 @@
 #define sn_hwp_is_shared	f.fields.is_shared
 #define sn_hwp_flags		f.b.flags
 
-#define SN_HWPERF_FOREIGN(x)	(!(x)->sn_hwp_this_part && !(x)->sn_hwp_is_shared)
+/* macros for object classification */
+#define SN_HWPERF_IS_NODE(x)		((x) && strstr((x)->name, "SHub"))
+#define SN_HWPERF_IS_IONODE(x)		((x) && strstr((x)->name, "TIO"))
+#define SN_HWPERF_IS_ROUTER(x)		((x) && strstr((x)->name, "Router"))
+#define SN_HWPERF_IS_NL3ROUTER(x)	((x) && strstr((x)->name, "NL3Router"))
+#define SN_HWPERF_FOREIGN(x)		((x) && !(x)->sn_hwp_this_part && !(x)->sn_hwp_is_shared)
+#define SN_HWPERF_SAME_OBJTYPE(x,y)	((SN_HWPERF_IS_NODE(x) && SN_HWPERF_IS_NODE(y)) ||\
+					(SN_HWPERF_IS_IONODE(x) && SN_HWPERF_IS_IONODE(y)) ||\
+					(SN_HWPERF_IS_ROUTER(x) && SN_HWPERF_IS_ROUTER(y)))
 
 /* numa port structure, SN_HWPERF_ENUM_PORTS returns an array of these */
 struct sn_hwperf_port_info {
diff -Nru a/include/asm-ia64/sn/sn2/sn_private.h b/include/asm-ia64/sn/sn2/sn_private.h
--- a/include/asm-ia64/sn/sn2/sn_private.h	2004-12-24 13:36:19 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,245 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_SN2_SN_PRIVATE_H
-#define _ASM_IA64_SN_SN2_SN_PRIVATE_H
-
-#include <linux/wait.h>
-#include <asm/sn/nodepda.h>
-#include <asm/sn/io.h>
-#include <asm/sn/iograph.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/xtalk/xtalk_private.h>
-
-extern nasid_t master_nasid;
-
-/* promif.c */
-extern void he_arcs_set_vectors(void);
-extern void mem_init(void);
-extern void cpu_unenable(cpuid_t);
-extern nasid_t get_lowest_nasid(void);
-extern unsigned long get_master_bridge_base(void);
-extern int check_nasid_equiv(nasid_t, nasid_t);
-extern char get_console_pcislot(void);
-
-extern int is_master_baseio_nasid_widget(nasid_t test_nasid,
-					 xwidgetnum_t test_wid);
-
-/* memsupport.c */
-extern void poison_state_alter_range(unsigned long start, int len, int poison);
-extern int memory_present(paddr_t);
-extern int memory_read_accessible(paddr_t);
-extern int memory_write_accessible(paddr_t);
-extern void memory_set_access(paddr_t, int, int);
-extern void show_dir_state(paddr_t, void (*)(char *, ...));
-extern void check_dir_state(nasid_t, int, void (*)(char *, ...));
-extern void set_dir_owner(paddr_t, int);
-extern void set_dir_state(paddr_t, int);
-extern void set_dir_state_POISONED(paddr_t);
-extern void set_dir_state_UNOWNED(paddr_t);
-extern int is_POISONED_dir_state(paddr_t);
-extern int is_UNOWNED_dir_state(paddr_t);
-#ifdef LATER
-extern void get_dir_ent(paddr_t paddr, int *state,
-			uint64_t * vec_ptr, hubreg_t * elo);
-#endif
-
-/* intr.c */
-extern void intr_unreserve_level(cpuid_t cpu, int level);
-extern int intr_connect_level(cpuid_t cpu, int bit);
-extern int intr_disconnect_level(cpuid_t cpu, int bit);
-extern cpuid_t intr_heuristic(vertex_hdl_t dev, int req_bit, int *resp_bit);
-extern void intr_block_bit(cpuid_t cpu, int bit);
-extern void intr_unblock_bit(cpuid_t cpu, int bit);
-extern void setrtvector(intr_func_t);
-extern void install_cpuintr(cpuid_t cpu);
-extern void install_dbgintr(cpuid_t cpu);
-extern void install_tlbintr(cpuid_t cpu);
-extern void hub_migrintr_init(cnodeid_t /*cnode */ );
-extern int cause_intr_connect(int level, intr_func_t handler,
-			      unsigned int intr_spl_mask);
-extern int cause_intr_disconnect(int level);
-extern void intr_dumpvec(cnodeid_t cnode, void (*pf) (char *, ...));
-
-/* error_dump.c */
-extern char *hub_rrb_err_type[];
-extern char *hub_wrb_err_type[];
-
-void nmi_dump(void);
-void install_cpu_nmi_handler(int slice);
-
-/* klclock.c */
-extern void hub_rtc_init(cnodeid_t);
-
-/* bte.c */
-void bte_lateinit(void);
-void bte_wait_for_xfer_completion(void *);
-
-/* klgraph.c */
-void klhwg_add_all_nodes(vertex_hdl_t);
-void klhwg_add_all_modules(vertex_hdl_t);
-
-/* klidbg.c */
-void install_klidbg_functions(void);
-
-/* klnuma.c */
-extern void replicate_kernel_text(int numnodes);
-extern unsigned long get_freemem_start(cnodeid_t cnode);
-extern void setup_replication_mask(int maxnodes);
-
-/* init.c */
-extern cnodeid_t get_compact_nodeid(void);	/* get compact node id */
-extern void init_platform_nodepda(nodepda_t * npda, cnodeid_t node);
-extern int is_fine_dirmode(void);
-extern void update_node_information(cnodeid_t);
-
-/* shubio.c */
-extern void hubio_init(void);
-extern void hub_merge_clean(nasid_t nasid);
-extern void hub_set_piomode(nasid_t nasid, int conveyor);
-
-/* shuberror.c */
-extern void hub_error_init(cnodeid_t);
-extern void dump_error_spool(cpuid_t cpu, void (*pf) (char *, ...));
-extern void hubni_error_handler(char *, int);
-extern int check_ni_errors(void);
-
-/* Used for debugger to signal upper software a breakpoint has taken place */
-
-extern void *debugger_update;
-extern unsigned long debugger_stopped;
-
-/* 
- * piomap, created by shub_pio_alloc.
- * xtalk_info MUST BE FIRST, since this structure is cast to a
- * xtalk_piomap_s by generic xtalk routines.
- */
-struct hub_piomap_s {
-	struct xtalk_piomap_s hpio_xtalk_info;	/* standard crosstalk pio info */
-	vertex_hdl_t hpio_hub;	/* which shub's mapping registers are set up */
-	short hpio_holdcnt;	/* count of current users of bigwin mapping */
-	char hpio_bigwin_num;	/* if big window map, which one */
-	int hpio_flags;		/* defined below */
-};
-/* hub_piomap flags */
-#define HUB_PIOMAP_IS_VALID		0x1
-#define HUB_PIOMAP_IS_BIGWINDOW		0x2
-#define HUB_PIOMAP_IS_FIXED		0x4
-
-#define	hub_piomap_xt_piomap(hp)	(&hp->hpio_xtalk_info)
-#define	hub_piomap_hub_v(hp)	(hp->hpio_hub)
-#define	hub_piomap_winnum(hp)	(hp->hpio_bigwin_num)
-
-/* 
- * dmamap, created by shub_pio_alloc.
- * xtalk_info MUST BE FIRST, since this structure is cast to a
- * xtalk_dmamap_s by generic xtalk routines.
- */
-struct hub_dmamap_s {
-	struct xtalk_dmamap_s hdma_xtalk_info;	/* standard crosstalk dma info */
-	vertex_hdl_t hdma_hub;	/* which shub we go through */
-	int hdma_flags;		/* defined below */
-};
-/* shub_dmamap flags */
-#define HUB_DMAMAP_IS_VALID		0x1
-#define HUB_DMAMAP_USED			0x2
-#define	HUB_DMAMAP_IS_FIXED		0x4
-
-/* 
- * interrupt handle, created by shub_intr_alloc.
- * xtalk_info MUST BE FIRST, since this structure is cast to a
- * xtalk_intr_s by generic xtalk routines.
- */
-struct hub_intr_s {
-	struct xtalk_intr_s i_xtalk_info;	/* standard crosstalk intr info */
-	cpuid_t i_cpuid;	/* which cpu */
-	int i_bit;		/* which bit */
-	int i_flags;
-};
-/* flag values */
-#define HUB_INTR_IS_ALLOCED	0x1	/* for debug: allocated */
-#define HUB_INTR_IS_CONNECTED	0x4	/* for debug: connected to a software driver */
-
-typedef struct hubinfo_s {
-	nodepda_t *h_nodepda;	/* pointer to node's private data area */
-	cnodeid_t h_cnodeid;	/* compact nodeid */
-	nasid_t h_nasid;	/* nasid */
-
-	/* structures for PIO management */
-	xwidgetnum_t h_widgetid;	/* my widget # (as viewed from xbow) */
-	struct hub_piomap_s h_small_window_piomap[HUB_WIDGET_ID_MAX + 1];
-	wait_queue_head_t h_bwwait;	/* wait for big window to free */
-	spinlock_t h_bwlock;		/* guard big window piomap's */
-	spinlock_t h_crblock;		/* gaurd CRB error handling */
-	int h_num_big_window_fixed;	/* count number of FIXED maps */
-	struct hub_piomap_s h_big_window_piomap[HUB_NUM_BIG_WINDOW];
-	hub_intr_t hub_ii_errintr;
-} *hubinfo_t;
-
-#define hubinfo_get(vhdl, infoptr) ((void)hwgraph_info_get_LBL \
-	(vhdl, INFO_LBL_NODE_INFO, (arbitrary_info_t *)infoptr))
-
-#define hubinfo_set(vhdl, infoptr) (void)hwgraph_info_add_LBL \
-	(vhdl, INFO_LBL_NODE_INFO, (arbitrary_info_t)infoptr)
-
-#define	hubinfo_to_hubv(hinfo, hub_v)	(hinfo->h_nodepda->node_vertex)
-
-/*
- * Hub info PIO map access functions.
- */
-#define	hubinfo_bwin_piomap_get(hinfo, win) 	\
-			(&hinfo->h_big_window_piomap[win])
-#define	hubinfo_swin_piomap_get(hinfo, win)	\
-			(&hinfo->h_small_window_piomap[win])
-
-/* cpu-specific information stored under INFO_LBL_CPU_INFO */
-typedef struct cpuinfo_s {
-	cpuid_t ci_cpuid;	/* CPU ID */
-} *cpuinfo_t;
-
-#define cpuinfo_get(vhdl, infoptr) ((void)hwgraph_info_get_LBL \
-	(vhdl, INFO_LBL_CPU_INFO, (arbitrary_info_t *)infoptr))
-
-#define cpuinfo_set(vhdl, infoptr) (void)hwgraph_info_add_LBL \
-	(vhdl, INFO_LBL_CPU_INFO, (arbitrary_info_t)infoptr)
-
-/* Special initialization function for xswitch vertices created during startup. */
-extern void xswitch_vertex_init(vertex_hdl_t xswitch);
-
-extern xtalk_provider_t hub_provider;
-extern int numionodes;
-
-/* du.c */
-int ducons_write(char *buf, int len);
-
-/* memerror.c */
-
-extern void install_eccintr(cpuid_t cpu);
-extern void memerror_get_stats(cnodeid_t cnode,
-			       int *bank_stats, int *bank_stats_max);
-extern void probe_md_errors(nasid_t);
-/* sysctlr.c */
-extern void sysctlr_init(void);
-extern void sysctlr_power_off(int sdonly);
-extern void sysctlr_keepalive(void);
-
-#define valid_cpuid(_x)		(((_x) >= 0) && ((_x) < maxcpus))
-
-/* Useful definitions to get the memory dimm given a physical
- * address.
- */
-#define paddr_dimm(_pa)		((_pa & MD_BANK_MASK) >> MD_BANK_SHFT)
-#define paddr_cnode(_pa)	(nasid_to_cnodeid(NASID_GET(_pa)))
-extern void membank_pathname_get(paddr_t, char *);
-
-extern void crbx(nasid_t nasid, void (*pf) (char *, ...));
-void bootstrap(void);
-
-/* sndrv.c */
-extern int sndrv_attach(vertex_hdl_t vertex);
-
-#endif				/* _ASM_IA64_SN_SN2_SN_PRIVATE_H */
diff -Nru a/include/asm-ia64/sn/sn_cpuid.h b/include/asm-ia64/sn/sn_cpuid.h
--- a/include/asm-ia64/sn/sn_cpuid.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-ia64/sn/sn_cpuid.h	2004-12-24 13:36:18 -08:00
@@ -36,9 +36,6 @@
  *		the boot cpu is 0.
  *			smp_processor_id() returns the cpuid of the current cpu.
  *
- *	   CPUNUM - On IA64, a cpunum and cpuid are the same. This is NOT true
- *		on other architectures like IA32.
- *
  * 	   CPU_PHYSICAL_ID (also known as HARD_PROCESSOR_ID)
  *		This is the same as 31:24 of the processor LID register
  *			hard_smp_processor_id()- cpu_physical_id of current processor
@@ -46,15 +43,15 @@
  *			cpu_logical_id(phy_id) - convert a <physical_cpuid> to a <cpuid> 
  *				* not real efficient - don't use in perf critical code
  *
- *         LID - processor defined register (see PRM V2).
- *
- *           On SN2
- *		31:28 - id   Contains 0-3 to identify the cpu on the node
- *		27:16 - eid  Contains the NASID
+ *         SLICE - a number in the range of 0 - 3 (typically) that represents the
+ *		cpu number on a brick.
  *
+ *	   SUBNODE - (almost obsolete) the number of the FSB that a cpu is
+ *		connected to. This is also the same as the PI number. Usually 0 or 1.
  *
+ *	NOTE!!!: the value of the bits in the cpu physical id (SAPICid or LID) of a cpu has no 
+ *	significance. The SAPIC id (LID) is a 16-bit cookie that has meaning only to the PROM.
  *
- * The following assumes the following mappings for LID register values:
  *
  * The macros convert between cpu physical ids & slice/nasid/cnodeid.
  * These terms are described below:
@@ -84,18 +81,11 @@
  */
 
 #ifndef CONFIG_SMP
+#define cpu_logical_id(cpu)			0
 #define cpu_physical_id(cpuid)			((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
 #endif
 
-/*
- * macros for some of these exist in sn/addrs.h & sn/arch.h, etc. However, 
- * trying #include these files here causes circular dependencies.
- */
-#define cpu_physical_id_to_nasid(cpi)		((cpi) &0xfff)
-#define cpu_physical_id_to_slice(cpi)		((cpi>>12) & 3)
-#define cpu_physical_id_to_coherence_id(cpi)	(cpu_physical_id_to_nasid(cpi) >> 9)
-#define get_nasid()				((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xfff)
-#define get_slice()				((ia64_getreg(_IA64_REG_CR_LID) >> 28) & 0xf)
+
 #define get_node_number(addr)			(((unsigned long)(addr)>>38) & 0x7ff)
 
 /*
@@ -103,43 +93,35 @@
  * 
  * NOTE: on non-MP systems, only cpuid 0 exists
  */
-#define id_eid_to_cpu_physical_id(id,eid)	 	(((id)<<8) | (eid))
-
-#define nasid_slice_to_cpuid(nasid,slice)		(cpu_logical_id(nasid_slice_to_cpu_physical_id((nasid),(slice))))
-
-#define nasid_slice_to_cpu_physical_id(nasid, slice)	(((slice)<<12) | (nasid))
-
-/*
- * The following table/struct  is used for managing PTC coherency domains.
- */
-typedef struct {
-	u8	domain;
-	u8	reserved;
-	u16	sapicid;
-} sn_sapicid_info_t;
 
-extern sn_sapicid_info_t	sn_sapicid_info[];	/* indexed by cpuid */
 extern short physical_node_map[];			/* indexed by nasid to get cnode */
 
-
 /*
- * cpuid_to_slice  - convert a cpuid to the slice that it resides on
- *  There are 4 cpus per node. This function returns 0 .. 3)
+ * Macros for retrieving info about current cpu
  */
-#define cpuid_to_slice(cpuid)		(cpu_physical_id_to_slice(cpu_physical_id(cpuid)))
-
+#define get_nasid()			(nodepda->phys_cpuid[smp_processor_id()].nasid)
+#define get_subnode()			(nodepda->phys_cpuid[smp_processor_id()].subnode)
+#define get_slice()			(nodepda->phys_cpuid[smp_processor_id()].slice)
+#define get_cnode()			(nodepda->phys_cpuid[smp_processor_id()].cnode)
+#define get_sapicid()			((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
 
 /*
- * cpuid_to_nasid  - convert a cpuid to the NASID that it resides on
+ * Macros for retrieving info about an arbitrary cpu
+ *	cpuid - logical cpu id
  */
-#define cpuid_to_nasid(cpuid)		(cpu_physical_id_to_nasid(cpu_physical_id(cpuid)))
+#define cpuid_to_nasid(cpuid)		(nodepda->phys_cpuid[cpuid].nasid)
+#define cpuid_to_subnode(cpuid)		(nodepda->phys_cpuid[cpuid].subnode)
+#define cpuid_to_slice(cpuid)		(nodepda->phys_cpuid[cpuid].slice)
+#define cpuid_to_cnodeid(cpuid)		(physical_node_map[cpuid_to_nasid(cpuid)])
 
 
 /*
- * cpuid_to_cnodeid  - convert a cpuid to the cnode that it resides on
+ * Dont use the following in performance critical code. They require scans
+ * of potentially large tables.
  */
-#define cpuid_to_cnodeid(cpuid)		(physical_node_map[cpuid_to_nasid(cpuid)])
-
+extern int nasid_slice_to_cpuid(int, int);
+#define nasid_slice_to_cpu_physical_id(nasid, slice)			\
+	cpu_physical_id(nasid_slice_to_cpuid(nasid, slice))
 
 /*
  * cnodeid_to_nasid - convert a cnodeid to a NASID
@@ -149,35 +131,15 @@
  */
 #define cnodeid_to_nasid(cnodeid)	pda->cnodeid_to_nasid_table[cnodeid]
  
-
 /*
  * nasid_to_cnodeid - convert a NASID to a cnodeid
  */
 #define nasid_to_cnodeid(nasid)		(physical_node_map[nasid])
 
-
-/*
- * cnode_slice_to_cpuid - convert a codeid & slice to a cpuid
- */
-
-#define cnode_slice_to_cpuid(cnodeid,slice) (nasid_slice_to_cpuid(cnodeid_to_nasid(cnodeid),(slice)))
- 
-
-/*
- * cpuid_to_subnode - convert a cpuid to the subnode it resides on.
- *   slice 0 & 1 are on subnode 0
- *   slice 2 & 3 are on subnode 1.
- */
-#define cpuid_to_subnode(cpuid)		((cpuid_to_slice(cpuid)<2) ? 0 : 1)
- 
-
-#define smp_physical_node_id()			(cpuid_to_nasid(smp_processor_id()))
-
 /*
- * cpuid_to_coherence_id - convert a cpuid to the coherence domain id it
- * resides on
+ * partition_coherence_id - cget the coherence ID of the current partition
  */
-#define cpuid_to_coherence_id(cpuid)	cpu_physical_id_to_coherence_id(cpu_physical_id(cpuid))
+#define partition_coherence_id()	(get_nasid() >> 9)
 
 #endif /* _ASM_IA64_SN_SN_CPUID_H */
 
diff -Nru a/include/asm-ia64/sn/sn_fru.h b/include/asm-ia64/sn/sn_fru.h
--- a/include/asm-ia64/sn/sn_fru.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-ia64/sn/sn_fru.h	2004-12-24 13:36:17 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992-1997,1999-2003 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992-1997,1999-2004 Silicon Graphics, Inc. All rights reserved.
  */
 #ifndef _ASM_IA64_SN_SN_FRU_H
 #define _ASM_IA64_SN_SN_FRU_H
diff -Nru a/include/asm-ia64/sn/sn_private.h b/include/asm-ia64/sn/sn_private.h
--- a/include/asm-ia64/sn/sn_private.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,13 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_SN_PRIVATE_H
-#define _ASM_IA64_SN_SN_PRIVATE_H
-
-#include <asm/sn/sn2/sn_private.h>
-
-#endif /* _ASM_IA64_SN_SN_PRIVATE_H */
diff -Nru a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h
--- a/include/asm-ia64/sn/sn_sal.h	2004-12-24 13:37:32 -08:00
+++ b/include/asm-ia64/sn/sn_sal.h	2004-12-24 13:37:32 -08:00
@@ -16,9 +16,8 @@
 #include <asm/sal.h>
 #include <asm/sn/sn_cpuid.h>
 #include <asm/sn/arch.h>
+#include <asm/sn/geo.h>
 #include <asm/sn/nodepda.h>
-#include <asm/sn/klconfig.h>
-        
 
 // SGI Specific Calls
 #define  SN_SAL_POD_MODE                           0x02000001
@@ -33,6 +32,7 @@
 #define  SN_SAL_NO_FAULT_ZONE_VIRTUAL		   0x02000010
 #define  SN_SAL_NO_FAULT_ZONE_PHYSICAL		   0x02000011
 #define  SN_SAL_PRINT_ERROR			   0x02000012
+#define  SN_SAL_GET_SAPIC_INFO                     0x02009999	//ZZZZ fix
 #define  SN_SAL_SET_ERROR_HANDLING_FEATURES	   0x0200001a	// reentrant
 #define  SN_SAL_GET_FIT_COMPT			   0x0200001b	// reentrant
 #define  SN_SAL_CONSOLE_PUTC                       0x02000021
@@ -62,7 +62,19 @@
 
 #define  SN_SAL_SYSCTL_IOBRICK_PCI_OP		   0x02000042	// reentrant
 #define	 SN_SAL_IROUTER_OP			   0x02000043
+#define  SN_SAL_IOIF_INTERRUPT			   0x0200004a
 #define  SN_SAL_HWPERF_OP			   0x02000050   // lock
+#define  SN_SAL_IOIF_ERROR_INTERRUPT		   0x02000051
+
+#define  SN_SAL_IOIF_SLOT_ENABLE		   0x02000053
+#define  SN_SAL_IOIF_SLOT_DISABLE		   0x02000054
+#define  SN_SAL_IOIF_GET_HUBDEV_INFO		   0x02000055
+#define  SN_SAL_IOIF_GET_PCIBUS_INFO		   0x02000056
+#define  SN_SAL_IOIF_GET_PCIDEV_INFO		   0x02000057
+#define  SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST	   0x02000058
+
+#define SN_SAL_HUB_ERROR_INTERRUPT		   0x02000060
+
 
 /*
  * Service-specific constants
@@ -77,16 +89,9 @@
 #define SAL_CONSOLE_INTR_XMIT	1	/* output interrupt */
 #define SAL_CONSOLE_INTR_RECV	2	/* input interrupt */
 
-#ifdef CONFIG_HOTPLUG_PCI_SGI
-/* power up / power down / reset a PCI slot or bus */
-#define SAL_SYSCTL_PCI_POWER_UP         0
-#define SAL_SYSCTL_PCI_POWER_DOWN       1
-#define SAL_SYSCTL_PCI_RESET            2
-
-/* what type of I/O brick? */
-#define SAL_SYSCTL_IO_XTALK	0       /* connected via a compute node */
-
-#endif	/* CONFIG_HOTPLUG_PCI_SGI */
+/* interrupt handling */
+#define SAL_INTR_ALLOC		1
+#define SAL_INTR_FREE		2
 
 /*
  * IRouter (i.e. generalized system controller) operations
@@ -116,19 +121,6 @@
 #define SALRET_INVALID_ARG	(-2)
 #define SALRET_ERROR		(-3)
 
-/*
- * SN_SAL_SET_ERROR_HANDLING_FEATURES bit settings
- */
-enum 
-{
-	/* if "rz always" is set, have the mca slaves call os_init_slave */
-	SN_SAL_EHF_MCA_SLV_TO_OS_INIT_SLV=0,
-	/* do not rz on tlb checks, even if "rz always" is set */
-	SN_SAL_EHF_NO_RZ_TLBC,
-	/* do not rz on PIO reads to I/O space, even if "rz always" is set */
-	SN_SAL_EHF_NO_RZ_IO_READ,
-};
-
 
 /**
  * sn_sal_rev_major - get the major SGI SAL revision number
@@ -164,10 +156,8 @@
  * Specify the minimum PROM revsion required for this kernel.
  * Note that they're stored in hex format...
  */
-#define SN_SAL_MIN_MAJOR	0x3  /* SN2 kernels need at least PROM 3.40 */
-#define SN_SAL_MIN_MINOR	0x40
-
-u64 ia64_sn_probe_io_slot(long paddr, long size, void *data_ptr);
+#define SN_SAL_MIN_MAJOR	0x4  /* SN2 kernels need at least PROM 4.0 */
+#define SN_SAL_MIN_MINOR	0x0
 
 /*
  * Returns the master console nasid, if the call fails, return an illegal
@@ -646,12 +636,12 @@
 	unsigned long irq_flags;
 
 	cnodeid = nasid_to_cnodeid(get_node_number(paddr));
-	spin_lock(&NODEPDA(cnodeid)->bist_lock);
+	// spin_lock(&NODEPDA(cnodeid)->bist_lock);
 	local_irq_save(irq_flags);
 	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_MEMPROTECT, paddr, len, nasid_array,
 		 perms, 0, 0, 0);
 	local_irq_restore(irq_flags);
-	spin_unlock(&NODEPDA(cnodeid)->bist_lock);
+	// spin_unlock(&NODEPDA(cnodeid)->bist_lock);
 	return ret_stuff.status;
 }
 #define SN_MEMPROT_ACCESS_CLASS_0		0x14a080
@@ -695,7 +685,7 @@
  */
 static inline u64
 ia64_sn_sysctl_iobrick_pci_op(nasid_t n, u64 connection_type, 
-			      u64 bus, slotid_t slot, 
+			      u64 bus, char slot, 
 			      u64 action)
 {
 	struct ia64_sal_retval rv = {0, 0, 0, 0};
@@ -707,26 +697,6 @@
 	return 0;
 }
 
-/*
- * Tell the prom how the OS wants to handle specific error features.
- * It takes an array of 7 u64.
- */
-static inline u64
-ia64_sn_set_error_handling_features(const u64 *feature_bits)
-{
-	struct ia64_sal_retval rv = {0, 0, 0, 0};
-
-	SAL_CALL_REENTRANT(rv, SN_SAL_SET_ERROR_HANDLING_FEATURES,
-			feature_bits[0],
-			feature_bits[1],
-			feature_bits[2],
-			feature_bits[3],
-			feature_bits[4],
-			feature_bits[5],
-			feature_bits[6]);
-	return rv.status;
-}
-
 
 /*
  * Open a subchannel for sending arbitrary data to the system
@@ -875,6 +845,37 @@
 	return (int) rv.status;
 }
 
+/*
+ * Returns the nasid, subnode & slice corresponding to a SAPIC ID
+ */
+static inline u64
+ia64_sn_get_sapic_info(int sapicid, int *nasid, int *subnode, int *slice)
+{
+	struct ia64_sal_retval ret_stuff;
+
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+	ret_stuff.v1 = 0;
+	ret_stuff.v2 = 0;
+	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SAPIC_INFO, sapicid, 0, 0, 0, 0, 0, 0);
+
+/***** BEGIN HACK - temp til new proms available ********/
+	if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
+		if (nasid) *nasid = sapicid & 0xfff;
+		if (subnode) *subnode = (sapicid >> 13) & 1;
+		if (slice) *slice = (sapicid >> 12) & 3;
+		return 0;
+	}
+/***** END HACK *******/
+
+	if (ret_stuff.status < 0)
+		return ret_stuff.status;
+
+	if (nasid) *nasid = (int) ret_stuff.v0;
+	if (subnode) *subnode = (int) ret_stuff.v1;
+	if (slice) *slice = (int) ret_stuff.v2;
+	return 0;
+}
 /*
  * This is the access point to the Altix PROM hardware performance
  * and status monitoring interface. For info on using this, see
diff -Nru a/include/asm-ia64/sn/sndrv.h b/include/asm-ia64/sn/sndrv.h
--- a/include/asm-ia64/sn/sndrv.h	2004-12-24 13:36:56 -08:00
+++ b/include/asm-ia64/sn/sndrv.h	2004-12-24 13:36:56 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2002-2004 Silicon Graphics, Inc.  All Rights Reserved.
  */
 
 #ifndef _ASM_IA64_SN_SNDRV_H
@@ -34,18 +34,6 @@
 #define SNDRV_SYNERGY_APPEND		33
 #define SNDRV_SYNERGY_ENABLE		34
 #define SNDRV_SYNERGY_FREQ		35
-
-/* see shubstats_ioctl() */
-#define SNDRV_SHUB_INFOSIZE		40
-#define SNDRV_SHUB_CONFIGURE		41
-#define SNDRV_SHUB_RESETSTATS		42
-#define SNDRV_SHUB_GETSTATS		43
-#define SNDRV_SHUB_GETNASID		44
-#define SNDRV_SHUB_GETMMR32            45
-#define SNDRV_SHUB_GETMMR64            46
-#define SNDRV_SHUB_GETMMR64_IO         47
-#define SNDRV_SHUB_PUTMMR64            48
-#define SNDRV_SHUB_PUTMMR64_IO         49
 
 /* Devices */
 #define SNDRV_UKNOWN_DEVICE		-1
diff -Nru a/include/asm-ia64/sn/types.h b/include/asm-ia64/sn/types.h
--- a/include/asm-ia64/sn/types.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-ia64/sn/types.h	2004-12-24 13:37:19 -08:00
@@ -9,13 +9,15 @@
 #ifndef _ASM_IA64_SN_TYPES_H
 #define _ASM_IA64_SN_TYPES_H
 
+#include <linux/types.h>
+
 typedef unsigned long 	cpuid_t;
 typedef signed short	nasid_t;	/* node id in numa-as-id space */
 typedef signed char	partid_t;	/* partition ID type */
 typedef unsigned int    moduleid_t;     /* user-visible module number type */
 typedef unsigned int    cmoduleid_t;    /* kernel compact module id type */
 typedef signed char     slabid_t;
-
+typedef u64 nic_t;
 typedef unsigned long iopaddr_t;
 typedef unsigned long paddr_t;
 typedef short cnodeid_t;
diff -Nru a/include/asm-ia64/sn/vector.h b/include/asm-ia64/sn/vector.h
--- a/include/asm-ia64/sn/vector.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,75 +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) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_VECTOR_H
-#define _ASM_IA64_SN_VECTOR_H
-
-#define NET_VEC_NULL            ((net_vec_t)  0)
-#define NET_VEC_BAD             ((net_vec_t) -1)
-
-#define VEC_POLLS_W		128	/* Polls before write times out */
-#define VEC_POLLS_R		128	/* Polls before read times out */
-#define VEC_POLLS_X		128	/* Polls before exch times out */
-
-#define VEC_RETRIES_W		8	/* Retries before write fails */
-#define VEC_RETRIES_R           8	/* Retries before read fails */
-#define VEC_RETRIES_X		4	/* Retries before exch fails */
-
-#define NET_ERROR_NONE		0	/* No error		*/
-#define NET_ERROR_HARDWARE	(-1)	/* Hardware error	*/
-#define NET_ERROR_OVERRUN	(-2)	/* Extra response(s)	*/
-#define NET_ERROR_REPLY		(-3)	/* Reply parms mismatch */
-#define NET_ERROR_ADDRESS	(-4)	/* Addr error response	*/
-#define NET_ERROR_COMMAND	(-5)	/* Cmd error response	*/
-#define NET_ERROR_PROT		(-6)	/* Prot error response	*/
-#define NET_ERROR_TIMEOUT	(-7)	/* Too many retries	*/
-#define NET_ERROR_VECTOR	(-8)	/* Invalid vector/path	*/
-#define NET_ERROR_ROUTERLOCK	(-9)	/* Timeout locking rtr	*/
-#define NET_ERROR_INVAL		(-10)	/* Invalid vector request */
-
-#ifndef __ASSEMBLY__
-#include <linux/types.h>
-#include <asm/sn/types.h>
-
-typedef uint64_t              net_reg_t;
-typedef uint64_t              net_vec_t;
-
-int             vector_write(net_vec_t dest,
-                              int write_id, int address,
-                              uint64_t value);
-
-int             vector_read(net_vec_t dest,
-                             int write_id, int address,
-                             uint64_t *value);
-
-int             vector_write_node(net_vec_t dest, nasid_t nasid,
-                              int write_id, int address,
-                              uint64_t value);
-
-int             vector_read_node(net_vec_t dest, nasid_t nasid,
-                             int write_id, int address,
-                             uint64_t *value);
-
-int             vector_length(net_vec_t vec);
-net_vec_t       vector_get(net_vec_t vec, int n);
-net_vec_t       vector_prefix(net_vec_t vec, int n);
-net_vec_t       vector_modify(net_vec_t entry, int n, int route);
-net_vec_t       vector_reverse(net_vec_t vec);
-net_vec_t       vector_concat(net_vec_t vec1, net_vec_t vec2);
-
-char		*net_errmsg(int);
-
-#ifndef _STANDALONE
-int hub_vector_write(cnodeid_t cnode, net_vec_t vector, int writeid,
-	int addr, net_reg_t value);
-int hub_vector_read(cnodeid_t cnode, net_vec_t vector, int writeid,
-	int addr, net_reg_t *value);
-#endif
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* _ASM_IA64_SN_VECTOR_H */
diff -Nru a/include/asm-ia64/sn/xtalk/xbow.h b/include/asm-ia64/sn/xtalk/xbow.h
--- a/include/asm-ia64/sn/xtalk/xbow.h	2004-12-24 13:36:31 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,675 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- */
-#ifndef _ASM_IA64_SN_XTALK_XBOW_H
-#define _ASM_IA64_SN_XTALK_XBOW_H
-
-/*
- * xbow.h - header file for crossbow chip and xbow section of xbridge
- */
-
-#include <asm/types.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/xtalk/xswitch.h>
-#ifndef __ASSEMBLY__
-#include <asm/sn/xtalk/xbow_info.h>
-#endif
-
-
-#define	XBOW_DRV_PREFIX	"xbow_"
-
-/* The crossbow chip supports 8 8/16 bits I/O ports, numbered 0x8 through 0xf.
- * It also implements the widget 0 address space and register set.
- */
-#define XBOW_PORT_0	0x0
-#define XBOW_PORT_8	0x8
-#define XBOW_PORT_9	0x9
-#define XBOW_PORT_A	0xa
-#define XBOW_PORT_B	0xb
-#define XBOW_PORT_C	0xc
-#define XBOW_PORT_D	0xd
-#define XBOW_PORT_E	0xe
-#define XBOW_PORT_F	0xf
-
-#define MAX_XBOW_PORTS	8	/* number of ports on xbow chip */
-#define BASE_XBOW_PORT	XBOW_PORT_8	/* Lowest external port */
-#define MAX_PORT_NUM	0x10	/* maximum port number + 1 */
-#define XBOW_WIDGET_ID	0	/* xbow is itself widget 0 */
-
-#define XBOW_HUBLINK_LOW  0xa
-#define XBOW_HUBLINK_HIGH 0xb
-
-#define XBOW_PEER_LINK(link) (link == XBOW_HUBLINK_LOW) ? \
-                                XBOW_HUBLINK_HIGH : XBOW_HUBLINK_LOW
-
-
-#define	XBOW_CREDIT	4
-
-#define MAX_XBOW_NAME 	16
-
-#ifndef __ASSEMBLY__
-typedef uint32_t      xbowreg_t;
-
-/* Register set for each xbow link */
-typedef volatile struct xb_linkregs_s {
-/* 
- * we access these through synergy unswizzled space, so the address
- * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
- * That's why we put the register first and filler second.
- */
-    xbowreg_t               link_ibf;
-    xbowreg_t               filler0;	/* filler for proper alignment */
-    xbowreg_t               link_control;
-    xbowreg_t               filler1;
-    xbowreg_t               link_status;
-    xbowreg_t               filler2;
-    xbowreg_t               link_arb_upper;
-    xbowreg_t               filler3;
-    xbowreg_t               link_arb_lower;
-    xbowreg_t               filler4;
-    xbowreg_t               link_status_clr;
-    xbowreg_t               filler5;
-    xbowreg_t               link_reset;
-    xbowreg_t               filler6;
-    xbowreg_t               link_aux_status;
-    xbowreg_t               filler7;
-} xb_linkregs_t;
-
-typedef volatile struct xbow_s {
-    /* standard widget configuration                       0x000000-0x000057 */
-    widget_cfg_t            xb_widget;  /* 0x000000 */
-
-    /* helper fieldnames for accessing bridge widget */
-
-#define xb_wid_id                       xb_widget.w_id
-#define xb_wid_stat                     xb_widget.w_status
-#define xb_wid_err_upper                xb_widget.w_err_upper_addr
-#define xb_wid_err_lower                xb_widget.w_err_lower_addr
-#define xb_wid_control                  xb_widget.w_control
-#define xb_wid_req_timeout              xb_widget.w_req_timeout
-#define xb_wid_int_upper                xb_widget.w_intdest_upper_addr
-#define xb_wid_int_lower                xb_widget.w_intdest_lower_addr
-#define xb_wid_err_cmdword              xb_widget.w_err_cmd_word
-#define xb_wid_llp                      xb_widget.w_llp_cfg
-#define xb_wid_stat_clr                 xb_widget.w_tflush
-
-/* 
- * we access these through synergy unswizzled space, so the address
- * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
- * That's why we put the register first and filler second.
- */
-    /* xbow-specific widget configuration                  0x000058-0x0000FF */
-    xbowreg_t               xb_wid_arb_reload;  /* 0x00005C */
-    xbowreg_t               _pad_000058;
-    xbowreg_t               xb_perf_ctr_a;      /* 0x000064 */
-    xbowreg_t               _pad_000060;
-    xbowreg_t               xb_perf_ctr_b;      /* 0x00006c */
-    xbowreg_t               _pad_000068;
-    xbowreg_t               xb_nic;     /* 0x000074 */
-    xbowreg_t               _pad_000070;
-
-    /* Xbridge only */
-    xbowreg_t               xb_w0_rst_fnc;      /* 0x00007C */
-    xbowreg_t               _pad_000078;
-    xbowreg_t               xb_l8_rst_fnc;      /* 0x000084 */
-    xbowreg_t               _pad_000080;
-    xbowreg_t               xb_l9_rst_fnc;      /* 0x00008c */
-    xbowreg_t               _pad_000088;
-    xbowreg_t               xb_la_rst_fnc;      /* 0x000094 */
-    xbowreg_t               _pad_000090;
-    xbowreg_t               xb_lb_rst_fnc;      /* 0x00009c */
-    xbowreg_t               _pad_000098;
-    xbowreg_t               xb_lc_rst_fnc;      /* 0x0000a4 */
-    xbowreg_t               _pad_0000a0;
-    xbowreg_t               xb_ld_rst_fnc;      /* 0x0000ac */
-    xbowreg_t               _pad_0000a8;
-    xbowreg_t               xb_le_rst_fnc;      /* 0x0000b4 */
-    xbowreg_t               _pad_0000b0;
-    xbowreg_t               xb_lf_rst_fnc;      /* 0x0000bc */
-    xbowreg_t               _pad_0000b8;
-    xbowreg_t               xb_lock;            /* 0x0000c4 */
-    xbowreg_t               _pad_0000c0;
-    xbowreg_t               xb_lock_clr;        /* 0x0000cc */
-    xbowreg_t               _pad_0000c8;
-    /* end of Xbridge only */
-    xbowreg_t               _pad_0000d0[12];
-
-    /* Link Specific Registers, port 8..15                 0x000100-0x000300 */
-    xb_linkregs_t           xb_link_raw[MAX_XBOW_PORTS];
-#define xb_link(p)      xb_link_raw[(p) & (MAX_XBOW_PORTS - 1)]
-
-} xbow_t;
-
-/* Configuration structure which describes each xbow link */
-typedef struct xbow_cfg_s {
-    int			    xb_port;	/* port number (0-15) */
-    int			    xb_flags;	/* port software flags */
-    short		    xb_shift;	/* shift for arb reg (mask is 0xff) */
-    short		    xb_ul;	/* upper or lower arb reg */
-    int			    xb_pad;	/* use this later (pad to ptr align) */
-    xb_linkregs_t	   *xb_linkregs;	/* pointer to link registers */
-    widget_cfg_t	   *xb_widget;	/* pointer to widget registers */
-    char		    xb_name[MAX_XBOW_NAME];	/* port name */
-    xbowreg_t		    xb_sh_arb_upper;	/* shadow upper arb register */
-    xbowreg_t		    xb_sh_arb_lower;	/* shadow lower arb register */
-} xbow_cfg_t;
-
-#define XB_FLAGS_EXISTS		0x1	/* device exists */
-#define XB_FLAGS_MASTER		0x2
-#define XB_FLAGS_SLAVE		0x0
-#define XB_FLAGS_GBR		0x4
-#define XB_FLAGS_16BIT		0x8
-#define XB_FLAGS_8BIT		0x0
-
-/* get xbow config information for port p */
-#define XB_CONFIG(p)	xbow_cfg[xb_ports[p]]
-
-/* is widget port number valid?  (based on version 7.0 of xbow spec) */
-#define XBOW_WIDGET_IS_VALID(wid) ((wid) >= XBOW_PORT_8 && (wid) <= XBOW_PORT_F)
-
-/* whether to use upper or lower arbitration register, given source widget id */
-#define XBOW_ARB_IS_UPPER(wid) 	((wid) >= XBOW_PORT_8 && (wid) <= XBOW_PORT_B)
-#define XBOW_ARB_IS_LOWER(wid) 	((wid) >= XBOW_PORT_C && (wid) <= XBOW_PORT_F)
-
-/* offset of arbitration register, given source widget id */
-#define XBOW_ARB_OFF(wid) 	(XBOW_ARB_IS_UPPER(wid) ? 0x1c : 0x24)
-
-#endif				/* __ASSEMBLY__ */
-
-#define	XBOW_WID_ID		WIDGET_ID
-#define	XBOW_WID_STAT		WIDGET_STATUS
-#define	XBOW_WID_ERR_UPPER	WIDGET_ERR_UPPER_ADDR
-#define	XBOW_WID_ERR_LOWER	WIDGET_ERR_LOWER_ADDR
-#define	XBOW_WID_CONTROL	WIDGET_CONTROL
-#define	XBOW_WID_REQ_TO		WIDGET_REQ_TIMEOUT
-#define	XBOW_WID_INT_UPPER	WIDGET_INTDEST_UPPER_ADDR
-#define	XBOW_WID_INT_LOWER	WIDGET_INTDEST_LOWER_ADDR
-#define	XBOW_WID_ERR_CMDWORD	WIDGET_ERR_CMD_WORD
-#define	XBOW_WID_LLP		WIDGET_LLP_CFG
-#define	XBOW_WID_STAT_CLR	WIDGET_TFLUSH
-#define XBOW_WID_ARB_RELOAD 	0x5c
-#define XBOW_WID_PERF_CTR_A 	0x64
-#define XBOW_WID_PERF_CTR_B 	0x6c
-#define XBOW_WID_NIC 		0x74
-
-/* Xbridge only */
-#define XBOW_W0_RST_FNC		0x00007C
-#define	XBOW_L8_RST_FNC		0x000084
-#define	XBOW_L9_RST_FNC		0x00008c
-#define	XBOW_LA_RST_FNC		0x000094
-#define	XBOW_LB_RST_FNC		0x00009c
-#define	XBOW_LC_RST_FNC		0x0000a4
-#define	XBOW_LD_RST_FNC		0x0000ac
-#define	XBOW_LE_RST_FNC		0x0000b4
-#define	XBOW_LF_RST_FNC		0x0000bc
-#define XBOW_RESET_FENCE(x) ((x) > 7 && (x) < 16) ? \
-				(XBOW_W0_RST_FNC + ((x) - 7) * 8) : \
-				((x) == 0) ? XBOW_W0_RST_FNC : 0
-#define XBOW_LOCK		0x0000c4
-#define XBOW_LOCK_CLR		0x0000cc
-/* End of Xbridge only */
-
-/* used only in ide, but defined here within the reserved portion */
-/*              of the widget0 address space (before 0xf4) */
-#define	XBOW_WID_UNDEF		0xe4
-
-/* xbow link register set base, legal value for x is 0x8..0xf */
-#define	XB_LINK_BASE		0x100
-#define	XB_LINK_OFFSET		0x40
-#define	XB_LINK_REG_BASE(x)	(XB_LINK_BASE + ((x) & (MAX_XBOW_PORTS - 1)) * XB_LINK_OFFSET)
-
-#define	XB_LINK_IBUF_FLUSH(x)	(XB_LINK_REG_BASE(x) + 0x4)
-#define	XB_LINK_CTRL(x)		(XB_LINK_REG_BASE(x) + 0xc)
-#define	XB_LINK_STATUS(x)	(XB_LINK_REG_BASE(x) + 0x14)
-#define	XB_LINK_ARB_UPPER(x)	(XB_LINK_REG_BASE(x) + 0x1c)
-#define	XB_LINK_ARB_LOWER(x)	(XB_LINK_REG_BASE(x) + 0x24)
-#define	XB_LINK_STATUS_CLR(x)	(XB_LINK_REG_BASE(x) + 0x2c)
-#define	XB_LINK_RESET(x)	(XB_LINK_REG_BASE(x) + 0x34)
-#define	XB_LINK_AUX_STATUS(x)	(XB_LINK_REG_BASE(x) + 0x3c)
-
-/* link_control(x) */
-#define	XB_CTRL_LINKALIVE_IE		0x80000000	/* link comes alive */
-     /* reserved:			0x40000000 */
-#define	XB_CTRL_PERF_CTR_MODE_MSK	0x30000000	/* perf counter mode */
-#define	XB_CTRL_IBUF_LEVEL_MSK		0x0e000000	/* input packet buffer level */
-#define	XB_CTRL_8BIT_MODE		0x01000000	/* force link into 8 bit mode */
-#define XB_CTRL_BAD_LLP_PKT		0x00800000	/* force bad LLP packet */
-#define XB_CTRL_WIDGET_CR_MSK		0x007c0000	/* LLP widget credit mask */
-#define XB_CTRL_WIDGET_CR_SHFT	18			/* LLP widget credit shift */
-#define XB_CTRL_ILLEGAL_DST_IE		0x00020000	/* illegal destination */
-#define XB_CTRL_OALLOC_IBUF_IE		0x00010000	/* overallocated input buffer */
-     /* reserved:			0x0000fe00 */
-#define XB_CTRL_BNDWDTH_ALLOC_IE	0x00000100	/* bandwidth alloc */
-#define XB_CTRL_RCV_CNT_OFLOW_IE	0x00000080	/* rcv retry overflow */
-#define XB_CTRL_XMT_CNT_OFLOW_IE	0x00000040	/* xmt retry overflow */
-#define XB_CTRL_XMT_MAX_RTRY_IE		0x00000020	/* max transmit retry */
-#define XB_CTRL_RCV_IE			0x00000010	/* receive */
-#define XB_CTRL_XMT_RTRY_IE		0x00000008	/* transmit retry */
-     /* reserved:			0x00000004 */
-#define	XB_CTRL_MAXREQ_TOUT_IE		0x00000002	/* maximum request timeout */
-#define	XB_CTRL_SRC_TOUT_IE		0x00000001	/* source timeout */
-
-/* link_status(x) */
-#define	XB_STAT_LINKALIVE		XB_CTRL_LINKALIVE_IE
-     /* reserved:			0x7ff80000 */
-#define	XB_STAT_MULTI_ERR		0x00040000	/* multi error */
-#define	XB_STAT_ILLEGAL_DST_ERR		XB_CTRL_ILLEGAL_DST_IE
-#define	XB_STAT_OALLOC_IBUF_ERR		XB_CTRL_OALLOC_IBUF_IE
-#define	XB_STAT_BNDWDTH_ALLOC_ID_MSK	0x0000ff00	/* port bitmask */
-#define	XB_STAT_RCV_CNT_OFLOW_ERR	XB_CTRL_RCV_CNT_OFLOW_IE
-#define	XB_STAT_XMT_CNT_OFLOW_ERR	XB_CTRL_XMT_CNT_OFLOW_IE
-#define	XB_STAT_XMT_MAX_RTRY_ERR	XB_CTRL_XMT_MAX_RTRY_IE
-#define	XB_STAT_RCV_ERR			XB_CTRL_RCV_IE
-#define	XB_STAT_XMT_RTRY_ERR		XB_CTRL_XMT_RTRY_IE
-     /* reserved:			0x00000004 */
-#define	XB_STAT_MAXREQ_TOUT_ERR		XB_CTRL_MAXREQ_TOUT_IE
-#define	XB_STAT_SRC_TOUT_ERR		XB_CTRL_SRC_TOUT_IE
-
-/* link_aux_status(x) */
-#define	XB_AUX_STAT_RCV_CNT	0xff000000
-#define	XB_AUX_STAT_XMT_CNT	0x00ff0000
-#define	XB_AUX_STAT_TOUT_DST	0x0000ff00
-#define	XB_AUX_LINKFAIL_RST_BAD	0x00000040
-#define	XB_AUX_STAT_PRESENT	0x00000020
-#define	XB_AUX_STAT_PORT_WIDTH	0x00000010
-     /*	reserved:		0x0000000f */
-
-/*
- * link_arb_upper/link_arb_lower(x), (reg) should be the link_arb_upper
- * register if (x) is 0x8..0xb, link_arb_lower if (x) is 0xc..0xf
- */
-#define	XB_ARB_GBR_MSK		0x1f
-#define	XB_ARB_RR_MSK		0x7
-#define	XB_ARB_GBR_SHFT(x)	(((x) & 0x3) * 8)
-#define	XB_ARB_RR_SHFT(x)	(((x) & 0x3) * 8 + 5)
-#define	XB_ARB_GBR_CNT(reg,x)	((reg) >> XB_ARB_GBR_SHFT(x) & XB_ARB_GBR_MSK)
-#define	XB_ARB_RR_CNT(reg,x)	((reg) >> XB_ARB_RR_SHFT(x) & XB_ARB_RR_MSK)
-
-/* XBOW_WID_STAT */
-#define	XB_WID_STAT_LINK_INTR_SHFT	(24)
-#define	XB_WID_STAT_LINK_INTR_MASK	(0xFF << XB_WID_STAT_LINK_INTR_SHFT)
-#define	XB_WID_STAT_LINK_INTR(x)	(0x1 << (((x)&7) + XB_WID_STAT_LINK_INTR_SHFT))
-#define	XB_WID_STAT_WIDGET0_INTR	0x00800000
-#define XB_WID_STAT_SRCID_MASK		0x000003c0	/* Xbridge only */
-#define	XB_WID_STAT_REG_ACC_ERR		0x00000020
-#define XB_WID_STAT_RECV_TOUT		0x00000010	/* Xbridge only */
-#define XB_WID_STAT_ARB_TOUT		0x00000008	/* Xbridge only */
-#define	XB_WID_STAT_XTALK_ERR		0x00000004
-#define XB_WID_STAT_DST_TOUT		0x00000002	/* Xbridge only */
-#define	XB_WID_STAT_MULTI_ERR		0x00000001
-
-#define XB_WID_STAT_SRCID_SHFT		6
-
-/* XBOW_WID_CONTROL */
-#define XB_WID_CTRL_REG_ACC_IE		XB_WID_STAT_REG_ACC_ERR
-#define XB_WID_CTRL_RECV_TOUT		XB_WID_STAT_RECV_TOUT
-#define XB_WID_CTRL_ARB_TOUT		XB_WID_STAT_ARB_TOUT
-#define XB_WID_CTRL_XTALK_IE		XB_WID_STAT_XTALK_ERR
-
-/* XBOW_WID_INT_UPPER */
-/* defined in xwidget.h for WIDGET_INTDEST_UPPER_ADDR */
-
-/* XBOW WIDGET part number, in the ID register */
-#define XBOW_WIDGET_PART_NUM	0x0		/* crossbow */
-#define XXBOW_WIDGET_PART_NUM	0xd000		/* Xbridge */
-#define	XBOW_WIDGET_MFGR_NUM	0x0
-#define	XXBOW_WIDGET_MFGR_NUM	0x0
-#define PXBOW_WIDGET_PART_NUM   0xd100          /* PIC */
-
-#define	XBOW_REV_1_0		0x1	/* xbow rev 1.0 is "1" */
-#define	XBOW_REV_1_1		0x2	/* xbow rev 1.1 is "2" */
-#define XBOW_REV_1_2		0x3	/* xbow rev 1.2 is "3" */
-#define XBOW_REV_1_3		0x4	/* xbow rev 1.3 is "4" */
-#define XBOW_REV_2_0		0x5	/* xbow rev 2.0 is "5" */
-
-#define XXBOW_PART_REV_1_0		(XXBOW_WIDGET_PART_NUM << 4 | 0x1 )
-#define XXBOW_PART_REV_2_0		(XXBOW_WIDGET_PART_NUM << 4 | 0x2 )
-
-/* XBOW_WID_ARB_RELOAD */
-#define	XBOW_WID_ARB_RELOAD_INT	0x3f	/* GBR reload interval */
-
-#define IS_XBRIDGE_XBOW(wid) \
-        (XWIDGET_PART_NUM(wid) == XXBOW_WIDGET_PART_NUM && \
-                        XWIDGET_MFG_NUM(wid) == XXBOW_WIDGET_MFGR_NUM)
-
-#define IS_PIC_XBOW(wid) \
-        (XWIDGET_PART_NUM(wid) == PXBOW_WIDGET_PART_NUM && \
-                        XWIDGET_MFG_NUM(wid) == XXBOW_WIDGET_MFGR_NUM)
-
-#define XBOW_WAR_ENABLED(pv, widid) ((1 << XWIDGET_REV_NUM(widid)) & pv)
-
-#ifndef __ASSEMBLY__
-/*
- * XBOW Widget 0 Register formats.
- * Format for many of these registers are similar to the standard
- * widget register format described as part of xtalk specification
- * Standard widget register field format description is available in
- * xwidget.h
- * Following structures define the format for xbow widget 0 registers
- */
-/*
- * Xbow Widget 0 Command error word
- */
-typedef union xbw0_cmdword_u {
-    xbowreg_t               cmdword;
-    struct {
-	uint32_t              rsvd:8,		/* Reserved */
-                                barr:1,         /* Barrier operation */
-                                error:1,        /* Error Occured */
-                                vbpm:1,         /* Virtual Backplane message */
-                                gbr:1,  /* GBR enable ?                 */
-                                ds:2,   /* Data size                    */
-                                ct:1,   /* Is it a coherent transaction */
-                                tnum:5,         /* Transaction Number */
-                                pactyp:4,       /* Packet type: */
-                                srcid:4,        /* Source ID number */
-                                destid:4;       /* Desination ID number */
-
-    } xbw0_cmdfield;
-} xbw0_cmdword_t;
-
-#define	xbcmd_destid	xbw0_cmdfield.destid
-#define	xbcmd_srcid	xbw0_cmdfield.srcid
-#define	xbcmd_pactyp	xbw0_cmdfield.pactyp
-#define	xbcmd_tnum	xbw0_cmdfield.tnum
-#define	xbcmd_ct	xbw0_cmdfield.ct
-#define	xbcmd_ds	xbw0_cmdfield.ds
-#define	xbcmd_gbr	xbw0_cmdfield.gbr
-#define	xbcmd_vbpm	xbw0_cmdfield.vbpm
-#define	xbcmd_error	xbw0_cmdfield.error
-#define	xbcmd_barr	xbw0_cmdfield.barr
-
-/*
- * Values for field PACTYP in xbow error command word
- */
-#define	XBCMDTYP_READREQ	0	/* Read Request   packet  */
-#define	XBCMDTYP_READRESP	1	/* Read Response packet   */
-#define	XBCMDTYP_WRREQ_RESP	2	/* Write Request with response    */
-#define	XBCMDTYP_WRRESP		3	/* Write Response */
-#define	XBCMDTYP_WRREQ_NORESP	4	/* Write request with  No Response */
-#define	XBCMDTYP_FETCHOP	6	/* Fetch & Op packet      */
-#define	XBCMDTYP_STOREOP	8	/* Store & Op packet      */
-#define	XBCMDTYP_SPLPKT_REQ	0xE	/* Special packet request */
-#define	XBCMDTYP_SPLPKT_RESP	0xF	/* Special packet response        */
-
-/*
- * Values for field ds (datasize) in xbow error command word
- */
-#define	XBCMDSZ_DOUBLEWORD	0
-#define	XBCMDSZ_QUARTRCACHE	1
-#define	XBCMDSZ_FULLCACHE	2
-
-/*
- * Xbow widget 0 Status register format.
- */
-
-typedef union xbw0_status_u {
-    xbowreg_t               statusword;
-    struct {
-       uint32_t		mult_err:1,	/* Multiple error occurred */
-                                connect_tout:1, /* Connection timeout   */
-                                xtalk_err:1,    /* Xtalk pkt with error bit */
-                                /* End of Xbridge only */
-                                w0_arb_tout,    /* arbiter timeout err */
-                                w0_recv_tout,   /* receive timeout err */
-                                /* Xbridge only */
-                                regacc_err:1,   /* Reg Access error     */
-                                src_id:4,       /* source id. Xbridge only */
-                                resvd1:13,
-                                wid0intr:1;     /* Widget 0 err intr */
-    } xbw0_stfield;
-} xbw0_status_t;
-
-#define	xbst_linkXintr		xbw0_stfield.linkXintr
-#define	xbst_w0intr		xbw0_stfield.wid0intr
-#define	xbst_regacc_err		xbw0_stfield.regacc_err
-#define	xbst_xtalk_err		xbw0_stfield.xtalk_err
-#define	xbst_connect_tout	xbw0_stfield.connect_tout
-#define	xbst_mult_err		xbw0_stfield.mult_err
-#define xbst_src_id		xbw0_stfield.src_id	    /* Xbridge only */
-#define xbst_w0_recv_tout	xbw0_stfield.w0_recv_tout   /* Xbridge only */
-#define xbst_w0_arb_tout	xbw0_stfield.w0_arb_tout    /* Xbridge only */
-
-/*
- * Xbow widget 0 Control register format
- */
-
-typedef union xbw0_ctrl_u {
-    xbowreg_t               ctrlword;
-    struct {
-	uint32_t              
-				resvd3:1,
-                                conntout_intr:1,
-                                xtalkerr_intr:1,
-                                w0_arg_tout_intr:1,     /* Xbridge only */
-                                w0_recv_tout_intr:1,    /* Xbridge only */
-                                accerr_intr:1,
-                                enable_w0_tout_cntr:1,  /* Xbridge only */
-                                enable_watchdog:1,      /* Xbridge only */
-                                resvd1:24;
-    } xbw0_ctrlfield;
-} xbw0_ctrl_t;
-
-typedef union xbow_linkctrl_u {
-    xbowreg_t               xbl_ctrlword;
-    struct {
-	uint32_t 		srcto_intr:1,
-                                maxto_intr:1, 
-                                rsvd3:1,
-                                trx_retry_intr:1, 
-                                rcv_err_intr:1, 
-                                trx_max_retry_intr:1,
-                                trxov_intr:1, 
-                                rcvov_intr:1,
-                                bwalloc_intr:1, 
-                                rsvd2:7, 
-                                obuf_intr:1,
-                                idest_intr:1, 
-                                llp_credit:5, 
-                                force_badllp:1,
-                                send_bm8:1, 
-                                inbuf_level:3, 
-                                perf_mode:2,
-                                rsvd1:1, 
-       		                alive_intr:1;
-
-    } xb_linkcontrol;
-} xbow_linkctrl_t;
-
-#define	xbctl_accerr_intr	(xbw0_ctrlfield.accerr_intr)
-#define	xbctl_xtalkerr_intr	(xbw0_ctrlfield.xtalkerr_intr)
-#define	xbctl_cnntout_intr	(xbw0_ctrlfield.conntout_intr)
-
-#define	XBW0_CTRL_ACCERR_INTR	(1 << 5)
-#define	XBW0_CTRL_XTERR_INTR	(1 << 2)
-#define	XBW0_CTRL_CONNTOUT_INTR	(1 << 1)
-
-/*
- * Xbow Link specific Registers structure definitions.
- */
-
-typedef union xbow_linkX_status_u {
-    xbowreg_t               linkstatus;
-    struct {
-	uint32_t               pkt_toutsrc:1,
-                                pkt_toutconn:1, /* max_req_tout in Xbridge */
-                                pkt_toutdest:1, /* reserved in Xbridge */
-                                llp_xmitretry:1,
-                                llp_rcverror:1,
-                                llp_maxtxretry:1,
-                                llp_txovflow:1,
-                                llp_rxovflow:1,
-                                bw_errport:8,   /* BW allocation error port   */
-                                ioe:1,          /* Input overallocation error */
-                                illdest:1,
-                                merror:1,
-                                resvd1:12,
-				alive:1;
-    } xb_linkstatus;
-} xbwX_stat_t;
-
-#define	link_alive		xb_linkstatus.alive
-#define	link_multierror		xb_linkstatus.merror
-#define	link_illegal_dest	xb_linkstatus.illdest
-#define	link_ioe		xb_linkstatus.ioe
-#define link_max_req_tout	xb_linkstatus.pkt_toutconn  /* Xbridge */
-#define link_pkt_toutconn	xb_linkstatus.pkt_toutconn  /* Xbow */
-#define link_pkt_toutdest	xb_linkstatus.pkt_toutdest
-#define	link_pkt_toutsrc	xb_linkstatus.pkt_toutsrc
-
-typedef union xbow_aux_linkX_status_u {
-    xbowreg_t               aux_linkstatus;
-    struct {
-	uint32_t 		rsvd2:4,
-                                bit_mode_8:1,
-                                wid_present:1,
-                                fail_mode:1,
-                                rsvd1:1,
-                                to_src_loc:8,
-                                tx_retry_cnt:8,
-				rx_err_cnt:8;
-    } xb_aux_linkstatus;
-} xbow_aux_link_status_t;
-
-typedef union xbow_perf_count_u {
-    xbowreg_t               xb_counter_val;
-    struct {
-        uint32_t 		count:20,
-                                link_select:3,
-				rsvd:9;
-    } xb_perf;
-} xbow_perfcount_t;
-
-#define XBOW_COUNTER_MASK	0xFFFFF
-
-extern int              xbow_widget_present(xbow_t * xbow, int port);
-
-extern xwidget_intr_preset_f xbow_intr_preset;
-extern xswitch_reset_link_f xbow_reset_link;
-void                    xbow_mlreset(xbow_t *);
-
-/* ========================================================================
- */
-
-#ifdef	MACROFIELD_LINE
-/*
- * This table forms a relation between the byte offset macros normally
- * used for ASM coding and the calculated byte offsets of the fields
- * in the C structure.
- *
- * See xbow_check.c xbow_html.c for further details.
- */
-#ifndef MACROFIELD_LINE_BITFIELD
-#define MACROFIELD_LINE_BITFIELD(m)	/* ignored */
-#endif
-
-struct macrofield_s     xbow_macrofield[] =
-{
-
-    MACROFIELD_LINE(XBOW_WID_ID, xb_wid_id)
-    MACROFIELD_LINE(XBOW_WID_STAT, xb_wid_stat)
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_LINK_INTR(0xF))
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_LINK_INTR(0xE))
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_LINK_INTR(0xD))
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_LINK_INTR(0xC))
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_LINK_INTR(0xB))
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_LINK_INTR(0xA))
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_LINK_INTR(0x9))
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_LINK_INTR(0x8))
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_WIDGET0_INTR)
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_REG_ACC_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_XTALK_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_WID_STAT_MULTI_ERR)
-    MACROFIELD_LINE(XBOW_WID_ERR_UPPER, xb_wid_err_upper)
-    MACROFIELD_LINE(XBOW_WID_ERR_LOWER, xb_wid_err_lower)
-    MACROFIELD_LINE(XBOW_WID_CONTROL, xb_wid_control)
-    MACROFIELD_LINE_BITFIELD(XB_WID_CTRL_REG_ACC_IE)
-    MACROFIELD_LINE_BITFIELD(XB_WID_CTRL_XTALK_IE)
-    MACROFIELD_LINE(XBOW_WID_REQ_TO, xb_wid_req_timeout)
-    MACROFIELD_LINE(XBOW_WID_INT_UPPER, xb_wid_int_upper)
-    MACROFIELD_LINE(XBOW_WID_INT_LOWER, xb_wid_int_lower)
-    MACROFIELD_LINE(XBOW_WID_ERR_CMDWORD, xb_wid_err_cmdword)
-    MACROFIELD_LINE(XBOW_WID_LLP, xb_wid_llp)
-    MACROFIELD_LINE(XBOW_WID_STAT_CLR, xb_wid_stat_clr)
-    MACROFIELD_LINE(XBOW_WID_ARB_RELOAD, xb_wid_arb_reload)
-    MACROFIELD_LINE(XBOW_WID_PERF_CTR_A, xb_perf_ctr_a)
-    MACROFIELD_LINE(XBOW_WID_PERF_CTR_B, xb_perf_ctr_b)
-    MACROFIELD_LINE(XBOW_WID_NIC, xb_nic)
-    MACROFIELD_LINE(XB_LINK_REG_BASE(8), xb_link(8))
-    MACROFIELD_LINE(XB_LINK_IBUF_FLUSH(8), xb_link(8).link_ibf)
-    MACROFIELD_LINE(XB_LINK_CTRL(8), xb_link(8).link_control)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_LINKALIVE_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_PERF_CTR_MODE_MSK)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_IBUF_LEVEL_MSK)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_8BIT_MODE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_BAD_LLP_PKT)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_WIDGET_CR_MSK)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_ILLEGAL_DST_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_OALLOC_IBUF_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_BNDWDTH_ALLOC_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_RCV_CNT_OFLOW_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_XMT_CNT_OFLOW_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_XMT_MAX_RTRY_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_RCV_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_XMT_RTRY_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_MAXREQ_TOUT_IE)
-    MACROFIELD_LINE_BITFIELD(XB_CTRL_SRC_TOUT_IE)
-    MACROFIELD_LINE(XB_LINK_STATUS(8), xb_link(8).link_status)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_LINKALIVE)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_MULTI_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_ILLEGAL_DST_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_OALLOC_IBUF_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_BNDWDTH_ALLOC_ID_MSK)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_RCV_CNT_OFLOW_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_XMT_CNT_OFLOW_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_XMT_MAX_RTRY_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_RCV_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_XMT_RTRY_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_MAXREQ_TOUT_ERR)
-    MACROFIELD_LINE_BITFIELD(XB_STAT_SRC_TOUT_ERR)
-    MACROFIELD_LINE(XB_LINK_ARB_UPPER(8), xb_link(8).link_arb_upper)
-    MACROFIELD_LINE_BITFIELD(XB_ARB_RR_MSK << XB_ARB_RR_SHFT(0xb))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(0xb))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_RR_MSK << XB_ARB_RR_SHFT(0xa))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(0xa))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_RR_MSK << XB_ARB_RR_SHFT(0x9))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(0x9))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_RR_MSK << XB_ARB_RR_SHFT(0x8))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(0x8))
-    MACROFIELD_LINE(XB_LINK_ARB_LOWER(8), xb_link(8).link_arb_lower)
-    MACROFIELD_LINE_BITFIELD(XB_ARB_RR_MSK << XB_ARB_RR_SHFT(0xf))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(0xf))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_RR_MSK << XB_ARB_RR_SHFT(0xe))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(0xe))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_RR_MSK << XB_ARB_RR_SHFT(0xd))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(0xd))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_RR_MSK << XB_ARB_RR_SHFT(0xc))
-    MACROFIELD_LINE_BITFIELD(XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(0xc))
-    MACROFIELD_LINE(XB_LINK_STATUS_CLR(8), xb_link(8).link_status_clr)
-    MACROFIELD_LINE(XB_LINK_RESET(8), xb_link(8).link_reset)
-    MACROFIELD_LINE(XB_LINK_AUX_STATUS(8), xb_link(8).link_aux_status)
-    MACROFIELD_LINE_BITFIELD(XB_AUX_STAT_RCV_CNT)
-    MACROFIELD_LINE_BITFIELD(XB_AUX_STAT_XMT_CNT)
-    MACROFIELD_LINE_BITFIELD(XB_AUX_LINKFAIL_RST_BAD)
-    MACROFIELD_LINE_BITFIELD(XB_AUX_STAT_PRESENT)
-    MACROFIELD_LINE_BITFIELD(XB_AUX_STAT_PORT_WIDTH)
-    MACROFIELD_LINE_BITFIELD(XB_AUX_STAT_TOUT_DST)
-    MACROFIELD_LINE(XB_LINK_REG_BASE(0x8), xb_link(0x8))
-    MACROFIELD_LINE(XB_LINK_REG_BASE(0x9), xb_link(0x9))
-    MACROFIELD_LINE(XB_LINK_REG_BASE(0xA), xb_link(0xA))
-    MACROFIELD_LINE(XB_LINK_REG_BASE(0xB), xb_link(0xB))
-    MACROFIELD_LINE(XB_LINK_REG_BASE(0xC), xb_link(0xC))
-    MACROFIELD_LINE(XB_LINK_REG_BASE(0xD), xb_link(0xD))
-    MACROFIELD_LINE(XB_LINK_REG_BASE(0xE), xb_link(0xE))
-    MACROFIELD_LINE(XB_LINK_REG_BASE(0xF), xb_link(0xF))
-};				/* xbow_macrofield[] */
-
-#endif				/* MACROFIELD_LINE */
-
-#endif				/* __ASSEMBLY__ */
-#endif                          /* _ASM_IA64_SN_XTALK_XBOW_H */
diff -Nru a/include/asm-ia64/sn/xtalk/xbow_info.h b/include/asm-ia64/sn/xtalk/xbow_info.h
--- a/include/asm-ia64/sn/xtalk/xbow_info.h	2004-12-24 13:37:01 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,21 +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) 1992-1997,2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-#ifndef _ASM_IA64_SN_XTALK_XBOW_INFO_H
-#define _ASM_IA64_SN_XTALK_XBOW_INFO_H
-
-#include <linux/types.h>
-
-#define XBOW_PERF_MODES	       0x03
-
-typedef struct xbow_link_status {
-    uint64_t              rx_err_count;
-    uint64_t              tx_retry_count;
-} xbow_link_status_t;
-
-
-#endif				/* _ASM_IA64_SN_XTALK_XBOW_INFO_H */
diff -Nru a/include/asm-ia64/sn/xtalk/xswitch.h b/include/asm-ia64/sn/xtalk/xswitch.h
--- a/include/asm-ia64/sn/xtalk/xswitch.h	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,56 +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) 1992-1997,2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-#ifndef _ASM_IA64_SN_XTALK_XSWITCH_H
-#define _ASM_IA64_SN_XTALK_XSWITCH_H
-
-/*
- * xswitch.h - controls the format of the data
- * provided by xswitch verticies back to the
- * xtalk bus providers.
- */
-
-#ifndef __ASSEMBLY__
-
-#include <asm/sn/xtalk/xtalk.h>
-
-typedef struct xswitch_info_s *xswitch_info_t;
-
-typedef int
-                        xswitch_reset_link_f(vertex_hdl_t xconn);
-
-typedef struct xswitch_provider_s {
-    xswitch_reset_link_f   *reset_link;
-} xswitch_provider_t;
-
-extern void             xswitch_provider_register(vertex_hdl_t sw_vhdl, xswitch_provider_t * xsw_fns);
-
-xswitch_reset_link_f    xswitch_reset_link;
-
-extern xswitch_info_t   xswitch_info_new(vertex_hdl_t vhdl);
-
-extern void             xswitch_info_link_is_ok(xswitch_info_t xswitch_info,
-						xwidgetnum_t port);
-extern void             xswitch_info_vhdl_set(xswitch_info_t xswitch_info,
-					      xwidgetnum_t port,
-					      vertex_hdl_t xwidget);
-extern void             xswitch_info_master_assignment_set(xswitch_info_t xswitch_info,
-						       xwidgetnum_t port,
-					       vertex_hdl_t master_vhdl);
-
-extern xswitch_info_t   xswitch_info_get(vertex_hdl_t vhdl);
-
-extern int              xswitch_info_link_ok(xswitch_info_t xswitch_info,
-					     xwidgetnum_t port);
-extern vertex_hdl_t     xswitch_info_vhdl_get(xswitch_info_t xswitch_info,
-					      xwidgetnum_t port);
-extern vertex_hdl_t     xswitch_info_master_assignment_get(xswitch_info_t xswitch_info,
-						      xwidgetnum_t port);
-
-#endif				/* __ASSEMBLY__ */
-
-#endif				/* _ASM_IA64_SN_XTALK_XSWITCH_H */
diff -Nru a/include/asm-ia64/sn/xtalk/xtalk.h b/include/asm-ia64/sn/xtalk/xtalk.h
--- a/include/asm-ia64/sn/xtalk/xtalk.h	2004-12-24 13:37:00 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,360 +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) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-#ifndef _ASM_IA64_SN_XTALK_XTALK_H
-#define _ASM_IA64_SN_XTALK_XTALK_H
-#include <linux/config.h>
-
-#ifdef __KERNEL__
-#include "asm/sn/sgi.h"
-#endif
-
-
-/*
- * xtalk.h -- platform-independent crosstalk interface
- */
-/*
- * User-level device driver visible types
- */
-typedef char            xwidgetnum_t;	/* xtalk widget number  (0..15) */
-
-#define XWIDGET_NONE		(-1)
-
-typedef int xwidget_part_num_t;	/* xtalk widget part number */
-
-#define XWIDGET_PART_NUM_NONE	(-1)
-
-typedef int             xwidget_rev_num_t;	/* xtalk widget revision number */
-
-#define XWIDGET_REV_NUM_NONE	(-1)
-
-typedef int xwidget_mfg_num_t;	/* xtalk widget manufacturing ID */
-
-#define XWIDGET_MFG_NUM_NONE	(-1)
-
-typedef struct xtalk_piomap_s *xtalk_piomap_t;
-
-/* It is often convenient to fold the XIO target port
- * number into the XIO address.
- */
-#define	XIO_NOWHERE	(0xFFFFFFFFFFFFFFFFull)
-#define	XIO_ADDR_BITS	(0x0000FFFFFFFFFFFFull)
-#define	XIO_PORT_BITS	(0xF000000000000000ull)
-#define	XIO_PORT_SHIFT	(60)
-
-#define	XIO_PACKED(x)	(((x)&XIO_PORT_BITS) != 0)
-#define	XIO_ADDR(x)	((x)&XIO_ADDR_BITS)
-#define	XIO_PORT(x)	((xwidgetnum_t)(((x)&XIO_PORT_BITS) >> XIO_PORT_SHIFT))
-#define	XIO_PACK(p,o)	((((uint64_t)(p))<<XIO_PORT_SHIFT) | ((o)&XIO_ADDR_BITS))
-
-
-/*
- * Kernel/driver only definitions
- */
-#ifdef __KERNEL__
-
-#include <asm/types.h>
-#include <asm/sn/types.h>
-#include <asm/sn/ioerror.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/dmamap.h>
-
-struct xwidget_hwid_s;
-
-/*
- *    Acceptable flag bits for xtalk service calls
- *
- * XTALK_FIXED: require that mappings be established
- *	using fixed sharable resources; address
- *	translation results will be permanently
- *	available. (PIOMAP_FIXED and DMAMAP_FIXED are
- *	the same numeric value and are acceptable).
- * XTALK_NOSLEEP: if any part of the operation would
- *	sleep waiting for resoruces, return an error
- *	instead. (PIOMAP_NOSLEEP and DMAMAP_NOSLEEP are
- *	the same numeric value and are acceptable).
- */
-#define	XTALK_FIXED		DMAMAP_FIXED
-#define	XTALK_NOSLEEP		DMAMAP_NOSLEEP
-
-/* PIO MANAGEMENT */
-typedef xtalk_piomap_t
-xtalk_piomap_alloc_f    (vertex_hdl_t dev,	/* set up mapping for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 iopaddr_t xtalk_addr,	/* map for this xtalk_addr range */
-			 size_t byte_count,
-			 size_t byte_count_max,		/* maximum size of a mapping */
-			 unsigned int flags);	/* defined in sys/pio.h */
-typedef void
-xtalk_piomap_free_f     (xtalk_piomap_t xtalk_piomap);
-
-typedef caddr_t
-xtalk_piomap_addr_f     (xtalk_piomap_t xtalk_piomap,	/* mapping resources */
-			 iopaddr_t xtalk_addr,	/* map for this xtalk address */
-			 size_t byte_count);	/* map this many bytes */
-
-typedef void
-xtalk_piomap_done_f     (xtalk_piomap_t xtalk_piomap);
-
-typedef caddr_t
-xtalk_piotrans_addr_f   (vertex_hdl_t dev,	/* translate for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 iopaddr_t xtalk_addr,	/* Crosstalk address */
-			 size_t byte_count,	/* map this many bytes */
-			 unsigned int flags);	/* (currently unused) */
-
-extern caddr_t
-xtalk_pio_addr		(vertex_hdl_t dev,	/* translate for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 iopaddr_t xtalk_addr,	/* Crosstalk address */
-			 size_t byte_count,	/* map this many bytes */
-			 xtalk_piomap_t *xtalk_piomapp,	/* RETURNS mapping resources */
-			 unsigned int flags);	/* (currently unused) */
-
-/* DMA MANAGEMENT */
-
-typedef struct xtalk_dmamap_s *xtalk_dmamap_t;
-
-typedef xtalk_dmamap_t
-xtalk_dmamap_alloc_f    (vertex_hdl_t dev,	/* set up mappings for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 size_t byte_count_max,		/* max size of a mapping */
-			 unsigned int flags);	/* defined in dma.h */
-
-typedef void
-xtalk_dmamap_free_f     (xtalk_dmamap_t dmamap);
-
-typedef iopaddr_t
-xtalk_dmamap_addr_f     (xtalk_dmamap_t dmamap,		/* use these mapping resources */
-			 paddr_t paddr,		/* map for this address */
-			 size_t byte_count);	/* map this many bytes */
-
-typedef void
-xtalk_dmamap_done_f     (xtalk_dmamap_t dmamap);
-
-typedef iopaddr_t
-xtalk_dmatrans_addr_f   (vertex_hdl_t dev,	/* translate for this device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 paddr_t paddr,		/* system physical address */
-			 size_t byte_count,	/* length */
-			 unsigned int flags);
-
-typedef void
-xtalk_dmamap_drain_f	(xtalk_dmamap_t map);	/* drain this map's channel */
-
-typedef void
-xtalk_dmaaddr_drain_f	(vertex_hdl_t vhdl,	/* drain channel from this device */
-			 paddr_t addr,		/* to this physical address */
-			 size_t bytes);		/* for this many bytes */
-
-/* INTERRUPT MANAGEMENT */
-
-/*
- * A xtalk interrupt resource handle.  When resources are allocated
- * in order to satisfy a xtalk_intr_alloc request, a xtalk_intr handle
- * is returned.  xtalk_intr_connect associates a software handler with
-
- * these system resources.
- */
-typedef struct xtalk_intr_s *xtalk_intr_t;
-
-
-/*
- * When a crosstalk device connects an interrupt, it passes in a function
- * that knows how to set its xtalk interrupt register appropriately.  The
- * low-level interrupt code may invoke this function later in order to
- * migrate an interrupt transparently to the device driver(s) that use this
- * interrupt.
- *
- * The argument passed to this function contains enough information for a
- * crosstalk device to (re-)target an interrupt.  A function of this type
- * must be supplied by every crosstalk driver.
- */
-typedef int
-xtalk_intr_setfunc_f    (xtalk_intr_t intr_hdl);	/* interrupt handle */
-
-typedef xtalk_intr_t
-xtalk_intr_alloc_f      (vertex_hdl_t dev,	/* which crosstalk device */
-			 device_desc_t dev_desc,	/* device descriptor */
-			 vertex_hdl_t owner_dev);	/* owner of this intr */
-
-typedef void
-xtalk_intr_free_f       (xtalk_intr_t intr_hdl);
-
-typedef int
-xtalk_intr_connect_f    (xtalk_intr_t intr_hdl,		/* xtalk intr resource handle */
-			intr_func_t intr_func,         /* xtalk intr handler */
-			void *intr_arg,	/* arg to intr handler */
-			xtalk_intr_setfunc_f *setfunc,		/* func to set intr hw */
-			void *setfunc_arg);	/* arg to setfunc */
-
-typedef void
-xtalk_intr_disconnect_f (xtalk_intr_t intr_hdl);
-
-typedef vertex_hdl_t
-xtalk_intr_cpu_get_f    (xtalk_intr_t intr_hdl);	/* xtalk intr resource handle */
-
-/* CONFIGURATION MANAGEMENT */
-
-typedef void
-xtalk_provider_startup_f (vertex_hdl_t xtalk_provider);
-
-typedef void
-xtalk_provider_shutdown_f (vertex_hdl_t xtalk_provider);
-
-typedef void
-xtalk_widgetdev_enable_f (vertex_hdl_t, int);
-
-typedef void
-xtalk_widgetdev_shutdown_f (vertex_hdl_t, int);
-
-/* Error Management */
-
-/* Early Action Support */
-typedef caddr_t
-xtalk_early_piotrans_addr_f (xwidget_part_num_t part_num,
-			     xwidget_mfg_num_t mfg_num,
-			     int which,
-			     iopaddr_t xtalk_addr,
-			     size_t byte_count,
-			     unsigned int flags);
-
-/*
- * Adapters that provide a crosstalk interface adhere to this software interface.
- */
-typedef struct xtalk_provider_s {
-    /* PIO MANAGEMENT */
-    xtalk_piomap_alloc_f   *piomap_alloc;
-    xtalk_piomap_free_f    *piomap_free;
-    xtalk_piomap_addr_f    *piomap_addr;
-    xtalk_piomap_done_f    *piomap_done;
-    xtalk_piotrans_addr_f  *piotrans_addr;
-
-    /* DMA MANAGEMENT */
-    xtalk_dmamap_alloc_f   *dmamap_alloc;
-    xtalk_dmamap_free_f    *dmamap_free;
-    xtalk_dmamap_addr_f    *dmamap_addr;
-    xtalk_dmamap_done_f    *dmamap_done;
-    xtalk_dmatrans_addr_f  *dmatrans_addr;
-    xtalk_dmamap_drain_f   *dmamap_drain;
-    xtalk_dmaaddr_drain_f  *dmaaddr_drain;
-
-    /* INTERRUPT MANAGEMENT */
-    xtalk_intr_alloc_f     *intr_alloc;
-    xtalk_intr_alloc_f     *intr_alloc_nothd;
-    xtalk_intr_free_f      *intr_free;
-    xtalk_intr_connect_f   *intr_connect;
-    xtalk_intr_disconnect_f *intr_disconnect;
-
-    /* CONFIGURATION MANAGEMENT */
-    xtalk_provider_startup_f *provider_startup;
-    xtalk_provider_shutdown_f *provider_shutdown;
-} xtalk_provider_t;
-
-/* Crosstalk devices use these standard Crosstalk provider interfaces */
-extern xtalk_piomap_alloc_f xtalk_piomap_alloc;
-extern xtalk_piomap_free_f xtalk_piomap_free;
-extern xtalk_piomap_addr_f xtalk_piomap_addr;
-extern xtalk_piomap_done_f xtalk_piomap_done;
-extern xtalk_piotrans_addr_f xtalk_piotrans_addr;
-extern xtalk_dmamap_alloc_f xtalk_dmamap_alloc;
-extern xtalk_dmamap_free_f xtalk_dmamap_free;
-extern xtalk_dmamap_addr_f xtalk_dmamap_addr;
-extern xtalk_dmamap_done_f xtalk_dmamap_done;
-extern xtalk_dmatrans_addr_f xtalk_dmatrans_addr;
-extern xtalk_dmamap_drain_f xtalk_dmamap_drain;
-extern xtalk_dmaaddr_drain_f xtalk_dmaaddr_drain;
-extern xtalk_intr_alloc_f xtalk_intr_alloc;
-extern xtalk_intr_alloc_f xtalk_intr_alloc_nothd;
-extern xtalk_intr_free_f xtalk_intr_free;
-extern xtalk_intr_connect_f xtalk_intr_connect;
-extern xtalk_intr_disconnect_f xtalk_intr_disconnect;
-extern xtalk_intr_cpu_get_f xtalk_intr_cpu_get;
-extern xtalk_provider_startup_f xtalk_provider_startup;
-extern xtalk_provider_shutdown_f xtalk_provider_shutdown;
-extern xtalk_widgetdev_enable_f xtalk_widgetdev_enable;
-extern xtalk_widgetdev_shutdown_f xtalk_widgetdev_shutdown;
-extern xtalk_early_piotrans_addr_f xtalk_early_piotrans_addr;
-
-/* error management */
-
-extern int              xtalk_error_handler(vertex_hdl_t,
-					    int,
-					    ioerror_mode_t,
-					    ioerror_t *);
-
-/*
- * Generic crosstalk interface, for use with all crosstalk providers
- * and all crosstalk devices.
- */
-typedef unchar xtalk_intr_vector_t;	/* crosstalk interrupt vector (0..255) */
-
-#define XTALK_INTR_VECTOR_NONE	(xtalk_intr_vector_t)0
-
-/* Generic crosstalk interrupt interfaces */
-extern vertex_hdl_t     xtalk_intr_dev_get(xtalk_intr_t xtalk_intr);
-extern xwidgetnum_t     xtalk_intr_target_get(xtalk_intr_t xtalk_intr);
-extern xtalk_intr_vector_t xtalk_intr_vector_get(xtalk_intr_t xtalk_intr);
-extern iopaddr_t        xtalk_intr_addr_get(xtalk_intr_t xtalk_intr);
-extern vertex_hdl_t     xtalk_intr_cpu_get(xtalk_intr_t xtalk_intr);
-extern void            *xtalk_intr_sfarg_get(xtalk_intr_t xtalk_intr);
-
-/* Generic crosstalk pio interfaces */
-extern vertex_hdl_t     xtalk_pio_dev_get(xtalk_piomap_t xtalk_piomap);
-extern xwidgetnum_t     xtalk_pio_target_get(xtalk_piomap_t xtalk_piomap);
-extern iopaddr_t        xtalk_pio_xtalk_addr_get(xtalk_piomap_t xtalk_piomap);
-extern size_t           xtalk_pio_mapsz_get(xtalk_piomap_t xtalk_piomap);
-extern caddr_t          xtalk_pio_kvaddr_get(xtalk_piomap_t xtalk_piomap);
-
-/* Generic crosstalk dma interfaces */
-extern vertex_hdl_t     xtalk_dma_dev_get(xtalk_dmamap_t xtalk_dmamap);
-extern xwidgetnum_t     xtalk_dma_target_get(xtalk_dmamap_t xtalk_dmamap);
-
-/* Register/unregister Crosstalk providers and get implementation handle */
-extern void             xtalk_set_early_piotrans_addr(xtalk_early_piotrans_addr_f *);
-extern void             xtalk_provider_register(vertex_hdl_t provider, xtalk_provider_t *xtalk_fns);
-extern void             xtalk_provider_unregister(vertex_hdl_t provider);
-extern xtalk_provider_t *xtalk_provider_fns_get(vertex_hdl_t provider);
-
-/* Crosstalk Switch generic layer, for use by initialization code */
-extern void             xswitch_census(vertex_hdl_t xswitchv);
-extern void             xswitch_init_widgets(vertex_hdl_t xswitchv);
-
-/* early init interrupt management */
-
-typedef void
-xwidget_intr_preset_f   (void *which_widget,
-			 int which_widget_intr,
-			 xwidgetnum_t targ,
-			 iopaddr_t addr,
-			 xtalk_intr_vector_t vect);
-
-typedef void
-xtalk_intr_prealloc_f   (void *which_xtalk,
-			 xtalk_intr_vector_t xtalk_vector,
-			 xwidget_intr_preset_f *preset_func,
-			 void *which_widget,
-			 int which_widget_intr);
-
-typedef void
-xtalk_intr_preconn_f    (void *which_xtalk,
-			 xtalk_intr_vector_t xtalk_vector,
-			 intr_func_t intr_func,
-			 intr_arg_t intr_arg);
-
-
-#define XTALK_ADDR_TO_UPPER(xtalk_addr) (((iopaddr_t)(xtalk_addr) >> 32) & 0xffff)
-#define XTALK_ADDR_TO_LOWER(xtalk_addr) ((iopaddr_t)(xtalk_addr) & 0xffffffff)
-
-typedef xtalk_intr_setfunc_f *xtalk_intr_setfunc_t;
-
-typedef void		xtalk_iter_f(vertex_hdl_t vhdl);
-
-extern void		xtalk_iterate(char *prefix, xtalk_iter_f *func);
-
-#endif				/* __KERNEL__ */
-#endif				/* _ASM_IA64_SN_XTALK_XTALK_H */
diff -Nru a/include/asm-ia64/sn/xtalk/xtalk_private.h b/include/asm-ia64/sn/xtalk/xtalk_private.h
--- a/include/asm-ia64/sn/xtalk/xtalk_private.h	2004-12-24 13:37:02 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,79 +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) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- */
-#ifndef _ASM_IA64_SN_XTALK_XTALK_PRIVATE_H
-#define _ASM_IA64_SN_XTALK_XTALK_PRIVATE_H
-
-#include <asm/sn/ioerror.h>        /* for error function and arg types */
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/xtalk/xtalk.h>
-
-/*
- * xtalk_private.h -- private definitions for xtalk
- * crosstalk drivers should NOT include this file.
- */
-
-/*
- * All Crosstalk providers set up PIO using this information.
- */
-struct xtalk_piomap_s {
-    vertex_hdl_t            xp_dev;	/* a requestor of this mapping */
-    xwidgetnum_t            xp_target;	/* target (node's widget number) */
-    iopaddr_t               xp_xtalk_addr;	/* which crosstalk addr is mapped */
-    size_t                  xp_mapsz;	/* size of this mapping */
-    caddr_t                 xp_kvaddr;	/* kernel virtual address to use */
-};
-
-/*
- * All Crosstalk providers set up DMA using this information.
- */
-struct xtalk_dmamap_s {
-    vertex_hdl_t            xd_dev;	/* a requestor of this mapping */
-    xwidgetnum_t            xd_target;	/* target (node's widget number) */
-};
-
-/*
- * All Crosstalk providers set up interrupts using this information.
- */
-struct xtalk_intr_s {
-    vertex_hdl_t            xi_dev;	/* requestor of this intr */
-    xwidgetnum_t            xi_target;	/* master's widget number */
-    xtalk_intr_vector_t     xi_vector;	/* 8-bit interrupt vector */
-    iopaddr_t               xi_addr;	/* xtalk address to generate intr */
-    void                   *xi_sfarg;	/* argument for setfunc */
-    xtalk_intr_setfunc_t    xi_setfunc;		/* device's setfunc routine */
-};
-
-/*
- * Xtalk interrupt handler structure access functions
- */
-#define	xwidget_hwid_is_sn1_xswitch(_hwid)	\
-		(((_hwid)->part_num == XXBOW_WIDGET_PART_NUM ||		\
-		  (_hwid)->part_num == PXBOW_WIDGET_PART_NUM) &&  	\
-		 ((_hwid)->mfg_num == XXBOW_WIDGET_MFGR_NUM ))
-
-#define	xwidget_hwid_is_xswitch(_hwid)	\
-			xwidget_hwid_is_sn1_xswitch(_hwid)
-
-/* common iograph info for all widgets,
- * stashed in FASTINFO of widget connection points.
- */
-struct xwidget_info_s {
-    char                   *w_fingerprint;
-    vertex_hdl_t            w_vertex;	/* back pointer to vertex */
-    xwidgetnum_t            w_id;	/* widget id */
-    struct xwidget_hwid_s   w_hwid;	/* hardware identification (part/rev/mfg) */
-    vertex_hdl_t            w_master;	/* CACHED widget's master */
-    xwidgetnum_t            w_masterid;		/* CACHED widget's master's widgetnum */
-    error_handler_f        *w_efunc;	/* error handling function */
-    error_handler_arg_t     w_einfo;	/* first parameter for efunc */
-    char		   *w_name;	/* canonical hwgraph name */	
-};
-
-extern char             widget_info_fingerprint[];
-
-#endif				/* _ASM_IA64_SN_XTALK_XTALK_PRIVATE_H */
diff -Nru a/include/asm-ia64/sn/xtalk/xtalkaddrs.h b/include/asm-ia64/sn/xtalk/xtalkaddrs.h
--- a/include/asm-ia64/sn/xtalk/xtalkaddrs.h	2004-12-24 13:37:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,106 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- */
-#ifndef _ASM_IA64_SN_XTALK_XTALKADDRS_H
-#define _ASM_IA64_SN_XTALK_XTALKADDRS_H
-
-
-/*
- * CrossTalk to SN0 Hub addressing support
- *
- * This file defines the mapping conventions used by the Hub's
- * I/O interface when it receives a read or write request from 
- * a CrossTalk widget.  
- *
- * Format for non-Memory accesses:
- *
- *  +--------------+------------------------------------------------+
- *  | 0  | XXXXX   |        SN0Addr                                |
- *  +----+---------+------------------------------------------------+
- *    47  46     40 39                                             0
- *	bit 47 indicates Memory (0)
- *	bits 46..40 are unused
- *	bits 39..0 hold the memory address
- *			(bits 39..31 hold the nodeID in N mode
- *			 bits 39..32 hold the nodeID in M mode
- * By design, this looks exactly like a 0-extended SN0 Address, so
- * we don't need to do any conversions.
- *
- *
- *
- * Format for non-Memory accesses:
- *
- *  +--------------+------+---------+------+--+---------------------+
- *  | 1  | DstNode | XXXX | BigW=0  | SW=1 | 1|   Addr              |
- *  +----+---------+------+---------+------+--+---------------------+
- *    47  46     38 37  31 30     28 27  24 23 22                  0
- *
- *	bit 47 indicates IO (1)
- *      bits 46..38 hold the destination node ID
- *      bits 37..31 are unused
- *      bits 30..28 hold the big window being addressed
- *      bits 27..24 hold the small window being addressed
- *                  0 always refers to the xbow
- *                  1 always refers to the hub itself
- *      bit 23 indicates local (0) or remote (1)
- *             no accessing checks are done if this bit is 0
- *      bits 22..0 hold the register address
- *                 bits 22..21 determine which section of the hub
- *                              00 -> PI
- *                              01 -> MD
- *                              10 -> IO
- *                              11 -> NI
- * This looks very much like a REMOTE_HUB access, except the nodeID
- * is in a different place, and the highest xtalk bit is set.
- */
-/* Hub-specific xtalk definitions */
-
-#define HX_MEM_BIT		0L	/* Hub's idea of xtalk memory access */
-#define HX_IO_BIT		1L	/* Hub's idea of xtalk register access */
-#define HX_ACCTYPE_SHIFT	47
-
-#define HX_NODE_SHIFT		39
-
-#define HX_BIGWIN_SHIFT		28
-#define HX_SWIN_SHIFT		23
-
-#define HX_LOCACC		0L	/* local access */
-#define HX_REMACC		1L	/* remote access */
-#define HX_ACCESS_SHIFT		23
-
-/*
- * Pre-calculate the fixed portion of a crosstalk address that maps
- * to local register space on a hub.
- */
-#define HX_REG_BASE		((HX_IO_BIT<<HX_ACCTYPE_SHIFT) + \
-				(0L<<HX_BIGWIN_SHIFT) + \
-				(1L<<HX_SWIN_SHIFT) + IALIAS_SIZE + \
-				(HX_REMACC<<HX_ACCESS_SHIFT))
-
-/* 
- * Return a crosstalk address which a widget can use to access a
- * designated register on a designated node.
- */
-#define HUBREG_AS_XTALKADDR(nasid, regaddr) \
-	((iopaddr_t)(HX_REG_BASE + (((long)nasid)<<HX_NODE_SHIFT) + ((long)regaddr)))
-
-#if TBD
-#assert sizeof(iopaddr_t) == 8
-#endif /* TBD */
-
-/*
- * Get widget part number, given node id and widget id. 
- * Always do a 32-bit read, because some widgets, e.g., Bridge, require so.
- * Widget ID is at offset 0 for 64-bit access.  Add 4 to get lower 32 bits
- * in big endian mode. 
- * XXX Double check this with Hub, Xbow, Bridge and other hardware folks.
- */
-#define XWIDGET_ID_READ(nasid, widget) \
-        (widgetreg_t)(*(volatile uint32_t *)(NODE_SWIN_BASE(nasid, widget) + WIDGET_ID))
-
-
-#endif /* _ASM_IA64_SN_XTALK_XTALKADDRS_H */
diff -Nru a/include/asm-ia64/sn/xtalk/xwidget.h b/include/asm-ia64/sn/xtalk/xwidget.h
--- a/include/asm-ia64/sn/xtalk/xwidget.h	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,240 +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) 1992-1997,2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- */
-#ifndef _ASM_IA64_SN_XTALK_XWIDGET_H
-#define _ASM_IA64_SN_XTALK_XWIDGET_H
-
-/*
- * xwidget.h - generic crosstalk widget header file
- */
-
-#ifdef __KERNEL__
-#include <asm/sn/xtalk/xtalk.h>
-#ifndef __ASSEMBLY__
-#include <asm/sn/cdl.h>
-#endif /* __ASSEMBLY__ */
-#else
-#include <xtalk/xtalk.h>
-#endif
-
-#define WIDGET_ID			0x00
-#define WIDGET_STATUS			0x08
-#define WIDGET_ERR_UPPER_ADDR		0x10
-#define WIDGET_ERR_LOWER_ADDR		0x18
-#define WIDGET_CONTROL			0x20
-#define WIDGET_REQ_TIMEOUT		0x28
-#define WIDGET_INTDEST_UPPER_ADDR	0x30
-#define WIDGET_INTDEST_LOWER_ADDR	0x38
-#define WIDGET_ERR_CMD_WORD		0x40
-#define WIDGET_LLP_CFG			0x48
-#define WIDGET_TFLUSH			0x50
-
-/* WIDGET_ID */
-#define WIDGET_REV_NUM			0xf0000000
-#define WIDGET_PART_NUM			0x0ffff000
-#define WIDGET_MFG_NUM			0x00000ffe
-#define WIDGET_REV_NUM_SHFT		28
-#define WIDGET_PART_NUM_SHFT		12
-#define WIDGET_MFG_NUM_SHFT		1
-
-#define XWIDGET_PART_NUM(widgetid) (((widgetid) & WIDGET_PART_NUM) >> WIDGET_PART_NUM_SHFT)
-#define XWIDGET_REV_NUM(widgetid) (((widgetid) & WIDGET_REV_NUM) >> WIDGET_REV_NUM_SHFT)
-#define XWIDGET_MFG_NUM(widgetid) (((widgetid) & WIDGET_MFG_NUM) >> WIDGET_MFG_NUM_SHFT)
-#define XWIDGET_PART_REV_NUM(widgetid) ((XWIDGET_PART_NUM(widgetid) << 4) | \
-					XWIDGET_REV_NUM(widgetid))
-#define XWIDGET_PART_REV_NUM_REV(partrev) (partrev & 0xf)
-
-/* WIDGET_STATUS */
-#define WIDGET_LLP_REC_CNT		0xff000000
-#define WIDGET_LLP_TX_CNT		0x00ff0000
-#define WIDGET_PENDING			0x0000001f
-
-/* WIDGET_ERR_UPPER_ADDR */
-#define	WIDGET_ERR_UPPER_ADDR_ONLY	0x0000ffff
-
-/* WIDGET_CONTROL */
-#define WIDGET_F_BAD_PKT		0x00010000
-#define WIDGET_LLP_XBAR_CRD		0x0000f000
-#define	WIDGET_LLP_XBAR_CRD_SHFT	12
-#define WIDGET_CLR_RLLP_CNT		0x00000800
-#define WIDGET_CLR_TLLP_CNT		0x00000400
-#define WIDGET_SYS_END			0x00000200
-#define WIDGET_MAX_TRANS		0x000001f0
-#define WIDGET_PCI_SPEED		0x00000030
-#define WIDGET_PCI_SPEED_SHFT		4
-#define WIDGET_PCI_SPEED_33MHZ 0
-#define WIDGET_PCI_SPEED_66MHZ 1
-#define WIDGET_WIDGET_ID		0x0000000f
-
-/* WIDGET_INTDEST_UPPER_ADDR */
-#define WIDGET_INT_VECTOR		0xff000000
-#define WIDGET_INT_VECTOR_SHFT		24
-#define WIDGET_TARGET_ID		0x000f0000
-#define WIDGET_TARGET_ID_SHFT		16
-#define WIDGET_UPP_ADDR			0x0000ffff
-
-/* WIDGET_ERR_CMD_WORD */
-#define WIDGET_DIDN			0xf0000000
-#define WIDGET_SIDN			0x0f000000
-#define WIDGET_PACTYP			0x00f00000
-#define WIDGET_TNUM			0x000f8000
-#define WIDGET_COHERENT			0x00004000
-#define WIDGET_DS			0x00003000
-#define WIDGET_GBR			0x00000800
-#define WIDGET_VBPM			0x00000400
-#define WIDGET_ERROR			0x00000200
-#define WIDGET_BARRIER			0x00000100
-
-/* WIDGET_LLP_CFG */
-#define WIDGET_LLP_MAXRETRY		0x03ff0000
-#define WIDGET_LLP_MAXRETRY_SHFT	16
-#define WIDGET_LLP_NULLTIMEOUT		0x0000fc00
-#define WIDGET_LLP_NULLTIMEOUT_SHFT	10
-#define WIDGET_LLP_MAXBURST		0x000003ff
-#define WIDGET_LLP_MAXBURST_SHFT	0
-
-/*
- * according to the crosstalk spec, only 32-bits access to the widget
- * configuration registers is allowed.  some widgets may allow 64-bits
- * access but software should not depend on it.  registers beyond the
- * widget target flush register are widget dependent thus will not be
- * defined here
- */
-#ifndef __ASSEMBLY__
-typedef uint32_t      widgetreg_t;
-
-/* widget configuration registers */
-typedef volatile struct widget_cfg {
-/*
- * we access these through synergy unswizzled space, so the address
- * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
- * That's why we put the register first and filler second.
- */
-    widgetreg_t		    w_id;	/* 0x04 */
-    widgetreg_t		    w_pad_0;	/* 0x00 */
-    widgetreg_t		    w_status;	/* 0x0c */
-    widgetreg_t		    w_pad_1;	/* 0x08 */
-    widgetreg_t		    w_err_upper_addr;	/* 0x14 */
-    widgetreg_t		    w_pad_2;	/* 0x10 */
-    widgetreg_t		    w_err_lower_addr;	/* 0x1c */
-    widgetreg_t		    w_pad_3;	/* 0x18 */
-    widgetreg_t		    w_control;	/* 0x24 */
-    widgetreg_t		    w_pad_4;	/* 0x20 */
-    widgetreg_t		    w_req_timeout;	/* 0x2c */
-    widgetreg_t		    w_pad_5;	/* 0x28 */
-    widgetreg_t		    w_intdest_upper_addr;	/* 0x34 */
-    widgetreg_t		    w_pad_6;	/* 0x30 */
-    widgetreg_t		    w_intdest_lower_addr;	/* 0x3c */
-    widgetreg_t		    w_pad_7;	/* 0x38 */
-    widgetreg_t		    w_err_cmd_word;	/* 0x44 */
-    widgetreg_t		    w_pad_8;	/* 0x40 */
-    widgetreg_t		    w_llp_cfg;	/* 0x4c */
-    widgetreg_t		    w_pad_9;	/* 0x48 */
-    widgetreg_t		    w_tflush;	/* 0x54 */
-    widgetreg_t		    w_pad_10;	/* 0x50 */
-} widget_cfg_t;
-
-typedef struct {
-    unsigned int            other:8;
-    unsigned int            bo:1;
-    unsigned int            error:1;
-    unsigned int            vbpm:1;
-    unsigned int            gbr:1;
-    unsigned int            ds:2;
-    unsigned int            ct:1;
-    unsigned int            tnum:5;
-    unsigned int            pactyp:4;
-    unsigned int            sidn:4;
-    unsigned int            didn:4;
-} w_err_cmd_word_f;
-
-typedef union {
-    w_err_cmd_word_f        f;
-    widgetreg_t             r;
-} w_err_cmd_word_u;
-
-/* IO widget initialization function */
-typedef struct xwidget_info_s *xwidget_info_t;
-
-/*
- * Crosstalk Widget Hardware Identification, as defined in the Crosstalk spec.
- */
-typedef struct xwidget_hwid_s {
-    xwidget_mfg_num_t       mfg_num;
-    xwidget_rev_num_t       rev_num;
-    xwidget_part_num_t      part_num;
-}                      *xwidget_hwid_t;
-
-
-/*
- * Returns 1 if a driver that handles devices described by hwid1 is able
- * to manage a device with hardwareid hwid2.  NOTE: We don't check rev
- * numbers at all.
- */
-#define XWIDGET_HARDWARE_ID_MATCH(hwid1, hwid2) \
-	(((hwid1)->part_num == (hwid2)->part_num) && \
-	(((hwid1)->mfg_num == XWIDGET_MFG_NUM_NONE) || \
-	((hwid2)->mfg_num == XWIDGET_MFG_NUM_NONE) || \
-	((hwid1)->mfg_num == (hwid2)->mfg_num)))
-
-
-/* Generic crosstalk widget initialization interface */
-#ifdef __KERNEL__
-
-extern int              xwidget_driver_register(xwidget_part_num_t part_num,
-						xwidget_mfg_num_t mfg_num,
-						char *driver_prefix,
-						unsigned int flags);
-
-extern void             xwidget_driver_unregister(char *driver_prefix);
-
-extern int              xwidget_register(struct xwidget_hwid_s *hwid,
-					 vertex_hdl_t dev,
-					 xwidgetnum_t id,
-					 vertex_hdl_t master,
-					 xwidgetnum_t targetid);
-
-extern int		xwidget_unregister(vertex_hdl_t);
-
-extern void             xwidget_reset(vertex_hdl_t xwidget);
-extern void             xwidget_gfx_reset(vertex_hdl_t xwidget);
-extern char		*xwidget_name_get(vertex_hdl_t xwidget);	
-
-/* Generic crosstalk widget information access interface */
-extern xwidget_info_t   xwidget_info_chk(vertex_hdl_t widget);
-extern xwidget_info_t   xwidget_info_get(vertex_hdl_t widget);
-extern void             xwidget_info_set(vertex_hdl_t widget, xwidget_info_t widget_info);
-extern vertex_hdl_t     xwidget_info_dev_get(xwidget_info_t xwidget_info);
-extern xwidgetnum_t     xwidget_info_id_get(xwidget_info_t xwidget_info);
-extern int              xwidget_info_type_get(xwidget_info_t xwidget_info);
-extern int              xwidget_info_state_get(xwidget_info_t xwidget_info);
-extern vertex_hdl_t     xwidget_info_master_get(xwidget_info_t xwidget_info);
-extern xwidgetnum_t     xwidget_info_masterid_get(xwidget_info_t xwidget_info);
-extern xwidget_part_num_t xwidget_info_part_num_get(xwidget_info_t xwidget_info);
-extern xwidget_rev_num_t xwidget_info_rev_num_get(xwidget_info_t xwidget_info);
-extern xwidget_mfg_num_t xwidget_info_mfg_num_get(xwidget_info_t xwidget_info);
-
-extern xwidgetnum_t hub_widget_id(nasid_t);
-
-
-
-/*
- * TBD: DELETE THIS ENTIRE STRUCTURE!  Equivalent is now in
- * xtalk_private.h: xwidget_info_s
- * This is just here for now because we still have a lot of
- * junk referencing it.
- * However, since nobody looks inside ...
- */
-typedef struct v_widget_s {
-    unsigned int                v_widget_s_is_really_empty;
-#define	v_widget_s_is_really_empty	and using this would be a syntax error.
-} v_widget_t;
-#endif				/* _KERNEL */
-
-#endif				/* __ASSEMBLY__ */
-
-#endif				/* _ASM_IA64_SN_XTALK_XWIDGET_H */
diff -Nru a/include/asm-ia64/topology.h b/include/asm-ia64/topology.h
--- a/include/asm-ia64/topology.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-ia64/topology.h	2004-12-24 13:36:16 -08:00
@@ -40,10 +40,46 @@
  */
 #define node_to_first_cpu(node) (__ffs(node_to_cpumask(node)))
 
-/* Cross-node load balancing interval. */
-#define NODE_BALANCE_RATE 10
-
 void build_cpu_to_node_map(void);
+
+/* sched_domains SD_NODE_INIT for IA64 NUMA machines */
+#define SD_NODE_INIT (struct sched_domain) {		\
+	.span			= CPU_MASK_NONE,	\
+	.parent			= NULL,			\
+	.groups			= NULL,			\
+	.min_interval		= 80,			\
+	.max_interval		= 320,			\
+	.busy_factor		= 320,			\
+	.imbalance_pct		= 125,			\
+	.cache_hot_time		= (10*1000000),		\
+	.cache_nice_tries	= 1,			\
+	.per_cpu_gain		= 100,			\
+	.flags			= SD_LOAD_BALANCE	\
+				| SD_BALANCE_EXEC	\
+				| SD_WAKE_BALANCE,	\
+	.last_balance		= jiffies,		\
+	.balance_interval	= 1,			\
+	.nr_balance_failed	= 0,			\
+}
+
+/* sched_domains SD_ALLNODES_INIT for IA64 NUMA machines */
+#define SD_ALLNODES_INIT (struct sched_domain) {	\
+	.span			= CPU_MASK_NONE,	\
+	.parent			= NULL,			\
+	.groups			= NULL,			\
+	.min_interval		= 80,			\
+	.max_interval		= 320,			\
+	.busy_factor		= 320,			\
+	.imbalance_pct		= 125,			\
+	.cache_hot_time		= (10*1000000),		\
+	.cache_nice_tries	= 1,			\
+	.per_cpu_gain		= 100,			\
+	.flags			= SD_LOAD_BALANCE	\
+				| SD_BALANCE_EXEC,	\
+	.last_balance		= jiffies,		\
+	.balance_interval	= 100*(63+num_online_cpus())/64,   \
+	.nr_balance_failed	= 0,			\
+}
 
 #endif /* CONFIG_NUMA */
 
diff -Nru a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
--- a/include/asm-ia64/unistd.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-ia64/unistd.h	2004-12-24 13:36:18 -08:00
@@ -259,6 +259,10 @@
 #define __NR_mq_getsetattr		1267
 #define __NR_kexec_load			1268
 #define __NR_vserver			1269
+#define __NR_waitid			1270
+#define __NR_add_key			1271
+#define __NR_request_key		1272
+#define __NR_keyctl			1273
 
 #ifdef __KERNEL__
 
@@ -385,7 +389,7 @@
  * "Conditional" syscalls
  *
  * Note, this macro can only be used in the file which defines sys_ni_syscall, i.e., in
- * kernel/sys.c.  This version causes warnings because the declaration isn't a
+ * kernel/sys_ni.c.  This version causes warnings because the declaration isn't a
  * proper prototype, but we can't use __typeof__ either, because not all cond_syscall()
  * declarations have prototypes at the moment.
  */
diff -Nru a/include/asm-m32r/elf.h b/include/asm-m32r/elf.h
--- a/include/asm-m32r/elf.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-m32r/elf.h	2004-12-24 13:37:00 -08:00
@@ -24,47 +24,9 @@
 #define	R_M32R_HI16_SLO		8
 #define	R_M32R_LO16		9
 #define	R_M32R_SDA16		10
-#ifdef OLD_TYPE
-#define	R_M32R_GOT24		11
-#define	R_M32R_26_PLTREL	12
-#define	R_M32R_GOT16_HI_ULO	13
-#define	R_M32R_GOT16_HI_SLO	14
-#define	R_M32R_GOT16_LO		15
-#define	R_M32R_GOTPC24		16
-#define	R_M32R_COPY		17
-#define	R_M32R_GLOB_DAT		18
-#define	R_M32R_JMP_SLOT		19
-#define	R_M32R_RELATIVE		20
-#define	R_M32R_GNU_VTINHERIT	21
-#define	R_M32R_GNU_VTENTRY	22
-
-#define R_M32R_16_RELA		R_M32R_16
-#define R_M32R_32_RELA		R_M32R_32
-#define R_M32R_24_RELA		R_M32R_24
-#define R_M32R_10_PCREL_RELA	R_M32R_10_PCREL
-#define R_M32R_18_PCREL_RELA	R_M32R_18_PCREL
-#define R_M32R_26_PCREL_RELA	R_M32R_26_PCREL
-#define R_M32R_HI16_ULO_RELA	R_M32R_HI16_ULO
-#define R_M32R_HI16_SLO_RELA	R_M32R_HI16_SLO
-#define R_M32R_LO16_RELA	R_M32R_LO16
-#define R_M32R_SDA16_RELA	R_M32R_SDA16
-#else /* not OLD_TYPE */
 #define	R_M32R_GNU_VTINHERIT	11
 #define	R_M32R_GNU_VTENTRY	12
 
-#define	R_M32R_GOT24_SAMPLE		11 /* comflict */
-#define	R_M32R_26_PLTREL_SAMPLE	12 /* comflict */
-#define	R_M32R_GOT16_HI_ULO_SAMPLE	13
-#define	R_M32R_GOT16_HI_SLO_SAMPLE	14
-#define	R_M32R_GOT16_LO_SAMPLE		15
-#define	R_M32R_GOTPC24_SAMPLE		16
-#define	R_M32R_COPY_SAMPLE		17
-#define	R_M32R_GLOB_DAT_SAMPLE		18
-#define	R_M32R_JMP_SLOT_SAMPLE		19
-#define	R_M32R_RELATIVE_SAMPLE		20
-#define	R_M32R_GNU_VTINHERIT_SAMPLE	21
-#define	R_M32R_GNU_VTENTRY_SAMPLE	22
-
 #define R_M32R_16_RELA		33
 #define R_M32R_32_RELA		34
 #define R_M32R_24_RELA		35
@@ -92,7 +54,6 @@
 #define R_M32R_GOTPC_HI_ULO	59
 #define R_M32R_GOTPC_HI_SLO	60
 #define R_M32R_GOTPC_LO		61
-#endif /* not OLD_TYPE */
 
 #define R_M32R_NUM		256
 
@@ -154,7 +115,7 @@
    now struct_user_regs, they are different) */
 
 #define ELF_CORE_COPY_REGS(pr_reg, regs)  \
-	memcpy((char *)&pr_reg, (char *)&regs, sizeof (struct pt_regs));
+	memcpy((char *)pr_reg, (char *)regs, sizeof (struct pt_regs));
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this CPU supports.  */
diff -Nru a/include/asm-m32r/hardirq.h b/include/asm-m32r/hardirq.h
--- a/include/asm-m32r/hardirq.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-m32r/hardirq.h	2004-12-24 13:37:02 -08:00
@@ -13,33 +13,11 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
-
 #if NR_IRQS > 256
 #define HARDIRQ_BITS	9
 #else
 #define HARDIRQ_BITS	8
 #endif
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have
diff -Nru a/include/asm-m32r/ide.h b/include/asm-m32r/ide.h
--- a/include/asm-m32r/ide.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-m32r/ide.h	2004-12-24 13:36:55 -08:00
@@ -35,7 +35,7 @@
 static __inline__ int ide_default_irq(unsigned long base)
 {
 	switch (base) {
-#if defined(CONFIG_PLAT_M32700UT)
+#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2)
 		case 0x1f0: return PLD_IRQ_CFIREQ;
 		default:
 			return 0;
diff -Nru a/include/asm-m32r/io.h b/include/asm-m32r/io.h
--- a/include/asm-m32r/io.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-m32r/io.h	2004-12-24 13:36:49 -08:00
@@ -151,6 +151,9 @@
 #define __raw_readb readb
 #define __raw_readw readw
 #define __raw_readl readl
+#define readb_relaxed readb
+#define readw_relaxed readw
+#define readl_relaxed readl
 
 #define writeb(val, addr)  _writeb((val), (unsigned long)(addr))
 #define writew(val, addr)  _writew((val), (unsigned long)(addr))
@@ -159,10 +162,12 @@
 #define __raw_writew writew
 #define __raw_writel writel
 
+#define mmiowb()
+
 #define flush_write_buffers() do { } while (0)  /* M32R_FIXME */
 
 /**
- *	isa_check_signature		-	find BIOS signatures
+ *	check_signature		-	find BIOS signatures
  *	@io_addr: mmio address to check
  *	@signature:  signature block
  *	@length: length of signature
@@ -174,14 +179,14 @@
  *	check_signature.
  */
 
-static inline int isa_check_signature(unsigned long io_addr,
+static inline int check_signature(void __iomem *io_addr,
         const unsigned char *signature, int length)
 {
         int retval = 0;
 #if 0
-printk("isa_check_signature\n");
+printk("check_signature\n");
         do {
-                if (isa_readb(io_addr) != *signature)
+                if (readb(io_addr) != *signature)
                         goto out;
                 io_addr++;
                 signature++;
diff -Nru a/include/asm-m32r/m32102.h b/include/asm-m32r/m32102.h
--- a/include/asm-m32r/m32102.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-m32r/m32102.h	2004-12-24 13:37:00 -08:00
@@ -23,6 +23,34 @@
 #define M32R_CPM_PLLCR_PORTL     (0x08+M32R_CPM_OFFSET)
 
 /*
+ * DMA Controller registers.
+ */
+#define M32R_DMA_OFFSET		(0x000F8000+M32R_SFR_OFFSET)
+
+#define M32R_DMAEN_PORTL	(0x000+M32R_DMA_OFFSET)
+#define M32R_DMAISTS_PORTL	(0x004+M32R_DMA_OFFSET)
+#define M32R_DMAEDET_PORTL	(0x008+M32R_DMA_OFFSET)
+#define M32R_DMAASTS_PORTL	(0x00c+M32R_DMA_OFFSET)
+
+#define M32R_DMA0CR0_PORTL	(0x100+M32R_DMA_OFFSET)
+#define M32R_DMA0CR1_PORTL	(0x104+M32R_DMA_OFFSET)
+#define M32R_DMA0CSA_PORTL	(0x108+M32R_DMA_OFFSET)
+#define M32R_DMA0RSA_PORTL	(0x10c+M32R_DMA_OFFSET)
+#define M32R_DMA0CDA_PORTL	(0x110+M32R_DMA_OFFSET)
+#define M32R_DMA0RDA_PORTL	(0x114+M32R_DMA_OFFSET)
+#define M32R_DMA0CBCUT_PORTL	(0x118+M32R_DMA_OFFSET)
+#define M32R_DMA0RBCUT_PORTL	(0x11c+M32R_DMA_OFFSET)
+
+#define M32R_DMA1CR0_PORTL	(0x200+M32R_DMA_OFFSET)
+#define M32R_DMA1CR1_PORTL	(0x204+M32R_DMA_OFFSET)
+#define M32R_DMA1CSA_PORTL	(0x208+M32R_DMA_OFFSET)
+#define M32R_DMA1RSA_PORTL	(0x20c+M32R_DMA_OFFSET)
+#define M32R_DMA1CDA_PORTL	(0x210+M32R_DMA_OFFSET)
+#define M32R_DMA1RDA_PORTL	(0x214+M32R_DMA_OFFSET)
+#define M32R_DMA1CBCUT_PORTL	(0x218+M32R_DMA_OFFSET)
+#define M32R_DMA1RBCUT_PORTL	(0x21c+M32R_DMA_OFFSET)
+
+/*
  * Multi Function Timer registers.
  */
 #define M32R_MFT_OFFSET        (0x000FC000+M32R_SFR_OFFSET)
@@ -121,15 +149,15 @@
  */
 #define M32R_SIO_OFFSET  (0x000FD000+M32R_SFR_OFFSET)
 
-#define M32R_SIO0_CR_PORTL     (0x000+M32R_SIO_OFFSET)
-#define M32R_SIO0_MOD0_PORTL   (0x004+M32R_SIO_OFFSET)
-#define M32R_SIO0_MOD1_PORTL   (0x008+M32R_SIO_OFFSET)
-#define M32R_SIO0_STS_PORTL    (0x00C+M32R_SIO_OFFSET)
-#define M32R_SIO0_TRCR_PORTL   (0x010+M32R_SIO_OFFSET)
-#define M32R_SIO0_BAUR_PORTL   (0x014+M32R_SIO_OFFSET)
-#define M32R_SIO0_RBAUR_PORTL  (0x018+M32R_SIO_OFFSET)
-#define M32R_SIO0_TXB_PORTL    (0x01C+M32R_SIO_OFFSET)
-#define M32R_SIO0_RXB_PORTL    (0x020+M32R_SIO_OFFSET)
+#define M32R_SIO0_CR_PORTL    (0x000+M32R_SIO_OFFSET)
+#define M32R_SIO0_MOD0_PORTL  (0x004+M32R_SIO_OFFSET)
+#define M32R_SIO0_MOD1_PORTL  (0x008+M32R_SIO_OFFSET)
+#define M32R_SIO0_STS_PORTL   (0x00C+M32R_SIO_OFFSET)
+#define M32R_SIO0_TRCR_PORTL  (0x010+M32R_SIO_OFFSET)
+#define M32R_SIO0_BAUR_PORTL  (0x014+M32R_SIO_OFFSET)
+#define M32R_SIO0_RBAUR_PORTL (0x018+M32R_SIO_OFFSET)
+#define M32R_SIO0_TXB_PORTL   (0x01C+M32R_SIO_OFFSET)
+#define M32R_SIO0_RXB_PORTL   (0x020+M32R_SIO_OFFSET)
 
 /*
  * Interrupt Control Unit registers.
@@ -201,41 +229,41 @@
 #define M32R_ICUCR_ILEVEL6  (6UL<<0)   /* b29-b31: Interrupt priority level 6 */
 #define M32R_ICUCR_ILEVEL7  (7UL<<0)   /* b29-b31: Disable interrupt */
 
-#define  M32R_IRQ_INT0    (1)   /* INT0 */
-#define  M32R_IRQ_INT1    (2)   /* INT1 */
-#define  M32R_IRQ_INT2    (3)   /* INT2 */
-#define  M32R_IRQ_INT3    (4)   /* INT3 */
-#define  M32R_IRQ_INT4    (5)   /* INT4 */
-#define  M32R_IRQ_INT5    (6)   /* INT5 */
-#define  M32R_IRQ_INT6    (7)   /* INT6 */
-#define  M32R_IRQ_MFT0    (16)  /* MFT0 */
-#define  M32R_IRQ_MFT1    (17)  /* MFT1 */
-#define  M32R_IRQ_MFT2    (18)  /* MFT2 */
-#define  M32R_IRQ_MFT3    (19)  /* MFT3 */
-#define  M32R_IRQ_MFT4    (20)  /* MFT4 */
-#define  M32R_IRQ_MFT5    (21)  /* MFT5 */
-#define  M32R_IRQ_DMA0    (32)  /* DMA0 */
-#define  M32R_IRQ_DMA1    (33)  /* DMA1 */
-#define  M32R_IRQ_SIO0_R  (48)  /* SIO0 send    */
-#define  M32R_IRQ_SIO0_S  (49)  /* SIO0 receive */
-#define  M32R_IRQ_SIO1_R  (50)  /* SIO1 send    */
-#define  M32R_IRQ_SIO1_S  (51)  /* SIO1 receive */
-#define  M32R_IRQ_SIO2_R  (52)  /* SIO2 send    */
-#define  M32R_IRQ_SIO2_S  (53)  /* SIO2 receive */
-#define  M32R_IRQ_SIO3_R  (54)  /* SIO3 send    */
-#define  M32R_IRQ_SIO3_S  (55)  /* SIO3 receive */
-#define  M32R_IRQ_SIO4_R  (56)  /* SIO4 send    */
-#define  M32R_IRQ_SIO4_S  (57)  /* SIO4 receive */
+#define M32R_IRQ_INT0    (1)   /* INT0 */
+#define M32R_IRQ_INT1    (2)   /* INT1 */
+#define M32R_IRQ_INT2    (3)   /* INT2 */
+#define M32R_IRQ_INT3    (4)   /* INT3 */
+#define M32R_IRQ_INT4    (5)   /* INT4 */
+#define M32R_IRQ_INT5    (6)   /* INT5 */
+#define M32R_IRQ_INT6    (7)   /* INT6 */
+#define M32R_IRQ_MFT0    (16)  /* MFT0 */
+#define M32R_IRQ_MFT1    (17)  /* MFT1 */
+#define M32R_IRQ_MFT2    (18)  /* MFT2 */
+#define M32R_IRQ_MFT3    (19)  /* MFT3 */
+#define M32R_IRQ_MFT4    (20)  /* MFT4 */
+#define M32R_IRQ_MFT5    (21)  /* MFT5 */
+#define M32R_IRQ_DMA0    (32)  /* DMA0 */
+#define M32R_IRQ_DMA1    (33)  /* DMA1 */
+#define M32R_IRQ_SIO0_R  (48)  /* SIO0 send    */
+#define M32R_IRQ_SIO0_S  (49)  /* SIO0 receive */
+#define M32R_IRQ_SIO1_R  (50)  /* SIO1 send    */
+#define M32R_IRQ_SIO1_S  (51)  /* SIO1 receive */
+#define M32R_IRQ_SIO2_R  (52)  /* SIO2 send    */
+#define M32R_IRQ_SIO2_S  (53)  /* SIO2 receive */
+#define M32R_IRQ_SIO3_R  (54)  /* SIO3 send    */
+#define M32R_IRQ_SIO3_S  (55)  /* SIO3 receive */
+#define M32R_IRQ_SIO4_R  (56)  /* SIO4 send    */
+#define M32R_IRQ_SIO4_S  (57)  /* SIO4 receive */
 
 #ifdef CONFIG_SMP
-#define M32R_IRQ_IPI0 (56)
-#define M32R_IRQ_IPI1 (57)
-#define M32R_IRQ_IPI2 (58)
-#define M32R_IRQ_IPI3 (59)
-#define M32R_IRQ_IPI4 (60)
-#define M32R_IRQ_IPI5 (61)
-#define M32R_IRQ_IPI6 (62)
-#define M32R_IRQ_IPI7 (63)
+#define M32R_IRQ_IPI0    (56)
+#define M32R_IRQ_IPI1    (57)
+#define M32R_IRQ_IPI2    (58)
+#define M32R_IRQ_IPI3    (59)
+#define M32R_IRQ_IPI4    (60)
+#define M32R_IRQ_IPI5    (61)
+#define M32R_IRQ_IPI6    (62)
+#define M32R_IRQ_IPI7    (63)
 #define M32R_CPUID_PORTL (0xffffffe0)
 
 #define M32R_FPGA_TOP (0x000F0000+M32R_SFR_OFFSET)
diff -Nru a/include/asm-m32r/pgtable.h b/include/asm-m32r/pgtable.h
--- a/include/asm-m32r/pgtable.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-m32r/pgtable.h	2004-12-24 13:36:16 -08:00
@@ -408,7 +408,8 @@
 /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range	remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
diff -Nru a/include/asm-m32r/processor.h b/include/asm-m32r/processor.h
--- a/include/asm-m32r/processor.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-m32r/processor.h	2004-12-24 13:36:17 -08:00
@@ -1,28 +1,23 @@
 #ifndef _ASM_M32R_PROCESSOR_H
 #define _ASM_M32R_PROCESSOR_H
 
-/* $Id$ */
-
 /*
+ * include/asm-m32r/processor.h
+ *
  * 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  by Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
+ * Copyright (C) 1994  Linus Torvalds
+ * Copyright (C) 2001  Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
+ * Copyright (C) 2004  Hirokazu Takata <takata at linux-m32r.org>
  */
 
-/*
- * include/asm-m32r/processor.h
- *
- * Copyright (C) 1994 Linus Torvalds
- */
 #include <linux/kernel.h>
 #include <linux/config.h>
 #include <asm/cache.h>
 #include <asm/ptrace.h>  /* pt_regs */
 
-#include <asm/cachectl.h>
-
 /*
  * Default implementation of macro that returns current
  * instruction pointer ("program counter").
@@ -53,7 +48,7 @@
 extern struct cpuinfo_m32r cpu_data[];
 #define current_cpu_data cpu_data[smp_processor_id()]
 #else
-#define cpu_data &boot_cpu_data
+#define cpu_data (&boot_cpu_data)
 #define current_cpu_data boot_cpu_data
 #endif
 
@@ -141,17 +136,6 @@
 
 #define THREAD_SIZE (2*PAGE_SIZE)
 
-/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
-static __inline__ void rep_nop(void)
-{
-	__asm__ __volatile__(
-		"nop \n\t"
-		"nop \n\t"
-		:
-		:
-		: "memory");
-}
-
-#define cpu_relax()     rep_nop()
+#define cpu_relax()	barrier()
 
 #endif /* _ASM_M32R_PROCESSOR_H */
diff -Nru a/include/asm-m32r/rtc.h b/include/asm-m32r/rtc.h
--- a/include/asm-m32r/rtc.h	2004-12-24 13:37:31 -08:00
+++ b/include/asm-m32r/rtc.h	2004-12-24 13:37:31 -08:00
@@ -29,7 +29,7 @@
 #  define RTC_TCR_4KOHM 	0x02	/* xxxxxx10 4kOhm */
 #  define RTC_TCR_8KOHM 	0x03	/* xxxxxx11 8kOhm */
 
-#ifdef CONFIG_M32700UT_DS1302
+#ifdef CONFIG_DS1302
 extern unsigned char ds1302_readreg(int reg);
 extern void ds1302_writereg(int reg, unsigned char val);
 extern int ds1302_init(void);
diff -Nru a/include/asm-m32r/termbits.h b/include/asm-m32r/termbits.h
--- a/include/asm-m32r/termbits.h	2004-12-24 13:36:59 -08:00
+++ b/include/asm-m32r/termbits.h	2004-12-24 13:36:59 -08:00
@@ -136,6 +136,7 @@
 #define  B3500000 0010016
 #define  B4000000 0010017
 #define CIBAUD	  002003600000	/* input baud rate (not used) */
+#define CTVB	  004000000000		/* VisioBraille Terminal flow control */
 #define CMSPAR	  010000000000		/* mark or space (stick) parity */
 #define CRTSCTS	  020000000000		/* flow control */
 
diff -Nru a/include/asm-m32r/topology.h b/include/asm-m32r/topology.h
--- a/include/asm-m32r/topology.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-m32r/topology.h	2004-12-24 13:36:16 -08:00
@@ -45,9 +45,4 @@
 #define pcibus_to_cpumask(bus)	(cpu_online_map)
 #endif
 
-/* Cross-node load balancing interval. */
-#ifndef NODE_BALANCE_RATE
-#define NODE_BALANCE_RATE 10
-#endif
-
 #endif /* _ASM_M32R_TOPOLOGY_H */
diff -Nru a/include/asm-m68k/atomic.h b/include/asm-m68k/atomic.h
--- a/include/asm-m68k/atomic.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-m68k/atomic.h	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,8 @@
 #ifndef __ARCH_M68K_ATOMIC__
 #define __ARCH_M68K_ATOMIC__
 
+#include <linux/config.h>
+
 #include <asm/system.h>	/* local_irq_XXX() */
 
 /*
diff -Nru a/include/asm-m68k/blinken.h b/include/asm-m68k/blinken.h
--- a/include/asm-m68k/blinken.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-m68k/blinken.h	2004-12-24 13:36:18 -08:00
@@ -13,15 +13,20 @@
 #define _M68K_BLINKEN_H
 
 #include <asm/setup.h>
+#include <asm/io.h>
 
 #define HP300_LEDS		0xf001ffff
 
-static __inline__ void blinken_leds(int x)
+extern unsigned char ledstate;
+
+static __inline__ void blinken_leds(int on, int off)
 {
-  if (MACH_IS_HP300)
-  {
-    *((volatile unsigned char *)HP300_LEDS) = (x);
-  }
+	if (MACH_IS_HP300)
+	{
+		ledstate |= on;
+		ledstate &= ~off;
+		out_8(HP300_LEDS, ~ledstate);
+	}
 }
 
 #endif
diff -Nru a/include/asm-m68k/bootinfo.h b/include/asm-m68k/bootinfo.h
--- a/include/asm-m68k/bootinfo.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-m68k/bootinfo.h	2004-12-24 13:37:01 -08:00
@@ -213,7 +213,13 @@
 
 #define BI_APOLLO_MODEL         0x8000  /* model (u_long) */
 
+    /*
+     *  HP300-specific tags
+     */
 
+#define BI_HP300_MODEL		0x8000	/* model (u_long) */
+#define BI_HP300_UART_SCODE	0x8001	/* UART select code (u_long) */
+#define BI_HP300_UART_ADDR	0x8002	/* phys. addr of UART (u_long) */
 
     /*
      * Stuff for bootinfo interface versioning
@@ -255,6 +261,7 @@
 #define MVME16x_BOOTI_VERSION  MK_BI_VERSION( 2, 0 )
 #define BVME6000_BOOTI_VERSION MK_BI_VERSION( 2, 0 )
 #define Q40_BOOTI_VERSION      MK_BI_VERSION( 2, 0 )
+#define HP300_BOOTI_VERSION    MK_BI_VERSION( 2, 0 )
 
 #ifdef BOOTINFO_COMPAT_1_0
 
diff -Nru a/include/asm-m68k/hardirq.h b/include/asm-m68k/hardirq.h
--- a/include/asm-m68k/hardirq.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-m68k/hardirq.h	2004-12-24 13:36:49 -08:00
@@ -12,28 +12,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * HARDIRQ_MASK: 0x0000ff00
- * SOFTIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have
diff -Nru a/include/asm-m68k/hp300hw.h b/include/asm-m68k/hp300hw.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-m68k/hp300hw.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,25 @@
+#ifndef _M68K_HP300HW_H
+#define _M68K_HP300HW_H
+
+extern unsigned long hp300_model;
+
+/* This information was taken from NetBSD */
+#define	HP_320		(0)	/* 16MHz 68020+HP MMU+16K external cache */
+#define	HP_330		(1)	/* 16MHz 68020+68851 MMU */
+#define	HP_340		(2)	/* 16MHz 68030 */
+#define	HP_345		(3)	/* 50MHz 68030+32K external cache */
+#define	HP_350		(4)	/* 25MHz 68020+HP MMU+32K external cache */
+#define	HP_360		(5)	/* 25MHz 68030 */
+#define	HP_370		(6)	/* 33MHz 68030+64K external cache */
+#define	HP_375		(7)	/* 50MHz 68030+32K external cache */
+#define	HP_380		(8)	/* 25MHz 68040 */
+#define	HP_385		(9)	/* 33MHz 68040 */
+
+#define	HP_400		(10)	/* 50MHz 68030+32K external cache */
+#define	HP_425T		(11)	/* 25MHz 68040 - model 425t */
+#define	HP_425S		(12)	/* 25MHz 68040 - model 425s */
+#define HP_425E		(13)	/* 25MHz 68040 - model 425e */
+#define HP_433T		(14)	/* 33MHz 68040 - model 433t */
+#define HP_433S		(15)	/* 33MHz 68040 - model 433s */
+
+#endif /* _M68K_HP300HW_H */
diff -Nru a/include/asm-m68k/io.h b/include/asm-m68k/io.h
--- a/include/asm-m68k/io.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-m68k/io.h	2004-12-24 13:37:00 -08:00
@@ -306,6 +306,25 @@
 #endif
 #endif /* CONFIG_PCI */
 
+#if !defined(CONFIG_ISA) && !defined(CONFIG_PCI) && defined(CONFIG_HP300)
+/*
+ * We need to define dummy functions otherwise drivers/serial/8250.c doesn't link
+ */
+#define inb(port)        0xff
+#define inb_p(port)      0xff
+#define outb(val,port)   do { } while (0)
+#define outb_p(val,port) do { } while (0)
+
+/*
+ * These should be valid on any ioremap()ed region
+ */
+#define readb(addr)      in_8(addr)
+#define writeb(val,addr) out_8((addr),(val))
+#define readl(addr)      in_le32(addr)
+#define writel(val,addr) out_le32((addr),(val))
+#endif
+
+#define mmiowb()
 
 static inline void *ioremap(unsigned long physaddr, unsigned long size)
 {
diff -Nru a/include/asm-m68k/mc146818rtc.h b/include/asm-m68k/mc146818rtc.h
--- a/include/asm-m68k/mc146818rtc.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-m68k/mc146818rtc.h	2004-12-24 13:36:19 -08:00
@@ -4,6 +4,8 @@
 #ifndef _ASM_MC146818RTC_H
 #define _ASM_MC146818RTC_H
 
+#include <linux/config.h>
+
 #ifdef CONFIG_ATARI
 /* RTC in Atari machines */
 
diff -Nru a/include/asm-m68k/pgtable.h b/include/asm-m68k/pgtable.h
--- a/include/asm-m68k/pgtable.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-m68k/pgtable.h	2004-12-24 13:37:19 -08:00
@@ -138,7 +138,8 @@
 
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 /* MMU-specific headers */
 
diff -Nru a/include/asm-m68k/setup.h b/include/asm-m68k/setup.h
--- a/include/asm-m68k/setup.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-m68k/setup.h	2004-12-24 13:37:00 -08:00
@@ -264,7 +264,7 @@
 #  define MMU_IS_SUN3 (0)
 #elif defined(CONFIG_M68030) || defined(CONFIG_M68040) || defined(CONFIG_M68060)
 #  define CPU_IS_020 (m68k_cputype & CPU_68020)
-#  define MMU_IS_851 (m68k_cputype & MMU_68851)
+#  define MMU_IS_851 (m68k_mmutype & MMU_68851)
 #  define MMU_IS_SUN3 (0)	/* Sun3 not supported with other CPU enabled */
 #else
 #  define CPU_M68020_ONLY
diff -Nru a/include/asm-m68k/timex.h b/include/asm-m68k/timex.h
--- a/include/asm-m68k/timex.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-m68k/timex.h	2004-12-24 13:36:17 -08:00
@@ -7,10 +7,6 @@
 #define _ASMm68k_TIMEX_H
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 typedef unsigned long cycles_t;
 
diff -Nru a/include/asm-m68k/tlbflush.h b/include/asm-m68k/tlbflush.h
--- a/include/asm-m68k/tlbflush.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-m68k/tlbflush.h	2004-12-24 13:37:03 -08:00
@@ -1,6 +1,8 @@
 #ifndef _M68K_TLBFLUSH_H
 #define _M68K_TLBFLUSH_H
 
+#include <linux/config.h>
+
 #ifndef CONFIG_SUN3
 
 #include <asm/current.h>
diff -Nru a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h
--- a/include/asm-m68k/unistd.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-m68k/unistd.h	2004-12-24 13:36:49 -08:00
@@ -238,8 +238,54 @@
 #define __NR_lremovexattr	233
 #define __NR_fremovexattr	234
 #define __NR_futex		235
+#define __NR_sendfile64		236
+#define __NR_mincore		237
+#define __NR_madvise		238
+#define __NR_fcntl64		239
+#define __NR_readahead		240
+#define __NR_io_setup		241
+#define __NR_io_destroy		242
+#define __NR_io_getevents	243
+#define __NR_io_submit		244
+#define __NR_io_cancel		245
+#define __NR_fadvise64		246
+#define __NR_exit_group		247
+#define __NR_lookup_dcookie	248
+#define __NR_epoll_create	249
+#define __NR_epoll_ctl		250
+#define __NR_epoll_wait		251
+#define __NR_remap_file_pages	252
+#define __NR_set_tid_address	253
+#define __NR_timer_create	254
+#define __NR_timer_settime	255
+#define __NR_timer_gettime	256
+#define __NR_timer_getoverrun	257
+#define __NR_timer_delete	258
+#define __NR_clock_settime	259
+#define __NR_clock_gettime	260
+#define __NR_clock_getres	261
+#define __NR_clock_nanosleep	262
+#define __NR_statfs64		263
+#define __NR_fstatfs64		264
+#define __NR_tgkill		265
+#define __NR_utimes		266
+#define __NR_fadvise64_64	267
+#define __NR_mbind		268
+#define __NR_get_mempolicy	269
+#define __NR_set_mempolicy	270
+#define __NR_mq_open		271
+#define __NR_mq_unlink		272
+#define __NR_mq_timedsend	273
+#define __NR_mq_timedreceive	274
+#define __NR_mq_notify		275
+#define __NR_mq_getsetattr	276
+#define __NR_waitid		277
+#define __NR_vserver		278
+#define __NR_add_key		279
+#define __NR_request_key	280
+#define __NR_keyctl		281
 
-#define NR_syscalls		236
+#define NR_syscalls		282
 
 /* user-visible error numbers are in the range -1 - -124: see
    <asm-m68k/errno.h> */
diff -Nru a/include/asm-m68knommu/checksum.h b/include/asm-m68knommu/checksum.h
--- a/include/asm-m68knommu/checksum.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-m68knommu/checksum.h	2004-12-24 13:36:18 -08:00
@@ -1,6 +1,8 @@
 #ifndef _M68K_CHECKSUM_H
 #define _M68K_CHECKSUM_H
 
+#include <linux/in6.h>
+
 /*
  * computes the checksum of a memory block at buff, length len,
  * and adds in "sum" (32-bit)
diff -Nru a/include/asm-m68knommu/coldfire.h b/include/asm-m68knommu/coldfire.h
--- a/include/asm-m68knommu/coldfire.h	2004-12-24 13:36:34 -08:00
+++ b/include/asm-m68knommu/coldfire.h	2004-12-24 13:36:34 -08:00
@@ -22,7 +22,7 @@
 #define	MCF_MBAR2	0x80000000
 #define	MCF_IPSBAR	0x40000000
 
-#ifdef CONFIG_M5282
+#if defined(CONFIG_M527x) || defined(CONFIG_M528x)
 #undef MCF_MBAR
 #define	MCF_MBAR	MCF_IPSBAR
 #endif
@@ -60,8 +60,14 @@
 #define	MCF_CLK		66000000
 #elif defined(CONFIG_CLOCK_70MHz)
 #define	MCF_CLK		70000000
+#elif defined(CONFIG_CLOCK_100MHz)
+#define	MCF_CLK		100000000
 #elif defined(CONFIG_CLOCK_140MHz)
 #define	MCF_CLK		140000000
+#elif defined(CONFIG_CLOCK_150MHz)
+#define	MCF_CLK		150000000
+#elif defined(CONFIG_CLOCK_166MHz)
+#define	MCF_CLK		166000000
 #else
 #error "Don't know what your ColdFire CPU clock frequency is??"
 #endif
@@ -70,7 +76,7 @@
  *	One some ColdFire family members the bus clock (used by internal
  *	peripherals) is not the same as the CPU clock.
  */
-#ifdef CONFIG_M5249
+#if defined(CONFIG_M5249) || defined(CONFIG_M527x)
 #define	MCF_BUSCLK	(MCF_CLK / 2)
 #else
 #define	MCF_BUSCLK	MCF_CLK
diff -Nru a/include/asm-m68knommu/delay.h b/include/asm-m68knommu/delay.h
--- a/include/asm-m68knommu/delay.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-m68knommu/delay.h	2004-12-24 13:36:19 -08:00
@@ -1,14 +1,13 @@
 #ifndef _M68KNOMMU_DELAY_H
 #define _M68KNOMMU_DELAY_H
 
-#include <asm/param.h>
-
 /*
  * Copyright (C) 1994 Hamish Macdonald
- *
- * Delay routines, using a pre-computed "loops_per_second" value.
+ * Copyright (C) 2004 Greg Ungerer <gerg@snapgear.com>
  */
 
+#include <asm/param.h>
+
 extern __inline__ void __delay(unsigned long loops)
 {
 #if defined(CONFIG_COLDFIRE)
@@ -34,35 +33,27 @@
 }
 
 /*
- * Use only for very small delays ( < 1 msec).  Should probably use a
- * lookup table, really, as the multiplications take much too long with
- * short delays.  This is a "reasonable" implementation, though (and the
- * first constant multiplications gets optimized away if the delay is
- * a constant)  
+ *	Ideally we use a 32*32->64 multiply to calculate the number of
+ *	loop iterations, but the older standard 68k and ColdFire do not
+ *	have this instruction. So for them we have a clsoe approximation
+ *	loop using 32*32->32 multiplies only. This calculation based on
+ *	the ARM version of delay.
+ *
+ *	We want to implement:
+ *
+ *	loops = (usecs * 0x10c6 * HZ * loops_per_jiffy) / 2^32
  */
 
+#define	HZSCALE		(268435456 / (1000000/HZ))
+
 extern unsigned long loops_per_jiffy;
 
-extern __inline__ void udelay(unsigned long usecs)
+extern __inline__ void _udelay(unsigned long usecs)
 {
-#ifdef CONFIG_M68332
-        usecs *= 0x000010c6;       
-       __asm__ __volatile__ ("mulul %1,%0:%2"
-                    : "=d" (usecs)
-                  : "d" (usecs),
-                   "d" (loops_per_jiffy*HZ));
-	__delay(usecs);
-
-#elif defined(CONFIG_M68328) || defined(CONFIG_M68EZ328) || \
-		defined(CONFIG_COLDFIRE) || defined(CONFIG_M68360) || \
-		defined(CONFIG_M68VZ328)
-	register unsigned long full_loops, part_loops;
-
-	full_loops = ((usecs * HZ) / 1000000) * loops_per_jiffy;
-	usecs %= (1000000 / HZ);
-	part_loops = (usecs * HZ * loops_per_jiffy) / 1000000;
-
-	__delay(full_loops + part_loops);
+#if defined(CONFIG_M68328) || defined(CONFIG_M68EZ328) || \
+    defined(CONFIG_M68VZ328) || defined(CONFIG_M68360) || \
+    defined(CONFIG_COLDFIRE)
+	__delay((((usecs * HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6);
 #else
 	unsigned long tmp;
 
@@ -73,5 +64,13 @@
 	__delay(usecs);
 #endif
 }
+
+/*
+ *	Moved the udelay() function into library code, no longer inlined.
+ *	I had to change the algorithm because we are overflowing now on
+ *	the faster ColdFire parts. The code is a little biger, so it makes
+ *	sense to library it.
+ */
+extern void udelay(unsigned long usecs);
 
 #endif /* defined(_M68KNOMMU_DELAY_H) */
diff -Nru a/include/asm-m68knommu/hardirq.h b/include/asm-m68knommu/hardirq.h
--- a/include/asm-m68knommu/hardirq.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-m68knommu/hardirq.h	2004-12-24 13:36:17 -08:00
@@ -13,28 +13,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * HARDIRQ_MASK: 0x0000ff00
- * SOFTIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have
diff -Nru a/include/asm-m68knommu/io.h b/include/asm-m68knommu/io.h
--- a/include/asm-m68knommu/io.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-m68knommu/io.h	2004-12-24 13:36:48 -08:00
@@ -102,6 +102,8 @@
 		*bp++ = _swapl(*ap);
 }
 
+#define mmiowb()
+
 /*
  *	make the short names macros so specific devices
  *	can override them as required
diff -Nru a/include/asm-m68knommu/m527xsim.h b/include/asm-m68knommu/m527xsim.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-m68knommu/m527xsim.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,38 @@
+/****************************************************************************/
+
+/*
+ *	m527xsim.h -- ColdFire 5270/5271 System Integration Module support.
+ *
+ *	(C) Copyright 2004, Greg Ungerer (gerg@snapgear.com)
+ */
+
+/****************************************************************************/
+#ifndef	m527xsim_h
+#define	m527xsim_h
+/****************************************************************************/
+
+#include <linux/config.h>
+
+/*
+ *	Define the 5270/5271 SIM register set addresses.
+ */
+#define	MCFICM_INTC0		0x0c00		/* Base for Interrupt Ctrl 0 */
+#define	MCFICM_INTC1		0x0d00		/* Base for Interrupt Ctrl 1 */
+#define	MCFINTC_IPRH		0x00		/* Interrupt pending 32-63 */
+#define	MCFINTC_IPRL		0x04		/* Interrupt pending 1-31 */
+#define	MCFINTC_IMRH		0x08		/* Interrupt mask 32-63 */
+#define	MCFINTC_IMRL		0x0c		/* Interrupt mask 1-31 */
+#define	MCFINTC_INTFRCH		0x10		/* Interrupt force 32-63 */
+#define	MCFINTC_INTFRCL		0x14		/* Interrupt force 1-31 */
+#define	MCFINTC_IRLR		0x18		/* */
+#define	MCFINTC_IACKL		0x19		/* */
+#define	MCFINTC_ICR0		0x40		/* Base ICR register */
+
+#define	MCFINT_VECBASE		64		/* Vector base number */
+#define	MCFINT_UART0		13		/* Interrupt number for UART0 */
+#define	MCFINT_UART1		14		/* Interrupt number for UART1 */
+#define	MCFINT_UART2		15		/* Interrupt number for UART2 */
+#define	MCFINT_PIT1		36		/* Interrupt number for PIT1 */
+
+/****************************************************************************/
+#endif	/* m527xsim_h */
diff -Nru a/include/asm-m68knommu/m5282sim.h b/include/asm-m68knommu/m5282sim.h
--- a/include/asm-m68knommu/m5282sim.h	2004-12-24 13:36:16 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,35 +0,0 @@
-/****************************************************************************/
-
-/*
- *	m5282sim.h -- ColdFire 5282 System Integration Module support.
- *
- *	(C) Copyright 2003, Greg Ungerer (gerg@snapgear.com)
- */
-
-/****************************************************************************/
-#ifndef	m5282sim_h
-#define	m5282sim_h
-/****************************************************************************/
-
-#include <linux/config.h>
-
-/*
- *	Define the 5282 SIM register set addresses.
- */
-#define	MCFICM_INTC0		0x0c00		/* Base for Interrupt Ctrl 0 */
-#define	MCFICM_INTC1		0x0d00		/* Base for Interrupt Ctrl 0 */
-#define	MCFINTC_IPRH		0x00		/* Interrupt pending 32-63 */
-#define	MCFINTC_IPRL		0x04		/* Interrupt pending 1-31 */
-#define	MCFINTC_IMRH		0x08		/* Interrupt mask 32-63 */
-#define	MCFINTC_IMRL		0x0c		/* Interrupt mask 1-31 */
-#define	MCFINTC_INTFRCH		0x10		/* Interrupt force 32-63 */
-#define	MCFINTC_INTFRCL		0x14		/* Interrupt force 1-31 */
-#define	MCFINTC_IRLR		0x18		/* */
-#define	MCFINTC_IACKL		0x19		/* */
-#define	MCFINTC_ICR0		0x40		/* Base ICR register */
-
-#define	MCFINT_UART0		13		/* Interrupt number for UART0 */
-#define	MCFINT_PIT1		55		/* Interrupt number for PIT1 */
-
-/****************************************************************************/
-#endif	/* m5282sim_h */
diff -Nru a/include/asm-m68knommu/m528xsim.h b/include/asm-m68knommu/m528xsim.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-m68knommu/m528xsim.h	2004-12-24 13:36:16 -08:00
@@ -0,0 +1,36 @@
+/****************************************************************************/
+
+/*
+ *	m528xsim.h -- ColdFire 5280/5282 System Integration Module support.
+ *
+ *	(C) Copyright 2003, Greg Ungerer (gerg@snapgear.com)
+ */
+
+/****************************************************************************/
+#ifndef	m528xsim_h
+#define	m528xsim_h
+/****************************************************************************/
+
+#include <linux/config.h>
+
+/*
+ *	Define the 5280/5282 SIM register set addresses.
+ */
+#define	MCFICM_INTC0		0x0c00		/* Base for Interrupt Ctrl 0 */
+#define	MCFICM_INTC1		0x0d00		/* Base for Interrupt Ctrl 0 */
+#define	MCFINTC_IPRH		0x00		/* Interrupt pending 32-63 */
+#define	MCFINTC_IPRL		0x04		/* Interrupt pending 1-31 */
+#define	MCFINTC_IMRH		0x08		/* Interrupt mask 32-63 */
+#define	MCFINTC_IMRL		0x0c		/* Interrupt mask 1-31 */
+#define	MCFINTC_INTFRCH		0x10		/* Interrupt force 32-63 */
+#define	MCFINTC_INTFRCL		0x14		/* Interrupt force 1-31 */
+#define	MCFINTC_IRLR		0x18		/* */
+#define	MCFINTC_IACKL		0x19		/* */
+#define	MCFINTC_ICR0		0x40		/* Base ICR register */
+
+#define	MCFINT_VECBASE		64		/* Vector base number */
+#define	MCFINT_UART0		13		/* Interrupt number for UART0 */
+#define	MCFINT_PIT1		55		/* Interrupt number for PIT1 */
+
+/****************************************************************************/
+#endif	/* m528xsim_h */
diff -Nru a/include/asm-m68knommu/mcfdma.h b/include/asm-m68knommu/mcfdma.h
--- a/include/asm-m68knommu/mcfdma.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-m68knommu/mcfdma.h	2004-12-24 13:36:31 -08:00
@@ -21,7 +21,7 @@
 #define	MCFDMA_BASE1		0x240		/* Base address of DMA 1 */
 #elif defined(CONFIG_M5272)
 #define	MCFDMA_BASE0		0x0e0		/* Base address of DMA 0 */
-#elif defined(CONFIG_M5282)
+#elif defined(CONFIG_M527x) || defined(CONFIG_M528x)
 /* These are relative to the IPSBAR, not MBAR */
 #define	MCFDMA_BASE0		0x100		/* Base address of DMA 0 */
 #define	MCFDMA_BASE1		0x140		/* Base address of DMA 1 */
diff -Nru a/include/asm-m68knommu/mcfpit.h b/include/asm-m68knommu/mcfpit.h
--- a/include/asm-m68knommu/mcfpit.h	2004-12-24 13:36:32 -08:00
+++ b/include/asm-m68knommu/mcfpit.h	2004-12-24 13:36:32 -08:00
@@ -14,7 +14,7 @@
 #include <linux/config.h>
 
 /*
- *	Get address specific defines for the 5282.
+ *	Get address specific defines for the 5270/5271 and 5280/5282.
  */
 #define	MCFPIT_BASE1		0x00150000	/* Base address of TIMER1 */
 #define	MCFPIT_BASE2		0x00160000	/* Base address of TIMER2 */
diff -Nru a/include/asm-m68knommu/mcfsim.h b/include/asm-m68knommu/mcfsim.h
--- a/include/asm-m68knommu/mcfsim.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-m68knommu/mcfsim.h	2004-12-24 13:37:43 -08:00
@@ -15,7 +15,8 @@
 #include <linux/config.h>
 
 /*
- *	Include 5204, 5206, 5249, 5272, 5282, 5307 or 5407 specific addresses.
+ *	Include 5204, 5206/e, 5249, 5270/5271, 5272, 5280/5282, 5307 or
+ *	5407 specific addresses.
  */
 #if defined(CONFIG_M5204)
 #include <asm/m5204sim.h>
@@ -23,10 +24,12 @@
 #include <asm/m5206sim.h>
 #elif defined(CONFIG_M5249)
 #include <asm/m5249sim.h>
+#elif defined(CONFIG_M527x)
+#include <asm/m527xsim.h>
 #elif defined(CONFIG_M5272)
 #include <asm/m5272sim.h>
-#elif defined(CONFIG_M5282)
-#include <asm/m5282sim.h>
+#elif defined(CONFIG_M528x)
+#include <asm/m528xsim.h>
 #elif defined(CONFIG_M5307)
 #include <asm/m5307sim.h>
 #elif defined(CONFIG_M5407)
diff -Nru a/include/asm-m68knommu/mcfuart.h b/include/asm-m68knommu/mcfuart.h
--- a/include/asm-m68knommu/mcfuart.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-m68knommu/mcfuart.h	2004-12-24 13:37:19 -08:00
@@ -29,7 +29,7 @@
 #define	MCFUART_BASE1		0x140		/* Base address of UART1 */
 #define	MCFUART_BASE2		0x180		/* Base address of UART2 */
 #endif
-#elif defined(CONFIG_M5282)
+#elif defined(CONFIG_M527x) || defined(CONFIG_M528x)
 #define MCFUART_BASE1		0x200           /* Base address of UART1 */
 #define MCFUART_BASE2		0x240           /* Base address of UART2 */
 #define MCFUART_BASE3		0x280           /* Base address of UART3 */
diff -Nru a/include/asm-m68knommu/page_offset.h b/include/asm-m68knommu/page_offset.h
--- a/include/asm-m68knommu/page_offset.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-m68knommu/page_offset.h	2004-12-24 13:36:16 -08:00
@@ -1,6 +1,5 @@
 
 #include <linux/config.h>
-#include <asm/shglcore.h>
 
 /* This handles the memory map.. */
 
@@ -44,8 +43,5 @@
 #endif
 #ifdef CONFIG_M68EN302
 #define PAGE_OFFSET_RAW		0x00000000
-#endif
-#ifdef CONFIG_SHGLCORE
-#define PAGE_OFFSET_RAW		SHGLCORE_RAM_BANK_0_ADDR 
 #endif
 
diff -Nru a/include/asm-m68knommu/param.h b/include/asm-m68knommu/param.h
--- a/include/asm-m68knommu/param.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-m68knommu/param.h	2004-12-24 13:36:55 -08:00
@@ -3,38 +3,11 @@
 
 #include <linux/config.h>
 
-#ifndef HZ
-#ifdef CONFIG_COLDFIRE
 #if defined(CONFIG_CLEOPATRA)
-#define HZ 1000
-#else
-#define HZ 100
-#endif
-#endif
-#ifdef CONFIG_M68EN302
-#define HZ 100
-#endif
-#ifdef CONFIG_M68328
-#define HZ 100
-#endif
-#ifdef CONFIG_M68EZ328
-#define HZ 100
+#define	HZ 1000
 #endif
-#ifdef CONFIG_UCSIMM
-#define HZ 100
-#endif
-
-#ifdef CONFIG_M68VZ328
-#define HZ 100
-#endif
-
-#ifdef CONFIG_SHGLCORE
-#define HZ 50
-#endif
-#ifdef CONFIG_M68360
-#define HZ 100
-#endif
-
+#ifndef HZ
+#define	HZ 100
 #endif
 
 #ifdef __KERNEL__
diff -Nru a/include/asm-m68knommu/pgtable.h b/include/asm-m68knommu/pgtable.h
--- a/include/asm-m68knommu/pgtable.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-m68knommu/pgtable.h	2004-12-24 13:37:00 -08:00
@@ -54,7 +54,8 @@
  * No page table caches to initialise.
  */
 #define pgtable_cache_init()	do { } while (0)
-#define io_remap_page_range	remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 /*
  * All 32bit addresses are effectively valid for vmalloc...
diff -Nru a/include/asm-m68knommu/shglcore.h b/include/asm-m68knommu/shglcore.h
--- a/include/asm-m68knommu/shglcore.h	2004-12-24 13:37:32 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,65 +0,0 @@
-
-/* Copyright (C) 1998  Kenneth Albanowski <kjahds@kjahds.com>,
- */
-
-#ifndef _M68K_SHGLCORE_H
-#define _M68K_SHGLCORE_H
-
-#include <linux/config.h>
-
-#ifdef CONFIG_SHGLCORE
-
-#include <asm/MC68332.h>
-
-#ifdef CONFIG_SHGLCORE_2MEG
-
-#define SHGLCORE_ROM_BANK_0_ADDR	0x000000
-#define SHGLCORE_ROM_BANK_1_ADDR	0x100000
-#define SHGLCORE_RAM_BANK_0_ADDR	0x200000
-#define SHGLCORE_RAM_BANK_1_ADDR	0x300000
-#define SHGLCORE_FLASH_BANK_0_ADDR	0x400000
-
-#define SHGLCORE_ROM_BANK_0_LENGTH	0x100000
-#define SHGLCORE_ROM_BANK_1_LENGTH	0x100000
-#define SHGLCORE_RAM_BANK_0_LENGTH	0x100000
-#define SHGLCORE_RAM_BANK_1_LENGTH	0x100000
-#define SHGLCORE_FLASH_BANK_0_LENGTH	0x80000
-
-#define SHGLCORE_ACC_ADDR		0x600000
-#define SHGLCORE_LANCE_ADDR		0x700000
-
-#else
-
-#define SHGLCORE_ROM_BANK_0_ADDR	0x000000
-#define SHGLCORE_RAM_BANK_0_ADDR	0x100000
-#define SHGLCORE_FLASH_BANK_0_ADDR	0x300000
-
-#define SHGLCORE_ROM_BANK_0_LENGTH	0x100000
-#define SHGLCORE_RAM_BANK_0_LENGTH	0x100000
-#define SHGLCORE_FLASH_BANK_0_LENGTH	0x80000
-
-#define SHGLCORE_ACC_ADDR		0x400000
-#define SHGLCORE_LANCE_ADDR		0x500000
-
-#endif
-
-#define MAX_DMA_ADDRESS			SHGLCORE_RAM_BANK_0_ADDR + SHGLCORE_RAM_BANK_0_LENGTH
-
-#define SHGLCORE_LATCH_ADDR	(SHGLCORE_ACC_ADDR+0x100)
-#define SHGLCORE_1865_0_ADDR	(SHGLCORE_ACC_ADDR+0x600)
-#define SHGLCORE_1865_1_ADDR	(SHGLCORE_ACC_ADDR+0x700)
-
-#define SHGLCORE_LATCH_BIT(x)	BYTE_REF(SHGLCORE_LATCH_ADDR+x)
-
-#define SHGLCORE_LATCH_STATUS_LED	0
-#define SHGLCORE_LATCH_ERROR_LED	1
-#define SHGLCORE_LATCH_ALARM_LED	2
-
-#define SHGLCORE_LATCH_1865		4
-
-#define SHGLCORE_LATCH_RELAY_1		6
-#define SHGLCORE_LATCH_RELAY_2		7
-
-#endif /* SHGLCORE */
-
-#endif /* _M68K_SHGLCORE_H */
diff -Nru a/include/asm-m68knommu/shglports.h b/include/asm-m68knommu/shglports.h
--- a/include/asm-m68knommu/shglports.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,76 +0,0 @@
-
-/* Copyright (C) 1998  Kenneth Albanowski <kjahds@kjahds.com>,
- *         1997, 1998  D. Jeff Dionne <jeff@lineo.ca>,
- */
-
-#ifndef _M68K_SHGLPORTS_H
-#define _M68K_SHGLPORTS_H
-
-#include <linux/config.h>
-#include <linux/sched.h>
-
-#ifdef CONFIG_SHGLCORE
-
-extern struct semaphore porte_interlock;
-
-struct SHGLCORE_PORT_QS { 
-  unsigned char
-  nullqs:1, /* COM1TX */ 
-  sbin:1,   /* PQS6 (PCS3) */
-  sbclk:1,  /* PQS5 (PCS2) */
-  sbout:1,  /* PQS4 (PCS1) */
-  null4:4;  /* MISO, MOSI, SCLK, /SS=PCS0 */
-};
-
-#define PORT_QS ((volatile struct SHGLCORE_PORT_QS*)PORTQS_ADDR)
-
-struct SHGLCORE_PORT_E {
-  unsigned char
-  dead:1,       /* LED */
-  sbirigb:1,    /* PE6 */
-  ds:1,         /* /DS */
-  nulle1:1,     /* na */ 
-  sbpll:1,      /* PE3 */
-  avec:1,       /* /AVEC */
-  sbsrom:1,     /* PE1 */
-  sbpanel:1;    /* PE0 */
-};
-
-#define PORT_E ((volatile struct SHGLCORE_PORT_E*)PORTE_ADDR)
-
-struct SHGLCORE_PORT_F {
-  unsigned char
-  nullf1:4,
-  nullf2:4;
-};
-
-#define PORT_F ((volatile struct SHGLCORE_PORT_F*)PORTF_ADDR)
-
-extern int comm_status_led, comm_error_led, alarm_led;
-
-static inline void SET_COMM_STATUS_LED(int value) {
-	BYTE_REF(SHGLCORE_ACC_ADDR+0x100+0) = comm_status_led = value;
-}
-static inline int GET_COMM_STATUS_LED(void) {
-	return comm_status_led;
-}
-
-
-static inline void SET_COMM_ERROR_LED(int value) {
-	BYTE_REF(SHGLCORE_ACC_ADDR+0x100+1) = comm_error_led = value;
-}
-static inline int GET_COMM_ERROR_LED(void) {
-	return comm_error_led;
-}
-
-
-static inline void SET_ALARM_LED(int value) {
-	BYTE_REF(SHGLCORE_ACC_ADDR+0x100+2) = alarm_led = value;
-}
-static inline int GET_ALARM_LED(void) {
-	return alarm_led;
-}
-
-#endif
-
-#endif /* _M68K_SHGLPORTS_H */
diff -Nru a/include/asm-m68knommu/system.h b/include/asm-m68knommu/system.h
--- a/include/asm-m68knommu/system.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-m68knommu/system.h	2004-12-24 13:37:00 -08:00
@@ -257,6 +257,19 @@
         jmp (%a0);			\
         ");				\
 })
+#elif defined(CONFIG_M528x)
+/*
+ * The MCF528x has a bit (SOFTRST) in memory (Reset Control Register RCR),
+ * that when set, resets the MCF528x.
+ */
+#define HARD_RESET_NOW() \
+({						\
+	unsigned char volatile *reset;		\
+	asm("move.w	#0x2700, %sr");		\
+	reset = ((volatile unsigned short *)(MCF_IPSBAR + 0x110000));	\
+	while(1)				\
+	*reset |= (0x01 << 7);\
+})
 #else
 #define HARD_RESET_NOW() ({		\
         asm("				\
diff -Nru a/include/asm-m68knommu/thread_info.h b/include/asm-m68knommu/thread_info.h
--- a/include/asm-m68knommu/thread_info.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-m68knommu/thread_info.h	2004-12-24 13:36:48 -08:00
@@ -12,6 +12,12 @@
 
 #ifdef __KERNEL__
 
+/*
+ * Size of kernel stack for each process. This must be a power of 2...
+ */
+#define THREAD_SIZE		8192	/* 2 pages */
+
+
 #ifndef __ASSEMBLY__
 
 /*
@@ -43,12 +49,6 @@
 
 #define init_thread_info	(init_thread_union.thread_info)
 #define init_stack		(init_thread_union.stack)
-
-
-/*
- * Size of kernel stack for each process. This must be a power of 2...
- */
-#define THREAD_SIZE		8192	/* 2 pages */
 
 
 /* how to get the thread information struct from C */
diff -Nru a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h
--- a/include/asm-m68knommu/unistd.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-m68knommu/unistd.h	2004-12-24 13:36:55 -08:00
@@ -5,6 +5,7 @@
  * This file contains the system call numbers.
  */
 
+#define __NR_restart_syscall      0
 #define __NR_exit		  1
 #define __NR_fork		  2
 #define __NR_read		  3
@@ -80,7 +81,7 @@
 #define __NR_sigpending		 73
 #define __NR_sethostname	 74
 #define __NR_setrlimit		 75
-#define __NR_old_getrlimit	 76
+#define __NR_getrlimit		 76
 #define __NR_getrusage		 77
 #define __NR_gettimeofday	 78
 #define __NR_settimeofday	 79
@@ -170,6 +171,7 @@
 #define __NR_mremap		163
 #define __NR_setresuid		164
 #define __NR_getresuid		165
+#define __NR_getpagesize	166
 #define __NR_query_module	167
 #define __NR_poll		168
 #define __NR_nfsservctl		169
@@ -194,7 +196,7 @@
 #define __NR_getpmsg		188	/* some people actually want streams */
 #define __NR_putpmsg		189	/* some people actually want streams */
 #define __NR_vfork		190
-#define __NR_getrlimit		191
+#define __NR_ugetrlimit		191
 #define __NR_mmap2		192
 #define __NR_truncate64		193
 #define __NR_ftruncate64	194
@@ -220,8 +222,71 @@
 #define __NR_setgid32		214
 #define __NR_setfsuid32		215
 #define __NR_setfsgid32		216
-
-#define	NR_syscalls		256
+#define __NR_pivot_root		217
+#define __NR_getdents64		220
+#define __NR_gettid		221
+#define __NR_tkill		222
+#define __NR_setxattr		223
+#define __NR_lsetxattr		224
+#define __NR_fsetxattr		225
+#define __NR_getxattr		226
+#define __NR_lgetxattr		227
+#define __NR_fgetxattr		228
+#define __NR_listxattr		229
+#define __NR_llistxattr		230
+#define __NR_flistxattr		231
+#define __NR_removexattr	232
+#define __NR_lremovexattr	233
+#define __NR_fremovexattr	234
+#define __NR_futex		235
+#define __NR_sendfile64		236
+#define __NR_mincore		237
+#define __NR_madvise		238
+#define __NR_fcntl64		239
+#define __NR_readahead		240
+#define __NR_io_setup		241
+#define __NR_io_destroy		242
+#define __NR_io_getevents	243
+#define __NR_io_submit		244
+#define __NR_io_cancel		245
+#define __NR_fadvise64		246
+#define __NR_exit_group		247
+#define __NR_lookup_dcookie	248
+#define __NR_epoll_create	249
+#define __NR_epoll_ctl		250
+#define __NR_epoll_wait		251
+#define __NR_remap_file_pages	252
+#define __NR_set_tid_address	253
+#define __NR_timer_create	254
+#define __NR_timer_settime	255
+#define __NR_timer_gettime	256
+#define __NR_timer_getoverrun	257
+#define __NR_timer_delete	258
+#define __NR_clock_settime	259
+#define __NR_clock_gettime	260
+#define __NR_clock_getres	261
+#define __NR_clock_nanosleep	262
+#define __NR_statfs64		263
+#define __NR_fstatfs64		264
+#define __NR_tgkill		265
+#define __NR_utimes		266
+#define __NR_fadvise64_64	267
+#define __NR_mbind		268
+#define __NR_get_mempolicy	269
+#define __NR_set_mempolicy	270
+#define __NR_mq_open		271
+#define __NR_mq_unlink		272
+#define __NR_mq_timedsend	273
+#define __NR_mq_timedreceive	274
+#define __NR_mq_notify		275
+#define __NR_mq_getsetattr	276
+#define __NR_waitid		277
+#define __NR_sys_setaltroot	278
+#define __NR_add_key		279
+#define __NR_request_key	280
+#define __NR_keyctl		281
+ 
+#define NR_syscalls		282
 
 /* user-visible error numbers are in the range -1 - -122: see
    <asm-m68k/errno.h> */
diff -Nru a/include/asm-mips/addrspace.h b/include/asm-mips/addrspace.h
--- a/include/asm-mips/addrspace.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/addrspace.h	2004-12-24 13:36:17 -08:00
@@ -38,16 +38,6 @@
 #endif
 
 /*
- * Memory segments (32bit kernel mode addresses)
- * These are the traditional names used in the 32-bit universe.
- */
-#define KUSEG			0x00000000
-#define KSEG0			0x80000000
-#define KSEG1			0xa0000000
-#define KSEG2			0xc0000000
-#define KSEG3			0xe0000000
-
-/*
  * Returns the kernel segment base of a given address
  */
 #define KSEGX(a)		((_ACAST32_ (a)) & 0xe0000000)
@@ -58,18 +48,7 @@
 #define CPHYSADDR(a)		((_ACAST32_ (a)) & 0x1fffffff)
 #define XPHYSADDR(a)            ((_ACAST64_ (a)) & 0x000000ffffffffff)
 
-/*
- * Map an address to a certain kernel segment
- */
-#define KSEG0ADDR(a)		(CPHYSADDR(a) | KSEG0)
-#define KSEG1ADDR(a)		(CPHYSADDR(a) | KSEG1)
-#define KSEG2ADDR(a)		(CPHYSADDR(a) | KSEG2)
-#define KSEG3ADDR(a)		(CPHYSADDR(a) | KSEG3)
-
-#define CKSEG0ADDR(a)		(CPHYSADDR(a) | CKSEG0)
-#define CKSEG1ADDR(a)		(CPHYSADDR(a) | CKSEG1)
-#define CKSEG2ADDR(a)		(CPHYSADDR(a) | CKSEG2)
-#define CKSEG3ADDR(a)		(CPHYSADDR(a) | CKSEG3)
+#ifdef CONFIG_MIPS64
 
 /*
  * Memory segments (64bit kernel mode addresses)
@@ -84,6 +63,44 @@
 #define CKSEG1			0xffffffffa0000000
 #define CKSSEG			0xffffffffc0000000
 #define CKSEG3			0xffffffffe0000000
+
+#define CKSEG0ADDR(a)		(CPHYSADDR(a) | CKSEG0)
+#define CKSEG1ADDR(a)		(CPHYSADDR(a) | CKSEG1)
+#define CKSEG2ADDR(a)		(CPHYSADDR(a) | CKSEG2)
+#define CKSEG3ADDR(a)		(CPHYSADDR(a) | CKSEG3)
+
+#else
+
+#define CKSEG0ADDR(a)		(CPHYSADDR(a) | KSEG0)
+#define CKSEG1ADDR(a)		(CPHYSADDR(a) | KSEG1)
+#define CKSEG2ADDR(a)		(CPHYSADDR(a) | KSEG2)
+#define CKSEG3ADDR(a)		(CPHYSADDR(a) | KSEG3)
+
+/*
+ * Map an address to a certain kernel segment
+ */
+#define KSEG0ADDR(a)		(CPHYSADDR(a) | KSEG0)
+#define KSEG1ADDR(a)		(CPHYSADDR(a) | KSEG1)
+#define KSEG2ADDR(a)		(CPHYSADDR(a) | KSEG2)
+#define KSEG3ADDR(a)		(CPHYSADDR(a) | KSEG3)
+
+/*
+ * Memory segments (32bit kernel mode addresses)
+ * These are the traditional names used in the 32-bit universe.
+ */
+#define KUSEG			0x00000000
+#define KSEG0			0x80000000
+#define KSEG1			0xa0000000
+#define KSEG2			0xc0000000
+#define KSEG3			0xe0000000
+
+#define CKUSEG			0x00000000
+#define CKSEG0			0x80000000
+#define CKSEG1			0xa0000000
+#define CKSEG2			0xc0000000
+#define CKSEG3			0xe0000000
+
+#endif
 
 /*
  * Cache modes for XKPHYS address conversion macros
diff -Nru a/include/asm-mips/asmmacro-32.h b/include/asm-mips/asmmacro-32.h
--- a/include/asm-mips/asmmacro-32.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/asmmacro-32.h	2004-12-24 13:36:17 -08:00
@@ -12,8 +12,8 @@
 #include <asm/fpregdef.h>
 #include <asm/mipsregs.h>
 
-	.macro	fpu_save_double thread tmp=t0
-	cfc1	\tmp,  fcr31
+	.macro	fpu_save_double thread status tmp1=t0 tmp2
+	cfc1	\tmp1,  fcr31
 	sdc1	$f0,  THREAD_FPR0(\thread)
 	sdc1	$f2,  THREAD_FPR2(\thread)
 	sdc1	$f4,  THREAD_FPR4(\thread)
@@ -30,7 +30,7 @@
 	sdc1	$f26, THREAD_FPR26(\thread)
 	sdc1	$f28, THREAD_FPR28(\thread)
 	sdc1	$f30, THREAD_FPR30(\thread)
-	sw	\tmp, THREAD_FCR31(\thread)
+	sw	\tmp1, THREAD_FCR31(\thread)
 	.endm
 
 	.macro	fpu_save_single thread tmp=t0
diff -Nru a/include/asm-mips/asmmacro-64.h b/include/asm-mips/asmmacro-64.h
--- a/include/asm-mips/asmmacro-64.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-mips/asmmacro-64.h	2004-12-24 13:36:47 -08:00
@@ -15,6 +15,7 @@
 
 	.macro	fpu_save_16even thread tmp=t0
 	cfc1	\tmp, fcr31
+	sdc1	$f0,  THREAD_FPR0(\thread)
 	sdc1	$f2,  THREAD_FPR2(\thread)
 	sdc1	$f4,  THREAD_FPR4(\thread)
 	sdc1	$f6,  THREAD_FPR6(\thread)
@@ -52,6 +53,14 @@
 	sdc1	$f31, THREAD_FPR31(\thread)
 	.endm
 
+	.macro	fpu_save_double thread status tmp1 tmp2
+	sll	\tmp2, \tmp1, 5
+	bgez	\tmp2, 2f
+	fpu_save_16odd \thread
+2:
+	fpu_save_16even \thread \tmp1			# clobbers t1
+	.endm
+
 	.macro	fpu_restore_16even thread tmp=t0
 	lw	\tmp, THREAD_FCR31(\thread)
 	ldc1	$f0,  THREAD_FPR0(\thread)
@@ -90,6 +99,15 @@
 	ldc1	$f27, THREAD_FPR27(\thread)
 	ldc1	$f29, THREAD_FPR29(\thread)
 	ldc1	$f31, THREAD_FPR31(\thread)
+	.endm
+
+	.macro	fpu_restore_double thread tmp
+	mfc0	t0, CP0_STATUS
+	sll	t1, t0, 5
+	bgez	t1, 1f				# 16 register mode?
+
+	fpu_restore_16odd a0
+1:	fpu_restore_16even a0, t0		# clobbers t0
 	.endm
 
 	.macro	cpu_save_nonscratch thread
diff -Nru a/include/asm-mips/atomic.h b/include/asm-mips/atomic.h
--- a/include/asm-mips/atomic.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-mips/atomic.h	2004-12-24 13:36:16 -08:00
@@ -23,6 +23,9 @@
 #ifndef _ASM_ATOMIC_H
 #define _ASM_ATOMIC_H
 
+#include <asm/cpu-features.h>
+#include <asm/war.h>
+
 extern spinlock_t atomic_lock;
 
 typedef struct { volatile int counter; } atomic_t;
@@ -46,8 +49,6 @@
  */
 #define atomic_set(v,i)		((v)->counter = (i))
 
-#ifdef CONFIG_CPU_HAS_LLSC
-
 /*
  * atomic_add - add integer to atomic variable
  * @i: integer value to add
@@ -57,15 +58,33 @@
  */
 static __inline__ void atomic_add(int i, atomic_t * v)
 {
-	unsigned long temp;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-	__asm__ __volatile__(
-	"1:	ll	%0, %1		# atomic_add		\n"
-	"	addu	%0, %2					\n"
-	"	sc	%0, %1					\n"
-	"	beqz	%0, 1b					\n"
-	: "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter));
+		__asm__ __volatile__(
+		"1:	ll	%0, %1		# atomic_add		\n"
+		"	addu	%0, %2					\n"
+		"	sc	%0, %1					\n"
+		"	beqzl	%0, 1b					\n"
+		: "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter));
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	ll	%0, %1		# atomic_add		\n"
+		"	addu	%0, %2					\n"
+		"	sc	%0, %1					\n"
+		"	beqz	%0, 1b					\n"
+		: "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter));
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		v->counter += i;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 }
 
 /*
@@ -77,15 +96,33 @@
  */
 static __inline__ void atomic_sub(int i, atomic_t * v)
 {
-	unsigned long temp;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-	__asm__ __volatile__(
-	"1:	ll	%0, %1		# atomic_sub		\n"
-	"	subu	%0, %2					\n"
-	"	sc	%0, %1					\n"
-	"	beqz	%0, 1b					\n"
-	: "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter));
+		__asm__ __volatile__(
+		"1:	ll	%0, %1		# atomic_sub		\n"
+		"	subu	%0, %2					\n"
+		"	sc	%0, %1					\n"
+		"	beqzl	%0, 1b					\n"
+		: "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter));
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	ll	%0, %1		# atomic_sub		\n"
+		"	subu	%0, %2					\n"
+		"	sc	%0, %1					\n"
+		"	beqz	%0, 1b					\n"
+		: "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter));
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		v->counter -= i;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 }
 
 /*
@@ -93,131 +130,90 @@
  */
 static __inline__ int atomic_add_return(int i, atomic_t * v)
 {
-	unsigned long temp, result;
+	unsigned long result;
 
-	__asm__ __volatile__(
-	"1:	ll	%1, %2		# atomic_add_return	\n"
-	"	addu	%0, %1, %3				\n"
-	"	sc	%0, %2					\n"
-	"	beqz	%0, 1b					\n"
-	"	addu	%0, %1, %3				\n"
-	"	sync						\n"
-	: "=&r" (result), "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter)
-	: "memory");
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	ll	%1, %2		# atomic_add_return	\n"
+		"	addu	%0, %1, %3				\n"
+		"	sc	%0, %2					\n"
+		"	beqzl	%0, 1b					\n"
+		"	addu	%0, %1, %3				\n"
+		"	sync						\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	ll	%1, %2		# atomic_add_return	\n"
+		"	addu	%0, %1, %3				\n"
+		"	sc	%0, %2					\n"
+		"	beqz	%0, 1b					\n"
+		"	addu	%0, %1, %3				\n"
+		"	sync						\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		result = v->counter;
+		result += i;
+		v->counter = result;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 
 	return result;
 }
 
 static __inline__ int atomic_sub_return(int i, atomic_t * v)
 {
-	unsigned long temp, result;
-
-	__asm__ __volatile__(
-	"1:	ll	%1, %2		# atomic_sub_return	\n"
-	"	subu	%0, %1, %3				\n"
-	"	sc	%0, %2					\n"
-	"	beqz	%0, 1b					\n"
-	"	subu	%0, %1, %3				\n"
-	"	sync						\n"
-	: "=&r" (result), "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter)
-	: "memory");
+	unsigned long result;
 
-	return result;
-}
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-/*
- * atomic_sub_if_positive - add integer to atomic variable
- * @v: pointer of type atomic_t
- *
- * Atomically test @v and decrement if it is greater than 0.
- * The function returns the old value of @v minus 1.
- */
-static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
-{
-	unsigned long temp, result;
-
-	__asm__ __volatile__(
-	"1:	ll	%1, %2		# atomic_sub_if_positive\n"
-	"	subu	%0, %1, %3				\n"
-	"	bltz	%0, 1f					\n"
-	"	sc	%0, %2					\n"
-	"	beqz	%0, 1b					\n"
-	"	sync						\n"
-	"1:							\n"
-	: "=&r" (result), "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter)
-	: "memory");
+		__asm__ __volatile__(
+		"1:	ll	%1, %2		# atomic_sub_return	\n"
+		"	subu	%0, %1, %3				\n"
+		"	sc	%0, %2					\n"
+		"	beqzl	%0, 1b					\n"
+		"	subu	%0, %1, %3				\n"
+		"	sync						\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	ll	%1, %2		# atomic_sub_return	\n"
+		"	subu	%0, %1, %3				\n"
+		"	sc	%0, %2					\n"
+		"	beqz	%0, 1b					\n"
+		"	subu	%0, %1, %3				\n"
+		"	sync						\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		result = v->counter;
+		result -= i;
+		v->counter = result;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 
 	return result;
 }
 
-#else
-
-/*
- * The MIPS I implementation is only atomic with respect to
- * interrupts.  R3000 based multiprocessor machines are rare anyway ...
- *
- * atomic_add - add integer to atomic variable
- * @i: integer value to add
- * @v: pointer of type atomic_t
- *
- * Atomically adds @i to @v.
- */
-static __inline__ void atomic_add(int i, atomic_t * v)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&atomic_lock, flags);
-	v->counter += i;
-	spin_unlock_irqrestore(&atomic_lock, flags);
-}
-
-/*
- * atomic_sub - subtract the atomic variable
- * @i: integer value to subtract
- * @v: pointer of type atomic_t
- *
- * Atomically subtracts @i from @v.
- */
-static __inline__ void atomic_sub(int i, atomic_t * v)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&atomic_lock, flags);
-	v->counter -= i;
-	spin_unlock_irqrestore(&atomic_lock, flags);
-}
-
-static __inline__ int atomic_add_return(int i, atomic_t * v)
-{
-	unsigned long flags;
-	int temp;
-
-	spin_lock_irqsave(&atomic_lock, flags);
-	temp = v->counter;
-	temp += i;
-	v->counter = temp;
-	spin_unlock_irqrestore(&atomic_lock, flags);
-
-	return temp;
-}
-
-static __inline__ int atomic_sub_return(int i, atomic_t * v)
-{
-	unsigned long flags;
-	int temp;
-
-	spin_lock_irqsave(&atomic_lock, flags);
-	temp = v->counter;
-	temp -= i;
-	v->counter = temp;
-	spin_unlock_irqrestore(&atomic_lock, flags);
-
-	return temp;
-}
-
 /*
  * atomic_sub_if_positive - add integer to atomic variable
  * @v: pointer of type atomic_t
@@ -227,20 +223,49 @@
  */
 static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
 {
-	unsigned long flags;
-	int temp;
+	unsigned long result;
 
-	spin_lock_irqsave(&atomic_lock, flags);
-	temp = v->counter;
-	temp -= i;
-	if (temp >= 0)
-		v->counter = temp;
-	spin_unlock_irqrestore(&atomic_lock, flags);
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-	return temp;
-}
+		__asm__ __volatile__(
+		"1:	ll	%1, %2		# atomic_sub_if_positive\n"
+		"	subu	%0, %1, %3				\n"
+		"	bltz	%0, 1f					\n"
+		"	sc	%0, %2					\n"
+		"	beqzl	%0, 1b					\n"
+		"	sync						\n"
+		"1:							\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	ll	%1, %2		# atomic_sub_if_positive\n"
+		"	subu	%0, %1, %3				\n"
+		"	bltz	%0, 1f					\n"
+		"	sc	%0, %2					\n"
+		"	beqz	%0, 1b					\n"
+		"	sync						\n"
+		"1:							\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		result = v->counter;
+		result -= i;
+		if (result >= 0)
+			v->counter = result;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 
-#endif /* CONFIG_CPU_HAS_LLSC */
+	return result;
+}
 
 #define atomic_dec_return(v) atomic_sub_return(1,(v))
 #define atomic_inc_return(v) atomic_add_return(1,(v))
@@ -329,8 +354,6 @@
  */
 #define atomic64_set(v,i)	((v)->counter = (i))
 
-#ifdef CONFIG_CPU_HAS_LLDSCD
-
 /*
  * atomic64_add - add integer to atomic variable
  * @i: integer value to add
@@ -340,15 +363,33 @@
  */
 static __inline__ void atomic64_add(long i, atomic64_t * v)
 {
-	unsigned long temp;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-	__asm__ __volatile__(
-	"1:	lld	%0, %1		# atomic64_add		\n"
-	"	addu	%0, %2					\n"
-	"	scd	%0, %1					\n"
-	"	beqz	%0, 1b					\n"
-	: "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter));
+		__asm__ __volatile__(
+		"1:	lld	%0, %1		# atomic64_add		\n"
+		"	addu	%0, %2					\n"
+		"	scd	%0, %1					\n"
+		"	beqzl	%0, 1b					\n"
+		: "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter));
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	lld	%0, %1		# atomic64_add		\n"
+		"	addu	%0, %2					\n"
+		"	scd	%0, %1					\n"
+		"	beqz	%0, 1b					\n"
+		: "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter));
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		v->counter += i;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 }
 
 /*
@@ -360,15 +401,33 @@
  */
 static __inline__ void atomic64_sub(long i, atomic64_t * v)
 {
-	unsigned long temp;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-	__asm__ __volatile__(
-	"1:	lld	%0, %1		# atomic64_sub		\n"
-	"	subu	%0, %2					\n"
-	"	scd	%0, %1					\n"
-	"	beqz	%0, 1b					\n"
-	: "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter));
+		__asm__ __volatile__(
+		"1:	lld	%0, %1		# atomic64_sub		\n"
+		"	subu	%0, %2					\n"
+		"	scd	%0, %1					\n"
+		"	beqzl	%0, 1b					\n"
+		: "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter));
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	lld	%0, %1		# atomic64_sub		\n"
+		"	subu	%0, %2					\n"
+		"	scd	%0, %1					\n"
+		"	beqz	%0, 1b					\n"
+		: "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter));
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		v->counter -= i;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 }
 
 /*
@@ -376,131 +435,90 @@
  */
 static __inline__ long atomic64_add_return(long i, atomic64_t * v)
 {
-	unsigned long temp, result;
+	unsigned long result;
+
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-	__asm__ __volatile__(
-	"1:	lld	%1, %2		# atomic64_add_return	\n"
-	"	addu	%0, %1, %3				\n"
-	"	scd	%0, %2					\n"
-	"	beqz	%0, 1b					\n"
-	"	addu	%0, %1, %3				\n"
-	"	sync						\n"
-	: "=&r" (result), "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter)
-	: "memory");
+		__asm__ __volatile__(
+		"1:	lld	%1, %2		# atomic64_add_return	\n"
+		"	addu	%0, %1, %3				\n"
+		"	scd	%0, %2					\n"
+		"	beqzl	%0, 1b					\n"
+		"	addu	%0, %1, %3				\n"
+		"	sync						\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	lld	%1, %2		# atomic64_add_return	\n"
+		"	addu	%0, %1, %3				\n"
+		"	scd	%0, %2					\n"
+		"	beqz	%0, 1b					\n"
+		"	addu	%0, %1, %3				\n"
+		"	sync						\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		result = v->counter;
+		result += i;
+		v->counter = result;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 
 	return result;
 }
 
 static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
 {
-	unsigned long temp, result;
+	unsigned long result;
 
-	__asm__ __volatile__(
-	"1:	lld	%1, %2		# atomic64_sub_return	\n"
-	"	subu	%0, %1, %3				\n"
-	"	scd	%0, %2					\n"
-	"	beqz	%0, 1b					\n"
-	"	subu	%0, %1, %3				\n"
-	"	sync						\n"
-	: "=&r" (result), "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter)
-	: "memory");
-
-	return result;
-}
-
-/*
- * atomic64_sub_if_positive - add integer to atomic variable
- * @v: pointer of type atomic64_t
- *
- * Atomically test @v and decrement if it is greater than 0.
- * The function returns the old value of @v minus 1.
- */
-static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
-{
-	unsigned long temp, result;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-	__asm__ __volatile__(
-	"1:	lld	%1, %2		# atomic64_sub_if_positive\n"
-	"	dsubu	%0, %1, %3				\n"
-	"	bltz	%0, 1f					\n"
-	"	scd	%0, %2					\n"
-	"	beqz	%0, 1b					\n"
-	"	sync						\n"
-	"1:							\n"
-	: "=&r" (result), "=&r" (temp), "=m" (v->counter)
-	: "Ir" (i), "m" (v->counter)
-	: "memory");
+		__asm__ __volatile__(
+		"1:	lld	%1, %2		# atomic64_sub_return	\n"
+		"	subu	%0, %1, %3				\n"
+		"	scd	%0, %2					\n"
+		"	beqzl	%0, 1b					\n"
+		"	subu	%0, %1, %3				\n"
+		"	sync						\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	lld	%1, %2		# atomic64_sub_return	\n"
+		"	subu	%0, %1, %3				\n"
+		"	scd	%0, %2					\n"
+		"	beqz	%0, 1b					\n"
+		"	subu	%0, %1, %3				\n"
+		"	sync						\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		result = v->counter;
+		result -= i;
+		v->counter = result;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 
 	return result;
 }
 
-#else
-
-/*
- * This implementation is only atomic with respect to interrupts.  It can't
- * be used on SMP
- *
- * atomic64_add - add integer to atomic variable
- * @i: integer value to add
- * @v: pointer of type atomic64_t
- *
- * Atomically adds @i to @v.
- */
-static __inline__ void atomic64_add(long i, atomic64_t * v)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&atomic_lock, flags);
-	v->counter += i;
-	spin_unlock_irqrestore(&atomic_lock, flags);
-}
-
-/*
- * atomic64_sub - subtract the atomic variable
- * @i: integer value to subtract
- * @v: pointer of type atomic64_t
- *
- * Atomically subtracts @i from @v.
- */
-static __inline__ void atomic64_sub(long i, atomic64_t * v)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&atomic_lock, flags);
-	v->counter -= i;
-	spin_unlock_irqrestore(&atomic_lock, flags);
-}
-
-static __inline__ long atomic64_add_return(long i, atomic64_t * v)
-{
-	unsigned long flags;
-	long temp;
-
-	spin_lock_irqsave(&atomic_lock, flags);
-	temp = v->counter;
-	temp += i;
-	v->counter = temp;
-	spin_unlock_irqrestore(&atomic_lock, flags);
-
-	return temp;
-}
-
-static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
-{
-	unsigned long flags;
-	long temp;
-
-	spin_lock_irqsave(&atomic_lock, flags);
-	temp = v->counter;
-	temp -= i;
-	v->counter = temp;
-	spin_unlock_irqrestore(&atomic_lock, flags);
-
-	return temp;
-}
-
 /*
  * atomic64_sub_if_positive - add integer to atomic variable
  * @v: pointer of type atomic64_t
@@ -510,20 +528,49 @@
  */
 static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
 {
-	unsigned long flags;
-	long temp;
+	unsigned long result;
 
-	spin_lock_irqsave(&atomic_lock, flags);
-	temp = v->counter;
-	temp -= i;
-	if (temp >= 0)
-		v->counter = temp;
-	spin_unlock_irqrestore(&atomic_lock, flags);
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long temp;
 
-	return temp;
-}
+		__asm__ __volatile__(
+		"1:	lld	%1, %2		# atomic64_sub_if_positive\n"
+		"	dsubu	%0, %1, %3				\n"
+		"	bltz	%0, 1f					\n"
+		"	scd	%0, %2					\n"
+		"	beqzl	%0, 1b					\n"
+		"	sync						\n"
+		"1:							\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else if (cpu_has_llsc) {
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	lld	%1, %2		# atomic64_sub_if_positive\n"
+		"	dsubu	%0, %1, %3				\n"
+		"	bltz	%0, 1f					\n"
+		"	scd	%0, %2					\n"
+		"	beqz	%0, 1b					\n"
+		"	sync						\n"
+		"1:							\n"
+		: "=&r" (result), "=&r" (temp), "=m" (v->counter)
+		: "Ir" (i), "m" (v->counter)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		spin_lock_irqsave(&atomic_lock, flags);
+		result = v->counter;
+		result -= i;
+		if (result >= 0)
+			v->counter = result;
+		spin_unlock_irqrestore(&atomic_lock, flags);
+	}
 
-#endif /* CONFIG_CPU_HAS_LLDSCD */
+	return result;
+}
 
 #define atomic64_dec_return(v) atomic64_sub_return(1,(v))
 #define atomic64_inc_return(v) atomic64_add_return(1,(v))
diff -Nru a/include/asm-mips/baget/baget.h b/include/asm-mips/baget/baget.h
--- a/include/asm-mips/baget/baget.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,69 +0,0 @@
-/*
- * baget.h: Definitions specific to Baget/MIPS machines.
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#ifndef _MIPS_BAGET_H
-#define _MIPS_BAGET_H
-
-#include "vic.h"
-#include "vac.h"
-
-#define VIC_BASE         0xBFFC0000
-#define VAC_BASE         0xBFFD0000
-
-
-/* Baget interrupt registers and their sizes */
-
-struct  baget_int_reg {
-	unsigned long address;
-	int size;  /* in bytes */
-};
-#define BAGET_INT_NONE   {0,0}
-
-#define BAGET_INT0_ACK   {0xbffa0003,1}
-#define BAGET_INT1_ACK   {0xbffa0008,4}
-#define BAGET_INT5_ACK   {0xbff00000,1}
-
-#define BAGET_WRERR_ACK  ((volatile char*)0xbff00000)
-
-
-/* Baget address spaces */
-
-#define BAGET_A24M_BASE       0xFC000000      /* VME-master A24 base address  */
-#define BAGET_A24S_BASE       0x00000000      /* VME-slave A24 base address   */
-#define BAGET_A24S_MASK       0x00c00000      /* VME-slave A24 address mask   */
-#define BAGET_GSW_BASE        0xf000          /* global switches address base */
-#define BAGET_MSW_BASE(P) (0xe000+(P)*0x100)  /* module switches address base */
-
-#define BAGET_LED_BASE  ((volatile short *)(0xbffd0000 + 0x00001800))
-
-#define BAGET_PIL_NR            8
-#define BAGET_IRQ_NR            NR_IRQS /* 64 */
-#define BAGET_IRQ_MASK(x)       ((NR_IRQS-1) & (x))
-
-#define BAGET_FPU_IRQ           0x26
-#define BAGET_VIC_TIMER_IRQ     0x32
-#define BAGET_VAC_TIMER_IRQ     0x36
-#define BAGET_BSM_IRQ           0x3C
-
-#define BAGET_LANCE_MEM_BASE    0xfcf10000
-#define BAGET_LANCE_MEM_SIZE    0x10000
-#define BAGET_LANCE_IO_BASE     0xbffeff00
-
-#define BALO_OFFSET     0x400000 /* sync with ld.script.balo  */
-#define BALO_SIZE       0x200000 /* sync with image segs size */
-
-/* move it to the right place, somehere in include/asm */
-#define CAUSE_DBE       0x1C
-#define CAUSE_MASK      0x7C
-
-/* Simple debug fascilities */
-extern void outc(char);
-extern void outs(char *);
-extern void baget_write(char *s, int l);
-extern int  baget_printk(const char *, ...);
-extern void balo_printf( char *f, ... );
-extern void balo_hungup(void);
-
-#endif /* !(_MIPS_BAGET_H) */
diff -Nru a/include/asm-mips/baget/vac.h b/include/asm-mips/baget/vac.h
--- a/include/asm-mips/baget/vac.h	2004-12-24 13:36:47 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,208 +0,0 @@
-/*
- * vac.h: Various VIC controller defines.  The VIC is a VME controller
- *        used in Baget/MIPS series.
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#ifndef _ASM_VAC_H
-#define _ASM_VAC_H
-
-#define VAC_SLSEL1_MASK      0x000
-#define VAC_SLSEL1_BASE      0x100
-#define VAC_SLSEL0_MASK      0x200
-#define VAC_SLSEL0_BASE      0x300
-#define VAC_ICFSEL_BASE      0x400
-#define VAC_ICFSEL_GLOBAL_VAL(x) (((x)>>8)&0xff)
-#define VAC_ICFSEL_MODULE_VAL(x) ((x)&0xff)
-#define VAC_DRAM_MASK        0x500
-#define VAC_BNDR2            0x600
-#define VAC_BNDR3            0x700
-#define VAC_A24_BASE         0x800
-#define    VAC_A24_MASK          (0x3f<<9)
-#define    VAC_A24_D32_ENABLE    (1<<8)
-#define    VAC_A24_A24_CACHINH   (1<<7)
-#define    VAC_A24_A16D32_ENABLE (1<<6)
-#define    VAC_A24_A16D32        (1<<5)
-#define    VAC_A24_DATAPATH      (1<<4)
-#define    VAC_A24_IO_CACHINH    (1<<3)
-#define VAC_REG1             0x900
-#define VAC_REG2             0xA00
-#define VAC_REG3             0xB00
-#define    VAC_REG_WORD      (1<<15)
-#define    VAC_REG_ASIZ1     (1<<14)
-#define    VAC_REG_ASIZ0     (1<<13)
-#define    VAC_REG_ASIZ_VAL(x) (((x)>>13)&3)
-#define    VAC_REG_CACHINH   (1<<12)
-#define    VAC_REG_INACTIVE  (0<<10)
-#define    VAC_REG_SHARED    (1<<10)
-#define    VAC_REG_VSB       (2<<10)
-#define    VAC_REG_MWB       (3<<10)
-#define    VAC_REG_MASK      (3<<10)
-#define    VAC_REG_MODE(x)   (((x)>>10)&3)
-#define VAC_IOSEL4_CTRL      0xC00
-#define VAC_IOSEL5_CTRL      0xD00
-#define VAC_SHRCS_CTRL       0xE00
-#define VAC_EPROMCS_CTRL     0xF00
-#define VAC_IOSEL0_CTRL      0x1000
-#define VAC_IOSEL1_CTRL      0x1100
-#define VAC_IOSEL2_CTRL      0x1200
-#define VAC_IOSEL3_CTRL      0x1300
-#define    VAC_CTRL_IOWR               (1<<0)
-#define    VAC_CTRL_IORD               (1<<1)
-#define    VAC_CTRL_DELAY_IOSELI(x)    (((x)&3)<<2)
-#define    VAC_CTRL_DELAY_IOSELI_VAL(x) (((x)>>2)&3)
-#define    VAC_CTRL_DELAY_IOWR(x)      (((x)&3)<<4)
-#define    VAC_CTRL_DELAY_IOWR_VAL(x)  (((x)>>4)&3)
-#define    VAC_CTRL_DELAY_IORD(x)      (((x)&3)<<6)
-#define    VAC_CTRL_DELAY_IORD_VAL(x)  (((x)>>6)&3)
-#define    VAC_CTRL_RECOVERY_IOSELI(x) ((((x)-1)&7)<<8)
-#define    VAC_CTRL_RECOVERY_IOSELI_VAL(x) ((((x)>>8)&7)+1)
-#define    VAC_CTRL_DSACK0             (1<<11)
-#define    VAC_CTRL_DSACK1             (1<<12)
-#define    VAC_CTRL_DELAY_DSACKI(x)    ((((x)-1)&7)<<13)
-#define    VAC_CTRL_DELAY_DSACKI_VAL(x) ((((x)>>13)&7)+1)
-#define VAC_DECODE_CTRL      0x1400
-#define    VAC_DECODE_FPUCS   (1<<0)
-#define    VAC_DECODE_CPUCLK(x)  (((x)&3)<<1)
-#define    VAC_DECODE_CPUCLK_VAL(x) (((x)>>1)&3)
-#define    VAC_DECODE_RDR_SLSEL0 (1<<3)
-#define    VAC_DECODE_RDR_SLSEL1 (1<<4)
-#define    VAC_DECODE_DSACK   (1<<5)
-#define    VAC_DECODE_QFY_BNDR    (1<<6)
-#define    VAC_DECODE_QFY_ICFSEL  (1<<7)
-#define    VAC_DECODE_QFY_SLSEL1  (1<<8)
-#define    VAC_DECODE_QFY_SLSEL0  (1<<9)
-#define    VAC_DECODE_CMP_SLSEL1_LO  (1<<10)
-#define    VAC_DECODE_CMP_SLSEL1_HI  (1<<11)
-#define    VAC_DECODE_CMP_SLSEL1_VAL(x) (((x)>>10)&3)
-#define    VAC_DECODE_DRAMCS  (3<<12)
-#define    VAC_DECODE_SHRCS   (2<<12)
-#define    VAC_DECODE_VSBSEL  (1<<12)
-#define    VAC_DECODE_EPROMCS (0<<12)
-#define    VAC_DECODE_MODE_VAL(x) (((x)>>12)&3)
-#define    VAC_DECODE_QFY_DRAMCS  (1<<14)
-#define    VAC_DECODE_DSACKI  (1<<15)
-#define VAC_INT_STATUS       0x1500
-#define VAC_INT_CTRL         0x1600
-#define    VAC_INT_CTRL_TIMER_PIO11    (3<<0)
-#define    VAC_INT_CTRL_TIMER_PIO10    (2<<0)
-#define    VAC_INT_CTRL_TIMER_PIO7     (1<<0)
-#define    VAC_INT_CTRL_TIMER_DISABLE  (0<<0)
-#define    VAC_INT_CTRL_TIMER_MASK     (3<<0)
-#define    VAC_INT_CTRL_UART_B_PIO11   (3<<2)
-#define    VAC_INT_CTRL_UART_B_PIO10   (2<<2)
-#define    VAC_INT_CTRL_UART_B_PIO7    (1<<2)
-#define    VAC_INT_CTRL_UART_B_DISABLE (0<<2)
-#define    VAC_INT_CTRL_UART_A_PIO11   (3<<4)
-#define    VAC_INT_CTRL_UART_A_PIO10   (2<<4)
-#define    VAC_INT_CTRL_UART_A_PIO7    (1<<4)
-#define    VAC_INT_CTRL_UART_A_DISABLE (0<<4)
-#define    VAC_INT_CTRL_MBOX_PIO11     (3<<6)
-#define    VAC_INT_CTRL_MBOX_PIO10     (2<<6)
-#define    VAC_INT_CTRL_MBOX_PIO7      (1<<6)
-#define    VAC_INT_CTRL_MBOX_DISABLE   (0<<6)
-#define    VAC_INT_CTRL_PIO4_PIO11     (3<<8)
-#define    VAC_INT_CTRL_PIO4_PIO10     (2<<8)
-#define    VAC_INT_CTRL_PIO4_PIO7      (1<<8)
-#define    VAC_INT_CTRL_PIO4_DISABLE   (0<<8)
-#define    VAC_INT_CTRL_PIO7_PIO11     (3<<10)
-#define    VAC_INT_CTRL_PIO7_PIO10     (2<<10)
-#define    VAC_INT_CTRL_PIO7_PIO7      (1<<10)
-#define    VAC_INT_CTRL_PIO7_DISABLE   (0<<10)
-#define    VAC_INT_CTRL_PIO8_PIO11     (3<<12)
-#define    VAC_INT_CTRL_PIO8_PIO10     (2<<12)
-#define    VAC_INT_CTRL_PIO8_PIO7      (1<<12)
-#define    VAC_INT_CTRL_PIO8_DISABLE   (0<<12)
-#define    VAC_INT_CTRL_PIO9_PIO11     (3<<14)
-#define    VAC_INT_CTRL_PIO9_PIO10     (2<<14)
-#define    VAC_INT_CTRL_PIO9_PIO7      (1<<14)
-#define    VAC_INT_CTRL_PIO9_DISABLE   (0<<14)
-#define VAC_DEV_LOC          0x1700
-#define    VAC_DEV_LOC_IOSEL(x)   (1<<(x))
-#define VAC_PIO_DATA_OUT     0x1800
-#define VAC_PIO_PIN          0x1900
-#define VAC_PIO_DIRECTION    0x1A00
-#define    VAC_PIO_DIR_OUT(x)     (1<<(x))
-#define    VAC_PIO_DIR_IN(x)      (0<<(x))
-#define    VAC_PIO_DIR_FCIACK     (1<<14)
-#define VAC_PIO_FUNC         0x1B00
-#define    VAC_PIO_FUNC_UART_A_TX (1<<0)
-#define    VAC_PIO_FUNC_UART_A_RX (1<<1)
-#define    VAC_PIO_FUNC_UART_B_TX (1<<2)
-#define    VAC_PIO_FUNC_UART_B_RX (1<<3)
-#define    VAC_PIO_FUNC_IORD      (1<<4)
-#define    VAC_PIO_FUNC_IOWR      (1<<5)
-#define    VAC_PIO_FUNC_IOSEL3    (1<<6)
-#define    VAC_PIO_FUNC_IRQ7      (1<<7)
-#define    VAC_PIO_FUNC_IOSEL4    (1<<8)
-#define    VAC_PIO_FUNC_IOSEL5    (1<<9)
-#define    VAC_PIO_FUNC_IRQ10     (1<<10)
-#define    VAC_PIO_FUNC_IRQ11     (1<<11)
-#define    VAC_PIO_FUNC_OUT       (1<<12)
-#define    VAC_PIO_FUNC_IOSEL2    (1<<13)
-#define    VAC_PIO_FUNC_DELAY     (1<<14)
-#define    VAC_PIO_FUNC_FCIACK    (1<<15)
-#define VAC_CPU_CLK_DIV      0x1C00
-#define VAC_UART_A_MODE      0x1D00
-#define    VAC_UART_MODE_PARITY_ENABLE  (1<<15) /* Inversed in manual ? */
-#define    VAC_UART_MODE_PARITY_ODD     (1<<14) /* Inversed in manual ? */
-#define    VAC_UART_MODE_8BIT_CHAR      (1<<13)
-#define    VAC_UART_MODE_BAUD(x)        (((x)&7)<<10)
-#define    VAC_UART_MODE_CHAR_RX_ENABLE (1<<9)
-#define    VAC_UART_MODE_CHAR_TX_ENABLE (1<<8)
-#define    VAC_UART_MODE_TX_ENABLE      (1<<7)
-#define    VAC_UART_MODE_RX_ENABLE      (1<<6)
-#define    VAC_UART_MODE_SEND_BREAK     (1<<5)
-#define    VAC_UART_MODE_LOOPBACK       (1<<4)
-#define    VAC_UART_MODE_INITIAL        (VAC_UART_MODE_8BIT_CHAR | \
-                                         VAC_UART_MODE_TX_ENABLE | \
-                                         VAC_UART_MODE_RX_ENABLE | \
-                                         VAC_UART_MODE_CHAR_TX_ENABLE | \
-                                         VAC_UART_MODE_CHAR_RX_ENABLE | \
-                                         VAC_UART_MODE_BAUD(5)) /* 9600/4 */
-#define VAC_UART_A_TX        0x1E00
-#define VAC_UART_B_MODE      0x1F00
-#define VAC_UART_A_RX        0x2000
-#define    VAC_UART_RX_ERR_BREAK        (1<<10)
-#define    VAC_UART_RX_ERR_FRAME        (1<<9)
-#define    VAC_UART_RX_ERR_PARITY       (1<<8)
-#define    VAC_UART_RX_DATA_MASK        (0xff)
-#define VAC_UART_B_RX        0x2100
-#define VAC_UART_B_TX        0x2200
-#define VAC_UART_A_INT_MASK  0x2300
-#define    VAC_UART_INT_RX_READY        (1<<15)
-#define    VAC_UART_INT_RX_FULL         (1<<14)
-#define    VAC_UART_INT_RX_BREAK_CHANGE (1<<13)
-#define    VAC_UART_INT_RX_ERRS         (1<<12)
-#define    VAC_UART_INT_TX_READY        (1<<11)
-#define    VAC_UART_INT_TX_EMPTY        (1<<10)
-#define VAC_UART_B_INT_MASK  0x2400
-#define VAC_UART_A_INT_STATUS  0x2500
-#define    VAC_UART_STATUS_RX_READY        (1<<15)
-#define    VAC_UART_STATUS_RX_FULL         (1<<14)
-#define    VAC_UART_STATUS_RX_BREAK_CHANGE (1<<13)
-#define    VAC_UART_STATUS_RX_ERR_PARITY   (1<<12)
-#define    VAC_UART_STATUS_RX_ERR_FRAME    (1<<11)
-#define    VAC_UART_STATUS_RX_ERR_OVERRUN  (1<<10)
-#define    VAC_UART_STATUS_TX_READY        (1<<9)
-#define    VAC_UART_STATUS_TX_EMPTY        (1<<8)
-#define    VAC_UART_STATUS_INTS            (0xff<<8)
-#define VAC_UART_B_INT_STATUS  0x2600
-#define VAC_TIMER_DATA       0x2700
-#define VAC_TIMER_CTRL       0x2800
-#define    VAC_TIMER_ONCE      (1<<15)
-#define    VAC_TIMER_ENABLE    (1<<14)
-#define    VAC_TIMER_PRESCALE(x) (((x)&0x3F)<<8)
-#define VAC_ID               0x2900
-
-
-#ifndef __ASSEMBLY__
-
-#define vac_inb(p)    (*(volatile unsigned char *)(VAC_BASE + (p)))
-#define vac_outb(v,p) (*((volatile unsigned char *)(VAC_BASE + (p))) = v)
-#define vac_inw(p)    (*(volatile unsigned short*)(VAC_BASE + (p)))
-#define vac_outw(v,p) (*((volatile unsigned short*)(VAC_BASE + (p))) = v)
-
-#endif /* !__ASSEMBLY__ */
-
-#endif /* _ASM_VAC_H */
diff -Nru a/include/asm-mips/baget/vic.h b/include/asm-mips/baget/vic.h
--- a/include/asm-mips/baget/vic.h	2004-12-24 13:36:18 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,192 +0,0 @@
-/*
- * vic.h: Various VIC controller defines.  The VIC is an interrupt controller
- *        used in Baget/MIPS series.
- *
- * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
- */
-#ifndef _ASM_BAGET_VIC_H
-#define _ASM_BAGET_VIC_H
-
-#define VIC_VME_II       0x3
-#define VIC_VME_INT1     0x7
-#define VIC_VME_INT2     0xB
-#define VIC_VME_INT3     0xF
-#define VIC_VME_INT4     0x13
-#define VIC_VME_INT5     0x17
-#define VIC_VME_INT6     0x1B
-#define VIC_VME_INT7     0x1F
-#define VIC_DMA_INT      0x23
-#define VIC_LINT1        0x27
-#define VIC_LINT2        0x2B
-#define VIC_LINT3        0x2F
-#define VIC_LINT4        0x33
-#define VIC_LINT5        0x37
-#define VIC_LINT6        0x3B
-#define VIC_LINT7        0x3F
-#define VIC_ICGS_INT     0x43
-#define VIC_ICMS_INT     0x47
-#define    VIC_INT_IPL(lev)  ((~(lev))&0x7)
-#define    VIC_INT_ACTIVE    (1<<3)
-#define    VIC_INT_AUTO      (0<<4)
-#define    VIC_INT_NOAUTO    (1<<4)
-#define    VIC_INT_LEVEL     (0<<5)
-#define    VIC_INT_EDGE      (1<<5)
-#define    VIC_INT_LOW       (0<<6)
-#define    VIC_INT_HIGH      (1<<6)
-#define    VIC_INT_ENABLE    (0<<7)
-#define    VIC_INT_DISABLE   (1<<7)
-#define    VIC_INT_SWITCH(x) (1<<(((x)&0x3)+4))
-#define VIC_ERR_INT      0x4B
-#define    VIC_ERR_INT_SYSFAIL_ACTIVE  (1<<3)
-#define    VIC_ERR_INT_SYSFAIL  (1<<4)
-#define    VIC_ERR_INT_TIMO     (1<<5)
-#define    VIC_ERR_INT_WRPOST   (1<<6)
-#define    VIC_ERR_INT_ACFAIL   (1<<7)
-#define VIC_ICGS_BASE    0x4F
-#define VIC_ICMS_BASE    0x53
-#define    VIC_ICxS_BASE_GSWITCH_MASK 0x3
-#define    VIC_ICxS_BASE_ID(x)  (((x)&0x3f)<<2)
-#define VIC_LOCAL_BASE   0x57
-#define    VIC_LOCAL_BASE_LINT_MASK 0x7
-#define    VIC_LOCAL_BASE_ID(x)  (((x)&0x1f)<<3)
-#define VIC_ERR_BASE     0x5B
-#define    VIC_ERR_BASE_ACFAIL   0
-#define    VIC_ERR_BASE_WRPOST   1
-#define    VIC_ERR_BASE_TIMO     2
-#define    VIC_ERR_BASE_SYSFAIL  3
-#define    VIC_ERR_BASE_VMEACK   4
-#define    VIC_ERR_BASE_DMA      5
-#define    VIC_ERR_BASE_ID(x)  (((x)&0x1f)<<3)
-#define VIC_ICS          0x5F
-#define VIC_IC0          0x63
-#define VIC_IC1          0x67
-#define VIC_IC2          0x6B
-#define VIC_IC3          0x6F
-#define VIC_IC4          0x73
-#define VIC_ID           0x77
-#define VIC_IC6          0x7B
-#define    VIC_IC6_IRESET_STATUS (1<<7)
-#define    VIC_IC6_HALT_STATUS   (1<<6)
-#define    VIC_IC6_SYSRESET   (3<<0)
-#define    VIC_IC6_RESET      (2<<0)
-#define    VIC_IC6_HALT       (1<<0)
-#define    VIC_IC6_RUN        (0<<0)
-#define VIC_IC7          0x7F
-#define    VIC_IC7_SYSFAIL     (1<<7)
-#define    VIC_IC7_RESET       (1<<6)
-#define    VIC_IC7_VME_MASTER  (1<<5)
-#define    VIC_IC7_SEMSET(x)   ((1<<(x))&0x1f)
-#define VIC_VME_REQ      0x83
-#define VIC_VME_BASE1    0x87
-#define VIC_VME_BASE2    0x8B
-#define VIC_VME_BASE3    0x8F
-#define VIC_VME_BASE4    0x93
-#define VIC_VME_BASE5    0x97
-#define VIC_VME_BASE6    0x9B
-#define VIC_VME_BASE7    0x9F
-#define VIC_XFER_TIMO    0xA3
-#define    VIC_XFER_TIMO_VME_PERIOD_INF (7<<5)
-#define    VIC_XFER_TIMO_VME_PERIOD_512 (6<<5)
-#define    VIC_XFER_TIMO_VME_PERIOD_256 (5<<5)
-#define    VIC_XFER_TIMO_VME_PERIOD_128 (4<<5)
-#define    VIC_XFER_TIMO_VME_PERIOD_64 (3<<5)
-#define    VIC_XFER_TIMO_VME_PERIOD_32 (2<<5)
-#define    VIC_XFER_TIMO_VME_PERIOD_16 (1<<5)
-#define    VIC_XFER_TIMO_VME_PERIOD_4  (0<<5)
-#define    VIC_XFER_TIMO_VME_PERIOD_VAL(x) (((x)>>5)&7)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_INF (7<<2)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_512 (6<<2)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_256 (5<<2)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_128 (4<<2)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_64 (3<<2)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_32 (2<<2)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_16 (1<<2)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_4  (0<<2)
-#define    VIC_XFER_TIMO_LOCAL_PERIOD_VAL(x) (((x)>>2)&7)
-#define    VIC_XFER_TIMO_ARB  (1<<1)
-#define    VIC_XFER_TIMO_VME  (1<<0)
-#define VIC_LOCAL_TIM    0xA7
-#define    VIC_LOCAL_TIM_PAS_ASSERT(x)   (((x)-2)&0xf)
-#define    VIC_LOCAL_TIM_PAS_ASSERT_VAL(x) (((x)&0xf)+2)
-#define    VIC_LOCAT_TIM_DS_DEASSERT(x)  ((((x)-1)&1)<<4)
-#define    VIC_LOCAT_TIM_DS_DEASSERT_VAL(x)  ((((x)>>4)&1)+1)
-#define    VIC_LOCAL_TIM_PAS_DEASSERT(x) ((((x)-1)&0x7)<<5)
-#define    VIC_LOCAL_TIM_PAS_DEASSERT_VAL(x) ((((x)>>5)&0x7)+1)
-#define VIC_BXFER_DEF    0xAB
-#define    VIC_BXFER_DEF_VME_CROSS    (1<<3)
-#define    VIC_BXFER_DEF_LOCAL_CROSS  (1<<2)
-#define    VIC_BXFER_DEF_AMSR   (1<<1)
-#define    VIC_BXFER_DEF_DUAL   (1<<0)
-#define VIC_IFACE_CFG    0xAF
-#define    VIC_IFACE_CFG_RMC3    (1<<7)
-#define    VIC_IFACE_CFG_RMC2    (1<<6)
-#define    VIC_IFACE_CFG_RMC1    (1<<5)
-#define    VIC_IFACE_CFG_HALT    (1<<4)
-#define    VIC_IFACE_CFG_NOHALT  (0<<4)
-#define    VIC_IFACE_CFG_NORMC   (1<<3)
-#define    VIC_IFACE_CFG_DEADLOCK_VAL(x) (((x)>>3)&3)
-#define    VIC_IFACE_CFG_MSTAB   (1<<2)
-#define    VIC_IFACE_CFG_TURBO   (1<<1)
-#define    VIC_IFACE_CFG_NOTURBO (0<<1)
-#define    VIC_IFACE_CFG_VME     (1<<0)
-#define VIC_REQ_CFG      0xB3
-#define    VIC_REQ_CFG_FAIRNESS_DISABLED  0
-#define    VIC_REQ_CFG_FAIRNESS_ENABLED   1
-#define    VIC_REQ_CFG_TIMO_DISABLED      0xf
-#define    VIC_REQ_CFG_DRAM_REFRESH       (1<<4)
-#define    VIC_REQ_CFG_LEVEL(x)           (((x)&3)<<5)
-#define    VIC_REQ_CFG_PRIO_ARBITRATION   (1<<7)
-#define    VIC_REQ_CFG_RR_ARBITRATION     (0<<7)
-#define VIC_AMS          0xB7
-#define    VIC_AMS_AM_2_0   (1<<7)
-#define    VIC_AMS_AM_5_3   (1<<6)
-#define    VIC_AMS_CODE(x)  ((x)&0x1f)
-#define VIC_BERR_STATUS  0xBB
-#define VIC_DMA_STATUS   0xBF
-#define VIC_SS0CR0       0xC3
-#define VIC_SS1CR0       0xCB
-#define    VIC_SSxCR0_LOCAL_XFER_ACCEL  (2)
-#define    VIC_SSxCR0_LOCAL_XFER_SINGLE (1)
-#define    VIC_SSxCR0_LOCAL_XFER_NONE   (0)
-#define    VIC_SSxCR0_A32       (0<<2)
-#define    VIC_SSxCR0_A24       (1<<2)
-#define    VIC_SSxCR0_A16       (2<<2)
-#define    VIC_SSxCR0_USER      (3<<2)
-#define    VIC_SSxCR0_D32       (1<<4)
-#define    VIC_SSxCR0_SUPER     (1<<5)
-#define    VIC_SS0CR0_TIMER_FREQ_MASK   (3<<6)
-#define    VIC_SS0CR0_TIMER_FREQ_NONE   (0<<6)
-#define    VIC_SS0CR0_TIMER_FREQ_50HZ   (1<<6)
-#define    VIC_SS0CR0_TIMER_FREQ_1000HZ (2<<6)
-#define    VIC_SS0CR0_TIMER_FREQ_100HZ  (3<<6)
-#define    VIC_SS1CR0_MASTER_WRPOST (1<<6)
-#define    VIC_SS1CR0_SLAVE_WRPOST  (1<<7)
-#define VIC_SS0CR1       0xC7
-#define VIC_SS1CR1       0xCF
-#define    VIC_SSxCR1_TF2(x)  (((x)&0xf)<<4)
-#define    VIC_SSxCR1_TF1(x)  ((x)&0xf)
-#define VIC_RELEASE      0xD3
-#define    VIC_RELEASE_BLKXFER_BLEN(x) ((x)&0x1f)
-#define    VIC_RELEASE_ROR             (0<<6)
-#define    VIC_RELEASE_RWD             (1<<6)
-#define    VIC_RELEASE_ROC             (2<<6)
-#define    VIC_RELEASE_BCAP            (3<<6)
-#define VIC_BXFER_CTRL   0xD7
-#define    VIC_BXFER_CTRL_MODULE     (1<<7)
-#define    VIC_BXFER_CTRL_LOCAL      (1<<6)
-#define    VIC_BXFER_CTRL_MOVEM      (1<<5)
-#define    VIC_BXFER_CTRL_READ       (1<<4)
-#define    VIC_BXFER_CTRL_WRITE      (0<<4)
-#define    VIC_BXFER_CTRL_INTERLEAVE(x)  ((x)&0xf)
-#define VIC_BXFER_LEN_LO    0xDB
-#define VIC_BXFER_LEN_HI    0xDF
-#define VIC_SYS_RESET    0xE3
-
-#ifndef __ASSEMBLY__
-
-#define vic_inb(p)    (*(volatile unsigned char *)(VIC_BASE + (p)))
-#define vic_outb(v,p) (*((volatile unsigned char *)(VIC_BASE + (p))) = v)
-
-#endif /* !__ASSEMBLY__ */
-
-#endif /* _ASM_BAGET_VIC_H */
diff -Nru a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
--- a/include/asm-mips/bitops.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-mips/bitops.h	2004-12-24 13:36:18 -08:00
@@ -13,25 +13,27 @@
 #include <linux/compiler.h>
 #include <linux/types.h>
 #include <asm/byteorder.h>		/* sigh ... */
+#include <asm/cpu-features.h>
 
 #if (_MIPS_SZLONG == 32)
 #define SZLONG_LOG 5
 #define SZLONG_MASK 31UL
-#define __LL	"ll"
-#define __SC	"sc"
+#define __LL	"ll	"
+#define __SC	"sc	"
 #define cpu_to_lelongp(x) cpu_to_le32p((__u32 *) (x)) 
 #elif (_MIPS_SZLONG == 64)
 #define SZLONG_LOG 6
 #define SZLONG_MASK 63UL
-#define __LL	"lld"
-#define __SC	"scd"
+#define __LL	"lld	"
+#define __SC	"scd	"
 #define cpu_to_lelongp(x) cpu_to_le64p((__u64 *) (x)) 
 #endif
 
 #ifdef __KERNEL__
 
+#include <asm/interrupt.h>
 #include <asm/sgidefs.h>
-#include <asm/system.h>
+#include <asm/war.h>
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
@@ -43,26 +45,16 @@
  * Only disable interrupt for kernel mode stuff to keep usermode stuff
  * that dares to use kernel include files alive.
  */
+
 #define __bi_flags			unsigned long flags
-#define __bi_cli()			local_irq_disable()
-#define __bi_save_flags(x)		local_save_flags(x)
 #define __bi_local_irq_save(x)		local_irq_save(x)
 #define __bi_local_irq_restore(x)	local_irq_restore(x)
 #else
 #define __bi_flags
-#define __bi_cli()
-#define __bi_save_flags(x)
 #define __bi_local_irq_save(x)
 #define __bi_local_irq_restore(x)
 #endif /* __KERNEL__ */
 
-#ifdef CONFIG_CPU_HAS_LLSC
-
-/*
- * These functions for MIPS ISA > 1 are interrupt and SMP proof and
- * interrupt friendly
- */
-
 /*
  * set_bit - Atomically set a bit in memory
  * @nr: the bit to set
@@ -78,13 +70,33 @@
 	unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
 	unsigned long temp;
 
-	__asm__ __volatile__(
-		"1:\t" __LL "\t%0, %1\t\t# set_bit\n\t"
-		"or\t%0, %2\n\t"
-		__SC "\t%0, %1\n\t"
-		"beqz\t%0, 1b"
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"1:	" __LL "%0, %1			# set_bit	\n"
+		"	or	%0, %2					\n"
+		"	"__SC	"%0, %1					\n"
+		"	beqzl	%0, 1b					\n"
 		: "=&r" (temp), "=m" (*m)
 		: "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m));
+	} else if (cpu_has_llsc) {
+		__asm__ __volatile__(
+		"1:	" __LL "%0, %1			# set_bit	\n"
+		"	or	%0, %2					\n"
+		"	"__SC	"%0, %1					\n"
+		"	beqz	%0, 1b					\n"
+		: "=&r" (temp), "=m" (*m)
+		: "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m));
+	} else {
+		volatile unsigned long *a = addr;
+		unsigned long mask;
+		__bi_flags;
+
+		a += nr >> SZLONG_LOG;
+		mask = 1 << (nr & SZLONG_MASK);
+		__bi_local_irq_save(flags);
+		*a |= mask;
+		__bi_local_irq_restore(flags);
+	}
 }
 
 /*
@@ -118,13 +130,33 @@
 	unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
 	unsigned long temp;
 
-	__asm__ __volatile__(
-		"1:\t" __LL "\t%0, %1\t\t# clear_bit\n\t"
-		"and\t%0, %2\n\t"
-		__SC "\t%0, %1\n\t"
-		"beqz\t%0, 1b\n\t"
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"1:	" __LL "%0, %1			# clear_bit	\n"
+		"	and	%0, %2					\n"
+		"	" __SC "%0, %1					\n"
+		"	beqzl	%0, 1b					\n"
+		: "=&r" (temp), "=m" (*m)
+		: "ir" (~(1UL << (nr & SZLONG_MASK))), "m" (*m));
+	} else if (cpu_has_llsc) {
+		__asm__ __volatile__(
+		"1:	" __LL "%0, %1			# clear_bit	\n"
+		"	and	%0, %2					\n"
+		"	" __SC "%0, %1					\n"
+		"	beqz	%0, 1b					\n"
 		: "=&r" (temp), "=m" (*m)
 		: "ir" (~(1UL << (nr & SZLONG_MASK))), "m" (*m));
+	} else {
+		volatile unsigned long *a = addr;
+		unsigned long mask;
+		__bi_flags;
+
+		a += nr >> SZLONG_LOG;
+		mask = 1 << (nr & SZLONG_MASK);
+		__bi_local_irq_save(flags);
+		*a &= ~mask;
+		__bi_local_irq_restore(flags);
+	}
 }
 
 /*
@@ -154,16 +186,39 @@
  */
 static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
 {
-	unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
-	unsigned long temp;
-
-	__asm__ __volatile__(
-		"1:\t" __LL "\t%0, %1\t\t# change_bit\n\t"
-		"xor\t%0, %2\n\t"
-		__SC "\t%0, %1\n\t"
-		"beqz\t%0, 1b"
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	" __LL "%0, %1		# change_bit	\n"
+		"	xor	%0, %2				\n"
+		"	"__SC	"%0, %1				\n"
+		"	beqzl	%0, 1b				\n"
+		: "=&r" (temp), "=m" (*m)
+		: "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m));
+	} else if (cpu_has_llsc) {
+		unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
+		unsigned long temp;
+
+		__asm__ __volatile__(
+		"1:	" __LL "%0, %1		# change_bit	\n"
+		"	xor	%0, %2				\n"
+		"	"__SC	"%0, %1				\n"
+		"	beqz	%0, 1b				\n"
 		: "=&r" (temp), "=m" (*m)
 		: "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m));
+	} else {
+		volatile unsigned long *a = addr;
+		unsigned long mask;
+		__bi_flags;
+
+		a += nr >> SZLONG_LOG;
+		mask = 1 << (nr & SZLONG_MASK);
+		__bi_local_irq_save(flags);
+		*a ^= mask;
+		__bi_local_irq_restore(flags);
+	}
 }
 
 /*
@@ -193,25 +248,59 @@
 static inline int test_and_set_bit(unsigned long nr,
 	volatile unsigned long *addr)
 {
-	unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
-	unsigned long temp, res;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
+		unsigned long temp, res;
+
+		__asm__ __volatile__(
+		"1:	" __LL "%0, %1		# test_and_set_bit	\n"
+		"	or	%2, %0, %3				\n"
+		"	" __SC	"%2, %1					\n"
+		"	beqzl	%2, 1b					\n"
+		"	and	%2, %0, %3				\n"
+#ifdef CONFIG_SMP
+		"sync							\n"
+#endif
+		: "=&r" (temp), "=m" (*m), "=&r" (res)
+		: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
+		: "memory");
 
-	__asm__ __volatile__(
-		".set\tnoreorder\t\t# test_and_set_bit\n"
-		"1:\t" __LL "\t%0, %1\n\t"
-		"or\t%2, %0, %3\n\t"
-		__SC "\t%2, %1\n\t"
-		"beqz\t%2, 1b\n\t"
-		" and\t%2, %0, %3\n\t"
+		return res != 0;
+	} else if (cpu_has_llsc) {
+		unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
+		unsigned long temp, res;
+
+		__asm__ __volatile__(
+		"	.set	noreorder	# test_and_set_bit	\n"
+		"1:	" __LL "%0, %1					\n"
+		"	or	%2, %0, %3				\n"
+		"	" __SC	"%2, %1					\n"
+		"	beqz	%2, 1b					\n"
+		"	 and	%2, %0, %3				\n"
 #ifdef CONFIG_SMP
-		"sync\n\t"
+		"sync							\n"
 #endif
 		".set\treorder"
 		: "=&r" (temp), "=m" (*m), "=&r" (res)
 		: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
 		: "memory");
 
-	return res != 0;
+		return res != 0;
+	} else {
+		volatile unsigned long *a = addr;
+		unsigned long mask;
+		int retval;
+		__bi_flags;
+
+		a += nr >> SZLONG_LOG;
+		mask = 1 << (nr & SZLONG_MASK);
+		__bi_local_irq_save(flags);
+		retval = (mask & *a) != 0;
+		*a |= mask;
+		__bi_local_irq_restore(flags);
+
+		return retval;
+	}
 }
 
 /*
@@ -249,26 +338,61 @@
 static inline int test_and_clear_bit(unsigned long nr,
 	volatile unsigned long *addr)
 {
-	unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
-	unsigned long temp, res;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
+		unsigned long temp, res;
+
+		__asm__ __volatile__(
+		"1:	" __LL	"%0, %1		# test_and_clear_bit	\n"
+		"	or	%2, %0, %3				\n"
+		"	xor	%2, %3					\n"
+			__SC 	"%2, %1					\n"
+		"	beqzl	%2, 1b					\n"
+		"	and	%2, %0, %3				\n"
+#ifdef CONFIG_SMP
+		"	sync						\n"
+#endif
+		: "=&r" (temp), "=m" (*m), "=&r" (res)
+		: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
+		: "memory");
 
-	__asm__ __volatile__(
-		".set\tnoreorder\t\t# test_and_clear_bit\n"
-		"1:\t" __LL "\t%0, %1\n\t"
-		"or\t%2, %0, %3\n\t"
-		"xor\t%2, %3\n\t"
-		__SC "\t%2, %1\n\t"
-		"beqz\t%2, 1b\n\t"
-		" and\t%2, %0, %3\n\t"
+		return res != 0;
+	} else if (cpu_has_llsc) {
+		unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
+		unsigned long temp, res;
+
+		__asm__ __volatile__(
+		"	.set	noreorder	# test_and_clear_bit	\n"
+		"1:	" __LL	"%0, %1					\n"
+		"	or	%2, %0, %3				\n"
+		"	xor	%2, %3					\n"
+			__SC 	"%2, %1					\n"
+		"	beqz	%2, 1b					\n"
+		"	 and	%2, %0, %3				\n"
 #ifdef CONFIG_SMP
-		"sync\n\t"
+		"	sync						\n"
 #endif
-		".set\treorder"
+		"	.set	reorder					\n"
 		: "=&r" (temp), "=m" (*m), "=&r" (res)
 		: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
 		: "memory");
 
-	return res != 0;
+		return res != 0;
+	} else {
+		volatile unsigned long *a = addr;
+		unsigned long mask;
+		int retval;
+		__bi_flags;
+
+		a += nr >> SZLONG_LOG;
+		mask = 1 << (nr & SZLONG_MASK);
+		__bi_local_irq_save(flags);
+		retval = (mask & *a) != 0;
+		*a &= ~mask;
+		__bi_local_irq_restore(flags);
+
+		return retval;
+	}
 }
 
 /*
@@ -306,25 +430,58 @@
 static inline int test_and_change_bit(unsigned long nr,
 	volatile unsigned long *addr)
 {
-	unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
-	unsigned long temp, res;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
+		unsigned long temp, res;
+
+		__asm__ __volatile__(
+		"1:	" __LL	" %0, %1	# test_and_change_bit	\n"
+		"	xor	%2, %0, %3				\n"
+		"	"__SC	"%2, %1					\n"
+		"	beqzl	%2, 1b					\n"
+		"	and	%2, %0, %3				\n"
+#ifdef CONFIG_SMP
+		"	sync						\n"
+#endif
+		: "=&r" (temp), "=m" (*m), "=&r" (res)
+		: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
+		: "memory");
 
-	__asm__ __volatile__(
-		".set\tnoreorder\t\t# test_and_change_bit\n"
-		"1:\t" __LL "\t%0, %1\n\t"
-		"xor\t%2, %0, %3\n\t"
-		__SC "\t%2, %1\n\t"
-		"beqz\t%2, 1b\n\t"
-		" and\t%2, %0, %3\n\t"
+		return res != 0;
+	} else if (cpu_has_llsc) {
+		unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
+		unsigned long temp, res;
+
+		__asm__ __volatile__(
+		"	.set	noreorder	# test_and_change_bit	\n"
+		"1:	" __LL	" %0, %1				\n"
+		"	xor	%2, %0, %3				\n"
+		"	"__SC	"\t%2, %1				\n"
+		"	beqz	%2, 1b					\n"
+		"	 and	%2, %0, %3				\n"
 #ifdef CONFIG_SMP
-		"sync\n\t"
+		"	sync						\n"
 #endif
-		".set\treorder"
+		"	.set	reorder					\n"
 		: "=&r" (temp), "=m" (*m), "=&r" (res)
 		: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
 		: "memory");
 
-	return res != 0;
+		return res != 0;
+	} else {
+		volatile unsigned long *a = addr;
+		unsigned long mask, retval;
+		__bi_flags;
+
+		a += nr >> SZLONG_LOG;
+		mask = 1 << (nr & SZLONG_MASK);
+		__bi_local_irq_save(flags);
+		retval = (mask & *a) != 0;
+		*a ^= mask;
+		__bi_local_irq_restore(flags);
+
+		return retval;
+	}
 }
 
 /*
@@ -351,276 +508,9 @@
 	return retval;
 }
 
-#else /* MIPS I */
-
-/*
- * set_bit - Atomically set a bit in memory
- * @nr: the bit to set
- * @addr: the address to start counting from
- *
- * This function is atomic and may not be reordered.  See __set_bit()
- * if you do not require the atomic guarantees.
- * Note that @nr may be almost arbitrarily large; this function is not
- * restricted to acting on a single-word quantity.
- */
-static inline void set_bit(unsigned long nr, volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-	__bi_flags;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	__bi_local_irq_save(flags);
-	*a |= mask;
-	__bi_local_irq_restore(flags);
-}
-
-/*
- * __set_bit - Set a bit in memory
- * @nr: the bit to set
- * @addr: the address to start counting from
- *
- * Unlike set_bit(), this function is non-atomic and may be reordered.
- * If it's called on the same region of memory simultaneously, the effect
- * may be that only one operation succeeds.
- */
-static inline void __set_bit(unsigned long nr, volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	*a |= mask;
-}
-
-/*
- * clear_bit - Clears a bit in memory
- * @nr: Bit to clear
- * @addr: Address to start counting from
- *
- * clear_bit() is atomic and may not be reordered.  However, it does
- * not contain a memory barrier, so if it is used for locking purposes,
- * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
- * in order to ensure changes are visible on other processors.
- */
-static inline void clear_bit(unsigned long nr, volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-	__bi_flags;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	__bi_local_irq_save(flags);
-	*a &= ~mask;
-	__bi_local_irq_restore(flags);
-}
-
-static inline void __clear_bit(unsigned long nr, volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	*a &= ~mask;
-}
-
-/*
- * change_bit - Toggle a bit in memory
- * @nr: Bit to change
- * @addr: Address to start counting from
- *
- * change_bit() is atomic and may not be reordered.
- * Note that @nr may be almost arbitrarily large; this function is not
- * restricted to acting on a single-word quantity.
- */
-static inline void change_bit(unsigned long nr, volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-	__bi_flags;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	__bi_local_irq_save(flags);
-	*a ^= mask;
-	__bi_local_irq_restore(flags);
-}
-
-/*
- * __change_bit - Toggle a bit in memory
- * @nr: the bit to change
- * @addr: the address to start counting from
- *
- * Unlike change_bit(), this function is non-atomic and may be reordered.
- * If it's called on the same region of memory simultaneously, the effect
- * may be that only one operation succeeds.
- */
-static inline void __change_bit(unsigned long nr, volatile unsigned long * addr)
-{
-	unsigned long * m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
-
-	*m ^= 1UL << (nr & SZLONG_MASK);
-}
-
-/*
- * test_and_set_bit - Set a bit and return its old value
- * @nr: Bit to set
- * @addr: Address to count from
- *
- * This operation is atomic and cannot be reordered.
- * It also implies a memory barrier.
- */
-static inline int test_and_set_bit(unsigned long nr,
-	volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-	int retval;
-	__bi_flags;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	__bi_local_irq_save(flags);
-	retval = (mask & *a) != 0;
-	*a |= mask;
-	__bi_local_irq_restore(flags);
-
-	return retval;
-}
-
-/*
- * __test_and_set_bit - Set a bit and return its old value
- * @nr: Bit to set
- * @addr: Address to count from
- *
- * This operation is non-atomic and can be reordered.
- * If two examples of this operation race, one can appear to succeed
- * but actually fail.  You must protect multiple accesses with a lock.
- */
-static inline int __test_and_set_bit(unsigned long nr,
-	volatile unsigned long *addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-	int retval;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	retval = (mask & *a) != 0;
-	*a |= mask;
-
-	return retval;
-}
-
-/*
- * test_and_clear_bit - Clear a bit and return its old value
- * @nr: Bit to clear
- * @addr: Address to count from
- *
- * This operation is atomic and cannot be reordered.
- * It also implies a memory barrier.
- */
-static inline int test_and_clear_bit(unsigned long nr,
-	volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-	int retval;
-	__bi_flags;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	__bi_local_irq_save(flags);
-	retval = (mask & *a) != 0;
-	*a &= ~mask;
-	__bi_local_irq_restore(flags);
-
-	return retval;
-}
-
-/*
- * __test_and_clear_bit - Clear a bit and return its old value
- * @nr: Bit to clear
- * @addr: Address to count from
- *
- * This operation is non-atomic and can be reordered.
- * If two examples of this operation race, one can appear to succeed
- * but actually fail.  You must protect multiple accesses with a lock.
- */
-static inline int __test_and_clear_bit(unsigned long nr,
-	volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-	int retval;
-
-	a += (nr >> SZLONG_LOG);
-	mask = 1UL << (nr & SZLONG_MASK);
-	retval = ((mask & *a) != 0);
-	*a &= ~mask;
-
-	return retval;
-}
-
-/*
- * test_and_change_bit - Change a bit and return its old value
- * @nr: Bit to change
- * @addr: Address to count from
- *
- * This operation is atomic and cannot be reordered.
- * It also implies a memory barrier.
- */
-static inline int test_and_change_bit(unsigned long nr,
-	volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask, retval;
-	__bi_flags;
-
-	a += nr >> SZLONG_LOG;
-	mask = 1 << (nr & SZLONG_MASK);
-	__bi_local_irq_save(flags);
-	retval = (mask & *a) != 0;
-	*a ^= mask;
-	__bi_local_irq_restore(flags);
-
-	return retval;
-}
-
-/*
- * __test_and_change_bit - Change a bit and return its old value
- * @nr: Bit to change
- * @addr: Address to count from
- *
- * This operation is non-atomic and can be reordered.
- * If two examples of this operation race, one can appear to succeed
- * but actually fail.  You must protect multiple accesses with a lock.
- */
-static inline int __test_and_change_bit(unsigned long nr,
-	volatile unsigned long * addr)
-{
-	volatile unsigned long *a = addr;
-	unsigned long mask;
-	int retval;
-
-	a += (nr >> SZLONG_LOG);
-	mask = 1 << (nr & SZLONG_MASK);
-	retval = (mask & *a) != 0;
-	*a ^= mask;
-
-	return retval;
-}
-
 #undef __bi_flags
-#undef __bi_cli
-#undef __bi_save_flags
+#undef __bi_local_irq_save
 #undef __bi_local_irq_restore
-
-#endif /* MIPS I */
 
 /*
  * test_bit - Determine whether a bit is set
diff -Nru a/include/asm-mips/bootinfo.h b/include/asm-mips/bootinfo.h
--- a/include/asm-mips/bootinfo.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-mips/bootinfo.h	2004-12-24 13:36:31 -08:00
@@ -122,6 +122,7 @@
 #define  MACH_MOMENCO_OCELOT_G	1
 #define  MACH_MOMENCO_OCELOT_C	2
 #define  MACH_MOMENCO_JAGUAR_ATX 3
+#define  MACH_MOMENCO_OCELOT_3	4
 
 /*
  * Valid machtype for group ITE
@@ -175,6 +176,7 @@
 #define  MACH_XXS1500		6       /* Au1500-based eval board */
 #define  MACH_MTX1		7       /* 4G MTX-1 Au1500-based board */
 #define  MACH_PB1550		8       /* Au1550-based eval board */
+#define  MACH_DB1550		9       /* Au1550-based eval board */
 
 /*
  * Valid machtype for group NEC_VR41XX
diff -Nru a/include/asm-mips/checksum.h b/include/asm-mips/checksum.h
--- a/include/asm-mips/checksum.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-mips/checksum.h	2004-12-24 13:36:18 -08:00
@@ -46,6 +46,7 @@
 						  int len, int sum,
 						  int *err_ptr)
 {
+	might_sleep();
 	sum = csum_partial(src, len, sum);
 
 	if (copy_to_user(dst, src, len)) {
diff -Nru a/include/asm-mips/compat.h b/include/asm-mips/compat.h
--- a/include/asm-mips/compat.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-mips/compat.h	2004-12-24 13:37:01 -08:00
@@ -132,10 +132,10 @@
 
 static inline void *compat_alloc_user_space(long len)
 {
-	unsigned long sp = (unsigned long) current_thread_info() +
-	                    THREAD_SIZE - 32;
+	struct pt_regs *regs = (struct pt_regs *)
+		((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1;
 
-	return (void *) (sp - len);
+	return (void *) (regs->regs[29] - len);
 }
 
 #endif /* _ASM_COMPAT_H */
diff -Nru a/include/asm-mips/compiler.h b/include/asm-mips/compiler.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/compiler.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2004  Maciej W. Rozycki
+ *
+ * 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.
+ */
+#ifndef _ASM_COMPILER_H
+#define _ASM_COMPILER_H
+
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#define GCC_REG_ACCUM "$0"
+#else
+#define GCC_REG_ACCUM "accum"
+#endif
+
+#endif /* _ASM_COMPILER_H */
diff -Nru a/include/asm-mips/cpu-features.h b/include/asm-mips/cpu-features.h
--- a/include/asm-mips/cpu-features.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-mips/cpu-features.h	2004-12-24 13:37:19 -08:00
@@ -8,6 +8,8 @@
 #ifndef __ASM_CPU_FEATURES_H
 #define __ASM_CPU_FEATURES_H
 
+#include <asm/cpu.h>
+#include <asm/cpu-info.h>
 #include <cpu-feature-overrides.h>
 
 /*
@@ -69,7 +71,18 @@
 #define cpu_has_dc_aliases	(cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
 #endif
 #ifndef cpu_has_ic_fills_f_dc
-#define cpu_has_ic_fills_f_dc	(cpu_data[0].dcache.flags & MIPS_CACHE_IC_F_DC)
+#define cpu_has_ic_fills_f_dc	(cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC)
+#endif
+
+/*
+ * Certain CPUs may throw bizarre exceptions if not the whole cacheline
+ * contains valid instructions.  For these we ensure proper alignment of
+ * signal trampolines and pad them to the size of a full cache lines with
+ * nops.  This is also used in structure definitions so can't be a test macro
+ * like the others.
+ */
+#ifndef PLAT_TRAMPOLINE_STUFF_LINE
+#define PLAT_TRAMPOLINE_STUFF_LINE	0UL
 #endif
 
 #ifdef CONFIG_MIPS32
diff -Nru a/include/asm-mips/cpu-info.h b/include/asm-mips/cpu-info.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/cpu-info.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,81 @@
+/*
+ * 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 Waldorf GMBH
+ * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
+ * Copyright (C) 1996 Paul M. Antoine
+ * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ */
+#ifndef __ASM_CPU_INFO_H
+#define __ASM_CPU_INFO_H
+
+#include <linux/config.h>
+#include <asm/cache.h>
+
+#ifdef CONFIG_SGI_IP27
+#include <asm/sn/types.h>
+#endif
+
+/*
+ * Descriptor for a cache
+ */
+struct cache_desc {
+	unsigned short linesz;	/* Size of line in bytes */
+	unsigned short ways;	/* Number of ways */
+	unsigned short sets;	/* Number of lines per set */
+	unsigned int waysize;	/* Bytes per way */
+	unsigned int waybit;	/* Bits to select in a cache set */
+	unsigned int flags;	/* Flags describing cache properties */
+};
+
+/*
+ * Flag definitions
+ */
+#define MIPS_CACHE_NOT_PRESENT	0x00000001
+#define MIPS_CACHE_VTAG		0x00000002	/* Virtually tagged cache */
+#define MIPS_CACHE_ALIASES	0x00000004	/* Cache could have aliases */
+#define MIPS_CACHE_IC_F_DC	0x00000008	/* Ic can refill from D-cache */
+
+struct cpuinfo_mips {
+	unsigned long		udelay_val;
+	unsigned long		asid_cache;
+#if defined(CONFIG_SGI_IP27)
+//	cpuid_t		p_cpuid;	/* PROM assigned cpuid */
+	cnodeid_t	p_nodeid;	/* my node ID in compact-id-space */
+	nasid_t		p_nasid;	/* my node ID in numa-as-id-space */
+	unsigned char	p_slice;	/* Physical position on node board */
+#endif
+#if 0
+	unsigned long		loops_per_sec;
+	unsigned long		ipi_count;
+	unsigned long		irq_attempt[NR_IRQS];
+	unsigned long		smp_local_irq_count;
+	unsigned long		prof_multiplier;
+	unsigned long		prof_counter;
+#endif
+
+	/*
+	 * Capability and feature descriptor structure for MIPS CPU
+	 */
+	unsigned long		options;
+	unsigned int		processor_id;
+	unsigned int		fpu_id;
+	unsigned int		cputype;
+	int			isa_level;
+	int			tlbsize;
+	struct cache_desc	icache;	/* Primary I-cache */
+	struct cache_desc	dcache;	/* Primary D or combined I/D cache */
+	struct cache_desc	scache;	/* Secondary cache */
+	struct cache_desc	tcache;	/* Tertiary/split secondary cache */
+	void 			*data;	/* Additional data */
+} __attribute__((aligned(SMP_CACHE_BYTES)));
+
+extern struct cpuinfo_mips cpu_data[];
+#define current_cpu_data cpu_data[smp_processor_id()]
+
+extern void cpu_probe(void);
+extern void cpu_report(void);
+
+#endif /* __ASM_CPU_INFO_H */
diff -Nru a/include/asm-mips/debug.h b/include/asm-mips/debug.h
--- a/include/asm-mips/debug.h	2004-12-24 13:36:33 -08:00
+++ b/include/asm-mips/debug.h	2004-12-24 13:36:33 -08:00
@@ -1,5 +1,6 @@
 /*
- * Debug macros for run-time debugging.  Turned on/off with CONFIG_RUNTIME_DEBUG option.
+ * Debug macros for run-time debugging.
+ * Turned on/off with CONFIG_RUNTIME_DEBUG option.
  *
  * Copyright (C) 2001 MontaVista Software Inc.
  * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
diff -Nru a/include/asm-mips/dec/serial.h b/include/asm-mips/dec/serial.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/dec/serial.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,36 @@
+/*
+ *	include/asm-mips/dec/serial.h
+ *
+ *	Definitions common to all DECstation serial devices.
+ *
+ *	Copyright (C) 2004  Maciej W. Rozycki
+ *
+ *	Based on bits extracted from drivers/tc/zs.h for which
+ *	the following copyrights apply:
+ *
+ *	Copyright (C) 1995  David S. Miller (davem@caip.rutgers.edu)
+ *	Copyright (C) 1996  Paul Mackerras (Paul.Mackerras@cs.anu.edu.au)
+ *	Copyright (C)       Harald Koerfgen
+ *
+ *	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.
+ */
+#ifndef __ASM_MIPS_DEC_SERIAL_H
+#define __ASM_MIPS_DEC_SERIAL_H
+
+struct dec_serial_hook {
+	int (*init_channel)(void *handle);
+	void (*init_info)(void *handle);
+	void (*rx_char)(unsigned char ch, unsigned char fl);
+	int (*poll_rx_char)(void *handle);
+	int (*poll_tx_char)(void *handle, unsigned char ch);
+	unsigned int cflags;
+};
+
+extern int register_dec_serial_hook(unsigned int channel,
+				    struct dec_serial_hook *hook);
+extern int unregister_dec_serial_hook(unsigned int channel);
+
+#endif /* __ASM_MIPS_DEC_SERIAL_H */
diff -Nru a/include/asm-mips/delay.h b/include/asm-mips/delay.h
--- a/include/asm-mips/delay.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-mips/delay.h	2004-12-24 13:37:29 -08:00
@@ -13,6 +13,8 @@
 #include <linux/config.h>
 #include <linux/param.h>
 
+#include <asm/compiler.h>
+
 extern unsigned long loops_per_jiffy;
 
 static inline void __delay(unsigned long loops)
@@ -69,11 +71,13 @@
 	if (sizeof(long) == 4)
 		__asm__("multu\t%2, %3"
 		: "=h" (usecs), "=l" (lo)
-		: "r" (usecs),"r" (lpj));
+		: "r" (usecs), "r" (lpj)
+		: GCC_REG_ACCUM);
 	else if (sizeof(long) == 8)
 		__asm__("dmultu\t%2, %3"
 		: "=h" (usecs), "=l" (lo)
-		: "r" (usecs),"r" (lpj));
+		: "r" (usecs), "r" (lpj)
+		: GCC_REG_ACCUM);
 
 	__delay(usecs);
 }
diff -Nru a/include/asm-mips/div64.h b/include/asm-mips/div64.h
--- a/include/asm-mips/div64.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-mips/div64.h	2004-12-24 13:37:02 -08:00
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2000 Maciej W. Rozycki
+ * Copyright (C) 2000, 2004  Maciej W. Rozycki
  * Copyright (C) 2003 Ralf Baechle
  *
  * This file is subject to the terms and conditions of the GNU General Public
@@ -11,6 +11,8 @@
 
 #if (_MIPS_SZLONG == 32)
 
+#include <asm/compiler.h>
+
 /*
  * No traps on overflows for any of these...
  */
@@ -67,7 +69,8 @@
 	if (__high) \
 		__asm__("divu	$0, %z2, %z3" \
 			: "=h" (__upper), "=l" (__high) \
-			: "Jr" (__high), "Jr" (__base)); \
+			: "Jr" (__high), "Jr" (__base) \
+			: GCC_REG_ACCUM); \
 	\
 	__mod = do_div64_32(__low, __upper, __low, __base); \
 	\
diff -Nru a/include/asm-mips/dma-mapping.h b/include/asm-mips/dma-mapping.h
--- a/include/asm-mips/dma-mapping.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-mips/dma-mapping.h	2004-12-24 13:37:00 -08:00
@@ -68,4 +68,12 @@
 extern void dma_cache_sync(void *vaddr, size_t size,
 	       enum dma_data_direction direction);
 
+#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
+
+extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+	dma_addr_t device_addr, size_t size, int flags);
+extern void dma_release_declared_memory(struct device *dev);
+extern void * dma_mark_declared_memory_occupied(struct device *dev,
+	dma_addr_t device_addr, size_t size);
+
 #endif /* _ASM_DMA_MAPPING_H */
diff -Nru a/include/asm-mips/errno.h b/include/asm-mips/errno.h
--- a/include/asm-mips/errno.h	2004-12-24 13:36:56 -08:00
+++ b/include/asm-mips/errno.h	2004-12-24 13:36:56 -08:00
@@ -110,6 +110,10 @@
  */
 #define ENOMEDIUM	159	/* No medium found */
 #define EMEDIUMTYPE	160	/* Wrong medium type */
+#define	ENOKEY		161	/* Required key not available */
+#define	EKEYEXPIRED	162	/* Key has expired */
+#define	EKEYREVOKED	163	/* Key has been revoked */
+#define	EKEYREJECTED	164	/* Key was rejected by service */
 
 #define EDQUOT		1133	/* Quota exceeded */
 
diff -Nru a/include/asm-mips/fixmap.h b/include/asm-mips/fixmap.h
--- a/include/asm-mips/fixmap.h	2004-12-24 13:36:35 -08:00
+++ b/include/asm-mips/fixmap.h	2004-12-24 13:36:35 -08:00
@@ -14,7 +14,6 @@
 #define _ASM_FIXMAP_H
 
 #include <linux/config.h>
-#include <linux/kernel.h>
 #include <asm/page.h>
 #ifdef CONFIG_HIGHMEM
 #include <linux/threads.h>
diff -Nru a/include/asm-mips/gdb-stub.h b/include/asm-mips/gdb-stub.h
--- a/include/asm-mips/gdb-stub.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-mips/gdb-stub.h	2004-12-24 13:36:55 -08:00
@@ -207,6 +207,7 @@
  * Prototypes
  */
 
+extern int kgdb_enabled;
 void set_debug_traps(void);
 void set_async_breakpoint(unsigned long *epc);
 
diff -Nru a/include/asm-mips/hardirq.h b/include/asm-mips/hardirq.h
--- a/include/asm-mips/hardirq.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-mips/hardirq.h	2004-12-24 13:36:31 -08:00
@@ -20,45 +20,6 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
-#define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
-
-/*
- * The hardirq mask has to be large enough to have
- * space for potentially all IRQ sources in the system
- * nesting on a single CPU:
- */
-#if (1 << HARDIRQ_BITS) < NR_IRQS
-# error HARDIRQ_BITS is too low!
-#endif
-
-#define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
-#define irq_exit()                                                     \
-do {                                                                   \
-	preempt_count() -= IRQ_EXIT_OFFSET;                     \
-	if (!in_interrupt() && softirq_pending(smp_processor_id())) \
-		do_softirq();                                   \
-	preempt_enable_no_resched();                            \
-} while (0)
+extern void ack_bad_irq(unsigned int irq);
 
 #endif /* _ASM_HARDIRQ_H */
diff -Nru a/include/asm-mips/hazards.h b/include/asm-mips/hazards.h
--- a/include/asm-mips/hazards.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-mips/hazards.h	2004-12-24 13:37:04 -08:00
@@ -13,7 +13,7 @@
 #ifdef __ASSEMBLY__
 
 	.macro	_ssnop
-	sll	$0, $2, 1
+	sll	$0, $0, 1
 	.endm
 
 /*
diff -Nru a/include/asm-mips/hw_irq.h b/include/asm-mips/hw_irq.h
--- a/include/asm-mips/hw_irq.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-mips/hw_irq.h	2004-12-24 13:37:19 -08:00
@@ -11,8 +11,6 @@
 #include <linux/profile.h>
 #include <asm/atomic.h>
 
-extern void mask_irq(unsigned int irq);
-extern void unmask_irq(unsigned int irq);
 extern void disable_8259A_irq(unsigned int irq);
 extern void enable_8259A_irq(unsigned int irq);
 extern int i8259A_irq_pending(unsigned int irq);
diff -Nru a/include/asm-mips/ide.h b/include/asm-mips/ide.h
--- a/include/asm-mips/ide.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-mips/ide.h	2004-12-24 13:37:03 -08:00
@@ -4,22 +4,10 @@
  * for more details.
  *
  * This file contains the MIPS architecture specific IDE code.
- *
- * Copyright (C) 1994-1996  Linus Torvalds & authors
  */
-
 #ifndef __ASM_IDE_H
 #define __ASM_IDE_H
 
-#ifdef __KERNEL__
-
 #include <ide.h>
-
-#define __ide_mm_insw   ide_insw
-#define __ide_mm_insl   ide_insl
-#define __ide_mm_outsw  ide_outsw
-#define __ide_mm_outsl  ide_outsl
-
-#endif /* __KERNEL__ */
 
 #endif /* __ASM_IDE_H */
diff -Nru a/include/asm-mips/interrupt.h b/include/asm-mips/interrupt.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/interrupt.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,134 @@
+/*
+ * 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, 95, 96, 97, 98, 99, 2003 by Ralf Baechle
+ * Copyright (C) 1996 by Paul M. Antoine
+ * Copyright (C) 1999 Silicon Graphics
+ * Copyright (C) 2000 MIPS Technologies, Inc.
+ */
+#ifndef _ASM_INTERRUPT_H
+#define _ASM_INTERRUPT_H
+
+#include <asm/hazards.h>
+
+__asm__ (
+	".macro\tlocal_irq_enable\n\t"
+	".set\tpush\n\t"
+	".set\treorder\n\t"
+	".set\tnoat\n\t"
+	"mfc0\t$1,$12\n\t"
+	"ori\t$1,0x1f\n\t"
+	"xori\t$1,0x1e\n\t"
+	"mtc0\t$1,$12\n\t"
+	"irq_enable_hazard\n\t"
+	".set\tpop\n\t"
+	".endm");
+
+static inline void local_irq_enable(void)
+{
+	__asm__ __volatile__(
+		"local_irq_enable"
+		: /* no outputs */
+		: /* no inputs */
+		: "memory");
+}
+
+/*
+ * For cli() we have to insert nops to make sure that the new value
+ * has actually arrived in the status register before the end of this
+ * macro.
+ * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
+ * no nops at all.
+ */
+__asm__ (
+	".macro\tlocal_irq_disable\n\t"
+	".set\tpush\n\t"
+	".set\tnoat\n\t"
+	"mfc0\t$1,$12\n\t"
+	"ori\t$1,1\n\t"
+	"xori\t$1,1\n\t"
+	".set\tnoreorder\n\t"
+	"mtc0\t$1,$12\n\t"
+	"irq_disable_hazard\n\t"
+	".set\tpop\n\t"
+	".endm");
+
+static inline void local_irq_disable(void)
+{
+	__asm__ __volatile__(
+		"local_irq_disable"
+		: /* no outputs */
+		: /* no inputs */
+		: "memory");
+}
+
+__asm__ (
+	".macro\tlocal_save_flags flags\n\t"
+	".set\tpush\n\t"
+	".set\treorder\n\t"
+	"mfc0\t\\flags, $12\n\t"
+	".set\tpop\n\t"
+	".endm");
+
+#define local_save_flags(x)						\
+__asm__ __volatile__(							\
+	"local_save_flags %0"						\
+	: "=r" (x))
+
+__asm__ (
+	".macro\tlocal_irq_save result\n\t"
+	".set\tpush\n\t"
+	".set\treorder\n\t"
+	".set\tnoat\n\t"
+	"mfc0\t\\result, $12\n\t"
+	"ori\t$1, \\result, 1\n\t"
+	"xori\t$1, 1\n\t"
+	".set\tnoreorder\n\t"
+	"mtc0\t$1, $12\n\t"
+	"irq_disable_hazard\n\t"
+	".set\tpop\n\t"
+	".endm");
+
+#define local_irq_save(x)						\
+__asm__ __volatile__(							\
+	"local_irq_save\t%0"						\
+	: "=r" (x)							\
+	: /* no inputs */						\
+	: "memory")
+
+__asm__ (
+	".macro\tlocal_irq_restore flags\n\t"
+	".set\tnoreorder\n\t"
+	".set\tnoat\n\t"
+	"mfc0\t$1, $12\n\t"
+	"andi\t\\flags, 1\n\t"
+	"ori\t$1, 1\n\t"
+	"xori\t$1, 1\n\t"
+	"or\t\\flags, $1\n\t"
+	"mtc0\t\\flags, $12\n\t"
+	"irq_disable_hazard\n\t"
+	".set\tat\n\t"
+	".set\treorder\n\t"
+	".endm");
+
+#define local_irq_restore(flags)					\
+do {									\
+	unsigned long __tmp1;						\
+									\
+	__asm__ __volatile__(						\
+		"local_irq_restore\t%0"					\
+		: "=r" (__tmp1)						\
+		: "0" (flags)						\
+		: "memory");						\
+} while(0)
+
+#define irqs_disabled()							\
+({									\
+	unsigned long flags;						\
+	local_save_flags(flags);					\
+	!(flags & 1);							\
+})
+
+#endif /* _ASM_INTERRUPT_H */
diff -Nru a/include/asm-mips/io.h b/include/asm-mips/io.h
--- a/include/asm-mips/io.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-mips/io.h	2004-12-24 13:36:47 -08:00
@@ -11,6 +11,7 @@
 #define _ASM_IO_H
 
 #include <linux/config.h>
+#include <linux/compiler.h>
 #include <linux/types.h>
 
 #include <asm/addrspace.h>
@@ -169,9 +170,9 @@
 #define page_to_phys(page)	((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
 
 extern void * __ioremap(phys_t offset, phys_t size, unsigned long flags);
-extern void __iounmap(void *addr);
+extern void __iounmap(volatile void __iomem *addr);
 
-static inline void * __ioremap_mode(unsigned long offset, unsigned long size,
+static inline void * __ioremap_mode(phys_t offset, unsigned long size,
 	unsigned long flags)
 {
 	if (cpu_has_64bit_addresses) {
@@ -236,7 +237,7 @@
 #define ioremap_uncached_accelerated(offset, size)			\
 	__ioremap_mode((offset), (size), _CACHE_UNCACHED_ACCELERATED)
 
-static inline void iounmap(void *addr)
+static inline void iounmap(volatile void __iomem *addr)
 {
 	if (cpu_has_64bits)
 		return;
@@ -244,9 +245,12 @@
 	__iounmap(addr);
 }
 
-#define __raw_readb(addr)	(*(volatile unsigned char *)(addr))
-#define __raw_readw(addr)	(*(volatile unsigned short *)(addr))
-#define __raw_readl(addr)	(*(volatile unsigned int *)(addr))
+#define __raw_readb(addr)						\
+	(*(volatile unsigned char *) __swizzle_addr_b((unsigned long)(addr)))
+#define __raw_readw(addr)						\
+	(*(volatile unsigned short *) __swizzle_addr_w((unsigned long)(addr)))
+#define __raw_readl(addr)						\
+	(*(volatile unsigned int *) __swizzle_addr_l((unsigned long)(addr)))
 #ifdef CONFIG_MIPS32
 #define ____raw_readq(addr)						\
 ({									\
@@ -259,7 +263,7 @@
 		"	sll	%L0, %L0, 0			\n"	\
 		"	.set	mips0				\n"	\
 		: "=r" (__res)						\
-		: "r" (addr));						\
+		: "r" (__swizzle_addr_q((unsigned long)(addr))));	\
 	__res;								\
 })
 #define __raw_readq(addr)						\
@@ -274,7 +278,8 @@
 })
 #endif
 #ifdef CONFIG_MIPS64
-#define ____raw_readq(addr)	(*(volatile unsigned long *)(addr))
+#define ____raw_readq(addr)						\
+	(*(volatile unsigned long *)__swizzle_addr_q((unsigned long)(addr)))
 #define __raw_readq(addr)	____raw_readq(addr)
 #endif
 
@@ -287,12 +292,24 @@
 #define readl_relaxed(addr)	readl(addr)
 #define readq_relaxed(addr)	readq(addr)
 
-#define __raw_writeb(b,addr)	((*(volatile unsigned char *)(addr)) = (b))
-#define __raw_writew(w,addr)	((*(volatile unsigned short *)(addr)) = (w))
-#define __raw_writel(l,addr)	((*(volatile unsigned int *)(addr)) = (l))
+#define __raw_writeb(b,addr)						\
+do {									\
+	((*(volatile unsigned char *)__swizzle_addr_b((unsigned long)(addr))) = (b));	\
+} while (0)
+
+#define __raw_writew(w,addr)						\
+do {									\
+	((*(volatile unsigned short *)__swizzle_addr_w((unsigned long)(addr))) = (w));	\
+} while (0)
+
+#define __raw_writel(l,addr)						\
+do {									\
+	((*(volatile unsigned int *)__swizzle_addr_l((unsigned long)(addr))) = (l));	\
+} while (0)
+
 #ifdef CONFIG_MIPS32
-#define ____raw_writeq(val,addr)						\
-({									\
+#define ____raw_writeq(val,addr)					\
+do {									\
 	u64 __tmp;							\
 									\
 	__asm__ __volatile__ (						\
@@ -304,19 +321,25 @@
 		"	sd	%L0, (%2)			\n"	\
 		"	.set	mips0				\n"	\
 		: "=r" (__tmp)						\
-		: "0" ((unsigned long long)val), "r" (addr));		\
-})
+		: "0" ((unsigned long long)val),			\
+		  "r" (__swizzle_addr_q((unsigned long)(addr))));	\
+} while (0)
+
 #define __raw_writeq(val,addr)						\
-({									\
+do {									\
 	unsigned long __flags;						\
 									\
 	local_irq_save(__flags);					\
 	____raw_writeq(val, addr);					\
 	local_irq_restore(__flags);					\
-})
+} while (0)
 #endif
 #ifdef CONFIG_MIPS64
-#define ____raw_writeq(q,addr)	((*(volatile unsigned long *)(addr)) = (q))
+#define ____raw_writeq(q,addr)						\
+do {									\
+	*(volatile unsigned long *)__swizzle_addr_q((unsigned long)(addr)) = (q);	\
+} while (0)
+
 #define __raw_writeq(q,addr)	____raw_writeq(q, addr)
 #endif
 
@@ -325,6 +348,9 @@
 #define writel(l,addr)		__raw_writel(__ioswab32(l),(addr))
 #define writeq(q,addr)		__raw_writeq(__ioswab64(q),(addr))
 
+/* Depends on MIPS II instruction set */
+#define mmiowb() asm volatile ("sync" ::: "memory")
+
 #define memset_io(a,b,c)	memset((void *)(a),(b),(c))
 #define memcpy_fromio(a,b,c)	memcpy((a),(void *)(b),(c))
 #define memcpy_toio(a,b,c)	memcpy((void *)(a),(b),(c))
@@ -383,20 +409,6 @@
 out:
 	return retval;
 }
-
-/*
- *     isa_check_signature             -       find BIOS signatures
- *     @io_addr: mmio address to check
- *     @signature:  signature block
- *     @length: length of signature
- *
- *     Perform a signature comparison with the ISA mmio address io_addr.
- *     Returns 1 on a match.
- *
- *     This function is deprecated. New drivers should use ioremap and
- *     check_signature.
- */
-#define isa_check_signature(io, s, l)	check_signature(i,s,l)
 
 static inline void __outb(unsigned char val, unsigned long port)
 {
diff -Nru a/include/asm-mips/ip32/crime.h b/include/asm-mips/ip32/crime.h
--- a/include/asm-mips/ip32/crime.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-mips/ip32/crime.h	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,6 @@
 /*
- * Definitions for the SGI O2 Crime chip.
+ * Definitions for the SGI CRIME (CPU, Rendering, Interconnect and Memory
+ * Engine)
  *
  * 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
@@ -11,178 +12,116 @@
 #ifndef __ASM_CRIME_H__
 #define __ASM_CRIME_H__
 
-#include <asm/addrspace.h>
-#include <asm/io.h>
-
 /*
  * Address map
  */
 #define CRIME_BASE	0x14000000	/* physical */
 
-extern void *sgi_crime;
-
-static inline uint64_t crime_read(unsigned long offset)
-{
-        return readq(sgi_crime + offset);
-}
-static inline void crime_write(uint64_t val, unsigned long offset)
-{
-	writeq(val, sgi_crime + offset);
-}
-
 #undef BIT
-#define BIT(x) (1UL << (x))
-
-/* All CRIME registers are 64 bits */
-#define CRIME_ID		0x000
-
-#define CRIME_ID_MASK		0xff
-#define CRIME_ID_IDBITS		0xf0
-#define CRIME_ID_IDVALUE	0xa0
-#define CRIME_ID_REV		0x0f
-
-#define CRIME_REV_PETTY		0x00
-#define CRIME_REV_11		0x11
-#define CRIME_REV_13		0x13
-#define CRIME_REV_14		0x14
+#define BIT(x)	(1UL << (x))
 
-#define CRIME_CONTROL		0x008
-#define CRIME_CONTROL_MASK	0x3fff
+struct sgi_crime {
+	volatile unsigned long id;
+#define CRIME_ID_MASK			0xff
+#define CRIME_ID_IDBITS			0xf0
+#define CRIME_ID_IDVALUE		0xa0
+#define CRIME_ID_REV			0x0f
+#define CRIME_REV_PETTY			0x00
+#define CRIME_REV_11			0x11
+#define CRIME_REV_13			0x13
+#define CRIME_REV_14			0x14
 
-/* CRIME_CONTROL register bits */
+	volatile unsigned long control;
+#define CRIME_CONTROL_MASK		0x3fff
 #define CRIME_CONTROL_TRITON_SYSADC	0x2000
 #define CRIME_CONTROL_CRIME_SYSADC	0x1000
 #define CRIME_CONTROL_HARD_RESET	0x0800
 #define CRIME_CONTROL_SOFT_RESET	0x0400
 #define CRIME_CONTROL_DOG_ENA		0x0200
 #define CRIME_CONTROL_ENDIANESS		0x0100
-
 #define CRIME_CONTROL_ENDIAN_BIG	0x0100
 #define CRIME_CONTROL_ENDIAN_LITTLE	0x0000
-
 #define CRIME_CONTROL_CQUEUE_HWM	0x000f
 #define CRIME_CONTROL_CQUEUE_SHFT	0
 #define CRIME_CONTROL_WBUF_HWM		0x00f0
 #define CRIME_CONTROL_WBUF_SHFT		8
 
-#define CRIME_INT_STAT			0x010
-#define CRIME_INT_MASK			0x018
-#define CRIME_SOFT_INT			0x020
-#define CRIME_HARD_INT			0x028
-
-/* Bits in CRIME_INT_XXX and CRIME_HARD_INT */
-#define MACE_VID_IN1_INT		BIT (0)
-#define MACE_VID_IN2_INT		BIT (1)
-#define MACE_VID_OUT_INT		BIT (2)
-#define MACE_ETHERNET_INT		BIT (3)
-#define MACE_SUPERIO_INT		BIT (4)
-#define MACE_MISC_INT			BIT (5)
-#define MACE_AUDIO_INT			BIT (6)
-#define MACE_PCI_BRIDGE_INT		BIT (7)
-#define MACEPCI_SCSI0_INT		BIT (8)
-#define MACEPCI_SCSI1_INT		BIT (9)
-#define MACEPCI_SLOT0_INT		BIT (10)
-#define MACEPCI_SLOT1_INT		BIT (11)
-#define MACEPCI_SLOT2_INT		BIT (12)
-#define MACEPCI_SHARED0_INT		BIT (13)
-#define MACEPCI_SHARED1_INT		BIT (14)
-#define MACEPCI_SHARED2_INT		BIT (15)
-#define CRIME_GBE0_INT			BIT (16)
-#define CRIME_GBE1_INT			BIT (17)
-#define CRIME_GBE2_INT			BIT (18)
-#define CRIME_GBE3_INT			BIT (19)
-#define CRIME_CPUERR_INT		BIT (20)
-#define CRIME_MEMERR_INT		BIT (21)
-#define CRIME_RE_EMPTY_E_INT		BIT (22)
-#define CRIME_RE_FULL_E_INT		BIT (23)
-#define CRIME_RE_IDLE_E_INT		BIT (24)
-#define CRIME_RE_EMPTY_L_INT		BIT (25)
-#define CRIME_RE_FULL_L_INT		BIT (26)
-#define CRIME_RE_IDLE_L_INT    		BIT (27)
-#define CRIME_SOFT0_INT			BIT (28)
-#define CRIME_SOFT1_INT			BIT (29)
-#define CRIME_SOFT2_INT			BIT (30)
+	volatile unsigned long istat;
+	volatile unsigned long imask;
+	volatile unsigned long soft_int;
+	volatile unsigned long hard_int;
+#define MACE_VID_IN1_INT		BIT(0)
+#define MACE_VID_IN2_INT		BIT(1)
+#define MACE_VID_OUT_INT		BIT(2)
+#define MACE_ETHERNET_INT		BIT(3)
+#define MACE_SUPERIO_INT		BIT(4)
+#define MACE_MISC_INT			BIT(5)
+#define MACE_AUDIO_INT			BIT(6)
+#define MACE_PCI_BRIDGE_INT		BIT(7)
+#define MACEPCI_SCSI0_INT		BIT(8)
+#define MACEPCI_SCSI1_INT		BIT(9)
+#define MACEPCI_SLOT0_INT		BIT(10)
+#define MACEPCI_SLOT1_INT		BIT(11)
+#define MACEPCI_SLOT2_INT		BIT(12)
+#define MACEPCI_SHARED0_INT		BIT(13)
+#define MACEPCI_SHARED1_INT		BIT(14)
+#define MACEPCI_SHARED2_INT		BIT(15)
+#define CRIME_GBE0_INT			BIT(16)
+#define CRIME_GBE1_INT			BIT(17)
+#define CRIME_GBE2_INT			BIT(18)
+#define CRIME_GBE3_INT			BIT(19)
+#define CRIME_CPUERR_INT		BIT(20)
+#define CRIME_MEMERR_INT		BIT(21)
+#define CRIME_RE_EMPTY_E_INT		BIT(22)
+#define CRIME_RE_FULL_E_INT		BIT(23)
+#define CRIME_RE_IDLE_E_INT		BIT(24)
+#define CRIME_RE_EMPTY_L_INT		BIT(25)
+#define CRIME_RE_FULL_L_INT		BIT(26)
+#define CRIME_RE_IDLE_L_INT    		BIT(27)
+#define CRIME_SOFT0_INT			BIT(28)
+#define CRIME_SOFT1_INT			BIT(29)
+#define CRIME_SOFT2_INT			BIT(30)
 #define CRIME_SYSCORERR_INT		CRIME_SOFT2_INT
-#define CRIME_VICE_INT			BIT (31)
-
+#define CRIME_VICE_INT			BIT(31)
 /* Masks for deciding who handles the interrupt */
 #define CRIME_MACE_INT_MASK		0x8f
 #define CRIME_MACEISA_INT_MASK		0x70
 #define CRIME_MACEPCI_INT_MASK		0xff00
 #define CRIME_CRIME_INT_MASK		0xffff0000
 
-#define CRIME_DOG			0x030
-#define CRIME_DOG_MASK			0x001fffff
-
-/* CRIME_DOG register bits */
+	volatile unsigned long watchdog;
 #define CRIME_DOG_POWER_ON_RESET	0x00010000
 #define CRIME_DOG_WARM_RESET		0x00080000
 #define CRIME_DOG_TIMEOUT		(CRIME_DOG_POWER_ON_RESET|CRIME_DOG_WARM_RESET)
 #define CRIME_DOG_VALUE			0x00007fff
 
-#define CRIME_TIMER			0x038
-#define CRIME_TIMER_MASK		0x0000ffffffffffff
-
+	volatile unsigned long timer;
 #define CRIME_MASTER_FREQ		66666500	/* Crime upcounter frequency */
 #define CRIME_NS_PER_TICK		15		/* for delay_calibrate */
 
-#define CRIME_CPU_ERROR_ADDR		0x040
+	volatile unsigned long cpu_error_addr;
 #define CRIME_CPU_ERROR_ADDR_MASK	0x3ffffffff
 
-#define CRIME_CPU_ERROR_STAT		0x048
-/* REV_PETTY only! */
-#define CRIME_CPU_ERROR_ENA		0x050
-
-/*
- * bit definitions for CRIME/VICE error status and enable registers
- */
-#define CRIME_CPU_ERROR_MASK           0x7	/* cpu error stat is 3 bits */
-#define CRIME_CPU_ERROR_CPU_ILL_ADDR   0x4
-#define CRIME_CPU_ERROR_VICE_WRT_PRTY  0x2
-#define CRIME_CPU_ERROR_CPU_WRT_PRTY   0x1
-
-/*
- * these are the definitions for the error status/enable  register in
- * petty crime.  Note that the enable register does not exist in crime
- * rev 1 and above.
- */
-#define CRIME_CPU_ERROR_MASK_REV0		0x3ff	/* cpu error stat is 9 bits */
-#define CRIME_CPU_ERROR_CPU_INV_ADDR_RD		0x200
-#define CRIME_CPU_ERROR_VICE_II			0x100
-#define CRIME_CPU_ERROR_VICE_SYSAD		0x80
-#define CRIME_CPU_ERROR_VICE_SYSCMD		0x40
-#define CRIME_CPU_ERROR_VICE_INV_ADDR		0x20
-#define CRIME_CPU_ERROR_CPU_II			0x10
-#define CRIME_CPU_ERROR_CPU_SYSAD		0x8
-#define CRIME_CPU_ERROR_CPU_SYSCMD		0x4
-#define CRIME_CPU_ERROR_CPU_INV_ADDR_WR		0x2
-#define CRIME_CPU_ERROR_CPU_INV_REG_ADDR	0x1
-
-#define CRIME_VICE_ERROR_ADDR		0x058
-#define CRIME_VICE_ERROR_ADDR_MASK	0x3fffffff
-
-#define CRIME_MEM_CONTROL		0x200
-#define CRIME_MEM_CONTROL_MASK		0x3	/* 25 cent register */
-#define CRIME_MEM_CONTROL_ECC_ENA	0x1
-#define CRIME_MEM_CONTROL_USE_ECC_REPL	0x2
-
-/*
- * macros for CRIME memory bank control registers.
- */
-#define CRIME_MEM_BANK_CONTROL(__bank)		(0x208 + ((__bank) << 3))
-#define CRIME_MEM_BANK_CONTROL_MASK		0x11f /* 9 bits 7:5 reserved */
+	volatile unsigned long cpu_error_stat;
+#define CRIME_CPU_ERROR_MASK		0x7		/* cpu error stat is 3 bits */
+#define CRIME_CPU_ERROR_CPU_ILL_ADDR	0x4
+#define CRIME_CPU_ERROR_VICE_WRT_PRTY	0x2
+#define CRIME_CPU_ERROR_CPU_WRT_PRTY	0x1
+
+	unsigned long _pad0[54];
+
+	volatile unsigned long mc_ctrl;
+	volatile unsigned long bank_ctrl[8];
+#define CRIME_MEM_BANK_CONTROL_MASK		0x11f	/* 9 bits 7:5 reserved */
 #define CRIME_MEM_BANK_CONTROL_ADDR		0x01f
 #define CRIME_MEM_BANK_CONTROL_SDRAM_SIZE	0x100
 #define CRIME_MAXBANKS				8
 
-#define CRIME_MEM_REFRESH_COUNTER	0x248
-#define CRIME_MEM_REFRESH_COUNTER_MASK	0x7ff	
+	volatile unsigned long mem_ref_counter;
+#define CRIME_MEM_REF_COUNTER_MASK	0x3ff		/* 10bit */
 
-/*
- * CRIME Memory error status register bit definitions
- */
-#define CRIME_MEM_ERROR_STAT		0x250
-#define CRIME_MEM_ERROR_STAT_MASK       0x0ff7ffff    /* 28-bit register */
+	volatile unsigned long mem_error_stat;
+#define CRIME_MEM_ERROR_STAT_MASK       0x0ff7ffff	/* 28-bit register */
 #define CRIME_MEM_ERROR_MACE_ID		0x0000007f
 #define CRIME_MEM_ERROR_MACE_ACCESS	0x00000080
 #define CRIME_MEM_ERROR_RE_ID		0x00007f00
@@ -200,18 +139,21 @@
 #define CRIME_MEM_ERROR_INV		0x0e000000
 #define CRIME_MEM_ERROR_INV_MEM_ADDR_RD	0x02000000
 #define CRIME_MEM_ERROR_INV_MEM_ADDR_WR	0x04000000
-#define CRIME_MEM_ERROR_INV_MEM_ADDR_RMW	0x08000000
+#define CRIME_MEM_ERROR_INV_MEM_ADDR_RMW 0x08000000
 
-#define CRIME_MEM_ERROR_ADDR		0x258
+	volatile unsigned long mem_error_addr;
 #define CRIME_MEM_ERROR_ADDR_MASK	0x3fffffff
 
-#define CRIME_MEM_ERROR_ECC_SYN		0x260
+	volatile unsigned long mem_ecc_syn;
 #define CRIME_MEM_ERROR_ECC_SYN_MASK	0xffffffff
 
-#define CRIME_MEM_ERROR_ECC_CHK		0x268
-#define CRIME_MEM_ERROR_ECC_CHK_MASK    0xffffffff
+	volatile unsigned long mem_ecc_chk;
+#define CRIME_MEM_ERROR_ECC_CHK_MASK	0xffffffff
 
-#define CRIME_MEM_ERROR_ECC_REPL	0x270
+	volatile unsigned long mem_ecc_repl;
 #define CRIME_MEM_ERROR_ECC_REPL_MASK	0xffffffff
+};
+
+extern struct sgi_crime *crime;
 
 #endif /* __ASM_CRIME_H__ */
diff -Nru a/include/asm-mips/ip32/mace.h b/include/asm-mips/ip32/mace.h
--- a/include/asm-mips/ip32/mace.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-mips/ip32/mace.h	2004-12-24 13:36:48 -08:00
@@ -12,41 +12,13 @@
 #ifndef __ASM_MACE_H__
 #define __ASM_MACE_H__
 
-#include <linux/config.h>
-#include <asm/io.h>
-
 /*
  * Address map
  */
 #define MACE_BASE	0x1f000000	/* physical */
 
 #undef BIT
-#define BIT(x) (1ULL << (x))
-
-#ifdef CONFIG_MIPS32
-typedef struct {
-	volatile unsigned long long reg;
-} mace64_t;
-
-typedef struct {
-	unsigned long pad;
-	volatile unsigned long reg;
-} mace32_t;
-#endif
-#ifdef CONFIG_MIPS64
-typedef struct {
-	volatile unsigned long reg;
-} mace64_t;
-
-typedef struct {
-	volatile unsigned long reg;
-} mace32_t;
-#endif
-
-#define mace_read(r)	\
-	(sizeof(r.reg) == 4 ? readl(&r.reg) : readq(&r.reg))
-#define mace_write(v,r)	\
-	(sizeof(r.reg) == 4 ? writel(v,&r.reg) : writeq(v,&r.reg))
+#define BIT(x) (1UL << (x))
 
 /*
  * PCI interface
@@ -119,48 +91,43 @@
  * Video interface
  */
 struct mace_video {
-	mace32_t xxx;	/* later... */
+	unsigned long xxx;	/* later... */
 };
 
 /* 
  * Ethernet interface
  */
 struct mace_ethernet {
-	mace32_t mac_ctrl;
-	mace32_t int_stat;
-	mace32_t dma_ctrl;
-	mace32_t timer;
-	mace32_t tx_int_al;
-	mace32_t rx_int_al;
-	mace32_t tx_info;
-	mace32_t tx_info_al;
-	mace32_t rx_buff;
-	mace32_t rx_buff_al1;
-	mace32_t rx_buff_al2;
-	mace64_t diag;
-	mace32_t phy_data;
-	mace32_t phy_regs;
-	mace32_t phy_trans_go;
-	mace32_t backoff_seed;
+	volatile unsigned long mac_ctrl;
+	volatile unsigned long int_stat;
+	volatile unsigned long dma_ctrl;
+	volatile unsigned long timer;
+	volatile unsigned long tx_int_al;
+	volatile unsigned long rx_int_al;
+	volatile unsigned long tx_info;
+	volatile unsigned long tx_info_al;
+	volatile unsigned long rx_buff;
+	volatile unsigned long rx_buff_al1;
+	volatile unsigned long rx_buff_al2;
+	volatile unsigned long diag;
+	volatile unsigned long phy_data;
+	volatile unsigned long phy_regs;
+	volatile unsigned long phy_trans_go;
+	volatile unsigned long backoff_seed;
 	/*===================================*/
-	mace64_t imq_reserved[4];
-	mace64_t mac_addr;
-	mace64_t mac_addr2;
-	mace64_t mcast_filter;
-	mace32_t tx_ring_base;
+	volatile unsigned long imq_reserved[4];
+	volatile unsigned long mac_addr;
+	volatile unsigned long mac_addr2;
+	volatile unsigned long mcast_filter;
+	volatile unsigned long tx_ring_base;
 	/* Following are read-only registers for debugging */
-	mace64_t tx_pkt1_hdr;
-	mace64_t tx_pkt1_ptr[3];
-	mace64_t tx_pkt2_hdr;
-	mace64_t tx_pkt2_ptr[3];
+	volatile unsigned long tx_pkt1_hdr;
+	volatile unsigned long tx_pkt1_ptr[3];
+	volatile unsigned long tx_pkt2_hdr;
+	volatile unsigned long tx_pkt2_ptr[3];
 	/*===================================*/
-	mace32_t rx_fifo;
+	volatile unsigned long rx_fifo;
 };
-#define mace_eth_read(r)	\
-	mace_read(mace->eth.r)
-#define mace_eth_write(v,r)	\
-	mace_write(v,mace->eth.r)
-
 
 /* 
  * Peripherals
@@ -168,28 +135,24 @@
 
 /* Audio registers */
 struct mace_audio {
-	mace32_t control;
-	mace32_t codec_control;		/* codec status control */
-	mace32_t codec_mask;		/* codec status input mask */
-	mace32_t codec_read;		/* codec status read data */
+	volatile unsigned long control;
+	volatile unsigned long codec_control;		/* codec status control */
+	volatile unsigned long codec_mask;		/* codec status input mask */
+	volatile unsigned long codec_read;		/* codec status read data */
 	struct {
-		mace32_t control;	/* channel control */
-		mace32_t read_ptr;	/* channel read pointer */
-		mace32_t write_ptr;	/* channel write pointer */
-		mace32_t depth;		/* channel depth */
-	} channel[3];
-};
-#define mace_perif_audio_read(r)	\
-	mace_read(mace->perif.audio.r)
-#define mace_perif_audio_write(v,r)	\
-	mace_write(v,mace->perif.audio.r)
+		volatile unsigned long control;		/* channel control */
+		volatile unsigned long read_ptr;	/* channel read pointer */
+		volatile unsigned long write_ptr;	/* channel write pointer */
+		volatile unsigned long depth;		/* channel depth */
+	} chan[3];
+};
 
 /* ISA Control and DMA registers */
 struct mace_isactrl {
-	mace32_t ringbase;
+	volatile unsigned long ringbase;
 #define MACEISA_RINGBUFFERS_SIZE	(8 * 4096)
 
-	mace32_t misc;
+	volatile unsigned long misc;
 #define MACEISA_FLASH_WE		BIT(0)	/* 1=> Enable FLASH writes */
 #define MACEISA_PWD_CLEAR		BIT(1)	/* 1=> PWD CLEAR jumper detected */
 #define MACEISA_NIC_DEASSERT		BIT(2)
@@ -198,8 +161,8 @@
 #define MACEISA_LED_GREEN		BIT(5)	/* 0=> Illuminate green LED */
 #define MACEISA_DP_RAM_ENABLE		BIT(6)
 
-	mace32_t istat;
-	mace32_t imask;
+	volatile unsigned long istat;
+	volatile unsigned long imask;
 #define MACEISA_AUDIO_SW_INT		BIT(0)
 #define MACEISA_AUDIO_SC_INT		BIT(1)
 #define MACEISA_AUDIO1_DMAT_INT		BIT(2)
@@ -233,22 +196,18 @@
 #define MACEISA_SERIAL2_RDMAT_INT	BIT(30)
 #define MACEISA_SERIAL2_RDMAOR_INT	BIT(31)
 
-	mace64_t _pad[0x2000/8 - 4];
+	volatile unsigned long _pad[0x2000/8 - 4];
 
-	mace64_t dp_ram[0x400];
+	volatile unsigned long dp_ram[0x400];
 };
-#define mace_perif_ctrl_read(r)		\
-	mace_read(mace->perif.ctrl.r)
-#define mace_perif_ctrl_write(v,r)	\
-	mace_write(v,mace->perif.ctrl.r)
 
 /* Keyboard & Mouse registers
  * -> drivers/input/serio/maceps2.c */
 struct mace_ps2port {
-	mace32_t tx;
-	mace32_t rx;
-	mace32_t control;
-	mace32_t status;
+	volatile unsigned long tx;
+	volatile unsigned long rx;
+	volatile unsigned long control;
+	volatile unsigned long status;
 };
 
 struct mace_ps2 {
@@ -259,20 +218,20 @@
 /* I2C registers
  * -> drivers/i2c/algos/i2c-algo-sgi.c */
 struct mace_i2c {
-	mace32_t config;
+	volatile unsigned long config;
 #define MACEI2C_RESET           BIT(0)
 #define MACEI2C_FAST            BIT(1)
 #define MACEI2C_DATA_OVERRIDE   BIT(2)
 #define MACEI2C_CLOCK_OVERRIDE  BIT(3)
 #define MACEI2C_DATA_STATUS     BIT(4)
 #define MACEI2C_CLOCK_STATUS    BIT(5)
-	mace32_t control;
-	mace32_t data;
+	volatile unsigned long control;
+	volatile unsigned long data;
 };
 
 /* Timer registers */
 typedef union {
-	mace64_t ust_msc;
+	volatile unsigned long ust_msc;
 	struct reg {
 		volatile unsigned int ust;
 		volatile unsigned int msc;
@@ -280,12 +239,12 @@
 } timer_reg;
 
 struct mace_timers {
-	mace32_t ust;
+	volatile unsigned long ust;
 #define MACE_UST_PERIOD_NS	960
 
-	mace32_t compare1;
-	mace32_t compare2;
-	mace32_t compare3;
+	volatile unsigned long compare1;
+	volatile unsigned long compare2;
+	volatile unsigned long compare3;
 
 	timer_reg audio_in;
 	timer_reg audio_out1;
@@ -326,7 +285,7 @@
 
 /* Serial port */
 struct mace_serial {
-	mace64_t xxx;	/* later... */
+	volatile unsigned long xxx;	/* later... */
 };
 
 struct mace_isa {
diff -Nru a/include/asm-mips/irq.h b/include/asm-mips/irq.h
--- a/include/asm-mips/irq.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-mips/irq.h	2004-12-24 13:36:18 -08:00
@@ -22,14 +22,32 @@
 #define irq_canonicalize(irq) (irq)	/* Sane hardware, sane code ... */
 #endif
 
-extern void disable_irq(unsigned int);
-extern void disable_irq_nosync(unsigned int);
-extern void enable_irq(unsigned int);
-
 struct pt_regs;
-extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
 
-extern void init_generic_irq(void);
+#ifdef CONFIG_PREEMPT
+
+extern asmlinkage unsigned int do_IRQ(unsigned int irq, struct pt_regs *regs);
+
+#else
+
+/*
+ * do_IRQ handles all normal device IRQ's (the special
+ * SMP cross-CPU interrupts have their own specific
+ * handlers).
+ *
+ * Ideally there should be away to get this into kernel/irq/handle.c to
+ * avoid the overhead of a call for just a tiny function ...
+ */
+#define do_IRQ(irq, regs)						\
+do {									\
+	irq_enter();							\
+	__do_IRQ((irq), (regs));					\
+	irq_exit();							\
+} while (0)
+
+#endif
+
+extern void arch_init_irq(void);
 
 struct irqaction;
 int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
diff -Nru a/include/asm-mips/jazz.h b/include/asm-mips/jazz.h
--- a/include/asm-mips/jazz.h	2004-12-24 13:36:34 -08:00
+++ b/include/asm-mips/jazz.h	2004-12-24 13:36:34 -08:00
@@ -107,6 +107,8 @@
 	unsigned char command;
 } jazz_keyboard_hardware;
 
+#define jazz_kh ((keyboard_hardware *) JAZZ_KEYBOARD_ADDRESS)
+
 typedef struct {
 	unsigned char pad0[3];
 	unsigned char data;
diff -Nru a/include/asm-mips/mach-atlas/mc146818rtc.h b/include/asm-mips/mach-atlas/mc146818rtc.h
--- a/include/asm-mips/mach-atlas/mc146818rtc.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-mips/mach-atlas/mc146818rtc.h	2004-12-24 13:37:29 -08:00
@@ -29,7 +29,7 @@
 #define RTC_EXTENT	16
 #define RTC_IRQ		ATLASINT_RTC
 
-#if CONFIG_CPU_LITTLE_ENDIAN
+#ifdef CONFIG_CPU_LITTLE_ENDIAN
 #define ATLAS_RTC_PORT(x) (RTC_PORT(x) + 0)
 #else
 #define ATLAS_RTC_PORT(x) (RTC_PORT(x) + 3)
diff -Nru a/include/asm-mips/mach-au1x00/au1000.h b/include/asm-mips/mach-au1x00/au1000.h
--- a/include/asm-mips/mach-au1x00/au1000.h	2004-12-24 13:36:30 -08:00
+++ b/include/asm-mips/mach-au1x00/au1000.h	2004-12-24 13:36:30 -08:00
@@ -161,6 +161,7 @@
 #endif
 
 /* SDRAM Controller */
+#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1100)
 #define MEM_SDMODE0                0xB4000000
 #define MEM_SDMODE1                0xB4000004
 #define MEM_SDMODE2                0xB4000008
@@ -179,6 +180,7 @@
 
 #define MEM_SDSLEEP                0xB4000030
 #define MEM_SDSMCKE                0xB4000034
+#endif
 
 /* Static Bus Controller */
 #define MEM_STCFG0                 0xB4001000
@@ -197,7 +199,7 @@
 #define MEM_STTIME3                0xB4001034
 #define MEM_STADDR3                0xB4001038
 
-#ifdef CONFIG_SOC_AU1550
+#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
 #define MEM_STNDCTL                0xB4001100
 #define MEM_STSTAT                 0xB4001104
 
@@ -292,21 +294,14 @@
 #define INTC_INT_HIGH_AND_LOW_LEVEL    0x7
 
 /* Interrupt Numbers */
+/* Au1000 */
+#ifdef CONFIG_SOC_AU1000
 #define AU1000_UART0_INT          0
 #define AU1000_UART1_INT          1 /* au1000 */
 #define AU1000_UART2_INT          2 /* au1000 */
-
-#define AU1000_PCI_INTA           1 /* au1500 */
-#define AU1000_PCI_INTB           2 /* au1500 */
-
 #define AU1000_UART3_INT          3
-
 #define AU1000_SSI0_INT           4 /* au1000 */
 #define AU1000_SSI1_INT           5 /* au1000 */
-
-#define AU1000_PCI_INTC           4 /* au1500 */
-#define AU1000_PCI_INTD           5 /* au1500 */
-
 #define AU1000_DMA_INT_BASE       6
 #define AU1000_TOY_INT            14
 #define AU1000_TOY_MATCH0_INT     15
@@ -324,11 +319,8 @@
 #define AU1000_ACSYNC_INT         27
 #define AU1000_MAC0_DMA_INT       28
 #define AU1000_MAC1_DMA_INT       29
-#define AU1000_ETH0_IRQ           AU1000_MAC0_DMA_INT
-#define AU1000_ETH1_IRQ           AU1000_MAC1_DMA_INT
 #define AU1000_I2S_UO_INT         30 /* au1000 */
 #define AU1000_AC97C_INT          31
-#define AU1000_LAST_INTC0_INT     AU1000_AC97C_INT
 #define AU1000_GPIO_0             32
 #define AU1000_GPIO_1             33
 #define AU1000_GPIO_2             34
@@ -345,8 +337,6 @@
 #define AU1000_GPIO_13            45
 #define AU1000_GPIO_14            46
 #define AU1000_GPIO_15            47
-
-/* Au1000 only */
 #define AU1000_GPIO_16            48
 #define AU1000_GPIO_17            49
 #define AU1000_GPIO_18            50
@@ -364,7 +354,62 @@
 #define AU1000_GPIO_30            62
 #define AU1000_GPIO_31            63
 
-/* Au1500 only */
+#define UART0_ADDR                0xB1100000
+#define UART1_ADDR                0xB1200000
+#define UART2_ADDR                0xB1300000
+#define UART3_ADDR                0xB1400000
+
+#define USB_OHCI_BASE             0x10100000 // phys addr for ioremap
+#define USB_HOST_CONFIG           0xB017fffc
+
+#define AU1000_ETH0_BASE      0xB0500000
+#define AU1000_ETH1_BASE      0xB0510000
+#define AU1000_MAC0_ENABLE       0xB0520000
+#define AU1000_MAC1_ENABLE       0xB0520004
+#define NUM_ETH_INTERFACES 2
+#endif // CONFIG_SOC_AU1000
+
+/* Au1500 */
+#ifdef CONFIG_SOC_AU1500
+#define AU1500_UART0_INT          0
+#define AU1000_PCI_INTA           1 /* au1500 */
+#define AU1000_PCI_INTB           2 /* au1500 */
+#define AU1500_UART3_INT          3
+#define AU1000_PCI_INTC           4 /* au1500 */
+#define AU1000_PCI_INTD           5 /* au1500 */
+#define AU1000_DMA_INT_BASE       6
+#define AU1000_TOY_INT            14
+#define AU1000_TOY_MATCH0_INT     15
+#define AU1000_TOY_MATCH1_INT     16
+#define AU1000_TOY_MATCH2_INT     17
+#define AU1000_RTC_INT            18
+#define AU1000_RTC_MATCH0_INT     19
+#define AU1000_RTC_MATCH1_INT     20
+#define AU1000_RTC_MATCH2_INT     21
+#define AU1500_PCI_ERR_INT        22
+#define AU1000_USB_DEV_REQ_INT    24
+#define AU1000_USB_DEV_SUS_INT    25
+#define AU1000_USB_HOST_INT       26
+#define AU1000_ACSYNC_INT         27
+#define AU1500_MAC0_DMA_INT       28
+#define AU1500_MAC1_DMA_INT       29
+#define AU1000_AC97C_INT          31
+#define AU1000_GPIO_0             32
+#define AU1000_GPIO_1             33
+#define AU1000_GPIO_2             34
+#define AU1000_GPIO_3             35
+#define AU1000_GPIO_4             36
+#define AU1000_GPIO_5             37
+#define AU1000_GPIO_6             38
+#define AU1000_GPIO_7             39
+#define AU1000_GPIO_8             40
+#define AU1000_GPIO_9             41
+#define AU1000_GPIO_10            42
+#define AU1000_GPIO_11            43
+#define AU1000_GPIO_12            44
+#define AU1000_GPIO_13            45
+#define AU1000_GPIO_14            46
+#define AU1000_GPIO_15            47
 #define AU1500_GPIO_200           48
 #define AU1500_GPIO_201           49
 #define AU1500_GPIO_202           50
@@ -382,14 +427,79 @@
 #define AU1500_GPIO_207           62
 #define AU1500_GPIO_208_215       63
 
-#define AU1000_MAX_INTR           63
+#define UART0_ADDR                0xB1100000
+#define UART3_ADDR                0xB1400000
+
+#define USB_OHCI_BASE             0x10100000 // phys addr for ioremap
+#define USB_HOST_CONFIG           0xB017fffc
 
-#define AU1100_SD		2
+#define AU1500_ETH0_BASE	  0xB1500000
+#define AU1500_ETH1_BASE	  0xB1510000
+#define AU1500_MAC0_ENABLE       0xB1520000
+#define AU1500_MAC1_ENABLE       0xB1520004
+#define NUM_ETH_INTERFACES 2
+#endif // CONFIG_SOC_AU1500
+
+/* Au1100 */
+#ifdef CONFIG_SOC_AU1100
+#define AU1100_UART0_INT          0
+#define AU1100_UART1_INT          1
+#define AU1100_SD_INT             2
+#define AU1100_UART3_INT          3
+#define AU1000_SSI0_INT           4
+#define AU1000_SSI1_INT           5
+#define AU1000_DMA_INT_BASE       6
+#define AU1000_TOY_INT            14
+#define AU1000_TOY_MATCH0_INT     15
+#define AU1000_TOY_MATCH1_INT     16
+#define AU1000_TOY_MATCH2_INT     17
+#define AU1000_RTC_INT            18
+#define AU1000_RTC_MATCH0_INT     19
+#define AU1000_RTC_MATCH1_INT     20
+#define AU1000_RTC_MATCH2_INT     21
+#define AU1000_IRDA_TX_INT        22
+#define AU1000_IRDA_RX_INT        23
+#define AU1000_USB_DEV_REQ_INT    24
+#define AU1000_USB_DEV_SUS_INT    25
+#define AU1000_USB_HOST_INT       26
+#define AU1000_ACSYNC_INT         27
+#define AU1100_MAC0_DMA_INT       28
 #define	AU1100_GPIO_208_215	29
-// Seperate defines for AU1550 SOC
-#define AU1550_UART0_INT          AU1000_UART0_INT
-#define AU1550_PCI_INTA           AU1000_PCI_INTA
-#define AU1550_PCI_INTB           AU1000_PCI_INTB
+#define	AU1100_LCD_INT            30
+#define AU1000_AC97C_INT          31
+#define AU1000_GPIO_0             32
+#define AU1000_GPIO_1             33
+#define AU1000_GPIO_2             34
+#define AU1000_GPIO_3             35
+#define AU1000_GPIO_4             36
+#define AU1000_GPIO_5             37
+#define AU1000_GPIO_6             38
+#define AU1000_GPIO_7             39
+#define AU1000_GPIO_8             40
+#define AU1000_GPIO_9             41
+#define AU1000_GPIO_10            42
+#define AU1000_GPIO_11            43
+#define AU1000_GPIO_12            44
+#define AU1000_GPIO_13            45
+#define AU1000_GPIO_14            46
+#define AU1000_GPIO_15            47
+
+#define UART0_ADDR                0xB1100000
+#define UART1_ADDR                0xB1200000
+#define UART3_ADDR                0xB1400000
+
+#define USB_OHCI_BASE             0x10100000 // phys addr for ioremap
+#define USB_HOST_CONFIG           0xB017fffc
+
+#define AU1100_ETH0_BASE	  0xB0500000
+#define AU1100_MAC0_ENABLE       0xB0520000
+#define NUM_ETH_INTERFACES 1
+#endif // CONFIG_SOC_AU1100
+
+#ifdef CONFIG_SOC_AU1550
+#define AU1550_UART0_INT          0
+#define AU1550_PCI_INTA           1
+#define AU1550_PCI_INTB           2
 #define AU1550_DDMA_INT           3
 #define AU1550_CRYPTO_INT         4
 #define AU1550_PCI_INTC           5
@@ -413,11 +523,27 @@
 #define AU1550_USB_DEV_REQ_INT    24
 #define AU1550_USB_DEV_SUS_INT    25
 #define AU1550_USB_HOST_INT       26
+#define AU1000_USB_DEV_REQ_INT    AU1550_USB_DEV_REQ_INT
+#define AU1000_USB_DEV_SUS_INT    AU1550_USB_DEV_SUS_INT
+#define AU1000_USB_HOST_INT       AU1550_USB_HOST_INT
 #define AU1550_MAC0_DMA_INT       27
 #define AU1550_MAC1_DMA_INT       28
-#define AU1550_ETH0_IRQ           AU1550_MAC0_DMA_INT
-#define AU1550_ETH1_IRQ           AU1550_MAC1_DMA_INT
-
+#define AU1000_GPIO_0             32
+#define AU1000_GPIO_1             33
+#define AU1000_GPIO_2             34
+#define AU1000_GPIO_3             35
+#define AU1000_GPIO_4             36
+#define AU1000_GPIO_5             37
+#define AU1000_GPIO_6             38
+#define AU1000_GPIO_7             39
+#define AU1000_GPIO_8             40
+#define AU1000_GPIO_9             41
+#define AU1000_GPIO_10            42
+#define AU1000_GPIO_11            43
+#define AU1000_GPIO_12            44
+#define AU1000_GPIO_13            45
+#define AU1000_GPIO_14            46
+#define AU1000_GPIO_15            47
 #define AU1550_GPIO_200           48
 #define AU1500_GPIO_201_205       49	// Logical or of GPIO201:205
 #define AU1500_GPIO_16            50
@@ -435,7 +561,101 @@
 #define AU1500_GPIO_207           62
 #define AU1500_GPIO_208_218       63	// Logical or of GPIO208:218
 
-// REDEFINE SECONDARY GPIO BLOCK INTO IC1 CONTROLLER HERE
+#define UART0_ADDR                0xB1100000
+#define UART1_ADDR                0xB1200000
+#define UART3_ADDR                0xB1400000
+
+#define USB_OHCI_BASE             0x14020000 // phys addr for ioremap
+#define USB_HOST_CONFIG           0xB4027ffc
+
+#define AU1550_ETH0_BASE      0xB0500000
+#define AU1550_ETH1_BASE      0xB0510000
+#define AU1550_MAC0_ENABLE       0xB0520000
+#define AU1550_MAC1_ENABLE       0xB0520004
+#define NUM_ETH_INTERFACES 2
+#endif // CONFIG_SOC_AU1550
+
+#ifdef CONFIG_SOC_AU1200
+#define AU1200_UART0_INT          0
+#define AU1200_SWT_INT            1
+#define AU1200_SD_INT             2
+#define AU1200_DDMA_INT           3
+#define AU1200_MAE_BE_INT         4
+#define AU1200_GPIO_200           5
+#define AU1200_GPIO_201           6
+#define AU1200_GPIO_202           7
+#define AU1200_UART1_INT          8
+#define AU1200_MAE_FE_INT         9
+#define AU1200_PSC0_INT           10
+#define AU1200_PSC1_INT           11
+#define AU1200_AES_INT            12
+#define AU1200_CAMERA_INT         13
+#define AU1200_TOY_INT			  14
+#define AU1200_TOY_MATCH0_INT     15
+#define AU1200_TOY_MATCH1_INT     16
+#define AU1200_TOY_MATCH2_INT     17
+#define AU1200_RTC_INT            18
+#define AU1200_RTC_MATCH0_INT     19
+#define AU1200_RTC_MATCH1_INT     20
+#define AU1200_RTC_MATCH2_INT     21
+#define AU1200_NAND_INT           23
+#define AU1200_GPIO_204           24
+#define AU1200_GPIO_205           25
+#define AU1200_GPIO_206           26
+#define AU1200_GPIO_207           27
+#define AU1200_GPIO_208_215       28 // Logical OR of 208:215
+#define AU1200_USB_INT            29
+#define AU1200_LCD_INT            30
+#define AU1200_MAE_BOTH_INT       31
+#define AU1000_GPIO_0             32
+#define AU1000_GPIO_1             33
+#define AU1000_GPIO_2             34
+#define AU1000_GPIO_3             35
+#define AU1000_GPIO_4             36
+#define AU1000_GPIO_5             37
+#define AU1000_GPIO_6             38
+#define AU1000_GPIO_7             39
+#define AU1000_GPIO_8             40
+#define AU1000_GPIO_9             41
+#define AU1000_GPIO_10            42
+#define AU1000_GPIO_11            43
+#define AU1000_GPIO_12            44
+#define AU1000_GPIO_13            45
+#define AU1000_GPIO_14            46
+#define AU1000_GPIO_15            47
+#define AU1000_GPIO_16            48
+#define AU1000_GPIO_17            49
+#define AU1000_GPIO_18            50
+#define AU1000_GPIO_19            51
+#define AU1000_GPIO_20            52
+#define AU1000_GPIO_21            53
+#define AU1000_GPIO_22            54
+#define AU1000_GPIO_23            55
+#define AU1000_GPIO_24            56
+#define AU1000_GPIO_25            57
+#define AU1000_GPIO_26            58
+#define AU1000_GPIO_27            59
+#define AU1000_GPIO_28            60
+#define AU1000_GPIO_29            61
+#define AU1000_GPIO_30            62
+#define AU1000_GPIO_31            63
+
+#define UART0_ADDR                0xB1100000
+#define UART1_ADDR                0xB1200000
+
+#define USB_OHCI_BASE             0x14020000 // phys addr for ioremap
+#define USB_HOST_CONFIG           0xB4027ffc
+
+// these are here for prototyping on au1550 (do not exist on au1200)
+#define AU1200_ETH0_BASE      0xB0500000
+#define AU1200_ETH1_BASE      0xB0510000
+#define AU1200_MAC0_ENABLE       0xB0520000
+#define AU1200_MAC1_ENABLE       0xB0520004
+#define NUM_ETH_INTERFACES 2
+#endif // CONFIG_SOC_AU1200
+
+#define AU1000_LAST_INTC0_INT     31
+#define AU1000_MAX_INTR           63
 
 
 /* Programmable Counters 0 and 1 */
@@ -509,16 +729,7 @@
   #define I2S_CONTROL_CE        (1<<0)
 
 /* USB Host Controller */
-// We pass USB_OHCI_BASE to ioremap, so it needs to be a physical address
-#if defined( CONFIG_SOC_AU1550 )
-#define USB_OHCI_BASE             0x14020000
-#define USB_OHCI_LEN              0x00100000
-#define USB_HOST_CONFIG           0xB4027ffc
-#else
-#define USB_OHCI_BASE             0x10100000
 #define USB_OHCI_LEN              0x00100000
-#define USB_HOST_CONFIG           0xB017fffc
-#endif
 
 /* USB Device Controller */
 #define USBD_EP0RD                0xB0200000
@@ -563,13 +774,6 @@
   #define USBDEV_CE     (1<<0)
 
 /* Ethernet Controllers  */
-#define AU1000_ETH0_BASE          0xB0500000
-#define AU1000_ETH1_BASE          0xB0510000
-#define AU1500_ETH0_BASE	  0xB1500000
-#define AU1500_ETH1_BASE	  0xB1510000
-#define AU1100_ETH0_BASE	  0xB0500000
-#define AU1550_ETH0_BASE      0xB0500000
-#define AU1550_ETH1_BASE      0xB0510000
 
 /* 4 byte offsets from AU1000_ETH_BASE */
 #define MAC_CONTROL                     0x0
@@ -614,11 +818,6 @@
 #define MAC_VLAN2_TAG                  0x24
 
 /* Ethernet Controller Enable */
-#define AU1000_MAC0_ENABLE       0xB0520000
-#define AU1000_MAC1_ENABLE       0xB0520004
-#define AU1500_MAC0_ENABLE       0xB1520000
-#define AU1500_MAC1_ENABLE       0xB1520004
-#define AU1100_MAC0_ENABLE       0xB0520000
 
   #define MAC_EN_CLOCK_ENABLE         (1<<0)
   #define MAC_EN_RESET0               (1<<1)
@@ -702,10 +901,6 @@
 
 
 /* UARTS 0-3 */
-#define UART0_ADDR                0xB1100000
-#define UART1_ADDR                0xB1200000
-#define UART2_ADDR                0xB1300000
-#define UART3_ADDR                0xB1400000
 #define UART_BASE                 UART0_ADDR
 #define UART_DEBUG_BASE           UART3_ADDR
 
@@ -976,7 +1171,6 @@
   #define SYS_PF_PSC1_S1		(1 << 1)
   #define SYS_PF_MUST_BE_SET		((1 << 5) | (1 << 2))
 
-
 #define SYS_TRIOUTRD              0xB1900100
 #define SYS_TRIOUTCLR             0xB1900100
 #define SYS_OUTPUTRD              0xB1900108
@@ -1134,12 +1328,12 @@
  * addresses.  For PCI IO, it's simpler because we get to do the ioremap
  * ourselves and then adjust the device's resources.
  */
-#define Au1500_EXT_CFG            0x600000000
-#define Au1500_EXT_CFG_TYPE1      0x680000000
-#define Au1500_PCI_IO_START       0x500000000
-#define Au1500_PCI_IO_END         0x5000FFFFF
-#define Au1500_PCI_MEM_START      0x440000000
-#define Au1500_PCI_MEM_END        0x44FFFFFFF
+#define Au1500_EXT_CFG            0x600000000ULL
+#define Au1500_EXT_CFG_TYPE1      0x680000000ULL
+#define Au1500_PCI_IO_START       0x500000000ULL
+#define Au1500_PCI_IO_END         0x5000FFFFFULL
+#define Au1500_PCI_MEM_START      0x440000000ULL
+#define Au1500_PCI_MEM_END        0x44FFFFFFFULL
 
 #define PCI_IO_START    (Au1500_PCI_IO_START + 0x1000)
 #define PCI_IO_END      (Au1500_PCI_IO_END)
@@ -1148,7 +1342,7 @@
 #define PCI_FIRST_DEVFN (0<<3)
 #define PCI_LAST_DEVFN  (19<<3)
 
-#define IOPORT_RESOURCE_START 0x00001000 /* skip the legacy ide probing */
+#define IOPORT_RESOURCE_START 0x00001000 /* skip legacy probing */
 #define IOPORT_RESOURCE_END   0xffffffff
 #define IOMEM_RESOURCE_START  0x10000000
 #define IOMEM_RESOURCE_END    0xffffffff
@@ -1194,11 +1388,6 @@
 
 #endif
 
-#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550)
-#define NUM_ETH_INTERFACES 2
-#elif defined(CONFIG_SOC_AU1100)
-#define NUM_ETH_INTERFACES 1
-#endif
 /* Processor information base on prid.
  * Copied from PowerPC.
  */
@@ -1208,11 +1397,10 @@
 	unsigned int	prid_value;
 
 	char		*cpu_name;
-	unsigned int	cpu_od;		/* Set Config[OD] */
-	unsigned int	cpu_bclk;	/* Enable BCLK switching */
+	unsigned char	cpu_od;		/* Set Config[OD] */
+	unsigned char	cpu_bclk;	/* Enable BCLK switching */
 };
 
 extern struct cpu_spec		cpu_specs[];
 extern struct cpu_spec		*cur_cpu_spec[];
-
 #endif
diff -Nru a/include/asm-mips/mach-db1x00/db1x00.h b/include/asm-mips/mach-db1x00/db1x00.h
--- a/include/asm-mips/mach-db1x00/db1x00.h	2004-12-24 13:36:56 -08:00
+++ b/include/asm-mips/mach-db1x00/db1x00.h	2004-12-24 13:36:56 -08:00
@@ -29,6 +29,7 @@
 
 #ifdef CONFIG_MIPS_DB1550
 #define BCSR_KSEG1_ADDR 0xAF000000
+#define NAND_PHYS_ADDR  0x20000000
 #else
 #define BCSR_KSEG1_ADDR 0xAE000000
 #endif
@@ -130,15 +131,6 @@
 #define SET_VCC_VPP(VCC, VPP, SLOT)\
 	((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8))
 
-/* MTD CONFIG OPTIONS */
-#if defined(CONFIG_MTD_DB1X00_BOOT) && defined(CONFIG_MTD_DB1X00_USER)
-#define DB1X00_BOTH_BANKS
-#elif defined(CONFIG_MTD_DB1X00_BOOT) && !defined(CONFIG_MTD_DB1X00_USER)
-#define DB1X00_BOOT_ONLY
-#elif !defined(CONFIG_MTD_DB1X00_BOOT) && defined(CONFIG_MTD_DB1X00_USER)
-#define DB1X00_USER_ONLY
-#endif
-
 /* SD controller macros */
 /*
  * Detect card.
@@ -181,6 +173,30 @@
 			au_sync(); \
 		} \
 	} while (0)
+
+
+/* NAND defines */
+/* Timing values as described in databook, * ns value stripped of
+ * lower 2 bits.
+ * These defines are here rather than an SOC1550 generic file because
+ * the parts chosen on another board may be different and may require
+ * different timings.
+ */
+#define NAND_T_H			(18 >> 2)
+#define NAND_T_PUL			(30 >> 2)
+#define NAND_T_SU			(30 >> 2)
+#define NAND_T_WH			(30 >> 2)
+
+/* Bitfield shift amounts */
+#define NAND_T_H_SHIFT		0
+#define NAND_T_PUL_SHIFT	4
+#define NAND_T_SU_SHIFT		8
+#define NAND_T_WH_SHIFT		12
+
+#define NAND_TIMING	((NAND_T_H   & 0xF)	<< NAND_T_H_SHIFT)   | \
+			((NAND_T_PUL & 0xF)	<< NAND_T_PUL_SHIFT) | \
+			((NAND_T_SU  & 0xF)	<< NAND_T_SU_SHIFT)  | \
+			((NAND_T_WH  & 0xF)	<< NAND_T_WH_SHIFT)
 
 #endif /* __ASM_DB1X00_H */
 
diff -Nru a/include/asm-mips/mach-generic/floppy.h b/include/asm-mips/mach-generic/floppy.h
--- a/include/asm-mips/mach-generic/floppy.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-mips/mach-generic/floppy.h	2004-12-24 13:37:43 -08:00
@@ -12,7 +12,6 @@
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/sched.h>
-#include <linux/kernel.h>
 #include <linux/linkage.h>
 #include <linux/types.h>
 #include <linux/mm.h>
diff -Nru a/include/asm-mips/mach-generic/ide.h b/include/asm-mips/mach-generic/ide.h
--- a/include/asm-mips/mach-generic/ide.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-mips/mach-generic/ide.h	2004-12-24 13:37:00 -08:00
@@ -3,13 +3,18 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * IDE routines for typical pc-like legacy IDE configurations.
+ * Copyright (C) 1994-1996  Linus Torvalds & authors
  *
- * Copyright (C) 1998, 1999, 2001, 2003 by Ralf Baechle
+ * Copied from i386; many of the especially older MIPS or ISA-based platforms
+ * are basically identical.  Using this file probably implies i8259 PIC
+ * support in a system but the very least interrupt numbers 0 - 15 need to
+ * be put aside for legacy devices.
  */
 #ifndef __ASM_MACH_GENERIC_IDE_H
 #define __ASM_MACH_GENERIC_IDE_H
 
+#ifdef __KERNEL__
+
 #include <linux/config.h>
 
 #ifndef MAX_HWIFS
@@ -22,7 +27,7 @@
 
 #define IDE_ARCH_OBSOLETE_DEFAULTS
 
-static inline int ide_default_irq(unsigned long base)
+static __inline__ int ide_default_irq(unsigned long base)
 {
 	switch (base) {
 		case 0x1f0: return 14;
@@ -36,11 +41,11 @@
 	}
 }
 
-static inline unsigned long ide_default_io_base(int index)
+static __inline__ unsigned long ide_default_io_base(int index)
 {
 	switch (index) {
-		case 0: return 0x1f0;
-		case 1: return 0x170;
+		case 0:	return 0x1f0;
+		case 1:	return 0x170;
 		case 2: return 0x1e8;
 		case 3: return 0x168;
 		case 4: return 0x1e0;
@@ -58,5 +63,9 @@
 #else
 #define ide_init_default_irq(base)	ide_default_irq(base)
 #endif
+
+#include <asm-generic/ide_iops.h>
+
+#endif /* __KERNEL__ */
 
 #endif /* __ASM_MACH_GENERIC_IDE_H */
diff -Nru a/include/asm-mips/mach-generic/mangle-port.h b/include/asm-mips/mach-generic/mangle-port.h
--- a/include/asm-mips/mach-generic/mangle-port.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-mips/mach-generic/mangle-port.h	2004-12-24 13:37:43 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2003 Ralf Baechle
+ * Copyright (C) 2003, 2004 Ralf Baechle
  */
 #ifndef __ASM_MACH_GENERIC_MANGLE_PORT_H
 #define __ASM_MACH_GENERIC_MANGLE_PORT_H
@@ -11,5 +11,6 @@
 #define __swizzle_addr_b(port)	(port)
 #define __swizzle_addr_w(port)	(port)
 #define __swizzle_addr_l(port)	(port)
+#define __swizzle_addr_q(port)	(port)
 
 #endif /* __ASM_MACH_GENERIC_MANGLE_PORT_H */
diff -Nru a/include/asm-mips/mach-generic/spaces.h b/include/asm-mips/mach-generic/spaces.h
--- a/include/asm-mips/mach-generic/spaces.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-mips/mach-generic/spaces.h	2004-12-24 13:37:29 -08:00
@@ -7,8 +7,8 @@
  * Copyright (C) 2000, 2002  Maciej W. Rozycki
  * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
  */
-#ifndef _ASM_MACH_SPACES_H
-#define _ASM_MACH_SPACES_H
+#ifndef _ASM_MACH_GENERIC_SPACES_H
+#define _ASM_MACH_GENERIC_SPACES_H
 
 #include <linux/config.h>
 
diff -Nru a/include/asm-mips/mach-ip22/spaces.h b/include/asm-mips/mach-ip22/spaces.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/mach-ip22/spaces.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,55 @@
+/*
+ * 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 - 1999, 2000, 03, 04 Ralf Baechle
+ * Copyright (C) 2000, 2002  Maciej W. Rozycki
+ * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
+ */
+#ifndef _ASM_MACH_IP22_SPACES_H
+#define _ASM_MACH_IP22_SPACES_H
+
+#include <linux/config.h>
+
+#ifdef CONFIG_MIPS32
+
+#define CAC_BASE		0x80000000
+#define IO_BASE			0xa0000000
+#define UNCAC_BASE		0xa0000000
+#define MAP_BASE		0xc0000000
+
+/*
+ * This handles the memory map.
+ * We handle pages at KSEG0 for kernels with 32 bit address space.
+ */
+#define PAGE_OFFSET		0x80000000UL
+
+/*
+ * Memory above this physical address will be considered highmem.
+ */
+#ifndef HIGHMEM_START
+#define HIGHMEM_START		0x20000000UL
+#endif
+
+#endif /* CONFIG_MIPS32 */
+
+#ifdef CONFIG_MIPS64
+#define PAGE_OFFSET		0xffffffff80000000UL
+
+#ifndef HIGHMEM_START
+#define HIGHMEM_START		(1UL << 59UL)
+#endif
+
+#define CAC_BASE		0xffffffff80000000
+#define IO_BASE			0xffffffffa0000000
+#define UNCAC_BASE		0xffffffffa0000000
+#define MAP_BASE		0xffffffffc0000000
+
+#define TO_PHYS(x)		(             ((x) & TO_PHYS_MASK))
+#define TO_CAC(x)		(CAC_BASE   | ((x) & TO_PHYS_MASK))
+#define TO_UNCAC(x)		(UNCAC_BASE | ((x) & TO_PHYS_MASK))
+
+#endif /* CONFIG_MIPS64 */
+
+#endif /* __ASM_MACH_IP22_SPACES_H */
diff -Nru a/include/asm-mips/mach-ip27/mangle-port.h b/include/asm-mips/mach-ip27/mangle-port.h
--- a/include/asm-mips/mach-ip27/mangle-port.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-mips/mach-ip27/mangle-port.h	2004-12-24 13:37:29 -08:00
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2003 Ralf Baechle
+ * Copyright (C) 2003, 2004 Ralf Baechle
  */
 #ifndef __ASM_MACH_IP27_MANGLE_PORT_H
 #define __ASM_MACH_IP27_MANGLE_PORT_H
@@ -11,5 +11,6 @@
 #define __swizzle_addr_b(port)	(port)
 #define __swizzle_addr_w(port)	((port) ^ 2)
 #define __swizzle_addr_l(port)	(port)
+#define __swizzle_addr_q(port)	(port)
 
 #endif /* __ASM_MACH_IP27_MANGLE_PORT_H */
diff -Nru a/include/asm-mips/mach-ip27/mmzone.h b/include/asm-mips/mach-ip27/mmzone.h
--- a/include/asm-mips/mach-ip27/mmzone.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-mips/mach-ip27/mmzone.h	2004-12-24 13:36:48 -08:00
@@ -3,7 +3,34 @@
 
 #include <asm/sn/addrs.h>
 #include <asm/sn/arch.h>
+#include <asm/sn/hub.h>
 
 #define pa_to_nid(addr)		NASID_TO_COMPACT_NODEID(NASID_GET(addr))
+
+#define LEVELS_PER_SLICE        128
+
+struct slice_data {
+	unsigned long irq_alloc_mask[2];
+	unsigned long irq_enable_mask[2];
+	int level_to_irq[LEVELS_PER_SLICE];
+};
+
+struct hub_data {
+	kern_vars_t	kern_vars;
+	DECLARE_BITMAP(h_bigwin_used, HUB_NUM_BIG_WINDOW);
+	cpumask_t	h_cpus;
+	unsigned long slice_map;
+	struct slice_data slice[2];
+};
+
+struct node_data {
+	struct pglist_data pglist;
+	struct hub_data hub;
+};
+
+extern struct node_data *__node_data[];
+
+#define NODE_DATA(n)		(&__node_data[(n)]->pglist)
+#define hub_data(n)		(&__node_data[(n)]->hub)
 
 #endif /* _ASM_MACH_MMZONE_H */
diff -Nru a/include/asm-mips/mach-ip27/spaces.h b/include/asm-mips/mach-ip27/spaces.h
--- a/include/asm-mips/mach-ip27/spaces.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-mips/mach-ip27/spaces.h	2004-12-24 13:37:18 -08:00
@@ -7,8 +7,8 @@
  * Copyright (C) 2000, 2002  Maciej W. Rozycki
  * Copyright (C) 1990, 1999 by Silicon Graphics, Inc.
  */
-#ifndef _ASM_MACH_SPACES_H
-#define _ASM_MACH_SPACES_H
+#ifndef _ASM_MACH_IP27_SPACES_H
+#define _ASM_MACH_IP27_SPACES_H
 
 /*
  * IP27 uses the R10000's uncached attribute feature.  Attribute 3 selects
@@ -31,4 +31,4 @@
 
 #define HIGHMEM_START		(~0UL)
 
-#endif /* _ASM_MACH_SPACES_H */
+#endif /* _ASM_MACH_IP27_SPACES_H */
diff -Nru a/include/asm-mips/mach-ip27/topology.h b/include/asm-mips/mach-ip27/topology.h
--- a/include/asm-mips/mach-ip27/topology.h	2004-12-24 13:37:44 -08:00
+++ b/include/asm-mips/mach-ip27/topology.h	2004-12-24 13:37:44 -08:00
@@ -1,18 +1,38 @@
 #ifndef _ASM_MACH_TOPOLOGY_H
 #define _ASM_MACH_TOPOLOGY_H	1
 
+#include <asm/sn/arch.h>
 #include <asm/sn/hub.h>
+#include <asm/mmzone.h>
 
 #define cpu_to_node(cpu)	(cpu_data[(cpu)].p_nodeid)
 #define parent_node(node)	(node)
-#define node_to_cpumask(node)	(HUB_DATA(node)->h_cpus)
+#define node_to_cpumask(node)	(hub_data(node)->h_cpus)
 #define node_to_first_cpu(node)	(first_cpu(node_to_cpumask(node)))
 #define pcibus_to_cpumask(bus)	(cpu_online_map)
 
-extern int node_distance(nasid_t nasid_a, nasid_t nasid_b);
-#define node_distance(from, to)	node_distance(from, to)
+extern unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES];
 
-/* Cross-node load balancing interval. */
-#define NODE_BALANCE_RATE	10
+#define node_distance(from, to)	(__node_distances[(from)][(to)])
+
+/* sched_domains SD_NODE_INIT for SGI IP27 machines */
+#define SD_NODE_INIT (struct sched_domain) {		\
+	.span			= CPU_MASK_NONE,	\
+	.parent			= NULL,			\
+	.groups			= NULL,			\
+	.min_interval		= 8,			\
+	.max_interval		= 32,			\
+	.busy_factor		= 32,			\
+	.imbalance_pct		= 125,			\
+	.cache_hot_time		= (10*1000),		\
+	.cache_nice_tries	= 1,			\
+	.per_cpu_gain		= 100,			\
+	.flags			= SD_LOAD_BALANCE	\
+				| SD_BALANCE_EXEC	\
+				| SD_WAKE_BALANCE,	\
+	.last_balance		= jiffies,		\
+	.balance_interval	= 1,			\
+	.nr_balance_failed	= 0,			\
+}
 
 #endif /* _ASM_MACH_TOPOLOGY_H */
diff -Nru a/include/asm-mips/mach-ip32/mangle-port.h b/include/asm-mips/mach-ip32/mangle-port.h
--- a/include/asm-mips/mach-ip32/mangle-port.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-mips/mach-ip32/mangle-port.h	2004-12-24 13:37:18 -08:00
@@ -4,6 +4,7 @@
  * for more details.
  *
  * Copyright (C) 2003 Ladislav Michl
+ * Copyright (C) 2004 Ralf Baechle
  */
 #ifndef __ASM_MACH_IP32_MANGLE_PORT_H
 #define __ASM_MACH_IP32_MANGLE_PORT_H
@@ -11,5 +12,6 @@
 #define __swizzle_addr_b(port)	((port) ^ 3)
 #define __swizzle_addr_w(port)	((port) ^ 2)
 #define __swizzle_addr_l(port)	(port)
+#define __swizzle_addr_q(port)	(port)
 
 #endif /* __ASM_MACH_IP32_MANGLE_PORT_H */
diff -Nru a/include/asm-mips/mach-ip32/spaces.h b/include/asm-mips/mach-ip32/spaces.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/mach-ip32/spaces.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,42 @@
+/*
+ * 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 - 1999, 2000, 03, 04 Ralf Baechle
+ * Copyright (C) 2000, 2002  Maciej W. Rozycki
+ * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
+ */
+#ifndef _ASM_MACH_IP32_SPACES_H
+#define _ASM_MACH_IP32_SPACES_H
+
+#include <linux/config.h>
+
+/*
+ * This handles the memory map.
+ */
+#define PAGE_OFFSET		0xffffffff80000000
+
+/*
+ * Memory above this physical address will be considered highmem.
+ * Fixme: 59 bits is a fictive number and makes assumptions about processors
+ * in the distant future.  Nobody will care for a few years :-)
+ */
+#ifndef HIGHMEM_START
+#define HIGHMEM_START		(1UL << 59UL)
+#endif
+
+#ifdef CONFIG_DMA_NONCOHERENT
+#define CAC_BASE		0x9800000000000000
+#else
+#define CAC_BASE		0xa800000000000000
+#endif
+#define IO_BASE			0x9000000000000000
+#define UNCAC_BASE		0x9000000000000000
+#define MAP_BASE		0xc000000000000000
+
+#define TO_PHYS(x)		(             ((x) & TO_PHYS_MASK))
+#define TO_CAC(x)		(CAC_BASE   | ((x) & TO_PHYS_MASK))
+#define TO_UNCAC(x)		(UNCAC_BASE | ((x) & TO_PHYS_MASK))
+
+#endif /* __ASM_MACH_IP32_SPACES_H */
diff -Nru a/include/asm-mips/mach-ja/cpu-feature-overrides.h b/include/asm-mips/mach-ja/cpu-feature-overrides.h
--- a/include/asm-mips/mach-ja/cpu-feature-overrides.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-mips/mach-ja/cpu-feature-overrides.h	2004-12-24 13:37:04 -08:00
@@ -35,4 +35,10 @@
 #define cpu_icache_line_size()	32
 #define cpu_scache_line_size()	32
 
+/*
+ * On the RM9000 we need to ensure that I-cache lines being fetches only
+ * contain valid instructions are funny things will happen.
+ */
+#define PLAT_TRAMPOLINE_STUFF_LINE	32UL
+
 #endif /* __ASM_MACH_JA_CPU_FEATURE_OVERRIDES_H */
diff -Nru a/include/asm-mips/mach-mips/cpu-feature-overrides.h b/include/asm-mips/mach-mips/cpu-feature-overrides.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/mach-mips/cpu-feature-overrides.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,64 @@
+/*
+ * 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) 2003, 2004 Chris Dearman
+ */
+#ifndef __ASM_MACH_MIPS_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_MIPS_CPU_FEATURE_OVERRIDES_H
+
+/*
+ * CPU feature overrides for MIPS boards
+ */
+#ifdef CONFIG_CPU_MIPS32
+#define cpu_has_tlb		1
+#define cpu_has_4kex		1
+#define cpu_has_4ktlb		1
+/* #define cpu_has_fpu		? */
+/* #define cpu_has_32fpr	? */
+#define cpu_has_counter		1
+/* #define cpu_has_watch	? */
+#define cpu_has_divec		1
+#define cpu_has_vce		0
+/* #define cpu_has_cache_cdex_p	? */
+/* #define cpu_has_cache_cdex_s	? */
+/* #define cpu_has_prefetch	? */
+#define cpu_has_mcheck		1
+/* #define cpu_has_ejtag	? */
+#define cpu_has_llsc		1
+/* #define cpu_has_vtag_icache	? */
+/* #define cpu_has_dc_aliases	? */
+/* #define cpu_has_ic_fills_f_dc ? */
+#define cpu_has_nofpuex		0
+/* #define cpu_has_64bits	? */
+/* #define cpu_has_64bit_zero_reg ? */
+/* #define cpu_has_subset_pcaches ? */
+#endif
+
+#ifdef CONFIG_CPU_MIPS64
+#define cpu_has_tlb		1
+#define cpu_has_4kex		1
+#define cpu_has_4ktlb		1
+/* #define cpu_has_fpu		? */
+/* #define cpu_has_32fpr	? */
+#define cpu_has_counter		1
+/* #define cpu_has_watch	? */
+#define cpu_has_divec		1
+#define cpu_has_vce		0
+/* #define cpu_has_cache_cdex_p	? */
+/* #define cpu_has_cache_cdex_s	? */
+/* #define cpu_has_prefetch	? */
+#define cpu_has_mcheck		1
+/* #define cpu_has_ejtag	? */
+#define cpu_has_llsc		1
+/* #define cpu_has_vtag_icache	? */
+/* #define cpu_has_dc_aliases	? */
+/* #define cpu_has_ic_fills_f_dc ? */
+#define cpu_has_nofpuex		0
+/* #define cpu_has_64bits	? */
+/* #define cpu_has_64bit_zero_reg ? */
+/* #define cpu_has_subset_pcaches ? */
+#endif
+
+#endif /* __ASM_MACH_MIPS_CPU_FEATURE_OVERRIDES_H */
diff -Nru a/include/asm-mips/mach-ocelot3/cpu-feature-overrides.h b/include/asm-mips/mach-ocelot3/cpu-feature-overrides.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/mach-ocelot3/cpu-feature-overrides.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,47 @@
+/*
+ * 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) 2004 MontaVista Software Inc.
+ * Author: Manish Lachwani, mlachwani@mvista.com
+ * Copyright (C) 2004 Ralf Baechle
+ */
+#ifndef __ASM_MACH_JA_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_JA_CPU_FEATURE_OVERRIDES_H
+
+/*
+ * Momentum Ocelot-3 is based on Rm7900 processor which
+ * is based on the E9000 core.
+ */
+#define cpu_has_watch		1
+#define cpu_has_mips16		0
+#define cpu_has_divec		0
+#define cpu_has_vce		0
+#define cpu_has_cache_cdex_p	0
+#define cpu_has_cache_cdex_s	0
+#define cpu_has_prefetch	1
+#define cpu_has_mcheck		0
+#define cpu_has_ejtag		0
+
+#define cpu_has_llsc		1
+#define cpu_has_vtag_icache	0
+#define cpu_has_dc_aliases	0
+#define cpu_has_ic_fills_f_dc	0
+
+#define cpu_has_nofpuex 	0
+#define cpu_has_64bits		1
+
+#define cpu_has_subset_pcaches	0
+
+#define cpu_dcache_line_size()	32
+#define cpu_icache_line_size()	32
+#define cpu_scache_line_size()	32
+
+/*
+ * On the RM9000 we need to ensure that I-cache lines being fetches only
+ * contain valid instructions are funny things will happen.
+ */
+#define PLAT_TRAMPOLINE_STUFF_LINE	32UL
+
+#endif /* __ASM_MACH_JA_CPU_FEATURE_OVERRIDES_H */
diff -Nru a/include/asm-mips/mach-sibyte/cpu-feature-overrides.h b/include/asm-mips/mach-sibyte/cpu-feature-overrides.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/mach-sibyte/cpu-feature-overrides.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,38 @@
+/*
+ * 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) 2003, 2004 Ralf Baechle
+ */
+#ifndef __ASM_MACH_SIBYTE_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_SIBYTE_CPU_FEATURE_OVERRIDES_H
+
+/*
+ * Sibyte are MIPS64 processors weired to a specific configuration
+ */
+#define cpu_has_watch		1
+#define cpu_has_mips16		0
+#define cpu_has_divec		1
+#define cpu_has_vce		0
+#define cpu_has_cache_cdex_p	0
+#define cpu_has_cache_cdex_s	0
+#define cpu_has_prefetch	1
+#define cpu_has_mcheck		1
+#define cpu_has_ejtag		1
+
+#define cpu_has_llsc		1
+#define cpu_has_vtag_icache	1
+#define cpu_has_dc_aliases	0
+#define cpu_has_ic_fills_f_dc	0
+
+#define cpu_has_nofpuex		0
+#define cpu_has_64bits		1
+
+#define cpu_has_subset_pcaches	0
+
+#define cpu_dcache_line_size()	32
+#define cpu_icache_line_size()	32
+#define cpu_scache_line_size()	32
+
+#endif /* __ASM_MACH_SIBYTE_CPU_FEATURE_OVERRIDES_H */
diff -Nru a/include/asm-mips/mach-yosemite/cpu-feature-overrides.h b/include/asm-mips/mach-yosemite/cpu-feature-overrides.h
--- a/include/asm-mips/mach-yosemite/cpu-feature-overrides.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-mips/mach-yosemite/cpu-feature-overrides.h	2004-12-24 13:37:00 -08:00
@@ -35,4 +35,10 @@
 #define cpu_icache_line_size()	32
 #define cpu_scache_line_size()	32
 
+/*
+ * On the RM9000 we need to ensure that I-cache lines being fetches only
+ * contain valid instructions are funny things will happen.
+ */
+#define PLAT_TRAMPOLINE_STUFF_LINE	32UL
+
 #endif /* __ASM_MACH_YOSEMITE_CPU_FEATURE_OVERRIDES_H */
diff -Nru a/include/asm-mips/marvell.h b/include/asm-mips/marvell.h
--- a/include/asm-mips/marvell.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/marvell.h	2004-12-24 13:36:17 -08:00
@@ -11,7 +11,6 @@
 #include <linux/pci.h>
 
 #include <asm/byteorder.h>
-#include <asm/pci_channel.h>
 
 extern unsigned long marvell_base;
 
diff -Nru a/include/asm-mips/mipsregs.h b/include/asm-mips/mipsregs.h
--- a/include/asm-mips/mipsregs.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-mips/mipsregs.h	2004-12-24 13:36:49 -08:00
@@ -253,6 +253,13 @@
 #define ST0_CE			0x00020000
 
 /*
+ * Setting c0_status.co enables Hit_Writeback and Hit_Writeback_Invalidate
+ * cacheops in userspace.  This bit exists only on RM7000 and RM9000
+ * processors.
+ */
+#define ST0_CO			0x08000000
+
+/*
  * Bitfields in the R[23]000 cp0 status register.
  */
 #define ST0_IEC                 0x00000001
diff -Nru a/include/asm-mips/mmu_context.h b/include/asm-mips/mmu_context.h
--- a/include/asm-mips/mmu_context.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-mips/mmu_context.h	2004-12-24 13:36:48 -08:00
@@ -126,8 +126,8 @@
 	 * Mark current->active_mm as not "active" anymore.
 	 * We don't want to mislead possible IPI tlb flush routines.
 	 */
-	clear_bit(cpu, &prev->cpu_vm_mask);
-	set_bit(cpu, &next->cpu_vm_mask);
+	cpu_clear(cpu, prev->cpu_vm_mask);
+	cpu_set(cpu, next->cpu_vm_mask);
 
 	local_irq_restore(flags);
 }
@@ -161,8 +161,8 @@
 	TLBMISS_HANDLER_SETUP_PGD(next->pgd);
 
 	/* mark mmu ownership change */
-	clear_bit(cpu, &prev->cpu_vm_mask);
-	set_bit(cpu, &next->cpu_vm_mask);
+	cpu_clear(cpu, prev->cpu_vm_mask);
+	cpu_set(cpu, next->cpu_vm_mask);
 
 	local_irq_restore(flags);
 }
@@ -178,7 +178,7 @@
 
 	local_irq_save(flags);
 
-	if (test_bit(cpu, &mm->cpu_vm_mask))  {
+	if (cpu_isset(cpu, mm->cpu_vm_mask))  {
 		get_new_mmu_context(mm, cpu);
 		write_c0_entryhi(cpu_asid(cpu, mm));
 	} else {
diff -Nru a/include/asm-mips/mmzone.h b/include/asm-mips/mmzone.h
--- a/include/asm-mips/mmzone.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/mmzone.h	2004-12-24 13:36:17 -08:00
@@ -8,9 +8,6 @@
 #include <asm/page.h>
 #include <mmzone.h>
 
-extern struct pglist_data *node_data[];
-
-#define NODE_DATA(n)		(node_data[(n)])
 #define kvaddr_to_nid(kvaddr)	pa_to_nid(__pa(kvaddr))
 #define pfn_to_nid(pfn)		pa_to_nid((pfn) << PAGE_SHIFT)
 
diff -Nru a/include/asm-mips/msc01_ic.h b/include/asm-mips/msc01_ic.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/msc01_ic.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,151 @@
+/*
+ * PCI Register definitions for the MIPS System Controller.
+ *
+ * Copyright (C) 2004 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef __ASM_MIPS_BOARDS_MSC01_IC_H
+#define __ASM_MIPS_BOARDS_MSC01_IC_H
+
+/*****************************************************************************
+ * Register offset addresses
+ *****************************************************************************/
+
+#define MSC01_IC_RST_OFS     0x00008    /* Software reset              */
+#define MSC01_IC_ENAL_OFS    0x00100    /* Int_in enable mask 31:0     */
+#define MSC01_IC_ENAH_OFS    0x00108    /* Int_in enable mask 63:32    */
+#define MSC01_IC_DISL_OFS    0x00120    /* Int_in disable mask 31:0    */
+#define MSC01_IC_DISH_OFS    0x00128    /* Int_in disable mask 63:32   */
+#define MSC01_IC_ISBL_OFS    0x00140    /* Raw int_in 31:0             */
+#define MSC01_IC_ISBH_OFS    0x00148    /* Raw int_in 63:32            */
+#define MSC01_IC_ISAL_OFS    0x00160    /* Masked int_in 31:0          */
+#define MSC01_IC_ISAH_OFS    0x00168    /* Masked int_in 63:32         */
+#define MSC01_IC_LVL_OFS     0x00180    /* Disable priority int_out    */
+#define MSC01_IC_RAMW_OFS    0x00180    /* Shadow set RAM (EI)	       */
+#define MSC01_IC_OSB_OFS     0x00188    /* Raw int_out                 */
+#define MSC01_IC_OSA_OFS     0x00190    /* Masked int_out              */
+#define MSC01_IC_GENA_OFS    0x00198    /* Global HW int enable        */
+#define MSC01_IC_BASE_OFS    0x001a0    /* Base address of IC_VEC      */
+#define MSC01_IC_VEC_OFS     0x001b0    /* Active int's vector address */
+#define MSC01_IC_EOI_OFS     0x001c0    /* Enable lower level ints     */
+#define MSC01_IC_CFG_OFS     0x001c8    /* Configuration register      */
+#define MSC01_IC_TRLD_OFS    0x001d0    /* Interval timer reload val   */
+#define MSC01_IC_TVAL_OFS    0x001e0    /* Interval timer current val  */
+#define MSC01_IC_TCFG_OFS    0x001f0    /* Interval timer config       */
+#define MSC01_IC_SUP_OFS     0x00200    /* Set up int_in line 0        */
+#define MSC01_IC_ENA_OFS     0x00800    /* Int_in enable mask 63:0     */
+#define MSC01_IC_DIS_OFS     0x00820    /* Int_in disable mask 63:0    */
+#define MSC01_IC_ISB_OFS     0x00840    /* Raw int_in 63:0             */
+#define MSC01_IC_ISA_OFS     0x00860    /* Masked int_in 63:0          */
+
+/*****************************************************************************
+ * Register field encodings
+ *****************************************************************************/
+
+#define MSC01_IC_RST_RST_SHF      0
+#define MSC01_IC_RST_RST_MSK      0x00000001
+#define MSC01_IC_RST_RST_BIT      MSC01_IC_RST_RST_MSK
+#define MSC01_IC_LVL_LVL_SHF      0
+#define MSC01_IC_LVL_LVL_MSK      0x000000ff
+#define MSC01_IC_LVL_SPUR_SHF     16
+#define MSC01_IC_LVL_SPUR_MSK     0x00010000
+#define MSC01_IC_LVL_SPUR_BIT     MSC01_IC_LVL_SPUR_MSK
+#define MSC01_IC_RAMW_RIPL_SHF	  0
+#define MSC01_IC_RAMW_RIPL_MSK	  0x0000003f
+#define MSC01_IC_RAMW_DATA_SHF	  6
+#define MSC01_IC_RAMW_DATA_MSK	  0x00000fc0
+#define MSC01_IC_RAMW_ADDR_SHF	  25
+#define MSC01_IC_RAMW_ADDR_MSK	  0x7e000000
+#define MSC01_IC_RAMW_READ_SHF	  31
+#define MSC01_IC_RAMW_READ_MSK	  0x80000000
+#define MSC01_IC_RAMW_READ_BIT	  MSC01_IC_RAMW_READ_MSK
+#define MSC01_IC_OSB_OSB_SHF      0
+#define MSC01_IC_OSB_OSB_MSK      0x000000ff
+#define MSC01_IC_OSA_OSA_SHF      0
+#define MSC01_IC_OSA_OSA_MSK      0x000000ff
+#define MSC01_IC_GENA_GENA_SHF    0
+#define MSC01_IC_GENA_GENA_MSK    0x00000001
+#define MSC01_IC_GENA_GENA_BIT    MSC01_IC_GENA_GENA_MSK
+#define MSC01_IC_CFG_DIS_SHF      0
+#define MSC01_IC_CFG_DIS_MSK      0x00000001
+#define MSC01_IC_CFG_DIS_BIT      MSC01_IC_CFG_DIS_MSK
+#define MSC01_IC_CFG_SHFT_SHF     8
+#define MSC01_IC_CFG_SHFT_MSK     0x00000f00
+#define MSC01_IC_TCFG_ENA_SHF     0
+#define MSC01_IC_TCFG_ENA_MSK     0x00000001
+#define MSC01_IC_TCFG_ENA_BIT     MSC01_IC_TCFG_ENA_MSK
+#define MSC01_IC_TCFG_INT_SHF     8
+#define MSC01_IC_TCFG_INT_MSK     0x00000100
+#define MSC01_IC_TCFG_INT_BIT     MSC01_IC_TCFG_INT_MSK
+#define MSC01_IC_TCFG_EDGE_SHF    16
+#define MSC01_IC_TCFG_EDGE_MSK    0x00010000
+#define MSC01_IC_TCFG_EDGE_BIT    MSC01_IC_TCFG_EDGE_MSK
+#define MSC01_IC_SUP_PRI_SHF      0
+#define MSC01_IC_SUP_PRI_MSK      0x00000007
+#define MSC01_IC_SUP_EDGE_SHF     8
+#define MSC01_IC_SUP_EDGE_MSK     0x00000100
+#define MSC01_IC_SUP_EDGE_BIT     MSC01_IC_SUP_EDGE_MSK
+#define MSC01_IC_SUP_STEP         8
+
+/*
+ * MIPS System controller interrupt register base.
+ *
+ * FIXME - are these macros specific to Malta and co or to the MSC?  If the
+ * latter, they should be moved elsewhere.
+ */
+#define MIPS_MSC01_IC_REG_BASE	0x1bc40000
+
+/*****************************************************************************
+ * Absolute register addresses
+ *****************************************************************************/
+
+#define MSC01_IC_RST     (MSC01_IC_REG_BASE + MSC01_IC_RST_OFS)
+#define MSC01_IC_ENAL    (MSC01_IC_REG_BASE + MSC01_IC_ENAL_OFS)
+#define MSC01_IC_ENAH    (MSC01_IC_REG_BASE + MSC01_IC_ENAH_OFS)
+#define MSC01_IC_DISL    (MSC01_IC_REG_BASE + MSC01_IC_DISL_OFS)
+#define MSC01_IC_DISH    (MSC01_IC_REG_BASE + MSC01_IC_DISH_OFS)
+#define MSC01_IC_ISBL    (MSC01_IC_REG_BASE + MSC01_IC_ISBL_OFS)
+#define MSC01_IC_ISBH    (MSC01_IC_REG_BASE + MSC01_IC_ISBH_OFS)
+#define MSC01_IC_ISAL    (MSC01_IC_REG_BASE + MSC01_IC_ISAL_OFS)
+#define MSC01_IC_ISAH    (MSC01_IC_REG_BASE + MSC01_IC_ISAH_OFS)
+#define MSC01_IC_LVL     (MSC01_IC_REG_BASE + MSC01_IC_LVL_OFS)
+#define MSC01_IC_RAMW    (MSC01_IC_REG_BASE + MSC01_IC_RAMW_OFS)
+#define MSC01_IC_OSB     (MSC01_IC_REG_BASE + MSC01_IC_OSB_OFS)
+#define MSC01_IC_OSA     (MSC01_IC_REG_BASE + MSC01_IC_OSA_OFS)
+#define MSC01_IC_GENA    (MSC01_IC_REG_BASE + MSC01_IC_GENA_OFS)
+#define MSC01_IC_BASE    (MSC01_IC_REG_BASE + MSC01_IC_BASE_OFS)
+#define MSC01_IC_VEC     (MSC01_IC_REG_BASE + MSC01_IC_VEC_OFS)
+#define MSC01_IC_EOI     (MSC01_IC_REG_BASE + MSC01_IC_EOI_OFS)
+#define MSC01_IC_CFG     (MSC01_IC_REG_BASE + MSC01_IC_CFG_OFS)
+#define MSC01_IC_TRLD    (MSC01_IC_REG_BASE + MSC01_IC_TRLD_OFS)
+#define MSC01_IC_TVAL    (MSC01_IC_REG_BASE + MSC01_IC_TVAL_OFS)
+#define MSC01_IC_TCFG    (MSC01_IC_REG_BASE + MSC01_IC_TCFG_OFS)
+#define MSC01_IC_SUP     (MSC01_IC_REG_BASE + MSC01_IC_SUP_OFS)
+#define MSC01_IC_ENA     (MSC01_IC_REG_BASE + MSC01_IC_ENA_OFS)
+#define MSC01_IC_DIS     (MSC01_IC_REG_BASE + MSC01_IC_DIS_OFS)
+#define MSC01_IC_ISB     (MSC01_IC_REG_BASE + MSC01_IC_ISB_OFS)
+#define MSC01_IC_ISA     (MSC01_IC_REG_BASE + MSC01_IC_ISA_OFS)
+
+/*
+ * Soc-it interrupts are configurable.
+ * Every board describes its IRQ mapping with this table.
+ */
+typedef struct msc_irqmap {
+	int	im_irq;
+	int	im_type;
+	int	im_lvl;
+} msc_irqmap_t;
+
+/* im_type */
+#define MSC01_IRQ_LEVEL		0
+#define MSC01_IRQ_EDGE		1
+
+extern void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq);
+extern void ll_msc_irq(struct pt_regs *regs);
+
+#endif /* __ASM_MIPS_BOARDS_MSC01_IC_H */
+
diff -Nru a/include/asm-mips/numnodes.h b/include/asm-mips/numnodes.h
--- a/include/asm-mips/numnodes.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-mips/numnodes.h	2004-12-24 13:37:29 -08:00
@@ -2,6 +2,6 @@
 #define _ASM_MAX_NUMNODES_H
 
 /* Max 128 Nodes */
-#define NODES_SHIFT	7
+#define NODES_SHIFT	6
 
 #endif /* _ASM_MAX_NUMNODES_H */
diff -Nru a/include/asm-mips/page.h b/include/asm-mips/page.h
--- a/include/asm-mips/page.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-mips/page.h	2004-12-24 13:36:47 -08:00
@@ -15,6 +15,8 @@
 
 #include <spaces.h>
 
+#endif
+
 /*
  * PAGE_SHIFT determines the page size
  */
@@ -31,8 +33,10 @@
 #define PAGE_SHIFT	16
 #endif
 #define PAGE_SIZE	(1UL << PAGE_SHIFT)
-#define PAGE_MASK	(~(PAGE_SIZE-1))
+#define PAGE_MASK       (~((1 << PAGE_SHIFT) - 1))
+
 
+#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
 extern void clear_page(void * page);
@@ -72,15 +76,22 @@
  * These are used to make use of C type-checking..
  */
 #ifdef CONFIG_64BIT_PHYS_ADDR
-typedef struct { unsigned long long pte; } pte_t;
+  #ifdef CONFIG_CPU_MIPS32
+    typedef struct { unsigned long pte_low, pte_high; } pte_t;
+    #define pte_val(x)    ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
+  #else
+     typedef struct { unsigned long long pte; } pte_t;
+     #define pte_val(x)	((x).pte)
+  #endif
 #else
 typedef struct { unsigned long pte; } pte_t;
+#define pte_val(x)	((x).pte)
 #endif
+
 typedef struct { unsigned long pmd; } pmd_t;
 typedef struct { unsigned long pgd; } pgd_t;
 typedef struct { unsigned long pgprot; } pgprot_t;
 
-#define pte_val(x)	((x).pte)
 #define pmd_val(x)	((x).pmd)
 #define pgd_val(x)	((x).pgd)
 #define pgprot_val(x)	((x).pgprot)
diff -Nru a/include/asm-mips/pci/bridge.h b/include/asm-mips/pci/bridge.h
--- a/include/asm-mips/pci/bridge.h	2004-12-24 13:36:34 -08:00
+++ b/include/asm-mips/pci/bridge.h	2004-12-24 13:36:34 -08:00
@@ -13,7 +13,7 @@
 #define _ASM_PCI_BRIDGE_H
 
 #include <linux/types.h>
-#include <asm/pci_channel.h>
+#include <linux/pci.h>
 #include <asm/xtalk/xwidget.h>		/* generic widget header */
 
 /* I/O page size */
@@ -830,7 +830,6 @@
 
 #define BRIDGE_INTERNAL_ATES	128
 
-
 struct bridge_controller {
 	struct pci_controller	pc;
 	struct resource		mem;
@@ -840,9 +839,13 @@
 	unsigned int		widget_id;
 	unsigned int 		irq_cpu;
 	dma64_addr_t		baddr;
+	unsigned int		pci_int[8];
 };
 
 #define BRIDGE_CONTROLLER(bus) \
 	((struct bridge_controller *)((bus)->sysdata))
+
+extern void register_bridge_irq(unsigned int irq);
+extern int request_bridge_irq(struct bridge_controller *bc);
 
 #endif /* _ASM_PCI_BRIDGE_H */
diff -Nru a/include/asm-mips/pci.h b/include/asm-mips/pci.h
--- a/include/asm-mips/pci.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-mips/pci.h	2004-12-24 13:37:02 -08:00
@@ -11,6 +11,49 @@
 
 #ifdef __KERNEL__
 
+/*
+ * This file essentially defines the interface between board
+ * specific PCI code and MIPS common PCI code.  Should potentially put
+ * into include/asm/pci.h file.
+ */
+
+#include <linux/ioport.h>
+
+/*
+ * Each pci channel is a top-level PCI bus seem by CPU.  A machine  with
+ * multiple PCI channels may have multiple PCI host controllers or a
+ * single controller supporting multiple channels.
+ */
+struct pci_controller {
+	struct pci_controller *next;
+	struct pci_bus *bus;
+
+	struct pci_ops *pci_ops;
+	struct resource *mem_resource;
+	unsigned long mem_offset;
+	struct resource *io_resource;
+	unsigned long io_offset;
+
+	unsigned int index;
+	/* For compatibility with current (as of July 2003) pciutils
+	   and XFree86. Eventually will be removed. */
+	unsigned int need_domain_info;
+
+	int iommu;
+};
+
+/*
+ * Used by boards to register their PCI busses before the actual scanning.
+ */
+extern struct pci_controller * alloc_pci_controller(void);
+extern void register_pci_controller(struct pci_controller *hose);
+
+/*
+ * board supplied pci irq fixup routine
+ */
+extern int pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin);
+
+
 /* Can be used to override the logic in pci_scan_bus for skipping
    already-configured bus numbers - to be used for buggy BIOSes
    or architectures with incomplete PCI setup by the loader */
@@ -90,6 +133,25 @@
 extern void pcibios_resource_to_bus(struct pci_dev *dev,
 	struct pci_bus_region *region, struct resource *res);
 
+#ifdef CONFIG_PCI_DOMAINS
+
+#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
+
+static inline int
+pci_name_bus(char *name, struct pci_bus *bus)
+{
+	struct pci_controller *hose = bus->sysdata;
+
+	if (likely(hose->need_domain_info == 0)) {
+		sprintf(name, "%02x", bus->number);
+	} else {
+		sprintf(name, "%04x:%02x", hose->index, bus->number);
+	}
+	return 0;
+}
+
+#endif /* CONFIG_PCI_DOMAINS */
+
 #endif /* __KERNEL__ */
 
 /* implement the pci_ DMA API in terms of the generic device dma_ one */
@@ -98,5 +160,8 @@
 static inline void pcibios_add_platform_entries(struct pci_dev *dev)
 {
 }
+
+/* Do platform specific device initialization at pci_enable_device() time */
+extern int pcibios_plat_dev_init(struct pci_dev *dev);
 
 #endif /* _ASM_PCI_H */
diff -Nru a/include/asm-mips/pci_channel.h b/include/asm-mips/pci_channel.h
--- a/include/asm-mips/pci_channel.h	2004-12-24 13:37:43 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,46 +0,0 @@
-#ifndef __ASM_PCI_CHANNEL_H
-#define __ASM_PCI_CHANNEL_H
-
-/*
- * This file essentially defines the interface between board
- * specific PCI code and MIPS common PCI code.  Should potentially put
- * into include/asm/pci.h file.
- */
-
-#include <linux/ioport.h>
-#include <linux/pci.h>
-
-/*
- * Each pci channel is a top-level PCI bus seem by CPU.  A machine  with
- * multiple PCI channels may have multiple PCI host controllers or a
- * single controller supporting multiple channels.
- */
-struct pci_controller {
-	struct pci_controller *next;
-	struct pci_bus *bus;
-
-	struct pci_ops *pci_ops;
-	struct resource *mem_resource;
-	unsigned long mem_offset;
-	struct resource *io_resource;
-	unsigned long io_offset;
-
-	/* For compatibility with current (as of July 2003) pciutils
-	   and XFree86. Eventually will be removed. */
-	unsigned int need_domain_info;
-
-	int iommu;
-};
-
-/*
- * Used by boards to register their PCI interfaces before the actual scanning.
- */
-extern struct pci_controller * alloc_pci_controller(void);
-extern void register_pci_controller(struct pci_controller *hose);
-
-/*
- * board supplied pci irq fixup routine
- */
-extern int pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin);
-
-#endif  /* __ASM_PCI_CHANNEL_H */
diff -Nru a/include/asm-mips/pgtable-32.h b/include/asm-mips/pgtable-32.h
--- a/include/asm-mips/pgtable-32.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-mips/pgtable-32.h	2004-12-24 13:36:55 -08:00
@@ -130,8 +130,21 @@
 static inline int pgd_present(pgd_t pgd)	{ return 1; }
 static inline void pgd_clear(pgd_t *pgdp)	{ }
 
+#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
 #define pte_page(x)		pfn_to_page(pte_pfn(x))
+#define pte_pfn(x)		((unsigned long)((x).pte_high >> 6))
+static inline pte_t
+pfn_pte(unsigned long pfn, pgprot_t prot)
+{
+	pte_t pte;
+	pte.pte_high = (pfn << 6) | (pgprot_val(prot) & 0x3f);
+	pte.pte_low = pgprot_val(prot);
+	return pte;
+}
 
+#else
+
+#define pte_page(x)		pfn_to_page(pte_pfn(x))
 
 #ifdef CONFIG_CPU_VR41XX
 #define pte_pfn(x)		((unsigned long)((x).pte >> (PAGE_SHIFT + 2)))
@@ -140,6 +153,7 @@
 #define pte_pfn(x)		((unsigned long)((x).pte >> PAGE_SHIFT))
 #define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 #endif
+#endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */
 
 #define __pgd_offset(address)	pgd_index(address)
 #define __pmd_offset(address)	(((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
@@ -207,11 +221,19 @@
  */
 #define PTE_FILE_MAX_BITS	27
 
+#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
+	/* fixme */
+#define pte_to_pgoff(_pte) (((_pte).pte_high >> 6) + ((_pte).pte_high & 0x3f))
+#define pgoff_to_pte(off) \
+ 	((pte_t){(((off) & 0x3f) + ((off) << 6) + _PAGE_FILE)})
+
+#else
 #define pte_to_pgoff(_pte) \
 	((((_pte).pte >> 3) & 0x1f ) + (((_pte).pte >> 9) << 6 ))
 
 #define pgoff_to_pte(off) \
 	((pte_t) { (((off) & 0x1f) << 3) + (((off) >> 6) << 9) + _PAGE_FILE })
+#endif
 
 #endif
 
diff -Nru a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h
--- a/include/asm-mips/pgtable-64.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-mips/pgtable-64.h	2004-12-24 13:36:18 -08:00
@@ -29,11 +29,10 @@
  * that the failure is recognized later on. Linux does not seem to
  * handle these failures very well though. The empty_bad_page_table has
  * invalid pte entries in it, to force page faults.
- * Vmalloc handling: vmalloc uses swapper_pg_dir[0] (returned by
- * pgd_offset_k), which is initalized to point to kpmdtbl. kpmdtbl is
- * the only single page pmd in the system. kpmdtbl entries point into
- * kptbl[] array. We reserve 1 << PGD_ORDER pages to hold the
- * vmalloc range translations, which the fault handler looks at.
+ *
+ * Kernel mappings: kernel mappings are held in the swapper_pg_table.
+ * The layout is identical to userspace except it's indexed with the
+ * fault address - VMALLOC_START.
  */
 
 /* PMD_SHIFT determines the size of the area a second-level page table can map */
@@ -66,7 +65,7 @@
  */
 #ifdef CONFIG_PAGE_SIZE_4KB
 #define PGD_ORDER		1
-#define PMD_ORDER		1
+#define PMD_ORDER		0
 #define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_8KB
@@ -94,7 +93,7 @@
 
 #define VMALLOC_START		XKSEG
 #define VMALLOC_END	\
-	(VMALLOC_START + ((1 << PGD_ORDER) * PTRS_PER_PTE * PAGE_SIZE))
+	(VMALLOC_START + PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE)
 
 #define pte_ERROR(e) \
 	printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
@@ -224,11 +223,5 @@
 
 #define pgoff_to_pte(off) \
 	((pte_t) { (((off) & 0x1f) << 3) + (((off) >> 6) << 9) + _PAGE_FILE })
-
-/*
- * Used for the b0rked handling of kernel pagetables on the 64-bit kernel.
- */
-extern pte_t kptbl[(PAGE_SIZE << PGD_ORDER)/sizeof(pte_t)];
-extern pmd_t kpmdtbl[PTRS_PER_PMD];
 
 #endif /* _ASM_PGTABLE_64_H */
diff -Nru a/include/asm-mips/pgtable-bits.h b/include/asm-mips/pgtable-bits.h
--- a/include/asm-mips/pgtable-bits.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-mips/pgtable-bits.h	2004-12-24 13:36:18 -08:00
@@ -33,6 +33,32 @@
  * unpredictable things.  The code (when it is written) to deal with
  * this problem will be in the update_mmu_cache() code for the r4k.
  */
+#if defined(CONFIG_CPU_MIPS32) && defined(CONFIG_64BIT_PHYS_ADDR)
+
+#define _PAGE_PRESENT               (1<<6)  /* implemented in software */
+#define _PAGE_READ                  (1<<7)  /* implemented in software */
+#define _PAGE_WRITE                 (1<<8)  /* implemented in software */
+#define _PAGE_ACCESSED              (1<<9)  /* implemented in software */
+#define _PAGE_MODIFIED              (1<<10) /* implemented in software */
+#define _PAGE_FILE                  (1<<10)  /* set:pagecache unset:swap */
+
+#define _PAGE_R4KBUG                (1<<0)  /* workaround for r4k bug  */
+#define _PAGE_GLOBAL                (1<<0)
+#define _PAGE_VALID                 (1<<1)
+#define _PAGE_SILENT_READ           (1<<1)  /* synonym                 */
+#define _PAGE_DIRTY                 (1<<2)  /* The MIPS dirty bit      */
+#define _PAGE_SILENT_WRITE          (1<<2)
+#define _CACHE_MASK                 (7<<3)
+
+/* MIPS32 defines only values 2 and 3. The rest are implementation
+ * dependent.
+ */
+#define _CACHE_UNCACHED             (2<<3)
+#define _CACHE_CACHABLE_NONCOHERENT (3<<3)
+#define _CACHE_CACHABLE_COW         (3<<3)  /* Au1x                    */
+
+#else
+
 #define _PAGE_PRESENT               (1<<0)  /* implemented in software */
 #define _PAGE_READ                  (1<<1)  /* implemented in software */
 #define _PAGE_WRITE                 (1<<2)  /* implemented in software */
@@ -97,6 +123,7 @@
 
 #endif
 #endif
+#endif /* defined(CONFIG_CPU_MIPS32) && defined(CONFIG_64BIT_PHYS_ADDR) */
 
 #define __READABLE	(_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)
 #define __WRITEABLE	(_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
@@ -108,11 +135,15 @@
 #elif defined(CONFIG_DMA_NONCOHERENT)
 #define PAGE_CACHABLE_DEFAULT	_CACHE_CACHABLE_NONCOHERENT
 #elif defined(CONFIG_CPU_RM9000)
-#define PAGE_CACHABLE_DEFAULT	_CACHE_CWBEA
+#define PAGE_CACHABLE_DEFAULT	_CACHE_CWB
 #else
 #define PAGE_CACHABLE_DEFAULT	_CACHE_CACHABLE_COW
 #endif
 
+#if defined(CONFIG_CPU_MIPS32) && defined(CONFIG_64BIT_PHYS_ADDR)
+#define CONF_CM_DEFAULT		(PAGE_CACHABLE_DEFAULT >> 3)
+#else
 #define CONF_CM_DEFAULT		(PAGE_CACHABLE_DEFAULT >> 9)
+#endif
 
 #endif /* _ASM_PGTABLE_BITS_H */
diff -Nru a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
--- a/include/asm-mips/pgtable.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-mips/pgtable.h	2004-12-24 13:36:31 -08:00
@@ -80,6 +80,34 @@
 #define pte_none(pte)		(!(pte_val(pte) & ~_PAGE_GLOBAL))
 #define pte_present(pte)	(pte_val(pte) & _PAGE_PRESENT)
 
+#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
+static inline void set_pte(pte_t *ptep, pte_t pte)
+{
+	ptep->pte_high = pte.pte_high;
+	smp_wmb();
+	ptep->pte_low = pte.pte_low;
+	//printk("pte_high %x pte_low %x\n", ptep->pte_high, ptep->pte_low);
+
+	if (pte_val(pte) & _PAGE_GLOBAL) {
+		pte_t *buddy = ptep_buddy(ptep);
+		/*
+		 * Make sure the buddy is global too (if it's !none,
+		 * it better already be global)
+		 */
+		if (pte_none(*buddy))
+			buddy->pte_low |= _PAGE_GLOBAL;
+	}
+}
+
+static inline void pte_clear(pte_t *ptep)
+{
+	/* Preserve global status for the pair */
+	if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL)
+		set_pte(ptep, __pte(_PAGE_GLOBAL));
+	else
+		set_pte(ptep, __pte(0));
+}
+#else
 /*
  * Certain architectures need to do special things when pte's
  * within a page table are directly modified.  Thus, the following
@@ -111,6 +139,7 @@
 #endif
 		set_pte(ptep, __pte(0));
 }
+#endif
 
 /*
  * (pmds are folded into pgds so this doesn't get actually called,
@@ -130,6 +159,79 @@
  * Undefined behaviour if not..
  */
 static inline int pte_user(pte_t pte)	{ BUG(); return 0; }
+#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
+static inline int pte_read(pte_t pte)	{ return (pte).pte_low & _PAGE_READ; }
+static inline int pte_write(pte_t pte)	{ return (pte).pte_low & _PAGE_WRITE; }
+static inline int pte_dirty(pte_t pte)	{ return (pte).pte_low & _PAGE_MODIFIED; }
+static inline int pte_young(pte_t pte)	{ return (pte).pte_low & _PAGE_ACCESSED; }
+static inline int pte_file(pte_t pte)	{ return (pte).pte_low & _PAGE_FILE; }
+static inline pte_t pte_wrprotect(pte_t pte)
+{
+	(pte).pte_low &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
+	(pte).pte_high &= ~_PAGE_SILENT_WRITE;
+	return pte;
+}
+
+static inline pte_t pte_rdprotect(pte_t pte)
+{
+	(pte).pte_low &= ~(_PAGE_READ | _PAGE_SILENT_READ);
+	(pte).pte_high &= ~_PAGE_SILENT_READ;
+	return pte;
+}
+
+static inline pte_t pte_mkclean(pte_t pte)
+{
+	(pte).pte_low &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE);
+	(pte).pte_high &= ~_PAGE_SILENT_WRITE;
+	return pte;
+}
+
+static inline pte_t pte_mkold(pte_t pte)
+{
+	(pte).pte_low &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ);
+	(pte).pte_high &= ~_PAGE_SILENT_READ;
+	return pte;
+}
+
+static inline pte_t pte_mkwrite(pte_t pte)
+{
+	(pte).pte_low |= _PAGE_WRITE;
+	if ((pte).pte_low & _PAGE_MODIFIED) {
+		(pte).pte_low |= _PAGE_SILENT_WRITE;
+		(pte).pte_high |= _PAGE_SILENT_WRITE;
+	}
+	return pte;
+}
+
+static inline pte_t pte_mkread(pte_t pte)
+{
+	(pte).pte_low |= _PAGE_READ;
+	if ((pte).pte_low & _PAGE_ACCESSED) {
+		(pte).pte_low |= _PAGE_SILENT_READ;
+		(pte).pte_high |= _PAGE_SILENT_READ;
+	}
+	return pte;
+}
+
+static inline pte_t pte_mkdirty(pte_t pte)
+{
+	(pte).pte_low |= _PAGE_MODIFIED;
+	if ((pte).pte_low & _PAGE_WRITE) {
+		(pte).pte_low |= _PAGE_SILENT_WRITE;
+		(pte).pte_high |= _PAGE_SILENT_WRITE;
+	}
+	return pte;
+}
+
+static inline pte_t pte_mkyoung(pte_t pte)
+{
+	(pte).pte_low |= _PAGE_ACCESSED;
+	if ((pte).pte_low & _PAGE_READ)
+		(pte).pte_low |= _PAGE_SILENT_READ;
+		(pte).pte_high |= _PAGE_SILENT_READ;
+	return pte;
+}
+#else
 static inline int pte_read(pte_t pte)	{ return pte_val(pte) & _PAGE_READ; }
 static inline int pte_write(pte_t pte)	{ return pte_val(pte) & _PAGE_WRITE; }
 static inline int pte_dirty(pte_t pte)	{ return pte_val(pte) & _PAGE_MODIFIED; }
@@ -191,6 +293,7 @@
 		pte_val(pte) |= _PAGE_SILENT_READ;
 	return pte;
 }
+#endif
 
 /*
  * Macro to make mark a page protection value as "uncacheable".  Note
@@ -215,10 +318,20 @@
  */
 #define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
 
+#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
+	pte.pte_low &= _PAGE_CHG_MASK;
+	pte.pte_low |= pgprot_val(newprot);
+	pte.pte_high |= pgprot_val(newprot) & 0x3f;
+	return pte;
+}
+#else
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
 }
+#endif
 
 
 extern void __update_tlb(struct vm_area_struct *vma, unsigned long address,
@@ -237,6 +350,24 @@
 #define kern_addr_valid(addr)	(1)
 #endif
 
+#ifdef CONFIG_64BIT_PHYS_ADDR
+extern phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size);
+extern int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot);
+
+static inline int io_remap_page_range(struct vm_area_struct *vma,
+		unsigned long vaddr,
+		unsigned long paddr,
+		unsigned long size,
+		pgprot_t prot)
+{
+	phys_t phys_addr_high = fixup_bigphys_addr(paddr, size);
+	return remap_pfn_range(vma, vaddr, phys_addr_high >> PAGE_SHIFT, size, prot);
+}
+#else
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+	remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
+#endif
+
 #include <asm-generic/pgtable.h>
 
 /*
@@ -244,8 +375,6 @@
  * constraints placed on us by the cache architecture.
  */
 #define HAVE_ARCH_UNMAPPED_AREA
-
-#define io_remap_page_range remap_page_range
 
 /*
  * No page table caches to initialise
diff -Nru a/include/asm-mips/posix_types.h b/include/asm-mips/posix_types.h
--- a/include/asm-mips/posix_types.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-mips/posix_types.h	2004-12-24 13:37:00 -08:00
@@ -28,8 +28,8 @@
 typedef long		__kernel_off_t;
 typedef int		__kernel_pid_t;
 typedef int		__kernel_ipc_pid_t;
-typedef int		__kernel_uid_t;
-typedef int		__kernel_gid_t;
+typedef unsigned int	__kernel_uid_t;
+typedef unsigned int	__kernel_gid_t;
 #if (_MIPS_SZLONG == 32)
 typedef unsigned int	__kernel_size_t;
 typedef int		__kernel_ssize_t;
@@ -50,8 +50,8 @@
 
 typedef unsigned short	__kernel_uid16_t;
 typedef unsigned short	__kernel_gid16_t;
-typedef int		__kernel_uid32_t;
-typedef int		__kernel_gid32_t;
+typedef unsigned int	__kernel_uid32_t;
+typedef unsigned int	__kernel_gid32_t;
 typedef __kernel_uid_t	__kernel_old_uid_t;
 typedef __kernel_gid_t	__kernel_old_gid_t;
 typedef unsigned int	__kernel_old_dev_t;
diff -Nru a/include/asm-mips/processor.h b/include/asm-mips/processor.h
--- a/include/asm-mips/processor.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/processor.h	2004-12-24 13:36:17 -08:00
@@ -12,79 +12,15 @@
 #define _ASM_PROCESSOR_H
 
 #include <linux/config.h>
-#include <linux/cache.h>
 #include <linux/threads.h>
 
 #include <asm/cachectl.h>
 #include <asm/cpu.h>
+#include <asm/cpu-info.h>
 #include <asm/mipsregs.h>
 #include <asm/prefetch.h>
 #include <asm/system.h>
 
-#ifdef CONFIG_SGI_IP27
-#include <asm/sn/types.h>
-#endif
-
-/*
- * Descriptor for a cache
- */
-struct cache_desc {
-	unsigned short linesz;	/* Size of line in bytes */
-	unsigned short ways;	/* Number of ways */
-	unsigned short sets;	/* Number of lines per set */
-	unsigned int waysize;	/* Bytes per way */
-	unsigned int waybit;	/* Bits to select in a cache set */
-	unsigned int flags;	/* Flags describing cache properties */
-};
-
-/*
- * Flag definitions
- */
-#define MIPS_CACHE_NOT_PRESENT	0x00000001
-#define MIPS_CACHE_VTAG		0x00000002	/* Virtually tagged cache */
-#define MIPS_CACHE_ALIASES	0x00000004	/* Cache could have aliases */
-#define MIPS_CACHE_IC_F_DC	0x00000008	/* Ic can refill from D-cache */
-
-struct cpuinfo_mips {
-	unsigned long		udelay_val;
-	unsigned long		asid_cache;
-#if defined(CONFIG_SGI_IP27)
-//	cpuid_t		p_cpuid;	/* PROM assigned cpuid */
-	cnodeid_t	p_nodeid;	/* my node ID in compact-id-space */
-	nasid_t		p_nasid;	/* my node ID in numa-as-id-space */
-	unsigned char	p_slice;	/* Physical position on node board */
-#endif
-#if 0
-	unsigned long		loops_per_sec;
-	unsigned long		ipi_count;
-	unsigned long		irq_attempt[NR_IRQS];
-	unsigned long		smp_local_irq_count;
-	unsigned long		prof_multiplier;
-	unsigned long		prof_counter;
-#endif
-
-	/*
-	 * Capability and feature descriptor structure for MIPS CPU
-	 */
-	unsigned long		options;
-	unsigned int		processor_id;
-	unsigned int		fpu_id;
-	unsigned int		cputype;
-	int			isa_level;
-	int			tlbsize;
-	struct cache_desc	icache;	/* Primary I-cache */
-	struct cache_desc	dcache;	/* Primary D or combined I/D cache */
-	struct cache_desc	scache;	/* Secondary cache */
-	struct cache_desc	tcache;	/* Tertiary/split secondary cache */
-	void 			*data;	/* Additional data */
-} __attribute__((aligned(SMP_CACHE_BYTES)));
-
-extern struct cpuinfo_mips cpu_data[];
-#define current_cpu_data cpu_data[smp_processor_id()]
-
-extern void cpu_probe(void);
-extern void cpu_report(void);
-
 /*
  * Return current * instruction pointer ("program counter").
  */
@@ -143,7 +79,7 @@
 
 #define NUM_FPU_REGS	32
 
-typedef u64 fpureg_t;
+typedef __u64 fpureg_t;
 
 struct mips_fpu_hard_struct {
 	fpureg_t	fpr[NUM_FPU_REGS];
@@ -235,8 +171,6 @@
 	MF_FIXADE, 0, 0 \
 }
 
-#ifdef __KERNEL__
-
 struct task_struct;
 
 /* Free all resources held by a thread. */
@@ -263,8 +197,6 @@
 #define KSTK_STATUS(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(cp0_status)))
 
 #define cpu_relax()	barrier()
-
-#endif /* __KERNEL__ */
 
 /*
  * Return_address is a replacement for __builtin_return_address(count)
diff -Nru a/include/asm-mips/ptrace.h b/include/asm-mips/ptrace.h
--- a/include/asm-mips/ptrace.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-mips/ptrace.h	2004-12-24 13:37:00 -08:00
@@ -60,6 +60,8 @@
 
 #ifdef __KERNEL__
 
+#include <linux/linkage.h>
+
 /*
  * Does the process account for user or for system time?
  */
diff -Nru a/include/asm-mips/r4kcache.h b/include/asm-mips/r4kcache.h
--- a/include/asm-mips/r4kcache.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/r4kcache.h	2004-12-24 13:36:17 -08:00
@@ -26,7 +26,7 @@
  *  - We need a properly sign extended address for 64-bit code.  To get away
  *    without ifdefs we let the compiler do it by a type cast.
  */
-#define INDEX_BASE	((int) KSEG0)
+#define INDEX_BASE	CKSEG0
 
 #define cache_op(op,addr)						\
 	__asm__ __volatile__(						\
diff -Nru a/include/asm-mips/serial.h b/include/asm-mips/serial.h
--- a/include/asm-mips/serial.h	2004-12-24 13:37:33 -08:00
+++ b/include/asm-mips/serial.h	2004-12-24 13:37:33 -08:00
@@ -55,7 +55,7 @@
 
 #define C_P(card,port) (((card)<<6|(port)<<3) + 1)
 
-#ifdef CONFIG_MIPS_JAZZ
+#ifdef CONFIG_MACH_JAZZ
 #include <asm/jazz.h>
 
 #ifndef CONFIG_OLIVETTI_M700
@@ -152,15 +152,82 @@
 
 #ifdef CONFIG_SERIAL_AU1X00
 #include <asm/mach-au1x00/au1000.h>
-#define AU1000_SERIAL_PORT_DEFNS                              \
-    { .baud_base = 0, .port = UART0_ADDR, .irq = AU1000_UART0_INT,  \
-      .flags = STD_COM_FLAGS, .type = 1 },                        \
-    { .baud_base = 0, .port = UART1_ADDR, .irq = AU1000_UART1_INT,  \
-      .flags = STD_COM_FLAGS, .type = 1 },     \
-    { .baud_base = 0, .port = UART2_ADDR, .irq = AU1000_UART2_INT,  \
-      .flags = STD_COM_FLAGS, .type = 1 },    \
-    { .baud_base = 0, .port = UART3_ADDR, .irq = AU1000_UART3_INT,  \
-      .flags = STD_COM_FLAGS, .type = 1 },
+#ifdef CONFIG_SOC_AU1000
+#define AU1000_SERIAL_PORT_DEFNS                       \
+    { .baud_base = 0, .port = UART0_ADDR,              \
+      .iomem_base = (unsigned char *)UART0_ADDR,       \
+      .irq = AU1000_UART0_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART1_ADDR,              \
+      .iomem_base = (unsigned char *)UART1_ADDR,       \
+      .irq = AU1000_UART1_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART2_ADDR,              \
+      .iomem_base = (unsigned char *)UART2_ADDR,       \
+      .irq = AU1000_UART2_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART3_ADDR,              \
+      .iomem_base = (unsigned char *)UART3_ADDR,       \
+      .irq = AU1000_UART3_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },
+#endif
+
+#ifdef CONFIG_SOC_AU1500
+#define AU1000_SERIAL_PORT_DEFNS                       \
+    { .baud_base = 0, .port = UART0_ADDR,              \
+      .iomem_base = (unsigned char *)UART0_ADDR,       \
+      .irq = AU1500_UART0_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART3_ADDR,              \
+      .iomem_base = (unsigned char *)UART3_ADDR,       \
+      .irq = AU1500_UART3_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },
+#endif
+
+#ifdef CONFIG_SOC_AU1100
+#define AU1000_SERIAL_PORT_DEFNS                       \
+    { .baud_base = 0, .port = UART0_ADDR,              \
+      .iomem_base = (unsigned char *)UART0_ADDR,       \
+      .irq = AU1100_UART0_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART1_ADDR,              \
+      .iomem_base = (unsigned char *)UART1_ADDR,       \
+      .irq = AU1100_UART1_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART3_ADDR,              \
+      .iomem_base = (unsigned char *)UART3_ADDR,       \
+      .irq = AU1100_UART3_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },
+#endif
+
+#ifdef CONFIG_SOC_AU1550
+#define AU1000_SERIAL_PORT_DEFNS                       \
+    { .baud_base = 0, .port = UART0_ADDR,              \
+      .iomem_base = (unsigned char *)UART0_ADDR,       \
+      .irq = AU1550_UART0_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART1_ADDR,              \
+      .iomem_base = (unsigned char *)UART1_ADDR,       \
+      .irq = AU1550_UART1_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART3_ADDR,              \
+      .iomem_base = (unsigned char *)UART3_ADDR,       \
+      .irq = AU1550_UART3_INT,  .flags = STD_COM_FLAGS,\
+      .iomem_reg_shift = 2 },
+#endif
+
+#ifdef CONFIG_SOC_AU1200
+#define AU1000_SERIAL_PORT_DEFNS                       \
+    { .baud_base = 0, .port = UART0_ADDR,              \
+      .iomem_base = (unsigned char *)UART0_ADDR,       \
+      .irq = AU1200_UART0_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },                          \
+    { .baud_base = 0, .port = UART1_ADDR,              \
+      .iomem_base = (unsigned char *)UART1_ADDR,       \
+      .irq = AU1200_UART1_INT, .flags = STD_COM_FLAGS, \
+      .iomem_reg_shift = 2 },
+#endif
+
 #else
 #define AU1000_SERIAL_PORT_DEFNS
 #endif
@@ -252,6 +319,23 @@
 #define MOMENCO_JAGUAR_ATX_SERIAL_PORT_DEFNS
 #endif
 
+#ifdef CONFIG_MOMENCO_OCELOT_3
+#define OCELOT_3_BASE_BAUD	( 20000000 / 16 )
+#define OCELOT_3_SERIAL_IRQ	6
+#define OCELOT_3_SERIAL_BASE	(signed)0xfd000020
+
+#define _OCELOT_3_SERIAL_INIT(int, base)				\
+	{ baud_base: OCELOT_3_BASE_BAUD, irq: int, 			\
+	  flags: STD_COM_FLAGS,						\
+	  iomem_base: (u8 *) base, iomem_reg_shift: 2,			\
+	  io_type: SERIAL_IO_MEM }
+
+#define MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS				\
+	_OCELOT_3_SERIAL_INIT(OCELOT_3_SERIAL_IRQ, OCELOT_3_SERIAL_BASE)
+#else
+#define MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS
+#endif
+
 #ifdef CONFIG_MOMENCO_OCELOT
 /* Ordinary NS16552 duart with a 20MHz crystal.  */
 #define OCELOT_BASE_BAUD ( 20000000 / 16 )
@@ -353,6 +437,7 @@
 	MOMENCO_OCELOT_G_SERIAL_PORT_DEFNS		\
 	MOMENCO_OCELOT_C_SERIAL_PORT_DEFNS		\
 	MOMENCO_OCELOT_SERIAL_PORT_DEFNS		\
+	MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS		\
 	TXX927_SERIAL_PORT_DEFNS                        \
 	AU1000_SERIAL_PORT_DEFNS
 
diff -Nru a/include/asm-mips/sgi/ioc.h b/include/asm-mips/sgi/ioc.h
--- a/include/asm-mips/sgi/ioc.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-mips/sgi/ioc.h	2004-12-24 13:36:48 -08:00
@@ -120,7 +120,7 @@
 struct sgioc_regs {
 	struct pi1_regs pport;
 	u32 _unused0[2];
-	struct sgioc_uart_regs serport;
+	struct sgioc_uart_regs uart;
 	struct sgioc_keyb_regs kbdmouse;
 	u8 _gcsel[3];
 	volatile u8 gcsel;
diff -Nru a/include/asm-mips/sgiarcs.h b/include/asm-mips/sgiarcs.h
--- a/include/asm-mips/sgiarcs.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-mips/sgiarcs.h	2004-12-24 13:36:47 -08:00
@@ -371,7 +371,7 @@
 
 #define __arc_clobbers							\
 	"$2","$3" /* ... */, "$8","$9","$10","$11",			\
-	"$12","$13","$14","$15","$16","$24","25","$31"
+	"$12","$13","$14","$15","$16","$24","$25","$31"
 
 #define ARC_CALL0(dest)							\
 ({	long __res;							\
@@ -464,7 +464,7 @@
 	long __vec = (long) romvec->dest;				\
 	__asm__ __volatile__(						\
 	"dsubu\t$29, 32\n\t"						\
-	"sw\t%6, 16($29)\n\t"						\
+	"sw\t%7, 16($29)\n\t"						\
 	"jalr\t%1\n\t"							\
 	"daddu\t$29, 32\n\t"						\
 	"move\t%0, $2"							\
diff -Nru a/include/asm-mips/siginfo.h b/include/asm-mips/siginfo.h
--- a/include/asm-mips/siginfo.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-mips/siginfo.h	2004-12-24 13:36:55 -08:00
@@ -13,7 +13,7 @@
 
 #define SIGEV_HEAD_SIZE	(sizeof(long) + 2*sizeof(int))
 #define SIGEV_PAD_SIZE	((SIGEV_MAX_SIZE-SIGEV_HEAD_SIZE) / sizeof(int))
-#define SI_PAD_SIZE	((SI_MAX_SIZE/sizeof(int)) - 4)
+#undef __ARCH_SI_TRAPNO	/* exception code needs to fill this ...  */
 
 #define HAVE_ARCH_SIGINFO_T
 
@@ -24,15 +24,23 @@
 #define HAVE_ARCH_COPY_SIGINFO
 struct siginfo;
 
-#include <asm-generic/siginfo.h>
+/*
+ * Careful to keep union _sifields from shifting ...
+ */
+#ifdef CONFIG_MIPS32
+#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
+#endif
+#ifdef CONFIG_MIPS64
+#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
+#endif
 
-/* This structure matches the 32/n32 ABIs for source compatibility but
-   has Linux extensions.  */
+#include <asm-generic/siginfo.h>
 
 typedef struct siginfo {
 	int si_signo;
 	int si_code;
 	int si_errno;
+	int __pad0[SI_MAX_SIZE / sizeof(int) - SI_PAD_SIZE - 3];
 
 	union {
 		int _pad[SI_PAD_SIZE];
@@ -40,131 +48,57 @@
 		/* kill() */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			uid_t _uid;		/* sender's uid */
+			__ARCH_SI_UID_T _uid;	/* sender's uid */
 		} _kill;
 
-		/* SIGCHLD */
-		struct {
-			pid_t _pid;		/* which child */
-			uid_t _uid;		/* sender's uid */
-			int _status;		/* exit code */
-			clock_t _utime;
-			clock_t _stime;
-		} _sigchld;
-
-		/* IRIX SIGCHLD */
-		struct {
-			pid_t _pid;		/* which child */
-			clock_t _utime;
-			int _status;		/* exit code */
-			clock_t _stime;
-		} _irix_sigchld;
-
-		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
-		struct {
-			void *_addr; /* faulting insn/memory ref. */
-		} _sigfault;
-
-		/* SIGPOLL, SIGXFSZ (To do ...)  */
-		struct {
-#ifdef CONFIG_MIPS32
-			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
-#endif
-#ifdef CONFIG_MIPS64
-			long _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
-#endif
-			int _fd;
-		} _sigpoll;
-
 		/* POSIX.1b timers */
 		struct {
 			timer_t _tid;		/* timer id */
 			int _overrun;		/* overrun count */
 			char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
 			sigval_t _sigval;	/* same as below */
-			int _sys_private;	/* not to be passed to user */
+			int _sys_private;       /* not to be passed to user */
 		} _timer;
 
 		/* POSIX.1b signals */
 		struct {
 			pid_t _pid;		/* sender's pid */
-			uid_t _uid;		/* sender's uid */
+			__ARCH_SI_UID_T _uid;	/* sender's uid */
 			sigval_t _sigval;
 		} _rt;
 
-	} _sifields;
-} siginfo_t;
-
-#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
-
-#include <linux/compat.h>
-
-#define SI_PAD_SIZE32   ((SI_MAX_SIZE/sizeof(int)) - 3)
-
-typedef union sigval32 {
-	int sival_int;
-	s32 sival_ptr;
-} sigval_t32;
-
-typedef struct siginfo32 {
-	int si_signo;
-	int si_code;
-	int si_errno;
-
-	union {
-		int _pad[SI_PAD_SIZE32];
-
-		/* kill() */
-		struct {
-			compat_pid_t _pid;	/* sender's pid */
-			compat_uid_t _uid;	/* sender's uid */
-		} _kill;
-
 		/* SIGCHLD */
 		struct {
-			compat_pid_t _pid;	/* which child */
-			compat_uid_t _uid;	/* sender's uid */
-			compat_clock_t _utime;
+			pid_t _pid;		/* which child */
+			__ARCH_SI_UID_T _uid;	/* sender's uid */
 			int _status;		/* exit code */
-			compat_clock_t _stime;
+			clock_t _utime;
+			clock_t _stime;
 		} _sigchld;
 
 		/* IRIX SIGCHLD */
 		struct {
-			compat_pid_t _pid;	/* which child */
-			compat_clock_t _utime;
+			pid_t _pid;		/* which child */
+			clock_t _utime;
 			int _status;		/* exit code */
-			compat_clock_t _stime;
+			clock_t _stime;
 		} _irix_sigchld;
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
 		struct {
-			s32 _addr; /* faulting insn/memory ref. */
+			void __user *_addr; /* faulting insn/memory ref. */
+#ifdef __ARCH_SI_TRAPNO
+			int _trapno;	/* TRAP # which caused the signal */
+#endif
 		} _sigfault;
 
 		/* SIGPOLL, SIGXFSZ (To do ...)  */
 		struct {
-			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
+			__ARCH_SI_BAND_T _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
 			int _fd;
 		} _sigpoll;
-
-		/* POSIX.1b timers */
-		struct {
-			unsigned int _timer1;
-			unsigned int _timer2;
-		} _timer;
-
-		/* POSIX.1b signals */
-		struct {
-			compat_pid_t _pid;	/* sender's pid */
-			compat_uid_t _uid;	/* sender's uid */
-			sigval_t32 _sigval;
-		} _rt;
-
 	} _sifields;
-} siginfo_t32;
-
-#endif /* defined(__KERNEL__) && defined(CONFIG_COMPAT) */
+} siginfo_t;
 
 /*
  * si_code values
diff -Nru a/include/asm-mips/sim.h b/include/asm-mips/sim.h
--- a/include/asm-mips/sim.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-mips/sim.h	2004-12-24 13:37:02 -08:00
@@ -13,9 +13,6 @@
 
 #include <asm/offset.h>
 
-/* Used in declaration of save_static functions.  */
-#define static_unused static __attribute__((unused))
-
 #define __str2(x) #x
 #define __str(x) __str2(x)
 
@@ -39,6 +36,7 @@
 	"sw\t$22,"__str(PT_R22)"($29)\n\t"				\
 	"sw\t$23,"__str(PT_R23)"($29)\n\t"				\
 	"sw\t$30,"__str(PT_R30)"($29)\n\t"				\
+	"j\t_" #symbol "\n\t"						\
 	".end\t" #symbol "\n\t"						\
 	".size\t" #symbol",. - " #symbol)
 
@@ -66,6 +64,7 @@
 	"sd\t$22,"__str(PT_R22)"($29)\n\t"				\
 	"sd\t$23,"__str(PT_R23)"($29)\n\t"				\
 	"sd\t$30,"__str(PT_R30)"($29)\n\t"				\
+	"j\t_" #symbol "\n\t"						\
 	".end\t" #symbol "\n\t"						\
 	".size\t" #symbol",. - " #symbol)
 
diff -Nru a/include/asm-mips/smp.h b/include/asm-mips/smp.h
--- a/include/asm-mips/smp.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-mips/smp.h	2004-12-24 13:36:19 -08:00
@@ -68,11 +68,6 @@
 extern void core_send_ipi(int cpu, unsigned int action);
 
 /*
- * Detect available CPUs, populate phys_cpu_present_map
- */
-extern void prom_build_cpu_map(void);
-
-/*
  * Firmware CPU startup hook
  */
 extern void prom_boot_secondary(int cpu, struct task_struct *idle);
@@ -84,7 +79,7 @@
 extern void prom_init_secondary(void);
 
 /*
- * Callout to firmware before smp_init
+ * Detect available CPUs, populate phys_cpu_present_map before smp_init
  */
 extern void prom_prepare_cpus(unsigned int max_cpus);
 
diff -Nru a/include/asm-mips/sn/hub.h b/include/asm-mips/sn/hub.h
--- a/include/asm-mips/sn/hub.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-mips/sn/hub.h	2004-12-24 13:37:18 -08:00
@@ -8,25 +8,6 @@
 #include <asm/sn/klkernvars.h>
 #include <asm/xtalk/xtalk.h>
 
-#define LEVELS_PER_SLICE	128
-
-struct slice_data {
-	unsigned long irq_alloc_mask[2];
-	unsigned long irq_enable_mask[2];
-	int level_to_irq[LEVELS_PER_SLICE];
-};
-
-struct hub_data {
-	kern_vars_t	kern_vars;
-	DECLARE_BITMAP  (h_bigwin_used, HUB_NUM_BIG_WINDOW);
-	cpumask_t	h_cpus;
-	unsigned long slice_map;
-	struct slice_data slice[2];
-};
-
-extern struct hub_data *hub_data[];
-#define HUB_DATA(n)		(hub_data[(n)])
-
 /* ip27-hubio.c */
 extern unsigned long hub_pio_map(cnodeid_t cnode, xwidgetnum_t widget,
 			  unsigned long xtalk_addr, size_t size);
diff -Nru a/include/asm-mips/sn/mapped_kernel.h b/include/asm-mips/sn/mapped_kernel.h
--- a/include/asm-mips/sn/mapped_kernel.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-mips/sn/mapped_kernel.h	2004-12-24 13:36:48 -08:00
@@ -39,13 +39,11 @@
 #define MAPPED_KERN_RW_TO_PHYS(x) \
 				((unsigned long)MAPPED_ADDR_RW_TO_PHYS(x) | \
 				MAPPED_KERN_RW_PHYSBASE(get_compact_nodeid()))
-#define MAPPED_OFFSET			16777216
 
 #else /* CONFIG_MAPPED_KERNEL */
 
 #define MAPPED_KERN_RO_TO_PHYS(x)	(x - CKSEG0)
 #define MAPPED_KERN_RW_TO_PHYS(x)	(x - CKSEG0)
-#define MAPPED_OFFSET			0
 
 #endif /* CONFIG_MAPPED_KERNEL */
 
diff -Nru a/include/asm-mips/sn/sn_private.h b/include/asm-mips/sn/sn_private.h
--- a/include/asm-mips/sn/sn_private.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-mips/sn/sn_private.h	2004-12-24 13:37:03 -08:00
@@ -10,12 +10,10 @@
 extern void hub_rtc_init(cnodeid_t);
 extern void cpu_time_init(void);
 extern void per_cpu_init(void);
-extern void per_hub_init(cnodeid_t cnode);
 extern void install_cpu_nmi_handler(int slice);
 extern void install_ipi(void);
 extern void setup_replication_mask(int);
 extern void replicate_kernel_text(int);
 extern pfn_t node_getfirstfree(cnodeid_t);
-extern void mlreset(void);
 
 #endif /* __ASM_SN_SN_PRIVATE_H */
diff -Nru a/include/asm-mips/socket.h b/include/asm-mips/socket.h
--- a/include/asm-mips/socket.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-mips/socket.h	2004-12-24 13:37:18 -08:00
@@ -68,6 +68,8 @@
 
 #define SO_PEERSEC		30
 
+#ifdef __KERNEL__
+
 /** sock_type - Socket types
  *
  * Please notice that for binary compat reasons MIPS has to
@@ -93,6 +95,8 @@
 
 #define SOCK_MAX (SOCK_PACKET + 1)
 
-#define ARCH_HAS_SOCKET_TYPES
+#define ARCH_HAS_SOCKET_TYPES 1
+
+#endif /* __KERNEL__ */
 
 #endif /* _ASM_SOCKET_H */
diff -Nru a/include/asm-mips/spinlock.h b/include/asm-mips/spinlock.h
--- a/include/asm-mips/spinlock.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-mips/spinlock.h	2004-12-24 13:37:29 -08:00
@@ -9,6 +9,8 @@
 #ifndef _ASM_SPINLOCK_H
 #define _ASM_SPINLOCK_H
 
+#include <asm/war.h>
+
 /*
  * Your basic SMP spinlocks, allowing only a single CPU anywhere
  */
@@ -36,27 +38,43 @@
 {
 	unsigned int tmp;
 
-	__asm__ __volatile__(
-	".set\tnoreorder\t\t\t# _raw_spin_lock\n"
-	"1:\tll\t%1, %2\n\t"
-	"bnez\t%1, 1b\n\t"
-	" li\t%1, 1\n\t"
-	"sc\t%1, %0\n\t"
-	"beqz\t%1, 1b\n\t"
-	" sync\n\t"
-	".set\treorder"
-	: "=m" (lock->lock), "=&r" (tmp)
-	: "m" (lock->lock)
-	: "memory");
+	if (R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_spin_lock	\n"
+		"1:	ll	%1, %2					\n"
+		"	bnez	%1, 1b					\n"
+		"	 li	%1, 1					\n"
+		"	sc	%1, %0					\n"
+		"	beqzl	%1, 1b					\n"
+		"	 nop						\n"
+		"	sync						\n"
+		"	.set	reorder					\n"
+		: "=m" (lock->lock), "=&r" (tmp)
+		: "m" (lock->lock)
+		: "memory");
+	} else {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_spin_lock	\n"
+		"1:	ll	%1, %2					\n"
+		"	bnez	%1, 1b					\n"
+		"	 li	%1, 1					\n"
+		"	sc	%1, %0					\n"
+		"	beqz	%1, 1b					\n"
+		"	 sync						\n"
+		"	.set	reorder					\n"
+		: "=m" (lock->lock), "=&r" (tmp)
+		: "m" (lock->lock)
+		: "memory");
+	}
 }
 
 static inline void _raw_spin_unlock(spinlock_t *lock)
 {
 	__asm__ __volatile__(
-	".set\tnoreorder\t\t\t# _raw_spin_unlock\n\t"
-	"sync\n\t"
-	"sw\t$0, %0\n\t"
-	".set\treorder"
+	"	.set	noreorder	# _raw_spin_unlock	\n"
+	"	sync						\n"
+	"	sw	$0, %0					\n"
+	"	.set\treorder					\n"
 	: "=m" (lock->lock)
 	: "m" (lock->lock)
 	: "memory");
@@ -66,17 +84,34 @@
 {
 	unsigned int temp, res;
 
-	__asm__ __volatile__(
-	".set\tnoreorder\t\t\t# _raw_spin_trylock\n\t"
-	"1:\tll\t%0, %3\n\t"
-	"ori\t%2, %0, 1\n\t"
-	"sc\t%2, %1\n\t"
-	"beqz\t%2, 1b\n\t"
-	" andi\t%2, %0, 1\n\t"
-	".set\treorder"
-	: "=&r" (temp), "=m" (lock->lock), "=&r" (res)
-	: "m" (lock->lock)
-	: "memory");
+	if (R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_spin_trylock	\n"
+		"1:	ll	%0, %3					\n"
+		"	ori	%2, %0, 1				\n"
+		"	sc	%2, %1					\n"
+		"	beqzl	%2, 1b					\n"
+		"	 nop						\n"
+		"	andi	%2, %0, 1				\n"
+		"	sync						\n"
+		"	.set	reorder"
+		: "=&r" (temp), "=m" (lock->lock), "=&r" (res)
+		: "m" (lock->lock)
+		: "memory");
+	} else {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_spin_trylock	\n"
+		"1:	ll	%0, %3					\n"
+		"	ori	%2, %0, 1				\n"
+		"	sc	%2, %1					\n"
+		"	beqz	%2, 1b					\n"
+		"	 andi	%2, %0, 1				\n"
+		"	sync						\n"
+		"	.set	reorder"
+		: "=&r" (temp), "=m" (lock->lock), "=&r" (res)
+		: "m" (lock->lock)
+		: "memory");
+	}
 
 	return res == 0;
 }
@@ -104,18 +139,34 @@
 {
 	unsigned int tmp;
 
-	__asm__ __volatile__(
-	".set\tnoreorder\t\t\t# _raw_read_lock\n"
-	"1:\tll\t%1, %2\n\t"
-	"bltz\t%1, 1b\n\t"
-	" addu\t%1, 1\n\t"
-	"sc\t%1, %0\n\t"
-	"beqz\t%1, 1b\n\t"
-	" sync\n\t"
-	".set\treorder"
-	: "=m" (rw->lock), "=&r" (tmp)
-	: "m" (rw->lock)
-	: "memory");
+	if (R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_read_lock	\n"
+		"1:	ll	%1, %2					\n"
+		"	bltz	%1, 1b					\n"
+		"	 addu	%1, 1					\n"
+		"	sc	%1, %0					\n"
+		"	beqzl	%1, 1b					\n"
+		"	 nop						\n"
+		"	sync						\n"
+		"	.set	reorder					\n"
+		: "=m" (rw->lock), "=&r" (tmp)
+		: "m" (rw->lock)
+		: "memory");
+	} else {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_read_lock	\n"
+		"1:	ll	%1, %2					\n"
+		"	bltz	%1, 1b					\n"
+		"	 addu	%1, 1					\n"
+		"	sc	%1, %0					\n"
+		"	beqz	%1, 1b					\n"
+		"	 sync						\n"
+		"	.set	reorder					\n"
+		: "=m" (rw->lock), "=&r" (tmp)
+		: "m" (rw->lock)
+		: "memory");
+	}
 }
 
 /* Note the use of sub, not subu which will make the kernel die with an
@@ -125,44 +176,71 @@
 {
 	unsigned int tmp;
 
-	__asm__ __volatile__(
-	".set\tnoreorder\t\t\t# _raw_read_unlock\n"
-	"1:\tll\t%1, %2\n\t"
-	"sub\t%1, 1\n\t"
-	"sc\t%1, %0\n\t"
-	"beqz\t%1, 1b\n\t"
-	" sync\n\t"
-	".set\treorder"
-	: "=m" (rw->lock), "=&r" (tmp)
-	: "m" (rw->lock)
-	: "memory");
+	if (R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"1:	ll	%1, %2		# _raw_read_unlock	\n"
+		"	sub	%1, 1					\n"
+		"	sc	%1, %0					\n"
+		"	beqzl	%1, 1b					\n"
+		"	sync						\n"
+		: "=m" (rw->lock), "=&r" (tmp)
+		: "m" (rw->lock)
+		: "memory");
+	} else {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_read_unlock	\n"
+		"1:	ll	%1, %2					\n"
+		"	sub	%1, 1					\n"
+		"	sc	%1, %0					\n"
+		"	beqz	%1, 1b					\n"
+		"	 sync						\n"
+		"	.set	reorder					\n"
+		: "=m" (rw->lock), "=&r" (tmp)
+		: "m" (rw->lock)
+		: "memory");
+	}
 }
 
 static inline void _raw_write_lock(rwlock_t *rw)
 {
 	unsigned int tmp;
 
-	__asm__ __volatile__(
-	".set\tnoreorder\t\t\t# _raw_write_lock\n"
-	"1:\tll\t%1, %2\n\t"
-	"bnez\t%1, 1b\n\t"
-	" lui\t%1, 0x8000\n\t"
-	"sc\t%1, %0\n\t"
-	"beqz\t%1, 1b\n\t"
-	" sync\n\t"
-	".set\treorder"
-	: "=m" (rw->lock), "=&r" (tmp)
-	: "m" (rw->lock)
-	: "memory");
+	if (R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_write_lock	\n"
+		"1:	ll	%1, %2					\n"
+		"	bnez	%1, 1b					\n"
+		"	 lui	%1, 0x8000				\n"
+		"	sc	%1, %0					\n"
+		"	beqzl	%1, 1b					\n"
+		"	 nop						\n"
+		"	sync						\n"
+		"	.set	reorder					\n"
+		: "=m" (rw->lock), "=&r" (tmp)
+		: "m" (rw->lock)
+		: "memory");
+	} else {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_write_lock	\n"
+		"1:	ll	%1, %2					\n"
+		"	bnez	%1, 1b					\n"
+		"	 lui	%1, 0x8000				\n"
+		"	sc	%1, %0					\n"
+		"	beqz	%1, 1b					\n"
+		"	 nop						\n"
+		"	sync						\n"
+		"	.set	reorder					\n"
+		: "=m" (rw->lock), "=&r" (tmp)
+		: "m" (rw->lock)
+		: "memory");
+	}
 }
 
 static inline void _raw_write_unlock(rwlock_t *rw)
 {
 	__asm__ __volatile__(
-	".set\tnoreorder\t\t\t# _raw_write_unlock\n\t"
-	"sync\n\t"
-	"sw\t$0, %0\n\t"
-	".set\treorder"
+	"	sync			# _raw_write_unlock	\n"
+	"	sw	$0, %0					\n"
 	: "=m" (rw->lock)
 	: "m" (rw->lock)
 	: "memory");
@@ -173,21 +251,40 @@
 	unsigned int tmp;
 	int ret;
 
-	__asm__ __volatile__(
-	".set\tnoreorder\t\t\t# _raw_write_trylock\n"
-	"li\t%2, 0\n\t"
-	"1:\tll\t%1, %3\n\t"
-	"bnez\t%1, 2f\n\t"
-	"lui\t%1, 0x8000\n\t"
-	"sc\t%1, %0\n\t"
-	"beqz\t%1, 1b\n\t"
-	"sync\n\t"
-	"li\t%2, 1\n\t"
-	".set\treorder\n"
-	"2:"
-	: "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
-	: "m" (rw->lock)
-	: "memory");
+	if (R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_write_trylock	\n"
+		"	li	%2, 0					\n"
+		"1:	ll	%1, %3					\n"
+		"	bnez	%1, 2f					\n"
+		"	 lui	%1, 0x8000				\n"
+		"	sc	%1, %0					\n"
+		"	beqzl	%1, 1b					\n"
+		"	 nop						\n"
+		"	sync						\n"
+		"	li	%2, 1					\n"
+		"	.set	reorder					\n"
+		"2:							\n"
+		: "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
+		: "m" (rw->lock)
+		: "memory");
+	} else {
+		__asm__ __volatile__(
+		"	.set	noreorder	# _raw_write_trylock	\n"
+		"	li	%2, 0					\n"
+		"1:	ll	%1, %3					\n"
+		"	bnez	%1, 2f					\n"
+		"	lui	%1, 0x8000				\n"
+		"	sc	%1, %0					\n"
+		"	beqz	%1, 1b					\n"
+		"	 sync						\n"
+		"	li	%2, 1					\n"
+		"	.set	reorder					\n"
+		"2:							\n"
+		: "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
+		: "m" (rw->lock)
+		: "memory");
+	}
 
 	return ret;
 }
diff -Nru a/include/asm-mips/stackframe.h b/include/asm-mips/stackframe.h
--- a/include/asm-mips/stackframe.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/stackframe.h	2004-12-24 13:36:17 -08:00
@@ -68,7 +68,7 @@
 		MFC0	k1, CP0_CONTEXT
 		dsra	k1, 23
 		lui	k0, %hi(pgd_current)
-		daddiu	k0, %lo(pgd_current)
+		addiu	k0, %lo(pgd_current)
 		dsubu	k1, k0
 		lui	k0, %hi(kernelsp)
 		daddu	k1, k0
diff -Nru a/include/asm-mips/statfs.h b/include/asm-mips/statfs.h
--- a/include/asm-mips/statfs.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-mips/statfs.h	2004-12-24 13:37:01 -08:00
@@ -28,9 +28,9 @@
 	long		f_bfree;
 	long		f_files;
 	long		f_ffree;
+	long		f_bavail;
 
 	/* Linux specials */
-	long	f_bavail;
 	__kernel_fsid_t	f_fsid;
 	long		f_namelen;
 	long		f_spare[6];
@@ -44,15 +44,16 @@
 struct statfs64 {
 	__u32	f_type;
 	__u32	f_bsize;
+	__u32	f_frsize;	/* Fragment size - unsupported */
+	__u32	__pad;
 	__u64	f_blocks;
 	__u64	f_bfree;
-	__u64	f_bavail;
 	__u64	f_files;
 	__u64	f_ffree;
+	__u64	f_bavail;
 	__kernel_fsid_t f_fsid;
 	__u32	f_namelen;
-	__u32	f_frsize;
-	__u32	f_spare[5];
+	__u32	f_spare[6];
 };
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
@@ -67,26 +68,27 @@
 	long		f_bfree;
 	long		f_files;
 	long		f_ffree;
+	long		f_bavail;
 
 	/* Linux specials */
-	long	f_bavail;
 	__kernel_fsid_t	f_fsid;
 	long		f_namelen;
 	long		f_spare[6];
 };
 
 struct compat_statfs64 {
-	__u32 f_type;
-	__u32 f_bsize;
-	__u64 f_blocks;
-	__u64 f_bfree;
-	__u64 f_bavail;
-	__u64 f_files;
-	__u64 f_ffree;
+	__u32	f_type;
+	__u32	f_bsize;
+	__u32	f_frsize;	/* Fragment size - unsupported */
+	__u32	__pad;
+	__u64	f_blocks;
+	__u64	f_bfree;
+	__u64	f_files;
+	__u64	f_ffree;
+	__u64	f_bavail;
 	__kernel_fsid_t f_fsid;
-	__u32 f_namelen;
-	__u32 f_frsize;
-	__u32 f_spare[5];
+	__u32	f_namelen;
+	__u32	f_spare[6];
 };
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
diff -Nru a/include/asm-mips/system.h b/include/asm-mips/system.h
--- a/include/asm-mips/system.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-mips/system.h	2004-12-24 13:36:48 -08:00
@@ -13,131 +13,13 @@
 #define _ASM_SYSTEM_H
 
 #include <linux/config.h>
-#include <asm/sgidefs.h>
-
-#include <linux/kernel.h>
+#include <linux/types.h>
 
 #include <asm/addrspace.h>
+#include <asm/cpu-features.h>
 #include <asm/ptrace.h>
-#include <asm/hazards.h>
-
-__asm__ (
-	".macro\tlocal_irq_enable\n\t"
-	".set\tpush\n\t"
-	".set\treorder\n\t"
-	".set\tnoat\n\t"
-	"mfc0\t$1,$12\n\t"
-	"ori\t$1,0x1f\n\t"
-	"xori\t$1,0x1e\n\t"
-	"mtc0\t$1,$12\n\t"
-	"irq_enable_hazard\n\t"
-	".set\tpop\n\t"
-	".endm");
-
-static inline void local_irq_enable(void)
-{
-	__asm__ __volatile__(
-		"local_irq_enable"
-		: /* no outputs */
-		: /* no inputs */
-		: "memory");
-}
-
-/*
- * For cli() we have to insert nops to make sure that the new value
- * has actually arrived in the status register before the end of this
- * macro.
- * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
- * no nops at all.
- */
-__asm__ (
-	".macro\tlocal_irq_disable\n\t"
-	".set\tpush\n\t"
-	".set\tnoat\n\t"
-	"mfc0\t$1,$12\n\t"
-	"ori\t$1,1\n\t"
-	"xori\t$1,1\n\t"
-	".set\tnoreorder\n\t"
-	"mtc0\t$1,$12\n\t"
-	"irq_disable_hazard\n\t"
-	".set\tpop\n\t"
-	".endm");
-
-static inline void local_irq_disable(void)
-{
-	__asm__ __volatile__(
-		"local_irq_disable"
-		: /* no outputs */
-		: /* no inputs */
-		: "memory");
-}
-
-__asm__ (
-	".macro\tlocal_save_flags flags\n\t"
-	".set\tpush\n\t"
-	".set\treorder\n\t"
-	"mfc0\t\\flags, $12\n\t"
-	".set\tpop\n\t"
-	".endm");
-
-#define local_save_flags(x)						\
-__asm__ __volatile__(							\
-	"local_save_flags %0"						\
-	: "=r" (x))
-
-__asm__ (
-	".macro\tlocal_irq_save result\n\t"
-	".set\tpush\n\t"
-	".set\treorder\n\t"
-	".set\tnoat\n\t"
-	"mfc0\t\\result, $12\n\t"
-	"ori\t$1, \\result, 1\n\t"
-	"xori\t$1, 1\n\t"
-	".set\tnoreorder\n\t"
-	"mtc0\t$1, $12\n\t"
-	"irq_disable_hazard\n\t"
-	".set\tpop\n\t"
-	".endm");
-
-#define local_irq_save(x)						\
-__asm__ __volatile__(							\
-	"local_irq_save\t%0"						\
-	: "=r" (x)							\
-	: /* no inputs */						\
-	: "memory")
-
-__asm__ (
-	".macro\tlocal_irq_restore flags\n\t"
-	".set\tnoreorder\n\t"
-	".set\tnoat\n\t"
-	"mfc0\t$1, $12\n\t"
-	"andi\t\\flags, 1\n\t"
-	"ori\t$1, 1\n\t"
-	"xori\t$1, 1\n\t"
-	"or\t\\flags, $1\n\t"
-	"mtc0\t\\flags, $12\n\t"
-	"irq_disable_hazard\n\t"
-	".set\tat\n\t"
-	".set\treorder\n\t"
-	".endm");
-
-#define local_irq_restore(flags)					\
-do {									\
-	unsigned long __tmp1;						\
-									\
-	__asm__ __volatile__(						\
-		"local_irq_restore\t%0"					\
-		: "=r" (__tmp1)						\
-		: "0" (flags)						\
-		: "memory");						\
-} while(0)
-
-#define irqs_disabled()							\
-({									\
-	unsigned long flags;						\
-	local_save_flags(flags);					\
-	!(flags & 1);							\
-})
+#include <asm/war.h>
+#include <asm/interrupt.h>
 
 /*
  * read_barrier_depends - Flush all pending reads that subsequents reads
@@ -277,37 +159,51 @@
 	(last) = resume(prev, next, next->thread_info); \
 } while(0)
 
+#define ROT_IN_PIECES							\
+	"	.set	noreorder	\n"				\
+	"	.set	reorder		\n"
+
 static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
 {
 	__u32 retval;
 
-#ifdef CONFIG_CPU_HAS_LLSC
-	unsigned long dummy;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long dummy;
 
-	__asm__ __volatile__(
-		".set\tpush\t\t\t\t# xchg_u32\n\t"
-		".set\tnoreorder\n\t"
-		".set\tnomacro\n\t"
-		"ll\t%0, %3\n"
-		"1:\tmove\t%2, %z4\n\t"
-		"sc\t%2, %1\n\t"
-		"beqzl\t%2, 1b\n\t"
-		" ll\t%0, %3\n\t"
+		__asm__ __volatile__(
+		"1:	ll	%0, %3			# xchg_u32	\n"
+		"	move	%2, %z4					\n"
+		"	sc	%2, %1					\n"
+		"	beqzl	%2, 1b					\n"
+		ROT_IN_PIECES
 #ifdef CONFIG_SMP
-		"sync\n\t"
+		"	sync						\n"
 #endif
-		".set\tpop"
 		: "=&r" (retval), "=m" (*m), "=&r" (dummy)
 		: "R" (*m), "Jr" (val)
 		: "memory");
-#else
-	unsigned long flags;
+	} else if (cpu_has_llsc) {
+		unsigned long dummy;
 
-	local_irq_save(flags);
-	retval = *m;
-	*m = val;
-	local_irq_restore(flags);	/* implies memory barrier  */
+		__asm__ __volatile__(
+		"1:	ll	%0, %3			# xchg_u32	\n"
+		"	move	%2, %z4					\n"
+		"	sc	%2, %1					\n"
+		"	beqz	%2, 1b					\n"
+#ifdef CONFIG_SMP
+		"	sync						\n"
 #endif
+		: "=&r" (retval), "=m" (*m), "=&r" (dummy)
+		: "R" (*m), "Jr" (val)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		local_irq_save(flags);
+		retval = *m;
+		*m = val;
+		local_irq_restore(flags);	/* implies memory barrier  */
+	}
 
 	return retval;
 }
@@ -317,33 +213,43 @@
 {
 	__u64 retval;
 
-#ifdef CONFIG_CPU_HAS_LLDSCD
-	unsigned long dummy;
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		unsigned long dummy;
 
-	__asm__ __volatile__(
-		".set\tpush\t\t\t\t# xchg_u64\n\t"
-		".set\tnoreorder\n\t"
-		".set\tnomacro\n\t"
-		"lld\t%0, %3\n"
-		"1:\tmove\t%2, %z4\n\t"
-		"scd\t%2, %1\n\t"
-		"beqzl\t%2, 1b\n\t"
-		" lld\t%0, %3\n\t"
+		__asm__ __volatile__(
+		"1:	lld	%0, %3			# xchg_u64	\n"
+		"	move	%2, %z4					\n"
+		"	scd	%2, %1					\n"
+		"	beqzl	%2, 1b					\n"
+		ROT_IN_PIECES
 #ifdef CONFIG_SMP
-		"sync\n\t"
+		"	sync						\n"
 #endif
-		".set\tpop"
 		: "=&r" (retval), "=m" (*m), "=&r" (dummy)
 		: "R" (*m), "Jr" (val)
 		: "memory");
-#else
-	unsigned long flags;
+	} else if (cpu_has_llsc) {
+		unsigned long dummy;
 
-	local_irq_save(flags);
-	retval = *m;
-	*m = val;
-	local_irq_restore(flags);	/* implies memory barrier  */
+		__asm__ __volatile__(
+		"1:	lld	%0, %3			# xchg_u64	\n"
+		"	move	%2, %z4					\n"
+		"	scd	%2, %1					\n"
+		"	beqz	%2, 1b					\n"
+#ifdef CONFIG_SMP
+		"	sync						\n"
 #endif
+		: "=&r" (retval), "=m" (*m), "=&r" (dummy)
+		: "R" (*m), "Jr" (val)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		local_irq_save(flags);
+		retval = *m;
+		*m = val;
+		local_irq_restore(flags);	/* implies memory barrier  */
+	}
 
 	return retval;
 }
@@ -378,31 +284,48 @@
 {
 	__u32 retval;
 
-#ifdef CONFIG_CPU_HAS_LLSC
-	__asm__ __volatile__(
-	"	.set	noat					\n"
-	"1:	ll	%0, %2			# __cmpxchg_u32	\n"
-	"	bne	%0, %z3, 2f				\n"
-	"	move	$1, %z4					\n"
-	"	sc	$1, %1					\n"
-	"	beqz	$1, 1b					\n"
+	if (cpu_has_llsc && R10000_LLSC_WAR) {
+		__asm__ __volatile__(
+		"	.set	noat					\n"
+		"1:	ll	%0, %2			# __cmpxchg_u32	\n"
+		"	bne	%0, %z3, 2f				\n"
+		"	move	$1, %z4					\n"
+		"	sc	$1, %1					\n"
+		"	beqzl	$1, 1b					\n"
+		ROT_IN_PIECES
 #ifdef CONFIG_SMP
-	"	sync						\n"
+		"	sync						\n"
 #endif
-	"2:							\n"
-	"	.set	at					\n"
-	: "=&r" (retval), "=m" (*m)
-	: "R" (*m), "Jr" (old), "Jr" (new)
-	: "memory");
-#else
-	unsigned long flags;
-
-	local_irq_save(flags);
-	retval = *m;
-	if (retval == old)
-		*m = new;
-	local_irq_restore(flags);	/* implies memory barrier  */
+		"2:							\n"
+		"	.set	at					\n"
+		: "=&r" (retval), "=m" (*m)
+		: "R" (*m), "Jr" (old), "Jr" (new)
+		: "memory");
+	} else if (cpu_has_llsc) {
+		__asm__ __volatile__(
+		"	.set	noat					\n"
+		"1:	ll	%0, %2			# __cmpxchg_u32	\n"
+		"	bne	%0, %z3, 2f				\n"
+		"	move	$1, %z4					\n"
+		"	sc	$1, %1					\n"
+		"	beqz	$1, 1b					\n"
+#ifdef CONFIG_SMP
+		"	sync						\n"
 #endif
+		"2:							\n"
+		"	.set	at					\n"
+		: "=&r" (retval), "=m" (*m)
+		: "R" (*m), "Jr" (old), "Jr" (new)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		local_irq_save(flags);
+		retval = *m;
+		if (retval == old)
+			*m = new;
+		local_irq_restore(flags);	/* implies memory barrier  */
+	}
 
 	return retval;
 }
@@ -413,31 +336,48 @@
 {
 	__u64 retval;
 
-#ifdef CONFIG_CPU_HAS_LLDSCD
-	__asm__ __volatile__(
-	"	.set	noat					\n"
-	"1:	lld	%0, %2			# __cmpxchg_u64	\n"
-	"	bne	%0, %z3, 2f				\n"
-	"	move	$1, %z4					\n"
-	"	scd	$1, %1					\n"
-	"	beqz	$1, 1b					\n"
+	if (cpu_has_llsc) {
+		__asm__ __volatile__(
+		"	.set	noat					\n"
+		"1:	lld	%0, %2			# __cmpxchg_u64	\n"
+		"	bne	%0, %z3, 2f				\n"
+		"	move	$1, %z4					\n"
+		"	scd	$1, %1					\n"
+		"	beqzl	$1, 1b					\n"
+		ROT_IN_PIECES
 #ifdef CONFIG_SMP
-	"	sync						\n"
+		"	sync						\n"
 #endif
-	"2:							\n"
-	"	.set	at					\n"
-	: "=&r" (retval), "=m" (*m)
-	: "R" (*m), "Jr" (old), "Jr" (new)
-	: "memory");
-#else
-	unsigned long flags;
-
-	local_irq_save(flags);
-	retval = *m;
-	if (retval == old)
-		*m = new;
-	local_irq_restore(flags);	/* implies memory barrier  */
+		"2:							\n"
+		"	.set	at					\n"
+		: "=&r" (retval), "=m" (*m)
+		: "R" (*m), "Jr" (old), "Jr" (new)
+		: "memory");
+	} else if (cpu_has_llsc) {
+		__asm__ __volatile__(
+		"	.set	noat					\n"
+		"1:	lld	%0, %2			# __cmpxchg_u64	\n"
+		"	bne	%0, %z3, 2f				\n"
+		"	move	$1, %z4					\n"
+		"	scd	$1, %1					\n"
+		"	beqz	$1, 1b					\n"
+#ifdef CONFIG_SMP
+		"	sync						\n"
 #endif
+		"2:							\n"
+		"	.set	at					\n"
+		: "=&r" (retval), "=m" (*m)
+		: "R" (*m), "Jr" (old), "Jr" (new)
+		: "memory");
+	} else {
+		unsigned long flags;
+
+		local_irq_save(flags);
+		retval = *m;
+		if (retval == old)
+			*m = new;
+		local_irq_restore(flags);	/* implies memory barrier  */
+	}
 
 	return retval;
 }
@@ -479,13 +419,7 @@
 #define die_if_kernel(msg, regs)					\
 	__die_if_kernel(msg, regs, __FILE__ ":", __FUNCTION__, __LINE__)
 
-extern int serial_console;
 extern int stop_a_enabled;
-
-static __inline__ int con_is_present(void)
-{
-	return serial_console ? 0 : 1;
-}
 
 /*
  * Taken from include/asm-ia64/system.h; prevents deadlock on SMP
diff -Nru a/include/asm-mips/thread_info.h b/include/asm-mips/thread_info.h
--- a/include/asm-mips/thread_info.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-mips/thread_info.h	2004-12-24 13:36:16 -08:00
@@ -101,7 +101,7 @@
 
 #endif /* !__ASSEMBLY__ */
 
-#define PREEMPT_ACTIVE		0x4000000
+#define PREEMPT_ACTIVE		0x10000000
 
 /*
  * thread information flags
diff -Nru a/include/asm-mips/titan_dep.h b/include/asm-mips/titan_dep.h
--- a/include/asm-mips/titan_dep.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/titan_dep.h	2004-12-24 13:36:17 -08:00
@@ -16,25 +16,19 @@
 #include <asm/addrspace.h>              /* for KSEG1ADDR() */
 #include <asm/byteorder.h>              /* for cpu_to_le32() */
 
-/* PCI */
-#define	TITAN_PCI_BASE			0xbb000000
-
-#define TITAN_WRITE(ofs, data)  \
-        *(volatile u32 *)(TITAN_PCI_BASE+(ofs)) = cpu_to_le32(data)
-#define TITAN_READ(ofs, data)   \
-        *(data) = le32_to_cpu(*(volatile u32 *)(TITAN_PCI_BASE+(ofs)))
-#define TITAN_READ_DATA(ofs)    \
-        le32_to_cpu(*(volatile u32 *)(TITAN_PCI_BASE+(ofs)))
-
-#define TITAN_WRITE_16(ofs, data)  \
-        *(volatile u16 *)(TITAN_PCI_BASE+(ofs)) = cpu_to_le16(data)
-#define TITAN_READ_16(ofs, data)   \
-        *(data) = le16_to_cpu(*(volatile u16 *)(TITAN_PCI_BASE+(ofs)))
-
-#define TITAN_WRITE_8(ofs, data)  \
-        *(volatile u8 *)(TITAN_PCI_BASE+(ofs)) = data
-#define TITAN_READ_8(ofs, data)   \
-        *(data) = *(volatile u8 *)(TITAN_PCI_BASE+(ofs))
+#define TITAN_READ(ofs)							\
+	(*(volatile u32 *)(ocd_base+(ofs)))
+#define TITAN_READ_16(ofs)						\
+	(*(volatile u16 *)(ocd_base+(ofs)))
+#define TITAN_READ_8(ofs)						\
+	(*(volatile u8 *)(ocd_base+(ofs)))
+
+#define TITAN_WRITE(ofs, data)						\
+	do { *(volatile u32 *)(ocd_base+(ofs)) = (data); } while (0)
+#define TITAN_WRITE_16(ofs, data)					\
+	do { *(volatile u16 *)(ocd_base+(ofs)) = (data); } while (0)
+#define TITAN_WRITE_8(ofs, data)					\
+	do { *(volatile u8 *)(ocd_base+(ofs)) = (data); } while (0)
 
 /*
  * PCI specific defines
@@ -45,11 +39,11 @@
 /*
  * HT specific defines
  */
-#define RM9000x2_HTLINK_REG     0xbb000644
-#define RM9000x2_BASE_ADDR      0xbb000000
+#define RM9000x2_HTLINK_REG		0xbb000644
+#define RM9000x2_BASE_ADDR		0xbb000000
 
-#define OCD_BASE                0xfb000000UL
-#define OCD_SIZE                0x3000UL
+#define OCD_BASE			0xfb000000UL
+#define OCD_SIZE			0x3000UL
 
 extern unsigned long ocd_base;
 
diff -Nru a/include/asm-mips/tx4927/smsc_fdc37m81x.h b/include/asm-mips/tx4927/smsc_fdc37m81x.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-mips/tx4927/smsc_fdc37m81x.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,69 @@
+/*
+ * linux/include/asm-mips/tx4927/smsc_fdc37m81x.h
+ *
+ * Interface for smsc fdc48m81x Super IO chip
+ *
+ * Author: MontaVista Software, Inc. source@mvista.com
+ *
+ * 2001-2003 (c) MontaVista Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Manish Lachwani, mlachwani@mvista.com
+ */
+
+#ifndef _SMSC_FDC37M81X_H_
+#define _SMSC_FDC37M81X_H_
+
+/* Common Registers */
+#define SMSC_FDC37M81X_CONFIG_INDEX  0x00
+#define SMSC_FDC37M81X_CONFIG_DATA   0x01
+#define SMSC_FDC37M81X_CONF          0x02
+#define SMSC_FDC37M81X_INDEX         0x03
+#define SMSC_FDC37M81X_DNUM          0x07
+#define SMSC_FDC37M81X_DID           0x20
+#define SMSC_FDC37M81X_DREV          0x21
+#define SMSC_FDC37M81X_PCNT          0x22
+#define SMSC_FDC37M81X_PMGT          0x23
+#define SMSC_FDC37M81X_OSC           0x24
+#define SMSC_FDC37M81X_CONFPA0       0x26
+#define SMSC_FDC37M81X_CONFPA1       0x27
+#define SMSC_FDC37M81X_TEST4         0x2B
+#define SMSC_FDC37M81X_TEST5         0x2C
+#define SMSC_FDC37M81X_TEST1         0x2D
+#define SMSC_FDC37M81X_TEST2         0x2E
+#define SMSC_FDC37M81X_TEST3         0x2F
+
+/* Logical device numbers */
+#define SMSC_FDC37M81X_FDD           0x00
+#define SMSC_FDC37M81X_PARALLEL      0x03
+#define SMSC_FDC37M81X_SERIAL1       0x04
+#define SMSC_FDC37M81X_SERIAL2       0x05
+#define SMSC_FDC37M81X_KBD           0x07
+#define SMSC_FDC37M81X_AUXIO         0x08
+#define SMSC_FDC37M81X_NONE          0xff
+
+/* Logical device Config Registers */
+#define SMSC_FDC37M81X_ACTIVE        0x30
+#define SMSC_FDC37M81X_BASEADDR0     0x60
+#define SMSC_FDC37M81X_BASEADDR1     0x61
+#define SMSC_FDC37M81X_INT           0x70
+#define SMSC_FDC37M81X_INT2          0x72
+#define SMSC_FDC37M81X_LDCR_F0       0xF0
+
+/* Chip Config Values */
+#define SMSC_FDC37M81X_CONFIG_ENTER  0x55
+#define SMSC_FDC37M81X_CONFIG_EXIT   0xaa
+#define SMSC_FDC37M81X_CHIP_ID       0x4d
+
+unsigned long __init smsc_fdc37m81x_init(unsigned long port);
+
+void smsc_fdc37m81x_config_beg(void);
+
+void smsc_fdc37m81x_config_end(void);
+
+void smsc_fdc37m81x_config_set(u8 reg, u8 val);
+
+#endif
diff -Nru a/include/asm-mips/tx4927/tx4927.h b/include/asm-mips/tx4927/tx4927.h
--- a/include/asm-mips/tx4927/tx4927.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-mips/tx4927/tx4927.h	2004-12-24 13:37:18 -08:00
@@ -88,8 +88,8 @@
 
 
 /* TX4927 Configuration registers (64-bit registers) */
-#define TX4927_CONFIG_BASE                       0xe300
-#define TX4927_CONFIG_CCFG                       0xe300
+#define TX4927_CONFIG_BASE                       0xe000
+#define TX4927_CONFIG_CCFG                       0xe000
 #define TX4927_CONFIG_CCFG_RESERVED_42_63                BM_63_42
 #define TX4927_CONFIG_CCFG_WDRST                         BM_41_41
 #define TX4927_CONFIG_CCFG_WDREXEN                       BM_40_40
@@ -124,14 +124,14 @@
 #define TX4927_CONFIG_CCFG_ENDIAN                        BM_02_02
 #define TX4927_CONFIG_CCFG_ARMODE                        BM_01_01
 #define TX4927_CONFIG_CCFG_ACEHOLD                       BM_00_00
-#define TX4927_CONFIG_REVID                      0xe308 
+#define TX4927_CONFIG_REVID                      0xe008
 #define TX4927_CONFIG_REVID_RESERVED_32_63               BM_32_63
 #define TX4927_CONFIG_REVID_PCODE                        BM_16_31
 #define TX4927_CONFIG_REVID_MJERREV                      BM_12_15
 #define TX4927_CONFIG_REVID_MINEREV                      BM_08_11
 #define TX4927_CONFIG_REVID_MJREV                        BM_04_07
 #define TX4927_CONFIG_REVID_MINREV                       BM_00_03
-#define TX4927_CONFIG_PCFG                       0xe310 
+#define TX4927_CONFIG_PCFG                       0xe010
 #define TX4927_CONFIG_PCFG_RESERVED_57_63                BM_57_63
 #define TX4927_CONFIG_PCFG_DRVDATA                       BM_56_56
 #define TX4927_CONFIG_PCFG_DRVCB                         BM_55_55
@@ -197,10 +197,10 @@
 #define TX4927_CONFIG_PCFG_DMASEL0_SIO1                  BM_00_00
 #define TX4927_CONFIG_PCFG_DMASEL0_ACLC0                 BM_01_01
 #define TX4927_CONFIG_PCFG_DMASEL0_ACLC2                 BM_00_01
-#define TX4927_CONFIG_TOEA                       0xe318 
+#define TX4927_CONFIG_TOEA                       0xe018
 #define TX4927_CONFIG_TOEA_RESERVED_36_63                BM_36_63
 #define TX4927_CONFIG_TOEA_TOEA                          BM_00_35
-#define TX4927_CONFIG_CLKCTR                     0xe320 
+#define TX4927_CONFIG_CLKCTR                     0xe020
 #define TX4927_CONFIG_CLKCTR_RESERVED_26_63              BM_26_63
 #define TX4927_CONFIG_CLKCTR_ACLCKD                      BM_25_25
 #define TX4927_CONFIG_CLKCTR_PIOCKD                      BM_24_24
@@ -223,7 +223,7 @@
 #define TX4927_CONFIG_CLKCTR_TM2RST                      BM_02_02
 #define TX4927_CONFIG_CLKCTR_SIO0RST                     BM_01_01
 #define TX4927_CONFIG_CLKCTR_SIO1RST                     BM_00_00
-#define TX4927_CONFIG_GARBC                      0xe330 
+#define TX4927_CONFIG_GARBC                      0xe030
 #define TX4927_CONFIG_GARBC_RESERVED_10_63               BM_10_63
 #define TX4927_CONFIG_GARBC_SET_09                       BM_09_09
 #define TX4927_CONFIG_GARBC_ARBMD                        BM_08_08
@@ -243,7 +243,7 @@
 #define TX4927_CONFIG_GARBC_PRIORITY_H3_PDMAC            BM_00_00
 #define TX4927_CONFIG_GARBC_PRIORITY_H3_DMAC             BM_01_01
 #define TX4927_CONFIG_GARBC_PRIORITY_H3_BAD_VALUE        BM_00_01
-#define TX4927_CONFIG_RAMP                       0xe348 
+#define TX4927_CONFIG_RAMP                       0xe048
 #define TX4927_CONFIG_RAMP_RESERVED_20_63                BM_20_63
 #define TX4927_CONFIG_RAMP_RAMP                          BM_00_19
 #define TX4927_CONFIG_LIMIT                      0xefff
@@ -456,7 +456,7 @@
 #define TX4927_ACLC_ACINTSTS            0xf710
 #define TX4927_ACLC_ACINTMSTS           0xf714
 #define TX4927_ACLC_ACINTEN             0xf718
-#define TX4927_ACLC_ACINTDIS            0xfR71c
+#define TX4927_ACLC_ACINTDIS            0xf71c
 #define TX4927_ACLC_ACSEMAPH            0xf720
 #define TX4927_ACLC_ACGPIDAT            0xf740
 #define TX4927_ACLC_ACGPODAT            0xf744
diff -Nru a/include/asm-mips/uaccess.h b/include/asm-mips/uaccess.h
--- a/include/asm-mips/uaccess.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/uaccess.h	2004-12-24 13:36:17 -08:00
@@ -10,7 +10,7 @@
 #define _ASM_UACCESS_H
 
 #include <linux/config.h>
-#include <linux/compiler.h>
+#include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/thread_info.h>
 #include <asm-generic/uaccess.h>
@@ -225,89 +225,89 @@
  * for 32 bit mode and old iron.
  */
 #ifdef __mips64
-#define __GET_USER_DW __get_user_asm("ld")
+#define __GET_USER_DW(__gu_err) __get_user_asm("ld", __gu_err)
 #else
-#define __GET_USER_DW __get_user_asm_ll32
+#define __GET_USER_DW(__gu_err) __get_user_asm_ll32(__gu_err)
 #endif
 
-#define __get_user_nocheck(x,ptr,size)				\
-({								\
-	long __gu_err;						\
-	__typeof(*(ptr)) __gu_val;				\
-	long __gu_addr;						\
-	might_sleep();						\
-	__asm__("":"=r" (__gu_val));				\
-	__gu_addr = (long) (ptr);				\
-	__asm__("":"=r" (__gu_err));				\
-	switch (size) {						\
-	case 1: __get_user_asm("lb"); break;			\
-	case 2: __get_user_asm("lh"); break;			\
-	case 4: __get_user_asm("lw"); break;			\
-	case 8: __GET_USER_DW; break;				\
-	default: __get_user_unknown(); break;			\
-	} x = (__typeof__(*(ptr))) __gu_val; __gu_err;		\
+#define __get_user_nocheck(x,ptr,size)					\
+({									\
+	long __gu_err = 0;						\
+	__typeof(*(ptr)) __gu_val = 0;					\
+	long __gu_addr;							\
+	might_sleep();							\
+	__gu_addr = (long) (ptr);					\
+	switch (size) {							\
+	case 1: __get_user_asm("lb", __gu_err); break;			\
+	case 2: __get_user_asm("lh", __gu_err); break;			\
+	case 4: __get_user_asm("lw", __gu_err); break;			\
+	case 8: __GET_USER_DW(__gu_err); break;				\
+	default: __get_user_unknown(); break;				\
+	}								\
+	 x = (__typeof__(*(ptr))) __gu_val;				\
+	__gu_err;							\
 })
 
 #define __get_user_check(x,ptr,size)					\
 ({									\
+	__typeof__(*(ptr)) __gu_val = 0;				\
+	long __gu_addr = (long) (ptr);					\
 	long __gu_err;							\
-	__typeof__(*(ptr)) __gu_val;					\
-	long __gu_addr;							\
+									\
 	might_sleep();							\
-	__asm__("":"=r" (__gu_val));					\
-	__gu_addr = (long) (ptr);					\
-	__asm__("":"=r" (__gu_err));					\
-	if (access_ok(VERIFY_READ,__gu_addr,size)) {			\
+	__gu_err = verify_area(VERIFY_READ, (void *) __gu_addr, size);	\
+									\
+	if (likely(!__gu_err)) {					\
 		switch (size) {						\
-		case 1: __get_user_asm("lb"); break;			\
-		case 2: __get_user_asm("lh"); break;			\
-		case 4: __get_user_asm("lw"); break;			\
-		case 8: __GET_USER_DW; break;				\
+		case 1: __get_user_asm("lb", __gu_err); break;		\
+		case 2: __get_user_asm("lh", __gu_err); break;		\
+		case 4: __get_user_asm("lw", __gu_err); break;		\
+		case 8: __GET_USER_DW(__gu_err); break;			\
 		default: __get_user_unknown(); break;			\
 		}							\
-	} x = (__typeof__(*(ptr))) __gu_val; __gu_err;			\
+	}								\
+	x = (__typeof__(*(ptr))) __gu_val;				\
+	 __gu_err;							\
 })
 
-#define __get_user_asm(insn)						\
+#define __get_user_asm(insn,__gu_err)					\
 ({									\
 	__asm__ __volatile__(						\
-	"1:\t" insn "\t%1,%2\n\t"					\
-	"move\t%0,$0\n"							\
-	"2:\n\t"							\
-	".section\t.fixup,\"ax\"\n"					\
-	"3:\tli\t%0,%3\n\t"						\
-	"move\t%1,$0\n\t"						\
-	"j\t2b\n\t"							\
-	".previous\n\t"							\
-	".section\t__ex_table,\"a\"\n\t"				\
-	__UA_ADDR "\t1b,3b\n\t"						\
-	".previous"							\
-	:"=r" (__gu_err), "=r" (__gu_val)				\
-	:"o" (__m(__gu_addr)), "i" (-EFAULT));				\
+	"1:	" insn "	%1, %3				\n"	\
+	"2:							\n"	\
+	"	.section .fixup,\"ax\"				\n"	\
+	"3:	li	%0, %4					\n"	\
+	"	j	2b					\n"	\
+	"	.previous					\n"	\
+	"	.section __ex_table,\"a\"			\n"	\
+	"	"__UA_ADDR "\t1b, 3b				\n"	\
+	"	.previous					\n"	\
+	: "=r" (__gu_err), "=r" (__gu_val)				\
+	: "0" (__gu_err), "o" (__m(__gu_addr)), "i" (-EFAULT));		\
 })
 
 /*
  * Get a long long 64 using 32 bit registers.
  */
-#define __get_user_asm_ll32						\
+#define __get_user_asm_ll32(__gu_err)					\
 ({									\
 	__asm__ __volatile__(						\
-	"1:\tlw\t%1,%2\n"						\
-	"2:\tlw\t%D1,%3\n\t"						\
-	"move\t%0,$0\n"							\
-	"3:\t.section\t.fixup,\"ax\"\n"					\
-	"4:\tli\t%0,%4\n\t"						\
-	"move\t%1,$0\n\t"						\
-	"move\t%D1,$0\n\t"						\
-	"j\t3b\n\t"							\
-	".previous\n\t"							\
-	".section\t__ex_table,\"a\"\n\t"				\
-	__UA_ADDR "\t1b,4b\n\t"						\
-	__UA_ADDR "\t2b,4b\n\t"						\
-	".previous"							\
-	:"=r" (__gu_err), "=&r" (__gu_val)				\
-	:"o" (__m(__gu_addr)), "o" (__m(__gu_addr + 4)),		\
-	 "i" (-EFAULT));						\
+	"1:	lw	%1, %3					\n"	\
+	"2:	lw	%D1, %4					\n"	\
+	"	move	%0, $0					\n"	\
+	"3:	.section	.fixup,\"ax\"			\n"	\
+	"4:	li	%0, %5					\n"	\
+	"	move	%1, $0					\n"	\
+	"	move	%D1, $0					\n"	\
+	"	j	3b					\n"	\
+	"	.previous					\n"	\
+	"	.section	__ex_table,\"a\"		\n"	\
+	"	" __UA_ADDR "	1b, 4b				\n"	\
+	"	" __UA_ADDR "	2b, 4b				\n"	\
+	"	.previous					\n"	\
+	: "=r" (__gu_err), "=&r" (__gu_val)				\
+	: "0" (__gu_err), "o" (__m(__gu_addr)),				\
+	  "o" (__m(__gu_addr + 4)), "i" (-EFAULT));			\
 })
 
 extern void __get_user_unknown(void);
@@ -317,25 +317,24 @@
  * for 32 bit mode and old iron.
  */
 #ifdef __mips64
-#define __PUT_USER_DW __put_user_asm("sd")
+#define __PUT_USER_DW(__pu_val) __put_user_asm("sd", __pu_val)
 #else
-#define __PUT_USER_DW __put_user_asm_ll32
+#define __PUT_USER_DW(__pu_val) __put_user_asm_ll32(__pu_val)
 #endif
 
 #define __put_user_nocheck(x,ptr,size)					\
 ({									\
-	long __pu_err;							\
+	long __pu_err = 0;						\
 	__typeof__(*(ptr)) __pu_val;					\
 	long __pu_addr;							\
 	might_sleep();							\
 	__pu_val = (x);							\
 	__pu_addr = (long) (ptr);					\
-	__asm__("":"=r" (__pu_err));					\
 	switch (size) {							\
-	case 1: __put_user_asm("sb"); break;				\
-	case 2: __put_user_asm("sh"); break;				\
-	case 4: __put_user_asm("sw"); break;				\
-	case 8: __PUT_USER_DW; break;					\
+	case 1: __put_user_asm("sb", __pu_val); break;			\
+	case 2: __put_user_asm("sh", __pu_val); break;			\
+	case 4: __put_user_asm("sw", __pu_val); break;			\
+	case 8: __PUT_USER_DW(__pu_val); break;				\
 	default: __put_user_unknown(); break;				\
 	}								\
 	__pu_err;							\
@@ -343,60 +342,59 @@
 
 #define __put_user_check(x,ptr,size)					\
 ({									\
+	__typeof__(*(ptr)) __pu_val = (x);				\
+	long __pu_addr = (long) (ptr);					\
 	long __pu_err;							\
-	__typeof__(*(ptr)) __pu_val;					\
-	long __pu_addr;							\
+									\
 	might_sleep();							\
-	__pu_val = (x);							\
-	__pu_addr = (long) (ptr);					\
-	__asm__("":"=r" (__pu_err));					\
-	if (access_ok(VERIFY_WRITE, __pu_addr, size)) {			\
+	__pu_err = verify_area(VERIFY_WRITE, (void *) __pu_addr, size);	\
+									\
+	if (likely(!__pu_err)) {					\
 		switch (size) {						\
-		case 1: __put_user_asm("sb"); break;			\
-		case 2: __put_user_asm("sh"); break;			\
-		case 4: __put_user_asm("sw"); break;			\
-		case 8: __PUT_USER_DW; break;				\
+		case 1: __put_user_asm("sb", __pu_val); break;		\
+		case 2: __put_user_asm("sh", __pu_val); break;		\
+		case 4: __put_user_asm("sw", __pu_val); break;		\
+		case 8: __PUT_USER_DW(__pu_val); break;			\
 		default: __put_user_unknown(); break;			\
 		}							\
 	}								\
 	__pu_err;							\
 })
 
-#define __put_user_asm(insn)						\
+#define __put_user_asm(insn, __pu_val)					\
 ({									\
 	__asm__ __volatile__(						\
-	"1:\t" insn "\t%z1, %2\t\t\t# __put_user_asm\n\t"		\
-	"move\t%0, $0\n"						\
-	"2:\n\t"							\
-	".section\t.fixup,\"ax\"\n"					\
-	"3:\tli\t%0,%3\n\t"						\
-	"j\t2b\n\t"							\
-	".previous\n\t"							\
-	".section\t__ex_table,\"a\"\n\t"				\
-	__UA_ADDR "\t1b,3b\n\t"						\
-	".previous"							\
-	:"=r" (__pu_err)						\
-	:"Jr" (__pu_val), "o" (__m(__pu_addr)), "i" (-EFAULT));		\
+	"1:	" insn "	%z2, %3		# __put_user_asm\n"	\
+	"2:							\n"	\
+	"	.section	.fixup,\"ax\"			\n"	\
+	"3:	li	%0, %4					\n"	\
+	"	j	2b					\n"	\
+	"	.previous					\n"	\
+	"	.section	__ex_table,\"a\"		\n"	\
+	"	" __UA_ADDR "	1b, 3b				\n"	\
+	"	.previous					\n"	\
+	: "=r" (__pu_err)						\
+	: "0" (__pu_err), "Jr" (__pu_val), "o" (__m(__pu_addr)),	\
+	  "i" (-EFAULT));						\
 })
 
-#define __put_user_asm_ll32						\
+#define __put_user_asm_ll32(__pu_val)					\
 ({									\
 	__asm__ __volatile__(						\
-	"1:\tsw\t%1, %2\t\t\t# __put_user_asm_ll32\n\t"			\
-	"2:\tsw\t%D1, %3\n"						\
-	"move\t%0, $0\n"						\
-	"3:\n\t"							\
-	".section\t.fixup,\"ax\"\n"					\
-	"4:\tli\t%0,%4\n\t"						\
-	"j\t3b\n\t"							\
-	".previous\n\t"							\
-	".section\t__ex_table,\"a\"\n\t"				\
-	__UA_ADDR "\t1b,4b\n\t"						\
-	__UA_ADDR "\t2b,4b\n\t"						\
-	".previous"							\
-	:"=r" (__pu_err)						\
-	:"r" (__pu_val), "o" (__m(__pu_addr)),				\
-	 "o" (__m(__pu_addr + 4)), "i" (-EFAULT));			\
+	"1:	sw	%2, %3		# __put_user_asm_ll32	\n"	\
+	"2:	sw	%D2, %4					\n"	\
+	"3:							\n"	\
+	"	.section	.fixup,\"ax\"			\n"	\
+	"4:	li	%0, %5					\n"	\
+	"	j	3b					\n"	\
+	"	.previous					\n"	\
+	"	.section	__ex_table,\"a\"		\n"	\
+	"	" __UA_ADDR "	1b, 4b				\n"	\
+	"	" __UA_ADDR "	2b, 4b				\n"	\
+	"	.previous"						\
+	: "=r" (__pu_err)						\
+	: "0" (__pu_err), "r" (__pu_val), "o" (__m(__pu_addr)),		\
+	  "o" (__m(__pu_addr + 4)), "i" (-EFAULT));			\
 })
 
 extern void __put_user_unknown(void);
@@ -511,8 +509,7 @@
 	".set\tnoat\n\t"						\
 	__UA_ADDU "\t$1, %1, %2\n\t"					\
 	".set\tat\n\t"							\
-	".set\treorder\n\t"						\
-	"move\t%0, $6"		/* XXX */				\
+	".set\treorder"							\
 	: "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r)	\
 	:								\
 	: "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31",		\
diff -Nru a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
--- a/include/asm-mips/unistd.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-mips/unistd.h	2004-12-24 13:36:17 -08:00
@@ -298,16 +298,21 @@
 #define __NR_mq_notify			(__NR_Linux + 275)
 #define __NR_mq_getsetattr		(__NR_Linux + 276)
 #define __NR_vserver			(__NR_Linux + 277)
+#define __NR_waitid			(__NR_Linux + 278)
+/* #define __NR_sys_setaltroot		(__NR_Linux + 279) */
+#define __NR_add_key			(__NR_Linux + 280)
+#define __NR_request_key		(__NR_Linux + 281)
+#define __NR_keyctl			(__NR_Linux + 282)
 
 /*
  * Offset of the last Linux o32 flavoured syscall
  */
-#define __NR_Linux_syscalls		277
+#define __NR_Linux_syscalls		282
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
 
 #define __NR_O32_Linux			4000
-#define __NR_O32_Linux_syscalls		277
+#define __NR_O32_Linux_syscalls		282
 
 #if _MIPS_SIM == _MIPS_SIM_ABI64
 
@@ -552,16 +557,21 @@
 #define __NR_mq_notify			(__NR_Linux + 234)
 #define __NR_mq_getsetattr		(__NR_Linux + 235)
 #define __NR_vserver			(__NR_Linux + 236)
+#define __NR_waitid			(__NR_Linux + 237)
+/* #define __NR_sys_setaltroot		(__NR_Linux + 238) */
+#define __NR_add_key			(__NR_Linux + 239)
+#define __NR_request_key		(__NR_Linux + 240)
+#define __NR_keyctl			(__NR_Linux + 241)
 
 /*
- * Offset of the last Linux flavoured syscall
+ * Offset of the last Linux 64-bit flavoured syscall
  */
-#define __NR_Linux_syscalls		236
+#define __NR_Linux_syscalls		241
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
 
 #define __NR_64_Linux			5000
-#define __NR_64_Linux_syscalls		236
+#define __NR_64_Linux_syscalls		241
 
 #if _MIPS_SIM == _MIPS_SIM_NABI32
 
@@ -810,16 +820,21 @@
 #define __NR_mq_notify			(__NR_Linux + 238)
 #define __NR_mq_getsetattr		(__NR_Linux + 239)
 #define __NR_vserver			(__NR_Linux + 240)
+#define __NR_waitid			(__NR_Linux + 241)
+/* #define __NR_sys_setaltroot		(__NR_Linux + 242) */
+#define __NR_add_key			(__NR_Linux + 243)
+#define __NR_request_key		(__NR_Linux + 244)
+#define __NR_keyctl			(__NR_Linux + 245)
 
 /*
  * Offset of the last N32 flavoured syscall
  */
-#define __NR_Linux_syscalls		240
+#define __NR_Linux_syscalls		245
 
 #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
 
 #define __NR_N32_Linux			6000
-#define __NR_N32_Linux_syscalls		240
+#define __NR_N32_Linux_syscalls		245
 
 #ifndef __ASSEMBLY__
 
@@ -838,12 +853,13 @@
 	".set\treorder" \
 	: "=&r" (__v0), "=r" (__a3) \
 	: "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 /*
@@ -865,12 +881,13 @@
 	".set\treorder" \
 	: "=&r" (__v0), "=r" (__a3) \
 	: "r" (__a0), "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 #define _syscall2(type,name,atype,a,btype,b) \
@@ -889,12 +906,13 @@
 	".set\treorder" \
 	: "=&r" (__v0), "=r" (__a3) \
 	: "r" (__a0), "r" (__a1), "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 #define _syscall3(type,name,atype,a,btype,b,ctype,c) \
@@ -914,12 +932,13 @@
 	".set\treorder" \
 	: "=&r" (__v0), "=r" (__a3) \
 	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 #define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
@@ -939,12 +958,13 @@
 	".set\treorder" \
 	: "=&r" (__v0), "+r" (__a3) \
 	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
@@ -975,12 +995,13 @@
 	: "=&r" (__v0), "+r" (__a3) \
 	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
 	  "m" ((unsigned long)e) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 #define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
@@ -1007,12 +1028,13 @@
 	: "=&r" (__v0), "+r" (__a3) \
 	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
 	  "m" ((unsigned long)e), "m" ((unsigned long)f) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 #endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */
@@ -1035,14 +1057,15 @@
 	"syscall\n\t" \
 	"move\t%0, $2\n\t" \
 	".set\treorder" \
-	: "=&r" (__v0), "+r" (__a3), "+r" (__a4) \
-	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
-	: "$2","$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "=&r" (__v0), "+r" (__a3) \
+	: "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "i" (__NR_##name) \
+	: "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 #define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
@@ -1065,12 +1088,13 @@
 	: "=&r" (__v0), "+r" (__a3) \
 	: "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "r" (__a5), \
 	  "i" (__NR_##name) \
-	: "$2","$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24"); \
+	: "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
+	  "memory"); \
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
 	errno = __v0; \
-	return -1; \
+	return (type) -1; \
 }
 
 #endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
@@ -1120,21 +1144,7 @@
  * won't be any messing with the stack from main(), but we define
  * some others too.
  */
-static inline _syscall0(pid_t,setsid)
-static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
-static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static inline _syscall1(int,dup,int,fd)
 static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
-static inline _syscall1(int,close,int,fd)
-struct rusage;
-static inline _syscall4(pid_t,wait4,pid_t,pid,int *,stat_addr,int,options,struct rusage *,ru)
-
-static inline pid_t waitpid(int pid, int * wait_stat, int flags)
-{
-	return wait4(pid, wait_stat, flags, NULL);
-}
 
 asmlinkage unsigned long sys_mmap(
 				unsigned long addr, size_t len,
diff -Nru a/include/asm-mips/war.h b/include/asm-mips/war.h
--- a/include/asm-mips/war.h	2004-12-24 13:37:30 -08:00
+++ b/include/asm-mips/war.h	2004-12-24 13:37:30 -08:00
@@ -177,6 +177,14 @@
 #endif
 
 /*
+ * ON the R10000 upto version 2.6 (not sure about 2.7) there is a bug that
+ * may cause ll / sc and lld / scd sequences to execute non-atomically.
+ */
+#ifdef CONFIG_SGI_IP27
+#define R10000_LLSC_WAR 1
+#endif
+
+/*
  * Workarounds default to off
  */
 #ifndef R4600_V1_INDEX_ICACHEOP_WAR
@@ -208,6 +216,9 @@
 #endif
 #ifndef RM9000_CDEX_SMP_WAR
 #define RM9000_CDEX_SMP_WAR		0
+#endif
+#ifndef R10000_LLSC_WAR
+#define R10000_LLSC_WAR			0
 #endif
 
 #endif /* _ASM_WAR_H */
diff -Nru a/include/asm-parisc/assembly.h b/include/asm-parisc/assembly.h
--- a/include/asm-parisc/assembly.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-parisc/assembly.h	2004-12-24 13:36:55 -08:00
@@ -27,8 +27,10 @@
 #define LDREGX  ldd,s
 #define LDREGM	ldd,mb
 #define STREGM	std,ma
+#define SHRREG  shrd
 #define RP_OFFSET	16
 #define FRAME_SIZE	128
+#define CALLEE_SAVE_FRAME_SIZE	144
 #else
 #define LDREG	ldw
 #define STREG	stw
@@ -37,12 +39,19 @@
 #define STREGM	stwm
 #define RP_OFFSET	20
 #define FRAME_SIZE	64
+#define CALLEE_SAVE_FRAME_SIZE	128
 #endif
 
 #ifdef CONFIG_PA20
 #define BL		b,l
+# ifdef CONFIG_PARISC64
+#  define LEVEL		2.0w
+# else
+#  define LEVEL		2.0
+# endif
 #else
 #define BL		bl
+#define LEVEL		1.1
 #endif
 
 #ifdef __ASSEMBLY__
@@ -292,7 +301,7 @@
 
 #ifdef __LP64__
 	.macro	callee_save
-	std,ma	  %r3,	144(%r30)
+	std,ma	  %r3,	CALLEE_SAVE_FRAME_SIZE(%r30)
 	mfctl	  %cr27, %r3
 	std	  %r4,	-136(%r30)
 	std	  %r5,	-128(%r30)
@@ -330,13 +339,13 @@
 	ldd	-128(%r30),    %r5
 	ldd	-136(%r30),    %r4
 	mtctl	%r3, %cr27
-	ldd,mb	-144(%r30),    %r3
+	ldd,mb	-CALLEE_SAVE_FRAME_SIZE(%r30),    %r3
 	.endm
 
 #else /* ! __LP64__ */
 
 	.macro	callee_save
-	stw,ma	 %r3,	128(%r30)
+	stw,ma	 %r3,	CALLEE_SAVE_FRAME_SIZE(%r30)
 	mfctl	 %cr27, %r3
 	stw	 %r4,	-124(%r30)
 	stw	 %r5,	-120(%r30)
@@ -374,7 +383,7 @@
 	ldw	-120(%r30),   %r5
 	ldw	-124(%r30),   %r4
 	mtctl	%r3, %cr27
-	ldw,mb	-128(%r30),   %r3
+	ldw,mb	-CALLEE_SAVE_FRAME_SIZE(%r30),   %r3
 	.endm
 #endif /* ! __LP64__ */
 
diff -Nru a/include/asm-parisc/atomic.h b/include/asm-parisc/atomic.h
--- a/include/asm-parisc/atomic.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-parisc/atomic.h	2004-12-24 13:36:47 -08:00
@@ -14,10 +14,9 @@
  */
 
 #ifdef CONFIG_SMP
+#include <asm/spinlock.h>
 #include <asm/cache.h>		/* we use L1_CACHE_BYTES */
 
-typedef spinlock_t atomic_lock_t;
-
 /* Use an array of spinlocks for our atomic_ts.
  * Hash function to index into a different SPINLOCK.
  * Since "a" is usually an address, use one spinlock per cacheline.
@@ -25,44 +24,35 @@
 #  define ATOMIC_HASH_SIZE 4
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
 
-extern atomic_lock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
+extern spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
 
-static inline void atomic_spin_lock(atomic_lock_t *a)
-{
-	while (__ldcw(a) == 0)
-		while (a->lock[0] == 0);
-}
+/* Can't use _raw_spin_lock_irq because of #include problems, so
+ * this is the substitute */
+#define _atomic_spin_lock_irqsave(l,f) do {	\
+	spinlock_t *s = ATOMIC_HASH(l);		\
+	local_irq_save(f);			\
+	_raw_spin_lock(s);			\
+} while(0)
+
+#define _atomic_spin_unlock_irqrestore(l,f) do {	\
+	spinlock_t *s = ATOMIC_HASH(l);			\
+	_raw_spin_unlock(s);				\
+	local_irq_restore(f);				\
+} while(0)
 
-static inline void atomic_spin_unlock(atomic_lock_t *a)
-{
-	a->lock[0] = 1;
-}
 
 #else
-#  define ATOMIC_HASH_SIZE 1
-#  define ATOMIC_HASH(a)	(0)
-#  define atomic_spin_lock(x) (void)(x)
-#  define atomic_spin_unlock(x) do { } while(0)
+#  define _atomic_spin_lock_irqsave(l,f) do { local_irq_save(f); } while (0)
+#  define _atomic_spin_unlock_irqrestore(l,f) do { local_irq_restore(f); } while (0)
 #endif
 
-/* copied from <linux/spinlock.h> and modified */
-#define atomic_spin_lock_irqsave(lock, flags)	do { 	\
-	local_irq_save(flags);				\
-	atomic_spin_lock(lock); 			\
-} while (0)
-
-#define atomic_spin_unlock_irqrestore(lock, flags) do {	\
-	atomic_spin_unlock(lock);			\
-	local_irq_restore(flags);			\
-} while (0)
-
 /* Note that we need not lock read accesses - aligned word writes/reads
  * are atomic, so a reader never sees unconsistent values.
  *
  * Cache-line alignment would conflict with, for example, linux/module.h
  */
 
-typedef struct { volatile long counter; } atomic_t;
+typedef struct { volatile int counter; } atomic_t;
 
 
 /* This should get optimized out since it's never called.
@@ -150,22 +140,22 @@
 {
 	int ret;
 	unsigned long flags;
-	atomic_spin_lock_irqsave(ATOMIC_HASH(v), flags);
+	_atomic_spin_lock_irqsave(v, flags);
 
 	ret = (v->counter += i);
 
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
+	_atomic_spin_unlock_irqrestore(v, flags);
 	return ret;
 }
 
 static __inline__ void atomic_set(atomic_t *v, int i) 
 {
 	unsigned long flags;
-	atomic_spin_lock_irqsave(ATOMIC_HASH(v), flags);
+	_atomic_spin_lock_irqsave(v, flags);
 
 	v->counter = i;
 
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
+	_atomic_spin_unlock_irqrestore(v, flags);
 }
 
 static __inline__ int atomic_read(const atomic_t *v)
diff -Nru a/include/asm-parisc/bitops.h b/include/asm-parisc/bitops.h
--- a/include/asm-parisc/bitops.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-parisc/bitops.h	2004-12-24 13:36:17 -08:00
@@ -38,9 +38,9 @@
 
 	addr += (nr >> SHIFT_PER_LONG);
 	mask = 1L << CHOP_SHIFTCOUNT(nr);
-	atomic_spin_lock_irqsave(ATOMIC_HASH(addr), flags);
+	_atomic_spin_lock_irqsave(addr, flags);
 	*addr |= mask;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
+	_atomic_spin_unlock_irqrestore(addr, flags);
 }
 
 static __inline__ void __set_bit(int nr, volatile unsigned long * address)
@@ -61,9 +61,9 @@
 
 	addr += (nr >> SHIFT_PER_LONG);
 	mask = 1L << CHOP_SHIFTCOUNT(nr);
-	atomic_spin_lock_irqsave(ATOMIC_HASH(addr), flags);
+	_atomic_spin_lock_irqsave(addr, flags);
 	*addr &= ~mask;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
+	_atomic_spin_unlock_irqrestore(addr, flags);
 }
 
 static __inline__ void __clear_bit(unsigned long nr, volatile unsigned long * address)
@@ -84,9 +84,9 @@
 
 	addr += (nr >> SHIFT_PER_LONG);
 	mask = 1L << CHOP_SHIFTCOUNT(nr);
-	atomic_spin_lock_irqsave(ATOMIC_HASH(addr), flags);
+	_atomic_spin_lock_irqsave(addr, flags);
 	*addr ^= mask;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
+	_atomic_spin_unlock_irqrestore(addr, flags);
 }
 
 static __inline__ void __change_bit(int nr, volatile unsigned long * address)
@@ -108,10 +108,10 @@
 
 	addr += (nr >> SHIFT_PER_LONG);
 	mask = 1L << CHOP_SHIFTCOUNT(nr);
-	atomic_spin_lock_irqsave(ATOMIC_HASH(addr), flags);
+	_atomic_spin_lock_irqsave(addr, flags);
 	oldbit = (*addr & mask) ? 1 : 0;
 	*addr |= mask;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
+	_atomic_spin_unlock_irqrestore(addr, flags);
 
 	return oldbit;
 }
@@ -139,10 +139,10 @@
 
 	addr += (nr >> SHIFT_PER_LONG);
 	mask = 1L << CHOP_SHIFTCOUNT(nr);
-	atomic_spin_lock_irqsave(ATOMIC_HASH(addr), flags);
+	_atomic_spin_lock_irqsave(addr, flags);
 	oldbit = (*addr & mask) ? 1 : 0;
 	*addr &= ~mask;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
+	_atomic_spin_unlock_irqrestore(addr, flags);
 
 	return oldbit;
 }
@@ -170,10 +170,10 @@
 
 	addr += (nr >> SHIFT_PER_LONG);
 	mask = 1L << CHOP_SHIFTCOUNT(nr);
-	atomic_spin_lock_irqsave(ATOMIC_HASH(addr), flags);
+	_atomic_spin_lock_irqsave(addr, flags);
 	oldbit = (*addr & mask) ? 1 : 0;
 	*addr ^= mask;
-	atomic_spin_unlock_irqrestore(ATOMIC_HASH(addr), flags);
+	_atomic_spin_unlock_irqrestore(addr, flags);
 
 	return oldbit;
 }
diff -Nru a/include/asm-parisc/bug.h b/include/asm-parisc/bug.h
--- a/include/asm-parisc/bug.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-parisc/bug.h	2004-12-24 13:37:03 -08:00
@@ -1,4 +1,12 @@
 #ifndef _PARISC_BUG_H
 #define _PARISC_BUG_H
+
+#define HAVE_ARCH_BUG
+#define BUG() do { \
+	printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
+	dump_stack(); \
+	panic("BUG!"); \
+} while (0)
+
 #include <asm-generic/bug.h>
 #endif
diff -Nru a/include/asm-parisc/errno.h b/include/asm-parisc/errno.h
--- a/include/asm-parisc/errno.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-parisc/errno.h	2004-12-24 13:37:19 -08:00
@@ -67,6 +67,10 @@
 #define	EREMOTEIO	181	/* Remote I/O error */
 #define	ENOMEDIUM	182	/* No medium found */
 #define	EMEDIUMTYPE	183	/* Wrong medium type */
+#define	ENOKEY		184	/* Required key not available */
+#define	EKEYEXPIRED	185	/* Key has expired */
+#define	EKEYREVOKED	186	/* Key has been revoked */
+#define	EKEYREJECTED	187	/* Key was rejected by service */
 
 /* We now return you to your regularly scheduled HPUX. */
 
diff -Nru a/include/asm-parisc/hardirq.h b/include/asm-parisc/hardirq.h
--- a/include/asm-parisc/hardirq.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-parisc/hardirq.h	2004-12-24 13:37:19 -08:00
@@ -28,28 +28,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption counter. The bitmask has the
- * following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-31 are the hardirq count (max # of hardirqs: 65536)
- *
- * - (bit 63 is the PREEMPT_ACTIVE flag---not currently implemented.)
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0xffff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	16
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have space for potentially all IRQ sources
diff -Nru a/include/asm-parisc/io.h b/include/asm-parisc/io.h
--- a/include/asm-parisc/io.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-parisc/io.h	2004-12-24 13:36:18 -08:00
@@ -177,6 +177,8 @@
 #define readl_relaxed(addr) readl(addr)
 #define readq_relaxed(addr) readq(addr)
 
+#define mmiowb()
+
 extern void __memcpy_fromio(unsigned long dest, unsigned long src, int count);
 extern void __memcpy_toio(unsigned long dest, unsigned long src, int count);
 extern void __memset_io(unsigned long dest, char fill, int count);
diff -Nru a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h
--- a/include/asm-parisc/pci.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-parisc/pci.h	2004-12-24 13:37:03 -08:00
@@ -4,6 +4,8 @@
 #include <linux/config.h>
 #include <asm/scatterlist.h>
 
+
+
 /*
 ** HP PCI platforms generally support multiple bus adapters.
 **    (workstations 1-~4, servers 2-~32)
@@ -35,6 +37,7 @@
 	struct resource lmmio_space;	/* bus addresses < 4Gb */
 	struct resource elmmio_space;	/* additional bus addresses < 4Gb */
 	struct resource gmmio_space;	/* bus addresses > 4Gb */
+
 	/* NOTE: Dino code assumes it can use *all* of the lmmio_space,
 	 * elmmio_space and gmmio_space as a contiguous array of
 	 * resources.  This #define represents the array size */
@@ -43,6 +46,12 @@
 	unsigned long   lmmio_space_offset;  /* CPU view - PCI view */
 	void *          iommu;          /* IOMMU this device is under */
 	/* REVISIT - spinlock to protect resources? */
+
+	#define HBA_NAME_SIZE 16
+	char io_name[HBA_NAME_SIZE];
+	char lmmio_name[HBA_NAME_SIZE];
+	char elmmio_name[HBA_NAME_SIZE];
+	char gmmio_name[HBA_NAME_SIZE];
 };
 
 #define HBA_DATA(d)		((struct pci_hba_data *) (d))
@@ -60,12 +69,35 @@
 #define PCI_PORT_HBA(a)		((a) >> HBA_PORT_SPACE_BITS)
 #define PCI_PORT_ADDR(a)	((a) & (HBA_PORT_SPACE_SIZE - 1))
 
+#if CONFIG_PARISC64
+#define PCI_F_EXTEND		0xffffffff00000000UL
+#define PCI_IS_LMMIO(hba,a)	pci_is_lmmio(hba,a)
+
+/* We need to know if an address is LMMMIO or GMMIO.
+ * LMMIO requires mangling and GMMIO we must use as-is.
+ */
+static __inline__  int pci_is_lmmio(struct pci_hba_data *hba, unsigned long a)
+{
+	return(((a) & PCI_F_EXTEND) == PCI_F_EXTEND);
+}
+
 /*
 ** Convert between PCI (IO_VIEW) addresses and processor (PA_VIEW) addresses.
-** Note that we currently support only LMMIO.
+** See pcibios.c for more conversions used by Generic PCI code.
 */
-#define PCI_BUS_ADDR(hba,a)	((a) - hba->lmmio_space_offset)
+#define PCI_BUS_ADDR(hba,a)	(PCI_IS_LMMIO(hba,a)	\
+		?  ((a) - hba->lmmio_space_offset)	/* mangle LMMIO */ \
+		: (a))					/* GMMIO */
 #define PCI_HOST_ADDR(hba,a)	((a) + hba->lmmio_space_offset)
+
+#else	/* !CONFIG_PARISC64 */
+
+#define PCI_BUS_ADDR(hba,a)	(a)
+#define PCI_HOST_ADDR(hba,a)	(a)
+#define PCI_F_EXTEND		0UL
+#define PCI_IS_LMMIO(hba,a)	(1)	/* 32-bit doesn't support GMMIO */
+
+#endif /* !CONFIG_PARISC64 */
 
 /*
 ** KLUGE: linux/pci.h include asm/pci.h BEFORE declaring struct pci_bus
diff -Nru a/include/asm-parisc/pdc.h b/include/asm-parisc/pdc.h
--- a/include/asm-parisc/pdc.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-parisc/pdc.h	2004-12-24 13:36:16 -08:00
@@ -754,6 +754,7 @@
 int pdc_iodc_getc(void);
 void pdc_iodc_putc(unsigned char c);
 void pdc_iodc_outc(unsigned char c);
+void pdc_printf(const char *fmt, ...);
 
 void pdc_emergency_unlock(void);
 int pdc_sti_call(unsigned long func, unsigned long flags,
diff -Nru a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h
--- a/include/asm-parisc/pgtable.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-parisc/pgtable.h	2004-12-24 13:37:19 -08:00
@@ -505,7 +505,8 @@
 
 #endif /* !__ASSEMBLY__ */
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 /* We provide our own get_unmapped_area to provide cache coherency */
 
diff -Nru a/include/asm-parisc/posix_types.h b/include/asm-parisc/posix_types.h
--- a/include/asm-parisc/posix_types.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-parisc/posix_types.h	2004-12-24 13:37:18 -08:00
@@ -15,7 +15,7 @@
 typedef unsigned int		__kernel_uid_t;
 typedef unsigned int		__kernel_gid_t;
 typedef int			__kernel_suseconds_t;
-typedef int			__kernel_clock_t;
+typedef long			__kernel_clock_t;
 typedef int			__kernel_timer_t;
 typedef int			__kernel_clockid_t;
 typedef int			__kernel_daddr_t;
diff -Nru a/include/asm-parisc/ptrace.h b/include/asm-parisc/ptrace.h
--- a/include/asm-parisc/ptrace.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-parisc/ptrace.h	2004-12-24 13:36:48 -08:00
@@ -46,7 +46,8 @@
 #ifdef __KERNEL__
 
 /* XXX should we use iaoq[1] or iaoq[0] ? */
-#define user_mode(regs)			(((regs)->iaoq[0] &  3) ? 1 : 0)
+#define user_mode(regs)			(((regs)->iaoq[0] & 3) ? 1 : 0)
+#define user_space(regs)		(((regs)->iasq[0] != 0) ? 1 : 0)
 #define instruction_pointer(regs)	((regs)->iaoq[0] & ~3)
 #define profile_pc(regs) instruction_pointer(regs)
 extern void show_regs(struct pt_regs *);
diff -Nru a/include/asm-parisc/som.h b/include/asm-parisc/som.h
--- a/include/asm-parisc/som.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,8 +0,0 @@
-#ifndef _ASM_PARISC_SOM_H
-#define _ASM_PARISC_SOM_H
-
-/* File format definition for SOM executables / shared libraries */
-#include <linux/som.h>
-
-
-#endif /* _ASM_PARISC_SOM_H
diff -Nru a/include/asm-parisc/spinlock.h b/include/asm-parisc/spinlock.h
--- a/include/asm-parisc/spinlock.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-parisc/spinlock.h	2004-12-24 13:37:43 -08:00
@@ -27,21 +27,35 @@
 
 static inline void _raw_spin_lock(spinlock_t *x)
 {
-	volatile unsigned int *a = __ldcw_align(x);
+	volatile unsigned int *a;
+
+	mb();
+	a = __ldcw_align(x);
 	while (__ldcw(a) == 0)
 		while (*a == 0);
+	mb();
 }
 
 static inline void _raw_spin_unlock(spinlock_t *x)
 {
-	volatile unsigned int *a = __ldcw_align(x);
+	volatile unsigned int *a;
+	mb();
+	a = __ldcw_align(x);
 	*a = 1;
+	mb();
 }
 
 static inline int _raw_spin_trylock(spinlock_t *x)
 {
-	volatile unsigned int *a = __ldcw_align(x);
-	return __ldcw(a) != 0;
+	volatile unsigned int *a;
+	int ret;
+
+	mb();
+	a = __ldcw_align(x);
+        ret = __ldcw(a) != 0;
+	mb();
+
+	return ret;
 }
 	
 #define spin_lock_own(LOCK, LOCATION)	((void)0)
@@ -207,6 +221,26 @@
 	rw->counter = 0;
 	_raw_spin_unlock(&rw->lock);
 }
+
+#ifdef CONFIG_DEBUG_RWLOCK
+extern void _dbg_write_trylock(rwlock_t * rw, const char *bfile, int bline);
+#define _raw_write_trylock(rw) _dbg_write_trylock(rw, __FILE__, __LINE__)
+#else
+static  __inline__ int _raw_write_trylock(rwlock_t *rw)
+{
+	_raw_spin_lock(&rw->lock);
+	if (rw->counter != 0) {
+		/* this basically never happens */
+		_raw_spin_unlock(&rw->lock);
+
+		return 0;
+	}
+
+	/* got it.  now leave without unlocking */
+	rw->counter = -1; /* remember we are locked */
+	return 1;
+}
+#endif /* CONFIG_DEBUG_RWLOCK */
 
 static __inline__ int is_read_locked(rwlock_t *rw)
 {
diff -Nru a/include/asm-parisc/string.h b/include/asm-parisc/string.h
--- a/include/asm-parisc/string.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-parisc/string.h	2004-12-24 13:37:02 -08:00
@@ -1,3 +1,13 @@
+#ifndef _PA_STRING_H_
+#define _PA_STRING_H_
 
 #define __HAVE_ARCH_MEMSET
 extern void * memset(void *, int, size_t);
+
+#define __HAVE_ARCH_MEMCPY
+void * memcpy(void * dest,const void *src,size_t count);
+
+#define __HAVE_ARCH_BCOPY
+void bcopy(const void * srcp, void * destp, size_t count);
+
+#endif
diff -Nru a/include/asm-parisc/superio.h b/include/asm-parisc/superio.h
--- a/include/asm-parisc/superio.h	2004-12-24 13:36:34 -08:00
+++ b/include/asm-parisc/superio.h	2004-12-24 13:36:34 -08:00
@@ -87,6 +87,5 @@
 extern void superio_serial_init(void);		/* called by rs_init() */
 extern int superio_fixup_irq(struct pci_dev *pcidev); /* called by iosapic */
 extern void superio_fixup_pci(struct pci_dev *pdev);
-extern void superio_ide_init_iops (struct hwif_s *hwif);
 
 #endif /* _PARISC_SUPERIO_H */
diff -Nru a/include/asm-parisc/system.h b/include/asm-parisc/system.h
--- a/include/asm-parisc/system.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-parisc/system.h	2004-12-24 13:37:00 -08:00
@@ -80,7 +80,7 @@
 #define mtctl(gr, cr) \
 	__asm__ __volatile__("mtctl %0,%1" \
 		: /* no outputs */ \
-		: "r" (gr), "i" (cr))
+		: "r" (gr), "i" (cr) : "memory")
 
 /* these are here to de-mystefy the calling code, and to provide hooks */
 /* which I needed for debugging EIEM problems -PB */
@@ -102,7 +102,7 @@
 #define mtsp(gr, cr) \
 	__asm__ __volatile__("mtsp %0,%1" \
 		: /* no outputs */ \
-		: "r" (gr), "i" (cr))
+		: "r" (gr), "i" (cr) : "memory")
 
 
 /*
@@ -154,7 +154,7 @@
    for the semaphore.  */
 #define __PA_LDCW_ALIGNMENT 16
 #define __ldcw_align(a) ({ \
-  unsigned long __ret = (unsigned long) a;                     		\
+  unsigned long __ret = (unsigned long) &(a)->lock[0];        		\
   __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) & ~(__PA_LDCW_ALIGNMENT - 1); \
   (volatile unsigned int *) __ret;                                      \
 })
@@ -183,5 +183,23 @@
 #endif
 
 #define KERNEL_START (0x10100000 - 0x1000)
+
+/* This is for the serialisation of PxTLB broadcasts.  At least on the
+ * N class systems, only one PxTLB inter processor broadcast can be
+ * active at any one time on the Merced bus.  This tlb purge
+ * synchronisation is fairly lightweight and harmless so we activate
+ * it on all SMP systems not just the N class. */
+#ifdef CONFIG_SMP
+extern spinlock_t pa_tlb_lock;
+
+#define purge_tlb_start(x) spin_lock(&pa_tlb_lock)
+#define purge_tlb_end(x) spin_unlock(&pa_tlb_lock)
+
+#else
+
+#define purge_tlb_start(x) do { } while(0)
+#define purge_tlb_end(x) do { } while (0)
+
+#endif
 
 #endif
diff -Nru a/include/asm-parisc/thread_info.h b/include/asm-parisc/thread_info.h
--- a/include/asm-parisc/thread_info.h	2004-12-24 13:36:33 -08:00
+++ b/include/asm-parisc/thread_info.h	2004-12-24 13:36:33 -08:00
@@ -18,12 +18,15 @@
 
 #define INIT_THREAD_INFO(tsk)			\
 {						\
-	task:		&tsk,			\
-	exec_domain:	&default_exec_domain,	\
-	flags:		0,			\
-	cpu:		0,			\
-	addr_limit:	KERNEL_DS,		\
-	preempt_count:	0,			\
+	.task		= &tsk,			\
+	.exec_domain	= &default_exec_domain,	\
+	.flags		= 0,			\
+	.cpu		= 0,			\
+	.addr_limit	= KERNEL_DS,		\
+	.preempt_count	= 0,			\
+  	.restart_block	= {			\
+		.fn = do_no_restart_syscall	\
+	}					\
 }
 
 #define init_thread_info        (init_thread_union.thread_info)
diff -Nru a/include/asm-parisc/tlbflush.h b/include/asm-parisc/tlbflush.h
--- a/include/asm-parisc/tlbflush.h	2004-12-24 13:37:30 -08:00
+++ b/include/asm-parisc/tlbflush.h	2004-12-24 13:37:30 -08:00
@@ -51,9 +51,12 @@
 {
 	/* For one page, it's not worth testing the split_tlb variable */
 
+	mb();
 	mtsp(vma->vm_mm->context,1);
+	purge_tlb_start();
 	pdtlb(addr);
 	pitlb(addr);
+	purge_tlb_end();
 }
 
 static inline void flush_tlb_range(struct vm_area_struct *vma,
@@ -61,6 +64,7 @@
 {
 	unsigned long npages;
 
+	
 	npages = ((end - (start & PAGE_MASK)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
 	if (npages >= 512)  /* XXX arbitrary, should be tuned */
 		flush_tlb_all();
@@ -68,16 +72,20 @@
 
 		mtsp(vma->vm_mm->context,1);
 		if (split_tlb) {
+			purge_tlb_start();
 			while (npages--) {
 				pdtlb(start);
 				pitlb(start);
 				start += PAGE_SIZE;
 			}
+			purge_tlb_end();
 		} else {
+			purge_tlb_start();
 			while (npages--) {
 				pdtlb(start);
 				start += PAGE_SIZE;
 			}
+			purge_tlb_end();
 		}
 	}
 }
diff -Nru a/include/asm-parisc/uaccess.h b/include/asm-parisc/uaccess.h
--- a/include/asm-parisc/uaccess.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-parisc/uaccess.h	2004-12-24 13:36:31 -08:00
@@ -8,6 +8,7 @@
 #include <asm/page.h>
 #include <asm/system.h>
 #include <asm/cache.h>
+#include <asm-generic/uaccess.h>
 
 #define VERIFY_READ 0
 #define VERIFY_WRITE 1
@@ -54,16 +55,22 @@
 /*
  * The exception table contains two values: the first is an address
  * for an instruction that is allowed to fault, and the second is
- * the number of bytes to skip if a fault occurs. We also support in
- * two bit flags: 0x2 tells the exception handler to clear register
- * r9 and 0x1 tells the exception handler to put -EFAULT in r8.
- * This allows us to handle the simple cases for put_user and
- * get_user without having to have .fixup sections.
+ * the address to the fixup routine. 
  */
 
 struct exception_table_entry {
 	unsigned long insn;  /* address of insn that is allowed to fault.   */
-	long skip;           /* pcoq skip | r9 clear flag | r8 -EFAULT flag */
+	long fixup;          /* fixup routine */
+};
+
+/*
+ * The page fault handler stores, in a per-cpu area, the following information
+ * if a fixup routine is available.
+ */
+struct exception_data {
+	unsigned long fault_ip;
+	unsigned long fault_space;
+	unsigned long fault_addr;
 };
 
 #define __get_user(x,ptr)                               \
@@ -97,48 +104,44 @@
 #ifdef __LP64__
 #define __get_kernel_asm(ldx,ptr)                       \
 	__asm__("\n1:\t" ldx "\t0(%2),%0\n"             \
-		"2:\n"					\
-		"\t.section __ex_table,\"aw\"\n"         \
-		 "\t.dword\t1b\n"                       \
-		 "\t.dword\t(2b-1b)+3\n"                \
-		 "\t.previous"                          \
+		"\t.section __ex_table,\"aw\"\n"        \
+		"\t.dword\t1b,fixup_get_user_skip_1\n"	\
+		"\t.previous"                          	\
 		: "=r"(__gu_val), "=r"(__gu_err)        \
-		: "r"(ptr), "1"(__gu_err));
+		: "r"(ptr), "1"(__gu_err)		\
+		: "r1");
 
 #define __get_user_asm(ldx,ptr)                         \
 	__asm__("\n1:\t" ldx "\t0(%%sr3,%2),%0\n"       \
-		"2:\n"					\
-		"\t.section __ex_table,\"aw\"\n"         \
-		 "\t.dword\t1b\n"                       \
-		 "\t.dword\t(2b-1b)+3\n"                \
-		 "\t.previous"                          \
+		"\t.section __ex_table,\"aw\"\n"	\
+		"\t.dword\t1b,fixup_get_user_skip_1\n"	\
+		"\t.previous"				\
 		: "=r"(__gu_val), "=r"(__gu_err)        \
-		: "r"(ptr), "1"(__gu_err));
+		: "r"(ptr), "1"(__gu_err)		\
+		: "r1");
 #else
 #define __get_kernel_asm(ldx,ptr)                       \
 	__asm__("\n1:\t" ldx "\t0(%2),%0\n"             \
-		"2:\n"					\
-		"\t.section __ex_table,\"aw\"\n"         \
-		 "\t.word\t1b\n"                        \
-		 "\t.word\t(2b-1b)+3\n"                 \
-		 "\t.previous"                          \
+		"\t.section __ex_table,\"aw\"\n"        \
+		"\t.word\t1b,fixup_get_user_skip_1\n"	\
+		"\t.previous"                          	\
 		: "=r"(__gu_val), "=r"(__gu_err)        \
-		: "r"(ptr), "1"(__gu_err));
+		: "r"(ptr), "1"(__gu_err)		\
+		: "r1");
 
 #define __get_user_asm(ldx,ptr)                         \
 	__asm__("\n1:\t" ldx "\t0(%%sr3,%2),%0\n"       \
-		"2:\n"					\
-		"\t.section __ex_table,\"aw\"\n"         \
-		 "\t.word\t1b\n"                        \
-		 "\t.word\t(2b-1b)+3\n"                 \
+		"\t.section __ex_table,\"aw\"\n"	\
+		 "\t.word\t1b,fixup_get_user_skip_1\n"	\
 		 "\t.previous"                          \
 		: "=r"(__gu_val), "=r"(__gu_err)        \
-		: "r"(ptr), "1"(__gu_err));
+		: "r"(ptr), "1"(__gu_err)		\
+		: "r1");
 #endif /* !__LP64__ */
 
 #define __put_user(x,ptr)                                       \
 ({								\
-	register long __pu_err __asm__ ("r8") = 0;		\
+	register long __pu_err __asm__ ("r8") = 0;      	\
 								\
 	if (segment_eq(get_fs(),KERNEL_DS)) {                   \
 	    switch (sizeof(*(ptr))) {                           \
@@ -172,82 +175,73 @@
 #define __put_kernel_asm(stx,x,ptr)                         \
 	__asm__ __volatile__ (                              \
 		"\n1:\t" stx "\t%2,0(%1)\n"                 \
-		"2:\n"					    \
-		"\t.section __ex_table,\"aw\"\n"             \
-		 "\t.dword\t1b\n"                           \
-		 "\t.dword\t(2b-1b)+1\n"                    \
-		 "\t.previous"                              \
+		"\t.section __ex_table,\"aw\"\n"            \
+		"\t.dword\t1b,fixup_put_user_skip_1\n"	    \
+		"\t.previous"                               \
 		: "=r"(__pu_err)                            \
 		: "r"(ptr), "r"(x), "0"(__pu_err))
 
 #define __put_user_asm(stx,x,ptr)                           \
 	__asm__ __volatile__ (                              \
 		"\n1:\t" stx "\t%2,0(%%sr3,%1)\n"           \
-		"2:\n"					    \
-		"\t.section __ex_table,\"aw\"\n"             \
-		 "\t.dword\t1b\n"                           \
-		 "\t.dword\t(2b-1b)+1\n"                    \
+		"\t.section __ex_table,\"aw\"\n"            \
+		 "\t.dword\t1b,fixup_put_user_skip_1\n"	    \
 		 "\t.previous"                              \
 		: "=r"(__pu_err)                            \
-		: "r"(ptr), "r"(x), "0"(__pu_err))
+		: "r"(ptr), "r"(x), "0"(__pu_err)	    \
+		: "r1")
 #else
 #define __put_kernel_asm(stx,x,ptr)                         \
 	__asm__ __volatile__ (                              \
 		"\n1:\t" stx "\t%2,0(%1)\n"                 \
-		"2:\n"					    \
-		"\t.section __ex_table,\"aw\"\n"             \
-		 "\t.word\t1b\n"                            \
-		 "\t.word\t(2b-1b)+1\n"                     \
+		"\t.section __ex_table,\"aw\"\n"            \
+		 "\t.word\t1b,fixup_put_user_skip_1\n"	    \
 		 "\t.previous"                              \
 		: "=r"(__pu_err)                            \
-		: "r"(ptr), "r"(x), "0"(__pu_err))
+		: "r"(ptr), "r"(x), "0"(__pu_err)	    \
+		: "r1")
 
 #define __put_user_asm(stx,x,ptr)                           \
 	__asm__ __volatile__ (                              \
 		"\n1:\t" stx "\t%2,0(%%sr3,%1)\n"           \
-		"2:\n"					    \
-		"\t.section __ex_table,\"aw\"\n"             \
-		 "\t.word\t1b\n"                            \
-		 "\t.word\t(2b-1b)+1\n"                     \
+		"\t.section __ex_table,\"aw\"\n"            \
+		 "\t.word\t1b,fixup_put_user_skip_1\n"      \
 		 "\t.previous"                              \
 		: "=r"(__pu_err)                            \
-		: "r"(ptr), "r"(x), "0"(__pu_err))
+		: "r"(ptr), "r"(x), "0"(__pu_err)	    \
+		: "r1")
 
-static inline void __put_kernel_asm64(u64 x, void *ptr)
-{
-	u32 hi = x>>32;
-	u32 lo = x&0xffffffff;
-	__asm__ __volatile__ (
-		"\n1:\tstw %1,0(%0)\n"
-		"\n2:\tstw %2,4(%0)\n"
-		"3:\n"
-		"\t.section __ex_table,\"aw\"\n"
-		 "\t.word\t1b\n"
-		 "\t.word\t(3b-1b)+1\n"
-		 "\t.word\t2b\n"
-		 "\t.word\t(3b-2b)+1\n"
-		 "\t.previous"
-		: : "r"(ptr), "r"(hi), "r"(lo));
-
-}
-
-static inline void __put_user_asm64(u64 x, void *ptr)
-{
-	u32 hi = x>>32;
-	u32 lo = x&0xffffffff;
-	__asm__ __volatile__ (
-		"\n1:\tstw %1,0(%%sr3,%0)\n"
-		"\n2:\tstw %2,4(%%sr3,%0)\n"
-		"3:\n"
-		"\t.section __ex_table,\"aw\"\n"
-		 "\t.word\t1b\n"
-		 "\t.word\t(3b-1b)+1\n"
-		 "\t.word\t2b\n"
-		 "\t.word\t(3b-2b)+1\n"
-		 "\t.previous"
-		: : "r"(ptr), "r"(hi), "r"(lo));
-
-}
+#define __put_kernel_asm64(__val,ptr) do {		    	    \
+	u64 __val64 = (u64)(__val);				    \
+	u32 hi = (__val64) >> 32;					    \
+	u32 lo = (__val64) & 0xffffffff;				    \
+	__asm__ __volatile__ (				    \
+		"\n1:\tstw %2,0(%1)\n"			    \
+		"\n2:\tstw %3,4(%1)\n"			    \
+		"\t.section __ex_table,\"aw\"\n"	    \
+		 "\t.word\t1b,fixup_put_user_skip_2\n"	    \
+		 "\t.word\t2b,fixup_put_user_skip_1\n"	    \
+		 "\t.previous"				    \
+		: "=r"(__pu_err)                            \
+		: "r"(ptr), "r"(hi), "r"(lo), "0"(__pu_err) \
+		: "r1");				    \
+} while (0)
+
+#define __put_user_asm64(__val,ptr) do {		    	    \
+	u64 __val64 = (u64)__val;				    \
+	u32 hi = (__val64) >> 32;					    \
+	u32 lo = (__val64) & 0xffffffff;				    \
+	__asm__ __volatile__ (				    \
+		"\n1:\tstw %2,0(%%sr3,%1)\n"		    \
+		"\n2:\tstw %3,4(%%sr3,%1)\n"		    \
+		"\t.section __ex_table,\"aw\"\n"	    \
+		 "\t.word\t1b,fixup_get_user_skip_2\n"	    \
+		 "\t.word\t2b,fixup_get_user_skip_1\n"	    \
+		 "\t.previous"				    \
+		: "=r"(__pu_err)                            \
+		: "r"(ptr), "r"(hi), "r"(lo), "0"(__pu_err) \
+		: "r1");				    \
+} while (0)
 
 #endif /* !__LP64__ */
 
@@ -273,12 +267,12 @@
 #define clear_user lclear_user
 #define __clear_user lclear_user
 
-#define copy_from_user lcopy_from_user
-#define __copy_from_user lcopy_from_user
-#define copy_to_user lcopy_to_user
-#define __copy_to_user lcopy_to_user
-#define copy_in_user lcopy_in_user
-#define __copy_in_user lcopy_in_user
+unsigned long copy_to_user(void __user *dst, const void *src, unsigned long len);
+#define __copy_to_user copy_to_user
+unsigned long copy_from_user(void *dst, const void __user *src, unsigned long len);
+#define __copy_from_user copy_from_user
+unsigned long copy_in_user(void __user *dst, const void __user *src, unsigned long len);
+#define __copy_in_user copy_in_user
 #define __copy_to_user_inatomic __copy_to_user
 #define __copy_from_user_inatomic __copy_from_user
 
diff -Nru a/include/asm-parisc/unistd.h b/include/asm-parisc/unistd.h
--- a/include/asm-parisc/unistd.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-parisc/unistd.h	2004-12-24 13:36:16 -08:00
@@ -721,14 +721,42 @@
 #define __NR_epoll_wait         (__NR_Linux + 226)
 #define __NR_remap_file_pages   (__NR_Linux + 227)
 #define __NR_semtimedop         (__NR_Linux + 228)
-#define __NR_mq_open            (__NR_Linux + 229) /* Keep the mq_* syscalls together */
+#define __NR_mq_open            (__NR_Linux + 229)
 #define __NR_mq_unlink          (__NR_Linux + 230)
 #define __NR_mq_timedsend       (__NR_Linux + 231)
 #define __NR_mq_timedreceive    (__NR_Linux + 232)
 #define __NR_mq_notify          (__NR_Linux + 233)
 #define __NR_mq_getsetattr      (__NR_Linux + 234)
+#define __NR_waitid		(__NR_Linux + 235)
+#define __NR_fadvise64_64	(__NR_Linux + 236)
+#define __NR_set_tid_address	(__NR_Linux + 237)
+#define __NR_setxattr		(__NR_Linux + 238)
+#define __NR_lsetxattr		(__NR_Linux + 239)
+#define __NR_fsetxattr		(__NR_Linux + 240)
+#define __NR_getxattr		(__NR_Linux + 241)
+#define __NR_lgetxattr		(__NR_Linux + 242)
+#define __NR_fgetxattr		(__NR_Linux + 243)
+#define __NR_listxattr		(__NR_Linux + 244)
+#define __NR_llistxattr		(__NR_Linux + 245)
+#define __NR_flistxattr		(__NR_Linux + 246)
+#define __NR_removexattr	(__NR_Linux + 247)
+#define __NR_lremovexattr	(__NR_Linux + 248)
+#define __NR_fremovexattr	(__NR_Linux + 249)
+#define __NR_timer_create	(__NR_Linux + 250)
+#define __NR_timer_settime	(__NR_Linux + 251)
+#define __NR_timer_gettime	(__NR_Linux + 252)
+#define __NR_timer_getoverrun	(__NR_Linux + 253)
+#define __NR_timer_delete	(__NR_Linux + 254)
+#define __NR_clock_settime	(__NR_Linux + 255)
+#define __NR_clock_gettime	(__NR_Linux + 256)
+#define __NR_clock_getres	(__NR_Linux + 257)
+#define __NR_clock_nanosleep	(__NR_Linux + 258)
+#define __NR_tgkill		(__NR_Linux + 259)
+#define __NR_mbind		(__NR_Linux + 260)
+#define __NR_get_mempolicy	(__NR_Linux + 261)
+#define __NR_set_mempolicy	(__NR_Linux + 262)
 
-#define __NR_Linux_syscalls     235
+#define __NR_Linux_syscalls     263
 
 #define HPUX_GATEWAY_ADDR       0xC0000004
 #define LINUX_GATEWAY_ADDR      0x100
@@ -752,14 +780,10 @@
 
 #ifdef PIC
 /* WARNING: CANNOT BE USED IN A NOP! */
-# define K_STW_PIC stw %r19, -32(%sr0, %sp) ASM_LINE_SEP
-# define K_LDW_PIC ldw -32(%sr0, %sp), %r19 ASM_LINE_SEP
 # define K_STW_ASM_PIC	"       copy %%r19, %%r4\n"
 # define K_LDW_ASM_PIC	"       copy %%r4, %%r19\n"
 # define K_USING_GR4	"%r4",
 #else
-# define K_STW_PIC ASM_LINE_SEP
-# define K_LDW_PIC ASM_LINE_SEP
 # define K_STW_ASM_PIC	" \n"
 # define K_LDW_ASM_PIC	" \n"
 # define K_USING_GR4
@@ -793,7 +817,7 @@
 			K_LDW_ASM_PIC					\
 			: "=r" (__res)					\
 			: "i" (SYS_ify(name)) K_ASM_ARGS_##nr   	\
-			: K_CALL_CLOB_REGS K_CLOB_ARGS_##nr		\
+			: "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_##nr	\
 		);							\
 		__sys_res = (long)__res;				\
 	}								\
diff -Nru a/include/asm-ppc/8xx_immap.h b/include/asm-ppc/8xx_immap.h
--- a/include/asm-ppc/8xx_immap.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-ppc/8xx_immap.h	2004-12-24 13:37:29 -08:00
@@ -92,23 +92,77 @@
 	char	res3[0x80];
 } memctl8xx_t;
 
+/*-----------------------------------------------------------------------
+ * BR - Memory Controler: Base Register					16-9
+ */
+#define BR_BA_MSK	0xffff8000	/* Base Address Mask			*/
+#define BR_AT_MSK	0x00007000	/* Address Type Mask			*/
+#define BR_PS_MSK	0x00000c00	/* Port Size Mask			*/
+#define BR_PS_32	0x00000000	/* 32 bit port size			*/
+#define BR_PS_16	0x00000800	/* 16 bit port size			*/
+#define BR_PS_8		0x00000400	/*  8 bit port size			*/
+#define BR_PARE		0x00000200	/* Parity Enable			*/
+#define BR_WP		0x00000100	/* Write Protect			*/
+#define BR_MS_MSK	0x000000c0	/* Machine Select Mask			*/
+#define BR_MS_GPCM	0x00000000	/* G.P.C.M. Machine Select		*/
+#define BR_MS_UPMA	0x00000080	/* U.P.M.A Machine Select		*/
+#define BR_MS_UPMB	0x000000c0	/* U.P.M.B Machine Select		*/
+#define BR_V		0x00000001	/* Bank Valid				*/
+
+/*-----------------------------------------------------------------------
+ * OR - Memory Controler: Option Register				16-11
+ */
+#define OR_AM_MSK	0xffff8000	/* Address Mask Mask			*/
+#define OR_ATM_MSK	0x00007000	/* Address Type Mask Mask		*/
+#define OR_CSNT_SAM	0x00000800	/* Chip Select Negation Time/ Start	*/
+					/* Address Multiplex			*/
+#define OR_ACS_MSK	0x00000600	/* Address to Chip Select Setup mask	*/
+#define OR_ACS_DIV1	0x00000000	/* CS is output at the same time	*/
+#define OR_ACS_DIV4	0x00000400	/* CS is output 1/4 a clock later	*/
+#define OR_ACS_DIV2	0x00000600	/* CS is output 1/2 a clock later	*/
+#define OR_G5LA		0x00000400	/* Output #GPL5 on #GPL_A5		*/
+#define OR_G5LS		0x00000200	/* Drive #GPL high on falling edge of...*/
+#define OR_BI		0x00000100	/* Burst inhibit			*/
+#define OR_SCY_MSK	0x000000f0	/* Cycle Lenght in Clocks		*/
+#define OR_SCY_0_CLK	0x00000000	/* 0 clock cycles wait states		*/
+#define OR_SCY_1_CLK	0x00000010	/* 1 clock cycles wait states		*/
+#define OR_SCY_2_CLK	0x00000020	/* 2 clock cycles wait states		*/
+#define OR_SCY_3_CLK	0x00000030	/* 3 clock cycles wait states		*/
+#define OR_SCY_4_CLK	0x00000040	/* 4 clock cycles wait states		*/
+#define OR_SCY_5_CLK	0x00000050	/* 5 clock cycles wait states		*/
+#define OR_SCY_6_CLK	0x00000060	/* 6 clock cycles wait states		*/
+#define OR_SCY_7_CLK	0x00000070	/* 7 clock cycles wait states		*/
+#define OR_SCY_8_CLK	0x00000080	/* 8 clock cycles wait states		*/
+#define OR_SCY_9_CLK	0x00000090	/* 9 clock cycles wait states		*/
+#define OR_SCY_10_CLK	0x000000a0	/* 10 clock cycles wait states		*/
+#define OR_SCY_11_CLK	0x000000b0	/* 11 clock cycles wait states		*/
+#define OR_SCY_12_CLK	0x000000c0	/* 12 clock cycles wait states		*/
+#define OR_SCY_13_CLK	0x000000d0	/* 13 clock cycles wait states		*/
+#define OR_SCY_14_CLK	0x000000e0	/* 14 clock cycles wait states		*/
+#define OR_SCY_15_CLK	0x000000f0	/* 15 clock cycles wait states		*/
+#define OR_SETA		0x00000008	/* External Transfer Acknowledge	*/
+#define OR_TRLX		0x00000004	/* Timing Relaxed			*/
+#define OR_EHTR		0x00000002	/* Extended Hold Time on Read		*/
+
 /* System Integration Timers.
 */
 typedef struct	sys_int_timers {
 	ushort	sit_tbscr;
+	char	res0[0x02];
 	uint	sit_tbreff0;
 	uint	sit_tbreff1;
 	char	res1[0x14];
 	ushort	sit_rtcsc;
+	char	res2[0x02];
 	uint	sit_rtc;
 	uint	sit_rtsec;
 	uint	sit_rtcal;
-	char	res2[0x10];
+	char	res3[0x10];
 	ushort	sit_piscr;
-	char	res3[2];
+	char	res4[2];
 	uint	sit_pitc;
 	uint	sit_pitr;
-	char	res4[0x34];
+	char	res5[0x34];
 } sit8xx_t;
 
 #define TBSCR_TBIRQ_MASK	((ushort)0xff00)
@@ -174,20 +228,38 @@
 */
 #define KAPWR_KEY	((unsigned int)0x55ccaa33)
 
-/* LCD interface.  MPC821 and MPC823 Only.
+/* Video interface.  MPC823 Only.
+*/
+typedef struct vid823 {
+	ushort	vid_vccr;
+	ushort	res1;
+	u_char	vid_vsr;
+	u_char	res2;
+	u_char	vid_vcmr;
+	u_char	res3;
+	uint	vid_vbcb;
+	uint	res4;
+	uint	vid_vfcr0;
+	uint	vid_vfaa0;
+	uint	vid_vfba0;
+	uint	vid_vfcr1;
+	uint	vid_vfaa1;
+	uint	vid_vfba1;
+	u_char	res5[0x18];
+} vid823_t;
+
+/* LCD interface.  823 Only.
 */
 typedef struct lcd {
-	ushort	lcd_lcolr[16];
-	char	res[0x20];
 	uint	lcd_lccr;
 	uint	lcd_lchcr;
 	uint	lcd_lcvcr;
-	char	res2[4];
+	char	res1[4];
 	uint	lcd_lcfaa;
 	uint	lcd_lcfba;
 	char	lcd_lcsr;
-	char	res3[0x7];
-} lcd8xx_t;
+	char	res2[0x7];
+} lcd823_t;
 
 /* I2C
 */
@@ -254,7 +326,8 @@
 	ushort	iop_pdpar;
 	char	res3[2];
 	ushort	iop_pddat;
-	char	res4[8];
+	uint	utmode;
+	char	res4[4];
 } iop8xx_t;
 
 /* Communication Processor Module Timers
@@ -290,7 +363,7 @@
 typedef struct scc {		/* Serial communication channels */
 	uint	scc_gsmrl;
 	uint	scc_gsmrh;
-	ushort	scc_pmsr;
+	ushort	scc_psmr;
 	char	res1[2];
 	ushort	scc_todr;
 	ushort	scc_dsr;
@@ -315,41 +388,44 @@
 /* MPC860T Fast Ethernet Controller.  It isn't part of the CPM, but
  * it fits within the address space.
  */
+
 typedef struct fec {
-	uint	fec_addr_low;		/* LS 32 bits of station address */
-	ushort	fec_addr_high;		/* MS 16 bits of address */
-	ushort	res1;
-	uint	fec_hash_table_high;
-	uint	fec_hash_table_low;
-	uint	fec_r_des_start;
-	uint	fec_x_des_start;
-	uint	fec_r_buff_size;
-	uint	res2[9];
-	uint	fec_ecntrl;
-	uint	fec_ievent;
-	uint	fec_imask;
-	uint	fec_ivec;
-	uint	fec_r_des_active;
-	uint	fec_x_des_active;
-	uint	res3[10];
-	uint	fec_mii_data;
-	uint	fec_mii_speed;
-	uint	res4[17];
-	uint	fec_r_bound;
-	uint	fec_r_fstart;
-	uint	res5[6];
-	uint	fec_x_fstart;
-	uint	res6[17];
-	uint	fec_fun_code;
-	uint	res7[3];
-	uint	fec_r_cntrl;
-	uint	fec_r_hash;
-	uint	res8[14];
-	uint	fec_x_cntrl;
-	uint	res9[0x1e];
+	uint	fec_addr_low;		/* lower 32 bits of station address	*/
+	ushort	fec_addr_high;		/* upper 16 bits of station address	*/
+	ushort	res1;			/* reserved				*/
+	uint	fec_hash_table_high;	/* upper 32-bits of hash table		*/
+	uint	fec_hash_table_low;	/* lower 32-bits of hash table		*/
+	uint	fec_r_des_start;	/* beginning of Rx descriptor ring	*/
+	uint	fec_x_des_start;	/* beginning of Tx descriptor ring	*/
+	uint	fec_r_buff_size;	/* Rx buffer size			*/
+	uint	res2[9];		/* reserved				*/
+	uint	fec_ecntrl;		/* ethernet control register		*/
+	uint	fec_ievent;		/* interrupt event register		*/
+	uint	fec_imask;		/* interrupt mask register		*/
+	uint	fec_ivec;		/* interrupt level and vector status	*/
+	uint	fec_r_des_active;	/* Rx ring updated flag			*/
+	uint	fec_x_des_active;	/* Tx ring updated flag			*/
+	uint	res3[10];		/* reserved				*/
+	uint	fec_mii_data;		/* MII data register			*/
+	uint	fec_mii_speed;		/* MII speed control register		*/
+	uint	res4[17];		/* reserved				*/
+	uint	fec_r_bound;		/* end of RAM (read-only)		*/
+	uint	fec_r_fstart;		/* Rx FIFO start address		*/
+	uint	res5[6];		/* reserved				*/
+	uint	fec_x_fstart;		/* Tx FIFO start address		*/
+	uint	res6[17];		/* reserved				*/
+	uint	fec_fun_code;		/* fec SDMA function code		*/
+	uint	res7[3];		/* reserved				*/
+	uint	fec_r_cntrl;		/* Rx control register			*/
+	uint	fec_r_hash;		/* Rx hash register			*/
+	uint	res8[14];		/* reserved				*/
+	uint	fec_x_cntrl;		/* Tx control register			*/
+	uint	res9[0x1e];		/* reserved				*/
 } fec_t;
 
-/* We need this as the fec and fb cmap use the same address space */
+/* The FEC and LCD color map share the same address space....
+ * I guess we will never see an 823T :-).
+ */
 union fec_lcd {
 	fec_t	fl_un_fec;
 	u_char	fl_un_cmap[0x200];
@@ -359,18 +435,20 @@
 	/* General control and status registers.
 	*/
 	ushort	cp_cpcr;
-	char	res1[2];
+	u_char	res1[2];
 	ushort	cp_rccr;
-	char	res2[6];
+	u_char	res2;
+	u_char	cp_rmds;
+	u_char	res3[4];
 	ushort	cp_cpmcr1;
 	ushort	cp_cpmcr2;
 	ushort	cp_cpmcr3;
 	ushort	cp_cpmcr4;
-	char	res3[2];
+	u_char	res4[2];
 	ushort	cp_rter;
-	char	res4[2];
+	u_char	res5[2];
 	ushort	cp_rtmr;
-	char	res5[0x14];
+	u_char	res6[0x14];
 
 	/* Baud rate generators.
 	*/
@@ -390,56 +468,75 @@
 	/* Serial Peripheral Interface.
 	*/
 	ushort	cp_spmode;
-	char	res6[4];
+	u_char	res7[4];
 	u_char	cp_spie;
-	char	res7[3];
+	u_char	res8[3];
 	u_char	cp_spim;
-	char	res8[2];
+	u_char	res9[2];
 	u_char	cp_spcom;
-	char	res9[2];
+	u_char	res10[2];
 
 	/* Parallel Interface Port.
 	*/
-	char	res10[2];
+	u_char	res11[2];
 	ushort	cp_pipc;
-	char	res11[2];
+	u_char	res12[2];
 	ushort	cp_ptpr;
 	uint	cp_pbdir;
 	uint	cp_pbpar;
-	char	res12[2];
+	u_char	res13[2];
 	ushort	cp_pbodr;
 	uint	cp_pbdat;
-	char	res13[0x18];
+
+	/* Port E - MPC87x/88x only.
+	 */
+	uint	cp_pedir;
+	uint	cp_pepar;
+	uint	cp_peso;
+	uint	cp_peodr;
+	uint	cp_pedat;
+
+	/* Communications Processor Timing Register -
+	   Contains RMII Timing for the FECs on MPC87x/88x only.
+	*/
+	uint	cp_cptr;
 
 	/* Serial Interface and Time Slot Assignment.
 	*/
 	uint	cp_simode;
 	u_char	cp_sigmr;
-	char	res14;
+	u_char	res15;
 	u_char	cp_sistr;
 	u_char	cp_sicmr;
-	char	res15[4];
+	u_char	res16[4];
 	uint	cp_sicr;
 	uint	cp_sirp;
-	char	res16[0x10c];
+	u_char	res17[0xc];
+
+	/* 256 bytes of MPC823 video controller RAM array.
+	*/
+	u_char	cp_vcram[0x100];
 	u_char	cp_siram[0x200];
 
 	/* The fast ethernet controller is not really part of the CPM,
 	 * but it resides in the address space.
-	 *
-	 * The colormap for the LCD controller is also located here
+	 * The LCD color map is also here.
 	 */
-	union	fec_lcd fl_un;
-#define cp_fec	fl_un.fl_un_fec
-#define lcd_cmap fl_un.fl_un_cmap
-	char	res18[0x1000];
+	union	fec_lcd	fl_un;
+#define cp_fec		fl_un.fl_un_fec
+#define lcd_cmap	fl_un.fl_un_cmap
+	char	res18[0xE00];
+
+	/* The DUET family has a second FEC here */
+	fec_t	cp_fec2;
+#define cp_fec1	cp_fec	/* consistency macro */
 
 	/* Dual Ported RAM follows.
 	 * There are many different formats for this memory area
 	 * depending upon the devices used and options chosen.
+	 * Some processors don't have all of it populated.
 	 */
-	u_char	cp_dpmem[0x1000];	/* BD / Data / ucode */
-	u_char	res19[0xc00];
+	u_char	cp_dpmem[0x1C00];	/* BD / Data / ucode */
 	u_char	cp_dparam[0x400];	/* Parameter RAM */
 } cpm8xx_t;
 
@@ -453,7 +550,8 @@
 	car8xx_t	im_clkrst;	/* Clocks and reset */
 	sitk8xx_t	im_sitk;	/* Sys int timer keys */
 	cark8xx_t	im_clkrstk;	/* Clocks and reset keys */
-	lcd8xx_t	im_lcd;		/* LCD (821 and 823 only) */
+	vid823_t	im_vid;		/* Video (823 only) */
+	lcd823_t	im_lcd;		/* LCD (823 only) */
 	i2c8xx_t	im_i2c;		/* I2C control/status */
 	sdma8xx_t	im_sdma;	/* SDMA control/status */
 	cpic8xx_t	im_cpic;	/* CPM Interrupt Controller */
diff -Nru a/include/asm-ppc/commproc.h b/include/asm-ppc/commproc.h
--- a/include/asm-ppc/commproc.h	2004-12-24 13:36:59 -08:00
+++ b/include/asm-ppc/commproc.h	2004-12-24 13:36:59 -08:00
@@ -19,6 +19,7 @@
 
 #include <linux/config.h>
 #include <asm/8xx_immap.h>
+#include <asm/ptrace.h>
 
 /* CPM Command register.
 */
@@ -78,7 +79,9 @@
 extern void *cpm_dpram_addr(uint offset);
 extern void cpm_setbrg(uint brg, uint rate);
 
-uint		m8xx_cpm_hostalloc(uint size);
+extern uint m8xx_cpm_hostalloc(uint size);
+extern int  m8xx_cpm_hostfree(uint start);
+extern void m8xx_cpm_hostdump(void);
 
 /* Buffer descriptors used by many of the CPM protocols.
 */
@@ -142,6 +145,8 @@
 	ushort	smc_brkec;	/* rcv'd break condition counter */
 	ushort	smc_brkcr;	/* xmt break count register */
 	ushort	smc_rmask;	/* Temporary bit mask */
+	char	res1[8];	/* Reserved */
+	ushort	smc_rpbase;	/* Relocation pointer */
 } smc_uart_t;
 
 /* Function code bits.
@@ -309,6 +314,7 @@
 #define SCC_GSMRL_ENR		((uint)0x00000020)
 #define SCC_GSMRL_ENT		((uint)0x00000010)
 #define SCC_GSMRL_MODE_ENET	((uint)0x0000000c)
+#define SCC_GSMRL_MODE_QMC	((uint)0x0000000a)
 #define SCC_GSMRL_MODE_DDCMP	((uint)0x00000009)
 #define SCC_GSMRL_MODE_BISYNC	((uint)0x00000008)
 #define SCC_GSMRL_MODE_V14	((uint)0x00000007)
@@ -418,19 +424,19 @@
 
 /* SCC Mode Register (PMSR) as used by Ethernet.
 */
-#define SCC_PMSR_HBC	((ushort)0x8000)	/* Enable heartbeat */
-#define SCC_PMSR_FC	((ushort)0x4000)	/* Force collision */
-#define SCC_PMSR_RSH	((ushort)0x2000)	/* Receive short frames */
-#define SCC_PMSR_IAM	((ushort)0x1000)	/* Check individual hash */
-#define SCC_PMSR_ENCRC	((ushort)0x0800)	/* Ethernet CRC mode */
-#define SCC_PMSR_PRO	((ushort)0x0200)	/* Promiscuous mode */
-#define SCC_PMSR_BRO	((ushort)0x0100)	/* Catch broadcast pkts */
-#define SCC_PMSR_SBT	((ushort)0x0080)	/* Special backoff timer */
-#define SCC_PMSR_LPB	((ushort)0x0040)	/* Set Loopback mode */
-#define SCC_PMSR_SIP	((ushort)0x0020)	/* Sample Input Pins */
-#define SCC_PMSR_LCW	((ushort)0x0010)	/* Late collision window */
-#define SCC_PMSR_NIB22	((ushort)0x000a)	/* Start frame search */
-#define SCC_PMSR_FDE	((ushort)0x0001)	/* Full duplex enable */
+#define SCC_PSMR_HBC	((ushort)0x8000)	/* Enable heartbeat */
+#define SCC_PSMR_FC	((ushort)0x4000)	/* Force collision */
+#define SCC_PSMR_RSH	((ushort)0x2000)	/* Receive short frames */
+#define SCC_PSMR_IAM	((ushort)0x1000)	/* Check individual hash */
+#define SCC_PSMR_ENCRC	((ushort)0x0800)	/* Ethernet CRC mode */
+#define SCC_PSMR_PRO	((ushort)0x0200)	/* Promiscuous mode */
+#define SCC_PSMR_BRO	((ushort)0x0100)	/* Catch broadcast pkts */
+#define SCC_PSMR_SBT	((ushort)0x0080)	/* Special backoff timer */
+#define SCC_PSMR_LPB	((ushort)0x0040)	/* Set Loopback mode */
+#define SCC_PSMR_SIP	((ushort)0x0020)	/* Sample Input Pins */
+#define SCC_PSMR_LCW	((ushort)0x0010)	/* Late collision window */
+#define SCC_PSMR_NIB22	((ushort)0x000a)	/* Start frame search */
+#define SCC_PSMR_FDE	((ushort)0x0001)	/* Full duplex enable */
 
 /* Buffer descriptor control/status used by Ethernet receive.
 */
@@ -471,8 +477,7 @@
 */
 typedef struct scc_uart {
 	sccp_t	scc_genscc;
-	uint	scc_res1;	/* Reserved */
-	uint	scc_res2;	/* Reserved */
+	char	res1[8];	/* Reserved */
 	ushort	scc_maxidl;	/* Maximum idle chars */
 	ushort	scc_idlc;	/* temp idle counter */
 	ushort	scc_brkcr;	/* Break count register */
@@ -514,19 +519,19 @@
 
 /* The SCC PMSR when used as a UART.
 */
-#define SCU_PMSR_FLC		((ushort)0x8000)
-#define SCU_PMSR_SL		((ushort)0x4000)
-#define SCU_PMSR_CL		((ushort)0x3000)
-#define SCU_PMSR_UM		((ushort)0x0c00)
-#define SCU_PMSR_FRZ		((ushort)0x0200)
-#define SCU_PMSR_RZS		((ushort)0x0100)
-#define SCU_PMSR_SYN		((ushort)0x0080)
-#define SCU_PMSR_DRT		((ushort)0x0040)
-#define SCU_PMSR_PEN		((ushort)0x0010)
-#define SCU_PMSR_RPM		((ushort)0x000c)
-#define SCU_PMSR_REVP		((ushort)0x0008)
-#define SCU_PMSR_TPM		((ushort)0x0003)
-#define SCU_PMSR_TEVP		((ushort)0x0002)
+#define SCU_PSMR_FLC		((ushort)0x8000)
+#define SCU_PSMR_SL		((ushort)0x4000)
+#define SCU_PSMR_CL		((ushort)0x3000)
+#define SCU_PSMR_UM		((ushort)0x0c00)
+#define SCU_PSMR_FRZ		((ushort)0x0200)
+#define SCU_PSMR_RZS		((ushort)0x0100)
+#define SCU_PSMR_SYN		((ushort)0x0080)
+#define SCU_PSMR_DRT		((ushort)0x0040)
+#define SCU_PSMR_PEN		((ushort)0x0010)
+#define SCU_PSMR_RPM		((ushort)0x000c)
+#define SCU_PSMR_REVP		((ushort)0x0008)
+#define SCU_PSMR_TPM		((ushort)0x0003)
+#define SCU_PSMR_TEVP		((ushort)0x0002)
 
 /* CPM Transparent mode SCC.
  */
@@ -556,9 +561,9 @@
 	ushort	iic_tbptr;	/* Internal */
 	ushort	iic_tbc;	/* Internal */
 	uint	iic_txtmp;	/* Internal */
-	uint	iic_res;	/* reserved */
-  	ushort	iic_rpbase;	/* Relocation pointer */
-	ushort	iic_res2;	/* reserved */
+	char	res1[4];	/* Reserved */
+	ushort	iic_rpbase;	/* Relocation pointer */
+	char	res2[2];	/* Reserved */
 } iic_t;
 
 #define BD_IIC_START		((ushort)0x0400)
diff -Nru a/include/asm-ppc/cputable.h b/include/asm-ppc/cputable.h
--- a/include/asm-ppc/cputable.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-ppc/cputable.h	2004-12-24 13:36:48 -08:00
@@ -21,6 +21,9 @@
 #define PPC_FEATURE_HAS_MMU		0x04000000
 #define PPC_FEATURE_HAS_4xxMAC		0x02000000
 #define PPC_FEATURE_UNIFIED_CACHE	0x01000000
+#define PPC_FEATURE_HAS_SPE		0x00800000
+#define PPC_FEATURE_HAS_EFP_SINGLE	0x00400000
+#define PPC_FEATURE_HAS_EFP_DOUBLE	0x00200000
 
 #ifdef __KERNEL__
 
@@ -45,6 +48,9 @@
 	/* cache line sizes */
 	unsigned int	icache_bsize;
 	unsigned int	dcache_bsize;
+
+	/* number of performance monitor counters */
+	unsigned int	num_pmcs;
 
 	/* this is called to initialize various CPU bits like L1 cache,
 	 * BHT, SPD, etc... from head.S before branching to identify_machine
diff -Nru a/include/asm-ppc/hardirq.h b/include/asm-ppc/hardirq.h
--- a/include/asm-ppc/hardirq.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-ppc/hardirq.h	2004-12-24 13:36:16 -08:00
@@ -21,46 +21,11 @@
 
 #define last_jiffy_stamp(cpu) __IRQ_STAT((cpu), __last_jiffy_stamp)
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
-#define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
-
-/*
- * The hardirq mask has to be large enough to have
- * space for potentially all IRQ sources in the system
- * nesting on a single CPU:
- */
-#if (1 << HARDIRQ_BITS) < NR_IRQS
-# error HARDIRQ_BITS is too low!
-#endif
-
-#define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
-#define irq_exit()							\
-do {									\
-	preempt_count() -= IRQ_EXIT_OFFSET;				\
-	if (!in_interrupt() && softirq_pending(smp_processor_id()))	\
-		do_softirq();						\
-	preempt_enable_no_resched();					\
-} while (0)
+static inline void ack_bad_irq(int irq)
+{
+	printk(KERN_CRIT "illegal vector %d received!\n", irq);
+	BUG();
+}
 
 #endif /* __ASM_HARDIRQ_H */
 #endif /* __KERNEL__ */
diff -Nru a/include/asm-ppc/hw_irq.h b/include/asm-ppc/hw_irq.h
--- a/include/asm-ppc/hw_irq.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-ppc/hw_irq.h	2004-12-24 13:37:02 -08:00
@@ -9,7 +9,6 @@
 #include <asm/reg.h>
 
 extern void timer_interrupt(struct pt_regs *);
-extern void ppc_irq_dispatch_handler(struct pt_regs *regs, int irq);
 
 #define INLINE_IRQS
 
diff -Nru a/include/asm-ppc/ibm4xx.h b/include/asm-ppc/ibm4xx.h
--- a/include/asm-ppc/ibm4xx.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-ppc/ibm4xx.h	2004-12-24 13:36:55 -08:00
@@ -59,6 +59,10 @@
 #include <platforms/4xx/walnut.h>
 #endif
 
+#if defined(CONFIG_XILINX_ML300)
+#include <platforms/4xx/xilinx_ml300.h>
+#endif
+
 #ifndef __ASSEMBLY__
 
 #ifdef CONFIG_40x
diff -Nru a/include/asm-ppc/immap_cpm2.h b/include/asm-ppc/immap_cpm2.h
--- a/include/asm-ppc/immap_cpm2.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-ppc/immap_cpm2.h	2004-12-24 13:36:49 -08:00
@@ -133,7 +133,7 @@
 	u8	res5[2];
 	u32	sit_pitc;
 	u32	sit_pitr;
-	u8	res6[92];
+	u8      res6[94];
 	u8	res7[390];
 } sit_cpm2_t;
 
diff -Nru a/include/asm-ppc/io.h b/include/asm-ppc/io.h
--- a/include/asm-ppc/io.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-ppc/io.h	2004-12-24 13:37:18 -08:00
@@ -3,6 +3,7 @@
 #define _PPC_IO_H
 
 #include <linux/config.h>
+#include <linux/string.h>
 #include <linux/types.h>
 
 #include <asm/page.h>
@@ -41,34 +42,172 @@
 #define PCI_DRAM_OFFSET	pci_dram_offset
 #endif /* Platform-dependent I/O */
 
+#define ___IO_BASE ((void __iomem *)_IO_BASE)
 extern unsigned long isa_io_base;
 extern unsigned long isa_mem_base;
 extern unsigned long pci_dram_offset;
 
-#define readb(addr) in_8((volatile u8 *)(addr))
-#define writeb(b,addr) out_8((volatile u8 *)(addr), (b))
+/*
+ * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
+ *
+ * Read operations have additional twi & isync to make sure the read
+ * is actually performed (i.e. the data has come back) before we start
+ * executing any following instructions.
+ */
+extern inline int in_8(volatile unsigned char __iomem *addr)
+{
+	int ret;
+
+	__asm__ __volatile__(
+		"lbz%U1%X1 %0,%1;\n"
+		"twi 0,%0,0;\n"
+		"isync" : "=r" (ret) : "m" (*addr));
+	return ret;
+}
+
+extern inline void out_8(volatile unsigned char __iomem *addr, int val)
+{
+	__asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+}
+
+extern inline int in_le16(volatile unsigned short __iomem *addr)
+{
+	int ret;
+
+	__asm__ __volatile__("lhbrx %0,0,%1;\n"
+			     "twi 0,%0,0;\n"
+			     "isync" : "=r" (ret) :
+			      "r" (addr), "m" (*addr));
+	return ret;
+}
+
+extern inline int in_be16(volatile unsigned short __iomem *addr)
+{
+	int ret;
+
+	__asm__ __volatile__("lhz%U1%X1 %0,%1;\n"
+			     "twi 0,%0,0;\n"
+			     "isync" : "=r" (ret) : "m" (*addr));
+	return ret;
+}
+
+extern inline void out_le16(volatile unsigned short __iomem *addr, int val)
+{
+	__asm__ __volatile__("sthbrx %1,0,%2; eieio" : "=m" (*addr) :
+			      "r" (val), "r" (addr));
+}
+
+extern inline void out_be16(volatile unsigned short __iomem *addr, int val)
+{
+	__asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+}
+
+extern inline unsigned in_le32(volatile unsigned __iomem *addr)
+{
+	unsigned ret;
+
+	__asm__ __volatile__("lwbrx %0,0,%1;\n"
+			     "twi 0,%0,0;\n"
+			     "isync" : "=r" (ret) :
+			     "r" (addr), "m" (*addr));
+	return ret;
+}
+
+extern inline unsigned in_be32(volatile unsigned __iomem *addr)
+{
+	unsigned ret;
+
+	__asm__ __volatile__("lwz%U1%X1 %0,%1;\n"
+			     "twi 0,%0,0;\n"
+			     "isync" : "=r" (ret) : "m" (*addr));
+	return ret;
+}
+
+extern inline void out_le32(volatile unsigned __iomem *addr, int val)
+{
+	__asm__ __volatile__("stwbrx %1,0,%2; eieio" : "=m" (*addr) :
+			     "r" (val), "r" (addr));
+}
+
+extern inline void out_be32(volatile unsigned __iomem *addr, int val)
+{
+	__asm__ __volatile__("stw%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+}
+
+static inline __u8 readb(volatile void __iomem *addr)
+{
+	return in_8(addr);
+}
+static inline void writeb(__u8 b, volatile void __iomem *addr)
+{
+	out_8(addr, b);
+}
 #if defined(CONFIG_APUS)
-#define readw(addr) (*(volatile u16 *) (addr))
-#define readl(addr) (*(volatile u32 *) (addr))
-#define writew(b,addr) ((*(volatile u16 *) (addr)) = (b))
-#define writel(b,addr) ((*(volatile u32 *) (addr)) = (b))
+static inline __u16 readw(volatile void __iomem *addr)
+{
+	return *(__force volatile __u16 *)(addr);
+}
+static inline __u32 readl(volatile void __iomem *addr)
+{
+	return *(__force volatile __u32 *)(addr);
+}
+static inline void writew(__u16 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u16 *)(addr) = b;
+}
+static inline void writel(__u32 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u32 *)(addr) = b;
+}
 #else
-#define readw(addr) in_le16((volatile u16 *)(addr))
-#define readl(addr) in_le32((volatile u32 *)(addr))
-#define writew(b,addr) out_le16((volatile u16 *)(addr),(b))
-#define writel(b,addr) out_le32((volatile u32 *)(addr),(b))
+static inline __u16 readw(volatile void __iomem *addr)
+{
+	return in_le16(addr);
+}
+static inline __u32 readl(volatile void __iomem *addr)
+{
+	return in_le32(addr);
+}
+static inline void writew(__u16 b, volatile void __iomem *addr)
+{
+	out_le16(addr, b);
+}
+static inline void writel(__u32 b, volatile void __iomem *addr)
+{
+	out_le32(addr, b);
+}
 #endif /* CONFIG_APUS */
 
 #define readb_relaxed(addr) readb(addr)
 #define readw_relaxed(addr) readw(addr)
 #define readl_relaxed(addr) readl(addr)
 
-#define __raw_readb(addr)	(*(volatile unsigned char *)(addr))
-#define __raw_readw(addr)	(*(volatile unsigned short *)(addr))
-#define __raw_readl(addr)	(*(volatile unsigned int *)(addr))
-#define __raw_writeb(v, addr)	(*(volatile unsigned char *)(addr) = (v))
-#define __raw_writew(v, addr)	(*(volatile unsigned short *)(addr) = (v))
-#define __raw_writel(v, addr)	(*(volatile unsigned int *)(addr) = (v))
+static inline __u8 __raw_readb(volatile void __iomem *addr)
+{
+	return *(__force volatile __u8 *)(addr);
+}
+static inline __u16 __raw_readw(volatile void __iomem *addr)
+{
+	return *(__force volatile __u16 *)(addr);
+}
+static inline __u32 __raw_readl(volatile void __iomem *addr)
+{
+	return *(__force volatile __u32 *)(addr);
+}
+static inline void __raw_writeb(__u8 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u8 *)(addr) = b;
+}
+static inline void __raw_writew(__u16 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u16 *)(addr) = b;
+}
+static inline void __raw_writel(__u32 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u32 *)(addr) = b;
+}
+
+#define mmiowb()
 
 /*
  * The insw/outsw/insl/outsl macros don't do byte-swapping.
@@ -76,12 +215,12 @@
  * are arrays of bytes, and byte-swapping is not appropriate in
  * that case.  - paulus
  */
-#define insb(port, buf, ns)	_insb((u8 *)((port)+_IO_BASE), (buf), (ns))
-#define outsb(port, buf, ns)	_outsb((u8 *)((port)+_IO_BASE), (buf), (ns))
-#define insw(port, buf, ns)	_insw_ns((u16 *)((port)+_IO_BASE), (buf), (ns))
-#define outsw(port, buf, ns)	_outsw_ns((u16 *)((port)+_IO_BASE), (buf), (ns))
-#define insl(port, buf, nl)	_insl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
-#define outsl(port, buf, nl)	_outsl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
+#define insb(port, buf, ns)	_insb((port)+___IO_BASE, (buf), (ns))
+#define outsb(port, buf, ns)	_outsb((port)+___IO_BASE, (buf), (ns))
+#define insw(port, buf, ns)	_insw_ns((port)+___IO_BASE, (buf), (ns))
+#define outsw(port, buf, ns)	_outsw_ns((port)+___IO_BASE, (buf), (ns))
+#define insl(port, buf, nl)	_insl_ns((port)+___IO_BASE, (buf), (nl))
+#define outsl(port, buf, nl)	_outsl_ns((port)+___IO_BASE, (buf), (nl))
 
 /*
  * On powermacs, we will get a machine check exception if we
@@ -121,7 +260,7 @@
 		"	.long	3b,5b\n"		\
 		".previous"				\
 		: "=&r" (x)				\
-		: "r" (port + _IO_BASE));		\
+		: "r" (port + ___IO_BASE));		\
 	return x;					\
 }
 
@@ -136,7 +275,7 @@
 		"	.align	2\n"			\
 		"	.long	1b,2b\n"		\
 		".previous"				\
-		: : "r" (val), "r" (port + _IO_BASE));	\
+		: : "r" (val), "r" (port + ___IO_BASE));	\
 }
 
 __do_out_asm(outb, "stbx")
@@ -148,9 +287,9 @@
 __do_out_asm(outw, "sth%U0%X0")
 #elif defined (CONFIG_8260_PCI9)
 /* in asm cannot be defined if PCI9 workaround is used */
-#define inb(port)		in_8((u8 *)((port)+_IO_BASE))
-#define inw(port)		in_le16((u16 *)((port)+_IO_BASE))
-#define inl(port)		in_le32((u32 *)((port)+_IO_BASE))
+#define inb(port)		in_8((port)+___IO_BASE)
+#define inw(port)		in_le16((port)+___IO_BASE)
+#define inl(port)		in_le32((port)+___IO_BASE)
 __do_out_asm(outw, "sthbrx")
 __do_out_asm(outl, "stwbrx")
 #else
@@ -169,46 +308,55 @@
 #define inl_p(port)		inl((port))
 #define outl_p(val, port)	outl((val), (port))
 
-extern void _insb(volatile u8 *port, void *buf, int ns);
-extern void _outsb(volatile u8 *port, const void *buf, int ns);
-extern void _insw(volatile u16 *port, void *buf, int ns);
-extern void _outsw(volatile u16 *port, const void *buf, int ns);
-extern void _insl(volatile u32 *port, void *buf, int nl);
-extern void _outsl(volatile u32 *port, const void *buf, int nl);
-extern void _insw_ns(volatile u16 *port, void *buf, int ns);
-extern void _outsw_ns(volatile u16 *port, const void *buf, int ns);
-extern void _insl_ns(volatile u32 *port, void *buf, int nl);
-extern void _outsl_ns(volatile u32 *port, const void *buf, int nl);
+extern void _insb(volatile u8 __iomem *port, void *buf, int ns);
+extern void _outsb(volatile u8 __iomem *port, const void *buf, int ns);
+extern void _insw(volatile u16 __iomem *port, void *buf, int ns);
+extern void _outsw(volatile u16 __iomem *port, const void *buf, int ns);
+extern void _insl(volatile u32 __iomem *port, void *buf, int nl);
+extern void _outsl(volatile u32 __iomem *port, const void *buf, int nl);
+extern void _insw_ns(volatile u16 __iomem *port, void *buf, int ns);
+extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, int ns);
+extern void _insl_ns(volatile u32 __iomem *port, void *buf, int nl);
+extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl);
 
 /*
  * The *_ns versions below don't do byte-swapping.
  * Neither do the standard versions now, these are just here
  * for older code.
  */
-#define insw_ns(port, buf, ns)	_insw_ns((u16 *)((port)+_IO_BASE), (buf), (ns))
-#define outsw_ns(port, buf, ns)	_outsw_ns((u16 *)((port)+_IO_BASE), (buf), (ns))
-#define insl_ns(port, buf, nl)	_insl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
-#define outsl_ns(port, buf, nl)	_outsl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
+#define insw_ns(port, buf, ns)	_insw_ns((port)+___IO_BASE, (buf), (ns))
+#define outsw_ns(port, buf, ns)	_outsw_ns((port)+___IO_BASE, (buf), (ns))
+#define insl_ns(port, buf, nl)	_insl_ns((port)+___IO_BASE, (buf), (nl))
+#define outsl_ns(port, buf, nl)	_outsl_ns((port)+___IO_BASE, (buf), (nl))
 
 
 #define IO_SPACE_LIMIT ~0
 
-#define memset_io(a,b,c)       memset((void *)(a),(b),(c))
-#define memcpy_fromio(a,b,c)   memcpy((a),(void *)(b),(c))
-#define memcpy_toio(a,b,c)	memcpy((void *)(a),(b),(c))
+static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
+{
+	memset((void __force *)addr, val, count);
+}
+static inline void memcpy_fromio(void *dst, volatile void __iomem *src, int count)
+{
+	memcpy(dst, (void __force *) src, count);
+}
+static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
+{
+	memcpy((void __force *) dst, src, count);
+}
 
 /*
  * Map in an area of physical address space, for accessing
  * I/O devices etc.
  */
-extern void *__ioremap(phys_addr_t address, unsigned long size,
+extern void __iomem *__ioremap(phys_addr_t address, unsigned long size,
 		       unsigned long flags);
-extern void *ioremap(phys_addr_t address, unsigned long size);
+extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
 #ifdef CONFIG_44x
-extern void *ioremap64(unsigned long long address, unsigned long size);
+extern void __iomem *ioremap64(unsigned long long address, unsigned long size);
 #endif
 #define ioremap_nocache(addr, size)	ioremap((addr), (size))
-extern void iounmap(void *addr);
+extern void iounmap(volatile void __iomem *addr);
 extern unsigned long iopa(unsigned long addr);
 extern unsigned long mm_ptov(unsigned long addr) __attribute_const__;
 extern void io_block_mapping(unsigned long virt, phys_addr_t phys,
@@ -288,94 +436,7 @@
 #define iobarrier_r()  eieio()
 #define iobarrier_w()  eieio()
 
-/*
- * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
- *
- * Read operations have additional twi & isync to make sure the read
- * is actually performed (i.e. the data has come back) before we start
- * executing any following instructions.
- */
-extern inline int in_8(volatile unsigned char *addr)
-{
-	int ret;
-
-	__asm__ __volatile__(
-		"lbz%U1%X1 %0,%1;\n"
-		"twi 0,%0,0;\n"
-		"isync" : "=r" (ret) : "m" (*addr));
-	return ret;
-}
-
-extern inline void out_8(volatile unsigned char *addr, int val)
-{
-	__asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
-}
-
-extern inline int in_le16(volatile unsigned short *addr)
-{
-	int ret;
-
-	__asm__ __volatile__("lhbrx %0,0,%1;\n"
-			     "twi 0,%0,0;\n"
-			     "isync" : "=r" (ret) :
-			      "r" (addr), "m" (*addr));
-	return ret;
-}
-
-extern inline int in_be16(volatile unsigned short *addr)
-{
-	int ret;
-
-	__asm__ __volatile__("lhz%U1%X1 %0,%1;\n"
-			     "twi 0,%0,0;\n"
-			     "isync" : "=r" (ret) : "m" (*addr));
-	return ret;
-}
-
-extern inline void out_le16(volatile unsigned short *addr, int val)
-{
-	__asm__ __volatile__("sthbrx %1,0,%2; eieio" : "=m" (*addr) :
-			      "r" (val), "r" (addr));
-}
-
-extern inline void out_be16(volatile unsigned short *addr, int val)
-{
-	__asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
-}
-
-extern inline unsigned in_le32(volatile unsigned *addr)
-{
-	unsigned ret;
-
-	__asm__ __volatile__("lwbrx %0,0,%1;\n"
-			     "twi 0,%0,0;\n"
-			     "isync" : "=r" (ret) :
-			     "r" (addr), "m" (*addr));
-	return ret;
-}
-
-extern inline unsigned in_be32(volatile unsigned *addr)
-{
-	unsigned ret;
-
-	__asm__ __volatile__("lwz%U1%X1 %0,%1;\n"
-			     "twi 0,%0,0;\n"
-			     "isync" : "=r" (ret) : "m" (*addr));
-	return ret;
-}
-
-extern inline void out_le32(volatile unsigned *addr, int val)
-{
-	__asm__ __volatile__("stwbrx %1,0,%2; eieio" : "=m" (*addr) :
-			     "r" (val), "r" (addr));
-}
-
-extern inline void out_be32(volatile unsigned *addr, int val)
-{
-	__asm__ __volatile__("stw%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
-}
-
-static inline int check_signature(unsigned long io_addr,
+static inline int check_signature(volatile void __iomem * io_addr,
 	const unsigned char *signature, int length)
 {
 	int retval = 0;
@@ -389,13 +450,6 @@
 	retval = 1;
 out:
 	return retval;
-}
-
-/* Make some pcmcia drivers happy */
-static inline int isa_check_signature(unsigned long io_addr,
-	const unsigned char *signature, int length)
-{
-	return 0;
 }
 
 /*
diff -Nru a/include/asm-ppc/irq.h b/include/asm-ppc/irq.h
--- a/include/asm-ppc/irq.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-ppc/irq.h	2004-12-24 13:36:18 -08:00
@@ -6,10 +6,6 @@
 #include <asm/machdep.h>		/* ppc_md */
 #include <asm/atomic.h>
 
-extern void disable_irq(unsigned int);
-extern void disable_irq_nosync(unsigned int);
-extern void enable_irq(unsigned int);
-
 /*
  * These constants are used for passing information about interrupt
  * signal polarity and level/edge sensing to the low-level PIC chip
@@ -85,6 +81,10 @@
 
 #elif defined(CONFIG_8xx)
 
+/* Now include the board configuration specific associations.
+*/
+#include <asm/mpc8xx.h>
+
 /* The MPC8xx cores have 16 possible interrupts.  There are eight
  * possible level sensitive interrupts assigned and generated internally
  * from such devices as CPM, PCMCIA, RTC, PIT, TimeBase and Decrementer.
@@ -93,10 +93,22 @@
  *
  * On some implementations, there is also the possibility of an 8259
  * through the PCI and PCI-ISA bridges.
+ *
+ * We are "flattening" the interrupt vectors of the cascaded CPM
+ * and 8259 interrupt controllers so that we can uniquely identify
+ * any interrupt source with a single integer.
  */
 #define NR_SIU_INTS	16
+#define NR_CPM_INTS	32
+#ifndef NR_8259_INTS
+#define NR_8259_INTS 0
+#endif
+
+#define SIU_IRQ_OFFSET		0
+#define CPM_IRQ_OFFSET		(SIU_IRQ_OFFSET + NR_SIU_INTS)
+#define I8259_IRQ_OFFSET	(CPM_IRQ_OFFSET + NR_CPM_INTS)
 
-#define NR_IRQS	(NR_SIU_INTS + NR_8259_INTS)
+#define NR_IRQS	(NR_SIU_INTS + NR_CPM_INTS + NR_8259_INTS)
 
 /* These values must be zero-based and map 1:1 with the SIU configuration.
  * They are used throughout the 8xx I/O subsystem to generate
@@ -120,10 +132,6 @@
 #define	SIU_LEVEL6	(13)
 #define	SIU_IRQ7	(14)
 #define	SIU_LEVEL7	(15)
-
-/* Now include the board configuration specific associations.
-*/
-#include <asm/mpc8xx.h>
 
 /* The internal interrupts we can configure as we see fit.
  * My personal preference is CPM at level 2, which puts it above the
diff -Nru a/include/asm-ppc/machdep.h b/include/asm-ppc/machdep.h
--- a/include/asm-ppc/machdep.h	2004-12-24 13:36:32 -08:00
+++ b/include/asm-ppc/machdep.h	2004-12-24 13:36:32 -08:00
@@ -56,6 +56,7 @@
 	unsigned long	(*find_end_of_memory)(void);
 	void		(*setup_io_mappings)(void);
 
+	void		(*early_serial_map)(void);
   	void		(*progress)(char *, unsigned short);
 	void		(*kgdb_map_scc)(void);
 
diff -Nru a/include/asm-ppc/mpc85xx.h b/include/asm-ppc/mpc85xx.h
--- a/include/asm-ppc/mpc85xx.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-ppc/mpc85xx.h	2004-12-24 13:37:43 -08:00
@@ -81,6 +81,7 @@
 #define MPC85xx_IRQ_DUART	(26 + MPC85xx_OPENPIC_IRQ_OFFSET)
 #define MPC85xx_IRQ_IIC1	(27 + MPC85xx_OPENPIC_IRQ_OFFSET)
 #define MPC85xx_IRQ_PERFMON	(28 + MPC85xx_OPENPIC_IRQ_OFFSET)
+#define MPC85xx_IRQ_SEC2	(29 + MPC85xx_OPENPIC_IRQ_OFFSET)
 #define MPC85xx_IRQ_CPM		(30 + MPC85xx_OPENPIC_IRQ_OFFSET)
 
 /* The 12 external interrupt lines */
@@ -120,6 +121,8 @@
 #define MPC85xx_PCI2_SIZE	(0x01000)
 #define MPC85xx_PERFMON_OFFSET	(0xe1000)
 #define MPC85xx_PERFMON_SIZE	(0x01000)
+#define MPC85xx_SEC2_OFFSET	(0x30000)
+#define MPC85xx_SEC2_SIZE	(0x10000)
 #define MPC85xx_UART0_OFFSET	(0x04500)
 #define MPC85xx_UART0_SIZE	(0x00100)
 #define MPC85xx_UART1_OFFSET	(0x04600)
diff -Nru a/include/asm-ppc/mpc8xx.h b/include/asm-ppc/mpc8xx.h
--- a/include/asm-ppc/mpc8xx.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-ppc/mpc8xx.h	2004-12-24 13:37:19 -08:00
@@ -96,11 +96,7 @@
 extern unsigned char __res[];
 
 struct pt_regs;
-extern int request_8xxirq(unsigned int irq,
-		       void (*handler)(int, void *, struct pt_regs *),
-		       unsigned long flags,
-		       const char *device,
-		       void *dev_id);
+
 #endif /* !__ASSEMBLY__ */
 #endif /* CONFIG_8xx */
 #endif /* __CONFIG_8xx_DEFS */
diff -Nru a/include/asm-ppc/ocp_ids.h b/include/asm-ppc/ocp_ids.h
--- a/include/asm-ppc/ocp_ids.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-ppc/ocp_ids.h	2004-12-24 13:37:19 -08:00
@@ -61,6 +61,7 @@
 #define OCP_FUNC_PERFMON	0x00D2	/* Performance Monitor */
 #define OCP_FUNC_RGMII		0x00D3
 #define OCP_FUNC_TAH		0x00D4
+#define OCP_FUNC_SEC2		0x00D5	/* Crypto/Security 2.0 */
 
 /* Network 0x0200 - 0x02FF */
 #define OCP_FUNC_EMAC		0x0200
diff -Nru a/include/asm-ppc/open_pic.h b/include/asm-ppc/open_pic.h
--- a/include/asm-ppc/open_pic.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-ppc/open_pic.h	2004-12-24 13:36:47 -08:00
@@ -36,6 +36,7 @@
 extern u_int OpenPIC_NumInitSenses;
 extern u_char *OpenPIC_InitSenses;
 extern void* OpenPIC_Addr;
+extern int epic_serial_mode;
 
 /* Exported functions */
 extern void openpic_set_sources(int first_irq, int num_irqs, void *isr);
@@ -54,6 +55,7 @@
 extern void smp_openpic_message_pass(int target, int msg, unsigned long data,
 				     int wait);
 extern void openpic_set_k2_cascade(int irq);
+extern void openpic_set_priority(u_int pri);
 
 extern inline int openpic_to_irq(int irq)
 {
diff -Nru a/include/asm-ppc/pci-bridge.h b/include/asm-ppc/pci-bridge.h
--- a/include/asm-ppc/pci-bridge.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-ppc/pci-bridge.h	2004-12-24 13:36:18 -08:00
@@ -94,6 +94,8 @@
 int early_write_config_dword(struct pci_controller *hose, int bus, int dev_fn,
 			     int where, u32 val);
 
+extern void setup_indirect_pci_nomap(struct pci_controller* hose,
+			       u32 cfg_addr, u32 cfg_data);
 extern void setup_indirect_pci(struct pci_controller* hose,
 			       u32 cfg_addr, u32 cfg_data);
 extern void setup_grackle(struct pci_controller *hose);
diff -Nru a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
--- a/include/asm-ppc/pgtable.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-ppc/pgtable.h	2004-12-24 13:36:31 -08:00
@@ -714,7 +714,8 @@
 /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 /*
  * No page table caches to initialise
diff -Nru a/include/asm-ppc/pmac_feature.h b/include/asm-ppc/pmac_feature.h
--- a/include/asm-ppc/pmac_feature.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-ppc/pmac_feature.h	2004-12-24 13:36:16 -08:00
@@ -9,7 +9,7 @@
  *                    Ben. Herrenschmidt.
  *
  *
- * Note: I removed media-bay details from the feature stuff, I beleive it's
+ * Note: I removed media-bay details from the feature stuff, I believe it's
  *       not worth it, the media-bay driver can directly use the mac-io
  *       ASIC registers.
  *
@@ -315,7 +315,7 @@
 	int			type;
 	const char		*name;
 	int			rev;
-	volatile u32		*base;
+	volatile u32		__iomem *base;
 	unsigned long		flags;
 
 	/* For use by macio_asic PCI driver */
@@ -333,7 +333,7 @@
 extern struct macio_chip* macio_find(struct device_node* child, int type);
 
 #define MACIO_FCR32(macio, r)	((macio)->base + ((r) >> 2))
-#define MACIO_FCR8(macio, r)	(((volatile u8*)((macio)->base)) + (r))
+#define MACIO_FCR8(macio, r)	(((volatile u8 __iomem *)((macio)->base)) + (r))
 
 #define MACIO_IN32(r)		(in_le32(MACIO_FCR32(macio,r)))
 #define MACIO_OUT32(r,v)	(out_le32(MACIO_FCR32(macio,r), (v)))
diff -Nru a/include/asm-ppc/reg_booke.h b/include/asm-ppc/reg_booke.h
--- a/include/asm-ppc/reg_booke.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-ppc/reg_booke.h	2004-12-24 13:37:04 -08:00
@@ -63,9 +63,9 @@
 
 /* Default MSR for kernel mode. */
 #if defined (CONFIG_40x)
-#define MSR_KERNEL	(MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE|MSR_DE)
+#define MSR_KERNEL	(MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE)
 #elif defined(CONFIG_BOOKE)
-#define MSR_KERNEL	(MSR_ME|MSR_RI|MSR_CE|MSR_DE)
+#define MSR_KERNEL	(MSR_ME|MSR_RI|MSR_CE)
 #endif
 
 /* Special Purpose Registers (SPRNs)*/
diff -Nru a/include/asm-ppc/thread_info.h b/include/asm-ppc/thread_info.h
--- a/include/asm-ppc/thread_info.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-ppc/thread_info.h	2004-12-24 13:36:31 -08:00
@@ -65,7 +65,7 @@
  */
 #define THREAD_SIZE		8192	/* 2 pages */
 
-#define PREEMPT_ACTIVE		0x4000000
+#define PREEMPT_ACTIVE		0x10000000
 
 /*
  * thread information flag bit numbers
diff -Nru a/include/asm-ppc/time.h b/include/asm-ppc/time.h
--- a/include/asm-ppc/time.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-ppc/time.h	2004-12-24 13:36:17 -08:00
@@ -10,7 +10,8 @@
 #define __ASM_TIME_H__
 
 #include <linux/config.h>
-#include <linux/mc146818rtc.h>
+#include <linux/types.h>
+#include <linux/rtc.h>
 #include <linux/threads.h>
 
 #include <asm/reg.h>
diff -Nru a/include/asm-ppc/timex.h b/include/asm-ppc/timex.h
--- a/include/asm-ppc/timex.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-ppc/timex.h	2004-12-24 13:36:49 -08:00
@@ -11,10 +11,6 @@
 #include <asm/cputable.h>
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 typedef unsigned long cycles_t;
 
diff -Nru a/include/asm-ppc/unistd.h b/include/asm-ppc/unistd.h
--- a/include/asm-ppc/unistd.h	2004-12-24 13:36:30 -08:00
+++ b/include/asm-ppc/unistd.h	2004-12-24 13:36:30 -08:00
@@ -273,8 +273,11 @@
 #define __NR_mq_notify		266
 #define __NR_mq_getsetattr	267
 #define __NR_kexec_load		268
+#define __NR_add_key		269
+#define __NR_request_key	270
+#define __NR_keyctl		271
 
-#define __NR_syscalls		269
+#define __NR_syscalls		272
 
 #define __NR(n)	#n
 
diff -Nru a/include/asm-ppc/xparameters.h b/include/asm-ppc/xparameters.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-ppc/xparameters.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,18 @@
+/*
+ * include/asm-ppc/xparameters.h
+ *
+ * This file includes the correct xparameters.h for the CONFIG'ed board
+ *
+ * Author: MontaVista Software, Inc.
+ *         source@mvista.com
+ *
+ * 2004 (c) MontaVista Software, Inc.  This file is licensed under the terms
+ * of the GNU General Public License version 2.  This program is licensed
+ * "as is" without any warranty of any kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+
+#if defined(CONFIG_XILINX_ML300)
+#include <platforms/4xx/xparameters/xparameters_ml300.h>
+#endif
diff -Nru a/include/asm-ppc64/eeh.h b/include/asm-ppc64/eeh.h
--- a/include/asm-ppc64/eeh.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-ppc64/eeh.h	2004-12-24 13:37:19 -08:00
@@ -20,8 +20,10 @@
 #ifndef _PPC64_EEH_H
 #define _PPC64_EEH_H
 
-#include <linux/string.h>
 #include <linux/init.h>
+#include <linux/list.h>
+#include <linux/string.h>
+#include <linux/notifier.h>
 
 struct pci_dev;
 struct device_node;
@@ -29,6 +31,7 @@
 /* Values for eeh_mode bits in device_node */
 #define EEH_MODE_SUPPORTED	(1<<0)
 #define EEH_MODE_NOCHECK	(1<<1)
+#define EEH_MODE_ISOLATED	(1<<2)
 
 #ifdef CONFIG_PPC_PSERIES
 extern void __init eeh_init(void);
@@ -68,7 +71,28 @@
 #define EEH_RELEASE_DMA		3
 int eeh_set_option(struct pci_dev *dev, int options);
 
-/*
+
+/**
+ * Notifier event flags.
+ */
+#define EEH_NOTIFY_FREEZE  1
+
+/** EEH event -- structure holding pci slot data that describes
+ *  a change in the isolation status of a PCI slot.  A pointer
+ *  to this struct is passed as the data pointer in a notify callback.
+ */
+struct eeh_event {
+	struct list_head     list;
+	struct pci_dev       *dev;
+	struct device_node   *dn;
+	int                  reset_state;
+};
+
+/** Register to find out about EEH events. */
+int eeh_register_notifier(struct notifier_block *nb);
+int eeh_unregister_notifier(struct notifier_block *nb);
+
+/**
  * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
  *
  * If this macro yields TRUE, the caller relays to eeh_check_failure()
@@ -86,114 +110,116 @@
 /* 
  * MMIO read/write operations with EEH support.
  */
-static inline u8 eeh_readb(const volatile void __iomem *addr) {
-	volatile u8 *vaddr = (volatile u8 __force *) addr;
-	u8 val = in_8(vaddr);
+static inline u8 eeh_readb(const volatile void __iomem *addr)
+{
+	u8 val = in_8(addr);
 	if (EEH_POSSIBLE_ERROR(val, u8))
 		return eeh_check_failure(addr, val);
 	return val;
 }
-static inline void eeh_writeb(u8 val, volatile void __iomem *addr) {
-	volatile u8 *vaddr = (volatile u8 __force *) addr;
-	out_8(vaddr, val);
+static inline void eeh_writeb(u8 val, volatile void __iomem *addr)
+{
+	out_8(addr, val);
 }
 
-static inline u16 eeh_readw(const volatile void __iomem *addr) {
-	volatile u16 *vaddr = (volatile u16 __force *) addr;
-	u16 val = in_le16(vaddr);
+static inline u16 eeh_readw(const volatile void __iomem *addr)
+{
+	u16 val = in_le16(addr);
 	if (EEH_POSSIBLE_ERROR(val, u16))
 		return eeh_check_failure(addr, val);
 	return val;
 }
-static inline void eeh_writew(u16 val, volatile void __iomem *addr) {
-	volatile u16 *vaddr = (volatile u16 __force *) addr;
-	out_le16(vaddr, val);
-}
-static inline u16 eeh_raw_readw(const volatile void __iomem *addr) {
-	volatile u16 *vaddr = (volatile u16 __force *) addr;
-	u16 val = in_be16(vaddr);
+static inline void eeh_writew(u16 val, volatile void __iomem *addr)
+{
+	out_le16(addr, val);
+}
+static inline u16 eeh_raw_readw(const volatile void __iomem *addr)
+{
+	u16 val = in_be16(addr);
 	if (EEH_POSSIBLE_ERROR(val, u16))
 		return eeh_check_failure(addr, val);
 	return val;
 }
 static inline void eeh_raw_writew(u16 val, volatile void __iomem *addr) {
-	volatile u16 *vaddr = (volatile u16 __force *) addr;
+	volatile u16 __iomem *vaddr = (volatile u16 __iomem *) addr;
 	out_be16(vaddr, val);
 }
 
-static inline u32 eeh_readl(const volatile void __iomem *addr) {
-	volatile u32 *vaddr = (volatile u32 __force *) addr;
-	u32 val = in_le32(vaddr);
+static inline u32 eeh_readl(const volatile void __iomem *addr)
+{
+	u32 val = in_le32(addr);
 	if (EEH_POSSIBLE_ERROR(val, u32))
 		return eeh_check_failure(addr, val);
 	return val;
 }
-static inline void eeh_writel(u32 val, volatile void __iomem *addr) {
-	volatile u32 *vaddr = (volatile u32 __force *) addr;
-	out_le32(vaddr, val);
-}
-static inline u32 eeh_raw_readl(const volatile void __iomem *addr) {
-	volatile u32 *vaddr = (volatile u32 __force *) addr;
-	u32 val = in_be32(vaddr);
+static inline void eeh_writel(u32 val, volatile void __iomem *addr)
+{
+	out_le32(addr, val);
+}
+static inline u32 eeh_raw_readl(const volatile void __iomem *addr)
+{
+	u32 val = in_be32(addr);
 	if (EEH_POSSIBLE_ERROR(val, u32))
 		return eeh_check_failure(addr, val);
 	return val;
 }
-static inline void eeh_raw_writel(u32 val, volatile void __iomem *addr) {
-	volatile u32 *vaddr = (volatile u32 __force *) addr;
-	out_be32(vaddr, val);
+static inline void eeh_raw_writel(u32 val, volatile void __iomem *addr)
+{
+	out_be32(addr, val);
 }
 
-static inline u64 eeh_readq(const volatile void __iomem *addr) {
-	volatile u64 *vaddr = (volatile u64 __force *) addr;
-	u64 val = in_le64(vaddr);
+static inline u64 eeh_readq(const volatile void __iomem *addr)
+{
+	u64 val = in_le64(addr);
 	if (EEH_POSSIBLE_ERROR(val, u64))
 		return eeh_check_failure(addr, val);
 	return val;
 }
-static inline void eeh_writeq(u64 val, volatile void __iomem *addr) {
-	volatile u64 *vaddr = (volatile u64 __force *) addr;
-	out_le64(vaddr, val);
-}
-static inline u64 eeh_raw_readq(const volatile void __iomem *addr) {
-	volatile u64 *vaddr = (volatile u64 __force *) addr;
-	u64 val = in_be64(vaddr);
+static inline void eeh_writeq(u64 val, volatile void __iomem *addr)
+{
+	out_le64(addr, val);
+}
+static inline u64 eeh_raw_readq(const volatile void __iomem *addr)
+{
+	u64 val = in_be64(addr);
 	if (EEH_POSSIBLE_ERROR(val, u64))
 		return eeh_check_failure(addr, val);
 	return val;
 }
-static inline void eeh_raw_writeq(u64 val, volatile void __iomem *addr) {
-	volatile u64 *vaddr = (volatile u64 __force *) addr;
-	out_be64(vaddr, val);
+static inline void eeh_raw_writeq(u64 val, volatile void __iomem *addr)
+{
+	out_be64(addr, val);
 }
 
 #define EEH_CHECK_ALIGN(v,a) \
 	((((unsigned long)(v)) & ((a) - 1)) == 0)
 
-static inline void eeh_memset_io(volatile void __iomem *addr, int c, unsigned long n) {
-	void *vaddr = (void __force *) addr;
+static inline void eeh_memset_io(volatile void __iomem *addr, int c, unsigned long n)
+{
 	u32 lc = c;
 	lc |= lc << 8;
 	lc |= lc << 16;
 
-	while(n && !EEH_CHECK_ALIGN(vaddr, 4)) {
-		*((volatile u8 *)vaddr) = c;
-		vaddr = (void *)((unsigned long)vaddr + 1);
+	while(n && !EEH_CHECK_ALIGN(addr, 4)) {
+		*((volatile u8 *)addr) = c;
+		addr = (void *)((unsigned long)addr + 1);
 		n--;
 	}
 	while(n >= 4) {
-		*((volatile u32 *)vaddr) = lc;
-		vaddr = (void *)((unsigned long)vaddr + 4);
+		*((volatile u32 *)addr) = lc;
+		addr = (void *)((unsigned long)addr + 4);
 		n -= 4;
 	}
 	while(n) {
-		*((volatile u8 *)vaddr) = c;
-		vaddr = (void *)((unsigned long)vaddr + 1);
+		*((volatile u8 *)addr) = c;
+		addr = (void *)((unsigned long)addr + 1);
 		n--;
 	}
 	__asm__ __volatile__ ("sync" : : : "memory");
 }
-static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *src, unsigned long n) {
+static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *src,
+				     unsigned long n)
+{
 	void *vsrc = (void __force *) src;
 	void *destsave = dest;
 	unsigned long nsave = n;
@@ -230,7 +256,9 @@
 	}
 }
 
-static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n) {
+static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src,
+				   unsigned long n)
+{
 	void *vdest = (void __force *) dest;
 
 	while(n && (!EEH_CHECK_ALIGN(vdest, 4) || !EEH_CHECK_ALIGN(src, 4))) {
@@ -256,70 +284,75 @@
 
 #undef EEH_CHECK_ALIGN
 
-#define MAX_ISA_PORT 0x10000
-extern unsigned long io_page_mask;
-#define _IO_IS_VALID(port) ((port) >= MAX_ISA_PORT || (1 << (port>>PAGE_SHIFT)) & io_page_mask)
-
-static inline u8 eeh_inb(unsigned long port) {
+static inline u8 eeh_inb(unsigned long port)
+{
 	u8 val;
 	if (!_IO_IS_VALID(port))
 		return ~0;
-	val = in_8((u8 *)(port+pci_io_base));
+	val = in_8((u8 __iomem *)(port+pci_io_base));
 	if (EEH_POSSIBLE_ERROR(val, u8))
 		return eeh_check_failure((void __iomem *)(port), val);
 	return val;
 }
 
-static inline void eeh_outb(u8 val, unsigned long port) {
+static inline void eeh_outb(u8 val, unsigned long port)
+{
 	if (_IO_IS_VALID(port))
-		out_8((u8 *)(port+pci_io_base), val);
+		out_8((u8 __iomem *)(port+pci_io_base), val);
 }
 
-static inline u16 eeh_inw(unsigned long port) {
+static inline u16 eeh_inw(unsigned long port)
+{
 	u16 val;
 	if (!_IO_IS_VALID(port))
 		return ~0;
-	val = in_le16((u16 *)(port+pci_io_base));
+	val = in_le16((u16 __iomem *)(port+pci_io_base));
 	if (EEH_POSSIBLE_ERROR(val, u16))
 		return eeh_check_failure((void __iomem *)(port), val);
 	return val;
 }
 
-static inline void eeh_outw(u16 val, unsigned long port) {
+static inline void eeh_outw(u16 val, unsigned long port)
+{
 	if (_IO_IS_VALID(port))
-		out_le16((u16 *)(port+pci_io_base), val);
+		out_le16((u16 __iomem *)(port+pci_io_base), val);
 }
 
-static inline u32 eeh_inl(unsigned long port) {
+static inline u32 eeh_inl(unsigned long port)
+{
 	u32 val;
 	if (!_IO_IS_VALID(port))
 		return ~0;
-	val = in_le32((u32 *)(port+pci_io_base));
+	val = in_le32((u32 __iomem *)(port+pci_io_base));
 	if (EEH_POSSIBLE_ERROR(val, u32))
 		return eeh_check_failure((void __iomem *)(port), val);
 	return val;
 }
 
-static inline void eeh_outl(u32 val, unsigned long port) {
+static inline void eeh_outl(u32 val, unsigned long port)
+{
 	if (_IO_IS_VALID(port))
-		out_le32((u32 *)(port+pci_io_base), val);
+		out_le32((u32 __iomem *)(port+pci_io_base), val);
 }
 
 /* in-string eeh macros */
-static inline void eeh_insb(unsigned long port, void * buf, int ns) {
-	_insb((u8 *)(port+pci_io_base), buf, ns);
+static inline void eeh_insb(unsigned long port, void * buf, int ns)
+{
+	_insb((u8 __iomem *)(port+pci_io_base), buf, ns);
 	if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8))
 		eeh_check_failure((void __iomem *)(port), *(u8*)buf);
 }
 
-static inline void eeh_insw_ns(unsigned long port, void * buf, int ns) {
-	_insw_ns((u16 *)(port+pci_io_base), buf, ns);
+static inline void eeh_insw_ns(unsigned long port, void * buf, int ns)
+{
+	_insw_ns((u16 __iomem *)(port+pci_io_base), buf, ns);
 	if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16))
 		eeh_check_failure((void __iomem *)(port), *(u16*)buf);
 }
 
-static inline void eeh_insl_ns(unsigned long port, void * buf, int nl) {
-	_insl_ns((u32 *)(port+pci_io_base), buf, nl);
+static inline void eeh_insl_ns(unsigned long port, void * buf, int nl)
+{
+	_insl_ns((u32 __iomem *)(port+pci_io_base), buf, nl);
 	if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32))
 		eeh_check_failure((void __iomem *)(port), *(u32*)buf);
 }
diff -Nru a/include/asm-ppc64/floppy.h b/include/asm-ppc64/floppy.h
--- a/include/asm-ppc64/floppy.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-ppc64/floppy.h	2004-12-24 13:37:02 -08:00
@@ -11,6 +11,7 @@
 #define __ASM_PPC64_FLOPPY_H
 
 #include <linux/config.h>
+#include <asm/machdep.h>
 
 #define fd_inb(port)			inb_p(port)
 #define fd_outb(value,port)		outb_p(value,port)
diff -Nru a/include/asm-ppc64/hardirq.h b/include/asm-ppc64/hardirq.h
--- a/include/asm-ppc64/hardirq.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-ppc64/hardirq.h	2004-12-24 13:36:19 -08:00
@@ -19,45 +19,10 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-24 are the hardirq count (max # of hardirqs: 512)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x01ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
-#define HARDIRQ_BITS	9
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
-
-/*
- * The hardirq mask has to be large enough to have
- * space for potentially all IRQ sources in the system
- * nesting on a single CPU:
- */
-#if (1 << HARDIRQ_BITS) < NR_IRQS
-# error HARDIRQ_BITS is too low!
-#endif
-
-#define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
-#define irq_exit()							\
-do {									\
-		preempt_count() -= IRQ_EXIT_OFFSET;			\
-		if (!in_interrupt() && softirq_pending(smp_processor_id())) \
-			do_softirq();					\
-		preempt_enable_no_resched();				\
-} while (0)
+static inline void ack_bad_irq(int irq)
+{
+	printk(KERN_CRIT "illegal vector %d received!\n", irq);
+	BUG();
+}
 
 #endif /* __ASM_HARDIRQ_H */
diff -Nru a/include/asm-ppc64/iSeries/mf.h b/include/asm-ppc64/iSeries/mf.h
--- a/include/asm-ppc64/iSeries/mf.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-ppc64/iSeries/mf.h	2004-12-24 13:36:31 -08:00
@@ -1,6 +1,7 @@
 /*
  * mf.h
  * Copyright (C) 2001  Troy D. Armstrong IBM Corporation
+ * Copyright (C) 2004  Stephen Rothwell IBM Corporation
  *
  * This modules exists as an interface between a Linux secondary partition
  * running on an iSeries and the primary partition's Virtual Service
@@ -23,48 +24,34 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
-#ifndef MF_H_INCLUDED
-#define MF_H_INCLUDED
+#ifndef _ASM_PPC64_ISERIES_MF_H
+#define _ASM_PPC64_ISERIES_MF_H
 
-#include <linux/proc_fs.h>
+#include <linux/types.h>
 
 #include <asm/iSeries/HvTypes.h>
-#include <asm/iSeries/HvLpEvent.h>
+#include <asm/iSeries/HvCallEvent.h>
 
 struct rtc_time;
 
 typedef void (*MFCompleteHandler)(void *clientToken, int returnCode);
 
-extern void mf_allocateLpEvents(HvLpIndex targetLp, HvLpEvent_Type type,
+extern void mf_allocate_lp_events(HvLpIndex targetLp, HvLpEvent_Type type,
 		unsigned size, unsigned amount, MFCompleteHandler hdlr,
 		void *userToken);
-extern void mf_deallocateLpEvents(HvLpIndex targetLp, HvLpEvent_Type type,
+extern void mf_deallocate_lp_events(HvLpIndex targetLp, HvLpEvent_Type type,
 		unsigned count, MFCompleteHandler hdlr, void *userToken);
 
-extern void mf_powerOff(void);
+extern void mf_power_off(void);
 extern void mf_reboot(void);
 
-extern void mf_displaySrc(u32 word);
-extern void mf_displayProgress(u16 value);
-extern void mf_clearSrc(void);
+extern void mf_display_src(u32 word);
+extern void mf_display_progress(u16 value);
+extern void mf_clear_src(void);
 
 extern void mf_init(void);
 
-extern void mf_setSide(char side);
-extern char mf_getSide(void);
+extern int mf_get_rtc(struct rtc_time *tm);
+extern int mf_set_rtc(struct rtc_time *tm);
 
-extern void mf_setCmdLine(const char *cmdline, int size, u64 side);
-extern int  mf_getCmdLine(char *cmdline, int *size, u64 side);
-
-extern void mf_getSrcHistory(char *buffer, int size);
-
-extern int mf_setVmlinuxChunk(const char *buffer, int size, int offset,
-		u64 side);
-extern int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side);
-
-extern int mf_setRtcTime(unsigned long time);
-extern int mf_getRtcTime(unsigned long *time);
-extern int mf_getRtc( struct rtc_time * tm );
-extern int mf_setRtc( struct rtc_time * tm );
-
-#endif /* MF_H_INCLUDED */
+#endif /* _ASM_PPC64_ISERIES_MF_H */
diff -Nru a/include/asm-ppc64/ide.h b/include/asm-ppc64/ide.h
--- a/include/asm-ppc64/ide.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-ppc64/ide.h	2004-12-24 13:36:49 -08:00
@@ -19,7 +19,7 @@
 #ifdef __KERNEL__
 
 #ifndef MAX_HWIFS
-# define MAX_HWIFS	4
+# define MAX_HWIFS	10
 #endif
 
 #define IDE_ARCH_OBSOLETE_INIT
diff -Nru a/include/asm-ppc64/io.h b/include/asm-ppc64/io.h
--- a/include/asm-ppc64/io.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-ppc64/io.h	2004-12-24 13:37:29 -08:00
@@ -1,4 +1,4 @@
-#ifndef _PPC64_IO_H
+ #ifndef _PPC64_IO_H
 #define _PPC64_IO_H
 
 /* 
@@ -33,6 +33,12 @@
 
 extern unsigned long isa_io_base;
 extern unsigned long pci_io_base;
+extern unsigned long io_page_mask;
+
+#define MAX_ISA_PORT 0x10000
+
+#define _IO_IS_VALID(port) ((port) >= MAX_ISA_PORT || (1 << (port>>PAGE_SHIFT)) \
+			    & io_page_mask)
 
 #ifdef CONFIG_PPC_ISERIES
 /* __raw_* accessors aren't supported on iSeries */
@@ -152,6 +158,8 @@
 extern void _insl_ns(volatile u32 *port, void *buf, int nl);
 extern void _outsl_ns(volatile u32 *port, const void *buf, int nl);
 
+#define mmiowb()
+
 /*
  * output pause versions need a delay at least for the
  * w83c105 ide controller in a p610.
@@ -197,7 +205,7 @@
 #define ioremap_nocache(addr, size)	ioremap((addr), (size))
 extern int iounmap_explicit(volatile void __iomem *addr, unsigned long size);
 extern void iounmap(volatile void __iomem *addr);
-extern void * reserve_phb_iospace(unsigned long size);
+extern void __iomem * reserve_phb_iospace(unsigned long size);
 
 /**
  *	virt_to_phys	-	map virtual addresses to physical
@@ -265,7 +273,7 @@
  * and should not be used directly by device drivers.  Use inb/readb
  * instead.
  */
-static inline int in_8(volatile unsigned char *addr)
+static inline int in_8(const volatile unsigned char __iomem *addr)
 {
 	int ret;
 
@@ -274,13 +282,13 @@
 	return ret;
 }
 
-static inline void out_8(volatile unsigned char *addr, int val)
+static inline void out_8(volatile unsigned char __iomem *addr, int val)
 {
 	__asm__ __volatile__("stb%U0%X0 %1,%0; sync"
 			     : "=m" (*addr) : "r" (val));
 }
 
-static inline int in_le16(volatile unsigned short *addr)
+static inline int in_le16(const volatile unsigned short __iomem *addr)
 {
 	int ret;
 
@@ -289,7 +297,7 @@
 	return ret;
 }
 
-static inline int in_be16(volatile unsigned short *addr)
+static inline int in_be16(const volatile unsigned short __iomem *addr)
 {
 	int ret;
 
@@ -298,19 +306,19 @@
 	return ret;
 }
 
-static inline void out_le16(volatile unsigned short *addr, int val)
+static inline void out_le16(volatile unsigned short __iomem *addr, int val)
 {
 	__asm__ __volatile__("sthbrx %1,0,%2; sync"
 			     : "=m" (*addr) : "r" (val), "r" (addr));
 }
 
-static inline void out_be16(volatile unsigned short *addr, int val)
+static inline void out_be16(volatile unsigned short __iomem *addr, int val)
 {
 	__asm__ __volatile__("sth%U0%X0 %1,%0; sync"
 			     : "=m" (*addr) : "r" (val));
 }
 
-static inline unsigned in_le32(volatile unsigned *addr)
+static inline unsigned in_le32(const volatile unsigned __iomem *addr)
 {
 	unsigned ret;
 
@@ -319,7 +327,7 @@
 	return ret;
 }
 
-static inline unsigned in_be32(volatile unsigned *addr)
+static inline unsigned in_be32(const volatile unsigned __iomem *addr)
 {
 	unsigned ret;
 
@@ -328,19 +336,19 @@
 	return ret;
 }
 
-static inline void out_le32(volatile unsigned *addr, int val)
+static inline void out_le32(volatile unsigned __iomem *addr, int val)
 {
 	__asm__ __volatile__("stwbrx %1,0,%2; sync" : "=m" (*addr)
 			     : "r" (val), "r" (addr));
 }
 
-static inline void out_be32(volatile unsigned *addr, int val)
+static inline void out_be32(volatile unsigned __iomem *addr, int val)
 {
 	__asm__ __volatile__("stw%U0%X0 %1,%0; sync"
 			     : "=m" (*addr) : "r" (val));
 }
 
-static inline unsigned long in_le64(volatile unsigned long *addr)
+static inline unsigned long in_le64(const volatile unsigned long __iomem *addr)
 {
 	unsigned long tmp, ret;
 
@@ -359,7 +367,7 @@
 	return ret;
 }
 
-static inline unsigned long in_be64(volatile unsigned long *addr)
+static inline unsigned long in_be64(const volatile unsigned long __iomem *addr)
 {
 	unsigned long ret;
 
@@ -368,7 +376,7 @@
 	return ret;
 }
 
-static inline void out_le64(volatile unsigned long *addr, unsigned long val)
+static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long val)
 {
 	unsigned long tmp;
 
@@ -385,7 +393,7 @@
 			     : "=&r" (tmp) , "=&r" (val) : "1" (val) , "b" (addr) , "m" (*addr));
 }
 
-static inline void out_be64(volatile unsigned long *addr, unsigned long val)
+static inline void out_be64(volatile unsigned long __iomem *addr, unsigned long val)
 {
 	__asm__ __volatile__("std%U0%X0 %1,%0; sync" : "=m" (*addr) : "r" (val));
 }
@@ -429,6 +437,10 @@
 #define dma_cache_inv(_start,_size)		do { } while (0)
 #define dma_cache_wback(_start,_size)		do { } while (0)
 #define dma_cache_wback_inv(_start,_size)	do { } while (0)
+
+/* Check of existence of legacy devices */
+extern int check_legacy_ioport(unsigned long base_port);
+
 
 #endif /* __KERNEL__ */
 
diff -Nru a/include/asm-ppc64/iommu.h b/include/asm-ppc64/iommu.h
--- a/include/asm-ppc64/iommu.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-ppc64/iommu.h	2004-12-24 13:37:03 -08:00
@@ -110,11 +110,18 @@
 extern void iommu_setup_pSeries(void);
 extern void iommu_setup_u3(void);
 
-/* Creates table for an individual device node */
-extern void iommu_devnode_init(struct device_node *dn);
+/* Frees table for an individual device node */
+extern void iommu_free_table(struct device_node *dn);
 
 #endif /* CONFIG_PPC_MULTIPLATFORM */
 
+#ifdef CONFIG_PPC_PSERIES
+
+/* Creates table for an individual device node */
+extern void iommu_devnode_init_pSeries(struct device_node *dn);
+
+#endif /* CONFIG_PPC_PSERIES */
+
 #ifdef CONFIG_PPC_ISERIES
 
 /* Walks all buses and creates iommu tables */
@@ -125,7 +132,7 @@
 
 struct iSeries_Device_Node;
 /* Creates table for an individual device node */
-extern void iommu_devnode_init(struct iSeries_Device_Node *dn);
+extern void iommu_devnode_init_iSeries(struct iSeries_Device_Node *dn);
 
 #endif /* CONFIG_PPC_ISERIES */
 
diff -Nru a/include/asm-ppc64/irq.h b/include/asm-ppc64/irq.h
--- a/include/asm-ppc64/irq.h	2004-12-24 13:37:31 -08:00
+++ b/include/asm-ppc64/irq.h	2004-12-24 13:37:31 -08:00
@@ -17,13 +17,22 @@
  */
 #define NR_IRQS		512
 
-extern void disable_irq(unsigned int);
-extern void disable_irq_nosync(unsigned int);
-extern void enable_irq(unsigned int);
-
 /* this number is used when no interrupt has been assigned */
 #define NO_IRQ			(-1)
 
+/*
+ * These constants are used for passing information about interrupt
+ * signal polarity and level/edge sensing to the low-level PIC chip
+ * drivers.
+ */
+#define IRQ_SENSE_MASK		0x1
+#define IRQ_SENSE_LEVEL		0x1	/* interrupt on active level */
+#define IRQ_SENSE_EDGE		0x0	/* interrupt triggered by edge */
+
+#define IRQ_POLARITY_MASK	0x2
+#define IRQ_POLARITY_POSITIVE	0x2	/* high level or low->high edge */
+#define IRQ_POLARITY_NEGATIVE	0x0	/* low level or high->low edge */
+
 #define get_irq_desc(irq) (&irq_desc[(irq)])
 
 /* Define a way to iterate across irqs. */
@@ -80,7 +89,6 @@
 
 struct irqaction;
 struct pt_regs;
-int handle_irq_event(int, struct pt_regs *, struct irqaction *);
 
 #ifdef CONFIG_IRQSTACKS
 /*
@@ -91,7 +99,7 @@
 
 extern void irq_ctx_init(void);
 extern void call_do_softirq(struct thread_info *tp);
-extern int call_handle_irq_event(int irq, struct pt_regs *regs,
+extern int call_handle_IRQ_event(int irq, struct pt_regs *regs,
 			struct irqaction *action, struct thread_info *tp);
 
 #define __ARCH_HAS_DO_SOFTIRQ
diff -Nru a/include/asm-ppc64/machdep.h b/include/asm-ppc64/machdep.h
--- a/include/asm-ppc64/machdep.h	2004-12-24 13:36:33 -08:00
+++ b/include/asm-ppc64/machdep.h	2004-12-24 13:36:34 -08:00
@@ -28,6 +28,7 @@
 	int   (*probe)(void);
 	void  (*kick_cpu)(int nr);
 	void  (*setup_cpu)(int nr);
+	void  (*late_setup_cpu)(int nr);
 	void  (*take_timebase)(void);
 	void  (*give_timebase)(void);
 };
@@ -86,6 +87,7 @@
 	void		(*power_off)(void);
 	void		(*halt)(void);
 	void		(*panic)(char *str);
+	void		(*cpu_die)(void);
 
 	int		(*set_rtc_time)(struct rtc_time *);
 	void		(*get_rtc_time)(struct rtc_time *);
@@ -114,6 +116,12 @@
 	 */
 	long	 	(*feature_call)(unsigned int feature, ...);
 
+	/* Check availability of legacy devices like i8042 */
+	int 		(*check_legacy_ioport)(unsigned int baseport);
+
+	/* Get legacy PCI/IDE interrupt mapping */ 
+	int		(*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
+	
 };
 
 extern struct machdep_calls ppc_md;
diff -Nru a/include/asm-ppc64/mmu.h b/include/asm-ppc64/mmu.h
--- a/include/asm-ppc64/mmu.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-ppc64/mmu.h	2004-12-24 13:37:01 -08:00
@@ -24,6 +24,7 @@
 typedef struct {
 	mm_context_id_t id;
 #ifdef CONFIG_HUGETLB_PAGE
+	pgd_t *huge_pgdir;
 	u16 htlb_segs; /* bitmask */
 #endif
 } mm_context_t;
diff -Nru a/include/asm-ppc64/paca.h b/include/asm-ppc64/paca.h
--- a/include/asm-ppc64/paca.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-ppc64/paca.h	2004-12-24 13:36:48 -08:00
@@ -99,11 +99,17 @@
 	u64 exdsi[8];		/* used for linear mapping hash table misses */
 
 	/*
-	 * iSeries structues which the hypervisor knows about - Not
-	 * sure if these particularly need to be cacheline aligned.
+	 * iSeries structure which the hypervisor knows about -
+	 * this structure should not cross a page boundary.
+	 * The vpa_init/register_vpa call is now known to fail if the
+	 * lppaca structure crosses a page boundary.
 	 * The lppaca is also used on POWER5 pSeries boxes.
+	 * The lppaca is 640 bytes long, and cannot readily change
+	 * since the hypervisor knows its layout, so a 1kB
+	 * alignment will suffice to ensure that it doesn't
+	 * cross a page boundary.
 	 */
-	struct ItLpPaca lppaca __attribute__((aligned(0x80)));
+	struct ItLpPaca lppaca __attribute__((__aligned__(0x400)));
 #ifdef CONFIG_PPC_ISERIES
 	struct ItLpRegSave reg_save;
 #endif
diff -Nru a/include/asm-ppc64/page.h b/include/asm-ppc64/page.h
--- a/include/asm-ppc64/page.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-ppc64/page.h	2004-12-24 13:36:17 -08:00
@@ -64,7 +64,6 @@
 #define is_hugepage_only_range(addr, len) \
 	(touches_hugepage_high_range((addr), (len)) || \
 	  touches_hugepage_low_range((addr), (len)))
-#define hugetlb_free_pgtables free_pgtables
 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
 
 #define in_hugepage_area(context, addr) \
diff -Nru a/include/asm-ppc64/pci-bridge.h b/include/asm-ppc64/pci-bridge.h
--- a/include/asm-ppc64/pci-bridge.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-ppc64/pci-bridge.h	2004-12-24 13:36:17 -08:00
@@ -18,39 +18,31 @@
 extern struct pci_controller*
 pci_find_hose_for_OF_device(struct device_node* node);
 
-enum phb_types { 
-	phb_type_unknown    = 0x0,
-	phb_type_hypervisor = 0x1,
-	phb_type_python     = 0x10,
-	phb_type_speedwagon = 0x11,
-	phb_type_winnipeg   = 0x12,
-	phb_type_apple      = 0xff
-};
-
 /*
  * Structure of a PCI controller (host bridge)
  */
 struct pci_controller {
 	char what[8];                     /* Eye catcher      */
-	enum phb_types type;              /* Type of hardware */
 	struct pci_bus *bus;
+	char is_dynamic;
 	void *arch_data;
 	struct list_head list_node;
 
 	int first_busno;
 	int last_busno;
 
-	void *io_base_virt;
+	void __iomem *io_base_virt;
 	unsigned long io_base_phys;
 
 	/* Some machines have a non 1:1 mapping of
 	 * the PCI memory space in the CPU bus space
 	 */
 	unsigned long pci_mem_offset;
+	unsigned long pci_io_size;
 
 	struct pci_ops *ops;
-	volatile unsigned int *cfg_addr;
-	volatile unsigned char *cfg_data;
+	volatile unsigned int __iomem *cfg_addr;
+	volatile unsigned char __iomem *cfg_data;
 
 	/* Currently, we limit ourselves to 1 IO range and 3 mem
 	 * ranges since the common pci_bus structure can't handle more
@@ -88,12 +80,20 @@
 }
 
 extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
-					 struct device_node *dev, int primary);
+					 struct device_node *dev);
+
+extern int pcibios_remove_root_bus(struct pci_controller *phb);
+
+extern void phbs_remap_io(void);
+
+static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
+{
+	struct device_node *busdn = bus->sysdata;
+
+	BUG_ON(busdn == NULL);
+	return busdn->phb;
+}
 
-/* Use this macro after the PCI bus walk for max performance when it
- * is known that sysdata is correct.
- */
-#define PCI_GET_DN(dev) ((struct device_node *)((dev)->sysdata))
 
 #endif
 #endif /* __KERNEL__ */
diff -Nru a/include/asm-ppc64/pci.h b/include/asm-ppc64/pci.h
--- a/include/asm-ppc64/pci.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-ppc64/pci.h	2004-12-24 13:36:47 -08:00
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/dma-mapping.h>
+#include <asm/machdep.h>
 #include <asm/scatterlist.h>
 #include <asm/io.h>
 #include <asm/prom.h>
@@ -20,6 +21,8 @@
 #define PCIBIOS_MIN_IO		0x1000
 #define PCIBIOS_MIN_MEM		0x10000000
 
+struct pci_dev;
+
 #ifdef CONFIG_PPC_ISERIES
 #define pcibios_scan_all_fns(a, b)	0
 #else
@@ -36,7 +39,13 @@
 	/* We don't do dynamic PCI IRQ allocation */
 }
 
-struct pci_dev;
+#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
+static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
+{
+	if (ppc_md.pci_get_legacy_ide_irq)
+		return ppc_md.pci_get_legacy_ide_irq(dev, channel);
+	return channel ? 15 : 14;
+}
 
 #define HAVE_ARCH_PCI_MWI 1
 static inline int pcibios_prep_mwi(struct pci_dev *dev)
@@ -228,6 +237,8 @@
 
 extern void
 pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus);
+
+extern struct pci_controller *init_phb_dynamic(struct device_node *dn);
 
 extern int pci_read_irq_line(struct pci_dev *dev);
 
diff -Nru a/include/asm-ppc64/pgtable.h b/include/asm-ppc64/pgtable.h
--- a/include/asm-ppc64/pgtable.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-ppc64/pgtable.h	2004-12-24 13:37:29 -08:00
@@ -67,12 +67,6 @@
 #define IMALLOC_END       (IMALLOC_BASE + PGTABLE_EA_MASK)
 
 /*
- * Define the address range mapped virt <-> physical
- */
-#define KRANGE_START KERNELBASE
-#define KRANGE_END   (KRANGE_START + PGTABLE_EA_MASK)
-
-/*
  * Define the user address range
  */
 #define USER_START (0UL)
@@ -98,6 +92,7 @@
 #define _PAGE_BUSY	0x0800 /* software: PTE & hash are busy */ 
 #define _PAGE_SECONDARY 0x8000 /* software: HPTE is in secondary group */
 #define _PAGE_GROUP_IX  0x7000 /* software: HPTE index within group */
+#define _PAGE_HUGE	0x10000 /* 16MB page */
 /* Bits 0x7000 identify the index within an HPT Group */
 #define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | _PAGE_SECONDARY | _PAGE_GROUP_IX)
 /* PAGE_MASK gives the right answer below, but only by accident */
@@ -157,19 +152,19 @@
 #endif /* __ASSEMBLY__ */
 
 /* shift to put page number into pte */
-#define PTE_SHIFT (16)
+#define PTE_SHIFT (17)
 
 /* We allow 2^41 bytes of real memory, so we need 29 bits in the PMD
  * to give the PTE page number.  The bottom two bits are for flags. */
 #define PMD_TO_PTEPAGE_SHIFT (2)
 
 #ifdef CONFIG_HUGETLB_PAGE
-#define _PMD_HUGEPAGE	0x00000001U
-#define HUGEPTE_BATCH_SIZE (1<<(HPAGE_SHIFT-PMD_SHIFT))
 
 #ifndef __ASSEMBLY__
 int hash_huge_page(struct mm_struct *mm, unsigned long access,
 		   unsigned long ea, unsigned long vsid, int local);
+
+void hugetlb_mm_free_pgd(struct mm_struct *mm);
 #endif /* __ASSEMBLY__ */
 
 #define HAVE_ARCH_UNMAPPED_AREA
@@ -177,7 +172,7 @@
 #else
 
 #define hash_huge_page(mm,a,ea,vsid,local)	-1
-#define _PMD_HUGEPAGE	0
+#define hugetlb_mm_free_pgd(mm)			do {} while (0)
 
 #endif
 
@@ -213,10 +208,8 @@
 #define pmd_set(pmdp, ptep) 	\
 	(pmd_val(*(pmdp)) = (__ba_to_bpn(ptep) << PMD_TO_PTEPAGE_SHIFT))
 #define pmd_none(pmd)		(!pmd_val(pmd))
-#define	pmd_hugepage(pmd)	(!!(pmd_val(pmd) & _PMD_HUGEPAGE))
-#define	pmd_bad(pmd)		(((pmd_val(pmd)) == 0) || pmd_hugepage(pmd))
-#define	pmd_present(pmd)	((!pmd_hugepage(pmd)) \
-				 && (pmd_val(pmd) & ~_PMD_HUGEPAGE) != 0)
+#define	pmd_bad(pmd)		(pmd_val(pmd) == 0)
+#define	pmd_present(pmd)	(pmd_val(pmd) != 0)
 #define	pmd_clear(pmdp)		(pmd_val(*(pmdp)) = 0)
 #define pmd_page_kernel(pmd)	\
 	(__bpn_to_ba(pmd_val(pmd) >> PMD_TO_PTEPAGE_SHIFT))
@@ -269,6 +262,7 @@
 static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;}
 static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;}
 static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;}
+static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_HUGE;}
 
 static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
 static inline void pte_cache(pte_t pte)   { pte_val(pte) &= ~_PAGE_NO_CACHE; }
@@ -294,6 +288,8 @@
 	pte_val(pte) |= _PAGE_DIRTY; return pte; }
 static inline pte_t pte_mkyoung(pte_t pte) {
 	pte_val(pte) |= _PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mkhuge(pte_t pte) {
+	pte_val(pte) |= _PAGE_HUGE; return pte; }
 
 /* Atomic PTE updates */
 static inline unsigned long pte_update(pte_t *p, unsigned long clr)
@@ -464,6 +460,10 @@
 
 extern void paging_init(void);
 
+struct mmu_gather;
+void hugetlb_free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *prev,
+			   unsigned long start, unsigned long end);
+
 /*
  * This gets called at the end of handling a page fault, when
  * the kernel has put a new PTE into the page table for the process.
@@ -492,7 +492,8 @@
  */
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range 
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 void pgtable_cache_init(void);
 
diff -Nru a/include/asm-ppc64/plpar_wrappers.h b/include/asm-ppc64/plpar_wrappers.h
--- a/include/asm-ppc64/plpar_wrappers.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-ppc64/plpar_wrappers.h	2004-12-24 13:36:55 -08:00
@@ -22,11 +22,13 @@
 	return(0); 
 }
 
-static inline long register_vpa(unsigned long flags, unsigned long proc, unsigned long vpa)
+static inline long register_vpa(unsigned long flags, unsigned long proc,
+				unsigned long vpa)
 {
-	plpar_hcall_norets(H_REGISTER_VPA, flags, proc, vpa);
-	return(0); 
+	return plpar_hcall_norets(H_REGISTER_VPA, flags, proc, vpa);
 }
+
+void vpa_init(int cpu);
 
 static inline long plpar_pte_remove(unsigned long flags,
 				    unsigned long ptex,
diff -Nru a/include/asm-ppc64/processor.h b/include/asm-ppc64/processor.h
--- a/include/asm-ppc64/processor.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-ppc64/processor.h	2004-12-24 13:36:18 -08:00
@@ -389,6 +389,7 @@
 #define PLATFORM_ISERIES_LPAR 0x0201
 #define PLATFORM_LPAR         0x0001
 #define PLATFORM_POWERMAC     0x0400
+#define PLATFORM_MAPLE        0x0500
 
 /* Compatibility with drivers coming from PPC32 world */
 #define _machine	(systemcfg->platform)
diff -Nru a/include/asm-ppc64/prom.h b/include/asm-ppc64/prom.h
--- a/include/asm-ppc64/prom.h	2004-12-24 13:37:31 -08:00
+++ b/include/asm-ppc64/prom.h	2004-12-24 13:37:31 -08:00
@@ -56,6 +56,8 @@
 	u32	off_mem_rsvmap;		/* offset to memory reserve map */
 	u32	version;		/* format version */
 	u32	last_comp_version;	/* last compatible version */
+	/* version 2 fields below */
+	u32	boot_cpuid_phys;	/* Which physical CPU id we're booting on */
 };
 
 
@@ -91,33 +93,6 @@
 	struct isa_address isa_addr;
 	struct pci_address pci_addr;
 	unsigned int size;
-};
-
-struct pci_range32 {
-	struct pci_address child_addr;
-	unsigned int  parent_addr;
-  	unsigned long size; 
-};
-
-struct pci_range64 {
-	struct pci_address child_addr;
-  	unsigned long parent_addr;
-        unsigned long size; 
-};
-
-union pci_range {
-	struct {
-		struct pci_address addr;
-		u32 phys;
-		u32 size_hi;
-	} pci32;
-	struct {
-		struct pci_address addr;
-		u32 phys_hi;
-		u32 phys_lo;
-		u32 size_hi;
-		u32 size_lo;
-	} pci64;
 };
 
 struct of_tce_table {
diff -Nru a/include/asm-ppc64/ptrace-common.h b/include/asm-ppc64/ptrace-common.h
--- a/include/asm-ppc64/ptrace-common.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-ppc64/ptrace-common.h	2004-12-24 13:37:00 -08:00
@@ -58,6 +58,7 @@
 	struct pt_regs *regs = task->thread.regs;
 	if (regs != NULL)
 		regs->msr |= MSR_SE;
+	set_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
 }
 
 static inline void clear_single_step(struct task_struct *task)
@@ -65,6 +66,7 @@
 	struct pt_regs *regs = task->thread.regs;
 	if (regs != NULL)
 		regs->msr &= ~MSR_SE;
+	clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
 }
 
 #endif /* _PPC64_PTRACE_COMMON_H */
diff -Nru a/include/asm-ppc64/rtas.h b/include/asm-ppc64/rtas.h
--- a/include/asm-ppc64/rtas.h	2004-12-24 13:37:30 -08:00
+++ b/include/asm-ppc64/rtas.h	2004-12-24 13:37:30 -08:00
@@ -149,7 +149,7 @@
 	unsigned long target:4;			/* Target of failed operation */
 	unsigned long type:8;			/* General event or error*/
 	unsigned long extended_log_length:32;	/* length in bytes */
-	unsigned char buffer[1];		/* allocated by klimit bump */
+	unsigned char buffer[1];
 };
 
 struct flash_block {
diff -Nru a/include/asm-ppc64/serial.h b/include/asm-ppc64/serial.h
--- a/include/asm-ppc64/serial.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-ppc64/serial.h	2004-12-24 13:37:03 -08:00
@@ -4,8 +4,6 @@
 #ifndef _PPC64_SERIAL_H
 #define _PPC64_SERIAL_H
 
-#include <linux/config.h>
-
 /*
  * This assumes you have a 1.8432 MHz clock for your UART.
  *
@@ -18,113 +16,8 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
-#define BASE_BAUD ( 1843200 / 16 )
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define RS_TABLE_SIZE  64
-#else
-#define RS_TABLE_SIZE  4
-#endif
-
-/* Standard COM flags (except for COM4, because of the 8514 problem) */
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS ASYNC_BOOT_AUTOCONF
-#endif
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define FOURPORT_FLAGS ASYNC_FOURPORT
-#define ACCENT_FLAGS 0
-#define BOCA_FLAGS 0
-#define HUB6_FLAGS 0
-#endif
-	
-/*
- * The following define the access methods for the HUB6 card. All
- * access is through two ports for all 24 possible chips. The card is
- * selected through the high 2 bits, the port on that card with the
- * "middle" 3 bits, and the register on that port with the bottom
- * 3 bits.
- *
- * While the access port and interrupt is configurable, the default
- * port locations are 0x302 for the port control register, and 0x303
- * for the data read/write register. Normally, the interrupt is at irq3
- * but can be anything from 3 to 7 inclusive. Note that using 3 will
- * require disabling com2.
- */
 
-#define C_P(card,port) (((card)<<6|(port)<<3) + 1)
-
-#define STD_SERIAL_PORT_DEFNS			\
-	/* UART CLK   PORT IRQ     FLAGS        */			\
-	{ 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS },	/* ttyS0 */	\
-	{ 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS },	/* ttyS1 */	\
-	{ 0, BASE_BAUD, 0x890, 0xf, STD_COM_FLAGS },	/* ttyS2 */	\
-	{ 0, BASE_BAUD, 0x898, 0xe, STD_COM_FLAGS },	/* ttyS3 */
-
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define EXTRA_SERIAL_PORT_DEFNS			\
-	{ 0, BASE_BAUD, 0x1A0, 9, FOURPORT_FLAGS }, 	/* ttyS4 */	\
-	{ 0, BASE_BAUD, 0x1A8, 9, FOURPORT_FLAGS },	/* ttyS5 */	\
-	{ 0, BASE_BAUD, 0x1B0, 9, FOURPORT_FLAGS },	/* ttyS6 */	\
-	{ 0, BASE_BAUD, 0x1B8, 9, FOURPORT_FLAGS },	/* ttyS7 */	\
-	{ 0, BASE_BAUD, 0x2A0, 5, FOURPORT_FLAGS },	/* ttyS8 */	\
-	{ 0, BASE_BAUD, 0x2A8, 5, FOURPORT_FLAGS },	/* ttyS9 */	\
-	{ 0, BASE_BAUD, 0x2B0, 5, FOURPORT_FLAGS },	/* ttyS10 */	\
-	{ 0, BASE_BAUD, 0x2B8, 5, FOURPORT_FLAGS },	/* ttyS11 */	\
-	{ 0, BASE_BAUD, 0x330, 4, ACCENT_FLAGS },	/* ttyS12 */	\
-	{ 0, BASE_BAUD, 0x338, 4, ACCENT_FLAGS },	/* ttyS13 */	\
-	{ 0, BASE_BAUD, 0x000, 0, 0 },	/* ttyS14 (spare) */		\
-	{ 0, BASE_BAUD, 0x000, 0, 0 },	/* ttyS15 (spare) */		\
-	{ 0, BASE_BAUD, 0x100, 12, BOCA_FLAGS },	/* ttyS16 */	\
-	{ 0, BASE_BAUD, 0x108, 12, BOCA_FLAGS },	/* ttyS17 */	\
-	{ 0, BASE_BAUD, 0x110, 12, BOCA_FLAGS },	/* ttyS18 */	\
-	{ 0, BASE_BAUD, 0x118, 12, BOCA_FLAGS },	/* ttyS19 */	\
-	{ 0, BASE_BAUD, 0x120, 12, BOCA_FLAGS },	/* ttyS20 */	\
-	{ 0, BASE_BAUD, 0x128, 12, BOCA_FLAGS },	/* ttyS21 */	\
-	{ 0, BASE_BAUD, 0x130, 12, BOCA_FLAGS },	/* ttyS22 */	\
-	{ 0, BASE_BAUD, 0x138, 12, BOCA_FLAGS },	/* ttyS23 */	\
-	{ 0, BASE_BAUD, 0x140, 12, BOCA_FLAGS },	/* ttyS24 */	\
-	{ 0, BASE_BAUD, 0x148, 12, BOCA_FLAGS },	/* ttyS25 */	\
-	{ 0, BASE_BAUD, 0x150, 12, BOCA_FLAGS },	/* ttyS26 */	\
-	{ 0, BASE_BAUD, 0x158, 12, BOCA_FLAGS },	/* ttyS27 */	\
-	{ 0, BASE_BAUD, 0x160, 12, BOCA_FLAGS },	/* ttyS28 */	\
-	{ 0, BASE_BAUD, 0x168, 12, BOCA_FLAGS },	/* ttyS29 */	\
-	{ 0, BASE_BAUD, 0x170, 12, BOCA_FLAGS },	/* ttyS30 */	\
-	{ 0, BASE_BAUD, 0x178, 12, BOCA_FLAGS },	/* ttyS31 */
-#else
-#define EXTRA_SERIAL_PORT_DEFNS
-#endif
-
-/* You can have up to four HUB6's in the system, but I've only
- * included two cards here for a total of twelve ports.
- */
-#if (defined(CONFIG_HUB6) && defined(CONFIG_SERIAL_MANY_PORTS))
-#define HUB6_SERIAL_PORT_DFNS		\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,0) },  /* ttyS32 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,1) },  /* ttyS33 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,2) },  /* ttyS34 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,3) },  /* ttyS35 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,4) },  /* ttyS36 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(0,5) },  /* ttyS37 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,0) },  /* ttyS38 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,1) },  /* ttyS39 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,2) },  /* ttyS40 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,3) },  /* ttyS41 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,4) },  /* ttyS42 */	\
-	{ 0, BASE_BAUD, 0x302, 3, HUB6_FLAGS, C_P(1,5) },  /* ttyS43 */
-#else
-#define HUB6_SERIAL_PORT_DFNS
-#endif
-
-#define MCA_SERIAL_PORT_DFNS
-
-#define SERIAL_PORT_DFNS		\
-	STD_SERIAL_PORT_DEFNS		\
-	EXTRA_SERIAL_PORT_DEFNS		\
-	HUB6_SERIAL_PORT_DFNS		\
-	MCA_SERIAL_PORT_DFNS
+/* Default baud base if not found in device-tree */
+#define BASE_BAUD ( 1843200 / 16 )
 
 #endif /* _PPC64_SERIAL_H */
diff -Nru a/include/asm-ppc64/smp.h b/include/asm-ppc64/smp.h
--- a/include/asm-ppc64/smp.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-ppc64/smp.h	2004-12-24 13:36:16 -08:00
@@ -27,6 +27,9 @@
 #include <asm/paca.h>
 
 extern int boot_cpuid;
+extern int boot_cpuid_phys;
+
+extern void cpu_die(void) __attribute__((noreturn));
 
 #ifdef CONFIG_SMP
 
@@ -52,22 +55,28 @@
 #endif
 #define PPC_MSG_DEBUGGER_BREAK  3
 
-extern cpumask_t irq_affinity[];
-
 void smp_init_iSeries(void);
 void smp_init_pSeries(void);
 
 extern int __cpu_disable(void);
 extern void __cpu_die(unsigned int cpu);
-extern void cpu_die(void) __attribute__((noreturn));
-extern int query_cpu_stopped(unsigned int pcpu);
-#endif /* !(CONFIG_SMP) */
+#endif /* CONFIG_SMP */
 
 #define get_hard_smp_processor_id(CPU) (paca[(CPU)].hw_cpu_id)
 #define set_hard_smp_processor_id(CPU, VAL) \
 	do { (paca[(CPU)].hw_cpu_id = (VAL)); } while (0)
 
 extern int smt_enabled_at_boot;
+
+extern int smp_mpic_probe(void);
+extern void smp_mpic_setup_cpu(int cpu);
+extern void smp_mpic_message_pass(int target, int msg);
+extern void smp_generic_kick_cpu(int nr);
+
+extern void smp_generic_give_timebase(void);
+extern void smp_generic_take_timebase(void);
+
+extern struct smp_ops_t *smp_ops;
 
 #endif /* __ASSEMBLY__ */
 
diff -Nru a/include/asm-ppc64/sstep.h b/include/asm-ppc64/sstep.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-ppc64/sstep.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2004 Paul Mackerras <paulus@au.ibm.com>, IBM
+ *
+ * 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.
+ */
+
+struct pt_regs;
+
+/* Emulate instructions that cause a transfer of control. */
+extern int emulate_step(struct pt_regs *regs, unsigned int instr);
diff -Nru a/include/asm-ppc64/thread_info.h b/include/asm-ppc64/thread_info.h
--- a/include/asm-ppc64/thread_info.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-ppc64/thread_info.h	2004-12-24 13:36:18 -08:00
@@ -82,7 +82,7 @@
 
 #endif /* __ASSEMBLY__ */
 
-#define PREEMPT_ACTIVE		0x4000000
+#define PREEMPT_ACTIVE		0x10000000
 
 /*
  * thread information flag bit numbers
@@ -97,6 +97,7 @@
 #define TIF_RUN_LIGHT		6	/* iSeries run light */
 #define TIF_ABI_PENDING		7	/* 32/64 bit switch needed */
 #define TIF_SYSCALL_AUDIT	8	/* syscall auditing active */
+#define TIF_SINGLESTEP		9	/* singlestepping active */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -108,6 +109,7 @@
 #define _TIF_RUN_LIGHT		(1<<TIF_RUN_LIGHT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
+#define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
 
 #define _TIF_USER_WORK_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
diff -Nru a/include/asm-ppc64/timex.h b/include/asm-ppc64/timex.h
--- a/include/asm-ppc64/timex.h	2004-12-24 13:37:32 -08:00
+++ b/include/asm-ppc64/timex.h	2004-12-24 13:37:32 -08:00
@@ -12,10 +12,6 @@
 #define _ASMPPC64_TIMEX_H
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 typedef unsigned long cycles_t;
 
diff -Nru a/include/asm-ppc64/topology.h b/include/asm-ppc64/topology.h
--- a/include/asm-ppc64/topology.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-ppc64/topology.h	2004-12-24 13:37:29 -08:00
@@ -37,8 +37,25 @@
 
 #define nr_cpus_node(node)	(nr_cpus_in_node[node])
 
-/* Cross-node load balancing interval. */
-#define NODE_BALANCE_RATE 10
+/* sched_domains SD_NODE_INIT for PPC64 machines */
+#define SD_NODE_INIT (struct sched_domain) {		\
+	.span			= CPU_MASK_NONE,	\
+	.parent			= NULL,			\
+	.groups			= NULL,			\
+	.min_interval		= 8,			\
+	.max_interval		= 32,			\
+	.busy_factor		= 32,			\
+	.imbalance_pct		= 125,			\
+	.cache_hot_time		= (10*1000),		\
+	.cache_nice_tries	= 1,			\
+	.per_cpu_gain		= 100,			\
+	.flags			= SD_LOAD_BALANCE	\
+				| SD_BALANCE_EXEC	\
+				| SD_WAKE_BALANCE,	\
+	.last_balance		= jiffies,		\
+	.balance_interval	= 1,			\
+	.nr_balance_failed	= 0,			\
+}
 
 #else /* !CONFIG_NUMA */
 
diff -Nru a/include/asm-ppc64/udbg.h b/include/asm-ppc64/udbg.h
--- a/include/asm-ppc64/udbg.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-ppc64/udbg.h	2004-12-24 13:36:19 -08:00
@@ -1,6 +1,8 @@
 #ifndef __UDBG_HDR
 #define __UDBG_HDR
 
+#include <linux/compiler.h>
+
 /*
  * c 2001 PPC 64 Team, IBM Corp
  *
@@ -10,7 +12,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
-void udbg_init_uart(void *comport);
+void udbg_init_uart(void __iomem *comport, unsigned int speed);
 void udbg_putc(unsigned char c);
 unsigned char udbg_getc(void);
 int udbg_getc_poll(void);
diff -Nru a/include/asm-ppc64/unistd.h b/include/asm-ppc64/unistd.h
--- a/include/asm-ppc64/unistd.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-ppc64/unistd.h	2004-12-24 13:36:17 -08:00
@@ -202,19 +202,19 @@
 #define __NR_vfork		189
 #define __NR_ugetrlimit		190	/* SuS compliant getrlimit */
 #define __NR_readahead		191
-#define __NR_mmap2		192
-#define __NR_truncate64		193
-#define __NR_ftruncate64	194
-#define __NR_stat64		195
-#define __NR_lstat64		196
-#define __NR_fstat64		197
+/* #define __NR_mmap2		192	32bit only */
+/* #define __NR_truncate64	193	32bit only */
+/* #define __NR_ftruncate64	194	32bit only */
+/* #define __NR_stat64		195	32bit only */
+/* #define __NR_lstat64		196	32bit only */
+/* #define __NR_fstat64		197	32bit only */
 #define __NR_pciconfig_read	198
 #define __NR_pciconfig_write	199
 #define __NR_pciconfig_iobase	200
 #define __NR_multiplexer	201
 #define __NR_getdents64		202
 #define __NR_pivot_root		203
-#define __NR_fcntl64		204
+/* #define __NR_fcntl64		204	32bit only */
 #define __NR_madvise		205
 #define __NR_mincore		206
 #define __NR_gettid		207
@@ -236,7 +236,7 @@
 #define __NR_sched_getaffinity	223
 /* 224 currently unused */
 #define __NR_tuxcall		225
-#define __NR_sendfile64		226
+/* #define __NR_sendfile64	226	32bit only */
 #define __NR_io_setup		227
 #define __NR_io_destroy		228
 #define __NR_io_getevents	229
@@ -264,7 +264,7 @@
 #define __NR_utimes		251
 #define __NR_statfs64		252
 #define __NR_fstatfs64		253
-#define __NR_fadvise64_64	254
+/* #define __NR_fadvise64_64	254	32bit only */
 #define __NR_rtas		255
 /* Number 256 is reserved for sys_debug_setcontext */
 /* Number 257 is reserved for vserver */
@@ -279,8 +279,11 @@
 #define __NR_mq_notify		266
 #define __NR_mq_getsetattr	267
 #define __NR_kexec_load		268
+#define __NR_add_key		269
+#define __NR_request_key	270
+#define __NR_keyctl		271
 
-#define __NR_syscalls		269
+#define __NR_syscalls		272
 #ifdef __KERNEL__
 #define NR_syscalls	__NR_syscalls
 #endif
diff -Nru a/include/asm-s390/debug.h b/include/asm-s390/debug.h
--- a/include/asm-s390/debug.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-s390/debug.h	2004-12-24 13:36:55 -08:00
@@ -127,6 +127,8 @@
 
 void debug_set_level(debug_info_t* id, int new_level);
 
+void debug_stop_all(void);
+
 extern inline debug_entry_t* 
 debug_event(debug_info_t* id, int level, void* data, int length)
 {
diff -Nru a/include/asm-s390/elf.h b/include/asm-s390/elf.h
--- a/include/asm-s390/elf.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-s390/elf.h	2004-12-24 13:37:19 -08:00
@@ -98,6 +98,7 @@
 
 #include <asm/ptrace.h>
 #include <asm/user.h>
+#include <asm/system.h>		/* for save_access_regs */
 
 
 typedef s390_fp_regs elf_fpregset_t;
@@ -152,6 +153,7 @@
 static inline int dump_regs(struct pt_regs *ptregs, elf_gregset_t *regs)
 {
 	memcpy(&regs->psw, &ptregs->psw, sizeof(regs->psw)+sizeof(regs->gprs));
+	save_access_regs(regs->acrs);
 	regs->orig_gpr2 = ptregs->orig_gpr2;
 	return 1;
 }
@@ -160,8 +162,10 @@
 
 static inline int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
 {
-	dump_regs(__KSTK_PTREGS(tsk), regs);
+	struct pt_regs *ptregs = __KSTK_PTREGS(tsk);
+	memcpy(&regs->psw, &ptregs->psw, sizeof(regs->psw)+sizeof(regs->gprs));
 	memcpy(regs->acrs, tsk->thread.acrs, sizeof(regs->acrs));
+	regs->orig_gpr2 = ptregs->orig_gpr2;
 	return 1;
 }
 
@@ -169,7 +173,10 @@
 
 static inline int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
 {
-	memcpy(fpregs, &tsk->thread.fp_regs, sizeof(elf_fpregset_t));
+	if (tsk == current)
+		save_fp_regs(fpregs);
+	else
+		memcpy(fpregs, &tsk->thread.fp_regs, sizeof(elf_fpregset_t));
 	return 1;
 }
 
diff -Nru a/include/asm-s390/extmem.h b/include/asm-s390/extmem.h
--- a/include/asm-s390/extmem.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-s390/extmem.h	2004-12-24 13:37:02 -08:00
@@ -8,12 +8,25 @@
 #ifndef _ASM_S390X_DCSS_H
 #define _ASM_S390X_DCSS_H
 #ifndef __ASSEMBLY__
-#define SEGMENT_SHARED_RW       0
-#define SEGMENT_SHARED_RO       1
-#define SEGMENT_EXCLUSIVE_RW    2
-#define SEGMENT_EXCLUSIVE_RO    3
+
+/* possible values for segment type as returned by segment_info */
+#define SEG_TYPE_SW 0
+#define SEG_TYPE_EW 1
+#define SEG_TYPE_SR 2
+#define SEG_TYPE_ER 3
+#define SEG_TYPE_SN 4
+#define SEG_TYPE_EN 5
+#define SEG_TYPE_SC 6
+#define SEG_TYPE_EWEN 7
+
+#define SEGMENT_SHARED 0
+#define SEGMENT_EXCLUSIVE 1
+
 extern int segment_load (char *name,int segtype,unsigned long *addr,unsigned long *length);
 extern void segment_unload(char *name);
-extern void segment_replace(char *name);
+extern void segment_save(char *name);
+extern int segment_type (char* name);
+extern int segment_modify_shared (char *name, int do_nonshared);
+
 #endif
 #endif
diff -Nru a/include/asm-s390/hardirq.h b/include/asm-s390/hardirq.h
--- a/include/asm-s390/hardirq.h	2004-12-24 13:37:32 -08:00
+++ b/include/asm-s390/hardirq.h	2004-12-24 13:37:32 -08:00
@@ -38,28 +38,7 @@
 
 #define __ARCH_IRQ_STAT
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 extern void account_ticks(struct pt_regs *);
 
diff -Nru a/include/asm-s390/io.h b/include/asm-s390/io.h
--- a/include/asm-s390/io.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-s390/io.h	2004-12-24 13:37:01 -08:00
@@ -105,6 +105,8 @@
 #define outb(x,addr) ((void) writeb(x,addr))
 #define outb_p(x,addr) outb(x,addr)
 
+#define mmiowb()
+
 #endif /* __KERNEL__ */
 
 #endif
diff -Nru a/include/asm-s390/siginfo.h b/include/asm-s390/siginfo.h
--- a/include/asm-s390/siginfo.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-s390/siginfo.h	2004-12-24 13:37:19 -08:00
@@ -9,7 +9,6 @@
 #ifndef _S390_SIGINFO_H
 #define _S390_SIGINFO_H
 
-#define HAVE_ARCH_SI_CODES
 #ifdef __s390x__
 #define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
 #endif
@@ -21,75 +20,5 @@
 #endif
 
 #include <asm-generic/siginfo.h>
-
-/*
- * SIGILL si_codes
- */
-#define ILL_ILLOPC	(__SI_FAULT|1)	/* illegal opcode */
-#define ILL_ILLOPN	(__SI_FAULT|2)	/* illegal operand */
-#define ILL_ILLADR	(__SI_FAULT|3)	/* illegal addressing mode */
-#define ILL_ILLTRP	(__SI_FAULT|4)	/* illegal trap */
-#define ILL_PRVOPC	(__SI_FAULT|5)	/* privileged opcode */
-#define ILL_PRVREG	(__SI_FAULT|6)	/* privileged register */
-#define ILL_COPROC	(__SI_FAULT|7)	/* coprocessor error */
-#define ILL_BADSTK	(__SI_FAULT|8)	/* internal stack error */
-#define NSIGILL		8
-
-/*
- * SIGFPE si_codes
- */
-#define FPE_INTDIV	(__SI_FAULT|1)	/* integer divide by zero */
-#define FPE_INTOVF	(__SI_FAULT|2)	/* integer overflow */
-#define FPE_FLTDIV	(__SI_FAULT|3)	/* floating point divide by zero */
-#define FPE_FLTOVF	(__SI_FAULT|4)	/* floating point overflow */
-#define FPE_FLTUND	(__SI_FAULT|5)	/* floating point underflow */
-#define FPE_FLTRES	(__SI_FAULT|6)	/* floating point inexact result */
-#define FPE_FLTINV	(__SI_FAULT|7)	/* floating point invalid operation */
-#define FPE_FLTSUB	(__SI_FAULT|8)	/* subscript out of range */
-#define NSIGFPE		8
-
-/*
- * SIGSEGV si_codes
- */
-#define SEGV_MAPERR	(__SI_FAULT|1)	/* address not mapped to object */
-#define SEGV_ACCERR	(__SI_FAULT|2)	/* invalid permissions for mapped object */
-#define NSIGSEGV	2
-
-/*
- * SIGBUS si_codes
- */
-#define BUS_ADRALN	(__SI_FAULT|1)	/* invalid address alignment */
-#define BUS_ADRERR	(__SI_FAULT|2)	/* non-existant physical address */
-#define BUS_OBJERR	(__SI_FAULT|3)	/* object specific hardware error */
-#define NSIGBUS		3
-
-/*
- * SIGTRAP si_codes
- */
-#define TRAP_BRKPT	(__SI_FAULT|1)	/* process breakpoint */
-#define TRAP_TRACE	(__SI_FAULT|2)	/* process trace trap */
-#define NSIGTRAP	2
-
-/*
- * SIGCHLD si_codes
- */
-#define CLD_EXITED	(__SI_CHLD|1)	/* child has exited */
-#define CLD_KILLED	(__SI_CHLD|2)	/* child was killed */
-#define CLD_DUMPED	(__SI_CHLD|3)	/* child terminated abnormally */
-#define CLD_TRAPPED	(__SI_CHLD|4)	/* traced child has trapped */
-#define CLD_STOPPED	(__SI_CHLD|5)	/* child has stopped */
-#define CLD_CONTINUED	(__SI_CHLD|6)	/* stopped child has continued */
-#define NSIGCHLD	6
-
-/*
- * SIGPOLL si_codes
- */
-#define POLL_IN		(__SI_POLL|1)	/* data input available */
-#define POLL_OUT	(__SI_POLL|2)	/* output buffers available */
-#define POLL_MSG	(__SI_POLL|3)	/* input message available */
-#define POLL_ERR	(__SI_POLL|4)	/* i/o error */
-#define POLL_PRI	(__SI_POLL|5)	/* high priority input available */
-#define POLL_HUP	(__SI_POLL|6)	/* device disconnected */
-#define NSIGPOLL	6
 
 #endif
diff -Nru a/include/asm-s390/timex.h b/include/asm-s390/timex.h
--- a/include/asm-s390/timex.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-s390/timex.h	2004-12-24 13:36:17 -08:00
@@ -12,10 +12,6 @@
 #define _ASM_S390_TIMEX_H
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 typedef unsigned long long cycles_t;
 
diff -Nru a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
--- a/include/asm-s390/unistd.h	2004-12-24 13:37:44 -08:00
+++ b/include/asm-s390/unistd.h	2004-12-24 13:37:44 -08:00
@@ -269,8 +269,9 @@
 #define __NR_mq_timedreceive	274
 #define __NR_mq_notify		275
 #define __NR_mq_getsetattr	276
+/* Number 277 is reserved for new sys_kexec_load */
 
-#define NR_syscalls 277
+#define NR_syscalls 278
 
 /* 
  * There are some system calls that are not present on 64 bit, some
diff -Nru a/include/asm-sh/adc.h b/include/asm-sh/adc.h
--- a/include/asm-sh/adc.h	2004-12-24 13:37:17 -08:00
+++ b/include/asm-sh/adc.h	2004-12-24 13:37:17 -08:00
@@ -1,6 +1,6 @@
 #ifndef __ASM_ADC_H
 #define __ASM_ADC_H
-
+#ifdef __KERNEL__
 /*
  * Copyright (C) 2004  Andriy Skulysh
  */
@@ -9,4 +9,5 @@
 
 int adc_single(unsigned int channel);
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_ADC_H */
diff -Nru a/include/asm-sh/addrspace.h b/include/asm-sh/addrspace.h
--- a/include/asm-sh/addrspace.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-sh/addrspace.h	2004-12-24 13:36:48 -08:00
@@ -9,6 +9,7 @@
  */
 #ifndef __ASM_SH_ADDRSPACE_H
 #define __ASM_SH_ADDRSPACE_H
+#ifdef __KERNEL__
 
 #include <asm/cpu/addrspace.h>
 
@@ -33,4 +34,5 @@
 #define P3SEGADDR(a)	((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P3SEG))
 #define P4SEGADDR(a)	((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P4SEG))
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_ADDRSPACE_H */
diff -Nru a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
--- a/include/asm-sh/bitops.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-sh/bitops.h	2004-12-24 13:36:17 -08:00
@@ -212,7 +212,7 @@
  * @offset: The bitnumber to start searching at
  * @size: The maximum size to search
  */
-static __inline__ unsigned long find_next_bit(unsigned long *addr,
+static __inline__ unsigned long find_next_bit(const unsigned long *addr,
 	unsigned long size, unsigned long offset)
 {
 	unsigned int *p = ((unsigned int *) addr) + (offset >> 5);
@@ -344,7 +344,7 @@
 #define ext2_test_bit(nr, addr) test_bit((nr), (addr))
 #define ext2_find_first_zero_bit(addr, size) find_first_zero_bit((addr), (size))
 #define ext2_find_next_zero_bit(addr, size, offset) \
-                find_next_zero_bit((addr), (size), (offset))
+                find_next_zero_bit((unsigned long *)(addr), (size), (offset))
 #else
 static __inline__ int ext2_set_bit(int nr, volatile void * addr)
 {
diff -Nru a/include/asm-sh/bugs.h b/include/asm-sh/bugs.h
--- a/include/asm-sh/bugs.h	2004-12-24 13:36:34 -08:00
+++ b/include/asm-sh/bugs.h	2004-12-24 13:36:34 -08:00
@@ -21,7 +21,7 @@
 	char *p= &system_utsname.machine[2]; /* "sh" */
 
 	cpu_data->loops_per_jiffy = loops_per_jiffy;
-	
+
 	switch (cpu_data->type) {
 	case CPU_SH7604:
 		*p++ = '2';
@@ -29,7 +29,7 @@
 	case CPU_SH7705 ... CPU_SH7300:
 		*p++ = '3';
 		break;
-	case CPU_SH7750 ... CPU_ST40GX1:
+	case CPU_SH7750 ... CPU_SH4_501:
 		*p++ = '4';
 		break;
 	default:
diff -Nru a/include/asm-sh/cache.h b/include/asm-sh/cache.h
--- a/include/asm-sh/cache.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-sh/cache.h	2004-12-24 13:37:02 -08:00
@@ -1,4 +1,4 @@
-/* $Id: cache.h,v 1.5 2003/07/16 04:08:29 lethal Exp $
+/* $Id: cache.h,v 1.6 2004/03/11 18:08:05 lethal Exp $
  *
  * include/asm-sh/cache.h
  *
@@ -7,6 +7,7 @@
  */
 #ifndef __ASM_SH_CACHE_H
 #define __ASM_SH_CACHE_H
+#ifdef __KERNEL__
 
 #include <asm/cpu/cache.h>
 #include <asm/cpu/cacheflush.h>
@@ -43,5 +44,5 @@
 /* Flush (invalidate only) a region (smaller than a page) */
 extern void __flush_invalidate_region(void *start, int size);
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_CACHE_H */
-
diff -Nru a/include/asm-sh/checksum.h b/include/asm-sh/checksum.h
--- a/include/asm-sh/checksum.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-sh/checksum.h	2004-12-24 13:36:19 -08:00
@@ -10,6 +10,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/in6.h>
 
 /*
  * computes the checksum of a memory block at buff, length len,
@@ -159,7 +160,6 @@
 }
 
 #define _HAVE_ARCH_IPV6_CSUM
-#ifdef CONFIG_IPV6
 static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
 						     struct in6_addr *daddr,
 						     __u32 len,
@@ -195,7 +195,6 @@
 
 	return csum_fold(sum);
 }
-#endif
 
 /* 
  *	Copy and checksum to user
diff -Nru a/include/asm-sh/cpu-sh3/cache.h b/include/asm-sh/cpu-sh3/cache.h
--- a/include/asm-sh/cpu-sh3/cache.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-sh/cpu-sh3/cache.h	2004-12-24 13:36:17 -08:00
@@ -26,5 +26,12 @@
 #define CCR_CACHE_ENABLE	CCR_CACHE_CE
 #define CCR_CACHE_INVALIDATE	CCR_CACHE_CF
 
+#if defined(CONFIG_CPU_SUBTYPE_SH7705)
+#define CCR3	0xa40000b4
+#define CCR_CACHE_16KB  0x00010000
+#define CCR_CACHE_32KB	0x00020000
+#endif
+
+
 #endif /* __ASM_CPU_SH3_CACHE_H */
 
diff -Nru a/include/asm-sh/cpu-sh3/cacheflush.h b/include/asm-sh/cpu-sh3/cacheflush.h
--- a/include/asm-sh/cpu-sh3/cacheflush.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-sh/cpu-sh3/cacheflush.h	2004-12-24 13:36:48 -08:00
@@ -25,6 +25,46 @@
  *  Caches are indexed (effectively) by physical address on SH-3, so
  *  we don't need them.
  */
+
+#if defined(CONFIG_SH7705_CACHE_32KB)
+
+/* SH7705 is an SH3 processor with 32KB cache. This has alias issues like the
+ * SH4. Unlike the SH4 this is a unified cache so we need to do some work
+ * in mmap when 'exec'ing a new binary
+ */
+ /* 32KB cache, 4kb PAGE sizes need to check bit 12 */
+#define CACHE_ALIAS 0x00001000
+
+struct page;
+struct mm_struct;
+struct vm_area_struct;
+
+extern void flush_cache_all(void);
+extern void flush_cache_mm(struct mm_struct *mm);
+extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
+                              unsigned long end);
+extern void flush_cache_page(struct vm_area_struct *vma, unsigned long addr);
+extern void flush_dcache_page(struct page *pg);
+extern void flush_icache_range(unsigned long start, unsigned long end);
+extern void flush_icache_page(struct vm_area_struct *vma, struct page *page);
+
+#define flush_dcache_mmap_lock(mapping)		do { } while (0)
+#define flush_dcache_mmap_unlock(mapping)	do { } while (0)
+
+/* SH3 has unified cache so no special action needed here */
+#define flush_cache_sigtramp(vaddr)		do { } while (0)
+#define flush_page_to_ram(page)			do { } while (0)
+#define flush_icache_user_range(vma,pg,adr,len)	do { } while (0)
+
+#define p3_cache_init()				do { } while (0)
+
+#define PG_mapped	PG_arch_1
+
+/* We provide our own get_unmapped_area to avoid cache alias issue */
+#define HAVE_ARCH_UNMAPPED_AREA
+
+#else
+
 #define flush_cache_all()			do { } while (0)
 #define flush_cache_mm(mm)			do { } while (0)
 #define flush_cache_range(vma, start, end)	do { } while (0)
@@ -40,6 +80,8 @@
 #define p3_cache_init()				do { } while (0)
 
 #define HAVE_ARCH_UNMAPPED_AREA
+
+#endif
 
 #endif /* __ASM_CPU_SH3_CACHEFLUSH_H */
 
diff -Nru a/include/asm-sh/cpu-sh4/freq.h b/include/asm-sh/cpu-sh4/freq.h
--- a/include/asm-sh/cpu-sh4/freq.h	2004-12-24 13:36:32 -08:00
+++ b/include/asm-sh/cpu-sh4/freq.h	2004-12-24 13:36:32 -08:00
@@ -10,7 +10,11 @@
 #ifndef __ASM_CPU_SH4_FREQ_H
 #define __ASM_CPU_SH4_FREQ_H
 
+#if defined(CONFIG_CPU_SUBTYPE_SH73180)
+#define FRQCR		        0xa4150000
+#else
 #define FRQCR			0xffc00000
+#endif
 #define MIN_DIVISOR_NR		0
 #define MAX_DIVISOR_NR		3
 
diff -Nru a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h
--- a/include/asm-sh/dma-mapping.h	2004-12-24 13:37:33 -08:00
+++ b/include/asm-sh/dma-mapping.h	2004-12-24 13:37:33 -08:00
@@ -3,23 +3,17 @@
 
 #include <linux/config.h>
 #include <linux/mm.h>
+#include <linux/device.h>
 #include <asm/scatterlist.h>
 #include <asm/io.h>
 
+extern struct bus_type pci_bus_type;
+
 /* arch/sh/mm/consistent.c */
 extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle);
 extern void consistent_free(void *vaddr, size_t size);
 extern void consistent_sync(void *vaddr, size_t size, int direction);
 
-#ifdef CONFIG_SH_DREAMCAST
-struct pci_dev;
-extern struct bus_type pci_bus_type;
-extern void *__pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-				    dma_addr_t *dma_handle);
-extern void __pci_free_consistent(struct pci_dev *hwdev, size_t size,
-				  void *vaddr, dma_addr_t dma_handle);
-#endif
-
 #define dma_supported(dev, mask)	(1)
 
 static inline int dma_set_mask(struct device *dev, u64 mask)
@@ -35,16 +29,13 @@
 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
 			 dma_addr_t *dma_handle, int flag)
 {
-	/*
-	 * Some platforms have special pci_alloc_consistent() implementations,
-	 * in these instances we can't use the generic consistent_alloc().
-	 */
-#ifdef CONFIG_SH_DREAMCAST
-	if (dev && dev->bus == &pci_bus_type)
-		return __pci_alloc_consistent(NULL, size, dma_handle);
-#endif
-	if (sh_mv.mv_consistent_alloc)
-		return sh_mv.mv_consistent_alloc(dev, size, dma_handle, flag);
+	if (sh_mv.mv_consistent_alloc) {
+		void *ret;
+
+		ret = sh_mv.mv_consistent_alloc(dev, size, dma_handle, flag);
+		if (ret != NULL)
+			return ret;
+	}
 
 	return consistent_alloc(flag, size, dma_handle);
 }
@@ -52,19 +43,12 @@
 static inline void dma_free_coherent(struct device *dev, size_t size,
 		       void *vaddr, dma_addr_t dma_handle)
 {
-	/*
-	 * Same note as above applies to pci_free_consistent()..
-	 */
-#ifdef CONFIG_SH_DREAMCAST
-	if (dev && dev->bus == &pci_bus_type) {
-		__pci_free_consistent(NULL, size, vaddr, dma_handle);
-		return;
-	}
-#endif
-
 	if (sh_mv.mv_consistent_free) {
-		sh_mv.mv_consistent_free(dev, size, vaddr, dma_handle);
-		return;
+		int ret;
+
+		ret = sh_mv.mv_consistent_free(dev, size, vaddr, dma_handle);
+		if (ret == 0)
+			return;
 	}
 
 	consistent_free(vaddr, size);
diff -Nru a/include/asm-sh/dma.h b/include/asm-sh/dma.h
--- a/include/asm-sh/dma.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-sh/dma.h	2004-12-24 13:36:17 -08:00
@@ -9,6 +9,7 @@
  */
 #ifndef __ASM_SH_DMA_H
 #define __ASM_SH_DMA_H
+#ifdef __KERNEL__
 
 #include <linux/config.h>
 #include <linux/spinlock.h>
@@ -138,4 +139,5 @@
 #define isa_dma_bridge_buggy	(0)
 #endif
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_DMA_H */
diff -Nru a/include/asm-sh/edosk7705/io.h b/include/asm-sh/edosk7705/io.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-sh/edosk7705/io.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,30 @@
+/*
+ * include/asm-sh/edosk7705/io.h
+ *
+ * Modified version of io_se.h for the EDOSK7705 specific functions.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ * IO functions for an Hitachi EDOSK7705 development board
+ */
+
+#ifndef __ASM_SH_EDOSK7705_IO_H
+#define __ASM_SH_EDOSK7705_IO_H
+
+#include <asm/io_generic.h>
+
+extern unsigned char sh_edosk7705_inb(unsigned long port);
+extern unsigned int sh_edosk7705_inl(unsigned long port);
+
+extern void sh_edosk7705_outb(unsigned char value, unsigned long port);
+extern void sh_edosk7705_outl(unsigned int value, unsigned long port);
+
+extern void sh_edosk7705_insb(unsigned long port, void *addr, unsigned long count);
+extern void sh_edosk7705_insl(unsigned long port, void *addr, unsigned long count);
+extern void sh_edosk7705_outsb(unsigned long port, const void *addr, unsigned long count);
+extern void sh_edosk7705_outsl(unsigned long port, const void *addr, unsigned long count);
+
+extern unsigned long sh_edosk7705_isa_port2addr(unsigned long offset);
+
+#endif /* __ASM_SH_EDOSK7705_IO_H */
diff -Nru a/include/asm-sh/freq.h b/include/asm-sh/freq.h
--- a/include/asm-sh/freq.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-sh/freq.h	2004-12-24 13:37:19 -08:00
@@ -10,6 +10,7 @@
  */
 #ifndef __ASM_SH_FREQ_H
 #define __ASM_SH_FREQ_H
+#ifdef __KERNEL__
 
 #include <asm/cpu/freq.h>
 
@@ -24,5 +25,5 @@
 extern unsigned int get_pfc_value(unsigned int divisor);
 extern unsigned int get_bfc_value(unsigned int divisor);
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_FREQ_H */
-
diff -Nru a/include/asm-sh/hardirq.h b/include/asm-sh/hardirq.h
--- a/include/asm-sh/hardirq.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-sh/hardirq.h	2004-12-24 13:36:47 -08:00
@@ -12,28 +12,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have
diff -Nru a/include/asm-sh/io.h b/include/asm-sh/io.h
--- a/include/asm-sh/io.h	2004-12-24 13:36:59 -08:00
+++ b/include/asm-sh/io.h	2004-12-24 13:36:59 -08:00
@@ -134,6 +134,8 @@
 #define readw_relaxed(a) readw(a)
 #define readl_relaxed(a) readl(a)
 
+#define mmiowb()
+
 /*
  * If the platform has PC-like I/O, this function converts the offset into
  * an address.
diff -Nru a/include/asm-sh/irq-sh73180.h b/include/asm-sh/irq-sh73180.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-sh/irq-sh73180.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,350 @@
+#ifndef __ASM_SH_IRQ_SH73180_H
+#define __ASM_SH_IRQ_SH73180_H
+
+/*
+ * linux/include/asm-sh/irq-sh73180.h
+ *
+ * Copyright (C) 2004 Takashi SHUDO <shudo@hitachi-ul.co.jp>
+ */
+
+#undef INTC_IPRA
+#undef INTC_IPRB
+#undef INTC_IPRC
+#undef INTC_IPRD
+
+#undef DMTE0_IRQ
+#undef DMTE1_IRQ
+#undef DMTE2_IRQ
+#undef DMTE3_IRQ
+#undef DMTE4_IRQ
+#undef DMTE5_IRQ
+#undef DMTE6_IRQ
+#undef DMTE7_IRQ
+#undef DMAE_IRQ
+#undef DMA_IPR_ADDR
+#undef DMA_IPR_POS
+#undef DMA_PRIORITY
+
+#undef NR_IRQS
+
+#undef __irq_demux
+#undef irq_demux
+
+#undef INTC_IMCR0
+#undef INTC_IMCR1
+#undef INTC_IMCR2
+#undef INTC_IMCR3
+#undef INTC_IMCR4
+#undef INTC_IMCR5
+#undef INTC_IMCR6
+#undef INTC_IMCR7
+#undef INTC_IMCR8
+#undef INTC_IMCR9
+#undef INTC_IMCR10
+
+
+#define INTC_IPRA  	0xA4080000UL
+#define INTC_IPRB  	0xA4080004UL
+#define INTC_IPRC  	0xA4080008UL
+#define INTC_IPRD  	0xA408000CUL
+#define INTC_IPRE  	0xA4080010UL
+#define INTC_IPRF  	0xA4080014UL
+#define INTC_IPRG  	0xA4080018UL
+#define INTC_IPRH  	0xA408001CUL
+#define INTC_IPRI  	0xA4080020UL
+#define INTC_IPRJ  	0xA4080024UL
+#define INTC_IPRK  	0xA4080028UL
+
+#define INTC_IMR0	0xA4080080UL
+#define INTC_IMR1	0xA4080084UL
+#define INTC_IMR2	0xA4080088UL
+#define INTC_IMR3	0xA408008CUL
+#define INTC_IMR4	0xA4080090UL
+#define INTC_IMR5	0xA4080094UL
+#define INTC_IMR6	0xA4080098UL
+#define INTC_IMR7	0xA408009CUL
+#define INTC_IMR8	0xA40800A0UL
+#define INTC_IMR9	0xA40800A4UL
+#define INTC_IMR10	0xA40800A8UL
+#define INTC_IMR11	0xA40800ACUL
+
+#define INTC_IMCR0	0xA40800C0UL
+#define INTC_IMCR1	0xA40800C4UL
+#define INTC_IMCR2	0xA40800C8UL
+#define INTC_IMCR3	0xA40800CCUL
+#define INTC_IMCR4	0xA40800D0UL
+#define INTC_IMCR5	0xA40800D4UL
+#define INTC_IMCR6	0xA40800D8UL
+#define INTC_IMCR7	0xA40800DCUL
+#define INTC_IMCR8	0xA40800E0UL
+#define INTC_IMCR9	0xA40800E4UL
+#define INTC_IMCR10	0xA40800E8UL
+#define INTC_IMCR11	0xA40800ECUL
+
+#define INTC_ICR0	0xA4140000UL
+#define INTC_ICR1	0xA414001CUL
+
+#define INTMSK0		0xa4140044
+#define INTMSKCLR0	0xa4140064
+#define INTC_INTPRI0	0xa4140010
+
+/*
+  NOTE:
+
+  *_IRQ = (INTEVT2 - 0x200)/0x20
+*/
+
+/* TMU0 */
+#define TMU0_IRQ	16
+#define TMU0_IPR_ADDR	INTC_IPRA
+#define TMU0_IPR_POS	 3
+#define TMU0_PRIORITY	 2
+
+#define TIMER_IRQ       16
+#define TIMER_IPR_ADDR  INTC_IPRA
+#define TIMER_IPR_POS    3
+#define TIMER_PRIORITY   2
+
+/* TMU1 */
+#define TMU1_IRQ	17
+#define TMU1_IPR_ADDR	INTC_IPRA
+#define TMU1_IPR_POS	 2
+#define TMU1_PRIORITY	 2
+
+/* TMU2 */
+#define TMU2_IRQ	18
+#define TMU2_IPR_ADDR	INTC_IPRA
+#define TMU2_IPR_POS	 1
+#define TMU2_PRIORITY	 2
+
+/* LCDC */
+#define LCDC_IRQ	28
+#define LCDC_IPR_ADDR	INTC_IPRB
+#define LCDC_IPR_POS	 2
+#define LCDC_PRIORITY	 2
+
+/* VIO (Video I/O) */
+#define CEU_IRQ		52
+#define BEU_IRQ		53
+#define VEU_IRQ		54
+#define VOU_IRQ		55
+#define VIO_IPR_ADDR	INTC_IPRE
+#define VIO_IPR_POS	 2
+#define VIO_PRIORITY	 2
+
+/* MFI (Multi Functional Interface) */
+#define MFI_IRQ		56
+#define MFI_IPR_ADDR	INTC_IPRE
+#define MFI_IPR_POS	 1
+#define MFI_PRIORITY	 2
+
+/* VPU (Video Processing Unit) */
+#define VPU_IRQ		60
+#define VPU_IPR_ADDR	INTC_IPRE
+#define VPU_IPR_POS	 0
+#define VPU_PRIORITY	 2
+
+/* 3DG */
+#define TDG_IRQ		63
+#define TDG_IPR_ADDR	INTC_IPRJ
+#define TDG_IPR_POS	 2
+#define TDG_PRIORITY	 2
+
+/* DMAC(1) */
+#define DMTE0_IRQ	48
+#define DMTE1_IRQ	49
+#define DMTE2_IRQ	50
+#define DMTE3_IRQ	51
+#define DMA1_IPR_ADDR	INTC_IPRE
+#define DMA1_IPR_POS	3
+#define DMA1_PRIORITY	7
+
+/* DMAC(2) */
+#define DMTE4_IRQ	76
+#define DMTE5_IRQ	77
+#define DMA2_IPR_ADDR	INTC_IPRF
+#define DMA2_IPR_POS	2
+#define DMA2_PRIORITY	7
+
+/* SCIF0 */
+#define SCIF_ERI_IRQ	80
+#define SCIF_RXI_IRQ	81
+#define SCIF_BRI_IRQ	82
+#define SCIF_TXI_IRQ	83
+#define SCIF_IPR_ADDR	INTC_IPRG
+#define SCIF_IPR_POS	3
+#define SCIF_PRIORITY	3
+
+/* SIOF0 */
+#define SIOF0_IRQ	84
+#define SIOF0_IPR_ADDR	INTC_IPRH
+#define SIOF0_IPR_POS	3
+#define SIOF0_PRIORITY	3
+
+/* FLCTL (Flash Memory Controller) */
+#define FLSTE_IRQ	92
+#define FLTEND_IRQ	93
+#define FLTRQ0_IRQ	94
+#define FLTRQ1_IRQ	95
+#define FLCTL_IPR_ADDR	INTC_IPRH
+#define FLCTL_IPR_POS	1
+#define FLCTL_PRIORITY	3
+
+/* IIC(0) (IIC Bus Interface) */
+#define IIC0_ALI_IRQ	96
+#define IIC0_TACKI_IRQ	97
+#define IIC0_WAITI_IRQ	98
+#define IIC0_DTEI_IRQ	99
+#define IIC0_IPR_ADDR	INTC_IPRH
+#define IIC0_IPR_POS	0
+#define IIC0_PRIORITY	3
+
+/* IIC(1) (IIC Bus Interface) */
+#define IIC1_ALI_IRQ	44
+#define IIC1_TACKI_IRQ	45
+#define IIC1_WAITI_IRQ	46
+#define IIC1_DTEI_IRQ	47
+#define IIC1_IPR_ADDR	INTC_IPRG
+#define IIC1_IPR_POS	0
+#define IIC1_PRIORITY	3
+
+/* SIO0 */
+#define SIO0_IRQ	88
+#define SIO0_IPR_ADDR	INTC_IPRI
+#define SIO0_IPR_POS	3
+#define SIO0_PRIORITY	3
+
+/* SDHI */
+#define SDHI_SDHII0_IRQ	100
+#define SDHI_SDHII1_IRQ	101
+#define SDHI_SDHII2_IRQ	102
+#define SDHI_SDHII3_IRQ	103
+#define SDHI_IPR_ADDR	INTC_IPRK
+#define SDHI_IPR_POS	0
+#define SDHI_PRIORITY	3
+
+/* SIU (Sound Interface Unit) */
+#define SIU_IRQ		108
+#define SIU_IPR_ADDR	INTC_IPRJ
+#define SIU_IPR_POS	1
+#define SIU_PRIORITY	3
+
+
+/* ONCHIP_NR_IRQS */
+#define NR_IRQS 109
+
+/* In a generic kernel, NR_IRQS is an upper bound, and we should use
+ * ACTUAL_NR_IRQS (which uses the machine vector) to get the correct value.
+ */
+#define ACTUAL_NR_IRQS NR_IRQS
+
+
+extern void disable_irq(unsigned int);
+extern void disable_irq_nosync(unsigned int);
+extern void enable_irq(unsigned int);
+
+/*
+ * Simple Mask Register Support
+ */
+extern void make_maskreg_irq(unsigned int irq);
+extern unsigned short *irq_mask_register;
+
+/*
+ * Function for "on chip support modules".
+ */
+extern void make_ipr_irq(unsigned int irq, unsigned int addr,
+			 int pos,  int priority);
+extern void make_imask_irq(unsigned int irq);
+
+#define PORT_PACR	0xA4050100UL
+#define PORT_PBCR	0xA4050102UL
+#define PORT_PCCR	0xA4050104UL
+#define PORT_PDCR	0xA4050106UL
+#define PORT_PECR	0xA4050108UL
+#define PORT_PFCR	0xA405010AUL
+#define PORT_PGCR	0xA405010CUL
+#define PORT_PHCR	0xA405010EUL
+#define PORT_PJCR	0xA4050110UL
+#define PORT_PKCR	0xA4050112UL
+#define PORT_PLCR	0xA4050114UL
+#define PORT_SCPCR	0xA4050116UL
+#define PORT_PMCR	0xA4050118UL
+#define PORT_PNCR	0xA405011AUL
+#define PORT_PQCR	0xA405011CUL
+#define PORT_PRCR	0xA405011EUL
+#define PORT_PTCR	0xA405014CUL
+#define PORT_PUCR	0xA405014EUL
+#define PORT_PVCR	0xA4050150UL
+
+#define PORT_PSELA	0xA4050140UL
+#define PORT_PSELB	0xA4050142UL
+#define PORT_PSELC	0xA4050144UL
+#define PORT_PSELE	0xA4050158UL
+
+#define PORT_HIZCRA	0xA4050146UL
+#define PORT_HIZCRB	0xA4050148UL
+#define PORT_DRVCR	0xA405014AUL
+
+#define PORT_PADR  	0xA4050120UL
+#define PORT_PBDR  	0xA4050122UL
+#define PORT_PCDR  	0xA4050124UL
+#define PORT_PDDR  	0xA4050126UL
+#define PORT_PEDR  	0xA4050128UL
+#define PORT_PFDR  	0xA405012AUL
+#define PORT_PGDR  	0xA405012CUL
+#define PORT_PHDR  	0xA405012EUL
+#define PORT_PJDR  	0xA4050130UL
+#define PORT_PKDR  	0xA4050132UL
+#define PORT_PLDR  	0xA4050134UL
+#define PORT_SCPDR  	0xA4050136UL
+#define PORT_PMDR  	0xA4050138UL
+#define PORT_PNDR  	0xA405013AUL
+#define PORT_PQDR  	0xA405013CUL
+#define PORT_PRDR  	0xA405013EUL
+#define PORT_PTDR  	0xA405016CUL
+#define PORT_PUDR  	0xA405016EUL
+#define PORT_PVDR  	0xA4050170UL
+
+#define IRQ0_IRQ	32
+#define IRQ1_IRQ	33
+#define IRQ2_IRQ	34
+#define IRQ3_IRQ	35
+#define IRQ4_IRQ	36
+#define IRQ5_IRQ	37
+#define IRQ6_IRQ	38
+#define IRQ7_IRQ	39
+
+#define INTPRI00	0xA4140010UL
+
+#define IRQ0_IPR_ADDR	INTPRI00
+#define IRQ1_IPR_ADDR	INTPRI00
+#define IRQ2_IPR_ADDR	INTPRI00
+#define IRQ3_IPR_ADDR	INTPRI00
+#define IRQ4_IPR_ADDR	INTPRI00
+#define IRQ5_IPR_ADDR	INTPRI00
+#define IRQ6_IPR_ADDR	INTPRI00
+#define IRQ7_IPR_ADDR	INTPRI00
+
+#define IRQ0_IPR_POS	7
+#define IRQ1_IPR_POS	6
+#define IRQ2_IPR_POS	5
+#define IRQ3_IPR_POS	4
+#define IRQ4_IPR_POS	3
+#define IRQ5_IPR_POS	2
+#define IRQ6_IPR_POS	1
+#define IRQ7_IPR_POS	0
+
+#define IRQ0_PRIORITY	1
+#define IRQ1_PRIORITY	1
+#define IRQ2_PRIORITY	1
+#define IRQ3_PRIORITY	1
+#define IRQ4_PRIORITY	1
+#define IRQ5_PRIORITY	1
+#define IRQ6_PRIORITY	1
+#define IRQ7_PRIORITY	1
+
+extern int shmse_irq_demux(int irq);
+#define __irq_demux(irq) shmse_irq_demux(irq)
+#define irq_demux(irq) __irq_demux(irq)
+
+#endif /* __ASM_SH_IRQ_SH73180_H */
diff -Nru a/include/asm-sh/irq.h b/include/asm-sh/irq.h
--- a/include/asm-sh/irq.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-sh/irq.h	2004-12-24 13:36:18 -08:00
@@ -218,7 +218,7 @@
 #define IRDA_IPR_POS	2
 #define IRDA_PRIORITY	3
 #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || \
-      defined(CONFIG_CPU_SUBTYPE_ST40STB1)
+      defined(CONFIG_CPU_SUBTYPE_ST40STB1) || defined(CONFIG_CPU_SUBTYPE_SH4_202)
 #define SCIF_ERI_IRQ	40
 #define SCIF_RXI_IRQ	41
 #define SCIF_BRI_IRQ	42
@@ -264,6 +264,8 @@
 #  define ONCHIP_NR_IRQS 72
 # elif defined(CONFIG_CPU_SUBTYPE_SH7760)
 #  define ONCHIP_NR_IRQS 110
+# elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
+#  define ONCHIP_NR_IRQS 72
 # elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
 #  define ONCHIP_NR_IRQS 144
 # elif defined(CONFIG_CPU_SUBTYPE_SH7300)
@@ -545,7 +547,7 @@
 #endif /* CONFIG_CPU_SUBTYPE_SH7707 || CONFIG_CPU_SUBTYPE_SH7709 */
 
 #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || \
-    defined(CONFIG_CPU_SUBTYPE_ST40STB1)
+    defined(CONFIG_CPU_SUBTYPE_ST40STB1) || defined(CONFIG_CPU_SUBTYPE_SH4_202)
 #define INTC_ICR        0xffd00000
 #define INTC_ICR_NMIL	(1<<15)
 #define INTC_ICR_MAI	(1<<14)
@@ -555,21 +557,26 @@
 #endif
 
 #ifdef CONFIG_CPU_SUBTYPE_ST40STB1
+
 #define INTC2_FIRST_IRQ 64
 #define NR_INTC2_IRQS 25
 
-#define INTC2_BASE0 0xfe080000
-#define INTC2_INTC2MODE  (INTC2_BASE0+0x80)
+#define INTC2_BASE	0xfe080000
+#define INTC2_INTC2MODE	(INTC2_BASE+0x80)
 
 #define INTC2_INTPRI_OFFSET	0x00
 #define INTC2_INTREQ_OFFSET	0x20
 #define INTC2_INTMSK_OFFSET	0x40
 #define INTC2_INTMSKCLR_OFFSET	0x60
 
-extern void make_intc2_irq(unsigned int irq,unsigned int addr,
-                           unsigned int group,int pos,int priority);
+void make_intc2_irq(unsigned int irq,
+		    unsigned int ipr_offset, unsigned int ipr_shift,
+		    unsigned int msk_offset, unsigned int msk_shift,
+		    unsigned int priority);
+void init_IRQ_intc2(void);
+void intc2_add_clear_irq(int irq, int (*fn)(int));
 
-#endif
+#endif	/* CONFIG_CPU_SUBTYPE_ST40STB1 */
 
 static inline int generic_irq_demux(int irq)
 {
@@ -582,5 +589,9 @@
 struct irqaction;
 struct pt_regs;
 int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
+
+#if defined(CONFIG_CPU_SUBTYPE_SH73180)
+#include <asm/irq-sh73180.h>
+#endif
 
 #endif /* __ASM_SH_IRQ_H */
diff -Nru a/include/asm-sh/machvec.h b/include/asm-sh/machvec.h
--- a/include/asm-sh/machvec.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-sh/machvec.h	2004-12-24 13:36:17 -08:00
@@ -65,7 +65,7 @@
 	void (*mv_heartbeat)(void);
 
 	void *(*mv_consistent_alloc)(struct device *, size_t, dma_addr_t *, int);
-	void (*mv_consistent_free)(struct device *, size_t, void *, dma_addr_t);
+	int (*mv_consistent_free)(struct device *, size_t, void *, dma_addr_t);
 };
 
 extern struct sh_machine_vector sh_mv;
diff -Nru a/include/asm-sh/microdev/io.h b/include/asm-sh/microdev/io.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-sh/microdev/io.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,53 @@
+/*
+ * linux/include/asm-sh/io_microdev.h
+ *
+ * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
+ *
+ * IO functions for the SuperH SH4-202 MicroDev board.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ */
+
+
+#ifndef _ASM_SH_IO_MICRODEV_H
+#define _ASM_SH_IO_MICRODEV_H
+
+extern unsigned long microdev_isa_port2addr(unsigned long offset);
+
+extern unsigned char microdev_inb(unsigned long port);
+extern unsigned short microdev_inw(unsigned long port);
+extern unsigned int microdev_inl(unsigned long port);
+
+extern void microdev_outb(unsigned char value, unsigned long port);
+extern void microdev_outw(unsigned short value, unsigned long port);
+extern void microdev_outl(unsigned int value, unsigned long port);
+
+extern unsigned char microdev_inb_p(unsigned long port);
+extern unsigned short microdev_inw_p(unsigned long port);
+extern unsigned int microdev_inl_p(unsigned long port);
+
+extern void microdev_outb_p(unsigned char value, unsigned long port);
+extern void microdev_outw_p(unsigned short value, unsigned long port);
+extern void microdev_outl_p(unsigned int value, unsigned long port);
+
+extern void microdev_insb(unsigned long port, void *addr, unsigned long count);
+extern void microdev_insw(unsigned long port, void *addr, unsigned long count);
+extern void microdev_insl(unsigned long port, void *addr, unsigned long count);
+
+extern void microdev_outsb(unsigned long port, const void *addr, unsigned long count);
+extern void microdev_outsw(unsigned long port, const void *addr, unsigned long count);
+extern void microdev_outsl(unsigned long port, const void *addr, unsigned long count);
+
+#if defined(CONFIG_PCI)
+extern unsigned char  microdev_pci_inb(unsigned long port);
+extern unsigned short microdev_pci_inw(unsigned long port);
+extern unsigned long  microdev_pci_inl(unsigned long port);
+extern void           microdev_pci_outb(unsigned char  data, unsigned long port);
+extern void           microdev_pci_outw(unsigned short data, unsigned long port);
+extern void           microdev_pci_outl(unsigned long  data, unsigned long port);
+#endif
+
+#endif /* _ASM_SH_IO_MICRODEV_H */
+
diff -Nru a/include/asm-sh/microdev/irq.h b/include/asm-sh/microdev/irq.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-sh/microdev/irq.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,72 @@
+/*
+ * linux/include/asm-sh/irq_microdev.h
+ *
+ * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
+ *
+ * IRQ functions for the SuperH SH4-202 MicroDev board.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ */
+
+
+#ifndef _ASM_SH_IRQ_MICRODEV_H
+#define _ASM_SH_IRQ_MICRODEV_H
+
+extern void init_microdev_irq(void);
+extern void microdev_print_fpga_intc_status(void);
+
+
+	/*
+	 *	The following are useful macros for manipulating the
+	 *	interrupt controller (INTC) on the CPU-board FPGA.
+	 *	It should be noted that there is an INTC on the FPGA,
+	 *	and a seperate INTC on the SH4-202 core - these are
+	 *	two different things, both of which need to be prorammed
+	 *	to correctly route - unfortunately, they have the
+	 *	same name and abbreviations!
+	 */
+#define	MICRODEV_FPGA_INTC_BASE		0xa6110000ul				/* INTC base address on CPU-board FPGA */
+#define	MICRODEV_FPGA_INTENB_REG	(MICRODEV_FPGA_INTC_BASE+0ul)		/* Interrupt Enable Register on INTC on CPU-board FPGA */
+#define	MICRODEV_FPGA_INTDSB_REG	(MICRODEV_FPGA_INTC_BASE+8ul)		/* Interrupt Disable Register on INTC on CPU-board FPGA */
+#define	MICRODEV_FPGA_INTC_MASK(n)	(1ul<<(n))				/* Interupt mask to enable/disable INTC in CPU-board FPGA */
+#define	MICRODEV_FPGA_INTPRI_REG(n)	(MICRODEV_FPGA_INTC_BASE+0x10+((n)/8)*8)/* Interrupt Priority Register on INTC on CPU-board FPGA */
+#define	MICRODEV_FPGA_INTPRI_LEVEL(n,x)	((x)<<(((n)%8)*4))			/* MICRODEV_FPGA_INTPRI_LEVEL(int_number, int_level) */
+#define	MICRODEV_FPGA_INTPRI_MASK(n)	(MICRODEV_FPGA_INTPRI_LEVEL((n),0xful))	/* Interrupt Priority Mask on INTC on CPU-board FPGA */
+#define	MICRODEV_FPGA_INTSRC_REG	(MICRODEV_FPGA_INTC_BASE+0x30ul)	/* Interrupt Source Register on INTC on CPU-board FPGA */
+#define	MICRODEV_FPGA_INTREQ_REG	(MICRODEV_FPGA_INTC_BASE+0x38ul)	/* Interrupt Request Register on INTC on CPU-board FPGA */
+
+
+	/*
+	 *	The following are the IRQ numbers for the Linux Kernel for external interrupts.
+	 *	i.e. the numbers seen by 'cat /proc/interrupt'.
+	 */
+#define MICRODEV_LINUX_IRQ_KEYBOARD	 1	/* SuperIO Keyboard */
+#define MICRODEV_LINUX_IRQ_SERIAL1	 2	/* SuperIO Serial #1 */
+#define MICRODEV_LINUX_IRQ_ETHERNET	 3	/* on-board Ethnernet */
+#define MICRODEV_LINUX_IRQ_SERIAL2	 4	/* SuperIO Serial #2 */
+#define MICRODEV_LINUX_IRQ_USB_HC	 7	/* on-board USB HC */
+#define MICRODEV_LINUX_IRQ_MOUSE	12	/* SuperIO PS/2 Mouse */
+#define MICRODEV_LINUX_IRQ_IDE2		13	/* SuperIO IDE #2 */
+#define MICRODEV_LINUX_IRQ_IDE1		14	/* SuperIO IDE #1 */
+
+	/*
+	 *	The following are the IRQ numbers for the INTC on the FPGA for external interrupts.
+	 *	i.e. the bits in the INTC registers in the FPGA.
+	 */
+#define MICRODEV_FPGA_IRQ_KEYBOARD	 1	/* SuperIO Keyboard */
+#define MICRODEV_FPGA_IRQ_SERIAL1	 3	/* SuperIO Serial #1 */
+#define MICRODEV_FPGA_IRQ_SERIAL2	 4	/* SuperIO Serial #2 */
+#define MICRODEV_FPGA_IRQ_MOUSE		12	/* SuperIO PS/2 Mouse */
+#define MICRODEV_FPGA_IRQ_IDE1		14	/* SuperIO IDE #1 */
+#define MICRODEV_FPGA_IRQ_IDE2		15	/* SuperIO IDE #2 */
+#define MICRODEV_FPGA_IRQ_USB_HC	16	/* on-board USB HC */
+#define MICRODEV_FPGA_IRQ_ETHERNET	18	/* on-board Ethnernet */
+
+#define MICRODEV_IRQ_PCI_INTA		 8
+#define MICRODEV_IRQ_PCI_INTB		 9
+#define MICRODEV_IRQ_PCI_INTC		10
+#define MICRODEV_IRQ_PCI_INTD		11
+
+#endif /* _ASM_SH_IRQ_MICRODEV_H */
diff -Nru a/include/asm-sh/mmu_context.h b/include/asm-sh/mmu_context.h
--- a/include/asm-sh/mmu_context.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-sh/mmu_context.h	2004-12-24 13:37:04 -08:00
@@ -6,6 +6,7 @@
  */
 #ifndef __ASM_SH_MMU_CONTEXT_H
 #define __ASM_SH_MMU_CONTEXT_H
+#ifdef __KERNEL__
 
 #include <asm/cpu/mmu_context.h>
 #include <asm/tlbflush.h>
@@ -201,4 +202,5 @@
 #define disable_mmu()	do { BUG(); } while (0)
 #endif
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_MMU_CONTEXT_H */
diff -Nru a/include/asm-sh/page.h b/include/asm-sh/page.h
--- a/include/asm-sh/page.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-sh/page.h	2004-12-24 13:37:19 -08:00
@@ -42,7 +42,13 @@
 extern void clear_page_slow(void *to);
 extern void copy_page_slow(void *to, void *from);
 
-#if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
+#if defined(CONFIG_SH7705_CACHE_32KB) && defined(CONFIG_MMU)
+struct page;
+extern void clear_user_page(void *to, unsigned long address, struct page *pg);
+extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
+extern void __clear_user_page(void *to, void *orig_to);
+extern void __copy_user_page(void *to, void *from, void *orig_to);
+#elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
 #define clear_user_page(page, vaddr, pg)	clear_page(page)
 #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
 #elif defined(CONFIG_CPU_SH4)
diff -Nru a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
--- a/include/asm-sh/pgtable.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-sh/pgtable.h	2004-12-24 13:37:43 -08:00
@@ -274,7 +274,8 @@
 
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 /*
  * No page table caches to initialise
@@ -285,9 +286,9 @@
 extern unsigned int kobjsize(const void *objp);
 #endif /* !CONFIG_MMU */
 
-#ifdef CONFIG_CPU_SH4
+#if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
-extern inline pte_t ptep_get_and_clear(pte_t *ptep);
+extern pte_t ptep_get_and_clear(pte_t *ptep);
 #endif
 
 #include <asm-generic/pgtable.h>
diff -Nru a/include/asm-sh/processor.h b/include/asm-sh/processor.h
--- a/include/asm-sh/processor.h	2004-12-24 13:36:35 -08:00
+++ b/include/asm-sh/processor.h	2004-12-24 13:36:35 -08:00
@@ -7,6 +7,7 @@
 
 #ifndef __ASM_SH_PROCESSOR_H
 #define __ASM_SH_PROCESSOR_H
+#ifdef __KERNEL__
 
 #include <asm/page.h>
 #include <asm/types.h>
@@ -43,6 +44,7 @@
 	/* SH-4 types */
 	CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
 	CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501,
+	CPU_SH73180,
 
 	/* Unknown subtype */
 	CPU_SH_NONE
@@ -137,6 +139,7 @@
 #define CPU_HAS_P2_FLUSH_BUG	0x0002	/* Need to flush the cache in P2 area */
 #define CPU_HAS_MMU_PAGE_ASSOC	0x0004	/* SH3: TLB way selection bit support */
 #define CPU_HAS_DSP		0x0008	/* SH-DSP: DSP support */
+#define CPU_HAS_PERF_COUNTER	0x0010	/* Hardware performance counters */
 
 struct thread_struct {
 	unsigned long sp;
@@ -274,4 +277,5 @@
 #define cpu_sleep()	__asm__ __volatile__ ("sleep" : : : "memory")
 #define cpu_relax()	do { } while (0)
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_PROCESSOR_H */
diff -Nru a/include/asm-sh/rtc.h b/include/asm-sh/rtc.h
--- a/include/asm-sh/rtc.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-sh/rtc.h	2004-12-24 13:37:01 -08:00
@@ -1,5 +1,6 @@
 #ifndef _ASM_RTC_H
 #define _ASM_RTC_H
+#ifdef __KERNEL__
 
 #include <asm/machvec.h>
 #include <asm/cpu/rtc.h>
@@ -24,5 +25,5 @@
 #define RCR2_RESET	0x02	/* Reset bit               */
 #define RCR2_START	0x01	/* Start bit               */
 
+#endif /* __KERNEL__ */
 #endif /* _ASM_RTC_H */
-
diff -Nru a/include/asm-sh/se/se.h b/include/asm-sh/se/se.h
--- a/include/asm-sh/se/se.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-sh/se/se.h	2004-12-24 13:36:48 -08:00
@@ -36,7 +36,11 @@
 #define PA_DIPSW0	0xb0800000	/* Dip switch 5,6 */
 #define PA_DIPSW1	0xb0800002	/* Dip switch 7,8 */
 #define PA_LED		0xb0c00000	/* LED */
+#if defined(CONFIG_CPU_SUBTYPE_SH7705)
+#define PA_BCR		0xb0e00000
+#else
 #define PA_BCR		0xb1400000	/* FPGA */
+#endif
 
 #define PA_MRSHPC	0xb83fffe0	/* MR-SHPC-01 PCMCIA controller */
 #define PA_MRSHPC_MW1	0xb8400000	/* MR-SHPC-01 memory window base */
@@ -64,6 +68,10 @@
 #define BCR_ILCRF	(PA_BCR + 10)
 #define BCR_ILCRG	(PA_BCR + 12)
 
+#if defined(CONFIG_CPU_SUBTYPE_SH7705)
+#define IRQ_STNIC   12
+#else
 #define IRQ_STNIC	10
+#endif
 
 #endif  /* __ASM_SH_HITACHI_SE_H */
diff -Nru a/include/asm-sh/se73180/io.h b/include/asm-sh/se73180/io.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-sh/se73180/io.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,32 @@
+/*
+ * include/asm-sh/se73180/io.h
+ *
+ * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
+ * Based on include/asm-sh/se7300/io.h
+ *
+ * IO functions for SH-Mobile3(SH73180) SolutionEngine
+ *
+ */
+
+#ifndef _ASM_SH_IO_73180SE_H
+#define _ASM_SH_IO_73180SE_H
+
+extern unsigned char sh73180se_inb(unsigned long port);
+extern unsigned short sh73180se_inw(unsigned long port);
+extern unsigned int sh73180se_inl(unsigned long port);
+
+extern void sh73180se_outb(unsigned char value, unsigned long port);
+extern void sh73180se_outw(unsigned short value, unsigned long port);
+extern void sh73180se_outl(unsigned int value, unsigned long port);
+
+extern unsigned char sh73180se_inb_p(unsigned long port);
+extern void sh73180se_outb_p(unsigned char value, unsigned long port);
+
+extern void sh73180se_insb(unsigned long port, void *addr, unsigned long count);
+extern void sh73180se_insw(unsigned long port, void *addr, unsigned long count);
+extern void sh73180se_insl(unsigned long port, void *addr, unsigned long count);
+extern void sh73180se_outsb(unsigned long port, const void *addr, unsigned long count);
+extern void sh73180se_outsw(unsigned long port, const void *addr, unsigned long count);
+extern void sh73180se_outsl(unsigned long port, const void *addr, unsigned long count);
+
+#endif /* _ASM_SH_IO_73180SE_H */
diff -Nru a/include/asm-sh/se73180/se73180.h b/include/asm-sh/se73180/se73180.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-sh/se73180/se73180.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,62 @@
+#ifndef __ASM_SH_HITACHI_SE73180_H
+#define __ASM_SH_HITACHI_SE73180_H
+
+/*
+ * include/asm-sh/se/se73180.h
+ *
+ * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
+ *
+ * SH-Mobile SolutionEngine 73180 support
+ */
+
+/* Box specific addresses.  */
+
+/* Area 0 */
+#define PA_ROM		0x00000000	/* EPROM */
+#define PA_ROM_SIZE	0x00400000	/* EPROM size 4M byte(Actually 2MB) */
+#define PA_FROM		0x00400000	/* Flash ROM */
+#define PA_FROM_SIZE	0x00400000	/* Flash size 4M byte */
+#define PA_SRAM		0x00800000	/* SRAM */
+#define PA_FROM_SIZE	0x00400000	/* SRAM size 4M byte */
+/* Area 1 */
+#define PA_EXT1		0x04000000
+#define PA_EXT1_SIZE	0x04000000
+/* Area 2 */
+#define PA_EXT2		0x08000000
+#define PA_EXT2_SIZE	0x04000000
+/* Area 3 */
+#define PA_SDRAM	0x0c000000
+#define PA_SDRAM_SIZE	0x04000000
+/* Area 4 */
+#define PA_PCIC		0x10000000	/* MR-SHPC-01 PCMCIA */
+#define PA_MRSHPC       0xb03fffe0      /* MR-SHPC-01 PCMCIA controller */
+#define PA_MRSHPC_MW1   0xb0400000      /* MR-SHPC-01 memory window base */
+#define PA_MRSHPC_MW2   0xb0500000      /* MR-SHPC-01 attribute window base */
+#define PA_MRSHPC_IO    0xb0600000      /* MR-SHPC-01 I/O window base */
+#define MRSHPC_OPTION   (PA_MRSHPC + 6)
+#define MRSHPC_CSR      (PA_MRSHPC + 8)
+#define MRSHPC_ISR      (PA_MRSHPC + 10)
+#define MRSHPC_ICR      (PA_MRSHPC + 12)
+#define MRSHPC_CPWCR    (PA_MRSHPC + 14)
+#define MRSHPC_MW0CR1   (PA_MRSHPC + 16)
+#define MRSHPC_MW1CR1   (PA_MRSHPC + 18)
+#define MRSHPC_IOWCR1   (PA_MRSHPC + 20)
+#define MRSHPC_MW0CR2   (PA_MRSHPC + 22)
+#define MRSHPC_MW1CR2   (PA_MRSHPC + 24)
+#define MRSHPC_IOWCR2   (PA_MRSHPC + 26)
+#define MRSHPC_CDCR     (PA_MRSHPC + 28)
+#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
+#define PA_LED		0xb0C00000	/* LED */
+#define LED_SHIFT       0
+#define PA_DIPSW	0xb0900000	/* Dip switch 31 */
+#define PA_EPLD_MODESET	0xb0a00000	/* FPGA Mode set register */
+#define PA_EPLD_ST1	0xb0a80000	/* FPGA Interrupt status register1 */
+#define PA_EPLD_ST2	0xb0ac0000	/* FPGA Interrupt status register2 */
+/* Area 5 */
+#define PA_EXT5		0x14000000
+#define PA_EXT5_SIZE	0x04000000
+/* Area 6 */
+#define PA_LCD1		0xb8000000
+#define PA_LCD2		0xb8800000
+
+#endif  /* __ASM_SH_HITACHI_SE73180_H */
diff -Nru a/include/asm-sh/sh03/io.h b/include/asm-sh/sh03/io.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-sh/sh03/io.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,46 @@
+/*
+ * include/asm-sh/sh03/io.h
+ *
+ * Copyright 2004 Interface Co.,Ltd. Saito.K
+ *
+ * IO functions for an Interface CTP/PCI-SH03
+ */
+
+#ifndef _ASM_SH_IO_SH03_H
+#define _ASM_SH_IO_SH03_H
+
+#include <linux/time.h>
+
+#define INTC_IPRD	0xffd00010UL
+
+#define IRL0_IRQ	2
+#define IRL0_IPR_ADDR	INTC_IPRD
+#define IRL0_IPR_POS	3
+#define IRL0_PRIORITY	13
+
+#define IRL1_IRQ	5
+#define IRL1_IPR_ADDR	INTC_IPRD
+#define IRL1_IPR_POS	2
+#define IRL1_PRIORITY	10
+
+#define IRL2_IRQ	8
+#define IRL2_IPR_ADDR	INTC_IPRD
+#define IRL2_IPR_POS	1
+#define IRL2_PRIORITY	7
+
+#define IRL3_IRQ	11
+#define IRL3_IPR_ADDR	INTC_IPRD
+#define IRL3_IPR_POS	0
+#define IRL3_PRIORITY	4
+
+
+extern unsigned long sh03_isa_port2addr(unsigned long offset);
+
+extern void setup_sh03(void);
+extern void init_sh03_IRQ(void);
+extern void heartbeat_sh03(void);
+
+extern void sh03_rtc_gettimeofday(struct timeval *tv);
+extern int sh03_rtc_settimeofday(const struct timeval *tv);
+
+#endif /* _ASM_SH_IO_SH03_H */
diff -Nru a/include/asm-sh/sh03/sh03.h b/include/asm-sh/sh03/sh03.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-sh/sh03/sh03.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,18 @@
+#ifndef __ASM_SH_SH03_H
+#define __ASM_SH_SH03_H
+
+/*
+ * linux/include/asm-sh/sh03/sh03.h
+ *
+ * Copyright (C) 2004  Interface Co., Ltd. Saito.K
+ *
+ * Interface CTP/PCI-SH03 support
+ */
+
+#define PA_PCI_IO       (0xbe240000)    /* PCI I/O space */
+#define PA_PCI_MEM      (0xbd000000)    /* PCI MEM space */
+
+#define PCIPAR          (0xa4000cf8)    /* PCI Config address */
+#define PCIPDR          (0xa4000cfc)    /* PCI Config data    */
+
+#endif  /* __ASM_SH_SH03_H */
diff -Nru a/include/asm-sh/shmparam.h b/include/asm-sh/shmparam.h
--- a/include/asm-sh/shmparam.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-sh/shmparam.h	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,8 @@
 #ifndef __ASM_SH_SHMPARAM_H
 #define __ASM_SH_SHMPARAM_H
+#ifdef __KERNEL__
 
 #include <asm/cpu/shmparam.h>
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_SHMPARAM_H */
diff -Nru a/include/asm-sh/system.h b/include/asm-sh/system.h
--- a/include/asm-sh/system.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-sh/system.h	2004-12-24 13:37:19 -08:00
@@ -7,7 +7,6 @@
  */
 
 #include <linux/config.h>
-#include <linux/kernel.h>
 
 /*
  *	switch_to() should switch tasks to task nr n, first
diff -Nru a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
--- a/include/asm-sh/thread_info.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-sh/thread_info.h	2004-12-24 13:37:02 -08:00
@@ -25,16 +25,6 @@
 	__u8			supervisor_stack[0];
 };
 
-#else /* !__ASSEMBLY__ */
-
-/* offsets into the thread_info struct for assembly code access */
-#define TI_TASK		0x00000000
-#define TI_EXEC_DOMAIN	0x00000004
-#define TI_FLAGS	0x00000008
-#define TI_CPU		0x0000000c
-#define TI_PRE_COUNT	0x00000010
-#define TI_RESTART_BLOCK 0x00000014
-
 #endif
 
 #define PREEMPT_ACTIVE		0x4000000
diff -Nru a/include/asm-sh/timex.h b/include/asm-sh/timex.h
--- a/include/asm-sh/timex.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-sh/timex.h	2004-12-24 13:36:16 -08:00
@@ -7,10 +7,6 @@
 #define __ASM_SH_TIMEX_H
 
 #define CLOCK_TICK_RATE		(CONFIG_SH_PCLK_FREQ / 4) /* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 typedef unsigned long long cycles_t;
 
diff -Nru a/include/asm-sh/ubc.h b/include/asm-sh/ubc.h
--- a/include/asm-sh/ubc.h	2004-12-24 13:36:47 -08:00
+++ b/include/asm-sh/ubc.h	2004-12-24 13:36:47 -08:00
@@ -10,6 +10,7 @@
  */
 #ifndef __ASM_SH_UBC_H
 #define __ASM_SH_UBC_H
+#ifdef __KERNEL__
 
 #include <asm/cpu/ubc.h>
 
@@ -55,5 +56,5 @@
 extern void ubc_sleep(void);
 #endif
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_UBC_H */
-
diff -Nru a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
--- a/include/asm-sh/unistd.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-sh/unistd.h	2004-12-24 13:37:19 -08:00
@@ -290,8 +290,13 @@
 #define __NR_mq_timedreceive    (__NR_mq_open+3)
 #define __NR_mq_notify          (__NR_mq_open+4)
 #define __NR_mq_getsetattr      (__NR_mq_open+5)
+#define __NR_sys_kexec_load	283
+#define __NR_waitid		284
+#define __NR_add_key		285
+#define __NR_request_key	286
+#define __NR_keyctl		287
 
-#define NR_syscalls 283
+#define NR_syscalls 288
 
 /* user-visible error numbers are in the range -1 - -124: see <asm-sh/errno.h> */
 
@@ -464,7 +469,6 @@
 static __inline__ _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
 static __inline__ _syscall3(int,open,const char *,file,int,flag,int,mode)
 static __inline__ _syscall1(int,close,int,fd)
-static __inline__ _syscall1(int,_exit,int,exitcode)
 static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
 static __inline__ _syscall1(int,delete_module,const char *,name)
 
diff -Nru a/include/asm-sh/user.h b/include/asm-sh/user.h
--- a/include/asm-sh/user.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-sh/user.h	2004-12-24 13:37:19 -08:00
@@ -1,8 +1,6 @@
 #ifndef __ASM_SH_USER_H
 #define __ASM_SH_USER_H
 
-#include <linux/types.h>
-#include <asm/processor.h>
 #include <asm/ptrace.h>
 #include <asm/page.h>
 
diff -Nru a/include/asm-sh/watchdog.h b/include/asm-sh/watchdog.h
--- a/include/asm-sh/watchdog.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-sh/watchdog.h	2004-12-24 13:36:48 -08:00
@@ -10,6 +10,7 @@
  */
 #ifndef __ASM_SH_WATCHDOG_H
 #define __ASM_SH_WATCHDOG_H
+#ifdef __KERNEL__
 
 #include <linux/types.h>
 #include <linux/config.h>
@@ -106,5 +107,5 @@
 	ctrl_outw((WTCSR_HIGH << 8) | (__u16)val, WTCSR);
 }
 
+#endif /* __KERNEL__ */
 #endif /* __ASM_SH_WATCHDOG_H */
-
diff -Nru a/include/asm-sh64/io.h b/include/asm-sh64/io.h
--- a/include/asm-sh64/io.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-sh64/io.h	2004-12-24 13:36:48 -08:00
@@ -86,6 +86,9 @@
 #define readb(addr)		sh64_in8(addr)
 #define readw(addr)		sh64_in16(addr)
 #define readl(addr)		sh64_in32(addr)
+#define readb_relaxed(addr)		sh64_in8(addr)
+#define readw_relaxed(addr)		sh64_in16(addr)
+#define readl_relaxed(addr)		sh64_in32(addr)
 
 #define writeb(b, addr)		sh64_out8(b, addr)
 #define writew(b, addr)		sh64_out16(b, addr)
@@ -105,6 +108,8 @@
 void outb(unsigned long value, unsigned long port);
 void outw(unsigned long value, unsigned long port);
 void outl(unsigned long value, unsigned long port);
+
+#define mmiowb()
 
 #ifdef __KERNEL__
 
diff -Nru a/include/asm-sh64/pgtable.h b/include/asm-sh64/pgtable.h
--- a/include/asm-sh64/pgtable.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-sh64/pgtable.h	2004-12-24 13:37:04 -08:00
@@ -479,7 +479,8 @@
 #define PageSkip(page)		(0)
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 #endif /* !__ASSEMBLY__ */
 
 /*
diff -Nru a/include/asm-sparc/atomic.h b/include/asm-sparc/atomic.h
--- a/include/asm-sparc/atomic.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-sparc/atomic.h	2004-12-24 13:37:01 -08:00
@@ -46,6 +46,7 @@
 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
 
 #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
+#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
 
 /* This is the old 24-bit implementation.  It's still used internally
  * by some sparc-specific code, notably the semaphore implementation.
diff -Nru a/include/asm-sparc/dma.h b/include/asm-sparc/dma.h
--- a/include/asm-sparc/dma.h	2004-12-24 13:36:56 -08:00
+++ b/include/asm-sparc/dma.h	2004-12-24 13:36:56 -08:00
@@ -69,7 +69,7 @@
 struct sbus_dma {
 	struct sbus_dma *next;
 	struct sbus_dev *sdev;
-	unsigned long regs;
+	void __iomem *regs;
 
 	/* Status, misc info */
 	int node;                /* Prom node for this DMA device */
diff -Nru a/include/asm-sparc/elf.h b/include/asm-sparc/elf.h
--- a/include/asm-sparc/elf.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-sparc/elf.h	2004-12-24 13:37:18 -08:00
@@ -143,7 +143,7 @@
    the loader.  We need to make sure that it is out of the way of the program
    that it will "exec", and that there is sufficient room for the brk.  */
 
-#define ELF_ET_DYN_BASE         (0x08000000)
+#define ELF_ET_DYN_BASE         (TASK_UNMAPPED_BASE)
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this cpu supports.  This can NOT be done in userspace
diff -Nru a/include/asm-sparc/errno.h b/include/asm-sparc/errno.h
--- a/include/asm-sparc/errno.h	2004-12-24 13:37:17 -08:00
+++ b/include/asm-sparc/errno.h	2004-12-24 13:37:17 -08:00
@@ -101,5 +101,10 @@
 
 #define	ENOMEDIUM	125	/* No medium found */
 #define	EMEDIUMTYPE	126	/* Wrong medium type */
+#define	ECANCELED	127	/* Operation Cancelled */
+#define	ENOKEY		128	/* Required key not available */
+#define	EKEYEXPIRED	129	/* Key has expired */
+#define	EKEYREVOKED	130	/* Key has been revoked */
+#define	EKEYREJECTED	131	/* Key was rejected by service */
 
 #endif
diff -Nru a/include/asm-sparc/fbio.h b/include/asm-sparc/fbio.h
--- a/include/asm-sparc/fbio.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-sparc/fbio.h	2004-12-24 13:36:18 -08:00
@@ -53,9 +53,9 @@
 struct  fbcmap {
         int             index;          /* first element (0 origin) */
         int             count;
-        unsigned char   *red;
-        unsigned char   *green;
-        unsigned char   *blue;
+        unsigned char   __user *red;
+        unsigned char   __user *green;
+        unsigned char   __user *blue;
 };
 
 #ifdef __KERNEL__
diff -Nru a/include/asm-sparc/hardirq.h b/include/asm-sparc/hardirq.h
--- a/include/asm-sparc/hardirq.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-sparc/hardirq.h	2004-12-24 13:37:43 -08:00
@@ -19,28 +19,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS    8
-#define SOFTIRQ_BITS    8
 #define HARDIRQ_BITS    8
-
-#define PREEMPT_SHIFT   0
-#define SOFTIRQ_SHIFT   (PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT   (SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 #define irq_enter()             (preempt_count() += HARDIRQ_OFFSET)
 #define irq_exit()                                                      \
diff -Nru a/include/asm-sparc/io.h b/include/asm-sparc/io.h
--- a/include/asm-sparc/io.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-sparc/io.h	2004-12-24 13:36:18 -08:00
@@ -23,89 +23,82 @@
 	return ((w&0xff) << 8) | ((w>>8)&0xff);
 }
 
+#define mmiowb()
+
 /*
  * Memory mapped I/O to PCI
- *
- * Observe that ioremap returns void* cookie, but accessors, such
- * as readb, take unsigned long as address, by API. This mismatch
- * happened historically. The ioremap is much older than accessors,
- * so at one time ioremap's cookie was used as address (*a = val).
- * When accessors came about, they were designed to be compatible across
- * buses, so that drivers can select proper ones like sunhme.c did.
- * To make that easier, they use same aruments (ulong) for sbus, pci, isa.
- * The offshot is, we must cast readb et. al. arguments with a #define.
  */
 
-static inline u8 __raw_readb(unsigned long addr)
+static inline u8 __raw_readb(const volatile void __iomem *addr)
 {
-	return *(volatile u8 *)addr;
+	return *(__force volatile u8 *)addr;
 }
 
-static inline u16 __raw_readw(unsigned long addr)
+static inline u16 __raw_readw(const volatile void __iomem *addr)
 {
-	return *(volatile u16 *)addr;
+	return *(__force volatile u16 *)addr;
 }
 
-static inline u32 __raw_readl(unsigned long addr)
+static inline u32 __raw_readl(const volatile void __iomem *addr)
 {
-	return *(volatile u32 *)addr;
+	return *(__force volatile u32 *)addr;
 }
 
-static inline void __raw_writeb(u8 b, unsigned long addr)
+static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
 {
-	*(volatile u8 *)addr = b;
+	*(__force volatile u8 *)addr = b;
 }
 
-static inline void __raw_writew(u16 w, unsigned long addr)
+static inline void __raw_writew(u16 w, volatile void __iomem *addr)
 {
-	*(volatile u16 *)addr = w;
+	*(__force volatile u16 *)addr = w;
 }
 
-static inline void __raw_writel(u32 l, unsigned long addr)
+static inline void __raw_writel(u32 l, volatile void __iomem *addr)
 {
-	*(volatile u32 *)addr = l;
+	*(__force volatile u32 *)addr = l;
 }
 
-static inline u8 __readb(unsigned long addr)
+static inline u8 __readb(const volatile void __iomem *addr)
 {
-	return *(volatile u8 *)addr;
+	return *(__force volatile u8 *)addr;
 }
 
-static inline u16 __readw(unsigned long addr)
+static inline u16 __readw(const volatile void __iomem *addr)
 {
-	return flip_word(*(volatile u16 *)addr);
+	return flip_word(*(__force volatile u16 *)addr);
 }
 
-static inline u32 __readl(unsigned long addr)
+static inline u32 __readl(const volatile void __iomem *addr)
 {
-	return flip_dword(*(volatile u32 *)addr);
+	return flip_dword(*(__force volatile u32 *)addr);
 }
 
-static inline void __writeb(u8 b, unsigned long addr)
+static inline void __writeb(u8 b, volatile void __iomem *addr)
 {
-	*(volatile u8 *)addr = b;
+	*(__force volatile u8 *)addr = b;
 }
 
-static inline void __writew(u16 w, unsigned long addr)
+static inline void __writew(u16 w, volatile void __iomem *addr)
 {
-	*(volatile u16 *)addr = flip_word(w);
+	*(__force volatile u16 *)addr = flip_word(w);
 }
 
-static inline void __writel(u32 l, unsigned long addr)
+static inline void __writel(u32 l, volatile void __iomem *addr)
 {
-	*(volatile u32 *)addr = flip_dword(l);
+	*(__force volatile u32 *)addr = flip_dword(l);
 }
 
-#define readb(__addr)		__readb((unsigned long)(__addr))
-#define readw(__addr)		__readw((unsigned long)(__addr))
-#define readl(__addr)		__readl((unsigned long)(__addr))
+#define readb(__addr)		__readb(__addr)
+#define readw(__addr)		__readw(__addr)
+#define readl(__addr)		__readl(__addr)
 #define readb_relaxed(__addr)	readb(__addr)
 #define readw_relaxed(__addr)	readw(__addr)
 #define readl_relaxed(__addr)	readl(__addr)
 
-#define writeb(__b, __addr)	__writeb((__b),(unsigned long)(__addr))
-#define writew(__w, __addr)	__writew((__w),(unsigned long)(__addr))
-#define writel(__l, __addr)	__writel((__l),(unsigned long)(__addr))
+#define writeb(__b, __addr)	__writeb((__b),(__addr))
+#define writew(__w, __addr)	__writew((__w),(__addr))
+#define writel(__l, __addr)	__writel((__l),(__addr))
 
 /*
  * I/O space operations
@@ -124,15 +117,15 @@
  * mapped somewhere into virtual kernel space and we
  * can use inb/outb again.
  */
-#define inb_local(__addr)	__readb((unsigned long)(__addr))
-#define inb(__addr)		__readb((unsigned long)(__addr))
-#define inw(__addr)		__readw((unsigned long)(__addr))
-#define inl(__addr)		__readl((unsigned long)(__addr))
-
-#define outb_local(__b, __addr)	__writeb(__b, (unsigned long)(__addr))
-#define outb(__b, __addr)	__writeb(__b, (unsigned long)(__addr))
-#define outw(__w, __addr)	__writew(__w, (unsigned long)(__addr))
-#define outl(__l, __addr)	__writel(__l, (unsigned long)(__addr))
+#define inb_local(__addr)	__readb((void __iomem *)(unsigned long)(__addr))
+#define inb(__addr)		__readb((void __iomem *)(unsigned long)(__addr))
+#define inw(__addr)		__readw((void __iomem *)(unsigned long)(__addr))
+#define inl(__addr)		__readl((void __iomem *)(unsigned long)(__addr))
+
+#define outb_local(__b, __addr)	__writeb(__b, (void __iomem *)(unsigned long)(__addr))
+#define outb(__b, __addr)	__writeb(__b, (void __iomem *)(unsigned long)(__addr))
+#define outw(__w, __addr)	__writew(__w, (void __iomem *)(unsigned long)(__addr))
+#define outl(__l, __addr)	__writel(__l, (void __iomem *)(unsigned long)(__addr))
 
 #define inb_p(__addr)		inb(__addr)
 #define outb_p(__b, __addr)	outb(__b, __addr)
@@ -156,73 +149,112 @@
  * SBus has only one, memory mapped, I/O space.
  * We do not need to flip bytes for SBus of course.
  */
-static inline u8 _sbus_readb(unsigned long addr)
+static inline u8 _sbus_readb(const volatile void __iomem *addr)
 {
-	return *(volatile u8 *)addr;
+	return *(__force volatile u8 *)addr;
 }
 
-static inline u16 _sbus_readw(unsigned long addr)
+static inline u16 _sbus_readw(const volatile void __iomem *addr)
 {
-	return *(volatile u16 *)addr;
+	return *(__force volatile u16 *)addr;
 }
 
-static inline u32 _sbus_readl(unsigned long addr)
+static inline u32 _sbus_readl(const volatile void __iomem *addr)
 {
-	return *(volatile u32 *)addr;
+	return *(__force volatile u32 *)addr;
 }
 
-static inline void _sbus_writeb(u8 b, unsigned long addr)
+static inline void _sbus_writeb(u8 b, volatile void __iomem *addr)
 {
-	*(volatile u8 *)addr = b;
+	*(__force volatile u8 *)addr = b;
 }
 
-static inline void _sbus_writew(u16 w, unsigned long addr)
+static inline void _sbus_writew(u16 w, volatile void __iomem *addr)
 {
-	*(volatile u16 *)addr = w;
+	*(__force volatile u16 *)addr = w;
 }
 
-static inline void _sbus_writel(u32 l, unsigned long addr)
+static inline void _sbus_writel(u32 l, volatile void __iomem *addr)
 {
-	*(volatile u32 *)addr = l;
+	*(__force volatile u32 *)addr = l;
 }
 
 /*
  * The only reason for #define's is to hide casts to unsigned long.
  */
-#define sbus_readb(__addr)		_sbus_readb((unsigned long)(__addr))
-#define sbus_readw(__addr)		_sbus_readw((unsigned long)(__addr))
-#define sbus_readl(__addr)		_sbus_readl((unsigned long)(__addr))
-#define sbus_writeb(__b, __addr)	_sbus_writeb(__b, (unsigned long)(__addr))
-#define sbus_writew(__w, __addr)	_sbus_writew(__w, (unsigned long)(__addr))
-#define sbus_writel(__l, __addr)	_sbus_writel(__l, (unsigned long)(__addr))
+#define sbus_readb(__addr)		_sbus_readb(__addr)
+#define sbus_readw(__addr)		_sbus_readw(__addr)
+#define sbus_readl(__addr)		_sbus_readl(__addr)
+#define sbus_writeb(__b, __addr)	_sbus_writeb(__b, __addr)
+#define sbus_writew(__w, __addr)	_sbus_writew(__w, __addr)
+#define sbus_writel(__l, __addr)	_sbus_writel(__l, __addr)
 
-static inline void *sbus_memset_io(void *__dst, int c, __kernel_size_t n)
+static inline void sbus_memset_io(volatile void __iomem *__dst, int c, __kernel_size_t n)
 {
-	unsigned long dst = (unsigned long)__dst;
-
 	while(n--) {
-		sbus_writeb(c, dst);
-		dst++;
+		sbus_writeb(c, __dst);
+		__dst++;
 	}
-	return (void *) dst;
 }
 
+static inline void
+_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
+{
+	volatile void __iomem *d = dst;
+
+	while (n--) {
+		writeb(c, d);
+		d++;
+	}
+}
+
+#define memset_io(d,c,sz)	_memset_io(d,c,sz)
+
+static inline void
+_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
+{
+	char *d = dst;
+
+	while (n--) {
+		char tmp = readb(src);
+		*d++ = tmp;
+		src++;
+	}
+}
+
+#define memcpy_fromio(d,s,sz)	_memcpy_fromio(d,s,sz)
+
+static inline void 
+_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
+{
+	const char *s = src;
+	volatile void __iomem *d = dst;
+
+	while (n--) {
+		char tmp = *s++;
+		writeb(tmp, d);
+		d++;
+	}
+}
+
+#define memcpy_toio(d,s,sz)	_memcpy_toio(d,s,sz)
+
 #ifdef __KERNEL__
 
 /*
  * Bus number may be embedded in the higher bits of the physical address.
  * This is why we have no bus number argument to ioremap().
  */
-extern void *ioremap(unsigned long offset, unsigned long size);
+extern void __iomem *ioremap(unsigned long offset, unsigned long size);
 #define ioremap_nocache(X,Y)	ioremap((X),(Y))
-extern void iounmap(void *addr);
+extern void iounmap(volatile void __iomem *addr);
 
 /*
  * Bus number may be in res->flags... somewhere.
  */
-extern unsigned long sbus_ioremap(struct resource *res, unsigned long offset,
+extern void __iomem *sbus_ioremap(struct resource *res, unsigned long offset,
     unsigned long size, char *name);
-extern void sbus_iounmap(unsigned long vaddr, unsigned long size);
+extern void sbus_iounmap(volatile void __iomem *vaddr, unsigned long size);
 
 
 /*
diff -Nru a/include/asm-sparc/mostek.h b/include/asm-sparc/mostek.h
--- a/include/asm-sparc/mostek.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-sparc/mostek.h	2004-12-24 13:37:19 -08:00
@@ -11,6 +11,7 @@
 
 #include <linux/config.h>
 #include <asm/idprom.h>
+#include <asm/io.h>
 
 /*       M48T02 Register Map (adapted from Sun NVRAM/Hostid FAQ)
  *
@@ -38,8 +39,8 @@
  * other than the control register are in binary coded decimal. Some
  * control bits also live outside the control register.
  */
-#define mostek_read(_addr)		(*((volatile u8 *)(_addr)))
-#define mostek_write(_addr,_val)	((*((volatile u8 *)(_addr))) = (_val))
+#define mostek_read(_addr)		readb(_addr)
+#define mostek_write(_addr,_val)	writeb(_val, _addr)
 #define MOSTEK_EEPROM		0x0000UL
 #define MOSTEK_IDPROM		0x07d8UL
 #define MOSTEK_CREG		0x07f8UL
@@ -65,7 +66,7 @@
 };
 
 extern spinlock_t mostek_lock;
-extern unsigned long mstk48t02_regs;
+extern void __iomem *mstk48t02_regs;
 
 /* Control register values. */
 #define	MSTK_CREG_WRITE	0x80	/* Must set this before placing values. */
diff -Nru a/include/asm-sparc/processor.h b/include/asm-sparc/processor.h
--- a/include/asm-sparc/processor.h	2004-12-24 13:37:31 -08:00
+++ b/include/asm-sparc/processor.h	2004-12-24 13:37:31 -08:00
@@ -43,10 +43,12 @@
 
 struct task_struct;
 
+#ifdef __KERNEL__
 struct fpq {
 	unsigned long *insn_addr;
 	unsigned long insn;
 };
+#endif
 
 typedef struct {
 	int seg;
diff -Nru a/include/asm-sparc/sigcontext.h b/include/asm-sparc/sigcontext.h
--- a/include/asm-sparc/sigcontext.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-sparc/sigcontext.h	2004-12-24 13:36:31 -08:00
@@ -4,7 +4,6 @@
 
 #ifdef __KERNEL__
 #include <asm/ptrace.h>
-#endif
 
 #ifndef __ASSEMBLY__
 
@@ -58,5 +57,7 @@
 } __siginfo_fpu_t;
 
 #endif /* !(__ASSEMBLY__) */
+
+#endif /* (__KERNEL__) */
 
 #endif /* !(__SPARC_SIGCONTEXT_H) */
diff -Nru a/include/asm-sparc/signal.h b/include/asm-sparc/signal.h
--- a/include/asm-sparc/signal.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-sparc/signal.h	2004-12-24 13:37:00 -08:00
@@ -3,6 +3,7 @@
 #define _ASMSPARC_SIGNAL_H
 
 #include <asm/sigcontext.h>
+#include <linux/compiler.h>
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
@@ -111,11 +112,14 @@
 	unsigned long	sig[_NSIG_WORDS];
 } __new_sigset_t;
 
+
+#ifdef __KERNEL__
 /* A SunOS sigstack */
 struct sigstack {
 	char *the_stack;
 	int   cur_status;
 };
+#endif
 
 /* Sigvec flags */
 #define _SV_SSTACK    1u    /* This signal handler should use sig-stack */
@@ -189,6 +193,7 @@
 #define SIG_IGN	((__sighandler_t)1)	/* ignore signal */
 #define SIG_ERR	((__sighandler_t)-1)	/* error return from signal */
 
+#ifdef __KERNEL__
 struct __new_sigaction {
 	__sighandler_t	sa_handler;
 	unsigned long	sa_flags;
@@ -196,12 +201,10 @@
 	__new_sigset_t	sa_mask;
 };
 
-#ifdef __KERNEL__
 struct k_sigaction {
 	struct __new_sigaction	sa;
 	void			__user *ka_restorer;
 };
-#endif
 
 struct __old_sigaction {
 	__sighandler_t	sa_handler;
@@ -216,7 +219,6 @@
 	size_t		ss_size;
 } stack_t;
 
-#ifdef __KERNEL__
 struct sparc_deliver_cookie {
 	int restart_syscall;
 	unsigned long orig_i0;
diff -Nru a/include/asm-sparc/timex.h b/include/asm-sparc/timex.h
--- a/include/asm-sparc/timex.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-sparc/timex.h	2004-12-24 13:37:01 -08:00
@@ -7,10 +7,6 @@
 #define _ASMsparc_TIMEX_H
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 /* XXX Maybe do something better at some point... -DaveM */
 typedef unsigned long cycles_t;
diff -Nru a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
--- a/include/asm-sparc/unistd.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-sparc/unistd.h	2004-12-24 13:36:18 -08:00
@@ -296,8 +296,12 @@
 #define __NR_mq_notify		277
 #define __NR_mq_getsetattr	278
 #define __NR_waitid		279
+#define __NR_sys_setaltroot	280
+#define __NR_add_key		281
+#define __NR_request_key	282
+#define __NR_keyctl		283
 
-/* WARNING: You MAY NOT add syscall numbers larger than 282, since
+/* WARNING: You MAY NOT add syscall numbers larger than 283, since
  *          all of the syscall tables in the Sparc kernel are
  *          sized to have 283 entries (starting at zero).  Therefore
  *          find a free slot in the 0-282 range.
diff -Nru a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h
--- a/include/asm-sparc64/atomic.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-sparc64/atomic.h	2004-12-24 13:37:19 -08:00
@@ -40,6 +40,12 @@
 #define atomic_inc_return(v) __atomic_add(1, v)
 #define atomic64_inc_return(v) __atomic64_add(1, v)
 
+#define atomic_sub_return(i, v) __atomic_sub(i, v)
+#define atomic64_sub_return(i, v) __atomic64_sub(i, v)
+
+#define atomic_add_return(i, v) __atomic_add(i, v)
+#define atomic64_add_return(i, v) __atomic64_add(i, v)
+
 /*
  * atomic_inc_and_test - increment and test
  * @v: pointer of type atomic_t
diff -Nru a/include/asm-sparc64/errno.h b/include/asm-sparc64/errno.h
--- a/include/asm-sparc64/errno.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-sparc64/errno.h	2004-12-24 13:36:18 -08:00
@@ -101,5 +101,10 @@
 
 #define ENOMEDIUM       125     /* No medium found */
 #define EMEDIUMTYPE     126     /* Wrong medium type */
+#define	ECANCELED	127	/* Operation Cancelled */
+#define	ENOKEY		128	/* Required key not available */
+#define	EKEYEXPIRED	129	/* Key has expired */
+#define	EKEYREVOKED	130	/* Key has been revoked */
+#define	EKEYREJECTED	131	/* Key was rejected by service */
 
 #endif /* !(_SPARC64_ERRNO_H) */
diff -Nru a/include/asm-sparc64/hardirq.h b/include/asm-sparc64/hardirq.h
--- a/include/asm-sparc64/hardirq.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-sparc64/hardirq.h	2004-12-24 13:37:02 -08:00
@@ -18,28 +18,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 #define irq_exit()							\
diff -Nru a/include/asm-sparc64/io.h b/include/asm-sparc64/io.h
--- a/include/asm-sparc64/io.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-sparc64/io.h	2004-12-24 13:37:18 -08:00
@@ -114,7 +114,7 @@
 #define iowrite32_rep(a,s,c)	outsl(a,s,c)
 
 /* Memory functions, same as I/O accesses on Ultra. */
-static inline u8 _readb(void __iomem *addr)
+static inline u8 _readb(const volatile void __iomem *addr)
 {	u8 ret;
 
 	__asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_readb */"
@@ -123,7 +123,7 @@
 	return ret;
 }
 
-static inline u16 _readw(void __iomem *addr)
+static inline u16 _readw(const volatile void __iomem *addr)
 {	u16 ret;
 
 	__asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_readw */"
@@ -133,7 +133,7 @@
 	return ret;
 }
 
-static inline u32 _readl(void __iomem *addr)
+static inline u32 _readl(const volatile void __iomem *addr)
 {	u32 ret;
 
 	__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_readl */"
@@ -143,7 +143,7 @@
 	return ret;
 }
 
-static inline u64 _readq(void __iomem *addr)
+static inline u64 _readq(const volatile void __iomem *addr)
 {	u64 ret;
 
 	__asm__ __volatile__("ldxa\t[%1] %2, %0\t/* pci_readq */"
@@ -153,28 +153,28 @@
 	return ret;
 }
 
-static inline void _writeb(u8 b, void __iomem *addr)
+static inline void _writeb(u8 b, volatile void __iomem *addr)
 {
 	__asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_writeb */"
 			     : /* no outputs */
 			     : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
 }
 
-static inline void _writew(u16 w, void __iomem *addr)
+static inline void _writew(u16 w, volatile void __iomem *addr)
 {
 	__asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_writew */"
 			     : /* no outputs */
 			     : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
 }
 
-static inline void _writel(u32 l, void __iomem *addr)
+static inline void _writel(u32 l, volatile void __iomem *addr)
 {
 	__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_writel */"
 			     : /* no outputs */
 			     : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
 }
 
-static inline void _writeq(u64 q, void __iomem *addr)
+static inline void _writeq(u64 q, volatile void __iomem *addr)
 {
 	__asm__ __volatile__("stxa\t%r0, [%1] %2\t/* pci_writeq */"
 			     : /* no outputs */
@@ -284,7 +284,7 @@
 /* Now, SBUS variants, only difference from PCI is that we do
  * not use little-endian ASIs.
  */
-static inline u8 _sbus_readb(void __iomem *addr)
+static inline u8 _sbus_readb(const volatile void __iomem *addr)
 {
 	u8 ret;
 
@@ -295,7 +295,7 @@
 	return ret;
 }
 
-static inline u16 _sbus_readw(void __iomem *addr)
+static inline u16 _sbus_readw(const volatile void __iomem *addr)
 {
 	u16 ret;
 
@@ -306,7 +306,7 @@
 	return ret;
 }
 
-static inline u32 _sbus_readl(void __iomem *addr)
+static inline u32 _sbus_readl(const volatile void __iomem *addr)
 {
 	u32 ret;
 
@@ -317,7 +317,7 @@
 	return ret;
 }
 
-static inline u64 _sbus_readq(void __iomem *addr)
+static inline u64 _sbus_readq(const volatile void __iomem *addr)
 {
 	u64 ret;
 
@@ -328,28 +328,28 @@
 	return ret;
 }
 
-static inline void _sbus_writeb(u8 b, void __iomem *addr)
+static inline void _sbus_writeb(u8 b, volatile void __iomem *addr)
 {
 	__asm__ __volatile__("stba\t%r0, [%1] %2\t/* sbus_writeb */"
 			     : /* no outputs */
 			     : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
 }
 
-static inline void _sbus_writew(u16 w, void __iomem *addr)
+static inline void _sbus_writew(u16 w, volatile void __iomem *addr)
 {
 	__asm__ __volatile__("stha\t%r0, [%1] %2\t/* sbus_writew */"
 			     : /* no outputs */
 			     : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
 }
 
-static inline void _sbus_writel(u32 l, void __iomem *addr)
+static inline void _sbus_writel(u32 l, volatile void __iomem *addr)
 {
 	__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* sbus_writel */"
 			     : /* no outputs */
 			     : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
 }
 
-static inline void _sbus_writeq(u64 l, void __iomem *addr)
+static inline void _sbus_writeq(u64 l, volatile void __iomem *addr)
 {
 	__asm__ __volatile__("stxa\t%r0, [%1] %2\t/* sbus_writeq */"
 			     : /* no outputs */
@@ -365,35 +365,31 @@
 #define sbus_writel(__l, __addr)	_sbus_writel(__l, __addr)
 #define sbus_writeq(__l, __addr)	_sbus_writeq(__l, __addr)
 
-static inline void __iomem*_sbus_memset_io(void __iomem *dst, int c,
-					   __kernel_size_t n)
+static inline void _sbus_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
 {
 	while(n--) {
 		sbus_writeb(c, dst);
 		dst++;
 	}
-	return (void *) dst;
 }
 
 #define sbus_memset_io(d,c,sz)	_sbus_memset_io(d,c,sz)
 
-static inline void __iomem *
-_memset_io(void __iomem *dst, int c, __kernel_size_t n)
+static inline void
+_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
 {
-	void __iomem *d = dst;
+	volatile void __iomem *d = dst;
 
 	while (n--) {
 		writeb(c, d);
 		d++;
 	}
-
-	return dst;
 }
 
 #define memset_io(d,c,sz)	_memset_io(d,c,sz)
 
-static inline void __iomem *
-_memcpy_fromio(void *dst, void __iomem *src, __kernel_size_t n)
+static inline void
+_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
 {
 	char *d = dst;
 
@@ -402,24 +398,21 @@
 		*d++ = tmp;
 		src++;
 	}
-
-	return dst;
 }
 
 #define memcpy_fromio(d,s,sz)	_memcpy_fromio(d,s,sz)
 
-static inline void __iomem *
-_memcpy_toio(void __iomem *dst, const void *src, __kernel_size_t n)
+static inline void 
+_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
 {
 	const char *s = src;
-	void __iomem *d = dst;
+	volatile void __iomem *d = dst;
 
 	while (n--) {
 		char tmp = *s++;
 		writeb(tmp, d);
 		d++;
 	}
-	return dst;
 }
 
 #define memcpy_toio(d,s,sz)	_memcpy_toio(d,s,sz)
@@ -439,14 +432,23 @@
 	return retval;
 }
 
+#define mmiowb()
+
 #ifdef __KERNEL__
 
 /* On sparc64 we have the whole physical IO address space accessible
  * using physically addressed loads and stores, so this does nothing.
  */
-#define ioremap(__offset, __size)	((void __iomem *)(__offset))
+static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
+{
+	return (void __iomem *)offset;
+}
+
 #define ioremap_nocache(X,Y)		ioremap((X),(Y))
-#define iounmap(__addr)			do { (void)(__addr); } while(0)
+
+static inline void iounmap(volatile void __iomem *addr)
+{
+}
 
 #define ioread8(X)			readb(X)
 #define ioread16(X)			readw(X)
diff -Nru a/include/asm-sparc64/kprobes.h b/include/asm-sparc64/kprobes.h
--- a/include/asm-sparc64/kprobes.h	2004-12-24 13:37:00 -08:00
+++ b/include/asm-sparc64/kprobes.h	2004-12-24 13:37:00 -08:00
@@ -10,6 +10,12 @@
 #define BREAKPOINT_INSTRUCTION_2 0x91d02071 /* ta 0x71 */
 #define MAX_INSN_SIZE 2
 
+/* Architecture specific copy of original instruction*/
+struct arch_specific_insn {
+	/* copy of the original instruction */
+	kprobe_opcode_t insn[MAX_INSN_SIZE];
+};
+
 #ifdef CONFIG_KPROBES
 extern int kprobe_exceptions_notify(struct notifier_block *self,
 				    unsigned long val, void *data);
diff -Nru a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
--- a/include/asm-sparc64/pci.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-sparc64/pci.h	2004-12-24 13:36:19 -08:00
@@ -251,6 +251,11 @@
 {
 }
 
+static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
+{
+	return PCI_IRQ_NONE;
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* __SPARC64_PCI_H */
diff -Nru a/include/asm-sparc64/timex.h b/include/asm-sparc64/timex.h
--- a/include/asm-sparc64/timex.h	2004-12-24 13:36:49 -08:00
+++ b/include/asm-sparc64/timex.h	2004-12-24 13:36:49 -08:00
@@ -9,10 +9,6 @@
 #include <asm/timer.h>
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 /* Getting on the cycle counter on sparc64. */
 typedef unsigned long cycles_t;
diff -Nru a/include/asm-sparc64/uaccess.h b/include/asm-sparc64/uaccess.h
--- a/include/asm-sparc64/uaccess.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-sparc64/uaccess.h	2004-12-24 13:37:43 -08:00
@@ -253,12 +253,13 @@
 
 extern int __get_user_bad(void);
 
-extern unsigned long ___copy_from_user(void *to, const void __user *from,
-				       unsigned long size);
+extern unsigned long __must_check ___copy_from_user(void *to,
+						    const void __user *from,
+						    unsigned long size);
 extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
 					  unsigned long size);
-static inline unsigned long copy_from_user(void *to, const void __user *from,
-					   unsigned long size)
+static inline unsigned long __must_check
+copy_from_user(void *to, const void __user *from, unsigned long size)
 {
 	unsigned long ret = ___copy_from_user(to, from, size);
 
@@ -268,12 +269,13 @@
 }
 #define __copy_from_user copy_from_user
 
-extern unsigned long ___copy_to_user(void __user *to, const void *from,
-				     unsigned long size);
+extern unsigned long __must_check ___copy_to_user(void __user *to,
+						  const void *from,
+						  unsigned long size);
 extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
 					unsigned long size);
-static inline unsigned long copy_to_user(void __user *to, const void *from,
-					 unsigned long size)
+static inline unsigned long __must_check
+copy_to_user(void __user *to, const void *from, unsigned long size)
 {
 	unsigned long ret = ___copy_to_user(to, from, size);
 
@@ -283,12 +285,13 @@
 }
 #define __copy_to_user copy_to_user
 
-extern unsigned long ___copy_in_user(void __user *to, const void __user *from,
-				     unsigned long size);
+extern unsigned long __must_check ___copy_in_user(void __user *to,
+						  const void __user *from,
+						  unsigned long size);
 extern unsigned long copy_in_user_fixup(void __user *to, void __user *from,
 					unsigned long size);
-static inline unsigned long copy_in_user(void __user *to, void __user *from,
-					 unsigned long size)
+static inline unsigned long __must_check
+copy_in_user(void __user *to, void __user *from, unsigned long size)
 {
 	unsigned long ret = ___copy_in_user(to, from, size);
 
@@ -298,9 +301,10 @@
 }
 #define __copy_in_user copy_in_user
 
-extern unsigned long __bzero_noasi(void __user *, unsigned long);
+extern unsigned long __must_check __bzero_noasi(void __user *, unsigned long);
 
-static inline unsigned long __clear_user(void __user *addr, unsigned long size)
+static inline unsigned long __must_check
+__clear_user(void __user *addr, unsigned long size)
 {
 	
 	return __bzero_noasi(addr, size);
@@ -308,7 +312,7 @@
 
 #define clear_user __clear_user
 
-extern long __strncpy_from_user(char *dest, const char __user *src, long count);
+extern long __must_check __strncpy_from_user(char *dest, const char __user *src, long count);
 
 #define strncpy_from_user __strncpy_from_user
 
diff -Nru a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
--- a/include/asm-sparc64/unistd.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-sparc64/unistd.h	2004-12-24 13:36:19 -08:00
@@ -298,8 +298,12 @@
 #define __NR_mq_notify		277
 #define __NR_mq_getsetattr	278
 #define __NR_waitid		279
+/*#define __NR_sys_setaltroot	280 available (was setaltroot) */
+#define __NR_add_key		281
+#define __NR_request_key	282
+#define __NR_keyctl		283
 
-/* WARNING: You MAY NOT add syscall numbers larger than 282, since
+/* WARNING: You MAY NOT add syscall numbers larger than 283, since
  *          all of the syscall tables in the Sparc kernel are
  *          sized to have 283 entries (starting at zero).  Therefore
  *          find a free slot in the 0-282 range.
diff -Nru a/include/asm-um/atomic.h b/include/asm-um/atomic.h
--- a/include/asm-um/atomic.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-um/atomic.h	2004-12-24 13:36:55 -08:00
@@ -1,6 +1,11 @@
 #ifndef __UM_ATOMIC_H
 #define __UM_ATOMIC_H
 
+/* The i386 atomic.h calls printk, but doesn't include kernel.h, so we
+ * include it here.
+ */
+#include "linux/kernel.h"
+
 #include "asm/arch/atomic.h"
 
 #endif
diff -Nru a/include/asm-um/current.h b/include/asm-um/current.h
--- a/include/asm-um/current.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-um/current.h	2004-12-24 13:36:18 -08:00
@@ -8,18 +8,13 @@
 
 #ifndef __ASSEMBLY__
 
-struct thread_info;
-
-#include "linux/config.h"
 #include "asm/page.h"
+#include "linux/thread_info.h"
 
-#define CURRENT_THREAD(dummy) (((unsigned long) &dummy) & \
-			        (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER))
-
-#define current_thread \
-	({ int dummy; ((struct thread_info *) CURRENT_THREAD(dummy)); })
+#define current (current_thread_info()->task)
 
-#define current (current_thread->task)
+/*Backward compatibility - it's used inside arch/um.*/
+#define current_thread current_thread_info()
 
 #endif /* __ASSEMBLY__ */
 
diff -Nru a/include/asm-um/hardirq.h b/include/asm-um/hardirq.h
--- a/include/asm-um/hardirq.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-um/hardirq.h	2004-12-24 13:36:18 -08:00
@@ -1,6 +1,26 @@
-#ifndef __UM_HARDIRQ_H
-#define __UM_HARDIRQ_H
+/* (c) 2004 cw@f00f.org, GPLv2 blah blah */
 
-#include "asm/arch/hardirq.h"
+#ifndef __ASM_UM_HARDIRQ_H
+#define __ASM_UM_HARDIRQ_H
 
-#endif
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <linux/irq.h>
+
+/* NOTE: When SMP works again we might want to make this
+ * ____cacheline_aligned or maybe use per_cpu state? --cw */
+typedef struct {
+	unsigned int __softirq_pending;
+} irq_cpustat_t;
+
+#include <linux/irq_cpustat.h>
+
+/* As this would be very strange for UML to get we BUG() after the
+ * printk. */
+static inline void ack_bad_irq(unsigned int irq)
+{
+	printk(KERN_ERR "unexpected IRQ %02x\n", irq);
+	BUG();
+}
+
+#endif /* __ASM_UM_HARDIRQ_H */
diff -Nru a/include/asm-um/pgtable.h b/include/asm-um/pgtable.h
--- a/include/asm-um/pgtable.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-um/pgtable.h	2004-12-24 13:37:43 -08:00
@@ -405,11 +405,10 @@
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_kernel(*(dir)) +  pte_index(address))
 #define pte_offset_map(dir, address) \
-        ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
-#define pte_offset_map_nested(dir, address) \
-	((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address))
-#define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0)
-#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
+	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
+#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
 
 #define update_mmu_cache(vma,address,pte) do ; while (0)
 
diff -Nru a/include/asm-um/processor-generic.h b/include/asm-um/processor-generic.h
--- a/include/asm-um/processor-generic.h	2004-12-24 13:36:19 -08:00
+++ b/include/asm-um/processor-generic.h	2004-12-24 13:36:19 -08:00
@@ -25,6 +25,7 @@
 	unsigned long cr2;
 	int err;
 	unsigned long trap_no;
+	int singlestep_syscall;
 	void *fault_addr;
 	void *fault_catcher;
 	struct task_struct *prev_sched;
@@ -37,7 +38,6 @@
 			int extern_pid;
 			int tracing;
 			int switch_pipe[2];
-			int singlestep_syscall;
 			int vm_seq;
 		} tt;
 #endif
diff -Nru a/include/asm-um/ptrace-generic.h b/include/asm-um/ptrace-generic.h
--- a/include/asm-um/ptrace-generic.h	2004-12-24 13:37:04 -08:00
+++ b/include/asm-um/ptrace-generic.h	2004-12-24 13:37:04 -08:00
@@ -10,8 +10,6 @@
 
 #include "linux/config.h"
 
-#include "asm/current.h"
-
 #define pt_regs pt_regs_subarch
 #define show_regs show_regs_subarch
 
diff -Nru a/include/asm-um/thread_info.h b/include/asm-um/thread_info.h
--- a/include/asm-um/thread_info.h	2004-12-24 13:36:34 -08:00
+++ b/include/asm-um/thread_info.h	2004-12-24 13:36:34 -08:00
@@ -8,6 +8,7 @@
 
 #ifndef __ASSEMBLY__
 
+#include <linux/config.h>
 #include <asm/processor.h>
 #include <asm/types.h>
 
diff -Nru a/include/asm-um/unistd.h b/include/asm-um/unistd.h
--- a/include/asm-um/unistd.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-um/unistd.h	2004-12-24 13:37:18 -08:00
@@ -13,10 +13,9 @@
 extern int um_execve(const char *file, char *const argv[], char *const env[]);
 
 #ifdef __KERNEL__
+/* We get __ARCH_WANT_OLD_STAT and __ARCH_WANT_STAT64 from the base arch */
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
-#define __ARCH_WANT_OLD_STAT
-#define __ARCH_WANT_STAT64
 #define __ARCH_WANT_SYS_ALARM
 #define __ARCH_WANT_SYS_GETHOSTNAME
 #define __ARCH_WANT_SYS_PAUSE
@@ -84,7 +83,7 @@
 	KERNEL_CALL(pid_t, sys_setsid)
 }
 
-static inline long lseek(unsigned int fd, off_t offset, unsigned int whence)
+static inline off_t lseek(unsigned int fd, off_t offset, unsigned int whence)
 {
 	KERNEL_CALL(long, sys_lseek, fd, offset, whence)
 }
@@ -102,13 +101,12 @@
 long sys_mmap2(unsigned long addr, unsigned long len,
 		unsigned long prot, unsigned long flags,
 		unsigned long fd, unsigned long pgoff);
-int sys_execve(char *file, char **argv, char **env);
+long sys_execve(char *file, char **argv, char **env);
 long sys_clone(unsigned long clone_flags, unsigned long newsp,
 		int *parent_tid, int *child_tid);
 long sys_fork(void);
 long sys_vfork(void);
-int sys_pipe(unsigned long *fildes);
-int sys_ptrace(long request, long pid, long addr, long data);
+long sys_pipe(unsigned long *fildes);
 struct sigaction;
 asmlinkage long sys_rt_sigaction(int sig,
 				const struct sigaction __user *act,
diff -Nru a/include/asm-v850/hardirq.h b/include/asm-v850/hardirq.h
--- a/include/asm-v850/hardirq.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-v850/hardirq.h	2004-12-24 13:36:18 -08:00
@@ -13,28 +13,7 @@
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * HARDIRQ_MASK: 0x0000ff00
- * SOFTIRQ_MASK: 0x00ff0000
- */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
 #define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
 /*
  * The hardirq mask has to be large enough to have
diff -Nru a/include/asm-v850/io.h b/include/asm-v850/io.h
--- a/include/asm-v850/io.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-v850/io.h	2004-12-24 13:36:18 -08:00
@@ -1,8 +1,8 @@
 /*
  * include/asm-v850/io.h -- Misc I/O operations
  *
- *  Copyright (C) 2001,02,03  NEC Electronics Corporation
- *  Copyright (C) 2001,02,03  Miles Bader <miles@gnu.org>
+ *  Copyright (C) 2001,02,03,04  NEC Electronics Corporation
+ *  Copyright (C) 2001,02,03,04  Miles Bader <miles@gnu.org>
  *
  * 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
@@ -102,6 +102,8 @@
 #define ioremap_writethrough(physaddr, size)	(physaddr)
 #define ioremap_fullcache(physaddr, size)	(physaddr)
 
+#define mmiowb()
+
 #define page_to_phys(page)      ((page - mem_map) << PAGE_SHIFT)
 #if 0
 /* This is really stupid; don't define it.  */
@@ -113,5 +115,8 @@
 #define mm_vtop(addr)		((unsigned long)__virt_to_phys (addr))
 #define phys_to_virt(addr)	((void *)__phys_to_virt (addr))
 #define virt_to_phys(addr)	((unsigned long)__virt_to_phys (addr))
+
+#define memcpy_fromio(dst, src, len) memcpy (dst, (void *)src, len)
+#define memcpy_toio(dst, src, len) memcpy ((void *)dst, src, len)
 
 #endif /* __V850_IO_H__ */
diff -Nru a/include/asm-v850/posix_types.h b/include/asm-v850/posix_types.h
--- a/include/asm-v850/posix_types.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-v850/posix_types.h	2004-12-24 13:37:43 -08:00
@@ -54,7 +54,9 @@
 
 #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
 
-#include <asm/bitops.h>
+/* We used to include <asm/bitops.h> here, which seems the right thing, but
+   it caused nasty include-file definition order problems.  Removing the
+   include seems to work, so fingers crossed...  */
 
 #undef	__FD_SET
 #define __FD_SET(fd, fd_set) \
diff -Nru a/include/asm-v850/timex.h b/include/asm-v850/timex.h
--- a/include/asm-v850/timex.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-v850/timex.h	2004-12-24 13:37:19 -08:00
@@ -7,10 +7,6 @@
 #define __V850_TIMEX_H__
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 typedef unsigned long cycles_t;
 
diff -Nru a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h
--- a/include/asm-x86_64/acpi.h	2004-12-24 13:37:01 -08:00
+++ b/include/asm-x86_64/acpi.h	2004-12-24 13:37:01 -08:00
@@ -166,6 +166,8 @@
 
 extern u8 x86_acpiid_to_apicid[];
 
+extern int acpi_skip_timer_override;
+
 #endif /*__KERNEL__*/
 
 #endif /*_ASM_ACPI_H*/
diff -Nru a/include/asm-x86_64/apic.h b/include/asm-x86_64/apic.h
--- a/include/asm-x86_64/apic.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-x86_64/apic.h	2004-12-24 13:37:19 -08:00
@@ -97,6 +97,7 @@
 extern int APIC_init_uniprocessor (void);
 extern void disable_APIC_timer(void);
 extern void enable_APIC_timer(void);
+extern void clustered_apic_check(void);
 
 extern int check_nmi_watchdog(void);
 extern void nmi_watchdog_default(void);
@@ -111,7 +112,6 @@
 
 #endif /* CONFIG_X86_LOCAL_APIC */
 
-#define clustered_apic_mode 0
 #define esr_disable 0
 extern unsigned boot_cpu_id;
 
diff -Nru a/include/asm-x86_64/apicdef.h b/include/asm-x86_64/apicdef.h
--- a/include/asm-x86_64/apicdef.h	2004-12-24 13:36:31 -08:00
+++ b/include/asm-x86_64/apicdef.h	2004-12-24 13:36:31 -08:00
@@ -11,27 +11,29 @@
 #define		APIC_DEFAULT_PHYS_BASE	0xfee00000
  
 #define		APIC_ID		0x20
-#define			APIC_ID_MASK		(0x0F<<24)
-#define			GET_APIC_ID(x)		(((x)>>24)&0x0F)
+#define			APIC_ID_MASK		(0xFFu<<24)
+#define			GET_APIC_ID(x)		(((x)>>24)&0xFFu)
 #define		APIC_LVR	0x30
 #define			APIC_LVR_MASK		0xFF00FF
-#define			GET_APIC_VERSION(x)	((x)&0xFF)
-#define			GET_APIC_MAXLVT(x)	(((x)>>16)&0xFF)
-#define			APIC_INTEGRATED(x)	((x)&0xF0)
+#define			GET_APIC_VERSION(x)	((x)&0xFFu)
+#define			GET_APIC_MAXLVT(x)	(((x)>>16)&0xFFu)
+#define			APIC_INTEGRATED(x)	((x)&0xF0u)
 #define		APIC_TASKPRI	0x80
-#define			APIC_TPRI_MASK		0xFF
+#define			APIC_TPRI_MASK		0xFFu
 #define		APIC_ARBPRI	0x90
-#define			APIC_ARBPRI_MASK	0xFF
+#define			APIC_ARBPRI_MASK	0xFFu
 #define		APIC_PROCPRI	0xA0
 #define		APIC_EOI	0xB0
 #define			APIC_EIO_ACK		0x0		/* Write this to the EOI register */
 #define		APIC_RRR	0xC0
 #define		APIC_LDR	0xD0
-#define			APIC_LDR_MASK		(0xFF<<24)
-#define			GET_APIC_LOGICAL_ID(x)	(((x)>>24)&0xFF)
+#define			APIC_LDR_MASK		(0xFFu<<24)
+#define			GET_APIC_LOGICAL_ID(x)	(((x)>>24)&0xFFu)
 #define			SET_APIC_LOGICAL_ID(x)	(((x)<<24))
-#define			APIC_ALL_CPUS		0xFF
+#define			APIC_ALL_CPUS		0xFFu
 #define		APIC_DFR	0xE0
+#define			APIC_DFR_CLUSTER		0x0FFFFFFFul
+#define			APIC_DFR_FLAT			0xFFFFFFFFul
 #define		APIC_SPIV	0xF0
 #define			APIC_SPIV_FOCUS_DISABLED	(1<<9)
 #define			APIC_SPIV_APIC_ENABLED		(1<<8)
@@ -58,6 +60,7 @@
 #define			APIC_INT_ASSERT		0x04000
 #define			APIC_ICR_BUSY		0x01000
 #define			APIC_DEST_LOGICAL	0x00800
+#define			APIC_DEST_PHYSICAL	0x00000
 #define			APIC_DM_FIXED		0x00000
 #define			APIC_DM_LOWEST		0x00100
 #define			APIC_DM_SMI		0x00200
@@ -86,6 +89,7 @@
 #define			APIC_LVT_REMOTE_IRR		(1<<14)
 #define			APIC_INPUT_POLARITY		(1<<13)
 #define			APIC_SEND_PENDING		(1<<12)
+#define			APIC_MODE_MASK			0x700
 #define			GET_APIC_DELIVERY_MODE(x)	(((x)>>8)&0x7)
 #define			SET_APIC_DELIVERY_MODE(x,y)	(((x)&~0x700)|((y)<<8))
 #define				APIC_MODE_FIXED		0x0
@@ -109,6 +113,18 @@
 #define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
 
 #define MAX_IO_APICS 32
+
+/*
+ * All x86-64 systems are xAPIC compatible.
+ * In the following, "apicid" is a physical APIC ID.
+ */
+#define XAPIC_DEST_CPUS_SHIFT	4
+#define XAPIC_DEST_CPUS_MASK	((1u << XAPIC_DEST_CPUS_SHIFT) - 1)
+#define XAPIC_DEST_CLUSTER_MASK	(XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT)
+#define APIC_CLUSTER(apicid)	((apicid) & XAPIC_DEST_CLUSTER_MASK)
+#define APIC_CLUSTERID(apicid)	(APIC_CLUSTER(apicid) >> XAPIC_DEST_CPUS_SHIFT)
+#define APIC_CPUID(apicid)	((apicid) & XAPIC_DEST_CPUS_MASK)
+#define NUM_APIC_CLUSTERS	((BAD_APICID + 1) >> XAPIC_DEST_CPUS_SHIFT)
 
 /*
  * the local APIC register structure, memory mapped. Not terribly well
diff -Nru a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h
--- a/include/asm-x86_64/atomic.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-x86_64/atomic.h	2004-12-24 13:37:29 -08:00
@@ -338,6 +338,31 @@
 	return c;
 }
 
+/**
+ * atomic_add_return - add and return
+ * @v: pointer of type atomic_t
+ * @i: integer value to add
+ *
+ * Atomically adds @i to @v and returns @i + @v
+ */
+static __inline__ int atomic_add_return(int i, atomic_t *v)
+{
+	int __i = i;
+	__asm__ __volatile__(
+		LOCK "xaddl %0, %1;"
+		:"=r"(i)
+		:"m"(v->counter), "0"(i));
+	return i + __i;
+}
+
+static __inline__ int atomic_sub_return(int i, atomic_t *v)
+{
+	return atomic_add_return(-i,v);
+}
+
+#define atomic_inc_return(v)  (atomic_add_return(1,v))
+#define atomic_dec_return(v)  (atomic_sub_return(1,v))
+
 /* These are x86-specific, used by some header files */
 #define atomic_clear_mask(mask, addr) \
 __asm__ __volatile__(LOCK "andl %0,%1" \
diff -Nru a/include/asm-x86_64/bootsetup.h b/include/asm-x86_64/bootsetup.h
--- a/include/asm-x86_64/bootsetup.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-x86_64/bootsetup.h	2004-12-24 13:37:18 -08:00
@@ -25,7 +25,7 @@
 #define KERNEL_START (*(unsigned int *) (PARAM+0x214))
 #define INITRD_START (*(unsigned int *) (PARAM+0x218))
 #define INITRD_SIZE (*(unsigned int *) (PARAM+0x21c))
-#define EDID_INFO (*(struct edid_info *) (PARAM+0x440))
+#define EDID_INFO (*(struct edid_info *) (PARAM+0x140))
 #define EDD_NR     (*(unsigned char *) (PARAM+EDDNR))
 #define EDD_MBR_SIG_NR (*(unsigned char *) (PARAM+EDD_MBR_SIG_NR_BUF))
 #define EDD_MBR_SIGNATURE ((unsigned int *) (PARAM+EDD_MBR_SIG_BUF))
diff -Nru a/include/asm-x86_64/compat.h b/include/asm-x86_64/compat.h
--- a/include/asm-x86_64/compat.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-x86_64/compat.h	2004-12-24 13:37:03 -08:00
@@ -28,7 +28,7 @@
 typedef s32		compat_daddr_t;
 typedef u32		compat_caddr_t;
 typedef __kernel_fsid_t	compat_fsid_t;
-typedef u32		compat_timer_t;
+typedef s32		compat_timer_t;
 typedef s32		compat_key_t;
 
 typedef s32		compat_int_t;
diff -Nru a/include/asm-x86_64/cpufeature.h b/include/asm-x86_64/cpufeature.h
--- a/include/asm-x86_64/cpufeature.h	2004-12-24 13:36:55 -08:00
+++ b/include/asm-x86_64/cpufeature.h	2004-12-24 13:36:55 -08:00
@@ -45,6 +45,7 @@
 /* Don't duplicate feature flags which are redundant with Intel! */
 #define X86_FEATURE_SYSCALL	(1*32+11) /* SYSCALL/SYSRET */
 #define X86_FEATURE_MMXEXT	(1*32+22) /* AMD MMX extensions */
+#define X86_FEATURE_FXSR_OPT	(1*32+25) /* FXSR optimizations */
 #define X86_FEATURE_LM		(1*32+29) /* Long Mode (x86-64) */
 #define X86_FEATURE_3DNOWEXT	(1*32+30) /* AMD 3DNow! extensions */
 #define X86_FEATURE_3DNOW	(1*32+31) /* 3DNow! */
@@ -73,7 +74,8 @@
 #define X86_FEATURE_XTPR	(4*32+14) /* Send Task Priority Messages */
 
 /* More extended AMD flags: CPUID level 0x80000001, ecx, word 5 */
-#define X86_FEATURE_HTVALID	(5*32+ 0) /* HyperThreading valid, otherwise CMP */
+#define X86_FEATURE_LAHF_LM	(5*32+ 0) /* LAHF/SAHF in long mode */
+#define X86_FEATURE_HTVALID	(5*32+ 1) /* HyperThreading valid, otherwise CMP */
 
 #define cpu_has(c, bit)                test_bit(bit, (c)->x86_capability)
 #define boot_cpu_has(bit)      test_bit(bit, boot_cpu_data.x86_capability)
diff -Nru a/include/asm-x86_64/desc.h b/include/asm-x86_64/desc.h
--- a/include/asm-x86_64/desc.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-x86_64/desc.h	2004-12-24 13:37:43 -08:00
@@ -210,6 +210,8 @@
 	put_cpu();
 }
 
+extern struct desc_ptr idt_descr;
+
 #endif /* !__ASSEMBLY__ */
 
 #endif
diff -Nru a/include/asm-x86_64/elf.h b/include/asm-x86_64/elf.h
--- a/include/asm-x86_64/elf.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-x86_64/elf.h	2004-12-24 13:37:18 -08:00
@@ -143,6 +143,11 @@
 #ifdef __KERNEL__
 extern void set_personality_64bit(void);
 #define SET_PERSONALITY(ex, ibcs2) set_personality_64bit()
+/*
+ * An executable for which elf_read_implies_exec() returns TRUE will
+ * have the READ_IMPLIES_EXEC personality flag set automatically.
+ */
+#define elf_read_implies_exec(ex, have_pt_gnu_stack)	(!(have_pt_gnu_stack))
 	
 /*
  * An executable for which elf_read_implies_exec() returns TRUE will
diff -Nru a/include/asm-x86_64/genapic.h b/include/asm-x86_64/genapic.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-x86_64/genapic.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,35 @@
+#ifndef _ASM_GENAPIC_H
+#define _ASM_GENAPIC_H 1
+
+/*
+ * Copyright 2004 James Cleverdon, IBM.
+ * Subject to the GNU Public License, v.2
+ *
+ * Generic APIC sub-arch data struct.
+ *
+ * Hacked for x86-64 by James Cleverdon from i386 architecture code by
+ * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
+ * James Cleverdon.
+ */
+
+struct genapic {
+	char *name;
+	u32 int_delivery_mode;
+	u32 int_dest_mode;
+	u32 int_delivery_dest;	/* for quick IPIs */
+	int (*apic_id_registered)(void);
+	cpumask_t (*target_cpus)(void);
+	void (*init_apic_ldr)(void);
+	/* ipi */
+	void (*send_IPI_mask)(cpumask_t mask, int vector);
+	void (*send_IPI_allbutself)(int vector);
+	void (*send_IPI_all)(int vector);
+	/* */
+	unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
+	unsigned int (*phys_pkg_id)(int index_msb);
+};
+
+
+extern struct genapic *genapic;
+
+#endif
diff -Nru a/include/asm-x86_64/hardirq.h b/include/asm-x86_64/hardirq.h
--- a/include/asm-x86_64/hardirq.h	2004-12-24 13:36:30 -08:00
+++ b/include/asm-x86_64/hardirq.h	2004-12-24 13:36:30 -08:00
@@ -5,6 +5,7 @@
 #include <linux/threads.h>
 #include <linux/irq.h>
 #include <asm/pda.h>
+#include <asm/apic.h>
 
 #define __ARCH_IRQ_STAT 1
 
@@ -15,47 +16,24 @@
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
 /*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * HARDIRQ_MASK: 0x0000ff00
- * SOFTIRQ_MASK: 0x00ff0000
+ * 'what should we do if we get a hw irq event on an illegal vector'.
+ * each architecture has to answer this themselves.
  */
-
-#define PREEMPT_BITS	8
-#define SOFTIRQ_BITS	8
-#define HARDIRQ_BITS	8
-
-#define PREEMPT_SHIFT	0
-#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
-
-/*
- * The hardirq mask has to be large enough to have
- * space for potentially all IRQ sources in the system
- * nesting on a single CPU:
- */
-#if (1 << HARDIRQ_BITS) < NR_IRQS
-# error HARDIRQ_BITS is too low!
+static inline void ack_bad_irq(unsigned int irq)
+{
+#ifdef CONFIG_X86
+	printk("unexpected IRQ trap at vector %02x\n", irq);
+#ifdef CONFIG_X86_LOCAL_APIC
+	/*
+	 * Currently unexpected vectors happen only on SMP and APIC.
+	 * We _must_ ack these because every local APIC has only N
+	 * irq slots per priority level, and a 'hanging, unacked' IRQ
+	 * holds up an irq slot - in excessive cases (when multiple
+	 * unexpected vectors occur) that might lock up the APIC
+	 * completely.
+	 */
+	ack_APIC_irq();
 #endif
-
-#define nmi_enter()		(irq_enter())
-#define nmi_exit()		(preempt_count() -= HARDIRQ_OFFSET)
-
-#define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
-#define irq_exit()							\
-do {									\
-		preempt_count() -= IRQ_EXIT_OFFSET;			\
-		if (!in_interrupt() && softirq_pending(smp_processor_id())) \
-			do_softirq();					\
-		preempt_enable_no_resched();				\
-} while (0)
-
+#endif
+}
 #endif /* __ASM_HARDIRQ_H */
diff -Nru a/include/asm-x86_64/hpet.h b/include/asm-x86_64/hpet.h
--- a/include/asm-x86_64/hpet.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-x86_64/hpet.h	2004-12-24 13:37:19 -08:00
@@ -28,12 +28,15 @@
 #define HPET_ID_LEGSUP	0x00008000
 #define HPET_ID_NUMBER	0x00001f00
 #define HPET_ID_REV	0x000000ff
+#define	HPET_ID_NUMBER_SHIFT	8
 
 #define HPET_ID_VENDOR_SHIFT	16
 #define HPET_ID_VENDOR_8086	0x8086
 
 #define HPET_CFG_ENABLE	0x001
 #define HPET_CFG_LEGACY	0x002
+#define	HPET_LEGACY_8254	2
+#define	HPET_LEGACY_RTC		8
 
 #define HPET_TN_ENABLE		0x004
 #define HPET_TN_PERIODIC	0x008
@@ -43,6 +46,7 @@
 
 extern int is_hpet_enabled(void);
 extern int hpet_rtc_timer_init(void);
+extern int oem_force_hpet_timer(void);
 
 #ifdef CONFIG_HPET_EMULATE_RTC
 extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
diff -Nru a/include/asm-x86_64/hw_irq.h b/include/asm-x86_64/hw_irq.h
--- a/include/asm-x86_64/hw_irq.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-x86_64/hw_irq.h	2004-12-24 13:37:29 -08:00
@@ -130,7 +130,7 @@
 	"push $" #nr "-256 ; " \
 	"jmp common_interrupt");
 
-#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP)
+#if defined(CONFIG_X86_IO_APIC)
 static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {
 	if (IO_APIC_IRQ(i))
 		send_IPI_self(IO_APIC_VECTOR(i));
diff -Nru a/include/asm-x86_64/io.h b/include/asm-x86_64/io.h
--- a/include/asm-x86_64/io.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-x86_64/io.h	2004-12-24 13:36:48 -08:00
@@ -135,6 +135,8 @@
 #define page_to_phys(page)	((page - mem_map) << PAGE_SHIFT)
 #endif
 
+#include <asm-generic/iomap.h>
+
 extern void __iomem *__ioremap(unsigned long offset, unsigned long size, unsigned long flags);
 
 extern inline void __iomem * ioremap (unsigned long offset, unsigned long size)
@@ -148,7 +150,7 @@
  * or read caching is not desirable:
  */
 extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
-extern void iounmap(void __iomem *addr);
+extern void iounmap(volatile void __iomem *addr);
 
 /*
  * ISA I/O bus memory addresses are 1:1 with the physical address.
@@ -173,10 +175,26 @@
  * memory location directly.
  */
 
-#define readb(addr) (*(__force volatile __u8 *) (__u8 __iomem *)(addr))
-#define readw(addr) (*(__force volatile __u16 *) (__u16 __iomem *)(addr))
-#define readl(addr) (*(__force volatile __u32 *) (__u32 __iomem *)(addr))
-#define readq(addr) (*(__force volatile __u64 *) (__u64 __iomem *)(addr))
+static inline __u8 __readb(volatile void __iomem *addr)
+{
+	return *(__force volatile __u8 *)addr;
+}
+static inline __u16 __readw(volatile void __iomem *addr)
+{
+	return *(__force volatile __u16 *)addr;
+}
+static inline __u32 __readl(volatile void __iomem *addr)
+{
+	return *(__force volatile __u32 *)addr;
+}
+static inline __u64 __readq(volatile void __iomem *addr)
+{
+	return *(__force volatile __u64 *)addr;
+}
+#define readb(x) __readb(x)
+#define readw(x) __readw(x)
+#define readl(x) __readl(x)
+#define readq(x) __readq(x)
 #define readb_relaxed(a) readb(a)
 #define readw_relaxed(a) readw(a)
 #define readl_relaxed(a) readl(a)
@@ -186,8 +204,10 @@
 #define __raw_readl readl
 #define __raw_readq readq
 
+#define mmiowb()
+
 #ifdef CONFIG_UNORDERED_IO
-static inline void __writel(__u32 val, void __iomem *addr)
+static inline void __writel(__u32 val, volatile void __iomem *addr)
 {
 	volatile __u32 __iomem *target = addr;
 	asm volatile("movnti %1,%0"
@@ -195,21 +215,35 @@
 		     : "r" (val) : "memory");
 }
 
-static inline void __writeq(__u64 val, void __iomem *addr)
+static inline void __writeq(__u64 val, volatile void __iomem *addr)
 {
-	volatile __u64 *target = addr;
+	volatile __u64 __iomem *target = addr;
 	asm volatile("movnti %1,%0"
 		     : "=m" (*target)
 		     : "r" (val) : "memory");
 }
-#define writeq(val,addr) __writeq((val),(void __iomem *)(addr))
-#define writel(val,addr) __writel((val),(void __iomem *)(addr))
 #else
-#define writel(b,addr) (*(__force volatile __u32 *)(__u32 __iomem *)(addr) = (b))
-#define writeq(b,addr) (*(__force volatile __u64 *)(__u64 __iomem *)(addr) = (b))
+static inline void __writel(__u32 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u32 *)addr = b;
+}
+static inline void __writeq(__u64 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u64 *)addr = b;
+}
 #endif
-#define writeb(b,addr) (*(__force volatile __u8 *)(__u8 __iomem *)(addr) = (b))
-#define writew(b,addr) (*(__force volatile __u16 *)(__u16 __iomem *)(addr) = (b))
+static inline void __writeb(__u8 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u8 *)addr = b;
+}
+static inline void __writew(__u16 b, volatile void __iomem *addr)
+{
+	*(__force volatile __u16 *)addr = b;
+}
+#define writeq(val,addr) __writeq((val),(addr))
+#define writel(val,addr) __writel((val),(addr))
+#define writew(val,addr) __writew((val),(addr))
+#define writeb(val,addr) __writeb((val),(addr))
 #define __raw_writeb writeb
 #define __raw_writew writew
 #define __raw_writel writel
@@ -218,11 +252,18 @@
 void *__memcpy_fromio(void*,unsigned long,unsigned);
 void *__memcpy_toio(unsigned long,const void*,unsigned);
 
-#define memcpy_fromio(to,from,len) \
-  __memcpy_fromio((to),(unsigned long)(void __iomem *)(from),(len))
-#define memcpy_toio(to,from,len) \
-  __memcpy_toio((unsigned long)(void __iomem *)(to),(from),(len))
-#define memset_io(a,b,c)	memset((__force void *)(void __iomem *)(a),(b),(c))
+static inline void *memcpy_fromio(void *to, volatile void __iomem *from, unsigned len)
+{
+	return __memcpy_fromio(to,(unsigned long)from,len);
+}
+static inline void *memcpy_toio(volatile void __iomem *to, const void *from, unsigned len)
+{
+	return __memcpy_toio((unsigned long)to,from,len);
+}
+static inline void *memset_io(volatile void __iomem *a, int b, size_t c)
+{
+	return memset((__force void *)a,b,c);
+}
 
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
@@ -263,7 +304,7 @@
  *	Returns 1 on a match.
  */
  
-static inline int check_signature(unsigned long io_addr,
+static inline int check_signature(void __iomem *io_addr,
 	const unsigned char *signature, int length)
 {
 	int retval = 0;
@@ -278,38 +319,6 @@
 out:
 	return retval;
 }
-
-#ifndef __i386__
-/**
- *	isa_check_signature		-	find BIOS signatures
- *	@io_addr: mmio address to check 
- *	@signature:  signature block
- *	@length: length of signature
- *
- *	Perform a signature comparison with the ISA mmio address io_addr.
- *	Returns 1 on a match.
- *
- *	This function is deprecated. New drivers should use ioremap and
- *	check_signature.
- */
- 
-
-static inline int isa_check_signature(unsigned long io_addr,
-	const unsigned char *signature, int length)
-{
-	int retval = 0;
-	do {
-		if (isa_readb(io_addr) != *signature)
-			goto out;
-		io_addr++;
-		signature++;
-		length--;
-	} while (length);
-	retval = 1;
-out:
-	return retval;
-}
-#endif
 
 /* Nothing to do */
 
diff -Nru a/include/asm-x86_64/io_apic.h b/include/asm-x86_64/io_apic.h
--- a/include/asm-x86_64/io_apic.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-x86_64/io_apic.h	2004-12-24 13:36:18 -08:00
@@ -199,7 +199,7 @@
  * If we use the IO-APIC for IRQ routing, disable automatic
  * assignment of PCI IRQ's.
  */
-#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup)
+#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
 
 #ifdef CONFIG_ACPI_BOOT
 extern int io_apic_get_unique_id (int ioapic, int apic_id);
diff -Nru a/include/asm-x86_64/ipi.h b/include/asm-x86_64/ipi.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-x86_64/ipi.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,113 @@
+#ifndef __ASM_IPI_H
+#define __ASM_IPI_H
+
+/*
+ * Copyright 2004 James Cleverdon, IBM.
+ * Subject to the GNU Public License, v.2
+ *
+ * Generic APIC InterProcessor Interrupt code.
+ *
+ * Moved to include file by James Cleverdon from
+ * arch/x86-64/kernel/smp.c
+ *
+ * Copyrights from kernel/smp.c:
+ *
+ * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
+ * (c) 1998-99, 2000 Ingo Molnar <mingo@redhat.com>
+ * (c) 2002,2003 Andi Kleen, SuSE Labs.
+ * Subject to the GNU Public License, v.2
+ */
+
+#include <asm/fixmap.h>
+#include <asm/hw_irq.h>
+#include <asm/apicdef.h>
+#include <asm/genapic.h>
+
+/*
+ * the following functions deal with sending IPIs between CPUs.
+ *
+ * We use 'broadcast', CPU->CPU IPIs and self-IPIs too.
+ */
+
+static inline unsigned int __prepare_ICR (unsigned int shortcut, int vector, unsigned int dest)
+{
+	unsigned int icr =  APIC_DM_FIXED | shortcut | vector | dest;
+	if (vector == KDB_VECTOR)
+		icr = (icr & (~APIC_VECTOR_MASK)) | APIC_DM_NMI;
+	return icr;
+}
+
+static inline int __prepare_ICR2 (unsigned int mask)
+{
+	return SET_APIC_DEST_FIELD(mask);
+}
+
+static inline void __send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest)
+{
+	/*
+	 * Subtle. In the case of the 'never do double writes' workaround
+	 * we have to lock out interrupts to be safe.  As we don't care
+	 * of the value read we use an atomic rmw access to avoid costly
+	 * cli/sti.  Otherwise we use an even cheaper single atomic write
+	 * to the APIC.
+	 */
+	unsigned int cfg;
+
+	/*
+	 * Wait for idle.
+	 */
+	apic_wait_icr_idle();
+
+	/*
+	 * No need to touch the target chip field
+	 */
+	cfg = __prepare_ICR(shortcut, vector, dest);
+
+	/*
+	 * Send the IPI. The write to APIC_ICR fires this off.
+	 */
+	apic_write_around(APIC_ICR, cfg);
+}
+
+
+static inline void send_IPI_mask_sequence(cpumask_t mask, int vector)
+{
+	unsigned long cfg, flags;
+	unsigned long query_cpu;
+
+	/*
+	 * Hack. The clustered APIC addressing mode doesn't allow us to send
+	 * to an arbitrary mask, so I do a unicast to each CPU instead.
+	 * - mbligh
+	 */
+	local_irq_save(flags);
+
+	for (query_cpu = 0; query_cpu < NR_CPUS; ++query_cpu) {
+		if (cpu_isset(query_cpu, mask)) {
+
+			/*
+			 * Wait for idle.
+			 */
+			apic_wait_icr_idle();
+
+			/*
+			 * prepare target chip field
+			 */
+			cfg = __prepare_ICR2(x86_cpu_to_apicid[query_cpu]);
+			apic_write_around(APIC_ICR2, cfg);
+
+			/*
+			 * program the ICR
+			 */
+			cfg = __prepare_ICR(0, vector, APIC_DEST_PHYSICAL);
+
+			/*
+			 * Send the IPI. The write to APIC_ICR fires this off.
+			 */
+			apic_write_around(APIC_ICR, cfg);
+		}
+	}
+	local_irq_restore(flags);
+}
+
+#endif /* __ASM_IPI_H */
diff -Nru a/include/asm-x86_64/irq.h b/include/asm-x86_64/irq.h
--- a/include/asm-x86_64/irq.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-x86_64/irq.h	2004-12-24 13:36:16 -08:00
@@ -36,18 +36,13 @@
 #define NR_IRQ_VECTORS NR_IRQS
 #else
 #define NR_IRQS 224
-#define NR_IRQ_VECTORS NR_IRQS
+#define NR_IRQ_VECTORS 1024
 #endif
 
 static __inline__ int irq_canonicalize(int irq)
 {
 	return ((irq == 2) ? 9 : irq);
 }
-
-extern void disable_irq(unsigned int);
-extern void disable_irq_nosync(unsigned int);
-extern void enable_irq(unsigned int);
-extern int can_request_irq(unsigned int, unsigned long flags);
 
 #ifdef CONFIG_X86_LOCAL_APIC
 #define ARCH_HAS_NMI_WATCHDOG		/* See include/linux/nmi.h */
diff -Nru a/include/asm-x86_64/kdebug.h b/include/asm-x86_64/kdebug.h
--- a/include/asm-x86_64/kdebug.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-x86_64/kdebug.h	2004-12-24 13:36:18 -08:00
@@ -16,8 +16,8 @@
 /* Note - you should never unregister because that can race with NMIs.
    If you really want to do it first unregister - then synchronize_kernel - then free. 
   */
+int register_die_notifier(struct notifier_block *nb);
 extern struct notifier_block *die_chain;
-
 /* Grossly misnamed. */
 enum die_val { 
 	DIE_OOPS = 1,
@@ -32,6 +32,7 @@
 	DIE_GPF,
 	DIE_CALL,
 	DIE_NMI_IPI,
+	DIE_PAGE_FAULT,
 }; 
 	
 static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,long err,int trap, int sig)
diff -Nru a/include/asm-x86_64/kprobes.h b/include/asm-x86_64/kprobes.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-x86_64/kprobes.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,61 @@
+#ifndef _ASM_KPROBES_H
+#define _ASM_KPROBES_H
+/*
+ *  Kernel Probes (KProbes)
+ *  include/asm-x86_64/kprobes.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2002, 2004
+ *
+ * 2004-Oct	Prasanna S Panchamukhi <prasanna@in.ibm.com> and Jim Keniston
+ *		kenistoj@us.ibm.com adopted from i386.
+ */
+#include <linux/types.h>
+#include <linux/ptrace.h>
+
+struct pt_regs;
+
+typedef u8 kprobe_opcode_t;
+#define BREAKPOINT_INSTRUCTION	0xcc
+#define MAX_INSN_SIZE 15
+#define MAX_STACK_SIZE 64
+#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
+	(((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
+	? (MAX_STACK_SIZE) \
+	: (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
+
+/* Architecture specific copy of original instruction*/
+struct arch_specific_insn {
+	/* copy of the original instruction */
+	kprobe_opcode_t *insn;
+};
+
+/* trap3/1 are intr gates for kprobes.  So, restore the status of IF,
+ * if necessary, before executing the original int3/1 (trap) handler.
+ */
+static inline void restore_interrupts(struct pt_regs *regs)
+{
+	if (regs->eflags & IF_MASK)
+		local_irq_enable();
+}
+
+extern int post_kprobe_handler(struct pt_regs *regs);
+extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
+extern int kprobe_handler(struct pt_regs *regs);
+
+extern int kprobe_exceptions_notify(struct notifier_block *self,
+				    unsigned long val, void *data);
+#endif				/* _ASM_KPROBES_H */
diff -Nru a/include/asm-x86_64/mach_apic.h b/include/asm-x86_64/mach_apic.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/asm-x86_64/mach_apic.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,29 @@
+#ifndef __ASM_MACH_APIC_H
+#define __ASM_MACH_APIC_H
+
+/*
+ * Copyright 2004 James Cleverdon, IBM.
+ * Subject to the GNU Public License, v.2
+ *
+ * Generic APIC sub-arch defines.
+ *
+ * Hacked for x86-64 by James Cleverdon from i386 architecture code by
+ * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
+ * James Cleverdon.
+ */
+
+#include <asm/genapic.h>
+
+#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
+#define INT_DEST_MODE (genapic->int_dest_mode)
+#define INT_DELIVERY_DEST (genapic->int_delivery_dest)
+#define TARGET_CPUS	  (genapic->target_cpus())
+#define apic_id_registered (genapic->apic_id_registered)
+#define init_apic_ldr (genapic->init_apic_ldr)
+#define send_IPI_mask (genapic->send_IPI_mask)
+#define send_IPI_allbutself (genapic->send_IPI_allbutself)
+#define send_IPI_all (genapic->send_IPI_all)
+#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
+#define phys_pkg_id	(genapic->phys_pkg_id)
+
+#endif /* __ASM_MACH_APIC_H */
diff -Nru a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h
--- a/include/asm-x86_64/mpspec.h	2004-12-24 13:36:48 -08:00
+++ b/include/asm-x86_64/mpspec.h	2004-12-24 13:36:48 -08:00
@@ -14,9 +14,9 @@
 #define SMP_MAGIC_IDENT	(('_'<<24)|('P'<<16)|('M'<<8)|'_')
 
 /*
- * a maximum of 16 APICs with the current APIC ID architecture.
+ * A maximum of 255 APICs with the current APIC ID architecture.
  */
-#define MAX_APICS 16
+#define MAX_APICS 128
 
 struct intel_mp_floating
 {
@@ -188,7 +188,7 @@
 extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base);
 extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi);
 extern void mp_config_acpi_legacy_irqs (void);
-extern void mp_register_gsi (u32 gsi, int edge_level, int active_high_low);
+extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low);
 #endif /*CONFIG_X86_IO_APIC*/
 #endif
 
diff -Nru a/include/asm-x86_64/msi.h b/include/asm-x86_64/msi.h
--- a/include/asm-x86_64/msi.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-x86_64/msi.h	2004-12-24 13:37:18 -08:00
@@ -7,6 +7,7 @@
 #define ASM_MSI_H
 
 #include <asm/desc.h>
+#include <asm/mach_apic.h>
 #include <asm/smp.h>
 
 #define LAST_DEVICE_VECTOR		232
diff -Nru a/include/asm-x86_64/nmi.h b/include/asm-x86_64/nmi.h
--- a/include/asm-x86_64/nmi.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-x86_64/nmi.h	2004-12-24 13:36:18 -08:00
@@ -47,5 +47,11 @@
 #endif /* CONFIG_PM */
  
 extern void default_do_nmi(struct pt_regs *);
+extern void die_nmi(char *str, struct pt_regs *regs);
+
+#define get_nmi_reason() inb(0x61)
+
+extern int panic_on_timeout;
+extern int unknown_nmi_panic;
  
 #endif /* ASM_NMI_H */
diff -Nru a/include/asm-x86_64/numa.h b/include/asm-x86_64/numa.h
--- a/include/asm-x86_64/numa.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-x86_64/numa.h	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,8 @@
 #ifndef _ASM_X8664_NUMA_H 
 #define _ASM_X8664_NUMA_H 1
 
+#include <linux/nodemask.h>
+
 #define MAXNODE 8 
 #define NODEMASK 0xff
 
diff -Nru a/include/asm-x86_64/page.h b/include/asm-x86_64/page.h
--- a/include/asm-x86_64/page.h	2004-12-24 13:36:17 -08:00
+++ b/include/asm-x86_64/page.h	2004-12-24 13:36:17 -08:00
@@ -130,18 +130,10 @@
 #define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
 
-#define __VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
-				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
-#define __VM_STACK_FLAGS 	(VM_GROWSDOWN | VM_READ | VM_WRITE | VM_EXEC | \
-                                VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
-
 #define VM_DATA_DEFAULT_FLAGS \
-	(test_thread_flag(TIF_IA32) ? vm_data_default_flags32 : \
-	  vm_data_default_flags) 
+	(((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
+	 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
-#define VM_STACK_DEFAULT_FLAGS \
-	(test_thread_flag(TIF_IA32) ? vm_stack_flags32 : vm_stack_flags) 
-	
 #define CONFIG_ARCH_GATE_AREA 1	
 
 #ifndef __ASSEMBLY__
diff -Nru a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
--- a/include/asm-x86_64/pgtable.h	2004-12-24 13:37:03 -08:00
+++ b/include/asm-x86_64/pgtable.h	2004-12-24 13:37:03 -08:00
@@ -421,7 +421,8 @@
 
 extern int kern_addr_valid(unsigned long addr); 
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
+		remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
 
 #define HAVE_ARCH_UNMAPPED_AREA
 
diff -Nru a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
--- a/include/asm-x86_64/processor.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-x86_64/processor.h	2004-12-24 13:37:29 -08:00
@@ -90,6 +90,7 @@
 
 extern void identify_cpu(struct cpuinfo_x86 *);
 extern void print_cpu_info(struct cpuinfo_x86 *);
+extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
 extern void dodgy_tsc(void);
 
 /*
@@ -459,5 +460,7 @@
 })
 
 #define cache_line_size() (boot_cpu_data.x86_cache_alignment)
+
+extern unsigned long boot_option_idle_override;
 
 #endif /* __ASM_X86_64_PROCESSOR_H */
diff -Nru a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
--- a/include/asm-x86_64/proto.h	2004-12-24 13:37:19 -08:00
+++ b/include/asm-x86_64/proto.h	2004-12-24 13:37:19 -08:00
@@ -12,6 +12,8 @@
 extern void start_kernel(void);
 extern void pda_init(int); 
 
+extern void early_idt_handler(void);
+
 extern void mcheck_init(struct cpuinfo_x86 *c);
 extern void init_memory_mapping(void);
 
diff -Nru a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
--- a/include/asm-x86_64/smp.h	2004-12-24 13:36:16 -08:00
+++ b/include/asm-x86_64/smp.h	2004-12-24 13:36:16 -08:00
@@ -48,7 +48,7 @@
 extern void zap_low_mappings(void);
 void smp_stop_cpu(void);
 extern cpumask_t cpu_sibling_map[NR_CPUS];
-extern char phys_proc_id[NR_CPUS];
+extern u8 phys_proc_id[NR_CPUS];
 
 #define SMP_TRAMPOLINE_BASE 0x6000
 
@@ -74,14 +74,29 @@
 	return GET_APIC_ID(*(unsigned int *)(APIC_BASE+APIC_ID));
 }
 
+#define safe_smp_processor_id() (disable_apic ? 0 : x86_apicid_to_cpu(hard_smp_processor_id()))
+
+#endif /* !ASSEMBLY */
+
+#define NO_PROC_ID		0xFF		/* No processor magic marker */
+
+#endif
+
+#ifndef ASSEMBLY
 /*
  * Some lowlevel functions might want to know about
  * the real APIC ID <-> CPU # mapping.
- * AK: why is this volatile?
  */
-extern volatile char x86_cpu_to_apicid[NR_CPUS];
+extern u8 x86_cpu_to_apicid[NR_CPUS];	/* physical ID */
+extern u8 x86_cpu_to_log_apicid[NR_CPUS];
+extern u8 bios_cpu_apicid[];
+
+static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
+{
+	return cpus_addr(cpumask)[0];
+}
 
-static inline char x86_apicid_to_cpu(char apicid)
+static inline int x86_apicid_to_cpu(u8 apicid)
 {
 	int i;
 
@@ -89,13 +104,14 @@
 		if (x86_cpu_to_apicid[i] == apicid)
 			return i;
 
+	/* No entries in x86_cpu_to_apicid?  Either no MPS|ACPI,
+	 * or called too early.  Either way, we must be CPU 0. */
+      	if (x86_cpu_to_apicid[0] == BAD_APICID)
+		return 0;
+
 	return -1;
 }
 
-#define safe_smp_processor_id() (disable_apic ? 0 : x86_apicid_to_cpu(hard_smp_processor_id()))
-
-extern u8 bios_cpu_apicid[];
-
 static inline int cpu_present_to_apicid(int mps_cpu)
 {
 	if (mps_cpu < NR_CPUS)
@@ -105,23 +121,6 @@
 }
 
 #endif /* !ASSEMBLY */
-
-#define NO_PROC_ID		0xFF		/* No processor magic marker */
-
-#endif
-#define INT_DELIVERY_MODE 1     /* logical delivery */
-
-#ifndef ASSEMBLY
-#ifdef CONFIG_SMP
-#define TARGET_CPUS cpu_online_map
-#else
-#define TARGET_CPUS cpumask_of_cpu(0)
-#endif
-static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
-{
-	return cpus_addr(cpumask)[0];
-}
-#endif
 
 #ifndef CONFIG_SMP
 #define stack_smp_processor_id() 0
diff -Nru a/include/asm-x86_64/swiotlb.h b/include/asm-x86_64/swiotlb.h
--- a/include/asm-x86_64/swiotlb.h	2004-12-24 13:36:18 -08:00
+++ b/include/asm-x86_64/swiotlb.h	2004-12-24 13:36:18 -08:00
@@ -26,6 +26,10 @@
 extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
 			 int nents, int direction);
 extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr);
+extern void *swiotlb_alloc_coherent (struct device *hwdev, size_t size,
+				     dma_addr_t *dma_handle, int flags);
+extern void swiotlb_free_coherent (struct device *hwdev, size_t size,
+				   void *vaddr, dma_addr_t dma_handle);
 
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
diff -Nru a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
--- a/include/asm-x86_64/system.h	2004-12-24 13:37:18 -08:00
+++ b/include/asm-x86_64/system.h	2004-12-24 13:37:18 -08:00
@@ -123,7 +123,7 @@
  * If you use variable sized constraints like "m" or "g" in the 
  * replacement maake sure to pad to the worst case length.
  */
-#define alternative_input(oldinstr, newinstr, feature, input)		\
+#define alternative_input(oldinstr, newinstr, feature, input...)	\
 	asm volatile ("661:\n\t" oldinstr "\n662:\n"			\
 		      ".section .altinstructions,\"a\"\n"		\
 		      "  .align 8\n"					\
@@ -135,7 +135,7 @@
 		      ".previous\n"					\
 		      ".section .altinstr_replacement,\"ax\"\n"		\
 		      "663:\n\t" newinstr "\n664:\n"   /* replacement */ \
-		      ".previous" :: "i" (feature), input)
+		      ".previous" :: "i" (feature), ##input)
 
 /*
  * Clear and set 'TS' bit respectively
diff -Nru a/include/asm-x86_64/thread_info.h b/include/asm-x86_64/thread_info.h
--- a/include/asm-x86_64/thread_info.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-x86_64/thread_info.h	2004-12-24 13:37:02 -08:00
@@ -125,7 +125,7 @@
 /* work to do on any return to user space */
 #define _TIF_ALLWORK_MASK 0x0000FFFF	
 
-#define PREEMPT_ACTIVE     0x4000000
+#define PREEMPT_ACTIVE     0x10000000
 
 /*
  * Thread-synchronous status.
diff -Nru a/include/asm-x86_64/timex.h b/include/asm-x86_64/timex.h
--- a/include/asm-x86_64/timex.h	2004-12-24 13:36:59 -08:00
+++ b/include/asm-x86_64/timex.h	2004-12-24 13:36:59 -08:00
@@ -13,10 +13,6 @@
 #include <asm/hpet.h>
 
 #define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
-#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
-#define FINETUNE ((((((int)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
-	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
 typedef unsigned long long cycles_t;
 
diff -Nru a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
--- a/include/asm-x86_64/topology.h	2004-12-24 13:37:02 -08:00
+++ b/include/asm-x86_64/topology.h	2004-12-24 13:37:02 -08:00
@@ -32,7 +32,27 @@
 /* broken generic file uses #ifndef later on this */
 #define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus)
 
-#define NODE_BALANCE_RATE 30	/* CHECKME */ 
+#ifdef CONFIG_NUMA
+/* sched_domains SD_NODE_INIT for x86_64 machines */
+#define SD_NODE_INIT (struct sched_domain) {		\
+	.span			= CPU_MASK_NONE,	\
+	.parent			= NULL,			\
+	.groups			= NULL,			\
+	.min_interval		= 8,			\
+	.max_interval		= 32,			\
+	.busy_factor		= 32,			\
+	.imbalance_pct		= 125,			\
+	.cache_hot_time		= (10*1000),		\
+	.cache_nice_tries	= 1,			\
+	.per_cpu_gain		= 100,			\
+	.flags			= SD_LOAD_BALANCE	\
+				| SD_BALANCE_EXEC	\
+				| SD_WAKE_BALANCE,	\
+	.last_balance		= jiffies,		\
+	.balance_interval	= 1,			\
+	.nr_balance_failed	= 0,			\
+}
+#endif
 
 #endif
 
diff -Nru a/include/asm-x86_64/uaccess.h b/include/asm-x86_64/uaccess.h
--- a/include/asm-x86_64/uaccess.h	2004-12-24 13:37:43 -08:00
+++ b/include/asm-x86_64/uaccess.h	2004-12-24 13:37:43 -08:00
@@ -102,7 +102,7 @@
 
 /* Careful: we have to cast the result to the type of the pointer for sign reasons */
 #define get_user(x,ptr)							\
-({	long __val_gu;							\
+({	unsigned long __val_gu;						\
 	int __ret_gu; 							\
 	__chk_user_ptr(ptr);						\
 	switch(sizeof (*(ptr))) {					\
diff -Nru a/include/asm-x86_64/vsyscall.h b/include/asm-x86_64/vsyscall.h
--- a/include/asm-x86_64/vsyscall.h	2004-12-24 13:37:29 -08:00
+++ b/include/asm-x86_64/vsyscall.h	2004-12-24 13:37:29 -08:00
@@ -21,7 +21,7 @@
 #define __section_sys_tz __attribute__ ((unused, __section__ (".sys_tz"), aligned(16)))
 #define __section_sysctl_vsyscall __attribute__ ((unused, __section__ (".sysctl_vsyscall"), aligned(16)))
 #define __section_xtime __attribute__ ((unused, __section__ (".xtime"), aligned(16)))
-#define __section_xtime_lock __attribute__ ((unused, __section__ (".xtime_lock"), aligned(L1_CACHE_BYTES)))
+#define __section_xtime_lock __attribute__ ((unused, __section__ (".xtime_lock"), aligned(16)))
 
 #define VXTIME_TSC	1
 #define VXTIME_HPET	2
@@ -36,8 +36,8 @@
 	int mode;
 };
 
-#define hpet_readl(a)           readl(fix_to_virt(FIX_HPET_BASE) + a)
-#define hpet_writel(d,a)        writel(d, fix_to_virt(FIX_HPET_BASE) + a)
+#define hpet_readl(a)           readl((void *)fix_to_virt(FIX_HPET_BASE) + a)
+#define hpet_writel(d,a)        writel(d, (void *)fix_to_virt(FIX_HPET_BASE) + a)
 
 /* vsyscall space (readonly) */
 extern struct vxtime_data __vxtime;
diff -Nru a/include/linux/acpi.h b/include/linux/acpi.h
--- a/include/linux/acpi.h	2004-12-24 13:36:16 -08:00
+++ b/include/linux/acpi.h	2004-12-24 13:36:16 -08:00
@@ -439,6 +439,7 @@
 struct pci_dev;
 
 int acpi_pci_irq_enable (struct pci_dev *dev);
+void acpi_penalize_isa_irq(int irq);
 
 struct acpi_pci_driver {
 	struct acpi_pci_driver *next;
@@ -471,5 +472,31 @@
 }
 
 #endif /*!CONFIG_ACPI_INTERPRETER*/
+
+#define	ACPI_CSTATE_LIMIT_DEFINED	/* for driver builds */
+#ifdef	CONFIG_ACPI
+
+/*
+ * Set highest legal C-state
+ * 0: C0 okay, but not C1
+ * 1: C1 okay, but not C2
+ * 2: C2 okay, but not C3 etc.
+ */
+
+extern unsigned int max_cstate;
+
+static inline unsigned int acpi_get_cstate_limit(void)
+{
+	return max_cstate;
+}
+static inline void acpi_set_cstate_limit(unsigned int new_limit)
+{
+	max_cstate = new_limit;
+	return;
+}
+#else
+static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
+static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
+#endif
 
 #endif /*_LINUX_ACPI_H*/
diff -Nru a/include/linux/ata.h b/include/linux/ata.h
--- a/include/linux/ata.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/ata.h	2004-12-24 13:37:00 -08:00
@@ -24,6 +24,8 @@
 #ifndef __LINUX_ATA_H__
 #define __LINUX_ATA_H__
 
+#include <linux/types.h>
+
 /* defines only for the constants which don't work well as enums */
 #define ATA_DMA_BOUNDARY	0xffffUL
 #define ATA_DMA_MASK		0xffffffffULL
@@ -33,8 +35,6 @@
 	ATA_MAX_DEVICES		= 2,	/* per bus/port */
 	ATA_MAX_PRD		= 256,	/* we could make these 256/256 */
 	ATA_SECT_SIZE		= 512,
-	ATA_SECT_SIZE_MASK	= (ATA_SECT_SIZE - 1),
-	ATA_SECT_DWORDS		= ATA_SECT_SIZE / sizeof(u32),
 
 	ATA_ID_WORDS		= 256,
 	ATA_ID_PROD_OFS		= 27,
@@ -142,6 +142,10 @@
 	XFER_PIO_2		= 0x0A,
 	XFER_PIO_1		= 0x09,
 	XFER_PIO_0		= 0x08,
+	XFER_SW_DMA_2		= 0x12,
+	XFER_SW_DMA_1		= 0x11,
+	XFER_SW_DMA_0		= 0x10,
+	XFER_PIO_SLOW		= 0x00,
 
 	/* ATAPI stuff */
 	ATAPI_PKT_DMA		= (1 << 0),
@@ -217,24 +221,24 @@
 	u8			command;	/* IO operation */
 };
 
-#define ata_id_is_ata(dev)	(((dev)->id[0] & (1 << 15)) == 0)
-#define ata_id_rahead_enabled(dev) ((dev)->id[85] & (1 << 6))
-#define ata_id_wcache_enabled(dev) ((dev)->id[85] & (1 << 5))
-#define ata_id_has_flush(dev) ((dev)->id[83] & (1 << 12))
-#define ata_id_has_flush_ext(dev) ((dev)->id[83] & (1 << 13))
-#define ata_id_has_lba48(dev)	((dev)->id[83] & (1 << 10))
-#define ata_id_has_wcache(dev)	((dev)->id[82] & (1 << 5))
-#define ata_id_has_pm(dev)	((dev)->id[82] & (1 << 3))
-#define ata_id_has_lba(dev)	((dev)->id[49] & (1 << 9))
-#define ata_id_has_dma(dev)	((dev)->id[49] & (1 << 8))
-#define ata_id_removeable(dev)	((dev)->id[0] & (1 << 7))
-#define ata_id_u32(dev,n)	\
-	(((u32) (dev)->id[(n) + 1] << 16) | ((u32) (dev)->id[(n)]))
-#define ata_id_u64(dev,n)	\
-	( ((u64) dev->id[(n) + 3] << 48) |	\
-	  ((u64) dev->id[(n) + 2] << 32) |	\
-	  ((u64) dev->id[(n) + 1] << 16) |	\
-	  ((u64) dev->id[(n) + 0]) )
+#define ata_id_is_ata(id)	(((id)[0] & (1 << 15)) == 0)
+#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
+#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
+#define ata_id_has_flush(id) ((id)[83] & (1 << 12))
+#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13))
+#define ata_id_has_lba48(id)	((id)[83] & (1 << 10))
+#define ata_id_has_wcache(id)	((id)[82] & (1 << 5))
+#define ata_id_has_pm(id)	((id)[82] & (1 << 3))
+#define ata_id_has_lba(id)	((id)[49] & (1 << 9))
+#define ata_id_has_dma(id)	((id)[49] & (1 << 8))
+#define ata_id_removeable(id)	((id)[0] & (1 << 7))
+#define ata_id_u32(id,n)	\
+	(((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
+#define ata_id_u64(id,n)	\
+	( ((u64) (id)[(n) + 3] << 48) |	\
+	  ((u64) (id)[(n) + 2] << 32) |	\
+	  ((u64) (id)[(n) + 1] << 16) |	\
+	  ((u64) (id)[(n) + 0]) )
 
 static inline int atapi_cdb_len(u16 *dev_id)
 {
diff -Nru a/include/linux/atm.h b/include/linux/atm.h
--- a/include/linux/atm.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/atm.h	2004-12-24 13:37:18 -08:00
@@ -78,6 +78,9 @@
 			    /* Service Access Point */
 #define SO_ATMPVC	__SO_ENCODE(SOL_ATM,4,struct sockaddr_atmpvc)
 			    /* "PVC" address (also for SVCs); get only */
+#define SO_MULTIPOINT	__SO_ENCODE(SOL_ATM, 5, int)
+			    /* make this vc a p2mp */
+
 
 /*
  * Note @@@: since the socket layers don't really distinguish the control and
diff -Nru a/include/linux/atmdev.h b/include/linux/atmdev.h
--- a/include/linux/atmdev.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/atmdev.h	2004-12-24 13:37:18 -08:00
@@ -95,6 +95,10 @@
 					/* set backend handler */
 #define ATM_NEWBACKENDIF _IOW('a',ATMIOC_SPECIAL+3,atm_backend_t)
 					/* use backend to make new if */
+#define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
+ 					/* add party to p2mp call */
+#define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
+					/* drop party from p2mp call */
 
 /*
  * These are backend handkers that can be set via the ATM_SETBACKEND call
@@ -391,7 +395,6 @@
 void atm_dev_deregister(struct atm_dev *dev);
 void shutdown_atm_dev(struct atm_dev *dev);
 void vcc_insert_socket(struct sock *sk);
-void vcc_remove_socket(struct sock *sk);
 
 
 /*
diff -Nru a/include/linux/atmsvc.h b/include/linux/atmsvc.h
--- a/include/linux/atmsvc.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/atmsvc.h	2004-12-24 13:37:19 -08:00
@@ -14,9 +14,10 @@
 #define ATMSIGD_CTRL _IO('a',ATMIOC_SPECIAL)
 				/* become ATM signaling demon control socket */
 
-enum atmsvc_msg_type { as_catch_null,as_bind,as_connect,as_accept,as_reject,
-  as_listen,as_okay,as_error,as_indicate,as_close,as_itf_notify,
-  as_modify,as_identify,as_terminate };
+enum atmsvc_msg_type { as_catch_null, as_bind, as_connect, as_accept, as_reject,
+		       as_listen, as_okay, as_error, as_indicate, as_close,
+		       as_itf_notify, as_modify, as_identify, as_terminate,
+		       as_addparty, as_dropparty };
 
 struct atmsvc_msg {
 	enum atmsvc_msg_type type;
diff -Nru a/include/linux/bio.h b/include/linux/bio.h
--- a/include/linux/bio.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/bio.h	2004-12-24 13:37:18 -08:00
@@ -188,8 +188,15 @@
 
 #define __BVEC_END(bio)		bio_iovec_idx((bio), (bio)->bi_vcnt - 1)
 #define __BVEC_START(bio)	bio_iovec_idx((bio), (bio)->bi_idx)
+
+/*
+ * allow arch override, for eg virtualized architectures (put in asm/io.h)
+ */
+#ifndef BIOVEC_PHYS_MERGEABLE
 #define BIOVEC_PHYS_MERGEABLE(vec1, vec2)	\
 	((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
+#endif
+
 #define BIOVEC_VIRT_MERGEABLE(vec1, vec2)	\
 	((((bvec_to_phys((vec1)) + (vec1)->bv_len) | bvec_to_phys((vec2))) & (BIO_VMERGE_BOUNDARY - 1)) == 0)
 #define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \
diff -Nru a/include/linux/bitops.h b/include/linux/bitops.h
--- a/include/linux/bitops.h	2004-12-24 13:37:29 -08:00
+++ b/include/linux/bitops.h	2004-12-24 13:37:29 -08:00
@@ -42,7 +42,7 @@
  * fls: find last bit set.
  */
 
-extern __inline__ int generic_fls(int x)
+static __inline__ int generic_fls(int x)
 {
 	int r = 32;
 
@@ -71,7 +71,7 @@
 	return r;
 }
 
-extern __inline__ int get_bitmask_order(unsigned int count)
+static __inline__ int get_bitmask_order(unsigned int count)
 {
 	int order;
 	
diff -Nru a/include/linux/blkdev.h b/include/linux/blkdev.h
--- a/include/linux/blkdev.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/blkdev.h	2004-12-24 13:36:31 -08:00
@@ -19,8 +19,8 @@
 
 struct request_queue;
 typedef struct request_queue request_queue_t;
-struct elevator_s;
-typedef struct elevator_s elevator_t;
+struct elevator_queue;
+typedef struct elevator_queue elevator_t;
 struct request_pm_state;
 
 #define BLKDEV_MIN_RQ	4
@@ -52,6 +52,20 @@
 	sector_t seek_mean;
 };
 
+struct cfq_queue;
+struct cfq_io_context {
+	void (*dtor)(struct cfq_io_context *);
+	void (*exit)(struct cfq_io_context *);
+
+	struct io_context *ioc;
+
+	/*
+	 * circular list of cfq_io_contexts belonging to a process io context
+	 */
+	struct list_head list;
+	struct cfq_queue *cfqq;
+};
+
 /*
  * This is the per-process I/O subsystem state.  It is refcounted and
  * kmalloc'ed. Currently all fields are modified in process io context
@@ -67,7 +81,10 @@
 	unsigned long last_waited; /* Time last woken after wait for request */
 	int nr_batch_requests;     /* Number of requests left in the batch */
 
+	spinlock_t lock;
+
 	struct as_io_context *aic;
+	struct cfq_io_context *cic;
 };
 
 void put_io_context(struct io_context *ioc);
@@ -80,6 +97,7 @@
 	int count[2];
 	mempool_t *rq_pool;
 	wait_queue_head_t wait[2];
+	wait_queue_head_t drain;
 };
 
 #define BLK_MAX_CDB	16
@@ -107,13 +125,7 @@
 	/* no. of sectors left to complete in the current segment */
 	unsigned int hard_cur_sectors;
 
-	/* no. of segments left to submit in the current bio */
-	unsigned short nr_cbio_segments;
-	/* no. of sectors left to submit in the current bio */
-	unsigned long nr_cbio_sectors;
-
-	struct bio *cbio;		/* next bio to submit */
-	struct bio *bio;		/* next unfinished bio to complete */
+	struct bio *bio;
 	struct bio *biotail;
 
 	void *elevator_private;
@@ -279,7 +291,7 @@
 	 */
 	struct list_head	queue_head;
 	struct request		*last_merge;
-	elevator_t		elevator;
+	elevator_t		*elevator;
 
 	/*
 	 * the queue request freelist, one for reads and one for writes
@@ -342,6 +354,7 @@
 	unsigned long		nr_requests;	/* Max # of requests */
 	unsigned int		nr_congestion_on;
 	unsigned int		nr_congestion_off;
+	unsigned int		nr_batching;
 
 	unsigned short		max_sectors;
 	unsigned short		max_hw_sectors;
@@ -364,6 +377,8 @@
 	 */
 	unsigned int		sg_timeout;
 	unsigned int		sg_reserved_size;
+
+	struct list_head	drain_list;
 };
 
 #define RQ_INACTIVE		(-1)
@@ -381,6 +396,7 @@
 #define QUEUE_FLAG_REENTER	6	/* Re-entrancy avoidance */
 #define QUEUE_FLAG_PLUGGED	7	/* queue is plugged */
 #define QUEUE_FLAG_ORDERED	8	/* supports ordered writes */
+#define QUEUE_FLAG_DRAIN	9	/* draining queue for sched switch */
 
 #define blk_queue_plugged(q)	test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags)
 #define blk_queue_tagged(q)	test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
@@ -445,32 +461,6 @@
  */
 #define blk_queue_headactive(q, head_active)
 
-/* current index into bio being processed for submission */
-#define blk_rq_idx(rq)	((rq)->cbio->bi_vcnt - (rq)->nr_cbio_segments)
-
-/* current bio vector being processed */
-#define blk_rq_vec(rq)	(bio_iovec_idx((rq)->cbio, blk_rq_idx(rq)))
-
-/* current offset with respect to start of the segment being submitted */
-#define blk_rq_offset(rq) \
-	(((rq)->hard_cur_sectors - (rq)->current_nr_sectors) << 9)
-
-/*
- * temporarily mapping a (possible) highmem bio (typically for PIO transfer)
- */
-
-/* Assumes rq->cbio != NULL */
-static inline char * rq_map_buffer(struct request *rq, unsigned long *flags)
-{
-	return (__bio_kmap_irq(rq->cbio, blk_rq_idx(rq), flags)
-		+ blk_rq_offset(rq));
-}
-
-static inline void rq_unmap_buffer(char *buffer, unsigned long *flags)
-{
-	__bio_kunmap_irq(buffer, flags);
-}
-
 /*
  * q->prep_rq_fn return values
  */
@@ -532,6 +522,7 @@
 extern int scsi_cmd_ioctl(struct file *, struct gendisk *, unsigned int, void __user *);
 extern void blk_start_queue(request_queue_t *q);
 extern void blk_stop_queue(request_queue_t *q);
+extern void blk_sync_queue(struct request_queue *q);
 extern void __blk_stop_queue(request_queue_t *q);
 extern void blk_run_queue(request_queue_t *);
 extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *);
@@ -569,7 +560,6 @@
 extern int end_that_request_first(struct request *, int, int);
 extern int end_that_request_chunk(struct request *, int, int);
 extern void end_that_request_last(struct request *);
-extern int process_that_request_first(struct request *, unsigned int);
 extern void end_request(struct request *req, int uptodate);
 
 /*
@@ -617,6 +607,8 @@
 extern void generic_unplug_device(request_queue_t *);
 extern void __generic_unplug_device(request_queue_t *);
 extern long nr_blockdev_pages(void);
+extern void blk_wait_queue_drained(request_queue_t *, int);
+extern void blk_finish_queue_drain(request_queue_t *);
 
 int blk_get_queue(request_queue_t *);
 request_queue_t *blk_alloc_queue(int);
@@ -638,7 +630,6 @@
 extern long blk_congestion_wait(int rw, long timeout);
 
 extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
-extern void blk_rq_prep_restart(struct request *);
 extern int blkdev_issue_flush(struct block_device *, sector_t *);
 
 #define MAX_PHYS_SEGMENTS 128
diff -Nru a/include/linux/buffer_head.h b/include/linux/buffer_head.h
--- a/include/linux/buffer_head.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/buffer_head.h	2004-12-24 13:36:17 -08:00
@@ -10,6 +10,7 @@
 #include <linux/types.h>
 #include <linux/fs.h>
 #include <linux/linkage.h>
+#include <linux/pagemap.h>
 #include <linux/wait.h>
 #include <asm/atomic.h>
 
@@ -76,7 +77,7 @@
 {									\
 	clear_bit(BH_##bit, &(bh)->b_state);				\
 }									\
-static inline int buffer_##name(struct buffer_head *bh)			\
+static inline int buffer_##name(const struct buffer_head *bh)		\
 {									\
 	return test_bit(BH_##bit, &(bh)->b_state);			\
 }
@@ -136,6 +137,8 @@
 void set_bh_page(struct buffer_head *bh,
 		struct page *page, unsigned long offset);
 int try_to_free_buffers(struct page *);
+struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
+		int retry);
 void create_empty_buffers(struct page *, unsigned long,
 			unsigned long b_state);
 void end_buffer_read_sync(struct buffer_head *bh, int uptodate);
@@ -155,7 +158,6 @@
 int sync_blockdev(struct block_device *bdev);
 void __wait_on_buffer(struct buffer_head *);
 wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
-void wake_up_buffer(struct buffer_head *bh);
 int fsync_bdev(struct block_device *);
 struct super_block *freeze_bdev(struct block_device *);
 void thaw_bdev(struct block_device *, struct super_block *);
@@ -205,6 +207,14 @@
 /*
  * inline definitions
  */
+
+static inline void attach_page_buffers(struct page *page,
+		struct buffer_head *head)
+{
+	page_cache_get(page);
+	SetPagePrivate(page);
+	page->private = (unsigned long)head;
+}
 
 static inline void get_bh(struct buffer_head *bh)
 {
diff -Nru a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
--- a/include/linux/byteorder/big_endian.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/byteorder/big_endian.h	2004-12-24 13:37:19 -08:00
@@ -27,12 +27,12 @@
 #define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x))
 #define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x))
 #define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x))
-#define __cpu_to_le64(x) ((__force __le64)___swab64((x)))
-#define __le64_to_cpu(x) ___swab64((__force __u64)(__le64)(x))
-#define __cpu_to_le32(x) ((__force __le32)___swab32((x)))
-#define __le32_to_cpu(x) ___swab32((__force __u32)(__le32)(x))
-#define __cpu_to_le16(x) ((__force __le16)___swab16((x)))
-#define __le16_to_cpu(x) ___swab16((__force __u16)(__le16)(x))
+#define __cpu_to_le64(x) ((__force __le64)__swab64((x)))
+#define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
+#define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
+#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
+#define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
+#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
 #define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
 #define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
 #define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
diff -Nru a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
--- a/include/linux/byteorder/little_endian.h	2004-12-24 13:36:59 -08:00
+++ b/include/linux/byteorder/little_endian.h	2004-12-24 13:36:59 -08:00
@@ -33,12 +33,12 @@
 #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
 #define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
 #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
-#define __cpu_to_be64(x) ((__force __be64)___swab64((x)))
-#define __be64_to_cpu(x) ___swab64((__force __u64)(__be64)(x))
-#define __cpu_to_be32(x) ((__force __be32)___swab32((x)))
-#define __be32_to_cpu(x) ___swab32((__force __u32)(__be32)(x))
-#define __cpu_to_be16(x) ((__force __be16)___swab16((x)))
-#define __be16_to_cpu(x) ___swab16((__force __u16)(__be16)(x))
+#define __cpu_to_be64(x) ((__force __be64)__swab64((x)))
+#define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x))
+#define __cpu_to_be32(x) ((__force __be32)__swab32((x)))
+#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
+#define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
+#define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))
 
 static inline __le64 __cpu_to_le64p(const __u64 *p)
 {
diff -Nru a/include/linux/cdev.h b/include/linux/cdev.h
--- a/include/linux/cdev.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/cdev.h	2004-12-24 13:37:01 -08:00
@@ -17,8 +17,6 @@
 
 void cdev_put(struct cdev *p);
 
-struct kobject *cdev_get(struct cdev *);
-
 int cdev_add(struct cdev *, dev_t, unsigned);
 
 void cdev_del(struct cdev *);
diff -Nru a/include/linux/cdrom.h b/include/linux/cdrom.h
--- a/include/linux/cdrom.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/cdrom.h	2004-12-24 13:36:17 -08:00
@@ -452,6 +452,7 @@
 #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL  0x1e
 #define GPCMD_READ_10			    0x28
 #define GPCMD_READ_12			    0xa8
+#define GPCMD_READ_BUFFER_CAPACITY	    0x5c
 #define GPCMD_READ_CDVD_CAPACITY	    0x25
 #define GPCMD_READ_CD			    0xbe
 #define GPCMD_READ_CD_MSF		    0xb9
@@ -499,6 +500,7 @@
 #define GPMODE_VENDOR_PAGE		0x00
 #define GPMODE_R_W_ERROR_PAGE		0x01
 #define GPMODE_WRITE_PARMS_PAGE		0x05
+#define GPMODE_WCACHING_PAGE		0x08
 #define GPMODE_AUDIO_CTL_PAGE		0x0e
 #define GPMODE_POWER_PAGE		0x1a
 #define GPMODE_FAULT_FAIL_PAGE		0x1c
@@ -947,6 +949,8 @@
         __u8 reserved		: 6;	/* not used yet */
 	int cdda_method;		/* see flags */
 	__u8 last_sense;
+	__u8 media_written;		/* dirty flag, DVD+RW bookkeeping */
+	unsigned short mmc3_profile;	/* current MMC3 profile */
 	int for_data;
 	int (*exit)(struct cdrom_device_info *);
 	int mrw_mode_page;
diff -Nru a/include/linux/compat.h b/include/linux/compat.h
--- a/include/linux/compat.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/compat.h	2004-12-24 13:36:48 -08:00
@@ -119,6 +119,8 @@
 long compat_sys_shmctl(int first, int second, void __user *uptr);
 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
 		unsigned nsems, const struct compat_timespec __user *timeout);
+asmlinkage long compat_sys_keyctl(u32 option,
+			      u32 arg2, u32 arg3, u32 arg4, u32 arg5);
 
 asmlinkage ssize_t compat_sys_readv(unsigned long fd,
 		const struct compat_iovec __user *vec, unsigned long vlen);
diff -Nru a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
--- a/include/linux/compat_ioctl.h	2004-12-24 13:37:29 -08:00
+++ b/include/linux/compat_ioctl.h	2004-12-24 13:37:29 -08:00
@@ -23,6 +23,8 @@
 COMPATIBLE_IOCTL(TCSETSW)
 COMPATIBLE_IOCTL(TCSETSF)
 COMPATIBLE_IOCTL(TIOCLINUX)
+COMPATIBLE_IOCTL(TIOCSBRK)
+COMPATIBLE_IOCTL(TIOCCBRK)
 /* Little t */
 COMPATIBLE_IOCTL(TIOCGETD)
 COMPATIBLE_IOCTL(TIOCSETD)
@@ -138,6 +140,7 @@
 COMPATIBLE_IOCTL(DM_TABLE_DEPS_32)
 COMPATIBLE_IOCTL(DM_TABLE_STATUS_32)
 COMPATIBLE_IOCTL(DM_LIST_VERSIONS_32)
+COMPATIBLE_IOCTL(DM_TARGET_MSG_32)
 COMPATIBLE_IOCTL(DM_VERSION)
 COMPATIBLE_IOCTL(DM_REMOVE_ALL)
 COMPATIBLE_IOCTL(DM_LIST_DEVICES)
@@ -152,6 +155,7 @@
 COMPATIBLE_IOCTL(DM_TABLE_DEPS)
 COMPATIBLE_IOCTL(DM_TABLE_STATUS)
 COMPATIBLE_IOCTL(DM_LIST_VERSIONS)
+COMPATIBLE_IOCTL(DM_TARGET_MSG)
 /* Big K */
 COMPATIBLE_IOCTL(PIO_FONT)
 COMPATIBLE_IOCTL(GIO_FONT)
@@ -338,6 +342,11 @@
 COMPATIBLE_IOCTL(PPPOEIOCDFWD)
 /* LP */
 COMPATIBLE_IOCTL(LPGETSTATUS)
+/* ppdev */
+COMPATIBLE_IOCTL(PPCLAIM)
+COMPATIBLE_IOCTL(PPRELEASE)
+COMPATIBLE_IOCTL(PPEXCL)
+COMPATIBLE_IOCTL(PPYIELD)
 /* CDROM stuff */
 COMPATIBLE_IOCTL(CDROMPAUSE)
 COMPATIBLE_IOCTL(CDROMRESUME)
@@ -382,6 +391,8 @@
 COMPATIBLE_IOCTL(DVD_READ_STRUCT)
 COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
 COMPATIBLE_IOCTL(DVD_AUTH)
+/* pktcdvd */
+COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
 /* Big L */
 ULONG_IOCTL(LOOP_SET_FD)
 ULONG_IOCTL(LOOP_CHANGE_FD)
diff -Nru a/include/linux/compiler.h b/include/linux/compiler.h
--- a/include/linux/compiler.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/compiler.h	2004-12-24 13:37:00 -08:00
@@ -1,12 +1,19 @@
 #ifndef __LINUX_COMPILER_H
 #define __LINUX_COMPILER_H
 
+#ifndef __ASSEMBLY__
+
 #ifdef __CHECKER__
 # define __user		__attribute__((noderef, address_space(1)))
 # define __kernel	/* default address space */
 # define __safe		__attribute__((safe))
 # define __force	__attribute__((force))
 # define __iomem	__attribute__((noderef, address_space(2)))
+# define __acquires(x)	__attribute__((context(0,1)))
+# define __releases(x)	__attribute__((context(1,0)))
+# define __acquire(x)	__context__(1)
+# define __release(x)	__context__(-1)
+# define __cond_lock(x)	((x) ? ({ __context__(1); 1; }) : 0)
 extern void __chk_user_ptr(void __user *);
 extern void __chk_io_ptr(void __iomem *);
 #else
@@ -17,11 +24,16 @@
 # define __iomem
 # define __chk_user_ptr(x) (void)0
 # define __chk_io_ptr(x) (void)0
+# define __builtin_warning(x, y...) (1)
+# define __acquires(x)
+# define __releases(x)
+# define __acquire(x) (void)0
+# define __release(x) (void)0
+# define __cond_lock(x) (x)
 #endif
 
 #ifdef __KERNEL__
 
-#ifndef __ASSEMBLY__
 #if __GNUC__ > 3
 # include <linux/compiler-gcc+.h>	/* catch-all for GCC 4, 5, etc. */
 #elif __GNUC__ == 3
@@ -31,7 +43,6 @@
 #else
 # error Sorry, your compiler is too old/not recognized.
 #endif
-#endif
 
 /* Intel compiler defines __GNUC__. So we will overwrite implementations
  * coming from above header files here
@@ -60,6 +71,8 @@
      __ptr = (unsigned long) (ptr);				\
     (typeof(ptr)) (__ptr + (off)); })
 #endif
+
+#endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
 
diff -Nru a/include/linux/cpufreq.h b/include/linux/cpufreq.h
--- a/include/linux/cpufreq.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/cpufreq.h	2004-12-24 13:37:00 -08:00
@@ -22,6 +22,7 @@
 #include <linux/sysfs.h>
 #include <linux/completion.h>
 #include <linux/workqueue.h>
+#include <linux/cpumask.h>
 
 #define CPUFREQ_NAME_LEN 16
 
@@ -69,7 +70,8 @@
 };
 
 struct cpufreq_policy {
-	unsigned int		cpu;    /* cpu nr */
+	cpumask_t		cpus;	/* affected CPUs */
+	unsigned int		cpu;    /* cpu nr of registered CPU */
 	struct cpufreq_cpuinfo	cpuinfo;/* see above */
 
 	unsigned int		min;    /* in kHz */
@@ -259,8 +261,8 @@
  *********************************************************************/
 #ifdef CONFIG_CPU_FREQ_24_API
 
-int cpufreq_setmax(unsigned int cpu);
-int cpufreq_set(unsigned int kHz, unsigned int cpu);
+int __deprecated cpufreq_setmax(unsigned int cpu);
+int __deprecated cpufreq_set(unsigned int kHz, unsigned int cpu);
 
 
 /* /proc/sys/cpu */
@@ -357,5 +359,24 @@
 
 void cpufreq_frequency_table_put_attr(unsigned int cpu);
 
+
+/*********************************************************************
+ *                     UNIFIED DEBUG HELPERS                         *
+ *********************************************************************/
+
+#define CPUFREQ_DEBUG_CORE	1
+#define CPUFREQ_DEBUG_DRIVER	2
+#define CPUFREQ_DEBUG_GOVERNOR	4
+
+#ifdef CONFIG_CPU_FREQ_DEBUG
+
+extern void cpufreq_debug_printk(unsigned int type, const char *prefix, 
+				 const char *fmt, ...);
+
+#else
+
+#define cpufreq_debug_printk(msg...) do { } while(0)
+
+#endif /* CONFIG_CPU_FREQ_DEBUG */
 
 #endif /* _LINUX_CPUFREQ_H */
diff -Nru a/include/linux/crc-ccitt.h b/include/linux/crc-ccitt.h
--- a/include/linux/crc-ccitt.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/crc-ccitt.h	2004-12-24 13:36:48 -08:00
@@ -1,5 +1,6 @@
 #ifndef _LINUX_CRC_CCITT_H
 #define _LINUX_CRC_CCITT_H
+#ifdef __KERNEL__
 
 #include <linux/types.h>
 
@@ -12,4 +13,5 @@
 	return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff];
 }
 
+#endif /* __KERNEL__ */
 #endif /* _LINUX_CRC_CCITT_H */
diff -Nru a/include/linux/cyclomx.h b/include/linux/cyclomx.h
--- a/include/linux/cyclomx.h	2004-12-24 13:36:55 -08:00
+++ b/include/linux/cyclomx.h	2004-12-24 13:36:55 -08:00
@@ -52,7 +52,7 @@
 	char in_isr;			/* interrupt-in-service flag */
 	char buff_int_mode_unbusy;      /* flag for carrying out dev_tint */
 	wait_queue_head_t wait_stats;  /* to wait for the STATS indication */
-	void *mbox;			/* -> mailbox */
+	void __iomem *mbox;			/* -> mailbox */
 	void (*isr)(struct cycx_device* card);	/* interrupt service routine */
 	int (*exec)(struct cycx_device* card, void* u_cmd, void* u_data);
 	union {
diff -Nru a/include/linux/cycx_drv.h b/include/linux/cycx_drv.h
--- a/include/linux/cycx_drv.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/cycx_drv.h	2004-12-24 13:36:47 -08:00
@@ -48,17 +48,17 @@
 struct cycx_hw {
 	u32 fwid;
 	int irq;
-	void *dpmbase;
+	void __iomem *dpmbase;
 	u32 dpmsize;
 	u32 reserved[5];
 };
 
 /* Function Prototypes */
-extern int cycx_setup(struct cycx_hw *hw, void *sfm, u32 len);
+extern int cycx_setup(struct cycx_hw *hw, void *sfm, u32 len, unsigned long base);
 extern int cycx_down(struct cycx_hw *hw);
 extern int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
 extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
-extern int cycx_exec(void *addr);
+extern int cycx_exec(void __iomem *addr);
 
 extern void cycx_inten(struct cycx_hw *hw);
 extern void cycx_intr(struct cycx_hw *hw);
diff -Nru a/include/linux/dcache.h b/include/linux/dcache.h
--- a/include/linux/dcache.h	2004-12-24 13:37:31 -08:00
+++ b/include/linux/dcache.h	2004-12-24 13:37:31 -08:00
@@ -28,7 +28,7 @@
  * "quick string" -- eases parameter passing, but more importantly
  * saves "metadata" about the string (ie length and the hash).
  *
- * hash comes first so it snuggles against d_parent and d_bucket in the
+ * hash comes first so it snuggles against d_parent in the
  * dentry.
  */
 struct qstr {
@@ -91,7 +91,6 @@
 	 * so they all fit in a 16-byte range, with 16-byte alignment.
 	 */
 	struct dentry *d_parent;	/* parent directory */
-	struct hlist_head *d_bucket;	/* lookup hash bucket */
 	struct qstr d_name;
 
 	struct list_head d_lru;		/* LRU list */
diff -Nru a/include/linux/device-mapper.h b/include/linux/device-mapper.h
--- a/include/linux/device-mapper.h	2004-12-24 13:37:02 -08:00
+++ b/include/linux/device-mapper.h	2004-12-24 13:37:02 -08:00
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001 Sistina Software (UK) Limited.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the LGPL.
  */
@@ -57,6 +58,8 @@
 typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,
 			     char *result, unsigned int maxlen);
 
+typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv);
+
 void dm_error(const char *message);
 
 /*
@@ -82,6 +85,7 @@
 	dm_suspend_fn suspend;
 	dm_resume_fn resume;
 	dm_status_fn status;
+	dm_message_fn message;
 };
 
 struct io_restrictions {
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/device.h	2004-12-24 13:37:19 -08:00
@@ -106,6 +106,8 @@
 	struct kobject		kobj;
 	struct list_head	devices;
 
+	struct module 		* owner;
+
 	int	(*probe)	(struct device * dev);
 	int 	(*remove)	(struct device * dev);
 	void	(*shutdown)	(struct device * dev);
@@ -266,12 +268,7 @@
 	void		*platform_data;	/* Platform specific data (e.g. ACPI,
 					   BIOS data relevant to device) */
 	struct dev_pm_info	power;
-	u32		power_state;	/* Current operating state. In
-					   ACPI-speak, this is D0-D3, D0
-					   being fully functional, and D3
-					   being off. */
 
-	unsigned char *saved_state;	/* saved device state */
 	u32		detach_state;	/* State to enter when device is
 					   detached from its driver. */
 
@@ -320,11 +317,13 @@
 		     int (*fn)(struct device *, void *));
 
 /*
- * Manual binding of a device to driver. See drivers/base/bus.c 
+ * Manual binding of a device to driver. See drivers/base/bus.c
  * for information on use.
  */
+extern int  driver_probe_device(struct device_driver * drv, struct device * dev);
 extern void device_bind_driver(struct device * dev);
 extern void device_release_driver(struct device * dev);
+extern int  device_attach(struct device * dev);
 extern void driver_attach(struct device_driver * drv);
 
 
diff -Nru a/include/linux/dio.h b/include/linux/dio.h
--- a/include/linux/dio.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/dio.h	2004-12-24 13:37:19 -08:00
@@ -3,11 +3,12 @@
  * The general structure of this is vaguely based on how
  * the Amiga port handles Zorro boards.
  * Copyright (C) Peter Maydell 05/1998 <pmaydell@chiark.greenend.org.uk>
+ * Converted to driver model Jochen Friedrich <jochen@scram.de>
  *
  * The board IDs are from the NetBSD kernel, which for once provided
  * helpful comments...
  *
- * This goes with arch/m68k/hp300/dio.c
+ * This goes with drivers/dio/dio.c
  */
 
 #ifndef _LINUX_DIO_H
@@ -27,34 +28,80 @@
  * so currently we just don't handle DIO-II boards.  It wouldn't be hard to 
  * do with ioremap() though.
  */
+
+#include <linux/device.h>
+
 #ifdef __KERNEL__
+
+#include <asm/hp300hw.h>
+
+typedef __u16 dio_id;
+
+    /*
+     *  DIO devices
+     */
+
+struct dio_dev {
+	struct dio_bus *bus;
+	dio_id id;
+	int scode;
+	struct dio_driver *driver;	/* which driver has allocated this device */
+	struct device dev;		/* Generic device interface */
+	u8 ipl;
+	char name[64];
+	struct resource resource;
+};
+
+#define to_dio_dev(n) container_of(n, struct dio_dev, dev)
+
+    /*
+     *  DIO bus
+     */
+
+struct dio_bus {
+	struct list_head devices;           /* list of devices on this bus */
+	unsigned int num_resources;         /* number of resources */
+	struct resource resources[2];       /* address space routed to this bus */
+	struct device dev;
+	char name[10];
+};
+
+extern struct dio_bus dio_bus;      /* Single DIO bus */
+extern struct bus_type dio_bus_type;
+
+    /*
+     *  DIO device IDs
+     */
+
+struct dio_device_id {
+	dio_id id;                    /* Device ID or DIO_WILDCARD */
+	unsigned long driver_data;    /* Data private to the driver */
+};
+
+    /*
+     *  DIO device drivers
+     */
+
+struct dio_driver {
+	struct list_head node;
+	char *name;
+	const struct dio_device_id *id_table;     /* NULL if wants all devices */
+	int (*probe)(struct dio_dev *z, const struct dio_device_id *id);
+/* New device inserted */
+	void (*remove)(struct dio_dev *z);        /* Device removed (NULL if not a hot-plug capable driver) */
+	struct device_driver driver;
+};
+
+#define to_dio_driver(drv)    container_of(drv, struct dio_driver, driver)
+
 /* DIO/DIO-II boards all have the following 8bit registers.
  * These are offsets from the base of the device.
  */
-#define DIO_IDOFF     0x01                        /* primary device ID */
-#define DIO_IPLOFF    0x03                        /* interrupt priority level */
-#define DIO_SECIDOFF  0x15                        /* secondary device ID */
-#define DIOII_SIZEOFF 0x101                       /* device size, DIO-II only */
-
-/* The internal HPIB device is special; this is its physaddr; its select code is 7. 
- * The reason why we have to treat it specially is because apparently it's broken:
- * the device ID isn't consistent/reliable. *sigh*
- */
-#define DIO_IHPIBADDR 0x47800
-#define DIO_IHPIBSCODE 7
-
-/* If we don't have the internal HPIB defined, then treat select code 7 like
- * any other. If we *do* have internal HPIB, then we just have to assume that
- * select code 7 is the internal HPIB regardless of the ID register :-<
- */
-#define CONFIG_IHPIB /* hack hack : not yet a proper config option */
-#ifdef CONFIG_IHPIB
-#define DIO_ISIHPIB(scode) ((scode) == DIO_IHPIBSCODE)
-#else
-#define DIO_ISIHPIB(scode) 0
-#endif
-
-#define DIO_VIRADDRBASE 0xf0000000                /* vir addr where IOspace is mapped */
+#define DIO_IDOFF     0x01             /* primary device ID */
+#define DIO_IPLOFF    0x03             /* interrupt priority level */
+#define DIO_SECIDOFF  0x15             /* secondary device ID */
+#define DIOII_SIZEOFF 0x101            /* device size, DIO-II only */
+#define DIO_VIRADDRBASE 0xf0000000UL   /* vir addr where IOspace is mapped */
 
 #define DIO_BASE                0x600000        /* start of DIO space */
 #define DIO_END                 0x1000000       /* end of DIO space */
@@ -67,9 +114,10 @@
 /* Highest valid select code. If we add DIO-II support this should become
  * 256 for everything except HP320, which only has DIO.
  */
-#define DIO_SCMAX 32                             
+#define DIO_SCMAX (hp300_model == HP_320 ? 32 : 256)
 #define DIOII_SCBASE 132 /* lowest DIO-II select code */
 #define DIO_SCINHOLE(scode) (((scode) >= 32) && ((scode) < DIOII_SCBASE))
+#define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256)
 
 /* macros to read device IDs, given base address */
 #define DIO_ID(baseaddr) in_8((baseaddr) + DIO_IDOFF)
@@ -91,9 +139,10 @@
  * In practice this is only important for framebuffers,
  * and everybody else just sets ID fields equal to the DIO_ID_FOO value.
  */
-#define DIO_ENCODE_ID(pr,sec) ((((int)sec & 0xff) << 8) & ((int)pr & 0xff))
+#define DIO_ENCODE_ID(pr,sec) ((((int)sec & 0xff) << 8) | ((int)pr & 0xff))
 /* macro to determine whether a given primary ID requires a secondary ID byte */
 #define DIO_NEEDSSECID(id) ((id) == DIO_ID_FBUFFER)
+#define DIO_WILDCARD 0xff
 
 /* Now a whole slew of macros giving device IDs and descriptive strings: */
 #define DIO_ID_DCA0     0x02 /* 98644A serial */
@@ -112,18 +161,16 @@
 #define DIO_DESC_LAN "98643A LANCE ethernet"
 #define DIO_ID_FHPIB    0x08 /* 98625A/98625B fast HP-IB */
 #define DIO_DESC_FHPIB "98625A/98625B fast HPIB"
-#define DIO_ID_NHPIB    0x80 /* 98624A HP-IB (normal ie slow) */
+#define DIO_ID_NHPIB    0x01 /* 98624A HP-IB (normal ie slow) */
 #define DIO_DESC_NHPIB "98624A HPIB"
-#define DIO_ID_IHPIB    0x00 /* internal HPIB (not its real ID, it hasn't got one! */
-#define DIO_DESC_IHPIB "internal HPIB"
-#define DIO_ID_SCSI0    0x07 /* 98625A SCSI */
-#define DIO_DESC_SCSI0 "98625A SCSI0"
+#define DIO_ID_SCSI0    0x07 /* 98265A SCSI */
+#define DIO_DESC_SCSI0 "98265A SCSI0"
 #define DIO_ID_SCSI1    0x27 /* ditto */
-#define DIO_DESC_SCSI1 "98625A SCSI1"
+#define DIO_DESC_SCSI1 "98265A SCSI1"
 #define DIO_ID_SCSI2    0x47 /* ditto */
-#define DIO_DESC_SCSI2 "98625A SCSI2"
+#define DIO_DESC_SCSI2 "98265A SCSI2"
 #define DIO_ID_SCSI3    0x67 /* ditto */
-#define DIO_DESC_SCSI3 "98625A SCSI3"
+#define DIO_DESC_SCSI3 "98265A SCSI3"
 #define DIO_ID_FBUFFER  0x39 /* framebuffer: flavour is distinguished by secondary ID */
 #define DIO_DESC_FBUFFER "bitmapped display"
 /* the NetBSD kernel source is a bit unsure as to what these next IDs actually do :-> */
@@ -193,12 +240,73 @@
  */
 
 extern int dio_find(int deviceid);
-extern void *dio_scodetoviraddr(int scode);
-extern int dio_scodetoipl(int scode);
-extern const char *dio_scodetoname(int scode);
-extern void dio_config_board(int scode);
-extern void dio_unconfig_board(int scode);
+extern unsigned long dio_scodetophysaddr(int scode);
+extern void dio_create_sysfs_dev_files(struct dio_dev *);
+
+/* New-style probing */
+extern int dio_register_driver(struct dio_driver *);
+extern void dio_unregister_driver(struct dio_driver *);
+extern const struct dio_device_id *dio_match_device(const struct dio_device_id *ids, const struct dio_dev *z);
+static inline struct dio_driver *dio_dev_driver(const struct dio_dev *d)
+{
+    return d->driver;
+}
+
+#define dio_resource_start(d) ((d)->resource.start)
+#define dio_resource_end(d)   ((d)->resource.end)
+#define dio_resource_len(d)   ((d)->resource.end-(d)->resource.start+1)
+#define dio_resource_flags(d) ((d)->resource.flags)
+
+#define dio_request_device(d, name) \
+    request_mem_region(dio_resource_start(d), dio_resource_len(d), name)
+#define dio_release_device(d) \
+    release_mem_region(dio_resource_start(d), dio_resource_len(d))
+
+/* Similar to the helpers above, these manipulate per-dio_dev
+ * driver-specific data.  They are really just a wrapper around
+ * the generic device structure functions of these calls.
+ */
+static inline void *dio_get_drvdata (struct dio_dev *d)
+{
+	return dev_get_drvdata(&d->dev);
+}
+
+static inline void dio_set_drvdata (struct dio_dev *d, void *data)
+{
+	dev_set_drvdata(&d->dev, data);
+}
+
+/*
+ * A helper function which helps ensure correct dio_driver
+ * setup and cleanup for commonly-encountered hotplug/modular cases
+ *
+ * This MUST stay in a header, as it checks for -DMODULE
+ */
+static inline int dio_module_init(struct dio_driver *drv)
+{
+	int rc = dio_register_driver(drv);
+
+	if (rc > 0)
+		return 0;
+
+	/* iff CONFIG_HOTPLUG and built into kernel, we should
+	 * leave the driver around for future hotplug events.
+	 * For the module case, a hotplug daemon of some sort
+	 * should load a module in response to an insert event. */
+#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
+	if (rc == 0)
+		return 0;
+#else
+	if (rc == 0)
+		rc = -ENODEV;
+#endif
+
+	/* if we get here, we need to clean up DIO driver instance
+	 * and return some sort of error */
+	dio_unregister_driver(drv);
 
+	return rc;
+}
 
 #endif /* __KERNEL__ */
 #endif /* ndef _LINUX_DIO_H */
diff -Nru a/include/linux/divert.h b/include/linux/divert.h
--- a/include/linux/divert.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/divert.h	2004-12-24 13:37:18 -08:00
@@ -109,6 +109,8 @@
 #include <linux/skbuff.h>
 
 #ifdef CONFIG_NET_DIVERT
+#include <linux/netdevice.h>
+
 int alloc_divert_blk(struct net_device *);
 void free_divert_blk(struct net_device *);
 int divert_ioctl(unsigned int cmd, struct divert_cf __user *arg);
diff -Nru a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h
--- a/include/linux/dm-ioctl.h	2004-12-24 13:36:16 -08:00
+++ b/include/linux/dm-ioctl.h	2004-12-24 13:36:16 -08:00
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the LGPL.
  */
@@ -76,6 +77,9 @@
  *
  * DM_TABLE_STATUS:
  * Return the targets status for the 'active' table.
+ *
+ * DM_TARGET_MSG:
+ * Pass a message string to the target at a specific offset of a device.
  */
 
 /*
@@ -179,6 +183,15 @@
 };
 
 /*
+ * Used to pass message to a target
+ */
+struct dm_target_msg {
+	uint64_t sector;	/* Device sector */
+
+	char message[0];
+};
+
+/*
  * If you change this make sure you make the corresponding change
  * to dm-ioctl.c:lookup_ioctl()
  */
@@ -204,6 +217,7 @@
 
 	/* Added later */
 	DM_LIST_VERSIONS_CMD,
+	DM_TARGET_MSG_CMD,
 };
 
 /*
@@ -232,6 +246,7 @@
 #define DM_TABLE_DEPS_32    _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
 #define DM_TABLE_STATUS_32  _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
 #define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
+#define DM_TARGET_MSG_32    _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
 #endif
 
 #define DM_IOCTL 0xfd
@@ -254,10 +269,12 @@
 
 #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
 
+#define DM_TARGET_MSG	 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
+
 #define DM_VERSION_MAJOR	4
-#define DM_VERSION_MINOR	1
+#define DM_VERSION_MINOR	3
 #define DM_VERSION_PATCHLEVEL	0
-#define DM_VERSION_EXTRA	"-ioctl (2003-12-10)"
+#define DM_VERSION_EXTRA	"-ioctl (2004-09-30)"
 
 /* Status bits */
 #define DM_READONLY_FLAG	(1 << 0) /* In/Out */
diff -Nru a/include/linux/dnotify.h b/include/linux/dnotify.h
--- a/include/linux/dnotify.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/dnotify.h	2004-12-24 13:36:17 -08:00
@@ -1,3 +1,5 @@
+#ifndef _LINUX_DNOTIFY_H
+#define _LINUX_DNOTIFY_H
 /*
  * Directory notification for Linux
  *
@@ -8,20 +10,54 @@
 
 struct dnotify_struct {
 	struct dnotify_struct *	dn_next;
-	unsigned long		dn_mask;	/* Events to be notified
-						   see linux/fcntl.h */
+	unsigned long		dn_mask;
 	int			dn_fd;
 	struct file *		dn_filp;
 	fl_owner_t		dn_owner;
 };
 
+#ifdef __KERNEL__
+
+#include <linux/config.h>
+
+#ifdef CONFIG_DNOTIFY
+
 extern void __inode_dir_notify(struct inode *, unsigned long);
-extern void dnotify_flush(struct file *filp, fl_owner_t id);
+extern void dnotify_flush(struct file *, fl_owner_t);
 extern int fcntl_dirnotify(int, struct file *, unsigned long);
-void dnotify_parent(struct dentry *dentry, unsigned long event);
+extern void dnotify_parent(struct dentry *, unsigned long);
 
 static inline void inode_dir_notify(struct inode *inode, unsigned long event)
 {
-	if ((inode)->i_dnotify_mask & (event))
+	if (inode->i_dnotify_mask & (event))
 		__inode_dir_notify(inode, event);
 }
+
+#else
+
+static inline void __inode_dir_notify(struct inode *inode, unsigned long event)
+{
+}
+
+static inline void dnotify_flush(struct file *filp, fl_owner_t id)
+{
+}
+
+static inline int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
+{
+	return -EINVAL;
+}
+
+static inline void dnotify_parent(struct dentry *dentry, unsigned long event)
+{
+}
+
+static inline void inode_dir_notify(struct inode *inode, unsigned long event)
+{
+}
+
+#endif /* CONFIG_DNOTIFY */
+
+#endif /* __KERNEL __ */
+
+#endif /* _LINUX_DNOTIFY_H */
diff -Nru a/include/linux/dvb/frontend.h b/include/linux/dvb/frontend.h
--- a/include/linux/dvb/frontend.h	2004-12-24 13:36:49 -08:00
+++ b/include/linux/dvb/frontend.h	2004-12-24 13:36:49 -08:00
@@ -32,7 +32,8 @@
 typedef enum fe_type {
         FE_QPSK,
         FE_QAM,
-        FE_OFDM
+	FE_OFDM,
+	FE_ATSC
 } fe_type_t;
 
 
@@ -59,7 +60,9 @@
 	FE_CAN_BANDWIDTH_AUTO         = 0x40000,
 	FE_CAN_GUARD_INTERVAL_AUTO    = 0x80000,
 	FE_CAN_HIERARCHY_AUTO         = 0x100000,
-	FE_NEEDS_BENDING              = 0x20000000, // frontend requires frequency bending
+	FE_CAN_8VSB			= 0x200000,
+	FE_CAN_16VSB			= 0x400000,
+	FE_NEEDS_BENDING		= 0x20000000, // not supported anymore, don't use (frontend requires frequency bending)
 	FE_CAN_RECOVER                = 0x40000000, // frontend can recover from a cable unplug automatically
 	FE_CAN_MUTE_TS                = 0x80000000  // frontend can stop spurious TS data output
 } fe_caps_t;
@@ -75,7 +78,7 @@
 	__u32      symbol_rate_min;
         __u32      symbol_rate_max;
 	__u32      symbol_rate_tolerance;     /* ppm */
-	__u32      notifier_delay;            /* ms */
+	__u32      notifier_delay;		/* DEPRECATED */
 	fe_caps_t  caps;
 };
 
@@ -254,6 +257,8 @@
 #define FE_SET_FRONTEND            _IOW('o', 76, struct dvb_frontend_parameters)
 #define FE_GET_FRONTEND            _IOR('o', 77, struct dvb_frontend_parameters)
 #define FE_GET_EVENT               _IOR('o', 78, struct dvb_frontend_event)
+
+#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
 
 
 #endif /*_DVBFRONTEND_H_*/
diff -Nru a/include/linux/dvb/osd.h b/include/linux/dvb/osd.h
--- a/include/linux/dvb/osd.h	2004-12-24 13:37:02 -08:00
+++ b/include/linux/dvb/osd.h	2004-12-24 13:37:02 -08:00
@@ -94,6 +94,7 @@
   OSD_Text,       // (x0,y0,size,color,text)
   OSD_SetWindow, //  (x0) set window with number 0<x0<8 as current
   OSD_MoveWindow, //  move current window to (x0, y0)  
+  OSD_OpenRaw,	// Open other types of OSD windows
 } OSD_Command;
 
 typedef struct osd_cmd_s {
@@ -106,8 +107,39 @@
         void __user *data;
 } osd_cmd_t;
 
+/* OSD_OpenRaw: set 'color' to desired window type */
+typedef enum {
+        OSD_BITMAP1,           /* 1 bit bitmap */
+        OSD_BITMAP2,           /* 2 bit bitmap */
+        OSD_BITMAP4,           /* 4 bit bitmap */
+        OSD_BITMAP8,           /* 8 bit bitmap */
+        OSD_BITMAP1HR,         /* 1 Bit bitmap half resolution */
+        OSD_BITMAP2HR,         /* 2 bit bitmap half resolution */
+        OSD_BITMAP4HR,         /* 4 bit bitmap half resolution */
+        OSD_BITMAP8HR,         /* 8 bit bitmap half resolution */
+        OSD_YCRCB422,          /* 4:2:2 YCRCB Graphic Display */
+        OSD_YCRCB444,          /* 4:4:4 YCRCB Graphic Display */
+        OSD_YCRCB444HR,        /* 4:4:4 YCRCB graphic half resolution */
+        OSD_VIDEOTSIZE,        /* True Size Normal MPEG Video Display */
+        OSD_VIDEOHSIZE,        /* MPEG Video Display Half Resolution */
+        OSD_VIDEOQSIZE,        /* MPEG Video Display Quarter Resolution */
+        OSD_VIDEODSIZE,        /* MPEG Video Display Double Resolution */
+        OSD_VIDEOTHSIZE,       /* True Size MPEG Video Display Half Resolution */
+        OSD_VIDEOTQSIZE,       /* True Size MPEG Video Display Quarter Resolution*/
+        OSD_VIDEOTDSIZE,       /* True Size MPEG Video Display Double Resolution */
+        OSD_VIDEONSIZE,        /* Full Size MPEG Video Display */
+        OSD_CURSOR             /* Cursor */
+} osd_raw_window_t;
+
+typedef struct osd_cap_s {
+        int  cmd;
+#define OSD_CAP_MEMSIZE         1  /* memory size */
+        long val;
+} osd_cap_t;
+
 
 #define OSD_SEND_CMD       _IOW('o', 160, osd_cmd_t)
+#define OSD_GET_CAPABILITY      _IOR('o', 161, osd_cap_t)
 
 #endif
 
diff -Nru a/include/linux/eeprom.h b/include/linux/eeprom.h
--- a/include/linux/eeprom.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/eeprom.h	2004-12-24 13:36:17 -08:00
@@ -15,7 +15,7 @@
 	void *dev;
 	struct eeprom_ops *ops;
 
-	long		addr;
+	void __iomem *	addr;
 
 	unsigned	ee_addr_bits;
 
@@ -43,7 +43,7 @@
         EE_WriteCmd=(5 << 6), EE_ReadCmd=(6 << 6), EE_EraseCmd=(7 << 6),
 };
 
-void setup_ee_mem_bitbanger(struct eeprom *ee, long memaddr, int eesel_bit, int eeclk_bit, int eedo_bit, int eedi_bit, unsigned polarity)
+void setup_ee_mem_bitbanger(struct eeprom *ee, void __iomem *memaddr, int eesel_bit, int eeclk_bit, int eedo_bit, int eedi_bit, unsigned polarity)
 {
 	ee->addr = memaddr;
 	ee->eesel = 1 << eesel_bit;
diff -Nru a/include/linux/efi.h b/include/linux/efi.h
--- a/include/linux/efi.h	2004-12-24 13:37:29 -08:00
+++ b/include/linux/efi.h	2004-12-24 13:37:29 -08:00
@@ -306,7 +306,7 @@
 extern struct efi_memory_map memmap;
 
 #ifdef CONFIG_EFI_PCDP
-extern void __init efi_setup_pcdp_console(char *);
+extern int __init efi_setup_pcdp_console(char *);
 #endif
 
 /*
diff -Nru a/include/linux/efs_fs.h b/include/linux/efs_fs.h
--- a/include/linux/efs_fs.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/efs_fs.h	2004-12-24 13:36:48 -08:00
@@ -45,6 +45,7 @@
 extern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 
 extern struct dentry *efs_lookup(struct inode *, struct dentry *, struct nameidata *);
+extern struct dentry *efs_get_parent(struct dentry *);
 extern int efs_bmap(struct inode *, int);
 
 #endif /* __EFS_FS_H__ */
diff -Nru a/include/linux/elevator.h b/include/linux/elevator.h
--- a/include/linux/elevator.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/elevator.h	2004-12-24 13:36:17 -08:00
@@ -22,9 +22,9 @@
 typedef void (elevator_put_req_fn) (request_queue_t *, struct request *);
 
 typedef int (elevator_init_fn) (request_queue_t *, elevator_t *);
-typedef void (elevator_exit_fn) (request_queue_t *, elevator_t *);
+typedef void (elevator_exit_fn) (elevator_t *);
 
-struct elevator_s
+struct elevator_ops
 {
 	elevator_merge_fn *elevator_merge_fn;
 	elevator_merged_fn *elevator_merged_fn;
@@ -48,12 +48,32 @@
 
 	elevator_init_fn *elevator_init_fn;
 	elevator_exit_fn *elevator_exit_fn;
+};
 
-	void *elevator_data;
+#define ELV_NAME_MAX	(16)
 
-	struct kobject kobj;
+/*
+ * identifies an elevator type, such as AS or deadline
+ */
+struct elevator_type
+{
+	struct list_head list;
+	struct elevator_ops ops;
+	struct elevator_type *elevator_type;
 	struct kobj_type *elevator_ktype;
-	const char *elevator_name;
+	char elevator_name[ELV_NAME_MAX];
+	struct module *elevator_owner;
+};
+
+/*
+ * each queue has an elevator_queue assoicated with it
+ */
+struct elevator_queue
+{
+	struct elevator_ops *ops;
+	void *elevator_data;
+	struct kobject kobj;
+	struct elevator_type *elevator_type;
 };
 
 /*
@@ -79,28 +99,19 @@
 extern void elv_put_request(request_queue_t *, struct request *);
 
 /*
- * noop I/O scheduler. always merges, always inserts new request at tail
- */
-extern elevator_t elevator_noop;
-
-/*
- * deadline i/o scheduler. uses request time outs to prevent indefinite
- * starvation
+ * io scheduler registration
  */
-extern elevator_t iosched_deadline;
+extern int elv_register(struct elevator_type *);
+extern void elv_unregister(struct elevator_type *);
 
 /*
- * anticipatory I/O scheduler
+ * io scheduler sysfs switching
  */
-extern elevator_t iosched_as;
+extern ssize_t elv_iosched_show(request_queue_t *, char *);
+extern ssize_t elv_iosched_store(request_queue_t *, const char *, size_t);
 
-/*
- * completely fair queueing I/O scheduler
- */
-extern elevator_t iosched_cfq;
-
-extern int elevator_init(request_queue_t *, elevator_t *);
-extern void elevator_exit(request_queue_t *);
+extern int elevator_init(request_queue_t *, char *);
+extern void elevator_exit(elevator_t *);
 extern int elv_rq_merge_ok(struct request *, struct bio *);
 extern int elv_try_merge(struct request *, struct bio *);
 extern int elv_try_last_merge(request_queue_t *, struct bio *);
@@ -118,5 +129,14 @@
 #define ELEVATOR_INSERT_FRONT	1
 #define ELEVATOR_INSERT_BACK	2
 #define ELEVATOR_INSERT_SORT	3
+
+/*
+ * return values from elevator_may_queue_fn
+ */
+enum {
+	ELV_MQUEUE_MAY,
+	ELV_MQUEUE_NO,
+	ELV_MQUEUE_MUST,
+};
 
 #endif
diff -Nru a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
--- a/include/linux/ext3_fs.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/ext3_fs.h	2004-12-24 13:37:00 -08:00
@@ -33,11 +33,11 @@
 #undef EXT3FS_DEBUG
 
 /*
- * Define EXT3_PREALLOCATE to preallocate data blocks for expanding files
+ * Define EXT3_RESERVATION to reserve data blocks for expanding files
  */
-#undef  EXT3_PREALLOCATE /* @@@ Fix this! */
-#define EXT3_DEFAULT_PREALLOC_BLOCKS	8
-
+#define EXT3_DEFAULT_RESERVE_BLOCKS     8
+#define EXT3_MAX_RESERVE_BLOCKS         1024
+#define EXT3_RESERVE_WINDOW_NOT_ALLOCATED 0
 /*
  * Always enable hashed directories
  */
@@ -196,6 +196,31 @@
 #define EXT3_STATE_JDATA		0x00000001 /* journaled data exists */
 #define EXT3_STATE_NEW			0x00000002 /* inode is newly created */
 
+
+/* Used to pass group descriptor data when online resize is done */
+struct ext3_new_group_input {
+	__u32 group;            /* Group number for this data */
+	__u32 block_bitmap;     /* Absolute block number of block bitmap */
+	__u32 inode_bitmap;     /* Absolute block number of inode bitmap */
+	__u32 inode_table;      /* Absolute block number of inode table start */
+	__u32 blocks_count;     /* Total number of blocks in this group */
+	__u16 reserved_blocks;  /* Number of reserved blocks in this group */
+	__u16 unused;
+};
+
+/* The struct ext3_new_group_input in kernel space, with free_blocks_count */
+struct ext3_new_group_data {
+	__u32 group;
+	__u32 block_bitmap;
+	__u32 inode_bitmap;
+	__u32 inode_table;
+	__u32 blocks_count;
+	__u16 reserved_blocks;
+	__u16 unused;
+	__u32 free_blocks_count;
+};
+
+
 /*
  * ioctl commands
  */
@@ -203,11 +228,15 @@
 #define	EXT3_IOC_SETFLAGS		_IOW('f', 2, long)
 #define	EXT3_IOC_GETVERSION		_IOR('f', 3, long)
 #define	EXT3_IOC_SETVERSION		_IOW('f', 4, long)
+#define EXT3_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
+#define EXT3_IOC_GROUP_ADD		_IOW('f', 8,struct ext3_new_group_input)
 #define	EXT3_IOC_GETVERSION_OLD		_IOR('v', 1, long)
 #define	EXT3_IOC_SETVERSION_OLD		_IOW('v', 2, long)
 #ifdef CONFIG_JBD_DEBUG
 #define EXT3_IOC_WAIT_FOR_READONLY	_IOR('f', 99, long)
 #endif
+#define EXT3_IOC_GETRSVSZ		_IOR('f', 5, long)
+#define EXT3_IOC_SETRSVSZ		_IOW('f', 6, long)
 
 /*
  * Structure of an inode on the disk
@@ -306,25 +335,26 @@
 /*
  * Mount flags
  */
-#define EXT3_MOUNT_CHECK		0x0001	/* Do mount-time checks */
-#define EXT3_MOUNT_OLDALLOC		0x0002  /* Don't use the new Orlov allocator */
-#define EXT3_MOUNT_GRPID		0x0004	/* Create files with directory's group */
-#define EXT3_MOUNT_DEBUG		0x0008	/* Some debugging messages */
-#define EXT3_MOUNT_ERRORS_CONT		0x0010	/* Continue on errors */
-#define EXT3_MOUNT_ERRORS_RO		0x0020	/* Remount fs ro on errors */
-#define EXT3_MOUNT_ERRORS_PANIC		0x0040	/* Panic on errors */
-#define EXT3_MOUNT_MINIX_DF		0x0080	/* Mimics the Minix statfs */
-#define EXT3_MOUNT_NOLOAD		0x0100	/* Don't use existing journal*/
-#define EXT3_MOUNT_ABORT		0x0200	/* Fatal error detected */
-#define EXT3_MOUNT_DATA_FLAGS		0x0C00	/* Mode for data writes: */
-  #define EXT3_MOUNT_JOURNAL_DATA	0x0400	/* Write data to journal */
-  #define EXT3_MOUNT_ORDERED_DATA	0x0800	/* Flush data before commit */
-  #define EXT3_MOUNT_WRITEBACK_DATA	0x0C00	/* No data ordering */
-#define EXT3_MOUNT_UPDATE_JOURNAL	0x1000	/* Update the journal format */
-#define EXT3_MOUNT_NO_UID32		0x2000  /* Disable 32-bit UIDs */
-#define EXT3_MOUNT_XATTR_USER		0x4000	/* Extended user attributes */
-#define EXT3_MOUNT_POSIX_ACL		0x8000	/* POSIX Access Control Lists */
-#define EXT3_MOUNT_BARRIER		0x10000 /* Use block barriers */
+#define EXT3_MOUNT_CHECK		0x00001	/* Do mount-time checks */
+#define EXT3_MOUNT_OLDALLOC		0x00002  /* Don't use the new Orlov allocator */
+#define EXT3_MOUNT_GRPID		0x00004	/* Create files with directory's group */
+#define EXT3_MOUNT_DEBUG		0x00008	/* Some debugging messages */
+#define EXT3_MOUNT_ERRORS_CONT		0x00010	/* Continue on errors */
+#define EXT3_MOUNT_ERRORS_RO		0x00020	/* Remount fs ro on errors */
+#define EXT3_MOUNT_ERRORS_PANIC		0x00040	/* Panic on errors */
+#define EXT3_MOUNT_MINIX_DF		0x00080	/* Mimics the Minix statfs */
+#define EXT3_MOUNT_NOLOAD		0x00100	/* Don't use existing journal*/
+#define EXT3_MOUNT_ABORT		0x00200	/* Fatal error detected */
+#define EXT3_MOUNT_DATA_FLAGS		0x00C00	/* Mode for data writes: */
+#define EXT3_MOUNT_JOURNAL_DATA		0x00400	/* Write data to journal */
+#define EXT3_MOUNT_ORDERED_DATA		0x00800	/* Flush data before commit */
+#define EXT3_MOUNT_WRITEBACK_DATA	0x00C00	/* No data ordering */
+#define EXT3_MOUNT_UPDATE_JOURNAL	0x01000	/* Update the journal format */
+#define EXT3_MOUNT_NO_UID32		0x02000  /* Disable 32-bit UIDs */
+#define EXT3_MOUNT_XATTR_USER		0x04000	/* Extended user attributes */
+#define EXT3_MOUNT_POSIX_ACL		0x08000	/* POSIX Access Control Lists */
+#define EXT3_MOUNT_RESERVATION		0x10000	/* Preallocation */
+#define EXT3_MOUNT_BARRIER		0x20000 /* Use block barriers */
 
 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
 #ifndef _LINUX_EXT2_FS_H
@@ -418,7 +448,7 @@
 	 */
 	__u8	s_prealloc_blocks;	/* Nr of blocks to try to preallocate*/
 	__u8	s_prealloc_dir_blocks;	/* Nr to preallocate for dirs */
-	__u16	s_padding1;
+	__u16	s_reserved_gdt_blocks;	/* Per group desc for online growth */
 	/*
 	 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
 	 */
@@ -681,16 +711,18 @@
 /* balloc.c */
 extern int ext3_bg_has_super(struct super_block *sb, int group);
 extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group);
-extern int ext3_new_block (handle_t *, struct inode *, unsigned long,
-					    __u32 *, __u32 *, int *);
+extern int ext3_new_block (handle_t *, struct inode *, unsigned long, int *);
 extern void ext3_free_blocks (handle_t *, struct inode *, unsigned long,
 			      unsigned long);
+extern void ext3_free_blocks_sb (handle_t *, struct super_block *,
+				 unsigned long, unsigned long, int *);
 extern unsigned long ext3_count_free_blocks (struct super_block *);
 extern void ext3_check_blocks_bitmap (struct super_block *);
 extern struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
 						    unsigned int block_group,
 						    struct buffer_head ** bh);
 extern int ext3_should_retry_alloc(struct super_block *sb, int *retries);
+extern void ext3_rsv_window_add(struct super_block *sb, struct ext3_reserve_window_node *rsv);
 
 /* dir.c */
 extern int ext3_check_dir_entry(const char *, struct inode *,
@@ -729,7 +761,7 @@
 extern void ext3_put_inode (struct inode *);
 extern void ext3_delete_inode (struct inode *);
 extern int  ext3_sync_inode (handle_t *, struct inode *);
-extern void ext3_discard_prealloc (struct inode *);
+extern void ext3_discard_reservation (struct inode *);
 extern void ext3_dirty_inode(struct inode *);
 extern int ext3_change_inode_journal_flag(struct inode *, int);
 extern void ext3_truncate (struct inode *);
@@ -745,6 +777,13 @@
 extern int ext3_orphan_del(handle_t *, struct inode *);
 extern int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
 				__u32 start_minor_hash, __u32 *next_hash);
+
+/* resize.c */
+extern int ext3_group_add(struct super_block *sb,
+				struct ext3_new_group_data *input);
+extern int ext3_group_extend(struct super_block *sb,
+				struct ext3_super_block *es,
+				unsigned long n_blocks_count);
 
 /* super.c */
 extern void ext3_error (struct super_block *, const char *, const char *, ...)
diff -Nru a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h
--- a/include/linux/ext3_fs_i.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/ext3_fs_i.h	2004-12-24 13:36:17 -08:00
@@ -17,9 +17,27 @@
 #define _LINUX_EXT3_FS_I
 
 #include <linux/rwsem.h>
+#include <linux/rbtree.h>
+#include <linux/seqlock.h>
+
+struct ext3_reserve_window {
+	__u32			_rsv_start;	/* First byte reserved */
+	__u32			_rsv_end;	/* Last byte reserved or 0 */
+};
+
+struct ext3_reserve_window_node {
+	struct rb_node	 	rsv_node;
+	atomic_t		rsv_goal_size;
+	atomic_t		rsv_alloc_hit;
+	seqlock_t		rsv_seqlock;
+	struct ext3_reserve_window	rsv_window;
+};
+
+#define rsv_start rsv_window._rsv_start
+#define rsv_end rsv_window._rsv_end
 
 /*
- * second extended file system inode data in memory
+ * third extended file system inode data in memory
  */
 struct ext3_inode_info {
 	__le32	i_data[15];	/* unconverted */
@@ -57,10 +75,9 @@
 	 * allocation when we detect linearly ascending requests.
 	 */
 	__u32	i_next_alloc_goal;
-#ifdef EXT3_PREALLOCATE
-	__u32	i_prealloc_block;
-	__u32	i_prealloc_count;
-#endif
+	/* block reservation window */
+	struct ext3_reserve_window_node i_rsv_window;
+
 	__u32	i_dir_start_lookup;
 #ifdef CONFIG_EXT3_FS_XATTR
 	/*
diff -Nru a/include/linux/ext3_fs_sb.h b/include/linux/ext3_fs_sb.h
--- a/include/linux/ext3_fs_sb.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/ext3_fs_sb.h	2004-12-24 13:37:19 -08:00
@@ -22,6 +22,7 @@
 #include <linux/blockgroup_lock.h>
 #include <linux/percpu_counter.h>
 #endif
+#include <linux/rbtree.h>
 
 /*
  * third extended-fs super-block data in memory
@@ -53,11 +54,15 @@
 	u32 s_next_generation;
 	u32 s_hash_seed[4];
 	int s_def_hash_version;
-        u8 *s_debts;
 	struct percpu_counter s_freeblocks_counter;
 	struct percpu_counter s_freeinodes_counter;
 	struct percpu_counter s_dirs_counter;
 	struct blockgroup_lock s_blockgroup_lock;
+
+	/* root of the per fs reservation window tree */
+	spinlock_t s_rsv_window_lock;
+	struct rb_root s_rsv_window_root;
+	struct ext3_reserve_window_node s_rsv_window_head;
 
 	/* Journaling */
 	struct inode * s_journal_inode;
diff -Nru a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
--- a/include/linux/ext3_jbd.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/ext3_jbd.h	2004-12-24 13:36:18 -08:00
@@ -188,8 +188,13 @@
 #define ext3_journal_dirty_metadata(handle, bh) \
 	__ext3_journal_dirty_metadata(__FUNCTION__, (handle), (bh))
 
-handle_t *ext3_journal_start(struct inode *inode, int nblocks);
+handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks);
 int __ext3_journal_stop(const char *where, handle_t *handle);
+
+static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks)
+{
+	return ext3_journal_start_sb(inode->i_sb, nblocks);
+}
 
 #define ext3_journal_stop(handle) \
 	__ext3_journal_stop(__FUNCTION__, (handle))
diff -Nru a/include/linux/fb.h b/include/linux/fb.h
--- a/include/linux/fb.h	2004-12-24 13:36:32 -08:00
+++ b/include/linux/fb.h	2004-12-24 13:36:32 -08:00
@@ -102,6 +102,7 @@
 #define FB_ACCEL_I810           39      /* Intel 810/815                */
 #define FB_ACCEL_SIS_GLAMOUR_2  40	/* SiS 315, 650, 740		*/
 #define FB_ACCEL_SIS_XABRE      41	/* SiS 330 ("Xabre")		*/
+#define FB_ACCEL_I830           42      /* Intel 830M/845G/85x/865G     */
 
 #define FB_ACCEL_NEOMAGIC_NM2070 90	/* NeoMagic NM2070              */
 #define FB_ACCEL_NEOMAGIC_NM2090 91	/* NeoMagic NM2090              */
@@ -113,6 +114,21 @@
 #define FB_ACCEL_NEOMAGIC_NM2360 97	/* NeoMagic NM2360              */
 #define FB_ACCEL_NEOMAGIC_NM2380 98	/* NeoMagic NM2380              */
 
+#define FB_ACCEL_SAVAGE4        0x80	/* S3 Savage4                   */
+#define FB_ACCEL_SAVAGE3D       0x81	/* S3 Savage3D                  */
+#define FB_ACCEL_SAVAGE3D_MV    0x82	/* S3 Savage3D-MV               */
+#define FB_ACCEL_SAVAGE2000     0x83	/* S3 Savage2000                */
+#define FB_ACCEL_SAVAGE_MX_MV   0x84	/* S3 Savage/MX-MV              */
+#define FB_ACCEL_SAVAGE_MX      0x85	/* S3 Savage/MX                 */
+#define FB_ACCEL_SAVAGE_IX_MV   0x86	/* S3 Savage/IX-MV              */
+#define FB_ACCEL_SAVAGE_IX      0x87	/* S3 Savage/IX                 */
+#define FB_ACCEL_PROSAVAGE_PM   0x88	/* S3 ProSavage PM133           */
+#define FB_ACCEL_PROSAVAGE_KM   0x89	/* S3 ProSavage KM133           */
+#define FB_ACCEL_S3TWISTER_P    0x8a	/* S3 Twister                   */
+#define FB_ACCEL_S3TWISTER_K    0x8b	/* S3 TwisterK                  */
+#define FB_ACCEL_SUPERSAVAGE    0x8c    /* S3 Supersavage               */
+#define FB_ACCEL_PROSAVAGE_DDR  0x8d	/* S3 ProSavage DDR             */
+#define FB_ACCEL_PROSAVAGE_DDRK 0x8e	/* S3 ProSavage DDR-K           */
 
 struct fb_fix_screeninfo {
 	char id[16];			/* identification string eg "TT Builtin" */
@@ -242,6 +258,24 @@
 #define VESA_HSYNC_SUSPEND      2
 #define VESA_POWERDOWN          3
 
+
+enum {
+	/* screen: unblanked, hsync: on,  vsync: on */
+	FB_BLANK_UNBLANK       = VESA_NO_BLANKING,
+
+	/* screen: blanked,   hsync: on,  vsync: on */
+	FB_BLANK_NORMAL        = VESA_NO_BLANKING + 1,
+
+	/* screen: blanked,   hsync: on,  vsync: off */
+	FB_BLANK_VSYNC_SUSPEND = VESA_VSYNC_SUSPEND + 1,
+
+	/* screen: blanked,   hsync: off, vsync: on */
+	FB_BLANK_HSYNC_SUSPEND = VESA_HSYNC_SUSPEND + 1,
+
+	/* screen: blanked,   hsync: off, vsync: off */
+	FB_BLANK_POWERDOWN     = VESA_POWERDOWN + 1
+};
+
 #define FB_VBLANK_VBLANKING	0x001	/* currently in a vertical blank */
 #define FB_VBLANK_HBLANKING	0x002	/* currently in a horizontal blank */
 #define FB_VBLANK_HAVE_VBLANK	0x004	/* vertical blanks can be detected */
@@ -298,7 +332,7 @@
  * hardware cursor control
  */
 
-#define FB_CUR_SETCUR   0x01
+#define FB_CUR_SETIMAGE 0x01
 #define FB_CUR_SETPOS   0x02
 #define FB_CUR_SETHOT   0x04
 #define FB_CUR_SETCMAP  0x08
@@ -317,8 +351,6 @@
 	const char *mask;	/* cursor mask bits */
 	struct fbcurpos hot;	/* cursor hot spot */
 	struct fb_image	image;	/* Cursor image */
-/* all fields below are for fbcon use only */
-	char  *data;             /* copy of bitmap */
 };
 
 #ifdef __KERNEL__
@@ -555,6 +587,82 @@
 	int (*fb_mmap)(struct fb_info *info, struct file *file, struct vm_area_struct *vma);
 };
 
+#ifdef CONFIG_FB_TILEBLITTING
+
+#define FB_TILE_CURSOR_NONE        0
+#define FB_TILE_CURSOR_UNDERLINE   1
+#define FB_TILE_CURSOR_LOWER_THIRD 2
+#define FB_TILE_CURSOR_LOWER_HALF  3
+#define FB_TILE_CURSOR_TWO_THIRDS  4
+#define FB_TILE_CURSOR_BLOCK       5
+
+struct fb_tilemap {
+	__u32 width;                /* width of each tile in pixels */
+	__u32 height;               /* height of each tile in scanlines */
+	__u32 depth;                /* color depth of each tile */
+	__u32 length;               /* number of tiles in the map */
+	__u8  *data;                /* actual tile map: a bitmap array, packed
+				       to the nearest byte */
+};
+
+struct fb_tilerect {
+	__u32 sx;                   /* origin in the x-axis */
+	__u32 sy;                   /* origin in the y-axis */
+	__u32 width;                /* number of tiles in the x-axis */
+	__u32 height;               /* number of tiles in the y-axis */
+	__u32 index;                /* what tile to use: index to tile map */
+	__u32 fg;                   /* foreground color */
+	__u32 bg;                   /* background color */
+	__u32 rop;                  /* raster operation */
+};
+
+struct fb_tilearea {
+	__u32 sx;                   /* source origin in the x-axis */
+	__u32 sy;                   /* source origin in the y-axis */
+	__u32 dx;                   /* destination origin in the x-axis */
+	__u32 dy;                   /* destination origin in the y-axis */
+	__u32 width;                /* number of tiles in the x-axis */
+	__u32 height;               /* number of tiles in the y-axis */
+};
+
+struct fb_tileblit {
+	__u32 sx;                   /* origin in the x-axis */
+	__u32 sy;                   /* origin in the y-axis */
+	__u32 width;                /* number of tiles in the x-axis */
+	__u32 height;               /* number of tiles in the y-axis */
+	__u32 fg;                   /* foreground color */
+	__u32 bg;                   /* background color */
+	__u32 length;               /* number of tiles to draw */
+	__u32 *indices;             /* array of indices to tile map */
+};
+
+struct fb_tilecursor {
+	__u32 sx;                   /* cursor position in the x-axis */
+	__u32 sy;                   /* cursor position in the y-axis */
+	__u32 mode;                 /* 0 = erase, 1 = draw */
+	__u32 shape;                /* see FB_TILE_CURSOR_* */
+	__u32 fg;                   /* foreground color */
+	__u32 bg;                   /* background color */
+};
+
+struct fb_tile_ops {
+	/* set tile characteristics */
+	void (*fb_settile)(struct fb_info *info, struct fb_tilemap *map);
+
+	/* all dimensions from hereon are in terms of tiles */
+
+	/* move a rectangular region of tiles from one area to another*/
+	void (*fb_tilecopy)(struct fb_info *info, struct fb_tilearea *area);
+	/* fill a rectangular region with a tile */
+	void (*fb_tilefill)(struct fb_info *info, struct fb_tilerect *rect);
+	/* copy an array of tiles */
+	void (*fb_tileblit)(struct fb_info *info, struct fb_tileblit *blit);
+	/* cursor */
+	void (*fb_tilecursor)(struct fb_info *info,
+			      struct fb_tilecursor *cursor);
+};
+#endif /* CONFIG_FB_TILEBLITTING */
+
 /* FBINFO_* = fb_info.flags bit flags */
 #define FBINFO_MODULE		0x0001	/* Low-level driver is a module */
 #define FBINFO_HWACCEL_DISABLED	0x0002
@@ -586,6 +694,7 @@
 						  from userspace */
 #define FBINFO_MISC_MODESWITCH         0x20000 /* mode switch */
 #define FBINFO_MISC_MODESWITCHLATE     0x40000 /* init hardware later */
+#define FBINFO_MISC_TILEBLITTING       0x80000 /* use tile blitting */
 
 struct fb_info {
 	int node;
@@ -593,22 +702,23 @@
 	struct fb_var_screeninfo var;	/* Current var */
 	struct fb_fix_screeninfo fix;	/* Current fix */
 	struct fb_monspecs monspecs;	/* Current Monitor specs */
-	struct fb_cursor cursor;	/* Current cursor */	
 	struct work_struct queue;	/* Framebuffer event queue */
-	struct timer_list cursor_timer; /* Cursor timer */
 	struct fb_pixmap pixmap;	/* Image hardware mapper */
 	struct fb_pixmap sprite;	/* Cursor hardware mapper */
 	struct fb_cmap cmap;		/* Current cmap */
 	struct list_head modelist;      /* mode list */
 	struct fb_ops *fbops;
+	struct device *device;
+#ifdef CONFIG_FB_TILEBLITTING
+	struct fb_tile_ops *tileops;    /* Tile Blitting */
+#endif
 	char __iomem *screen_base;	/* Virtual address */
 	unsigned long screen_size;	/* Amount of ioremapped VRAM or 0 */ 
-	int currcon;			/* Current VC. */
 	void *pseudo_palette;		/* Fake palette of 16 colors */ 
 #define FBINFO_STATE_RUNNING	0
 #define FBINFO_STATE_SUSPENDED	1
 	u32 state;			/* Hardware state i.e suspend */
-
+	void *fbcon_par;                /* fbcon use-only private area */
 	/* From here on everything is device dependent */
 	void *par;	
 };
@@ -705,7 +815,6 @@
 extern void fb_sysmove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,
 				u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
 				u32 height);
-extern void fb_load_cursor_image(struct fb_info *);
 extern void fb_set_suspend(struct fb_info *info, int state);
 extern int fb_get_color_depth(struct fb_info *info);
 extern int fb_get_options(char *name, char **option);
diff -Nru a/include/linux/filter.h b/include/linux/filter.h
--- a/include/linux/filter.h	2004-12-24 13:37:04 -08:00
+++ b/include/linux/filter.h	2004-12-24 13:37:04 -08:00
@@ -6,6 +6,11 @@
 #define __LINUX_FILTER_H__
 
 #include <linux/compiler.h>
+#include <linux/types.h>
+
+#ifdef __KERNEL__
+#include <asm/atomic.h>
+#endif
 
 /*
  * Current version of the filter code architecture.
@@ -135,6 +140,9 @@
 #define SKF_LL_OFF    (-0x200000)
 
 #ifdef __KERNEL__
+struct sk_buff;
+struct sock;
+
 extern int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen);
 extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
 extern int sk_chk_filter(struct sock_filter *filter, int flen);
diff -Nru a/include/linux/fs.h b/include/linux/fs.h
--- a/include/linux/fs.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/fs.h	2004-12-24 13:36:31 -08:00
@@ -61,7 +61,11 @@
 };
 extern struct inodes_stat_t inodes_stat;
 
-extern int leases_enable, dir_notify_enable, lease_break_time;
+extern int leases_enable, lease_break_time;
+
+#ifdef CONFIG_DNOTIFY
+extern int dir_notify_enable;
+#endif
 
 #define NR_FILE  8192	/* this can well be larger on a larger system */
 #define NR_RESERVED_FILES 10 /* reserved for root */
@@ -348,7 +352,12 @@
 	spinlock_t		private_lock;	/* for use by the address_space */
 	struct list_head	private_list;	/* ditto */
 	struct address_space	*assoc_mapping;	/* ditto */
-};
+} __attribute__((aligned(sizeof(long))));
+	/*
+	 * On most architectures that alignment is already the case; but
+	 * must be enforced here for CRIS, to let the least signficant bit
+	 * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON.
+	 */
 
 struct block_device {
 	dev_t			bd_dev;  /* not a kdev_t - it's a search key */
@@ -459,8 +468,10 @@
 
 	__u32			i_generation;
 
+#ifdef CONFIG_DNOTIFY
 	unsigned long		i_dnotify_mask; /* Directory notify events */
 	struct dnotify_struct	*i_dnotify; /* for directory notifications */
+#endif
 
 	unsigned long		i_state;
 	unsigned long		dirtied_when;	/* jiffies of first dirtying */
@@ -633,6 +644,9 @@
 struct lock_manager_operations {
 	int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
 	void (*fl_notify)(struct file_lock *);	/* unblock callback */
+	void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
+	void (*fl_release_private)(struct file_lock *);
+	void (*fl_break)(struct file_lock *);
 };
 
 /* that will die - we need it for nfs_lock_info */
@@ -698,6 +712,8 @@
 extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
 extern int __break_lease(struct inode *inode, unsigned int flags);
 extern void lease_get_mtime(struct inode *, struct timespec *time);
+extern int setlease(struct file *, long, struct file_lock **);
+extern void remove_lease(struct file_lock *);
 extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
 extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
 extern void steal_locks(fl_owner_t from);
@@ -758,6 +774,7 @@
 	int			s_need_sync_fs;
 	atomic_t		s_active;
 	void                    *s_security;
+	struct xattr_handler	**s_xattr;
 
 	struct list_head	s_dirty;	/* dirty inodes */
 	struct list_head	s_io;		/* parked for writeback */
@@ -981,7 +998,8 @@
 #define I_DIRTY_SYNC		1 /* Not dirty enough for O_DATASYNC */
 #define I_DIRTY_DATASYNC	2 /* Data-related inode changes pending */
 #define I_DIRTY_PAGES		4 /* Data-related inode changes pending */
-#define I_LOCK			8
+#define __I_LOCK		3
+#define I_LOCK			(1 << __I_LOCK)
 #define I_FREEING		16
 #define I_CLEAR			32
 #define I_NEW			64
@@ -1254,7 +1272,6 @@
 extern void bd_set_size(struct block_device *, loff_t size);
 extern void bd_forget(struct inode *inode);
 extern void bdput(struct block_device *);
-extern int blkdev_open(struct inode *, struct file *);
 extern struct block_device *open_by_devnum(dev_t, unsigned);
 extern struct file_operations def_blk_fops;
 extern struct address_space_operations def_blk_aops;
@@ -1269,8 +1286,8 @@
 extern void bd_release(struct block_device *);
 
 /* fs/char_dev.c */
-extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, char *);
-extern int register_chrdev_region(dev_t, unsigned, char *);
+extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
+extern int register_chrdev_region(dev_t, unsigned, const char *);
 extern int register_chrdev(unsigned int, const char *,
 			   struct file_operations *);
 extern int unregister_chrdev(unsigned int, const char *);
@@ -1339,7 +1356,9 @@
 extern int setattr_mask(unsigned int);
 extern int notify_change(struct dentry *, struct iattr *);
 extern int permission(struct inode *, int, struct nameidata *);
-extern int vfs_permission(struct inode *, int);
+extern int generic_permission(struct inode *, int,
+		int (*check_acl)(struct inode *, int));
+
 extern int get_write_access(struct inode *);
 extern int deny_write_access(struct file *);
 static inline void put_write_access(struct inode * inode)
@@ -1516,7 +1535,6 @@
 extern int vfs_readlink(struct dentry *, char __user *, int, const char *);
 extern int vfs_follow_link(struct nameidata *, const char *);
 extern int page_readlink(struct dentry *, char __user *, int);
-extern int page_follow_link(struct dentry *, struct nameidata *);
 extern int page_follow_link_light(struct dentry *, struct nameidata *);
 extern void page_put_link(struct dentry *, struct nameidata *);
 extern int page_symlink(struct inode *inode, const char *symname, int len);
@@ -1563,6 +1581,7 @@
 extern struct file_operations simple_dir_operations;
 extern struct inode_operations simple_dir_inode_operations;
 struct tree_descr { char *name; struct file_operations *ops; int mode; };
+struct dentry *d_alloc_name(struct dentry *, const char *);
 extern int simple_fill_super(struct super_block *, int, struct tree_descr *);
 extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count);
 extern void simple_release_fs(struct vfsmount **mount, int *count);
diff -Nru a/include/linux/gen_stats.h b/include/linux/gen_stats.h
--- a/include/linux/gen_stats.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/gen_stats.h	2004-12-24 13:37:01 -08:00
@@ -14,6 +14,7 @@
 #define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
 
 /**
+ * struct gnet_stats_basic - byte/packet throughput statistics
  * @bytes: number of seen bytes
  * @packets: number of seen packets
  */
@@ -24,6 +25,7 @@
 };
 
 /**
+ * struct gnet_stats_rate_est - rate estimator
  * @bps: current byte rate
  * @pps: current packet rate
  */
@@ -34,10 +36,12 @@
 };
 
 /**
+ * struct gnet_stats_queue - queuing statistics
  * @qlen: queue length
  * @backlog: backlog size of queue
  * @drops: number of dropped packets
  * @requeues: number of requeues
+ * @overlimits: number of enqueues over the limit
  */
 struct gnet_stats_queue
 {
@@ -49,6 +53,7 @@
 };
 
 /**
+ * struct gnet_estimator - rate estimator configuration
  * @interval: sampling period
  * @ewma_log: the log of measurement window weight
  */
diff -Nru a/include/linux/generic_serial.h b/include/linux/generic_serial.h
--- a/include/linux/generic_serial.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/generic_serial.h	2004-12-24 13:37:18 -08:00
@@ -73,7 +73,7 @@
 
 
 void gs_put_char(struct tty_struct *tty, unsigned char ch);
-int  gs_write(struct tty_struct *tty, int from_user, 
+int  gs_write(struct tty_struct *tty, 
              const unsigned char *buf, int count);
 int  gs_write_room(struct tty_struct *tty);
 int  gs_chars_in_buffer(struct tty_struct *tty);
diff -Nru a/include/linux/genhd.h b/include/linux/genhd.h
--- a/include/linux/genhd.h	2004-12-24 13:36:19 -08:00
+++ b/include/linux/genhd.h	2004-12-24 13:36:19 -08:00
@@ -28,6 +28,7 @@
 	LINUX_RAID_PARTITION = 0xfd,	/* autodetect RAID partition */
 
 	SOLARIS_X86_PARTITION =	LINUX_SWAP_PARTITION,
+	NEW_SOLARIS_X86_PARTITION = 0xbf,
 
 	DM6_AUX1PARTITION = 0x51,	/* no DDO:  use xlated geom */
 	DM6_AUX3PARTITION = 0x53,	/* no DDO:  use xlated geom */
@@ -129,13 +130,14 @@
 
 /* 
  * Macros to operate on percpu disk statistics:
- * Since writes to disk_stats are serialised through the queue_lock,
- * smp_processor_id() should be enough to get to the per_cpu versions
- * of statistics counters
+ *
+ * The __ variants should only be called in critical sections. The full
+ * variants disable/enable preemption.
  */
 #ifdef	CONFIG_SMP
-#define disk_stat_add(gendiskp, field, addnd) 	\
+#define __disk_stat_add(gendiskp, field, addnd) 	\
 	(per_cpu_ptr(gendiskp->dkstats, smp_processor_id())->field += addnd)
+
 #define disk_stat_read(gendiskp, field)					\
 ({									\
 	typeof(gendiskp->dkstats->field) res = 0;			\
@@ -159,7 +161,8 @@
 }		
 				
 #else
-#define disk_stat_add(gendiskp, field, addnd) (gendiskp->dkstats.field += addnd)
+#define __disk_stat_add(gendiskp, field, addnd) \
+				(gendiskp->dkstats.field += addnd)
 #define disk_stat_read(gendiskp, field)	(gendiskp->dkstats.field)
 
 static inline void disk_stat_set_all(struct gendisk *gendiskp, int value)	{
@@ -167,8 +170,21 @@
 }
 #endif
 
-#define disk_stat_inc(gendiskp, field) disk_stat_add(gendiskp, field, 1)
+#define disk_stat_add(gendiskp, field, addnd)			\
+	do {							\
+		preempt_disable();				\
+		__disk_stat_add(gendiskp, field, addnd);	\
+		preempt_enable();				\
+	} while (0)
+
+#define __disk_stat_dec(gendiskp, field) __disk_stat_add(gendiskp, field, -1)
 #define disk_stat_dec(gendiskp, field) disk_stat_add(gendiskp, field, -1)
+
+#define __disk_stat_inc(gendiskp, field) __disk_stat_add(gendiskp, field, 1)
+#define disk_stat_inc(gendiskp, field) disk_stat_add(gendiskp, field, 1)
+
+#define __disk_stat_sub(gendiskp, field, subnd) \
+		__disk_stat_add(gendiskp, field, -subnd)
 #define disk_stat_sub(gendiskp, field, subnd) \
 		disk_stat_add(gendiskp, field, -subnd)
 
diff -Nru a/include/linux/hardirq.h b/include/linux/hardirq.h
--- a/include/linux/hardirq.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/hardirq.h	2004-12-24 13:36:47 -08:00
@@ -5,6 +5,40 @@
 #include <linux/smp_lock.h>
 #include <asm/hardirq.h>
 
+/*
+ * We put the hardirq and softirq counter into the preemption
+ * counter. The bitmask has the following meaning:
+ *
+ * - bits 0-7 are the preemption count (max preemption depth: 256)
+ * - bits 8-15 are the softirq count (max # of softirqs: 256)
+ *
+ * The hardirq count can be overridden per architecture, the default is:
+ *
+ * - bits 16-27 are the hardirq count (max # of hardirqs: 4096)
+ * - ( bit 28 is the PREEMPT_ACTIVE flag. )
+ *
+ * PREEMPT_MASK: 0x000000ff
+ * SOFTIRQ_MASK: 0x0000ff00
+ * HARDIRQ_MASK: 0x0fff0000
+ */
+#define PREEMPT_BITS	8
+#define SOFTIRQ_BITS	8
+
+#ifndef HARDIRQ_BITS
+#define HARDIRQ_BITS	12
+/*
+ * The hardirq mask has to be large enough to have space for potentially
+ * all IRQ sources in the system nesting on a single CPU.
+ */
+#if (1 << HARDIRQ_BITS) < NR_IRQS
+# error HARDIRQ_BITS is too low!
+#endif
+#endif
+
+#define PREEMPT_SHIFT	0
+#define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
+#define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
+
 #define __IRQ_MASK(x)	((1UL << (x))-1)
 
 #define PREEMPT_MASK	(__IRQ_MASK(PREEMPT_BITS) << PREEMPT_SHIFT)
@@ -41,6 +75,14 @@
 extern void synchronize_irq(unsigned int irq);
 #else
 # define synchronize_irq(irq)	barrier()
+#endif
+
+#ifdef CONFIG_GENERIC_HARDIRQS
+#define nmi_enter()		(preempt_count() += HARDIRQ_OFFSET)
+#define nmi_exit()		(preempt_count() -= HARDIRQ_OFFSET)
+
+#define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
+extern void irq_exit(void);
 #endif
 
 #endif /* LINUX_HARDIRQ_H */
diff -Nru a/include/linux/hdlc.h b/include/linux/hdlc.h
--- a/include/linux/hdlc.h	2004-12-24 13:37:32 -08:00
+++ b/include/linux/hdlc.h	2004-12-24 13:37:32 -08:00
@@ -243,11 +243,15 @@
 static __inline__ unsigned short hdlc_type_trans(struct sk_buff *skb,
 						 struct net_device *dev)
 {
-	hdlc_device *hdlc = dev_to_hdlc(skb->dev);
+	hdlc_device *hdlc = dev_to_hdlc(dev);
+
+	skb->mac.raw  = skb->data;
+	skb->dev      = dev;
+
 	if (hdlc->proto.type_trans)
 		return hdlc->proto.type_trans(skb, dev);
 	else
-		return __constant_htons(ETH_P_HDLC);
+		return htons(ETH_P_HDLC);
 }
 
 #endif /* __KERNEL */
diff -Nru a/include/linux/hdreg.h b/include/linux/hdreg.h
--- a/include/linux/hdreg.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/hdreg.h	2004-12-24 13:36:48 -08:00
@@ -1,6 +1,9 @@
 #ifndef _LINUX_HDREG_H
 #define _LINUX_HDREG_H
 
+#ifdef __KERNEL__
+#include <linux/ata.h>
+
 /*
  * This file contains some defines for the AT-hd-controller.
  * Various sources.
@@ -55,7 +58,7 @@
 #define IO			0x02
 #define REL			0x04
 #define TAG_MASK		0xf8
-
+#endif /* __KERNEL__ */
 
 /*
  * Command Header sizes for IOCTL commands
@@ -328,27 +331,6 @@
 /* WIN_SETFEATURES sub-commands */
 #define SETFEATURES_EN_8BIT	0x01	/* Enable 8-Bit Transfers */
 #define SETFEATURES_EN_WCACHE	0x02	/* Enable write cache */
-#define SETFEATURES_XFER	0x03	/* Set transfer mode */
-#	define XFER_UDMA_7	0x47	/* 0100|0111 */
-#	define XFER_UDMA_6	0x46	/* 0100|0110 */
-#	define XFER_UDMA_5	0x45	/* 0100|0101 */
-#	define XFER_UDMA_4	0x44	/* 0100|0100 */
-#	define XFER_UDMA_3	0x43	/* 0100|0011 */
-#	define XFER_UDMA_2	0x42	/* 0100|0010 */
-#	define XFER_UDMA_1	0x41	/* 0100|0001 */
-#	define XFER_UDMA_0	0x40	/* 0100|0000 */
-#	define XFER_MW_DMA_2	0x22	/* 0010|0010 */
-#	define XFER_MW_DMA_1	0x21	/* 0010|0001 */
-#	define XFER_MW_DMA_0	0x20	/* 0010|0000 */
-#	define XFER_SW_DMA_2	0x12	/* 0001|0010 */
-#	define XFER_SW_DMA_1	0x11	/* 0001|0001 */
-#	define XFER_SW_DMA_0	0x10	/* 0001|0000 */
-#	define XFER_PIO_4	0x0C	/* 0000|1100 */
-#	define XFER_PIO_3	0x0B	/* 0000|1011 */
-#	define XFER_PIO_2	0x0A	/* 0000|1010 */
-#	define XFER_PIO_1	0x09	/* 0000|1001 */
-#	define XFER_PIO_0	0x08	/* 0000|1000 */
-#	define XFER_PIO_SLOW	0x00	/* 0000|0000 */
 #define SETFEATURES_DIS_DEFECT	0x04	/* Disable Defect Management */
 #define SETFEATURES_EN_APM	0x05	/* Enable advanced power management */
 #define SETFEATURES_EN_SAME_R	0x22	/* for a region ATA-1 */
diff -Nru a/include/linux/hpet.h b/include/linux/hpet.h
--- a/include/linux/hpet.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/hpet.h	2004-12-24 13:37:01 -08:00
@@ -112,6 +112,7 @@
 };
 
 struct hpet_data {
+	unsigned long hd_phys_address;
 	void __iomem *hd_address;
 	unsigned short hd_nirqs;
 	unsigned short hd_flags;
diff -Nru a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h
--- a/include/linux/i2c-sensor.h	2004-12-24 13:36:59 -08:00
+++ b/include/linux/i2c-sensor.h	2004-12-24 13:36:59 -08:00
@@ -42,51 +42,25 @@
 /* A structure containing the detect information.
    normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_ISA_END.
      A list of I2C addresses which should normally be examined.
-   normal_i2c_range: filled in by the module writer. Terminated by 
-     I2C_CLIENT_ISA_END
-     A list of pairs of I2C addresses, each pair being an inclusive range of
-     addresses which should normally be examined.
    normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
      A list of ISA addresses which should normally be examined.
-   normal_isa_range: filled in by the module writer. Terminated by 
-     SENSORS_ISA_END
-     A list of triples. The first two elements are ISA addresses, being an
-     range of addresses which should normally be examined. The third is the
-     modulo parameter: only addresses which are 0 module this value relative
-     to the first address of the range are actually considered.
    probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
      A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
      the ISA bus, -1 for any I2C bus), the second is the address. These
      addresses are also probed, as if they were in the 'normal' list.
-   probe_range: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END 
-     values.
-     A list of triples. The first value is a bus number (ANY_I2C_ISA_BUS for
-     the ISA bus, -1 for any I2C bus), the second and third are addresses. 
-     These form an inclusive range of addresses that are also probed, as
-     if they were in the 'normal' list.
    ignore: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
      A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
      the ISA bus, -1 for any I2C bus), the second is the I2C address. These
      addresses are never probed. This parameter overrules 'normal' and 
      'probe', but not the 'force' lists.
-   ignore_range: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END 
-      values.
-     A list of triples. The first value is a bus number (ANY_I2C_ISA_BUS for
-     the ISA bus, -1 for any I2C bus), the second and third are addresses. 
-     These form an inclusive range of I2C addresses that are never probed.
-     This parameter overrules 'normal' and 'probe', but not the 'force' lists.
    force_data: insmod parameters. A list, ending with an element of which
      the force field is NULL.
 */
 struct i2c_address_data {
 	unsigned short *normal_i2c;
-	unsigned short *normal_i2c_range;
 	unsigned int *normal_isa;
-	unsigned int *normal_isa_range;
 	unsigned short *probe;
-	unsigned short *probe_range;
 	unsigned short *ignore;
-	unsigned short *ignore_range;
 	struct i2c_force_data *forces;
 };
 
@@ -100,23 +74,13 @@
 #define SENSORS_INSMOD \
   I2C_CLIENT_MODULE_PARM(probe, \
                       "List of adapter,address pairs to scan additionally"); \
-  I2C_CLIENT_MODULE_PARM(probe_range, \
-                      "List of adapter,start-addr,end-addr triples to scan " \
-                      "additionally"); \
   I2C_CLIENT_MODULE_PARM(ignore, \
                       "List of adapter,address pairs not to scan"); \
-  I2C_CLIENT_MODULE_PARM(ignore_range, \
-                      "List of adapter,start-addr,end-addr triples not to " \
-                      "scan"); \
 	static struct i2c_address_data addr_data = {			\
 			.normal_i2c =		normal_i2c,		\
-			.normal_i2c_range =	normal_i2c_range,	\
 			.normal_isa =		normal_isa,		\
-			.normal_isa_range =	normal_isa_range,	\
 			.probe =		probe,			\
-			.probe_range =		probe_range,		\
 			.ignore =		ignore,			\
-			.ignore_range =		ignore_range,		\
 			.forces =		forces,			\
 		}
 
diff -Nru a/include/linux/i2c-vid.h b/include/linux/i2c-vid.h
--- a/include/linux/i2c-vid.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/i2c-vid.h	2004-12-24 13:36:17 -08:00
@@ -29,7 +29,22 @@
 */
 
 /*
-    Legal val values 00 - 1F.
+    AMD Opteron processors don't follow the Intel VRM spec.
+    I'm going to "make up" 2.4 as the VRM spec for the Opterons.
+    No good reason just a mnemonic for the 24x Opteron processor
+    series
+
+    Opteron VID encoding is:
+
+       00000  =  1.550 V
+       00001  =  1.525 V
+        . . . .
+       11110  =  0.800 V
+       11111  =  0.000 V (off)
+ */
+
+/*
+    Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
     vrm is the Intel VRM document version.
     Note: vrm version is scaled by 10 and the return value is scaled by 1000
     to avoid floating point in the kernel.
@@ -41,9 +56,28 @@
 
 static inline int vid_from_reg(int val, int vrm)
 {
+	int vid;
+
 	switch(vrm) {
+
 	case  0:
 		return 0;
+
+	case 100:               /* VRD 10.0 */
+		if((val & 0x1f) == 0x1f)
+			return 0;
+		if((val & 0x1f) <= 0x09 || val == 0x0a)
+			vid = 10875 - (val & 0x1f) * 250;
+		else
+			vid = 18625 - (val & 0x1f) * 250;
+		if(val & 0x20)
+			vid -= 125;
+		vid /= 10;      /* only return 3 dec. places for now */
+		return vid;
+
+	case 24:                /* Opteron processor */
+		return(val == 0x1f ? 0 : 1550 - val * 25);
+
 	case 91:		/* VRM 9.1 */
 	case 90:		/* VRM 9.0 */
 		return(val == 0x1f ? 0 :
diff -Nru a/include/linux/i2c.h b/include/linux/i2c.h
--- a/include/linux/i2c.h	2004-12-24 13:36:19 -08:00
+++ b/include/linux/i2c.h	2004-12-24 13:36:19 -08:00
@@ -88,20 +88,12 @@
 extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
 extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
                                      u8 command, u16 value);
-extern s32 i2c_smbus_process_call(struct i2c_client * client,
-                                  u8 command, u16 value);
-/* Returns the number of read bytes */
-extern s32 i2c_smbus_read_block_data(struct i2c_client * client,
-                                     u8 command, u8 *values);
+/* Returns the number of bytes transferred */
 extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
-                                      u8 command, u8 length,
-                                      u8 *values);
+				      u8 command, u8 length,
+				      u8 *values);
 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
-                                         u8 command, u8 *values);
-extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
-                                          u8 command, u8 length,
-                                          u8 *values);
-
+					 u8 command, u8 *values);
 
 /*
  * A driver is capable of handling one or more physical devices present on
@@ -568,7 +560,7 @@
   static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
   static unsigned int var##_num; \
   /*MODULE_PARM(var,I2C_CLIENT_MODPARM);*/ \
-  module_param_array(var, short, var##_num, 0); \
+  module_param_array(var, short, &var##_num, 0); \
   MODULE_PARM_DESC(var,desc)
 
 /* This is the one you want to use in your own modules */
diff -Nru a/include/linux/i2o.h b/include/linux/i2o.h
--- a/include/linux/i2o.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/i2o.h	2004-12-24 13:36:31 -08:00
@@ -147,10 +147,10 @@
 
 	struct pci_dev *pdev;	/* PCI device */
 
-	int short_req:1;	/* use small block sizes */
-	int no_quiesce:1;	/* dont quiesce before reset */
-	int raptor:1;		/* split bar */
-	int promise:1;		/* Promise controller */
+	unsigned int short_req:1;	/* use small block sizes */
+	unsigned int no_quiesce:1;	/* dont quiesce before reset */
+	unsigned int raptor:1;		/* split bar */
+	unsigned int promise:1;		/* Promise controller */
 
 #ifdef CONFIG_MTRR
 	int mtrr_reg0;
@@ -162,9 +162,9 @@
 	struct notifier_block *event_notifer;	/* Events */
 	atomic_t users;
 	struct list_head list;	/* Controller list */
-	void *post_port;	/* Inbout port address */
-	void *reply_port;	/* Outbound port address */
-	void *irq_mask;		/* Interrupt register address */
+	void __iomem *post_port;	/* Inbout port address */
+	void __iomem *reply_port;	/* Outbound port address */
+	void __iomem *irq_mask;		/* Interrupt register address */
 
 	/* Dynamic LCT related data */
 
@@ -180,9 +180,9 @@
 	struct i2o_dma in_queue;	/* inbound message queue Host->IOP */
 	struct i2o_dma out_queue;	/* outbound message queue IOP->Host */
 
-	int battery:1;		/* Has a battery backup */
-	int io_alloc:1;		/* An I/O resource was allocated */
-	int mem_alloc:1;	/* A memory resource was allocated */
+	unsigned int battery:1;		/* Has a battery backup */
+	unsigned int io_alloc:1;	/* An I/O resource was allocated */
+	unsigned int mem_alloc:1;	/* A memory resource was allocated */
 
 	struct resource io_resource;	/* I/O resource allocated to the IOP */
 	struct resource mem_resource;	/* Mem resource allocated to the IOP */
@@ -241,8 +241,8 @@
 extern struct list_head i2o_controllers;
 
 /* Message functions */
-static inline u32 i2o_msg_get(struct i2o_controller *, struct i2o_message **);
-extern u32 i2o_msg_get_wait(struct i2o_controller *, struct i2o_message **,
+static inline u32 i2o_msg_get(struct i2o_controller *, struct i2o_message __iomem **);
+extern u32 i2o_msg_get_wait(struct i2o_controller *, struct i2o_message __iomem **,
 			    int);
 static inline void i2o_msg_post(struct i2o_controller *, u32);
 static inline int i2o_msg_post_wait(struct i2o_controller *, u32,
@@ -263,7 +263,6 @@
 
 /* IOP functions */
 extern int i2o_status_get(struct i2o_controller *);
-extern int i2o_hrt_get(struct i2o_controller *);
 
 extern int i2o_event_register(struct i2o_device *, struct i2o_driver *, int,
 			      u32);
@@ -385,7 +384,6 @@
 
 /* Exec OSM functions */
 extern int i2o_exec_lct_get(struct i2o_controller *);
-extern int i2o_exec_lct_notify(struct i2o_controller *, u32);
 
 /* device to i2o_device and driver to i2o_driver convertion functions */
 #define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver)
@@ -445,7 +443,7 @@
  *	available returns I2O_QUEUE_EMPTY and msg is leaved untouched.
  */
 static inline u32 i2o_msg_get(struct i2o_controller *c,
-			      struct i2o_message **msg)
+			      struct i2o_message __iomem **msg)
 {
 	u32 m;
 
@@ -502,6 +500,43 @@
 };
 
 /**
+ *	i2o_out_to_virt - Turn an I2O message to a virtual address
+ *	@c: controller
+ *	@m: message engine value
+ *
+ *	Turn a receive message from an I2O controller bus address into
+ *	a Linux virtual address. The shared page frame is a linear block
+ *	so we simply have to shift the offset. This function does not
+ *	work for sender side messages as they are ioremap objects
+ *	provided by the I2O controller.
+ */
+static inline struct i2o_message *i2o_msg_out_to_virt(struct i2o_controller *c,
+						      u32 m)
+{
+	BUG_ON(m < c->out_queue.phys
+	       || m >= c->out_queue.phys + c->out_queue.len);
+
+	return c->out_queue.virt + (m - c->out_queue.phys);
+};
+
+/**
+ *	i2o_msg_in_to_virt - Turn an I2O message to a virtual address
+ *	@c: controller
+ *	@m: message engine value
+ *
+ *	Turn a send message from an I2O controller bus address into
+ *	a Linux virtual address. The shared page frame is a linear block
+ *	so we simply have to shift the offset. This function does not
+ *	work for receive side messages as they are kmalloc objects
+ *	in a different pool.
+ */
+static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct i2o_controller *c,
+						     u32 m)
+{
+	return c->in_queue.virt + m;
+};
+
+/**
  *	i2o_dma_alloc - Allocate DMA memory
  *	@dev: struct device pointer to the PCI device of the I2O controller
  *	@addr: i2o_dma struct which should get the DMA buffer
@@ -594,7 +629,6 @@
 #define i2o_raw_writel(val, mem)	__raw_writel(cpu_to_le32(val), mem)
 
 extern int i2o_parm_field_get(struct i2o_device *, int, int, void *, int);
-extern int i2o_parm_field_set(struct i2o_device *, int, int, void *, int);
 extern int i2o_parm_table_get(struct i2o_device *, int, int, int, void *, int,
 			      void *, int);
 /* FIXME: remove
@@ -942,7 +976,7 @@
 #define I2O_TIMEOUT_MESSAGE_GET		5
 #define I2O_TIMEOUT_RESET		30
 #define I2O_TIMEOUT_STATUS_GET		5
-#define I2O_TIMEOUT_LCT_GET		20
+#define I2O_TIMEOUT_LCT_GET		360
 #define I2O_TIMEOUT_SCSI_SCB_ABORT	240
 
 /* retries */
diff -Nru a/include/linux/icmp.h b/include/linux/icmp.h
--- a/include/linux/icmp.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/icmp.h	2004-12-24 13:37:18 -08:00
@@ -17,6 +17,8 @@
 #ifndef _LINUX_ICMP_H
 #define	_LINUX_ICMP_H
 
+#include <linux/types.h>
+
 #define ICMP_ECHOREPLY		0	/* Echo Reply			*/
 #define ICMP_DEST_UNREACH	3	/* Destination Unreachable	*/
 #define ICMP_SOURCE_QUENCH	4	/* Source Quench		*/
diff -Nru a/include/linux/ide.h b/include/linux/ide.h
--- a/include/linux/ide.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/ide.h	2004-12-24 13:36:47 -08:00
@@ -39,7 +39,6 @@
  *
  * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary
  */
-#define REALLY_FAST_IO			/* define if ide ports are perfect */
 #define INITIAL_MULT_COUNT	0	/* off=0; on=2,4,8,16,32, etc.. */
 
 #ifndef SUPPORT_SLOW_DATA_PORTS		/* 1 to support slow data ports */
@@ -64,18 +63,6 @@
 #define IDE_NO_IRQ		(-1)
 
 /*
- * IDE_DRIVE_CMD is used to implement many features of the hdparm utility
- */
-#define IDE_DRIVE_CMD			99	/* (magic) undef to reduce kernel size*/
-
-#define IDE_DRIVE_TASK			98
-
-/*
- * IDE_DRIVE_TASKFILE is used to implement many features needed for raw tasks
- */
-#define IDE_DRIVE_TASKFILE		97
-
-/*
  *  "No user-serviceable parts" beyond this point  :)
  *****************************************************************************/
 
@@ -101,13 +88,6 @@
 
 #define DMA_PIO_RETRY	1	/* retrying in PIO */
 
-/*
- * Ensure that various configuration flags have compatible settings
- */
-#ifdef REALLY_SLOW_IO
-#undef REALLY_FAST_IO
-#endif
-
 #define HWIF(drive)		((ide_hwif_t *)((drive)->hwif))
 #define HWGROUP(drive)		((ide_hwgroup_t *)(HWIF(drive)->hwgroup))
 
@@ -197,10 +177,7 @@
 /*
  * Some more useful definitions
  */
-#define IDE_MAJOR_NAME	"hd"	/* the same for all i/f; see also genhd.c */
-#define MAJOR_NAME	IDE_MAJOR_NAME
 #define PARTN_BITS	6	/* number of minor dev bits for partitions */
-#define PARTN_MASK	((1<<PARTN_BITS)-1)	/* a useful bit mask */
 #define MAX_DRIVES	2	/* per interface; 2 assumed by lots of code */
 #define SECTOR_SIZE	512
 #define SECTOR_WORDS	(SECTOR_SIZE / 4)	/* number of 32bit words per sector */
@@ -242,7 +219,7 @@
 typedef enum {	ide_unknown,	ide_generic,	ide_pci,
 		ide_cmd640,	ide_dtc2278,	ide_ali14xx,
 		ide_qd65xx,	ide_umc8672,	ide_ht6560b,
-		ide_pdc4030,	ide_rz1000,	ide_trm290,
+		ide_rz1000,	ide_trm290,
 		ide_cmd646,	ide_cy82c693,	ide_4drives,
 		ide_pmac,	ide_etrax100,	ide_acorn,
 		ide_forced
@@ -256,16 +233,14 @@
 	int		irq;			/* our irq number */
 	int		dma;			/* our dma entry */
 	ide_ack_intr_t	*ack_intr;		/* acknowledge interrupt */
-	void		*priv;			/* interface specific data */
 	hwif_chipset_t  chipset;
-	unsigned long	sata_scr[SATA_NR_PORTS];
-	unsigned long	sata_misc[SATA_NR_PORTS];
 } hw_regs_t;
 
 /*
  * Register new hardware with ide
  */
 int ide_register_hw(hw_regs_t *hw, struct hwif_s **hwifp);
+int ide_register_hw_with_fixup(hw_regs_t *, struct hwif_s **, void (*)(struct hwif_s *));
 
 /*
  * Set up hw_regs_t structure before calling ide_register_hw (optional)
@@ -739,7 +714,6 @@
 	unsigned remap_0_to_1	: 1;	/* 0=noremap, 1=remap 0->1 (for EZDrive) */
 	unsigned blocked        : 1;	/* 1=powermanagment told us not to do anything, so sleep nicely */
 	unsigned vdma		: 1;	/* 1=doing PIO over DMA 0=doing normal DMA */
-	unsigned stroke		: 1;	/* from:  hdx=stroke */
 	unsigned addressing;		/*      : 3;
 					 *  0=28-bit
 					 *  1=48-bit
@@ -789,27 +763,6 @@
 	struct gendisk *disk;
 } ide_drive_t;
 
-/*
- * mapping stuff, prepare for highmem...
- * 
- * temporarily mapping a (possible) highmem bio for PIO transfer
- */
-#ifndef CONFIG_IDE_TASKFILE_IO
-
-#define ide_rq_offset(rq) \
-	(((rq)->hard_cur_sectors - (rq)->current_nr_sectors) << 9)
-
-static inline void *ide_map_buffer(struct request *rq, unsigned long *flags)
-{
-	return bio_kmap_irq(rq->bio, flags) + ide_rq_offset(rq);
-}
-
-static inline void ide_unmap_buffer(struct request *rq, char *buffer, unsigned long *flags)
-{
-	bio_kunmap_irq(buffer, flags);
-}
-#endif /* !CONFIG_IDE_TASKFILE_IO */
-
 #define IDE_CHIPSET_PCI_MASK	\
     ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
 #define IDE_CHIPSET_IS_PCI(c)	((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
@@ -853,8 +806,6 @@
 #if 0
 	ide_hwif_ops_t	*hwifops;
 #else
-	/* routine is for HBA specific IDENTITY operations */
-	int	(*identify)(ide_drive_t *);
 	/* routine to tune PIO mode for drives */
 	void	(*tuneproc)(ide_drive_t *, u8);
 	/* routine to retune DMA modes for drives */
@@ -887,9 +838,9 @@
 	void (*atapi_input_bytes)(ide_drive_t *, void *, u32);
 	void (*atapi_output_bytes)(ide_drive_t *, void *, u32);
 
-	int (*ide_dma_read)(ide_drive_t *drive);
-	int (*ide_dma_write)(ide_drive_t *drive);
-	int (*ide_dma_begin)(ide_drive_t *drive);
+	int (*dma_setup)(ide_drive_t *);
+	void (*dma_exec_cmd)(ide_drive_t *, u8);
+	void (*dma_start)(ide_drive_t *);
 	int (*ide_dma_end)(ide_drive_t *drive);
 	int (*ide_dma_check)(ide_drive_t *drive);
 	int (*ide_dma_on)(ide_drive_t *drive);
@@ -897,7 +848,6 @@
 	int (*ide_dma_test_irq)(ide_drive_t *drive);
 	int (*ide_dma_host_on)(ide_drive_t *drive);
 	int (*ide_dma_host_off)(ide_drive_t *drive);
-	int (*ide_dma_verbose)(ide_drive_t *drive);
 	int (*ide_dma_lostirq)(ide_drive_t *drive);
 	int (*ide_dma_timeout)(ide_drive_t *drive);
 
@@ -920,12 +870,18 @@
 	dma_addr_t	dmatable_dma;
 	/* Scatter-gather list used to build the above */
 	struct scatterlist *sg_table;
+	int sg_max_nents;		/* Maximum number of entries in it */
 	int sg_nents;			/* Current number of entries in it */
 	int sg_dma_direction;		/* dma transfer direction */
 
 	/* data phase of the active command (currently only valid for PIO/DMA) */
 	int		data_phase;
 
+	unsigned int nsect;
+	unsigned int nleft;
+	unsigned int cursg;
+	unsigned int cursg_ofs;
+
 	int		mmio;		/* hosts iomio (0) or custom (2) select */
 	int		rqsize;		/* max sectors per request */
 	int		irq;		/* our irq number */
@@ -955,6 +911,7 @@
 	unsigned	no_lba48_dma : 1; /* 1 = cannot do LBA48 DMA */
 	unsigned	no_dsc     : 1;	/* 0 default, 1 dsc_overlap disabled */
 	unsigned	auto_poll  : 1; /* supports nop auto-poll */
+	unsigned	sg_mapped  : 1;	/* sg_table and sg_nents are ready */
 
 	struct device	gendev;
 	struct semaphore gendev_rel_sem; /* To deal with device release() */
@@ -1062,8 +1019,8 @@
 
 extern void proc_ide_create(void);
 extern void proc_ide_destroy(void);
-extern void destroy_proc_ide_drives(ide_hwif_t *);
 extern void create_proc_ide_interfaces(void);
+void destroy_proc_ide_interface(ide_hwif_t *);
 extern void ide_add_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *, void *);
 extern void ide_remove_proc_entries(struct proc_dir_entry *, ide_proc_entry_t *);
 read_proc_t proc_ide_read_capacity;
@@ -1090,6 +1047,7 @@
 }
 #else
 static inline void create_proc_ide_interfaces(void) { ; }
+static inline void destroy_proc_ide_interface(ide_hwif_t *hwif) { ; }
 #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
 #endif
 
@@ -1211,14 +1169,6 @@
  */
 extern ide_startstop_t ide_abort(ide_drive_t *, const char *);
 
-/*
- * Issue a simple drive command
- * The drive must be selected beforehand.
- *
- * (drive, command, nsector, handler)
- */
-extern void ide_cmd(ide_drive_t *, u8, u8, ide_handler_t *);
-
 extern void ide_fix_driveid(struct hd_driveid *);
 /*
  * ide_fixstring() cleans up and (optionally) byte-swaps a text string,
@@ -1319,9 +1269,6 @@
  */
 extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *);
 
-/* (ide_drive_t *drive, u8 *buf) */
-extern int ide_wait_cmd_task(ide_drive_t *, u8 *);
-
 typedef struct ide_task_s {
 /*
  *	struct hd_drive_task_hdr	tf;
@@ -1366,37 +1313,6 @@
 extern void ata_output_data(ide_drive_t *, void *, u32);
 extern void atapi_input_bytes(ide_drive_t *, void *, u32);
 extern void atapi_output_bytes(ide_drive_t *, void *, u32);
-extern void taskfile_input_data(ide_drive_t *, void *, u32);
-extern void taskfile_output_data(ide_drive_t *, void *, u32);
-
-#define IDE_PIO_IN	0
-#define IDE_PIO_OUT	1
-
-static inline void __task_sectors(ide_drive_t *drive, char *buf,
-				  unsigned nsect, unsigned rw)
-{
-	/*
-	 * IRQ can happen instantly after reading/writing
-	 * last sector of the datablock.
-	 */
-	if (rw == IDE_PIO_OUT)
-		taskfile_output_data(drive, buf, nsect * SECTOR_WORDS);
-	else
-		taskfile_input_data(drive, buf, nsect * SECTOR_WORDS);
-}
-
-#ifdef CONFIG_IDE_TASKFILE_IO
-static inline void task_bio_sectors(ide_drive_t *drive, struct request *rq,
-				    unsigned nsect, unsigned rw)
-{
-	unsigned long flags;
-	char *buf = rq_map_buffer(rq, &flags);
-
-	process_that_request_first(rq, nsect);
-	__task_sectors(drive, buf, nsect, rw);
-	rq_unmap_buffer(buf, &flags);
-}
-#endif /* CONFIG_IDE_TASKFILE_IO */
 
 extern int drive_is_ready(ide_drive_t *);
 extern int wait_for_ready(ide_drive_t *, int /* timeout */);
@@ -1417,7 +1333,6 @@
 extern ide_startstop_t task_no_data_intr(ide_drive_t *);
 extern ide_startstop_t task_in_intr(ide_drive_t *);
 extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);
-extern ide_startstop_t task_out_intr(ide_drive_t *);
 
 extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *);
 
@@ -1427,7 +1342,6 @@
 
 extern int system_bus_clock(void);
 
-extern u8 ide_auto_reduce_xfer(ide_drive_t *);
 extern int ide_driveid_update(ide_drive_t *);
 extern int ide_ata66_check(ide_drive_t *, ide_task_t *);
 extern int ide_config_drive_speed(ide_drive_t *, u8);
@@ -1468,7 +1382,7 @@
 extern void ide_scan_pcibus(int scan_direction) __init;
 extern int ide_pci_register_driver(struct pci_driver *driver);
 extern void ide_pci_unregister_driver(struct pci_driver *driver);
-extern void ide_pci_setup_ports(struct pci_dev *dev, struct ide_pci_device_s *d, int autodma, int pciirq, ata_index_t *index);
+void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, ata_index_t *);
 extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d);
 
 extern void default_hwif_iops(ide_hwif_t *);
@@ -1503,9 +1417,7 @@
 enum {
 	/* Uses ISA control ports not PCI ones. */
 	IDEPCI_FLAG_ISA_PORTS		= (1 << 0),
-
-	IDEPCI_FLAG_FORCE_MASTER	= (1 << 1),
-	IDEPCI_FLAG_FORCE_PDC		= (1 << 2),
+	IDEPCI_FLAG_FORCE_PDC		= (1 << 1),
 };
 
 typedef struct ide_pci_device_s {
@@ -1516,6 +1428,7 @@
 	void			(*init_iops)(ide_hwif_t *);
 	void                    (*init_hwif)(ide_hwif_t *);
 	void			(*init_dma)(ide_hwif_t *, unsigned long);
+	void			(*fixup)(ide_hwif_t *);
 	u8			channels;
 	u8			autodma;
 	ide_pci_enablebit_t	enablebits[2];
@@ -1528,41 +1441,44 @@
 extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
 extern void ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, ide_pci_device_t *);
 
+void ide_map_sg(ide_drive_t *, struct request *);
+void ide_init_sg_cmd(ide_drive_t *, struct request *);
+
 #define BAD_DMA_DRIVE		0
 #define GOOD_DMA_DRIVE		1
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
 int __ide_dma_bad_drive(ide_drive_t *);
 int __ide_dma_good_drive(ide_drive_t *);
+int ide_use_dma(ide_drive_t *);
 int __ide_dma_off(ide_drive_t *);
+void ide_dma_verbose(ide_drive_t *);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
 extern int ide_build_sglist(ide_drive_t *, struct request *);
-extern int ide_raw_build_sglist(ide_drive_t *, struct request *);
 extern int ide_build_dmatable(ide_drive_t *, struct request *);
 extern void ide_destroy_dmatable(ide_drive_t *);
 extern ide_startstop_t ide_dma_intr(ide_drive_t *);
 extern int ide_release_dma(ide_hwif_t *);
 extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int);
-extern int ide_start_dma(ide_hwif_t *, ide_drive_t *, int);
 
 extern int __ide_dma_host_off(ide_drive_t *);
 extern int __ide_dma_off_quietly(ide_drive_t *);
 extern int __ide_dma_host_on(ide_drive_t *);
 extern int __ide_dma_on(ide_drive_t *);
 extern int __ide_dma_check(ide_drive_t *);
-extern int __ide_dma_read(ide_drive_t *);
-extern int __ide_dma_write(ide_drive_t *);
-extern int __ide_dma_begin(ide_drive_t *);
+extern int ide_dma_setup(ide_drive_t *);
+extern void ide_dma_start(ide_drive_t *);
 extern int __ide_dma_end(ide_drive_t *);
 extern int __ide_dma_test_irq(ide_drive_t *);
-extern int __ide_dma_verbose(ide_drive_t *);
 extern int __ide_dma_lostirq(ide_drive_t *);
 extern int __ide_dma_timeout(ide_drive_t *);
 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
 
 #else
+static inline int ide_use_dma(ide_drive_t *drive) { return 0; }
 static inline int __ide_dma_off(ide_drive_t *drive) { return 0; }
+static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
 #ifndef CONFIG_BLK_DEV_IDEDMA_PCI
@@ -1573,6 +1489,9 @@
 extern void ide_hwif_release_regions(ide_hwif_t* hwif);
 extern void ide_unregister (unsigned int index);
 
+void ide_undecoded_slave(ide_hwif_t *);
+
+int probe_hwif_init_with_fixup(ide_hwif_t *, void (*)(ide_hwif_t *));
 extern int probe_hwif_init(ide_hwif_t *);
 
 static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
diff -Nru a/include/linux/idr.h b/include/linux/idr.h
--- a/include/linux/idr.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/idr.h	2004-12-24 13:36:18 -08:00
@@ -9,7 +9,7 @@
  * tables.
  */
 #include <linux/types.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 #if BITS_PER_LONG == 32
 # define IDR_BITS 5
diff -Nru a/include/linux/if_ppp.h b/include/linux/if_ppp.h
--- a/include/linux/if_ppp.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/if_ppp.h	2004-12-24 13:37:19 -08:00
@@ -92,7 +92,7 @@
 
 /* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
 struct ppp_option_data {
-	__u8	*ptr;
+	__u8	__user *ptr;
 	__u32	length;
 	int	transmit;
 };
diff -Nru a/include/linux/if_vlan.h b/include/linux/if_vlan.h
--- a/include/linux/if_vlan.h	2004-12-24 13:36:30 -08:00
+++ b/include/linux/if_vlan.h	2004-12-24 13:36:30 -08:00
@@ -366,7 +366,9 @@
 	GET_VLAN_INGRESS_PRIORITY_CMD,
 	GET_VLAN_EGRESS_PRIORITY_CMD,
 	SET_VLAN_NAME_TYPE_CMD,
-	SET_VLAN_FLAG_CMD
+	SET_VLAN_FLAG_CMD,
+	GET_VLAN_REALDEV_NAME_CMD, /* If this works, you know it's a VLAN device, btw */
+	GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */
 };
 
 enum vlan_name_types {
diff -Nru a/include/linux/inet.h b/include/linux/inet.h
--- a/include/linux/inet.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/inet.h	2004-12-24 13:36:31 -08:00
@@ -43,6 +43,8 @@
 #define _LINUX_INET_H
 
 #ifdef __KERNEL__
+#include <linux/types.h>
+
 extern __u32 in_aton(const char *str);
 #endif
 #endif	/* _LINUX_INET_H */
diff -Nru a/include/linux/inetdevice.h b/include/linux/inetdevice.h
--- a/include/linux/inetdevice.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/inetdevice.h	2004-12-24 13:37:01 -08:00
@@ -3,7 +3,10 @@
 
 #ifdef __KERNEL__
 
+#include <linux/if.h>
+#include <linux/netdevice.h>
 #include <linux/rcupdate.h>
+#include <linux/timer.h>
 
 struct ipv4_devconf
 {
diff -Nru a/include/linux/init_task.h b/include/linux/init_task.h
--- a/include/linux/init_task.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/init_task.h	2004-12-24 13:36:18 -08:00
@@ -50,6 +50,7 @@
 		.list = LIST_HEAD_INIT(sig.shared_pending.list),	\
 		.signal =  {{0}}}, \
 	.posix_timers	 = LIST_HEAD_INIT(sig.posix_timers),		\
+	.rlim		= INIT_RLIMITS,					\
 }
 
 #define INIT_SIGHAND(sighand) {	\
@@ -96,7 +97,6 @@
 	.cap_inheritable = CAP_INIT_INH_SET,				\
 	.cap_permitted	= CAP_FULL_SET,					\
 	.keep_capabilities = 0,						\
-	.rlim		= INIT_RLIMITS,					\
 	.user		= INIT_USER,					\
 	.comm		= "swapper",					\
 	.thread		= INIT_THREAD,					\
diff -Nru a/include/linux/input.h b/include/linux/input.h
--- a/include/linux/input.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/input.h	2004-12-24 13:36:48 -08:00
@@ -473,6 +473,28 @@
 #define KEY_INS_LINE		0x1c2
 #define KEY_DEL_LINE		0x1c3
 
+#define KEY_FN			0x1d0
+#define KEY_FN_ESC		0x1d1
+#define KEY_FN_F1		0x1d2
+#define KEY_FN_F2		0x1d3
+#define KEY_FN_F3		0x1d4
+#define KEY_FN_F4		0x1d5
+#define KEY_FN_F5		0x1d6
+#define KEY_FN_F6		0x1d7
+#define KEY_FN_F7		0x1d8
+#define KEY_FN_F8		0x1d9
+#define KEY_FN_F9		0x1da
+#define KEY_FN_F10		0x1db
+#define KEY_FN_F11		0x1dc
+#define KEY_FN_F12		0x1dd
+#define KEY_FN_1		0x1de
+#define KEY_FN_2		0x1df
+#define KEY_FN_D		0x1e0
+#define KEY_FN_E		0x1e1
+#define KEY_FN_F		0x1e2
+#define KEY_FN_S		0x1e3
+#define KEY_FN_B		0x1e4
+
 #define KEY_MAX			0x1ff
 
 /*
diff -Nru a/include/linux/interrupt.h b/include/linux/interrupt.h
--- a/include/linux/interrupt.h	2004-12-24 13:36:55 -08:00
+++ b/include/linux/interrupt.h	2004-12-24 13:36:55 -08:00
@@ -40,6 +40,8 @@
 	const char *name;
 	void *dev_id;
 	struct irqaction *next;
+	int irq;
+	struct proc_dir_entry *dir;
 };
 
 extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
@@ -48,6 +50,13 @@
 		       unsigned long, const char *, void *);
 extern void free_irq(unsigned int, void *);
 
+
+#ifdef CONFIG_GENERIC_HARDIRQS
+extern void disable_irq_nosync(unsigned int irq);
+extern void disable_irq(unsigned int irq);
+extern void enable_irq(unsigned int irq);
+#endif
+
 /*
  * Temporary defines for UP kernels, until all code gets fixed.
  */
@@ -100,10 +109,6 @@
 extern void FASTCALL(raise_softirq_irqoff(unsigned int nr));
 extern void FASTCALL(raise_softirq(unsigned int nr));
 
-#ifndef invoke_softirq
-#define invoke_softirq() do_softirq()
-#endif
-
 
 /* Tasklets --- multithreaded analogue of BHs.
 
@@ -243,8 +248,24 @@
  * or zero if none occurred, or a negative irq number
  * if more than one irq occurred.
  */
+
+#if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE) 
+static inline unsigned long probe_irq_on(void)
+{
+	return 0;
+}
+static inline int probe_irq_off(unsigned long val)
+{
+	return 0;
+}
+static inline unsigned int probe_irq_mask(unsigned long val)
+{
+	return 0;
+}
+#else
 extern unsigned long probe_irq_on(void);	/* returns 0 on failure */
 extern int probe_irq_off(unsigned long);	/* returns 0 or negative on failure */
 extern unsigned int probe_irq_mask(unsigned long);	/* returns mask of ISA interrupts */
+#endif
 
 #endif
diff -Nru a/include/linux/ioport.h b/include/linux/ioport.h
--- a/include/linux/ioport.h	2004-12-24 13:36:30 -08:00
+++ b/include/linux/ioport.h	2004-12-24 13:36:30 -08:00
@@ -82,6 +82,11 @@
 #define IORESOURCE_MEM_SHADOWABLE	(1<<5)	/* dup: IORESOURCE_SHADOWABLE */
 #define IORESOURCE_MEM_EXPANSIONROM	(1<<6)
 
+/* PCI ROM control bits (IORESOURCE_BITS) */
+#define IORESOURCE_ROM_ENABLE		(1<<0)	/* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
+#define IORESOURCE_ROM_SHADOW		(1<<1)	/* ROM is copy at C000:0 */
+#define IORESOURCE_ROM_COPY		(1<<2)	/* ROM is alloc'd copy, resource field overlaid */
+
 /* PC/ISA/whatever - the normal PC address spaces: IO and memory */
 extern struct resource ioport_resource;
 extern struct resource iomem_resource;
diff -Nru a/include/linux/ipmi.h b/include/linux/ipmi.h
--- a/include/linux/ipmi.h	2004-12-24 13:37:32 -08:00
+++ b/include/linux/ipmi.h	2004-12-24 13:37:32 -08:00
@@ -124,7 +124,7 @@
  * In this address, the remote_SWID is always the SWID the remote
  * message came from, or the SWID we are sending the message to.
  * local_SWID is always our SWID.  Note that having our SWID in the
- * message is a little wierd, but this is required.
+ * message is a little weird, but this is required.
  */
 #define IPMI_LAN_ADDR_TYPE		0x04
 struct ipmi_lan_addr
diff -Nru a/include/linux/ipmi_msgdefs.h b/include/linux/ipmi_msgdefs.h
--- a/include/linux/ipmi_msgdefs.h	2004-12-24 13:37:03 -08:00
+++ b/include/linux/ipmi_msgdefs.h	2004-12-24 13:37:03 -08:00
@@ -66,7 +66,7 @@
  * one transfer.  Its "virtual" BMC supports some commands that are longer
  * than 128 bytes.  Use the full 256, plus NetFn/LUN, Cmd, cCode, plus
  * some overhead.  It would be nice to base this on the "BT Capabilities"
- * but that's too hard to propogate to the rest of the driver. */
+ * but that's too hard to propagate to the rest of the driver. */
 #define IPMI_MAX_MSG_LENGTH	272	/* multiple of 16 */
 
 #define IPMI_CC_NO_ERROR		0x00
diff -Nru a/include/linux/ipv6_route.h b/include/linux/ipv6_route.h
--- a/include/linux/ipv6_route.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/ipv6_route.h	2004-12-24 13:36:31 -08:00
@@ -14,7 +14,8 @@
 #define _LINUX_IPV6_ROUTE_H
 
 #define RTF_DEFAULT	0x00010000	/* default - learned via ND	*/
-#define RTF_ALLONLINK	0x00020000	/* fallback, no routers on link	*/
+#define RTF_ALLONLINK	0x00020000	/* (deprecated and will be removed)
+					   fallback, no routers on link */
 #define RTF_ADDRCONF	0x00040000	/* addrconf route - RA		*/
 #define RTF_PREFIX_RT	0x00080000	/* A prefix only route - RA	*/
 
diff -Nru a/include/linux/irq.h b/include/linux/irq.h
--- a/include/linux/irq.h	2004-12-24 13:37:43 -08:00
+++ b/include/linux/irq.h	2004-12-24 13:37:43 -08:00
@@ -13,6 +13,7 @@
 
 #if !defined(CONFIG_ARCH_S390)
 
+#include <linux/linkage.h>
 #include <linux/cache.h>
 #include <linux/spinlock.h>
 #include <linux/cpumask.h>
@@ -71,7 +72,22 @@
 
 #include <asm/hw_irq.h> /* the arch dependent stuff */
 
-extern int setup_irq(unsigned int , struct irqaction * );
+extern int setup_irq(unsigned int irq, struct irqaction * new);
+
+#ifdef CONFIG_GENERIC_HARDIRQS
+extern cpumask_t irq_affinity[NR_IRQS];
+extern int no_irq_affinity;
+extern int noirqdebug_setup(char *str);
+
+extern fastcall int handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
+				       struct irqaction *action);
+extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
+extern void note_interrupt(unsigned int irq, irq_desc_t *desc, int action_ret);
+extern void report_bad_irq(unsigned int irq, irq_desc_t *desc, int action_ret);
+extern int can_request_irq(unsigned int irq, unsigned long irqflags);
+
+extern void init_irq_proc(void);
+#endif
 
 extern hw_irq_controller no_irq_type;  /* needed in every arch ? */
 
diff -Nru a/include/linux/jbd.h b/include/linux/jbd.h
--- a/include/linux/jbd.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/jbd.h	2004-12-24 13:37:18 -08:00
@@ -299,6 +299,7 @@
 	BH_JBDDirty,		/* Is dirty but journaled */
 	BH_State,		/* Pins most journal_head state */
 	BH_JournalHead,		/* Pins bh->b_private and jh->b_bh */
+	BH_Unshadow,		/* Dummy bit, for BJ_Shadow wakeup filtering */
 };
 
 BUFFER_FNS(JBD, jbd)
@@ -351,27 +352,6 @@
 	bit_spin_unlock(BH_JournalHead, &bh->b_state);
 }
 
-#define HAVE_JOURNAL_CALLBACK_STATUS
-/**
- *   struct journal_callback - Base structure for callback information.
- *   @jcb_list: list information for other callbacks attached to the same handle.
- *   @jcb_func: Function to call with this callback structure. 
- *
- *   This struct is a 'seed' structure for a using with your own callback
- *   structs. If you are using callbacks you must allocate one of these
- *   or another struct of your own definition which has this struct 
- *   as it's first element and pass it to journal_callback_set().
- *
- *   This is used internally by jbd to maintain callback information.
- *
- *   See journal_callback_set for more information.
- **/
-struct journal_callback {
-	struct list_head jcb_list;		/* t_jcb_lock */
-	void (*jcb_func)(struct journal_callback *jcb, int error);
-	/* user data goes here */
-};
-
 struct jbd_revoke_table_s;
 
 /**
@@ -380,7 +360,6 @@
  * @h_transaction: Which compound transaction is this update a part of?
  * @h_buffer_credits: Number of remaining buffers we are allowed to dirty.
  * @h_ref: Reference count on this handle
- * @h_jcb: List of application registered callbacks for this handle.
  * @h_err: Field for caller's use to track errors through large fs operations
  * @h_sync: flag for sync-on-close
  * @h_jdata: flag to force data journaling
@@ -406,13 +385,6 @@
 	/* operations */
 	int			h_err;
 
-	/*
-	 * List of application registered callbacks for this handle. The
-	 * function(s) will be called after the transaction that this handle is
-	 * part of has been committed to disk. [t_jcb_lock]
-	 */
-	struct list_head	h_jcb;
-
 	/* Flags [no locking] */
 	unsigned int	h_sync:		1;	/* sync-on-close */
 	unsigned int	h_jdata:	1;	/* force data journaling */
@@ -454,8 +426,6 @@
  *    j_state_lock
  *    ->j_list_lock			(journal_unmap_buffer)
  *
- *    t_handle_lock
- *    ->t_jcb_lock
  */
 
 struct transaction_s 
@@ -579,15 +549,6 @@
 	 */
 	int t_handle_count;
 
-	/*
-	 * Protects the callback list
-	 */
-	spinlock_t		t_jcb_lock;
-	/*
-	 * List of registered callback functions for this transaction.
-	 * Called when the transaction is committed. [t_jcb_lock]
-	 */
-	struct list_head	t_jcb;
 };
 
 /**
@@ -920,10 +881,6 @@
 extern int	 journal_try_to_free_buffers(journal_t *, struct page *, int);
 extern int	 journal_stop(handle_t *);
 extern int	 journal_flush (journal_t *);
-extern void	 journal_callback_set(handle_t *handle,
-				      void (*fn)(struct journal_callback *,int),
-				      struct journal_callback *jcb);
-
 extern void	 journal_lock_updates (journal_t *);
 extern void	 journal_unlock_updates (journal_t *);
 
diff -Nru a/include/linux/jffs2_fs_i.h b/include/linux/jffs2_fs_i.h
--- a/include/linux/jffs2_fs_i.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/jffs2_fs_i.h	2004-12-24 13:37:01 -08:00
@@ -1,10 +1,11 @@
-/* $Id: jffs2_fs_i.h,v 1.16 2003/01/09 14:03:21 dwmw2 Exp $ */
+/* $Id: jffs2_fs_i.h,v 1.17 2004/11/11 23:51:27 dwmw2 Exp $ */
 
 #ifndef _JFFS2_FS_I
 #define _JFFS2_FS_I
 
 #include <linux/version.h>
 #include <linux/rbtree.h>
+#include <asm/semaphore.h>
 
 struct jffs2_inode_info {
 	/* We need an internal semaphore similar to inode->i_sem.
diff -Nru a/include/linux/jiffies.h b/include/linux/jiffies.h
--- a/include/linux/jiffies.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/jiffies.h	2004-12-24 13:36:17 -08:00
@@ -3,10 +3,72 @@
 
 #include <linux/kernel.h>
 #include <linux/types.h>
-#include <linux/spinlock.h>
-#include <linux/seqlock.h>
-#include <asm/system.h>
+#include <linux/time.h>
+#include <linux/timex.h>
 #include <asm/param.h>			/* for HZ */
+#include <asm/div64.h>
+
+#ifndef div_long_long_rem
+#define div_long_long_rem(dividend,divisor,remainder) \
+({							\
+	u64 result = dividend;				\
+	*remainder = do_div(result,divisor);		\
+	result;						\
+})
+#endif
+
+/*
+ * The following defines establish the engineering parameters of the PLL
+ * model. The HZ variable establishes the timer interrupt frequency, 100 Hz
+ * for the SunOS kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the
+ * OSF/1 kernel. The SHIFT_HZ define expresses the same value as the
+ * nearest power of two in order to avoid hardware multiply operations.
+ */
+#if HZ >= 12 && HZ < 24
+# define SHIFT_HZ	4
+#elif HZ >= 24 && HZ < 48
+# define SHIFT_HZ	5
+#elif HZ >= 48 && HZ < 96
+# define SHIFT_HZ	6
+#elif HZ >= 96 && HZ < 192
+# define SHIFT_HZ	7
+#elif HZ >= 192 && HZ < 384
+# define SHIFT_HZ	8
+#elif HZ >= 384 && HZ < 768
+# define SHIFT_HZ	9
+#elif HZ >= 768 && HZ < 1536
+# define SHIFT_HZ	10
+#else
+# error You lose.
+#endif
+
+/* LATCH is used in the interval timer and ftape setup. */
+#define LATCH  ((CLOCK_TICK_RATE + HZ/2) / HZ)	/* For divider */
+
+/* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, the we can
+ * improve accuracy by shifting LSH bits, hence calculating:
+ *     (NOM << LSH) / DEN
+ * This however means trouble for large NOM, because (NOM << LSH) may no
+ * longer fit in 32 bits. The following way of calculating this gives us
+ * some slack, under the following conditions:
+ *   - (NOM / DEN) fits in (32 - LSH) bits.
+ *   - (NOM % DEN) fits in (32 - LSH) bits.
+ */
+#define SH_DIV(NOM,DEN,LSH) (   ((NOM / DEN) << LSH)                    \
+                             + (((NOM % DEN) << LSH) + DEN / 2) / DEN)
+
+/* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */
+#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
+
+/* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */
+#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
+
+/* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */
+#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
+
+/* TICK_USEC_TO_NSEC is the time between ticks in nsec assuming real ACTHZ and	*/
+/* a value TUSEC for TICK_USEC (can be set bij adjtimex)		*/
+#define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8))
 
 /*
  * The 64-bit value is not volatile - you MUST NOT read it
@@ -49,5 +111,321 @@
 	 typecheck(unsigned long, b) && \
 	 ((long)(a) - (long)(b) >= 0))
 #define time_before_eq(a,b)	time_after_eq(b,a)
+
+/*
+ * Have the 32 bit jiffies value wrap 5 minutes after boot
+ * so jiffies wrap bugs show up earlier.
+ */
+#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
+
+/*
+ * Change timeval to jiffies, trying to avoid the
+ * most obvious overflows..
+ *
+ * And some not so obvious.
+ *
+ * Note that we don't want to return MAX_LONG, because
+ * for various timeout reasons we often end up having
+ * to wait "jiffies+1" in order to guarantee that we wait
+ * at _least_ "jiffies" - so "jiffies+1" had better still
+ * be positive.
+ */
+#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
+
+/*
+ * We want to do realistic conversions of time so we need to use the same
+ * values the update wall clock code uses as the jiffies size.  This value
+ * is: TICK_NSEC (which is defined in timex.h).  This
+ * is a constant and is in nanoseconds.  We will used scaled math
+ * with a set of scales defined here as SEC_JIFFIE_SC,  USEC_JIFFIE_SC and
+ * NSEC_JIFFIE_SC.  Note that these defines contain nothing but
+ * constants and so are computed at compile time.  SHIFT_HZ (computed in
+ * timex.h) adjusts the scaling for different HZ values.
+
+ * Scaled math???  What is that?
+ *
+ * Scaled math is a way to do integer math on values that would,
+ * otherwise, either overflow, underflow, or cause undesired div
+ * instructions to appear in the execution path.  In short, we "scale"
+ * up the operands so they take more bits (more precision, less
+ * underflow), do the desired operation and then "scale" the result back
+ * by the same amount.  If we do the scaling by shifting we avoid the
+ * costly mpy and the dastardly div instructions.
+
+ * Suppose, for example, we want to convert from seconds to jiffies
+ * where jiffies is defined in nanoseconds as NSEC_PER_JIFFIE.  The
+ * simple math is: jiff = (sec * NSEC_PER_SEC) / NSEC_PER_JIFFIE; We
+ * observe that (NSEC_PER_SEC / NSEC_PER_JIFFIE) is a constant which we
+ * might calculate at compile time, however, the result will only have
+ * about 3-4 bits of precision (less for smaller values of HZ).
+ *
+ * So, we scale as follows:
+ * jiff = (sec) * (NSEC_PER_SEC / NSEC_PER_JIFFIE);
+ * jiff = ((sec) * ((NSEC_PER_SEC * SCALE)/ NSEC_PER_JIFFIE)) / SCALE;
+ * Then we make SCALE a power of two so:
+ * jiff = ((sec) * ((NSEC_PER_SEC << SCALE)/ NSEC_PER_JIFFIE)) >> SCALE;
+ * Now we define:
+ * #define SEC_CONV = ((NSEC_PER_SEC << SCALE)/ NSEC_PER_JIFFIE))
+ * jiff = (sec * SEC_CONV) >> SCALE;
+ *
+ * Often the math we use will expand beyond 32-bits so we tell C how to
+ * do this and pass the 64-bit result of the mpy through the ">> SCALE"
+ * which should take the result back to 32-bits.  We want this expansion
+ * to capture as much precision as possible.  At the same time we don't
+ * want to overflow so we pick the SCALE to avoid this.  In this file,
+ * that means using a different scale for each range of HZ values (as
+ * defined in timex.h).
+ *
+ * For those who want to know, gcc will give a 64-bit result from a "*"
+ * operator if the result is a long long AND at least one of the
+ * operands is cast to long long (usually just prior to the "*" so as
+ * not to confuse it into thinking it really has a 64-bit operand,
+ * which, buy the way, it can do, but it take more code and at least 2
+ * mpys).
+
+ * We also need to be aware that one second in nanoseconds is only a
+ * couple of bits away from overflowing a 32-bit word, so we MUST use
+ * 64-bits to get the full range time in nanoseconds.
+
+ */
+
+/*
+ * Here are the scales we will use.  One for seconds, nanoseconds and
+ * microseconds.
+ *
+ * Within the limits of cpp we do a rough cut at the SEC_JIFFIE_SC and
+ * check if the sign bit is set.  If not, we bump the shift count by 1.
+ * (Gets an extra bit of precision where we can use it.)
+ * We know it is set for HZ = 1024 and HZ = 100 not for 1000.
+ * Haven't tested others.
+
+ * Limits of cpp (for #if expressions) only long (no long long), but
+ * then we only need the most signicant bit.
+ */
+
+#define SEC_JIFFIE_SC (31 - SHIFT_HZ)
+#if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000)
+#undef SEC_JIFFIE_SC
+#define SEC_JIFFIE_SC (32 - SHIFT_HZ)
+#endif
+#define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29)
+#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19)
+#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\
+                                TICK_NSEC -1) / (u64)TICK_NSEC))
+
+#define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\
+                                        TICK_NSEC -1) / (u64)TICK_NSEC))
+#define USEC_CONVERSION  \
+                    ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\
+                                        TICK_NSEC -1) / (u64)TICK_NSEC))
+/*
+ * USEC_ROUND is used in the timeval to jiffie conversion.  See there
+ * for more details.  It is the scaled resolution rounding value.  Note
+ * that it is a 64-bit value.  Since, when it is applied, we are already
+ * in jiffies (albit scaled), it is nothing but the bits we will shift
+ * off.
+ */
+#define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1)
+/*
+ * The maximum jiffie value is (MAX_INT >> 1).  Here we translate that
+ * into seconds.  The 64-bit case will overflow if we are not careful,
+ * so use the messy SH_DIV macro to do it.  Still all constants.
+ */
+#if BITS_PER_LONG < 64
+# define MAX_SEC_IN_JIFFIES \
+	(long)((u64)((u64)MAX_JIFFY_OFFSET * TICK_NSEC) / NSEC_PER_SEC)
+#else	/* take care of overflow on 64 bits machines */
+# define MAX_SEC_IN_JIFFIES \
+	(SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 1) - 1)
+
+#endif
+
+/*
+ * Convert jiffies to milliseconds and back.
+ *
+ * Avoid unnecessary multiplications/divisions in the
+ * two most common HZ cases:
+ */
+static inline unsigned int jiffies_to_msecs(const unsigned long j)
+{
+#if HZ <= 1000 && !(1000 % HZ)
+	return (1000 / HZ) * j;
+#elif HZ > 1000 && !(HZ % 1000)
+	return (j + (HZ / 1000) - 1)/(HZ / 1000);
+#else
+	return (j * 1000) / HZ;
+#endif
+}
+
+static inline unsigned int jiffies_to_usecs(const unsigned long j)
+{
+#if HZ <= 1000 && !(1000 % HZ)
+	return (1000000 / HZ) * j;
+#elif HZ > 1000 && !(HZ % 1000)
+	return (j*1000 + (HZ - 1000))/(HZ / 1000);
+#else
+	return (j * 1000000) / HZ;
+#endif
+}
+
+static inline unsigned long msecs_to_jiffies(const unsigned int m)
+{
+	if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
+		return MAX_JIFFY_OFFSET;
+#if HZ <= 1000 && !(1000 % HZ)
+	return (m + (1000 / HZ) - 1) / (1000 / HZ);
+#elif HZ > 1000 && !(HZ % 1000)
+	return m * (HZ / 1000);
+#else
+	return (m * HZ + 999) / 1000;
+#endif
+}
+
+/*
+ * The TICK_NSEC - 1 rounds up the value to the next resolution.  Note
+ * that a remainder subtract here would not do the right thing as the
+ * resolution values don't fall on second boundries.  I.e. the line:
+ * nsec -= nsec % TICK_NSEC; is NOT a correct resolution rounding.
+ *
+ * Rather, we just shift the bits off the right.
+ *
+ * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
+ * value to a scaled second value.
+ */
+static __inline__ unsigned long
+timespec_to_jiffies(const struct timespec *value)
+{
+	unsigned long sec = value->tv_sec;
+	long nsec = value->tv_nsec + TICK_NSEC - 1;
+
+	if (sec >= MAX_SEC_IN_JIFFIES){
+		sec = MAX_SEC_IN_JIFFIES;
+		nsec = 0;
+	}
+	return (((u64)sec * SEC_CONVERSION) +
+		(((u64)nsec * NSEC_CONVERSION) >>
+		 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
+
+}
+
+static __inline__ void
+jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
+{
+	/*
+	 * Convert jiffies to nanoseconds and separate with
+	 * one divide.
+	 */
+	u64 nsec = (u64)jiffies * TICK_NSEC;
+	value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec);
+}
+
+/* Same for "timeval"
+ *
+ * Well, almost.  The problem here is that the real system resolution is
+ * in nanoseconds and the value being converted is in micro seconds.
+ * Also for some machines (those that use HZ = 1024, in-particular),
+ * there is a LARGE error in the tick size in microseconds.
+
+ * The solution we use is to do the rounding AFTER we convert the
+ * microsecond part.  Thus the USEC_ROUND, the bits to be shifted off.
+ * Instruction wise, this should cost only an additional add with carry
+ * instruction above the way it was done above.
+ */
+static __inline__ unsigned long
+timeval_to_jiffies(const struct timeval *value)
+{
+	unsigned long sec = value->tv_sec;
+	long usec = value->tv_usec;
+
+	if (sec >= MAX_SEC_IN_JIFFIES){
+		sec = MAX_SEC_IN_JIFFIES;
+		usec = 0;
+	}
+	return (((u64)sec * SEC_CONVERSION) +
+		(((u64)usec * USEC_CONVERSION + USEC_ROUND) >>
+		 (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
+}
+
+static __inline__ void
+jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
+{
+	/*
+	 * Convert jiffies to nanoseconds and separate with
+	 * one divide.
+	 */
+	u64 nsec = (u64)jiffies * TICK_NSEC;
+	value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec);
+	value->tv_usec /= NSEC_PER_USEC;
+}
+
+/*
+ * Convert jiffies/jiffies_64 to clock_t and back.
+ */
+static inline clock_t jiffies_to_clock_t(long x)
+{
+#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
+	return x / (HZ / USER_HZ);
+#else
+	u64 tmp = (u64)x * TICK_NSEC;
+	do_div(tmp, (NSEC_PER_SEC / USER_HZ));
+	return (long)tmp;
+#endif
+}
+
+static inline unsigned long clock_t_to_jiffies(unsigned long x)
+{
+#if (HZ % USER_HZ)==0
+	if (x >= ~0UL / (HZ / USER_HZ))
+		return ~0UL;
+	return x * (HZ / USER_HZ);
+#else
+	u64 jif;
+
+	/* Don't worry about loss of precision here .. */
+	if (x >= ~0UL / HZ * USER_HZ)
+		return ~0UL;
+
+	/* .. but do try to contain it here */
+	jif = x * (u64) HZ;
+	do_div(jif, USER_HZ);
+	return jif;
+#endif
+}
+
+static inline u64 jiffies_64_to_clock_t(u64 x)
+{
+#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
+	do_div(x, HZ / USER_HZ);
+#else
+	/*
+	 * There are better ways that don't overflow early,
+	 * but even this doesn't overflow in hundreds of years
+	 * in 64 bits, so..
+	 */
+	x *= TICK_NSEC;
+	do_div(x, (NSEC_PER_SEC / USER_HZ));
+#endif
+	return x;
+}
+
+static inline u64 nsec_to_clock_t(u64 x)
+{
+#if (NSEC_PER_SEC % USER_HZ) == 0
+	do_div(x, (NSEC_PER_SEC / USER_HZ));
+#elif (USER_HZ % 512) == 0
+	x *= USER_HZ/512;
+	do_div(x, (NSEC_PER_SEC / 512));
+#else
+	/*
+         * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024,
+         * overflow after 64.99 years.
+         * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ...
+         */
+	x *= 9;
+	do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (USER_HZ/2))
+	                          / USER_HZ));
+#endif
+	return x;
+}
 
 #endif
diff -Nru a/include/linux/kallsyms.h b/include/linux/kallsyms.h
--- a/include/linux/kallsyms.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/kallsyms.h	2004-12-24 13:36:17 -08:00
@@ -47,6 +47,16 @@
 static inline void __check_printsym_format(const char *fmt, ...)
 {
 }
+/* ia64 and ppc64 use function descriptors, which contain the real address */
+#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
+#define print_fn_descriptor_symbol(fmt, addr)		\
+do {						\
+	unsigned long *__faddr = (unsigned long*) addr;		\
+	print_symbol(fmt, __faddr[0]);		\
+} while (0)
+#else
+#define print_fn_descriptor_symbol(fmt, addr) print_symbol(fmt, addr)
+#endif
 
 #define print_symbol(fmt, addr)			\
 do {						\
diff -Nru a/include/linux/kernel.h b/include/linux/kernel.h
--- a/include/linux/kernel.h	2004-12-24 13:36:16 -08:00
+++ b/include/linux/kernel.h	2004-12-24 13:36:16 -08:00
@@ -66,9 +66,10 @@
 	})
 
 extern struct notifier_block *panic_notifier_list;
+extern long (*panic_blink)(long time);
 NORET_TYPE void panic(const char * fmt, ...)
 	__attribute__ ((NORET_AND format (printf, 1, 2)));
-asmlinkage NORET_TYPE void do_exit(long error_code)
+fastcall NORET_TYPE void do_exit(long error_code)
 	ATTRIB_NORET;
 NORET_TYPE void complete_and_exit(struct completion *, long)
 	ATTRIB_NORET;
@@ -136,6 +137,7 @@
 extern int panic_on_oops;
 extern int tainted;
 extern const char *print_tainted(void);
+extern void add_taint(unsigned);
 
 /* Values used for system_state */
 extern enum system_states {
@@ -150,6 +152,8 @@
 #define TAINT_FORCED_MODULE		(1<<1)
 #define TAINT_UNSAFE_SMP		(1<<2)
 #define TAINT_FORCED_RMMOD		(1<<3)
+#define TAINT_MACHINE_CHECK		(1<<4)
+#define TAINT_BAD_PAGE			(1<<5)
 
 extern void dump_stack(void);
 
diff -Nru a/include/linux/key-ui.h b/include/linux/key-ui.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/key-ui.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,97 @@
+/* key-ui.h: key userspace interface stuff for use by keyfs
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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.
+ */
+
+#ifndef _LINUX_KEY_UI_H
+#define _LINUX_KEY_UI_H
+
+#include <linux/key.h>
+
+/* the key tree */
+extern struct rb_root key_serial_tree;
+extern spinlock_t key_serial_lock;
+
+/* required permissions */
+#define	KEY_VIEW	0x01	/* require permission to view attributes */
+#define	KEY_READ	0x02	/* require permission to read content */
+#define	KEY_WRITE	0x04	/* require permission to update / modify */
+#define	KEY_SEARCH	0x08	/* require permission to search (keyring) or find (key) */
+#define	KEY_LINK	0x10	/* require permission to link */
+#define	KEY_ALL		0x1f	/* all the above permissions */
+
+/*
+ * the keyring payload contains a list of the keys to which the keyring is
+ * subscribed
+ */
+struct keyring_list {
+	unsigned	maxkeys;	/* max keys this list can hold */
+	unsigned	nkeys;		/* number of keys currently held */
+	struct key	*keys[0];
+};
+
+
+/*
+ * check to see whether permission is granted to use a key in the desired way
+ */
+static inline int key_permission(const struct key *key, key_perm_t perm)
+{
+	key_perm_t kperm;
+
+	if (key->uid == current->fsuid)
+		kperm = key->perm >> 16;
+	else if (key->gid != -1 &&
+		 key->perm & KEY_GRP_ALL &&
+		 in_group_p(key->gid)
+		 )
+		kperm = key->perm >> 8;
+	else
+		kperm = key->perm;
+
+	kperm = kperm & perm & KEY_ALL;
+
+	return kperm == perm;
+}
+
+/*
+ * check to see whether permission is granted to use a key in at least one of
+ * the desired ways
+ */
+static inline int key_any_permission(const struct key *key, key_perm_t perm)
+{
+	key_perm_t kperm;
+
+	if (key->uid == current->fsuid)
+		kperm = key->perm >> 16;
+	else if (key->gid != -1 &&
+		 key->perm & KEY_GRP_ALL &&
+		 in_group_p(key->gid)
+		 )
+		kperm = key->perm >> 8;
+	else
+		kperm = key->perm;
+
+	kperm = kperm & perm & KEY_ALL;
+
+	return kperm != 0;
+}
+
+
+extern struct key *lookup_user_key(key_serial_t id, int create, int part,
+				   key_perm_t perm);
+
+extern long join_session_keyring(const char *name);
+
+extern struct key_type *key_type_lookup(const char *type);
+extern void key_type_put(struct key_type *ktype);
+
+#define key_negative_timeout	60	/* default timeout on a negative key's existence */
+
+
+#endif /* _LINUX_KEY_UI_H */
diff -Nru a/include/linux/key.h b/include/linux/key.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/key.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,286 @@
+/* key.h: authentication token and access key management
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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.
+ *
+ *
+ * See Documentation/keys.txt for information on keys/keyrings.
+ */
+
+#ifndef _LINUX_KEY_H
+#define _LINUX_KEY_H
+
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/rbtree.h>
+#include <linux/spinlock.h>
+#include <asm/atomic.h>
+
+#ifdef __KERNEL__
+
+/* key handle serial number */
+typedef int32_t key_serial_t;
+
+/* key handle permissions mask */
+typedef uint32_t key_perm_t;
+
+struct key;
+
+#ifdef CONFIG_KEYS
+
+#undef KEY_DEBUGGING
+
+#define KEY_USR_VIEW	0x00010000	/* user can view a key's attributes */
+#define KEY_USR_READ	0x00020000	/* user can read key payload / view keyring */
+#define KEY_USR_WRITE	0x00040000	/* user can update key payload / add link to keyring */
+#define KEY_USR_SEARCH	0x00080000	/* user can find a key in search / search a keyring */
+#define KEY_USR_LINK	0x00100000	/* user can create a link to a key/keyring */
+#define KEY_USR_ALL	0x001f0000
+
+#define KEY_GRP_VIEW	0x00000100	/* group permissions... */
+#define KEY_GRP_READ	0x00000200
+#define KEY_GRP_WRITE	0x00000400
+#define KEY_GRP_SEARCH	0x00000800
+#define KEY_GRP_LINK	0x00001000
+#define KEY_GRP_ALL	0x00001f00
+
+#define KEY_OTH_VIEW	0x00000001	/* third party permissions... */
+#define KEY_OTH_READ	0x00000002
+#define KEY_OTH_WRITE	0x00000004
+#define KEY_OTH_SEARCH	0x00000008
+#define KEY_OTH_LINK	0x00000010
+#define KEY_OTH_ALL	0x0000001f
+
+struct seq_file;
+struct user_struct;
+
+struct key_type;
+struct key_owner;
+struct keyring_list;
+struct keyring_name;
+
+/*****************************************************************************/
+/*
+ * authentication token / access credential / keyring
+ * - types of key include:
+ *   - keyrings
+ *   - disk encryption IDs
+ *   - Kerberos TGTs and tickets
+ */
+struct key {
+	atomic_t		usage;		/* number of references */
+	key_serial_t		serial;		/* key serial number */
+	struct rb_node		serial_node;
+	struct key_type		*type;		/* type of key */
+	rwlock_t		lock;		/* examination vs change lock */
+	struct rw_semaphore	sem;		/* change vs change sem */
+	struct key_user		*user;		/* owner of this key */
+	time_t			expiry;		/* time at which key expires (or 0) */
+	uid_t			uid;
+	gid_t			gid;
+	key_perm_t		perm;		/* access permissions */
+	unsigned short		quotalen;	/* length added to quota */
+	unsigned short		datalen;	/* payload data length */
+	unsigned short		flags;		/* status flags (change with lock writelocked) */
+#define KEY_FLAG_INSTANTIATED	0x00000001	/* set if key has been instantiated */
+#define KEY_FLAG_DEAD		0x00000002	/* set if key type has been deleted */
+#define KEY_FLAG_REVOKED	0x00000004	/* set if key had been revoked */
+#define KEY_FLAG_IN_QUOTA	0x00000008	/* set if key consumes quota */
+#define KEY_FLAG_USER_CONSTRUCT	0x00000010	/* set if key is being constructed in userspace */
+#define KEY_FLAG_NEGATIVE	0x00000020	/* set if key is negative */
+
+#ifdef KEY_DEBUGGING
+	unsigned		magic;
+#define KEY_DEBUG_MAGIC		0x18273645u
+#define KEY_DEBUG_MAGIC_X	0xf8e9dacbu
+#endif
+
+	/* the description string
+	 * - this is used to match a key against search criteria
+	 * - this should be a printable string
+	 * - eg: for krb5 AFS, this might be "afs@REDHAT.COM"
+	 */
+	char			*description;
+
+	/* type specific data
+	 * - this is used by the keyring type to index the name
+	 */
+	union {
+		struct list_head	link;
+	} type_data;
+
+	/* key data
+	 * - this is used to hold the data actually used in cryptography or
+	 *   whatever
+	 */
+	union {
+		unsigned long		value;
+		void			*data;
+		struct keyring_list	*subscriptions;
+	} payload;
+};
+
+/*****************************************************************************/
+/*
+ * kernel managed key type definition
+ */
+struct key_type {
+	/* name of the type */
+	const char *name;
+
+	/* default payload length for quota precalculation (optional)
+	 * - this can be used instead of calling key_payload_reserve(), that
+	 *   function only needs to be called if the real datalen is different
+	 */
+	size_t def_datalen;
+
+	/* instantiate a key of this type
+	 * - this method should call key_payload_reserve() to determine if the
+	 *   user's quota will hold the payload
+	 */
+	int (*instantiate)(struct key *key, const void *data, size_t datalen);
+
+	/* duplicate a key of this type (optional)
+	 * - the source key will be locked against change
+	 * - the new description will be attached
+	 * - the quota will have been adjusted automatically from
+	 *   source->quotalen
+	 */
+	int (*duplicate)(struct key *key, const struct key *source);
+
+	/* update a key of this type (optional)
+	 * - this method should call key_payload_reserve() to recalculate the
+	 *   quota consumption
+	 * - the key must be locked against read when modifying
+	 */
+	int (*update)(struct key *key, const void *data, size_t datalen);
+
+	/* match a key against a description */
+	int (*match)(const struct key *key, const void *desc);
+
+	/* clear the data from a key (optional) */
+	void (*destroy)(struct key *key);
+
+	/* describe a key */
+	void (*describe)(const struct key *key, struct seq_file *p);
+
+	/* read a key's data (optional)
+	 * - permission checks will be done by the caller
+	 * - the key's semaphore will be readlocked by the caller
+	 * - should return the amount of data that could be read, no matter how
+	 *   much is copied into the buffer
+	 * - shouldn't do the copy if the buffer is NULL
+	 */
+	long (*read)(const struct key *key, char __user *buffer, size_t buflen);
+
+	/* internal fields */
+	struct list_head	link;		/* link in types list */
+};
+
+extern struct key_type key_type_keyring;
+
+extern int register_key_type(struct key_type *ktype);
+extern void unregister_key_type(struct key_type *ktype);
+
+extern struct key *key_alloc(struct key_type *type,
+			     const char *desc,
+			     uid_t uid, gid_t gid, key_perm_t perm,
+			     int not_in_quota);
+extern int key_payload_reserve(struct key *key, size_t datalen);
+extern int key_instantiate_and_link(struct key *key,
+				    const void *data,
+				    size_t datalen,
+				    struct key *keyring);
+extern int key_negate_and_link(struct key *key,
+			       unsigned timeout,
+			       struct key *keyring);
+extern void key_revoke(struct key *key);
+extern void key_put(struct key *key);
+
+static inline struct key *key_get(struct key *key)
+{
+	if (key)
+		atomic_inc(&key->usage);
+	return key;
+}
+
+extern struct key *request_key(struct key_type *type,
+			       const char *description,
+			       const char *callout_info);
+
+extern int key_validate(struct key *key);
+
+extern struct key *key_create_or_update(struct key *keyring,
+					const char *type,
+					const char *description,
+					const void *payload,
+					size_t plen,
+					int not_in_quota);
+
+extern int key_update(struct key *key,
+		      const void *payload,
+		      size_t plen);
+
+extern int key_link(struct key *keyring,
+		    struct key *key);
+
+extern int key_unlink(struct key *keyring,
+		      struct key *key);
+
+extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,
+				 int not_in_quota, struct key *dest);
+
+extern int keyring_clear(struct key *keyring);
+
+extern struct key *keyring_search(struct key *keyring,
+				  struct key_type *type,
+				  const char *description);
+
+extern struct key *search_process_keyrings(struct key_type *type,
+					   const char *description);
+
+extern int keyring_add_key(struct key *keyring,
+			   struct key *key);
+
+extern struct key *key_lookup(key_serial_t id);
+
+#define key_serial(key) ((key) ? (key)->serial : 0)
+
+/*
+ * the userspace interface
+ */
+extern struct key root_user_keyring, root_session_keyring;
+extern int alloc_uid_keyring(struct user_struct *user);
+extern void switch_uid_keyring(struct user_struct *new_user);
+extern int copy_keys(unsigned long clone_flags, struct task_struct *tsk);
+extern void exit_keys(struct task_struct *tsk);
+extern int suid_keys(struct task_struct *tsk);
+extern int exec_keys(struct task_struct *tsk);
+extern void key_fsuid_changed(struct task_struct *tsk);
+extern void key_fsgid_changed(struct task_struct *tsk);
+extern void key_init(void);
+
+#else /* CONFIG_KEYS */
+
+#define key_validate(k)			0
+#define key_serial(k)			0
+#define key_get(k) 			NULL
+#define key_put(k)			do { } while(0)
+#define alloc_uid_keyring(u)		0
+#define switch_uid_keyring(u)		do { } while(0)
+#define copy_keys(f,t)			0
+#define exit_keys(t)			do { } while(0)
+#define suid_keys(t)			do { } while(0)
+#define exec_keys(t)			do { } while(0)
+#define key_fsuid_changed(t)		do { } while(0)
+#define key_fsgid_changed(t)		do { } while(0)
+#define key_init()			do { } while(0)
+
+#endif /* CONFIG_KEYS */
+#endif /* __KERNEL__ */
+#endif /* _LINUX_KEY_H */
diff -Nru a/include/linux/keyctl.h b/include/linux/keyctl.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/keyctl.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,39 @@
+/* keyctl.h: keyctl command IDs
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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.
+ */
+
+#ifndef _LINUX_KEYCTL_H
+#define _LINUX_KEYCTL_H
+
+/* special process keyring shortcut IDs */
+#define KEY_SPEC_THREAD_KEYRING		-1	/* - key ID for thread-specific keyring */
+#define KEY_SPEC_PROCESS_KEYRING	-2	/* - key ID for process-specific keyring */
+#define KEY_SPEC_SESSION_KEYRING	-3	/* - key ID for session-specific keyring */
+#define KEY_SPEC_USER_KEYRING		-4	/* - key ID for UID-specific keyring */
+#define KEY_SPEC_USER_SESSION_KEYRING	-5	/* - key ID for UID-session keyring */
+#define KEY_SPEC_GROUP_KEYRING		-6	/* - key ID for GID-specific keyring */
+
+/* keyctl commands */
+#define KEYCTL_GET_KEYRING_ID		0	/* ask for a keyring's ID */
+#define KEYCTL_JOIN_SESSION_KEYRING	1	/* join or start named session keyring */
+#define KEYCTL_UPDATE			2	/* update a key */
+#define KEYCTL_REVOKE			3	/* revoke a key */
+#define KEYCTL_CHOWN			4	/* set ownership of a key */
+#define KEYCTL_SETPERM			5	/* set perms on a key */
+#define KEYCTL_DESCRIBE			6	/* describe a key */
+#define KEYCTL_CLEAR			7	/* clear contents of a keyring */
+#define KEYCTL_LINK			8	/* link a key into a keyring */
+#define KEYCTL_UNLINK			9	/* unlink a key from a keyring */
+#define KEYCTL_SEARCH			10	/* search for a key in a keyring */
+#define KEYCTL_READ			11	/* read a key or keyring's contents */
+#define KEYCTL_INSTANTIATE		12	/* instantiate a partially constructed key */
+#define KEYCTL_NEGATE			13	/* negate a partially constructed key */
+
+#endif /*  _LINUX_KEYCTL_H */
diff -Nru a/include/linux/kfifo.h b/include/linux/kfifo.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/kfifo.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,157 @@
+/*
+ * A simple kernel FIFO implementation.
+ *
+ * Copyright (C) 2004 Stelian Pop <stelian@popies.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 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.
+ *
+ */
+#ifndef _LINUX_KFIFO_H
+#define _LINUX_KFIFO_H
+
+#ifdef __KERNEL__
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+
+struct kfifo {
+	unsigned char *buffer;	/* the buffer holding the data */
+	unsigned int size;	/* the size of the allocated buffer */
+	unsigned int in;	/* data is added at offset (in % size) */
+	unsigned int out;	/* data is extracted from off. (out % size) */
+	spinlock_t *lock;	/* protects concurrent modifications */
+};
+
+extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
+				int gfp_mask, spinlock_t *lock);
+extern struct kfifo *kfifo_alloc(unsigned int size, int gfp_mask,
+				 spinlock_t *lock);
+extern void kfifo_free(struct kfifo *fifo);
+extern unsigned int __kfifo_put(struct kfifo *fifo,
+				unsigned char *buffer, unsigned int len);
+extern unsigned int __kfifo_get(struct kfifo *fifo,
+				unsigned char *buffer, unsigned int len);
+
+/*
+ * __kfifo_reset - removes the entire FIFO contents, no locking version
+ * @fifo: the fifo to be emptied.
+ */
+static inline void __kfifo_reset(struct kfifo *fifo)
+{
+	fifo->in = fifo->out = 0;
+}
+
+/*
+ * kfifo_reset - removes the entire FIFO contents
+ * @fifo: the fifo to be emptied.
+ */
+static inline void kfifo_reset(struct kfifo *fifo)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(fifo->lock, flags);
+
+	__kfifo_reset(fifo);
+
+	spin_unlock_irqrestore(fifo->lock, flags);
+}
+
+/*
+ * kfifo_put - puts some data into the FIFO
+ * @fifo: the fifo to be used.
+ * @buffer: the data to be added.
+ * @len: the length of the data to be added.
+ *
+ * This function copies at most 'len' bytes from the 'buffer' into
+ * the FIFO depending on the free space, and returns the number of
+ * bytes copied.
+ */
+static inline unsigned int kfifo_put(struct kfifo *fifo,
+				     unsigned char *buffer, unsigned int len)
+{
+	unsigned long flags;
+	unsigned int ret;
+
+	spin_lock_irqsave(fifo->lock, flags);
+
+	ret = __kfifo_put(fifo, buffer, len);
+
+	spin_unlock_irqrestore(fifo->lock, flags);
+
+	return ret;
+}
+
+/*
+ * kfifo_get - gets some data from the FIFO
+ * @fifo: the fifo to be used.
+ * @buffer: where the data must be copied.
+ * @len: the size of the destination buffer.
+ *
+ * This function copies at most 'len' bytes from the FIFO into the
+ * 'buffer' and returns the number of copied bytes.
+ */
+static inline unsigned int kfifo_get(struct kfifo *fifo,
+				     unsigned char *buffer, unsigned int len)
+{
+	unsigned long flags;
+	unsigned int ret;
+
+	spin_lock_irqsave(fifo->lock, flags);
+
+	ret = __kfifo_get(fifo, buffer, len);
+
+	/*
+	 * optimization: if the FIFO is empty, set the indices to 0
+	 * so we don't wrap the next time
+	 */
+	if (fifo->in == fifo->out)
+		fifo->in = fifo->out = 0;
+
+	spin_unlock_irqrestore(fifo->lock, flags);
+
+	return ret;
+}
+
+/*
+ * __kfifo_len - returns the number of bytes available in the FIFO, no locking version
+ * @fifo: the fifo to be used.
+ */
+static inline unsigned int __kfifo_len(struct kfifo *fifo)
+{
+	return fifo->in - fifo->out;
+}
+
+/*
+ * kfifo_len - returns the number of bytes available in the FIFO
+ * @fifo: the fifo to be used.
+ */
+static inline unsigned int kfifo_len(struct kfifo *fifo)
+{
+	unsigned long flags;
+	unsigned int ret;
+
+	spin_lock_irqsave(fifo->lock, flags);
+
+	ret = __kfifo_len(fifo);
+
+	spin_unlock_irqrestore(fifo->lock, flags);
+
+	return ret;
+}
+
+#else
+#warning "don't include kernel headers in userspace"
+#endif /* __KERNEL__ */
+#endif
diff -Nru a/include/linux/kmod.h b/include/linux/kmod.h
--- a/include/linux/kmod.h	2004-12-24 13:36:30 -08:00
+++ b/include/linux/kmod.h	2004-12-24 13:36:30 -08:00
@@ -37,8 +37,4 @@
 extern int call_usermodehelper(char *path, char *argv[], char *envp[], int wait);
 extern void usermodehelper_init(void);
 
-#ifdef CONFIG_HOTPLUG
-extern char hotplug_path [];
-#endif
-
 #endif /* __LINUX_KMOD_H__ */
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
--- a/include/linux/kobject.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/kobject.h	2004-12-24 13:36:17 -08:00
@@ -22,10 +22,14 @@
 #include <linux/sysfs.h>
 #include <linux/rwsem.h>
 #include <linux/kref.h>
+#include <linux/kobject_uevent.h>
 #include <asm/atomic.h>
 
 #define KOBJ_NAME_LEN	20
 
+/* counter to tag the hotplug event, read only except for the kobject core */
+extern u64 hotplug_seqnum;
+
 struct kobject {
 	char			* k_name;
 	char			name[KOBJ_NAME_LEN];
@@ -59,9 +63,7 @@
 extern struct kobject * kobject_get(struct kobject *);
 extern void kobject_put(struct kobject *);
 
-extern void kobject_hotplug(const char *action, struct kobject *);
-
-extern char * kobject_get_path(struct kset *, struct kobject *, int);
+extern char * kobject_get_path(struct kobject *, int);
 
 struct kobj_type {
 	void (*release)(struct kobject *);
@@ -233,6 +235,20 @@
 
 extern int subsys_create_file(struct subsystem * , struct subsys_attribute *);
 extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *);
+
+#ifdef CONFIG_HOTPLUG
+void kobject_hotplug(struct kobject *kobj, enum kobject_action action);
+int add_hotplug_env_var(char **envp, int num_envp, int *cur_index,
+			char *buffer, int buffer_size, int *cur_len,
+			const char *format, ...)
+	__attribute__((format (printf, 7, 8)));
+#else
+static inline void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { }
+static inline int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, 
+				      char *buffer, int buffer_size, int *cur_len, 
+				      const char *format, ...)
+{ return 0; }
+#endif
 
 #endif /* __KERNEL__ */
 #endif /* _KOBJECT_H_ */
diff -Nru a/include/linux/kobject_uevent.h b/include/linux/kobject_uevent.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/kobject_uevent.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,57 @@
+/*
+ * kobject_uevent.h - list of kobject user events that can be generated
+ *
+ * Copyright (C) 2004 IBM Corp.
+ * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
+ *
+ * This file is released under the GPLv2.
+ *
+ */
+
+#ifndef _KOBJECT_EVENT_H_
+#define _KOBJECT_EVENT_H_
+
+#define HOTPLUG_PATH_LEN	256
+
+/* path to the hotplug userspace helper executed on an event */
+extern char hotplug_path[];
+
+/*
+ * If you add an action here, you must also add the proper string to the
+ * lib/kobject_uevent.c file.
+ */
+typedef int __bitwise kobject_action_t;
+enum kobject_action {
+	KOBJ_ADD	= (__force kobject_action_t) 0x01,	/* add event, for hotplug */
+	KOBJ_REMOVE	= (__force kobject_action_t) 0x02,	/* remove event, for hotplug */
+	KOBJ_CHANGE	= (__force kobject_action_t) 0x03,	/* a sysfs attribute file has changed */
+	KOBJ_MOUNT	= (__force kobject_action_t) 0x04,	/* mount event for block devices */
+	KOBJ_UMOUNT	= (__force kobject_action_t) 0x05,	/* umount event for block devices */
+	KOBJ_OFFLINE	= (__force kobject_action_t) 0x06,	/* offline event for hotplug devices */
+	KOBJ_ONLINE	= (__force kobject_action_t) 0x07,	/* online event for hotplug devices */
+};
+
+
+#ifdef CONFIG_KOBJECT_UEVENT
+int kobject_uevent(struct kobject *kobj,
+		   enum kobject_action action,
+		   struct attribute *attr);
+int kobject_uevent_atomic(struct kobject *kobj,
+			  enum kobject_action action,
+			  struct attribute *attr);
+#else
+static inline int kobject_uevent(struct kobject *kobj,
+				 enum kobject_action action,
+				 struct attribute *attr)
+{
+	return 0;
+}
+static inline int kobject_uevent_atomic(struct kobject *kobj,
+				        enum kobject_action action,
+					struct attribute *attr)
+{
+	return 0;
+}
+#endif
+
+#endif
diff -Nru a/include/linux/kprobes.h b/include/linux/kprobes.h
--- a/include/linux/kprobes.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/kprobes.h	2004-12-24 13:36:31 -08:00
@@ -64,7 +64,7 @@
 	kprobe_opcode_t opcode;
 
 	/* copy of the original instruction */
-	kprobe_opcode_t insn[MAX_INSN_SIZE];
+	struct arch_specific_insn ainsn;
 };
 
 /*
@@ -94,7 +94,8 @@
 	return kprobe_cpu == smp_processor_id();
 }
 
-extern void arch_prepare_kprobe(struct kprobe *p);
+extern int arch_prepare_kprobe(struct kprobe *p);
+extern void arch_remove_kprobe(struct kprobe *p);
 extern void show_registers(struct pt_regs *regs);
 
 /* Get the kprobe at this addr (if any).  Must have called lock_kprobes */
diff -Nru a/include/linux/libata.h b/include/linux/libata.h
--- a/include/linux/libata.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/libata.h	2004-12-24 13:36:17 -08:00
@@ -25,6 +25,7 @@
 
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/pci.h>
 #include <asm/io.h>
 #include <linux/ata.h>
 #include <linux/workqueue.h>
@@ -68,6 +69,12 @@
 /* defines only for the constants which don't work well as enums */
 #define ATA_TAG_POISON		0xfafbfcfdU
 
+/* move to PCI layer? */
+static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
+{
+	return &pdev->dev;
+}
+
 enum {
 	/* various global constants */
 	LIBATA_MAX_PRD		= ATA_MAX_PRD / 2,
@@ -105,6 +112,7 @@
 	ATA_FLAG_SRST		= (1 << 5), /* use ATA SRST, not E.D.D. */
 	ATA_FLAG_MMIO		= (1 << 6), /* use MMIO, not PIO */
 	ATA_FLAG_SATA_RESET	= (1 << 7), /* use COMRESET */
+	ATA_FLAG_PIO_DMA	= (1 << 8), /* PIO cmds via DMA */
 
 	ATA_QCFLAG_ACTIVE	= (1 << 1), /* cmd not yet ack'd to scsi lyer */
 	ATA_QCFLAG_SG		= (1 << 3), /* have s/g table? */
@@ -184,11 +192,12 @@
 
 struct ata_probe_ent {
 	struct list_head	node;
-	struct pci_dev		*pdev;
+	struct device 		*dev;
 	struct ata_port_operations	*port_ops;
 	Scsi_Host_Template	*sht;
 	struct ata_ioports	port[ATA_MAX_PORTS];
 	unsigned int		n_ports;
+	unsigned int		hard_port_no;
 	unsigned int		pio_mask;
 	unsigned int		mwdma_mask;
 	unsigned int		udma_mask;
@@ -202,7 +211,7 @@
 
 struct ata_host_set {
 	spinlock_t		lock;
-	struct pci_dev		*pdev;
+	struct device 		*dev;
 	unsigned long		irq;
 	void __iomem		*mmio_base;
 	unsigned int		n_ports;
@@ -225,10 +234,14 @@
 	unsigned int		tag;
 	unsigned int		n_elem;
 
-	int			pci_dma_dir;
+	int			dma_dir;
 
 	unsigned int		nsect;
 	unsigned int		cursect;
+
+	unsigned int		nbytes;
+	unsigned int		curbytes;
+
 	unsigned int		cursg;
 	unsigned int		cursg_ofs;
 
@@ -273,6 +286,7 @@
 	unsigned long		flags;	/* ATA_FLAG_xxx */
 	unsigned int		id;	/* unique id req'd by scsi midlyr */
 	unsigned int		port_no; /* unique port #; from zero */
+	unsigned int		hard_port_no;	/* hardware port #; from zero */
 
 	struct ata_prd		*prd;	 /* our SG list */
 	dma_addr_t		prd_dma; /* and its DMA mapping */
@@ -355,12 +369,6 @@
 	struct ata_port_operations	*port_ops;
 };
 
-struct pci_bits {
-	unsigned int		reg;	/* PCI config register to read */
-	unsigned int		width;	/* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
-	unsigned long		mask;
-	unsigned long		val;
-};
 
 extern void ata_port_probe(struct ata_port *);
 extern void __sata_phy_reset(struct ata_port *ap);
@@ -368,9 +376,11 @@
 extern void ata_bus_reset(struct ata_port *ap);
 extern void ata_port_disable(struct ata_port *);
 extern void ata_std_ports(struct ata_ioports *ioaddr);
+#ifdef CONFIG_PCI
 extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
 			     unsigned int n_ports);
 extern void ata_pci_remove_one (struct pci_dev *pdev);
+#endif /* CONFIG_PCI */
 extern int ata_device_add(struct ata_probe_ent *ent);
 extern int ata_scsi_detect(Scsi_Host_Template *sht);
 extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
@@ -392,10 +402,6 @@
 extern int ata_port_start (struct ata_port *ap);
 extern void ata_port_stop (struct ata_port *ap);
 extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
-extern struct ata_probe_ent *
-ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port);
-extern struct ata_probe_ent *
-ata_pci_init_legacy_mode(struct pci_dev *pdev, struct ata_port_info **port);
 extern void ata_qc_prep(struct ata_queued_cmd *qc);
 extern int ata_qc_issue_prot(struct ata_queued_cmd *qc);
 extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
@@ -403,20 +409,38 @@
 extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
 		 unsigned int n_elem);
 extern unsigned int ata_dev_classify(struct ata_taskfile *tf);
-extern void ata_dev_id_string(struct ata_device *dev, unsigned char *s,
+extern void ata_dev_id_string(u16 *id, unsigned char *s,
 			      unsigned int ofs, unsigned int len);
 extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
 extern void ata_bmdma_start (struct ata_queued_cmd *qc);
 extern void ata_bmdma_irq_clear(struct ata_port *ap);
-extern int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits);
 extern void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat);
 extern void ata_eng_timeout(struct ata_port *ap);
+extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd,
+			      void (*done)(struct scsi_cmnd *));
 extern int ata_std_bios_param(struct scsi_device *sdev,
 			      struct block_device *bdev,
 			      sector_t capacity, int geom[]);
 extern int ata_scsi_slave_config(struct scsi_device *sdev);
 
 
+#ifdef CONFIG_PCI
+struct pci_bits {
+	unsigned int		reg;	/* PCI config register to read */
+	unsigned int		width;	/* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
+	unsigned long		mask;
+	unsigned long		val;
+};
+
+extern struct ata_probe_ent *
+ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port);
+extern struct ata_probe_ent *
+ata_pci_init_legacy_mode(struct pci_dev *pdev, struct ata_port_info **port);
+extern int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits);
+
+#endif /* CONFIG_PCI */
+
+
 static inline unsigned int ata_tag_valid(unsigned int tag)
 {
 	return (tag < ATA_MAX_QUEUE) ? 1 : 0;
@@ -613,9 +637,9 @@
 
 static inline int ata_try_flush_cache(struct ata_device *dev)
 {
-	return ata_id_wcache_enabled(dev) ||
-	       ata_id_has_flush(dev) ||
-	       ata_id_has_flush_ext(dev);
+	return ata_id_wcache_enabled(dev->id) ||
+	       ata_id_has_flush(dev->id) ||
+	       ata_id_has_flush_ext(dev->id);
 }
 
 #endif /* __LINUX_LIBATA_H__ */
diff -Nru a/include/linux/list.h b/include/linux/list.h
--- a/include/linux/list.h	2004-12-24 13:36:56 -08:00
+++ b/include/linux/list.h	2004-12-24 13:36:56 -08:00
@@ -568,8 +568,6 @@
 	}
 }
 
-#define hlist_del_rcu_init hlist_del_init
-
 static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
 {
 	struct hlist_node *first = h->first;
diff -Nru a/include/linux/lockd/debug.h b/include/linux/lockd/debug.h
--- a/include/linux/lockd/debug.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/lockd/debug.h	2004-12-24 13:37:18 -08:00
@@ -45,4 +45,13 @@
 #define NLMDBG_ALL		0x7fff
 
 
+/*
+ * Support for printing NLM cookies in dprintk()
+ */
+#ifdef RPC_DEBUG
+struct nlm_cookie;
+/* Call this function with the BKL held (it uses a static buffer) */
+extern const char *nlmdbg_cookie2a(const struct nlm_cookie *);
+#endif
+
 #endif /* LINUX_LOCKD_DEBUG_H */
diff -Nru a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
--- a/include/linux/lockd/xdr.h	2004-12-24 13:36:16 -08:00
+++ b/include/linux/lockd/xdr.h	2004-12-24 13:36:16 -08:00
@@ -13,10 +13,9 @@
 #include <linux/nfs.h>
 #include <linux/sunrpc/xdr.h>
 
+#define NLM_MAXCOOKIELEN    	32
 #define NLM_MAXSTRLEN		1024
 
-#define QUADLEN(len)		(((len) + 3) >> 2)
-
 #define	nlm_granted		__constant_htonl(NLM_LCK_GRANTED)
 #define	nlm_lck_denied		__constant_htonl(NLM_LCK_DENIED)
 #define	nlm_lck_denied_nolocks	__constant_htonl(NLM_LCK_DENIED_NOLOCKS)
@@ -33,13 +32,14 @@
 };
 
 /*
- *	NLM cookies. Technically they can be 1K, Nobody uses over 8 bytes
- *	however.
+ *	NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
+ *	FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
+ *	32 bytes.
  */
  
 struct nlm_cookie
 {
-	unsigned char data[8];
+	unsigned char data[NLM_MAXCOOKIELEN];
 	unsigned int len;
 };
 
diff -Nru a/include/linux/mbcache.h b/include/linux/mbcache.h
--- a/include/linux/mbcache.h	2004-12-24 13:37:32 -08:00
+++ b/include/linux/mbcache.h	2004-12-24 13:37:32 -08:00
@@ -56,9 +56,7 @@
 			  sector_t, unsigned int[]);
 void mb_cache_entry_rehash(struct mb_cache_entry *, unsigned int[]);
 void mb_cache_entry_release(struct mb_cache_entry *);
-void mb_cache_entry_takeout(struct mb_cache_entry *);
 void mb_cache_entry_free(struct mb_cache_entry *);
-struct mb_cache_entry *mb_cache_entry_dup(struct mb_cache_entry *);
 struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *,
 					  struct block_device *,
 					  sector_t);
diff -Nru a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h
--- a/include/linux/mc146818rtc.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/mc146818rtc.h	2004-12-24 13:37:18 -08:00
@@ -13,10 +13,12 @@
 
 #include <asm/io.h>
 #include <linux/rtc.h>			/* get the user-level API */
-#include <linux/spinlock.h>		/* spinlock_t */
 #include <asm/mc146818rtc.h>		/* register access macros */
 
+#ifdef __KERNEL__
+#include <linux/spinlock.h>		/* spinlock_t */
 extern spinlock_t rtc_lock;		/* serialize CMOS RAM access */
+#endif
 
 /**********************************************************************
  * register summary
diff -Nru a/include/linux/mempolicy.h b/include/linux/mempolicy.h
--- a/include/linux/mempolicy.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/mempolicy.h	2004-12-24 13:36:17 -08:00
@@ -30,7 +30,7 @@
 #include <linux/bitmap.h>
 #include <linux/slab.h>
 #include <linux/rbtree.h>
-#include <asm/semaphore.h>
+#include <linux/spinlock.h>
 
 struct vm_area_struct;
 
@@ -134,13 +134,13 @@
 
 struct shared_policy {
 	struct rb_root root;
-	struct semaphore sem;
+	spinlock_t lock;
 };
 
 static inline void mpol_shared_policy_init(struct shared_policy *info)
 {
 	info->root = RB_ROOT;
-	init_MUTEX(&info->sem);
+	spin_lock_init(&info->lock);
 }
 
 int mpol_set_shared_policy(struct shared_policy *info,
diff -Nru a/include/linux/meye.h b/include/linux/meye.h
--- a/include/linux/meye.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/meye.h	2004-12-24 13:36:31 -08:00
@@ -1,4 +1,4 @@
-/* 
+/*
  * Motion Eye video4linux driver for Sony Vaio PictureBook
  *
  * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
@@ -8,20 +8,20 @@
  * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
  *
  * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
- * 
+ *
  * Some parts borrowed from various video4linux drivers, especially
  * bttv-driver.c and zoran.c, see original files for credits.
- * 
+ *
  * 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.
@@ -55,5 +55,12 @@
 #define MEYEIOC_STILLCAPT	_IO  ('v', BASE_VIDIOCPRIVATE+4)
 /* get a jpeg compressed snapshot */
 #define MEYEIOC_STILLJCAPT	_IOR ('v', BASE_VIDIOCPRIVATE+5, int)
+
+/* V4L2 private controls */
+#define V4L2_CID_AGC		V4L2_CID_PRIVATE_BASE
+#define V4L2_CID_SHARPNESS	(V4L2_CID_PRIVATE_BASE + 1)
+#define V4L2_CID_PICTURE	(V4L2_CID_PRIVATE_BASE + 2)
+#define V4L2_CID_JPEGQUAL	(V4L2_CID_PRIVATE_BASE + 3)
+#define V4L2_CID_FRAMERATE	(V4L2_CID_PRIVATE_BASE + 4)
 
 #endif
diff -Nru a/include/linux/mm.h b/include/linux/mm.h
--- a/include/linux/mm.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/mm.h	2004-12-24 13:36:17 -08:00
@@ -41,6 +41,8 @@
 #define MM_VM_SIZE(mm)	TASK_SIZE
 #endif
 
+#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
+
 /*
  * Linux kernel virtual memory manager primitives.
  * The idea being to have a "virtual" mm in the same way
@@ -540,7 +542,7 @@
 {
 	if (capable(CAP_IPC_LOCK))
 		return 1;
-	if (current->rlim[RLIMIT_MEMLOCK].rlim_cur != 0)
+	if (current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur != 0)
 		return 1;
 	return 0;
 }
@@ -673,7 +675,7 @@
 extern struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *);
 extern int split_vma(struct mm_struct *,
 	struct vm_area_struct *, unsigned long addr, int new_below);
-extern void insert_vm_struct(struct mm_struct *, struct vm_area_struct *);
+extern int insert_vm_struct(struct mm_struct *, struct vm_area_struct *);
 extern void __vma_link_rb(struct mm_struct *, struct vm_area_struct *,
 	struct rb_node **, struct rb_node *);
 extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
@@ -756,10 +758,18 @@
 extern struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr);
 
 extern struct page * vmalloc_to_page(void *addr);
+extern unsigned long vmalloc_to_pfn(void *addr);
 extern struct page * follow_page(struct mm_struct *mm, unsigned long address,
 		int write);
-extern int remap_page_range(struct vm_area_struct *vma, unsigned long from,
-		unsigned long to, unsigned long size, pgprot_t prot);
+int remap_pfn_range(struct vm_area_struct *, unsigned long,
+		unsigned long, unsigned long, pgprot_t);
+
+static inline __deprecated /* since 25 Sept 2004 -- wli */
+int remap_page_range(struct vm_area_struct *vma, unsigned long uvaddr,
+			unsigned long paddr, unsigned long size, pgprot_t prot)
+{
+	return remap_pfn_range(vma, uvaddr, paddr >> PAGE_SHIFT, size, prot);
+}
 
 #ifdef CONFIG_PROC_FS
 void __vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
diff -Nru a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
--- a/include/linux/mmc/mmc.h	2004-12-24 13:36:55 -08:00
+++ b/include/linux/mmc/mmc.h	2004-12-24 13:36:55 -08:00
@@ -57,7 +57,7 @@
 	unsigned int		timeout_clks;	/* data timeout (in clocks) */
 	unsigned int		blksz_bits;	/* data block size */
 	unsigned int		blocks;		/* number of blocks */
-	struct request		*req;		/* request structure */
+	struct request		*req __attribute__((deprecated));/* request structure (use the sg list instead) */
 	unsigned int		error;		/* data error */
 	unsigned int		flags;
 
@@ -69,6 +69,9 @@
 
 	struct mmc_command	*stop;		/* stop command */
 	struct mmc_request	*mrq;		/* assoicated request */
+
+	unsigned int		sg_len;		/* size of scatter list */
+	struct scatterlist	*sg;		/* I/O scatter list */
 };
 
 struct mmc_request {
diff -Nru a/include/linux/mmzone.h b/include/linux/mmzone.h
--- a/include/linux/mmzone.h	2004-12-24 13:36:56 -08:00
+++ b/include/linux/mmzone.h	2004-12-24 13:36:56 -08:00
@@ -35,7 +35,7 @@
  */
 #if defined(CONFIG_SMP)
 struct zone_padding {
-	int x;
+	char x[0];
 } ____cacheline_maxaligned_in_smp;
 #define ZONE_PADDING(name)	struct zone_padding name;
 #else
@@ -108,10 +108,7 @@
  */
 
 struct zone {
-	/*
-	 * Commonly accessed fields:
-	 */
-	spinlock_t		lock;
+	/* Fields commonly accessed by the page allocator */
 	unsigned long		free_pages;
 	unsigned long		pages_min, pages_low, pages_high;
 	/*
@@ -128,8 +125,18 @@
 	 */
 	unsigned long		protection[MAX_NR_ZONES];
 
+	struct per_cpu_pageset	pageset[NR_CPUS];
+
+	/*
+	 * free areas of different sizes
+	 */
+	spinlock_t		lock;
+	struct free_area	free_area[MAX_ORDER];
+
+
 	ZONE_PADDING(_pad1_)
 
+	/* Fields commonly accessed by the page reclaim scanner */
 	spinlock_t		lru_lock;	
 	struct list_head	active_list;
 	struct list_head	inactive_list;
@@ -137,10 +144,8 @@
 	unsigned long		nr_scan_inactive;
 	unsigned long		nr_active;
 	unsigned long		nr_inactive;
-	int			all_unreclaimable; /* All pages pinned */
 	unsigned long		pages_scanned;	   /* since last reclaim */
-
-	ZONE_PADDING(_pad2_)
+	int			all_unreclaimable; /* All pages pinned */
 
 	/*
 	 * prev_priority holds the scanning priority for this zone.  It is
@@ -161,10 +166,9 @@
 	int temp_priority;
 	int prev_priority;
 
-	/*
-	 * free areas of different sizes
-	 */
-	struct free_area	free_area[MAX_ORDER];
+
+	ZONE_PADDING(_pad2_)
+	/* Rarely used or read-mostly fields */
 
 	/*
 	 * wait_table		-- the array holding the hash table
@@ -194,10 +198,6 @@
 	unsigned long		wait_table_size;
 	unsigned long		wait_table_bits;
 
-	ZONE_PADDING(_pad3_)
-
-	struct per_cpu_pageset	pageset[NR_CPUS];
-
 	/*
 	 * Discontig memory support fields.
 	 */
@@ -206,12 +206,13 @@
 	/* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */
 	unsigned long		zone_start_pfn;
 
+	unsigned long		spanned_pages;	/* total size, including holes */
+	unsigned long		present_pages;	/* amount of memory (excluding holes) */
+
 	/*
 	 * rarely used fields:
 	 */
 	char			*name;
-	unsigned long		spanned_pages;	/* total size, including holes */
-	unsigned long		present_pages;	/* amount of memory (excluding holes) */
 } ____cacheline_maxaligned_in_smp;
 
 
@@ -410,35 +411,6 @@
 #error ZONES_SHIFT > MAX_ZONES_SHIFT
 #endif
 
-extern DECLARE_BITMAP(node_online_map, MAX_NUMNODES);
-
-#if defined(CONFIG_DISCONTIGMEM) || defined(CONFIG_NUMA)
-
-#define node_online(node)	test_bit(node, node_online_map)
-#define node_set_online(node)	set_bit(node, node_online_map)
-#define node_set_offline(node)	clear_bit(node, node_online_map)
-static inline unsigned int num_online_nodes(void)
-{
-	int i, num = 0;
-
-	for(i = 0; i < MAX_NUMNODES; i++){
-		if (node_online(i))
-			num++;
-	}
-	return num;
-}
-
-#else /* !CONFIG_DISCONTIGMEM && !CONFIG_NUMA */
-
-#define node_online(node) \
-	({ BUG_ON((node) != 0); test_bit(node, node_online_map); })
-#define node_set_online(node) \
-	({ BUG_ON((node) != 0); set_bit(node, node_online_map); })
-#define node_set_offline(node) \
-	({ BUG_ON((node) != 0); clear_bit(node, node_online_map); })
-#define num_online_nodes()	1
-
-#endif /* CONFIG_DISCONTIGMEM || CONFIG_NUMA */
 #endif /* !__ASSEMBLY__ */
 #endif /* __KERNEL__ */
 #endif /* _LINUX_MMZONE_H */
diff -Nru a/include/linux/module.h b/include/linux/module.h
--- a/include/linux/module.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/module.h	2004-12-24 13:37:18 -08:00
@@ -44,6 +44,20 @@
 	char name[MODULE_NAME_LEN];
 };
 
+struct module;
+
+struct module_attribute {
+        struct attribute attr;
+        ssize_t (*show)(struct module *, char *);
+        ssize_t (*store)(struct module *, const char *, size_t count);
+};
+
+struct module_kobject
+{
+	struct kobject kobj;
+	struct module *mod;
+};
+
 /* These are either module local, or the kernel's dummy ones. */
 extern int init_module(void);
 extern void cleanup_module(void);
@@ -59,6 +73,8 @@
 		  struct exception_table_entry *finish);
 void sort_main_extable(void);
 
+extern struct subsystem module_subsys;
+
 #ifdef MODULE
 #define ___module_cat(a,b) __mod_ ## a ## b
 #define __module_cat(a,b) ___module_cat(a,b)
@@ -141,11 +157,9 @@
            customizations, eg "rh3" or "rusty1".
 
   Using this automatically adds a checksum of the .c files and the
-  local headers to the end.  Use MODULE_VERSION("") if you want just
-  this.  Macro includes room for this.
+  local headers in "srcversion".
 */
-#define MODULE_VERSION(_version) \
-  MODULE_INFO(version, _version "\0xxxxxxxxxxxxxxxxxxxxxxxx")
+#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
 
 /* Given an address, look for it in the exception tables */
 const struct exception_table_entry *search_exception_tables(unsigned long add);
@@ -208,23 +222,6 @@
 	MODULE_STATE_GOING,
 };
 
-/* sysfs stuff */
-struct module_attribute
-{
-	struct attribute attr;
-	struct kernel_param *param;
-};
-
-struct module_kobject
-{
-	/* Everyone should have one of these. */
-	struct kobject kobj;
-
-	/* We always have refcnt, we may have others from module_param(). */
-	unsigned int num_attributes;
-	struct module_attribute attr[0];
-};
-
 /* Similar stuff for section attributes. */
 #define MODULE_SECT_NAME_LEN 32
 struct module_sect_attr
@@ -240,6 +237,7 @@
 	struct module_sect_attr attrs[0];
 };
 
+struct param_kobject;
 
 struct module
 {
@@ -253,6 +251,7 @@
 
 	/* Sysfs stuff. */
 	struct module_kobject *mkobj;
+	struct param_kobject *params_kobject;
 
 	/* Exported symbols */
 	const struct kernel_symbol *syms;
@@ -304,9 +303,6 @@
 
 	/* Destruction function. */
 	void (*exit)(void);
-
-	/* Fake kernel param for refcnt. */
-	struct kernel_param refcnt_param;
 #endif
 
 #ifdef CONFIG_KALLSYMS
@@ -445,6 +441,11 @@
 int unregister_module_notifier(struct notifier_block * nb);
 
 extern void print_modules(void);
+
+struct device_driver;
+void module_add_driver(struct module *, struct device_driver *);
+void module_remove_driver(struct device_driver *);
+
 #else /* !CONFIG_MODULES... */
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
@@ -534,6 +535,18 @@
 static inline void print_modules(void)
 {
 }
+
+struct device_driver;
+struct module;
+
+static inline void module_add_driver(struct module *module, struct device_driver *driver)
+{
+}
+
+static inline void module_remove_driver(struct device_driver *driver)
+{
+}
+
 #endif /* CONFIG_MODULES */
 
 #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
@@ -545,45 +558,27 @@
 	char type[64-sizeof(void *)];
 	void *addr;
 };
+
+static inline void MODULE_PARM_(void) { }
 #ifdef MODULE
 /* DEPRECATED: Do not use. */
 #define MODULE_PARM(var,type)						    \
 struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \
-{ __stringify(var), type };
-
-static inline void __deprecated MOD_INC_USE_COUNT(struct module *module)
-{
-	__unsafe(module);
-
-#if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE)
-	local_inc(&module->ref[get_cpu()].count);
-	put_cpu();
-#else
-	(void)try_module_get(module);
-#endif
-}
-
-static inline void __deprecated MOD_DEC_USE_COUNT(struct module *module)
-{
-	module_put(module);
-}
-
-#define MOD_INC_USE_COUNT	MOD_INC_USE_COUNT(THIS_MODULE)
-#define MOD_DEC_USE_COUNT	MOD_DEC_USE_COUNT(THIS_MODULE)
+{ __stringify(var), type, &MODULE_PARM_ };
 #else
-#define MODULE_PARM(var,type)
-#define MOD_INC_USE_COUNT	do { } while (0)
-#define MOD_DEC_USE_COUNT	do { } while (0)
+#define MODULE_PARM(var,type) static void __attribute__((__unused__)) *__parm_##var = &MODULE_PARM_;
 #endif
 
 #define __MODULE_STRING(x) __stringify(x)
 
 /* Use symbol_get and symbol_put instead.  You'll thank me. */
 #define HAVE_INTER_MODULE
-extern void inter_module_register(const char *, struct module *, const void *);
-extern void inter_module_unregister(const char *);
-extern const void *inter_module_get(const char *);
-extern const void *inter_module_get_request(const char *, const char *);
-extern void inter_module_put(const char *);
+extern void __deprecated inter_module_register(const char *,
+		struct module *, const void *);
+extern void __deprecated inter_module_unregister(const char *);
+extern const void * __deprecated inter_module_get(const char *);
+extern const void * __deprecated inter_module_get_request(const char *,
+		const char *);
+extern void __deprecated inter_module_put(const char *);
 
 #endif /* _LINUX_MODULE_H */
diff -Nru a/include/linux/moduleparam.h b/include/linux/moduleparam.h
--- a/include/linux/moduleparam.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/moduleparam.h	2004-12-24 13:36:48 -08:00
@@ -129,16 +129,16 @@
 extern int param_get_invbool(char *buffer, struct kernel_param *kp);
 #define param_check_invbool(name, p) __param_check(name, p, int)
 
-/* Comma-separated array: num is set to number they actually specified. */
-#define module_param_array_named(name, array, type, num, perm)		\
+/* Comma-separated array: *nump is set to number they actually specified. */
+#define module_param_array_named(name, array, type, nump, perm)		\
 	static struct kparam_array __param_arr_##name			\
-	= { ARRAY_SIZE(array), &num, param_set_##type, param_get_##type,\
+	= { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type,\
 	    sizeof(array[0]), array };					\
 	module_param_call(name, param_array_set, param_array_get, 	\
 			  &__param_arr_##name, perm)
 
-#define module_param_array(name, type, num, perm)		\
-	module_param_array_named(name, name, type, num, perm)
+#define module_param_array(name, type, nump, perm)		\
+	module_param_array_named(name, name, type, nump, perm)
 
 extern int param_array_set(const char *val, struct kernel_param *kp);
 extern int param_array_get(char *buffer, struct kernel_param *kp);
@@ -152,4 +152,15 @@
 		void *elem, int elemsize,
 		int (*set)(const char *, struct kernel_param *kp),
 		int *num);
+
+/* for exporting parameters in /sys/parameters */
+
+struct module;
+
+extern int module_param_sysfs_setup(struct module *mod,
+				    struct kernel_param *kparam,
+				    unsigned int num_params);
+
+extern void module_param_sysfs_remove(struct module *mod);
+
 #endif /* _LINUX_MODULE_PARAMS_H */
diff -Nru a/include/linux/mount.h b/include/linux/mount.h
--- a/include/linux/mount.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/mount.h	2004-12-24 13:36:18 -08:00
@@ -13,6 +13,8 @@
 #ifdef __KERNEL__
 
 #include <linux/list.h>
+#include <linux/spinlock.h>
+#include <asm/atomic.h>
 
 #define MNT_NOSUID	1
 #define MNT_NODEV	2
diff -Nru a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
--- a/include/linux/msdos_fs.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/msdos_fs.h	2004-12-24 13:37:18 -08:00
@@ -87,8 +87,8 @@
 
 #define FAT_FSINFO_SIG1	0x41615252
 #define FAT_FSINFO_SIG2	0x61417272
-#define IS_FSINFO(x)	(CF_LE_L((x)->signature1) == FAT_FSINFO_SIG1	\
-			 && CF_LE_L((x)->signature2) == FAT_FSINFO_SIG2)
+#define IS_FSINFO(x)	(le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \
+			 && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2)
 
 /*
  * ioctl commands
@@ -232,8 +232,6 @@
 extern int fat_access(struct super_block *sb, int nr, int new_value);
 extern int __fat_access(struct super_block *sb, int nr, int new_value);
 extern int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys);
-extern void fat_cache_init(struct super_block *sb);
-extern void fat_cache_add(struct inode *inode, int f_clu, int d_clu);
 extern void fat_cache_inval_inode(struct inode *inode);
 extern int fat_get_cluster(struct inode *inode, int cluster,
 			   int *fclus, int *dclus);
@@ -244,9 +242,6 @@
 extern int fat_search_long(struct inode *inode, const unsigned char *name,
 			   int name_len, int anycase,
 			   loff_t *spos, loff_t *lpos);
-extern int fat_readdir(struct file *filp, void *dirent, filldir_t filldir);
-extern int fat_dir_ioctl(struct inode * inode, struct file * filp,
-			 unsigned int cmd, unsigned long arg);
 extern int fat_add_entries(struct inode *dir, int slots, struct buffer_head **bh,
 			struct msdos_dir_entry **de, loff_t *i_pos);
 extern int fat_new_dir(struct inode *dir, struct inode *parent, int is_vfat);
@@ -264,19 +259,13 @@
 extern void fat_truncate(struct inode *inode);
 
 /* fat/inode.c */
-extern void fat_hash_init(void);
 extern void fat_attach(struct inode *inode, loff_t i_pos);
 extern void fat_detach(struct inode *inode);
 extern struct inode *fat_iget(struct super_block *sb, loff_t i_pos);
 extern struct inode *fat_build_inode(struct super_block *sb,
 			struct msdos_dir_entry *de, loff_t i_pos, int *res);
-extern void fat_delete_inode(struct inode *inode);
-extern void fat_clear_inode(struct inode *inode);
-extern void fat_put_super(struct super_block *sb);
 int fat_fill_super(struct super_block *sb, void *data, int silent,
 		   struct inode_operations *fs_dir_inode_ops, int isvfat);
-extern int fat_statfs(struct super_block *sb, struct kstatfs *buf);
-extern int fat_write_inode(struct inode *inode, int wait);
 extern int fat_notify_change(struct dentry * dentry, struct iattr * attr);
 
 /* fat/misc.c */
diff -Nru a/include/linux/msdos_fs_i.h b/include/linux/msdos_fs_i.h
--- a/include/linux/msdos_fs_i.h	2004-12-24 13:37:29 -08:00
+++ b/include/linux/msdos_fs_i.h	2004-12-24 13:37:29 -08:00
@@ -7,10 +7,14 @@
  * MS-DOS file system inode data in memory
  */
 
+#define FAT_CACHE_VALID	0	/* special case for valid cache */
+
 struct msdos_inode_info {
-	/* cache of lastest accessed cluster */
-	int file_cluster;	/* cluster number in the file. */
-	int disk_cluster;	/* cluster number on disk. */
+	spinlock_t cache_lru_lock;
+	struct list_head cache_lru;
+	int nr_caches;
+	/* for avoiding the race between fat_free() and fat_get_cluster() */
+	unsigned int cache_valid_id;
 
 	loff_t mmu_private;
 	int i_start;	/* first cluster or 0 */
@@ -18,7 +22,7 @@
 	int i_attrs;	/* unused attribute bits */
 	int i_ctime_ms;	/* unused change time in milliseconds */
 	loff_t i_pos;	/* on-disk position of directory entry or 0 */
-	struct list_head i_fat_hash;	/* hash by i_location */
+	struct hlist_node i_fat_hash;	/* hash by i_location */
 	struct inode vfs_inode;
 };
 
diff -Nru a/include/linux/msdos_fs_sb.h b/include/linux/msdos_fs_sb.h
--- a/include/linux/msdos_fs_sb.h	2004-12-24 13:36:49 -08:00
+++ b/include/linux/msdos_fs_sb.h	2004-12-24 13:36:49 -08:00
@@ -26,14 +26,9 @@
 		 nocase:1;	  /* Does this need case conversion? 0=need case conversion*/
 };
 
-#define FAT_CACHE_NR	8 /* number of FAT cache */
-
-struct fat_cache {
-	int start_cluster; /* first cluster of the chain. */
-	int file_cluster; /* cluster number in the file. */
-	int disk_cluster; /* cluster number on disk. */
-	struct fat_cache *next; /* next cache entry */
-};
+#define FAT_HASH_BITS	8
+#define FAT_HASH_SIZE	(1UL << FAT_HASH_BITS)
+#define FAT_HASH_MASK	(FAT_HASH_SIZE-1)
 
 struct msdos_sb_info {
 	unsigned short sec_per_clus; /* sectors/cluster */
@@ -58,8 +53,8 @@
 	int dir_per_block;	     /* dir entries per block */
 	int dir_per_block_bits;	     /* log2(dir_per_block) */
 
-	spinlock_t cache_lock;
-	struct fat_cache cache_array[FAT_CACHE_NR], *cache;
+	spinlock_t inode_hash_lock;
+	struct hlist_head inode_hashtable[FAT_HASH_SIZE];
 };
 
 #endif
diff -Nru a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
--- a/include/linux/mtd/cfi.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/mtd/cfi.h	2004-12-24 13:36:47 -08:00
@@ -1,7 +1,7 @@
 
 /* Common Flash Interface structures 
  * See http://support.intel.com/design/flash/technote/index.htm
- * $Id: cfi.h,v 1.45 2004/07/20 02:44:27 dwmw2 Exp $
+ * $Id: cfi.h,v 1.49 2004/11/15 20:56:32 nico Exp $
  */
 
 #ifndef __MTD_CFI_H__
@@ -145,6 +145,24 @@
 	uint16_t ProtRegAddr;
 	uint8_t  FactProtRegSize;
 	uint8_t  UserProtRegSize;
+	uint8_t  extra[0];
+} __attribute__((packed));
+
+struct cfi_intelext_blockinfo {
+	uint16_t NumIdentBlocks;
+	uint16_t BlockSize;
+	uint16_t MinBlockEraseCycles;
+	uint8_t  BitsPerCell;
+	uint8_t  BlockCap;
+} __attribute__((packed));
+
+struct cfi_intelext_regioninfo {
+	uint16_t NumIdentPartitions;
+	uint8_t  NumOpAllowed;
+	uint8_t  NumOpAllowedSimProgMode;
+	uint8_t  NumOpAllowedSimEraMode;
+	uint8_t  NumBlockTypes;
+	struct cfi_intelext_blockinfo BlockTypes[1];
 } __attribute__((packed));
 
 /* Vendor-Specific PRI for AMD/Fujitsu Extended Command Set (0x0002) */
@@ -177,16 +195,19 @@
 	uint32_t ConfField[1]; /* Not host ordered */
 } __attribute__((packed));
 
-#define P_ID_NONE 0
-#define P_ID_INTEL_EXT 1
-#define P_ID_AMD_STD 2
-#define P_ID_INTEL_STD 3
-#define P_ID_AMD_EXT 4
-#define P_ID_ST_ADV 32
-#define P_ID_MITSUBISHI_STD 256
-#define P_ID_MITSUBISHI_EXT 257
-#define P_ID_SST_PAGE 258
-#define P_ID_RESERVED 65535
+#define P_ID_NONE               0x0000
+#define P_ID_INTEL_EXT          0x0001
+#define P_ID_AMD_STD            0x0002
+#define P_ID_INTEL_STD          0x0003
+#define P_ID_AMD_EXT            0x0004
+#define P_ID_WINBOND            0x0006
+#define P_ID_ST_ADV             0x0020
+#define P_ID_MITSUBISHI_STD     0x0100
+#define P_ID_MITSUBISHI_EXT     0x0101
+#define P_ID_SST_PAGE           0x0102
+#define P_ID_INTEL_PERFORMANCE  0x0200
+#define P_ID_INTEL_DATA         0x0210
+#define P_ID_RESERVED           0xffff
 
 
 #define CFI_MODE_CFI	1
@@ -350,17 +371,26 @@
 
 struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t size,
 			     const char* name);
-
 struct cfi_fixup {
 	uint16_t mfr;
 	uint16_t id;
-	void (*fixup)(struct map_info *map, void* param);
+	void (*fixup)(struct mtd_info *mtd, void* param);
 	void* param;
 };
 
 #define CFI_MFR_ANY 0xffff
 #define CFI_ID_ANY  0xffff
 
-void cfi_fixup(struct map_info *map, struct cfi_fixup* fixups);
+#define CFI_MFR_AMD 0x0001
+#define CFI_MFR_ST  0x0020 	/* STMicroelectronics */
+
+void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);
+
+typedef int (*varsize_frob_t)(struct map_info *map, struct flchip *chip,
+			      unsigned long adr, int len, void *thunk);
+
+int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
+	loff_t ofs, size_t len, void *thunk);
+
 
 #endif /* __MTD_CFI_H__ */
diff -Nru a/include/linux/mtd/doc2000.h b/include/linux/mtd/doc2000.h
--- a/include/linux/mtd/doc2000.h	2004-12-24 13:36:55 -08:00
+++ b/include/linux/mtd/doc2000.h	2004-12-24 13:36:55 -08:00
@@ -6,7 +6,7 @@
  * Copyright (C) 2002-2003 Greg Ungerer <gerg@snapgear.com>
  * Copyright (C) 2002-2003 SnapGear Inc
  *
- * $Id: doc2000.h,v 1.22 2003/11/05 10:51:36 dwmw2 Exp $ 
+ * $Id: doc2000.h,v 1.23 2004/09/16 23:26:08 gleixner Exp $ 
  *
  * Released under GPL
  */
@@ -89,8 +89,8 @@
 #define WriteDOC_(d, adr, reg)  do{ *(volatile __u16 *)(((unsigned long)adr)+((reg)<<1)) = (__u16)d; wmb();} while(0)
 #define DOC_IOREMAP_LEN 0x4000
 #else
-#define ReadDOC_(adr, reg)      readb(((unsigned long)adr) + (reg))
-#define WriteDOC_(d, adr, reg)  writeb(d, ((unsigned long)adr) + (reg))
+#define ReadDOC_(adr, reg)      readb((void __iomem *)(((unsigned long)adr) + (reg)))
+#define WriteDOC_(d, adr, reg)  writeb(d, (void __iomem *)(((unsigned long)adr) + (reg)))
 #define DOC_IOREMAP_LEN 0x2000
 
 #endif
@@ -168,7 +168,7 @@
 
 struct DiskOnChip {
 	unsigned long physadr;
-	unsigned long virtadr;
+	void __iomem *virtadr;
 	unsigned long totlen;
 	unsigned char ChipID; /* Type of DiskOnChip */
 	int ioreg;
diff -Nru a/include/linux/mtd/gen_probe.h b/include/linux/mtd/gen_probe.h
--- a/include/linux/mtd/gen_probe.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/mtd/gen_probe.h	2004-12-24 13:37:00 -08:00
@@ -10,7 +10,7 @@
 #include <linux/mtd/flashchip.h>
 #include <linux/mtd/map.h> 
 #include <linux/mtd/cfi.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 struct chip_probe {
 	char *name;
diff -Nru a/include/linux/mtd/map.h b/include/linux/mtd/map.h
--- a/include/linux/mtd/map.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/mtd/map.h	2004-12-24 13:36:47 -08:00
@@ -1,6 +1,6 @@
 
 /* Overhauled routines for dealing with different mmap regions of flash */
-/* $Id: map.h,v 1.43 2004/07/14 13:30:27 dwmw2 Exp $ */
+/* $Id: map.h,v 1.45 2004/09/21 14:31:17 bjd Exp $ */
 
 #ifndef __LINUX_MTD_MAP_H__
 #define __LINUX_MTD_MAP_H__
@@ -8,6 +8,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/mtd/compatmac.h>
 #include <asm/unaligned.h>
 #include <asm/system.h>
 #include <asm/io.h>
@@ -55,6 +56,11 @@
 #define map_bankwidth_is_4(map) (0)
 #endif
 
+/* ensure we never evaluate anything shorted than an unsigned long
+ * to zero, and ensure we'll never miss the end of an comparison (bjd) */
+
+#define map_calc_words(map) ((map_bankwidth(map) + (sizeof(unsigned long)-1))/ sizeof(unsigned long))
+
 #ifdef CONFIG_MTD_MAP_BANK_WIDTH_8
 # ifdef map_bankwidth
 #  undef map_bankwidth
@@ -63,12 +69,12 @@
 #   undef map_bankwidth_is_large
 #   define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
 #   undef map_words
-#   define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
+#   define map_words(map) map_calc_words(map)
 #  endif
 # else
 #  define map_bankwidth(map) 8
 #  define map_bankwidth_is_large(map) (BITS_PER_LONG < 64)
-#  define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
+#  define map_words(map) map_calc_words(map)
 # endif
 #define map_bankwidth_is_8(map) (map_bankwidth(map) == 8)
 #undef MAX_MAP_BANKWIDTH
@@ -84,11 +90,11 @@
 #  undef map_bankwidth_is_large
 #  define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
 #  undef map_words
-#  define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
+#  define map_words(map) map_calc_words(map)
 # else
 #  define map_bankwidth(map) 16
 #  define map_bankwidth_is_large(map) (1)
-#  define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
+#  define map_words(map) map_calc_words(map)
 # endif
 #define map_bankwidth_is_16(map) (map_bankwidth(map) == 16)
 #undef MAX_MAP_BANKWIDTH
@@ -104,11 +110,11 @@
 #  undef map_bankwidth_is_large
 #  define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
 #  undef map_words
-#  define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
+#  define map_words(map) map_calc_words(map)
 # else
 #  define map_bankwidth(map) 32
 #  define map_bankwidth_is_large(map) (1)
-#  define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
+#  define map_words(map) map_calc_words(map)
 # endif
 #define map_bankwidth_is_32(map) (map_bankwidth(map) == 32)
 #undef MAX_MAP_BANKWIDTH
diff -Nru a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
--- a/include/linux/mtd/nand.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/mtd/nand.h	2004-12-24 13:37:19 -08:00
@@ -5,7 +5,7 @@
  *                     Steven J. Hill <sjhill@realitydiluted.com>
  *		       Thomas Gleixner <tglx@linutronix.de>
  *
- * $Id: nand.h,v 1.63 2004/07/07 16:29:43 gleixner Exp $
+ * $Id: nand.h,v 1.66 2004/10/02 10:07:08 gleixner Exp $
  *
  * 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
@@ -212,6 +212,18 @@
 	FL_CACHEDPRG,
 } nand_state_t;
 
+/* Keep gcc happy */
+struct nand_chip;
+
+/**
+ * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independend devices
+ * @lock:               protection lock  
+ * @active:		the mtd device which holds the controller currently
+ */
+struct nand_hw_control {
+	spinlock_t	 lock;
+	struct nand_chip *active;
+};
 
 /**
  * struct nand_chip - NAND Private Flash Chip Data
@@ -265,12 +277,13 @@
  * @bbt:		[INTERN] bad block table pointer
  * @bbt_td:		[REPLACEABLE] bad block table descriptor for flash lookup
  * @bbt_md:		[REPLACEABLE] bad block table mirror descriptor
+ * @controller:		[OPTIONAL] a pointer to a hardware controller structure which is shared among multiple independend devices
  * @priv:		[OPTIONAL] pointer to private chip date
  */
  
 struct nand_chip {
-	unsigned long 	IO_ADDR_R;
-	unsigned long 	IO_ADDR_W;
+	void  __iomem	*IO_ADDR_R;
+	void  __iomem 	*IO_ADDR_W;
 	
 	u_char		(*read_byte)(struct mtd_info *mtd);
 	void		(*write_byte)(struct mtd_info *mtd, u_char byte);
@@ -317,6 +330,7 @@
 	uint8_t		*bbt;
 	struct nand_bbt_descr	*bbt_td;
 	struct nand_bbt_descr	*bbt_md;
+	struct nand_hw_control  *controller;
 	void		*priv;
 };
 
diff -Nru a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
--- a/include/linux/mtd/partitions.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/mtd/partitions.h	2004-12-24 13:37:19 -08:00
@@ -5,7 +5,7 @@
  *
  * This code is GPL
  *
- * $Id: partitions.h,v 1.15 2003/07/09 11:15:43 dwmw2 Exp $
+ * $Id: partitions.h,v 1.16 2004/11/16 18:34:40 dwmw2 Exp $
  */
 
 #ifndef MTD_PARTITIONS_H
@@ -64,7 +64,6 @@
 	int (*parse_fn)(struct mtd_info *, struct mtd_partition **, unsigned long);
 };
 
-extern struct mtd_part_parser *get_partition_parser(const char *name);
 extern int register_mtd_parser(struct mtd_part_parser *parser);
 extern int deregister_mtd_parser(struct mtd_part_parser *parser);
 extern int parse_mtd_partitions(struct mtd_info *master, const char **types, 
diff -Nru a/include/linux/net.h b/include/linux/net.h
--- a/include/linux/net.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/net.h	2004-12-24 13:36:48 -08:00
@@ -176,7 +176,6 @@
 extern int	     sock_wake_async(struct socket *sk, int how, int band);
 extern int	     sock_register(struct net_proto_family *fam);
 extern int	     sock_unregister(int family);
-extern struct socket *sock_alloc(void);
 extern int	     sock_create(int family, int type, int proto,
 				 struct socket **res);
 extern int	     sock_create_kern(int family, int type, int proto,
diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
--- a/include/linux/netdevice.h	2004-12-24 13:37:29 -08:00
+++ b/include/linux/netdevice.h	2004-12-24 13:37:29 -08:00
@@ -309,7 +309,9 @@
 
 	/* List of functions to handle Wireless Extensions (instead of ioctl).
 	 * See <net/iw_handler.h> for details. Jean II */
-	struct iw_handler_def *	wireless_handlers;
+	const struct iw_handler_def *	wireless_handlers;
+	/* Instance data managed by the core of Wireless Extensions. */
+	struct iw_public_data *	wireless_data;
 
 	struct ethtool_ops *ethtool_ops;
 
@@ -524,20 +526,13 @@
 extern int 			netdev_boot_setup_check(struct net_device *dev);
 extern unsigned long		netdev_boot_base(const char *prefix, int unit);
 extern struct net_device    *dev_getbyhwaddr(unsigned short type, char *hwaddr);
-extern struct net_device *__dev_getfirstbyhwtype(unsigned short type);
 extern struct net_device *dev_getfirstbyhwtype(unsigned short type);
 extern void		dev_add_pack(struct packet_type *pt);
 extern void		dev_remove_pack(struct packet_type *pt);
 extern void		__dev_remove_pack(struct packet_type *pt);
-extern int		__dev_get(const char *name);
-static inline int __deprecated dev_get(const char *name)
-{
-	return __dev_get(name);
-}
+
 extern struct net_device	*dev_get_by_flags(unsigned short flags,
 						  unsigned short mask);
-extern struct net_device	*__dev_get_by_flags(unsigned short flags,
-						    unsigned short mask);
 extern struct net_device	*dev_get_by_name(const char *name);
 extern struct net_device	*__dev_get_by_name(const char *name);
 extern int		dev_alloc_name(struct net_device *dev, const char *name);
@@ -551,7 +546,6 @@
 extern int 		register_netdevice_notifier(struct notifier_block *nb);
 extern int		unregister_netdevice_notifier(struct notifier_block *nb);
 extern int		call_netdevice_notifiers(unsigned long val, void *v);
-extern int		dev_new_index(void);
 extern struct net_device	*dev_get_by_index(int ifindex);
 extern struct net_device	*__dev_get_by_index(int ifindex);
 extern int		dev_restart(struct net_device *dev);
@@ -675,6 +669,7 @@
 
 #define HAVE_NETIF_RX 1
 extern int		netif_rx(struct sk_buff *skb);
+extern int		netif_rx_ni(struct sk_buff *skb);
 #define HAVE_NETIF_RECEIVE_SKB 1
 extern int		netif_receive_skb(struct sk_buff *skb);
 extern int		dev_ioctl(unsigned int cmd, void __user *);
@@ -689,17 +684,6 @@
 
 extern int		netdev_nit;
 
-/* Post buffer to the network code from _non interrupt_ context.
- * see net/core/dev.c for netif_rx description.
- */
-static inline int netif_rx_ni(struct sk_buff *skb)
-{
-       int err = netif_rx(skb);
-       if (softirq_pending(smp_processor_id()))
-               do_softirq();
-       return err;
-}
-
 /* Called by rtnetlink.c:rtnl_unlock() */
 extern void netdev_run_todo(void);
 
@@ -918,10 +902,7 @@
 /* These functions live elsewhere (drivers/net/net_init.c, but related) */
 
 extern void		ether_setup(struct net_device *dev);
-extern void		fddi_setup(struct net_device *dev);
-extern void		tr_setup(struct net_device *dev);
-extern void		fc_setup(struct net_device *dev);
-extern void		fc_freedev(struct net_device *dev);
+
 /* Support for loadable net-drivers */
 extern struct net_device *alloc_netdev(int sizeof_priv, const char *name,
 				       void (*setup)(struct net_device *));
@@ -938,14 +919,15 @@
 /* Load a device via the kmod */
 extern void		dev_load(const char *name);
 extern void		dev_mcast_init(void);
-extern int		netdev_register_fc(struct net_device *dev, void (*stimul)(struct net_device *dev));
-extern void		netdev_unregister_fc(int bit);
 extern int		netdev_max_backlog;
 extern int		weight_p;
 extern unsigned long	netdev_fc_xoff;
 extern atomic_t netdev_dropping;
 extern int		netdev_set_master(struct net_device *dev, struct net_device *master);
-extern int skb_checksum_help(struct sk_buff **pskb, int inward);
+extern int skb_checksum_help(struct sk_buff *skb, int inward);
+/* rx skb timestamps */
+extern void		net_enable_timestamp(void);
+extern void		net_disable_timestamp(void);
 
 #ifdef CONFIG_SYSCTL
 extern char *net_sysctl_strdup(const char *s);
diff -Nru a/include/linux/netfilter.h b/include/linux/netfilter.h
--- a/include/linux/netfilter.h	2004-12-24 13:36:54 -08:00
+++ b/include/linux/netfilter.h	2004-12-24 13:36:54 -08:00
@@ -172,13 +172,8 @@
 			struct nf_info *info,
 			unsigned int verdict);
 
-extern inline struct ipt_target *
-ipt_find_target_lock(const char *name, int *error, struct semaphore *mutex);
-extern inline struct ip6t_target *
-ip6t_find_target_lock(const char *name, int *error, struct semaphore *mutex);
-extern inline struct arpt_target *
-arpt_find_target_lock(const char *name, int *error, struct semaphore *mutex);
 extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *);
+extern void nf_ct_attach(struct sk_buff *, struct sk_buff *);
 
 #ifdef CONFIG_NETFILTER_DEBUG
 extern void nf_dump_skb(int pf, struct sk_buff *skb);
@@ -189,6 +184,7 @@
 
 #else /* !CONFIG_NETFILTER */
 #define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb)
+static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
 #endif /*CONFIG_NETFILTER*/
 
 #endif /*__KERNEL__*/
diff -Nru a/include/linux/netfilter_ipv4/ip_conntrack.h b/include/linux/netfilter_ipv4/ip_conntrack.h
--- a/include/linux/netfilter_ipv4/ip_conntrack.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/netfilter_ipv4/ip_conntrack.h	2004-12-24 13:37:19 -08:00
@@ -212,6 +212,10 @@
 	} nat;
 #endif /* CONFIG_IP_NF_NAT_NEEDED */
 
+#if defined(CONFIG_IP_NF_CONNTRACK_MARK)
+	unsigned long mark;
+#endif
+
 	/* Traversed often, so hopefully in different cacheline to top */
 	/* These are my tuples; original and reply */
 	struct ip_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX];
diff -Nru a/include/linux/netfilter_ipv4/ip_conntrack_tcp.h b/include/linux/netfilter_ipv4/ip_conntrack_tcp.h
--- a/include/linux/netfilter_ipv4/ip_conntrack_tcp.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/netfilter_ipv4/ip_conntrack_tcp.h	2004-12-24 13:36:47 -08:00
@@ -18,7 +18,7 @@
 };
 
 /* Window scaling is advertised by the sender */
-#define IP_CT_TCP_STATE_FLAG_WINDOW_SCALE	0x01
+#define IP_CT_TCP_FLAG_WINDOW_SCALE		0x01
 
 /* SACK is permitted by the sender */
 #define IP_CT_TCP_FLAG_SACK_PERM		0x02
diff -Nru a/include/linux/netfilter_ipv4/ip_nat_protocol.h b/include/linux/netfilter_ipv4/ip_nat_protocol.h
--- a/include/linux/netfilter_ipv4/ip_nat_protocol.h	2004-12-24 13:36:56 -08:00
+++ b/include/linux/netfilter_ipv4/ip_nat_protocol.h	2004-12-24 13:36:56 -08:00
@@ -18,7 +18,7 @@
 	/* Do a packet translation according to the ip_nat_proto_manip
 	 * and manip type.  Return true if succeeded. */
 	int (*manip_pkt)(struct sk_buff **pskb,
-			 unsigned int hdroff,
+			 unsigned int iphdroff,
 			 const struct ip_conntrack_manip *manip,
 			 enum ip_nat_manip_type maniptype);
 
diff -Nru a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
--- a/include/linux/netfilter_ipv4/ip_tables.h	2004-12-24 13:36:55 -08:00
+++ b/include/linux/netfilter_ipv4/ip_tables.h	2004-12-24 13:36:55 -08:00
@@ -407,16 +407,15 @@
 	struct module *me;
 };
 
-extern struct ipt_target *
-ipt_find_target_lock(const char *name, int *error, struct semaphore *mutex);
-extern struct arpt_target *
-arpt_find_target_lock(const char *name, int *error, struct semaphore *mutex);
-
 extern int ipt_register_target(struct ipt_target *target);
 extern void ipt_unregister_target(struct ipt_target *target);
 
 extern int ipt_register_match(struct ipt_match *match);
 extern void ipt_unregister_match(struct ipt_match *match);
+
+extern struct ipt_target *
+__ipt_find_target_lock(const char *name, int *error);
+extern void __ipt_mutex_up(void);
 
 /* Furniture shopping... */
 struct ipt_table
diff -Nru a/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,32 @@
+#ifndef _IPT_CLUSTERIP_H_target
+#define _IPT_CLUSTERIP_H_target
+
+enum clusterip_hashmode {
+    CLUSTERIP_HASHMODE_SIP = 0,
+    CLUSTERIP_HASHMODE_SIP_SPT,
+    CLUSTERIP_HASHMODE_SIP_SPT_DPT,
+};
+
+#define CLUSTERIP_HASHMODE_MAX CLUSTERIP_HASHMODE_SIP_SPT_DPT
+
+#define CLUSTERIP_MAX_NODES 16
+
+#define CLUSTERIP_FLAG_NEW 0x00000001
+
+struct clusterip_config;
+
+struct ipt_clusterip_tgt_info {
+
+	u_int32_t flags;
+	struct clusterip_config *config;
+	
+	/* only relevant for new ones */
+	u_int8_t clustermac[6];
+	u_int16_t num_total_nodes;
+	u_int16_t num_local_nodes;
+	u_int16_t local_nodes[CLUSTERIP_MAX_NODES];
+	enum clusterip_hashmode hash_mode;
+	u_int32_t hash_initval;
+};
+
+#endif /*_IPT_CLUSTERIP_H_target*/
diff -Nru a/include/linux/netfilter_ipv4/ipt_CONNMARK.h b/include/linux/netfilter_ipv4/ipt_CONNMARK.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/netfilter_ipv4/ipt_CONNMARK.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,25 @@
+#ifndef _IPT_CONNMARK_H_target
+#define _IPT_CONNMARK_H_target
+
+/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
+ * by Henrik Nordstrom <hno@marasystems.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.
+ */
+
+enum {
+	IPT_CONNMARK_SET = 0,
+	IPT_CONNMARK_SAVE,
+	IPT_CONNMARK_RESTORE
+};
+
+struct ipt_connmark_target_info {
+	unsigned long mark;
+	unsigned long mask;
+	u_int8_t mode;
+};
+
+#endif /*_IPT_CONNMARK_H_target*/
diff -Nru a/include/linux/netfilter_ipv4/ipt_connmark.h b/include/linux/netfilter_ipv4/ipt_connmark.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/netfilter_ipv4/ipt_connmark.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,18 @@
+#ifndef _IPT_CONNMARK_H
+#define _IPT_CONNMARK_H
+
+/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
+ * by Henrik Nordstrom <hno@marasystems.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.
+ */
+
+struct ipt_connmark_info {
+	unsigned long mark, mask;
+	u_int8_t invert;
+};
+
+#endif /*_IPT_CONNMARK_H*/
diff -Nru a/include/linux/netfilter_ipv4/ipt_hashlimit.h b/include/linux/netfilter_ipv4/ipt_hashlimit.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/netfilter_ipv4/ipt_hashlimit.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,40 @@
+#ifndef _IPT_HASHLIMIT_H
+#define _IPT_HASHLIMIT_H
+
+/* timings are in milliseconds. */
+#define IPT_HASHLIMIT_SCALE 10000
+/* 1/10,000 sec period => max of 10,000/sec.  Min rate is then 429490
+   seconds, or one every 59 hours. */
+
+/* details of this structure hidden by the implementation */
+struct ipt_hashlimit_htable;
+
+#define IPT_HASHLIMIT_HASH_DIP	0x0001
+#define IPT_HASHLIMIT_HASH_DPT	0x0002
+#define IPT_HASHLIMIT_HASH_SIP	0x0004
+#define IPT_HASHLIMIT_HASH_SPT	0x0008
+
+struct hashlimit_cfg {
+	u_int32_t mode;	  /* bitmask of IPT_HASHLIMIT_HASH_* */
+	u_int32_t avg;    /* Average secs between packets * scale */
+	u_int32_t burst;  /* Period multiplier for upper limit. */
+
+	/* user specified */
+	u_int32_t size;		/* how many buckets */
+	u_int32_t max;		/* max number of entries */
+	u_int32_t gc_interval;	/* gc interval */
+	u_int32_t expire;	/* when do entries expire? */
+};
+
+struct ipt_hashlimit_info {
+	char name [IFNAMSIZ];		/* name */
+	struct hashlimit_cfg cfg;
+	struct ipt_hashlimit_htable *hinfo;
+
+	/* Used internally by the kernel */
+	union {
+		void *ptr;
+		struct ipt_hashlimit_info *master;
+	} u;
+};
+#endif /*_IPT_HASHLIMIT_H*/
diff -Nru a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
--- a/include/linux/netfilter_ipv6/ip6_tables.h	2004-12-24 13:37:29 -08:00
+++ b/include/linux/netfilter_ipv6/ip6_tables.h	2004-12-24 13:37:29 -08:00
@@ -355,13 +355,15 @@
 
 	/* Return true or false: return FALSE and set *hotdrop = 1 to
            force immediate packet drop. */
+	/* Arguments changed since 2.6.9, as this must now handle
+	   non-linear skb, using skb_header_pointer and
+	   skb_ip_make_writable. */
 	int (*match)(const struct sk_buff *skb,
 		     const struct net_device *in,
 		     const struct net_device *out,
 		     const void *matchinfo,
 		     int offset,
-		     const void *hdr,
-		     u_int16_t datalen,
+		     unsigned int protoff,
 		     int *hotdrop);
 
 	/* Called when user tries to insert an entry of this type. */
@@ -386,11 +388,13 @@
 
 	const char name[IP6T_FUNCTION_MAXNAMELEN];
 
-	/* Returns verdict. */
+	/* Returns verdict. Argument order changed since 2.6.9, as this
+	   must now handle non-linear skbs, using skb_copy_bits and
+	   skb_ip_make_writable. */
 	unsigned int (*target)(struct sk_buff **pskb,
-			       unsigned int hooknum,
 			       const struct net_device *in,
 			       const struct net_device *out,
+			       unsigned int hooknum,
 			       const void *targinfo,
 			       void *userdata);
 
diff -Nru a/include/linux/netlink.h b/include/linux/netlink.h
--- a/include/linux/netlink.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/netlink.h	2004-12-24 13:37:18 -08:00
@@ -17,6 +17,7 @@
 #define NETLINK_ROUTE6		11	/* af_inet6 route comm channel */
 #define NETLINK_IP6_FW		13
 #define NETLINK_DNRTMSG		14	/* DECnet routing messages */
+#define NETLINK_KOBJECT_UEVENT	15	/* Kernel messages to userspace */
 #define NETLINK_TAPBASE		16	/* 16 to 31 are ethertap */
 
 #define MAX_LINKS 32		
diff -Nru a/include/linux/nfs4.h b/include/linux/nfs4.h
--- a/include/linux/nfs4.h	2004-12-24 13:36:49 -08:00
+++ b/include/linux/nfs4.h	2004-12-24 13:36:49 -08:00
@@ -35,6 +35,7 @@
 #define NFS4_FH_VOL_RENAME		0x0008
 
 #define NFS4_OPEN_RESULT_CONFIRM 0x0002
+#define NFS4_OPEN_RESULT_LOCKTYPE_POSIX 0x0004
 
 #define NFS4_SHARE_ACCESS_READ	0x0001
 #define NFS4_SHARE_ACCESS_WRITE	0x0002
diff -Nru a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
--- a/include/linux/nfsd/state.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/nfsd/state.h	2004-12-24 13:36:17 -08:00
@@ -38,6 +38,7 @@
 #define _NFSD4_STATE_H
 
 #include <linux/list.h>
+#include <linux/kref.h>
 #include <linux/sunrpc/clnt.h>
 
 #define NFS4_OPAQUE_LIMIT 1024
@@ -168,6 +169,7 @@
 *         reaped by laundramat thread after lease period.
 */
 struct nfs4_stateowner {
+	struct kref		so_ref;
 	struct list_head        so_idhash;   /* hash by so_id */
 	struct list_head        so_strhash;   /* hash by op_name */
 	struct list_head        so_perclient; /* nfs4_client->cl_perclient */
@@ -248,4 +250,18 @@
 extern void nfs4_unlock_state(void);
 extern int nfs4_in_grace(void);
 extern int nfs4_check_open_reclaim(clientid_t *clid);
+extern void nfs4_free_stateowner(struct kref *kref);
+
+static inline void
+nfs4_put_stateowner(struct nfs4_stateowner *so)
+{
+	kref_put(&so->so_ref, nfs4_free_stateowner);
+}
+
+static inline void
+nfs4_get_stateowner(struct nfs4_stateowner *so)
+{
+	kref_get(&so->so_ref);
+}
+
 #endif   /* NFSD4_STATE_H */
diff -Nru a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
--- a/include/linux/nfsd/xdr4.h	2004-12-24 13:36:19 -08:00
+++ b/include/linux/nfsd/xdr4.h	2004-12-24 13:36:19 -08:00
@@ -116,6 +116,7 @@
 };
 
 struct nfsd4_lock_denied {
+	clientid_t	ld_clientid;
 	struct nfs4_stateowner   *ld_sop;
 	u64             ld_start;
 	u64             ld_length;
diff -Nru a/include/linux/nodemask.h b/include/linux/nodemask.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/nodemask.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,326 @@
+#ifndef __LINUX_NODEMASK_H
+#define __LINUX_NODEMASK_H
+
+/*
+ * Nodemasks provide a bitmap suitable for representing the
+ * set of Node's in a system, one bit position per Node number.
+ *
+ * See detailed comments in the file linux/bitmap.h describing the
+ * data type on which these nodemasks are based.
+ *
+ * For details of nodemask_scnprintf() and nodemask_parse(),
+ * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c.
+ *
+ * The available nodemask operations are:
+ *
+ * void node_set(node, mask)		turn on bit 'node' in mask
+ * void node_clear(node, mask)		turn off bit 'node' in mask
+ * void nodes_setall(mask)		set all bits
+ * void nodes_clear(mask)		clear all bits
+ * int node_isset(node, mask)		true iff bit 'node' set in mask
+ * int node_test_and_set(node, mask)	test and set bit 'node' in mask
+ *
+ * void nodes_and(dst, src1, src2)	dst = src1 & src2  [intersection]
+ * void nodes_or(dst, src1, src2)	dst = src1 | src2  [union]
+ * void nodes_xor(dst, src1, src2)	dst = src1 ^ src2
+ * void nodes_andnot(dst, src1, src2)	dst = src1 & ~src2
+ * void nodes_complement(dst, src)	dst = ~src
+ *
+ * int nodes_equal(mask1, mask2)	Does mask1 == mask2?
+ * int nodes_intersects(mask1, mask2)	Do mask1 and mask2 intersect?
+ * int nodes_subset(mask1, mask2)	Is mask1 a subset of mask2?
+ * int nodes_empty(mask)		Is mask empty (no bits sets)?
+ * int nodes_full(mask)			Is mask full (all bits sets)?
+ * int nodes_weight(mask)		Hamming weight - number of set bits
+ *
+ * void nodes_shift_right(dst, src, n)	Shift right
+ * void nodes_shift_left(dst, src, n)	Shift left
+ *
+ * int first_node(mask)			Number lowest set bit, or MAX_NUMNODES
+ * int next_node(node, mask)		Next node past 'node', or MAX_NUMNODES
+ *
+ * nodemask_t nodemask_of_node(node)	Return nodemask with bit 'node' set
+ * NODE_MASK_ALL			Initializer - all bits set
+ * NODE_MASK_NONE			Initializer - no bits set
+ * unsigned long *nodes_addr(mask)	Array of unsigned long's in mask
+ *
+ * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
+ * int nodemask_parse(ubuf, ulen, mask)	Parse ascii string as nodemask
+ *
+ * for_each_node_mask(node, mask)	for-loop node over mask
+ *
+ * int num_online_nodes()		Number of online Nodes
+ * int num_possible_nodes()		Number of all possible Nodes
+ *
+ * int node_online(node)		Is some node online?
+ * int node_possible(node)		Is some node possible?
+ *
+ * int any_online_node(mask)		First online node in mask
+ *
+ * node_set_online(node)		set bit 'node' in node_online_map
+ * node_set_offline(node)		clear bit 'node' in node_online_map
+ *
+ * for_each_node(node)			for-loop node over node_possible_map
+ * for_each_online_node(node)		for-loop node over node_online_map
+ *
+ * Subtlety:
+ * 1) The 'type-checked' form of node_isset() causes gcc (3.3.2, anyway)
+ *    to generate slightly worse code.  So use a simple one-line #define
+ *    for node_isset(), instead of wrapping an inline inside a macro, the
+ *    way we do the other calls.
+ */
+
+#include <linux/kernel.h>
+#include <linux/threads.h>
+#include <linux/bitmap.h>
+#include <linux/numa.h>
+#include <asm/bug.h>
+
+typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
+extern nodemask_t _unused_nodemask_arg_;
+
+#define node_set(node, dst) __node_set((node), &(dst))
+static inline void __node_set(int node, volatile nodemask_t *dstp)
+{
+	set_bit(node, dstp->bits);
+}
+
+#define node_clear(node, dst) __node_clear((node), &(dst))
+static inline void __node_clear(int node, volatile nodemask_t *dstp)
+{
+	clear_bit(node, dstp->bits);
+}
+
+#define nodes_setall(dst) __nodes_setall(&(dst), MAX_NUMNODES)
+static inline void __nodes_setall(nodemask_t *dstp, int nbits)
+{
+	bitmap_fill(dstp->bits, nbits);
+}
+
+#define nodes_clear(dst) __nodes_clear(&(dst), MAX_NUMNODES)
+static inline void __nodes_clear(nodemask_t *dstp, int nbits)
+{
+	bitmap_zero(dstp->bits, nbits);
+}
+
+/* No static inline type checking - see Subtlety (1) above. */
+#define node_isset(node, nodemask) test_bit((node), (nodemask).bits)
+
+#define node_test_and_set(node, nodemask) \
+			__node_test_and_set((node), &(nodemask))
+static inline int __node_test_and_set(int node, nodemask_t *addr)
+{
+	return test_and_set_bit(node, addr->bits);
+}
+
+#define nodes_and(dst, src1, src2) \
+			__nodes_and(&(dst), &(src1), &(src2), MAX_NUMNODES)
+static inline void __nodes_and(nodemask_t *dstp, const nodemask_t *src1p,
+					const nodemask_t *src2p, int nbits)
+{
+	bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
+}
+
+#define nodes_or(dst, src1, src2) \
+			__nodes_or(&(dst), &(src1), &(src2), MAX_NUMNODES)
+static inline void __nodes_or(nodemask_t *dstp, const nodemask_t *src1p,
+					const nodemask_t *src2p, int nbits)
+{
+	bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits);
+}
+
+#define nodes_xor(dst, src1, src2) \
+			__nodes_xor(&(dst), &(src1), &(src2), MAX_NUMNODES)
+static inline void __nodes_xor(nodemask_t *dstp, const nodemask_t *src1p,
+					const nodemask_t *src2p, int nbits)
+{
+	bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits);
+}
+
+#define nodes_andnot(dst, src1, src2) \
+			__nodes_andnot(&(dst), &(src1), &(src2), MAX_NUMNODES)
+static inline void __nodes_andnot(nodemask_t *dstp, const nodemask_t *src1p,
+					const nodemask_t *src2p, int nbits)
+{
+	bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
+}
+
+#define nodes_complement(dst, src) \
+			__nodes_complement(&(dst), &(src), MAX_NUMNODES)
+static inline void __nodes_complement(nodemask_t *dstp,
+					const nodemask_t *srcp, int nbits)
+{
+	bitmap_complement(dstp->bits, srcp->bits, nbits);
+}
+
+#define nodes_equal(src1, src2) \
+			__nodes_equal(&(src1), &(src2), MAX_NUMNODES)
+static inline int __nodes_equal(const nodemask_t *src1p,
+					const nodemask_t *src2p, int nbits)
+{
+	return bitmap_equal(src1p->bits, src2p->bits, nbits);
+}
+
+#define nodes_intersects(src1, src2) \
+			__nodes_intersects(&(src1), &(src2), MAX_NUMNODES)
+static inline int __nodes_intersects(const nodemask_t *src1p,
+					const nodemask_t *src2p, int nbits)
+{
+	return bitmap_intersects(src1p->bits, src2p->bits, nbits);
+}
+
+#define nodes_subset(src1, src2) \
+			__nodes_subset(&(src1), &(src2), MAX_NUMNODES)
+static inline int __nodes_subset(const nodemask_t *src1p,
+					const nodemask_t *src2p, int nbits)
+{
+	return bitmap_subset(src1p->bits, src2p->bits, nbits);
+}
+
+#define nodes_empty(src) __nodes_empty(&(src), MAX_NUMNODES)
+static inline int __nodes_empty(const nodemask_t *srcp, int nbits)
+{
+	return bitmap_empty(srcp->bits, nbits);
+}
+
+#define nodes_full(nodemask) __nodes_full(&(nodemask), MAX_NUMNODES)
+static inline int __nodes_full(const nodemask_t *srcp, int nbits)
+{
+	return bitmap_full(srcp->bits, nbits);
+}
+
+#define nodes_weight(nodemask) __nodes_weight(&(nodemask), MAX_NUMNODES)
+static inline int __nodes_weight(const nodemask_t *srcp, int nbits)
+{
+	return bitmap_weight(srcp->bits, nbits);
+}
+
+#define nodes_shift_right(dst, src, n) \
+			__nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES)
+static inline void __nodes_shift_right(nodemask_t *dstp,
+					const nodemask_t *srcp, int n, int nbits)
+{
+	bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
+}
+
+#define nodes_shift_left(dst, src, n) \
+			__nodes_shift_left(&(dst), &(src), (n), MAX_NUMNODES)
+static inline void __nodes_shift_left(nodemask_t *dstp,
+					const nodemask_t *srcp, int n, int nbits)
+{
+	bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
+}
+
+#define first_node(src) __first_node(&(src), MAX_NUMNODES)
+static inline int __first_node(const nodemask_t *srcp, int nbits)
+{
+	return min_t(int, nbits, find_first_bit(srcp->bits, nbits));
+}
+
+#define next_node(n, src) __next_node((n), &(src), MAX_NUMNODES)
+static inline int __next_node(int n, const nodemask_t *srcp, int nbits)
+{
+	return min_t(int, nbits, find_next_bit(srcp->bits, nbits, n+1));
+}
+
+#define nodemask_of_node(node)						\
+({									\
+	typeof(_unused_nodemask_arg_) m;				\
+	if (sizeof(m) == sizeof(unsigned long)) {			\
+		m.bits[0] = 1UL<<(node);				\
+	} else {							\
+		nodes_clear(m);						\
+		node_set((node), m);					\
+	}								\
+	m;								\
+})
+
+#define NODE_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES)
+
+#if MAX_NUMNODES <= BITS_PER_LONG
+
+#define NODE_MASK_ALL							\
+((nodemask_t) { {							\
+	[BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD		\
+} })
+
+#else
+
+#define NODE_MASK_ALL							\
+((nodemask_t) { {							\
+	[0 ... BITS_TO_LONGS(MAX_NUMNODES)-2] = ~0UL,			\
+	[BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD		\
+} })
+
+#endif
+
+#define NODE_MASK_NONE							\
+((nodemask_t) { {							\
+	[0 ... BITS_TO_LONGS(MAX_NUMNODES)-1] =  0UL			\
+} })
+
+#define nodes_addr(src) ((src).bits)
+
+#define nodemask_scnprintf(buf, len, src) \
+			__nodemask_scnprintf((buf), (len), &(src), MAX_NUMNODES)
+static inline int __nodemask_scnprintf(char *buf, int len,
+					const nodemask_t *srcp, int nbits)
+{
+	return bitmap_scnprintf(buf, len, srcp->bits, nbits);
+}
+
+#define nodemask_parse(ubuf, ulen, src) \
+			__nodemask_parse((ubuf), (ulen), &(src), MAX_NUMNODES)
+static inline int __nodemask_parse(const char __user *buf, int len,
+					nodemask_t *dstp, int nbits)
+{
+	return bitmap_parse(buf, len, dstp->bits, nbits);
+}
+
+#if MAX_NUMNODES > 1
+#define for_each_node_mask(node, mask)			\
+	for ((node) = first_node(mask);			\
+		(node) < MAX_NUMNODES;			\
+		(node) = next_node((node), (mask)))
+#else /* MAX_NUMNODES == 1 */
+#define for_each_node_mask(node, mask)			\
+	if (!nodes_empty(mask))				\
+		for ((node) = 0; (node) < 1; (node)++)
+#endif /* MAX_NUMNODES */
+
+/*
+ * The following particular system nodemasks and operations
+ * on them manage all possible and online nodes.
+ */
+
+extern nodemask_t node_online_map;
+extern nodemask_t node_possible_map;
+
+#if MAX_NUMNODES > 1
+#define num_online_nodes()	nodes_weight(node_online_map)
+#define num_possible_nodes()	nodes_weight(node_possible_map)
+#define node_online(node)	node_isset((node), node_online_map)
+#define node_possible(node)	node_isset((node), node_possible_map)
+#else
+#define num_online_nodes()	1
+#define num_possible_nodes()	1
+#define node_online(node)	((node) == 0)
+#define node_possible(node)	((node) == 0)
+#endif
+
+#define any_online_node(mask)			\
+({						\
+	int node;				\
+	for_each_node_mask(node, (mask))	\
+		if (node_online(node))		\
+			break;			\
+	node;					\
+})
+
+#define node_set_online(node)	   set_bit((node), node_online_map.bits)
+#define node_set_offline(node)	   clear_bit((node), node_online_map.bits)
+
+#define for_each_node(node)	   for_each_node_mask((node), node_possible_map)
+#define for_each_online_node(node) for_each_node_mask((node), node_online_map)
+
+#endif /* __LINUX_NODEMASK_H */
diff -Nru a/include/linux/notifier.h b/include/linux/notifier.h
--- a/include/linux/notifier.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/notifier.h	2004-12-24 13:36:18 -08:00
@@ -64,10 +64,12 @@
 
 #define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
-#define CPU_ONLINE	0x0002 /* CPU (unsigned)v is up */
-#define CPU_UP_PREPARE	0x0003 /* CPU (unsigned)v coming up */
-#define CPU_UP_CANCELED	0x0004 /* CPU (unsigned)v NOT coming up */
-#define CPU_DEAD	0x0006 /* CPU (unsigned)v dead */
+#define CPU_ONLINE		0x0002 /* CPU (unsigned)v is up */
+#define CPU_UP_PREPARE		0x0003 /* CPU (unsigned)v coming up */
+#define CPU_UP_CANCELED		0x0004 /* CPU (unsigned)v NOT coming up */
+#define CPU_DOWN_PREPARE	0x0005 /* CPU (unsigned)v going down */
+#define CPU_DOWN_FAILED		0x0006 /* CPU (unsigned)v NOT going down */
+#define CPU_DEAD		0x0007 /* CPU (unsigned)v dead */
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_NOTIFIER_H */
diff -Nru a/include/linux/pagevec.h b/include/linux/pagevec.h
--- a/include/linux/pagevec.h	2004-12-24 13:37:30 -08:00
+++ b/include/linux/pagevec.h	2004-12-24 13:37:30 -08:00
@@ -5,14 +5,15 @@
  * pages.  A pagevec is a multipage container which is used for that.
  */
 
-#define PAGEVEC_SIZE	16
+/* 14 pointers + two long's align the pagevec structure to a power of two */
+#define PAGEVEC_SIZE	14
 
 struct page;
 struct address_space;
 
 struct pagevec {
-	unsigned nr;
-	int cold;
+	unsigned long nr;
+	unsigned long cold;
 	struct page *pages[PAGEVEC_SIZE];
 };
 
diff -Nru a/include/linux/parport.h b/include/linux/parport.h
--- a/include/linux/parport.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/parport.h	2004-12-24 13:37:19 -08:00
@@ -466,7 +466,6 @@
 				    int usec);
 
 /* For architectural drivers */
-extern void parport_ieee1284_wakeup (struct parport *port);
 extern size_t parport_ieee1284_write_compat (struct parport *,
 					     const void *, size_t, int);
 extern size_t parport_ieee1284_read_nibble (struct parport *,
@@ -500,20 +499,8 @@
 extern void parport_close (struct pardevice *dev);
 extern ssize_t parport_device_id (int devnum, char *buffer, size_t len);
 extern int parport_device_num (int parport, int mux, int daisy);
-extern int parport_device_coords (int devnum, int *parport, int *mux,
-				  int *daisy);
 extern void parport_daisy_deselect_all (struct parport *port);
 extern int parport_daisy_select (struct parport *port, int daisy, int mode);
-
-/* For finding devices based on their device ID.  Example usage:
-   int devnum = -1;
-   while ((devnum = parport_find_class (PARPORT_CLASS_DIGCAM, devnum)) != -1) {
-       struct pardevice *dev = parport_open (devnum, ...);
-       ...
-   }
-*/
-extern int parport_find_device (const char *mfg, const char *mdl, int from);
-extern int parport_find_class (parport_device_class cls, int from);
 
 /* Lowlevel drivers _can_ call this support function to handle irqs.  */
 static __inline__ void parport_generic_irq(int irq, struct parport *port,
diff -Nru a/include/linux/parport_pc.h b/include/linux/parport_pc.h
--- a/include/linux/parport_pc.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/parport_pc.h	2004-12-24 13:37:18 -08:00
@@ -43,6 +43,23 @@
 	struct parport *port;
 };
 
+struct parport_pc_via_data
+{
+	/* ISA PnP IRQ routing register 1 */
+	u8 via_pci_parport_irq_reg;
+	/* ISA PnP DMA request routing register */
+	u8 via_pci_parport_dma_reg;
+	/* Register and value to enable SuperIO configuration access */
+	u8 via_pci_superio_config_reg;
+	u8 via_pci_superio_config_data;
+	/* SuperIO function register number */
+	u8 viacfg_function;
+	/* parallel port control register number */
+	u8 viacfg_parport_control;
+	/* Parallel port base address register */
+	u8 viacfg_parport_base;
+};
+
 static __inline__ void parport_pc_write_data(struct parport *p, unsigned char d)
 {
 #ifdef DEBUG_PARPORT
diff -Nru a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/pci-acpi.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,61 @@
+/*
+ * File		pci-acpi.h
+ *
+ * Copyright (C) 2004 Intel
+ * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
+ */
+
+#ifndef _PCI_ACPI_H_
+#define _PCI_ACPI_H_
+
+#define OSC_QUERY_TYPE			0
+#define OSC_SUPPORT_TYPE 		1
+#define OSC_CONTROL_TYPE		2
+#define OSC_SUPPORT_MASKS		0x1f
+
+/*
+ * _OSC DW0 Definition 
+ */
+#define OSC_QUERY_ENABLE		1
+#define OSC_REQUEST_ERROR		2
+#define OSC_INVALID_UUID_ERROR		4
+#define OSC_INVALID_REVISION_ERROR	8
+#define OSC_CAPABILITIES_MASK_ERROR	16
+
+/*
+ * _OSC DW1 Definition (OS Support Fields)
+ */
+#define OSC_EXT_PCI_CONFIG_SUPPORT		1
+#define OSC_ACTIVE_STATE_PWR_SUPPORT 		2
+#define OSC_CLOCK_PWR_CAPABILITY_SUPPORT	4
+#define OSC_PCI_SEGMENT_GROUPS_SUPPORT		8
+#define OSC_MSI_SUPPORT				16
+
+/*
+ * _OSC DW1 Definition (OS Control Fields)
+ */
+#define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL	1
+#define OSC_SHPC_NATIVE_HP_CONTROL 		2
+#define OSC_PCI_EXPRESS_PME_CONTROL		4
+#define OSC_PCI_EXPRESS_AER_CONTROL		8
+#define OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL	16
+
+#define OSC_CONTROL_MASKS 	(OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | 	\
+				OSC_SHPC_NATIVE_HP_CONTROL | 		\
+				OSC_PCI_EXPRESS_PME_CONTROL |		\
+				OSC_PCI_EXPRESS_AER_CONTROL |		\
+				OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL)
+
+#ifdef CONFIG_ACPI
+extern acpi_status pci_osc_control_set(u32 flags);
+extern acpi_status pci_osc_support_set(u32 flags);
+#else
+#if !defined(acpi_status)
+typedef u32 		acpi_status;
+#define AE_ERROR      	(acpi_status) (0x0001)
+#endif    
+static inline acpi_status pci_osc_control_set(u32 flags) {return AE_ERROR;}
+static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;} 
+#endif
+
+#endif	/* _PCI_ACPI_H_ */
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/pci.h	2004-12-24 13:36:48 -08:00
@@ -1,5 +1,5 @@
 /*
- *	$Id: pci.h,v 1.87 1998/10/11 15:13:12 mj Exp $
+ *	pci.h
  *
  *	PCI defines and function prototypes
  *	Copyright 1994, Drew Eckhardt
@@ -537,6 +537,8 @@
 	unsigned int	is_busmaster:1; /* device is busmaster */
 	
 	u32		saved_config_space[16]; /* config space saved at suspend time */
+	struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */
+	int rom_attr_enabled;		/* has display of the rom attribute been enabled? */
 #ifdef CONFIG_PCI_NAMES
 #define PCI_NAME_SIZE	96
 #define PCI_NAME_HALF	__stringify(43)	/* less than half to handle slop */
@@ -547,6 +549,7 @@
 #define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
 #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
 #define	to_pci_dev(n) container_of(n, struct pci_dev, dev)
+#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
 
 /*
  *  For PCI devices, the region numbers are assigned this way:
@@ -631,9 +634,11 @@
 	unsigned int use_driver_data:1; /* pci_driver->driver_data is used */
 };
 
+struct module;
 struct pci_driver {
 	struct list_head node;
 	char *name;
+	struct module *owner;
 	const struct pci_device_id *id_table;	/* must be non-NULL for probe to be called */
 	int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);	/* New device inserted */
 	void (*remove) (struct pci_dev *dev);	/* Device removed (NULL if not a hot-plug capable driver) */
@@ -674,6 +679,12 @@
 	.vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
 	.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
 
+/* 
+ * pci_module_init is obsolete, this stays here till we fix up all usages of it
+ * in the tree.
+ */
+#define pci_module_init	pci_register_driver
+
 /* these external functions are only available when PCI support is enabled */
 #ifdef CONFIG_PCI
 
@@ -704,6 +715,7 @@
 int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
+void pci_bus_add_device(struct pci_dev *dev);
 void pci_bus_add_devices(struct pci_bus *bus);
 void pci_name_device(struct pci_dev *dev);
 char *pci_class_name(u32 class);
@@ -719,10 +731,6 @@
 
 struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from);
 struct pci_dev *pci_find_device_reverse (unsigned int vendor, unsigned int device, const struct pci_dev *from);
-struct pci_dev *pci_find_subsys (unsigned int vendor, unsigned int device,
-				 unsigned int ss_vendor, unsigned int ss_device,
-				 const struct pci_dev *from);
-struct pci_dev *pci_find_class (unsigned int class, const struct pci_dev *from);
 struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
 int pci_find_capability (struct pci_dev *dev, int cap);
 int pci_find_ext_capability (struct pci_dev *dev, int cap);
@@ -733,6 +741,8 @@
 				unsigned int ss_vendor, unsigned int ss_device,
 				struct pci_dev *from);
 struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn);
+struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from);
+int pci_dev_present(const struct pci_device_id *ids);
 
 int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
 int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
@@ -778,9 +788,15 @@
 int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
 int pci_assign_resource(struct pci_dev *dev, int i);
 
+/* ROM control related routines */
+void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size);
+void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size);
+void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
+void pci_remove_rom(struct pci_dev *pdev);
+
 /* Power management related routines */
-int pci_save_state(struct pci_dev *dev, u32 *buffer);
-int pci_restore_state(struct pci_dev *dev, u32 *buffer);
+int pci_save_state(struct pci_dev *dev);
+int pci_restore_state(struct pci_dev *dev);
 int pci_set_power_state(struct pci_dev *dev, int state);
 int pci_enable_wake(struct pci_dev *dev, u32 state, int enable);
 
@@ -860,10 +876,6 @@
 
 #include <asm/pci.h>
 
-/* Backwards compat, remove in 2.7.x */
-#define pci_dma_sync_single	pci_dma_sync_single_for_cpu
-#define pci_dma_sync_sg		pci_dma_sync_sg_for_cpu
-
 /*
  *  If the system does not have PCI, clearly these return errors.  Define
  *  these as simple inline functions to avoid hair in drivers.
@@ -882,16 +894,9 @@
 static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from)
 { return NULL; }
 
-static inline struct pci_dev *pci_find_class(unsigned int class, const struct pci_dev *from)
-{ return NULL; }
-
 static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn)
 { return NULL; }
 
-static inline struct pci_dev *pci_find_subsys(unsigned int vendor, unsigned int device,
-unsigned int ss_vendor, unsigned int ss_device, const struct pci_dev *from)
-{ return NULL; }
-
 static inline struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from)
 { return NULL; }
 
@@ -899,10 +904,15 @@
 unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from)
 { return NULL; }
 
+static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
+{ return NULL; }
+
+#define pci_dev_present(ids)	(0)
+#define pci_dev_put(dev)	do { } while (0)
+
 static inline void pci_set_master(struct pci_dev *dev) { }
 static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
 static inline void pci_disable_device(struct pci_dev *dev) { }
-static inline int pci_module_init(struct pci_driver *drv) { return -ENODEV; }
 static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
 static inline int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
 static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;}
@@ -913,8 +923,8 @@
 static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; }
 
 /* Power management related routines */
-static inline int pci_save_state(struct pci_dev *dev, u32 *buffer) { return 0; }
-static inline int pci_restore_state(struct pci_dev *dev, u32 *buffer) { return 0; }
+static inline int pci_save_state(struct pci_dev *dev) { return 0; }
+static inline int pci_restore_state(struct pci_dev *dev) { return 0; }
 static inline int pci_set_power_state(struct pci_dev *dev, int state) { return 0; }
 static inline int pci_enable_wake(struct pci_dev *dev, u32 state, int enable) { return 0; }
 
@@ -923,19 +933,6 @@
 #else
 
 /*
- * a helper function which helps ensure correct pci_driver
- * setup and cleanup for commonly-encountered hotplug/modular cases
- *
- * This MUST stay in a header, as it checks for -DMODULE
- */
-static inline int pci_module_init(struct pci_driver *drv)
-{
-	int rc = pci_register_driver (drv);
-
-	return rc < 0 ? rc : 0;
-}
-
-/*
  * PCI domain support.  Sometimes called PCI segment (eg by ACPI),
  * a PCI domain is defined to be a set of PCI busses which share
  * configuration space.
@@ -1001,25 +998,34 @@
  */
 
 struct pci_fixup {
-	u16 vendor, device;			/* You can use PCI_ANY_ID here of course */
+	u16 vendor, device;	/* You can use PCI_ANY_ID here of course */
 	void (*hook)(struct pci_dev *dev);
 };
 
 enum pci_fixup_pass {
-	pci_fixup_header,	/* Called immediately after reading configuration header */
+	pci_fixup_early,	/* Before probing BARs */
+	pci_fixup_header,	/* After reading configuration header */
 	pci_fixup_final,	/* Final phase of device fixups */
+	pci_fixup_enable,	/* pci_enable_device() time */
 };
 
 /* Anonymous variables would be nice... */
-#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook)					\
-	static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__	\
-	__attribute__((__section__(".pci_fixup_header"))) = {				\
-		vendor, device, hook };
-
-#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook)				\
-	static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__	\
-	__attribute__((__section__(".pci_fixup_final"))) = {				\
-		vendor, device, hook };
+#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook)	\
+	static struct pci_fixup __pci_fixup_##name __attribute_used__	\
+	__attribute__((__section__(#section))) = { vendor, device, hook };
+#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook)			\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early,			\
+			vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook)			\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header,			\
+			vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook)			\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final,			\
+			vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook)			\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable,			\
+			vendor##device##hook, vendor, device, hook)
+
 
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
 
diff -Nru a/include/linux/pci_ids.h b/include/linux/pci_ids.h
--- a/include/linux/pci_ids.h	2004-12-24 13:37:43 -08:00
+++ b/include/linux/pci_ids.h	2004-12-24 13:37:43 -08:00
@@ -344,6 +344,7 @@
 #define PCI_DEVICE_ID_ATI_RS300_200	0x5833
 /* ATI IXP Chipset */
 #define PCI_DEVICE_ID_ATI_IXP_IDE	0x4349
+#define PCI_DEVICE_ID_ATI_IXP2_IDE	0x4369	/* True name not yet sure */
 
 #define PCI_VENDOR_ID_VLSI		0x1004
 #define PCI_DEVICE_ID_VLSI_82C592	0x0005
@@ -521,7 +522,9 @@
 #define PCI_VENDOR_ID_AI		0x1025
 #define PCI_DEVICE_ID_AI_M1435		0x1435
 
-#define PCI_VENDOR_ID_DELL              0x1028
+#define PCI_VENDOR_ID_DELL		0x1028
+#define PCI_DEVICE_ID_DELL_RACIII	0x0008
+#define PCI_DEVICE_ID_DELL_RAC4		0x0012
 
 #define PCI_VENDOR_ID_MATROX		0x102B
 #define PCI_DEVICE_ID_MATROX_MGA_2	0x0518
@@ -569,6 +572,7 @@
 #define PCI_DEVICE_ID_NEC_PCX2		0x0046 /* PowerVR */
 #define PCI_DEVICE_ID_NEC_NILE4		0x005a
 #define PCI_DEVICE_ID_NEC_VRC5476       0x009b
+#define PCI_DEVICE_ID_NEC_VRC4173	0x00a5
 #define PCI_DEVICE_ID_NEC_VRC5477_AC97  0x00a6
 #define PCI_DEVICE_ID_NEC_PC9821CS01    0x800c /* PC-9821-CS01 */
 #define PCI_DEVICE_ID_NEC_PC9821NRB06   0x800d /* PC-9821NR-B06 */
@@ -1026,6 +1030,7 @@
 #define PCI_DEVICE_ID_AL_M3307		0x3307
 #define PCI_DEVICE_ID_AL_M4803		0x5215
 #define PCI_DEVICE_ID_AL_M5219		0x5219
+#define PCI_DEVICE_ID_AL_M5228		0x5228
 #define PCI_DEVICE_ID_AL_M5229		0x5229
 #define PCI_DEVICE_ID_AL_M5237		0x5237
 #define PCI_DEVICE_ID_AL_M5243		0x5243
@@ -1080,9 +1085,11 @@
 #define PCI_DEVICE_ID_NVIDIA_NVENET_8		0x0056
 #define PCI_DEVICE_ID_NVIDIA_NVENET_9		0x0057
 #define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO	0x0059
+#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS	0x0064
 #define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE	0x0065
 #define PCI_DEVICE_ID_NVIDIA_NVENET_2		0x0066
 #define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO		0x006a
+#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS	0x0084
 #define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE	0x0085
 #define PCI_DEVICE_ID_NVIDIA_NVENET_4		0x0086
 #define PCI_DEVICE_ID_NVIDIA_NVENET_5		0x008c
@@ -1091,6 +1098,7 @@
 #define PCI_DEVICE_ID_NVIDIA_NFORCE3		0x00d1
 #define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO		0x00da
 #define PCI_DEVICE_ID_NVIDIA_NFORCE3S  		0x00e1
+#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS	0x00d4
 #define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE	0x00d5
 #define PCI_DEVICE_ID_NVIDIA_NVENET_3		0x00d6
 #define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO		0x00da
@@ -1138,6 +1146,7 @@
 #define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL	0x0258
 #define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL	0x0259
 #define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL	0x025B
+#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200	0x0329
 
 #define PCI_VENDOR_ID_IMS		0x10e0
 #define PCI_DEVICE_ID_IMS_8849		0x8849
@@ -1199,6 +1208,7 @@
 #define PCI_DEVICE_ID_VIA_8763_0	0x0198
 #define PCI_DEVICE_ID_VIA_8380_0	0x0204
 #define PCI_DEVICE_ID_VIA_3238_0	0x0238
+#define PCI_DEVICE_ID_VIA_PT880		0x0258
 #define PCI_DEVICE_ID_VIA_PX8X0_0	0x0259
 #define PCI_DEVICE_ID_VIA_3269_0	0x0269
 #define PCI_DEVICE_ID_VIA_K8T800PRO_0	0x0282
@@ -1257,7 +1267,6 @@
 #define PCI_DEVICE_ID_VIA_8377_0	0x3189
 #define PCI_DEVICE_ID_VIA_8378_0	0x3205
 #define PCI_DEVICE_ID_VIA_8783_0	0x3208
-#define PCI_DEVICE_ID_VIA_PT880		0x3258
 #define PCI_DEVICE_ID_VIA_P4M400	0x3209
 #define PCI_DEVICE_ID_VIA_8237		0x3227
 #define PCI_DEVICE_ID_VIA_3296_0	0x0296
@@ -1790,8 +1799,21 @@
 #define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003
 
 #define PCI_VENDOR_ID_MOXA		0x1393
+#define PCI_DEVICE_ID_MOXA_RC7000	0x0001
+#define PCI_DEVICE_ID_MOXA_CP102	0x1020
+#define PCI_DEVICE_ID_MOXA_CP102UL	0x1021
+#define PCI_DEVICE_ID_MOXA_CP102U	0x1022
 #define PCI_DEVICE_ID_MOXA_C104		0x1040
+#define PCI_DEVICE_ID_MOXA_CP104U	0x1041
+#define PCI_DEVICE_ID_MOXA_CP104JU	0x1042
+#define PCI_DEVICE_ID_MOXA_CT114	0x1140
+#define PCI_DEVICE_ID_MOXA_CP114	0x1141
+#define PCI_DEVICE_ID_MOXA_CP118U	0x1180
+#define PCI_DEVICE_ID_MOXA_CP132	0x1320
+#define PCI_DEVICE_ID_MOXA_CP132U	0x1321
+#define PCI_DEVICE_ID_MOXA_CP134U	0x1340
 #define PCI_DEVICE_ID_MOXA_C168		0x1680
+#define PCI_DEVICE_ID_MOXA_CP168U	0x1681
 #define PCI_DEVICE_ID_MOXA_CP204J	0x2040
 #define PCI_DEVICE_ID_MOXA_C218		0x2180
 #define PCI_DEVICE_ID_MOXA_C320		0x3200
@@ -1916,11 +1938,15 @@
 #define PCI_DEVICE_ID_TIGON3_5704S	0x16a8
 #define PCI_DEVICE_ID_TIGON3_5702A3	0x16c6
 #define PCI_DEVICE_ID_TIGON3_5703A3	0x16c7
+#define PCI_DEVICE_ID_TIGON3_5781	0x16dd
+#define PCI_DEVICE_ID_TIGON3_5753	0x16f7
+#define PCI_DEVICE_ID_TIGON3_5753M	0x16fd
+#define PCI_DEVICE_ID_TIGON3_5753F	0x16fe
 #define PCI_DEVICE_ID_TIGON3_5901	0x170d
+#define PCI_DEVICE_ID_BCM4401B1		0x170c
 #define PCI_DEVICE_ID_TIGON3_5901_2	0x170e
 #define PCI_DEVICE_ID_BCM4401		0x4401
 #define PCI_DEVICE_ID_BCM4401B0		0x4402
-#define PCI_DEVICE_ID_BCM4401B1		0x170c
 
 #define PCI_VENDOR_ID_ENE		0x1524
 #define PCI_DEVICE_ID_ENE_1211		0x1211
@@ -2204,7 +2230,15 @@
 #define PCI_DEVICE_ID_INTEL_82830_CGC	0x3577
 #define PCI_DEVICE_ID_INTEL_82855GM_HB	0x3580
 #define PCI_DEVICE_ID_INTEL_82855GM_IG	0x3582
-#define PCI_DEVICE_ID_INTEL_SMCH	0x3590
+#define PCI_DEVICE_ID_INTEL_E7520_MCH	0x3590
+#define PCI_DEVICE_ID_INTEL_E7320_MCH	0x3592
+#define PCI_DEVICE_ID_INTEL_MCH_PA	0x3595
+#define PCI_DEVICE_ID_INTEL_MCH_PA1	0x3596
+#define PCI_DEVICE_ID_INTEL_MCH_PB	0x3597
+#define PCI_DEVICE_ID_INTEL_MCH_PB1	0x3598
+#define PCI_DEVICE_ID_INTEL_MCH_PC	0x3599
+#define PCI_DEVICE_ID_INTEL_MCH_PC1	0x359a
+#define PCI_DEVICE_ID_INTEL_E7525_MCH	0x359e
 #define PCI_DEVICE_ID_INTEL_80310	0x530d
 #define PCI_DEVICE_ID_INTEL_82371SB_0	0x7000
 #define PCI_DEVICE_ID_INTEL_82371SB_1	0x7010
diff -Nru a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
--- a/include/linux/pkt_cls.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/pkt_cls.h	2004-12-24 13:36:17 -08:00
@@ -1,6 +1,8 @@
 #ifndef __LINUX_PKT_CLS_H
 #define __LINUX_PKT_CLS_H
 
+#include <linux/pkt_sched.h>
+
 /* I think i could have done better macros ; for now this is stolen from
  * some arch/mips code - jhs
 */
@@ -136,9 +138,9 @@
 
 struct tcf_t
 {
-	__u32   install;
-	__u32   lastuse;
-	__u32   expires;
+	__u64   install;
+	__u64   lastuse;
+	__u64   expires;
 };
 
 struct tc_cnt
diff -Nru a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
--- a/include/linux/pkt_sched.h	2004-12-24 13:37:03 -08:00
+++ b/include/linux/pkt_sched.h	2004-12-24 13:37:03 -08:00
@@ -117,8 +117,11 @@
 	TCA_TBF_PARMS,
 	TCA_TBF_RTAB,
 	TCA_TBF_PTAB,
+	__TCA_TBF_MAX,
 };
 
+#define TCA_TBF_MAX (__TCA_TBF_MAX - 1)
+
 
 /* TEQL section */
 
@@ -151,8 +154,11 @@
 	TCA_RED_UNSPEC,
 	TCA_RED_PARMS,
 	TCA_RED_STAB,
+	__TCA_RED_MAX,
 };
 
+#define TCA_RED_MAX (__TCA_RED_MAX - 1)
+
 struct tc_red_qopt
 {
 	__u32		limit;		/* HARD maximal queue length (bytes)	*/
@@ -183,8 +189,11 @@
        TCA_GRED_PARMS,
        TCA_GRED_STAB,
        TCA_GRED_DPS,
+	   __TCA_GRED_MAX,
 };
 
+#define TCA_GRED_MAX (__TCA_GRED_MAX - 1)
+
 #define TCA_SET_OFF TCA_GRED_PARMS
 struct tc_gred_qopt
 {
@@ -249,7 +258,11 @@
 	TCA_HTB_INIT,
 	TCA_HTB_CTAB,
 	TCA_HTB_RTAB,
+	__TCA_HTB_MAX,
 };
+
+#define TCA_HTB_MAX (__TCA_HTB_MAX - 1)
+
 struct tc_htb_xstats
 {
 	__u32 lends;
@@ -287,9 +300,12 @@
 	TCA_HFSC_RSC,
 	TCA_HFSC_FSC,
 	TCA_HFSC_USC,
-	TCA_HFSC_MAX = TCA_HFSC_USC
+	__TCA_HFSC_MAX,
 };
 
+#define TCA_HFSC_MAX (__TCA_HFSC_MAX - 1)
+
+
 /* CBQ section */
 
 #define TC_CBQ_MAXPRIO		8
@@ -370,9 +386,10 @@
 	TCA_CBQ_RATE,
 	TCA_CBQ_RTAB,
 	TCA_CBQ_POLICE,
+	__TCA_CBQ_MAX,
 };
 
-#define TCA_CBQ_MAX	TCA_CBQ_POLICE
+#define TCA_CBQ_MAX	(__TCA_CBQ_MAX - 1)
 
 /* dsmark section */
 
@@ -382,10 +399,11 @@
 	TCA_DSMARK_DEFAULT_INDEX,
 	TCA_DSMARK_SET_TC_INDEX,
 	TCA_DSMARK_MASK,
-	TCA_DSMARK_VALUE
+	TCA_DSMARK_VALUE,
+	__TCA_DSMARK_MAX,
 };
 
-#define TCA_DSMARK_MAX TCA_DSMARK_VALUE
+#define TCA_DSMARK_MAX (__TCA_DSMARK_MAX - 1)
 
 /* ATM  section */
 
@@ -396,10 +414,11 @@
 	TCA_ATM_HDR,		/* LL header */
 	TCA_ATM_EXCESS,		/* excess traffic class (0 for CLP)  */
 	TCA_ATM_ADDR,		/* PVC address (for output only) */
-	TCA_ATM_STATE		/* VC state (ATM_VS_*; for output only) */
+	TCA_ATM_STATE,		/* VC state (ATM_VS_*; for output only) */
+	__TCA_ATM_MAX,
 };
 
-#define TCA_ATM_MAX	TCA_ATM_STATE
+#define TCA_ATM_MAX	(__TCA_ATM_MAX - 1)
 
 /* Network emulator */
 
@@ -408,9 +427,10 @@
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	__TCA_NETEM_MAX,
 };
 
-#define TCA_NETEM_MAX	TCA_NETEM_DELAY_DIST
+#define TCA_NETEM_MAX (__TCA_NETEM_MAX - 1)
 
 struct tc_netem_qopt
 {
diff -Nru a/include/linux/pktcdvd.h b/include/linux/pktcdvd.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/pktcdvd.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2000 Jens Axboe <axboe@suse.de>
+ * Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com>
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ * Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and
+ * DVD-RW devices.
+ *
+ */
+#ifndef __PKTCDVD_H
+#define __PKTCDVD_H
+
+#include <linux/types.h>
+
+/*
+ * 1 for normal debug messages, 2 is very verbose. 0 to turn it off.
+ */
+#define PACKET_DEBUG		1
+
+#define	MAX_WRITERS		8
+
+#define PKT_RB_POOL_SIZE	512
+
+/*
+ * How long we should hold a non-full packet before starting data gathering.
+ */
+#define PACKET_WAIT_TIME	(HZ * 5 / 1000)
+
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to sucessfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
+/*
+ * No user-servicable parts beyond this point ->
+ */
+
+/*
+ * device types
+ */
+#define PACKET_CDR		1
+#define	PACKET_CDRW		2
+#define PACKET_DVDR		3
+#define PACKET_DVDRW		4
+
+/*
+ * flags
+ */
+#define PACKET_WRITABLE		1	/* pd is writable */
+#define PACKET_NWA_VALID	2	/* next writable address valid */
+#define PACKET_LRA_VALID	3	/* last recorded address valid */
+#define PACKET_MERGE_SEGS	4	/* perform segment merging to keep */
+					/* underlying cdrom device happy */
+
+/*
+ * Disc status -- from READ_DISC_INFO
+ */
+#define PACKET_DISC_EMPTY	0
+#define PACKET_DISC_INCOMPLETE	1
+#define PACKET_DISC_COMPLETE	2
+#define PACKET_DISC_OTHER	3
+
+/*
+ * write type, and corresponding data block type
+ */
+#define PACKET_MODE1		1
+#define PACKET_MODE2		2
+#define PACKET_BLOCK_MODE1	8
+#define PACKET_BLOCK_MODE2	10
+
+/*
+ * Last session/border status
+ */
+#define PACKET_SESSION_EMPTY		0
+#define PACKET_SESSION_INCOMPLETE	1
+#define PACKET_SESSION_RESERVED		2
+#define PACKET_SESSION_COMPLETE		3
+
+#define PACKET_MCN			"4a656e734178626f65323030300000"
+
+#undef PACKET_USE_LS
+
+#define PKT_CTRL_CMD_SETUP	0
+#define PKT_CTRL_CMD_TEARDOWN	1
+#define PKT_CTRL_CMD_STATUS	2
+
+struct pkt_ctrl_command {
+	__u32 command;				/* in: Setup, teardown, status */
+	__u32 dev_index;			/* in/out: Device index */
+	__u32 dev;				/* in/out: Device nr for cdrw device */
+	__u32 pkt_dev;				/* in/out: Device nr for packet device */
+	__u32 num_devices;			/* out: Largest device index + 1 */
+	__u32 padding;				/* Not used */
+};
+
+/*
+ * packet ioctls
+ */
+#define PACKET_IOCTL_MAGIC	('X')
+#define PACKET_CTRL_CMD		_IOWR(PACKET_IOCTL_MAGIC, 1, struct pkt_ctrl_command)
+
+#ifdef __KERNEL__
+#include <linux/blkdev.h>
+#include <linux/completion.h>
+#include <linux/cdrom.h>
+
+struct packet_settings
+{
+	__u8			size;		/* packet size in (512 byte) sectors */
+	__u8			fp;		/* fixed packets */
+	__u8			link_loss;	/* the rest is specified
+						 * as per Mt Fuji */
+	__u8			write_type;
+	__u8			track_mode;
+	__u8			block_mode;
+};
+
+/*
+ * Very crude stats for now
+ */
+struct packet_stats
+{
+	unsigned long		pkt_started;
+	unsigned long		pkt_ended;
+	unsigned long		secs_w;
+	unsigned long		secs_rg;
+	unsigned long		secs_r;
+};
+
+struct packet_cdrw
+{
+	struct list_head	pkt_free_list;
+	struct list_head	pkt_active_list;
+	spinlock_t		active_list_lock; /* Serialize access to pkt_active_list */
+	struct task_struct	*thread;
+	atomic_t		pending_bios;
+};
+
+/*
+ * Switch to high speed reading after reading this many kilobytes
+ * with no interspersed writes.
+ */
+#define HI_SPEED_SWITCH 512
+
+struct packet_iosched
+{
+	atomic_t		attention;	/* Set to non-zero when queue processing is needed */
+	int			writing;	/* Non-zero when writing, zero when reading */
+	spinlock_t		lock;		/* Protecting read/write queue manipulations */
+	struct bio		*read_queue;
+	struct bio		*read_queue_tail;
+	struct bio		*write_queue;
+	struct bio		*write_queue_tail;
+	int			high_prio_read;	/* An important read request has been queued */
+	int			successive_reads;
+};
+
+/*
+ * 32 buffers of 2048 bytes
+ */
+#define PACKET_MAX_SIZE		32
+#define PAGES_PER_PACKET	(PACKET_MAX_SIZE * CD_FRAMESIZE / PAGE_SIZE)
+#define PACKET_MAX_SECTORS	(PACKET_MAX_SIZE * CD_FRAMESIZE >> 9)
+
+enum packet_data_state {
+	PACKET_IDLE_STATE,			/* Not used at the moment */
+	PACKET_WAITING_STATE,			/* Waiting for more bios to arrive, so */
+						/* we don't have to do as much */
+						/* data gathering */
+	PACKET_READ_WAIT_STATE,			/* Waiting for reads to fill in holes */
+	PACKET_WRITE_WAIT_STATE,		/* Waiting for the write to complete */
+	PACKET_RECOVERY_STATE,			/* Recover after read/write errors */
+	PACKET_FINISHED_STATE,			/* After write has finished */
+
+	PACKET_NUM_STATES			/* Number of possible states */
+};
+
+/*
+ * Information needed for writing a single packet
+ */
+struct pktcdvd_device;
+
+struct packet_data
+{
+	struct list_head	list;
+
+	spinlock_t		lock;		/* Lock protecting state transitions and */
+						/* orig_bios list */
+
+	struct bio		*orig_bios;	/* Original bios passed to pkt_make_request */
+	struct bio		*orig_bios_tail;/* that will be handled by this packet */
+	int			write_size;	/* Total size of all bios in the orig_bios */
+						/* list, measured in number of frames */
+
+	struct bio		*w_bio;		/* The bio we will send to the real CD */
+						/* device once we have all data for the */
+						/* packet we are going to write */
+	sector_t		sector;		/* First sector in this packet */
+	int			frames;		/* Number of frames in this packet */
+
+	enum packet_data_state	state;		/* Current state */
+	atomic_t		run_sm;		/* Incremented whenever the state */
+						/* machine needs to be run */
+	long			sleep_time;	/* Set this to non-zero to make the state */
+						/* machine run after this many jiffies. */
+
+	atomic_t		io_wait;	/* Number of pending IO operations */
+	atomic_t		io_errors;	/* Number of read/write errors during IO */
+
+	struct bio		*r_bios[PACKET_MAX_SIZE]; /* bios to use during data gathering */
+	struct page		*pages[PAGES_PER_PACKET];
+
+	int			cache_valid;	/* If non-zero, the data for the zone defined */
+						/* by the sector variable is completely cached */
+						/* in the pages[] vector. */
+
+	int			id;		/* ID number for debugging */
+	struct pktcdvd_device	*pd;
+};
+
+struct pkt_rb_node {
+	struct rb_node		rb_node;
+	struct bio		*bio;
+};
+
+struct packet_stacked_data
+{
+	struct bio		*bio;		/* Original read request bio */
+	struct pktcdvd_device	*pd;
+};
+#define PSD_POOL_SIZE		64
+
+struct pktcdvd_device
+{
+	struct block_device	*bdev;		/* dev attached */
+	dev_t			pkt_dev;	/* our dev */
+	char			name[20];
+	struct packet_settings	settings;
+	struct packet_stats	stats;
+	int			refcnt;		/* Open count */
+	int			write_speed;	/* current write speed, kB/s */
+	int			read_speed;	/* current read speed, kB/s */
+	unsigned long		offset;		/* start offset */
+	__u8			mode_offset;	/* 0 / 8 */
+	__u8			type;
+	unsigned long		flags;
+	__u16			mmc3_profile;
+	__u32			nwa;		/* next writable address */
+	__u32			lra;		/* last recorded address */
+	struct packet_cdrw	cdrw;
+	wait_queue_head_t	wqueue;
+
+	spinlock_t		lock;		/* Serialize access to bio_queue */
+	struct rb_root		bio_queue;	/* Work queue of bios we need to handle */
+	int			bio_queue_size;	/* Number of nodes in bio_queue */
+	sector_t		current_sector;	/* Keep track of where the elevator is */
+	atomic_t		scan_queue;	/* Set to non-zero when pkt_handle_queue */
+						/* needs to be run. */
+	mempool_t		*rb_pool;	/* mempool for pkt_rb_node allocations */
+
+	struct packet_iosched   iosched;
+	struct gendisk		*disk;
+};
+
+#endif /* __KERNEL__ */
+
+#endif /* __PKTCDVD_H */
diff -Nru a/include/linux/pm.h b/include/linux/pm.h
--- a/include/linux/pm.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/pm.h	2004-12-24 13:37:00 -08:00
@@ -143,11 +143,6 @@
  */
 int pm_send_all(pm_request_t rqst, void *data);
 
-/*
- * Find a device
- */
-struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from);
-
 static inline void pm_access(struct pm_dev *dev) {}
 static inline void pm_dev_idle(struct pm_dev *dev) {}
 
@@ -193,34 +188,32 @@
 extern void (*pm_idle)(void);
 extern void (*pm_power_off)(void);
 
-enum {
-	PM_SUSPEND_ON = 0,
-	PM_SUSPEND_STANDBY = 1,
-	/* NOTE: PM_SUSPEND_MEM == PCI_D3hot */
-	PM_SUSPEND_MEM = 3,
-	PM_SUSPEND_DISK = 4,
-	PM_SUSPEND_MAX = 5,
-};
-
-enum {
-	PM_DISK_FIRMWARE = 1,
-	PM_DISK_PLATFORM,
-	PM_DISK_SHUTDOWN,
-	PM_DISK_REBOOT,
-	PM_DISK_MAX,
-};
+typedef int __bitwise suspend_state_t;
 
+#define PM_SUSPEND_ON		((__force suspend_state_t) 0)
+#define PM_SUSPEND_STANDBY	((__force suspend_state_t) 1)
+#define PM_SUSPEND_MEM		((__force suspend_state_t) 3)
+#define PM_SUSPEND_DISK		((__force suspend_state_t) 4)
+#define PM_SUSPEND_MAX		((__force suspend_state_t) 5)
+
+typedef int __bitwise suspend_disk_method_t;
+
+#define	PM_DISK_FIRMWARE	((__force suspend_disk_method_t) 1)
+#define	PM_DISK_PLATFORM	((__force suspend_disk_method_t) 2)
+#define	PM_DISK_SHUTDOWN	((__force suspend_disk_method_t) 3)
+#define	PM_DISK_REBOOT		((__force suspend_disk_method_t) 4)
+#define	PM_DISK_MAX		((__force suspend_disk_method_t) 5)
 
 struct pm_ops {
-	u32	pm_disk_mode;
-	int (*prepare)(u32 state);
-	int (*enter)(u32 state);
-	int (*finish)(u32 state);
+	suspend_disk_method_t pm_disk_mode;
+	int (*prepare)(suspend_state_t state);
+	int (*enter)(suspend_state_t state);
+	int (*finish)(suspend_state_t state);
 };
 
 extern void pm_set_ops(struct pm_ops *);
 
-extern int pm_suspend(u32 state);
+extern int pm_suspend(suspend_state_t state);
 
 
 /*
diff -Nru a/include/linux/pnp.h b/include/linux/pnp.h
--- a/include/linux/pnp.h	2004-12-24 13:37:30 -08:00
+++ b/include/linux/pnp.h	2004-12-24 13:37:30 -08:00
@@ -82,8 +82,9 @@
 	struct pnp_port *next;		/* next port */
 };
 
+#define PNP_IRQ_NR 256
 struct pnp_irq {
-	unsigned short map;		/* bitmaks for IRQ lines */
+	DECLARE_BITMAP(map, PNP_IRQ_NR); /* bitmaks for IRQ lines */
 	unsigned char flags;		/* IRQ flags */
 	unsigned char pad;		/* pad */
 	struct pnp_irq *next;		/* next IRQ */
@@ -200,6 +201,7 @@
 	unsigned short	regs;		/* ISAPnP: supported registers */
 	int 		flags;		/* used by protocols */
 	struct proc_dir_entry *procent;	/* device entry in /proc/bus/isapnp */
+	void *data;
 };
 
 #define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
diff -Nru a/include/linux/posix-timers.h b/include/linux/posix-timers.h
--- a/include/linux/posix-timers.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/posix-timers.h	2004-12-24 13:36:48 -08:00
@@ -4,6 +4,26 @@
 #include <linux/spinlock.h>
 #include <linux/list.h>
 
+/* POSIX.1b interval timer structure. */
+struct k_itimer {
+	struct list_head list;		/* free/ allocate list */
+	spinlock_t it_lock;
+	clockid_t it_clock;		/* which timer type */
+	timer_t it_id;			/* timer id */
+	int it_overrun;			/* overrun on pending signal  */
+	int it_overrun_last;		/* overrun on last delivered signal */
+	int it_requeue_pending;         /* waiting to requeue this timer */
+	int it_sigev_notify;		/* notify word of sigevent struct */
+	int it_sigev_signo;		/* signo word of sigevent struct */
+	sigval_t it_sigev_value;	/* value word of sigevent struct */
+	unsigned long it_incr;		/* interval specified in jiffies */
+	struct task_struct *it_process;	/* process to send signal to */
+	struct timer_list it_timer;
+	struct sigqueue *sigq;		/* signal queue entry. */
+	struct list_head abs_timer_entry; /* clock abs_timer_list */
+	struct timespec wall_to_prev;   /* wall_to_monotonic used when set */
+};
+
 struct k_clock_abs {
 	struct list_head list;
 	spinlock_t lock;
@@ -13,9 +33,9 @@
 	struct k_clock_abs *abs_struct;
 	int (*clock_set) (struct timespec * tp);
 	int (*clock_get) (struct timespec * tp);
-	int (*nsleep) (int flags,
-		       struct timespec * new_setting,
-		       struct itimerspec * old_setting);
+	int (*timer_create) (struct k_itimer *timer);
+	int (*nsleep) (int which_clock, int flags,
+		       struct timespec * t);
 	int (*timer_set) (struct k_itimer * timr, int flags,
 			  struct itimerspec * new_setting,
 			  struct itimerspec * old_setting);
@@ -23,6 +43,17 @@
 	void (*timer_get) (struct k_itimer * timr,
 			   struct itimerspec * cur_setting);
 };
+
+void register_posix_clock(int clock_id, struct k_clock *new_clock);
+
+/* Error handlers for timer_create, nanosleep and settime */
+int do_posix_clock_notimer_create(struct k_itimer *timer);
+int do_posix_clock_nonanosleep(int which_clock, int flags, struct timespec * t);
+int do_posix_clock_nosettime(struct timespec *tp);
+
+/* function to call to trigger timer event */
+int posix_timer_event(struct k_itimer *timr, int si_private);
+
 struct now_struct {
 	unsigned long jiffies;
 };
@@ -42,3 +73,4 @@
               }								\
             }while (0)
 #endif
+
diff -Nru a/include/linux/posix_acl.h b/include/linux/posix_acl.h
--- a/include/linux/posix_acl.h	2004-12-24 13:37:33 -08:00
+++ b/include/linux/posix_acl.h	2004-12-24 13:37:33 -08:00
@@ -79,7 +79,6 @@
 extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
 extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
 extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
-extern int posix_acl_masq_nfs_mode(struct posix_acl *, mode_t *);
 
 extern struct posix_acl *get_posix_acl(struct inode *, int);
 extern int set_posix_acl(struct inode *, int, struct posix_acl *);
diff -Nru a/include/linux/prctl.h b/include/linux/prctl.h
--- a/include/linux/prctl.h	2004-12-24 13:36:56 -08:00
+++ b/include/linux/prctl.h	2004-12-24 13:36:56 -08:00
@@ -49,7 +49,6 @@
 # define PR_TIMING_TIMESTAMP    1       /* Accurate timestamp based
                                                    process timing */
 
-
 #define PR_SET_NAME    15		/* Set process name */
 
 #endif /* _LINUX_PRCTL_H */
diff -Nru a/include/linux/proc_fs.h b/include/linux/proc_fs.h
--- a/include/linux/proc_fs.h	2004-12-24 13:37:43 -08:00
+++ b/include/linux/proc_fs.h	2004-12-24 13:37:43 -08:00
@@ -193,6 +193,7 @@
 
 #define proc_root_driver NULL
 #define proc_net NULL
+#define proc_bus NULL
 
 #define proc_net_fops_create(name, mode, fops)  ({ (void)(mode), NULL; })
 #define proc_net_create(name, mode, info)	({ (void)(mode), NULL; })
@@ -226,7 +227,7 @@
 
 #endif /* CONFIG_PROC_FS */
 
-#if !defined(CONFIG_PROC_FS)
+#if !defined(CONFIG_PROC_KCORE)
 static inline void kclist_add(struct kcore_list *new, void *addr, size_t size)
 {
 }
diff -Nru a/include/linux/profile.h b/include/linux/profile.h
--- a/include/linux/profile.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/profile.h	2004-12-24 13:36:48 -08:00
@@ -53,13 +53,13 @@
 int profile_event_register(enum profile_type, struct notifier_block * n);
 int profile_event_unregister(enum profile_type, struct notifier_block * n);
 
-int register_profile_notifier(struct notifier_block * nb);
-int unregister_profile_notifier(struct notifier_block * nb);
+int register_timer_hook(int (*hook)(struct pt_regs *));
+void unregister_timer_hook(int (*hook)(struct pt_regs *));
 
-struct pt_regs;
+/* Timer based profiling hook */
+extern int (*timer_hook)(struct pt_regs *);
 
-/* profiling hook activated on each timer interrupt */
-void profile_hook(struct pt_regs * regs);
+struct pt_regs;
 
 #else
 
@@ -87,17 +87,15 @@
 #define profile_handoff_task(a) (0)
 #define profile_munmap(a) do { } while (0)
 
-static inline int register_profile_notifier(struct notifier_block * nb)
+static inline int register_timer_hook(int (*hook)(struct pt_regs *))
 {
 	return -ENOSYS;
 }
 
-static inline int unregister_profile_notifier(struct notifier_block * nb)
+static inline void unregister_timer_hook(int (*hook)(struct pt_regs *))
 {
-	return -ENOSYS;
+	return;
 }
-
-#define profile_hook(regs) do { } while (0)
 
 #endif /* CONFIG_PROFILING */
 
diff -Nru a/include/linux/ptrace.h b/include/linux/ptrace.h
--- a/include/linux/ptrace.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/ptrace.h	2004-12-24 13:36:18 -08:00
@@ -63,6 +63,7 @@
 #define PT_TRACE_EXEC	0x00000080
 #define PT_TRACE_VFORK_DONE	0x00000100
 #define PT_TRACE_EXIT	0x00000200
+#define PT_ATTACHED	0x00000400	/* parent != real_parent */
 
 #define PT_TRACE_MASK	0x000003f4
 
diff -Nru a/include/linux/raid/linear.h b/include/linux/raid/linear.h
--- a/include/linux/raid/linear.h	2004-12-24 13:37:29 -08:00
+++ b/include/linux/raid/linear.h	2004-12-24 13:37:29 -08:00
@@ -5,8 +5,8 @@
 
 struct dev_info {
 	mdk_rdev_t	*rdev;
-	unsigned long	size;
-	unsigned long	offset;
+	sector_t	size;
+	sector_t	offset;
 };
 
 typedef struct dev_info dev_info_t;
diff -Nru a/include/linux/raid/md.h b/include/linux/raid/md.h
--- a/include/linux/raid/md.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/raid/md.h	2004-12-24 13:36:17 -08:00
@@ -60,7 +60,7 @@
  */
 #define MD_MAJOR_VERSION                0
 #define MD_MINOR_VERSION                90
-#define MD_PATCHLEVEL_VERSION           0
+#define MD_PATCHLEVEL_VERSION           1
 
 extern int register_md_personality (int p_num, mdk_personality_t *p);
 extern int unregister_md_personality (int p_num);
diff -Nru a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
--- a/include/linux/raid/md_k.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/raid/md_k.h	2004-12-24 13:36:17 -08:00
@@ -25,10 +25,12 @@
 #define MULTIPATH         7UL
 #define RAID6		  8UL
 #define	RAID10		  9UL
-#define MAX_PERSONALITY   10UL
+#define FAULTY		  10UL
+#define MAX_PERSONALITY   11UL
 
 #define	LEVEL_MULTIPATH		(-4)
 #define	LEVEL_LINEAR		(-1)
+#define	LEVEL_FAULTY		(-5)
 
 #define MaxSector (~(sector_t)0)
 #define MD_THREAD_NAME_MAX 14
@@ -36,6 +38,7 @@
 static inline int pers_to_level (int pers)
 {
 	switch (pers) {
+		case FAULTY:		return LEVEL_FAULTY;
 		case MULTIPATH:		return LEVEL_MULTIPATH;
 		case HSM:		return -3;
 		case TRANSLUCENT:	return -2;
@@ -53,6 +56,7 @@
 static inline int level_to_pers (int level)
 {
 	switch (level) {
+		case LEVEL_FAULTY: return FAULTY;
 		case LEVEL_MULTIPATH: return MULTIPATH;
 		case -3: return HSM;
 		case -2: return TRANSLUCENT;
@@ -290,6 +294,7 @@
 	int (*sync_request)(mddev_t *mddev, sector_t sector_nr, int go_faster);
 	int (*resize) (mddev_t *mddev, sector_t sectors);
 	int (*reshape) (mddev_t *mddev, int raid_disks);
+	int (*reconfig) (mddev_t *mddev, int layout, int chunk_size);
 };
 
 
diff -Nru a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h
--- a/include/linux/raid/md_p.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/raid/md_p.h	2004-12-24 13:36:31 -08:00
@@ -197,7 +197,7 @@
 
 	__u32	chunksize;	/* in 512byte sectors */
 	__u32	raid_disks;
-	__u8	pad1[128-92];	/* set to 0 when written */
+	__u8	pad1[128-96];	/* set to 0 when written */
 
 	/* constant this-device information - 64 bytes */
 	__u64	data_offset;	/* sector start of data, often 0 */
@@ -215,7 +215,7 @@
 	__u64	resync_offset;	/* data before this offset (from data_offset) known to be in sync */
 	__u32	sb_csum;	/* checksum upto devs[max_dev] */
 	__u32	max_dev;	/* size of devs[] array to consider */
-	__u8	pad3[64-40];	/* set to 0 when writing */
+	__u8	pad3[64-32];	/* set to 0 when writing */
 
 	/* device state information. Indexed by dev_number.
 	 * 2 bytes per device
diff -Nru a/include/linux/raid/multipath.h b/include/linux/raid/multipath.h
--- a/include/linux/raid/multipath.h	2004-12-24 13:37:04 -08:00
+++ b/include/linux/raid/multipath.h	2004-12-24 13:37:04 -08:00
@@ -13,6 +13,7 @@
 	int			raid_disks;
 	int			working_disks;
 	spinlock_t		device_lock;
+	struct list_head	retry_list;
 
 	mempool_t		*pool;
 };
@@ -36,6 +37,6 @@
 	struct bio		*master_bio;
 	struct bio		bio;
 	int			path;
-	struct multipath_bh	*next_mp; /* next for retry */
+	struct list_head	retry_list;
 };
 #endif
diff -Nru a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h
--- a/include/linux/raid/raid1.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/raid/raid1.h	2004-12-24 13:37:00 -08:00
@@ -35,6 +35,7 @@
 	sector_t		next_seq_sect;
 	spinlock_t		device_lock;
 
+	struct list_head	retry_list;
 	/* for use when syncing mirrors: */
 
 	spinlock_t		resync_lock;
diff -Nru a/include/linux/random.h b/include/linux/random.h
--- a/include/linux/random.h	2004-12-24 13:37:31 -08:00
+++ b/include/linux/random.h	2004-12-24 13:37:31 -08:00
@@ -44,8 +44,6 @@
 
 extern void rand_initialize_irq(int irq);
 
-extern void batch_entropy_store(u32 a, u32 b, int num);
-
 extern void add_keyboard_randomness(unsigned char scancode);
 extern void add_mouse_randomness(__u32 mouse_data);
 extern void add_interrupt_randomness(int irq);
diff -Nru a/include/linux/rbtree.h b/include/linux/rbtree.h
--- a/include/linux/rbtree.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/rbtree.h	2004-12-24 13:36:47 -08:00
@@ -113,8 +113,7 @@
 };
 
 #define RB_ROOT	(struct rb_root) { NULL, }
-#define	rb_entry(ptr, type, member)					\
-	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+#define	rb_entry(ptr, type, member) container_of(ptr, type, member)
 
 extern void rb_insert_color(struct rb_node *, struct rb_root *);
 extern void rb_erase(struct rb_node *, struct rb_root *);
diff -Nru a/include/linux/rcupdate.h b/include/linux/rcupdate.h
--- a/include/linux/rcupdate.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/rcupdate.h	2004-12-24 13:36:31 -08:00
@@ -238,6 +238,24 @@
 				(_________p1); \
 				})
 
+/**
+ * rcu_assign_pointer - assign (publicize) a pointer to a newly
+ * initialized structure that will be dereferenced by RCU read-side
+ * critical sections.  Returns the value assigned.
+ *
+ * Inserts memory barriers on architectures that require them
+ * (pretty much all of them other than x86), and also prevents
+ * the compiler from reordering the code that initializes the
+ * structure after the pointer assignment.  More importantly, this
+ * call documents which pointers will be dereferenced by RCU read-side
+ * code.
+ */
+
+#define rcu_assign_pointer(p, v)	({ \
+						smp_wmb(); \
+						(p) = (v); \
+					})
+
 extern void rcu_init(void);
 extern void rcu_check_callbacks(int cpu, int user);
 extern void rcu_restart_cpu(int cpu);
diff -Nru a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
--- a/include/linux/reiserfs_fs.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/reiserfs_fs.h	2004-12-24 13:37:19 -08:00
@@ -16,6 +16,7 @@
 #ifdef __KERNEL__
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/sched.h>
 #include <linux/workqueue.h>
 #include <asm/unaligned.h>
 #include <linux/bitops.h>
@@ -438,7 +439,7 @@
 
 /* Key of an item determines its location in the S+tree, and
    is composed of 4 components */
-struct key {
+struct reiserfs_key {
     __u32 k_dir_id;    /* packing locality: by default parent
 			  directory object id */
     __u32 k_objectid;  /* object identifier */
@@ -450,7 +451,7 @@
 
 
 struct cpu_key {
-    struct key on_disk_key;
+    struct reiserfs_key on_disk_key;
     int version;
     int key_length; /* 3 in all cases but direct2indirect and
 		       indirect2direct conversion */
@@ -470,7 +471,7 @@
 #define KEY_FOUND 1
 #define KEY_NOT_FOUND 0
 
-#define KEY_SIZE (sizeof(struct key))
+#define KEY_SIZE (sizeof(struct reiserfs_key))
 #define SHORT_KEY_SIZE (sizeof (__u32) + sizeof (__u32))
 
 /* return values for search_by_key and clones */
@@ -503,7 +504,7 @@
 {
 	/* Everything in the tree is found by searching for it based on
 	 * its key.*/
-	struct key ih_key; 	
+	struct reiserfs_key ih_key;
 	union {
 		/* The free space in the last unformatted node of an
 		   indirect item if this is an indirect item.  This
@@ -602,7 +603,7 @@
 // there is no way to get version of object from key, so, provide
 // version to these defines
 //
-static inline loff_t le_key_k_offset (int version, const struct key * key)
+static inline loff_t le_key_k_offset (int version, const struct reiserfs_key * key)
 {
     return (version == KEY_FORMAT_3_5) ?
         le32_to_cpu( key->u.k_offset_v1.k_offset ) :
@@ -614,7 +615,7 @@
     return le_key_k_offset (ih_version (ih), &(ih->ih_key));
 }
 
-static inline loff_t le_key_k_type (int version, const struct key * key)
+static inline loff_t le_key_k_type (int version, const struct reiserfs_key * key)
 {
     return (version == KEY_FORMAT_3_5) ?
         uniqueness2type( le32_to_cpu( key->u.k_offset_v1.k_uniqueness)) :
@@ -627,7 +628,7 @@
 }
 
 
-static inline void set_le_key_k_offset (int version, struct key * key, loff_t offset)
+static inline void set_le_key_k_offset (int version, struct reiserfs_key * key, loff_t offset)
 {
     (version == KEY_FORMAT_3_5) ?
         (void)(key->u.k_offset_v1.k_offset = cpu_to_le32 (offset)) : /* jdm check */
@@ -641,7 +642,7 @@
 }
 
 
-static inline void set_le_key_k_type (int version, struct key * key, int type)
+static inline void set_le_key_k_type (int version, struct reiserfs_key * key, int type)
 {
     (version == KEY_FORMAT_3_5) ?
         (void)(key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type2uniqueness(type))):
@@ -738,7 +739,7 @@
 /* object identifier for root dir */
 #define REISERFS_ROOT_OBJECTID 2
 #define REISERFS_ROOT_PARENT_OBJECTID 1
-extern struct key root_key;
+extern struct reiserfs_key root_key;
 
 
 
@@ -760,7 +761,7 @@
   __u16 blk_free_space;   /* Block free space in bytes. */
   __u16 blk_reserved;
 				/* dump this in v4/planA */
-  struct key  blk_right_delim_key; /* kept only for compatibility */
+  struct reiserfs_key  blk_right_delim_key; /* kept only for compatibility */
 };
 
 #define BLKH_SIZE                     (sizeof(struct block_head))
@@ -1301,7 +1302,7 @@
 #define UNFM_P_SHIFT 2
 
 // in in-core inode key is stored on le form
-#define INODE_PKEY(inode) ((struct key *)(REISERFS_I(inode)->i_key))
+#define INODE_PKEY(inode) ((struct reiserfs_key *)(REISERFS_I(inode)->i_key))
 
 #define MAX_UL_INT 0xffffffff
 #define MAX_INT    0x7ffffff
@@ -1479,7 +1480,7 @@
   int fs_gen;                  /* saved value of `reiserfs_generation' counter
 			          see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */
 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
-  struct key  key;	      /* key pointer, to pass to block allocator or
+  struct reiserfs_key  key;	      /* key pointer, to pass to block allocator or
 				 another low-level subsystem */
 #endif
 } ;
@@ -1543,7 +1544,7 @@
 struct item_operations {
     int (*bytes_number) (struct item_head * ih, int block_size);
     void (*decrement_key) (struct cpu_key *);
-    int (*is_left_mergeable) (struct key * ih, unsigned long bsize);
+    int (*is_left_mergeable) (struct reiserfs_key * ih, unsigned long bsize);
     void (*print_item) (struct item_head *, char * item);
     void (*check_item) (struct item_head *, char * item);
 
@@ -1594,7 +1595,7 @@
 #define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) )
 
 /* get key */
-#define B_N_PDELIM_KEY(bh,item_num) ( (struct key * )((bh)->b_data + BLKH_SIZE) + (item_num) )
+#define B_N_PDELIM_KEY(bh,item_num) ( (struct reiserfs_key * )((bh)->b_data + BLKH_SIZE) + (item_num) )
 
 /* get the key */
 #define B_N_PKEY(bh,item_num) ( &(B_N_PITEM_HEAD(bh,item_num)->ih_key) )
@@ -1711,14 +1712,29 @@
 #define journal_bread(s, block) __bread(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)
 
 enum reiserfs_bh_state_bits {
-    BH_JDirty = BH_PrivateStart,
+    BH_JDirty = BH_PrivateStart, /* buffer is in current transaction */
     BH_JDirty_wait,
-    BH_JNew,
+    BH_JNew,                     /* disk block was taken off free list before
+                                  * being in a finished transaction, or
+                                  * written to disk. Can be reused immed. */
     BH_JPrepared,
     BH_JRestore_dirty,
     BH_JTest, // debugging only will go away
 };
 
+BUFFER_FNS(JDirty, journaled);
+TAS_BUFFER_FNS(JDirty, journaled);
+BUFFER_FNS(JDirty_wait, journal_dirty);
+TAS_BUFFER_FNS(JDirty_wait, journal_dirty);
+BUFFER_FNS(JNew, journal_new);
+TAS_BUFFER_FNS(JNew, journal_new);
+BUFFER_FNS(JPrepared, journal_prepared);
+TAS_BUFFER_FNS(JPrepared, journal_prepared);
+BUFFER_FNS(JRestore_dirty, journal_restore_dirty);
+TAS_BUFFER_FNS(JRestore_dirty, journal_restore_dirty);
+BUFFER_FNS(JTest, journal_test);
+TAS_BUFFER_FNS(JTest, journal_test);
+
 /*
 ** transaction handle which is passed around for all journal calls
 */
@@ -1736,6 +1752,7 @@
   void *t_handle_save ;		/* save existing current->journal_info */
   unsigned displace_new_blocks:1; /* if new block allocation occurres, that block
 				   should be displaced from others */
+  struct list_head t_list;
 } ;
 
 /* used to keep track of ordered and tail writes, attached to the buffer
@@ -1795,41 +1812,14 @@
 int journal_transaction_should_end(struct reiserfs_transaction_handle *, int) ;
 int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr, int searchall, b_blocknr_t *next) ;
 int journal_begin(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;
-
-int buffer_journaled(const struct buffer_head *bh) ;
-int mark_buffer_journal_new(struct buffer_head *bh) ;
+int journal_join_abort(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;
+void reiserfs_journal_abort (struct super_block *sb, int errno);
+void reiserfs_abort (struct super_block *sb, int errno, const char *fmt, ...);
 int reiserfs_allocate_list_bitmaps(struct super_block *s, struct reiserfs_list_bitmap *, int) ;
 
-				/* why is this kerplunked right here? */
-static inline int reiserfs_buffer_prepared(const struct buffer_head *bh) {
-  if (bh && test_bit(BH_JPrepared, &bh->b_state))
-    return 1 ;
-  else
-    return 0 ;
-}
-
-/* buffer was journaled, waiting to get to disk */
-static inline int buffer_journal_dirty(const struct buffer_head *bh) {
-  if (bh)
-    return test_bit(BH_JDirty_wait, &bh->b_state) ;
-  else
-    return 0 ;
-}
-static inline int mark_buffer_notjournal_dirty(struct buffer_head *bh) {
-  if (bh)
-    clear_bit(BH_JDirty_wait, &bh->b_state) ;
-  return 0 ;
-}
-static inline int mark_buffer_notjournal_new(struct buffer_head *bh) {
-  if (bh) {
-    clear_bit(BH_JNew, &bh->b_state) ;
-  }
-  return 0 ;
-}
-
 void add_save_link (struct reiserfs_transaction_handle * th,
 					struct inode * inode, int truncate);
-void remove_save_link (struct inode * inode, int truncate);
+int remove_save_link (struct inode * inode, int truncate);
 
 /* objectid.c */
 __u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th);
@@ -1843,11 +1833,11 @@
 								  const struct item_head * p_v_from);
 
 // first key is in cpu form, second - le
-extern int comp_keys (const struct key * le_key,
+extern int comp_keys (const struct reiserfs_key * le_key,
 			     const struct cpu_key * cpu_key);
-extern int  comp_short_keys (const struct key * le_key,
+extern int  comp_short_keys (const struct reiserfs_key * le_key,
 				    const struct cpu_key * cpu_key);
-extern void le_key2cpu_key (struct cpu_key * to, const struct key * from);
+extern void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from);
 
 // both are cpu keys
 extern  int comp_cpu_keys (const struct cpu_key *, const struct cpu_key *);
@@ -1856,13 +1846,13 @@
 extern void cpu_key2cpu_key (struct cpu_key *, const struct cpu_key *);
 
 // both are in le form
-extern int comp_le_keys (const struct key *, const struct key *);
-extern int comp_short_le_keys (const struct key *, const struct key *);
+extern int comp_le_keys (const struct reiserfs_key *, const struct reiserfs_key *);
+extern int comp_short_le_keys (const struct reiserfs_key *, const struct reiserfs_key *);
 
 //
 // get key version from on disk key - kludge
 //
-static inline int le_key_version (const struct key * key)
+static inline int le_key_version (const struct reiserfs_key * key)
 {
     int type;
     
@@ -1875,14 +1865,14 @@
 }
 
 
-static inline void copy_key (struct key *to, const struct key *from)
+static inline void copy_key (struct reiserfs_key *to, const struct reiserfs_key *from)
 {
     memcpy (to, from, KEY_SIZE);
 }
 
 
 int comp_items (const struct item_head * stored_ih, const struct path * p_s_path);
-const struct key * get_rkey (const struct path * p_s_chk_path, 
+const struct reiserfs_key * get_rkey (const struct path * p_s_chk_path,
 							 const struct super_block  * p_s_sb);
 inline int bin_search (const void * p_v_key, const void * p_v_base, 
 					   int p_n_num, int p_n_width, int * p_n_pos);
@@ -1924,9 +1914,9 @@
 			  struct buffer_head  * p_s_un_bh);
 
 void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
-				 struct inode *inode, struct key * key);
-void reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * p_s_inode);
-void reiserfs_do_truncate (struct reiserfs_transaction_handle *th, 
+			struct inode *inode, struct reiserfs_key * key);
+int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * p_s_inode);
+int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
 			   struct  inode * p_s_inode, struct page *, 
 			   int update_timestamps);
 
@@ -1940,7 +1930,7 @@
 void padd_item (char * item, int total_length, int length);
 
 /* inode.c */
-void restart_transaction(struct reiserfs_transaction_handle *th, struct inode *inode, struct path *path);
+int restart_transaction(struct reiserfs_transaction_handle *th, struct inode *inode, struct path *path);
 void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
 int reiserfs_find_actor(struct inode * inode, void *p) ;
 int reiserfs_init_locked_inode(struct inode * inode, void *p) ;
@@ -1955,7 +1945,7 @@
 						int connectable );
 
 int reiserfs_prepare_write(struct file *, struct page *, unsigned, unsigned) ;
-void reiserfs_truncate_file(struct inode *, int update_timestamps) ;
+int reiserfs_truncate_file(struct inode *, int update_timestamps) ;
 void make_cpu_key (struct cpu_key * cpu_key, struct inode * inode, loff_t offset,
 		   int type, int key_length);
 void make_le_item_head (struct item_head * ih, const struct cpu_key * key, 
@@ -2142,7 +2132,7 @@
  struct __reiserfs_blocknr_hint {
      struct inode * inode;		/* inode passed to allocator, if we allocate unf. nodes */
      long block;			/* file offset, in blocks */
-     struct key key;
+     struct reiserfs_key key;
      struct path * path;		/* search path, used by allocator to deternine search_start by
 					 * various ways */
      struct reiserfs_transaction_handle * th; /* transaction handle is needed to log super blocks and
diff -Nru a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
--- a/include/linux/reiserfs_fs_sb.h	2004-12-24 13:36:55 -08:00
+++ b/include/linux/reiserfs_fs_sb.h	2004-12-24 13:36:55 -08:00
@@ -206,11 +206,11 @@
   int j_cnode_used ;	      /* number of cnodes on the used list */
   int j_cnode_free ;          /* number of cnodes on the free list */
 
-  unsigned int s_journal_trans_max ;           /* max number of blocks in a transaction.  */
-  unsigned int s_journal_max_batch ;           /* max number of blocks to batch into a trans */
-  unsigned int s_journal_max_commit_age ;      /* in seconds, how old can an async commit be */
-  unsigned int s_journal_default_max_commit_age ; /* the default for the max commit age */
-  unsigned int s_journal_max_trans_age ;       /* in seconds, how old can a transaction be */  
+  unsigned int j_trans_max ;           /* max number of blocks in a transaction.  */
+  unsigned int j_max_batch ;           /* max number of blocks to batch into a trans */
+  unsigned int j_max_commit_age ;      /* in seconds, how old can an async commit be */
+  unsigned int j_max_trans_age ;       /* in seconds, how old can a transaction be */
+  unsigned int j_default_max_commit_age ; /* the default for the max commit age */
 
   struct reiserfs_journal_cnode *j_cnode_free_list ;
   struct reiserfs_journal_cnode *j_cnode_free_orig ; /* orig pointer returned from vmalloc */
@@ -242,14 +242,24 @@
   struct reiserfs_journal_cnode *j_list_hash_table[JOURNAL_HASH_SIZE] ; /* hash table for all the real buffer heads in all 
   										the transactions */
   struct list_head j_prealloc_list;     /* list of inodes which have preallocated blocks */
+  int j_persistent_trans;
   unsigned long j_max_trans_size ;
   unsigned long j_max_batch_size ;
 
+  int j_errno;
+
   /* when flushing ordered buffers, throttle new ordered writers */
   struct work_struct j_work;
   atomic_t j_async_throttle;
 };
 
+enum journal_state_bits {
+    J_WRITERS_BLOCKED = 1,   /* set when new writers not allowed */
+    J_WRITERS_QUEUED,        /* set when log is full due to too many writers */
+    J_ABORTED,               /* set when log is aborted */
+};
+
+
 #define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick.  magic string to find desc blocks in the journal */
 
 typedef __u32 (*hashf_t) (const signed char *, int);
@@ -399,6 +409,7 @@
     struct dentry *xattr_root; /* root of /.reiserfs_priv/.xa */
     struct rw_semaphore xattr_dir_sem;
 
+    int j_errno;
 };
 
 /* Definitions of reiserfs on-disk properties: */
@@ -447,10 +458,16 @@
     REISERFS_BARRIER_NONE,
     REISERFS_BARRIER_FLUSH,
 
+    /* Actions on error */
+    REISERFS_ERROR_PANIC,
+    REISERFS_ERROR_RO,
+    REISERFS_ERROR_CONTINUE,
+
     REISERFS_TEST1,
     REISERFS_TEST2,
     REISERFS_TEST3,
     REISERFS_TEST4,
+    REISERFS_UNSUPPORTED_OPT,
 };
 
 #define reiserfs_r5_hash(s) (REISERFS_SB(s)->s_mount_opt & (1 << FORCE_R5_HASH))
@@ -478,6 +495,10 @@
 #define reiserfs_barrier_none(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_BARRIER_NONE))
 #define reiserfs_barrier_flush(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_BARRIER_FLUSH))
 
+#define reiserfs_error_panic(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_ERROR_PANIC))
+#define reiserfs_error_ro(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_ERROR_RO))
+#define reiserfs_error_continue(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_ERROR_CONTINUE))
+
 void reiserfs_file_buffer (struct buffer_head * bh, int list);
 extern struct file_system_type reiserfs_fs_type;
 int reiserfs_resize(struct super_block *, unsigned long) ;
@@ -494,18 +515,18 @@
 
 #define SB_DISK_JOURNAL_HEAD(s) (SB_JOURNAL(s)->j_header_bh->)
 
-#define SB_JOURNAL_TRANS_MAX(s)      (SB_JOURNAL(s)->s_journal_trans_max)
-#define SB_JOURNAL_MAX_BATCH(s)      (SB_JOURNAL(s)->s_journal_max_batch)
-#define SB_JOURNAL_MAX_COMMIT_AGE(s) (SB_JOURNAL(s)->s_journal_max_commit_age)
-#define SB_JOURNAL_DEFAULT_MAX_COMMIT_AGE(s) (SB_JOURNAL(s)->s_journal_default_max_commit_age)
-#define SB_JOURNAL_MAX_TRANS_AGE(s)  (SB_JOURNAL(s)->s_journal_max_trans_age)
-
 /* A safe version of the "bdevname", which returns the "s_id" field of
  * a superblock or else "Null superblock" if the super block is NULL.
  */
 static inline char *reiserfs_bdevname(struct super_block *s)
 {
         return (s == NULL) ? "Null superblock" : s -> s_id;
+}
+
+#define reiserfs_is_journal_aborted(journal) (unlikely (__reiserfs_is_journal_aborted (journal)))
+static inline int __reiserfs_is_journal_aborted (struct reiserfs_journal *journal)
+{
+    return test_bit (J_ABORTED, &journal->j_state);
 }
 
 #endif	/* _LINUX_REISER_FS_SB */
diff -Nru a/include/linux/rmap.h b/include/linux/rmap.h
--- a/include/linux/rmap.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/rmap.h	2004-12-24 13:36:18 -08:00
@@ -7,6 +7,7 @@
 #include <linux/config.h>
 #include <linux/list.h>
 #include <linux/slab.h>
+#include <linux/mm.h>
 #include <linux/spinlock.h>
 
 /*
@@ -88,7 +89,7 @@
 /*
  * Called from mm/vmscan.c to handle paging out
  */
-int page_referenced(struct page *, int is_locked);
+int page_referenced(struct page *, int is_locked, int ignore_token);
 int try_to_unmap(struct page *);
 
 /*
@@ -102,7 +103,7 @@
 #define anon_vma_prepare(vma)	(0)
 #define anon_vma_link(vma)	do {} while (0)
 
-#define page_referenced(page,l)	TestClearPageReferenced(page)
+#define page_referenced(page,l,i) TestClearPageReferenced(page)
 #define try_to_unmap(page)	SWAP_FAIL
 
 #endif	/* CONFIG_MMU */
diff -Nru a/include/linux/rslib.h b/include/linux/rslib.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/rslib.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,105 @@
+/* 
+ * include/linux/rslib.h
+ *
+ * Overview:
+ *   Generic Reed Solomon encoder / decoder library
+ *   
+ * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
+ *
+ * RS code lifted from reed solomon library written by Phil Karn
+ * Copyright 2002 Phil Karn, KA9Q
+ *
+ * $Id: rslib.h,v 1.3 2004/10/05 22:08:22 gleixner Exp $
+ *
+ * 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.
+ */
+
+#ifndef _RSLIB_H_
+#define _RSLIB_H_
+
+#include <linux/list.h>
+
+/** 
+ * struct rs_control - rs control structure
+ * 
+ * @mm:		Bits per symbol
+ * @nn:		Symbols per block (= (1<<mm)-1)
+ * @alpha_to:	log lookup table
+ * @index_of:	Antilog lookup table
+ * @genpoly:	Generator polynomial 
+ * @nroots:	Number of generator roots = number of parity symbols
+ * @fcr:	First consecutive root, index form
+ * @prim:	Primitive element, index form 
+ * @iprim:	prim-th root of 1, index form 
+ * @gfpoly:	The primitive generator polynominal 
+ * @users:	Users of this structure 
+ * @list:	List entry for the rs control list
+*/
+struct rs_control {
+	int 		mm;
+	int 		nn;
+	uint16_t	*alpha_to;
+	uint16_t	*index_of;
+	uint16_t	*genpoly;
+	int 		nroots;
+	int 		fcr;
+	int 		prim;
+	int 		iprim;
+	int		gfpoly;
+	int		users;
+	struct list_head list;
+};
+
+/* General purpose RS codec, 8-bit data width, symbol width 1-15 bit  */
+#ifdef CONFIG_REED_SOLOMON_ENC8
+int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par,
+	       uint16_t invmsk);
+#endif
+#ifdef CONFIG_REED_SOLOMON_DEC8
+int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, 
+		uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,
+	       uint16_t *corr);
+#endif
+
+/* General purpose RS codec, 16-bit data width, symbol width 1-15 bit  */
+#ifdef CONFIG_REED_SOLOMON_ENC16
+int encode_rs16(struct rs_control *rs, uint16_t *data, int len, uint16_t *par,
+		uint16_t invmsk);
+#endif
+#ifdef CONFIG_REED_SOLOMON_DEC16
+int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len,
+		uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,
+		uint16_t *corr);
+#endif
+
+/* Create or get a matching rs control structure */
+struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, 
+			   int nroots);
+
+/* Release a rs control structure */
+void free_rs(struct rs_control *rs);
+
+/** modulo replacement for galois field arithmetics
+ *
+ *  @rs:	the rs control structure
+ *  @x:		the value to reduce
+ *
+ *  where
+ *  rs->mm = number of bits per symbol	
+ *  rs->nn = (2^rs->mm) - 1
+ *  
+ *  Simple arithmetic modulo would return a wrong result for values
+ *  >= 3 * rs->nn
+*/
+static inline int rs_modnn(struct rs_control *rs, int x)
+{
+	while (x >= rs->nn) {
+		x -= rs->nn;
+		x = (x >> rs->mm) + (x & rs->nn);
+	}
+	return x;
+}
+
+#endif
diff -Nru a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
--- a/include/linux/rtnetlink.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/rtnetlink.h	2004-12-24 13:37:18 -08:00
@@ -698,6 +698,8 @@
 	TCA_XSTATS,
 	TCA_RATE,
 	TCA_FCNT,
+	TCA_STATS2,
+	TCA_ACT_STATS,
 	__TCA_MAX
 };
 
diff -Nru a/include/linux/scatterlist.h b/include/linux/scatterlist.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/scatterlist.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,14 @@
+#ifndef _LINUX_SCATTERLIST_H
+#define _LINUX_SCATTERLIST_H
+
+static inline void sg_init_one(struct scatterlist *sg,
+			       u8 *buf, unsigned int buflen)
+{
+	memset(sg, 0, sizeof(*sg));
+
+	sg->page = virt_to_page(buf);
+	sg->offset = offset_in_page(buf);
+	sg->length = buflen;
+}
+
+#endif /* _LINUX_SCATTERLIST_H */
diff -Nru a/include/linux/sched.h b/include/linux/sched.h
--- a/include/linux/sched.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/sched.h	2004-12-24 13:36:18 -08:00
@@ -29,6 +29,7 @@
 #include <linux/completion.h>
 #include <linux/pid.h>
 #include <linux/percpu.h>
+#include <linux/topology.h>
 
 struct exec_domain;
 
@@ -107,8 +108,8 @@
 #define TASK_UNINTERRUPTIBLE	2
 #define TASK_STOPPED		4
 #define TASK_TRACED		8
-#define TASK_ZOMBIE		16
-#define TASK_DEAD		32
+#define EXIT_ZOMBIE		16
+#define EXIT_DEAD		32
 
 #define __set_task_state(tsk, state_value)		\
 	do { (tsk)->state = (state_value); } while (0)
@@ -215,9 +216,9 @@
 	atomic_t mm_count;			/* How many references to "struct mm_struct" (users count as 1) */
 	int map_count;				/* number of VMAs */
 	struct rw_semaphore mmap_sem;
-	spinlock_t page_table_lock;		/* Protects task page tables and mm->rss */
+	spinlock_t page_table_lock;		/* Protects page tables, mm->rss, mm->anon_rss */
 
-	struct list_head mmlist;		/* List of all active mm's.  These are globally strung
+	struct list_head mmlist;		/* List of maybe swapped mm's.  These are globally strung
 						 * together off init_mm.mmlist, and are protected
 						 * by mmlist_lock
 						 */
@@ -225,8 +226,8 @@
 	unsigned long start_code, end_code, start_data, end_data;
 	unsigned long start_brk, brk, start_stack;
 	unsigned long arg_start, arg_end, env_start, env_end;
-	unsigned long rss, total_vm, locked_vm, shared_vm;
-	unsigned long exec_vm, stack_vm, reserved_vm, def_flags;
+	unsigned long rss, anon_rss, total_vm, locked_vm, shared_vm;
+	unsigned long exec_vm, stack_vm, reserved_vm, def_flags, nr_ptes;
 
 	unsigned long saved_auxv[42]; /* for /proc/PID/auxv */
 
@@ -251,8 +252,6 @@
 	struct kioctx		default_kioctx;
 };
 
-extern int mmlist_nr;
-
 struct sighand_struct {
 	atomic_t		count;
 	struct k_sigaction	action[_NSIG];
@@ -268,6 +267,7 @@
  */
 struct signal_struct {
 	atomic_t		count;
+	atomic_t		live;
 
 	/* current thread group signal load-balancing target: */
 	task_t			*curr_target;
@@ -312,6 +312,17 @@
 	unsigned long utime, stime, cutime, cstime;
 	unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
 	unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
+
+	/*
+	 * We don't bother to synchronize most readers of this at all,
+	 * because there is no reader checking a limit that actually needs
+	 * to get both rlim_cur and rlim_max atomically, and either one
+	 * alone is a single word that can safely be read normally.
+	 * getrlimit/setrlimit use task_lock(current->group_leader) to
+	 * protect this instead of the siglock, because they really
+	 * have no need to disable irqs.
+	 */
+	struct rlimit rlim[RLIM_NLIMITS];
 };
 
 /*
@@ -346,6 +357,11 @@
 	unsigned long mq_bytes;	/* How many bytes can be allocated to mqueue? */
 	unsigned long locked_shm; /* How many pages of mlocked shm ? */
 
+#ifdef CONFIG_KEYS
+	struct key *uid_keyring;	/* UID specific keyring */
+	struct key *session_keyring;	/* UID's default session keyring */
+#endif
+
 	/* Hash table maintenance information */
 	struct list_head uidhash_list;
 	uid_t uid;
@@ -360,26 +376,6 @@
 struct backing_dev_info;
 struct reclaim_state;
 
-/* POSIX.1b interval timer structure. */
-struct k_itimer {
-	struct list_head list;		 /* free/ allocate list */
-	spinlock_t it_lock;
-	clockid_t it_clock;		/* which timer type */
-	timer_t it_id;			/* timer id */
-	int it_overrun;			/* overrun on pending signal  */
-	int it_overrun_last;		 /* overrun on last delivered signal */
-	int it_requeue_pending;          /* waiting to requeue this timer */
-	int it_sigev_notify;		 /* notify word of sigevent struct */
-	int it_sigev_signo;		 /* signo word of sigevent struct */
-	sigval_t it_sigev_value;	 /* value word of sigevent struct */
-	unsigned long it_incr;		/* interval specified in jiffies */
-	struct task_struct *it_process;	/* process to send signal to */
-	struct timer_list it_timer;
-	struct sigqueue *sigq;		/* signal queue entry. */
-	struct list_head abs_timer_entry; /* clock abs_timer_list */
-	struct timespec wall_to_prev;   /* wall_to_monotonic used when set */
-};
-
 #ifdef CONFIG_SCHEDSTATS
 struct sched_info {
 	/* cumulative counters */
@@ -395,6 +391,86 @@
 extern struct file_operations proc_schedstat_operations;
 #endif
 
+enum idle_type
+{
+	SCHED_IDLE,
+	NOT_IDLE,
+	NEWLY_IDLE,
+	MAX_IDLE_TYPES
+};
+
+/*
+ * sched-domains (multiprocessor balancing) declarations:
+ */
+#ifdef CONFIG_SMP
+#define SCHED_LOAD_SCALE	128UL	/* increase resolution of load */
+
+#define SD_LOAD_BALANCE		1	/* Do load balancing on this domain. */
+#define SD_BALANCE_NEWIDLE	2	/* Balance when about to become idle */
+#define SD_BALANCE_EXEC		4	/* Balance on exec */
+#define SD_WAKE_IDLE		8	/* Wake to idle CPU on task wakeup */
+#define SD_WAKE_AFFINE		16	/* Wake task to waking CPU */
+#define SD_WAKE_BALANCE		32	/* Perform balancing at task wakeup */
+#define SD_SHARE_CPUPOWER	64	/* Domain members share cpu power */
+
+struct sched_group {
+	struct sched_group *next;	/* Must be a circular list */
+	cpumask_t cpumask;
+
+	/*
+	 * CPU power of this group, SCHED_LOAD_SCALE being max power for a
+	 * single CPU. This is read only (except for setup, hotplug CPU).
+	 */
+	unsigned long cpu_power;
+};
+
+struct sched_domain {
+	/* These fields must be setup */
+	struct sched_domain *parent;	/* top domain must be null terminated */
+	struct sched_group *groups;	/* the balancing groups of the domain */
+	cpumask_t span;			/* span of all CPUs in this domain */
+	unsigned long min_interval;	/* Minimum balance interval ms */
+	unsigned long max_interval;	/* Maximum balance interval ms */
+	unsigned int busy_factor;	/* less balancing by factor if busy */
+	unsigned int imbalance_pct;	/* No balance until over watermark */
+	unsigned long long cache_hot_time; /* Task considered cache hot (ns) */
+	unsigned int cache_nice_tries;	/* Leave cache hot tasks for # tries */
+	unsigned int per_cpu_gain;	/* CPU % gained by adding domain cpus */
+	int flags;			/* See SD_* */
+
+	/* Runtime fields. */
+	unsigned long last_balance;	/* init to jiffies. units in jiffies */
+	unsigned int balance_interval;	/* initialise to 1. units in ms. */
+	unsigned int nr_balance_failed; /* initialise to 0 */
+
+#ifdef CONFIG_SCHEDSTATS
+	/* load_balance() stats */
+	unsigned long lb_cnt[MAX_IDLE_TYPES];
+	unsigned long lb_failed[MAX_IDLE_TYPES];
+	unsigned long lb_imbalance[MAX_IDLE_TYPES];
+	unsigned long lb_nobusyg[MAX_IDLE_TYPES];
+	unsigned long lb_nobusyq[MAX_IDLE_TYPES];
+
+	/* sched_balance_exec() stats */
+	unsigned long sbe_attempts;
+	unsigned long sbe_pushed;
+
+	/* try_to_wake_up() stats */
+	unsigned long ttwu_wake_affine;
+	unsigned long ttwu_wake_balance;
+#endif
+};
+
+#ifdef ARCH_HAS_SCHED_DOMAIN
+/* Useful helpers that arch setup code may use. Defined in kernel/sched.c */
+extern cpumask_t cpu_isolated_map;
+extern void init_sched_build_groups(struct sched_group groups[],
+	                        cpumask_t span, int (*group_fn)(int cpu));
+extern void cpu_attach_domain(struct sched_domain *sd, int cpu);
+#endif /* ARCH_HAS_SCHED_DOMAIN */
+#endif /* CONFIG_SMP */
+
+
 struct io_context;			/* See blkdev.h */
 void exit_io_context(void);
 
@@ -472,6 +548,7 @@
 
 /* task state */
 	struct linux_binfmt *binfmt;
+	long exit_state;
 	int exit_code, exit_signal;
 	int pdeath_signal;  /*  The signal sent when the parent dies  */
 	/* ??? */
@@ -518,8 +595,11 @@
 	kernel_cap_t   cap_effective, cap_inheritable, cap_permitted;
 	unsigned keep_capabilities:1;
 	struct user_struct *user;
-/* limits */
-	struct rlimit rlim[RLIM_NLIMITS];
+#ifdef CONFIG_KEYS
+	struct key *session_keyring;	/* keyring inherited over fork */
+	struct key *process_keyring;	/* keyring private to this process (CLONE_THREAD) */
+	struct key *thread_keyring;	/* keyring private to this thread */
+#endif
 	unsigned short used_math;
 	char comm[16];
 /* file system info */
@@ -553,7 +633,7 @@
 /* Thread group tracking */
    	u32 parent_exec_id;
    	u32 self_exec_id;
-/* Protection of (de-)allocation: mm, files, fs, tty */
+/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */
 	spinlock_t alloc_lock;
 /* Protection of proc_dentry: nesting proc_lock, dcache_lock, write_lock_irq(&tasklist_lock); */
 	spinlock_t proc_lock;
@@ -591,6 +671,19 @@
 	return tsk->signal->pgrp;
 }
 
+/**
+ * pid_alive - check that a task structure is not stale
+ * @p: Task structure to be checked.
+ *
+ * Test if a process is not yet dead (at most zombie state)
+ * If pid_alive fails, then pointers within the task structure
+ * can be stale and must not be dereferenced.
+ */
+static inline int pid_alive(struct task_struct *p)
+{
+	return p->pids[PIDTYPE_PID].nr != 0;
+}
+
 extern void free_task(struct task_struct *tsk);
 extern void __put_task_struct(struct task_struct *tsk);
 #define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)
@@ -621,6 +714,7 @@
 #define PF_SWAPOFF	0x00080000	/* I am in swapoff */
 #define PF_LESS_THROTTLE 0x00100000	/* Throttle me less: I clean memory */
 #define PF_SYNCWRITE	0x00200000	/* I am doing a sync write */
+#define PF_BORROWED_MM	0x00400000	/* I am a kthread doing use_mm */
 
 #ifdef CONFIG_SMP
 extern int set_cpus_allowed(task_t *p, cpumask_t new_mask);
@@ -691,8 +785,6 @@
 
 #include <asm/current.h>
 
-extern unsigned long itimer_ticks;
-extern unsigned long itimer_next;
 extern void do_timer(struct pt_regs *);
 
 extern int FASTCALL(wake_up_state(struct task_struct * tsk, unsigned int state));
@@ -737,7 +829,6 @@
 extern int force_sig_info(int, struct siginfo *, struct task_struct *);
 extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
 extern int kill_pg_info(int, struct siginfo *, pid_t);
-extern int kill_sl_info(int, struct siginfo *, pid_t);
 extern int kill_proc_info(int, struct siginfo *, pid_t);
 extern void do_notify_parent(struct task_struct *, int);
 extern void force_sig(int, struct task_struct *);
@@ -886,8 +977,8 @@
 extern void unhash_process(struct task_struct *p);
 
 /*
- * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info, ->comm and
- * synchronises with wait4().
+ * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info, ->comm, keyring
+ * subscriptions and synchronises with wait4().  Also used in procfs.
  *
  * Nests both inside and outside of read_lock(&tasklist_lock).
  * It must not be nested with write_lock_irq(&tasklist_lock),
@@ -1026,6 +1117,12 @@
 
 extern long sched_setaffinity(pid_t pid, cpumask_t new_mask);
 extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
+
+#ifdef CONFIG_MAGIC_SYSRQ
+
+extern void normalize_rt_tasks(void);
+
+#endif
 
 #endif /* __KERNEL__ */
 
diff -Nru a/include/linux/sctp.h b/include/linux/sctp.h
--- a/include/linux/sctp.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/sctp.h	2004-12-24 13:37:00 -08:00
@@ -281,7 +281,11 @@
 	sctp_paramhdr_t param_hdr;
 } __attribute__((packed)) sctp_ecn_capable_param_t;
 
-
+/* ADDIP Section 3.2.6 Adaption Layer Indication */
+typedef struct sctp_adaption_ind_param {
+	struct sctp_paramhdr param_hdr;
+	__u32 adaption_ind;
+} __attribute__((packed)) sctp_adaption_ind_param_t;
 
 /* RFC 2960.  Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
  *   The INIT ACK chunk is used to acknowledge the initiation of an SCTP
diff -Nru a/include/linux/security.h b/include/linux/security.h
--- a/include/linux/security.h	2004-12-24 13:37:03 -08:00
+++ b/include/linux/security.h	2004-12-24 13:37:03 -08:00
@@ -27,18 +27,18 @@
 #include <linux/signal.h>
 #include <linux/resource.h>
 #include <linux/sem.h>
-#include <linux/sysctl.h>
 #include <linux/shm.h>
 #include <linux/msg.h>
 #include <linux/sched.h>
-#include <linux/skbuff.h>
-#include <linux/netlink.h>
+
+struct ctl_table;
 
 /*
  * These functions are in security/capability.c and are used
  * as the default capabilities functions
  */
 extern int cap_capable (struct task_struct *tsk, int cap);
+extern int cap_settime (struct timespec *ts, struct timezone *tz);
 extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
 extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
 extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
@@ -53,18 +53,14 @@
 extern int cap_syslog (int type);
 extern int cap_vm_enough_memory (long pages);
 
-static inline int cap_netlink_send (struct sock *sk, struct sk_buff *skb)
-{
-	NETLINK_CB (skb).eff_cap = current->cap_effective;
-	return 0;
-}
+struct msghdr;
+struct sk_buff;
+struct sock;
+struct sockaddr;
+struct socket;
 
-static inline int cap_netlink_recv (struct sk_buff *skb)
-{
-	if (!cap_raised (NETLINK_CB (skb).eff_cap, CAP_NET_ADMIN))
-		return -EPERM;
-	return 0;
-}
+extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
+extern int cap_netlink_recv(struct sk_buff *skb);
 
 /*
  * Values used in the task_security_ops calls
@@ -395,13 +391,13 @@
  * 	Return 0 if permission is granted.
  * @inode_getsecurity:
  *	Copy the extended attribute representation of the security label 
- *	associated with @name for @dentry into @buffer.  @buffer may be 
+ *	associated with @name for @inode into @buffer.  @buffer may be
  *	NULL to request the size of the buffer required.  @size indicates
  *	the size of @buffer in bytes.  Note that @name is the remainder
  *	of the attribute name after the security. prefix has been removed.
  *	Return number of bytes used/required on success.
  * @inode_setsecurity:
- *	Set the security label associated with @name for @dentry from the 
+ *	Set the security label associated with @name for @inode from the
  *	extended attribute value @value.  @size indicates the size of the
  *	@value in bytes.  @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
  *	Note that @name is the remainder of the attribute name after the 
@@ -409,8 +405,9 @@
  *	Return 0 on success.
  * @inode_listsecurity:
  *	Copy the extended attribute names for the security labels
- *	associated with @dentry into @buffer.  @buffer may be NULL to 
- *	request the size of the buffer required.  
+ *	associated with @inode into @buffer.  The maximum size of @buffer
+ *	is specified by @buffer_size.  @buffer may be NULL to request
+ *	the size of the buffer required.
  *	Returns number of bytes used/required on success.
  *
  * Security hooks for file operations
@@ -485,16 +482,15 @@
  *	@file contains the file structure to update.
  *	Return 0 on success.
  * @file_send_sigiotask:
- *	Check permission for the file owner @fown to send SIGIO to the process
- *	@tsk.  Note that this hook is always called from interrupt.  Note that
- *	the fown_struct, @fown, is never outside the context of a struct file,
- *	so the file structure (and associated security information) can always
- *	be obtained:
+ *	Check permission for the file owner @fown to send SIGIO or SIGURG to the
+ *	process @tsk.  Note that this hook is sometimes called from interrupt.
+ *	Note that the fown_struct, @fown, is never outside the context of a
+ *	struct file, so the file structure (and associated security information)
+ *	can always be obtained:
  *		(struct file *)((long)fown - offsetof(struct file,f_owner));
  * 	@tsk contains the structure of task receiving signal.
  *	@fown contains the file owner information.
- *	@fd contains the file descriptor.
- *	@reason contains the operational flags.
+ *	@sig is the signal that will be sent.  When 0, kernel sends SIGIO.
  *	Return 0 if permission is granted.
  * @file_receive:
  *	This hook allows security modules to control the ability of a process
@@ -582,7 +578,7 @@
  * @task_setrlimit:
  *	Check permission before setting the resource limits of the current
  *	process for @resource to @new_rlim.  The old resource limit values can
- *	be examined by dereferencing (current->rlim + resource).
+ *	be examined by dereferencing (current->signal->rlim + resource).
  *	@resource contains the resource whose limit is being set.
  *	@new_rlim contains the new limits for @resource.
  *	Return 0 if permission is granted.
@@ -999,6 +995,12 @@
  *	See the syslog(2) manual page for an explanation of the @type values.  
  *	@type contains the type of action.
  *	Return 0 if permission is granted.
+ * @settime:
+ *	Check permission to change the system time.
+ *	struct timespec and timezone are defined in include/linux/time.h
+ *	@ts contains new time
+ *	@tz contains new timezone
+ *	Return 0 if permission is granted.
  * @vm_enough_memory:
  *	Check permissions for allocating a new virtual mapping.
  *      @pages contains the number of pages.
@@ -1029,11 +1031,12 @@
 			    kernel_cap_t * inheritable,
 			    kernel_cap_t * permitted);
 	int (*acct) (struct file * file);
-	int (*sysctl) (ctl_table * table, int op);
+	int (*sysctl) (struct ctl_table * table, int op);
 	int (*capable) (struct task_struct * tsk, int cap);
 	int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
 	int (*quota_on) (struct file * f);
 	int (*syslog) (int type);
+	int (*settime) (struct timespec *ts, struct timezone *tz);
 	int (*vm_enough_memory) (long pages);
 
 	int (*bprm_alloc_security) (struct linux_binprm * bprm);
@@ -1108,9 +1111,9 @@
 	int (*inode_getxattr) (struct dentry *dentry, char *name);
 	int (*inode_listxattr) (struct dentry *dentry);
 	int (*inode_removexattr) (struct dentry *dentry, char *name);
-  	int (*inode_getsecurity)(struct dentry *dentry, const char *name, void *buffer, size_t size);
-  	int (*inode_setsecurity)(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
-  	int (*inode_listsecurity)(struct dentry *dentry, char *buffer);
+  	int (*inode_getsecurity)(struct inode *inode, const char *name, void *buffer, size_t size);
+  	int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
+  	int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
 
 	int (*file_permission) (struct file * file, int mask);
 	int (*file_alloc_security) (struct file * file);
@@ -1125,8 +1128,7 @@
 			   unsigned long arg);
 	int (*file_set_fowner) (struct file * file);
 	int (*file_send_sigiotask) (struct task_struct * tsk,
-				    struct fown_struct * fown,
-				    int fd, int reason);
+				    struct fown_struct * fown, int sig);
 	int (*file_receive) (struct file * file);
 
 	int (*task_create) (unsigned long clone_flags);
@@ -1268,7 +1270,7 @@
 	return security_ops->acct (file);
 }
 
-static inline int security_sysctl(ctl_table * table, int op)
+static inline int security_sysctl(struct ctl_table *table, int op)
 {
 	return security_ops->sysctl(table, op);
 }
@@ -1289,6 +1291,12 @@
 	return security_ops->syslog(type);
 }
 
+static inline int security_settime(struct timespec *ts, struct timezone *tz)
+{
+	return security_ops->settime(ts, tz);
+}
+
+
 static inline int security_vm_enough_memory(long pages)
 {
 	return security_ops->vm_enough_memory(pages);
@@ -1575,19 +1583,19 @@
 	return security_ops->inode_removexattr (dentry, name);
 }
 
-static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
+static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
 {
-	return security_ops->inode_getsecurity(dentry, name, buffer, size);
+	return security_ops->inode_getsecurity(inode, name, buffer, size);
 }
 
-static inline int security_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) 
+static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
 {
-	return security_ops->inode_setsecurity(dentry, name, value, size, flags);
+	return security_ops->inode_setsecurity(inode, name, value, size, flags);
 }
 
-static inline int security_inode_listsecurity(struct dentry *dentry, char *buffer)
+static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
 {
-	return security_ops->inode_listsecurity(dentry, buffer);
+	return security_ops->inode_listsecurity(inode, buffer, buffer_size);
 }
 
 static inline int security_file_permission (struct file *file, int mask)
@@ -1641,9 +1649,9 @@
 
 static inline int security_file_send_sigiotask (struct task_struct *tsk,
 						struct fown_struct *fown,
-						int fd, int reason)
+						int sig)
 {
-	return security_ops->file_send_sigiotask (tsk, fown, fd, reason);
+	return security_ops->file_send_sigiotask (tsk, fown, sig);
 }
 
 static inline int security_file_receive (struct file *file)
@@ -1887,7 +1895,7 @@
 }
 
 /* prototypes */
-extern int security_scaffolding_startup	(void);
+extern int security_init	(void);
 extern int register_security	(struct security_operations *ops);
 extern int unregister_security	(struct security_operations *ops);
 extern int mod_reg_security	(const char *name, struct security_operations *ops);
@@ -1901,7 +1909,7 @@
  * are just stubbed out, but a few must call the proper capable code.
  */
 
-static inline int security_scaffolding_startup (void)
+static inline int security_init(void)
 {
 	return 0;
 }
@@ -1940,7 +1948,7 @@
 	return 0;
 }
 
-static inline int security_sysctl(ctl_table * table, int op)
+static inline int security_sysctl(struct ctl_table *table, int op)
 {
 	return 0;
 }
@@ -1961,6 +1969,11 @@
 	return cap_syslog(type);
 }
 
+static inline int security_settime(struct timespec *ts, struct timezone *tz)
+{
+	return cap_settime(ts, tz);
+}
+
 static inline int security_vm_enough_memory(long pages)
 {
 	return cap_vm_enough_memory(pages);
@@ -2214,17 +2227,17 @@
 	return cap_inode_removexattr(dentry, name);
 }
 
-static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
+static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
 {
 	return -EOPNOTSUPP;
 }
 
-static inline int security_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) 
+static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
 {
 	return -EOPNOTSUPP;
 }
 
-static inline int security_inode_listsecurity(struct dentry *dentry, char *buffer)
+static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
 {
 	return 0;
 }
@@ -2278,7 +2291,7 @@
 
 static inline int security_file_send_sigiotask (struct task_struct *tsk,
 						struct fown_struct *fown,
-						int fd, int reason)
+						int sig)
 {
 	return 0;
 }
@@ -2499,11 +2512,6 @@
 	return -EINVAL;
 }
 
-/*
- * The netlink capability defaults need to be used inline by default
- * (rather than hooking into the capability module) to reduce overhead
- * in the networking code.
- */
 static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
 {
 	return cap_netlink_send (sk, skb);
diff -Nru a/include/linux/serial.h b/include/linux/serial.h
--- a/include/linux/serial.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/serial.h	2004-12-24 13:36:31 -08:00
@@ -181,6 +181,8 @@
 /* Allow architectures to override entries in serial8250_ports[] at run time: */
 struct uart_port;	/* forward declaration */
 extern int early_serial_setup(struct uart_port *port);
+extern int early_serial_console_init(char *options);
+extern int serial8250_start_console(struct uart_port *port, char *options);
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_SERIAL_H */
diff -Nru a/include/linux/serial_8250.h b/include/linux/serial_8250.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/serial_8250.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,28 @@
+/*
+ *  linux/include/linux/serial_8250.h
+ *
+ *  Copyright (C) 2004 Russell King
+ *
+ * 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.
+ */
+#ifndef _LINUX_SERIAL_8250_H
+#define _LINUX_SERIAL_8250_H
+
+#include <linux/serial_core.h>
+#include <linux/device.h>
+
+struct plat_serial8250_port {
+	unsigned long	iobase;		/* io base address */
+	void __iomem	*membase;	/* ioremap cookie or NULL */
+	unsigned long	mapbase;	/* resource base */
+	unsigned int	irq;		/* interrupt number */
+	unsigned int	uartclk;	/* UART clock rate */
+	unsigned char	regshift;	/* register shift */
+	unsigned char	iotype;		/* UPIO_* */
+	unsigned int	flags;		/* UPF_* flags */
+};
+
+#endif
diff -Nru a/include/linux/serial_core.h b/include/linux/serial_core.h
--- a/include/linux/serial_core.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/serial_core.h	2004-12-24 13:36:18 -08:00
@@ -17,6 +17,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#ifndef LINUX_SERIAL_CORE_H
+#define LINUX_SERIAL_CORE_H
 
 /*
  * The type definitions.  These are from Ted Ts'o's serial.h
@@ -89,6 +91,15 @@
 /* MPC52xx type numbers */
 #define PORT_MPC52xx	59
 
+/* IBM icom */
+#define PORT_ICOM	60
+
+/* Samsung S3C2440 SoC */
+#define PORT_S3C2440	61
+
+/* Motorola i.MX SoC */
+#define PORT_IMX	62
+
 #ifdef __KERNEL__
 
 #include <linux/config.h>
@@ -96,6 +107,7 @@
 #include <linux/circ_buf.h>
 #include <linux/spinlock.h>
 #include <linux/sched.h>
+#include <linux/tty.h>
 
 struct uart_port;
 struct uart_info;
@@ -165,7 +177,7 @@
 struct uart_port {
 	spinlock_t		lock;			/* port lock */
 	unsigned int		iobase;			/* in/out[bwl] */
-	char			*membase;		/* read/write[bwl] */
+	unsigned char __iomem	*membase;		/* read/write[bwl] */
 	unsigned int		irq;			/* irq number */
 	unsigned int		uartclk;		/* base uart clock */
 	unsigned char		fifosize;		/* tx fifo size */
@@ -232,11 +244,11 @@
  * within.
  */
 struct uart_state {
-	unsigned int		close_delay;
-	unsigned int		closing_wait;
+	unsigned int		close_delay;		/* msec */
+	unsigned int		closing_wait;		/* msec */
 
 #define USF_CLOSING_WAIT_INF	(0)
-#define USF_CLOSING_WAIT_NONE	(65535)
+#define USF_CLOSING_WAIT_NONE	(~0U)
 
 	int			count;
 	int			pm_state;
@@ -246,7 +258,7 @@
 	struct semaphore	sem;
 };
 
-#define UART_XMIT_SIZE 1024
+#define UART_XMIT_SIZE	PAGE_SIZE
 /*
  * This is the state information which is only valid when the port
  * is open; it may be freed by the core driver once the device has
@@ -268,9 +280,6 @@
 #define UIF_NORMAL_ACTIVE	(1 << 29)
 #define UIF_INITIALIZED		(1 << 31)
 
-	unsigned char		*tmpbuf;
-	struct semaphore	tmpbuf_sem;
-
 	int			blocked_open;
 
 	struct tasklet_struct	tlet;
@@ -458,3 +467,5 @@
 					 !((cflag) & CLOCAL))
 
 #endif
+
+#endif /* LINUX_SERIAL_CORE_H */
diff -Nru a/include/linux/serial_reg.h b/include/linux/serial_reg.h
--- a/include/linux/serial_reg.h	2004-12-24 13:37:04 -08:00
+++ b/include/linux/serial_reg.h	2004-12-24 13:37:04 -08:00
@@ -14,47 +14,63 @@
 #ifndef _LINUX_SERIAL_REG_H
 #define _LINUX_SERIAL_REG_H
 
-#define UART_RX		0	/* In:  Receive buffer (DLAB=0) */
-#define UART_TX		0	/* Out: Transmit buffer (DLAB=0) */
-#define UART_DLL	0	/* Out: Divisor Latch Low (DLAB=1) */
-#define UART_TRG	0	/* (LCR=BF) FCTR bit 7 selects Rx or Tx
-				 * In: Fifo count
-				 * Out: Fifo custom trigger levels
-				 * XR16C85x only */
+/*
+ * DLAB=0
+ */
+#define UART_RX		0	/* In:  Receive buffer */
+#define UART_TX		0	/* Out: Transmit buffer */
 
-#define UART_DLM	1	/* Out: Divisor Latch High (DLAB=1) */
 #define UART_IER	1	/* Out: Interrupt Enable Register */
-#define UART_FCTR	1	/* (LCR=BF) Feature Control Register
-				 * XR16C85x only */
+#define UART_IER_MSI		0x08 /* Enable Modem status interrupt */
+#define UART_IER_RLSI		0x04 /* Enable receiver line status interrupt */
+#define UART_IER_THRI		0x02 /* Enable Transmitter holding register int. */
+#define UART_IER_RDI		0x01 /* Enable receiver data interrupt */
+/*
+ * Sleep mode for ST16650 and TI16750.  For the ST16650, EFR[4]=1
+ */
+#define UART_IERX_SLEEP		0x10 /* Enable sleep mode */
 
 #define UART_IIR	2	/* In:  Interrupt ID Register */
-#define UART_FCR	2	/* Out: FIFO Control Register */
-#define UART_EFR	2	/* I/O: Extended Features Register */
-				/* (DLAB=1, 16C660 only) */
+#define UART_IIR_NO_INT		0x01 /* No interrupts pending */
+#define UART_IIR_ID		0x06 /* Mask for the interrupt ID */
+#define UART_IIR_MSI		0x00 /* Modem status interrupt */
+#define UART_IIR_THRI		0x02 /* Transmitter holding register empty */
+#define UART_IIR_RDI		0x04 /* Receiver data interrupt */
+#define UART_IIR_RLSI		0x06 /* Receiver line status interrupt */
 
-#define UART_LCR	3	/* Out: Line Control Register */
-#define UART_MCR	4	/* Out: Modem Control Register */
-#define UART_LSR	5	/* In:  Line Status Register */
-#define UART_MSR	6	/* In:  Modem Status Register */
-#define UART_SCR	7	/* I/O: Scratch Register */
-#define UART_EMSR	7	/* (LCR=BF) Extended Mode Select Register 
-				 * FCTR bit 6 selects SCR or EMSR
-				 * XR16c85x only */
-
-/*
- * These are the definitions for the FIFO Control Register
- * (16650 only)
- */
+#define UART_FCR	2	/* Out: FIFO Control Register */
 #define UART_FCR_ENABLE_FIFO	0x01 /* Enable the FIFO */
 #define UART_FCR_CLEAR_RCVR	0x02 /* Clear the RCVR FIFO */
 #define UART_FCR_CLEAR_XMIT	0x04 /* Clear the XMIT FIFO */
 #define UART_FCR_DMA_SELECT	0x08 /* For DMA applications */
+/*
+ * Note: The FIFO trigger levels are chip specific:
+ *	RX:76 = 00  01  10  11	TX:54 = 00  01  10  11
+ * PC16550D:	 1   4   8  14		xx  xx  xx  xx
+ * TI16C550A:	 1   4   8  14          xx  xx  xx  xx
+ * TI16C550C:	 1   4   8  14          xx  xx  xx  xx
+ * ST16C550:	 1   4   8  14		xx  xx  xx  xx
+ * ST16C650:	 8  16  24  28		16   8  24  30	PORT_16650V2
+ * NS16C552:	 1   4   8  14		xx  xx  xx  xx
+ * ST16C654:	 8  16  56  60		 8  16  32  56	PORT_16654
+ * TI16C750:	 1  16  32  56		xx  xx  xx  xx	PORT_16750
+ * TI16C752:	 8  16  56  60		 8  16  32  56
+ */
+#define UART_FCR_R_TRIG_00	0x00
+#define UART_FCR_R_TRIG_01	0x40
+#define UART_FCR_R_TRIG_10	0x80
+#define UART_FCR_R_TRIG_11	0xc0
+#define UART_FCR_T_TRIG_00	0x00
+#define UART_FCR_T_TRIG_01	0x10
+#define UART_FCR_T_TRIG_10	0x20
+#define UART_FCR_T_TRIG_11	0x30
+
 #define UART_FCR_TRIGGER_MASK	0xC0 /* Mask for the FIFO trigger range */
 #define UART_FCR_TRIGGER_1	0x00 /* Mask for trigger set at 1 */
 #define UART_FCR_TRIGGER_4	0x40 /* Mask for trigger set at 4 */
 #define UART_FCR_TRIGGER_8	0x80 /* Mask for trigger set at 8 */
 #define UART_FCR_TRIGGER_14	0xC0 /* Mask for trigger set at 14 */
-/* 16650 redefinitions */
+/* 16650 definitions */
 #define UART_FCR6_R_TRIGGER_8	0x00 /* Mask for receive trigger set at 1 */
 #define UART_FCR6_R_TRIGGER_16	0x40 /* Mask for receive trigger set at 4 */
 #define UART_FCR6_R_TRIGGER_24  0x80 /* Mask for receive trigger set at 8 */
@@ -63,83 +79,129 @@
 #define UART_FCR6_T_TRIGGER_8	0x10 /* Mask for transmit trigger set at 8 */
 #define UART_FCR6_T_TRIGGER_24  0x20 /* Mask for transmit trigger set at 24 */
 #define UART_FCR6_T_TRIGGER_30	0x30 /* Mask for transmit trigger set at 30 */
-/* TI 16750 definitions */
-#define UART_FCR7_64BYTE	0x20 /* Go into 64 byte mode */
+#define UART_FCR7_64BYTE	0x20 /* Go into 64 byte mode (TI16C750) */
 
+#define UART_LCR	3	/* Out: Line Control Register */
 /*
- * These are the definitions for the Line Control Register
- * 
  * Note: if the word length is 5 bits (UART_LCR_WLEN5), then setting 
  * UART_LCR_STOP will select 1.5 stop bits, not 2 stop bits.
  */
-#define UART_LCR_DLAB	0x80	/* Divisor latch access bit */
-#define UART_LCR_SBC	0x40	/* Set break control */
-#define UART_LCR_SPAR	0x20	/* Stick parity (?) */
-#define UART_LCR_EPAR	0x10	/* Even parity select */
-#define UART_LCR_PARITY	0x08	/* Parity Enable */
-#define UART_LCR_STOP	0x04	/* Stop bits: 0=1 stop bit, 1= 2 stop bits */
-#define UART_LCR_WLEN5  0x00	/* Wordlength: 5 bits */
-#define UART_LCR_WLEN6  0x01	/* Wordlength: 6 bits */
-#define UART_LCR_WLEN7  0x02	/* Wordlength: 7 bits */
-#define UART_LCR_WLEN8  0x03	/* Wordlength: 8 bits */
+#define UART_LCR_DLAB		0x80 /* Divisor latch access bit */
+#define UART_LCR_SBC		0x40 /* Set break control */
+#define UART_LCR_SPAR		0x20 /* Stick parity (?) */
+#define UART_LCR_EPAR		0x10 /* Even parity select */
+#define UART_LCR_PARITY		0x08 /* Parity Enable */
+#define UART_LCR_STOP		0x04 /* Stop bits: 0=1 bit, 1=2 bits */
+#define UART_LCR_WLEN5		0x00 /* Wordlength: 5 bits */
+#define UART_LCR_WLEN6		0x01 /* Wordlength: 6 bits */
+#define UART_LCR_WLEN7		0x02 /* Wordlength: 7 bits */
+#define UART_LCR_WLEN8		0x03 /* Wordlength: 8 bits */
+
+#define UART_MCR	4	/* Out: Modem Control Register */
+#define UART_MCR_CLKSEL		0x80 /* Divide clock by 4 (TI16C752, EFR[4]=1) */
+#define UART_MCR_TCRTLR		0x40 /* Access TCR/TLR (TI16C752, EFR[4]=1) */
+#define UART_MCR_XONANY		0x20 /* Enable Xon Any (TI16C752, EFR[4]=1) */
+#define UART_MCR_AFE		0x20 /* Enable auto-RTS/CTS (TI16C550C/TI16C750) */
+#define UART_MCR_LOOP		0x10 /* Enable loopback test mode */
+#define UART_MCR_OUT2		0x08 /* Out2 complement */
+#define UART_MCR_OUT1		0x04 /* Out1 complement */
+#define UART_MCR_RTS		0x02 /* RTS complement */
+#define UART_MCR_DTR		0x01 /* DTR complement */
+
+#define UART_LSR	5	/* In:  Line Status Register */
+#define UART_LSR_TEMT		0x40 /* Transmitter empty */
+#define UART_LSR_THRE		0x20 /* Transmit-hold-register empty */
+#define UART_LSR_BI		0x10 /* Break interrupt indicator */
+#define UART_LSR_FE		0x08 /* Frame error indicator */
+#define UART_LSR_PE		0x04 /* Parity error indicator */
+#define UART_LSR_OE		0x02 /* Overrun error indicator */
+#define UART_LSR_DR		0x01 /* Receiver data ready */
+
+#define UART_MSR	6	/* In:  Modem Status Register */
+#define UART_MSR_DCD		0x80 /* Data Carrier Detect */
+#define UART_MSR_RI		0x40 /* Ring Indicator */
+#define UART_MSR_DSR		0x20 /* Data Set Ready */
+#define UART_MSR_CTS		0x10 /* Clear to Send */
+#define UART_MSR_DDCD		0x08 /* Delta DCD */
+#define UART_MSR_TERI		0x04 /* Trailing edge ring indicator */
+#define UART_MSR_DDSR		0x02 /* Delta DSR */
+#define UART_MSR_DCTS		0x01 /* Delta CTS */
+#define UART_MSR_ANY_DELTA	0x0F /* Any of the delta bits! */
+
+#define UART_SCR	7	/* I/O: Scratch Register */
 
 /*
- * These are the definitions for the Line Status Register
+ * DLAB=1
  */
-#define UART_LSR_TEMT	0x40	/* Transmitter empty */
-#define UART_LSR_THRE	0x20	/* Transmit-hold-register empty */
-#define UART_LSR_BI	0x10	/* Break interrupt indicator */
-#define UART_LSR_FE	0x08	/* Frame error indicator */
-#define UART_LSR_PE	0x04	/* Parity error indicator */
-#define UART_LSR_OE	0x02	/* Overrun error indicator */
-#define UART_LSR_DR	0x01	/* Receiver data ready */
+#define UART_DLL	0	/* Out: Divisor Latch Low */
+#define UART_DLM	1	/* Out: Divisor Latch High */
 
 /*
- * These are the definitions for the Interrupt Identification Register
+ * LCR=0xBF (or DLAB=1 for 16C660)
+ */
+#define UART_EFR	2	/* I/O: Extended Features Register */
+#define UART_EFR_CTS		0x80 /* CTS flow control */
+#define UART_EFR_RTS		0x40 /* RTS flow control */
+#define UART_EFR_SCD		0x20 /* Special character detect */
+#define UART_EFR_ECB		0x10 /* Enhanced control bit */
+/*
+ * the low four bits control software flow control
  */
-#define UART_IIR_NO_INT	0x01	/* No interrupts pending */
-#define UART_IIR_ID	0x06	/* Mask for the interrupt ID */
-
-#define UART_IIR_MSI	0x00	/* Modem status interrupt */
-#define UART_IIR_THRI	0x02	/* Transmitter holding register empty */
-#define UART_IIR_RDI	0x04	/* Receiver data interrupt */
-#define UART_IIR_RLSI	0x06	/* Receiver line status interrupt */
 
 /*
- * These are the definitions for the Interrupt Enable Register
+ * LCR=0xBF, TI16C752, ST16650, ST16650A, ST16654
  */
-#define UART_IER_MSI	0x08	/* Enable Modem status interrupt */
-#define UART_IER_RLSI	0x04	/* Enable receiver line status interrupt */
-#define UART_IER_THRI	0x02	/* Enable Transmitter holding register int. */
-#define UART_IER_RDI	0x01	/* Enable receiver data interrupt */
+#define UART_XON1	4	/* I/O: Xon character 1 */
+#define UART_XON2	5	/* I/O: Xon character 2 */
+#define UART_XOFF1	6	/* I/O: Xoff character 1 */
+#define UART_XOFF2	7	/* I/O: Xoff character 2 */
+
 /*
- * Sleep mode for ST16650 and TI16750.
- * Note that for 16650, EFR-bit 4 must be selected as well.
+ * EFR[4]=1 MCR[6]=1, TI16C752
  */
-#define UART_IERX_SLEEP  0x10	/* Enable sleep mode */
+#define UART_TI752_TCR	6	/* I/O: transmission control register */
+#define UART_TI752_TLR	7	/* I/O: trigger level register */
 
 /*
- * These are the definitions for the Modem Control Register
+ * LCR=0xBF, XR16C85x
  */
-#define UART_MCR_AFE	0x20	/* Enable auto-RTS/CTS (TI16C750) */
-#define UART_MCR_LOOP	0x10	/* Enable loopback test mode */
-#define UART_MCR_OUT2	0x08	/* Out2 complement */
-#define UART_MCR_OUT1	0x04	/* Out1 complement */
-#define UART_MCR_RTS	0x02	/* RTS complement */
-#define UART_MCR_DTR	0x01	/* DTR complement */
+#define UART_TRG	0	/* FCTR bit 7 selects Rx or Tx
+				 * In: Fifo count
+				 * Out: Fifo custom trigger levels */
+/*
+ * These are the definitions for the Programmable Trigger Register
+ */
+#define UART_TRG_1		0x01
+#define UART_TRG_4		0x04
+#define UART_TRG_8		0x08
+#define UART_TRG_16		0x10
+#define UART_TRG_32		0x20
+#define UART_TRG_64		0x40
+#define UART_TRG_96		0x60
+#define UART_TRG_120		0x78
+#define UART_TRG_128		0x80
+
+#define UART_FCTR	1	/* Feature Control Register */
+#define UART_FCTR_RTS_NODELAY	0x00  /* RTS flow control delay */
+#define UART_FCTR_RTS_4DELAY	0x01
+#define UART_FCTR_RTS_6DELAY	0x02
+#define UART_FCTR_RTS_8DELAY	0x03
+#define UART_FCTR_IRDA		0x04  /* IrDa data encode select */
+#define UART_FCTR_TX_INT	0x08  /* Tx interrupt type select */
+#define UART_FCTR_TRGA		0x00  /* Tx/Rx 550 trigger table select */
+#define UART_FCTR_TRGB		0x10  /* Tx/Rx 650 trigger table select */
+#define UART_FCTR_TRGC		0x20  /* Tx/Rx 654 trigger table select */
+#define UART_FCTR_TRGD		0x30  /* Tx/Rx 850 programmable trigger select */
+#define UART_FCTR_SCR_SWAP	0x40  /* Scratch pad register swap */
+#define UART_FCTR_RX		0x00  /* Programmable trigger mode select */
+#define UART_FCTR_TX		0x80  /* Programmable trigger mode select */
 
 /*
- * These are the definitions for the Modem Status Register
+ * LCR=0xBF, FCTR[6]=1
  */
-#define UART_MSR_DCD	0x80	/* Data Carrier Detect */
-#define UART_MSR_RI	0x40	/* Ring Indicator */
-#define UART_MSR_DSR	0x20	/* Data Set Ready */
-#define UART_MSR_CTS	0x10	/* Clear to Send */
-#define UART_MSR_DDCD	0x08	/* Delta DCD */
-#define UART_MSR_TERI	0x04	/* Trailing edge ring indicator */
-#define UART_MSR_DDSR	0x02	/* Delta DSR */
-#define UART_MSR_DCTS	0x01	/* Delta CTS */
-#define UART_MSR_ANY_DELTA 0x0F	/* Any of the delta bits! */
+#define UART_EMSR	7	/* Extended Mode Select Register */
+#define UART_EMSR_FIFO_COUNT	0x01  /* Rx/Tx select */
+#define UART_EMSR_ALT_COUNT	0x02  /* Alternating count select */
 
 /*
  * The Intel XScale on-chip UARTs define these bits
@@ -156,17 +218,8 @@
 #define UART_FCR_PXAR16	0x80	/* receive FIFO treshold = 16 */
 #define UART_FCR_PXAR32	0xc0	/* receive FIFO treshold = 32 */
 
-/*
- * These are the definitions for the Extended Features Register
- * (StarTech 16C660 only, when DLAB=1)
- */
-#define UART_EFR_CTS	0x80	/* CTS flow control */
-#define UART_EFR_RTS	0x40	/* RTS flow control */
-#define UART_EFR_SCD	0x20	/* Special character detect */
-#define UART_EFR_ECB	0x10	/* Enhanced control bit */
-/*
- * the low four bits control software flow control
- */
+
+
 
 /*
  * These register definitions are for the 16C950
@@ -203,47 +256,7 @@
 #define UART_ACR_ICRRD	0x40	/* ICR Read enable */
 #define UART_ACR_ASREN	0x80	/* Additional status enable */
 
-/*
- * These are the definitions for the Feature Control Register
- * (XR16C85x only, when LCR=bf; doubles with the Interrupt Enable
- * Register, UART register #1)
- */
-#define UART_FCTR_RTS_NODELAY	0x00  /* RTS flow control delay */
-#define UART_FCTR_RTS_4DELAY	0x01
-#define UART_FCTR_RTS_6DELAY	0x02
-#define UART_FCTR_RTS_8DELAY	0x03
-#define UART_FCTR_IRDA	0x04  /* IrDa data encode select */
-#define UART_FCTR_TX_INT	0x08  /* Tx interrupt type select */
-#define UART_FCTR_TRGA	0x00  /* Tx/Rx 550 trigger table select */
-#define UART_FCTR_TRGB	0x10  /* Tx/Rx 650 trigger table select */
-#define UART_FCTR_TRGC	0x20  /* Tx/Rx 654 trigger table select */
-#define UART_FCTR_TRGD	0x30  /* Tx/Rx 850 programmable trigger select */
-#define UART_FCTR_SCR_SWAP	0x40  /* Scratch pad register swap */
-#define UART_FCTR_RX	0x00  /* Programmable trigger mode select */
-#define UART_FCTR_TX	0x80  /* Programmable trigger mode select */
-
-/*
- * These are the definitions for the Enhanced Mode Select Register
- * (XR16C85x only, when LCR=bf and FCTR bit 6=1; doubles with the
- * Scratch register, UART register #7)
- */
-#define UART_EMSR_FIFO_COUNT	0x01  /* Rx/Tx select */
-#define UART_EMSR_ALT_COUNT	0x02  /* Alternating count select */
 
-/*
- * These are the definitions for the Programmable Trigger
- * Register (XR16C85x only, when LCR=bf; doubles with the UART RX/TX
- * register, UART register #0)
- */
-#define UART_TRG_1	0x01
-#define UART_TRG_4	0x04
-#define UART_TRG_8	0x08
-#define UART_TRG_16	0x10
-#define UART_TRG_32	0x20
-#define UART_TRG_64	0x40
-#define UART_TRG_96	0x60
-#define UART_TRG_120	0x78
-#define UART_TRG_128	0x80
 
 /*
  * These definitions are for the RSA-DV II/S card, from
diff -Nru a/include/linux/slab.h b/include/linux/slab.h
--- a/include/linux/slab.h	2004-12-24 13:37:31 -08:00
+++ b/include/linux/slab.h	2004-12-24 13:37:31 -08:00
@@ -13,6 +13,7 @@
 
 #include	<linux/config.h>	/* kmalloc_sizes.h needs CONFIG_ options */
 #include	<linux/gfp.h>
+#include	<linux/init.h>
 #include	<linux/types.h>
 #include	<asm/page.h>		/* kmalloc_sizes.h needs PAGE_SIZE */
 #include	<asm/cache.h>		/* kmalloc_sizes.h needs L1_CACHE_BYTES */
@@ -53,7 +54,7 @@
 #define	SLAB_CTOR_VERIFY	0x004UL		/* tell constructor it's a verify call */
 
 /* prototypes */
-extern void kmem_cache_init(void);
+extern void __init kmem_cache_init(void);
 
 extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long,
 				       void (*)(void *, kmem_cache_t *, unsigned long),
@@ -61,7 +62,14 @@
 extern int kmem_cache_destroy(kmem_cache_t *);
 extern int kmem_cache_shrink(kmem_cache_t *);
 extern void *kmem_cache_alloc(kmem_cache_t *, int);
+#ifdef CONFIG_NUMA
 extern void *kmem_cache_alloc_node(kmem_cache_t *, int);
+#else
+static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int node)
+{
+	return kmem_cache_alloc(cachep, GFP_KERNEL);
+}
+#endif
 extern void kmem_cache_free(kmem_cache_t *, void *);
 extern unsigned int kmem_cache_size(kmem_cache_t *);
 
diff -Nru a/include/linux/smb_fs.h b/include/linux/smb_fs.h
--- a/include/linux/smb_fs.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/smb_fs.h	2004-12-24 13:37:01 -08:00
@@ -12,7 +12,6 @@
 #include <linux/smb.h>
 #include <linux/smb_fs_i.h>
 #include <linux/smb_fs_sb.h>
-#include <linux/fs.h>
 
 /*
  * ioctl commands
@@ -26,6 +25,7 @@
 
 #ifdef __KERNEL__
 
+#include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/vmalloc.h>
 #include <linux/smb_mount.h>
diff -Nru a/include/linux/smb_mount.h b/include/linux/smb_mount.h
--- a/include/linux/smb_mount.h	2004-12-24 13:36:16 -08:00
+++ b/include/linux/smb_mount.h	2004-12-24 13:36:16 -08:00
@@ -38,7 +38,10 @@
 #define SMB_MOUNT_DIRATTR	0x0004	/* Use find_first for getattr */
 #define SMB_MOUNT_CASE		0x0008	/* Be case sensitive */
 #define SMB_MOUNT_UNICODE	0x0010	/* Server talks unicode */
-
+#define SMB_MOUNT_UID		0x0020  /* Use user specified uid */
+#define SMB_MOUNT_GID		0x0040  /* Use user specified gid */
+#define SMB_MOUNT_FMODE		0x0080  /* Use user specified file mode */
+#define SMB_MOUNT_DMODE		0x0100  /* Use user specified dir mode */
 
 struct smb_mount_data_kernel {
 	int version;
diff -Nru a/include/linux/smp_lock.h b/include/linux/smp_lock.h
--- a/include/linux/smp_lock.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/smp_lock.h	2004-12-24 13:37:18 -08:00
@@ -5,62 +5,50 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
-
-extern spinlock_t kernel_flag;
+#ifdef CONFIG_LOCK_KERNEL
 
 #define kernel_locked()		(current->lock_depth >= 0)
 
-#define get_kernel_lock()	spin_lock(&kernel_flag)
-#define put_kernel_lock()	spin_unlock(&kernel_flag)
+extern int __lockfunc get_kernel_lock(void);
+extern void __lockfunc put_kernel_lock(void);
 
 /*
- * Release global kernel lock.
+ * Release/re-acquire global kernel lock for the scheduler
  */
-static inline void release_kernel_lock(struct task_struct *task)
-{
-	if (unlikely(task->lock_depth >= 0))
-		put_kernel_lock();
-}
+#define release_kernel_lock(tsk) do { 		\
+	if (unlikely((tsk)->lock_depth >= 0))	\
+		put_kernel_lock();		\
+} while (0)
 
 /*
- * Re-acquire the kernel lock
+ * Non-SMP kernels will never block on the kernel lock,
+ * so we are better off returning a constant zero from
+ * reacquire_kernel_lock() so that the compiler can see
+ * it at compile-time.
  */
-static inline void reacquire_kernel_lock(struct task_struct *task)
-{
-	if (unlikely(task->lock_depth >= 0))
-		get_kernel_lock();
-}
+#ifdef CONFIG_SMP
+#define return_value_on_smp return
+#else
+#define return_value_on_smp
+#endif
 
-/*
- * Getting the big kernel lock.
- *
- * This cannot happen asynchronously,
- * so we only need to worry about other
- * CPU's.
- */
-static inline void lock_kernel(void)
+static inline int reacquire_kernel_lock(struct task_struct *task)
 {
-	int depth = current->lock_depth+1;
-	if (likely(!depth))
-		get_kernel_lock();
-	current->lock_depth = depth;
+	if (unlikely(task->lock_depth >= 0))
+		return_value_on_smp get_kernel_lock();
+	return 0;
 }
 
-static inline void unlock_kernel(void)
-{
-	BUG_ON(current->lock_depth < 0);
-	if (likely(--current->lock_depth < 0))
-		put_kernel_lock();
-}
+extern void __lockfunc lock_kernel(void)	__acquires(kernel_lock);
+extern void __lockfunc unlock_kernel(void)	__releases(kernel_lock);
 
 #else
 
 #define lock_kernel()				do { } while(0)
 #define unlock_kernel()				do { } while(0)
 #define release_kernel_lock(task)		do { } while(0)
-#define reacquire_kernel_lock(task)		do { } while(0)
+#define reacquire_kernel_lock(task)		0
 #define kernel_locked()				1
 
-#endif /* CONFIG_SMP || CONFIG_PREEMPT */
+#endif /* CONFIG_LOCK_KERNEL */
 #endif /* __LINUX_SMPLOCK_H */
diff -Nru a/include/linux/socket.h b/include/linux/socket.h
--- a/include/linux/socket.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/socket.h	2004-12-24 13:37:18 -08:00
@@ -90,6 +90,10 @@
 				  (struct cmsghdr *)(ctl) : \
 				  (struct cmsghdr *)NULL)
 #define CMSG_FIRSTHDR(msg)	__CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && \
+			     (cmsg)->cmsg_len <= (unsigned long) \
+			     ((mhdr)->msg_controllen - \
+			      ((char *)(cmsg) - (char *)(mhdr)->msg_control)))
 
 /*
  *	This mess will go away with glibc
diff -Nru a/include/linux/sonypi.h b/include/linux/sonypi.h
--- a/include/linux/sonypi.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/sonypi.h	2004-12-24 13:36:47 -08:00
@@ -1,7 +1,7 @@
-/* 
+/*
  * Sony Programmable I/O Control Device driver for VAIO
  *
- * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
+ * Copyright (C) 2001-2004 Stelian Pop <stelian@popies.net>
  *
  * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
  *
@@ -14,24 +14,24 @@
  * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
  *
  * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
- * 
+ *
  * 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.
  *
  */
 
-#ifndef _SONYPI_H_ 
+#ifndef _SONYPI_H_
 #define _SONYPI_H_
 
 #include <linux/types.h>
@@ -96,6 +96,7 @@
 #define SONYPI_EVENT_ANYBUTTON_RELEASED		56
 #define SONYPI_EVENT_BATTERY_INSERT		57
 #define SONYPI_EVENT_BATTERY_REMOVE		58
+#define SONYPI_EVENT_FNKEY_RELEASED		59
 
 /* get/set brightness */
 #define SONYPI_IOCGBRT		_IOR('v', 0, __u8)
@@ -121,28 +122,28 @@
 
 /* used only for communication between v4l and sonypi */
 
-#define SONYPI_COMMAND_GETCAMERA		 1
+#define SONYPI_COMMAND_GETCAMERA		 1	/* obsolete */
 #define SONYPI_COMMAND_SETCAMERA		 2
-#define SONYPI_COMMAND_GETCAMERABRIGHTNESS	 3
+#define SONYPI_COMMAND_GETCAMERABRIGHTNESS	 3	/* obsolete */
 #define SONYPI_COMMAND_SETCAMERABRIGHTNESS	 4
-#define SONYPI_COMMAND_GETCAMERACONTRAST	 5
+#define SONYPI_COMMAND_GETCAMERACONTRAST	 5	/* obsolete */
 #define SONYPI_COMMAND_SETCAMERACONTRAST	 6
-#define SONYPI_COMMAND_GETCAMERAHUE		 7
+#define SONYPI_COMMAND_GETCAMERAHUE		 7	/* obsolete */
 #define SONYPI_COMMAND_SETCAMERAHUE		 8
-#define SONYPI_COMMAND_GETCAMERACOLOR		 9
+#define SONYPI_COMMAND_GETCAMERACOLOR		 9	/* obsolete */
 #define SONYPI_COMMAND_SETCAMERACOLOR		10
-#define SONYPI_COMMAND_GETCAMERASHARPNESS	11
+#define SONYPI_COMMAND_GETCAMERASHARPNESS	11	/* obsolete */
 #define SONYPI_COMMAND_SETCAMERASHARPNESS	12
-#define SONYPI_COMMAND_GETCAMERAPICTURE		13
+#define SONYPI_COMMAND_GETCAMERAPICTURE		13	/* obsolete */
 #define SONYPI_COMMAND_SETCAMERAPICTURE		14
-#define SONYPI_COMMAND_GETCAMERAAGC		15
+#define SONYPI_COMMAND_GETCAMERAAGC		15	/* obsolete */
 #define SONYPI_COMMAND_SETCAMERAAGC		16
-#define SONYPI_COMMAND_GETCAMERADIRECTION	17
-#define SONYPI_COMMAND_GETCAMERAROMVERSION	18
-#define SONYPI_COMMAND_GETCAMERAREVISION	19
+#define SONYPI_COMMAND_GETCAMERADIRECTION	17	/* obsolete */
+#define SONYPI_COMMAND_GETCAMERAROMVERSION	18	/* obsolete */
+#define SONYPI_COMMAND_GETCAMERAREVISION	19	/* obsolete */
 
-u8 sonypi_camera_command(int command, u8 value);
+int sonypi_camera_command(int command, u8 value);
 
-#endif /* __KERNEL__ */
+#endif				/* __KERNEL__ */
 
-#endif /* _SONYPI_H_ */
+#endif				/* _SONYPI_H_ */
diff -Nru a/include/linux/spinlock.h b/include/linux/spinlock.h
--- a/include/linux/spinlock.h	2004-12-24 13:36:49 -08:00
+++ b/include/linux/spinlock.h	2004-12-24 13:36:49 -08:00
@@ -27,54 +27,60 @@
         extra                                   \
         ".ifndef " LOCK_SECTION_NAME "\n\t"     \
         LOCK_SECTION_NAME ":\n\t"               \
-        ".endif\n\t"
+        ".endif\n"
 
 #define LOCK_SECTION_END                        \
         ".previous\n\t"
 
+#define __lockfunc fastcall __attribute__((section(".spinlock.text")))
+
 /*
  * If CONFIG_SMP is set, pull in the _raw_* definitions
  */
 #ifdef CONFIG_SMP
 #include <asm/spinlock.h>
 
-#define __lockfunc fastcall __attribute__((section(".spinlock.text")))
-
 int __lockfunc _spin_trylock(spinlock_t *lock);
 int __lockfunc _write_trylock(rwlock_t *lock);
-void __lockfunc _spin_lock(spinlock_t *lock);
-void __lockfunc _write_lock(rwlock_t *lock);
-void __lockfunc _spin_lock(spinlock_t *lock);
-void __lockfunc _read_lock(rwlock_t *lock);
-void __lockfunc _spin_unlock(spinlock_t *lock);
-void __lockfunc _write_unlock(rwlock_t *lock);
-void __lockfunc _read_unlock(rwlock_t *lock);
-unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock);
-unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock);
-unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock);
-void __lockfunc _spin_lock_irq(spinlock_t *lock);
-void __lockfunc _spin_lock_bh(spinlock_t *lock);
-void __lockfunc _read_lock_irq(rwlock_t *lock);
-void __lockfunc _read_lock_bh(rwlock_t *lock);
-void __lockfunc _write_lock_irq(rwlock_t *lock);
-void __lockfunc _write_lock_bh(rwlock_t *lock);
-void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags);
-void __lockfunc _spin_unlock_irq(spinlock_t *lock);
-void __lockfunc _spin_unlock_bh(spinlock_t *lock);
-void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags);
-void __lockfunc _read_unlock_irq(rwlock_t *lock);
-void __lockfunc _read_unlock_bh(rwlock_t *lock);
-void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags);
-void __lockfunc _write_unlock_irq(rwlock_t *lock);
-void __lockfunc _write_unlock_bh(rwlock_t *lock);
+
+void __lockfunc _spin_lock(spinlock_t *lock)	__acquires(spinlock_t);
+void __lockfunc _read_lock(rwlock_t *lock)	__acquires(rwlock_t);
+void __lockfunc _write_lock(rwlock_t *lock)	__acquires(rwlock_t);
+
+void __lockfunc _spin_unlock(spinlock_t *lock)	__releases(spinlock_t);
+void __lockfunc _read_unlock(rwlock_t *lock)	__releases(rwlock_t);
+void __lockfunc _write_unlock(rwlock_t *lock)	__releases(rwlock_t);
+
+unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock)	__acquires(spinlock_t);
+unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock)	__acquires(rwlock_t);
+unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock)	__acquires(rwlock_t);
+
+void __lockfunc _spin_lock_irq(spinlock_t *lock)	__acquires(spinlock_t);
+void __lockfunc _spin_lock_bh(spinlock_t *lock)		__acquires(spinlock_t);
+void __lockfunc _read_lock_irq(rwlock_t *lock)		__acquires(rwlock_t);
+void __lockfunc _read_lock_bh(rwlock_t *lock)		__acquires(rwlock_t);
+void __lockfunc _write_lock_irq(rwlock_t *lock)		__acquires(rwlock_t);
+void __lockfunc _write_lock_bh(rwlock_t *lock)		__acquires(rwlock_t);
+
+void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)	__releases(spinlock_t);
+void __lockfunc _spin_unlock_irq(spinlock_t *lock)				__releases(spinlock_t);
+void __lockfunc _spin_unlock_bh(spinlock_t *lock)				__releases(spinlock_t);
+void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)	__releases(rwlock_t);
+void __lockfunc _read_unlock_irq(rwlock_t *lock)				__releases(rwlock_t);
+void __lockfunc _read_unlock_bh(rwlock_t *lock)					__releases(rwlock_t);
+void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)	__releases(rwlock_t);
+void __lockfunc _write_unlock_irq(rwlock_t *lock)				__releases(rwlock_t);
+void __lockfunc _write_unlock_bh(rwlock_t *lock)				__releases(rwlock_t);
+
 int __lockfunc _spin_trylock_bh(spinlock_t *lock);
 int in_lock_functions(unsigned long addr);
+
 #else
 
 #define in_lock_functions(ADDR) 0
 
 #if !defined(CONFIG_PREEMPT) && !defined(CONFIG_DEBUG_SPINLOCK)
-# define atomic_dec_and_lock(atomic,lock) atomic_dec_and_test(atomic)
+# define _atomic_dec_and_lock(atomic,lock) atomic_dec_and_test(atomic)
 # define ATOMIC_DEC_AND_LOCK
 #endif
 
@@ -229,36 +235,42 @@
 do { \
 	preempt_disable(); \
 	_raw_spin_lock(lock); \
+	__acquire(lock); \
 } while(0)
 
 #define _write_lock(lock) \
 do { \
 	preempt_disable(); \
 	_raw_write_lock(lock); \
+	__acquire(lock); \
 } while(0)
  
 #define _read_lock(lock)	\
 do { \
 	preempt_disable(); \
 	_raw_read_lock(lock); \
+	__acquire(lock); \
 } while(0)
 
 #define _spin_unlock(lock) \
 do { \
 	_raw_spin_unlock(lock); \
 	preempt_enable(); \
+	__release(lock); \
 } while (0)
 
 #define _write_unlock(lock) \
 do { \
 	_raw_write_unlock(lock); \
 	preempt_enable(); \
+	__release(lock); \
 } while(0)
 
 #define _read_unlock(lock) \
 do { \
 	_raw_read_unlock(lock); \
 	preempt_enable(); \
+	__release(lock); \
 } while(0)
 
 #define _spin_lock_irqsave(lock, flags) \
@@ -266,6 +278,7 @@
 	local_irq_save(flags); \
 	preempt_disable(); \
 	_raw_spin_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _spin_lock_irq(lock) \
@@ -273,6 +286,7 @@
 	local_irq_disable(); \
 	preempt_disable(); \
 	_raw_spin_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _spin_lock_bh(lock) \
@@ -280,6 +294,7 @@
 	local_bh_disable(); \
 	preempt_disable(); \
 	_raw_spin_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _read_lock_irqsave(lock, flags) \
@@ -287,6 +302,7 @@
 	local_irq_save(flags); \
 	preempt_disable(); \
 	_raw_read_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _read_lock_irq(lock) \
@@ -294,6 +310,7 @@
 	local_irq_disable(); \
 	preempt_disable(); \
 	_raw_read_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _read_lock_bh(lock) \
@@ -301,6 +318,7 @@
 	local_bh_disable(); \
 	preempt_disable(); \
 	_raw_read_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _write_lock_irqsave(lock, flags) \
@@ -308,6 +326,7 @@
 	local_irq_save(flags); \
 	preempt_disable(); \
 	_raw_write_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _write_lock_irq(lock) \
@@ -315,6 +334,7 @@
 	local_irq_disable(); \
 	preempt_disable(); \
 	_raw_write_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _write_lock_bh(lock) \
@@ -322,6 +342,7 @@
 	local_bh_disable(); \
 	preempt_disable(); \
 	_raw_write_lock(lock); \
+	__acquire(lock); \
 } while (0)
 
 #define _spin_unlock_irqrestore(lock, flags) \
@@ -329,12 +350,7 @@
 	_raw_spin_unlock(lock); \
 	local_irq_restore(flags); \
 	preempt_enable(); \
-} while (0)
-
-#define _raw_spin_unlock_irqrestore(lock, flags) \
-do { \
-	_raw_spin_unlock(lock); \
-	local_irq_restore(flags); \
+	__release(lock); \
 } while (0)
 
 #define _spin_unlock_irq(lock) \
@@ -342,6 +358,7 @@
 	_raw_spin_unlock(lock); \
 	local_irq_enable(); \
 	preempt_enable(); \
+	__release(lock); \
 } while (0)
 
 #define _spin_unlock_bh(lock) \
@@ -349,6 +366,7 @@
 	_raw_spin_unlock(lock); \
 	preempt_enable(); \
 	local_bh_enable(); \
+	__release(lock); \
 } while (0)
 
 #define _write_unlock_bh(lock) \
@@ -356,6 +374,7 @@
 	_raw_write_unlock(lock); \
 	preempt_enable(); \
 	local_bh_enable(); \
+	__release(lock); \
 } while (0)
 
 #define _read_unlock_irqrestore(lock, flags) \
@@ -363,6 +382,7 @@
 	_raw_read_unlock(lock); \
 	local_irq_restore(flags); \
 	preempt_enable(); \
+	__release(lock); \
 } while (0)
 
 #define _write_unlock_irqrestore(lock, flags) \
@@ -370,6 +390,7 @@
 	_raw_write_unlock(lock); \
 	local_irq_restore(flags); \
 	preempt_enable(); \
+	__release(lock); \
 } while (0)
 
 #define _read_unlock_irq(lock)	\
@@ -377,6 +398,7 @@
 	_raw_read_unlock(lock);	\
 	local_irq_enable();	\
 	preempt_enable();	\
+	__release(lock); \
 } while (0)
 
 #define _read_unlock_bh(lock)	\
@@ -384,6 +406,7 @@
 	_raw_read_unlock(lock);	\
 	local_bh_enable();	\
 	preempt_enable();	\
+	__release(lock); \
 } while (0)
 
 #define _write_unlock_irq(lock)	\
@@ -391,6 +414,7 @@
 	_raw_write_unlock(lock);	\
 	local_irq_enable();	\
 	preempt_enable();	\
+	__release(lock); \
 } while (0)
 
 #endif /* !SMP */
@@ -400,8 +424,8 @@
  * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various
  * methods are defined as nops in the case they are not required.
  */
-#define spin_trylock(lock)	_spin_trylock(lock)
-#define write_trylock(lock)	_write_trylock(lock)
+#define spin_trylock(lock)	__cond_lock(_spin_trylock(lock))
+#define write_trylock(lock)	__cond_lock(_write_trylock(lock))
 
 /* Where's read_trylock? */
 
@@ -442,7 +466,7 @@
 #define write_unlock_irq(lock)			_write_unlock_irq(lock)
 #define write_unlock_bh(lock)			_write_unlock_bh(lock)
 
-#define spin_trylock_bh(lock)			_spin_trylock_bh(lock)
+#define spin_trylock_bh(lock)			__cond_lock(_spin_trylock_bh(lock))
 
 #ifdef CONFIG_LOCKMETER
 extern void _metered_spin_lock   (spinlock_t *lock);
@@ -458,9 +482,11 @@
 /* "lock on reference count zero" */
 #ifndef ATOMIC_DEC_AND_LOCK
 #include <asm/atomic.h>
-extern int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
+extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
 #endif
 
+#define atomic_dec_and_lock(atomic,lock) __cond_lock(_atomic_dec_and_lock(atomic,lock))
+
 /*
  *  bit-based spin_lock()
  *
@@ -483,6 +509,7 @@
 			cpu_relax();
 	}
 #endif
+	__acquire(bitlock);
 }
 
 /*
@@ -490,18 +517,15 @@
  */
 static inline int bit_spin_trylock(int bitnum, unsigned long *addr)
 {
+	preempt_disable();	
 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
-	int ret;
-
-	preempt_disable();
-	ret = !test_and_set_bit(bitnum, addr);
-	if (!ret)
+	if (test_and_set_bit(bitnum, addr)) {
 		preempt_enable();
-	return ret;
-#else
-	preempt_disable();
-	return 1;
+		return 0;
+	}
 #endif
+	__acquire(bitlock);
+	return 1;
 }
 
 /*
@@ -515,6 +539,7 @@
 	clear_bit(bitnum, addr);
 #endif
 	preempt_enable();
+	__release(bitlock);
 }
 
 /*
diff -Nru a/include/linux/swap.h b/include/linux/swap.h
--- a/include/linux/swap.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/swap.h	2004-12-24 13:36:17 -08:00
@@ -230,6 +230,7 @@
 
 /* linux/mm/thrash.c */
 extern struct mm_struct * swap_token_mm;
+extern unsigned long swap_token_default_timeout;
 extern void grab_swap_token(void);
 extern void __put_swap_token(struct mm_struct *);
 
@@ -268,6 +269,7 @@
 #define move_from_swap_cache(p, i, m)		1
 #define __delete_from_swap_cache(p)		/*NOTHING*/
 #define delete_from_swap_cache(p)		/*NOTHING*/
+#define swap_token_default_timeout		0
 
 static inline int remove_exclusive_swap_page(struct page *p)
 {
diff -Nru a/include/linux/swapops.h b/include/linux/swapops.h
--- a/include/linux/swapops.h	2004-12-24 13:36:16 -08:00
+++ b/include/linux/swapops.h	2004-12-24 13:36:16 -08:00
@@ -30,8 +30,7 @@
  */
 static inline unsigned swp_type(swp_entry_t entry)
 {
-	return (entry.val >> SWP_TYPE_SHIFT(entry)) &
-			((1 << MAX_SWAPFILES_SHIFT) - 1);
+	return (entry.val >> SWP_TYPE_SHIFT(entry));
 }
 
 /*
diff -Nru a/include/linux/syscalls.h b/include/linux/syscalls.h
--- a/include/linux/syscalls.h	2004-12-24 13:37:33 -08:00
+++ b/include/linux/syscalls.h	2004-12-24 13:37:33 -08:00
@@ -61,6 +61,7 @@
 #include <asm/siginfo.h>
 #include <asm/signal.h>
 #include <linux/quota.h>
+#include <linux/key.h>
 
 asmlinkage long sys_time(int __user *tloc);
 asmlinkage long sys_stime(time_t __user *tptr);
@@ -490,5 +491,19 @@
 asmlinkage long sys_syslog(int type, char __user *buf, int len);
 asmlinkage long sys_uselib(const char __user *library);
 asmlinkage long sys_ni_syscall(void);
+
+asmlinkage long sys_add_key(const char __user *_type,
+			    const char __user *_description,
+			    const void __user *_payload,
+			    size_t plen,
+			    key_serial_t destringid);
+
+asmlinkage long sys_request_key(const char __user *_type,
+				const char __user *_description,
+				const char __user *_callout_info,
+				key_serial_t destringid);
+
+asmlinkage long sys_keyctl(int cmd, unsigned long arg2, unsigned long arg3,
+			   unsigned long arg4, unsigned long arg5);
 
 #endif
diff -Nru a/include/linux/sysctl.h b/include/linux/sysctl.h
--- a/include/linux/sysctl.h	2004-12-24 13:36:56 -08:00
+++ b/include/linux/sysctl.h	2004-12-24 13:36:56 -08:00
@@ -167,6 +167,7 @@
 	VM_HUGETLB_GROUP=25,	/* permitted hugetlb group */
 	VM_VFS_CACHE_PRESSURE=26, /* dcache/icache reclaim pressure */
 	VM_LEGACY_VA_LAYOUT=27, /* legacy/compatibility virtual address space layout */
+	VM_SWAP_TOKEN_TIMEOUT=28, /* default time for token time out */
 };
 
 
diff -Nru a/include/linux/sysfs.h b/include/linux/sysfs.h
--- a/include/linux/sysfs.h	2004-12-24 13:36:47 -08:00
+++ b/include/linux/sysfs.h	2004-12-24 13:36:47 -08:00
@@ -9,6 +9,8 @@
 #ifndef _SYSFS_H_
 #define _SYSFS_H_
 
+#include <asm/atomic.h>
+
 struct kobject;
 struct module;
 
@@ -56,6 +58,23 @@
 	ssize_t	(*show)(struct kobject *, struct attribute *,char *);
 	ssize_t	(*store)(struct kobject *,struct attribute *,const char *, size_t);
 };
+
+struct sysfs_dirent {
+	atomic_t		s_count;
+	struct list_head	s_sibling;
+	struct list_head	s_children;
+	void 			* s_element;
+	int			s_type;
+	umode_t			s_mode;
+	struct dentry		* s_dentry;
+};
+
+#define SYSFS_ROOT		0x0001
+#define SYSFS_DIR		0x0002
+#define SYSFS_KOBJ_ATTR 	0x0004
+#define SYSFS_KOBJ_BIN_ATTR	0x0008
+#define SYSFS_KOBJ_LINK 	0x0020
+#define SYSFS_NOT_PINNED	(SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR | SYSFS_KOBJ_LINK)
 
 #ifdef CONFIG_SYSFS
 
diff -Nru a/include/linux/sysrq.h b/include/linux/sysrq.h
--- a/include/linux/sysrq.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/sysrq.h	2004-12-24 13:36:17 -08:00
@@ -31,49 +31,9 @@
 
 void handle_sysrq(int, struct pt_regs *, struct tty_struct *);
 void __handle_sysrq(int, struct pt_regs *, struct tty_struct *);
-
-/*
- * Sysrq registration manipulation functions
- */
-
-void __sysrq_lock_table (void);
-void __sysrq_unlock_table (void);
-struct sysrq_key_op *__sysrq_get_key_op (int key);
-void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p);
-
-extern __inline__ int
-__sysrq_swap_key_ops_nolock(int key, struct sysrq_key_op *insert_op_p,
-				struct sysrq_key_op *remove_op_p)
-{
-	int retval;
-	if (__sysrq_get_key_op(key) == remove_op_p) {
-		__sysrq_put_key_op(key, insert_op_p);
-		retval = 0;
-	} else {
-                retval = -1;
-	}
-	return retval;
-}
-
-extern __inline__ int
-__sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
-				struct sysrq_key_op *remove_op_p) {
-	int retval;
-	__sysrq_lock_table();
-	retval = __sysrq_swap_key_ops_nolock(key, insert_op_p, remove_op_p);
-	__sysrq_unlock_table();
-	return retval;
-}
-	
-static inline int register_sysrq_key(int key, struct sysrq_key_op *op_p)
-{
-	return __sysrq_swap_key_ops(key, op_p, NULL);
-}
-
-static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
-{
-	return __sysrq_swap_key_ops(key, NULL, op_p);
-}
+int register_sysrq_key(int, struct sysrq_key_op *);
+int unregister_sysrq_key(int, struct sysrq_key_op *);
+struct sysrq_key_op *__sysrq_get_key_op(int key);
 
 #else
 
diff -Nru a/include/linux/tc_act/tc_ipt.h b/include/linux/tc_act/tc_ipt.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/tc_act/tc_ipt.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,21 @@
+#ifndef __LINUX_TC_IPT_H
+#define __LINUX_TC_IPT_H
+
+#include <linux/pkt_cls.h>
+
+#define TCA_ACT_IPT 6
+
+enum
+{
+	TCA_IPT_UNSPEC,
+	TCA_IPT_TABLE,
+	TCA_IPT_HOOK,
+	TCA_IPT_INDEX,
+	TCA_IPT_CNT,
+	TCA_IPT_TM,
+	TCA_IPT_TARG,
+	__TCA_IPT_MAX
+};
+#define TCA_IPT_MAX (__TCA_IPT_MAX - 1)
+                                                                                
+#endif
diff -Nru a/include/linux/tc_act/tc_mirred.h b/include/linux/tc_act/tc_mirred.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/tc_act/tc_mirred.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,28 @@
+#ifndef __LINUX_TC_MIR_H
+#define __LINUX_TC_MIR_H
+
+#include <linux/pkt_cls.h>
+
+#define TCA_ACT_MIRRED 8
+#define TCA_EGRESS_REDIR 1  /* packet redirect to EGRESS*/
+#define TCA_EGRESS_MIRROR 2 /* mirror packet to EGRESS */
+#define TCA_INGRESS_REDIR 3  /* packet redirect to INGRESS*/
+#define TCA_INGRESS_MIRROR 4 /* mirror packet to INGRESS */
+                                                                                
+struct tc_mirred
+{
+	tc_gen;
+	int                     eaction;   /* one of IN/EGRESS_MIRROR/REDIR */
+	__u32                   ifindex;  /* ifindex of egress port */
+};
+                                                                                
+enum
+{
+	TCA_MIRRED_UNSPEC,
+	TCA_MIRRED_TM,
+	TCA_MIRRED_PARMS,
+	__TCA_MIRRED_MAX
+};
+#define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1)
+                                                                                
+#endif
diff -Nru a/include/linux/tc_act/tc_pedit.h b/include/linux/tc_act/tc_pedit.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/tc_act/tc_pedit.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,36 @@
+#ifndef __LINUX_TC_PED_H
+#define __LINUX_TC_PED_H
+
+#include <linux/pkt_cls.h>
+
+#define TCA_ACT_PEDIT 7
+
+enum
+{
+	TCA_PEDIT_UNSPEC,
+	TCA_PEDIT_TM,
+	TCA_PEDIT_PARMS,
+	__TCA_PEDIT_MAX
+};
+#define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1)
+                                                                                
+struct tc_pedit_key
+{
+	__u32           mask;  /* AND */
+	__u32           val;   /*XOR */
+	__u32           off;  /*offset */
+	__u32           at;
+	__u32           offmask;
+	__u32           shift;
+};
+                                                                                
+struct tc_pedit_sel
+{
+	tc_gen;
+	unsigned char           nkeys;
+	unsigned char           flags;
+	struct tc_pedit_key     keys[0];
+};
+#define tc_pedit tc_pedit_sel
+
+#endif
diff -Nru a/include/linux/tcp.h b/include/linux/tcp.h
--- a/include/linux/tcp.h	2004-12-24 13:36:49 -08:00
+++ b/include/linux/tcp.h	2004-12-24 13:36:49 -08:00
@@ -186,6 +186,8 @@
 
 	__u32	tcpi_rcv_rtt;
 	__u32	tcpi_rcv_space;
+
+	__u32	tcpi_total_retrans;
 };
 
 #ifdef __KERNEL__
@@ -363,6 +365,8 @@
 	__u8	pending;	/* Scheduled timer event	*/
 	__u8	urg_mode;	/* In urgent mode		*/
 	__u32	snd_up;		/* Urgent pointer		*/
+
+	__u32	total_retrans;	/* Total retransmits for entire connection */
 
 	/* The syn_wait_lock is necessary only to avoid proc interface having
 	 * to grab the main lock sock while browsing the listening hash
diff -Nru a/include/linux/threads.h b/include/linux/threads.h
--- a/include/linux/threads.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/threads.h	2004-12-24 13:36:17 -08:00
@@ -30,6 +30,6 @@
 /*
  * A maximum of 4 million PIDs should be enough for a while:
  */
-#define PID_MAX_LIMIT (4*1024*1024)
+#define PID_MAX_LIMIT (sizeof(long) > 4 ? 4*1024*1024 : PID_MAX_DEFAULT)
 
 #endif
diff -Nru a/include/linux/ticable.h b/include/linux/ticable.h
--- a/include/linux/ticable.h	2004-12-24 13:37:18 -08:00
+++ b/include/linux/ticable.h	2004-12-24 13:37:18 -08:00
@@ -38,5 +38,7 @@
 #define IOCTL_TIUSB_TIMEOUT        _IOW('N', 0x20, int) /* set timeout */
 #define IOCTL_TIUSB_RESET_DEVICE   _IOW('N', 0x21, int) /* reset device */
 #define IOCTL_TIUSB_RESET_PIPES    _IOW('N', 0x22, int) /* reset both pipes*/
+#define IOCTL_TIUSB_GET_MAXPS      _IOR('N', 0x23, int) /* max packet size */
+#define IOCTL_TIUSB_GET_DEVID      _IOR('N', 0x24, int) /* get device type */
 
 #endif /* TICABLE_H */
diff -Nru a/include/linux/time.h b/include/linux/time.h
--- a/include/linux/time.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/time.h	2004-12-24 13:37:00 -08:00
@@ -1,9 +1,12 @@
 #ifndef _LINUX_TIME_H
 #define _LINUX_TIME_H
 
-#include <asm/param.h>
 #include <linux/types.h>
 
+#ifdef __KERNEL__
+#include <linux/seqlock.h>
+#endif
+
 #ifndef _STRUCT_TIMESPEC
 #define _STRUCT_TIMESPEC
 struct timespec {
@@ -24,39 +27,6 @@
 
 #ifdef __KERNEL__
 
-#include <linux/spinlock.h>
-#include <linux/seqlock.h>
-#include <linux/timex.h>
-#include <asm/div64.h>
-#ifndef div_long_long_rem
-
-#define div_long_long_rem(dividend,divisor,remainder) ({ \
-		       u64 result = dividend;		\
-		       *remainder = do_div(result,divisor); \
-		       result; })
-
-#endif
-
-/*
- * Have the 32 bit jiffies value wrap 5 minutes after boot
- * so jiffies wrap bugs show up earlier.
- */
-#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
-
-/*
- * Change timeval to jiffies, trying to avoid the
- * most obvious overflows..
- *
- * And some not so obvious.
- *
- * Note that we don't want to return MAX_LONG, because
- * for various timeout reasons we often end up having
- * to wait "jiffies+1" in order to guarantee that we wait
- * at _least_ "jiffies" - so "jiffies+1" had better still
- * be positive.
- */
-#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
-
 /* Parameters used to convert the timespec values */
 #ifndef USEC_PER_SEC
 #define USEC_PER_SEC (1000000L)
@@ -70,232 +40,6 @@
 #define NSEC_PER_USEC (1000L)
 #endif
 
-/*
- * We want to do realistic conversions of time so we need to use the same
- * values the update wall clock code uses as the jiffies size.  This value
- * is: TICK_NSEC (which is defined in timex.h).  This
- * is a constant and is in nanoseconds.  We will used scaled math
- * with a set of scales defined here as SEC_JIFFIE_SC,  USEC_JIFFIE_SC and
- * NSEC_JIFFIE_SC.  Note that these defines contain nothing but
- * constants and so are computed at compile time.  SHIFT_HZ (computed in
- * timex.h) adjusts the scaling for different HZ values.
-
- * Scaled math???  What is that?
- *
- * Scaled math is a way to do integer math on values that would,
- * otherwise, either overflow, underflow, or cause undesired div
- * instructions to appear in the execution path.  In short, we "scale"
- * up the operands so they take more bits (more precision, less
- * underflow), do the desired operation and then "scale" the result back
- * by the same amount.  If we do the scaling by shifting we avoid the
- * costly mpy and the dastardly div instructions.
-
- * Suppose, for example, we want to convert from seconds to jiffies
- * where jiffies is defined in nanoseconds as NSEC_PER_JIFFIE.  The
- * simple math is: jiff = (sec * NSEC_PER_SEC) / NSEC_PER_JIFFIE; We
- * observe that (NSEC_PER_SEC / NSEC_PER_JIFFIE) is a constant which we
- * might calculate at compile time, however, the result will only have
- * about 3-4 bits of precision (less for smaller values of HZ).
- *
- * So, we scale as follows:
- * jiff = (sec) * (NSEC_PER_SEC / NSEC_PER_JIFFIE);
- * jiff = ((sec) * ((NSEC_PER_SEC * SCALE)/ NSEC_PER_JIFFIE)) / SCALE;
- * Then we make SCALE a power of two so:
- * jiff = ((sec) * ((NSEC_PER_SEC << SCALE)/ NSEC_PER_JIFFIE)) >> SCALE;
- * Now we define:
- * #define SEC_CONV = ((NSEC_PER_SEC << SCALE)/ NSEC_PER_JIFFIE))
- * jiff = (sec * SEC_CONV) >> SCALE;
- *
- * Often the math we use will expand beyond 32-bits so we tell C how to
- * do this and pass the 64-bit result of the mpy through the ">> SCALE"
- * which should take the result back to 32-bits.  We want this expansion
- * to capture as much precision as possible.  At the same time we don't
- * want to overflow so we pick the SCALE to avoid this.  In this file,
- * that means using a different scale for each range of HZ values (as
- * defined in timex.h).
- *
- * For those who want to know, gcc will give a 64-bit result from a "*"
- * operator if the result is a long long AND at least one of the
- * operands is cast to long long (usually just prior to the "*" so as
- * not to confuse it into thinking it really has a 64-bit operand,
- * which, buy the way, it can do, but it take more code and at least 2
- * mpys).
-
- * We also need to be aware that one second in nanoseconds is only a
- * couple of bits away from overflowing a 32-bit word, so we MUST use
- * 64-bits to get the full range time in nanoseconds.
-
- */
-
-/*
- * Here are the scales we will use.  One for seconds, nanoseconds and
- * microseconds.
- *
- * Within the limits of cpp we do a rough cut at the SEC_JIFFIE_SC and
- * check if the sign bit is set.  If not, we bump the shift count by 1.
- * (Gets an extra bit of precision where we can use it.)
- * We know it is set for HZ = 1024 and HZ = 100 not for 1000.
- * Haven't tested others.
-
- * Limits of cpp (for #if expressions) only long (no long long), but
- * then we only need the most signicant bit.
- */
-
-#define SEC_JIFFIE_SC (31 - SHIFT_HZ)
-#if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000)
-#undef SEC_JIFFIE_SC
-#define SEC_JIFFIE_SC (32 - SHIFT_HZ)
-#endif
-#define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29)
-#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19)
-#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\
-                                TICK_NSEC -1) / (u64)TICK_NSEC))
-
-#define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\
-                                        TICK_NSEC -1) / (u64)TICK_NSEC))
-#define USEC_CONVERSION  \
-                    ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\
-                                        TICK_NSEC -1) / (u64)TICK_NSEC))
-/*
- * USEC_ROUND is used in the timeval to jiffie conversion.  See there
- * for more details.  It is the scaled resolution rounding value.  Note
- * that it is a 64-bit value.  Since, when it is applied, we are already
- * in jiffies (albit scaled), it is nothing but the bits we will shift
- * off.
- */
-#define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1)
-/*
- * The maximum jiffie value is (MAX_INT >> 1).  Here we translate that
- * into seconds.  The 64-bit case will overflow if we are not careful,
- * so use the messy SH_DIV macro to do it.  Still all constants.
- */
-#if BITS_PER_LONG < 64
-# define MAX_SEC_IN_JIFFIES \
-	(long)((u64)((u64)MAX_JIFFY_OFFSET * TICK_NSEC) / NSEC_PER_SEC)
-#else	/* take care of overflow on 64 bits machines */
-# define MAX_SEC_IN_JIFFIES \
-	(SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 1) - 1)
-
-#endif
-
-/*
- * Convert jiffies to milliseconds and back.
- *
- * Avoid unnecessary multiplications/divisions in the
- * two most common HZ cases:
- */
-static inline unsigned int jiffies_to_msecs(const unsigned long j)
-{
-#if HZ <= 1000 && !(1000 % HZ)
-	return (1000 / HZ) * j;
-#elif HZ > 1000 && !(HZ % 1000)
-	return (j + (HZ / 1000) - 1)/(HZ / 1000);
-#else
-	return (j * 1000) / HZ;
-#endif
-}
-
-static inline unsigned int jiffies_to_usecs(const unsigned long j)
-{
-#if HZ <= 1000 && !(1000 % HZ)
-	return (1000000 / HZ) * j;
-#elif HZ > 1000 && !(HZ % 1000)
-	return (j*1000 + (HZ - 1000))/(HZ / 1000);
-#else
-	return (j * 1000000) / HZ;
-#endif
-}
-
-static inline unsigned long msecs_to_jiffies(const unsigned int m)
-{
-	if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
-		return MAX_JIFFY_OFFSET;
-#if HZ <= 1000 && !(1000 % HZ)
-	return (m + (1000 / HZ) - 1) / (1000 / HZ);
-#elif HZ > 1000 && !(HZ % 1000)
-	return m * (HZ / 1000);
-#else
-	return (m * HZ + 999) / 1000;
-#endif
-}
-
-/*
- * The TICK_NSEC - 1 rounds up the value to the next resolution.  Note
- * that a remainder subtract here would not do the right thing as the
- * resolution values don't fall on second boundries.  I.e. the line:
- * nsec -= nsec % TICK_NSEC; is NOT a correct resolution rounding.
- *
- * Rather, we just shift the bits off the right.
- *
- * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
- * value to a scaled second value.
- */
-static __inline__ unsigned long
-timespec_to_jiffies(const struct timespec *value)
-{
-	unsigned long sec = value->tv_sec;
-	long nsec = value->tv_nsec + TICK_NSEC - 1;
-
-	if (sec >= MAX_SEC_IN_JIFFIES){
-		sec = MAX_SEC_IN_JIFFIES;
-		nsec = 0;
-	}
-	return (((u64)sec * SEC_CONVERSION) +
-		(((u64)nsec * NSEC_CONVERSION) >>
-		 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
-
-}
-
-static __inline__ void
-jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
-{
-	/*
-	 * Convert jiffies to nanoseconds and separate with
-	 * one divide.
-	 */
-	u64 nsec = (u64)jiffies * TICK_NSEC; 
-	value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec);
-}
-
-/* Same for "timeval"
- *
- * Well, almost.  The problem here is that the real system resolution is
- * in nanoseconds and the value being converted is in micro seconds.
- * Also for some machines (those that use HZ = 1024, in-particular),
- * there is a LARGE error in the tick size in microseconds.
-
- * The solution we use is to do the rounding AFTER we convert the
- * microsecond part.  Thus the USEC_ROUND, the bits to be shifted off.
- * Instruction wise, this should cost only an additional add with carry
- * instruction above the way it was done above.
- */
-static __inline__ unsigned long
-timeval_to_jiffies(const struct timeval *value)
-{
-	unsigned long sec = value->tv_sec;
-	long usec = value->tv_usec;
-
-	if (sec >= MAX_SEC_IN_JIFFIES){
-		sec = MAX_SEC_IN_JIFFIES;
-		usec = 0;
-	}
-	return (((u64)sec * SEC_CONVERSION) +
-		(((u64)usec * USEC_CONVERSION + USEC_ROUND) >>
-		 (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
-}
-
-static __inline__ void
-jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
-{
-	/*
-	 * Convert jiffies to nanoseconds and separate with
-	 * one divide.
-	 */
-	u64 nsec = (u64)jiffies * TICK_NSEC; 
-	value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec);
-	value->tv_usec /= NSEC_PER_USEC;
-}
-
 static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) 
 { 
 	return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
@@ -347,11 +91,6 @@
 
 #define CURRENT_TIME (current_kernel_time())
 
-#endif /* __KERNEL__ */
-
-#define NFDBITS			__NFDBITS
-
-#ifdef __KERNEL__
 extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday(struct timespec *tv);
 extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz);
@@ -378,7 +117,10 @@
 	ts->tv_sec = sec;
 	ts->tv_nsec = nsec;
 }
-#endif
+
+#endif /* __KERNEL__ */
+
+#define NFDBITS			__NFDBITS
 
 #define FD_SETSIZE		__FD_SETSIZE
 #define FD_SET(fd,fdsetp)	__FD_SET(fd,fdsetp)
@@ -415,7 +157,13 @@
 #define CLOCK_REALTIME_HR	 4
 #define CLOCK_MONOTONIC_HR	  5
 
-#define MAX_CLOCKS 6
+/*
+ * The IDs of various hardware clocks
+ */
+
+
+#define CLOCK_SGI_CYCLE 10
+#define MAX_CLOCKS 16
 #define CLOCKS_MASK  (CLOCK_REALTIME | CLOCK_MONOTONIC | \
                      CLOCK_REALTIME_HR | CLOCK_MONOTONIC_HR)
 #define CLOCKS_MONO (CLOCK_MONOTONIC & CLOCK_MONOTONIC_HR)
diff -Nru a/include/linux/times.h b/include/linux/times.h
--- a/include/linux/times.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/times.h	2004-12-24 13:36:17 -08:00
@@ -1,79 +1,7 @@
 #ifndef _LINUX_TIMES_H
 #define _LINUX_TIMES_H
 
-#ifdef __KERNEL__
-#include <linux/timex.h>
-#include <asm/div64.h>
-#include <asm/types.h>
-#include <asm/param.h>
-
-static inline clock_t jiffies_to_clock_t(long x)
-{
-#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
-	return x / (HZ / USER_HZ);
-#else
-	u64 tmp = (u64)x * TICK_NSEC;
-	do_div(tmp, (NSEC_PER_SEC / USER_HZ));
-	return (long)tmp;
-#endif
-}
-
-static inline unsigned long clock_t_to_jiffies(unsigned long x)
-{
-#if (HZ % USER_HZ)==0
-	if (x >= ~0UL / (HZ / USER_HZ))
-		return ~0UL;
-	return x * (HZ / USER_HZ);
-#else
-	u64 jif;
-
-	/* Don't worry about loss of precision here .. */
-	if (x >= ~0UL / HZ * USER_HZ)
-		return ~0UL;
-
-	/* .. but do try to contain it here */
-	jif = x * (u64) HZ;
-	do_div(jif, USER_HZ);
-	return jif;
-#endif
-}
-
-static inline u64 jiffies_64_to_clock_t(u64 x)
-{
-#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
-	do_div(x, HZ / USER_HZ);
-#else
-	/*
-	 * There are better ways that don't overflow early,
-	 * but even this doesn't overflow in hundreds of years
-	 * in 64 bits, so..
-	 */
-	x *= TICK_NSEC;
-	do_div(x, (NSEC_PER_SEC / USER_HZ));
-#endif
-	return x;
-}
-#endif
-
-static inline u64 nsec_to_clock_t(u64 x)
-{
-#if (NSEC_PER_SEC % USER_HZ) == 0
-	do_div(x, (NSEC_PER_SEC / USER_HZ));
-#elif (USER_HZ % 512) == 0
-	x *= USER_HZ/512;
-	do_div(x, (NSEC_PER_SEC / 512));
-#else
-	/*
-         * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024,
-         * overflow after 64.99 years.
-         * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ...
-         */
-	x *= 9;
-	do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (USER_HZ/2))
-	                          / USER_HZ));
-#endif
-	return x;
-}
+#include <linux/types.h>
 
 struct tms {
 	clock_t tms_utime;
diff -Nru a/include/linux/timex.h b/include/linux/timex.h
--- a/include/linux/timex.h	2004-12-24 13:36:17 -08:00
+++ b/include/linux/timex.h	2004-12-24 13:36:17 -08:00
@@ -55,33 +55,10 @@
 
 #include <linux/config.h>
 #include <linux/compiler.h>
+#include <linux/time.h>
 
 #include <asm/param.h>
-
-/*
- * The following defines establish the engineering parameters of the PLL
- * model. The HZ variable establishes the timer interrupt frequency, 100 Hz
- * for the SunOS kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the
- * OSF/1 kernel. The SHIFT_HZ define expresses the same value as the
- * nearest power of two in order to avoid hardware multiply operations.
- */
-#if HZ >= 12 && HZ < 24
-# define SHIFT_HZ	4
-#elif HZ >= 24 && HZ < 48
-# define SHIFT_HZ	5
-#elif HZ >= 48 && HZ < 96
-# define SHIFT_HZ	6
-#elif HZ >= 96 && HZ < 192
-# define SHIFT_HZ	7
-#elif HZ >= 192 && HZ < 384
-# define SHIFT_HZ	8
-#elif HZ >= 384 && HZ < 768
-# define SHIFT_HZ	9
-#elif HZ >= 768 && HZ < 1536
-# define SHIFT_HZ	10
-#else
-# error You lose.
-#endif
+#include <asm/timex.h>
 
 /*
  * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
@@ -152,41 +129,6 @@
 #define MAXGLITCH 30		/* pps signal glitch max (s) */
 
 /*
- * Pick up the architecture specific timex specifications
- */
-#include <asm/timex.h>
-
-/* LATCH is used in the interval timer and ftape setup. */
-#define LATCH  ((CLOCK_TICK_RATE + HZ/2) / HZ)	/* For divider */
-
-/* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, the we can
- * improve accuracy by shifting LSH bits, hence calculating:
- *     (NOM << LSH) / DEN
- * This however means trouble for large NOM, because (NOM << LSH) may no
- * longer fit in 32 bits. The following way of calculating this gives us
- * some slack, under the following conditions:
- *   - (NOM / DEN) fits in (32 - LSH) bits.
- *   - (NOM % DEN) fits in (32 - LSH) bits.
- */
-#define SH_DIV(NOM,DEN,LSH) (   ((NOM / DEN) << LSH)                    \
-                             + (((NOM % DEN) << LSH) + DEN / 2) / DEN)
-
-/* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */
-#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
-
-/* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */
-#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
-
-/* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */
-#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
-
-/* TICK_USEC_TO_NSEC is the time between ticks in nsec assuming real ACTHZ and	*/
-/* a value TUSEC for TICK_USEC (can be set bij adjtimex)		*/
-#define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8))
-
-
-#include <linux/time.h>
-/*
  * syscall interface - used (mainly by NTP daemon)
  * to discipline kernel clock oscillator
  */
@@ -343,20 +285,18 @@
  * for the compensation is that the timer routines are not as scalable anymore.
  */
 
-#define INTERPOLATOR_ADJUST 65536
-#define INTERPOLATOR_MAX_SKIP 10*INTERPOLATOR_ADJUST
-
 struct time_interpolator {
-	unsigned short source;		/* time source flags */
-	unsigned char shift;		/* increases accuracy of multiply by shifting. */
-			/* Note that bits may be lost if shift is set too high */
-	unsigned char jitter;		/* if set compensate for fluctuations */
-	unsigned nsec_per_cyc;		/* set by register_time_interpolator() */
+	u16 source;			/* time source flags */
+	u8 shift;			/* increases accuracy of multiply by shifting. */
+				/* Note that bits may be lost if shift is set too high */
+	u8 jitter;			/* if set compensate for fluctuations */
+	u32 nsec_per_cyc;		/* set by register_time_interpolator() */
 	void *addr;			/* address of counter or function */
+	u64 mask;			/* mask the valid bits of the counter */
 	unsigned long offset;		/* nsec offset at last update of interpolator */
-	unsigned long last_counter;	/* counter value in units of the counter at last update */
-	unsigned long last_cycle;	/* Last timer value if TIME_SOURCE_JITTER is set */
-	unsigned long frequency;	/* frequency in counts/second */
+	u64 last_counter;		/* counter value in units of the counter at last update */
+	u64 last_cycle;			/* Last timer value if TIME_SOURCE_JITTER is set */
+	u64 frequency;			/* frequency in counts/second */
 	long drift;			/* drift in parts-per-million (or -1) */
 	unsigned long skips;		/* skips forward */
 	unsigned long ns_skipped;	/* nanoseconds skipped */
@@ -366,7 +306,6 @@
 extern void register_time_interpolator(struct time_interpolator *);
 extern void unregister_time_interpolator(struct time_interpolator *);
 extern void time_interpolator_reset(void);
-extern unsigned long time_interpolator_resolution(void);
 extern unsigned long time_interpolator_get_offset(void);
 
 #else /* !CONFIG_TIME_INTERPOLATION */
diff -Nru a/include/linux/topology.h b/include/linux/topology.h
--- a/include/linux/topology.h	2004-12-24 13:37:02 -08:00
+++ b/include/linux/topology.h	2004-12-24 13:37:02 -08:00
@@ -61,4 +61,76 @@
 #define PENALTY_FOR_NODE_WITH_CPUS	(1)
 #endif
 
+/*
+ * Below are the 3 major initializers used in building sched_domains:
+ * SD_SIBLING_INIT, for SMT domains
+ * SD_CPU_INIT, for SMP domains
+ * SD_NODE_INIT, for NUMA domains
+ *
+ * Any architecture that cares to do any tuning to these values should do so
+ * by defining their own arch-specific initializer in include/asm/topology.h.
+ * A definition there will automagically override these default initializers
+ * and allow arch-specific performance tuning of sched_domains.
+ */
+#ifdef CONFIG_SCHED_SMT
+/* MCD - Do we really need this?  It is always on if CONFIG_SCHED_SMT is,
+ * so can't we drop this in favor of CONFIG_SCHED_SMT?
+ */
+#define ARCH_HAS_SCHED_WAKE_IDLE
+/* Common values for SMT siblings */
+#ifndef SD_SIBLING_INIT
+#define SD_SIBLING_INIT (struct sched_domain) {		\
+	.span			= CPU_MASK_NONE,	\
+	.parent			= NULL,			\
+	.groups			= NULL,			\
+	.min_interval		= 1,			\
+	.max_interval		= 2,			\
+	.busy_factor		= 8,			\
+	.imbalance_pct		= 110,			\
+	.cache_hot_time		= 0,			\
+	.cache_nice_tries	= 0,			\
+	.per_cpu_gain		= 25,			\
+	.flags			= SD_LOAD_BALANCE	\
+				| SD_BALANCE_NEWIDLE	\
+				| SD_BALANCE_EXEC	\
+				| SD_WAKE_AFFINE	\
+				| SD_WAKE_IDLE		\
+				| SD_SHARE_CPUPOWER,	\
+	.last_balance		= jiffies,		\
+	.balance_interval	= 1,			\
+	.nr_balance_failed	= 0,			\
+}
+#endif
+#endif /* CONFIG_SCHED_SMT */
+
+/* Common values for CPUs */
+#ifndef SD_CPU_INIT
+#define SD_CPU_INIT (struct sched_domain) {		\
+	.span			= CPU_MASK_NONE,	\
+	.parent			= NULL,			\
+	.groups			= NULL,			\
+	.min_interval		= 1,			\
+	.max_interval		= 4,			\
+	.busy_factor		= 64,			\
+	.imbalance_pct		= 125,			\
+	.cache_hot_time		= (5*1000/2),		\
+	.cache_nice_tries	= 1,			\
+	.per_cpu_gain		= 100,			\
+	.flags			= SD_LOAD_BALANCE	\
+				| SD_BALANCE_NEWIDLE	\
+				| SD_BALANCE_EXEC	\
+				| SD_WAKE_AFFINE	\
+				| SD_WAKE_BALANCE,	\
+	.last_balance		= jiffies,		\
+	.balance_interval	= 1,			\
+	.nr_balance_failed	= 0,			\
+}
+#endif
+
+#ifdef CONFIG_NUMA
+#ifndef SD_NODE_INIT
+#error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!!
+#endif
+#endif /* CONFIG_NUMA */
+
 #endif /* _LINUX_TOPOLOGY_H */
diff -Nru a/include/linux/tty.h b/include/linux/tty.h
--- a/include/linux/tty.h	2004-12-24 13:36:49 -08:00
+++ b/include/linux/tty.h	2004-12-24 13:36:49 -08:00
@@ -291,6 +291,8 @@
 	unsigned int canon_column;
 	struct semaphore atomic_read;
 	struct semaphore atomic_write;
+	unsigned char *write_buf;
+	int write_cnt;
 	spinlock_t read_lock;
 	/* If the tty has a pending do_SAK, queue it here - akpm */
 	struct work_struct SAK_work;
diff -Nru a/include/linux/tty_driver.h b/include/linux/tty_driver.h
--- a/include/linux/tty_driver.h	2004-12-24 13:37:00 -08:00
+++ b/include/linux/tty_driver.h	2004-12-24 13:37:00 -08:00
@@ -17,7 +17,7 @@
  *
  * 	This routine is called when a particular tty device is closed.
  *
- * int (*write)(struct tty_struct * tty, int from_user,
+ * int (*write)(struct tty_struct * tty,
  * 		 const unsigned char *buf, int count);
  *
  * 	This routine is called by the kernel to write a series of
@@ -124,7 +124,7 @@
 struct tty_operations {
 	int  (*open)(struct tty_struct * tty, struct file * filp);
 	void (*close)(struct tty_struct * tty, struct file * filp);
-	int  (*write)(struct tty_struct * tty, int from_user,
+	int  (*write)(struct tty_struct * tty,
 		      const unsigned char *buf, int count);
 	void (*put_char)(struct tty_struct *tty, unsigned char ch);
 	void (*flush_chars)(struct tty_struct *tty);
@@ -186,7 +186,7 @@
 	 */
 	int  (*open)(struct tty_struct * tty, struct file * filp);
 	void (*close)(struct tty_struct * tty, struct file * filp);
-	int  (*write)(struct tty_struct * tty, int from_user,
+	int  (*write)(struct tty_struct * tty,
 		      const unsigned char *buf, int count);
 	void (*put_char)(struct tty_struct *tty, unsigned char ch);
 	void (*flush_chars)(struct tty_struct *tty);
diff -Nru a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
--- a/include/linux/tty_ldisc.h	2004-12-24 13:37:31 -08:00
+++ b/include/linux/tty_ldisc.h	2004-12-24 13:37:31 -08:00
@@ -123,7 +123,7 @@
 	ssize_t	(*read)(struct tty_struct * tty, struct file * file,
 			unsigned char __user * buf, size_t nr);
 	ssize_t	(*write)(struct tty_struct * tty, struct file * file,
-			 const unsigned char __user * buf, size_t nr);	
+			 const unsigned char * buf, size_t nr);	
 	int	(*ioctl)(struct tty_struct * tty, struct file * file,
 			 unsigned int cmd, unsigned long arg);
 	void	(*set_termios)(struct tty_struct *tty, struct termios * old);
diff -Nru a/include/linux/types.h b/include/linux/types.h
--- a/include/linux/types.h	2004-12-24 13:37:19 -08:00
+++ b/include/linux/types.h	2004-12-24 13:37:19 -08:00
@@ -140,6 +140,13 @@
 #define pgoff_t unsigned long
 #endif
 
+#endif /* __KERNEL_STRICT_NAMES */
+
+/*
+ * Below are truly Linux-specific types that should never collide with
+ * any application/library that wants linux/types.h.
+ */
+
 #ifdef __CHECKER__
 #define __bitwise __attribute__((bitwise))
 #else
@@ -150,15 +157,10 @@
 typedef __u16 __bitwise __be16;
 typedef __u32 __bitwise __le32;
 typedef __u32 __bitwise __be32;
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
 typedef __u64 __bitwise __le64;
 typedef __u64 __bitwise __be64;
-
-#endif /* __KERNEL_STRICT_NAMES */
-
-/*
- * Below are truly Linux-specific types that should never collide with
- * any application/library that wants linux/types.h.
- */
+#endif
 
 struct ustat {
 	__kernel_daddr_t	f_tfree;
diff -Nru a/include/linux/usb.h b/include/linux/usb.h
--- a/include/linux/usb.h	2004-12-24 13:36:48 -08:00
+++ b/include/linux/usb.h	2004-12-24 13:36:48 -08:00
@@ -61,6 +61,13 @@
 	int extralen;
 };
 
+enum usb_interface_condition {
+	USB_INTERFACE_UNBOUND = 0,
+	USB_INTERFACE_BINDING,
+	USB_INTERFACE_BOUND,
+	USB_INTERFACE_UNBINDING,
+};
+
 /**
  * struct usb_interface - what usb device drivers talk to
  * @altsetting: array of interface structures, one for each alternate
@@ -75,6 +82,8 @@
  *	be unused.  The driver should set this value in the probe()
  *	function of the driver, after it has been assigned a minor
  *	number from the USB core by calling usb_register_dev().
+ * @condition: binding state of the interface: not bound, binding
+ *	(in probe()), bound to a driver, or unbinding (in disconnect())
  * @dev: driver model's view of this device
  * @class_dev: driver model's class view of this device.
  *
@@ -113,6 +122,7 @@
 	unsigned num_altsetting;	/* number of alternate settings */
 
 	int minor;			/* minor number this interface is bound to */
+	enum usb_interface_condition condition;		/* state of binding */
 	struct device dev;		/* interface specific device info */
 	struct class_device *class_dev;
 };
@@ -264,7 +274,6 @@
 	int bandwidth_isoc_reqs;	/* number of Isoc. requests */
 
 	struct dentry *usbfs_dentry;	/* usbfs dentry entry for the bus */
-	struct dentry *usbdevfs_dentry;	/* usbdevfs dentry entry for the bus */
 
 	struct class_device class_dev;	/* class device for this bus */
 	void (*release)(struct usb_bus *bus);	/* function to destroy this bus's memory */
@@ -282,6 +291,14 @@
 
 struct usb_tt;
 
+/*
+ * struct usb_device - kernel's representation of a USB device
+ *
+ * FIXME: Write the kerneldoc!
+ *
+ * Usbcore drivers should not set usbdev->state directly.  Instead use
+ * usb_set_device_state().
+ */
 struct usb_device {
 	int		devnum;		/* Address on USB bus */
 	char		devpath [16];	/* Use in messages: /port/port/... */
@@ -315,7 +332,6 @@
 	
 	struct list_head filelist;
 	struct dentry *usbfs_dentry;	/* usbfs dentry entry for the device */
-	struct dentry *usbdevfs_dentry;	/* usbdevfs dentry entry for the device */
 
 	/*
 	 * Child devices - these can be either new devices
@@ -333,9 +349,14 @@
 extern struct usb_device *usb_get_dev(struct usb_device *dev);
 extern void usb_put_dev(struct usb_device *dev);
 
-/* mostly for devices emulating SCSI over USB */
+extern void usb_lock_device(struct usb_device *udev);
+extern int usb_trylock_device(struct usb_device *udev);
+extern int usb_lock_device_for_reset(struct usb_device *udev,
+		struct usb_interface *iface);
+extern void usb_unlock_device(struct usb_device *udev);
+
+/* USB port reset for device reinitialization */
 extern int usb_reset_device(struct usb_device *dev);
-extern int __usb_reset_device(struct usb_device *dev);
 
 extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
 
diff -Nru a/include/linux/usb_sl811.h b/include/linux/usb_sl811.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/usb_sl811.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,26 @@
+
+/*
+ * board initialization should put one of these into dev->platform_data
+ * and place the sl811hs onto platform_bus named "sl811-hcd".
+ */
+
+struct sl811_platform_data {
+	unsigned	can_wakeup:1;
+
+	/* given port_power, msec/2 after power on till power good */
+	u8		potpg;
+
+	/* mA/2 power supplied on this port (max = default = 250) */
+	u8		power;
+
+	/* sl811 relies on an external source of VBUS current */
+	void 		(*port_power)(struct device *dev, int is_on);
+
+	/* pulse sl811 nRST (probably with a GPIO) */
+	void 		(*reset)(struct device *dev);
+
+	// some boards need something like these:
+ 	// int 		(*check_overcurrent)(struct device *dev);
+ 	// void 	(*clock_enable)(struct device *dev, int is_on);
+};
+
diff -Nru a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
--- a/include/linux/usbdevice_fs.h	2004-12-24 13:36:31 -08:00
+++ b/include/linux/usbdevice_fs.h	2004-12-24 13:36:31 -08:00
@@ -144,39 +144,4 @@
 #define USBDEVFS_DISCONNECT        _IO('U', 22)
 #define USBDEVFS_CONNECT           _IO('U', 23)
 
-/* --------------------------------------------------------------------- */
-
-#ifdef __KERNEL__
-
-#include <linux/list.h>
-#include <asm/semaphore.h>
-
-
-struct dev_state {
-	struct list_head list;      /* state list */
-	struct usb_device *dev;
-	struct file *file;
-	spinlock_t lock;            /* protects the async urb lists */
-	struct list_head async_pending;
-	struct list_head async_completed;
-	wait_queue_head_t wait;     /* wake up if a request completed */
-	unsigned int discsignr;
-	struct task_struct *disctask;
-	void __user *disccontext;
-	unsigned long ifclaimed;
-};
-
-/* internal methods & data */
-extern struct usb_driver usbdevfs_driver;
-extern struct file_operations usbdevfs_drivers_fops;
-extern struct file_operations usbdevfs_devices_fops;
-extern struct file_operations usbdevfs_device_file_operations;
-extern struct inode_operations usbdevfs_device_inode_operations;
-extern struct inode_operations usbdevfs_bus_inode_operations;
-extern struct file_operations usbdevfs_bus_file_operations;
-extern void usbdevfs_conn_disc_event(void);
-
-#endif /* __KERNEL__ */
-
-/* --------------------------------------------------------------------- */
 #endif /* _LINUX_USBDEVICE_FS_H */
diff -Nru a/include/linux/via.h b/include/linux/via.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/via.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,22 @@
+/* Miscellaneous definitions for VIA chipsets
+   Currently used only by drivers/parport/parport_pc.c */
+
+/* Values for SuperIO function select configuration register */
+#define VIA_FUNCTION_PARPORT_SPP     0x00
+#define VIA_FUNCTION_PARPORT_ECP     0x01
+#define VIA_FUNCTION_PARPORT_EPP     0x02
+#define VIA_FUNCTION_PARPORT_DISABLE 0x03
+#define VIA_FUNCTION_PROBE           0xFF /* Special magic value to be used in code, not to be written into chip */
+
+/* Bits for parallel port mode configuration register */
+#define VIA_PARPORT_ECPEPP 0X20
+#define VIA_PARPORT_BIDIR  0x80
+
+/* VIA configuration registers */
+#define VIA_CONFIG_INDEX 0x3F0
+#define VIA_CONFIG_DATA  0x3F1
+
+/* Mask for parallel port IRQ bits (in ISA PnP IRQ routing register 1) */
+#define VIA_IRQCONTROL_PARALLEL 0xF0
+/* Mask for parallel port DMA bits (in ISA PnP DMA routing register) */
+#define VIA_DMACONTROL_PARALLEL 0x0C
diff -Nru a/include/linux/videodev.h b/include/linux/videodev.h
--- a/include/linux/videodev.h	2004-12-24 13:37:43 -08:00
+++ b/include/linux/videodev.h	2004-12-24 13:37:43 -08:00
@@ -133,7 +133,7 @@
 #define VIDEO_VC_AUDIO		2	/* Channel has audio */
 	__u16  type;
 #define VIDEO_TYPE_TV		1
-#define VIDEO_TYPE_CAMERA	2	
+#define VIDEO_TYPE_CAMERA	2
 	__u16 norm;			/* Norm set by channel */
 };
 
@@ -172,7 +172,7 @@
 #define VIDEO_PALETTE_HI240	2	/* High 240 cube (BT848) */
 #define VIDEO_PALETTE_RGB565	3	/* 565 16 bit RGB */
 #define VIDEO_PALETTE_RGB24	4	/* 24bit RGB */
-#define VIDEO_PALETTE_RGB32	5	/* 32bit RGB */	
+#define VIDEO_PALETTE_RGB32	5	/* 32bit RGB */
 #define VIDEO_PALETTE_RGB555	6	/* 555 15bit RGB */
 #define VIDEO_PALETTE_YUV422	7	/* YUV422 capture */
 #define VIDEO_PALETTE_YUYV	8
@@ -198,7 +198,7 @@
 #define VIDEO_AUDIO_MUTABLE	2
 #define VIDEO_AUDIO_VOLUME	4
 #define VIDEO_AUDIO_BASS	8
-#define VIDEO_AUDIO_TREBLE	16	
+#define VIDEO_AUDIO_TREBLE	16
 #define VIDEO_AUDIO_BALANCE	32
 	char    name[16];
 #define VIDEO_SOUND_MONO	1
@@ -272,11 +272,11 @@
 	int	frames;		/* Frames */
 	int	offsets[VIDEO_MAX_FRAME];
 };
-	
+
 
 #define 	VIDEO_NO_UNIT	(-1)
 
-	
+
 struct video_unit
 {
 	int 	video;		/* Video minor */
@@ -373,7 +373,7 @@
 	/* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */
 #define VID_PLAY_GENLOCK		1
 	/* p1: 0 = OFF, 1 = ON */
-	/* p2: GENLOCK FINE DELAY value */ 
+	/* p2: GENLOCK FINE DELAY value */
 #define VID_PLAY_NORMAL			2
 #define VID_PLAY_PAUSE			3
 #define VID_PLAY_SINGLE_FRAME		4
@@ -421,7 +421,7 @@
 #define VID_HARDWARE_CPIA	24
 #define VID_HARDWARE_ZR36120	25	/* Zoran ZR36120/ZR36125 */
 #define VID_HARDWARE_ZR36067	26	/* Zoran ZR36067/36060 */
-#define VID_HARDWARE_OV511	27	
+#define VID_HARDWARE_OV511	27
 #define VID_HARDWARE_ZR356700	28	/* Zoran 36700 series */
 #define VID_HARDWARE_W9966	29
 #define VID_HARDWARE_SE401	30	/* SE401 USB webcams */
@@ -433,6 +433,7 @@
 #define VID_HARDWARE_W9968CF	36
 #define VID_HARDWARE_SAA7114H   37
 #define VID_HARDWARE_SN9C102	38
+#define VID_HARDWARE_ARV	39
 #endif /* __LINUX_VIDEODEV_H */
 
 /*
diff -Nru a/include/linux/videodev2.h b/include/linux/videodev2.h
--- a/include/linux/videodev2.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/videodev2.h	2004-12-24 13:37:01 -08:00
@@ -16,6 +16,7 @@
 #ifdef __KERNEL__
 #include <linux/time.h> /* need struct timeval */
 #endif
+#include <linux/compiler.h> /* need __user */
 
 /*
  *	M I S C E L L A N E O U S
@@ -95,20 +96,20 @@
 
 	/* HD and modern captures. */
 	V4L2_COLORSPACE_REC709        = 3,
-	
+
 	/* broken BT878 extents (601, luma range 16-253 instead of 16-235) */
 	V4L2_COLORSPACE_BT878         = 4,
-	
+
 	/* These should be useful.  Assume 601 extents. */
 	V4L2_COLORSPACE_470_SYSTEM_M  = 5,
 	V4L2_COLORSPACE_470_SYSTEM_BG = 6,
-	
+
 	/* I know there will be cameras that send this.  So, this is
 	 * unspecified chromaticities and full 0-255 on each of the
 	 * Y'CbCr components
 	 */
 	V4L2_COLORSPACE_JPEG          = 7,
-	
+
 	/* For RGB colourspaces, this is probably a good start. */
 	V4L2_COLORSPACE_SRGB          = 8,
 };
@@ -218,6 +219,7 @@
 
 /*  Vendor-specific formats   */
 #define V4L2_PIX_FMT_WNVA     v4l2_fourcc('W','N','V','A') /* Winnov hw compress */
+#define V4L2_PIX_FMT_SN9C10X  v4l2_fourcc('S','9','1','0') /* SN9C10x compression */
 
 /*
  *	F O R M A T   E N U M E R A T I O N
@@ -334,10 +336,10 @@
 				 * must be 0..15 */
 	int  APP_len;           /* Length of data in JPEG APPn segment */
 	char APP_data[60];      /* Data in the JPEG APPn segment. */
-	
+
 	int  COM_len;           /* Length of data in JPEG COM segment */
 	char COM_data[60];      /* Data in JPEG COM segment */
-	
+
 	__u32 jpeg_markers;     /* Which markers should go into the JPEG
 				 * output. Unless you exactly know what
 				 * you do, leave them untouched.
@@ -347,7 +349,7 @@
 				 * The presence of the APP and COM marker
 				 * is influenced by APP_len and COM_len
 				 * ONLY, not by this property! */
-	
+
 #define V4L2_JPEG_MARKER_DHT (1<<3)    /* Define Huffman Tables */
 #define V4L2_JPEG_MARKER_DQT (1<<4)    /* Define Quantization Tables */
 #define V4L2_JPEG_MARKER_DRI (1<<5)    /* Define Restart Interval */
@@ -470,7 +472,7 @@
  */
 
 struct v4l2_cropcap {
-	enum v4l2_buf_type      type;	
+	enum v4l2_buf_type      type;
         struct v4l2_rect        bounds;
         struct v4l2_rect        defrect;
         struct v4l2_fract       pixelaspect;
diff -Nru a/include/linux/wait.h b/include/linux/wait.h
--- a/include/linux/wait.h	2004-12-24 13:36:55 -08:00
+++ b/include/linux/wait.h	2004-12-24 13:36:55 -08:00
@@ -24,6 +24,7 @@
 #include <linux/stddef.h>
 #include <linux/spinlock.h>
 #include <asm/system.h>
+#include <asm/current.h>
 
 typedef struct __wait_queue wait_queue_t;
 typedef int (*wait_queue_func_t)(wait_queue_t *wait, unsigned mode, int sync, void *key);
@@ -37,6 +38,16 @@
 	struct list_head task_list;
 };
 
+struct wait_bit_key {
+	void *flags;
+	int bit_nr;
+};
+
+struct wait_bit_queue {
+	struct wait_bit_key key;
+	wait_queue_t wait;
+};
+
 struct __wait_queue_head {
 	spinlock_t lock;
 	struct list_head task_list;
@@ -63,6 +74,9 @@
 #define DECLARE_WAIT_QUEUE_HEAD(name) \
 	wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
 
+#define __WAIT_BIT_KEY_INITIALIZER(word, bit)				\
+	{ .flags = word, .bit_nr = bit, }
+
 static inline void init_waitqueue_head(wait_queue_head_t *q)
 {
 	q->lock = SPIN_LOCK_UNLOCKED;
@@ -125,11 +139,17 @@
 void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key));
 extern void FASTCALL(__wake_up_locked(wait_queue_head_t *q, unsigned int mode));
 extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr));
+void FASTCALL(__wake_up_bit(wait_queue_head_t *, void *, int));
+int FASTCALL(__wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned));
+int FASTCALL(__wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned));
+void FASTCALL(wake_up_bit(void *, int));
+int FASTCALL(out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned));
+int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned));
+wait_queue_head_t *FASTCALL(bit_waitqueue(void *, int));
 
 #define wake_up(x)			__wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1, NULL)
 #define wake_up_nr(x, nr)		__wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, nr, NULL)
 #define wake_up_all(x)			__wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0, NULL)
-#define wake_up_all_sync(x)			__wake_up_sync((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0)
 #define wake_up_interruptible(x)	__wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
 #define wake_up_interruptible_nr(x, nr)	__wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)
 #define wake_up_interruptible_all(x)	__wake_up(x, TASK_INTERRUPTIBLE, 0, NULL)
@@ -300,22 +320,80 @@
 				wait_queue_t *wait, int state));
 void FASTCALL(finish_wait(wait_queue_head_t *q, wait_queue_t *wait));
 int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
+int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
 
 #define DEFINE_WAIT(name)						\
 	wait_queue_t name = {						\
 		.task		= current,				\
 		.func		= autoremove_wake_function,		\
-		.task_list	= {	.next = &name.task_list,	\
-					.prev = &name.task_list,	\
+		.task_list	= {	.next = &(name).task_list,	\
+					.prev = &(name).task_list,	\
 				},					\
 	}
 
+#define DEFINE_WAIT_BIT(name, word, bit)				\
+	struct wait_bit_queue name = {					\
+		.key = __WAIT_BIT_KEY_INITIALIZER(word, bit),		\
+		.wait	= {						\
+			.task		= current,			\
+			.func		= wake_bit_function,		\
+			.task_list	=				\
+				LIST_HEAD_INIT((name).wait.task_list),	\
+		},							\
+	}
+
 #define init_wait(wait)							\
 	do {								\
-		wait->task = current;					\
-		wait->func = autoremove_wake_function;			\
-		INIT_LIST_HEAD(&wait->task_list);			\
+		(wait)->task = current;					\
+		(wait)->func = autoremove_wake_function;		\
+		INIT_LIST_HEAD(&(wait)->task_list);			\
 	} while (0)
+
+/**
+ * wait_on_bit - wait for a bit to be cleared
+ * @word: the word being waited on, a kernel virtual address
+ * @bit: the bit of the word being waited on
+ * @action: the function used to sleep, which may take special actions
+ * @mode: the task state to sleep in
+ *
+ * There is a standard hashed waitqueue table for generic use. This
+ * is the part of the hashtable's accessor API that waits on a bit.
+ * For instance, if one were to have waiters on a bitflag, one would
+ * call wait_on_bit() in threads waiting for the bit to clear.
+ * One uses wait_on_bit() where one is waiting for the bit to clear,
+ * but has no intention of setting it.
+ */
+static inline int wait_on_bit(void *word, int bit,
+				int (*action)(void *), unsigned mode)
+{
+	if (!test_bit(bit, word))
+		return 0;
+	return out_of_line_wait_on_bit(word, bit, action, mode);
+}
+
+/**
+ * wait_on_bit_lock - wait for a bit to be cleared, when wanting to set it
+ * @word: the word being waited on, a kernel virtual address
+ * @bit: the bit of the word being waited on
+ * @action: the function used to sleep, which may take special actions
+ * @mode: the task state to sleep in
+ *
+ * There is a standard hashed waitqueue table for generic use. This
+ * is the part of the hashtable's accessor API that waits on a bit
+ * when one intends to set it, for instance, trying to lock bitflags.
+ * For instance, if one were to have waiters trying to set bitflag
+ * and waiting for it to clear before setting it, one would call
+ * wait_on_bit() in threads waiting to be able to set the bit.
+ * One uses wait_on_bit_lock() where one is waiting for the bit to
+ * clear with the intention of setting it, and when done, clearing it.
+ */
+static inline int wait_on_bit_lock(void *word, int bit,
+				int (*action)(void *), unsigned mode)
+{
+	if (!test_and_set_bit(bit, word))
+		return 0;
+	return out_of_line_wait_on_bit_lock(word, bit, action, mode);
+}
 	
 #endif /* __KERNEL__ */
 
diff -Nru a/include/linux/wireless.h b/include/linux/wireless.h
--- a/include/linux/wireless.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/wireless.h	2004-12-24 13:37:01 -08:00
@@ -1,10 +1,10 @@
 /*
  * This file define a set of standard wireless extensions
  *
- * Version :	16	2.4.03
+ * Version :	17	21.6.04
  *
  * Authors :	Jean Tourrilhes - HPL - <jt@hpl.hp.com>
- * Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved.
+ * Copyright (c) 1997-2004 Jean Tourrilhes, All Rights Reserved.
  */
 
 #ifndef _LINUX_WIRELESS_H
@@ -47,12 +47,12 @@
  *	# include/net/iw_handler.h
  *
  * Note as well that /proc/net/wireless implementation has now moved in :
- *	# include/linux/wireless.c
+ *	# net/core/wireless.c
  *
  * Wireless Events (2002 -> onward) :
  * --------------------------------
  * Events are defined at the end of this file, and implemented in :
- *	# include/linux/wireless.c
+ *	# net/core/wireless.c
  *
  * Other comments :
  * --------------
@@ -82,7 +82,7 @@
  * (there is some stuff that will be added in the future...)
  * I just plan to increment with each new version.
  */
-#define WIRELESS_EXT	16
+#define WIRELESS_EXT	17
 
 /*
  * Changes :
@@ -175,6 +175,13 @@
  *	- Remove IW_MAX_GET_SPY because conflict with enhanced spy support
  *	- Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
  *	- Add IW_ENCODE_TEMP and iw_range->encoding_login_index
+ *
+ * V16 to V17
+ * ----------
+ *	- Add flags to frequency -> auto/fixed
+ *	- Document (struct iw_quality *)->updated, add new flags (INVALID)
+ *	- Wireless Event capability in struct iw_range
+ *	- Add support for relative TxPower (yick !)
  */
 
 /**************************** CONSTANTS ****************************/
@@ -251,7 +258,7 @@
 
 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
 
-/* These 16 ioctl are wireless device private.
+/* These 32 ioctl are wireless device private, for 16 commands.
  * Each driver is free to use them for whatever purpose it chooses,
  * however the driver *must* export the description of those ioctls
  * with SIOCGIWPRIV and *must* use arguments as defined below.
@@ -266,8 +273,8 @@
  * We now have 32 commands, so a bit more space ;-).
  * Also, all 'odd' commands are only usable by root and don't return the
  * content of ifr/iwr to user (but you are not obliged to use the set/get
- * convention, just use every other two command).
- * And I repeat : you are not obliged to use them with iwspy, but you
+ * convention, just use every other two command). More details in iwpriv.c.
+ * And I repeat : you are not forced to use them with iwpriv, but you
  * must be compliant with it.
  */
 
@@ -352,6 +359,18 @@
 #define IW_MODE_SECOND	5	/* Secondary master/repeater (backup) */
 #define IW_MODE_MONITOR	6	/* Passive monitor (listen only) */
 
+/* Statistics flags (bitmask in updated) */
+#define IW_QUAL_QUAL_UPDATED	0x1	/* Value was updated since last read */
+#define IW_QUAL_LEVEL_UPDATED	0x2
+#define IW_QUAL_NOISE_UPDATED	0x4
+#define IW_QUAL_QUAL_INVALID	0x10	/* Driver doesn't provide value */
+#define IW_QUAL_LEVEL_INVALID	0x20
+#define IW_QUAL_NOISE_INVALID	0x40
+
+/* Frequency flags */
+#define IW_FREQ_AUTO		0x00	/* Let the driver decides */
+#define IW_FREQ_FIXED		0x01	/* Force a specific value */
+
 /* Maximum number of size of encoding token available
  * they are listed in the range structure */
 #define IW_MAX_ENCODING_SIZES	8
@@ -390,6 +409,7 @@
 #define IW_TXPOW_TYPE		0x00FF	/* Type of value */
 #define IW_TXPOW_DBM		0x0000	/* Value is in dBm */
 #define IW_TXPOW_MWATT		0x0001	/* Value is in mW */
+#define IW_TXPOW_RELATIVE	0x0002	/* Value is in arbitrary units */
 #define IW_TXPOW_RANGE		0x1000	/* Range of value between min/max */
 
 /* Retry limits and lifetime flags available */
@@ -418,6 +438,25 @@
 /* Max number of char in custom event - use multiple of them if needed */
 #define IW_CUSTOM_MAX		256	/* In bytes */
 
+/* Event capability macros - in (struct iw_range *)->event_capa
+ * Because we have more than 32 possible events, we use an array of
+ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
+#define IW_EVENT_CAPA_BASE(cmd)		((cmd >= SIOCIWFIRSTPRIV) ? \
+					 (cmd - SIOCIWFIRSTPRIV + 0x60) : \
+					 (cmd - SIOCSIWCOMMIT))
+#define IW_EVENT_CAPA_INDEX(cmd)	(IW_EVENT_CAPA_BASE(cmd) >> 5)
+#define IW_EVENT_CAPA_MASK(cmd)		(1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
+/* Event capability constants - event autogenerated by the kernel
+ * This list is valid for most 802.11 devices, customise as needed... */
+#define IW_EVENT_CAPA_K_0	(IW_EVENT_CAPA_MASK(0x8B04) | \
+				 IW_EVENT_CAPA_MASK(0x8B06) | \
+				 IW_EVENT_CAPA_MASK(0x8B1A))
+#define IW_EVENT_CAPA_K_1	(IW_EVENT_CAPA_MASK(0x8B2A))
+/* "Easy" macro to set events in iw_range (less efficient) */
+#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
+#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
+
+
 /****************************** TYPES ******************************/
 
 /* --------------------------- SUBTYPES --------------------------- */
@@ -456,7 +495,7 @@
 	__s32		m;		/* Mantissa */
 	__s16		e;		/* Exponent */
 	__u8		i;		/* List index (when in range struct) */
-	__u8		pad;		/* Unused - just for alignement */
+	__u8		flags;		/* Flags (fixed/auto) */
 };
 
 /*
@@ -610,11 +649,12 @@
 	/* Old Frequency (backward compat - moved lower ) */
 	__u16		old_num_channels;
 	__u8		old_num_frequency;
-	/* Filler to keep "version" at the same offset */
-	__s32		old_freq[6];
+
+	/* Wireless event capability bitmasks */
+	__u32		event_capa[6];
 
 	/* signal level threshold range */
-	__s32	sensitivity;
+	__s32		sensitivity;
 
 	/* Quality of link & SNR stuff */
 	/* Quality range (link, level, noise)
diff -Nru a/include/linux/writeback.h b/include/linux/writeback.h
--- a/include/linux/writeback.h	2004-12-24 13:36:18 -08:00
+++ b/include/linux/writeback.h	2004-12-24 13:36:18 -08:00
@@ -68,7 +68,7 @@
  */	
 void writeback_inodes(struct writeback_control *wbc);
 void wake_up_inode(struct inode *inode);
-void __wait_on_inode(struct inode * inode);
+int inode_wait(void *);
 void sync_inodes_sb(struct super_block *, int wait);
 void sync_inodes(int wait);
 
@@ -76,8 +76,8 @@
 static inline void wait_on_inode(struct inode *inode)
 {
 	might_sleep();
-	if (inode->i_state & I_LOCK)
-		__wait_on_inode(inode);
+	wait_on_bit(&inode->i_state, __I_LOCK, inode_wait,
+							TASK_UNINTERRUPTIBLE);
 }
 
 /*
@@ -106,6 +106,8 @@
 int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
 int sync_page_range(struct inode *inode, struct address_space *mapping,
 			loff_t pos, size_t count);
+int sync_page_range_nolock(struct inode *inode, struct address_space
+		*mapping, loff_t pos, size_t count);
 
 /* pdflush.c */
 extern int nr_pdflush_threads;	/* Global so it can be exported to sysctl
diff -Nru a/include/linux/xattr.h b/include/linux/xattr.h
--- a/include/linux/xattr.h	2004-12-24 13:37:01 -08:00
+++ b/include/linux/xattr.h	2004-12-24 13:37:01 -08:00
@@ -5,6 +5,7 @@
 
   Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
   Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
+  Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
 */
 #ifndef _LINUX_XATTR_H
 #define _LINUX_XATTR_H
@@ -13,5 +14,20 @@
 #define XATTR_REPLACE	0x2	/* set value, fail if attr does not exist */
 
 #define XATTR_SECURITY_PREFIX	"security."
+
+struct xattr_handler {
+	char *prefix;
+	size_t (*list)(struct inode *inode, char *list, size_t list_size,
+		       const char *name, size_t name_len);
+	int (*get)(struct inode *inode, const char *name, void *buffer,
+		   size_t size);
+	int (*set)(struct inode *inode, const char *name, const void *buffer,
+		   size_t size, int flags);
+};
+
+ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size);
+ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
+int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
+int generic_removexattr(struct dentry *dentry, const char *name);
 
 #endif	/* _LINUX_XATTR_H */
diff -Nru a/include/media/audiochip.h b/include/media/audiochip.h
--- a/include/media/audiochip.h	2004-12-24 13:36:31 -08:00
+++ b/include/media/audiochip.h	2004-12-24 13:36:31 -08:00
@@ -13,7 +13,7 @@
 #define AUDIO_RADIO        0x01
 #define AUDIO_EXTERN       0x02
 #define AUDIO_INTERN       0x03
-#define AUDIO_OFF          0x04 
+#define AUDIO_OFF          0x04
 #define AUDIO_ON           0x05
 #define AUDIO_EXTERN_1     AUDIO_EXTERN
 #define AUDIO_EXTERN_2     0x06
diff -Nru a/include/media/ir-common.h b/include/media/ir-common.h
--- a/include/media/ir-common.h	2004-12-24 13:37:19 -08:00
+++ b/include/media/ir-common.h	2004-12-24 13:37:19 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: ir-common.h,v 1.6 2004/09/15 16:15:24 kraxel Exp $
+ *
  * some common structs and functions to handle infrared remotes via
  * input layer ...
  *
diff -Nru a/include/media/saa6752hs.h b/include/media/saa6752hs.h
--- a/include/media/saa6752hs.h	2004-12-24 13:37:43 -08:00
+++ b/include/media/saa6752hs.h	2004-12-24 13:37:43 -08:00
@@ -1,4 +1,4 @@
-/* 
+/*
     saa6752hs.h - definition for saa6752hs MPEG encoder
 
     Copyright (C) 2003 Andrew de Quincey <adq@lidskialf.net>
@@ -31,14 +31,14 @@
 enum mpeg_audio_bitrate {
 	MPEG_AUDIO_BITRATE_256 = 0, /* 256 kBit/sec */
 	MPEG_AUDIO_BITRATE_384 = 1, /* 384 kBit/sec */
-    
+
 	MPEG_AUDIO_BITRATE_MAX
 };
 
 #define MPEG_VIDEO_TARGET_BITRATE_MAX 27000
 #define MPEG_VIDEO_MAX_BITRATE_MAX 27000
 #define MPEG_TOTAL_BITRATE_MAX 27000
-    
+
 struct mpeg_params {
 	enum mpeg_bitrate_mode bitrate_mode;
 	unsigned int video_target_bitrate;
diff -Nru a/include/media/saa7146.h b/include/media/saa7146.h
--- a/include/media/saa7146.h	2004-12-24 13:36:17 -08:00
+++ b/include/media/saa7146.h	2004-12-24 13:36:17 -08:00
@@ -51,10 +51,12 @@
 #define DEB_INT(x)  if (0!=(DEBUG_VARIABLE&0x20)) { DEBUG_PROLOG; printk x; } /* interrupt debug messages */
 #define DEB_CAP(x)  if (0!=(DEBUG_VARIABLE&0x40)) { DEBUG_PROLOG; printk x; } /* capture debug messages */
 
-#define IER_DISABLE(x,y) \
+#define SAA7146_IER_DISABLE(x,y) \
 	saa7146_write(x, IER, saa7146_read(x, IER) & ~(y));
-#define IER_ENABLE(x,y) \
+#define SAA7146_IER_ENABLE(x,y) \
 	saa7146_write(x, IER, saa7146_read(x, IER) | (y));
+#define SAA7146_ISR_CLEAR(x,y) \
+	saa7146_write(x, ISR, (y));
 
 struct saa7146_dev;
 struct saa7146_extension;
@@ -123,7 +125,7 @@
        	spinlock_t                 	slock;
         struct semaphore           	lock;
 
-	unsigned char			*mem;		/* pointer to mapped IO memory */
+	unsigned char			__iomem *mem;	/* pointer to mapped IO memory */
 	int				revision;	/* chip revision; needed for bug-workarounds*/
 
 	/* pci-device & irq stuff*/
@@ -154,7 +156,7 @@
 };
 
 /* from saa7146_i2c.c */
-int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, unsigned int class, u32 bitrate);
+int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate);
 int saa7146_i2c_transfer(struct saa7146_dev *saa, const struct i2c_msg msgs[], int num,  int retries);
 
 /* from saa7146_core.c */
@@ -168,7 +170,7 @@
 int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length );
 char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa7146_pgtable *pt);
 void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data);
-int saa7146_wait_for_debi_done(struct saa7146_dev *dev);
+int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop);
 
 /* some memory sizes */
 #define SAA7146_I2C_MEM		( 1*PAGE_SIZE)
diff -Nru a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
--- a/include/media/saa7146_vv.h	2004-12-24 13:36:18 -08:00
+++ b/include/media/saa7146_vv.h	2004-12-24 13:36:18 -08:00
@@ -35,6 +35,7 @@
 	u32	trans;
 	u8	depth;
 	u8	flags;
+	u8	swap;
 };
 
 struct saa7146_standard
@@ -188,8 +189,8 @@
 };
 
 /* from saa7146_fops.c */
-int saa7146_register_device(struct video_device *vid, struct saa7146_dev* dev, char *name, int type);
-int saa7146_unregister_device(struct video_device *vid, struct saa7146_dev* dev);
+int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, char *name, int type);
+int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev);
 void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, int state);
 void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi);
 int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf);
@@ -218,8 +219,6 @@
 
 /* resource management functions */
 int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit);
-int saa7146_res_check(struct saa7146_fh *fh, unsigned int bit);
-int saa7146_res_locked(struct saa7146_dev *dev, unsigned int bit);
 void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits);
 
 #define RESOURCE_DMA1_HPS	0x1
diff -Nru a/include/media/tuner.h b/include/media/tuner.h
--- a/include/media/tuner.h	2004-12-24 13:37:02 -08:00
+++ b/include/media/tuner.h	2004-12-24 13:37:02 -08:00
@@ -1,4 +1,5 @@
-/* 
+
+/*
     tuner.h - definition for different tuners
 
     Copyright (C) 1997 Markus Schroeder (schroedm@uni-duesseldorf.de)
@@ -69,9 +70,13 @@
 #define TUNER_PHILIPS_ATSC       42
 #define TUNER_PHILIPS_FM1236_MK3 43
 #define TUNER_PHILIPS_4IN1       44	/* ATI TV Wonder Pro - Conexant */
+/* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */
 #define TUNER_MICROTUNE_4049FM5  45
 #define TUNER_LG_NTSC_TAPE       47
 #define TUNER_TNF_8831BGFF       48
+#define TUNER_MICROTUNE_4042FI5  49	/* FusionHDTV 3 Gold - 4042 FI5 (3X 8147) */
+#define TUNER_TCL_2002N          50
+#define TUNER_PHILIPS_FM1256_IH3   51
 
 #define NOTUNER 0
 #define PAL     1	/* PAL_BG */
@@ -91,6 +96,7 @@
 #define Microtune 8
 #define HITACHI 9
 #define Panasonic 10
+#define TCL     11
 
 #define TUNER_SET_TYPE               _IOW('t',1,int)    /* set tuner type */
 #define TUNER_SET_TVFREQ             _IOW('t',2,int)    /* set tv freq */
diff -Nru a/include/media/video-buf-dvb.h b/include/media/video-buf-dvb.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/media/video-buf-dvb.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,34 @@
+#include <dvbdev.h>
+#include <dmxdev.h>
+#include <dvb_demux.h>
+#include <dvb_net.h>
+#include <dvb_frontend.h>
+
+struct videobuf_dvb {
+	/* filling that the job of the driver */
+	char                       *name;
+	struct dvb_frontend        *frontend;
+	struct videobuf_queue      dvbq;
+
+	/* video-buf-dvb state info */
+	struct semaphore           lock;
+	struct task_struct         *thread;
+	int                        nfeeds;
+
+	/* videobuf_dvb_(un)register manges this */
+	struct dvb_adapter         *adapter;
+	struct dvb_demux           demux;
+	struct dmxdev              dmxdev;
+	struct dmx_frontend        fe_hw;
+	struct dmx_frontend        fe_mem;
+	struct dvb_net             net;
+};
+
+int videobuf_dvb_register(struct videobuf_dvb *dvb);
+void videobuf_dvb_unregister(struct videobuf_dvb *dvb);
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -Nru a/include/media/video-buf.h b/include/media/video-buf.h
--- a/include/media/video-buf.h	2004-12-24 13:36:55 -08:00
+++ b/include/media/video-buf.h	2004-12-24 13:36:55 -08:00
@@ -1,4 +1,6 @@
 /*
+ * $Id: video-buf.h,v 1.9 2004/11/07 13:17:15 kraxel Exp $
+ *
  * generic helper functions for video4linux capture buffers, to handle
  * memory management and PCI DMA.  Right now bttv + saa7134 use it.
  *
@@ -7,7 +9,7 @@
  * into PAGE_SIZE chunks).  They also assume the driver does not need
  * to touch the video data (thus it is probably not useful for USB as
  * data often must be uncompressed by the drivers).
- * 
+ *
  * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -100,7 +102,7 @@
  * functions, additionally some commonly used fields for v4l buffers
  * (width, height, lists, waitqueue) are in there.  That struct should
  * be used as first element in the drivers buffer struct.
- * 
+ *
  * about the mmap helpers (videobuf_mmap_*):
  *
  * The mmaper function allows to map any subset of contingous buffers.
@@ -119,7 +121,6 @@
 
 struct videobuf_mapping {
 	unsigned int count;
-	int highmem_ok;
 	unsigned long start;
 	unsigned long end;
 	struct videobuf_queue *q;
@@ -165,12 +166,15 @@
 };
 
 struct videobuf_queue_ops {
-	int (*buf_setup)(struct file *file,
+	int (*buf_setup)(struct videobuf_queue *q,
 			 unsigned int *count, unsigned int *size);
-	int (*buf_prepare)(struct file *file,struct videobuf_buffer *vb,
+	int (*buf_prepare)(struct videobuf_queue *q,
+			   struct videobuf_buffer *vb,
 			   enum v4l2_field field);
-	void (*buf_queue)(struct file *file,struct videobuf_buffer *vb);
-	void (*buf_release)(struct file *file,struct videobuf_buffer *vb);
+	void (*buf_queue)(struct videobuf_queue *q,
+			  struct videobuf_buffer *vb);
+	void (*buf_release)(struct videobuf_queue *q,
+			    struct videobuf_buffer *vb);
 };
 
 struct videobuf_queue {
@@ -194,6 +198,9 @@
 	unsigned int               reading;
 	unsigned int               read_off;
 	struct videobuf_buffer     *read_buf;
+
+	/* driver private data */
+	void                       *priv_data;
 };
 
 void* videobuf_alloc(unsigned int size);
@@ -203,43 +210,46 @@
 
 void videobuf_queue_init(struct videobuf_queue *q,
 			 struct videobuf_queue_ops *ops,
-			 struct pci_dev *pci, spinlock_t *irqlock,
+			 struct pci_dev *pci,
+			 spinlock_t *irqlock,
 			 enum v4l2_buf_type type,
 			 enum v4l2_field field,
-			 unsigned int msize);
+			 unsigned int msize,
+			 void *priv);
 int  videobuf_queue_is_busy(struct videobuf_queue *q);
-void videobuf_queue_cancel(struct file *file, struct videobuf_queue *q);
+void videobuf_queue_cancel(struct videobuf_queue *q);
 
 enum v4l2_field videobuf_next_field(struct videobuf_queue *q);
 void videobuf_status(struct v4l2_buffer *b, struct videobuf_buffer *vb,
 		     enum v4l2_buf_type type);
-int videobuf_reqbufs(struct file *file, struct videobuf_queue *q,
+int videobuf_reqbufs(struct videobuf_queue *q,
 		     struct v4l2_requestbuffers *req);
 int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b);
-int videobuf_qbuf(struct file *file, struct videobuf_queue *q,
+int videobuf_qbuf(struct videobuf_queue *q,
 		  struct v4l2_buffer *b);
-int videobuf_dqbuf(struct file *file, struct videobuf_queue *q,
-		   struct v4l2_buffer *b);
-int videobuf_streamon(struct file *file, struct videobuf_queue *q);
-int videobuf_streamoff(struct file *file, struct videobuf_queue *q);
-
-int videobuf_read_start(struct file *file, struct videobuf_queue *q);
-void videobuf_read_stop(struct file *file, struct videobuf_queue *q);
-ssize_t videobuf_read_stream(struct file *file, struct videobuf_queue *q,
+int videobuf_dqbuf(struct videobuf_queue *q,
+		   struct v4l2_buffer *b, int nonblocking);
+int videobuf_streamon(struct videobuf_queue *q);
+int videobuf_streamoff(struct videobuf_queue *q);
+
+int videobuf_read_start(struct videobuf_queue *q);
+void videobuf_read_stop(struct videobuf_queue *q);
+ssize_t videobuf_read_stream(struct videobuf_queue *q,
 			     char __user *data, size_t count, loff_t *ppos,
-			     int vbihack);
-ssize_t videobuf_read_one(struct file *file, struct videobuf_queue *q,
-			  char __user *data, size_t count, loff_t *ppos);
+			     int vbihack, int nonblocking);
+ssize_t videobuf_read_one(struct videobuf_queue *q,
+			  char __user *data, size_t count, loff_t *ppos,
+			  int nonblocking);
 unsigned int videobuf_poll_stream(struct file *file,
 				  struct videobuf_queue *q,
 				  poll_table *wait);
 
-int videobuf_mmap_setup(struct file *file, struct videobuf_queue *q,
+int videobuf_mmap_setup(struct videobuf_queue *q,
 			unsigned int bcount, unsigned int bsize,
 			enum v4l2_memory memory);
-int videobuf_mmap_free(struct file *file, struct videobuf_queue *q);
-int videobuf_mmap_mapper(struct vm_area_struct *vma,
-			 struct videobuf_queue *q);
+int videobuf_mmap_free(struct videobuf_queue *q);
+int videobuf_mmap_mapper(struct videobuf_queue *q,
+			 struct vm_area_struct *vma);
 
 /* --------------------------------------------------------------------- */
 
diff -Nru a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
--- a/include/mtd/mtd-abi.h	2004-12-24 13:36:59 -08:00
+++ b/include/mtd/mtd-abi.h	2004-12-24 13:36:59 -08:00
@@ -1,11 +1,16 @@
 /*
- * $Id: mtd-abi.h,v 1.5 2004/06/22 09:29:35 gleixner Exp $
+ * $Id: mtd-abi.h,v 1.6 2004/08/09 13:38:30 dwmw2 Exp $
  *
  * Portions of MTD ABI definition which are shared by kernel and user space 
  */
 
 #ifndef __MTD_ABI_H__
 #define __MTD_ABI_H__
+
+#ifndef __KERNEL__ /* Urgh. The whole point of splitting this out into
+		    separate files was to avoid #ifdef __KERNEL__ */
+#define __user
+#endif
 
 struct erase_info_user {
 	uint32_t start;
diff -Nru a/include/net/act_api.h b/include/net/act_api.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/net/act_api.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,119 @@
+#ifndef __NET_ACT_API_H
+#define __NET_ACT_API_H
+
+/*
+ * Public police action API for classifiers/qdiscs
+ */
+
+#include <net/sch_generic.h>
+#include <net/pkt_sched.h>
+
+#define tca_gen(name) \
+struct tcf_##name *next; \
+	u32 index; \
+	int refcnt; \
+	int bindcnt; \
+	u32 capab; \
+	int action; \
+	struct tcf_t tm; \
+	struct gnet_stats_basic bstats; \
+	struct gnet_stats_queue qstats; \
+	struct gnet_stats_rate_est rate_est; \
+	spinlock_t *stats_lock; \
+	spinlock_t lock
+
+struct tcf_police
+{
+	tca_gen(police);
+	int		result;
+	u32		ewma_rate;
+	u32		burst;
+	u32		mtu;
+	u32		toks;
+	u32		ptoks;
+	psched_time_t	t_c;
+	struct qdisc_rate_table *R_tab;
+	struct qdisc_rate_table *P_tab;
+};
+
+#ifdef CONFIG_NET_CLS_ACT
+
+#define ACT_P_CREATED 1
+#define ACT_P_DELETED 1
+
+struct tcf_act_hdr
+{
+	tca_gen(act_hdr);
+};
+
+struct tc_action
+{
+	void *priv;
+	struct tc_action_ops *ops;
+	__u32   type;   /* for backward compat(TCA_OLD_COMPAT) */
+	__u32   order; 
+	struct tc_action *next;
+};
+
+#define TCA_CAP_NONE 0
+struct tc_action_ops
+{
+	struct tc_action_ops *next;
+	char    kind[IFNAMSIZ];
+	__u32   type; /* TBD to match kind */
+	__u32 	capab;  /* capabilities includes 4 bit version */
+	struct module		*owner;
+	int     (*act)(struct sk_buff **, struct tc_action *);
+	int     (*get_stats)(struct sk_buff *, struct tc_action *);
+	int     (*dump)(struct sk_buff *, struct tc_action *,int , int);
+	int     (*cleanup)(struct tc_action *, int bind);
+	int     (*lookup)(struct tc_action *, u32 );
+	int     (*init)(struct rtattr *,struct rtattr *,struct tc_action *, int , int );
+	int     (*walk)(struct sk_buff *, struct netlink_callback *, int , struct tc_action *);
+};
+
+extern int tcf_register_action(struct tc_action_ops *a);
+extern int tcf_unregister_action(struct tc_action_ops *a);
+extern void tcf_action_destroy(struct tc_action *a, int bind);
+extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res);
+extern int tcf_action_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,char *n, int ovr, int bind);
+extern int tcf_action_init_1(struct rtattr *rta, struct rtattr *est, struct tc_action *a,char *n, int ovr, int bind);
+extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
+extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
+extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
+extern int tcf_action_copy_stats (struct sk_buff *,struct tc_action *);
+extern int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,struct tc_action *,int , int );
+extern int tcf_act_police_dump(struct sk_buff *, struct tc_action *, int, int);
+extern int tcf_act_police(struct sk_buff **skb, struct tc_action *a);
+#endif /* CONFIG_NET_CLS_ACT */
+
+extern int tcf_police(struct sk_buff *skb, struct tcf_police *p);
+extern void tcf_police_destroy(struct tcf_police *p);
+extern struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est);
+extern int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p);
+extern int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *p);
+
+static inline int
+tcf_police_release(struct tcf_police *p, int bind)
+{
+	int ret = 0;
+#ifdef CONFIG_NET_CLS_ACT
+	if (p) {
+		if (bind) {
+			 p->bindcnt--;
+		}
+		p->refcnt--;
+		if (p->refcnt <= 0 && !p->bindcnt) {
+			tcf_police_destroy(p);
+			ret = 1;
+		}
+	}
+#else
+	if (p && --p->refcnt == 0)
+		tcf_police_destroy(p);
+
+#endif /* CONFIG_NET_CLS_ACT */
+	return ret;
+}
+
+#endif
diff -Nru a/include/net/addrconf.h b/include/net/addrconf.h
--- a/include/net/addrconf.h	2004-12-24 13:37:18 -08:00
+++ b/include/net/addrconf.h	2004-12-24 13:37:18 -08:00
@@ -67,8 +67,7 @@
 					       struct in6_addr *saddr);
 extern int			ipv6_dev_get_saddr(struct net_device *dev, 
 					       struct in6_addr *daddr,
-					       struct in6_addr *saddr,
-					       int onlink);
+					       struct in6_addr *saddr);
 extern int			ipv6_get_lladdr(struct net_device *dev, struct in6_addr *);
 extern int			ipv6_rcv_saddr_equal(const struct sock *sk, 
 						      const struct sock *sk2);
diff -Nru a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
--- a/include/net/bluetooth/bluetooth.h	2004-12-24 13:36:48 -08:00
+++ b/include/net/bluetooth/bluetooth.h	2004-12-24 13:36:48 -08:00
@@ -133,6 +133,7 @@
 int  bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
 
 void bt_accept_enqueue(struct sock *parent, struct sock *sk);
+void bt_accept_unlink(struct sock *sk);
 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock);
 
 /* Skb helpers */
diff -Nru a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
--- a/include/net/bluetooth/hci.h	2004-12-24 13:37:19 -08:00
+++ b/include/net/bluetooth/hci.h	2004-12-24 13:37:19 -08:00
@@ -68,7 +68,9 @@
 	HCI_ENCRYPT,
 	HCI_INQUIRY,
 
-	HCI_RAW
+	HCI_RAW,
+
+	HCI_SECMGR
 };
 
 /* HCI ioctl defines */
@@ -91,7 +93,8 @@
 #define HCISETLINKMODE	_IOW('H', 226, int)
 #define HCISETACLMTU	_IOW('H', 227, int)
 #define HCISETSCOMTU	_IOW('H', 228, int)
-#define HCISETRAWVND	_IOW('H', 229, int)
+
+#define HCISETSECMGR	_IOW('H', 230, int)
 
 #define HCIINQUIRY	_IOR('H', 240, int)
 
@@ -105,7 +108,7 @@
 #define HCI_ACLDATA_PKT		0x02
 #define HCI_SCODATA_PKT		0x03
 #define HCI_EVENT_PKT		0x04
-#define HCI_UNKNOWN_PKT		0xff
+#define HCI_VENDOR_PKT		0xff
 
 /* HCI Packet types */
 #define HCI_DM1		0x0008
@@ -167,6 +170,8 @@
 #define HCI_LM_AUTH	0x0002
 #define HCI_LM_ENCRYPT	0x0004
 #define HCI_LM_TRUSTED	0x0008
+#define HCI_LM_RELIABLE	0x0010
+#define HCI_LM_SECURE	0x0020
 
 /* -----  HCI Commands ---- */
 /* OGF & OCF values */
@@ -324,20 +329,28 @@
 #define OCF_INQUIRY_CANCEL	0x0002
 
 #define OCF_LINK_KEY_REPLY	0x000B
-#define OCF_LINK_KEY_NEG_REPLY	0x000C
 struct hci_cp_link_key_reply {
 	bdaddr_t bdaddr;
 	__u8     link_key[16];
 } __attribute__ ((packed));
 
+#define OCF_LINK_KEY_NEG_REPLY	0x000C
+struct hci_cp_link_key_neg_reply {
+	bdaddr_t bdaddr;
+} __attribute__ ((packed));
+
 #define OCF_PIN_CODE_REPLY	0x000D
-#define OCF_PIN_CODE_NEG_REPLY	0x000E
 struct hci_cp_pin_code_reply {
 	bdaddr_t bdaddr;
 	__u8     pin_len;
 	__u8     pin_code[16];
 } __attribute__ ((packed));
 
+#define OCF_PIN_CODE_NEG_REPLY	0x000E
+struct hci_cp_pin_code_neg_reply {
+	bdaddr_t bdaddr;
+} __attribute__ ((packed));
+
 #define OCF_CHANGE_CONN_PTYPE	0x000F
 struct hci_cp_change_conn_ptype {
 	__u16    handle;
@@ -355,6 +368,11 @@
 	__u8     encrypt;
 } __attribute__ ((packed));
 
+#define OCF_CHANGE_CONN_LINK_KEY 0x0015
+struct hci_cp_change_conn_link_key {
+	__u16    handle;
+} __attribute__ ((packed));
+
 #define OCF_READ_REMOTE_FEATURES 0x001B
 struct hci_cp_read_rmt_features {
 	__u16    handle;
@@ -471,6 +489,12 @@
 	__u8     encrypt;
 } __attribute__ ((packed));
 
+#define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE	0x09
+struct hci_ev_change_conn_link_key_complete {
+	__u8     status;
+	__u16    handle;
+} __attribute__ ((packed));
+
 #define HCI_EV_QOS_SETUP_COMPLETE	0x0D
 struct hci_qos {
 	__u8     service_type;
@@ -509,6 +533,14 @@
 	__u8     status;
 	bdaddr_t bdaddr;
 	__u8     role;
+} __attribute__ ((packed));
+
+#define HCI_EV_MODE_CHANGE	0x14
+struct hci_ev_mode_change {
+	__u8     status;
+	__u16    handle;
+	__u8     mode;
+	__u16    interval;
 } __attribute__ ((packed));
 
 #define HCI_EV_PIN_CODE_REQ	0x16
diff -Nru a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
--- a/include/net/bluetooth/hci_core.h	2004-12-24 13:36:55 -08:00
+++ b/include/net/bluetooth/hci_core.h	2004-12-24 13:36:55 -08:00
@@ -38,10 +38,20 @@
 
 /* HCI Core structures */
 
+struct inquiry_data {
+	bdaddr_t	bdaddr;
+	__u8		pscan_rep_mode;
+	__u8		pscan_period_mode;
+	__u8		pscan_mode;
+	__u8		dev_class[3];
+	__u16		clock_offset;
+	__s8		rssi;
+};
+
 struct inquiry_entry {
 	struct inquiry_entry 	*next;
 	__u32			timestamp;
-	struct inquiry_info	info;
+	struct inquiry_data	data;
 };
 
 struct inquiry_cache {
@@ -53,7 +63,8 @@
 struct hci_conn_hash {
 	struct list_head list;
 	spinlock_t       lock;
-	unsigned int     num;
+	unsigned int     acl_num;
+	unsigned int     sco_num;
 };
 
 struct hci_dev {
@@ -141,6 +152,7 @@
 	__u16		 state;
 	__u8		 type;
 	__u8		 out;
+	__u8		 dev_class[3];
 	__u32		 link_mode;
 	unsigned long	 pend;
 	
@@ -160,7 +172,9 @@
 
 extern struct hci_proto *hci_proto[];
 extern struct list_head hci_dev_list;
+extern struct list_head hci_cb_list;
 extern rwlock_t hci_dev_list_lock;
+extern rwlock_t hci_cb_list_lock;
 
 /* ----- Inquiry cache ----- */
 #define INQUIRY_CACHE_AGE_MAX   (HZ*30)   // 30 seconds
@@ -196,7 +210,7 @@
 }
 
 struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);
-void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_info *info);
+void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data);
 
 /* ----- HCI Connections ----- */
 enum {
@@ -209,21 +223,28 @@
 	struct hci_conn_hash *h = &hdev->conn_hash;
 	INIT_LIST_HEAD(&h->list);
 	spin_lock_init(&h->lock);
-	h->num = 0;
+	h->acl_num = 0;
+	h->sco_num = 0;
 }
 
 static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
 {
 	struct hci_conn_hash *h = &hdev->conn_hash;
 	list_add(&c->list, &h->list);
-	h->num++;
+	if (c->type == ACL_LINK)
+		h->acl_num++;
+	else
+		h->sco_num++;
 }
 
 static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
 {
 	struct hci_conn_hash *h = &hdev->conn_hash;
 	list_del(&c->list);
-	h->num--;
+	if (c->type == ACL_LINK)
+		h->acl_num--;
+	else
+		h->sco_num--;
 }
 
 static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
@@ -267,6 +288,7 @@
 struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *src);
 int hci_conn_auth(struct hci_conn *conn);
 int hci_conn_encrypt(struct hci_conn *conn);
+int hci_conn_change_link_key(struct hci_conn *conn);
 
 static inline void hci_conn_set_timer(struct hci_conn *conn, unsigned long timeout)
 {
@@ -483,6 +505,50 @@
 
 int hci_register_proto(struct hci_proto *hproto);
 int hci_unregister_proto(struct hci_proto *hproto);
+
+/* ----- HCI callbacks ----- */
+struct hci_cb {
+	struct list_head list;
+
+	char *name;
+
+	void (*auth_cfm)	(struct hci_conn *conn, __u8 status);
+	void (*encrypt_cfm)	(struct hci_conn *conn, __u8 status, __u8 encrypt);
+};
+
+static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
+{
+	struct list_head *p;
+
+	hci_proto_auth_cfm(conn, status);
+
+	read_lock_bh(&hci_cb_list_lock);
+	list_for_each(p, &hci_cb_list) {
+		struct hci_cb *cb = list_entry(p, struct hci_cb, list);
+		if (cb->auth_cfm)
+			cb->auth_cfm(conn, status);
+	}
+	read_unlock_bh(&hci_cb_list_lock);
+}
+
+static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt)
+{
+	struct list_head *p;
+
+	hci_proto_encrypt_cfm(conn, status);
+
+	read_lock_bh(&hci_cb_list_lock);
+	list_for_each(p, &hci_cb_list) {
+		struct hci_cb *cb = list_entry(p, struct hci_cb, list);
+		if (cb->encrypt_cfm)
+			cb->encrypt_cfm(conn, status, encrypt);
+	}
+	read_unlock_bh(&hci_cb_list_lock);
+}
+
+int hci_register_cb(struct hci_cb *hcb);
+int hci_unregister_cb(struct hci_cb *hcb);
+
 int hci_register_notifier(struct notifier_block *nb);
 int hci_unregister_notifier(struct notifier_block *nb);
 
diff -Nru a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
--- a/include/net/bluetooth/l2cap.h	2004-12-24 13:36:19 -08:00
+++ b/include/net/bluetooth/l2cap.h	2004-12-24 13:36:19 -08:00
@@ -56,6 +56,8 @@
 #define L2CAP_LM_AUTH		0x0002
 #define L2CAP_LM_ENCRYPT	0x0004
 #define L2CAP_LM_TRUSTED	0x0008
+#define L2CAP_LM_RELIABLE	0x0010
+#define L2CAP_LM_SECURE		0x0020
 
 #define L2CAP_QOS	0x04
 struct l2cap_qos {
diff -Nru a/include/net/dn_nsp.h b/include/net/dn_nsp.h
--- a/include/net/dn_nsp.h	2004-12-24 13:37:18 -08:00
+++ b/include/net/dn_nsp.h	2004-12-24 13:37:18 -08:00
@@ -37,7 +37,7 @@
 extern int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
 
 extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri);
-extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, int *err);
+extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err);
 
 #define NSP_REASON_OK 0		/* No error */
 #define NSP_REASON_NR 1		/* No resources */
diff -Nru a/include/net/dst.h b/include/net/dst.h
--- a/include/net/dst.h	2004-12-24 13:37:19 -08:00
+++ b/include/net/dst.h	2004-12-24 13:37:19 -08:00
@@ -67,7 +67,7 @@
 	struct xfrm_state	*xfrm;
 
 	int			(*input)(struct sk_buff*);
-	int			(*output)(struct sk_buff**);
+	int			(*output)(struct sk_buff*);
 
 #ifdef CONFIG_NET_CLS_ROUTE
 	__u32			tclassid;
@@ -103,19 +103,19 @@
 #ifdef __KERNEL__
 
 static inline u32
-dst_metric(struct dst_entry *dst, int metric)
+dst_metric(const struct dst_entry *dst, int metric)
 {
 	return dst->metrics[metric-1];
 }
 
 static inline u32
-dst_path_metric(struct dst_entry *dst, int metric)
+dst_path_metric(const struct dst_entry *dst, int metric)
 {
 	return dst->path->metrics[metric-1];
 }
 
 static inline u32
-dst_pmtu(struct dst_entry *dst)
+dst_pmtu(const struct dst_entry *dst)
 {
 	u32 mtu = dst_path_metric(dst, RTAX_MTU);
 	/* Yes, _exactly_. This is paranoia. */
@@ -142,16 +142,11 @@
 	return dst;
 }
 
-extern const char dst_underflow_bug_msg[];
-
 static inline
 void dst_release(struct dst_entry * dst)
 {
 	if (dst) {
-		if (atomic_read(&dst->__refcnt) < 1)
-			printk(dst_underflow_bug_msg, 
-			       atomic_read(&dst->__refcnt), 
-			       dst, current_text_addr());
+		WARN_ON(atomic_read(&dst->__refcnt) < 1);
 		atomic_dec(&dst->__refcnt);
 	}
 }
@@ -227,7 +222,7 @@
 	int err;
 
 	for (;;) {
-		err = skb->dst->output(&skb);
+		err = skb->dst->output(skb);
 
 		if (likely(err == 0))
 			return err;
diff -Nru a/include/net/gen_stats.h b/include/net/gen_stats.h
--- a/include/net/gen_stats.h	2004-12-24 13:37:18 -08:00
+++ b/include/net/gen_stats.h	2004-12-24 13:37:18 -08:00
@@ -41,5 +41,8 @@
 			     spinlock_t *stats_lock, struct rtattr *opt);
 extern void gen_kill_estimator(struct gnet_stats_basic *bstats,
 			       struct gnet_stats_rate_est *rate_est);
+extern int gen_replace_estimator(struct gnet_stats_basic *bstats,
+				 struct gnet_stats_rate_est *rate_est,
+				 spinlock_t *stats_lock, struct rtattr *opt);
 
 #endif
diff -Nru a/include/net/ip.h b/include/net/ip.h
--- a/include/net/ip.h	2004-12-24 13:37:02 -08:00
+++ b/include/net/ip.h	2004-12-24 13:37:02 -08:00
@@ -89,8 +89,8 @@
 			       struct packet_type *pt);
 extern int		ip_local_deliver(struct sk_buff *skb);
 extern int		ip_mr_input(struct sk_buff *skb);
-extern int		ip_output(struct sk_buff **pskb);
-extern int		ip_mc_output(struct sk_buff **pskb);
+extern int		ip_output(struct sk_buff *skb);
+extern int		ip_mc_output(struct sk_buff *skb);
 extern int		ip_fragment(struct sk_buff *skb, int (*out)(struct sk_buff*));
 extern int		ip_do_nat(struct sk_buff *skb);
 extern void		ip_send_check(struct iphdr *ip);
diff -Nru a/include/net/ip6_route.h b/include/net/ip6_route.h
--- a/include/net/ip6_route.h	2004-12-24 13:36:31 -08:00
+++ b/include/net/ip6_route.h	2004-12-24 13:36:31 -08:00
@@ -70,7 +70,7 @@
 extern struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
 					 struct neighbour *neigh,
 					 struct in6_addr *addr,
-					 int (*output)(struct sk_buff **));
+					 int (*output)(struct sk_buff *));
 extern int ndisc_dst_gc(int *more);
 extern void fib6_force_start_gc(void);
 
@@ -87,7 +87,7 @@
 extern struct rt6_info *	rt6_add_dflt_router(struct in6_addr *gwaddr,
 						    struct net_device *dev);
 
-extern void			rt6_purge_dflt_routers(int lst_resort);
+extern void			rt6_purge_dflt_routers(void);
 
 extern void			rt6_reset_dflt_pointer(struct rt6_info *rt);
 
diff -Nru a/include/net/ip_vs.h b/include/net/ip_vs.h
--- a/include/net/ip_vs.h	2004-12-24 13:36:17 -08:00
+++ b/include/net/ip_vs.h	2004-12-24 13:36:17 -08:00
@@ -8,7 +8,7 @@
 
 #include <asm/types.h>		/* For __uXX types */
 
-#define IP_VS_VERSION_CODE	0x010200
+#define IP_VS_VERSION_CODE	0x010201
 #define NVERSION(version)			\
 	(version >> 16) & 0xFF,			\
 	(version >> 8) & 0xFF,			\
@@ -358,6 +358,7 @@
 	NET_IPV4_VS_EXPIRE_NODEST_CONN=23,
 	NET_IPV4_VS_SYNC_THRESHOLD=24,
 	NET_IPV4_VS_NAT_ICMP_SEND=25,
+	NET_IPV4_VS_EXPIRE_QUIESCENT_TEMPLATE=26,
 	NET_IPV4_VS_LAST
 };
 
@@ -879,6 +880,7 @@
  */
 extern int sysctl_ip_vs_cache_bypass;
 extern int sysctl_ip_vs_expire_nodest_conn;
+extern int sysctl_ip_vs_expire_quiescent_template;
 extern int sysctl_ip_vs_sync_threshold[2];
 extern int sysctl_ip_vs_nat_icmp_send;
 extern struct ip_vs_stats ip_vs_stats;
diff -Nru a/include/net/ipv6.h b/include/net/ipv6.h
--- a/include/net/ipv6.h	2004-12-24 13:37:18 -08:00
+++ b/include/net/ipv6.h	2004-12-24 13:37:18 -08:00
@@ -296,6 +296,15 @@
 }
 #endif
 
+static inline int ipv6_addr_equal(const struct in6_addr *a1,
+				  const struct in6_addr *a2)
+{
+	return (a1->s6_addr32[0] == a2->s6_addr32[0] &&
+		a1->s6_addr32[1] == a2->s6_addr32[1] &&
+		a1->s6_addr32[2] == a2->s6_addr32[2] &&
+		a1->s6_addr32[3] == a2->s6_addr32[3]);
+}
+
 static inline int ipv6_addr_any(const struct in6_addr *a)
 {
 	return ((a->s6_addr32[0] | a->s6_addr32[1] | 
@@ -355,7 +364,7 @@
  *	skb processing functions
  */
 
-extern int			ip6_output(struct sk_buff **pskb);
+extern int			ip6_output(struct sk_buff *skb);
 extern int			ip6_forward(struct sk_buff *skb);
 extern int			ip6_input(struct sk_buff *skb);
 extern int			ip6_mc_input(struct sk_buff *skb);
diff -Nru a/include/net/irda/ircomm_tty_attach.h b/include/net/irda/ircomm_tty_attach.h
--- a/include/net/irda/ircomm_tty_attach.h	2004-12-24 13:37:19 -08:00
+++ b/include/net/irda/ircomm_tty_attach.h	2004-12-24 13:37:19 -08:00
@@ -72,7 +72,6 @@
 
 int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
 			struct sk_buff *skb, struct ircomm_tty_info *info);
-void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_STATE state);
 
 
 int  ircomm_tty_attach_cable(struct ircomm_tty_cb *self);
diff -Nru a/include/net/irda/irias_object.h b/include/net/irda/irias_object.h
--- a/include/net/irda/irias_object.h	2004-12-24 13:37:31 -08:00
+++ b/include/net/irda/irias_object.h	2004-12-24 13:37:31 -08:00
@@ -81,7 +81,8 @@
 struct ias_object *irias_new_object(char *name, int id);
 void irias_insert_object(struct ias_object *obj);
 int  irias_delete_object(struct ias_object *obj);
-int  irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib);
+int  irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib,
+			 int cleanobject);
 void __irias_delete_object(struct ias_object *obj);
 
 void irias_add_integer_attrib(struct ias_object *obj, char *name, int value,
diff -Nru a/include/net/irda/irlmp.h b/include/net/irda/irlmp.h
--- a/include/net/irda/irlmp.h	2004-12-24 13:36:17 -08:00
+++ b/include/net/irda/irlmp.h	2004-12-24 13:36:17 -08:00
@@ -175,7 +175,8 @@
 	discovery_t discovery_cmd; /* Discovery command to use by IrLAP */
 	discovery_t discovery_rsp; /* Discovery response to use by IrLAP */
 
-	int free_lsap_sel;
+	/* Last lsap picked automatically by irlmp_find_free_slsap() */
+	int	last_lsap_sel;
 
 	struct timer_list discovery_timer;
 
diff -Nru a/include/net/irda/timer.h b/include/net/irda/timer.h
--- a/include/net/irda/timer.h	2004-12-24 13:36:17 -08:00
+++ b/include/net/irda/timer.h	2004-12-24 13:36:17 -08:00
@@ -58,14 +58,16 @@
  *  Slot timer must never exceed 85 ms, and must always be at least 25 ms, 
  *  suggested to  75-85 msec by IrDA lite. This doesn't work with a lot of
  *  devices, and other stackes uses a lot more, so it's best we do it as well
+ *  (Note : this is the default value and sysctl overides it - Jean II)
  */
 #define SLOT_TIMEOUT            (90*HZ/1000)
 
 /* 
- *  We set the query timeout to 100 ms and then expect the value to be 
- *  multiplied with the number of slots to product the actual timeout value
+ *  The latest discovery frame (XID) is longer due to the extra discovery
+ *  information (hints, device name...). This is its extra length.
+ *  We use that when setting the query timeout. Jean II
  */
-#define QUERY_TIMEOUT           (HZ/10)       
+#define XIDEXTRA_TIMEOUT        (34*HZ/1000)  /* 34 msec */
 
 #define WATCHDOG_TIMEOUT        (20*HZ)       /* 20 sec */
 
@@ -85,7 +87,7 @@
 
 
 void irlap_start_slot_timer(struct irlap_cb *self, int timeout);
-void irlap_start_query_timer(struct irlap_cb *self, int timeout);
+void irlap_start_query_timer(struct irlap_cb *self, int S, int s);
 void irlap_start_final_timer(struct irlap_cb *self, int timeout);
 void irlap_start_wd_timer(struct irlap_cb *self, int timeout);
 void irlap_start_backoff_timer(struct irlap_cb *self, int timeout);
diff -Nru a/include/net/iw_handler.h b/include/net/iw_handler.h
--- a/include/net/iw_handler.h	2004-12-24 13:37:43 -08:00
+++ b/include/net/iw_handler.h	2004-12-24 13:37:43 -08:00
@@ -1,10 +1,10 @@
 /*
  * This file define the new driver API for Wireless Extensions
  *
- * Version :	5	4.12.02
+ * Version :	6	21.6.04
  *
  * Authors :	Jean Tourrilhes - HPL - <jt@hpl.hp.com>
- * Copyright (c) 2001-2002 Jean Tourrilhes, All Rights Reserved.
+ * Copyright (c) 2001-2004 Jean Tourrilhes, All Rights Reserved.
  */
 
 #ifndef _IW_HANDLER_H
@@ -198,6 +198,7 @@
 /***************************** INCLUDES *****************************/
 
 #include <linux/wireless.h>		/* IOCTL user space API */
+#include <linux/if_ether.h>
 
 /***************************** VERSION *****************************/
 /*
@@ -206,7 +207,7 @@
  * will be needed...
  * I just plan to increment with each new version.
  */
-#define IW_HANDLER_VERSION	5
+#define IW_HANDLER_VERSION	6
 
 /*
  * Changes :
@@ -224,11 +225,18 @@
  * V4 to V5
  * --------
  *	- Add new spy support : struct iw_spy_data & prototypes
+ *
+ * V5 to V6
+ * --------
+ *	- Change the way we get to spy_data method for added safety
+ *	- Remove spy #ifdef, they are always on -> cleaner code
+ *	- Add IW_DESCR_FLAG_NOMAX flag for very large requests
+ *	- Start migrating get_wireless_stats to struct iw_handler_def
  */
 
 /**************************** CONSTANTS ****************************/
 
-/* Enable enhanced spy support. Disable to reduce footprint */
+/* Enhanced spy support available */
 #define IW_WIRELESS_SPY
 #define IW_WIRELESS_THRSPY
 
@@ -258,6 +266,7 @@
 #define IW_DESCR_FLAG_EVENT	0x0002	/* Generate an event on SET */
 #define IW_DESCR_FLAG_RESTRICT	0x0004	/* GET : request is ROOT only */
 				/* SET : Omit payload from generated iwevent */
+#define IW_DESCR_FLAG_NOMAX	0x0008	/* GET : no limit on request size */
 /* Driver level flags */
 #define IW_DESCR_FLAG_WAIT	0x0100	/* Wait for driver event */
 
@@ -286,6 +295,8 @@
 	__u16		flags;		/* More to come ;-) */
 };
 
+struct net_device;
+
 /*
  * This is how a function handling a Wireless Extension should look
  * like (both get and set, standard and private).
@@ -311,23 +322,25 @@
 	/* Array of handlers for standard ioctls
 	 * We will call dev->wireless_handlers->standard[ioctl - SIOCSIWNAME]
 	 */
-	iw_handler *		standard;
+	const iw_handler *	standard;
 
 	/* Array of handlers for private ioctls
 	 * Will call dev->wireless_handlers->private[ioctl - SIOCIWFIRSTPRIV]
 	 */
-	iw_handler *		private;
+	const iw_handler *	private;
 
 	/* Arguments of private handler. This one is just a list, so you
 	 * can put it in any order you want and should not leave holes...
 	 * We will automatically export that to user space... */
-	struct iw_priv_args *	private_args;
+	const struct iw_priv_args *	private_args;
 
-	/* Driver enhanced spy support */
-	long			spy_offset;	/* Spy data offset */
+	/* This field will be *removed* in the next version of WE */
+	long			spy_offset;	/* DO NOT USE */
 
-	/* In the long term, get_wireless_stats will move from
-	 * 'struct net_device' to here, to minimise bloat. */
+	/* New location of get_wireless_stats, to de-bloat struct net_device.
+	 * The old pointer in struct net_device will be gradually phased
+	 * out, and drivers are encouraged to use this one... */
+	struct iw_statistics*	(*get_wireless_stats)(struct net_device *dev);
 };
 
 /* ---------------------- IOCTL DESCRIPTION ---------------------- */
@@ -374,18 +387,29 @@
  */
 struct iw_spy_data
 {
-#ifdef IW_WIRELESS_SPY
 	/* --- Standard spy support --- */
 	int			spy_number;
 	u_char			spy_address[IW_MAX_SPY][ETH_ALEN];
 	struct iw_quality	spy_stat[IW_MAX_SPY];
-#ifdef IW_WIRELESS_THRSPY
 	/* --- Enhanced spy support (event) */
 	struct iw_quality	spy_thr_low;	/* Low threshold */
 	struct iw_quality	spy_thr_high;	/* High threshold */
 	u_char			spy_thr_under[IW_MAX_SPY];
-#endif /* IW_WIRELESS_THRSPY */
-#endif /* IW_WIRELESS_SPY */
+};
+
+/* --------------------- DEVICE WIRELESS DATA --------------------- */
+/*
+ * This is all the wireless data specific to a device instance that
+ * is managed by the core of Wireless Extensions.
+ * We only keep pointer to those structures, so that a driver is free
+ * to share them between instances.
+ * This structure should be initialised before registering the device.
+ * Access to this data follow the same rules as any other struct net_device
+ * data (i.e. valid as long as struct net_device exist, same locking rules).
+ */
+struct iw_public_data {
+	/* Driver enhanced spy support */
+	struct iw_spy_data *	spy_data;
 };
 
 /**************************** PROTOTYPES ****************************/
@@ -393,6 +417,9 @@
  * Functions part of the Wireless Extensions (defined in net/core/wireless.c).
  * Those may be called only within the kernel.
  */
+
+/* Data needed by fs/compat_ioctl.c for 32->64 bit conversion */
+extern const char iw_priv_type_size[];
 
 /* First : function strictly used inside the kernel */
 
diff -Nru a/include/net/ndisc.h b/include/net/ndisc.h
--- a/include/net/ndisc.h	2004-12-24 13:37:18 -08:00
+++ b/include/net/ndisc.h	2004-12-24 13:37:18 -08:00
@@ -45,6 +45,11 @@
 	__u8		opt[0];
 };
 
+struct rs_msg {
+	struct icmp6hdr	icmph;
+	__u8		opt[0];
+};
+
 struct ra_msg {
         struct icmp6hdr		icmph;
 	__u32			reachable_time;
diff -Nru a/include/net/neighbour.h b/include/net/neighbour.h
--- a/include/net/neighbour.h	2004-12-24 13:37:29 -08:00
+++ b/include/net/neighbour.h	2004-12-24 13:37:29 -08:00
@@ -112,7 +112,11 @@
 };
 
 #define NEIGH_CACHE_STAT_INC(tbl, field)				\
-		(per_cpu_ptr((tbl)->stats, smp_processor_id())->field++)
+	do {								\
+		preempt_disable();					\
+		(per_cpu_ptr((tbl)->stats, smp_processor_id())->field)++; \
+		preempt_enable();					\
+	} while (0)
 
 struct neighbour
 {
@@ -185,7 +189,7 @@
 	struct timer_list 	gc_timer;
 	struct timer_list 	proxy_timer;
 	struct sk_buff_head	proxy_queue;
-	int			entries;
+	atomic_t		entries;
 	rwlock_t		lock;
 	unsigned long		last_rand;
 	struct neigh_parms	*parms_list;
diff -Nru a/include/net/pkt_act.h b/include/net/pkt_act.h
--- a/include/net/pkt_act.h	2004-12-24 13:37:18 -08:00
+++ b/include/net/pkt_act.h	2004-12-24 13:37:18 -08:00
@@ -3,7 +3,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -60,7 +60,7 @@
 			*p1p = p->next;
 			write_unlock_bh(&tcf_t_lock);
 #ifdef CONFIG_NET_ESTIMATOR
-			qdisc_kill_estimator(&p->stats);
+			gen_kill_estimator(&p->bstats, &p->rate_est);
 #endif
 			kfree(p);
 			return;
@@ -256,9 +256,8 @@
 	p->tm.install = jiffies;
 	p->tm.lastuse = jiffies;
 #ifdef CONFIG_NET_ESTIMATOR
-	if (est) {
-		qdisc_new_estimator(&p->stats, p->stats_lock, est);
-	}
+	if (est)
+		gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
 #endif
 	h = tcf_hash(p->index);
 	write_lock_bh(&tcf_t_lock);
diff -Nru a/include/net/pkt_cls.h b/include/net/pkt_cls.h
--- a/include/net/pkt_cls.h	2004-12-24 13:37:03 -08:00
+++ b/include/net/pkt_cls.h	2004-12-24 13:37:03 -08:00
@@ -1,36 +1,12 @@
 #ifndef __NET_PKT_CLS_H
 #define __NET_PKT_CLS_H
 
-
 #include <linux/pkt_cls.h>
-
-struct rtattr;
-struct tcmsg;
+#include <net/sch_generic.h>
+#include <net/act_api.h>
 
 /* Basic packet classifier frontend definitions. */
 
-struct tcf_result
-{
-	unsigned long	class;
-	u32		classid;
-};
-
-struct tcf_proto
-{
-	/* Fast access part */
-	struct tcf_proto	*next;
-	void			*root;
-	int			(*classify)(struct sk_buff*, struct tcf_proto*, struct tcf_result *);
-	u32			protocol;
-
-	/* All the rest */
-	u32			prio;
-	u32			classid;
-	struct Qdisc		*q;
-	void			*data;
-	struct tcf_proto_ops	*ops;
-};
-
 struct tcf_walker
 {
 	int	stop;
@@ -39,86 +15,216 @@
 	int	(*fn)(struct tcf_proto *, unsigned long node, struct tcf_walker *);
 };
 
-struct module;
+extern int register_tcf_proto_ops(struct tcf_proto_ops *ops);
+extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
+extern int ing_filter(struct sk_buff *skb);
 
-struct tcf_proto_ops
+static inline unsigned long
+__cls_set_class(unsigned long *clp, unsigned long cl)
 {
-	struct tcf_proto_ops	*next;
-	char			kind[IFNAMSIZ];
+	unsigned long old_cl;
+ 
+	old_cl = *clp;
+	*clp = cl;
+	return old_cl;
+}
 
-	int			(*classify)(struct sk_buff*, struct tcf_proto*, struct tcf_result *);
-	int			(*init)(struct tcf_proto*);
-	void			(*destroy)(struct tcf_proto*);
+static inline unsigned long
+cls_set_class(struct tcf_proto *tp, unsigned long *clp, 
+	unsigned long cl)
+{
+	unsigned long old_cl;
+	
+	tcf_tree_lock(tp);
+	old_cl = __cls_set_class(clp, cl);
+	tcf_tree_unlock(tp);
+ 
+	return old_cl;
+}
 
-	unsigned long		(*get)(struct tcf_proto*, u32 handle);
-	void			(*put)(struct tcf_proto*, unsigned long);
-	int			(*change)(struct tcf_proto*, unsigned long, u32 handle, struct rtattr **, unsigned long *);
-	int			(*delete)(struct tcf_proto*, unsigned long);
-	void			(*walk)(struct tcf_proto*, struct tcf_walker *arg);
+static inline void
+tcf_bind_filter(struct tcf_proto *tp, struct tcf_result *r, unsigned long base)
+{
+	unsigned long cl;
 
-	/* rtnetlink specific */
-	int			(*dump)(struct tcf_proto*, unsigned long, struct sk_buff *skb, struct tcmsg*);
+	cl = tp->q->ops->cl_ops->bind_tcf(tp->q, base, r->classid);
+	cl = cls_set_class(tp, &r->class, cl);
+	if (cl)
+		tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+}
 
-	struct module		*owner;
-};
+static inline void
+tcf_unbind_filter(struct tcf_proto *tp, struct tcf_result *r)
+{
+	unsigned long cl;
 
-/* Main classifier routine: scans classifier chain attached
-   to this qdisc, (optionally) tests for protocol and asks
-   specific classifiers.
- */
+	if ((cl = __cls_set_class(&r->class, 0)) != 0)
+		tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+}
 
-static inline int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res)
-{
-	int err = 0;
-	u32 protocol = skb->protocol;
-#ifdef CONFIG_NET_CLS_ACT
-	struct tcf_proto *otp = tp;
-reclassify:
-#endif
-	protocol = skb->protocol;
-
-	for ( ; tp; tp = tp->next) {
-		if ((tp->protocol == protocol ||
-			tp->protocol == __constant_htons(ETH_P_ALL)) &&
-			(err = tp->classify(skb, tp, res)) >= 0) {
 #ifdef CONFIG_NET_CLS_ACT
-			if ( TC_ACT_RECLASSIFY == err) {
-				__u32 verd = (__u32) G_TC_VERD(skb->tc_verd);
-				tp = otp;
-
-				if (MAX_REC_LOOP < verd++) {
-					printk("rule prio %d protocol %02x reclassify is buggy packet dropped\n",tp->prio&0xffff, ntohs(tp->protocol));
-					return TC_ACT_SHOT;
-				}
-				skb->tc_verd = SET_TC_VERD(skb->tc_verd,verd);
-				goto reclassify;
-			} else {
-				if (skb->tc_verd) 
-					skb->tc_verd = SET_TC_VERD(skb->tc_verd,0);
-				return err;
-			}
-#else
-
-			return err;
-#endif
-            }
+static inline int
+tcf_change_act_police(struct tcf_proto *tp, struct tc_action **action,
+	struct rtattr *act_police_tlv, struct rtattr *rate_tlv)
+{
+	int ret;
+	struct tc_action *act;
+
+	act = kmalloc(sizeof(*act), GFP_KERNEL);
+	if (NULL == act)
+		return -ENOMEM;
+	memset(act, 0, sizeof(*act));
+	
+	ret = tcf_action_init_1(act_police_tlv, rate_tlv, act, "police",
+		TCA_ACT_NOREPLACE, TCA_ACT_BIND);
+	if (ret < 0) {
+		tcf_action_destroy(act, TCA_ACT_UNBIND);
+		return ret;
+	}
+
+	act->type = TCA_OLD_COMPAT;
+
+	if (*action) {
+		tcf_tree_lock(tp);
+		act = xchg(action, act);
+		tcf_tree_unlock(tp);
+
+		tcf_action_destroy(act, TCA_ACT_UNBIND);
+	} else
+		*action = act;
+
+	return 0;
+}
+
+static inline int
+tcf_change_act(struct tcf_proto *tp, struct tc_action **action,
+	struct rtattr *act_tlv, struct rtattr *rate_tlv)
+{
+	int ret;
+	struct tc_action *act;
+
+	act = kmalloc(sizeof(*act), GFP_KERNEL);
+	if (NULL == act)
+		return -ENOMEM;
+	memset(act, 0, sizeof(*act));
+
+	ret = tcf_action_init(act_tlv, rate_tlv, act, NULL,
+		TCA_ACT_NOREPLACE, TCA_ACT_BIND);
+	if (ret < 0) {
+		tcf_action_destroy(act, TCA_ACT_UNBIND);
+		return ret;
+	}
+
+	if (*action) {
+		tcf_tree_lock(tp);
+		act = xchg(action, act);
+		tcf_tree_unlock(tp);
+
+		tcf_action_destroy(act, TCA_ACT_UNBIND);
+	} else
+		*action = act;
+
+	return 0;
+}
 
+static inline int
+tcf_dump_act(struct sk_buff *skb, struct tc_action *action,
+	int act_type, int compat_type)
+{
+	/*
+	 * again for backward compatible mode - we want
+	 * to work with both old and new modes of entering
+	 * tc data even if iproute2  was newer - jhs
+	 */
+	if (action) {
+		struct rtattr * p_rta = (struct rtattr*) skb->tail;
+
+		if (action->type != TCA_OLD_COMPAT) {
+			RTA_PUT(skb, act_type, 0, NULL);
+			if (tcf_action_dump(skb, action, 0, 0) < 0)
+				goto rtattr_failure;
+		} else {
+			RTA_PUT(skb, compat_type, 0, NULL);
+			if (tcf_action_dump_old(skb, action, 0, 0) < 0)
+				goto rtattr_failure;
+		}
+		
+		p_rta->rta_len = skb->tail - (u8*)p_rta;
 	}
+	return 0;
+
+rtattr_failure:
 	return -1;
 }
+#endif /* CONFIG_NET_CLS_ACT */
+
+#ifdef CONFIG_NET_CLS_IND
+static inline int
+tcf_change_indev(struct tcf_proto *tp, char *indev, struct rtattr *indev_tlv)
+{
+	if (RTA_PAYLOAD(indev_tlv) >= IFNAMSIZ) {
+		printk("cls: bad indev name %s\n", (char *) RTA_DATA(indev_tlv));
+		return -EINVAL;
+	}
 
-static inline void tcf_destroy(struct tcf_proto *tp)
+	memset(indev, 0, IFNAMSIZ);
+	sprintf(indev, "%s", (char *) RTA_DATA(indev_tlv));
+
+	return 0;
+}
+
+static inline int
+tcf_match_indev(struct sk_buff *skb, char *indev)
 {
-	tp->ops->destroy(tp);
-	module_put(tp->ops->owner);
-	kfree(tp);
+	if (0 != indev[0]) {
+		if  (NULL == skb->input_dev)
+			return 0;
+		else if (0 != strcmp(indev, skb->input_dev->name))
+			return 0;
+	}
+
+	return 1;
 }
+#endif /* CONFIG_NET_CLS_IND */
 
-extern int register_tcf_proto_ops(struct tcf_proto_ops *ops);
-extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
-extern int ing_filter(struct sk_buff *skb);
+#ifdef CONFIG_NET_CLS_POLICE
+static inline int
+tcf_change_police(struct tcf_proto *tp, struct tcf_police **police,
+	struct rtattr *police_tlv, struct rtattr *rate_tlv)
+{
+	struct tcf_police *p = tcf_police_locate(police_tlv, rate_tlv);
+
+	if (*police) {
+		tcf_tree_lock(tp);
+		p = xchg(police, p);
+		tcf_tree_unlock(tp);
 
+		tcf_police_release(p, TCA_ACT_UNBIND);
+	} else
+		*police = p;
 
+	return 0;
+}
+
+static inline int
+tcf_dump_police(struct sk_buff *skb, struct tcf_police *police,
+	int police_type)
+{
+	if (police) {
+		struct rtattr * p_rta = (struct rtattr*) skb->tail;
 
+		RTA_PUT(skb, police_type, 0, NULL);
+
+		if (tcf_police_dump(skb, police) < 0)
+			goto rtattr_failure;
+
+		p_rta->rta_len = skb->tail - (u8*)p_rta;
+	}
+	return 0;
+
+rtattr_failure:
+	return -1;
+}
+#endif /* CONFIG_NET_CLS_POLICE */
 
 #endif
diff -Nru a/include/net/pkt_sched.h b/include/net/pkt_sched.h
--- a/include/net/pkt_sched.h	2004-12-24 13:36:30 -08:00
+++ b/include/net/pkt_sched.h	2004-12-24 13:36:30 -08:00
@@ -1,17 +1,7 @@
 #ifndef __NET_PKT_SCHED_H
 #define __NET_PKT_SCHED_H
 
-#include <linux/config.h>
-#include <linux/netdevice.h>
-#include <linux/types.h>
-#include <linux/pkt_sched.h>
-#include <linux/rcupdate.h>
-#include <net/pkt_cls.h>
-#include <linux/module.h>
-#include <linux/rtnetlink.h>
-
-struct rtattr;
-struct Qdisc;
+#include <net/sch_generic.h>
 
 struct qdisc_walker
 {
@@ -21,82 +11,8 @@
 	int	(*fn)(struct Qdisc *, unsigned long cl, struct qdisc_walker *);
 };
 
-struct Qdisc_class_ops
-{
-	/* Child qdisc manipulation */
-	int			(*graft)(struct Qdisc *, unsigned long cl, struct Qdisc *, struct Qdisc **);
-	struct Qdisc *		(*leaf)(struct Qdisc *, unsigned long cl);
-
-	/* Class manipulation routines */
-	unsigned long		(*get)(struct Qdisc *, u32 classid);
-	void			(*put)(struct Qdisc *, unsigned long);
-	int			(*change)(struct Qdisc *, u32, u32, struct rtattr **, unsigned long *);
-	int			(*delete)(struct Qdisc *, unsigned long);
-	void			(*walk)(struct Qdisc *, struct qdisc_walker * arg);
-
-	/* Filter manipulation */
-	struct tcf_proto **	(*tcf_chain)(struct Qdisc *, unsigned long);
-	unsigned long		(*bind_tcf)(struct Qdisc *, unsigned long, u32 classid);
-	void			(*unbind_tcf)(struct Qdisc *, unsigned long);
-
-	/* rtnetlink specific */
-	int			(*dump)(struct Qdisc *, unsigned long, struct sk_buff *skb, struct tcmsg*);
-};
-
-struct module;
-
-struct Qdisc_ops
-{
-	struct Qdisc_ops	*next;
-	struct Qdisc_class_ops	*cl_ops;
-	char			id[IFNAMSIZ];
-	int			priv_size;
-
-	int 			(*enqueue)(struct sk_buff *, struct Qdisc *);
-	struct sk_buff *	(*dequeue)(struct Qdisc *);
-	int 			(*requeue)(struct sk_buff *, struct Qdisc *);
-	unsigned int		(*drop)(struct Qdisc *);
-
-	int			(*init)(struct Qdisc *, struct rtattr *arg);
-	void			(*reset)(struct Qdisc *);
-	void			(*destroy)(struct Qdisc *);
-	int			(*change)(struct Qdisc *, struct rtattr *arg);
-
-	int			(*dump)(struct Qdisc *, struct sk_buff *);
-
-	struct module		*owner;
-};
-
 extern rwlock_t qdisc_tree_lock;
 
-struct Qdisc
-{
-	int 			(*enqueue)(struct sk_buff *skb, struct Qdisc *dev);
-	struct sk_buff *	(*dequeue)(struct Qdisc *dev);
-	unsigned		flags;
-#define TCQ_F_BUILTIN	1
-#define TCQ_F_THROTTLED	2
-#define TCQ_F_INGRES	4
-	int			padded;
-	struct Qdisc_ops	*ops;
-	u32			handle;
-	u32			parent;
-	atomic_t		refcnt;
-	struct sk_buff_head	q;
-	struct net_device	*dev;
-	struct list_head	list;
-
-	struct tc_stats		stats;
-	spinlock_t		*stats_lock;
-	struct rcu_head 	q_rcu;
-	int			(*reshape_fail)(struct sk_buff *skb, struct Qdisc *q);
-
-	/* This field is deprecated, but it is still used by CBQ
-	 * and it will live until better solution will be invented.
-	 */
-	struct Qdisc		*__parent;
-};
-
 #define	QDISC_ALIGN		32
 #define	QDISC_ALIGN_CONST	(QDISC_ALIGN - 1)
 
@@ -106,34 +22,6 @@
 			      & ~QDISC_ALIGN_CONST);
 }
 
-struct qdisc_rate_table
-{
-	struct tc_ratespec rate;
-	u32		data[256];
-	struct qdisc_rate_table *next;
-	int		refcnt;
-};
-
-extern void qdisc_lock_tree(struct net_device *dev);
-extern void qdisc_unlock_tree(struct net_device *dev);
-
-#define sch_tree_lock(q)	qdisc_lock_tree((q)->dev)
-#define sch_tree_unlock(q)	qdisc_unlock_tree((q)->dev)
-#define tcf_tree_lock(tp)	qdisc_lock_tree((tp)->q->dev)
-#define tcf_tree_unlock(tp)	qdisc_unlock_tree((tp)->q->dev)
-
-#define cls_set_class(tp, clp, cl) tcf_set_class(tp, clp, cl)
-static inline unsigned long
-__cls_set_class(unsigned long *clp, unsigned long cl)
-{
-	unsigned long old_cl;
-
-	old_cl = *clp;
-	*clp = cl;
-	return old_cl;
-}
-
-
 /* 
    Timer resolution MUST BE < 10% of min_schedulable_packet_size/bandwidth
    
@@ -244,7 +132,18 @@
 	   __delta; \
 })
 
-extern int psched_tod_diff(int delta_sec, int bound);
+static inline int
+psched_tod_diff(int delta_sec, int bound)
+{
+	int delta;
+
+	if (bound <= 1000000 || delta_sec > (0x7FFFFFFF/1000000)-1)
+		return bound;
+	delta = delta_sec * 1000000;
+	if (delta > bound)
+		delta = bound;
+	return delta;
+}
 
 #define PSCHED_TDIFF_SAFE(tv1, tv2, bound) \
 ({ \
@@ -306,140 +205,37 @@
 
 #endif /* !CONFIG_NET_SCH_CLK_GETTIMEOFDAY */
 
-struct tcf_police
-{
-	struct tcf_police *next;
-	int		refcnt;
-#ifdef CONFIG_NET_CLS_ACT
-	int		bindcnt;
-#endif
-	u32		index;
-	int		action;
-	int		result;
-	u32		ewma_rate;
-	u32		burst;
-	u32		mtu;
-	u32		toks;
-	u32		ptoks;
-	psched_time_t	t_c;
-	spinlock_t	lock;
-	struct qdisc_rate_table *R_tab;
-	struct qdisc_rate_table *P_tab;
-
-	struct tc_stats	stats;
-	spinlock_t	*stats_lock;
-};
-
-#ifdef CONFIG_NET_CLS_ACT
-
-#define ACT_P_CREATED 1
-#define ACT_P_DELETED 1
-#define tca_gen(name) \
-struct tcf_##name *next; \
-	u32 index; \
-	int refcnt; \
-	int bindcnt; \
-	u32 capab; \
-	int action; \
-	struct tcf_t tm; \
-	struct tc_stats stats; \
-	spinlock_t *stats_lock; \
-	spinlock_t lock
-
-
-struct tc_action
-{
-	void *priv;
-	struct tc_action_ops *ops;
-	__u32   type;   /* for backward compat(TCA_OLD_COMPAT) */
-	__u32   order; 
-	struct tc_action *next;
-};
-
-#define TCA_CAP_NONE 0
-struct tc_action_ops
-{
-	struct tc_action_ops *next;
-	char    kind[IFNAMSIZ];
-	__u32   type; /* TBD to match kind */
-	__u32 	capab;  /* capabilities includes 4 bit version */
-	struct module		*owner;
-	int     (*act)(struct sk_buff **, struct tc_action *);
-	int     (*get_stats)(struct sk_buff *, struct tc_action *);
-	int     (*dump)(struct sk_buff *, struct tc_action *,int , int);
-	int     (*cleanup)(struct tc_action *, int bind);
-	int     (*lookup)(struct tc_action *, u32 );
-	int     (*init)(struct rtattr *,struct rtattr *,struct tc_action *, int , int );
-	int     (*walk)(struct sk_buff *, struct netlink_callback *, int , struct tc_action *);
-};
-
-extern int tcf_register_action(struct tc_action_ops *a);
-extern int tcf_unregister_action(struct tc_action_ops *a);
-extern void tcf_action_destroy(struct tc_action *a, int bind);
-extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res);
-extern int tcf_action_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,char *n, int ovr, int bind);
-extern int tcf_action_init_1(struct rtattr *rta, struct rtattr *est, struct tc_action *a,char *n, int ovr, int bind);
-extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
-extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
-extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
-extern int tcf_action_copy_stats (struct sk_buff *,struct tc_action *);
-extern int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,struct tc_action *,int , int );
-extern int tcf_act_police_dump(struct sk_buff *, struct tc_action *, int, int);
-extern int tcf_act_police(struct sk_buff **skb, struct tc_action *a);
-#endif
-
-extern unsigned long tcf_set_class(struct tcf_proto *tp, unsigned long *clp, 
-				   unsigned long cl);
-extern int tcf_police(struct sk_buff *skb, struct tcf_police *p);
-extern int qdisc_copy_stats(struct sk_buff *skb, struct tc_stats *st, spinlock_t *lock);
-extern void tcf_police_destroy(struct tcf_police *p);
-extern struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est);
-extern int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p);
-
-static inline int tcf_police_release(struct tcf_police *p, int bind)
-{
-	int ret = 0;
-#ifdef CONFIG_NET_CLS_ACT
-	if (p) {
-		if (bind) {
-			 p->bindcnt--;
-		}
-		p->refcnt--;
-		if (p->refcnt <= 0 && !p->bindcnt) {
-			tcf_police_destroy(p);
-			ret = 1;
-		}
-	}
-#else
-	if (p && --p->refcnt == 0)
-		tcf_police_destroy(p);
-
-#endif
-	return ret;
-}
-
 extern struct Qdisc noop_qdisc;
 extern struct Qdisc_ops noop_qdisc_ops;
 extern struct Qdisc_ops pfifo_qdisc_ops;
 extern struct Qdisc_ops bfifo_qdisc_ops;
 
-int register_qdisc(struct Qdisc_ops *qops);
-int unregister_qdisc(struct Qdisc_ops *qops);
-struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle);
-struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle);
-void dev_init_scheduler(struct net_device *dev);
-void dev_shutdown(struct net_device *dev);
-void dev_activate(struct net_device *dev);
-void dev_deactivate(struct net_device *dev);
-void qdisc_reset(struct Qdisc *qdisc);
-void qdisc_destroy(struct Qdisc *qdisc);
-struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops);
-int qdisc_new_estimator(struct tc_stats *stats, spinlock_t *stats_lock, struct rtattr *opt);
-void qdisc_kill_estimator(struct tc_stats *stats);
-struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct rtattr *tab);
-void qdisc_put_rtab(struct qdisc_rate_table *tab);
+extern int register_qdisc(struct Qdisc_ops *qops);
+extern int unregister_qdisc(struct Qdisc_ops *qops);
+extern struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle);
+extern struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle);
+extern void dev_init_scheduler(struct net_device *dev);
+extern void dev_shutdown(struct net_device *dev);
+extern void dev_activate(struct net_device *dev);
+extern void dev_deactivate(struct net_device *dev);
+extern void qdisc_reset(struct Qdisc *qdisc);
+extern void qdisc_destroy(struct Qdisc *qdisc);
+extern struct Qdisc * qdisc_create_dflt(struct net_device *dev,
+	struct Qdisc_ops *ops);
+extern struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r,
+		struct rtattr *tab);
+extern void qdisc_put_rtab(struct qdisc_rate_table *tab);
 
 extern int qdisc_restart(struct net_device *dev);
+
+static inline void qdisc_run(struct net_device *dev)
+{
+	while (!netif_queue_stopped(dev) && qdisc_restart(dev) < 0)
+		/* NOTHING */;
+}
+
+extern int tc_classify(struct sk_buff *skb, struct tcf_proto *tp,
+	struct tcf_result *res);
 
 /* Calculate maximal size of packet seen by hard_start_xmit
    routine of this device.
diff -Nru a/include/net/sch_generic.h b/include/net/sch_generic.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/net/sch_generic.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,175 @@
+#ifndef __NET_SCHED_GENERIC_H
+#define __NET_SCHED_GENERIC_H
+
+#include <linux/config.h>
+#include <linux/netdevice.h>
+#include <linux/types.h>
+#include <linux/rcupdate.h>
+#include <linux/module.h>
+#include <linux/rtnetlink.h>
+#include <linux/pkt_sched.h>
+#include <linux/pkt_cls.h>
+#include <net/gen_stats.h>
+
+struct Qdisc_ops;
+struct qdisc_walker;
+struct tcf_walker;
+struct module;
+
+struct qdisc_rate_table
+{
+	struct tc_ratespec rate;
+	u32		data[256];
+	struct qdisc_rate_table *next;
+	int		refcnt;
+};
+
+struct Qdisc
+{
+	int 			(*enqueue)(struct sk_buff *skb, struct Qdisc *dev);
+	struct sk_buff *	(*dequeue)(struct Qdisc *dev);
+	unsigned		flags;
+#define TCQ_F_BUILTIN	1
+#define TCQ_F_THROTTLED	2
+#define TCQ_F_INGRESS	4
+	int			padded;
+	struct Qdisc_ops	*ops;
+	u32			handle;
+	u32			parent;
+	atomic_t		refcnt;
+	struct sk_buff_head	q;
+	struct net_device	*dev;
+	struct list_head	list;
+
+	struct gnet_stats_basic	bstats;
+	struct gnet_stats_queue	qstats;
+	struct gnet_stats_rate_est	rate_est;
+	spinlock_t		*stats_lock;
+	struct rcu_head 	q_rcu;
+	int			(*reshape_fail)(struct sk_buff *skb,
+					struct Qdisc *q);
+
+	/* This field is deprecated, but it is still used by CBQ
+	 * and it will live until better solution will be invented.
+	 */
+	struct Qdisc		*__parent;
+};
+
+struct Qdisc_class_ops
+{
+	/* Child qdisc manipulation */
+	int			(*graft)(struct Qdisc *, unsigned long cl,
+					struct Qdisc *, struct Qdisc **);
+	struct Qdisc *		(*leaf)(struct Qdisc *, unsigned long cl);
+
+	/* Class manipulation routines */
+	unsigned long		(*get)(struct Qdisc *, u32 classid);
+	void			(*put)(struct Qdisc *, unsigned long);
+	int			(*change)(struct Qdisc *, u32, u32,
+					struct rtattr **, unsigned long *);
+	int			(*delete)(struct Qdisc *, unsigned long);
+	void			(*walk)(struct Qdisc *, struct qdisc_walker * arg);
+
+	/* Filter manipulation */
+	struct tcf_proto **	(*tcf_chain)(struct Qdisc *, unsigned long);
+	unsigned long		(*bind_tcf)(struct Qdisc *, unsigned long,
+					u32 classid);
+	void			(*unbind_tcf)(struct Qdisc *, unsigned long);
+
+	/* rtnetlink specific */
+	int			(*dump)(struct Qdisc *, unsigned long,
+					struct sk_buff *skb, struct tcmsg*);
+	int			(*dump_stats)(struct Qdisc *, unsigned long,
+					struct gnet_dump *);
+};
+
+struct Qdisc_ops
+{
+	struct Qdisc_ops	*next;
+	struct Qdisc_class_ops	*cl_ops;
+	char			id[IFNAMSIZ];
+	int			priv_size;
+
+	int 			(*enqueue)(struct sk_buff *, struct Qdisc *);
+	struct sk_buff *	(*dequeue)(struct Qdisc *);
+	int 			(*requeue)(struct sk_buff *, struct Qdisc *);
+	unsigned int		(*drop)(struct Qdisc *);
+
+	int			(*init)(struct Qdisc *, struct rtattr *arg);
+	void			(*reset)(struct Qdisc *);
+	void			(*destroy)(struct Qdisc *);
+	int			(*change)(struct Qdisc *, struct rtattr *arg);
+
+	int			(*dump)(struct Qdisc *, struct sk_buff *);
+	int			(*dump_stats)(struct Qdisc *, struct gnet_dump *);
+
+	struct module		*owner;
+};
+
+
+struct tcf_result
+{
+	unsigned long	class;
+	u32		classid;
+};
+
+struct tcf_proto_ops
+{
+	struct tcf_proto_ops	*next;
+	char			kind[IFNAMSIZ];
+
+	int			(*classify)(struct sk_buff*, struct tcf_proto*,
+					struct tcf_result *);
+	int			(*init)(struct tcf_proto*);
+	void			(*destroy)(struct tcf_proto*);
+
+	unsigned long		(*get)(struct tcf_proto*, u32 handle);
+	void			(*put)(struct tcf_proto*, unsigned long);
+	int			(*change)(struct tcf_proto*, unsigned long,
+					u32 handle, struct rtattr **,
+					unsigned long *);
+	int			(*delete)(struct tcf_proto*, unsigned long);
+	void			(*walk)(struct tcf_proto*, struct tcf_walker *arg);
+
+	/* rtnetlink specific */
+	int			(*dump)(struct tcf_proto*, unsigned long,
+					struct sk_buff *skb, struct tcmsg*);
+
+	struct module		*owner;
+};
+
+struct tcf_proto
+{
+	/* Fast access part */
+	struct tcf_proto	*next;
+	void			*root;
+	int			(*classify)(struct sk_buff*, struct tcf_proto*,
+					struct tcf_result *);
+	u32			protocol;
+
+	/* All the rest */
+	u32			prio;
+	u32			classid;
+	struct Qdisc		*q;
+	void			*data;
+	struct tcf_proto_ops	*ops;
+};
+
+
+extern void qdisc_lock_tree(struct net_device *dev);
+extern void qdisc_unlock_tree(struct net_device *dev);
+
+#define sch_tree_lock(q)	qdisc_lock_tree((q)->dev)
+#define sch_tree_unlock(q)	qdisc_unlock_tree((q)->dev)
+#define tcf_tree_lock(tp)	qdisc_lock_tree((tp)->q->dev)
+#define tcf_tree_unlock(tp)	qdisc_unlock_tree((tp)->q->dev)
+
+static inline void
+tcf_destroy(struct tcf_proto *tp)
+{
+	tp->ops->destroy(tp);
+	module_put(tp->ops->owner);
+	kfree(tp);
+}
+
+#endif
diff -Nru a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
--- a/include/net/sctp/sctp.h	2004-12-24 13:36:31 -08:00
+++ b/include/net/sctp/sctp.h	2004-12-24 13:36:31 -08:00
@@ -335,7 +335,7 @@
 /* Map an association to an assoc_id. */
 static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc)
 {
-	return (asoc?asoc->assoc_id:NULL);
+	return (asoc?asoc->assoc_id:0);
 }
 
 /* Look up the association by its id.  */
@@ -607,14 +607,14 @@
 
 /* Is a socket of this style? */
 #define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style))
-int static inline __sctp_style(const struct sock *sk, sctp_socket_type_t style)
+static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style)
 {
 	return sctp_sk(sk)->type == style;
 }
 
 /* Is the association in this state? */
 #define sctp_state(asoc, state) __sctp_state((asoc), (SCTP_STATE_##state))
-int static inline __sctp_state(const struct sctp_association *asoc,
+static inline int __sctp_state(const struct sctp_association *asoc,
 			       sctp_state_t state)
 {
 	return asoc->state == state;
@@ -622,7 +622,7 @@
 
 /* Is the socket in this state? */
 #define sctp_sstate(sk, state) __sctp_sstate((sk), (SCTP_SS_##state))
-int static inline __sctp_sstate(const struct sock *sk, sctp_sock_state_t state)
+static inline int __sctp_sstate(const struct sock *sk, sctp_sock_state_t state)
 {
 	return sk->sk_state == state;
 }
diff -Nru a/include/net/sctp/structs.h b/include/net/sctp/structs.h
--- a/include/net/sctp/structs.h	2004-12-24 13:37:31 -08:00
+++ b/include/net/sctp/structs.h	2004-12-24 13:37:31 -08:00
@@ -266,6 +266,7 @@
 	__u8 disable_fragments;
 	__u8 pd_mode;
 	__u8 v4mapped;
+	__u32 adaption_ind;
 
 	/* Receive to here while partial delivery is in effect. */
 	struct sk_buff_head pd_lobby;
@@ -323,6 +324,8 @@
 
 	__u8 prsctp_capable;
 
+	__u32 adaption_ind;	
+
 	/* This is a shim for my peer's INIT packet, followed by
 	 * a copy of the raw address list of the association.
 	 * The length of the raw address list is saved in the
@@ -362,6 +365,7 @@
 	struct sctp_ipv4addr_param *v4;
 	struct sctp_ipv6addr_param *v6;
 	union sctp_addr_param *addr;
+	struct sctp_adaption_ind_param *aind;
 };
 
 /* RFC 2960.  Section 3.3.5 Heartbeat.
@@ -1394,6 +1398,8 @@
 		__u8	hostname_address;/* Peer understands DNS addresses? */
 		__u8    asconf_capable;  /* Does peer support ADDIP? */
 		__u8    prsctp_capable;  /* Can peer do PR-SCTP? */
+
+		__u32   adaption_ind;	 /* Adaption Code point. */
 
 		/* This mask is used to disable sending the ASCONF chunk
 		 * with specified parameter to peer.
diff -Nru a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h
--- a/include/net/sctp/ulpevent.h	2004-12-24 13:36:18 -08:00
+++ b/include/net/sctp/ulpevent.h	2004-12-24 13:36:18 -08:00
@@ -121,6 +121,9 @@
 	const struct sctp_association *asoc,
 	__u32 indication, int gfp);
 
+struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
+	const struct sctp_association *asoc, int gfp);
+
 struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
 	struct sctp_chunk *chunk,
 	int gfp);
diff -Nru a/include/net/sctp/user.h b/include/net/sctp/user.h
--- a/include/net/sctp/user.h	2004-12-24 13:36:17 -08:00
+++ b/include/net/sctp/user.h	2004-12-24 13:36:17 -08:00
@@ -55,7 +55,7 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 
-typedef void * sctp_assoc_t;
+typedef __s32 sctp_assoc_t;
 
 /* The following symbols come from the Sockets API Extensions for
  * SCTP <draft-ietf-tsvwg-sctpsocket-07.txt>.
@@ -338,8 +338,8 @@
 /*
  * 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
  *
- *   When a reciever is engaged in a partial delivery of a
- *   message this notification will be used to inidicate
+ *   When a receiver is engaged in a partial delivery of a
+ *   message this notification will be used to indicate
  *   various events.
  */
 struct sctp_pdapi_event {
diff -Nru a/include/net/sock.h b/include/net/sock.h
--- a/include/net/sock.h	2004-12-24 13:37:03 -08:00
+++ b/include/net/sock.h	2004-12-24 13:37:03 -08:00
@@ -556,6 +556,8 @@
 	kmem_cache_t		*slab;
 	int			slab_obj_size;
 
+	struct module		*owner;
+
 	char			name[32];
 
 	struct {
@@ -698,8 +700,6 @@
  * Since ~2.3.5 it is also exclusive sleep lock serializing
  * accesses from user process context.
  */
-extern void __lock_sock(struct sock *sk);
-extern void __release_sock(struct sock *sk);
 #define sock_owned_by_user(sk)	((sk)->sk_lock.owner)
 
 extern void FASTCALL(lock_sock(struct sock *sk));
@@ -746,7 +746,6 @@
  * Functions to fill in entries in struct proto_ops when a protocol
  * does not implement a particular function.
  */
-extern int                      sock_no_release(struct socket *);
 extern int                      sock_no_bind(struct socket *, 
 					     struct sockaddr *, int);
 extern int                      sock_no_connect(struct socket *,
@@ -1273,20 +1272,7 @@
 	__kfree_skb(skb);
 }
 
-extern atomic_t netstamp_needed;
 extern void sock_enable_timestamp(struct sock *sk);
-extern void sock_disable_timestamp(struct sock *sk);
-
-static inline void net_timestamp(struct timeval *stamp) 
-{ 
-	if (atomic_read(&netstamp_needed)) 
-		do_gettimeofday(stamp);
-	else {
-		stamp->tv_sec = 0;
-		stamp->tv_usec = 0;
-	}		
-} 
-
 extern int sock_get_timestamp(struct sock *, struct timeval __user *);
 
 /* 
@@ -1336,6 +1322,13 @@
 extern __u32 sysctl_wmem_max;
 extern __u32 sysctl_rmem_max;
 
+#ifdef CONFIG_NET
 int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
+#else
+static inline int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	return -ENODEV;
+}
+#endif
 
 #endif	/* _SOCK_H */
diff -Nru a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h
--- a/include/net/tc_act/tc_gact.h	2004-12-24 13:37:00 -08:00
+++ b/include/net/tc_act/tc_gact.h	2004-12-24 13:37:00 -08:00
@@ -1,7 +1,7 @@
 #ifndef __NET_TC_GACT_H
 #define __NET_TC_GACT_H
 
-#include <net/pkt_sched.h>
+#include <net/act_api.h>
 
 struct tcf_gact
 {
diff -Nru a/include/net/tc_act/tc_ipt.h b/include/net/tc_act/tc_ipt.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/net/tc_act/tc_ipt.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,16 @@
+#ifndef __NET_TC_IPT_H
+#define __NET_TC_IPT_H
+
+#include <net/act_api.h>
+
+struct ipt_entry_target;
+
+struct tcf_ipt
+{
+	tca_gen(ipt);
+	u32 hook;
+	char *tname;
+	struct ipt_entry_target *t;
+};
+
+#endif
diff -Nru a/include/net/tc_act/tc_mirred.h b/include/net/tc_act/tc_mirred.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/net/tc_act/tc_mirred.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,15 @@
+#ifndef __NET_TC_MIR_H
+#define __NET_TC_MIR_H
+
+#include <net/act_api.h>
+
+struct tcf_mirred
+{
+	tca_gen(mirred);
+	int eaction;
+	int ifindex;
+	int ok_push;
+	struct net_device *dev;
+};
+
+#endif
diff -Nru a/include/net/tc_act/tc_pedit.h b/include/net/tc_act/tc_pedit.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/net/tc_act/tc_pedit.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,14 @@
+#ifndef __NET_TC_PED_H
+#define __NET_TC_PED_H
+
+#include <net/act_api.h>
+
+struct tcf_pedit
+{
+	tca_gen(pedit);
+	unsigned char           nkeys;
+	unsigned char           flags;
+	struct tc_pedit_key     keys[0];
+};
+
+#endif
diff -Nru a/include/net/tcp.h b/include/net/tcp.h
--- a/include/net/tcp.h	2004-12-24 13:36:18 -08:00
+++ b/include/net/tcp.h	2004-12-24 13:36:18 -08:00
@@ -159,7 +159,6 @@
 extern void tcp_bucket_destroy(struct tcp_bind_bucket *tb);
 extern void tcp_bucket_unlock(struct sock *sk);
 extern int tcp_port_rover;
-extern struct sock *tcp_v4_lookup_listener(u32 addr, unsigned short hnum, int dif);
 
 /* These are AF independent. */
 static __inline__ int tcp_bhashfn(__u16 lport)
@@ -362,8 +361,8 @@
 #define TCP_IPV6_MATCH(__sk, __saddr, __daddr, __ports, __dif)	   \
 	(((*((__u32 *)&(inet_sk(__sk)->dport)))== (__ports))   	&& \
 	 ((__sk)->sk_family		== AF_INET6)		&& \
-	 !ipv6_addr_cmp(&inet6_sk(__sk)->daddr, (__saddr))	&& \
-	 !ipv6_addr_cmp(&inet6_sk(__sk)->rcv_saddr, (__daddr))	&& \
+	 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr))	&& \
+	 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr))	&& \
 	 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
 
 /* These can have wildcards, don't try too hard. */
@@ -961,12 +960,14 @@
 extern void tcp_init_xmit_timers(struct sock *);
 extern void tcp_clear_xmit_timers(struct sock *);
 
-extern void tcp_delete_keepalive_timer (struct sock *);
-extern void tcp_reset_keepalive_timer (struct sock *, unsigned long);
+extern void tcp_delete_keepalive_timer(struct sock *);
+extern void tcp_reset_keepalive_timer(struct sock *, unsigned long);
 extern unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu);
 extern unsigned int tcp_current_mss(struct sock *sk, int large);
 
-extern const char timer_bug_msg[];
+#ifdef TCP_DEBUG
+extern const char tcp_timer_bug_msg[];
+#endif
 
 /* tcp_diag.c */
 extern void tcp_get_info(struct sock *, struct tcp_info *);
@@ -999,7 +1000,9 @@
 #endif
 		break;
 	default:
-		printk(timer_bug_msg);
+#ifdef TCP_DEBUG
+		printk(tcp_timer_bug_msg);
+#endif
 		return;
 	};
 
@@ -1034,7 +1037,9 @@
 		break;
 
 	default:
-		printk(timer_bug_msg);
+#ifdef TCP_DEBUG
+		printk(tcp_timer_bug_msg);
+#endif
 	};
 }
 
@@ -1083,7 +1088,7 @@
  * Rcv_nxt can be after the window if our peer push more data
  * than the offered window.
  */
-static __inline__ u32 tcp_receive_window(struct tcp_opt *tp)
+static __inline__ u32 tcp_receive_window(const struct tcp_opt *tp)
 {
 	s32 win = tp->rcv_wup + tp->rcv_wnd - tp->rcv_nxt;
 
@@ -1161,18 +1166,19 @@
 /* Due to TSO, an SKB can be composed of multiple actual
  * packets.  To keep these tracked properly, we use this.
  */
-static inline int tcp_skb_pcount(struct sk_buff *skb)
+static inline int tcp_skb_pcount(const struct sk_buff *skb)
 {
 	return skb_shinfo(skb)->tso_segs;
 }
 
 /* This is valid iff tcp_skb_pcount() > 1. */
-static inline int tcp_skb_mss(struct sk_buff *skb)
+static inline int tcp_skb_mss(const struct sk_buff *skb)
 {
 	return skb_shinfo(skb)->tso_size;
 }
 
-static inline void tcp_inc_pcount(tcp_pcount_t *count, struct sk_buff *skb)
+static inline void tcp_inc_pcount(tcp_pcount_t *count,
+				  const struct sk_buff *skb)
 {
 	count->val += tcp_skb_pcount(skb);
 }
@@ -1187,13 +1193,14 @@
 	count->val -= amt;
 }
 
-static inline void tcp_dec_pcount(tcp_pcount_t *count, struct sk_buff *skb)
+static inline void tcp_dec_pcount(tcp_pcount_t *count, 
+				  const struct sk_buff *skb)
 {
 	count->val -= tcp_skb_pcount(skb);
 }
 
 static inline void tcp_dec_pcount_approx(tcp_pcount_t *count,
-					 struct sk_buff *skb)
+					 const struct sk_buff *skb)
 {
 	if (count->val) {
 		count->val -= tcp_skb_pcount(skb);
@@ -1202,7 +1209,7 @@
 	}
 }
 
-static inline __u32 tcp_get_pcount(tcp_pcount_t *count)
+static inline __u32 tcp_get_pcount(const tcp_pcount_t *count)
 {
 	return count->val;
 }
@@ -1212,8 +1219,9 @@
 	count->val = val;
 }
 
-static inline void tcp_packets_out_inc(struct sock *sk, struct tcp_opt *tp,
-				       struct sk_buff *skb)
+static inline void tcp_packets_out_inc(struct sock *sk, 
+				       struct tcp_opt *tp,
+				       const struct sk_buff *skb)
 {
 	int orig = tcp_get_pcount(&tp->packets_out);
 
@@ -1222,7 +1230,8 @@
 		tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS, tp->rto);
 }
 
-static inline void tcp_packets_out_dec(struct tcp_opt *tp, struct sk_buff *skb)
+static inline void tcp_packets_out_dec(struct tcp_opt *tp, 
+				       const struct sk_buff *skb)
 {
 	tcp_dec_pcount(&tp->packets_out, skb);
 }
@@ -1241,7 +1250,7 @@
  *	"Packets left network, but not honestly ACKed yet" PLUS
  *	"Packets fast retransmitted"
  */
-static __inline__ unsigned int tcp_packets_in_flight(struct tcp_opt *tp)
+static __inline__ unsigned int tcp_packets_in_flight(const struct tcp_opt *tp)
 {
 	return (tcp_get_pcount(&tp->packets_out) -
 		tcp_get_pcount(&tp->left_out) +
@@ -1408,18 +1417,19 @@
 /* Slow start with delack produces 3 packets of burst, so that
  * it is safe "de facto".
  */
-static __inline__ __u32 tcp_max_burst(struct tcp_opt *tp)
+static __inline__ __u32 tcp_max_burst(const struct tcp_opt *tp)
 {
 	return 3;
 }
 
-static __inline__ int tcp_minshall_check(struct tcp_opt *tp)
+static __inline__ int tcp_minshall_check(const struct tcp_opt *tp)
 {
 	return after(tp->snd_sml,tp->snd_una) &&
 		!after(tp->snd_sml, tp->snd_nxt);
 }
 
-static __inline__ void tcp_minshall_update(struct tcp_opt *tp, int mss, struct sk_buff *skb)
+static __inline__ void tcp_minshall_update(struct tcp_opt *tp, int mss, 
+					   const struct sk_buff *skb)
 {
 	if (skb->len < mss)
 		tp->snd_sml = TCP_SKB_CB(skb)->end_seq;
@@ -1434,7 +1444,8 @@
  */
 
 static __inline__ int
-tcp_nagle_check(struct tcp_opt *tp, struct sk_buff *skb, unsigned mss_now, int nonagle)
+tcp_nagle_check(const struct tcp_opt *tp, const struct sk_buff *skb, 
+		unsigned mss_now, int nonagle)
 {
 	return (skb->len < mss_now &&
 		!(TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN) &&
@@ -1449,7 +1460,8 @@
 /* This checks if the data bearing packet SKB (usually sk->sk_send_head)
  * should be put on the wire right now.
  */
-static __inline__ int tcp_snd_test(struct tcp_opt *tp, struct sk_buff *skb,
+static __inline__ int tcp_snd_test(const struct tcp_opt *tp, 
+				   struct sk_buff *skb,
 				   unsigned cur_mss, int nonagle)
 {
 	int pkts = tcp_skb_pcount(skb);
@@ -1496,7 +1508,8 @@
 		tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0, tp->rto);
 }
 
-static __inline__ int tcp_skb_is_last(struct sock *sk, struct sk_buff *skb)
+static __inline__ int tcp_skb_is_last(const struct sock *sk, 
+				      const struct sk_buff *skb)
 {
 	return skb->next == (struct sk_buff *)&sk->sk_write_queue;
 }
@@ -1547,7 +1560,7 @@
 	tp->snd_wl1 = seq;
 }
 
-extern void			tcp_destroy_sock(struct sock *sk);
+extern void tcp_destroy_sock(struct sock *sk);
 
 
 /*
@@ -1621,7 +1634,7 @@
 #undef STATE_TRACE
 
 #ifdef STATE_TRACE
-static char *statename[]={
+static const char *statename[]={
 	"Unused","Established","Syn Sent","Syn Recv",
 	"Fin Wait 1","Fin Wait 2","Time Wait", "Close",
 	"Close Wait","Last ACK","Listen","Closing"
@@ -1892,17 +1905,17 @@
 		wake_up(&tcp_lhash_wait);
 }
 
-static inline int keepalive_intvl_when(struct tcp_opt *tp)
+static inline int keepalive_intvl_when(const struct tcp_opt *tp)
 {
 	return tp->keepalive_intvl ? : sysctl_tcp_keepalive_intvl;
 }
 
-static inline int keepalive_time_when(struct tcp_opt *tp)
+static inline int keepalive_time_when(const struct tcp_opt *tp)
 {
 	return tp->keepalive_time ? : sysctl_tcp_keepalive_time;
 }
 
-static inline int tcp_fin_time(struct tcp_opt *tp)
+static inline int tcp_fin_time(const struct tcp_opt *tp)
 {
 	int fin_timeout = tp->linger2 ? : sysctl_tcp_fin_timeout;
 
@@ -1912,7 +1925,7 @@
 	return fin_timeout;
 }
 
-static inline int tcp_paws_check(struct tcp_opt *tp, int rst)
+static inline int tcp_paws_check(const struct tcp_opt *tp, int rst)
 {
 	if ((s32)(tp->rcv_tsval - tp->ts_recent) >= 0)
 		return 0;
diff -Nru a/include/net/udp.h b/include/net/udp.h
--- a/include/net/udp.h	2004-12-24 13:37:18 -08:00
+++ b/include/net/udp.h	2004-12-24 13:37:18 -08:00
@@ -71,6 +71,8 @@
 extern int	udp_rcv(struct sk_buff *skb);
 extern int	udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
 extern int	udp_disconnect(struct sock *sk, int flags);
+extern unsigned int udp_poll(struct file *file, struct socket *sock,
+			     poll_table *wait);
 
 DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
 #define UDP_INC_STATS(field)		SNMP_INC_STATS(udp_statistics, field)
diff -Nru a/include/net/x25device.h b/include/net/x25device.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/net/x25device.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,17 @@
+#ifndef _X25DEVICE_H
+#define _X25DEVICE_H
+
+#include <linux/if_ether.h>
+#include <linux/if_packet.h>
+#include <linux/skbuff.h>
+
+static inline unsigned short x25_type_trans(struct sk_buff *skb,
+					    struct net_device *dev)
+{
+	skb->mac.raw = skb->data;
+	skb->input_dev = skb->dev = dev;
+	skb->pkt_type = PACKET_HOST;
+	
+	return htons(ETH_P_X25);
+}
+#endif
diff -Nru a/include/net/xfrm.h b/include/net/xfrm.h
--- a/include/net/xfrm.h	2004-12-24 13:37:18 -08:00
+++ b/include/net/xfrm.h	2004-12-24 13:37:18 -08:00
@@ -178,8 +178,6 @@
 
 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
-extern struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family);
-extern void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo);
 
 #define XFRM_ACQ_EXPIRES	30
 
@@ -200,8 +198,6 @@
 
 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
-extern struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family);
-extern void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo);
 
 extern void xfrm_state_delete_tunnel(struct xfrm_state *x);
 
@@ -601,7 +597,7 @@
 	if (sk && sk->sk_policy[XFRM_POLICY_IN])
 		return __xfrm_policy_check(sk, dir, skb, family);
 		
-	return	!xfrm_policy_list[dir] ||
+	return	(!xfrm_policy_list[dir] && !skb->sp) ||
 		(skb->dst->flags & DST_NOPOLICY) ||
 		__xfrm_policy_check(sk, dir, skb, family);
 }
@@ -805,17 +801,15 @@
 extern void xfrm_state_insert(struct xfrm_state *x);
 extern int xfrm_state_add(struct xfrm_state *x);
 extern int xfrm_state_update(struct xfrm_state *x);
-extern int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb);
 extern struct xfrm_state *xfrm_state_lookup(xfrm_address_t *daddr, u32 spi, u8 proto, unsigned short family);
 extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq);
 extern void xfrm_state_delete(struct xfrm_state *x);
 extern void xfrm_state_flush(u8 proto);
 extern int xfrm_replay_check(struct xfrm_state *x, u32 seq);
 extern void xfrm_replay_advance(struct xfrm_state *x, u32 seq);
-extern int xfrm_check_selectors(struct xfrm_state **x, int n, struct flowi *fl);
 extern int xfrm_state_check(struct xfrm_state *x, struct sk_buff *skb);
 extern int xfrm4_rcv(struct sk_buff *skb);
-extern int xfrm4_output(struct sk_buff **pskb);
+extern int xfrm4_output(struct sk_buff *skb);
 extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler);
 extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler);
 extern int xfrm6_rcv_spi(struct sk_buff **pskb, unsigned int *nhoffp, u32 spi);
@@ -825,7 +819,7 @@
 extern u32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr);
 extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr);
 extern u32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr);
-extern int xfrm6_output(struct sk_buff **pskb);
+extern int xfrm6_output(struct sk_buff *skb);
 
 #ifdef CONFIG_XFRM
 extern int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type);
@@ -863,7 +857,6 @@
 				  xfrm_address_t *daddr, xfrm_address_t *saddr, 
 				  int create, unsigned short family);
 extern void xfrm_policy_flush(void);
-extern void xfrm_policy_kill(struct xfrm_policy *);
 extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
 extern struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struct flowi *fl);
 extern int xfrm_flush_bundles(void);
diff -Nru a/include/pcmcia/bulkmem.h b/include/pcmcia/bulkmem.h
--- a/include/pcmcia/bulkmem.h	2004-12-24 13:36:48 -08:00
+++ b/include/pcmcia/bulkmem.h	2004-12-24 13:36:48 -08:00
@@ -53,155 +53,7 @@
 #define REGION_BAR_MASK		0xe000
 #define REGION_BAR_SHIFT	13
 
-/* For OpenMemory */
-typedef struct open_mem_t {
-    u_int		Attributes;
-    u_int		Offset;
-} open_mem_t;
-
-/* Attributes for OpenMemory */
-#define MEMORY_TYPE		0x0001
-#define MEMORY_TYPE_CM		0x0000
-#define MEMORY_TYPE_AM		0x0001
-#define MEMORY_EXCLUSIVE	0x0002
-#define MEMORY_PREFETCH		0x0008
-#define MEMORY_CACHEABLE	0x0010
-#define MEMORY_BAR_MASK		0xe000
-#define MEMORY_BAR_SHIFT	13
-
-typedef struct eraseq_entry_t {
-    memory_handle_t	Handle;
-    u_char		State;
-    u_int		Size;
-    u_int		Offset;
-    void		*Optional;
-} eraseq_entry_t;
-
-typedef struct eraseq_hdr_t {
-    int			QueueEntryCnt;
-    eraseq_entry_t	*QueueEntryArray;
-} eraseq_hdr_t;
-
-#define ERASE_QUEUED		0x00
-#define ERASE_IN_PROGRESS(n)	(((n) > 0) && ((n) < 0x80))
-#define ERASE_IDLE		0xff
-#define ERASE_PASSED		0xe0
-#define ERASE_FAILED		0xe1
-
-#define ERASE_MISSING		0x80
-#define ERASE_MEDIA_WRPROT	0x84
-#define ERASE_NOT_ERASABLE	0x85
-#define ERASE_BAD_OFFSET	0xc1
-#define ERASE_BAD_TECH		0xc2
-#define ERASE_BAD_SOCKET	0xc3
-#define ERASE_BAD_VCC		0xc4
-#define ERASE_BAD_VPP		0xc5
-#define ERASE_BAD_SIZE		0xc6
-
-/* For CopyMemory */
-typedef struct copy_op_t {
-    u_int		Attributes;
-    u_int		SourceOffset;
-    u_int		DestOffset;
-    u_int		Count;
-} copy_op_t;
-
-/* For ReadMemory and WriteMemory */
-typedef struct mem_op_t {
-    u_int	Attributes;
-    u_int	Offset;
-    u_int	Count;
-} mem_op_t;
-
-#define MEM_OP_BUFFER		0x01
-#define MEM_OP_BUFFER_USER	0x00
-#define MEM_OP_BUFFER_KERNEL	0x01
-#define MEM_OP_DISABLE_ERASE	0x02
-#define MEM_OP_VERIFY		0x04
-
-/* For RegisterMTD */
-typedef struct mtd_reg_t {
-    u_int	Attributes;
-    u_int	Offset;
-    u_long	MediaID;
-} mtd_reg_t;
-
-/*
- *  Definitions for MTD requests
- */
-
-typedef struct mtd_request_t {
-    u_int	SrcCardOffset;
-    u_int	DestCardOffset;
-    u_int	TransferLength;
-    u_int	Function;
-    u_long	MediaID;
-    u_int	Status;
-    u_int	Timeout;
-} mtd_request_t;
-
-/* Fields in MTD Function */
-#define MTD_REQ_ACTION		0x003
-#define MTD_REQ_ERASE		0x000
-#define MTD_REQ_READ		0x001
-#define MTD_REQ_WRITE		0x002
-#define MTD_REQ_COPY		0x003
-#define MTD_REQ_NOERASE		0x004
-#define MTD_REQ_VERIFY		0x008
-#define MTD_REQ_READY		0x010
-#define MTD_REQ_TIMEOUT		0x020
-#define MTD_REQ_LAST		0x040
-#define MTD_REQ_FIRST		0x080
-#define MTD_REQ_KERNEL		0x100
-
-/* Status codes */
-#define MTD_WAITREQ	0x00
-#define MTD_WAITTIMER	0x01
-#define MTD_WAITRDY	0x02
-#define MTD_WAITPOWER	0x03
-
-/*
- *  Definitions for MTD helper functions
- */
-
-/* For MTDModifyWindow */
-typedef struct mtd_mod_win_t {
-    u_int	Attributes;
-    u_int	AccessSpeed;
-    u_int	CardOffset;
-} mtd_mod_win_t;
-
-/* For MTDSetVpp */
-typedef struct mtd_vpp_req_t {
-    u_char	Vpp1, Vpp2;
-} mtd_vpp_req_t;
-
-/* For MTDRDYMask */
-typedef struct mtd_rdy_req_t {
-    u_int	Mask;
-} mtd_rdy_req_t;
-
-enum mtd_helper {
-    MTDRequestWindow, MTDModifyWindow, MTDReleaseWindow,
-    MTDSetVpp, MTDRDYMask
-};
-
-#ifdef IN_CARD_SERVICES
-extern int MTDHelperEntry(int func, void *a1, void *a2);
-#else
-extern int MTDHelperEntry(int func, ...);
-#endif
-
 int pcmcia_get_first_region(client_handle_t handle, region_info_t *rgn);
 int pcmcia_get_next_region(client_handle_t handle, region_info_t *rgn);
-int pcmcia_register_mtd(client_handle_t handle, mtd_reg_t *reg);
-int pcmcia_register_erase_queue(client_handle_t *handle, eraseq_hdr_t *header, eraseq_handle_t *e);
-int pcmcia_deregister_erase_queue(eraseq_handle_t eraseq);
-int pcmcia_check_erase_queue(eraseq_handle_t eraseq);
-int pcmcia_open_memory(client_handle_t *handle, open_mem_t *open, memory_handle_t *m);
-int pcmcia_close_memory(memory_handle_t handle);
-int pcmcia_read_memory(memory_handle_t handle, mem_op_t *req, caddr_t buf);
-int pcmcia_write_memory(memory_handle_t handle, mem_op_t *req, caddr_t buf);
-int pcmcia_copy_memory(memory_handle_t handle, copy_op_t *req);
 
 #endif /* _LINUX_BULKMEM_H */
diff -Nru a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h
--- a/include/pcmcia/cistpl.h	2004-12-24 13:37:18 -08:00
+++ b/include/pcmcia/cistpl.h	2004-12-24 13:37:18 -08:00
@@ -607,6 +607,14 @@
 int pcmcia_parse_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse);
 
 int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info);
-int pcmcia_replace_cis(client_handle_t handle, cisdump_t *cis);
+int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis);
+
+/* don't use outside of PCMCIA core yet */
+int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple);
+int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple);
+int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple);
+int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse);
+
+int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_t *info);
 
 #endif /* LINUX_CISTPL_H */
diff -Nru a/include/pcmcia/cs.h b/include/pcmcia/cs.h
--- a/include/pcmcia/cs.h	2004-12-24 13:36:16 -08:00
+++ b/include/pcmcia/cs.h	2004-12-24 13:36:16 -08:00
@@ -348,7 +348,6 @@
 #define CS_EVENT_RESET_PHYSICAL		0x000200
 #define CS_EVENT_CARD_RESET		0x000400
 #define CS_EVENT_REGISTRATION_COMPLETE	0x000800
-#define CS_EVENT_RESET_COMPLETE		0x001000
 #define CS_EVENT_PM_SUSPEND		0x002000
 #define CS_EVENT_PM_RESUME		0x004000
 #define CS_EVENT_INSERTION_REQUEST	0x008000
@@ -425,16 +424,12 @@
 int pcmcia_deregister_client(client_handle_t handle);
 int pcmcia_get_configuration_info(client_handle_t handle, config_info_t *config);
 int pcmcia_get_card_services_info(servinfo_t *info);
-int pcmcia_get_first_client(client_handle_t *handle, client_req_t *req);
-int pcmcia_get_next_client(client_handle_t *handle, client_req_t *req);
-int pcmcia_get_window(window_handle_t *handle, int idx, win_req_t *req);
 int pcmcia_get_first_window(window_handle_t *win, win_req_t *req);
 int pcmcia_get_next_window(window_handle_t *win, win_req_t *req);
 int pcmcia_get_status(client_handle_t handle, cs_status_t *status);
 int pcmcia_get_mem_page(window_handle_t win, memreq_t *req);
 int pcmcia_map_mem_page(window_handle_t win, memreq_t *req);
 int pcmcia_modify_configuration(client_handle_t handle, modconf_t *mod);
-int pcmcia_modify_window(window_handle_t win, modwin_t *req);
 int pcmcia_register_client(client_handle_t *handle, client_reg_t *req);
 int pcmcia_release_configuration(client_handle_t handle);
 int pcmcia_release_io(client_handle_t handle, io_req_t *req);
@@ -449,12 +444,14 @@
 int pcmcia_resume_card(struct pcmcia_socket *skt);
 int pcmcia_eject_card(struct pcmcia_socket *skt);
 int pcmcia_insert_card(struct pcmcia_socket *skt);
-int pcmcia_set_event_mask(client_handle_t handle, eventmask_t *mask);
 int pcmcia_report_error(client_handle_t handle, error_info_t *err);
-struct pci_bus *pcmcia_lookup_bus(client_handle_t handle);
 
-/* rsrc_mgr.c */
-int pcmcia_adjust_resource_info(client_handle_t handle, adjust_t *adj);
+#ifdef CONFIG_PCMCIA_OBSOLETE
+int pcmcia_get_first_client(client_handle_t *handle, client_req_t *req);
+int pcmcia_get_next_client(client_handle_t *handle, client_req_t *req);
+int pcmcia_modify_window(window_handle_t win, modwin_t *req);
+int pcmcia_set_event_mask(client_handle_t handle, eventmask_t *mask);
+#endif
 
 #endif /* __KERNEL__ */
 
diff -Nru a/include/pcmcia/cs_types.h b/include/pcmcia/cs_types.h
--- a/include/pcmcia/cs_types.h	2004-12-24 13:36:31 -08:00
+++ b/include/pcmcia/cs_types.h	2004-12-24 13:36:31 -08:00
@@ -56,9 +56,6 @@
 struct region_t;
 typedef struct region_t *memory_handle_t;
 
-struct eraseq_t;
-typedef struct eraseq_t *eraseq_handle_t;
-
 #ifndef DEV_NAME_LEN
 #define DEV_NAME_LEN 32
 #endif
diff -Nru a/include/pcmcia/ftl.h b/include/pcmcia/ftl.h
--- a/include/pcmcia/ftl.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,73 +0,0 @@
-/*
- * ftl.h 1.8 2000/06/12 21:55:40
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License. 
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in which
- * case the provisions of the GPL are applicable instead of the
- * above.  If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL.  If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_FTL_H
-#define _LINUX_FTL_H
-
-typedef struct erase_unit_header_t {
-    u_char	LinkTargetTuple[5];
-    u_char	DataOrgTuple[10];
-    u_char	NumTransferUnits;
-    u_int	EraseCount;
-    u_short	LogicalEUN;
-    u_char	BlockSize;
-    u_char	EraseUnitSize;
-    u_short	FirstPhysicalEUN;
-    u_short	NumEraseUnits;
-    u_int	FormattedSize;
-    u_int	FirstVMAddress;
-    u_short	NumVMPages;
-    u_char	Flags;
-    u_char	Code;
-    u_int	SerialNumber;
-    u_int	AltEUHOffset;
-    u_int	BAMOffset;
-    u_char	Reserved[12];
-    u_char	EndTuple[2];
-} erase_unit_header_t;
-
-/* Flags in erase_unit_header_t */
-#define HIDDEN_AREA		0x01
-#define REVERSE_POLARITY	0x02
-#define DOUBLE_BAI		0x04
-
-/* Definitions for block allocation information */
-
-#define BLOCK_FREE(b)		((b) == 0xffffffff)
-#define BLOCK_DELETED(b)	(((b) == 0) || ((b) == 0xfffffffe))
-
-#define BLOCK_TYPE(b)		((b) & 0x7f)
-#define BLOCK_ADDRESS(b)	((b) & ~0x7f)
-#define BLOCK_NUMBER(b)		((b) >> 9)
-#define BLOCK_CONTROL		0x30
-#define BLOCK_DATA		0x40
-#define BLOCK_REPLACEMENT	0x60
-#define BLOCK_BAD		0x70
-
-#endif /* _LINUX_FTL_H */
diff -Nru a/include/pcmcia/memory.h b/include/pcmcia/memory.h
--- a/include/pcmcia/memory.h	2004-12-24 13:36:55 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,41 +0,0 @@
-/*
- * memory.h 1.7 2000/06/12 21:55:40
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License. 
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in which
- * case the provisions of the GPL are applicable instead of the
- * above.  If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL.  If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_MEMORY_H
-#define _LINUX_MEMORY_H
-
-typedef struct erase_info_t {
-    u_long	Offset;
-    u_long	Size;
-} erase_info_t;
-
-#define MEMGETINFO		_IOR('M', 1, region_info_t)
-#define MEMERASE		_IOW('M', 2, erase_info_t)
-
-#endif /* _LINUX_MEMORY_H */
diff -Nru a/include/pcmcia/ss.h b/include/pcmcia/ss.h
--- a/include/pcmcia/ss.h	2004-12-24 13:37:29 -08:00
+++ b/include/pcmcia/ss.h	2004-12-24 13:37:29 -08:00
@@ -135,13 +135,6 @@
  */
 struct pcmcia_socket;
 
-typedef struct erase_busy_t {
-	eraseq_entry_t		*erase;
-	client_handle_t		client;
-	struct timer_list	timeout;
-	struct erase_busy_t	*prev, *next;
-} erase_busy_t;
-
 typedef struct io_window_t {
 	u_int			Attributes;
 	ioaddr_t		BasePort, NumPorts;
@@ -185,7 +178,6 @@
 	io_window_t			io[MAX_IO_WIN];
 	window_t			win[MAX_WIN];
 	struct region_t			*c_region, *a_region;
-	erase_busy_t			erase_busy;
 	struct list_head		cis_cache;
 	u_int				fake_cis_len;
 	char				*fake_cis;
diff -Nru a/include/scsi/scsi.h b/include/scsi/scsi.h
--- a/include/scsi/scsi.h	2004-12-24 13:37:30 -08:00
+++ b/include/scsi/scsi.h	2004-12-24 13:37:30 -08:00
@@ -246,24 +246,35 @@
 #define     EXTENDED_SDTR                   0x01
 #define     EXTENDED_EXTENDED_IDENTIFY      0x02    /* SCSI-I only */
 #define     EXTENDED_WDTR                   0x03
+#define     EXTENDED_PPR                    0x04
+#define     EXTENDED_MODIFY_BIDI_DATA_PTR   0x05
 #define SAVE_POINTERS       0x02
 #define RESTORE_POINTERS    0x03
 #define DISCONNECT          0x04
 #define INITIATOR_ERROR     0x05
-#define ABORT               0x06
+#define ABORT_TASK_SET      0x06
 #define MESSAGE_REJECT      0x07
 #define NOP                 0x08
 #define MSG_PARITY_ERROR    0x09
 #define LINKED_CMD_COMPLETE 0x0a
 #define LINKED_FLG_CMD_COMPLETE 0x0b
-#define BUS_DEVICE_RESET    0x0c
-
+#define TARGET_RESET        0x0c
+#define ABORT_TASK          0x0d
+#define CLEAR_TASK_SET      0x0e
 #define INITIATE_RECOVERY   0x0f            /* SCSI-II only */
 #define RELEASE_RECOVERY    0x10            /* SCSI-II only */
-
+#define CLEAR_ACA           0x16
+#define LOGICAL_UNIT_RESET  0x17
 #define SIMPLE_QUEUE_TAG    0x20
 #define HEAD_OF_QUEUE_TAG   0x21
 #define ORDERED_QUEUE_TAG   0x22
+#define IGNORE_WIDE_RESIDUE 0x23
+#define ACA                 0x24
+#define QAS_REQUEST         0x55
+
+/* Old SCSI2 names, don't use in new code */
+#define BUS_DEVICE_RESET    TARGET_RESET
+#define ABORT               ABORT_TASK_SET
 
 /*
  * Host byte codes
diff -Nru a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
--- a/include/scsi/scsi_device.h	2004-12-24 13:36:17 -08:00
+++ b/include/scsi/scsi_device.h	2004-12-24 13:36:17 -08:00
@@ -30,6 +30,9 @@
 				 * originate in the mid-layer) */
 	SDEV_OFFLINE,		/* Device offlined (by error handling or
 				 * user request */
+	SDEV_BLOCK,		/* Device blocked by scsi lld.  No scsi 
+				 * commands from user or midlayer should be issued
+				 * to the scsi lld. */
 };
 
 struct scsi_device {
@@ -106,6 +109,9 @@
 	unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
 	unsigned no_start_on_add:1;	/* do not issue start on add */
 	unsigned allow_restart:1; /* issue START_UNIT in error handler */
+	unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
+	unsigned select_no_atn:1;
+	unsigned fix_capacity:1;	/* READ_CAPACITY is too high by 1 */
 
 	unsigned int device_blocked;	/* Device returned QUEUE_FULL. */
 
@@ -120,7 +126,7 @@
 	struct class_device	transport_classdev;
 
 	enum scsi_device_state sdev_state;
-	unsigned long		transport_data[0];
+	unsigned long		sdev_data[0];
 } __attribute__((aligned(sizeof(unsigned long))));
 #define	to_scsi_device(d)	\
 	container_of(d, struct scsi_device, sdev_gendev)
@@ -129,6 +135,30 @@
 #define transport_class_to_sdev(class_dev) \
 	container_of(class_dev, struct scsi_device, transport_classdev)
 
+/*
+ * scsi_target: representation of a scsi target, for now, this is only
+ * used for single_lun devices. If no one has active IO to the target,
+ * starget_sdev_user is NULL, else it points to the active sdev.
+ */
+struct scsi_target {
+	struct scsi_device	*starget_sdev_user;
+	struct device		dev;
+	unsigned int		channel;
+	unsigned int		id; /* target id ... replace
+				     * scsi_device.id eventually */
+	struct class_device	transport_classdev;
+	unsigned long		create:1; /* signal that it needs to be added */
+	unsigned long		starget_data[0];
+} __attribute__((aligned(sizeof(unsigned long))));
+
+#define to_scsi_target(d)	container_of(d, struct scsi_target, dev)
+static inline struct scsi_target *scsi_target(struct scsi_device *sdev)
+{
+	return to_scsi_target(sdev->sdev_gendev.parent);
+}
+#define transport_class_to_starget(class_dev) \
+	container_of(class_dev, struct scsi_target, transport_classdev)
+
 extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
 		uint, uint, uint, void *hostdata);
 #define scsi_add_device(host, channel, target, lun) \
@@ -191,6 +221,8 @@
 				 enum scsi_device_state state);
 extern int scsi_device_quiesce(struct scsi_device *sdev);
 extern void scsi_device_resume(struct scsi_device *sdev);
+extern void scsi_target_quiesce(struct scsi_target *);
+extern void scsi_target_resume(struct scsi_target *);
 extern const char *scsi_device_state_name(enum scsi_device_state);
 static inline int scsi_device_online(struct scsi_device *sdev)
 {
diff -Nru a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
--- a/include/scsi/scsi_devinfo.h	2004-12-24 13:36:17 -08:00
+++ b/include/scsi/scsi_devinfo.h	2004-12-24 13:36:17 -08:00
@@ -25,4 +25,6 @@
  					   (if HBA supports more than 8 LUNs) */
 #define BLIST_NOREPORTLUN	0x40000	/* don't try REPORT_LUNS scan (SCSI-3 devs) */
 #define BLIST_NOT_LOCKABLE	0x80000	/* don't use PREVENT-ALLOW commands */
+#define BLIST_NO_ULD_ATTACH	0x100000 /* device is actually for RAID config */
+#define BLIST_SELECT_NO_ATN	0x200000 /* select without ATN */
 #endif
diff -Nru a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
--- a/include/scsi/scsi_eh.h	2004-12-24 13:37:29 -08:00
+++ b/include/scsi/scsi_eh.h	2004-12-24 13:37:29 -08:00
@@ -3,15 +3,48 @@
 
 struct scsi_cmnd;
 struct scsi_device;
+struct scsi_request;
 struct Scsi_Host;
 
+/*
+ * This is a slightly modified SCSI sense "descriptor" format header.
+ * The addition is to allow the 0x70 and 0x71 response codes. The idea
+ * is to place the salient data from either "fixed" or "descriptor" sense
+ * format into one structure to ease application processing.
+ *
+ * The original sense buffer should be kept around for those cases
+ * in which more information is required (e.g. the LBA of a MEDIUM ERROR).
+ */
+struct scsi_sense_hdr {		/* See SPC-3 section 4.5 */
+	u8 response_code;	/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */
+	u8 sense_key;
+	u8 asc;
+	u8 ascq;
+	u8 byte4;
+	u8 byte5;
+	u8 byte6;
+	u8 additional_length;	/* always 0 for fixed sense format */
+};
+
+
 extern void scsi_add_timer(struct scsi_cmnd *, int,
-			   void (*)(struct scsi_cmnd *));
+		void (*)(struct scsi_cmnd *));
 extern int scsi_delete_timer(struct scsi_cmnd *);
 extern void scsi_report_bus_reset(struct Scsi_Host *, int);
 extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
 extern int scsi_block_when_processing_errors(struct scsi_device *);
+extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
+		struct scsi_sense_hdr *sshdr);
+extern int scsi_request_normalize_sense(struct scsi_request *sreq,
+		struct scsi_sense_hdr *sshdr);
+extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
+		struct scsi_sense_hdr *sshdr);
 
+static inline int scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr)
+{
+	return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
+}
+ 
 /*
  * Reset request from external source
  */
diff -Nru a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
--- a/include/scsi/scsi_host.h	2004-12-24 13:36:19 -08:00
+++ b/include/scsi/scsi_host.h	2004-12-24 13:36:19 -08:00
@@ -146,15 +146,6 @@
 	enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *);
 
 	/*
-	 * Old EH handlers, no longer used. Make them warn the user of old
-	 * drivers by using a wrong type
-	 *
-	 * Status: MORE THAN OBSOLETE
-	 */
-	int (* abort)(int);
-	int (* reset)(int, int);
-
-	/*
 	 * Before the mid layer attempts to scan for a new device where none
 	 * currently exists, it will call this entry in your driver.  Should
 	 * your driver need to allocate any structs or perform any other init
@@ -511,6 +502,13 @@
 	struct list_head sht_legacy_list;
 
 	/*
+	 * Points to the transport data (if any) which is allocated
+	 * separately
+	 */
+	void *shost_data;
+	struct class_device transport_classdev;
+
+	/*
 	 * We should ensure that this is aligned, both for better performance
 	 * and also because some compilers (m68k) don't automatically force
 	 * alignment to a long boundary.
@@ -522,9 +520,12 @@
 	container_of(d, struct Scsi_Host, shost_gendev)
 #define		class_to_shost(d)	\
 	container_of(d, struct Scsi_Host, shost_classdev)
+#define		transport_class_to_shost(class_dev) \
+	container_of(class_dev, struct Scsi_Host, transport_classdev)
+
 
 extern struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *, int);
-extern int scsi_add_host(struct Scsi_Host *, struct device *);
+extern int __must_check scsi_add_host(struct Scsi_Host *, struct device *);
 extern void scsi_scan_host(struct Scsi_Host *);
 extern void scsi_remove_host(struct Scsi_Host *);
 extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
diff -Nru a/include/scsi/scsi_ioctl.h b/include/scsi/scsi_ioctl.h
--- a/include/scsi/scsi_ioctl.h	2004-12-24 13:36:17 -08:00
+++ b/include/scsi/scsi_ioctl.h	2004-12-24 13:36:17 -08:00
@@ -43,6 +43,8 @@
 extern int scsi_ioctl(struct scsi_device *, int, void __user *);
 extern int scsi_ioctl_send_command(struct scsi_device *,
 				   struct scsi_ioctl_command __user *);
+extern int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd,
+				   void __user *arg, struct file *filp);
 
 #endif /* __KERNEL__ */
 #endif /* _SCSI_IOCTL_H */
diff -Nru a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
--- a/include/scsi/scsi_transport.h	2004-12-24 13:37:18 -08:00
+++ b/include/scsi/scsi_transport.h	2004-12-24 13:37:18 -08:00
@@ -24,18 +24,28 @@
 	/* The NULL terminated list of transport attributes
 	 * that should be exported.
 	 */
-	struct class_device_attribute **attrs;
+	struct class_device_attribute **device_attrs;
+	struct class_device_attribute **target_attrs;
+	struct class_device_attribute **host_attrs;
+
 
 	/* The transport class that the device is in */
-	struct class *class;
+	struct class *device_class;
+	struct class *target_class;
+	struct class *host_class;
+
+	/* Constructor functions */
+	int (*device_setup)(struct scsi_device *);
+	int (*device_configure)(struct scsi_device *);
+	int (*target_setup)(struct scsi_target *);
+	int (*host_setup)(struct Scsi_Host *);
 
-	/* Constructor/Destructor functions */
-	int (* setup)(struct scsi_device *);
-	void (* cleanup)(struct scsi_device *);
 	/* The size of the specific transport attribute structure (a
 	 * space of this size will be left at the end of the
-	 * scsi_device structure */
-	int	size;
+	 * scsi_* structure */
+	int	device_size;
+	int	target_size;
+	int	host_size;
 };
 
 #endif /* SCSI_TRANSPORT_H */
diff -Nru a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
--- a/include/scsi/scsi_transport_fc.h	2004-12-24 13:36:34 -08:00
+++ b/include/scsi/scsi_transport_fc.h	2004-12-24 13:36:34 -08:00
@@ -24,33 +24,68 @@
 
 struct scsi_transport_template;
 
-struct fc_transport_attrs {
+struct fc_starget_attrs {	/* aka fc_target_attrs */
 	int port_id;
 	uint64_t node_name;
 	uint64_t port_name;
+	uint32_t dev_loss_tmo;	/* Remote Port loss timeout in seconds. */
+	struct timer_list dev_loss_timer;
 };
 
-/* accessor functions */
-#define fc_port_id(x)	(((struct fc_transport_attrs *)&(x)->transport_data)->port_id)
-#define fc_node_name(x)	(((struct fc_transport_attrs *)&(x)->transport_data)->node_name)
-#define fc_port_name(x)	(((struct fc_transport_attrs *)&(x)->transport_data)->port_name)
+#define fc_starget_port_id(x) \
+	(((struct fc_starget_attrs *)&(x)->starget_data)->port_id)
+#define fc_starget_node_name(x) \
+	(((struct fc_starget_attrs *)&(x)->starget_data)->node_name)
+#define fc_starget_port_name(x)	\
+	(((struct fc_starget_attrs *)&(x)->starget_data)->port_name)
+#define fc_starget_dev_loss_tmo(x) \
+	(((struct fc_starget_attrs *)&(x)->starget_data)->dev_loss_tmo)
+#define fc_starget_dev_loss_timer(x) \
+	(((struct fc_starget_attrs *)&(x)->starget_data)->dev_loss_timer)
+
+struct fc_host_attrs {
+	uint32_t link_down_tmo;	/* Link Down timeout in seconds. */
+	struct timer_list link_down_timer;
+};
+
+#define fc_host_link_down_tmo(x) \
+	(((struct fc_host_attrs *)(x)->shost_data)->link_down_tmo)
+#define fc_host_link_down_timer(x) \
+	(((struct fc_host_attrs *)(x)->shost_data)->link_down_timer)
+
 
 /* The functions by which the transport class and the driver communicate */
 struct fc_function_template {
-	void 	(*get_port_id)(struct scsi_device *);
-	void	(*get_node_name)(struct scsi_device *);
-	void	(*get_port_name)(struct scsi_device *);
-	/* The driver sets these to tell the transport class it
+	void 	(*get_starget_port_id)(struct scsi_target *);
+	void	(*get_starget_node_name)(struct scsi_target *);
+	void	(*get_starget_port_name)(struct scsi_target *);
+	void    (*get_starget_dev_loss_tmo)(struct scsi_target *);
+	void	(*set_starget_dev_loss_tmo)(struct scsi_target *, uint32_t);
+
+	void    (*get_host_link_down_tmo)(struct Scsi_Host *);
+	void	(*set_host_link_down_tmo)(struct Scsi_Host *, uint32_t);
+
+	/* 
+	 * The driver sets these to tell the transport class it
 	 * wants the attributes displayed in sysfs.  If the show_ flag
 	 * is not set, the attribute will be private to the transport
-	 * class */
-	unsigned long	show_port_id:1;
-	unsigned long	show_node_name:1;
-	unsigned long	show_port_name:1;
+	 * class 
+	 */
+	unsigned long	show_starget_port_id:1;
+	unsigned long	show_starget_node_name:1;
+	unsigned long	show_starget_port_name:1;
+	unsigned long   show_starget_dev_loss_tmo:1;
+
+	unsigned long   show_host_link_down_tmo:1;
+
 	/* Private Attributes */
 };
 
 struct scsi_transport_template *fc_attach_transport(struct fc_function_template *);
 void fc_release_transport(struct scsi_transport_template *);
+int fc_target_block(struct scsi_target *starget);
+void fc_target_unblock(struct scsi_target *starget);
+int fc_host_block(struct Scsi_Host *shost);
+void fc_host_unblock(struct Scsi_Host *shost);
 
 #endif /* SCSI_TRANSPORT_FC_H */
diff -Nru a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h
--- a/include/scsi/scsi_transport_spi.h	2004-12-24 13:36:30 -08:00
+++ b/include/scsi/scsi_transport_spi.h	2004-12-24 13:36:30 -08:00
@@ -35,45 +35,80 @@
 	unsigned int rd_strm:1;	/* Read streaming enabled */
 	unsigned int rti:1;	/* Retain Training Information */
 	unsigned int pcomp_en:1;/* Precompensation enabled */
+	unsigned int initial_dv:1; /* DV done to this target yet  */
+	unsigned long flags;	/* flags field for drivers to use */
+	/* Device Properties fields */
+	unsigned int support_sync:1; /* synchronous support */
+	unsigned int support_wide:1; /* wide support */
+	unsigned int support_dt:1; /* allows DT phases */
+	unsigned int support_dt_only; /* disallows ST phases */
+	unsigned int support_ius; /* support Information Units */
+	unsigned int support_qas; /* supports quick arbitration and selection */
 	/* Private Fields */
 	unsigned int dv_pending:1; /* Internal flag */
 	struct semaphore dv_sem; /* semaphore to serialise dv */
 };
 
+enum spi_signal_type {
+	SPI_SIGNAL_UNKNOWN = 1,
+	SPI_SIGNAL_SE,
+	SPI_SIGNAL_LVD,
+	SPI_SIGNAL_HVD,
+};
+
+struct spi_host_attrs {
+	enum spi_signal_type signalling;
+};
+
 /* accessor functions */
-#define spi_period(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->period)
-#define spi_offset(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->offset)
-#define spi_width(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->width)
-#define spi_iu(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->iu)
-#define spi_dt(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->dt)
-#define spi_qas(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->qas)
-#define spi_wr_flow(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->wr_flow)
-#define spi_rd_strm(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->rd_strm)
-#define spi_rti(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->rti)
-#define spi_pcomp_en(x)	(((struct spi_transport_attrs *)&(x)->transport_data)->pcomp_en)
+#define spi_period(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->period)
+#define spi_offset(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->offset)
+#define spi_width(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->width)
+#define spi_iu(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->iu)
+#define spi_dt(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->dt)
+#define spi_qas(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->qas)
+#define spi_wr_flow(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->wr_flow)
+#define spi_rd_strm(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->rd_strm)
+#define spi_rti(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->rti)
+#define spi_pcomp_en(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->pcomp_en)
+#define spi_initial_dv(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->initial_dv)
+
+#define spi_support_sync(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->support_sync)
+#define spi_support_wide(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->support_wide)
+#define spi_support_dt(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->support_dt)
+#define spi_support_dt_only(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->support_dt_only)
+#define spi_support_ius(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->support_ius)
+#define spi_support_qas(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->support_qas)
+
+#define spi_flags(x)	(((struct spi_transport_attrs *)&(x)->starget_data)->flags)
+#define spi_signalling(h)	(((struct spi_host_attrs *)(h)->shost_data)->signalling)
+
+
 
 /* The functions by which the transport class and the driver communicate */
 struct spi_function_template {
-	void	(*get_period)(struct scsi_device *);
-	void	(*set_period)(struct scsi_device *, int);
-	void	(*get_offset)(struct scsi_device *);
-	void	(*set_offset)(struct scsi_device *, int);
-	void	(*get_width)(struct scsi_device *);
-	void	(*set_width)(struct scsi_device *, int);
-	void	(*get_iu)(struct scsi_device *);
-	void	(*set_iu)(struct scsi_device *, int);
-	void	(*get_dt)(struct scsi_device *);
-	void	(*set_dt)(struct scsi_device *, int);
-	void	(*get_qas)(struct scsi_device *);
-	void	(*set_qas)(struct scsi_device *, int);
-	void	(*get_wr_flow)(struct scsi_device *);
-	void	(*set_wr_flow)(struct scsi_device *, int);
-	void	(*get_rd_strm)(struct scsi_device *);
-	void	(*set_rd_strm)(struct scsi_device *, int);
-	void	(*get_rti)(struct scsi_device *);
-	void	(*set_rti)(struct scsi_device *, int);
-	void	(*get_pcomp_en)(struct scsi_device *);
-	void	(*set_pcomp_en)(struct scsi_device *, int);
+	void	(*get_period)(struct scsi_target *);
+	void	(*set_period)(struct scsi_target *, int);
+	void	(*get_offset)(struct scsi_target *);
+	void	(*set_offset)(struct scsi_target *, int);
+	void	(*get_width)(struct scsi_target *);
+	void	(*set_width)(struct scsi_target *, int);
+	void	(*get_iu)(struct scsi_target *);
+	void	(*set_iu)(struct scsi_target *, int);
+	void	(*get_dt)(struct scsi_target *);
+	void	(*set_dt)(struct scsi_target *, int);
+	void	(*get_qas)(struct scsi_target *);
+	void	(*set_qas)(struct scsi_target *, int);
+	void	(*get_wr_flow)(struct scsi_target *);
+	void	(*set_wr_flow)(struct scsi_target *, int);
+	void	(*get_rd_strm)(struct scsi_target *);
+	void	(*set_rd_strm)(struct scsi_target *, int);
+	void	(*get_rti)(struct scsi_target *);
+	void	(*set_rti)(struct scsi_target *, int);
+	void	(*get_pcomp_en)(struct scsi_target *);
+	void	(*set_pcomp_en)(struct scsi_target *, int);
+	void	(*get_signalling)(struct Scsi_Host *);
+	void	(*set_signalling)(struct Scsi_Host *, enum spi_signal_type);
 	/* The driver sets these to tell the transport class it
 	 * wants the attributes displayed in sysfs.  If the show_ flag
 	 * is not set, the attribute will be private to the transport
diff -Nru a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
--- a/include/sound/ac97_codec.h	2004-12-24 13:36:55 -08:00
+++ b/include/sound/ac97_codec.h	2004-12-24 13:36:55 -08:00
@@ -26,6 +26,7 @@
  */
 
 #include <linux/bitops.h>
+#include "pcm.h"
 #include "control.h"
 #include "info.h"
 
@@ -133,6 +134,11 @@
 #define AC97_BC_20BIT_ADC	0x0200	/* 20-bit ADC resolution */
 #define AC97_BC_ADC_MASK	0x0300
 
+/* general purpose */
+#define AC97_GP_DRSS_MASK	0x0c00	/* double rate slot select */
+#define AC97_GP_DRSS_1011	0x0000	/* LR(C) 10+11(+12) */
+#define AC97_GP_DRSS_78		0x0400	/* LR 7+8 */
+
 /* extended audio ID bit defines */
 #define AC97_EI_VRA		0x0001	/* Variable bit rate supported */
 #define AC97_EI_DRA		0x0002	/* Double rate supported */
@@ -348,6 +354,8 @@
 #define AC97_SCAP_SKIP_AUDIO	(1<<4)	/* skip audio part of codec */
 #define AC97_SCAP_SKIP_MODEM	(1<<5)	/* skip modem part of codec */
 #define AC97_SCAP_INDEP_SDIN	(1<<6)	/* independent SDIN */
+#define AC97_SCAP_INV_EAPD	(1<<7)	/* inverted EAPD */
+#define AC97_SCAP_DETECT_BY_VENDOR (1<<8) /* use vendor registers for read tests */
 
 /* ac97->flags */
 #define AC97_HAS_PC_BEEP	(1<<0)	/* force PC Speaker usage */
@@ -355,6 +363,7 @@
 #define AC97_CS_SPDIF		(1<<2)	/* Cirrus Logic uses funky SPDIF */
 #define AC97_CX_SPDIF		(1<<3)	/* Conexant's spdif interface */
 #define AC97_STEREO_MUTES	(1<<4)	/* has stereo mute bits */
+#define AC97_DOUBLE_RATE	(1<<5)	/* supports double rate playback */
 
 /* rates indexes */
 #define AC97_RATES_FRONT_DAC	0
@@ -369,6 +378,7 @@
 	AC97_SHARED_TYPE_NONE,
 	AC97_SHARED_TYPE_ICH,
 	AC97_SHARED_TYPE_ATIIXP,
+	AC97_SHARED_TYPE_VIA,
 	AC97_SHARED_TYPES
 };
 
@@ -432,6 +442,7 @@
 	snd_card_t *card;
 	unsigned short num;	/* bus number */
 	unsigned short no_vra: 1, /* bridge doesn't support VRA */
+		       dra: 1,	/* bridge supports double rate */
 		       isdin: 1;/* independent SDIN */
 	unsigned int clock;	/* AC'97 base clock (usually 48000Hz) */
 	spinlock_t bus_lock;	/* used mainly for slot allocation */
@@ -518,6 +529,7 @@
 /* functions */
 int snd_ac97_bus(snd_card_t *card, int num, ac97_bus_ops_t *ops, void *private_data, ac97_bus_t **rbus); /* create new AC97 bus */
 int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97);	/* create mixer controls */
+const char *snd_ac97_get_short_name(ac97_t *ac97);
 
 void snd_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short value);
 unsigned short snd_ac97_read(ac97_t *ac97, unsigned short reg);
@@ -538,18 +550,20 @@
 	AC97_TUNE_SWAP_SURROUND, /* swap master and surround controls */
 	AC97_TUNE_AD_SHARING,	/* for AD1985, turn on OMS bit and use headphone */
 	AC97_TUNE_ALC_JACK,	/* for Realtek, enable JACK detection */
+	AC97_TUNE_INV_EAPD,	/* inverted EAPD implementation */
 };
 
 struct ac97_quirk {
 	unsigned short vendor;	/* PCI vendor id */
 	unsigned short device;	/* PCI device id */
 	unsigned short mask;	/* device id bit mask, 0 = accept all */
+	unsigned int codec_id;	/* codec id (if any), 0 = accept all */
 	const char *name;	/* name shown as info */
 	int type;		/* quirk type above */
 };
 
 int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, int override);
-int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned short rate);
+int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned int rate);
 
 int snd_ac97_pcm_assign(ac97_bus_t *ac97,
 			unsigned short pcms_count,
@@ -557,5 +571,6 @@
 int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
 		      enum ac97_pcm_cfg cfg, unsigned short slots);
 int snd_ac97_pcm_close(struct ac97_pcm *pcm);
+int snd_ac97_pcm_double_rate_rules(snd_pcm_runtime_t *runtime);
 
 #endif /* __SOUND_AC97_CODEC_H */
diff -Nru a/include/sound/core.h b/include/sound/core.h
--- a/include/sound/core.h	2004-12-24 13:37:31 -08:00
+++ b/include/sound/core.h	2004-12-24 13:37:31 -08:00
@@ -307,8 +307,8 @@
 #define vfree_nocheck(obj) vfree(obj)
 #endif
 char *snd_kmalloc_strdup(const char *string, int flags);
-int copy_to_user_fromio(void __user *dst, unsigned long src, size_t count);
-int copy_from_user_toio(unsigned long dst, const void __user *src, size_t count);
+int copy_to_user_fromio(void __user *dst, const void __iomem *src, size_t count);
+int copy_from_user_toio(void __iomem *dst, const void __user *src, size_t count);
 
 /* init.c */
 
@@ -417,7 +417,7 @@
  */
 #define snd_assert(expr, args...) do {\
 	if (unlikely(!(expr))) {				\
-		snd_printk("BUG? (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\
+		snd_printk(KERN_ERR "BUG? (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\
 		args;\
 	}\
 } while (0)
@@ -433,7 +433,7 @@
  */
 #define snd_runtime_check(expr, args...) do {\
 	if (unlikely(!(expr))) {				\
-		snd_printk("ERROR (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\
+		snd_printk(KERN_ERR "ERROR (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\
 		args;\
 	}\
 } while (0)
diff -Nru a/include/sound/cs46xx.h b/include/sound/cs46xx.h
--- a/include/sound/cs46xx.h	2004-12-24 13:36:34 -08:00
+++ b/include/sound/cs46xx.h	2004-12-24 13:36:34 -08:00
@@ -1662,7 +1662,7 @@
 typedef struct {
 	char name[24];
 	unsigned long base;
-	unsigned long remap_addr;
+	void __iomem *remap_addr;
 	unsigned long size;
 	struct resource *resource;
 } snd_cs46xx_region_t;
diff -Nru a/include/sound/emu10k1.h b/include/sound/emu10k1.h
--- a/include/sound/emu10k1.h	2004-12-24 13:36:31 -08:00
+++ b/include/sound/emu10k1.h	2004-12-24 13:36:31 -08:00
@@ -737,6 +737,9 @@
 #define FXGPREGBASE		0x100		/* FX general purpose registers base       	*/
 #define A_FXGPREGBASE		0x400		/* Audigy GPRs, 0x400 to 0x5ff			*/
 
+#define A_TANKMEMCTLREGBASE	0x100		/* Tank memory control registers base - only for Audigy */
+#define A_TANKMEMCTLREG_MASK	0x1f		/* only 5 bits used - only for Audigy */
+
 /* Tank audio data is logarithmically compressed down to 16 bits before writing to TRAM and is	*/
 /* decompressed back to 20 bits on a read.  There are a total of 160 locations, the last 32	*/
 /* locations are for external TRAM. 								*/
@@ -857,7 +860,7 @@
 	struct list_head list;		/* list link container */
 	unsigned int vcount;
 	unsigned int count;		/* count of GPR (1..16) */
-	unsigned char gpr[32];		/* GPR number(s) */
+	unsigned short gpr[32];		/* GPR number(s) */
 	unsigned int value[32];
 	unsigned int min;		/* minimum range */
 	unsigned int max;		/* maximum range */
@@ -870,7 +873,7 @@
 typedef struct _snd_emu10k1_fx8010_irq {
 	struct _snd_emu10k1_fx8010_irq *next;
 	snd_fx8010_irq_handler_t *handler;
-	unsigned char gpr_running;
+	unsigned short gpr_running;
 	void *private_data;
 } snd_emu10k1_fx8010_irq_t;
 
@@ -881,12 +884,12 @@
 	unsigned int channels;		/* 16-bit channels count */
 	unsigned int tram_start;	/* initial ring buffer position in TRAM (in samples) */
 	unsigned int buffer_size;	/* count of buffered samples */
-	unsigned char gpr_size;		/* GPR containing size of ring buffer in samples (host) */
-	unsigned char gpr_ptr;		/* GPR containing current pointer in the ring buffer (host = reset, FX8010) */
-	unsigned char gpr_count;	/* GPR containing count of samples between two interrupts (host) */
-	unsigned char gpr_tmpcount;	/* GPR containing current count of samples to interrupt (host = set, FX8010) */
-	unsigned char gpr_trigger;	/* GPR containing trigger (activate) information (host) */
-	unsigned char gpr_running;	/* GPR containing info if PCM is running (FX8010) */
+	unsigned short gpr_size;		/* GPR containing size of ring buffer in samples (host) */
+	unsigned short gpr_ptr;		/* GPR containing current pointer in the ring buffer (host = reset, FX8010) */
+	unsigned short gpr_count;	/* GPR containing count of samples between two interrupts (host) */
+	unsigned short gpr_tmpcount;	/* GPR containing current count of samples to interrupt (host = set, FX8010) */
+	unsigned short gpr_trigger;	/* GPR containing trigger (activate) information (host) */
+	unsigned short gpr_running;	/* GPR containing info if PCM is running (FX8010) */
 	unsigned char etram[32];	/* external TRAM address & data */
 	snd_pcm_indirect_t pcm_rec;
 	unsigned int tram_pos;
@@ -1141,6 +1144,13 @@
 #define ITRAM_ADDR(x)	(TANKMEMADDRREGBASE + 0x00 + (x)) /* x = 0x00 - 0x7f */
 #define ETRAM_ADDR(x)	(TANKMEMADDRREGBASE + 0x80 + (x)) /* x = 0x00 - 0x1f */
 
+#define A_ITRAM_DATA(x)	(TANKMEMDATAREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
+#define A_ETRAM_DATA(x)	(TANKMEMDATAREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
+#define A_ITRAM_ADDR(x)	(TANKMEMADDRREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
+#define A_ETRAM_ADDR(x)	(TANKMEMADDRREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
+#define A_ITRAM_CTL(x)	(A_TANKMEMCTLREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
+#define A_ETRAM_CTL(x)	(A_TANKMEMCTLREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
+
 #define A_FXBUS(x)	(0x00 + (x))	/* x = 0x00 - 0x3f? */
 #define A_EXTIN(x)	(0x40 + (x))	/* x = 0x00 - 0x1f? */
 #define A_EXTOUT(x)	(0x60 + (x))	/* x = 0x00 - 0x1f? */
@@ -1269,8 +1279,11 @@
 #define A_C_00100000	0xd5
 #define A_GPR_ACCU	0xd6		/* ACCUM, accumulator */
 #define A_GPR_COND	0xd7		/* CCR, condition register */
-/* 0xd8 = noise1 */
-/* 0xd9 = noise2 */
+#define A_GPR_NOISE0	0xd8		/* noise source */
+#define A_GPR_NOISE1	0xd9		/* noise source */
+#define A_GPR_IRQ	0xda		/* IRQ register */
+#define A_GPR_DBAC	0xdb		/* TRAM Delay Base Address Counter - internal */
+#define A_GPR_DBACE	0xde		/* TRAM Delay Base Address Counter - external */
 
 /* definitions for debug register */
 #define EMU10K1_DBG_ZC			0x80000000	/* zero tram counter */
@@ -1310,7 +1323,7 @@
 	snd_ctl_elem_id_t id;		/* full control ID definition */
 	unsigned int vcount;		/* visible count */
 	unsigned int count;		/* count of GPR (1..16) */
-	unsigned char gpr[32];		/* GPR number(s) */
+	unsigned short gpr[32];		/* GPR number(s) */
 	unsigned int value[32];		/* initial values */
 	unsigned int min;		/* minimum range */
 	unsigned int max;		/* maximum range */
@@ -1320,8 +1333,8 @@
 typedef struct {
 	char name[128];
 
-	unsigned long gpr_valid[0x100/(sizeof(unsigned long)*8)]; /* bitmask of valid initializers */
-	unsigned int gpr_map[0x100];	  /* initializers */
+	DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */
+	unsigned int gpr_map[0x200];	  /* initializers */
 
 	unsigned int gpr_add_control_count; /* count of GPR controls to add/replace */
 	emu10k1_fx8010_control_gpr_t __user *gpr_add_controls; /* GPR controls to add/replace */
@@ -1333,12 +1346,12 @@
 	unsigned int gpr_list_control_total; /* total count of GPR controls */
 	emu10k1_fx8010_control_gpr_t __user *gpr_list_controls; /* listed GPR controls */
 
-	unsigned long tram_valid[0xa0/(sizeof(unsigned long)*8)]; /* bitmask of valid initializers */
-	unsigned int tram_data_map[0xa0]; /* data initializers */
-	unsigned int tram_addr_map[0xa0]; /* map initializers */
+	DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */
+	unsigned int tram_data_map[0x100]; /* data initializers */
+	unsigned int tram_addr_map[0x100]; /* map initializers */
 
-	unsigned long code_valid[512/(sizeof(unsigned long)*8)];  /* bitmask of valid instructions */
-	unsigned int code[512][2];	  /* one instruction - 64 bits */
+	DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions */
+	unsigned int code[1024][2];	  /* one instruction - 64 bits */
 } emu10k1_fx8010_code_t;
 
 typedef struct {
@@ -1354,12 +1367,12 @@
 	unsigned int channels;		/* 16-bit channels count, zero = remove this substream */
 	unsigned int tram_start;	/* ring buffer position in TRAM (in samples) */
 	unsigned int buffer_size;	/* count of buffered samples */
-	unsigned char gpr_size;		/* GPR containing size of ringbuffer in samples (host) */
-	unsigned char gpr_ptr;		/* GPR containing current pointer in the ring buffer (host = reset, FX8010) */
-	unsigned char gpr_count;	/* GPR containing count of samples between two interrupts (host) */
-	unsigned char gpr_tmpcount;	/* GPR containing current count of samples to interrupt (host = set, FX8010) */
-	unsigned char gpr_trigger;	/* GPR containing trigger (activate) information (host) */
-	unsigned char gpr_running;	/* GPR containing info if PCM is running (FX8010) */
+	unsigned short gpr_size;		/* GPR containing size of ringbuffer in samples (host) */
+	unsigned short gpr_ptr;		/* GPR containing current pointer in the ring buffer (host = reset, FX8010) */
+	unsigned short gpr_count;	/* GPR containing count of samples between two interrupts (host) */
+	unsigned short gpr_tmpcount;	/* GPR containing current count of samples to interrupt (host = set, FX8010) */
+	unsigned short gpr_trigger;	/* GPR containing trigger (activate) information (host) */
+	unsigned short gpr_running;	/* GPR containing info if PCM is running (FX8010) */
 	unsigned char pad;		/* reserved */
 	unsigned char etram[32];	/* external TRAM address & data (one per channel) */
 	unsigned int res2;		/* reserved */
diff -Nru a/include/sound/hdsp.h b/include/sound/hdsp.h
--- a/include/sound/hdsp.h	2004-12-24 13:37:19 -08:00
+++ b/include/sound/hdsp.h	2004-12-24 13:37:19 -08:00
@@ -32,13 +32,13 @@
 typedef struct _snd_hdsp_peak_rms hdsp_peak_rms_t;
 
 struct _snd_hdsp_peak_rms {
-	unsigned int input_peaks[26];
-	unsigned int playback_peaks[26];
-	unsigned int output_peaks[28];
-	unsigned long long input_rms[26];
-	unsigned long long playback_rms[26];
+	u32 input_peaks[26];
+	u32 playback_peaks[26];
+	u32 output_peaks[28];
+	u64 input_rms[26];
+	u64 playback_rms[26];
 	/* These are only used for H96xx cards */
-	unsigned long long output_rms[26];
+	u64 output_rms[26];
 };
 
 #define SNDRV_HDSP_IOCTL_GET_PEAK_RMS _IOR('H', 0x40, hdsp_peak_rms_t)
@@ -76,7 +76,7 @@
 typedef struct _snd_hdsp_firmware hdsp_firmware_t;
 
 struct _snd_hdsp_firmware {
-	unsigned long __user *firmware_data;	/* 24413 long words */
+	void __user *firmware_data;	/* 24413 x 4 bytes */
 };
 
 #define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW('H', 0x42, hdsp_firmware_t)
diff -Nru a/include/sound/opl3.h b/include/sound/opl3.h
--- a/include/sound/opl3.h	2004-12-24 13:36:18 -08:00
+++ b/include/sound/opl3.h	2004-12-24 13:36:18 -08:00
@@ -274,6 +274,9 @@
 	snd_timer_t *timer2;
 	spinlock_t timer_lock;
 
+	void *private_data;
+	void (*private_free)(opl3_t *);
+
 	spinlock_t reg_lock;
 	snd_card_t *card;		/* The card that this belongs to */
 	int used;			/* usage flag - exclusive */
@@ -314,6 +317,8 @@
 
 /* opl3.c */
 void snd_opl3_interrupt(snd_hwdep_t * hw);
+int snd_opl3_new(snd_card_t *card, unsigned short hardware, opl3_t **ropl3);
+int snd_opl3_init(opl3_t *opl3);
 int snd_opl3_create(snd_card_t * card,
 		    unsigned long l_port, unsigned long r_port,
 		    unsigned short hardware,
diff -Nru a/include/sound/pcm.h b/include/sound/pcm.h
--- a/include/sound/pcm.h	2004-12-24 13:36:49 -08:00
+++ b/include/sound/pcm.h	2004-12-24 13:36:49 -08:00
@@ -364,6 +364,7 @@
 typedef struct _snd_pcm_group {		/* keep linked substreams */
 	spinlock_t lock;
 	struct list_head substreams;
+	int count;
 } snd_pcm_group_t;
 
 struct _snd_pcm_substream {
@@ -405,6 +406,8 @@
 	snd_info_entry_t *proc_sw_params_entry;
 	snd_info_entry_t *proc_status_entry;
 	snd_info_entry_t *proc_prealloc_entry;
+	/* misc flags */
+	unsigned int no_mmap_ctrl: 1;
 };
 
 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
@@ -486,6 +489,7 @@
 int snd_pcm_prepare(snd_pcm_substream_t *substream);
 int snd_pcm_start(snd_pcm_substream_t *substream);
 int snd_pcm_stop(snd_pcm_substream_t *substream, int status);
+int snd_pcm_drain_done(snd_pcm_substream_t *substream);
 #ifdef CONFIG_PM
 int snd_pcm_suspend(snd_pcm_substream_t *substream);
 int snd_pcm_suspend_all(snd_pcm_t *pcm);
diff -Nru a/include/sound/seq_kernel.h b/include/sound/seq_kernel.h
--- a/include/sound/seq_kernel.h	2004-12-24 13:37:29 -08:00
+++ b/include/sound/seq_kernel.h	2004-12-24 13:37:29 -08:00
@@ -180,4 +180,12 @@
 			      int cap, int type, int midi_channels, int midi_voices, char *portname);
 int snd_seq_event_port_detach(int client, int port);
 
+#ifdef CONFIG_KMOD
+void snd_seq_autoload_lock(void);
+void snd_seq_autoload_unlock(void);
+#else
+#define snd_seq_autoload_lock()
+#define snd_seq_autoload_unlock()
+#endif
+
 #endif /* __SOUND_SEQ_KERNEL_H */
diff -Nru a/include/sound/ymfpci.h b/include/sound/ymfpci.h
--- a/include/sound/ymfpci.h	2004-12-24 13:36:47 -08:00
+++ b/include/sound/ymfpci.h	2004-12-24 13:36:47 -08:00
@@ -305,7 +305,7 @@
 	unsigned int device_id;	/* PCI device ID */
 	unsigned int rev;	/* PCI revision */
 	unsigned long reg_area_phys;
-	unsigned long reg_area_virt;
+	void __iomem *reg_area_virt;
 	struct resource *res_reg_area;
 	struct resource *fm_res;
 	struct resource *mpu_res;
diff -Nru a/include/video/kyro.h b/include/video/kyro.h
--- a/include/video/kyro.h	2004-12-24 13:37:19 -08:00
+++ b/include/video/kyro.h	2004-12-24 13:37:19 -08:00
@@ -13,7 +13,7 @@
 #define _KYRO_H
 
 struct kyrofb_info {
-	void *regbase;
+	void __iomem *regbase;
 
 	u32 HTot;	/* Hor Total Time    */
 	u32 HFP;	/* Hor Front Porch   */
diff -Nru a/include/video/mach64.h b/include/video/mach64.h
--- a/include/video/mach64.h	2004-12-24 13:37:00 -08:00
+++ b/include/video/mach64.h	2004-12-24 13:37:00 -08:00
@@ -68,6 +68,8 @@
 
 #define I2C_CNTL_0		0x003C	/* Dword offset 0_0F */
 
+#define DSTN_CONTROL_LG		0x003C	/* Dword offset 0_0F (LG) */
+
 /* Overscan */
 #define OVR_CLR			0x0040	/* Dword offset 0_10 */
 #define OVR2_CLR		0x0040	/* Dword offset 0_10 */
@@ -101,7 +103,7 @@
 #define CUR_HORZ_VERT_OFF	0x0070	/* Dword offset 0_1C */
 #define CUR2_HORZ_VERT_OFF	0x0070	/* Dword offset 0_1C */
 
-#define CONFIG_PANEL_LG		0x0074	/* Dword offset 0_1D */
+#define CONFIG_PANEL_LG		0x0074	/* Dword offset 0_1D (LG) */
 
 /* General I/O Control */
 #define GP_IO			0x0078	/* Dword offset 0_1E */
@@ -116,7 +118,31 @@
 #define SCRATCH_REG3		0x008C	/* Dword offset 0_23 */
 
 /* Clock Control */
-#define CLOCK_CNTL		0x0090	/* Dword offset 0_24 */
+#define CLOCK_CNTL			0x0090	/* Dword offset 0_24 */
+/* CLOCK_CNTL register constants CT LAYOUT */
+#define CLOCK_SEL			0x0f
+#define CLOCK_SEL_INTERNAL		0x03
+#define CLOCK_SEL_EXTERNAL		0x0c
+#define CLOCK_DIV			0x30
+#define CLOCK_DIV1			0x00
+#define CLOCK_DIV2			0x10
+#define CLOCK_DIV4			0x20
+#define CLOCK_STROBE			0x40
+/*  ?					0x80 */
+/* CLOCK_CNTL register constants GX LAYOUT */
+#define CLOCK_BIT			0x04	/* For ICS2595 */
+#define CLOCK_PULSE			0x08	/* For ICS2595 */
+/*#define CLOCK_STROBE			0x40 dito as CT */
+#define CLOCK_DATA			0x80
+
+/* For internal PLL(CT) start */
+#define CLOCK_CNTL_ADDR			CLOCK_CNTL + 1
+#define PLL_WR_EN			0x02
+#define PLL_ADDR			0xfc
+#define CLOCK_CNTL_DATA			CLOCK_CNTL + 2
+#define PLL_DATA			0xff
+/* For internal PLL(CT) end */
+
 #define CLOCK_SEL_CNTL		0x0090	/* Dword offset 0_24 */
 
 /* Configuration */
@@ -129,6 +155,8 @@
 #define LCD_INDEX		0x00A4	/* Dword offset 0_29 */
 #define LCD_DATA		0x00A8	/* Dword offset 0_2A */
 
+#define HFB_PITCH_ADDR_LG	0x00A8	/* Dword offset 0_2A (LG) */
+
 /* Memory Control */
 #define EXT_MEM_CNTL		0x00AC	/* Dword offset 0_2B */
 #define MEM_CNTL		0x00B0	/* Dword offset 0_2C */
@@ -137,6 +165,8 @@
 
 #define I2C_CNTL_1		0x00BC	/* Dword offset 0_2F */
 
+#define LT_GIO_LG		0x00BC	/* Dword offset 0_2F (LG) */
+
 /* DAC Control */
 #define DAC_REGS		0x00C0	/* Dword offset 0_30 */
 #define DAC_W_INDEX		0x00C0	/* Dword offset 0_30 */
@@ -147,14 +177,16 @@
 
 #define EXT_DAC_REGS		0x00C8	/* Dword offset 0_32 */
 
+#define HORZ_STRETCHING_LG	0x00C8	/* Dword offset 0_32 (LG) */
+#define VERT_STRETCHING_LG	0x00CC	/* Dword offset 0_33 (LG) */
+
 /* Test and Debug */
 #define GEN_TEST_CNTL		0x00D0	/* Dword offset 0_34 */
 
 /* Custom Macros */
 #define CUSTOM_MACRO_CNTL	0x00D4	/* Dword offset 0_35 */
 
-#define LCD_GEN_CNTL_LG		0x00D4	/* Dword offset 0_35 */
-
+#define LCD_GEN_CNTL_LG		0x00D4	/* Dword offset 0_35 (LG) */
 #define POWER_MANAGEMENT_LG	0x00D8	/* Dword offset 0_36 (LG) */
 
 /* Configuration */
@@ -558,7 +590,7 @@
 #define CRTC_CSYNC_EN		0x00000010
 #define CRTC_PIX_BY_2_EN	0x00000020	/* unused on RAGE */
 #define CRTC_DISPLAY_DIS	0x00000040
-#define CRTC_VGA_XOVERSCAN	0x00000040
+#define CRTC_VGA_XOVERSCAN	0x00000080
 
 #define CRTC_PIX_WIDTH_MASK	0x00000700
 #define CRTC_PIX_WIDTH_4BPP	0x00000100
@@ -572,25 +604,95 @@
 #define CRTC_PIX_ORDER_MSN_LSN	0x00000000
 #define CRTC_PIX_ORDER_LSN_MSN	0x00000800
 
+#define CRTC_VSYNC_INT_EN	0x00001000ul	/* XC/XL */
+#define CRTC_VSYNC_INT		0x00002000ul	/* XC/XL */
+#define CRTC_FIFO_OVERFILL	0x0000c000ul	/* VT/GT */
+#define CRTC2_VSYNC_INT_EN	0x00004000ul	/* XC/XL */
+#define CRTC2_VSYNC_INT		0x00008000ul	/* XC/XL */
+
 #define CRTC_FIFO_LWM		0x000f0000
+#define CRTC_HVSYNC_IO_DRIVE	0x00010000	/* XC/XL */
+#define CRTC2_PIX_WIDTH		0x000e0000	/* LTPro */
 
-#define VGA_128KAP_PAGING	0x00100000
-#define VFC_SYNC_TRISTATE	0x00200000
+#define CRTC_VGA_128KAP_PAGING	0x00100000
+#define CRTC_VFC_SYNC_TRISTATE	0x00200000	/* VTB/GTB/LT */
+#define CRTC2_EN		0x00200000	/* LTPro */
 #define CRTC_LOCK_REGS		0x00400000
 #define CRTC_SYNC_TRISTATE	0x00800000
 
 #define CRTC_EXT_DISP_EN	0x01000000
-#define CRTC_ENABLE		0x02000000
-#define CRTC_DISP_REQ_ENB	0x04000000
-#define VGA_ATI_LINEAR		0x08000000
+#define CRTC_EN			0x02000000
+#define CRTC_DISP_REQ_EN	0x04000000
+#define CRTC_VGA_LINEAR		0x08000000
 #define CRTC_VSYNC_FALL_EDGE	0x10000000
-#define VGA_TEXT_132		0x20000000
-#define VGA_XCRT_CNT_EN		0x40000000
-#define VGA_CUR_B_TEST		0x80000000
+#define CRTC_VGA_TEXT_132	0x20000000
+#define CRTC_CNT_EN		0x40000000
+#define CRTC_CUR_B_TEST		0x80000000
 
 #define CRTC_CRNT_VLINE		0x07f00000
-#define CRTC_VBLANK		0x00000001
 
+#define CRTC_PRESERVED_MASK	0x0001f000
+
+#define CRTC_VBLANK		0x00000001
+#define CRTC_VBLANK_INT_EN	0x00000002
+#define CRTC_VBLANK_INT		0x00000004
+#define CRTC_VBLANK_INT_AK	CRTC_VBLANK_INT
+#define CRTC_VLINE_INT_EN	0x00000008
+#define CRTC_VLINE_INT		0x00000010
+#define CRTC_VLINE_INT_AK	CRTC_VLINE_INT
+#define CRTC_VLINE_SYNC		0x00000020
+#define CRTC_FRAME		0x00000040
+#define SNAPSHOT_INT_EN		0x00000080
+#define SNAPSHOT_INT		0x00000100
+#define SNAPSHOT_INT_AK		SNAPSHOT_INT
+#define I2C_INT_EN		0x00000200
+#define I2C_INT			0x00000400
+#define I2C_INT_AK		I2C_INT
+#define CRTC2_VBLANK		0x00000800
+#define CRTC2_VBLANK_INT_EN	0x00001000
+#define CRTC2_VBLANK_INT	0x00002000
+#define CRTC2_VBLANK_INT_AK	CRTC2_VBLANK_INT
+#define CRTC2_VLINE_INT_EN	0x00004000
+#define CRTC2_VLINE_INT		0x00008000
+#define CRTC2_VLINE_INT_AK	CRTC2_VLINE_INT
+#define CAPBUF0_INT_EN		0x00010000
+#define CAPBUF0_INT		0x00020000
+#define CAPBUF0_INT_AK		CAPBUF0_INT
+#define CAPBUF1_INT_EN		0x00040000
+#define CAPBUF1_INT		0x00080000
+#define CAPBUF1_INT_AK		CAPBUF1_INT
+#define OVERLAY_EOF_INT_EN	0x00100000
+#define OVERLAY_EOF_INT		0x00200000
+#define OVERLAY_EOF_INT_AK	OVERLAY_EOF_INT
+#define ONESHOT_CAP_INT_EN	0x00400000
+#define ONESHOT_CAP_INT		0x00800000
+#define ONESHOT_CAP_INT_AK	ONESHOT_CAP_INT
+#define BUSMASTER_EOL_INT_EN	0x01000000
+#define BUSMASTER_EOL_INT	0x02000000
+#define BUSMASTER_EOL_INT_AK	BUSMASTER_EOL_INT
+#define GP_INT_EN		0x04000000
+#define GP_INT			0x08000000
+#define GP_INT_AK		GP_INT
+#define CRTC2_VLINE_SYNC	0x10000000
+#define SNAPSHOT2_INT_EN	0x20000000
+#define SNAPSHOT2_INT		0x40000000
+#define SNAPSHOT2_INT_AK	SNAPSHOT2_INT
+#define VBLANK_BIT2_INT		0x80000000
+#define VBLANK_BIT2_INT_AK	VBLANK_BIT2_INT
+
+#define CRTC_INT_EN_MASK	(CRTC_VBLANK_INT_EN |	\
+				 CRTC_VLINE_INT_EN |	\
+				 SNAPSHOT_INT_EN |	\
+				 I2C_INT_EN |		\
+				 CRTC2_VBLANK_INT_EN |	\
+				 CRTC2_VLINE_INT_EN |	\
+				 CAPBUF0_INT_EN |	\
+				 CAPBUF1_INT_EN |	\
+				 OVERLAY_EOF_INT_EN |	\
+				 ONESHOT_CAP_INT_EN |	\
+				 BUSMASTER_EOL_INT_EN |	\
+				 GP_INT_EN |		\
+				 SNAPSHOT2_INT_EN)
 
 /* DAC control values */
 
@@ -606,6 +708,24 @@
 #define DAC_BLANK_ADJ_1		0x00000800
 #define DAC_BLANK_ADJ_2		0x00001000
 
+/* DAC control values (my source XL/XC Register reference) */
+#define DAC_OUTPUT_MASK         0x00000001  /* 0 - PAL, 1 - NTSC */
+#define DAC_MISTERY_BIT         0x00000002  /* PS2 ? RS343 ?, EXTRA_BRIGHT for GT */
+#define DAC_BLANKING            0x00000004
+#define DAC_CMP_DISABLE         0x00000008
+#define DAC1_CLK_SEL            0x00000010
+#define PALETTE_ACCESS_CNTL     0x00000020
+#define PALETTE2_SNOOP_EN       0x00000040
+#define DAC_CMP_OUTPUT          0x00000080 /* read only */
+/* #define DAC_8BIT_EN is ok */
+#define CRT_SENSE               0x00000800 /* read only */
+#define CRT_DETECTION_ON        0x00001000
+#define DAC_VGA_ADR_EN          0x00002000
+#define DAC_FEA_CON_EN          0x00004000
+#define DAC_PDWN                0x00008000
+#define DAC_TYPE_MASK           0x00070000 /* read only */
+
+
 
 /* Mix control values */
 
@@ -635,6 +755,7 @@
 /* Mach64 engine bit constants - these are typically ORed together */
 
 /* BUS_CNTL register constants */
+#define BUS_APER_REG_DIS	0x00000010
 #define BUS_FIFO_ERR_ACK	0x00200000
 #define BUS_HOST_ERR_ACK	0x00800000
 
@@ -652,29 +773,48 @@
 /* DSP_ON_OFF register constants */
 #define DSP_OFF			0x000007ff
 #define DSP_ON			0x07ff0000
+#define VGA_DSP_OFF		DSP_OFF
+#define VGA_DSP_ON		DSP_ON
+#define VGA_DSP_XCLKS_PER_QW	DSP_XCLKS_PER_QW
 
-/* CLOCK_CNTL register constants */
-#define CLOCK_SEL		0x0f
-#define CLOCK_DIV		0x30
-#define CLOCK_DIV1		0x00
-#define CLOCK_DIV2		0x10
-#define CLOCK_DIV4		0x20
-#define CLOCK_STROBE		0x40
-#define PLL_WR_EN		0x02
-
-/* PLL register indices */
+/* PLL register indices and fields */
 #define MPLL_CNTL		0x00
+#define PLL_PC_GAIN		0x07
+#define PLL_VC_GAIN		0x18
+#define PLL_DUTY_CYC		0xE0
 #define VPLL_CNTL		0x01
 #define PLL_REF_DIV		0x02
 #define PLL_GEN_CNTL		0x03
+#define PLL_OVERRIDE		0x01	/* PLL_SLEEP */
+#define PLL_MCLK_RST		0x02	/* PLL_MRESET */
+#define OSC_EN			0x04
+#define EXT_CLK_EN		0x08
+#define FORCE_DCLK_TRI_STATE	0x08    /* VT4 -> */
+#define MCLK_SRC_SEL		0x70
+#define EXT_CLK_CNTL		0x80
+#define DLL_PWDN		0x80    /* VT4 -> */
 #define MCLK_FB_DIV		0x04
 #define PLL_VCLK_CNTL		0x05
+#define PLL_VCLK_SRC_SEL	0x03
+#define PLL_VCLK_RST		0x04
+#define PLL_VCLK_INVERT		0x08
 #define VCLK_POST_DIV		0x06
+#define VCLK0_POST		0x03
+#define VCLK1_POST		0x0C
+#define VCLK2_POST		0x30
+#define VCLK3_POST		0xC0
 #define VCLK0_FB_DIV		0x07
 #define VCLK1_FB_DIV		0x08
 #define VCLK2_FB_DIV		0x09
 #define VCLK3_FB_DIV		0x0A
 #define PLL_EXT_CNTL		0x0B
+#define PLL_XCLK_MCLK_RATIO	0x03
+#define PLL_XCLK_SRC_SEL	0x07
+#define PLL_MFB_TIMES_4_2B	0x08
+#define PLL_VCLK0_XDIV		0x10
+#define PLL_VCLK1_XDIV		0x20
+#define PLL_VCLK2_XDIV		0x40
+#define PLL_VCLK3_XDIV		0x80
 #define DLL_CNTL		0x0C
 #define DLL1_CNTL		0x0C
 #define VFC_CNTL		0x0D
@@ -690,6 +830,9 @@
 #define SPLL_CNTL2		0x17
 #define APLL_STRAPS		0x18
 #define EXT_VPLL_CNTL		0x19
+#define EXT_VPLL_EN		0x04
+#define EXT_VPLL_VGA_EN		0x08
+#define EXT_VPLL_INSYNC		0x10
 #define EXT_VPLL_REF_DIV	0x1A
 #define EXT_VPLL_FB_DIV		0x1B
 #define EXT_VPLL_MSB		0x1C
@@ -708,24 +851,6 @@
 #define PLL_YCLK_CNTL		0x29
 #define PM_DYN_CLK_CNTL		0x2A
 
-/* Fields in PLL registers */
-#define PLL_PC_GAIN		0x07
-#define PLL_VC_GAIN		0x18
-#define PLL_DUTY_CYC		0xE0
-#define PLL_OVERRIDE		0x01
-#define PLL_MCLK_RST		0x02
-#define OSC_EN			0x04
-#define EXT_CLK_EN		0x08
-#define MCLK_SRC_SEL		0x70
-#define EXT_CLK_CNTL		0x80
-#define VCLK_SRC_SEL		0x03
-#define PLL_VCLK_RST		0x04
-#define VCLK_INVERT		0x08
-#define VCLK0_POST		0x03
-#define VCLK1_POST		0x0C
-#define VCLK2_POST		0x30
-#define VCLK3_POST		0xC0
-
 /* CONFIG_CNTL register constants */
 #define APERTURE_4M_ENABLE	1
 #define APERTURE_8M_ENABLE	2
@@ -811,6 +936,7 @@
 #define MEM_BNDRY_1M		0x00030000
 #define MEM_BNDRY_EN		0x00040000
 
+#define ONE_MB			0x100000
 /* ATI PCI constants */
 #define PCI_ATI_VENDOR_ID	0x1002
 
@@ -849,7 +975,19 @@
 #define LI_CHIP_ID	0x4c49	/* RAGE LT PRO */
 #define LP_CHIP_ID	0x4c50	/* RAGE LT PRO */
 #define LT_CHIP_ID	0x4c54	/* RAGE LT */
-#define XL_CHIP_ID	0x4752	/* RAGE (XL) */
+
+/* mach64CT family / (Rage XL) class */
+#define GR_CHIP_ID	0x4752	/* RAGE XL, BGA, PCI33 */
+#define GS_CHIP_ID	0x4753	/* RAGE XL, PQFP, PCI33 */
+#define GM_CHIP_ID	0x474d	/* RAGE XL, BGA, AGP 1x,2x */
+#define GN_CHIP_ID	0x474e	/* RAGE XL, PQFP,AGP 1x,2x */
+#define GO_CHIP_ID	0x474f	/* RAGE XL, BGA, PCI66 */
+#define GL_CHIP_ID	0x474c	/* RAGE XL, PQFP, PCI66 */
+
+#define IS_XL(id) ((id)==GR_CHIP_ID || (id)==GS_CHIP_ID || \
+		   (id)==GM_CHIP_ID || (id)==GN_CHIP_ID || \
+		   (id)==GO_CHIP_ID || (id)==GL_CHIP_ID)
+
 #define GT_CHIP_ID	0x4754	/* RAGE (GT) */
 #define GU_CHIP_ID	0x4755	/* RAGE II/II+ (GTB) */
 #define GV_CHIP_ID	0x4756	/* RAGE IIC, PCI */
@@ -860,10 +998,14 @@
 #define GI_CHIP_ID	0x4749	/* RAGE PRO, BGA, PCI33 only */
 #define GP_CHIP_ID	0x4750	/* RAGE PRO, PQFP, PCI33, full 3D */
 #define GQ_CHIP_ID	0x4751	/* RAGE PRO, PQFP, PCI33, limited 3D */
-#define LM_CHIP_ID	0x4c4d	/* RAGE Mobility PCI */
-#define LN_CHIP_ID	0x4c4e	/* RAGE Mobility AGP */
 
+#define LM_CHIP_ID	0x4c4d	/* RAGE Mobility AGP, full function */
+#define LN_CHIP_ID	0x4c4e	/* RAGE Mobility AGP */
+#define LR_CHIP_ID	0x4c52	/* RAGE Mobility PCI, full function */
+#define LS_CHIP_ID	0x4c53	/* RAGE Mobility PCI */
 
+#define IS_MOBILITY(id) ((id)==LM_CHIP_ID || (id)==LN_CHIP_ID || \
+			(id)==LR_CHIP_ID || (id)==LS_CHIP_ID)
 /* Mach64 major ASIC revisions */
 #define MACH64_ASIC_NEC_VT_A3		0x08
 #define MACH64_ASIC_NEC_VT_A4		0x48
@@ -889,7 +1031,7 @@
 #define MACH64_UNKNOWN		0
 #define MACH64_GX		1
 #define MACH64_CX		2
-#define MACH64_CT		3
+#define MACH64_CT		3Restore
 #define MACH64_ET		4
 #define MACH64_VT		5
 #define MACH64_GT		6
@@ -934,26 +1076,34 @@
 #define DP_CHAIN_32BPP		0x8080
 
 /* DP_PIX_WIDTH register constants */
-#define DST_1BPP		0
-#define DST_4BPP		1
-#define DST_8BPP		2
-#define DST_15BPP		3
-#define DST_16BPP		4
-#define DST_32BPP		6
-#define SRC_1BPP		0
+#define DST_1BPP		0x0
+#define DST_4BPP		0x1
+#define DST_8BPP		0x2
+#define DST_15BPP		0x3
+#define DST_16BPP		0x4
+#define DST_24BPP		0x5
+#define DST_32BPP		0x6
+#define DST_MASK		0xF
+#define SRC_1BPP		0x000
 #define SRC_4BPP		0x100
 #define SRC_8BPP		0x200
 #define SRC_15BPP		0x300
 #define SRC_16BPP		0x400
+#define SRC_24BPP		0x500
 #define SRC_32BPP		0x600
-#define HOST_1BPP		0
+#define SRC_MASK		0xF00
+#define DP_HOST_TRIPLE_EN	0x2000
+#define HOST_1BPP		0x00000
 #define HOST_4BPP		0x10000
 #define HOST_8BPP		0x20000
 #define HOST_15BPP		0x30000
 #define HOST_16BPP		0x40000
+#define HOST_24BPP		0x50000
 #define HOST_32BPP		0x60000
+#define HOST_MASK		0xF0000
 #define BYTE_ORDER_MSB_TO_LSB	0
 #define BYTE_ORDER_LSB_TO_MSB	0x1000000
+#define BYTE_ORDER_MASK		0x1000000
 
 /* DP_MIX register constants */
 #define BKGD_MIX_NOT_D			0
@@ -1027,12 +1177,12 @@
 #define CONTEXT_CMD_DISABLE		0x80000000
 
 /* GUI_STAT register constants */
-#define ENGINE_IDLE		0
-#define ENGINE_BUSY		1
-#define SCISSOR_LEFT_FLAG	0x10
-#define SCISSOR_RIGHT_FLAG	0x20
-#define SCISSOR_TOP_FLAG	0x40
-#define SCISSOR_BOTTOM_FLAG	0x80
+#define ENGINE_IDLE			0
+#define ENGINE_BUSY			1
+#define SCISSOR_LEFT_FLAG		0x10
+#define SCISSOR_RIGHT_FLAG		0x20
+#define SCISSOR_TOP_FLAG		0x40
+#define SCISSOR_BOTTOM_FLAG		0x80
 
 /* ATI VGA Extended Regsiters */
 #define sioATIEXT		0x1ce
@@ -1043,6 +1193,7 @@
 #define ATI36			0xb6
 
 /* VGA Graphics Controller Registers */
+#define R_GENMO			0x3cc
 #define VGAGRA			0x3ce
 #define GRA06			0x06
 
@@ -1103,7 +1254,7 @@
 
 /* LCD register indices */
 #define CONFIG_PANEL		0x00
-#define LCD_GEN_CTRL		0x01
+#define LCD_GEN_CNTL		0x01
 #define DSTN_CONTROL		0x02
 #define HFB_PITCH_ADDR		0x03
 #define HORZ_STRETCHING		0x04
@@ -1148,11 +1299,79 @@
 #define APC_LUT_MN		0x39
 #define APC_LUT_OP		0x3A
 
+/* Values in LCD_GEN_CTRL */
+#define CRT_ON                          0x00000001ul
+#define LCD_ON                          0x00000002ul
+#define HORZ_DIVBY2_EN                  0x00000004ul
+#define DONT_DS_ICON                    0x00000008ul
+#define LOCK_8DOT                       0x00000010ul
+#define ICON_ENABLE                     0x00000020ul
+#define DONT_SHADOW_VPAR                0x00000040ul
+#define V2CLK_PM_EN                     0x00000080ul
+#define RST_FM                          0x00000100ul
+#define DISABLE_PCLK_RESET              0x00000200ul	/* XC/XL */
+#define DIS_HOR_CRT_DIVBY2              0x00000400ul
+#define SCLK_SEL                        0x00000800ul
+#define SCLK_DELAY                      0x0000f000ul
+#define TVCLK_PM_EN                     0x00010000ul
+#define VCLK_DAC_PM_EN                  0x00020000ul
+#define VCLK_LCD_OFF                    0x00040000ul
+#define SELECT_WAIT_4MS                 0x00080000ul
+#define XTALIN_PM_EN                    0x00080000ul	/* XC/XL */
+#define V2CLK_DAC_PM_EN                 0x00100000ul
+#define LVDS_EN                         0x00200000ul
+#define LVDS_PLL_EN                     0x00400000ul
+#define LVDS_PLL_RESET                  0x00800000ul
+#define LVDS_RESERVED_BITS              0x07000000ul
+#define CRTC_RW_SELECT                  0x08000000ul	/* LTPro */
+#define USE_SHADOWED_VEND               0x10000000ul
+#define USE_SHADOWED_ROWCUR             0x20000000ul
+#define SHADOW_EN                       0x40000000ul
+#define SHADOW_RW_EN                  	0x80000000ul
+
+#define LCD_SET_PRIMARY_MASK            0x07FFFBFBul
+
+/* Values in HORZ_STRETCHING */
+#define HORZ_STRETCH_BLEND		0x00000ffful
+#define HORZ_STRETCH_RATIO		0x0000fffful
+#define HORZ_STRETCH_LOOP		0x00070000ul
+#define HORZ_STRETCH_LOOP09		0x00000000ul
+#define HORZ_STRETCH_LOOP11		0x00010000ul
+#define HORZ_STRETCH_LOOP12		0x00020000ul
+#define HORZ_STRETCH_LOOP14		0x00030000ul
+#define HORZ_STRETCH_LOOP15		0x00040000ul
+/*	?				0x00050000ul */
+/*	?				0x00060000ul */
+/*	?				0x00070000ul */
+/*	?				0x00080000ul */
+#define HORZ_PANEL_SIZE			0x0ff00000ul	/* XC/XL */
+/*	?				0x10000000ul */
+#define AUTO_HORZ_RATIO			0x20000000ul	/* XC/XL */
+#define HORZ_STRETCH_MODE		0x40000000ul
+#define HORZ_STRETCH_EN			0x80000000ul
+
+/* Values in VERT_STRETCHING */
+#define VERT_STRETCH_RATIO0		0x000003fful
+#define VERT_STRETCH_RATIO1		0x000ffc00ul
+#define VERT_STRETCH_RATIO2		0x3ff00000ul
+#define VERT_STRETCH_USE0		0x40000000ul
+#define VERT_STRETCH_EN			0x80000000ul
+
+/* Values in EXT_VERT_STRETCH */
+#define VERT_STRETCH_RATIO3		0x000003fful
+#define FORCE_DAC_DATA			0x000000fful
+#define FORCE_DAC_DATA_SEL		0x00000300ul
+#define VERT_STRETCH_MODE		0x00000400ul
+#define VERT_PANEL_SIZE			0x003ff800ul
+#define AUTO_VERT_RATIO			0x00400000ul
+#define USE_AUTO_FP_POS			0x00800000ul
+#define USE_AUTO_LCD_VSYNC		0x01000000ul
+/*	?				0xfe000000ul */
 
 /* Values in LCD_MISC_CNTL */
-#define BIAS_MOD_LEVEL_MASK	0x0000ff00
-#define BIAS_MOD_LEVEL_SHIFT	8
-#define BLMOD_EN		0x00010000
-#define BIASMOD_EN		0x00020000
+#define BIAS_MOD_LEVEL_MASK		0x0000ff00
+#define BIAS_MOD_LEVEL_SHIFT		8
+#define BLMOD_EN			0x00010000
+#define BIASMOD_EN			0x00020000
 
-#endif /* REGMACH64_H */
+#endif				/* REGMACH64_H */
diff -Nru a/include/video/neomagic.h b/include/video/neomagic.h
--- a/include/video/neomagic.h	2004-12-24 13:36:47 -08:00
+++ b/include/video/neomagic.h	2004-12-24 13:36:47 -08:00
@@ -179,11 +179,11 @@
 #ifdef CONFIG_MTRR
 	int mtrr;
 #endif
-	u8 *mmio_vbase;
+	u8 __iomem *mmio_vbase;
 	u8 cursorOff;
 	u8 *cursorPad;		/* Must die !! */
 
-	Neo2200 *neo2200;
+	Neo2200 __iomem *neo2200;
 
 	/* Panels size */
 	int NeoPanelWidth;
diff -Nru a/include/video/radeon.h b/include/video/radeon.h
--- a/include/video/radeon.h	2004-12-24 13:37:32 -08:00
+++ b/include/video/radeon.h	2004-12-24 13:37:32 -08:00
@@ -619,8 +619,7 @@
 #define LVDS_BLON				   (1 << 19)
 #define LVDS_SEL_CRTC2				   (1 << 23)
 #define LVDS_STATE_MASK	\
-	(LVDS_ON | LVDS_DISPLAY_DIS | LVDS_BL_MOD_LEVEL_MASK | \
-	 LVDS_EN | LVDS_DIGON | LVDS_BLON)
+	(LVDS_ON | LVDS_DISPLAY_DIS | LVDS_BL_MOD_LEVEL_MASK | LVDS_BLON)
 
 /* LVDS_PLL_CNTL bit constatns */
 #define HSYNC_DELAY_SHIFT			   0x1c
diff -Nru a/include/video/sstfb.h b/include/video/sstfb.h
--- a/include/video/sstfb.h	2004-12-24 13:36:18 -08:00
+++ b/include/video/sstfb.h	2004-12-24 13:36:18 -08:00
@@ -18,11 +18,14 @@
 
 #ifdef SST_DEBUG
 #  define dprintk(X...)		printk("sstfb: " X)
+#  define SST_DEBUG_REG  1
+#  define SST_DEBUG_FUNC 1
+#  define SST_DEBUG_VAR  1
 #else
 #  define dprintk(X...)
-#  undef SST_DEBUG_REG
-#  undef SST_DEBUG_FUNC
-#  undef SST_DEBUG_VAR
+#  define SST_DEBUG_REG  0
+#  define SST_DEBUG_FUNC 0
+#  define SST_DEBUG_VAR  0
 #endif
 
 #if (SST_DEBUG_REG > 0)
@@ -340,7 +343,7 @@
 	unsigned int vBackPorch;
 	struct pll_timing pll;
 	unsigned int tiles_in_X;/* num of tiles in X res */
-	unsigned long mmio_vbase;
+	u8 __iomem *mmio_vbase;
 	struct dac_switch 	dac_sw;	/* dac specific functions */
 	struct pci_dev		*dev;
 	int	type;
diff -Nru a/include/video/tdfx.h b/include/video/tdfx.h
--- a/include/video/tdfx.h	2004-12-24 13:36:47 -08:00
+++ b/include/video/tdfx.h	2004-12-24 13:36:47 -08:00
@@ -173,7 +173,7 @@
 struct tdfx_par {
   u32 max_pixclock;
 
-  void *regbase_virt;
+  void __iomem *regbase_virt;
   unsigned long iobase;
   u32 baseline;
 
diff -Nru a/include/video/tgafb.h b/include/video/tgafb.h
--- a/include/video/tgafb.h	2004-12-24 13:37:18 -08:00
+++ b/include/video/tgafb.h	2004-12-24 13:37:18 -08:00
@@ -176,9 +176,9 @@
 	struct pci_dev *pdev;
 
 	/* Device dependent information.  */
-	void *tga_mem_base;
-	void *tga_fb_base;
-	void *tga_regs_base;
+	void __iomem *tga_mem_base;
+	void __iomem *tga_fb_base;
+	void __iomem *tga_regs_base;
 	u8 tga_type;				/* TGA_TYPE_XXX */
 	u8 tga_chip_rev;			/* dc21030 revision */
 
diff -Nru a/init/Kconfig b/init/Kconfig
--- a/init/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/init/Kconfig	2004-12-24 13:37:18 -08:00
@@ -50,6 +50,11 @@
 	depends on BROKEN || !SMP
 	default y
 
+config LOCK_KERNEL
+	bool
+	depends on SMP || PREEMPT
+	default y
+
 endmenu
 
 menu "General setup"
@@ -171,7 +176,7 @@
 
 config LOG_BUF_SHIFT
 	int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL
-	range 12 20
+	range 12 21
 	default 17 if ARCH_S390
 	default 16 if X86_NUMAQ || IA64
 	default 15 if SMP
@@ -205,6 +210,25 @@
 	  agent" (/sbin/hotplug) to load modules and set up software needed
 	  to use devices as you hotplug them.
 
+config KOBJECT_UEVENT
+	bool "Kernel Userspace Events"
+	depends on NET
+	default y
+	help
+	  This option enables the kernel userspace event layer, which is a
+	  simple mechanism for kernel-to-user communication over a netlink
+	  socket.
+	  The goal of the kernel userspace events layer is to provide a simple
+	  and efficient events system, that notifies userspace about kobject
+	  state changes. This will enable applications to just listen for
+	  events instead of polling system devices and files.
+	  Hotplug events (kobject addition and removal) are also available on
+	  the netlink socket in addition to the execution of /sbin/hotplug if
+	  CONFIG_HOTPLUG is enabled.
+
+	  Say Y, unless you are building a system requiring minimal memory
+	  consumption.
+
 config IKCONFIG
 	bool "Kernel .config support"
 	---help---
@@ -278,8 +302,6 @@
 	  Disabling this option will cause the kernel to be built without
 	  support for epoll family of system calls.
 
-source "drivers/block/Kconfig.iosched"
-
 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size" if EMBEDDED
 	default y if ARM || H8300
@@ -303,6 +325,43 @@
 	  option replaces shmem and tmpfs with the much simpler ramfs code,
 	  which may be appropriate on small systems without swap.
 
+config CC_ALIGN_FUNCTIONS
+	int "Function alignment" if EMBEDDED
+	default 0
+	help
+	  Align the start of functions to the next power-of-two greater than n,
+	  skipping up to n bytes.  For instance, 32 aligns functions
+	  to the next 32-byte boundary, but 24 would align to the next
+	  32-byte boundary only if this can be done by skipping 23 bytes or less.
+	  Zero means use compiler's default.
+
+config CC_ALIGN_LABELS
+	int "Label alignment" if EMBEDDED
+	default 0
+	help
+	  Align all branch targets to a power-of-two boundary, skipping
+	  up to n bytes like ALIGN_FUNCTIONS.  This option can easily
+	  make code slower, because it must insert dummy operations for
+	  when the branch target is reached in the usual flow of the code.
+	  Zero means use compiler's default.
+
+config CC_ALIGN_LOOPS
+	int "Loop alignment" if EMBEDDED
+	default 0
+	help
+	  Align loops to a power-of-two boundary, skipping up to n bytes.
+	  Zero means use compiler's default.
+
+config CC_ALIGN_JUMPS
+	int "Jump alignment" if EMBEDDED
+	default 0
+	help
+	  Align branch targets to a power-of-two boundary, for branch
+	  targets where the targets can only be reached by jumping,
+	  skipping up to n bytes like ALIGN_FUNCTIONS.  In this case,
+	  no dummy operations need be executed.
+	  Zero means use compiler's default.
+
 endmenu		# General setup
 
 config TINY_SHMEM
@@ -369,6 +428,18 @@
 	  to the modules to (hopefully) spot any changes which would
 	  make them incompatible with the kernel you are running.  If
 	  unsure, say N.
+
+config MODULE_SRCVERSION_ALL
+	bool "Source checksum for all modules"
+	depends on MODULES
+	help
+	  Modules which contain a MODULE_VERSION get an extra "srcversion"
+	  field inserted into their modinfo section, which contains a
+    	  sum of the source files which made it.  This helps maintainers
+	  see exactly which source was used to build a module (since
+	  others sometimes change the module source without updating
+	  the version).  With this option, such a "srcversion" field
+	  will be created for all modules.  If unsure, say N.
 
 config KMOD
 	bool "Automatic kernel module loading"
diff -Nru a/init/do_mounts.c b/init/do_mounts.c
--- a/init/do_mounts.c	2004-12-24 13:36:47 -08:00
+++ b/init/do_mounts.c	2004-12-24 13:36:47 -08:00
@@ -142,7 +142,7 @@
 	int part;
 
 #ifdef CONFIG_SYSFS
-	sys_mkdir("/sys", 0700);
+	int mkdir_err = sys_mkdir("/sys", 0700);
 	if (sys_mount("sysfs", "/sys", "sysfs", 0, NULL) < 0)
 		goto out;
 #endif
@@ -197,7 +197,8 @@
 #ifdef CONFIG_SYSFS
 	sys_umount("/sys", 0);
 out:
-	sys_rmdir("/sys");
+	if (!mkdir_err)
+		sys_rmdir("/sys");
 #endif
 	return res;
 fail:
diff -Nru a/init/do_mounts_devfs.c b/init/do_mounts_devfs.c
--- a/init/do_mounts_devfs.c	2004-12-24 13:37:43 -08:00
+++ b/init/do_mounts_devfs.c	2004-12-24 13:37:43 -08:00
@@ -2,7 +2,6 @@
 #include <linux/kernel.h>
 #include <linux/dirent.h>
 #include <linux/string.h>
-#include <linux/syscalls.h>
 
 #include "do_mounts.h"
 
diff -Nru a/init/do_mounts_rd.c b/init/do_mounts_rd.c
--- a/init/do_mounts_rd.c	2004-12-24 13:37:02 -08:00
+++ b/init/do_mounts_rd.c	2004-12-24 13:37:02 -08:00
@@ -309,14 +309,15 @@
 #define Tracecv(c,x)
 
 #define STATIC static
+#define INIT __init
 
-static int  fill_inbuf(void);
-static void flush_window(void);
-static void *malloc(size_t size);
-static void free(void *where);
-static void error(char *m);
-static void gzip_mark(void **);
-static void gzip_release(void **);
+static int  __init fill_inbuf(void);
+static void __init flush_window(void);
+static void __init *malloc(size_t size);
+static void __init free(void *where);
+static void __init error(char *m);
+static void __init gzip_mark(void **);
+static void __init gzip_release(void **);
 
 #include "../lib/inflate.c"
 
diff -Nru a/init/initramfs.c b/init/initramfs.c
--- a/init/initramfs.c	2004-12-24 13:36:17 -08:00
+++ b/init/initramfs.c	2004-12-24 13:36:17 -08:00
@@ -372,11 +372,12 @@
 #define Tracecv(c,x)
 
 #define STATIC static
+#define INIT __init
 
-static void flush_window(void);
-static void error(char *m);
-static void gzip_mark(void **);
-static void gzip_release(void **);
+static void __init flush_window(void);
+static void __init error(char *m);
+static void __init gzip_mark(void **);
+static void __init gzip_release(void **);
 
 #include "../lib/inflate.c"
 
@@ -445,8 +446,7 @@
 		bytes_out = 0;
 		crc = (ulg)0xffffffffL; /* shift register contents */
 		makecrc();
-		if (gunzip())
-			message = "ungzip failed";
+		gunzip();
 		if (state != Reset)
 			error("junk in gzipped archive");
 		this_header = saved_offset + inptr;
diff -Nru a/init/main.c b/init/main.c
--- a/init/main.c	2004-12-24 13:36:19 -08:00
+++ b/init/main.c	2004-12-24 13:36:19 -08:00
@@ -45,6 +45,7 @@
 #include <linux/unistd.h>
 #include <linux/rmap.h>
 #include <linux/mempolicy.h>
+#include <linux/key.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -287,8 +288,15 @@
 {
 	/* Change NUL term back to "=", to make "param" the whole string. */
 	if (val) {
-		if (val[-1] == '"') val[-2] = '=';
-		else val[-1] = '=';
+		/* param=val or param="val"? */
+		if (val == param+strlen(param)+1)
+			val[-1] = '=';
+		else if (val == param+strlen(param)+2) {
+			val[-2] = '=';
+			memmove(val-1, val, strlen(val)+1);
+			val--;
+		} else
+			BUG();
 	}
 
 	/* Handle obsolete-style parameters */
@@ -433,6 +441,7 @@
  */
 
 static void noinline rest_init(void)
+	__releases(kernel_lock)
 {
 	kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND);
 	numa_default_policy();
@@ -555,7 +564,7 @@
 	proc_caches_init();
 	buffer_init();
 	unnamed_dev_init();
-	security_scaffolding_startup();
+	security_init();
 	vfs_caches_init(num_physpages);
 	radix_tree_init();
 	signals_init();
@@ -595,7 +604,7 @@
 
 		if (initcall_debug) {
 			printk(KERN_DEBUG "Calling initcall 0x%p", *call);
-			print_symbol(": %s()", (unsigned long) *call);
+			print_fn_descriptor_symbol(": %s()", (unsigned long) *call);
 			printk("\n");
 		}
 
@@ -632,7 +641,7 @@
 	/* drivers will send hotplug events */
 	init_workqueues();
 	usermodehelper_init();
-
+	key_init();
 	driver_init();
 
 #ifdef CONFIG_SYSCTL
diff -Nru a/ipc/mqueue.c b/ipc/mqueue.c
--- a/ipc/mqueue.c	2004-12-24 13:36:55 -08:00
+++ b/ipc/mqueue.c	2004-12-24 13:36:55 -08:00
@@ -22,6 +22,7 @@
 #include <linux/msg.h>
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
+#include <linux/syscalls.h>
 #include <net/sock.h>
 #include "util.h"
 
@@ -145,7 +146,7 @@
 			spin_lock(&mq_lock);
 			if (u->mq_bytes + mq_bytes < u->mq_bytes ||
 		 	    u->mq_bytes + mq_bytes >
-			    p->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
+			    p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
 				spin_unlock(&mq_lock);
 				goto out_inode;
 			}
@@ -1218,11 +1219,8 @@
 	if (mqueue_inode_cachep == NULL)
 		return -ENOMEM;
 
+	/* ignore failues - they are not fatal */
 	mq_sysctl_table = register_sysctl_table(mq_sysctl_root, 0);
-	if (!mq_sysctl_table) {
-		error = -ENOMEM;
-		goto out_cache;
-	}
 
 	error = register_filesystem(&mqueue_fs_type);
 	if (error)
@@ -1242,8 +1240,8 @@
 out_filesystem:
 	unregister_filesystem(&mqueue_fs_type);
 out_sysctl:
-	unregister_sysctl_table(mq_sysctl_table);
-out_cache:
+	if (mq_sysctl_table)
+		unregister_sysctl_table(mq_sysctl_table);
 	if (kmem_cache_destroy(mqueue_inode_cachep)) {
 		printk(KERN_INFO
 			"mqueue_inode_cache: not all structures were freed\n");
diff -Nru a/ipc/msg.c b/ipc/msg.c
--- a/ipc/msg.c	2004-12-24 13:36:16 -08:00
+++ b/ipc/msg.c	2004-12-24 13:36:16 -08:00
@@ -24,6 +24,7 @@
 #include <linux/list.h>
 #include <linux/security.h>
 #include <linux/sched.h>
+#include <linux/syscalls.h>
 #include <asm/current.h>
 #include <asm/uaccess.h>
 #include "util.h"
@@ -380,7 +381,7 @@
 		int success_return;
 		if (!buf)
 			return -EFAULT;
-		if(cmd == MSG_STAT && msqid >= msg_ids.size)
+		if(cmd == MSG_STAT && msqid >= msg_ids.entries->size)
 			return -EINVAL;
 
 		memset(&tbuf,0,sizeof(tbuf));
diff -Nru a/ipc/sem.c b/ipc/sem.c
--- a/ipc/sem.c	2004-12-24 13:36:47 -08:00
+++ b/ipc/sem.c	2004-12-24 13:36:47 -08:00
@@ -71,6 +71,7 @@
 #include <linux/time.h>
 #include <linux/smp_lock.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 #include <asm/uaccess.h>
 #include "util.h"
 
@@ -523,7 +524,7 @@
 		struct semid64_ds tbuf;
 		int id;
 
-		if(semid >= sem_ids.size)
+		if(semid >= sem_ids.entries->size)
 			return -EINVAL;
 
 		memset(&tbuf,0,sizeof(tbuf));
diff -Nru a/ipc/shm.c b/ipc/shm.c
--- a/ipc/shm.c	2004-12-24 13:36:49 -08:00
+++ b/ipc/shm.c	2004-12-24 13:36:49 -08:00
@@ -26,6 +26,7 @@
 #include <linux/proc_fs.h>
 #include <linux/shmem_fs.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 #include <asm/uaccess.h>
 
 #include "util.h"
@@ -510,11 +511,6 @@
 	case SHM_LOCK:
 	case SHM_UNLOCK:
 	{
-		/* Allow superuser to lock segment in memory */
-		if (!can_do_mlock() && cmd == SHM_LOCK) {
-			err = -EPERM;
-			goto out;
-		}
 		shp = shm_lock(shmid);
 		if(shp==NULL) {
 			err = -EINVAL;
@@ -523,6 +519,16 @@
 		err = shm_checkid(shp,shmid);
 		if(err)
 			goto out_unlock;
+
+		if (!capable(CAP_IPC_LOCK)) {
+			err = -EPERM;
+			if (current->euid != shp->shm_perm.uid &&
+			    current->euid != shp->shm_perm.cuid)
+				goto out_unlock;
+			if (cmd == SHM_LOCK &&
+			    !current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur)
+				goto out_unlock;
+		}
 
 		err = security_shm_shmctl(shp, cmd);
 		if (err)
diff -Nru a/ipc/util.c b/ipc/util.c
--- a/ipc/util.c	2004-12-24 13:37:43 -08:00
+++ b/ipc/util.c	2004-12-24 13:37:43 -08:00
@@ -62,7 +62,6 @@
 
 	if(size > IPCMNI)
 		size = IPCMNI;
-	ids->size = size;
 	ids->in_use = 0;
 	ids->max_id = -1;
 	ids->seq = 0;
@@ -74,14 +73,17 @@
 		 	ids->seq_max = seq_limit;
 	}
 
-	ids->entries = ipc_rcu_alloc(sizeof(struct ipc_id)*size);
+	ids->entries = ipc_rcu_alloc(sizeof(struct kern_ipc_perm *)*size +
+				     sizeof(struct ipc_id_ary));
 
 	if(ids->entries == NULL) {
 		printk(KERN_ERR "ipc_init_ids() failed, ipc service disabled.\n");
-		ids->size = 0;
+		size = 0;
+		ids->entries = &ids->nullentry;
 	}
-	for(i=0;i<ids->size;i++)
-		ids->entries[i].p = NULL;
+	ids->entries->size = size;
+	for(i=0;i<size;i++)
+		ids->entries->p[i] = NULL;
 }
 
 /**
@@ -104,7 +106,7 @@
 	 * since ipc_ids.sem is held
 	 */
 	for (id = 0; id <= max_id; id++) {
-		p = ids->entries[id].p;
+		p = ids->entries->p[id];
 		if(p==NULL)
 			continue;
 		if (key == p->key)
@@ -118,36 +120,36 @@
  */
 static int grow_ary(struct ipc_ids* ids, int newsize)
 {
-	struct ipc_id* new;
-	struct ipc_id* old;
+	struct ipc_id_ary* new;
+	struct ipc_id_ary* old;
 	int i;
+	int size = ids->entries->size;
 
 	if(newsize > IPCMNI)
 		newsize = IPCMNI;
-	if(newsize <= ids->size)
+	if(newsize <= size)
 		return newsize;
 
-	new = ipc_rcu_alloc(sizeof(struct ipc_id)*newsize);
+	new = ipc_rcu_alloc(sizeof(struct kern_ipc_perm *)*newsize +
+			    sizeof(struct ipc_id_ary));
 	if(new == NULL)
-		return ids->size;
-	memcpy(new, ids->entries, sizeof(struct ipc_id)*ids->size);
-	for(i=ids->size;i<newsize;i++) {
-		new[i].p = NULL;
+		return size;
+	new->size = newsize;
+	memcpy(new->p, ids->entries->p, sizeof(struct kern_ipc_perm *)*size +
+					sizeof(struct ipc_id_ary));
+	for(i=size;i<newsize;i++) {
+		new->p[i] = NULL;
 	}
 	old = ids->entries;
 
 	/*
-	 * before setting the ids->entries to the new array, there must be a
-	 * smp_wmb() to make sure the memcpyed contents of the new array are
-	 * visible before the new array becomes visible.
+	 * Use rcu_assign_pointer() to make sure the memcpyed contents
+	 * of the new array are visible before the new array becomes visible.
 	 */
-	smp_wmb();	/* prevent seeing new array uninitialized. */
-	ids->entries = new;
-	smp_wmb();	/* prevent indexing into old array based on new size. */
-	ids->size = newsize;
+	rcu_assign_pointer(ids->entries, new);
 
 	ipc_rcu_putref(old);
-	return ids->size;
+	return newsize;
 }
 
 /**
@@ -175,7 +177,7 @@
 	 * ipc_ids.sem is held
 	 */
 	for (id = 0; id < size; id++) {
-		if(ids->entries[id].p == NULL)
+		if(ids->entries->p[id] == NULL)
 			goto found;
 	}
 	return -1;
@@ -191,11 +193,11 @@
 	if(ids->seq > ids->seq_max)
 		ids->seq = 0;
 
-	new->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&new->lock);
 	new->deleted = 0;
 	rcu_read_lock();
 	spin_lock(&new->lock);
-	ids->entries[id].p = new;
+	ids->entries->p[id] = new;
 	return id;
 }
 
@@ -216,15 +218,15 @@
 {
 	struct kern_ipc_perm* p;
 	int lid = id % SEQ_MULTIPLIER;
-	if(lid >= ids->size)
+	if(lid >= ids->entries->size)
 		BUG();
 
 	/* 
 	 * do not need a rcu_dereference()() here to force ordering
 	 * on Alpha, since the ipc_ids.sem is held.
 	 */	
-	p = ids->entries[lid].p;
-	ids->entries[lid].p = NULL;
+	p = ids->entries->p[lid];
+	ids->entries->p[lid] = NULL;
 	if(p==NULL)
 		BUG();
 	ids->in_use--;
@@ -234,7 +236,7 @@
 			lid--;
 			if(lid == -1)
 				break;
-		} while (ids->entries[lid].p == NULL);
+		} while (ids->entries->p[lid] == NULL);
 		ids->max_id = lid;
 	}
 	p->deleted = 1;
@@ -493,9 +495,9 @@
 {
 	struct kern_ipc_perm* out;
 	int lid = id % SEQ_MULTIPLIER;
-	if(lid >= ids->size)
+	if(lid >= ids->entries->size)
 		return NULL;
-	out = ids->entries[lid].p;
+	out = ids->entries->p[lid];
 	return out;
 }
 
@@ -503,25 +505,15 @@
 {
 	struct kern_ipc_perm* out;
 	int lid = id % SEQ_MULTIPLIER;
-	struct ipc_id* entries;
+	struct ipc_id_ary* entries;
 
 	rcu_read_lock();
-	if(lid >= ids->size) {
+	entries = rcu_dereference(ids->entries);
+	if(lid >= entries->size) {
 		rcu_read_unlock();
 		return NULL;
 	}
-
-	/* 
-	 * Note: The following two read barriers are corresponding
-	 * to the two write barriers in grow_ary(). They guarantee 
-	 * the writes are seen in the same order on the read side. 
-	 * smp_rmb() has effect on all CPUs.  rcu_dereference()
-	 * is used if there are data dependency between two reads, and 
-	 * has effect only on Alpha.
-	 */
-	smp_rmb(); /* prevent indexing old array with new size */
-	entries = rcu_dereference(ids->entries);
-	out = entries[lid].p;
+	out = entries->p[lid];
 	if(out == NULL) {
 		rcu_read_unlock();
 		return NULL;
diff -Nru a/ipc/util.h b/ipc/util.h
--- a/ipc/util.h	2004-12-24 13:36:58 -08:00
+++ b/ipc/util.h	2004-12-24 13:36:58 -08:00
@@ -15,18 +15,19 @@
 void msg_init (void);
 void shm_init (void);
 
-struct ipc_ids {
+struct ipc_id_ary {
 	int size;
+	struct kern_ipc_perm *p[0];
+};
+
+struct ipc_ids {
 	int in_use;
 	int max_id;
 	unsigned short seq;
 	unsigned short seq_max;
 	struct semaphore sem;	
-	struct ipc_id* entries;
-};
-
-struct ipc_id {
-	struct kern_ipc_perm* p;
+	struct ipc_id_ary nullentry;
+	struct ipc_id_ary* entries;
 };
 
 void __init ipc_init_ids(struct ipc_ids* ids, int size);
diff -Nru a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile	2004-12-24 13:36:31 -08:00
+++ b/kernel/Makefile	2004-12-24 13:36:31 -08:00
@@ -7,7 +7,7 @@
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
 	    rcupdate.o intermodule.o extable.o params.o posix-timers.o \
-	    kthread.o
+	    kthread.o wait.o kfifo.o sys_ni.o
 
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
@@ -24,6 +24,8 @@
 obj-$(CONFIG_AUDIT) += audit.o
 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
 obj-$(CONFIG_KPROBES) += kprobes.o
+obj-$(CONFIG_SYSFS) += ksysfs.o
+obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
 
 ifneq ($(CONFIG_IA64),y)
 # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
diff -Nru a/kernel/acct.c b/kernel/acct.c
--- a/kernel/acct.c	2004-12-24 13:36:56 -08:00
+++ b/kernel/acct.c	2004-12-24 13:36:56 -08:00
@@ -53,6 +53,7 @@
 #include <linux/vfs.h>
 #include <linux/jiffies.h>
 #include <linux/times.h>
+#include <linux/syscalls.h>
 #include <asm/uaccess.h>
 #include <asm/div64.h>
 #include <linux/blkdev.h> /* sector_div */
@@ -426,8 +427,12 @@
 #endif
 	do_div(elapsed, AHZ);
 	ac.ac_btime = xtime.tv_sec - elapsed;
-	ac.ac_utime = encode_comp_t(jiffies_to_AHZ(current->utime));
-	ac.ac_stime = encode_comp_t(jiffies_to_AHZ(current->stime));
+	ac.ac_utime = encode_comp_t(jiffies_to_AHZ(
+					    current->signal->utime +
+					    current->group_leader->utime));
+	ac.ac_stime = encode_comp_t(jiffies_to_AHZ(
+					    current->signal->stime +
+					    current->group_leader->stime));
 	/* we really need to bite the bullet and change layout */
 	ac.ac_uid = current->uid;
 	ac.ac_gid = current->gid;
@@ -440,8 +445,8 @@
 	ac.ac_gid16 = current->gid;
 #endif
 #if ACCT_VERSION==3
-	ac.ac_pid = current->pid;
-	ac.ac_ppid = current->parent->pid;
+	ac.ac_pid = current->tgid;
+	ac.ac_ppid = current->parent->tgid;
 #endif
 
 	read_lock(&tasklist_lock);	/* pin current->signal */
@@ -474,8 +479,10 @@
 	ac.ac_mem = encode_comp_t(vsize);
 	ac.ac_io = encode_comp_t(0 /* current->io_usage */);	/* %% */
 	ac.ac_rw = encode_comp_t(ac.ac_io / 1024);
-	ac.ac_minflt = encode_comp_t(current->min_flt);
-	ac.ac_majflt = encode_comp_t(current->maj_flt);
+	ac.ac_minflt = encode_comp_t(current->signal->min_flt +
+				     current->group_leader->min_flt);
+	ac.ac_majflt = encode_comp_t(current->signal->maj_flt +
+				     current->group_leader->maj_flt);
 	ac.ac_swaps = encode_comp_t(0);
 	ac.ac_exitcode = exitcode;
 
@@ -488,11 +495,11 @@
 	/*
  	 * Accounting records are not subject to resource limits.
  	 */
-	flim = current->rlim[RLIMIT_FSIZE].rlim_cur;
-	current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
+	flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
+	current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
 	file->f_op->write(file, (char *)&ac,
 			       sizeof(acct_t), &file->f_pos);
-	current->rlim[RLIMIT_FSIZE].rlim_cur = flim;
+	current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
 	set_fs(fs);
 }
 
diff -Nru a/kernel/capability.c b/kernel/capability.c
--- a/kernel/capability.c	2004-12-24 13:37:01 -08:00
+++ b/kernel/capability.c	2004-12-24 13:37:01 -08:00
@@ -10,6 +10,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 #include <asm/uaccess.h>
 
 unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings */
diff -Nru a/kernel/compat.c b/kernel/compat.c
--- a/kernel/compat.c	2004-12-24 13:36:54 -08:00
+++ b/kernel/compat.c	2004-12-24 13:36:54 -08:00
@@ -484,7 +484,7 @@
 	return 0;
 } 
 
-long compat_timer_settime(timer_t timer_id, int flags, 
+long compat_sys_timer_settime(timer_t timer_id, int flags,
 			  struct compat_itimerspec __user *new, 
 			  struct compat_itimerspec __user *old)
 { 
@@ -507,7 +507,7 @@
 	return err;
 } 
 
-long compat_timer_gettime(timer_t timer_id,
+long compat_sys_timer_gettime(timer_t timer_id,
 		struct compat_itimerspec __user *setting)
 { 
 	long err;
@@ -524,7 +524,7 @@
 	return err;
 } 
 
-long compat_clock_settime(clockid_t which_clock,
+long compat_sys_clock_settime(clockid_t which_clock,
 		struct compat_timespec __user *tp)
 {
 	long err;
@@ -541,7 +541,7 @@
 	return err;
 } 
 
-long compat_clock_gettime(clockid_t which_clock,
+long compat_sys_clock_gettime(clockid_t which_clock,
 		struct compat_timespec __user *tp)
 {
 	long err;
@@ -558,7 +558,7 @@
 	return err;
 } 
 
-long compat_clock_getres(clockid_t which_clock,
+long compat_sys_clock_getres(clockid_t which_clock,
 		struct compat_timespec __user *tp)
 {
 	long err;
@@ -575,7 +575,7 @@
 	return err;
 } 
 
-long compat_clock_nanosleep(clockid_t which_clock, int flags,
+long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
 			    struct compat_timespec __user *rqtp,
 			    struct compat_timespec __user *rmtp)
 {
diff -Nru a/kernel/cpu.c b/kernel/cpu.c
--- a/kernel/cpu.c	2004-12-24 13:37:19 -08:00
+++ b/kernel/cpu.c	2004-12-24 13:37:19 -08:00
@@ -11,7 +11,6 @@
 #include <linux/unistd.h>
 #include <linux/cpu.h>
 #include <linux/module.h>
-#include <linux/kmod.h>		/* for hotplug_path */
 #include <linux/kthread.h>
 #include <linux/stop_machine.h>
 #include <asm/semaphore.h>
@@ -57,34 +56,6 @@
 	write_unlock_irq(&tasklist_lock);
 }
 
-/* Notify userspace when a cpu event occurs, by running '/sbin/hotplug
- * cpu' with certain environment variables set.  */
-static int cpu_run_sbin_hotplug(unsigned int cpu, const char *action)
-{
-	char *argv[3], *envp[6], cpu_str[12], action_str[32], devpath_str[40];
-	int i;
-
-	sprintf(cpu_str, "CPU=%d", cpu);
-	sprintf(action_str, "ACTION=%s", action);
-	sprintf(devpath_str, "DEVPATH=devices/system/cpu/cpu%d", cpu);
-	
-	i = 0;
-	argv[i++] = hotplug_path;
-	argv[i++] = "cpu";
-	argv[i] = NULL;
-
-	i = 0;
-	/* minimal command environment */
-	envp[i++] = "HOME=/";
-	envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
-	envp[i++] = cpu_str;
-	envp[i++] = action_str;
-	envp[i++] = devpath_str;
-	envp[i] = NULL;
-
-	return call_usermodehelper(argv[0], argv, envp, 0);
-}
-
 /* Take this CPU down. */
 static int take_cpu_down(void *unused)
 {
@@ -124,6 +95,15 @@
 		goto out;
 	}
 
+	err = notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE,
+						(void *)(long)cpu);
+	if (err == NOTIFY_BAD) {
+		printk("%s: attempt to take down CPU %u failed\n",
+				__FUNCTION__, cpu);
+		err = -EINVAL;
+		goto out;
+	}
+
 	/* Ensure that we are not runnable on dying cpu */
 	old_allowed = current->cpus_allowed;
 	tmp = CPU_MASK_ALL;
@@ -132,6 +112,11 @@
 
 	p = __stop_machine_run(take_cpu_down, NULL, cpu);
 	if (IS_ERR(p)) {
+		/* CPU didn't die: tell everyone.  Can't complain. */
+		if (notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED,
+				(void *)(long)cpu) == NOTIFY_BAD)
+			BUG();
+
 		err = PTR_ERR(p);
 		goto out_allowed;
 	}
@@ -156,8 +141,6 @@
 
 	check_for_tasks(cpu);
 
-	cpu_run_sbin_hotplug(cpu, "offline");
-
 out_thread:
 	err = kthread_stop(p);
 out_allowed:
@@ -165,11 +148,6 @@
 out:
 	unlock_cpu_hotplug();
 	return err;
-}
-#else
-static inline int cpu_run_sbin_hotplug(unsigned int cpu, const char *action)
-{
-	return 0;
 }
 #endif /*CONFIG_HOTPLUG_CPU*/
 
diff -Nru a/kernel/exec_domain.c b/kernel/exec_domain.c
--- a/kernel/exec_domain.c	2004-12-24 13:37:00 -08:00
+++ b/kernel/exec_domain.c	2004-12-24 13:37:00 -08:00
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/personality.h>
 #include <linux/sched.h>
+#include <linux/syscalls.h>
 #include <linux/sysctl.h>
 #include <linux/types.h>
 
diff -Nru a/kernel/exit.c b/kernel/exit.c
--- a/kernel/exit.c	2004-12-24 13:37:19 -08:00
+++ b/kernel/exit.c	2004-12-24 13:37:19 -08:00
@@ -14,6 +14,7 @@
 #include <linux/personality.h>
 #include <linux/tty.h>
 #include <linux/namespace.h>
+#include <linux/key.h>
 #include <linux/security.h>
 #include <linux/cpu.h>
 #include <linux/acct.h>
@@ -24,6 +25,7 @@
 #include <linux/mount.h>
 #include <linux/proc_fs.h>
 #include <linux/mempolicy.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -75,7 +77,7 @@
 	 */
 	zap_leader = 0;
 	leader = p->group_leader;
-	if (leader != p && thread_group_empty(leader) && leader->state == TASK_ZOMBIE) {
+	if (leader != p && thread_group_empty(leader) && leader->exit_state == EXIT_ZOMBIE) {
 		BUG_ON(leader->exit_signal == -1);
 		do_notify_parent(leader, leader->exit_signal);
 		/*
@@ -157,7 +159,7 @@
 
 	do_each_task_pid(pgrp, PIDTYPE_PGID, p) {
 		if (p == ignored_task
-				|| p->state >= TASK_ZOMBIE 
+				|| p->exit_state >= EXIT_ZOMBIE
 				|| p->real_parent->pid == 1)
 			continue;
 		if (process_group(p->real_parent) != pgrp
@@ -237,11 +239,11 @@
 	/* rt_priority? */
 	/* signals? */
 	security_task_reparent_to_init(current);
-	memcpy(current->rlim, init_task.rlim, sizeof(*(current->rlim)));
+	memcpy(current->signal->rlim, init_task.signal->rlim,
+	       sizeof(current->signal->rlim));
 	atomic_inc(&(INIT_USER->__count));
-	switch_uid(INIT_USER);
-
 	write_unlock_irq(&tasklist_lock);
+	switch_uid(INIT_USER);
 }
 
 void __set_special_pids(pid_t session, pid_t pgrp)
@@ -509,15 +511,13 @@
 	__exit_mm(tsk);
 }
 
-EXPORT_SYMBOL(exit_mm);
-
 static inline void choose_new_parent(task_t *p, task_t *reaper, task_t *child_reaper)
 {
 	/*
 	 * Make sure we're not reparenting to ourselves and that
 	 * the parent is not a zombie.
 	 */
-	BUG_ON(p == reaper || reaper->state >= TASK_ZOMBIE);
+	BUG_ON(p == reaper || reaper->state >= EXIT_ZOMBIE || reaper->exit_state >= EXIT_ZOMBIE);
 	p->real_parent = reaper;
 	if (p->parent == p->real_parent)
 		BUG();
@@ -528,7 +528,6 @@
 	/* We don't want people slaying init.  */
 	if (p->exit_signal != -1)
 		p->exit_signal = SIGCHLD;
-	p->self_exec_id++;
 
 	if (p->pdeath_signal)
 		/* We already hold the tasklist_lock here.  */
@@ -552,7 +551,7 @@
 		/* If we'd notified the old parent about this child's death,
 		 * also notify the new parent.
 		 */
-		if (p->state == TASK_ZOMBIE && p->exit_signal != -1 &&
+		if (p->exit_state == EXIT_ZOMBIE && p->exit_signal != -1 &&
 		    thread_group_empty(p))
 			do_notify_parent(p, p->exit_signal);
 		else if (p->state == TASK_TRACED) {
@@ -600,7 +599,7 @@
 			reaper = child_reaper;
 			break;
 		}
-	} while (reaper->state >= TASK_ZOMBIE);
+	} while (reaper->exit_state >= EXIT_ZOMBIE);
 
 	/*
 	 * There are only two places where our children can be:
@@ -626,7 +625,7 @@
 		} else {
 			/* reparent ptraced task to its real parent */
 			__ptrace_unlink (p);
-			if (p->state == TASK_ZOMBIE && p->exit_signal != -1 &&
+			if (p->exit_state == EXIT_ZOMBIE && p->exit_signal != -1 &&
 			    thread_group_empty(p))
 				do_notify_parent(p, p->exit_signal);
 		}
@@ -637,7 +636,7 @@
 		 * zombie forever since we prevented it from self-reap itself
 		 * while it was being traced by us, to be able to see it in wait4.
 		 */
-		if (unlikely(ptrace && p->state == TASK_ZOMBIE && p->exit_signal == -1))
+		if (unlikely(ptrace && p->exit_state == EXIT_ZOMBIE && p->exit_signal == -1))
 			list_add(&p->ptrace_list, to_release);
 	}
 	list_for_each_safe(_p, _n, &father->ptrace_children) {
@@ -750,10 +749,10 @@
 		do_notify_parent(tsk, SIGCHLD);
 	}
 
-	state = TASK_ZOMBIE;
+	state = EXIT_ZOMBIE;
 	if (tsk->exit_signal == -1 && tsk->ptrace == 0)
-		state = TASK_DEAD;
-	tsk->state = state;
+		state = EXIT_DEAD;
+	tsk->exit_state = state;
 
 	/*
 	 * Clear these here so that update_process_times() won't try to deliver
@@ -761,7 +760,6 @@
 	 */
 	tsk->it_virt_value = 0;
 	tsk->it_prof_value = 0;
-	tsk->rlim[RLIMIT_CPU].rlim_cur = RLIM_INFINITY;
 
 	write_unlock_irq(&tasklist_lock);
 
@@ -772,7 +770,7 @@
 	}
 
 	/* If the process is dead, release it - nobody will wait for it */
-	if (state == TASK_DEAD)
+	if (state == EXIT_DEAD)
 		release_task(tsk);
 
 	/* PF_DEAD causes final put_task_struct after we schedule. */
@@ -780,9 +778,10 @@
 	tsk->flags |= PF_DEAD;
 }
 
-asmlinkage NORET_TYPE void do_exit(long code)
+fastcall NORET_TYPE void do_exit(long code)
 {
 	struct task_struct *tsk = current;
+	int group_dead;
 
 	profile_task_exit(tsk);
 
@@ -807,7 +806,9 @@
 		ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP);
 	}
 
-	acct_process(code);
+	group_dead = atomic_dec_and_test(&tsk->signal->live);
+	if (group_dead)
+		acct_process(code);
 	__exit_mm(tsk);
 
 	exit_sem(tsk);
@@ -815,8 +816,9 @@
 	__exit_fs(tsk);
 	exit_namespace(tsk);
 	exit_thread();
+	exit_keys(tsk);
 
-	if (tsk->signal->leader)
+	if (group_dead && tsk->signal->leader)
 		disassociate_ctty(1);
 
 	module_put(tsk->thread_info->exec_domain->module);
@@ -829,6 +831,8 @@
 	mpol_free(tsk->mempolicy);
 	tsk->mempolicy = NULL;
 #endif
+
+	BUG_ON(!(current->flags & PF_DEAD));
 	schedule();
 	BUG();
 	/* Avoid "noreturn function does return".  */
@@ -972,7 +976,7 @@
 }
 
 /*
- * Handle sys_wait4 work for one task in state TASK_ZOMBIE.  We hold
+ * Handle sys_wait4 work for one task in state EXIT_ZOMBIE.  We hold
  * read_lock(&tasklist_lock) on entry.  If we return zero, we still hold
  * the lock and this task is uninteresting.  If we return nonzero, we have
  * released the lock and the system call should return.
@@ -991,7 +995,7 @@
 		int exit_code = p->exit_code;
 		int why, status;
 
-		if (unlikely(p->state != TASK_ZOMBIE))
+		if (unlikely(p->exit_state != EXIT_ZOMBIE))
 			return 0;
 		if (unlikely(p->exit_signal == -1 && p->ptrace == 0))
 			return 0;
@@ -1012,9 +1016,9 @@
 	 * Try to move the task's state to DEAD
 	 * only one thread is allowed to do this:
 	 */
-	state = xchg(&p->state, TASK_DEAD);
-	if (state != TASK_ZOMBIE) {
-		BUG_ON(state != TASK_DEAD);
+	state = xchg(&p->exit_state, EXIT_DEAD);
+	if (state != EXIT_ZOMBIE) {
+		BUG_ON(state != EXIT_DEAD);
 		return 0;
 	}
 	if (unlikely(p->exit_signal == -1 && p->ptrace == 0)) {
@@ -1059,7 +1063,7 @@
 
 	/*
 	 * Now we are sure this task is interesting, and no other
-	 * thread can reap it because we set its state to TASK_DEAD.
+	 * thread can reap it because we set its state to EXIT_DEAD.
 	 */
 	read_unlock(&tasklist_lock);
 
@@ -1091,7 +1095,8 @@
 	if (!retval && infop)
 		retval = put_user(p->uid, &infop->si_uid);
 	if (retval) {
-		p->state = TASK_ZOMBIE;
+		// TODO: is this safe?
+		p->exit_state = EXIT_ZOMBIE;
 		return retval;
 	}
 	retval = p->pid;
@@ -1100,7 +1105,8 @@
 		/* Double-check with lock held.  */
 		if (p->real_parent != p->parent) {
 			__ptrace_unlink(p);
-			p->state = TASK_ZOMBIE;
+			// TODO: is this safe?
+			p->exit_state = EXIT_ZOMBIE;
 			/*
 			 * If this is not a detached task, notify the parent.
 			 * If it's still not detached after that, don't release
@@ -1171,13 +1177,13 @@
 	/*
 	 * This uses xchg to be atomic with the thread resuming and setting
 	 * it.  It must also be done with the write lock held to prevent a
-	 * race with the TASK_ZOMBIE case.
+	 * race with the EXIT_ZOMBIE case.
 	 */
 	exit_code = xchg(&p->exit_code, 0);
-	if (unlikely(p->state >= TASK_ZOMBIE)) {
+	if (unlikely(p->exit_state >= EXIT_ZOMBIE)) {
 		/*
 		 * The task resumed and then died.  Let the next iteration
-		 * catch it in TASK_ZOMBIE.  Note that exit_code might
+		 * catch it in EXIT_ZOMBIE.  Note that exit_code might
 		 * already be zero here if it resumed and did _exit(0).
 		 * The task itself is dead and won't touch exit_code again;
 		 * other processors in this function are locked out.
@@ -1193,8 +1199,15 @@
 		write_unlock_irq(&tasklist_lock);
 bail_ref:
 		put_task_struct(p);
-		read_lock(&tasklist_lock);
-		return 0;
+		/*
+		 * We are returning to the wait loop without having successfully
+		 * removed the process and having released the lock. We cannot
+		 * continue, since the "p" task pointer is potentially stale.
+		 *
+		 * Return -EAGAIN, and do_wait() will restart the loop from the
+		 * beginning. Do _not_ re-acquire the lock.
+		 */
+		return -EAGAIN;
 	}
 
 	/* move to end of parent's list to avoid starvation */
@@ -1228,6 +1241,74 @@
 	return retval;
 }
 
+/*
+ * Handle do_wait work for one task in a live, non-stopped state.
+ * read_lock(&tasklist_lock) on entry.  If we return zero, we still hold
+ * the lock and this task is uninteresting.  If we return nonzero, we have
+ * released the lock and the system call should return.
+ */
+static int wait_task_continued(task_t *p, int noreap,
+			       struct siginfo __user *infop,
+			       int __user *stat_addr, struct rusage __user *ru)
+{
+	int retval;
+	pid_t pid;
+	uid_t uid;
+
+	if (unlikely(!p->signal))
+		return 0;
+
+	if (p->signal->stop_state >= 0)
+		return 0;
+
+	spin_lock_irq(&p->sighand->siglock);
+	if (p->signal->stop_state >= 0) { /* Re-check with the lock held.  */
+		spin_unlock_irq(&p->sighand->siglock);
+		return 0;
+	}
+	if (!noreap)
+		p->signal->stop_state = 0;
+	spin_unlock_irq(&p->sighand->siglock);
+
+	pid = p->pid;
+	uid = p->uid;
+	get_task_struct(p);
+	read_unlock(&tasklist_lock);
+
+	if (!infop) {
+		retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
+		put_task_struct(p);
+		if (!retval && stat_addr)
+			retval = put_user(0xffff, stat_addr);
+		if (!retval)
+			retval = p->pid;
+	} else {
+		retval = wait_noreap_copyout(p, pid, uid,
+					     CLD_CONTINUED, SIGCONT,
+					     infop, ru);
+		BUG_ON(retval == 0);
+	}
+
+	return retval;
+}
+
+
+static inline int my_ptrace_child(struct task_struct *p)
+{
+	if (!(p->ptrace & PT_PTRACED))
+		return 0;
+	if (!(p->ptrace & PT_ATTACHED))
+		return 1;
+	/*
+	 * This child was PTRACE_ATTACH'd.  We should be seeing it only if
+	 * we are the attacher.  If we are the real parent, this is a race
+	 * inside ptrace_attach.  It is waiting for the tasklist_lock,
+	 * which we have to switch the parent links, but has already set
+	 * the flags in p->ptrace.
+	 */
+	return (p->parent != p->real_parent);
+}
+
 static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
 		    int __user *stat_addr, struct rusage __user *ru)
 {
@@ -1237,6 +1318,10 @@
 
 	add_wait_queue(&current->wait_chldexit,&wait);
 repeat:
+	/*
+	 * We will set this flag if we see any child that might later
+	 * match our criteria, even if we are not able to reap it yet.
+	 */
 	flag = 0;
 	current->state = TASK_INTERRUPTIBLE;
 	read_lock(&tasklist_lock);
@@ -1252,66 +1337,66 @@
 			ret = eligible_child(pid, options, p);
 			if (!ret)
 				continue;
-			flag = 1;
 
 			switch (p->state) {
 			case TASK_TRACED:
-				if (!(p->ptrace & PT_PTRACED))
+				if (!my_ptrace_child(p))
 					continue;
 				/*FALLTHROUGH*/
 			case TASK_STOPPED:
+				/*
+				 * It's stopped now, so it might later
+				 * continue, exit, or stop again.
+				 */
+				flag = 1;
 				if (!(options & WUNTRACED) &&
-				    !(p->ptrace & PT_PTRACED))
+				    !my_ptrace_child(p))
 					continue;
 				retval = wait_task_stopped(p, ret == 2,
 							   (options & WNOWAIT),
 							   infop,
 							   stat_addr, ru);
+				if (retval == -EAGAIN)
+					goto repeat;
 				if (retval != 0) /* He released the lock.  */
 					goto end;
 				break;
-			case TASK_ZOMBIE:
+			default:
+			// case EXIT_DEAD:
+				if (p->exit_state == EXIT_DEAD)
+					continue;
+			// case EXIT_ZOMBIE:
+				if (p->exit_state == EXIT_ZOMBIE) {
+					/*
+					 * Eligible but we cannot release
+					 * it yet:
+					 */
+					if (ret == 2)
+						goto check_continued;
+					if (!likely(options & WEXITED))
+						continue;
+					retval = wait_task_zombie(
+						p, (options & WNOWAIT),
+						infop, stat_addr, ru);
+					/* He released the lock.  */
+					if (retval != 0)
+						goto end;
+					break;
+				}
+check_continued:
 				/*
-				 * Eligible but we cannot release it yet:
+				 * It's running now, so it might later
+				 * exit, stop, or stop and then continue.
 				 */
-				if (ret == 2)
-					goto check_continued;
-				if (!likely(options & WEXITED))
+				flag = 1;
+				if (!unlikely(options & WCONTINUED))
 					continue;
-				retval = wait_task_zombie(
+				retval = wait_task_continued(
 					p, (options & WNOWAIT),
 					infop, stat_addr, ru);
 				if (retval != 0) /* He released the lock.  */
 					goto end;
 				break;
-			case TASK_DEAD:
-				continue;
-			default:
-check_continued:
-				if (!unlikely(options & WCONTINUED))
-					continue;
-				if (unlikely(!p->signal))
-					continue;
-				spin_lock_irq(&p->sighand->siglock);
-				if (p->signal->stop_state < 0) {
-					pid_t pid;
-					uid_t uid;
-
-					if (!(options & WNOWAIT))
-						p->signal->stop_state = 0;
-					spin_unlock_irq(&p->sighand->siglock);
-					pid = p->pid;
-					uid = p->uid;
-					get_task_struct(p);
-					read_unlock(&tasklist_lock);
-					retval = wait_noreap_copyout(p, pid,
-							uid, CLD_CONTINUED,
-							SIGCONT, infop, ru);
-					BUG_ON(retval == 0);
-					goto end;
-				}
-				spin_unlock_irq(&p->sighand->siglock);
-				break;
 			}
 		}
 		if (!flag) {
@@ -1412,7 +1497,8 @@
 {
 	long ret;
 
-	if (options & ~(WNOHANG|WUNTRACED|__WNOTHREAD|__WCLONE|__WALL))
+	if (options & ~(WNOHANG|WUNTRACED|WCONTINUED|
+			__WNOTHREAD|__WCLONE|__WALL))
 		return -EINVAL;
 	ret = do_wait(pid, options | WEXITED, NULL, stat_addr, ru);
 
diff -Nru a/kernel/fork.c b/kernel/fork.c
--- a/kernel/fork.c	2004-12-24 13:36:18 -08:00
+++ b/kernel/fork.c	2004-12-24 13:36:18 -08:00
@@ -24,6 +24,7 @@
 #include <linux/mempolicy.h>
 #include <linux/sem.h>
 #include <linux/file.h>
+#include <linux/key.h>
 #include <linux/binfmts.h>
 #include <linux/mman.h>
 #include <linux/fs.h>
@@ -86,7 +87,7 @@
 
 void __put_task_struct(struct task_struct *tsk)
 {
-	WARN_ON(!(tsk->state & (TASK_DEAD | TASK_ZOMBIE)));
+	WARN_ON(!(tsk->exit_state & (EXIT_DEAD | EXIT_ZOMBIE)));
 	WARN_ON(atomic_read(&tsk->usage));
 	WARN_ON(tsk == current);
 
@@ -100,131 +101,6 @@
 		free_task(tsk);
 }
 
-void fastcall add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)
-{
-	unsigned long flags;
-
-	wait->flags &= ~WQ_FLAG_EXCLUSIVE;
-	spin_lock_irqsave(&q->lock, flags);
-	__add_wait_queue(q, wait);
-	spin_unlock_irqrestore(&q->lock, flags);
-}
-
-EXPORT_SYMBOL(add_wait_queue);
-
-void fastcall add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait)
-{
-	unsigned long flags;
-
-	wait->flags |= WQ_FLAG_EXCLUSIVE;
-	spin_lock_irqsave(&q->lock, flags);
-	__add_wait_queue_tail(q, wait);
-	spin_unlock_irqrestore(&q->lock, flags);
-}
-
-EXPORT_SYMBOL(add_wait_queue_exclusive);
-
-void fastcall remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&q->lock, flags);
-	__remove_wait_queue(q, wait);
-	spin_unlock_irqrestore(&q->lock, flags);
-}
-
-EXPORT_SYMBOL(remove_wait_queue);
-
-
-/*
- * Note: we use "set_current_state()" _after_ the wait-queue add,
- * because we need a memory barrier there on SMP, so that any
- * wake-function that tests for the wait-queue being active
- * will be guaranteed to see waitqueue addition _or_ subsequent
- * tests in this thread will see the wakeup having taken place.
- *
- * The spin_unlock() itself is semi-permeable and only protects
- * one way (it only protects stuff inside the critical region and
- * stops them from bleeding out - it would still allow subsequent
- * loads to move into the the critical region).
- */
-void fastcall prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
-{
-	unsigned long flags;
-
-	wait->flags &= ~WQ_FLAG_EXCLUSIVE;
-	spin_lock_irqsave(&q->lock, flags);
-	if (list_empty(&wait->task_list))
-		__add_wait_queue(q, wait);
-	/*
-	 * don't alter the task state if this is just going to
-	 * queue an async wait queue callback
-	 */
-	if (is_sync_wait(wait))
-		set_current_state(state);
-	spin_unlock_irqrestore(&q->lock, flags);
-}
-
-EXPORT_SYMBOL(prepare_to_wait);
-
-void fastcall
-prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state)
-{
-	unsigned long flags;
-
-	wait->flags |= WQ_FLAG_EXCLUSIVE;
-	spin_lock_irqsave(&q->lock, flags);
-	if (list_empty(&wait->task_list))
-		__add_wait_queue_tail(q, wait);
-	/*
-	 * don't alter the task state if this is just going to
- 	 * queue an async wait queue callback
-	 */
-	if (is_sync_wait(wait))
-		set_current_state(state);
-	spin_unlock_irqrestore(&q->lock, flags);
-}
-
-EXPORT_SYMBOL(prepare_to_wait_exclusive);
-
-void fastcall finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
-{
-	unsigned long flags;
-
-	__set_current_state(TASK_RUNNING);
-	/*
-	 * We can check for list emptiness outside the lock
-	 * IFF:
-	 *  - we use the "careful" check that verifies both
-	 *    the next and prev pointers, so that there cannot
-	 *    be any half-pending updates in progress on other
-	 *    CPU's that we haven't seen yet (and that might
-	 *    still change the stack area.
-	 * and
-	 *  - all other users take the lock (ie we can only
-	 *    have _one_ other CPU that looks at or modifies
-	 *    the list).
-	 */
-	if (!list_empty_careful(&wait->task_list)) {
-		spin_lock_irqsave(&q->lock, flags);
-		list_del_init(&wait->task_list);
-		spin_unlock_irqrestore(&q->lock, flags);
-	}
-}
-
-EXPORT_SYMBOL(finish_wait);
-
-int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key)
-{
-	int ret = default_wake_function(wait, mode, sync, key);
-
-	if (ret)
-		list_del_init(&wait->task_list);
-	return ret;
-}
-
-EXPORT_SYMBOL(autoremove_wake_function);
-
 void __init fork_init(unsigned long mempages)
 {
 #ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
@@ -242,15 +118,16 @@
 	 * value: the thread structures can take up at most half
 	 * of memory.
 	 */
-	max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 8;
+	max_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE);
+
 	/*
 	 * we need to allow at least 20 threads to boot a system
 	 */
 	if(max_threads < 20)
 		max_threads = 20;
 
-	init_task.rlim[RLIMIT_NPROC].rlim_cur = max_threads/2;
-	init_task.rlim[RLIMIT_NPROC].rlim_max = max_threads/2;
+	init_task.signal->rlim[RLIMIT_NPROC].rlim_cur = max_threads/2;
+	init_task.signal->rlim[RLIMIT_NPROC].rlim_max = max_threads/2;
 }
 
 static struct task_struct *dup_task_struct(struct task_struct *orig)
@@ -297,23 +174,13 @@
 	mm->free_area_cache = oldmm->mmap_base;
 	mm->map_count = 0;
 	mm->rss = 0;
+	mm->anon_rss = 0;
 	cpus_clear(mm->cpu_vm_mask);
 	mm->mm_rb = RB_ROOT;
 	rb_link = &mm->mm_rb.rb_node;
 	rb_parent = NULL;
 	pprev = &mm->mmap;
 
-	/*
-	 * Add it to the mmlist after the parent.
-	 * Doing it this way means that we can order the list,
-	 * and fork() won't mess up the ordering significantly.
-	 * Add it first so that swapoff can see any swap entries.
-	 */
-	spin_lock(&mmlist_lock);
-	list_add(&mm->mmlist, &current->mm->mmlist);
-	mmlist_nr++;
-	spin_unlock(&mmlist_lock);
-
 	for (mpnt = current->mm->mmap ; mpnt ; mpnt = mpnt->vm_next) {
 		struct file *file;
 
@@ -413,7 +280,6 @@
 #endif /* CONFIG_MMU */
 
 spinlock_t mmlist_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
-int mmlist_nr;
 
 #define allocate_mm()	(kmem_cache_alloc(mm_cachep, SLAB_KERNEL))
 #define free_mm(mm)	(kmem_cache_free(mm_cachep, (mm)))
@@ -425,9 +291,11 @@
 	atomic_set(&mm->mm_users, 1);
 	atomic_set(&mm->mm_count, 1);
 	init_rwsem(&mm->mmap_sem);
+	INIT_LIST_HEAD(&mm->mmlist);
 	mm->core_waiters = 0;
-	mm->page_table_lock = SPIN_LOCK_UNLOCKED;
-	mm->ioctx_list_lock = RW_LOCK_UNLOCKED;
+	mm->nr_ptes = 0;
+	spin_lock_init(&mm->page_table_lock);
+	rwlock_init(&mm->ioctx_list_lock);
 	mm->ioctx_list = NULL;
 	mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm);
 	mm->free_area_cache = TASK_UNMAPPED_BASE;
@@ -473,12 +341,14 @@
  */
 void mmput(struct mm_struct *mm)
 {
-	if (atomic_dec_and_lock(&mm->mm_users, &mmlist_lock)) {
-		list_del(&mm->mmlist);
-		mmlist_nr--;
-		spin_unlock(&mmlist_lock);
+	if (atomic_dec_and_test(&mm->mm_users)) {
 		exit_aio(mm);
 		exit_mmap(mm);
+		if (!list_empty(&mm->mmlist)) {
+			spin_lock(&mmlist_lock);
+			list_del(&mm->mmlist);
+			spin_unlock(&mmlist_lock);
+		}
 		put_swap_token(mm);
 		mmdrop(mm);
 	}
@@ -488,15 +358,11 @@
 /**
  * get_task_mm - acquire a reference to the task's mm
  *
- * Returns %NULL if the task has no mm.  Checks if the use count
- * of the mm is non-zero and if so returns a reference to it, after
+ * Returns %NULL if the task has no mm.  Checks PF_BORROWED_MM (meaning
+ * this kernel workthread has transiently adopted a user mm with use_mm,
+ * to do its AIO) is not set and if so returns a reference to it, after
  * bumping up the use count.  User must release the mm via mmput()
  * after use.  Typically used by /proc and ptrace.
- *
- * If the use count is zero, it means that this mm is going away,
- * so return %NULL.  This only happens in the case of an AIO daemon
- * which has temporarily adopted an mm (see use_mm), in the course
- * of its final mmput, before exit_aio has completed.
  */
 struct mm_struct *get_task_mm(struct task_struct *task)
 {
@@ -505,12 +371,10 @@
 	task_lock(task);
 	mm = task->mm;
 	if (mm) {
-		spin_lock(&mmlist_lock);
-		if (!atomic_read(&mm->mm_users))
+		if (task->flags & PF_BORROWED_MM)
 			mm = NULL;
 		else
 			atomic_inc(&mm->mm_users);
-		spin_unlock(&mmlist_lock);
 	}
 	task_unlock(task);
 	return mm;
@@ -631,7 +495,7 @@
 	/* We don't need to lock fs - think why ;-) */
 	if (fs) {
 		atomic_set(&fs->count, 1);
-		fs->lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&fs->lock);
 		fs->umask = old->umask;
 		read_lock(&old->lock);
 		fs->rootmnt = mntget(old->rootmnt);
@@ -713,7 +577,7 @@
 
 	atomic_set(&newf->count, 1);
 
-	newf->file_lock	    = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&newf->file_lock);
 	newf->next_fd	    = 0;
 	newf->max_fds	    = NR_OPEN_DEFAULT;
 	newf->max_fdset	    = __FD_SETSIZE;
@@ -762,8 +626,17 @@
 
 	for (i = open_files; i != 0; i--) {
 		struct file *f = *old_fds++;
-		if (f)
+		if (f) {
 			get_file(f);
+		} else {
+			/*
+			 * The fd may be claimed in the fd bitmap but not yet
+			 * instantiated in the files array if a sibling thread
+			 * is partway through open().  So make sure that this
+			 * fd is available to the new process.
+			 */
+			FD_CLR(open_files - i, newf->open_fds);
+		}
 		*new_fds++ = f;
 	}
 	spin_unlock(&oldf->file_lock);
@@ -847,6 +720,7 @@
 
 	if (clone_flags & CLONE_THREAD) {
 		atomic_inc(&current->signal->count);
+		atomic_inc(&current->signal->live);
 		return 0;
 	}
 	sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
@@ -854,10 +728,12 @@
 	if (!sig)
 		return -ENOMEM;
 	atomic_set(&sig->count, 1);
+	atomic_set(&sig->live, 1);
 	sig->group_exit = 0;
 	sig->group_exit_code = 0;
 	sig->group_exit_task = NULL;
 	sig->group_stop_count = 0;
+	sig->stop_state = 0;
 	sig->curr_target = NULL;
 	init_sigpending(&sig->shared_pending);
 	INIT_LIST_HEAD(&sig->posix_timers);
@@ -872,6 +748,10 @@
 	sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0;
 	sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0;
 
+	task_lock(current->group_leader);
+	memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim);
+	task_unlock(current->group_leader);
+
 	return 0;
 }
 
@@ -941,7 +821,7 @@
 
 	retval = -EAGAIN;
 	if (atomic_read(&p->user->processes) >=
-			p->rlim[RLIMIT_NPROC].rlim_cur) {
+			p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
 		if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
 				p->user != &root_user)
 			goto bad_fork_free;
@@ -1006,6 +886,10 @@
  	}
 #endif
 
+	p->tgid = p->pid;
+	if (clone_flags & CLONE_THREAD)
+		p->tgid = current->tgid;
+
 	if ((retval = security_task_alloc(p)))
 		goto bad_fork_cleanup_policy;
 	if ((retval = audit_alloc(p)))
@@ -1023,8 +907,10 @@
 		goto bad_fork_cleanup_sighand;
 	if ((retval = copy_mm(clone_flags, p)))
 		goto bad_fork_cleanup_signal;
-	if ((retval = copy_namespace(clone_flags, p)))
+	if ((retval = copy_keys(clone_flags, p)))
 		goto bad_fork_cleanup_mm;
+	if ((retval = copy_namespace(clone_flags, p)))
+		goto bad_fork_cleanup_keys;
 	retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs);
 	if (retval)
 		goto bad_fork_cleanup_namespace;
@@ -1049,6 +935,7 @@
 	/* ok, now we should be set up.. */
 	p->exit_signal = (clone_flags & CLONE_THREAD) ? -1 : (clone_flags & CSIGNAL);
 	p->pdeath_signal = 0;
+	p->exit_state = 0;
 
 	/* Perform scheduler related setup */
 	sched_fork(p);
@@ -1057,7 +944,6 @@
 	 * Ok, make it visible to the rest of the system.
 	 * We dont wake it up yet.
 	 */
-	p->tgid = p->pid;
 	p->group_leader = p;
 	INIT_LIST_HEAD(&p->ptrace_children);
 	INIT_LIST_HEAD(&p->ptrace_list);
@@ -1105,7 +991,6 @@
 			retval = -EAGAIN;
 			goto bad_fork_cleanup_namespace;
 		}
-		p->tgid = current->tgid;
 		p->group_leader = current->group_leader;
 
 		if (current->signal->group_stop_count > 0) {
@@ -1145,6 +1030,8 @@
 
 bad_fork_cleanup_namespace:
 	exit_namespace(p);
+bad_fork_cleanup_keys:
+	exit_keys(p);
 bad_fork_cleanup_mm:
 	if (p->mm)
 		mmput(p->mm);
diff -Nru a/kernel/futex.c b/kernel/futex.c
--- a/kernel/futex.c	2004-12-24 13:36:31 -08:00
+++ b/kernel/futex.c	2004-12-24 13:36:31 -08:00
@@ -6,7 +6,7 @@
  *  (C) Copyright 2003 Red Hat Inc, All Rights Reserved
  *
  *  Removed page pinning, fix privately mapped COW pages and other cleanups
- *  (C) Copyright 2003 Jamie Lokier
+ *  (C) Copyright 2003, 2004 Jamie Lokier
  *
  *  Thanks to Ben LaHaise for yelling "hashed waitqueues" loudly
  *  enough at me, Linus for the original (flawed) idea, Matthew
@@ -489,9 +489,24 @@
 	queue_me(&q, -1, NULL);
 
 	/*
-	 * Access the page after the futex is queued.
+	 * Access the page AFTER the futex is queued.
+	 * Order is important:
+	 *
+	 *   Userspace waiter: val = var; if (cond(val)) futex_wait(&var, val);
+	 *   Userspace waker:  if (cond(var)) { var = new; futex_wake(&var); }
+	 *
+	 * The basic logical guarantee of a futex is that it blocks ONLY
+	 * if cond(var) is known to be true at the time of blocking, for
+	 * any cond.  If we queued after testing *uaddr, that would open
+	 * a race condition where we could block indefinitely with
+	 * cond(var) false, which would violate the guarantee.
+	 *
+	 * A consequence is that futex_wait() can return zero and absorb
+	 * a wakeup when *uaddr != val on entry to the syscall.  This is
+	 * rare, but normal.
+	 *
 	 * We hold the mmap semaphore, so the mapping cannot have changed
-	 * since we looked it up.
+	 * since we looked it up in get_futex_key.
 	 */
 	if (get_user(curval, (int __user *)uaddr) != 0) {
 		ret = -EFAULT;
@@ -538,8 +553,8 @@
 		return 0;
 	if (time == 0)
 		return -ETIMEDOUT;
-	/* A spurious wakeup should never happen. */
-	WARN_ON(!signal_pending(current));
+	/* We expect signal_pending(current), but another thread may
+	 * have handled it for us already. */
 	return -EINTR;
 
  out_unqueue:
@@ -732,7 +747,7 @@
 
 	for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
 		INIT_LIST_HEAD(&futex_queues[i].chain);
-		futex_queues[i].lock = SPIN_LOCK_UNLOCKED;
+		spin_lock_init(&futex_queues[i].lock);
 	}
 	return 0;
 }
diff -Nru a/kernel/irq/Makefile b/kernel/irq/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/irq/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,5 @@
+
+obj-y := handle.o manage.o spurious.o
+obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o
+obj-$(CONFIG_PROC_FS) += proc.o
+
diff -Nru a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/irq/autoprobe.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,188 @@
+/*
+ * linux/kernel/irq/autoprobe.c
+ *
+ * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
+ *
+ * This file contains the interrupt probing code and driver APIs.
+ */
+
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+
+/*
+ * Autodetection depends on the fact that any interrupt that
+ * comes in on to an unassigned handler will get stuck with
+ * "IRQ_WAITING" cleared and the interrupt disabled.
+ */
+static DECLARE_MUTEX(probe_sem);
+
+/**
+ *	probe_irq_on	- begin an interrupt autodetect
+ *
+ *	Commence probing for an interrupt. The interrupts are scanned
+ *	and a mask of potential interrupt lines is returned.
+ *
+ */
+unsigned long probe_irq_on(void)
+{
+	unsigned long val, delay;
+	irq_desc_t *desc;
+	unsigned int i;
+
+	down(&probe_sem);
+	/*
+	 * something may have generated an irq long ago and we want to
+	 * flush such a longstanding irq before considering it as spurious.
+	 */
+	for (i = NR_IRQS-1; i > 0; i--) {
+		desc = irq_desc + i;
+
+		spin_lock_irq(&desc->lock);
+		if (!irq_desc[i].action)
+			irq_desc[i].handler->startup(i);
+		spin_unlock_irq(&desc->lock);
+	}
+
+	/* Wait for longstanding interrupts to trigger. */
+	for (delay = jiffies + HZ/50; time_after(delay, jiffies); )
+		/* about 20ms delay */ barrier();
+
+	/*
+	 * enable any unassigned irqs
+	 * (we must startup again here because if a longstanding irq
+	 * happened in the previous stage, it may have masked itself)
+	 */
+	for (i = NR_IRQS-1; i > 0; i--) {
+		desc = irq_desc + i;
+
+		spin_lock_irq(&desc->lock);
+		if (!desc->action) {
+			desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
+			if (desc->handler->startup(i))
+				desc->status |= IRQ_PENDING;
+		}
+		spin_unlock_irq(&desc->lock);
+	}
+
+	/*
+	 * Wait for spurious interrupts to trigger
+	 */
+	for (delay = jiffies + HZ/10; time_after(delay, jiffies); )
+		/* about 100ms delay */ barrier();
+
+	/*
+	 * Now filter out any obviously spurious interrupts
+	 */
+	val = 0;
+	for (i = 0; i < NR_IRQS; i++) {
+		irq_desc_t *desc = irq_desc + i;
+		unsigned int status;
+
+		spin_lock_irq(&desc->lock);
+		status = desc->status;
+
+		if (status & IRQ_AUTODETECT) {
+			/* It triggered already - consider it spurious. */
+			if (!(status & IRQ_WAITING)) {
+				desc->status = status & ~IRQ_AUTODETECT;
+				desc->handler->shutdown(i);
+			} else
+				if (i < 32)
+					val |= 1 << i;
+		}
+		spin_unlock_irq(&desc->lock);
+	}
+
+	return val;
+}
+
+EXPORT_SYMBOL(probe_irq_on);
+
+/**
+ *	probe_irq_mask - scan a bitmap of interrupt lines
+ *	@val:	mask of interrupts to consider
+ *
+ *	Scan the interrupt lines and return a bitmap of active
+ *	autodetect interrupts. The interrupt probe logic state
+ *	is then returned to its previous value.
+ *
+ *	Note: we need to scan all the irq's even though we will
+ *	only return autodetect irq numbers - just so that we reset
+ *	them all to a known state.
+ */
+unsigned int probe_irq_mask(unsigned long val)
+{
+	unsigned int mask;
+	int i;
+
+	mask = 0;
+	for (i = 0; i < NR_IRQS; i++) {
+		irq_desc_t *desc = irq_desc + i;
+		unsigned int status;
+
+		spin_lock_irq(&desc->lock);
+		status = desc->status;
+
+		if (status & IRQ_AUTODETECT) {
+			if (i < 16 && !(status & IRQ_WAITING))
+				mask |= 1 << i;
+
+			desc->status = status & ~IRQ_AUTODETECT;
+			desc->handler->shutdown(i);
+		}
+		spin_unlock_irq(&desc->lock);
+	}
+	up(&probe_sem);
+
+	return mask & val;
+}
+
+/**
+ *	probe_irq_off	- end an interrupt autodetect
+ *	@val: mask of potential interrupts (unused)
+ *
+ *	Scans the unused interrupt lines and returns the line which
+ *	appears to have triggered the interrupt. If no interrupt was
+ *	found then zero is returned. If more than one interrupt is
+ *	found then minus the first candidate is returned to indicate
+ *	their is doubt.
+ *
+ *	The interrupt probe logic state is returned to its previous
+ *	value.
+ *
+ *	BUGS: When used in a module (which arguably shouldn't happen)
+ *	nothing prevents two IRQ probe callers from overlapping. The
+ *	results of this are non-optimal.
+ */
+int probe_irq_off(unsigned long val)
+{
+	int i, irq_found = 0, nr_irqs = 0;
+
+	for (i = 0; i < NR_IRQS; i++) {
+		irq_desc_t *desc = irq_desc + i;
+		unsigned int status;
+
+		spin_lock_irq(&desc->lock);
+		status = desc->status;
+
+		if (status & IRQ_AUTODETECT) {
+			if (!(status & IRQ_WAITING)) {
+				if (!nr_irqs)
+					irq_found = i;
+				nr_irqs++;
+			}
+			desc->status = status & ~IRQ_AUTODETECT;
+			desc->handler->shutdown(i);
+		}
+		spin_unlock_irq(&desc->lock);
+	}
+	up(&probe_sem);
+
+	if (nr_irqs > 1)
+		irq_found = -irq_found;
+	return irq_found;
+}
+
+EXPORT_SYMBOL(probe_irq_off);
+
diff -Nru a/kernel/irq/handle.c b/kernel/irq/handle.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/irq/handle.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,204 @@
+/*
+ * linux/kernel/irq/handle.c
+ *
+ * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
+ *
+ * This file contains the core interrupt handling code.
+ */
+
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/random.h>
+#include <linux/interrupt.h>
+#include <linux/kernel_stat.h>
+
+#include "internals.h"
+
+/*
+ * Linux has a controller-independent interrupt architecture.
+ * Every controller has a 'controller-template', that is used
+ * by the main code to do the right thing. Each driver-visible
+ * interrupt source is transparently wired to the apropriate
+ * controller. Thus drivers need not be aware of the
+ * interrupt-controller.
+ *
+ * The code is designed to be easily extended with new/different
+ * interrupt controllers, without having to do assembly magic or
+ * having to touch the generic code.
+ *
+ * Controller mappings for all interrupt sources:
+ */
+irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
+	[0 ... NR_IRQS-1] = {
+		.handler = &no_irq_type,
+		.lock = SPIN_LOCK_UNLOCKED
+	}
+};
+
+/*
+ * Generic 'no controller' code
+ */
+static void end_none(unsigned int irq) { }
+static void enable_none(unsigned int irq) { }
+static void disable_none(unsigned int irq) { }
+static void shutdown_none(unsigned int irq) { }
+static unsigned int startup_none(unsigned int irq) { return 0; }
+
+static void ack_none(unsigned int irq)
+{
+	/*
+	 * 'what should we do if we get a hw irq event on an illegal vector'.
+	 * each architecture has to answer this themself.
+	 */
+	ack_bad_irq(irq);
+}
+
+struct hw_interrupt_type no_irq_type = {
+	.typename = 	"none",
+	.startup = 	startup_none,
+	.shutdown = 	shutdown_none,
+	.enable = 	enable_none,
+	.disable = 	disable_none,
+	.ack = 		ack_none,
+	.end = 		end_none,
+	.set_affinity = NULL
+};
+
+/*
+ * Special, empty irq handler:
+ */
+irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs)
+{
+	return IRQ_NONE;
+}
+
+/*
+ * Exit an interrupt context. Process softirqs if needed and possible:
+ */
+void irq_exit(void)
+{
+	preempt_count() -= IRQ_EXIT_OFFSET;
+	if (!in_interrupt() && local_softirq_pending())
+		do_softirq();
+	preempt_enable_no_resched();
+}
+
+/*
+ * Have got an event to handle:
+ */
+fastcall int handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
+				struct irqaction *action)
+{
+	int ret, retval = 0, status = 0;
+
+	if (!(action->flags & SA_INTERRUPT))
+		local_irq_enable();
+
+	do {
+		ret = action->handler(irq, action->dev_id, regs);
+		if (ret == IRQ_HANDLED)
+			status |= action->flags;
+		retval |= ret;
+		action = action->next;
+	} while (action);
+
+	if (status & SA_SAMPLE_RANDOM)
+		add_interrupt_randomness(irq);
+	local_irq_disable();
+
+	return retval;
+}
+
+/*
+ * do_IRQ handles all normal device IRQ's (the special
+ * SMP cross-CPU interrupts have their own specific
+ * handlers).
+ */
+fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs)
+{
+	irq_desc_t *desc = irq_desc + irq;
+	struct irqaction * action;
+	unsigned int status;
+
+	kstat_this_cpu.irqs[irq]++;
+	if (desc->status & IRQ_PER_CPU) {
+		irqreturn_t action_ret;
+
+		/*
+		 * No locking required for CPU-local interrupts:
+		 */
+		desc->handler->ack(irq);
+		action_ret = handle_IRQ_event(irq, regs, desc->action);
+		if (!noirqdebug)
+			note_interrupt(irq, desc, action_ret);
+		desc->handler->end(irq);
+		return 1;
+	}
+
+	spin_lock(&desc->lock);
+	desc->handler->ack(irq);
+	/*
+	 * REPLAY is when Linux resends an IRQ that was dropped earlier
+	 * WAITING is used by probe to mark irqs that are being tested
+	 */
+	status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
+	status |= IRQ_PENDING; /* we _want_ to handle it */
+
+	/*
+	 * If the IRQ is disabled for whatever reason, we cannot
+	 * use the action we have.
+	 */
+	action = NULL;
+	if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
+		action = desc->action;
+		status &= ~IRQ_PENDING; /* we commit to handling */
+		status |= IRQ_INPROGRESS; /* we are handling it */
+	}
+	desc->status = status;
+
+	/*
+	 * If there is no IRQ handler or it was disabled, exit early.
+	 * Since we set PENDING, if another processor is handling
+	 * a different instance of this same irq, the other processor
+	 * will take care of it.
+	 */
+	if (unlikely(!action))
+		goto out;
+
+	/*
+	 * Edge triggered interrupts need to remember
+	 * pending events.
+	 * This applies to any hw interrupts that allow a second
+	 * instance of the same irq to arrive while we are in do_IRQ
+	 * or in the handler. But the code here only handles the _second_
+	 * instance of the irq, not the third or fourth. So it is mostly
+	 * useful for irq hardware that does not mask cleanly in an
+	 * SMP environment.
+	 */
+	for (;;) {
+		irqreturn_t action_ret;
+
+		spin_unlock(&desc->lock);
+
+		action_ret = handle_IRQ_event(irq, regs, action);
+
+		spin_lock(&desc->lock);
+		if (!noirqdebug)
+			note_interrupt(irq, desc, action_ret);
+		if (likely(!(desc->status & IRQ_PENDING)))
+			break;
+		desc->status &= ~IRQ_PENDING;
+	}
+	desc->status &= ~IRQ_INPROGRESS;
+
+out:
+	/*
+	 * The ->end() handler has to deal with interrupts which got
+	 * disabled while the handler was running.
+	 */
+	desc->handler->end(irq);
+	spin_unlock(&desc->lock);
+
+	return 1;
+}
+
diff -Nru a/kernel/irq/internals.h b/kernel/irq/internals.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/irq/internals.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,18 @@
+/*
+ * IRQ subsystem internal functions and variables:
+ */
+
+extern int noirqdebug;
+
+#ifdef CONFIG_PROC_FS
+extern void register_irq_proc(unsigned int irq);
+extern void register_handler_proc(unsigned int irq, struct irqaction *action);
+extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
+#else
+static inline void register_irq_proc(unsigned int irq) { }
+static inline void register_handler_proc(unsigned int irq,
+					 struct irqaction *action) { }
+static inline void unregister_handler_proc(unsigned int irq,
+					   struct irqaction *action) { }
+#endif
+
diff -Nru a/kernel/irq/manage.c b/kernel/irq/manage.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/irq/manage.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,347 @@
+/*
+ * linux/kernel/irq/manage.c
+ *
+ * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
+ *
+ * This file contains driver APIs to the irq subsystem.
+ */
+
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/random.h>
+#include <linux/interrupt.h>
+
+#include "internals.h"
+
+#ifdef CONFIG_SMP
+
+/**
+ *	synchronize_irq - wait for pending IRQ handlers (on other CPUs)
+ *
+ *	This function waits for any pending IRQ handlers for this interrupt
+ *	to complete before returning. If you use this function while
+ *	holding a resource the IRQ handler may need you will deadlock.
+ *
+ *	This function may be called - with care - from IRQ context.
+ */
+void synchronize_irq(unsigned int irq)
+{
+	struct irq_desc *desc = irq_desc + irq;
+
+	while (desc->status & IRQ_INPROGRESS)
+		cpu_relax();
+}
+
+EXPORT_SYMBOL(synchronize_irq);
+
+#endif
+
+/**
+ *	disable_irq_nosync - disable an irq without waiting
+ *	@irq: Interrupt to disable
+ *
+ *	Disable the selected interrupt line.  Disables and Enables are
+ *	nested.
+ *	Unlike disable_irq(), this function does not ensure existing
+ *	instances of the IRQ handler have completed before returning.
+ *
+ *	This function may be called from IRQ context.
+ */
+void disable_irq_nosync(unsigned int irq)
+{
+	irq_desc_t *desc = irq_desc + irq;
+	unsigned long flags;
+
+	spin_lock_irqsave(&desc->lock, flags);
+	if (!desc->depth++) {
+		desc->status |= IRQ_DISABLED;
+		desc->handler->disable(irq);
+	}
+	spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(disable_irq_nosync);
+
+/**
+ *	disable_irq - disable an irq and wait for completion
+ *	@irq: Interrupt to disable
+ *
+ *	Disable the selected interrupt line.  Enables and Disables are
+ *	nested.
+ *	This function waits for any pending IRQ handlers for this interrupt
+ *	to complete before returning. If you use this function while
+ *	holding a resource the IRQ handler may need you will deadlock.
+ *
+ *	This function may be called - with care - from IRQ context.
+ */
+void disable_irq(unsigned int irq)
+{
+	irq_desc_t *desc = irq_desc + irq;
+
+	disable_irq_nosync(irq);
+	if (desc->action)
+		synchronize_irq(irq);
+}
+
+EXPORT_SYMBOL(disable_irq);
+
+/**
+ *	enable_irq - enable handling of an irq
+ *	@irq: Interrupt to enable
+ *
+ *	Undoes the effect of one call to disable_irq().  If this
+ *	matches the last disable, processing of interrupts on this
+ *	IRQ line is re-enabled.
+ *
+ *	This function may be called from IRQ context.
+ */
+void enable_irq(unsigned int irq)
+{
+	irq_desc_t *desc = irq_desc + irq;
+	unsigned long flags;
+
+	spin_lock_irqsave(&desc->lock, flags);
+	switch (desc->depth) {
+	case 0:
+		WARN_ON(1);
+		break;
+	case 1: {
+		unsigned int status = desc->status & ~IRQ_DISABLED;
+
+		desc->status = status;
+		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
+			desc->status = status | IRQ_REPLAY;
+			hw_resend_irq(desc->handler,irq);
+		}
+		desc->handler->enable(irq);
+		/* fall-through */
+	}
+	default:
+		desc->depth--;
+	}
+	spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(enable_irq);
+
+/*
+ * Internal function that tells the architecture code whether a
+ * particular irq has been exclusively allocated or is available
+ * for driver use.
+ */
+int can_request_irq(unsigned int irq, unsigned long irqflags)
+{
+	struct irqaction *action;
+
+	if (irq >= NR_IRQS)
+		return 0;
+
+	action = irq_desc[irq].action;
+	if (action)
+		if (irqflags & action->flags & SA_SHIRQ)
+			action = NULL;
+
+	return !action;
+}
+
+/*
+ * Internal function to register an irqaction - typically used to
+ * allocate special interrupts that are part of the architecture.
+ */
+int setup_irq(unsigned int irq, struct irqaction * new)
+{
+	struct irq_desc *desc = irq_desc + irq;
+	struct irqaction *old, **p;
+	unsigned long flags;
+	int shared = 0;
+
+	if (desc->handler == &no_irq_type)
+		return -ENOSYS;
+	/*
+	 * Some drivers like serial.c use request_irq() heavily,
+	 * so we have to be careful not to interfere with a
+	 * running system.
+	 */
+	if (new->flags & SA_SAMPLE_RANDOM) {
+		/*
+		 * This function might sleep, we want to call it first,
+		 * outside of the atomic block.
+		 * Yes, this might clear the entropy pool if the wrong
+		 * driver is attempted to be loaded, without actually
+		 * installing a new handler, but is this really a problem,
+		 * only the sysadmin is able to do this.
+		 */
+		rand_initialize_irq(irq);
+	}
+
+	/*
+	 * The following block of code has to be executed atomically
+	 */
+	spin_lock_irqsave(&desc->lock,flags);
+	p = &desc->action;
+	if ((old = *p) != NULL) {
+		/* Can't share interrupts unless both agree to */
+		if (!(old->flags & new->flags & SA_SHIRQ)) {
+			spin_unlock_irqrestore(&desc->lock,flags);
+			return -EBUSY;
+		}
+
+		/* add new interrupt at end of irq queue */
+		do {
+			p = &old->next;
+			old = *p;
+		} while (old);
+		shared = 1;
+	}
+
+	*p = new;
+
+	if (!shared) {
+		desc->depth = 0;
+		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
+				  IRQ_WAITING | IRQ_INPROGRESS);
+		if (desc->handler->startup)
+			desc->handler->startup(irq);
+		else
+			desc->handler->enable(irq);
+	}
+	spin_unlock_irqrestore(&desc->lock,flags);
+
+	new->irq = irq;
+	register_irq_proc(irq);
+	new->dir = NULL;
+	register_handler_proc(irq, new);
+
+	return 0;
+}
+
+/**
+ *	free_irq - free an interrupt
+ *	@irq: Interrupt line to free
+ *	@dev_id: Device identity to free
+ *
+ *	Remove an interrupt handler. The handler is removed and if the
+ *	interrupt line is no longer in use by any driver it is disabled.
+ *	On a shared IRQ the caller must ensure the interrupt is disabled
+ *	on the card it drives before calling this function. The function
+ *	does not return until any executing interrupts for this IRQ
+ *	have completed.
+ *
+ *	This function must not be called from interrupt context.
+ */
+void free_irq(unsigned int irq, void *dev_id)
+{
+	struct irq_desc *desc;
+	struct irqaction **p;
+	unsigned long flags;
+
+	if (irq >= NR_IRQS)
+		return;
+
+	desc = irq_desc + irq;
+	spin_lock_irqsave(&desc->lock,flags);
+	p = &desc->action;
+	for (;;) {
+		struct irqaction * action = *p;
+
+		if (action) {
+			struct irqaction **pp = p;
+
+			p = &action->next;
+			if (action->dev_id != dev_id)
+				continue;
+
+			/* Found it - now remove it from the list of entries */
+			*pp = action->next;
+			if (!desc->action) {
+				desc->status |= IRQ_DISABLED;
+				if (desc->handler->shutdown)
+					desc->handler->shutdown(irq);
+				else
+					desc->handler->disable(irq);
+			}
+			spin_unlock_irqrestore(&desc->lock,flags);
+			unregister_handler_proc(irq, action);
+
+			/* Make sure it's not being used on another CPU */
+			synchronize_irq(irq);
+			kfree(action);
+			return;
+		}
+		printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
+		spin_unlock_irqrestore(&desc->lock,flags);
+		return;
+	}
+}
+
+EXPORT_SYMBOL(free_irq);
+
+/**
+ *	request_irq - allocate an interrupt line
+ *	@irq: Interrupt line to allocate
+ *	@handler: Function to be called when the IRQ occurs
+ *	@irqflags: Interrupt type flags
+ *	@devname: An ascii name for the claiming device
+ *	@dev_id: A cookie passed back to the handler function
+ *
+ *	This call allocates interrupt resources and enables the
+ *	interrupt line and IRQ handling. From the point this
+ *	call is made your handler function may be invoked. Since
+ *	your handler function must clear any interrupt the board
+ *	raises, you must take care both to initialise your hardware
+ *	and to set up the interrupt handler in the right order.
+ *
+ *	Dev_id must be globally unique. Normally the address of the
+ *	device data structure is used as the cookie. Since the handler
+ *	receives this value it makes sense to use it.
+ *
+ *	If your interrupt is shared you must pass a non NULL dev_id
+ *	as this is required when freeing the interrupt.
+ *
+ *	Flags:
+ *
+ *	SA_SHIRQ		Interrupt is shared
+ *	SA_INTERRUPT		Disable local interrupts while processing
+ *	SA_SAMPLE_RANDOM	The interrupt can be used for entropy
+ *
+ */
+int request_irq(unsigned int irq,
+		irqreturn_t (*handler)(int, void *, struct pt_regs *),
+		unsigned long irqflags, const char * devname, void *dev_id)
+{
+	struct irqaction * action;
+	int retval;
+
+	/*
+	 * Sanity-check: shared interrupts must pass in a real dev-ID,
+	 * otherwise we'll have trouble later trying to figure out
+	 * which interrupt is which (messes up the interrupt freeing
+	 * logic etc).
+	 */
+	if ((irqflags & SA_SHIRQ) && !dev_id)
+		return -EINVAL;
+	if (irq >= NR_IRQS)
+		return -EINVAL;
+	if (!handler)
+		return -EINVAL;
+
+	action = kmalloc(sizeof(struct irqaction), GFP_ATOMIC);
+	if (!action)
+		return -ENOMEM;
+
+	action->handler = handler;
+	action->flags = irqflags;
+	cpus_clear(action->mask);
+	action->name = devname;
+	action->next = NULL;
+	action->dev_id = dev_id;
+
+	retval = setup_irq(irq, action);
+	if (retval)
+		kfree(action);
+
+	return retval;
+}
+
+EXPORT_SYMBOL(request_irq);
+
diff -Nru a/kernel/irq/proc.c b/kernel/irq/proc.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/irq/proc.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,155 @@
+/*
+ * linux/kernel/irq/proc.c
+ *
+ * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
+ *
+ * This file contains the /proc/irq/ handling code.
+ */
+
+#include <linux/irq.h>
+#include <linux/proc_fs.h>
+#include <linux/interrupt.h>
+
+static struct proc_dir_entry *root_irq_dir, *irq_dir[NR_IRQS];
+
+#ifdef CONFIG_SMP
+
+/*
+ * The /proc/irq/<irq>/smp_affinity values:
+ */
+static struct proc_dir_entry *smp_affinity_entry[NR_IRQS];
+
+cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
+
+static int irq_affinity_read_proc(char *page, char **start, off_t off,
+				  int count, int *eof, void *data)
+{
+	int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
+
+	if (count - len < 2)
+		return -EINVAL;
+	len += sprintf(page + len, "\n");
+	return len;
+}
+
+int no_irq_affinity;
+static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
+				   unsigned long count, void *data)
+{
+	unsigned int irq = (int)(long)data, full_count = count, err;
+	cpumask_t new_value, tmp;
+
+	if (!irq_desc[irq].handler->set_affinity || no_irq_affinity)
+		return -EIO;
+
+	err = cpumask_parse(buffer, count, new_value);
+	if (err)
+		return err;
+
+	/*
+	 * Do not allow disabling IRQs completely - it's a too easy
+	 * way to make the system unusable accidentally :-) At least
+	 * one online CPU still has to be targeted.
+	 */
+	cpus_and(tmp, new_value, cpu_online_map);
+	if (cpus_empty(tmp))
+		return -EINVAL;
+
+	irq_affinity[irq] = new_value;
+	irq_desc[irq].handler->set_affinity(irq, new_value);
+
+	return full_count;
+}
+
+#endif
+
+#define MAX_NAMELEN 128
+
+static int name_unique(unsigned int irq, struct irqaction *new_action)
+{
+	struct irq_desc *desc = irq_desc + irq;
+	struct irqaction *action;
+
+	for (action = desc->action ; action; action = action->next)
+		if ((action != new_action) && action->name &&
+				!strcmp(new_action->name, action->name))
+			return 0;
+	return 1;
+}
+
+void register_handler_proc(unsigned int irq, struct irqaction *action)
+{
+	char name [MAX_NAMELEN];
+
+	if (!irq_dir[irq] || action->dir || !action->name ||
+					!name_unique(irq, action))
+		return;
+
+	memset(name, 0, MAX_NAMELEN);
+	snprintf(name, MAX_NAMELEN, "%s", action->name);
+
+	/* create /proc/irq/1234/handler/ */
+	action->dir = proc_mkdir(name, irq_dir[irq]);
+}
+
+#undef MAX_NAMELEN
+
+#define MAX_NAMELEN 10
+
+void register_irq_proc(unsigned int irq)
+{
+	char name [MAX_NAMELEN];
+
+	if (!root_irq_dir ||
+		(irq_desc[irq].handler == &no_irq_type) ||
+			irq_dir[irq])
+		return;
+
+	memset(name, 0, MAX_NAMELEN);
+	sprintf(name, "%d", irq);
+
+	/* create /proc/irq/1234 */
+	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
+
+#ifdef CONFIG_SMP
+	{
+		struct proc_dir_entry *entry;
+
+		/* create /proc/irq/<irq>/smp_affinity */
+		entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
+
+		if (entry) {
+			entry->nlink = 1;
+			entry->data = (void *)(long)irq;
+			entry->read_proc = irq_affinity_read_proc;
+			entry->write_proc = irq_affinity_write_proc;
+		}
+		smp_affinity_entry[irq] = entry;
+	}
+#endif
+}
+
+#undef MAX_NAMELEN
+
+void unregister_handler_proc(unsigned int irq, struct irqaction *action)
+{
+	if (action->dir)
+		remove_proc_entry(action->dir->name, irq_dir[irq]);
+}
+
+void init_irq_proc(void)
+{
+	int i;
+
+	/* create /proc/irq */
+	root_irq_dir = proc_mkdir("irq", NULL);
+	if (!root_irq_dir)
+		return;
+
+	/*
+	 * Create entries for all existing IRQs.
+	 */
+	for (i = 0; i < NR_IRQS; i++)
+		register_irq_proc(i);
+}
+
diff -Nru a/kernel/irq/spurious.c b/kernel/irq/spurious.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/irq/spurious.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,96 @@
+/*
+ * linux/kernel/irq/spurious.c
+ *
+ * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
+ *
+ * This file contains spurious interrupt handling.
+ */
+
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/kallsyms.h>
+#include <linux/interrupt.h>
+
+/*
+ * If 99,900 of the previous 100,000 interrupts have not been handled
+ * then assume that the IRQ is stuck in some manner. Drop a diagnostic
+ * and try to turn the IRQ off.
+ *
+ * (The other 100-of-100,000 interrupts may have been a correctly
+ *  functioning device sharing an IRQ with the failing one)
+ *
+ * Called under desc->lock
+ */
+
+static void
+__report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
+{
+	struct irqaction *action;
+
+	if (action_ret != IRQ_HANDLED && action_ret != IRQ_NONE) {
+		printk(KERN_ERR "irq event %d: bogus return value %x\n",
+				irq, action_ret);
+	} else {
+		printk(KERN_ERR "irq %d: nobody cared!\n", irq);
+	}
+	dump_stack();
+	printk(KERN_ERR "handlers:\n");
+	action = desc->action;
+	while (action) {
+		printk(KERN_ERR "[<%p>]", action->handler);
+		print_symbol(" (%s)",
+			(unsigned long)action->handler);
+		printk("\n");
+		action = action->next;
+	}
+}
+
+void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
+{
+	static int count = 100;
+
+	if (count > 0) {
+		count--;
+		__report_bad_irq(irq, desc, action_ret);
+	}
+}
+
+void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
+{
+	if (action_ret != IRQ_HANDLED) {
+		desc->irqs_unhandled++;
+		if (action_ret != IRQ_NONE)
+			report_bad_irq(irq, desc, action_ret);
+	}
+
+	desc->irq_count++;
+	if (desc->irq_count < 100000)
+		return;
+
+	desc->irq_count = 0;
+	if (desc->irqs_unhandled > 99900) {
+		/*
+		 * The interrupt is stuck
+		 */
+		__report_bad_irq(irq, desc, action_ret);
+		/*
+		 * Now kill the IRQ
+		 */
+		printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
+		desc->status |= IRQ_DISABLED;
+		desc->handler->disable(irq);
+	}
+	desc->irqs_unhandled = 0;
+}
+
+int noirqdebug;
+
+int __init noirqdebug_setup(char *str)
+{
+	noirqdebug = 1;
+	printk(KERN_INFO "IRQ lockup detection disabled\n");
+	return 1;
+}
+
+__setup("noirqdebug", noirqdebug_setup);
+
diff -Nru a/kernel/itimer.c b/kernel/itimer.c
--- a/kernel/itimer.c	2004-12-24 13:36:48 -08:00
+++ b/kernel/itimer.c	2004-12-24 13:36:48 -08:00
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/interrupt.h>
+#include <linux/syscalls.h>
 #include <linux/time.h>
 
 #include <asm/uaccess.h>
diff -Nru a/kernel/kallsyms.c b/kernel/kallsyms.c
--- a/kernel/kallsyms.c	2004-12-24 13:37:29 -08:00
+++ b/kernel/kallsyms.c	2004-12-24 13:37:29 -08:00
@@ -4,7 +4,12 @@
  * Rewritten and vastly simplified by Rusty Russell for in-kernel
  * module loader:
  *   Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
- * Stem compression by Andi Kleen.
+ *
+ * ChangeLog:
+ *
+ * (25/Aug/2004) Paulo Marques <pmarques@grupopie.com>
+ *      Changed the compression method from stem compression to "table lookup"
+ *      compression (see scripts/kallsyms.c for a more complete description)
  */
 #include <linux/kallsyms.h>
 #include <linux/module.h>
@@ -17,7 +22,12 @@
 /* These will be re-linked against their real values during the second link stage */
 extern unsigned long kallsyms_addresses[] __attribute__((weak));
 extern unsigned long kallsyms_num_syms __attribute__((weak));
-extern char kallsyms_names[] __attribute__((weak));
+extern u8 kallsyms_names[] __attribute__((weak));
+
+extern u8 kallsyms_token_table[] __attribute__((weak));
+extern u16 kallsyms_token_index[] __attribute__((weak));
+
+extern unsigned long kallsyms_markers[] __attribute__((weak));
 
 /* Defined by the linker script. */
 extern char _stext[], _etext[], _sinittext[], _einittext[];
@@ -37,21 +47,88 @@
 	return 0;
 }
 
+/* expand a compressed symbol data into the resulting uncompressed string,
+   given the offset to where the symbol is in the compressed stream */
+static unsigned int kallsyms_expand_symbol(unsigned int off, char *result)
+{
+	int len, skipped_first = 0;
+	u8 *tptr, *data;
+
+	/* get the compressed symbol length from the first symbol byte */
+	data = &kallsyms_names[off];
+	len = *data;
+	data++;
+
+	/* update the offset to return the offset for the next symbol on
+	 * the compressed stream */
+	off += len + 1;
+
+	/* for every byte on the compressed symbol data, copy the table
+	   entry for that byte */
+	while(len) {
+		tptr = &kallsyms_token_table[ kallsyms_token_index[*data] ];
+		data++;
+		len--;
+
+		while (*tptr) {
+			if(skipped_first) {
+				*result = *tptr;
+				result++;
+			} else
+				skipped_first = 1;
+			tptr++;
+		}
+	}
+
+	*result = '\0';
+
+	/* return to offset to the next symbol */
+	return off;
+}
+
+/* get symbol type information. This is encoded as a single char at the
+ * begining of the symbol name */
+static char kallsyms_get_symbol_type(unsigned int off)
+{
+	/* get just the first code, look it up in the token table, and return the
+	 * first char from this token */
+	return kallsyms_token_table[ kallsyms_token_index[ kallsyms_names[off+1] ] ];
+}
+
+
+/* find the offset on the compressed stream given and index in the
+ * kallsyms array */
+static unsigned int get_symbol_offset(unsigned long pos)
+{
+	u8 *name;
+	int i;
+
+	/* use the closest marker we have. We have markers every 256 positions,
+	 * so that should be close enough */
+	name = &kallsyms_names[ kallsyms_markers[pos>>8] ];
+
+	/* sequentially scan all the symbols up to the point we're searching for.
+	 * Every symbol is stored in a [<len>][<len> bytes of data] format, so we
+	 * just need to add the len to the current pointer for every symbol we
+	 * wish to skip */
+	for(i = 0; i < (pos&0xFF); i++)
+		name = name + (*name) + 1;
+
+	return name - kallsyms_names;
+}
+
 /* Lookup the address for this symbol. Returns 0 if not found. */
 unsigned long kallsyms_lookup_name(const char *name)
 {
 	char namebuf[KSYM_NAME_LEN+1];
 	unsigned long i;
-	char *knames;
+	unsigned int off;
 
-	for (i = 0, knames = kallsyms_names; i < kallsyms_num_syms; i++) {
-		unsigned prefix = *knames++;
+	for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
+		off = kallsyms_expand_symbol(off, namebuf);
 
-		strlcpy(namebuf + prefix, knames, KSYM_NAME_LEN - prefix);
 		if (strcmp(namebuf, name) == 0)
 			return kallsyms_addresses[i];
-
-		knames += strlen(knames) + 1;
 	}
 	return module_kallsyms_lookup_name(name);
 }
@@ -62,7 +139,7 @@
 			    unsigned long *offset,
 			    char **modname, char *namebuf)
 {
-	unsigned long i, best = 0;
+	unsigned long i, low, high, mid;
 
 	/* This kernel should never had been booted. */
 	BUG_ON(!kallsyms_addresses);
@@ -71,40 +148,45 @@
 	namebuf[0] = 0;
 
 	if (is_kernel_text(addr) || is_kernel_inittext(addr)) {
-		unsigned long symbol_end;
-		char *name = kallsyms_names;
+		unsigned long symbol_end=0;
 
-		/* They're sorted, we could be clever here, but who cares? */
-		for (i = 0; i < kallsyms_num_syms; i++) {
-			if (kallsyms_addresses[i] > kallsyms_addresses[best] &&
-			    kallsyms_addresses[i] <= addr)
-				best = i;
+		/* do a binary search on the sorted kallsyms_addresses array */
+		low = 0;
+		high = kallsyms_num_syms;
+
+		while (high-low > 1) {
+			mid = (low + high) / 2;
+			if (kallsyms_addresses[mid] <= addr) low = mid;
+			else high = mid;
 		}
 
-		/* Grab name */
-		for (i = 0; i <= best; i++) { 
-			unsigned prefix = *name++;
-			strncpy(namebuf + prefix, name, KSYM_NAME_LEN - prefix);
-			name += strlen(name) + 1;
-		}
+		/* search for the first aliased symbol. Aliased symbols are
+		   symbols with the same address */
+		while (low && kallsyms_addresses[low - 1] == kallsyms_addresses[low])
+			--low;
 
-		/* At worst, symbol ends at end of section. */
-		if (is_kernel_inittext(addr))
-			symbol_end = (unsigned long)_einittext;
-		else
-			symbol_end = (unsigned long)_etext;
+		/* Grab name */
+		kallsyms_expand_symbol(get_symbol_offset(low), namebuf);
 
 		/* Search for next non-aliased symbol */
-		for (i = best+1; i < kallsyms_num_syms; i++) {
-			if (kallsyms_addresses[i] > kallsyms_addresses[best]) {
+		for (i = low + 1; i < kallsyms_num_syms; i++) {
+			if (kallsyms_addresses[i] > kallsyms_addresses[low]) {
 				symbol_end = kallsyms_addresses[i];
 				break;
 			}
 		}
 
-		*symbolsize = symbol_end - kallsyms_addresses[best];
+		/* if we found no next symbol, we use the end of the section */
+		if (!symbol_end) {
+			if (is_kernel_inittext(addr))
+				symbol_end = (unsigned long)_einittext;
+			else
+				symbol_end = (unsigned long)_etext;
+		}
+
+		*symbolsize = symbol_end - kallsyms_addresses[low];
 		*modname = NULL;
-		*offset = addr - kallsyms_addresses[best];
+		*offset = addr - kallsyms_addresses[low];
 		return namebuf;
 	}
 
@@ -135,7 +217,7 @@
 	printk(fmt, buffer);
 }
 
-/* To avoid O(n^2) iteration, we carry prefix along. */
+/* To avoid using get_symbol_offset for every symbol, we carry prefix along. */
 struct kallsym_iter
 {
 	loff_t pos;
@@ -168,31 +250,23 @@
 /* Returns space to next name. */
 static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
 {
-	unsigned stemlen, off = iter->nameoff;
+	unsigned off = iter->nameoff;
 
-	/* First char of each symbol name indicates prefix length
-	   shared with previous name (stem compression). */
-	stemlen = kallsyms_names[off++];
-
-	strlcpy(iter->name+stemlen, kallsyms_names + off,
-		KSYM_NAME_LEN+1-stemlen);
-	off += strlen(kallsyms_names + off) + 1;
 	iter->owner = NULL;
 	iter->value = kallsyms_addresses[iter->pos];
-	if (is_kernel_text(iter->value) || is_kernel_inittext(iter->value))
-		iter->type = 't';
-	else
-		iter->type = 'd';
 
-	upcase_if_global(iter);
+	iter->type = kallsyms_get_symbol_type(off);
+
+	off = kallsyms_expand_symbol(off, iter->name);
+
 	return off - iter->nameoff;
 }
 
-static void reset_iter(struct kallsym_iter *iter)
+static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
 {
 	iter->name[0] = '\0';
-	iter->nameoff = 0;
-	iter->pos = 0;
+	iter->nameoff = get_symbol_offset(new_pos);
+	iter->pos = new_pos;
 }
 
 /* Returns false if pos at or past end of file. */
@@ -204,16 +278,13 @@
 		return get_ksymbol_mod(iter);
 	}
 	
-	/* If we're past the desired position, reset to start. */
-	if (pos < iter->pos)
-		reset_iter(iter);
-
-	/* We need to iterate through the previous symbols: can be slow */
-	for (; iter->pos != pos; iter->pos++) {
-		iter->nameoff += get_ksymbol_core(iter);
-		cond_resched();
-	}
-	get_ksymbol_core(iter);
+	/* If we're not on the desired position, reset to new position. */
+	if (pos != iter->pos)
+		reset_iter(iter, pos);
+
+	iter->nameoff += get_ksymbol_core(iter);
+	iter->pos++;
+
 	return 1;
 }
 
@@ -267,14 +338,15 @@
 static int kallsyms_open(struct inode *inode, struct file *file)
 {
 	/* We keep iterator in m->private, since normal case is to
-	 * s_start from where we left off, so we avoid O(N^2). */
+	 * s_start from where we left off, so we avoid doing
+	 * using get_symbol_offset for every symbol */
 	struct kallsym_iter *iter;
 	int ret;
 
 	iter = kmalloc(sizeof(*iter), GFP_KERNEL);
 	if (!iter)
 		return -ENOMEM;
-	reset_iter(iter);
+	reset_iter(iter, 0);
 
 	ret = seq_open(file, &kallsyms_op);
 	if (ret == 0)
diff -Nru a/kernel/kfifo.c b/kernel/kfifo.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/kfifo.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,168 @@
+/*
+ * A simple kernel FIFO implementation.
+ *
+ * Copyright (C) 2004 Stelian Pop <stelian@popies.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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/kfifo.h>
+
+/*
+ * kfifo_init - allocates a new FIFO using a preallocated buffer
+ * @buffer: the preallocated buffer to be used.
+ * @size: the size of the internal buffer, this have to be a power of 2.
+ * @gfp_mask: get_free_pages mask, passed to kmalloc()
+ * @lock: the lock to be used to protect the fifo buffer
+ *
+ * Do NOT pass the kfifo to kfifo_free() after use ! Simply free the
+ * struct kfifo with kfree().
+ */
+struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
+			 int gfp_mask, spinlock_t *lock)
+{
+	struct kfifo *fifo;
+
+	/* size must be a power of 2 */
+	BUG_ON(size & (size - 1));
+
+	fifo = kmalloc(sizeof(struct kfifo), gfp_mask);
+	if (!fifo)
+		return ERR_PTR(-ENOMEM);
+
+	fifo->buffer = buffer;
+	fifo->size = size;
+	fifo->in = fifo->out = 0;
+	fifo->lock = lock;
+
+	return fifo;
+}
+EXPORT_SYMBOL(kfifo_init);
+
+/*
+ * kfifo_alloc - allocates a new FIFO and its internal buffer
+ * @size: the size of the internal buffer to be allocated.
+ * @gfp_mask: get_free_pages mask, passed to kmalloc()
+ * @lock: the lock to be used to protect the fifo buffer
+ *
+ * The size will be rounded-up to a power of 2.
+ */
+struct kfifo *kfifo_alloc(unsigned int size, int gfp_mask, spinlock_t *lock)
+{
+	unsigned char *buffer;
+	struct kfifo *ret;
+
+	/*
+	 * round up to the next power of 2, since our 'let the indices
+	 * wrap' tachnique works only in this case.
+	 */
+	if (size & (size - 1)) {
+		BUG_ON(size > 0x80000000);
+		size = roundup_pow_of_two(size);
+	}
+
+	buffer = kmalloc(size, gfp_mask);
+	if (!buffer)
+		return ERR_PTR(-ENOMEM);
+
+	ret = kfifo_init(buffer, size, gfp_mask, lock);
+
+	if (IS_ERR(ret))
+		kfree(buffer);
+
+	return ret;
+}
+EXPORT_SYMBOL(kfifo_alloc);
+
+/*
+ * kfifo_free - frees the FIFO
+ * @fifo: the fifo to be freed.
+ */
+void kfifo_free(struct kfifo *fifo)
+{
+	kfree(fifo->buffer);
+	kfree(fifo);
+}
+EXPORT_SYMBOL(kfifo_free);
+
+/*
+ * __kfifo_put - puts some data into the FIFO, no locking version
+ * @fifo: the fifo to be used.
+ * @buffer: the data to be added.
+ * @len: the length of the data to be added.
+ *
+ * This function copies at most 'len' bytes from the 'buffer' into
+ * the FIFO depending on the free space, and returns the number of
+ * bytes copied.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
+ */
+unsigned int __kfifo_put(struct kfifo *fifo,
+			 unsigned char *buffer, unsigned int len)
+{
+	unsigned int l;
+
+	len = min(len, fifo->size - fifo->in + fifo->out);
+
+	/* first put the data starting from fifo->in to buffer end */
+	l = min(len, fifo->size - (fifo->in & (fifo->size - 1)));
+	memcpy(fifo->buffer + (fifo->in & (fifo->size - 1)), buffer, l);
+
+	/* then put the rest (if any) at the beginning of the buffer */
+	memcpy(fifo->buffer, buffer + l, len - l);
+
+	fifo->in += len;
+
+	return len;
+}
+EXPORT_SYMBOL(__kfifo_put);
+
+/*
+ * __kfifo_get - gets some data from the FIFO, no locking version
+ * @fifo: the fifo to be used.
+ * @buffer: where the data must be copied.
+ * @len: the size of the destination buffer.
+ *
+ * This function copies at most 'len' bytes from the FIFO into the
+ * 'buffer' and returns the number of copied bytes.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
+ */
+unsigned int __kfifo_get(struct kfifo *fifo,
+			 unsigned char *buffer, unsigned int len)
+{
+	unsigned int l;
+
+	len = min(len, fifo->in - fifo->out);
+
+	/* first get the data from fifo->out until the end of the buffer */
+	l = min(len, fifo->size - (fifo->out & (fifo->size - 1)));
+	memcpy(buffer, fifo->buffer + (fifo->out & (fifo->size - 1)), l);
+
+	/* then get the rest (if any) from the beginning of the buffer */
+	memcpy(buffer + l, fifo->buffer, len - l);
+
+	fifo->out += len;
+
+	return len;
+}
+EXPORT_SYMBOL(__kfifo_get);
diff -Nru a/kernel/kmod.c b/kernel/kmod.c
--- a/kernel/kmod.c	2004-12-24 13:36:32 -08:00
+++ b/kernel/kmod.c	2004-12-24 13:36:32 -08:00
@@ -115,29 +115,6 @@
 EXPORT_SYMBOL(request_module);
 #endif /* CONFIG_KMOD */
 
-#ifdef CONFIG_HOTPLUG
-/*
-	hotplug path is set via /proc/sys
-	invoked by hotplug-aware bus drivers,
-	with call_usermodehelper
-
-	argv [0] = hotplug_path;
-	argv [1] = "usb", "scsi", "pci", "network", etc;
-	... plus optional type-specific parameters
-	argv [n] = 0;
-
-	envp [*] = HOME, PATH; optional type-specific parameters
-
-	a hotplug bus should invoke this for device add/remove
-	events.  the command is expected to load drivers when
-	necessary, and may perform additional system setup.
-*/
-char hotplug_path[KMOD_PATH_LEN] = "/sbin/hotplug";
-
-EXPORT_SYMBOL(hotplug_path);
-
-#endif /* CONFIG_HOTPLUG */
-
 struct subprocess_info {
 	struct completion *complete;
 	char *path;
diff -Nru a/kernel/kprobes.c b/kernel/kprobes.c
--- a/kernel/kprobes.c	2004-12-24 13:37:44 -08:00
+++ b/kernel/kprobes.c	2004-12-24 13:37:44 -08:00
@@ -84,10 +84,13 @@
 		ret = -EEXIST;
 		goto out;
 	}
+
+	if ((ret = arch_prepare_kprobe(p)) != 0) {
+		goto out;
+	}
 	hlist_add_head(&p->hlist,
 		       &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]);
 
-	arch_prepare_kprobe(p);
 	p->opcode = *p->addr;
 	*p->addr = BREAKPOINT_INSTRUCTION;
 	flush_icache_range((unsigned long) p->addr,
@@ -101,6 +104,7 @@
 {
 	unsigned long flags;
 	spin_lock_irqsave(&kprobe_lock, flags);
+	arch_remove_kprobe(p);
 	*p->addr = p->opcode;
 	hlist_del(&p->hlist);
 	flush_icache_range((unsigned long) p->addr,
diff -Nru a/kernel/ksysfs.c b/kernel/ksysfs.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/ksysfs.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,56 @@
+/*
+ * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
+ * 		     are not related to any other subsystem
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * 
+ * This file is release under the GPLv2
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#define KERNEL_ATTR_RO(_name) \
+static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
+
+#define KERNEL_ATTR_RW(_name) \
+static struct subsys_attribute _name##_attr = \
+	__ATTR(_name, 0644, _name##_show, _name##_store)
+
+#ifdef CONFIG_HOTPLUG
+static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
+{
+	return sprintf(page, "%llu\n", (unsigned long long)hotplug_seqnum);
+}
+KERNEL_ATTR_RO(hotplug_seqnum);
+#endif
+
+static decl_subsys(kernel, NULL, NULL);
+
+static struct attribute * kernel_attrs[] = {
+#ifdef CONFIG_HOTPLUG
+	&hotplug_seqnum_attr.attr,
+#endif
+	NULL
+};
+
+static struct attribute_group kernel_attr_group = {
+	.attrs = kernel_attrs,
+};
+
+static int __init ksysfs_init(void)
+{
+	int error = subsystem_register(&kernel_subsys);
+	if (!error)
+		error = sysfs_create_group(&kernel_subsys.kset.kobj,
+					   &kernel_attr_group);
+
+	return error;
+}
+
+core_initcall(ksysfs_init);
diff -Nru a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c	2004-12-24 13:37:03 -08:00
+++ b/kernel/module.c	2004-12-24 13:37:03 -08:00
@@ -34,6 +34,7 @@
 #include <linux/vermagic.h>
 #include <linux/notifier.h>
 #include <linux/stop_machine.h>
+#include <linux/device.h>
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 #include <asm/cacheflush.h>
@@ -368,22 +369,6 @@
 }
 #endif /* CONFIG_SMP */
 
-static int add_attribute(struct module *mod, struct kernel_param *kp)
-{
-	struct module_attribute *a;
-	int retval;
-
-	a = &mod->mkobj->attr[mod->mkobj->num_attributes];
-	a->attr.name = (char *)kp->name;
-	a->attr.owner = mod;
-	a->attr.mode = kp->perm;
-	a->param = kp;
-	retval = sysfs_create_file(&mod->mkobj->kobj, &a->attr);
-	if (!retval)
-		mod->mkobj->num_attributes++;
-	return retval;
-}
-
 #ifdef CONFIG_MODULE_UNLOAD
 /* Init the unload section of the module. */
 static void module_unload_init(struct module *mod)
@@ -591,6 +576,8 @@
 
 	/* Stop the machine so refcounts can't move and disable module. */
 	ret = try_stop_module(mod, flags, &forced);
+	if (ret != 0)
+		goto out;
 
 	/* Never wait if forced. */
 	if (!forced && module_refcount(mod) != 0)
@@ -664,22 +651,16 @@
 }
 EXPORT_SYMBOL_GPL(symbol_put_addr);
 
-static int refcnt_get_fn(char *buffer, struct kernel_param *kp)
+static ssize_t show_refcnt(struct module *mod, char *buffer)
 {
-	struct module *mod = container_of(kp, struct module, refcnt_param);
-
-	/* sysfs holds one reference. */
-	return sprintf(buffer, "%u", module_refcount(mod)-1);
+	/* sysfs holds a reference */
+	return sprintf(buffer, "%u\n", module_refcount(mod)-1);
 }
 
-static inline int sysfs_unload_setup(struct module *mod)
-{
-	mod->refcnt_param.name = "refcnt";
-	mod->refcnt_param.perm = 0444;
-	mod->refcnt_param.get = refcnt_get_fn;
-
-	return add_attribute(mod, &mod->refcnt_param);
-}
+static struct module_attribute refcnt = {
+	.attr = { .name = "refcnt", .mode = 0444, .owner = THIS_MODULE },
+	.show = show_refcnt,
+};
 
 #else /* !CONFIG_MODULE_UNLOAD */
 static void print_unload_info(struct seq_file *m, struct module *mod)
@@ -707,10 +688,6 @@
 	return -ENOSYS;
 }
 
-static inline int sysfs_unload_setup(struct module *mod)
-{
-	return 0;
-}
 #endif /* CONFIG_MODULE_UNLOAD */
 
 #ifdef CONFIG_OBSOLETE_MODPARM
@@ -1049,101 +1026,57 @@
 #endif /* CONFIG_KALLSYMS */
 
 
-
-
-#define to_module_attr(n) container_of(n, struct module_attribute, attr);
-
-static ssize_t module_attr_show(struct kobject *kobj,
-				struct attribute *attr,
-				char *buf)
+#ifdef CONFIG_MODULE_UNLOAD
+static inline int module_add_refcnt_attr(struct module *mod)
 {
-	int count;
-	struct module_attribute *attribute = to_module_attr(attr);
-
-	if (!attribute->param->get)
-		return -EPERM;
-
-	count = attribute->param->get(buf, attribute->param);
-	if (count > 0) {
-		strcat(buf, "\n");
-		++count;
-	}
-	return count;
+	return sysfs_create_file(&mod->mkobj->kobj, &refcnt.attr);
 }
-
-/* sysfs always hands a nul-terminated string in buf.  We rely on that. */
-static ssize_t module_attr_store(struct kobject *kobj,
-				 struct attribute *attr,
-				 const char *buf, size_t len)
+static void module_remove_refcnt_attr(struct module *mod)
 {
-	int err;
-	struct module_attribute *attribute = to_module_attr(attr);
-
-	if (!attribute->param->set)
-		return -EPERM;
-
-	err = attribute->param->set(buf, attribute->param);
-	if (!err)
-		return len;
-	return err;
+	return sysfs_remove_file(&mod->mkobj->kobj, &refcnt.attr);
 }
-
-static struct sysfs_ops module_sysfs_ops = {
-	.show = module_attr_show,
-	.store = module_attr_store,
-};
-
-static void module_kobj_release(struct kobject *kobj)
+#else
+static inline int module_add_refcnt_attr(struct module *mod)
+{
+	return 0;
+}
+static void module_remove_refcnt_attr(struct module *mod)
 {
-	kfree(container_of(kobj, struct module_kobject, kobj));
 }
+#endif
 
-static struct kobj_type module_ktype = {
-	.sysfs_ops =	&module_sysfs_ops,
-	.release =	&module_kobj_release,
-};
-static decl_subsys(module, &module_ktype, NULL);
 
 static int mod_sysfs_setup(struct module *mod,
 			   struct kernel_param *kparam,
 			   unsigned int num_params)
 {
-	unsigned int i;
 	int err;
 
-	/* We overallocate: not every param is in sysfs, and maybe no refcnt */
-	mod->mkobj = kmalloc(sizeof(*mod->mkobj)
-			     + sizeof(mod->mkobj->attr[0]) * (num_params+1),
-			     GFP_KERNEL);
+	mod->mkobj = kmalloc(sizeof(struct module_kobject), GFP_KERNEL);
 	if (!mod->mkobj)
 		return -ENOMEM;
 
 	memset(&mod->mkobj->kobj, 0, sizeof(mod->mkobj->kobj));
-	err = kobject_set_name(&mod->mkobj->kobj, mod->name);
+	err = kobject_set_name(&mod->mkobj->kobj, "%s", mod->name);
 	if (err)
 		goto out;
 	kobj_set_kset_s(mod->mkobj, module_subsys);
+	mod->mkobj->mod = mod;
 	err = kobject_register(&mod->mkobj->kobj);
 	if (err)
 		goto out;
 
-	mod->mkobj->num_attributes = 0;
+	err = module_add_refcnt_attr(mod);
+	if (err)
+		goto out_unreg;
 
-	for (i = 0; i < num_params; i++) {
-		if (kparam[i].perm) {
-			err = add_attribute(mod, &kparam[i]);
-			if (err)
-				goto out_unreg;
-		}
-	}
-	err = sysfs_unload_setup(mod);
+	err = module_param_sysfs_setup(mod, kparam, num_params);
 	if (err)
 		goto out_unreg;
+
 	return 0;
 
 out_unreg:
-	for (i = 0; i < mod->mkobj->num_attributes; i++)
-		sysfs_remove_file(&mod->mkobj->kobj,&mod->mkobj->attr[i].attr);
 	/* Calls module_kobj_release */
 	kobject_unregister(&mod->mkobj->kobj);
 	return err;
@@ -1154,9 +1087,9 @@
 
 static void mod_kobject_remove(struct module *mod)
 {
-	unsigned int i;
-	for (i = 0; i < mod->mkobj->num_attributes; i++)
-		sysfs_remove_file(&mod->mkobj->kobj,&mod->mkobj->attr[i].attr);
+	module_remove_refcnt_attr(mod);
+	module_param_sysfs_remove(mod);
+
 	/* Calls module_kobj_release */
 	kobject_unregister(&mod->mkobj->kobj);
 }
@@ -1903,6 +1836,16 @@
 }
 
 #ifdef CONFIG_KALLSYMS
+/*
+ * This ignores the intensely annoying "mapping symbols" found
+ * in ARM ELF files: $a, $t and $d.
+ */
+static inline int is_arm_mapping_symbol(const char *str)
+{
+	return str[0] == '$' && strchr("atd", str[1]) 
+	       && (str[2] == '\0' || str[2] == '.');
+}
+
 static const char *get_ksymbol(struct module *mod,
 			       unsigned long addr,
 			       unsigned long *size,
@@ -1927,11 +1870,13 @@
 		 * and inserted at a whim. */
 		if (mod->symtab[i].st_value <= addr
 		    && mod->symtab[i].st_value > mod->symtab[best].st_value
-		    && *(mod->strtab + mod->symtab[i].st_name) != '\0' )
+		    && *(mod->strtab + mod->symtab[i].st_name) != '\0'
+		    && !is_arm_mapping_symbol(mod->strtab + mod->symtab[i].st_name))
 			best = i;
 		if (mod->symtab[i].st_value > addr
 		    && mod->symtab[i].st_value < nextval
-		    && *(mod->strtab + mod->symtab[i].st_name) != '\0')
+		    && *(mod->strtab + mod->symtab[i].st_name) != '\0'
+		    && !is_arm_mapping_symbol(mod->strtab + mod->symtab[i].st_name))
 			nextval = mod->symtab[i].st_value;
 	}
 
@@ -2140,14 +2085,28 @@
 	printk("\n");
 }
 
+void module_add_driver(struct module *mod, struct device_driver *drv)
+{
+	if (!mod || !drv)
+		return;
+	if (!mod->mkobj)
+		return;
+
+	/* Don't check return code; this call is idempotent */
+	sysfs_create_link(&drv->kobj, &mod->mkobj->kobj, "module");
+}
+EXPORT_SYMBOL(module_add_driver);
+
+void module_remove_driver(struct device_driver *drv)
+{
+	if (!drv)
+		return;
+	sysfs_remove_link(&drv->kobj, "module");
+}
+EXPORT_SYMBOL(module_remove_driver);
+
 #ifdef CONFIG_MODVERSIONS
 /* Generate the signature for struct module here, too, for modversions. */
 void struct_module(struct module *mod) { return; }
 EXPORT_SYMBOL(struct_module);
 #endif
-
-static int __init modules_init(void)
-{
-	return subsystem_register(&module_subsys);
-}
-__initcall(modules_init);
diff -Nru a/kernel/panic.c b/kernel/panic.c
--- a/kernel/panic.c	2004-12-24 13:37:29 -08:00
+++ b/kernel/panic.c	2004-12-24 13:37:29 -08:00
@@ -16,7 +16,6 @@
 #include <linux/notifier.h>
 #include <linux/init.h>
 #include <linux/sysrq.h>
-#include <linux/syscalls.h>
 #include <linux/interrupt.h>
 #include <linux/nmi.h>
 
@@ -37,6 +36,15 @@
 }
 __setup("panic=", panic_setup);
 
+static long no_blink(long time)
+{
+	return 0;
+}
+
+/* Returns how long it waited in ms */
+long (*panic_blink)(long time);
+EXPORT_SYMBOL(panic_blink);
+
 /**
  *	panic - halt the system
  *	@fmt: The text string to print
@@ -49,6 +57,7 @@
  
 NORET_TYPE void panic(const char * fmt, ...)
 {
+	long i;
 	static char buf[1024];
 	va_list args;
 #if defined(CONFIG_ARCH_S390)
@@ -66,19 +75,23 @@
 	smp_send_stop();
 #endif
 
-       notifier_call_chain(&panic_notifier_list, 0, buf);
+	notifier_call_chain(&panic_notifier_list, 0, buf);
+
+	if (!panic_blink)
+		panic_blink = no_blink;
 
 	if (panic_timeout > 0)
 	{
-		int i;
 		/*
 	 	 * Delay timeout seconds before rebooting the machine. 
 		 * We can't use the "normal" timers since we just panicked..
 	 	 */
 		printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
-		for (i = 0; i < panic_timeout; i++) {
+		for (i = 0; i < panic_timeout*1000; ) {
 			touch_nmi_watchdog();
-			mdelay(1000);
+			i += panic_blink(i);
+			mdelay(1);
+			i++;
 		}
 		/*
 		 *	Should we run the reboot notifier. For the moment Im
@@ -99,8 +112,11 @@
         disabled_wait(caller);
 #endif
 	local_irq_enable();
-	for (;;)
-		;
+	for (i = 0;;) {
+		i += panic_blink(i);
+		mdelay(1);
+		i++;
+	}
 }
 
 EXPORT_SYMBOL(panic);
@@ -111,6 +127,9 @@
  *  'P' - Proprietary module has been loaded.
  *  'F' - Module has been forcibly loaded.
  *  'S' - SMP with CPUs not designed for SMP.
+ *  'R' - User forced a module unload.
+ *  'M' - Machine had a machine check experience.
+ *  'B' - System has hit bad_page.
  *
  *	The string is overwritten by the next call to print_taint().
  */
@@ -119,12 +138,21 @@
 {
 	static char buf[20];
 	if (tainted) {
-		snprintf(buf, sizeof(buf), "Tainted: %c%c%c",
+		snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c",
 			tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
 			tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
-			tainted & TAINT_UNSAFE_SMP ? 'S' : ' ');
+			tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
+			tainted & TAINT_FORCED_RMMOD ? 'R' : ' ',
+ 			tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
+			tainted & TAINT_BAD_PAGE ? 'B' : ' ');
 	}
 	else
 		snprintf(buf, sizeof(buf), "Not tainted");
 	return(buf);
 }
+
+void add_taint(unsigned flag)
+{
+	tainted |= flag;
+}
+EXPORT_SYMBOL(add_taint);
diff -Nru a/kernel/params.c b/kernel/params.c
--- a/kernel/params.c	2004-12-24 13:37:18 -08:00
+++ b/kernel/params.c	2004-12-24 13:37:18 -08:00
@@ -15,11 +15,14 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+#include <linux/config.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/module.h>
+#include <linux/device.h>
+#include <linux/err.h>
 
 #if 0
 #define DEBUGP printk
@@ -304,7 +307,7 @@
 	struct kparam_array *arr = kp->arg;
 
 	return param_array(kp->name, val, 1, arr->max, arr->elem,
-			   arr->elemsize, arr->set, arr->num);
+			   arr->elemsize, arr->set, arr->num ?: &arr->max);
 }
 
 int param_array_get(char *buffer, struct kernel_param *kp)
@@ -314,7 +317,7 @@
 	struct kernel_param p;
 
 	p = *kp;
-	for (i = off = 0; i < *arr->num; i++) {
+	for (i = off = 0; i < (arr->num ? *arr->num : arr->max); i++) {
 		if (i)
 			buffer[off++] = ',';
 		p.arg = arr->elem + arr->elemsize * i;
@@ -345,6 +348,394 @@
 	struct kparam_string *kps = kp->arg;
 	return strlcpy(buffer, kps->string, kps->maxlen);
 }
+
+/* sysfs output in /sys/modules/XYZ/parameters/ */
+
+extern struct kernel_param __start___param[], __stop___param[];
+
+#define MAX_KBUILD_MODNAME KOBJ_NAME_LEN
+
+struct param_attribute
+{
+	struct attribute attr;
+	struct kernel_param *param;
+};
+
+struct param_kobject
+{
+	struct kobject kobj;
+
+	unsigned int num_attributes;
+	struct param_attribute attr[0];
+};
+
+#define to_param_attr(n) container_of(n, struct param_attribute, attr);
+
+static ssize_t param_attr_show(struct kobject *kobj,
+			       struct attribute *attr,
+			       char *buf)
+{
+	int count;
+	struct param_attribute *attribute = to_param_attr(attr);
+
+	if (!attribute->param->get)
+		return -EPERM;
+
+	count = attribute->param->get(buf, attribute->param);
+	if (count > 0) {
+		strcat(buf, "\n");
+		++count;
+	}
+	return count;
+}
+
+/* sysfs always hands a nul-terminated string in buf.  We rely on that. */
+static ssize_t param_attr_store(struct kobject *kobj,
+				struct attribute *attr,
+				const char *buf, size_t len)
+{
+ 	int err;
+	struct param_attribute *attribute = to_param_attr(attr);
+
+	if (!attribute->param->set)
+		return -EPERM;
+
+	err = attribute->param->set(buf, attribute->param);
+	if (!err)
+		return len;
+	return err;
+}
+
+
+static struct sysfs_ops param_sysfs_ops = {
+	.show = param_attr_show,
+	.store = param_attr_store,
+};
+
+static void param_kobj_release(struct kobject *kobj)
+{
+	kfree(container_of(kobj, struct param_kobject, kobj));
+}
+
+static struct kobj_type param_ktype = {
+	.sysfs_ops =	&param_sysfs_ops,
+	.release =	&param_kobj_release,
+};
+
+static struct kset param_kset = {
+	.subsys =	&module_subsys,
+	.ktype =	&param_ktype,
+};
+
+#ifdef CONFIG_MODULES
+#define __modinit
+#else
+#define __modinit __init
+#endif
+
+/*
+ * param_add_attribute - actually adds an parameter to sysfs
+ * @mod: owner of parameter
+ * @pk: param_kobject the attribute shall be assigned to.
+ *      One per module, one per KBUILD_MODNAME.
+ * @kp: kernel_param to be added
+ * @skip: offset where the parameter name start in kp->name.
+ * Needed for built-in modules
+ *
+ * Fill in data into appropriate &pk->attr[], and create sysfs file.
+ */
+static __modinit int param_add_attribute(struct module *mod,
+					 struct param_kobject *pk,
+					 struct kernel_param *kp,
+					 unsigned int skip)
+{
+	struct param_attribute *a;
+	int err;
+
+	a = &pk->attr[pk->num_attributes];
+	a->attr.name = (char *) &kp->name[skip];
+	a->attr.owner = mod;
+	a->attr.mode = kp->perm;
+	a->param = kp;
+	err = sysfs_create_file(&pk->kobj, &a->attr);
+	if (!err)
+		pk->num_attributes++;
+	return err;
+}
+
+/*
+ * param_sysfs_remove - remove sysfs support for one module or KBUILD_MODNAME
+ * @pk: struct param_kobject which is to be removed
+ *
+ * Called when an error in registration occurs or a module is removed
+ * from the system.
+ */
+static __modinit void param_sysfs_remove(struct param_kobject *pk)
+{
+	unsigned int i;
+	for (i = 0; i < pk->num_attributes; i++)
+		sysfs_remove_file(&pk->kobj,&pk->attr[i].attr);
+
+	/* Calls param_kobj_release */
+	kobject_unregister(&pk->kobj);
+}
+
+
+/*
+ * param_sysfs_setup - setup sysfs support for one module or KBUILD_MODNAME
+ * @mk: struct module_kobject (contains parent kobject)
+ * @kparam: array of struct kernel_param, the actual parameter definitions
+ * @num_params: number of entries in array
+ * @name_skip: offset where the parameter name start in kparam[].name. Needed for built-in "modules"
+ *
+ * Create a kobject for a (per-module) group of parameters, and create files
+ * in sysfs. A pointer to the param_kobject is returned on success,
+ * NULL if there's no parameter to export, or other ERR_PTR(err).
+ */
+static __modinit struct param_kobject *
+param_sysfs_setup(struct module_kobject *mk,
+		  struct kernel_param *kparam,
+		  unsigned int num_params,
+		  unsigned int name_skip)
+{
+	struct param_kobject *pk;
+	unsigned int valid_attrs = 0;
+	unsigned int i;
+	int err;
+
+	for (i=0; i<num_params; i++) {
+		if (kparam[i].perm)
+			valid_attrs++;
+	}
+
+	if (!valid_attrs)
+		return NULL;
+
+	pk = kmalloc(sizeof(struct param_kobject)
+		     + sizeof(struct param_attribute) * valid_attrs,
+		     GFP_KERNEL);
+	if (!pk)
+		return ERR_PTR(-ENOMEM);
+	memset(pk, 0, sizeof(struct param_kobject)
+	       + sizeof(struct param_attribute) * valid_attrs);
+
+	err = kobject_set_name(&pk->kobj, "parameters");
+	if (err)
+		goto out;
+
+	pk->kobj.kset = &param_kset;
+	pk->kobj.parent = &mk->kobj;
+	err = kobject_register(&pk->kobj);
+	if (err)
+		goto out;
+
+	for (i = 0; i < num_params; i++) {
+		if (kparam[i].perm) {
+			err = param_add_attribute(mk->mod, pk,
+						  &kparam[i], name_skip);
+			if (err)
+				goto out_unreg;
+		}
+	}
+
+	return pk;
+
+out_unreg:
+	param_sysfs_remove(pk);
+	return ERR_PTR(err);
+
+out:
+	kfree(pk);
+	return ERR_PTR(err);
+}
+
+
+#ifdef CONFIG_MODULES
+
+/*
+ * module_param_sysfs_setup - setup sysfs support for one module
+ * @mod: module
+ * @kparam: module parameters (array)
+ * @num_params: number of module parameters
+ *
+ * Adds sysfs entries for module parameters, and creates a link from
+ * /sys/module/[mod->name]/parameters to /sys/parameters/[mod->name]/
+ */
+int module_param_sysfs_setup(struct module *mod,
+			     struct kernel_param *kparam,
+			     unsigned int num_params)
+{
+	struct param_kobject *pk;
+
+	pk = param_sysfs_setup(mod->mkobj, kparam, num_params, 0);
+	if (IS_ERR(pk))
+		return PTR_ERR(pk);
+
+	mod->params_kobject = pk;
+	return 0;
+}
+
+/*
+ * module_param_sysfs_remove - remove sysfs support for one module
+ * @mod: module
+ *
+ * Remove sysfs entries for module parameters and the corresponding
+ * kobject.
+ */
+void module_param_sysfs_remove(struct module *mod)
+{
+	if (mod->params_kobject) {
+		param_sysfs_remove(mod->params_kobject);
+		mod->params_kobject = NULL;
+	}
+}
+#endif
+
+/*
+ * kernel_param_sysfs_setup - wrapper for built-in params support
+ */
+static void __init kernel_param_sysfs_setup(const char *name,
+					    struct kernel_param *kparam,
+					    unsigned int num_params,
+					    unsigned int name_skip)
+{
+	struct module_kobject *mk;
+
+	mk = kmalloc(sizeof(struct module_kobject), GFP_KERNEL);
+	memset(mk, 0, sizeof(struct module_kobject));
+
+	mk->mod = THIS_MODULE;
+	kobj_set_kset_s(mk, module_subsys);
+	kobject_set_name(&mk->kobj, name);
+	kobject_register(&mk->kobj);
+
+	/* no need to keep the kobject if no parameter is exported */
+	if (!param_sysfs_setup(mk, kparam, num_params, name_skip))
+		kobject_unregister(&mk->kobj);
+}
+
+/*
+ * param_sysfs_builtin - add contents in /sys/parameters for built-in modules
+ *
+ * Add module_parameters to sysfs for "modules" built into the kernel.
+ *
+ * The "module" name (KBUILD_MODNAME) is stored before a dot, the
+ * "parameter" name is stored behind a dot in kernel_param->name. So,
+ * extract the "module" name for all built-in kernel_param-eters,
+ * and for all who have the same, call kernel_param_sysfs_setup.
+ */
+static void __init param_sysfs_builtin(void)
+{
+	struct kernel_param *kp, *kp_begin = NULL;
+	unsigned int i, name_len, count = 0;
+	char modname[MAX_KBUILD_MODNAME + 1] = "";
+
+	for (i=0; i < __stop___param - __start___param; i++) {
+		char *dot;
+
+		kp = &__start___param[i];
+
+		/* We do not handle args without periods. */
+		dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
+		if (!dot) {
+			DEBUGP("couldn't find period in %s\n", kp->name);
+			continue;
+		}
+		name_len = dot - kp->name;
+
+ 		/* new kbuild_modname? */
+		if (strlen(modname) != name_len
+		    || strncmp(modname, kp->name, name_len) != 0) {
+			/* add a new kobject for previous kernel_params. */
+			if (count)
+				kernel_param_sysfs_setup(modname,
+							 kp_begin,
+							 count,
+							 strlen(modname)+1);
+
+			strncpy(modname, kp->name, name_len);
+			modname[name_len] = '\0';
+			count = 0;
+			kp_begin = kp;
+		}
+		count++;
+	}
+
+	/* last kernel_params need to be registered as well */
+	if (count)
+		kernel_param_sysfs_setup(modname, kp_begin, count,
+					 strlen(modname)+1);
+}
+
+
+/* module-related sysfs stuff */
+#ifdef CONFIG_MODULES
+
+#define to_module_attr(n) container_of(n, struct module_attribute, attr);
+#define to_module_kobject(n) container_of(n, struct module_kobject, kobj);
+
+static ssize_t module_attr_show(struct kobject *kobj,
+				struct attribute *attr,
+				char *buf)
+{
+	struct module_attribute *attribute;
+	struct module_kobject *mk;
+	int ret;
+
+	attribute = to_module_attr(attr);
+	mk = to_module_kobject(kobj);
+
+	if (!attribute->show)
+		return -EPERM;
+
+	if (!try_module_get(mk->mod))
+		return -ENODEV;
+
+	ret = attribute->show(mk->mod, buf);
+
+	module_put(mk->mod);
+
+	return ret;
+}
+
+static struct sysfs_ops module_sysfs_ops = {
+	.show = module_attr_show,
+	.store = NULL,
+};
+
+#else
+static struct sysfs_ops module_sysfs_ops = {
+	.show = NULL,
+	.store = NULL,
+};
+#endif
+
+static void module_kobj_release(struct kobject *kobj)
+{
+	kfree(container_of(kobj, struct module_kobject, kobj));
+}
+
+static struct kobj_type module_ktype = {
+	.sysfs_ops =	&module_sysfs_ops,
+	.release =	&module_kobj_release,
+};
+
+decl_subsys(module, &module_ktype, NULL);
+
+/*
+ * param_sysfs_init - wrapper for built-in params support
+ */
+static int __init param_sysfs_init(void)
+{
+	subsystem_register(&module_subsys);
+	kobject_set_name(&param_kset.kobj, "parameters");
+	kset_init(&param_kset);
+
+	param_sysfs_builtin();
+
+	return 0;
+}
+__initcall(param_sysfs_init);
 
 EXPORT_SYMBOL(param_set_byte);
 EXPORT_SYMBOL(param_get_byte);
diff -Nru a/kernel/pid.c b/kernel/pid.c
--- a/kernel/pid.c	2004-12-24 13:36:57 -08:00
+++ b/kernel/pid.c	2004-12-24 13:36:57 -08:00
@@ -1,8 +1,9 @@
 /*
  * Generic pidhash and scalable, time-bounded PID allocator
  *
- * (C) 2002 William Irwin, IBM
- * (C) 2002 Ingo Molnar, Red Hat
+ * (C) 2002-2003 William Irwin, IBM
+ * (C) 2004 William Irwin, Oracle
+ * (C) 2002-2004 Ingo Molnar, Red Hat
  *
  * pid-structures are backing objects for tasks sharing a given ID to chain
  * against. There is very little to them aside from hashing them and
@@ -35,9 +36,15 @@
 
 #define RESERVED_PIDS		300
 
-#define PIDMAP_ENTRIES		(PID_MAX_LIMIT/PAGE_SIZE/8)
+int pid_max_min = RESERVED_PIDS + 1;
+int pid_max_max = PID_MAX_LIMIT;
+
+#define PIDMAP_ENTRIES		((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8)
 #define BITS_PER_PAGE		(PAGE_SIZE*8)
 #define BITS_PER_PAGE_MASK	(BITS_PER_PAGE-1)
+#define mk_pid(map, off)	(((map) - pidmap_array)*BITS_PER_PAGE + (off))
+#define find_next_offset(map, off)					\
+		find_next_zero_bit((map)->page, BITS_PER_PAGE, off)
 
 /*
  * PID-map pages start out as NULL, they get allocated upon
@@ -53,8 +60,6 @@
 static pidmap_t pidmap_array[PIDMAP_ENTRIES] =
 	 { [ 0 ... PIDMAP_ENTRIES-1 ] = { ATOMIC_INIT(BITS_PER_PAGE), NULL } };
 
-static pidmap_t *map_limit = pidmap_array + PIDMAP_ENTRIES;
-
 static spinlock_t pidmap_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
 
 fastcall void free_pidmap(int pid)
@@ -66,15 +71,18 @@
 	atomic_inc(&map->nr_free);
 }
 
-/*
- * Here we search for the next map that has free bits left.
- * Normally the next map has free PIDs.
- */
-static inline pidmap_t *next_free_map(pidmap_t *map, int *max_steps)
+int alloc_pidmap(void)
 {
-	while (--*max_steps) {
-		if (++map == map_limit)
-			map = pidmap_array;
+	int i, offset, max_scan, pid, last = last_pid;
+	pidmap_t *map;
+
+	pid = last + 1;
+	if (pid >= pid_max)
+		pid = RESERVED_PIDS;
+	offset = pid & BITS_PER_PAGE_MASK;
+	map = &pidmap_array[pid/BITS_PER_PAGE];
+	max_scan = (pid_max + BITS_PER_PAGE - 1)/BITS_PER_PAGE - !offset;
+	for (i = 0; i <= max_scan; ++i) {
 		if (unlikely(!map->page)) {
 			unsigned long page = get_zeroed_page(GFP_KERNEL);
 			/*
@@ -87,62 +95,39 @@
 			else
 				map->page = (void *)page;
 			spin_unlock(&pidmap_lock);
-
-			if (!map->page)
+			if (unlikely(!map->page))
 				break;
 		}
-		if (atomic_read(&map->nr_free))
-			return map;
-	}
-	return NULL;
-}
-
-int alloc_pidmap(void)
-{
-	int pid, offset, max_steps = PIDMAP_ENTRIES + 1;
-	pidmap_t *map;
-
-	pid = last_pid + 1;
-	if (pid >= pid_max)
-		pid = RESERVED_PIDS;
-
-	offset = pid & BITS_PER_PAGE_MASK;
-	map = pidmap_array + pid / BITS_PER_PAGE;
-
-	if (likely(map->page && !test_and_set_bit(offset, map->page))) {
-		/*
-		 * There is a small window for last_pid updates to race,
-		 * but in that case the next allocation will go into the
-		 * slowpath and that fixes things up.
-		 */
-return_pid:
-		atomic_dec(&map->nr_free);
-		last_pid = pid;
-		return pid;
-	}
-	
-	if (!offset || !atomic_read(&map->nr_free)) {
-next_map:
-		map = next_free_map(map, &max_steps);
-		if (!map)
-			goto failure;
-		offset = 0;
+		if (likely(atomic_read(&map->nr_free))) {
+			do {
+				if (!test_and_set_bit(offset, map->page)) {
+					atomic_dec(&map->nr_free);
+					last_pid = pid;
+					return pid;
+				}
+				offset = find_next_offset(map, offset);
+				pid = mk_pid(map, offset);
+			/*
+			 * find_next_offset() found a bit, the pid from it
+			 * is in-bounds, and if we fell back to the last
+			 * bitmap block and the final block was the same
+			 * as the starting point, pid is before last_pid.
+			 */
+			} while (offset < BITS_PER_PAGE && pid < pid_max &&
+					(i != max_scan || pid < last ||
+					    !((last+1) & BITS_PER_PAGE_MASK)));
+		}
+		if (map < &pidmap_array[(pid_max-1)/BITS_PER_PAGE]) {
+			++map;
+			offset = 0;
+		} else {
+			map = &pidmap_array[0];
+			offset = RESERVED_PIDS;
+			if (unlikely(last == offset))
+				break;
+		}
+		pid = mk_pid(map, offset);
 	}
-	/*
-	 * Find the next zero bit:
-	 */
-scan_more:
-	offset = find_next_zero_bit(map->page, BITS_PER_PAGE, offset);
-	if (offset >= BITS_PER_PAGE)
-		goto next_map;
-	if (test_and_set_bit(offset, map->page))
-		goto scan_more;
-
-	/* we got the PID: */
-	pid = (map - pidmap_array) * BITS_PER_PAGE + offset;
-	goto return_pid;
-
-failure:
 	return -1;
 }
 
@@ -178,15 +163,18 @@
 	return 0;
 }
 
-static inline int __detach_pid(task_t *task, enum pid_type type)
+static fastcall int __detach_pid(task_t *task, enum pid_type type)
 {
 	struct pid *pid, *pid_next;
-	int nr;
+	int nr = 0;
 
 	pid = &task->pids[type];
 	if (!hlist_unhashed(&pid->pid_chain)) {
 		hlist_del(&pid->pid_chain);
-		if (!list_empty(&pid->pid_list)) {
+
+		if (list_empty(&pid->pid_list))
+			nr = pid->nr;
+		else {
 			pid_next = list_entry(pid->pid_list.next,
 						struct pid, pid_list);
 			/* insert next pid from pid_list to hash */
@@ -194,8 +182,8 @@
 				&pid_hash[type][pid_hashfn(pid_next->nr)]);
 		}
 	}
+
 	list_del(&pid->pid_list);
-	nr = pid->nr;
 	pid->nr = 0;
 
 	return nr;
@@ -203,15 +191,16 @@
 
 void fastcall detach_pid(task_t *task, enum pid_type type)
 {
-	int nr;
+	int tmp, nr;
 
 	nr = __detach_pid(task, type);
 	if (!nr)
 		return;
 
-	for (type = 0; type < PIDTYPE_MAX; ++type)
-		if (find_pid(type, nr))
+	for (tmp = PIDTYPE_MAX; --tmp >= 0; )
+		if (tmp != type && find_pid(tmp, nr))
 			return;
+
 	free_pidmap(nr);
 }
 
diff -Nru a/kernel/posix-timers.c b/kernel/posix-timers.c
--- a/kernel/posix-timers.c	2004-12-24 13:36:55 -08:00
+++ b/kernel/posix-timers.c	2004-12-24 13:36:55 -08:00
@@ -43,6 +43,7 @@
 #include <linux/compiler.h>
 #include <linux/idr.h>
 #include <linux/posix-timers.h>
+#include <linux/syscalls.h>
 #include <linux/wait.h>
 #include <linux/workqueue.h>
 
@@ -133,18 +134,10 @@
  *	    resolution.	 Here we define the standard CLOCK_REALTIME as a
  *	    1/HZ resolution clock.
  *
- * CPUTIME & THREAD_CPUTIME: We are not, at this time, definding these
- *	    two clocks (and the other process related clocks (Std
- *	    1003.1d-1999).  The way these should be supported, we think,
- *	    is to use large negative numbers for the two clocks that are
- *	    pinned to the executing process and to use -pid for clocks
- *	    pinned to particular pids.	Calls which supported these clock
- *	    ids would split early in the function.
- *
  * RESOLUTION: Clock resolution is used to round up timer and interval
  *	    times, NOT to report clock times, which are reported with as
  *	    much resolution as the system can muster.  In some cases this
- *	    resolution may depend on the underlaying clock hardware and
+ *	    resolution may depend on the underlying clock hardware and
  *	    may not be quantifiable until run time, and only then is the
  *	    necessary code is written.	The standard says we should say
  *	    something about this issue in the documentation...
@@ -162,7 +155,7 @@
  *
  *          At this time all functions EXCEPT clock_nanosleep can be
  *          redirected by the CLOCKS structure.  Clock_nanosleep is in
- *          there, but the code ignors it.
+ *          there, but the code ignores it.
  *
  * Permissions: It is assumed that the clock_settime() function defined
  *	    for each clock will take care of permission checks.	 Some
@@ -192,12 +185,10 @@
 #define p_timer_del(clock,a) \
 		if_clock_do((clock)->timer_del, do_timer_delete, (a))
 
-void register_posix_clock(int clock_id, struct k_clock *new_clock);
 static int do_posix_gettime(struct k_clock *clock, struct timespec *tp);
 static u64 do_posix_clock_monotonic_gettime_parts(
 	struct timespec *tp, struct timespec *mo);
 int do_posix_clock_monotonic_gettime(struct timespec *tp);
-int do_posix_clock_monotonic_settime(struct timespec *tp);
 static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags);
 
 static inline void unlock_timer(struct k_itimer *timr, unsigned long flags)
@@ -216,7 +207,7 @@
 	struct k_clock clock_monotonic = {.res = CLOCK_REALTIME_RES,
 		.abs_struct = NULL,
 		.clock_get = do_posix_clock_monotonic_gettime,
-		.clock_set = do_posix_clock_monotonic_settime
+		.clock_set = do_posix_clock_nosettime
 	};
 
 	register_posix_clock(CLOCK_REALTIME, &clock_realtime);
@@ -371,32 +362,10 @@
 		unlock_timer(timr, flags);
 }
 
-/*
- * Notify the task and set up the timer for the next expiration (if
- * applicable).  This function requires that the k_itimer structure
- * it_lock is taken.  This code will requeue the timer only if we get
- * either an error return or a flag (ret > 0) from send_seg_info
- * indicating that the signal was either not queued or was queued
- * without an info block.  In this case, we will not get a call back to
- * do_schedule_next_timer() so we do it here.  This should be rare...
-
- * An interesting problem can occur if, while a signal, and thus a call
- * back is pending, the timer is rearmed, i.e. stopped and restarted.
- * We then need to sort out the call back and do the right thing.  What
- * we do is to put a counter in the info block and match it with the
- * timers copy on the call back.  If they don't match, we just ignore
- * the call back.  The counter is local to the timer and we use odd to
- * indicate a call back is pending.  Note that we do allow the timer to 
- * be deleted while a signal is pending.  The standard says we can
- * allow that signal to be delivered, and we do. 
- */
-
-static void timer_notify_task(struct k_itimer *timr)
+int posix_timer_event(struct k_itimer *timr,int si_private)
 {
-	int ret;
-
 	memset(&timr->sigq->info, 0, sizeof(siginfo_t));
-
+	timr->sigq->info.si_sys_private = si_private;
 	/*
 	 * Send signal to the process that owns this timer.
 
@@ -411,12 +380,6 @@
 	timr->sigq->info.si_code = SI_TIMER;
 	timr->sigq->info.si_tid = timr->it_id;
 	timr->sigq->info.si_value = timr->it_sigev_value;
-	if (timr->it_incr)
-		timr->sigq->info.si_sys_private = ++timr->it_requeue_pending;
-	else {
-		remove_from_abslist(timr);
-	}
-
 	if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
 		if (unlikely(timr->it_process->flags & PF_EXITING)) {
 			timr->it_sigev_notify = SIGEV_SIGNAL;
@@ -424,28 +387,20 @@
 			timr->it_process = timr->it_process->group_leader;
 			goto group;
 		}
-		ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
+		return send_sigqueue(timr->it_sigev_signo, timr->sigq,
 			timr->it_process);
 	}
 	else {
 	group:
-		ret = send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
+		return send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
 			timr->it_process);
 	}
-	if (ret) {
-		/*
-		 * signal was not sent because of sig_ignor
-		 * we will not get a call back to restart it AND
-		 * it should be restarted.
-		 */
-		schedule_next_timer(timr);
-	}
 }
 
 /*
  * This function gets called when a POSIX.1b interval timer expires.  It
  * is used as a callback from the kernel internal timer.  The
- * run_timer_list code ALWAYS calls with interrutps on.
+ * run_timer_list code ALWAYS calls with interrupts on.
 
  * This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers.
  */
@@ -488,8 +443,23 @@
 		spin_unlock(&abs_list.lock);
 
 	}
-	if (do_notify)
-		timer_notify_task(timr);
+	if (do_notify)  {
+		int si_private=0;
+
+		if (timr->it_incr)
+			si_private = ++timr->it_requeue_pending;
+		else {
+			remove_from_abslist(timr);
+		}
+
+		if (posix_timer_event(timr, si_private))
+			/*
+			 * signal was not sent because of sig_ignor
+			 * we will not get a call back to restart it AND
+			 * it should be restarted.
+			 */
+			schedule_next_timer(timr);
+	}
 	unlock_timer(timr, flags); /* hold thru abs lock to keep irq off */
 }
 
@@ -603,11 +573,17 @@
 	new_timer->it_clock = which_clock;
 	new_timer->it_incr = 0;
 	new_timer->it_overrun = -1;
-	init_timer(&new_timer->it_timer);
-	new_timer->it_timer.expires = 0;
-	new_timer->it_timer.data = (unsigned long) new_timer;
-	new_timer->it_timer.function = posix_timer_fn;
-	set_timer_inactive(new_timer);
+	if (posix_clocks[which_clock].timer_create) {
+		error =  posix_clocks[which_clock].timer_create(new_timer);
+		if (error)
+			goto out;
+	} else {
+		init_timer(&new_timer->it_timer);
+		new_timer->it_timer.expires = 0;
+		new_timer->it_timer.data = (unsigned long) new_timer;
+		new_timer->it_timer.function = posix_timer_fn;
+		set_timer_inactive(new_timer);
+	}
 
 	/*
 	 * return the timer_id now.  The next step is hard to
@@ -1217,11 +1193,25 @@
 	return 0;
 }
 
-int do_posix_clock_monotonic_settime(struct timespec *tp)
+int do_posix_clock_nosettime(struct timespec *tp)
+{
+	return -EINVAL;
+}
+
+int do_posix_clock_notimer_create(struct k_itimer *timer)
 {
 	return -EINVAL;
 }
 
+int do_posix_clock_nonanosleep(int which_clock, int flags, struct timespec *t)
+{
+#ifndef ENOTSUP
+	return -EOPNOTSUPP;	/* aka ENOTSUP in userland for POSIX */
+#else  /*  parisc does define it separately.  */
+	return -ENOTSUP;
+#endif
+}
+
 asmlinkage long
 sys_clock_settime(clockid_t which_clock, const struct timespec __user *tp)
 {
@@ -1238,19 +1228,23 @@
 	return do_sys_settimeofday(&new_tp, NULL);
 }
 
-asmlinkage long
-sys_clock_gettime(clockid_t which_clock, struct timespec __user *tp)
+static int do_clock_gettime(clockid_t which_clock, struct timespec *tp)
 {
-	struct timespec rtn_tp;
-	int error = 0;
-
 	if ((unsigned) which_clock >= MAX_CLOCKS ||
 					!posix_clocks[which_clock].res)
 		return -EINVAL;
 
-	error = do_posix_gettime(&posix_clocks[which_clock], &rtn_tp);
+	return do_posix_gettime(&posix_clocks[which_clock], tp);
+}
+
+asmlinkage long
+sys_clock_gettime(clockid_t which_clock, struct timespec __user *tp)
+{
+	struct timespec kernel_tp;
+	int error;
 
-	if (!error && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp)))
+	error = do_clock_gettime(which_clock, &kernel_tp);
+	if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
 		error = -EFAULT;
 
 	return error;
@@ -1408,7 +1402,10 @@
 	if ((unsigned) t.tv_nsec >= NSEC_PER_SEC || t.tv_sec < 0)
 		return -EINVAL;
 
-	ret = do_clock_nanosleep(which_clock, flags, &t);
+	if (posix_clocks[which_clock].nsleep)
+		ret = posix_clocks[which_clock].nsleep(which_clock, flags, &t);
+	else
+		ret = do_clock_nanosleep(which_clock, flags, &t);
 	/*
 	 * Do this here as do_clock_nanosleep does not have the real address
 	 */
diff -Nru a/kernel/power/Kconfig b/kernel/power/Kconfig
--- a/kernel/power/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/kernel/power/Kconfig	2004-12-24 13:37:18 -08:00
@@ -20,6 +20,7 @@
 
 config PM_DEBUG
 	bool "Power Management Debug Support"
+	depends on PM
 	---help---
 	This option enables verbose debugging support in the Power Management
 	code. This is helpful when debugging and reporting various PM bugs, 
@@ -29,18 +30,18 @@
 	bool "Software Suspend (EXPERIMENTAL)"
 	depends on EXPERIMENTAL && PM && SWAP
 	---help---
-	  Enable the possibilty of suspendig machine. It doesn't need APM.
+	  Enable the possibility of suspending the machine.
+	  It doesn't need APM.
 	  You may suspend your machine by 'swsusp' or 'shutdown -z <time>' 
 	  (patch for sysvinit needed). 
 
-	  It creates an image which is saved in your active swaps. By the next
-	  booting the, pass 'resume=/dev/swappartition' and kernel will 
-	  detect the saved image, restore the memory from
-	  it and then it continues to run as before you've suspended.
-	  If you don't want the previous state to continue use the 'noresume'
-	  kernel option. However note that your partitions will be fsck'd and
-	  you must re-mkswap your swap partitions. It does not work with swap
-	  files.
+	  It creates an image which is saved in your active swap. Upon next
+	  boot, pass the 'resume=/dev/swappartition' argument to the kernel to
+	  have it detect the saved image, restore memory state from it, and
+	  continue to run as before. If you do not want the previous state to
+	  be reloaded, then use the 'noresume' kernel argument. However, note
+	  that your partitions will be fsck'd and you must re-mkswap your swap
+	  partitions. It does not work with swap files.
 
 	  Right now you may boot without resuming and then later resume but
 	  in meantime you cannot use those swap partitions/files which were
diff -Nru a/kernel/power/disk.c b/kernel/power/disk.c
--- a/kernel/power/disk.c	2004-12-24 13:36:17 -08:00
+++ b/kernel/power/disk.c	2004-12-24 13:36:17 -08:00
@@ -3,6 +3,7 @@
  *
  * Copyright (c) 2003 Patrick Mochel
  * Copyright (c) 2003 Open Source Development Lab
+ * Copyright (c) 2004 Pavel Machek <pavel@suse.cz>
  *
  * This file is released under the GPLv2.
  *
@@ -15,10 +16,11 @@
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/fs.h>
+#include <linux/device.h>
 #include "power.h"
 
 
-extern u32 pm_disk_mode;
+extern suspend_disk_method_t pm_disk_mode;
 extern struct pm_ops * pm_ops;
 
 extern int swsusp_suspend(void);
@@ -41,7 +43,7 @@
  *	there ain't no turning back.
  */
 
-static int power_down(u32 mode)
+static void power_down(suspend_disk_method_t mode)
 {
 	unsigned long flags;
 	int error = 0;
@@ -67,7 +69,6 @@
 	   after resume. */
 	printk(KERN_CRIT "Please power me down manually\n");
 	while(1);
-	return 0;
 }
 
 
@@ -85,10 +86,20 @@
 
 static void free_some_memory(void)
 {
-	printk("Freeing memory: ");
-	while (shrink_all_memory(10000))
-		printk(".");
-	printk("|\n");
+	unsigned int i = 0;
+	unsigned int tmp;
+	unsigned long pages = 0;
+	char *p = "-\\|/";
+
+	printk("Freeing memory...  ");
+	while ((tmp = shrink_all_memory(10000))) {
+		pages += tmp;
+		printk("\b%c", p[i]);
+		i++;
+		if (i > 3)
+			i = 0;
+	}
+	printk("\bdone (%li pages freed)\n", pages);
 }
 
 
@@ -152,7 +163,7 @@
  *
  *	If we're going through the firmware, then get it over with quickly.
  *
- *	If not, then call pmdis to do it's thing, then figure out how
+ *	If not, then call swsusp to do it's thing, then figure out how
  *	to power down the system.
  */
 
@@ -174,18 +185,9 @@
 
 	if (in_suspend) {
 		pr_debug("PM: writing image.\n");
-
-		/*
-		 * FIXME: Leftover from swsusp. Are they necessary?
-		 */
-		mb();
-		barrier();
-
 		error = swsusp_write();
-		if (!error) {
-			error = power_down(pm_disk_mode);
-			pr_debug("PM: Power down failed.\n");
-		}
+		if (!error)
+			power_down(pm_disk_mode);
 	} else
 		pr_debug("PM: Image restored successfully.\n");
 	swsusp_free();
@@ -292,7 +294,7 @@
 	int i;
 	int len;
 	char *p;
-	u32 mode = 0;
+	suspend_disk_method_t mode = 0;
 
 	p = memchr(buf, '\n', n);
 	len = p ? p - buf : n;
diff -Nru a/kernel/power/main.c b/kernel/power/main.c
--- a/kernel/power/main.c	2004-12-24 13:36:31 -08:00
+++ b/kernel/power/main.c	2004-12-24 13:36:31 -08:00
@@ -4,7 +4,7 @@
  * Copyright (c) 2003 Patrick Mochel
  * Copyright (c) 2003 Open Source Development Lab
  * 
- * This file is release under the GPLv2
+ * This file is released under the GPLv2
  *
  */
 
@@ -22,7 +22,7 @@
 DECLARE_MUTEX(pm_sem);
 
 struct pm_ops * pm_ops = NULL;
-u32 pm_disk_mode = PM_DISK_SHUTDOWN;
+suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
 
 /**
  *	pm_set_ops - Set the global power method table. 
@@ -46,7 +46,7 @@
  *	the platform can enter the requested state.
  */
 
-static int suspend_prepare(u32 state)
+static int suspend_prepare(suspend_state_t state)
 {
 	int error = 0;
 
@@ -102,7 +102,7 @@
  *	console that we've allocated.
  */
 
-static void suspend_finish(u32 state)
+static void suspend_finish(suspend_state_t state)
 {
 	device_resume();
 	if (pm_ops && pm_ops->finish)
@@ -133,7 +133,7 @@
  *	we've woken up).
  */
 
-static int enter_state(u32 state)
+static int enter_state(suspend_state_t state)
 {
 	int error;
 
@@ -183,7 +183,7 @@
  *	structure, and enter (above).
  */
 
-int pm_suspend(u32 state)
+int pm_suspend(suspend_state_t state)
 {
 	if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX)
 		return enter_state(state);
@@ -221,7 +221,7 @@
 
 static ssize_t state_store(struct subsystem * subsys, const char * buf, size_t n)
 {
-	u32 state = PM_SUSPEND_STANDBY;
+	suspend_state_t state = PM_SUSPEND_STANDBY;
 	char ** s;
 	char *p;
 	int error;
diff -Nru a/kernel/power/pm.c b/kernel/power/pm.c
--- a/kernel/power/pm.c	2004-12-24 13:36:19 -08:00
+++ b/kernel/power/pm.c	2004-12-24 13:36:19 -08:00
@@ -256,41 +256,10 @@
 	return 0;
 }
 
-/**
- *	pm_find  - find a device
- *	@type: type of device
- *	@from: where to start looking
- *
- *	Scan the power management list for devices of a specific type. The
- *	return value for a matching device may be passed to further calls
- *	to this function to find further matches. A %NULL indicates the end
- *	of the list. 
- *
- *	To search from the beginning pass %NULL as the @from value.
- *
- *	The caller MUST hold the pm_devs_lock lock when calling this 
- *	function. The instant that the lock is dropped all pointers returned
- *	may become invalid.
- */
- 
-struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
-{
-	struct list_head *entry = from ? from->entry.next:pm_devs.next;
-	while (entry != &pm_devs) {
-		struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
-		if (type == PM_UNKNOWN_DEV || dev->type == type)
-			return dev;
-		entry = entry->next;
-	}
-	return NULL;
-}
-
 EXPORT_SYMBOL(pm_register);
 EXPORT_SYMBOL(pm_unregister);
 EXPORT_SYMBOL(pm_unregister_all);
-EXPORT_SYMBOL(pm_send);
 EXPORT_SYMBOL(pm_send_all);
-EXPORT_SYMBOL(pm_find);
 EXPORT_SYMBOL(pm_active);
 
 
diff -Nru a/kernel/power/poweroff.c b/kernel/power/poweroff.c
--- a/kernel/power/poweroff.c	2004-12-24 13:36:49 -08:00
+++ b/kernel/power/poweroff.c	2004-12-24 13:36:49 -08:00
@@ -32,7 +32,7 @@
 static struct sysrq_key_op	sysrq_poweroff_op = {
 	.handler        = handle_poweroff,
 	.help_msg       = "powerOff",
-	.action_msg     = "Power Off\n"
+	.action_msg     = "Power Off"
 };
 
 static int pm_sysrq_init(void)
diff -Nru a/kernel/power/process.c b/kernel/power/process.c
--- a/kernel/power/process.c	2004-12-24 13:36:17 -08:00
+++ b/kernel/power/process.c	2004-12-24 13:36:17 -08:00
@@ -23,8 +23,8 @@
 {
 	if ((p == current) || 
 	    (p->flags & PF_NOFREEZE) ||
-	    (p->state == TASK_ZOMBIE) ||
-	    (p->state == TASK_DEAD) ||
+	    (p->exit_state == EXIT_ZOMBIE) ||
+	    (p->exit_state == EXIT_DEAD) ||
 	    (p->state == TASK_STOPPED) ||
 	    (p->state == TASK_TRACED))
 		return 0;
diff -Nru a/kernel/power/swsusp.c b/kernel/power/swsusp.c
--- a/kernel/power/swsusp.c	2004-12-24 13:36:31 -08:00
+++ b/kernel/power/swsusp.c	2004-12-24 13:36:31 -08:00
@@ -294,15 +294,19 @@
 {
 	int error = 0;
 	int i;
+	unsigned int mod = nr_copy_pages / 100;
 
-	printk( "Writing data to swap (%d pages): ", nr_copy_pages );
+	if (!mod)
+		mod = 1;
+
+	printk( "Writing data to swap (%d pages)...     ", nr_copy_pages );
 	for (i = 0; i < nr_copy_pages && !error; i++) {
-		if (!(i%100))
-			printk( "." );
+		if (!(i%mod))
+			printk( "\b\b\b\b%3d%%", i / mod );
 		error = write_page((pagedir_nosave+i)->address,
 					  &((pagedir_nosave+i)->swap_address));
 	}
-	printk(" %d Pages done.\n",i);
+	printk("\b\b\b\bdone\n");
 	return error;
 }
 
@@ -782,12 +786,13 @@
 
 int suspend_prepare_image(void)
 {
-	unsigned int nr_needed_pages = 0;
+	unsigned int nr_needed_pages;
 	int error;
 
 	pr_debug("swsusp: critical section: \n");
 	if (save_highmem()) {
 		printk(KERN_CRIT "Suspend machine: Not enough free pages for highmem\n");
+		restore_highmem();
 		return -ENOMEM;
 	}
 
@@ -843,8 +848,11 @@
 {
 	int error = 0;
 
-	if ((error = swsusp_swap_check()))
+	if ((error = swsusp_swap_check())) {
+		printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try "
+				"swapon -a!\n");
 		return error;
+	}
 	return suspend_prepare_image();
 }
 
@@ -978,6 +986,8 @@
 		c = *c;
 		free_pages((unsigned long)f, pagedir_order);
 	}
+	if (ret)
+		return ret;
 	printk("|\n");
 	return check_pagedir();
 }
@@ -1121,7 +1131,7 @@
 		 */
 		error = bio_write_page(0, &swsusp_header);
 	} else { 
-		pr_debug(KERN_ERR "swsusp: Invalid partition type.\n");
+		pr_debug(KERN_ERR "swsusp: Suspend partition has wrong signature?\n");
 		return -EINVAL;
 	}
 	if (!error)
@@ -1141,14 +1151,18 @@
 	struct pbe * p;
 	int error;
 	int i;
+	int mod = nr_copy_pages / 100;
+
+	if (!mod)
+		mod = 1;
 
 	if ((error = swsusp_pagedir_relocate()))
 		return error;
 
-	printk( "Reading image data (%d pages): ", nr_copy_pages );
+	printk( "Reading image data (%d pages):     ", nr_copy_pages );
 	for(i = 0, p = pagedir_nosave; i < nr_copy_pages && !error; i++, p++) {
-		if (!(i%100))
-			printk( "." );
+		if (!(i%mod))
+			printk( "\b\b\b\b%3d%%", i / mod );
 		error = bio_read_page(swp_offset(p->swap_address),
 				  (void *)p->address);
 	}
diff -Nru a/kernel/printk.c b/kernel/printk.c
--- a/kernel/printk.c	2004-12-24 13:37:31 -08:00
+++ b/kernel/printk.c	2004-12-24 13:37:31 -08:00
@@ -30,6 +30,7 @@
 #include <linux/smp.h>
 #include <linux/security.h>
 #include <linux/bootmem.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 
@@ -108,6 +109,7 @@
 #define MAX_CMDLINECONSOLES 8
 
 static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
+static int selected_console = -1;
 static int preferred_console = -1;
 
 /* Flag: console code may call schedule() */
@@ -140,7 +142,7 @@
 		strcpy(name, "ttyS1");
 #endif
 	for(s = name; *s; s++)
-		if (*s >= '0' && *s <= '9')
+		if ((*s >= '0' && *s <= '9') || *s == ',')
 			break;
 	idx = simple_strtoul(s, NULL, 10);
 	*s = 0;
@@ -173,12 +175,12 @@
 	for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
 		if (strcmp(console_cmdline[i].name, name) == 0 &&
 			  console_cmdline[i].index == idx) {
-				preferred_console = i;
+				selected_console = i;
 				return 0;
 		}
 	if (i == MAX_CMDLINECONSOLES)
 		return -E2BIG;
-	preferred_console = i;
+	selected_console = i;
 	c = &console_cmdline[i];
 	memcpy(c->name, name, sizeof(c->name));
 	c->name[sizeof(c->name) - 1] = 0;
@@ -660,12 +662,10 @@
  *
  * Must be called within acquire_console_sem().
  */
-void console_conditional_schedule(void)
+void __sched console_conditional_schedule(void)
 {
-	if (console_may_schedule && need_resched()) {
-		set_current_state(TASK_RUNNING);
-		schedule();
-	}
+	if (console_may_schedule)
+		cond_resched();
 }
 EXPORT_SYMBOL(console_conditional_schedule);
 
@@ -747,6 +747,9 @@
 	int     i;
 	unsigned long flags;
 
+	if (preferred_console < 0)
+		preferred_console = selected_console;
+
 	/*
 	 *	See if we want to use this console driver. If we
 	 *	didn't select a console we take the first one
@@ -837,7 +840,7 @@
 	 * would prevent fbcon from taking over.
 	 */
 	if (console_drivers == NULL)
-		preferred_console = -1;
+		preferred_console = selected_console;
 		
 
 	release_console_sem();
@@ -855,7 +858,7 @@
 void tty_write_message(struct tty_struct *tty, char *msg)
 {
 	if (tty && tty->driver->write)
-		tty->driver->write(tty, 0, msg, strlen(msg));
+		tty->driver->write(tty, msg, strlen(msg));
 	return;
 }
 
diff -Nru a/kernel/profile.c b/kernel/profile.c
--- a/kernel/profile.c	2004-12-24 13:37:29 -08:00
+++ b/kernel/profile.c	2004-12-24 13:37:29 -08:00
@@ -1,5 +1,16 @@
 /*
  *  linux/kernel/profile.c
+ *  Simple profiling. Manages a direct-mapped profile hit count buffer,
+ *  with configurable resolution, support for restricting the cpus on
+ *  which profiling is done, and switching between cpu time and
+ *  schedule() calls via kernel command line parameters passed at boot.
+ *
+ *  Scheduler profiling support, Arjan van de Ven and Ingo Molnar,
+ *	Red Hat, July 2004
+ *  Consolidation of architecture support code for profiling,
+ *	William Irwin, Oracle, July 2004
+ *  Amortized hit count accounting via per-cpu open-addressed hashtables
+ *	to resolve timer interrupt livelocks, William Irwin, Oracle, 2004
  */
 
 #include <linux/config.h>
@@ -9,27 +20,46 @@
 #include <linux/notifier.h>
 #include <linux/mm.h>
 #include <linux/cpumask.h>
+#include <linux/cpu.h>
 #include <linux/profile.h>
+#include <linux/highmem.h>
 #include <asm/sections.h>
+#include <asm/semaphore.h>
+
+struct profile_hit {
+	u32 pc, hits;
+};
+#define PROFILE_GRPSHIFT	3
+#define PROFILE_GRPSZ		(1 << PROFILE_GRPSHIFT)
+#define NR_PROFILE_HIT		(PAGE_SIZE/sizeof(struct profile_hit))
+#define NR_PROFILE_GRP		(NR_PROFILE_HIT/PROFILE_GRPSZ)
+
+/* Oprofile timer tick hook */
+int (*timer_hook)(struct pt_regs *);
 
 static atomic_t *prof_buffer;
 static unsigned long prof_len, prof_shift;
 static int prof_on;
 static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
+#ifdef CONFIG_SMP
+static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
+static DEFINE_PER_CPU(int, cpu_profile_flip);
+static DECLARE_MUTEX(profile_flip_mutex);
+#endif /* CONFIG_SMP */
 
 static int __init profile_setup(char * str)
 {
 	int par;
 
 	if (!strncmp(str, "schedule", 8)) {
-		prof_on = 2;
+		prof_on = SCHED_PROFILING;
 		printk(KERN_INFO "kernel schedule profiling enabled\n");
 		if (str[7] == ',')
 			str += 8;
 	}
 	if (get_option(&str,&par)) {
 		prof_shift = par;
-		prof_on = 1;
+		prof_on = CPU_PROFILING;
 		printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n",
 			prof_shift);
 	}
@@ -141,38 +171,24 @@
 	return err;
 }
 
-static struct notifier_block * profile_listeners;
-static rwlock_t profile_lock = RW_LOCK_UNLOCKED;
- 
-int register_profile_notifier(struct notifier_block * nb)
-{
-	int err;
-	write_lock_irq(&profile_lock);
-	err = notifier_chain_register(&profile_listeners, nb);
-	write_unlock_irq(&profile_lock);
-	return err;
-}
-
-
-int unregister_profile_notifier(struct notifier_block * nb)
+int register_timer_hook(int (*hook)(struct pt_regs *))
 {
-	int err;
-	write_lock_irq(&profile_lock);
-	err = notifier_chain_unregister(&profile_listeners, nb);
-	write_unlock_irq(&profile_lock);
-	return err;
+	if (timer_hook)
+		return -EBUSY;
+	timer_hook = hook;
+	return 0;
 }
 
-
-void profile_hook(struct pt_regs * regs)
+void unregister_timer_hook(int (*hook)(struct pt_regs *))
 {
-	read_lock(&profile_lock);
-	notifier_call_chain(&profile_listeners, 0, regs);
-	read_unlock(&profile_lock);
+	WARN_ON(hook != timer_hook);
+	timer_hook = NULL;
+	/* make sure all CPUs see the NULL hook */
+	synchronize_kernel();
 }
 
-EXPORT_SYMBOL_GPL(register_profile_notifier);
-EXPORT_SYMBOL_GPL(unregister_profile_notifier);
+EXPORT_SYMBOL_GPL(register_timer_hook);
+EXPORT_SYMBOL_GPL(unregister_timer_hook);
 EXPORT_SYMBOL_GPL(task_handoff_register);
 EXPORT_SYMBOL_GPL(task_handoff_unregister);
 
@@ -181,6 +197,179 @@
 EXPORT_SYMBOL_GPL(profile_event_register);
 EXPORT_SYMBOL_GPL(profile_event_unregister);
 
+#ifdef CONFIG_SMP
+/*
+ * Each cpu has a pair of open-addressed hashtables for pending
+ * profile hits. read_profile() IPI's all cpus to request them
+ * to flip buffers and flushes their contents to prof_buffer itself.
+ * Flip requests are serialized by the profile_flip_mutex. The sole
+ * use of having a second hashtable is for avoiding cacheline
+ * contention that would otherwise happen during flushes of pending
+ * profile hits required for the accuracy of reported profile hits
+ * and so resurrect the interrupt livelock issue.
+ *
+ * The open-addressed hashtables are indexed by profile buffer slot
+ * and hold the number of pending hits to that profile buffer slot on
+ * a cpu in an entry. When the hashtable overflows, all pending hits
+ * are accounted to their corresponding profile buffer slots with
+ * atomic_add() and the hashtable emptied. As numerous pending hits
+ * may be accounted to a profile buffer slot in a hashtable entry,
+ * this amortizes a number of atomic profile buffer increments likely
+ * to be far larger than the number of entries in the hashtable,
+ * particularly given that the number of distinct profile buffer
+ * positions to which hits are accounted during short intervals (e.g.
+ * several seconds) is usually very small. Exclusion from buffer
+ * flipping is provided by interrupt disablement (note that for
+ * SCHED_PROFILING profile_hit() may be called from process context).
+ * The hash function is meant to be lightweight as opposed to strong,
+ * and was vaguely inspired by ppc64 firmware-supported inverted
+ * pagetable hash functions, but uses a full hashtable full of finite
+ * collision chains, not just pairs of them.
+ *
+ * -- wli
+ */
+static void __profile_flip_buffers(void *unused)
+{
+	int cpu = smp_processor_id();
+
+	per_cpu(cpu_profile_flip, cpu) = !per_cpu(cpu_profile_flip, cpu);
+}
+
+static void profile_flip_buffers(void)
+{
+	int i, j, cpu;
+
+	down(&profile_flip_mutex);
+	j = per_cpu(cpu_profile_flip, get_cpu());
+	put_cpu();
+	on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
+	for_each_online_cpu(cpu) {
+		struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[j];
+		for (i = 0; i < NR_PROFILE_HIT; ++i) {
+			if (!hits[i].hits) {
+				if (hits[i].pc)
+					hits[i].pc = 0;
+				continue;
+			}
+			atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
+			hits[i].hits = hits[i].pc = 0;
+		}
+	}
+	up(&profile_flip_mutex);
+}
+
+static void profile_discard_flip_buffers(void)
+{
+	int i, cpu;
+
+	down(&profile_flip_mutex);
+	i = per_cpu(cpu_profile_flip, get_cpu());
+	put_cpu();
+	on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
+	for_each_online_cpu(cpu) {
+		struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i];
+		memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit));
+	}
+	up(&profile_flip_mutex);
+}
+
+void profile_hit(int type, void *__pc)
+{
+	unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
+	int i, j, cpu;
+	struct profile_hit *hits;
+
+	if (prof_on != type || !prof_buffer)
+		return;
+	pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
+	i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
+	secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
+	cpu = get_cpu();
+	hits = per_cpu(cpu_profile_hits, cpu)[per_cpu(cpu_profile_flip, cpu)];
+	if (!hits) {
+		put_cpu();
+		return;
+	}
+	local_irq_save(flags);
+	do {
+		for (j = 0; j < PROFILE_GRPSZ; ++j) {
+			if (hits[i + j].pc == pc) {
+				hits[i + j].hits++;
+				goto out;
+			} else if (!hits[i + j].hits) {
+				hits[i + j].pc = pc;
+				hits[i + j].hits = 1;
+				goto out;
+			}
+		}
+		i = (i + secondary) & (NR_PROFILE_HIT - 1);
+	} while (i != primary);
+	atomic_inc(&prof_buffer[pc]);
+	for (i = 0; i < NR_PROFILE_HIT; ++i) {
+		atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
+		hits[i].pc = hits[i].hits = 0;
+	}
+out:
+	local_irq_restore(flags);
+	put_cpu();
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+static int __devinit profile_cpu_callback(struct notifier_block *info,
+					unsigned long action, void *__cpu)
+{
+	int node, cpu = (unsigned long)__cpu;
+	struct page *page;
+
+	switch (action) {
+	case CPU_UP_PREPARE:
+		node = cpu_to_node(cpu);
+		per_cpu(cpu_profile_flip, cpu) = 0;
+		if (!per_cpu(cpu_profile_hits, cpu)[1]) {
+			page = alloc_pages_node(node, GFP_KERNEL, 0);
+			if (!page)
+				return NOTIFY_BAD;
+			clear_highpage(page);
+			per_cpu(cpu_profile_hits, cpu)[1] = page_address(page);
+		}
+		if (!per_cpu(cpu_profile_hits, cpu)[0]) {
+			page = alloc_pages_node(node, GFP_KERNEL, 0);
+			if (!page)
+				goto out_free;
+			clear_highpage(page);
+			per_cpu(cpu_profile_hits, cpu)[0] = page_address(page);
+		}
+		break;
+	out_free:
+		page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
+		per_cpu(cpu_profile_hits, cpu)[1] = NULL;
+		__free_page(page);
+		return NOTIFY_BAD;
+	case CPU_ONLINE:
+		cpu_set(cpu, prof_cpu_mask);
+		break;
+	case CPU_UP_CANCELED:
+	case CPU_DEAD:
+		cpu_clear(cpu, prof_cpu_mask);
+		if (per_cpu(cpu_profile_hits, cpu)[0]) {
+			page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[0]);
+			per_cpu(cpu_profile_hits, cpu)[0] = NULL;
+			__free_page(page);
+		}
+		if (per_cpu(cpu_profile_hits, cpu)[1]) {
+			page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
+			per_cpu(cpu_profile_hits, cpu)[1] = NULL;
+			__free_page(page);
+		}
+		break;
+	}
+	return NOTIFY_OK;
+}
+#endif /* CONFIG_HOTPLUG_CPU */
+#else /* !CONFIG_SMP */
+#define profile_flip_buffers()		do { } while (0)
+#define profile_discard_flip_buffers()	do { } while (0)
+
 void profile_hit(int type, void *__pc)
 {
 	unsigned long pc;
@@ -190,11 +379,12 @@
 	pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
 	atomic_inc(&prof_buffer[min(pc, prof_len - 1)]);
 }
+#endif /* !CONFIG_SMP */
 
 void profile_tick(int type, struct pt_regs *regs)
 {
-	if (type == CPU_PROFILING)
-		profile_hook(regs);
+	if (type == CPU_PROFILING && timer_hook)
+		timer_hook(regs);
 	if (!user_mode(regs) && cpu_isset(smp_processor_id(), prof_cpu_mask))
 		profile_hit(type, (void *)profile_pc(regs));
 }
@@ -256,6 +446,7 @@
 	char * pnt;
 	unsigned int sample_step = 1 << prof_shift;
 
+	profile_flip_buffers();
 	if (p >= (prof_len+1)*sizeof(unsigned int))
 		return 0;
 	if (count > (prof_len+1)*sizeof(unsigned int) - p)
@@ -296,7 +487,7 @@
 			return -EINVAL;
 	}
 #endif
-
+	profile_discard_flip_buffers();
 	memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
 	return count;
 }
@@ -306,16 +497,70 @@
 	.write		= write_profile,
 };
 
+#ifdef CONFIG_SMP
+static void __init profile_nop(void *unused)
+{
+}
+
+static int __init create_hash_tables(void)
+{
+	int cpu;
+
+	for_each_online_cpu(cpu) {
+		int node = cpu_to_node(cpu);
+		struct page *page;
+
+		page = alloc_pages_node(node, GFP_KERNEL, 0);
+		if (!page)
+			goto out_cleanup;
+		clear_highpage(page);
+		per_cpu(cpu_profile_hits, cpu)[1]
+				= (struct profile_hit *)page_address(page);
+		page = alloc_pages_node(node, GFP_KERNEL, 0);
+		if (!page)
+			goto out_cleanup;
+		clear_highpage(page);
+		per_cpu(cpu_profile_hits, cpu)[0]
+				= (struct profile_hit *)page_address(page);
+	}
+	return 0;
+out_cleanup:
+	prof_on = 0;
+	mb();
+	on_each_cpu(profile_nop, NULL, 0, 1);
+	for_each_online_cpu(cpu) {
+		struct page *page;
+
+		if (per_cpu(cpu_profile_hits, cpu)[0]) {
+			page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[0]);
+			per_cpu(cpu_profile_hits, cpu)[0] = NULL;
+			__free_page(page);
+		}
+		if (per_cpu(cpu_profile_hits, cpu)[1]) {
+			page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
+			per_cpu(cpu_profile_hits, cpu)[1] = NULL;
+			__free_page(page);
+		}
+	}
+	return -1;
+}
+#else
+#define create_hash_tables()			({ 0; })
+#endif
+
 static int __init create_proc_profile(void)
 {
 	struct proc_dir_entry *entry;
 
 	if (!prof_on)
 		return 0;
+	if (create_hash_tables())
+		return -1;
 	if (!(entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL)))
 		return 0;
 	entry->proc_fops = &proc_profile_operations;
 	entry->size = (1+prof_len) * sizeof(atomic_t);
+	hotcpu_notifier(profile_cpu_callback, 0);
 	return 0;
 }
 module_init(create_proc_profile);
diff -Nru a/kernel/ptrace.c b/kernel/ptrace.c
--- a/kernel/ptrace.c	2004-12-24 13:37:33 -08:00
+++ b/kernel/ptrace.c	2004-12-24 13:37:33 -08:00
@@ -38,6 +38,12 @@
 	SET_LINKS(child);
 }
  
+static inline int pending_resume_signal(struct sigpending *pending)
+{
+#define M(sig) (1UL << ((sig)-1))
+	return sigtestsetmask(&pending->signal, M(SIGCONT) | M(SIGKILL));
+}
+
 /*
  * unptrace a task: move it back to its original parent and
  * remove it from the ptrace list.
@@ -61,8 +67,16 @@
 		 * Turn a tracing stop into a normal stop now,
 		 * since with no tracer there would be no way
 		 * to wake it up with SIGCONT or SIGKILL.
+		 * If there was a signal sent that would resume the child,
+		 * but didn't because it was in TASK_TRACED, resume it now.
 		 */
+		spin_lock(&child->sighand->siglock);
 		child->state = TASK_STOPPED;
+		if (pending_resume_signal(&child->pending) ||
+		    pending_resume_signal(&child->signal->shared_pending)) {
+			signal_wake_up(child, 1);
+		}
+		spin_unlock(&child->sighand->siglock);
 	}
 }
 
@@ -82,7 +96,8 @@
 	 */
 	read_lock(&tasklist_lock);
 	if ((child->ptrace & PT_PTRACED) && child->parent == current &&
-	    child->signal != NULL) {
+	    (!(child->ptrace & PT_ATTACHED) || child->real_parent != current)
+	    && child->signal != NULL) {
 		ret = 0;
 		spin_lock_irq(&child->sighand->siglock);
 		if (child->state == TASK_STOPPED) {
@@ -131,7 +146,8 @@
 		goto bad;
 
 	/* Go */
-	task->ptrace |= PT_PTRACED;
+	task->ptrace |= PT_PTRACED | ((task->real_parent != current)
+				      ? PT_ATTACHED : 0);
 	if (capable(CAP_SYS_PTRACE))
 		task->ptrace |= PT_PTRACE_CAP;
 	task_unlock(task);
@@ -162,7 +178,7 @@
 	write_lock_irq(&tasklist_lock);
 	__ptrace_unlink(child);
 	/* .. and wake it up. */
-	if (child->state != TASK_ZOMBIE)
+	if (child->exit_state != EXIT_ZOMBIE)
 		wake_up_process(child);
 	write_unlock_irq(&tasklist_lock);
 
diff -Nru a/kernel/rcupdate.c b/kernel/rcupdate.c
--- a/kernel/rcupdate.c	2004-12-24 13:36:17 -08:00
+++ b/kernel/rcupdate.c	2004-12-24 13:36:17 -08:00
@@ -38,7 +38,7 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <asm/atomic.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/completion.h>
 #include <linux/moduleparam.h>
diff -Nru a/kernel/resource.c b/kernel/resource.c
--- a/kernel/resource.c	2004-12-24 13:37:01 -08:00
+++ b/kernel/resource.c	2004-12-24 13:37:01 -08:00
@@ -57,6 +57,7 @@
 }
 
 static void *r_start(struct seq_file *m, loff_t *pos)
+	__acquires(resource_lock)
 {
 	struct resource *p = m->private;
 	loff_t l = 0;
@@ -67,6 +68,7 @@
 }
 
 static void r_stop(struct seq_file *m, void *v)
+	__releases(resource_lock)
 {
 	read_unlock(&resource_lock);
 }
diff -Nru a/kernel/sched.c b/kernel/sched.c
--- a/kernel/sched.c	2004-12-24 13:37:18 -08:00
+++ b/kernel/sched.c	2004-12-24 13:37:18 -08:00
@@ -42,6 +42,7 @@
 #include <linux/percpu.h>
 #include <linux/kthread.h>
 #include <linux/seq_file.h>
+#include <linux/syscalls.h>
 #include <linux/times.h>
 #include <asm/tlb.h>
 
@@ -183,16 +184,6 @@
 #define task_hot(p, now, sd) ((long long) ((now) - (p)->last_ran)	\
 				< (long long) (sd)->cache_hot_time)
 
-enum idle_type
-{
-	IDLE,
-	NOT_IDLE,
-	NEWLY_IDLE,
-	MAX_IDLE_TYPES
-};
-
-struct sched_domain;
-
 /*
  * These are the runqueue data structures:
  */
@@ -226,7 +217,16 @@
 	unsigned long cpu_load;
 #endif
 	unsigned long long nr_switches;
-	unsigned long expired_timestamp, nr_uninterruptible;
+
+	/*
+	 * This is part of a global counter where only the total sum
+	 * over all CPUs matters. A task can increase this counter on
+	 * one CPU and if it got migrated afterwards it may decrease
+	 * it on another CPU. Always updated under the runqueue lock:
+	 */
+	unsigned long nr_uninterruptible;
+
+	unsigned long expired_timestamp;
 	unsigned long long timestamp_last_tick;
 	task_t *curr, *idle;
 	struct mm_struct *prev_mm;
@@ -290,140 +290,6 @@
 
 static DEFINE_PER_CPU(struct runqueue, runqueues);
 
-/*
- * sched-domains (multiprocessor balancing) declarations:
- */
-#ifdef CONFIG_SMP
-#define SCHED_LOAD_SCALE	128UL	/* increase resolution of load */
-
-#define SD_BALANCE_NEWIDLE	1	/* Balance when about to become idle */
-#define SD_BALANCE_EXEC		2	/* Balance on exec */
-#define SD_WAKE_IDLE		4	/* Wake to idle CPU on task wakeup */
-#define SD_WAKE_AFFINE		8	/* Wake task to waking CPU */
-#define SD_WAKE_BALANCE		16	/* Perform balancing at task wakeup */
-#define SD_SHARE_CPUPOWER	32	/* Domain members share cpu power */
-
-struct sched_group {
-	struct sched_group *next;	/* Must be a circular list */
-	cpumask_t cpumask;
-
-	/*
-	 * CPU power of this group, SCHED_LOAD_SCALE being max power for a
-	 * single CPU. This should be read only (except for setup). Although
-	 * it will need to be written to at cpu hot(un)plug time, perhaps the
-	 * cpucontrol semaphore will provide enough exclusion?
-	 */
-	unsigned long cpu_power;
-};
-
-struct sched_domain {
-	/* These fields must be setup */
-	struct sched_domain *parent;	/* top domain must be null terminated */
-	struct sched_group *groups;	/* the balancing groups of the domain */
-	cpumask_t span;			/* span of all CPUs in this domain */
-	unsigned long min_interval;	/* Minimum balance interval ms */
-	unsigned long max_interval;	/* Maximum balance interval ms */
-	unsigned int busy_factor;	/* less balancing by factor if busy */
-	unsigned int imbalance_pct;	/* No balance until over watermark */
-	unsigned long long cache_hot_time; /* Task considered cache hot (ns) */
-	unsigned int cache_nice_tries;	/* Leave cache hot tasks for # tries */
-	unsigned int per_cpu_gain;	/* CPU % gained by adding domain cpus */
-	int flags;			/* See SD_* */
-
-	/* Runtime fields. */
-	unsigned long last_balance;	/* init to jiffies. units in jiffies */
-	unsigned int balance_interval;	/* initialise to 1. units in ms. */
-	unsigned int nr_balance_failed; /* initialise to 0 */
-
-#ifdef CONFIG_SCHEDSTATS
-	/* load_balance() stats */
-	unsigned long lb_cnt[MAX_IDLE_TYPES];
-	unsigned long lb_failed[MAX_IDLE_TYPES];
-	unsigned long lb_imbalance[MAX_IDLE_TYPES];
-	unsigned long lb_nobusyg[MAX_IDLE_TYPES];
-	unsigned long lb_nobusyq[MAX_IDLE_TYPES];
-
-	/* sched_balance_exec() stats */
-	unsigned long sbe_attempts;
-	unsigned long sbe_pushed;
-
-	/* try_to_wake_up() stats */
-	unsigned long ttwu_wake_affine;
-	unsigned long ttwu_wake_balance;
-#endif
-};
-
-#ifndef ARCH_HAS_SCHED_TUNE
-#ifdef CONFIG_SCHED_SMT
-#define ARCH_HAS_SCHED_WAKE_IDLE
-/* Common values for SMT siblings */
-#define SD_SIBLING_INIT (struct sched_domain) {		\
-	.span			= CPU_MASK_NONE,	\
-	.parent			= NULL,			\
-	.groups			= NULL,			\
-	.min_interval		= 1,			\
-	.max_interval		= 2,			\
-	.busy_factor		= 8,			\
-	.imbalance_pct		= 110,			\
-	.cache_hot_time		= 0,			\
-	.cache_nice_tries	= 0,			\
-	.per_cpu_gain		= 25,			\
-	.flags			= SD_BALANCE_NEWIDLE	\
-				| SD_BALANCE_EXEC	\
-				| SD_WAKE_AFFINE	\
-				| SD_WAKE_IDLE		\
-				| SD_SHARE_CPUPOWER,	\
-	.last_balance		= jiffies,		\
-	.balance_interval	= 1,			\
-	.nr_balance_failed	= 0,			\
-}
-#endif
-
-/* Common values for CPUs */
-#define SD_CPU_INIT (struct sched_domain) {		\
-	.span			= CPU_MASK_NONE,	\
-	.parent			= NULL,			\
-	.groups			= NULL,			\
-	.min_interval		= 1,			\
-	.max_interval		= 4,			\
-	.busy_factor		= 64,			\
-	.imbalance_pct		= 125,			\
-	.cache_hot_time		= cache_decay_ticks*1000000 ? : (5*1000000/2),\
-	.cache_nice_tries	= 1,			\
-	.per_cpu_gain		= 100,			\
-	.flags			= SD_BALANCE_NEWIDLE	\
-				| SD_BALANCE_EXEC	\
-				| SD_WAKE_AFFINE	\
-				| SD_WAKE_BALANCE,	\
-	.last_balance		= jiffies,		\
-	.balance_interval	= 1,			\
-	.nr_balance_failed	= 0,			\
-}
-
-/* Arch can override this macro in processor.h */
-#if defined(CONFIG_NUMA) && !defined(SD_NODE_INIT)
-#define SD_NODE_INIT (struct sched_domain) {		\
-	.span			= CPU_MASK_NONE,	\
-	.parent			= NULL,			\
-	.groups			= NULL,			\
-	.min_interval		= 8,			\
-	.max_interval		= 32,			\
-	.busy_factor		= 32,			\
-	.imbalance_pct		= 125,			\
-	.cache_hot_time		= (10*1000000),		\
-	.cache_nice_tries	= 1,			\
-	.per_cpu_gain		= 100,			\
-	.flags			= SD_BALANCE_EXEC	\
-				| SD_WAKE_BALANCE,	\
-	.last_balance		= jiffies,		\
-	.balance_interval	= 1,			\
-	.nr_balance_failed	= 0,			\
-}
-#endif
-#endif /* ARCH_HAS_SCHED_TUNE */
-#endif
-
-
 #define for_each_domain(cpu, domain) \
 	for (domain = cpu_rq(cpu)->sd; domain; domain = domain->parent)
 
@@ -447,6 +313,7 @@
  * explicitly disabling preemption.
  */
 static runqueue_t *task_rq_lock(task_t *p, unsigned long *flags)
+	__acquires(rq->lock)
 {
 	struct runqueue *rq;
 
@@ -462,6 +329,7 @@
 }
 
 static inline void task_rq_unlock(runqueue_t *rq, unsigned long *flags)
+	__releases(rq->lock)
 {
 	spin_unlock_irqrestore(&rq->lock, *flags);
 }
@@ -502,7 +370,7 @@
 		    rq->smt_cnt, rq->sbe_cnt, rq->rq_sched_info.cpu_time,
 		    rq->rq_sched_info.run_delay, rq->rq_sched_info.pcnt);
 
-		for (itype = IDLE; itype < MAX_IDLE_TYPES; itype++)
+		for (itype = SCHED_IDLE; itype < MAX_IDLE_TYPES; itype++)
 			seq_printf(seq, " %lu %lu", rq->pt_gained[itype],
 						    rq->pt_lost[itype]);
 		seq_printf(seq, "\n");
@@ -514,7 +382,8 @@
 
 			cpumask_scnprintf(mask_str, NR_CPUS, sd->span);
 			seq_printf(seq, "domain%d %s", dcnt++, mask_str);
-			for (itype = IDLE; itype < MAX_IDLE_TYPES; itype++) {
+			for (itype = SCHED_IDLE; itype < MAX_IDLE_TYPES;
+						itype++) {
 				seq_printf(seq, " %lu %lu %lu %lu %lu",
 				    sd->lb_cnt[itype],
 				    sd->lb_failed[itype],
@@ -568,6 +437,7 @@
  * rq_lock - lock a given runqueue and disable interrupts.
  */
 static runqueue_t *this_rq_lock(void)
+	__acquires(rq->lock)
 {
 	runqueue_t *rq;
 
@@ -579,6 +449,7 @@
 }
 
 static inline void rq_unlock(runqueue_t *rq)
+	__releases(rq->lock)
 {
 	spin_unlock_irq(&rq->lock);
 }
@@ -900,8 +771,6 @@
 static void deactivate_task(struct task_struct *p, runqueue_t *rq)
 {
 	rq->nr_running--;
-	if (p->state == TASK_UNINTERRUPTIBLE)
-		rq->nr_uninterruptible++;
 	dequeue_task(p, p->array);
 	p->array = NULL;
 }
@@ -1037,8 +906,6 @@
 	preempt_enable();
 }
 
-EXPORT_SYMBOL_GPL(kick_process);
-
 /*
  * Return a low guess at the load of a migration-source cpu.
  *
@@ -1088,8 +955,7 @@
 	if (!(sd->flags & SD_WAKE_IDLE))
 		return cpu;
 
-	cpus_and(tmp, sd->span, cpu_online_map);
-	cpus_and(tmp, tmp, p->cpus_allowed);
+	cpus_and(tmp, sd->span, p->cpus_allowed);
 
 	for_each_cpu_mask(i, tmp) {
 		if (idle_cpu(i))
@@ -1463,6 +1329,7 @@
  * details.)
  */
 static void finish_task_switch(task_t *prev)
+	__releases(rq->lock)
 {
 	runqueue_t *rq = this_rq();
 	struct mm_struct *mm = rq->prev_mm;
@@ -1472,10 +1339,10 @@
 
 	/*
 	 * A task struct has one reference for the use as "current".
-	 * If a task dies, then it sets TASK_ZOMBIE in tsk->state and calls
-	 * schedule one last time. The schedule call will never return,
+	 * If a task dies, then it sets EXIT_ZOMBIE in tsk->exit_state and
+	 * calls schedule one last time. The schedule call will never return,
 	 * and the scheduled task must drop that reference.
-	 * The test for TASK_ZOMBIE must occur while the runqueue locks are
+	 * The test for EXIT_ZOMBIE must occur while the runqueue locks are
 	 * still held, otherwise prev could be scheduled on another cpu, die
 	 * there before we look at prev->state, and then the reference would
 	 * be dropped twice.
@@ -1494,6 +1361,7 @@
  * @prev: the thread we just switched away from.
  */
 asmlinkage void schedule_tail(task_t *prev)
+	__releases(rq->lock)
 {
 	finish_task_switch(prev);
 
@@ -1554,6 +1422,13 @@
 	for_each_cpu(i)
 		sum += cpu_rq(i)->nr_uninterruptible;
 
+	/*
+	 * Since we read the counters lockless, it might be slightly
+	 * inaccurate. Do not allow it to go below zero though:
+	 */
+	if (unlikely((long)sum < 0))
+		sum = 0;
+
 	return sum;
 }
 
@@ -1586,10 +1461,13 @@
  * you need to do so manually before calling.
  */
 static void double_rq_lock(runqueue_t *rq1, runqueue_t *rq2)
+	__acquires(rq1->lock)
+	__acquires(rq2->lock)
 {
-	if (rq1 == rq2)
+	if (rq1 == rq2) {
 		spin_lock(&rq1->lock);
-	else {
+		__acquire(rq2->lock);	/* Fake it out ;) */
+	} else {
 		if (rq1 < rq2) {
 			spin_lock(&rq1->lock);
 			spin_lock(&rq2->lock);
@@ -1607,16 +1485,23 @@
  * you need to do so manually after calling.
  */
 static void double_rq_unlock(runqueue_t *rq1, runqueue_t *rq2)
+	__releases(rq1->lock)
+	__releases(rq2->lock)
 {
 	spin_unlock(&rq1->lock);
 	if (rq1 != rq2)
 		spin_unlock(&rq2->lock);
+	else
+		__release(rq2->lock);
 }
 
 /*
  * double_lock_balance - lock the busiest runqueue, this_rq is locked already.
  */
 static void double_lock_balance(runqueue_t *this_rq, runqueue_t *busiest)
+	__releases(this_rq->lock)
+	__acquires(busiest->lock)
+	__acquires(this_rq->lock)
 {
 	if (unlikely(!spin_trylock(&busiest->lock))) {
 		if (busiest < this_rq) {
@@ -1641,8 +1526,7 @@
 	min_cpu = UINT_MAX;
 	min_load = ULONG_MAX;
 
-	cpus_and(mask, sd->span, cpu_online_map);
-	cpus_and(mask, mask, p->cpus_allowed);
+	cpus_and(mask, sd->span, p->cpus_allowed);
 
 	for_each_cpu_mask(i, mask) {
 		load = target_load(i);
@@ -1894,7 +1778,6 @@
 	max_load = this_load = total_load = total_pwr = 0;
 
 	do {
-		cpumask_t tmp;
 		unsigned long load;
 		int local_group;
 		int i, nr_cpus = 0;
@@ -1903,11 +1786,8 @@
 
 		/* Tally up the load of all CPUs in the group */
 		avg_load = 0;
-		cpus_and(tmp, group->cpumask, cpu_online_map);
-		if (unlikely(cpus_empty(tmp)))
-			goto nextgroup;
 
-		for_each_cpu_mask(i, tmp) {
+		for_each_cpu_mask(i, group->cpumask) {
 			/* Bias balancing toward cpus of our domain */
 			if (local_group)
 				load = target_load(i);
@@ -2012,7 +1892,7 @@
 
 out_balanced:
 	if (busiest && (idle == NEWLY_IDLE ||
-			(idle == IDLE && max_load > SCHED_LOAD_SCALE)) ) {
+			(idle == SCHED_IDLE && max_load > SCHED_LOAD_SCALE)) ) {
 		*imbalance = 1;
 		return busiest;
 	}
@@ -2026,13 +1906,11 @@
  */
 static runqueue_t *find_busiest_queue(struct sched_group *group)
 {
-	cpumask_t tmp;
 	unsigned long load, max_load = 0;
 	runqueue_t *busiest = NULL;
 	int i;
 
-	cpus_and(tmp, group->cpumask, cpu_online_map);
-	for_each_cpu_mask(i, tmp) {
+	for_each_cpu_mask(i, group->cpumask) {
 		load = source_load(i);
 
 		if (load > max_load) {
@@ -2123,11 +2001,19 @@
 			 */
 			sd->nr_balance_failed = sd->cache_nice_tries;
 		}
-	} else
-		sd->nr_balance_failed = 0;
 
-	/* We were unbalanced, so reset the balancing interval */
-	sd->balance_interval = sd->min_interval;
+		/*
+		 * We were unbalanced, but unsuccessful in move_tasks(),
+		 * so bump the balance_interval to lessen the lock contention.
+		 */
+		if (sd->balance_interval < sd->max_interval)
+			sd->balance_interval++;
+	} else {
+                sd->nr_balance_failed = 0;
+
+		/* We were unbalanced, so reset the balancing interval */
+		sd->balance_interval = sd->min_interval;
+	}
 
 	return nr_moved;
 
@@ -2202,75 +2088,85 @@
 	}
 }
 
+#ifdef CONFIG_SCHED_SMT
+static int cpu_and_siblings_are_idle(int cpu)
+{
+	int sib;
+	for_each_cpu_mask(sib, cpu_sibling_map[cpu]) {
+		if (idle_cpu(sib))
+			continue;
+		return 0;
+	}
+
+	return 1;
+}
+#else
+#define cpu_and_siblings_are_idle(A) idle_cpu(A)
+#endif
+
+
 /*
- * active_load_balance is run by migration threads. It pushes a running
- * task off the cpu. It can be required to correctly have at least 1 task
- * running on each physical CPU where possible, and not have a physical /
- * logical imbalance.
+ * active_load_balance is run by migration threads. It pushes running tasks
+ * off the busiest CPU onto idle CPUs. It requires at least 1 task to be
+ * running on each physical CPU where possible, and avoids physical /
+ * logical imbalances.
  *
- * Called with busiest locked.
+ * Called with busiest_rq locked.
  */
-static void active_load_balance(runqueue_t *busiest, int busiest_cpu)
+static void active_load_balance(runqueue_t *busiest_rq, int busiest_cpu)
 {
 	struct sched_domain *sd;
-	struct sched_group *group, *busy_group;
-	int i;
-
-	schedstat_inc(busiest, alb_cnt);
-	if (busiest->nr_running <= 1)
-		return;
+	struct sched_group *cpu_group;
+	cpumask_t visited_cpus;
 
-	for_each_domain(busiest_cpu, sd)
-		if (cpu_isset(busiest->push_cpu, sd->span))
-			break;
-	if (!sd)
-		return;
-
-	group = sd->groups;
-	while (!cpu_isset(busiest_cpu, group->cpumask))
-		group = group->next;
-	busy_group = group;
+	schedstat_inc(busiest_rq, alb_cnt);
+	/*
+	 * Search for suitable CPUs to push tasks to in successively higher
+	 * domains with SD_LOAD_BALANCE set.
+	 */
+	visited_cpus = CPU_MASK_NONE;
+	for_each_domain(busiest_cpu, sd) {
+		if (!(sd->flags & SD_LOAD_BALANCE) || busiest_rq->nr_running <= 1)
+			break; /* no more domains to search or no more tasks to move */
+
+		cpu_group = sd->groups;
+		do { /* sched_groups should either use list_heads or be merged into the domains structure */
+			int cpu, target_cpu = -1;
+			runqueue_t *target_rq;
+
+			for_each_cpu_mask(cpu, cpu_group->cpumask) {
+				if (cpu_isset(cpu, visited_cpus) || cpu == busiest_cpu ||
+				    !cpu_and_siblings_are_idle(cpu)) {
+					cpu_set(cpu, visited_cpus);
+					continue;
+				}
+				target_cpu = cpu;
+				break;
+			}
+			if (target_cpu == -1)
+				goto next_group; /* failed to find a suitable target cpu in this domain */
 
-	group = sd->groups;
-	do {
-		cpumask_t tmp;
-		runqueue_t *rq;
-		int push_cpu = 0;
-
-		if (group == busy_group)
-			goto next_group;
-
-		cpus_and(tmp, group->cpumask, cpu_online_map);
-		if (!cpus_weight(tmp))
-			goto next_group;
-
-		for_each_cpu_mask(i, tmp) {
-			if (!idle_cpu(i))
-				goto next_group;
-			push_cpu = i;
-		}
+			target_rq = cpu_rq(target_cpu);
 
-		rq = cpu_rq(push_cpu);
+			/*
+			 * This condition is "impossible", if it occurs we need to fix it
+			 * Reported by Bjorn Helgaas on a 128-cpu setup.
+			 */
+			BUG_ON(busiest_rq == target_rq);
 
-		/*
-		 * This condition is "impossible", but since load
-		 * balancing is inherently a bit racy and statistical,
-		 * it can trigger.. Reported by Bjorn Helgaas on a
-		 * 128-cpu setup.
-		 */
-		if (unlikely(busiest == rq))
-			goto next_group;
-		double_lock_balance(busiest, rq);
-		if (move_tasks(rq, push_cpu, busiest, 1, sd, IDLE)) {
-			schedstat_inc(busiest, alb_lost);
-			schedstat_inc(rq, alb_gained);
-		} else {
-			schedstat_inc(busiest, alb_failed);
-		}
-		spin_unlock(&rq->lock);
+			/* move a task from busiest_rq to target_rq */
+			double_lock_balance(busiest_rq, target_rq);
+			if (move_tasks(target_rq, target_cpu, busiest_rq, 1, sd, SCHED_IDLE)) {
+				schedstat_inc(busiest_rq, alb_lost);
+				schedstat_inc(target_rq, alb_gained);
+			} else {
+				schedstat_inc(busiest_rq, alb_failed);
+			}
+			spin_unlock(&target_rq->lock);
 next_group:
-		group = group->next;
-	} while (group != sd->groups);
+			cpu_group = cpu_group->next;
+		} while (cpu_group != sd->groups && busiest_rq->nr_running > 1);
+	}
 }
 
 /*
@@ -2305,9 +2201,13 @@
 	this_rq->cpu_load = (old_load + this_load) / 2;
 
 	for_each_domain(this_cpu, sd) {
-		unsigned long interval = sd->balance_interval;
+		unsigned long interval;
 
-		if (idle != IDLE)
+		if (!(sd->flags & SD_LOAD_BALANCE))
+			continue;
+
+		interval = sd->balance_interval;
+		if (idle != SCHED_IDLE)
 			interval *= sd->busy_factor;
 
 		/* scale ms to jiffies */
@@ -2409,7 +2309,7 @@
 			cpustat->idle += sys_ticks;
 		if (wake_priority_sleeper(rq))
 			goto out;
-		rebalance_tick(cpu, rq, IDLE);
+		rebalance_tick(cpu, rq, SCHED_IDLE);
 		return;
 	}
 	if (TASK_NICE(p) > 0)
@@ -2513,7 +2413,7 @@
 	 */
 	spin_unlock(&this_rq->lock);
 
-	cpus_and(sibling_map, sd->span, cpu_online_map);
+	sibling_map = sd->span;
 
 	for_each_cpu_mask(i, sibling_map)
 		spin_lock(&cpu_rq(i)->lock);
@@ -2558,7 +2458,7 @@
 	 * wake_sleeping_dependent():
 	 */
 	spin_unlock(&this_rq->lock);
-	cpus_and(sibling_map, sd->span, cpu_online_map);
+	sibling_map = sd->span;
 	for_each_cpu_mask(i, sibling_map)
 		spin_lock(&cpu_rq(i)->lock);
 	cpu_clear(this_cpu, sibling_map);
@@ -2640,16 +2540,21 @@
 	 * schedule() atomically, we ignore that path for now.
 	 * Otherwise, whine if we are scheduling when we should not be.
 	 */
-	if (likely(!(current->state & (TASK_DEAD | TASK_ZOMBIE)))) {
+	if (likely(!(current->exit_state & (EXIT_DEAD | EXIT_ZOMBIE)))) {
 		if (unlikely(in_atomic())) {
-			printk(KERN_ERR "bad: scheduling while atomic!\n");
+			printk(KERN_ERR "scheduling while atomic: "
+				"%s/0x%08x/%d\n",
+				current->comm, preempt_count(), current->pid);
 			dump_stack();
 		}
 	}
+	profile_hit(SCHED_PROFILING, __builtin_return_address(0));
 
 need_resched:
 	preempt_disable();
 	prev = current;
+	release_kernel_lock(prev);
+need_resched_nonpreemptible:
 	rq = this_rq();
 
 	/*
@@ -2661,7 +2566,6 @@
 		dump_stack();
 	}
 
-	release_kernel_lock(prev);
 	schedstat_inc(rq, sched_cnt);
 	now = sched_clock();
 	if (likely(now - prev->timestamp < NS_MAX_SLEEP_AVG))
@@ -2679,6 +2583,8 @@
 
 	spin_lock_irq(&rq->lock);
 
+	if (unlikely(current->flags & PF_DEAD))
+		current->state = EXIT_DEAD;
 	/*
 	 * if entering off of a kernel preemption go straight
 	 * to picking the next task.
@@ -2689,8 +2595,11 @@
 		if (unlikely((prev->state & TASK_INTERRUPTIBLE) &&
 				unlikely(signal_pending(prev))))
 			prev->state = TASK_RUNNING;
-		else
+		else {
+			if (prev->state == TASK_UNINTERRUPTIBLE)
+				rq->nr_uninterruptible++;
 			deactivate_task(prev, rq);
+		}
 	}
 
 	cpu = smp_processor_id();
@@ -2711,7 +2620,6 @@
 		}
 	} else {
 		if (dependent_sleeper(cpu, rq)) {
-			schedstat_inc(rq, sched_goidle);
 			next = rq->idle;
 			goto switch_tasks;
 		}
@@ -2755,6 +2663,8 @@
 	}
 	next->activated = 0;
 switch_tasks:
+	if (next == rq->idle)
+		schedstat_inc(rq, sched_goidle);
 	prefetch(next);
 	clear_tsk_need_resched(prev);
 	rcu_qsctr_inc(task_cpu(prev));
@@ -2782,7 +2692,9 @@
 	} else
 		spin_unlock_irq(&rq->lock);
 
-	reacquire_kernel_lock(current);
+	prev = current;
+	if (unlikely(reacquire_kernel_lock(prev) < 0))
+		goto need_resched_nonpreemptible;
 	preempt_enable_no_resched();
 	if (unlikely(test_thread_flag(TIF_NEED_RESCHED)))
 		goto need_resched;
@@ -3143,8 +3055,6 @@
 	return TASK_NICE(p);
 }
 
-EXPORT_SYMBOL(task_nice);
-
 /**
  * idle_cpu - is a given cpu idle currently?
  * @cpu: the processor in question.
@@ -3184,7 +3094,7 @@
 {
 	struct sched_param lp;
 	int retval = -EINVAL;
-	int oldprio;
+	int oldprio, oldpolicy = -1;
 	prio_array_t *array;
 	unsigned long flags;
 	runqueue_t *rq;
@@ -3206,24 +3116,17 @@
 
 	retval = -ESRCH;
 	if (!p)
-		goto out_unlock_tasklist;
-
-	/*
-	 * To be able to change p->policy safely, the apropriate
-	 * runqueue lock must be held.
-	 */
-	rq = task_rq_lock(p, &flags);
-
+		goto out_unlock;
+recheck:
+	/* double check policy once rq lock held */
 	if (policy < 0)
-		policy = p->policy;
+		policy = oldpolicy = p->policy;
 	else {
 		retval = -EINVAL;
 		if (policy != SCHED_FIFO && policy != SCHED_RR &&
 				policy != SCHED_NORMAL)
 			goto out_unlock;
 	}
-	profile_hit(SCHED_PROFILING, __builtin_return_address(0));
-
 	/*
 	 * Valid priorities for SCHED_FIFO and SCHED_RR are
 	 * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL is 0.
@@ -3245,7 +3148,17 @@
 	retval = security_task_setscheduler(p, policy, &lp);
 	if (retval)
 		goto out_unlock;
-
+	/*
+	 * To be able to change p->policy safely, the apropriate
+	 * runqueue lock must be held.
+	 */
+	rq = task_rq_lock(p, &flags);
+	/* recheck policy now with rq lock held */
+	if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) {
+		policy = oldpolicy = -1;
+		task_rq_unlock(rq, &flags);
+		goto recheck;
+	}
 	array = p->array;
 	if (array)
 		deactivate_task(p, task_rq(p));
@@ -3265,12 +3178,9 @@
 		} else if (TASK_PREEMPTS_CURR(p, rq))
 			resched_task(rq->curr);
 	}
-
-out_unlock:
 	task_rq_unlock(rq, &flags);
-out_unlock_tasklist:
+out_unlock:
 	read_unlock_irq(&tasklist_lock);
-
 out_nounlock:
 	return retval;
 }
@@ -3532,6 +3442,7 @@
 	 * Since we are going to call schedule() anyway, there's
 	 * no need to preempt or enable interrupts:
 	 */
+	__release(rq->lock);
 	_raw_spin_unlock(&rq->lock);
 	preempt_enable_no_resched();
 
@@ -4020,6 +3931,26 @@
 	__migrate_task(tsk, dead_cpu, dest_cpu);
 }
 
+/*
+ * While a dead CPU has no uninterruptible tasks queued at this point,
+ * it might still have a nonzero ->nr_uninterruptible counter, because
+ * for performance reasons the counter is not stricly tracking tasks to
+ * their home CPUs. So we just add the counter to another CPU's counter,
+ * to keep the global sum constant after CPU-down:
+ */
+static void migrate_nr_uninterruptible(runqueue_t *rq_src)
+{
+	runqueue_t *rq_dest = cpu_rq(any_online_cpu(CPU_MASK_ALL));
+	unsigned long flags;
+
+	local_irq_save(flags);
+	double_rq_lock(rq_src, rq_dest);
+	rq_dest->nr_uninterruptible += rq_src->nr_uninterruptible;
+	rq_src->nr_uninterruptible = 0;
+	double_rq_unlock(rq_src, rq_dest);
+	local_irq_restore(flags);
+}
+
 /* Run through task list and migrate tasks from the dead cpu. */
 static void migrate_live_tasks(int src_cpu)
 {
@@ -4069,7 +4000,7 @@
 	struct runqueue *rq = cpu_rq(dead_cpu);
 
 	/* Must be exiting, otherwise would be on tasklist. */
-	BUG_ON(tsk->state != TASK_ZOMBIE && tsk->state != TASK_DEAD);
+	BUG_ON(tsk->exit_state != EXIT_ZOMBIE && tsk->exit_state != EXIT_DEAD);
 
 	/* Cannot have done final schedule yet: would have vanished. */
 	BUG_ON(tsk->flags & PF_DEAD);
@@ -4154,6 +4085,7 @@
 		__setscheduler(rq->idle, SCHED_NORMAL, 0);
 		migrate_dead_tasks(cpu);
 		task_rq_unlock(rq, &flags);
+		migrate_nr_uninterruptible(rq);
 		BUG_ON(rq->nr_running != 0);
 
 		/* No need to migrate the tasks: it was best-effort if
@@ -4194,32 +4126,18 @@
 }
 #endif
 
+#ifdef CONFIG_SMP
 /*
- * The 'big kernel lock'
- *
- * This spinlock is taken and released recursively by lock_kernel()
- * and unlock_kernel().  It is transparently dropped and reaquired
- * over schedule().  It is used to protect legacy code that hasn't
- * been migrated to a proper locking design yet.
- *
- * Don't use in new code.
- *
- * Note: spinlock debugging needs this even on !CONFIG_SMP.
+ * Attach the domain 'sd' to 'cpu' as its base domain.  Callers must
+ * hold the hotplug lock.
  */
-spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
-EXPORT_SYMBOL(kernel_flag);
-
-#ifdef CONFIG_SMP
-/* Attach the domain 'sd' to 'cpu' as its base domain */
-static void cpu_attach_domain(struct sched_domain *sd, int cpu)
+void __devinit cpu_attach_domain(struct sched_domain *sd, int cpu)
 {
 	migration_req_t req;
 	unsigned long flags;
 	runqueue_t *rq = cpu_rq(cpu);
 	int local = 1;
 
-	lock_cpu_hotplug();
-
 	spin_lock_irqsave(&rq->lock, flags);
 
 	if (cpu == smp_processor_id() || !cpu_online(cpu)) {
@@ -4238,128 +4156,10 @@
 		wake_up_process(rq->migration_thread);
 		wait_for_completion(&req.done);
 	}
-
-	unlock_cpu_hotplug();
-}
-
-/*
- * To enable disjoint top-level NUMA domains, define SD_NODES_PER_DOMAIN
- * in arch code. That defines the number of nearby nodes in a node's top
- * level scheduling domain.
- */
-#if defined(CONFIG_NUMA) && defined(SD_NODES_PER_DOMAIN)
-/**
- * find_next_best_node - find the next node to include in a sched_domain
- * @node: node whose sched_domain we're building
- * @used_nodes: nodes already in the sched_domain
- *
- * Find the next node to include in a given scheduling domain.  Simply
- * finds the closest node not already in the @used_nodes map.
- *
- * Should use nodemask_t.
- */
-static int __init find_next_best_node(int node, unsigned long *used_nodes)
-{
-	int i, n, val, min_val, best_node = 0;
-
-	min_val = INT_MAX;
-
-	for (i = 0; i < numnodes; i++) {
-		/* Start at @node */
-		n = (node + i) % numnodes;
-
-		/* Skip already used nodes */
-		if (test_bit(n, used_nodes))
-			continue;
-
-		/* Simple min distance search */
-		val = node_distance(node, i);
-
-		if (val < min_val) {
-			min_val = val;
-			best_node = n;
-		}
-	}
-
-	set_bit(best_node, used_nodes);
-	return best_node;
 }
 
-/**
- * sched_domain_node_span - get a cpumask for a node's sched_domain
- * @node: node whose cpumask we're constructing
- * @size: number of nodes to include in this span
- *
- * Given a node, construct a good cpumask for its sched_domain to span.  It
- * should be one that prevents unnecessary balancing, but also spreads tasks
- * out optimally.
- */
-cpumask_t __init sched_domain_node_span(int node)
-{
-	int i;
-	cpumask_t span;
-	DECLARE_BITMAP(used_nodes, MAX_NUMNODES);
-
-	cpus_clear(span);
-	bitmap_zero(used_nodes, MAX_NUMNODES);
-
-	for (i = 0; i < SD_NODES_PER_DOMAIN; i++) {
-		int next_node = find_next_best_node(node, used_nodes);
-		cpumask_t  nodemask;
-
-		nodemask = node_to_cpumask(next_node);
-		cpus_or(span, span, nodemask);
-	}
-
-	return span;
-}
-#else /* CONFIG_NUMA && SD_NODES_PER_DOMAIN */
-cpumask_t __init sched_domain_node_span(int node)
-{
-	return cpu_possible_map;
-}
-#endif /* CONFIG_NUMA && SD_NODES_PER_DOMAIN */
-
-#ifdef CONFIG_SCHED_SMT
-static DEFINE_PER_CPU(struct sched_domain, cpu_domains);
-static struct sched_group sched_group_cpus[NR_CPUS];
-__init static int cpu_to_cpu_group(int cpu)
-{
-	return cpu;
-}
-#endif
-
-static DEFINE_PER_CPU(struct sched_domain, phys_domains);
-static struct sched_group sched_group_phys[NR_CPUS];
-__init static int cpu_to_phys_group(int cpu)
-{
-#ifdef CONFIG_SCHED_SMT
-	return first_cpu(cpu_sibling_map[cpu]);
-#else
-	return cpu;
-#endif
-}
-
-#ifdef CONFIG_NUMA
-
-static DEFINE_PER_CPU(struct sched_domain, node_domains);
-static struct sched_group sched_group_nodes[MAX_NUMNODES];
-__init static int cpu_to_node_group(int cpu)
-{
-	return cpu_to_node(cpu);
-}
-#endif
-
-/* Groups for isolated scheduling domains */
-static struct sched_group sched_group_isolated[NR_CPUS];
-
 /* cpus with isolated domains */
-cpumask_t __initdata cpu_isolated_map = CPU_MASK_NONE;
-
-__init static int cpu_to_isolated_group(int cpu)
-{
-	return cpu;
-}
+cpumask_t __devinitdata cpu_isolated_map = CPU_MASK_NONE;
 
 /* Setup the mask of cpus configured for isolated domains */
 static int __init isolated_cpu_setup(char *str)
@@ -4386,7 +4186,7 @@
  * covered by the given span, and will set each group's ->cpumask correctly,
  * and ->cpu_power to 0.
  */
-__init static void init_sched_build_groups(struct sched_group groups[],
+void __devinit init_sched_build_groups(struct sched_group groups[],
 			cpumask_t span, int (*group_fn)(int cpu))
 {
 	struct sched_group *first = NULL, *last = NULL;
@@ -4420,56 +4220,99 @@
 	last->next = first;
 }
 
-__init static void arch_init_sched_domains(void)
+
+#ifdef ARCH_HAS_SCHED_DOMAIN
+extern void __devinit arch_init_sched_domains(void);
+extern void __devinit arch_destroy_sched_domains(void);
+#else
+#ifdef CONFIG_SCHED_SMT
+static DEFINE_PER_CPU(struct sched_domain, cpu_domains);
+static struct sched_group sched_group_cpus[NR_CPUS];
+static int __devinit cpu_to_cpu_group(int cpu)
+{
+	return cpu;
+}
+#endif
+
+static DEFINE_PER_CPU(struct sched_domain, phys_domains);
+static struct sched_group sched_group_phys[NR_CPUS];
+static int __devinit cpu_to_phys_group(int cpu)
+{
+#ifdef CONFIG_SCHED_SMT
+	return first_cpu(cpu_sibling_map[cpu]);
+#else
+	return cpu;
+#endif
+}
+
+#ifdef CONFIG_NUMA
+
+static DEFINE_PER_CPU(struct sched_domain, node_domains);
+static struct sched_group sched_group_nodes[MAX_NUMNODES];
+static int __devinit cpu_to_node_group(int cpu)
+{
+	return cpu_to_node(cpu);
+}
+#endif
+
+#if defined(CONFIG_SCHED_SMT) && defined(CONFIG_NUMA)
+/*
+ * The domains setup code relies on siblings not spanning
+ * multiple nodes. Make sure the architecture has a proper
+ * siblings map:
+ */
+static void check_sibling_maps(void)
+{
+	int i, j;
+
+	for_each_online_cpu(i) {
+		for_each_cpu_mask(j, cpu_sibling_map[i]) {
+			if (cpu_to_node(i) != cpu_to_node(j)) {
+				printk(KERN_INFO "warning: CPU %d siblings map "
+					"to different node - isolating "
+					"them.\n", i);
+				cpu_sibling_map[i] = cpumask_of_cpu(i);
+				break;
+			}
+		}
+	}
+}
+#endif
+
+/*
+ * Set up scheduler domains and groups.  Callers must hold the hotplug lock.
+ */
+static void __devinit arch_init_sched_domains(void)
 {
 	int i;
 	cpumask_t cpu_default_map;
 
+#if defined(CONFIG_SCHED_SMT) && defined(CONFIG_NUMA)
+	check_sibling_maps();
+#endif
 	/*
 	 * Setup mask for cpus without special case scheduling requirements.
 	 * For now this just excludes isolated cpus, but could be used to
 	 * exclude other special cases in the future.
 	 */
 	cpus_complement(cpu_default_map, cpu_isolated_map);
-	cpus_and(cpu_default_map, cpu_default_map, cpu_possible_map);
+	cpus_and(cpu_default_map, cpu_default_map, cpu_online_map);
 
-	/* Set up domains */
-	for_each_cpu(i) {
+	/*
+	 * Set up domains. Isolated domains just stay on the dummy domain.
+	 */
+	for_each_cpu_mask(i, cpu_default_map) {
 		int group;
 		struct sched_domain *sd = NULL, *p;
 		cpumask_t nodemask = node_to_cpumask(cpu_to_node(i));
 
 		cpus_and(nodemask, nodemask, cpu_default_map);
 
-		/*
-		 * Set up isolated domains.
-		 * Unlike those of other cpus, the domains and groups are
-		 * single level, and span a single cpu.
-		 */
-		if (cpu_isset(i, cpu_isolated_map)) {
-#ifdef CONFIG_SCHED_SMT
-			sd = &per_cpu(cpu_domains, i);
-#else
-			sd = &per_cpu(phys_domains, i);
-#endif
-			group = cpu_to_isolated_group(i);
-			*sd = SD_CPU_INIT;
-			cpu_set(i, sd->span);
-			sd->balance_interval = INT_MAX;	/* Don't balance */
-			sd->flags = 0;			/* Avoid WAKE_ */
-			sd->groups = &sched_group_isolated[group];
-			printk(KERN_INFO "Setting up cpu %d isolated.\n", i);
-			/* Single level, so continue with next cpu */
-			continue;
-		}
-
 #ifdef CONFIG_NUMA
 		sd = &per_cpu(node_domains, i);
 		group = cpu_to_node_group(i);
 		*sd = SD_NODE_INIT;
-		/* FIXME: should be multilevel, in arch code */
-		sd->span = sched_domain_node_span(i);
-		cpus_and(sd->span, sd->span, cpu_default_map);
+		sd->span = cpu_default_map;
 		sd->groups = &sched_group_nodes[group];
 #endif
 
@@ -4477,11 +4320,7 @@
 		sd = &per_cpu(phys_domains, i);
 		group = cpu_to_phys_group(i);
 		*sd = SD_CPU_INIT;
-#ifdef CONFIG_NUMA
 		sd->span = nodemask;
-#else
-		sd->span = cpu_possible_map;
-#endif
 		sd->parent = p;
 		sd->groups = &sched_group_phys[group];
 
@@ -4499,7 +4338,7 @@
 
 #ifdef CONFIG_SCHED_SMT
 	/* Set up CPU (sibling) groups */
-	for_each_cpu(i) {
+	for_each_online_cpu(i) {
 		cpumask_t this_sibling_map = cpu_sibling_map[i];
 		cpus_and(this_sibling_map, this_sibling_map, cpu_default_map);
 		if (i != first_cpu(this_sibling_map))
@@ -4510,16 +4349,6 @@
 	}
 #endif
 
-	/* Set up isolated groups */
-	for_each_cpu_mask(i, cpu_isolated_map) {
-		cpumask_t mask;
-		cpus_clear(mask);
-		cpu_set(i, mask);
-		init_sched_build_groups(sched_group_isolated, mask,
-						&cpu_to_isolated_group);
-	}
-
-#ifdef CONFIG_NUMA
 	/* Set up physical groups */
 	for (i = 0; i < MAX_NUMNODES; i++) {
 		cpumask_t nodemask = node_to_cpumask(i);
@@ -4531,10 +4360,6 @@
 		init_sched_build_groups(sched_group_phys, nodemask,
 						&cpu_to_phys_group);
 	}
-#else
-	init_sched_build_groups(sched_group_phys, cpu_possible_map,
-							&cpu_to_phys_group);
-#endif
 
 #ifdef CONFIG_NUMA
 	/* Set up node groups */
@@ -4567,7 +4392,7 @@
 	}
 
 	/* Attach the domains */
-	for_each_cpu(i) {
+	for_each_online_cpu(i) {
 		struct sched_domain *sd;
 #ifdef CONFIG_SCHED_SMT
 		sd = &per_cpu(cpu_domains, i);
@@ -4578,21 +4403,29 @@
 	}
 }
 
-#undef SCHED_DOMAIN_DEBUG
+#ifdef CONFIG_HOTPLUG_CPU
+static void __devinit arch_destroy_sched_domains(void)
+{
+	/* Do nothing: everything is statically allocated. */
+}
+#endif
+
+#endif /* ARCH_HAS_SCHED_DOMAIN */
+
+#define SCHED_DOMAIN_DEBUG
 #ifdef SCHED_DOMAIN_DEBUG
-void sched_domain_debug(void)
+static void sched_domain_debug(void)
 {
 	int i;
 
-	for_each_cpu(i) {
+	for_each_online_cpu(i) {
 		runqueue_t *rq = cpu_rq(i);
 		struct sched_domain *sd;
 		int level = 0;
 
 		sd = rq->sd;
 
-		printk(KERN_DEBUG "CPU%d: %s\n",
-				i, (cpu_online(i) ? " online" : "offline"));
+		printk(KERN_DEBUG "CPU%d:\n", i);
 
 		do {
 			int j;
@@ -4606,14 +4439,22 @@
 			printk(KERN_DEBUG);
 			for (j = 0; j < level + 1; j++)
 				printk(" ");
-			printk("domain %d: span %s\n", level, str);
+			printk("domain %d: ", level);
+
+			if (!(sd->flags & SD_LOAD_BALANCE)) {
+				printk("does not load-balance");
+				if (sd->parent)
+					printk(" ERROR !SD_LOAD_BALANCE domain has parent");
+				printk("\n");
+				break;
+			}
+
+			printk("span %s\n", str);
 
 			if (!cpu_isset(i, sd->span))
 				printk(KERN_DEBUG "ERROR domain->span does not contain CPU%d\n", i);
 			if (!cpu_isset(i, group->cpumask))
 				printk(KERN_DEBUG "ERROR domain->groups does not contain CPU%d\n", i);
-			if (!group->cpu_power)
-				printk(KERN_DEBUG "ERROR domain->cpu_power not set\n");
 
 			printk(KERN_DEBUG);
 			for (j = 0; j < level + 2; j++)
@@ -4624,6 +4465,9 @@
 					printk(" ERROR: NULL");
 					break;
 				}
+				
+				if (!group->cpu_power)
+					printk(KERN_DEBUG "ERROR group->cpu_power not set\n");
 
 				if (!cpus_weight(group->cpumask))
 					printk(" ERROR empty group:");
@@ -4658,10 +4502,62 @@
 #define sched_domain_debug() {}
 #endif
 
+/*
+ * Initial dummy domain for early boot and for hotplug cpu. Being static,
+ * it is initialized to zero, so all balancing flags are cleared which is
+ * what we want.
+ */
+static struct sched_domain sched_domain_dummy;
+
+#ifdef CONFIG_HOTPLUG_CPU
+/*
+ * Force a reinitialization of the sched domains hierarchy.  The domains
+ * and groups cannot be updated in place without racing with the balancing
+ * code, so we temporarily attach all running cpus to a "dummy" domain
+ * which will prevent rebalancing while the sched domains are recalculated.
+ */
+static int update_sched_domains(struct notifier_block *nfb,
+				unsigned long action, void *hcpu)
+{
+	int i;
+
+	switch (action) {
+	case CPU_UP_PREPARE:
+	case CPU_DOWN_PREPARE:
+		for_each_online_cpu(i)
+			cpu_attach_domain(&sched_domain_dummy, i);
+		arch_destroy_sched_domains();
+		return NOTIFY_OK;
+
+	case CPU_UP_CANCELED:
+	case CPU_DOWN_FAILED:
+	case CPU_ONLINE:
+	case CPU_DEAD:
+		/*
+		 * Fall through and re-initialise the domains.
+		 */
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+
+	/* The hotplug lock is already held by cpu_up/cpu_down */
+	arch_init_sched_domains();
+
+	sched_domain_debug();
+
+	return NOTIFY_OK;
+}
+#endif
+
 void __init sched_init_smp(void)
 {
+	lock_cpu_hotplug();
 	arch_init_sched_domains();
 	sched_domain_debug();
+	unlock_cpu_hotplug();
+	/* XXX: Theoretical race here - CPU may be hotplugged now */
+	hotcpu_notifier(update_sched_domains, 0);
 }
 #else
 void __init sched_init_smp(void)
@@ -4683,24 +4579,6 @@
 	runqueue_t *rq;
 	int i, j, k;
 
-#ifdef CONFIG_SMP
-	/* Set up an initial dummy domain for early boot */
-	static struct sched_domain sched_domain_init;
-	static struct sched_group sched_group_init;
-
-	memset(&sched_domain_init, 0, sizeof(struct sched_domain));
-	sched_domain_init.span = CPU_MASK_ALL;
-	sched_domain_init.groups = &sched_group_init;
-	sched_domain_init.last_balance = jiffies;
-	sched_domain_init.balance_interval = INT_MAX; /* Don't balance */
-	sched_domain_init.busy_factor = 1;
-
-	memset(&sched_group_init, 0, sizeof(struct sched_group));
-	sched_group_init.cpumask = CPU_MASK_ALL;
-	sched_group_init.next = &sched_group_init;
-	sched_group_init.cpu_power = SCHED_LOAD_SCALE;
-#endif
-
 	for (i = 0; i < NR_CPUS; i++) {
 		prio_array_t *array;
 
@@ -4711,7 +4589,7 @@
 		rq->best_expired_prio = MAX_PRIO;
 
 #ifdef CONFIG_SMP
-		rq->sd = &sched_domain_init;
+		rq->sd = &sched_domain_dummy;
 		rq->cpu_load = 0;
 		rq->active_balance = 0;
 		rq->push_cpu = 0;
@@ -4767,3 +4645,34 @@
 }
 EXPORT_SYMBOL(__might_sleep);
 #endif
+
+#ifdef CONFIG_MAGIC_SYSRQ
+void normalize_rt_tasks(void)
+{
+	struct task_struct *p;
+	prio_array_t *array;
+	unsigned long flags;
+	runqueue_t *rq;
+
+	read_lock_irq(&tasklist_lock);
+	for_each_process (p) {
+		if (!rt_task(p))
+			continue;
+
+		rq = task_rq_lock(p, &flags);
+
+		array = p->array;
+		if (array)
+			deactivate_task(p, task_rq(p));
+		__setscheduler(p, SCHED_NORMAL, 0);
+		if (array) {
+			__activate_task(p, task_rq(p));
+			resched_task(rq->curr);
+		}
+
+		task_rq_unlock(rq, &flags);
+	}
+	read_unlock_irq(&tasklist_lock);
+}
+
+#endif /* CONFIG_MAGIC_SYSRQ */
diff -Nru a/kernel/signal.c b/kernel/signal.c
--- a/kernel/signal.c	2004-12-24 13:36:48 -08:00
+++ b/kernel/signal.c	2004-12-24 13:36:48 -08:00
@@ -20,6 +20,7 @@
 #include <linux/tty.h>
 #include <linux/binfmts.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 #include <linux/ptrace.h>
 #include <asm/param.h>
 #include <asm/uaccess.h>
@@ -264,18 +265,18 @@
 	return sig;
 }
 
-static struct sigqueue *__sigqueue_alloc(void)
+static struct sigqueue *__sigqueue_alloc(struct task_struct *t, int flags)
 {
 	struct sigqueue *q = NULL;
 
-	if (atomic_read(&current->user->sigpending) <
-			current->rlim[RLIMIT_SIGPENDING].rlim_cur)
-		q = kmem_cache_alloc(sigqueue_cachep, GFP_ATOMIC);
+	if (atomic_read(&t->user->sigpending) <
+			t->signal->rlim[RLIMIT_SIGPENDING].rlim_cur)
+		q = kmem_cache_alloc(sigqueue_cachep, flags);
 	if (q) {
 		INIT_LIST_HEAD(&q->list);
 		q->flags = 0;
 		q->lock = NULL;
-		q->user = get_uid(current->user);
+		q->user = get_uid(t->user);
 		atomic_inc(&q->user->sigpending);
 	}
 	return(q);
@@ -763,14 +764,8 @@
 	   make sure at least one signal gets delivered and don't
 	   pass on the info struct.  */
 
-	if (atomic_read(&t->user->sigpending) <
-			t->rlim[RLIMIT_SIGPENDING].rlim_cur)
-		q = kmem_cache_alloc(sigqueue_cachep, GFP_ATOMIC);
-
+	q = __sigqueue_alloc(t, GFP_ATOMIC);
 	if (q) {
-		q->flags = 0;
-		q->user = get_uid(t->user);
-		atomic_inc(&q->user->sigpending);
 		list_add_tail(&q->list, &signals->list);
 		switch ((unsigned long) info) {
 		case 0:
@@ -913,7 +908,7 @@
 	 * Don't bother zombies and stopped tasks (but
 	 * SIGKILL will punch through stopped state)
 	 */
-	mask = TASK_DEAD | TASK_ZOMBIE | TASK_TRACED;
+	mask = EXIT_DEAD | EXIT_ZOMBIE | TASK_TRACED;
 	if (sig != SIGKILL)
 		mask |= TASK_STOPPED;
 
@@ -1069,7 +1064,7 @@
 		/*
 		 * Don't bother with already dead threads
 		 */
-		if (t->state & (TASK_ZOMBIE|TASK_DEAD))
+		if (t->exit_state & (EXIT_ZOMBIE|EXIT_DEAD))
 			continue;
 
 		/*
@@ -1114,7 +1109,7 @@
 
 int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp)
 {
-	struct task_struct *p;
+	struct task_struct *p = NULL;
 	int retval, success;
 
 	if (pgrp <= 0)
@@ -1142,36 +1137,6 @@
 	return retval;
 }
 
-/*
- * kill_sl_info() sends a signal to the session leader: this is used
- * to send SIGHUP to the controlling process of a terminal when
- * the connection is lost.
- */
-
-
-int
-kill_sl_info(int sig, struct siginfo *info, pid_t sid)
-{
-	int err, retval = -EINVAL;
-	struct task_struct *p;
-
-	if (sid <= 0)
-		goto out;
-
-	retval = -ESRCH;
-	read_lock(&tasklist_lock);
-	do_each_task_pid(sid, PIDTYPE_SID, p) {
-		if (!p->signal->leader)
-			continue;
-		err = group_send_sig_info(sig, info, p);
-		if (retval)
-			retval = err;
-	} while_each_task_pid(sid, PIDTYPE_SID, p);
-	read_unlock(&tasklist_lock);
-out:
-	return retval;
-}
-
 int
 kill_proc_info(int sig, struct siginfo *info, pid_t pid)
 {
@@ -1308,12 +1273,6 @@
 }
 
 int
-kill_sl(pid_t sess, int sig, int priv)
-{
-	return kill_sl_info(sig, (void *)(long)(priv != 0), sess);
-}
-
-int
 kill_proc(pid_t pid, int sig, int priv)
 {
 	return kill_proc_info(sig, (void *)(long)(priv != 0), pid);
@@ -1333,7 +1292,7 @@
 {
 	struct sigqueue *q;
 
-	if ((q = __sigqueue_alloc()))
+	if ((q = __sigqueue_alloc(current, GFP_KERNEL)))
 		q->flags |= SIGQUEUE_PREALLOC;
 	return(q);
 }
@@ -1944,22 +1903,16 @@
 		 * Anything else is fatal, maybe with a core dump.
 		 */
 		current->flags |= PF_SIGNALED;
-		if (sig_kernel_coredump(signr) &&
-		    do_coredump((long)signr, signr, regs)) {
+		if (sig_kernel_coredump(signr)) {
 			/*
-			 * That killed all other threads in the group and
-			 * synchronized with their demise, so there can't
-			 * be any more left to kill now.  The group_exit
-			 * flags are set by do_coredump.  Note that
-			 * thread_group_empty won't always be true yet,
-			 * because those threads were blocked in __exit_mm
-			 * and we just let them go to finish dying.
+			 * If it was able to dump core, this kills all
+			 * other threads in the group and synchronizes with
+			 * their demise.  If we lost the race with another
+			 * thread getting here, it set group_exit_code
+			 * first and our do_group_exit call below will use
+			 * that value and ignore the one we pass it.
 			 */
-			const int code = signr | 0x80;
-			BUG_ON(!current->signal->group_exit);
-			BUG_ON(current->signal->group_exit_code != code);
-			do_exit(code);
-			/* NOTREACHED */
+			do_coredump((long)signr, signr, regs);
 		}
 
 		/*
@@ -1978,21 +1931,11 @@
 EXPORT_SYMBOL_GPL(dequeue_signal);
 EXPORT_SYMBOL(flush_signals);
 EXPORT_SYMBOL(force_sig);
-EXPORT_SYMBOL(force_sig_info);
 EXPORT_SYMBOL(kill_pg);
-EXPORT_SYMBOL(kill_pg_info);
 EXPORT_SYMBOL(kill_proc);
-EXPORT_SYMBOL(kill_proc_info);
-EXPORT_SYMBOL(kill_sl);
-EXPORT_SYMBOL(kill_sl_info);
 EXPORT_SYMBOL(ptrace_notify);
 EXPORT_SYMBOL(send_sig);
 EXPORT_SYMBOL(send_sig_info);
-EXPORT_SYMBOL(send_group_sig_info);
-EXPORT_SYMBOL(sigqueue_alloc);
-EXPORT_SYMBOL(sigqueue_free);
-EXPORT_SYMBOL(send_sigqueue);
-EXPORT_SYMBOL(send_group_sigqueue);
 EXPORT_SYMBOL(sigprocmask);
 EXPORT_SYMBOL(block_all_signals);
 EXPORT_SYMBOL(unblock_all_signals);
diff -Nru a/kernel/softirq.c b/kernel/softirq.c
--- a/kernel/softirq.c	2004-12-24 13:36:31 -08:00
+++ b/kernel/softirq.c	2004-12-24 13:36:31 -08:00
@@ -137,11 +137,17 @@
 
 void local_bh_enable(void)
 {
-	__local_bh_enable();
 	WARN_ON(irqs_disabled());
-	if (unlikely(!in_interrupt() &&
-		     local_softirq_pending()))
-		invoke_softirq();
+	/*
+	 * Keep preemption disabled until we are done with
+	 * softirq processing:
+ 	 */
+	preempt_count() -= SOFTIRQ_OFFSET - 1;
+
+	if (unlikely(!in_interrupt() && local_softirq_pending()))
+		do_softirq();
+
+	dec_preempt_count();
 	preempt_check_resched();
 }
 EXPORT_SYMBOL(local_bh_enable);
@@ -176,8 +182,6 @@
 	raise_softirq_irqoff(nr);
 	local_irq_restore(flags);
 }
-
-EXPORT_SYMBOL(raise_softirq);
 
 void open_softirq(int nr, void (*action)(struct softirq_action*), void *data)
 {
diff -Nru a/kernel/stop_machine.c b/kernel/stop_machine.c
--- a/kernel/stop_machine.c	2004-12-24 13:36:17 -08:00
+++ b/kernel/stop_machine.c	2004-12-24 13:36:17 -08:00
@@ -52,7 +52,12 @@
 			mb(); /* Must read state first. */
 			atomic_inc(&stopmachine_thread_ack);
 		}
-		cpu_relax();
+		/* Yield in first stage: migration threads need to
+		 * help our sisters onto their CPUs. */
+		if (!prepared && !irqs_disabled)
+			yield();
+		else
+			cpu_relax();
 	}
 
 	/* Ack: we are exiting. */
diff -Nru a/kernel/sys.c b/kernel/sys.c
--- a/kernel/sys.c	2004-12-24 13:36:18 -08:00
+++ b/kernel/sys.c	2004-12-24 13:36:18 -08:00
@@ -5,7 +5,6 @@
  */
 
 #include <linux/config.h>
-#include <linux/compat.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/utsname.h>
@@ -19,11 +18,15 @@
 #include <linux/fs.h>
 #include <linux/workqueue.h>
 #include <linux/device.h>
+#include <linux/key.h>
 #include <linux/times.h>
 #include <linux/security.h>
 #include <linux/dcookies.h>
 #include <linux/suspend.h>
 
+#include <linux/compat.h>
+#include <linux/syscalls.h>
+
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/unistd.h>
@@ -212,77 +215,6 @@
 }
 
 EXPORT_SYMBOL(unregister_reboot_notifier);
-
-asmlinkage long sys_ni_syscall(void)
-{
-	return -ENOSYS;
-}
-
-cond_syscall(sys_nfsservctl)
-cond_syscall(sys_quotactl)
-cond_syscall(sys_acct)
-cond_syscall(sys_lookup_dcookie)
-cond_syscall(sys_swapon)
-cond_syscall(sys_swapoff)
-cond_syscall(sys_init_module)
-cond_syscall(sys_delete_module)
-cond_syscall(sys_socketpair)
-cond_syscall(sys_bind)
-cond_syscall(sys_listen)
-cond_syscall(sys_accept)
-cond_syscall(sys_connect)
-cond_syscall(sys_getsockname)
-cond_syscall(sys_getpeername)
-cond_syscall(sys_sendto)
-cond_syscall(sys_send)
-cond_syscall(sys_recvfrom)
-cond_syscall(sys_recv)
-cond_syscall(sys_socket)
-cond_syscall(sys_setsockopt)
-cond_syscall(sys_getsockopt)
-cond_syscall(sys_shutdown)
-cond_syscall(sys_sendmsg)
-cond_syscall(sys_recvmsg)
-cond_syscall(sys_socketcall)
-cond_syscall(sys_futex)
-cond_syscall(compat_sys_futex)
-cond_syscall(sys_epoll_create)
-cond_syscall(sys_epoll_ctl)
-cond_syscall(sys_epoll_wait)
-cond_syscall(sys_semget)
-cond_syscall(sys_semop)
-cond_syscall(sys_semtimedop)
-cond_syscall(sys_semctl)
-cond_syscall(sys_msgget)
-cond_syscall(sys_msgsnd)
-cond_syscall(sys_msgrcv)
-cond_syscall(sys_msgctl)
-cond_syscall(sys_shmget)
-cond_syscall(sys_shmdt)
-cond_syscall(sys_shmctl)
-cond_syscall(sys_mq_open)
-cond_syscall(sys_mq_unlink)
-cond_syscall(sys_mq_timedsend)
-cond_syscall(sys_mq_timedreceive)
-cond_syscall(sys_mq_notify)
-cond_syscall(sys_mq_getsetattr)
-cond_syscall(compat_sys_mq_open)
-cond_syscall(compat_sys_mq_timedsend)
-cond_syscall(compat_sys_mq_timedreceive)
-cond_syscall(compat_sys_mq_notify)
-cond_syscall(compat_sys_mq_getsetattr)
-cond_syscall(sys_mbind)
-cond_syscall(sys_get_mempolicy)
-cond_syscall(sys_set_mempolicy)
-cond_syscall(compat_mbind)
-cond_syscall(compat_get_mempolicy)
-cond_syscall(compat_set_mempolicy)
-
-/* arch-specific weak syscall entries */
-cond_syscall(sys_pciconfig_read)
-cond_syscall(sys_pciconfig_write)
-cond_syscall(sys_pciconfig_iobase)
-
 static int set_one_prio(struct task_struct *p, int niceval, int error)
 {
 	int no_nice;
@@ -341,19 +273,18 @@
 			} while_each_task_pid(who, PIDTYPE_PGID, p);
 			break;
 		case PRIO_USER:
+			user = current->user;
 			if (!who)
-				user = current->user;
+				who = current->uid;
 			else
-				user = find_user(who);
-
-			if (!user)
-				goto out_unlock;
+				if ((who != current->uid) && !(user = find_user(who)))
+					goto out_unlock;	/* No processes for this user */
 
 			do_each_thread(g, p)
 				if (p->uid == who)
 					error = set_one_prio(p, niceval, error);
 			while_each_thread(g, p);
-			if (who)
+			if (who != current->uid)
 				free_uid(user);		/* For find_user() */
 			break;
 	}
@@ -400,13 +331,12 @@
 			} while_each_task_pid(who, PIDTYPE_PGID, p);
 			break;
 		case PRIO_USER:
+			user = current->user;
 			if (!who)
-				user = current->user;
+				who = current->uid;
 			else
-				user = find_user(who);
-
-			if (!user)
-				goto out_unlock;
+				if ((who != current->uid) && !(user = find_user(who)))
+					goto out_unlock;	/* No processes for this user */
 
 			do_each_thread(g, p)
 				if (p->uid == who) {
@@ -415,7 +345,7 @@
 						retval = niceval;
 				}
 			while_each_thread(g, p);
-			if (who)
+			if (who != current->uid)
 				free_uid(user);		/* for find_user() */
 			break;
 	}
@@ -600,6 +530,7 @@
 	current->fsgid = new_egid;
 	current->egid = new_egid;
 	current->gid = new_rgid;
+	key_fsgid_changed(current);
 	return 0;
 }
 
@@ -637,6 +568,8 @@
 	}
 	else
 		return -EPERM;
+
+	key_fsgid_changed(current);
 	return 0;
 }
   
@@ -649,7 +582,7 @@
 		return -EAGAIN;
 
 	if (atomic_read(&new_user->processes) >=
-				current->rlim[RLIMIT_NPROC].rlim_cur &&
+				current->signal->rlim[RLIMIT_NPROC].rlim_cur &&
 			new_user != &root_user) {
 		free_uid(new_user);
 		return -EAGAIN;
@@ -725,6 +658,8 @@
 		current->suid = current->euid;
 	current->fsuid = current->euid;
 
+	key_fsuid_changed(current);
+
 	return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RE);
 }
 
@@ -770,6 +705,8 @@
 	current->fsuid = current->euid = uid;
 	current->suid = new_suid;
 
+	key_fsuid_changed(current);
+
 	return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID);
 }
 
@@ -816,6 +753,8 @@
 	if (suid != (uid_t) -1)
 		current->suid = suid;
 
+	key_fsuid_changed(current);
+
 	return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RES);
 }
 
@@ -865,6 +804,8 @@
 		current->gid = rgid;
 	if (sgid != (gid_t) -1)
 		current->sgid = sgid;
+
+	key_fsgid_changed(current);
 	return 0;
 }
 
@@ -906,6 +847,8 @@
 		current->fsuid = uid;
 	}
 
+	key_fsuid_changed(current);
+
 	security_task_post_setuid(old_fsuid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS);
 
 	return old_fsuid;
@@ -932,6 +875,7 @@
 			wmb();
 		}
 		current->fsgid = gid;
+		key_fsgid_changed(current);
 	}
 	return old_fsgid;
 }
@@ -1496,9 +1440,13 @@
 {
 	if (resource >= RLIM_NLIMITS)
 		return -EINVAL;
-	else
-		return copy_to_user(rlim, current->rlim + resource, sizeof(*rlim))
-			? -EFAULT : 0;
+	else {
+		struct rlimit value;
+		task_lock(current->group_leader);
+		value = current->signal->rlim[resource];
+		task_unlock(current->group_leader);
+		return copy_to_user(rlim, &value, sizeof(*rlim)) ? -EFAULT : 0;
+	}
 }
 
 #ifdef __ARCH_WANT_SYS_OLD_GETRLIMIT
@@ -1513,7 +1461,9 @@
 	if (resource >= RLIM_NLIMITS)
 		return -EINVAL;
 
-	memcpy(&x, current->rlim + resource, sizeof(*rlim));
+	task_lock(current->group_leader);
+	x = current->signal->rlim[resource];
+	task_unlock(current->group_leader);
 	if(x.rlim_cur > 0x7FFFFFFF)
 		x.rlim_cur = 0x7FFFFFFF;
 	if(x.rlim_max > 0x7FFFFFFF)
@@ -1534,21 +1484,20 @@
 		return -EFAULT;
        if (new_rlim.rlim_cur > new_rlim.rlim_max)
                return -EINVAL;
-	old_rlim = current->rlim + resource;
-	if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||
-	     (new_rlim.rlim_max > old_rlim->rlim_max)) &&
+	old_rlim = current->signal->rlim + resource;
+	if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
 	    !capable(CAP_SYS_RESOURCE))
 		return -EPERM;
-	if (resource == RLIMIT_NOFILE) {
-		if (new_rlim.rlim_cur > NR_OPEN || new_rlim.rlim_max > NR_OPEN)
+	if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
 			return -EPERM;
-	}
 
 	retval = security_task_setrlimit(resource, &new_rlim);
 	if (retval)
 		return retval;
 
+	task_lock(current->group_leader);
 	*old_rlim = new_rlim;
+	task_unlock(current->group_leader);
 	return 0;
 }
 
@@ -1659,7 +1608,7 @@
 asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
 			  unsigned long arg4, unsigned long arg5)
 {
-	int error;
+	long error;
 	int sig;
 
 	error = security_task_prctl(option, arg2, arg3, arg4, arg5);
diff -Nru a/kernel/sys_ni.c b/kernel/sys_ni.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/sys_ni.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,84 @@
+
+#include <linux/linkage.h>
+#include <linux/errno.h>
+
+#include <asm/unistd.h>
+
+/*
+ * Non-implemented system calls get redirected here.
+ */
+asmlinkage long sys_ni_syscall(void)
+{
+	return -ENOSYS;
+}
+
+cond_syscall(sys_nfsservctl)
+cond_syscall(sys_quotactl)
+cond_syscall(sys_acct)
+cond_syscall(sys_lookup_dcookie)
+cond_syscall(sys_swapon)
+cond_syscall(sys_swapoff)
+cond_syscall(sys_init_module)
+cond_syscall(sys_delete_module)
+cond_syscall(sys_socketpair)
+cond_syscall(sys_bind)
+cond_syscall(sys_listen)
+cond_syscall(sys_accept)
+cond_syscall(sys_connect)
+cond_syscall(sys_getsockname)
+cond_syscall(sys_getpeername)
+cond_syscall(sys_sendto)
+cond_syscall(sys_send)
+cond_syscall(sys_recvfrom)
+cond_syscall(sys_recv)
+cond_syscall(sys_socket)
+cond_syscall(sys_setsockopt)
+cond_syscall(sys_getsockopt)
+cond_syscall(sys_shutdown)
+cond_syscall(sys_sendmsg)
+cond_syscall(sys_recvmsg)
+cond_syscall(sys_socketcall)
+cond_syscall(sys_futex)
+cond_syscall(compat_sys_futex)
+cond_syscall(sys_epoll_create)
+cond_syscall(sys_epoll_ctl)
+cond_syscall(sys_epoll_wait)
+cond_syscall(sys_semget)
+cond_syscall(sys_semop)
+cond_syscall(sys_semtimedop)
+cond_syscall(sys_semctl)
+cond_syscall(sys_msgget)
+cond_syscall(sys_msgsnd)
+cond_syscall(sys_msgrcv)
+cond_syscall(sys_msgctl)
+cond_syscall(sys_shmget)
+cond_syscall(sys_shmdt)
+cond_syscall(sys_shmctl)
+cond_syscall(sys_mq_open)
+cond_syscall(sys_mq_unlink)
+cond_syscall(sys_mq_timedsend)
+cond_syscall(sys_mq_timedreceive)
+cond_syscall(sys_mq_notify)
+cond_syscall(sys_mq_getsetattr)
+cond_syscall(compat_sys_mq_open)
+cond_syscall(compat_sys_mq_timedsend)
+cond_syscall(compat_sys_mq_timedreceive)
+cond_syscall(compat_sys_mq_notify)
+cond_syscall(compat_sys_mq_getsetattr)
+cond_syscall(sys_mbind)
+cond_syscall(sys_get_mempolicy)
+cond_syscall(sys_set_mempolicy)
+cond_syscall(compat_sys_mbind)
+cond_syscall(compat_sys_get_mempolicy)
+cond_syscall(compat_sys_set_mempolicy)
+cond_syscall(sys_add_key)
+cond_syscall(sys_request_key)
+cond_syscall(sys_keyctl)
+cond_syscall(compat_sys_keyctl)
+cond_syscall(compat_sys_socketcall)
+
+/* arch-specific weak syscall entries */
+cond_syscall(sys_pciconfig_read)
+cond_syscall(sys_pciconfig_write)
+cond_syscall(sys_pciconfig_iobase)
+
diff -Nru a/kernel/sysctl.c b/kernel/sysctl.c
--- a/kernel/sysctl.c	2004-12-24 13:36:18 -08:00
+++ b/kernel/sysctl.c	2004-12-24 13:36:18 -08:00
@@ -40,6 +40,7 @@
 #include <linux/times.h>
 #include <linux/limits.h>
 #include <linux/dcache.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/processor.h>
@@ -65,8 +66,9 @@
 extern int min_free_kbytes;
 extern int printk_ratelimit_jiffies;
 extern int printk_ratelimit_burst;
+extern int pid_max_min, pid_max_max;
 
-#if defined(CONFIG_X86_LOCAL_APIC) && defined(__i386__)
+#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
 int unknown_nmi_panic;
 extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
 				  void __user *, size_t *, loff_t *);
@@ -392,7 +394,7 @@
 		.ctl_name	= KERN_HOTPLUG,
 		.procname	= "hotplug",
 		.data		= &hotplug_path,
-		.maxlen		= KMOD_PATH_LEN,
+		.maxlen		= HOTPLUG_PATH_LEN,
 		.mode		= 0644,
 		.proc_handler	= &proc_dostring,
 		.strategy	= &sysctl_string,
@@ -574,7 +576,10 @@
 		.data		= &pid_max,
 		.maxlen		= sizeof (int),
 		.mode		= 0644,
-		.proc_handler	= &proc_dointvec,
+		.proc_handler	= &proc_dointvec_minmax,
+		.strategy	= sysctl_intvec,
+		.extra1		= &pid_max_min,
+		.extra2		= &pid_max_max,
 	},
 	{
 		.ctl_name	= KERN_PANIC_ON_OOPS,
@@ -609,7 +614,7 @@
 		.mode		= 0444,
 		.proc_handler	= &proc_dointvec,
 	},
-#if defined(CONFIG_X86_LOCAL_APIC) && defined(__i386__)
+#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
 	{
 		.ctl_name       = KERN_UNKNOWN_NMI_PANIC,
 		.procname       = "unknown_nmi_panic",
@@ -800,6 +805,17 @@
 		.extra1		= &zero,
 	},
 #endif
+#ifdef CONFIG_SWAP
+	{
+		.ctl_name	= VM_SWAP_TOKEN_TIMEOUT,
+		.procname	= "swap_token_timeout",
+		.data		= &swap_token_default_timeout,
+		.maxlen		= sizeof(swap_token_default_timeout),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec_jiffies,
+		.strategy	= &sysctl_jiffies,
+	},
+#endif
 	{ .ctl_name = 0 }
 };
 
@@ -878,6 +894,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+#ifdef CONFIG_DNOTIFY
 	{
 		.ctl_name	= FS_DIR_NOTIFY,
 		.procname	= "dir-notify-enable",
@@ -886,6 +903,7 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+#endif
 	{
 		.ctl_name	= FS_LEASE_TIME,
 		.procname	= "lease-break-time",
diff -Nru a/kernel/time.c b/kernel/time.c
--- a/kernel/time.c	2004-12-24 13:36:31 -08:00
+++ b/kernel/time.c	2004-12-24 13:36:31 -08:00
@@ -31,6 +31,9 @@
 #include <linux/timex.h>
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
+#include <linux/syscalls.h>
+#include <linux/security.h>
+
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
 
@@ -77,13 +80,17 @@
 asmlinkage long sys_stime(time_t __user *tptr)
 {
 	struct timespec tv;
+	int err;
 
-	if (!capable(CAP_SYS_TIME))
-		return -EPERM;
 	if (get_user(tv.tv_sec, tptr))
 		return -EFAULT;
 
 	tv.tv_nsec = 0;
+
+	err = security_settime(&tv, NULL);
+	if (err)
+		return err;
+
 	do_settimeofday(&tv);
 	return 0;
 }
@@ -145,10 +152,12 @@
 int do_sys_settimeofday(struct timespec *tv, struct timezone *tz)
 {
 	static int firsttime = 1;
+	int error = 0;
+
+	error = security_settime(tv, tz);
+	if (error)
+		return error;
 
-	if (!capable(CAP_SYS_TIME))
-		return -EPERM;
-		
 	if (tz) {
 		/* SMP safe, global irq locking makes it work. */
 		sys_tz = *tz;
@@ -478,8 +487,6 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(do_settimeofday);
-
 void do_gettimeofday (struct timeval *tv)
 {
 	unsigned long seq, nsec, usec, sec, offset;
@@ -518,8 +525,6 @@
 	tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
 }
 #endif
-
-EXPORT_SYMBOL(getnstimeofday);
 
 #if (BITS_PER_LONG < 64)
 u64 get_jiffies_64(void)
diff -Nru a/kernel/timer.c b/kernel/timer.c
--- a/kernel/timer.c	2004-12-24 13:37:18 -08:00
+++ b/kernel/timer.c	2004-12-24 13:37:18 -08:00
@@ -31,6 +31,7 @@
 #include <linux/time.h>
 #include <linux/jiffies.h>
 #include <linux/cpu.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -240,7 +241,6 @@
 	spin_unlock_irqrestore(&base->lock, flags);
 }
 
-EXPORT_SYMBOL(add_timer_on);
 
 /***
  * mod_timer - modify a timer's timeout
@@ -308,6 +308,8 @@
 		goto repeat;
 	}
 	list_del(&timer->entry);
+	/* Need to make sure that anybody who sees a NULL base also sees the list ops */
+	smp_wmb();
 	timer->base = NULL;
 	spin_unlock_irqrestore(&base->lock, flags);
 
@@ -789,13 +791,12 @@
 	do {
 		ticks--;
 		update_wall_time_one_tick();
+		if (xtime.tv_nsec >= 1000000000) {
+			xtime.tv_nsec -= 1000000000;
+			xtime.tv_sec++;
+			second_overflow();
+		}
 	} while (ticks);
-
-	if (xtime.tv_nsec >= 1000000000) {
-	    xtime.tv_nsec -= 1000000000;
-	    xtime.tv_sec++;
-	    second_overflow();
-	}
 }
 
 static inline void do_process_times(struct task_struct *p,
@@ -805,12 +806,13 @@
 
 	psecs = (p->utime += user);
 	psecs += (p->stime += system);
-	if (psecs / HZ >= p->rlim[RLIMIT_CPU].rlim_cur) {
+	if (p->signal && !unlikely(p->state & (EXIT_DEAD|EXIT_ZOMBIE)) &&
+	    psecs / HZ >= p->signal->rlim[RLIMIT_CPU].rlim_cur) {
 		/* Send SIGXCPU every second.. */
 		if (!(psecs % HZ))
 			send_sig(SIGXCPU, p, 1);
 		/* and SIGKILL when we go over max.. */
-		if (psecs / HZ >= p->rlim[RLIMIT_CPU].rlim_max)
+		if (psecs / HZ >= p->signal->rlim[RLIMIT_CPU].rlim_max)
 			send_sig(SIGKILL, p, 1);
 	}
 }
@@ -958,11 +960,6 @@
 void do_timer(struct pt_regs *regs)
 {
 	jiffies_64++;
-#ifndef CONFIG_SMP
-	/* SMP process accounting uses the local APIC timer */
-
-	update_process_times(user_mode(regs));
-#endif
 	update_times();
 }
 
@@ -1443,7 +1440,7 @@
 static struct time_interpolator *time_interpolator_list;
 static spinlock_t time_interpolator_lock = SPIN_LOCK_UNLOCKED;
 
-static inline unsigned long time_interpolator_get_cycles(unsigned int src)
+static inline u64 time_interpolator_get_cycles(unsigned int src)
 {
 	unsigned long (*x)(void);
 
@@ -1458,23 +1455,25 @@
 
 		case TIME_SOURCE_MMIO32	:
 			return readl(time_interpolator->addr);
+
 		default: return get_cycles();
 	}
 }
 
-static inline unsigned long time_interpolator_get_counter(void)
+static inline u64 time_interpolator_get_counter(void)
 {
 	unsigned int src = time_interpolator->source;
 
 	if (time_interpolator->jitter)
 	{
-		unsigned long lcycle;
-		unsigned long now;
+		u64 lcycle;
+		u64 now;
 
 		do {
 			lcycle = time_interpolator->last_cycle;
 			now = time_interpolator_get_cycles(src);
-			if (lcycle && time_after(lcycle, now)) return lcycle;
+			if (lcycle && time_after(lcycle, now))
+				return lcycle;
 			/* Keep track of the last timer value returned. The use of cmpxchg here
 			 * will cause contention in an SMP environment.
 			 */
@@ -1491,26 +1490,29 @@
 	time_interpolator->last_counter = time_interpolator_get_counter();
 }
 
-unsigned long time_interpolator_resolution(void)
-{
-	if (time_interpolator->frequency < NSEC_PER_SEC)
-		return NSEC_PER_SEC / time_interpolator->frequency;
-	else
-		return 1;
-}
-
-#define GET_TI_NSECS(count,i) ((((count) - i->last_counter) * i->nsec_per_cyc) >> i->shift)
+#define GET_TI_NSECS(count,i) (((((count) - i->last_counter) & (i)->mask) * (i)->nsec_per_cyc) >> (i)->shift)
 
 unsigned long time_interpolator_get_offset(void)
 {
+	/* If we do not have a time interpolator set up then just return zero */
+	if (!time_interpolator)
+		return 0;
+
 	return time_interpolator->offset +
 		GET_TI_NSECS(time_interpolator_get_counter(), time_interpolator);
 }
 
+#define INTERPOLATOR_ADJUST 65536
+#define INTERPOLATOR_MAX_SKIP 10*INTERPOLATOR_ADJUST
+
 static void time_interpolator_update(long delta_nsec)
 {
-	unsigned long counter = time_interpolator_get_counter();
-	unsigned long offset = time_interpolator->offset + GET_TI_NSECS(counter, time_interpolator);
+	u64 counter;
+	unsigned long offset;
+
+	/* If there is no time interpolator set up then do nothing */
+	if (!time_interpolator)
+		return;
 
 	/* The interpolator compensates for late ticks by accumulating
          * the late time in time_interpolator->offset. A tick earlier than
@@ -1520,6 +1522,9 @@
 	 * and the tuning logic insures that.
          */
 
+	counter = time_interpolator_get_counter();
+	offset = time_interpolator->offset + GET_TI_NSECS(counter, time_interpolator);
+
 	if (delta_nsec < 0 || (unsigned long) delta_nsec < offset)
 		time_interpolator->offset = offset - delta_nsec;
 	else {
@@ -1558,7 +1563,11 @@
 {
 	unsigned long flags;
 
-	ti->nsec_per_cyc = (NSEC_PER_SEC << ti->shift) / ti->frequency;
+	/* Sanity check */
+	if (ti->frequency == 0 || ti->mask == 0)
+		BUG();
+
+	ti->nsec_per_cyc = ((u64)NSEC_PER_SEC << ti->shift) / ti->frequency;
 	spin_lock(&time_interpolator_lock);
 	write_seqlock_irqsave(&xtime_lock, flags);
 	if (is_better_time_interpolator(ti)) {
@@ -1609,7 +1618,7 @@
  */
 void msleep(unsigned int msecs)
 {
-	unsigned long timeout = msecs_to_jiffies(msecs);
+	unsigned long timeout = msecs_to_jiffies(msecs) + 1;
 
 	while (timeout) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
@@ -1625,7 +1634,7 @@
  */
 unsigned long msleep_interruptible(unsigned int msecs)
 {
-	unsigned long timeout = msecs_to_jiffies(msecs);
+	unsigned long timeout = msecs_to_jiffies(msecs) + 1;
 
 	while (timeout && !signal_pending(current)) {
 		set_current_state(TASK_INTERRUPTIBLE);
diff -Nru a/kernel/user.c b/kernel/user.c
--- a/kernel/user.c	2004-12-24 13:36:47 -08:00
+++ b/kernel/user.c	2004-12-24 13:36:47 -08:00
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/bitops.h>
+#include <linux/key.h>
 
 /*
  * UID task count cache, to get fast user lookup in "alloc_uid"
@@ -34,6 +35,10 @@
 	.sigpending	= ATOMIC_INIT(0),
 	.mq_bytes	= 0,
 	.locked_shm     = 0,
+#ifdef CONFIG_KEYS
+	.uid_keyring	= &root_user_keyring,
+	.session_keyring = &root_session_keyring,
+#endif
 };
 
 /*
@@ -87,6 +92,8 @@
 {
 	if (up && atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
 		uid_hash_remove(up);
+		key_put(up->uid_keyring);
+		key_put(up->session_keyring);
 		kmem_cache_free(uid_cachep, up);
 		spin_unlock(&uidhash_lock);
 	}
@@ -116,6 +123,11 @@
 		new->mq_bytes = 0;
 		new->locked_shm = 0;
 
+		if (alloc_uid_keyring(new) < 0) {
+			kmem_cache_free(uid_cachep, new);
+			return NULL;
+		}
+
 		/*
 		 * Before adding this, check whether we raced
 		 * on adding the same user already..
@@ -123,6 +135,8 @@
 		spin_lock(&uidhash_lock);
 		up = uid_hash_find(uid, hashent);
 		if (up) {
+			key_put(new->uid_keyring);
+			key_put(new->session_keyring);
 			kmem_cache_free(uid_cachep, new);
 		} else {
 			uid_hash_insert(new, hashent);
@@ -146,8 +160,10 @@
 	old_user = current->user;
 	atomic_inc(&new_user->processes);
 	atomic_dec(&old_user->processes);
+	switch_uid_keyring(new_user);
 	current->user = new_user;
 	free_uid(old_user);
+	suid_keys(current);
 }
 
 
diff -Nru a/kernel/wait.c b/kernel/wait.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/wait.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,246 @@
+/*
+ * Generic waiting primitives.
+ *
+ * (C) 2004 William Irwin, Oracle
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/wait.h>
+#include <linux/hash.h>
+
+void fastcall add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
+{
+	unsigned long flags;
+
+	wait->flags &= ~WQ_FLAG_EXCLUSIVE;
+	spin_lock_irqsave(&q->lock, flags);
+	__add_wait_queue(q, wait);
+	spin_unlock_irqrestore(&q->lock, flags);
+}
+EXPORT_SYMBOL(add_wait_queue);
+
+void fastcall add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait)
+{
+	unsigned long flags;
+
+	wait->flags |= WQ_FLAG_EXCLUSIVE;
+	spin_lock_irqsave(&q->lock, flags);
+	__add_wait_queue_tail(q, wait);
+	spin_unlock_irqrestore(&q->lock, flags);
+}
+EXPORT_SYMBOL(add_wait_queue_exclusive);
+
+void fastcall remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&q->lock, flags);
+	__remove_wait_queue(q, wait);
+	spin_unlock_irqrestore(&q->lock, flags);
+}
+EXPORT_SYMBOL(remove_wait_queue);
+
+
+/*
+ * Note: we use "set_current_state()" _after_ the wait-queue add,
+ * because we need a memory barrier there on SMP, so that any
+ * wake-function that tests for the wait-queue being active
+ * will be guaranteed to see waitqueue addition _or_ subsequent
+ * tests in this thread will see the wakeup having taken place.
+ *
+ * The spin_unlock() itself is semi-permeable and only protects
+ * one way (it only protects stuff inside the critical region and
+ * stops them from bleeding out - it would still allow subsequent
+ * loads to move into the the critical region).
+ */
+void fastcall
+prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
+{
+	unsigned long flags;
+
+	wait->flags &= ~WQ_FLAG_EXCLUSIVE;
+	spin_lock_irqsave(&q->lock, flags);
+	if (list_empty(&wait->task_list))
+		__add_wait_queue(q, wait);
+	/*
+	 * don't alter the task state if this is just going to
+	 * queue an async wait queue callback
+	 */
+	if (is_sync_wait(wait))
+		set_current_state(state);
+	spin_unlock_irqrestore(&q->lock, flags);
+}
+EXPORT_SYMBOL(prepare_to_wait);
+
+void fastcall
+prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state)
+{
+	unsigned long flags;
+
+	wait->flags |= WQ_FLAG_EXCLUSIVE;
+	spin_lock_irqsave(&q->lock, flags);
+	if (list_empty(&wait->task_list))
+		__add_wait_queue_tail(q, wait);
+	/*
+	 * don't alter the task state if this is just going to
+ 	 * queue an async wait queue callback
+	 */
+	if (is_sync_wait(wait))
+		set_current_state(state);
+	spin_unlock_irqrestore(&q->lock, flags);
+}
+EXPORT_SYMBOL(prepare_to_wait_exclusive);
+
+void fastcall finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
+{
+	unsigned long flags;
+
+	__set_current_state(TASK_RUNNING);
+	/*
+	 * We can check for list emptiness outside the lock
+	 * IFF:
+	 *  - we use the "careful" check that verifies both
+	 *    the next and prev pointers, so that there cannot
+	 *    be any half-pending updates in progress on other
+	 *    CPU's that we haven't seen yet (and that might
+	 *    still change the stack area.
+	 * and
+	 *  - all other users take the lock (ie we can only
+	 *    have _one_ other CPU that looks at or modifies
+	 *    the list).
+	 */
+	if (!list_empty_careful(&wait->task_list)) {
+		spin_lock_irqsave(&q->lock, flags);
+		list_del_init(&wait->task_list);
+		spin_unlock_irqrestore(&q->lock, flags);
+	}
+}
+EXPORT_SYMBOL(finish_wait);
+
+int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key)
+{
+	int ret = default_wake_function(wait, mode, sync, key);
+
+	if (ret)
+		list_del_init(&wait->task_list);
+	return ret;
+}
+EXPORT_SYMBOL(autoremove_wake_function);
+
+int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *arg)
+{
+	struct wait_bit_key *key = arg;
+	struct wait_bit_queue *wait_bit
+		= container_of(wait, struct wait_bit_queue, wait);
+
+	if (wait_bit->key.flags != key->flags ||
+			wait_bit->key.bit_nr != key->bit_nr ||
+			test_bit(key->bit_nr, key->flags))
+		return 0;
+	else
+		return autoremove_wake_function(wait, mode, sync, key);
+}
+EXPORT_SYMBOL(wake_bit_function);
+
+/*
+ * To allow interruptible waiting and asynchronous (i.e. nonblocking)
+ * waiting, the actions of __wait_on_bit() and __wait_on_bit_lock() are
+ * permitted return codes. Nonzero return codes halt waiting and return.
+ */
+int __sched fastcall
+__wait_on_bit(wait_queue_head_t *wq, struct wait_bit_queue *q,
+			int (*action)(void *), unsigned mode)
+{
+	int ret = 0;
+
+	do {
+		prepare_to_wait(wq, &q->wait, mode);
+		if (test_bit(q->key.bit_nr, q->key.flags))
+			ret = (*action)(q->key.flags);
+	} while (test_bit(q->key.bit_nr, q->key.flags) && !ret);
+	finish_wait(wq, &q->wait);
+	return ret;
+}
+EXPORT_SYMBOL(__wait_on_bit);
+
+int __sched fastcall out_of_line_wait_on_bit(void *word, int bit,
+					int (*action)(void *), unsigned mode)
+{
+	wait_queue_head_t *wq = bit_waitqueue(word, bit);
+	DEFINE_WAIT_BIT(wait, word, bit);
+
+	return __wait_on_bit(wq, &wait, action, mode);
+}
+EXPORT_SYMBOL(out_of_line_wait_on_bit);
+
+int __sched fastcall
+__wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q,
+			int (*action)(void *), unsigned mode)
+{
+	int ret = 0;
+
+	do {
+		prepare_to_wait_exclusive(wq, &q->wait, mode);
+		if (test_bit(q->key.bit_nr, q->key.flags)) {
+			if ((ret = (*action)(q->key.flags)))
+				break;
+		}
+	} while (test_and_set_bit(q->key.bit_nr, q->key.flags));
+	finish_wait(wq, &q->wait);
+	return ret;
+}
+EXPORT_SYMBOL(__wait_on_bit_lock);
+
+int __sched fastcall out_of_line_wait_on_bit_lock(void *word, int bit,
+					int (*action)(void *), unsigned mode)
+{
+	wait_queue_head_t *wq = bit_waitqueue(word, bit);
+	DEFINE_WAIT_BIT(wait, word, bit);
+
+	return __wait_on_bit_lock(wq, &wait, action, mode);
+}
+EXPORT_SYMBOL(out_of_line_wait_on_bit_lock);
+
+void fastcall __wake_up_bit(wait_queue_head_t *wq, void *word, int bit)
+{
+	struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit);
+	if (waitqueue_active(wq))
+		__wake_up(wq, TASK_INTERRUPTIBLE|TASK_UNINTERRUPTIBLE, 1, &key);
+}
+EXPORT_SYMBOL(__wake_up_bit);
+
+/**
+ * wake_up_bit - wake up a waiter on a bit
+ * @word: the word being waited on, a kernel virtual address
+ * @bit: the bit of the word being waited on
+ *
+ * There is a standard hashed waitqueue table for generic use. This
+ * is the part of the hashtable's accessor API that wakes up waiters
+ * on a bit. For instance, if one were to have waiters on a bitflag,
+ * one would call wake_up_bit() after clearing the bit.
+ *
+ * In order for this to function properly, as it uses waitqueue_active()
+ * internally, some kind of memory barrier must be done prior to calling
+ * this. Typically, this will be smp_mb__after_clear_bit(), but in some
+ * cases where bitflags are manipulated non-atomically under a lock, one
+ * may need to use a less regular barrier, such fs/inode.c's smp_mb(),
+ * because spin_unlock() does not guarantee a memory barrier.
+ */
+void fastcall wake_up_bit(void *word, int bit)
+{
+	__wake_up_bit(bit_waitqueue(word, bit), word, bit);
+}
+EXPORT_SYMBOL(wake_up_bit);
+
+fastcall wait_queue_head_t *bit_waitqueue(void *word, int bit)
+{
+	const int shift = BITS_PER_LONG == 32 ? 5 : 6;
+	const struct zone *zone = page_zone(virt_to_page(word));
+	unsigned long val = (unsigned long)word << shift | bit;
+
+	return &zone->wait_table[hash_long(val, zone->wait_table_bits)];
+}
+EXPORT_SYMBOL(bit_waitqueue);
diff -Nru a/lib/Kconfig b/lib/Kconfig
--- a/lib/Kconfig	2004-12-24 13:36:59 -08:00
+++ b/lib/Kconfig	2004-12-24 13:36:59 -08:00
@@ -39,5 +39,23 @@
 config ZLIB_DEFLATE
 	tristate
 
+#
+# reed solomon support is select'ed if needed
+#
+config REED_SOLOMON
+	tristate
+	
+config REED_SOLOMON_ENC8
+	boolean
+
+config REED_SOLOMON_DEC8
+	boolean
+
+config REED_SOLOMON_ENC16
+	boolean
+
+config REED_SOLOMON_DEC16
+	boolean
+
 endmenu
 
diff -Nru a/lib/Kconfig.debug b/lib/Kconfig.debug
--- a/lib/Kconfig.debug	2004-12-24 13:37:18 -08:00
+++ b/lib/Kconfig.debug	2004-12-24 13:37:18 -08:00
@@ -1,14 +1,14 @@
 
 config DEBUG_KERNEL
 	bool "Kernel debugging"
-	depends on (ALPHA || ARM || CRIS || H8300 || X86 || IA64 || M68K || M68KNOMMU || MIPS || PARISC || PPC32 || PPC64 || ARCH_S390 || SUPERH || SUPERH64 || SPARC32 || SPARC64 || USERMODE || V850 || X86_64)
+	depends on (ALPHA || ARM || CRIS || H8300 || X86 || IA64 || M32R || M68K || M68KNOMMU || MIPS || PARISC || PPC32 || PPC64 || ARCH_S390 || SUPERH || SUPERH64 || SPARC32 || SPARC64 || USERMODE || V850 || X86_64)
 	help
 	  Say Y here if you are developing drivers or trying to debug and
 	  identify kernel problems.
 
 config MAGIC_SYSRQ
 	bool "Magic SysRq key"
-	depends on DEBUG_KERNEL && (ALPHA || ARM || X86 || IA64 || M68K || MIPS || PARISC || PPC32 || PPC64 || ARCH_S390 || SUPERH || SUPERH64 || SPARC32 || SPARC64 || X86_64)
+	depends on DEBUG_KERNEL && (ALPHA || ARM || X86 || IA64 || M32R || M68K || MIPS || PARISC || PPC32 || PPC64 || ARCH_S390 || SUPERH || SUPERH64 || SPARC32 || SPARC64 || X86_64 || USERMODE)
 	help
 	  If you say Y here, you will have some control over the system even
 	  if the system crashes for example during kernel debugging (e.g., you
@@ -28,17 +28,29 @@
 	  Enables console device to interpret special characters as
 	  commands to dump state information.
 
+config SCHEDSTATS
+	bool "Collect scheduler statistics"
+	depends on DEBUG_KERNEL && PROC_FS
+	help
+	  If you say Y here, additional code will be inserted into the
+	  scheduler and related routines to collect statistics about
+	  scheduler behavior and provide them in /proc/schedstat.  These
+	  stats may be useful for both tuning and debugging the scheduler
+	  If you aren't debugging the scheduler or trying to tune a specific
+	  application, you can say N to avoid the very slight overhead
+	  this adds.
+
 config DEBUG_SLAB
 	bool "Debug memory allocations"
-	depends on DEBUG_KERNEL && (ALPHA || ARM || X86 || IA64 || M68K || MIPS || PARISC || PPC32 || PPC64 || ARCH_S390 || SPARC32 || SPARC64 || USERMODE || X86_64)
+	depends on DEBUG_KERNEL && (ALPHA || ARM || X86 || IA64 || M32R || M68K || MIPS || PARISC || PPC32 || PPC64 || ARCH_S390 || SPARC32 || SPARC64 || USERMODE || X86_64)
 	help
 	  Say Y here to have the kernel do limited verification on memory
 	  allocation as well as poisoning memory on free to catch use of freed
-	  memory.
+	  memory. This can make kmalloc/kfree-intensive workloads much slower.
 
 config DEBUG_SPINLOCK
 	bool "Spinlock debugging"
-	depends on DEBUG_KERNEL && (ALPHA || ARM || X86 || IA64 || MIPS || PPC32 || (SUPERH && !SUPERH64) || SPARC32 || SPARC64 || USERMODE || X86_64)
+	depends on DEBUG_KERNEL && (ALPHA || ARM || X86 || IA64 || M32R || MIPS || PARISC || PPC32 || (SUPERH && !SUPERH64) || SPARC32 || SPARC64 || USERMODE || X86_64)
 	help
 	  Say Y here and build SMP to catch missing spinlock initialization
 	  and certain other kinds of spinlock errors commonly made.  This is
@@ -47,11 +59,18 @@
 
 config DEBUG_SPINLOCK_SLEEP
 	bool "Sleep-inside-spinlock checking"
-	depends on DEBUG_KERNEL && (X86 || IA64 || MIPS || PPC32 || PPC64 || ARCH_S390 || SPARC32 || SPARC64)
+	depends on DEBUG_KERNEL && (X86 || IA64 || M32R || MIPS || PPC32 || PPC64 || ARCH_S390 || SPARC32 || SPARC64 || USERMODE)
 	help
 	  If you say Y here, various routines which may sleep will become very
 	  noisy if they are called with a spinlock held.
 
+config DEBUG_KOBJECT
+	bool "kobject debugging"
+	depends on DEBUG_KERNEL
+	help
+	  If you say Y here, some extra kobject debugging messages will be sent
+	  to the syslog. 
+
 config DEBUG_HIGHMEM
 	bool "Highmem debugging"
 	depends on DEBUG_KERNEL && HIGHMEM && (X86 || PPC32 || MIPS || SPARC32)
@@ -61,7 +80,7 @@
 
 config DEBUG_BUGVERBOSE
 	bool "Verbose BUG() reporting (adds 70K)"
-	depends on DEBUG_KERNEL && (ARM || ARM26 || M68K || SPARC32 || SPARC64)
+	depends on DEBUG_KERNEL && (ARM || ARM26 || M32R || M68K || SPARC32 || SPARC64)
 	help
 	  Say Y here to make BUG() panics output the file name and line number
 	  of the BUG call as well as the EIP and oops trace.  This aids
@@ -69,7 +88,7 @@
 
 config DEBUG_INFO
 	bool "Compile the kernel with debug info"
-	depends on DEBUG_KERNEL && (ALPHA || CRIS || X86 || IA64 || M68K || MIPS || PARISC || PPC32 || PPC64 || ARCH_S390 || (SUPERH && !SUPERH64) || SPARC64 || V850 || X86_64)
+	depends on DEBUG_KERNEL && (ALPHA || CRIS || X86 || IA64 || M32R || M68K || MIPS || PARISC || PPC32 || PPC64 || ARCH_S390 || (SUPERH && !SUPERH64) || SPARC64 || V850 || X86_64)
 	help
           If you say Y here the resulting kernel image will include
 	  debugging info resulting in a larger kernel image.
@@ -91,7 +110,7 @@
 if !X86_64
 config FRAME_POINTER
 	bool "Compile the kernel with frame pointers"
-	depends on X86 || CRIS || M68KNOMMU || PARISC
+	depends on X86 || CRIS || M68KNOMMU
 	help
 	  If you say Y here the resulting kernel image will be slightly larger
 	  and slower, but it will give very useful debugging information.
diff -Nru a/lib/Makefile b/lib/Makefile
--- a/lib/Makefile	2004-12-24 13:36:17 -08:00
+++ b/lib/Makefile	2004-12-24 13:36:17 -08:00
@@ -2,14 +2,19 @@
 # Makefile for some libs needed in the kernel.
 #
 
-
 lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
 	 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
 	 kobject.o kref.o idr.o div64.o parser.o int_sqrt.o \
-	 bitmap.o extable.o
+	 bitmap.o extable.o kobject_uevent.o
+
+ifeq ($(CONFIG_DEBUG_KOBJECT),y)
+CFLAGS_kobject.o += -DDEBUG
+CFLAGS_kobject_uevent.o += -DDEBUG
+endif
 
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
+obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
 
 ifneq ($(CONFIG_HAVE_DEC_LOCK),y) 
   lib-y += dec_and_lock.o
@@ -22,6 +27,7 @@
 
 obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
 obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
+obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
 
 hostprogs-y	:= gen_crc32table
 clean-files	:= crc32table.h
diff -Nru a/lib/bitmap.c b/lib/bitmap.c
--- a/lib/bitmap.c	2004-12-24 13:37:18 -08:00
+++ b/lib/bitmap.c	2004-12-24 13:37:18 -08:00
@@ -9,7 +9,7 @@
 #include <linux/ctype.h>
 #include <linux/errno.h>
 #include <linux/bitmap.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 
 /*
diff -Nru a/lib/dec_and_lock.c b/lib/dec_and_lock.c
--- a/lib/dec_and_lock.c	2004-12-24 13:37:43 -08:00
+++ b/lib/dec_and_lock.c	2004-12-24 13:37:43 -08:00
@@ -27,7 +27,7 @@
  */
 
 #ifndef ATOMIC_DEC_AND_LOCK
-int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
+int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
 {
 	spin_lock(lock);
 	if (atomic_dec_and_test(atomic))
@@ -36,5 +36,5 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(atomic_dec_and_lock);
+EXPORT_SYMBOL(_atomic_dec_and_lock);
 #endif
diff -Nru a/lib/idr.c b/lib/idr.c
--- a/lib/idr.c	2004-12-24 13:37:43 -08:00
+++ b/lib/idr.c	2004-12-24 13:37:43 -08:00
@@ -39,13 +39,11 @@
 	struct idr_layer *p;
 
 	spin_lock(&idp->lock);
-	if (!(p = idp->id_free)) {
-		spin_unlock(&idp->lock);
-		return NULL;
+	if ((p = idp->id_free)) {
+		idp->id_free = p->ary[0];
+		idp->id_free_cnt--;
+		p->ary[0] = NULL;
 	}
-	idp->id_free = p->ary[0];
-	idp->id_free_cnt--;
-	p->ary[0] = NULL;
 	spin_unlock(&idp->lock);
 	return(p);
 }
@@ -277,24 +275,31 @@
 }
 EXPORT_SYMBOL(idr_get_new);
 
+static void idr_remove_warning(int id)
+{
+	printk("idr_remove called for id=%d which is not allocated.\n", id);
+	dump_stack();
+}
+
 static void sub_remove(struct idr *idp, int shift, int id)
 {
 	struct idr_layer *p = idp->top;
 	struct idr_layer **pa[MAX_LEVEL];
 	struct idr_layer ***paa = &pa[0];
+	int n;
 
 	*paa = NULL;
 	*++paa = &idp->top;
 
 	while ((shift > 0) && p) {
-		int n = (id >> shift) & IDR_MASK;
+		n = (id >> shift) & IDR_MASK;
 		__clear_bit(n, &p->bitmap);
 		*++paa = &p->ary[n];
 		p = p->ary[n];
 		shift -= IDR_BITS;
 	}
-	if (likely(p != NULL)){
-		int n = id & IDR_MASK;
+	n = id & IDR_MASK;
+	if (likely(p != NULL && test_bit(n, &p->bitmap))){
 		__clear_bit(n, &p->bitmap);
 		p->ary[n] = NULL;
 		while(*paa && ! --((**paa)->count)){
@@ -303,6 +308,8 @@
 		}
 		if ( ! *paa )
 			idp->layers = 0;
+	} else {
+		idr_remove_warning(id);
 	}
 }
 
diff -Nru a/lib/inflate.c b/lib/inflate.c
--- a/lib/inflate.c	2004-12-24 13:36:48 -08:00
+++ b/lib/inflate.c	2004-12-24 13:36:48 -08:00
@@ -118,6 +118,10 @@
 #include "gzip.h"
 #define STATIC
 #endif /* !STATIC */
+
+#ifndef INIT
+#define INIT
+#endif
 	
 #define slide window
 
@@ -139,15 +143,15 @@
 
 
 /* Function prototypes */
-STATIC int huft_build OF((unsigned *, unsigned, unsigned, 
+STATIC int INIT huft_build OF((unsigned *, unsigned, unsigned, 
 		const ush *, const ush *, struct huft **, int *));
-STATIC int huft_free OF((struct huft *));
-STATIC int inflate_codes OF((struct huft *, struct huft *, int, int));
-STATIC int inflate_stored OF((void));
-STATIC int inflate_fixed OF((void));
-STATIC int inflate_dynamic OF((void));
-STATIC int inflate_block OF((int *));
-STATIC int inflate OF((void));
+STATIC int INIT huft_free OF((struct huft *));
+STATIC int INIT inflate_codes OF((struct huft *, struct huft *, int, int));
+STATIC int INIT inflate_stored OF((void));
+STATIC int INIT inflate_fixed OF((void));
+STATIC int INIT inflate_dynamic OF((void));
+STATIC int INIT inflate_block OF((int *));
+STATIC int INIT inflate OF((void));
 
 
 /* The inflate algorithm uses a sliding 32 K byte window on the uncompressed
@@ -272,7 +276,7 @@
 STATIC unsigned hufts;         /* track memory usage */
 
 
-STATIC int huft_build(
+STATIC int INIT huft_build(
 	unsigned *b,            /* code lengths in bits (all assumed <= BMAX) */
 	unsigned n,             /* number of codes (assumed <= N_MAX) */
 	unsigned s,             /* number of simple-valued codes (0..s-1) */
@@ -491,7 +495,7 @@
 
 
 
-STATIC int huft_free(
+STATIC int INIT huft_free(
 	struct huft *t         /* table to free */
 	)
 /* Free the malloc'ed tables built by huft_build(), which makes a linked
@@ -513,7 +517,7 @@
 }
 
 
-STATIC int inflate_codes(
+STATIC int INIT inflate_codes(
 	struct huft *tl,    /* literal/length decoder tables */
 	struct huft *td,    /* distance decoder tables */
 	int bl,             /* number of bits decoded by tl[] */
@@ -628,7 +632,7 @@
 
 
 
-STATIC int inflate_stored(void)
+STATIC int INIT inflate_stored(void)
 /* "decompress" an inflated type 0 (stored) block. */
 {
   unsigned n;           /* number of bytes in block */
@@ -689,7 +693,7 @@
 /*
  * We use `noinline' here to prevent gcc-3.5 from using too much stack space
  */
-STATIC int noinline inflate_fixed(void)
+STATIC int noinline INIT inflate_fixed(void)
 /* decompress an inflated type 1 (fixed Huffman codes) block.  We should
    either replace this with a custom decoder, or at least precompute the
    Huffman tables. */
@@ -745,7 +749,7 @@
 /*
  * We use `noinline' here to prevent gcc-3.5 from using too much stack space
  */
-STATIC int noinline inflate_dynamic(void)
+STATIC int noinline INIT inflate_dynamic(void)
 /* decompress an inflated type 2 (dynamic Huffman codes) block. */
 {
   int i;                /* temporary variables */
@@ -926,7 +930,7 @@
 
 
 
-STATIC int inflate_block(
+STATIC int INIT inflate_block(
 	int *e                  /* last block flag */
 	)
 /* decompress an inflated block */
@@ -977,7 +981,7 @@
 
 
 
-STATIC int inflate(void)
+STATIC int INIT inflate(void)
 /* decompress an inflated entry */
 {
   int e;                /* last block flag */
@@ -1039,7 +1043,7 @@
  * gzip-1.0.3/makecrc.c.
  */
 
-static void
+static void INIT
 makecrc(void)
 {
 /* Not copyrighted 1990 Mark Adler	*/
@@ -1087,7 +1091,7 @@
 /*
  * Do the uncompression!
  */
-static int gunzip(void)
+static int INIT gunzip(void)
 {
     uch flags;
     unsigned char magic[2]; /* magic header */
diff -Nru a/lib/iomap.c b/lib/iomap.c
--- a/lib/iomap.c	2004-12-24 13:36:17 -08:00
+++ b/lib/iomap.c	2004-12-24 13:36:17 -08:00
@@ -1,5 +1,7 @@
 /*
  * Implement the default iomap interfaces
+ *
+ * (C) Copyright 2004 Linus Torvalds
  */
 #include <linux/pci.h>
 #include <linux/module.h>
@@ -17,7 +19,10 @@
  *
  * Architectures for which this is not true can't use this generic
  * implementation and should do their own copy.
- *
+ */
+
+#ifndef HAVE_ARCH_PIO_SIZE
+/*
  * We encode the physical PIO addresses (0-0xffff) into the
  * pointer by offsetting them with a constant (0x10000) and
  * assuming that all the low addresses are always PIO. That means
@@ -27,6 +32,7 @@
 #define PIO_OFFSET	0x10000UL
 #define PIO_MASK	0x0ffffUL
 #define PIO_RESERVED	0x40000UL
+#endif
 
 /*
  * Ugly macros are a way of life.
diff -Nru a/lib/kernel_lock.c b/lib/kernel_lock.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/lib/kernel_lock.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,126 @@
+/*
+ * lib/kernel_lock.c
+ *
+ * This is the traditional BKL - big kernel lock. Largely
+ * relegated to obsolescense, but used by various less
+ * important (or lazy) subsystems.
+ */
+#include <linux/smp_lock.h>
+#include <linux/module.h>
+
+/*
+ * The 'big kernel lock'
+ *
+ * This spinlock is taken and released recursively by lock_kernel()
+ * and unlock_kernel().  It is transparently dropped and reaquired
+ * over schedule().  It is used to protect legacy code that hasn't
+ * been migrated to a proper locking design yet.
+ *
+ * Don't use in new code.
+ */
+static spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
+
+
+/*
+ * Acquire/release the underlying lock from the scheduler.
+ *
+ * This is called with preemption disabled, and should
+ * return an error value if it cannot get the lock and
+ * TIF_NEED_RESCHED gets set.
+ *
+ * If it successfully gets the lock, it should increment
+ * the preemption count like any spinlock does.
+ *
+ * (This works on UP too - _raw_spin_trylock will never
+ * return false in that case)
+ */
+int __lockfunc get_kernel_lock(void)
+{
+	while (!_raw_spin_trylock(&kernel_flag)) {
+		if (test_thread_flag(TIF_NEED_RESCHED))
+			return -EAGAIN;
+		cpu_relax();
+	}
+	preempt_disable();
+	return 0;
+}
+
+void __lockfunc put_kernel_lock(void)
+{
+	_raw_spin_unlock(&kernel_flag);
+	preempt_enable_no_resched();
+}
+
+/*
+ * These are the BKL spinlocks - we try to be polite about preemption. 
+ * If SMP is not on (ie UP preemption), this all goes away because the
+ * _raw_spin_trylock() will always succeed.
+ */
+#ifdef CONFIG_PREEMPT
+static inline void __lock_kernel(void)
+{
+	preempt_disable();
+	if (unlikely(!_raw_spin_trylock(&kernel_flag))) {
+		/*
+		 * If preemption was disabled even before this
+		 * was called, there's nothing we can be polite
+		 * about - just spin.
+		 */
+		if (preempt_count() > 1) {
+			_raw_spin_lock(&kernel_flag);
+			return;
+		}
+
+		/*
+		 * Otherwise, let's wait for the kernel lock
+		 * with preemption enabled..
+		 */
+		do {
+			preempt_enable();
+			while (spin_is_locked(&kernel_flag))
+				cpu_relax();
+			preempt_disable();
+		} while (!_raw_spin_trylock(&kernel_flag));
+	}
+}
+
+#else
+
+/*
+ * Non-preemption case - just get the spinlock
+ */
+static inline void __lock_kernel(void)
+{
+	_raw_spin_lock(&kernel_flag);
+}
+#endif
+
+static inline void __unlock_kernel(void)
+{
+	_raw_spin_unlock(&kernel_flag);
+	preempt_enable();
+}
+
+/*
+ * Getting the big kernel lock.
+ *
+ * This cannot happen asynchronously, so we only need to
+ * worry about other CPU's.
+ */
+void __lockfunc lock_kernel(void)
+{
+	int depth = current->lock_depth+1;
+	if (likely(!depth))
+		__lock_kernel();
+	current->lock_depth = depth;
+}
+
+void __lockfunc unlock_kernel(void)
+{
+	BUG_ON(current->lock_depth < 0);
+	if (likely(--current->lock_depth < 0))
+		__unlock_kernel();
+}
+
+EXPORT_SYMBOL(lock_kernel);
+EXPORT_SYMBOL(unlock_kernel);
diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c	2004-12-24 13:37:19 -08:00
+++ b/lib/kobject.c	2004-12-24 13:37:19 -08:00
@@ -10,8 +10,6 @@
  * about using the kobject interface.
  */
 
-#undef DEBUG
-
 #include <linux/kobject.h>
 #include <linux/string.h>
 #include <linux/module.h>
@@ -63,7 +61,7 @@
 	return container_of(entry,struct kobject,entry);
 }
 
-static int get_kobj_path_length(struct kset *kset, struct kobject *kobj)
+static int get_kobj_path_length(struct kobject *kobj)
 {
 	int length = 1;
 	struct kobject * parent = kobj;
@@ -79,7 +77,7 @@
 	return length;
 }
 
-static void fill_kobj_path(struct kset *kset, struct kobject *kobj, char *path, int length)
+static void fill_kobj_path(struct kobject *kobj, char *path, int length)
 {
 	struct kobject * parent;
 
@@ -99,153 +97,31 @@
  * kobject_get_path - generate and return the path associated with a given kobj
  * and kset pair.  The result must be freed by the caller with kfree().
  *
- * @kset:	kset in question, with which to build the path
  * @kobj:	kobject in question, with which to build the path
  * @gfp_mask:	the allocation type used to allocate the path
  */
-char * kobject_get_path(struct kset *kset, struct kobject *kobj, int gfp_mask)
+char *kobject_get_path(struct kobject *kobj, int gfp_mask)
 {
 	char *path;
 	int len;
 
-	len = get_kobj_path_length(kset, kobj);
+	len = get_kobj_path_length(kobj);
 	path = kmalloc(len, gfp_mask);
 	if (!path)
 		return NULL;
 	memset(path, 0x00, len);
-	fill_kobj_path(kset, kobj, path, len);
+	fill_kobj_path(kobj, path, len);
 
 	return path;
 }
 
-#ifdef CONFIG_HOTPLUG
-
-#define BUFFER_SIZE	1024	/* should be enough memory for the env */
-#define NUM_ENVP	32	/* number of env pointers */
-static unsigned long sequence_num;
-static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
-
-static void kset_hotplug(const char *action, struct kset *kset,
-			 struct kobject *kobj)
-{
-	char *argv [3];
-	char **envp = NULL;
-	char *buffer = NULL;
-	char *scratch;
-	int i = 0;
-	int retval;
-	char *kobj_path = NULL;
-	char *name = NULL;
-	unsigned long seq;
-
-	/* If the kset has a filter operation, call it. If it returns
-	   failure, no hotplug event is required. */
-	if (kset->hotplug_ops->filter) {
-		if (!kset->hotplug_ops->filter(kset, kobj))
-			return;
-	}
-
-	pr_debug ("%s\n", __FUNCTION__);
-
-	if (!hotplug_path[0])
-		return;
-
-	envp = kmalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL);
-	if (!envp)
-		return;
-	memset (envp, 0x00, NUM_ENVP * sizeof (char *));
-
-	buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL);
-	if (!buffer)
-		goto exit;
-
-	if (kset->hotplug_ops->name)
-		name = kset->hotplug_ops->name(kset, kobj);
-	if (name == NULL)
-		name = kset->kobj.name;
-
-	argv [0] = hotplug_path;
-	argv [1] = name;
-	argv [2] = NULL;
-
-	/* minimal command environment */
-	envp [i++] = "HOME=/";
-	envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
-
-	scratch = buffer;
-
-	envp [i++] = scratch;
-	scratch += sprintf(scratch, "ACTION=%s", action) + 1;
-
-	spin_lock(&sequence_lock);
-	seq = sequence_num++;
-	spin_unlock(&sequence_lock);
-
-	envp [i++] = scratch;
-	scratch += sprintf(scratch, "SEQNUM=%ld", seq) + 1;
-
-	kobj_path = kobject_get_path(kset, kobj, GFP_KERNEL);
-	if (!kobj_path)
-		goto exit;
-
-	envp [i++] = scratch;
-	scratch += sprintf (scratch, "DEVPATH=%s", kobj_path) + 1;
-
-	if (kset->hotplug_ops->hotplug) {
-		/* have the kset specific function add its stuff */
-		retval = kset->hotplug_ops->hotplug (kset, kobj,
-				  &envp[i], NUM_ENVP - i, scratch,
-				  BUFFER_SIZE - (scratch - buffer));
-		if (retval) {
-			pr_debug ("%s - hotplug() returned %d\n",
-				  __FUNCTION__, retval);
-			goto exit;
-		}
-	}
-
-	pr_debug ("%s: %s %s %s %s %s %s %s\n", __FUNCTION__, argv[0], argv[1],
-		  envp[0], envp[1], envp[2], envp[3], envp[4]);
-	retval = call_usermodehelper (argv[0], argv, envp, 0);
-	if (retval)
-		pr_debug ("%s - call_usermodehelper returned %d\n",
-			  __FUNCTION__, retval);
-
-exit:
-	kfree(kobj_path);
-	kfree(buffer);
-	kfree(envp);
-	return;
-}
-
-void kobject_hotplug(const char *action, struct kobject *kobj)
-{
-	struct kobject * top_kobj = kobj;
-
-	/* If this kobj does not belong to a kset,
-	   try to find a parent that does. */
-	if (!top_kobj->kset && top_kobj->parent) {
-		do {
-			top_kobj = top_kobj->parent;
-		} while (!top_kobj->kset && top_kobj->parent);
-	}
-
-	if (top_kobj->kset && top_kobj->kset->hotplug_ops)
-		kset_hotplug(action, top_kobj->kset, kobj);
-}
-#else
-void kobject_hotplug(const char *action, struct kobject *kobj)
-{
-	return;
-}
-#endif	/* CONFIG_HOTPLUG */
-
 /**
  *	kobject_init - initialize object.
  *	@kobj:	object in question.
  */
 void kobject_init(struct kobject * kobj)
 {
- 	kref_init(&kobj->kref);
+	kref_init(&kobj->kref);
 	INIT_LIST_HEAD(&kobj->entry);
 	kobj->kset = kset_get(kobj->kset);
 }
@@ -304,11 +180,12 @@
 
 	error = create_dir(kobj);
 	if (error) {
+		/* unlink does the kobject_put() for us */
 		unlink(kobj);
 		if (parent)
 			kobject_put(parent);
 	} else {
-		kobject_hotplug("add", kobj);
+		kobject_hotplug(kobj, KOBJ_ADD);
 	}
 
 	return error;
@@ -355,11 +232,12 @@
 	va_list args;
 	char * name;
 
-	va_start(args,fmt);
 	/* 
 	 * First, try the static array 
 	 */
+	va_start(args,fmt);
 	need = vsnprintf(kobj->name,limit,fmt,args);
+	va_end(args);
 	if (need < limit) 
 		name = kobj->name;
 	else {
@@ -372,7 +250,9 @@
 			error = -ENOMEM;
 			goto Done;
 		}
+		va_start(args,fmt);
 		need = vsnprintf(name,limit,fmt,args);
+		va_end(args);
 
 		/* Still? Give up. */
 		if (need >= limit) {
@@ -389,7 +269,6 @@
 	/* Now, set the new name */
 	kobj->k_name = name;
  Done:
-	va_end(args);
 	return error;
 }
 
@@ -422,7 +301,7 @@
 
 void kobject_del(struct kobject * kobj)
 {
-	kobject_hotplug("remove", kobj);
+	kobject_hotplug(kobj, KOBJ_REMOVE);
 	sysfs_remove_dir(kobj);
 	unlink(kobj);
 }
@@ -654,7 +533,6 @@
 EXPORT_SYMBOL(kobject_add);
 EXPORT_SYMBOL(kobject_del);
 EXPORT_SYMBOL(kobject_rename);
-EXPORT_SYMBOL(kobject_hotplug);
 
 EXPORT_SYMBOL(kset_register);
 EXPORT_SYMBOL(kset_unregister);
diff -Nru a/lib/kobject_uevent.c b/lib/kobject_uevent.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/lib/kobject_uevent.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,369 @@
+/*
+ * kernel userspace event delivery
+ *
+ * Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+ * Copyright (C) 2004 Novell, Inc.  All rights reserved.
+ * Copyright (C) 2004 IBM, Inc. All rights reserved.
+ *
+ * Licensed under the GNU GPL v2.
+ *
+ * Authors:
+ *	Robert Love		<rml@novell.com>
+ *	Kay Sievers		<kay.sievers@vrfy.org>
+ *	Arjan van de Ven	<arjanv@redhat.com>
+ *	Greg Kroah-Hartman	<greg@kroah.com>
+ */
+
+#include <linux/spinlock.h>
+#include <linux/socket.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <linux/string.h>
+#include <linux/kobject_uevent.h>
+#include <linux/kobject.h>
+#include <net/sock.h>
+
+#define BUFFER_SIZE	1024	/* buffer for the hotplug env */
+#define NUM_ENVP	32	/* number of env pointers */
+
+#if defined(CONFIG_KOBJECT_UEVENT) || defined(CONFIG_HOTPLUG)
+static char *action_to_string(enum kobject_action action)
+{
+	switch (action) {
+	case KOBJ_ADD:
+		return "add";
+	case KOBJ_REMOVE:
+		return "remove";
+	case KOBJ_CHANGE:
+		return "change";
+	case KOBJ_MOUNT:
+		return "mount";
+	case KOBJ_UMOUNT:
+		return "umount";
+	case KOBJ_OFFLINE:
+		return "offline";
+	case KOBJ_ONLINE:
+		return "online";
+	default:
+		return NULL;
+	}
+}
+#endif
+
+#ifdef CONFIG_KOBJECT_UEVENT
+static struct sock *uevent_sock;
+
+/**
+ * send_uevent - notify userspace by sending event trough netlink socket
+ *
+ * @signal: signal name
+ * @obj: object path (kobject)
+ * @envp: possible hotplug environment to pass with the message
+ * @gfp_mask:
+ */
+static int send_uevent(const char *signal, const char *obj,
+		       char **envp, int gfp_mask)
+{
+	struct sk_buff *skb;
+	char *pos;
+	int len;
+
+	if (!uevent_sock)
+		return -EIO;
+
+	len = strlen(signal) + 1;
+	len += strlen(obj) + 1;
+
+	/* allocate buffer with the maximum possible message size */
+	skb = alloc_skb(len + BUFFER_SIZE, gfp_mask);
+	if (!skb)
+		return -ENOMEM;
+
+	pos = skb_put(skb, len);
+	sprintf(pos, "%s@%s", signal, obj);
+
+	/* copy the environment key by key to our continuous buffer */
+	if (envp) {
+		int i;
+
+		for (i = 2; envp[i]; i++) {
+			len = strlen(envp[i]) + 1;
+			pos = skb_put(skb, len);
+			strcpy(pos, envp[i]);
+		}
+	}
+
+	return netlink_broadcast(uevent_sock, skb, 0, 1, gfp_mask);
+}
+
+static int do_kobject_uevent(struct kobject *kobj, enum kobject_action action, 
+			     struct attribute *attr, int gfp_mask)
+{
+	char *path;
+	char *attrpath;
+	char *signal;
+	int len;
+	int rc = -ENOMEM;
+
+	path = kobject_get_path(kobj, gfp_mask);
+	if (!path)
+		return -ENOMEM;
+
+	signal = action_to_string(action);
+	if (!signal)
+		return -EINVAL;
+
+	if (attr) {
+		len = strlen(path);
+		len += strlen(attr->name) + 2;
+		attrpath = kmalloc(len, gfp_mask);
+		if (!attrpath)
+			goto exit;
+		sprintf(attrpath, "%s/%s", path, attr->name);
+		rc = send_uevent(signal, attrpath, NULL, gfp_mask);
+		kfree(attrpath);
+	} else
+		rc = send_uevent(signal, path, NULL, gfp_mask);
+
+exit:
+	kfree(path);
+	return rc;
+}
+
+/**
+ * kobject_uevent - notify userspace by sending event through netlink socket
+ * 
+ * @signal: signal name
+ * @kobj: struct kobject that the event is happening to
+ * @attr: optional struct attribute the event belongs to
+ */
+int kobject_uevent(struct kobject *kobj, enum kobject_action action,
+		   struct attribute *attr)
+{
+	return do_kobject_uevent(kobj, action, attr, GFP_KERNEL);
+}
+EXPORT_SYMBOL_GPL(kobject_uevent);
+
+int kobject_uevent_atomic(struct kobject *kobj, enum kobject_action action,
+			  struct attribute *attr)
+{
+	return do_kobject_uevent(kobj, action, attr, GFP_ATOMIC);
+}
+EXPORT_SYMBOL_GPL(kobject_uevent_atomic);
+
+static int __init kobject_uevent_init(void)
+{
+	uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, NULL);
+
+	if (!uevent_sock) {
+		printk(KERN_ERR
+		       "kobject_uevent: unable to create netlink socket!\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+postcore_initcall(kobject_uevent_init);
+
+#else
+static inline int send_uevent(const char *signal, const char *obj,
+			      char **envp, int gfp_mask)
+{
+	return 0;
+}
+
+#endif /* CONFIG_KOBJECT_UEVENT */
+
+
+#ifdef CONFIG_HOTPLUG
+char hotplug_path[HOTPLUG_PATH_LEN] = "/sbin/hotplug";
+u64 hotplug_seqnum;
+static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
+
+/**
+ * kobject_hotplug - notify userspace by executing /sbin/hotplug
+ *
+ * @action: action that is happening (usually "ADD" or "REMOVE")
+ * @kobj: struct kobject that the action is happening to
+ */
+void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
+{
+	char *argv [3];
+	char **envp = NULL;
+	char *buffer = NULL;
+	char *seq_buff;
+	char *scratch;
+	int i = 0;
+	int retval;
+	char *kobj_path = NULL;
+	char *name = NULL;
+	char *action_string;
+	u64 seq;
+	struct kobject *top_kobj = kobj;
+	struct kset *kset;
+	static struct kset_hotplug_ops null_hotplug_ops;
+	struct kset_hotplug_ops *hotplug_ops = &null_hotplug_ops;
+
+	/* If this kobj does not belong to a kset,
+	   try to find a parent that does. */
+	if (!top_kobj->kset && top_kobj->parent) {
+		do {
+			top_kobj = top_kobj->parent;
+		} while (!top_kobj->kset && top_kobj->parent);
+	}
+
+	if (top_kobj->kset)
+		kset = top_kobj->kset;
+	else
+		return;
+
+	if (kset->hotplug_ops)
+		hotplug_ops = kset->hotplug_ops;
+
+	/* If the kset has a filter operation, call it.
+	   Skip the event, if the filter returns zero. */
+	if (hotplug_ops->filter) {
+		if (!hotplug_ops->filter(kset, kobj))
+			return;
+	}
+
+	pr_debug ("%s\n", __FUNCTION__);
+
+	action_string = action_to_string(action);
+	if (!action_string)
+		return;
+
+	envp = kmalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL);
+	if (!envp)
+		return;
+	memset (envp, 0x00, NUM_ENVP * sizeof (char *));
+
+	buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL);
+	if (!buffer)
+		goto exit;
+
+	if (hotplug_ops->name)
+		name = hotplug_ops->name(kset, kobj);
+	if (name == NULL)
+		name = kset->kobj.name;
+
+	argv [0] = hotplug_path;
+	argv [1] = name;
+	argv [2] = NULL;
+
+	/* minimal command environment */
+	envp [i++] = "HOME=/";
+	envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
+
+	scratch = buffer;
+
+	envp [i++] = scratch;
+	scratch += sprintf(scratch, "ACTION=%s", action_string) + 1;
+
+	kobj_path = kobject_get_path(kobj, GFP_KERNEL);
+	if (!kobj_path)
+		goto exit;
+
+	envp [i++] = scratch;
+	scratch += sprintf (scratch, "DEVPATH=%s", kobj_path) + 1;
+
+	envp [i++] = scratch;
+	scratch += sprintf(scratch, "SUBSYSTEM=%s", name) + 1;
+
+	/* reserve space for the sequence,
+	 * put the real one in after the hotplug call */
+	envp[i++] = seq_buff = scratch;
+	scratch += strlen("SEQNUM=18446744073709551616") + 1;
+
+	if (hotplug_ops->hotplug) {
+		/* have the kset specific function add its stuff */
+		retval = hotplug_ops->hotplug (kset, kobj,
+				  &envp[i], NUM_ENVP - i, scratch,
+				  BUFFER_SIZE - (scratch - buffer));
+		if (retval) {
+			pr_debug ("%s - hotplug() returned %d\n",
+				  __FUNCTION__, retval);
+			goto exit;
+		}
+	}
+
+	spin_lock(&sequence_lock);
+	seq = ++hotplug_seqnum;
+	spin_unlock(&sequence_lock);
+	sprintf(seq_buff, "SEQNUM=%llu", (unsigned long long)seq);
+
+	pr_debug ("%s: %s %s seq=%llu %s %s %s %s %s\n",
+		  __FUNCTION__, argv[0], argv[1], (unsigned long long)seq,
+		  envp[0], envp[1], envp[2], envp[3], envp[4]);
+
+	send_uevent(action_string, kobj_path, envp, GFP_KERNEL);
+
+	if (!hotplug_path[0])
+		goto exit;
+
+	retval = call_usermodehelper (argv[0], argv, envp, 0);
+	if (retval)
+		pr_debug ("%s - call_usermodehelper returned %d\n",
+			  __FUNCTION__, retval);
+
+exit:
+	kfree(kobj_path);
+	kfree(buffer);
+	kfree(envp);
+	return;
+}
+EXPORT_SYMBOL(kobject_hotplug);
+
+/**
+ * add_hotplug_env_var - helper for creating hotplug environment variables
+ * @envp: Pointer to table of environment variables, as passed into
+ * hotplug() method.
+ * @num_envp: Number of environment variable slots available, as
+ * passed into hotplug() method.
+ * @cur_index: Pointer to current index into @envp.  It should be
+ * initialized to 0 before the first call to add_hotplug_env_var(),
+ * and will be incremented on success.
+ * @buffer: Pointer to buffer for environment variables, as passed
+ * into hotplug() method.
+ * @buffer_size: Length of @buffer, as passed into hotplug() method.
+ * @cur_len: Pointer to current length of space used in @buffer.
+ * Should be initialized to 0 before the first call to
+ * add_hotplug_env_var(), and will be incremented on success.
+ * @format: Format for creating environment variable (of the form
+ * "XXX=%x") for snprintf().
+ *
+ * Returns 0 if environment variable was added successfully or -ENOMEM
+ * if no space was available.
+ */
+int add_hotplug_env_var(char **envp, int num_envp, int *cur_index,
+			char *buffer, int buffer_size, int *cur_len,
+			const char *format, ...)
+{
+	va_list args;
+
+	/*
+	 * We check against num_envp - 1 to make sure there is at
+	 * least one slot left after we return, since the hotplug
+	 * method needs to set the last slot to NULL.
+	 */
+	if (*cur_index >= num_envp - 1)
+		return -ENOMEM;
+
+	envp[*cur_index] = buffer + *cur_len;
+
+	va_start(args, format);
+	*cur_len += vsnprintf(envp[*cur_index],
+			      max(buffer_size - *cur_len, 0),
+			      format, args) + 1;
+	va_end(args);
+
+	if (*cur_len > buffer_size)
+		return -ENOMEM;
+
+	(*cur_index)++;
+	return 0;
+}
+EXPORT_SYMBOL(add_hotplug_env_var);
+
+#endif /* CONFIG_HOTPLUG */
diff -Nru a/lib/parser.c b/lib/parser.c
--- a/lib/parser.c	2004-12-24 13:36:48 -08:00
+++ b/lib/parser.c	2004-12-24 13:36:48 -08:00
@@ -47,6 +47,7 @@
 		else if (*p == '%') {
 			if (*s++ != '%')
 				return 0;
+			p++;
 			continue;
 		}
 
diff -Nru a/lib/radix-tree.c b/lib/radix-tree.c
--- a/lib/radix-tree.c	2004-12-24 13:36:31 -08:00
+++ b/lib/radix-tree.c	2004-12-24 13:36:31 -08:00
@@ -701,8 +701,10 @@
 		for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
 			int idx;
 
-			if (!tags[tag])
-				tag_clear(pathp[0].node, tag, pathp[0].offset);
+			if (tags[tag])
+				continue;
+
+			tag_clear(pathp[0].node, tag, pathp[0].offset);
 
 			for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) {
 				if (pathp[0].node->tags[tag][idx]) {
diff -Nru a/lib/reed_solomon/Makefile b/lib/reed_solomon/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/lib/reed_solomon/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,6 @@
+#
+# This is a modified version of reed solomon lib, 
+#
+
+obj-$(CONFIG_REED_SOLOMON) += reed_solomon.o
+
diff -Nru a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/lib/reed_solomon/decode_rs.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,272 @@
+/* 
+ * lib/reed_solomon/decode_rs.c
+ *
+ * Overview:
+ *   Generic Reed Solomon encoder / decoder library
+ *   
+ * Copyright 2002, Phil Karn, KA9Q
+ * May be used under the terms of the GNU General Public License (GPL)
+ *
+ * Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de)
+ *
+ * $Id: decode_rs.c,v 1.6 2004/10/22 15:41:47 gleixner Exp $
+ *
+ */
+
+/* Generic data width independent code which is included by the 
+ * wrappers.
+ */
+{ 
+	int deg_lambda, el, deg_omega;
+	int i, j, r, k, pad;
+	int nn = rs->nn;
+	int nroots = rs->nroots;
+	int fcr = rs->fcr;
+	int prim = rs->prim;
+	int iprim = rs->iprim;
+	uint16_t *alpha_to = rs->alpha_to;
+	uint16_t *index_of = rs->index_of;
+	uint16_t u, q, tmp, num1, num2, den, discr_r, syn_error;
+	/* Err+Eras Locator poly and syndrome poly The maximum value
+	 * of nroots is 8. So the necessary stack size will be about
+	 * 220 bytes max.
+	 */
+	uint16_t lambda[nroots + 1], syn[nroots];
+	uint16_t b[nroots + 1], t[nroots + 1], omega[nroots + 1];
+	uint16_t root[nroots], reg[nroots + 1], loc[nroots];
+	int count = 0;
+	uint16_t msk = (uint16_t) rs->nn;
+
+	/* Check length parameter for validity */
+	pad = nn - nroots - len;
+	if (pad < 0 || pad >= nn)
+		return -ERANGE;
+		
+	/* Does the caller provide the syndrome ? */
+	if (s != NULL) 
+		goto decode;
+
+	/* form the syndromes; i.e., evaluate data(x) at roots of
+	 * g(x) */
+	for (i = 0; i < nroots; i++)
+		syn[i] = (((uint16_t) data[0]) ^ invmsk) & msk;
+
+	for (j = 1; j < len; j++) {
+		for (i = 0; i < nroots; i++) {
+			if (syn[i] == 0) {
+				syn[i] = (((uint16_t) data[j]) ^ 
+					  invmsk) & msk;
+			} else {
+				syn[i] = ((((uint16_t) data[j]) ^
+					   invmsk) & msk) ^ 
+					alpha_to[rs_modnn(rs, index_of[syn[i]] +
+						       (fcr + i) * prim)];
+			}
+		}
+	}
+
+	for (j = 0; j < nroots; j++) {
+		for (i = 0; i < nroots; i++) {
+			if (syn[i] == 0) {
+				syn[i] = ((uint16_t) par[j]) & msk;
+			} else {
+				syn[i] = (((uint16_t) par[j]) & msk) ^ 
+					alpha_to[rs_modnn(rs, index_of[syn[i]] +
+						       (fcr+i)*prim)];
+			}
+		}
+	}
+	s = syn;
+
+	/* Convert syndromes to index form, checking for nonzero condition */
+	syn_error = 0;
+	for (i = 0; i < nroots; i++) {
+		syn_error |= s[i];
+		s[i] = index_of[s[i]];
+	}
+
+	if (!syn_error) {
+		/* if syndrome is zero, data[] is a codeword and there are no
+		 * errors to correct. So return data[] unmodified
+		 */
+		count = 0;
+		goto finish;
+	}
+
+ decode:
+	memset(&lambda[1], 0, nroots * sizeof(lambda[0]));
+	lambda[0] = 1;
+
+	if (no_eras > 0) {
+		/* Init lambda to be the erasure locator polynomial */
+		lambda[1] = alpha_to[rs_modnn(rs, 
+					      prim * (nn - 1 - eras_pos[0]))];
+		for (i = 1; i < no_eras; i++) {
+			u = rs_modnn(rs, prim * (nn - 1 - eras_pos[i]));
+			for (j = i + 1; j > 0; j--) {
+				tmp = index_of[lambda[j - 1]];
+				if (tmp != nn) {
+					lambda[j] ^= 
+						alpha_to[rs_modnn(rs, u + tmp)];
+				}
+			}
+		}
+	}
+
+	for (i = 0; i < nroots + 1; i++)
+		b[i] = index_of[lambda[i]];
+
+	/*
+	 * Begin Berlekamp-Massey algorithm to determine error+erasure
+	 * locator polynomial
+	 */
+	r = no_eras;
+	el = no_eras;
+	while (++r <= nroots) {	/* r is the step number */
+		/* Compute discrepancy at the r-th step in poly-form */
+		discr_r = 0;
+		for (i = 0; i < r; i++) {
+			if ((lambda[i] != 0) && (s[r - i - 1] != nn)) {
+				discr_r ^= 
+					alpha_to[rs_modnn(rs, 
+							  index_of[lambda[i]] +
+							  s[r - i - 1])];
+			}
+		}
+		discr_r = index_of[discr_r];	/* Index form */
+		if (discr_r == nn) {
+			/* 2 lines below: B(x) <-- x*B(x) */
+			memmove (&b[1], b, nroots * sizeof (b[0]));
+			b[0] = nn;
+		} else {
+			/* 7 lines below: T(x) <-- lambda(x)-discr_r*x*b(x) */
+			t[0] = lambda[0];
+			for (i = 0; i < nroots; i++) {
+				if (b[i] != nn) {
+					t[i + 1] = lambda[i + 1] ^ 
+						alpha_to[rs_modnn(rs, discr_r +
+								  b[i])];
+				} else
+					t[i + 1] = lambda[i + 1];
+			}
+			if (2 * el <= r + no_eras - 1) {
+				el = r + no_eras - el;
+				/*
+				 * 2 lines below: B(x) <-- inv(discr_r) *
+				 * lambda(x)
+				 */
+				for (i = 0; i <= nroots; i++) {
+					b[i] = (lambda[i] == 0) ? nn :
+						rs_modnn(rs, index_of[lambda[i]]
+							 - discr_r + nn);
+				}
+			} else {
+				/* 2 lines below: B(x) <-- x*B(x) */
+				memmove(&b[1], b, nroots * sizeof(b[0]));
+				b[0] = nn;
+			}
+			memcpy(lambda, t, (nroots + 1) * sizeof(t[0]));
+		}
+	}
+
+	/* Convert lambda to index form and compute deg(lambda(x)) */
+	deg_lambda = 0;
+	for (i = 0; i < nroots + 1; i++) {
+		lambda[i] = index_of[lambda[i]];
+		if (lambda[i] != nn)
+			deg_lambda = i;
+	}
+	/* Find roots of error+erasure locator polynomial by Chien search */
+	memcpy(&reg[1], &lambda[1], nroots * sizeof(reg[0]));
+	count = 0;		/* Number of roots of lambda(x) */
+	for (i = 1, k = iprim - 1; i <= nn; i++, k = rs_modnn(rs, k + iprim)) {
+		q = 1;		/* lambda[0] is always 0 */
+		for (j = deg_lambda; j > 0; j--) {
+			if (reg[j] != nn) {
+				reg[j] = rs_modnn(rs, reg[j] + j);
+				q ^= alpha_to[reg[j]];
+			}
+		}
+		if (q != 0)
+			continue;	/* Not a root */
+		/* store root (index-form) and error location number */
+		root[count] = i;
+		loc[count] = k;
+		/* If we've already found max possible roots,
+		 * abort the search to save time
+		 */
+		if (++count == deg_lambda)
+			break;
+	}
+	if (deg_lambda != count) {
+		/*
+		 * deg(lambda) unequal to number of roots => uncorrectable
+		 * error detected
+		 */
+		count = -1;
+		goto finish;
+	}
+	/*
+	 * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
+	 * x**nroots). in index form. Also find deg(omega).
+	 */
+	deg_omega = deg_lambda - 1;
+	for (i = 0; i <= deg_omega; i++) {
+		tmp = 0;
+		for (j = i; j >= 0; j--) {
+			if ((s[i - j] != nn) && (lambda[j] != nn))
+				tmp ^=
+				    alpha_to[rs_modnn(rs, s[i - j] + lambda[j])];
+		}
+		omega[i] = index_of[tmp];
+	}
+
+	/*
+	 * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
+	 * inv(X(l))**(fcr-1) and den = lambda_pr(inv(X(l))) all in poly-form
+	 */
+	for (j = count - 1; j >= 0; j--) {
+		num1 = 0;
+		for (i = deg_omega; i >= 0; i--) {
+			if (omega[i] != nn)
+				num1 ^= alpha_to[rs_modnn(rs, omega[i] + 
+							i * root[j])];
+		}
+		num2 = alpha_to[rs_modnn(rs, root[j] * (fcr - 1) + nn)];
+		den = 0;
+
+		/* lambda[i+1] for i even is the formal derivative
+		 * lambda_pr of lambda[i] */
+		for (i = min(deg_lambda, nroots - 1) & ~1; i >= 0; i -= 2) {
+			if (lambda[i + 1] != nn) {
+				den ^= alpha_to[rs_modnn(rs, lambda[i + 1] + 
+						       i * root[j])];
+			}
+		}
+		/* Apply error to data */
+		if (num1 != 0 && loc[j] >= pad) {
+			uint16_t cor = alpha_to[rs_modnn(rs,index_of[num1] + 
+						       index_of[num2] +
+						       nn - index_of[den])];
+			/* Store the error correction pattern, if a
+			 * correction buffer is available */
+			if (corr) {
+				corr[j] = cor;
+			} else {
+				/* If a data buffer is given and the
+				 * error is inside the message,
+				 * correct it */
+				if (data && (loc[j] < (nn - nroots)))
+					data[loc[j] - pad] ^= cor;
+			}
+		}
+	}
+
+finish:
+	if (eras_pos != NULL) {
+		for (i = 0; i < count; i++)
+			eras_pos[i] = loc[i] - pad;
+	}
+	return count;
+
+}
diff -Nru a/lib/reed_solomon/encode_rs.c b/lib/reed_solomon/encode_rs.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/lib/reed_solomon/encode_rs.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,54 @@
+/* 
+ * lib/reed_solomon/encode_rs.c
+ *
+ * Overview:
+ *   Generic Reed Solomon encoder / decoder library
+ *   
+ * Copyright 2002, Phil Karn, KA9Q
+ * May be used under the terms of the GNU General Public License (GPL)
+ *
+ * Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de)
+ *
+ * $Id: encode_rs.c,v 1.4 2004/10/22 15:41:47 gleixner Exp $
+ *
+ */
+
+/* Generic data width independent code which is included by the 
+ * wrappers.
+ * int encode_rsX (struct rs_control *rs, uintX_t *data, int len, uintY_t *par)
+ */
+{
+	int i, j, pad;
+	int nn = rs->nn;
+	int nroots = rs->nroots;
+	uint16_t *alpha_to = rs->alpha_to;
+	uint16_t *index_of = rs->index_of;
+	uint16_t *genpoly = rs->genpoly;
+	uint16_t fb;
+	uint16_t msk = (uint16_t) rs->nn;
+
+	/* Check length parameter for validity */
+	pad = nn - nroots - len;
+	if (pad < 0 || pad >= nn)
+		return -ERANGE;
+
+	for (i = 0; i < len; i++) {
+		fb = index_of[((((uint16_t) data[i])^invmsk) & msk) ^ par[0]];
+		/* feedback term is non-zero */
+		if (fb != nn) {	
+			for (j = 1; j < nroots; j++) {
+				par[j] ^= alpha_to[rs_modnn(rs, fb + 
+							 genpoly[nroots - j])];
+			}
+		}
+		/* Shift */
+		memmove(&par[0], &par[1], sizeof(uint16_t) * (nroots - 1));
+		if (fb != nn) {
+			par[nroots - 1] = alpha_to[rs_modnn(rs, 
+							    fb + genpoly[0])];
+		} else {
+			par[nroots - 1] = 0;
+		}
+	}
+	return 0;
+}
diff -Nru a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/lib/reed_solomon/reed_solomon.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,335 @@
+/* 
+ * lib/reed_solomon/rslib.c
+ *
+ * Overview:
+ *   Generic Reed Solomon encoder / decoder library
+ *   
+ * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
+ *
+ * Reed Solomon code lifted from reed solomon library written by Phil Karn
+ * Copyright 2002 Phil Karn, KA9Q
+ *
+ * $Id: rslib.c,v 1.4 2004/10/05 22:07:53 gleixner Exp $
+ *
+ * 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.
+ *
+ * Description:
+ *	
+ * The generic Reed Solomon library provides runtime configurable
+ * encoding / decoding of RS codes.
+ * Each user must call init_rs to get a pointer to a rs_control
+ * structure for the given rs parameters. This structure is either
+ * generated or a already available matching control structure is used.
+ * If a structure is generated then the polynominal arrays for
+ * fast encoding / decoding are built. This can take some time so
+ * make sure not to call this function from a timecritical path.
+ * Usually a module / driver should initialize the neccecary 
+ * rs_control structure on module / driver init and release it
+ * on exit.
+ * The encoding puts the calculated syndrome into a given syndrom 
+ * buffer. 
+ * The decoding is a two step process. The first step calculates
+ * the syndrome over the received (data + syndrom) and calls the
+ * second stage, which does the decoding / error correction itself.
+ * Many hw encoders provide a syndrom calculation over the received
+ * data + syndrom and can call the second stage directly.
+ *
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/rslib.h>
+#include <linux/slab.h>
+#include <asm/semaphore.h>
+
+/* This list holds all currently allocated rs control structures */
+static LIST_HEAD (rslist);
+/* Protection for the list */
+static DECLARE_MUTEX(rslistlock);
+
+/** 
+ * rs_init - Initialize a Reed-Solomon codec
+ *
+ * @symsize:	symbol size, bits (1-8)
+ * @gfpoly:	Field generator polynomial coefficients
+ * @fcr:	first root of RS code generator polynomial, index form
+ * @prim:	primitive element to generate polynomial roots
+ * @nroots:	RS code generator polynomial degree (number of roots)
+ *
+ * Allocate a control structure and the polynom arrays for faster
+ * en/decoding. Fill the arrays according to the given parameters
+ */
+static struct rs_control *rs_init(int symsize, int gfpoly, int fcr, 
+				   int prim, int nroots)
+{
+	struct rs_control *rs;
+	int i, j, sr, root, iprim;
+
+	/* Allocate the control structure */
+	rs = kmalloc(sizeof (struct rs_control), GFP_KERNEL);
+	if (rs == NULL)
+		return NULL;
+
+	INIT_LIST_HEAD(&rs->list);
+
+	rs->mm = symsize;
+	rs->nn = (1 << symsize) - 1;
+	rs->fcr = fcr;
+	rs->prim = prim;
+	rs->nroots = nroots;
+	rs->gfpoly = gfpoly;
+
+	/* Allocate the arrays */
+	rs->alpha_to = kmalloc(sizeof(uint16_t) * (rs->nn + 1), GFP_KERNEL);
+	if (rs->alpha_to == NULL)
+		goto errrs;
+
+	rs->index_of = kmalloc(sizeof(uint16_t) * (rs->nn + 1), GFP_KERNEL);
+	if (rs->index_of == NULL)
+		goto erralp;
+
+	rs->genpoly = kmalloc(sizeof(uint16_t) * (rs->nroots + 1), GFP_KERNEL);
+	if(rs->genpoly == NULL)
+		goto erridx;
+
+	/* Generate Galois field lookup tables */
+	rs->index_of[0] = rs->nn;	/* log(zero) = -inf */
+	rs->alpha_to[rs->nn] = 0;	/* alpha**-inf = 0 */
+	sr = 1;
+	for (i = 0; i < rs->nn; i++) {
+		rs->index_of[sr] = i;
+		rs->alpha_to[i] = sr;
+		sr <<= 1;
+		if (sr & (1 << symsize))
+			sr ^= gfpoly;
+		sr &= rs->nn;
+	}
+	/* If it's not primitive, exit */
+	if(sr != 1)
+		goto errpol;
+
+	/* Find prim-th root of 1, used in decoding */
+	for(iprim = 1; (iprim % prim) != 0; iprim += rs->nn);
+	/* prim-th root of 1, index form */
+	rs->iprim = iprim / prim;
+
+	/* Form RS code generator polynomial from its roots */
+	rs->genpoly[0] = 1;
+	for (i = 0, root = fcr * prim; i < nroots; i++, root += prim) {
+		rs->genpoly[i + 1] = 1;
+		/* Multiply rs->genpoly[] by  @**(root + x) */
+		for (j = i; j > 0; j--) {
+			if (rs->genpoly[j] != 0) {
+				rs->genpoly[j] = rs->genpoly[j -1] ^ 
+					rs->alpha_to[rs_modnn(rs, 
+					rs->index_of[rs->genpoly[j]] + root)];
+			} else
+				rs->genpoly[j] = rs->genpoly[j - 1];
+		}
+		/* rs->genpoly[0] can never be zero */
+		rs->genpoly[0] = 
+			rs->alpha_to[rs_modnn(rs, 
+				rs->index_of[rs->genpoly[0]] + root)];
+	}
+	/* convert rs->genpoly[] to index form for quicker encoding */
+	for (i = 0; i <= nroots; i++)
+		rs->genpoly[i] = rs->index_of[rs->genpoly[i]];
+	return rs;
+
+	/* Error exit */
+errpol:
+	kfree(rs->genpoly);
+erridx:
+	kfree(rs->index_of);
+erralp:
+	kfree(rs->alpha_to);
+errrs:
+	kfree(rs);
+	return NULL;
+}
+
+
+/** 
+ *  free_rs - Free the rs control structure, if its not longer used
+ *
+ *  @rs:	the control structure which is not longer used by the
+ *		caller
+ */
+void free_rs(struct rs_control *rs)
+{
+	down(&rslistlock);
+	rs->users--;
+	if(!rs->users) {
+		list_del(&rs->list);
+		kfree(rs->alpha_to);
+		kfree(rs->index_of);
+		kfree(rs->genpoly);
+		kfree(rs);
+	}
+	up(&rslistlock);
+}
+
+/** 
+ * init_rs - Find a matching or allocate a new rs control structure
+ *
+ *  @symsize:	the symbol size (number of bits)
+ *  @gfpoly:	the extended Galois field generator polynomial coefficients,
+ *		with the 0th coefficient in the low order bit. The polynomial
+ *		must be primitive;
+ *  @fcr:  	the first consecutive root of the rs code generator polynomial 
+ *		in index form
+ *  @prim:	primitive element to generate polynomial roots
+ *  @nroots:	RS code generator polynomial degree (number of roots)
+ */
+struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, 
+			   int nroots)
+{
+	struct list_head	*tmp;
+	struct rs_control	*rs;
+
+	/* Sanity checks */
+	if (symsize < 1)
+		return NULL;
+	if (fcr < 0 || fcr >= (1<<symsize))
+    		return NULL;
+	if (prim <= 0 || prim >= (1<<symsize))
+    		return NULL;
+	if (nroots < 0 || nroots >= (1<<symsize) || nroots > 8)
+		return NULL;
+	
+	down(&rslistlock);
+
+	/* Walk through the list and look for a matching entry */
+	list_for_each(tmp, &rslist) {
+		rs = list_entry(tmp, struct rs_control, list);
+		if (symsize != rs->mm)
+			continue;
+		if (gfpoly != rs->gfpoly)
+			continue;
+		if (fcr != rs->fcr)
+			continue;	
+		if (prim != rs->prim)
+			continue;	
+		if (nroots != rs->nroots)
+			continue;
+		/* We have a matching one already */
+		rs->users++;
+		goto out;
+	}
+
+	/* Create a new one */
+	rs = rs_init(symsize, gfpoly, fcr, prim, nroots);
+	if (rs) {
+		rs->users = 1;
+		list_add(&rs->list, &rslist);
+	}
+out:	
+	up(&rslistlock);
+	return rs;
+}
+
+#ifdef CONFIG_REED_SOLOMON_ENC8
+/** 
+ *  encode_rs8 - Calculate the parity for data values (8bit data width)
+ *
+ *  @rs:	the rs control structure
+ *  @data:	data field of a given type
+ *  @len:	data length 
+ *  @par:	parity data, must be initialized by caller (usually all 0)
+ *  @invmsk:	invert data mask (will be xored on data)
+ *
+ *  The parity uses a uint16_t data type to enable
+ *  symbol size > 8. The calling code must take care of encoding of the
+ *  syndrome result for storage itself.
+ */
+int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par, 
+	       uint16_t invmsk)
+{
+#include "encode_rs.c"
+}
+EXPORT_SYMBOL_GPL(encode_rs8);
+#endif
+
+#ifdef CONFIG_REED_SOLOMON_DEC8
+/** 
+ *  decode_rs8 - Decode codeword (8bit data width)
+ *
+ *  @rs:	the rs control structure
+ *  @data:	data field of a given type
+ *  @par:	received parity data field
+ *  @len:	data length
+ *  @s:		syndrome data field (if NULL, syndrome is calculated)
+ *  @no_eras:	number of erasures
+ *  @eras_pos:	position of erasures, can be NULL
+ *  @invmsk:	invert data mask (will be xored on data, not on parity!)
+ *  @corr:	buffer to store correction bitmask on eras_pos
+ *
+ *  The syndrome and parity uses a uint16_t data type to enable
+ *  symbol size > 8. The calling code must take care of decoding of the
+ *  syndrome result and the received parity before calling this code.
+ */
+int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len,
+	       uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, 
+	       uint16_t *corr)
+{
+#include "decode_rs.c"
+}
+EXPORT_SYMBOL_GPL(decode_rs8);
+#endif
+
+#ifdef CONFIG_REED_SOLOMON_ENC16
+/**
+ *  encode_rs16 - Calculate the parity for data values (16bit data width)
+ *
+ *  @rs:	the rs control structure
+ *  @data:	data field of a given type
+ *  @len:	data length 
+ *  @par:	parity data, must be initialized by caller (usually all 0)
+ *  @invmsk:	invert data mask (will be xored on data, not on parity!)
+ *
+ *  Each field in the data array contains up to symbol size bits of valid data.
+ */
+int encode_rs16(struct rs_control *rs, uint16_t *data, int len, uint16_t *par, 
+	uint16_t invmsk)
+{
+#include "encode_rs.c"
+}
+EXPORT_SYMBOL_GPL(encode_rs16);
+#endif
+
+#ifdef CONFIG_REED_SOLOMON_DEC16
+/** 
+ *  decode_rs16 - Decode codeword (16bit data width)
+ *
+ *  @rs:	the rs control structure
+ *  @data:	data field of a given type
+ *  @par:	received parity data field
+ *  @len:	data length
+ *  @s:		syndrome data field (if NULL, syndrome is calculated)
+ *  @no_eras:	number of erasures
+ *  @eras_pos:	position of erasures, can be NULL
+ *  @invmsk:	invert data mask (will be xored on data, not on parity!) 
+ *  @corr:	buffer to store correction bitmask on eras_pos
+ *
+ *  Each field in the data array contains up to symbol size bits of valid data.
+ */
+int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len,
+		uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, 
+		uint16_t *corr)
+{
+#include "decode_rs.c"
+}
+EXPORT_SYMBOL_GPL(decode_rs16);
+#endif
+
+EXPORT_SYMBOL_GPL(init_rs);
+EXPORT_SYMBOL_GPL(free_rs);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Reed Solomon encoder/decoder");
+MODULE_AUTHOR("Phil Karn, Thomas Gleixner");
+
diff -Nru a/mm/bootmem.c b/mm/bootmem.c
--- a/mm/bootmem.c	2004-12-24 13:36:33 -08:00
+++ b/mm/bootmem.c	2004-12-24 13:36:33 -08:00
@@ -343,31 +343,29 @@
 	return(free_all_bootmem_core(pgdat));
 }
 
-#ifndef CONFIG_DISCONTIGMEM
 unsigned long __init init_bootmem (unsigned long start, unsigned long pages)
 {
 	max_low_pfn = pages;
 	min_low_pfn = start;
-	return(init_bootmem_core(&contig_page_data, start, 0, pages));
+	return(init_bootmem_core(NODE_DATA(0), start, 0, pages));
 }
 
 #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
 void __init reserve_bootmem (unsigned long addr, unsigned long size)
 {
-	reserve_bootmem_core(contig_page_data.bdata, addr, size);
+	reserve_bootmem_core(NODE_DATA(0)->bdata, addr, size);
 }
 #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
 
 void __init free_bootmem (unsigned long addr, unsigned long size)
 {
-	free_bootmem_core(contig_page_data.bdata, addr, size);
+	free_bootmem_core(NODE_DATA(0)->bdata, addr, size);
 }
 
 unsigned long __init free_all_bootmem (void)
 {
-	return(free_all_bootmem_core(&contig_page_data));
+	return(free_all_bootmem_core(NODE_DATA(0)));
 }
-#endif /* !CONFIG_DISCONTIGMEM */
 
 void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal)
 {
diff -Nru a/mm/fadvise.c b/mm/fadvise.c
--- a/mm/fadvise.c	2004-12-24 13:36:47 -08:00
+++ b/mm/fadvise.c	2004-12-24 13:36:47 -08:00
@@ -15,6 +15,7 @@
 #include <linux/backing-dev.h>
 #include <linux/pagevec.h>
 #include <linux/fadvise.h>
+#include <linux/syscalls.h>
 
 #include <asm/unistd.h>
 
diff -Nru a/mm/filemap.c b/mm/filemap.c
--- a/mm/filemap.c	2004-12-24 13:37:43 -08:00
+++ b/mm/filemap.c	2004-12-24 13:37:43 -08:00
@@ -27,6 +27,7 @@
 #include <linux/pagevec.h>
 #include <linux/blkdev.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 /*
  * This is needed for the following functions:
  *  - try_to_release_page
@@ -130,9 +131,12 @@
 	spin_unlock_irq(&mapping->tree_lock);
 }
 
-static inline int sync_page(struct page *page)
+static int sync_page(void *word)
 {
 	struct address_space *mapping;
+	struct page *page;
+
+	page = container_of((page_flags_t *)word, struct page, flags);
 
 	/*
 	 * FIXME, fercrissake.  What is this barrier here for?
@@ -140,7 +144,8 @@
 	smp_mb();
 	mapping = page_mapping(page);
 	if (mapping && mapping->a_ops && mapping->a_ops->sync_page)
-		return mapping->a_ops->sync_page(page);
+		mapping->a_ops->sync_page(page);
+	io_schedule();
 	return 0;
 }
 
@@ -186,12 +191,11 @@
 }
 EXPORT_SYMBOL(filemap_fdatawrite);
 
-int filemap_fdatawrite_range(struct address_space *mapping,
+static int filemap_fdatawrite_range(struct address_space *mapping,
 	loff_t start, loff_t end)
 {
 	return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_ALL);
 }
-EXPORT_SYMBOL(filemap_fdatawrite_range);
 
 /*
  * This is a mostly non-blocking flush.  Not suitable for data-integrity
@@ -279,6 +283,29 @@
 }
 EXPORT_SYMBOL(sync_page_range);
 
+/*
+ * Note: Holding i_sem across sync_page_range_nolock is not a good idea
+ * as it forces O_SYNC writers to different parts of the same file
+ * to be serialised right until io completion.
+ */
+int sync_page_range_nolock(struct inode *inode, struct address_space *mapping,
+			loff_t pos, size_t count)
+{
+	pgoff_t start = pos >> PAGE_CACHE_SHIFT;
+	pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT;
+	int ret;
+
+	if (mapping->backing_dev_info->memory_backed || !count)
+		return 0;
+	ret = filemap_fdatawrite_range(mapping, pos, pos + count - 1);
+	if (ret == 0)
+		ret = generic_osync_inode(inode, mapping, OSYNC_METADATA);
+	if (ret == 0)
+		ret = wait_on_page_writeback_range(mapping, start, end);
+	return ret;
+}
+EXPORT_SYMBOL(sync_page_range_nolock);
+
 /**
  * filemap_fdatawait - walk the list of under-writeback pages of the given
  *     address space and wait for all of them.
@@ -359,40 +386,6 @@
  * at a cost of "thundering herd" phenomena during rare hash
  * collisions.
  */
-struct page_wait_queue {
-	struct page *page;
-	int bit;
-	wait_queue_t wait;
-};
-
-static int page_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key)
-{
-	struct page *page = key;
-	struct page_wait_queue *wq;
-
-	wq = container_of(wait, struct page_wait_queue, wait);
-	if (wq->page != page || test_bit(wq->bit, &page->flags))
-		return 0;
-	else
-		return autoremove_wake_function(wait, mode, sync, NULL);
-}
-
-#define __DEFINE_PAGE_WAIT(name, p, b, f)				\
-	struct page_wait_queue name = {					\
-		.page	= p,						\
-		.bit	= b,						\
-		.wait	= {						\
-			.task	= current,				\
-			.func	= page_wake_function,			\
-			.flags	= f,					\
-			.task_list = LIST_HEAD_INIT(name.wait.task_list),\
-		},							\
-	}
-
-#define DEFINE_PAGE_WAIT(name, p, b)	__DEFINE_PAGE_WAIT(name, p, b, 0)
-#define DEFINE_PAGE_WAIT_EXCLUSIVE(name, p, b)				\
-		__DEFINE_PAGE_WAIT(name, p, b, WQ_FLAG_EXCLUSIVE)
-
 static wait_queue_head_t *page_waitqueue(struct page *page)
 {
 	const struct zone *zone = page_zone(page);
@@ -400,30 +393,19 @@
 	return &zone->wait_table[hash_ptr(page, zone->wait_table_bits)];
 }
 
-static void wake_up_page(struct page *page)
+static inline void wake_up_page(struct page *page, int bit)
 {
-	const unsigned int mode = TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE;
-	wait_queue_head_t *waitqueue = page_waitqueue(page);
-
-	if (waitqueue_active(waitqueue))
-		__wake_up(waitqueue, mode, 1, page);
+	__wake_up_bit(page_waitqueue(page), &page->flags, bit);
 }
 
 void fastcall wait_on_page_bit(struct page *page, int bit_nr)
 {
-	wait_queue_head_t *waitqueue = page_waitqueue(page);
-	DEFINE_PAGE_WAIT(wait, page, bit_nr);
+	DEFINE_WAIT_BIT(wait, &page->flags, bit_nr);
 
-	do {
-		prepare_to_wait(waitqueue, &wait.wait, TASK_UNINTERRUPTIBLE);
-		if (test_bit(bit_nr, &page->flags)) {
-			sync_page(page);
-			io_schedule();
-		}
-	} while (test_bit(bit_nr, &page->flags));
-	finish_wait(waitqueue, &wait.wait);
+	if (test_bit(bit_nr, &page->flags))
+		__wait_on_bit(page_waitqueue(page), &wait, sync_page,
+							TASK_UNINTERRUPTIBLE);
 }
-
 EXPORT_SYMBOL(wait_on_page_bit);
 
 /**
@@ -447,11 +429,9 @@
 	if (!TestClearPageLocked(page))
 		BUG();
 	smp_mb__after_clear_bit(); 
-	wake_up_page(page);
+	wake_up_page(page, PG_locked);
 }
-
 EXPORT_SYMBOL(unlock_page);
-EXPORT_SYMBOL(lock_page);
 
 /*
  * End writeback against a page.
@@ -461,11 +441,10 @@
 	if (!TestClearPageReclaim(page) || rotate_reclaimable_page(page)) {
 		if (!test_clear_page_writeback(page))
 			BUG();
-		smp_mb__after_clear_bit();
 	}
-	wake_up_page(page);
+	smp_mb__after_clear_bit();
+	wake_up_page(page, PG_writeback);
 }
-
 EXPORT_SYMBOL(end_page_writeback);
 
 /*
@@ -478,19 +457,11 @@
  */
 void fastcall __lock_page(struct page *page)
 {
-	wait_queue_head_t *wqh = page_waitqueue(page);
-	DEFINE_PAGE_WAIT_EXCLUSIVE(wait, page, PG_locked);
+	DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
 
-	while (TestSetPageLocked(page)) {
-		prepare_to_wait_exclusive(wqh, &wait.wait, TASK_UNINTERRUPTIBLE);
-		if (PageLocked(page)) {
-			sync_page(page);
-			io_schedule();
-		}
-	}
-	finish_wait(wqh, &wait.wait);
+	__wait_on_bit_lock(page_waitqueue(page), &wait, sync_page,
+							TASK_UNINTERRUPTIBLE);
 }
-
 EXPORT_SYMBOL(__lock_page);
 
 /*
@@ -1804,7 +1775,7 @@
 inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk)
 {
 	struct inode *inode = file->f_mapping->host;
-	unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	unsigned long limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
 
         if (unlikely(*pos < 0))
                 return -EINVAL;
@@ -1878,7 +1849,6 @@
 	}
 	return 0;
 }
-
 EXPORT_SYMBOL(generic_write_checks);
 
 ssize_t
@@ -1916,7 +1886,6 @@
 		written = -EIOCBQUEUED;
 	return written;
 }
-
 EXPORT_SYMBOL(generic_file_direct_write);
 
 ssize_t
@@ -2038,11 +2007,10 @@
 	pagevec_lru_add(&lru_pvec);
 	return written ? written : status;
 }
-
 EXPORT_SYMBOL(generic_file_buffered_write);
 
 ssize_t
-generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
+__generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
 				unsigned long nr_segs, loff_t *ppos)
 {
 	struct file *file = iocb->ki_filp;
@@ -2115,10 +2083,45 @@
 	current->backing_dev_info = NULL;
 	return written ? written : err;
 }
-
 EXPORT_SYMBOL(generic_file_aio_write_nolock);
 
 ssize_t
+generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
+				unsigned long nr_segs, loff_t *ppos)
+{
+	struct file *file = iocb->ki_filp;
+	struct address_space *mapping = file->f_mapping;
+	struct inode *inode = mapping->host;
+	ssize_t ret;
+	loff_t pos = *ppos;
+
+	ret = __generic_file_aio_write_nolock(iocb, iov, nr_segs, ppos);
+
+	if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
+		int err;
+
+		err = sync_page_range_nolock(inode, mapping, pos, ret);
+		if (err < 0)
+			ret = err;
+	}
+	return ret;
+}
+
+ssize_t
+__generic_file_write_nolock(struct file *file, const struct iovec *iov,
+				unsigned long nr_segs, loff_t *ppos)
+{
+	struct kiocb kiocb;
+	ssize_t ret;
+
+	init_sync_kiocb(&kiocb, file);
+	ret = __generic_file_aio_write_nolock(&kiocb, iov, nr_segs, ppos);
+	if (ret == -EIOCBQUEUED)
+		ret = wait_on_sync_kiocb(&kiocb);
+	return ret;
+}
+
+ssize_t
 generic_file_write_nolock(struct file *file, const struct iovec *iov,
 				unsigned long nr_segs, loff_t *ppos)
 {
@@ -2131,7 +2134,6 @@
 		ret = wait_on_sync_kiocb(&kiocb);
 	return ret;
 }
-
 EXPORT_SYMBOL(generic_file_write_nolock);
 
 ssize_t generic_file_aio_write(struct kiocb *iocb, const char __user *buf,
@@ -2172,7 +2174,7 @@
 					.iov_len = count };
 
 	down(&inode->i_sem);
-	ret = generic_file_write_nolock(file, &local_iov, 1, ppos);
+	ret = __generic_file_write_nolock(file, &local_iov, 1, ppos);
 	up(&inode->i_sem);
 
 	if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
@@ -2198,7 +2200,6 @@
 		ret = wait_on_sync_kiocb(&kiocb);
 	return ret;
 }
-
 EXPORT_SYMBOL(generic_file_readv);
 
 ssize_t generic_file_writev(struct file *file, const struct iovec *iov,
@@ -2209,7 +2210,7 @@
 	ssize_t ret;
 
 	down(&inode->i_sem);
-	ret = generic_file_write_nolock(file, iov, nr_segs, ppos);
+	ret = __generic_file_write_nolock(file, iov, nr_segs, ppos);
 	up(&inode->i_sem);
 
 	if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
@@ -2221,7 +2222,6 @@
 	}
 	return ret;
 }
-
 EXPORT_SYMBOL(generic_file_writev);
 
 /*
@@ -2244,5 +2244,4 @@
 	}
 	return retval;
 }
-
 EXPORT_SYMBOL_GPL(generic_file_direct_IO);
diff -Nru a/mm/fremap.c b/mm/fremap.c
--- a/mm/fremap.c	2004-12-24 13:36:17 -08:00
+++ b/mm/fremap.c	2004-12-24 13:36:17 -08:00
@@ -14,6 +14,7 @@
 #include <linux/swapops.h>
 #include <linux/rmap.h>
 #include <linux/module.h>
+#include <linux/syscalls.h>
 
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
diff -Nru a/mm/highmem.c b/mm/highmem.c
--- a/mm/highmem.c	2004-12-24 13:37:00 -08:00
+++ b/mm/highmem.c	2004-12-24 13:37:00 -08:00
@@ -305,14 +305,14 @@
 	}
 }
 
-static void bounce_end_io(struct bio *bio, mempool_t *pool)
+static void bounce_end_io(struct bio *bio, mempool_t *pool, int err)
 {
 	struct bio *bio_orig = bio->bi_private;
 	struct bio_vec *bvec, *org_vec;
-	int i, err = 0;
+	int i;
 
-	if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
-		err = -EIO;
+	if (test_bit(BIO_EOPNOTSUPP, &bio->bi_flags))
+		set_bit(BIO_EOPNOTSUPP, &bio_orig->bi_flags);
 
 	/*
 	 * free up bounce indirect pages used
@@ -334,7 +334,7 @@
 	if (bio->bi_size)
 		return 1;
 
-	bounce_end_io(bio, page_pool);
+	bounce_end_io(bio, page_pool, err);
 	return 0;
 }
 
@@ -343,18 +343,18 @@
 	if (bio->bi_size)
 		return 1;
 
-	bounce_end_io(bio, isa_page_pool);
+	bounce_end_io(bio, isa_page_pool, err);
 	return 0;
 }
 
-static void __bounce_end_io_read(struct bio *bio, mempool_t *pool)
+static void __bounce_end_io_read(struct bio *bio, mempool_t *pool, int err)
 {
 	struct bio *bio_orig = bio->bi_private;
 
 	if (test_bit(BIO_UPTODATE, &bio->bi_flags))
 		copy_to_high_bio_irq(bio_orig, bio);
 
-	bounce_end_io(bio, pool);
+	bounce_end_io(bio, pool, err);
 }
 
 static int bounce_end_io_read(struct bio *bio, unsigned int bytes_done, int err)
@@ -362,7 +362,7 @@
 	if (bio->bi_size)
 		return 1;
 
-	__bounce_end_io_read(bio, page_pool);
+	__bounce_end_io_read(bio, page_pool, err);
 	return 0;
 }
 
@@ -371,7 +371,7 @@
 	if (bio->bi_size)
 		return 1;
 
-	__bounce_end_io_read(bio, isa_page_pool);
+	__bounce_end_io_read(bio, isa_page_pool, err);
 	return 0;
 }
 
diff -Nru a/mm/madvise.c b/mm/madvise.c
--- a/mm/madvise.c	2004-12-24 13:36:31 -08:00
+++ b/mm/madvise.c	2004-12-24 13:36:31 -08:00
@@ -7,6 +7,7 @@
 
 #include <linux/mman.h>
 #include <linux/pagemap.h>
+#include <linux/syscalls.h>
 
 
 /*
diff -Nru a/mm/memory.c b/mm/memory.c
--- a/mm/memory.c	2004-12-24 13:36:48 -08:00
+++ b/mm/memory.c	2004-12-24 13:36:48 -08:00
@@ -114,6 +114,7 @@
 	page = pmd_page(*dir);
 	pmd_clear(dir);
 	dec_page_state(nr_page_table_pages);
+	tlb->mm->nr_ptes--;
 	pte_free_tlb(tlb, page);
 }
 
@@ -163,7 +164,6 @@
 		spin_lock(&mm->page_table_lock);
 		if (!new)
 			return NULL;
-
 		/*
 		 * Because we dropped the lock, we should re-check the
 		 * entry, as somebody else could have populated it..
@@ -172,6 +172,7 @@
 			pte_free(new);
 			goto out;
 		}
+		mm->nr_ptes++;
 		inc_page_state(nr_page_table_pages);
 		pmd_populate(mm, pmd, new);
 	}
@@ -288,8 +289,15 @@
 					goto cont_copy_pte_range_noset;
 				/* pte contains position in swap, so copy. */
 				if (!pte_present(pte)) {
-					if (!pte_file(pte))
+					if (!pte_file(pte)) {
 						swap_duplicate(pte_to_swp_entry(pte));
+						if (list_empty(&dst->mmlist)) {
+							spin_lock(&mmlist_lock);
+							list_add(&dst->mmlist,
+								 &src->mmlist);
+							spin_unlock(&mmlist_lock);
+						}
+					}
 					set_pte(dst_pte, pte);
 					goto cont_copy_pte_range_noset;
 				}
@@ -326,6 +334,8 @@
 				pte = pte_mkold(pte);
 				get_page(page);
 				dst->rss++;
+				if (PageAnon(page))
+					dst->anon_rss++;
 				set_pte(dst_pte, pte);
 				page_dup_rmap(page);
 cont_copy_pte_range_noset:
@@ -416,7 +426,9 @@
 				set_pte(ptep, pgoff_to_pte(page->index));
 			if (pte_dirty(pte))
 				set_page_dirty(page);
-			if (pte_young(pte) && !PageAnon(page))
+			if (PageAnon(page))
+				tlb->mm->anon_rss--;
+			else if (pte_young(pte))
 				mark_page_accessed(page);
 			tlb->freed++;
 			page_remove_rmap(page);
@@ -727,19 +739,15 @@
 			pte_t *pte;
 			if (write) /* user gate pages are read-only */
 				return i ? : -EFAULT;
-			pgd = pgd_offset_gate(mm, pg);
-			if (!pgd)
-				return i ? : -EFAULT;
+			if (pg > TASK_SIZE)
+				pgd = pgd_offset_k(pg);
+			else
+				pgd = pgd_offset_gate(mm, pg);
+			BUG_ON(pgd_none(*pgd));
 			pmd = pmd_offset(pgd, pg);
-			if (!pmd)
-				return i ? : -EFAULT;
+			BUG_ON(pmd_none(*pmd));
 			pte = pte_offset_map(pmd, pg);
-			if (!pte)
-				return i ? : -EFAULT;
-			if (!pte_present(*pte)) {
-				pte_unmap(pte);
-				return i ? : -EFAULT;
-			}
+			BUG_ON(pte_none(*pte));
 			if (pages) {
 				pages[i] = pte_page(*pte);
 				get_page(pages[i]);
@@ -753,7 +761,7 @@
 			continue;
 		}
 
-		if (!vma || (pages && (vma->vm_flags & VM_IO))
+		if (!vma || (vma->vm_flags & VM_IO)
 				|| !(flags & vma->vm_flags))
 			return i ? : -EFAULT;
 
@@ -910,16 +918,14 @@
  * in null mappings (currently treated as "copy-on-access")
  */
 static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
-	unsigned long phys_addr, pgprot_t prot)
+	unsigned long pfn, pgprot_t prot)
 {
 	unsigned long end;
-	unsigned long pfn;
 
 	address &= ~PMD_MASK;
 	end = address + size;
 	if (end > PMD_SIZE)
 		end = PMD_SIZE;
-	pfn = phys_addr >> PAGE_SHIFT;
 	do {
 		BUG_ON(!pte_none(*pte));
 		if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
@@ -931,7 +937,7 @@
 }
 
 static inline int remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size,
-	unsigned long phys_addr, pgprot_t prot)
+	unsigned long pfn, pgprot_t prot)
 {
 	unsigned long base, end;
 
@@ -940,12 +946,12 @@
 	end = address + size;
 	if (end > PGDIR_SIZE)
 		end = PGDIR_SIZE;
-	phys_addr -= address;
+	pfn -= address >> PAGE_SHIFT;
 	do {
 		pte_t * pte = pte_alloc_map(mm, pmd, base + address);
 		if (!pte)
 			return -ENOMEM;
-		remap_pte_range(pte, base + address, end - address, address + phys_addr, prot);
+		remap_pte_range(pte, base + address, end - address, pfn + (address >> PAGE_SHIFT), prot);
 		pte_unmap(pte);
 		address = (address + PMD_SIZE) & PMD_MASK;
 		pmd++;
@@ -954,7 +960,7 @@
 }
 
 /*  Note: this is only safe if the mm semaphore is held when called. */
-int remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long phys_addr, unsigned long size, pgprot_t prot)
+int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot)
 {
 	int error = 0;
 	pgd_t * dir;
@@ -962,19 +968,28 @@
 	unsigned long end = from + size;
 	struct mm_struct *mm = vma->vm_mm;
 
-	phys_addr -= from;
+	pfn -= from >> PAGE_SHIFT;
 	dir = pgd_offset(mm, from);
 	flush_cache_range(vma, beg, end);
 	if (from >= end)
 		BUG();
 
+	/*
+	 * Physically remapped pages are special. Tell the
+	 * rest of the world about it:
+	 *   VM_IO tells people not to look at these pages
+	 *	(accesses can have side effects).
+	 *   VM_RESERVED tells swapout not to try to touch
+	 *	this region.
+	 */
+	vma->vm_flags |= VM_IO | VM_RESERVED;
 	spin_lock(&mm->page_table_lock);
 	do {
 		pmd_t *pmd = pmd_alloc(mm, dir, from);
 		error = -ENOMEM;
 		if (!pmd)
 			break;
-		error = remap_pmd_range(mm, pmd, from, end - from, phys_addr + from, prot);
+		error = remap_pmd_range(mm, pmd, from, end - from, pfn + (from >> PAGE_SHIFT), prot);
 		if (error)
 			break;
 		from = (from + PGDIR_SIZE) & PGDIR_MASK;
@@ -987,8 +1002,7 @@
 	spin_unlock(&mm->page_table_lock);
 	return error;
 }
-
-EXPORT_SYMBOL(remap_page_range);
+EXPORT_SYMBOL(remap_pfn_range);
 
 /*
  * Do pte_mkwrite, but only if the vma says VM_WRITE.  We do this when
@@ -1095,6 +1109,8 @@
 	spin_lock(&mm->page_table_lock);
 	page_table = pte_offset_map(pmd, address);
 	if (likely(pte_same(*page_table, pte))) {
+		if (PageAnon(old_page))
+			mm->anon_rss--;
 		if (PageReserved(old_page))
 			++mm->rss;
 		else
@@ -1236,7 +1252,7 @@
 	goto out_truncate;
 
 do_expand:
-	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
 	if (limit != RLIM_INFINITY && offset > limit)
 		goto out_sig;
 	if (offset > inode->i_sb->s_maxbytes)
@@ -1773,19 +1789,27 @@
 	if (!pgd_none(*pgd)) {
 		pmd = pmd_offset(pgd, addr);
 		if (!pmd_none(*pmd)) {
-			preempt_disable();
 			ptep = pte_offset_map(pmd, addr);
 			pte = *ptep;
 			if (pte_present(pte))
 				page = pte_page(pte);
 			pte_unmap(ptep);
-			preempt_enable();
 		}
 	}
 	return page;
 }
 
 EXPORT_SYMBOL(vmalloc_to_page);
+
+/*
+ * Map a vmalloc()-space virtual address to the physical page frame number.
+ */
+unsigned long vmalloc_to_pfn(void * vmalloc_addr)
+{
+	return page_to_pfn(vmalloc_to_page(vmalloc_addr));
+}
+
+EXPORT_SYMBOL(vmalloc_to_pfn);
 
 #if !defined(CONFIG_ARCH_GATE_AREA)
 
diff -Nru a/mm/mempolicy.c b/mm/mempolicy.c
--- a/mm/mempolicy.c	2004-12-24 13:37:31 -08:00
+++ b/mm/mempolicy.c	2004-12-24 13:37:31 -08:00
@@ -66,6 +66,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/nodemask.h>
 #include <linux/gfp.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -74,6 +75,7 @@
 #include <linux/init.h>
 #include <linux/compat.h>
 #include <linux/mempolicy.h>
+#include <asm/tlbflush.h>
 #include <asm/uaccess.h>
 
 static kmem_cache_t *policy_cache;
@@ -95,7 +97,7 @@
 {
 	DECLARE_BITMAP(online2, MAX_NUMNODES);
 
-	bitmap_copy(online2, node_online_map, MAX_NUMNODES);
+	bitmap_copy(online2, nodes_addr(node_online_map), MAX_NUMNODES);
 	if (bitmap_empty(online2, MAX_NUMNODES))
 		set_bit(0, online2);
 	if (!bitmap_subset(nodes, online2, MAX_NUMNODES))
@@ -424,7 +426,7 @@
 	case MPOL_PREFERRED:
 		/* or use current node instead of online map? */
 		if (p->v.preferred_node < 0)
-			bitmap_copy(nodes, node_online_map, MAX_NUMNODES);
+			bitmap_copy(nodes, nodes_addr(node_online_map), MAX_NUMNODES);
 		else
 			__set_bit(p->v.preferred_node, nodes);
 		break;
@@ -529,7 +531,7 @@
 
 #ifdef CONFIG_COMPAT
 
-asmlinkage long compat_get_mempolicy(int __user *policy,
+asmlinkage long compat_sys_get_mempolicy(int __user *policy,
 				     compat_ulong_t __user *nmask,
 				     compat_ulong_t maxnode,
 				     compat_ulong_t addr, compat_ulong_t flags)
@@ -557,7 +559,7 @@
 	return err;
 }
 
-asmlinkage long compat_set_mempolicy(int mode, compat_ulong_t __user *nmask,
+asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
 				     compat_ulong_t maxnode)
 {
 	long err = 0;
@@ -580,7 +582,7 @@
 	return sys_set_mempolicy(mode, nm, nr_bits+1);
 }
 
-asmlinkage long compat_mbind(compat_ulong_t start, compat_ulong_t len,
+asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
 			     compat_ulong_t mode, compat_ulong_t __user *nmask,
 			     compat_ulong_t maxnode, compat_ulong_t flags)
 {
@@ -692,7 +694,7 @@
 	struct zonelist *zl;
 	struct page *page;
 
-	BUG_ON(!test_bit(nid, node_online_map));
+	BUG_ON(!node_online(nid));
 	zl = NODE_DATA(nid)->node_zonelists + (gfp & GFP_ZONEMASK);
 	page = __alloc_pages(gfp, order, zl);
 	if (page && page_zone(page) == zl->zones[0]) {
@@ -886,12 +888,12 @@
  *
  * Remember policies even when nobody has shared memory mapped.
  * The policies are kept in Red-Black tree linked from the inode.
- * They are protected by the sp->sem semaphore, which should be held
+ * They are protected by the sp->lock spinlock, which should be held
  * for any accesses to the tree.
  */
 
 /* lookup first element intersecting start-end */
-/* Caller holds sp->sem */
+/* Caller holds sp->lock */
 static struct sp_node *
 sp_lookup(struct shared_policy *sp, unsigned long start, unsigned long end)
 {
@@ -899,13 +901,13 @@
 
 	while (n) {
 		struct sp_node *p = rb_entry(n, struct sp_node, nd);
-		if (start >= p->end) {
+
+		if (start >= p->end)
 			n = n->rb_right;
-		} else if (end < p->start) {
+		else if (end <= p->start)
 			n = n->rb_left;
-		} else {
+		else
 			break;
-		}
 	}
 	if (!n)
 		return NULL;
@@ -923,7 +925,7 @@
 }
 
 /* Insert a new shared policy into the list. */
-/* Caller holds sp->sem */
+/* Caller holds sp->lock */
 static void sp_insert(struct shared_policy *sp, struct sp_node *new)
 {
 	struct rb_node **p = &sp->root.rb_node;
@@ -953,13 +955,15 @@
 	struct mempolicy *pol = NULL;
 	struct sp_node *sn;
 
-	down(&sp->sem);
+	if (!sp->root.rb_node)
+		return NULL;
+	spin_lock(&sp->lock);
 	sn = sp_lookup(sp, idx, idx+1);
 	if (sn) {
 		mpol_get(sn->policy);
 		pol = sn->policy;
 	}
-	up(&sp->sem);
+	spin_unlock(&sp->lock);
 	return pol;
 }
 
@@ -989,9 +993,10 @@
 static int shared_policy_replace(struct shared_policy *sp, unsigned long start,
 				 unsigned long end, struct sp_node *new)
 {
-	struct sp_node *n, *new2;
+	struct sp_node *n, *new2 = NULL;
 
-	down(&sp->sem);
+restart:
+	spin_lock(&sp->lock);
 	n = sp_lookup(sp, start, end);
 	/* Take care of old policies in the same range. */
 	while (n && n->start < end) {
@@ -1004,13 +1009,16 @@
 		} else {
 			/* Old policy spanning whole new range. */
 			if (n->end > end) {
-				new2 = sp_alloc(end, n->end, n->policy);
 				if (!new2) {
-					up(&sp->sem);
-					return -ENOMEM;
+					spin_unlock(&sp->lock);
+					new2 = sp_alloc(end, n->end, n->policy);
+					if (!new2)
+						return -ENOMEM;
+					goto restart;
 				}
 				n->end = end;
 				sp_insert(sp, new2);
+				new2 = NULL;
 			}
 			/* Old crossing beginning, but not end (easy) */
 			if (n->start < start && n->end > start)
@@ -1022,7 +1030,11 @@
 	}
 	if (new)
 		sp_insert(sp, new);
-	up(&sp->sem);
+	spin_unlock(&sp->lock);
+	if (new2) {
+		mpol_free(new2->policy);
+		kmem_cache_free(sn_cache, new2);
+	}
 	return 0;
 }
 
@@ -1055,7 +1067,9 @@
 	struct sp_node *n;
 	struct rb_node *next;
 
-	down(&p->sem);
+	if (!p->root.rb_node)
+		return;
+	spin_lock(&p->lock);
 	next = rb_first(&p->root);
 	while (next) {
 		n = rb_entry(next, struct sp_node, nd);
@@ -1064,7 +1078,7 @@
 		mpol_free(n->policy);
 		kmem_cache_free(sn_cache, n);
 	}
-	up(&p->sem);
+	spin_unlock(&p->lock);
 }
 
 /* assumes fs == KERNEL_DS */
@@ -1081,7 +1095,8 @@
 	/* Set interleaving policy for system init. This way not all
 	   the data structures allocated at system boot end up in node zero. */
 
-	if (sys_set_mempolicy(MPOL_INTERLEAVE, node_online_map, MAX_NUMNODES) < 0)
+	if (sys_set_mempolicy(MPOL_INTERLEAVE, nodes_addr(node_online_map),
+							MAX_NUMNODES) < 0)
 		printk("numa_policy_init: interleaving failed\n");
 }
 
diff -Nru a/mm/mincore.c b/mm/mincore.c
--- a/mm/mincore.c	2004-12-24 13:37:30 -08:00
+++ b/mm/mincore.c	2004-12-24 13:37:30 -08:00
@@ -11,6 +11,7 @@
 #include <linux/pagemap.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
diff -Nru a/mm/mlock.c b/mm/mlock.c
--- a/mm/mlock.c	2004-12-24 13:36:17 -08:00
+++ b/mm/mlock.c	2004-12-24 13:36:17 -08:00
@@ -7,6 +7,7 @@
 
 #include <linux/mman.h>
 #include <linux/mm.h>
+#include <linux/syscalls.h>
 
 
 static int mlock_fixup(struct vm_area_struct * vma, 
@@ -46,7 +47,8 @@
 	pages = (end - start) >> PAGE_SHIFT;
 	if (newflags & VM_LOCKED) {
 		pages = -pages;
-		ret = make_pages_present(start, end);
+		if (!(newflags & VM_IO))
+			ret = make_pages_present(start, end);
 	}
 
 	vma->vm_mm->locked_vm -= pages;
@@ -115,7 +117,7 @@
 	locked = len >> PAGE_SHIFT;
 	locked += current->mm->locked_vm;
 
-	lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
+	lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
 	lock_limit >>= PAGE_SHIFT;
 
 	/* check against resource limits */
@@ -176,7 +178,7 @@
 
 	down_write(&current->mm->mmap_sem);
 
-	lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
+	lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
 	lock_limit >>= PAGE_SHIFT;
 
 	ret = -ENOMEM;
@@ -209,10 +211,10 @@
 	unsigned long lock_limit, locked;
 	int allowed = 0;
 
-	spin_lock(&shmlock_user_lock);
-	locked = size >> PAGE_SHIFT;
-	lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
+	locked = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+	lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
 	lock_limit >>= PAGE_SHIFT;
+	spin_lock(&shmlock_user_lock);
 	if (locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK))
 		goto out;
 	get_uid(user);
@@ -226,7 +228,7 @@
 void user_shm_unlock(size_t size, struct user_struct *user)
 {
 	spin_lock(&shmlock_user_lock);
-	user->locked_shm -= (size >> PAGE_SHIFT);
+	user->locked_shm -= (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	spin_unlock(&shmlock_user_lock);
 	free_uid(user);
 }
diff -Nru a/mm/mmap.c b/mm/mmap.c
--- a/mm/mmap.c	2004-12-24 13:37:00 -08:00
+++ b/mm/mmap.c	2004-12-24 13:37:00 -08:00
@@ -136,7 +136,7 @@
 	}
 
 	/* Check against rlimit.. */
-	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
+	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
 	if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
 		goto out;
 
@@ -744,12 +744,12 @@
 	}
 #endif /* CONFIG_HUGETLB */
 
-	if (file)
+	if (file) {
 		mm->shared_vm += pages;
-	else if (flags & stack_flags)
+		if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
+			mm->exec_vm += pages;
+	} else if (flags & stack_flags)
 		mm->stack_vm += pages;
-	if (flags & VM_EXEC)
-		mm->exec_vm += pages;
 	if (flags & (VM_RESERVED|VM_IO))
 		mm->reserved_vm += pages;
 }
@@ -833,7 +833,7 @@
 	if (vm_flags & VM_LOCKED) {
 		unsigned long locked, lock_limit;
 		locked = mm->locked_vm << PAGE_SHIFT;
-		lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
+		lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
 		locked += len;
 		if (locked > lock_limit && !capable(CAP_IPC_LOCK))
 			return -EAGAIN;
@@ -905,7 +905,7 @@
 
 	/* Check against address space limit. */
 	if ((mm->total_vm << PAGE_SHIFT) + len
-	    > current->rlim[RLIMIT_AS].rlim_cur)
+	    > current->signal->rlim[RLIMIT_AS].rlim_cur)
 		return -ENOMEM;
 
 	if (accountable && (!(flags & MAP_NORESERVE) ||
@@ -988,9 +988,12 @@
 	 *         f_op->mmap method. -DaveM
 	 */
 	addr = vma->vm_start;
+	pgoff = vma->vm_pgoff;
+	vm_flags = vma->vm_flags;
 
 	if (!file || !vma_merge(mm, prev, addr, vma->vm_end,
 			vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) {
+		file = vma->vm_file;
 		vma_link(mm, vma, prev, rb_link, rb_parent);
 		if (correct_wcount)
 			atomic_inc(&inode->i_writecount);
@@ -1005,6 +1008,7 @@
 	}
 out:	
 	mm->total_vm += len >> PAGE_SHIFT;
+	__vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
 	if (vm_flags & VM_LOCKED) {
 		mm->locked_vm += len >> PAGE_SHIFT;
 		make_pages_present(addr, addr + len);
@@ -1015,7 +1019,6 @@
 					pgoff, flags & MAP_NONBLOCK);
 		down_write(&mm->mmap_sem);
 	}
-	__vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
 	return addr;
 
 unmap_and_free_vma:
@@ -1350,9 +1353,9 @@
 		return -ENOMEM;
 	}
 	
-	if (address - vma->vm_start > current->rlim[RLIMIT_STACK].rlim_cur ||
+	if (address - vma->vm_start > current->signal->rlim[RLIMIT_STACK].rlim_cur ||
 			((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) >
-			current->rlim[RLIMIT_AS].rlim_cur) {
+			current->signal->rlim[RLIMIT_AS].rlim_cur) {
 		anon_vma_unlock(vma);
 		vm_unacct_memory(grow);
 		return -ENOMEM;
@@ -1412,9 +1415,9 @@
 		return -ENOMEM;
 	}
 	
-	if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur ||
+	if (vma->vm_end - address > current->signal->rlim[RLIMIT_STACK].rlim_cur ||
 			((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) >
-			current->rlim[RLIMIT_AS].rlim_cur) {
+			current->signal->rlim[RLIMIT_AS].rlim_cur) {
 		anon_vma_unlock(vma);
 		vm_unacct_memory(grow);
 		return -ENOMEM;
@@ -1760,7 +1763,7 @@
 	if (mm->def_flags & VM_LOCKED) {
 		unsigned long locked, lock_limit;
 		locked = mm->locked_vm << PAGE_SHIFT;
-		lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
+		lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
 		locked += len;
 		if (locked > lock_limit && !capable(CAP_IPC_LOCK))
 			return -EAGAIN;
@@ -1779,7 +1782,7 @@
 
 	/* Check against address space limits *after* clearing old maps... */
 	if ((mm->total_vm << PAGE_SHIFT) + len
-	    > current->rlim[RLIMIT_AS].rlim_cur)
+	    > current->signal->rlim[RLIMIT_AS].rlim_cur)
 		return -ENOMEM;
 
 	if (mm->map_count > sysctl_max_map_count)
@@ -1868,7 +1871,7 @@
  * and into the inode's i_mmap tree.  If vm_file is non-NULL
  * then i_mmap_lock is taken here.
  */
-void insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
+int insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
 {
 	struct vm_area_struct * __vma, * prev;
 	struct rb_node ** rb_link, * rb_parent;
@@ -1891,8 +1894,9 @@
 	}
 	__vma = find_vma_prepare(mm,vma->vm_start,&prev,&rb_link,&rb_parent);
 	if (__vma && __vma->vm_start < vma->vm_end)
-		BUG();
+		return -ENOMEM;
 	vma_link(mm, vma, prev, rb_link, rb_parent);
+	return 0;
 }
 
 /*
diff -Nru a/mm/mprotect.c b/mm/mprotect.c
--- a/mm/mprotect.c	2004-12-24 13:37:43 -08:00
+++ b/mm/mprotect.c	2004-12-24 13:37:43 -08:00
@@ -18,6 +18,7 @@
 #include <linux/security.h>
 #include <linux/mempolicy.h>
 #include <linux/personality.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -110,15 +111,17 @@
 
 static int
 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
-	unsigned long start, unsigned long end, unsigned int newflags)
+	unsigned long start, unsigned long end, unsigned long newflags)
 {
 	struct mm_struct * mm = vma->vm_mm;
+	unsigned long oldflags = vma->vm_flags;
+	long nrpages = (end - start) >> PAGE_SHIFT;
 	unsigned long charged = 0;
 	pgprot_t newprot;
 	pgoff_t pgoff;
 	int error;
 
-	if (newflags == vma->vm_flags) {
+	if (newflags == oldflags) {
 		*pprev = vma;
 		return 0;
 	}
@@ -132,8 +135,8 @@
 	 * a MAP_NORESERVE private mapping to writable will now reserve.
 	 */
 	if (newflags & VM_WRITE) {
-		if (!(vma->vm_flags & (VM_ACCOUNT|VM_WRITE|VM_SHARED|VM_HUGETLB))) {
-			charged = (end - start) >> PAGE_SHIFT;
+		if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_SHARED|VM_HUGETLB))) {
+			charged = nrpages;
 			if (security_vm_enough_memory(charged))
 				return -ENOMEM;
 			newflags |= VM_ACCOUNT;
@@ -175,11 +178,11 @@
 	 * vm_flags and vm_page_prot are protected by the mmap_sem
 	 * held in write mode.
 	 */
-	vm_stat_unaccount(vma);
 	vma->vm_flags = newflags;
 	vma->vm_page_prot = newprot;
 	change_protection(vma, start, end, newprot);
-	vm_stat_account(vma);
+	__vm_stat_account(mm, oldflags, vma->vm_file, -nrpages);
+	__vm_stat_account(mm, newflags, vma->vm_file, nrpages);
 	return 0;
 
 fail:
@@ -245,7 +248,7 @@
 		prev = vma;
 
 	for (nstart = start ; ; ) {
-		unsigned int newflags;
+		unsigned long newflags;
 
 		/* Here we know that  vma->vm_start <= nstart < vma->vm_end. */
 
diff -Nru a/mm/mremap.c b/mm/mremap.c
--- a/mm/mremap.c	2004-12-24 13:36:56 -08:00
+++ b/mm/mremap.c	2004-12-24 13:36:56 -08:00
@@ -16,6 +16,7 @@
 #include <linux/fs.h>
 #include <linux/highmem.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/cacheflush.h>
@@ -327,7 +328,7 @@
 	if (vma->vm_flags & VM_LOCKED) {
 		unsigned long locked, lock_limit;
 		locked = current->mm->locked_vm << PAGE_SHIFT;
-		lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
+		lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
 		locked += new_len - old_len;
 		ret = -EAGAIN;
 		if (locked > lock_limit && !capable(CAP_IPC_LOCK))
@@ -335,7 +336,7 @@
 	}
 	ret = -ENOMEM;
 	if ((current->mm->total_vm << PAGE_SHIFT) + (new_len - old_len)
-	    > current->rlim[RLIMIT_AS].rlim_cur)
+	    > current->signal->rlim[RLIMIT_AS].rlim_cur)
 		goto out;
 
 	if (vma->vm_flags & VM_ACCOUNT) {
diff -Nru a/mm/msync.c b/mm/msync.c
--- a/mm/msync.c	2004-12-24 13:36:47 -08:00
+++ b/mm/msync.c	2004-12-24 13:36:47 -08:00
@@ -12,6 +12,7 @@
 #include <linux/mm.h>
 #include <linux/mman.h>
 #include <linux/hugetlb.h>
+#include <linux/syscalls.h>
 
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
diff -Nru a/mm/nommu.c b/mm/nommu.c
--- a/mm/nommu.c	2004-12-24 13:37:19 -08:00
+++ b/mm/nommu.c	2004-12-24 13:37:19 -08:00
@@ -19,6 +19,7 @@
 #include <linux/vmalloc.h>
 #include <linux/blkdev.h>
 #include <linux/backing-dev.h>
+#include <linux/syscalls.h>
 
 #include <asm/uaccess.h>
 #include <asm/tlb.h>
@@ -32,9 +33,10 @@
 atomic_t vm_committed_space = ATOMIC_INIT(0);
 int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
 int sysctl_overcommit_ratio = 50; /* default is 50% */
-
 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
+
 EXPORT_SYMBOL(sysctl_max_map_count);
+EXPORT_SYMBOL(mem_map);
 
 /*
  * Handle all mappings that got truncated by a "truncate()"
@@ -57,7 +59,7 @@
 	goto out_truncate;
 
 do_expand:
-	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+	limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
 	if (limit != RLIM_INFINITY && offset > limit)
 		goto out_sig;
 	if (offset > inode->i_sb->s_maxbytes)
@@ -74,6 +76,8 @@
 	return -EFBIG;
 }
 
+EXPORT_SYMBOL(vmtruncate);
+
 /*
  * Return the total memory allocated for this pointer, not
  * just what the caller asked for.
@@ -140,6 +144,12 @@
 	return virt_to_page(addr);
 }
 
+unsigned long vmalloc_to_pfn(void *addr)
+{
+	return page_to_pfn(virt_to_page(addr));
+}
+
+
 long vread(char *buf, char *addr, unsigned long count)
 {
 	memcpy(buf, addr, count);
@@ -430,6 +440,7 @@
 
 	tblock->next = current->mm->context.tblock.next;
 	current->mm->context.tblock.next = tblock;
+	current->mm->total_vm += len >> PAGE_SHIFT;
 
 #ifdef DEBUG
 	printk("do_mmap:\n");
@@ -483,6 +494,7 @@
 	realalloc -= kobjsize(tblock);
 	askedalloc -= sizeof(struct mm_tblock_struct);
 	kfree(tblock);
+	mm->total_vm -= len >> PAGE_SHIFT;
 
 #ifdef DEBUG
 	show_process_blocks();
@@ -495,6 +507,7 @@
 void exit_mmap(struct mm_struct * mm)
 {
 	struct mm_tblock_struct *tmp;
+	mm->total_vm = 0;
 
 	if (!mm)
 		return;
@@ -559,7 +572,7 @@
 	return NULL;
 }
 
-int remap_page_range(struct vm_area_struct *vma, unsigned long from,
+int remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
 		unsigned long to, unsigned long size, pgprot_t prot)
 {
 	return -EPERM;
@@ -574,3 +587,14 @@
 void swap_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
 {
 }
+
+unsigned long arch_get_unmapped_area(struct file *file, unsigned long addr,
+	unsigned long len, unsigned long pgoff, unsigned long flags)
+{
+	return -ENOMEM;
+}
+
+void arch_unmap_area(struct vm_area_struct *area)
+{
+}
+
diff -Nru a/mm/page-writeback.c b/mm/page-writeback.c
--- a/mm/page-writeback.c	2004-12-24 13:37:01 -08:00
+++ b/mm/page-writeback.c	2004-12-24 13:37:01 -08:00
@@ -504,6 +504,11 @@
 		dirty_background_ratio /= 100;
 		vm_dirty_ratio *= correction;
 		vm_dirty_ratio /= 100;
+
+		if (dirty_background_ratio <= 0)
+			dirty_background_ratio = 1;
+		if (vm_dirty_ratio <= 0)
+			vm_dirty_ratio = 1;
 	}
 	mod_timer(&wb_timer, jiffies + (dirty_writeback_centisecs * HZ) / 100);
 	set_ratelimit();
@@ -580,12 +585,13 @@
 
 	if (!TestSetPageDirty(page)) {
 		struct address_space *mapping = page_mapping(page);
+		struct address_space *mapping2;
 
 		if (mapping) {
 			spin_lock_irq(&mapping->tree_lock);
-			mapping = page_mapping(page);
-			if (page_mapping(page)) { /* Race with truncate? */
-				BUG_ON(page_mapping(page) != mapping);
+			mapping2 = page_mapping(page);
+			if (mapping2) { /* Race with truncate? */
+				BUG_ON(mapping2 != mapping);
 				if (!mapping->backing_dev_info->memory_backed)
 					inc_page_state(nr_dirty);
 				radix_tree_tag_set(&mapping->page_tree,
diff -Nru a/mm/page_alloc.c b/mm/page_alloc.c
--- a/mm/page_alloc.c	2004-12-24 13:36:18 -08:00
+++ b/mm/page_alloc.c	2004-12-24 13:36:18 -08:00
@@ -31,10 +31,12 @@
 #include <linux/topology.h>
 #include <linux/sysctl.h>
 #include <linux/cpu.h>
+#include <linux/nodemask.h>
 
 #include <asm/tlbflush.h>
 
-DECLARE_BITMAP(node_online_map, MAX_NUMNODES);
+nodemask_t node_online_map = NODE_MASK_NONE;
+nodemask_t node_possible_map = NODE_MASK_ALL;
 struct pglist_data *pgdat_list;
 unsigned long totalram_pages;
 unsigned long totalhigh_pages;
@@ -92,6 +94,7 @@
 	set_page_count(page, 0);
 	reset_page_mapcount(page);
 	page->mapping = NULL;
+	tainted |= TAINT_BAD_PAGE;
 }
 
 #ifndef CONFIG_HUGETLB_PAGE
@@ -1100,6 +1103,8 @@
 			" active:%lukB"
 			" inactive:%lukB"
 			" present:%lukB"
+			" pages_scanned:%lu"
+			" all_unreclaimable? %s"
 			"\n",
 			zone->name,
 			K(zone->free_pages),
@@ -1108,7 +1113,9 @@
 			K(zone->pages_high),
 			K(zone->nr_active),
 			K(zone->nr_inactive),
-			K(zone->present_pages)
+			K(zone->present_pages),
+			zone->pages_scanned,
+			(zone->all_unreclaimable ? "yes" : "no")
 			);
 		printk("protections[]:");
 		for (i = 0; i < MAX_NR_ZONES; i++)
@@ -1206,6 +1213,12 @@
 		if (test_bit(n, used_node_mask))
 			continue;
 
+		/* Use the local node if we haven't already */
+		if (!test_bit(node, used_node_mask)) {
+			best_node = node;
+			break;
+		}
+
 		/* Use the distance array to find the distance */
 		val = node_distance(node, n);
 
@@ -1932,8 +1945,12 @@
 			                   lowmem_pages;
 		}
 
-		zone->pages_low = zone->pages_min * 2;
-		zone->pages_high = zone->pages_min * 3;
+		/*
+		 * When interpreting these watermarks, just keep in mind that:
+		 * zone->pages_min == (zone->pages_min * 4) / 4;
+		 */
+		zone->pages_low   = (zone->pages_min * 5) / 4;
+		zone->pages_high  = (zone->pages_min * 6) / 4;
 		spin_unlock_irqrestore(&zone->lru_lock, flags);
 	}
 }
@@ -1942,24 +1959,25 @@
  * Initialise min_free_kbytes.
  *
  * For small machines we want it small (128k min).  For large machines
- * we want it large (16MB max).  But it is not linear, because network
+ * we want it large (64MB max).  But it is not linear, because network
  * bandwidth does not increase linearly with machine size.  We use
  *
- *	min_free_kbytes = sqrt(lowmem_kbytes)
+ * 	min_free_kbytes = 4 * sqrt(lowmem_kbytes), for better accuracy:
+ *	min_free_kbytes = sqrt(lowmem_kbytes * 16)
  *
  * which yields
  *
- * 16MB:	128k
- * 32MB:	181k
- * 64MB:	256k
- * 128MB:	362k
- * 256MB:	512k
- * 512MB:	724k
- * 1024MB:	1024k
- * 2048MB:	1448k
- * 4096MB:	2048k
- * 8192MB:	2896k
- * 16384MB:	4096k
+ * 16MB:	512k
+ * 32MB:	724k
+ * 64MB:	1024k
+ * 128MB:	1448k
+ * 256MB:	2048k
+ * 512MB:	2896k
+ * 1024MB:	4096k
+ * 2048MB:	5792k
+ * 4096MB:	8192k
+ * 8192MB:	11584k
+ * 16384MB:	16384k
  */
 static int __init init_per_zone_pages_min(void)
 {
@@ -1967,11 +1985,11 @@
 
 	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
 
-	min_free_kbytes = int_sqrt(lowmem_kbytes);
+	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
 	if (min_free_kbytes < 128)
 		min_free_kbytes = 128;
-	if (min_free_kbytes > 16384)
-		min_free_kbytes = 16384;
+	if (min_free_kbytes > 65536)
+		min_free_kbytes = 65536;
 	setup_per_zone_pages_min();
 	setup_per_zone_protection();
 	return 0;
diff -Nru a/mm/prio_tree.c b/mm/prio_tree.c
--- a/mm/prio_tree.c	2004-12-24 13:37:29 -08:00
+++ b/mm/prio_tree.c	2004-12-24 13:37:29 -08:00
@@ -245,7 +245,7 @@
 		mask >>= 1;
 
 		if (!mask) {
-			mask = 1UL << (root->index_bits - 1);
+			mask = 1UL << (BITS_PER_LONG - 1);
 			size_flag = 1;
 		}
 	}
@@ -334,7 +334,7 @@
 				iter->mask = ULONG_MAX;
 			} else {
 				iter->size_level = 1;
-				iter->mask = 1UL << (iter->root->index_bits - 1);
+				iter->mask = 1UL << (BITS_PER_LONG - 1);
 			}
 		}
 		return iter->cur;
@@ -376,7 +376,7 @@
 				iter->mask = ULONG_MAX;
 			} else {
 				iter->size_level = 1;
-				iter->mask = 1UL << (iter->root->index_bits - 1);
+				iter->mask = 1UL << (BITS_PER_LONG - 1);
 			}
 		}
 		return iter->cur;
diff -Nru a/mm/rmap.c b/mm/rmap.c
--- a/mm/rmap.c	2004-12-24 13:37:19 -08:00
+++ b/mm/rmap.c	2004-12-24 13:37:19 -08:00
@@ -35,6 +35,7 @@
  *         mm->page_table_lock
  *           zone->lru_lock (in mark_page_accessed)
  *           swap_list_lock (in swap_free etc's swap_info_get)
+ *             mmlist_lock (in mmput, drain_mmlist and others)
  *             swap_device_lock (in swap_duplicate, swap_info_get)
  *             mapping->private_lock (in __set_page_dirty_buffers)
  *             inode_lock (in set_page_dirty's __mark_inode_dirty)
@@ -253,7 +254,7 @@
  * repeatedly from either page_referenced_anon or page_referenced_file.
  */
 static int page_referenced_one(struct page *page,
-	struct vm_area_struct *vma, unsigned int *mapcount)
+	struct vm_area_struct *vma, unsigned int *mapcount, int ignore_token)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long address;
@@ -288,7 +289,7 @@
 	if (ptep_clear_flush_young(vma, address, pte))
 		referenced++;
 
-	if (mm != current->mm && has_swap_token(mm))
+	if (mm != current->mm && !ignore_token && has_swap_token(mm))
 		referenced++;
 
 	(*mapcount)--;
@@ -301,7 +302,7 @@
 	return referenced;
 }
 
-static int page_referenced_anon(struct page *page)
+static int page_referenced_anon(struct page *page, int ignore_token)
 {
 	unsigned int mapcount;
 	struct anon_vma *anon_vma;
@@ -314,7 +315,8 @@
 
 	mapcount = page_mapcount(page);
 	list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
-		referenced += page_referenced_one(page, vma, &mapcount);
+		referenced += page_referenced_one(page, vma, &mapcount,
+							ignore_token);
 		if (!mapcount)
 			break;
 	}
@@ -333,7 +335,7 @@
  *
  * This function is only called from page_referenced for object-based pages.
  */
-static int page_referenced_file(struct page *page)
+static int page_referenced_file(struct page *page, int ignore_token)
 {
 	unsigned int mapcount;
 	struct address_space *mapping = page->mapping;
@@ -371,7 +373,8 @@
 			referenced++;
 			break;
 		}
-		referenced += page_referenced_one(page, vma, &mapcount);
+		referenced += page_referenced_one(page, vma, &mapcount,
+							ignore_token);
 		if (!mapcount)
 			break;
 	}
@@ -388,10 +391,13 @@
  * Quick test_and_clear_referenced for all mappings to a page,
  * returns the number of ptes which referenced the page.
  */
-int page_referenced(struct page *page, int is_locked)
+int page_referenced(struct page *page, int is_locked, int ignore_token)
 {
 	int referenced = 0;
 
+	if (!swap_token_default_timeout)
+		ignore_token = 1;
+
 	if (page_test_and_clear_young(page))
 		referenced++;
 
@@ -400,14 +406,15 @@
 
 	if (page_mapped(page) && page->mapping) {
 		if (PageAnon(page))
-			referenced += page_referenced_anon(page);
+			referenced += page_referenced_anon(page, ignore_token);
 		else if (is_locked)
-			referenced += page_referenced_file(page);
+			referenced += page_referenced_file(page, ignore_token);
 		else if (TestSetPageLocked(page))
 			referenced++;
 		else {
 			if (page->mapping)
-				referenced += page_referenced_file(page);
+				referenced += page_referenced_file(page,
+								ignore_token);
 			unlock_page(page);
 		}
 	}
@@ -431,6 +438,8 @@
 	BUG_ON(PageReserved(page));
 	BUG_ON(!anon_vma);
 
+	vma->vm_mm->anon_rss++;
+
 	anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
 	index = (address - vma->vm_start) >> PAGE_SHIFT;
 	index += vma->vm_pgoff;
@@ -576,8 +585,14 @@
 		 */
 		BUG_ON(!PageSwapCache(page));
 		swap_duplicate(entry);
+		if (list_empty(&mm->mmlist)) {
+			spin_lock(&mmlist_lock);
+			list_add(&mm->mmlist, &init_mm.mmlist);
+			spin_unlock(&mmlist_lock);
+		}
 		set_pte(pte, swp_entry_to_pte(entry));
 		BUG_ON(pte_file(*pte));
+		mm->anon_rss--;
 	}
 
 	mm->rss--;
diff -Nru a/mm/shmem.c b/mm/shmem.c
--- a/mm/shmem.c	2004-12-24 13:36:48 -08:00
+++ b/mm/shmem.c	2004-12-24 13:36:48 -08:00
@@ -10,6 +10,10 @@
  * Copyright (C) 2002-2004 VERITAS Software Corporation.
  * Copyright (C) 2004 Andi Kleen, SuSE Labs
  *
+ * Extended attribute support for tmpfs:
+ * Copyright (c) 2004, Luke Kenneth Casson Leighton <lkcl@lkcl.net>
+ * Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
+ *
  * This file is released under the GPL.
  */
 
@@ -41,6 +45,7 @@
 #include <linux/swapops.h>
 #include <linux/mempolicy.h>
 #include <linux/namei.h>
+#include <linux/xattr.h>
 #include <asm/uaccess.h>
 #include <asm/div64.h>
 #include <asm/pgtable.h>
@@ -61,6 +66,9 @@
 #define SHMEM_PAGEIN	 VM_READ
 #define SHMEM_TRUNCATE	 VM_WRITE
 
+/* Definition to limit shmem_truncate's steps between cond_rescheds */
+#define LATENCY_LIMIT	 64
+
 /* Pretend that each entry is of this size in directory's i_size */
 #define BOGO_DIRENT_SIZE 20
 
@@ -171,6 +179,7 @@
 static struct file_operations shmem_file_operations;
 static struct inode_operations shmem_inode_operations;
 static struct inode_operations shmem_dir_inode_operations;
+static struct inode_operations shmem_special_inode_operations;
 static struct vm_operations_struct shmem_vm_ops;
 
 static struct backing_dev_info shmem_backing_dev_info = {
@@ -182,13 +191,13 @@
 static LIST_HEAD(shmem_swaplist);
 static spinlock_t shmem_swaplist_lock = SPIN_LOCK_UNLOCKED;
 
-static void shmem_free_block(struct inode *inode)
+static void shmem_free_blocks(struct inode *inode, long pages)
 {
 	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
 	if (sbinfo) {
 		spin_lock(&sbinfo->stat_lock);
-		sbinfo->free_blocks++;
-		inode->i_blocks -= BLOCKS_PER_PAGE;
+		sbinfo->free_blocks += pages;
+		inode->i_blocks -= pages*BLOCKS_PER_PAGE;
 		spin_unlock(&sbinfo->stat_lock);
 	}
 }
@@ -213,15 +222,9 @@
 
 	freed = info->alloced - info->swapped - inode->i_mapping->nrpages;
 	if (freed > 0) {
-		struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
 		info->alloced -= freed;
 		shmem_unacct_blocks(info->flags, freed);
-		if (sbinfo) {
-			spin_lock(&sbinfo->stat_lock);
-			sbinfo->free_blocks += freed;
-			inode->i_blocks -= freed*BLOCKS_PER_PAGE;
-			spin_unlock(&sbinfo->stat_lock);
-		}
+		shmem_free_blocks(inode, freed);
 	}
 }
 
@@ -374,7 +377,7 @@
 		spin_lock(&info->lock);
 
 		if (!page) {
-			shmem_free_block(inode);
+			shmem_free_blocks(inode, 1);
 			return ERR_PTR(-ENOMEM);
 		}
 		if (sgp != SGP_WRITE &&
@@ -387,7 +390,7 @@
 	}
 	if (page) {
 		/* another task gave its page, or truncated the file */
-		shmem_free_block(inode);
+		shmem_free_blocks(inode, 1);
 		shmem_dir_free(page);
 	}
 	if (info->next_index <= index && !IS_ERR(entry))
@@ -416,6 +419,49 @@
 	return freed;
 }
 
+static int shmem_map_and_free_swp(struct page *subdir,
+		int offset, int limit, struct page ***dir)
+{
+	swp_entry_t *ptr;
+	int freed = 0;
+
+	ptr = shmem_swp_map(subdir);
+	for (; offset < limit; offset += LATENCY_LIMIT) {
+		int size = limit - offset;
+		if (size > LATENCY_LIMIT)
+			size = LATENCY_LIMIT;
+		freed += shmem_free_swp(ptr+offset, ptr+offset+size);
+		if (need_resched()) {
+			shmem_swp_unmap(ptr);
+			if (*dir) {
+				shmem_dir_unmap(*dir);
+				*dir = NULL;
+			}
+			cond_resched();
+			ptr = shmem_swp_map(subdir);
+		}
+	}
+	shmem_swp_unmap(ptr);
+	return freed;
+}
+
+static void shmem_free_pages(struct list_head *next)
+{
+	struct page *page;
+	int freed = 0;
+
+	do {
+		page = container_of(next, struct page, lru);
+		next = next->next;
+		shmem_dir_free(page);
+		freed++;
+		if (freed >= LATENCY_LIMIT) {
+			cond_resched();
+			freed = 0;
+		}
+	} while (next);
+}
+
 static void shmem_truncate(struct inode *inode)
 {
 	struct shmem_inode_info *info = SHMEM_I(inode);
@@ -423,10 +469,15 @@
 	unsigned long size;
 	unsigned long limit;
 	unsigned long stage;
+	unsigned long diroff;
 	struct page **dir;
+	struct page *topdir;
+	struct page *middir;
 	struct page *subdir;
-	struct page *empty;
 	swp_entry_t *ptr;
+	LIST_HEAD(pages_to_free);
+	long nr_pages_to_free = 0;
+	long nr_swaps_freed = 0;
 	int offset;
 	int freed;
 
@@ -439,14 +490,22 @@
 	info->flags |= SHMEM_TRUNCATE;
 	limit = info->next_index;
 	info->next_index = idx;
+	topdir = info->i_indirect;
+	if (topdir && idx <= SHMEM_NR_DIRECT) {
+		info->i_indirect = NULL;
+		nr_pages_to_free++;
+		list_add(&topdir->lru, &pages_to_free);
+	}
+	spin_unlock(&info->lock);
+
 	if (info->swapped && idx < SHMEM_NR_DIRECT) {
 		ptr = info->i_direct;
 		size = limit;
 		if (size > SHMEM_NR_DIRECT)
 			size = SHMEM_NR_DIRECT;
-		info->swapped -= shmem_free_swp(ptr+idx, ptr+size);
+		nr_swaps_freed = shmem_free_swp(ptr+idx, ptr+size);
 	}
-	if (!info->i_indirect)
+	if (!topdir)
 		goto done2;
 
 	BUG_ON(limit <= SHMEM_NR_DIRECT);
@@ -455,36 +514,38 @@
 	offset = idx % ENTRIES_PER_PAGE;
 	idx -= offset;
 
-	empty = NULL;
-	dir = shmem_dir_map(info->i_indirect);
+	dir = shmem_dir_map(topdir);
 	stage = ENTRIES_PER_PAGEPAGE/2;
-	if (idx < ENTRIES_PER_PAGEPAGE/2)
-		dir += idx/ENTRIES_PER_PAGE;
-	else {
+	if (idx < ENTRIES_PER_PAGEPAGE/2) {
+		middir = topdir;
+		diroff = idx/ENTRIES_PER_PAGE;
+	} else {
 		dir += ENTRIES_PER_PAGE/2;
 		dir += (idx - ENTRIES_PER_PAGEPAGE/2)/ENTRIES_PER_PAGEPAGE;
 		while (stage <= idx)
 			stage += ENTRIES_PER_PAGEPAGE;
+		middir = *dir;
 		if (*dir) {
-			subdir = *dir;
-			size = ((idx - ENTRIES_PER_PAGEPAGE/2) %
+			diroff = ((idx - ENTRIES_PER_PAGEPAGE/2) %
 				ENTRIES_PER_PAGEPAGE) / ENTRIES_PER_PAGE;
-			if (!size && !offset) {
-				empty = subdir;
+			if (!diroff && !offset) {
 				*dir = NULL;
+				nr_pages_to_free++;
+				list_add(&middir->lru, &pages_to_free);
 			}
 			shmem_dir_unmap(dir);
-			dir = shmem_dir_map(subdir) + size;
+			dir = shmem_dir_map(middir);
 		} else {
+			diroff = 0;
 			offset = 0;
 			idx = stage;
 		}
 	}
 
-	for (; idx < limit; idx += ENTRIES_PER_PAGE, dir++) {
+	for (; idx < limit; idx += ENTRIES_PER_PAGE, diroff++) {
 		if (unlikely(idx == stage)) {
-			shmem_dir_unmap(dir-1);
-			dir = shmem_dir_map(info->i_indirect) +
+			shmem_dir_unmap(dir);
+			dir = shmem_dir_map(topdir) +
 			    ENTRIES_PER_PAGE/2 + idx/ENTRIES_PER_PAGEPAGE;
 			while (!*dir) {
 				dir++;
@@ -493,50 +554,43 @@
 					goto done1;
 			}
 			stage = idx + ENTRIES_PER_PAGEPAGE;
-			subdir = *dir;
+			middir = *dir;
 			*dir = NULL;
+			nr_pages_to_free++;
+			list_add(&middir->lru, &pages_to_free);
 			shmem_dir_unmap(dir);
-			if (empty) {
-				shmem_dir_free(empty);
-				shmem_free_block(inode);
-			}
-			empty = subdir;
-			cond_resched_lock(&info->lock);
-			dir = shmem_dir_map(subdir);
+			cond_resched();
+			dir = shmem_dir_map(middir);
+			diroff = 0;
 		}
-		subdir = *dir;
+		subdir = dir[diroff];
 		if (subdir && subdir->nr_swapped) {
-			ptr = shmem_swp_map(subdir);
 			size = limit - idx;
 			if (size > ENTRIES_PER_PAGE)
 				size = ENTRIES_PER_PAGE;
-			freed = shmem_free_swp(ptr+offset, ptr+size);
-			shmem_swp_unmap(ptr);
-			info->swapped -= freed;
+			freed = shmem_map_and_free_swp(subdir,
+						offset, size, &dir);
+			if (!dir)
+				dir = shmem_dir_map(middir);
+			nr_swaps_freed += freed;
+			if (offset)
+				spin_lock(&info->lock);
 			subdir->nr_swapped -= freed;
+			if (offset)
+				spin_unlock(&info->lock);
 			BUG_ON(subdir->nr_swapped > offset);
 		}
 		if (offset)
 			offset = 0;
 		else if (subdir) {
-			*dir = NULL;
-			shmem_dir_free(subdir);
-			shmem_free_block(inode);
+			dir[diroff] = NULL;
+			nr_pages_to_free++;
+			list_add(&subdir->lru, &pages_to_free);
 		}
 	}
 done1:
-	shmem_dir_unmap(dir-1);
-	if (empty) {
-		shmem_dir_free(empty);
-		shmem_free_block(inode);
-	}
-	if (info->next_index <= SHMEM_NR_DIRECT) {
-		shmem_dir_free(info->i_indirect);
-		info->i_indirect = NULL;
-		shmem_free_block(inode);
-	}
+	shmem_dir_unmap(dir);
 done2:
-	BUG_ON(info->swapped > info->next_index);
 	if (inode->i_mapping->nrpages && (info->flags & SHMEM_PAGEIN)) {
 		/*
 		 * Call truncate_inode_pages again: racing shmem_unuse_inode
@@ -545,13 +599,24 @@
 		 * Also, though shmem_getpage checks i_size before adding to
 		 * cache, no recheck after: so fix the narrow window there too.
 		 */
-		spin_unlock(&info->lock);
 		truncate_inode_pages(inode->i_mapping, inode->i_size);
-		spin_lock(&info->lock);
 	}
+
+	spin_lock(&info->lock);
 	info->flags &= ~SHMEM_TRUNCATE;
+	info->swapped -= nr_swaps_freed;
+	if (nr_pages_to_free)
+		shmem_free_blocks(inode, nr_pages_to_free);
 	shmem_recalc_inode(inode);
 	spin_unlock(&info->lock);
+
+	/*
+	 * Empty swap vector directory pages to be freed?
+	 */
+	if (!list_empty(&pages_to_free)) {
+		pages_to_free.prev->next = NULL;
+		shmem_free_pages(pages_to_free.next);
+	}
 }
 
 static int shmem_notify_change(struct dentry *dentry, struct iattr *attr)
@@ -659,9 +724,6 @@
 	}
 	if (!info->i_indirect)
 		goto lost2;
-	/* we might be racing with shmem_truncate */
-	if (limit <= SHMEM_NR_DIRECT)
-		goto lost2;
 
 	dir = shmem_dir_map(info->i_indirect);
 	stage = SHMEM_NR_DIRECT + ENTRIES_PER_PAGEPAGE/2;
@@ -1044,7 +1106,7 @@
 						    idx);
 			if (!filepage) {
 				shmem_unacct_blocks(info->flags, 1);
-				shmem_free_block(inode);
+				shmem_free_blocks(inode, 1);
 				error = -ENOMEM;
 				goto failed;
 			}
@@ -1062,7 +1124,7 @@
 				spin_unlock(&info->lock);
 				page_cache_release(filepage);
 				shmem_unacct_blocks(info->flags, 1);
-				shmem_free_block(inode);
+				shmem_free_blocks(inode, 1);
 				filepage = NULL;
 				if (error)
 					goto failed;
@@ -1230,16 +1292,17 @@
 		info = SHMEM_I(inode);
 		memset(info, 0, (char *)inode - (char *)info);
 		spin_lock_init(&info->lock);
- 		mpol_shared_policy_init(&info->policy);
 		INIT_LIST_HEAD(&info->swaplist);
 
 		switch (mode & S_IFMT) {
 		default:
+			inode->i_op = &shmem_special_inode_operations;
 			init_special_inode(inode, mode, dev);
 			break;
 		case S_IFREG:
 			inode->i_op = &shmem_inode_operations;
 			inode->i_fop = &shmem_file_operations;
+			mpol_shared_policy_init(&info->policy);
 			break;
 		case S_IFDIR:
 			inode->i_nlink++;
@@ -1249,8 +1312,17 @@
 			inode->i_fop = &simple_dir_operations;
 			break;
 		case S_IFLNK:
+			/*
+			 * Must not load anything in the rbtree,
+			 * mpol_free_shared_policy will not be called.
+			 */
+			mpol_shared_policy_init(&info->policy);
 			break;
 		}
+	} else if (sbinfo) {
+		spin_lock(&sbinfo->stat_lock);
+		sbinfo->free_inodes++;
+		spin_unlock(&sbinfo->stat_lock);
 	}
 	return inode;
 }
@@ -1756,6 +1828,12 @@
 static struct inode_operations shmem_symlink_inline_operations = {
 	.readlink	= generic_readlink,
 	.follow_link	= shmem_follow_link_inline,
+#ifdef CONFIG_TMPFS_XATTR
+	.setxattr       = generic_setxattr,
+	.getxattr       = generic_getxattr,
+	.listxattr      = generic_listxattr,
+	.removexattr    = generic_removexattr,
+#endif
 };
 
 static struct inode_operations shmem_symlink_inode_operations = {
@@ -1763,6 +1841,12 @@
 	.readlink	= generic_readlink,
 	.follow_link	= shmem_follow_link,
 	.put_link	= shmem_put_link,
+#ifdef CONFIG_TMPFS_XATTR
+	.setxattr       = generic_setxattr,
+	.getxattr       = generic_getxattr,
+	.listxattr      = generic_listxattr,
+	.removexattr    = generic_removexattr,
+#endif
 };
 
 static int shmem_parse_options(char *options, int *mode, uid_t *uid, gid_t *gid, unsigned long *blocks, unsigned long *inodes)
@@ -1862,6 +1946,12 @@
 	sb->s_fs_info = NULL;
 }
 
+#ifdef CONFIG_TMPFS_XATTR
+static struct xattr_handler *shmem_xattr_handlers[];
+#else
+#define shmem_xattr_handlers NULL
+#endif
+
 static int shmem_fill_super(struct super_block *sb,
 			    void *data, int silent)
 {
@@ -1904,6 +1994,9 @@
 		sbinfo->max_inodes = inodes;
 		sbinfo->free_inodes = inodes;
 	}
+	sb->s_xattr = shmem_xattr_handlers;
+#else
+	sb->s_flags |= MS_NOUSER;
 #endif
 
 	sb->s_maxbytes = SHMEM_MAX_BYTES;
@@ -1942,7 +2035,10 @@
 
 static void shmem_destroy_inode(struct inode *inode)
 {
-	mpol_free_shared_policy(&SHMEM_I(inode)->policy);
+	if ((inode->i_mode & S_IFMT) == S_IFREG) {
+		/* only struct inode is valid if it's an inline symlink */
+		mpol_free_shared_policy(&SHMEM_I(inode)->policy);
+	}
 	kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode));
 }
 
@@ -1995,6 +2091,12 @@
 static struct inode_operations shmem_inode_operations = {
 	.truncate	= shmem_truncate,
 	.setattr	= shmem_notify_change,
+#ifdef CONFIG_TMPFS_XATTR
+	.setxattr       = generic_setxattr,
+	.getxattr       = generic_getxattr,
+	.listxattr      = generic_listxattr,
+	.removexattr    = generic_removexattr,
+#endif
 };
 
 static struct inode_operations shmem_dir_inode_operations = {
@@ -2008,6 +2110,21 @@
 	.rmdir		= shmem_rmdir,
 	.mknod		= shmem_mknod,
 	.rename		= shmem_rename,
+#ifdef CONFIG_TMPFS_XATTR
+	.setxattr       = generic_setxattr,
+	.getxattr       = generic_getxattr,
+	.listxattr      = generic_listxattr,
+	.removexattr    = generic_removexattr,
+#endif
+#endif
+};
+
+static struct inode_operations shmem_special_inode_operations = {
+#ifdef CONFIG_TMPFS_XATTR
+	.setxattr	= generic_setxattr,
+	.getxattr	= generic_getxattr,
+	.listxattr	= generic_listxattr,
+	.removexattr	= generic_removexattr,
 #endif
 };
 
@@ -2032,6 +2149,49 @@
 #endif
 };
 
+
+#ifdef CONFIG_TMPFS_SECURITY
+
+static size_t shmem_xattr_security_list(struct inode *inode, char *list, size_t list_len,
+					const char *name, size_t name_len)
+{
+	return security_inode_listsecurity(inode, list, list_len);
+}
+
+static int shmem_xattr_security_get(struct inode *inode, const char *name, void *buffer, size_t size)
+{
+	if (strcmp(name, "") == 0)
+		return -EINVAL;
+	return security_inode_getsecurity(inode, name, buffer, size);
+}
+
+static int shmem_xattr_security_set(struct inode *inode, const char *name, const void *value, size_t size, int flags)
+{
+	if (strcmp(name, "") == 0)
+		return -EINVAL;
+	return security_inode_setsecurity(inode, name, value, size, flags);
+}
+
+struct xattr_handler shmem_xattr_security_handler = {
+	.prefix	= XATTR_SECURITY_PREFIX,
+	.list	= shmem_xattr_security_list,
+	.get	= shmem_xattr_security_get,
+	.set	= shmem_xattr_security_set,
+};
+
+#endif	/* CONFIG_TMPFS_SECURITY */
+
+#ifdef CONFIG_TMPFS_XATTR
+
+static struct xattr_handler *shmem_xattr_handlers[] = {
+#ifdef CONFIG_TMPFS_SECURITY
+	&shmem_xattr_security_handler,
+#endif
+	NULL
+};
+
+#endif	/* CONFIG_TMPFS_XATTR */
+
 static struct super_block *shmem_get_sb(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data)
 {
@@ -2164,5 +2324,3 @@
 	vma->vm_ops = &shmem_vm_ops;
 	return 0;
 }
-
-EXPORT_SYMBOL(shmem_file_setup);
diff -Nru a/mm/slab.c b/mm/slab.c
--- a/mm/slab.c	2004-12-24 13:37:44 -08:00
+++ b/mm/slab.c	2004-12-24 13:37:44 -08:00
@@ -327,6 +327,7 @@
 	unsigned long		reaped;
 	unsigned long 		errors;
 	unsigned long		max_freeable;
+	unsigned long		node_allocs;
 	atomic_t		allochit;
 	atomic_t		allocmiss;
 	atomic_t		freehit;
@@ -361,6 +362,7 @@
 					(x)->high_mark = (x)->num_active; \
 				} while (0)
 #define	STATS_INC_ERR(x)	((x)->errors++)
+#define	STATS_INC_NODEALLOCS(x)	((x)->node_allocs++)
 #define	STATS_SET_FREEABLE(x, i) \
 				do { if ((x)->max_freeable < i) \
 					(x)->max_freeable = i; \
@@ -378,6 +380,7 @@
 #define	STATS_INC_REAPED(x)	do { } while (0)
 #define	STATS_SET_HIGH(x)	do { } while (0)
 #define	STATS_INC_ERR(x)	do { } while (0)
+#define	STATS_INC_NODEALLOCS(x)	do { } while (0)
 #define	STATS_SET_FREEABLE(x, i) \
 				do { } while (0)
 
@@ -506,7 +509,7 @@
 
 static struct arraycache_init initarray_cache __initdata =
 	{ { 0, BOOT_CPUCACHE_ENTRIES, 1, 0} };
-static struct arraycache_init initarray_generic __initdata =
+static struct arraycache_init initarray_generic =
 	{ { 0, BOOT_CPUCACHE_ENTRIES, 1, 0} };
 
 /* internal cache of cache description objs */
@@ -1747,7 +1750,7 @@
  * Grow (by 1) the number of slabs within a cache.  This is called by
  * kmem_cache_alloc() when there are no active objs left in a cache.
  */
-static int cache_grow (kmem_cache_t * cachep, int flags)
+static int cache_grow (kmem_cache_t * cachep, int flags, int nodeid)
 {
 	struct slab	*slabp;
 	void		*objp;
@@ -1798,7 +1801,7 @@
 
 
 	/* Get mem for the objs. */
-	if (!(objp = kmem_getpages(cachep, flags, -1)))
+	if (!(objp = kmem_getpages(cachep, flags, nodeid)))
 		goto failed;
 
 	/* Get slab management. */
@@ -2032,7 +2035,7 @@
 
 	if (unlikely(!ac->avail)) {
 		int x;
-		x = cache_grow(cachep, flags);
+		x = cache_grow(cachep, flags, -1);
 		
 		// cache_grow can reenable interrupts, then ac could change.
 		ac = ac_data(cachep);
@@ -2313,6 +2316,7 @@
 	return 0;
 }
 
+#ifdef CONFIG_NUMA
 /**
  * kmem_cache_alloc_node - Allocate an object on the specified node
  * @cachep: The cache to allocate from.
@@ -2325,69 +2329,80 @@
  */
 void *kmem_cache_alloc_node(kmem_cache_t *cachep, int nodeid)
 {
-	size_t offset;
+	int loop;
 	void *objp;
 	struct slab *slabp;
 	kmem_bufctl_t next;
 
-	/* The main algorithms are not node aware, thus we have to cheat:
-	 * We bypass all caches and allocate a new slab.
-	 * The following code is a streamlined copy of cache_grow().
-	 */
+	for (loop = 0;;loop++) {
+		struct list_head *q;
 
-	/* Get colour for the slab, and update the next value. */
-	spin_lock_irq(&cachep->spinlock);
-	offset = cachep->colour_next;
-	cachep->colour_next++;
-	if (cachep->colour_next >= cachep->colour)
-		cachep->colour_next = 0;
-	offset *= cachep->colour_off;
-	spin_unlock_irq(&cachep->spinlock);
-
-	/* Get mem for the objs. */
-	if (!(objp = kmem_getpages(cachep, GFP_KERNEL, nodeid)))
-		goto failed;
+		objp = NULL;
+		check_irq_on();
+		spin_lock_irq(&cachep->spinlock);
+		/* walk through all partial and empty slab and find one
+		 * from the right node */
+		list_for_each(q,&cachep->lists.slabs_partial) {
+			slabp = list_entry(q, struct slab, list);
+
+			if (page_to_nid(virt_to_page(slabp->s_mem)) == nodeid ||
+					loop > 2)
+				goto got_slabp;
+		}
+		list_for_each(q, &cachep->lists.slabs_free) {
+			slabp = list_entry(q, struct slab, list);
+
+			if (page_to_nid(virt_to_page(slabp->s_mem)) == nodeid ||
+					loop > 2)
+				goto got_slabp;
+		}
+		spin_unlock_irq(&cachep->spinlock);
 
-	/* Get slab management. */
-	if (!(slabp = alloc_slabmgmt(cachep, objp, offset, GFP_KERNEL)))
-		goto opps1;
+		local_irq_disable();
+		if (!cache_grow(cachep, GFP_KERNEL, nodeid)) {
+			local_irq_enable();
+			return NULL;
+		}
+		local_irq_enable();
+	}
+got_slabp:
+	/* found one: allocate object */
+	check_slabp(cachep, slabp);
+	check_spinlock_acquired(cachep);
 
-	set_slab_attr(cachep, slabp, objp);
-	cache_init_objs(cachep, slabp, SLAB_CTOR_CONSTRUCTOR);
+	STATS_INC_ALLOCED(cachep);
+	STATS_INC_ACTIVE(cachep);
+	STATS_SET_HIGH(cachep);
+	STATS_INC_NODEALLOCS(cachep);
 
-	/* The first object is ours: */
 	objp = slabp->s_mem + slabp->free*cachep->objsize;
+
 	slabp->inuse++;
 	next = slab_bufctl(slabp)[slabp->free];
 #if DEBUG
 	slab_bufctl(slabp)[slabp->free] = BUFCTL_FREE;
 #endif
 	slabp->free = next;
-
-	/* add the remaining objects into the cache */
-	spin_lock_irq(&cachep->spinlock);
 	check_slabp(cachep, slabp);
-	STATS_INC_GROWN(cachep);
-	/* Make slab active. */
-	if (slabp->free == BUFCTL_END) {
-		list_add_tail(&slabp->list, &(list3_data(cachep)->slabs_full));
-	} else {
-		list_add_tail(&slabp->list,
-				&(list3_data(cachep)->slabs_partial));
-		list3_data(cachep)->free_objects += cachep->num-1;
-	}
+
+	/* move slabp to correct slabp list: */
+	list_del(&slabp->list);
+	if (slabp->free == BUFCTL_END)
+		list_add(&slabp->list, &cachep->lists.slabs_full);
+	else
+		list_add(&slabp->list, &cachep->lists.slabs_partial);
+
+	list3_data(cachep)->free_objects--;
 	spin_unlock_irq(&cachep->spinlock);
+
 	objp = cache_alloc_debugcheck_after(cachep, GFP_KERNEL, objp,
 					__builtin_return_address(0));
 	return objp;
-opps1:
-	kmem_freepages(cachep, objp);
-failed:
-	return NULL;
-
 }
 EXPORT_SYMBOL(kmem_cache_alloc_node);
 
+#endif
+
 /**
  * kmalloc - allocate memory
  * @size: how many bytes of memory are required.
@@ -2558,6 +2573,7 @@
 			continue;
 		kfree(p->ptrs[i]);
 	}
+	kfree(p);
 }
 
 EXPORT_SYMBOL(free_percpu);
@@ -2812,15 +2828,16 @@
 		 * without _too_ many complaints.
 		 */
 #if STATS
-		seq_puts(m, "slabinfo - version: 2.0 (statistics)\n");
+		seq_puts(m, "slabinfo - version: 2.1 (statistics)\n");
 #else
-		seq_puts(m, "slabinfo - version: 2.0\n");
+		seq_puts(m, "slabinfo - version: 2.1\n");
 #endif
 		seq_puts(m, "# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab>");
 		seq_puts(m, " : tunables <batchcount> <limit> <sharedfactor>");
 		seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
 #if STATS
-		seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> <error> <maxfreeable> <freelimit>");
+		seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped>"
+				" <error> <maxfreeable> <freelimit> <nodeallocs>");
 		seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
 #endif
 		seq_putc(m, '\n');
@@ -2911,10 +2928,11 @@
 		unsigned long errors = cachep->errors;
 		unsigned long max_freeable = cachep->max_freeable;
 		unsigned long free_limit = cachep->free_limit;
+		unsigned long node_allocs = cachep->node_allocs;
 
-		seq_printf(m, " : globalstat %7lu %6lu %5lu %4lu %4lu %4lu %4lu",
+		seq_printf(m, " : globalstat %7lu %6lu %5lu %4lu %4lu %4lu %4lu %4lu",
 				allocs, high, grown, reaped, errors, 
-				max_freeable, free_limit);
+				max_freeable, free_limit, node_allocs);
 	}
 	/* cpu stats */
 	{
diff -Nru a/mm/swap_state.c b/mm/swap_state.c
--- a/mm/swap_state.c	2004-12-24 13:36:48 -08:00
+++ b/mm/swap_state.c	2004-12-24 13:36:48 -08:00
@@ -34,7 +34,7 @@
 };
 
 struct address_space swapper_space = {
-	.page_tree	= RADIX_TREE_INIT(GFP_ATOMIC),
+	.page_tree	= RADIX_TREE_INIT(GFP_ATOMIC|__GFP_NOWARN),
 	.tree_lock	= SPIN_LOCK_UNLOCKED,
 	.a_ops		= &swap_aops,
 	.i_mmap_nonlinear = LIST_HEAD_INIT(swapper_space.i_mmap_nonlinear),
diff -Nru a/mm/swapfile.c b/mm/swapfile.c
--- a/mm/swapfile.c	2004-12-24 13:36:31 -08:00
+++ b/mm/swapfile.c	2004-12-24 13:36:31 -08:00
@@ -25,6 +25,7 @@
 #include <linux/rmap.h>
 #include <linux/security.h>
 #include <linux/backing-dev.h>
+#include <linux/syscalls.h>
 
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
@@ -647,11 +648,12 @@
 	 *
 	 * A simpler strategy would be to start at the last mm we
 	 * freed the previous entry from; but that would take less
-	 * advantage of mmlist ordering (now preserved by swap_out()),
-	 * which clusters forked address spaces together, most recent
-	 * child immediately after parent.  If we race with dup_mmap(),
-	 * we very much want to resolve parent before child, otherwise
-	 * we may miss some entries: using last mm would invert that.
+	 * advantage of mmlist ordering, which clusters forked mms
+	 * together, child after parent.  If we race with dup_mmap(), we
+	 * prefer to resolve parent before child, lest we miss entries
+	 * duplicated after we scanned child: using last mm would invert
+	 * that.  Though it's only a serious concern when an overflowed
+	 * swap count is reset from SWAP_MAP_MAX, preventing a rescan.
 	 */
 	start_mm = &init_mm;
 	atomic_inc(&init_mm.mm_users);
@@ -659,15 +661,7 @@
 	/*
 	 * Keep on scanning until all entries have gone.  Usually,
 	 * one pass through swap_map is enough, but not necessarily:
-	 * mmput() removes mm from mmlist before exit_mmap() and its
-	 * zap_page_range().  That's not too bad, those entries are
-	 * on their way out, and handled faster there than here.
-	 * do_munmap() behaves similarly, taking the range out of mm's
-	 * vma list before zap_page_range().  But unfortunately, when
-	 * unmapping a part of a vma, it takes the whole out first,
-	 * then reinserts what's left after (might even reschedule if
-	 * open() method called) - so swap entries may be invisible
-	 * to swapoff for a while, then reappear - but that is rare.
+	 * there are races when an instance of an entry might be missed.
 	 */
 	while ((i = find_next_to_unuse(si, i)) != 0) {
 		if (signal_pending(current)) {
@@ -719,7 +713,7 @@
 		wait_on_page_writeback(page);
 
 		/*
-		 * Remove all references to entry, without blocking.
+		 * Remove all references to entry.
 		 * Whenever we reach init_mm, there's no address space
 		 * to search, but use it as a reminder to search shmem.
 		 */
@@ -744,7 +738,10 @@
 			while (*swap_map > 1 && !retval &&
 					(p = p->next) != &start_mm->mmlist) {
 				mm = list_entry(p, struct mm_struct, mmlist);
-				atomic_inc(&mm->mm_users);
+				if (atomic_inc_return(&mm->mm_users) == 1) {
+					atomic_dec(&mm->mm_users);
+					continue;
+				}
 				spin_unlock(&mmlist_lock);
 				mmput(prev_mm);
 				prev_mm = mm;
@@ -858,6 +855,26 @@
 }
 
 /*
+ * After a successful try_to_unuse, if no swap is now in use, we know we
+ * can empty the mmlist.  swap_list_lock must be held on entry and exit.
+ * Note that mmlist_lock nests inside swap_list_lock, and an mm must be
+ * added to the mmlist just after page_duplicate - before would be racy.
+ */
+static void drain_mmlist(void)
+{
+	struct list_head *p, *next;
+	unsigned int i;
+
+	for (i = 0; i < nr_swapfiles; i++)
+		if (swap_info[i].inuse_pages)
+			return;
+	spin_lock(&mmlist_lock);
+	list_for_each_safe(p, next, &init_mm.mmlist)
+		list_del_init(p);
+	spin_unlock(&mmlist_lock);
+}
+
+/*
  * Use this swapdev's extent info to locate the (PAGE_SIZE) block which
  * corresponds to page offset `offset'.
  */
@@ -1171,6 +1188,7 @@
 	}
 	down(&swapon_sem);
 	swap_list_lock();
+	drain_mmlist();
 	swap_device_lock(p);
 	swap_file = p->swap_file;
 	p->swap_file = NULL;
@@ -1356,7 +1374,7 @@
 	p->highest_bit = 0;
 	p->cluster_nr = 0;
 	p->inuse_pages = 0;
-	p->sdev_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&p->sdev_lock);
 	p->next = -1;
 	if (swap_flags & SWAP_FLAG_PREFER) {
 		p->prio =
diff -Nru a/mm/thrash.c b/mm/thrash.c
--- a/mm/thrash.c	2004-12-24 13:36:31 -08:00
+++ b/mm/thrash.c	2004-12-24 13:36:31 -08:00
@@ -19,7 +19,11 @@
 struct mm_struct * swap_token_mm = &init_mm;
 
 #define SWAP_TOKEN_CHECK_INTERVAL (HZ * 2)
-#define SWAP_TOKEN_TIMEOUT (HZ * 300)
+#define SWAP_TOKEN_TIMEOUT	0
+/*
+ * Currently disabled; Needs further code to work at HZ * 300.
+ */
+unsigned long swap_token_default_timeout = SWAP_TOKEN_TIMEOUT;
 
 /*
  * Take the token away if the process had no page faults
@@ -75,10 +79,10 @@
 		if ((reason = should_release_swap_token(mm))) {
 			unsigned long eligible = jiffies;
 			if (reason == SWAP_TOKEN_TIMED_OUT) {
-				eligible += SWAP_TOKEN_TIMEOUT;
+				eligible += swap_token_default_timeout;
 			}
 			mm->swap_token_time = eligible;
-			swap_token_timeout = jiffies + SWAP_TOKEN_TIMEOUT;
+			swap_token_timeout = jiffies + swap_token_default_timeout;
 			swap_token_mm = current->mm;
 		}
 		spin_unlock(&swap_token_lock);
diff -Nru a/mm/tiny-shmem.c b/mm/tiny-shmem.c
--- a/mm/tiny-shmem.c	2004-12-24 13:37:18 -08:00
+++ b/mm/tiny-shmem.c	2004-12-24 13:37:18 -08:00
@@ -120,5 +120,3 @@
 {
 	return 0;
 }
-
-EXPORT_SYMBOL(shmem_file_setup);
diff -Nru a/mm/truncate.c b/mm/truncate.c
--- a/mm/truncate.c	2004-12-24 13:37:29 -08:00
+++ b/mm/truncate.c	2004-12-24 13:37:29 -08:00
@@ -79,6 +79,12 @@
 		spin_unlock_irq(&mapping->tree_lock);
 		return 0;
 	}
+
+	BUG_ON(PagePrivate(page));
+	if (page_count(page) != 2) {
+		spin_unlock_irq(&mapping->tree_lock);
+		return 0;
+	}
 	__remove_from_page_cache(page);
 	spin_unlock_irq(&mapping->tree_lock);
 	ClearPageUptodate(page);
@@ -269,7 +275,11 @@
 					clear_page_dirty(page);
 					ClearPageUptodate(page);
 				} else {
-					invalidate_complete_page(mapping, page);
+					if (!invalidate_complete_page(mapping,
+								      page)) {
+						clear_page_dirty(page);
+						ClearPageUptodate(page);
+					}
 				}
 			}
 			unlock_page(page);
diff -Nru a/mm/vmscan.c b/mm/vmscan.c
--- a/mm/vmscan.c	2004-12-24 13:36:18 -08:00
+++ b/mm/vmscan.c	2004-12-24 13:36:18 -08:00
@@ -377,7 +377,7 @@
 		if (page_mapped(page) || PageSwapCache(page))
 			sc->nr_scanned++;
 
-		referenced = page_referenced(page, 1);
+		referenced = page_referenced(page, 1, sc->priority <= 0);
 		/* In active use or really unfreeable?  Activate it. */
 		if (referenced && page_mapping_inuse(page))
 			goto activate_locked;
@@ -574,7 +574,6 @@
 			nr_taken++;
 		}
 		zone->nr_inactive -= nr_taken;
-		zone->pages_scanned += nr_taken;
 		spin_unlock_irq(&zone->lru_lock);
 
 		if (nr_taken == 0)
@@ -675,6 +674,7 @@
 		}
 		pgscanned++;
 	}
+	zone->pages_scanned += pgscanned;
 	zone->nr_active -= pgmoved;
 	spin_unlock_irq(&zone->lru_lock);
 
@@ -715,7 +715,7 @@
 		if (page_mapped(page)) {
 			if (!reclaim_mapped ||
 			    (total_swap_pages == 0 && PageAnon(page)) ||
-			    page_referenced(page, 0)) {
+			    page_referenced(page, 0, sc->priority <= 0)) {
 				list_add(&page->lru, &l_active);
 				continue;
 			}
diff -Nru a/net/802/fc.c b/net/802/fc.c
--- a/net/802/fc.c	2004-12-24 13:37:29 -08:00
+++ b/net/802/fc.c	2004-12-24 13:37:29 -08:00
@@ -129,3 +129,35 @@
 
 	return ntohs(ETH_P_802_2);
 }
+
+static void fc_setup(struct net_device *dev)
+{
+	dev->hard_header	= fc_header;
+	dev->rebuild_header	= fc_rebuild_header;
+                
+	dev->type		= ARPHRD_IEEE802;
+	dev->hard_header_len	= FC_HLEN;
+	dev->mtu		= 2024;
+	dev->addr_len		= FC_ALEN;
+	dev->tx_queue_len	= 100; /* Long queues on fc */
+	dev->flags		= IFF_BROADCAST;
+
+	memset(dev->broadcast, 0xFF, FC_ALEN);
+}
+
+/**
+ * alloc_fcdev - Register fibre channel device
+ * @sizeof_priv: Size of additional driver-private structure to be allocated
+ *	for this fibre channel device
+ *
+ * Fill in the fields of the device structure with fibre channel-generic values.
+ *
+ * Constructs a new net device, complete with a private data area of
+ * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
+ * this private data area.
+ */
+struct net_device *alloc_fcdev(int sizeof_priv)
+{
+	return alloc_netdev(sizeof_priv, "fc%d", fc_setup);
+}
+EXPORT_SYMBOL(alloc_fcdev);
diff -Nru a/net/802/fddi.c b/net/802/fddi.c
--- a/net/802/fddi.c	2004-12-24 13:37:18 -08:00
+++ b/net/802/fddi.c	2004-12-24 13:37:18 -08:00
@@ -166,3 +166,44 @@
 }
 
 EXPORT_SYMBOL(fddi_type_trans);
+
+static int fddi_change_mtu(struct net_device *dev, int new_mtu)
+{
+	if ((new_mtu < FDDI_K_SNAP_HLEN) || (new_mtu > FDDI_K_SNAP_DLEN))
+		return(-EINVAL);
+	dev->mtu = new_mtu;
+	return(0);
+}
+
+static void fddi_setup(struct net_device *dev)
+{
+	dev->change_mtu		= fddi_change_mtu;
+	dev->hard_header	= fddi_header;
+	dev->rebuild_header	= fddi_rebuild_header;
+
+	dev->type		= ARPHRD_FDDI;
+	dev->hard_header_len	= FDDI_K_SNAP_HLEN+3;	/* Assume 802.2 SNAP hdr len + 3 pad bytes */
+	dev->mtu		= FDDI_K_SNAP_DLEN;	/* Assume max payload of 802.2 SNAP frame */
+	dev->addr_len		= FDDI_K_ALEN;
+	dev->tx_queue_len	= 100;			/* Long queues on FDDI */
+	dev->flags		= IFF_BROADCAST | IFF_MULTICAST;
+	
+	memset(dev->broadcast, 0xFF, FDDI_K_ALEN);
+}
+
+/**
+ * alloc_fddidev - Register FDDI device
+ * @sizeof_priv: Size of additional driver-private structure to be allocated
+ *	for this FDDI device
+ *
+ * Fill in the fields of the device structure with FDDI-generic values.
+ *
+ * Constructs a new net device, complete with a private data area of
+ * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
+ * this private data area.
+ */
+struct net_device *alloc_fddidev(int sizeof_priv)
+{
+	return alloc_netdev(sizeof_priv, "fddi%d", fddi_setup);
+}
+EXPORT_SYMBOL(alloc_fddidev);
diff -Nru a/net/802/hippi.c b/net/802/hippi.c
--- a/net/802/hippi.c	2004-12-24 13:36:49 -08:00
+++ b/net/802/hippi.c	2004-12-24 13:36:49 -08:00
@@ -154,3 +154,92 @@
 }
 
 EXPORT_SYMBOL(hippi_type_trans);
+
+static int hippi_change_mtu(struct net_device *dev, int new_mtu)
+{
+	/*
+	 * HIPPI's got these nice large MTUs.
+	 */
+	if ((new_mtu < 68) || (new_mtu > 65280))
+		return -EINVAL;
+	dev->mtu = new_mtu;
+	return(0);
+}
+
+/*
+ * For HIPPI we will actually use the lower 4 bytes of the hardware
+ * address as the I-FIELD rather than the actual hardware address.
+ */
+static int hippi_mac_addr(struct net_device *dev, void *p)
+{
+	struct sockaddr *addr = p;
+	if (netif_running(dev))
+		return -EBUSY;
+	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+	return 0;
+}
+
+static int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p)
+{
+	/* Never send broadcast/multicast ARP messages */
+	p->mcast_probes = 0;
+ 
+	/* In IPv6 unicast probes are valid even on NBMA,
+	* because they are encapsulated in normal IPv6 protocol.
+	* Should be a generic flag. 
+	*/
+	if (p->tbl->family != AF_INET6)
+		p->ucast_probes = 0;
+	return 0;
+}
+
+static void hippi_setup(struct net_device *dev)
+{
+	dev->set_multicast_list		= NULL;
+	dev->change_mtu			= hippi_change_mtu;
+	dev->hard_header		= hippi_header;
+	dev->rebuild_header 		= hippi_rebuild_header;
+	dev->set_mac_address 		= hippi_mac_addr;
+	dev->hard_header_parse		= NULL;
+	dev->hard_header_cache		= NULL;
+	dev->header_cache_update	= NULL;
+	dev->neigh_setup 		= hippi_neigh_setup_dev; 
+
+	/*
+	 * We don't support HIPPI `ARP' for the time being, and probably
+	 * never will unless someone else implements it. However we
+	 * still need a fake ARPHRD to make ifconfig and friends play ball.
+	 */
+	dev->type		= ARPHRD_HIPPI;
+	dev->hard_header_len 	= HIPPI_HLEN;
+	dev->mtu		= 65280;
+	dev->addr_len		= HIPPI_ALEN;
+	dev->tx_queue_len	= 25 /* 5 */;
+	memset(dev->broadcast, 0xFF, HIPPI_ALEN);
+
+
+	/*
+	 * HIPPI doesn't support broadcast+multicast and we only use
+	 * static ARP tables. ARP is disabled by hippi_neigh_setup_dev. 
+	 */
+	dev->flags = 0; 
+}
+
+/**
+ * alloc_hippi_dev - Register HIPPI device
+ * @sizeof_priv: Size of additional driver-private structure to be allocated
+ *	for this HIPPI device
+ *
+ * Fill in the fields of the device structure with HIPPI-generic values.
+ *
+ * Constructs a new net device, complete with a private data area of
+ * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
+ * this private data area.
+ */
+
+struct net_device *alloc_hippi_dev(int sizeof_priv)
+{
+	return alloc_netdev(sizeof_priv, "hip%d", hippi_setup);
+}
+
+EXPORT_SYMBOL(alloc_hippi_dev);
diff -Nru a/net/802/tr.c b/net/802/tr.c
--- a/net/802/tr.c	2004-12-24 13:36:18 -08:00
+++ b/net/802/tr.c	2004-12-24 13:36:18 -08:00
@@ -583,6 +583,43 @@
 
 #endif
 
+static void tr_setup(struct net_device *dev)
+{
+	/*
+	 *	Configure and register
+	 */
+	
+	dev->hard_header	= tr_header;
+	dev->rebuild_header	= tr_rebuild_header;
+
+	dev->type		= ARPHRD_IEEE802_TR;
+	dev->hard_header_len	= TR_HLEN;
+	dev->mtu		= 2000;
+	dev->addr_len		= TR_ALEN;
+	dev->tx_queue_len	= 100;	/* Long queues on tr */
+	
+	memset(dev->broadcast,0xFF, TR_ALEN);
+
+	/* New-style flags. */
+	dev->flags		= IFF_BROADCAST | IFF_MULTICAST ;
+}
+
+/**
+ * alloc_trdev - Register token ring device
+ * @sizeof_priv: Size of additional driver-private structure to be allocated
+ *	for this token ring device
+ *
+ * Fill in the fields of the device structure with token ring-generic values.
+ *
+ * Constructs a new net device, complete with a private data area of
+ * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
+ * this private data area.
+ */
+struct net_device *alloc_trdev(int sizeof_priv)
+{
+	return alloc_netdev(sizeof_priv, "tr%d", tr_setup);
+}
+
 /*
  *	Called during bootup.  We don't actually have to initialise
  *	too much for this.
@@ -604,3 +641,4 @@
 
 EXPORT_SYMBOL(tr_source_route);
 EXPORT_SYMBOL(tr_type_trans);
+EXPORT_SYMBOL(alloc_trdev);
diff -Nru a/net/8021q/vlan.c b/net/8021q/vlan.c
--- a/net/8021q/vlan.c	2004-12-24 13:37:18 -08:00
+++ b/net/8021q/vlan.c	2004-12-24 13:37:18 -08:00
@@ -35,6 +35,8 @@
 #include "vlan.h"
 #include "vlanproc.h"
 
+#define DRV_VERSION "1.8"
+
 /* Global VLAN variables */
 
 /* Our listing of VLAN group(s) */
@@ -42,8 +44,7 @@
 #define vlan_grp_hashfn(IDX)	((((IDX) >> VLAN_GRP_HASH_SHIFT) ^ (IDX)) & VLAN_GRP_HASH_MASK)
 
 static char vlan_fullname[] = "802.1Q VLAN Support";
-static unsigned int vlan_version = 1;
-static unsigned int vlan_release = 8;
+static char vlan_version[] = DRV_VERSION;
 static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
 static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
 
@@ -68,7 +69,7 @@
 	.func = vlan_skb_recv, /* VLAN receive method */
 };
 
-/* Bits of netdev state that are propogated from real device to virtual */
+/* Bits of netdev state that are propagated from real device to virtual */
 #define VLAN_LINK_STATE_MASK \
 	((1<<__LINK_STATE_PRESENT)|(1<<__LINK_STATE_NOCARRIER))
 
@@ -84,8 +85,8 @@
 {
 	int err;
 
-	printk(VLAN_INF "%s v%u.%u %s\n",
-	       vlan_fullname, vlan_version, vlan_release, vlan_copyright);
+	printk(VLAN_INF "%s v%s %s\n",
+	       vlan_fullname, vlan_version, vlan_copyright);
 	printk(VLAN_INF "All bugs added by %s\n",
 	       vlan_buggyright);
 
@@ -95,13 +96,18 @@
 		printk(KERN_ERR 
 		       "%s %s: can't create entry in proc filesystem!\n",
 		       __FUNCTION__, VLAN_NAME);
-		return 1;
+		return err;
 	}
 
 	dev_add_pack(&vlan_packet_type);
 
 	/* Register us to receive netdevice events */
-	register_netdevice_notifier(&vlan_notifier_block);
+	err = register_netdevice_notifier(&vlan_notifier_block);
+	if (err < 0) {
+		dev_remove_pack(&vlan_packet_type);
+		vlan_proc_cleanup();
+		return err;
+	}
 
 	vlan_ioctl_set(vlan_ioctl_handler);
 
@@ -568,7 +574,7 @@
 
 	switch (event) {
 	case NETDEV_CHANGE:
-		/* Propogate real device state to vlan devices */
+		/* Propagate real device state to vlan devices */
 		flgs = dev->state & VLAN_LINK_STATE_MASK;
 		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
 			vlandev = grp->vlan_devices[i];
@@ -646,15 +652,9 @@
 static int vlan_ioctl_handler(void __user *arg)
 {
 	int err = 0;
+	unsigned short vid = 0;
 	struct vlan_ioctl_args args;
 
-	/* everything here needs root permissions, except aguably the
-	 * hack ioctls for sending packets.  However, I know _I_ don't
-	 * want users running that on my network! --BLG
-	 */
-	if (!capable(CAP_NET_ADMIN))
-		return -EPERM;
-
 	if (copy_from_user(&args, arg, sizeof(struct vlan_ioctl_args)))
 		return -EFAULT;
 
@@ -668,24 +668,32 @@
 
 	switch (args.cmd) {
 	case SET_VLAN_INGRESS_PRIORITY_CMD:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
 		err = vlan_dev_set_ingress_priority(args.device1,
 						    args.u.skb_priority,
 						    args.vlan_qos);
 		break;
 
 	case SET_VLAN_EGRESS_PRIORITY_CMD:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
 		err = vlan_dev_set_egress_priority(args.device1,
 						   args.u.skb_priority,
 						   args.vlan_qos);
 		break;
 
 	case SET_VLAN_FLAG_CMD:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
 		err = vlan_dev_set_vlan_flag(args.device1,
 					     args.u.flag,
 					     args.vlan_qos);
 		break;
 
 	case SET_VLAN_NAME_TYPE_CMD:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
 		if ((args.u.name_type >= 0) &&
 		    (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
 			vlan_name_type = args.u.name_type;
@@ -695,17 +703,9 @@
 		}
 		break;
 
-		/* TODO:  Figure out how to pass info back...
-		   case GET_VLAN_INGRESS_PRIORITY_IOCTL:
-		   err = vlan_dev_get_ingress_priority(args);
-		   break;
-
-		   case GET_VLAN_EGRESS_PRIORITY_IOCTL:
-		   err = vlan_dev_get_egress_priority(args);
-		   break;
-		*/
-
 	case ADD_VLAN_CMD:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
 		/* we have been given the name of the Ethernet Device we want to
 		 * talk to:  args.dev1	 We also have the
 		 * VLAN ID:  args.u.VID
@@ -718,12 +718,51 @@
 		break;
 
 	case DEL_VLAN_CMD:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
 		/* Here, the args.dev1 is the actual VLAN we want
 		 * to get rid of.
 		 */
 		err = unregister_vlan_device(args.device1);
 		break;
 
+	case GET_VLAN_INGRESS_PRIORITY_CMD:
+		/* TODO:  Implement
+		   err = vlan_dev_get_ingress_priority(args);
+		   if (copy_to_user((void*)arg, &args,
+		        sizeof(struct vlan_ioctl_args))) {
+		        err = -EFAULT;
+		   }
+		*/
+		err = -EINVAL;
+		break;
+	case GET_VLAN_EGRESS_PRIORITY_CMD:
+		/* TODO:  Implement
+		   err = vlan_dev_get_egress_priority(args.device1, &(args.args);
+		   if (copy_to_user((void*)arg, &args,
+		        sizeof(struct vlan_ioctl_args))) {
+		        err = -EFAULT;
+		   }
+		*/
+		err = -EINVAL;
+		break;
+	case GET_VLAN_REALDEV_NAME_CMD:
+		err = vlan_dev_get_realdev_name(args.device1, args.u.device2);
+		if (copy_to_user(arg, &args,
+				 sizeof(struct vlan_ioctl_args))) {
+			err = -EFAULT;
+		}
+		break;
+
+	case GET_VLAN_VID_CMD:
+		err = vlan_dev_get_vid(args.device1, &vid);
+		args.u.VID = vid;
+		if (copy_to_user(arg, &args,
+				 sizeof(struct vlan_ioctl_args))) {
+                      err = -EFAULT;
+		}
+		break;
+
 	default:
 		/* pass on to underlying device instead?? */
 		printk(VLAN_DBG "%s: Unknown VLAN CMD: %x \n",
@@ -735,3 +774,4 @@
 }
 
 MODULE_LICENSE("GPL");
+MODULE_VERSION(DRV_VERSION);
diff -Nru a/net/8021q/vlan.h b/net/8021q/vlan.h
--- a/net/8021q/vlan.h	2004-12-24 13:37:01 -08:00
+++ b/net/8021q/vlan.h	2004-12-24 13:37:01 -08:00
@@ -66,6 +66,8 @@
 int vlan_dev_set_ingress_priority(char* dev_name, __u32 skb_prio, short vlan_prio);
 int vlan_dev_set_egress_priority(char* dev_name, __u32 skb_prio, short vlan_prio);
 int vlan_dev_set_vlan_flag(char* dev_name, __u32 flag, short flag_val);
+int vlan_dev_get_realdev_name(const char* dev_name, char* result);
+int vlan_dev_get_vid(const char* dev_name, unsigned short* result);
 void vlan_dev_set_multicast_list(struct net_device *vlan_dev);
 
 #endif /* !(__BEN_VLAN_802_1Q_INC__) */
diff -Nru a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
--- a/net/8021q/vlan_dev.c	2004-12-24 13:37:19 -08:00
+++ b/net/8021q/vlan_dev.c	2004-12-24 13:37:19 -08:00
@@ -1,4 +1,4 @@
-/*
+/* -*- linux-c -*-
  * INET		802.1Q VLAN
  *		Ethernet-type device handling.
  *
@@ -527,7 +527,7 @@
 
 	dev->mtu = new_mtu;
 
-	return new_mtu;
+	return 0;
 }
 
 int vlan_dev_set_ingress_priority(char *dev_name, __u32 skb_prio, short vlan_prio)
@@ -621,6 +621,44 @@
 
 	return -EINVAL;
 }
+
+
+int vlan_dev_get_realdev_name(const char *dev_name, char* result)
+{
+	struct net_device *dev = dev_get_by_name(dev_name);
+	int rv = 0;
+	if (dev) {
+		if (dev->priv_flags & IFF_802_1Q_VLAN) {
+			strncpy(result, VLAN_DEV_INFO(dev)->real_dev->name, 23);
+			rv = 0;
+		} else {
+			rv = -EINVAL;
+		}
+		dev_put(dev);
+	} else {
+		rv = -ENODEV;
+	}
+	return rv;
+}
+
+int vlan_dev_get_vid(const char *dev_name, unsigned short* result)
+{
+	struct net_device *dev = dev_get_by_name(dev_name);
+	int rv = 0;
+	if (dev) {
+		if (dev->priv_flags & IFF_802_1Q_VLAN) {
+			*result = VLAN_DEV_INFO(dev)->vlan_id;
+			rv = 0;
+		} else {
+			rv = -EINVAL;
+		}
+		dev_put(dev);
+	} else {
+		rv = -ENODEV;
+	}
+	return rv;
+}
+
 
 int vlan_dev_set_mac_address(struct net_device *dev, void *addr_struct_p)
 {
diff -Nru a/net/Kconfig b/net/Kconfig
--- a/net/Kconfig	2004-12-24 13:36:17 -08:00
+++ b/net/Kconfig	2004-12-24 13:36:17 -08:00
@@ -219,6 +219,10 @@
 
 endif
 
+config XFRM
+       bool
+       depends on NET
+
 source "net/xfrm/Kconfig"
 
 source "net/sctp/Kconfig"
@@ -563,24 +567,6 @@
 	  module will be called wanrouter.
 
 	  If unsure, say N.
-
-config NET_HW_FLOWCONTROL
-	bool "Forwarding between high speed interfaces"
-	depends on EXPERIMENTAL
-	---help---
-	  This option enables NIC (Network Interface Card) hardware throttling
-	  during periods of extreme congestion. At the moment only a couple
-	  of device drivers support it (really only one -- tulip, a modified
-	  8390 driver can be found at
-	  <ftp://ftp.tux.org/pub/net/ip-routing/fastroute/fastroute-8390.tar.gz>).
-
-	  Really, this option is applicable to any machine attached to a fast
-	  enough network, and even a 10 Mb NIC is able to kill a not very slow
-	  box, such as a 120MHz Pentium.
-
-	  However, do not say Y here if you did not experience any serious
-	  problems.
-
 
 menu "QoS and/or fair queueing"
 
diff -Nru a/net/Makefile b/net/Makefile
--- a/net/Makefile	2004-12-24 13:36:48 -08:00
+++ b/net/Makefile	2004-12-24 13:36:48 -08:00
@@ -15,7 +15,8 @@
 # LLC has to be linked before the files in net/802/
 obj-$(CONFIG_LLC)		+= llc/
 obj-$(CONFIG_NET)		+= ethernet/ 802/ sched/ netlink/
-obj-$(CONFIG_INET)		+= ipv4/ xfrm/
+obj-$(CONFIG_INET)		+= ipv4/
+obj-$(CONFIG_XFRM)		+= xfrm/
 obj-$(CONFIG_UNIX)		+= unix/
 ifneq ($(CONFIG_IPV6),)
 obj-y				+= ipv6/
diff -Nru a/net/appletalk/Makefile b/net/appletalk/Makefile
--- a/net/appletalk/Makefile	2004-12-24 13:37:01 -08:00
+++ b/net/appletalk/Makefile	2004-12-24 13:37:01 -08:00
@@ -4,6 +4,6 @@
 
 obj-$(CONFIG_ATALK) += appletalk.o
 
-appletalk-y			:= aarp.o ddp.o
+appletalk-y			:= aarp.o ddp.o dev.o
 appletalk-$(CONFIG_PROC_FS)	+= atalk_proc.o
 appletalk-$(CONFIG_SYSCTL)	+= sysctl_net_atalk.o
diff -Nru a/net/appletalk/ddp.c b/net/appletalk/ddp.c
--- a/net/appletalk/ddp.c	2004-12-24 13:37:31 -08:00
+++ b/net/appletalk/ddp.c	2004-12-24 13:37:31 -08:00
@@ -78,13 +78,6 @@
 	sk_add_node(sk, &atalk_sockets);
 }
 
-static inline void atalk_insert_socket(struct sock *sk)
-{
-	write_lock_bh(&atalk_sockets_lock);
-	__atalk_insert_socket(sk);
-	write_unlock_bh(&atalk_sockets_lock);
-}
-
 static inline void atalk_remove_socket(struct sock *sk)
 {
 	write_lock_bh(&atalk_sockets_lock);
@@ -570,7 +563,7 @@
 
 		retval = -ENOBUFS;
 		if (!rt)
-			goto out;
+			goto out_unlock;
 		memset(rt, 0, sizeof(*rt));
 
 		rt->next = atalk_routes;
diff -Nru a/net/appletalk/dev.c b/net/appletalk/dev.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/net/appletalk/dev.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,43 @@
+/*
+ * Moved here from drivers/net/net_init.c, which is:
+ *	Written 1993,1994,1995 by Donald Becker.
+ */
+
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/if_arp.h>
+#include <linux/if_ltalk.h>
+
+static int ltalk_change_mtu(struct net_device *dev, int mtu)
+{
+	return -EINVAL;
+}
+
+static int ltalk_mac_addr(struct net_device *dev, void *addr)
+{	
+	return -EINVAL;
+}
+
+void ltalk_setup(struct net_device *dev)
+{
+	/* Fill in the fields of the device structure with localtalk-generic values. */
+	
+	dev->change_mtu		= ltalk_change_mtu;
+	dev->hard_header	= NULL;
+	dev->rebuild_header 	= NULL;
+	dev->set_mac_address 	= ltalk_mac_addr;
+	dev->hard_header_cache	= NULL;
+	dev->header_cache_update= NULL;
+
+	dev->type		= ARPHRD_LOCALTLK;
+	dev->hard_header_len 	= LTALK_HLEN;
+	dev->mtu		= LTALK_MTU;
+	dev->addr_len		= LTALK_ALEN;
+	dev->tx_queue_len	= 10;	
+	
+	dev->broadcast[0]	= 0xFF;
+
+	dev->flags		= IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP;
+}
+EXPORT_SYMBOL(ltalk_setup);
diff -Nru a/net/atm/common.c b/net/atm/common.c
--- a/net/atm/common.c	2004-12-24 13:37:43 -08:00
+++ b/net/atm/common.c	2004-12-24 13:37:43 -08:00
@@ -57,7 +57,7 @@
 	write_unlock_irq(&vcc_sklist_lock);
 }
 
-void vcc_remove_socket(struct sock *sk)
+static void vcc_remove_socket(struct sock *sk)
 {
 	write_lock_irq(&vcc_sklist_lock);
 	sk_del_node_init(sk);
@@ -86,7 +86,6 @@
 EXPORT_SYMBOL(vcc_hash);
 EXPORT_SYMBOL(vcc_sklist_lock);
 EXPORT_SYMBOL(vcc_insert_socket);
-EXPORT_SYMBOL(vcc_remove_socket);
 
 static void vcc_sock_destruct(struct sock *sk)
 {
@@ -178,6 +177,7 @@
 	struct atm_vcc *vcc = atm_sk(sk);
 	struct sk_buff *skb;
 
+	set_bit(ATM_VF_CLOSE, &vcc->flags);
 	clear_bit(ATM_VF_READY, &vcc->flags);
 	if (vcc->dev) {
 		if (vcc->dev->ops->close)
@@ -216,6 +216,7 @@
 void vcc_release_async(struct atm_vcc *vcc, int reply)
 {
 	set_bit(ATM_VF_CLOSE, &vcc->flags);
+	vcc->sk->sk_shutdown |= RCV_SHUTDOWN;
 	vcc->sk->sk_err = -reply;
 	clear_bit(ATM_VF_WAITING, &vcc->flags);
 	vcc->sk->sk_state_change(vcc->sk);
diff -Nru a/net/atm/mpc.c b/net/atm/mpc.c
--- a/net/atm/mpc.c	2004-12-24 13:37:18 -08:00
+++ b/net/atm/mpc.c	2004-12-24 13:37:18 -08:00
@@ -267,8 +267,8 @@
 	if (mpc == NULL)
 		return NULL;
 	memset(mpc, 0, sizeof(struct mpoa_client));
-	mpc->ingress_lock = RW_LOCK_UNLOCKED;
-	mpc->egress_lock  = RW_LOCK_UNLOCKED;
+	rwlock_init(&mpc->ingress_lock);
+	rwlock_init(&mpc->egress_lock);
 	mpc->next = mpcs;
 	atm_mpoa_init_cache(mpc);
 
@@ -755,13 +755,18 @@
 {
 	struct mpoa_client *mpc;
 	struct lec_priv *priv;
+	int err;
 	
 	if (mpcs == NULL) {
 		init_timer(&mpc_timer);
 		mpc_timer_refresh();
 
 		/* This lets us now how our LECs are doing */
-		register_netdevice_notifier(&mpoa_notifier);
+		err = register_netdevice_notifier(&mpoa_notifier);
+		if (err < 0) {
+			del_timer(&mpc_timer);
+			return err;
+		}
 	}
 	
 	mpc = find_mpc_by_itfnum(arg);
diff -Nru a/net/atm/signaling.c b/net/atm/signaling.c
--- a/net/atm/signaling.c	2004-12-24 13:37:18 -08:00
+++ b/net/atm/signaling.c	2004-12-24 13:37:18 -08:00
@@ -136,6 +136,7 @@
 			if (vcc->sk->sk_ack_backlog ==
 			    vcc->sk->sk_max_ack_backlog) {
 				sigd_enq(NULL,as_reject,vcc,NULL,NULL);
+				dev_kfree_skb(skb);
 				goto as_indicate_complete;
 			}
 			vcc->sk->sk_ack_backlog++;
@@ -147,19 +148,23 @@
 			return 0;
 		case as_close:
 			set_bit(ATM_VF_RELEASED,&vcc->flags);
-			clear_bit(ATM_VF_READY,&vcc->flags);
-			vcc->sk->sk_err = -msg->reply;
-			clear_bit(ATM_VF_WAITING, &vcc->flags);
-			break;
+			vcc_release_async(vcc, msg->reply);
+			goto out;
 		case as_modify:
 			modify_qos(vcc,msg);
 			break;
+		case as_addparty:
+		case as_dropparty:
+			vcc->sk->sk_err_soft = msg->reply;	/* < 0 failure, otherwise ep_ref */
+			clear_bit(ATM_VF_WAITING, &vcc->flags);
+			break;
 		default:
 			printk(KERN_ALERT "sigd_send: bad message type %d\n",
 			    (int) msg->type);
 			return -EINVAL;
 	}
 	vcc->sk->sk_state_change(vcc->sk);
+out:
 	dev_kfree_skb(skb);
 	return 0;
 }
@@ -171,6 +176,7 @@
 {
 	struct sk_buff *skb;
 	struct atmsvc_msg *msg;
+	static unsigned session = 0;
 
 	DPRINTK("sigd_enq %d (0x%p)\n",(int) type,vcc);
 	while (!(skb = alloc_skb(sizeof(struct atmsvc_msg),GFP_KERNEL)))
@@ -186,6 +192,11 @@
 	if (svc) msg->svc = *svc;
 	if (vcc) msg->local = vcc->local;
 	if (pvc) msg->pvc = *pvc;
+	if (vcc) {
+		if (type == as_connect && test_bit(ATM_VF_SESSION, &vcc->flags))
+			msg->session = ++session;
+			/* every new pmp connect gets the next session number */
+	}
 	sigd_put_skb(skb);
 	if (vcc) set_bit(ATM_VF_REGIS,&vcc->flags);
 }
@@ -205,9 +216,7 @@
 	if (vcc->sk->sk_family == PF_ATMSVC &&
 	    !test_bit(ATM_VF_META,&vcc->flags)) {
 		set_bit(ATM_VF_RELEASED,&vcc->flags);
-		vcc->sk->sk_err = EUNATCH;
-		clear_bit(ATM_VF_WAITING, &vcc->flags);
-		vcc->sk->sk_state_change(vcc->sk);
+		vcc_release_async(vcc, -EUNATCH);
 	}
 }
 
diff -Nru a/net/atm/svc.c b/net/atm/svc.c
--- a/net/atm/svc.c	2004-12-24 13:37:01 -08:00
+++ b/net/atm/svc.c	2004-12-24 13:37:01 -08:00
@@ -194,10 +194,6 @@
 		}
 		break;
 	case SS_UNCONNECTED:
-		if (test_bit(ATM_VF_SESSION, &vcc->flags)) {
-			error = -EINVAL;
-			goto out;
-		}
 		addr = (struct sockaddr_atmsvc *) sockaddr;
 		if (addr->sas_family != AF_ATMSVC) {
 			error = -EAFNOSUPPORT;
@@ -458,24 +454,48 @@
 }
 
 
-static int svc_setsockopt(struct socket *sock,int level,int optname,
-    char __user *optval,int optlen)
+static int svc_setsockopt(struct socket *sock, int level, int optname,
+			  char __user *optval, int optlen)
 {
 	struct sock *sk = sock->sk;
-	struct atm_vcc *vcc;
-	int error = 0;
+	struct atm_vcc *vcc = ATM_SD(sock);
+	int value, error = 0;
 
-	if (!__SO_LEVEL_MATCH(optname, level) || optname != SO_ATMSAP ||
-	    optlen != sizeof(struct atm_sap)) {
-		error = vcc_setsockopt(sock, level, optname, optval, optlen);
-		goto out;
-	}
-	vcc = ATM_SD(sock);
-	if (copy_from_user(&vcc->sap, optval, optlen)) {
-		error = -EFAULT;
-		goto out;
+	lock_sock(sk);
+	switch (optname) {
+		case SO_ATMSAP:
+			if (level != SOL_ATM || optlen != sizeof(struct atm_sap)) {
+				error = -EINVAL;
+				goto out;
+			}
+			if (copy_from_user(&vcc->sap, optval, optlen)) {
+				error = -EFAULT;
+				goto out;
+			}
+			set_bit(ATM_VF_HASSAP, &vcc->flags);
+			break;
+ 		case SO_MULTIPOINT:
+			if (level != SOL_ATM || optlen != sizeof(int)) {
+				error = -EINVAL;
+				goto out;
+			}
+ 			if (get_user(value, (int __user *) optval)) {
+ 				error = -EFAULT;
+				goto out;
+			}
+			if (value == 1) {
+				set_bit(ATM_VF_SESSION, &vcc->flags);
+			} else if (value == 0) {
+				clear_bit(ATM_VF_SESSION, &vcc->flags);
+			} else {
+				error = -EINVAL;
+			}
+  			break;
+		default:
+			error = vcc_setsockopt(sock, level, optname,
+					       optval, optlen);
 	}
-	set_bit(ATM_VF_HASSAP, &vcc->flags);
+
 out:
 	release_sock(sk);
 	return error;
@@ -511,6 +531,90 @@
 }
 
 
+static int svc_addparty(struct socket *sock, struct sockaddr *sockaddr,
+			int sockaddr_len, int flags)
+{
+	DEFINE_WAIT(wait);
+	struct atm_vcc *vcc = ATM_SD(sock);
+	int error;
+
+	lock_sock(vcc->sk);
+	set_bit(ATM_VF_WAITING, &vcc->flags);
+	prepare_to_wait(vcc->sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
+	sigd_enq(vcc, as_addparty, NULL, NULL,
+	         (struct sockaddr_atmsvc *) sockaddr);
+	if (flags & O_NONBLOCK) {
+		finish_wait(vcc->sk->sk_sleep, &wait);
+		error = -EINPROGRESS;
+		goto out;
+	}
+	DPRINTK("svc_addparty added wait queue\n");
+	while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) {
+		schedule();
+		prepare_to_wait(vcc->sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
+	}
+	finish_wait(vcc->sk->sk_sleep, &wait);
+	error = xchg(&vcc->sk->sk_err_soft, 0);
+out:
+	release_sock(vcc->sk);
+	return error;
+}
+
+
+static int svc_dropparty(struct socket *sock, int ep_ref)
+{
+	DEFINE_WAIT(wait);
+	struct atm_vcc *vcc = ATM_SD(sock);
+	int error;
+
+	lock_sock(vcc->sk);
+	set_bit(ATM_VF_WAITING, &vcc->flags);
+	prepare_to_wait(vcc->sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
+	sigd_enq2(vcc, as_dropparty, NULL, NULL, NULL, NULL, ep_ref);
+	while (test_bit(ATM_VF_WAITING, &vcc->flags) && sigd) {
+		schedule();
+		prepare_to_wait(vcc->sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
+	}
+	finish_wait(vcc->sk->sk_sleep, &wait);
+	if (!sigd) {
+		error = -EUNATCH;
+		goto out;
+	}
+	error = xchg(&vcc->sk->sk_err_soft, 0);
+out:
+	release_sock(vcc->sk);
+	return error;
+}
+
+
+static int svc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
+{
+ 	int error, ep_ref;
+ 	struct sockaddr_atmsvc sa;
+	struct atm_vcc *vcc = ATM_SD(sock);
+  
+	switch (cmd) {
+ 		case ATM_ADDPARTY:
+ 			if (!test_bit(ATM_VF_SESSION, &vcc->flags))
+ 				return -EINVAL;
+ 			if (copy_from_user(&sa, (void __user *) arg, sizeof(sa)))
+				return -EFAULT;
+ 			error = svc_addparty(sock, (struct sockaddr *) &sa, sizeof(sa), 0);
+ 			break;
+ 		case ATM_DROPPARTY:
+ 			if (!test_bit(ATM_VF_SESSION, &vcc->flags))
+ 				return -EINVAL;
+ 			if (copy_from_user(&ep_ref, (void __user *) arg, sizeof(int)))
+				return -EFAULT;
+ 			error = svc_dropparty(sock, ep_ref);
+ 			break;
+  		default:
+			error = vcc_ioctl(sock, cmd, arg);
+	}
+
+	return error;
+}
+
 static struct proto_ops svc_proto_ops = {
 	.family =	PF_ATMSVC,
 	.owner =	THIS_MODULE,
@@ -522,7 +626,7 @@
 	.accept =	svc_accept,
 	.getname =	svc_getname,
 	.poll =		vcc_poll,
-	.ioctl =	vcc_ioctl,
+	.ioctl =	svc_ioctl,
 	.listen =	svc_listen,
 	.shutdown =	svc_shutdown,
 	.setsockopt =	svc_setsockopt,
diff -Nru a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
--- a/net/ax25/af_ax25.c	2004-12-24 13:37:19 -08:00
+++ b/net/ax25/af_ax25.c	2004-12-24 13:37:19 -08:00
@@ -207,16 +207,8 @@
 			continue;
 		if (s->ax25_dev == NULL)
 			continue;
-		if (ax25cmp(&s->source_addr, src_addr) == 0 && ax25cmp(&s->dest_addr, dest_addr) == 0 && s->ax25_dev->dev == dev) {
-			if (digi != NULL && digi->ndigi != 0) {
-				if (s->digipeat == NULL)
-					continue;
-				if (ax25digicmp(s->digipeat, digi) != 0)
-					continue;
-			} else {
-				if (s->digipeat != NULL && s->digipeat->ndigi != 0)
-					continue;
-			}
+		if (ax25cmp(&s->source_addr, src_addr) == 0 &&
+		    ax25cmp(&s->dest_addr, dest_addr) == 0) {
 			ax25_cb_hold(s);
 			spin_unlock_bh(&ax25_list_lock);
 
diff -Nru a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
--- a/net/ax25/ax25_route.c	2004-12-24 13:37:02 -08:00
+++ b/net/ax25/ax25_route.c	2004-12-24 13:37:02 -08:00
@@ -41,22 +41,6 @@
 
 static ax25_route *ax25_get_route(ax25_address *, struct net_device *);
 
-/*
- * small macro to drop non-digipeated digipeaters and reverse path
- */
-static inline void ax25_route_invert(ax25_digi *in, ax25_digi *out)
-{
-	int k;
-
-	for (k = 0; k < in->ndigi; k++)
-		if (!in->repeated[k])
-			break;
-
-	in->ndigi = k;
-
-	ax25_digi_invert(in, out);
-}
-
 void ax25_rt_device_down(struct net_device *dev)
 {
 	ax25_route *s, *t, *ax25_rt;
diff -Nru a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
--- a/net/bluetooth/af_bluetooth.c	2004-12-24 13:36:19 -08:00
+++ b/net/bluetooth/af_bluetooth.c	2004-12-24 13:36:19 -08:00
@@ -51,7 +51,7 @@
 #define BT_DBG(D...)
 #endif
 
-#define VERSION "2.6"
+#define VERSION "2.7"
 
 struct proc_dir_entry *proc_bt;
 EXPORT_SYMBOL(proc_bt);
@@ -165,7 +165,7 @@
 }
 EXPORT_SYMBOL(bt_accept_enqueue);
 
-static void bt_accept_unlink(struct sock *sk)
+void bt_accept_unlink(struct sock *sk)
 {
 	BT_DBG("sk %p state %d", sk, sk->sk_state);
 
@@ -174,6 +174,7 @@
 	bt_sk(sk)->parent = NULL;
 	sock_put(sk);
 }
+EXPORT_SYMBOL(bt_accept_unlink);
 
 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock)
 {
@@ -186,6 +187,8 @@
 		sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
 
 		lock_sock(sk);
+
+		/* FIXME: Is this check still needed */
 		if (sk->sk_state == BT_CLOSED) {
 			release_sock(sk);
 			bt_accept_unlink(sk);
@@ -199,6 +202,7 @@
 			release_sock(sk);
 			return sk;
 		}
+
 		release_sock(sk);
 	}
 	return NULL;
diff -Nru a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
--- a/net/bluetooth/cmtp/capi.c	2004-12-24 13:37:00 -08:00
+++ b/net/bluetooth/cmtp/capi.c	2004-12-24 13:37:00 -08:00
@@ -493,7 +493,6 @@
 	application = cmtp_application_get(session, CMTP_APPLID, appl);
 	if ((!application) || (application->state != BT_CONNECTED)) {
 		BT_ERR("Can't find application with id %d", appl);
-		kfree_skb(skb);
 		return CAPI_ILLAPPNR;
 	}
 
diff -Nru a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
--- a/net/bluetooth/hci_conn.c	2004-12-24 13:37:30 -08:00
+++ b/net/bluetooth/hci_conn.c	2004-12-24 13:37:30 -08:00
@@ -71,9 +71,10 @@
 
 	if ((ie = hci_inquiry_cache_lookup(hdev, &conn->dst)) &&
 			inquiry_entry_age(ie) <= INQUIRY_ENTRY_AGE_MAX) {
-		cp.pscan_rep_mode = ie->info.pscan_rep_mode;
-		cp.pscan_mode     = ie->info.pscan_mode;
-		cp.clock_offset   = ie->info.clock_offset | __cpu_to_le16(0x8000);
+		cp.pscan_rep_mode = ie->data.pscan_rep_mode;
+		cp.pscan_mode     = ie->data.pscan_mode;
+		cp.clock_offset   = ie->data.clock_offset | __cpu_to_le16(0x8000);
+		memcpy(conn->dev_class, ie->data.dev_class, 3);
 	}
 
 	cp.pkt_type = __cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK);
@@ -163,12 +164,13 @@
 	hci_dev_hold(hdev);
 
 	tasklet_disable(&hdev->tx_task);
-	hci_conn_hash_add(hdev, conn);
-	tasklet_enable(&hdev->tx_task);
 
+	hci_conn_hash_add(hdev, conn);
 	if (hdev->notify)
 		hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
 
+	tasklet_enable(&hdev->tx_task);
+
 	return conn;
 }
 
@@ -195,11 +197,12 @@
 		hdev->acl_cnt += conn->sent;
 	}
 
+	tasklet_disable(&hdev->tx_task);
+
+	hci_conn_hash_del(hdev, conn);
 	if (hdev->notify)
 		hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
 
-	tasklet_disable(&hdev->tx_task);
-	hci_conn_hash_del(hdev, conn);
 	tasklet_enable(&hdev->tx_task);
 
 	skb_queue_purge(&conn->data_q);
@@ -330,6 +333,20 @@
 	return 0;
 }
 EXPORT_SYMBOL(hci_conn_encrypt);
+
+/* Change link key */
+int hci_conn_change_link_key(struct hci_conn *conn)
+{
+	BT_DBG("conn %p", conn);
+
+	if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
+		struct hci_cp_change_conn_link_key cp;
+		cp.handle = __cpu_to_le16(conn->handle);
+		hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_CHANGE_CONN_LINK_KEY, sizeof(cp), &cp);
+	}
+	return 0;
+}
+EXPORT_SYMBOL(hci_conn_change_link_key);
 
 /* Drop all connection on the device */
 void hci_conn_hash_flush(struct hci_dev *hdev)
diff -Nru a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
--- a/net/bluetooth/hci_core.c	2004-12-24 13:36:31 -08:00
+++ b/net/bluetooth/hci_core.c	2004-12-24 13:36:31 -08:00
@@ -65,6 +65,10 @@
 LIST_HEAD(hci_dev_list);
 rwlock_t hci_dev_list_lock = RW_LOCK_UNLOCKED;
 
+/* HCI callback list */
+LIST_HEAD(hci_cb_list);
+rwlock_t hci_cb_list_lock = RW_LOCK_UNLOCKED;
+
 /* HCI protocols */
 #define HCI_MAX_PROTO	2
 struct hci_proto *hci_proto[HCI_MAX_PROTO];
@@ -309,19 +313,19 @@
 	BT_DBG("cache %p, %s", cache, batostr(bdaddr));
 
 	for (e = cache->list; e; e = e->next)
-		if (!bacmp(&e->info.bdaddr, bdaddr))
+		if (!bacmp(&e->data.bdaddr, bdaddr))
 			break;
 	return e;
 }
 
-void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_info *info)
+void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data)
 {
 	struct inquiry_cache *cache = &hdev->inq_cache;
 	struct inquiry_entry *e;
 
-	BT_DBG("cache %p, %s", cache, batostr(&info->bdaddr));
+	BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr));
 
-	if (!(e = hci_inquiry_cache_lookup(hdev, &info->bdaddr))) {
+	if (!(e = hci_inquiry_cache_lookup(hdev, &data->bdaddr))) {
 		/* Entry not in the cache. Add new one. */
 		if (!(e = kmalloc(sizeof(struct inquiry_entry), GFP_ATOMIC)))
 			return;
@@ -330,7 +334,7 @@
 		cache->list = e;
 	}
 
-	memcpy(&e->info, info, sizeof(*info));
+	memcpy(&e->data, data, sizeof(*data));
 	e->timestamp = jiffies;
 	cache->timestamp = jiffies;
 }
@@ -342,8 +346,16 @@
 	struct inquiry_entry *e;
 	int copied = 0;
 
-	for (e = cache->list; e && copied < num; e = e->next, copied++)
-		memcpy(info++, &e->info, sizeof(*info));
+	for (e = cache->list; e && copied < num; e = e->next, copied++) {
+		struct inquiry_data *data = &e->data;
+		bacpy(&info->bdaddr, &data->bdaddr);
+		info->pscan_rep_mode	= data->pscan_rep_mode;
+		info->pscan_period_mode	= data->pscan_period_mode;
+		info->pscan_mode	= data->pscan_mode;
+		memcpy(info->dev_class, data->dev_class, 3);
+		info->clock_offset	= data->clock_offset;
+		info++;
+	}
 
 	BT_DBG("cache %p, copied %d", cache, copied);
 	return copied;
@@ -929,6 +941,30 @@
 	return err;
 }
 EXPORT_SYMBOL(hci_unregister_proto);
+
+int hci_register_cb(struct hci_cb *cb)
+{
+	BT_DBG("%p name %s", cb, cb->name);
+
+	write_lock_bh(&hci_cb_list_lock);
+	list_add(&cb->list, &hci_cb_list);
+	write_unlock_bh(&hci_cb_list_lock);
+
+	return 0;
+}
+EXPORT_SYMBOL(hci_register_cb);
+
+int hci_unregister_cb(struct hci_cb *cb)
+{
+	BT_DBG("%p name %s", cb, cb->name);
+
+	write_lock_bh(&hci_cb_list_lock);
+	list_del(&cb->list);
+	write_unlock_bh(&hci_cb_list_lock);
+
+	return 0;
+}
+EXPORT_SYMBOL(hci_unregister_cb);
 
 static int hci_send_frame(struct sk_buff *skb)
 {
diff -Nru a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
--- a/net/bluetooth/hci_event.c	2004-12-24 13:36:17 -08:00
+++ b/net/bluetooth/hci_event.c	2004-12-24 13:36:17 -08:00
@@ -104,7 +104,7 @@
 			else
 				conn->link_mode |= HCI_LM_MASTER;
 		}
-			
+
 		hci_dev_unlock(hdev);
 		break;
 
@@ -229,8 +229,11 @@
 
 			BT_DBG("%s: voice setting 0x%04x", hdev->name, setting);
 
-			if (hdev->notify)
+			if (hdev->notify) {
+				tasklet_disable(&hdev->tx_task);
 				hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
+				tasklet_enable(&hdev->tx_task);
+			}
 		}
 		break;
 
@@ -247,8 +250,11 @@
 
 			BT_DBG("%s: voice setting 0x%04x", hdev->name, setting);
 
-			if (hdev->notify)
+			if (hdev->notify) {
+				tasklet_disable(&hdev->tx_task);
 				hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
+				tasklet_enable(&hdev->tx_task);
+			}
 		}
 		hci_req_complete(hdev, status);
 		break;
@@ -320,7 +326,7 @@
 		hdev->sco_pkts = hdev->sco_cnt = __le16_to_cpu(bs->sco_max_pkt);
 
 		BT_DBG("%s mtu: acl %d, sco %d max_pkt: acl %d, sco %d", hdev->name,
-			    hdev->acl_mtu, hdev->sco_mtu, hdev->acl_pkts, hdev->sco_pkts);
+			hdev->acl_mtu, hdev->sco_mtu, hdev->acl_pkts, hdev->sco_pkts);
 		break;
 
 	case OCF_READ_BD_ADDR:
@@ -400,7 +406,7 @@
 			BT_DBG("%s Add SCO error: handle %d status 0x%x", hdev->name, handle, status);
 
 			hci_dev_lock(hdev);
-	
+
 			acl = hci_conn_hash_lookup_handle(hdev, handle);
 			if (acl && (sco = acl->link)) {
 				sco->state = BT_CLOSED;
@@ -485,8 +491,18 @@
 	BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
 
 	hci_dev_lock(hdev);
-	for (; num_rsp; num_rsp--)
-		hci_inquiry_cache_update(hdev, info++);
+	for (; num_rsp; num_rsp--) {
+		struct inquiry_data data;
+		bacpy(&data.bdaddr, &info->bdaddr);
+		data.pscan_rep_mode	= info->pscan_rep_mode;
+		data.pscan_period_mode	= info->pscan_period_mode;
+		data.pscan_mode		= info->pscan_mode;
+		memcpy(data.dev_class, info->dev_class, 3);
+		data.clock_offset	= info->clock_offset;
+		data.rssi		= 0x00;
+		info++;
+		hci_inquiry_cache_update(hdev, &data);
+	}
 	hci_dev_unlock(hdev);
 }
 
@@ -500,15 +516,16 @@
 
 	hci_dev_lock(hdev);
 	for (; num_rsp; num_rsp--) {
-		struct inquiry_info tmp;
-		bacpy(&tmp.bdaddr, &info->bdaddr);
-		tmp.pscan_rep_mode    = info->pscan_rep_mode;
-		tmp.pscan_period_mode = info->pscan_period_mode;
-		tmp.pscan_mode        = 0x00;
-		memcpy(tmp.dev_class, &info->dev_class, 3);
-		tmp.clock_offset      = info->clock_offset;
+		struct inquiry_data data;
+		bacpy(&data.bdaddr, &info->bdaddr);
+		data.pscan_rep_mode	= info->pscan_rep_mode;
+		data.pscan_period_mode	= info->pscan_period_mode;
+		data.pscan_mode		= 0x00;
+		memcpy(data.dev_class, info->dev_class, 3);
+		data.clock_offset	= info->clock_offset;
+		data.rssi		= info->rssi;
 		info++;
-		hci_inquiry_cache_update(hdev, &tmp);
+		hci_inquiry_cache_update(hdev, &data);
 	}
 	hci_dev_unlock(hdev);
 }
@@ -538,11 +555,12 @@
 				return;
 			}
 		}
+		memcpy(conn->dev_class, ev->dev_class, 3);
 		conn->state = BT_CONNECT;
 		hci_dev_unlock(hdev);
 
 		bacpy(&cp.bdaddr, &ev->bdaddr);
-	
+
 		if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER))
 			cp.role = 0x00; /* Become master */
 		else
@@ -585,7 +603,6 @@
 		if (test_bit(HCI_ENCRYPT, &hdev->flags))
 			conn->link_mode |= HCI_LM_ENCRYPT;
 
-
 		/* Set link policy */
 		if (conn->type == ACL_LINK && hdev->link_policy) {
 			struct hci_cp_write_link_policy cp;
@@ -710,7 +727,7 @@
 	if (conn) {
 		if (ev->role)
 			conn->link_mode &= ~HCI_LM_MASTER;
-		else 
+		else
 			conn->link_mode |= HCI_LM_MASTER;
 	}
 
@@ -734,7 +751,7 @@
 			conn->link_mode |= HCI_LM_AUTH;
 		clear_bit(HCI_CONN_AUTH_PEND, &conn->pend);
 
-		hci_proto_auth_cfm(conn, ev->status);
+		hci_auth_cfm(conn, ev->status);
 
 		if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
 			if (!ev->status) {
@@ -746,7 +763,7 @@
 						sizeof(cp), &cp);
 			} else {
 				clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
-				hci_proto_encrypt_cfm(conn, ev->status);
+				hci_encrypt_cfm(conn, ev->status, 0x00);
 			}
 		}
 	}
@@ -774,13 +791,33 @@
 				conn->link_mode &= ~HCI_LM_ENCRYPT;
 		}
 		clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
-		
-		hci_proto_encrypt_cfm(conn, ev->status);
+
+		hci_encrypt_cfm(conn, ev->status, ev->encrypt);
 	}
 
 	hci_dev_unlock(hdev);
 }
 
+/* Change Connection Link Key Complete */
+static inline void hci_change_conn_link_key_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
+{
+}
+
+/* Pin Code Request*/
+static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
+{
+}
+
+/* Link Key Request */
+static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
+{
+}
+
+/* Link Key Notification */
+static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
+{
+}
+
 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_event_hdr *hdr = (struct hci_event_hdr *) skb->data;
@@ -831,6 +868,22 @@
 
 	case HCI_EV_ENCRYPT_CHANGE:
 		hci_encrypt_change_evt(hdev, skb);
+		break;
+
+	case HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE:
+		hci_change_conn_link_key_complete_evt(hdev, skb);
+		break;
+
+	case HCI_EV_PIN_CODE_REQ:
+		hci_pin_code_request_evt(hdev, skb);
+		break;
+
+	case HCI_EV_LINK_KEY_REQ:
+		hci_link_key_request_evt(hdev, skb);
+		break;
+
+	case HCI_EV_LINK_KEY_NOTIFY:
+		hci_link_key_notify_evt(hdev, skb);
 		break;
 
 	case HCI_EV_CMD_STATUS:
diff -Nru a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
--- a/net/bluetooth/hci_sock.c	2004-12-24 13:36:57 -08:00
+++ b/net/bluetooth/hci_sock.c	2004-12-24 13:36:57 -08:00
@@ -111,7 +111,8 @@
 		/* Apply filter */
 		flt = &hci_pi(sk)->filter;
 
-		if (!test_bit((skb->pkt_type & HCI_FLT_TYPE_BITS), &flt->type_mask))
+		if (!test_bit((skb->pkt_type == HCI_VENDOR_PKT) ?
+				0 : (skb->pkt_type & HCI_FLT_TYPE_BITS), &flt->type_mask))
 			continue;
 
 		if (skb->pkt_type == HCI_EVENT_PKT) {
@@ -182,6 +183,17 @@
 			set_bit(HCI_RAW, &hdev->flags);
 		else
 			clear_bit(HCI_RAW, &hdev->flags);
+
+		return 0;
+
+	case HCISETSECMGR:
+		if (!capable(CAP_NET_ADMIN))
+			return -EACCES;
+
+		if (arg)
+			set_bit(HCI_SECMGR, &hdev->flags);
+		else
+			clear_bit(HCI_SECMGR, &hdev->flags);
 
 		return 0;
 
diff -Nru a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
--- a/net/bluetooth/hci_sysfs.c	2004-12-24 13:37:04 -08:00
+++ b/net/bluetooth/hci_sysfs.c	2004-12-24 13:37:04 -08:00
@@ -48,14 +48,14 @@
 	hci_dev_lock_bh(hdev);
 
 	for (e = cache->list; e; e = e->next) {
-		struct inquiry_info *info = &e->info;
+		struct inquiry_data *data = &e->data;
 		bdaddr_t bdaddr;
-		baswap(&bdaddr, &info->bdaddr);
-		n += sprintf(buf + n, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x 0x%.2x %u\n",
+		baswap(&bdaddr, &data->bdaddr);
+		n += sprintf(buf + n, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %u\n",
 				batostr(&bdaddr),
-				info->pscan_rep_mode, info->pscan_period_mode, info->pscan_mode,
-				info->dev_class[2], info->dev_class[1], info->dev_class[0],
-				info->clock_offset, 0, e->timestamp);
+				data->pscan_rep_mode, data->pscan_period_mode, data->pscan_mode,
+				data->dev_class[2], data->dev_class[1], data->dev_class[0],
+				data->clock_offset, data->rssi, e->timestamp);
 	}
 
 	hci_dev_unlock_bh(hdev);
@@ -114,7 +114,8 @@
 int hci_register_sysfs(struct hci_dev *hdev)
 {
 	struct class_device *cdev = &hdev->class_dev;
-	int i, err;
+	unsigned int i;
+	int err;
 
 	BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);
 
diff -Nru a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
--- a/net/bluetooth/l2cap.c	2004-12-24 13:37:02 -08:00
+++ b/net/bluetooth/l2cap.c	2004-12-24 13:37:02 -08:00
@@ -57,7 +57,7 @@
 #define BT_DBG(D...)
 #endif
 
-#define VERSION "2.4"
+#define VERSION "2.6"
 
 static struct proto_ops l2cap_sock_ops;
 
@@ -74,8 +74,8 @@
 static void l2cap_sock_close(struct sock *sk);
 static void l2cap_sock_kill(struct sock *sk);
 
-static int l2cap_send_req(struct l2cap_conn *conn, u8 code, u16 len, void *data);
-static int l2cap_send_rsp(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
+static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
+				u8 code, u8 ident, u16 dlen, void *data);
 
 /* ---- L2CAP timers ---- */
 static void l2cap_sock_timeout(unsigned long arg)
@@ -134,7 +134,7 @@
 	conn->dst = &hcon->dst;
 
 	spin_lock_init(&conn->lock);
-	conn->chan_list.lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&conn->chan_list.lock);
 
 	BT_DBG("hcon %p conn %p", hcon, conn);
 	return conn;
@@ -174,6 +174,40 @@
 	write_unlock(&l->lock);
 }
 
+static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
+{
+	u8 id;
+
+	/* Get next available identificator.
+	 *    1 - 128 are used by kernel.
+	 *  129 - 199 are reserved.
+	 *  200 - 254 are used by utilities like l2ping, etc.
+	 */
+
+	spin_lock(&conn->lock);
+
+	if (++conn->tx_ident > 128)
+		conn->tx_ident = 1;
+
+	id = conn->tx_ident;
+
+	spin_unlock(&conn->lock);
+
+	return id;
+}
+
+static inline int l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
+{
+	struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
+
+	BT_DBG("code 0x%2.2x", code);
+
+	if (!skb)
+		return -ENOMEM;
+
+	return hci_send_acl(conn->hcon, skb, 0);
+}
+
 /* ---- Socket interface ---- */
 static struct sock *__l2cap_get_sock_by_addr(u16 psm, bdaddr_t *src)
 {
@@ -286,7 +320,8 @@
 
 			req.dcid = __cpu_to_le16(l2cap_pi(sk)->dcid);
 			req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
-			l2cap_send_req(conn, L2CAP_DISCONN_REQ, sizeof(req), &req);
+			l2cap_send_cmd(conn, l2cap_get_ident(conn),
+					L2CAP_DISCONN_REQ, sizeof(req), &req);
 		} else {
 			l2cap_chan_del(sk, reason);
 		}
@@ -365,7 +400,8 @@
 
 	sock->state = SS_UNCONNECTED;
 
-	if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_DGRAM && sock->type != SOCK_RAW)
+	if (sock->type != SOCK_SEQPACKET &&
+			sock->type != SOCK_DGRAM && sock->type != SOCK_RAW)
 		return -ESOCKTNOSUPPORT;
 
 	if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW))
@@ -459,9 +495,11 @@
 	if (hcon->state == BT_CONNECTED) {
 		if (sk->sk_type == SOCK_SEQPACKET) {
 			struct l2cap_conn_req req;
+			l2cap_pi(sk)->ident = l2cap_get_ident(conn);
 			req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
 			req.psm  = l2cap_pi(sk)->psm;
-			l2cap_send_req(conn, L2CAP_CONN_REQ, sizeof(req), &req);
+			l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
+					L2CAP_CONN_REQ, sizeof(req), &req);
 		} else {
 			l2cap_sock_clear_timer(sk);
 			sk->sk_state = BT_CONNECTED;
@@ -911,6 +949,26 @@
 	return s;
 }
 
+static struct sock *__l2cap_get_chan_by_ident(struct l2cap_chan_list *l, u8 ident)
+{
+	struct sock *s;
+	for (s = l->head; s; s = l2cap_pi(s)->next_c) {
+		if (l2cap_pi(s)->ident == ident)
+			break;
+	}
+	return s;
+}
+
+static inline struct sock *l2cap_get_chan_by_ident(struct l2cap_chan_list *l, u8 ident)
+{
+	struct sock *s;
+	read_lock(&l->lock);
+	s = __l2cap_get_chan_by_ident(l, ident);
+	if (s) bh_lock_sock(s);
+	read_unlock(&l->lock);
+	return s;
+}
+
 static u16 l2cap_alloc_cid(struct l2cap_chan_list *l)
 {
 	u16 cid = 0x0040;
@@ -1005,9 +1063,10 @@
 	if (err)
 		sk->sk_err = err;
 
-	if (parent)
+	if (parent) {
+		bt_accept_unlink(sk);
 		parent->sk_data_ready(parent, 0);
-	else
+	} else
 		sk->sk_state_change(sk);
 }
 
@@ -1029,9 +1088,10 @@
 			sk->sk_state_change(sk);
 		} else if (sk->sk_state == BT_CONNECT) {
 			struct l2cap_conn_req req;
+			l2cap_pi(sk)->ident = l2cap_get_ident(conn);
 			req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
 			req.psm  = l2cap_pi(sk)->psm;
-			l2cap_send_req(conn, L2CAP_CONN_REQ, sizeof(req), &req);
+			l2cap_send_cmd(conn, l2cap_pi(sk)->ident, L2CAP_CONN_REQ, sizeof(req), &req);
 		}
 
 		bh_unlock_sock(sk);
@@ -1040,6 +1100,22 @@
 	read_unlock(&l->lock);
 }
 
+/* Notify sockets that we cannot guaranty reliability anymore */
+static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
+{
+	struct l2cap_chan_list *l = &conn->chan_list;
+	struct sock *sk;
+
+	BT_DBG("conn %p", conn);
+
+	read_lock(&l->lock);
+	for (sk = l->head; sk; sk = l2cap_pi(sk)->next_c) {
+		if (l2cap_pi(sk)->link_mode & L2CAP_LM_RELIABLE)
+			sk->sk_err = err;
+	}
+	read_unlock(&l->lock);
+}
+
 static void l2cap_chan_ready(struct sock *sk)
 {
 	struct sock *parent = bt_sk(sk)->parent;
@@ -1091,27 +1167,6 @@
 }
 
 /* ---- L2CAP signalling commands ---- */
-static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
-{
-	u8 id;
-
-	/* Get next available identificator.
-	 *    1 - 199 are used by kernel.
-	 *  200 - 254 are used by utilities like l2ping, etc 
-	 */
-
-	spin_lock(&conn->lock);
-
-	if (++conn->tx_ident > 199)
-		conn->tx_ident = 1;
-
-	id = conn->tx_ident;
-
-	spin_unlock(&conn->lock);
-
-	return id;
-}
-
 static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
 				u8 code, u8 ident, u16 dlen, void *data)
 {
@@ -1170,29 +1225,6 @@
 	return NULL;
 }
 
-static int l2cap_send_req(struct l2cap_conn *conn, u8 code, u16 len, void *data)
-{
-	u8 ident = l2cap_get_ident(conn);
-	struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
-
-	BT_DBG("code 0x%2.2x", code);
-
-	if (!skb)
-		return -ENOMEM;
-	return hci_send_acl(conn->hcon, skb, 0);
-}
-
-static int l2cap_send_rsp(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
-{
-	struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
-
-	BT_DBG("code 0x%2.2x", code);
-
-	if (!skb)
-		return -ENOMEM;
-	return hci_send_acl(conn->hcon, skb, 0);
-}
-
 static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned long *val)
 {
 	struct l2cap_conf_opt *opt = *ptr;
@@ -1303,7 +1335,7 @@
 	if (pi->imtu != L2CAP_DEFAULT_MTU)
 		l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->imtu);
 
-	/* FIXME. Need actual value of the flush timeout */
+	/* FIXME: Need actual value of the flush timeout */
 	//if (flush_to != L2CAP_DEFAULT_FLUSH_TO)
 	//   l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, 2, pi->flush_to);
 
@@ -1411,8 +1443,9 @@
 	status = L2CAP_CS_AUTHEN_PEND;
 	sk->sk_state = BT_CONNECT2;
 	l2cap_pi(sk)->ident = cmd->ident;
-	
-	if (l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT) {
+
+	if ((l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT) ||
+			(l2cap_pi(sk)->link_mode & L2CAP_LM_SECURE)) {
 		if (!hci_conn_encrypt(conn->hcon))
 			goto done;
 	} else if (l2cap_pi(sk)->link_mode & L2CAP_LM_AUTH) {
@@ -1434,7 +1467,7 @@
 	rsp.dcid   = __cpu_to_le16(dcid);
 	rsp.result = __cpu_to_le16(result);
 	rsp.status = __cpu_to_le16(status);
-	l2cap_send_rsp(conn, cmd->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
+	l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
 	return 0;
 }
 
@@ -1452,16 +1485,23 @@
 
 	BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status);
 
-	if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid)))
-		return 0;
+	if (scid) {
+		if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid)))
+			return 0;
+	} else {
+		if (!(sk = l2cap_get_chan_by_ident(&conn->chan_list, cmd->ident)))
+			return 0;
+	}
 
 	switch (result) {
 	case L2CAP_CR_SUCCESS:
 		sk->sk_state = BT_CONFIG;
+		l2cap_pi(sk)->ident = 0;
 		l2cap_pi(sk)->dcid = dcid;
 		l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
 
-		l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
+		l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
+					l2cap_build_conf_req(sk, req), req);
 		break;
 
 	case L2CAP_CR_PEND:
@@ -1496,12 +1536,14 @@
 
 	if (flags & 0x0001) {
 		/* Incomplete config. Send empty response. */
-		l2cap_send_rsp(conn, cmd->ident, L2CAP_CONF_RSP, l2cap_build_conf_rsp(sk, rsp, NULL), rsp);
+		l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
+				l2cap_build_conf_rsp(sk, rsp, NULL), rsp);
 		goto unlock;
 	}
 
 	/* Complete config. */
-	l2cap_send_rsp(conn, cmd->ident, L2CAP_CONF_RSP, l2cap_build_conf_rsp(sk, rsp, &result), rsp);
+	l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
+			l2cap_build_conf_rsp(sk, rsp, &result), rsp);
 
 	if (result)
 		goto unlock;
@@ -1514,7 +1556,8 @@
 		l2cap_chan_ready(sk);
 	} else if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT)) {
 		u8 req[64];
-		l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
+		l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
+					l2cap_build_conf_req(sk, req), req);
 	}
 
 unlock:
@@ -1549,8 +1592,8 @@
 			 * resend config request that we sent earlier. It is
 			 * stupid, but it helps qualification testing which
 			 * expects at least some response from us. */
-			l2cap_send_req(conn, L2CAP_CONF_REQ,
-				l2cap_build_conf_req(sk, req), req);
+			l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
+						l2cap_build_conf_req(sk, req), req);
 			goto done;
 		}
 
@@ -1562,7 +1605,8 @@
 			struct l2cap_disconn_req req;
 			req.dcid = __cpu_to_le16(l2cap_pi(sk)->dcid);
 			req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
-			l2cap_send_req(conn, L2CAP_DISCONN_REQ, sizeof(req), &req);
+			l2cap_send_cmd(conn, l2cap_get_ident(conn),
+					L2CAP_DISCONN_REQ, sizeof(req), &req);
 		}
 		goto done;
 	}
@@ -1600,7 +1644,7 @@
 
 	rsp.dcid = __cpu_to_le16(l2cap_pi(sk)->scid);
 	rsp.scid = __cpu_to_le16(l2cap_pi(sk)->dcid);
-	l2cap_send_rsp(conn, cmd->ident, L2CAP_DISCONN_RSP, sizeof(rsp), &rsp);
+	l2cap_send_cmd(conn, cmd->ident, L2CAP_DISCONN_RSP, sizeof(rsp), &rsp);
 
 	sk->sk_shutdown = SHUTDOWN_MASK;
 
@@ -1644,7 +1688,7 @@
 
 	rsp.type   = __cpu_to_le16(type);
 	rsp.result = __cpu_to_le16(L2CAP_IR_NOTSUPP);
-	l2cap_send_rsp(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp), &rsp);
+	l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp), &rsp);
 
 	return 0;
 }
@@ -1715,7 +1759,7 @@
 			break;
 
 		case L2CAP_ECHO_REQ:
-			l2cap_send_rsp(conn, cmd.ident, L2CAP_ECHO_RSP, cmd.len, data);
+			l2cap_send_cmd(conn, cmd.ident, L2CAP_ECHO_RSP, cmd.len, data);
 			break;
 
 		case L2CAP_ECHO_RSP:
@@ -1741,7 +1785,7 @@
 
 			/* FIXME: Map err to a valid reason */
 			rej.reason = __cpu_to_le16(0);
-			l2cap_send_rsp(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
+			l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
 		}
 
 		data += cmd.len;
@@ -1920,7 +1964,8 @@
 		bh_lock_sock(sk);
 
 		if (sk->sk_state != BT_CONNECT2 ||
-				(l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT)) {
+				(l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT) ||
+				(l2cap_pi(sk)->link_mode & L2CAP_LM_SECURE)) {
 			bh_unlock_sock(sk);
 			continue;
 		}
@@ -1938,7 +1983,8 @@
 		rsp.dcid   = __cpu_to_le16(l2cap_pi(sk)->scid);
 		rsp.result = __cpu_to_le16(result);
 		rsp.status = __cpu_to_le16(0);
-		l2cap_send_rsp(conn, l2cap_pi(sk)->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
+		l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
+				L2CAP_CONN_RSP, sizeof(rsp), &rsp);
 
 		bh_unlock_sock(sk);
 	}
@@ -1984,7 +2030,11 @@
 		rsp.dcid   = __cpu_to_le16(l2cap_pi(sk)->scid);
 		rsp.result = __cpu_to_le16(result);
 		rsp.status = __cpu_to_le16(0);
-		l2cap_send_rsp(conn, l2cap_pi(sk)->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
+		l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
+				L2CAP_CONN_RSP, sizeof(rsp), &rsp);
+
+		if (l2cap_pi(sk)->link_mode & L2CAP_LM_SECURE)
+			hci_conn_change_link_key(hcon);
 
 		bh_unlock_sock(sk);
 	}
@@ -2011,10 +2061,12 @@
 			kfree_skb(conn->rx_skb);
 			conn->rx_skb = NULL;
 			conn->rx_len = 0;
+			l2cap_conn_unreliable(conn, ECOMM);
 		}
 
 		if (skb->len < 2) {
 			BT_ERR("Frame is too short (len %d)", skb->len);
+			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
 
@@ -2032,6 +2084,7 @@
 		if (skb->len > len) {
 			BT_ERR("Frame is too long (len %d, expected len %d)",
 				skb->len, len);
+			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
 
@@ -2046,6 +2099,7 @@
 
 		if (!conn->rx_len) {
 			BT_ERR("Unexpected continuation frame (len %d)", skb->len);
+			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
 
@@ -2055,6 +2109,7 @@
 			kfree_skb(conn->rx_skb);
 			conn->rx_skb = NULL;
 			conn->rx_len = 0;
+			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
 
@@ -2236,7 +2291,7 @@
 void l2cap_load(void)
 {
 	/* Dummy function to trigger automatic L2CAP module loading by
-	 * other modules that use L2CAP sockets but don not use any othe
+	 * other modules that use L2CAP sockets but don't use any other
 	 * symbols from it. */
 	return;
 }
diff -Nru a/net/bluetooth/lib.c b/net/bluetooth/lib.c
--- a/net/bluetooth/lib.c	2004-12-24 13:36:17 -08:00
+++ b/net/bluetooth/lib.c	2004-12-24 13:36:17 -08:00
@@ -38,13 +38,13 @@
 {
 	char *ptr;
 	char line[100];
-	int i;
+	unsigned int i;
 
 	printk(KERN_INFO "%s: dump, len %d\n", pref, count);
 
 	ptr = line;
 	*ptr = 0;
-	for (i = 0; i<count; i++) {
+	for (i = 0; i < count; i++) {
 		ptr += sprintf(ptr, " %2.2X", buf[i]);
 
 		if (i && !((i + 1) % 20)) {
@@ -63,7 +63,7 @@
 {
 	unsigned char *d = (unsigned char *) dst;
 	unsigned char *s = (unsigned char *) src;
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < 6; i++)
 		d[i] = s[5 - i];
diff -Nru a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
--- a/net/bluetooth/rfcomm/sock.c	2004-12-24 13:37:01 -08:00
+++ b/net/bluetooth/rfcomm/sock.c	2004-12-24 13:37:01 -08:00
@@ -97,17 +97,26 @@
 
 	if (err)
 		sk->sk_err = err;
+
 	sk->sk_state = d->state;
 
 	parent = bt_sk(sk)->parent;
-	if (!parent) {
+	if (parent) {
+		if (d->state == BT_CLOSED) {
+			sk->sk_zapped = 1;
+			bt_accept_unlink(sk);
+		}
+		parent->sk_data_ready(parent, 0);
+	} else {
 		if (d->state == BT_CONNECTED)
 			rfcomm_session_getaddr(d->session, &bt_sk(sk)->src, NULL);
 		sk->sk_state_change(sk);
-	} else
-		parent->sk_data_ready(parent, 0);
+	}
 
 	bh_unlock_sock(sk);
+
+	if (parent && sk->sk_zapped)
+		rfcomm_sock_kill(sk);
 }
 
 /* ---- Socket functions ---- */
diff -Nru a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
--- a/net/bluetooth/rfcomm/tty.c	2004-12-24 13:36:55 -08:00
+++ b/net/bluetooth/rfcomm/tty.c	2004-12-24 13:36:55 -08:00
@@ -645,32 +645,26 @@
 	rfcomm_dev_put(dev);
 }
 
-static int rfcomm_tty_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
+static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 	struct rfcomm_dlc *dlc = dev->dlc;
 	struct sk_buff *skb;
 	int err = 0, sent = 0, size;
 
-	BT_DBG("tty %p from_user %d count %d", tty, from_user, count);
+	BT_DBG("tty %p count %d", tty, count);
 
 	while (count) {
 		size = min_t(uint, count, dlc->mtu);
 
-		if (from_user)
-			skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_KERNEL);
-		else
-			skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_ATOMIC);
+		skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_ATOMIC);
 		
 		if (!skb)
 			break;
 
 		skb_reserve(skb, RFCOMM_SKB_HEAD_RESERVE);
 
-		if (from_user)
-			copy_from_user(skb_put(skb, size), buf + sent, size);
-		else
-			memcpy(skb_put(skb, size), buf + sent, size);
+		memcpy(skb_put(skb, size), buf + sent, size);
 
 		if ((err = rfcomm_dlc_send(dlc, skb)) < 0) {
 			kfree_skb(skb);
diff -Nru a/net/bridge/br_if.c b/net/bridge/br_if.c
--- a/net/bridge/br_if.c	2004-12-24 13:37:30 -08:00
+++ b/net/bridge/br_if.c	2004-12-24 13:37:30 -08:00
@@ -147,9 +147,9 @@
 	br = netdev_priv(dev);
 	br->dev = dev;
 
-	br->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&br->lock);
 	INIT_LIST_HEAD(&br->port_list);
-	br->hash_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&br->hash_lock);
 
 	br->bridge_id.prio[0] = 0x80;
 	br->bridge_id.prio[1] = 0x00;
diff -Nru a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
--- a/net/bridge/br_netfilter.c	2004-12-24 13:37:29 -08:00
+++ b/net/bridge/br_netfilter.c	2004-12-24 13:37:29 -08:00
@@ -197,7 +197,7 @@
 		skb_pull(skb, VLAN_HLEN);
 		skb->nh.raw += VLAN_HLEN;
 	}
-	skb->dst->output(&skb);
+	skb->dst->output(skb);
 	return 0;
 }
 
diff -Nru a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
--- a/net/bridge/netfilter/ebtables.c	2004-12-24 13:36:47 -08:00
+++ b/net/bridge/netfilter/ebtables.c	2004-12-24 13:36:47 -08:00
@@ -109,11 +109,17 @@
 
 static inline int ebt_dev_check(char *entry, const struct net_device *device)
 {
+	int i = 0;
+	char *devname = device->name;
+
 	if (*entry == '\0')
 		return 0;
 	if (!device)
 		return 1;
-	return !!strcmp(entry, device->name);
+	/* 1 is the wildcard token */
+	while (entry[i] != '\0' && entry[i] != 1 && entry[i] == devname[i])
+		i++;
+	return (devname[i] != entry[i] && entry[i] != 1);
 }
 
 #define FWINV2(bool,invflg) ((bool) ^ !!(e->invflags & invflg))
@@ -1162,7 +1168,7 @@
 	}
 
 	table->private = newinfo;
-	table->lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&table->lock);
 	ret = down_interruptible(&ebt_mutex);
 	if (ret != 0)
 		goto free_chainstack;
diff -Nru a/net/compat.c b/net/compat.c
--- a/net/compat.c	2004-12-24 13:37:00 -08:00
+++ b/net/compat.c	2004-12-24 13:37:00 -08:00
@@ -22,6 +22,7 @@
 #include <linux/filter.h>
 #include <linux/compat.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/security.h>
 
 #include <net/scm.h>
 #include <net/sock.h>
@@ -123,6 +124,12 @@
 	 (struct compat_cmsghdr __user *)((msg)->msg_control) :		\
 	 (struct compat_cmsghdr __user *)NULL)
 
+#define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
+	((ucmlen) >= sizeof(struct cmsghdr) && \
+	 (ucmlen) <= (unsigned long) \
+	 ((mhdr)->msg_controllen - \
+	  ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
+
 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
 		struct compat_cmsghdr __user *cmsg, int cmsg_len)
 {
@@ -153,11 +160,7 @@
 			return -EFAULT;
 
 		/* Catch bogons. */
-		if(CMSG_COMPAT_ALIGN(ucmlen) <
-		   CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)))
-			return -EINVAL;
-		if((unsigned long)(((char __user *)ucmsg - (char __user *)kmsg->msg_control)
-				   + ucmlen) > kmsg->msg_controllen)
+		if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg))
 			return -EINVAL;
 
 		tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) +
@@ -264,6 +267,9 @@
 
 	for (i = 0, cmfptr = (int __user *) CMSG_COMPAT_DATA(cm); i < fdmax; i++, cmfptr++) {
 		int new_fd;
+		err = security_file_receive(fp[i]);
+		if (err)
+			break;
 		err = get_unused_fd();
 		if (err < 0)
 			break;
diff -Nru a/net/core/dev.c b/net/core/dev.c
--- a/net/core/dev.c	2004-12-24 13:36:54 -08:00
+++ b/net/core/dev.c	2004-12-24 13:36:54 -08:00
@@ -74,7 +74,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/config.h>
 #include <linux/cpu.h>
 #include <linux/types.h>
@@ -520,35 +520,6 @@
 	return dev;
 }
 
-/*
-   Return value is changed to int to prevent illegal usage in future.
-   It is still legal to use to check for device existence.
-
-   User should understand, that the result returned by this function
-   is meaningless, if it was not issued under rtnl semaphore.
- */
-
-/**
- *	dev_get	-	test if a device exists
- *	@name:	name to test for
- *
- *	Test if a name exists. Returns true if the name is found. In order
- *	to be sure the name is not allocated or removed during the test the
- *	caller must hold the rtnl semaphore.
- *
- *	This function exists only for back compatibility with older
- *	drivers.
- */
-int __dev_get(const char *name)
-{
-	struct net_device *dev;
-
-	read_lock(&dev_base_lock);
-	dev = __dev_get_by_name(name);
-	read_unlock(&dev_base_lock);
-	return dev != NULL;
-}
-
 /**
  *	__dev_get_by_index - find a device by its ifindex
  *	@ifindex: index of device
@@ -623,26 +594,17 @@
 	return dev;
 }
 
-struct net_device *__dev_getfirstbyhwtype(unsigned short type)
-{
-	struct net_device *dev;
-
-	for (dev = dev_base; dev; dev = dev->next)
-		if (dev->type == type)
-			break;
-	return dev;
-}
-
-EXPORT_SYMBOL(__dev_getfirstbyhwtype);
-
 struct net_device *dev_getfirstbyhwtype(unsigned short type)
 {
 	struct net_device *dev;
 
 	rtnl_lock();
-	dev = __dev_getfirstbyhwtype(type);
-	if (dev)
-		dev_hold(dev);
+	for (dev = dev_base; dev; dev = dev->next) {
+		if (dev->type == type) {
+			dev_hold(dev);
+			break;
+		}
+	}
 	rtnl_unlock();
 	return dev;
 }
@@ -665,32 +627,14 @@
 	struct net_device *dev;
 
 	read_lock(&dev_base_lock);
-	dev = __dev_get_by_flags(if_flags, mask);
-	if (dev)
-		dev_hold(dev);
-	read_unlock(&dev_base_lock);
-	return dev;
-}
-
-/**
- *	__dev_get_by_flags - find any device with given flags
- *	@if_flags: IFF_* values
- *	@mask: bitmask of bits in if_flags to check
- *
- *	Search for any interface with the given flags. Returns NULL if a device
- *	is not found or a pointer to the device. The caller must hold either
- *	the RTNL semaphore or @dev_base_lock.
- */
-
-struct net_device *__dev_get_by_flags(unsigned short if_flags, unsigned short mask)
-{
-	struct net_device *dev;
-
 	for (dev = dev_base; dev != NULL; dev = dev->next) {
-		if (((dev->flags ^ if_flags) & mask) == 0)
-			return dev;
+		if (((dev->flags ^ if_flags) & mask) == 0) {
+			dev_hold(dev);
+			break;
+		}
 	}
-	return NULL;
+	read_unlock(&dev_base_lock);
+	return dev;
 }
 
 /**
@@ -1057,6 +1001,29 @@
 	return notifier_call_chain(&netdev_chain, val, v);
 }
 
+/* When > 0 there are consumers of rx skb time stamps */
+static atomic_t netstamp_needed = ATOMIC_INIT(0);
+
+void net_enable_timestamp(void)
+{
+	atomic_inc(&netstamp_needed);
+}
+
+void net_disable_timestamp(void)
+{
+	atomic_dec(&netstamp_needed);
+}
+
+static inline void net_timestamp(struct timeval *stamp)
+{
+	if (atomic_read(&netstamp_needed))
+		do_gettimeofday(stamp);
+	else {
+		stamp->tv_sec = 0;
+		stamp->tv_usec = 0;
+	}
+}
+
 /*
  *	Support routine. Sends outgoing frames to any network
  *	taps currently in use.
@@ -1106,34 +1073,34 @@
  * Invalidate hardware checksum when packet is to be mangled, and
  * complete checksum manually on outgoing path.
  */
-int skb_checksum_help(struct sk_buff **pskb, int inward)
+int skb_checksum_help(struct sk_buff *skb, int inward)
 {
 	unsigned int csum;
-	int ret = 0, offset = (*pskb)->h.raw - (*pskb)->data;
+	int ret = 0, offset = skb->h.raw - skb->data;
 
 	if (inward) {
-		(*pskb)->ip_summed = CHECKSUM_NONE;
+		skb->ip_summed = CHECKSUM_NONE;
 		goto out;
 	}
 
-	if (skb_cloned(*pskb)) {
-		ret = pskb_expand_head(*pskb, 0, 0, GFP_ATOMIC);
+	if (skb_cloned(skb)) {
+		ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
 		if (ret)
 			goto out;
 	}
 
-	if (offset > (int)(*pskb)->len)
+	if (offset > (int)skb->len)
 		BUG();
-	csum = skb_checksum(*pskb, offset, (*pskb)->len-offset, 0);
+	csum = skb_checksum(skb, offset, skb->len-offset, 0);
 
-	offset = (*pskb)->tail - (*pskb)->h.raw;
+	offset = skb->tail - skb->h.raw;
 	if (offset <= 0)
 		BUG();
-	if ((*pskb)->csum + 2 > offset)
+	if (skb->csum + 2 > offset)
 		BUG();
 
-	*(u16*)((*pskb)->h.raw + (*pskb)->csum) = csum_fold(csum);
-	(*pskb)->ip_summed = CHECKSUM_NONE;
+	*(u16*)(skb->h.raw + skb->csum) = csum_fold(csum);
+	skb->ip_summed = CHECKSUM_NONE;
 out:	
 	return ret;
 }
@@ -1235,13 +1202,6 @@
 	}						\
 }
 
-static inline void qdisc_run(struct net_device *dev)
-{
-	while (!netif_queue_stopped(dev) &&
-	       qdisc_restart(dev)<0)
-		/* NOTHING */;
-}
-
 /**
  *	dev_queue_xmit - transmit a buffer
  *	@skb: buffer to transmit
@@ -1282,10 +1242,9 @@
 	    (!(dev->features & (NETIF_F_HW_CSUM | NETIF_F_NO_CSUM)) &&
 	     (!(dev->features & NETIF_F_IP_CSUM) ||
 	      skb->protocol != htons(ETH_P_IP))))
-	      	if (skb_checksum_help(&skb, 0))
+	      	if (skb_checksum_help(skb, 0))
 	      		goto out_kfree_skb;
 
-
 	/* Disable soft irqs for various locks below. Also 
 	 * stops preemption for RCU. 
 	 */
@@ -1353,7 +1312,6 @@
 			if (net_ratelimit())
 				printk(KERN_CRIT "Virtual device %s asks to "
 				       "queue packet!\n", dev->name);
-			goto out_enetdown;
 		} else {
 			/* Recursion is detected! It is possible,
 			 * unfortunately */
@@ -1362,10 +1320,13 @@
 				       "%s, fix it urgently!\n", dev->name);
 		}
 	}
-out_enetdown:
+
 	rc = -ENETDOWN;
+	local_bh_enable();
+
 out_kfree_skb:
 	kfree_skb(skb);
+	return rc;
 out:
 	local_bh_enable();
 	return rc;
@@ -1390,66 +1351,6 @@
 DEFINE_PER_CPU(struct netif_rx_stats, netdev_rx_stat) = { 0, };
 
 
-#ifdef CONFIG_NET_HW_FLOWCONTROL
-atomic_t netdev_dropping = ATOMIC_INIT(0);
-static unsigned long netdev_fc_mask = 1;
-unsigned long netdev_fc_xoff;
-spinlock_t netdev_fc_lock = SPIN_LOCK_UNLOCKED;
-
-static struct
-{
-	void (*stimul)(struct net_device *);
-	struct net_device *dev;
-} netdev_fc_slots[BITS_PER_LONG];
-
-int netdev_register_fc(struct net_device *dev,
-		       void (*stimul)(struct net_device *dev))
-{
-	int bit = 0;
-	unsigned long flags;
-
-	spin_lock_irqsave(&netdev_fc_lock, flags);
-	if (netdev_fc_mask != ~0UL) {
-		bit = ffz(netdev_fc_mask);
-		netdev_fc_slots[bit].stimul = stimul;
-		netdev_fc_slots[bit].dev = dev;
-		set_bit(bit, &netdev_fc_mask);
-		clear_bit(bit, &netdev_fc_xoff);
-	}
-	spin_unlock_irqrestore(&netdev_fc_lock, flags);
-	return bit;
-}
-
-void netdev_unregister_fc(int bit)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&netdev_fc_lock, flags);
-	if (bit > 0) {
-		netdev_fc_slots[bit].stimul = NULL;
-		netdev_fc_slots[bit].dev = NULL;
-		clear_bit(bit, &netdev_fc_mask);
-		clear_bit(bit, &netdev_fc_xoff);
-	}
-	spin_unlock_irqrestore(&netdev_fc_lock, flags);
-}
-
-static void netdev_wakeup(void)
-{
-	unsigned long xoff;
-
-	spin_lock(&netdev_fc_lock);
-	xoff = netdev_fc_xoff;
-	netdev_fc_xoff = 0;
-	while (xoff) {
-		int i = ffz(~xoff);
-		xoff &= ~(1 << i);
-		netdev_fc_slots[i].stimul(netdev_fc_slots[i].dev);
-	}
-	spin_unlock(&netdev_fc_lock);
-}
-#endif
-
 static void get_sample_stats(int cpu)
 {
 #ifdef RAND_LIE
@@ -1559,13 +1460,8 @@
 			return queue->cng_level;
 		}
 
-		if (queue->throttle) {
+		if (queue->throttle)
 			queue->throttle = 0;
-#ifdef CONFIG_NET_HW_FLOWCONTROL
-			if (atomic_dec_and_test(&netdev_dropping))
-				netdev_wakeup();
-#endif
-		}
 
 		netif_rx_schedule(&queue->backlog_dev);
 		goto enqueue;
@@ -1574,9 +1470,6 @@
 	if (!queue->throttle) {
 		queue->throttle = 1;
 		__get_cpu_var(netdev_rx_stat).throttled++;
-#ifdef CONFIG_NET_HW_FLOWCONTROL
-		atomic_inc(&netdev_dropping);
-#endif
 	}
 
 drop:
@@ -1587,6 +1480,21 @@
 	return NET_RX_DROP;
 }
 
+int netif_rx_ni(struct sk_buff *skb)
+{
+	int err;
+
+	preempt_disable();
+	err = netif_rx(skb);
+	if (softirq_pending(smp_processor_id()))
+		do_softirq();
+	preempt_enable();
+
+	return err;
+}
+
+EXPORT_SYMBOL(netif_rx_ni);
+
 static __inline__ void skb_bond(struct sk_buff *skb)
 {
 	struct net_device *dev = skb->dev;
@@ -1833,16 +1741,6 @@
 		if (work >= quota || jiffies - start_time > 1)
 			break;
 
-#ifdef CONFIG_NET_HW_FLOWCONTROL
-		if (queue->throttle &&
-		    queue->input_pkt_queue.qlen < no_cong_thresh ) {
-			queue->throttle = 0;
-			if (atomic_dec_and_test(&netdev_dropping)) {
-				netdev_wakeup();
-				break;
-			}
-		}
-#endif
 	}
 
 	backlog_dev->quota -= work;
@@ -1857,13 +1755,8 @@
 	smp_mb__before_clear_bit();
 	netif_poll_enable(backlog_dev);
 
-	if (queue->throttle) {
+	if (queue->throttle)
 		queue->throttle = 0;
-#ifdef CONFIG_NET_HW_FLOWCONTROL
-		if (atomic_dec_and_test(&netdev_dropping))
-			netdev_wakeup();
-#endif
-	}
 	local_irq_enable();
 	return 0;
 }
@@ -2443,8 +2336,11 @@
 			return dev_set_mtu(dev, ifr->ifr_mtu);
 
 		case SIOCGIFHWADDR:
-			memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr,
-			       min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
+			if (!dev->addr_len)
+				memset(ifr->ifr_hwaddr.sa_data, 0, sizeof ifr->ifr_hwaddr.sa_data);
+			else
+				memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr,
+				       min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
 			ifr->ifr_hwaddr.sa_family = dev->type;
 			return 0;
 
@@ -2745,7 +2641,7 @@
 				/* Follow me in net/core/wireless.c */
 				ret = wireless_process_ioctl(&ifr, cmd);
 				rtnl_unlock();
-				if (!ret && IW_IS_GET(cmd) &&
+				if (IW_IS_GET(cmd) &&
 				    copy_to_user(arg, &ifr,
 					    	 sizeof(struct ifreq)))
 					ret = -EFAULT;
@@ -2764,7 +2660,7 @@
  *	number.  The caller must hold the rtnl semaphore or the
  *	dev_base_lock to be sure it remains unique.
  */
-int dev_new_index(void)
+static int dev_new_index(void)
 {
 	static int ifindex;
 	for (;;) {
@@ -2871,6 +2767,14 @@
 		dev->features &= ~NETIF_F_SG;
 	}
 
+	/* TSO requires that SG is present as well. */
+	if ((dev->features & NETIF_F_TSO) &&
+	    !(dev->features & NETIF_F_SG)) {
+		printk("%s: Dropping NETIF_F_TSO since no SG feature.\n",
+		       dev->name);
+		dev->features &= ~NETIF_F_TSO;
+	}
+
 	/*
 	 *	nil rebuild_header routine,
 	 *	that should be never called and used as just bug trap.
@@ -3296,30 +3200,23 @@
 
 subsys_initcall(net_dev_init);
 
-EXPORT_SYMBOL(__dev_get);
-EXPORT_SYMBOL(__dev_get_by_flags);
 EXPORT_SYMBOL(__dev_get_by_index);
 EXPORT_SYMBOL(__dev_get_by_name);
 EXPORT_SYMBOL(__dev_remove_pack);
 EXPORT_SYMBOL(__skb_linearize);
-EXPORT_SYMBOL(call_netdevice_notifiers);
 EXPORT_SYMBOL(dev_add_pack);
 EXPORT_SYMBOL(dev_alloc_name);
 EXPORT_SYMBOL(dev_close);
 EXPORT_SYMBOL(dev_get_by_flags);
 EXPORT_SYMBOL(dev_get_by_index);
 EXPORT_SYMBOL(dev_get_by_name);
-EXPORT_SYMBOL(dev_getbyhwaddr);
 EXPORT_SYMBOL(dev_ioctl);
-EXPORT_SYMBOL(dev_new_index);
 EXPORT_SYMBOL(dev_open);
 EXPORT_SYMBOL(dev_queue_xmit);
-EXPORT_SYMBOL(dev_queue_xmit_nit);
 EXPORT_SYMBOL(dev_remove_pack);
 EXPORT_SYMBOL(dev_set_allmulti);
 EXPORT_SYMBOL(dev_set_promiscuity);
 EXPORT_SYMBOL(dev_change_flags);
-EXPORT_SYMBOL(dev_change_name);
 EXPORT_SYMBOL(dev_set_mtu);
 EXPORT_SYMBOL(free_netdev);
 EXPORT_SYMBOL(netdev_boot_setup_check);
@@ -3334,6 +3231,8 @@
 EXPORT_SYMBOL(synchronize_net);
 EXPORT_SYMBOL(unregister_netdevice);
 EXPORT_SYMBOL(unregister_netdevice_notifier);
+EXPORT_SYMBOL(net_enable_timestamp);
+EXPORT_SYMBOL(net_disable_timestamp);
 
 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
 EXPORT_SYMBOL(br_handle_frame_hook);
@@ -3341,12 +3240,6 @@
 
 #ifdef CONFIG_KMOD
 EXPORT_SYMBOL(dev_load);
-#endif
-#ifdef CONFIG_NET_HW_FLOWCONTROL
-EXPORT_SYMBOL(netdev_dropping);
-EXPORT_SYMBOL(netdev_fc_xoff);
-EXPORT_SYMBOL(netdev_register_fc);
-EXPORT_SYMBOL(netdev_unregister_fc);
 #endif
 
 #ifdef CONFIG_NET_CLS_ACT
diff -Nru a/net/core/dev_mcast.c b/net/core/dev_mcast.c
--- a/net/core/dev_mcast.c	2004-12-24 13:36:35 -08:00
+++ b/net/core/dev_mcast.c	2004-12-24 13:36:35 -08:00
@@ -25,7 +25,7 @@
 #include <linux/module.h> 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff -Nru a/net/core/dst.c b/net/core/dst.c
--- a/net/core/dst.c	2004-12-24 13:37:00 -08:00
+++ b/net/core/dst.c	2004-12-24 13:37:00 -08:00
@@ -19,8 +19,6 @@
 
 #include <net/dst.h>
 
-const char dst_underflow_bug_msg[] = KERN_DEBUG "BUG: dst underflow %d: %p at %p\n";
-
 /* Locking strategy:
  * 1) Garbage collection state of dead destination cache
  *    entries is protected by dst_lock.
@@ -108,9 +106,9 @@
 	return 0;
 }
 
-static int dst_discard_out(struct sk_buff **pskb)
+static int dst_discard_out(struct sk_buff *skb)
 {
-	kfree_skb(*pskb);
+	kfree_skb(skb);
 	return 0;
 }
 
@@ -275,7 +273,6 @@
 	register_netdevice_notifier(&dst_dev_notifier);
 }
 
-EXPORT_SYMBOL(dst_underflow_bug_msg);
 EXPORT_SYMBOL(__dst_free);
 EXPORT_SYMBOL(dst_alloc);
 EXPORT_SYMBOL(dst_destroy);
diff -Nru a/net/core/ethtool.c b/net/core/ethtool.c
--- a/net/core/ethtool.c	2004-12-24 13:37:43 -08:00
+++ b/net/core/ethtool.c	2004-12-24 13:37:43 -08:00
@@ -452,9 +452,23 @@
 	return 0;
 }
 
+static int __ethtool_set_sg(struct net_device *dev, u32 data)
+{
+	int err;
+
+	if (!data && dev->ethtool_ops->set_tso) {
+		err = dev->ethtool_ops->set_tso(dev, 0);
+		if (err)
+			return err;
+	}
+
+	return dev->ethtool_ops->set_sg(dev, data);
+}
+
 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
 {
 	struct ethtool_value edata;
+	int err;
 
 	if (!dev->ethtool_ops->set_tx_csum)
 		return -EOPNOTSUPP;
@@ -462,6 +476,12 @@
 	if (copy_from_user(&edata, useraddr, sizeof(edata)))
 		return -EFAULT;
 
+	if (!edata.data && dev->ethtool_ops->set_sg) {
+		err = __ethtool_set_sg(dev, 0);
+		if (err)
+			return err;
+	}
+
 	return dev->ethtool_ops->set_tx_csum(dev, edata.data);
 }
 
@@ -489,7 +509,13 @@
 	if (copy_from_user(&edata, useraddr, sizeof(edata)))
 		return -EFAULT;
 
-	return dev->ethtool_ops->set_sg(dev, edata.data);
+	if (edata.data && 
+	    !(dev->features & (NETIF_F_IP_CSUM |
+			       NETIF_F_NO_CSUM |
+			       NETIF_F_HW_CSUM)))
+		return -EINVAL;
+
+	return __ethtool_set_sg(dev, edata.data);
 }
 
 static int ethtool_get_tso(struct net_device *dev, char __user *useraddr)
@@ -515,6 +541,9 @@
 
 	if (copy_from_user(&edata, useraddr, sizeof(edata)))
 		return -EFAULT;
+
+	if (edata.data && !(dev->features & NETIF_F_SG))
+		return -EINVAL;
 
 	return dev->ethtool_ops->set_tso(dev, edata.data);
 }
diff -Nru a/net/core/gen_estimator.c b/net/core/gen_estimator.c
--- a/net/core/gen_estimator.c	2004-12-24 13:37:00 -08:00
+++ b/net/core/gen_estimator.c	2004-12-24 13:37:00 -08:00
@@ -132,6 +132,21 @@
 	read_unlock(&est_lock);
 }
 
+/**
+ * gen_new_estimator - create a new rate estimator
+ * @bstats: basic statistics
+ * @rate_est: rate estimator statistics
+ * @stats_lock: statistics lock
+ * @opt: rate estimator configuration TLV
+ *
+ * Creates a new rate estimator with &bstats as source and &rate_est
+ * as destination. A new timer with the interval specified in the
+ * configuration TLV is created. Upon each interval, the latest statistics
+ * will be read from &bstats and the estimated rate will be stored in
+ * &rate_est with the statistics lock grabed during this period.
+ * 
+ * Returns 0 on success or a negative error code.
+ */
 int gen_new_estimator(struct gnet_stats_basic *bstats,
 	struct gnet_stats_rate_est *rate_est, spinlock_t *stats_lock, struct rtattr *opt)
 {
@@ -173,6 +188,14 @@
 	return 0;
 }
 
+/**
+ * gen_kill_estimator - remove a rate estimator
+ * @bstats: basic statistics
+ * @rate_est: rate estimator statistics
+ *
+ * Removes the rate estimator specified by &bstats and &rate_est
+ * and deletes the timer.
+ */
 void gen_kill_estimator(struct gnet_stats_basic *bstats,
 	struct gnet_stats_rate_est *rate_est)
 {
@@ -200,5 +223,28 @@
 	}
 }
 
+/**
+ * gen_replace_estimator - replace rate estimator configruation
+ * @bstats: basic statistics
+ * @rate_est: rate estimator statistics
+ * @stats_lock: statistics lock
+ * @opt: rate estimator configuration TLV
+ *
+ * Replaces the configuration of a rate estimator by calling
+ * gen_kill_estimator() and gen_new_estimator().
+ * 
+ * Returns 0 on success or a negative error code.
+ */
+int
+gen_replace_estimator(struct gnet_stats_basic *bstats,
+	struct gnet_stats_rate_est *rate_est, spinlock_t *stats_lock,
+	struct rtattr *opt)
+{
+    gen_kill_estimator(bstats, rate_est);
+    return gen_new_estimator(bstats, rate_est, stats_lock, opt);
+}
+    
+
 EXPORT_SYMBOL(gen_kill_estimator);
 EXPORT_SYMBOL(gen_new_estimator);
+EXPORT_SYMBOL(gen_replace_estimator);
diff -Nru a/net/core/gen_stats.c b/net/core/gen_stats.c
--- a/net/core/gen_stats.c	2004-12-24 13:37:19 -08:00
+++ b/net/core/gen_stats.c	2004-12-24 13:37:19 -08:00
@@ -34,6 +34,24 @@
 	return -1;
 }
 
+/**
+ * gnet_stats_start_copy_compat - start dumping procedure in compatibility mode
+ * @skb: socket buffer to put statistics TLVs into
+ * @type: TLV type for top level statistic TLV
+ * @tc_stats_type: TLV type for backward compatibility struct tc_stats TLV
+ * @xstats_type: TLV type for backward compatibility xstats TLV
+ * @lock: statistics lock
+ * @d: dumping handle
+ *
+ * Initializes the dumping handle, grabs the statistic lock and appends
+ * an empty TLV header to the socket buffer for use a container for all
+ * other statistic TLVS.
+ *
+ * The dumping handle is marked to be in backward compatibility mode telling
+ * all gnet_stats_copy_XXX() functions to fill a local copy of struct tc_stats.
+ *
+ * Returns 0 on success or -1 if the room in the socket buffer was not sufficient.
+ */
 int
 gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
 	int xstats_type, spinlock_t *lock, struct gnet_dump *d)
@@ -52,6 +70,19 @@
 	return gnet_stats_copy(d, type, NULL, 0);
 }
 
+/**
+ * gnet_stats_start_copy_compat - start dumping procedure in compatibility mode
+ * @skb: socket buffer to put statistics TLVs into
+ * @type: TLV type for top level statistic TLV
+ * @lock: statistics lock
+ * @d: dumping handle
+ *
+ * Initializes the dumping handle, grabs the statistic lock and appends
+ * an empty TLV header to the socket buffer for use a container for all
+ * other statistic TLVS.
+ *
+ * Returns 0 on success or -1 if the room in the socket buffer was not sufficient.
+ */
 int
 gnet_stats_start_copy(struct sk_buff *skb, int type, spinlock_t *lock,
 	struct gnet_dump *d)
@@ -59,7 +90,17 @@
 	return gnet_stats_start_copy_compat(skb, type, 0, 0, lock, d);
 }
 
-
+/**
+ * gnet_stats_copy_basic - copy basic statistics into statistic TLV
+ * @d: dumping handle
+ * @b: basic statistics
+ *
+ * Appends the basic statistics to the top level TLV created by
+ * gnet_stats_start_copy().
+ *
+ * Returns 0 on success or -1 with the statistic lock released
+ * if the room in the socket buffer was not sufficient.
+ */
 int
 gnet_stats_copy_basic(struct gnet_dump *d, struct gnet_stats_basic *b)
 {
@@ -71,6 +112,17 @@
 	return gnet_stats_copy(d, TCA_STATS_BASIC, b, sizeof(*b));
 }
 
+/**
+ * gnet_stats_copy_rate_est - copy rate estimator statistics into statistics TLV
+ * @d: dumping handle
+ * @r: rate estimator statistics
+ *
+ * Appends the rate estimator statistics to the top level TLV created by
+ * gnet_stats_start_copy().
+ *
+ * Returns 0 on success or -1 with the statistic lock released
+ * if the room in the socket buffer was not sufficient.
+ */
 int
 gnet_stats_copy_rate_est(struct gnet_dump *d, struct gnet_stats_rate_est *r)
 {
@@ -82,6 +134,17 @@
 	return gnet_stats_copy(d, TCA_STATS_RATE_EST, r, sizeof(*r));
 }
 
+/**
+ * gnet_stats_copy_queue - copy queue statistics into statistics TLV
+ * @d: dumping handle
+ * @q: queue statistics
+ *
+ * Appends the queue statistics to the top level TLV created by
+ * gnet_stats_start_copy().
+ *
+ * Returns 0 on success or -1 with the statistic lock released
+ * if the room in the socket buffer was not sufficient.
+ */
 int
 gnet_stats_copy_queue(struct gnet_dump *d, struct gnet_stats_queue *q)
 {
@@ -95,6 +158,19 @@
 	return gnet_stats_copy(d, TCA_STATS_QUEUE, q, sizeof(*q));
 }
 
+/**
+ * gnet_stats_copy_app - copy application specific statistics into statistics TLV
+ * @d: dumping handle
+ * @st: application specific statistics data
+ * @len: length of data
+ *
+ * Appends the application sepecific statistics to the top level TLV created by
+ * gnet_stats_start_copy() and remembers the data for XSTATS if the dumping
+ * handle is in backward compatibility mode.
+ *
+ * Returns 0 on success or -1 with the statistic lock released
+ * if the room in the socket buffer was not sufficient.
+ */
 int
 gnet_stats_copy_app(struct gnet_dump *d, void *st, int len)
 {
@@ -103,6 +179,18 @@
 	return gnet_stats_copy(d, TCA_STATS_APP, st, len);
 }
 
+/**
+ * gnet_stats_finish_copy - finish dumping procedure
+ * @d: dumping handle
+ *
+ * Corrects the length of the top level TLV to include all TLVs added
+ * by gnet_stats_copy_XXX() calls. Adds the backward compatibility TLVs
+ * if gnet_stats_start_copy_compat() was used and releases the statistics
+ * lock.
+ *
+ * Returns 0 on success or -1 with the statistic lock released
+ * if the room in the socket buffer was not sufficient.
+ */
 int
 gnet_stats_finish_copy(struct gnet_dump *d)
 {
@@ -125,6 +213,7 @@
 
 
 EXPORT_SYMBOL(gnet_stats_start_copy);
+EXPORT_SYMBOL(gnet_stats_start_copy_compat);
 EXPORT_SYMBOL(gnet_stats_copy_basic);
 EXPORT_SYMBOL(gnet_stats_copy_rate_est);
 EXPORT_SYMBOL(gnet_stats_copy_queue);
diff -Nru a/net/core/link_watch.c b/net/core/link_watch.c
--- a/net/core/link_watch.c	2004-12-24 13:36:16 -08:00
+++ b/net/core/link_watch.c	2004-12-24 13:36:16 -08:00
@@ -22,7 +22,7 @@
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/types.h>
 
 
diff -Nru a/net/core/neighbour.c b/net/core/neighbour.c
--- a/net/core/neighbour.c	2004-12-24 13:36:17 -08:00
+++ b/net/core/neighbour.c	2004-12-24 13:36:17 -08:00
@@ -59,7 +59,6 @@
 static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
 void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
 
-static int neigh_glbl_allocs;
 static struct neigh_table *neigh_tables;
 static struct file_operations neigh_stat_seq_fops;
 
@@ -254,23 +253,25 @@
 {
 	struct neighbour *n = NULL;
 	unsigned long now = jiffies;
+	int entries;
 
-	if (tbl->entries > tbl->gc_thresh3 ||
-	    (tbl->entries > tbl->gc_thresh2 &&
+	entries = atomic_inc_return(&tbl->entries) - 1;
+	if (entries >= tbl->gc_thresh3 ||
+	    (entries >= tbl->gc_thresh2 &&
 	     time_after(now, tbl->last_flush + 5 * HZ))) {
 		if (!neigh_forced_gc(tbl) &&
-		    tbl->entries > tbl->gc_thresh3)
-			goto out;
+		    entries >= tbl->gc_thresh3)
+			goto out_entries;
 	}
 
 	n = kmem_cache_alloc(tbl->kmem_cachep, SLAB_ATOMIC);
 	if (!n)
-		goto out;
+		goto out_entries;
 
 	memset(n, 0, tbl->entry_size);
 
 	skb_queue_head_init(&n->arp_queue);
-	n->lock		  = RW_LOCK_UNLOCKED;
+	rwlock_init(&n->lock);
 	n->updated	  = n->used = now;
 	n->nud_state	  = NUD_NONE;
 	n->output	  = neigh_blackhole;
@@ -280,13 +281,15 @@
 	n->timer.data	  = (unsigned long)n;
 
 	NEIGH_CACHE_STAT_INC(tbl, allocs);
-	neigh_glbl_allocs++;
-	tbl->entries++;
 	n->tbl		  = tbl;
 	atomic_set(&n->refcnt, 1);
 	n->dead		  = 1;
 out:
 	return n;
+
+out_entries:
+	atomic_dec(&tbl->entries);
+	goto out;
 }
 
 static struct neighbour **neigh_hash_alloc(unsigned int entries)
@@ -427,7 +430,7 @@
 
 	write_lock_bh(&tbl->lock);
 
-	if (tbl->entries > (tbl->hash_mask + 1))
+	if (atomic_read(&tbl->entries) > (tbl->hash_mask + 1))
 		neigh_hash_grow(tbl, (tbl->hash_mask + 1) << 1);
 
 	hash_val = tbl->hash(pkey, dev) & tbl->hash_mask;
@@ -607,8 +610,7 @@
 
 	NEIGH_PRINTK2("neigh %p is destroyed.\n", neigh);
 
-	neigh_glbl_allocs--;
-	neigh->tbl->entries--;
+	atomic_dec(&neigh->tbl->entries);
 	kmem_cache_free(neigh->tbl->kmem_cachep, neigh);
 }
 
@@ -1089,7 +1091,7 @@
 
 	if (!hh && (hh = kmalloc(sizeof(*hh), GFP_ATOMIC)) != NULL) {
 		memset(hh, 0, sizeof(struct hh_cache));
-		hh->hh_lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&hh->hh_lock);
 		hh->hh_type = protocol;
 		atomic_set(&hh->hh_refcnt, 0);
 		hh->hh_next = NULL;
@@ -1365,7 +1367,7 @@
 
 	get_random_bytes(&tbl->hash_rnd, sizeof(tbl->hash_rnd));
 
-	tbl->lock	       = RW_LOCK_UNLOCKED;
+	rwlock_init(&tbl->lock);
 	init_timer(&tbl->gc_timer);
 	tbl->gc_timer.data     = (unsigned long)tbl;
 	tbl->gc_timer.function = neigh_periodic_timer;
@@ -1394,7 +1396,7 @@
 	del_timer_sync(&tbl->proxy_timer);
 	pneigh_queue_purge(&tbl->proxy_queue);
 	neigh_ifdown(tbl, NULL);
-	if (tbl->entries)
+	if (atomic_read(&tbl->entries))
 		printk(KERN_CRIT "neighbour leakage\n");
 	write_lock(&neigh_tbl_lock);
 	for (tp = &neigh_tables; *tp; tp = &(*tp)->next) {
@@ -1951,7 +1953,7 @@
 
 	seq_printf(seq, "%08x  %08lx %08lx %08lx  %08lx %08lx  %08lx  "
 			"%08lx %08lx  %08lx %08lx\n",
-		   tbl->entries,
+		   atomic_read(&tbl->entries),
 
 		   st->allocs,
 		   st->destroys,
diff -Nru a/net/core/net-sysfs.c b/net/core/net-sysfs.c
--- a/net/core/net-sysfs.c	2004-12-24 13:37:19 -08:00
+++ b/net/core/net-sysfs.c	2004-12-24 13:37:19 -08:00
@@ -126,8 +126,18 @@
 	return -EINVAL;
 }
 
+static ssize_t show_carrier(struct class_device *dev, char *buf)
+{
+	struct net_device *netdev = to_net_dev(dev);
+	if (netif_running(netdev)) {
+		return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
+	}
+	return -EINVAL;
+}
+
 static CLASS_DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
 static CLASS_DEVICE_ATTR(broadcast, S_IRUGO, show_broadcast, NULL);
+static CLASS_DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL);
 
 /* read-write attributes */
 NETDEVICE_SHOW(mtu, fmt_dec);
@@ -186,6 +196,7 @@
 	&class_device_attr_type,
 	&class_device_attr_address,
 	&class_device_attr_broadcast,
+	&class_device_attr_carrier,
 	NULL
 };
 
diff -Nru a/net/core/netfilter.c b/net/core/netfilter.c
--- a/net/core/netfilter.c	2004-12-24 13:36:48 -08:00
+++ b/net/core/netfilter.c	2004-12-24 13:36:48 -08:00
@@ -673,6 +673,7 @@
 
 	return 0;
 }
+EXPORT_SYMBOL(ip_route_me_harder);
 
 int skb_ip_make_writable(struct sk_buff **pskb, unsigned int writable_len)
 {
@@ -751,10 +752,9 @@
 
 	/* Any setup of logging members must be done before
 	 * substituting pointer. */
-	smp_wmb();
 	spin_lock(&nf_log_lock);
 	if (!nf_logging[pf]) {
-		nf_logging[pf] = logfn;
+		rcu_assign_pointer(nf_logging[pf], logfn);
 		ret = 0;
 	}
 	spin_unlock(&nf_log_lock);
@@ -802,12 +802,21 @@
 EXPORT_SYMBOL(nf_log_unregister);
 EXPORT_SYMBOL(nf_log_packet);
 
-/* This does not belong here, but ipt_REJECT needs it if connection
-   tracking in use: without this, connection may not be in hash table,
-   and hence manufactured ICMP or RST packets will not be associated
-   with it. */
+/* This does not belong here, but locally generated errors need it if connection
+   tracking in use: without this, connection may not be in hash table, and hence
+   manufactured ICMP or RST packets will not be associated with it. */
 void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *);
 
+void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb)
+{
+	void (*attach)(struct sk_buff *, struct sk_buff *);
+
+	if (skb->nfct && (attach = ip_ct_attach) != NULL) {
+		mb(); /* Just to be sure: must be read before executing this */
+		attach(new, skb);
+	}
+}
+
 void __init netfilter_init(void)
 {
 	int i, h;
@@ -819,7 +828,7 @@
 }
 
 EXPORT_SYMBOL(ip_ct_attach);
-EXPORT_SYMBOL(ip_route_me_harder);
+EXPORT_SYMBOL(nf_ct_attach);
 EXPORT_SYMBOL(nf_getsockopt);
 EXPORT_SYMBOL(nf_hook_slow);
 EXPORT_SYMBOL(nf_hooks);
diff -Nru a/net/core/netpoll.c b/net/core/netpoll.c
--- a/net/core/netpoll.c	2004-12-24 13:37:29 -08:00
+++ b/net/core/netpoll.c	2004-12-24 13:37:29 -08:00
@@ -565,7 +565,7 @@
 		goto release;
 	}
 
-	if (!(ndev->flags & IFF_UP)) {
+	if (!netif_running(ndev)) {
 		unsigned short oflags;
 		unsigned long atmost, atleast;
 
@@ -611,7 +611,7 @@
 		rcu_read_lock();
 		in_dev = __in_dev_get(ndev);
 
-		if (!in_dev) {
+		if (!in_dev || !in_dev->ifa_list) {
 			rcu_read_unlock();
 			printk(KERN_ERR "%s: no IP address for %s, aborting\n",
 			       np->name, np->dev_name);
diff -Nru a/net/core/pktgen.c b/net/core/pktgen.c
--- a/net/core/pktgen.c	2004-12-24 13:37:01 -08:00
+++ b/net/core/pktgen.c	2004-12-24 13:37:01 -08:00
@@ -69,13 +69,12 @@
 #include <linux/ioport.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/inet.h>
 #include <linux/rcupdate.h>
+#include <linux/bitops.h>
 #include <asm/byteorder.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/uaccess.h>
@@ -603,8 +602,10 @@
 	do_div(idle, cpu_speed);
 
 	p += sprintf(p, "OK: %llu(c%llu+d%lu) usec, %llu (%dbyte,%dfrags)\n",
-		     total, total - idle, idle,
-		     info->sofar, size, nr_frags);
+		     (unsigned long long) total,
+		     (unsigned long long) (total - idle), idle,
+		     (unsigned long long) info->sofar,
+		     size, nr_frags);
 
 	pps = info->sofar * USEC_PER_SEC;
 	
@@ -620,7 +621,10 @@
 	mbps = bps;
 	do_div(mbps, 1000000);
 	p += sprintf(p, "  %llupps %lluMb/sec (%llubps) errors: %llu",
-		     pps, mbps, bps, info->errors);
+		     (unsigned long long) pps,
+		     (unsigned long long) mbps,
+		     (unsigned long long) bps,
+		     (unsigned long long) info->errors);
 }
 
 static void inject(struct pktgen_info* info)
@@ -643,6 +647,7 @@
 	info->do_run_run = 1; /* Cranke yeself! */
 	info->idle_acc = 0;
 	info->sofar = 0;
+	info->errors = 0;
 	lcount = info->count;
 
 
diff -Nru a/net/core/scm.c b/net/core/scm.c
--- a/net/core/scm.c	2004-12-24 13:36:47 -08:00
+++ b/net/core/scm.c	2004-12-24 13:36:47 -08:00
@@ -127,9 +127,7 @@
 		   for too short ancillary data object at all! Oops.
 		   OK, let's add it...
 		 */
-		if (cmsg->cmsg_len < sizeof(struct cmsghdr) ||
-		    (unsigned long)(((char*)cmsg - (char*)msg->msg_control)
-				    + cmsg->cmsg_len) > msg->msg_controllen)
+		if (!CMSG_OK(msg, cmsg))
 			goto error;
 
 		if (cmsg->cmsg_level != SOL_SOCKET)
diff -Nru a/net/core/skbuff.c b/net/core/skbuff.c
--- a/net/core/skbuff.c	2004-12-24 13:37:03 -08:00
+++ b/net/core/skbuff.c	2004-12-24 13:37:03 -08:00
@@ -394,6 +394,8 @@
 	new->tc_index	= old->tc_index;
 #endif
 	atomic_set(&new->users, 1);
+	skb_shinfo(new)->tso_size = skb_shinfo(old)->tso_size;
+	skb_shinfo(new)->tso_segs = skb_shinfo(old)->tso_segs;
 }
 
 /**
@@ -483,8 +485,6 @@
 		}
 		skb_shinfo(n)->nr_frags = i;
 	}
-	skb_shinfo(n)->tso_size = skb_shinfo(skb)->tso_size;
-	skb_shinfo(n)->tso_segs = skb_shinfo(skb)->tso_segs;
 
 	if (skb_shinfo(skb)->frag_list) {
 		skb_shinfo(n)->frag_list = skb_shinfo(skb)->frag_list;
@@ -631,8 +631,6 @@
 		BUG();
 
 	copy_skb_header(n, skb);
-	skb_shinfo(n)->tso_size = skb_shinfo(skb)->tso_size;
-	skb_shinfo(n)->tso_segs = skb_shinfo(skb)->tso_segs;
 
 	return n;
 }
@@ -1352,7 +1350,7 @@
 }
 #endif
 
-static void inline skb_split_inside_header(struct sk_buff *skb,
+static inline void skb_split_inside_header(struct sk_buff *skb,
 					   struct sk_buff* skb1,
 					   const u32 len, const int pos)
 {
@@ -1373,7 +1371,7 @@
 	skb->tail		   = skb->data + len;
 }
 
-static void inline skb_split_no_header(struct sk_buff *skb,
+static inline void skb_split_no_header(struct sk_buff *skb,
 				       struct sk_buff* skb1,
 				       const u32 len, int pos)
 {
diff -Nru a/net/core/sock.c b/net/core/sock.c
--- a/net/core/sock.c	2004-12-24 13:37:03 -08:00
+++ b/net/core/sock.c	2004-12-24 13:37:03 -08:00
@@ -175,6 +175,15 @@
 	}
 }
 
+static void sock_disable_timestamp(struct sock *sk)
+{	
+	if (sock_flag(sk, SOCK_TIMESTAMP)) { 
+		sock_reset_flag(sk, SOCK_TIMESTAMP);
+		net_disable_timestamp();
+	}
+}
+
+
 /*
  *	This is meant for all protocols to use and covers goings on
  *	at the socket level. Everything here is generic.
@@ -904,7 +913,7 @@
 	return sock_alloc_send_pskb(sk, size, 0, noblock, errcode);
 }
 
-void __lock_sock(struct sock *sk)
+static void __lock_sock(struct sock *sk)
 {
 	DEFINE_WAIT(wait);
 
@@ -920,7 +929,7 @@
 	finish_wait(&sk->sk_lock.wq, &wait);
 }
 
-void __release_sock(struct sock *sk)
+static void __release_sock(struct sock *sk)
 {
 	struct sk_buff *skb = sk->sk_backlog.head;
 
@@ -972,11 +981,6 @@
  * function, some default processing is provided.
  */
 
-int sock_no_release(struct socket *sock)
-{
-	return 0;
-}
-
 int sock_no_bind(struct socket *sock, struct sockaddr *saddr, int len)
 {
 	return -EOPNOTSUPP;
@@ -1171,8 +1175,8 @@
 	} else
 		sk->sk_sleep	=	NULL;
 
-	sk->sk_dst_lock		=	RW_LOCK_UNLOCKED;
-	sk->sk_callback_lock	=	RW_LOCK_UNLOCKED;
+	rwlock_init(&sk->sk_dst_lock);
+	rwlock_init(&sk->sk_callback_lock);
 
 	sk->sk_state_change	=	sock_def_wakeup;
 	sk->sk_data_ready	=	sock_def_readable;
@@ -1222,9 +1226,6 @@
 }
 EXPORT_SYMBOL(release_sock);
 
-/* When > 0 there are consumers of rx skb time stamps */
-atomic_t netstamp_needed = ATOMIC_INIT(0); 
-
 int sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
 { 
 	if (!sock_flag(sk, SOCK_TIMESTAMP))
@@ -1242,20 +1243,11 @@
 {	
 	if (!sock_flag(sk, SOCK_TIMESTAMP)) { 
 		sock_set_flag(sk, SOCK_TIMESTAMP);
-		atomic_inc(&netstamp_needed);
+		net_enable_timestamp();
 	}
 }
 EXPORT_SYMBOL(sock_enable_timestamp); 
 
-void sock_disable_timestamp(struct sock *sk)
-{	
-	if (sock_flag(sk, SOCK_TIMESTAMP)) { 
-		sock_reset_flag(sk, SOCK_TIMESTAMP);
-		atomic_dec(&netstamp_needed);
-	}
-}
-EXPORT_SYMBOL(sock_disable_timestamp);
-
 /*
  *	Get a socket option on an socket.
  *
@@ -1364,14 +1356,11 @@
 
 EXPORT_SYMBOL(sk_free_slab);
 
-EXPORT_SYMBOL(__lock_sock);
-EXPORT_SYMBOL(__release_sock);
 EXPORT_SYMBOL(sk_alloc);
 EXPORT_SYMBOL(sk_free);
 EXPORT_SYMBOL(sk_send_sigurg);
 EXPORT_SYMBOL(sock_alloc_send_pskb);
 EXPORT_SYMBOL(sock_alloc_send_skb);
-EXPORT_SYMBOL(sock_getsockopt);
 EXPORT_SYMBOL(sock_init_data);
 EXPORT_SYMBOL(sock_kfree_s);
 EXPORT_SYMBOL(sock_kmalloc);
@@ -1385,14 +1374,12 @@
 EXPORT_SYMBOL(sock_no_mmap);
 EXPORT_SYMBOL(sock_no_poll);
 EXPORT_SYMBOL(sock_no_recvmsg);
-EXPORT_SYMBOL(sock_no_release);
 EXPORT_SYMBOL(sock_no_sendmsg);
 EXPORT_SYMBOL(sock_no_sendpage);
 EXPORT_SYMBOL(sock_no_setsockopt);
 EXPORT_SYMBOL(sock_no_shutdown);
 EXPORT_SYMBOL(sock_no_socketpair);
 EXPORT_SYMBOL(sock_rfree);
-EXPORT_SYMBOL(sock_rmalloc);
 EXPORT_SYMBOL(sock_setsockopt);
 EXPORT_SYMBOL(sock_wfree);
 EXPORT_SYMBOL(sock_wmalloc);
diff -Nru a/net/core/wireless.c b/net/core/wireless.c
--- a/net/core/wireless.c	2004-12-24 13:37:44 -08:00
+++ b/net/core/wireless.c	2004-12-24 13:37:44 -08:00
@@ -2,7 +2,7 @@
  * This file implement the Wireless Extensions APIs.
  *
  * Authors :	Jean Tourrilhes - HPL - <jt@hpl.hp.com>
- * Copyright (c) 1997-2003 Jean Tourrilhes, All Rights Reserved.
+ * Copyright (c) 1997-2004 Jean Tourrilhes, All Rights Reserved.
  *
  * (As all part of the Linux kernel, this file is GPL)
  */
@@ -48,6 +48,16 @@
  *	o Add common spy support : iw_handler_set_spy(), wireless_spy_update()
  *	o Add enhanced spy support : iw_handler_set_thrspy() and event.
  *	o Add WIRELESS_EXT version display in /proc/net/wireless
+ *
+ * v6 - 18.06.04 - Jean II
+ *	o Change get_spydata() method for added safety
+ *	o Remove spy #ifdef, they are always on -> cleaner code
+ *	o Allow any size GET request if user specifies length > max
+ *		and if request has IW_DESCR_FLAG_NOMAX flag or is SIOCGIWPRIV
+ *	o Start migrating get_wireless_stats to struct iw_handler_def
+ *	o Add wmb() in iw_handler_set_spy() for non-coherent archs/cpus
+ * Based on patch from Pavel Roskin <proski@gnu.org> :
+ *	o Fix kernel data leak to user space in private handler handling
  */
 
 /***************************** INCLUDES *****************************/
@@ -69,10 +79,6 @@
 
 /**************************** CONSTANTS ****************************/
 
-/* Enough lenience, let's make sure things are proper... */
-#define WE_STRICT_WRITE		/* Check write buffer size */
-/* I'll probably drop both the define and kernel message in the next version */
-
 /* Debugging stuff */
 #undef WE_IOCTL_DEBUG		/* Debug IOCTL API */
 #undef WE_EVENT_DEBUG		/* Debug Event dispatcher */
@@ -186,6 +192,7 @@
 		.token_size	= sizeof(struct sockaddr) +
 				  sizeof(struct iw_quality),
 		.max_tokens	= IW_MAX_AP,
+		.flags		= IW_DESCR_FLAG_NOMAX,
 	},
 	[SIOCSIWSCAN	- SIOCIWFIRST] = {
 		.header_type	= IW_HEADER_TYPE_PARAM,
@@ -194,6 +201,7 @@
 		.header_type	= IW_HEADER_TYPE_POINT,
 		.token_size	= 1,
 		.max_tokens	= IW_SCAN_MAX_DATA,
+		.flags		= IW_DESCR_FLAG_NOMAX,
 	},
 	[SIOCSIWESSID	- SIOCIWFIRST] = {
 		.header_type	= IW_HEADER_TYPE_POINT,
@@ -296,7 +304,7 @@
 				       sizeof(struct iw_ioctl_description));
 
 /* Size (in bytes) of the various private data types */
-static const char priv_type_size[] = {
+const char iw_priv_type_size[] = {
 	0,				/* IW_PRIV_TYPE_NONE */
 	1,				/* IW_PRIV_TYPE_BYTE */
 	1,				/* IW_PRIV_TYPE_CHAR */
@@ -363,12 +371,15 @@
  */
 static inline struct iw_statistics *get_wireless_stats(struct net_device *dev)
 {
+	/* New location */
+	if((dev->wireless_handlers != NULL) &&
+	   (dev->wireless_handlers->get_wireless_stats != NULL))
+		return dev->wireless_handlers->get_wireless_stats(dev);
+
+	/* Old location, will be phased out in next WE */
 	return (dev->get_wireless_stats ?
 		dev->get_wireless_stats(dev) :
 		(struct iw_statistics *) NULL);
-	/* In the future, get_wireless_stats may move from 'struct net_device'
-	 * to 'struct iw_handler_def', to de-bloat struct net_device.
-	 * Definitely worse a thought... */
 }
 
 /* ---------------------------------------------------------------- */
@@ -403,14 +414,32 @@
 
 /* ---------------------------------------------------------------- */
 /*
- * Number of private arguments
+ * Calculate size of private arguments
  */
 static inline int get_priv_size(__u16	args)
 {
 	int	num = args & IW_PRIV_SIZE_MASK;
 	int	type = (args & IW_PRIV_TYPE_MASK) >> 12;
 
-	return num * priv_type_size[type];
+	return num * iw_priv_type_size[type];
+}
+
+/* ---------------------------------------------------------------- */
+/*
+ * Re-calculate the size of private arguments
+ */
+static inline int adjust_priv_size(__u16		args,
+				   union iwreq_data *	wrqu)
+{
+	int	num = wrqu->data.length;
+	int	max = args & IW_PRIV_SIZE_MASK;
+	int	type = (args & IW_PRIV_TYPE_MASK) >> 12;
+
+	/* Make sure the driver doesn't goof up */
+	if (max < num)
+		num = max;
+
+	return num * iw_priv_type_size[type];
 }
 
 
@@ -440,11 +469,14 @@
 		seq_printf(seq, "%6s: %04x  %3d%c  %3d%c  %3d%c  %6d %6d %6d "
 				"%6d %6d   %6d\n",
 			   dev->name, stats->status, stats->qual.qual,
-			   stats->qual.updated & 1 ? '.' : ' ',
+			   stats->qual.updated & IW_QUAL_QUAL_UPDATED
+			   ? '.' : ' ',
 			   ((__u8) stats->qual.level),
-			   stats->qual.updated & 2 ? '.' : ' ',
+			   stats->qual.updated & IW_QUAL_LEVEL_UPDATED
+			   ? '.' : ' ',
 			   ((__u8) stats->qual.noise),
-			   stats->qual.updated & 4 ? '.' : ' ',
+			   stats->qual.updated & IW_QUAL_NOISE_UPDATED
+			   ? '.' : ' ',
 			   stats->discard.nwid, stats->discard.code,
 			   stats->discard.fragment, stats->discard.retries,
 			   stats->discard.misc, stats->miss.beacon);
@@ -555,13 +587,15 @@
 	/* Check NULL pointer */
 	if(iwr->u.data.pointer == NULL)
 		return -EFAULT;
-#ifdef WE_STRICT_WRITE
+
 	/* Check if there is enough buffer up there */
 	if(iwr->u.data.length < dev->wireless_handlers->num_private_args) {
-		printk(KERN_ERR "%s (WE) : Buffer for request SIOCGIWPRIV too small (%d<%d)\n", dev->name, iwr->u.data.length, dev->wireless_handlers->num_private_args);
+		/* User space can't know in advance how large the buffer
+		 * needs to be. Give it a hint, so that we can support
+		 * any size buffer we want somewhat efficiently... */
+		iwr->u.data.length = dev->wireless_handlers->num_private_args;
 		return -E2BIG;
 	}
-#endif	/* WE_STRICT_WRITE */
 
 	/* Set the number of available ioctls. */
 	iwr->u.data.length = dev->wireless_handlers->num_private_args;
@@ -590,7 +624,6 @@
 	const struct iw_ioctl_description *	descr;
 	struct iw_request_info			info;
 	int					ret = -EINVAL;
-	int					user_size = 0;
 
 	/* Get the description of the IOCTL */
 	if((cmd - SIOCIWFIRST) >= standard_ioctl_num)
@@ -621,8 +654,14 @@
 #endif	/* WE_SET_EVENT */
 	} else {
 		char *	extra;
+		int	extra_size;
+		int	user_length = 0;
 		int	err;
 
+		/* Calculate space needed by arguments. Always allocate
+		 * for max space. Easier, and won't last long... */
+		extra_size = descr->max_tokens * descr->token_size;
+
 		/* Check what user space is giving us */
 		if(IW_IS_SET(cmd)) {
 			/* Check NULL pointer */
@@ -639,18 +678,33 @@
 			if(iwr->u.data.pointer == NULL)
 				return -EFAULT;
 			/* Save user space buffer size for checking */
-			user_size = iwr->u.data.length;
+			user_length = iwr->u.data.length;
+
+			/* Don't check if user_length > max to allow forward
+			 * compatibility. The test user_length < min is
+			 * implied by the test at the end. */
+
+			/* Support for very large requests */
+			if((descr->flags & IW_DESCR_FLAG_NOMAX) &&
+			   (user_length > descr->max_tokens)) {
+				/* Allow userspace to GET more than max so
+				 * we can support any size GET requests.
+				 * There is still a limit : -ENOMEM. */
+				extra_size = user_length * descr->token_size;
+				/* Note : user_length is originally a __u16,
+				 * and token_size is controlled by us,
+				 * so extra_size won't get negative and
+				 * won't overflow... */
+			}
 		}
 
 #ifdef WE_IOCTL_DEBUG
 		printk(KERN_DEBUG "%s (WE) : Malloc %d bytes\n",
-		       dev->name, descr->max_tokens * descr->token_size);
+		       dev->name, extra_size);
 #endif	/* WE_IOCTL_DEBUG */
 
-		/* Always allocate for max space. Easier, and won't last
-		 * long... */
-		extra = kmalloc(descr->max_tokens * descr->token_size,
-				GFP_KERNEL);
+		/* Create the kernel buffer */
+		extra = kmalloc(extra_size, GFP_KERNEL);
 		if (extra == NULL) {
 			return -ENOMEM;
 		}
@@ -676,14 +730,11 @@
 
 		/* If we have something to return to the user */
 		if (!ret && IW_IS_GET(cmd)) {
-#ifdef WE_STRICT_WRITE
 			/* Check if there is enough buffer up there */
-			if(user_size < iwr->u.data.length) {
-				printk(KERN_ERR "%s (WE) : Buffer for request %04X too small (%d<%d)\n", dev->name, cmd, user_size, iwr->u.data.length);
+			if(user_length < iwr->u.data.length) {
 				kfree(extra);
 				return -E2BIG;
 			}
-#endif	/* WE_STRICT_WRITE */
 
 			err = copy_to_user(iwr->u.data.pointer, extra,
 					   iwr->u.data.length *
@@ -746,7 +797,7 @@
 				     iw_handler		handler)
 {
 	struct iwreq *			iwr = (struct iwreq *) ifr;
-	struct iw_priv_args *		descr = NULL;
+	const struct iw_priv_args *	descr = NULL;
 	struct iw_request_info		info;
 	int				extra_size = 0;
 	int				i;
@@ -786,7 +837,7 @@
 			   ((extra_size + offset) <= IFNAMSIZ))
 				extra_size = 0;
 		} else {
-			/* Size of set arguments */
+			/* Size of get arguments */
 			extra_size = get_priv_size(descr->get_args);
 
 			/* Does it fits in iwr ? */
@@ -856,6 +907,14 @@
 
 		/* If we have something to return to the user */
 		if (!ret && IW_IS_GET(cmd)) {
+
+			/* Adjust for the actual length if it's variable,
+			 * avoid leaking kernel bits outside. */
+			if (!(descr->get_args & IW_PRIV_SIZE_FIXED)) {
+				extra_size = adjust_priv_size(descr->get_args,
+							      &(iwr->u));
+			}
+
 			err = copy_to_user(iwr->u.data.pointer, extra,
 					   extra_size);
 			if (err)
@@ -1127,9 +1186,25 @@
  * One of the main advantage of centralising spy support here is that
  * it becomes much easier to improve and extend it without having to touch
  * the drivers. One example is the addition of the Spy-Threshold events.
- * Note : IW_WIRELESS_SPY is defined in iw_handler.h
  */
 
+/* ---------------------------------------------------------------- */
+/*
+ * Return the pointer to the spy data in the driver.
+ * Because this is called on the Rx path via wireless_spy_update(),
+ * we want it to be efficient...
+ */
+static inline struct iw_spy_data * get_spydata(struct net_device *dev)
+{
+	/* This is the new way */
+	if(dev->wireless_data)
+		return(dev->wireless_data->spy_data);
+
+	/* This is the old way. Doesn't work for multi-headed drivers.
+	 * It will be removed in the next version of WE. */
+	return (dev->priv + dev->wireless_handlers->spy_offset);
+}
+
 /*------------------------------------------------------------------*/
 /*
  * Standard Wireless Handler : set Spy List
@@ -1139,16 +1214,30 @@
 		       union iwreq_data *	wrqu,
 		       char *			extra)
 {
-#ifdef IW_WIRELESS_SPY
-	struct iw_spy_data *	spydata = (dev->priv +
-					   dev->wireless_handlers->spy_offset);
+	struct iw_spy_data *	spydata = get_spydata(dev);
 	struct sockaddr *	address = (struct sockaddr *) extra;
 
+	if(!dev->wireless_data)
+		/* Help user know that driver needs updating */
+		printk(KERN_DEBUG "%s (WE) : Driver using old/buggy spy support, please fix driver !\n",
+		       dev->name);
+	/* Make sure driver is not buggy or using the old API */
+	if(!spydata)
+		return -EOPNOTSUPP;
+
 	/* Disable spy collection while we copy the addresses.
-	 * As we don't disable interrupts, we need to do this to avoid races.
-	 * As we are the only writer, this is good enough. */
+	 * While we copy addresses, any call to wireless_spy_update()
+	 * will NOP. This is OK, as anyway the addresses are changing. */
 	spydata->spy_number = 0;
 
+	/* We want to operate without locking, because wireless_spy_update()
+	 * most likely will happen in the interrupt handler, and therefore
+	 * have its own locking constraints and needs performance.
+	 * The rtnl_lock() make sure we don't race with the other iw_handlers.
+	 * This make sure wireless_spy_update() "see" that the spy list
+	 * is temporarily disabled. */
+	wmb();
+
 	/* Are there are addresses to copy? */
 	if(wrqu->data.length > 0) {
 		int i;
@@ -1174,13 +1263,14 @@
 			       spydata->spy_address[i][5]);
 #endif	/* WE_SPY_DEBUG */
 	}
+
+	/* Make sure above is updated before re-enabling */
+	wmb();
+
 	/* Enable addresses */
 	spydata->spy_number = wrqu->data.length;
 
 	return 0;
-#else /* IW_WIRELESS_SPY */
-	return -EOPNOTSUPP;
-#endif /* IW_WIRELESS_SPY */
 }
 
 /*------------------------------------------------------------------*/
@@ -1192,12 +1282,14 @@
 		       union iwreq_data *	wrqu,
 		       char *			extra)
 {
-#ifdef IW_WIRELESS_SPY
-	struct iw_spy_data *	spydata = (dev->priv +
-					   dev->wireless_handlers->spy_offset);
+	struct iw_spy_data *	spydata = get_spydata(dev);
 	struct sockaddr *	address = (struct sockaddr *) extra;
 	int			i;
 
+	/* Make sure driver is not buggy or using the old API */
+	if(!spydata)
+		return -EOPNOTSUPP;
+
 	wrqu->data.length = spydata->spy_number;
 
 	/* Copy addresses. */
@@ -1214,9 +1306,6 @@
 	for(i = 0; i < spydata->spy_number; i++)
 		spydata->spy_stat[i].updated = 0;
 	return 0;
-#else /* IW_WIRELESS_SPY */
-	return -EOPNOTSUPP;
-#endif /* IW_WIRELESS_SPY */
 }
 
 /*------------------------------------------------------------------*/
@@ -1228,11 +1317,13 @@
 			  union iwreq_data *	wrqu,
 			  char *		extra)
 {
-#ifdef IW_WIRELESS_THRSPY
-	struct iw_spy_data *	spydata = (dev->priv +
-					   dev->wireless_handlers->spy_offset);
+	struct iw_spy_data *	spydata = get_spydata(dev);
 	struct iw_thrspy *	threshold = (struct iw_thrspy *) extra;
 
+	/* Make sure driver is not buggy or using the old API */
+	if(!spydata)
+		return -EOPNOTSUPP;
+
 	/* Just do it */
 	memcpy(&(spydata->spy_thr_low), &(threshold->low),
 	       2 * sizeof(struct iw_quality));
@@ -1245,9 +1336,6 @@
 #endif	/* WE_SPY_DEBUG */
 
 	return 0;
-#else /* IW_WIRELESS_THRSPY */
-	return -EOPNOTSUPP;
-#endif /* IW_WIRELESS_THRSPY */
 }
 
 /*------------------------------------------------------------------*/
@@ -1259,22 +1347,20 @@
 			  union iwreq_data *	wrqu,
 			  char *		extra)
 {
-#ifdef IW_WIRELESS_THRSPY
-	struct iw_spy_data *	spydata = (dev->priv +
-					   dev->wireless_handlers->spy_offset);
+	struct iw_spy_data *	spydata = get_spydata(dev);
 	struct iw_thrspy *	threshold = (struct iw_thrspy *) extra;
 
+	/* Make sure driver is not buggy or using the old API */
+	if(!spydata)
+		return -EOPNOTSUPP;
+
 	/* Just do it */
 	memcpy(&(threshold->low), &(spydata->spy_thr_low),
 	       2 * sizeof(struct iw_quality));
 
 	return 0;
-#else /* IW_WIRELESS_THRSPY */
-	return -EOPNOTSUPP;
-#endif /* IW_WIRELESS_THRSPY */
 }
 
-#ifdef IW_WIRELESS_THRSPY
 /*------------------------------------------------------------------*/
 /*
  * Prepare and send a Spy Threshold event
@@ -1312,7 +1398,6 @@
 	/* Send event to user space */
 	wireless_send_event(dev, SIOCGIWTHRSPY, &wrqu, (char *) &threshold);
 }
-#endif /* IW_WIRELESS_THRSPY */
 
 /* ---------------------------------------------------------------- */
 /*
@@ -1325,12 +1410,14 @@
 			 unsigned char *	address,
 			 struct iw_quality *	wstats)
 {
-#ifdef IW_WIRELESS_SPY
-	struct iw_spy_data *	spydata = (dev->priv +
-					   dev->wireless_handlers->spy_offset);
+	struct iw_spy_data *	spydata = get_spydata(dev);
 	int			i;
 	int			match = -1;
 
+	/* Make sure driver is not buggy or using the old API */
+	if(!spydata)
+		return;
+
 #ifdef WE_SPY_DEBUG
 	printk(KERN_DEBUG "wireless_spy_update() :  offset %ld, spydata %p, address %02X:%02X:%02X:%02X:%02X:%02X\n", dev->wireless_handlers->spy_offset, spydata, address[0], address[1], address[2], address[3], address[4], address[5]);
 #endif	/* WE_SPY_DEBUG */
@@ -1342,7 +1429,7 @@
 			       sizeof(struct iw_quality));
 			match = i;
 		}
-#ifdef IW_WIRELESS_THRSPY
+
 	/* Generate an event if we cross the spy threshold.
 	 * To avoid event storms, we have a simple hysteresis : we generate
 	 * event only when we go under the low threshold or above the
@@ -1362,8 +1449,6 @@
 			}
 		}
 	}
-#endif /* IW_WIRELESS_THRSPY */
-#endif /* IW_WIRELESS_SPY */
 }
 
 EXPORT_SYMBOL(iw_handler_get_spy);
diff -Nru a/net/decnet/Kconfig b/net/decnet/Kconfig
--- a/net/decnet/Kconfig	2004-12-24 13:37:30 -08:00
+++ b/net/decnet/Kconfig	2004-12-24 13:37:30 -08:00
@@ -1,17 +1,6 @@
 #
 # DECnet configuration
 #
-config DECNET_SIOCGIFCONF
-	bool "DECnet: SIOCGIFCONF support"
-	depends on DECNET
-	help
-	  This option should only be turned on if you are really sure that
-	  you know what you are doing. It can break other applications which
-	  use this system call and the proper way to get the information
-	  provided by this call is to use rtnetlink.
-
-	  If unsure, say N.
-
 config DECNET_ROUTER
 	bool "DECnet: router support (EXPERIMENTAL)"
 	depends on DECNET && EXPERIMENTAL
diff -Nru a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
--- a/net/decnet/af_decnet.c	2004-12-24 13:36:55 -08:00
+++ b/net/decnet/af_decnet.c	2004-12-24 13:36:55 -08:00
@@ -1075,7 +1075,7 @@
 		skb = dn_wait_for_connect(sk, &timeo);
 		if (IS_ERR(skb)) {
 			release_sock(sk);
-			return PTR_ERR(sk);
+			return PTR_ERR(skb);
 		}
 	}
 
@@ -1723,7 +1723,7 @@
 			goto out;
 
 		if (signal_pending(current)) {
-			rv = -ERESTARTSYS;
+			rv = sock_intr_errno(timeo);
 			goto out;
 		}
 
@@ -1957,7 +1957,7 @@
 			goto out;
 
 		if (signal_pending(current)) {
-			err = -ERESTARTSYS;
+			err = sock_intr_errno(timeo);
 			goto out;
 		}
 
@@ -1992,7 +1992,7 @@
 		/*
 		 * Get a suitably sized skb.
 		 */
-		skb = dn_alloc_send_skb(sk, &len, flags & MSG_DONTWAIT, &err);
+		skb = dn_alloc_send_skb(sk, &len, flags & MSG_DONTWAIT, timeo, &err);
 
 		if (err)
 			break;
diff -Nru a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
--- a/net/decnet/dn_dev.c	2004-12-24 13:36:47 -08:00
+++ b/net/decnet/dn_dev.c	2004-12-24 13:36:47 -08:00
@@ -1291,59 +1291,6 @@
 	return notifier_chain_unregister(&dnaddr_chain, nb);
 }
 
-#ifdef CONFIG_DECNET_SIOCGIFCONF
-/*
- * Now we support multiple addresses per interface.
- * Since we don't want to break existing code, you have to enable
- * it as a compile time option. Probably you should use the
- * rtnetlink interface instead.
- */
-int dnet_gifconf(struct net_device *dev, char __user *buf, int len)
-{
-	struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
-	struct dn_ifaddr *ifa;
-	char buffer[DN_IFREQ_SIZE];
-	struct ifreq *ifr = (struct ifreq *)buffer;
-	struct sockaddr_dn *addr = (struct sockaddr_dn *)&ifr->ifr_addr;
-	int done = 0;
-
-	if ((dn_db == NULL) || ((ifa = dn_db->ifa_list) == NULL))
-		return 0;
-
-	for(; ifa; ifa = ifa->ifa_next) {
-		if (!buf) {
-			done += sizeof(DN_IFREQ_SIZE);
-			continue;
-		}
-		if (len < DN_IFREQ_SIZE)
-			return done;
-		memset(buffer, 0, DN_IFREQ_SIZE);
-
-		if (ifa->ifa_label)
-			strcpy(ifr->ifr_name, ifa->ifa_label);
-		else
-			strcpy(ifr->ifr_name, dev->name);
-
-		addr->sdn_family = AF_DECnet;
-		addr->sdn_add.a_len = 2;
-		memcpy(addr->sdn_add.a_addr, &ifa->ifa_local,
-			sizeof(dn_address));
-
-		if (copy_to_user(buf, buffer, DN_IFREQ_SIZE)) {
-			done = -EFAULT;
-			break;
-		}
-
-		buf  += DN_IFREQ_SIZE;
-		len  -= DN_IFREQ_SIZE;
-		done += DN_IFREQ_SIZE;
-	}
-
-	return done;
-}
-#endif /* CONFIG_DECNET_SIOCGIFCONF */
-
-
 #ifdef CONFIG_PROC_FS
 static inline struct net_device *dn_dev_get_next(struct seq_file *seq, struct net_device *dev)
 {
@@ -1484,8 +1431,7 @@
 };
 
 static int __initdata addr[2];
-static int __initdata num;
-module_param_array(addr, int, num, 0444);
+module_param_array(addr, int, NULL, 0444);
 MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node");
 
 void __init dn_dev_init(void)
@@ -1503,9 +1449,6 @@
         decnet_address = dn_htons((addr[0] << 10) | addr[1]);
 
 	dn_dev_devices_on();
-#ifdef CONFIG_DECNET_SIOCGIFCONF
-	register_gifconf(PF_DECnet, dnet_gifconf);
-#endif /* CONFIG_DECNET_SIOCGIFCONF */
 
 	rtnetlink_links[PF_DECnet] = dnet_rtnetlink_table;
 
@@ -1523,10 +1466,6 @@
 void __exit dn_dev_cleanup(void)
 {
 	rtnetlink_links[PF_DECnet] = NULL;
-
-#ifdef CONFIG_DECNET_SIOCGIFCONF
-	unregister_gifconf(PF_DECnet);
-#endif /* CONFIG_DECNET_SIOCGIFCONF */
 
 #ifdef CONFIG_SYSCTL
 	{
diff -Nru a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c
--- a/net/decnet/dn_neigh.c	2004-12-24 13:37:01 -08:00
+++ b/net/decnet/dn_neigh.c	2004-12-24 13:37:01 -08:00
@@ -26,6 +26,7 @@
 
 #include <linux/config.h>
 #include <linux/net.h>
+#include <linux/module.h>
 #include <linux/socket.h>
 #include <linux/if_arp.h>
 #include <linux/if_ether.h>
diff -Nru a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c
--- a/net/decnet/dn_nsp_in.c	2004-12-24 13:36:47 -08:00
+++ b/net/decnet/dn_nsp_in.c	2004-12-24 13:36:47 -08:00
@@ -419,6 +419,7 @@
 		case DN_CI:
 		case DN_CD:
 			scp->state = DN_RJ;
+			sk->sk_err = ECONNREFUSED;
 			break;
 		case DN_RUN:
 			sk->sk_shutdown |= SHUTDOWN_MASK;
diff -Nru a/net/decnet/dn_nsp_out.c b/net/decnet/dn_nsp_out.c
--- a/net/decnet/dn_nsp_out.c	2004-12-24 13:37:29 -08:00
+++ b/net/decnet/dn_nsp_out.c	2004-12-24 13:37:29 -08:00
@@ -141,7 +141,7 @@
  * whole size thats been asked for (plus 11 bytes of header). If this
  * fails, then we try for any size over 16 bytes for SOCK_STREAMS.
  */
-struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, int *err)
+struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err)
 {
 	int space;
 	int len;
@@ -151,7 +151,7 @@
 
 	while(skb == NULL) {
 		if (signal_pending(current)) {
-			*err = ERESTARTSYS;
+			*err = sock_intr_errno(timeo);
 			break;
 		}
 
diff -Nru a/net/decnet/dn_route.c b/net/decnet/dn_route.c
--- a/net/decnet/dn_route.c	2004-12-24 13:37:29 -08:00
+++ b/net/decnet/dn_route.c	2004-12-24 13:37:29 -08:00
@@ -287,10 +287,9 @@
 		if (compare_keys(&rth->fl, &rt->fl)) {
 			/* Put it first */
 			*rthp = rth->u.rt_next;
-			smp_wmb();
-			rth->u.rt_next = dn_rt_hash_table[hash].chain;
-			smp_wmb();
-			dn_rt_hash_table[hash].chain = rth;
+			rcu_assign_pointer(rth->u.rt_next,
+					   dn_rt_hash_table[hash].chain);
+			rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth);
 
 			rth->u.dst.__use++;
 			dst_hold(&rth->u.dst);
@@ -304,10 +303,8 @@
 		rthp = &rth->u.rt_next;
 	}
 
-	smp_wmb();
-	rt->u.rt_next = dn_rt_hash_table[hash].chain;
-	smp_wmb();
-	dn_rt_hash_table[hash].chain = rt;
+	rcu_assign_pointer(rt->u.rt_next, dn_rt_hash_table[hash].chain);
+	rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt);
 	
 	dst_hold(&rt->u.dst);
 	rt->u.dst.__use++;
@@ -683,9 +680,8 @@
 	return NET_RX_DROP;
 }
 
-static int dn_output(struct sk_buff **pskb)
+static int dn_output(struct sk_buff *skb)
 {
-	struct sk_buff *skb = *pskb;
 	struct dst_entry *dst = skb->dst;
 	struct dn_route *rt = (struct dn_route *)dst;
 	struct net_device *dev = dst->dev;
@@ -796,11 +792,6 @@
 	return NET_RX_BAD;
 }
 
-static int dn_rt_bug_out(struct sk_buff **pskb)
-{
-	return dn_rt_bug(*pskb);
-}
-
 static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
 {
 	struct dn_fib_info *fi = res->fi;
@@ -1392,7 +1383,7 @@
 	rt->u.dst.neighbour = neigh;
 	rt->u.dst.dev = out_dev;
 	rt->u.dst.lastuse = jiffies;
-	rt->u.dst.output = dn_rt_bug_out;
+	rt->u.dst.output = dn_rt_bug;
 	switch(res.type) {
 		case RTN_UNICAST:
 			rt->u.dst.input = dn_forward;
@@ -1685,7 +1676,7 @@
 		rt = dn_rt_hash_table[s->bucket].chain;
 		if (rt)
 			break;
-		rcu_read_unlock();
+		rcu_read_unlock_bh();
 	}
 	return rt;
 }
@@ -1831,7 +1822,7 @@
 
 	dn_rt_hash_mask--;
         for(i = 0; i <= dn_rt_hash_mask; i++) {
-                dn_rt_hash_table[i].lock = SPIN_LOCK_UNLOCKED;
+                spin_lock_init(&dn_rt_hash_table[i].lock);
                 dn_rt_hash_table[i].chain = NULL;
         }
 
diff -Nru a/net/econet/af_econet.c b/net/econet/af_econet.c
--- a/net/econet/af_econet.c	2004-12-24 13:36:49 -08:00
+++ b/net/econet/af_econet.c	2004-12-24 13:36:49 -08:00
@@ -40,10 +40,10 @@
 #include <net/ip.h>
 #include <linux/spinlock.h>
 #include <linux/rcupdate.h>
+#include <linux/bitops.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 static struct proto_ops econet_ops;
 static struct hlist_head econet_sklist;
diff -Nru a/net/ethernet/eth.c b/net/ethernet/eth.c
--- a/net/ethernet/eth.c	2004-12-24 13:36:55 -08:00
+++ b/net/ethernet/eth.c	2004-12-24 13:36:55 -08:00
@@ -245,3 +245,64 @@
 }
 
 EXPORT_SYMBOL(eth_type_trans);
+
+static int eth_mac_addr(struct net_device *dev, void *p)
+{
+	struct sockaddr *addr=p;
+	if (netif_running(dev))
+		return -EBUSY;
+	memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
+	return 0;
+}
+
+static int eth_change_mtu(struct net_device *dev, int new_mtu)
+{
+	if ((new_mtu < 68) || (new_mtu > 1500))
+		return -EINVAL;
+	dev->mtu = new_mtu;
+	return 0;
+}
+
+/*
+ * Fill in the fields of the device structure with ethernet-generic values.
+ */
+void ether_setup(struct net_device *dev)
+{
+	dev->change_mtu		= eth_change_mtu;
+	dev->hard_header	= eth_header;
+	dev->rebuild_header 	= eth_rebuild_header;
+	dev->set_mac_address 	= eth_mac_addr;
+	dev->hard_header_cache	= eth_header_cache;
+	dev->header_cache_update= eth_header_cache_update;
+	dev->hard_header_parse	= eth_header_parse;
+
+	dev->type		= ARPHRD_ETHER;
+	dev->hard_header_len 	= ETH_HLEN;
+	dev->mtu		= 1500; /* eth_mtu */
+	dev->addr_len		= ETH_ALEN;
+	dev->tx_queue_len	= 1000;	/* Ethernet wants good queues */	
+	dev->flags		= IFF_BROADCAST|IFF_MULTICAST;
+	
+	memset(dev->broadcast,0xFF, ETH_ALEN);
+
+}
+EXPORT_SYMBOL(ether_setup);
+
+/**
+ * alloc_etherdev - Allocates and sets up an ethernet device
+ * @sizeof_priv: Size of additional driver-private structure to be allocated
+ *	for this ethernet device
+ *
+ * Fill in the fields of the device structure with ethernet-generic
+ * values. Basically does everything except registering the device.
+ *
+ * Constructs a new net device, complete with a private data area of
+ * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
+ * this private data area.
+ */
+
+struct net_device *alloc_etherdev(int sizeof_priv)
+{
+	return alloc_netdev(sizeof_priv, "eth%d", ether_setup);
+}
+EXPORT_SYMBOL(alloc_etherdev);
diff -Nru a/net/ipv4/Kconfig b/net/ipv4/Kconfig
--- a/net/ipv4/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/net/ipv4/Kconfig	2004-12-24 13:37:18 -08:00
@@ -301,6 +301,7 @@
 
 config INET_AH
 	tristate "IP: AH transformation"
+	depends on INET
 	select XFRM
 	select CRYPTO
 	select CRYPTO_HMAC
@@ -313,6 +314,7 @@
 
 config INET_ESP
 	tristate "IP: ESP transformation"
+	depends on INET
 	select XFRM
 	select CRYPTO
 	select CRYPTO_HMAC
@@ -326,24 +328,39 @@
 
 config INET_IPCOMP
 	tristate "IP: IPComp transformation"
+	depends on INET
 	select XFRM
 	select INET_TUNNEL
 	select CRYPTO
 	select CRYPTO_DEFLATE
 	---help---
-	  Support for IP Paylod Compression (RFC3173), typically needed
-	  for IPsec.
+	  Support for IP Payload Compression Protocol (IPComp) (RFC3173),
+	  typically needed for IPsec.
 	  
 	  If unsure, say Y.
 
 config INET_TUNNEL
 	tristate "IP: tunnel transformation"
+	depends on INET
 	select XFRM
 	---help---
 	  Support for generic IP tunnel transformation, which is required by
 	  the IP tunneling module as well as tunnel mode IPComp.
 	  
 	  If unsure, say Y.
+
+config IP_TCPDIAG
+	tristate "IP: TCP socket monitoring interface"
+	depends on INET
+	default y
+	---help---
+	  Support for TCP socket monitoring interface used by native Linux
+	  tools such as ss.
+	  
+	  If unsure, say Y.
+
+config IP_TCPDIAG_IPV6
+	def_bool (IP_TCPDIAG=y && IPV6=y) || (IP_TCPDIAG=m && IPV6)
 
 source "net/ipv4/ipvs/Kconfig"
 
diff -Nru a/net/ipv4/Makefile b/net/ipv4/Makefile
--- a/net/ipv4/Makefile	2004-12-24 13:36:31 -08:00
+++ b/net/ipv4/Makefile	2004-12-24 13:36:31 -08:00
@@ -6,7 +6,7 @@
 	     ip_input.o ip_fragment.o ip_forward.o ip_options.o \
 	     ip_output.o ip_sockglue.o \
 	     tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o tcp_minisocks.o \
-	     tcp_diag.o datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \
+	     datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \
 	     sysctl_net_ipv4.o fib_frontend.o fib_semantics.o fib_hash.o
 
 obj-$(CONFIG_PROC_FS) += proc.o
@@ -22,6 +22,7 @@
 obj-$(CONFIG_IP_PNP) += ipconfig.o
 obj-$(CONFIG_NETFILTER)	+= netfilter/
 obj-$(CONFIG_IP_VS) += ipvs/
+obj-$(CONFIG_IP_TCPDIAG) += tcp_diag.o 
 
 obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
 		      xfrm4_output.o
diff -Nru a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
--- a/net/ipv4/af_inet.c	2004-12-24 13:36:18 -08:00
+++ b/net/ipv4/af_inet.c	2004-12-24 13:36:18 -08:00
@@ -309,7 +309,7 @@
 	inet->id = 0;
 
 	sock_init_data(sock, sk);
-	sk_set_owner(sk, THIS_MODULE);
+	sk_set_owner(sk, sk->sk_prot->owner);
 
 	sk->sk_destruct	   = inet_sock_destruct;
 	sk->sk_family	   = PF_INET;
@@ -809,6 +809,31 @@
 	.socketpair =	sock_no_socketpair,
 	.accept =	sock_no_accept,
 	.getname =	inet_getname,
+	.poll =		udp_poll,
+	.ioctl =	inet_ioctl,
+	.listen =	sock_no_listen,
+	.shutdown =	inet_shutdown,
+	.setsockopt =	sock_common_setsockopt,
+	.getsockopt =	sock_common_getsockopt,
+	.sendmsg =	inet_sendmsg,
+	.recvmsg =	sock_common_recvmsg,
+	.mmap =		sock_no_mmap,
+	.sendpage =	inet_sendpage,
+};
+
+/*
+ * For SOCK_RAW sockets; should be the same as inet_dgram_ops but without
+ * udp_poll
+ */
+static struct proto_ops inet_sockraw_ops = {
+	.family =	PF_INET,
+	.owner =	THIS_MODULE,
+	.release =	inet_release,
+	.bind =		inet_bind,
+	.connect =	inet_dgram_connect,
+	.socketpair =	sock_no_socketpair,
+	.accept =	sock_no_accept,
+	.getname =	inet_getname,
 	.poll =		datagram_poll,
 	.ioctl =	inet_ioctl,
 	.listen =	sock_no_listen,
@@ -861,7 +886,7 @@
                .type =       SOCK_RAW,
                .protocol =   IPPROTO_IP,	/* wild card */
                .prot =       &raw_prot,
-               .ops =        &inet_dgram_ops,
+               .ops =        &inet_sockraw_ops,
                .capability = CAP_NET_RAW,
                .no_check =   UDP_CSUM_DEFAULT,
                .flags =      INET_PROTOSW_REUSE,
@@ -1165,8 +1190,6 @@
 EXPORT_SYMBOL(inet_stream_ops);
 EXPORT_SYMBOL(inet_unregister_protosw);
 EXPORT_SYMBOL(net_statistics);
-EXPORT_SYMBOL(tcp_protocol);
-EXPORT_SYMBOL(udp_protocol);
 
 #ifdef INET_REFCNT_DEBUG
 EXPORT_SYMBOL(inet_sock_nr);
diff -Nru a/net/ipv4/devinet.c b/net/ipv4/devinet.c
--- a/net/ipv4/devinet.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv4/devinet.c	2004-12-24 13:36:31 -08:00
@@ -31,7 +31,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -158,8 +158,7 @@
 
 	/* Account for reference dev->ip_ptr */
 	in_dev_hold(in_dev);
-	smp_wmb();
-	dev->ip_ptr = in_dev;
+	rcu_assign_pointer(dev->ip_ptr, in_dev);
 
 #ifdef CONFIG_SYSCTL
 	devinet_sysctl_register(in_dev, &in_dev->cnf);
diff -Nru a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
--- a/net/ipv4/fib_frontend.c	2004-12-24 13:37:31 -08:00
+++ b/net/ipv4/fib_frontend.c	2004-12-24 13:37:31 -08:00
@@ -19,7 +19,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff -Nru a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
--- a/net/ipv4/fib_hash.c	2004-12-24 13:36:49 -08:00
+++ b/net/ipv4/fib_hash.c	2004-12-24 13:36:49 -08:00
@@ -18,7 +18,7 @@
 #include <linux/config.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff -Nru a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
--- a/net/ipv4/fib_rules.c	2004-12-24 13:36:57 -08:00
+++ b/net/ipv4/fib_rules.c	2004-12-24 13:36:57 -08:00
@@ -22,7 +22,7 @@
 #include <linux/config.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff -Nru a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
--- a/net/ipv4/fib_semantics.c	2004-12-24 13:36:19 -08:00
+++ b/net/ipv4/fib_semantics.c	2004-12-24 13:36:19 -08:00
@@ -18,7 +18,7 @@
 #include <linux/config.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/jiffies.h>
@@ -163,6 +163,8 @@
 		if (fi->fib_prefsrc)
 			hlist_del(&fi->fib_lhash);
 		change_nexthops(fi) {
+			if (!nh->nh_dev)
+				continue;
 			hlist_del(&nh->nh_hash);
 		} endfor_nexthops(fi)
 		fi->fib_dead = 1;
diff -Nru a/net/ipv4/icmp.c b/net/ipv4/icmp.c
--- a/net/ipv4/icmp.c	2004-12-24 13:37:29 -08:00
+++ b/net/ipv4/icmp.c	2004-12-24 13:37:29 -08:00
@@ -338,6 +338,8 @@
 				      to, len, 0);
 
 	skb->csum = csum_block_add(skb->csum, csum, odd);
+	if (icmp_pointers[icmp_param->data.icmph.type].error)
+		nf_ct_attach(skb, icmp_param->skb);
 	return 0;
 }
 
diff -Nru a/net/ipv4/igmp.c b/net/ipv4/igmp.c
--- a/net/ipv4/igmp.c	2004-12-24 13:37:30 -08:00
+++ b/net/ipv4/igmp.c	2004-12-24 13:37:30 -08:00
@@ -1252,8 +1252,8 @@
 	in_dev->mr_qrv = IGMP_Unsolicited_Report_Count;
 #endif
 
-	in_dev->mc_list_lock = RW_LOCK_UNLOCKED;
-	in_dev->mc_tomb_lock = SPIN_LOCK_UNLOCKED;
+	rwlock_init(&in_dev->mc_list_lock);
+	spin_lock_init(&in_dev->mc_tomb_lock);
 }
 
 /* Device going up */
@@ -1778,12 +1778,12 @@
 			goto done;
 		rv = !0;
 		for (i=0; i<psl->sl_count; i++) {
-			rv = memcmp(&psl->sl_addr, &mreqs->imr_multiaddr,
+			rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
 				sizeof(__u32));
-			if (rv >= 0)
+			if (rv == 0)
 				break;
 		}
-		if (!rv)	/* source not found */
+		if (rv)		/* source not found */
 			goto done;
 
 		/* update the interface filter */
@@ -1825,9 +1825,9 @@
 	}
 	rv = 1;	/* > 0 for insert logic below if sl_count is 0 */
 	for (i=0; i<psl->sl_count; i++) {
-		rv = memcmp(&psl->sl_addr, &mreqs->imr_multiaddr,
+		rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
 			sizeof(__u32));
-		if (rv >= 0)
+		if (rv == 0)
 			break;
 	}
 	if (rv == 0)		/* address already there is an error */
diff -Nru a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
--- a/net/ipv4/ip_fragment.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv4/ip_fragment.c	2004-12-24 13:36:31 -08:00
@@ -373,7 +373,7 @@
 	init_timer(&qp->timer);
 	qp->timer.data = (unsigned long) qp;	/* pointer to queue	*/
 	qp->timer.function = ip_expire;		/* expire function	*/
-	qp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&qp->lock);
 	atomic_set(&qp->refcnt, 1);
 
 	return ip_frag_intern(hash, qp);
diff -Nru a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
--- a/net/ipv4/ip_options.c	2004-12-24 13:37:02 -08:00
+++ b/net/ipv4/ip_options.c	2004-12-24 13:37:02 -08:00
@@ -515,6 +515,8 @@
 		kfree(opt);
 		return -EINVAL;
 	}
+	if (*optp)
+		kfree(*optp);
 	*optp = opt;
 	return 0;
 }
diff -Nru a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
--- a/net/ipv4/ip_output.c	2004-12-24 13:37:30 -08:00
+++ b/net/ipv4/ip_output.c	2004-12-24 13:37:30 -08:00
@@ -224,9 +224,8 @@
 		       ip_finish_output2);
 }
 
-int ip_mc_output(struct sk_buff **pskb)
+int ip_mc_output(struct sk_buff *skb)
 {
-	struct sk_buff *skb = *pskb;
 	struct sock *sk = skb->sk;
 	struct rtable *rt = (struct rtable*)skb->dst;
 	struct net_device *dev = rt->u.dst.dev;
@@ -279,20 +278,17 @@
 				newskb->dev, ip_dev_loopback_xmit);
 	}
 
-	if (skb->len > dst_pmtu(&rt->u.dst) || skb_shinfo(skb)->frag_list)
+	if (skb->len > dst_pmtu(&rt->u.dst))
 		return ip_fragment(skb, ip_finish_output);
 	else
 		return ip_finish_output(skb);
 }
 
-int ip_output(struct sk_buff **pskb)
+int ip_output(struct sk_buff *skb)
 {
-	struct sk_buff *skb = *pskb;
-
 	IP_INC_STATS(IPSTATS_MIB_OUTREQUESTS);
 
-	if ((skb->len > dst_pmtu(skb->dst) || skb_shinfo(skb)->frag_list) &&
-	    !skb_shinfo(skb)->tso_size)
+	if (skb->len > dst_pmtu(skb->dst) && !skb_shinfo(skb)->tso_size)
 		return ip_fragment(skb, ip_finish_output);
 	else
 		return ip_finish_output(skb);
diff -Nru a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
--- a/net/ipv4/ip_sockglue.c	2004-12-24 13:36:32 -08:00
+++ b/net/ipv4/ip_sockglue.c	2004-12-24 13:36:32 -08:00
@@ -146,11 +146,8 @@
 	struct cmsghdr *cmsg;
 
 	for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
-		if (cmsg->cmsg_len < sizeof(struct cmsghdr) ||
-		    (unsigned long)(((char*)cmsg - (char*)msg->msg_control)
-				    + cmsg->cmsg_len) > msg->msg_controllen) {
+		if (!CMSG_OK(msg, cmsg))
 			return -EINVAL;
-		}
 		if (cmsg->cmsg_level != SOL_IP)
 			continue;
 		switch (cmsg->cmsg_type) {
diff -Nru a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
--- a/net/ipv4/ipconfig.c	2004-12-24 13:36:17 -08:00
+++ b/net/ipv4/ipconfig.c	2004-12-24 13:36:17 -08:00
@@ -1102,8 +1102,8 @@
 
 		jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
 		while (time_before(jiffies, jiff) && !ic_got_reply) {
-			barrier();
-			cpu_relax();
+			set_current_state(TASK_UNINTERRUPTIBLE);
+			schedule_timeout(1);
 		}
 #ifdef IPCONFIG_DHCP
 		/* DHCP isn't done until we get a DHCPACK. */
@@ -1245,7 +1245,6 @@
 
 static int __init ip_auto_config(void)
 {
-	unsigned long jiff;
 	u32 addr;
 
 #ifdef CONFIG_PROC_FS
@@ -1260,18 +1259,16 @@
  try_try_again:
 #endif
 	/* Give hardware a chance to settle */
-	jiff = jiffies + CONF_PRE_OPEN;
-	while (time_before(jiffies, jiff))
-		cpu_relax();
+	set_current_state(TASK_UNINTERRUPTIBLE);
+	schedule_timeout(CONF_PRE_OPEN);
 
 	/* Setup all network devices */
 	if (ic_open_devs() < 0)
 		return -1;
 
 	/* Give drivers a chance to settle */
-	jiff = jiffies + CONF_POST_OPEN;
-	while (time_before(jiffies, jiff))
-		cpu_relax();
+	set_current_state(TASK_UNINTERRUPTIBLE);
+	schedule_timeout(CONF_POST_OPEN);
 
 	/*
 	 * If the config information is insufficient (e.g., our IP address or
diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
--- a/net/ipv4/ipvs/ip_vs_conn.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv4/ipvs/ip_vs_conn.c	2004-12-24 13:37:19 -08:00
@@ -453,7 +453,9 @@
 	 * Checking the dest server status.
 	 */
 	if ((dest == NULL) ||
-	    !(dest->flags & IP_VS_DEST_F_AVAILABLE)) {
+	    !(dest->flags & IP_VS_DEST_F_AVAILABLE) || 
+	    (sysctl_ip_vs_expire_quiescent_template && 
+	     (atomic_read(&dest->weight) == 0))) {
 		IP_VS_DBG(9, "check_template: dest not available for "
 			  "protocol %s s:%u.%u.%u.%u:%d v:%u.%u.%u.%u:%d "
 			  "-> d:%u.%u.%u.%u:%d\n",
@@ -580,7 +582,7 @@
 	cp->daddr          = daddr;
 	cp->dport          = dport;
 	cp->flags	   = flags;
-	cp->lock           = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&cp->lock);
 
 	/*
 	 * Set the entry is referenced by the current thread before hashing
@@ -894,7 +896,7 @@
 	}
 
 	for (idx = 0; idx < CT_LOCKARRAY_SIZE; idx++)  {
-		__ip_vs_conntbl_lock_array[idx].l = RW_LOCK_UNLOCKED;
+		rwlock_init(&__ip_vs_conntbl_lock_array[idx].l);
 	}
 
 	proc_net_fops_create("ip_vs_conn", 0, &ip_vs_conn_fops);
diff -Nru a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
--- a/net/ipv4/ipvs/ip_vs_ctl.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv4/ipvs/ip_vs_ctl.c	2004-12-24 13:37:19 -08:00
@@ -75,6 +75,7 @@
 static int sysctl_ip_vs_am_droprate = 10;
 int sysctl_ip_vs_cache_bypass = 0;
 int sysctl_ip_vs_expire_nodest_conn = 0;
+int sysctl_ip_vs_expire_quiescent_template = 0;
 int sysctl_ip_vs_sync_threshold[2] = { 3, 50 };
 int sysctl_ip_vs_nat_icmp_send = 0;
 
@@ -746,8 +747,8 @@
 	atomic_set(&dest->refcnt, 0);
 
 	INIT_LIST_HEAD(&dest->d_list);
-	dest->dst_lock = SPIN_LOCK_UNLOCKED;
-	dest->stats.lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&dest->dst_lock);
+	spin_lock_init(&dest->stats.lock);
 	__ip_vs_update_dest(svc, dest, udest);
 	ip_vs_new_estimator(&dest->stats);
 
@@ -1062,8 +1063,8 @@
 	svc->netmask = u->netmask;
 
 	INIT_LIST_HEAD(&svc->destinations);
-	svc->sched_lock = RW_LOCK_UNLOCKED;
-	svc->stats.lock = SPIN_LOCK_UNLOCKED;
+	rwlock_init(&svc->sched_lock);
+	spin_lock_init(&svc->stats.lock);
 
 	/* Bind the scheduler */
 	ret = ip_vs_bind_scheduler(svc, sched);
@@ -1447,9 +1448,9 @@
 	{
 		.ctl_name	= NET_IPV4_VS_TO_ES,
 		.procname	= "timeout_established",
-	  	.data	= &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED],
+		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1457,7 +1458,7 @@
 		.procname	= "timeout_synsent",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_SYN_SENT],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1465,7 +1466,7 @@
 		.procname	= "timeout_synrecv",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_SYN_RECV],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1473,7 +1474,7 @@
 		.procname	= "timeout_finwait",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_FIN_WAIT],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1489,7 +1490,7 @@
 		.procname	= "timeout_close",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1497,7 +1498,7 @@
 		.procname	= "timeout_closewait",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE_WAIT],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1505,7 +1506,7 @@
 		.procname	= "timeout_lastack",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_LAST_ACK],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1513,7 +1514,7 @@
 		.procname	= "timeout_listen",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_LISTEN],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1521,7 +1522,7 @@
 		.procname	= "timeout_synack",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_SYNACK],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1529,7 +1530,7 @@
 		.procname	= "timeout_udp",
 		.data	= &vs_timeout_table_dos.timeout[IP_VS_S_UDP],
 		.maxlen		= sizeof(int),
-		.mode		= 0644, 
+		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_jiffies,
 	},
 	{
@@ -1558,6 +1559,14 @@
 		.proc_handler	= &proc_dointvec,
 	},
 	{
+		.ctl_name	= NET_IPV4_VS_EXPIRE_QUIESCENT_TEMPLATE,
+		.procname	= "expire_quiescent_template",
+		.data		= &sysctl_ip_vs_expire_quiescent_template,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+	},
+	{
 		.ctl_name	= NET_IPV4_VS_SYNC_THRESHOLD,
 		.procname	= "sync_threshold",
 		.data		= &sysctl_ip_vs_sync_threshold,
@@ -2357,7 +2366,7 @@
 	}
 
 	memset(&ip_vs_stats, 0, sizeof(ip_vs_stats));
-	ip_vs_stats.lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&ip_vs_stats.lock);
 	ip_vs_new_estimator(&ip_vs_stats);
 
 	/* Hook the defense timer */
diff -Nru a/net/ipv4/ipvs/ip_vs_ftp.c b/net/ipv4/ipvs/ip_vs_ftp.c
--- a/net/ipv4/ipvs/ip_vs_ftp.c	2004-12-24 13:37:31 -08:00
+++ b/net/ipv4/ipvs/ip_vs_ftp.c	2004-12-24 13:37:31 -08:00
@@ -45,8 +45,7 @@
  * First port is set to the default port.
  */
 static int ports[IP_VS_APP_MAX_PORTS] = {21, 0};
-static int ports_c;
-module_param_array(ports, int, ports_c, 0);
+module_param_array(ports, int, NULL, 0);
 
 /*
  *	Debug level
diff -Nru a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
--- a/net/ipv4/ipvs/ip_vs_lblc.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv4/ipvs/ip_vs_lblc.c	2004-12-24 13:37:19 -08:00
@@ -409,7 +409,7 @@
 	for (i=0; i<IP_VS_LBLC_TAB_SIZE; i++) {
 		INIT_LIST_HEAD(&tbl->bucket[i]);
 	}
-	tbl->lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&tbl->lock);
 	tbl->max_size = IP_VS_LBLC_TAB_SIZE*16;
 	tbl->rover = 0;
 	tbl->counter = 1;
diff -Nru a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
--- a/net/ipv4/ipvs/ip_vs_lblcr.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv4/ipvs/ip_vs_lblcr.c	2004-12-24 13:37:18 -08:00
@@ -362,7 +362,7 @@
 	/* initilize its dest set */
 	atomic_set(&(en->set.size), 0);
 	en->set.list = NULL;
-	en->set.lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&en->set.lock);
 
 	return en;
 }
@@ -659,7 +659,7 @@
 	for (i=0; i<IP_VS_LBLCR_TAB_SIZE; i++) {
 		INIT_LIST_HEAD(&tbl->bucket[i]);
 	}
-	tbl->lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&tbl->lock);
 	tbl->max_size = IP_VS_LBLCR_TAB_SIZE*16;
 	tbl->rover = 0;
 	tbl->counter = 1;
diff -Nru a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
--- a/net/ipv4/netfilter/Kconfig	2004-12-24 13:37:18 -08:00
+++ b/net/ipv4/netfilter/Kconfig	2004-12-24 13:37:18 -08:00
@@ -32,6 +32,14 @@
 
 	  If unsure, say `N'.
 
+config IP_NF_CONNTRACK_MARK
+	bool  'Connection mark tracking support'
+	help
+	  This option enables support for connection marks, used by the
+	  `CONNMARK' target and `connmark' match. Similar to the mark value
+	  of packets, but this mark value is kept in the conntrack session
+	  instead of the individual packets.
+	
 config IP_NF_CT_PROTO_SCTP
 	tristate  'SCTP protocol connection tracking support (EXPERIMENTAL)'
 	depends on IP_NF_CONNTRACK && EXPERIMENTAL
@@ -342,6 +350,31 @@
 	  If you want to compile it as a module, say M here and read
 	  Documentation/modules.txt.  If unsure, say `N'.
 
+config IP_NF_MATCH_CONNMARK
+	tristate  'Connection mark match support'
+	depends on IP_NF_CONNTRACK_MARK && IP_NF_IPTABLES
+	help
+	  This option adds a `connmark' match, which allows you to match the
+	  connection mark value previously set for the session by `CONNMARK'. 
+	
+	  If you want to compile it as a module, say M here and read
+	  Documentation/modules.txt.  The module will be called
+	  ipt_connmark.o.  If unsure, say `N'.
+
+config IP_NF_MATCH_HASHLIMIT
+	tristate  'hashlimit match support'
+	depends on IP_NF_IPTABLES
+	help
+	  This option adds a new iptables `hashlimit' match.  
+
+	  As opposed to `limit', this match dynamically crates a hash table
+	  of limit buckets, based on your selection of source/destination
+	  ip addresses and/or ports.
+
+	  It enables you to express policies like `10kpps for any given
+	  destination IP' or `500pps from any given source IP'  with a single
+	  IPtables rule.
+
 # `filter', generic and specific targets
 config IP_NF_FILTER
 	tristate "Packet filtering"
@@ -595,6 +628,28 @@
 
   	  atm, cbq, dsmark, pfifo_fast, htb, prio
 
+	  To compile it as a module, choose M here.  If unsure, say N.
+
+config IP_NF_TARGET_CONNMARK
+	tristate  'CONNMARK target support'
+	depends on IP_NF_CONNTRACK_MARK && IP_NF_MANGLE
+	help
+	  This option adds a `CONNMARK' target, which allows one to manipulate
+	  the connection mark value.  Similar to the MARK target, but
+	  affects the connection mark value rather than the packet mark value.
+	
+	  If you want to compile it as a module, say M here and read
+	  Documentation/modules.txt.  The module will be called
+	  ipt_CONNMARK.o.  If unsure, say `N'.
+
+config IP_NF_TARGET_CLUSTERIP
+	tristate "CLUSTERIP target support (EXPERIMENTAL)"
+	depends on IP_NF_CONNTRACK_MARK && IP_NF_IPTABLES && EXPERIMENTAL
+	help
+	  The CLUSTERIP target allows you to build load-balancing clusters of
+	  network servers without having a dedicated load-balancing
+	  router/server/switch.
+	
 	  To compile it as a module, choose M here.  If unsure, say N.
 
 # raw + specific targets
diff -Nru a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
--- a/net/ipv4/netfilter/Makefile	2004-12-24 13:36:31 -08:00
+++ b/net/ipv4/netfilter/Makefile	2004-12-24 13:36:31 -08:00
@@ -46,6 +46,7 @@
 # matches
 obj-$(CONFIG_IP_NF_MATCH_HELPER) += ipt_helper.o
 obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o
+obj-$(CONFIG_IP_NF_MATCH_HASHLIMIT) += ipt_hashlimit.o
 obj-$(CONFIG_IP_NF_MATCH_SCTP) += ipt_sctp.o
 obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o
 obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o
@@ -61,6 +62,7 @@
 obj-$(CONFIG_IP_NF_MATCH_LENGTH) += ipt_length.o
 obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
 obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o
+obj-$(CONFIG_IP_NF_MATCH_CONNMARK) += ipt_connmark.o
 obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o
 obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o
 obj-$(CONFIG_IP_NF_MATCH_REALM) += ipt_realm.o
@@ -81,9 +83,11 @@
 obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o
 obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
+obj-$(CONFIG_IP_NF_TARGET_CONNMARK) += ipt_CONNMARK.o
 obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
 obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o
 obj-$(CONFIG_IP_NF_TARGET_NOTRACK) += ipt_NOTRACK.o
+obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
 
 # generic ARP tables
 obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o
diff -Nru a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
--- a/net/ipv4/netfilter/arp_tables.c	2004-12-24 13:37:44 -08:00
+++ b/net/ipv4/netfilter/arp_tables.c	2004-12-24 13:37:44 -08:00
@@ -395,7 +395,7 @@
 	return find_inlist_lock(&arpt_tables, name, "arptable_", error, mutex);
 }
 
-struct arpt_target *arpt_find_target_lock(const char *name, int *error, struct semaphore *mutex)
+static struct arpt_target *arpt_find_target_lock(const char *name, int *error, struct semaphore *mutex)
 {
 	return find_inlist_lock(&arpt_target, name, "arpt_", error, mutex);
 }
@@ -1199,7 +1199,7 @@
 	/* save number of initial entries */
 	table->private->initial_entries = table->private->number;
 
-	table->lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&table->lock);
 	list_prepend(&arpt_tables, table);
 
  unlock:
@@ -1325,7 +1325,6 @@
 EXPORT_SYMBOL(arpt_register_table);
 EXPORT_SYMBOL(arpt_unregister_table);
 EXPORT_SYMBOL(arpt_do_table);
-EXPORT_SYMBOL(arpt_find_target_lock);
 EXPORT_SYMBOL(arpt_register_target);
 EXPORT_SYMBOL(arpt_unregister_target);
 
diff -Nru a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c
--- a/net/ipv4/netfilter/ip_conntrack_amanda.c	2004-12-24 13:37:01 -08:00
+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c	2004-12-24 13:37:01 -08:00
@@ -49,7 +49,7 @@
 {
 	struct ip_conntrack_expect *exp;
 	struct ip_ct_amanda_expect *exp_amanda_info;
-	char *amp, *data, *data_limit, *tmp;
+	char *data, *data_limit, *tmp;
 	unsigned int dataoff, i;
 	u_int16_t port, len;
 
@@ -70,11 +70,9 @@
 	}
 
 	LOCK_BH(&amanda_buffer_lock);
-	amp = skb_header_pointer(skb, dataoff,
-				 skb->len - dataoff, amanda_buffer);
-	BUG_ON(amp == NULL);
-	data = amp;
-	data_limit = amp + skb->len - dataoff;
+	skb_copy_bits(skb, dataoff, amanda_buffer, skb->len - dataoff);
+	data = amanda_buffer;
+	data_limit = amanda_buffer + skb->len - dataoff;
 	*data_limit = '\0';
 
 	/* Search for the CONNECT string */
@@ -110,7 +108,7 @@
 		exp->mask.dst.u.tcp.port = 0xFFFF;
 
 		exp_amanda_info = &exp->help.exp_amanda_info;
-		exp_amanda_info->offset = tmp - amp;
+		exp_amanda_info->offset = tmp - amanda_buffer;
 		exp_amanda_info->port   = port;
 		exp_amanda_info->len    = len;
 
diff -Nru a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
--- a/net/ipv4/netfilter/ip_conntrack_core.c	2004-12-24 13:36:16 -08:00
+++ b/net/ipv4/netfilter/ip_conntrack_core.c	2004-12-24 13:36:16 -08:00
@@ -62,7 +62,6 @@
 
 /* ip_conntrack_standalone needs this */
 atomic_t ip_conntrack_count = ATOMIC_INIT(0);
-EXPORT_SYMBOL(ip_conntrack_count);
 
 void (*ip_conntrack_destroyed)(struct ip_conntrack *conntrack) = NULL;
 LIST_HEAD(ip_conntrack_expect_list);
@@ -313,6 +312,7 @@
 		}
 		kmem_cache_free(ip_conntrack_expect_cachep, ct->master);
 	}
+	CONNTRACK_STAT_INC(delete);
 	WRITE_UNLOCK(&ip_conntrack_lock);
 
 	if (master)
@@ -321,16 +321,16 @@
 	DEBUGP("destroy_conntrack: returning ct=%p to slab\n", ct);
 	kmem_cache_free(ip_conntrack_cachep, ct);
 	atomic_dec(&ip_conntrack_count);
-	CONNTRACK_STAT_INC(delete);
 }
 
 static void death_by_timeout(unsigned long ul_conntrack)
 {
 	struct ip_conntrack *ct = (void *)ul_conntrack;
 
-	CONNTRACK_STAT_INC(delete_list);
-
 	WRITE_LOCK(&ip_conntrack_lock);
+	/* Inside lock so preempt is disabled on module removal path.
+	 * Otherwise we can get spurious warnings. */
+	CONNTRACK_STAT_INC(delete_list);
 	clean_from_lists(ct);
 	WRITE_UNLOCK(&ip_conntrack_lock);
 	ip_conntrack_put(ct);
@@ -352,16 +352,14 @@
 {
 	struct ip_conntrack_tuple_hash *h;
 	unsigned int hash = hash_conntrack(tuple);
-	/* use per_cpu() to avoid multiple calls to smp_processor_id() */
-	unsigned int cpu = smp_processor_id();
 
 	MUST_BE_READ_LOCKED(&ip_conntrack_lock);
 	list_for_each_entry(h, &ip_conntrack_hash[hash], list) {
 		if (conntrack_tuple_cmp(h, tuple, ignored_conntrack)) {
-			per_cpu(ip_conntrack_stat, cpu).found++;
+			CONNTRACK_STAT_INC(found);
 			return h;
 		}
-		per_cpu(ip_conntrack_stat, cpu).searched++;
+		CONNTRACK_STAT_INC(searched);
 	}
 
 	return NULL;
@@ -436,13 +434,14 @@
 		add_timer(&ct->timeout);
 		atomic_inc(&ct->ct_general.use);
 		set_bit(IPS_CONFIRMED_BIT, &ct->status);
-		WRITE_UNLOCK(&ip_conntrack_lock);
 		CONNTRACK_STAT_INC(insert);
+		WRITE_UNLOCK(&ip_conntrack_lock);
 		return NF_ACCEPT;
 	}
 
-	WRITE_UNLOCK(&ip_conntrack_lock);
 	CONNTRACK_STAT_INC(insert_failed);
+	WRITE_UNLOCK(&ip_conntrack_lock);
+
 	return NF_DROP;
 }
 
@@ -595,6 +594,9 @@
 		__set_bit(IPS_EXPECTED_BIT, &conntrack->status);
 		conntrack->master = expected;
 		expected->sibling = conntrack;
+#if CONFIG_IP_NF_CONNTRACK_MARK
+		conntrack->mark = expected->expectant->mark;
+#endif
 		LIST_DELETE(&ip_conntrack_expect_list, expected);
 		expected->expectant->expecting--;
 		nf_conntrack_get(&master_ct(conntrack)->ct_general);
diff -Nru a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c	2004-12-24 13:37:44 -08:00
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c	2004-12-24 13:37:44 -08:00
@@ -34,7 +34,7 @@
 #define MAX_PORTS 8
 static int ports[MAX_PORTS];
 static int ports_c;
-module_param_array(ports, int, ports_c, 0400);
+module_param_array(ports, int, &ports_c, 0400);
 
 static int loose;
 module_param(loose, int, 0600);
@@ -381,6 +381,7 @@
 		   problem (DMZ machines opening holes to internal
 		   networks, or the packet filter itself). */
 		if (!loose) {
+			ip_conntrack_expect_put(exp);
 			ret = NF_ACCEPT;
 			goto out;
 		}
diff -Nru a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
--- a/net/ipv4/netfilter/ip_conntrack_irc.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv4/netfilter/ip_conntrack_irc.c	2004-12-24 13:37:18 -08:00
@@ -46,7 +46,7 @@
 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
 MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
 MODULE_LICENSE("GPL");
-module_param_array(ports, int, ports_c, 0400);
+module_param_array(ports, int, &ports_c, 0400);
 MODULE_PARM_DESC(ports, "port numbers of IRC servers");
 module_param(max_dcc_channels, int, 0400);
 MODULE_PARM_DESC(max_dcc_channels, "max number of expected DCC channels per IRC session");
@@ -65,8 +65,8 @@
 #define DEBUGP(format, args...)
 #endif
 
-int parse_dcc(char *data, char *data_end, u_int32_t * ip, u_int16_t * port,
-	      char **ad_beg_p, char **ad_end_p)
+static int parse_dcc(char *data, char *data_end, u_int32_t *ip,
+		     u_int16_t *port, char **ad_beg_p, char **ad_end_p)
 /* tries to get the ip_addr and port out of a dcc command
    return value: -1 on failure, 0 on success 
 	data		pointer to first byte of DCC command data
diff -Nru a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c	2004-12-24 13:37:30 -08:00
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c	2004-12-24 13:37:30 -08:00
@@ -273,9 +273,9 @@
  *	sCL -> sCL
  */
 /* 	     sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI	*/
-/*ack*/	   { sIV, sIV, sIV, sES, sCW, sCW, sTW, sTW, sCL, sIV },
+/*ack*/	   { sIV, sIG, sIV, sES, sCW, sCW, sTW, sTW, sCL, sIV },
 /*
- *	sSS -> sIV	ACK is invalid: we haven't seen a SYN/ACK yet.
+ *	sSS -> sIG	Might be a half-open connection.
  *	sSR -> sIV	Simultaneous open.
  *	sES -> sES	:-)
  *	sFW -> sCW	Normal close request answered by ACK.
@@ -436,7 +436,7 @@
 					state->td_scale = 14;
 				}
 				state->flags |=
-					IP_CT_TCP_STATE_FLAG_WINDOW_SCALE;
+					IP_CT_TCP_FLAG_WINDOW_SCALE;
 			}
 			ptr += opsize - 2;
 			length -= opsize;
@@ -552,8 +552,8 @@
 			 * Both sides must send the Window Scale option
 			 * to enable window scaling in either direction.
 			 */
-			if (!(sender->flags & IP_CT_TCP_STATE_FLAG_WINDOW_SCALE
-			      && receiver->flags & IP_CT_TCP_STATE_FLAG_WINDOW_SCALE))
+			if (!(sender->flags & IP_CT_TCP_FLAG_WINDOW_SCALE
+			      && receiver->flags & IP_CT_TCP_FLAG_WINDOW_SCALE))
 				sender->td_scale = 
 				receiver->td_scale = 0;
 		} else {
@@ -566,9 +566,11 @@
 			sender->td_maxwin = (win == 0 ? 1 : win);
 			sender->td_maxend = end + sender->td_maxwin;
 		}
-	} else if (state->state == TCP_CONNTRACK_SYN_SENT
-		   && dir == IP_CT_DIR_ORIGINAL
-		   && after(end, sender->td_end)) {
+	} else if (((state->state == TCP_CONNTRACK_SYN_SENT
+		     && dir == IP_CT_DIR_ORIGINAL)
+		    || (state->state == TCP_CONNTRACK_SYN_RECV
+		        && dir == IP_CT_DIR_REPLY))
+		    && after(end, sender->td_end)) {
 		/*
 		 * RFC 793: "if a TCP is reinitialized ... then it need
 		 * not wait at all; it must only be sure to use sequence 
@@ -685,7 +687,7 @@
 			"ip_ct_tcp: %s ",
 			before(end, sender->td_maxend + 1) ?
 			after(seq, sender->td_end - receiver->td_maxwin - 1) ?
-			before(ack, receiver->td_end + 1) ?
+			before(sack, receiver->td_end + 1) ?
 			after(ack, receiver->td_end - MAXACKWINDOW(sender)) ? "BUG"
 			: "ACK is under the lower bound (possibly overly delayed ACK)"
 			: "ACK is over the upper bound (ACKed data has never seen yet)"
@@ -737,7 +739,6 @@
 	return 1;
 }
  
-EXPORT_SYMBOL(ip_conntrack_tcp_update);
 #endif
 
 #define	TH_FIN	0x01
@@ -847,7 +848,9 @@
 
 	switch (new_state) {
 	case TCP_CONNTRACK_IGNORE:
-		/* Either SYN in ORIGINAL, or SYN/ACK in REPLY direction. */
+		/* Either SYN in ORIGINAL
+		 * or SYN/ACK in REPLY
+		 * or ACK in REPLY direction (half-open connection). */
 		if (index == TCP_SYNACK_SET
 		    && conntrack->proto.tcp.last_index == TCP_SYN_SET
 		    && conntrack->proto.tcp.last_dir != dir
@@ -876,7 +879,7 @@
 		WRITE_UNLOCK(&tcp_lock);
 		if (LOG_INVALID(IPPROTO_TCP))
 			nf_log_packet(PF_INET, 0, skb, NULL, NULL, 
-				  "ip_ct_tcp: invalid SYN (ignored) ");
+				  "ip_ct_tcp: invalid packet ignored ");
 		return NF_ACCEPT;
 	case TCP_CONNTRACK_MAX:
 		/* Invalid packet */
@@ -901,11 +904,12 @@
 		break;
 	case TCP_CONNTRACK_CLOSE:
 		if (index == TCP_RST_SET
-		    && test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)
-		    && conntrack->proto.tcp.last_index <= TCP_SYNACK_SET
+		    && ((test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)
+		         && conntrack->proto.tcp.last_index <= TCP_SYNACK_SET)
+		        || conntrack->proto.tcp.last_index == TCP_ACK_SET)
 		    && after(ntohl(th->ack_seq),
 		    	     conntrack->proto.tcp.last_seq)) {
-			/* Ignore RST closing down invalid SYN 
+			/* Ignore RST closing down invalid SYN or ACK
 			   we had let trough. */ 
 		    	WRITE_UNLOCK(&tcp_lock);
 			if (LOG_INVALID(IPPROTO_TCP))
diff -Nru a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c	2004-12-24 13:36:48 -08:00
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c	2004-12-24 13:36:48 -08:00
@@ -146,6 +146,11 @@
 		if (seq_printf(s, "[ASSURED] "))
 			return 1;
 
+#if defined(CONFIG_IP_NF_CONNTRACK_MARK)
+	if (seq_printf(s, "mark=%ld ", conntrack->mark))
+		return 1;
+#endif
+
 	if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
 		return 1;
 
@@ -736,6 +741,7 @@
 		goto cleanup_nothing;
 
 #ifdef CONFIG_PROC_FS
+	ret = -ENOMEM;
 	proc = proc_net_fops_create("ip_conntrack", 0440, &ct_file_ops);
 	if (!proc) goto cleanup_init;
 
@@ -816,7 +822,7 @@
 #ifdef CONFIG_PROC_FS
 	proc_net_remove("ip_conntrack_stat");
 cleanup_proc_exp:
-	proc_net_remove("ip_conntrack_exp");
+	proc_net_remove("ip_conntrack_expect");
  cleanup_proc:
 	proc_net_remove("ip_conntrack");
  cleanup_init:
@@ -903,3 +909,6 @@
 EXPORT_SYMBOL(ip_conntrack_untracked);
 EXPORT_SYMBOL_GPL(ip_conntrack_find_get);
 EXPORT_SYMBOL_GPL(ip_conntrack_put);
+#ifdef CONFIG_IP_NF_NAT_NEEDED
+EXPORT_SYMBOL(ip_conntrack_tcp_update);
+#endif
diff -Nru a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
--- a/net/ipv4/netfilter/ip_conntrack_tftp.c	2004-12-24 13:36:34 -08:00
+++ b/net/ipv4/netfilter/ip_conntrack_tftp.c	2004-12-24 13:36:34 -08:00
@@ -28,7 +28,7 @@
 #define MAX_PORTS 8
 static int ports[MAX_PORTS];
 static int ports_c;
-module_param_array(ports, int, ports_c, 0400);
+module_param_array(ports, int, &ports_c, 0400);
 MODULE_PARM_DESC(ports, "port numbers of tftp servers");
 
 #if 0
diff -Nru a/net/ipv4/netfilter/ip_fw_compat.c b/net/ipv4/netfilter/ip_fw_compat.c
--- a/net/ipv4/netfilter/ip_fw_compat.c	2004-12-24 13:36:47 -08:00
+++ b/net/ipv4/netfilter/ip_fw_compat.c	2004-12-24 13:36:47 -08:00
@@ -69,7 +69,7 @@
 	/* Assume worse case: any hook could change packet */
 	(*pskb)->nfcache |= NFC_UNKNOWN | NFC_ALTERED;
 	if ((*pskb)->ip_summed == CHECKSUM_HW)
-		if (skb_checksum_help(pskb, (out == NULL)))
+		if (skb_checksum_help(*pskb, (out == NULL)))
 			return NF_DROP;
 
 	switch (hooknum) {
diff -Nru a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
--- a/net/ipv4/netfilter/ip_nat_core.c	2004-12-24 13:36:19 -08:00
+++ b/net/ipv4/netfilter/ip_nat_core.c	2004-12-24 13:36:19 -08:00
@@ -118,31 +118,27 @@
 	return ip_conntrack_tuple_taken(&reply, ignored_conntrack);
 }
 
-/* Does tuple + the source manip come within the range mr */
+/* If we source map this tuple so reply looks like reply_tuple, will
+ * that meet the constraints of mr. */
 static int
 in_range(const struct ip_conntrack_tuple *tuple,
-	 const struct ip_conntrack_manip *manip,
 	 const struct ip_nat_multi_range *mr)
 {
 	struct ip_nat_protocol *proto = ip_nat_find_proto(tuple->dst.protonum);
 	unsigned int i;
-	struct ip_conntrack_tuple newtuple = { *manip, tuple->dst };
 
 	for (i = 0; i < mr->rangesize; i++) {
-		/* If we are allowed to map IPs, then we must be in the
-		   range specified, otherwise we must be unchanged. */
+		/* If we are supposed to map IPs, then we must be in the
+		   range specified. */
 		if (mr->range[i].flags & IP_NAT_RANGE_MAP_IPS) {
-			if (ntohl(newtuple.src.ip) < ntohl(mr->range[i].min_ip)
-			    || (ntohl(newtuple.src.ip)
+			if (ntohl(tuple->src.ip) < ntohl(mr->range[i].min_ip)
+			    || (ntohl(tuple->src.ip)
 				> ntohl(mr->range[i].max_ip)))
 				continue;
-		} else {
-			if (newtuple.src.ip != tuple->src.ip)
-				continue;
 		}
 
 		if (!(mr->range[i].flags & IP_NAT_RANGE_PROTO_SPECIFIED)
-		    || proto->in_range(&newtuple, IP_NAT_MANIP_SRC,
+		    || proto->in_range(tuple, IP_NAT_MANIP_SRC,
 				       &mr->range[i].min, &mr->range[i].max))
 			return 1;
 	}
@@ -150,33 +146,40 @@
 }
 
 static inline int
-src_cmp(const struct ip_conntrack *ct,
-	const struct ip_conntrack_tuple *tuple,
-	const struct ip_nat_multi_range *mr)
+same_src(const struct ip_conntrack *ct,
+	 const struct ip_conntrack_tuple *tuple)
 {
 	return (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum
 		== tuple->dst.protonum
 		&& ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip
 		== tuple->src.ip
 		&& ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all
-		== tuple->src.u.all
-		&& in_range(tuple,
-			    &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src, mr));
+		== tuple->src.u.all);
 }
 
 /* Only called for SRC manip */
-static struct ip_conntrack_manip *
+static int
 find_appropriate_src(const struct ip_conntrack_tuple *tuple,
+		     struct ip_conntrack_tuple *result,
 		     const struct ip_nat_multi_range *mr)
 {
 	unsigned int h = hash_by_src(&tuple->src, tuple->dst.protonum);
 	struct ip_conntrack *ct;
 
 	MUST_BE_READ_LOCKED(&ip_nat_lock);
-	list_for_each_entry(ct, &bysource[h], nat.info.bysource)
-		if (src_cmp(ct, tuple, mr))
-			return &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src;
-	return NULL;
+
+	list_for_each_entry(ct, &bysource[h], nat.info.bysource) {
+		if (same_src(ct, tuple)) {
+			/* Copy source part from reply tuple. */
+			invert_tuplepr(result,
+				       &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
+			result->dst = tuple->dst;
+
+			if (in_range(result, mr))
+				return 1;
+		}
+	}
+	return 0;
 }
 
 #ifdef CONFIG_IP_NF_NAT_LOCAL
@@ -393,13 +396,7 @@
 	   So far, we don't do local source mappings, so multiple
 	   manips not an issue.  */
 	if (hooknum == NF_IP_POST_ROUTING) {
-		struct ip_conntrack_manip *manip;
-
-		manip = find_appropriate_src(orig_tuple, mr);
-		if (manip) {
-			/* Apply same source manipulation. */
-			*tuple = ((struct ip_conntrack_tuple)
-				  { *manip, orig_tuple->dst });
+		if (find_appropriate_src(orig_tuple, tuple, mr)) {
 			DEBUGP("get_unique_tuple: Found current src map\n");
 			if (!ip_nat_used_tuple(tuple, conntrack))
 				return 1;
@@ -687,7 +684,7 @@
 	iph = (void *)(*pskb)->data + iphdroff;
 
 	/* Manipulate protcol part. */
-	if (!ip_nat_find_proto(proto)->manip_pkt(pskb, iphdroff + iph->ihl*4,
+	if (!ip_nat_find_proto(proto)->manip_pkt(pskb, iphdroff,
 	                                         manip, maniptype))
 		return 0;
 
diff -Nru a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c
--- a/net/ipv4/netfilter/ip_nat_ftp.c	2004-12-24 13:37:01 -08:00
+++ b/net/ipv4/netfilter/ip_nat_ftp.c	2004-12-24 13:37:01 -08:00
@@ -34,7 +34,7 @@
 static int ports[MAX_PORTS];
 static int ports_c;
 
-module_param_array(ports, int, ports_c, 0400);
+module_param_array(ports, int, &ports_c, 0400);
 
 /* FIXME: Time out? --RR */
 
diff -Nru a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc.c
--- a/net/ipv4/netfilter/ip_nat_irc.c	2004-12-24 13:37:32 -08:00
+++ b/net/ipv4/netfilter/ip_nat_irc.c	2004-12-24 13:37:32 -08:00
@@ -42,7 +42,7 @@
 MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
 MODULE_DESCRIPTION("IRC (DCC) NAT helper");
 MODULE_LICENSE("GPL");
-module_param_array(ports, int, ports_c, 0400);
+module_param_array(ports, int, &ports_c, 0400);
 MODULE_PARM_DESC(ports, "port numbers of IRC servers");
 
 /* FIXME: Time out? --RR */
diff -Nru a/net/ipv4/netfilter/ip_nat_proto_icmp.c b/net/ipv4/netfilter/ip_nat_proto_icmp.c
--- a/net/ipv4/netfilter/ip_nat_proto_icmp.c	2004-12-24 13:36:34 -08:00
+++ b/net/ipv4/netfilter/ip_nat_proto_icmp.c	2004-12-24 13:36:34 -08:00
@@ -53,11 +53,13 @@
 
 static int
 icmp_manip_pkt(struct sk_buff **pskb,
-	       unsigned int hdroff,
+	       unsigned int iphdroff,
 	       const struct ip_conntrack_manip *manip,
 	       enum ip_nat_manip_type maniptype)
 {
+	struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
 	struct icmphdr *hdr;
+	unsigned int hdroff = iphdroff + iph->ihl*4;
 
 	if (!skb_ip_make_writable(pskb, hdroff + sizeof(*hdr)))
 		return 0;
diff -Nru a/net/ipv4/netfilter/ip_nat_proto_tcp.c b/net/ipv4/netfilter/ip_nat_proto_tcp.c
--- a/net/ipv4/netfilter/ip_nat_proto_tcp.c	2004-12-24 13:36:17 -08:00
+++ b/net/ipv4/netfilter/ip_nat_proto_tcp.c	2004-12-24 13:36:17 -08:00
@@ -84,11 +84,13 @@
 
 static int
 tcp_manip_pkt(struct sk_buff **pskb,
-	      unsigned int hdroff,
+	      unsigned int iphdroff,
 	      const struct ip_conntrack_manip *manip,
 	      enum ip_nat_manip_type maniptype)
 {
+	struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
 	struct tcphdr *hdr;
+	unsigned int hdroff = iphdroff + iph->ihl*4;
 	u_int32_t oldip;
 	u_int16_t *portptr, oldport;
 	int hdrsize = 8; /* TCP connection tracking guarantees this much */
@@ -106,11 +108,11 @@
 
 	if (maniptype == IP_NAT_MANIP_SRC) {
 		/* Get rid of src ip and src pt */
-		oldip = (*pskb)->nh.iph->saddr;
+		oldip = iph->saddr;
 		portptr = &hdr->source;
 	} else {
 		/* Get rid of dst ip and dst pt */
-		oldip = (*pskb)->nh.iph->daddr;
+		oldip = iph->daddr;
 		portptr = &hdr->dest;
 	}
 
diff -Nru a/net/ipv4/netfilter/ip_nat_proto_udp.c b/net/ipv4/netfilter/ip_nat_proto_udp.c
--- a/net/ipv4/netfilter/ip_nat_proto_udp.c	2004-12-24 13:36:19 -08:00
+++ b/net/ipv4/netfilter/ip_nat_proto_udp.c	2004-12-24 13:36:19 -08:00
@@ -83,11 +83,13 @@
 
 static int
 udp_manip_pkt(struct sk_buff **pskb,
-	      unsigned int hdroff,
+	      unsigned int iphdroff,
 	      const struct ip_conntrack_manip *manip,
 	      enum ip_nat_manip_type maniptype)
 {
+	struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
 	struct udphdr *hdr;
+	unsigned int hdroff = iphdroff + iph->ihl*4;
 	u_int32_t oldip;
 	u_int16_t *portptr;
 
@@ -97,11 +99,11 @@
 	hdr = (void *)(*pskb)->data + hdroff;
 	if (maniptype == IP_NAT_MANIP_SRC) {
 		/* Get rid of src ip and src pt */
-		oldip = (*pskb)->nh.iph->saddr;
+		oldip = iph->saddr;
 		portptr = &hdr->source;
 	} else {
 		/* Get rid of dst ip and dst pt */
-		oldip = (*pskb)->nh.iph->daddr;
+		oldip = iph->daddr;
 		portptr = &hdr->dest;
 	}
 	if (hdr->check) /* 0 is a special case meaning no checksum */
diff -Nru a/net/ipv4/netfilter/ip_nat_proto_unknown.c b/net/ipv4/netfilter/ip_nat_proto_unknown.c
--- a/net/ipv4/netfilter/ip_nat_proto_unknown.c	2004-12-24 13:36:55 -08:00
+++ b/net/ipv4/netfilter/ip_nat_proto_unknown.c	2004-12-24 13:36:55 -08:00
@@ -39,7 +39,7 @@
 
 static int
 unknown_manip_pkt(struct sk_buff **pskb,
-		  unsigned int hdroff,
+		  unsigned int iphdroff,
 		  const struct ip_conntrack_manip *manip,
 		  enum ip_nat_manip_type maniptype)
 {
diff -Nru a/net/ipv4/netfilter/ip_nat_rule.c b/net/ipv4/netfilter/ip_nat_rule.c
--- a/net/ipv4/netfilter/ip_nat_rule.c	2004-12-24 13:36:48 -08:00
+++ b/net/ipv4/netfilter/ip_nat_rule.c	2004-12-24 13:36:48 -08:00
@@ -59,8 +59,8 @@
 	struct ipt_replace repl;
 	struct ipt_standard entries[3];
 	struct ipt_error term;
-} nat_initial_table __initdata
-= { { "nat", NAT_VALID_HOOKS, 4,
+} nat_initial_table = {
+    { "nat", NAT_VALID_HOOKS, 4,
       sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error),
       { [NF_IP_PRE_ROUTING] = 0,
 	[NF_IP_POST_ROUTING] = sizeof(struct ipt_standard),
diff -Nru a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
--- a/net/ipv4/netfilter/ip_nat_standalone.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv4/netfilter/ip_nat_standalone.c	2004-12-24 13:37:18 -08:00
@@ -86,7 +86,7 @@
 
 	/* If we had a hardware checksum before, it's now invalid */
 	if ((*pskb)->ip_summed == CHECKSUM_HW)
-		if (skb_checksum_help(pskb, (out == NULL)))
+		if (skb_checksum_help(*pskb, (out == NULL)))
 			return NF_DROP;
 
 	ct = ip_conntrack_get(*pskb, &ctinfo);
diff -Nru a/net/ipv4/netfilter/ip_nat_tftp.c b/net/ipv4/netfilter/ip_nat_tftp.c
--- a/net/ipv4/netfilter/ip_nat_tftp.c	2004-12-24 13:36:33 -08:00
+++ b/net/ipv4/netfilter/ip_nat_tftp.c	2004-12-24 13:36:33 -08:00
@@ -42,7 +42,7 @@
 
 static int ports[MAX_PORTS];
 static int ports_c = 0;
-module_param_array(ports, int, ports_c, 0400);
+module_param_array(ports, int, &ports_c, 0400);
 MODULE_PARM_DESC(ports, "port numbers of tftp servers");
 
 #if 0
diff -Nru a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
--- a/net/ipv4/netfilter/ip_queue.c	2004-12-24 13:37:43 -08:00
+++ b/net/ipv4/netfilter/ip_queue.c	2004-12-24 13:37:43 -08:00
@@ -162,6 +162,7 @@
 __ipq_reset(void)
 {
 	peer_pid = 0;
+	net_disable_timestamp();
 	__ipq_set_mode(IPQ_COPY_NONE, 0);
 	__ipq_flush(NF_DROP);
 }
@@ -257,7 +258,8 @@
 	}
 	
 	if (data_len)
-		memcpy(pmsg->payload, entry->skb->data, data_len);
+		if (skb_copy_bits(entry->skb, 0, pmsg->payload, data_len))
+			BUG();
 		
 	nlh->nlmsg_len = skb->tail - old_tail;
 	return skb;
@@ -362,6 +364,8 @@
 		}
 		skb_put(e->skb, diff);
 	}
+	if (!skb_ip_make_writable(&e->skb, v->data_len))
+		return -ENOMEM;
 	memcpy(e->skb->data, v->payload, v->data_len);
 	e->skb->nfcache |= NFC_ALTERED;
 
@@ -514,9 +518,10 @@
 			write_unlock_bh(&queue_lock);
 			RCV_SKB_FAIL(-EBUSY);
 		}
-	}
-	else
+	} else {
+		net_enable_timestamp();
 		peer_pid = pid;
+	}
 		
 	write_unlock_bh(&queue_lock);
 	
diff -Nru a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
--- a/net/ipv4/netfilter/ip_tables.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv4/netfilter/ip_tables.c	2004-12-24 13:36:31 -08:00
@@ -471,12 +471,24 @@
 	return find_inlist_lock(&ipt_match, name, "ipt_", error, mutex);
 }
 
-struct ipt_target *
+static struct ipt_target *
 ipt_find_target_lock(const char *name, int *error, struct semaphore *mutex)
 {
 	return find_inlist_lock(&ipt_target, name, "ipt_", error, mutex);
 }
 
+struct ipt_target *
+__ipt_find_target_lock(const char *name, int *error)
+{
+	return ipt_find_target_lock(name,error,&ipt_mutex);
+}
+
+void
+__ipt_mutex_up(void)
+{
+	up(&ipt_mutex);
+}
+
 /* All zeroes == unconditional rule. */
 static inline int
 unconditional(const struct ipt_ip *ip)
@@ -1280,7 +1292,7 @@
 			       sizeof(info.underflow));
 			info.num_entries = t->private->number;
 			info.size = t->private->size;
-			strcpy(info.name, name);
+			memcpy(info.name, name, sizeof(info.name));
 
 			if (copy_to_user(user, &info, *len) != 0)
 				ret = -EFAULT;
@@ -1418,7 +1430,7 @@
 	/* save number of initial entries */
 	table->private->initial_entries = table->private->number;
 
-	table->lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&table->lock);
 	list_prepend(&ipt_tables, table);
 
  unlock:
@@ -1877,7 +1889,8 @@
 EXPORT_SYMBOL(ipt_do_table);
 EXPORT_SYMBOL(ipt_register_target);
 EXPORT_SYMBOL(ipt_unregister_target);
-EXPORT_SYMBOL(ipt_find_target_lock);
+EXPORT_SYMBOL_GPL(__ipt_find_target_lock);
+EXPORT_SYMBOL_GPL(__ipt_mutex_up);
 
 module_init(init);
 module_exit(fini);
diff -Nru a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,760 @@
+/* Cluster IP hashmark target 
+ * (C) 2003-2004 by Harald Welte <laforge@netfilter.org>
+ * based on ideas of Fabio Olive Leite <olive@unixforge.org>
+ *
+ * Development of this code funded by SuSE Linux AG, http://www.suse.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.
+ *
+ */
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/proc_fs.h>
+#include <linux/jhash.h>
+#include <linux/skbuff.h>
+#include <linux/ip.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <linux/icmp.h>
+#include <linux/if_arp.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+#include <net/checksum.h>
+
+#include <linux/netfilter_arp.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv4/ipt_CLUSTERIP.h>
+#include <linux/netfilter_ipv4/ip_conntrack.h>
+
+#define CLUSTERIP_VERSION "0.6"
+
+#define DEBUG_CLUSTERIP
+
+#ifdef DEBUG_CLUSTERIP
+#define DEBUGP	printk
+#else
+#define DEBUGP
+#endif
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
+MODULE_DESCRIPTION("iptables target for CLUSTERIP");
+
+struct clusterip_config {
+	struct list_head list;			/* list of all configs */
+	atomic_t refcount;			/* reference count */
+
+	u_int32_t clusterip;			/* the IP address */
+	u_int8_t clustermac[ETH_ALEN];		/* the MAC address */
+	struct net_device *dev;			/* device */
+	u_int16_t num_total_nodes;		/* total number of nodes */
+	u_int16_t num_local_nodes;		/* number of local nodes */
+	u_int16_t local_nodes[CLUSTERIP_MAX_NODES];	/* node number array */
+
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *pde;		/* proc dir entry */
+#endif
+	enum clusterip_hashmode hash_mode;	/* which hashing mode */
+	u_int32_t hash_initval;			/* hash initialization */
+};
+
+static LIST_HEAD(clusterip_configs);
+
+/* clusterip_lock protects the clusterip_configs list _AND_ the configurable
+ * data within all structurses (num_local_nodes, local_nodes[]) */
+DECLARE_RWLOCK(clusterip_lock);
+
+#ifdef CONFIG_PROC_FS
+static struct file_operations clusterip_proc_fops;
+static struct proc_dir_entry *clusterip_procdir;
+#endif
+
+static inline void
+clusterip_config_get(struct clusterip_config *c) {
+	atomic_inc(&c->refcount);
+}
+
+static inline void
+clusterip_config_put(struct clusterip_config *c) {
+	if (atomic_dec_and_test(&c->refcount)) {
+		WRITE_LOCK(&clusterip_lock);
+		list_del(&c->list);
+		WRITE_UNLOCK(&clusterip_lock);
+		dev_mc_delete(c->dev, c->clustermac, ETH_ALEN, 0);
+		dev_put(c->dev);
+		kfree(c);
+	}
+}
+
+
+static struct clusterip_config *
+__clusterip_config_find(u_int32_t clusterip)
+{
+	struct list_head *pos;
+
+	MUST_BE_READ_LOCKED(&clusterip_lock);
+	list_for_each(pos, &clusterip_configs) {
+		struct clusterip_config *c = list_entry(pos, 
+					struct clusterip_config, list);
+		if (c->clusterip == clusterip) {
+			return c;
+		}
+	}
+
+	return NULL;
+}
+
+static inline struct clusterip_config *
+clusterip_config_find_get(u_int32_t clusterip)
+{
+	struct clusterip_config *c;
+
+	READ_LOCK(&clusterip_lock);
+	c = __clusterip_config_find(clusterip);
+	if (!c) {
+		READ_UNLOCK(&clusterip_lock);
+		return NULL;
+	}
+	atomic_inc(&c->refcount);
+	READ_UNLOCK(&clusterip_lock);
+
+	return c;
+}
+
+static struct clusterip_config *
+clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip,
+			struct net_device *dev)
+{
+	struct clusterip_config *c;
+	char buffer[16];
+
+	c = kmalloc(sizeof(*c), GFP_ATOMIC);
+	if (!c)
+		return NULL;
+
+	memset(c, 0, sizeof(*c));
+	c->dev = dev;
+	c->clusterip = ip;
+	memcpy(&c->clustermac, &i->clustermac, ETH_ALEN);
+	c->num_total_nodes = i->num_total_nodes;
+	c->num_local_nodes = i->num_local_nodes;
+	memcpy(&c->local_nodes, &i->local_nodes, sizeof(&c->local_nodes));
+	c->hash_mode = i->hash_mode;
+	c->hash_initval = i->hash_initval;
+	atomic_set(&c->refcount, 1);
+
+#ifdef CONFIG_PROC_FS
+	/* create proc dir entry */
+	sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip));
+	c->pde = create_proc_entry(buffer, S_IWUSR|S_IRUSR, clusterip_procdir);
+	if (!c->pde) {
+		kfree(c);
+		return NULL;
+	}
+	c->pde->proc_fops = &clusterip_proc_fops;
+	c->pde->data = c;
+#endif
+
+	WRITE_LOCK(&clusterip_lock);
+	list_add(&c->list, &clusterip_configs);
+	WRITE_UNLOCK(&clusterip_lock);
+
+	return c;
+}
+
+static int
+clusterip_add_node(struct clusterip_config *c, u_int16_t nodenum)
+{
+	int i;
+
+	WRITE_LOCK(&clusterip_lock);
+
+	if (c->num_local_nodes >= CLUSTERIP_MAX_NODES
+	    || nodenum > CLUSTERIP_MAX_NODES) {
+		WRITE_UNLOCK(&clusterip_lock);
+		return 1;
+	}
+
+	/* check if we alrady have this number in our array */
+	for (i = 0; i < c->num_local_nodes; i++) {
+		if (c->local_nodes[i] == nodenum) {
+			WRITE_UNLOCK(&clusterip_lock);
+			return 1;
+		}
+	}
+
+	c->local_nodes[c->num_local_nodes++] = nodenum;
+
+	WRITE_UNLOCK(&clusterip_lock);
+	return 0;
+}
+
+static int
+clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
+{
+	int i;
+
+	WRITE_LOCK(&clusterip_lock);
+
+	if (c->num_local_nodes <= 1 || nodenum > CLUSTERIP_MAX_NODES) {
+		WRITE_UNLOCK(&clusterip_lock);
+		return 1;
+	}
+		
+	for (i = 0; i < c->num_local_nodes; i++) {
+		if (c->local_nodes[i] == nodenum) {
+			int size = sizeof(u_int16_t)*(c->num_local_nodes-(i+1));
+			memmove(&c->local_nodes[i], &c->local_nodes[i+1], size);
+			c->num_local_nodes--;
+			WRITE_UNLOCK(&clusterip_lock);
+			return 0;
+		}
+	}
+
+	WRITE_UNLOCK(&clusterip_lock);
+	return 1;
+}
+
+static inline u_int32_t
+clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
+{
+	struct iphdr *iph = skb->nh.iph;
+	unsigned long hashval;
+	u_int16_t sport, dport;
+	struct tcphdr *th;
+	struct udphdr *uh;
+	struct icmphdr *ih;
+
+	switch (iph->protocol) {
+	case IPPROTO_TCP:
+		th = (void *)iph+iph->ihl*4;
+		sport = ntohs(th->source);
+		dport = ntohs(th->dest);
+		break;
+	case IPPROTO_UDP:
+		uh = (void *)iph+iph->ihl*4;
+		sport = ntohs(uh->source);
+		dport = ntohs(uh->dest);
+		break;
+	case IPPROTO_ICMP:
+		ih = (void *)iph+iph->ihl*4;
+		sport = ntohs(ih->un.echo.id);
+		dport = (ih->type<<8)|ih->code;
+		break;
+	default:
+		if (net_ratelimit()) {
+			printk(KERN_NOTICE "CLUSTERIP: unknown protocol `%u'\n",
+				iph->protocol);
+		}
+		sport = dport = 0;
+	}
+
+	switch (config->hash_mode) {
+	case CLUSTERIP_HASHMODE_SIP:
+		hashval = jhash_1word(ntohl(iph->saddr),
+				      config->hash_initval);
+		break;
+	case CLUSTERIP_HASHMODE_SIP_SPT:
+		hashval = jhash_2words(ntohl(iph->saddr), sport, 
+				       config->hash_initval);
+		break;
+	case CLUSTERIP_HASHMODE_SIP_SPT_DPT:
+		hashval = jhash_3words(ntohl(iph->saddr), sport, dport,
+				       config->hash_initval);
+		break;
+	default:
+		/* to make gcc happy */
+		hashval = 0;
+		/* This cannot happen, unless the check function wasn't called
+		 * at rule load time */
+		printk("CLUSTERIP: unknown mode `%u'\n", config->hash_mode);
+		BUG();
+		break;
+	}
+
+	/* node numbers are 1..n, not 0..n */
+	return ((hashval % config->num_total_nodes)+1);
+}
+
+static inline int
+clusterip_responsible(struct clusterip_config *config, u_int32_t hash)
+{
+	int i;
+
+	READ_LOCK(&clusterip_lock);
+
+	if (config->num_local_nodes == 0) {
+		READ_UNLOCK(&clusterip_lock);
+		return 0;
+	}
+
+	for (i = 0; i < config->num_local_nodes; i++) {
+		if (config->local_nodes[i] == hash) {
+			READ_UNLOCK(&clusterip_lock);
+			return 1;
+		}
+	}
+
+	READ_UNLOCK(&clusterip_lock);
+
+	return 0;
+}
+
+/*********************************************************************** 
+ * IPTABLES TARGET 
+ ***********************************************************************/
+
+static unsigned int
+target(struct sk_buff **pskb,
+       const struct net_device *in,
+       const struct net_device *out,
+       unsigned int hooknum,
+       const void *targinfo,
+       void *userinfo)
+{
+	const struct ipt_clusterip_tgt_info *cipinfo = targinfo;
+	enum ip_conntrack_info ctinfo;
+	struct ip_conntrack *ct = ip_conntrack_get((*pskb), &ctinfo);
+	u_int32_t hash;
+
+	/* don't need to clusterip_config_get() here, since refcount
+	 * is only decremented by destroy() - and ip_tables guarantees
+	 * that the ->target() function isn't called after ->destroy() */
+
+	if (!ct) {
+		printk(KERN_ERR "CLUSTERIP: no conntrack!\n");
+			/* FIXME: need to drop invalid ones, since replies
+			 * to outgoing connections of other nodes will be 
+			 * marked as INVALID */
+		return NF_DROP;
+	}
+
+	/* special case: ICMP error handling. conntrack distinguishes between
+	 * error messages (RELATED) and information requests (see below) */
+	if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP
+	    && (ctinfo == IP_CT_RELATED 
+		|| ctinfo == IP_CT_IS_REPLY+IP_CT_IS_REPLY))
+		return IPT_CONTINUE;
+
+	/* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO, 
+	 * TIMESTAMP, INFO_REQUEST or ADDRESS type icmp packets from here
+	 * on, which all have an ID field [relevant for hashing]. */
+
+	hash = clusterip_hashfn(*pskb, cipinfo->config);
+
+	switch (ctinfo) {
+		case IP_CT_NEW:
+			ct->mark = hash;
+			break;
+		case IP_CT_RELATED:
+		case IP_CT_RELATED+IP_CT_IS_REPLY:
+			/* FIXME: we don't handle expectations at the
+			 * moment.  they can arrive on a different node than
+			 * the master connection (e.g. FTP passive mode) */
+		case IP_CT_ESTABLISHED:
+		case IP_CT_ESTABLISHED+IP_CT_IS_REPLY:
+			break;
+		default:
+			break;
+	}
+
+#ifdef DEBUG_CLUSTERP
+	DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
+#endif
+	DEBUGP("hash=%u ct_hash=%lu ", hash, ct->mark);
+	if (!clusterip_responsible(cipinfo->config, hash)) {
+		DEBUGP("not responsible\n");
+		return NF_DROP;
+	}
+	DEBUGP("responsible\n");
+
+	/* despite being received via linklayer multicast, this is
+	 * actually a unicast IP packet. TCP doesn't like PACKET_MULTICAST */
+	(*pskb)->pkt_type = PACKET_HOST;
+
+	return IPT_CONTINUE;
+}
+
+static int
+checkentry(const char *tablename,
+	   const struct ipt_entry *e,
+           void *targinfo,
+           unsigned int targinfosize,
+           unsigned int hook_mask)
+{
+	struct ipt_clusterip_tgt_info *cipinfo = targinfo;
+
+	struct clusterip_config *config;
+
+	if (targinfosize != IPT_ALIGN(sizeof(struct ipt_clusterip_tgt_info))) {
+		printk(KERN_WARNING "CLUSTERIP: targinfosize %u != %Zu\n",
+		       targinfosize,
+		       IPT_ALIGN(sizeof(struct ipt_clusterip_tgt_info)));
+		return 0;
+	}
+
+	if (cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP &&
+	    cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP_SPT &&
+	    cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP_SPT_DPT) {
+		printk(KERN_WARNING "CLUSTERIP: unknown mode `%u'\n",
+			cipinfo->hash_mode);
+		return 0;
+
+	}
+	if (e->ip.dmsk.s_addr != 0xffffffff
+	    || e->ip.dst.s_addr == 0) {
+		printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n");
+		return 0;
+	}
+
+	/* FIXME: further sanity checks */
+
+	config = clusterip_config_find_get(e->ip.dst.s_addr);
+	if (!config) {
+		if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) {
+			printk(KERN_WARNING "CLUSTERIP: no config found for %u.%u.%u.%u, need 'new'\n", NIPQUAD(e->ip.dst.s_addr));
+			return 0;
+		} else {
+			struct net_device *dev;
+
+			if (e->ip.iniface[0] == '\0') {
+				printk(KERN_WARNING "CLUSTERIP: Please specify an interface name\n");
+				return 0;
+			}
+
+			dev = dev_get_by_name(e->ip.iniface);
+			if (!dev) {
+				printk(KERN_WARNING "CLUSTERIP: no such interface %s\n", e->ip.iniface);
+				return 0;
+			}
+
+			config = clusterip_config_init(cipinfo, 
+							e->ip.dst.s_addr, dev);
+			if (!config) {
+				printk(KERN_WARNING "CLUSTERIP: cannot allocate config\n");
+				dev_put(dev);
+				return 0;
+			}
+			dev_mc_add(config->dev,config->clustermac, ETH_ALEN, 0);
+		}
+	}
+
+	cipinfo->config = config;
+
+	return 1;
+}
+
+/* drop reference count of cluster config when rule is deleted */
+static void destroy(void *matchinfo, unsigned int matchinfosize)
+{
+	struct ipt_clusterip_tgt_info *cipinfo = matchinfo;
+
+	/* we first remove the proc entry and then drop the reference
+	 * count.  In case anyone still accesses the file, the open/close
+	 * functions are also incrementing the refcount on their own */
+#ifdef CONFIG_PROC_FS
+	remove_proc_entry(cipinfo->config->pde->name,
+			  cipinfo->config->pde->parent);
+#endif
+	clusterip_config_put(cipinfo->config);
+}
+
+static struct ipt_target clusterip_tgt = { 
+	.name = "CLUSTERIP",
+	.target = &target, 
+	.checkentry = &checkentry, 
+	.destroy = &destroy,
+	.me = THIS_MODULE
+};
+
+
+/*********************************************************************** 
+ * ARP MANGLING CODE 
+ ***********************************************************************/
+
+/* hardcoded for 48bit ethernet and 32bit ipv4 addresses */
+struct arp_payload {
+	u_int8_t src_hw[ETH_ALEN];
+	u_int32_t src_ip;
+	u_int8_t dst_hw[ETH_ALEN];
+	u_int32_t dst_ip;
+} __attribute__ ((packed));
+
+#ifdef CLUSTERIP_DEBUG
+static void arp_print(struct arp_payload *payload) 
+{
+#define HBUFFERLEN 30
+	char hbuffer[HBUFFERLEN];
+	int j,k;
+	const char hexbuf[]= "0123456789abcdef";
+
+	for (k=0, j=0; k < HBUFFERLEN-3 && j < ETH_ALEN; j++) {
+		hbuffer[k++]=hexbuf[(payload->src_hw[j]>>4)&15];
+		hbuffer[k++]=hexbuf[payload->src_hw[j]&15];
+		hbuffer[k++]=':';
+	}
+	hbuffer[--k]='\0';
+
+	printk("src %u.%u.%u.%u@%s, dst %u.%u.%u.%u\n", 
+		NIPQUAD(payload->src_ip), hbuffer,
+		NIPQUAD(payload->dst_ip));
+}
+#endif
+
+static unsigned int
+arp_mangle(unsigned int hook,
+	   struct sk_buff **pskb,
+	   const struct net_device *in,
+	   const struct net_device *out,
+	   int (*okfn)(struct sk_buff *))
+{
+	struct arphdr *arp = (*pskb)->nh.arph;
+	struct arp_payload *payload;
+	struct clusterip_config *c;
+
+	/* we don't care about non-ethernet and non-ipv4 ARP */
+	if (arp->ar_hrd != htons(ARPHRD_ETHER)
+	    || arp->ar_pro != htons(ETH_P_IP)
+	    || arp->ar_pln != 4 || arp->ar_hln != ETH_ALEN)
+		return NF_ACCEPT;
+
+	/* we only want to mangle arp replies */
+	if (arp->ar_op != htons(ARPOP_REPLY))
+		return NF_ACCEPT;
+
+	payload = (void *)(arp+1);
+
+	/* if there is no clusterip configuration for the arp reply's 
+	 * source ip, we don't want to mangle it */
+	c = clusterip_config_find_get(payload->src_ip);
+	if (!c)
+		return NF_ACCEPT;
+
+	/* normally the linux kernel always replies to arp queries of 
+	 * addresses on different interfacs.  However, in the CLUSTERIP case
+	 * this wouldn't work, since we didn't subscribe the mcast group on
+	 * other interfaces */
+	if (c->dev != out) {
+		DEBUGP("CLUSTERIP: not mangling arp reply on different "
+		       "interface: cip'%s'-skb'%s'\n", c->dev->name, out->name);
+		clusterip_config_put(c);
+		return NF_ACCEPT;
+	}
+
+	/* mangle reply hardware address */
+	memcpy(payload->src_hw, c->clustermac, arp->ar_hln);
+
+#ifdef CLUSTERIP_DEBUG
+	DEBUGP(KERN_DEBUG "CLUSTERIP mangled arp reply: ");
+	arp_print(payload);
+#endif
+
+	clusterip_config_put(c);
+
+	return NF_ACCEPT;
+}
+
+static struct nf_hook_ops cip_arp_ops = {
+	.hook = arp_mangle,
+	.pf = NF_ARP,
+	.hooknum = NF_ARP_OUT,
+	.priority = -1
+};
+
+/*********************************************************************** 
+ * PROC DIR HANDLING 
+ ***********************************************************************/
+
+#ifdef CONFIG_PROC_FS
+
+static void *clusterip_seq_start(struct seq_file *s, loff_t *pos)
+{
+	struct proc_dir_entry *pde = s->private;
+	struct clusterip_config *c = pde->data;
+	unsigned int *nodeidx;
+
+	READ_LOCK(&clusterip_lock);
+	if (*pos >= c->num_local_nodes)
+		return NULL;
+
+	nodeidx = kmalloc(sizeof(unsigned int), GFP_KERNEL);
+	if (!nodeidx)
+		return ERR_PTR(-ENOMEM);
+
+	*nodeidx = *pos;
+	return nodeidx;
+}
+
+static void *clusterip_seq_next(struct seq_file *s, void *v, loff_t *pos)
+{
+	struct proc_dir_entry *pde = s->private;
+	struct clusterip_config *c = pde->data;
+	unsigned int *nodeidx = (unsigned int *)v;
+
+	*pos = ++(*nodeidx);
+	if (*pos >= c->num_local_nodes) {
+		kfree(v);
+		return NULL;
+	}
+	return nodeidx;
+}
+
+static void clusterip_seq_stop(struct seq_file *s, void *v)
+{
+	kfree(v);
+
+	READ_UNLOCK(&clusterip_lock);
+}
+
+static int clusterip_seq_show(struct seq_file *s, void *v)
+{
+	struct proc_dir_entry *pde = s->private;
+	struct clusterip_config *c = pde->data;
+	unsigned int *nodeidx = (unsigned int *)v;
+
+	if (*nodeidx != 0) 
+		seq_putc(s, ',');
+	seq_printf(s, "%u", c->local_nodes[*nodeidx]);
+
+	if (*nodeidx == c->num_local_nodes-1)
+		seq_putc(s, '\n');
+
+	return 0;
+}
+
+static struct seq_operations clusterip_seq_ops = {
+	.start	= clusterip_seq_start,
+	.next	= clusterip_seq_next,
+	.stop	= clusterip_seq_stop,
+	.show	= clusterip_seq_show,
+};
+
+static int clusterip_proc_open(struct inode *inode, struct file *file)
+{
+	int ret = seq_open(file, &clusterip_seq_ops);
+
+	if (!ret) {
+		struct seq_file *sf = file->private_data;
+		struct proc_dir_entry *pde = PDE(inode);
+		struct clusterip_config *c = pde->data;
+
+		sf->private = pde;
+
+		clusterip_config_get(c);
+	}
+
+	return ret;
+}
+
+static int clusterip_proc_release(struct inode *inode, struct file *file)
+{
+	struct proc_dir_entry *pde = PDE(inode);
+	struct clusterip_config *c = pde->data;
+	int ret;
+
+	ret = seq_release(inode, file);
+
+	if (!ret)
+		clusterip_config_put(c);
+
+	return ret;
+}
+
+static ssize_t clusterip_proc_write(struct file *file, const char __user *input,
+				size_t size, loff_t *ofs)
+{
+#define PROC_WRITELEN	10
+	char buffer[PROC_WRITELEN+1];
+	struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
+	struct clusterip_config *c = pde->data;
+	unsigned long nodenum;
+
+	if (copy_from_user(buffer, input, PROC_WRITELEN))
+		return -EFAULT;
+
+	if (*buffer == '+') {
+		nodenum = simple_strtoul(buffer+1, NULL, 10);
+		if (clusterip_add_node(c, nodenum))
+			return -ENOMEM;
+	} else if (*buffer == '-') {
+		nodenum = simple_strtoul(buffer+1, NULL,10);
+		if (clusterip_del_node(c, nodenum))
+			return -ENOENT;
+	} else
+		return -EIO;
+
+	return size;
+}
+
+static struct file_operations clusterip_proc_fops = {
+	.owner	 = THIS_MODULE,
+	.open	 = clusterip_proc_open,
+	.read	 = seq_read,
+	.write	 = clusterip_proc_write,
+	.llseek	 = seq_lseek,
+	.release = clusterip_proc_release,
+};
+
+#endif /* CONFIG_PROC_FS */
+
+static int init_or_cleanup(int fini)
+{
+	int ret;
+
+	if (fini)
+		goto cleanup;
+
+	if (ipt_register_target(&clusterip_tgt)) {
+		ret = -EINVAL;
+		goto cleanup_none;
+	}
+
+	if (nf_register_hook(&cip_arp_ops) < 0) {
+		ret = -EINVAL;
+		goto cleanup_target;
+	}
+
+#ifdef CONFIG_PROC_FS
+	clusterip_procdir = proc_mkdir("ipt_CLUSTERIP", proc_net);
+	if (!clusterip_procdir) {
+		printk(KERN_ERR "CLUSTERIP: Unable to proc dir entry\n");
+		ret = -ENOMEM;
+		goto cleanup_hook;
+	}
+#endif /* CONFIG_PROC_FS */
+
+	printk(KERN_NOTICE "ClusterIP Version %s loaded successfully\n",
+		CLUSTERIP_VERSION);
+
+	return 0;
+
+cleanup:
+	printk(KERN_NOTICE "ClusterIP Version %s unloading\n",
+		CLUSTERIP_VERSION);
+#ifdef CONFIG_PROC_FS
+	remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
+#endif
+cleanup_hook:
+	nf_unregister_hook(&cip_arp_ops);
+cleanup_target:
+	ipt_unregister_target(&clusterip_tgt);
+cleanup_none:
+	return -EINVAL;
+}
+
+static int __init init(void)
+{
+	return init_or_cleanup(0);
+}
+
+static void __exit fini(void)
+{
+	init_or_cleanup(1);
+}
+
+module_init(init);
+module_exit(fini);
diff -Nru a/net/ipv4/netfilter/ipt_CONNMARK.c b/net/ipv4/netfilter/ipt_CONNMARK.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/net/ipv4/netfilter/ipt_CONNMARK.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,118 @@
+/* This kernel module is used to modify the connection mark values, or
+ * to optionally restore the skb nfmark from the connection mark
+ *
+ * Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
+ * by Henrik Nordstrom <hno@marasystems.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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <linux/ip.h>
+#include <net/checksum.h>
+
+MODULE_AUTHOR("Henrik Nordstrom <hno@marasytems.com>");
+MODULE_DESCRIPTION("IP tables CONNMARK matching module");
+MODULE_LICENSE("GPL");
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv4/ipt_CONNMARK.h>
+#include <linux/netfilter_ipv4/ip_conntrack.h>
+
+static unsigned int
+target(struct sk_buff **pskb,
+       const struct net_device *in,
+       const struct net_device *out,
+       unsigned int hooknum,
+       const void *targinfo,
+       void *userinfo)
+{
+	const struct ipt_connmark_target_info *markinfo = targinfo;
+	unsigned long diff;
+	unsigned long nfmark;
+	unsigned long newmark;
+
+	enum ip_conntrack_info ctinfo;
+	struct ip_conntrack *ct = ip_conntrack_get((*pskb), &ctinfo);
+	if (ct) {
+	    switch(markinfo->mode) {
+	    case IPT_CONNMARK_SET:
+		newmark = (ct->mark & ~markinfo->mask) | markinfo->mark;
+		if (newmark != ct->mark)
+		    ct->mark = newmark;
+		break;
+	    case IPT_CONNMARK_SAVE:
+		newmark = (ct->mark & ~markinfo->mask) | ((*pskb)->nfmark & markinfo->mask);
+		if (ct->mark != newmark)
+		    ct->mark = newmark;
+		break;
+	    case IPT_CONNMARK_RESTORE:
+		nfmark = (*pskb)->nfmark;
+		diff = (ct->mark ^ nfmark) & markinfo->mask;
+		if (diff != 0) {
+		    (*pskb)->nfmark = nfmark ^ diff;
+		    (*pskb)->nfcache |= NFC_ALTERED;
+		}
+		break;
+	    }
+	}
+
+	return IPT_CONTINUE;
+}
+
+static int
+checkentry(const char *tablename,
+	   const struct ipt_entry *e,
+	   void *targinfo,
+	   unsigned int targinfosize,
+	   unsigned int hook_mask)
+{
+	struct ipt_connmark_target_info *matchinfo = targinfo;
+	if (targinfosize != IPT_ALIGN(sizeof(struct ipt_connmark_target_info))) {
+		printk(KERN_WARNING "CONNMARK: targinfosize %u != %Zu\n",
+		       targinfosize,
+		       IPT_ALIGN(sizeof(struct ipt_connmark_target_info)));
+		return 0;
+	}
+
+	if (matchinfo->mode == IPT_CONNMARK_RESTORE) {
+	    if (strcmp(tablename, "mangle") != 0) {
+		    printk(KERN_WARNING "CONNMARK: restore can only be called from \"mangle\" table, not \"%s\"\n", tablename);
+		    return 0;
+	    }
+	}
+
+	return 1;
+}
+
+static struct ipt_target ipt_connmark_reg = {
+	.name = "CONNMARK",
+	.target = &target,
+	.checkentry = &checkentry,
+	.me = THIS_MODULE
+};
+
+static int __init init(void)
+{
+	return ipt_register_target(&ipt_connmark_reg);
+}
+
+static void __exit fini(void)
+{
+	ipt_unregister_target(&ipt_connmark_reg);
+}
+
+module_init(init);
+module_exit(fini);
diff -Nru a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c
--- a/net/ipv4/netfilter/ipt_ECN.c	2004-12-24 13:37:30 -08:00
+++ b/net/ipv4/netfilter/ipt_ECN.c	2004-12-24 13:37:30 -08:00
@@ -86,7 +86,7 @@
 		memcpy((*pskb)->data + (*pskb)->nh.iph->ihl*4,
 		       &_tcph, sizeof(_tcph));
 		if ((*pskb)->ip_summed == CHECKSUM_HW)
-			if (skb_checksum_help(pskb, inward))
+			if (skb_checksum_help(*pskb, inward))
 				return 0;
 		(*pskb)->nfcache |= NFC_ALTERED;
 	}
diff -Nru a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
--- a/net/ipv4/netfilter/ipt_MASQUERADE.c	2004-12-24 13:37:00 -08:00
+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c	2004-12-24 13:37:00 -08:00
@@ -81,8 +81,8 @@
 	enum ip_conntrack_info ctinfo;
 	const struct ip_nat_multi_range *mr;
 	struct ip_nat_multi_range newrange;
-	u_int32_t newsrc;
 	struct rtable *rt;
+	u_int32_t newsrc;
 
 	IP_NF_ASSERT(hooknum == NF_IP_POST_ROUTING);
 
@@ -96,36 +96,13 @@
 	                    || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
 
 	mr = targinfo;
-
-	{
-		struct flowi fl = { .nl_u = { .ip4_u =
-					      { .daddr = (*pskb)->nh.iph->daddr,
-						.tos = (RT_TOS((*pskb)->nh.iph->tos) |
-							RTO_CONN),
-#ifdef CONFIG_IP_ROUTE_FWMARK
-						.fwmark = (*pskb)->nfmark
-#endif
-					      } } };
-		if (ip_route_output_key(&rt, &fl) != 0) {
-			/* Funky routing can do this. */
-			if (net_ratelimit())
-				printk("MASQUERADE:"
-				       " No route: Rusty's brain broke!\n");
-			return NF_DROP;
-		}
-		if (rt->u.dst.dev != out) {
-			if (net_ratelimit())
-				printk("MASQUERADE:"
-				       " Route sent us somewhere else.\n");
-			ip_rt_put(rt);
-			return NF_DROP;
-		}
+	rt = (struct rtable *)(*pskb)->dst;
+	newsrc = inet_select_addr(out, rt->rt_gateway, RT_SCOPE_UNIVERSE);
+	if (!newsrc) {
+		printk("MASQUERADE: %s ate my IP address\n", out->name);
+		return NF_DROP;
 	}
 
-	newsrc = rt->rt_src;
-	DEBUGP("newsrc = %u.%u.%u.%u\n", NIPQUAD(newsrc));
-	ip_rt_put(rt);
-
 	WRITE_LOCK(&masq_lock);
 	ct->nat.masq_index = out->ifindex;
 	WRITE_UNLOCK(&masq_lock);
@@ -141,35 +118,57 @@
 }
 
 static inline int
-device_cmp(const struct ip_conntrack *i, void *_ina)
+device_cmp(const struct ip_conntrack *i, void *ifindex)
 {
-	int ret = 0;
-	struct in_ifaddr *ina = _ina;
+	int ret;
 
 	READ_LOCK(&masq_lock);
-	/* If it's masquerading out this interface with a different address,
-	   or we don't know the new address of this interface. */
-	if (i->nat.masq_index == ina->ifa_dev->dev->ifindex
-	    && i->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip != ina->ifa_address)
-		ret = 1;
+	ret = (i->nat.masq_index == (int)(long)ifindex);
 	READ_UNLOCK(&masq_lock);
 
 	return ret;
 }
 
+static int masq_device_event(struct notifier_block *this,
+			     unsigned long event,
+			     void *ptr)
+{
+	struct net_device *dev = ptr;
+
+	if (event == NETDEV_DOWN) {
+		/* Device was downed.  Search entire table for
+		   conntracks which were associated with that device,
+		   and forget them. */
+		IP_NF_ASSERT(dev->ifindex != 0);
+
+		ip_ct_selective_cleanup(device_cmp, (void *)(long)dev->ifindex);
+	}
+
+	return NOTIFY_DONE;
+}
+
 static int masq_inet_event(struct notifier_block *this,
 			   unsigned long event,
 			   void *ptr)
 {
-	/* For some configurations, interfaces often come back with
-	 * the same address.  If not, clean up old conntrack
-	 * entries. */
-	if (event == NETDEV_UP)
-		ip_ct_selective_cleanup(device_cmp, ptr);
+	struct net_device *dev = ((struct in_ifaddr *)ptr)->ifa_dev->dev;
+
+	if (event == NETDEV_DOWN) {
+		/* IP address was deleted.  Search entire table for
+		   conntracks which were associated with that device,
+		   and forget them. */
+		IP_NF_ASSERT(dev->ifindex != 0);
+
+		ip_ct_selective_cleanup(device_cmp, (void *)(long)dev->ifindex);
+	}
 
 	return NOTIFY_DONE;
 }
 
+static struct notifier_block masq_dev_notifier = {
+	.notifier_call	= masq_device_event,
+};
+
 static struct notifier_block masq_inet_notifier = {
 	.notifier_call	= masq_inet_event,
 };
@@ -187,9 +186,12 @@
 
 	ret = ipt_register_target(&masquerade);
 
-	if (ret == 0)
+	if (ret == 0) {
+		/* Register for device down reports */
+		register_netdevice_notifier(&masq_dev_notifier);
 		/* Register IP address change reports */
 		register_inetaddr_notifier(&masq_inet_notifier);
+	}
 
 	return ret;
 }
@@ -197,6 +199,7 @@
 static void __exit fini(void)
 {
 	ipt_unregister_target(&masquerade);
+	unregister_netdevice_notifier(&masq_dev_notifier);
 	unregister_inetaddr_notifier(&masq_inet_notifier);	
 }
 
diff -Nru a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
--- a/net/ipv4/netfilter/ipt_REJECT.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv4/netfilter/ipt_REJECT.c	2004-12-24 13:37:18 -08:00
@@ -22,6 +22,7 @@
 #include <net/ip.h>
 #include <net/tcp.h>
 #include <net/route.h>
+#include <net/dst.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv4/ipt_REJECT.h>
 #ifdef CONFIG_BRIDGE_NETFILTER
@@ -38,21 +39,8 @@
 #define DEBUGP(format, args...)
 #endif
 
-/* If the original packet is part of a connection, but the connection
-   is not confirmed, our manufactured reply will not be associated
-   with it, so we need to do this manually. */
-static void connection_attach(struct sk_buff *new_skb, struct sk_buff *skb)
-{
-	void (*attach)(struct sk_buff *, struct sk_buff *);
-
-	/* Avoid module unload race with ip_ct_attach being NULLed out */
-	if (skb->nfct && (attach = ip_ct_attach) != NULL) {
-		mb(); /* Just to be sure: must be read before executing this */
-		attach(new_skb, skb);
-	}
-}
-
-static inline struct rtable *route_reverse(struct sk_buff *skb, int hook)
+static inline struct rtable *route_reverse(struct sk_buff *skb, 
+					   struct tcphdr *tcph, int hook)
 {
 	struct iphdr *iph = skb->nh.iph;
 	struct dst_entry *odst;
@@ -89,10 +77,23 @@
 		dst_release(&rt->u.dst);
 		rt = (struct rtable *)skb->dst;
 		skb->dst = odst;
+
+		fl.nl_u.ip4_u.daddr = iph->saddr;
+		fl.nl_u.ip4_u.saddr = iph->daddr;
+		fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
 	}
 
 	if (rt->u.dst.error) {
 		dst_release(&rt->u.dst);
+		return NULL;
+	}
+
+	fl.proto = IPPROTO_TCP;
+	fl.fl_ip_sport = tcph->dest;
+	fl.fl_ip_dport = tcph->source;
+
+	if (xfrm_lookup((struct dst_entry **)&rt, &fl, NULL, 0)) {
+		dst_release(&rt->u.dst);
 		rt = NULL;
 	}
 
@@ -124,7 +125,7 @@
 		return;
 
 	/* FIXME: Check checksum --RR */
-	if ((rt = route_reverse(oldskb, hook)) == NULL)
+	if ((rt = route_reverse(oldskb, oth, hook)) == NULL)
 		return;
 
 	hh_len = LL_RESERVED_SPACE(rt->u.dst.dev);
@@ -209,7 +210,7 @@
 	if (nskb->len > dst_pmtu(nskb->dst))
 		goto free_nskb;
 
-	connection_attach(nskb, oldskb);
+	nf_ct_attach(nskb, oldskb);
 
 	NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, nskb, NULL, nskb->dst->dev,
 		ip_finish_output);
@@ -296,10 +297,23 @@
 	tos = (iph->tos & IPTOS_TOS_MASK) | IPTOS_PREC_INTERNETCONTROL;
 
 	{
-		struct flowi fl = { .nl_u = { .ip4_u =
-					      { .daddr = skb_in->nh.iph->saddr,
-						.saddr = saddr,
-						.tos = RT_TOS(tos) } } };
+		struct flowi fl = {
+			.nl_u = {
+				.ip4_u = {
+					.daddr = skb_in->nh.iph->saddr,
+					.saddr = saddr,
+					.tos = RT_TOS(tos)
+				}
+			},
+			.proto = IPPROTO_ICMP,
+			.uli_u = {
+				.icmpt = {
+					.type = ICMP_DEST_UNREACH,
+					.code = code
+				}
+			}
+		};
+
 		if (ip_route_output_key(&rt, &fl))
 			return;
 	}
@@ -360,7 +374,7 @@
 	icmph->checksum = ip_compute_csum((unsigned char *)icmph,
 					  length - sizeof(struct iphdr));
 
-	connection_attach(nskb, skb_in);
+	nf_ct_attach(nskb, skb_in);
 
 	NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, nskb, NULL, nskb->dst->dev,
 		ip_finish_output);
diff -Nru a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
--- a/net/ipv4/netfilter/ipt_ULOG.c	2004-12-24 13:36:47 -08:00
+++ b/net/ipv4/netfilter/ipt_ULOG.c	2004-12-24 13:36:47 -08:00
@@ -1,7 +1,7 @@
 /*
  * netfilter module for userspace packet logging daemons
  *
- * (C) 2000-2002 by Harald Welte <laforge@netfilter.org>
+ * (C) 2000-2004 by Harald Welte <laforge@netfilter.org>
  *
  * 2000/09/22 ulog-cprange feature added
  * 2001/01/04 in-kernel queue as proposed by Sebastian Zander 
@@ -13,6 +13,8 @@
  * 2002/07/07 remove broken nflog_rcv() function -HW
  * 2002/08/29 fix shifted/unshifted nlgroup bug -HW
  * 2002/10/30 fix uninitialized mac_len field - <Anders K. Pedersen>
+ * 2004/10/25 fix erroneous calculation of 'len' parameter to NLMSG_PUT
+ *	      resulting in bogus 'error during NLMSG_PUT' messages.
  *
  * (C) 1999-2001 Paul `Rusty' Russell
  * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
@@ -212,7 +214,7 @@
 
 	/* NLMSG_PUT contains a hidden goto nlmsg_failure !!! */
 	nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, ULOG_NL_EVENT, 
-			size - sizeof(*nlh));
+			sizeof(*pm)+copy_len);
 	ub->qlen++;
 
 	pm = NLMSG_DATA(nlh);
diff -Nru a/net/ipv4/netfilter/ipt_connmark.c b/net/ipv4/netfilter/ipt_connmark.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/net/ipv4/netfilter/ipt_connmark.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,81 @@
+/* This kernel module matches connection mark values set by the
+ * CONNMARK target
+ *
+ * Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
+ * by Henrik Nordstrom <hno@marasystems.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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/module.h>
+#include <linux/skbuff.h>
+
+MODULE_AUTHOR("Henrik Nordstrom <hno@marasytems.com>");
+MODULE_DESCRIPTION("IP tables connmark match module");
+MODULE_LICENSE("GPL");
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv4/ipt_connmark.h>
+#include <linux/netfilter_ipv4/ip_conntrack.h>
+
+static int
+match(const struct sk_buff *skb,
+      const struct net_device *in,
+      const struct net_device *out,
+      const void *matchinfo,
+      int offset,
+      int *hotdrop)
+{
+	const struct ipt_connmark_info *info = matchinfo;
+	enum ip_conntrack_info ctinfo;
+	struct ip_conntrack *ct = ip_conntrack_get((struct sk_buff *)skb, &ctinfo);
+	if (!ct)
+		return 0;
+
+	return ((ct->mark & info->mask) == info->mark) ^ info->invert;
+}
+
+static int
+checkentry(const char *tablename,
+	   const struct ipt_ip *ip,
+	   void *matchinfo,
+	   unsigned int matchsize,
+	   unsigned int hook_mask)
+{
+	if (matchsize != IPT_ALIGN(sizeof(struct ipt_connmark_info)))
+		return 0;
+
+	return 1;
+}
+
+static struct ipt_match connmark_match = {
+	.name = "connmark",
+	.match = &match,
+	.checkentry = &checkentry,
+	.me = THIS_MODULE
+};
+
+static int __init init(void)
+{
+	return ipt_register_match(&connmark_match);
+}
+
+static void __exit fini(void)
+{
+	ipt_unregister_match(&connmark_match);
+}
+
+module_init(init);
+module_exit(fini);
diff -Nru a/net/ipv4/netfilter/ipt_hashlimit.c b/net/ipv4/netfilter/ipt_hashlimit.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/net/ipv4/netfilter/ipt_hashlimit.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,713 @@
+/* iptables match extension to limit the number of packets per second
+ * seperately for each hashbucket (sourceip/sourceport/dstip/dstport)
+ *
+ * (C) 2003-2004 by Harald Welte <laforge@netfilter.org>
+ *
+ * $Id: ipt_hashlimit.c 3244 2004-10-20 16:24:29Z laforge@netfilter.org $
+ *
+ * Development of this code was funded by Astaro AG, http://www.astaro.com/
+ *
+ * based on ipt_limit.c by:
+ * Jérôme de Vivie	<devivie@info.enserb.u-bordeaux.fr>
+ * Hervé Eychenne	<eychenne@info.enserb.u-bordeaux.fr>
+ * Rusty Russell	<rusty@rustcorp.com.au>
+ *
+ * The general idea is to create a hash table for every dstip and have a
+ * seperate limit counter per tuple.  This way you can do something like 'limit
+ * the number of syn packets for each of my internal addresses.
+ *
+ * Ideally this would just be implemented as a general 'hash' match, which would
+ * allow us to attach any iptables target to it's hash buckets.  But this is
+ * not possible in the current iptables architecture.  As always, pkttables for
+ * 2.7.x will help ;)
+ */
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <linux/spinlock.h>
+#include <linux/random.h>
+#include <linux/jhash.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <linux/sctp.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+#define ASSERT_READ_LOCK(x) 
+#define ASSERT_WRITE_LOCK(x) 
+#include <linux/netfilter_ipv4/lockhelp.h>
+#include <linux/netfilter_ipv4/listhelp.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv4/ipt_hashlimit.h>
+
+/* FIXME: this is just for IP_NF_ASSERRT */
+#include <linux/netfilter_ipv4/ip_conntrack.h>
+
+#define MS2JIFFIES(x) ((x*HZ)/1000)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
+MODULE_DESCRIPTION("iptables match for limiting per hash-bucket");
+
+/* need to declare this at the top */
+static struct proc_dir_entry *hashlimit_procdir;
+static struct file_operations dl_file_ops;
+
+/* hash table crap */
+
+struct dsthash_dst {
+	u_int32_t src_ip;
+	u_int32_t dst_ip;
+	/* ports have to be consecutive !!! */
+	u_int16_t src_port;
+	u_int16_t dst_port;
+};
+
+struct dsthash_ent {
+	/* static / read-only parts in the beginning */
+	struct list_head list;
+	struct dsthash_dst dst;
+
+	/* modified structure members in the end */
+	unsigned long expires;		/* precalculated expiry time */
+	struct {
+		unsigned long prev;	/* last modification */
+		u_int32_t credit;
+		u_int32_t credit_cap, cost;
+	} rateinfo;
+};
+
+struct ipt_hashlimit_htable {
+	struct list_head list;		/* global list of all htables */
+	atomic_t use;
+
+	struct hashlimit_cfg cfg;	/* config */
+
+	/* used internally */
+	spinlock_t lock;		/* lock for list_head */
+	u_int32_t rnd;			/* random seed for hash */
+	struct timer_list timer;	/* timer for gc */
+	atomic_t count;			/* number entries in table */
+
+	/* seq_file stuff */
+	struct proc_dir_entry *pde;
+
+	struct list_head hash[0];	/* hashtable itself */
+};
+
+DECLARE_RWLOCK(hashlimit_lock);		/* protects htables list */
+static LIST_HEAD(hashlimit_htables);
+static kmem_cache_t *hashlimit_cachep;
+
+static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b)
+{
+	return (ent->dst.dst_ip == b->dst_ip 
+		&& ent->dst.dst_port == b->dst_port
+		&& ent->dst.src_port == b->src_port
+		&& ent->dst.src_ip == b->src_ip);
+}
+
+static inline u_int32_t
+hash_dst(const struct ipt_hashlimit_htable *ht, const struct dsthash_dst *dst)
+{
+	return (jhash_3words(dst->dst_ip, (dst->dst_port<<16 & dst->src_port), 
+			     dst->src_ip, ht->rnd) % ht->cfg.size);
+}
+
+static inline struct dsthash_ent *
+__dsthash_find(const struct ipt_hashlimit_htable *ht, struct dsthash_dst *dst)
+{
+	struct dsthash_ent *ent;
+	u_int32_t hash = hash_dst(ht, dst);
+	ent = LIST_FIND(&ht->hash[hash], dst_cmp, struct dsthash_ent *, dst);
+	return ent;
+}
+
+/* allocate dsthash_ent, initialize dst, put in htable and lock it */
+static struct dsthash_ent *
+__dsthash_alloc_init(struct ipt_hashlimit_htable *ht, struct dsthash_dst *dst)
+{
+	struct dsthash_ent *ent;
+
+	/* initialize hash with random val at the time we allocate
+	 * the first hashtable entry */
+	if (!ht->rnd)
+		get_random_bytes(&ht->rnd, 4);
+
+	if (ht->cfg.max &&
+	    atomic_read(&ht->count) >= ht->cfg.max) {
+		/* FIXME: do something. question is what.. */
+		if (net_ratelimit())
+			printk(KERN_WARNING 
+				"ipt_hashlimit: max count of %u reached\n", 
+				ht->cfg.max);
+		return NULL;
+	}
+
+	ent = kmem_cache_alloc(hashlimit_cachep, GFP_ATOMIC);
+	if (!ent) {
+		if (net_ratelimit())
+			printk(KERN_ERR 
+				"ipt_hashlimit: can't allocate dsthash_ent\n");
+		return NULL;
+	}
+
+	atomic_inc(&ht->count);
+
+	ent->dst.dst_ip = dst->dst_ip;
+	ent->dst.dst_port = dst->dst_port;
+	ent->dst.src_ip = dst->src_ip;
+	ent->dst.src_port = dst->src_port;
+
+	list_add(&ent->list, &ht->hash[hash_dst(ht, dst)]);
+
+	return ent;
+}
+
+static inline void 
+__dsthash_free(struct ipt_hashlimit_htable *ht, struct dsthash_ent *ent)
+{
+	list_del(&ent->list);
+	kmem_cache_free(hashlimit_cachep, ent);
+	atomic_dec(&ht->count);
+}
+static void htable_gc(unsigned long htlong);
+
+static int htable_create(struct ipt_hashlimit_info *minfo)
+{
+	int i;
+	unsigned int size;
+	struct ipt_hashlimit_htable *hinfo;
+
+	if (minfo->cfg.size)
+		size = minfo->cfg.size;
+	else {
+		size = (((num_physpages << PAGE_SHIFT) / 16384)
+			 / sizeof(struct list_head));
+		if (num_physpages > (1024 * 1024 * 1024 / PAGE_SIZE))
+			size = 8192;
+		if (size < 16)
+			size = 16;
+	}
+	/* FIXME: don't use vmalloc() here or anywhere else -HW */
+	hinfo = vmalloc(sizeof(struct ipt_hashlimit_htable)
+			+ (sizeof(struct list_head) * size));
+	if (!hinfo) {
+		printk(KERN_ERR "ipt_hashlimit: Unable to create hashtable\n");
+		return -1;
+	}
+	minfo->hinfo = hinfo;
+
+	/* copy match config into hashtable config */
+	memcpy(&hinfo->cfg, &minfo->cfg, sizeof(hinfo->cfg));
+	hinfo->cfg.size = size;
+	if (!hinfo->cfg.max)
+		hinfo->cfg.max = 8 * hinfo->cfg.size;
+	else if (hinfo->cfg.max < hinfo->cfg.size)
+		hinfo->cfg.max = hinfo->cfg.size;
+
+	for (i = 0; i < hinfo->cfg.size; i++)
+		INIT_LIST_HEAD(&hinfo->hash[i]);
+
+	atomic_set(&hinfo->count, 0);
+	atomic_set(&hinfo->use, 1);
+	hinfo->rnd = 0;
+	spin_lock_init(&hinfo->lock);
+	hinfo->pde = create_proc_entry(minfo->name, 0, hashlimit_procdir);
+	if (!hinfo->pde) {
+		vfree(hinfo);
+		return -1;
+	}
+	hinfo->pde->proc_fops = &dl_file_ops;
+	hinfo->pde->data = hinfo;
+
+	init_timer(&hinfo->timer);
+	hinfo->timer.expires = jiffies + MS2JIFFIES(hinfo->cfg.gc_interval);
+	hinfo->timer.data = (unsigned long )hinfo;
+	hinfo->timer.function = htable_gc;
+	add_timer(&hinfo->timer);
+
+	WRITE_LOCK(&hashlimit_lock);
+	list_add(&hinfo->list, &hashlimit_htables);
+	WRITE_UNLOCK(&hashlimit_lock);
+
+	return 0;
+}
+
+static int select_all(struct ipt_hashlimit_htable *ht, struct dsthash_ent *he)
+{
+	return 1;
+}
+
+static int select_gc(struct ipt_hashlimit_htable *ht, struct dsthash_ent *he)
+{
+	return (jiffies >= he->expires);
+}
+
+static void htable_selective_cleanup(struct ipt_hashlimit_htable *ht,
+		 		int (*select)(struct ipt_hashlimit_htable *ht, 
+					      struct dsthash_ent *he))
+{
+	int i;
+
+	IP_NF_ASSERT(ht->cfg.size && ht->cfg.max);
+
+	/* lock hash table and iterate over it */
+	spin_lock_bh(&ht->lock);
+	for (i = 0; i < ht->cfg.size; i++) {
+		struct dsthash_ent *dh, *n;
+		list_for_each_entry_safe(dh, n, &ht->hash[i], list) {
+			if ((*select)(ht, dh))
+				__dsthash_free(ht, dh);
+		}
+	}
+	spin_unlock_bh(&ht->lock);
+}
+
+/* hash table garbage collector, run by timer */
+static void htable_gc(unsigned long htlong)
+{
+	struct ipt_hashlimit_htable *ht = (struct ipt_hashlimit_htable *)htlong;
+
+	htable_selective_cleanup(ht, select_gc);
+
+	/* re-add the timer accordingly */
+	ht->timer.expires = jiffies + MS2JIFFIES(ht->cfg.gc_interval);
+	add_timer(&ht->timer);
+}
+
+static void htable_destroy(struct ipt_hashlimit_htable *hinfo)
+{
+	/* remove timer, if it is pending */
+	if (timer_pending(&hinfo->timer))
+		del_timer(&hinfo->timer);
+
+	/* remove proc entry */
+	remove_proc_entry(hinfo->pde->name, hashlimit_procdir);
+
+	htable_selective_cleanup(hinfo, select_all);
+	vfree(hinfo);
+}
+
+static struct ipt_hashlimit_htable *htable_find_get(char *name)
+{
+	struct ipt_hashlimit_htable *hinfo;
+
+	READ_LOCK(&hashlimit_lock);
+	list_for_each_entry(hinfo, &hashlimit_htables, list) {
+		if (!strcmp(name, hinfo->pde->name)) {
+			atomic_inc(&hinfo->use);
+			READ_UNLOCK(&hashlimit_lock);
+			return hinfo;
+		}
+	}
+	READ_UNLOCK(&hashlimit_lock);
+
+	return NULL;
+}
+
+static void htable_put(struct ipt_hashlimit_htable *hinfo)
+{
+	if (atomic_dec_and_test(&hinfo->use)) {
+		WRITE_LOCK(&hashlimit_lock);
+		list_del(&hinfo->list);
+		WRITE_UNLOCK(&hashlimit_lock);
+		htable_destroy(hinfo);
+	}
+}
+
+
+/* The algorithm used is the Simple Token Bucket Filter (TBF)
+ * see net/sched/sch_tbf.c in the linux source tree
+ */
+
+/* Rusty: This is my (non-mathematically-inclined) understanding of
+   this algorithm.  The `average rate' in jiffies becomes your initial
+   amount of credit `credit' and the most credit you can ever have
+   `credit_cap'.  The `peak rate' becomes the cost of passing the
+   test, `cost'.
+
+   `prev' tracks the last packet hit: you gain one credit per jiffy.
+   If you get credit balance more than this, the extra credit is
+   discarded.  Every time the match passes, you lose `cost' credits;
+   if you don't have that many, the test fails.
+
+   See Alexey's formal explanation in net/sched/sch_tbf.c.
+
+   To get the maximum range, we multiply by this factor (ie. you get N
+   credits per jiffy).  We want to allow a rate as low as 1 per day
+   (slowest userspace tool allows), which means
+   CREDITS_PER_JIFFY*HZ*60*60*24 < 2^32 ie.
+*/
+#define MAX_CPJ (0xFFFFFFFF / (HZ*60*60*24))
+
+/* Repeated shift and or gives us all 1s, final shift and add 1 gives
+ * us the power of 2 below the theoretical max, so GCC simply does a
+ * shift. */
+#define _POW2_BELOW2(x) ((x)|((x)>>1))
+#define _POW2_BELOW4(x) (_POW2_BELOW2(x)|_POW2_BELOW2((x)>>2))
+#define _POW2_BELOW8(x) (_POW2_BELOW4(x)|_POW2_BELOW4((x)>>4))
+#define _POW2_BELOW16(x) (_POW2_BELOW8(x)|_POW2_BELOW8((x)>>8))
+#define _POW2_BELOW32(x) (_POW2_BELOW16(x)|_POW2_BELOW16((x)>>16))
+#define POW2_BELOW32(x) ((_POW2_BELOW32(x)>>1) + 1)
+
+#define CREDITS_PER_JIFFY POW2_BELOW32(MAX_CPJ)
+
+/* Precision saver. */
+static inline u_int32_t
+user2credits(u_int32_t user)
+{
+	/* If multiplying would overflow... */
+	if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY))
+		/* Divide first. */
+		return (user / IPT_HASHLIMIT_SCALE) * HZ * CREDITS_PER_JIFFY;
+
+	return (user * HZ * CREDITS_PER_JIFFY) / IPT_HASHLIMIT_SCALE;
+}
+
+static inline void rateinfo_recalc(struct dsthash_ent *dh, unsigned long now)
+{
+	dh->rateinfo.credit += (now - xchg(&dh->rateinfo.prev, now)) 
+					* CREDITS_PER_JIFFY;
+	if (dh->rateinfo.credit > dh->rateinfo.credit_cap)
+		dh->rateinfo.credit = dh->rateinfo.credit_cap;
+}
+
+static inline int get_ports(const struct sk_buff *skb, int offset, 
+			    u16 ports[2])
+{
+	union {
+		struct tcphdr th;
+		struct udphdr uh;
+		sctp_sctphdr_t sctph;
+	} hdr_u, *ptr_u;
+
+	/* Must not be a fragment. */
+	if (offset)
+		return 1;
+
+	/* Must be big enough to read ports (both UDP and TCP have
+	   them at the start). */
+	ptr_u = skb_header_pointer(skb, skb->nh.iph->ihl*4, 8, &hdr_u); 
+	if (!ptr_u)
+		return 1;
+
+	switch (skb->nh.iph->protocol) {
+		case IPPROTO_TCP:
+			ports[0] = ptr_u->th.source;
+			ports[1] = ptr_u->th.dest;
+			break;
+		case IPPROTO_UDP:
+			ports[0] = ptr_u->uh.source;
+			ports[1] = ptr_u->uh.dest;
+			break;
+		case IPPROTO_SCTP:
+			ports[0] = ptr_u->sctph.source;
+			ports[1] = ptr_u->sctph.dest;
+			break;
+		default:
+			/* all other protocols don't supprot per-port hash
+			 * buckets */
+			ports[0] = ports[1] = 0;
+			break;
+	}
+
+	return 0;
+}
+
+
+static int
+hashlimit_match(const struct sk_buff *skb,
+		const struct net_device *in,
+		const struct net_device *out,
+		const void *matchinfo,
+		int offset,
+		int *hotdrop)
+{
+	struct ipt_hashlimit_info *r = 
+		((struct ipt_hashlimit_info *)matchinfo)->u.master;
+	struct ipt_hashlimit_htable *hinfo = r->hinfo;
+	unsigned long now = jiffies;
+	struct dsthash_ent *dh;
+	struct dsthash_dst dst;
+
+	/* build 'dst' according to hinfo->cfg and current packet */
+	memset(&dst, 0, sizeof(dst));
+	if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DIP)
+		dst.dst_ip = skb->nh.iph->daddr;
+	if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SIP)
+		dst.src_ip = skb->nh.iph->saddr;
+	if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT
+	    ||hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT) {
+		u_int16_t ports[2];
+		if (get_ports(skb, offset, ports)) {
+			/* We've been asked to examine this packet, and we
+		 	  can't.  Hence, no choice but to drop. */
+			*hotdrop = 1;
+			return 0;
+		}
+		if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT)
+			dst.src_port = ports[0];
+		if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT)
+			dst.dst_port = ports[1];
+	} 
+
+	spin_lock_bh(&hinfo->lock);
+	dh = __dsthash_find(hinfo, &dst);
+	if (!dh) {
+		dh = __dsthash_alloc_init(hinfo, &dst);
+
+		if (!dh) {
+			/* enomem... don't match == DROP */
+			if (net_ratelimit())
+				printk(KERN_ERR "%s: ENOMEM\n", __FUNCTION__);
+			spin_unlock_bh(&hinfo->lock);
+			return 0;
+		}
+
+		dh->expires = jiffies + MS2JIFFIES(hinfo->cfg.expire);
+
+		dh->rateinfo.prev = jiffies;
+		dh->rateinfo.credit = user2credits(hinfo->cfg.avg * 
+							hinfo->cfg.burst);
+		dh->rateinfo.credit_cap = user2credits(hinfo->cfg.avg * 
+							hinfo->cfg.burst);
+		dh->rateinfo.cost = user2credits(hinfo->cfg.avg);
+
+		spin_unlock_bh(&hinfo->lock);
+		return 1;
+	}
+
+	/* update expiration timeout */
+	dh->expires = now + MS2JIFFIES(hinfo->cfg.expire);
+
+	rateinfo_recalc(dh, now);
+	if (dh->rateinfo.credit >= dh->rateinfo.cost) {
+		/* We're underlimit. */
+		dh->rateinfo.credit -= dh->rateinfo.cost;
+		spin_unlock_bh(&hinfo->lock);
+		return 1;
+	}
+
+       	spin_unlock_bh(&hinfo->lock);
+
+	/* default case: we're overlimit, thus don't match */
+	return 0;
+}
+
+static int
+hashlimit_checkentry(const char *tablename,
+		     const struct ipt_ip *ip,
+		     void *matchinfo,
+		     unsigned int matchsize,
+		     unsigned int hook_mask)
+{
+	struct ipt_hashlimit_info *r = matchinfo;
+
+	if (matchsize != IPT_ALIGN(sizeof(struct ipt_hashlimit_info)))
+		return 0;
+
+	/* Check for overflow. */
+	if (r->cfg.burst == 0
+	    || user2credits(r->cfg.avg * r->cfg.burst) < 
+	    				user2credits(r->cfg.avg)) {
+		printk(KERN_ERR "ipt_hashlimit: Overflow, try lower: %u/%u\n",
+		       r->cfg.avg, r->cfg.burst);
+		return 0;
+	}
+
+	if (r->cfg.mode == 0 
+	    || r->cfg.mode > (IPT_HASHLIMIT_HASH_DPT
+		          |IPT_HASHLIMIT_HASH_DIP
+			  |IPT_HASHLIMIT_HASH_SIP
+			  |IPT_HASHLIMIT_HASH_SPT))
+		return 0;
+
+	if (!r->cfg.gc_interval)
+		return 0;
+	
+	if (!r->cfg.expire)
+		return 0;
+
+	r->hinfo = htable_find_get(r->name);
+	if (!r->hinfo && (htable_create(r) != 0)) {
+		return 0;
+	}
+
+	/* Ugly hack: For SMP, we only want to use one set */
+	r->u.master = r;
+
+	return 1;
+}
+
+static void
+hashlimit_destroy(void *matchinfo, unsigned int matchsize)
+{
+	struct ipt_hashlimit_info *r = (struct ipt_hashlimit_info *) matchinfo;
+
+	htable_put(r->hinfo);
+}
+
+static struct ipt_match ipt_hashlimit = { 
+	.name = "hashlimit", 
+	.match = hashlimit_match, 
+	.checkentry = hashlimit_checkentry, 
+	.destroy = hashlimit_destroy,
+	.me = THIS_MODULE 
+};
+
+/* PROC stuff */
+
+static void *dl_seq_start(struct seq_file *s, loff_t *pos)
+{
+	struct proc_dir_entry *pde = s->private;
+	struct ipt_hashlimit_htable *htable = pde->data;
+	unsigned int *bucket;
+
+	spin_lock_bh(&htable->lock);
+	if (*pos >= htable->cfg.size)
+		return NULL;
+
+	bucket = kmalloc(sizeof(unsigned int), GFP_KERNEL);
+	if (!bucket)
+		return ERR_PTR(-ENOMEM);
+
+	*bucket = *pos;
+	return bucket;
+}
+
+static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos)
+{
+	struct proc_dir_entry *pde = s->private;
+	struct ipt_hashlimit_htable *htable = pde->data;
+	unsigned int *bucket = (unsigned int *)v;
+
+	*pos = ++(*bucket);
+	if (*pos >= htable->cfg.size) {
+		kfree(v);
+		return NULL;
+	}
+	return bucket;
+}
+
+static void dl_seq_stop(struct seq_file *s, void *v)
+{
+	struct proc_dir_entry *pde = s->private;
+	struct ipt_hashlimit_htable *htable = pde->data;
+	unsigned int *bucket = (unsigned int *)v;
+
+	kfree(bucket);
+
+	spin_unlock_bh(&htable->lock);
+}
+
+static inline int dl_seq_real_show(struct dsthash_ent *ent, struct seq_file *s)
+{
+	/* recalculate to show accurate numbers */
+	rateinfo_recalc(ent, jiffies);
+
+	return seq_printf(s, "%ld %u.%u.%u.%u:%u->%u.%u.%u.%u:%u %u %u %u\n",
+			(ent->expires - jiffies)/HZ,
+			NIPQUAD(ent->dst.src_ip), ntohs(ent->dst.src_port),
+			NIPQUAD(ent->dst.dst_ip), ntohs(ent->dst.dst_port),
+			ent->rateinfo.credit, ent->rateinfo.credit_cap,
+			ent->rateinfo.cost);
+}
+
+static int dl_seq_show(struct seq_file *s, void *v)
+{
+	struct proc_dir_entry *pde = s->private;
+	struct ipt_hashlimit_htable *htable = pde->data;
+	unsigned int *bucket = (unsigned int *)v;
+
+	if (LIST_FIND_W(&htable->hash[*bucket], dl_seq_real_show,
+		      struct dsthash_ent *, s)) {
+		/* buffer was filled and unable to print that tuple */
+		return 1;
+	}
+	return 0;
+}
+
+static struct seq_operations dl_seq_ops = {
+	.start = dl_seq_start,
+	.next  = dl_seq_next,
+	.stop  = dl_seq_stop,
+	.show  = dl_seq_show
+};
+
+static int dl_proc_open(struct inode *inode, struct file *file)
+{
+	int ret = seq_open(file, &dl_seq_ops);
+
+	if (!ret) {
+		struct seq_file *sf = file->private_data;
+		sf->private = PDE(inode);
+	}
+	return ret;
+}
+
+static struct file_operations dl_file_ops = {
+	.owner   = THIS_MODULE,
+	.open    = dl_proc_open,
+	.read    = seq_read,
+	.llseek  = seq_lseek,
+	.release = seq_release
+};
+
+static int init_or_fini(int fini)
+{
+	int ret = 0;
+
+	if (fini)
+		goto cleanup;
+
+	if (ipt_register_match(&ipt_hashlimit)) {
+		ret = -EINVAL;
+		goto cleanup_nothing;
+	}
+
+	/* FIXME: do we really want HWCACHE_ALIGN since our objects are
+	 * quite small ? */
+	hashlimit_cachep = kmem_cache_create("ipt_hashlimit",
+					    sizeof(struct dsthash_ent), 0,
+					    SLAB_HWCACHE_ALIGN, NULL, NULL);
+	if (!hashlimit_cachep) {
+		printk(KERN_ERR "Unable to create ipt_hashlimit slab cache\n");
+		ret = -ENOMEM;
+		goto cleanup_unreg_match;
+	}
+
+	hashlimit_procdir = proc_mkdir("ipt_hashlimit", proc_net);
+	if (!hashlimit_procdir) {
+		printk(KERN_ERR "Unable to create proc dir entry\n");
+		ret = -ENOMEM;
+		goto cleanup_free_slab;
+	}
+
+	return ret;
+
+cleanup:
+	remove_proc_entry("ipt_hashlimit", proc_net);
+cleanup_free_slab:
+	kmem_cache_destroy(hashlimit_cachep);
+cleanup_unreg_match:
+	ipt_unregister_match(&ipt_hashlimit);
+cleanup_nothing:
+	return ret;
+	
+}
+
+static int __init init(void)
+{
+	return init_or_fini(0);
+}
+
+static void __exit fini(void)
+{
+	init_or_fini(1);
+}
+
+module_init(init);
+module_exit(fini);
diff -Nru a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c
--- a/net/ipv4/netfilter/ipt_recent.c	2004-12-24 13:36:18 -08:00
+++ b/net/ipv4/netfilter/ipt_recent.c	2004-12-24 13:36:18 -08:00
@@ -715,7 +715,7 @@
 	curr_table = vmalloc(sizeof(struct recent_ip_tables));
 	if(curr_table == NULL) return -ENOMEM;
 
-	curr_table->list_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&curr_table->list_lock);
 	curr_table->next = NULL;
 	curr_table->count = 1;
 	curr_table->time_pos = 0;
diff -Nru a/net/ipv4/netfilter/ipt_tcpmss.c b/net/ipv4/netfilter/ipt_tcpmss.c
--- a/net/ipv4/netfilter/ipt_tcpmss.c	2004-12-24 13:36:18 -08:00
+++ b/net/ipv4/netfilter/ipt_tcpmss.c	2004-12-24 13:36:18 -08:00
@@ -87,18 +87,6 @@
 			       info->invert, hotdrop);
 }
 
-static inline int find_syn_match(const struct ipt_entry_match *m)
-{
-	const struct ipt_tcp *tcpinfo = (const struct ipt_tcp *)m->data;
-
-	if (strcmp(m->u.kernel.match->name, "tcp") == 0
-	    && (tcpinfo->flg_cmp & TH_SYN)
-	    && !(tcpinfo->invflags & IPT_TCP_INV_FLAGS))
-		return 1;
-
-	return 0;
-}
-
 static int
 checkentry(const char *tablename,
            const struct ipt_ip *ip,
diff -Nru a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
--- a/net/ipv4/netfilter/iptable_filter.c	2004-12-24 13:36:47 -08:00
+++ b/net/ipv4/netfilter/iptable_filter.c	2004-12-24 13:36:47 -08:00
@@ -44,8 +44,8 @@
 	struct ipt_replace repl;
 	struct ipt_standard entries[3];
 	struct ipt_error term;
-} initial_table __initdata
-= { { "filter", FILTER_VALID_HOOKS, 4,
+} initial_table = {
+    { "filter", FILTER_VALID_HOOKS, 4,
       sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error),
       { [NF_IP_LOCAL_IN] = 0,
 	[NF_IP_FORWARD] = sizeof(struct ipt_standard),
diff -Nru a/net/ipv4/raw.c b/net/ipv4/raw.c
--- a/net/ipv4/raw.c	2004-12-24 13:36:56 -08:00
+++ b/net/ipv4/raw.c	2004-12-24 13:36:56 -08:00
@@ -130,6 +130,9 @@
 {
 	int type;
 
+	if (!pskb_may_pull(skb, sizeof(struct icmphdr)))
+		return 1;
+
 	type = skb->h.icmph->type;
 	if (type < 32) {
 		__u32 data = raw4_sk(sk)->filter.data;
@@ -407,7 +410,7 @@
 				printk(KERN_INFO "%s forgot to set AF_INET in "
 						 "raw sendmsg. Fix it!\n",
 						 current->comm);
-			err = -EINVAL;
+			err = -EAFNOSUPPORT;
 			if (usin->sin_family)
 				goto out;
 		}
@@ -706,6 +709,7 @@
 
 struct proto raw_prot = {
 	.name =		"RAW",
+	.owner =	THIS_MODULE,
 	.close =	raw_close,
 	.connect =	ip4_datagram_connect,
 	.disconnect =	udp_disconnect,
diff -Nru a/net/ipv4/route.c b/net/ipv4/route.c
--- a/net/ipv4/route.c	2004-12-24 13:37:30 -08:00
+++ b/net/ipv4/route.c	2004-12-24 13:37:30 -08:00
@@ -65,7 +65,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -801,14 +801,13 @@
 			 * must be visible to another weakly ordered CPU before
 			 * the insertion at the start of the hash chain.
 			 */
-			smp_wmb();
-			rth->u.rt_next = rt_hash_table[hash].chain;
+			rcu_assign_pointer(rth->u.rt_next,
+					   rt_hash_table[hash].chain);
 			/*
 			 * Since lookup is lockfree, the update writes
 			 * must be ordered for consistency on SMP.
 			 */
-			smp_wmb();
-			rt_hash_table[hash].chain = rth;
+			rcu_assign_pointer(rt_hash_table[hash].chain, rth);
 
 			rth->u.dst.__use++;
 			dst_hold(&rth->u.dst);
@@ -1367,10 +1366,8 @@
 		dst_set_expires(&rt->u.dst, 0);
 }
 
-static int ip_rt_bug(struct sk_buff **pskb)
+static int ip_rt_bug(struct sk_buff *skb)
 {
-	struct sk_buff *skb = *pskb;
-
 	printk(KERN_DEBUG "ip_rt_bug: %u.%u.%u.%u -> %u.%u.%u.%u, %s\n",
 		NIPQUAD(skb->nh.iph->saddr), NIPQUAD(skb->nh.iph->daddr),
 		skb->dev ? skb->dev->name : "?");
@@ -2758,7 +2755,7 @@
 
 	rt_hash_mask--;
 	for (i = 0; i <= rt_hash_mask; i++) {
-		rt_hash_table[i].lock = SPIN_LOCK_UNLOCKED;
+		spin_lock_init(&rt_hash_table[i].lock);
 		rt_hash_table[i].chain = NULL;
 	}
 
diff -Nru a/net/ipv4/tcp.c b/net/ipv4/tcp.c
--- a/net/ipv4/tcp.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv4/tcp.c	2004-12-24 13:36:31 -08:00
@@ -467,7 +467,7 @@
 	sk->sk_max_ack_backlog = 0;
 	sk->sk_ack_backlog = 0;
 	tp->accept_queue = tp->accept_queue_tail = NULL;
-	tp->syn_wait_lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&tp->syn_wait_lock);
 	tcp_delack_init(tp);
 
 	lopt = kmalloc(sizeof(struct tcp_listen_opt), GFP_KERNEL);
@@ -2095,6 +2095,65 @@
 	return err;
 }
 
+/* Return information about state of tcp endpoint in API format. */
+void tcp_get_info(struct sock *sk, struct tcp_info *info)
+{
+	struct tcp_opt *tp = tcp_sk(sk);
+	u32 now = tcp_time_stamp;
+
+	memset(info, 0, sizeof(*info));
+
+	info->tcpi_state = sk->sk_state;
+	info->tcpi_ca_state = tp->ca_state;
+	info->tcpi_retransmits = tp->retransmits;
+	info->tcpi_probes = tp->probes_out;
+	info->tcpi_backoff = tp->backoff;
+
+	if (tp->tstamp_ok)
+		info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
+	if (tp->sack_ok)
+		info->tcpi_options |= TCPI_OPT_SACK;
+	if (tp->wscale_ok) {
+		info->tcpi_options |= TCPI_OPT_WSCALE;
+		info->tcpi_snd_wscale = tp->snd_wscale;
+		info->tcpi_rcv_wscale = tp->rcv_wscale;
+	} 
+
+	if (tp->ecn_flags&TCP_ECN_OK)
+		info->tcpi_options |= TCPI_OPT_ECN;
+
+	info->tcpi_rto = jiffies_to_usecs(tp->rto);
+	info->tcpi_ato = jiffies_to_usecs(tp->ack.ato);
+	info->tcpi_snd_mss = tp->mss_cache_std;
+	info->tcpi_rcv_mss = tp->ack.rcv_mss;
+
+	info->tcpi_unacked = tcp_get_pcount(&tp->packets_out);
+	info->tcpi_sacked = tcp_get_pcount(&tp->sacked_out);
+	info->tcpi_lost = tcp_get_pcount(&tp->lost_out);
+	info->tcpi_retrans = tcp_get_pcount(&tp->retrans_out);
+	info->tcpi_fackets = tcp_get_pcount(&tp->fackets_out);
+
+	info->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime);
+	info->tcpi_last_data_recv = jiffies_to_msecs(now - tp->ack.lrcvtime);
+	info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp);
+
+	info->tcpi_pmtu = tp->pmtu_cookie;
+	info->tcpi_rcv_ssthresh = tp->rcv_ssthresh;
+	info->tcpi_rtt = jiffies_to_usecs(tp->srtt)>>3;
+	info->tcpi_rttvar = jiffies_to_usecs(tp->mdev)>>2;
+	info->tcpi_snd_ssthresh = tp->snd_ssthresh;
+	info->tcpi_snd_cwnd = tp->snd_cwnd;
+	info->tcpi_advmss = tp->advmss;
+	info->tcpi_reordering = tp->reordering;
+
+	info->tcpi_rcv_rtt = jiffies_to_usecs(tp->rcv_rtt_est.rtt)>>3;
+	info->tcpi_rcv_space = tp->rcvq_space.space;
+
+	info->tcpi_total_retrans = tp->total_retrans;
+}
+
+EXPORT_SYMBOL_GPL(tcp_get_info);
+
 int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval,
 		   int __user *optlen)
 {
@@ -2250,7 +2309,7 @@
 	if (!tcp_ehash)
 		panic("Failed to allocate TCP established hash table\n");
 	for (i = 0; i < (tcp_ehash_size << 1); i++) {
-		tcp_ehash[i].lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&tcp_ehash[i].lock);
 		INIT_HLIST_HEAD(&tcp_ehash[i].chain);
 	}
 
@@ -2266,7 +2325,7 @@
 	if (!tcp_bhash)
 		panic("Failed to allocate TCP bind hash table\n");
 	for (i = 0; i < tcp_bhash_size; i++) {
-		tcp_bhash[i].lock = SPIN_LOCK_UNLOCKED;
+		spin_lock_init(&tcp_bhash[i].lock);
 		INIT_HLIST_HEAD(&tcp_bhash[i].chain);
 	}
 
@@ -2301,13 +2360,10 @@
 	printk(KERN_INFO "TCP: Hash tables configured "
 	       "(established %d bind %d)\n",
 	       tcp_ehash_size << 1, tcp_bhash_size);
-
-	tcpdiag_init();
 }
 
 EXPORT_SYMBOL(tcp_accept);
 EXPORT_SYMBOL(tcp_close);
-EXPORT_SYMBOL(tcp_close_state);
 EXPORT_SYMBOL(tcp_destroy_sock);
 EXPORT_SYMBOL(tcp_disconnect);
 EXPORT_SYMBOL(tcp_getsockopt);
diff -Nru a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
--- a/net/ipv4/tcp_diag.c	2004-12-24 13:36:17 -08:00
+++ b/net/ipv4/tcp_diag.c	2004-12-24 13:36:17 -08:00
@@ -18,6 +18,7 @@
 #include <linux/random.h>
 #include <linux/cache.h>
 #include <linux/init.h>
+#include <linux/time.h>
 
 #include <net/icmp.h>
 #include <net/tcp.h>
@@ -29,6 +30,16 @@
 
 #include <linux/tcp_diag.h>
 
+struct tcpdiag_entry
+{
+	u32 *saddr;
+	u32 *daddr;
+	u16 sport;
+	u16 dport;
+	u16 family;
+	u16 userlocks;
+};
+
 static struct sock *tcpnl;
 
 
@@ -41,63 +52,8 @@
    rta->rta_len = rtalen;                   \
    RTA_DATA(rta); })
 
-/* Return information about state of tcp endpoint in API format. */
-void tcp_get_info(struct sock *sk, struct tcp_info *info)
-{
-	struct tcp_opt *tp = tcp_sk(sk);
-	u32 now = tcp_time_stamp;
-
-	memset(info, 0, sizeof(*info));
-
-	info->tcpi_state = sk->sk_state;
-	info->tcpi_ca_state = tp->ca_state;
-	info->tcpi_retransmits = tp->retransmits;
-	info->tcpi_probes = tp->probes_out;
-	info->tcpi_backoff = tp->backoff;
-
-	if (tp->tstamp_ok)
-		info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
-	if (tp->sack_ok)
-		info->tcpi_options |= TCPI_OPT_SACK;
-	if (tp->wscale_ok) {
-		info->tcpi_options |= TCPI_OPT_WSCALE;
-		info->tcpi_snd_wscale = tp->snd_wscale;
-		info->tcpi_rcv_wscale = tp->rcv_wscale;
-	} 
-
-	if (tp->ecn_flags&TCP_ECN_OK)
-		info->tcpi_options |= TCPI_OPT_ECN;
-
-	info->tcpi_rto = jiffies_to_usecs(tp->rto);
-	info->tcpi_ato = jiffies_to_usecs(tp->ack.ato);
-	info->tcpi_snd_mss = tp->mss_cache_std;
-	info->tcpi_rcv_mss = tp->ack.rcv_mss;
-
-	info->tcpi_unacked = tcp_get_pcount(&tp->packets_out);
-	info->tcpi_sacked = tcp_get_pcount(&tp->sacked_out);
-	info->tcpi_lost = tcp_get_pcount(&tp->lost_out);
-	info->tcpi_retrans = tcp_get_pcount(&tp->retrans_out);
-	info->tcpi_fackets = tcp_get_pcount(&tp->fackets_out);
-
-	info->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime);
-	info->tcpi_last_data_recv = jiffies_to_msecs(now - tp->ack.lrcvtime);
-	info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp);
-
-	info->tcpi_pmtu = tp->pmtu_cookie;
-	info->tcpi_rcv_ssthresh = tp->rcv_ssthresh;
-	info->tcpi_rtt = jiffies_to_usecs(tp->srtt)>>3;
-	info->tcpi_rttvar = jiffies_to_usecs(tp->mdev)>>2;
-	info->tcpi_snd_ssthresh = tp->snd_ssthresh;
-	info->tcpi_snd_cwnd = tp->snd_cwnd;
-	info->tcpi_advmss = tp->advmss;
-	info->tcpi_reordering = tp->reordering;
-
-	info->tcpi_rcv_rtt = jiffies_to_usecs(tp->rcv_rtt_est.rtt)>>3;
-	info->tcpi_rcv_space = tp->rcvq_space.space;
-}
-
 static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
-			int ext, u32 pid, u32 seq)
+			int ext, u32 pid, u32 seq, u16 nlmsg_flags)
 {
 	struct inet_opt *inet = inet_sk(sk);
 	struct tcp_opt *tp = tcp_sk(sk);
@@ -109,6 +65,7 @@
 	unsigned char	 *b = skb->tail;
 
 	nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r));
+	nlh->nlmsg_flags = nlmsg_flags;
 	r = NLMSG_DATA(nlh);
 	if (sk->sk_state != TCP_TIME_WAIT) {
 		if (ext & (1<<(TCPDIAG_MEMINFO-1)))
@@ -146,7 +103,7 @@
 		r->tcpdiag_wqueue = 0;
 		r->tcpdiag_uid = 0;
 		r->tcpdiag_inode = 0;
-#ifdef CONFIG_IPV6
+#ifdef CONFIG_IP_TCPDIAG_IPV6
 		if (r->tcpdiag_family == AF_INET6) {
 			ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
 				       &tw->tw_v6_rcv_saddr);
@@ -163,7 +120,7 @@
 	r->id.tcpdiag_src[0] = inet->rcv_saddr;
 	r->id.tcpdiag_dst[0] = inet->daddr;
 
-#ifdef CONFIG_IPV6
+#ifdef CONFIG_IP_TCPDIAG_IPV6
 	if (r->tcpdiag_family == AF_INET6) {
 		struct ipv6_pinfo *np = inet6_sk(sk);
 
@@ -231,11 +188,19 @@
 	return -1;
 }
 
-extern struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport, int dif);
-#ifdef CONFIG_IPV6
+extern struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport,
+				  int dif);
+#ifdef CONFIG_IP_TCPDIAG_IPV6
 extern struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
 				  struct in6_addr *daddr, u16 dport,
 				  int dif);
+#else
+static inline struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
+					 struct in6_addr *daddr, u16 dport,
+					 int dif)
+{
+	return NULL;
+}
 #endif
 
 static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh)
@@ -250,7 +215,7 @@
 				   req->id.tcpdiag_src[0], req->id.tcpdiag_sport,
 				   req->id.tcpdiag_if);
 	}
-#ifdef CONFIG_IPV6
+#ifdef CONFIG_IP_TCPDIAG_IPV6
 	else if (req->tcpdiag_family == AF_INET6) {
 		sk = tcp_v6_lookup((struct in6_addr*)req->id.tcpdiag_dst, req->id.tcpdiag_dport,
 				   (struct in6_addr*)req->id.tcpdiag_src, req->id.tcpdiag_sport,
@@ -280,7 +245,7 @@
 
 	if (tcpdiag_fill(rep, sk, req->tcpdiag_ext,
 			 NETLINK_CB(in_skb).pid,
-			 nlh->nlmsg_seq) <= 0)
+			 nlh->nlmsg_seq, 0) <= 0)
 		BUG();
 
 	err = netlink_unicast(tcpnl, rep, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
@@ -324,11 +289,11 @@
 }
 
 
-static int tcpdiag_bc_run(const void *bc, int len, struct sock *sk)
+static int tcpdiag_bc_run(const void *bc, int len,
+			  const struct tcpdiag_entry *entry)
 {
 	while (len > 0) {
 		int yes = 1;
-		struct inet_opt *inet = inet_sk(sk);
 		const struct tcpdiag_bc_op *op = bc;
 
 		switch (op->code) {
@@ -338,19 +303,19 @@
 			yes = 0;
 			break;
 		case TCPDIAG_BC_S_GE:
-			yes = inet->num >= op[1].no;
+			yes = entry->sport >= op[1].no;
 			break;
 		case TCPDIAG_BC_S_LE:
-			yes = inet->num <= op[1].no;
+			yes = entry->dport <= op[1].no;
 			break;
 		case TCPDIAG_BC_D_GE:
-			yes = ntohs(inet->dport) >= op[1].no;
+			yes = entry->dport >= op[1].no;
 			break;
 		case TCPDIAG_BC_D_LE:
-			yes = ntohs(inet->dport) <= op[1].no;
+			yes = entry->dport <= op[1].no;
 			break;
 		case TCPDIAG_BC_AUTO:
-			yes = !(sk->sk_userlocks & SOCK_BINDPORT_LOCK);
+			yes = !(entry->userlocks & SOCK_BINDPORT_LOCK);
 			break;
 		case TCPDIAG_BC_S_COND:
 		case TCPDIAG_BC_D_COND:
@@ -360,7 +325,7 @@
 
 			if (cond->port != -1 &&
 			    cond->port != (op->code == TCPDIAG_BC_S_COND ?
-					     inet->num : ntohs(inet->dport))) {
+					     entry->sport : entry->dport)) {
 				yes = 0;
 				break;
 			}
@@ -368,26 +333,14 @@
 			if (cond->prefix_len == 0)
 				break;
 
-#ifdef CONFIG_IPV6
-			if (sk->sk_family == AF_INET6) {
-				struct ipv6_pinfo *np = inet6_sk(sk);
-
-				if (op->code == TCPDIAG_BC_S_COND)
-					addr = (u32*)&np->rcv_saddr;
-				else
-					addr = (u32*)&np->daddr;
-			} else
-#endif
-			{
-				if (op->code == TCPDIAG_BC_S_COND)
-					addr = &inet->rcv_saddr;
-				else
-					addr = &inet->daddr;
-			}
+			if (op->code == TCPDIAG_BC_S_COND)
+				addr = entry->saddr;
+			else
+				addr = entry->daddr;
 
 			if (bitstring_match(addr, cond->addr, cond->prefix_len))
 				break;
-			if (sk->sk_family == AF_INET6 &&
+			if (entry->family == AF_INET6 &&
 			    cond->family == AF_INET) {
 				if (addr[0] == 0 && addr[1] == 0 &&
 				    addr[2] == htonl(0xffff) &&
@@ -466,16 +419,182 @@
 	return len == 0 ? 0 : -EINVAL;
 }
 
+static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk,
+			     struct netlink_callback *cb)
+{
+	struct tcpdiagreq *r = NLMSG_DATA(cb->nlh);
+
+	if (cb->nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(*r))) {
+		struct tcpdiag_entry entry;
+		struct rtattr *bc = (struct rtattr *)(r + 1);
+		struct inet_opt *inet = inet_sk(sk);
+
+		entry.family = sk->sk_family;
+#ifdef CONFIG_IP_TCPDIAG_IPV6
+		if (entry.family == AF_INET6) {
+			struct ipv6_pinfo *np = inet6_sk(sk);
+
+			entry.saddr = np->rcv_saddr.s6_addr32;
+			entry.daddr = np->daddr.s6_addr32;
+		} else
+#endif
+		{
+			entry.saddr = &inet->rcv_saddr;
+			entry.daddr = &inet->daddr;
+		}
+		entry.sport = inet->num;
+		entry.dport = ntohs(inet->dport);
+		entry.userlocks = sk->sk_userlocks;
+
+		if (!tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), &entry))
+			return 0;
+	}
+
+	return tcpdiag_fill(skb, sk, r->tcpdiag_ext, NETLINK_CB(cb->skb).pid,
+			    cb->nlh->nlmsg_seq, NLM_F_MULTI);
+}
+
+static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk,
+			    struct open_request *req,
+			    u32 pid, u32 seq)
+{
+	struct inet_opt *inet = inet_sk(sk);
+	unsigned char *b = skb->tail;
+	struct tcpdiagmsg *r;
+	struct nlmsghdr *nlh;
+	long tmo;
+
+	nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r));
+	nlh->nlmsg_flags = NLM_F_MULTI;
+	r = NLMSG_DATA(nlh);
+
+	r->tcpdiag_family = sk->sk_family;
+	r->tcpdiag_state = TCP_SYN_RECV;
+	r->tcpdiag_timer = 1;
+	r->tcpdiag_retrans = req->retrans;
+
+	r->id.tcpdiag_if = sk->sk_bound_dev_if;
+	r->id.tcpdiag_cookie[0] = (u32)(unsigned long)req;
+	r->id.tcpdiag_cookie[1] = (u32)(((unsigned long)req >> 31) >> 1);
+
+	tmo = req->expires - jiffies;
+	if (tmo < 0)
+		tmo = 0;
+
+	r->id.tcpdiag_sport = inet->sport;
+	r->id.tcpdiag_dport = req->rmt_port;
+	r->id.tcpdiag_src[0] = req->af.v4_req.loc_addr;
+	r->id.tcpdiag_dst[0] = req->af.v4_req.rmt_addr;
+	r->tcpdiag_expires = jiffies_to_msecs(tmo),
+	r->tcpdiag_rqueue = 0;
+	r->tcpdiag_wqueue = 0;
+	r->tcpdiag_uid = sock_i_uid(sk);
+	r->tcpdiag_inode = 0;
+#ifdef CONFIG_IP_TCPDIAG_IPV6
+	if (r->tcpdiag_family == AF_INET6) {
+		ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
+			       &req->af.v6_req.loc_addr);
+		ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
+			       &req->af.v6_req.rmt_addr);
+	}
+#endif
+	nlh->nlmsg_len = skb->tail - b;
+
+	return skb->len;
+
+nlmsg_failure:
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk,
+			     struct netlink_callback *cb)
+{
+	struct tcpdiag_entry entry;
+	struct tcpdiagreq *r = NLMSG_DATA(cb->nlh);
+	struct tcp_opt *tp = tcp_sk(sk);
+	struct tcp_listen_opt *lopt;
+	struct rtattr *bc = NULL;
+	struct inet_opt *inet = inet_sk(sk);
+	int j, s_j;
+	int reqnum, s_reqnum;
+	int err = 0;
+
+	s_j = cb->args[3];
+	s_reqnum = cb->args[4];
+
+	if (s_j > 0)
+		s_j--;
+
+	entry.family = sk->sk_family;
+
+	read_lock_bh(&tp->syn_wait_lock);
+
+	lopt = tp->listen_opt;
+	if (!lopt || !lopt->qlen)
+		goto out;
+
+	if (cb->nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(*r))) {
+		bc = (struct rtattr *)(r + 1);
+		entry.sport = inet->num;
+		entry.userlocks = sk->sk_userlocks;
+	}
+
+	for (j = s_j; j < TCP_SYNQ_HSIZE; j++) {
+		struct open_request *req, *head = lopt->syn_table[j];
+
+		reqnum = 0;
+		for (req = head; req; reqnum++, req = req->dl_next) {
+			if (reqnum < s_reqnum)
+				continue;
+			if (r->id.tcpdiag_dport != req->rmt_port &&
+			    r->id.tcpdiag_dport)
+				continue;
+
+			if (bc) {
+				entry.saddr =
+#ifdef CONFIG_IP_TCPDIAG_IPV6
+					(entry.family == AF_INET6) ?
+					req->af.v6_req.loc_addr.s6_addr32 :
+#endif
+					&req->af.v4_req.loc_addr;
+				entry.daddr = 
+#ifdef CONFIG_IP_TCPDIAG_IPV6
+					(entry.family == AF_INET6) ?
+					req->af.v6_req.rmt_addr.s6_addr32 :
+#endif
+					&req->af.v4_req.rmt_addr;
+				entry.dport = ntohs(req->rmt_port);
+
+				if (!tcpdiag_bc_run(RTA_DATA(bc),
+						    RTA_PAYLOAD(bc), &entry))
+					continue;
+			}
+
+			err = tcpdiag_fill_req(skb, sk, req,
+					       NETLINK_CB(cb->skb).pid,
+					       cb->nlh->nlmsg_seq);
+			if (err < 0) {
+				cb->args[3] = j + 1;
+				cb->args[4] = reqnum;
+				goto out;
+			}
+		}
+
+		s_reqnum = 0;
+	}
+
+out:
+	read_unlock_bh(&tp->syn_wait_lock);
+
+	return err;
+}
 
 static int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int i, num;
 	int s_i, s_num;
 	struct tcpdiagreq *r = NLMSG_DATA(cb->nlh);
-	struct rtattr *bc = NULL;
-
-	if (cb->nlh->nlmsg_len > 4+NLMSG_SPACE(sizeof(struct tcpdiagreq)))
-		bc = (struct rtattr*)(r+1);
 
 	s_i = cb->args[1];
 	s_num = num = cb->args[2];
@@ -488,31 +607,47 @@
 			struct sock *sk;
 			struct hlist_node *node;
 
-			if (i > s_i)
-				s_num = 0;
-
 			num = 0;
 			sk_for_each(sk, node, &tcp_listening_hash[i]) {
 				struct inet_opt *inet = inet_sk(sk);
-				if (num < s_num)
-					goto next_listen;
-				if (!(r->tcpdiag_states&TCPF_LISTEN) ||
-				    r->id.tcpdiag_dport)
-					goto next_listen;
+
+				if (num < s_num) {
+					num++;
+					continue;
+				}
+
 				if (r->id.tcpdiag_sport != inet->sport &&
 				    r->id.tcpdiag_sport)
 					goto next_listen;
-				if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk))
+
+				if (!(r->tcpdiag_states&TCPF_LISTEN) ||
+				    r->id.tcpdiag_dport ||
+				    cb->args[3] > 0)
+					goto syn_recv;
+
+				if (tcpdiag_dump_sock(skb, sk, cb) < 0) {
+					tcp_listen_unlock();
+					goto done;
+				}
+
+syn_recv:
+				if (!(r->tcpdiag_states&TCPF_SYN_RECV))
 					goto next_listen;
-				if (tcpdiag_fill(skb, sk, r->tcpdiag_ext,
-						 NETLINK_CB(cb->skb).pid,
-						 cb->nlh->nlmsg_seq) <= 0) {
+
+				if (tcpdiag_dump_reqs(skb, sk, cb) < 0) {
 					tcp_listen_unlock();
 					goto done;
 				}
+
 next_listen:
+				cb->args[3] = 0;
+				cb->args[4] = 0;
 				++num;
 			}
+
+			s_num = 0;
+			cb->args[3] = 0;
+			cb->args[4] = 0;
 		}
 		tcp_listen_unlock();
 skip_listen_ht:
@@ -546,11 +681,7 @@
 				goto next_normal;
 			if (r->id.tcpdiag_dport != inet->dport && r->id.tcpdiag_dport)
 				goto next_normal;
-			if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk))
-				goto next_normal;
-			if (tcpdiag_fill(skb, sk, r->tcpdiag_ext,
-					 NETLINK_CB(cb->skb).pid,
-					 cb->nlh->nlmsg_seq) <= 0) {
+			if (tcpdiag_dump_sock(skb, sk, cb) < 0) {
 				read_unlock_bh(&head->lock);
 				goto done;
 			}
@@ -571,11 +702,7 @@
 				if (r->id.tcpdiag_dport != inet->dport &&
 				    r->id.tcpdiag_dport)
 					goto next_dying;
-				if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk))
-					goto next_dying;
-				if (tcpdiag_fill(skb, sk, r->tcpdiag_ext,
-						 NETLINK_CB(cb->skb).pid,
-						 cb->nlh->nlmsg_seq) <= 0) {
+				if (tcpdiag_dump_sock(skb, sk, cb) < 0) {
 					read_unlock_bh(&head->lock);
 					goto done;
 				}
@@ -657,9 +784,19 @@
 	}
 }
 
-void __init tcpdiag_init(void)
+static int __init tcpdiag_init(void)
 {
 	tcpnl = netlink_kernel_create(NETLINK_TCPDIAG, tcpdiag_rcv);
 	if (tcpnl == NULL)
-		panic("tcpdiag_init: Cannot create netlink socket.");
+		return -ENOMEM;
+	return 0;
 }
+
+static void __exit tcpdiag_exit(void)
+{
+	sock_release(tcpnl->sk_socket);
+}
+
+module_init(tcpdiag_init);
+module_exit(tcpdiag_exit);
+MODULE_LICENSE("GPL");
diff -Nru a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
--- a/net/ipv4/tcp_input.c	2004-12-24 13:37:04 -08:00
+++ b/net/ipv4/tcp_input.c	2004-12-24 13:37:04 -08:00
@@ -2369,25 +2369,19 @@
 {
 	struct tcp_opt *tp = tcp_sk(sk);
 	struct tcp_skb_cb *scb = TCP_SKB_CB(skb); 
-	__u32 mss = tcp_skb_mss(skb);
-	__u32 snd_una = tp->snd_una;
-	__u32 orig_seq, seq;
-	__u32 packets_acked = 0;
+	__u32 seq = tp->snd_una;
+	__u32 packets_acked;
 	int acked = 0;
 
 	/* If we get here, the whole TSO packet has not been
 	 * acked.
 	 */
-	BUG_ON(!after(scb->end_seq, snd_una));
+	BUG_ON(!after(scb->end_seq, seq));
 
-	seq = orig_seq = scb->seq;
-	while (!after(seq + mss, snd_una)) {
-		packets_acked++;
-		seq += mss;
-	}
-
-	if (tcp_trim_head(sk, skb, (seq - orig_seq)))
+	packets_acked = tcp_skb_pcount(skb);
+	if (tcp_trim_head(sk, skb, seq - scb->seq))
 		return 0;
+	packets_acked -= tcp_skb_pcount(skb);
 
 	if (packets_acked) {
 		__u8 sacked = scb->sacked;
@@ -3034,8 +3028,8 @@
 							tp->snd_wscale = *(__u8 *)ptr;
 							if(tp->snd_wscale > 14) {
 								if(net_ratelimit())
-									printk("tcp_parse_options: Illegal window "
-									       "scaling value %d >14 received.",
+									printk(KERN_INFO "tcp_parse_options: Illegal window "
+									       "scaling value %d >14 received.\n",
 									       tp->snd_wscale);
 								tp->snd_wscale = 14;
 							}
@@ -4963,7 +4957,6 @@
 
 EXPORT_SYMBOL(sysctl_tcp_ecn);
 EXPORT_SYMBOL(sysctl_tcp_reordering);
-EXPORT_SYMBOL(tcp_cwnd_application_limited);
 EXPORT_SYMBOL(tcp_parse_options);
 EXPORT_SYMBOL(tcp_rcv_established);
 EXPORT_SYMBOL(tcp_rcv_state_process);
diff -Nru a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c	2004-12-24 13:36:34 -08:00
+++ b/net/ipv4/tcp_ipv4.c	2004-12-24 13:36:34 -08:00
@@ -448,8 +448,8 @@
 }
 
 /* Optimize the common listener case. */
-inline struct sock *tcp_v4_lookup_listener(u32 daddr, unsigned short hnum,
-					   int dif)
+static inline struct sock *tcp_v4_lookup_listener(u32 daddr,
+		unsigned short hnum, int dif)
 {
 	struct sock *sk = NULL;
 	struct hlist_head *head;
@@ -535,6 +535,8 @@
 	return sk;
 }
 
+EXPORT_SYMBOL_GPL(tcp_v4_lookup);
+
 static inline __u32 tcp_v4_init_sequence(struct sock *sk, struct sk_buff *skb)
 {
 	return secure_tcp_sequence_number(skb->nh.iph->daddr,
@@ -2596,6 +2598,7 @@
 
 struct proto tcp_prot = {
 	.name			= "TCP",
+	.owner			= THIS_MODULE,
 	.close			= tcp_close,
 	.connect		= tcp_v4_connect,
 	.disconnect		= tcp_disconnect,
@@ -2653,7 +2656,6 @@
 EXPORT_SYMBOL(tcp_v4_conn_request);
 EXPORT_SYMBOL(tcp_v4_connect);
 EXPORT_SYMBOL(tcp_v4_do_rcv);
-EXPORT_SYMBOL(tcp_v4_lookup_listener);
 EXPORT_SYMBOL(tcp_v4_rebuild_header);
 EXPORT_SYMBOL(tcp_v4_remember_stamp);
 EXPORT_SYMBOL(tcp_v4_send_check);
@@ -2663,8 +2665,7 @@
 EXPORT_SYMBOL(tcp_proc_register);
 EXPORT_SYMBOL(tcp_proc_unregister);
 #endif
-#ifdef CONFIG_SYSCTL
 EXPORT_SYMBOL(sysctl_local_port_range);
 EXPORT_SYMBOL(sysctl_max_syn_backlog);
 EXPORT_SYMBOL(sysctl_tcp_low_latency);
-#endif
+
diff -Nru a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
--- a/net/ipv4/tcp_minisocks.c	2004-12-24 13:37:04 -08:00
+++ b/net/ipv4/tcp_minisocks.c	2004-12-24 13:37:04 -08:00
@@ -706,7 +706,7 @@
 		sock_lock_init(newsk);
 		bh_lock_sock(newsk);
 
-		newsk->sk_dst_lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&newsk->sk_dst_lock);
 		atomic_set(&newsk->sk_rmem_alloc, 0);
 		skb_queue_head_init(&newsk->sk_receive_queue);
 		atomic_set(&newsk->sk_wmem_alloc, 0);
@@ -719,7 +719,7 @@
 		newsk->sk_userlocks = sk->sk_userlocks & ~SOCK_BINDPORT_LOCK;
 		newsk->sk_backlog.head = newsk->sk_backlog.tail = NULL;
 		newsk->sk_send_head = NULL;
-		newsk->sk_callback_lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&newsk->sk_callback_lock);
 		skb_queue_head_init(&newsk->sk_error_queue);
 		newsk->sk_write_space = sk_stream_write_space;
 
@@ -1075,7 +1075,3 @@
 EXPORT_SYMBOL(tcp_create_openreq_child);
 EXPORT_SYMBOL(tcp_timewait_state_process);
 EXPORT_SYMBOL(tcp_tw_deschedule);
-
-#ifdef CONFIG_SYSCTL
-EXPORT_SYMBOL(sysctl_tcp_tw_recycle);
-#endif
diff -Nru a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
--- a/net/ipv4/tcp_output.c	2004-12-24 13:37:01 -08:00
+++ b/net/ipv4/tcp_output.c	2004-12-24 13:37:01 -08:00
@@ -455,9 +455,13 @@
 {
 	struct tcp_opt *tp = tcp_sk(sk);
 	struct sk_buff *buff;
-	int nsize = skb->len - len;
+	int nsize;
 	u16 flags;
 
+	nsize = skb_headlen(skb) - len;
+	if (nsize < 0)
+		nsize = 0;
+
 	if (skb_cloned(skb) &&
 	    skb_is_nonlinear(skb) &&
 	    pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
@@ -562,8 +566,6 @@
 
 int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
 {
-	struct tcp_opt *tp = tcp_sk(sk);
-
 	if (skb_cloned(skb) &&
 	    pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
 		return -ENOMEM;
@@ -586,7 +588,8 @@
 	/* Any change of skb->len requires recalculation of tso
 	 * factor and mss.
 	 */
-	tcp_set_skb_tso_segs(skb, tp->mss_cache_std);
+	if (tcp_skb_pcount(skb) > 1)
+		tcp_set_skb_tso_segs(skb, tcp_skb_mss(skb));
 
 	return 0;
 }
@@ -1102,6 +1105,8 @@
 		/* Update global TCP statistics. */
 		TCP_INC_STATS(TCP_MIB_RETRANSSEGS);
 
+		tp->total_retrans++;
+
 #if FASTRETRANS_DEBUG > 0
 		if (TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_RETRANS) {
 			if (net_ratelimit())
@@ -1715,12 +1720,7 @@
 	}
 }
 
-EXPORT_SYMBOL(tcp_acceptable_seq);
 EXPORT_SYMBOL(tcp_connect);
-EXPORT_SYMBOL(tcp_connect_init);
 EXPORT_SYMBOL(tcp_make_synack);
-EXPORT_SYMBOL(tcp_send_synack);
 EXPORT_SYMBOL(tcp_simple_retransmit);
 EXPORT_SYMBOL(tcp_sync_mss);
-EXPORT_SYMBOL(tcp_write_wakeup);
-EXPORT_SYMBOL(tcp_write_xmit);
diff -Nru a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
--- a/net/ipv4/tcp_timer.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv4/tcp_timer.c	2004-12-24 13:37:19 -08:00
@@ -36,7 +36,9 @@
 static void tcp_delack_timer(unsigned long);
 static void tcp_keepalive_timer (unsigned long data);
 
-const char timer_bug_msg[] = KERN_DEBUG "tcpbug: unknown timer value\n";
+#ifdef TCP_DEBUG
+const char tcp_timer_bug_msg[] = KERN_DEBUG "tcpbug: unknown timer value\n";
+#endif
 
 /*
  * Using different timers for retransmit, delayed acks and probes
@@ -651,3 +653,6 @@
 EXPORT_SYMBOL(tcp_delete_keepalive_timer);
 EXPORT_SYMBOL(tcp_init_xmit_timers);
 EXPORT_SYMBOL(tcp_reset_keepalive_timer);
+#ifdef TCP_DEBUG
+EXPORT_SYMBOL(tcp_timer_bug_msg);
+#endif
diff -Nru a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c	2004-12-24 13:36:19 -08:00
+++ b/net/ipv4/udp.c	2004-12-24 13:36:19 -08:00
@@ -531,7 +531,7 @@
 			return -EINVAL;
 		if (usin->sin_family != AF_INET) {
 			if (usin->sin_family != AF_UNSPEC)
-				return -EINVAL;
+				return -EAFNOSUPPORT;
 		}
 
 		daddr = usin->sin_addr.s_addr;
@@ -1303,9 +1303,56 @@
   	return 0;
 }
 
+/**
+ * 	udp_poll - wait for a UDP event.
+ *	@file - file struct
+ *	@sock - socket
+ *	@wait - poll table
+ *
+ *	This is same as datagram poll, except for the special case of 
+ *	blocking sockets. If application is using a blocking fd
+ *	and a packet with checksum error is in the queue;
+ *	then it could get return from select indicating data available
+ *	but then block when reading it. Add special case code
+ *	to work around these arguably broken applications.
+ */
+unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
+{
+	unsigned int mask = datagram_poll(file, sock, wait);
+	struct sock *sk = sock->sk;
+	
+	/* Check for false positives due to checksum errors */
+	if ( (mask & POLLRDNORM) &&
+	     !(file->f_flags & O_NONBLOCK) &&
+	     !(sk->sk_shutdown & RCV_SHUTDOWN)){
+		struct sk_buff_head *rcvq = &sk->sk_receive_queue;
+		struct sk_buff *skb;
+
+		spin_lock_irq(&rcvq->lock);
+		while ((skb = skb_peek(rcvq)) != NULL) {
+			if (udp_checksum_complete(skb)) {
+				UDP_INC_STATS_BH(UDP_MIB_INERRORS);
+				__skb_unlink(skb, rcvq);
+				kfree_skb(skb);
+			} else {
+				skb->ip_summed = CHECKSUM_UNNECESSARY;
+				break;
+			}
+		}
+		spin_unlock_irq(&rcvq->lock);
+
+		/* nothing to see, move along */
+		if (skb == NULL)
+			mask &= ~(POLLIN | POLLRDNORM);
+	}
+
+	return mask;
+	
+}
 
 struct proto udp_prot = {
  	.name =		"UDP",
+	.owner =	THIS_MODULE,
 	.close =	udp_close,
 	.connect =	ip4_datagram_connect,
 	.disconnect =	udp_disconnect,
@@ -1516,6 +1563,7 @@
 EXPORT_SYMBOL(udp_port_rover);
 EXPORT_SYMBOL(udp_prot);
 EXPORT_SYMBOL(udp_sendmsg);
+EXPORT_SYMBOL(udp_poll);
 
 #ifdef CONFIG_PROC_FS
 EXPORT_SYMBOL(udp_proc_register);
diff -Nru a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c
--- a/net/ipv4/xfrm4_input.c	2004-12-24 13:36:18 -08:00
+++ b/net/ipv4/xfrm4_input.c	2004-12-24 13:36:18 -08:00
@@ -9,6 +9,7 @@
  * 	
  */
 
+#include <linux/module.h>
 #include <linux/string.h>
 #include <net/inet_ecn.h>
 #include <net/ip.h>
@@ -18,6 +19,8 @@
 {
 	return xfrm4_rcv_encap(skb, 0);
 }
+
+EXPORT_SYMBOL(xfrm4_rcv);
 
 static inline void ipip_ecn_decapsulate(struct sk_buff *skb)
 {
diff -Nru a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
--- a/net/ipv4/xfrm4_output.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv4/xfrm4_output.c	2004-12-24 13:36:31 -08:00
@@ -91,16 +91,14 @@
 	return ret;
 }
 
-int xfrm4_output(struct sk_buff **pskb)
+int xfrm4_output(struct sk_buff *skb)
 {
-	struct sk_buff *skb = *pskb;
 	struct dst_entry *dst = skb->dst;
 	struct xfrm_state *x = dst->xfrm;
 	int err;
 	
 	if (skb->ip_summed == CHECKSUM_HW) {
-		err = skb_checksum_help(pskb, 0);
-		skb = *pskb;
+		err = skb_checksum_help(skb, 0);
 		if (err)
 			goto error_nolock;
 	}
diff -Nru a/net/ipv6/Kconfig b/net/ipv6/Kconfig
--- a/net/ipv6/Kconfig	2004-12-24 13:36:55 -08:00
+++ b/net/ipv6/Kconfig	2004-12-24 13:36:55 -08:00
@@ -52,8 +52,8 @@
 	select CRYPTO
 	select CRYPTO_DEFLATE
 	---help---
-	  Support for IP Paylod Compression (RFC3173), typically needed
-	  for IPsec.
+	  Support for IP Payload Compression Protocol (IPComp) (RFC3173),
+	  typically needed for IPsec.
 
 	  If unsure, say Y.
 
diff -Nru a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
--- a/net/ipv6/addrconf.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv6/addrconf.c	2004-12-24 13:37:19 -08:00
@@ -137,6 +137,7 @@
 static void addrconf_dad_timer(unsigned long data);
 static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
 static void addrconf_rs_timer(unsigned long data);
+static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
 
 static void inet6_prefix_notify(int event, struct inet6_dev *idev, 
@@ -326,7 +327,7 @@
 	if (ndev) {
 		memset(ndev, 0, sizeof(struct inet6_dev));
 
-		ndev->lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&ndev->lock);
 		ndev->dev = dev;
 		memcpy(&ndev->cnf, &ipv6_devconf_dflt, sizeof(ndev->cnf));
 		ndev->cnf.mtu6 = dev->mtu;
@@ -404,6 +405,7 @@
 	return idev;
 }
 
+#ifdef CONFIG_SYSCTL
 static void dev_forward_change(struct inet6_dev *idev)
 {
 	struct net_device *dev;
@@ -449,7 +451,7 @@
 	}
 	read_unlock(&dev_base_lock);
 }
-
+#endif
 
 /* Nobody refers to this ifaddr, destroy it */
 
@@ -485,10 +487,15 @@
 	struct inet6_ifaddr *ifa = NULL;
 	struct rt6_info *rt;
 	int hash;
-	static spinlock_t lock = SPIN_LOCK_UNLOCKED;
 	int err = 0;
 
-	spin_lock_bh(&lock);
+	read_lock_bh(&addrconf_lock);
+	if (idev->dead) {
+		err = -ENODEV;			/*XXX*/
+		goto out2;
+	}
+
+	write_lock(&addrconf_hash_lock);
 
 	/* Ignore adding duplicate addresses on an interface */
 	if (ipv6_chk_same_addr(addr, idev->dev)) {
@@ -522,13 +529,6 @@
 	ifa->flags = flags | IFA_F_TENTATIVE;
 	ifa->cstamp = ifa->tstamp = jiffies;
 
-	read_lock(&addrconf_lock);
-	if (idev->dead) {
-		read_unlock(&addrconf_lock);
-		err = -ENODEV;	/*XXX*/
-		goto out;
-	}
-
 	inet6_ifa_count++;
 	ifa->idev = idev;
 	in6_dev_hold(idev);
@@ -538,35 +538,30 @@
 	/* Add to big hash table */
 	hash = ipv6_addr_hash(addr);
 
-	write_lock_bh(&addrconf_hash_lock);
 	ifa->lst_next = inet6_addr_lst[hash];
 	inet6_addr_lst[hash] = ifa;
 	in6_ifa_hold(ifa);
-	write_unlock_bh(&addrconf_hash_lock);
+	write_unlock(&addrconf_hash_lock);
 
-	write_lock_bh(&idev->lock);
+	write_lock(&idev->lock);
 	/* Add to inet6_dev unicast addr list. */
 	ifa->if_next = idev->addr_list;
 	idev->addr_list = ifa;
 
 #ifdef CONFIG_IPV6_PRIVACY
-	ifa->regen_count = 0;
 	if (ifa->flags&IFA_F_TEMPORARY) {
 		ifa->tmp_next = idev->tempaddr_list;
 		idev->tempaddr_list = ifa;
 		in6_ifa_hold(ifa);
-	} else {
-		ifa->tmp_next = NULL;
 	}
 #endif
 
 	ifa->rt = rt;
 
 	in6_ifa_hold(ifa);
-	write_unlock_bh(&idev->lock);
-	read_unlock(&addrconf_lock);
-out:
-	spin_unlock_bh(&lock);
+	write_unlock(&idev->lock);
+out2:
+	read_unlock_bh(&addrconf_lock);
 
 	if (unlikely(err == 0))
 		notifier_call_chain(&inet6addr_chain, NETDEV_UP, ifa);
@@ -576,6 +571,9 @@
 	}
 
 	return ifa;
+out:
+	write_unlock(&addrconf_hash_lock);
+	goto out2;
 }
 
 /* This function wants to get referenced ifp and releases it before return */
@@ -644,13 +642,14 @@
 #ifdef CONFIG_IPV6_PRIVACY
 static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift)
 {
-	struct inet6_dev *idev;
+	struct inet6_dev *idev = ifp->idev;
 	struct in6_addr addr, *tmpaddr;
-	unsigned long tmp_prefered_lft, tmp_valid_lft;
+	unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_cstamp, tmp_tstamp;
 	int tmp_plen;
 	int ret = 0;
 	int max_addresses;
 
+	write_lock(&idev->lock);
 	if (ift) {
 		spin_lock_bh(&ift->lock);
 		memcpy(&addr.s6_addr[8], &ift->addr.s6_addr[8], 8);
@@ -660,40 +659,35 @@
 		tmpaddr = NULL;
 	}
 retry:
-	spin_lock_bh(&ifp->lock);
-	in6_ifa_hold(ifp);
-	idev = ifp->idev;
 	in6_dev_hold(idev);
-	memcpy(addr.s6_addr, ifp->addr.s6_addr, 8);
-	write_lock(&idev->lock);
 	if (idev->cnf.use_tempaddr <= 0) {
 		write_unlock(&idev->lock);
-		spin_unlock_bh(&ifp->lock);
 		printk(KERN_INFO
 			"ipv6_create_tempaddr(): use_tempaddr is disabled.\n");
 		in6_dev_put(idev);
-		in6_ifa_put(ifp);
 		ret = -1;
 		goto out;
 	}
+	spin_lock_bh(&ifp->lock);
 	if (ifp->regen_count++ >= idev->cnf.regen_max_retry) {
 		idev->cnf.use_tempaddr = -1;	/*XXX*/
-		write_unlock(&idev->lock);
 		spin_unlock_bh(&ifp->lock);
+		write_unlock(&idev->lock);
 		printk(KERN_WARNING
 			"ipv6_create_tempaddr(): regeneration time exceeded. disabled temporary address support.\n");
 		in6_dev_put(idev);
-		in6_ifa_put(ifp);
 		ret = -1;
 		goto out;
 	}
+	in6_ifa_hold(ifp);
+	memcpy(addr.s6_addr, ifp->addr.s6_addr, 8);
 	if (__ipv6_try_regen_rndid(idev, tmpaddr) < 0) {
-		write_unlock(&idev->lock);
 		spin_unlock_bh(&ifp->lock);
+		write_unlock(&idev->lock);
 		printk(KERN_WARNING
 			"ipv6_create_tempaddr(): regeneration of randomized interface id failed.\n");
-		in6_dev_put(idev);
 		in6_ifa_put(ifp);
+		in6_dev_put(idev);
 		ret = -1;
 		goto out;
 	}
@@ -706,27 +700,33 @@
 				 idev->cnf.temp_prefered_lft - desync_factor / HZ);
 	tmp_plen = ifp->prefix_len;
 	max_addresses = idev->cnf.max_addresses;
-	write_unlock(&idev->lock);
+	tmp_cstamp = ifp->cstamp;
+	tmp_tstamp = ifp->tstamp;
 	spin_unlock_bh(&ifp->lock);
+
+	write_unlock(&idev->lock);
 	ift = !max_addresses ||
 	      ipv6_count_addresses(idev) < max_addresses ? 
 		ipv6_add_addr(idev, &addr, tmp_plen,
 			      ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK, IFA_F_TEMPORARY) : NULL;
 	if (!ift || IS_ERR(ift)) {
-		in6_dev_put(idev);
 		in6_ifa_put(ifp);
+		in6_dev_put(idev);
 		printk(KERN_INFO
 			"ipv6_create_tempaddr(): retry temporary address regeneration.\n");
 		tmpaddr = &addr;
+		write_lock(&idev->lock);
 		goto retry;
 	}
+
 	spin_lock_bh(&ift->lock);
 	ift->ifpub = ifp;
 	ift->valid_lft = tmp_valid_lft;
 	ift->prefered_lft = tmp_prefered_lft;
-	ift->cstamp = ifp->cstamp;
-	ift->tstamp = ifp->tstamp;
+	ift->cstamp = tmp_cstamp;
+	ift->tstamp = tmp_tstamp;
 	spin_unlock_bh(&ift->lock);
+
 	addrconf_dad_start(ift, 0);
 	in6_ifa_put(ift);
 	in6_dev_put(idev);
@@ -760,7 +760,7 @@
 #endif
 
 int ipv6_dev_get_saddr(struct net_device *dev,
-		   struct in6_addr *daddr, struct in6_addr *saddr, int onlink)
+		       struct in6_addr *daddr, struct in6_addr *saddr)
 {
 	struct inet6_ifaddr *ifp = NULL;
 	struct inet6_ifaddr *match = NULL;
@@ -769,10 +769,7 @@
 	int err;
 	int hiscore = -1, score;
 
-	if (!onlink)
-		scope = ipv6_addr_scope(daddr);
-	else
-		scope = IFA_LINK;
+	scope = ipv6_addr_scope(daddr);
 
 	/*
 	 *	known dev
@@ -877,17 +874,7 @@
 int ipv6_get_saddr(struct dst_entry *dst,
 		   struct in6_addr *daddr, struct in6_addr *saddr)
 {
-	struct rt6_info *rt;
-	struct net_device *dev = NULL;
-	int onlink;
-
-	rt = (struct rt6_info *) dst;
-	if (rt)
-		dev = rt->rt6i_dev;
-
-	onlink = (rt && (rt->rt6i_flags & RTF_ALLONLINK));
-
-	return ipv6_dev_get_saddr(dev, daddr, saddr, onlink);
+	return ipv6_dev_get_saddr(dst ? dst->dev : NULL, daddr, saddr);
 }
 
 
@@ -933,7 +920,7 @@
 
 	read_lock_bh(&addrconf_hash_lock);
 	for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
-		if (ipv6_addr_cmp(&ifp->addr, addr) == 0 &&
+		if (ipv6_addr_equal(&ifp->addr, addr) &&
 		    !(ifp->flags&IFA_F_TENTATIVE)) {
 			if (dev == NULL || ifp->idev->dev == dev ||
 			    !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))
@@ -950,14 +937,12 @@
 	struct inet6_ifaddr * ifp;
 	u8 hash = ipv6_addr_hash(addr);
 
-	read_lock_bh(&addrconf_hash_lock);
 	for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
-		if (ipv6_addr_cmp(&ifp->addr, addr) == 0) {
+		if (ipv6_addr_equal(&ifp->addr, addr)) {
 			if (dev == NULL || ifp->idev->dev == dev)
 				break;
 		}
 	}
-	read_unlock_bh(&addrconf_hash_lock);
 	return ifp != NULL;
 }
 
@@ -968,7 +953,7 @@
 
 	read_lock_bh(&addrconf_hash_lock);
 	for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
-		if (ipv6_addr_cmp(&ifp->addr, addr) == 0) {
+		if (ipv6_addr_equal(&ifp->addr, addr)) {
 			if (dev == NULL || ifp->idev->dev == dev ||
 			    !(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) {
 				in6_ifa_hold(ifp);
@@ -1004,7 +989,7 @@
 		return 1;
 
 	if (sk2_rcv_saddr6 &&
-	    !ipv6_addr_cmp(sk_rcv_saddr6, sk2_rcv_saddr6))
+	    ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
 		return 1;
 
 	if (addr_type == IPV6_ADDR_MAPPED &&
@@ -1642,7 +1627,7 @@
 	read_lock_bh(&idev->lock);
 	for (ifp = idev->addr_list; ifp; ifp=ifp->if_next) {
 		if (ifp->prefix_len == plen &&
-		    (!memcmp(pfx, &ifp->addr, sizeof(struct in6_addr)))) {
+		    ipv6_addr_equal(pfx, &ifp->addr)) {
 			in6_ifa_hold(ifp);
 			read_unlock_bh(&idev->lock);
 			
@@ -2061,7 +2046,7 @@
 		addrconf_del_timer(ifa);
 		write_unlock_bh(&idev->lock);
 
-		ipv6_ifa_notify(RTM_DELADDR, ifa);
+		__ipv6_ifa_notify(RTM_DELADDR, ifa);
 		in6_ifa_put(ifa);
 
 		write_lock_bh(&idev->lock);
@@ -2141,11 +2126,10 @@
  */
 static void addrconf_dad_start(struct inet6_ifaddr *ifp, int flags)
 {
-	struct net_device *dev;
+	struct inet6_dev *idev = ifp->idev;
+	struct net_device *dev = idev->dev;
 	unsigned long rand_num;
 
-	dev = ifp->idev->dev;
-
 	addrconf_join_solict(dev, &ifp->addr);
 
 	if (ifp->prefix_len != 128 && (ifp->flags&IFA_F_PERMANENT))
@@ -2153,31 +2137,43 @@
 					flags);
 
 	net_srandom(ifp->addr.s6_addr32[3]);
-	rand_num = net_random() % (ifp->idev->cnf.rtr_solicit_delay ? : 1);
+	rand_num = net_random() % (idev->cnf.rtr_solicit_delay ? : 1);
 
+	read_lock_bh(&idev->lock);
+	if (ifp->dead)
+		goto out;
 	spin_lock_bh(&ifp->lock);
 
 	if (dev->flags&(IFF_NOARP|IFF_LOOPBACK) ||
 	    !(ifp->flags&IFA_F_TENTATIVE)) {
 		ifp->flags &= ~IFA_F_TENTATIVE;
 		spin_unlock_bh(&ifp->lock);
+		read_unlock_bh(&idev->lock);
 
 		addrconf_dad_completed(ifp);
 		return;
 	}
 
-	ifp->probes = ifp->idev->cnf.dad_transmits;
+	ifp->probes = idev->cnf.dad_transmits;
 	addrconf_mod_timer(ifp, AC_DAD, rand_num);
 
 	spin_unlock_bh(&ifp->lock);
+out:
+	read_unlock_bh(&idev->lock);
 }
 
 static void addrconf_dad_timer(unsigned long data)
 {
 	struct inet6_ifaddr *ifp = (struct inet6_ifaddr *) data;
+	struct inet6_dev *idev = ifp->idev;
 	struct in6_addr unspec;
 	struct in6_addr mcaddr;
 
+	read_lock_bh(&idev->lock);
+	if (idev->dead) {
+		read_unlock_bh(&idev->lock);
+		goto out;
+	}
 	spin_lock_bh(&ifp->lock);
 	if (ifp->probes == 0) {
 		/*
@@ -2186,22 +2182,23 @@
 
 		ifp->flags &= ~IFA_F_TENTATIVE;
 		spin_unlock_bh(&ifp->lock);
+		read_unlock_bh(&idev->lock);
 
 		addrconf_dad_completed(ifp);
 
-		in6_ifa_put(ifp);
-		return;
+		goto out;
 	}
 
 	ifp->probes--;
 	addrconf_mod_timer(ifp, AC_DAD, ifp->idev->nd_parms->retrans_time);
 	spin_unlock_bh(&ifp->lock);
+	read_unlock_bh(&idev->lock);
 
 	/* send a neighbour solicitation for our addr */
 	memset(&unspec, 0, sizeof(unspec));
 	addrconf_addr_solict_mult(&ifp->addr, &mcaddr);
 	ndisc_send_ns(ifp->idev->dev, NULL, &ifp->addr, &mcaddr, &unspec);
-
+out:
 	in6_ifa_put(ifp);
 }
 
@@ -2992,7 +2989,7 @@
 				      .dumpit	= inet6_dump_fib, },
 };
 
-static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
+static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
 {
 	inet6_ifa_notify(event ? : RTM_NEWADDR, ifp);
 
@@ -3017,6 +3014,14 @@
 	}
 }
 
+static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
+{
+	read_lock_bh(&addrconf_lock);
+	if (likely(ifp->idev->dead == 0))
+		__ipv6_ifa_notify(event, ifp);
+	read_unlock_bh(&addrconf_lock);
+}
+
 #ifdef CONFIG_SYSCTL
 
 static
@@ -3042,7 +3047,7 @@
 			addrconf_forward_change();
 		}
 		if (*valp)
-			rt6_purge_dflt_routers(0);
+			rt6_purge_dflt_routers();
 	}
 
         return ret;
@@ -3096,7 +3101,7 @@
 		}
 
 		if (*valp)
-			rt6_purge_dflt_routers(0);
+			rt6_purge_dflt_routers();
 	} else
 		*valp = new;
 
@@ -3399,6 +3404,29 @@
 
 void __init addrconf_init(void)
 {
+	/* The addrconf netdev notifier requires that loopback_dev
+	 * has it's ipv6 private information allocated and setup
+	 * before it can bring up and give link-local addresses
+	 * to other devices which are up.
+	 *
+	 * Unfortunately, loopback_dev is not necessarily the first
+	 * entry in the global dev_base list of net devices.  In fact,
+	 * it is likely to be the very last entry on that list.
+	 * So this causes the notifier registry below to try and
+	 * give link-local addresses to all devices besides loopback_dev
+	 * first, then loopback_dev, which cases all the non-loopback_dev
+	 * devices to fail to get a link-local address.
+	 *
+	 * So, as a temporary fix, register loopback_dev first by hand.
+	 * Longer term, all of the dependencies ipv6 has upon the loopback
+	 * device and it being up should be removed.
+	 */
+	rtnl_lock();
+	addrconf_notify(&ipv6_dev_notf, NETDEV_REGISTER, &loopback_dev);
+	if (loopback_dev.flags & IFF_UP)
+		addrconf_notify(&ipv6_dev_notf, NETDEV_UP, &loopback_dev);
+	rtnl_unlock();
+
 	register_netdevice_notifier(&ipv6_dev_notf);
 
 #ifdef CONFIG_IPV6_PRIVACY
diff -Nru a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
--- a/net/ipv6/af_inet6.c	2004-12-24 13:36:56 -08:00
+++ b/net/ipv6/af_inet6.c	2004-12-24 13:36:56 -08:00
@@ -174,10 +174,10 @@
 		goto out;
 
 	sock_init_data(sock, sk);
-	sk_set_owner(sk, THIS_MODULE);
+	sk->sk_prot = answer_prot;
+	sk_set_owner(sk, sk->sk_prot->owner);
 
 	rc = 0;
-	sk->sk_prot = answer_prot;
 	sk->sk_no_check = answer_no_check;
 	if (INET_PROTOSW_REUSE & answer_flags)
 		sk->sk_reuse = 1;
@@ -501,7 +501,7 @@
 	.socketpair =	sock_no_socketpair,		/* a do nothing	*/
 	.accept =	sock_no_accept,			/* a do nothing	*/
 	.getname =	inet6_getname, 
-	.poll =		datagram_poll,			/* ok		*/
+	.poll =		udp_poll,			/* ok		*/
 	.ioctl =	inet6_ioctl,			/* must change  */
 	.listen =	sock_no_listen,			/* ok		*/
 	.shutdown =	inet_shutdown,			/* ok		*/
@@ -524,11 +524,33 @@
 extern void ipv6_sysctl_unregister(void);
 #endif
 
+/* Same as inet6_dgram_ops, sans udp_poll.  */
+static struct proto_ops inet6_sockraw_ops = {
+	.family =	PF_INET6,
+	.owner =	THIS_MODULE,
+	.release =	inet6_release,
+	.bind =		inet6_bind,
+	.connect =	inet_dgram_connect,		/* ok		*/
+	.socketpair =	sock_no_socketpair,		/* a do nothing	*/
+	.accept =	sock_no_accept,			/* a do nothing	*/
+	.getname =	inet6_getname, 
+	.poll =		datagram_poll,			/* ok		*/
+	.ioctl =	inet6_ioctl,			/* must change  */
+	.listen =	sock_no_listen,			/* ok		*/
+	.shutdown =	inet_shutdown,			/* ok		*/
+	.setsockopt =	sock_common_setsockopt,		/* ok		*/
+	.getsockopt =	sock_common_getsockopt,		/* ok		*/
+	.sendmsg =	inet_sendmsg,			/* ok		*/
+	.recvmsg =	sock_common_recvmsg,		/* ok		*/
+	.mmap =		sock_no_mmap,
+	.sendpage =	sock_no_sendpage,
+};
+
 static struct inet_protosw rawv6_protosw = {
 	.type		= SOCK_RAW,
 	.protocol	= IPPROTO_IP,	/* wild card */
 	.prot		= &rawv6_prot,
-	.ops		= &inet6_dgram_ops,
+	.ops		= &inet6_sockraw_ops,
 	.capability	= CAP_NET_RAW,
 	.no_check	= UDP_CSUM_DEFAULT,
 	.flags		= INET_PROTOSW_REUSE,
diff -Nru a/net/ipv6/anycast.c b/net/ipv6/anycast.c
--- a/net/ipv6/anycast.c	2004-12-24 13:37:43 -08:00
+++ b/net/ipv6/anycast.c	2004-12-24 13:37:43 -08:00
@@ -205,7 +205,7 @@
 	prev_pac = NULL;
 	for (pac = np->ipv6_ac_list; pac; pac = pac->acl_next) {
 		if ((ifindex == 0 || pac->acl_ifindex == ifindex) &&
-		     ipv6_addr_cmp(&pac->acl_addr, addr) == 0)
+		     ipv6_addr_equal(&pac->acl_addr, addr))
 			break;
 		prev_pac = pac;
 	}
@@ -278,7 +278,7 @@
 	for (pac=np->ipv6_ac_list; pac; pac=pac->acl_next) {
 		if (ifindex && pac->acl_ifindex != ifindex)
 			continue;
-		found = ipv6_addr_cmp(&pac->acl_addr, addr) == 0;
+		found = ipv6_addr_equal(&pac->acl_addr, addr);
 		if (found)
 			break;
 	}
@@ -320,7 +320,7 @@
 	}
 
 	for (aca = idev->ac_list; aca; aca = aca->aca_next) {
-		if (ipv6_addr_cmp(&aca->aca_addr, addr) == 0) {
+		if (ipv6_addr_equal(&aca->aca_addr, addr)) {
 			aca->aca_users++;
 			err = 0;
 			goto out;
@@ -354,7 +354,7 @@
 	/* aca_tstamp should be updated upon changes */
 	aca->aca_cstamp = aca->aca_tstamp = jiffies;
 	atomic_set(&aca->aca_refcnt, 2);
-	aca->aca_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&aca->aca_lock);
 
 	aca->aca_next = idev->ac_list;
 	idev->ac_list = aca;
@@ -384,7 +384,7 @@
 	write_lock_bh(&idev->lock);
 	prev_aca = NULL;
 	for (aca = idev->ac_list; aca; aca = aca->aca_next) {
-		if (ipv6_addr_cmp(&aca->aca_addr, addr) == 0)
+		if (ipv6_addr_equal(&aca->aca_addr, addr))
 			break;
 		prev_aca = aca;
 	}
@@ -436,7 +436,7 @@
 	if (idev) {
 		read_lock_bh(&idev->lock);
 		for (aca = idev->ac_list; aca; aca = aca->aca_next)
-			if (ipv6_addr_cmp(&aca->aca_addr, addr) == 0)
+			if (ipv6_addr_equal(&aca->aca_addr, addr))
 				break;
 		read_unlock_bh(&idev->lock);
 		in6_dev_put(idev);
diff -Nru a/net/ipv6/datagram.c b/net/ipv6/datagram.c
--- a/net/ipv6/datagram.c	2004-12-24 13:36:18 -08:00
+++ b/net/ipv6/datagram.c	2004-12-24 13:36:18 -08:00
@@ -190,7 +190,7 @@
 	}
 
 	ip6_dst_store(sk, dst,
-		      !ipv6_addr_cmp(&fl.fl6_dst, &np->daddr) ?
+		      ipv6_addr_equal(&fl.fl6_dst, &np->daddr) ?
 		      &np->daddr : NULL);
 
 	sk->sk_state = TCP_ESTABLISHED;
@@ -427,9 +427,7 @@
 		int addr_type;
 		struct net_device *dev = NULL;
 
-		if (cmsg->cmsg_len < sizeof(struct cmsghdr) ||
-		    (unsigned long)(((char*)cmsg - (char*)msg->msg_control)
-				    + cmsg->cmsg_len) > msg->msg_controllen) {
+		if (!CMSG_OK(msg, cmsg)) {
 			err = -EINVAL;
 			goto exit_f;
 		}
diff -Nru a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
--- a/net/ipv6/ip6_fib.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv6/ip6_fib.c	2004-12-24 13:37:18 -08:00
@@ -433,7 +433,7 @@
 
 	if (fn->fn_flags&RTN_TL_ROOT &&
 	    fn->leaf == &ip6_null_entry &&
-	    !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF | RTF_ALLONLINK)) ){
+	    !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){
 		fn->leaf = rt;
 		rt->u.next = NULL;
 		goto out;
@@ -451,8 +451,8 @@
 
 			if (iter->rt6i_dev == rt->rt6i_dev &&
 			    iter->rt6i_idev == rt->rt6i_idev &&
-			    ipv6_addr_cmp(&iter->rt6i_gateway,
-					   &rt->rt6i_gateway) == 0) {
+			    ipv6_addr_equal(&iter->rt6i_gateway,
+					    &rt->rt6i_gateway)) {
 				if (!(iter->rt6i_flags&RTF_EXPIRES))
 					return -EEXIST;
 				iter->rt6i_expires = rt->rt6i_expires;
diff -Nru a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
--- a/net/ipv6/ip6_flowlabel.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv6/ip6_flowlabel.c	2004-12-24 13:36:31 -08:00
@@ -500,7 +500,7 @@
 					goto release;
 
 				err = -EINVAL;
-				if (ipv6_addr_cmp(&fl1->dst, &fl->dst) ||
+				if (!ipv6_addr_equal(&fl1->dst, &fl->dst) ||
 				    ipv6_opt_cmp(fl1->opt, fl->opt))
 					goto release;
 
diff -Nru a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
--- a/net/ipv6/ip6_output.c	2004-12-24 13:36:17 -08:00
+++ b/net/ipv6/ip6_output.c	2004-12-24 13:36:17 -08:00
@@ -56,7 +56,7 @@
 #include <net/xfrm.h>
 #include <net/checksum.h>
 
-static int ip6_fragment(struct sk_buff **pskb, int (*output)(struct sk_buff**));
+static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
 
 static __inline__ void ipv6_select_ident(struct sk_buff *skb, struct frag_hdr *fhdr)
 {
@@ -108,9 +108,8 @@
 }
 
 
-static int ip6_output2(struct sk_buff **pskb)
+static int ip6_output2(struct sk_buff *skb)
 {
-	struct sk_buff *skb = *pskb;
 	struct dst_entry *dst = skb->dst;
 	struct net_device *dev = dst->dev;
 
@@ -146,14 +145,12 @@
 	return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb,NULL, skb->dev,ip6_output_finish);
 }
 
-int ip6_output(struct sk_buff **pskb)
+int ip6_output(struct sk_buff *skb)
 {
-	struct sk_buff *skb = *pskb;
-
-	if ((skb->len > dst_pmtu(skb->dst) || skb_shinfo(skb)->frag_list))
-		return ip6_fragment(pskb, ip6_output2);
+	if (skb->len > dst_pmtu(skb->dst))
+		return ip6_fragment(skb, ip6_output2);
 	else
-		return ip6_output2(pskb);
+		return ip6_output2(skb);
 }
 
 #ifdef CONFIG_NETFILTER
@@ -518,10 +515,10 @@
 	return offset;
 }
 
-static int ip6_fragment(struct sk_buff **pskb, int (*output)(struct sk_buff**))
+static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
 {
 	struct net_device *dev;
-	struct sk_buff *frag, *skb = *pskb;
+	struct sk_buff *frag;
 	struct rt6_info *rt = (struct rt6_info*)skb->dst;
 	struct ipv6hdr *tmp_hdr;
 	struct frag_hdr *fh;
@@ -610,7 +607,7 @@
 				ip6_copy_metadata(frag, skb);
 			}
 			
-			err = output(&skb);
+			err = output(skb);
 			if (err || !frag)
 				break;
 
@@ -726,7 +723,7 @@
 
 		IP6_INC_STATS(IPSTATS_MIB_FRAGCREATES);
 
-		err = output(&frag);
+		err = output(frag);
 		if (err)
 			goto fail;
 	}
@@ -771,9 +768,9 @@
 				 */
 	
 			if (((rt->rt6i_dst.plen != 128 ||
-			      ipv6_addr_cmp(&fl->fl6_dst, &rt->rt6i_dst.addr))
+			      !ipv6_addr_equal(&fl->fl6_dst, &rt->rt6i_dst.addr))
 			     && (np->daddr_cache == NULL ||
-				 ipv6_addr_cmp(&fl->fl6_dst, np->daddr_cache)))
+				 !ipv6_addr_equal(&fl->fl6_dst, np->daddr_cache)))
 			    || (fl->oif && fl->oif != (*dst)->dev->ifindex)) {
 				*dst = NULL;
 			} else
diff -Nru a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
--- a/net/ipv6/ip6_tunnel.c	2004-12-24 13:36:17 -08:00
+++ b/net/ipv6/ip6_tunnel.c	2004-12-24 13:36:17 -08:00
@@ -133,8 +133,8 @@
 	struct ip6_tnl *t;
 
 	for (t = tnls_r_l[h0 ^ h1]; t; t = t->next) {
-		if (!ipv6_addr_cmp(local, &t->parms.laddr) &&
-		    !ipv6_addr_cmp(remote, &t->parms.raddr) &&
+		if (ipv6_addr_equal(local, &t->parms.laddr) &&
+		    ipv6_addr_equal(remote, &t->parms.raddr) &&
 		    (t->dev->flags & IFF_UP))
 			return t;
 	}
@@ -284,8 +284,8 @@
 		return -EINVAL;
 
 	for (t = *ip6ip6_bucket(p); t; t = t->next) {
-		if (!ipv6_addr_cmp(local, &t->parms.laddr) &&
-		    !ipv6_addr_cmp(remote, &t->parms.raddr)) {
+		if (ipv6_addr_equal(local, &t->parms.laddr) &&
+		    ipv6_addr_equal(remote, &t->parms.raddr)) {
 			*pt = t;
 			return (create ? -EEXIST : 0);
 		}
@@ -602,7 +602,7 @@
 static inline int
 ip6ip6_tnl_addr_conflict(struct ip6_tnl *t, struct ipv6hdr *hdr)
 {
-	return !ipv6_addr_cmp(&t->parms.raddr, &hdr->saddr);
+	return ipv6_addr_equal(&t->parms.raddr, &hdr->saddr);
 }
 
 /**
diff -Nru a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c
--- a/net/ipv6/ipv6_syms.c	2004-12-24 13:37:03 -08:00
+++ b/net/ipv6/ipv6_syms.c	2004-12-24 13:37:03 -08:00
@@ -35,13 +35,9 @@
 EXPORT_SYMBOL(in6addr_any);
 EXPORT_SYMBOL(in6addr_loopback);
 EXPORT_SYMBOL(in6_dev_finish_destroy);
-EXPORT_SYMBOL(ip6_find_1stfragopt);
 #ifdef CONFIG_XFRM
 EXPORT_SYMBOL(xfrm6_rcv);
 #endif
 EXPORT_SYMBOL(rt6_lookup);
 EXPORT_SYMBOL(fl6_sock_lookup);
-EXPORT_SYMBOL(ip6_append_data);
-EXPORT_SYMBOL(ip6_flush_pending_frames);
-EXPORT_SYMBOL(ip6_push_pending_frames);
 EXPORT_SYMBOL(ipv6_push_nfrag_opts);
diff -Nru a/net/ipv6/mcast.c b/net/ipv6/mcast.c
--- a/net/ipv6/mcast.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv6/mcast.c	2004-12-24 13:37:18 -08:00
@@ -247,7 +247,7 @@
 	write_lock_bh(&ipv6_sk_mc_lock);
 	for (lnk = &np->ipv6_mc_list; (mc_lst = *lnk) !=NULL ; lnk = &mc_lst->next) {
 		if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
-		    ipv6_addr_cmp(&mc_lst->addr, addr) == 0) {
+		    ipv6_addr_equal(&mc_lst->addr, addr)) {
 			struct net_device *dev;
 
 			*lnk = mc_lst->next;
@@ -369,7 +369,7 @@
 	for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) {
 		if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface)
 			continue;
-		if (ipv6_addr_cmp(&pmc->addr, group) == 0)
+		if (ipv6_addr_equal(&pmc->addr, group))
 			break;
 	}
 	if (!pmc)		/* must have a prior join */
@@ -391,12 +391,12 @@
 			goto done;
 		rv = !0;
 		for (i=0; i<psl->sl_count; i++) {
-			rv = memcmp(&psl->sl_addr, group,
+			rv = memcmp(&psl->sl_addr[i], source,
 				sizeof(struct in6_addr));
-			if (rv >= 0)
+			if (rv == 0)
 				break;
 		}
-		if (!rv)	/* source not found */
+		if (rv)		/* source not found */
 			goto done;
 
 		/* update the interface filter */
@@ -437,8 +437,8 @@
 	}
 	rv = 1;	/* > 0 for insert logic below if sl_count is 0 */
 	for (i=0; i<psl->sl_count; i++) {
-		rv = memcmp(&psl->sl_addr, group, sizeof(struct in6_addr));
-		if (rv >= 0)
+		rv = memcmp(&psl->sl_addr[i], source, sizeof(struct in6_addr));
+		if (rv == 0)
 			break;
 	}
 	if (rv == 0)		/* address already there is an error */
@@ -485,7 +485,7 @@
 	for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) {
 		if (pmc->ifindex != gsf->gf_interface)
 			continue;
-		if (ipv6_addr_cmp(&pmc->addr, group) == 0)
+		if (ipv6_addr_equal(&pmc->addr, group))
 			break;
 	}
 	if (!pmc)		/* must have a prior join */
@@ -556,7 +556,7 @@
 	for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) {
 		if (pmc->ifindex != gsf->gf_interface)
 			continue;
-		if (ipv6_addr_cmp(group, &pmc->addr) == 0)
+		if (ipv6_addr_equal(group, &pmc->addr))
 			break;
 	}
 	if (!pmc)		/* must have a prior join */
@@ -603,7 +603,7 @@
 
 	read_lock(&ipv6_sk_mc_lock);
 	for (mc = np->ipv6_mc_list; mc; mc = mc->next) {
-		if (ipv6_addr_cmp(&mc->addr, mc_addr) == 0)
+		if (ipv6_addr_equal(&mc->addr, mc_addr))
 			break;
 	}
 	if (!mc) {
@@ -617,7 +617,7 @@
 		int i;
 
 		for (i=0; i<psl->sl_count; i++) {
-			if (ipv6_addr_cmp(&psl->sl_addr[i], src_addr) == 0)
+			if (ipv6_addr_equal(&psl->sl_addr[i], src_addr))
 				break;
 		}
 		if (mc->sfmode == MCAST_INCLUDE && i >= psl->sl_count)
@@ -709,7 +709,7 @@
 		return;
 	memset(pmc, 0, sizeof(*pmc));
 	spin_lock_bh(&im->mca_lock);
-	pmc->mca_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&pmc->mca_lock);
 	pmc->idev = im->idev;
 	in6_dev_hold(idev);
 	pmc->mca_addr = im->mca_addr;
@@ -740,7 +740,7 @@
 	write_lock_bh(&idev->mc_lock);
 	pmc_prev = NULL;
 	for (pmc=idev->mc_tomb; pmc; pmc=pmc->next) {
-		if (ipv6_addr_cmp(&pmc->mca_addr, pmca) == 0)
+		if (ipv6_addr_equal(&pmc->mca_addr, pmca))
 			break;
 		pmc_prev = pmc;
 	}
@@ -816,7 +816,7 @@
 	}
 
 	for (mc = idev->mc_list; mc; mc = mc->next) {
-		if (ipv6_addr_cmp(&mc->mca_addr, addr) == 0) {
+		if (ipv6_addr_equal(&mc->mca_addr, addr)) {
 			mc->mca_users++;
 			write_unlock_bh(&idev->lock);
 			ip6_mc_add_src(idev, &mc->mca_addr, MCAST_EXCLUDE, 0,
@@ -849,7 +849,7 @@
 	/* mca_stamp should be updated upon changes */
 	mc->mca_cstamp = mc->mca_tstamp = jiffies;
 	atomic_set(&mc->mca_refcnt, 2);
-	mc->mca_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&mc->mca_lock);
 
 	/* initial mode is (EX, empty) */
 	mc->mca_sfmode = MCAST_EXCLUDE;
@@ -878,7 +878,7 @@
 
 	write_lock_bh(&idev->lock);
 	for (map = &idev->mc_list; (ma=*map) != NULL; map = &ma->next) {
-		if (ipv6_addr_cmp(&ma->mca_addr, addr) == 0) {
+		if (ipv6_addr_equal(&ma->mca_addr, addr)) {
 			if (--ma->mca_users == 0) {
 				*map = ma->next;
 				write_unlock_bh(&idev->lock);
@@ -953,7 +953,7 @@
 	if (idev) {
 		read_lock_bh(&idev->lock);
 		for (mc = idev->mc_list; mc; mc=mc->next) {
-			if (ipv6_addr_cmp(&mc->mca_addr, group) == 0)
+			if (ipv6_addr_equal(&mc->mca_addr, group))
 				break;
 		}
 		if (mc) {
@@ -962,8 +962,7 @@
 
 				spin_lock_bh(&mc->mca_lock);
 				for (psf=mc->mca_sources;psf;psf=psf->sf_next) {
-					if (ipv6_addr_cmp(&psf->sf_addr,
-					    src_addr) == 0)
+					if (ipv6_addr_equal(&psf->sf_addr, src_addr))
 						break;
 				}
 				if (psf)
@@ -1040,7 +1039,7 @@
 		if (scount == nsrcs)
 			break;
 		for (i=0; i<nsrcs; i++)
-			if (ipv6_addr_cmp(&srcs[i], &psf->sf_addr) == 0) {
+			if (ipv6_addr_equal(&srcs[i], &psf->sf_addr)) {
 				psf->sf_gsresp = 1;
 				scount++;
 				break;
@@ -1135,7 +1134,7 @@
 	} else {
 		for (ma = idev->mc_list; ma; ma=ma->next) {
 			if (group_type != IPV6_ADDR_ANY &&
-			    ipv6_addr_cmp(group, &ma->mca_addr) != 0)
+			    !ipv6_addr_equal(group, &ma->mca_addr))
 				continue;
 			spin_lock_bh(&ma->mca_lock);
 			if (ma->mca_flags & MAF_TIMER_RUNNING) {
@@ -1200,7 +1199,7 @@
 
 	read_lock_bh(&idev->lock);
 	for (ma = idev->mc_list; ma; ma=ma->next) {
-		if (ipv6_addr_cmp(&ma->mca_addr, addrp) == 0) {
+		if (ipv6_addr_equal(&ma->mca_addr, addrp)) {
 			spin_lock(&ma->mca_lock);
 			if (del_timer(&ma->mca_timer))
 				atomic_dec(&ma->mca_refcnt);
@@ -1695,7 +1694,7 @@
 
 	psf_prev = NULL;
 	for (psf=pmc->mca_sources; psf; psf=psf->sf_next) {
-		if (ipv6_addr_cmp(&psf->sf_addr, psfsrc) == 0)
+		if (ipv6_addr_equal(&psf->sf_addr, psfsrc))
 			break;
 		psf_prev = psf;
 	}
@@ -1735,7 +1734,7 @@
 		return -ENODEV;
 	read_lock_bh(&idev->lock);
 	for (pmc=idev->mc_list; pmc; pmc=pmc->next) {
-		if (ipv6_addr_cmp(pmca, &pmc->mca_addr) == 0)
+		if (ipv6_addr_equal(pmca, &pmc->mca_addr))
 			break;
 	}
 	if (!pmc) {
@@ -1790,7 +1789,7 @@
 
 	psf_prev = NULL;
 	for (psf=pmc->mca_sources; psf; psf=psf->sf_next) {
-		if (ipv6_addr_cmp(&psf->sf_addr, psfsrc) == 0)
+		if (ipv6_addr_equal(&psf->sf_addr, psfsrc))
 			break;
 		psf_prev = psf;
 	}
@@ -1859,7 +1858,7 @@
 		return -ENODEV;
 	read_lock_bh(&idev->lock);
 	for (pmc=idev->mc_list; pmc; pmc=pmc->next) {
-		if (ipv6_addr_cmp(pmca, &pmc->mca_addr) == 0)
+		if (ipv6_addr_equal(pmca, &pmc->mca_addr))
 			break;
 	}
 	if (!pmc) {
@@ -1882,7 +1881,8 @@
 	if (err) {
 		int j;
 
-		pmc->mca_sfcount[sfmode]--;
+		if (!delta)
+			pmc->mca_sfcount[sfmode]--;
 		for (j=0; j<i; j++)
 			(void) ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
 	} else if (isexclude != (pmc->mca_sfcount[MCAST_EXCLUDE] != 0)) {
@@ -2071,7 +2071,7 @@
 	struct in6_addr maddr;
 
 	write_lock_bh(&idev->lock);
-	idev->mc_lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&idev->mc_lock);
 	idev->mc_gq_running = 0;
 	init_timer(&idev->mc_gq_timer);
 	idev->mc_gq_timer.data = (unsigned long) idev;
diff -Nru a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
--- a/net/ipv6/ndisc.c	2004-12-24 13:37:00 -08:00
+++ b/net/ipv6/ndisc.c	2004-12-24 13:37:00 -08:00
@@ -396,7 +396,7 @@
 		src_addr = solicited_addr;
 		in6_ifa_put(ifp);
 	} else {
-		if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr, 0))
+		if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr))
 			return;
 		src_addr = &tmpaddr;
 	}
@@ -921,6 +921,64 @@
 	}
 }
 
+static void ndisc_recv_rs(struct sk_buff *skb)
+{
+	struct rs_msg *rs_msg = (struct rs_msg *) skb->h.raw;
+	unsigned long ndoptlen = skb->len - sizeof(*rs_msg);
+	struct neighbour *neigh;
+	struct inet6_dev *idev;
+	struct in6_addr *saddr = &skb->nh.ipv6h->saddr;
+	struct ndisc_options ndopts;
+	u8 *lladdr = NULL;
+	int lladdrlen = 0;
+
+	if (skb->len < sizeof(*rs_msg))
+		return;
+
+	idev = in6_dev_get(skb->dev);
+	if (!idev) {
+		if (net_ratelimit())
+			ND_PRINTK1("ICMP6 RS: can't find in6 device\n");
+		return;
+	}
+
+	/* Don't accept RS if we're not in router mode */
+	if (!idev->cnf.forwarding)
+		goto out;
+
+	/*
+	 * Don't update NCE if src = ::;
+	 * this implies that the source node has no ip address assigned yet.
+	 */
+	if (ipv6_addr_any(saddr))
+		goto out;
+
+	/* Parse ND options */
+	if (!ndisc_parse_options(rs_msg->opt, ndoptlen, &ndopts)) {
+		if (net_ratelimit())
+			ND_PRINTK2("ICMP6 NS: invalid ND option, ignored\n");
+		goto out;
+	}
+
+	if (ndopts.nd_opts_src_lladdr) {
+		lladdr = (u8 *)(ndopts.nd_opts_src_lladdr + 1);
+		lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
+		if (lladdrlen != NDISC_OPT_SPACE(skb->dev->addr_len))
+			goto out;
+	}
+
+	neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
+	if (neigh) {
+		neigh_update(neigh, lladdr, NUD_STALE,
+			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
+			     NEIGH_UPDATE_F_OVERRIDE|
+			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER);
+		neigh_release(neigh);
+	}
+out:
+	in6_dev_put(idev);
+}
+
 static void ndisc_router_discovery(struct sk_buff *skb)
 {
         struct ra_msg *ra_msg = (struct ra_msg *) skb->h.raw;
@@ -1020,13 +1078,6 @@
 			return;
 		}
 		neigh->flags |= NTF_ROUTER;
-
-		/*
-		 *	If we where using an "all destinations on link" route
-		 *	delete it
-		 */
-
-		rt6_purge_dflt_routers(RTF_ALLONLINK);
 	}
 
 	if (rt)
@@ -1168,7 +1219,7 @@
 		return;
 	}
 
-	if (ipv6_addr_cmp(dest, target) == 0) {
+	if (ipv6_addr_equal(dest, target)) {
 		on_link = 1;
 	} else if (!(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) {
 		ND_PRINTK2(KERN_WARNING 
@@ -1393,6 +1444,10 @@
 
 	case NDISC_NEIGHBOUR_ADVERTISEMENT:
 		ndisc_recv_na(skb);
+		break;
+
+	case NDISC_ROUTER_SOLICITATION:
+		ndisc_recv_rs(skb);
 		break;
 
 	case NDISC_ROUTER_ADVERTISEMENT:
diff -Nru a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
--- a/net/ipv6/netfilter/ip6_queue.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv6/netfilter/ip6_queue.c	2004-12-24 13:36:31 -08:00
@@ -167,6 +167,7 @@
 __ipq_reset(void)
 {
 	peer_pid = 0;
+	net_disable_timestamp();
 	__ipq_set_mode(IPQ_COPY_NONE, 0);
 	__ipq_flush(NF_DROP);
 }
@@ -262,7 +263,8 @@
 	}
 	
 	if (data_len)
-		memcpy(pmsg->payload, entry->skb->data, data_len);
+		if (skb_copy_bits(entry->skb, 0, pmsg->payload, data_len))
+			BUG();
 		
 	nlh->nlmsg_len = skb->tail - old_tail;
 	return skb;
@@ -366,6 +368,8 @@
 		}
 		skb_put(e->skb, diff);
 	}
+	if (!skb_ip_make_writable(&e->skb, v->data_len))
+		return -ENOMEM;
 	memcpy(e->skb->data, v->payload, v->data_len);
 	e->skb->nfcache |= NFC_ALTERED;
 
@@ -376,8 +380,8 @@
 	 */
 	if (e->info->hook == NF_IP_LOCAL_OUT) {
 		struct ipv6hdr *iph = e->skb->nh.ipv6h;
-		if (ipv6_addr_cmp(&iph->daddr, &e->rt_info.daddr) ||
-		    ipv6_addr_cmp(&iph->saddr, &e->rt_info.saddr))
+		if (!ipv6_addr_equal(&iph->daddr, &e->rt_info.daddr) ||
+		    !ipv6_addr_equal(&iph->saddr, &e->rt_info.saddr))
 			return ip6_route_me_harder(e->skb);
 	}
 	return 0;
@@ -517,9 +521,10 @@
 			write_unlock_bh(&queue_lock);
 			RCV_SKB_FAIL(-EBUSY);
 		}
-	}
-	else
+	} else {
+		net_enable_timestamp();
 		peer_pid = pid;
+	}
 		
 	write_unlock_bh(&queue_lock);
 	
diff -Nru a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
--- a/net/ipv6/netfilter/ip6_tables.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv6/netfilter/ip6_tables.c	2004-12-24 13:37:19 -08:00
@@ -158,14 +158,15 @@
 /* Returns whether matches rule or not. */
 static inline int
 ip6_packet_match(const struct sk_buff *skb,
-		 const struct ipv6hdr *ipv6,
 		 const char *indev,
 		 const char *outdev,
 		 const struct ip6t_ip6 *ip6info,
-		 int isfrag)
+		 unsigned int *protoff,
+		 int *fragoff)
 {
 	size_t i;
 	unsigned long ret;
+	const struct ipv6hdr *ipv6 = skb->nh.ipv6h;
 
 #define FWINV(bool,invflg) ((bool) ^ !!(ip6info->invflags & invflg))
 
@@ -216,9 +217,10 @@
 	/* look for the desired protocol header */
 	if((ip6info->flags & IP6T_F_PROTO)) {
 		u_int8_t currenthdr = ipv6->nexthdr;
-		struct ipv6_opt_hdr *hdrptr;
+		struct ipv6_opt_hdr _hdr, *hp;
 		u_int16_t ptr;		/* Header offset in skb */
 		u_int16_t hdrlen;	/* Header */
+		u_int16_t _fragoff = 0, *fp = NULL;
 
 		ptr = IPV6_HDR_LEN;
 
@@ -234,23 +236,41 @@
 				(currenthdr == IPPROTO_ESP))
 				return 0;
 
-	                hdrptr = (struct ipv6_opt_hdr *)(skb->data + ptr);
+			hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+			BUG_ON(hp == NULL);
 
 			/* Size calculation */
 	                if (currenthdr == IPPROTO_FRAGMENT) {
+				fp = skb_header_pointer(skb,
+						   ptr+offsetof(struct frag_hdr,
+								frag_off),
+						   sizeof(_fragoff),
+						   &_fragoff);
+				if (fp == NULL)
+					return 0;
+
+				_fragoff = ntohs(*fp) & ~0x7;
 	                        hdrlen = 8;
 	                } else if (currenthdr == IPPROTO_AH)
-	                        hdrlen = (hdrptr->hdrlen+2)<<2;
+	                        hdrlen = (hp->hdrlen+2)<<2;
 	                else
-	                        hdrlen = ipv6_optlen(hdrptr);
+	                        hdrlen = ipv6_optlen(hp);
 
-			currenthdr = hdrptr->nexthdr;
+			currenthdr = hp->nexthdr;
 	                ptr += hdrlen;
 			/* ptr is too large */
 	                if ( ptr > skb->len ) 
 				return 0;
+			if (_fragoff) {
+				if (ip6t_ext_hdr(currenthdr))
+					return 0;
+				break;
+			}
 		}
 
+		*protoff = ptr;
+		*fragoff = _fragoff;
+
 		/* currenthdr contains the protocol header */
 
 		dprintf("Packet protocol %hi ?= %s%hi.\n",
@@ -292,9 +312,9 @@
 
 static unsigned int
 ip6t_error(struct sk_buff **pskb,
-	  unsigned int hooknum,
 	  const struct net_device *in,
 	  const struct net_device *out,
+	  unsigned int hooknum,
 	  const void *targinfo,
 	  void *userinfo)
 {
@@ -310,13 +330,12 @@
 	     const struct net_device *in,
 	     const struct net_device *out,
 	     int offset,
-	     const void *hdr,
-	     u_int16_t datalen,
+	     unsigned int protoff,
 	     int *hotdrop)
 {
 	/* Stop iteration if it doesn't match */
 	if (!m->u.kernel.match->match(skb, in, out, m->data,
-				      offset, hdr, datalen, hotdrop))
+				      offset, protoff, hotdrop))
 		return 1;
 	else
 		return 0;
@@ -338,10 +357,8 @@
 	      void *userdata)
 {
 	static const char nulldevname[IFNAMSIZ];
-	u_int16_t offset = 0;
-	struct ipv6hdr *ipv6;
-	void *protohdr;
-	u_int16_t datalen;
+	int offset = 0;
+	unsigned int protoff = 0;
 	int hotdrop = 0;
 	/* Initializing verdict to NF_DROP keeps gcc happy. */
 	unsigned int verdict = NF_DROP;
@@ -354,9 +371,6 @@
 		return NF_DROP;
 
 	/* Initialization */
-	ipv6 = (*pskb)->nh.ipv6h;
-	protohdr = (u_int32_t *)((char *)ipv6 + IPV6_HDR_LEN);
-	datalen = (*pskb)->len - IPV6_HDR_LEN;
 	indev = in ? in->name : nulldevname;
 	outdev = out ? out->name : nulldevname;
 
@@ -393,17 +407,19 @@
 		IP_NF_ASSERT(e);
 		IP_NF_ASSERT(back);
 		(*pskb)->nfcache |= e->nfcache;
-		if (ip6_packet_match(*pskb, ipv6, indev, outdev, 
-			&e->ipv6, offset)) {
+		if (ip6_packet_match(*pskb, indev, outdev, &e->ipv6,
+			&protoff, &offset)) {
 			struct ip6t_entry_target *t;
 
 			if (IP6T_MATCH_ITERATE(e, do_match,
 					       *pskb, in, out,
-					       offset, protohdr,
-					       datalen, &hotdrop) != 0)
+					       offset, protoff, &hotdrop) != 0)
 				goto no_match;
 
-			ADD_COUNTER(e->counters, ntohs(ipv6->payload_len) + IPV6_HDR_LEN, 1);
+			ADD_COUNTER(e->counters,
+				    ntohs((*pskb)->nh.ipv6h->payload_len)
+				    + IPV6_HDR_LEN,
+				    1);
 
 			t = ip6t_get_target(e);
 			IP_NF_ASSERT(t->u.kernel.target);
@@ -443,8 +459,8 @@
 					= 0xeeeeeeec;
 #endif
 				verdict = t->u.kernel.target->target(pskb,
-								     hook,
 								     in, out,
+								     hook,
 								     t->data,
 								     userdata);
 
@@ -459,11 +475,6 @@
 				((struct ip6t_entry *)table_base)->comefrom
 					= 0x57acc001;
 #endif
-				/* Target might have changed stuff. */
-				ipv6 = (*pskb)->nh.ipv6h;
-				protohdr = (u_int32_t *)((void *)ipv6 + IPV6_HDR_LEN);
-				datalen = (*pskb)->len - IPV6_HDR_LEN;
-
 				if (verdict == IP6T_CONTINUE)
 					e = (void *)e + e->next_offset;
 				else
@@ -554,7 +565,7 @@
 	return find_inlist_lock(&ip6t_match, name, "ip6t_", error, mutex);
 }
 
-struct ip6t_target *
+static struct ip6t_target *
 ip6t_find_target_lock(const char *name, int *error, struct semaphore *mutex)
 {
 	return find_inlist_lock(&ip6t_target, name, "ip6t_", error, mutex);
@@ -1499,7 +1510,7 @@
 	/* save number of initial entries */
 	table->private->initial_entries = table->private->number;
 
-	table->lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&table->lock);
 	list_prepend(&ip6t_tables, table);
 
  unlock:
@@ -1535,26 +1546,31 @@
 
 static int
 tcp_find_option(u_int8_t option,
-		const struct tcphdr *tcp,
-		u_int16_t datalen,
+		const struct sk_buff *skb,
+		unsigned int tcpoff,
+		unsigned int optlen,
 		int invert,
 		int *hotdrop)
 {
-	unsigned int i = sizeof(struct tcphdr);
-	const u_int8_t *opt = (u_int8_t *)tcp;
+	/* tcp.doff is only 4 bits, ie. max 15 * 4 bytes */
+	u_int8_t _opt[60 - sizeof(struct tcphdr)], *op;
+	unsigned int i;
 
 	duprintf("tcp_match: finding option\n");
+	if (!optlen)
+		return invert;
 	/* If we don't have the whole header, drop packet. */
-	if (tcp->doff * 4 < sizeof(struct tcphdr) ||
-	    tcp->doff * 4 > datalen) {
+	op = skb_header_pointer(skb, tcpoff + sizeof(struct tcphdr), optlen,
+				_opt);
+	if (op == NULL) {
 		*hotdrop = 1;
 		return 0;
 	}
 
-	while (i < tcp->doff * 4) {
-		if (opt[i] == option) return !invert;
-		if (opt[i] < 2) i++;
-		else i += opt[i+1]?:1;
+	for (i = 0; i < optlen; ) {
+		if (op[i] == option) return !invert;
+		if (op[i] < 2) i++;
+		else i += op[i+1]?:1;
 	}
 
 	return invert;
@@ -1566,27 +1582,31 @@
 	  const struct net_device *out,
 	  const void *matchinfo,
 	  int offset,
-	  const void *hdr,
-	  u_int16_t datalen,
+	  unsigned int protoff,
 	  int *hotdrop)
 {
-	const struct tcphdr *tcp;
+	struct tcphdr _tcph, *th;
 	const struct ip6t_tcp *tcpinfo = matchinfo;
-	int tcpoff;
-	u8 nexthdr = skb->nh.ipv6h->nexthdr;
 
-	/* To quote Alan:
+	if (offset) {
+		/* To quote Alan:
 
-	   Don't allow a fragment of TCP 8 bytes in. Nobody normal
-	   causes this. Its a cracker trying to break in by doing a
-	   flag overwrite to pass the direction checks.
-	*/
-
-	if (offset == 1) {
-		duprintf("Dropping evil TCP offset=1 frag.\n");
-		*hotdrop = 1;
+		   Don't allow a fragment of TCP 8 bytes in. Nobody normal
+		   causes this. Its a cracker trying to break in by doing a
+		   flag overwrite to pass the direction checks.
+		*/
+		if (offset == 1) {
+			duprintf("Dropping evil TCP offset=1 frag.\n");
+			*hotdrop = 1;
+		}
+		/* Must not be a fragment. */
 		return 0;
-	} else if (offset == 0 && datalen < sizeof(struct tcphdr)) {
+	}
+
+#define FWINVTCP(bool,invflg) ((bool) ^ !!(tcpinfo->invflags & invflg))
+
+	th = skb_header_pointer(skb, protoff, sizeof(_tcph), &_tcph);
+	if (th == NULL) {
 		/* We've been asked to examine this packet, and we
 		   can't.  Hence, no choice but to drop. */
 		duprintf("Dropping evil TCP offset=0 tinygram.\n");
@@ -1594,45 +1614,30 @@
 		return 0;
 	}
 
-	tcpoff = (u8*)(skb->nh.ipv6h + 1) - skb->data;
-	tcpoff = ipv6_skip_exthdr(skb, tcpoff, &nexthdr, skb->len - tcpoff);
-	if (tcpoff < 0 || tcpoff > skb->len) {
-		duprintf("tcp_match: cannot skip exthdr. Dropping.\n");
-		*hotdrop = 1;
-		return 0;
-	} else if (nexthdr == IPPROTO_FRAGMENT)
-		return 0;
-	else if (nexthdr != IPPROTO_TCP ||
-		 skb->len - tcpoff < sizeof(struct tcphdr)) {
-		/* cannot be occured */
-		duprintf("tcp_match: cannot get TCP header. Dropping.\n");
-		*hotdrop = 1;
-		return 0;
+	if (!port_match(tcpinfo->spts[0], tcpinfo->spts[1],
+			ntohs(th->source),
+			!!(tcpinfo->invflags & IP6T_TCP_INV_SRCPT)))
+		return 0;
+	if (!port_match(tcpinfo->dpts[0], tcpinfo->dpts[1],
+			ntohs(th->dest),
+			!!(tcpinfo->invflags & IP6T_TCP_INV_DSTPT)))
+		return 0;
+	if (!FWINVTCP((((unsigned char *)th)[13] & tcpinfo->flg_mask)
+		      == tcpinfo->flg_cmp,
+		      IP6T_TCP_INV_FLAGS))
+		return 0;
+	if (tcpinfo->option) {
+		if (th->doff * 4 < sizeof(_tcph)) {
+			*hotdrop = 1;
+			return 0;
+		}
+		if (!tcp_find_option(tcpinfo->option, skb, protoff,
+				     th->doff*4 - sizeof(*th),
+				     tcpinfo->invflags & IP6T_TCP_INV_OPTION,
+				     hotdrop))
+			return 0;
 	}
-
-	tcp = (struct tcphdr *)(skb->data + tcpoff);
-
-	/* FIXME: Try tcp doff >> packet len against various stacks --RR */
-
-#define FWINVTCP(bool,invflg) ((bool) ^ !!(tcpinfo->invflags & invflg))
-
-	/* Must not be a fragment. */
-	return !offset
-		&& port_match(tcpinfo->spts[0], tcpinfo->spts[1],
-			      ntohs(tcp->source),
-			      !!(tcpinfo->invflags & IP6T_TCP_INV_SRCPT))
-		&& port_match(tcpinfo->dpts[0], tcpinfo->dpts[1],
-			      ntohs(tcp->dest),
-			      !!(tcpinfo->invflags & IP6T_TCP_INV_DSTPT))
-		&& FWINVTCP((((unsigned char *)tcp)[13]
-			     & tcpinfo->flg_mask)
-			    == tcpinfo->flg_cmp,
-			    IP6T_TCP_INV_FLAGS)
-		&& (!tcpinfo->option
-		    || tcp_find_option(tcpinfo->option, tcp, datalen,
-				       tcpinfo->invflags
-				       & IP6T_TCP_INV_OPTION,
-				       hotdrop));
+	return 1;
 }
 
 /* Called when user tries to insert an entry of this type. */
@@ -1658,16 +1663,18 @@
 	  const struct net_device *out,
 	  const void *matchinfo,
 	  int offset,
-	  const void *hdr,
-	  u_int16_t datalen,
+	  unsigned int protoff,
 	  int *hotdrop)
 {
-	const struct udphdr *udp;
+	struct udphdr _udph, *uh;
 	const struct ip6t_udp *udpinfo = matchinfo;
-	int udpoff;
-	u8 nexthdr = skb->nh.ipv6h->nexthdr;
 
-	if (offset == 0 && datalen < sizeof(struct udphdr)) {
+	/* Must not be a fragment. */
+	if (offset)
+		return 0;
+
+	uh = skb_header_pointer(skb, protoff, sizeof(_udph), &_udph);
+	if (uh == NULL) {
 		/* We've been asked to examine this packet, and we
 		   can't.  Hence, no choice but to drop. */
 		duprintf("Dropping evil UDP tinygram.\n");
@@ -1675,30 +1682,11 @@
 		return 0;
 	}
 
-	udpoff = (u8*)(skb->nh.ipv6h + 1) - skb->data;
-	udpoff = ipv6_skip_exthdr(skb, udpoff, &nexthdr, skb->len - udpoff);
-	if (udpoff < 0 || udpoff > skb->len) {
-		duprintf("udp_match: cannot skip exthdr. Dropping.\n");
-		*hotdrop = 1;
-		return 0;
-	} else if (nexthdr == IPPROTO_FRAGMENT)
-		return 0;
-	else if (nexthdr != IPPROTO_UDP ||
-		 skb->len - udpoff < sizeof(struct udphdr)) {
-		duprintf("udp_match: cannot get UDP header. Dropping.\n");
-		*hotdrop = 1;
-		return 0;
-	}
-
-	udp = (struct udphdr *)(skb->data + udpoff);
-
-	/* Must not be a fragment. */
-	return !offset
-		&& port_match(udpinfo->spts[0], udpinfo->spts[1],
-			      ntohs(udp->source),
-			      !!(udpinfo->invflags & IP6T_UDP_INV_SRCPT))
+	return port_match(udpinfo->spts[0], udpinfo->spts[1],
+			  ntohs(uh->source),
+			  !!(udpinfo->invflags & IP6T_UDP_INV_SRCPT))
 		&& port_match(udpinfo->dpts[0], udpinfo->dpts[1],
-			      ntohs(udp->dest),
+			      ntohs(uh->dest),
 			      !!(udpinfo->invflags & IP6T_UDP_INV_DSTPT));
 }
 
@@ -1748,14 +1736,18 @@
 	   const struct net_device *out,
 	   const void *matchinfo,
 	   int offset,
-	   const void *hdr,
-	   u_int16_t datalen,
+	   unsigned int protoff,
 	   int *hotdrop)
 {
-	const struct icmp6hdr *icmp = hdr;
+	struct icmp6hdr _icmp, *ic;
 	const struct ip6t_icmp *icmpinfo = matchinfo;
 
-	if (offset == 0 && datalen < 2) {
+	/* Must not be a fragment. */
+	if (offset)
+		return 0;
+
+	ic = skb_header_pointer(skb, protoff, sizeof(_icmp), &_icmp);
+	if (ic == NULL) {
 		/* We've been asked to examine this packet, and we
 		   can't.  Hence, no choice but to drop. */
 		duprintf("Dropping evil ICMP tinygram.\n");
@@ -1763,13 +1755,11 @@
 		return 0;
 	}
 
-	/* Must not be a fragment. */
-	return !offset
-		&& icmp6_type_code_match(icmpinfo->type,
-					icmpinfo->code[0],
-					icmpinfo->code[1],
-					icmp->icmp6_type, icmp->icmp6_code,
-					!!(icmpinfo->invflags&IP6T_ICMP_INV));
+	return icmp6_type_code_match(icmpinfo->type,
+				     icmpinfo->code[0],
+				     icmpinfo->code[1],
+				     ic->icmp6_type, ic->icmp6_code,
+				     !!(icmpinfo->invflags&IP6T_ICMP_INV));
 }
 
 /* Called when user tries to insert an entry of this type. */
@@ -1972,7 +1962,6 @@
 EXPORT_SYMBOL(ip6t_register_table);
 EXPORT_SYMBOL(ip6t_unregister_table);
 EXPORT_SYMBOL(ip6t_do_table);
-EXPORT_SYMBOL(ip6t_find_target_lock);
 EXPORT_SYMBOL(ip6t_register_match);
 EXPORT_SYMBOL(ip6t_unregister_match);
 EXPORT_SYMBOL(ip6t_register_target);
diff -Nru a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
--- a/net/ipv6/netfilter/ip6t_LOG.c	2004-12-24 13:36:32 -08:00
+++ b/net/ipv6/netfilter/ip6t_LOG.c	2004-12-24 13:36:32 -08:00
@@ -40,120 +40,166 @@
 #define DEBUGP(format, args...)
 #endif
 
-struct esphdr {
-	__u32   spi;
-}; /* FIXME evil kludge */
-        
 /* Use lock to serialize, so printks don't overlap */
 static spinlock_t log_lock = SPIN_LOCK_UNLOCKED;
 
-/* takes in current header and pointer to the header */
-/* if another header exists, sets hdrptr to the next header
-   and returns the new header value, else returns IPPROTO_NONE */
-static u_int8_t ip6_nexthdr(u_int8_t currenthdr, u_int8_t **hdrptr)
-{
-	u_int8_t hdrlen, nexthdr = IPPROTO_NONE;
-
-	switch(currenthdr){
-		case IPPROTO_AH:
-		/* whoever decided to do the length of AUTH for ipv6
-		in 32bit units unlike other headers should be beaten...
-		repeatedly...with a large stick...no, an even LARGER
-		stick...no, you're still not thinking big enough */
-			nexthdr = **hdrptr;
-			hdrlen = (*hdrptr)[1] * 4 + 8;
-			*hdrptr = *hdrptr + hdrlen;
-			break;
-		/*stupid rfc2402 */
-		case IPPROTO_DSTOPTS:
-		case IPPROTO_ROUTING:
-		case IPPROTO_HOPOPTS:
-			nexthdr = **hdrptr;
-			hdrlen = (*hdrptr)[1] * 8 + 8;
-			*hdrptr = *hdrptr + hdrlen;
-			break;
-		case IPPROTO_FRAGMENT:
-			nexthdr = **hdrptr;
-			*hdrptr = *hdrptr + 8;
-			break;
-	}	
-	return nexthdr;
-}
-
 /* One level of recursion won't kill us */
 static void dump_packet(const struct ip6t_log_info *info,
-			struct ipv6hdr *ipv6h, int recurse)
+			const struct sk_buff *skb, unsigned int ip6hoff,
+			int recurse)
 {
-	u_int8_t currenthdr = ipv6h->nexthdr;
-	u_int8_t *hdrptr;
+	u_int8_t currenthdr;
 	int fragment;
+	struct ipv6hdr _ip6h, *ih;
+	unsigned int ptr;
+	unsigned int hdrlen = 0;
+
+	ih = skb_header_pointer(skb, ip6hoff, sizeof(_ip6h), &_ip6h);
+	if (ih == NULL) {
+		printk("TRUNCATED");
+		return;
+	}
 
 	/* Max length: 88 "SRC=0000.0000.0000.0000.0000.0000.0000.0000 DST=0000.0000.0000.0000.0000.0000.0000.0000" */
-	printk("SRC=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ", NIP6(ipv6h->saddr));
-	printk("DST=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ", NIP6(ipv6h->daddr));
+	printk("SRC=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ", NIP6(ih->saddr));
+	printk("DST=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ", NIP6(ih->daddr));
 
 	/* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
 	printk("LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
-	       ntohs(ipv6h->payload_len) + sizeof(struct ipv6hdr),
-	       (ntohl(*(u_int32_t *)ipv6h) & 0x0ff00000) >> 20,
-	       ipv6h->hop_limit,
-	       (ntohl(*(u_int32_t *)ipv6h) & 0x000fffff));
+	       ntohs(ih->payload_len) + sizeof(struct ipv6hdr),
+	       (ntohl(*(u_int32_t *)ih) & 0x0ff00000) >> 20,
+	       ih->hop_limit,
+	       (ntohl(*(u_int32_t *)ih) & 0x000fffff));
 
 	fragment = 0;
-	hdrptr = (u_int8_t *)(ipv6h + 1);
-	while (currenthdr != IPPROTO_NONE) {
-		if ((currenthdr == IPPROTO_TCP) ||
-		    (currenthdr == IPPROTO_UDP) ||
-		    (currenthdr == IPPROTO_ICMPV6))
-			break;
+	ptr = ip6hoff + sizeof(struct ipv6hdr);
+	currenthdr = ih->nexthdr;
+	while (currenthdr != NEXTHDR_NONE && ip6t_ext_hdr(currenthdr)) {
+		struct ipv6_opt_hdr _hdr, *hp;
+
+		hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+		if (hp == NULL) {
+			printk("TRUNCATED");
+			return;
+		}
+
 		/* Max length: 48 "OPT (...) " */
-		printk("OPT ( ");
+		if (info->logflags & IP6T_LOG_IPOPT)
+			printk("OPT ( ");
+
 		switch (currenthdr) {
 		case IPPROTO_FRAGMENT: {
-			struct frag_hdr *fhdr = (struct frag_hdr *)hdrptr;
+			struct frag_hdr _fhdr, *fh;
 
-			/* Max length: 11 "FRAG:65535 " */
-			printk("FRAG:%u ", ntohs(fhdr->frag_off) & 0xFFF8);
+			printk("FRAG:");
+			fh = skb_header_pointer(skb, ptr, sizeof(_fhdr),
+						&_fhdr);
+			if (fh == NULL) {
+				printk("TRUNCATED ");
+				return;
+			}
+
+			/* Max length: 6 "65535 " */
+			printk("%u ", ntohs(fh->frag_off) & 0xFFF8);
 
 			/* Max length: 11 "INCOMPLETE " */
-			if (fhdr->frag_off & htons(0x0001))
+			if (fh->frag_off & htons(0x0001))
 				printk("INCOMPLETE ");
 
-			printk("ID:%08x ", fhdr->identification);
+			printk("ID:%08x ", ntohl(fh->identification));
 
-			if (ntohs(fhdr->frag_off) & 0xFFF8)
+			if (ntohs(fh->frag_off) & 0xFFF8)
 				fragment = 1;
 
+			hdrlen = 8;
+
 			break;
 		}
 		case IPPROTO_DSTOPTS:
 		case IPPROTO_ROUTING:
 		case IPPROTO_HOPOPTS:
+			if (fragment) {
+				if (info->logflags & IP6T_LOG_IPOPT)
+					printk(")");
+				return;
+			}
+			hdrlen = ipv6_optlen(hp);
 			break;
 		/* Max Length */
 		case IPPROTO_AH:
+			if (info->logflags & IP6T_LOG_IPOPT) {
+				struct ip_auth_hdr _ahdr, *ah;
+
+				/* Max length: 3 "AH " */
+				printk("AH ");
+
+				if (fragment) {
+					printk(")");
+					return;
+				}
+
+				ah = skb_header_pointer(skb, ptr, sizeof(_ahdr),
+							&_ahdr);
+				if (ah == NULL) {
+					/*
+					 * Max length: 26 "INCOMPLETE [65535 	
+					 *  bytes] )"
+					 */
+					printk("INCOMPLETE [%u bytes] )",
+					       skb->len - ptr);
+					return;
+				}
+
+				/* Length: 15 "SPI=0xF1234567 */
+				printk("SPI=0x%x ", ntohl(ah->spi));
+
+			}
+
+			hdrlen = (hp->hdrlen+2)<<2;
+			break;
 		case IPPROTO_ESP:
 			if (info->logflags & IP6T_LOG_IPOPT) {
-				struct esphdr *esph = (struct esphdr *)hdrptr;
-				int esp = (currenthdr == IPPROTO_ESP);
+				struct ip_esp_hdr _esph, *eh;
 
 				/* Max length: 4 "ESP " */
-				printk("%s ",esp ? "ESP" : "AH");
+				printk("ESP ");
+
+				if (fragment) {
+					printk(")");
+					return;
+				}
+
+				/*
+				 * Max length: 26 "INCOMPLETE [65535 bytes] )"
+				 */
+				eh = skb_header_pointer(skb, ptr, sizeof(_esph),
+							&_esph);
+				if (eh == NULL) {
+					printk("INCOMPLETE [%u bytes] )",
+					       skb->len - ptr);
+					return;
+				}
+
+				/* Length: 16 "SPI=0xF1234567 )" */
+				printk("SPI=0x%x )", ntohl(eh->spi) );
 
-				/* Length: 15 "SPI=0xF1234567 " */
-				printk("SPI=0x%x ", ntohl(esph->spi) );
-				break;
 			}
+			return;
 		default:
-			break;
+			/* Max length: 20 "Unknown Ext Hdr 255" */
+			printk("Unknown Ext Hdr %u", currenthdr);
+			return;
 		}
-		printk(") ");
-		currenthdr = ip6_nexthdr(currenthdr, &hdrptr);
+		if (info->logflags & IP6T_LOG_IPOPT)
+			printk(") ");
+
+		currenthdr = hp->nexthdr;
+		ptr += hdrlen;
 	}
 
 	switch (currenthdr) {
 	case IPPROTO_TCP: {
-		struct tcphdr *tcph = (struct tcphdr *)hdrptr;
+		struct tcphdr _tcph, *th;
 
 		/* Max length: 10 "PROTO=TCP " */
 		printk("PROTO=TCP ");
@@ -161,51 +207,69 @@
 		if (fragment)
 			break;
 
+		/* Max length: 25 "INCOMPLETE [65535 bytes] " */
+		th = skb_header_pointer(skb, ptr, sizeof(_tcph), &_tcph);
+		if (th == NULL) {
+			printk("INCOMPLETE [%u bytes] ", skb->len - ptr);
+			return;
+		}
+
 		/* Max length: 20 "SPT=65535 DPT=65535 " */
 		printk("SPT=%u DPT=%u ",
-		       ntohs(tcph->source), ntohs(tcph->dest));
+		       ntohs(th->source), ntohs(th->dest));
 		/* Max length: 30 "SEQ=4294967295 ACK=4294967295 " */
 		if (info->logflags & IP6T_LOG_TCPSEQ)
 			printk("SEQ=%u ACK=%u ",
-			       ntohl(tcph->seq), ntohl(tcph->ack_seq));
+			       ntohl(th->seq), ntohl(th->ack_seq));
 		/* Max length: 13 "WINDOW=65535 " */
-		printk("WINDOW=%u ", ntohs(tcph->window));
-		/* Max length: 9 "RES=0x3F " */
-		printk("RES=0x%02x ", (u_int8_t)(ntohl(tcp_flag_word(tcph) & TCP_RESERVED_BITS) >> 22));
+		printk("WINDOW=%u ", ntohs(th->window));
+		/* Max length: 9 "RES=0x3C " */
+		printk("RES=0x%02x ", (u_int8_t)(ntohl(tcp_flag_word(th) & TCP_RESERVED_BITS) >> 22));
 		/* Max length: 32 "CWR ECE URG ACK PSH RST SYN FIN " */
-		if (tcph->cwr)
+		if (th->cwr)
 			printk("CWR ");
-		if (tcph->ece)
+		if (th->ece)
 			printk("ECE ");
-		if (tcph->urg)
+		if (th->urg)
 			printk("URG ");
-		if (tcph->ack)
+		if (th->ack)
 			printk("ACK ");
-		if (tcph->psh)
+		if (th->psh)
 			printk("PSH ");
-		if (tcph->rst)
+		if (th->rst)
 			printk("RST ");
-		if (tcph->syn)
+		if (th->syn)
 			printk("SYN ");
-		if (tcph->fin)
+		if (th->fin)
 			printk("FIN ");
 		/* Max length: 11 "URGP=65535 " */
-		printk("URGP=%u ", ntohs(tcph->urg_ptr));
+		printk("URGP=%u ", ntohs(th->urg_ptr));
 
 		if ((info->logflags & IP6T_LOG_TCPOPT)
-		    && tcph->doff * 4 != sizeof(struct tcphdr)) {
+		    && th->doff * 4 > sizeof(struct tcphdr)) {
+			u_int8_t _opt[60 - sizeof(struct tcphdr)], *op;
 			unsigned int i;
+			unsigned int optsize = th->doff * 4
+					       - sizeof(struct tcphdr);
+
+			op = skb_header_pointer(skb,
+						ptr + sizeof(struct tcphdr),
+						optsize, _opt);
+			if (op == NULL) {
+				printk("OPT (TRUNCATED)");
+				return;
+			}
 
 			/* Max length: 127 "OPT (" 15*4*2chars ") " */
 			printk("OPT (");
-			for (i =sizeof(struct tcphdr); i < tcph->doff * 4; i++)
-				printk("%02X", ((u_int8_t *)tcph)[i]);
+			for (i =0; i < optsize; i++)
+				printk("%02X", op[i]);
 			printk(") ");
 		}
 		break;
 	}
 	case IPPROTO_UDP: {
-		struct udphdr *udph = (struct udphdr *)hdrptr;
+		struct udphdr _udph, *uh;
 
 		/* Max length: 10 "PROTO=UDP " */
 		printk("PROTO=UDP ");
@@ -213,14 +277,21 @@
 		if (fragment)
 			break;
 
+		/* Max length: 25 "INCOMPLETE [65535 bytes] " */
+		uh = skb_header_pointer(skb, ptr, sizeof(_udph), &_udph);
+		if (uh == NULL) {
+			printk("INCOMPLETE [%u bytes] ", skb->len - ptr);
+			return;
+		}
+
 		/* Max length: 20 "SPT=65535 DPT=65535 " */
 		printk("SPT=%u DPT=%u LEN=%u ",
-		       ntohs(udph->source), ntohs(udph->dest),
-		       ntohs(udph->len));
+		       ntohs(uh->source), ntohs(uh->dest),
+		       ntohs(uh->len));
 		break;
 	}
 	case IPPROTO_ICMPV6: {
-		struct icmp6hdr *icmp6h = (struct icmp6hdr *)hdrptr;
+		struct icmp6hdr _icmp6h, *ic;
 
 		/* Max length: 13 "PROTO=ICMPv6 " */
 		printk("PROTO=ICMPv6 ");
@@ -228,16 +299,23 @@
 		if (fragment)
 			break;
 
+		/* Max length: 25 "INCOMPLETE [65535 bytes] " */
+		ic = skb_header_pointer(skb, ptr, sizeof(_icmp6h), &_icmp6h);
+		if (ic == NULL) {
+			printk("INCOMPLETE [%u bytes] ", skb->len - ptr);
+			return;
+		}
+
 		/* Max length: 18 "TYPE=255 CODE=255 " */
-		printk("TYPE=%u CODE=%u ", icmp6h->icmp6_type, icmp6h->icmp6_code);
+		printk("TYPE=%u CODE=%u ", ic->icmp6_type, ic->icmp6_code);
 
-		switch (icmp6h->icmp6_type) {
+		switch (ic->icmp6_type) {
 		case ICMPV6_ECHO_REQUEST:
 		case ICMPV6_ECHO_REPLY:
 			/* Max length: 19 "ID=65535 SEQ=65535 " */
 			printk("ID=%u SEQ=%u ",
-				ntohs(icmp6h->icmp6_identifier),
-				ntohs(icmp6h->icmp6_sequence));
+				ntohs(ic->icmp6_identifier),
+				ntohs(ic->icmp6_sequence));
 			break;
 		case ICMPV6_MGM_QUERY:
 		case ICMPV6_MGM_REPORT:
@@ -246,7 +324,7 @@
 
 		case ICMPV6_PARAMPROB:
 			/* Max length: 17 "POINTER=ffffffff " */
-			printk("POINTER=%08x ", ntohl(icmp6h->icmp6_pointer));
+			printk("POINTER=%08x ", ntohl(ic->icmp6_pointer));
 			/* Fall through */
 		case ICMPV6_DEST_UNREACH:
 		case ICMPV6_PKT_TOOBIG:
@@ -254,13 +332,14 @@
 			/* Max length: 3+maxlen */
 			if (recurse) {
 				printk("[");
-				dump_packet(info, (struct ipv6hdr *)(icmp6h + 1), 0);
+				dump_packet(info, skb, ptr + sizeof(_icmp6h),
+					    0);
 				printk("] ");
 			}
 
 			/* Max length: 10 "MTU=65535 " */
-			if (icmp6h->icmp6_type == ICMPV6_PKT_TOOBIG)
-				printk("MTU=%u ", ntohl(icmp6h->icmp6_mtu));
+			if (ic->icmp6_type == ICMPV6_PKT_TOOBIG)
+				printk("MTU=%u ", ntohl(ic->icmp6_mtu));
 		}
 		break;
 	}
@@ -328,16 +407,16 @@
 			printk(" ");
 	}
 
-	dump_packet(loginfo, ipv6h, 1);
+	dump_packet(loginfo, skb, (u8*)skb->nh.ipv6h - skb->data, 1);
 	printk("\n");
 	spin_unlock_bh(&log_lock);
 }
 
 static unsigned int
 ip6t_log_target(struct sk_buff **pskb,
-		unsigned int hooknum,
 		const struct net_device *in,
 		const struct net_device *out,
+		unsigned int hooknum,
 		const void *targinfo,
 		void *userinfo)
 {
diff -Nru a/net/ipv6/netfilter/ip6t_MARK.c b/net/ipv6/netfilter/ip6t_MARK.c
--- a/net/ipv6/netfilter/ip6t_MARK.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv6/netfilter/ip6t_MARK.c	2004-12-24 13:37:19 -08:00
@@ -20,9 +20,9 @@
 
 static unsigned int
 target(struct sk_buff **pskb,
-       unsigned int hooknum,
        const struct net_device *in,
        const struct net_device *out,
+       unsigned int hooknum,
        const void *targinfo,
        void *userinfo)
 {
diff -Nru a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
--- a/net/ipv6/netfilter/ip6t_ah.c	2004-12-24 13:36:18 -08:00
+++ b/net/ipv6/netfilter/ip6t_ah.c	2004-12-24 13:36:18 -08:00
@@ -31,12 +31,12 @@
 static inline int
 spi_match(u_int32_t min, u_int32_t max, u_int32_t spi, int invert)
 {
-       int r=0;
-       DEBUGP("ah spi_match:%c 0x%x <= 0x%x <= 0x%x",invert? '!':' ',
-              min,spi,max);
-       r=(spi >= min && spi <= max) ^ invert;
-       DEBUGP(" result %s\n",r? "PASS\n" : "FAILED\n");
-       return r;
+	int r=0;
+	DEBUGP("ah spi_match:%c 0x%x <= 0x%x <= 0x%x",invert? '!':' ',
+	       min,spi,max);
+	r = (spi >= min && spi <= max) ^ invert;
+	DEBUGP(" result %s\n",r? "PASS\n" : "FAILED\n");
+	return r;
 }
 
 static int
@@ -45,125 +45,124 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *protohdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
-       struct ip_auth_hdr *ah = NULL;
-       const struct ip6t_ah *ahinfo = matchinfo;
-       unsigned int temp;
-       int len;
-       u8 nexthdr;
-       unsigned int ptr;
-       unsigned int hdrlen = 0;
-
-       /*DEBUGP("IPv6 AH entered\n");*/
-       /* if (opt->auth == 0) return 0;
-       * It does not filled on output */
-
-       /* type of the 1st exthdr */
-       nexthdr = skb->nh.ipv6h->nexthdr;
-       /* pointer to the 1st exthdr */
-       ptr = sizeof(struct ipv6hdr);
-       /* available length */
-       len = skb->len - ptr;
-       temp = 0;
-
-        while (ip6t_ext_hdr(nexthdr)) {
-               struct ipv6_opt_hdr *hdr;
-
-              DEBUGP("ipv6_ah header iteration \n");
-
-              /* Is there enough space for the next ext header? */
-                if (len < (int)sizeof(struct ipv6_opt_hdr))
-                        return 0;
-              /* No more exthdr -> evaluate */
-                if (nexthdr == NEXTHDR_NONE) {
-                     break;
-              }
-              /* ESP -> evaluate */
-                if (nexthdr == NEXTHDR_ESP) {
-                     break;
-              }
-
-              hdr=(struct ipv6_opt_hdr *)skb->data+ptr;
-
-              /* Calculate the header length */
-                if (nexthdr == NEXTHDR_FRAGMENT) {
-                        hdrlen = 8;
-                } else if (nexthdr == NEXTHDR_AUTH)
-                        hdrlen = (hdr->hdrlen+2)<<2;
-                else
-                        hdrlen = ipv6_optlen(hdr);
-
-              /* AH -> evaluate */
-                if (nexthdr == NEXTHDR_AUTH) {
-                     temp |= MASK_AH;
-                     break;
-              }
-
-
-              /* set the flag */
-              switch (nexthdr){
-                     case NEXTHDR_HOP:
-                     case NEXTHDR_ROUTING:
-                     case NEXTHDR_FRAGMENT:
-                     case NEXTHDR_AUTH:
-                     case NEXTHDR_DEST:
-                            break;
-                     default:
-                            DEBUGP("ipv6_ah match: unknown nextheader %u\n",nexthdr);
-                            return 0;
-                            break;
-              }
-
-                nexthdr = hdr->nexthdr;
-                len -= hdrlen;
-                ptr += hdrlen;
-		if ( ptr > skb->len ) {
-			DEBUGP("ipv6_ah: new pointer too large! \n");
+	struct ip_auth_hdr *ah = NULL, _ah;
+	const struct ip6t_ah *ahinfo = matchinfo;
+	unsigned int temp;
+	int len;
+	u8 nexthdr;
+	unsigned int ptr;
+	unsigned int hdrlen = 0;
+
+	/*DEBUGP("IPv6 AH entered\n");*/
+	/* if (opt->auth == 0) return 0;
+	* It does not filled on output */
+
+	/* type of the 1st exthdr */
+	nexthdr = skb->nh.ipv6h->nexthdr;
+	/* pointer to the 1st exthdr */
+	ptr = sizeof(struct ipv6hdr);
+	/* available length */
+	len = skb->len - ptr;
+	temp = 0;
+
+	while (ip6t_ext_hdr(nexthdr)) {
+		struct ipv6_opt_hdr _hdr, *hp;
+
+		DEBUGP("ipv6_ah header iteration \n");
+
+		/* Is there enough space for the next ext header? */
+		if (len < sizeof(struct ipv6_opt_hdr))
+			return 0;
+		/* No more exthdr -> evaluate */
+		if (nexthdr == NEXTHDR_NONE)
+			break;
+		/* ESP -> evaluate */
+		if (nexthdr == NEXTHDR_ESP)
+			break;
+
+		hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+		BUG_ON(hp == NULL);
+
+		/* Calculate the header length */
+		if (nexthdr == NEXTHDR_FRAGMENT)
+			hdrlen = 8;
+		else if (nexthdr == NEXTHDR_AUTH)
+			hdrlen = (hp->hdrlen+2)<<2;
+		else
+			hdrlen = ipv6_optlen(hp);
+
+		/* AH -> evaluate */
+		if (nexthdr == NEXTHDR_AUTH) {
+			temp |= MASK_AH;
+			break;
+		}
+
+		
+		/* set the flag */
+		switch (nexthdr) {
+		case NEXTHDR_HOP:
+		case NEXTHDR_ROUTING:
+		case NEXTHDR_FRAGMENT:
+		case NEXTHDR_AUTH:
+		case NEXTHDR_DEST:
 			break;
+		default:
+			DEBUGP("ipv6_ah match: unknown nextheader %u\n",nexthdr);
+			return 0;
 		}
-        }
 
-       /* AH header not found */
-       if ( temp != MASK_AH ) return 0;
+		nexthdr = hp->nexthdr;
+		len -= hdrlen;
+		ptr += hdrlen;
+		if (ptr > skb->len) {
+			DEBUGP("ipv6_ah: new pointer too large! \n");
+			break;
+		}
+	}
 
-       if (len < (int)sizeof(struct ip_auth_hdr)){
-	       *hotdrop = 1;
-       		return 0;
-       }
-
-       ah = (struct ip_auth_hdr *) (skb->data + ptr);
-
-       DEBUGP("IPv6 AH LEN %u %u ", hdrlen, ah->hdrlen);
-       DEBUGP("RES %04X ", ah->reserved);
-       DEBUGP("SPI %u %08X\n", ntohl(ah->spi), ntohl(ah->spi));
-
-       DEBUGP("IPv6 AH spi %02X ",
-       		(spi_match(ahinfo->spis[0], ahinfo->spis[1],
-                           ntohl(ah->spi),
-                           !!(ahinfo->invflags & IP6T_AH_INV_SPI))));
-       DEBUGP("len %02X %04X %02X ",
-       		ahinfo->hdrlen, hdrlen,
-       		(!ahinfo->hdrlen ||
-                           (ahinfo->hdrlen == hdrlen) ^
-                           !!(ahinfo->invflags & IP6T_AH_INV_LEN)));
-       DEBUGP("res %02X %04X %02X\n", 
-       		ahinfo->hdrres, ah->reserved,
-       		!(ahinfo->hdrres && ah->reserved));
-
-       return (ah != NULL)
-              &&
-              (spi_match(ahinfo->spis[0], ahinfo->spis[1],
-                           ntohl(ah->spi),
-                           !!(ahinfo->invflags & IP6T_AH_INV_SPI)))
-              &&
-              (!ahinfo->hdrlen ||
-                           (ahinfo->hdrlen == hdrlen) ^
-                           !!(ahinfo->invflags & IP6T_AH_INV_LEN))
-              &&
-              !(ahinfo->hdrres && ah->reserved);
+	/* AH header not found */
+	if (temp != MASK_AH)
+		return 0;
+
+	if (len < sizeof(struct ip_auth_hdr)){
+		*hotdrop = 1;
+		return 0;
+	}
+
+	ah = skb_header_pointer(skb, ptr, sizeof(_ah), &_ah);
+	BUG_ON(ah == NULL);
+
+	DEBUGP("IPv6 AH LEN %u %u ", hdrlen, ah->hdrlen);
+	DEBUGP("RES %04X ", ah->reserved);
+	DEBUGP("SPI %u %08X\n", ntohl(ah->spi), ntohl(ah->spi));
+
+	DEBUGP("IPv6 AH spi %02X ",
+	       (spi_match(ahinfo->spis[0], ahinfo->spis[1],
+	                  ntohl(ah->spi),
+	                  !!(ahinfo->invflags & IP6T_AH_INV_SPI))));
+	DEBUGP("len %02X %04X %02X ",
+	       ahinfo->hdrlen, hdrlen,
+	       (!ahinfo->hdrlen ||
+	        (ahinfo->hdrlen == hdrlen) ^
+	        !!(ahinfo->invflags & IP6T_AH_INV_LEN)));
+	DEBUGP("res %02X %04X %02X\n",
+	       ahinfo->hdrres, ah->reserved,
+	       !(ahinfo->hdrres && ah->reserved));
+
+	return (ah != NULL)
+	       &&
+	       (spi_match(ahinfo->spis[0], ahinfo->spis[1],
+	                  ntohl(ah->spi),
+	                  !!(ahinfo->invflags & IP6T_AH_INV_SPI)))
+	       &&
+	       (!ahinfo->hdrlen ||
+	        (ahinfo->hdrlen == hdrlen) ^
+	        !!(ahinfo->invflags & IP6T_AH_INV_LEN))
+	       &&
+	       !(ahinfo->hdrres && ah->reserved);
 }
 
 /* Called when user tries to insert an entry of this type. */
@@ -174,20 +173,18 @@
           unsigned int matchinfosize,
           unsigned int hook_mask)
 {
-       const struct ip6t_ah *ahinfo = matchinfo;
-
-       if (matchinfosize != IP6T_ALIGN(sizeof(struct ip6t_ah))) {
-              DEBUGP("ip6t_ah: matchsize %u != %u\n",
-                      matchinfosize, IP6T_ALIGN(sizeof(struct ip6t_ah)));
-              return 0;
-       }
-       if (ahinfo->invflags & ~IP6T_AH_INV_MASK) {
-              DEBUGP("ip6t_ah: unknown flags %X\n",
-                      ahinfo->invflags);
-              return 0;
-       }
+	const struct ip6t_ah *ahinfo = matchinfo;
 
-       return 1;
+	if (matchinfosize != IP6T_ALIGN(sizeof(struct ip6t_ah))) {
+		DEBUGP("ip6t_ah: matchsize %u != %u\n",
+		       matchinfosize, IP6T_ALIGN(sizeof(struct ip6t_ah)));
+		return 0;
+	}
+	if (ahinfo->invflags & ~IP6T_AH_INV_MASK) {
+		DEBUGP("ip6t_ah: unknown flags %X\n", ahinfo->invflags);
+		return 0;
+	}
+	return 1;
 }
 
 static struct ip6t_match ah_match = {
@@ -199,12 +196,12 @@
 
 static int __init init(void)
 {
-       return ip6t_register_match(&ah_match);
+	return ip6t_register_match(&ah_match);
 }
 
 static void __exit cleanup(void)
 {
-       ip6t_unregister_match(&ah_match);
+	ip6t_unregister_match(&ah_match);
 }
 
 module_init(init);
diff -Nru a/net/ipv6/netfilter/ip6t_dst.c b/net/ipv6/netfilter/ip6t_dst.c
--- a/net/ipv6/netfilter/ip6t_dst.c	2004-12-24 13:36:17 -08:00
+++ b/net/ipv6/netfilter/ip6t_dst.c	2004-12-24 13:36:17 -08:00
@@ -7,7 +7,6 @@
  * published by the Free Software Foundation.
  */
 
-
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ipv6.h>
@@ -20,8 +19,6 @@
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_opts.h>
 
-#define LOW(n)		(n & 0x00FF)
-
 #define HOPBYHOP	0
 
 MODULE_LICENSE("GPL");
@@ -48,8 +45,8 @@
  *  	0	-> invariant
  *  	1	-> can change the routing
  *  (Type & 0x1F) Type
- *      0	-> PAD0 (only 1 byte!)
- *      1	-> PAD1 LENGTH info (total length = length + 2)
+ *      0	-> Pad1 (only 1 byte!)
+ *      1	-> PadN LENGTH info (total length = length + 2)
  *      C0 | 2	-> JUMBO 4 x x x x ( xxxx > 64k )
  *      5	-> RTALERT 2 x x
  */
@@ -60,11 +57,10 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *protohdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
-       struct ipv6_opt_hdr *optsh = NULL;
+       struct ipv6_opt_hdr _optsh, *oh;
        const struct ip6t_opts *optinfo = matchinfo;
        unsigned int temp;
        unsigned int len;
@@ -72,7 +68,9 @@
        unsigned int ptr;
        unsigned int hdrlen = 0;
        unsigned int ret = 0;
-       u_int16_t *optdesc = NULL;
+       u8 _opttype, *tp = NULL;
+       u8 _optlen, *lp = NULL;
+       unsigned int optlen;
        
        /* type of the 1st exthdr */
        nexthdr = skb->nh.ipv6h->nexthdr;
@@ -83,7 +81,7 @@
        temp = 0;
 
         while (ip6t_ext_hdr(nexthdr)) {
-               struct ipv6_opt_hdr *hdr;
+               struct ipv6_opt_hdr _hdr, *hp;
 
               DEBUGP("ipv6_opts header iteration \n");
 
@@ -99,15 +97,16 @@
                      break;
               }
 
-              hdr=(void *)(skb->data)+ptr;
+	      hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+	      BUG_ON(hp == NULL);
 
               /* Calculate the header length */
                 if (nexthdr == NEXTHDR_FRAGMENT) {
                         hdrlen = 8;
                 } else if (nexthdr == NEXTHDR_AUTH)
-                        hdrlen = (hdr->hdrlen+2)<<2;
+                        hdrlen = (hp->hdrlen+2)<<2;
                 else
-                        hdrlen = ipv6_optlen(hdr);
+                        hdrlen = ipv6_optlen(hp);
 
               /* OPTS -> evaluate */
 #if HOPBYHOP
@@ -135,7 +134,7 @@
                             break;
               }
 
-                nexthdr = hdr->nexthdr;
+                nexthdr = hp->nexthdr;
                 len -= hdrlen;
                 ptr += hdrlen;
 		if ( ptr > skb->len ) {
@@ -161,9 +160,10 @@
        		return 0;
        }
 
-       optsh=(void *)(skb->data)+ptr;
+       oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
+       BUG_ON(oh == NULL);
 
-       DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, optsh->hdrlen);
+       DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, oh->hdrlen);
 
        DEBUGP("len %02X %04X %02X ",
        		optinfo->hdrlen, hdrlen,
@@ -171,13 +171,12 @@
                            ((optinfo->hdrlen == hdrlen) ^
                            !!(optinfo->invflags & IP6T_OPTS_INV_LEN))));
 
-       ret = (optsh != NULL)
+       ret = (oh != NULL)
        		&&
 	      	(!(optinfo->flags & IP6T_OPTS_LEN) ||
                            ((optinfo->hdrlen == hdrlen) ^
                            !!(optinfo->invflags & IP6T_OPTS_INV_LEN)));
 
-       temp = len = 0;
        ptr += 2;
        hdrlen -= 2;
        if ( !(optinfo->flags & IP6T_OPTS_OPTS) ){
@@ -188,48 +187,59 @@
 		DEBUGP("Strict ");
 		DEBUGP("#%d ",optinfo->optsnr);
 		for(temp=0; temp<optinfo->optsnr; temp++){
-			optdesc = (void *)(skb->data)+ptr;
+			/* type field exists ? */
+			if (hdrlen < 1)
+				break;
+			tp = skb_header_pointer(skb, ptr, sizeof(_opttype),
+						&_opttype);
+			if (tp == NULL)
+				break;
+
 			/* Type check */
-			if ( (unsigned char)*optdesc != 
-				(optinfo->opts[temp] & 0xFF00)>>8 ){
+			if (*tp != (optinfo->opts[temp] & 0xFF00)>>8){
 				DEBUGP("Tbad %02X %02X\n",
-						(unsigned char)*optdesc,
-						(optinfo->opts[temp] &
-						 0xFF00)>>8);
+				       *tp,
+				       (optinfo->opts[temp] & 0xFF00)>>8);
 				return 0;
 			} else {
 				DEBUGP("Tok ");
 			}
 			/* Length check */
-			if (((optinfo->opts[temp] & 0x00FF) != 0xFF) &&
-				(unsigned char)*optdesc != 0){
-				if ( ntohs((u16)*optdesc) != 
-						optinfo->opts[temp] ){
-					DEBUGP("Lbad %02X %04X %04X\n",
-							(unsigned char)*optdesc,
-							ntohs((u16)*optdesc),
-							optinfo->opts[temp]);
+			if (*tp) {
+				u16 spec_len;
+
+				/* length field exists ? */
+				if (hdrlen < 2)
+					break;
+				lp = skb_header_pointer(skb, ptr + 1,
+							sizeof(_optlen),
+							&_optlen);
+				if (lp == NULL)
+					break;
+				spec_len = optinfo->opts[temp] & 0x00FF;
+
+				if (spec_len != 0x00FF && spec_len != *lp) {
+					DEBUGP("Lbad %02X %04X\n", *lp,
+					       spec_len);
 					return 0;
-				} else {
-					DEBUGP("Lok ");
 				}
-			}
-			/* Step to the next */
-			if ((unsigned char)*optdesc == 0){
-				DEBUGP("PAD0 \n");
-				ptr++;
-				hdrlen--;
+				DEBUGP("Lok ");
+				optlen = *lp + 2;
 			} else {
-				ptr += LOW(ntohs(*optdesc));
-				hdrlen -= LOW(ntohs(*optdesc));
-				DEBUGP("len%04X \n", 
-					LOW(ntohs(*optdesc)));
+				DEBUGP("Pad1\n");
+				optlen = 1;
 			}
-			if (ptr > skb->len || ( !hdrlen && 
-				(temp != optinfo->optsnr - 1))) {
+
+			/* Step to the next */
+			DEBUGP("len%04X \n", optlen);
+
+			if ((ptr > skb->len - optlen || hdrlen < optlen) &&
+			    (temp < optinfo->optsnr - 1)) {
 				DEBUGP("new pointer is too large! \n");
 				break;
 			}
+			ptr += optlen;
+			hdrlen -= optlen;
 		}
 		if (temp == optinfo->optsnr)
 			return ret;
@@ -271,6 +281,7 @@
 #endif
 	.match		= &match,
 	.checkentry	= &checkentry,
+	.me		= THIS_MODULE,
 };
 
 static int __init init(void)
diff -Nru a/net/ipv6/netfilter/ip6t_esp.c b/net/ipv6/netfilter/ip6t_esp.c
--- a/net/ipv6/netfilter/ip6t_esp.c	2004-12-24 13:37:00 -08:00
+++ b/net/ipv6/netfilter/ip6t_esp.c	2004-12-24 13:37:00 -08:00
@@ -32,8 +32,8 @@
 spi_match(u_int32_t min, u_int32_t max, u_int32_t spi, int invert)
 {
 	int r=0;
-        DEBUGP("esp spi_match:%c 0x%x <= 0x%x <= 0x%x",invert? '!':' ',
-        	min,spi,max);
+	DEBUGP("esp spi_match:%c 0x%x <= 0x%x <= 0x%x",invert? '!':' ',
+	       min,spi,max);
 	r=(spi >= min && spi <= max) ^ invert;
 	DEBUGP(" result %s\n",r? "PASS\n" : "FAILED\n");
 	return r;
@@ -45,11 +45,10 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *protohdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
-	struct ip_esp_hdr *esp = NULL;
+	struct ip_esp_hdr _esp, *eh = NULL;
 	const struct ip6t_esp *espinfo = matchinfo;
 	unsigned int temp;
 	int len;
@@ -67,73 +66,74 @@
 	len = skb->len - ptr;
 	temp = 0;
 
-        while (ip6t_ext_hdr(nexthdr)) {
-        	struct ipv6_opt_hdr *hdr;
-        	int hdrlen;
+	while (ip6t_ext_hdr(nexthdr)) {
+		struct ipv6_opt_hdr _hdr, *hp;
+		int hdrlen;
 
 		DEBUGP("ipv6_esp header iteration \n");
 
 		/* Is there enough space for the next ext header? */
-                if (len < (int)sizeof(struct ipv6_opt_hdr))
-                        return 0;
+		if (len < sizeof(struct ipv6_opt_hdr))
+			return 0;
 		/* No more exthdr -> evaluate */
-                if (nexthdr == NEXTHDR_NONE) {
+		if (nexthdr == NEXTHDR_NONE)
 			break;
-		}
 		/* ESP -> evaluate */
-                if (nexthdr == NEXTHDR_ESP) {
+		if (nexthdr == NEXTHDR_ESP) {
 			temp |= MASK_ESP;
 			break;
 		}
 
-		hdr=(struct ipv6_opt_hdr *)skb->data+ptr;
+		hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+		BUG_ON(hp == NULL);
 
 		/* Calculate the header length */
-                if (nexthdr == NEXTHDR_FRAGMENT) {
-                        hdrlen = 8;
-                } else if (nexthdr == NEXTHDR_AUTH)
-                        hdrlen = (hdr->hdrlen+2)<<2;
-                else
-                        hdrlen = ipv6_optlen(hdr);
+		if (nexthdr == NEXTHDR_FRAGMENT)
+			hdrlen = 8;
+		else if (nexthdr == NEXTHDR_AUTH)
+			hdrlen = (hp->hdrlen+2)<<2;
+		else
+			hdrlen = ipv6_optlen(hp);
 
 		/* set the flag */
-		switch (nexthdr){
-			case NEXTHDR_HOP:
-			case NEXTHDR_ROUTING:
-			case NEXTHDR_FRAGMENT:
-			case NEXTHDR_AUTH:
-			case NEXTHDR_DEST:
-				break;
-			default:
-				DEBUGP("ipv6_esp match: unknown nextheader %u\n",nexthdr);
-				return 0;
-				break;
+		switch (nexthdr) {
+		case NEXTHDR_HOP:
+		case NEXTHDR_ROUTING:
+		case NEXTHDR_FRAGMENT:
+		case NEXTHDR_AUTH:
+		case NEXTHDR_DEST:
+			break;
+		default:
+			DEBUGP("ipv6_esp match: unknown nextheader %u\n",nexthdr);
+			return 0;
 		}
 
-                nexthdr = hdr->nexthdr;
-                len -= hdrlen;
-                ptr += hdrlen;
-		if ( ptr > skb->len ) {
+		nexthdr = hp->nexthdr;
+		len -= hdrlen;
+		ptr += hdrlen;
+		if (ptr > skb->len) {
 			DEBUGP("ipv6_esp: new pointer too large! \n");
 			break;
 		}
-        }
+	}
 
 	/* ESP header not found */
-	if ( temp != MASK_ESP ) return 0;
+	if (temp != MASK_ESP)
+		return 0;
 
-       if (len < (int)sizeof(struct ip_esp_hdr)){
-	       *hotdrop = 1;
-       		return 0;
-       }
+	if (len < sizeof(struct ip_esp_hdr)) {
+		*hotdrop = 1;
+		return 0;
+	}
 
-	esp = (struct ip_esp_hdr *) (skb->data + ptr);
+	eh = skb_header_pointer(skb, ptr, sizeof(_esp), &_esp);
+	BUG_ON(eh == NULL);
 
-	DEBUGP("IPv6 ESP SPI %u %08X\n", ntohl(esp->spi), ntohl(esp->spi));
+	DEBUGP("IPv6 ESP SPI %u %08X\n", ntohl(eh->spi), ntohl(eh->spi));
 
-	return (esp != NULL)
+	return (eh != NULL)
 		&& spi_match(espinfo->spis[0], espinfo->spis[1],
-			      ntohl(esp->spi),
+			      ntohl(eh->spi),
 			      !!(espinfo->invflags & IP6T_ESP_INV_SPI));
 }
 
@@ -157,7 +157,6 @@
 			 espinfo->invflags);
 		return 0;
 	}
-
 	return 1;
 }
 
diff -Nru a/net/ipv6/netfilter/ip6t_eui64.c b/net/ipv6/netfilter/ip6t_eui64.c
--- a/net/ipv6/netfilter/ip6t_eui64.c	2004-12-24 13:36:17 -08:00
+++ b/net/ipv6/netfilter/ip6t_eui64.c	2004-12-24 13:36:17 -08:00
@@ -24,8 +24,7 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *hdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
 
@@ -70,7 +69,7 @@
 {
 	if (hook_mask
 	    & ~((1 << NF_IP6_PRE_ROUTING) | (1 << NF_IP6_LOCAL_IN) |
-		(1 << NF_IP6_PRE_ROUTING) )) {
+		(1 << NF_IP6_FORWARD))) {
 		printk("ip6t_eui64: only valid for PRE_ROUTING, LOCAL_IN or FORWARD.\n");
 		return 0;
 	}
diff -Nru a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c
--- a/net/ipv6/netfilter/ip6t_frag.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv6/netfilter/ip6t_frag.c	2004-12-24 13:36:31 -08:00
@@ -14,8 +14,6 @@
 #include <net/checksum.h>
 #include <net/ipv6.h>
 
-#include <asm/byteorder.h>
-
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_frag.h>
 
@@ -29,29 +27,6 @@
 #define DEBUGP(format, args...)
 #endif
 
-#if 0
-#if     BYTE_ORDER == BIG_ENDIAN
-#define IP6F_OFF_MASK       0xfff8  /* mask out offset from _offlg */
-#define IP6F_RESERVED_MASK  0x0006  /* reserved bits in ip6f_offlg */
-#define IP6F_MORE_FRAG      0x0001  /* more-fragments flag */
-#else   /* BYTE_ORDER == LITTLE_ENDIAN */
-#define IP6F_OFF_MASK       0xf8ff  /* mask out offset from _offlg */
-#define IP6F_RESERVED_MASK  0x0600  /* reserved bits in ip6f_offlg */
-#define IP6F_MORE_FRAG      0x0100  /* more-fragments flag */
-#endif
-#endif
-
-#define IP6F_OFF_MASK       0xf8ff  /* mask out offset from _offlg */
-#define IP6F_RESERVED_MASK  0x0600  /* reserved bits in ip6f_offlg */
-#define IP6F_MORE_FRAG      0x0100  /* more-fragments flag */
-
-struct fraghdr {
-       __u8    nexthdr;
-       __u8    hdrlen;
-       __u16   info;
-       __u32   id;
-};
-
 /* Returns 1 if the id is matched by the range, 0 otherwise */
 static inline int
 id_match(u_int32_t min, u_int32_t max, u_int32_t id, int invert)
@@ -70,11 +45,10 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *protohdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
-       struct fraghdr *frag = NULL;
+       struct frag_hdr _frag, *fh = NULL;
        const struct ip6t_frag *fraginfo = matchinfo;
        unsigned int temp;
        int len;
@@ -91,7 +65,7 @@
        temp = 0;
 
         while (ip6t_ext_hdr(nexthdr)) {
-               struct ipv6_opt_hdr *hdr;
+               struct ipv6_opt_hdr _hdr, *hp;
 
               DEBUGP("ipv6_frag header iteration \n");
 
@@ -107,15 +81,16 @@
                      break;
               }
 
-              hdr=(struct ipv6_opt_hdr *)skb->data+ptr;
+	      hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+	      BUG_ON(hp == NULL);
 
               /* Calculate the header length */
                 if (nexthdr == NEXTHDR_FRAGMENT) {
                         hdrlen = 8;
                 } else if (nexthdr == NEXTHDR_AUTH)
-                        hdrlen = (hdr->hdrlen+2)<<2;
+                        hdrlen = (hp->hdrlen+2)<<2;
                 else
-                        hdrlen = ipv6_optlen(hdr);
+                        hdrlen = ipv6_optlen(hp);
 
               /* FRAG -> evaluate */
                 if (nexthdr == NEXTHDR_FRAGMENT) {
@@ -138,7 +113,7 @@
                             break;
               }
 
-                nexthdr = hdr->nexthdr;
+                nexthdr = hp->nexthdr;
                 len -= hdrlen;
                 ptr += hdrlen;
 		if ( ptr > skb->len ) {
@@ -150,59 +125,63 @@
        /* FRAG header not found */
        if ( temp != MASK_FRAGMENT ) return 0;
 
-       if (len < (int)sizeof(struct fraghdr)){
+       if (len < sizeof(struct frag_hdr)){
 	       *hotdrop = 1;
        		return 0;
        }
 
-       frag = (struct fraghdr *) (skb->data + ptr);
+       fh = skb_header_pointer(skb, ptr, sizeof(_frag), &_frag);
+       BUG_ON(fh == NULL);
 
-       DEBUGP("IPv6 FRAG LEN %u %u ", hdrlen, frag->hdrlen);
-       DEBUGP("INFO %04X ", frag->info);
-       DEBUGP("OFFSET %04X ", frag->info & IP6F_OFF_MASK);
-       DEBUGP("RES %04X ", frag->info & IP6F_RESERVED_MASK);
-       DEBUGP("MF %04X ", frag->info & IP6F_MORE_FRAG);
-       DEBUGP("ID %u %08X\n", ntohl(frag->id), ntohl(frag->id));
+       DEBUGP("INFO %04X ", fh->frag_off);
+       DEBUGP("OFFSET %04X ", ntohs(fh->frag_off) & ~0x7);
+       DEBUGP("RES %02X %04X", fh->reserved, ntohs(fh->frag_off) & 0x6);
+       DEBUGP("MF %04X ", fh->frag_off & htons(IP6_MF));
+       DEBUGP("ID %u %08X\n", ntohl(fh->identification),
+	      ntohl(fh->identification));
 
        DEBUGP("IPv6 FRAG id %02X ",
        		(id_match(fraginfo->ids[0], fraginfo->ids[1],
-                           ntohl(frag->id),
+                           ntohl(fh->identification),
                            !!(fraginfo->invflags & IP6T_FRAG_INV_IDS))));
-       DEBUGP("len %02X %04X %02X ",
-       		fraginfo->hdrlen, hdrlen,
-       		(!fraginfo->hdrlen ||
-                           (fraginfo->hdrlen == hdrlen) ^
-                           !!(fraginfo->invflags & IP6T_FRAG_INV_LEN)));
-       DEBUGP("res %02X %02X %02X ", 
-       		(fraginfo->flags & IP6T_FRAG_RES), frag->info & IP6F_RESERVED_MASK,
-       		!((fraginfo->flags & IP6T_FRAG_RES) && (frag->info & IP6F_RESERVED_MASK)));
+       DEBUGP("res %02X %02X%04X %02X ", 
+       		(fraginfo->flags & IP6T_FRAG_RES), fh->reserved,
+		ntohs(fh->frag_off) & 0x6,
+       		!((fraginfo->flags & IP6T_FRAG_RES)
+			&& (fh->reserved || (ntohs(fh->frag_off) & 0x06))));
        DEBUGP("first %02X %02X %02X ", 
-       		(fraginfo->flags & IP6T_FRAG_FST), frag->info & IP6F_OFF_MASK,
-       		!((fraginfo->flags & IP6T_FRAG_FST) && (frag->info & IP6F_OFF_MASK)));
+       		(fraginfo->flags & IP6T_FRAG_FST),
+		ntohs(fh->frag_off) & ~0x7,
+       		!((fraginfo->flags & IP6T_FRAG_FST)
+			&& (ntohs(fh->frag_off) & ~0x7)));
        DEBUGP("mf %02X %02X %02X ", 
-       		(fraginfo->flags & IP6T_FRAG_MF), frag->info & IP6F_MORE_FRAG,
-       		!((fraginfo->flags & IP6T_FRAG_MF) && !((frag->info & IP6F_MORE_FRAG))));
+       		(fraginfo->flags & IP6T_FRAG_MF),
+		ntohs(fh->frag_off) & IP6_MF,
+       		!((fraginfo->flags & IP6T_FRAG_MF)
+			&& !((ntohs(fh->frag_off) & IP6_MF))));
        DEBUGP("last %02X %02X %02X\n", 
-       		(fraginfo->flags & IP6T_FRAG_NMF), frag->info & IP6F_MORE_FRAG,
-       		!((fraginfo->flags & IP6T_FRAG_NMF) && (frag->info & IP6F_MORE_FRAG)));
+       		(fraginfo->flags & IP6T_FRAG_NMF),
+		ntohs(fh->frag_off) & IP6_MF,
+       		!((fraginfo->flags & IP6T_FRAG_NMF)
+			&& (ntohs(fh->frag_off) & IP6_MF)));
 
-       return (frag != NULL)
+       return (fh != NULL)
        		&&
        		(id_match(fraginfo->ids[0], fraginfo->ids[1],
-                           ntohl(frag->id),
+			  ntohl(fh->identification),
                            !!(fraginfo->invflags & IP6T_FRAG_INV_IDS)))
 		&&
-	      	(!fraginfo->hdrlen ||
-                           (fraginfo->hdrlen == hdrlen) ^
-                           !!(fraginfo->invflags & IP6T_FRAG_INV_LEN))
-		&&
-		!((fraginfo->flags & IP6T_FRAG_RES) && (frag->info & IP6F_RESERVED_MASK))
+		!((fraginfo->flags & IP6T_FRAG_RES)
+			&& (fh->reserved || (ntohs(fh->frag_off) & 0x6)))
 		&&
-		!((fraginfo->flags & IP6T_FRAG_FST) && (frag->info & IP6F_OFF_MASK))
+		!((fraginfo->flags & IP6T_FRAG_FST)
+			&& (ntohs(fh->frag_off) & ~0x7))
 		&&
-		!((fraginfo->flags & IP6T_FRAG_MF) && !((frag->info & IP6F_MORE_FRAG)))
+		!((fraginfo->flags & IP6T_FRAG_MF)
+			&& !(ntohs(fh->frag_off) & IP6_MF))
 		&&
-		!((fraginfo->flags & IP6T_FRAG_NMF) && (frag->info & IP6F_MORE_FRAG));
+		!((fraginfo->flags & IP6T_FRAG_NMF)
+			&& (ntohs(fh->frag_off) & IP6_MF));
 }
 
 /* Called when user tries to insert an entry of this type. */
diff -Nru a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c
--- a/net/ipv6/netfilter/ip6t_hbh.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv6/netfilter/ip6t_hbh.c	2004-12-24 13:37:18 -08:00
@@ -19,8 +19,6 @@
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_opts.h>
 
-#define LOW(n)		(n & 0x00FF)
-
 #define HOPBYHOP	1
 
 MODULE_LICENSE("GPL");
@@ -47,8 +45,8 @@
  *  	0	-> invariant
  *  	1	-> can change the routing
  *  (Type & 0x1F) Type
- *      0	-> PAD0 (only 1 byte!)
- *      1	-> PAD1 LENGTH info (total length = length + 2)
+ *      0	-> Pad1 (only 1 byte!)
+ *      1	-> PadN LENGTH info (total length = length + 2)
  *      C0 | 2	-> JUMBO 4 x x x x ( xxxx > 64k )
  *      5	-> RTALERT 2 x x
  */
@@ -59,11 +57,10 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *protohdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
-       struct ipv6_opt_hdr *optsh = NULL;
+       struct ipv6_opt_hdr _optsh, *oh;
        const struct ip6t_opts *optinfo = matchinfo;
        unsigned int temp;
        unsigned int len;
@@ -71,7 +68,9 @@
        unsigned int ptr;
        unsigned int hdrlen = 0;
        unsigned int ret = 0;
-       u_int16_t *optdesc = NULL;
+       u8 _opttype, *tp = NULL;
+       u8 _optlen, *lp = NULL;
+       unsigned int optlen;
        
        /* type of the 1st exthdr */
        nexthdr = skb->nh.ipv6h->nexthdr;
@@ -82,7 +81,7 @@
        temp = 0;
 
         while (ip6t_ext_hdr(nexthdr)) {
-               struct ipv6_opt_hdr *hdr;
+               struct ipv6_opt_hdr _hdr, *hp;
 
               DEBUGP("ipv6_opts header iteration \n");
 
@@ -98,15 +97,16 @@
                      break;
               }
 
-              hdr=(void *)(skb->data)+ptr;
+	      hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+	      BUG_ON(hp == NULL);
 
               /* Calculate the header length */
                 if (nexthdr == NEXTHDR_FRAGMENT) {
                         hdrlen = 8;
                 } else if (nexthdr == NEXTHDR_AUTH)
-                        hdrlen = (hdr->hdrlen+2)<<2;
+                        hdrlen = (hp->hdrlen+2)<<2;
                 else
-                        hdrlen = ipv6_optlen(hdr);
+                        hdrlen = ipv6_optlen(hp);
 
               /* OPTS -> evaluate */
 #if HOPBYHOP
@@ -134,7 +134,7 @@
                             break;
               }
 
-                nexthdr = hdr->nexthdr;
+                nexthdr = hp->nexthdr;
                 len -= hdrlen;
                 ptr += hdrlen;
 		if ( ptr > skb->len ) {
@@ -160,9 +160,10 @@
        		return 0;
        }
 
-       optsh=(void *)(skb->data)+ptr;
+       oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
+       BUG_ON(oh == NULL);
 
-       DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, optsh->hdrlen);
+       DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, oh->hdrlen);
 
        DEBUGP("len %02X %04X %02X ",
        		optinfo->hdrlen, hdrlen,
@@ -170,13 +171,12 @@
                            ((optinfo->hdrlen == hdrlen) ^
                            !!(optinfo->invflags & IP6T_OPTS_INV_LEN))));
 
-       ret = (optsh != NULL)
+       ret = (oh != NULL)
        		&&
 	      	(!(optinfo->flags & IP6T_OPTS_LEN) ||
                            ((optinfo->hdrlen == hdrlen) ^
                            !!(optinfo->invflags & IP6T_OPTS_INV_LEN)));
 
-       temp = len = 0;
        ptr += 2;
        hdrlen -= 2;
        if ( !(optinfo->flags & IP6T_OPTS_OPTS) ){
@@ -187,48 +187,59 @@
 		DEBUGP("Strict ");
 		DEBUGP("#%d ",optinfo->optsnr);
 		for(temp=0; temp<optinfo->optsnr; temp++){
-			optdesc = (void *)(skb->data)+ptr;
+			/* type field exists ? */
+			if (hdrlen < 1)
+				break;
+			tp = skb_header_pointer(skb, ptr, sizeof(_opttype),
+						&_opttype);
+			if (tp == NULL)
+				break;
+
 			/* Type check */
-			if ( (unsigned char)*optdesc != 
-				(optinfo->opts[temp] & 0xFF00)>>8 ){
+			if (*tp != (optinfo->opts[temp] & 0xFF00)>>8){
 				DEBUGP("Tbad %02X %02X\n",
-						(unsigned char)*optdesc,
-						(optinfo->opts[temp] &
-						 0xFF00)>>8);
+				       *tp,
+				       (optinfo->opts[temp] & 0xFF00)>>8);
 				return 0;
 			} else {
 				DEBUGP("Tok ");
 			}
 			/* Length check */
-			if (((optinfo->opts[temp] & 0x00FF) != 0xFF) &&
-				(unsigned char)*optdesc != 0){
-				if ( ntohs((u16)*optdesc) != 
-						optinfo->opts[temp] ){
-					DEBUGP("Lbad %02X %04X %04X\n",
-							(unsigned char)*optdesc,
-							ntohs((u16)*optdesc),
-							optinfo->opts[temp]);
+			if (*tp) {
+				u16 spec_len;
+
+				/* length field exists ? */
+				if (hdrlen < 2)
+					break;
+				lp = skb_header_pointer(skb, ptr + 1,
+							sizeof(_optlen),
+							&_optlen);
+				if (lp == NULL)
+					break;
+				spec_len = optinfo->opts[temp] & 0x00FF;
+
+				if (spec_len != 0x00FF && spec_len != *lp) {
+					DEBUGP("Lbad %02X %04X\n", *lp,
+					       spec_len);
 					return 0;
-				} else {
-					DEBUGP("Lok ");
 				}
-			}
-			/* Step to the next */
-			if ((unsigned char)*optdesc == 0){
-				DEBUGP("PAD0 \n");
-				ptr++;
-				hdrlen--;
+				DEBUGP("Lok ");
+				optlen = *lp + 2;
 			} else {
-				ptr += LOW(ntohs(*optdesc));
-				hdrlen -= LOW(ntohs(*optdesc));
-				DEBUGP("len%04X \n", 
-					LOW(ntohs(*optdesc)));
+				DEBUGP("Pad1\n");
+				optlen = 1;
 			}
-			if (ptr > skb->len || ( !hdrlen && 
-				(temp != optinfo->optsnr - 1))) {
+
+			/* Step to the next */
+			DEBUGP("len%04X \n", optlen);
+
+			if ((ptr > skb->len - optlen || hdrlen < optlen) &&
+			    (temp < optinfo->optsnr - 1)) {
 				DEBUGP("new pointer is too large! \n");
 				break;
 			}
+			ptr += optlen;
+			hdrlen -= optlen;
 		}
 		if (temp == optinfo->optsnr)
 			return ret;
diff -Nru a/net/ipv6/netfilter/ip6t_hl.c b/net/ipv6/netfilter/ip6t_hl.c
--- a/net/ipv6/netfilter/ip6t_hl.c	2004-12-24 13:37:01 -08:00
+++ b/net/ipv6/netfilter/ip6t_hl.c	2004-12-24 13:37:01 -08:00
@@ -20,7 +20,7 @@
 
 static int match(const struct sk_buff *skb, const struct net_device *in,
 		 const struct net_device *out, const void *matchinfo,
-		 int offset, const void *hdr, u_int16_t datalen,
+		 int offset, unsigned int protoff,
 		 int *hotdrop)
 {
 	const struct ip6t_hl_info *info = matchinfo;
diff -Nru a/net/ipv6/netfilter/ip6t_ipv6header.c b/net/ipv6/netfilter/ip6t_ipv6header.c
--- a/net/ipv6/netfilter/ip6t_ipv6header.c	2004-12-24 13:37:33 -08:00
+++ b/net/ipv6/netfilter/ip6t_ipv6header.c	2004-12-24 13:37:33 -08:00
@@ -31,8 +31,7 @@
 		 const struct net_device *out,
 		 const void *matchinfo,
 		 int offset,
-		 const void *protohdr,
-		 u_int16_t datalen,
+		 unsigned int protoff,
 		 int *hotdrop)
 {
 	const struct ip6t_ipv6header_info *info = matchinfo;
@@ -52,7 +51,7 @@
 	temp = 0;
 
         while (ip6t_ext_hdr(nexthdr)) {
-        	struct ipv6_opt_hdr *hdr;
+		struct ipv6_opt_hdr _hdr, *hp;
         	int hdrlen;
 
 		/* Is there enough space for the next ext header? */
@@ -69,15 +68,16 @@
 			break;
 		}
 
-		hdr=(struct ipv6_opt_hdr *)skb->data+ptr;
+		hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+		BUG_ON(hp == NULL);
 
 		/* Calculate the header length */
                 if (nexthdr == NEXTHDR_FRAGMENT) {
                         hdrlen = 8;
                 } else if (nexthdr == NEXTHDR_AUTH)
-                        hdrlen = (hdr->hdrlen+2)<<2;
+                        hdrlen = (hp->hdrlen+2)<<2;
                 else
-                        hdrlen = ipv6_optlen(hdr);
+                        hdrlen = ipv6_optlen(hp);
 
 		/* set the flag */
 		switch (nexthdr){
@@ -101,7 +101,7 @@
 				break;
 		}
 
-                nexthdr = hdr->nexthdr;
+                nexthdr = hp->nexthdr;
                 len -= hdrlen;
                 ptr += hdrlen;
 		if (ptr > skb->len)
@@ -112,10 +112,14 @@
 		temp |= MASK_PROTO;
 
 	if (info->modeflag)
-		return (!( (temp & info->matchflags)
-			^ info->matchflags) ^ info->invflags);
-	else
-		return (!( temp ^ info->matchflags) ^ info->invflags);
+		return !((temp ^ info->matchflags ^ info->invflags)
+			 & info->matchflags);
+	else {
+		if (info->invflags)
+			return temp != info->matchflags;
+		else
+			return temp == info->matchflags;
+	}
 }
 
 static int
@@ -125,9 +129,16 @@
 		      unsigned int matchsize,
 		      unsigned int hook_mask)
 {
+	const struct ip6t_ipv6header_info *info = matchinfo;
+
 	/* Check for obvious errors */
 	/* This match is valid in all hooks! */
 	if (matchsize != IP6T_ALIGN(sizeof(struct ip6t_ipv6header_info)))
+		return 0;
+
+	/* invflags is 0 or 0xff in hard mode */
+	if ((!info->modeflag) && info->invflags != 0x00
+			      && info->invflags != 0xFF)
 		return 0;
 
 	return 1;
diff -Nru a/net/ipv6/netfilter/ip6t_length.c b/net/ipv6/netfilter/ip6t_length.c
--- a/net/ipv6/netfilter/ip6t_length.c	2004-12-24 13:37:29 -08:00
+++ b/net/ipv6/netfilter/ip6t_length.c	2004-12-24 13:37:29 -08:00
@@ -23,8 +23,7 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *hdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
 	const struct ip6t_length_info *info = matchinfo;
diff -Nru a/net/ipv6/netfilter/ip6t_limit.c b/net/ipv6/netfilter/ip6t_limit.c
--- a/net/ipv6/netfilter/ip6t_limit.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv6/netfilter/ip6t_limit.c	2004-12-24 13:36:31 -08:00
@@ -57,8 +57,7 @@
 		const struct net_device *out,
 		const void *matchinfo,
 		int offset,
-		const void *hdr,
-		u_int16_t datalen,
+		unsigned int protoff,
 		int *hotdrop)
 {
 	struct ip6t_rateinfo *r = ((struct ip6t_rateinfo *)matchinfo)->master;
diff -Nru a/net/ipv6/netfilter/ip6t_mac.c b/net/ipv6/netfilter/ip6t_mac.c
--- a/net/ipv6/netfilter/ip6t_mac.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv6/netfilter/ip6t_mac.c	2004-12-24 13:37:19 -08:00
@@ -25,8 +25,7 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *hdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
     const struct ip6t_mac_info *info = matchinfo;
diff -Nru a/net/ipv6/netfilter/ip6t_mark.c b/net/ipv6/netfilter/ip6t_mark.c
--- a/net/ipv6/netfilter/ip6t_mark.c	2004-12-24 13:37:43 -08:00
+++ b/net/ipv6/netfilter/ip6t_mark.c	2004-12-24 13:37:43 -08:00
@@ -24,8 +24,7 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *hdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
 	const struct ip6t_mark_info *info = matchinfo;
diff -Nru a/net/ipv6/netfilter/ip6t_multiport.c b/net/ipv6/netfilter/ip6t_multiport.c
--- a/net/ipv6/netfilter/ip6t_multiport.c	2004-12-24 13:37:31 -08:00
+++ b/net/ipv6/netfilter/ip6t_multiport.c	2004-12-24 13:37:31 -08:00
@@ -53,28 +53,32 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *hdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
-	const struct udphdr *udp = hdr;
+	u16 _ports[2], *pptr;
 	const struct ip6t_multiport *multiinfo = matchinfo;
 
-	/* Must be big enough to read ports. */
-	if (offset == 0 && datalen < sizeof(struct udphdr)) {
+	/* Must not be a fragment. */
+	if (offset)
+		return 0;
+
+	/* Must be big enough to read ports (both UDP and TCP have
+	   them at the start). */
+	pptr = skb_header_pointer(skb, protoff, sizeof(_ports), &_ports[0]);
+	if (pptr == NULL) {
 		/* We've been asked to examine this packet, and we
-		   can't.  Hence, no choice but to drop. */
-			duprintf("ip6t_multiport:"
-				 " Dropping evil offset=0 tinygram.\n");
-			*hotdrop = 1;
-			return 0;
+		 * can't.  Hence, no choice but to drop.
+		 */
+		duprintf("ip6t_multiport:"
+			 " Dropping evil offset=0 tinygram.\n");
+		*hotdrop = 1;
+		return 0;
 	}
 
-	/* Must not be a fragment. */
-	return !offset
-		&& ports_match(multiinfo->ports,
-			       multiinfo->flags, multiinfo->count,
-			       ntohs(udp->source), ntohs(udp->dest));
+	return ports_match(multiinfo->ports,
+			   multiinfo->flags, multiinfo->count,
+			   ntohs(pptr[0]), ntohs(pptr[1]));
 }
 
 /* Called when user tries to insert an entry of this type. */
@@ -87,9 +91,12 @@
 {
 	const struct ip6t_multiport *multiinfo = matchinfo;
 
+	if (matchsize != IP6T_ALIGN(sizeof(struct ip6t_multiport)))
+		return 0;
+
 	/* Must specify proto == TCP/UDP, no unknown flags or bad count */
 	return (ip->proto == IPPROTO_TCP || ip->proto == IPPROTO_UDP)
-		&& !(ip->flags & IP6T_INV_PROTO)
+		&& !(ip->invflags & IP6T_INV_PROTO)
 		&& matchsize == IP6T_ALIGN(sizeof(struct ip6t_multiport))
 		&& (multiinfo->flags == IP6T_MULTIPORT_SOURCE
 		    || multiinfo->flags == IP6T_MULTIPORT_DESTINATION
diff -Nru a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c
--- a/net/ipv6/netfilter/ip6t_owner.c	2004-12-24 13:37:44 -08:00
+++ b/net/ipv6/netfilter/ip6t_owner.c	2004-12-24 13:37:44 -08:00
@@ -92,8 +92,7 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *hdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
 	const struct ip6t_owner_info *info = matchinfo;
diff -Nru a/net/ipv6/netfilter/ip6t_physdev.c b/net/ipv6/netfilter/ip6t_physdev.c
--- a/net/ipv6/netfilter/ip6t_physdev.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv6/netfilter/ip6t_physdev.c	2004-12-24 13:37:18 -08:00
@@ -26,8 +26,7 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *hdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
 	int i;
diff -Nru a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c
--- a/net/ipv6/netfilter/ip6t_rt.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv6/netfilter/ip6t_rt.c	2004-12-24 13:36:31 -08:00
@@ -47,11 +47,10 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *protohdr,
-      u_int16_t datalen,
+      unsigned int protoff,
       int *hotdrop)
 {
-       struct ipv6_rt_hdr *route = NULL;
+       struct ipv6_rt_hdr _route, *rh = NULL;
        const struct ip6t_rt *rtinfo = matchinfo;
        unsigned int temp;
        unsigned int len;
@@ -59,6 +58,7 @@
        unsigned int ptr;
        unsigned int hdrlen = 0;
        unsigned int ret = 0;
+       struct in6_addr *ap, _addr;
 
        /* type of the 1st exthdr */
        nexthdr = skb->nh.ipv6h->nexthdr;
@@ -69,7 +69,7 @@
        temp = 0;
 
         while (ip6t_ext_hdr(nexthdr)) {
-               struct ipv6_opt_hdr *hdr;
+               struct ipv6_opt_hdr _hdr, *hp;
 
               DEBUGP("ipv6_rt header iteration \n");
 
@@ -85,15 +85,16 @@
                      break;
               }
 
-              hdr=(struct ipv6_opt_hdr *)skb->data+ptr;
+	      hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
+	      BUG_ON(hp == NULL);
 
               /* Calculate the header length */
                 if (nexthdr == NEXTHDR_FRAGMENT) {
                         hdrlen = 8;
                 } else if (nexthdr == NEXTHDR_AUTH)
-                        hdrlen = (hdr->hdrlen+2)<<2;
+                        hdrlen = (hp->hdrlen+2)<<2;
                 else
-                        hdrlen = ipv6_optlen(hdr);
+                        hdrlen = ipv6_optlen(hp);
 
               /* ROUTING -> evaluate */
                 if (nexthdr == NEXTHDR_ROUTING) {
@@ -116,7 +117,7 @@
                             break;
               }
 
-                nexthdr = hdr->nexthdr;
+                nexthdr = hp->nexthdr;
                 len -= hdrlen;
                 ptr += hdrlen;
 		if ( ptr > skb->len ) {
@@ -138,20 +139,21 @@
        		return 0;
        }
 
-       route = (struct ipv6_rt_hdr *) (skb->data + ptr);
+       rh = skb_header_pointer(skb, ptr, sizeof(_route), &_route);
+       BUG_ON(rh == NULL);
 
-       DEBUGP("IPv6 RT LEN %u %u ", hdrlen, route->hdrlen);
-       DEBUGP("TYPE %04X ", route->type);
-       DEBUGP("SGS_LEFT %u %08X\n", ntohl(route->segments_left), ntohl(route->segments_left));
+       DEBUGP("IPv6 RT LEN %u %u ", hdrlen, rh->hdrlen);
+       DEBUGP("TYPE %04X ", rh->type);
+       DEBUGP("SGS_LEFT %u %02X\n", rh->segments_left, rh->segments_left);
 
        DEBUGP("IPv6 RT segsleft %02X ",
        		(segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
-                           ntohl(route->segments_left),
+                           rh->segments_left,
                            !!(rtinfo->invflags & IP6T_RT_INV_SGS))));
        DEBUGP("type %02X %02X %02X ",
-       		rtinfo->rt_type, route->type, 
+       		rtinfo->rt_type, rh->type, 
        		(!(rtinfo->flags & IP6T_RT_TYP) ||
-                           ((rtinfo->rt_type == route->type) ^
+                           ((rtinfo->rt_type == rh->type) ^
                            !!(rtinfo->invflags & IP6T_RT_INV_TYP))));
        DEBUGP("len %02X %04X %02X ",
        		rtinfo->hdrlen, hdrlen,
@@ -159,13 +161,13 @@
                            ((rtinfo->hdrlen == hdrlen) ^
                            !!(rtinfo->invflags & IP6T_RT_INV_LEN))));
        DEBUGP("res %02X %02X %02X ", 
-       		(rtinfo->flags & IP6T_RT_RES), ((struct rt0_hdr *)route)->bitmap,
-       		!((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)route)->bitmap)));
+       		(rtinfo->flags & IP6T_RT_RES), ((struct rt0_hdr *)rh)->bitmap,
+       		!((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)rh)->bitmap)));
 
-       ret = (route != NULL)
+       ret = (rh != NULL)
        		&&
        		(segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
-                           ntohl(route->segments_left),
+                           rh->segments_left,
                            !!(rtinfo->invflags & IP6T_RT_INV_SGS)))
 		&&
 	      	(!(rtinfo->flags & IP6T_RT_LEN) ||
@@ -173,13 +175,19 @@
                            !!(rtinfo->invflags & IP6T_RT_INV_LEN)))
 		&&
        		(!(rtinfo->flags & IP6T_RT_TYP) ||
-                           ((rtinfo->rt_type == route->type) ^
-                           !!(rtinfo->invflags & IP6T_RT_INV_TYP)))
-		&&
-       		!((rtinfo->flags & IP6T_RT_RES) && (((struct rt0_hdr *)route)->bitmap));
+                           ((rtinfo->rt_type == rh->type) ^
+                           !!(rtinfo->invflags & IP6T_RT_INV_TYP)));
+
+	if (ret && (rtinfo->flags & IP6T_RT_RES)) {
+		u_int32_t *bp, _bitmap;
+		bp = skb_header_pointer(skb,
+					ptr + offsetof(struct rt0_hdr, bitmap),
+					sizeof(_bitmap), &_bitmap);
+
+		ret = (*bp == 0);
+	}
 
 	DEBUGP("#%d ",rtinfo->addrnr);
-       temp = len = ptr = 0;
        if ( !(rtinfo->flags & IP6T_RT_FST) ){
 	       return ret;
 	} else if (rtinfo->flags & IP6T_RT_FST_NSTRICT) {
@@ -188,32 +196,27 @@
 			DEBUGP("There isn't enough space\n");
 			return 0;
 		} else {
+			unsigned int i = 0;
+
 			DEBUGP("#%d ",rtinfo->addrnr);
-			ptr = 0;
 			for(temp=0; temp<(unsigned int)((hdrlen-8)/16); temp++){
-				len = 0;
-				while ((u8)(((struct rt0_hdr *)route)->
-						addr[temp].s6_addr[len]) ==
-					(u8)(rtinfo->addrs[ptr].s6_addr[len])){
-					DEBUGP("%02X?%02X ",
-		(u8)(((struct rt0_hdr *)route)->addr[temp].s6_addr[len]),
-					(u8)(rtinfo->addrs[ptr].s6_addr[len]));
-					len++;
-					if ( len == 16 ) break;
+				ap = skb_header_pointer(skb,
+							ptr
+							+ sizeof(struct rt0_hdr)
+							+ temp * sizeof(_addr),
+							sizeof(_addr),
+							&_addr);
+
+				BUG_ON(ap == NULL);
+
+				if (ipv6_addr_equal(ap, &rtinfo->addrs[i])) {
+					DEBUGP("i=%d temp=%d;\n",i,temp);
+					i++;
 				}
-				if (len==16) {
-					DEBUGP("ptr=%d temp=%d;\n",ptr,temp);
-					ptr++;
-				} else {
-					DEBUGP("%02X?%02X ",
-		(u8)(((struct rt0_hdr *)route)->addr[temp].s6_addr[len]),
-					(u8)(rtinfo->addrs[ptr].s6_addr[len]));
-					DEBUGP("!ptr=%d temp=%d;\n",ptr,temp);
-				}
-				if (ptr==rtinfo->addrnr) break;
+				if (i==rtinfo->addrnr) break;
 			}
-			DEBUGP("ptr=%d len=%d #%d\n",ptr,len, rtinfo->addrnr);
-			if ( (len == 16) && (ptr == rtinfo->addrnr))
+			DEBUGP("i=%d #%d\n", i, rtinfo->addrnr);
+			if (i == rtinfo->addrnr)
 				return ret;
 			else return 0;
 		}
@@ -225,26 +228,19 @@
 		} else {
 			DEBUGP("#%d ",rtinfo->addrnr);
 			for(temp=0; temp<rtinfo->addrnr; temp++){
-				len = 0;
-				while ((u8)(((struct rt0_hdr *)route)->
-						addr[temp].s6_addr[len]) ==
-					(u8)(rtinfo->addrs[temp].s6_addr[len])){
-					DEBUGP("%02X?%02X ",
-		(u8)(((struct rt0_hdr *)route)->addr[temp].s6_addr[len]),
-					(u8)(rtinfo->addrs[temp].s6_addr[len]));
-					len++;
-					if ( len == 16 ) break;
-				}
-				if (len!=16) {
-					DEBUGP("%02X?%02X ",
-		(u8)(((struct rt0_hdr *)route)->addr[temp].s6_addr[len]),
-					(u8)(rtinfo->addrs[temp].s6_addr[len]));
-					DEBUGP("!len=%d temp=%d;\n",len,temp);
+				ap = skb_header_pointer(skb,
+							ptr
+							+ sizeof(struct rt0_hdr)
+							+ temp * sizeof(_addr),
+							sizeof(_addr),
+							&_addr);
+				BUG_ON(ap == NULL);
+
+				if (!ipv6_addr_equal(ap, &rtinfo->addrs[temp]))
 					break;
-				}
 			}
-			DEBUGP("temp=%d len=%d #%d\n",temp,len,rtinfo->addrnr);
-			if ( (len == 16) && (temp == rtinfo->addrnr) && (temp == (unsigned int)((hdrlen-8)/16)))
+			DEBUGP("temp=%d #%d\n", temp, rtinfo->addrnr);
+			if ((temp == rtinfo->addrnr) && (temp == (unsigned int)((hdrlen-8)/16)))
 				return ret;
 			else return 0;
 		}
diff -Nru a/net/ipv6/raw.c b/net/ipv6/raw.c
--- a/net/ipv6/raw.c	2004-12-24 13:36:47 -08:00
+++ b/net/ipv6/raw.c	2004-12-24 13:36:47 -08:00
@@ -90,11 +90,11 @@
 			struct ipv6_pinfo *np = inet6_sk(sk);
 
 			if (!ipv6_addr_any(&np->daddr) &&
-			    ipv6_addr_cmp(&np->daddr, rmt_addr))
+			    !ipv6_addr_equal(&np->daddr, rmt_addr))
 				continue;
 
 			if (!ipv6_addr_any(&np->rcv_saddr)) {
-				if (!ipv6_addr_cmp(&np->rcv_saddr, loc_addr))
+				if (ipv6_addr_equal(&np->rcv_saddr, loc_addr))
 					goto found;
 				if (is_multicast &&
 				    inet6_mc_check(sk, loc_addr, rmt_addr))
@@ -639,7 +639,7 @@
 			return -EINVAL;
 
 		if (sin6->sin6_family && sin6->sin6_family != AF_INET6) 
-			return(-EINVAL);
+			return(-EAFNOSUPPORT);
 
 		/* port is the proto value [0..255] carried in nexthdr */
 		proto = ntohs(sin6->sin6_port);
@@ -668,7 +668,7 @@
 		 * sk->sk_dst_cache.
 		 */
 		if (sk->sk_state == TCP_ESTABLISHED &&
-		    !ipv6_addr_cmp(daddr, &np->daddr))
+		    ipv6_addr_equal(daddr, &np->daddr))
 			daddr = &np->daddr;
 
 		if (addr_len >= sizeof(struct sockaddr_in6) &&
@@ -775,7 +775,7 @@
 	}
 done:
 	ip6_dst_store(sk, dst,
-		      !ipv6_addr_cmp(&fl.fl6_dst, &np->daddr) ?
+		      ipv6_addr_equal(&fl.fl6_dst, &np->daddr) ?
 		      &np->daddr : NULL);
 	if (err > 0)
 		err = np->recverr ? net_xmit_errno(err) : 0;
@@ -975,6 +975,7 @@
 
 struct proto rawv6_prot = {
 	.name =		"RAW",
+	.owner =	THIS_MODULE,
 	.close =	rawv6_close,
 	.connect =	ip6_datagram_connect,
 	.disconnect =	udp_disconnect,
diff -Nru a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
--- a/net/ipv6/reassembly.c	2004-12-24 13:36:33 -08:00
+++ b/net/ipv6/reassembly.c	2004-12-24 13:36:33 -08:00
@@ -342,8 +342,8 @@
 #ifdef CONFIG_SMP
 	for (fq = ip6_frag_hash[hash]; fq; fq = fq->next) {
 		if (fq->id == fq_in->id && 
-		    !ipv6_addr_cmp(&fq_in->saddr, &fq->saddr) &&
-		    !ipv6_addr_cmp(&fq_in->daddr, &fq->daddr)) {
+		    ipv6_addr_equal(&fq_in->saddr, &fq->saddr) &&
+		    ipv6_addr_equal(&fq_in->daddr, &fq->daddr)) {
 			atomic_inc(&fq->refcnt);
 			write_unlock(&ip6_frag_lock);
 			fq_in->last_in |= COMPLETE;
@@ -387,7 +387,7 @@
 	init_timer(&fq->timer);
 	fq->timer.function = ip6_frag_expire;
 	fq->timer.data = (long) fq;
-	fq->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&fq->lock);
 	atomic_set(&fq->refcnt, 1);
 
 	return ip6_frag_intern(hash, fq);
@@ -406,8 +406,8 @@
 	read_lock(&ip6_frag_lock);
 	for(fq = ip6_frag_hash[hash]; fq; fq = fq->next) {
 		if (fq->id == id && 
-		    !ipv6_addr_cmp(src, &fq->saddr) &&
-		    !ipv6_addr_cmp(dst, &fq->daddr)) {
+		    ipv6_addr_equal(src, &fq->saddr) &&
+		    ipv6_addr_equal(dst, &fq->daddr)) {
 			atomic_inc(&fq->refcnt);
 			read_unlock(&ip6_frag_lock);
 			return fq;
diff -Nru a/net/ipv6/route.c b/net/ipv6/route.c
--- a/net/ipv6/route.c	2004-12-24 13:37:04 -08:00
+++ b/net/ipv6/route.c	2004-12-24 13:37:04 -08:00
@@ -88,7 +88,7 @@
 static int		 ip6_dst_gc(void);
 
 static int		ip6_pkt_discard(struct sk_buff *skb);
-static int		ip6_pkt_discard_out(struct sk_buff **pskb);
+static int		ip6_pkt_discard_out(struct sk_buff *skb);
 static void		ip6_link_failure(struct sk_buff *skb);
 static void		ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu);
 
@@ -476,13 +476,19 @@
 	BACKTRACK();
 
 	if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) {
+		struct rt6_info *nrt;
+		dst_hold(&rt->u.dst);
 		read_unlock_bh(&rt6_lock);
 
-		rt = rt6_cow(rt, &skb->nh.ipv6h->daddr,
-			     &skb->nh.ipv6h->saddr);
-			
+		nrt = rt6_cow(rt, &skb->nh.ipv6h->daddr,
+			      &skb->nh.ipv6h->saddr);
+
+		dst_release(&rt->u.dst);
+		rt = nrt;
+
 		if (rt->u.dst.error != -EEXIST || --attempts <= 0)
 			goto out2;
+
 		/* Race condition! In the gap, when rt6_lock was
 		   released someone could insert this route.  Relookup.
 		*/
@@ -531,9 +537,14 @@
 	}
 
 	if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) {
+		struct rt6_info *nrt;
+		dst_hold(&rt->u.dst);
 		read_unlock_bh(&rt6_lock);
 
-		rt = rt6_cow(rt, &fl->fl6_dst, &fl->fl6_src);
+		nrt = rt6_cow(rt, &fl->fl6_dst, &fl->fl6_src);
+
+		dst_release(&rt->u.dst);
+		rt = nrt;
 
 		if (rt->u.dst.error != -EEXIST || --attempts <= 0)
 			goto out2;
@@ -638,7 +649,7 @@
 struct dst_entry *ndisc_dst_alloc(struct net_device *dev, 
 				  struct neighbour *neigh,
 				  struct in6_addr *addr,
-				  int (*output)(struct sk_buff **))
+				  int (*output)(struct sk_buff *))
 {
 	struct rt6_info *rt;
 	struct inet6_dev *idev = in6_dev_get(dev);
@@ -647,8 +658,10 @@
 		return NULL;
 
 	rt = ip6_dst_alloc();
-	if (unlikely(rt == NULL))
+	if (unlikely(rt == NULL)) {
+		in6_dev_put(idev);
 		goto out;
+	}
 
 	dev_hold(dev);
 	if (neigh)
@@ -796,8 +809,10 @@
 
 	rt = ip6_dst_alloc();
 
-	if (rt == NULL)
-		return -ENOMEM;
+	if (rt == NULL) {
+		err = -ENOMEM;
+		goto out;
+	}
 
 	rt->u.dst.obsolete = -1;
 	rt->rt6i_expires = clock_t_to_jiffies(rtmsg->rtmsg_info);
@@ -960,7 +975,10 @@
 out:
 	if (dev)
 		dev_put(dev);
-	dst_free((struct dst_entry *) rt);
+	if (idev)
+		in6_dev_put(idev);
+	if (rt)
+		dst_free((struct dst_entry *) rt);
 	return err;
 }
 
@@ -972,9 +990,9 @@
 
 	rt6_reset_dflt_pointer(NULL);
 
+	err = fib6_del(rt, nlh, _rtattr);
 	dst_release(&rt->u.dst);
 
-	err = fib6_del(rt, nlh, _rtattr);
 	write_unlock_bh(&rt6_lock);
 
 	return err;
@@ -999,7 +1017,7 @@
 			     rt->rt6i_dev->ifindex != rtmsg->rtmsg_ifindex))
 				continue;
 			if (rtmsg->rtmsg_flags&RTF_GATEWAY &&
-			    ipv6_addr_cmp(&rtmsg->rtmsg_gateway, &rt->rt6i_gateway))
+			    !ipv6_addr_equal(&rtmsg->rtmsg_gateway, &rt->rt6i_gateway))
 				continue;
 			if (rtmsg->rtmsg_metric &&
 			    rtmsg->rtmsg_metric != rt->rt6i_metric)
@@ -1050,13 +1068,13 @@
 	 *	is a bit fuzzy and one might need to check all default
 	 *	routers.
 	 */
-	if (ipv6_addr_cmp(saddr, &rt->rt6i_gateway)) {
+	if (!ipv6_addr_equal(saddr, &rt->rt6i_gateway)) {
 		if (rt->rt6i_flags & RTF_DEFAULT) {
 			struct rt6_info *rt1;
 
 			read_lock(&rt6_lock);
 			for (rt1 = ip6_routing_table.leaf; rt1; rt1 = rt1->u.next) {
-				if (!ipv6_addr_cmp(saddr, &rt1->rt6i_gateway)) {
+				if (ipv6_addr_equal(saddr, &rt1->rt6i_gateway)) {
 					dst_hold(&rt1->u.dst);
 					dst_release(&rt->u.dst);
 					read_unlock(&rt6_lock);
@@ -1255,7 +1273,7 @@
 	write_lock_bh(&rt6_lock);
 	for (rt = fn->leaf; rt; rt=rt->u.next) {
 		if (dev == rt->rt6i_dev &&
-		    ipv6_addr_cmp(&rt->rt6i_gateway, addr) == 0)
+		    ipv6_addr_equal(&rt->rt6i_gateway, addr))
 			break;
 	}
 	if (rt)
@@ -1281,20 +1299,14 @@
 	return rt6_get_dflt_router(gwaddr, dev);
 }
 
-void rt6_purge_dflt_routers(int last_resort)
+void rt6_purge_dflt_routers(void)
 {
 	struct rt6_info *rt;
-	u32 flags;
-
-	if (last_resort)
-		flags = RTF_ALLONLINK;
-	else
-		flags = RTF_DEFAULT | RTF_ADDRCONF;	
 
 restart:
 	read_lock_bh(&rt6_lock);
 	for (rt = ip6_routing_table.leaf; rt; rt = rt->u.next) {
-		if (rt->rt6i_flags & flags) {
+		if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) {
 			dst_hold(&rt->u.dst);
 
 			rt6_reset_dflt_pointer(NULL);
@@ -1355,11 +1367,10 @@
 	return 0;
 }
 
-int ip6_pkt_discard_out(struct sk_buff **pskb)
+int ip6_pkt_discard_out(struct sk_buff *skb)
 {
-	(*pskb)->dev = (*pskb)->dst->dev;
-	BUG_ON(!(*pskb)->dev);
-	return ip6_pkt_discard(*pskb);
+	skb->dev = skb->dst->dev;
+	return ip6_pkt_discard(skb);
 }
 
 /*
@@ -1585,7 +1596,7 @@
 	rtm->rtm_protocol = rt->rt6i_protocol;
 	if (rt->rt6i_flags&RTF_DYNAMIC)
 		rtm->rtm_protocol = RTPROT_REDIRECT;
-	else if (rt->rt6i_flags&(RTF_ADDRCONF|RTF_ALLONLINK))
+	else if (rt->rt6i_flags & RTF_ADDRCONF)
 		rtm->rtm_protocol = RTPROT_KERNEL;
 	else if (rt->rt6i_flags&RTF_DEFAULT)
 		rtm->rtm_protocol = RTPROT_RA;
diff -Nru a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
--- a/net/ipv6/tcp_ipv6.c	2004-12-24 13:36:56 -08:00
+++ b/net/ipv6/tcp_ipv6.c	2004-12-24 13:36:56 -08:00
@@ -262,7 +262,7 @@
 			
 			score = 1;
 			if (!ipv6_addr_any(&np->rcv_saddr)) {
-				if (ipv6_addr_cmp(&np->rcv_saddr, daddr))
+				if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
 					continue;
 				score++;
 			}
@@ -321,8 +321,8 @@
 
 		if(*((__u32 *)&(tw->tw_dport))	== ports	&&
 		   sk->sk_family		== PF_INET6) {
-			if(!ipv6_addr_cmp(&tw->tw_v6_daddr, saddr)	&&
-			   !ipv6_addr_cmp(&tw->tw_v6_rcv_saddr, daddr)	&&
+			if(ipv6_addr_equal(&tw->tw_v6_daddr, saddr)	&&
+			   ipv6_addr_equal(&tw->tw_v6_rcv_saddr, daddr)	&&
 			   (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif))
 				goto hit;
 		}
@@ -364,6 +364,8 @@
 	return sk;
 }
 
+EXPORT_SYMBOL_GPL(tcp_v6_lookup);
+
 
 /*
  * Open request hash tables.
@@ -404,8 +406,8 @@
 	     prev = &req->dl_next) {
 		if (req->rmt_port == rport &&
 		    req->class->family == AF_INET6 &&
-		    !ipv6_addr_cmp(&req->af.v6_req.rmt_addr, raddr) &&
-		    !ipv6_addr_cmp(&req->af.v6_req.loc_addr, laddr) &&
+		    ipv6_addr_equal(&req->af.v6_req.rmt_addr, raddr) &&
+		    ipv6_addr_equal(&req->af.v6_req.loc_addr, laddr) &&
 		    (!req->af.v6_req.iif || req->af.v6_req.iif == iif)) {
 			BUG_TRAP(req->sk == NULL);
 			*prevp = prev;
@@ -461,8 +463,8 @@
 
 		if(*((__u32 *)&(tw->tw_dport))	== ports	&&
 		   sk2->sk_family		== PF_INET6	&&
-		   !ipv6_addr_cmp(&tw->tw_v6_daddr, saddr)	&&
-		   !ipv6_addr_cmp(&tw->tw_v6_rcv_saddr, daddr)	&&
+		   ipv6_addr_equal(&tw->tw_v6_daddr, saddr)	&&
+		   ipv6_addr_equal(&tw->tw_v6_rcv_saddr, daddr)	&&
 		   sk2->sk_bound_dev_if == sk->sk_bound_dev_if) {
 			struct tcp_opt *tp = tcp_sk(sk);
 
@@ -608,7 +610,7 @@
 	}
 
 	if (tp->ts_recent_stamp &&
-	    ipv6_addr_cmp(&np->daddr, &usin->sin6_addr)) {
+	    !ipv6_addr_equal(&np->daddr, &usin->sin6_addr)) {
 		tp->ts_recent = 0;
 		tp->ts_recent_stamp = 0;
 		tp->write_seq = 0;
@@ -1802,6 +1804,7 @@
 	struct ipv6_pinfo *np = inet6_sk(sk);
 	struct flowi fl;
 	struct dst_entry *dst;
+	struct in6_addr *final_p = NULL, final;
 
 	memset(&fl, 0, sizeof(fl));
 	fl.proto = IPPROTO_TCP;
@@ -1815,7 +1818,9 @@
 
 	if (np->opt && np->opt->srcrt) {
 		struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
+		ipv6_addr_copy(&final, &fl.fl6_dst);
 		ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
+		final_p = &final;
 	}
 
 	dst = __sk_dst_check(sk, np->dst_cookie);
@@ -1828,6 +1833,9 @@
 			return err;
 		}
 
+		if (final_p)
+			ipv6_addr_copy(&fl.fl6_dst, final_p);
+
 		if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) {
 			sk->sk_route_caps = 0;
 			dst_release(dst);
@@ -2124,6 +2132,7 @@
 
 struct proto tcpv6_prot = {
 	.name			= "TCPv6",
+	.owner			= THIS_MODULE,
 	.close			= tcp_close,
 	.connect		= tcp_v6_connect,
 	.disconnect		= tcp_disconnect,
diff -Nru a/net/ipv6/udp.c b/net/ipv6/udp.c
--- a/net/ipv6/udp.c	2004-12-24 13:37:18 -08:00
+++ b/net/ipv6/udp.c	2004-12-24 13:37:18 -08:00
@@ -171,12 +171,12 @@
 				score++;
 			}
 			if (!ipv6_addr_any(&np->rcv_saddr)) {
-				if (ipv6_addr_cmp(&np->rcv_saddr, daddr))
+				if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
 					continue;
 				score++;
 			}
 			if (!ipv6_addr_any(&np->daddr)) {
-				if (ipv6_addr_cmp(&np->daddr, saddr))
+				if (!ipv6_addr_equal(&np->daddr, saddr))
 					continue;
 				score++;
 			}
@@ -395,14 +395,14 @@
 					continue;
 			}
 			if (!ipv6_addr_any(&np->daddr) &&
-			    ipv6_addr_cmp(&np->daddr, rmt_addr))
+			    !ipv6_addr_equal(&np->daddr, rmt_addr))
 				continue;
 
 			if (s->sk_bound_dev_if && s->sk_bound_dev_if != dif)
 				continue;
 
 			if (!ipv6_addr_any(&np->rcv_saddr)) {
-				if (!ipv6_addr_cmp(&np->rcv_saddr, loc_addr))
+				if (ipv6_addr_equal(&np->rcv_saddr, loc_addr))
 					return s;
 				continue;
 			}
@@ -699,7 +699,7 @@
 		if (likely(up->pending)) {
 			if (unlikely(up->pending != AF_INET6)) {
 				release_sock(sk);
-				return -EINVAL;
+				return -EAFNOSUPPORT;
 			}
 			dst = NULL;
 			goto do_append_data;
@@ -732,7 +732,7 @@
 		 * sk->sk_dst_cache.
 		 */
 		if (sk->sk_state == TCP_ESTABLISHED &&
-		    !ipv6_addr_cmp(daddr, &np->daddr))
+		    ipv6_addr_equal(daddr, &np->daddr))
 			daddr = &np->daddr;
 
 		if (addr_len >= sizeof(struct sockaddr_in6) &&
@@ -840,7 +840,7 @@
 
 	if (dst)
 		ip6_dst_store(sk, dst,
-			      !ipv6_addr_cmp(&fl->fl6_dst, &np->daddr) ?
+			      ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ?
 			      &np->daddr : NULL);
 	if (err > 0)
 		err = np->recverr ? net_xmit_errno(err) : 0;
@@ -1033,6 +1033,7 @@
 
 struct proto udpv6_prot = {
 	.name =		"UDP",
+	.owner =	THIS_MODULE,
 	.close =	udpv6_close,
 	.connect =	ip6_datagram_connect,
 	.disconnect =	udp_disconnect,
diff -Nru a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
--- a/net/ipv6/xfrm6_output.c	2004-12-24 13:37:19 -08:00
+++ b/net/ipv6/xfrm6_output.c	2004-12-24 13:37:19 -08:00
@@ -79,7 +79,7 @@
 	int mtu, ret = 0;
 	struct dst_entry *dst = skb->dst;
 
-	mtu = dst_pmtu(dst) - sizeof(struct ipv6hdr);
+	mtu = dst_pmtu(dst) - dst->header_len - dst->trailer_len;
 	if (mtu < IPV6_MIN_MTU)
 		mtu = IPV6_MIN_MTU;
 
@@ -91,16 +91,14 @@
 	return ret;
 }
 
-int xfrm6_output(struct sk_buff **pskb)
+int xfrm6_output(struct sk_buff *skb)
 {
-	struct sk_buff *skb = *pskb;
 	struct dst_entry *dst = skb->dst;
 	struct xfrm_state *x = dst->xfrm;
 	int err;
 	
 	if (skb->ip_summed == CHECKSUM_HW) {
-		err = skb_checksum_help(pskb, 0);
-		skb = *pskb;
+		err = skb_checksum_help(skb, 0);
 		if (err)
 			goto error_nolock;
 	}
diff -Nru a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
--- a/net/ipv6/xfrm6_policy.c	2004-12-24 13:36:31 -08:00
+++ b/net/ipv6/xfrm6_policy.c	2004-12-24 13:36:31 -08:00
@@ -68,8 +68,8 @@
 		ipv6_addr_prefix(&fl_src_prefix,
 				 &fl->fl6_src,
 				 xdst->u.rt6.rt6i_src.plen);
-		if (!ipv6_addr_cmp(&xdst->u.rt6.rt6i_dst.addr, &fl_dst_prefix) &&
-		    !ipv6_addr_cmp(&xdst->u.rt6.rt6i_src.addr, &fl_src_prefix) &&
+		if (ipv6_addr_equal(&xdst->u.rt6.rt6i_dst.addr, &fl_dst_prefix) &&
+		    ipv6_addr_equal(&xdst->u.rt6.rt6i_src.addr, &fl_src_prefix) &&
 		    __xfrm6_bundle_ok(xdst, fl)) {
 			dst_clone(dst);
 			break;
@@ -123,7 +123,7 @@
 		trailer_len += xfrm[i]->props.trailer_len;
 	}
 
-	if (ipv6_addr_cmp(remote, &fl->fl6_dst)) {
+	if (!ipv6_addr_equal(remote, &fl->fl6_dst)) {
 		struct flowi fl_tunnel;
 
 		memset(&fl_tunnel, 0, sizeof(fl_tunnel));
diff -Nru a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c
--- a/net/ipv6/xfrm6_state.c	2004-12-24 13:36:48 -08:00
+++ b/net/ipv6/xfrm6_state.c	2004-12-24 13:36:48 -08:00
@@ -55,7 +55,7 @@
 	list_for_each_entry(x, xfrm6_state_afinfo.state_byspi+h, byspi) {
 		if (x->props.family == AF_INET6 &&
 		    spi == x->id.spi &&
-		    !ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)x->id.daddr.a6) &&
+		    ipv6_addr_equal((struct in6_addr *)daddr, (struct in6_addr *)x->id.daddr.a6) &&
 		    proto == x->id.proto) {
 			xfrm_state_hold(x);
 			return x;
@@ -76,10 +76,10 @@
 
 	list_for_each_entry(x, xfrm6_state_afinfo.state_bydst+h, bydst) {
 		if (x->props.family == AF_INET6 &&
-		    !ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)x->id.daddr.a6) &&
+		    ipv6_addr_equal((struct in6_addr *)daddr, (struct in6_addr *)x->id.daddr.a6) &&
 		    mode == x->props.mode &&
 		    proto == x->id.proto &&
-		    !ipv6_addr_cmp((struct in6_addr *)saddr, (struct in6_addr *)x->props.saddr.a6) &&
+		    ipv6_addr_equal((struct in6_addr *)saddr, (struct in6_addr *)x->props.saddr.a6) &&
 		    reqid == x->props.reqid &&
 		    x->km.state == XFRM_STATE_ACQ &&
 		    !x->id.spi) {
diff -Nru a/net/irda/af_irda.c b/net/irda/af_irda.c
--- a/net/irda/af_irda.c	2004-12-24 13:36:34 -08:00
+++ b/net/irda/af_irda.c	2004-12-24 13:36:34 -08:00
@@ -2005,7 +2005,7 @@
 		}
 
 		/* Remove the attribute (and maybe the object) */
-		irias_delete_attrib(ias_obj, ias_attr);
+		irias_delete_attrib(ias_obj, ias_attr, 1);
 		kfree(ias_opt);
 		break;
 	case IRLMP_MAX_SDU_SIZE:
diff -Nru a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
--- a/net/irda/ircomm/ircomm_tty.c	2004-12-24 13:36:34 -08:00
+++ b/net/irda/ircomm/ircomm_tty.c	2004-12-24 13:36:34 -08:00
@@ -52,7 +52,7 @@
 
 static int  ircomm_tty_open(struct tty_struct *tty, struct file *filp);
 static void ircomm_tty_close(struct tty_struct * tty, struct file *filp);
-static int  ircomm_tty_write(struct tty_struct * tty, int from_user,
+static int  ircomm_tty_write(struct tty_struct * tty,
 			     const unsigned char *buf, int count);
 static int  ircomm_tty_write_room(struct tty_struct *tty);
 static void ircomm_tty_throttle(struct tty_struct *tty);
@@ -662,14 +662,14 @@
 }
 
 /*
- * Function ircomm_tty_write (tty, from_user, buf, count)
+ * Function ircomm_tty_write (tty, buf, count)
  *
  *    This routine is called by the kernel to write a series of characters
  *    to the tty device. The characters may come from user space or kernel
  *    space. This routine will return the number of characters actually
  *    accepted for writing. This routine is mandatory.
  */
-static int ircomm_tty_write(struct tty_struct *tty, int from_user,
+static int ircomm_tty_write(struct tty_struct *tty,
 			    const unsigned char *ubuf, int count)
 {
 	struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
@@ -713,21 +713,8 @@
 	if (count < 1)
 		return 0;
 
-	/* Additional copy to avoid copy_from_user() under spinlock.
-	 * We tradeoff this extra copy to allow to pack more the
-	 * IrCOMM frames. This is advantageous because the IrDA link
-	 * is the bottleneck. */
-	if (from_user) {
-		kbuf = kmalloc(count, GFP_KERNEL);
-		if (kbuf == NULL)
-			return -ENOMEM;
-		if (copy_from_user(kbuf, ubuf, count)) {
-			kfree(kbuf);
-			return -EFAULT;
-		}
-	} else
-		/* The buffer is already in kernel space */
-		kbuf = (unsigned char *) ubuf;
+	/* The buffer is already in kernel space */
+	kbuf = (unsigned char *) ubuf;
 
 	/* Protect our manipulation of self->tx_skb and related */
 	spin_lock_irqsave(&self->spinlock, flags);
@@ -781,8 +768,6 @@
 					    self->max_header_size);
 			if (!skb) {
 				spin_unlock_irqrestore(&self->spinlock, flags);
-	                        if (from_user)
-		                        kfree(kbuf);
 				return -ENOBUFS;
 			}
 			skb_reserve(skb, self->max_header_size);
@@ -800,9 +785,6 @@
 	}
 
 	spin_unlock_irqrestore(&self->spinlock, flags);
-
-	if (from_user)
-		kfree(kbuf);
 
 	/*     
 	 * Schedule a new thread which will transmit the frame as soon
diff -Nru a/net/irda/ircomm/ircomm_tty_attach.c b/net/irda/ircomm/ircomm_tty_attach.c
--- a/net/irda/ircomm/ircomm_tty_attach.c	2004-12-24 13:37:19 -08:00
+++ b/net/irda/ircomm/ircomm_tty_attach.c	2004-12-24 13:37:19 -08:00
@@ -143,12 +143,6 @@
 
 	ircomm_tty_ias_register(self);
 
-	/* Check if somebody has already connected to us */
-	if (ircomm_is_connected(self->ircomm)) {
-		IRDA_DEBUG(0, "%s(), already connected!\n", __FUNCTION__ );
-		return 0;
-	}
-
 	ircomm_tty_do_event(self, IRCOMM_TTY_ATTACH_CABLE, NULL, NULL);
 
 	return 0;
@@ -169,9 +163,16 @@
 
 	del_timer(&self->watchdog_timer);
 
+	/* Remove discovery handler */
+	if (self->ckey) {
+		irlmp_unregister_client(self->ckey);
+		self->ckey = NULL;
+	}
 	/* Remove IrCOMM hint bits */
-	irlmp_unregister_client(self->ckey);
-	irlmp_unregister_service(self->skey);
+	if (self->skey) {
+		irlmp_unregister_service(self->skey);
+		self->skey = NULL;
+	}
 
 	if (self->iriap) { 
 		iriap_close(self->iriap);
@@ -209,18 +210,30 @@
 	ASSERT(self != NULL, return;);
 	ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 	
+	/* Compute hint bits based on service */
+	hints = irlmp_service_to_hint(S_COMM);
+	if (self->service_type & IRCOMM_3_WIRE_RAW)
+		hints |= irlmp_service_to_hint(S_PRINTER);
+
+	/* Advertise IrCOMM hint bit in discovery */
+	if (!self->skey)
+		self->skey = irlmp_register_service(hints);
+	/* Set up a discovery handler */
+	if (!self->ckey)
+		self->ckey = irlmp_register_client(hints,
+						   ircomm_tty_discovery_indication,
+						   NULL, (void *) self);
+
+	/* If already done, no need to do it again */
+	if (self->obj)
+		return;
+
 	if (self->service_type & IRCOMM_3_WIRE_RAW) {
-		hints = irlmp_service_to_hint(S_PRINTER);
-		hints |= irlmp_service_to_hint(S_COMM);
-		
 		/* Register IrLPT with LM-IAS */
 		self->obj = irias_new_object("IrLPT", IAS_IRLPT_ID);
 		irias_add_integer_attrib(self->obj, "IrDA:IrLMP:LsapSel", 
 					 self->slsap_sel, IAS_KERNEL_ATTR);
-		irias_insert_object(self->obj);
 	} else {
-		hints = irlmp_service_to_hint(S_COMM);
-
 		/* Register IrCOMM with LM-IAS */
 		self->obj = irias_new_object("IrDA:IrCOMM", IAS_IRCOMM_ID);
 		irias_add_integer_attrib(self->obj, "IrDA:TinyTP:LsapSel", 
@@ -234,12 +247,45 @@
 		/* Register parameters with LM-IAS */
 		irias_add_octseq_attrib(self->obj, "Parameters", oct_seq, 6,
 					IAS_KERNEL_ATTR);
-		irias_insert_object(self->obj);
 	}
-	self->skey = irlmp_register_service(hints);
-	self->ckey = irlmp_register_client(hints,
-					   ircomm_tty_discovery_indication,
-					   NULL, (void *) self);
+	irias_insert_object(self->obj);
+}
+
+/*
+ * Function ircomm_tty_ias_unregister (self)
+ *
+ *    Remove our IAS object and client hook while connected.
+ *
+ */
+static void ircomm_tty_ias_unregister(struct ircomm_tty_cb *self)
+{
+	/* Remove LM-IAS object now so it is not reused.
+	 * IrCOMM deals very poorly with multiple incoming connections.
+	 * It should looks a lot more like IrNET, and "dup" a server TSAP
+	 * to the application TSAP (based on various rules).
+	 * This is a cheap workaround allowing multiple clients to
+	 * connect to us. It will not always work.
+	 * Each IrCOMM socket has an IAS entry. Incoming connection will
+	 * pick the first one found. So, when we are fully connected,
+	 * we remove our IAS entries so that the next IAS entry is used.
+	 * We do that for *both* client and server, because a server
+	 * can also create client instances.
+	 * Jean II */
+	if (self->obj) {
+		irias_delete_object(self->obj);
+		self->obj = NULL;
+	}
+
+#if 0
+	/* Remove discovery handler.
+	 * While we are connected, we no longer need to receive
+	 * discovery events. This would be the case if there is
+	 * multiple IrLAP interfaces. Jean II */
+	if (self->ckey) {
+		irlmp_unregister_client(self->ckey);
+		self->ckey = NULL;
+	}
+#endif
 }
 
 /*
@@ -333,7 +379,8 @@
 	info.daddr = discovery->daddr;
 	info.saddr = discovery->saddr;
 
-	/* FIXME. We probably need to use hashbin_find_next(), but we first
+	/* FIXME. We have a locking problem on the hashbin here.
+	 * We probably need to use hashbin_find_next(), but we first
 	 * need to ensure that "line" is unique. - Jean II */
 	self = (struct ircomm_tty_cb *) hashbin_get_first(ircomm_tty);
 	while (self != NULL) {
@@ -519,23 +566,6 @@
 	
 	del_timer(&self->watchdog_timer);
 
-	/* Remove LM-IAS object now so it is not reused.
-	 * IrCOMM deals very poorly with multiple incoming connections.
-	 * It should looks a lot more like IrNET, and "dup" a server TSAP
-	 * to the application TSAP (based on various rules).
-	 * This is a cheap workaround allowing multiple clients to
-	 * connect to us. It will not always work.
-	 * Each IrCOMM socket has an IAS entry. Incoming connection will
-	 * pick the first one found. So, when we are fully connected,
-	 * we remove our IAS entries so that the next IAS entry is used.
-	 * We do that for *both* client and server, because a server
-	 * can also create client instances.
-	 * Jean II */
-	if (self->obj) {
-		irias_delete_object(self->obj);
-		self->obj = NULL;
-	}
-
 	/* 
 	 * IrCOMM link is now up, and if we are not using hardware
 	 * flow-control, then declare the hardware as running. Otherwise we
@@ -558,7 +588,7 @@
 }
 
 /*
- * Function irlan_start_watchdog_timer (self, timeout)
+ * Function ircomm_tty_start_watchdog_timer (self, timeout)
  *
  *    Start the watchdog timer. This timer is used to make sure that any 
  *    connection attempt is successful, and if not, we will retry after 
@@ -591,6 +621,43 @@
 	ircomm_tty_do_event(self, IRCOMM_TTY_WD_TIMER_EXPIRED, NULL, NULL);
 }
 
+
+/*
+ * Function ircomm_tty_do_event (self, event, skb)
+ *
+ *    Process event
+ *
+ */
+int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
+			struct sk_buff *skb, struct ircomm_tty_info *info) 
+{
+	ASSERT(self != NULL, return -1;);
+	ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
+
+	IRDA_DEBUG(2, "%s: state=%s, event=%s\n", __FUNCTION__ ,
+		   ircomm_tty_state[self->state], ircomm_tty_event[event]);
+	
+	return (*state[self->state])(self, event, skb, info);
+}
+
+/*
+ * Function ircomm_tty_next_state (self, state)
+ *
+ *    Switch state
+ *
+ */
+static inline void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_STATE state)
+{
+	/*
+	ASSERT(self != NULL, return;);
+	ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+
+	IRDA_DEBUG(2, "%s: next state=%s, service type=%d\n", __FUNCTION__ , 
+		   ircomm_tty_state[self->state], self->service_type);
+	*/
+	self->state = state;
+}
+
 /*
  * Function ircomm_tty_state_idle (self, event, skb, info)
  *
@@ -700,6 +767,7 @@
 		break;
 	case IRCOMM_TTY_CONNECT_INDICATION:
 		del_timer(&self->watchdog_timer);
+		ircomm_tty_ias_unregister(self);
 
 		/* Accept connection */
 		ircomm_connect_response(self->ircomm, NULL);
@@ -765,6 +833,7 @@
 		break;
 	case IRCOMM_TTY_CONNECT_INDICATION:
 		del_timer(&self->watchdog_timer);
+		ircomm_tty_ias_unregister(self);
 
 		/* Accept connection */
 		ircomm_connect_response(self->ircomm, NULL);
@@ -813,6 +882,7 @@
 		break;
 	case IRCOMM_TTY_CONNECT_INDICATION:
 		del_timer(&self->watchdog_timer);
+		ircomm_tty_ias_unregister(self);
 
 		/* Accept connection */
 		ircomm_connect_response(self->ircomm, NULL);
@@ -848,7 +918,7 @@
 	switch (event) {
 	case IRCOMM_TTY_CONNECT_CONFIRM:
 		del_timer(&self->watchdog_timer);
-		ircomm_tty_next_state(self, IRCOMM_TTY_READY);
+		ircomm_tty_ias_unregister(self);
 		
 		/* 
 		 * Send initial parameters. This will also send out queued
@@ -856,9 +926,11 @@
 		 */
 		ircomm_tty_send_initial_parameters(self);
 		ircomm_tty_link_established(self);
+		ircomm_tty_next_state(self, IRCOMM_TTY_READY);
 		break;
 	case IRCOMM_TTY_CONNECT_INDICATION:
 		del_timer(&self->watchdog_timer);
+		ircomm_tty_ias_unregister(self);
 		
 		/* Accept connection */
 		ircomm_connect_response(self->ircomm, NULL);
@@ -903,6 +975,7 @@
 		ircomm_tty_next_state(self, IRCOMM_TTY_IDLE);
 		break;
 	case IRCOMM_TTY_DISCONNECT_INDICATION:
+		ircomm_tty_ias_register(self);
 		ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
 		ircomm_tty_start_watchdog_timer(self, 3*HZ);
 
@@ -922,40 +995,5 @@
 		ret = -EINVAL;
 	}
 	return ret;
-}
-
-/*
- * Function ircomm_tty_do_event (self, event, skb)
- *
- *    Process event
- *
- */
-int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
-			struct sk_buff *skb, struct ircomm_tty_info *info) 
-{
-	ASSERT(self != NULL, return -1;);
-	ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
-
-	IRDA_DEBUG(2, "%s: state=%s, event=%s\n", __FUNCTION__ ,
-		   ircomm_tty_state[self->state], ircomm_tty_event[event]);
-	
-	return (*state[self->state])(self, event, skb, info);
-}
-
-/*
- * Function ircomm_tty_next_state (self, state)
- *
- *    Switch state
- *
- */
-void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_STATE state)
-{
-	ASSERT(self != NULL, return;);
-	ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
-
-	self->state = state;
-	
-	IRDA_DEBUG(2, "%s: next state=%s, service type=%d\n", __FUNCTION__ , 
-		   ircomm_tty_state[self->state], self->service_type);
 }
 
diff -Nru a/net/irda/irias_object.c b/net/irda/irias_object.c
--- a/net/irda/irias_object.c	2004-12-24 13:37:00 -08:00
+++ b/net/irda/irias_object.c	2004-12-24 13:37:00 -08:00
@@ -159,11 +159,14 @@
 	ASSERT(obj != NULL, return -1;);
 	ASSERT(obj->magic == IAS_OBJECT_MAGIC, return -1;);
 
+	/* Remove from list */
 	node = hashbin_remove_this(irias_objects, (irda_queue_t *) obj);
 	if (!node)
-		return 0; /* Already removed */
+		IRDA_DEBUG( 0, "%s(), object already removed!\n",
+			    __FUNCTION__);
 
-	__irias_delete_object(node);
+	/* Destroy */
+	__irias_delete_object(obj);
 
 	return 0;
 }
@@ -176,7 +179,8 @@
  *    the object, remove the object as well.
  *
  */
-int irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib)
+int irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib,
+			int cleanobject)
 {
 	struct ias_attrib *node;
 
@@ -192,9 +196,13 @@
 	/* Deallocate attribute */
 	__irias_delete_attrib(node);
 
-	/* Check if object has still some attributes */
+	/* Check if object has still some attributes, destroy it if none.
+	 * At first glance, this look dangerous, as the kernel reference
+	 * various IAS objects. However, we only use this function on
+	 * user attributes, not kernel attributes, so there is no risk
+	 * of deleting a kernel object this way. Jean II */
 	node = (struct ias_attrib *) hashbin_get_first(obj->attribs);
-	if (!node)
+	if (cleanobject && !node)
 		irias_delete_object(obj);
 
 	return 0;
diff -Nru a/net/irda/irlan/irlan_client.c b/net/irda/irlan/irlan_client.c
--- a/net/irda/irlan/irlan_client.c	2004-12-24 13:36:56 -08:00
+++ b/net/irda/irlan/irlan_client.c	2004-12-24 13:36:56 -08:00
@@ -33,10 +33,10 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/if_arp.h>
+#include <linux/bitops.h>
 #include <net/arp.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
 
 #include <net/irda/irda.h>
@@ -234,7 +234,7 @@
 	ASSERT(tsap == self->client.tsap_ctrl, return;);
 
        	/* Remove frames queued on the control channel */
-	while ((skb = skb_dequeue(&self->client.txq))) {
+	while ((skb = skb_dequeue(&self->client.txq)) != NULL) {
 		dev_kfree_skb(skb);
 	}
 	self->client.tx_busy = FALSE;
diff -Nru a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
--- a/net/irda/irlan/irlan_common.c	2004-12-24 13:36:55 -08:00
+++ b/net/irda/irlan/irlan_common.c	2004-12-24 13:36:55 -08:00
@@ -37,9 +37,9 @@
 #include <linux/etherdevice.h>
 #include <linux/rtnetlink.h>
 #include <linux/moduleparam.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
 
 #include <net/irda/irda.h>
diff -Nru a/net/irda/irlan/irlan_provider.c b/net/irda/irlan/irlan_provider.c
--- a/net/irda/irlan/irlan_provider.c	2004-12-24 13:36:47 -08:00
+++ b/net/irda/irlan/irlan_provider.c	2004-12-24 13:36:47 -08:00
@@ -33,9 +33,9 @@
 #include <linux/etherdevice.h>
 #include <linux/init.h>
 #include <linux/random.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/byteorder.h>
 
 #include <net/irda/irda.h>
diff -Nru a/net/irda/irlap_event.c b/net/irda/irlap_event.c
--- a/net/irda/irlap_event.c	2004-12-24 13:37:00 -08:00
+++ b/net/irda/irlap_event.c	2004-12-24 13:37:00 -08:00
@@ -433,10 +433,11 @@
 				self->frame_sent = FALSE;
 
 			/*
-			 * Remember to multiply the query timeout value with
-			 * the number of slots used
+			 * Go to reply state until end of discovery to
+			 * inhibit our own transmissions. Set the timer
+			 * to not stay forever there... Jean II
 			 */
-			irlap_start_query_timer(self, QUERY_TIMEOUT*info->S);
+			irlap_start_query_timer(self, info->S, info->s);
 			irlap_next_state(self, LAP_REPLY);
 		} else {
 		/* This is the final slot. How is it possible ?
@@ -452,6 +453,9 @@
 		 * Not much. It's too late to answer those discovery frames,
 		 * so we just pass the info to IrLMP who will put it in the
 		 * log (and post an event).
+		 * Another cause would be devices that do discovery much
+		 * slower than us, however the latest fixes should minimise
+		 * those cases...
 		 * Jean II
 		 */
 			IRDA_DEBUG(1, "%s(), Receiving final discovery request, missed the discovery slots :-(\n", __FUNCTION__);
@@ -691,7 +695,7 @@
 
 	switch (event) {
 	case QUERY_TIMER_EXPIRED:
-		IRDA_DEBUG(2, "%s(), QUERY_TIMER_EXPIRED <%ld>\n",
+		IRDA_DEBUG(0, "%s(), QUERY_TIMER_EXPIRED <%ld>\n",
 			   __FUNCTION__, jiffies);
 		irlap_next_state(self, LAP_NDM);
 		break;
@@ -707,16 +711,26 @@
 			irlap_next_state(self, LAP_NDM);
 
 			irlap_discovery_indication(self, info->discovery);
-		} else if ((info->s >= self->slot) && (!self->frame_sent)) {
-			discovery_rsp = irlmp_get_discovery_response();
-			discovery_rsp->data.daddr = info->daddr;
-
-			irlap_send_discovery_xid_frame(self, info->S,
-						       self->slot, FALSE,
-						       discovery_rsp);
+		} else {
+			/* If it's our slot, send our reply */
+			if ((info->s >= self->slot) && (!self->frame_sent)) {
+				discovery_rsp = irlmp_get_discovery_response();
+				discovery_rsp->data.daddr = info->daddr;
+
+				irlap_send_discovery_xid_frame(self, info->S,
+							       self->slot,
+							       FALSE,
+							       discovery_rsp);
+
+				self->frame_sent = TRUE;
+			}
+			/* Readjust our timer to accomodate devices
+			 * doing faster or slower discovery than us...
+			 * Jean II */
+			irlap_start_query_timer(self, info->S, info->s);
 
-			self->frame_sent = TRUE;
-			irlap_next_state(self, LAP_REPLY);
+			/* Keep state */
+			//irlap_next_state(self, LAP_REPLY);
 		}
 		break;
 	default:
diff -Nru a/net/irda/irlmp.c b/net/irda/irlmp.c
--- a/net/irda/irlmp.c	2004-12-24 13:37:19 -08:00
+++ b/net/irda/irlmp.c	2004-12-24 13:37:19 -08:00
@@ -99,7 +99,7 @@
 
 	spin_lock_init(&irlmp->cachelog->hb_spinlock);
 
-	irlmp->free_lsap_sel = 0x10; /* Reserved 0x00-0x0f */
+	irlmp->last_lsap_sel = 0x0f; /* Reserved 0x00-0x0f */
 	strcpy(sysctl_devname, "Linux");
 
 	/* Do discovery every 3 seconds */
@@ -160,7 +160,7 @@
 	/* Allocate new instance of a LSAP connection */
 	self = kmalloc(sizeof(struct lsap_cb), GFP_ATOMIC);
 	if (self == NULL) {
-		ERROR("%s: can't allocate memory", __FUNCTION__);
+		ERROR("%s: can't allocate memory\n", __FUNCTION__);
 		return NULL;
 	}
 	memset(self, 0, sizeof(struct lsap_cb));
@@ -1649,6 +1649,12 @@
  * Function irlmp_slsap_inuse (slsap)
  *
  *    Check if the given source LSAP selector is in use
+ *
+ * This function is clearly not very efficient. On the mitigating side, the
+ * stack make sure that in 99% of the cases, we are called only once
+ * for each socket allocation. We could probably keep a bitmap
+ * of the allocated LSAP, but I'm not sure the complexity is worth it.
+ * Jean II
  */
 int irlmp_slsap_inuse(__u8 slsap_sel)
 {
@@ -1668,7 +1674,7 @@
 		return FALSE;
 #endif /* CONFIG_IRDA_ULTRA */
 
-	/* Valid values are between 0 and 127 */
+	/* Valid values are between 0 and 127 (0x0-0x6F) */
 	if (slsap_sel > LSAP_MAX)
 		return TRUE;
 
@@ -1680,30 +1686,68 @@
 	spin_lock_irqsave(&irlmp->links->hb_spinlock, flags);
 	lap = (struct lap_cb *) hashbin_get_first(irlmp->links);
 	while (lap != NULL) {
-		ASSERT(lap->magic == LMP_LAP_MAGIC, return TRUE;);
+		ASSERT(lap->magic == LMP_LAP_MAGIC, goto errlap;);
 
 		/* Careful for priority inversions here !
-		 * All other uses of attrib spinlock are independent of
-		 * the object spinlock, so we are safe. Jean II */
+		 * irlmp->links is never taken while another IrDA
+		 * spinlock is held, so we are safe. Jean II */
 		spin_lock(&lap->lsaps->hb_spinlock);
 
+		/* For this IrLAP, check all the LSAPs */
 		self = (struct lsap_cb *) hashbin_get_first(lap->lsaps);
 		while (self != NULL) {
-			ASSERT(self->magic == LMP_LSAP_MAGIC, return TRUE;);
+			ASSERT(self->magic == LMP_LSAP_MAGIC, goto errlsap;);
 
 			if ((self->slsap_sel == slsap_sel)) {
 				IRDA_DEBUG(4, "Source LSAP selector=%02x in use\n",
-				      self->slsap_sel);
-				return TRUE;
+					   self->slsap_sel);
+				goto errlsap;
 			}
 			self = (struct lsap_cb*) hashbin_get_next(lap->lsaps);
 		}
 		spin_unlock(&lap->lsaps->hb_spinlock);
+
 		/* Next LAP */
 		lap = (struct lap_cb *) hashbin_get_next(irlmp->links);
 	}
 	spin_unlock_irqrestore(&irlmp->links->hb_spinlock, flags);
+
+	/*
+	 * Server sockets are typically waiting for connections and
+	 * therefore reside in the unconnected list. We don't want
+	 * to give out their LSAPs for obvious reasons...
+	 * Jean II
+	 */
+	spin_lock_irqsave(&irlmp->unconnected_lsaps->hb_spinlock, flags);
+
+	self = (struct lsap_cb *) hashbin_get_first(irlmp->unconnected_lsaps);
+	while (self != NULL) {
+		ASSERT(self->magic == LMP_LSAP_MAGIC, goto erruncon;);
+		if ((self->slsap_sel == slsap_sel)) {
+			IRDA_DEBUG(4, "Source LSAP selector=%02x in use (unconnected)\n",
+				   self->slsap_sel);
+			goto erruncon;
+		}
+		self = (struct lsap_cb*) hashbin_get_next(irlmp->unconnected_lsaps);
+	}
+	spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock, flags);
+
 	return FALSE;
+
+	/* Error exit from within one of the two nested loops.
+	 * Make sure we release the right spinlock in the righ order.
+	 * Jean II */
+errlsap:
+	spin_unlock(&lap->lsaps->hb_spinlock);
+errlap:
+	spin_unlock_irqrestore(&irlmp->links->hb_spinlock, flags);
+	return TRUE;
+
+	/* Error exit from within the unconnected loop.
+	 * Just one spinlock to release... Jean II */
+erruncon:
+	spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock, flags);
+	return TRUE;
 }
 
 /*
@@ -1720,22 +1764,48 @@
 	ASSERT(irlmp != NULL, return -1;);
 	ASSERT(irlmp->magic == LMP_MAGIC, return -1;);
 
-	lsap_sel = irlmp->free_lsap_sel++;
-
-	/* Check if the new free lsap is really free */
-	while (irlmp_slsap_inuse(irlmp->free_lsap_sel)) {
-		irlmp->free_lsap_sel++;
+	/* Most users don't really care which LSAPs they are given,
+	 * and therefore we automatically give them a free LSAP.
+	 * This function try to find a suitable LSAP, i.e. which is
+	 * not in use and is within the acceptable range. Jean II */
+
+	do {
+		/* Always increment to LSAP number before using it.
+		 * In theory, we could reuse the last LSAP number, as long
+		 * as it is no longer in use. Some IrDA stack do that.
+		 * However, the previous socket may be half closed, i.e.
+		 * we closed it, we think it's no longer in use, but the
+		 * other side did not receive our close and think it's
+		 * active and still send data on it.
+		 * This is similar to what is done with PIDs and TCP ports.
+		 * Also, this reduce the number of calls to irlmp_slsap_inuse()
+		 * which is an expensive function to call.
+		 * Jean II */
+		irlmp->last_lsap_sel++;
 
 		/* Check if we need to wraparound (0x70-0x7f are reserved) */
-		if (irlmp->free_lsap_sel > LSAP_MAX) {
-			irlmp->free_lsap_sel = 10;
+		if (irlmp->last_lsap_sel > LSAP_MAX) {
+			/* 0x00-0x10 are also reserved for well know ports */
+			irlmp->last_lsap_sel = 0x10;
 
 			/* Make sure we terminate the loop */
-			if (wrapped++)
+			if (wrapped++) {
+				ERROR("%s: no more free LSAPs !\n",
+				      __FUNCTION__);
 				return 0;
+			}
 		}
-	}
-	IRDA_DEBUG(4, "%s(), next free lsap_sel=%02x\n",
+
+		/* If the LSAP is in use, try the next one.
+		 * Despite the autoincrement, we need to check if the lsap
+		 * is really in use or not, first because LSAP may be
+		 * directly allocated in irlmp_open_lsap(), and also because
+		 * we may wraparound on old sockets. Jean II */
+	} while (irlmp_slsap_inuse(irlmp->last_lsap_sel));
+
+	/* Got it ! */
+	lsap_sel = irlmp->last_lsap_sel;
+	IRDA_DEBUG(4, "%s(), found free lsap_sel=%02x\n",
 		   __FUNCTION__, lsap_sel);
 
 	return lsap_sel;
diff -Nru a/net/irda/irmod.c b/net/irda/irmod.c
--- a/net/irda/irmod.c	2004-12-24 13:37:19 -08:00
+++ b/net/irda/irmod.c	2004-12-24 13:37:19 -08:00
@@ -62,7 +62,7 @@
 #ifdef CONFIG_IRDA_DEBUG
 unsigned int irda_debug = IRDA_DEBUG_LEVEL;
 module_param_named(debug, irda_debug, uint, 0);
-MODULE_PARM_DESC(irda_debug, "IRDA debugging level");
+MODULE_PARM_DESC(debug, "IRDA debugging level");
 EXPORT_SYMBOL(irda_debug);
 #endif
 
diff -Nru a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c
--- a/net/irda/irnet/irnet_ppp.c	2004-12-24 13:37:04 -08:00
+++ b/net/irda/irnet/irnet_ppp.c	2004-12-24 13:37:04 -08:00
@@ -1111,3 +1111,4 @@
 MODULE_AUTHOR("Jean Tourrilhes <jt@hpl.hp.com>");
 MODULE_DESCRIPTION("IrNET : Synchronous PPP over IrDA"); 
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_CHARDEV(10, 187);
diff -Nru a/net/irda/qos.c b/net/irda/qos.c
--- a/net/irda/qos.c	2004-12-24 13:37:19 -08:00
+++ b/net/irda/qos.c	2004-12-24 13:37:19 -08:00
@@ -211,17 +211,6 @@
 	return index;
 }
 
-static inline __u32 byte_value(__u8 byte, __u32 *array) 
-{
-	int index;
-
-	ASSERT(array != NULL, return -1;);
-
-	index = msb_index(byte);
-
-	return index_value(index, array);
-}
-
 /*
  * Function value_lower_bits (value, array)
  *
diff -Nru a/net/irda/timer.c b/net/irda/timer.c
--- a/net/irda/timer.c	2004-12-24 13:36:56 -08:00
+++ b/net/irda/timer.c	2004-12-24 13:36:56 -08:00
@@ -34,6 +34,8 @@
 #include <net/irda/irlap.h>
 #include <net/irda/irlmp.h>
 
+extern int  sysctl_slot_timeout;
+
 static void irlap_slot_timer_expired(void* data);
 static void irlap_query_timer_expired(void* data);
 static void irlap_final_timer_expired(void* data);
@@ -47,8 +49,25 @@
 			 irlap_slot_timer_expired);
 }
 
-void irlap_start_query_timer(struct irlap_cb *self, int timeout)
+void irlap_start_query_timer(struct irlap_cb *self, int S, int s)
 {
+	int timeout;
+
+	/* Calculate when the peer discovery should end. Normally, we
+	 * get the end-of-discovery frame, so this is just in case
+	 * we miss it.
+	 * Basically, we multiply the number of remaining slots by our
+	 * slot time, plus add some extra time to properly receive the last
+	 * discovery packet (which is longer due to extra discovery info),
+	 * to avoid messing with for incomming connections requests and
+	 * to accomodate devices that perform discovery slower than us.
+	 * Jean II */
+	timeout = ((sysctl_slot_timeout * HZ / 1000) * (S - s)
+		   + XIDEXTRA_TIMEOUT + SMALLBUSY_TIMEOUT);
+
+	/* Set or re-set the timer. We reset the timer for each received
+	 * discovery query, which allow us to automatically adjust to
+	 * the speed of the peer discovery (faster or slower). Jean II */
 	irda_start_timer( &self->query_timer, timeout, (void *) self, 
 			  irlap_query_timer_expired);
 }
diff -Nru a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
--- a/net/netlink/af_netlink.c	2004-12-24 13:36:49 -08:00
+++ b/net/netlink/af_netlink.c	2004-12-24 13:36:49 -08:00
@@ -44,6 +44,12 @@
 #include <linux/smp_lock.h>
 #include <linux/notifier.h>
 #include <linux/security.h>
+#include <linux/jhash.h>
+#include <linux/jiffies.h>
+#include <linux/random.h>
+#include <linux/bitops.h>
+#include <linux/mm.h>
+#include <linux/types.h>
 #include <net/sock.h>
 #include <net/scm.h>
 
@@ -56,9 +62,9 @@
 struct netlink_opt
 {
 	u32			pid;
-	unsigned		groups;
+	unsigned int		groups;
 	u32			dst_pid;
-	unsigned		dst_groups;
+	unsigned int		dst_groups;
 	unsigned long		state;
 	int			(*handler)(int unit, struct sk_buff *skb);
 	wait_queue_head_t	wait;
@@ -69,9 +75,28 @@
 
 #define nlk_sk(__sk) ((struct netlink_opt *)(__sk)->sk_protinfo)
 
-static struct hlist_head nl_table[MAX_LINKS];
+struct nl_pid_hash {
+	struct hlist_head *table;
+	unsigned long rehash_time;
+
+	unsigned int mask;
+	unsigned int shift;
+
+	unsigned int entries;
+	unsigned int max_shift;
+
+	u32 rnd;
+};
+
+struct netlink_table {
+	struct nl_pid_hash hash;
+	struct hlist_head mc_list;
+};
+
+static struct netlink_table *nl_table;
+
 static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait);
-static unsigned nl_nonroot[MAX_LINKS];
+static unsigned int nl_nonroot[MAX_LINKS];
 
 #ifdef NL_EMULATE_DEV
 static struct socket *netlink_kernel[MAX_LINKS];
@@ -80,13 +105,16 @@
 static int netlink_dump(struct sock *sk);
 static void netlink_destroy_callback(struct netlink_callback *cb);
 
-atomic_t netlink_sock_nr;
-
 static rwlock_t nl_table_lock = RW_LOCK_UNLOCKED;
 static atomic_t nl_table_users = ATOMIC_INIT(0);
 
 static struct notifier_block *netlink_chain;
 
+static struct hlist_head *nl_pid_hashfn(struct nl_pid_hash *hash, u32 pid)
+{
+	return &hash->table[jhash_1word(pid, hash->rnd) & hash->mask];
+}
+
 static void netlink_sock_destruct(struct sock *sk)
 {
 	skb_queue_purge(&sk->sk_receive_queue);
@@ -100,11 +128,6 @@
 	BUG_TRAP(!nlk_sk(sk)->cb);
 
 	kfree(nlk_sk(sk));
-
-	atomic_dec(&netlink_sock_nr);
-#ifdef NETLINK_REFCNT_DEBUG
-	printk(KERN_DEBUG "NETLINK %p released, %d are still alive\n", sk, atomic_read(&netlink_sock_nr));
-#endif
 }
 
 /* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on SMP.
@@ -160,11 +183,14 @@
 
 static __inline__ struct sock *netlink_lookup(int protocol, u32 pid)
 {
+	struct nl_pid_hash *hash = &nl_table[protocol].hash;
+	struct hlist_head *head;
 	struct sock *sk;
 	struct hlist_node *node;
 
 	read_lock(&nl_table_lock);
-	sk_for_each(sk, node, &nl_table[protocol]) {
+	head = nl_pid_hashfn(hash, pid);
+	sk_for_each(sk, node, head) {
 		if (nlk_sk(sk)->pid == pid) {
 			sock_hold(sk);
 			goto found;
@@ -176,27 +202,118 @@
 	return sk;
 }
 
+static inline struct hlist_head *nl_pid_hash_alloc(size_t size)
+{
+	if (size <= PAGE_SIZE)
+		return kmalloc(size, GFP_ATOMIC);
+	else
+		return (struct hlist_head *)
+			__get_free_pages(GFP_ATOMIC, get_order(size));
+}
+
+static inline void nl_pid_hash_free(struct hlist_head *table, size_t size)
+{
+	if (size <= PAGE_SIZE)
+		kfree(table);
+	else
+		free_pages((unsigned long)table, get_order(size));
+}
+
+static int nl_pid_hash_rehash(struct nl_pid_hash *hash, int grow)
+{
+	unsigned int omask, mask, shift;
+	size_t osize, size;
+	struct hlist_head *otable, *table;
+	int i;
+
+	omask = mask = hash->mask;
+	osize = size = (mask + 1) * sizeof(*table);
+	shift = hash->shift;
+
+	if (grow) {
+		if (++shift > hash->max_shift)
+			return 0;
+		mask = mask * 2 + 1;
+		size *= 2;
+	}
+
+	table = nl_pid_hash_alloc(size);
+	if (!table)
+		return 0;
+
+	memset(table, 0, size);
+	otable = hash->table;
+	hash->table = table;
+	hash->mask = mask;
+	hash->shift = shift;
+	get_random_bytes(&hash->rnd, sizeof(hash->rnd));
+
+	for (i = 0; i <= omask; i++) {
+		struct sock *sk;
+		struct hlist_node *node, *tmp;
+
+		sk_for_each_safe(sk, node, tmp, &otable[i])
+			__sk_add_node(sk, nl_pid_hashfn(hash, nlk_sk(sk)->pid));
+	}
+
+	nl_pid_hash_free(otable, osize);
+	hash->rehash_time = jiffies + 10 * 60 * HZ;
+	return 1;
+}
+
+static inline int nl_pid_hash_dilute(struct nl_pid_hash *hash, int len)
+{
+	int avg = hash->entries >> hash->shift;
+
+	if (unlikely(avg > 1) && nl_pid_hash_rehash(hash, 1))
+		return 1;
+
+	if (unlikely(len > avg) && time_after(jiffies, hash->rehash_time)) {
+		nl_pid_hash_rehash(hash, 0);
+		return 1;
+	}
+
+	return 0;
+}
+
 static struct proto_ops netlink_ops;
 
 static int netlink_insert(struct sock *sk, u32 pid)
 {
+	struct nl_pid_hash *hash = &nl_table[sk->sk_protocol].hash;
+	struct hlist_head *head;
 	int err = -EADDRINUSE;
 	struct sock *osk;
 	struct hlist_node *node;
+	int len;
 
 	netlink_table_grab();
-	sk_for_each(osk, node, &nl_table[sk->sk_protocol]) {
+	head = nl_pid_hashfn(hash, pid);
+	len = 0;
+	sk_for_each(osk, node, head) {
 		if (nlk_sk(osk)->pid == pid)
 			break;
+		len++;
 	}
-	if (!node) {
-		err = -EBUSY;
-		if (nlk_sk(sk)->pid == 0) {
-			nlk_sk(sk)->pid = pid;
-			sk_add_node(sk, &nl_table[sk->sk_protocol]);
-			err = 0;
-		}
-	}
+	if (node)
+		goto err;
+
+	err = -EBUSY;
+	if (nlk_sk(sk)->pid)
+		goto err;
+
+	err = -ENOMEM;
+	if (BITS_PER_LONG > 32 && unlikely(hash->entries >= UINT_MAX))
+		goto err;
+
+	if (len && nl_pid_hash_dilute(hash, len))
+		head = nl_pid_hashfn(hash, pid);
+	hash->entries++;
+	nlk_sk(sk)->pid = pid;
+	sk_add_node(sk, head);
+	err = 0;
+
+err:
 	netlink_table_ungrab();
 	return err;
 }
@@ -204,7 +321,10 @@
 static void netlink_remove(struct sock *sk)
 {
 	netlink_table_grab();
+	nl_table[sk->sk_protocol].hash.entries--;
 	sk_del_node_init(sk);
+	if (nlk_sk(sk)->groups)
+		__sk_del_bind_node(sk);
 	netlink_table_ungrab();
 }
 
@@ -240,7 +360,6 @@
 	spin_lock_init(&nlk->cb_lock);
 	init_waitqueue_head(&nlk->wait);
 	sk->sk_destruct = netlink_sock_destruct;
-	atomic_inc(&netlink_sock_nr);
 
 	sk->sk_protocol = protocol;
 	return 0;
@@ -290,19 +409,24 @@
 static int netlink_autobind(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
+	struct nl_pid_hash *hash = &nl_table[sk->sk_protocol].hash;
+	struct hlist_head *head;
 	struct sock *osk;
 	struct hlist_node *node;
 	s32 pid = current->pid;
 	int err;
+	static s32 rover = -4097;
 
 retry:
+	cond_resched();
 	netlink_table_grab();
-	sk_for_each(osk, node, &nl_table[sk->sk_protocol]) {
+	head = nl_pid_hashfn(hash, pid);
+	sk_for_each(osk, node, head) {
 		if (nlk_sk(osk)->pid == pid) {
 			/* Bind collision, search negative pid values. */
-			if (pid > 0)
-				pid = -4096;
-			pid--;
+			pid = rover--;
+			if (rover > -4097)
+				rover = -4097;
 			netlink_table_ungrab();
 			goto retry;
 		}
@@ -316,7 +440,7 @@
 	return 0;
 }
 
-static inline int netlink_capable(struct socket *sock, unsigned flag) 
+static inline int netlink_capable(struct socket *sock, unsigned int flag) 
 { 
 	return (nl_nonroot[sock->sk->sk_protocol] & flag) ||
 	       capable(CAP_NET_ADMIN);
@@ -339,21 +463,26 @@
 	if (nlk->pid) {
 		if (nladdr->nl_pid != nlk->pid)
 			return -EINVAL;
-		nlk->groups = nladdr->nl_groups;
-		return 0;
+	} else {
+		err = nladdr->nl_pid ?
+			netlink_insert(sk, nladdr->nl_pid) :
+			netlink_autobind(sock);
+		if (err)
+			return err;
 	}
 
-	if (nladdr->nl_pid == 0) {
-		err = netlink_autobind(sock);
-		if (err == 0)
-			nlk->groups = nladdr->nl_groups;
-		return err;
-	}
+	if (!nladdr->nl_groups && !nlk->groups)
+		return 0;
 
-	err = netlink_insert(sk, nladdr->nl_pid);
-	if (err == 0)
-		nlk->groups = nladdr->nl_groups;
-	return err;
+	netlink_table_grab();
+	if (nlk->groups && !nladdr->nl_groups)
+		__sk_del_bind_node(sk);
+	else if (!nlk->groups && nladdr->nl_groups)
+		sk_add_bind_node(sk, &nl_table[sk->sk_protocol].mc_list);
+	nlk->groups = nladdr->nl_groups;
+	netlink_table_ungrab();
+
+	return 0;
 }
 
 static int netlink_connect(struct socket *sock, struct sockaddr *addr,
@@ -593,19 +722,81 @@
 		skb_set_owner_r(skb, sk);
 		skb_queue_tail(&sk->sk_receive_queue, skb);
 		sk->sk_data_ready(sk, skb->len);
-		return 0;
+		return atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf;
 	}
 	return -1;
 }
 
+struct netlink_broadcast_data {
+	struct sock *exclude_sk;
+	u32 pid;
+	u32 group;
+	int failure;
+	int congested;
+	int delivered;
+	int allocation;
+	struct sk_buff *skb, *skb2;
+};
+
+static inline int do_one_broadcast(struct sock *sk,
+				   struct netlink_broadcast_data *p)
+{
+	struct netlink_opt *nlk = nlk_sk(sk);
+	int val;
+
+	if (p->exclude_sk == sk)
+		goto out;
+
+	if (nlk->pid == p->pid || !(nlk->groups & p->group))
+		goto out;
+
+	if (p->failure) {
+		netlink_overrun(sk);
+		goto out;
+	}
+
+	sock_hold(sk);
+	if (p->skb2 == NULL) {
+		if (atomic_read(&p->skb->users) != 1) {
+			p->skb2 = skb_clone(p->skb, p->allocation);
+		} else {
+			p->skb2 = p->skb;
+			atomic_inc(&p->skb->users);
+		}
+	}
+	if (p->skb2 == NULL) {
+		netlink_overrun(sk);
+		/* Clone failed. Notify ALL listeners. */
+		p->failure = 1;
+	} else if ((val = netlink_broadcast_deliver(sk, p->skb2)) < 0) {
+		netlink_overrun(sk);
+	} else {
+		p->congested |= val;
+		p->delivered = 1;
+		p->skb2 = NULL;
+	}
+	sock_put(sk);
+
+out:
+	return 0;
+}
+
 int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
 		      u32 group, int allocation)
 {
-	struct sock *sk;
+	struct netlink_broadcast_data info;
 	struct hlist_node *node;
-	struct sk_buff *skb2 = NULL;
-	int protocol = ssk->sk_protocol;
-	int failure = 0, delivered = 0;
+	struct sock *sk;
+
+	info.exclude_sk = ssk;
+	info.pid = pid;
+	info.group = group;
+	info.failure = 0;
+	info.congested = 0;
+	info.delivered = 0;
+	info.allocation = allocation;
+	info.skb = skb;
+	info.skb2 = NULL;
 
 	netlink_trim(skb, allocation);
 
@@ -613,73 +804,65 @@
 
 	netlink_lock_table();
 
-	sk_for_each(sk, node, &nl_table[protocol]) {
-		struct netlink_opt *nlk = nlk_sk(sk);
-
-		if (ssk == sk)
-			continue;
-
-		if (nlk->pid == pid || !(nlk->groups & group))
-			continue;
-
-		if (failure) {
-			netlink_overrun(sk);
-			continue;
-		}
-
-		sock_hold(sk);
-		if (skb2 == NULL) {
-			if (atomic_read(&skb->users) != 1) {
-				skb2 = skb_clone(skb, allocation);
-			} else {
-				skb2 = skb;
-				atomic_inc(&skb->users);
-			}
-		}
-		if (skb2 == NULL) {
-			netlink_overrun(sk);
-			/* Clone failed. Notify ALL listeners. */
-			failure = 1;
-		} else if (netlink_broadcast_deliver(sk, skb2)) {
-			netlink_overrun(sk);
-		} else {
-			delivered = 1;
-			skb2 = NULL;
-		}
-		sock_put(sk);
-	}
+	sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
+		do_one_broadcast(sk, &info);
 
 	netlink_unlock_table();
 
-	if (skb2)
-		kfree_skb(skb2);
+	if (info.skb2)
+		kfree_skb(info.skb2);
 	kfree_skb(skb);
 
-	if (delivered)
+	if (info.delivered) {
+		if (info.congested && (allocation & __GFP_WAIT))
+			yield();
 		return 0;
-	if (failure)
+	}
+	if (info.failure)
 		return -ENOBUFS;
 	return -ESRCH;
 }
 
+struct netlink_set_err_data {
+	struct sock *exclude_sk;
+	u32 pid;
+	u32 group;
+	int code;
+};
+
+static inline int do_one_set_err(struct sock *sk,
+				 struct netlink_set_err_data *p)
+{
+	struct netlink_opt *nlk = nlk_sk(sk);
+
+	if (sk == p->exclude_sk)
+		goto out;
+
+	if (nlk->pid == p->pid || !(nlk->groups & p->group))
+		goto out;
+
+	sk->sk_err = p->code;
+	sk->sk_error_report(sk);
+out:
+	return 0;
+}
+
 void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
 {
-	struct sock *sk;
+	struct netlink_set_err_data info;
 	struct hlist_node *node;
-	int protocol = ssk->sk_protocol;
+	struct sock *sk;
+
+	info.exclude_sk = ssk;
+	info.pid = pid;
+	info.group = group;
+	info.code = code;
 
 	read_lock(&nl_table_lock);
-	sk_for_each(sk, node, &nl_table[protocol]) {
-		struct netlink_opt *nlk = nlk_sk(sk);
-		if (ssk == sk)
-			continue;
 
-		if (nlk->pid == pid || !(nlk->groups & group))
-			continue;
+	sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
+		do_one_set_err(sk, &info);
 
-		sk->sk_err = code;
-		sk->sk_error_report(sk);
-	}
 	read_unlock(&nl_table_lock);
 }
 
@@ -855,6 +1038,9 @@
 	struct socket *sock;
 	struct sock *sk;
 
+	if (!nl_table)
+		return NULL;
+
 	if (unit<0 || unit>=MAX_LINKS)
 		return NULL;
 
@@ -870,13 +1056,16 @@
 	if (input)
 		nlk_sk(sk)->data_ready = input;
 
-	netlink_insert(sk, 0);
+	if (netlink_insert(sk, 0)) {
+		sock_release(sock);
+		return NULL;
+	}
 	return sk;
 }
 
-void netlink_set_nonroot(int protocol, unsigned flags)
+void netlink_set_nonroot(int protocol, unsigned int flags)
 { 
-	if ((unsigned)protocol < MAX_LINKS) 
+	if ((unsigned int)protocol < MAX_LINKS) 
 		nl_nonroot[protocol] = flags;
 } 
 
@@ -1069,20 +1258,31 @@
 #endif
 
 #ifdef CONFIG_PROC_FS
+struct nl_seq_iter {
+	int link;
+	int hash_idx;
+};
+
 static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos)
 {
-	long i;
+	struct nl_seq_iter *iter = seq->private;
+	int i, j;
 	struct sock *s;
 	struct hlist_node *node;
 	loff_t off = 0;
 
 	for (i=0; i<MAX_LINKS; i++) {
-		sk_for_each(s, node, &nl_table[i]) {
-			if (off == pos) {
-				seq->private = (void *) i;
-				return s;
+		struct nl_pid_hash *hash = &nl_table[i].hash;
+
+		for (j = 0; j <= hash->mask; j++) {
+			sk_for_each(s, node, &hash->table[j]) {
+				if (off == pos) {
+					iter->link = i;
+					iter->hash_idx = j;
+					return s;
+				}
+				++off;
 			}
-			++off;
 		}
 	}
 	return NULL;
@@ -1097,6 +1297,8 @@
 static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
 	struct sock *s;
+	struct nl_seq_iter *iter;
+	int i, j;
 
 	++*pos;
 
@@ -1104,18 +1306,29 @@
 		return netlink_seq_socket_idx(seq, 0);
 		
 	s = sk_next(v);
-	if (!s) {
-		long i = (long)seq->private;
+	if (s)
+		return s;
+
+	iter = seq->private;
+	i = iter->link;
+	j = iter->hash_idx + 1;
 
-		while (++i < MAX_LINKS) {
-			s = sk_head(&nl_table[i]);
+	do {
+		struct nl_pid_hash *hash = &nl_table[i].hash;
+
+		for (; j <= hash->mask; j++) {
+			s = sk_head(&hash->table[j]);
 			if (s) {
-				seq->private = (void *) i;
-				break;
+				iter->link = i;
+				iter->hash_idx = j;
+				return s;
 			}
 		}
-	}
-	return s;
+
+		j = 0;
+	} while (++i < MAX_LINKS);
+
+	return NULL;
 }
 
 static void netlink_seq_stop(struct seq_file *seq, void *v)
@@ -1159,7 +1372,24 @@
 
 static int netlink_seq_open(struct inode *inode, struct file *file)
 {
-	return seq_open(file, &netlink_seq_ops);
+	struct seq_file *seq;
+	struct nl_seq_iter *iter;
+	int err;
+
+	iter = kmalloc(sizeof(*iter), GFP_KERNEL);
+	if (!iter)
+		return -ENOMEM;
+
+	err = seq_open(file, &netlink_seq_ops);
+	if (err) {
+		kfree(iter);
+		return err;
+	}
+
+	memset(iter, 0, sizeof(*iter));
+	seq = file->private_data;
+	seq->private = iter;
+	return 0;
 }
 
 static struct file_operations netlink_seq_fops = {
@@ -1167,7 +1397,7 @@
 	.open		= netlink_seq_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
-	.release	= seq_release,
+	.release	= seq_release_private,
 };
 
 #endif
@@ -1209,14 +1439,54 @@
 	.owner	= THIS_MODULE,	/* for consistency 8) */
 };
 
+extern void netlink_skb_parms_too_large(void);
+
 static int __init netlink_proto_init(void)
 {
 	struct sk_buff *dummy_skb;
+	int i;
+	unsigned long max;
+	unsigned int order;
+
+	if (sizeof(struct netlink_skb_parms) > sizeof(dummy_skb->cb))
+		netlink_skb_parms_too_large();
+
+	nl_table = kmalloc(sizeof(*nl_table) * MAX_LINKS, GFP_KERNEL);
+	if (!nl_table) {
+enomem:
+		printk(KERN_CRIT "netlink_init: Cannot allocate nl_table\n");
+		return -ENOMEM;
+	}
+
+	memset(nl_table, 0, sizeof(*nl_table) * MAX_LINKS);
 
-	if (sizeof(struct netlink_skb_parms) > sizeof(dummy_skb->cb)) {
-		printk(KERN_CRIT "netlink_init: panic\n");
-		return -1;
+	if (num_physpages >= (128 * 1024))
+		max = num_physpages >> (21 - PAGE_SHIFT);
+	else
+		max = num_physpages >> (23 - PAGE_SHIFT);
+
+	order = get_bitmask_order(max) - 1 + PAGE_SHIFT;
+	max = (1UL << order) / sizeof(struct hlist_head);
+	order = get_bitmask_order(max > UINT_MAX ? UINT_MAX : max) - 1;
+
+	for (i = 0; i < MAX_LINKS; i++) {
+		struct nl_pid_hash *hash = &nl_table[i].hash;
+
+		hash->table = nl_pid_hash_alloc(1 * sizeof(*hash->table));
+		if (!hash->table) {
+			while (i-- > 0)
+				nl_pid_hash_free(nl_table[i].hash.table,
+						 1 * sizeof(*hash->table));
+			kfree(nl_table);
+			goto enomem;
+		}
+		memset(hash->table, 0, 1 * sizeof(*hash->table));
+		hash->max_shift = order;
+		hash->shift = 0;
+		hash->mask = 0;
+		hash->rehash_time = jiffies;
 	}
+
 	sock_register(&netlink_family_ops);
 #ifdef CONFIG_PROC_FS
 	proc_net_fops_create("netlink", 0, &netlink_seq_fops);
@@ -1230,6 +1500,8 @@
 {
        sock_unregister(PF_NETLINK);
        proc_net_remove("netlink");
+       kfree(nl_table);
+       nl_table = NULL;
 }
 
 core_initcall(netlink_proto_init);
diff -Nru a/net/netlink/netlink_dev.c b/net/netlink/netlink_dev.c
--- a/net/netlink/netlink_dev.c	2004-12-24 13:36:47 -08:00
+++ b/net/netlink/netlink_dev.c	2004-12-24 13:36:47 -08:00
@@ -28,8 +28,8 @@
 #include <linux/devfs_fs_kernel.h>
 #include <linux/smp_lock.h>
 #include <linux/device.h>
+#include <linux/bitops.h>
 
-#include <asm/bitops.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
diff -Nru a/net/netrom/nr_route.c b/net/netrom/nr_route.c
--- a/net/netrom/nr_route.c	2004-12-24 13:37:30 -08:00
+++ b/net/netrom/nr_route.c	2004-12-24 13:37:30 -08:00
@@ -186,7 +186,7 @@
 		nr_node->which = 0;
 		nr_node->count = 1;
 		atomic_set(&nr_node->refcount, 1);
-		nr_node->node_lock = SPIN_LOCK_UNLOCKED;
+		spin_lock_init(&nr_node->node_lock);
 
 		nr_node->routes[0].quality   = quality;
 		nr_node->routes[0].obs_count = obs_count;
diff -Nru a/net/packet/af_packet.c b/net/packet/af_packet.c
--- a/net/packet/af_packet.c	2004-12-24 13:37:01 -08:00
+++ b/net/packet/af_packet.c	2004-12-24 13:37:01 -08:00
@@ -1729,7 +1729,8 @@
 	start = vma->vm_start;
 	err = -EAGAIN;
 	for (i=0; i<po->pg_vec_len; i++) {
-		if (remap_page_range(vma, start, __pa(po->pg_vec[i]),
+		if (remap_pfn_range(vma, start,
+				     __pa(po->pg_vec[i]) >> PAGE_SHIFT,
 				     po->pg_vec_pages*PAGE_SIZE,
 				     vma->vm_page_prot))
 			goto out;
diff -Nru a/net/rxrpc/rxrpc_syms.c b/net/rxrpc/rxrpc_syms.c
--- a/net/rxrpc/rxrpc_syms.c	2004-12-24 13:36:47 -08:00
+++ b/net/rxrpc/rxrpc_syms.c	2004-12-24 13:36:47 -08:00
@@ -18,15 +18,7 @@
 #include <rxrpc/krxiod.h>
 
 /* call.c */
-EXPORT_SYMBOL(rxrpc_call_rcv_timeout);
-EXPORT_SYMBOL(rxrpc_call_acks_timeout);
-EXPORT_SYMBOL(rxrpc_call_dfr_ack_timeout);
-EXPORT_SYMBOL(rxrpc_call_max_resend);
-EXPORT_SYMBOL(rxrpc_call_states);
-EXPORT_SYMBOL(rxrpc_call_error_states);
-
 EXPORT_SYMBOL(rxrpc_create_call);
-EXPORT_SYMBOL(rxrpc_incoming_call);
 EXPORT_SYMBOL(rxrpc_put_call);
 EXPORT_SYMBOL(rxrpc_call_abort);
 EXPORT_SYMBOL(rxrpc_call_read_data);
@@ -37,15 +29,8 @@
 EXPORT_SYMBOL(rxrpc_create_connection);
 EXPORT_SYMBOL(rxrpc_put_connection);
 
-/* sysctl.c */
-EXPORT_SYMBOL(rxrpc_ktrace);
-EXPORT_SYMBOL(rxrpc_kdebug);
-EXPORT_SYMBOL(rxrpc_kproto);
-EXPORT_SYMBOL(rxrpc_knet);
-
 /* transport.c */
 EXPORT_SYMBOL(rxrpc_create_transport);
-EXPORT_SYMBOL(rxrpc_clear_transport);
 EXPORT_SYMBOL(rxrpc_put_transport);
 EXPORT_SYMBOL(rxrpc_add_service);
 EXPORT_SYMBOL(rxrpc_del_service);
diff -Nru a/net/sched/Kconfig b/net/sched/Kconfig
--- a/net/sched/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/net/sched/Kconfig	2004-12-24 13:37:19 -08:00
@@ -391,11 +391,32 @@
         tristate "generic Actions"
         depends on NET_CLS_ACT
         ---help---
-        You must have new iproute2 to use this feature
-        This adds simple filtering actions like drop,accepet etc 
-                                                                                
+        You must have new iproute2 to use this feature.
+        This adds simple filtering actions like drop, accept etc.
+
 config GACT_PROB
         bool "generic Actions probability"
         depends on NET_ACT_GACT
         ---help---
-        Allows generic actions to be randomly  or deterministically used
+        Allows generic actions to be randomly or deterministically used.
+
+config NET_ACT_MIRRED
+        tristate "Packet In/Egress redirecton/mirror Actions"
+        depends on NET_CLS_ACT
+        ---help---
+        requires new iproute2
+        This allows packets to be mirrored or redirected to netdevices
+
+config NET_ACT_IPT
+        tristate "iptables Actions"
+        depends on NET_CLS_ACT && NETFILTER && IP_NF_IPTABLES
+        ---help---
+        requires new iproute2
+        This allows iptables targets to be used by tc filters
+
+config NET_ACT_PEDIT
+        tristate "Generic Packet Editor Actions"
+        depends on NET_CLS_ACT
+        ---help---
+        requires new iproute2
+        This allows for packets to be generically edited
diff -Nru a/net/sched/Makefile b/net/sched/Makefile
--- a/net/sched/Makefile	2004-12-24 13:36:49 -08:00
+++ b/net/sched/Makefile	2004-12-24 13:36:49 -08:00
@@ -5,12 +5,14 @@
 obj-y	:= sch_generic.o
 
 obj-$(CONFIG_NET_SCHED)		+= sch_api.o sch_fifo.o
-obj-$(CONFIG_NET_ESTIMATOR)	+= estimator.o
 obj-$(CONFIG_NET_CLS)		+= cls_api.o
 obj-$(CONFIG_NET_CLS_ACT)       += act_api.o
 obj-$(CONFIG_NET_ACT_POLICE)	+= police.o
 obj-$(CONFIG_NET_CLS_POLICE)	+= police.o
 obj-$(CONFIG_NET_ACT_GACT)      += gact.o
+obj-$(CONFIG_NET_ACT_MIRRED)    += mirred.o
+obj-$(CONFIG_NET_ACT_IPT)       += ipt.o
+obj-$(CONFIG_NET_ACT_PEDIT)     += pedit.o
 obj-$(CONFIG_NET_SCH_CBQ)	+= sch_cbq.o
 obj-$(CONFIG_NET_SCH_HTB)	+= sch_htb.o
 obj-$(CONFIG_NET_SCH_HPFQ)	+= sch_hpfq.o
diff -Nru a/net/sched/act_api.c b/net/sched/act_api.c
--- a/net/sched/act_api.c	2004-12-24 13:37:43 -08:00
+++ b/net/sched/act_api.c	2004-12-24 13:37:43 -08:00
@@ -13,7 +13,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -31,7 +31,8 @@
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <net/sock.h>
-#include <net/pkt_sched.h>
+#include <net/sch_generic.h>
+#include <net/act_api.h>
 
 #if 1 /* control */
 #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
@@ -87,7 +88,7 @@
 }
 
 /* lookup by name */
-struct tc_action_ops *tc_lookup_action_n(char *kind)
+static struct tc_action_ops *tc_lookup_action_n(char *kind)
 {
 
 	struct tc_action_ops *a = NULL;
@@ -110,7 +111,7 @@
 }
 
 /* lookup by rtattr */
-struct tc_action_ops *tc_lookup_action(struct rtattr *kind)
+static struct tc_action_ops *tc_lookup_action(struct rtattr *kind)
 {
 
 	struct tc_action_ops *a = NULL;
@@ -133,8 +134,9 @@
 	return a;
 }
 
+#if 0
 /* lookup by id */
-struct tc_action_ops *tc_lookup_action_id(u32 type)
+static struct tc_action_ops *tc_lookup_action_id(u32 type)
 {
 	struct tc_action_ops *a = NULL;
 
@@ -154,6 +156,7 @@
 
 	return a;
 }
+#endif
 
 int tcf_action_exec(struct sk_buff *skb,struct tc_action *act, struct tcf_result *res)
 {
@@ -415,14 +418,45 @@
 
 int tcf_action_copy_stats (struct sk_buff *skb,struct tc_action *a)
 {
+	int err;
+	struct gnet_dump d;
+	struct tcf_act_hdr *h = a->priv;
+	
 #ifdef CONFIG_KMOD
 	/* place holder */
 #endif
 
-	if (NULL == a->ops || NULL == a->ops->get_stats)
-		return 1;
+	if (NULL == h)
+		goto errout;
+
+	if (a->type == TCA_OLD_COMPAT)
+		err = gnet_stats_start_copy_compat(skb, TCA_ACT_STATS,
+			TCA_STATS, TCA_XSTATS, h->stats_lock, &d);
+	else
+		err = gnet_stats_start_copy(skb, TCA_ACT_STATS,
+			h->stats_lock, &d);
+
+	if (err < 0)
+		goto errout;
+
+	if (NULL != a->ops && NULL != a->ops->get_stats)
+		if (a->ops->get_stats(skb, a) < 0)
+			goto errout;
+
+	if (gnet_stats_copy_basic(&d, &h->bstats) < 0 ||
+#ifdef CONFIG_NET_ESTIMATOR
+	    gnet_stats_copy_rate_est(&d, &h->rate_est) < 0 ||
+#endif
+	    gnet_stats_copy_queue(&d, &h->qstats) < 0)
+		goto errout;
+
+	if (gnet_stats_finish_copy(&d) < 0)
+		goto errout;
+
+	return 0;
 
-	return a->ops->get_stats(skb,a);
+errout:
+	return -1;
 }
 
 
@@ -480,7 +514,7 @@
 	return err;
 }
 
-int tcf_action_get_1(struct rtattr *rta, struct tc_action *a, struct nlmsghdr *n, u32 pid)
+static int tcf_action_get_1(struct rtattr *rta, struct tc_action *a, struct nlmsghdr *n, u32 pid)
 {
 	struct tc_action_ops *a_o;
 	char act_name[4 + IFNAMSIZ + 1];
@@ -547,7 +581,7 @@
 	return err;
 }
 
-void cleanup_a (struct tc_action *act) 
+static void cleanup_a (struct tc_action *act) 
 {
 	struct tc_action *a;
 
@@ -563,7 +597,7 @@
 	}
 }
 
-struct tc_action_ops *get_ao(struct rtattr *kind, struct tc_action *a)
+static struct tc_action_ops *get_ao(struct rtattr *kind, struct tc_action *a)
 {
 	char act_name[4 + IFNAMSIZ + 1];
 	struct tc_action_ops *a_o = NULL;
@@ -598,7 +632,7 @@
 	return a_o;
 }
 
-struct tc_action *create_a(int i)
+static struct tc_action *create_a(int i)
 {
 	struct tc_action *act = NULL;
 
@@ -615,7 +649,7 @@
 	return act;
 }
 
-int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
+static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
 {
 	struct sk_buff *skb;
 	unsigned char *b;
@@ -685,7 +719,7 @@
 	return err;
 }
 
-int tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event )
+static int tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event )
 {
 
 	int s = 0;
@@ -769,7 +803,7 @@
 }
 
 
-int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, unsigned flags) 
+static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, unsigned flags) 
 {
 	struct tcamsg *t;
 	struct nlmsghdr  *nlh;
@@ -816,7 +850,7 @@
 }
 
 	
-int tcf_action_add(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int ovr ) 
+static int tcf_action_add(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int ovr ) 
 {
 	int ret = 0;
 	struct tc_action *act = NULL;
@@ -899,7 +933,7 @@
 	return ret;
 }
 
-char *
+static char *
 find_dump_kind(struct nlmsghdr *n)
 {
 	struct rtattr *tb1, *tb2[TCA_ACT_MAX+1];
diff -Nru a/net/sched/cls_api.c b/net/sched/cls_api.c
--- a/net/sched/cls_api.c	2004-12-24 13:36:31 -08:00
+++ b/net/sched/cls_api.c	2004-12-24 13:36:31 -08:00
@@ -16,7 +16,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -36,6 +36,7 @@
 #include <linux/kmod.h>
 #include <net/sock.h>
 #include <net/pkt_sched.h>
+#include <net/pkt_cls.h>
 
 #if 0 /* control */
 #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
@@ -52,15 +53,18 @@
 
 /* Find classifier type by string name */
 
-struct tcf_proto_ops * tcf_proto_lookup_ops(struct rtattr *kind)
+static struct tcf_proto_ops * tcf_proto_lookup_ops(struct rtattr *kind)
 {
 	struct tcf_proto_ops *t = NULL;
 
 	if (kind) {
 		read_lock(&cls_mod_lock);
 		for (t = tcf_proto_base; t; t = t->next) {
-			if (rtattr_strcmp(kind, t->kind) == 0)
+			if (rtattr_strcmp(kind, t->kind) == 0) {
+				if (!try_module_get(t->owner))
+					t = NULL;
 				break;
+			}
 		}
 		read_unlock(&cls_mod_lock);
 	}
@@ -230,11 +234,6 @@
 		tp->q = q;
 		tp->classify = tp_ops->classify;
 		tp->classid = parent;
-		err = -EBUSY;
-		if (!try_module_get(tp_ops->owner)) {
-			kfree(tp);
-			goto errout;
-		}
 		if ((err = tp_ops->init(tp)) != 0) {
 			module_put(tp_ops->owner);
 			kfree(tp);
@@ -297,19 +296,6 @@
 	return err;
 }
 
-unsigned long tcf_set_class(struct tcf_proto *tp, unsigned long *clp, 
-			    unsigned long cl)
-{
-	unsigned long old_cl;
-
-	tcf_tree_lock(tp);
-	old_cl = __cls_set_class(clp, cl);
-	tcf_tree_unlock(tp);
-
-	return old_cl;
-}
-
-
 static int
 tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp, unsigned long fh,
 	      u32 pid, u32 seq, unsigned flags, int event)
@@ -475,4 +461,3 @@
 
 EXPORT_SYMBOL(register_tcf_proto_ops);
 EXPORT_SYMBOL(unregister_tcf_proto_ops);
-EXPORT_SYMBOL(tcf_set_class);
diff -Nru a/net/sched/cls_fw.c b/net/sched/cls_fw.c
--- a/net/sched/cls_fw.c	2004-12-24 13:36:47 -08:00
+++ b/net/sched/cls_fw.c	2004-12-24 13:36:47 -08:00
@@ -22,7 +22,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -43,7 +43,8 @@
 #include <net/route.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
-#include <net/pkt_sched.h>
+#include <net/act_api.h>
+#include <net/pkt_cls.h>
 
 struct fw_head
 {
@@ -55,16 +56,16 @@
 	struct fw_filter	*next;
 	u32			id;
 	struct tcf_result	res;
-#ifdef CONFIG_NET_CLS_ACT
-       struct tc_action        *action;
 #ifdef CONFIG_NET_CLS_IND
-       char			indev[IFNAMSIZ];
-#endif
-#else
+	char			indev[IFNAMSIZ];
+#endif /* CONFIG_NET_CLS_IND */
+#ifdef CONFIG_NET_CLS_ACT
+	struct tc_action        *action;
+#else /* CONFIG_NET_CLS_ACT */
 #ifdef CONFIG_NET_CLS_POLICE
 	struct tcf_police	*police;
-#endif
-#endif
+#endif /* CONFIG_NET_CLS_POLICE */
+#endif /* CONFIG_NET_CLS_ACT */
 };
 
 static __inline__ int fw_hash(u32 handle)
@@ -83,47 +84,39 @@
 	u32 id = 0;
 #endif
 
-	if (head == NULL)
-		goto old_method;
-
-	for (f=head->ht[fw_hash(id)]; f; f=f->next) {
-		if (f->id == id) {
-			*res = f->res;
-#ifdef CONFIG_NET_CLS_ACT
+	if (head != NULL) {
+		for (f=head->ht[fw_hash(id)]; f; f=f->next) {
+			if (f->id == id) {
+				*res = f->res;
 #ifdef CONFIG_NET_CLS_IND
-			if (0 != f->indev[0]) {
-				if  (NULL == skb->input_dev) {
+				if (!tcf_match_indev(skb, f->indev))
+					continue;
+#endif /* CONFIG_NET_CLS_IND */
+#ifdef CONFIG_NET_CLS_ACT
+				if (f->action) {
+					int act_res = tcf_action_exec(skb, f->action, res);
+					if (act_res >= 0)
+						return act_res;
 					continue;
-				} else {
-					if (0 != strcmp(f->indev, skb->input_dev->name)) {
-						continue;
-					}
 				}
-			}
-#endif
-                               if (f->action) {
-                                       int pol_res = tcf_action_exec(skb, f->action, res);
-                                       if (pol_res >= 0)
-                                               return pol_res;
-                               } else
-#else
+#else /* CONFIG_NET_CLS_ACT */
 #ifdef CONFIG_NET_CLS_POLICE
-			if (f->police)
-				return tcf_police(skb, f->police);
-#endif
-#endif
+				if (f->police)
+					return tcf_police(skb, f->police);
+#endif /* CONFIG_NET_CLS_POLICE */
+#endif /* CONFIG_NET_CLS_ACT */
+				return 0;
+			}
+		}
+	} else {
+		/* old method */
+		if (id && (TC_H_MAJ(id) == 0 || !(TC_H_MAJ(id^tp->q->handle)))) {
+			res->classid = id;
+			res->class = 0;
 			return 0;
 		}
 	}
-	return -1;
 
-old_method:
-	if (id && (TC_H_MAJ(id) == 0 ||
-		     !(TC_H_MAJ(id^tp->q->handle)))) {
-		res->classid = id;
-		res->class = 0;
-		return 0;
-	}
 	return -1;
 }
 
@@ -162,20 +155,17 @@
 
 	for (h=0; h<256; h++) {
 		while ((f=head->ht[h]) != NULL) {
-			unsigned long cl;
 			head->ht[h] = f->next;
-
-			if ((cl = __cls_set_class(&f->res.class, 0)) != 0)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+			tcf_unbind_filter(tp, &f->res);
 #ifdef CONFIG_NET_CLS_ACT
-       if (f->action) {
-               tcf_action_destroy(f->action,TCA_ACT_UNBIND);
-       }
-#else
+			if (f->action)
+				tcf_action_destroy(f->action, TCA_ACT_UNBIND);
+#else /* CONFIG_NET_CLS_ACT */
 #ifdef CONFIG_NET_CLS_POLICE
-			tcf_police_release(f->police,TCA_ACT_UNBIND);
-#endif
-#endif
+			if (f->police)
+				tcf_police_release(f->police, TCA_ACT_UNBIND);
+#endif /* CONFIG_NET_CLS_POLICE */
+#endif /* CONFIG_NET_CLS_ACT */
 
 			kfree(f);
 		}
@@ -194,23 +184,18 @@
 
 	for (fp=&head->ht[fw_hash(f->id)]; *fp; fp = &(*fp)->next) {
 		if (*fp == f) {
-			unsigned long cl;
-
 			tcf_tree_lock(tp);
 			*fp = f->next;
 			tcf_tree_unlock(tp);
-
-			if ((cl = cls_set_class(tp, &f->res.class, 0)) != 0)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+			tcf_unbind_filter(tp, &f->res);
 #ifdef CONFIG_NET_CLS_ACT
-       if (f->action) {
-               tcf_action_destroy(f->action,TCA_ACT_UNBIND);
-       }
-#else
+			if (f->action)
+				tcf_action_destroy(f->action,TCA_ACT_UNBIND);
+#else /* CONFIG_NET_CLS_ACT */
 #ifdef CONFIG_NET_CLS_POLICE
 			tcf_police_release(f->police,TCA_ACT_UNBIND);
-#endif
-#endif
+#endif /* CONFIG_NET_CLS_POLICE */
+#endif /* CONFIG_NET_CLS_ACT */
 			kfree(f);
 			return 0;
 		}
@@ -219,21 +204,67 @@
 	return -EINVAL;
 }
 
+static int
+fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
+	struct rtattr **tb, struct rtattr **tca, unsigned long base)
+{
+	int err = -EINVAL;
+
+	if (tb[TCA_FW_CLASSID-1]) {
+		if (RTA_PAYLOAD(tb[TCA_FW_CLASSID-1]) != sizeof(u32))
+			goto errout;
+		f->res.classid = *(u32*)RTA_DATA(tb[TCA_FW_CLASSID-1]);
+		tcf_bind_filter(tp, &f->res, base);
+	}
+
+#ifdef CONFIG_NET_CLS_IND
+	if (tb[TCA_FW_INDEV-1]) {
+		err = tcf_change_indev(tp, f->indev, tb[TCA_FW_INDEV-1]);
+		if (err < 0)
+			goto errout;
+	}
+#endif /* CONFIG_NET_CLS_IND */
+
+#ifdef CONFIG_NET_CLS_ACT
+	if (tb[TCA_FW_POLICE-1]) {
+		err = tcf_change_act_police(tp, &f->action, tb[TCA_FW_POLICE-1],
+			tca[TCA_RATE-1]);
+		if (err < 0)
+			goto errout;
+	}
+
+	if (tb[TCA_FW_ACT-1]) {
+		err = tcf_change_act(tp, &f->action, tb[TCA_FW_ACT-1],
+			tca[TCA_RATE-1]);
+		if (err < 0)
+			goto errout;
+	}
+#else /* CONFIG_NET_CLS_ACT */
+#ifdef CONFIG_NET_CLS_POLICE
+	if (tb[TCA_FW_POLICE-1]) {
+		err = tcf_change_police(tp, &f->police, tb[TCA_FW_POLICE-1],
+			tca[TCA_RATE-1]);
+		if (err < 0)
+			goto errout;
+	}
+#endif /* CONFIG_NET_CLS_POLICE */
+#endif /* CONFIG_NET_CLS_ACT */
+
+	err = 0;
+errout:
+	return err;
+}
+
 static int fw_change(struct tcf_proto *tp, unsigned long base,
 		     u32 handle,
 		     struct rtattr **tca,
 		     unsigned long *arg)
 {
 	struct fw_head *head = (struct fw_head*)tp->root;
-	struct fw_filter *f;
+	struct fw_filter *f = (struct fw_filter *) *arg;
 	struct rtattr *opt = tca[TCA_OPTIONS-1];
 	struct rtattr *tb[TCA_FW_MAX];
 	int err;
-#ifdef CONFIG_NET_CLS_ACT
-       struct tc_action *act = NULL;
-       int ret;
-#endif
-
 
 	if (!opt)
 		return handle ? -EINVAL : 0;
@@ -241,85 +272,10 @@
 	if (rtattr_parse(tb, TCA_FW_MAX, RTA_DATA(opt), RTA_PAYLOAD(opt)) < 0)
 		return -EINVAL;
 
-	if ((f = (struct fw_filter*)*arg) != NULL) {
-		/* Node exists: adjust only classid */
-
+	if (f != NULL) {
 		if (f->id != handle && handle)
 			return -EINVAL;
-		if (tb[TCA_FW_CLASSID-1]) {
-			unsigned long cl;
-
-			f->res.classid = *(u32*)RTA_DATA(tb[TCA_FW_CLASSID-1]);
-			cl = tp->q->ops->cl_ops->bind_tcf(tp->q, base, f->res.classid);
-			cl = cls_set_class(tp, &f->res.class, cl);
-			if (cl)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
-		}
-#ifdef CONFIG_NET_CLS_ACT
-		if (tb[TCA_FW_POLICE-1]) {
-			act = kmalloc(sizeof(*act),GFP_KERNEL);
-			if (NULL == act)
-				return -ENOMEM;
-
-			memset(act,0,sizeof(*act));
-			ret = tcf_action_init_1(tb[TCA_FW_POLICE-1], tca[TCA_RATE-1] ,act,"police",TCA_ACT_NOREPLACE,TCA_ACT_BIND);
-			if (0 > ret){
-				tcf_action_destroy(act,TCA_ACT_UNBIND);
-				return ret;
-			}
-			act->type = TCA_OLD_COMPAT;
-
-			sch_tree_lock(tp->q);
-			act = xchg(&f->action, act);
-			sch_tree_unlock(tp->q);
-
-			tcf_action_destroy(act,TCA_ACT_UNBIND);
-
-		}
-
-		if(tb[TCA_FW_ACT-1]) {
-			act = kmalloc(sizeof(*act),GFP_KERNEL);
-			if (NULL == act)
-				return -ENOMEM;
-			memset(act,0,sizeof(*act));
-			ret = tcf_action_init(tb[TCA_FW_ACT-1], tca[TCA_RATE-1],act,NULL, TCA_ACT_NOREPLACE,TCA_ACT_BIND);
-			if (0 > ret) {
-				tcf_action_destroy(act,TCA_ACT_UNBIND);
-				return ret;
-			}
-
-			sch_tree_lock(tp->q);
-			act = xchg(&f->action, act);
-			sch_tree_unlock(tp->q);
-
-			tcf_action_destroy(act,TCA_ACT_UNBIND);
-		}
-#ifdef CONFIG_NET_CLS_IND
-		if(tb[TCA_FW_INDEV-1]) {
-			struct rtattr *idev = tb[TCA_FW_INDEV-1];
-			if (RTA_PAYLOAD(idev) >= IFNAMSIZ) {
-				printk("cls_fw: bad indev name %s\n",(char*)RTA_DATA(idev));
-				err = -EINVAL;
-				goto errout;
-			}
-			memset(f->indev,0,IFNAMSIZ);
-			sprintf(f->indev, "%s", (char*)RTA_DATA(idev));
-		}
-#endif
-#else /* only POLICE defined */
-#ifdef CONFIG_NET_CLS_POLICE
-		if (tb[TCA_FW_POLICE-1]) {
-			struct tcf_police *police = tcf_police_locate(tb[TCA_FW_POLICE-1], tca[TCA_RATE-1]);
-
-			tcf_tree_lock(tp);
-			police = xchg(&f->police, police);
-			tcf_tree_unlock(tp);
-
-			tcf_police_release(police,TCA_ACT_UNBIND);
-		}
-#endif
-#endif
-		return 0;
+		return fw_change_attrs(tp, f, tb, tca, base);
 	}
 
 	if (!handle)
@@ -343,45 +299,9 @@
 
 	f->id = handle;
 
-	if (tb[TCA_FW_CLASSID-1]) {
-		err = -EINVAL;
-		if (RTA_PAYLOAD(tb[TCA_FW_CLASSID-1]) != 4)
-			goto errout;
-		f->res.classid = *(u32*)RTA_DATA(tb[TCA_FW_CLASSID-1]);
-		cls_set_class(tp, &f->res.class, tp->q->ops->cl_ops->bind_tcf(tp->q, base, f->res.classid));
-	}
-
-#ifdef CONFIG_NET_CLS_ACT
-	if(tb[TCA_FW_ACT-1]) {
-		act = kmalloc(sizeof(*act),GFP_KERNEL);
-		if (NULL == act)
-			return -ENOMEM;
-		memset(act,0,sizeof(*act));
-		ret = tcf_action_init(tb[TCA_FW_ACT-1], tca[TCA_RATE-1],act,NULL,TCA_ACT_NOREPLACE,TCA_ACT_BIND);
-		if (0 > ret) {
-			tcf_action_destroy(act,TCA_ACT_UNBIND);
-			return ret;
-		}
-		f->action= act;
-	}
-#ifdef CONFIG_NET_CLS_IND
-		if(tb[TCA_FW_INDEV-1]) {
-			struct rtattr *idev = tb[TCA_FW_INDEV-1];
-			if (RTA_PAYLOAD(idev) >= IFNAMSIZ) {
-				printk("cls_fw: bad indev name %s\n",(char*)RTA_DATA(idev));
-				err = -EINVAL;
-				goto errout;
-			}
-			memset(f->indev,0,IFNAMSIZ);
-			sprintf(f->indev, "%s", (char*)RTA_DATA(idev));
-		}
-#endif
-#else
-#ifdef CONFIG_NET_CLS_POLICE
-	if (tb[TCA_FW_POLICE-1])
-		f->police = tcf_police_locate(tb[TCA_FW_POLICE-1], tca[TCA_RATE-1]);
-#endif
-#endif
+	err = fw_change_attrs(tp, f, tb, tca, base);
+	if (err < 0)
+		goto errout;
 
 	f->next = head->ht[fw_hash(handle)];
 	tcf_tree_lock(tp);
@@ -418,7 +338,7 @@
 			}
 			if (arg->fn(tp, (unsigned long)f, arg) < 0) {
 				arg->stop = 1;
-				break;
+				return;
 			}
 			arg->count++;
 		}
@@ -437,15 +357,15 @@
 
 	t->tcm_handle = f->id;
 
-       if (!f->res.classid
+	if (!f->res.classid
 #ifdef CONFIG_NET_CLS_ACT
-           && !f->action
+		&& !f->action
 #else
 #ifdef CONFIG_NET_CLS_POLICE
-           && !f->police
+		&& !f->police
 #endif
 #endif
-           )
+		)
 		return skb->len;
 
 	rta = (struct rtattr*)b;
@@ -453,65 +373,33 @@
 
 	if (f->res.classid)
 		RTA_PUT(skb, TCA_FW_CLASSID, 4, &f->res.classid);
-#ifdef CONFIG_NET_CLS_ACT
-               /* again for backward compatible mode - we want
-               *  to work with both old and new modes of entering
-               *  tc data even if iproute2  was newer - jhs
-               */
-	if (f->action) {
-		struct rtattr * p_rta = (struct rtattr*)skb->tail;
-
-		if (f->action->type != TCA_OLD_COMPAT) {
-			RTA_PUT(skb, TCA_FW_ACT, 0, NULL);
-			if (tcf_action_dump(skb,f->action,0,0) < 0) {
-				goto rtattr_failure;
-			}
-		} else {
-			RTA_PUT(skb, TCA_FW_POLICE, 0, NULL);
-			if (tcf_action_dump_old(skb,f->action,0,0) < 0) {
-				goto rtattr_failure;
-			}
-		}
-
-		p_rta->rta_len = skb->tail - (u8*)p_rta;
-	}
 #ifdef CONFIG_NET_CLS_IND
-	if(strlen(f->indev)) {
-		struct rtattr * p_rta = (struct rtattr*)skb->tail;
+	if (strlen(f->indev))
 		RTA_PUT(skb, TCA_FW_INDEV, IFNAMSIZ, f->indev);
-		p_rta->rta_len = skb->tail - (u8*)p_rta;
-	}
-#endif
-#else
+#endif /* CONFIG_NET_CLS_IND */
+#ifdef CONFIG_NET_CLS_ACT
+	if (tcf_dump_act(skb, f->action, TCA_FW_ACT, TCA_FW_POLICE) < 0)
+		goto rtattr_failure;
+#else /* CONFIG_NET_CLS_ACT */
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		struct rtattr * p_rta = (struct rtattr*)skb->tail;
-
-		RTA_PUT(skb, TCA_FW_POLICE, 0, NULL);
-
-		if (tcf_police_dump(skb, f->police) < 0)
-			goto rtattr_failure;
-
-		p_rta->rta_len = skb->tail - (u8*)p_rta;
-	}
-#endif
-#endif
+	if (tcf_dump_police(skb, f->police, TCA_FW_POLICE) < 0)
+		goto rtattr_failure;
+#endif /* CONFIG_NET_CLS_POLICE */
+#endif /* CONFIG_NET_CLS_ACT */
 
 	rta->rta_len = skb->tail - b;
 #ifdef CONFIG_NET_CLS_ACT
-       if (f->action && f->action->type == TCA_OLD_COMPAT) {
-               if (tcf_action_copy_stats(skb,f->action))
-                       goto rtattr_failure;
-       }
-#else
-#ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		if (qdisc_copy_stats(skb, &f->police->stats,
-				     f->police->stats_lock))
+	if (f->action && f->action->type == TCA_OLD_COMPAT) {
+		if (tcf_action_copy_stats(skb,f->action))
 			goto rtattr_failure;
 	}
-#endif
-#endif
+#else /* CONFIG_NET_CLS_ACT */
+#ifdef CONFIG_NET_CLS_POLICE
+	if (f->police)
+		if (tcf_police_dump_stats(skb, f->police) < 0)
+			goto rtattr_failure;
+#endif /* CONFIG_NET_CLS_POLICE */
+#endif /* CONFIG_NET_CLS_ACT */
 	return skb->len;
 
 rtattr_failure:
diff -Nru a/net/sched/cls_route.c b/net/sched/cls_route.c
--- a/net/sched/cls_route.c	2004-12-24 13:36:32 -08:00
+++ b/net/sched/cls_route.c	2004-12-24 13:36:32 -08:00
@@ -13,7 +13,7 @@
 #include <linux/config.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -33,7 +33,8 @@
 #include <net/route.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
-#include <net/pkt_sched.h>
+#include <net/act_api.h>
+#include <net/pkt_cls.h>
 
 /*
    1. For now we assume that route tags < 256.
@@ -291,11 +292,8 @@
 				struct route4_filter *f;
 
 				while ((f = b->ht[h2]) != NULL) {
-					unsigned long cl;
-
 					b->ht[h2] = f->next;
-					if ((cl = __cls_set_class(&f->res.class, 0)) != 0)
-						tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+					tcf_unbind_filter(tp, &f->res);
 #ifdef CONFIG_NET_CLS_POLICE
 					tcf_police_release(f->police,TCA_ACT_UNBIND);
 #endif
@@ -324,17 +322,12 @@
 
 	for (fp = &b->ht[from_hash(h>>16)]; *fp; fp = &(*fp)->next) {
 		if (*fp == f) {
-			unsigned long cl;
-
 			tcf_tree_lock(tp);
 			*fp = f->next;
 			tcf_tree_unlock(tp);
 
 			route4_reset_fastmap(tp->q->dev, head, f->id);
-
-			if ((cl = cls_set_class(tp, &f->res.class, 0)) != 0)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
-
+			tcf_unbind_filter(tp, &f->res);
 #ifdef CONFIG_NET_CLS_POLICE
 			tcf_police_release(f->police,TCA_ACT_UNBIND);
 #endif
@@ -378,27 +371,18 @@
 		return -EINVAL;
 
 	if ((f = (struct route4_filter*)*arg) != NULL) {
-		/* Node exists: adjust only classid */
-
 		if (f->handle != handle && handle)
 			return -EINVAL;
 		if (tb[TCA_ROUTE4_CLASSID-1]) {
-			unsigned long cl;
-
 			f->res.classid = *(u32*)RTA_DATA(tb[TCA_ROUTE4_CLASSID-1]);
-			cl = cls_set_class(tp, &f->res.class, tp->q->ops->cl_ops->bind_tcf(tp->q, base, f->res.classid));
-			if (cl)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+			tcf_bind_filter(tp, &f->res, base);
 		}
 #ifdef CONFIG_NET_CLS_POLICE
 		if (tb[TCA_ROUTE4_POLICE-1]) {
-			struct tcf_police *police = tcf_police_locate(tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]);
-
-			tcf_tree_lock(tp);
-			police = xchg(&f->police, police);
-			tcf_tree_unlock(tp);
-
-			tcf_police_release(police,TCA_ACT_UNBIND);
+			err = tcf_change_police(tp, &f->police,
+				tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]);
+			if (err < 0)
+				return err;
 		}
 #endif
 		return 0;
@@ -491,10 +475,10 @@
 			goto errout;
 	}
 
-	cls_set_class(tp, &f->res.class, tp->q->ops->cl_ops->bind_tcf(tp->q, base, f->res.classid));
+	tcf_bind_filter(tp, &f->res, base);
 #ifdef CONFIG_NET_CLS_POLICE
 	if (tb[TCA_ROUTE4_POLICE-1])
-		f->police = tcf_police_locate(tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]);
+		tcf_change_police(tp, &f->police, tb[TCA_ROUTE4_POLICE-1], tca[TCA_RATE-1]);
 #endif
 
 	f->next = f1;
@@ -537,7 +521,7 @@
 					}
 					if (arg->fn(tp, (unsigned long)f, arg) < 0) {
 						arg->stop = 1;
-						break;
+						return;
 					}
 					arg->count++;
 				}
@@ -576,25 +560,15 @@
 	if (f->res.classid)
 		RTA_PUT(skb, TCA_ROUTE4_CLASSID, 4, &f->res.classid);
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		struct rtattr * p_rta = (struct rtattr*)skb->tail;
-
-		RTA_PUT(skb, TCA_ROUTE4_POLICE, 0, NULL);
-
-		if (tcf_police_dump(skb, f->police) < 0)
-			goto rtattr_failure;
-
-		p_rta->rta_len = skb->tail - (u8*)p_rta;
-	}
+	if (tcf_dump_police(skb, f->police, TCA_ROUTE4_POLICE) < 0)
+		goto rtattr_failure;
 #endif
 
 	rta->rta_len = skb->tail - b;
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		if (qdisc_copy_stats(skb, &f->police->stats,
-				     f->police->stats_lock))
+	if (f->police)
+		if (tcf_police_dump_stats(skb, f->police) < 0)
 			goto rtattr_failure;
-	}
 #endif
 	return skb->len;
 
diff -Nru a/net/sched/cls_rsvp.c b/net/sched/cls_rsvp.c
--- a/net/sched/cls_rsvp.c	2004-12-24 13:36:47 -08:00
+++ b/net/sched/cls_rsvp.c	2004-12-24 13:36:47 -08:00
@@ -12,7 +12,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -32,7 +32,8 @@
 #include <net/route.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
-#include <net/pkt_sched.h>
+#include <net/act_api.h>
+#include <net/pkt_cls.h>
 
 #define RSVP_DST_LEN	1
 #define RSVP_ID		"rsvp"
diff -Nru a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
--- a/net/sched/cls_rsvp.h	2004-12-24 13:36:18 -08:00
+++ b/net/sched/cls_rsvp.h	2004-12-24 13:36:18 -08:00
@@ -272,11 +272,8 @@
 				struct rsvp_filter *f;
 
 				while ((f = s->ht[h2]) != NULL) {
-					unsigned long cl;
-
 					s->ht[h2] = f->next;
-					if ((cl = __cls_set_class(&f->res.class, 0)) != 0)
-						tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+					tcf_unbind_filter(tp, &f->res);
 #ifdef CONFIG_NET_CLS_POLICE
 					tcf_police_release(f->police,TCA_ACT_UNBIND);
 #endif
@@ -299,16 +296,10 @@
 
 	for (fp = &s->ht[(h>>8)&0xFF]; *fp; fp = &(*fp)->next) {
 		if (*fp == f) {
-			unsigned long cl;
-
-
 			tcf_tree_lock(tp);
 			*fp = f->next;
 			tcf_tree_unlock(tp);
-
-			if ((cl = cls_set_class(tp, &f->res.class, 0)) != 0)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
-
+			tcf_unbind_filter(tp, &f->res);
 #ifdef CONFIG_NET_CLS_POLICE
 			tcf_police_release(f->police,TCA_ACT_UNBIND);
 #endif
@@ -437,22 +428,15 @@
 		if (f->handle != handle && handle)
 			return -EINVAL;
 		if (tb[TCA_RSVP_CLASSID-1]) {
-			unsigned long cl;
-
 			f->res.classid = *(u32*)RTA_DATA(tb[TCA_RSVP_CLASSID-1]);
-			cl = cls_set_class(tp, &f->res.class, tp->q->ops->cl_ops->bind_tcf(tp->q, base, f->res.classid));
-			if (cl)
-				tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+			tcf_bind_filter(tp, &f->res, base);
 		}
 #ifdef CONFIG_NET_CLS_POLICE
 		if (tb[TCA_RSVP_POLICE-1]) {
-			struct tcf_police *police = tcf_police_locate(tb[TCA_RSVP_POLICE-1], tca[TCA_RATE-1]);
-
-			tcf_tree_lock(tp);
-			police = xchg(&f->police, police);
-			tcf_tree_unlock(tp);
-
-			tcf_police_release(police,TCA_ACT_UNBIND);
+			err = tcf_change_police(tp, &f->police,
+				tb[TCA_RSVP_POLICE-1], tca[TCA_RATE-1]);
+			if (err < 0)
+				return err;
 		}
 #endif
 		return 0;
@@ -531,10 +515,10 @@
 
 			f->sess = s;
 			if (f->tunnelhdr == 0)
-				cls_set_class(tp, &f->res.class, tp->q->ops->cl_ops->bind_tcf(tp->q, base, f->res.classid));
+				tcf_bind_filter(tp, &f->res, base);
 #ifdef CONFIG_NET_CLS_POLICE
 			if (tb[TCA_RSVP_POLICE-1])
-				f->police = tcf_police_locate(tb[TCA_RSVP_POLICE-1], tca[TCA_RATE-1]);
+				tcf_change_police(tp, &f->police, tb[TCA_RSVP_POLICE-1], tca[TCA_RATE-1]);
 #endif
 
 			for (fp = &s->ht[h2]; *fp; fp = &(*fp)->next)
@@ -601,7 +585,7 @@
 					}
 					if (arg->fn(tp, (unsigned long)f, arg) < 0) {
 						arg->stop = 1;
-						break;
+						return;
 					}
 					arg->count++;
 				}
@@ -641,25 +625,15 @@
 	if (((f->handle>>8)&0xFF) != 16)
 		RTA_PUT(skb, TCA_RSVP_SRC, sizeof(f->src), f->src);
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		struct rtattr * p_rta = (struct rtattr*)skb->tail;
-
-		RTA_PUT(skb, TCA_RSVP_POLICE, 0, NULL);
-
-		if (tcf_police_dump(skb, f->police) < 0)
-			goto rtattr_failure;
-
-		p_rta->rta_len = skb->tail - (u8*)p_rta;
-	}
+	if (tcf_dump_police(skb, f->police, TCA_RSVP_POLICE) < 0)
+		goto rtattr_failure;
 #endif
 
 	rta->rta_len = skb->tail - b;
 #ifdef CONFIG_NET_CLS_POLICE
-	if (f->police) {
-		if (qdisc_copy_stats(skb, &f->police->stats,
-				     f->police->stats_lock))
+	if (f->police)
+		if (tcf_police_dump_stats(skb, f->police) < 0)
 			goto rtattr_failure;
-	}
 #endif
 	return skb->len;
 
diff -Nru a/net/sched/cls_rsvp6.c b/net/sched/cls_rsvp6.c
--- a/net/sched/cls_rsvp6.c	2004-12-24 13:37:02 -08:00
+++ b/net/sched/cls_rsvp6.c	2004-12-24 13:37:02 -08:00
@@ -12,7 +12,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -33,7 +33,8 @@
 #include <net/route.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
-#include <net/pkt_sched.h>
+#include <net/act_api.h>
+#include <net/pkt_cls.h>
 
 #define RSVP_DST_LEN	4
 #define RSVP_ID		"rsvp6"
diff -Nru a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
--- a/net/sched/cls_tcindex.c	2004-12-24 13:36:48 -08:00
+++ b/net/sched/cls_tcindex.c	2004-12-24 13:36:48 -08:00
@@ -12,7 +12,8 @@
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <net/ip.h>
-#include <net/pkt_sched.h>
+#include <net/act_api.h>
+#include <net/pkt_cls.h>
 #include <net/route.h>
 
 
@@ -159,12 +160,12 @@
 }
 
 
-static int tcindex_delete(struct tcf_proto *tp, unsigned long arg)
+static int
+__tcindex_delete(struct tcf_proto *tp, unsigned long arg, int lock)
 {
 	struct tcindex_data *p = PRIV(tp);
 	struct tcindex_filter_result *r = (struct tcindex_filter_result *) arg;
 	struct tcindex_filter *f = NULL;
-	unsigned long cl;
 
 	DPRINTK("tcindex_delete(tp %p,arg 0x%lx),p %p,f %p\n",tp,arg,p,f);
 	if (p->perfect) {
@@ -182,13 +183,13 @@
 
 found:
 		f = *walk;
-		tcf_tree_lock(tp); 
+		if (lock)
+			tcf_tree_lock(tp);
 		*walk = f->next;
-		tcf_tree_unlock(tp);
+		if (lock)
+			tcf_tree_unlock(tp);
 	}
-	cl = __cls_set_class(&r->res.class,0);
-	if (cl)
-		tp->q->ops->cl_ops->unbind_tcf(tp->q,cl);
+	tcf_unbind_filter(tp, &r->res);
 #ifdef CONFIG_NET_CLS_POLICE
 	tcf_police_release(r->police, TCA_ACT_UNBIND);
 #endif
@@ -197,6 +198,10 @@
 	return 0;
 }
 
+static int tcindex_delete(struct tcf_proto *tp, unsigned long arg)
+{
+	return __tcindex_delete(tp, arg, 1);
+}
 
 /*
  * There are no parameters for tcindex_init, so we overload tcindex_change
@@ -312,28 +317,19 @@
 	}
 	DPRINTK("r=%p\n",r);
 	if (tb[TCA_TCINDEX_CLASSID-1]) {
-		unsigned long cl = cls_set_class(tp,&r->res.class,0);
-
-		if (cl)
-			tp->q->ops->cl_ops->unbind_tcf(tp->q,cl);
 		r->res.classid = *(__u32 *) RTA_DATA(tb[TCA_TCINDEX_CLASSID-1]);
-		r->res.class = tp->q->ops->cl_ops->bind_tcf(tp->q,base,
-							    r->res.classid);
+		tcf_bind_filter(tp, &r->res, base);
+
 		if (!r->res.class) {
 			r->res.classid = 0;
 			return -ENOENT;
 		}
-        }
+	}
 #ifdef CONFIG_NET_CLS_POLICE
-	{
-		struct tcf_police *police;
-
-		police = tb[TCA_TCINDEX_POLICE-1] ?
-		    tcf_police_locate(tb[TCA_TCINDEX_POLICE-1],NULL) : NULL;
-		tcf_tree_lock(tp);
-		police = xchg(&r->police,police);
-		tcf_tree_unlock(tp);
-		tcf_police_release(police,TCA_ACT_UNBIND);
+	if (tb[TCA_TCINDEX_POLICE-1]) {
+		int err = tcf_change_police(tp, &r->police, tb[TCA_TCINDEX_POLICE-1], NULL);
+		if (err < 0)
+			return err;
 	}
 #endif
 	if (r != &new_filter_result)
@@ -395,7 +391,7 @@
 static int tcindex_destroy_element(struct tcf_proto *tp,
     unsigned long arg, struct tcf_walker *walker)
 {
-	return tcindex_delete(tp,arg);
+	return __tcindex_delete(tp, arg, 0);
 }
 
 
@@ -458,14 +454,8 @@
 		if (r->res.class)
 			RTA_PUT(skb, TCA_TCINDEX_CLASSID, 4, &r->res.classid);
 #ifdef CONFIG_NET_CLS_POLICE
-		if (r->police) {
-			struct rtattr *p_rta = (struct rtattr *) skb->tail;
-
-			RTA_PUT(skb,TCA_TCINDEX_POLICE,0,NULL);
-			if (tcf_police_dump(skb,r->police) < 0)
-				goto rtattr_failure;
-			p_rta->rta_len = skb->tail-(u8 *) p_rta;
-		}
+		if (tcf_dump_police(skb, r->police, TCA_TCINDEX_POLICE) < 0)
+			goto rtattr_failure;
 #endif
 	}
 	rta->rta_len = skb->tail-b;
diff -Nru a/net/sched/cls_u32.c b/net/sched/cls_u32.c
--- a/net/sched/cls_u32.c	2004-12-24 13:36:31 -08:00
+++ b/net/sched/cls_u32.c	2004-12-24 13:36:31 -08:00
@@ -31,7 +31,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -54,7 +54,8 @@
 #include <net/route.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
-#include <net/pkt_sched.h>
+#include <net/act_api.h>
+#include <net/pkt_cls.h>
 
 
 struct tc_u_knode
@@ -88,7 +89,6 @@
 	struct tc_u_common	*tp_c;
 	int			refcnt;
 	unsigned		divisor;
-	u32			hgenerator;
 	struct tc_u_knode	*ht[1];
 };
 
@@ -156,18 +156,9 @@
 
 				*res = n->res;
 #ifdef CONFIG_NET_CLS_IND
-				/* yes, i know it sucks but the feature is 
-				** optional dammit! - JHS */
-				if (0 != n->indev[0]) {
-					if  (NULL == skb->input_dev) {
-						n = n->next;
-						goto next_knode;
-					} else {
-						if (0 != strcmp(n->indev, skb->input_dev->name)) {
-							n = n->next;
-							goto next_knode;
-						}
-					}
+				if (!tcf_match_indev(skb, n->indev)) {
+					n = n->next;
+					goto next_knode;
 				}
 #endif
 #ifdef CONFIG_CLS_U32_PERF
@@ -346,10 +337,7 @@
 
 static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n)
 {
-	unsigned long cl;
-
-	if ((cl = __cls_set_class(&n->res.class, 0)) != 0)
-		tp->q->ops->cl_ops->unbind_tcf(tp->q, cl);
+	tcf_unbind_filter(tp, &n->res);
 #ifdef CONFIG_NET_CLS_ACT
 	if (n->action) {
 		tcf_action_destroy(n->action, TCA_ACT_UNBIND);
@@ -495,15 +483,11 @@
 	return handle|(i>0xFFF ? 0xFFF : i);
 }
 
-static int u32_set_parms(struct Qdisc *q, unsigned long base,
+static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
 			 struct tc_u_hnode *ht,
 			 struct tc_u_knode *n, struct rtattr **tb,
 			 struct rtattr *est)
 {
-#ifdef CONFIG_NET_CLS_ACT
-	struct tc_action *act = NULL;
-	int ret;
-#endif
 	if (tb[TCA_U32_LINK-1]) {
 		u32 handle = *(u32*)RTA_DATA(tb[TCA_U32_LINK-1]);
 		struct tc_u_hnode *ht_down = NULL;
@@ -519,88 +503,43 @@
 			ht_down->refcnt++;
 		}
 
-		sch_tree_lock(q);
+		tcf_tree_lock(tp);
 		ht_down = xchg(&n->ht_down, ht_down);
-		sch_tree_unlock(q);
+		tcf_tree_unlock(tp);
 
 		if (ht_down)
 			ht_down->refcnt--;
 	}
 	if (tb[TCA_U32_CLASSID-1]) {
-		unsigned long cl;
-
 		n->res.classid = *(u32*)RTA_DATA(tb[TCA_U32_CLASSID-1]);
-		sch_tree_lock(q);
-		cl = __cls_set_class(&n->res.class, q->ops->cl_ops->bind_tcf(q, base, n->res.classid));
-		sch_tree_unlock(q);
-		if (cl)
-			q->ops->cl_ops->unbind_tcf(q, cl);
+		tcf_bind_filter(tp, &n->res, base);
 	}
 #ifdef CONFIG_NET_CLS_ACT
-	/*backward compatibility */
-	if (tb[TCA_U32_POLICE-1])
-	{
-		act = kmalloc(sizeof(*act),GFP_KERNEL);
-		if (NULL == act)
-			return -ENOMEM;
-
-		memset(act,0,sizeof(*act));
-		ret = tcf_action_init_1(tb[TCA_U32_POLICE-1], est,act,"police", TCA_ACT_NOREPLACE, TCA_ACT_BIND);
-		if (0 > ret){
-			tcf_action_destroy(act, TCA_ACT_UNBIND);
-			return ret;
-		}
-		act->type = TCA_OLD_COMPAT;
-
-		sch_tree_lock(q);
-		act = xchg(&n->action, act);
-		sch_tree_unlock(q);
-
-		tcf_action_destroy(act, TCA_ACT_UNBIND);
-
+	if (tb[TCA_U32_POLICE-1]) {
+		int err = tcf_change_act_police(tp, &n->action, tb[TCA_U32_POLICE-1], est);
+		if (err < 0)
+			return err;
 	}
 
-	if(tb[TCA_U32_ACT-1]) {
-		act = kmalloc(sizeof(*act),GFP_KERNEL);
-		if (NULL == act)
-			return -ENOMEM;
-		memset(act,0,sizeof(*act));
-		ret = tcf_action_init(tb[TCA_U32_ACT-1], est,act,NULL,TCA_ACT_NOREPLACE, TCA_ACT_BIND);
-		if (0 > ret) {
-			tcf_action_destroy(act, TCA_ACT_UNBIND);
-			return ret;
-		}
-
-		sch_tree_lock(q);
-		act = xchg(&n->action, act);
-		sch_tree_unlock(q);
-
-		tcf_action_destroy(act, TCA_ACT_UNBIND);
+	if (tb[TCA_U32_ACT-1]) {
+		int err = tcf_change_act(tp, &n->action, tb[TCA_U32_ACT-1], est);
+		if (err < 0)
+			return err;
 	}
-
-
 #else
 #ifdef CONFIG_NET_CLS_POLICE
 	if (tb[TCA_U32_POLICE-1]) {
-		struct tcf_police *police = tcf_police_locate(tb[TCA_U32_POLICE-1], est);
-		sch_tree_lock(q);
-		police = xchg(&n->police, police);
-		sch_tree_unlock(q);
-		tcf_police_release(police, TCA_ACT_UNBIND);
+		int err = tcf_change_police(tp, &n->police, tb[TCA_U32_POLICE-1], est);
+		if (err < 0)
+			return err;
 	}
 #endif
 #endif
 #ifdef CONFIG_NET_CLS_IND
-	n->indev[0] = 0;
-	if(tb[TCA_U32_INDEV-1]) {
-		struct rtattr *input_dev = tb[TCA_U32_INDEV-1];
-		if (RTA_PAYLOAD(input_dev) >= IFNAMSIZ) {
-			printk("cls_u32: bad indev name %s\n",(char*)RTA_DATA(input_dev));
-			/* should we clear state first? */
-			return  -EINVAL;
-		}
-		sprintf(n->indev, "%s", (char*)RTA_DATA(input_dev));
-		printk("got IND %s\n",n->indev);
+	if (tb[TCA_U32_INDEV-1]) {
+		int err = tcf_change_indev(tp, n->indev, tb[TCA_U32_INDEV-1]);
+		if (err < 0)
+			return err;
 	}
 #endif
 
@@ -630,7 +569,7 @@
 		if (TC_U32_KEY(n->handle) == 0)
 			return -EINVAL;
 
-		return u32_set_parms(tp->q, base, n->ht_up, n, tb, tca[TCA_RATE-1]);
+		return u32_set_parms(tp, base, n->ht_up, n, tb, tca[TCA_RATE-1]);
 	}
 
 	if (tb[TCA_U32_DIVISOR-1]) {
@@ -718,7 +657,7 @@
 	}
 	n->fshift = i;
 }
-	err = u32_set_parms(tp->q, base, ht, n, tb, tca[TCA_RATE-1]);
+	err = u32_set_parms(tp, base, ht, n, tb, tca[TCA_RATE-1]);
 	if (err == 0) {
 		struct tc_u_knode **ins;
 		for (ins = &ht->ht[TC_U32_HASH(handle)]; *ins; ins = &(*ins)->next)
@@ -806,49 +745,18 @@
 		if (n->ht_down)
 			RTA_PUT(skb, TCA_U32_LINK, 4, &n->ht_down->handle);
 #ifdef CONFIG_NET_CLS_ACT
-		/* again for backward compatible mode - we want
-		*  to work with both old and new modes of entering
-		*  tc data even if iproute2  was newer - jhs 
-		*/
-		if (n->action) {
-			struct rtattr * p_rta = (struct rtattr*)skb->tail;
-
-			if (n->action->type != TCA_OLD_COMPAT) {
-				RTA_PUT(skb, TCA_U32_ACT, 0, NULL);
-				if (tcf_action_dump(skb,n->action, 0, 0) < 0) {
-					goto rtattr_failure;
-				}
-			} else {
-				RTA_PUT(skb, TCA_U32_POLICE, 0, NULL);
-				if (tcf_action_dump_old(skb,n->action,0,0) < 0) {
-					goto rtattr_failure;
-				}
-			}
-
-			p_rta->rta_len = skb->tail - (u8*)p_rta;
-		}
-
+		if (tcf_dump_act(skb, n->action, TCA_U32_ACT, TCA_U32_POLICE) < 0)
+			goto rtattr_failure;
 #else
 #ifdef CONFIG_NET_CLS_POLICE
-		if (n->police) {
-			struct rtattr * p_rta = (struct rtattr*)skb->tail;
-			RTA_PUT(skb, TCA_U32_POLICE, 0, NULL);
-	 
-			if (tcf_police_dump(skb, n->police) < 0)
-				goto rtattr_failure;
-
-			p_rta->rta_len = skb->tail - (u8*)p_rta;
-
-		}
+		if (tcf_dump_police(skb, n->police, TCA_U32_POLICE) < 0)
+			goto rtattr_failure;
 #endif
 #endif
 
 #ifdef CONFIG_NET_CLS_IND
-		if(strlen(n->indev)) {
-			struct rtattr * p_rta = (struct rtattr*)skb->tail;
+		if(strlen(n->indev))
 			RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev);
-			p_rta->rta_len = skb->tail - (u8*)p_rta;
-		}
 #endif
 #ifdef CONFIG_CLS_U32_PERF
 		RTA_PUT(skb, TCA_U32_PCNT, 
@@ -867,11 +775,9 @@
 	}
 #else
 #ifdef CONFIG_NET_CLS_POLICE
-	if (TC_U32_KEY(n->handle) && n->police) {
-		if (qdisc_copy_stats(skb, &n->police->stats,
-				     n->police->stats_lock))
+	if (TC_U32_KEY(n->handle) && n->police)
+		if (tcf_police_dump_stats(skb, n->police) < 0)
 			goto rtattr_failure;
-	}
 #endif
 #endif
 	return skb->len;
diff -Nru a/net/sched/estimator.c b/net/sched/estimator.c
--- a/net/sched/estimator.c	2004-12-24 13:36:18 -08:00
+++ b/net/sched/estimator.c	2004-12-24 13:36:18 -08:00
@@ -11,7 +11,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
diff -Nru a/net/sched/gact.c b/net/sched/gact.c
--- a/net/sched/gact.c	2004-12-24 13:36:57 -08:00
+++ b/net/sched/gact.c	2004-12-24 13:36:57 -08:00
@@ -12,7 +12,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -53,16 +53,16 @@
 
 #ifdef CONFIG_GACT_PROB
 typedef int (*g_rand)(struct tcf_gact *p);
-int
+static int
 gact_net_rand(struct tcf_gact *p) {
 	if (net_random()%p->pval)
 		return p->action;
 	return p->paction;
 }
 
-int
+static int
 gact_determ(struct tcf_gact *p) {
-	if (p->stats.packets%p->pval)
+	if (p->bstats.packets%p->pval)
 		return p->action;
 	return p->paction;
 }
@@ -71,7 +71,7 @@
 g_rand gact_rand[MAX_RAND]= { NULL,gact_net_rand, gact_determ};
 
 #endif
-int
+static int
 tcf_gact_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,int ovr,int bind)
 {
 	struct rtattr *tb[TCA_GACT_MAX];
@@ -129,7 +129,7 @@
 	return ret;
 }
 
-int
+static int
 tcf_gact_cleanup(struct tc_action *a, int bind)
 {
 	struct tcf_gact *p;
@@ -139,7 +139,7 @@
 	return 0;
 }
 
-int
+static int
 tcf_gact(struct sk_buff **pskb, struct tc_action *a)
 {
 	struct tcf_gact *p;
@@ -163,17 +163,17 @@
 #else
 	action = p->action;
 #endif
-	p->stats.bytes += skb->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
 	if (TC_ACT_SHOT == action)
-		p->stats.drops++;
+		p->qstats.drops++;
 	p->tm.lastuse = jiffies;
 	spin_unlock(&p->lock);
 
 	return action;
 }
 
-int
+static int
 tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
 {
 	unsigned char *b = skb->tail;
@@ -203,9 +203,9 @@
 		RTA_PUT(skb, TCA_GACT_PROB, sizeof (p_opt), &p_opt);
 	} 
 #endif
-	t.install = jiffies - p->tm.install;
-	t.lastuse = jiffies - p->tm.lastuse;
-	t.expires = p->tm.expires;
+	t.install = jiffies_to_clock_t(jiffies - p->tm.install);
+	t.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse);
+	t.expires = jiffies_to_clock_t(p->tm.expires);
 	RTA_PUT(skb, TCA_GACT_TM, sizeof (t), &t);
 	return skb->len;
 
@@ -214,25 +214,13 @@
 	return -1;
 }
 
-int
-tcf_gact_stats(struct sk_buff *skb, struct tc_action *a)
-{
-	struct tcf_gact *p;
-	p = PRIV(a,gact);
-	if (NULL != p)
-		return qdisc_copy_stats(skb, &p->stats,p->stats_lock);
-
-	return 1;
-}
-
-struct tc_action_ops act_gact_ops = {
+static struct tc_action_ops act_gact_ops = {
 	.next		=	NULL,
 	.kind		=	"gact",
 	.type		=	TCA_ACT_GACT,
 	.capab		=	TCA_CAP_NONE,
 	.owner		=	THIS_MODULE,
 	.act		=	tcf_gact,
-	.get_stats	=	tcf_gact_stats,
 	.dump		=	tcf_gact_dump,
 	.cleanup	=	tcf_gact_cleanup,
 	.lookup		=	tcf_hash_search,
diff -Nru a/net/sched/ipt.c b/net/sched/ipt.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/net/sched/ipt.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,378 @@
+/*
+ * net/sched/ipt.c	iptables target interface
+ *
+ *TODO: Add other tables. For now we only support the ipv4 table targets
+ *
+ *		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:	Jamal Hadi Salim (2002-4)
+ */
+
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/bitops.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/socket.h>
+#include <linux/sockios.h>
+#include <linux/in.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/rtnetlink.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <net/sock.h>
+#include <net/pkt_sched.h>
+#include <linux/tc_act/tc_ipt.h>
+#include <net/tc_act/tc_ipt.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+
+/* use generic hash table */
+#define MY_TAB_SIZE     16
+#define MY_TAB_MASK     15
+
+static u32 idx_gen;
+static struct tcf_ipt *tcf_ipt_ht[MY_TAB_SIZE];
+/* ipt hash table lock */
+static rwlock_t ipt_lock = RW_LOCK_UNLOCKED;
+
+/* ovewrride the defaults */
+#define tcf_st  tcf_ipt
+#define tcf_t_lock   ipt_lock
+#define tcf_ht tcf_ipt_ht
+
+#include <net/pkt_act.h>
+
+static inline int
+init_targ(struct tcf_ipt *p)
+{
+	struct ipt_target *target;
+	int ret = 0;
+	struct ipt_entry_target *t = p->t;
+	target = __ipt_find_target_lock(t->u.user.name, &ret);
+
+	if (!target) {
+		printk("init_targ: Failed to find %s\n", t->u.user.name);
+		return -1;
+	}
+
+	DPRINTK("init_targ: found %s\n", target->name);
+	/* we really need proper ref counting
+	 seems to be only needed for modules?? Talk to laforge */
+/*      if (target->me)
+              __MOD_INC_USE_COUNT(target->me);
+*/
+	t->u.kernel.target = target;
+
+	__ipt_mutex_up();
+
+	if (t->u.kernel.target->checkentry
+	    && !t->u.kernel.target->checkentry(p->tname, NULL, t->data,
+					       t->u.target_size
+					       - sizeof (*t), p->hook)) {
+/*              if (t->u.kernel.target->me)
+	      __MOD_DEC_USE_COUNT(t->u.kernel.target->me);
+*/
+		DPRINTK("ip_tables: check failed for `%s'.\n",
+			t->u.kernel.target->name);
+		ret = -EINVAL;
+	}
+
+	return ret;
+}
+
+static int
+tcf_ipt_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a, int ovr, int bind)
+{
+	struct ipt_entry_target *t;
+	unsigned h;
+	struct rtattr *tb[TCA_IPT_MAX];
+	struct tcf_ipt *p;
+	int ret = 0;
+	u32 index = 0;
+	u32 hook = 0;
+
+	if (NULL == a || NULL == rta ||
+	    (rtattr_parse(tb, TCA_IPT_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) <
+	     0)) {
+		return -1;
+	}
+
+
+	if (tb[TCA_IPT_INDEX - 1]) {
+		index = *(u32 *) RTA_DATA(tb[TCA_IPT_INDEX - 1]);
+		DPRINTK("ipt index %d\n", index);
+	}
+
+	if (index && (p = tcf_hash_lookup(index)) != NULL) {
+		a->priv = (void *) p;
+		spin_lock(&p->lock);
+		if (bind) {
+			p->bindcnt += 1;
+			p->refcnt += 1;
+		}
+		if (ovr) {
+			goto override;
+		}
+		spin_unlock(&p->lock);
+		return ret;
+	}
+
+	if (NULL == tb[TCA_IPT_TARG - 1] || NULL == tb[TCA_IPT_HOOK - 1]) {
+		return -1;
+	}
+
+	p = kmalloc(sizeof (*p), GFP_KERNEL);
+	if (p == NULL)
+		return -1;
+
+	memset(p, 0, sizeof (*p));
+	p->refcnt = 1;
+	ret = 1;
+	spin_lock_init(&p->lock);
+	p->stats_lock = &p->lock;
+	if (bind)
+		p->bindcnt = 1;
+
+override:
+	hook = *(u32 *) RTA_DATA(tb[TCA_IPT_HOOK - 1]);
+
+	t = (struct ipt_entry_target *) RTA_DATA(tb[TCA_IPT_TARG - 1]);
+
+	p->t = kmalloc(t->u.target_size, GFP_KERNEL);
+	if (p->t == NULL) {
+		if (ovr) {
+			printk("ipt policy messed up \n");
+			spin_unlock(&p->lock);
+			return -1;
+		}
+		kfree(p);
+		return -1;
+	}
+
+	memcpy(p->t, RTA_DATA(tb[TCA_IPT_TARG - 1]), t->u.target_size);
+	DPRINTK(" target NAME %s size %d data[0] %x data[1] %x\n",
+		t->u.user.name, t->u.target_size, t->data[0], t->data[1]);
+
+	p->tname = kmalloc(IFNAMSIZ, GFP_KERNEL);
+
+	if (p->tname == NULL) {
+		if (ovr) {
+			printk("ipt policy messed up 2 \n");
+			spin_unlock(&p->lock);
+			return -1;
+		}
+		kfree(p->t);
+		kfree(p);
+		return -1;
+	} else {
+		int csize = IFNAMSIZ - 1;
+
+		memset(p->tname, 0, IFNAMSIZ);
+		if (tb[TCA_IPT_TABLE - 1]) {
+			if (strlen((char *) RTA_DATA(tb[TCA_IPT_TABLE - 1])) <
+			    csize)
+				csize = strlen(RTA_DATA(tb[TCA_IPT_TABLE - 1]));
+			strncpy(p->tname, RTA_DATA(tb[TCA_IPT_TABLE - 1]),
+				csize);
+			DPRINTK("table name %s\n", p->tname);
+		} else {
+			strncpy(p->tname, "mangle", 1 + strlen("mangle"));
+		}
+	}
+
+	if (0 > init_targ(p)) {
+		if (ovr) {
+			printk("ipt policy messed up 2 \n");
+			spin_unlock(&p->lock);
+			return -1;
+		}
+		kfree(p->tname);
+		kfree(p->t);
+		kfree(p);
+		return -1;
+	}
+
+	if (ovr) {
+		spin_unlock(&p->lock);
+		return -1;
+	}
+
+	p->index = index ? : tcf_hash_new_index();
+
+	p->tm.lastuse = jiffies;
+	/*
+	p->tm.expires = jiffies;
+	*/
+	p->tm.install = jiffies;
+#ifdef CONFIG_NET_ESTIMATOR
+	if (est)
+		gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
+#endif
+	h = tcf_hash(p->index);
+	write_lock_bh(&ipt_lock);
+	p->next = tcf_ipt_ht[h];
+	tcf_ipt_ht[h] = p;
+	write_unlock_bh(&ipt_lock);
+	a->priv = (void *) p;
+	return ret;
+
+}
+
+static int
+tcf_ipt_cleanup(struct tc_action *a, int bind)
+{
+	struct tcf_ipt *p;
+	p = PRIV(a,ipt);
+	if (NULL != p)
+		return tcf_hash_release(p, bind);
+	return 0;
+}
+
+static int
+tcf_ipt(struct sk_buff **pskb, struct tc_action *a)
+{
+	int ret = 0, result = 0;
+	struct tcf_ipt *p;
+	struct sk_buff *skb = *pskb;
+
+	p = PRIV(a,ipt);
+
+	if (NULL == p || NULL == skb) {
+		return -1;
+	}
+
+	spin_lock(&p->lock);
+
+	p->tm.lastuse = jiffies;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
+
+	if (skb_cloned(skb) ) {
+		if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
+			return -1;
+		}
+	}
+	/* yes, we have to worry about both in and out dev
+	 worry later - danger - this API seems to have changed
+	 from earlier kernels */
+
+	ret = p->t->u.kernel.target->target(&skb, skb->dev, NULL,
+					    p->hook, p->t->data, (void *)NULL);
+	switch (ret) {
+	case NF_ACCEPT:
+		result = TC_ACT_OK;
+		break;
+	case NF_DROP:
+		result = TC_ACT_SHOT;
+		p->qstats.drops++;
+		break;
+	case IPT_CONTINUE:
+		result = TC_ACT_PIPE;
+		break;
+	default:
+		if (net_ratelimit())
+			printk("Bogus netfilter code %d assume ACCEPT\n", ret);
+		result = TC_POLICE_OK;
+		break;
+	}
+	spin_unlock(&p->lock);
+	return result;
+
+}
+
+static int
+tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
+{
+	struct ipt_entry_target *t;
+	struct tcf_t tm;
+	struct tc_cnt c;
+	unsigned char *b = skb->tail;
+
+	struct tcf_ipt *p;
+
+	p = PRIV(a,ipt);
+	if (NULL == p) {
+		printk("BUG: tcf_ipt_dump called with NULL params\n");
+		goto rtattr_failure;
+	}
+	/* for simple targets kernel size == user size
+	** user name = target name
+	** for foolproof you need to not assume this
+	*/
+
+	t = kmalloc(p->t->u.user.target_size, GFP_ATOMIC);
+
+	if (NULL == t)
+		goto rtattr_failure;
+
+	c.bindcnt = p->bindcnt - bind;
+	c.refcnt = p->refcnt - ref;
+	memcpy(t, p->t, p->t->u.user.target_size);
+	strcpy(t->u.user.name, p->t->u.kernel.target->name);
+
+	DPRINTK("\ttcf_ipt_dump tablename %s length %d\n", p->tname,
+		strlen(p->tname));
+	DPRINTK
+	    ("\tdump target name %s size %d size user %d data[0] %x data[1] %x\n",
+	     p->t->u.kernel.target->name, p->t->u.target_size, p->t->u.user.target_size,
+	     p->t->data[0], p->t->data[1]);
+	RTA_PUT(skb, TCA_IPT_TARG, p->t->u.user.target_size, t);
+	RTA_PUT(skb, TCA_IPT_INDEX, 4, &p->index);
+	RTA_PUT(skb, TCA_IPT_HOOK, 4, &p->hook);
+	RTA_PUT(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c);
+	RTA_PUT(skb, TCA_IPT_TABLE, IFNAMSIZ, p->tname);
+	tm.install = jiffies_to_clock_t(jiffies - p->tm.install);
+	tm.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse);
+	tm.expires = jiffies_to_clock_t(p->tm.expires);
+	RTA_PUT(skb, TCA_IPT_TM, sizeof (tm), &tm);
+	return skb->len;
+
+      rtattr_failure:
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static struct tc_action_ops act_ipt_ops = {
+	.next		=	NULL,
+	.kind		=	"ipt",
+	.type		=	TCA_ACT_IPT,
+	.capab		=	TCA_CAP_NONE,
+	.owner		=	THIS_MODULE,
+	.act		=	tcf_ipt,
+	.dump		=	tcf_ipt_dump,
+	.cleanup	=	tcf_ipt_cleanup,
+	.lookup		=	tcf_hash_search,
+	.init		=	tcf_ipt_init,
+	.walk		=	tcf_generic_walker
+};
+
+MODULE_AUTHOR("Jamal Hadi Salim(2002-4)");
+MODULE_DESCRIPTION("Iptables target actions");
+MODULE_LICENSE("GPL");
+
+static int __init
+ipt_init_module(void)
+{
+	return tcf_register_action(&act_ipt_ops);
+}
+
+static void __exit
+ipt_cleanup_module(void)
+{
+	tcf_unregister_action(&act_ipt_ops);
+}
+
+module_init(ipt_init_module);
+module_exit(ipt_cleanup_module);
diff -Nru a/net/sched/mirred.c b/net/sched/mirred.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/net/sched/mirred.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,306 @@
+/*
+ * net/sched/mirred.c	packet mirroring and redirect actions
+ *
+ *		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.
+ *
+ * Authors:	Jamal Hadi Salim (2002-4)
+ *
+ * TODO: Add ingress support (and socket redirect support)
+ *
+ */
+
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/bitops.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/socket.h>
+#include <linux/sockios.h>
+#include <linux/in.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/rtnetlink.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <net/sock.h>
+#include <net/pkt_sched.h>
+#include <linux/tc_act/tc_mirred.h>
+#include <net/tc_act/tc_mirred.h>
+
+#include <linux/etherdevice.h>
+#include <linux/if_arp.h>
+
+
+/* use generic hash table */
+#define MY_TAB_SIZE     8
+#define MY_TAB_MASK     (MY_TAB_SIZE - 1)
+static u32 idx_gen;
+static struct tcf_mirred *tcf_mirred_ht[MY_TAB_SIZE];
+static rwlock_t mirred_lock = RW_LOCK_UNLOCKED;
+
+/* ovewrride the defaults */
+#define tcf_st  tcf_mirred
+#define tc_st  tc_mirred
+#define tcf_t_lock   mirred_lock
+#define tcf_ht tcf_mirred_ht
+
+#define CONFIG_NET_ACT_INIT 1
+#include <net/pkt_act.h>
+
+static inline int
+tcf_mirred_release(struct tcf_mirred *p, int bind)
+{
+	if (p) {
+		if (bind) {
+			p->bindcnt--;
+		}
+
+		p->refcnt--;
+		if(!p->bindcnt && p->refcnt <= 0) {
+			dev_put(p->dev);
+			tcf_hash_destroy(p);
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
+static int
+tcf_mirred_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,int ovr, int bind)
+{
+	struct rtattr *tb[TCA_MIRRED_MAX];
+	struct tc_mirred *parm;
+	struct tcf_mirred *p;
+	struct net_device *dev = NULL;
+	int size = sizeof (*p), new = 0;
+
+
+	if (rtattr_parse(tb, TCA_MIRRED_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) < 0) {
+		DPRINTK("tcf_mirred_init BUG in user space couldnt parse properly\n");
+		return -1;
+	}
+
+	if (NULL == a || NULL == tb[TCA_MIRRED_PARMS - 1]) {
+		DPRINTK("BUG: tcf_mirred_init called with NULL params\n");
+		return -1;
+	}
+
+	parm = RTA_DATA(tb[TCA_MIRRED_PARMS - 1]);
+
+	p = tcf_hash_check(parm, a, ovr, bind);
+	if (NULL == p) { /* new */
+		p = tcf_hash_create(parm,est,a,size,ovr,bind);
+		new = 1;
+		if (NULL == p)
+			return -1;
+	}
+
+	if (parm->ifindex) {
+		dev = dev_get_by_index(parm->ifindex);
+		if (NULL == dev) {
+			printk("BUG: tcf_mirred_init called with bad device\n");
+			return -1;
+		}
+		switch (dev->type) {
+			case ARPHRD_TUNNEL:
+			case ARPHRD_TUNNEL6:
+			case ARPHRD_SIT:
+			case ARPHRD_IPGRE:
+			case ARPHRD_VOID:
+			case ARPHRD_NONE:
+				p->ok_push = 0;
+				break;
+			default:
+				p->ok_push = 1;
+				break;
+		}
+	} else {
+		if (new) {
+			kfree(p);
+			return -1;
+		}	
+	}
+
+	if (new || ovr) {
+		spin_lock(&p->lock);
+		p->action = parm->action;
+		p->eaction = parm->eaction;
+		if (parm->ifindex) {
+			p->ifindex = parm->ifindex;
+			if (ovr)
+				dev_put(p->dev);
+			p->dev = dev;
+		}
+		spin_unlock(&p->lock);
+	}
+
+
+	DPRINTK(" tcf_mirred_init index %d action %d eaction %d device %s ifndex %d\n",parm->index,parm->action,parm->eaction,dev->name,parm->ifindex);
+	return new;
+
+}
+
+static int
+tcf_mirred_cleanup(struct tc_action *a, int bind)
+{
+	struct tcf_mirred *p;
+	p = PRIV(a,mirred);
+	if (NULL != p)
+		return tcf_mirred_release(p, bind);
+	return 0;
+}
+
+static int
+tcf_mirred(struct sk_buff **pskb, struct tc_action *a)
+{
+	struct tcf_mirred *p;
+	struct net_device *dev;
+	struct sk_buff *skb2 = NULL;
+	struct sk_buff *skb = *pskb;
+	__u32 at = G_TC_AT(skb->tc_verd);
+
+	if (NULL == a) {
+		if (net_ratelimit())
+			printk("BUG: tcf_mirred called with NULL action!\n");
+		return -1;
+	}
+
+	p = PRIV(a,mirred);
+
+	if (NULL == p) {
+		if (net_ratelimit())
+			printk("BUG: tcf_mirred called with NULL params\n");
+		return -1;
+	}
+
+	spin_lock(&p->lock);
+
+       	dev = p->dev;
+	p->tm.lastuse = jiffies;
+
+	if (NULL == dev || !(dev->flags&IFF_UP) ) {
+		if (net_ratelimit())
+			printk("mirred to Houston: device %s is gone!\n",
+					dev?dev->name:"");
+bad_mirred:
+		if (NULL != skb2)
+			kfree_skb(skb2);
+		p->qstats.overlimits++;
+		p->bstats.bytes += skb->len;
+		p->bstats.packets++;
+		spin_unlock(&p->lock);
+		/* should we be asking for packet to be dropped?
+		 * may make sense for redirect case only 
+		*/
+		return TC_ACT_SHOT;
+	} 
+
+	skb2 = skb_clone(skb, GFP_ATOMIC);
+	if (skb2 == NULL) {
+		goto bad_mirred;
+	}
+	if (TCA_EGRESS_MIRROR != p->eaction &&
+		TCA_EGRESS_REDIR != p->eaction) {
+		if (net_ratelimit())
+			printk("tcf_mirred unknown action %d\n",p->eaction);
+		goto bad_mirred;
+	}
+
+	p->bstats.bytes += skb2->len;
+	p->bstats.packets++;
+	if ( !(at & AT_EGRESS)) {
+		if (p->ok_push) {
+			skb_push(skb2, skb2->dev->hard_header_len);
+		}
+	}
+
+	/* mirror is always swallowed */
+	if (TCA_EGRESS_MIRROR != p->eaction)
+		skb2->tc_verd = SET_TC_FROM(skb2->tc_verd,at);
+
+	skb2->dev = dev;
+	skb2->input_dev = skb->dev;
+	dev_queue_xmit(skb2);
+	spin_unlock(&p->lock);
+	return p->action;
+}
+
+static int
+tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a,int bind, int ref)
+{
+	unsigned char *b = skb->tail;
+	struct tc_mirred opt;
+	struct tcf_mirred *p;
+	struct tcf_t t;
+
+	p = PRIV(a,mirred);
+	if (NULL == p) {
+		printk("BUG: tcf_mirred_dump called with NULL params\n");
+		goto rtattr_failure;
+	}
+
+	opt.index = p->index;
+	opt.action = p->action;
+	opt.refcnt = p->refcnt - ref;
+	opt.bindcnt = p->bindcnt - bind;
+	opt.eaction = p->eaction;
+	opt.ifindex = p->ifindex;
+	DPRINTK(" tcf_mirred_dump index %d action %d eaction %d ifndex %d\n",p->index,p->action,p->eaction,p->ifindex);
+	RTA_PUT(skb, TCA_MIRRED_PARMS, sizeof (opt), &opt);
+	t.install = jiffies_to_clock_t(jiffies - p->tm.install);
+	t.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse);
+	t.expires = jiffies_to_clock_t(p->tm.expires);
+	RTA_PUT(skb, TCA_MIRRED_TM, sizeof (t), &t);
+	return skb->len;
+
+      rtattr_failure:
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static struct tc_action_ops act_mirred_ops = {
+	.next		=	NULL,
+	.kind		=	"mirred",
+	.type		=	TCA_ACT_MIRRED,
+	.capab		=	TCA_CAP_NONE,
+	.owner		=	THIS_MODULE,
+	.act		=	tcf_mirred,
+	.dump		=	tcf_mirred_dump,
+	.cleanup	=	tcf_mirred_cleanup,
+	.lookup		=	tcf_hash_search,
+	.init		=	tcf_mirred_init,
+	.walk		=	tcf_generic_walker
+};
+
+MODULE_AUTHOR("Jamal Hadi Salim(2002)");
+MODULE_DESCRIPTION("Device Mirror/redirect actions");
+MODULE_LICENSE("GPL");
+
+
+static int __init
+mirred_init_module(void)
+{
+	printk("Mirror/redirect action on\n");
+	return tcf_register_action(&act_mirred_ops);
+}
+
+static void __exit
+mirred_cleanup_module(void)
+{
+	tcf_unregister_action(&act_mirred_ops);
+}
+
+module_init(mirred_init_module);
+module_exit(mirred_cleanup_module);
+
diff -Nru a/net/sched/pedit.c b/net/sched/pedit.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/net/sched/pedit.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,290 @@
+/*
+ * net/sched/pedit.c	Generic packet editor
+ *
+ *		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.
+ *
+ * Authors:	Jamal Hadi Salim (2002-4)
+ */
+
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/bitops.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/socket.h>
+#include <linux/sockios.h>
+#include <linux/in.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/rtnetlink.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <net/sock.h>
+#include <net/pkt_sched.h>
+#include <linux/tc_act/tc_pedit.h>
+#include <net/tc_act/tc_pedit.h>
+
+
+#define PEDIT_DEB 1
+
+/* use generic hash table */
+#define MY_TAB_SIZE     16
+#define MY_TAB_MASK     15
+static u32 idx_gen;
+static struct tcf_pedit *tcf_pedit_ht[MY_TAB_SIZE];
+static rwlock_t pedit_lock = RW_LOCK_UNLOCKED;
+
+#define tcf_st  tcf_pedit
+#define tc_st  tc_pedit
+#define tcf_t_lock   pedit_lock
+#define tcf_ht tcf_pedit_ht
+
+#define CONFIG_NET_ACT_INIT 1
+#include <net/pkt_act.h>
+
+
+static int
+tcf_pedit_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,int ovr, int bind)
+{
+	struct rtattr *tb[TCA_PEDIT_MAX];
+	struct tc_pedit *parm;
+	int size = 0;
+	int ret = 0;
+	struct tcf_pedit *p = NULL;
+
+	if (rtattr_parse(tb, TCA_PEDIT_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) < 0)
+		return -1;
+
+	if (NULL == a || NULL == tb[TCA_PEDIT_PARMS - 1]) {
+		printk("BUG: tcf_pedit_init called with NULL params\n");
+		return -1;
+	}
+
+	parm = RTA_DATA(tb[TCA_PEDIT_PARMS - 1]);
+
+	p = tcf_hash_check(parm, a, ovr, bind);
+
+	if (NULL == p) { /* new */
+
+		if (!parm->nkeys)
+			return -1;
+
+		size = sizeof (*p)+ (parm->nkeys*sizeof(struct tc_pedit_key));
+
+		p = tcf_hash_create(parm,est,a,size,ovr,bind);
+
+		if (NULL == p)
+			return -1;
+		ret = 1;
+		goto override;
+	} 
+
+	if (ovr) {
+override:
+		p->flags = parm->flags;
+		p->nkeys = parm->nkeys;
+		p->action = parm->action;
+		memcpy(p->keys,parm->keys,parm->nkeys*(sizeof(struct tc_pedit_key)));
+	}
+
+	return ret;
+}
+
+static int
+tcf_pedit_cleanup(struct tc_action *a, int bind)
+{
+	struct tcf_pedit *p;
+	p = PRIV(a,pedit);
+	if (NULL != p)
+		return	tcf_hash_release(p, bind);
+	return 0;
+}
+
+/*
+**
+*/
+static int
+tcf_pedit(struct sk_buff **pskb, struct tc_action *a)
+{
+	struct tcf_pedit *p;
+	struct sk_buff *skb = *pskb;
+	int i, munged = 0;
+	u8 *pptr;
+
+	p = PRIV(a,pedit);
+
+	if (NULL == p) {
+		printk("BUG: tcf_pedit called with NULL params\n");
+		return -1; /* change to something symbolic */
+	}
+
+	if (!(skb->tc_verd & TC_OK2MUNGE)) {
+		/* should we set skb->cloned? */
+		if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
+			return p->action;
+		}
+	}
+
+	pptr = skb->nh.raw;
+
+	spin_lock(&p->lock);
+
+	p->tm.lastuse = jiffies;
+
+	if (0 < p->nkeys) {
+		struct tc_pedit_key *tkey = p->keys;
+
+		for (i = p->nkeys; i > 0; i--, tkey++) {
+			u32 *ptr ;
+
+			int offset = tkey->off;
+			if (tkey->offmask) {
+				if (skb->len > tkey->at) {
+					 char *j = pptr+tkey->at;
+					 offset +=((*j&tkey->offmask)>>tkey->shift);
+				} else {
+					goto bad;
+				}
+			}
+
+			if (offset % 4) {
+				printk("offset must be on 32 bit boundaries\n");
+				goto bad;
+			}
+
+			if (skb->len < 0 || (offset > 0 && offset > skb->len)) {
+				printk("offset %d cant exceed pkt length %d\n",
+						offset, skb->len);
+				goto bad;
+			}
+
+
+			ptr = (u32 *)(pptr+offset);
+			/* just do it, baby */
+			*ptr = ((*ptr & tkey->mask) ^ tkey->val);
+			munged++;
+		}
+		
+		if (munged)
+			skb->tc_verd = SET_TC_MUNGED(skb->tc_verd);
+		goto done;
+	} else {
+		printk("pedit BUG: index %d\n",p->index);
+	}
+
+bad:
+	p->qstats.overlimits++;
+done:
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
+	spin_unlock(&p->lock);
+	return p->action;
+}
+
+static int
+tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,int bind, int ref)
+{
+	unsigned char *b = skb->tail;
+	struct tc_pedit *opt;
+	struct tcf_pedit *p;
+	struct tcf_t t;
+	int s; 
+		
+
+	p = PRIV(a,pedit);
+
+	if (NULL == p) {
+		printk("BUG: tcf_pedit_dump called with NULL params\n");
+		goto rtattr_failure;
+	}
+
+	s = sizeof (*opt)+(p->nkeys*sizeof(struct tc_pedit_key));
+
+	/* netlink spinlocks held above us - must use ATOMIC
+	 * */
+	opt = kmalloc(s, GFP_ATOMIC);
+	if (opt == NULL)
+		return -ENOBUFS;
+
+	memset(opt, 0, s);
+
+	memcpy(opt->keys,p->keys,p->nkeys*(sizeof(struct tc_pedit_key)));
+	opt->index = p->index;
+	opt->nkeys = p->nkeys;
+	opt->flags = p->flags;
+	opt->action = p->action;
+	opt->refcnt = p->refcnt - ref;
+	opt->bindcnt = p->bindcnt - bind;
+
+
+#ifdef PEDIT_DEB
+	{                
+		/* Debug - get rid of later */
+		int i;
+		struct tc_pedit_key *key = opt->keys;
+
+		for (i=0; i<opt->nkeys; i++, key++) {
+			printk( "\n key #%d",i);
+			printk( "  at %d: val %08x mask %08x",
+			(unsigned int)key->off,
+			(unsigned int)key->val,
+			(unsigned int)key->mask);
+												}
+											}
+#endif
+
+	RTA_PUT(skb, TCA_PEDIT_PARMS, s, opt);
+	t.install = jiffies_to_clock_t(jiffies - p->tm.install);
+	t.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse);
+	t.expires = jiffies_to_clock_t(p->tm.expires);
+	RTA_PUT(skb, TCA_PEDIT_TM, sizeof (t), &t);
+	return skb->len;
+
+rtattr_failure:
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static
+struct tc_action_ops act_pedit_ops = {
+	.kind		=	"pedit",
+	.type		=	TCA_ACT_PEDIT,
+	.capab		=	TCA_CAP_NONE,
+	.owner		=	THIS_MODULE,
+	.act		=	tcf_pedit,
+	.dump		=	tcf_pedit_dump,
+	.cleanup	=	tcf_pedit_cleanup,
+	.lookup		=	tcf_hash_search,
+	.init		=	tcf_pedit_init,
+	.walk		=	tcf_generic_walker
+};
+
+MODULE_AUTHOR("Jamal Hadi Salim(2002-4)");
+MODULE_DESCRIPTION("Generic Packet Editor actions");
+MODULE_LICENSE("GPL");
+
+static int __init
+pedit_init_module(void)
+{
+	return tcf_register_action(&act_pedit_ops);
+}
+
+static void __exit
+pedit_cleanup_module(void)
+{
+	tcf_unregister_action(&act_pedit_ops);
+}
+
+module_init(pedit_init_module);
+module_exit(pedit_cleanup_module);
+
diff -Nru a/net/sched/police.c b/net/sched/police.c
--- a/net/sched/police.c	2004-12-24 13:37:19 -08:00
+++ b/net/sched/police.c	2004-12-24 13:37:19 -08:00
@@ -12,7 +12,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -31,7 +31,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <net/sock.h>
-#include <net/pkt_sched.h>
+#include <net/act_api.h>
 
 #define L2T(p,L)   ((p)->R_tab->data[(L)>>(p)->R_tab->rate.cell_log])
 #define L2T_P(p,L) ((p)->P_tab->data[(L)>>(p)->P_tab->rate.cell_log])
@@ -149,7 +149,7 @@
 			*p1p = p->next;
 			write_unlock_bh(&police_lock);
 #ifdef CONFIG_NET_ESTIMATOR
-			qdisc_kill_estimator(&p->stats);
+			gen_kill_estimator(&p->bstats, &p->rate_est);
 #endif
 			if (p->R_tab)
 				qdisc_put_rtab(p->R_tab);
@@ -245,7 +245,7 @@
 	p->index = parm->index ? : tcf_police_new_index();
 #ifdef CONFIG_NET_ESTIMATOR
 	if (est)
-		qdisc_new_estimator(&p->stats, p->stats_lock, est);
+		gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
 #endif
 	h = tcf_police_hash(p->index);
 	write_lock_bh(&police_lock);
@@ -275,16 +275,6 @@
 	return 0;
 }
 
-int tcf_act_police_stats(struct sk_buff *skb, struct tc_action *a)
-{
-	struct tcf_police *p;
-	p = PRIV(a);
-	if (NULL != p) 
-		return qdisc_copy_stats(skb, &p->stats, p->stats_lock);
-
-	return 1;
-}
-
 int tcf_act_police(struct sk_buff **pskb, struct tc_action *a)
 {
 	psched_time_t now;
@@ -302,12 +292,12 @@
 
 	spin_lock(&p->lock);
 
-	p->stats.bytes += skb->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
 
 #ifdef CONFIG_NET_ESTIMATOR
-	if (p->ewma_rate && p->stats.bps >= p->ewma_rate) {
-		p->stats.overlimits++;
+	if (p->ewma_rate && p->rate_est.bps >= p->ewma_rate) {
+		p->qstats.overlimits++;
 		spin_unlock(&p->lock);
 		return p->action;
 	}
@@ -343,7 +333,7 @@
 		}
 	}
 
-	p->stats.overlimits++;
+	p->qstats.overlimits++;
 	spin_unlock(&p->lock);
 	return p->action;
 }
@@ -400,7 +390,6 @@
 	.capab		=	TCA_CAP_NONE, 
 	.owner		=	THIS_MODULE,
 	.act		=	tcf_act_police,
-	.get_stats	=	tcf_act_police_stats,
 	.dump		=	tcf_act_police_dump,
 	.cleanup	=	tcf_act_police_cleanup,
 	.lookup		=	tcf_hash_search,
@@ -480,7 +469,7 @@
 	p->action = parm->action;
 #ifdef CONFIG_NET_ESTIMATOR
 	if (est)
-		qdisc_new_estimator(&p->stats, p->stats_lock, est);
+		gen_new_estimator(&p->bstats, &p->rate_est, p->stats_lock, est);
 #endif
 	h = tcf_police_hash(p->index);
 	write_lock_bh(&police_lock);
@@ -504,12 +493,12 @@
 
 	spin_lock(&p->lock);
 
-	p->stats.bytes += skb->len;
-	p->stats.packets++;
+	p->bstats.bytes += skb->len;
+	p->bstats.packets++;
 
 #ifdef CONFIG_NET_ESTIMATOR
-	if (p->ewma_rate && p->stats.bps >= p->ewma_rate) {
-		p->stats.overlimits++;
+	if (p->ewma_rate && p->rate_est.bps >= p->ewma_rate) {
+		p->qstats.overlimits++;
 		spin_unlock(&p->lock);
 		return p->action;
 	}
@@ -545,7 +534,7 @@
 		}
 	}
 
-	p->stats.overlimits++;
+	p->qstats.overlimits++;
 	spin_unlock(&p->lock);
 	return p->action;
 }
@@ -581,9 +570,35 @@
 	return -1;
 }
 
+int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *p)
+{
+	struct gnet_dump d;
+	
+	if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
+			TCA_XSTATS, p->stats_lock, &d) < 0)
+		goto errout;
+	
+	if (gnet_stats_copy_basic(&d, &p->bstats) < 0 ||
+#ifdef CONFIG_NET_ESTIMATOR
+	    gnet_stats_copy_rate_est(&d, &p->rate_est) < 0 ||
+#endif
+	    gnet_stats_copy_queue(&d, &p->qstats) < 0)
+		goto errout;
+
+	if (gnet_stats_finish_copy(&d) < 0)
+		goto errout;
+
+	return 0;
+
+errout:
+	return -1;
+}
+
+
 EXPORT_SYMBOL(tcf_police);
 EXPORT_SYMBOL(tcf_police_destroy);
 EXPORT_SYMBOL(tcf_police_dump);
+EXPORT_SYMBOL(tcf_police_dump_stats);
 EXPORT_SYMBOL(tcf_police_hash);
 EXPORT_SYMBOL(tcf_police_ht);
 EXPORT_SYMBOL(tcf_police_locate);
diff -Nru a/net/sched/sch_api.c b/net/sched/sch_api.c
--- a/net/sched/sch_api.c	2004-12-24 13:36:48 -08:00
+++ b/net/sched/sch_api.c	2004-12-24 13:36:48 -08:00
@@ -35,6 +35,7 @@
 #include <linux/seq_file.h>
 #include <linux/kmod.h>
 #include <linux/list.h>
+#include <linux/bitops.h>
 
 #include <net/sock.h>
 #include <net/pkt_sched.h>
@@ -42,7 +43,6 @@
 #include <asm/processor.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 static int qdisc_notify(struct sk_buff *oskb, struct nlmsghdr *n, u32 clid,
 			struct Qdisc *old, struct Qdisc *new);
@@ -196,10 +196,14 @@
 {
 	struct Qdisc *q;
 
+	read_lock_bh(&qdisc_tree_lock);
 	list_for_each_entry(q, &dev->qdisc_list, list) {
-		if (q->handle == handle)
+		if (q->handle == handle) {
+			read_unlock_bh(&qdisc_tree_lock);
 			return q;
+		}
 	}
+	read_unlock_bh(&qdisc_tree_lock);
 	return NULL;
 }
 
@@ -229,8 +233,11 @@
 	if (kind) {
 		read_lock(&qdisc_mod_lock);
 		for (q = qdisc_base; q; q = q->next) {
-			if (rtattr_strcmp(kind, q->id) == 0)
+			if (rtattr_strcmp(kind, q->id) == 0) {
+				if (!try_module_get(q->owner))
+					q = NULL;
 				break;
+			}
 		}
 		read_unlock(&qdisc_mod_lock);
 	}
@@ -308,7 +315,7 @@
 		dev_deactivate(dev);
 
 	qdisc_lock_tree(dev);
-	if (qdisc && qdisc->flags&TCQ_F_INGRES) {
+	if (qdisc && qdisc->flags&TCQ_F_INGRESS) {
 		oqdisc = dev->qdisc_ingress;
 		/* Prune old scheduler */
 		if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1) {
@@ -357,7 +364,7 @@
 
 
 	if (parent == NULL) { 
-		if (q && q->flags&TCQ_F_INGRES) {
+		if (q && q->flags&TCQ_F_INGRESS) {
 			*old = dev_graft_qdisc(dev, q);
 		} else {
 			*old = dev_graft_qdisc(dev, new);
@@ -409,9 +416,6 @@
 	err = -EINVAL;
 	if (ops == NULL)
 		goto err_out;
-	err = -EBUSY;
-	if (!try_module_get(ops->owner))
-		goto err_out;
 
 	/* ensure that the Qdisc and the private data are 32-byte aligned */
 	size = ((sizeof(*sch) + QDISC_ALIGN_CONST) & ~QDISC_ALIGN_CONST);
@@ -430,7 +434,7 @@
 	skb_queue_head_init(&sch->q);
 
 	if (handle == TC_H_INGRESS)
-		sch->flags |= TCQ_F_INGRES;
+		sch->flags |= TCQ_F_INGRESS;
 
 	sch->ops = ops;
 	sch->enqueue = ops->enqueue;
@@ -451,9 +455,6 @@
         else
                 sch->handle = handle;
 
-	/* enqueue is accessed locklessly - make sure it's visible
-	 * before we set a netdevice's qdisc pointer to sch */
-	smp_wmb();
 	if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS-1])) == 0) {
 		qdisc_lock_tree(dev);
 		list_add_tail(&sch->list, &dev->qdisc_list);
@@ -461,8 +462,8 @@
 
 #ifdef CONFIG_NET_ESTIMATOR
 		if (tca[TCA_RATE-1])
-			qdisc_new_estimator(&sch->stats, sch->stats_lock,
-					    tca[TCA_RATE-1]);
+			gen_new_estimator(&sch->bstats, &sch->rate_est,
+				sch->stats_lock, tca[TCA_RATE-1]);
 #endif
 		return sch;
 	}
@@ -489,11 +490,9 @@
 			return err;
 	}
 #ifdef CONFIG_NET_ESTIMATOR
-	if (tca[TCA_RATE-1]) {
-		qdisc_kill_estimator(&sch->stats);
-		qdisc_new_estimator(&sch->stats, sch->stats_lock,
-				    tca[TCA_RATE-1]);
-	}
+	if (tca[TCA_RATE-1])
+		gen_replace_estimator(&sch->bstats, &sch->rate_est,
+			sch->stats_lock, tca[TCA_RATE-1]);
 #endif
 	return 0;
 }
@@ -731,25 +730,13 @@
 	return 0;
 }
 
-int qdisc_copy_stats(struct sk_buff *skb, struct tc_stats *st, spinlock_t *lock)
-{
-	spin_lock_bh(lock);
-	RTA_PUT(skb, TCA_STATS, sizeof(struct tc_stats), st);
-	spin_unlock_bh(lock);
-	return 0;
-
-rtattr_failure:
-	spin_unlock_bh(lock);
-	return -1;
-}
-
-
 static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
 			 u32 pid, u32 seq, unsigned flags, int event)
 {
 	struct tcmsg *tcm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
+	struct gnet_dump d;
 
 	nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*tcm));
 	nlh->nlmsg_flags = flags;
@@ -762,9 +749,25 @@
 	RTA_PUT(skb, TCA_KIND, IFNAMSIZ, q->ops->id);
 	if (q->ops->dump && q->ops->dump(q, skb) < 0)
 		goto rtattr_failure;
-	q->stats.qlen = q->q.qlen;
-	if (qdisc_copy_stats(skb, &q->stats, q->stats_lock))
+	q->qstats.qlen = q->q.qlen;
+
+	if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
+			TCA_XSTATS, q->stats_lock, &d) < 0)
+		goto rtattr_failure;
+
+	if (q->ops->dump_stats && q->ops->dump_stats(q, &d) < 0)
+		goto rtattr_failure;
+
+	if (gnet_stats_copy_basic(&d, &q->bstats) < 0 ||
+#ifdef CONFIG_NET_ESTIMATOR
+	    gnet_stats_copy_rate_est(&d, &q->rate_est) < 0 ||
+#endif
+	    gnet_stats_copy_queue(&d, &q->qstats) < 0)
+		goto rtattr_failure;
+	
+	if (gnet_stats_finish_copy(&d) < 0)
 		goto rtattr_failure;
+	
 	nlh->nlmsg_len = skb->tail - b;
 	return skb->len;
 
@@ -970,6 +973,8 @@
 	struct tcmsg *tcm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
+	struct gnet_dump d;
+	struct Qdisc_class_ops *cl_ops = q->ops->cl_ops;
 
 	nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*tcm));
 	nlh->nlmsg_flags = flags;
@@ -980,8 +985,19 @@
 	tcm->tcm_handle = q->handle;
 	tcm->tcm_info = 0;
 	RTA_PUT(skb, TCA_KIND, IFNAMSIZ, q->ops->id);
-	if (q->ops->cl_ops->dump && q->ops->cl_ops->dump(q, cl, skb, tcm) < 0)
+	if (cl_ops->dump && cl_ops->dump(q, cl, skb, tcm) < 0)
+		goto rtattr_failure;
+
+	if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
+			TCA_XSTATS, q->stats_lock, &d) < 0)
+		goto rtattr_failure;
+
+	if (cl_ops->dump_stats && cl_ops->dump_stats(q, cl, &d) < 0)
+		goto rtattr_failure;
+
+	if (gnet_stats_finish_copy(&d) < 0)
 		goto rtattr_failure;
+
 	nlh->nlmsg_len = skb->tail - b;
 	return skb->len;
 
@@ -1071,8 +1087,54 @@
 	return skb->len;
 }
 
-int psched_us_per_tick = 1;
-int psched_tick_per_us = 1;
+/* Main classifier routine: scans classifier chain attached
+   to this qdisc, (optionally) tests for protocol and asks
+   specific classifiers.
+ */
+int tc_classify(struct sk_buff *skb, struct tcf_proto *tp,
+	struct tcf_result *res)
+{
+	int err = 0;
+	u32 protocol = skb->protocol;
+#ifdef CONFIG_NET_CLS_ACT
+	struct tcf_proto *otp = tp;
+reclassify:
+#endif
+	protocol = skb->protocol;
+
+	for ( ; tp; tp = tp->next) {
+		if ((tp->protocol == protocol ||
+			tp->protocol == __constant_htons(ETH_P_ALL)) &&
+			(err = tp->classify(skb, tp, res)) >= 0) {
+#ifdef CONFIG_NET_CLS_ACT
+			if ( TC_ACT_RECLASSIFY == err) {
+				__u32 verd = (__u32) G_TC_VERD(skb->tc_verd);
+				tp = otp;
+
+				if (MAX_REC_LOOP < verd++) {
+					printk("rule prio %d protocol %02x reclassify is buggy packet dropped\n",
+						tp->prio&0xffff, ntohs(tp->protocol));
+					return TC_ACT_SHOT;
+				}
+				skb->tc_verd = SET_TC_VERD(skb->tc_verd,verd);
+				goto reclassify;
+			} else {
+				if (skb->tc_verd) 
+					skb->tc_verd = SET_TC_VERD(skb->tc_verd,0);
+				return err;
+			}
+#else
+
+			return err;
+#endif
+		}
+
+	}
+	return -1;
+}
+
+static int psched_us_per_tick = 1;
+static int psched_tick_per_us = 1;
 
 #ifdef CONFIG_PROC_FS
 static int psched_show(struct seq_file *seq, void *v)
@@ -1098,21 +1160,6 @@
 };	
 #endif
 
-#ifdef CONFIG_NET_SCH_CLK_GETTIMEOFDAY
-int psched_tod_diff(int delta_sec, int bound)
-{
-	int delta;
-
-	if (bound <= 1000000 || delta_sec > (0x7FFFFFFF/1000000)-1)
-		return bound;
-	delta = delta_sec * 1000000;
-	if (delta > bound)
-		delta = bound;
-	return delta;
-}
-EXPORT_SYMBOL(psched_tod_diff);
-#endif
-
 #ifdef CONFIG_NET_SCH_CLK_CPU
 psched_tdiff_t psched_clock_per_hz;
 int psched_clock_scale;
@@ -1213,8 +1260,8 @@
 
 subsys_initcall(pktsched_init);
 
-EXPORT_SYMBOL(qdisc_copy_stats);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
 EXPORT_SYMBOL(unregister_qdisc);
+EXPORT_SYMBOL(tc_classify);
diff -Nru a/net/sched/sch_atm.c b/net/sched/sch_atm.c
--- a/net/sched/sch_atm.c	2004-12-24 13:36:48 -08:00
+++ b/net/sched/sch_atm.c	2004-12-24 13:36:48 -08:00
@@ -69,7 +69,8 @@
 	struct socket		*sock;		/* for closing */
 	u32			classid;	/* x:y type ID */
 	int			ref;		/* reference count */
-	struct tc_stats		stats;
+	struct gnet_stats_basic	bstats;
+	struct gnet_stats_queue	qstats;
 	spinlock_t		*stats_lock;
 	struct atm_flow_data	*next;
 	struct atm_flow_data	*excess;	/* flow for excess traffic;
@@ -449,14 +450,14 @@
 	    result == TC_POLICE_SHOT ||
 #endif
 	    (ret = flow->q->enqueue(skb,flow->q)) != 0) {
-		sch->stats.drops++;
-		if (flow) flow->stats.drops++;
+		sch->qstats.drops++;
+		if (flow) flow->qstats.drops++;
 		return ret;
 	}
-	sch->stats.bytes += skb->len;
-	sch->stats.packets++;
-	flow->stats.bytes += skb->len;
-	flow->stats.packets++;
+	sch->bstats.bytes += skb->len;
+	sch->bstats.packets++;
+	flow->bstats.bytes += skb->len;
+	flow->bstats.packets++;
 	/*
 	 * Okay, this may seem weird. We pretend we've dropped the packet if
 	 * it goes via ATM. The reason for this is that the outer qdisc
@@ -545,10 +546,12 @@
 
 	D2PRINTK("atm_tc_requeue(skb %p,sch %p,[qdisc %p])\n",skb,sch,p);
 	ret = p->link.q->ops->requeue(skb,p->link.q);
-	if (!ret) sch->q.qlen++;
-	else {
-		sch->stats.drops++;
-		p->link.stats.drops++;
+	if (!ret) {
+        sch->q.qlen++;
+        sch->qstats.requeues++;
+    } else {
+		sch->qstats.drops++;
+		p->link.qstats.drops++;
 	}
 	return ret;
 }
@@ -664,6 +667,20 @@
 	skb_trim(skb,b-skb->data);
 	return -1;
 }
+static int
+atm_tc_dump_class_stats(struct Qdisc *sch, unsigned long arg,
+	struct gnet_dump *d)
+{
+	struct atm_flow_data *flow = (struct atm_flow_data *) arg;
+
+	flow->qstats.qlen = flow->q->q.qlen;
+
+	if (gnet_stats_copy_basic(d, &flow->bstats) < 0 ||
+	    gnet_stats_copy_queue(d, &flow->qstats) < 0)
+		return -1;
+
+	return 0;
+}
 
 static int atm_tc_dump(struct Qdisc *sch, struct sk_buff *skb)
 {
@@ -682,6 +699,7 @@
 	.bind_tcf	=	atm_tc_bind_filter,
 	.unbind_tcf	=	atm_tc_put,
 	.dump		=	atm_tc_dump_class,
+	.dump_stats	=	atm_tc_dump_class_stats,
 };
 
 static struct Qdisc_ops atm_qdisc_ops = {
diff -Nru a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
--- a/net/sched/sch_cbq.c	2004-12-24 13:36:18 -08:00
+++ b/net/sched/sch_cbq.c	2004-12-24 13:36:18 -08:00
@@ -14,7 +14,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -146,7 +146,9 @@
 	long			avgidle;
 	long			deficit;	/* Saved deficit for WRR */
 	unsigned long		penalized;
-	struct tc_stats		stats;
+	struct gnet_stats_basic bstats;
+	struct gnet_stats_queue qstats;
+	struct gnet_stats_rate_est rate_est;
 	spinlock_t		*stats_lock;
 	struct tc_cbq_xstats	xstats;
 
@@ -433,8 +435,8 @@
 #endif
 		if ((ret = cl->q->enqueue(skb, cl->q)) == NET_XMIT_SUCCESS) {
 			sch->q.qlen++;
-			sch->stats.packets++;
-			sch->stats.bytes+=len;
+			sch->bstats.packets++;
+			sch->bstats.bytes+=len;
 			cbq_mark_toplevel(q, cl);
 			if (!cl->next_alive)
 				cbq_activate_class(cl);
@@ -443,21 +445,21 @@
 	}
 
 #ifndef CONFIG_NET_CLS_ACT
-	sch->stats.drops++;
+	sch->qstats.drops++;
 	if (cl == NULL)
 		kfree_skb(skb);
 	else {
 		cbq_mark_toplevel(q, cl);
-		cl->stats.drops++;
+		cl->qstats.drops++;
 	}
 #else
 	if ( NET_XMIT_DROP == ret) {
-		sch->stats.drops++;
+		sch->qstats.drops++;
 	}
 
 	if (cl != NULL) {
 		cbq_mark_toplevel(q, cl);
-		cl->stats.drops++;
+		cl->qstats.drops++;
 	}
 #endif
 	return ret;
@@ -472,7 +474,7 @@
 
 	if ((cl = q->tx_class) == NULL) {
 		kfree_skb(skb);
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return NET_XMIT_CN;
 	}
 	q->tx_class = NULL;
@@ -485,12 +487,13 @@
 #endif
 	if ((ret = cl->q->ops->requeue(skb, cl->q)) == 0) {
 		sch->q.qlen++;
+		sch->qstats.requeues++;
 		if (!cl->next_alive)
 			cbq_activate_class(cl);
 		return 0;
 	}
-	sch->stats.drops++;
-	cl->stats.drops++;
+	sch->qstats.drops++;
+	cl->qstats.drops++;
 	return ret;
 }
 
@@ -729,17 +732,17 @@
 
 		if (cl->q->enqueue(skb, cl->q) == 0) {
 			sch->q.qlen++;
-			sch->stats.packets++;
-			sch->stats.bytes+=len;
+			sch->bstats.packets++;
+			sch->bstats.bytes+=len;
 			if (!cl->next_alive)
 				cbq_activate_class(cl);
 			return 0;
 		}
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return 0;
 	}
 
-	sch->stats.drops++;
+	sch->qstats.drops++;
 	return -1;
 }
 #endif
@@ -788,8 +791,8 @@
 		long avgidle = cl->avgidle;
 		long idle;
 
-		cl->stats.packets++;
-		cl->stats.bytes += len;
+		cl->bstats.packets++;
+		cl->bstats.bytes += len;
 
 		/*
 		   (now - last) is total time between packet right edges.
@@ -887,7 +890,7 @@
 		   no another solution exists.
 		 */
 		if ((cl = cl->borrow) == NULL) {
-			this_cl->stats.overlimits++;
+			this_cl->qstats.overlimits++;
 			this_cl->overlimit(this_cl);
 			return NULL;
 		}
@@ -1090,7 +1093,7 @@
 	   Sigh... start watchdog timer in the last case. */
 
 	if (sch->q.qlen) {
-		sch->stats.overlimits++;
+		sch->qstats.overlimits++;
 		if (q->wd_expires) {
 			long delay = PSCHED_US2JIFFIE(q->wd_expires);
 			if (delay <= 0)
@@ -1611,16 +1614,6 @@
 	return 0;
 }
 
-int cbq_copy_xstats(struct sk_buff *skb, struct tc_cbq_xstats *st)
-{
-	RTA_PUT(skb, TCA_XSTATS, sizeof(*st), st);
-	return 0;
-
-rtattr_failure:
-	return -1;
-}
-
-
 static int cbq_dump(struct Qdisc *sch, struct sk_buff *skb)
 {
 	struct cbq_sched_data *q = qdisc_priv(sch);
@@ -1632,13 +1625,6 @@
 	if (cbq_dump_attr(skb, &q->link) < 0)
 		goto rtattr_failure;
 	rta->rta_len = skb->tail - b;
-	spin_lock_bh(&sch->dev->queue_lock);
-	q->link.xstats.avgidle = q->link.avgidle;
-	if (cbq_copy_xstats(skb, &q->link.xstats)) {
-		spin_unlock_bh(&sch->dev->queue_lock);
-		goto rtattr_failure;
-	}
-	spin_unlock_bh(&sch->dev->queue_lock);
 	return skb->len;
 
 rtattr_failure:
@@ -1647,10 +1633,18 @@
 }
 
 static int
+cbq_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
+{
+	struct cbq_sched_data *q = qdisc_priv(sch);
+
+	q->link.xstats.avgidle = q->link.avgidle;
+	return gnet_stats_copy_app(d, &q->link.xstats, sizeof(q->link.xstats));
+}
+
+static int
 cbq_dump_class(struct Qdisc *sch, unsigned long arg,
 	       struct sk_buff *skb, struct tcmsg *tcm)
 {
-	struct cbq_sched_data *q = qdisc_priv(sch);
 	struct cbq_class *cl = (struct cbq_class*)arg;
 	unsigned char	 *b = skb->tail;
 	struct rtattr *rta;
@@ -1667,25 +1661,35 @@
 	if (cbq_dump_attr(skb, cl) < 0)
 		goto rtattr_failure;
 	rta->rta_len = skb->tail - b;
-	cl->stats.qlen = cl->q->q.qlen;
-	if (qdisc_copy_stats(skb, &cl->stats, cl->stats_lock))
-		goto rtattr_failure;
-	spin_lock_bh(&sch->dev->queue_lock);
+	return skb->len;
+
+rtattr_failure:
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static int
+cbq_dump_class_stats(struct Qdisc *sch, unsigned long arg,
+	struct gnet_dump *d)
+{
+	struct cbq_sched_data *q = qdisc_priv(sch);
+	struct cbq_class *cl = (struct cbq_class*)arg;
+
+	cl->qstats.qlen = cl->q->q.qlen;
 	cl->xstats.avgidle = cl->avgidle;
 	cl->xstats.undertime = 0;
+
 	if (!PSCHED_IS_PASTPERFECT(cl->undertime))
 		cl->xstats.undertime = PSCHED_TDIFF(cl->undertime, q->now);
-	if (cbq_copy_xstats(skb, &cl->xstats)) {
-		spin_unlock_bh(&sch->dev->queue_lock);
-		goto rtattr_failure;
-	}
-	spin_unlock_bh(&sch->dev->queue_lock);
 
-	return skb->len;
+	if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
+#ifdef CONFIG_NET_ESTIMATOR
+	    gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
+#endif
+	    gnet_stats_copy_queue(d, &cl->qstats) < 0)
+		return -1;
 
-rtattr_failure:
-	skb_trim(skb, b - skb->data);
-	return -1;
+	return gnet_stats_copy_app(d, &cl->xstats, sizeof(cl->xstats));
 }
 
 static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
@@ -1749,11 +1753,13 @@
 {
 	struct cbq_sched_data *q = qdisc_priv(sch);
 
+	BUG_TRAP(!cl->filters);
+
 	cbq_destroy_filters(cl);
 	qdisc_destroy(cl->q);
 	qdisc_put_rtab(cl->R_tab);
 #ifdef CONFIG_NET_ESTIMATOR
-	qdisc_kill_estimator(&cl->stats);
+	gen_kill_estimator(&cl->bstats, &cl->rate_est);
 #endif
 	if (cl != &q->link)
 		kfree(cl);
@@ -1769,6 +1775,14 @@
 #ifdef CONFIG_NET_CLS_POLICE
 	q->rx_class = NULL;
 #endif
+	/*
+	 * Filters must be destroyed first because we don't destroy the
+	 * classes from root to leafs which means that filters can still
+	 * be bound to classes which have been destroyed already. --TGR '04
+	 */
+	for (h = 0; h < 16; h++)
+		for (cl = q->classes[h]; cl; cl = cl->next)
+			cbq_destroy_filters(cl);
 
 	for (h = 0; h < 16; h++) {
 		struct cbq_class *next;
@@ -1891,11 +1905,9 @@
 		sch_tree_unlock(sch);
 
 #ifdef CONFIG_NET_ESTIMATOR
-		if (tca[TCA_RATE-1]) {
-			qdisc_kill_estimator(&cl->stats);
-			qdisc_new_estimator(&cl->stats, cl->stats_lock,
-					    tca[TCA_RATE-1]);
-		}
+		if (tca[TCA_RATE-1])
+			gen_replace_estimator(&cl->bstats, &cl->rate_est,
+				cl->stats_lock, tca[TCA_RATE-1]);
 #endif
 		return 0;
 	}
@@ -1985,8 +1997,8 @@
 
 #ifdef CONFIG_NET_ESTIMATOR
 	if (tca[TCA_RATE-1])
-		qdisc_new_estimator(&cl->stats, cl->stats_lock,
-				    tca[TCA_RATE-1]);
+		gen_new_estimator(&cl->bstats, &cl->rate_est,
+			cl->stats_lock, tca[TCA_RATE-1]);
 #endif
 
 	*arg = (unsigned long)cl;
@@ -2106,6 +2118,7 @@
 	.bind_tcf	=	cbq_bind_filter,
 	.unbind_tcf	=	cbq_unbind_filter,
 	.dump		=	cbq_dump_class,
+	.dump_stats	=	cbq_dump_class_stats,
 };
 
 static struct Qdisc_ops cbq_qdisc_ops = {
@@ -2122,6 +2135,7 @@
 	.destroy	=	cbq_destroy,
 	.change		=	NULL,
 	.dump		=	cbq_dump,
+	.dump_stats	=	cbq_dump_stats,
 	.owner		=	THIS_MODULE,
 };
 
diff -Nru a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
--- a/net/sched/sch_dsmark.c	2004-12-24 13:36:19 -08:00
+++ b/net/sched/sch_dsmark.c	2004-12-24 13:36:19 -08:00
@@ -241,11 +241,11 @@
 #endif
 
 	    ((ret = p->q->enqueue(skb,p->q)) != 0)) {
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return ret;
 	}
-	sch->stats.bytes += skb->len;
-	sch->stats.packets++;
+	sch->bstats.bytes += skb->len;
+	sch->bstats.packets++;
 	sch->q.qlen++;
 	return ret;
 }
@@ -297,9 +297,10 @@
 	D2PRINTK("dsmark_requeue(skb %p,sch %p,[qdisc %p])\n",skb,sch,p);
         if ((ret = p->q->ops->requeue(skb, p->q)) == 0) {
 		sch->q.qlen++;
+		sch->qstats.requeues++;
 		return 0;
 	}
-	sch->stats.drops++;
+	sch->qstats.drops++;
 	return ret;
 }
 
diff -Nru a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c
--- a/net/sched/sch_fifo.c	2004-12-24 13:36:31 -08:00
+++ b/net/sched/sch_fifo.c	2004-12-24 13:36:31 -08:00
@@ -13,7 +13,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -47,14 +47,14 @@
 {
 	struct fifo_sched_data *q = qdisc_priv(sch);
 
-	if (sch->stats.backlog + skb->len <= q->limit) {
+	if (sch->qstats.backlog + skb->len <= q->limit) {
 		__skb_queue_tail(&sch->q, skb);
-		sch->stats.backlog += skb->len;
-		sch->stats.bytes += skb->len;
-		sch->stats.packets++;
+		sch->qstats.backlog += skb->len;
+		sch->bstats.bytes += skb->len;
+		sch->bstats.packets++;
 		return 0;
 	}
-	sch->stats.drops++;
+	sch->qstats.drops++;
 #ifdef CONFIG_NET_CLS_POLICE
 	if (sch->reshape_fail==NULL || sch->reshape_fail(skb, sch))
 #endif
@@ -66,7 +66,8 @@
 bfifo_requeue(struct sk_buff *skb, struct Qdisc* sch)
 {
 	__skb_queue_head(&sch->q, skb);
-	sch->stats.backlog += skb->len;
+	sch->qstats.backlog += skb->len;
+	sch->qstats.requeues++;
 	return 0;
 }
 
@@ -77,7 +78,7 @@
 
 	skb = __skb_dequeue(&sch->q);
 	if (skb)
-		sch->stats.backlog -= skb->len;
+		sch->qstats.backlog -= skb->len;
 	return skb;
 }
 
@@ -89,7 +90,7 @@
 	skb = __skb_dequeue_tail(&sch->q);
 	if (skb) {
 		unsigned int len = skb->len;
-		sch->stats.backlog -= len;
+		sch->qstats.backlog -= len;
 		kfree_skb(skb);
 		return len;
 	}
@@ -100,7 +101,7 @@
 fifo_reset(struct Qdisc* sch)
 {
 	skb_queue_purge(&sch->q);
-	sch->stats.backlog = 0;
+	sch->qstats.backlog = 0;
 }
 
 static int
@@ -110,11 +111,11 @@
 
 	if (sch->q.qlen < q->limit) {
 		__skb_queue_tail(&sch->q, skb);
-		sch->stats.bytes += skb->len;
-		sch->stats.packets++;
+		sch->bstats.bytes += skb->len;
+		sch->bstats.packets++;
 		return 0;
 	}
-	sch->stats.drops++;
+	sch->qstats.drops++;
 #ifdef CONFIG_NET_CLS_POLICE
 	if (sch->reshape_fail==NULL || sch->reshape_fail(skb, sch))
 #endif
@@ -126,6 +127,7 @@
 pfifo_requeue(struct sk_buff *skb, struct Qdisc* sch)
 {
 	__skb_queue_head(&sch->q, skb);
+	sch->qstats.requeues++;
 	return 0;
 }
 
diff -Nru a/net/sched/sch_generic.c b/net/sched/sch_generic.c
--- a/net/sched/sch_generic.c	2004-12-24 13:36:17 -08:00
+++ b/net/sched/sch_generic.c	2004-12-24 13:36:17 -08:00
@@ -13,7 +13,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -280,6 +280,7 @@
 	.dequeue	=	noop_dequeue,
 	.flags		=	TCQ_F_BUILTIN,
 	.ops		=	&noop_qdisc_ops,	
+	.list		=	LIST_HEAD_INIT(noop_qdisc.list),
 };
 
 struct Qdisc_ops noqueue_qdisc_ops = {
@@ -298,6 +299,7 @@
 	.dequeue	=	noop_dequeue,
 	.flags		=	TCQ_F_BUILTIN,
 	.ops		=	&noqueue_qdisc_ops,
+	.list		=	LIST_HEAD_INIT(noqueue_qdisc.list),
 };
 
 
@@ -318,11 +320,11 @@
 	if (list->qlen < qdisc->dev->tx_queue_len) {
 		__skb_queue_tail(list, skb);
 		qdisc->q.qlen++;
-		qdisc->stats.bytes += skb->len;
-		qdisc->stats.packets++;
+		qdisc->bstats.bytes += skb->len;
+		qdisc->bstats.packets++;
 		return 0;
 	}
-	qdisc->stats.drops++;
+	qdisc->qstats.drops++;
 	kfree_skb(skb);
 	return NET_XMIT_DROP;
 }
@@ -353,6 +355,7 @@
 
 	__skb_queue_head(list, skb);
 	qdisc->q.qlen++;
+	qdisc->qstats.requeues++;
 	return 0;
 }
 
@@ -435,9 +438,6 @@
 	dev_hold(dev);
 	sch->stats_lock = &dev->queue_lock;
 	atomic_set(&sch->refcnt, 1);
-	/* enqueue is accessed locklessly - make sure it's visible
-	 * before we set a netdevice's qdisc pointer to sch */
-	smp_wmb();
 	if (!ops->init || ops->init(sch, NULL) == 0)
 		return sch;
 
@@ -465,7 +465,7 @@
 	struct Qdisc_ops  *ops = qdisc->ops;
 
 #ifdef CONFIG_NET_ESTIMATOR
-	qdisc_kill_estimator(&qdisc->stats);
+	gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est);
 #endif
 	write_lock(&qdisc_tree_lock);
 	if (ops->reset)
@@ -476,17 +476,39 @@
 	module_put(ops->owner);
 
 	dev_put(qdisc->dev);
-	if (!(qdisc->flags&TCQ_F_BUILTIN))
-		kfree((char *) qdisc - qdisc->padded);
+	kfree((char *) qdisc - qdisc->padded);
 }
 
 /* Under dev->queue_lock and BH! */
 
 void qdisc_destroy(struct Qdisc *qdisc)
 {
-	if (!atomic_dec_and_test(&qdisc->refcnt))
+	struct list_head cql = LIST_HEAD_INIT(cql);
+	struct Qdisc *cq, *q, *n;
+
+	if (qdisc->flags & TCQ_F_BUILTIN ||
+		!atomic_dec_and_test(&qdisc->refcnt))
 		return;
-	list_del(&qdisc->list);
+
+	if (!list_empty(&qdisc->list)) {
+		if (qdisc->ops->cl_ops == NULL)
+			list_del(&qdisc->list);
+		else
+			list_move(&qdisc->list, &cql);
+	}
+
+	/* unlink inner qdiscs from dev->qdisc_list immediately */
+	list_for_each_entry(cq, &cql, list)
+		list_for_each_entry_safe(q, n, &qdisc->dev->qdisc_list, list)
+			if (TC_H_MAJ(q->parent) == TC_H_MAJ(cq->handle)) {
+				if (q->ops->cl_ops == NULL)
+					list_del_init(&q->list);
+				else
+					list_move_tail(&q->list, &cql);
+			}
+	list_for_each_entry_safe(cq, n, &cql, list)
+		list_del_init(&cq->list);
+
 	call_rcu(&qdisc->q_rcu, __qdisc_destroy);
 }
 
@@ -518,7 +540,8 @@
 	}
 
 	spin_lock_bh(&dev->queue_lock);
-	if ((dev->qdisc = dev->qdisc_sleeping) != &noqueue_qdisc) {
+	rcu_assign_pointer(dev->qdisc, dev->qdisc_sleeping);
+	if (dev->qdisc != &noqueue_qdisc) {
 		dev->trans_start = jiffies;
 		dev_watchdog_up(dev);
 	}
diff -Nru a/net/sched/sch_gred.c b/net/sched/sch_gred.c
--- a/net/sched/sch_gred.c	2004-12-24 13:37:19 -08:00
+++ b/net/sched/sch_gred.c	2004-12-24 13:37:19 -08:00
@@ -24,7 +24,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -130,7 +130,7 @@
 
 	D2PRINTK("gred_enqueue virtualQ 0x%x classid %x backlog %d "
 	    "general backlog %d\n",skb->tc_index&0xf,sch->handle,q->backlog,
-	    sch->stats.backlog);
+	    sch->qstats.backlog);
 	/* sum up all the qaves of prios <= to ours to get the new qave*/
 	if (!t->eqp && t->grio) {
 		for (i=0;i<t->DPs;i++) {
@@ -161,7 +161,7 @@
 		q->qave >>= q->Stab[(us_idle>>q->Scell_log)&0xFF];
 	} else {
 		if (t->eqp) {
-			q->qave += sch->stats.backlog - (q->qave >> q->Wlog);
+			q->qave += sch->qstats.backlog - (q->qave >> q->Wlog);
 		} else {
 			q->qave += q->backlog - (q->qave >> q->Wlog);
 		}
@@ -179,9 +179,9 @@
 			q->backlog += skb->len;
 do_enqueue:
 			__skb_queue_tail(&sch->q, skb);
-			sch->stats.backlog += skb->len;
-			sch->stats.bytes += skb->len;
-			sch->stats.packets++;
+			sch->qstats.backlog += skb->len;
+			sch->bstats.bytes += skb->len;
+			sch->bstats.packets++;
 			return 0;
 		} else {
 			q->pdrop++;
@@ -189,12 +189,12 @@
 
 drop:
 		kfree_skb(skb);
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return NET_XMIT_DROP;
 	}
 	if ((q->qave+qave) >= q->qth_max) {
 		q->qcount = -1;
-		sch->stats.overlimits++;
+		sch->qstats.overlimits++;
 		q->forced++;
 		goto drop;
 	}
@@ -203,7 +203,7 @@
 			goto enqueue;
 		q->qcount = 0;
 		q->qR = net_random()&q->Rmask;
-		sch->stats.overlimits++;
+		sch->qstats.overlimits++;
 		q->early++;
 		goto drop;
 	}
@@ -221,7 +221,8 @@
 	PSCHED_SET_PASTPERFECT(q->qidlestart);
 
 	__skb_queue_head(&sch->q, skb);
-	sch->stats.backlog += skb->len;
+	sch->qstats.backlog += skb->len;
+	sch->qstats.requeues++;
 	q->backlog += skb->len;
 	return 0;
 }
@@ -235,7 +236,7 @@
 
 	skb = __skb_dequeue(&sch->q);
 	if (skb) {
-		sch->stats.backlog -= skb->len;
+		sch->qstats.backlog -= skb->len;
 		q= t->tab[(skb->tc_index&0xf)];
 		if (q) {
 			q->backlog -= skb->len;
@@ -269,8 +270,8 @@
 	skb = __skb_dequeue_tail(&sch->q);
 	if (skb) {
 		unsigned int len = skb->len;
-		sch->stats.backlog -= len;
-		sch->stats.drops++;
+		sch->qstats.backlog -= len;
+		sch->qstats.drops++;
 		q= t->tab[(skb->tc_index&0xf)];
 		if (q) {
 			q->backlog -= len;
@@ -304,7 +305,7 @@
 
 	__skb_queue_purge(&sch->q);
 
-	sch->stats.backlog = 0;
+	sch->qstats.backlog = 0;
 
         for (i=0;i<t->DPs;i++) {
 	        q= t->tab[i];
diff -Nru a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
--- a/net/sched/sch_hfsc.c	2004-12-24 13:36:18 -08:00
+++ b/net/sched/sch_hfsc.c	2004-12-24 13:36:18 -08:00
@@ -122,7 +122,9 @@
 	u32		classid;	/* class id */
 	unsigned int	refcnt;		/* usage count */
 
-	struct tc_stats	stats;		/* generic statistics */
+	struct gnet_stats_basic bstats;
+	struct gnet_stats_queue qstats;
+	struct gnet_stats_rate_est rate_est;
 	spinlock_t	*stats_lock;
 	unsigned int	level;		/* class level in hierarchy */
 	struct tcf_proto *filter_list;	/* filter list */
@@ -1098,11 +1100,9 @@
 		sch_tree_unlock(sch);
 
 #ifdef CONFIG_NET_ESTIMATOR
-		if (tca[TCA_RATE-1]) {
-			qdisc_kill_estimator(&cl->stats);
-			qdisc_new_estimator(&cl->stats, cl->stats_lock,
-					    tca[TCA_RATE-1]);
-		}
+		if (tca[TCA_RATE-1])
+			gen_replace_estimator(&cl->bstats, &cl->rate_est,
+				cl->stats_lock, tca[TCA_RATE-1]);
 #endif
 		return 0;
 	}
@@ -1160,8 +1160,8 @@
 
 #ifdef CONFIG_NET_ESTIMATOR
 	if (tca[TCA_RATE-1])
-		qdisc_new_estimator(&cl->stats, cl->stats_lock,
-				    tca[TCA_RATE-1]);
+		gen_new_estimator(&cl->bstats, &cl->rate_est,
+			cl->stats_lock, tca[TCA_RATE-1]);
 #endif
 	*arg = (unsigned long)cl;
 	return 0;
@@ -1186,7 +1186,7 @@
 	hfsc_destroy_filters(&cl->filter_list);
 	qdisc_destroy(cl->qdisc);
 #ifdef CONFIG_NET_ESTIMATOR
-	qdisc_kill_estimator(&cl->stats);
+	gen_kill_estimator(&cl->bstats, &cl->rate_est);
 #endif
 	if (cl != &q->root)
 		kfree(cl);
@@ -1404,36 +1404,6 @@
 	return -1;
 }
 
-static inline int
-hfsc_dump_stats(struct sk_buff *skb, struct hfsc_class *cl)
-{
-	cl->stats.qlen = cl->qdisc->q.qlen;
-	if (qdisc_copy_stats(skb, &cl->stats, cl->stats_lock) < 0)
-		goto rtattr_failure;
-
-	return skb->len;
-
- rtattr_failure:
-	return -1;
-}
-
-static inline int
-hfsc_dump_xstats(struct sk_buff *skb, struct hfsc_class *cl)
-{
-	struct tc_hfsc_stats xstats;
-
-	xstats.level  = cl->level;
-	xstats.period = cl->cl_vtperiod;
-	xstats.work   = cl->cl_total;
-	xstats.rtwork = cl->cl_cumul;
-	RTA_PUT(skb, TCA_XSTATS, sizeof(xstats), &xstats);
-
-	return skb->len;
-
- rtattr_failure:
-	return -1;
-}
-
 static int
 hfsc_dump_class(struct Qdisc *sch, unsigned long arg, struct sk_buff *skb,
                 struct tcmsg *tcm)
@@ -1451,11 +1421,6 @@
 	if (hfsc_dump_curves(skb, cl) < 0)
 		goto rtattr_failure;
 	rta->rta_len = skb->tail - b;
-
-	if ((hfsc_dump_stats(skb, cl) < 0) ||
-	    (hfsc_dump_xstats(skb, cl) < 0))
-		goto rtattr_failure;
-
 	return skb->len;
 
  rtattr_failure:
@@ -1463,6 +1428,31 @@
 	return -1;
 }
 
+static int
+hfsc_dump_class_stats(struct Qdisc *sch, unsigned long arg,
+	struct gnet_dump *d)
+{
+	struct hfsc_class *cl = (struct hfsc_class *)arg;
+	struct tc_hfsc_stats xstats;
+
+	cl->qstats.qlen = cl->qdisc->q.qlen;
+	xstats.level   = cl->level;
+	xstats.period  = cl->cl_vtperiod;
+	xstats.work    = cl->cl_total;
+	xstats.rtwork  = cl->cl_cumul;
+
+	if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
+#ifdef CONFIG_NET_ESTIMATOR
+	    gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
+#endif
+	    gnet_stats_copy_queue(d, &cl->qstats) < 0)
+		return -1;
+
+	return gnet_stats_copy_app(d, &xstats, sizeof(xstats));
+}
+
+
+
 static void
 hfsc_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 {
@@ -1653,11 +1643,6 @@
 
 	qopt.defcls = q->defcls;
 	RTA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt);
-
-	sch->stats.qlen = sch->q.qlen;
-	if (qdisc_copy_stats(skb, &sch->stats, sch->stats_lock) < 0)
-		goto rtattr_failure;
-
 	return skb->len;
 
  rtattr_failure:
@@ -1677,32 +1662,32 @@
 #ifdef CONFIG_NET_CLS_ACT
 	if (cl == NULL) {
 		if (NET_XMIT_DROP == ret) {
-			sch->stats.drops++;
+			sch->qstats.drops++;
 		}
 		return ret;
 	}
 #else
 	if (cl == NULL) {
 		kfree_skb(skb);
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return NET_XMIT_DROP;
 	}
 #endif
 
 	err = cl->qdisc->enqueue(skb, cl->qdisc);
 	if (unlikely(err != NET_XMIT_SUCCESS)) {
-		cl->stats.drops++;
-		sch->stats.drops++;
+		cl->qstats.drops++;
+		sch->qstats.drops++;
 		return err;
 	}
 
 	if (cl->qdisc->q.qlen == 1)
 		set_active(cl, len);
 
-	cl->stats.packets++;
-	cl->stats.bytes += len;
-	sch->stats.packets++;
-	sch->stats.bytes += len;
+	cl->bstats.packets++;
+	cl->bstats.bytes += len;
+	sch->bstats.packets++;
+	sch->bstats.bytes += len;
 	sch->q.qlen++;
 
 	return NET_XMIT_SUCCESS;
@@ -1739,7 +1724,7 @@
 		 */
 		cl = vttree_get_minvt(&q->root, cur_time);
 		if (cl == NULL) {
-			sch->stats.overlimits++;
+			sch->qstats.overlimits++;
 			hfsc_schedule_watchdog(sch, cur_time);
 			return NULL;
 		}
@@ -1784,6 +1769,7 @@
 
 	__skb_queue_head(&q->requeue, skb);
 	sch->q.qlen++;
+	sch->qstats.requeues++;
 	return NET_XMIT_SUCCESS;
 }
 
@@ -1803,8 +1789,8 @@
 			} else {
 				list_move_tail(&cl->dlist, &q->droplist);
 			}
-			cl->stats.drops++;
-			sch->stats.drops++;
+			cl->qstats.drops++;
+			sch->qstats.drops++;
 			sch->q.qlen--;
 			return len;
 		}
@@ -1823,6 +1809,7 @@
 	.unbind_tcf	= hfsc_unbind_tcf,
 	.tcf_chain	= hfsc_tcf_chain,
 	.dump		= hfsc_dump_class,
+	.dump_stats	= hfsc_dump_class_stats,
 	.walk		= hfsc_walk
 };
 
diff -Nru a/net/sched/sch_htb.c b/net/sched/sch_htb.c
--- a/net/sched/sch_htb.c	2004-12-24 13:37:00 -08:00
+++ b/net/sched/sch_htb.c	2004-12-24 13:37:00 -08:00
@@ -31,7 +31,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -142,8 +142,9 @@
 #endif
     /* general class parameters */
     u32 classid;
-    struct tc_stats	stats;	/* generic stats */
-    spinlock_t		*stats_lock;
+    struct gnet_stats_basic bstats;
+    struct gnet_stats_queue qstats;
+    struct gnet_stats_rate_est rate_est;
     struct tc_htb_xstats xstats;/* our special stats */
     int refcnt;			/* usage count of this class */
 
@@ -735,7 +736,7 @@
 	}
     } else if (!cl) {
 	    if (NET_XMIT_DROP == ret) {
-		    sch->stats.drops++;
+		    sch->qstats.drops++;
 	    }
 	    return ret;
     }
@@ -747,22 +748,22 @@
 	    q->direct_pkts++;
 	} else {
 	    kfree_skb (skb);
-	    sch->stats.drops++;
+	    sch->qstats.drops++;
 	    return NET_XMIT_DROP;
 	}
     }
 #endif
     else if (cl->un.leaf.q->enqueue(skb, cl->un.leaf.q) != NET_XMIT_SUCCESS) {
-	sch->stats.drops++;
-	cl->stats.drops++;
+	sch->qstats.drops++;
+	cl->qstats.drops++;
 	return NET_XMIT_DROP;
     } else {
-	cl->stats.packets++; cl->stats.bytes += skb->len;
+	cl->bstats.packets++; cl->bstats.bytes += skb->len;
 	htb_activate (q,cl);
     }
 
     sch->q.qlen++;
-    sch->stats.packets++; sch->stats.bytes += skb->len;
+    sch->bstats.packets++; sch->bstats.bytes += skb->len;
     HTB_DBG(1,1,"htb_enq_ok cl=%X skb=%p\n",(cl && cl != HTB_DIRECT)?cl->classid:0,skb);
     return NET_XMIT_SUCCESS;
 }
@@ -783,17 +784,18 @@
             __skb_queue_head(&q->direct_queue, skb);
             tskb = __skb_dequeue_tail(&q->direct_queue);
             kfree_skb (tskb);
-            sch->stats.drops++;
+            sch->qstats.drops++;
             return NET_XMIT_CN;	
 	}
     } else if (cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q) != NET_XMIT_SUCCESS) {
-	sch->stats.drops++;
-	cl->stats.drops++;
+	sch->qstats.drops++;
+	cl->qstats.drops++;
 	return NET_XMIT_DROP;
     } else 
 	    htb_activate (q,cl);
 
     sch->q.qlen++;
+    sch->qstats.requeues++;
     HTB_DBG(1,1,"htb_req_ok cl=%X skb=%p\n",(cl && cl != HTB_DIRECT)?cl->classid:0,skb);
     return NET_XMIT_SUCCESS;
 }
@@ -905,8 +907,8 @@
 
 		/* update byte stats except for leaves which are already updated */
 		if (cl->level) {
-			cl->stats.bytes += bytes;
-			cl->stats.packets++;
+			cl->bstats.bytes += bytes;
+			cl->bstats.packets++;
 		}
 		cl = cl->parent;
 	}
@@ -1117,7 +1119,7 @@
 	/* why don't use jiffies here ? because expires can be in past */
 	mod_timer(&q->timer, q->jiffies + delay);
 	sch->flags |= TCQ_F_THROTTLED;
-	sch->stats.overlimits++;
+	sch->qstats.overlimits++;
 	HTB_DBG(3,1,"htb_deq t_delay=%ld\n",delay);
 }
 
@@ -1316,7 +1318,6 @@
 	struct rtattr *rta;
 	struct tc_htb_glob gopt;
 	HTB_DBG(0,1,"htb_dump sch=%p, handle=%X\n",sch,sch->handle);
-	/* stats */
 	HTB_QLOCK(sch);
 	gopt.direct_pkts = q->direct_pkts;
 
@@ -1332,8 +1333,6 @@
 	RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
 	RTA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt);
 	rta->rta_len = skb->tail - b;
-	sch->stats.qlen = sch->q.qlen;
-	RTA_PUT(skb, TCA_STATS, sizeof(sch->stats), &sch->stats);
 	HTB_QUNLOCK(sch);
 	return skb->len;
 rtattr_failure:
@@ -1358,10 +1357,8 @@
 	HTB_QLOCK(sch);
 	tcm->tcm_parent = cl->parent ? cl->parent->classid : TC_H_ROOT;
 	tcm->tcm_handle = cl->classid;
-	if (!cl->level && cl->un.leaf.q) {
+	if (!cl->level && cl->un.leaf.q)
 		tcm->tcm_info = cl->un.leaf.q->handle;
-		cl->stats.qlen = cl->un.leaf.q->q.qlen;
-	}
 
 	rta = (struct rtattr*)b;
 	RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
@@ -1374,16 +1371,6 @@
 	opt.level = cl->level; 
 	RTA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt);
 	rta->rta_len = skb->tail - b;
-
-#ifdef HTB_RATECM
-	cl->stats.bps = cl->rate_bytes/(HTB_EWMAC*HTB_HSIZE);
-	cl->stats.pps = cl->rate_packets/(HTB_EWMAC*HTB_HSIZE);
-#endif
-
-	cl->xstats.tokens = cl->tokens;
-	cl->xstats.ctokens = cl->ctokens;
-	RTA_PUT(skb, TCA_STATS, sizeof(cl->stats), &cl->stats);
-	RTA_PUT(skb, TCA_XSTATS, sizeof(cl->xstats), &cl->xstats);
 	HTB_QUNLOCK(sch);
 	return skb->len;
 rtattr_failure:
@@ -1392,6 +1379,30 @@
 	return -1;
 }
 
+static int
+htb_dump_class_stats(struct Qdisc *sch, unsigned long arg,
+	struct gnet_dump *d)
+{
+	struct htb_class *cl = (struct htb_class*)arg;
+
+#ifdef HTB_RATECM
+	cl->rate_est.bps = cl->rate_bytes/(HTB_EWMAC*HTB_HSIZE);
+	cl->rate_est.pps = cl->rate_packets/(HTB_EWMAC*HTB_HSIZE);
+#endif
+
+	if (!cl->level && cl->un.leaf.q)
+		cl->qstats.qlen = cl->un.leaf.q->q.qlen;
+	cl->xstats.tokens = cl->tokens;
+	cl->xstats.ctokens = cl->ctokens;
+
+	if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
+	    gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
+	    gnet_stats_copy_queue(d, &cl->qstats) < 0)
+		return -1;
+
+	return gnet_stats_copy_app(d, &cl->xstats, sizeof(cl->xstats));
+}
+
 static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
 	struct Qdisc **old)
 {
@@ -1456,9 +1467,6 @@
 	qdisc_put_rtab(cl->rate);
 	qdisc_put_rtab(cl->ceil);
 	
-#ifdef CONFIG_NET_ESTIMATOR
-	qdisc_kill_estimator(&cl->stats);
-#endif
 	htb_destroy_filters (&cl->filter_list);
 	
 	while (!list_empty(&cl->children)) 
@@ -1746,6 +1754,7 @@
 	.bind_tcf	=	htb_bind_filter,
 	.unbind_tcf	=	htb_unbind_filter,
 	.dump		=	htb_dump_class,
+	.dump_stats	=	htb_dump_class_stats,
 };
 
 static struct Qdisc_ops htb_qdisc_ops = {
diff -Nru a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
--- a/net/sched/sch_ingress.c	2004-12-24 13:37:44 -08:00
+++ b/net/sched/sch_ingress.c	2004-12-24 13:37:44 -08:00
@@ -151,12 +151,12 @@
 	 * firewall FW_* code.
 	 */
 #ifdef CONFIG_NET_CLS_ACT
-	sch->stats.packets++;
-	sch->stats.bytes += skb->len;
+	sch->bstats.packets++;
+	sch->bstats.bytes += skb->len;
 	switch (result) {
 		case TC_ACT_SHOT:
 			result = TC_ACT_SHOT;
-			sch->stats.drops++;
+			sch->qstats.drops++;
 			break;
 		case TC_ACT_STOLEN:
 		case TC_ACT_QUEUED:
@@ -176,14 +176,14 @@
 	switch (result) {
 		case TC_POLICE_SHOT:
 		result = NF_DROP;
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		break;
 		case TC_POLICE_RECLASSIFY: /* DSCP remarking here ? */
 		case TC_POLICE_OK:
 		case TC_POLICE_UNSPEC:
 		default:
-		sch->stats.packets++;
-		sch->stats.bytes += skb->len;
+		sch->bstats.packets++;
+		sch->bstats.bytes += skb->len;
 		result = NF_ACCEPT;
 		break;
 	};
@@ -191,8 +191,8 @@
 #else
 	D2PRINTK("Overriding result to ACCEPT\n");
 	result = NF_ACCEPT;
-	sch->stats.packets++;
-	sch->stats.bytes += skb->len;
+	sch->bstats.packets++;
+	sch->bstats.bytes += skb->len;
 #endif
 #endif
 
diff -Nru a/net/sched/sch_netem.c b/net/sched/sch_netem.c
--- a/net/sched/sch_netem.c	2004-12-24 13:37:29 -08:00
+++ b/net/sched/sch_netem.c	2004-12-24 13:37:29 -08:00
@@ -15,7 +15,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -142,23 +142,27 @@
 {
 	struct netem_sched_data *q = qdisc_priv(sch);
 	struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
+	psched_tdiff_t td;
 	psched_time_t now;
 	
 	PSCHED_GET_TIME(now);
-	PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
-				    &q->delay_cor, q->delay_dist),
-		     cb->time_to_send);
+	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
+	PSCHED_TADD2(now, td, cb->time_to_send);
 	
 	/* Always queue at tail to keep packets in order */
 	if (likely(q->delayed.qlen < q->limit)) {
 		__skb_queue_tail(&q->delayed, skb);
-		sch->q.qlen++;
-		sch->stats.bytes += skb->len;
-		sch->stats.packets++;
+		sch->bstats.bytes += skb->len;
+		sch->bstats.packets++;
+
+		if (!timer_pending(&q->timer)) {
+			q->timer.expires = jiffies + PSCHED_US2JIFFIE(td);
+			add_timer(&q->timer);
+		}
 		return NET_XMIT_SUCCESS;
 	}
 
-	sch->stats.drops++;
+	sch->qstats.drops++;
 	kfree_skb(skb);
 	return NET_XMIT_DROP;
 }
@@ -172,7 +176,7 @@
 	/* Random packet drop 0 => none, ~0 => all */
 	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
 		pr_debug("netem_enqueue: random loss\n");
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return 0;	/* lie about loss so TCP doesn't know */
 	}
 
@@ -195,8 +199,12 @@
 
 		++q->counter;
 		ret = q->qdisc->enqueue(skb, q->qdisc);
-		if (ret)
-			sch->stats.drops++;
+		if (likely(ret == NET_XMIT_SUCCESS)) {
+			sch->q.qlen++;
+			sch->bstats.bytes += skb->len;
+			sch->bstats.packets++;
+		} else
+			sch->qstats.drops++;
 		return ret;
 	}
 	
@@ -211,8 +219,10 @@
 	struct netem_sched_data *q = qdisc_priv(sch);
 	int ret;
 
-	if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0)
+	if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0) {
 		sch->q.qlen++;
+		sch->qstats.requeues++;
+	}
 
 	return ret;
 }
@@ -224,7 +234,7 @@
 
 	if ((len = q->qdisc->ops->drop(q->qdisc)) != 0) {
 		sch->q.qlen--;
-		sch->stats.drops++;
+		sch->qstats.drops++;
 	}
 	return len;
 }
@@ -237,15 +247,32 @@
 {
 	struct netem_sched_data *q = qdisc_priv(sch);
 	struct sk_buff *skb;
+
+	skb = q->qdisc->dequeue(q->qdisc);
+	if (skb) 
+		sch->q.qlen--;
+	return skb;
+}
+
+static void netem_watchdog(unsigned long arg)
+{
+	struct Qdisc *sch = (struct Qdisc *)arg;
+	struct netem_sched_data *q = qdisc_priv(sch);
+	struct net_device *dev = sch->dev;
+	struct sk_buff *skb;
 	psched_time_t now;
 
+	pr_debug("netem_watchdog: fired @%lu\n", jiffies);
+
+	spin_lock_bh(&dev->queue_lock);
 	PSCHED_GET_TIME(now);
+
 	while ((skb = skb_peek(&q->delayed)) != NULL) {
 		const struct netem_skb_cb *cb
 			= (const struct netem_skb_cb *)skb->cb;
 		long delay 
 			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
-		pr_debug("netem_dequeue: delay queue %p@%lu %ld\n",
+		pr_debug("netem_watchdog: skb %p@%lu %ld\n",
 			 skb, jiffies, delay);
 
 		/* if more time remaining? */
@@ -256,21 +283,12 @@
 		__skb_unlink(skb, &q->delayed);
 
 		if (q->qdisc->enqueue(skb, q->qdisc))
-			sch->stats.drops++;
+			sch->qstats.drops++;
+		else
+			sch->q.qlen++;
 	}
-
-	skb = q->qdisc->dequeue(q->qdisc);
-	if (skb) 
-		sch->q.qlen--;
-	return skb;
-}
-
-static void netem_watchdog(unsigned long arg)
-{
-	struct Qdisc *sch = (struct Qdisc *)arg;
-
-	pr_debug("netem_watchdog: fired @%lu\n", jiffies);
-	netif_schedule(sch->dev);
+	qdisc_run(dev);
+	spin_unlock_bh(&dev->queue_lock);
 }
 
 static void netem_reset(struct Qdisc *sch)
diff -Nru a/net/sched/sch_prio.c b/net/sched/sch_prio.c
--- a/net/sched/sch_prio.c	2004-12-24 13:36:48 -08:00
+++ b/net/sched/sch_prio.c	2004-12-24 13:36:48 -08:00
@@ -15,7 +15,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -107,8 +107,8 @@
 		goto dropped;
 
 	if ((ret = qdisc->enqueue(skb, qdisc)) == NET_XMIT_SUCCESS) {
-		sch->stats.bytes += skb->len;
-		sch->stats.packets++;
+		sch->bstats.bytes += skb->len;
+		sch->bstats.packets++;
 		sch->q.qlen++;
 		return NET_XMIT_SUCCESS;
 	}
@@ -117,10 +117,10 @@
 #ifdef CONFIG_NET_CLS_ACT
 	if (NET_XMIT_DROP == ret) {
 #endif
-		sch->stats.drops++;
+		sch->qstats.drops++;
 #ifdef CONFIG_NET_CLS_ACT
 	} else {
-		sch->stats.overlimits++; /* abuse, but noone uses it */
+		sch->qstats.overlimits++; /* abuse, but noone uses it */
 	}
 #endif
 	return ret; 
@@ -139,10 +139,11 @@
 
 	if ((ret = qdisc->ops->requeue(skb, qdisc)) == 0) {
 		sch->q.qlen++;
+		sch->qstats.requeues++;
 		return 0;
 	}
 dropped:
-	sch->stats.drops++;
+	sch->qstats.drops++;
 	return NET_XMIT_DROP;
 }
 
diff -Nru a/net/sched/sch_red.c b/net/sched/sch_red.c
--- a/net/sched/sch_red.c	2004-12-24 13:37:30 -08:00
+++ b/net/sched/sch_red.c	2004-12-24 13:37:30 -08:00
@@ -18,7 +18,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -228,13 +228,13 @@
 				q->qave >>= 1;
 		}
 	} else {
-		q->qave += sch->stats.backlog - (q->qave >> q->Wlog);
+		q->qave += sch->qstats.backlog - (q->qave >> q->Wlog);
 		/* NOTE:
 		   q->qave is fixed point number with point at Wlog.
 		   The formulae above is equvalent to floating point
 		   version:
 
-		   qave = qave*(1-W) + sch->stats.backlog*W;
+		   qave = qave*(1-W) + sch->qstats.backlog*W;
 		                                           --ANK (980924)
 		 */
 	}
@@ -242,22 +242,22 @@
 	if (q->qave < q->qth_min) {
 		q->qcount = -1;
 enqueue:
-		if (sch->stats.backlog + skb->len <= q->limit) {
+		if (sch->qstats.backlog + skb->len <= q->limit) {
 			__skb_queue_tail(&sch->q, skb);
-			sch->stats.backlog += skb->len;
-			sch->stats.bytes += skb->len;
-			sch->stats.packets++;
+			sch->qstats.backlog += skb->len;
+			sch->bstats.bytes += skb->len;
+			sch->bstats.packets++;
 			return NET_XMIT_SUCCESS;
 		} else {
 			q->st.pdrop++;
 		}
 		kfree_skb(skb);
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return NET_XMIT_DROP;
 	}
 	if (q->qave >= q->qth_max) {
 		q->qcount = -1;
-		sch->stats.overlimits++;
+		sch->qstats.overlimits++;
 mark:
 		if  (!(q->flags&TC_RED_ECN) || !red_ecn_mark(skb)) {
 			q->st.early++;
@@ -288,7 +288,7 @@
 			goto enqueue;
 		q->qcount = 0;
 		q->qR = net_random()&q->Rmask;
-		sch->stats.overlimits++;
+		sch->qstats.overlimits++;
 		goto mark;
 	}
 	q->qR = net_random()&q->Rmask;
@@ -296,7 +296,7 @@
 
 drop:
 	kfree_skb(skb);
-	sch->stats.drops++;
+	sch->qstats.drops++;
 	return NET_XMIT_CN;
 }
 
@@ -308,7 +308,8 @@
 	PSCHED_SET_PASTPERFECT(q->qidlestart);
 
 	__skb_queue_head(&sch->q, skb);
-	sch->stats.backlog += skb->len;
+	sch->qstats.backlog += skb->len;
+	sch->qstats.requeues++;
 	return 0;
 }
 
@@ -320,7 +321,7 @@
 
 	skb = __skb_dequeue(&sch->q);
 	if (skb) {
-		sch->stats.backlog -= skb->len;
+		sch->qstats.backlog -= skb->len;
 		return skb;
 	}
 	PSCHED_GET_TIME(q->qidlestart);
@@ -335,8 +336,8 @@
 	skb = __skb_dequeue_tail(&sch->q);
 	if (skb) {
 		unsigned int len = skb->len;
-		sch->stats.backlog -= len;
-		sch->stats.drops++;
+		sch->qstats.backlog -= len;
+		sch->qstats.drops++;
 		q->st.other++;
 		kfree_skb(skb);
 		return len;
@@ -350,7 +351,7 @@
 	struct red_sched_data *q = qdisc_priv(sch);
 
 	__skb_queue_purge(&sch->q);
-	sch->stats.backlog = 0;
+	sch->qstats.backlog = 0;
 	PSCHED_SET_PASTPERFECT(q->qidlestart);
 	q->qave = 0;
 	q->qcount = -1;
@@ -395,16 +396,6 @@
 	return red_change(sch, opt);
 }
 
-
-int red_copy_xstats(struct sk_buff *skb, struct tc_red_xstats *st)
-{
-        RTA_PUT(skb, TCA_XSTATS, sizeof(*st), st);
-        return 0;
-
-rtattr_failure:
-        return 1;
-}
-
 static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
 {
 	struct red_sched_data *q = qdisc_priv(sch);
@@ -424,9 +415,6 @@
 	RTA_PUT(skb, TCA_RED_PARMS, sizeof(opt), &opt);
 	rta->rta_len = skb->tail - b;
 
-	if (red_copy_xstats(skb, &q->st))
-		goto rtattr_failure;
-
 	return skb->len;
 
 rtattr_failure:
@@ -434,6 +422,13 @@
 	return -1;
 }
 
+static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
+{
+	struct red_sched_data *q = qdisc_priv(sch);
+
+	return gnet_stats_copy_app(d, &q->st, sizeof(q->st));
+}
+
 static struct Qdisc_ops red_qdisc_ops = {
 	.next		=	NULL,
 	.cl_ops		=	NULL,
@@ -447,6 +442,7 @@
 	.reset		=	red_reset,
 	.change		=	red_change,
 	.dump		=	red_dump,
+	.dump_stats	=	red_dump_stats,
 	.owner		=	THIS_MODULE,
 };
 
diff -Nru a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
--- a/net/sched/sch_sfq.c	2004-12-24 13:37:19 -08:00
+++ b/net/sched/sch_sfq.c	2004-12-24 13:37:19 -08:00
@@ -13,7 +13,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/jiffies.h>
@@ -227,7 +227,7 @@
 		kfree_skb(skb);
 		sfq_dec(q, x);
 		sch->q.qlen--;
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return len;
 	}
 
@@ -243,7 +243,7 @@
 		sfq_dec(q, d);
 		sch->q.qlen--;
 		q->ht[q->hash[d]] = SFQ_DEPTH;
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return len;
 	}
 
@@ -276,8 +276,8 @@
 		}
 	}
 	if (++sch->q.qlen < q->limit-1) {
-		sch->stats.bytes += skb->len;
-		sch->stats.packets++;
+		sch->bstats.bytes += skb->len;
+		sch->bstats.packets++;
 		return 0;
 	}
 
@@ -310,10 +310,12 @@
 			q->tail = x;
 		}
 	}
-	if (++sch->q.qlen < q->limit - 1)
+	if (++sch->q.qlen < q->limit - 1) {
+		sch->qstats.requeues++;
 		return 0;
+	}
 
-	sch->stats.drops++;
+	sch->qstats.drops++;
 	sfq_drop(sch);
 	return NET_XMIT_CN;
 }
diff -Nru a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
--- a/net/sched/sch_tbf.c	2004-12-24 13:36:17 -08:00
+++ b/net/sched/sch_tbf.c	2004-12-24 13:36:17 -08:00
@@ -16,7 +16,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/jiffies.h>
@@ -141,7 +141,7 @@
 	int ret;
 
 	if (skb->len > q->max_size) {
-		sch->stats.drops++;
+		sch->qstats.drops++;
 #ifdef CONFIG_NET_CLS_POLICE
 		if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch))
 #endif
@@ -151,13 +151,13 @@
 	}
 
 	if ((ret = q->qdisc->enqueue(skb, q->qdisc)) != 0) {
-		sch->stats.drops++;
+		sch->qstats.drops++;
 		return ret;
 	}
 
 	sch->q.qlen++;
-	sch->stats.bytes += skb->len;
-	sch->stats.packets++;
+	sch->bstats.bytes += skb->len;
+	sch->bstats.packets++;
 	return 0;
 }
 
@@ -166,8 +166,10 @@
 	struct tbf_sched_data *q = qdisc_priv(sch);
 	int ret;
 
-	if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0)
+	if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0) {
 		sch->q.qlen++;
+		sch->qstats.requeues++;
+	}
 
 	return ret;
 }
@@ -179,7 +181,7 @@
 
 	if ((len = q->qdisc->ops->drop(q->qdisc)) != 0) {
 		sch->q.qlen--;
-		sch->stats.drops++;
+		sch->qstats.drops++;
 	}
 	return len;
 }
@@ -250,11 +252,11 @@
 		if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
 			/* When requeue fails skb is dropped */
 			sch->q.qlen--;
-			sch->stats.drops++;
+			sch->qstats.drops++;
 		}
 
 		sch->flags |= TCQ_F_THROTTLED;
-		sch->stats.overlimits++;
+		sch->qstats.overlimits++;
 	}
 	return NULL;
 }
diff -Nru a/net/sched/sch_teql.c b/net/sched/sch_teql.c
--- a/net/sched/sch_teql.c	2004-12-24 13:36:31 -08:00
+++ b/net/sched/sch_teql.c	2004-12-24 13:36:31 -08:00
@@ -11,7 +11,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -96,14 +96,14 @@
 
 	__skb_queue_tail(&q->q, skb);
 	if (q->q.qlen <= dev->tx_queue_len) {
-		sch->stats.bytes += skb->len;
-		sch->stats.packets++;
+		sch->bstats.bytes += skb->len;
+		sch->bstats.packets++;
 		return 0;
 	}
 
 	__skb_unlink(skb, &q->q);
 	kfree_skb(skb);
-	sch->stats.drops++;
+	sch->qstats.drops++;
 	return NET_XMIT_DROP;
 }
 
@@ -113,6 +113,7 @@
 	struct teql_sched_data *q = qdisc_priv(sch);
 
 	__skb_queue_head(&q->q, skb);
+	sch->qstats.requeues++;
 	return 0;
 }
 
diff -Nru a/net/sctp/associola.c b/net/sctp/associola.c
--- a/net/sctp/associola.c	2004-12-24 13:36:17 -08:00
+++ b/net/sctp/associola.c	2004-12-24 13:36:17 -08:00
@@ -125,7 +125,7 @@
 
 	/* Initialize the bind addr area.  */
 	sctp_bind_addr_init(&asoc->base.bind_addr, ep->base.bind_addr.port);
-	asoc->base.addr_lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&asoc->base.addr_lock);
 
 	asoc->state = SCTP_STATE_CLOSED;
 
@@ -271,7 +271,7 @@
 
 	asoc->need_ecne = 0;
 
-	asoc->assoc_id = (sctp_assoc_t)-1L;
+	asoc->assoc_id = 0;
 
 	/* Assume that peer would support both address types unless we are
 	 * told otherwise.
@@ -374,9 +374,9 @@
 	sctp_endpoint_put(asoc->ep);
 	sock_put(asoc->base.sk);
 
-	if ((long)asoc->assoc_id != -1L) {
+	if (asoc->assoc_id != 0) {
 		spin_lock_bh(&sctp_assocs_id_lock);
-		idr_remove(&sctp_assocs_id, (long)asoc->assoc_id);
+		idr_remove(&sctp_assocs_id, asoc->assoc_id);
 		spin_unlock_bh(&sctp_assocs_id_lock);
 	}
 
@@ -482,14 +482,15 @@
 
 	/* 7.2.1 Slow-Start
 	 *
-	 * o The initial cwnd before data transmission or after a
-	 *   sufficiently long idle period MUST be <= 2*MTU.
+	 * o The initial cwnd before DATA transmission or after a sufficiently
+	 *   long idle period MUST be set to
+	 *      min(4*MTU, max(2*MTU, 4380 bytes))
 	 *
 	 * o The initial value of ssthresh MAY be arbitrarily high
 	 *   (for example, implementations MAY use the size of the
 	 *   receiver advertised window).
 	 */
-	peer->cwnd = asoc->pmtu * 2;
+	peer->cwnd = min(4*asoc->pmtu, max_t(__u32, 2*asoc->pmtu, 4380));
 
 	/* At this point, we may not have the receiver's advertised window,
 	 * so initialize ssthresh to the default value and it will be set
diff -Nru a/net/sctp/endpointola.c b/net/sctp/endpointola.c
--- a/net/sctp/endpointola.c	2004-12-24 13:36:18 -08:00
+++ b/net/sctp/endpointola.c	2004-12-24 13:36:18 -08:00
@@ -113,7 +113,7 @@
 
 	/* Initialize the bind addr area */
 	sctp_bind_addr_init(&ep->base.bind_addr, 0);
-	ep->base.addr_lock = RW_LOCK_UNLOCKED;
+	rwlock_init(&ep->base.addr_lock);
 
 	/* Remember who we are attached to.  */
 	ep->base.sk = sk;
diff -Nru a/net/sctp/ipv6.c b/net/sctp/ipv6.c
--- a/net/sctp/ipv6.c	2004-12-24 13:37:00 -08:00
+++ b/net/sctp/ipv6.c	2004-12-24 13:37:00 -08:00
@@ -78,7 +78,10 @@
 
 #include <asm/uaccess.h>
 
-extern struct notifier_block sctp_inetaddr_notifier;
+extern int sctp_inetaddr_event(struct notifier_block *, unsigned long, void *);
+static struct notifier_block sctp_inet6addr_notifier = {
+	.notifier_call = sctp_inetaddr_event,
+};
 
 /* ICMP error handler. */
 void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
@@ -461,7 +464,7 @@
 		}
 		return 0;
 	}
-	if (ipv6_addr_cmp(&addr1->v6.sin6_addr, &addr2->v6.sin6_addr))
+	if (!ipv6_addr_equal(&addr1->v6.sin6_addr, &addr2->v6.sin6_addr))
 		return 0;
 	/* If this is a linklocal address, compare the scope_id. */
 	if (ipv6_addr_type(&addr1->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL) {
@@ -983,7 +986,7 @@
 	sctp_register_af(&sctp_ipv6_specific);
 
 	/* Register notifier for inet6 address additions/deletions. */
-	register_inet6addr_notifier(&sctp_inetaddr_notifier);
+	register_inet6addr_notifier(&sctp_inet6addr_notifier);
 	rc = 0;
 out:
 	return rc;
@@ -999,6 +1002,6 @@
 	inet6_del_protocol(&sctpv6_protocol, IPPROTO_SCTP);
 	inet6_unregister_protosw(&sctpv6_seqpacket_protosw);
 	inet6_unregister_protosw(&sctpv6_stream_protosw);
-	unregister_inet6addr_notifier(&sctp_inetaddr_notifier);
+	unregister_inet6addr_notifier(&sctp_inet6addr_notifier);
 	sk_free_slab(&sctpv6_prot);
 }
diff -Nru a/net/sctp/outqueue.c b/net/sctp/outqueue.c
--- a/net/sctp/outqueue.c	2004-12-24 13:36:34 -08:00
+++ b/net/sctp/outqueue.c	2004-12-24 13:36:34 -08:00
@@ -98,16 +98,6 @@
 	return;
 }
 
-/* Insert a chunk behind chunk 'pos'. */
-static inline void sctp_outq_insert_data(struct sctp_outq *q,
-					 struct sctp_chunk *ch,
-					 struct sctp_chunk *pos)
-{
-	__skb_insert((struct sk_buff *)ch, (struct sk_buff *)pos->prev,
-		     (struct sk_buff *)pos, pos->list);
-	q->out_qlen += ch->skb->len;
-}
-
 /*
  * SFR-CACC algorithm:
  * D) If count_of_newacks is greater than or equal to 2
@@ -706,10 +696,19 @@
 		if (!new_transport) {
 			new_transport = asoc->peer.active_path;
 		} else if (!new_transport->active) {
-			/* If the chunk is Heartbeat, send it to
-			 * chunk->transport, even it's inactive.
+			/* If the chunk is Heartbeat or Heartbeat Ack, 
+			 * send it to chunk->transport, even if it's 
+			 * inactive.
+			 *
+			 * 3.3.6 Heartbeat Acknowledgement:
+			 * ...  
+			 * A HEARTBEAT ACK is always sent to the source IP
+			 * address of the IP datagram containing the
+			 * HEARTBEAT chunk to which this ack is responding.
+			 * ...  
 			 */
-			if (chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT)
+			if (chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT &&
+			    chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT_ACK)
 				new_transport = asoc->peer.active_path;
 		}
 
diff -Nru a/net/sctp/protocol.c b/net/sctp/protocol.c
--- a/net/sctp/protocol.c	2004-12-24 13:37:00 -08:00
+++ b/net/sctp/protocol.c	2004-12-24 13:37:00 -08:00
@@ -622,8 +622,8 @@
 /* Event handler for inet address addition/deletion events.
  * Basically, whenever there is an event, we re-build our local address list.
  */
-static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
-			       void *ptr)
+int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
+                        void *ptr)
 {
 	unsigned long flags;
 
@@ -824,7 +824,7 @@
 };
 
 /* Notifier for inetaddr addition/deletion events.  */
-struct notifier_block sctp_inetaddr_notifier = {
+static struct notifier_block sctp_inetaddr_notifier = {
 	.notifier_call = sctp_inetaddr_event,
 };
 
@@ -1084,7 +1084,7 @@
 		goto err_ahash_alloc;
 	}
 	for (i = 0; i < sctp_assoc_hashsize; i++) {
-		sctp_assoc_hashtable[i].lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&sctp_assoc_hashtable[i].lock);
 		sctp_assoc_hashtable[i].chain = NULL;
 	}
 
@@ -1098,7 +1098,7 @@
 		goto err_ehash_alloc;
 	}
 	for (i = 0; i < sctp_ep_hashsize; i++) {
-		sctp_ep_hashtable[i].lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&sctp_ep_hashtable[i].lock);
 		sctp_ep_hashtable[i].chain = NULL;
 	}
 
@@ -1117,11 +1117,11 @@
 		goto err_bhash_alloc;
 	}
 	for (i = 0; i < sctp_port_hashsize; i++) {
-		sctp_port_hashtable[i].lock = SPIN_LOCK_UNLOCKED;
+		spin_lock_init(&sctp_port_hashtable[i].lock);
 		sctp_port_hashtable[i].chain = NULL;
 	}
 
-	sctp_port_alloc_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&sctp_port_alloc_lock);
 	sctp_port_rover = sysctl_local_port_range[0] - 1;
 
 	printk(KERN_INFO "SCTP: Hash tables configured "
@@ -1152,7 +1152,7 @@
 
 	/* Initialize the local address list. */
 	INIT_LIST_HEAD(&sctp_local_addr_list);
-	sctp_local_addr_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&sctp_local_addr_lock);
 
 	/* Register notifier for inet address additions/deletions. */
 	register_inetaddr_notifier(&sctp_inetaddr_notifier);
diff -Nru a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
--- a/net/sctp/sm_make_chunk.c	2004-12-24 13:36:18 -08:00
+++ b/net/sctp/sm_make_chunk.c	2004-12-24 13:36:18 -08:00
@@ -171,6 +171,7 @@
 	struct sctp_opt *sp;
 	sctp_supported_addrs_param_t sat;
 	__u16 types[2];
+	sctp_adaption_ind_param_t aiparam;
 
 	/* RFC 2960 3.3.2 Initiation (INIT) (1)
 	 *
@@ -196,6 +197,7 @@
 	chunksize += sizeof(ecap_param);
 	if (sctp_prsctp_enable)
 		chunksize += sizeof(prsctp_param);
+	chunksize += sizeof(aiparam);
 	chunksize += vparam_len;
 
 	/* RFC 2960 3.3.2 Initiation (INIT) (1)
@@ -234,6 +236,10 @@
 	sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param);
 	if (sctp_prsctp_enable)
 		sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param);
+	aiparam.param_hdr.type = SCTP_PARAM_ADAPTION_LAYER_IND;
+	aiparam.param_hdr.length = htons(sizeof(aiparam));
+	aiparam.adaption_ind = htonl(sp->adaption_ind);
+	sctp_addto_chunk(retval, sizeof(aiparam), &aiparam);
 nodata:
 	if (addrs.v)
 		kfree(addrs.v);
@@ -251,6 +257,7 @@
 	sctp_cookie_param_t *cookie;
 	int cookie_len;
 	size_t chunksize;
+	sctp_adaption_ind_param_t aiparam;
 
 	retval = NULL;
 
@@ -284,6 +291,8 @@
 	if (asoc->peer.prsctp_capable)
 		chunksize += sizeof(prsctp_param);
 
+	chunksize += sizeof(aiparam);
+
 	/* Now allocate and fill out the chunk.  */
 	retval = sctp_make_chunk(asoc, SCTP_CID_INIT_ACK, 0, chunksize);
 	if (!retval)
@@ -302,6 +311,11 @@
 	if (asoc->peer.prsctp_capable)
 		sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param);
 
+	aiparam.param_hdr.type = SCTP_PARAM_ADAPTION_LAYER_IND;
+	aiparam.param_hdr.length = htons(sizeof(aiparam));
+	aiparam.adaption_ind = htonl(sctp_sk(asoc->base.sk)->adaption_ind);
+	sctp_addto_chunk(retval, sizeof(aiparam), &aiparam);
+
 	/* We need to remove the const qualifier at this point.  */
 	retval->asoc = (struct sctp_association *) asoc;
 
@@ -1297,6 +1311,9 @@
 	/* Remember PR-SCTP capability. */
 	cookie->c.prsctp_capable = asoc->peer.prsctp_capable;
 
+	/* Save adaption indication in the cookie. */
+	cookie->c.adaption_ind = asoc->peer.adaption_ind;
+
 	/* Set an expiration time for the cookie.  */
 	do_gettimeofday(&cookie->c.expiration);
 	TIMEVAL_ADD(asoc->cookie_life, cookie->c.expiration);
@@ -1455,6 +1472,7 @@
 	retval->addip_serial = retval->c.initial_tsn;
 	retval->adv_peer_ack_point = retval->ctsn_ack_point;
 	retval->peer.prsctp_capable = retval->c.prsctp_capable;
+	retval->peer.adaption_ind = retval->c.adaption_ind;
 
 	/* The INIT stuff will be done by the side effects.  */
 	return retval;
@@ -1661,6 +1679,7 @@
 	case SCTP_PARAM_HEARTBEAT_INFO:
 	case SCTP_PARAM_UNRECOGNIZED_PARAMETERS:
 	case SCTP_PARAM_ECN_CAPABLE:
+	case SCTP_PARAM_ADAPTION_LAYER_IND:
 		break;
 
 	case SCTP_PARAM_HOST_NAME_ADDRESS:
@@ -1989,6 +2008,10 @@
 		asoc->peer.ecn_capable = 1;
 		break;
 
+	case SCTP_PARAM_ADAPTION_LAYER_IND:
+		asoc->peer.adaption_ind = param.aind->adaption_ind;
+		break;
+
 	case SCTP_PARAM_FWD_TSN_SUPPORT:
 		if (sctp_prsctp_enable) {
 			asoc->peer.prsctp_capable = 1;
@@ -2459,6 +2482,8 @@
 	union sctp_addr	addr;
 	struct sctp_bind_addr *bp = &asoc->base.bind_addr;
 	union sctp_addr_param *addr_param;
+	struct list_head *pos;
+	struct sctp_transport *transport;
 	int retval = 0;
 
 	addr_param = (union sctp_addr_param *)
@@ -2482,6 +2507,12 @@
 		retval = sctp_del_bind_addr(bp, &addr);
 		sctp_write_unlock(&asoc->base.addr_lock);
 		sctp_local_bh_enable();
+		list_for_each(pos, &asoc->peer.transport_addr_list) {
+			transport = list_entry(pos, struct sctp_transport,
+						 transports);
+			sctp_transport_route(transport, NULL,
+					     sctp_sk(asoc->base.sk));
+		}
 		break;
 	default:
 		break;
diff -Nru a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
--- a/net/sctp/sm_statefuns.c	2004-12-24 13:36:17 -08:00
+++ b/net/sctp/sm_statefuns.c	2004-12-24 13:36:17 -08:00
@@ -629,6 +629,21 @@
 
 	sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
 
+	/* Sockets API Draft Section 5.3.1.6 	
+	 * When a peer sends a Adaption Layer Indication parameter , SCTP
+	 * delivers this notification to inform the application that of the
+	 * peers requested adaption layer.
+	 */
+	if (new_asoc->peer.adaption_ind) {
+		ev = sctp_ulpevent_make_adaption_indication(new_asoc,
+							    GFP_ATOMIC);
+		if (!ev)
+			goto nomem_ev;
+
+		sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
+				SCTP_ULPEVENT(ev));
+	}
+
 	return SCTP_DISPOSITION_CONSUME;
 
 nomem_ev:
@@ -713,6 +728,20 @@
 
 	sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
 
+	/* Sockets API Draft Section 5.3.1.6
+	 * When a peer sends a Adaption Layer Indication parameter , SCTP
+	 * delivers this notification to inform the application that of the
+	 * peers requested adaption layer.
+	 */
+	if (asoc->peer.adaption_ind) {
+		ev = sctp_ulpevent_make_adaption_indication(asoc, GFP_ATOMIC);
+		if (!ev)
+			goto nomem;
+
+		sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
+				SCTP_ULPEVENT(ev));
+	}
+
 	return SCTP_DISPOSITION_CONSUME;
 nomem:
 	return SCTP_DISPOSITION_NOMEM;
@@ -1532,6 +1561,21 @@
 		goto nomem_ev;
 
 	sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
+
+	/* Sockets API Draft Section 5.3.1.6
+	 * When a peer sends a Adaption Layer Indication parameter , SCTP
+	 * delivers this notification to inform the application that of the
+	 * peers requested adaption layer.
+	 */
+	if (asoc->peer.adaption_ind) {
+		ev = sctp_ulpevent_make_adaption_indication(asoc, GFP_ATOMIC);
+		if (!ev)
+			goto nomem_ev;
+
+		sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
+				SCTP_ULPEVENT(ev));
+	}
+
 	return SCTP_DISPOSITION_CONSUME;
 
 nomem_ev:
@@ -1612,6 +1656,21 @@
 			goto nomem;
 		sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
 				SCTP_ULPEVENT(ev));
+
+		/* Sockets API Draft Section 5.3.1.6
+		 * When a peer sends a Adaption Layer Indication parameter,
+		 * SCTP delivers this notification to inform the application
+		 * that of the peers requested adaption layer.
+		 */
+		if (new_asoc->peer.adaption_ind) {
+			ev = sctp_ulpevent_make_adaption_indication(new_asoc,
+								 GFP_ATOMIC);
+			if (!ev)
+				goto nomem;
+
+			sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
+					SCTP_ULPEVENT(ev));
+		}
 	}
 	sctp_add_cmd_sf(commands, SCTP_CMD_TRANSMIT, SCTP_NULL());
 
diff -Nru a/net/sctp/socket.c b/net/sctp/socket.c
--- a/net/sctp/socket.c	2004-12-24 13:37:43 -08:00
+++ b/net/sctp/socket.c	2004-12-24 13:37:43 -08:00
@@ -1063,7 +1063,7 @@
 	struct sctp_sndrcvinfo default_sinfo = { 0 };
 	struct sctp_sndrcvinfo *sinfo;
 	struct sctp_initmsg *sinit;
-	sctp_assoc_t associd = NULL;
+	sctp_assoc_t associd = 0;
 	sctp_cmsgs_t cmsgs = { NULL };
 	int err;
 	sctp_scope_t scope;
@@ -2120,6 +2120,20 @@
 	return err;
 }
 
+static int sctp_setsockopt_adaption_layer(struct sock *sk, char __user *optval,
+					  int optlen)
+{
+	__u32 val;
+
+	if (optlen < sizeof(__u32))
+		return -EINVAL;
+	if (copy_from_user(&val, optval, sizeof(__u32)))
+		return -EFAULT;
+
+	sctp_sk(sk)->adaption_ind = val;
+
+	return 0;
+}
 
 /* API 6.2 setsockopt(), getsockopt()
  *
@@ -2219,6 +2233,10 @@
 	case SCTP_MAXSEG:
 		retval = sctp_setsockopt_maxseg(sk, optval, optlen);
 		break;
+	case SCTP_ADAPTION_LAYER:
+		retval = sctp_setsockopt_adaption_layer(sk, optval, optlen);
+		break;
+
 	default:
 		retval = -ENOPROTOOPT;
 		break;
@@ -2518,6 +2536,8 @@
 	/* User specified fragmentation limit. */
 	sp->user_frag         = 0;
 
+	sp->adaption_ind = 0;
+
 	sp->pf = sctp_get_pf_specific(sk->sk_family);
 
 	/* Control variables for partial data delivery. */
@@ -2649,7 +2669,7 @@
 		goto out;
 	}
 
-	SCTP_DEBUG_PRINTK("sctp_getsockopt_sctp_status(%d): %d %d %p\n",
+	SCTP_DEBUG_PRINTK("sctp_getsockopt_sctp_status(%d): %d %d %d\n",
 			  len, status.sstat_state, status.sstat_rwnd,
 			  status.sstat_assoc_id);
 
@@ -3160,6 +3180,29 @@
 }
 
 /*
+ * 7.1.11  Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER)
+ *
+ * Requests that the local endpoint set the specified Adaption Layer
+ * Indication parameter for all future INIT and INIT-ACK exchanges.
+ */
+static int sctp_getsockopt_adaption_layer(struct sock *sk, int len,
+				  char __user *optval, int __user *optlen)
+{
+	__u32 val;
+
+	if (len < sizeof(__u32))
+		return -EINVAL;
+
+	len = sizeof(__u32);
+	val = sctp_sk(sk)->adaption_ind;
+	if (put_user(len, optlen))
+		return -EFAULT;
+	if (copy_to_user(optval, &val, len))
+		return -EFAULT;
+	return 0;
+}
+
+/*
  *
  * 7.1.14 Set default send parameters (SCTP_DEFAULT_SEND_PARAM)
  *
@@ -3515,6 +3558,10 @@
 		retval = sctp_getsockopt_peer_addr_info(sk, len, optval,
 							optlen);
 		break;
+	case SCTP_ADAPTION_LAYER:
+		retval = sctp_getsockopt_adaption_layer(sk, len, optval,
+							optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
@@ -4051,12 +4098,8 @@
 	for (cmsg = CMSG_FIRSTHDR(msg);
 	     cmsg != NULL;
 	     cmsg = CMSG_NXTHDR((struct msghdr*)msg, cmsg)) {
-		/* Check for minimum length.  The SCM code has this check.  */
-		if (cmsg->cmsg_len < sizeof(struct cmsghdr) ||
-		    (unsigned long)(((char*)cmsg - (char*)msg->msg_control)
-				    + cmsg->cmsg_len) > msg->msg_controllen) {
+		if (!CMSG_OK(msg, cmsg))
 			return -EINVAL;
-		}
 
 		/* Should we parse this header or ignore?  */
 		if (cmsg->cmsg_level != IPPROTO_SCTP)
@@ -4551,7 +4594,7 @@
 	 * delivery.   Three cases:
 	 * 1) No partial deliver;  no work.
 	 * 2) Peeling off partial delivery; keep pd_lobby in new pd_lobby.
-	 * 3) Peeling off non-partial delivery; move pd_lobby to recieve_queue.
+	 * 3) Peeling off non-partial delivery; move pd_lobby to receive_queue.
 	 */
 	skb_queue_head_init(&newsp->pd_lobby);
 	sctp_sk(newsk)->pd_mode = assoc->ulpq.pd_mode;
@@ -4605,6 +4648,7 @@
 /* This proto struct describes the ULP interface for SCTP.  */
 struct proto sctp_prot = {
 	.name        =	"SCTP",
+	.owner       =	THIS_MODULE,
 	.close       =	sctp_close,
 	.connect     =	sctp_connect,
 	.disconnect  =	sctp_disconnect,
@@ -4628,6 +4672,7 @@
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 struct proto sctpv6_prot = {
 	.name		= "SCTPv6",
+	.owner		= THIS_MODULE,
 	.close		= sctp_close,
 	.connect	= sctp_connect,
 	.disconnect	= sctp_disconnect,
diff -Nru a/net/sctp/transport.c b/net/sctp/transport.c
--- a/net/sctp/transport.c	2004-12-24 13:36:30 -08:00
+++ b/net/sctp/transport.c	2004-12-24 13:36:30 -08:00
@@ -421,15 +421,15 @@
 {
 	switch (reason) {
 	case SCTP_LOWER_CWND_T3_RTX:
-		/* RFC 2960 Section 7.2.3, sctpimpguide-05 Section 2.9.2
+		/* RFC 2960 Section 7.2.3, sctpimpguide
 		 * When the T3-rtx timer expires on an address, SCTP should
 		 * perform slow start by:
-		 *      ssthresh = max(cwnd/2, 2*MTU)
+		 *      ssthresh = max(cwnd/2, 4*MTU)
 		 *      cwnd = 1*MTU
 		 *      partial_bytes_acked = 0
 		 */
 		transport->ssthresh = max(transport->cwnd/2,
-					  2*transport->asoc->pmtu);
+					  4*transport->asoc->pmtu);
 		transport->cwnd = transport->asoc->pmtu;
 		break;
 
@@ -439,15 +439,15 @@
 		 * were last sent, according to the formula described in
 		 * Section 7.2.3.
 	 	 *
-	 	 * RFC 2960 7.2.3, sctpimpguide-05 2.9.2 Upon detection of
-		 * packet losses from SACK (see Section 7.2.4), An endpoint
+	 	 * RFC 2960 7.2.3, sctpimpguide Upon detection of packet
+		 * losses from SACK (see Section 7.2.4), An endpoint
 		 * should do the following:
-		 *      ssthresh = max(cwnd/2, 2*MTU)
+		 *      ssthresh = max(cwnd/2, 4*MTU)
 		 *      cwnd = ssthresh
 		 *      partial_bytes_acked = 0
 		 */
 		transport->ssthresh = max(transport->cwnd/2,
-					  2*transport->asoc->pmtu);
+					  4*transport->asoc->pmtu);
 		transport->cwnd = transport->ssthresh;
 		break;
 
@@ -467,23 +467,24 @@
 		if ((jiffies - transport->last_time_ecne_reduced) >
 		    transport->rtt) {
 			transport->ssthresh = max(transport->cwnd/2,
-					  	  2*transport->asoc->pmtu);
+					  	  4*transport->asoc->pmtu);
 			transport->cwnd = transport->ssthresh;
 			transport->last_time_ecne_reduced = jiffies;
 		}
 		break;
 
 	case SCTP_LOWER_CWND_INACTIVE:
-		/* RFC 2960 Section 7.2.1, sctpimpguide-05 Section 2.14.2
-		 * When the association does not transmit data on a given
-		 * transport address within an RTO, the cwnd of the transport
-		 * address should be adjusted to 2*MTU.
+		/* RFC 2960 Section 7.2.1, sctpimpguide
+		 * When the endpoint does not transmit data on a given
+		 * transport address, the cwnd of the transport address
+		 * should be adjusted to max(cwnd/2, 4*MTU) per RTO.
 		 * NOTE: Although the draft recommends that this check needs
 		 * to be done every RTO interval, we do it every hearbeat
 		 * interval.
 		 */
 		if ((jiffies - transport->last_time_used) > transport->rto)
-			transport->cwnd = 2*transport->asoc->pmtu;
+			transport->cwnd = max(transport->cwnd/2,
+						 4*transport->asoc->pmtu);
 		break;
 	};
 
diff -Nru a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
--- a/net/sctp/ulpevent.c	2004-12-24 13:36:19 -08:00
+++ b/net/sctp/ulpevent.c	2004-12-24 13:36:19 -08:00
@@ -562,7 +562,7 @@
 	struct sctp_shutdown_event *sse;
 	struct sk_buff *skb;
 
-	event = sctp_ulpevent_new(sizeof(struct sctp_assoc_change),
+	event = sctp_ulpevent_new(sizeof(struct sctp_shutdown_event),
 				  MSG_NOTIFICATION, gfp);
 	if (!event)
 		goto fail;
@@ -613,6 +613,40 @@
 	return NULL;
 }
 
+/* Create and initialize a SCTP_ADAPTION_INDICATION notification.
+ *
+ * Socket Extensions for SCTP
+ * 5.3.1.6 SCTP_ADAPTION_INDICATION
+ */
+struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
+	const struct sctp_association *asoc, int gfp)
+{
+	struct sctp_ulpevent *event;
+	struct sctp_adaption_event *sai;
+	struct sk_buff *skb;
+
+	event = sctp_ulpevent_new(sizeof(struct sctp_adaption_event),
+				  MSG_NOTIFICATION, gfp);
+	if (!event)
+		goto fail;
+
+	skb = sctp_event2skb(event);
+	sai = (struct sctp_adaption_event *)
+		skb_put(skb, sizeof(struct sctp_adaption_event));
+
+	sai->sai_type = SCTP_ADAPTION_INDICATION;
+	sai->sai_flags = 0;
+	sai->sai_length = sizeof(struct sctp_adaption_event);
+	sai->sai_adaption_ind = asoc->peer.adaption_ind;
+	sctp_ulpevent_set_owner(event, asoc);
+	sai->sai_assoc_id = sctp_assoc2id(asoc);
+
+	return event;
+
+fail:
+	return NULL;
+}
+
 /* A message has been received.  Package this message as a notification
  * to pass it to the upper layers.  Go ahead and calculate the sndrcvinfo
  * even if filtered out later.
@@ -678,8 +712,8 @@
  *
  * 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
  *
- *   When a reciever is engaged in a partial delivery of a
- *   message this notification will be used to inidicate
+ *   When a receiver is engaged in a partial delivery of a
+ *   message this notification will be used to indicate
  *   various events.
  */
 struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
@@ -689,7 +723,7 @@
 	struct sctp_pdapi_event *pd;
 	struct sk_buff *skb;
 
-	event = sctp_ulpevent_new(sizeof(struct sctp_assoc_change),
+	event = sctp_ulpevent_new(sizeof(struct sctp_pdapi_event),
 				  MSG_NOTIFICATION, gfp);
 	if (!event)
 		goto fail;
diff -Nru a/net/socket.c b/net/socket.c
--- a/net/socket.c	2004-12-24 13:36:47 -08:00
+++ b/net/socket.c	2004-12-24 13:36:47 -08:00
@@ -459,7 +459,7 @@
  *	NULL is returned.
  */
 
-struct socket *sock_alloc(void)
+static struct socket *sock_alloc(void)
 {
 	struct inode * inode;
 	struct socket * sock;
@@ -1354,7 +1354,7 @@
 	if (!sock)
 		goto out;
 
-	err = -EMFILE;
+	err = -ENFILE;
 	if (!(newsock = sock_alloc())) 
 		goto out_put;
 
@@ -2089,8 +2089,6 @@
 /* ABI emulation layers need these two */
 EXPORT_SYMBOL(move_addr_to_kernel);
 EXPORT_SYMBOL(move_addr_to_user);
-EXPORT_SYMBOL(sock_alloc);
-EXPORT_SYMBOL(sock_alloc_inode);
 EXPORT_SYMBOL(sock_create);
 EXPORT_SYMBOL(sock_create_kern);
 EXPORT_SYMBOL(sock_create_lite);
diff -Nru a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
--- a/net/sunrpc/rpc_pipe.c	2004-12-24 13:36:33 -08:00
+++ b/net/sunrpc/rpc_pipe.c	2004-12-24 13:36:33 -08:00
@@ -523,16 +523,12 @@
 {
 	struct inode *inode, *dir = parent->d_inode;
 	void *private = RPC_I(dir)->private;
-	struct qstr name;
 	struct dentry *dentry;
 	int mode, i;
 
 	down(&dir->i_sem);
 	for (i = start; i < eof; i++) {
-		name.name = files[i].name;
-		name.len = strlen(name.name);
-		name.hash = full_name_hash(name.name, name.len);
-		dentry = d_alloc(parent, &name);
+		dentry = d_alloc_name(parent, files[i].name);
 		if (!dentry)
 			goto out_bad;
 		mode = files[i].mode;
diff -Nru a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
--- a/net/sunrpc/svcauth_unix.c	2004-12-24 13:37:00 -08:00
+++ b/net/sunrpc/svcauth_unix.c	2004-12-24 13:37:00 -08:00
@@ -150,11 +150,14 @@
 }
 
 static struct ip_map *ip_map_lookup(struct ip_map *, int);
+
 static int ip_map_parse(struct cache_detail *cd,
 			  char *mesg, int mlen)
 {
 	/* class ipaddress [domainname] */
-	char class[50], buf[50];
+	/* should be safe just to use the start of the input buffer
+	 * for scratch: */
+	char *buf = mesg;
 	int len;
 	int b1,b2,b3,b4;
 	char c;
@@ -167,13 +170,11 @@
 	mesg[mlen-1] = 0;
 
 	/* class */
-	len = qword_get(&mesg, class, 50);
+	len = qword_get(&mesg, ipm.m_class, sizeof(ipm.m_class));
 	if (len <= 0) return -EINVAL;
-	if (len >= sizeof(ipm.m_class))
-		return -EINVAL;
 
 	/* ip address */
-	len = qword_get(&mesg, buf, 50);
+	len = qword_get(&mesg, buf, mlen);
 	if (len <= 0) return -EINVAL;
 
 	if (sscanf(buf, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4)
@@ -184,7 +185,7 @@
 		return -EINVAL;
 
 	/* domainname, or empty for NEGATIVE */
-	len = qword_get(&mesg, buf, 50);
+	len = qword_get(&mesg, buf, mlen);
 	if (len < 0) return -EINVAL;
 
 	if (len) {
@@ -194,7 +195,6 @@
 	} else
 		dom = NULL;
 
-	strcpy(ipm.m_class, class);
 	ipm.m_addr.s_addr =
 		htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4);
 	ipm.h.flags = 0;
diff -Nru a/net/unix/af_unix.c b/net/unix/af_unix.c
--- a/net/unix/af_unix.c	2004-12-24 13:37:00 -08:00
+++ b/net/unix/af_unix.c	2004-12-24 13:37:00 -08:00
@@ -187,18 +187,7 @@
 		return -EINVAL;
 	if (!sunaddr || sunaddr->sun_family != AF_UNIX)
 		return -EINVAL;
-	if (sunaddr->sun_path[0])
-	{
-		/*
-		 *	This may look like an off by one error but it is
-		 *	a bit more subtle. 108 is the longest valid AF_UNIX
-		 *	path for a binding. sun_path[108] doesn't as such
-		 *	exist. However in kernel space we are guaranteed that
-		 *	it is a valid memory location in our kernel
-		 *	address buffer.
-		 */
-		if (len > sizeof(*sunaddr))
-			len = sizeof(*sunaddr);
+	if (sunaddr->sun_path[0]) {
 		((char *)sunaddr)[len]=0;
 		len = strlen(sunaddr->sun_path)+1+sizeof(short);
 		return len;
@@ -477,6 +466,8 @@
 			      struct msghdr *, size_t, int);
 static int unix_dgram_connect(struct socket *, struct sockaddr *,
 			      int, int);
+static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *,
+				  struct msghdr *, size_t);
 
 static struct proto_ops unix_stream_ops = {
 	.family =	PF_UNIX,
@@ -535,7 +526,7 @@
 	.shutdown =	unix_shutdown,
 	.setsockopt =	sock_no_setsockopt,
 	.getsockopt =	sock_no_getsockopt,
-	.sendmsg =	unix_dgram_sendmsg,
+	.sendmsg =	unix_seqpacket_sendmsg,
 	.recvmsg =	unix_dgram_recvmsg,
 	.mmap =		sock_no_mmap,
 	.sendpage =	sock_no_sendpage,
@@ -1365,9 +1356,11 @@
 	if (other->sk_shutdown & RCV_SHUTDOWN)
 		goto out_unlock;
 
-	err = security_unix_may_send(sk->sk_socket, other->sk_socket);
-	if (err)
-		goto out_unlock;
+	if (sk->sk_type != SOCK_SEQPACKET) {
+		err = security_unix_may_send(sk->sk_socket, other->sk_socket);
+		if (err)
+			goto out_unlock;
+	}
 
 	if (unix_peer(other) != sk &&
 	    (skb_queue_len(&other->sk_receive_queue) >
@@ -1517,6 +1510,25 @@
 	return sent ? : err;
 }
 
+static int unix_seqpacket_sendmsg(struct kiocb *kiocb, struct socket *sock,
+				  struct msghdr *msg, size_t len)
+{
+	int err;
+	struct sock *sk = sock->sk;
+	
+	err = sock_error(sk);
+	if (err)
+		return err;
+
+	if (sk->sk_state != TCP_ESTABLISHED)
+		return -ENOTCONN;
+
+	if (msg->msg_namelen)
+		msg->msg_namelen = 0;
+
+	return unix_dgram_sendmsg(kiocb, sock, msg, len);
+}
+                                                                                            
 static void unix_copy_addr(struct msghdr *msg, struct sock *sk)
 {
 	struct unix_sock *u = unix_sk(sk);
@@ -1546,9 +1558,11 @@
 
 	msg->msg_namelen = 0;
 
+	down(&u->readsem);
+
 	skb = skb_recv_datagram(sk, flags, noblock, &err);
 	if (!skb)
-		goto out;
+		goto out_unlock;
 
 	wake_up_interruptible(&u->peer_wait);
 
@@ -1598,6 +1612,8 @@
 
 out_free:
 	skb_free_datagram(sk,skb);
+out_unlock:
+	up(&u->readsem);
 out:
 	return err;
 }
diff -Nru a/net/x25/af_x25.c b/net/x25/af_x25.c
--- a/net/x25/af_x25.c	2004-12-24 13:37:29 -08:00
+++ b/net/x25/af_x25.c	2004-12-24 13:37:29 -08:00
@@ -347,6 +347,7 @@
 		/* Defer: outstanding buffers */
 		sk->sk_timer.expires  = jiffies + 10 * HZ;
 		sk->sk_timer.function = x25_destroy_timer;
+		sk->sk_timer.data = (unsigned long)sk;
 		add_timer(&sk->sk_timer);
 	} else {
 		/* drop last reference so sock_put will free */
diff -Nru a/net/x25/x25_dev.c b/net/x25/x25_dev.c
--- a/net/x25/x25_dev.c	2004-12-24 13:36:48 -08:00
+++ b/net/x25/x25_dev.c	2004-12-24 13:36:48 -08:00
@@ -92,7 +92,9 @@
 /*
 	x25_transmit_clear_request(nb, lci, 0x0D);
 */
-	printk(KERN_DEBUG "x25_receive_data(): unknown frame type %2x\n",frametype);
+
+	if (frametype != X25_CLEAR_CONFIRMATION)
+		printk(KERN_DEBUG "x25_receive_data(): unknown frame type %2x\n",frametype);
 
 	return 0;
 }
diff -Nru a/net/x25/x25_proc.c b/net/x25/x25_proc.c
--- a/net/x25/x25_proc.c	2004-12-24 13:36:19 -08:00
+++ b/net/x25/x25_proc.c	2004-12-24 13:36:19 -08:00
@@ -32,10 +32,11 @@
 
 	list_for_each(route_entry, &x25_route_list) {
 		rt = list_entry(route_entry, struct x25_route, node);
-		if (--pos)
-			break;
+		if (!pos--)
+			goto found;
 	}
-
+	rt = NULL;
+found:
 	return rt;
 }
 
diff -Nru a/net/xfrm/Kconfig b/net/xfrm/Kconfig
--- a/net/xfrm/Kconfig	2004-12-24 13:36:49 -08:00
+++ b/net/xfrm/Kconfig	2004-12-24 13:36:49 -08:00
@@ -1,10 +1,6 @@
 #
 # XFRM configuration
 #
-config XFRM
-       bool
-       depends on NET
-
 config XFRM_USER
 	tristate "IPsec user configuration interface"
 	depends on INET && XFRM
diff -Nru a/net/xfrm/xfrm_export.c b/net/xfrm/xfrm_export.c
--- a/net/xfrm/xfrm_export.c	2004-12-24 13:36:55 -08:00
+++ b/net/xfrm/xfrm_export.c	2004-12-24 13:36:55 -08:00
@@ -12,27 +12,21 @@
 EXPORT_SYMBOL(__xfrm_route_forward);
 EXPORT_SYMBOL(xfrm_state_alloc);
 EXPORT_SYMBOL(__xfrm_state_destroy);
-EXPORT_SYMBOL(xfrm_state_find);
 EXPORT_SYMBOL(xfrm_state_insert);
 EXPORT_SYMBOL(xfrm_state_add);
 EXPORT_SYMBOL(xfrm_state_update);
 EXPORT_SYMBOL(xfrm_state_check_expire);
-EXPORT_SYMBOL(xfrm_state_check_space);
 EXPORT_SYMBOL(xfrm_state_check);
 EXPORT_SYMBOL(xfrm_state_lookup);
 EXPORT_SYMBOL(xfrm_state_register_afinfo);
 EXPORT_SYMBOL(xfrm_state_unregister_afinfo);
-EXPORT_SYMBOL(xfrm_state_get_afinfo);
-EXPORT_SYMBOL(xfrm_state_put_afinfo);
 EXPORT_SYMBOL(xfrm_state_delete_tunnel);
 EXPORT_SYMBOL(xfrm_replay_check);
 EXPORT_SYMBOL(xfrm_replay_advance);
-EXPORT_SYMBOL(xfrm_check_selectors);
 EXPORT_SYMBOL(__secpath_destroy);
 EXPORT_SYMBOL(secpath_dup);
 EXPORT_SYMBOL(xfrm_get_acqseq);
 EXPORT_SYMBOL(xfrm_parse_spi);
-EXPORT_SYMBOL(xfrm4_rcv);
 EXPORT_SYMBOL(xfrm_register_type);
 EXPORT_SYMBOL(xfrm_unregister_type);
 EXPORT_SYMBOL(xfrm_get_type);
@@ -44,7 +38,6 @@
 EXPORT_SYMBOL(xfrm_find_acq);
 EXPORT_SYMBOL(xfrm_alloc_spi);
 EXPORT_SYMBOL(xfrm_state_flush);
-EXPORT_SYMBOL(xfrm_policy_kill);
 EXPORT_SYMBOL(xfrm_policy_bysel);
 EXPORT_SYMBOL(xfrm_policy_insert);
 EXPORT_SYMBOL(xfrm_policy_walk);
@@ -54,8 +47,6 @@
 EXPORT_SYMBOL(xfrm_dst_lookup);
 EXPORT_SYMBOL(xfrm_policy_register_afinfo);
 EXPORT_SYMBOL(xfrm_policy_unregister_afinfo);
-EXPORT_SYMBOL(xfrm_policy_get_afinfo);
-EXPORT_SYMBOL(xfrm_policy_put_afinfo);
 
 EXPORT_SYMBOL_GPL(xfrm_probe_algs);
 EXPORT_SYMBOL_GPL(xfrm_count_auth_supported);
diff -Nru a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
--- a/net/xfrm/xfrm_policy.c	2004-12-24 13:36:54 -08:00
+++ b/net/xfrm/xfrm_policy.c	2004-12-24 13:36:54 -08:00
@@ -40,6 +40,9 @@
 	LIST_HEAD_INIT(xfrm_policy_gc_list);
 static spinlock_t xfrm_policy_gc_lock = SPIN_LOCK_UNLOCKED;
 
+static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family);
+static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo);
+
 int xfrm_register_type(struct xfrm_type *type, unsigned short family)
 {
 	struct xfrm_policy_afinfo *afinfo = xfrm_policy_get_afinfo(family);
@@ -224,7 +227,7 @@
 	if (policy) {
 		memset(policy, 0, sizeof(struct xfrm_policy));
 		atomic_set(&policy->refcnt, 1);
-		policy->lock = RW_LOCK_UNLOCKED;
+		rwlock_init(&policy->lock);
 		init_timer(&policy->timer);
 		policy->timer.data = (unsigned long)policy;
 		policy->timer.function = xfrm_policy_timer;
@@ -286,7 +289,7 @@
  * entry dead. The rule must be unlinked from lists to the moment.
  */
 
-void xfrm_policy_kill(struct xfrm_policy *policy)
+static void xfrm_policy_kill(struct xfrm_policy *policy)
 {
 	write_lock_bh(&policy->lock);
 	if (policy->dead)
@@ -332,7 +335,7 @@
 	struct xfrm_policy **newpos = NULL;
 
 	write_lock_bh(&xfrm_policy_lock);
-	for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL; p = &pol->next) {
+	for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL;) {
 		if (!delpol && memcmp(&policy->selector, &pol->selector, sizeof(pol->selector)) == 0) {
 			if (excl) {
 				write_unlock_bh(&xfrm_policy_lock);
@@ -342,12 +345,15 @@
 			delpol = pol;
 			if (policy->priority > pol->priority)
 				continue;
-		} else if (policy->priority >= pol->priority)
+		} else if (policy->priority >= pol->priority) {
+			p = &pol->next;
 			continue;
+		}
 		if (!newpos)
 			newpos = p;
 		if (delpol)
 			break;
+		p = &pol->next;
 	}
 	if (newpos)
 		p = newpos;
@@ -893,6 +899,16 @@
 	return 0;
 }
 
+static inline int secpath_has_tunnel(struct sec_path *sp, int k)
+{
+	for (; k < sp->len; k++) {
+		if (sp->x[k].xvec->props.mode)
+			return 1;
+	}
+
+	return 0;
+}
+
 int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, 
 			unsigned short family)
 {
@@ -930,7 +946,7 @@
 					xfrm_policy_lookup);
 
 	if (!pol)
-		return !skb->sp;
+		return !skb->sp || !secpath_has_tunnel(skb->sp, 0);
 
 	pol->curlft.use_time = (unsigned long)xtime.tv_sec;
 
@@ -954,10 +970,8 @@
 				goto reject;
 		}
 
-		for (; k < sp->len; k++) {
-			if (sp->x[k].xvec->props.mode)
-				goto reject;
-		}
+		if (secpath_has_tunnel(sp, k))
+			goto reject;
 
 		xfrm_pol_put(pol);
 		return 1;
@@ -1177,7 +1191,7 @@
 	return err;
 }
 
-struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family)
+static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family)
 {
 	struct xfrm_policy_afinfo *afinfo;
 	if (unlikely(family >= NPROTO))
@@ -1190,7 +1204,7 @@
 	return afinfo;
 }
 
-void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo)
+static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo)
 {
 	if (unlikely(afinfo == NULL))
 		return;
diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
--- a/net/xfrm/xfrm_state.c	2004-12-24 13:37:03 -08:00
+++ b/net/xfrm/xfrm_state.c	2004-12-24 13:37:03 -08:00
@@ -48,6 +48,9 @@
 
 static void __xfrm_state_delete(struct xfrm_state *x);
 
+static struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family);
+static void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo);
+
 static void xfrm_state_gc_destroy(struct xfrm_state *x)
 {
 	if (del_timer(&x->timer))
@@ -183,7 +186,7 @@
 		x->lft.soft_packet_limit = XFRM_INF;
 		x->lft.hard_byte_limit = XFRM_INF;
 		x->lft.hard_packet_limit = XFRM_INF;
-		x->lock = SPIN_LOCK_UNLOCKED;
+		spin_lock_init(&x->lock);
 	}
 	return x;
 }
@@ -526,7 +529,7 @@
 	return 0;
 }
 
-int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb)
+static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int nhead = x->props.header_len + LL_RESERVED_SPACE(skb->dst->dev)
 		- skb_headroom(skb);
@@ -740,19 +743,6 @@
 	}
 }
 
-int xfrm_check_selectors(struct xfrm_state **x, int n, struct flowi *fl)
-{
-	int i;
-
-	for (i=0; i<n; i++) {
-		int match;
-		match = xfrm_selector_match(&x[i]->sel, fl, x[i]->props.family);
-		if (!match)
-			return -EINVAL;
-	}
-	return 0;
-}
-
 static struct list_head xfrm_km_list = LIST_HEAD_INIT(xfrm_km_list);
 static rwlock_t		xfrm_km_lock = RW_LOCK_UNLOCKED;
 
@@ -914,7 +904,7 @@
 	return err;
 }
 
-struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family)
+static struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family)
 {
 	struct xfrm_state_afinfo *afinfo;
 	if (unlikely(family >= NPROTO))
@@ -927,7 +917,7 @@
 	return afinfo;
 }
 
-void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo)
+static void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo)
 {
 	if (unlikely(afinfo == NULL))
 		return;
diff -Nru a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
--- a/net/xfrm/xfrm_user.c	2004-12-24 13:36:59 -08:00
+++ b/net/xfrm/xfrm_user.c	2004-12-24 13:36:59 -08:00
@@ -332,6 +332,7 @@
 	struct sk_buff *in_skb;
 	struct sk_buff *out_skb;
 	u32 nlmsg_seq;
+	u16 nlmsg_flags;
 	int start_idx;
 	int this_idx;
 };
@@ -351,7 +352,7 @@
 	nlh = NLMSG_PUT(skb, NETLINK_CB(in_skb).pid,
 			sp->nlmsg_seq,
 			XFRM_MSG_NEWSA, sizeof(*p));
-	nlh->nlmsg_flags = 0;
+	nlh->nlmsg_flags = sp->nlmsg_flags;
 
 	p = NLMSG_DATA(nlh);
 	copy_to_user_state(x, p);
@@ -386,6 +387,7 @@
 	info.in_skb = cb->skb;
 	info.out_skb = skb;
 	info.nlmsg_seq = cb->nlh->nlmsg_seq;
+	info.nlmsg_flags = NLM_F_MULTI;
 	info.this_idx = 0;
 	info.start_idx = cb->args[0];
 	(void) xfrm_state_walk(IPSEC_PROTO_ANY, dump_one_state, &info);
@@ -408,6 +410,7 @@
 	info.in_skb = in_skb;
 	info.out_skb = skb;
 	info.nlmsg_seq = seq;
+	info.nlmsg_flags = 0;
 	info.this_idx = info.start_idx = 0;
 
 	if (dump_one_state(x, 0, &info)) {
@@ -743,7 +746,7 @@
 			sp->nlmsg_seq,
 			XFRM_MSG_NEWPOLICY, sizeof(*p));
 	p = NLMSG_DATA(nlh);
-	nlh->nlmsg_flags = 0;
+	nlh->nlmsg_flags = sp->nlmsg_flags;
 
 	copy_to_user_policy(xp, p, dir);
 	if (copy_to_user_tmpl(xp, skb) < 0)
@@ -766,6 +769,7 @@
 	info.in_skb = cb->skb;
 	info.out_skb = skb;
 	info.nlmsg_seq = cb->nlh->nlmsg_seq;
+	info.nlmsg_flags = NLM_F_MULTI;
 	info.this_idx = 0;
 	info.start_idx = cb->args[0];
 	(void) xfrm_policy_walk(dump_one_policy, &info);
@@ -789,6 +793,7 @@
 	info.in_skb = in_skb;
 	info.out_skb = skb;
 	info.nlmsg_seq = seq;
+	info.nlmsg_flags = 0;
 	info.this_idx = info.start_idx = 0;
 
 	if (dump_one_policy(xp, dir, 0, &info) < 0) {
@@ -1232,8 +1237,7 @@
 
 	xfrm_nl = netlink_kernel_create(NETLINK_XFRM, xfrm_netlink_rcv);
 	if (xfrm_nl == NULL)
-		panic("xfrm_user_init: cannot initialize xfrm_nl\n");
-
+		return -ENOMEM;
 
 	xfrm_register_km(&netlink_mgr);
 
diff -Nru a/scripts/Makefile.build b/scripts/Makefile.build
--- a/scripts/Makefile.build	2004-12-24 13:37:18 -08:00
+++ b/scripts/Makefile.build	2004-12-24 13:37:18 -08:00
@@ -10,7 +10,7 @@
 # Read .config if it exist, otherwise ignore
 -include .config
 
-include $(obj)/Makefile
+include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
 
 include scripts/Makefile.lib
 
@@ -83,6 +83,7 @@
 
 # Linus' kernel sanity checking tool
 ifneq ($(KBUILD_CHECKSRC),0)
+  CHECKFLAGS += -I$(shell $(CC) -print-file-name=include)
   ifeq ($(KBUILD_CHECKSRC),2)
     quiet_cmd_force_checksrc = CHECK   $<
           cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
diff -Nru a/scripts/Makefile.clean b/scripts/Makefile.clean
--- a/scripts/Makefile.clean	2004-12-24 13:36:16 -08:00
+++ b/scripts/Makefile.clean	2004-12-24 13:36:16 -08:00
@@ -7,7 +7,7 @@
 .PHONY: __clean
 __clean:
 
-include $(obj)/Makefile
+include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
 
 # Figure out what we need to build from the various variables
 # ==========================================================================
diff -Nru a/scripts/Makefile.lib b/scripts/Makefile.lib
--- a/scripts/Makefile.lib	2004-12-24 13:36:49 -08:00
+++ b/scripts/Makefile.lib	2004-12-24 13:36:49 -08:00
@@ -232,3 +232,30 @@
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+
+# filechk is used to check if the content of a generated file is updated.
+# Sample usage:
+# define filechk_sample
+#	echo $KERNELRELEASE
+# endef
+# version.h : Makefile
+#	$(call filechk,sample)
+# The rule defined shall write to stdout the content of the new file.
+# The existing file will be compared with the new one.
+# - If no file exist it is created
+# - If the content differ the new file is used
+# - If they are equal no change, and no timestamp update
+
+define filechk
+	$(Q)set -e;				\
+	echo '  CHK     $@';			\
+	mkdir -p $(dir $@);			\
+	$(filechk_$(1)) $(2) > $@.tmp;		\
+	if [ -r $@ ] && cmp -s $@ $@.tmp; then	\
+		rm -f $@.tmp;			\
+	else					\
+		echo '  UPD     $@';		\
+		mv -f $@.tmp $@;		\
+	fi
+endef
+
diff -Nru a/scripts/Makefile.modinst b/scripts/Makefile.modinst
--- a/scripts/Makefile.modinst	2004-12-24 13:36:56 -08:00
+++ b/scripts/Makefile.modinst	2004-12-24 13:36:56 -08:00
@@ -19,7 +19,10 @@
 quiet_cmd_modules_install = INSTALL $@
       cmd_modules_install = mkdir -p $(2); cp $@ $(2)
 
-modinst_dir = $(MODLIB)/$(if $(filter ../% /%,$@),extra/,kernel/$(@D))
+# Modules built outside the kernel source tree go into extra by default
+INSTALL_MOD_DIR ?= extra
+
+modinst_dir = $(MODLIB)/$(if $(filter ../% /%,$@),$(INSTALL_MOD_DIR)/,kernel/$(@D))
 
 $(modules):
 	$(call cmd,modules_install,$(modinst_dir))
diff -Nru a/scripts/Makefile.modpost b/scripts/Makefile.modpost
--- a/scripts/Makefile.modpost	2004-12-24 13:36:56 -08:00
+++ b/scripts/Makefile.modpost	2004-12-24 13:36:56 -08:00
@@ -52,6 +52,7 @@
 quiet_cmd_modpost = MODPOST
       cmd_modpost = scripts/mod/modpost            \
         $(if $(CONFIG_MODVERSIONS),-m)             \
+	$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,)  \
 	$(if $(KBUILD_EXTMOD),-i,-o) $(symverfile) \
 	$(filter-out FORCE,$^)
 
diff -Nru a/scripts/basic/docproc.c b/scripts/basic/docproc.c
--- a/scripts/basic/docproc.c	2004-12-24 13:36:18 -08:00
+++ b/scripts/basic/docproc.c	2004-12-24 13:36:18 -08:00
@@ -52,7 +52,7 @@
 FILEONLY *externalfunctions;
 FILEONLY *symbolsonly;
 
-typedef void FILELINE(char * file, char * line);
+typedef void FILELINE(char * file, signed char * line);
 FILELINE * singlefunctions;
 FILELINE * entity_system;
 
@@ -79,6 +79,7 @@
 {
 	pid_t pid;
 	int ret;
+	char real_filename[PATH_MAX + 1];
 	/* Make sure output generated so far are flushed */
 	fflush(stdout);
 	switch(pid=fork()) {
@@ -86,8 +87,13 @@
 			perror("fork");
 			exit(1);
 		case  0:
-			execvp(KERNELDOCPATH KERNELDOC, svec);
-			perror("exec " KERNELDOCPATH KERNELDOC);
+			memset(real_filename, 0, sizeof(real_filename));
+			strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
+			strncat(real_filename, KERNELDOCPATH KERNELDOC,
+					PATH_MAX - strlen(real_filename));
+			execvp(real_filename, svec);
+			fprintf(stderr, "exec ");
+			perror(real_filename);
 			exit(1);
 		default:
 			waitpid(pid, &ret ,0);
@@ -142,9 +148,9 @@
  * Files are separated by tabs.
  */
 void adddep(char * file)		   { printf("\t%s", file); }
-void adddep2(char * file, char * line)     { line = line; adddep(file); }
+void adddep2(char * file, signed char * line)     { line = line; adddep(file); }
 void noaction(char * line)		   { line = line; }
-void noaction2(char * file, char * line)   { file = file; line = line; }
+void noaction2(char * file, signed char * line)   { file = file; line = line; }
 
 /* Echo the line without further action */
 void printline(char * line)               { printf("%s", line); }
@@ -160,16 +166,21 @@
 	struct symfile *sym;
 	char line[MAXLINESZ];
 	if (filename_exist(filename) == NULL) {
+		char real_filename[PATH_MAX + 1];
+		memset(real_filename, 0, sizeof(real_filename));
+		strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
+		strncat(real_filename, filename,
+				PATH_MAX - strlen(real_filename));
 		sym = add_new_file(filename);
-		fp = fopen(filename, "r");
+		fp = fopen(real_filename, "r");
 		if (fp == NULL)
 		{
 			fprintf(stderr, "docproc: ");
-			perror(filename);
+			perror(real_filename);
 		}
 		while(fgets(line, MAXLINESZ, fp)) {
-			char *p;
-			char *e;
+			signed char *p;
+			signed char *e;
 			if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != 0) ||
                             ((p = strstr(line, "EXPORT_SYMBOL")) != 0)) {
 				/* Skip EXPORT_SYMBOL{_GPL} */
@@ -242,7 +253,7 @@
  * Call kernel-doc with the following parameters:
  * kernel-doc -docbook -function function1 [-function function2]
  */
-void singfunc(char * filename, char * line)
+void singfunc(char * filename, signed char * line)
 {
 	char *vec[200]; /* Enough for specific functions */
         int i, idx = 0;
@@ -279,7 +290,7 @@
 void parse_file(FILE *infile)
 {
 	char line[MAXLINESZ];
-	char * s;
+	signed char * s;
 	while(fgets(line, MAXLINESZ, infile)) {
 		if (line[0] == '!') {
 			s = line + 2;
diff -Nru a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
--- a/scripts/basic/fixdep.c	2004-12-24 13:36:49 -08:00
+++ b/scripts/basic/fixdep.c	2004-12-24 13:36:49 -08:00
@@ -217,18 +217,18 @@
 	printf("    $(wildcard include/config/%s.h) \\\n", s);
 }
 
-void parse_config_file(char *map, size_t len)
+void parse_config_file(signed char *map, size_t len)
 {
 	int *end = (int *) (map + len);
 	/* start at +1, so that p can never be < map */
 	int *m   = (int *) map + 1;
-	char *p, *q;
+	signed char *p, *q;
 
 	for (; m < end; m++) {
-		if (*m == INT_CONF) { p = (char *) m  ; goto conf; }
-		if (*m == INT_ONFI) { p = (char *) m-1; goto conf; }
-		if (*m == INT_NFIG) { p = (char *) m-2; goto conf; }
-		if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }
+		if (*m == INT_CONF) { p = (signed char *) m  ; goto conf; }
+		if (*m == INT_ONFI) { p = (signed char *) m-1; goto conf; }
+		if (*m == INT_NFIG) { p = (signed char *) m-2; goto conf; }
+		if (*m == INT_FIG_) { p = (signed char *) m-3; goto conf; }
 		continue;
 	conf:
 		if (p > map + len - 7)
@@ -291,9 +291,9 @@
 
 void parse_dep_file(void *map, size_t len)
 {
-	char *m = map;
-	char *end = m + len;
-	char *p;
+	signed char *m = map;
+	signed char *end = m + len;
+	signed char *p;
 	char s[PATH_MAX];
 
 	p = strchr(m, ':');
diff -Nru a/scripts/basic/split-include.c b/scripts/basic/split-include.c
--- a/scripts/basic/split-include.c	2004-12-24 13:36:47 -08:00
+++ b/scripts/basic/split-include.c	2004-12-24 13:36:47 -08:00
@@ -104,7 +104,7 @@
     /* Read config lines. */
     while (fgets(line, buffer_size, fp_config))
     {
-	const char * str_config;
+	const signed char * str_config;
 	int is_same;
 	int itarget;
 
diff -Nru a/scripts/checkstack.pl b/scripts/checkstack.pl
--- a/scripts/checkstack.pl	2004-12-24 13:36:31 -08:00
+++ b/scripts/checkstack.pl	2004-12-24 13:36:31 -08:00
@@ -39,6 +39,9 @@
 	} elsif ($arch =~ /^i[3456]86$/) {
 		#c0105234:       81 ec ac 05 00 00       sub    $0x5ac,%esp
 		$re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%esp$/o;
+	} elsif ($arch eq 'x86_64') {
+		#    2f60:	48 81 ec e8 05 00 00 	sub    $0x5e8,%rsp
+		$re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%rsp$/o;
 	} elsif ($arch eq 'ia64') {
 		#e0000000044011fc:       01 0f fc 8c     adds r12=-384,r12
 		$re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
diff -Nru a/scripts/conmakehash.c b/scripts/conmakehash.c
--- a/scripts/conmakehash.c	2004-12-24 13:36:16 -08:00
+++ b/scripts/conmakehash.c	2004-12-24 13:36:16 -08:00
@@ -33,7 +33,7 @@
 
 int getunicode(char **p0)
 {
-  char *p = *p0;
+  unsigned char *p = *p0;
 
   while (*p == ' ' || *p == '\t')
     p++;
diff -Nru a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/scripts/gen_initramfs_list.sh	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,118 @@
+#!/bin/bash
+# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
+# Released under the terms of the GNU GPL
+#
+# Generate a newline separated list of entries from the file/directory pointed
+# out by the environment variable: CONFIG_INITRAMFS_SOURCE
+#
+# If CONFIG_INITRAMFS_SOURCE is non-existing then generate a small dummy file.
+#
+# The output is suitable for gen_init_cpio as found in usr/Makefile.
+#
+# TODO:  Add support for symlinks, sockets and pipes when gen_init_cpio
+#        supports them.
+
+simple_initramfs() {
+	cat <<-EOF
+		# This is a very simple initramfs
+
+		dir /dev 0755 0 0
+		nod /dev/console 0600 0 0 c 5 1
+		dir /root 0700 0 0
+	EOF
+}
+
+filetype() {
+	local argv1="$1"
+
+	if [ -f "${argv1}" ]; then
+		echo "file"
+	elif [ -d "${argv1}" ]; then
+		echo "dir"
+	elif [ -b "${argv1}" -o -c "${argv1}" ]; then
+		echo "nod"
+	else
+		echo "invalid"
+	fi
+	return 0
+}
+
+print_mtime() {
+	local argv1="$1"
+	local my_mtime="0"
+
+	if [ -e "${argv1}" ]; then
+		my_mtime=$(find "${argv1}" -printf "%T@\n" | sort -r | head -n 1)
+	fi
+	
+	echo "# Last modified: ${my_mtime}"
+	echo
+}
+
+parse() {
+	local location="$1"
+	local name="${location/${srcdir}//}"
+	local mode="$2"
+	local uid="$3"
+	local gid="$4"
+	local ftype=$(filetype "${location}")
+	local str="${mode} ${uid} ${gid}"
+
+	[ "${ftype}" == "invalid" ] && return 0
+	[ "${location}" == "${srcdir}" ] && return 0
+
+	case "${ftype}" in
+		"file")
+			str="${ftype} ${name} ${location} ${str}"
+			;;
+		"nod")
+			local dev_type=
+			local maj=$(LC_ALL=C ls -l "${location}" | \
+					gawk '{sub(/,/, "", $5); print $5}')
+			local min=$(LC_ALL=C ls -l "${location}" | \
+					gawk '{print $6}')
+
+			if [ -b "${location}" ]; then
+				dev_type="b"
+			else
+				dev_type="c"
+			fi
+			str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}"
+			;;
+		*)
+			str="${ftype} ${name} ${str}"
+			;;
+	esac
+
+	echo "${str}"
+
+	return 0
+}
+
+if [ -z "$1" ]; then
+	simple_initramfs
+elif [ -f "$1" ]; then
+	print_mtime "$1"
+	cat "$1"
+elif [ -d "$1" ]; then
+	srcdir=$(echo "$1" | sed -e 's://*:/:g')
+	dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
+
+	# If $dirlist is only one line, then the directory is empty
+	if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+		print_mtime "$1"
+		
+		echo "${dirlist}" | \
+		while read x; do
+			parse ${x}
+		done
+	else
+		# Failsafe in case directory is empty
+		simple_initramfs
+	fi
+else
+	echo "  $0: Cannot open '$1' (CONFIG_INITRAMFS_SOURCE)" >&2
+	exit 1
+fi
+
+exit 0
diff -Nru a/scripts/kallsyms.c b/scripts/kallsyms.c
--- a/scripts/kallsyms.c	2004-12-24 13:37:30 -08:00
+++ b/scripts/kallsyms.c	2004-12-24 13:37:30 -08:00
@@ -6,6 +6,22 @@
  * of the GNU General Public License, incorporated herein by reference.
  *
  * Usage: nm -n vmlinux | scripts/kallsyms [--all-symbols] > symbols.S
+ *
+ * ChangeLog:
+ *
+ * (25/Aug/2004) Paulo Marques <pmarques@grupopie.com>
+ *      Changed the compression method from stem compression to "table lookup"
+ *      compression
+ *
+ *      Table compression uses all the unused char codes on the symbols and
+ *  maps these to the most used substrings (tokens). For instance, it might
+ *  map char code 0xF7 to represent "write_" and then in every symbol where
+ *  "write_" appears it can be replaced by 0xF7, saving 5 bytes.
+ *      The used codes themselves are also placed in the table so that the
+ *  decompresion can work without "special cases".
+ *      Applied to kernel symbols, this usually produces a compression ratio
+ *  of about 50%.
+ *
  */
 
 #include <stdio.h>
@@ -13,10 +29,39 @@
 #include <string.h>
 #include <ctype.h>
 
+/* maximum token length used. It doesn't pay to increase it a lot, because
+ * very long substrings probably don't repeat themselves too often. */
+#define MAX_TOK_SIZE		11
+#define KSYM_NAME_LEN		127
+
+/* we use only a subset of the complete symbol table to gather the token count,
+ * to speed up compression, at the expense of a little compression ratio */
+#define WORKING_SET		1024
+
+/* first find the best token only on the list of tokens that would profit more
+ * than GOOD_BAD_THRESHOLD. Only if this list is empty go to the "bad" list.
+ * Increasing this value will put less tokens on the "good" list, so the search
+ * is faster. However, if the good list runs out of tokens, we must painfully
+ * search the bad list. */
+#define GOOD_BAD_THRESHOLD	10
+
+/* token hash parameters */
+#define HASH_BITS		18
+#define HASH_TABLE_SIZE		(1 << HASH_BITS)
+#define HASH_MASK		(HASH_TABLE_SIZE - 1)
+#define HASH_BASE_OFFSET	2166136261U
+#define HASH_FOLD(a)		((a)&(HASH_MASK))
+
+/* flags to mark symbols */
+#define SYM_FLAG_VALID		1
+#define SYM_FLAG_SAMPLED	2
+
 struct sym_entry {
 	unsigned long long addr;
 	char type;
-	char *sym;
+	unsigned char flags;
+	unsigned char len;
+	unsigned char *sym;
 };
 
 
@@ -25,6 +70,26 @@
 static unsigned long long _stext, _etext, _sinittext, _einittext;
 static int all_symbols = 0;
 
+struct token {
+	unsigned char data[MAX_TOK_SIZE];
+	unsigned char len;
+	/* profit: the number of bytes that could be saved by inserting this
+	 * token into the table */
+	int profit;
+	struct token *next;	/* next token on the hash list */
+	struct token *right;	/* next token on the good/bad list */
+	struct token *left;    /* previous token on the good/bad list */
+	struct token *smaller; /* token that is less one letter than this one */
+	};
+
+struct token bad_head, good_head;
+struct token *hash_table[HASH_TABLE_SIZE];
+
+/* the table that holds the result of the compression */
+unsigned char best_table[256][MAX_TOK_SIZE+1];
+unsigned char best_table_len[256];
+
+
 static void
 usage(void)
 {
@@ -32,6 +97,17 @@
 	exit(1);
 }
 
+/*
+ * This ignores the intensely annoying "mapping symbols" found
+ * in ARM ELF files: $a, $t and $d.
+ */
+static inline int
+is_arm_mapping_symbol(const char *str)
+{
+	return str[0] == '$' && strchr("atd", str[1])
+	       && (str[2] == '\0' || str[2] == '.');
+}
+
 static int
 read_symbol(FILE *in, struct sym_entry *s)
 {
@@ -56,37 +132,67 @@
 		_sinittext = s->addr;
 	else if (strcmp(str, "_einittext") == 0)
 		_einittext = s->addr;
-	else if (toupper(s->type) == 'A' || toupper(s->type) == 'U')
+	else if (toupper(s->type) == 'A')
+	{
+		/* Keep these useful absolute symbols */
+		if (strcmp(str, "__kernel_syscall_via_break") &&
+		    strcmp(str, "__kernel_syscall_via_epc") &&
+		    strcmp(str, "__kernel_sigtramp") &&
+		    strcmp(str, "__gp"))
+			return -1;
+
+	}
+	else if (toupper(s->type) == 'U' ||
+		 is_arm_mapping_symbol(str))
 		return -1;
 
-	s->sym = strdup(str);
+	/* include the type field in the symbol name, so that it gets
+	 * compressed together */
+	s->len = strlen(str) + 1;
+	s->sym = (char *) malloc(s->len + 1);
+	strcpy(s->sym + 1, str);
+	s->sym[0] = s->type;
+
 	return 0;
 }
 
 static int
 symbol_valid(struct sym_entry *s)
 {
+	/* Symbols which vary between passes.  Passes 1 and 2 must have
+	 * identical symbol lists.  The kallsyms_* symbols below are only added
+	 * after pass 1, they would be included in pass 2 when --all-symbols is
+	 * specified so exclude them to get a stable symbol list.
+	 */
+	static char *special_symbols[] = {
+		"kallsyms_addresses",
+		"kallsyms_num_syms",
+		"kallsyms_names",
+		"kallsyms_markers",
+		"kallsyms_token_table",
+		"kallsyms_token_index",
+
+	/* Exclude linker generated symbols which vary between passes */
+		"_SDA_BASE_",		/* ppc */
+		"_SDA2_BASE_",		/* ppc */
+		NULL };
+	int i;
+
+	/* if --all-symbols is not specified, then symbols outside the text
+	 * and inittext sections are discarded */
 	if (!all_symbols) {
 		if ((s->addr < _stext || s->addr > _etext)
 		    && (s->addr < _sinittext || s->addr > _einittext))
 			return 0;
 	}
 
-	/* Exclude symbols which vary between passes.  Passes 1 and 2 must have
-	 * identical symbol lists.  The kallsyms_* symbols below are only added
-	 * after pass 1, they would be included in pass 2 when --all-symbols is
-	 * specified so exclude them to get a stable symbol list.
-	 */
-	if (strstr(s->sym, "_compiled.") ||
-	    strcmp(s->sym, "kallsyms_addresses") == 0 ||
-	    strcmp(s->sym, "kallsyms_num_syms") == 0 ||
-	    strcmp(s->sym, "kallsyms_names") == 0)
+	/* Exclude symbols which vary between passes. */
+	if (strstr(s->sym + 1, "_compiled."))
 		return 0;
 
-	/* Exclude linker generated symbols which vary between passes */
-	if (strcmp(s->sym, "_SDA_BASE_") == 0 ||	/* ppc */
-	    strcmp(s->sym, "_SDA2_BASE_") == 0)		/* ppc */
-		return 0;
+	for (i = 0; special_symbols[i]; i++)
+		if( strcmp(s->sym + 1, special_symbols[i]) == 0 )
+			return 0;
 
 	return 1;
 }
@@ -108,11 +214,47 @@
 	}
 }
 
+static void output_label(char *label)
+{
+	printf(".globl %s\n",label);
+	printf("\tALGN\n");
+	printf("%s:\n",label);
+}
+
+/* uncompress a compressed symbol. When this function is called, the best table
+ * might still be compressed itself, so the function needs to be recursive */
+static int expand_symbol(unsigned char *data, int len, char *result)
+{
+	int c, rlen, total=0;
+
+	while (len) {
+		c = *data;
+		/* if the table holds a single char that is the same as the one
+		 * we are looking for, then end the search */
+		if (best_table[c][0]==c && best_table_len[c]==1) {
+			*result++ = c;
+			total++;
+		} else {
+			/* if not, recurse and expand */
+			rlen = expand_symbol(best_table[c], best_table_len[c], result);
+			total += rlen;
+			result += rlen;
+		}
+		data++;
+		len--;
+	}
+	*result=0;
+
+	return total;
+}
+
 static void
 write_src(void)
 {
-	int i, valid = 0;
-	char *prev;
+	int i, k, off, valid;
+	unsigned int best_idx[256];
+	unsigned int *markers;
+	char buf[KSYM_NAME_LEN+1];
 
 	printf("#include <asm/types.h>\n");
 	printf("#if BITS_PER_LONG == 64\n");
@@ -125,43 +267,399 @@
 
 	printf(".data\n");
 
-	printf(".globl kallsyms_addresses\n");
-	printf("\tALGN\n");
-	printf("kallsyms_addresses:\n");
+	output_label("kallsyms_addresses");
+	valid = 0;
 	for (i = 0; i < cnt; i++) {
-		if (!symbol_valid(&table[i]))
-			continue;
-
-		printf("\tPTR\t%#llx\n", table[i].addr);
-		valid++;
+		if (table[i].flags & SYM_FLAG_VALID) {
+			printf("\tPTR\t%#llx\n", table[i].addr);
+			valid++;
+		}
 	}
 	printf("\n");
 
-	printf(".globl kallsyms_num_syms\n");
-	printf("\tALGN\n");
-	printf("kallsyms_num_syms:\n");
+	output_label("kallsyms_num_syms");
 	printf("\tPTR\t%d\n", valid);
 	printf("\n");
 
-	printf(".globl kallsyms_names\n");
-	printf("\tALGN\n");
-	printf("kallsyms_names:\n");
-	prev = ""; 
+	/* table of offset markers, that give the offset in the compressed stream
+	 * every 256 symbols */
+	markers = (unsigned int *) malloc(sizeof(unsigned int)*((valid + 255) / 256));
+
+	output_label("kallsyms_names");
+	valid = 0;
+	off = 0;
 	for (i = 0; i < cnt; i++) {
-		int k;
 
-		if (!symbol_valid(&table[i]))
+		if (!table[i].flags & SYM_FLAG_VALID)
 			continue;
 
-		for (k = 0; table[i].sym[k] && table[i].sym[k] == prev[k]; ++k)
-			; 
+		if ((valid & 0xFF) == 0)
+			markers[valid >> 8] = off;
+
+		printf("\t.byte 0x%02x", table[i].len);
+		for (k = 0; k < table[i].len; k++)
+			printf(", 0x%02x", table[i].sym[k]);
+		printf("\n");
 
-		printf("\t.byte 0x%02x\n\t.asciz\t\"%s\"\n", k, table[i].sym + k);
-		prev = table[i].sym;
+		off += table[i].len + 1;
+		valid++;
 	}
 	printf("\n");
+
+	output_label("kallsyms_markers");
+	for (i = 0; i < ((valid + 255) >> 8); i++)
+		printf("\tPTR\t%d\n", markers[i]);
+	printf("\n");
+
+	free(markers);
+
+	output_label("kallsyms_token_table");
+	off = 0;
+	for (i = 0; i < 256; i++) {
+		best_idx[i] = off;
+		expand_symbol(best_table[i],best_table_len[i],buf);
+		printf("\t.asciz\t\"%s\"\n", buf);
+		off += strlen(buf) + 1;
+	}
+	printf("\n");
+
+	output_label("kallsyms_token_index");
+	for (i = 0; i < 256; i++)
+		printf("\t.short\t%d\n", best_idx[i]);
+	printf("\n");
+}
+
+
+/* table lookup compression functions */
+
+static inline unsigned int rehash_token(unsigned int hash, unsigned char data)
+{
+	return ((hash * 16777619) ^ data);
+}
+
+static unsigned int hash_token(unsigned char *data, int len)
+{
+	unsigned int hash=HASH_BASE_OFFSET;
+	int i;
+
+	for (i = 0; i < len; i++)
+		hash = rehash_token(hash, data[i]);
+
+	return HASH_FOLD(hash);
+}
+
+/* find a token given its data and hash value */
+static struct token *find_token_hash(unsigned char *data, int len, unsigned int hash)
+{
+	struct token *ptr;
+
+	ptr = hash_table[hash];
+
+	while (ptr) {
+		if ((ptr->len == len) && (memcmp(ptr->data, data, len) == 0))
+			return ptr;
+		ptr=ptr->next;
+	}
+
+	return NULL;
+}
+
+static inline void insert_token_in_group(struct token *head, struct token *ptr)
+{
+	ptr->right = head->right;
+	ptr->right->left = ptr;
+	head->right = ptr;
+	ptr->left = head;
+}
+
+static inline void remove_token_from_group(struct token *ptr)
+{
+	ptr->left->right = ptr->right;
+	ptr->right->left = ptr->left;
+}
+
+
+/* build the counts for all the tokens that start with "data", and have lenghts
+ * from 2 to "len" */
+static void learn_token(unsigned char *data, int len)
+{
+	struct token *ptr,*last_ptr;
+	int i, newprofit;
+	unsigned int hash = HASH_BASE_OFFSET;
+	unsigned int hashes[MAX_TOK_SIZE + 1];
+
+	if (len > MAX_TOK_SIZE)
+		len = MAX_TOK_SIZE;
+
+	/* calculate and store the hash values for all the sub-tokens */
+	hash = rehash_token(hash, data[0]);
+	for (i = 2; i <= len; i++) {
+		hash = rehash_token(hash, data[i-1]);
+		hashes[i] = HASH_FOLD(hash);
+	}
+
+	last_ptr = NULL;
+	ptr = NULL;
+
+	for (i = len; i >= 2; i--) {
+		hash = hashes[i];
+
+		if (!ptr) ptr = find_token_hash(data, i, hash);
+
+		if (!ptr) {
+			/* create a new token entry */
+			ptr = (struct token *) malloc(sizeof(*ptr));
+
+			memcpy(ptr->data, data, i);
+			ptr->len = i;
+
+			/* when we create an entry, it's profit is 0 because
+			 * we also take into account the size of the token on
+			 * the compressed table. We then subtract GOOD_BAD_THRESHOLD
+			 * so that the test to see if this token belongs to
+			 * the good or bad list, is a comparison to zero */
+			ptr->profit = -GOOD_BAD_THRESHOLD;
+
+			ptr->next = hash_table[hash];
+			hash_table[hash] = ptr;
+
+			insert_token_in_group(&bad_head, ptr);
+
+			ptr->smaller = NULL;
+		} else {
+			newprofit = ptr->profit + (ptr->len - 1);
+			/* check to see if this token needs to be moved to a
+			 * different list */
+			if((ptr->profit < 0) && (newprofit >= 0)) {
+				remove_token_from_group(ptr);
+				insert_token_in_group(&good_head,ptr);
+			}
+			ptr->profit = newprofit;
+		}
+
+		if (last_ptr) last_ptr->smaller = ptr;
+		last_ptr = ptr;
+
+		ptr = ptr->smaller;
+	}
+}
+
+/* decrease the counts for all the tokens that start with "data", and have lenghts
+ * from 2 to "len". This function is much simpler than learn_token because we have
+ * more guarantees (tho tokens exist, the ->smaller pointer is set, etc.)
+ * The two separate functions exist only because of compression performance */
+static void forget_token(unsigned char *data, int len)
+{
+	struct token *ptr;
+	int i, newprofit;
+	unsigned int hash=0;
+
+	if (len > MAX_TOK_SIZE) len = MAX_TOK_SIZE;
+
+	hash = hash_token(data, len);
+	ptr = find_token_hash(data, len, hash);
+
+	for (i = len; i >= 2; i--) {
+
+		newprofit = ptr->profit - (ptr->len - 1);
+		if ((ptr->profit >= 0) && (newprofit < 0)) {
+			remove_token_from_group(ptr);
+			insert_token_in_group(&bad_head, ptr);
+		}
+		ptr->profit=newprofit;
+
+		ptr=ptr->smaller;
+	}
+}
+
+/* count all the possible tokens in a symbol */
+static void learn_symbol(unsigned char *symbol, int len)
+{
+	int i;
+
+	for (i = 0; i < len - 1; i++)
+		learn_token(symbol + i, len - i);
+}
+
+/* decrease the count for all the possible tokens in a symbol */
+static void forget_symbol(unsigned char *symbol, int len)
+{
+	int i;
+
+	for (i = 0; i < len - 1; i++)
+		forget_token(symbol + i, len - i);
+}
+
+/* set all the symbol flags and do the initial token count */
+static void build_initial_tok_table(void)
+{
+	int i, use_it, valid;
+
+	valid = 0;
+	for (i = 0; i < cnt; i++) {
+		table[i].flags = 0;
+		if ( symbol_valid(&table[i]) ) {
+			table[i].flags |= SYM_FLAG_VALID;
+			valid++;
+		}
+	}
+
+	use_it = 0;
+	for (i = 0; i < cnt; i++) {
+
+		/* subsample the available symbols. This method is almost like
+		 * a Bresenham's algorithm to get uniformly distributed samples
+		 * across the symbol table */
+		if (table[i].flags & SYM_FLAG_VALID) {
+
+			use_it += WORKING_SET;
+
+			if (use_it >= valid) {
+				table[i].flags |= SYM_FLAG_SAMPLED;
+				use_it -= valid;
+			}
+		}
+		if (table[i].flags & SYM_FLAG_SAMPLED)
+			learn_symbol(table[i].sym, table[i].len);
+	}
+}
+
+/* replace a given token in all the valid symbols. Use the sampled symbols
+ * to update the counts */
+static void compress_symbols(unsigned char *str, int tlen, int idx)
+{
+	int i, len, learn, size;
+	unsigned char *p;
+
+	for (i = 0; i < cnt; i++) {
+
+		if (!(table[i].flags & SYM_FLAG_VALID)) continue;
+
+		len = table[i].len;
+		learn = 0;
+		p = table[i].sym;
+
+		do {
+			/* find the token on the symbol */
+			p = (unsigned char *) strstr((char *) p, (char *) str);
+			if (!p) break;
+
+			if (!learn) {
+				/* if this symbol was used to count, decrease it */
+				if (table[i].flags & SYM_FLAG_SAMPLED)
+					forget_symbol(table[i].sym, len);
+				learn = 1;
+			}
+
+			*p = idx;
+			size = (len - (p - table[i].sym)) - tlen + 1;
+			memmove(p + 1, p + tlen, size);
+			p++;
+			len -= tlen - 1;
+
+		} while (size >= tlen);
+
+		if(learn) {
+			table[i].len = len;
+			/* if this symbol was used to count, learn it again */
+			if(table[i].flags & SYM_FLAG_SAMPLED)
+				learn_symbol(table[i].sym, len);
+		}
+	}
 }
 
+/* search the token with the maximum profit */
+static struct token *find_best_token(void)
+{
+	struct token *ptr,*best,*head;
+	int bestprofit;
+
+	bestprofit=-10000;
+
+	/* failsafe: if the "good" list is empty search from the "bad" list */
+	if(good_head.right == &good_head) head = &bad_head;
+	else head = &good_head;
+
+	ptr = head->right;
+	best = NULL;
+	while (ptr != head) {
+		if (ptr->profit > bestprofit) {
+			bestprofit = ptr->profit;
+			best = ptr;
+		}
+		ptr = ptr->right;
+	}
+
+	return best;
+}
+
+/* this is the core of the algorithm: calculate the "best" table */
+static void optimize_result(void)
+{
+	struct token *best;
+	int i;
+
+	/* using the '\0' symbol last allows compress_symbols to use standard
+	 * fast string functions */
+	for (i = 255; i >= 0; i--) {
+
+		/* if this table slot is empty (it is not used by an actual
+		 * original char code */
+		if (!best_table_len[i]) {
+
+			/* find the token with the breates profit value */
+			best = find_best_token();
+
+			/* place it in the "best" table */
+			best_table_len[i] = best->len;
+			memcpy(best_table[i], best->data, best_table_len[i]);
+			/* zero terminate the token so that we can use strstr
+			   in compress_symbols */
+			best_table[i][best_table_len[i]]='\0';
+
+			/* replace this token in all the valid symbols */
+			compress_symbols(best_table[i], best_table_len[i], i);
+		}
+	}
+}
+
+/* start by placing the symbols that are actually used on the table */
+static void insert_real_symbols_in_table(void)
+{
+	int i, j, c;
+
+	memset(best_table, 0, sizeof(best_table));
+	memset(best_table_len, 0, sizeof(best_table_len));
+
+	for (i = 0; i < cnt; i++) {
+		if (table[i].flags & SYM_FLAG_VALID) {
+			for (j = 0; j < table[i].len; j++) {
+				c = table[i].sym[j];
+				best_table[c][0]=c;
+				best_table_len[c]=1;
+			}
+		}
+	}
+}
+
+static void optimize_token_table(void)
+{
+	memset(hash_table, 0, sizeof(hash_table));
+
+	good_head.left = &good_head;
+	good_head.right = &good_head;
+
+	bad_head.left = &bad_head;
+	bad_head.right = &bad_head;
+
+	build_initial_tok_table();
+
+	insert_real_symbols_in_table();
+
+	optimize_result();
+}
+
+
 int
 main(int argc, char **argv)
 {
@@ -171,6 +669,7 @@
 		usage();
 
 	read_map(stdin);
+	optimize_token_table();
 	write_src();
 
 	return 0;
diff -Nru a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
--- a/scripts/kconfig/Makefile	2004-12-24 13:37:31 -08:00
+++ b/scripts/kconfig/Makefile	2004-12-24 13:37:31 -08:00
@@ -38,7 +38,12 @@
 	$< -m arch/$(ARCH)/Kconfig
 
 defconfig: $(obj)/conf
+ifeq ($(KBUILD_DEFCONFIG),)
 	$< -d arch/$(ARCH)/Kconfig
+else
+	@echo *** Default configuration is based on '$(KBUILD_DEFCONFIG)'
+	$(Q)$< -D arch/$(ARCH)/configs/$(KBUILD_DEFCONFIG) arch/$(ARCH)/Kconfig
+endif
 
 %_defconfig: $(obj)/conf
 	$(Q)$< -D arch/$(ARCH)/configs/$@ arch/$(ARCH)/Kconfig
@@ -65,11 +70,9 @@
 #         Based on GTK which needs to be installed to compile it
 # object files used by all kconfig flavours
 
-libkconfig-objs := zconf.tab.o
-
 hostprogs-y	:= conf mconf qconf gconf
-conf-objs	:= conf.o  libkconfig.so
-mconf-objs	:= mconf.o libkconfig.so
+conf-objs	:= conf.o  zconf.tab.o
+mconf-objs	:= mconf.o zconf.tab.o
 
 ifeq ($(MAKECMDGOALS),xconfig)
 	qconf-target := 1
@@ -81,14 +84,14 @@
 
 ifeq ($(qconf-target),1)
 qconf-cxxobjs	:= qconf.o
-qconf-objs	:= kconfig_load.o
+qconf-objs	:= kconfig_load.o zconf.tab.o
 endif
 
 ifeq ($(gconf-target),1)
-gconf-objs	:= gconf.o kconfig_load.o
+gconf-objs	:= gconf.o kconfig_load.o zconf.tab.o
 endif
 
-clean-files	:= libkconfig.so lkc_defs.h qconf.moc .tmp_qtcheck \
+clean-files	:= lkc_defs.h qconf.moc .tmp_qtcheck \
 		   .tmp_gtkcheck zconf.tab.c zconf.tab.h lex.zconf.c
 
 # generated files seem to need this to find local include files
@@ -96,10 +99,11 @@
 HOSTCFLAGS_zconf.tab.o	:= -I$(src)
 
 HOSTLOADLIBES_qconf	= -L$(QTLIBPATH) -Wl,-rpath,$(QTLIBPATH) -l$(QTLIB) -ldl
-HOSTCXXFLAGS_qconf.o	= -I$(QTDIR)/include 
+HOSTCXXFLAGS_qconf.o	= -I$(QTDIR)/include -D LKC_DIRECT_LINK
 
 HOSTLOADLIBES_gconf	= `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --libs`
-HOSTCFLAGS_gconf.o	= `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags`
+HOSTCFLAGS_gconf.o	= `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags` \
+                          -D LKC_DIRECT_LINK
 
 $(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o: $(obj)/zconf.tab.h
 
diff -Nru a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
--- a/scripts/kconfig/conf.c	2004-12-24 13:37:19 -08:00
+++ b/scripts/kconfig/conf.c	2004-12-24 13:37:19 -08:00
@@ -31,14 +31,14 @@
 static int indent = 1;
 static int valid_stdin = 1;
 static int conf_cnt;
-static char line[128];
+static signed char line[128];
 static struct menu *rootEntry;
 
 static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
 
-static void strip(char *str)
+static void strip(signed char *str)
 {
-	char *p = str;
+	signed char *p = str;
 	int l;
 
 	while ((isspace(*p)))
diff -Nru a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
--- a/scripts/kconfig/confdata.c	2004-12-24 13:37:29 -08:00
+++ b/scripts/kconfig/confdata.c	2004-12-24 13:37:30 -08:00
@@ -27,10 +27,10 @@
 	NULL,
 };
 
-static char *conf_expand_value(const char *in)
+static char *conf_expand_value(const signed char *in)
 {
 	struct symbol *sym;
-	const char *src;
+	const signed char *src;
 	static char res_value[SYMBOL_MAXLENGTH];
 	char *dst, name[SYMBOL_MAXLENGTH];
 
@@ -270,6 +270,8 @@
 	int type, l;
 	const char *str;
 	time_t now;
+	int use_timestamp = 1;
+	char *env;
 
 	dirname[0] = 0;
 	if (name && name[0]) {
@@ -293,7 +295,7 @@
 	} else
 		basename = conf_def_filename;
 
-	sprintf(newname, "%s.tmpconfig.%d", dirname, getpid());
+	sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid());
 	out = fopen(newname, "w");
 	if (!out)
 		return 1;
@@ -306,22 +308,28 @@
 	sym = sym_lookup("KERNELRELEASE", 0);
 	sym_calc_value(sym);
 	time(&now);
+	env = getenv("KCONFIG_NOTIMESTAMP");
+	if (env && *env)
+		use_timestamp = 0;
+
 	fprintf(out, "#\n"
 		     "# Automatically generated make config: don't edit\n"
 		     "# Linux kernel version: %s\n"
-		     "# %s"
+		     "%s%s"
 		     "#\n",
 		     sym_get_string_value(sym),
-		     ctime(&now));
+		     use_timestamp ? "# " : "",
+		     use_timestamp ? ctime(&now) : "");
 	if (out_h)
 		fprintf(out_h, "/*\n"
 			       " * Automatically generated C config: don't edit\n"
 			       " * Linux kernel version: %s\n"
-			       " * %s"
+			       "%s%s"
 			       " */\n"
 			       "#define AUTOCONF_INCLUDED\n",
 			       sym_get_string_value(sym),
-			       ctime(&now));
+			       use_timestamp ? " * " : "",
+			       use_timestamp ? ctime(&now) : "");
 
 	if (!sym_change_count)
 		sym_clear_all_valid();
diff -Nru a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
--- a/scripts/kconfig/mconf.c	2004-12-24 13:36:31 -08:00
+++ b/scripts/kconfig/mconf.c	2004-12-24 13:36:31 -08:00
@@ -82,8 +82,8 @@
 	"leave this blank.\n"
 ;
 
-static char buf[4096], *bufptr = buf;
-static char input_buf[4096];
+static signed char buf[4096], *bufptr = buf;
+static signed char input_buf[4096];
 static char filename[PATH_MAX+1] = ".config";
 static char *args[1024], **argptr = args;
 static int indent;
diff -Nru a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
--- a/scripts/kconfig/symbol.c	2004-12-24 13:36:31 -08:00
+++ b/scripts/kconfig/symbol.c	2004-12-24 13:36:31 -08:00
@@ -421,7 +421,7 @@
 
 bool sym_string_valid(struct symbol *sym, const char *str)
 {
-	char ch;
+	signed char ch;
 
 	switch (sym->type) {
 	case S_STRING:
diff -Nru a/scripts/kernel-doc b/scripts/kernel-doc
--- a/scripts/kernel-doc	2004-12-24 13:36:48 -08:00
+++ b/scripts/kernel-doc	2004-12-24 13:36:48 -08:00
@@ -105,10 +105,7 @@
 # enums and typedefs. Instead of the function name you must write the name 
 # of the declaration;  the struct/union/enum/typedef must always precede 
 # the name. Nesting of declarations is not supported. 
-# Use the argument mechanism to document members or constants. In 
-# structs and unions you must declare one member per declaration 
-# (comma-separated members are not allowed -  the parser does not support 
-# this).
+# Use the argument mechanism to document members or constants.
 # e.g.
 # /**
 #  * struct my_struct - short description
@@ -455,7 +452,14 @@
     print "<h2>".$args{'type'}." ".$args{'struct'}."</h2>\n";
     print "<b>".$args{'type'}." ".$args{'struct'}."</b> {<br>\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-        ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
+	if ($parameter =~ /^#/) {
+		print "$parameter<br>\n";
+		next;
+	}
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+        ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
 	$type = $args{'parametertypes'}{$parameter};
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
@@ -471,10 +475,15 @@
     print "<h3>Members</h3>\n";
     print "<dl>\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-        ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
+	($parameter =~ /^#/) && next;
+
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+        ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
 	print "<dt><b>".$parameter."</b>\n";
 	print "<dd>";
-	output_highlight($args{'parameterdescs'}{$parameter});
+	output_highlight($args{'parameterdescs'}{$parameter_name});
     }
     print "</dl>\n";
     output_section_html(@_);
@@ -510,10 +519,13 @@
     print "<h3>Arguments</h3>\n";
     print "<dl>\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-        ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+        ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
 	print "<dt><b>".$parameter."</b>\n";
 	print "<dd>";
-	output_highlight($args{'parameterdescs'}{$parameter});
+	output_highlight($args{'parameterdescs'}{$parameter_name});
     }
     print "</dl>\n";
     output_section_html(@_);
@@ -605,10 +617,13 @@
     if ($#{$args{'parameterlist'}} >= 0) {
 	print " <variablelist>\n";
 	foreach $parameter (@{$args{'parameterlist'}}) {
+	    my $parameter_name = $parameter;
+	    $parameter_name =~ s/\[.*//;
+
 	    print "  <varlistentry>\n   <term><parameter>$parameter</parameter></term>\n";
 	    print "   <listitem>\n    <para>\n";
 	    $lineprefix="     ";
-	    output_highlight($args{'parameterdescs'}{$parameter});
+	    output_highlight($args{'parameterdescs'}{$parameter_name});
 	    print "    </para>\n   </listitem>\n  </varlistentry>\n";
 	}
 	print " </variablelist>\n";
@@ -647,8 +662,16 @@
     print "  <programlisting>\n";
     print $args{'type'}." ".$args{'struct'}." {\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-	defined($args{'parameterdescs'}{$parameter}) || next;
-        ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
+	if ($parameter =~ /^#/) {
+	    print "$parameter\n";
+	    next;
+	}
+
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+	defined($args{'parameterdescs'}{$parameter_name}) || next;
+        ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
 	$type = $args{'parametertypes'}{$parameter};
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
@@ -668,12 +691,17 @@
 
     print "  <variablelist>\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-      defined($args{'parameterdescs'}{$parameter}) || next;
-      ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
+      ($parameter =~ /^#/) && next;
+
+      my $parameter_name = $parameter;
+      $parameter_name =~ s/\[.*//;
+
+      defined($args{'parameterdescs'}{$parameter_name}) || next;
+      ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
       print "    <varlistentry>";
       print "      <term>$parameter</term>\n";
       print "      <listitem><para>\n";
-      output_highlight($args{'parameterdescs'}{$parameter});
+      output_highlight($args{'parameterdescs'}{$parameter_name});
       print "      </para></listitem>\n";
       print "    </varlistentry>\n";
     }
@@ -728,10 +756,13 @@
     print " <title>Constants</title>\n";    
     print "  <variablelist>\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+      my $parameter_name = $parameter;
+      $parameter_name =~ s/\[.*//;
+
       print "    <varlistentry>";
       print "      <term>$parameter</term>\n";
       print "      <listitem><para>\n";
-      output_highlight($args{'parameterdescs'}{$parameter});
+      output_highlight($args{'parameterdescs'}{$parameter_name});
       print "      </para></listitem>\n";
       print "    </varlistentry>\n";
     }
@@ -842,10 +873,13 @@
 	print "<colspec colwidth=\"8*\">\n";
 	print "<tbody>\n";
 	foreach $parameter (@{$args{'parameterlist'}}) {
+	    my $parameter_name = $parameter;
+	    $parameter_name =~ s/\[.*//;
+
 	    print "  <row><entry align=\"right\"><parameter>$parameter</parameter></entry>\n";
 	    print "   <entry>\n";
 	    $lineprefix="     ";
-	    output_highlight($args{'parameterdescs'}{$parameter});
+	    output_highlight($args{'parameterdescs'}{$parameter_name});
 	    print "    </entry></row>\n";
 	}
 	print " </tbody></tgroup></informaltable>\n";
@@ -909,8 +943,11 @@
 
     print ".SH ARGUMENTS\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
 	print ".IP \"".$parameter."\" 12\n";
-	output_highlight($args{'parameterdescs'}{$parameter});
+	output_highlight($args{'parameterdescs'}{$parameter_name});
     }
     foreach $section (@{$args{'sectionlist'}}) {
 	print ".SH \"", uc $section, "\"\n";
@@ -947,8 +984,11 @@
 
     print ".SH Constants\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
 	print ".IP \"".$parameter."\" 12\n";
-	output_highlight($args{'parameterdescs'}{$parameter});
+	output_highlight($args{'parameterdescs'}{$parameter_name});
     }
     foreach $section (@{$args{'sectionlist'}}) {
 	print ".SH \"$section\"\n";
@@ -968,11 +1008,17 @@
     print $args{'type'}." ".$args{'struct'}." \\- ".$args{'purpose'}."\n";
 
     print ".SH SYNOPSIS\n";
-    print $args{'type'}." ".$args{'struct'}." {\n";
+    print $args{'type'}." ".$args{'struct'}." {\n.br\n";
 
     foreach my $parameter (@{$args{'parameterlist'}}) {
-        ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
-	print "\n.br\n";
+	if ($parameter =~ /^#/) {
+	    print ".BI \"$parameter\"\n.br\n";
+	    next;
+	}
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+        ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
 	$type = $args{'parametertypes'}{$parameter};
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
@@ -989,9 +1035,14 @@
 
     print ".SH Arguments\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-        ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
+	($parameter =~ /^#/) && next;
+
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+        ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
 	print ".IP \"".$parameter."\" 12\n";
-	output_highlight($args{'parameterdescs'}{$parameter});
+	output_highlight($args{'parameterdescs'}{$parameter_name});
     }
     foreach $section (@{$args{'sectionlist'}}) {
 	print ".SH \"$section\"\n";
@@ -1058,7 +1109,10 @@
 
     print "Arguments:\n\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-	print $parameter."\n\t".$args{'parameterdescs'}{$parameter}."\n";
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+	print $parameter."\n\t".$args{'parameterdescs'}{$parameter_name}."\n";
     }
     output_section_text(@_);
 }
@@ -1123,7 +1177,15 @@
     print $args{'type'}." ".$args{'struct'}.":\n\n";
     print $args{'type'}." ".$args{'struct'}." {\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-        ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
+	if ($parameter =~ /^#/) {
+	    print "$parameter\n";
+	    next;
+	}
+
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+        ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
 	$type = $args{'parametertypes'}{$parameter};
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
@@ -1138,9 +1200,14 @@
 
     print "Members:\n\n";
     foreach $parameter (@{$args{'parameterlist'}}) {
-        ($args{'parameterdescs'}{$parameter} ne $undescribed) || next;
+	($parameter =~ /^#/) && next;
+
+	my $parameter_name = $parameter;
+	$parameter_name =~ s/\[.*//;
+
+        ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
 	print "$parameter\n\t";
-	print $args{'parameterdescs'}{$parameter}."\n";
+	print $args{'parameterdescs'}{$parameter_name}."\n";
     }
     print "\n";
     output_section_text(@_);
@@ -1311,33 +1378,57 @@
 	$arg =~ s/\s*$//;
 	$arg =~ s/\s+/ /;
 
-	if ($arg =~ m/\(/) {
+	if ($arg =~ /^#/) {
+	    # Treat preprocessor directive as a typeless variable just to fill
+	    # corresponding data structures "correctly". Catch it later in
+	    # output_* subs.
+	    push_parameter($arg, "", $file);
+	} elsif ($arg =~ m/\(/) {
 	    # pointer-to-function
 	    $arg =~ tr/#/,/;
 	    $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
 	    $param = $1;
 	    $type = $arg;
 	    $type =~ s/([^\(]+\(\*)$param/$1/;
+	    push_parameter($param, $type, $file);
 	} else {
-	    # evil magic to get fixed array parameters to work
-	    $arg =~ s/(.+\s+)(.+)\[.*/$1* $2/;
-	    my @args = split('\s', $arg);
-	
-	    $param = pop @args;
-	    if ($param =~ m/^(\*+)(.*)/) {
-	        $param = $2;
-		push @args, $1;
-	    } 
-	    elsif ($param =~ m/(.*?)\s*:\s*(\d+)/) {
-	        $param = $1;
-	        push @args, ":$2";
+	    $arg =~ s/\s*:\s*/:/g;
+	    $arg =~ s/\s*\[/\[/g;
+
+	    my @args = split('\s*,\s*', $arg);
+	    if ($args[0] =~ m/\*/) {
+		$args[0] =~ s/(\*+)\s*/ $1/;
+	    }
+	    my @first_arg = split('\s+', shift @args);
+	    unshift(@args, pop @first_arg);
+	    $type = join " ", @first_arg;
+
+	    foreach $param (@args) {
+		if ($param =~ m/^(\*+)\s*(.*)/) {
+		    push_parameter($2, "$type $1", $file);
+		}
+		elsif ($param =~ m/(.*?):(\d+)/) {
+		    push_parameter($1, "$type:$2", $file)
+		}
+		else {
+		    push_parameter($param, $type, $file);
+		}
 	    }
-	    $type = join " ", @args;
 	}
+    }
+}
+
+sub push_parameter($$$) {
+	my $param = shift;
+	my $type = shift;
+	my $file = shift;
+
+	my $param_name = $param;
+	$param_name =~ s/\[.*//;
 
 	if ($type eq "" && $param eq "...")
 	{
-	    $type="...";
+	    $type="";
 	    $param="...";
 	    $parameterdescs{"..."} = "variable arguments";
 	}
@@ -1347,8 +1438,8 @@
 	    $param="void";
 	    $parameterdescs{void} = "no arguments";
 	}
-	if (defined $type && $type && !defined $parameterdescs{$param}) {
-	    $parameterdescs{$param} = $undescribed;
+	if (defined $type && $type && !defined $parameterdescs{$param_name}) {
+	    $parameterdescs{$param_name} = $undescribed;
 
 	    if (($type eq 'function') || ($type eq 'enum')) {
 	        print STDERR "Warning(${file}:$.): Function parameter ".
@@ -1362,7 +1453,6 @@
 
 	push @parameterlist, $param;
 	$parametertypes{$param} = $type;
-    }
 }
 
 ##
@@ -1511,6 +1601,10 @@
     $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
     $x =~ s@^\s+@@gos; # strip leading spaces
     $x =~ s@\s+$@@gos; # strip trailing spaces
+    if ($x =~ /^#/) {
+	# To distinguish preprocessor directive from regular declaration later.
+	$x .= ";";
+    }
 
     while (1) {
         if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
@@ -1531,7 +1625,7 @@
 }
 
 sub process_file($) {
-    my ($file) = @_;
+    my ($file) = "$ENV{'SRCTREE'}@_";
     my $identifier;
     my $func;
     my $initial_section_counter = $section_counter;
diff -Nru a/scripts/lxdialog/Makefile b/scripts/lxdialog/Makefile
--- a/scripts/lxdialog/Makefile	2004-12-24 13:37:18 -08:00
+++ b/scripts/lxdialog/Makefile	2004-12-24 13:37:18 -08:00
@@ -1,5 +1,9 @@
 HOST_EXTRACFLAGS := -DLOCALE 
+ifeq ($(shell uname),SunOS)
+HOST_LOADLIBES   := -lcurses
+else
 HOST_LOADLIBES   := -lncurses
+endif
 
 ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
         HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
diff -Nru a/scripts/lxdialog/dialog.h b/scripts/lxdialog/dialog.h
--- a/scripts/lxdialog/dialog.h	2004-12-24 13:37:18 -08:00
+++ b/scripts/lxdialog/dialog.h	2004-12-24 13:37:18 -08:00
@@ -26,6 +26,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef __sun__
+#define CURS_MACROS
+#endif
 #include CURSES_LOC
 
 /*
diff -Nru a/scripts/mksysmap b/scripts/mksysmap
--- a/scripts/mksysmap	2004-12-24 13:37:18 -08:00
+++ b/scripts/mksysmap	2004-12-24 13:37:18 -08:00
@@ -40,5 +40,5 @@
 # so we just ignore them to let readprofile continue to work.
 # (At least sparc64 has __crc_ in the middle).
 
-$NM -n $1 | grep -v '\( [aUw] \)\|\(__crc_\)' > $2
+$NM -n $1 | grep -v '\( [aUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $2
 
diff -Nru a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
--- a/scripts/mod/file2alias.c	2004-12-24 13:36:48 -08:00
+++ b/scripts/mod/file2alias.c	2004-12-24 13:36:48 -08:00
@@ -12,17 +12,22 @@
 
 #include "modpost.h"
 
-/* We use the ELF typedefs, since we can't rely on stdint.h being present. */
-
+/* We use the ELF typedefs for kernel_ulong_t but bite the bullet and
+ * use either stdint.h or inttypes.h for the rest. */
 #if KERNEL_ELFCLASS == ELFCLASS32
-typedef Elf32_Addr     kernel_ulong_t;
+typedef Elf32_Addr	kernel_ulong_t;
+#else
+typedef Elf64_Addr	kernel_ulong_t;
+#endif
+#ifdef __sun__
+#include <inttypes.h>
 #else
-typedef Elf64_Addr     kernel_ulong_t;
+#include <stdint.h>
 #endif
 
-typedef Elf32_Word     __u32;
-typedef Elf32_Half     __u16;
-typedef unsigned char  __u8;
+typedef uint32_t	__u32;
+typedef uint16_t	__u16;
+typedef unsigned char	__u8;
 
 /* Big exception to the "don't include kernel headers into userspace, which
  * even potentially has different endianness and word sizes, since 
diff -Nru a/scripts/mod/modpost.c b/scripts/mod/modpost.c
--- a/scripts/mod/modpost.c	2004-12-24 13:36:19 -08:00
+++ b/scripts/mod/modpost.c	2004-12-24 13:36:19 -08:00
@@ -1,7 +1,7 @@
 /* Postprocess module symbol versions
  *
  * Copyright 2003       Kai Germaschewski
- *           2002-2003  Rusty Russell, IBM Corporation
+ * Copyright 2002-2004  Rusty Russell, IBM Corporation
  *
  * Based in part on module-init-tools/depmod.c,file2alias
  *
@@ -18,6 +18,8 @@
 int modversions = 0;
 /* Warn about undefined symbols? (do so if we have vmlinux) */
 int have_vmlinux = 0;
+/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
+static int all_versions = 0;
 
 void
 fatal(const char *fmt, ...)
@@ -102,6 +104,7 @@
 	struct module *module;
 	unsigned int crc;
 	int crc_valid;
+	unsigned int weak:1;
 	char name[0];
 };
 
@@ -124,12 +127,13 @@
  * the list of unresolved symbols per module */
 
 struct symbol *
-alloc_symbol(const char *name, struct symbol *next)
+alloc_symbol(const char *name, unsigned int weak, struct symbol *next)
 {
 	struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
 
 	memset(s, 0, sizeof(*s));
 	strcpy(s->name, name);
+	s->weak = weak;
 	s->next = next;
 	return s;
 }
@@ -143,7 +147,7 @@
 	struct symbol *new;
 
 	hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
-	new = symbolhash[hash] = alloc_symbol(name, symbolhash[hash]);
+	new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]);
 	new->module = module;
 	if (crc) {
 		new->crc = *crc;
@@ -215,7 +219,7 @@
 	static char line[4096];
 	int skip = 1;
 	size_t len = 0;
-	char *p = (char *)file + *pos;
+	signed char *p = (signed char *)file + *pos;
 	char *s = line;
 
 	for (; *pos < size ; (*pos)++)
@@ -347,7 +351,8 @@
 		break;
 	case SHN_UNDEF:
 		/* undefined symbol */
-		if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL)
+		if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL &&
+		    ELF_ST_BIND(sym->st_info) != STB_WEAK)
 			break;
 		/* ignore global offset table */
 		if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
@@ -368,6 +373,7 @@
 			   strlen(MODULE_SYMBOL_PREFIX)) == 0)
 			mod->unres = alloc_symbol(symname +
 						  strlen(MODULE_SYMBOL_PREFIX),
+						  ELF_ST_BIND(sym->st_info) == STB_WEAK,
 						  mod->unres);
 		break;
 	default:
@@ -397,10 +403,44 @@
 	return strcmp(myname, "vmlinux") == 0;
 }
 
+/* Parse tag=value strings from .modinfo section */
+static char *next_string(char *string, unsigned long *secsize)
+{
+	/* Skip non-zero chars */
+	while (string[0]) {
+		string++;
+		if ((*secsize)-- <= 1)
+			return NULL;
+	}
+
+	/* Skip any zero padding. */
+	while (!string[0]) {
+		string++;
+		if ((*secsize)-- <= 1)
+			return NULL;
+	}
+	return string;
+}
+
+static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
+			 const char *tag)
+{
+	char *p;
+	unsigned int taglen = strlen(tag);
+	unsigned long size = modinfo_len;
+
+	for (p = modinfo; p; p = next_string(p, &size)) {
+		if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=')
+			return p + taglen + 1;
+	}
+	return NULL;
+}
+
 void
 read_symbols(char *modname)
 {
 	const char *symname;
+	char *version;
 	struct module *mod;
 	struct elf_info info = { };
 	Elf_Sym *sym;
@@ -424,8 +464,15 @@
 		handle_modversions(mod, &info, sym, symname);
 		handle_moddevtable(mod, &info, sym, symname);
 	}
-	maybe_frob_version(modname, info.modinfo, info.modinfo_len,
-			   (void *)info.modinfo - (void *)info.hdr);
+
+	version = get_modinfo(info.modinfo, info.modinfo_len, "version");
+	if (version)
+		maybe_frob_rcs_version(modname, version, info.modinfo,
+				       version - (char *)info.hdr);
+	if (version || (all_versions && !is_vmlinux(modname)))
+		get_src_version(modname, mod->srcversion,
+				sizeof(mod->srcversion)-1);
+
 	parse_elf_finish(&info);
 
 	/* Our trick to get versioning for struct_module - it's
@@ -433,7 +480,7 @@
 	 * the automatic versioning doesn't pick it up, but it's really
 	 * important anyhow */
 	if (modversions)
-		mod->unres = alloc_symbol("struct_module", mod->unres);
+		mod->unres = alloc_symbol("struct_module", 0, mod->unres);
 }
 
 #define SZ 500
@@ -505,7 +552,7 @@
 	for (s = mod->unres; s; s = s->next) {
 		exp = find_symbol(s->name);
 		if (!exp || exp->module == mod) {
-			if (have_vmlinux)
+			if (have_vmlinux && !s->weak)
 				fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
 				"undefined!\n",	s->name, mod->name);
 			continue;
@@ -571,6 +618,16 @@
 }
 
 void
+add_srcversion(struct buffer *b, struct module *mod)
+{
+	if (mod->srcversion[0]) {
+		buf_printf(b, "\n");
+		buf_printf(b, "MODULE_INFO(srcversion, \"%s\");\n",
+			   mod->srcversion);
+	}
+}
+
+void
 write_if_changed(struct buffer *b, const char *fname)
 {
 	char *tmp;
@@ -691,7 +748,7 @@
 	char *dump_read = NULL, *dump_write = NULL;
 	int opt;
 
-	while ((opt = getopt(argc, argv, "i:mo:")) != -1) {
+	while ((opt = getopt(argc, argv, "i:mo:a")) != -1) {
 		switch(opt) {
 			case 'i':
 				dump_read = optarg;
@@ -702,6 +759,9 @@
 			case 'o':
 				dump_write = optarg;
 				break;
+			case 'a':
+				all_versions = 1;
+				break;
 			default:
 				exit(1);
 		}
@@ -724,6 +784,7 @@
 		add_versions(&buf, mod);
 		add_depends(&buf, mod, modules);
 		add_moddevtable(&buf, mod);
+		add_srcversion(&buf, mod);
 
 		sprintf(fname, "%s.mod.c", mod->name);
 		write_if_changed(&buf, fname);
diff -Nru a/scripts/mod/modpost.h b/scripts/mod/modpost.h
--- a/scripts/mod/modpost.h	2004-12-24 13:36:16 -08:00
+++ b/scripts/mod/modpost.h	2004-12-24 13:36:16 -08:00
@@ -77,6 +77,7 @@
 	int has_init;
 	int has_cleanup;
 	struct buffer dev_table_buf;
+	char	     srcversion[25];
 };
 
 struct elf_info {
@@ -95,10 +96,11 @@
 
 void add_moddevtable(struct buffer *buf, struct module *mod);
 
-void maybe_frob_version(const char *modfilename,
-			void *modinfo,
-			unsigned long modinfo_len,
-			unsigned long modinfo_offset);
+void maybe_frob_rcs_version(const char *modfilename,
+			    char *version,
+			    void *modinfo,
+			    unsigned long modinfo_offset);
+void get_src_version(const char *modname, char sum[], unsigned sumlen);
 
 void *grab_file(const char *filename, unsigned long *size);
 char* get_next_line(unsigned long *pos, void *file, unsigned long size);
diff -Nru a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
--- a/scripts/mod/sumversion.c	2004-12-24 13:37:02 -08:00
+++ b/scripts/mod/sumversion.c	2004-12-24 13:37:02 -08:00
@@ -9,39 +9,6 @@
 #include <string.h>
 #include "modpost.h"
 
-/* Parse tag=value strings from .modinfo section */
-static char *next_string(char *string, unsigned long *secsize)
-{
-	/* Skip non-zero chars */
-	while (string[0]) {
-		string++;
-		if ((*secsize)-- <= 1)
-			return NULL;
-	}
-
-	/* Skip any zero padding. */
-	while (!string[0]) {
-		string++;
-		if ((*secsize)-- <= 1)
-			return NULL;
-	}
-	return string;
-}
-
-static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
-			 const char *tag)
-{
-	char *p;
-	unsigned int taglen = strlen(tag);
-	unsigned long size = modinfo_len;
-
-	for (p = modinfo; p; p = next_string(p, &size)) {
-		if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=')
-			return p + taglen + 1;
-	}
-	return NULL;
-}
-
 /*
  * Stolen form Cryptographic API.
  *
@@ -285,9 +252,9 @@
 }
 
 /* FIXME: Handle .s files differently (eg. # starts comments) --RR */
-static int parse_file(const char *fname, struct md4_ctx *md)
+static int parse_file(const signed char *fname, struct md4_ctx *md)
 {
-	char *file;
+	signed char *file;
 	unsigned long i, len;
 
 	file = grab_file(fname, &len);
@@ -365,7 +332,7 @@
 	   Sum all files in the same dir or subdirs.
 	*/
 	while ((line = get_next_line(&pos, file, flen)) != NULL) {
-		char* p = line;
+		signed char* p = line;
 		if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) {
 			check_files = 1;
 			continue;
@@ -408,15 +375,16 @@
 	return ret;
 }
 
-static int get_version(const char *modname, char sum[])
+/* Calc and record src checksum. */
+void get_src_version(const char *modname, char sum[], unsigned sumlen)
 {
 	void *file;
 	unsigned long len;
-	int ret = 0;
 	struct md4_ctx md;
 	char *sources, *end, *fname;
 	const char *basename;
-	char filelist[sizeof(".tmp_versions/%s.mod") + strlen(modname)];
+	char filelist[strlen(getenv("MODVERDIR")) + strlen("/") +
+		      strlen(modname) - strlen(".o") + strlen(".mod") + 1 ];
 
 	/* Source files for module are in .tmp_versions/modname.mod,
 	   after the first line. */
@@ -424,15 +392,14 @@
 		basename = strrchr(modname, '/') + 1;
 	else
 		basename = modname;
-	sprintf(filelist, ".tmp_versions/%s", basename);
-	/* Truncate .o, add .mod */
-	strcpy(filelist + strlen(filelist)-2, ".mod");
+	sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"),
+		(int) strlen(basename) - 2, basename);
 
 	file = grab_file(filelist, &len);
 	if (!file) {
 		fprintf(stderr, "Warning: could not find versions for %s\n",
 			filelist);
-		return 0;
+		return;
 	}
 
 	sources = strchr(file, '\n');
@@ -457,12 +424,9 @@
 			goto release;
 	}
 
-	/* sum is of form \0<padding>. */
-	md4_final_ascii(&md, sum, 1 + strlen(sum+1));
-	ret = 1;
+	md4_final_ascii(&md, sum, sumlen);
 release:
 	release_file(file, len);
-	return ret;
 }
 
 static void write_version(const char *filename, const char *sum,
@@ -492,12 +456,12 @@
 	close(fd);
 }
 
-void strip_rcs_crap(char *version)
+static int strip_rcs_crap(signed char *version)
 {
 	unsigned int len, full_len;
 
 	if (strncmp(version, "$Revision", strlen("$Revision")) != 0)
-		return;
+		return 0;
 
 	/* Space for version string follows. */
 	full_len = strlen(version) + strlen(version + strlen(version) + 1) + 2;
@@ -518,31 +482,15 @@
 		len++;
 	memmove(version + len, version + strlen(version),
 		full_len - strlen(version));
+	return 1;
 }
 
-/* If the modinfo contains a "version" value, then set this. */
-void maybe_frob_version(const char *modfilename,
-			void *modinfo,
-			unsigned long modinfo_len,
-			unsigned long modinfo_offset)
+/* Clean up RCS-style version numbers. */
+void maybe_frob_rcs_version(const char *modfilename,
+			    char *version,
+			    void *modinfo,
+			    unsigned long version_offset)
 {
-	char *version, *csum;
-
-	version = get_modinfo(modinfo, modinfo_len, "version");
-	if (!version)
-		return;
-
-	/* RCS $Revision gets stripped out. */
-	strip_rcs_crap(version);
-
-	/* Check against double sumversion */
-	if (strchr(version, ' '))
-		return;
-
-	/* Version contains embedded NUL: second half has space for checksum */
-	csum = version + strlen(version);
-	*(csum++) = ' ';
-	if (get_version(modfilename, csum))
-		write_version(modfilename, version,
-			      modinfo_offset + (version - (char *)modinfo));
+	if (strip_rcs_crap(version))
+		write_version(modfilename, version, version_offset);
 }
diff -Nru a/scripts/reference_init.pl b/scripts/reference_init.pl
--- a/scripts/reference_init.pl	2004-12-24 13:37:04 -08:00
+++ b/scripts/reference_init.pl	2004-12-24 13:37:04 -08:00
@@ -93,6 +93,9 @@
 		     $from !~ /\.stab$/ &&
 		     $from !~ /\.rodata$/ &&
 		     $from !~ /\.text\.lock$/ &&
+		     $from !~ /\.pci_fixup_header$/ &&
+		     $from !~ /\.pci_fixup_final$/ &&
+		     $from !~ /\__param$/ &&
 		     $from !~ /\.debug_/)) {
 			printf("Error: %s %s refers to %s\n", $object, $from, $line);
 		}
diff -Nru a/security/Kconfig b/security/Kconfig
--- a/security/Kconfig	2004-12-24 13:37:02 -08:00
+++ b/security/Kconfig	2004-12-24 13:37:02 -08:00
@@ -4,6 +4,35 @@
 
 menu "Security options"
 
+config KEYS
+	bool "Enable access key retention support"
+	help
+	  This option provides support for retaining authentication tokens and
+	  access keys in the kernel.
+
+	  It also includes provision of methods by which such keys might be
+	  associated with a process so that network filesystems, encryption
+	  support and the like can find them.
+
+	  Furthermore, a special type of key is available that acts as keyring:
+	  a searchable sequence of keys. Each process is equipped with access
+	  to five standard keyrings: UID-specific, GID-specific, session,
+	  process and thread.
+
+	  If you are unsure as to whether this is required, answer N.
+
+config KEYS_DEBUG_PROC_KEYS
+	bool "Enable the /proc/keys file by which all keys may be viewed"
+	depends on KEYS
+	help
+	  This option turns on support for the /proc/keys file through which
+	  all the keys on the system can be listed.
+
+	  This option is a slight security risk in that it makes it possible
+	  for anyone to see all the keys on the system. Normally the manager
+	  pretends keys that are inaccessible to a process don't exist as far
+	  as that process is concerned.
+
 config SECURITY
 	bool "Enable different security models"
 	help
@@ -42,6 +71,17 @@
 	  See <http://www.linuxjournal.com/article.php?sid=6279> for
 	  more information about this module.
 	  
+	  If you are unsure how to answer this question, answer N.
+
+config SECURITY_SECLVL
+	tristate "BSD Secure Levels"
+	depends on SECURITY
+	select CRYPTO_SHA1
+	help
+	  Implements BSD Secure Levels as an LSM.  See
+	  Documentation/seclvl.txt for instructions on how to use this
+	  module.
+
 	  If you are unsure how to answer this question, answer N.
 
 source security/selinux/Kconfig
diff -Nru a/security/Makefile b/security/Makefile
--- a/security/Makefile	2004-12-24 13:37:02 -08:00
+++ b/security/Makefile	2004-12-24 13:37:02 -08:00
@@ -2,6 +2,7 @@
 # Makefile for the kernel security code
 #
 
+obj-$(CONFIG_KEYS)			+= keys/
 subdir-$(CONFIG_SECURITY_SELINUX)	+= selinux
 
 # if we don't select a security model, use the default capabilities
@@ -15,3 +16,4 @@
 obj-$(CONFIG_SECURITY_SELINUX)		+= selinux/built-in.o
 obj-$(CONFIG_SECURITY_CAPABILITIES)	+= commoncap.o capability.o
 obj-$(CONFIG_SECURITY_ROOTPLUG)		+= commoncap.o root_plug.o
+obj-$(CONFIG_SECURITY_SECLVL)		+= seclvl.o
diff -Nru a/security/capability.c b/security/capability.c
--- a/security/capability.c	2004-12-24 13:36:47 -08:00
+++ b/security/capability.c	2004-12-24 13:36:47 -08:00
@@ -30,6 +30,7 @@
 	.capset_check =			cap_capset_check,
 	.capset_set =			cap_capset_set,
 	.capable =			cap_capable,
+	.settime =			cap_settime,
 	.netlink_send =			cap_netlink_send,
 	.netlink_recv =			cap_netlink_recv,
 
diff -Nru a/security/commoncap.c b/security/commoncap.c
--- a/security/commoncap.c	2004-12-24 13:36:47 -08:00
+++ b/security/commoncap.c	2004-12-24 13:36:47 -08:00
@@ -24,23 +24,45 @@
 #include <linux/xattr.h>
 #include <linux/hugetlb.h>
 
+int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
+{
+	NETLINK_CB(skb).eff_cap = current->cap_effective;
+	return 0;
+}
+
+EXPORT_SYMBOL(cap_netlink_send);
+
+int cap_netlink_recv(struct sk_buff *skb)
+{
+	if (!cap_raised(NETLINK_CB(skb).eff_cap, CAP_NET_ADMIN))
+		return -EPERM;
+	return 0;
+}
+
+EXPORT_SYMBOL(cap_netlink_recv);
+
 int cap_capable (struct task_struct *tsk, int cap)
 {
 	/* Derived from include/linux/sched.h:capable. */
-	if (cap_raised (tsk->cap_effective, cap))
+	if (cap_raised(tsk->cap_effective, cap))
 		return 0;
-	else
+	return -EPERM;
+}
+
+int cap_settime(struct timespec *ts, struct timezone *tz)
+{
+	if (!capable(CAP_SYS_TIME))
 		return -EPERM;
+	return 0;
 }
 
 int cap_ptrace (struct task_struct *parent, struct task_struct *child)
 {
 	/* Derived from arch/i386/kernel/ptrace.c:sys_ptrace. */
 	if (!cap_issubset (child->cap_permitted, current->cap_permitted) &&
-	    !capable (CAP_SYS_PTRACE))
+	    !capable(CAP_SYS_PTRACE))
 		return -EPERM;
-	else
-		return 0;
+	return 0;
 }
 
 int cap_capget (struct task_struct *target, kernel_cap_t *effective,
@@ -373,6 +395,7 @@
 }
 
 EXPORT_SYMBOL(cap_capable);
+EXPORT_SYMBOL(cap_settime);
 EXPORT_SYMBOL(cap_ptrace);
 EXPORT_SYMBOL(cap_capget);
 EXPORT_SYMBOL(cap_capset_check);
diff -Nru a/security/dummy.c b/security/dummy.c
--- a/security/dummy.c	2004-12-24 13:36:31 -08:00
+++ b/security/dummy.c	2004-12-24 13:36:31 -08:00
@@ -104,6 +104,13 @@
 	return 0;
 }
 
+static int dummy_settime(struct timespec *ts, struct timezone *tz)
+{
+	if (!capable(CAP_SYS_TIME))
+		return -EPERM;
+	return 0;
+}
+
 /*
  * Check that a process has enough memory to allocate a new virtual
  * mapping. 0 means there is enough memory for the allocation to
@@ -447,17 +454,17 @@
 	return 0;
 }
 
-static int dummy_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
+static int dummy_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
 {
 	return -EOPNOTSUPP;
 }
 
-static int dummy_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) 
+static int dummy_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
 {
 	return -EOPNOTSUPP;
 }
 
-static int dummy_inode_listsecurity(struct dentry *dentry, char *buffer)
+static int dummy_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
 {
 	return 0;
 }
@@ -511,8 +518,7 @@
 }
 
 static int dummy_file_send_sigiotask (struct task_struct *tsk,
-				      struct fown_struct *fown, int fd,
-				      int reason)
+				      struct fown_struct *fown, int sig)
 {
 	return 0;
 }
@@ -897,6 +903,7 @@
 	set_to_dummy_if_null(ops, quota_on);
 	set_to_dummy_if_null(ops, sysctl);
 	set_to_dummy_if_null(ops, syslog);
+	set_to_dummy_if_null(ops, settime);
 	set_to_dummy_if_null(ops, vm_enough_memory);
 	set_to_dummy_if_null(ops, bprm_alloc_security);
 	set_to_dummy_if_null(ops, bprm_free_security);
diff -Nru a/security/keys/Makefile b/security/keys/Makefile
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/Makefile	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,14 @@
+#
+# Makefile for key management
+#
+
+obj-y := \
+	key.o \
+	keyring.o \
+	keyctl.o \
+	process_keys.o \
+	user_defined.o \
+	request_key.o
+
+obj-$(CONFIG_KEYS_COMPAT) += compat.o
+obj-$(CONFIG_PROC_FS) += proc.o
diff -Nru a/security/keys/compat.c b/security/keys/compat.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/compat.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,78 @@
+/* compat.c: 32-bit compatibility syscall for 64-bit systems
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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/sched.h>
+#include <linux/syscalls.h>
+#include <linux/keyctl.h>
+#include <linux/compat.h>
+#include "internal.h"
+
+/*****************************************************************************/
+/*
+ * the key control system call, 32-bit compatibility version for 64-bit archs
+ * - this should only be called if the 64-bit arch uses weird pointers in
+ *   32-bit mode or doesn't guarantee that the top 32-bits of the argument
+ *   registers on taking a 32-bit syscall are zero
+ * - if you can, you should call sys_keyctl directly
+ */
+asmlinkage long compat_sys_keyctl(u32 option,
+			      u32 arg2, u32 arg3, u32 arg4, u32 arg5)
+{
+	switch (option) {
+	case KEYCTL_GET_KEYRING_ID:
+		return keyctl_get_keyring_ID(arg2, arg3);
+
+	case KEYCTL_JOIN_SESSION_KEYRING:
+		return keyctl_join_session_keyring(compat_ptr(arg3));
+
+	case KEYCTL_UPDATE:
+		return keyctl_update_key(arg2, compat_ptr(arg3), arg4);
+
+	case KEYCTL_REVOKE:
+		return keyctl_revoke_key(arg2);
+
+	case KEYCTL_DESCRIBE:
+		return keyctl_describe_key(arg2, compat_ptr(arg3), arg4);
+
+	case KEYCTL_CLEAR:
+		return keyctl_keyring_clear(arg2);
+
+	case KEYCTL_LINK:
+		return keyctl_keyring_link(arg2, arg3);
+
+	case KEYCTL_UNLINK:
+		return keyctl_keyring_unlink(arg2, arg3);
+
+	case KEYCTL_SEARCH:
+		return keyctl_keyring_search(arg2, compat_ptr(arg3),
+					     compat_ptr(arg4), arg5);
+
+	case KEYCTL_READ:
+		return keyctl_read_key(arg2, compat_ptr(arg3), arg4);
+
+	case KEYCTL_CHOWN:
+		return keyctl_chown_key(arg2, arg3, arg4);
+
+	case KEYCTL_SETPERM:
+		return keyctl_setperm_key(arg2, arg3);
+
+	case KEYCTL_INSTANTIATE:
+		return keyctl_instantiate_key(arg2, compat_ptr(arg3), arg4,
+					      arg5);
+
+	case KEYCTL_NEGATE:
+		return keyctl_negate_key(arg2, arg3, arg4);
+
+	default:
+		return -EOPNOTSUPP;
+	}
+
+} /* end compat_sys_keyctl() */
diff -Nru a/security/keys/internal.h b/security/keys/internal.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/internal.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,123 @@
+/* internal.h: authentication token and access key management internal defs
+ *
+ * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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.
+ */
+
+#ifndef _INTERNAL_H
+#define _INTERNAL_H
+
+#include <linux/key.h>
+#include <linux/key-ui.h>
+
+extern struct key_type key_type_dead;
+extern struct key_type key_type_user;
+
+/*****************************************************************************/
+/*
+ * keep track of keys for a user
+ * - this needs to be separate to user_struct to avoid a refcount-loop
+ *   (user_struct pins some keyrings which pin this struct)
+ * - this also keeps track of keys under request from userspace for this UID
+ */
+struct key_user {
+	struct rb_node		node;
+	struct list_head	consq;		/* construction queue */
+	spinlock_t		lock;
+	atomic_t		usage;		/* for accessing qnkeys & qnbytes */
+	atomic_t		nkeys;		/* number of keys */
+	atomic_t		nikeys;		/* number of instantiated keys */
+	uid_t			uid;
+	int			qnkeys;		/* number of keys allocated to this user */
+	int			qnbytes;	/* number of bytes allocated to this user */
+};
+
+#define KEYQUOTA_MAX_KEYS	100
+#define KEYQUOTA_MAX_BYTES	10000
+#define KEYQUOTA_LINK_BYTES	4		/* a link in a keyring is worth 4 bytes */
+
+extern struct rb_root	key_user_tree;
+extern spinlock_t	key_user_lock;
+extern struct key_user	root_key_user;
+
+extern struct key_user *key_user_lookup(uid_t uid);
+extern void key_user_put(struct key_user *user);
+
+
+
+extern struct rb_root key_serial_tree;
+extern spinlock_t key_serial_lock;
+extern struct semaphore key_alloc_sem;
+extern struct rw_semaphore key_construction_sem;
+extern wait_queue_head_t request_key_conswq;
+
+
+extern void keyring_publish_name(struct key *keyring);
+
+extern int __key_link(struct key *keyring, struct key *key);
+
+extern struct key *__keyring_search_one(struct key *keyring,
+					const struct key_type *type,
+					const char *description,
+					key_perm_t perm);
+
+typedef int (*key_match_func_t)(const struct key *, const void *);
+
+extern struct key *keyring_search_aux(struct key *keyring,
+				      struct key_type *type,
+				      const void *description,
+				      key_match_func_t match);
+
+extern struct key *search_process_keyrings_aux(struct key_type *type,
+					       const void *description,
+					       key_match_func_t match);
+
+extern struct key *find_keyring_by_name(const char *name, key_serial_t bound);
+
+extern int install_thread_keyring(struct task_struct *tsk);
+
+/*
+ * keyctl functions
+ */
+extern long keyctl_get_keyring_ID(key_serial_t, int);
+extern long keyctl_join_session_keyring(const char __user *);
+extern long keyctl_update_key(key_serial_t, const void __user *, size_t);
+extern long keyctl_revoke_key(key_serial_t);
+extern long keyctl_keyring_clear(key_serial_t);
+extern long keyctl_keyring_link(key_serial_t, key_serial_t);
+extern long keyctl_keyring_unlink(key_serial_t, key_serial_t);
+extern long keyctl_describe_key(key_serial_t, char __user *, size_t);
+extern long keyctl_keyring_search(key_serial_t, const char __user *,
+				  const char __user *, key_serial_t);
+extern long keyctl_read_key(key_serial_t, char __user *, size_t);
+extern long keyctl_chown_key(key_serial_t, uid_t, gid_t);
+extern long keyctl_setperm_key(key_serial_t, key_perm_t);
+extern long keyctl_instantiate_key(key_serial_t, const void __user *,
+				   size_t, key_serial_t);
+extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t);
+
+
+/*
+ * debugging key validation
+ */
+#ifdef KEY_DEBUGGING
+extern void __key_check(const struct key *);
+
+static inline void key_check(const struct key *key)
+{
+	if (key && (IS_ERR(key) || key->magic != KEY_DEBUG_MAGIC))
+		__key_check(key);
+}
+
+#else
+
+#define key_check(key) do {} while(0)
+
+#endif
+
+#endif /* _INTERNAL_H */
diff -Nru a/security/keys/key.c b/security/keys/key.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/key.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,1039 @@
+/* key.c: basic authentication token and access key management
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+#include <linux/err.h>
+#include "internal.h"
+
+static kmem_cache_t	*key_jar;
+static key_serial_t	key_serial_next = 3;
+struct rb_root		key_serial_tree; /* tree of keys indexed by serial */
+spinlock_t		key_serial_lock = SPIN_LOCK_UNLOCKED;
+
+struct rb_root	key_user_tree; /* tree of quota records indexed by UID */
+spinlock_t	key_user_lock = SPIN_LOCK_UNLOCKED;
+
+static LIST_HEAD(key_types_list);
+static DECLARE_RWSEM(key_types_sem);
+
+static void key_cleanup(void *data);
+static DECLARE_WORK(key_cleanup_task, key_cleanup, NULL);
+
+/* we serialise key instantiation and link */
+DECLARE_RWSEM(key_construction_sem);
+
+/* any key who's type gets unegistered will be re-typed to this */
+struct key_type key_type_dead = {
+	.name		= "dead",
+};
+
+#ifdef KEY_DEBUGGING
+void __key_check(const struct key *key)
+{
+	printk("__key_check: key %p {%08x} should be {%08x}\n",
+	       key, key->magic, KEY_DEBUG_MAGIC);
+	BUG();
+}
+#endif
+
+/*****************************************************************************/
+/*
+ * get the key quota record for a user, allocating a new record if one doesn't
+ * already exist
+ */
+struct key_user *key_user_lookup(uid_t uid)
+{
+	struct key_user *candidate = NULL, *user;
+	struct rb_node *parent = NULL;
+	struct rb_node **p = &key_user_tree.rb_node;
+
+ try_again:
+	spin_lock(&key_user_lock);
+
+	/* search the tree for a user record with a matching UID */
+	while (*p) {
+		parent = *p;
+		user = rb_entry(parent, struct key_user, node);
+
+		if (uid < user->uid)
+			p = &(*p)->rb_left;
+		else if (uid > user->uid)
+			p = &(*p)->rb_right;
+		else
+			goto found;
+	}
+
+	/* if we get here, we failed to find a match in the tree */
+	if (!candidate) {
+		/* allocate a candidate user record if we don't already have
+		 * one */
+		spin_unlock(&key_user_lock);
+
+		user = NULL;
+		candidate = kmalloc(sizeof(struct key_user), GFP_KERNEL);
+		if (unlikely(!candidate))
+			goto out;
+
+		/* the allocation may have scheduled, so we need to repeat the
+		 * search lest someone else added the record whilst we were
+		 * asleep */
+		goto try_again;
+	}
+
+	/* if we get here, then the user record still hadn't appeared on the
+	 * second pass - so we use the candidate record */
+	atomic_set(&candidate->usage, 1);
+	atomic_set(&candidate->nkeys, 0);
+	atomic_set(&candidate->nikeys, 0);
+	candidate->uid = uid;
+	candidate->qnkeys = 0;
+	candidate->qnbytes = 0;
+	spin_lock_init(&candidate->lock);
+	INIT_LIST_HEAD(&candidate->consq);
+
+	rb_link_node(&candidate->node, parent, p);
+	rb_insert_color(&candidate->node, &key_user_tree);
+	spin_unlock(&key_user_lock);
+	user = candidate;
+	goto out;
+
+	/* okay - we found a user record for this UID */
+ found:
+	atomic_inc(&user->usage);
+	spin_unlock(&key_user_lock);
+	if (candidate)
+		kfree(candidate);
+ out:
+	return user;
+
+} /* end key_user_lookup() */
+
+/*****************************************************************************/
+/*
+ * dispose of a user structure
+ */
+void key_user_put(struct key_user *user)
+{
+	if (atomic_dec_and_lock(&user->usage, &key_user_lock)) {
+		rb_erase(&user->node, &key_user_tree);
+		spin_unlock(&key_user_lock);
+
+		kfree(user);
+	}
+
+} /* end key_user_put() */
+
+/*****************************************************************************/
+/*
+ * insert a key with a fixed serial number
+ */
+static void __init __key_insert_serial(struct key *key)
+{
+	struct rb_node *parent, **p;
+	struct key *xkey;
+
+	parent = NULL;
+	p = &key_serial_tree.rb_node;
+
+	while (*p) {
+		parent = *p;
+		xkey = rb_entry(parent, struct key, serial_node);
+
+		if (key->serial < xkey->serial)
+			p = &(*p)->rb_left;
+		else if (key->serial > xkey->serial)
+			p = &(*p)->rb_right;
+		else
+			BUG();
+	}
+
+	/* we've found a suitable hole - arrange for this key to occupy it */
+	rb_link_node(&key->serial_node, parent, p);
+	rb_insert_color(&key->serial_node, &key_serial_tree);
+
+} /* end __key_insert_serial() */
+
+/*****************************************************************************/
+/*
+ * assign a key the next unique serial number
+ * - we work through all the serial numbers between 2 and 2^31-1 in turn and
+ *   then wrap
+ */
+static inline void key_alloc_serial(struct key *key)
+{
+	struct rb_node *parent, **p;
+	struct key *xkey;
+
+	spin_lock(&key_serial_lock);
+
+	/* propose a likely serial number and look for a hole for it in the
+	 * serial number tree */
+	key->serial = key_serial_next;
+	if (key->serial < 3)
+		key->serial = 3;
+	key_serial_next = key->serial + 1;
+
+	parent = NULL;
+	p = &key_serial_tree.rb_node;
+
+	while (*p) {
+		parent = *p;
+		xkey = rb_entry(parent, struct key, serial_node);
+
+		if (key->serial < xkey->serial)
+			p = &(*p)->rb_left;
+		else if (key->serial > xkey->serial)
+			p = &(*p)->rb_right;
+		else
+			goto serial_exists;
+	}
+	goto insert_here;
+
+	/* we found a key with the proposed serial number - walk the tree from
+	 * that point looking for the next unused serial number */
+ serial_exists:
+	for (;;) {
+		key->serial = key_serial_next;
+		if (key->serial < 2)
+			key->serial = 2;
+		key_serial_next = key->serial + 1;
+
+		if (!parent->rb_parent)
+			p = &key_serial_tree.rb_node;
+		else if (parent->rb_parent->rb_left == parent)
+			p = &parent->rb_parent->rb_left;
+		else
+			p = &parent->rb_parent->rb_right;
+
+		parent = rb_next(parent);
+		if (!parent)
+			break;
+
+		xkey = rb_entry(parent, struct key, serial_node);
+		if (key->serial < xkey->serial)
+			goto insert_here;
+	}
+
+	/* we've found a suitable hole - arrange for this key to occupy it */
+ insert_here:
+	rb_link_node(&key->serial_node, parent, p);
+	rb_insert_color(&key->serial_node, &key_serial_tree);
+
+	spin_unlock(&key_serial_lock);
+
+} /* end key_alloc_serial() */
+
+/*****************************************************************************/
+/*
+ * allocate a key of the specified type
+ * - update the user's quota to reflect the existence of the key
+ * - called from a key-type operation with key_types_sem read-locked by either
+ *   key_create_or_update() or by key_duplicate(); this prevents unregistration
+ *   of the key type
+ * - upon return the key is as yet uninstantiated; the caller needs to either
+ *   instantiate the key or discard it before returning
+ */
+struct key *key_alloc(struct key_type *type, const char *desc,
+		      uid_t uid, gid_t gid, key_perm_t perm,
+		      int not_in_quota)
+{
+	struct key_user *user = NULL;
+	struct key *key;
+	size_t desclen, quotalen;
+
+	key = ERR_PTR(-EINVAL);
+	if (!desc || !*desc)
+		goto error;
+
+	desclen = strlen(desc) + 1;
+	quotalen = desclen + type->def_datalen;
+
+	/* get hold of the key tracking for this user */
+	user = key_user_lookup(uid);
+	if (!user)
+		goto no_memory_1;
+
+	/* check that the user's quota permits allocation of another key and
+	 * its description */
+	if (!not_in_quota) {
+		spin_lock(&user->lock);
+		if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS &&
+		    user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES
+		    )
+			goto no_quota;
+
+		user->qnkeys++;
+		user->qnbytes += quotalen;
+		spin_unlock(&user->lock);
+	}
+
+	/* allocate and initialise the key and its description */
+	key = kmem_cache_alloc(key_jar, SLAB_KERNEL);
+	if (!key)
+		goto no_memory_2;
+
+	if (desc) {
+		key->description = kmalloc(desclen, GFP_KERNEL);
+		if (!key->description)
+			goto no_memory_3;
+
+		memcpy(key->description, desc, desclen);
+	}
+
+	atomic_set(&key->usage, 1);
+	rwlock_init(&key->lock);
+	init_rwsem(&key->sem);
+	key->type = type;
+	key->user = user;
+	key->quotalen = quotalen;
+	key->datalen = type->def_datalen;
+	key->uid = uid;
+	key->gid = gid;
+	key->perm = perm;
+	key->flags = 0;
+	key->expiry = 0;
+	key->payload.data = NULL;
+
+	if (!not_in_quota)
+		key->flags |= KEY_FLAG_IN_QUOTA;
+
+	memset(&key->type_data, 0, sizeof(key->type_data));
+
+#ifdef KEY_DEBUGGING
+	key->magic = KEY_DEBUG_MAGIC;
+#endif
+
+	/* publish the key by giving it a serial number */
+	atomic_inc(&user->nkeys);
+	key_alloc_serial(key);
+
+ error:
+	return key;
+
+ no_memory_3:
+	kmem_cache_free(key_jar, key);
+ no_memory_2:
+	if (!not_in_quota) {
+		spin_lock(&user->lock);
+		user->qnkeys--;
+		user->qnbytes -= quotalen;
+		spin_unlock(&user->lock);
+	}
+	key_user_put(user);
+ no_memory_1:
+	key = ERR_PTR(-ENOMEM);
+	goto error;
+
+ no_quota:
+	spin_unlock(&user->lock);
+	key_user_put(user);
+	key = ERR_PTR(-EDQUOT);
+	goto error;
+
+} /* end key_alloc() */
+
+EXPORT_SYMBOL(key_alloc);
+
+/*****************************************************************************/
+/*
+ * reserve an amount of quota for the key's payload
+ */
+int key_payload_reserve(struct key *key, size_t datalen)
+{
+	int delta = (int) datalen - key->datalen;
+	int ret = 0;
+
+	key_check(key);
+
+	/* contemplate the quota adjustment */
+	if (delta != 0 && key->flags & KEY_FLAG_IN_QUOTA) {
+		spin_lock(&key->user->lock);
+
+		if (delta > 0 &&
+		    key->user->qnbytes + delta > KEYQUOTA_MAX_BYTES
+		    ) {
+			ret = -EDQUOT;
+		}
+		else {
+			key->user->qnbytes += delta;
+			key->quotalen += delta;
+		}
+		spin_unlock(&key->user->lock);
+	}
+
+	/* change the recorded data length if that didn't generate an error */
+	if (ret == 0)
+		key->datalen = datalen;
+
+	return ret;
+
+} /* end key_payload_reserve() */
+
+EXPORT_SYMBOL(key_payload_reserve);
+
+/*****************************************************************************/
+/*
+ * instantiate a key and link it into the target keyring atomically
+ * - called with the target keyring's semaphore writelocked
+ */
+static int __key_instantiate_and_link(struct key *key,
+				      const void *data,
+				      size_t datalen,
+				      struct key *keyring)
+{
+	int ret, awaken;
+
+	key_check(key);
+	key_check(keyring);
+
+	awaken = 0;
+	ret = -EBUSY;
+
+	down_write(&key_construction_sem);
+
+	/* can't instantiate twice */
+	if (!(key->flags & KEY_FLAG_INSTANTIATED)) {
+		/* instantiate the key */
+		ret = key->type->instantiate(key, data, datalen);
+
+		if (ret == 0) {
+			/* mark the key as being instantiated */
+			write_lock(&key->lock);
+
+			atomic_inc(&key->user->nikeys);
+			key->flags |= KEY_FLAG_INSTANTIATED;
+
+			if (key->flags & KEY_FLAG_USER_CONSTRUCT) {
+				key->flags &= ~KEY_FLAG_USER_CONSTRUCT;
+				awaken = 1;
+			}
+
+			write_unlock(&key->lock);
+
+			/* and link it into the destination keyring */
+			if (keyring)
+				ret = __key_link(keyring, key);
+		}
+	}
+
+	up_write(&key_construction_sem);
+
+	/* wake up anyone waiting for a key to be constructed */
+	if (awaken)
+		wake_up_all(&request_key_conswq);
+
+	return ret;
+
+} /* end __key_instantiate_and_link() */
+
+/*****************************************************************************/
+/*
+ * instantiate a key and link it into the target keyring atomically
+ */
+int key_instantiate_and_link(struct key *key,
+			     const void *data,
+			     size_t datalen,
+			     struct key *keyring)
+{
+	int ret;
+
+	if (keyring)
+		down_write(&keyring->sem);
+
+	ret = __key_instantiate_and_link(key, data, datalen, keyring);
+
+	if (keyring)
+		up_write(&keyring->sem);
+
+	return ret;
+} /* end key_instantiate_and_link() */
+
+EXPORT_SYMBOL(key_instantiate_and_link);
+
+/*****************************************************************************/
+/*
+ * negatively instantiate a key and link it into the target keyring atomically
+ */
+int key_negate_and_link(struct key *key,
+			unsigned timeout,
+			struct key *keyring)
+{
+	struct timespec now;
+	int ret, awaken;
+
+	key_check(key);
+	key_check(keyring);
+
+	awaken = 0;
+	ret = -EBUSY;
+
+	if (keyring)
+		down_write(&keyring->sem);
+
+	down_write(&key_construction_sem);
+
+	/* can't instantiate twice */
+	if (!(key->flags & KEY_FLAG_INSTANTIATED)) {
+		/* mark the key as being negatively instantiated */
+		write_lock(&key->lock);
+
+		atomic_inc(&key->user->nikeys);
+		key->flags |= KEY_FLAG_INSTANTIATED | KEY_FLAG_NEGATIVE;
+		now = current_kernel_time();
+		key->expiry = now.tv_sec + timeout;
+
+		if (key->flags & KEY_FLAG_USER_CONSTRUCT) {
+			key->flags &= ~KEY_FLAG_USER_CONSTRUCT;
+			awaken = 1;
+		}
+
+		write_unlock(&key->lock);
+		ret = 0;
+
+		/* and link it into the destination keyring */
+		if (keyring)
+			ret = __key_link(keyring, key);
+	}
+
+	up_write(&key_construction_sem);
+
+	if (keyring)
+		up_write(&keyring->sem);
+
+	/* wake up anyone waiting for a key to be constructed */
+	if (awaken)
+		wake_up_all(&request_key_conswq);
+
+	return ret;
+
+} /* end key_negate_and_link() */
+
+EXPORT_SYMBOL(key_negate_and_link);
+
+/*****************************************************************************/
+/*
+ * do cleaning up in process context so that we don't have to disable
+ * interrupts all over the place
+ */
+static void key_cleanup(void *data)
+{
+	struct rb_node *_n;
+	struct key *key;
+
+ go_again:
+	/* look for a dead key in the tree */
+	spin_lock(&key_serial_lock);
+
+	for (_n = rb_first(&key_serial_tree); _n; _n = rb_next(_n)) {
+		key = rb_entry(_n, struct key, serial_node);
+
+		if (atomic_read(&key->usage) == 0)
+			goto found_dead_key;
+	}
+
+	spin_unlock(&key_serial_lock);
+	return;
+
+ found_dead_key:
+	/* we found a dead key - once we've removed it from the tree, we can
+	 * drop the lock */
+	rb_erase(&key->serial_node, &key_serial_tree);
+	spin_unlock(&key_serial_lock);
+
+	/* deal with the user's key tracking and quota */
+	if (key->flags & KEY_FLAG_IN_QUOTA) {
+		spin_lock(&key->user->lock);
+		key->user->qnkeys--;
+		key->user->qnbytes -= key->quotalen;
+		spin_unlock(&key->user->lock);
+	}
+
+	atomic_dec(&key->user->nkeys);
+	if (key->flags & KEY_FLAG_INSTANTIATED)
+		atomic_dec(&key->user->nikeys);
+
+	key_user_put(key->user);
+
+	/* now throw away the key memory */
+	if (key->type->destroy)
+		key->type->destroy(key);
+
+	kfree(key->description);
+
+#ifdef KEY_DEBUGGING
+	key->magic = KEY_DEBUG_MAGIC_X;
+#endif
+	kmem_cache_free(key_jar, key);
+
+	/* there may, of course, be more than one key to destroy */
+	goto go_again;
+
+} /* end key_cleanup() */
+
+/*****************************************************************************/
+/*
+ * dispose of a reference to a key
+ * - when all the references are gone, we schedule the cleanup task to come and
+ *   pull it out of the tree in definite process context
+ */
+void key_put(struct key *key)
+{
+	if (key) {
+		key_check(key);
+
+		if (atomic_dec_and_test(&key->usage))
+			schedule_work(&key_cleanup_task);
+	}
+
+} /* end key_put() */
+
+EXPORT_SYMBOL(key_put);
+
+/*****************************************************************************/
+/*
+ * find a key by its serial number
+ */
+struct key *key_lookup(key_serial_t id)
+{
+	struct rb_node *n;
+	struct key *key;
+
+	spin_lock(&key_serial_lock);
+
+	/* search the tree for the specified key */
+	n = key_serial_tree.rb_node;
+	while (n) {
+		key = rb_entry(n, struct key, serial_node);
+
+		if (id < key->serial)
+			n = n->rb_left;
+		else if (id > key->serial)
+			n = n->rb_right;
+		else
+			goto found;
+	}
+
+ not_found:
+	key = ERR_PTR(-ENOKEY);
+	goto error;
+
+ found:
+	/* pretent doesn't exist if it's dead */
+	if (atomic_read(&key->usage) == 0 ||
+	    (key->flags & KEY_FLAG_DEAD) ||
+	    key->type == &key_type_dead)
+		goto not_found;
+
+	/* this races with key_put(), but that doesn't matter since key_put()
+	 * doesn't actually change the key
+	 */
+	atomic_inc(&key->usage);
+
+ error:
+	spin_unlock(&key_serial_lock);
+	return key;
+
+} /* end key_lookup() */
+
+/*****************************************************************************/
+/*
+ * find and lock the specified key type against removal
+ * - we return with the sem readlocked
+ */
+struct key_type *key_type_lookup(const char *type)
+{
+	struct key_type *ktype;
+
+	down_read(&key_types_sem);
+
+	/* look up the key type to see if it's one of the registered kernel
+	 * types */
+	list_for_each_entry(ktype, &key_types_list, link) {
+		if (strcmp(ktype->name, type) == 0)
+			goto found_kernel_type;
+	}
+
+	up_read(&key_types_sem);
+	ktype = ERR_PTR(-ENOKEY);
+
+ found_kernel_type:
+	return ktype;
+
+} /* end key_type_lookup() */
+
+/*****************************************************************************/
+/*
+ * unlock a key type
+ */
+void key_type_put(struct key_type *ktype)
+{
+	up_read(&key_types_sem);
+
+} /* end key_type_put() */
+
+/*****************************************************************************/
+/*
+ * attempt to update an existing key
+ * - the key has an incremented refcount
+ * - we need to put the key if we get an error
+ */
+static inline struct key *__key_update(struct key *key, const void *payload,
+				       size_t plen)
+{
+	int ret;
+
+	/* need write permission on the key to update it */
+	ret = -EACCES;
+	if (!key_permission(key, KEY_WRITE))
+		goto error;
+
+	ret = -EEXIST;
+	if (!key->type->update)
+		goto error;
+
+	down_write(&key->sem);
+
+	ret = key->type->update(key, payload, plen);
+
+	if (ret == 0) {
+		/* updating a negative key instantiates it */
+		write_lock(&key->lock);
+		key->flags &= ~KEY_FLAG_NEGATIVE;
+		write_unlock(&key->lock);
+	}
+
+	up_write(&key->sem);
+
+	if (ret < 0)
+		goto error;
+ out:
+	return key;
+
+ error:
+	key_put(key);
+	key = ERR_PTR(ret);
+	goto out;
+
+} /* end __key_update() */
+
+/*****************************************************************************/
+/*
+ * search the specified keyring for a key of the same description; if one is
+ * found, update it, otherwise add a new one
+ */
+struct key *key_create_or_update(struct key *keyring,
+				 const char *type,
+				 const char *description,
+				 const void *payload,
+				 size_t plen,
+				 int not_in_quota)
+{
+	struct key_type *ktype;
+	struct key *key = NULL;
+	key_perm_t perm;
+	int ret;
+
+	key_check(keyring);
+
+	/* look up the key type to see if it's one of the registered kernel
+	 * types */
+	ktype = key_type_lookup(type);
+	if (IS_ERR(ktype)) {
+		key = ERR_PTR(-ENODEV);
+		goto error;
+	}
+
+	ret = -EINVAL;
+	if (!ktype->match || !ktype->instantiate)
+		goto error_2;
+
+	/* search for an existing key of the same type and description in the
+	 * destination keyring
+	 */
+	down_write(&keyring->sem);
+
+	key = __keyring_search_one(keyring, ktype, description, 0);
+	if (!IS_ERR(key))
+		goto found_matching_key;
+
+	/* if we're going to allocate a new key, we're going to have to modify
+	 * the keyring */
+	ret = -EACCES;
+	if (!key_permission(keyring, KEY_WRITE))
+		goto error_3;
+
+	/* decide on the permissions we want */
+	perm = KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK;
+
+	if (ktype->read)
+		perm |= KEY_USR_READ;
+
+	if (ktype == &key_type_keyring || ktype->update)
+		perm |= KEY_USR_WRITE;
+
+	/* allocate a new key */
+	key = key_alloc(ktype, description, current->fsuid, current->fsgid,
+			perm, not_in_quota);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error_3;
+	}
+
+	/* instantiate it and link it into the target keyring */
+	ret = __key_instantiate_and_link(key, payload, plen, keyring);
+	if (ret < 0) {
+		key_put(key);
+		key = ERR_PTR(ret);
+	}
+
+ error_3:
+	up_write(&keyring->sem);
+ error_2:
+	key_type_put(ktype);
+ error:
+	return key;
+
+ found_matching_key:
+	/* we found a matching key, so we're going to try to update it
+	 * - we can drop the locks first as we have the key pinned
+	 */
+	up_write(&keyring->sem);
+	key_type_put(ktype);
+
+	key = __key_update(key, payload, plen);
+	goto error;
+
+} /* end key_create_or_update() */
+
+EXPORT_SYMBOL(key_create_or_update);
+
+/*****************************************************************************/
+/*
+ * update a key
+ */
+int key_update(struct key *key, const void *payload, size_t plen)
+{
+	int ret;
+
+	key_check(key);
+
+	/* the key must be writable */
+	ret = -EACCES;
+	if (!key_permission(key, KEY_WRITE))
+		goto error;
+
+	/* attempt to update it if supported */
+	ret = -EOPNOTSUPP;
+	if (key->type->update) {
+		down_write(&key->sem);
+		ret = key->type->update(key, payload, plen);
+
+		if (ret == 0) {
+			/* updating a negative key instantiates it */
+			write_lock(&key->lock);
+			key->flags &= ~KEY_FLAG_NEGATIVE;
+			write_unlock(&key->lock);
+		}
+
+		up_write(&key->sem);
+	}
+
+ error:
+	return ret;
+
+} /* end key_update() */
+
+EXPORT_SYMBOL(key_update);
+
+/*****************************************************************************/
+/*
+ * duplicate a key, potentially with a revised description
+ * - must be supported by the keytype (keyrings for instance can be duplicated)
+ */
+struct key *key_duplicate(struct key *source, const char *desc)
+{
+	struct key *key;
+	int ret;
+
+	key_check(source);
+
+	if (!desc)
+		desc = source->description;
+
+	down_read(&key_types_sem);
+
+	ret = -EINVAL;
+	if (!source->type->duplicate)
+		goto error;
+
+	/* allocate and instantiate a key */
+	key = key_alloc(source->type, desc, current->fsuid, current->fsgid,
+			source->perm, 0);
+	if (IS_ERR(key))
+		goto error_k;
+
+	down_read(&source->sem);
+	ret = key->type->duplicate(key, source);
+	up_read(&source->sem);
+	if (ret < 0)
+		goto error2;
+
+	atomic_inc(&key->user->nikeys);
+
+	write_lock(&key->lock);
+	key->flags |= KEY_FLAG_INSTANTIATED;
+	write_unlock(&key->lock);
+
+ error_k:
+	up_read(&key_types_sem);
+ out:
+	return key;
+
+ error2:
+	key_put(key);
+ error:
+	up_read(&key_types_sem);
+	key = ERR_PTR(ret);
+	goto out;
+
+} /* end key_duplicate() */
+
+/*****************************************************************************/
+/*
+ * revoke a key
+ */
+void key_revoke(struct key *key)
+{
+	key_check(key);
+
+	/* make sure no one's trying to change or use the key when we mark
+	 * it */
+	down_write(&key->sem);
+	write_lock(&key->lock);
+	key->flags |= KEY_FLAG_REVOKED;
+	write_unlock(&key->lock);
+	up_write(&key->sem);
+
+} /* end key_revoke() */
+
+EXPORT_SYMBOL(key_revoke);
+
+/*****************************************************************************/
+/*
+ * register a type of key
+ */
+int register_key_type(struct key_type *ktype)
+{
+	struct key_type *p;
+	int ret;
+
+	ret = -EEXIST;
+	down_write(&key_types_sem);
+
+	/* disallow key types with the same name */
+	list_for_each_entry(p, &key_types_list, link) {
+		if (strcmp(p->name, ktype->name) == 0)
+			goto out;
+	}
+
+	/* store the type */
+	list_add(&ktype->link, &key_types_list);
+	ret = 0;
+
+ out:
+	up_write(&key_types_sem);
+	return ret;
+
+} /* end register_key_type() */
+
+EXPORT_SYMBOL(register_key_type);
+
+/*****************************************************************************/
+/*
+ * unregister a type of key
+ */
+void unregister_key_type(struct key_type *ktype)
+{
+	struct rb_node *_n;
+	struct key *key;
+
+	down_write(&key_types_sem);
+
+	/* withdraw the key type */
+	list_del_init(&ktype->link);
+
+	/* need to withdraw all keys of this type */
+	spin_lock(&key_serial_lock);
+
+	for (_n = rb_first(&key_serial_tree); _n; _n = rb_next(_n)) {
+		key = rb_entry(_n, struct key, serial_node);
+
+		if (key->type != ktype)
+			continue;
+
+		write_lock(&key->lock);
+		key->type = &key_type_dead;
+		write_unlock(&key->lock);
+
+		/* there shouldn't be anyone looking at the description or
+		 * payload now */
+		if (ktype->destroy)
+			ktype->destroy(key);
+		memset(&key->payload, 0xbd, sizeof(key->payload));
+	}
+
+	spin_unlock(&key_serial_lock);
+	up_write(&key_types_sem);
+
+} /* end unregister_key_type() */
+
+EXPORT_SYMBOL(unregister_key_type);
+
+/*****************************************************************************/
+/*
+ * initialise the key management stuff
+ */
+void __init key_init(void)
+{
+	/* allocate a slab in which we can store keys */
+	key_jar = kmem_cache_create("key_jar", sizeof(struct key),
+			0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
+
+	/* add the special key types */
+	list_add_tail(&key_type_keyring.link, &key_types_list);
+	list_add_tail(&key_type_dead.link, &key_types_list);
+	list_add_tail(&key_type_user.link, &key_types_list);
+
+	/* record the root user tracking */
+	rb_link_node(&root_key_user.node,
+		     NULL,
+		     &key_user_tree.rb_node);
+
+	rb_insert_color(&root_key_user.node,
+			&key_user_tree);
+
+	/* record root's user standard keyrings */
+	key_check(&root_user_keyring);
+	key_check(&root_session_keyring);
+
+	__key_insert_serial(&root_user_keyring);
+	__key_insert_serial(&root_session_keyring);
+
+	keyring_publish_name(&root_user_keyring);
+	keyring_publish_name(&root_session_keyring);
+
+	/* link the two root keyrings together */
+	key_link(&root_session_keyring, &root_user_keyring);
+} /* end key_init() */
diff -Nru a/security/keys/keyctl.c b/security/keys/keyctl.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/keyctl.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,987 @@
+/* keyctl.c: userspace keyctl operations
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/syscalls.h>
+#include <linux/keyctl.h>
+#include <linux/fs.h>
+#include <linux/err.h>
+#include <asm/uaccess.h>
+#include "internal.h"
+
+/*****************************************************************************/
+/*
+ * extract the description of a new key from userspace and either add it as a
+ * new key to the specified keyring or update a matching key in that keyring
+ * - the keyring must be writable
+ * - returns the new key's serial number
+ * - implements add_key()
+ */
+asmlinkage long sys_add_key(const char __user *_type,
+			    const char __user *_description,
+			    const void __user *_payload,
+			    size_t plen,
+			    key_serial_t ringid)
+{
+	struct key *keyring, *key;
+	char type[32], *description;
+	void *payload;
+	long dlen, ret;
+
+	ret = -EINVAL;
+	if (plen > 32767)
+		goto error;
+
+	/* draw all the data into kernel space */
+	ret = strncpy_from_user(type, _type, sizeof(type) - 1);
+	if (ret < 0)
+		goto error;
+	type[31] = '\0';
+
+	ret = -EFAULT;
+	dlen = strnlen_user(_description, PAGE_SIZE - 1);
+	if (dlen <= 0)
+		goto error;
+
+	ret = -EINVAL;
+	if (dlen > PAGE_SIZE - 1)
+		goto error;
+
+	ret = -ENOMEM;
+	description = kmalloc(dlen + 1, GFP_KERNEL);
+	if (!description)
+		goto error;
+
+	ret = -EFAULT;
+	if (copy_from_user(description, _description, dlen + 1) != 0)
+		goto error2;
+
+	/* pull the payload in if one was supplied */
+	payload = NULL;
+
+	if (_payload) {
+		ret = -ENOMEM;
+		payload = kmalloc(plen, GFP_KERNEL);
+		if (!payload)
+			goto error2;
+
+		ret = -EFAULT;
+		if (copy_from_user(payload, _payload, plen) != 0)
+			goto error3;
+	}
+
+	/* find the target keyring (which must be writable) */
+	keyring = lookup_user_key(ringid, 1, 0, KEY_WRITE);
+	if (IS_ERR(keyring)) {
+		ret = PTR_ERR(keyring);
+		goto error3;
+	}
+
+	/* create or update the requested key and add it to the target
+	 * keyring */
+	key = key_create_or_update(keyring, type, description,
+				   payload, plen, 0);
+	if (!IS_ERR(key)) {
+		ret = key->serial;
+		key_put(key);
+	}
+	else {
+		ret = PTR_ERR(key);
+	}
+
+	key_put(keyring);
+ error3:
+	kfree(payload);
+ error2:
+	kfree(description);
+ error:
+	return ret;
+
+} /* end sys_add_key() */
+
+/*****************************************************************************/
+/*
+ * search the process keyrings for a matching key
+ * - nested keyrings may also be searched if they have Search permission
+ * - if a key is found, it will be attached to the destination keyring if
+ *   there's one specified
+ * - /sbin/request-key will be invoked if _callout_info is non-NULL
+ *   - the _callout_info string will be passed to /sbin/request-key
+ *   - if the _callout_info string is empty, it will be rendered as "-"
+ * - implements request_key()
+ */
+asmlinkage long sys_request_key(const char __user *_type,
+				const char __user *_description,
+				const char __user *_callout_info,
+				key_serial_t destringid)
+{
+	struct key_type *ktype;
+	struct key *key, *dest;
+	char type[32], *description, *callout_info;
+	long dlen, ret;
+
+	/* pull the type into kernel space */
+	ret = strncpy_from_user(type, _type, sizeof(type) - 1);
+	if (ret < 0)
+		goto error;
+	type[31] = '\0';
+
+	/* pull the description into kernel space */
+	ret = -EFAULT;
+	dlen = strnlen_user(_description, PAGE_SIZE - 1);
+	if (dlen <= 0)
+		goto error;
+
+	ret = -EINVAL;
+	if (dlen > PAGE_SIZE - 1)
+		goto error;
+
+	ret = -ENOMEM;
+	description = kmalloc(dlen + 1, GFP_KERNEL);
+	if (!description)
+		goto error;
+
+	ret = -EFAULT;
+	if (copy_from_user(description, _description, dlen + 1) != 0)
+		goto error2;
+
+	/* pull the callout info into kernel space */
+	callout_info = NULL;
+	if (_callout_info) {
+		ret = -EFAULT;
+		dlen = strnlen_user(_callout_info, PAGE_SIZE - 1);
+		if (dlen <= 0)
+			goto error2;
+
+		ret = -EINVAL;
+		if (dlen > PAGE_SIZE - 1)
+			goto error2;
+
+		ret = -ENOMEM;
+		callout_info = kmalloc(dlen + 1, GFP_KERNEL);
+		if (!callout_info)
+			goto error2;
+
+		ret = -EFAULT;
+		if (copy_from_user(callout_info, _callout_info, dlen + 1) != 0)
+			goto error3;
+	}
+
+	/* get the destination keyring if specified */
+	dest = NULL;
+	if (destringid) {
+		dest = lookup_user_key(destringid, 1, 0, KEY_WRITE);
+		if (IS_ERR(dest)) {
+			ret = PTR_ERR(dest);
+			goto error3;
+		}
+	}
+
+	/* find the key type */
+	ktype = key_type_lookup(type);
+	if (IS_ERR(ktype)) {
+		ret = PTR_ERR(ktype);
+		goto error4;
+	}
+
+	/* do the search */
+	key = request_key(ktype, description, callout_info);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error5;
+	}
+
+	/* link the resulting key to the destination keyring */
+	if (dest) {
+		ret = key_link(dest, key);
+		if (ret < 0)
+			goto error6;
+	}
+
+	ret = key->serial;
+
+ error6:
+	key_put(key);
+ error5:
+	key_type_put(ktype);
+ error4:
+	key_put(dest);
+ error3:
+	kfree(callout_info);
+ error2:
+	kfree(description);
+ error:
+	return ret;
+
+} /* end sys_request_key() */
+
+/*****************************************************************************/
+/*
+ * get the ID of the specified process keyring
+ * - the keyring must have search permission to be found
+ * - implements keyctl(KEYCTL_GET_KEYRING_ID)
+ */
+long keyctl_get_keyring_ID(key_serial_t id, int create)
+{
+	struct key *key;
+	long ret;
+
+	key = lookup_user_key(id, create, 0, KEY_SEARCH);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error;
+	}
+
+	ret = key->serial;
+	key_put(key);
+ error:
+	return ret;
+
+} /* end keyctl_get_keyring_ID() */
+
+/*****************************************************************************/
+/*
+ * join the session keyring
+ * - implements keyctl(KEYCTL_JOIN_SESSION_KEYRING)
+ */
+long keyctl_join_session_keyring(const char __user *_name)
+{
+	char *name;
+	long nlen, ret;
+
+	/* fetch the name from userspace */
+	name = NULL;
+	if (_name) {
+		ret = -EFAULT;
+		nlen = strnlen_user(_name, PAGE_SIZE - 1);
+		if (nlen <= 0)
+			goto error;
+
+		ret = -EINVAL;
+		if (nlen > PAGE_SIZE - 1)
+			goto error;
+
+		ret = -ENOMEM;
+		name = kmalloc(nlen + 1, GFP_KERNEL);
+		if (!name)
+			goto error;
+
+		ret = -EFAULT;
+		if (copy_from_user(name, _name, nlen + 1) != 0)
+			goto error2;
+	}
+
+	/* join the session */
+	ret = join_session_keyring(name);
+
+ error2:
+	kfree(name);
+ error:
+	return ret;
+
+} /* end keyctl_join_session_keyring() */
+
+/*****************************************************************************/
+/*
+ * update a key's data payload
+ * - the key must be writable
+ * - implements keyctl(KEYCTL_UPDATE)
+ */
+long keyctl_update_key(key_serial_t id,
+		       const void __user *_payload,
+		       size_t plen)
+{
+	struct key *key;
+	void *payload;
+	long ret;
+
+	ret = -EINVAL;
+	if (plen > PAGE_SIZE)
+		goto error;
+
+	/* pull the payload in if one was supplied */
+	payload = NULL;
+	if (_payload) {
+		ret = -ENOMEM;
+		payload = kmalloc(plen, GFP_KERNEL);
+		if (!payload)
+			goto error;
+
+		ret = -EFAULT;
+		if (copy_from_user(payload, _payload, plen) != 0)
+			goto error2;
+	}
+
+	/* find the target key (which must be writable) */
+	key = lookup_user_key(id, 0, 0, KEY_WRITE);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error2;
+	}
+
+	/* update the key */
+	ret = key_update(key, payload, plen);
+
+	key_put(key);
+ error2:
+	kfree(payload);
+ error:
+	return ret;
+
+} /* end keyctl_update_key() */
+
+/*****************************************************************************/
+/*
+ * revoke a key
+ * - the key must be writable
+ * - implements keyctl(KEYCTL_REVOKE)
+ */
+long keyctl_revoke_key(key_serial_t id)
+{
+	struct key *key;
+	long ret;
+
+	key = lookup_user_key(id, 0, 0, KEY_WRITE);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error;
+	}
+
+	key_revoke(key);
+	ret = 0;
+
+	key_put(key);
+ error:
+	return 0;
+
+} /* end keyctl_revoke_key() */
+
+/*****************************************************************************/
+/*
+ * clear the specified process keyring
+ * - the keyring must be writable
+ * - implements keyctl(KEYCTL_CLEAR)
+ */
+long keyctl_keyring_clear(key_serial_t ringid)
+{
+	struct key *keyring;
+	long ret;
+
+	keyring = lookup_user_key(ringid, 1, 0, KEY_WRITE);
+	if (IS_ERR(keyring)) {
+		ret = PTR_ERR(keyring);
+		goto error;
+	}
+
+	ret = keyring_clear(keyring);
+
+	key_put(keyring);
+ error:
+	return ret;
+
+} /* end keyctl_keyring_clear() */
+
+/*****************************************************************************/
+/*
+ * link a key into a keyring
+ * - the keyring must be writable
+ * - the key must be linkable
+ * - implements keyctl(KEYCTL_LINK)
+ */
+long keyctl_keyring_link(key_serial_t id, key_serial_t ringid)
+{
+	struct key *keyring, *key;
+	long ret;
+
+	keyring = lookup_user_key(ringid, 1, 0, KEY_WRITE);
+	if (IS_ERR(keyring)) {
+		ret = PTR_ERR(keyring);
+		goto error;
+	}
+
+	key = lookup_user_key(id, 1, 0, KEY_LINK);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error2;
+	}
+
+	ret = key_link(keyring, key);
+
+	key_put(key);
+ error2:
+	key_put(keyring);
+ error:
+	return ret;
+
+} /* end keyctl_keyring_link() */
+
+/*****************************************************************************/
+/*
+ * unlink the first attachment of a key from a keyring
+ * - the keyring must be writable
+ * - we don't need any permissions on the key
+ * - implements keyctl(KEYCTL_UNLINK)
+ */
+long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid)
+{
+	struct key *keyring, *key;
+	long ret;
+
+	keyring = lookup_user_key(ringid, 0, 0, KEY_WRITE);
+	if (IS_ERR(keyring)) {
+		ret = PTR_ERR(keyring);
+		goto error;
+	}
+
+	key = lookup_user_key(id, 0, 0, 0);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error2;
+	}
+
+	ret = key_unlink(keyring, key);
+
+	key_put(key);
+ error2:
+	key_put(keyring);
+ error:
+	return ret;
+
+} /* end keyctl_keyring_unlink() */
+
+/*****************************************************************************/
+/*
+ * describe a user key
+ * - the key must have view permission
+ * - if there's a buffer, we place up to buflen bytes of data into it
+ * - unless there's an error, we return the amount of description available,
+ *   irrespective of how much we may have copied
+ * - the description is formatted thus:
+ *	type;uid;gid;perm;description<NUL>
+ * - implements keyctl(KEYCTL_DESCRIBE)
+ */
+long keyctl_describe_key(key_serial_t keyid,
+			 char __user *buffer,
+			 size_t buflen)
+{
+	struct key *key;
+	char *tmpbuf;
+	long ret;
+
+	key = lookup_user_key(keyid, 0, 1, KEY_VIEW);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error;
+	}
+
+	/* calculate how much description we're going to return */
+	ret = -ENOMEM;
+	tmpbuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!tmpbuf)
+		goto error2;
+
+	ret = snprintf(tmpbuf, PAGE_SIZE - 1,
+		       "%s;%d;%d;%06x;%s",
+		       key->type->name,
+		       key->uid,
+		       key->gid,
+		       key->perm,
+		       key->description ? key->description :""
+		       );
+
+	/* include a NUL char at the end of the data */
+	if (ret > PAGE_SIZE - 1)
+		ret = PAGE_SIZE - 1;
+	tmpbuf[ret] = 0;
+	ret++;
+
+	/* consider returning the data */
+	if (buffer && buflen > 0) {
+		if (buflen > ret)
+			buflen = ret;
+
+		if (copy_to_user(buffer, tmpbuf, buflen) != 0)
+			ret = -EFAULT;
+	}
+
+	kfree(tmpbuf);
+ error2:
+	key_put(key);
+ error:
+	return ret;
+
+} /* end keyctl_describe_key() */
+
+/*****************************************************************************/
+/*
+ * search the specified keyring for a matching key
+ * - the start keyring must be searchable
+ * - nested keyrings may also be searched if they are searchable
+ * - only keys with search permission may be found
+ * - if a key is found, it will be attached to the destination keyring if
+ *   there's one specified
+ * - implements keyctl(KEYCTL_SEARCH)
+ */
+long keyctl_keyring_search(key_serial_t ringid,
+			   const char __user *_type,
+			   const char __user *_description,
+			   key_serial_t destringid)
+{
+	struct key_type *ktype;
+	struct key *keyring, *key, *dest;
+	char type[32], *description;
+	long dlen, ret;
+
+	/* pull the type and description into kernel space */
+	ret = strncpy_from_user(type, _type, sizeof(type) - 1);
+	if (ret < 0)
+		goto error;
+	type[31] = '\0';
+
+	ret = -EFAULT;
+	dlen = strnlen_user(_description, PAGE_SIZE - 1);
+	if (dlen <= 0)
+		goto error;
+
+	ret = -EINVAL;
+	if (dlen > PAGE_SIZE - 1)
+		goto error;
+
+	ret = -ENOMEM;
+	description = kmalloc(dlen + 1, GFP_KERNEL);
+	if (!description)
+		goto error;
+
+	ret = -EFAULT;
+	if (copy_from_user(description, _description, dlen + 1) != 0)
+		goto error2;
+
+	/* get the keyring at which to begin the search */
+	keyring = lookup_user_key(ringid, 0, 0, KEY_SEARCH);
+	if (IS_ERR(keyring)) {
+		ret = PTR_ERR(keyring);
+		goto error2;
+	}
+
+	/* get the destination keyring if specified */
+	dest = NULL;
+	if (destringid) {
+		dest = lookup_user_key(destringid, 1, 0, KEY_WRITE);
+		if (IS_ERR(dest)) {
+			ret = PTR_ERR(dest);
+			goto error3;
+		}
+	}
+
+	/* find the key type */
+	ktype = key_type_lookup(type);
+	if (IS_ERR(ktype)) {
+		ret = PTR_ERR(ktype);
+		goto error4;
+	}
+
+	/* do the search */
+	key = keyring_search(keyring, ktype, description);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+
+		/* treat lack or presence of a negative key the same */
+		if (ret == -EAGAIN)
+			ret = -ENOKEY;
+		goto error5;
+	}
+
+	/* link the resulting key to the destination keyring if we can */
+	if (dest) {
+		ret = -EACCES;
+		if (!key_permission(key, KEY_LINK))
+			goto error6;
+
+		ret = key_link(dest, key);
+		if (ret < 0)
+			goto error6;
+	}
+
+	ret = key->serial;
+
+ error6:
+	key_put(key);
+ error5:
+	key_type_put(ktype);
+ error4:
+	key_put(dest);
+ error3:
+	key_put(keyring);
+ error2:
+	kfree(description);
+ error:
+	return ret;
+
+} /* end keyctl_keyring_search() */
+
+/*****************************************************************************/
+/*
+ * see if the key we're looking at is the target key
+ */
+static int keyctl_read_key_same(const struct key *key, const void *target)
+{
+	return key == target;
+
+} /* end keyctl_read_key_same() */
+
+/*****************************************************************************/
+/*
+ * read a user key's payload
+ * - the keyring must be readable or the key must be searchable from the
+ *   process's keyrings
+ * - if there's a buffer, we place up to buflen bytes of data into it
+ * - unless there's an error, we return the amount of data in the key,
+ *   irrespective of how much we may have copied
+ * - implements keyctl(KEYCTL_READ)
+ */
+long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
+{
+	struct key *key, *skey;
+	long ret;
+
+	/* find the key first */
+	key = lookup_user_key(keyid, 0, 0, 0);
+	if (!IS_ERR(key)) {
+		/* see if we can read it directly */
+		if (key_permission(key, KEY_READ))
+			goto can_read_key;
+
+		/* can't; see if it's searchable from this process's
+		 * keyrings */
+		ret = -ENOKEY;
+		if (key_permission(key, KEY_SEARCH)) {
+			/* okay - we do have search permission on the key
+			 * itself, but do we have the key? */
+			skey = search_process_keyrings_aux(key->type, key,
+							   keyctl_read_key_same);
+			if (!IS_ERR(skey))
+				goto can_read_key2;
+		}
+
+		goto error2;
+	}
+
+	ret = -ENOKEY;
+	goto error;
+
+	/* the key is probably readable - now try to read it */
+ can_read_key2:
+	key_put(skey);
+ can_read_key:
+	ret = key_validate(key);
+	if (ret == 0) {
+		ret = -EOPNOTSUPP;
+		if (key->type->read) {
+			/* read the data with the semaphore held (since we
+			 * might sleep) */
+			down_read(&key->sem);
+			ret = key->type->read(key, buffer, buflen);
+			up_read(&key->sem);
+		}
+	}
+
+ error2:
+	key_put(key);
+ error:
+	return ret;
+
+} /* end keyctl_read_key() */
+
+/*****************************************************************************/
+/*
+ * change the ownership of a key
+ * - the keyring owned by the changer
+ * - if the uid or gid is -1, then that parameter is not changed
+ * - implements keyctl(KEYCTL_CHOWN)
+ */
+long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid)
+{
+	struct key *key;
+	long ret;
+
+	ret = 0;
+	if (uid == (uid_t) -1 && gid == (gid_t) -1)
+		goto error;
+
+	key = lookup_user_key(id, 1, 1, 0);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error;
+	}
+
+	/* make the changes with the locks held to prevent chown/chown races */
+	ret = -EACCES;
+	down_write(&key->sem);
+	write_lock(&key->lock);
+
+	if (!capable(CAP_SYS_ADMIN)) {
+		/* only the sysadmin can chown a key to some other UID */
+		if (uid != (uid_t) -1 && key->uid != uid)
+			goto no_access;
+
+		/* only the sysadmin can set the key's GID to a group other
+		 * than one of those that the current process subscribes to */
+		if (gid != (gid_t) -1 && gid != key->gid && !in_group_p(gid))
+			goto no_access;
+	}
+
+	/* change the UID (have to update the quotas) */
+	if (uid != (uid_t) -1 && uid != key->uid) {
+		/* don't support UID changing yet */
+		ret = -EOPNOTSUPP;
+		goto no_access;
+	}
+
+	/* change the GID */
+	if (gid != (gid_t) -1)
+		key->gid = gid;
+
+	ret = 0;
+
+ no_access:
+	write_unlock(&key->lock);
+	up_write(&key->sem);
+	key_put(key);
+ error:
+	return ret;
+
+} /* end keyctl_chown_key() */
+
+/*****************************************************************************/
+/*
+ * change the permission mask on a key
+ * - the keyring owned by the changer
+ * - implements keyctl(KEYCTL_SETPERM)
+ */
+long keyctl_setperm_key(key_serial_t id, key_perm_t perm)
+{
+	struct key *key;
+	long ret;
+
+	ret = -EINVAL;
+	if (perm & ~(KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL))
+		goto error;
+
+	key = lookup_user_key(id, 1, 1, 0);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error;
+	}
+
+	/* make the changes with the locks held to prevent chown/chmod
+	 * races */
+	ret = -EACCES;
+	down_write(&key->sem);
+	write_lock(&key->lock);
+
+	/* if we're not the sysadmin, we can only chmod a key that we
+	 * own */
+	if (!capable(CAP_SYS_ADMIN) && key->uid != current->fsuid)
+		goto no_access;
+
+	/* changing the permissions mask */
+	key->perm = perm;
+	ret = 0;
+
+ no_access:
+	write_unlock(&key->lock);
+	up_write(&key->sem);
+	key_put(key);
+ error:
+	return ret;
+
+} /* end keyctl_setperm_key() */
+
+/*****************************************************************************/
+/*
+ * instantiate the key with the specified payload, and, if one is given, link
+ * the key into the keyring
+ */
+long keyctl_instantiate_key(key_serial_t id,
+			    const void __user *_payload,
+			    size_t plen,
+			    key_serial_t ringid)
+{
+	struct key *key, *keyring;
+	void *payload;
+	long ret;
+
+	ret = -EINVAL;
+	if (plen > 32767)
+		goto error;
+
+	/* pull the payload in if one was supplied */
+	payload = NULL;
+
+	if (_payload) {
+		ret = -ENOMEM;
+		payload = kmalloc(plen, GFP_KERNEL);
+		if (!payload)
+			goto error;
+
+		ret = -EFAULT;
+		if (copy_from_user(payload, _payload, plen) != 0)
+			goto error2;
+	}
+
+	/* find the target key (which must be writable) */
+	key = lookup_user_key(id, 0, 1, KEY_WRITE);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error2;
+	}
+
+	/* find the destination keyring if present (which must also be
+	 * writable) */
+	keyring = NULL;
+	if (ringid) {
+		keyring = lookup_user_key(ringid, 1, 0, KEY_WRITE);
+		if (IS_ERR(keyring)) {
+			ret = PTR_ERR(keyring);
+			goto error3;
+		}
+	}
+
+	/* instantiate the key and link it into a keyring */
+	ret = key_instantiate_and_link(key, payload, plen, keyring);
+
+	key_put(keyring);
+ error3:
+	key_put(key);
+ error2:
+	kfree(payload);
+ error:
+	return ret;
+
+} /* end keyctl_instantiate_key() */
+
+/*****************************************************************************/
+/*
+ * negatively instantiate the key with the given timeout (in seconds), and, if
+ * one is given, link the key into the keyring
+ */
+long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid)
+{
+	struct key *key, *keyring;
+	long ret;
+
+	/* find the target key (which must be writable) */
+	key = lookup_user_key(id, 0, 1, KEY_WRITE);
+	if (IS_ERR(key)) {
+		ret = PTR_ERR(key);
+		goto error;
+	}
+
+	/* find the destination keyring if present (which must also be
+	 * writable) */
+	keyring = NULL;
+	if (ringid) {
+		keyring = lookup_user_key(ringid, 1, 0, KEY_WRITE);
+		if (IS_ERR(keyring)) {
+			ret = PTR_ERR(keyring);
+			goto error2;
+		}
+	}
+
+	/* instantiate the key and link it into a keyring */
+	ret = key_negate_and_link(key, timeout, keyring);
+
+	key_put(keyring);
+ error2:
+	key_put(key);
+ error:
+	return ret;
+
+} /* end keyctl_negate_key() */
+
+/*****************************************************************************/
+/*
+ * the key control system call
+ */
+asmlinkage long sys_keyctl(int option, unsigned long arg2, unsigned long arg3,
+			   unsigned long arg4, unsigned long arg5)
+{
+	switch (option) {
+	case KEYCTL_GET_KEYRING_ID:
+		return keyctl_get_keyring_ID((key_serial_t) arg2,
+					     (int) arg3);
+
+	case KEYCTL_JOIN_SESSION_KEYRING:
+		return keyctl_join_session_keyring((const char __user *) arg3);
+
+	case KEYCTL_UPDATE:
+		return keyctl_update_key((key_serial_t) arg2,
+					 (const void __user *) arg3,
+					 (size_t) arg4);
+
+	case KEYCTL_REVOKE:
+		return keyctl_revoke_key((key_serial_t) arg2);
+
+	case KEYCTL_DESCRIBE:
+		return keyctl_describe_key((key_serial_t) arg2,
+					   (char __user *) arg3,
+					   (unsigned) arg4);
+
+	case KEYCTL_CLEAR:
+		return keyctl_keyring_clear((key_serial_t) arg2);
+
+	case KEYCTL_LINK:
+		return keyctl_keyring_link((key_serial_t) arg2,
+					   (key_serial_t) arg3);
+
+	case KEYCTL_UNLINK:
+		return keyctl_keyring_unlink((key_serial_t) arg2,
+					     (key_serial_t) arg3);
+
+	case KEYCTL_SEARCH:
+		return keyctl_keyring_search((key_serial_t) arg2,
+					     (const char __user *) arg3,
+					     (const char __user *) arg4,
+					     (key_serial_t) arg5);
+
+	case KEYCTL_READ:
+		return keyctl_read_key((key_serial_t) arg2,
+				       (char __user *) arg3,
+				       (size_t) arg4);
+
+	case KEYCTL_CHOWN:
+		return keyctl_chown_key((key_serial_t) arg2,
+					(uid_t) arg3,
+					(gid_t) arg4);
+
+	case KEYCTL_SETPERM:
+		return keyctl_setperm_key((key_serial_t) arg2,
+					  (key_perm_t) arg3);
+
+	case KEYCTL_INSTANTIATE:
+		return keyctl_instantiate_key((key_serial_t) arg2,
+					      (const void __user *) arg3,
+					      (size_t) arg4,
+					      (key_serial_t) arg5);
+
+	case KEYCTL_NEGATE:
+		return keyctl_negate_key((key_serial_t) arg2,
+					 (unsigned) arg3,
+					 (key_serial_t) arg4);
+
+	default:
+		return -EOPNOTSUPP;
+	}
+
+} /* end sys_keyctl() */
diff -Nru a/security/keys/keyring.c b/security/keys/keyring.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/keyring.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,895 @@
+/* keyring.c: keyring handling
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/seq_file.h>
+#include <linux/err.h>
+#include <asm/uaccess.h>
+#include "internal.h"
+
+/*
+ * when plumbing the depths of the key tree, this sets a hard limit set on how
+ * deep we're willing to go
+ */
+#define KEYRING_SEARCH_MAX_DEPTH 6
+
+/*
+ * we keep all named keyrings in a hash to speed looking them up
+ */
+#define KEYRING_NAME_HASH_SIZE	(1 << 5)
+
+static struct list_head	keyring_name_hash[KEYRING_NAME_HASH_SIZE];
+static rwlock_t		keyring_name_lock = RW_LOCK_UNLOCKED;
+
+static inline unsigned keyring_hash(const char *desc)
+{
+	unsigned bucket = 0;
+
+	for (; *desc; desc++)
+		bucket += (unsigned char) *desc;
+
+	return bucket & (KEYRING_NAME_HASH_SIZE - 1);
+}
+
+/*
+ * the keyring type definition
+ */
+static int keyring_instantiate(struct key *keyring,
+			       const void *data, size_t datalen);
+static int keyring_duplicate(struct key *keyring, const struct key *source);
+static int keyring_match(const struct key *keyring, const void *criterion);
+static void keyring_destroy(struct key *keyring);
+static void keyring_describe(const struct key *keyring, struct seq_file *m);
+static long keyring_read(const struct key *keyring,
+			 char __user *buffer, size_t buflen);
+
+struct key_type key_type_keyring = {
+	.name		= "keyring",
+	.def_datalen	= sizeof(struct keyring_list),
+	.instantiate	= keyring_instantiate,
+	.duplicate	= keyring_duplicate,
+	.match		= keyring_match,
+	.destroy	= keyring_destroy,
+	.describe	= keyring_describe,
+	.read		= keyring_read,
+};
+
+/*
+ * semaphore to serialise link/link calls to prevent two link calls in parallel
+ * introducing a cycle
+ */
+DECLARE_RWSEM(keyring_serialise_link_sem);
+
+/*****************************************************************************/
+/*
+ * publish the name of a keyring so that it can be found by name (if it has
+ * one)
+ */
+void keyring_publish_name(struct key *keyring)
+{
+	int bucket;
+
+	if (keyring->description) {
+		bucket = keyring_hash(keyring->description);
+
+		write_lock(&keyring_name_lock);
+
+		if (!keyring_name_hash[bucket].next)
+			INIT_LIST_HEAD(&keyring_name_hash[bucket]);
+
+		list_add_tail(&keyring->type_data.link,
+			      &keyring_name_hash[bucket]);
+
+		write_unlock(&keyring_name_lock);
+	}
+
+} /* end keyring_publish_name() */
+
+/*****************************************************************************/
+/*
+ * initialise a keyring
+ * - we object if we were given any data
+ */
+static int keyring_instantiate(struct key *keyring,
+			       const void *data, size_t datalen)
+{
+	int ret;
+
+	ret = -EINVAL;
+	if (datalen == 0) {
+		/* make the keyring available by name if it has one */
+		keyring_publish_name(keyring);
+		ret = 0;
+	}
+
+	return ret;
+
+} /* end keyring_instantiate() */
+
+/*****************************************************************************/
+/*
+ * duplicate the list of subscribed keys from a source keyring into this one
+ */
+static int keyring_duplicate(struct key *keyring, const struct key *source)
+{
+	struct keyring_list *sklist, *klist;
+	unsigned max;
+	size_t size;
+	int loop, ret;
+
+	const unsigned limit =
+		(PAGE_SIZE - sizeof(*klist)) / sizeof(struct key);
+
+	ret = 0;
+	sklist = source->payload.subscriptions;
+
+	if (sklist && sklist->nkeys > 0) {
+		max = sklist->nkeys;
+		BUG_ON(max > limit);
+
+		max = (max + 3) & ~3;
+		if (max > limit)
+			max = limit;
+
+		ret = -ENOMEM;
+		size = sizeof(*klist) + sizeof(struct key) * max;
+		klist = kmalloc(size, GFP_KERNEL);
+		if (!klist)
+			goto error;
+
+		klist->maxkeys = max;
+		klist->nkeys = sklist->nkeys;
+		memcpy(klist->keys,
+		       sklist->keys,
+		       sklist->nkeys * sizeof(struct key));
+
+		for (loop = klist->nkeys - 1; loop >= 0; loop--)
+			atomic_inc(&klist->keys[loop]->usage);
+
+		keyring->payload.subscriptions = klist;
+		ret = 0;
+	}
+
+ error:
+	return ret;
+
+} /* end keyring_duplicate() */
+
+/*****************************************************************************/
+/*
+ * match keyrings on their name
+ */
+static int keyring_match(const struct key *keyring, const void *description)
+{
+	return keyring->description &&
+		strcmp(keyring->description, description) == 0;
+
+} /* end keyring_match() */
+
+/*****************************************************************************/
+/*
+ * dispose of the data dangling from the corpse of a keyring
+ */
+static void keyring_destroy(struct key *keyring)
+{
+	struct keyring_list *klist;
+	int loop;
+
+	if (keyring->description) {
+		write_lock(&keyring_name_lock);
+		list_del(&keyring->type_data.link);
+		write_unlock(&keyring_name_lock);
+	}
+
+	klist = keyring->payload.subscriptions;
+	if (klist) {
+		for (loop = klist->nkeys - 1; loop >= 0; loop--)
+			key_put(klist->keys[loop]);
+		kfree(klist);
+	}
+
+} /* end keyring_destroy() */
+
+/*****************************************************************************/
+/*
+ * describe the keyring
+ */
+static void keyring_describe(const struct key *keyring, struct seq_file *m)
+{
+	struct keyring_list *klist;
+
+	if (keyring->description) {
+		seq_puts(m, keyring->description);
+	}
+	else {
+		seq_puts(m, "[anon]");
+	}
+
+	klist = keyring->payload.subscriptions;
+	if (klist)
+		seq_printf(m, ": %u/%u", klist->nkeys, klist->maxkeys);
+	else
+		seq_puts(m, ": empty");
+
+} /* end keyring_describe() */
+
+/*****************************************************************************/
+/*
+ * read a list of key IDs from the keyring's contents
+ */
+static long keyring_read(const struct key *keyring,
+			 char __user *buffer, size_t buflen)
+{
+	struct keyring_list *klist;
+	struct key *key;
+	size_t qty, tmp;
+	int loop, ret;
+
+	ret = 0;
+	klist = keyring->payload.subscriptions;
+
+	if (klist) {
+		/* calculate how much data we could return */
+		qty = klist->nkeys * sizeof(key_serial_t);
+
+		if (buffer && buflen > 0) {
+			if (buflen > qty)
+				buflen = qty;
+
+			/* copy the IDs of the subscribed keys into the
+			 * buffer */
+			ret = -EFAULT;
+
+			for (loop = 0; loop < klist->nkeys; loop++) {
+				key = klist->keys[loop];
+
+				tmp = sizeof(key_serial_t);
+				if (tmp > buflen)
+					tmp = buflen;
+
+				if (copy_to_user(buffer,
+						 &key->serial,
+						 tmp) != 0)
+					goto error;
+
+				buflen -= tmp;
+				if (buflen == 0)
+					break;
+				buffer += tmp;
+			}
+		}
+
+		ret = qty;
+	}
+
+ error:
+	return ret;
+
+} /* end keyring_read() */
+
+/*****************************************************************************/
+/*
+ * allocate a keyring and link into the destination keyring
+ */
+struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,
+			  int not_in_quota, struct key *dest)
+{
+	struct key *keyring;
+	int ret;
+
+	keyring = key_alloc(&key_type_keyring, description,
+			    uid, gid, KEY_USR_ALL, not_in_quota);
+
+	if (!IS_ERR(keyring)) {
+		ret = key_instantiate_and_link(keyring, NULL, 0, dest);
+		if (ret < 0) {
+			key_put(keyring);
+			keyring = ERR_PTR(ret);
+		}
+	}
+
+	return keyring;
+
+} /* end keyring_alloc() */
+
+/*****************************************************************************/
+/*
+ * search the supplied keyring tree for a key that matches the criterion
+ * - perform a breadth-then-depth search up to the prescribed limit
+ * - we only find keys on which we have search permission
+ * - we use the supplied match function to see if the description (or other
+ *   feature of interest) matches
+ * - we readlock the keyrings as we search down the tree
+ * - we return -EAGAIN if we didn't find any matching key
+ * - we return -ENOKEY if we only found negative matching keys
+ */
+struct key *keyring_search_aux(struct key *keyring,
+			       struct key_type *type,
+			       const void *description,
+			       key_match_func_t match)
+{
+	struct {
+		struct key *keyring;
+		int kix;
+	} stack[KEYRING_SEARCH_MAX_DEPTH];
+
+	struct keyring_list *keylist;
+	struct timespec now;
+	struct key *key;
+	long err;
+	int sp, psp, kix;
+
+	key_check(keyring);
+
+	/* top keyring must have search permission to begin the search */
+	key = ERR_PTR(-EACCES);
+	if (!key_permission(keyring, KEY_SEARCH))
+		goto error;
+
+	key = ERR_PTR(-ENOTDIR);
+	if (keyring->type != &key_type_keyring)
+		goto error;
+
+	now = current_kernel_time();
+	err = -EAGAIN;
+	sp = 0;
+
+	/* start processing a new keyring */
+ descend:
+	read_lock(&keyring->lock);
+	if (keyring->flags & KEY_FLAG_REVOKED)
+		goto not_this_keyring;
+
+	keylist = keyring->payload.subscriptions;
+	if (!keylist)
+		goto not_this_keyring;
+
+	/* iterate through the keys in this keyring first */
+	for (kix = 0; kix < keylist->nkeys; kix++) {
+		key = keylist->keys[kix];
+
+		/* ignore keys not of this type */
+		if (key->type != type)
+			continue;
+
+		/* skip revoked keys and expired keys */
+		if (key->flags & KEY_FLAG_REVOKED)
+			continue;
+
+		if (key->expiry && now.tv_sec >= key->expiry)
+			continue;
+
+		/* keys that don't match */
+		if (!match(key, description))
+			continue;
+
+		/* key must have search permissions */
+		if (!key_permission(key, KEY_SEARCH))
+			continue;
+
+		/* we set a different error code if we find a negative key */
+		if (key->flags & KEY_FLAG_NEGATIVE) {
+			err = -ENOKEY;
+			continue;
+		}
+
+		goto found;
+	}
+
+	/* search through the keyrings nested in this one */
+	kix = 0;
+ ascend:
+	while (kix < keylist->nkeys) {
+		key = keylist->keys[kix];
+		if (key->type != &key_type_keyring)
+			goto next;
+
+		/* recursively search nested keyrings
+		 * - only search keyrings for which we have search permission
+		 */
+		if (sp >= KEYRING_SEARCH_MAX_DEPTH)
+			goto next;
+
+		if (!key_permission(key, KEY_SEARCH))
+			goto next;
+
+		/* evade loops in the keyring tree */
+		for (psp = 0; psp < sp; psp++)
+			if (stack[psp].keyring == keyring)
+				goto next;
+
+		/* stack the current position */
+		stack[sp].keyring = keyring;
+		stack[sp].kix = kix;
+		sp++;
+
+		/* begin again with the new keyring */
+		keyring = key;
+		goto descend;
+
+	next:
+		kix++;
+	}
+
+	/* the keyring we're looking at was disqualified or didn't contain a
+	 * matching key */
+ not_this_keyring:
+	read_unlock(&keyring->lock);
+
+	if (sp > 0) {
+		/* resume the processing of a keyring higher up in the tree */
+		sp--;
+		keyring = stack[sp].keyring;
+		keylist = keyring->payload.subscriptions;
+		kix = stack[sp].kix + 1;
+		goto ascend;
+	}
+
+	key = ERR_PTR(err);
+	goto error;
+
+	/* we found a viable match */
+ found:
+	atomic_inc(&key->usage);
+	read_unlock(&keyring->lock);
+
+	/* unwind the keyring stack */
+	while (sp > 0) {
+		sp--;
+		read_unlock(&stack[sp].keyring->lock);
+	}
+
+	key_check(key);
+ error:
+	return key;
+
+} /* end keyring_search_aux() */
+
+/*****************************************************************************/
+/*
+ * search the supplied keyring tree for a key that matches the criterion
+ * - perform a breadth-then-depth search up to the prescribed limit
+ * - we only find keys on which we have search permission
+ * - we readlock the keyrings as we search down the tree
+ * - we return -EAGAIN if we didn't find any matching key
+ * - we return -ENOKEY if we only found negative matching keys
+ */
+struct key *keyring_search(struct key *keyring,
+			   struct key_type *type,
+			   const char *description)
+{
+	return keyring_search_aux(keyring, type, description, type->match);
+
+} /* end keyring_search() */
+
+EXPORT_SYMBOL(keyring_search);
+
+/*****************************************************************************/
+/*
+ * search the given keyring only (no recursion)
+ * - keyring must be locked by caller
+ */
+struct key *__keyring_search_one(struct key *keyring,
+				 const struct key_type *ktype,
+				 const char *description,
+				 key_perm_t perm)
+{
+	struct keyring_list *klist;
+	struct key *key;
+	int loop;
+
+	klist = keyring->payload.subscriptions;
+	if (klist) {
+		for (loop = 0; loop < klist->nkeys; loop++) {
+			key = klist->keys[loop];
+
+			if (key->type == ktype &&
+			    key->type->match(key, description) &&
+			    key_permission(key, perm) &&
+			    !(key->flags & KEY_FLAG_REVOKED)
+			    )
+				goto found;
+		}
+	}
+
+	key = ERR_PTR(-ENOKEY);
+	goto error;
+
+ found:
+	atomic_inc(&key->usage);
+ error:
+	return key;
+
+} /* end __keyring_search_one() */
+
+/*****************************************************************************/
+/*
+ * find a keyring with the specified name
+ * - all named keyrings are searched
+ * - only find keyrings with search permission for the process
+ * - only find keyrings with a serial number greater than the one specified
+ */
+struct key *find_keyring_by_name(const char *name, key_serial_t bound)
+{
+	struct key *keyring;
+	int bucket;
+
+	keyring = ERR_PTR(-EINVAL);
+	if (!name)
+		goto error;
+
+	bucket = keyring_hash(name);
+
+	read_lock(&keyring_name_lock);
+
+	if (keyring_name_hash[bucket].next) {
+		/* search this hash bucket for a keyring with a matching name
+		 * that's readable and that hasn't been revoked */
+		list_for_each_entry(keyring,
+				    &keyring_name_hash[bucket],
+				    type_data.link
+				    ) {
+			if (keyring->flags & KEY_FLAG_REVOKED)
+				continue;
+
+			if (strcmp(keyring->description, name) != 0)
+				continue;
+
+			if (!key_permission(keyring, KEY_SEARCH))
+				continue;
+
+			/* found a potential candidate, but we still need to
+			 * check the serial number */
+			if (keyring->serial <= bound)
+				continue;
+
+			/* we've got a match */
+			atomic_inc(&keyring->usage);
+			read_unlock(&keyring_name_lock);
+			goto error;
+		}
+	}
+
+	read_unlock(&keyring_name_lock);
+	keyring = ERR_PTR(-ENOKEY);
+
+ error:
+	return keyring;
+
+} /* end find_keyring_by_name() */
+
+/*****************************************************************************/
+/*
+ * see if a cycle will will be created by inserting acyclic tree B in acyclic
+ * tree A at the topmost level (ie: as a direct child of A)
+ * - since we are adding B to A at the top level, checking for cycles should
+ *   just be a matter of seeing if node A is somewhere in tree B
+ */
+static int keyring_detect_cycle(struct key *A, struct key *B)
+{
+	struct {
+		struct key *subtree;
+		int kix;
+	} stack[KEYRING_SEARCH_MAX_DEPTH];
+
+	struct keyring_list *keylist;
+	struct key *subtree, *key;
+	int sp, kix, ret;
+
+	ret = -EDEADLK;
+	if (A == B)
+		goto error;
+
+	subtree = B;
+	sp = 0;
+
+	/* start processing a new keyring */
+ descend:
+	read_lock(&subtree->lock);
+	if (subtree->flags & KEY_FLAG_REVOKED)
+		goto not_this_keyring;
+
+	keylist = subtree->payload.subscriptions;
+	if (!keylist)
+		goto not_this_keyring;
+	kix = 0;
+
+ ascend:
+	/* iterate through the remaining keys in this keyring */
+	for (; kix < keylist->nkeys; kix++) {
+		key = keylist->keys[kix];
+
+		if (key == A)
+			goto cycle_detected;
+
+		/* recursively check nested keyrings */
+		if (key->type == &key_type_keyring) {
+			if (sp >= KEYRING_SEARCH_MAX_DEPTH)
+				goto too_deep;
+
+			/* stack the current position */
+			stack[sp].subtree = subtree;
+			stack[sp].kix = kix;
+			sp++;
+
+			/* begin again with the new keyring */
+			subtree = key;
+			goto descend;
+		}
+	}
+
+	/* the keyring we're looking at was disqualified or didn't contain a
+	 * matching key */
+ not_this_keyring:
+	read_unlock(&subtree->lock);
+
+	if (sp > 0) {
+		/* resume the checking of a keyring higher up in the tree */
+		sp--;
+		subtree = stack[sp].subtree;
+		keylist = subtree->payload.subscriptions;
+		kix = stack[sp].kix + 1;
+		goto ascend;
+	}
+
+	ret = 0; /* no cycles detected */
+
+ error:
+	return ret;
+
+ too_deep:
+	ret = -ELOOP;
+	goto error_unwind;
+ cycle_detected:
+	ret = -EDEADLK;
+ error_unwind:
+	read_unlock(&subtree->lock);
+
+	/* unwind the keyring stack */
+	while (sp > 0) {
+		sp--;
+		read_unlock(&stack[sp].subtree->lock);
+	}
+
+	goto error;
+
+} /* end keyring_detect_cycle() */
+
+/*****************************************************************************/
+/*
+ * link a key into to a keyring
+ * - must be called with the keyring's semaphore held
+ */
+int __key_link(struct key *keyring, struct key *key)
+{
+	struct keyring_list *klist, *nklist;
+	unsigned max;
+	size_t size;
+	int ret;
+
+	ret = -EKEYREVOKED;
+	if (keyring->flags & KEY_FLAG_REVOKED)
+		goto error;
+
+	ret = -ENOTDIR;
+	if (keyring->type != &key_type_keyring)
+		goto error;
+
+	/* serialise link/link calls to prevent parallel calls causing a
+	 * cycle when applied to two keyring in opposite orders */
+	down_write(&keyring_serialise_link_sem);
+
+	/* check that we aren't going to create a cycle adding one keyring to
+	 * another */
+	if (key->type == &key_type_keyring) {
+		ret = keyring_detect_cycle(keyring, key);
+		if (ret < 0)
+			goto error2;
+	}
+
+	/* check that we aren't going to overrun the user's quota */
+	ret = key_payload_reserve(keyring,
+				  keyring->datalen + KEYQUOTA_LINK_BYTES);
+	if (ret < 0)
+		goto error2;
+
+	klist = keyring->payload.subscriptions;
+
+	if (klist && klist->nkeys < klist->maxkeys) {
+		/* there's sufficient slack space to add directly */
+		atomic_inc(&key->usage);
+
+		write_lock(&keyring->lock);
+		klist->keys[klist->nkeys++] = key;
+		write_unlock(&keyring->lock);
+
+		ret = 0;
+	}
+	else {
+		/* grow the key list */
+		max = 4;
+		if (klist)
+			max += klist->maxkeys;
+
+		ret = -ENFILE;
+		size = sizeof(*klist) + sizeof(*key) * max;
+		if (size > PAGE_SIZE)
+			goto error3;
+
+		ret = -ENOMEM;
+		nklist = kmalloc(size, GFP_KERNEL);
+		if (!nklist)
+			goto error3;
+		nklist->maxkeys = max;
+		nklist->nkeys = 0;
+
+		if (klist) {
+			nklist->nkeys = klist->nkeys;
+			memcpy(nklist->keys,
+			       klist->keys,
+			       sizeof(struct key *) * klist->nkeys);
+		}
+
+		/* add the key into the new space */
+		atomic_inc(&key->usage);
+
+		write_lock(&keyring->lock);
+		keyring->payload.subscriptions = nklist;
+		nklist->keys[nklist->nkeys++] = key;
+		write_unlock(&keyring->lock);
+
+		/* dispose of the old keyring list */
+		kfree(klist);
+
+		ret = 0;
+	}
+
+ error2:
+	up_write(&keyring_serialise_link_sem);
+ error:
+	return ret;
+
+ error3:
+	/* undo the quota changes */
+	key_payload_reserve(keyring,
+			    keyring->datalen - KEYQUOTA_LINK_BYTES);
+	goto error2;
+
+} /* end __key_link() */
+
+/*****************************************************************************/
+/*
+ * link a key to a keyring
+ */
+int key_link(struct key *keyring, struct key *key)
+{
+	int ret;
+
+	key_check(keyring);
+	key_check(key);
+
+	down_write(&keyring->sem);
+	ret = __key_link(keyring, key);
+	up_write(&keyring->sem);
+
+	return ret;
+
+} /* end key_link() */
+
+EXPORT_SYMBOL(key_link);
+
+/*****************************************************************************/
+/*
+ * unlink the first link to a key from a keyring
+ */
+int key_unlink(struct key *keyring, struct key *key)
+{
+	struct keyring_list *klist;
+	int loop, ret;
+
+	key_check(keyring);
+	key_check(key);
+
+	ret = -ENOTDIR;
+	if (keyring->type != &key_type_keyring)
+		goto error;
+
+	down_write(&keyring->sem);
+
+	klist = keyring->payload.subscriptions;
+	if (klist) {
+		/* search the keyring for the key */
+		for (loop = 0; loop < klist->nkeys; loop++)
+			if (klist->keys[loop] == key)
+				goto key_is_present;
+	}
+
+	up_write(&keyring->sem);
+	ret = -ENOENT;
+	goto error;
+
+ key_is_present:
+	/* adjust the user's quota */
+	key_payload_reserve(keyring,
+			    keyring->datalen - KEYQUOTA_LINK_BYTES);
+
+	/* shuffle down the key pointers
+	 * - it might be worth shrinking the allocated memory, but that runs
+	 *   the risk of ENOMEM as we would have to copy
+	 */
+	write_lock(&keyring->lock);
+
+	klist->nkeys--;
+	if (loop < klist->nkeys)
+		memcpy(&klist->keys[loop],
+		       &klist->keys[loop + 1],
+		       (klist->nkeys - loop) * sizeof(struct key *));
+
+	write_unlock(&keyring->lock);
+
+	up_write(&keyring->sem);
+	key_put(key);
+	ret = 0;
+
+ error:
+	return ret;
+
+} /* end key_unlink() */
+
+EXPORT_SYMBOL(key_unlink);
+
+/*****************************************************************************/
+/*
+ * clear the specified process keyring
+ * - implements keyctl(KEYCTL_CLEAR)
+ */
+int keyring_clear(struct key *keyring)
+{
+	struct keyring_list *klist;
+	int loop, ret;
+
+	ret = -ENOTDIR;
+	if (keyring->type == &key_type_keyring) {
+		/* detach the pointer block with the locks held */
+		down_write(&keyring->sem);
+
+		klist = keyring->payload.subscriptions;
+		if (klist) {
+			/* adjust the quota */
+			key_payload_reserve(keyring,
+					    sizeof(struct keyring_list));
+
+			write_lock(&keyring->lock);
+			keyring->payload.subscriptions = NULL;
+			write_unlock(&keyring->lock);
+		}
+
+		up_write(&keyring->sem);
+
+		/* free the keys after the locks have been dropped */
+		if (klist) {
+			for (loop = klist->nkeys - 1; loop >= 0; loop--)
+				key_put(klist->keys[loop]);
+
+			kfree(klist);
+		}
+
+		ret = 0;
+	}
+
+	return ret;
+
+} /* end keyring_clear() */
+
+EXPORT_SYMBOL(keyring_clear);
diff -Nru a/security/keys/proc.c b/security/keys/proc.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/proc.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,251 @@
+/* proc.c: proc files for key database enumeration
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/fs.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/errno.h>
+#include "internal.h"
+
+#ifdef CONFIG_KEYS_DEBUG_PROC_KEYS
+static int proc_keys_open(struct inode *inode, struct file *file);
+static void *proc_keys_start(struct seq_file *p, loff_t *_pos);
+static void *proc_keys_next(struct seq_file *p, void *v, loff_t *_pos);
+static void proc_keys_stop(struct seq_file *p, void *v);
+static int proc_keys_show(struct seq_file *m, void *v);
+
+static struct seq_operations proc_keys_ops = {
+	.start	= proc_keys_start,
+	.next	= proc_keys_next,
+	.stop	= proc_keys_stop,
+	.show	= proc_keys_show,
+};
+
+static struct file_operations proc_keys_fops = {
+	.open		= proc_keys_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+#endif
+
+static int proc_key_users_open(struct inode *inode, struct file *file);
+static void *proc_key_users_start(struct seq_file *p, loff_t *_pos);
+static void *proc_key_users_next(struct seq_file *p, void *v, loff_t *_pos);
+static void proc_key_users_stop(struct seq_file *p, void *v);
+static int proc_key_users_show(struct seq_file *m, void *v);
+
+static struct seq_operations proc_key_users_ops = {
+	.start	= proc_key_users_start,
+	.next	= proc_key_users_next,
+	.stop	= proc_key_users_stop,
+	.show	= proc_key_users_show,
+};
+
+static struct file_operations proc_key_users_fops = {
+	.open		= proc_key_users_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
+/*****************************************************************************/
+/*
+ * declare the /proc files
+ */
+static int __init key_proc_init(void)
+{
+	struct proc_dir_entry *p;
+
+#ifdef CONFIG_KEYS_DEBUG_PROC_KEYS
+	p = create_proc_entry("keys", 0, NULL);
+	if (!p)
+		panic("Cannot create /proc/keys\n");
+
+	p->proc_fops = &proc_keys_fops;
+#endif
+
+	p = create_proc_entry("key-users", 0, NULL);
+	if (!p)
+		panic("Cannot create /proc/key-users\n");
+
+	p->proc_fops = &proc_key_users_fops;
+
+	return 0;
+
+} /* end key_proc_init() */
+
+__initcall(key_proc_init);
+
+/*****************************************************************************/
+/*
+ * implement "/proc/keys" to provides a list of the keys on the system
+ */
+#ifdef CONFIG_KEYS_DEBUG_PROC_KEYS
+
+static int proc_keys_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &proc_keys_ops);
+
+}
+
+static void *proc_keys_start(struct seq_file *p, loff_t *_pos)
+{
+	struct rb_node *_p;
+	loff_t pos = *_pos;
+
+	spin_lock(&key_serial_lock);
+
+	_p = rb_first(&key_serial_tree);
+	while (pos > 0 && _p) {
+		pos--;
+		_p = rb_next(_p);
+	}
+
+	return _p;
+
+}
+
+static void *proc_keys_next(struct seq_file *p, void *v, loff_t *_pos)
+{
+	(*_pos)++;
+	return rb_next((struct rb_node *) v);
+
+}
+
+static void proc_keys_stop(struct seq_file *p, void *v)
+{
+	spin_unlock(&key_serial_lock);
+}
+
+static int proc_keys_show(struct seq_file *m, void *v)
+{
+	struct rb_node *_p = v;
+	struct key *key = rb_entry(_p, struct key, serial_node);
+	struct timespec now;
+	unsigned long timo;
+	char xbuf[12];
+
+	now = current_kernel_time();
+
+	read_lock(&key->lock);
+
+	/* come up with a suitable timeout value */
+	if (key->expiry == 0) {
+		memcpy(xbuf, "perm", 5);
+	}
+	else if (now.tv_sec >= key->expiry) {
+		memcpy(xbuf, "expd", 5);
+	}
+	else {
+		timo = key->expiry - now.tv_sec;
+
+		if (timo < 60)
+			sprintf(xbuf, "%lus", timo);
+		else if (timo < 60*60)
+			sprintf(xbuf, "%lum", timo / 60);
+		else if (timo < 60*60*24)
+			sprintf(xbuf, "%luh", timo / (60*60));
+		else if (timo < 60*60*24*7)
+			sprintf(xbuf, "%lud", timo / (60*60*24));
+		else
+			sprintf(xbuf, "%luw", timo / (60*60*24*7));
+	}
+
+	seq_printf(m, "%08x %c%c%c%c%c%c %5d %4s %06x %5d %5d %-9.9s ",
+		   key->serial,
+		   key->flags & KEY_FLAG_INSTANTIATED	? 'I' : '-',
+		   key->flags & KEY_FLAG_REVOKED	? 'R' : '-',
+		   key->flags & KEY_FLAG_DEAD		? 'D' : '-',
+		   key->flags & KEY_FLAG_IN_QUOTA	? 'Q' : '-',
+		   key->flags & KEY_FLAG_USER_CONSTRUCT	? 'U' : '-',
+		   key->flags & KEY_FLAG_NEGATIVE	? 'N' : '-',
+		   atomic_read(&key->usage),
+		   xbuf,
+		   key->perm,
+		   key->uid,
+		   key->gid,
+		   key->type->name);
+
+	if (key->type->describe)
+		key->type->describe(key, m);
+	seq_putc(m, '\n');
+
+	read_unlock(&key->lock);
+
+	return 0;
+
+}
+
+#endif /* CONFIG_KEYS_DEBUG_PROC_KEYS */
+
+/*****************************************************************************/
+/*
+ * implement "/proc/key-users" to provides a list of the key users
+ */
+static int proc_key_users_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &proc_key_users_ops);
+
+}
+
+static void *proc_key_users_start(struct seq_file *p, loff_t *_pos)
+{
+	struct rb_node *_p;
+	loff_t pos = *_pos;
+
+	spin_lock(&key_user_lock);
+
+	_p = rb_first(&key_user_tree);
+	while (pos > 0 && _p) {
+		pos--;
+		_p = rb_next(_p);
+	}
+
+	return _p;
+
+}
+
+static void *proc_key_users_next(struct seq_file *p, void *v, loff_t *_pos)
+{
+	(*_pos)++;
+	return rb_next((struct rb_node *) v);
+
+}
+
+static void proc_key_users_stop(struct seq_file *p, void *v)
+{
+	spin_unlock(&key_user_lock);
+}
+
+static int proc_key_users_show(struct seq_file *m, void *v)
+{
+	struct rb_node *_p = v;
+	struct key_user *user = rb_entry(_p, struct key_user, node);
+
+	seq_printf(m, "%5u: %5d %d/%d %d/%d %d/%d\n",
+		   user->uid,
+		   atomic_read(&user->usage),
+		   atomic_read(&user->nkeys),
+		   atomic_read(&user->nikeys),
+		   user->qnkeys,
+		   KEYQUOTA_MAX_KEYS,
+		   user->qnbytes,
+		   KEYQUOTA_MAX_BYTES
+		   );
+
+	return 0;
+
+}
diff -Nru a/security/keys/process_keys.c b/security/keys/process_keys.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/process_keys.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,640 @@
+/* process_keys.c: management of a process's keyrings
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/keyctl.h>
+#include <linux/fs.h>
+#include <linux/err.h>
+#include <asm/uaccess.h>
+#include "internal.h"
+
+/* session keyring create vs join semaphore */
+static DECLARE_MUTEX(key_session_sem);
+
+/* the root user's tracking struct */
+struct key_user root_key_user = {
+	.usage		= ATOMIC_INIT(3),
+	.consq		= LIST_HEAD_INIT(root_key_user.consq),
+	.lock		= SPIN_LOCK_UNLOCKED,
+	.nkeys		= ATOMIC_INIT(2),
+	.nikeys		= ATOMIC_INIT(2),
+	.uid		= 0,
+};
+
+/* the root user's UID keyring */
+struct key root_user_keyring = {
+	.usage		= ATOMIC_INIT(1),
+	.serial		= 2,
+	.type		= &key_type_keyring,
+	.user		= &root_key_user,
+	.lock		= RW_LOCK_UNLOCKED,
+	.sem		= __RWSEM_INITIALIZER(root_user_keyring.sem),
+	.perm		= KEY_USR_ALL,
+	.flags		= KEY_FLAG_INSTANTIATED,
+	.description	= "_uid.0",
+#ifdef KEY_DEBUGGING
+	.magic		= KEY_DEBUG_MAGIC,
+#endif
+};
+
+/* the root user's default session keyring */
+struct key root_session_keyring = {
+	.usage		= ATOMIC_INIT(1),
+	.serial		= 1,
+	.type		= &key_type_keyring,
+	.user		= &root_key_user,
+	.lock		= RW_LOCK_UNLOCKED,
+	.sem		= __RWSEM_INITIALIZER(root_session_keyring.sem),
+	.perm		= KEY_USR_ALL,
+	.flags		= KEY_FLAG_INSTANTIATED,
+	.description	= "_uid_ses.0",
+#ifdef KEY_DEBUGGING
+	.magic		= KEY_DEBUG_MAGIC,
+#endif
+};
+
+/*****************************************************************************/
+/*
+ * allocate the keyrings to be associated with a UID
+ */
+int alloc_uid_keyring(struct user_struct *user)
+{
+	struct key *uid_keyring, *session_keyring;
+	char buf[20];
+	int ret;
+
+	/* concoct a default session keyring */
+	sprintf(buf, "_uid_ses.%u", user->uid);
+
+	session_keyring = keyring_alloc(buf, user->uid, (gid_t) -1, 0, NULL);
+	if (IS_ERR(session_keyring)) {
+		ret = PTR_ERR(session_keyring);
+		goto error;
+	}
+
+	/* and a UID specific keyring, pointed to by the default session
+	 * keyring */
+	sprintf(buf, "_uid.%u", user->uid);
+
+	uid_keyring = keyring_alloc(buf, user->uid, (gid_t) -1, 0,
+				    session_keyring);
+	if (IS_ERR(uid_keyring)) {
+		key_put(session_keyring);
+		ret = PTR_ERR(uid_keyring);
+		goto error;
+	}
+
+	/* install the keyrings */
+	user->uid_keyring = uid_keyring;
+	user->session_keyring = session_keyring;
+	ret = 0;
+
+ error:
+	return ret;
+
+} /* end alloc_uid_keyring() */
+
+/*****************************************************************************/
+/*
+ * deal with the UID changing
+ */
+void switch_uid_keyring(struct user_struct *new_user)
+{
+#if 0 /* do nothing for now */
+	struct key *old;
+
+	/* switch to the new user's session keyring if we were running under
+	 * root's default session keyring */
+	if (new_user->uid != 0 &&
+	    current->session_keyring == &root_session_keyring
+	    ) {
+		atomic_inc(&new_user->session_keyring->usage);
+
+		task_lock(current);
+		old = current->session_keyring;
+		current->session_keyring = new_user->session_keyring;
+		task_unlock(current);
+
+		key_put(old);
+	}
+#endif
+
+} /* end switch_uid_keyring() */
+
+/*****************************************************************************/
+/*
+ * install a fresh thread keyring, discarding the old one
+ */
+int install_thread_keyring(struct task_struct *tsk)
+{
+	struct key *keyring, *old;
+	char buf[20];
+	int ret;
+
+	sprintf(buf, "_tid.%u", tsk->pid);
+
+	keyring = keyring_alloc(buf, tsk->uid, tsk->gid, 1, NULL);
+	if (IS_ERR(keyring)) {
+		ret = PTR_ERR(keyring);
+		goto error;
+	}
+
+	task_lock(tsk);
+	old = tsk->thread_keyring;
+	tsk->thread_keyring = keyring;
+	task_unlock(tsk);
+
+	ret = 0;
+
+	key_put(old);
+ error:
+	return ret;
+
+} /* end install_thread_keyring() */
+
+/*****************************************************************************/
+/*
+ * install a fresh process keyring, discarding the old one
+ */
+static int install_process_keyring(struct task_struct *tsk)
+{
+	struct key *keyring, *old;
+	char buf[20];
+	int ret;
+
+	sprintf(buf, "_pid.%u", tsk->tgid);
+
+	keyring = keyring_alloc(buf, tsk->uid, tsk->gid, 1, NULL);
+	if (IS_ERR(keyring)) {
+		ret = PTR_ERR(keyring);
+		goto error;
+	}
+
+	task_lock(tsk);
+	old = tsk->process_keyring;
+	tsk->process_keyring = keyring;
+	task_unlock(tsk);
+
+	ret = 0;
+
+	key_put(old);
+ error:
+	return ret;
+
+} /* end install_process_keyring() */
+
+/*****************************************************************************/
+/*
+ * install a session keyring, discarding the old one
+ * - if a keyring is not supplied, an empty one is invented
+ */
+static int install_session_keyring(struct task_struct *tsk,
+				   struct key *keyring)
+{
+	struct key *old;
+	char buf[20];
+	int ret;
+
+	/* create an empty session keyring */
+	if (!keyring) {
+		sprintf(buf, "_ses.%u", tsk->tgid);
+
+		keyring = keyring_alloc(buf, tsk->uid, tsk->gid, 1, NULL);
+		if (IS_ERR(keyring)) {
+			ret = PTR_ERR(keyring);
+			goto error;
+		}
+	}
+	else {
+		atomic_inc(&keyring->usage);
+	}
+
+	/* install the keyring */
+	task_lock(tsk);
+	old = tsk->session_keyring;
+	tsk->session_keyring = keyring;
+	task_unlock(tsk);
+
+	ret = 0;
+
+	key_put(old);
+ error:
+	return ret;
+
+} /* end install_session_keyring() */
+
+/*****************************************************************************/
+/*
+ * copy the keys for fork
+ */
+int copy_keys(unsigned long clone_flags, struct task_struct *tsk)
+{
+	int ret = 0;
+
+	key_check(tsk->session_keyring);
+	key_check(tsk->process_keyring);
+	key_check(tsk->thread_keyring);
+
+	if (tsk->session_keyring)
+		atomic_inc(&tsk->session_keyring->usage);
+
+	if (tsk->process_keyring) {
+		if (clone_flags & CLONE_THREAD) {
+			atomic_inc(&tsk->process_keyring->usage);
+		}
+		else {
+			tsk->process_keyring = NULL;
+			ret = install_process_keyring(tsk);
+		}
+	}
+
+	tsk->thread_keyring = NULL;
+	return ret;
+
+} /* end copy_keys() */
+
+/*****************************************************************************/
+/*
+ * dispose of keys upon exit
+ */
+void exit_keys(struct task_struct *tsk)
+{
+	key_put(tsk->session_keyring);
+	key_put(tsk->process_keyring);
+	key_put(tsk->thread_keyring);
+
+} /* end exit_keys() */
+
+/*****************************************************************************/
+/*
+ * deal with execve()
+ */
+int exec_keys(struct task_struct *tsk)
+{
+	struct key *old;
+
+	/* newly exec'd tasks don't get a thread keyring */
+	task_lock(tsk);
+	old = tsk->thread_keyring;
+	tsk->thread_keyring = NULL;
+	task_unlock(tsk);
+
+	key_put(old);
+
+	/* newly exec'd tasks get a fresh process keyring */
+	return install_process_keyring(tsk);
+
+} /* end exec_keys() */
+
+/*****************************************************************************/
+/*
+ * deal with SUID programs
+ * - we might want to make this invent a new session keyring
+ */
+int suid_keys(struct task_struct *tsk)
+{
+	return 0;
+
+} /* end suid_keys() */
+
+/*****************************************************************************/
+/*
+ * the filesystem user ID changed
+ */
+void key_fsuid_changed(struct task_struct *tsk)
+{
+	/* update the ownership of the process keyring */
+	if (tsk->process_keyring) {
+		down_write(&tsk->process_keyring->sem);
+		write_lock(&tsk->process_keyring->lock);
+		tsk->process_keyring->uid = tsk->fsuid;
+		write_unlock(&tsk->process_keyring->lock);
+		up_write(&tsk->process_keyring->sem);
+	}
+
+	/* update the ownership of the thread keyring */
+	if (tsk->thread_keyring) {
+		down_write(&tsk->thread_keyring->sem);
+		write_lock(&tsk->thread_keyring->lock);
+		tsk->thread_keyring->uid = tsk->fsuid;
+		write_unlock(&tsk->thread_keyring->lock);
+		up_write(&tsk->thread_keyring->sem);
+	}
+
+} /* end key_fsuid_changed() */
+
+/*****************************************************************************/
+/*
+ * the filesystem group ID changed
+ */
+void key_fsgid_changed(struct task_struct *tsk)
+{
+	/* update the ownership of the process keyring */
+	if (tsk->process_keyring) {
+		down_write(&tsk->process_keyring->sem);
+		write_lock(&tsk->process_keyring->lock);
+		tsk->process_keyring->gid = tsk->fsgid;
+		write_unlock(&tsk->process_keyring->lock);
+		up_write(&tsk->process_keyring->sem);
+	}
+
+	/* update the ownership of the thread keyring */
+	if (tsk->thread_keyring) {
+		down_write(&tsk->thread_keyring->sem);
+		write_lock(&tsk->thread_keyring->lock);
+		tsk->thread_keyring->gid = tsk->fsgid;
+		write_unlock(&tsk->thread_keyring->lock);
+		up_write(&tsk->thread_keyring->sem);
+	}
+
+} /* end key_fsgid_changed() */
+
+/*****************************************************************************/
+/*
+ * search the process keyrings for the first matching key
+ * - we use the supplied match function to see if the description (or other
+ *   feature of interest) matches
+ * - we return -EAGAIN if we didn't find any matching key
+ * - we return -ENOKEY if we found only negative matching keys
+ */
+struct key *search_process_keyrings_aux(struct key_type *type,
+					const void *description,
+					key_match_func_t match)
+{
+	struct task_struct *tsk = current;
+	struct key *key, *ret, *err, *session;
+
+	/* we want to return -EAGAIN or -ENOKEY if any of the keyrings were
+	 * searchable, but we failed to find a key or we found a negative key;
+	 * otherwise we want to return a sample error (probably -EACCES) if
+	 * none of the keyrings were searchable
+	 *
+	 * in terms of priority: success > -ENOKEY > -EAGAIN > other error
+	 */
+	key = NULL;
+	ret = NULL;
+	err = ERR_PTR(-EAGAIN);
+
+	/* search the thread keyring first */
+	if (tsk->thread_keyring) {
+		key = keyring_search_aux(tsk->thread_keyring, type,
+					 description, match);
+		if (!IS_ERR(key))
+			goto found;
+
+		switch (PTR_ERR(key)) {
+		case -EAGAIN: /* no key */
+			if (ret)
+				break;
+		case -ENOKEY: /* negative key */
+			ret = key;
+			break;
+		default:
+			err = key;
+			break;
+		}
+	}
+
+	/* search the process keyring second */
+	if (tsk->process_keyring) {
+		key = keyring_search_aux(tsk->process_keyring, type,
+					 description, match);
+		if (!IS_ERR(key))
+			goto found;
+
+		switch (PTR_ERR(key)) {
+		case -EAGAIN: /* no key */
+			if (ret)
+				break;
+		case -ENOKEY: /* negative key */
+			ret = key;
+			break;
+		default:
+			err = key;
+			break;
+		}
+	}
+
+	/* search the session keyring last */
+	session = tsk->session_keyring;
+	if (!session)
+		session = tsk->user->session_keyring;
+
+	key = keyring_search_aux(session, type,
+				 description, match);
+	if (!IS_ERR(key))
+		goto found;
+
+	switch (PTR_ERR(key)) {
+	case -EAGAIN: /* no key */
+		if (ret)
+			break;
+	case -ENOKEY: /* negative key */
+		ret = key;
+		break;
+	default:
+		err = key;
+		break;
+	}
+
+	/* no key - decide on the error we're going to go for */
+	key = ret ? ret : err;
+
+ found:
+	return key;
+
+} /* end search_process_keyrings_aux() */
+
+/*****************************************************************************/
+/*
+ * search the process keyrings for the first matching key
+ * - we return -EAGAIN if we didn't find any matching key
+ * - we return -ENOKEY if we found only negative matching keys
+ */
+struct key *search_process_keyrings(struct key_type *type,
+				    const char *description)
+{
+	return search_process_keyrings_aux(type, description, type->match);
+
+} /* end search_process_keyrings() */
+
+/*****************************************************************************/
+/*
+ * lookup a key given a key ID from userspace with a given permissions mask
+ * - don't create special keyrings unless so requested
+ * - partially constructed keys aren't found unless requested
+ */
+struct key *lookup_user_key(key_serial_t id, int create, int partial,
+			    key_perm_t perm)
+{
+	struct task_struct *tsk = current;
+	struct key *key;
+	int ret;
+
+	key = ERR_PTR(-ENOKEY);
+
+	switch (id) {
+	case KEY_SPEC_THREAD_KEYRING:
+		if (!tsk->thread_keyring) {
+			if (!create)
+				goto error;
+
+			ret = install_thread_keyring(tsk);
+			if (ret < 0) {
+				key = ERR_PTR(ret);
+				goto error;
+			}
+		}
+
+		key = tsk->thread_keyring;
+		atomic_inc(&key->usage);
+		break;
+
+	case KEY_SPEC_PROCESS_KEYRING:
+		if (!tsk->process_keyring) {
+			if (!create)
+				goto error;
+
+			ret = install_process_keyring(tsk);
+			if (ret < 0) {
+				key = ERR_PTR(ret);
+				goto error;
+			}
+		}
+
+		key = tsk->process_keyring;
+		atomic_inc(&key->usage);
+		break;
+
+	case KEY_SPEC_SESSION_KEYRING:
+		if (!tsk->session_keyring) {
+			/* always install a session keyring upon access if one
+			 * doesn't exist yet */
+			ret = install_session_keyring(
+			       tsk, tsk->user->session_keyring);
+			if (ret < 0)
+				goto error;
+		}
+
+		key = tsk->session_keyring;
+		atomic_inc(&key->usage);
+		break;
+
+	case KEY_SPEC_USER_KEYRING:
+		key = tsk->user->uid_keyring;
+		atomic_inc(&key->usage);
+		break;
+
+	case KEY_SPEC_USER_SESSION_KEYRING:
+		key = tsk->user->session_keyring;
+		atomic_inc(&key->usage);
+		break;
+
+	case KEY_SPEC_GROUP_KEYRING:
+		/* group keyrings are not yet supported */
+		key = ERR_PTR(-EINVAL);
+		goto error;
+
+	default:
+		key = ERR_PTR(-EINVAL);
+		if (id < 1)
+			goto error;
+
+		key = key_lookup(id);
+		if (IS_ERR(key))
+			goto error;
+		break;
+	}
+
+	/* check the status and permissions */
+	if (perm) {
+		ret = key_validate(key);
+		if (ret < 0)
+			goto invalid_key;
+	}
+
+	ret = -EIO;
+	if (!partial && !(key->flags & KEY_FLAG_INSTANTIATED))
+		goto invalid_key;
+
+	ret = -EACCES;
+	if (!key_permission(key, perm))
+		goto invalid_key;
+
+ error:
+	return key;
+
+ invalid_key:
+	key_put(key);
+	key = ERR_PTR(ret);
+	goto error;
+
+} /* end lookup_user_key() */
+
+/*****************************************************************************/
+/*
+ * join the named keyring as the session keyring if possible, or attempt to
+ * create a new one of that name if not
+ * - if the name is NULL, an empty anonymous keyring is installed instead
+ * - named session keyring joining is done with a semaphore held
+ */
+long join_session_keyring(const char *name)
+{
+	struct task_struct *tsk = current;
+	struct key *keyring;
+	long ret;
+
+	/* if no name is provided, install an anonymous keyring */
+	if (!name) {
+		ret = install_session_keyring(tsk, NULL);
+		if (ret < 0)
+			goto error;
+
+		ret = tsk->session_keyring->serial;
+		goto error;
+	}
+
+	/* allow the user to join or create a named keyring */
+	down(&key_session_sem);
+
+	/* look for an existing keyring of this name */
+	keyring = find_keyring_by_name(name, 0);
+	if (PTR_ERR(keyring) == -ENOKEY) {
+		/* not found - try and create a new one */
+		keyring = keyring_alloc(name, tsk->uid, tsk->gid, 0, NULL);
+		if (IS_ERR(keyring)) {
+			ret = PTR_ERR(keyring);
+			goto error;
+		}
+	}
+	else if (IS_ERR(keyring)) {
+		ret = PTR_ERR(keyring);
+		goto error2;
+	}
+
+	/* we've got a keyring - now to install it */
+	ret = install_session_keyring(tsk, keyring);
+	if (ret < 0)
+		goto error2;
+
+	key_put(keyring);
+
+	ret = tsk->session_keyring->serial;
+
+ error2:
+	up(&key_session_sem);
+ error:
+	return ret;
+
+} /* end join_session_keyring() */
diff -Nru a/security/keys/request_key.c b/security/keys/request_key.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/request_key.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,337 @@
+/* request_key.c: request a key from userspace
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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/module.h>
+#include <linux/sched.h>
+#include <linux/kmod.h>
+#include <linux/err.h>
+#include "internal.h"
+
+struct key_construction {
+	struct list_head	link;	/* link in construction queue */
+	struct key		*key;	/* key being constructed */
+};
+
+/* when waiting for someone else's keys, you get added to this */
+DECLARE_WAIT_QUEUE_HEAD(request_key_conswq);
+
+/*****************************************************************************/
+/*
+ * request userspace finish the construction of a key
+ * - execute "/sbin/request-key <op> <key> <uid> <gid> <keyring> <keyring> <keyring> <info>"
+ * - if callout_info is an empty string, it'll be rendered as a "-" instead
+ */
+static int call_request_key(struct key *key,
+			    const char *op,
+			    const char *callout_info)
+{
+	struct task_struct *tsk = current;
+	char *argv[10], *envp[3], uid_str[12], gid_str[12];
+	char key_str[12], keyring_str[3][12];
+	int i;
+
+	/* record the UID and GID */
+	sprintf(uid_str, "%d", current->fsuid);
+	sprintf(gid_str, "%d", current->fsgid);
+
+	/* we say which key is under construction */
+	sprintf(key_str, "%d", key->serial);
+
+	/* we specify the process's default keyrings */
+	task_lock(current);
+	sprintf(keyring_str[0], "%d",
+		tsk->thread_keyring ? tsk->thread_keyring->serial : 0);
+	sprintf(keyring_str[1], "%d",
+		tsk->process_keyring ? tsk->process_keyring->serial : 0);
+	sprintf(keyring_str[2], "%d",
+		(tsk->session_keyring ?
+		 tsk->session_keyring->serial :
+		 tsk->user->session_keyring->serial));
+	task_unlock(tsk);
+
+	/* set up a minimal environment */
+	i = 0;
+	envp[i++] = "HOME=/";
+	envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
+	envp[i] = NULL;
+
+	/* set up the argument list */
+	i = 0;
+	argv[i++] = "/sbin/request-key";
+	argv[i++] = (char *) op;
+	argv[i++] = key_str;
+	argv[i++] = uid_str;
+	argv[i++] = gid_str;
+	argv[i++] = keyring_str[0];
+	argv[i++] = keyring_str[1];
+	argv[i++] = keyring_str[2];
+	argv[i++] = callout_info[0] ? (char *) callout_info : "-";
+	argv[i] = NULL;
+
+	/* do it */
+	return call_usermodehelper(argv[0], argv, envp, 1);
+
+} /* end call_request_key() */
+
+/*****************************************************************************/
+/*
+ * call out to userspace for the key
+ * - called with the construction sem held, but the sem is dropped here
+ * - we ignore program failure and go on key status instead
+ */
+static struct key *__request_key_construction(struct key_type *type,
+					      const char *description,
+					      const char *callout_info)
+{
+	struct key_construction cons;
+	struct timespec now;
+	struct key *key;
+	int ret, negative;
+
+	/* create a key and add it to the queue */
+	key = key_alloc(type, description,
+			current->fsuid, current->fsgid, KEY_USR_ALL, 0);
+	if (IS_ERR(key))
+		goto alloc_failed;
+
+	write_lock(&key->lock);
+	key->flags |= KEY_FLAG_USER_CONSTRUCT;
+	write_unlock(&key->lock);
+
+	cons.key = key;
+	list_add_tail(&cons.link, &key->user->consq);
+
+	/* we drop the construction sem here on behalf of the caller */
+	up_write(&key_construction_sem);
+
+	/* make the call */
+	ret = call_request_key(key, "create", callout_info);
+	if (ret < 0)
+		goto request_failed;
+
+	/* if the key wasn't instantiated, then we want to give an error */
+	ret = -ENOKEY;
+	if (!(key->flags & KEY_FLAG_INSTANTIATED))
+		goto request_failed;
+
+	down_write(&key_construction_sem);
+	list_del(&cons.link);
+	up_write(&key_construction_sem);
+
+	/* also give an error if the key was negatively instantiated */
+ check_not_negative:
+	if (key->flags & KEY_FLAG_NEGATIVE) {
+		key_put(key);
+		key = ERR_PTR(-ENOKEY);
+	}
+
+ out:
+	return key;
+
+ request_failed:
+	/* it wasn't instantiated
+	 * - remove from construction queue
+	 * - mark the key as dead
+	 */
+	negative = 0;
+	down_write(&key_construction_sem);
+
+	list_del(&cons.link);
+
+	write_lock(&key->lock);
+	key->flags &= ~KEY_FLAG_USER_CONSTRUCT;
+
+	/* check it didn't get instantiated between the check and the down */
+	if (!(key->flags & KEY_FLAG_INSTANTIATED)) {
+		key->flags |= KEY_FLAG_INSTANTIATED | KEY_FLAG_NEGATIVE;
+		negative = 1;
+	}
+
+	write_unlock(&key->lock);
+	up_write(&key_construction_sem);
+
+	if (!negative)
+		goto check_not_negative; /* surprisingly, the key got
+					  * instantiated */
+
+	/* set the timeout and store in the session keyring if we can */
+	now = current_kernel_time();
+	key->expiry = now.tv_sec + key_negative_timeout;
+
+	if (current->session_keyring)
+		key_link(current->session_keyring, key);
+	key_put(key);
+
+	/* notify anyone who was waiting */
+	wake_up_all(&request_key_conswq);
+
+	key = ERR_PTR(ret);
+	goto out;
+
+ alloc_failed:
+	up_write(&key_construction_sem);
+	goto out;
+
+} /* end __request_key_construction() */
+
+/*****************************************************************************/
+/*
+ * call out to userspace to request the key
+ * - we check the construction queue first to see if an appropriate key is
+ *   already being constructed by userspace
+ */
+static struct key *request_key_construction(struct key_type *type,
+					    const char *description,
+					    struct key_user *user,
+					    const char *callout_info)
+{
+	struct key_construction *pcons;
+	struct key *key, *ckey;
+
+	DECLARE_WAITQUEUE(myself, current);
+
+	/* see if there's such a key under construction already */
+	down_write(&key_construction_sem);
+
+	list_for_each_entry(pcons, &user->consq, link) {
+		ckey = pcons->key;
+
+		if (ckey->type != type)
+			continue;
+
+		if (type->match(ckey, description))
+			goto found_key_under_construction;
+	}
+
+	/* see about getting userspace to construct the key */
+	key = __request_key_construction(type, description, callout_info);
+ error:
+	return key;
+
+	/* someone else has the same key under construction
+	 * - we want to keep an eye on their key
+	 */
+ found_key_under_construction:
+	atomic_inc(&ckey->usage);
+	up_write(&key_construction_sem);
+
+	/* wait for the key to be completed one way or another */
+	add_wait_queue(&request_key_conswq, &myself);
+
+	for (;;) {
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		if (!(ckey->flags & KEY_FLAG_USER_CONSTRUCT))
+			break;
+		schedule();
+	}
+
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&request_key_conswq, &myself);
+
+	/* we'll need to search this process's keyrings to see if the key is
+	 * now there since we can't automatically assume it's also available
+	 * there */
+	key_put(ckey);
+	ckey = NULL;
+
+	key = NULL; /* request a retry */
+	goto error;
+
+} /* end request_key_construction() */
+
+/*****************************************************************************/
+/*
+ * request a key
+ * - search the process's keyrings
+ * - check the list of keys being created or updated
+ * - call out to userspace for a key if requested (supplementary info can be
+ *   passed)
+ */
+struct key *request_key(struct key_type *type,
+			const char *description,
+			const char *callout_info)
+{
+	struct key_user *user;
+	struct key *key;
+
+	/* search all the process keyrings for a key */
+	key = search_process_keyrings_aux(type, description, type->match);
+
+	if (PTR_ERR(key) == -EAGAIN) {
+		/* the search failed, but the keyrings were searchable, so we
+		 * should consult userspace if we can */
+		key = ERR_PTR(-ENOKEY);
+		if (!callout_info)
+			goto error;
+
+		/* - get hold of the user's construction queue */
+		user = key_user_lookup(current->fsuid);
+		if (IS_ERR(user)) {
+			key = ERR_PTR(PTR_ERR(user));
+			goto error;
+		}
+
+		for (;;) {
+			/* ask userspace (returns NULL if it waited on a key
+			 * being constructed) */
+			key = request_key_construction(type, description,
+						       user, callout_info);
+			if (key)
+				break;
+
+			/* someone else made the key we want, so we need to
+			 * search again as it might now be available to us */
+			key = search_process_keyrings_aux(type, description,
+							  type->match);
+			if (PTR_ERR(key) != -EAGAIN)
+				break;
+		}
+
+		key_user_put(user);
+	}
+
+ error:
+	return key;
+
+} /* end request_key() */
+
+EXPORT_SYMBOL(request_key);
+
+/*****************************************************************************/
+/*
+ * validate a key
+ */
+int key_validate(struct key *key)
+{
+	struct timespec now;
+	int ret = 0;
+
+	if (key) {
+		/* check it's still accessible */
+		ret = -EKEYREVOKED;
+		if (key->flags & (KEY_FLAG_REVOKED | KEY_FLAG_DEAD))
+			goto error;
+
+		/* check it hasn't expired */
+		ret = 0;
+		if (key->expiry) {
+			now = current_kernel_time();
+			if (now.tv_sec >= key->expiry)
+				ret = -EKEYEXPIRED;
+		}
+	}
+
+ error:
+	return ret;
+
+} /* end key_validate() */
+
+EXPORT_SYMBOL(key_validate);
diff -Nru a/security/keys/user_defined.c b/security/keys/user_defined.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/keys/user_defined.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,191 @@
+/* user_defined.c: user defined key type
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.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/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/seq_file.h>
+#include <linux/err.h>
+#include <asm/uaccess.h>
+#include "internal.h"
+
+static int user_instantiate(struct key *key, const void *data, size_t datalen);
+static int user_duplicate(struct key *key, const struct key *source);
+static int user_update(struct key *key, const void *data, size_t datalen);
+static int user_match(const struct key *key, const void *criterion);
+static void user_destroy(struct key *key);
+static void user_describe(const struct key *user, struct seq_file *m);
+static long user_read(const struct key *key,
+		      char __user *buffer, size_t buflen);
+
+/*
+ * user defined keys take an arbitrary string as the description and an
+ * arbitrary blob of data as the payload
+ */
+struct key_type key_type_user = {
+	.name		= "user",
+	.instantiate	= user_instantiate,
+	.duplicate	= user_duplicate,
+	.update		= user_update,
+	.match		= user_match,
+	.destroy	= user_destroy,
+	.describe	= user_describe,
+	.read		= user_read,
+};
+
+/*****************************************************************************/
+/*
+ * instantiate a user defined key
+ */
+static int user_instantiate(struct key *key, const void *data, size_t datalen)
+{
+	int ret;
+
+	ret = -EINVAL;
+	if (datalen <= 0 || datalen > 32767 || !data)
+		goto error;
+
+	ret = key_payload_reserve(key, datalen);
+	if (ret < 0)
+		goto error;
+
+	/* attach the data */
+	ret = -ENOMEM;
+	key->payload.data = kmalloc(datalen, GFP_KERNEL);
+	if (!key->payload.data)
+		goto error;
+
+	memcpy(key->payload.data, data, datalen);
+	ret = 0;
+
+ error:
+	return ret;
+
+} /* end user_instantiate() */
+
+/*****************************************************************************/
+/*
+ * duplicate a user defined key
+ */
+static int user_duplicate(struct key *key, const struct key *source)
+{
+	int ret;
+
+	/* just copy the payload */
+	ret = -ENOMEM;
+	key->payload.data = kmalloc(source->datalen, GFP_KERNEL);
+
+	if (key->payload.data) {
+		key->datalen = source->datalen;
+		memcpy(key->payload.data, source->payload.data, source->datalen);
+		ret = 0;
+	}
+
+	return ret;
+
+} /* end user_duplicate() */
+
+/*****************************************************************************/
+/*
+ * update a user defined key
+ */
+static int user_update(struct key *key, const void *data, size_t datalen)
+{
+	void *new, *zap;
+	int ret;
+
+	ret = -EINVAL;
+	if (datalen <= 0 || datalen > 32767 || !data)
+		goto error;
+
+	/* copy the data */
+	ret = -ENOMEM;
+	new = kmalloc(datalen, GFP_KERNEL);
+	if (!new)
+		goto error;
+
+	memcpy(new, data, datalen);
+
+	/* check the quota and attach the new data */
+	zap = new;
+	write_lock(&key->lock);
+
+	ret = key_payload_reserve(key, datalen);
+
+	if (ret == 0) {
+		/* attach the new data, displacing the old */
+		zap = key->payload.data;
+		key->payload.data = new;
+		key->expiry = 0;
+	}
+
+	write_unlock(&key->lock);
+	kfree(zap);
+
+ error:
+	return ret;
+
+} /* end user_update() */
+
+/*****************************************************************************/
+/*
+ * match users on their name
+ */
+static int user_match(const struct key *key, const void *description)
+{
+	return strcmp(key->description, description) == 0;
+
+} /* end user_match() */
+
+/*****************************************************************************/
+/*
+ * dispose of the data dangling from the corpse of a user
+ */
+static void user_destroy(struct key *key)
+{
+	kfree(key->payload.data);
+
+} /* end user_destroy() */
+
+/*****************************************************************************/
+/*
+ * describe the user
+ */
+static void user_describe(const struct key *key, struct seq_file *m)
+{
+	seq_puts(m, key->description);
+
+	seq_printf(m, ": %u", key->datalen);
+
+} /* end user_describe() */
+
+/*****************************************************************************/
+/*
+ * read the key data
+ */
+static long user_read(const struct key *key,
+		      char __user *buffer, size_t buflen)
+{
+	long ret = key->datalen;
+
+	/* we can return the data as is */
+	if (buffer && buflen > 0) {
+		if (buflen > key->datalen)
+			buflen = key->datalen;
+
+		if (copy_to_user(buffer, key->payload.data, buflen) != 0)
+			ret = -EFAULT;
+	}
+
+	return ret;
+
+} /* end user_read() */
diff -Nru a/security/seclvl.c b/security/seclvl.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/security/seclvl.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,747 @@
+/**
+ * BSD Secure Levels LSM
+ *
+ * Maintainers:
+ *	Michael A. Halcrow <mike@halcrow.us>
+ *	Serge Hallyn <hallyn@cs.wm.edu>
+ *
+ * Copyright (c) 2001 WireX Communications, Inc <chris@wirex.com>
+ * Copyright (c) 2001 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (c) 2002 International Business Machines <robb@austin.ibm.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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/security.h>
+#include <linux/netlink.h>
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/mount.h>
+#include <linux/capability.h>
+#include <linux/time.h>
+#include <linux/proc_fs.h>
+#include <linux/kobject.h>
+#include <linux/crypto.h>
+#include <asm/scatterlist.h>
+#include <linux/gfp.h>
+#include <linux/sysfs.h>
+
+#define SHA1_DIGEST_SIZE 20
+
+/**
+ * Module parameter that defines the initial secure level.
+ *
+ * When built as a module, it defaults to seclvl 1, which is the
+ * behavior of BSD secure levels.  Note that this default behavior
+ * wrecks havoc on a machine when the seclvl module is compiled into
+ * the kernel.	In that case, we default to seclvl 0.
+ */
+#ifdef CONFIG_SECURITY_SECLVL_MODULE
+static int initlvl = 1;
+#else
+static int initlvl;
+#endif
+module_param(initlvl, int, 0);
+MODULE_PARM_DESC(initlvl, "Initial secure level (defaults to 1)");
+
+/* Module parameter that defines the verbosity level */
+static int verbosity;
+module_param(verbosity, int, 0);
+MODULE_PARM_DESC(verbosity, "Initial verbosity level (0 or 1; defaults to "
+		 "0, which is Quiet)");
+
+/**
+ * Optional password which can be passed in to bring seclvl to 0
+ * (i.e., for halt/reboot).  Defaults to NULL (the passwd attribute
+ * file will not be registered in sysfs).
+ *
+ * This gets converted to its SHA1 hash when stored.  It's probably
+ * not a good idea to use this parameter when loading seclvl from a
+ * script; use sha1_passwd instead.
+ */
+
+#define MAX_PASSWD_SIZE	32
+static char passwd[MAX_PASSWD_SIZE];
+module_param_string(passwd, passwd, sizeof(passwd), 0);
+MODULE_PARM_DESC(passwd,
+		 "Plaintext of password that sets seclvl=0 when written to "
+		 "(sysfs mount point)/seclvl/passwd\n");
+
+/**
+ * SHA1 hashed version of the optional password which can be passed in
+ * to bring seclvl to 0 (i.e., for halt/reboot).  Must be in
+ * hexadecimal format (40 characters).	Defaults to NULL (the passwd
+ * attribute file will not be registered in sysfs).
+ *
+ * Use the sha1sum utility to generate the SHA1 hash of a password:
+ *
+ * echo -n "secret" | sha1sum
+ */
+#define MAX_SHA1_PASSWD	41
+static char sha1_passwd[MAX_SHA1_PASSWD];
+module_param_string(sha1_passwd, sha1_passwd, sizeof(sha1_passwd), 0);
+MODULE_PARM_DESC(sha1_passwd,
+		 "SHA1 hash (40 hexadecimal characters) of password that "
+		 "sets seclvl=0 when plaintext password is written to "
+		 "(sysfs mount point)/seclvl/passwd\n");
+
+static int hideHash = 1;
+module_param(hideHash, int, 0);
+MODULE_PARM_DESC(hideHash, "When set to 0, reading seclvl/passwd from sysfs "
+		 "will return the SHA1-hashed value of the password that "
+		 "lowers the secure level to 0.\n");
+
+#define MY_NAME "seclvl"
+
+/**
+ * This time-limits log writes to one per second.
+ */
+#define seclvl_printk(verb, type, fmt, arg...)			\
+	do {							\
+		if (verbosity >= verb) {			\
+			static unsigned long _prior;		\
+			unsigned long _now = jiffies;		\
+			if ((_now - _prior) > HZ) {		\
+				printk(type "%s: %s: " fmt,	\
+					MY_NAME, __FUNCTION__ ,	\
+					## arg);		\
+				_prior = _now;			\
+			}					\
+		}						\
+	} while (0)
+
+/**
+ * kobject stuff
+ */
+
+struct subsystem seclvl_subsys;
+
+struct seclvl_obj {
+	char *name;
+	struct list_head slot_list;
+	struct kobject kobj;
+};
+
+/**
+ * There is a seclvl_attribute struct for each file in sysfs.
+ *
+ * In our case, we have one of these structs for "passwd" and another
+ * for "seclvl".
+ */
+struct seclvl_attribute {
+	struct attribute attr;
+	ssize_t(*show) (struct seclvl_obj *, char *);
+	ssize_t(*store) (struct seclvl_obj *, const char *, size_t);
+};
+
+/**
+ * When this function is called, one of the files in sysfs is being
+ * written to.  attribute->store is a function pointer to whatever the
+ * struct seclvl_attribute store function pointer points to.  It is
+ * unique for "passwd" and "seclvl".
+ */
+static ssize_t
+seclvl_attr_store(struct kobject *kobj,
+		  struct attribute *attr, const char *buf, size_t len)
+{
+	struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj);
+	struct seclvl_attribute *attribute =
+	    container_of(attr, struct seclvl_attribute, attr);
+	return (attribute->store ? attribute->store(obj, buf, len) : 0);
+}
+
+static ssize_t
+seclvl_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+	struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj);
+	struct seclvl_attribute *attribute =
+	    container_of(attr, struct seclvl_attribute, attr);
+	return (attribute->show ? attribute->show(obj, buf) : 0);
+}
+
+/**
+ * Callback function pointers for show and store
+ */
+struct sysfs_ops seclvlfs_sysfs_ops = {
+	.show = seclvl_attr_show,
+	.store = seclvl_attr_store,
+};
+
+static struct kobj_type seclvl_ktype = {
+	.sysfs_ops = &seclvlfs_sysfs_ops
+};
+
+decl_subsys(seclvl, &seclvl_ktype, NULL);
+
+/**
+ * The actual security level.  Ranges between -1 and 2 inclusive.
+ */
+static int seclvl;
+
+/**
+ * flag to keep track of how we were registered
+ */
+static int secondary;
+
+/**
+ * Verifies that the requested secure level is valid, given the current
+ * secure level.
+ */
+static int seclvl_sanity(int reqlvl)
+{
+	if ((reqlvl < -1) || (reqlvl > 2)) {
+		seclvl_printk(1, KERN_WARNING, "Attempt to set seclvl out of "
+			      "range: [%d]\n", reqlvl);
+		return -EINVAL;
+	}
+	if ((seclvl == 0) && (reqlvl == -1))
+		return 0;
+	if (reqlvl < seclvl) {
+		seclvl_printk(1, KERN_WARNING, "Attempt to lower seclvl to "
+			      "[%d]\n", reqlvl);
+		return -EPERM;
+	}
+	return 0;
+}
+
+/**
+ * Called whenever the user reads the sysfs handle to this kernel
+ * object
+ */
+static ssize_t seclvl_read_file(struct seclvl_obj *obj, char *buff)
+{
+	return snprintf(buff, PAGE_SIZE, "%d\n", seclvl);
+}
+
+/**
+ * security level advancement rules:
+ *   Valid levels are -1 through 2, inclusive.
+ *   From -1, stuck.  [ in case compiled into kernel ]
+ *   From 0 or above, can only increment.
+ */
+static int do_seclvl_advance(int newlvl)
+{
+	if (newlvl <= seclvl) {
+		seclvl_printk(1, KERN_WARNING, "Cannot advance to seclvl "
+			      "[%d]\n", newlvl);
+		return -EINVAL;
+	}
+	if (newlvl > 2) {
+		seclvl_printk(1, KERN_WARNING, "Cannot advance to seclvl "
+			      "[%d]\n", newlvl);
+		return -EINVAL;
+	}
+	if (seclvl == -1) {
+		seclvl_printk(1, KERN_WARNING, "Not allowed to advance to "
+			      "seclvl [%d]\n", seclvl);
+		return -EPERM;
+	}
+	seclvl = newlvl;
+	return 0;
+}
+
+/**
+ * Called whenever the user writes to the sysfs handle to this kernel
+ * object (seclvl/seclvl).  It expects a single-digit number.
+ */
+static ssize_t
+seclvl_write_file(struct seclvl_obj *obj, const char *buff, size_t count)
+{
+	unsigned long val;
+	if (count > 2 || (count == 2 && buff[1] != '\n')) {
+		seclvl_printk(1, KERN_WARNING, "Invalid value passed to "
+			      "seclvl: [%s]\n", buff);
+		return -EINVAL;
+	}
+	val = buff[0] - 48;
+	if (seclvl_sanity(val)) {
+		seclvl_printk(1, KERN_WARNING, "Illegal secure level "
+			      "requested: [%d]\n", (int)val);
+		return -EPERM;
+	}
+	if (do_seclvl_advance(val)) {
+		seclvl_printk(0, KERN_ERR, "Failure advancing security level "
+			      "to %lu\n", val);
+	}
+	return count;
+}
+
+/* Generate sysfs_attr_seclvl */
+struct seclvl_attribute sysfs_attr_seclvl =
+__ATTR(seclvl, (S_IFREG | S_IRUGO | S_IWUSR), seclvl_read_file,
+       seclvl_write_file);
+
+static unsigned char hashedPassword[SHA1_DIGEST_SIZE];
+
+/**
+ * Called whenever the user reads the sysfs passwd handle.
+ */
+static ssize_t seclvl_read_passwd(struct seclvl_obj *obj, char *buff)
+{
+	/* So just how good *is* your password? :-) */
+	char tmp[3];
+	int i = 0;
+	buff[0] = '\0';
+	if (hideHash) {
+		/* Security through obscurity */
+		return 0;
+	}
+	while (i < SHA1_DIGEST_SIZE) {
+		snprintf(tmp, 3, "%02x", hashedPassword[i]);
+		strncat(buff, tmp, 2);
+		i++;
+	}
+	strcat(buff, "\n");
+	return ((SHA1_DIGEST_SIZE * 2) + 1);
+}
+
+/**
+ * Converts a block of plaintext of into its SHA1 hashed value.
+ *
+ * It would be nice if crypto had a wrapper to do this for us linear
+ * people...
+ */
+static int
+plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len)
+{
+	char *pgVirtAddr;
+	struct crypto_tfm *tfm;
+	struct scatterlist sg[1];
+	if (len > PAGE_SIZE) {
+		seclvl_printk(0, KERN_ERR, "Plaintext password too large (%d "
+			      "characters).  Largest possible is %lu "
+			      "bytes.\n", len, PAGE_SIZE);
+		return -ENOMEM;
+	}
+	tfm = crypto_alloc_tfm("sha1", 0);
+	if (tfm == NULL) {
+		seclvl_printk(0, KERN_ERR,
+			      "Failed to load transform for SHA1\n");
+		return -ENOSYS;
+	}
+	// Just get a new page; don't play around with page boundaries
+	// and scatterlists.
+	pgVirtAddr = (char *)__get_free_page(GFP_KERNEL);
+	sg[0].page = virt_to_page(pgVirtAddr);
+	sg[0].offset = 0;
+	sg[0].length = len;
+	strncpy(pgVirtAddr, plaintext, len);
+	crypto_digest_init(tfm);
+	crypto_digest_update(tfm, sg, 1);
+	crypto_digest_final(tfm, hash);
+	crypto_free_tfm(tfm);
+	free_page((unsigned long)pgVirtAddr);
+	return 0;
+}
+
+/**
+ * Called whenever the user writes to the sysfs passwd handle to this kernel
+ * object.  It hashes the password and compares the hashed results.
+ */
+static ssize_t
+seclvl_write_passwd(struct seclvl_obj *obj, const char *buff, size_t count)
+{
+	int i;
+	unsigned char tmp[SHA1_DIGEST_SIZE];
+	int rc;
+	int len;
+	if (!*passwd && !*sha1_passwd) {
+		seclvl_printk(0, KERN_ERR, "Attempt to password-unlock the "
+			      "seclvl module, but neither a plain text "
+			      "password nor a SHA1 hashed password was "
+			      "passed in as a module parameter!  This is a "
+			      "bug, since it should not be possible to be in "
+			      "this part of the module; please tell a "
+			      "maintainer about this event.\n");
+		return -EINVAL;
+	}
+	len = strlen(buff);
+	/* ``echo "secret" > seclvl/passwd'' includes a newline */
+	if (buff[len - 1] == '\n') {
+		len--;
+	}
+	/* Hash the password, then compare the hashed values */
+	if ((rc = plaintext_to_sha1(tmp, buff, len))) {
+		seclvl_printk(0, KERN_ERR, "Error hashing password: rc = "
+			      "[%d]\n", rc);
+		return rc;
+	}
+	for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
+		if (hashedPassword[i] != tmp[i]) {
+			return -EPERM;
+		}
+	}
+	seclvl_printk(0, KERN_INFO,
+		      "Password accepted; seclvl reduced to 0.\n");
+	seclvl = 0;
+	return count;
+}
+
+/* Generate sysfs_attr_passwd */
+struct seclvl_attribute sysfs_attr_passwd =
+__ATTR(passwd, (S_IFREG | S_IRUGO | S_IWUSR), seclvl_read_passwd,
+       seclvl_write_passwd);
+
+/**
+ * Explicitely disallow ptrace'ing the init process.
+ */
+static int seclvl_ptrace(struct task_struct *parent, struct task_struct *child)
+{
+	if (seclvl >= 0) {
+		if (child->pid == 1) {
+			seclvl_printk(1, KERN_WARNING, "Attempt to ptrace "
+				      "the init process dissallowed in "
+				      "secure level %d\n", seclvl);
+			return -EPERM;
+		}
+	}
+	return 0;
+}
+
+/**
+ * Capability checks for seclvl.  The majority of the policy
+ * enforcement for seclvl takes place here.
+ */
+static int seclvl_capable(struct task_struct *tsk, int cap)
+{
+	/* init can do anything it wants */
+	if (tsk->pid == 1)
+		return 0;
+
+	switch (seclvl) {
+	case 2:
+		/* fall through */
+	case 1:
+		if (cap == CAP_LINUX_IMMUTABLE) {
+			seclvl_printk(1, KERN_WARNING, "Attempt to modify "
+				      "the IMMUTABLE and/or APPEND extended "
+				      "attribute on a file with the IMMUTABLE "
+				      "and/or APPEND extended attribute set "
+				      "denied in seclvl [%d]\n", seclvl);
+			return -EPERM;
+		} else if (cap == CAP_SYS_RAWIO) {	// Somewhat broad...
+			seclvl_printk(1, KERN_WARNING, "Attempt to perform "
+				      "raw I/O while in secure level [%d] "
+				      "denied\n", seclvl);
+			return -EPERM;
+		} else if (cap == CAP_NET_ADMIN) {
+			seclvl_printk(1, KERN_WARNING, "Attempt to perform "
+				      "network administrative task while "
+				      "in secure level [%d] denied\n", seclvl);
+			return -EPERM;
+		} else if (cap == CAP_SETUID) {
+			seclvl_printk(1, KERN_WARNING, "Attempt to setuid "
+				      "while in secure level [%d] denied\n",
+				      seclvl);
+			return -EPERM;
+		} else if (cap == CAP_SETGID) {
+			seclvl_printk(1, KERN_WARNING, "Attempt to setgid "
+				      "while in secure level [%d] denied\n",
+				      seclvl);
+		} else if (cap == CAP_SYS_MODULE) {
+			seclvl_printk(1, KERN_WARNING, "Attempt to perform "
+				      "a module operation while in secure "
+				      "level [%d] denied\n", seclvl);
+			return -EPERM;
+		}
+		break;
+	default:
+		break;
+	}
+	/* from dummy.c */
+	if (cap_is_fs_cap(cap) ? tsk->fsuid == 0 : tsk->euid == 0)
+		return 0;	/* capability granted */
+	seclvl_printk(1, KERN_WARNING, "Capability denied\n");
+	return -EPERM;		/* capability denied */
+}
+
+/**
+ * Disallow reversing the clock in seclvl > 1
+ */
+static int seclvl_settime(struct timespec *tv, struct timezone *tz)
+{
+	struct timespec now;
+	if (seclvl > 1) {
+		now = current_kernel_time();
+		if (tv->tv_sec < now.tv_sec ||
+		    (tv->tv_sec == now.tv_sec && tv->tv_nsec < now.tv_nsec)) {
+			seclvl_printk(1, KERN_WARNING, "Attempt to decrement "
+				      "time in secure level %d denied: "
+				      "current->pid = [%d], "
+				      "current->group_leader->pid = [%d]\n",
+				      seclvl, current->pid,
+				      current->group_leader->pid);
+			return -EPERM;
+		}		/* if attempt to decrement time */
+	}			/* if seclvl > 1 */
+	return 0;
+}
+
+/* claim the blockdev to exclude mounters, release on file close */
+static int seclvl_bd_claim(struct inode *inode)
+{
+	int holder;
+	struct block_device *bdev = NULL;
+	dev_t dev = inode->i_rdev;
+	bdev = open_by_devnum(dev, FMODE_WRITE);
+	if (bdev) {
+		if (bd_claim(bdev, &holder)) {
+			blkdev_put(bdev);
+			return -EPERM;
+		}
+		/* claimed, mark it to release on close */
+		inode->i_security = current;
+	}
+	return 0;
+}
+
+/* release the blockdev if you claimed it */
+static void seclvl_bd_release(struct inode *inode)
+{
+	if (inode && S_ISBLK(inode->i_mode) && inode->i_security == current) {
+		struct block_device *bdev = inode->i_bdev;
+		if (bdev) {
+			bd_release(bdev);
+			blkdev_put(bdev);
+			inode->i_security = NULL;
+		}
+	}
+}
+
+/**
+ * Security for writes to block devices is regulated by this seclvl
+ * function.  Deny all writes to block devices in seclvl 2.  In
+ * seclvl 1, we only deny writes to *mounted* block devices.
+ */
+static int
+seclvl_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+	if (current->pid != 1 && S_ISBLK(inode->i_mode) && (mask & MAY_WRITE)) {
+		switch (seclvl) {
+		case 2:
+			seclvl_printk(1, KERN_WARNING, "Write to block device "
+				      "denied in secure level [%d]\n", seclvl);
+			return -EPERM;
+		case 1:
+			if (seclvl_bd_claim(inode)) {
+				seclvl_printk(1, KERN_WARNING,
+					      "Write to mounted block device "
+					      "denied in secure level [%d]\n",
+					      seclvl);
+				return -EPERM;
+			}
+		}
+	}
+	return 0;
+}
+
+/**
+ * The SUID and SGID bits cannot be set in seclvl >= 1
+ */
+static int seclvl_inode_setattr(struct dentry *dentry, struct iattr *iattr)
+{
+	if (seclvl > 0) {
+		if (iattr->ia_valid & ATTR_MODE)
+			if (iattr->ia_mode & S_ISUID ||
+			    iattr->ia_mode & S_ISGID) {
+				seclvl_printk(1, KERN_WARNING, "Attempt to "
+					      "modify SUID or SGID bit "
+					      "denied in seclvl [%d]\n",
+					      seclvl);
+				return -EPERM;
+			}
+	}
+	return 0;
+}
+
+/* release busied block devices */
+static void seclvl_file_free_security(struct file *filp)
+{
+	struct dentry *dentry = filp->f_dentry;
+	struct inode *inode = NULL;
+
+	if (dentry) {
+		inode = dentry->d_inode;
+		seclvl_bd_release(inode);
+	}
+}
+
+/**
+ * Cannot unmount in secure level 2
+ */
+static int seclvl_umount(struct vfsmount *mnt, int flags)
+{
+	if (current->pid == 1) {
+		return 0;
+	}
+	if (seclvl == 2) {
+		seclvl_printk(1, KERN_WARNING, "Attempt to unmount in secure "
+			      "level %d\n", seclvl);
+		return -EPERM;
+	}
+	return 0;
+}
+
+static struct security_operations seclvl_ops = {
+	.ptrace = seclvl_ptrace,
+	.capable = seclvl_capable,
+	.inode_permission = seclvl_inode_permission,
+	.inode_setattr = seclvl_inode_setattr,
+	.file_free_security = seclvl_file_free_security,
+	.settime = seclvl_settime,
+	.sb_umount = seclvl_umount,
+};
+
+/**
+ * Process the password-related module parameters
+ */
+static int processPassword(void)
+{
+	int rc = 0;
+	hashedPassword[0] = '\0';
+	if (*passwd) {
+		if (*sha1_passwd) {
+			seclvl_printk(0, KERN_ERR, "Error: Both "
+				      "passwd and sha1_passwd "
+				      "were set, but they are mutually "
+				      "exclusive.\n");
+			return -EINVAL;
+		}
+		if ((rc = plaintext_to_sha1(hashedPassword, passwd,
+					    strlen(passwd)))) {
+			seclvl_printk(0, KERN_ERR, "Error: SHA1 support not "
+				      "in kernel\n");
+			return rc;
+		}
+		/* All static data goes to the BSS, which zero's the
+		 * plaintext password out for us. */
+	} else if (*sha1_passwd) {	// Base 16
+		int i;
+		i = strlen(sha1_passwd);
+		if (i != (SHA1_DIGEST_SIZE * 2)) {
+			seclvl_printk(0, KERN_ERR, "Received [%d] bytes; "
+				      "expected [%d] for the hexadecimal "
+				      "representation of the SHA1 hash of "
+				      "the password.\n",
+				      i, (SHA1_DIGEST_SIZE * 2));
+			return -EINVAL;
+		}
+		while ((i -= 2) + 2) {
+			unsigned char tmp;
+			tmp = sha1_passwd[i + 2];
+			sha1_passwd[i + 2] = '\0';
+			hashedPassword[i / 2] = (unsigned char)
+			    simple_strtol(&sha1_passwd[i], NULL, 16);
+			sha1_passwd[i + 2] = tmp;
+		}
+	}
+	return 0;
+}
+
+/**
+ * Sysfs registrations
+ */
+static int doSysfsRegistrations(void)
+{
+	int rc = 0;
+	if ((rc = subsystem_register(&seclvl_subsys))) {
+		seclvl_printk(0, KERN_WARNING,
+			      "Error [%d] registering seclvl subsystem\n", rc);
+		return rc;
+	}
+	sysfs_create_file(&seclvl_subsys.kset.kobj, &sysfs_attr_seclvl.attr);
+	if (*passwd || *sha1_passwd) {
+		sysfs_create_file(&seclvl_subsys.kset.kobj,
+				  &sysfs_attr_passwd.attr);
+	}
+	return 0;
+}
+
+/**
+ * Initialize the seclvl module.
+ */
+static int __init seclvl_init(void)
+{
+	int rc = 0;
+	if (verbosity < 0 || verbosity > 1) {
+		printk(KERN_ERR "Error: bad verbosity [%d]; only 0 or 1 "
+		       "are valid values\n", verbosity);
+		rc = -EINVAL;
+		goto exit;
+	}
+	sysfs_attr_seclvl.attr.owner = THIS_MODULE;
+	sysfs_attr_passwd.attr.owner = THIS_MODULE;
+	if (initlvl < -1 || initlvl > 2) {
+		seclvl_printk(0, KERN_ERR, "Error: bad initial securelevel "
+			      "[%d].\n", initlvl);
+		rc = -EINVAL;
+		goto exit;
+	}
+	seclvl = initlvl;
+	if ((rc = processPassword())) {
+		seclvl_printk(0, KERN_ERR, "Error processing the password "
+			      "module parameter(s): rc = [%d]\n", rc);
+		goto exit;
+	}
+	/* register ourselves with the security framework */
+	if (register_security(&seclvl_ops)) {
+		seclvl_printk(0, KERN_ERR,
+			      "seclvl: Failure registering with the "
+			      "kernel.\n");
+		/* try registering with primary module */
+		rc = mod_reg_security(MY_NAME, &seclvl_ops);
+		if (rc) {
+			seclvl_printk(0, KERN_ERR, "seclvl: Failure "
+				      "registering with primary security "
+				      "module.\n");
+			goto exit;
+		}		/* if primary module registered */
+		secondary = 1;
+	}			/* if we registered ourselves with the security framework */
+	if ((rc = doSysfsRegistrations())) {
+		seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n");
+		goto exit;
+	}
+	seclvl_printk(0, KERN_INFO, "seclvl: Successfully initialized.\n");
+ exit:
+	if (rc) {
+		printk(KERN_ERR "seclvl: Error during initialization: rc = "
+		       "[%d]\n", rc);
+	}
+	return rc;
+}
+
+/**
+ * Remove the seclvl module.
+ */
+static void __exit seclvl_exit(void)
+{
+	sysfs_remove_file(&seclvl_subsys.kset.kobj, &sysfs_attr_seclvl.attr);
+	if (*passwd || *sha1_passwd) {
+		sysfs_remove_file(&seclvl_subsys.kset.kobj,
+				  &sysfs_attr_passwd.attr);
+	}
+	subsystem_unregister(&seclvl_subsys);
+	if (secondary == 1) {
+		mod_unreg_security(MY_NAME, &seclvl_ops);
+	} else if (unregister_security(&seclvl_ops)) {
+		seclvl_printk(0, KERN_INFO,
+			      "seclvl: Failure unregistering with the "
+			      "kernel\n");
+	}
+}
+
+module_init(seclvl_init);
+module_exit(seclvl_exit);
+
+MODULE_AUTHOR("Michael A. Halcrow <mike@halcrow.us>");
+MODULE_DESCRIPTION("LSM implementation of the BSD Secure Levels");
+MODULE_LICENSE("GPL");
diff -Nru a/security/security.c b/security/security.c
--- a/security/security.c	2004-12-24 13:36:16 -08:00
+++ b/security/security.c	2004-12-24 13:36:16 -08:00
@@ -18,23 +18,20 @@
 #include <linux/sched.h>
 #include <linux/security.h>
 
-#define SECURITY_SCAFFOLD_VERSION	"1.0.0"
+#define SECURITY_FRAMEWORK_VERSION	"1.0.0"
 
 /* things that live in dummy.c */
 extern struct security_operations dummy_security_ops;
-extern void security_fixup_ops (struct security_operations *ops);
+extern void security_fixup_ops(struct security_operations *ops);
 
 struct security_operations *security_ops;	/* Initialized to NULL */
 
-static inline int verify (struct security_operations *ops)
+static inline int verify(struct security_operations *ops)
 {
 	/* verify the security_operations structure exists */
-	if (!ops) {
-		printk (KERN_INFO "Passed a NULL security_operations "
-			"pointer, %s failed.\n", __FUNCTION__);
+	if (!ops)
 		return -EINVAL;
-	}
-	security_fixup_ops (ops);
+	security_fixup_ops(ops);
 	return 0;
 }
 
@@ -43,24 +40,24 @@
 	initcall_t *call;
 	call = &__security_initcall_start;
 	while (call < &__security_initcall_end) {
-		(*call)();
+		(*call) ();
 		call++;
 	}
 }
 
 /**
- * security_scaffolding_startup - initializes the security scaffolding framework
+ * security_init - initializes the security framework
  *
  * This should be called early in the kernel initialization sequence.
  */
-int __init security_scaffolding_startup (void)
+int __init security_init(void)
 {
-	printk (KERN_INFO "Security Scaffold v" SECURITY_SCAFFOLD_VERSION
-		" initialized\n");
+	printk(KERN_INFO "Security Framework v" SECURITY_FRAMEWORK_VERSION
+	       " initialized\n");
 
-	if (verify (&dummy_security_ops)) {
-		printk (KERN_ERR "%s could not verify "
-			"dummy_security_ops structure.\n", __FUNCTION__);
+	if (verify(&dummy_security_ops)) {
+		printk(KERN_ERR "%s could not verify "
+		       "dummy_security_ops structure.\n", __FUNCTION__);
 		return -EIO;
 	}
 
@@ -82,19 +79,16 @@
  * If there is already a security module registered with the kernel,
  * an error will be returned.  Otherwise 0 is returned on success.
  */
-int register_security (struct security_operations *ops)
+int register_security(struct security_operations *ops)
 {
-	if (verify (ops)) {
-		printk (KERN_INFO "%s could not verify "
-			"security_operations structure.\n", __FUNCTION__);
+	if (verify(ops)) {
+		printk(KERN_DEBUG "%s could not verify "
+		       "security_operations structure.\n", __FUNCTION__);
 		return -EINVAL;
 	}
 
-	if (security_ops != &dummy_security_ops) {
-		printk (KERN_INFO "There is already a security "
-			"framework initialized, %s failed.\n", __FUNCTION__);
-		return -EINVAL;
-	}
+	if (security_ops != &dummy_security_ops)
+		return -EAGAIN;
 
 	security_ops = ops;
 
@@ -112,12 +106,12 @@
  * an error is returned.  Otherwise the default security options is set to the
  * the dummy_security_ops structure, and 0 is returned.
  */
-int unregister_security (struct security_operations *ops)
+int unregister_security(struct security_operations *ops)
 {
 	if (ops != security_ops) {
-		printk (KERN_INFO "%s: trying to unregister "
-			"a security_opts structure that is not "
-			"registered, failing.\n", __FUNCTION__);
+		printk(KERN_INFO "%s: trying to unregister "
+		       "a security_opts structure that is not "
+		       "registered, failing.\n", __FUNCTION__);
 		return -EINVAL;
 	}
 
@@ -138,21 +132,21 @@
  * The return value depends on the currently loaded security module, with 0 as
  * success.
  */
-int mod_reg_security (const char *name, struct security_operations *ops)
+int mod_reg_security(const char *name, struct security_operations *ops)
 {
-	if (verify (ops)) {
-		printk (KERN_INFO "%s could not verify "
-			"security operations.\n", __FUNCTION__);
+	if (verify(ops)) {
+		printk(KERN_INFO "%s could not verify "
+		       "security operations.\n", __FUNCTION__);
 		return -EINVAL;
 	}
 
 	if (ops == security_ops) {
-		printk (KERN_INFO "%s security operations "
-			"already registered.\n", __FUNCTION__);
+		printk(KERN_INFO "%s security operations "
+		       "already registered.\n", __FUNCTION__);
 		return -EINVAL;
 	}
 
-	return security_ops->register_security (name, ops);
+	return security_ops->register_security(name, ops);
 }
 
 /**
@@ -168,15 +162,15 @@
  * The return value depends on the currently loaded security module, with 0 as
  * success.
  */
-int mod_unreg_security (const char *name, struct security_operations *ops)
+int mod_unreg_security(const char *name, struct security_operations *ops)
 {
 	if (ops == security_ops) {
-		printk (KERN_INFO "%s invalid attempt to unregister "
-			" primary security ops.\n", __FUNCTION__);
+		printk(KERN_INFO "%s invalid attempt to unregister "
+		       " primary security ops.\n", __FUNCTION__);
 		return -EINVAL;
 	}
 
-	return security_ops->unregister_security (name, ops);
+	return security_ops->unregister_security(name, ops);
 }
 
 /**
@@ -189,9 +183,9 @@
  * This allows the security module to implement the capable function call
  * however it chooses to.
  */
-int capable (int cap)
+int capable(int cap)
 {
-	if (security_ops->capable (current, cap)) {
+	if (security_ops->capable(current, cap)) {
 		/* capability denied */
 		return 0;
 	}
diff -Nru a/security/selinux/hooks.c b/security/selinux/hooks.c
--- a/security/selinux/hooks.c	2004-12-24 13:37:29 -08:00
+++ b/security/selinux/hooks.c	2004-12-24 13:37:29 -08:00
@@ -64,6 +64,7 @@
 #include <net/ipv6.h>
 #include <linux/hugetlb.h>
 #include <linux/personality.h>
+#include <linux/sysctl.h>
 
 #include "avc.h"
 #include "objsec.h"
@@ -386,13 +387,6 @@
 				break;
 
 			case Opt_fscontext:
-				if (sbsec->behavior != SECURITY_FS_USE_XATTR) {
-					rc = -EINVAL;
-					printk(KERN_WARNING "SELinux:  "
-					       "fscontext option is invalid for"
-					       " this filesystem type\n");
-					goto out_free;
-				}
 				if (seen & (Opt_context|Opt_fscontext)) {
 					rc = -EINVAL;
 					printk(KERN_WARNING SEL_MOUNT_FAIL_MSG);
@@ -637,10 +631,12 @@
 	case PF_UNIX:
 		switch (type) {
 		case SOCK_STREAM:
+		case SOCK_SEQPACKET:
 			return SECCLASS_UNIX_STREAM_SOCKET;
 		case SOCK_DGRAM:
 			return SECCLASS_UNIX_DGRAM_SOCKET;
 		}
+		break;
 	case PF_INET:
 	case PF_INET6:
 		switch (type) {
@@ -651,6 +647,7 @@
 		case SOCK_RAW:
 			return SECCLASS_RAWIP_SOCKET;
 		}
+		break;
 	case PF_NETLINK:
 		switch (protocol) {
 		case NETLINK_ROUTE:
@@ -1909,8 +1906,8 @@
 				  PROCESS__RLIMITINH, NULL, NULL);
 		if (rc) {
 			for (i = 0; i < RLIM_NLIMITS; i++) {
-				rlim = current->rlim + i;
-				initrlim = init_task.rlim+i;
+				rlim = current->signal->rlim + i;
+				initrlim = init_task.signal->rlim+i;
 				rlim->rlim_cur = min(rlim->rlim_max,initrlim->rlim_cur);
 			}
 		}
@@ -2243,6 +2240,9 @@
 	if (sbsec->behavior == SECURITY_FS_USE_MNTPOINT)
 		return -EOPNOTSUPP;
 
+	if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
+		return -EPERM;
+
 	AVC_AUDIT_DATA_INIT(&ad,FS);
 	ad.u.fs.dentry = dentry;
 
@@ -2331,9 +2331,8 @@
 	return -EACCES;
 }
 
-static int selinux_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
+static int selinux_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
 {
-	struct inode *inode = dentry->d_inode;
 	struct inode_security_struct *isec = inode->i_security;
 	char *context;
 	unsigned len;
@@ -2361,10 +2360,9 @@
 	return len;
 }
 
-static int selinux_inode_setsecurity(struct dentry *dentry, const char *name,
+static int selinux_inode_setsecurity(struct inode *inode, const char *name,
                                      const void *value, size_t size, int flags)
 {
-	struct inode *inode = dentry->d_inode;
 	struct inode_security_struct *isec = inode->i_security;
 	u32 newsid;
 	int rc;
@@ -2383,10 +2381,10 @@
 	return 0;
 }
 
-static int selinux_inode_listsecurity(struct dentry *dentry, char *buffer)
+static int selinux_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
 {
 	const int len = sizeof(XATTR_NAME_SELINUX);
-	if (buffer)
+	if (buffer && len <= buffer_size)
 		memcpy(buffer, XATTR_NAME_SELINUX, len);
 	return len;
 }
@@ -2570,8 +2568,7 @@
 }
 
 static int selinux_file_send_sigiotask(struct task_struct *tsk,
-				       struct fown_struct *fown,
-				       int fd, int reason)
+				       struct fown_struct *fown, int signum)
 {
         struct file *file;
 	u32 perm;
@@ -2584,10 +2581,10 @@
 	tsec = tsk->security;
 	fsec = file->f_security;
 
-	if (!fown->signum)
+	if (!signum)
 		perm = signal_to_av(SIGIO); /* as per send_sigio_to_task */
 	else
-		perm = signal_to_av(fown->signum);
+		perm = signal_to_av(signum);
 
 	return avc_has_perm(fsec->fown_sid, tsec->sid,
 			    SECCLASS_PROCESS, perm, NULL, NULL);
@@ -2699,7 +2696,7 @@
 
 static int selinux_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)
 {
-	struct rlimit *old_rlim = current->rlim + resource;
+	struct rlimit *old_rlim = current->signal->rlim + resource;
 	int rc;
 
 	rc = secondary_ops->task_setrlimit(resource, new_rlim);
@@ -3249,13 +3246,11 @@
 	u16 family;
 	char *addrp;
 	int len, err = 0;
-	u32 netif_perm, node_perm, node_sid, recv_perm = 0;
+	u32 netif_perm, node_perm, node_sid, if_sid, recv_perm = 0;
 	u32 sock_sid = 0;
 	u16 sock_class = 0;
 	struct socket *sock;
 	struct net_device *dev;
-	struct sel_netif *netif;
-	struct netif_security_struct *nsec;
 	struct avc_audit_data ad;
 
 	family = sk->sk_family;
@@ -3286,13 +3281,9 @@
 	if (!dev)
 		goto out;
 
-	netif = sel_netif_lookup(dev);
-	if (IS_ERR(netif)) {
-		err = PTR_ERR(netif);
+	err = sel_netif_sids(dev, &if_sid, NULL);
+	if (err)
 		goto out;
-	}
-	
-	nsec = &netif->nsec;
 
 	switch (sock_class) {
 	case SECCLASS_UDP_SOCKET:
@@ -3318,14 +3309,11 @@
 	ad.u.net.family = family;
 
 	err = selinux_parse_skb(skb, &ad, &addrp, &len, 1);
-	if (err) {
-		sel_netif_put(netif);
+	if (err)
 		goto out;
-	}
 
-	err = avc_has_perm(sock_sid, nsec->if_sid, SECCLASS_NETIF,
-	                   netif_perm, &nsec->avcr, &ad);
-	sel_netif_put(netif);
+	err = avc_has_perm(sock_sid, if_sid, SECCLASS_NETIF,
+	                   netif_perm, NULL, &ad);
 	if (err)
 		goto out;
 	
@@ -3441,13 +3429,11 @@
 {
 	char *addrp;
 	int len, err = NF_ACCEPT;
-	u32 netif_perm, node_perm, node_sid, send_perm = 0;
+	u32 netif_perm, node_perm, node_sid, if_sid, send_perm = 0;
 	struct sock *sk;
 	struct socket *sock;
 	struct inode *inode;
-	struct sel_netif *netif;
 	struct sk_buff *skb = *pskb;
-	struct netif_security_struct *nsec;
 	struct inode_security_struct *isec;
 	struct avc_audit_data ad;
 	struct net_device *dev = (struct net_device *)out;
@@ -3464,13 +3450,10 @@
 	if (!inode)
 		goto out;
 
-	netif = sel_netif_lookup(dev);
-	if (IS_ERR(netif)) {
-		err = NF_DROP;
+	err = sel_netif_sids(dev, &if_sid, NULL);
+	if (err)
 		goto out;
-	}
-	
-	nsec = &netif->nsec;
+
 	isec = inode->i_security;
 	
 	switch (isec->sclass) {
@@ -3499,14 +3482,11 @@
 
 	err = selinux_parse_skb(skb, &ad, &addrp,
 				&len, 0) ? NF_DROP : NF_ACCEPT;
-	if (err != NF_ACCEPT) {
-		sel_netif_put(netif);
+	if (err != NF_ACCEPT)
 		goto out;
-	}
 
-	err = avc_has_perm(isec->sid, nsec->if_sid, SECCLASS_NETIF,
-	                   netif_perm, &nsec->avcr, &ad) ? NF_DROP : NF_ACCEPT;
-	sel_netif_put(netif);
+	err = avc_has_perm(isec->sid, if_sid, SECCLASS_NETIF,
+	                   netif_perm, NULL, &ad) ? NF_DROP : NF_ACCEPT;
 	if (err != NF_ACCEPT)
 		goto out;
 		
diff -Nru a/security/selinux/include/netif.h b/security/selinux/include/netif.h
--- a/security/selinux/include/netif.h	2004-12-24 13:36:49 -08:00
+++ b/security/selinux/include/netif.h	2004-12-24 13:36:49 -08:00
@@ -15,16 +15,7 @@
 #ifndef _SELINUX_NETIF_H_
 #define _SELINUX_NETIF_H_
 
-struct sel_netif
-{
-	struct list_head list;
-	atomic_t users;
-	struct netif_security_struct nsec;
-	struct rcu_head rcu_head;
-};
-
-struct sel_netif *sel_netif_lookup(struct net_device *dev);
-void sel_netif_put(struct sel_netif *netif);
+int sel_netif_sids(struct net_device *dev, u32 *if_sid, u32 *msg_sid);
 
 #endif	/* _SELINUX_NETIF_H_ */
 
diff -Nru a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
--- a/security/selinux/include/objsec.h	2004-12-24 13:36:48 -08:00
+++ b/security/selinux/include/objsec.h	2004-12-24 13:36:48 -08:00
@@ -99,7 +99,6 @@
 	struct net_device *dev;		/* back pointer */
 	u32 if_sid;			/* SID for this interface */
 	u32 msg_sid;			/* default SID for messages received on this interface */
-	struct avc_entry_ref avcr;	/* reference to permissions */
 };
 
 struct sk_security_struct {
diff -Nru a/security/selinux/netif.c b/security/selinux/netif.c
--- a/security/selinux/netif.c	2004-12-24 13:36:55 -08:00
+++ b/security/selinux/netif.c	2004-12-24 13:36:55 -08:00
@@ -36,10 +36,17 @@
 #define DEBUGP(format, args...)
 #endif
 
+struct sel_netif
+{
+	struct list_head list;
+	struct netif_security_struct nsec;
+	struct rcu_head rcu_head;
+};
+
 static u32 sel_netif_total;
 static LIST_HEAD(sel_netif_list);
 static spinlock_t sel_netif_lock = SPIN_LOCK_UNLOCKED;
-static struct sel_netif sel_netif_hash[SEL_NETIF_HASH_SIZE];
+static struct list_head sel_netif_hash[SEL_NETIF_HASH_SIZE];
 
 static inline u32 sel_netif_hasfn(struct net_device *dev)
 {
@@ -50,12 +57,12 @@
  * All of the devices should normally fit in the hash, so we optimize
  * for that case.
  */
-static struct sel_netif *sel_netif_find(struct net_device *dev)
+static inline struct sel_netif *sel_netif_find(struct net_device *dev)
 {
 	struct list_head *pos;
 	int idx = sel_netif_hasfn(dev);
 
-	__list_for_each_rcu(pos, &sel_netif_hash[idx].list) {
+	__list_for_each_rcu(pos, &sel_netif_hash[idx]) {
 		struct sel_netif *netif = list_entry(pos,
 		                                     struct sel_netif, list);
 		if (likely(netif->nsec.dev == dev))
@@ -74,25 +81,38 @@
 	}
 	
 	idx = sel_netif_hasfn(netif->nsec.dev);
-	list_add_rcu(&netif->list, &sel_netif_hash[idx].list);
-	atomic_set(&netif->users, 1);
+	list_add_rcu(&netif->list, &sel_netif_hash[idx]);
 	sel_netif_total++;
 out:
 	return ret;
 }
 
-struct sel_netif *sel_netif_lookup(struct net_device *dev)
+static void sel_netif_free(struct rcu_head *p)
+{
+	struct sel_netif *netif = container_of(p, struct sel_netif, rcu_head);
+
+	DEBUGP("%s: %s\n", __FUNCTION__, netif->nsec.dev->name);
+	kfree(netif);
+}
+
+static void sel_netif_destroy(struct sel_netif *netif)
+{
+	DEBUGP("%s: %s\n", __FUNCTION__, netif->nsec.dev->name);
+
+	list_del_rcu(&netif->list);
+	sel_netif_total--;
+	call_rcu(&netif->rcu_head, sel_netif_free);
+}
+
+static struct sel_netif *sel_netif_lookup(struct net_device *dev)
 {
 	int ret;
 	struct sel_netif *netif, *new;
 	struct netif_security_struct *nsec;
 
-	rcu_read_lock();
 	netif = sel_netif_find(dev);
-	rcu_read_unlock();
-	
 	if (likely(netif != NULL))
-		goto out_hold;
+		goto out;
 	
 	new = kmalloc(sizeof(*new), GFP_ATOMIC);
 	if (!new) {
@@ -118,76 +138,86 @@
 	if (netif) {
 		spin_unlock_bh(&sel_netif_lock);
 		kfree(new);
-		goto out_hold;
+		goto out;
 	}
 	
-	sel_netif_insert(new);
+	ret = sel_netif_insert(new);
 	spin_unlock_bh(&sel_netif_lock);
 	
+	if (ret) {
+		kfree(new);
+		netif = ERR_PTR(ret);
+		goto out;
+	}
+
 	netif = new;
 	
 	DEBUGP("new: ifindex=%u name=%s if_sid=%u msg_sid=%u\n", dev->ifindex, dev->name,
 	        nsec->if_sid, nsec->msg_sid);
-out_hold:
-	atomic_inc(&netif->users);
 out:
 	return netif;
 }
 
-static void sel_netif_free(struct rcu_head *p)
+static void sel_netif_assign_sids(u32 if_sid_in, u32 msg_sid_in, u32 *if_sid_out, u32 *msg_sid_out)
 {
-	struct sel_netif *netif = container_of(p, struct sel_netif, rcu_head);
-	
-	DEBUGP("%s: %s\n", __FUNCTION__, netif->nsec.dev->name);
-	kfree(netif);
+	if (if_sid_out)
+		*if_sid_out = if_sid_in;
+	if (msg_sid_out)
+		*msg_sid_out = msg_sid_in;
 }
 
-static void sel_netif_destroy(struct sel_netif *netif)
+static int sel_netif_sids_slow(struct net_device *dev, u32 *if_sid, u32 *msg_sid)
 {
-	DEBUGP("%s: %s\n", __FUNCTION__, netif->nsec.dev->name);
+	int ret = 0;
+	u32 tmp_if_sid, tmp_msg_sid;
 	
-	spin_lock_bh(&sel_netif_lock);
-	list_del_rcu(&netif->list);
-	sel_netif_total--;
-	spin_unlock_bh(&sel_netif_lock);
-
-	call_rcu(&netif->rcu_head, sel_netif_free);
+	ret = security_netif_sid(dev->name, &tmp_if_sid, &tmp_msg_sid);
+	if (!ret)
+		sel_netif_assign_sids(tmp_if_sid, tmp_msg_sid, if_sid, msg_sid);
+	return ret;
 }
 
-void sel_netif_put(struct sel_netif *netif)
+int sel_netif_sids(struct net_device *dev, u32 *if_sid, u32 *msg_sid)
 {
-	if (atomic_dec_and_test(&netif->users))
-		sel_netif_destroy(netif);
+	int ret = 0;
+	struct sel_netif *netif;
+
+	rcu_read_lock();
+	netif = sel_netif_lookup(dev);
+	if (IS_ERR(netif)) {
+		rcu_read_unlock();
+		ret = sel_netif_sids_slow(dev, if_sid, msg_sid);
+		goto out;
+	}
+	sel_netif_assign_sids(netif->nsec.if_sid, netif->nsec.msg_sid, if_sid, msg_sid);
+	rcu_read_unlock();
+out:
+	return ret;
 }
 
 static void sel_netif_kill(struct net_device *dev)
 {
 	struct sel_netif *netif;
-	
-	rcu_read_lock();
-	netif = sel_netif_find(dev);
-	rcu_read_unlock();
 
-	/* Drop internal reference */
+	spin_lock_bh(&sel_netif_lock);
+	netif = sel_netif_find(dev);
 	if (netif)
-		sel_netif_put(netif);
+		sel_netif_destroy(netif);
+	spin_unlock_bh(&sel_netif_lock);
 }
 
 static void sel_netif_flush(void)
 {
 	int idx;
 
+	spin_lock_bh(&sel_netif_lock);
 	for (idx = 0; idx < SEL_NETIF_HASH_SIZE; idx++) {
-		struct list_head *pos;
+		struct sel_netif *netif;
 		
-		list_for_each_rcu(pos, &sel_netif_hash[idx].list) {
-			struct sel_netif *netif;
-			
-			netif = list_entry(pos, struct sel_netif, list);
-			if (netif)
-				sel_netif_put(netif);
-		}
+		list_for_each_entry(netif, &sel_netif_hash[idx], list)
+			sel_netif_destroy(netif);
 	}
+	spin_unlock_bh(&sel_netif_lock);
 }
 
 static int sel_netif_avc_callback(u32 event, u32 ssid, u32 tsid,
@@ -223,7 +253,7 @@
 		goto out;
 
 	for (i = 0; i < SEL_NETIF_HASH_SIZE; i++)
-		INIT_LIST_HEAD(&sel_netif_hash[i].list);
+		INIT_LIST_HEAD(&sel_netif_hash[i]);
 
 	register_netdevice_notifier(&sel_netif_netdev_notifier);
 	
diff -Nru a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
--- a/security/selinux/selinuxfs.c	2004-12-24 13:37:43 -08:00
+++ b/security/selinux/selinuxfs.c	2004-12-24 13:37:43 -08:00
@@ -818,7 +818,6 @@
 	struct dentry *dir = bool_dir;
 	struct inode *inode = NULL;
 	struct inode_security_struct *isec;
-	struct qstr qname;
 	char **names = NULL, *page;
 	int num;
 	int *values = NULL;
@@ -838,10 +837,7 @@
 		goto out;
 
 	for (i = 0; i < num; i++) {
-		qname.name = names[i];
-		qname.len = strlen(qname.name);
-		qname.hash = full_name_hash(qname.name, qname.len);
-		dentry = d_alloc(dir, &qname);
+		dentry = d_alloc_name(dir, names[i]);
 		if (!dentry) {
 			ret = -ENOMEM;
 			goto err;
@@ -896,7 +892,6 @@
 	int ret;
 	struct dentry *dentry;
 	struct inode *inode;
-	struct qstr qname;
 	struct inode_security_struct *isec;
 
 	static struct tree_descr selinux_files[] = {
@@ -917,10 +912,7 @@
 	if (ret)
 		return ret;
 
-	qname.name = BOOL_DIR_NAME;
-	qname.len = strlen(qname.name);
-	qname.hash = full_name_hash(qname.name, qname.len);
-	dentry = d_alloc(sb->s_root, &qname);
+	dentry = d_alloc_name(sb->s_root, BOOL_DIR_NAME);
 	if (!dentry)
 		return -ENOMEM;
 
@@ -935,10 +927,7 @@
 	if (ret)
 		goto out;
 
-	qname.name = NULL_FILE_NAME;
-	qname.len = strlen(qname.name);
-	qname.hash = full_name_hash(qname.name, qname.len);
-	dentry = d_alloc(sb->s_root, &qname);
+	dentry = d_alloc_name(sb->s_root, NULL_FILE_NAME);
 	if (!dentry)
 		return -ENOMEM;
 
diff -Nru a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c
--- a/security/selinux/ss/avtab.c	2004-12-24 13:37:03 -08:00
+++ b/security/selinux/ss/avtab.c	2004-12-24 13:37:03 -08:00
@@ -407,3 +407,8 @@
 					      sizeof(struct avtab_node),
 					      0, SLAB_PANIC, NULL, NULL);
 }
+
+void avtab_cache_destroy(void)
+{
+	kmem_cache_destroy (avtab_node_cachep);
+}
diff -Nru a/security/selinux/ss/avtab.h b/security/selinux/ss/avtab.h
--- a/security/selinux/ss/avtab.h	2004-12-24 13:36:47 -08:00
+++ b/security/selinux/ss/avtab.h	2004-12-24 13:36:47 -08:00
@@ -79,6 +79,7 @@
 struct avtab_node *avtab_search_node_next(struct avtab_node *node, int specified);
 
 void avtab_cache_init(void);
+void avtab_cache_destroy(void);
 
 #define AVTAB_HASH_BITS 15
 #define AVTAB_HASH_BUCKETS (1 << AVTAB_HASH_BITS)
diff -Nru a/security/selinux/ss/services.c b/security/selinux/ss/services.c
--- a/security/selinux/ss/services.c	2004-12-24 13:37:19 -08:00
+++ b/security/selinux/ss/services.c	2004-12-24 13:37:19 -08:00
@@ -1037,11 +1037,13 @@
 		avtab_cache_init();
 		if (policydb_read(&policydb, fp)) {
 			LOAD_UNLOCK;
+			avtab_cache_destroy();
 			return -EINVAL;
 		}
 		if (policydb_load_isids(&policydb, &sidtab)) {
 			LOAD_UNLOCK;
 			policydb_destroy(&policydb);
+			avtab_cache_destroy();
 			return -EINVAL;
 		}
 		ss_initialized = 1;
diff -Nru a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
--- a/security/selinux/ss/sidtab.c	2004-12-24 13:37:01 -08:00
+++ b/security/selinux/ss/sidtab.c	2004-12-24 13:37:01 -08:00
@@ -16,8 +16,8 @@
 (sid & SIDTAB_HASH_MASK)
 
 #define INIT_SIDTAB_LOCK(s) spin_lock_init(&s->lock)
-#define SIDTAB_LOCK(s) spin_lock_irq(&s->lock)
-#define SIDTAB_UNLOCK(s) spin_unlock_irq(&s->lock)
+#define SIDTAB_LOCK(s, x) spin_lock_irqsave(&s->lock, x)
+#define SIDTAB_UNLOCK(s, x) spin_unlock_irqrestore(&s->lock, x)
 
 int sidtab_init(struct sidtab *s)
 {
@@ -237,12 +237,13 @@
 {
 	u32 sid;
 	int ret = 0;
+	unsigned long flags;
 
 	*out_sid = SECSID_NULL;
 
 	sid = sidtab_search_context(s, context);
 	if (!sid) {
-		SIDTAB_LOCK(s);
+		SIDTAB_LOCK(s, flags);
 		/* Rescan now that we hold the lock. */
 		sid = sidtab_search_context(s, context);
 		if (sid)
@@ -257,7 +258,7 @@
 		if (ret)
 			s->next_sid--;
 unlock_out:
-		SIDTAB_UNLOCK(s);
+		SIDTAB_UNLOCK(s, flags);
 	}
 
 	if (ret)
@@ -320,17 +321,21 @@
 
 void sidtab_set(struct sidtab *dst, struct sidtab *src)
 {
-	SIDTAB_LOCK(src);
+	unsigned long flags;
+
+	SIDTAB_LOCK(src, flags);
 	dst->htable = src->htable;
 	dst->nel = src->nel;
 	dst->next_sid = src->next_sid;
 	dst->shutdown = 0;
-	SIDTAB_UNLOCK(src);
+	SIDTAB_UNLOCK(src, flags);
 }
 
 void sidtab_shutdown(struct sidtab *s)
 {
-	SIDTAB_LOCK(s);
+	unsigned long flags;
+
+	SIDTAB_LOCK(s, flags);
 	s->shutdown = 1;
-	SIDTAB_UNLOCK(s);
+	SIDTAB_UNLOCK(s, flags);
 }
diff -Nru a/sound/Kconfig b/sound/Kconfig
--- a/sound/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/sound/Kconfig	2004-12-24 13:37:19 -08:00
@@ -70,7 +70,7 @@
 endmenu
 
 menu "Open Sound System"
-	depends on SOUND!=n && (BROKEN || !SPARC64)
+	depends on SOUND!=n && (BROKEN || !(SPARC32 || SPARC64))
 
 config SOUND_PRIME
 	tristate "Open Sound System (DEPRECATED)"
diff -Nru a/sound/arm/Kconfig b/sound/arm/Kconfig
--- a/sound/arm/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/sound/arm/Kconfig	2004-12-24 13:37:19 -08:00
@@ -4,12 +4,15 @@
 	depends on SND!=n && ARM
 
 config SND_SA11XX_UDA1341
-	tristate "SA11xx UDA1341TS driver (H3600)"
+	tristate "SA11xx UDA1341TS driver (iPaq H3600)"
 	depends on ARCH_SA1100 && SND && L3
 	select SND_PCM
 	help
-	  Say Y or M if you have a Compaq iPaq H3x00 handheld computer and want
-	  to use its Philips UDA 1341 audio chip.
+	  Say Y here if you have a Compaq iPaq H3x00 handheld computer
+	  and want to use its Philips UDA 1341 audio chip.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-sa11xx-uda1341.
 
 endmenu
 
diff -Nru a/sound/core/Kconfig b/sound/core/Kconfig
--- a/sound/core/Kconfig	2004-12-24 13:37:02 -08:00
+++ b/sound/core/Kconfig	2004-12-24 13:37:02 -08:00
@@ -17,17 +17,26 @@
 	depends on SND
 	select SND_TIMER
 	help
-	  Say 'Y' or 'M' to enable MIDI sequencer and router support. This feature
-	  allows routing and enqueing MIDI events. Events can be processed at given
-	  time.
+	  Say Y or M to enable MIDI sequencer and router support.  This
+	  feature allows routing and enqueueing of MIDI events.  Events
+	  can be processed at a given time.
+
+	  Many programs require this feature, so you should enable it
+	  unless you know what you're doing.
 
 config SND_SEQ_DUMMY
 	tristate "Sequencer dummy client"
 	depends on SND_SEQUENCER
 	help
-	  Say 'Y' or 'M' to enable dummy sequencer client. This client is a simple
-	  midi-through client. All normal input events are redirected to output port
-	  immediately.
+	  Say Y here to enable the dummy sequencer client.  This client
+	  is a simple MIDI-through client: all normal input events are
+	  redirected to the output port immediately.
+
+	  You don't need this unless you want to connect many MIDI
+	  devices or applications together.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-seq-dummy.
 
 config SND_OSSEMUL
 	bool
@@ -37,7 +46,13 @@
 	depends on SND
 	select SND_OSSEMUL
 	help
-	  Say 'Y' or 'M' to enable mixer OSS API emulation (/dev/mixer*).
+	  To enable OSS mixer API emulation (/dev/mixer*), say Y here
+	  and read <file:Documentation/sound/alsa/OSS-Emulation.txt>.
+
+	  Many programs still use the OSS API, so say Y.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-mixer-oss.
 
 config SND_PCM_OSS
 	tristate "OSS PCM (digital audio) API"
@@ -45,15 +60,26 @@
 	select SND_OSSEMUL
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to enable digital audio (PCM) OSS API emulation (/dev/dsp*).
+	  To enable OSS digital audio (PCM) emulation (/dev/dsp*), say Y
+	  here and read <file:Documentation/sound/alsa/OSS-Emulation.txt>.
+
+	  Many programs still use the OSS API, so say Y.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-pcm-oss.
 
 config SND_SEQUENCER_OSS
 	bool "OSS Sequencer API"
 	depends on SND_SEQUENCER
 	select SND_OSSEMUL
 	help
-	  Say 'Y' to enable OSS sequencer emulation (both /dev/sequencer and
-	  /dev/music interfaces).
+	  Say Y here to enable OSS sequencer emulation (both
+	  /dev/sequencer and /dev/music interfaces).
+
+	  Many programs still use the OSS API, so say Y.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-seq-oss.
 
 config SND_BIT32_EMUL
 	tristate "Emulation for 32-bit applications"
@@ -63,38 +89,51 @@
 	select SND_TIMER
 	select SND_HWDEP
 	help
-	  Say 'Y' or 'M' to enable the emulation for 32-bit ALSA-native
+	  Say Y here to enable the emulation for 32-bit ALSA-native
 	  applications.
 
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ioctl32.
+
 config SND_RTCTIMER
 	tristate "RTC Timer support"
 	depends on SND && RTC
 	select SND_TIMER
 	help
-	  Say 'Y' or 'M' to enable RTC timer support for ALSA. ALSA code uses RTC
-	  timer as precise timing source and maps the RTC timer to the ALSA's timer
-	  interface. ALSA sequencer code can also use this timing source.
+	  Say Y here to enable RTC timer support for ALSA.  ALSA uses
+	  the RTC timer as a precise timing source and maps the RTC
+	  timer to ALSA's timer interface.  The ALSA sequencer code also
+	  can use this timing source.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-rtctimer.
 
 config SND_VERBOSE_PRINTK
 	bool "Verbose printk"
 	depends on SND
 	help
-	  Say 'Y' to enable verbose log messages. These messages will help to
-	  identify source file and position containing printed messages.
+	  Say Y here to enable verbose log messages.  These messages
+	  will help to identify source file and position containing
+	  printed messages.
+
+	  You don't need this unless you're debugging ALSA.
 
 config SND_DEBUG
 	bool "Debug"
 	depends on SND
 	help
-	  Say 'Y' to enable ALSA debug code.
+	  Say Y here to enable ALSA debug code.
 
 config SND_DEBUG_MEMORY
 	bool "Debug memory"
 	depends on SND_DEBUG
 	help
-	  Say 'Y' to enable debugging of memory allocation.
+	  Say Y here to enable debugging of memory allocations.
 
 config SND_DEBUG_DETECT
 	bool "Debug detection"
 	depends on SND_DEBUG
+	help
+	  Say Y here to enable extra-verbose log messages printed when
+	  detecting devices.
 
diff -Nru a/sound/core/info.c b/sound/core/info.c
--- a/sound/core/info.c	2004-12-24 13:37:29 -08:00
+++ b/sound/core/info.c	2004-12-24 13:37:29 -08:00
@@ -25,10 +25,13 @@
 #include <linux/vmalloc.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
+#include <linux/utsname.h>
+#include <linux/config.h>
+
 #include <sound/core.h>
+#include <sound/version.h>
 #include <sound/minors.h>
 #include <sound/info.h>
-#include <sound/version.h>
 #include <linux/proc_fs.h>
 #include <linux/devfs_fs_kernel.h>
 #include <stdarg.h>
@@ -959,7 +962,7 @@
 
 static void snd_info_version_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
 {
-	static char *kernel_version = UTS_RELEASE;
+	static char *kernel_version = system_utsname.release;
 
 	snd_iprintf(buffer,
 		    "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n"
diff -Nru a/sound/core/init.c b/sound/core/init.c
--- a/sound/core/init.c	2004-12-24 13:36:19 -08:00
+++ b/sound/core/init.c	2004-12-24 13:36:19 -08:00
@@ -785,12 +785,15 @@
 int snd_card_pci_suspend(struct pci_dev *dev, u32 state)
 {
 	snd_card_t *card = pci_get_drvdata(dev);
+	int err;
 	if (! card || ! card->pm_suspend)
 		return 0;
 	if (card->power_state == SNDRV_CTL_POWER_D3hot)
 		return 0;
 	/* FIXME: correct state value? */
-	return card->pm_suspend(card, 0);
+	err = card->pm_suspend(card, 0);
+	pci_save_state(dev);
+	return err;
 }
 
 int snd_card_pci_resume(struct pci_dev *dev)
@@ -801,7 +804,7 @@
 	if (card->power_state == SNDRV_CTL_POWER_D0)
 		return 0;
 	/* restore the PCI config space */
-	pci_restore_state(dev, dev->saved_config_space);
+	pci_restore_state(dev);
 	/* FIXME: correct state value? */
 	return card->pm_resume(card, 0);
 }
diff -Nru a/sound/core/ioctl32/hwdep32.c b/sound/core/ioctl32/hwdep32.c
--- a/sound/core/ioctl32/hwdep32.c	2004-12-24 13:37:19 -08:00
+++ b/sound/core/ioctl32/hwdep32.c	2004-12-24 13:37:19 -08:00
@@ -34,7 +34,7 @@
 	u32 driver_data;
 } /* don't set packed attribute here */;
 
-static int _snd_ioctl32_hwdep_dsp_image(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
+static inline int _snd_ioctl32_hwdep_dsp_image(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
 {
 	struct sndrv_hwdep_dsp_image data;
 	struct sndrv_hwdep_dsp_image32 data32;
diff -Nru a/sound/core/ioctl32/ioctl32.c b/sound/core/ioctl32/ioctl32.c
--- a/sound/core/ioctl32/ioctl32.c	2004-12-24 13:36:18 -08:00
+++ b/sound/core/ioctl32/ioctl32.c	2004-12-24 13:36:18 -08:00
@@ -102,7 +102,7 @@
 	CPTR(pids);\
 }
 
-static int _snd_ioctl32_ctl_elem_list(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
+static inline int _snd_ioctl32_ctl_elem_list(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
 {
 	struct sndrv_ctl_elem_list32 data32;
 	struct sndrv_ctl_elem_list data;
@@ -168,7 +168,7 @@
 	unsigned char reserved[64];
 } __attribute__((packed));
 
-static int _snd_ioctl32_ctl_elem_info(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
+static inline int _snd_ioctl32_ctl_elem_info(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
 {
 	struct sndrv_ctl_elem_info data;
 	struct sndrv_ctl_elem_info32 data32;
@@ -246,7 +246,7 @@
 		struct sndrv_aes_iec958 iec958;
         } value;
         unsigned char reserved[128];
-} __attribute__((packed));
+};
 
 
 /* hmm, it's so hard to retrieve the value type from the control id.. */
@@ -274,7 +274,7 @@
 }
 
 
-static int _snd_ioctl32_ctl_elem_value(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
+static inline int _snd_ioctl32_ctl_elem_value(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
 {
 	struct sndrv_ctl_elem_value *data;
 	struct sndrv_ctl_elem_value32 *data32;
diff -Nru a/sound/core/ioctl32/ioctl32.h b/sound/core/ioctl32/ioctl32.h
--- a/sound/core/ioctl32/ioctl32.h	2004-12-24 13:36:48 -08:00
+++ b/sound/core/ioctl32/ioctl32.h	2004-12-24 13:36:48 -08:00
@@ -18,7 +18,7 @@
  *
  *
  * This file registers the converters from 32-bit ioctls to 64-bit ones.
- * The converter assumes that a 32-bit user-pointer can be casted by A(x)
+ * The converter assumes that a 32-bit user-pointer can be casted by compat_ptr(x)
  * macro to a valid 64-bit pointer which is accessible via copy_from/to_user.
  *
  */
@@ -47,7 +47,7 @@
 
 
 #define DEFINE_ALSA_IOCTL(type) \
-static int _snd_ioctl32_##type(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)\
+static inline int _snd_ioctl32_##type(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)\
 {\
 	struct sndrv_##type##32 data32;\
 	struct sndrv_##type data;\
@@ -72,7 +72,7 @@
 }
 
 #define DEFINE_ALSA_IOCTL_BIG(type) \
-static int _snd_ioctl32_##type(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)\
+static inline int _snd_ioctl32_##type(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)\
 {\
 	struct sndrv_##type##32 *data32;\
 	struct sndrv_##type *data;\
diff -Nru a/sound/core/ioctl32/pcm32.c b/sound/core/ioctl32/pcm32.c
--- a/sound/core/ioctl32/pcm32.c	2004-12-24 13:37:00 -08:00
+++ b/sound/core/ioctl32/pcm32.c	2004-12-24 13:37:00 -08:00
@@ -169,11 +169,69 @@
 
 DEFINE_ALSA_IOCTL(pcm_uframes_str);
 DEFINE_ALSA_IOCTL(pcm_sframes_str);
-DEFINE_ALSA_IOCTL_BIG(pcm_hw_params);
 DEFINE_ALSA_IOCTL(pcm_sw_params);
 DEFINE_ALSA_IOCTL(pcm_channel_info);
 DEFINE_ALSA_IOCTL(pcm_status);
 
+/* recalcuate the boundary within 32bit */
+static void recalculate_boundary(struct file *file)
+{
+	snd_pcm_file_t *pcm_file;
+	snd_pcm_substream_t *substream;
+	snd_pcm_runtime_t *runtime;
+
+	/* FIXME: need to check whether fop->ioctl is sane */
+	if (! (pcm_file = file->private_data))
+		return;
+	if (! (substream = pcm_file->substream))
+		return;
+	if (! (runtime = substream->runtime))
+		return;
+	runtime->boundary = runtime->buffer_size;
+	while (runtime->boundary * 2 <= 0x7fffffffUL - runtime->buffer_size)
+		runtime->boundary *= 2;
+}
+
+static inline int _snd_ioctl32_pcm_hw_params(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
+{
+	struct sndrv_pcm_hw_params32 *data32;
+	struct sndrv_pcm_hw_params *data;
+	mm_segment_t oldseg;
+	int err;
+
+	data32 = kmalloc(sizeof(*data32), GFP_KERNEL);
+	data = kmalloc(sizeof(*data), GFP_KERNEL);
+	if (data32 == NULL || data == NULL) {
+		err = -ENOMEM;
+		goto __end;
+	}
+	if (copy_from_user(data32, (void __user *)arg, sizeof(*data32))) {
+		err = -EFAULT;
+		goto __end;
+	}
+	memset(data, 0, sizeof(*data));
+	convert_from_32(pcm_hw_params, data, data32);
+	oldseg = get_fs();
+	set_fs(KERNEL_DS);
+	err = file->f_op->ioctl(file->f_dentry->d_inode, file, native_ctl, (unsigned long)data);
+	set_fs(oldseg);
+	if (err < 0)
+		goto __end;
+	err = 0;
+	convert_to_32(pcm_hw_params, data32, data);
+	if (copy_to_user((void __user *)arg, data32, sizeof(*data32)))
+		err = -EFAULT;
+	else
+		recalculate_boundary(file);
+      __end:
+      	if (data)
+      		kfree(data);
+      	if (data32)
+      		kfree(data32);
+	return err;
+}
+
+
 /*
  */
 struct sndrv_xferi32 {
@@ -182,7 +240,7 @@
 	u32 frames;
 } __attribute__((packed));
 
-static int _snd_ioctl32_xferi(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
+static inline int _snd_ioctl32_xferi(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
 {
 	struct sndrv_xferi32 data32;
 	struct sndrv_xferi data;
@@ -222,7 +280,7 @@
  * handler there expands again the same 128 pointers on stack, so it is better
  * to handle the function (calling pcm_readv/writev) directly in this handler.
  */
-static int _snd_ioctl32_xfern(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
+static inline int _snd_ioctl32_xfern(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
 {
 	snd_pcm_file_t *pcm_file;
 	snd_pcm_substream_t *substream;
@@ -343,7 +401,7 @@
 	oparams->fifo_size = params->fifo_size;
 }
 
-static int _snd_ioctl32_pcm_hw_params_old(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
+static inline int _snd_ioctl32_pcm_hw_params_old(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
 {
 	struct sndrv_pcm_hw_params_old32 *data32;
 	struct sndrv_pcm_hw_params *data;
@@ -371,6 +429,8 @@
 	err = 0;
 	if (copy_to_user((void __user *)arg, data32, sizeof(*data32)))
 		err = -EFAULT;
+	else
+		recalculate_boundary(file);
       __end:
       	if (data)
       		kfree(data);
@@ -439,6 +499,30 @@
 
 
 /*
+ * When PCM is used on 32bit mode, we need to disable
+ * mmap of PCM status/control records because of the size
+ * incompatibility.
+ * 
+ * Since INFO ioctl is always called at first, we mark the
+ * mmap-disabling in this ioctl wrapper.
+ */
+static int snd_pcm_info_ioctl32(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *filp)
+{
+	snd_pcm_file_t *pcm_file;
+	snd_pcm_substream_t *substream;
+	if (! filp->f_op || ! filp->f_op->ioctl)
+		return -ENOTTY;
+	pcm_file = filp->private_data;
+	if (! pcm_file)
+		return -ENOTTY;
+	substream = pcm_file->substream;
+	if (! substream)
+		return -ENOTTY;
+	substream->no_mmap_ctrl = 1;
+	return filp->f_op->ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+}
+
+/*
  */
 #define AP(x) snd_ioctl32_##x
 
@@ -456,13 +540,14 @@
 	SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct sndrv_xfern32),
 	SNDRV_PCM_IOCTL_HW_REFINE_OLD32 = _IOWR('A', 0x10, struct sndrv_pcm_hw_params_old32),
 	SNDRV_PCM_IOCTL_HW_PARAMS_OLD32 = _IOWR('A', 0x11, struct sndrv_pcm_hw_params_old32),
-	SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct sndrv_pcm_sync_ptr),
+	SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct sndrv_pcm_sync_ptr32),
 
 };
 
 struct ioctl32_mapper pcm_mappers[] = {
 	MAP_COMPAT(SNDRV_PCM_IOCTL_PVERSION),
-	MAP_COMPAT(SNDRV_PCM_IOCTL_INFO),
+	/* MAP_COMPAT(SNDRV_PCM_IOCTL_INFO), */
+	{ SNDRV_PCM_IOCTL_INFO, snd_pcm_info_ioctl32 },
 	MAP_COMPAT(SNDRV_PCM_IOCTL_TSTAMP),
 	{ SNDRV_PCM_IOCTL_HW_REFINE32, AP(pcm_hw_refine) },
 	{ SNDRV_PCM_IOCTL_HW_PARAMS32, AP(pcm_hw_params) },
diff -Nru a/sound/core/memalloc.c b/sound/core/memalloc.c
--- a/sound/core/memalloc.c	2004-12-24 13:37:29 -08:00
+++ b/sound/core/memalloc.c	2004-12-24 13:37:29 -08:00
@@ -49,8 +49,7 @@
 /* FIXME: so far only some PCI devices have the preallocation table */
 #ifdef CONFIG_PCI
 static int enable[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
-static int boot_devs;
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable cards to allocate buffers.");
 #endif
 
@@ -246,9 +245,9 @@
 	snd_assert(size > 0, return NULL);
 	snd_assert(dma != NULL, return NULL);
 	pg = get_order(size);
-	gfp_flags = GFP_KERNEL;
-	if (pg > 0)
-		gfp_flags |= __GFP_NOWARN;
+	gfp_flags = GFP_KERNEL
+		| __GFP_NORETRY /* don't trigger OOM-killer */
+		| __GFP_NOWARN; /* no stack trace print - this call is non-critical */
 	res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags);
 	if (res != NULL) {
 #ifdef NEED_RESERVE_PAGES
diff -Nru a/sound/core/memory.c b/sound/core/memory.c
--- a/sound/core/memory.c	2004-12-24 13:36:17 -08:00
+++ b/sound/core/memory.c	2004-12-24 13:36:17 -08:00
@@ -257,7 +257,7 @@
  *
  * Returns zero if successful, or non-zero on failure.
  */
-int copy_to_user_fromio(void __user *dst, unsigned long src, size_t count)
+int copy_to_user_fromio(void __user *dst, const void __iomem *src, size_t count)
 {
 #if defined(__i386__) || defined(CONFIG_SPARC32)
 	return copy_to_user(dst, (const void*)src, count) ? -EFAULT : 0;
@@ -267,7 +267,7 @@
 		size_t c = count;
 		if (c > sizeof(buf))
 			c = sizeof(buf);
-		memcpy_fromio(buf, (void*)src, c);
+		memcpy_fromio(buf, src, c);
 		if (copy_to_user(dst, buf, c))
 			return -EFAULT;
 		count -= c;
@@ -288,7 +288,7 @@
  *
  * Returns zero if successful, or non-zero on failure.
  */
-int copy_from_user_toio(unsigned long dst, const void __user *src, size_t count)
+int copy_from_user_toio(void __iomem *dst, const void __user *src, size_t count)
 {
 #if defined(__i386__) || defined(CONFIG_SPARC32)
 	return copy_from_user((void*)dst, src, count) ? -EFAULT : 0;
@@ -300,7 +300,7 @@
 			c = sizeof(buf);
 		if (copy_from_user(buf, src, c))
 			return -EFAULT;
-		memcpy_toio((void*)dst, buf, c);
+		memcpy_toio(dst, buf, c);
 		count -= c;
 		dst += c;
 		src += c;
diff -Nru a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
--- a/sound/core/oss/pcm_oss.c	2004-12-24 13:37:19 -08:00
+++ b/sound/core/oss/pcm_oss.c	2004-12-24 13:37:19 -08:00
@@ -47,14 +47,13 @@
 static int dsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 0};
 static int adsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
 static int nonblock_open;
-static int boot_devs;
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Abramo Bagnara <abramo@alsa-project.org>");
 MODULE_DESCRIPTION("PCM OSS emulation for ALSA.");
 MODULE_LICENSE("GPL");
-module_param_array(dsp_map, int, boot_devs, 0444);
+module_param_array(dsp_map, int, NULL, 0444);
 MODULE_PARM_DESC(dsp_map, "PCM device number assigned to 1st OSS device.");
-module_param_array(adsp_map, int, boot_devs, 0444);
+module_param_array(adsp_map, int, NULL, 0444);
 MODULE_PARM_DESC(adsp_map, "PCM device number assigned to 2nd OSS device.");
 module_param(nonblock_open, bool, 0644);
 MODULE_PARM_DESC(nonblock_open, "Don't block opening busy PCM devices.");
@@ -830,13 +829,18 @@
 			xfer += tmp;
 			if ((substream->oss.setup != NULL && substream->oss.setup->partialfrag) ||
 			    runtime->oss.buffer_used == runtime->oss.period_bytes) {
-				tmp = snd_pcm_oss_write2(substream, runtime->oss.buffer, runtime->oss.buffer_used, 1);
+				tmp = snd_pcm_oss_write2(substream, runtime->oss.buffer + runtime->oss.period_ptr, 
+							 runtime->oss.buffer_used - runtime->oss.period_ptr, 1);
 				if (tmp <= 0)
 					return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
 				runtime->oss.bytes += tmp;
-				runtime->oss.buffer_used = 0;
 				runtime->oss.period_ptr += tmp;
 				runtime->oss.period_ptr %= runtime->oss.period_bytes;
+				if (runtime->oss.period_ptr == 0 ||
+				    runtime->oss.period_ptr == runtime->oss.buffer_used)
+					runtime->oss.buffer_used = 0;
+				else if ((substream->ffile->f_flags & O_NONBLOCK) != 0)
+					return xfer > 0 ? xfer : -EAGAIN;
 			}
 		} else {
 			tmp = snd_pcm_oss_write2(substream, (char *)buf, runtime->oss.period_bytes, 0);
@@ -846,6 +850,9 @@
 			buf += tmp;
 			bytes -= tmp;
 			xfer += tmp;
+			if ((substream->ffile->f_flags & O_NONBLOCK) != 0 &&
+			    tmp != runtime->oss.period_bytes)
+				break;
 		}
 	}
 	return xfer;
diff -Nru a/sound/core/pcm.c b/sound/core/pcm.c
--- a/sound/core/pcm.c	2004-12-24 13:37:32 -08:00
+++ b/sound/core/pcm.c	2004-12-24 13:37:32 -08:00
@@ -267,7 +267,7 @@
 }
 #endif
 
-
+#ifdef CONFIG_PROC_FS
 static void snd_pcm_proc_info_read(snd_pcm_substream_t *substream, snd_info_buffer_t *buffer)
 {
 	snd_pcm_info_t info;
@@ -391,6 +391,7 @@
 	snd_iprintf(buffer, "hw_ptr      : %ld\n", runtime->status->hw_ptr);
 	snd_iprintf(buffer, "appl_ptr    : %ld\n", runtime->control->appl_ptr);
 }
+#endif
 
 #ifdef CONFIG_SND_DEBUG
 static void snd_pcm_xrun_debug_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
diff -Nru a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
--- a/sound/core/pcm_lib.c	2004-12-24 13:36:48 -08:00
+++ b/sound/core/pcm_lib.c	2004-12-24 13:36:48 -08:00
@@ -176,7 +176,7 @@
 		runtime->avail_max = avail;
 	if (avail >= runtime->stop_threshold) {
 		if (substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING)
-			snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
+			snd_pcm_drain_done(substream);
 		else
 			xrun(substream);
 		return -EPIPE;
diff -Nru a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
--- a/sound/core/pcm_misc.c	2004-12-24 13:37:18 -08:00
+++ b/sound/core/pcm_misc.c	2004-12-24 13:37:18 -08:00
@@ -25,11 +25,14 @@
 #include <sound/pcm.h>
 #define SND_PCM_FORMAT_UNKNOWN (-1)
 
+/* NOTE: "signed" prefix must be given below since the default char is
+ *       unsigned on some architectures!
+ */
 struct pcm_format_data {
-	char width;	/* bit width */
-	char phys;	/* physical bit width */
-	char le;	/* 0 = big-endian, 1 = little-endian, -1 = others */
-	char signd;	/* 0 = unsigned, 1 = signed, -1 = others */
+	unsigned char width;	/* bit width */
+	unsigned char phys;	/* physical bit width */
+	signed char le;	/* 0 = big-endian, 1 = little-endian, -1 = others */
+	signed char signd;	/* 0 = unsigned, 1 = signed, -1 = others */
 	unsigned char silence[8];	/* silence data to fill */
 };
 
diff -Nru a/sound/core/pcm_native.c b/sound/core/pcm_native.c
--- a/sound/core/pcm_native.c	2004-12-24 13:36:47 -08:00
+++ b/sound/core/pcm_native.c	2004-12-24 13:36:47 -08:00
@@ -451,7 +451,7 @@
 static int snd_pcm_hw_free(snd_pcm_substream_t * substream)
 {
 	snd_pcm_runtime_t *runtime;
-	int result;
+	int result = 0;
 
 	snd_assert(substream != NULL, return -ENXIO);
 	runtime = substream->runtime;
@@ -468,11 +468,8 @@
 	snd_pcm_stream_unlock_irq(substream);
 	if (atomic_read(&runtime->mmap_count))
 		return -EBADFD;
-	if (substream->ops->hw_free == NULL) {
-		runtime->status->state = SNDRV_PCM_STATE_OPEN;
-		return 0;
-	}
-	result = substream->ops->hw_free(substream);
+	if (substream->ops->hw_free)
+		result = substream->ops->hw_free(substream);
 	runtime->status->state = SNDRV_PCM_STATE_OPEN;
 	return result;
 }
@@ -652,6 +649,7 @@
 struct action_ops {
 	int (*pre_action)(snd_pcm_substream_t *substream, int state);
 	int (*do_action)(snd_pcm_substream_t *substream, int state);
+	void (*undo_action)(snd_pcm_substream_t *substream, int state);
 	void (*post_action)(snd_pcm_substream_t *substream, int state);
 };
 
@@ -666,7 +664,8 @@
 {
 	struct list_head *pos;
 	snd_pcm_substream_t *s = NULL;
-	int err, res = 0;
+	snd_pcm_substream_t *s1;
+	int res = 0;
 
 	snd_pcm_group_for_each(pos, substream) {
 		s = snd_pcm_group_substream_entry(pos);
@@ -674,24 +673,31 @@
 			spin_lock(&s->self_group.lock);
 		res = ops->pre_action(s, state);
 		if (res < 0)
-			break;
+			goto _unlock;
 	}
-	if (res >= 0) {
-		snd_pcm_group_for_each(pos, substream) {
-			s = snd_pcm_group_substream_entry(pos);
-			err = ops->do_action(s, state);
-			if (err < 0) {
-				if (res == 0)
-					res = err;
-			} else {
-				ops->post_action(s, state);
+	snd_pcm_group_for_each(pos, substream) {
+		s = snd_pcm_group_substream_entry(pos);
+		res = ops->do_action(s, state);
+		if (res < 0) {
+			if (ops->undo_action) {
+				snd_pcm_group_for_each(pos, substream) {
+					s1 = snd_pcm_group_substream_entry(pos);
+					if (s1 == s) /* failed stream */
+						break;
+					ops->undo_action(s1, state);
+				}
 			}
-			if (do_lock && s != substream)
-				spin_unlock(&s->self_group.lock);
+			s = NULL; /* unlock all */
+			goto _unlock;
 		}
-	} else if (do_lock) {
-		snd_pcm_substream_t *s1;
-		/* unlock all streams */
+	}
+	snd_pcm_group_for_each(pos, substream) {
+		s = snd_pcm_group_substream_entry(pos);
+		ops->post_action(s, state);
+	}
+ _unlock:
+	if (do_lock) {
+		/* unlock streams */
 		snd_pcm_group_for_each(pos, substream) {
 			s1 = snd_pcm_group_substream_entry(pos);
 			if (s1 != substream)
@@ -716,9 +722,10 @@
 	if (res < 0)
 		return res;
 	res = ops->do_action(substream, state);
-	if (res == 0) {
+	if (res == 0)
 		ops->post_action(substream, state);
-	}
+	else if (ops->undo_action)
+		ops->undo_action(substream, state);
 	return res;
 }
 
@@ -787,6 +794,9 @@
 	return res;
 }
 
+/*
+ * start callbacks
+ */
 static int snd_pcm_pre_start(snd_pcm_substream_t *substream, int state)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
@@ -803,14 +813,20 @@
 {
 	if (substream->runtime->trigger_master != substream)
 		return 0;
-        return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START);
+	return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START);
+}
+
+static void snd_pcm_undo_start(snd_pcm_substream_t *substream, int state)
+{
+	if (substream->runtime->trigger_master == substream)
+		substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP);
 }
 
 static void snd_pcm_post_start(snd_pcm_substream_t *substream, int state)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
 	snd_pcm_trigger_tstamp(substream);
-	runtime->status->state = SNDRV_PCM_STATE_RUNNING;
+	runtime->status->state = state;
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
 	    runtime->silence_size > 0)
 		snd_pcm_playback_silence(substream, ULONG_MAX);
@@ -823,22 +839,27 @@
 static struct action_ops snd_pcm_action_start = {
 	.pre_action = snd_pcm_pre_start,
 	.do_action = snd_pcm_do_start,
+	.undo_action = snd_pcm_undo_start,
 	.post_action = snd_pcm_post_start
 };
 
 /**
  * snd_pcm_start
+ *
+ * Start all linked streams.
  */
 int snd_pcm_start(snd_pcm_substream_t *substream)
 {
-	return snd_pcm_action(&snd_pcm_action_start, substream, 0);
+	return snd_pcm_action(&snd_pcm_action_start, substream, SNDRV_PCM_STATE_RUNNING);
 }
 
+/*
+ * stop callbacks
+ */
 static int snd_pcm_pre_stop(snd_pcm_substream_t *substream, int state)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	if (substream->runtime->status->state != SNDRV_PCM_STATE_RUNNING &&
-	    substream->runtime->status->state != SNDRV_PCM_STATE_DRAINING)
+	if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
 		return -EBADFD;
 	runtime->trigger_master = substream;
 	return 0;
@@ -846,19 +867,22 @@
 
 static int snd_pcm_do_stop(snd_pcm_substream_t *substream, int state)
 {
-	if (substream->runtime->trigger_master != substream)
-		return 0;
-	return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP);
+	if (substream->runtime->trigger_master == substream &&
+	    snd_pcm_running(substream))
+		substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP);
+	return 0; /* unconditonally stop all substreams */
 }
 
 static void snd_pcm_post_stop(snd_pcm_substream_t *substream, int state)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	snd_pcm_trigger_tstamp(substream);
-	if (substream->timer)
-		snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTOP, &runtime->trigger_tstamp);
-	runtime->status->state = state;
-	snd_pcm_tick_set(substream, 0);
+	if (runtime->status->state != state) {
+		snd_pcm_trigger_tstamp(substream);
+		if (substream->timer)
+			snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTOP, &runtime->trigger_tstamp);
+		runtime->status->state = state;
+		snd_pcm_tick_set(substream, 0);
+	}
 	wake_up(&runtime->sleep);
 }
 
@@ -870,12 +894,30 @@
 
 /**
  * snd_pcm_stop
+ *
+ * Try to stop all running streams in the substream group.
+ * The state of each stream is changed to the given value after that unconditionally.
  */
 int snd_pcm_stop(snd_pcm_substream_t *substream, int state)
 {
 	return snd_pcm_action(&snd_pcm_action_stop, substream, state);
 }
 
+/**
+ * snd_pcm_drain_done
+ *
+ * Stop the DMA only when the given stream is playback.
+ * The state is changed to SETUP.
+ * Unlike snd_pcm_stop(), this affects only the given stream.
+ */
+int snd_pcm_drain_done(snd_pcm_substream_t *substream)
+{
+	return snd_pcm_action_single(&snd_pcm_action_stop, substream, SNDRV_PCM_STATE_SETUP);
+}
+
+/*
+ * pause callbacks
+ */
 static int snd_pcm_pre_pause(snd_pcm_substream_t *substream, int push)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
@@ -899,6 +941,14 @@
 					      SNDRV_PCM_TRIGGER_PAUSE_RELEASE);
 }
 
+static void snd_pcm_undo_pause(snd_pcm_substream_t *substream, int push)
+{
+	if (substream->runtime->trigger_master == substream)
+		substream->ops->trigger(substream,
+					push ? SNDRV_PCM_TRIGGER_PAUSE_RELEASE :
+					SNDRV_PCM_TRIGGER_PAUSE_PUSH);
+}
+
 static void snd_pcm_post_pause(snd_pcm_substream_t *substream, int push)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
@@ -921,9 +971,13 @@
 static struct action_ops snd_pcm_action_pause = {
 	.pre_action = snd_pcm_pre_pause,
 	.do_action = snd_pcm_do_pause,
+	.undo_action = snd_pcm_undo_pause,
 	.post_action = snd_pcm_post_pause
 };
 
+/*
+ * Push/release the pause for all linked streams.
+ */
 static int snd_pcm_pause(snd_pcm_substream_t *substream, int push)
 {
 	return snd_pcm_action(&snd_pcm_action_pause, substream, push);
@@ -937,7 +991,6 @@
 	snd_pcm_runtime_t *runtime = substream->runtime;
 	if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
 		return -EBUSY;
-	runtime->status->suspended_state = runtime->status->state;
 	runtime->trigger_master = substream;
 	return 0;
 }
@@ -947,10 +1000,10 @@
 	snd_pcm_runtime_t *runtime = substream->runtime;
 	if (runtime->trigger_master != substream)
 		return 0;
-	if (runtime->status->suspended_state != SNDRV_PCM_STATE_RUNNING &&
-	    runtime->status->suspended_state != SNDRV_PCM_STATE_DRAINING)
+	if (! snd_pcm_running(substream))
 		return 0;
-	return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND);
+	substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND);
+	return 0; /* suspend unconditionally */
 }
 
 static void snd_pcm_post_suspend(snd_pcm_substream_t *substream, int state)
@@ -959,6 +1012,7 @@
 	snd_pcm_trigger_tstamp(substream);
 	if (substream->timer)
 		snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MPAUSE, &runtime->trigger_tstamp);
+	runtime->status->suspended_state = runtime->status->state;
 	runtime->status->state = SNDRV_PCM_STATE_SUSPENDED;
 	snd_pcm_tick_set(substream, 0);
 	wake_up(&runtime->sleep);
@@ -972,6 +1026,9 @@
 
 /**
  * snd_pcm_suspend
+ *
+ * Trigger SUSPEND to all linked streams.
+ * After this call, all streams are changed to SUSPENDED state.
  */
 int snd_pcm_suspend(snd_pcm_substream_t *substream)
 {
@@ -980,11 +1037,14 @@
 
 /**
  * snd_pcm_suspend_all
+ *
+ * Trigger SUSPEND to all substreams in the given pcm.
+ * After this call, all streams are changed to SUSPENDED state.
  */
 int snd_pcm_suspend_all(snd_pcm_t *pcm)
 {
 	snd_pcm_substream_t *substream;
-	int stream, err;
+	int stream, err = 0;
 
 	for (stream = 0; stream < 2; stream++) {
 		for (substream = pcm->streams[stream].substream; substream; substream = substream->next) {
@@ -992,15 +1052,11 @@
 			if (substream->runtime == NULL)
 				continue;
 			snd_pcm_stream_lock(substream);
-			if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
-				snd_pcm_stream_unlock(substream);
-				continue;
-			}
-			if ((err = snd_pcm_suspend(substream)) < 0) {
-				snd_pcm_stream_unlock(substream);
-				return err;
-			}
+			if (substream->runtime->status->state != SNDRV_PCM_STATE_SUSPENDED)
+				err = snd_pcm_suspend(substream);
 			snd_pcm_stream_unlock(substream);
+			if (err < 0)
+				return err;
 		}
 	}
 	return 0;
@@ -1022,12 +1078,21 @@
 	snd_pcm_runtime_t *runtime = substream->runtime;
 	if (runtime->trigger_master != substream)
 		return 0;
+	/* DMA not running previously? */
 	if (runtime->status->suspended_state != SNDRV_PCM_STATE_RUNNING &&
-	    runtime->status->suspended_state != SNDRV_PCM_STATE_DRAINING)
+	    (runtime->status->suspended_state != SNDRV_PCM_STATE_DRAINING ||
+	     substream->stream != SNDRV_PCM_STREAM_PLAYBACK))
 		return 0;
 	return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME);
 }
 
+static void snd_pcm_undo_resume(snd_pcm_substream_t *substream, int state)
+{
+	if (substream->runtime->trigger_master == substream &&
+	    snd_pcm_running(substream))
+		substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND);
+}
+
 static void snd_pcm_post_resume(snd_pcm_substream_t *substream, int state)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
@@ -1042,6 +1107,7 @@
 static struct action_ops snd_pcm_action_resume = {
 	.pre_action = snd_pcm_pre_resume,
 	.do_action = snd_pcm_do_resume,
+	.undo_action = snd_pcm_undo_resume,
 	.post_action = snd_pcm_post_resume
 };
 
@@ -1066,6 +1132,11 @@
 
 #endif /* CONFIG_PM */
 
+/*
+ * xrun ioctl
+ *
+ * Change the RUNNING stream(s) to XRUN state.
+ */
 static int snd_pcm_xrun(snd_pcm_substream_t *substream)
 {
 	snd_card_t *card = substream->pcm->card;
@@ -1073,8 +1144,13 @@
 	int result;
 
 	snd_power_lock(card);
+	if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
+		result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
+		if (result < 0)
+			goto _unlock;
+	}
+
 	snd_pcm_stream_lock_irq(substream);
-       _xrun_recovery:
 	switch (runtime->status->state) {
 	case SNDRV_PCM_STATE_XRUN:
 		result = 0;	/* already there */
@@ -1082,21 +1158,18 @@
 	case SNDRV_PCM_STATE_RUNNING:
 		result = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
 		break;
-	case SNDRV_PCM_STATE_SUSPENDED:
-		snd_pcm_stream_unlock_irq(substream);
-		result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
-		snd_pcm_stream_lock_irq(substream);
-		if (result >= 0)
-			goto _xrun_recovery;
-		break;
 	default:
 		result = -EBADFD;
 	}
 	snd_pcm_stream_unlock_irq(substream);
+ _unlock:
 	snd_power_unlock(card);
 	return result;
 }
 
+/*
+ * reset ioctl
+ */
 static int snd_pcm_pre_reset(snd_pcm_substream_t * substream, int state)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
@@ -1145,17 +1218,17 @@
 	return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, 0);
 }
 
+/*
+ * prepare ioctl
+ */
 static int snd_pcm_pre_prepare(snd_pcm_substream_t * substream, int state)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	switch (runtime->status->state) {
-	case SNDRV_PCM_STATE_OPEN:
+	if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
 		return -EBADFD;
-	case SNDRV_PCM_STATE_RUNNING:
+	if (snd_pcm_running(substream))
 		return -EBUSY;
-	default:
-		return 0;
-	}
+	return 0;
 }
 
 static int snd_pcm_do_prepare(snd_pcm_substream_t * substream, int state)
@@ -1195,111 +1268,147 @@
 	return res;
 }
 
-static void snd_pcm_change_state(snd_pcm_substream_t *substream, int state)
+/*
+ * drain ioctl
+ */
+
+static int snd_pcm_pre_drain_init(snd_pcm_substream_t * substream, int state)
 {
-	struct list_head *pos;
-	snd_pcm_substream_t *s;
+	if (substream->ffile->f_flags & O_NONBLOCK)
+		return -EAGAIN;
+	substream->runtime->trigger_master = substream;
+	return 0;
+}
 
-	if (snd_pcm_stream_linked(substream)) {
-		if (!spin_trylock(&substream->group->lock)) {
-			spin_unlock(&substream->self_group.lock);
-			spin_lock(&substream->group->lock);
-			spin_lock(&substream->self_group.lock);
-		}
-		snd_pcm_group_for_each(pos, substream) {
-			s = snd_pcm_group_substream_entry(pos);
-			if (s != substream)
-				spin_lock(&s->self_group.lock);
-			s->runtime->status->state = state;
-			if (s != substream)
-				spin_unlock(&s->self_group.lock);
+static int snd_pcm_do_drain_init(snd_pcm_substream_t * substream, int state)
+{
+	snd_pcm_runtime_t *runtime = substream->runtime;
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		switch (runtime->status->state) {
+		case SNDRV_PCM_STATE_PREPARED:
+			/* start playback stream if possible */
+			if (! snd_pcm_playback_empty(substream)) {
+				snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING);
+				snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING);
+			}
+			break;
+		case SNDRV_PCM_STATE_RUNNING:
+			runtime->status->state = SNDRV_PCM_STATE_DRAINING;
+			break;
+		default:
+			break;
 		}
-		spin_unlock(&substream->group->lock);
 	} else {
-		substream->runtime->status->state = state;
+		/* stop running stream */
+		if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) {
+			int state = snd_pcm_capture_avail(runtime) > 0 ?
+				SNDRV_PCM_STATE_DRAINING : SNDRV_PCM_STATE_SETUP;
+			snd_pcm_do_stop(substream, state);
+			snd_pcm_post_stop(substream, state);
+		}
 	}
+	return 0;
 }
 
-static int snd_pcm_playback_drop(snd_pcm_substream_t *substream);
+static void snd_pcm_post_drain_init(snd_pcm_substream_t * substream, int state)
+{
+}
+
+static struct action_ops snd_pcm_action_drain_init = {
+	.pre_action = snd_pcm_pre_drain_init,
+	.do_action = snd_pcm_do_drain_init,
+	.post_action = snd_pcm_post_drain_init
+};
+
+struct drain_rec {
+	snd_pcm_substream_t *substream;
+	wait_queue_t wait;
+	snd_pcm_uframes_t stop_threshold;
+};
 
-static int snd_pcm_playback_drain(snd_pcm_substream_t * substream)
+static int snd_pcm_drop(snd_pcm_substream_t *substream);
+
+/*
+ * Drain the stream(s).
+ * When the substream is linked, sync until the draining of all playback streams
+ * is finished.
+ * After this call, all streams are supposed to be either SETUP or DRAINING
+ * (capture only) state.
+ */
+static int snd_pcm_drain(snd_pcm_substream_t *substream)
 {
 	snd_card_t *card;
 	snd_pcm_runtime_t *runtime;
-	int err, result = 0;
-	wait_queue_t wait;
-	enum { READY, EXPIRED, SUSPENDED, SIGNALED } state = READY;
-	snd_pcm_uframes_t stop_threshold;
+	struct list_head *pos;
+	int result = 0;
+	int i, num_drecs;
+	struct drain_rec *drec, drec_tmp, *d;
 
 	snd_assert(substream != NULL, return -ENXIO);
-	snd_assert(substream->stream == SNDRV_PCM_STREAM_PLAYBACK, return -EINVAL);
-	runtime = substream->runtime;
 	card = substream->pcm->card;
+	runtime = substream->runtime;
 
+	if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
+		return -EBADFD;
+
+	down_read(&snd_pcm_link_rwsem);
 	snd_power_lock(card);
-	snd_pcm_stream_lock_irq(substream);
+	if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
+		result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
+		if (result < 0)
+			goto _unlock;
+	}
 
-	/* stop_threshold fixup to avoid endless loop when */
-	/* stop_threshold > buffer_size */
-	stop_threshold = runtime->stop_threshold;
-	if (runtime->stop_threshold > runtime->buffer_size)
-		runtime->stop_threshold = runtime->buffer_size;
+	/* allocate temporary record for drain sync */
+	if (snd_pcm_stream_linked(substream)) {
+		drec = kmalloc(substream->group->count * sizeof(*drec), GFP_KERNEL);
+		if (! drec) {
+			result = -ENOMEM;
+			goto _unlock;
+		}
+	} else
+		drec = &drec_tmp;
 
-	switch (runtime->status->state) {
-	case SNDRV_PCM_STATE_PAUSED:
+	snd_pcm_stream_lock_irq(substream);
+	/* resume pause */
+	if (runtime->status->state == SNDRV_PCM_STATE_PAUSED)
 		snd_pcm_pause(substream, 0);
-		/* Fall through */
-	case SNDRV_PCM_STATE_RUNNING:
-	case SNDRV_PCM_STATE_DRAINING:
-		break;
-	case SNDRV_PCM_STATE_SUSPENDED:
-		snd_pcm_stream_unlock_irq(substream);
-		result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
-		snd_pcm_stream_lock_irq(substream);
-		if (result >= 0)
-			snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP);
-		goto _end;
-	case SNDRV_PCM_STATE_OPEN:
-		result = -EBADFD;
-		goto _end;
-	case SNDRV_PCM_STATE_PREPARED:
-		if (!snd_pcm_playback_empty(substream)) {
-			err = snd_pcm_start(substream);
-			if (err < 0) {
-				result = err;
-				goto _end;
-			}
-			break;
-		}
-		/* Fall through */
-	case SNDRV_PCM_STATE_XRUN:
-		snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP);
-		/* Fall through */
-	case SNDRV_PCM_STATE_SETUP:
+
+	/* pre-start/stop - all running streams are changed to DRAINING state */
+	result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0);
+	if (result < 0)
 		goto _end;
-	default: 
-		break; 
-	}
 
-	if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) {
-		if (snd_pcm_playback_empty(substream)) {
-			snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
-			goto _end;
+	/* check streams with PLAYBACK & DRAINING */
+	num_drecs = 0;
+	snd_pcm_group_for_each(pos, substream) {
+		snd_pcm_substream_t *s = snd_pcm_group_substream_entry(pos);
+		runtime = s->runtime;
+		if (runtime->status->state != SNDRV_PCM_STATE_DRAINING) {
+			runtime->status->state = SNDRV_PCM_STATE_SETUP;
+			continue;
+		}
+		if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+			d = &drec[num_drecs++];
+			d->substream = s;
+			init_waitqueue_entry(&d->wait, current);
+			add_wait_queue(&runtime->sleep, &d->wait);
+			/* stop_threshold fixup to avoid endless loop when
+			 * stop_threshold > buffer_size
+			 */
+			d->stop_threshold = runtime->stop_threshold;
+			if (runtime->stop_threshold > runtime->buffer_size)
+				runtime->stop_threshold = runtime->buffer_size;
 		}
-		snd_pcm_change_state(substream, SNDRV_PCM_STATE_DRAINING);
 	}
 
-	if (substream->ffile->f_flags & O_NONBLOCK) {
-		result = -EAGAIN;
+	if (! num_drecs)
 		goto _end;
-	}
 
-	init_waitqueue_entry(&wait, current);
-	add_wait_queue(&runtime->sleep, &wait);
-	while (1) {
+	for (;;) {
 		long tout;
 		if (signal_pending(current)) {
-			state = SIGNALED;
+			result = -ERESTARTSYS;
 			break;
 		}
 		set_current_state(TASK_INTERRUPTIBLE);
@@ -1309,177 +1418,81 @@
 		snd_power_lock(card);
 		snd_pcm_stream_lock_irq(substream);
 		if (tout == 0) {
-			state = runtime->status->state == SNDRV_PCM_STATE_SUSPENDED ? SUSPENDED : EXPIRED;
+			if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
+				result = -ESTRPIPE;
+			else {
+				snd_printd("playback drain error (DMA or IRQ trouble?)\n");
+				snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
+				result = -EIO;
+			}
 			break;
 		}
-		if (runtime->status->state != SNDRV_PCM_STATE_DRAINING) {
-			state = READY;
-			break;
+		/* all finished? */
+		for (i = 0; i < num_drecs; i++) {
+			runtime = drec[i].substream->runtime;
+			if (runtime->status->state == SNDRV_PCM_STATE_DRAINING)
+				break;
 		}
+		if (i == num_drecs)
+			break;
 	}
-	remove_wait_queue(&runtime->sleep, &wait);
-
-	switch (state) {
-	case SIGNALED:
-		result = -ERESTARTSYS;
-		goto _end;
-	case SUSPENDED:
-		result = -ESTRPIPE;
-		goto _end;
-	case EXPIRED:
-		snd_printd("playback drain error (DMA or IRQ trouble?)\n");
-		result = -EIO;
-		goto _end;
-	default:
-		break;
+	for (i = 0; i < num_drecs; i++) {
+		d = &drec[i];
+		runtime = d->substream->runtime;
+		remove_wait_queue(&runtime->sleep, &d->wait);
+		runtime->stop_threshold = d->stop_threshold;
 	}
 
-      _end:
-	runtime->stop_threshold = stop_threshold;
+ _end:
 	snd_pcm_stream_unlock_irq(substream);
+	if (drec && drec != &drec_tmp)
+		kfree(drec);
+ _unlock:
 	snd_power_unlock(card);
-	if (state == EXPIRED)
-		snd_pcm_playback_drop(substream);
+	up_read(&snd_pcm_link_rwsem);
 
 	return result;
 }
 
-static int snd_pcm_playback_drop(snd_pcm_substream_t *substream)
+/*
+ * drop ioctl
+ *
+ * Immediately put all linked substreams into SETUP state.
+ */
+static int snd_pcm_drop(snd_pcm_substream_t *substream)
 {
-	snd_pcm_runtime_t *runtime = substream->runtime;
-	snd_card_t *card = substream->pcm->card;
-	int res = 0;
+	snd_pcm_runtime_t *runtime;
+	snd_card_t *card;
+	int result = 0;
 	
-	snd_power_lock(card);
-	snd_pcm_stream_lock_irq(substream);
-	switch (runtime->status->state) {
-	case SNDRV_PCM_STATE_OPEN:
-		res = -EBADFD;
-		break;
-	case SNDRV_PCM_STATE_SETUP:
-		break;
-	case SNDRV_PCM_STATE_PAUSED:
-		snd_pcm_pause(substream, 0);
-		/* Fall through */
-	case SNDRV_PCM_STATE_RUNNING:
-	case SNDRV_PCM_STATE_DRAINING:
-		if (snd_pcm_update_hw_ptr(substream) >= 0) {
-			snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
-			break;
-		}
-		/* Fall through */
-	case SNDRV_PCM_STATE_PREPARED:
-	case SNDRV_PCM_STATE_XRUN:
-		snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP);
-		break;
-	case SNDRV_PCM_STATE_SUSPENDED:
-		snd_pcm_stream_unlock_irq(substream);
-		res = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
-		snd_pcm_stream_lock_irq(substream);
-		if (res >= 0)
-			snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP);
-		break;
-	default:
-		break; 
-	}
-	runtime->control->appl_ptr = runtime->status->hw_ptr;
-	snd_pcm_stream_unlock_irq(substream);
-	snd_power_unlock(card);
-	return res;
-}
+	snd_assert(substream != NULL, return -ENXIO);
+	runtime = substream->runtime;
+	card = substream->pcm->card;
 
-static int snd_pcm_capture_drain(snd_pcm_substream_t * substream)
-{
-	snd_pcm_runtime_t *runtime = substream->runtime;
-	snd_card_t *card = substream->pcm->card;
-	int res = 0;
+	if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
+		return -EBADFD;
 
 	snd_power_lock(card);
-	snd_pcm_stream_lock_irq(substream);
-	switch (runtime->status->state) {
-	case SNDRV_PCM_STATE_OPEN:
-		res = -EBADFD;
-		break;
-	case SNDRV_PCM_STATE_PREPARED:
-		snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP);
-		break;
-	case SNDRV_PCM_STATE_SETUP:
-	case SNDRV_PCM_STATE_DRAINING:
-		break;
-	case SNDRV_PCM_STATE_PAUSED:
-		snd_pcm_pause(substream, 0);
-		/* Fall through */
-	case SNDRV_PCM_STATE_RUNNING:
-		if (snd_pcm_update_hw_ptr(substream) >= 0) {
-			snd_pcm_stop(substream, 
-				     snd_pcm_capture_avail(runtime) > 0 ?
-				     SNDRV_PCM_STATE_DRAINING : SNDRV_PCM_STATE_SETUP);
-			break;
-		}
-		/* Fall through */
-	case SNDRV_PCM_STATE_XRUN:
-	       _xrun_recovery:
-		snd_pcm_change_state(substream, 
-				     snd_pcm_capture_avail(runtime) > 0 ?
-				     SNDRV_PCM_STATE_DRAINING : SNDRV_PCM_STATE_SETUP);
-		break;
-	case SNDRV_PCM_STATE_SUSPENDED:
-		snd_pcm_stream_unlock_irq(substream);
-		res = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
-		snd_pcm_stream_lock_irq(substream);
-		if (res >= 0)
-			goto _xrun_recovery;
-		break;
-	default: 
-		break; 
+	if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
+		result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
+		if (result < 0)
+			goto _unlock;
 	}
-	snd_pcm_stream_unlock_irq(substream);
-	snd_power_unlock(card);
-	return res;
-}
 
-static int snd_pcm_capture_drop(snd_pcm_substream_t * substream)
-{
-	snd_pcm_runtime_t *runtime = substream->runtime;
-	snd_card_t *card = substream->pcm->card;
-	int res = 0;
-
-	snd_power_lock(card);
 	snd_pcm_stream_lock_irq(substream);
-	switch (runtime->status->state) {
-	case SNDRV_PCM_STATE_OPEN:
-		res = -EBADFD;
-		break;
-	case SNDRV_PCM_STATE_SETUP:
-		break;
-	case SNDRV_PCM_STATE_PAUSED:
+	/* resume pause */
+	if (runtime->status->state == SNDRV_PCM_STATE_PAUSED)
 		snd_pcm_pause(substream, 0);
-		/* Fall through */
-	case SNDRV_PCM_STATE_RUNNING:
-		snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
-		break;
-	case SNDRV_PCM_STATE_SUSPENDED:
-		snd_pcm_stream_unlock_irq(substream);
-		res = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
-		snd_pcm_stream_lock_irq(substream);
-		if (res < 0)
-			goto _end;
-		/* Fall through */
-	case SNDRV_PCM_STATE_PREPARED:
-	case SNDRV_PCM_STATE_DRAINING:
-	case SNDRV_PCM_STATE_XRUN:
-		snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP);
-		break;
-	default: 
-		break; 
-	}
-	runtime->control->appl_ptr = runtime->status->hw_ptr;
-       _end:
+
+	snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
+	/* runtime->control->appl_ptr = runtime->status->hw_ptr; */
 	snd_pcm_stream_unlock_irq(substream);
+ _unlock:
 	snd_power_unlock(card);
-	return res;
+	return result;
 }
 
+
 /* WARNING: Don't forget to fput back the file */
 extern int snd_major;
 static struct file *snd_pcm_file_fd(int fd)
@@ -1505,6 +1518,9 @@
 	return file;
 }
 
+/*
+ * PCM link handling
+ */
 static int snd_pcm_link(snd_pcm_substream_t *substream, int fd)
 {
 	int res = 0;
@@ -1512,12 +1528,6 @@
 	snd_pcm_file_t *pcm_file;
 	snd_pcm_substream_t *substream1;
 
-	snd_pcm_stream_lock_irq(substream);
-	if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
-		snd_pcm_stream_unlock_irq(substream);
-		return -EBADFD;
-	}
-	snd_pcm_stream_unlock_irq(substream);
 	file = snd_pcm_file_fd(fd);
 	if (!file)
 		return -EBADFD;
@@ -1525,7 +1535,8 @@
 	substream1 = pcm_file->substream;
 	down_write(&snd_pcm_link_rwsem);
 	write_lock_irq(&snd_pcm_link_rwlock);
-	if (substream->runtime->status->state != substream1->runtime->status->state) {
+	if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN ||
+	    substream->runtime->status->state != substream1->runtime->status->state) {
 		res = -EBADFD;
 		goto _end;
 	}
@@ -1542,8 +1553,10 @@
 		spin_lock_init(&substream->group->lock);
 		INIT_LIST_HEAD(&substream->group->substreams);
 		list_add_tail(&substream->link_list, &substream->group->substreams);
+		substream->group->count = 1;
 	}
 	list_add_tail(&substream1->link_list, &substream->group->substreams);
+	substream->group->count++;
 	substream1->group = substream->group;
  _end:
 	write_unlock_irq(&snd_pcm_link_rwlock);
@@ -1562,7 +1575,7 @@
 static int snd_pcm_unlink(snd_pcm_substream_t *substream)
 {
 	struct list_head *pos;
-	int res = 0, count = 0;
+	int res = 0;
 
 	down_write(&snd_pcm_link_rwsem);
 	write_lock_irq(&snd_pcm_link_rwlock);
@@ -1571,11 +1584,8 @@
 		goto _end;
 	}
 	list_del(&substream->link_list);
-	snd_pcm_group_for_each(pos, substream) {
-		if (++count > 1)
-			break;
-	}
-	if (count == 1) {	/* detach the last stream, too */
+	substream->group->count--;
+	if (substream->group->count == 1) {	/* detach the last stream, too */
 		snd_pcm_group_for_each(pos, substream) {
 			relink_to_local(snd_pcm_group_substream_entry(pos));
 			break;
@@ -1589,6 +1599,9 @@
 	return res;
 }
 
+/*
+ * hw configurator
+ */
 static int snd_pcm_hw_rule_mul(snd_pcm_hw_params_t *params,
 			       snd_pcm_hw_rule_t *rule)
 {
@@ -1973,6 +1986,7 @@
 
 	str = substream->pstr;
 	substream->file = pcm_file;
+	substream->no_mmap_ctrl = 0;
 
 	pcm_file->substream = substream;
 
@@ -2076,10 +2090,7 @@
 	snd_assert(substream != NULL, return -ENXIO);
 	snd_assert(!atomic_read(&substream->runtime->mmap_count), );
 	pcm = substream->pcm;
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		snd_pcm_playback_drop(substream);
-	else
-		snd_pcm_capture_drop(substream);
+	snd_pcm_drop(substream);
 	fasync_helper(-1, file, 0, &substream->runtime->fasync);
 	down(&pcm->open_mutex);
 	snd_pcm_release_file(pcm_file);
@@ -2435,7 +2446,7 @@
 	case SNDRV_PCM_IOCTL_RESET:
 		return snd_pcm_reset(substream);
 	case SNDRV_PCM_IOCTL_START:
-		return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, 0);
+		return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, SNDRV_PCM_STATE_RUNNING);
 	case SNDRV_PCM_IOCTL_LINK:
 		return snd_pcm_link(substream, (int)(unsigned long) arg);
 	case SNDRV_PCM_IOCTL_UNLINK:
@@ -2454,6 +2465,10 @@
 		return snd_pcm_hw_refine_old_user(substream, arg);
 	case SNDRV_PCM_IOCTL_HW_PARAMS_OLD:
 		return snd_pcm_hw_params_old_user(substream, arg);
+	case SNDRV_PCM_IOCTL_DRAIN:
+		return snd_pcm_drain(substream);
+	case SNDRV_PCM_IOCTL_DROP:
+		return snd_pcm_drop(substream);
 	}
 	snd_printd("unknown ioctl = 0x%x\n", cmd);
 	return -ENOTTY;
@@ -2542,10 +2557,6 @@
 		snd_pcm_stream_unlock_irq(substream);
 		return res;
 	}
-	case SNDRV_PCM_IOCTL_DRAIN:
-		return snd_pcm_playback_drain(substream);
-	case SNDRV_PCM_IOCTL_DROP:
-		return snd_pcm_playback_drop(substream);
 	}
 	return snd_pcm_common_ioctl1(substream, cmd, arg);
 }
@@ -2625,10 +2636,6 @@
 		__put_user(result, _frames);
 		return result < 0 ? result : 0;
 	}
-	case SNDRV_PCM_IOCTL_DRAIN:
-		return snd_pcm_capture_drain(substream);
-	case SNDRV_PCM_IOCTL_DROP:
-		return snd_pcm_capture_drop(substream);
 	}
 	return snd_pcm_common_ioctl1(substream, cmd, arg);
 }
@@ -3092,6 +3099,7 @@
 	area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
 #endif
 	area->vm_ops = &snd_pcm_vm_ops_data_mmio;
+	area->vm_private_data = substream;
 	area->vm_flags |= VM_IO;
 	size = area->vm_end - area->vm_start;
 	offset = area->vm_pgoff << PAGE_SHIFT;
@@ -3158,8 +3166,12 @@
 	offset = area->vm_pgoff << PAGE_SHIFT;
 	switch (offset) {
 	case SNDRV_PCM_MMAP_OFFSET_STATUS:
+		if (substream->no_mmap_ctrl)
+			return -ENXIO;
 		return snd_pcm_mmap_status(substream, file, area);
 	case SNDRV_PCM_MMAP_OFFSET_CONTROL:
+		if (substream->no_mmap_ctrl)
+			return -ENXIO;
 		return snd_pcm_mmap_control(substream, file, area);
 	default:
 		return snd_pcm_mmap_data(substream, file, area);
diff -Nru a/sound/core/rawmidi.c b/sound/core/rawmidi.c
--- a/sound/core/rawmidi.c	2004-12-24 13:36:19 -08:00
+++ b/sound/core/rawmidi.c	2004-12-24 13:36:19 -08:00
@@ -42,10 +42,9 @@
 #ifdef CONFIG_SND_OSSEMUL
 static int midi_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 0};
 static int amidi_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
-static int boot_devs;
-module_param_array(midi_map, int, boot_devs, 0444);
+module_param_array(midi_map, int, NULL, 0444);
 MODULE_PARM_DESC(midi_map, "Raw MIDI device number assigned to 1st OSS device.");
-module_param_array(amidi_map, int, boot_devs, 0444);
+module_param_array(amidi_map, int, NULL, 0444);
 MODULE_PARM_DESC(amidi_map, "Raw MIDI device number assigned to 2nd OSS device.");
 #endif /* CONFIG_SND_OSSEMUL */
 
diff -Nru a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
--- a/sound/core/seq/oss/seq_oss.c	2004-12-24 13:37:18 -08:00
+++ b/sound/core/seq/oss/seq_oss.c	2004-12-24 13:37:18 -08:00
@@ -78,16 +78,17 @@
 		snd_seq_oss_synth_unregister,
 	};
 
+	snd_seq_autoload_lock();
 	if ((rc = register_device()) < 0)
-		return rc;
+		goto error;
 	if ((rc = register_proc()) < 0) {
 		unregister_device();
-		return rc;
+		goto error;
 	}
 	if ((rc = snd_seq_oss_create_client()) < 0) {
 		unregister_proc();
 		unregister_device();
-		return rc;
+		goto error;
 	}
 
 	if ((rc = snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OSS, &ops,
@@ -95,12 +96,15 @@
 		snd_seq_oss_delete_client();
 		unregister_proc();
 		unregister_device();
-		return rc;
+		goto error;
 	}
 
 	/* success */
 	snd_seq_oss_synth_init();
-	return 0;
+
+ error:
+	snd_seq_autoload_unlock();
+	return rc;
 }
 
 static void __exit alsa_seq_oss_exit(void)
diff -Nru a/sound/core/seq/seq.c b/sound/core/seq/seq.c
--- a/sound/core/seq/seq.c	2004-12-24 13:37:04 -08:00
+++ b/sound/core/seq/seq.c	2004-12-24 13:37:04 -08:00
@@ -51,8 +51,7 @@
 MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer.");
 MODULE_LICENSE("GPL");
 
-static int boot_devs;
-module_param_array(seq_client_load, int, boot_devs, 0444);
+module_param_array(seq_client_load, int, NULL, 0444);
 MODULE_PARM_DESC(seq_client_load, "The numbers of global (system) clients to load through kmod.");
 module_param(seq_default_timer_class, int, 0644);
 MODULE_PARM_DESC(seq_default_timer_class, "The default timer class.");
@@ -71,35 +70,37 @@
  *  INIT PART
  */
 
-
 static int __init alsa_seq_init(void)
 {
 	int err;
 
+	snd_seq_autoload_lock();
 	if ((err = client_init_data()) < 0)
-		return err;
+		goto error;
 
 	/* init memory, room for selected events */
 	if ((err = snd_sequencer_memory_init()) < 0)
-		return err;
+		goto error;
 
 	/* init event queues */
 	if ((err = snd_seq_queues_init()) < 0)
-		return err;
+		goto error;
 
 	/* register sequencer device */
 	if ((err = snd_sequencer_device_init()) < 0)
-		return err;
+		goto error;
 
 	/* register proc interface */
 	if ((err = snd_seq_info_init()) < 0)
-		return err;
+		goto error;
 
 	/* register our internal client */
 	if ((err = snd_seq_system_client_init()) < 0)
-		return err;
+		goto error;
 
-	return 0;
+ error:
+	snd_seq_autoload_unlock();
+	return err;
 }
 
 static void __exit alsa_seq_exit(void)
diff -Nru a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
--- a/sound/core/seq/seq_clientmgr.c	2004-12-24 13:36:18 -08:00
+++ b/sound/core/seq/seq_clientmgr.c	2004-12-24 13:36:18 -08:00
@@ -420,7 +420,10 @@
 			count -= err;
 			buf += err;
 		} else {
-			copy_to_user(buf, &cell->event, sizeof(snd_seq_event_t));
+			if (copy_to_user(buf, &cell->event, sizeof(snd_seq_event_t))) {
+				err = -EFAULT;
+				break;
+			}
 			count -= sizeof(snd_seq_event_t);
 			buf += sizeof(snd_seq_event_t);
 		}
diff -Nru a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
--- a/sound/core/seq/seq_device.c	2004-12-24 13:36:31 -08:00
+++ b/sound/core/seq/seq_device.c	2004-12-24 13:36:31 -08:00
@@ -41,6 +41,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/seq_device.h>
+#include <sound/seq_kernel.h>
 #include <sound/initval.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
@@ -125,11 +126,31 @@
  * load all registered drivers (called from seq_clientmgr.c)
  */
 
+#ifdef CONFIG_KMOD
+/* avoid auto-loading during module_init() */
+static int snd_seq_in_init;
+void snd_seq_autoload_lock(void)
+{
+	snd_seq_in_init++;
+}
+
+void snd_seq_autoload_unlock(void)
+{
+	snd_seq_in_init--;
+}
+#endif
+
 void snd_seq_device_load_drivers(void)
 {
 #ifdef CONFIG_KMOD
 	struct list_head *head;
 
+	/* Calling request_module during module_init()
+	 * may cause blocking.
+	 */
+	if (snd_seq_in_init)
+		return;
+
 	if (! current->fs->root)
 		return;
 
@@ -309,12 +330,16 @@
 	    entry->init_device == NULL || entry->free_device == NULL)
 		return -EINVAL;
 
+	snd_seq_autoload_lock();
 	ops = find_driver(id, 1);
-	if (ops == NULL)
+	if (ops == NULL) {
+		snd_seq_autoload_unlock();
 		return -ENOMEM;
+	}
 	if (ops->driver & DRIVER_LOADED) {
 		snd_printk(KERN_WARNING "driver_register: driver '%s' already exists\n", id);
 		unlock_driver(ops);
+		snd_seq_autoload_unlock();
 		return -EBUSY;
 	}
 
@@ -332,6 +357,7 @@
 	up(&ops->reg_mutex);
 
 	unlock_driver(ops);
+	snd_seq_autoload_unlock();
 
 	return 0;
 }
@@ -543,3 +569,7 @@
 EXPORT_SYMBOL(snd_seq_device_new);
 EXPORT_SYMBOL(snd_seq_device_register_driver);
 EXPORT_SYMBOL(snd_seq_device_unregister_driver);
+#ifdef CONFIG_KMOD
+EXPORT_SYMBOL(snd_seq_autoload_lock);
+EXPORT_SYMBOL(snd_seq_autoload_unlock);
+#endif
diff -Nru a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c
--- a/sound/core/seq/seq_dummy.c	2004-12-24 13:36:55 -08:00
+++ b/sound/core/seq/seq_dummy.c	2004-12-24 13:36:55 -08:00
@@ -256,7 +256,11 @@
 
 static int __init alsa_seq_dummy_init(void)
 {
-	return register_client();
+	int err;
+	snd_seq_autoload_lock();
+	err = register_client();
+	snd_seq_autoload_unlock();
+	return err;
 }
 
 static void __exit alsa_seq_dummy_exit(void)
diff -Nru a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
--- a/sound/core/seq/seq_midi.c	2004-12-24 13:37:18 -08:00
+++ b/sound/core/seq/seq_midi.c	2004-12-24 13:37:18 -08:00
@@ -279,7 +279,7 @@
 	cinfo.client = client->seq_client;
 	cinfo.type = KERNEL_CLIENT;
 	name = rmidi->name[0] ? (const char *)rmidi->name : "External MIDI";
-	snprintf(cinfo.name, sizeof(cinfo.name), "%s - Rawmidi %d", name, card->number);
+	strlcpy(cinfo.name, name, sizeof(cinfo.name));
 	return snd_seq_kernel_client_ctl(client->seq_client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo);
 }
 
@@ -464,7 +464,9 @@
 		snd_seq_midisynth_unregister_port,
 	};
 	memset(&synths, 0, sizeof(synths));
+	snd_seq_autoload_lock();
 	snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_MIDISYNTH, &ops, 0);
+	snd_seq_autoload_unlock();
 	return 0;
 }
 
diff -Nru a/sound/drivers/Kconfig b/sound/drivers/Kconfig
--- a/sound/drivers/Kconfig	2004-12-24 13:37:03 -08:00
+++ b/sound/drivers/Kconfig	2004-12-24 13:37:03 -08:00
@@ -30,8 +30,14 @@
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include dummy driver. This driver does nothing, but
-	  emulates various mixer controls and PCM devices.
+	  Say Y here to include the dummy driver.  This driver does
+	  nothing, but emulates various mixer controls and PCM devices.
+
+	  You don't need this unless you're testing the hardware support
+	  of programs using the ALSA API.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-dummy.
 
 config SND_VIRMIDI
 	tristate "Virtual MIDI soundcard"
@@ -39,8 +45,14 @@
 	select SND_TIMER
 	select SND_RAWMIDI
 	help
-	  Say 'Y' or 'M' to include virtual MIDI driver. This driver allows to
-	  connect applications using raw MIDI devices to sequencer.
+	  Say Y here to include the virtual MIDI driver.  This driver
+	  allows to connect applications using raw MIDI devices to
+	  sequencer clients.
+
+	  If you don't know what MIDI is, say N here.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-virmidi.
 
 config SND_MTPAV
 	tristate "MOTU MidiTimePiece AV multiport MIDI"
@@ -48,23 +60,39 @@
 	select SND_TIMER
 	select SND_RAWMIDI
 	help
-	  Say 'Y' or 'M' to include support for MOTU MidiTimePiece AV multiport
-	  MIDI adapter.
+	  To use a MOTU MidiTimePiece AV multiport MIDI adapter
+	  connected to the parallel port, say Y here and make sure that
+	  the standard parallel port driver isn't used for the port.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-mtpav.
 
 config SND_SERIAL_U16550
-	tristate "UART16550 - MIDI only driver"
+	tristate "UART16550 serial MIDI driver"
 	depends on SND
 	select SND_TIMER
 	select SND_RAWMIDI
 	help
-	  Say 'Y' or 'M' to include support for MIDI serial port driver. It works
-	  with serial UARTs 16550 and better.
+	  To include support for MIDI serial port interfaces, say Y here
+	  and read <file:Documentation/sound/alsa/serial-u16550.txt>.
+	  This driver works with serial UARTs 16550 and better.
+
+	  This driver accesses the serial port hardware directly, so
+	  make sure that the standard serial driver isn't used or
+	  deactivated with setserial before loading this driver.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-serial-u16550.
 
 config SND_MPU401
 	tristate "Generic MPU-401 UART driver"
 	depends on SND
 	select SND_MPU401_UART
 	help
-	  Say 'Y' or 'M' to include support for MPU401 hardware using UART access.
+	  Say Y here to include support for MIDI ports compatible with
+	  the Roland MPU-401 interface in UART mode.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-mpu401.
 
 endmenu
diff -Nru a/sound/drivers/dummy.c b/sound/drivers/dummy.c
--- a/sound/drivers/dummy.c	2004-12-24 13:37:19 -08:00
+++ b/sound/drivers/dummy.c	2004-12-24 13:37:19 -08:00
@@ -128,19 +128,18 @@
 static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
 static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8};
 //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for dummy soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for dummy soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable this dummy soundcard.");
-module_param_array(pcm_devs, int, boot_devs, 0444);
+module_param_array(pcm_devs, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver.");
-module_param_array(pcm_substreams, int, boot_devs, 0444);
+module_param_array(pcm_substreams, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver.");
-//module_param_array(midi_devs, int, boot_devs, 0444);
+//module_param_array(midi_devs, int, NULL, 0444);
 //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver.");
 
 #define MIXER_ADDR_MASTER	0
@@ -557,7 +556,7 @@
 DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_MASTER)
 };
 
-int __init snd_card_dummy_new_mixer(snd_card_dummy_t * dummy)
+static int __init snd_card_dummy_new_mixer(snd_card_dummy_t * dummy)
 {
 	snd_card_t *card = dummy->card;
 	unsigned int idx;
diff -Nru a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
--- a/sound/drivers/mpu401/mpu401.c	2004-12-24 13:37:02 -08:00
+++ b/sound/drivers/mpu401/mpu401.c	2004-12-24 13:37:02 -08:00
@@ -51,21 +51,20 @@
 #endif
 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;	/* MPU-401 port number */
 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* MPU-401 IRQ */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for MPU-401 device.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for MPU-401 device.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable MPU-401 device.");
 #ifdef USE_ACPI_PNP
-module_param_array(acpipnp, bool, boot_devs, 0444);
+module_param_array(acpipnp, bool, NULL, 0444);
 MODULE_PARM_DESC(acpipnp, "ACPI PnP detection for MPU-401 device.");
 #endif
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for MPU-401 device.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device.");
 
 #ifndef CONFIG_ACPI_BUS
diff -Nru a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
--- a/sound/drivers/mpu401/mpu401_uart.c	2004-12-24 13:36:47 -08:00
+++ b/sound/drivers/mpu401/mpu401_uart.c	2004-12-24 13:36:47 -08:00
@@ -70,12 +70,12 @@
 
 static void mpu401_write_mmio(mpu401_t *mpu, unsigned char data, unsigned long addr)
 {
-	writeb(data, (unsigned long*)addr);
+	writeb(data, (void __iomem *)addr);
 }
 
 static unsigned char mpu401_read_mmio(mpu401_t *mpu, unsigned long addr)
 {
-	return readb((unsigned long*)addr);
+	return readb((void __iomem *)addr);
 }
 /*  */
 
diff -Nru a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c
--- a/sound/drivers/opl3/opl3_lib.c	2004-12-24 13:36:31 -08:00
+++ b/sound/drivers/opl3/opl3_lib.c	2004-12-24 13:36:31 -08:00
@@ -85,28 +85,6 @@
 	spin_unlock_irqrestore(&opl3->reg_lock, flags);
 }
 
-void snd_opl3_cs4281_command(opl3_t * opl3, unsigned short cmd, unsigned char val)
-{
-	unsigned long flags;
-	unsigned long port;
-
-	/*
-	 * CS4281 requires a special access to I/O registers
-	 */
-
-	port = (cmd & OPL3_RIGHT) ? opl3->r_port : opl3->l_port;
-
-	spin_lock_irqsave(&opl3->reg_lock, flags);
-
-	writel((unsigned int)cmd, port << 2);
-	udelay(10);
-
-	writel((unsigned int)val, (port + 1) << 2);
-	udelay(30);
-
-	spin_unlock_irqrestore(&opl3->reg_lock, flags);
-}
-
 static int snd_opl3_detect(opl3_t * opl3)
 {
 	/*
@@ -344,6 +322,9 @@
 
 static int snd_opl3_free(opl3_t *opl3)
 {
+	snd_assert(opl3 != NULL, return -ENXIO);
+	if (opl3->private_free)
+		opl3->private_free(opl3);
 	if (opl3->res_l_port) {
 		release_resource(opl3->res_l_port);
 		kfree_nocheck(opl3->res_l_port);
@@ -362,51 +343,89 @@
 	return snd_opl3_free(opl3);
 }
 
-int snd_opl3_create(snd_card_t * card,
-		    unsigned long l_port,
-		    unsigned long r_port,
-		    unsigned short hardware,
-		    int integrated,
-		    opl3_t ** ropl3)
+int snd_opl3_new(snd_card_t *card,
+		 unsigned short hardware,
+		 opl3_t **ropl3)
 {
-	opl3_t *opl3;
-	int err;
 	static snd_device_ops_t ops = {
 		.dev_free = snd_opl3_dev_free,
 	};
+	opl3_t *opl3;
+	int err;
 
 	*ropl3 = NULL;
-
 	opl3 = kcalloc(1, sizeof(*opl3), GFP_KERNEL);
 	if (opl3 == NULL)
 		return -ENOMEM;
 
-	if (integrated)
-		goto __step1; /* ports are already reserved */
+	opl3->card = card;
+	opl3->hardware = hardware;
+	spin_lock_init(&opl3->reg_lock);
+	spin_lock_init(&opl3->timer_lock);
+	init_MUTEX(&opl3->access_mutex);
 
-	if ((opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)")) == NULL) {
-		snd_printk(KERN_ERR "opl3: can't grab left port 0x%lx\n", l_port);
+	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, opl3, &ops)) < 0) {
 		snd_opl3_free(opl3);
-		return -EBUSY;
+		return err;
 	}
-	if (r_port != 0 &&
-	    (opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)")) == NULL) {
-		snd_printk(KERN_ERR "opl3: can't grab right port 0x%lx\n", r_port);
-		snd_opl3_free(opl3);
-		return -EBUSY;
+
+	*ropl3 = opl3;
+	return 0;
+}
+
+int snd_opl3_init(opl3_t *opl3)
+{
+	if (! opl3->command) {
+		printk(KERN_ERR "snd_opl3_init: command not defined!\n");
+		return -EINVAL;
 	}
 
-      __step1:
+	opl3->command(opl3, OPL3_LEFT | OPL3_REG_TEST, OPL3_ENABLE_WAVE_SELECT);
+	/* Melodic mode */
+	opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, 0x00);
 
-	opl3->card = card;
-	opl3->hardware = hardware;
+	switch (opl3->hardware & OPL3_HW_MASK) {
+	case OPL3_HW_OPL2:
+		opl3->max_voices = MAX_OPL2_VOICES;
+		break;
+	case OPL3_HW_OPL3:
+	case OPL3_HW_OPL4:
+		opl3->max_voices = MAX_OPL3_VOICES;
+		/* Enter OPL3 mode */
+		opl3->command(opl3, OPL3_RIGHT | OPL3_REG_MODE, OPL3_OPL3_ENABLE);
+	}
+	return 0;
+}
+
+int snd_opl3_create(snd_card_t * card,
+		    unsigned long l_port,
+		    unsigned long r_port,
+		    unsigned short hardware,
+		    int integrated,
+		    opl3_t ** ropl3)
+{
+	opl3_t *opl3;
+	int err;
+
+	*ropl3 = NULL;
+	if ((err = snd_opl3_new(card, hardware, &opl3)) < 0)
+		return err;
+	if (! integrated) {
+		if ((opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)")) == NULL) {
+			snd_printk(KERN_ERR "opl3: can't grab left port 0x%lx\n", l_port);
+			snd_opl3_free(opl3);
+			return -EBUSY;
+		}
+		if (r_port != 0 &&
+		    (opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)")) == NULL) {
+			snd_printk(KERN_ERR "opl3: can't grab right port 0x%lx\n", r_port);
+			snd_opl3_free(opl3);
+			return -EBUSY;
+		}
+	}
 	opl3->l_port = l_port;
 	opl3->r_port = r_port;
 
-	spin_lock_init(&opl3->reg_lock);
-	spin_lock_init(&opl3->timer_lock);
-	init_MUTEX(&opl3->access_mutex);
-
 	switch (opl3->hardware) {
 	/* some hardware doesn't support timers */
 	case OPL3_HW_OPL3_SV:
@@ -414,9 +433,6 @@
 	case OPL3_HW_OPL3_FM801:
 		opl3->command = &snd_opl3_command;
 		break;
-	case OPL3_HW_OPL3_CS4281:
-		opl3->command = &snd_opl3_cs4281_command;
-		break;
 	default:
 		opl3->command = &snd_opl2_command;
 		if ((err = snd_opl3_detect(opl3)) < 0) {
@@ -433,23 +449,7 @@
 		}
 	}
 
-	opl3->command(opl3, OPL3_LEFT | OPL3_REG_TEST, OPL3_ENABLE_WAVE_SELECT);
-	opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, 0x00);	/* Melodic mode */
-
-	switch (opl3->hardware & OPL3_HW_MASK) {
-	case OPL3_HW_OPL2:
-		opl3->max_voices = MAX_OPL2_VOICES;
-		break;
-	case OPL3_HW_OPL3:
-	case OPL3_HW_OPL4:
-		opl3->max_voices = MAX_OPL3_VOICES;
-		snd_assert(opl3->r_port != 0, snd_opl3_free(opl3); return -ENODEV);
-		opl3->command(opl3, OPL3_RIGHT | OPL3_REG_MODE, OPL3_OPL3_ENABLE);	/* Enter OPL3 mode */
-	}
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, opl3, &ops)) < 0) {
-		snd_opl3_free(opl3);
-		return err;
-	}
+	snd_opl3_init(opl3);
 
 	*ropl3 = opl3;
 	return 0;
@@ -531,6 +531,8 @@
 }
 
 EXPORT_SYMBOL(snd_opl3_interrupt);
+EXPORT_SYMBOL(snd_opl3_new);
+EXPORT_SYMBOL(snd_opl3_init);
 EXPORT_SYMBOL(snd_opl3_create);
 EXPORT_SYMBOL(snd_opl3_timer_new);
 EXPORT_SYMBOL(snd_opl3_hwdep_new);
diff -Nru a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
--- a/sound/drivers/serial-u16550.c	2004-12-24 13:36:18 -08:00
+++ b/sound/drivers/serial-u16550.c	2004-12-24 13:36:18 -08:00
@@ -76,30 +76,29 @@
 static int ins[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};	/* 1 to 16 */
 static int adaptor[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = SNDRV_SERIAL_SOUNDCANVAS};
 static int droponfull[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS -1)] = SNDRV_SERIAL_NORMALBUFF };
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Serial MIDI.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Serial MIDI.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable UART16550A chip.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for UART16550A chip.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for UART16550A chip.");
-module_param_array(speed, int, boot_devs, 0444);
+module_param_array(speed, int, NULL, 0444);
 MODULE_PARM_DESC(speed, "Speed in bauds.");
-module_param_array(base, int, boot_devs, 0444);
+module_param_array(base, int, NULL, 0444);
 MODULE_PARM_DESC(base, "Base for divisor in bauds.");
-module_param_array(outs, int, boot_devs, 0444);
+module_param_array(outs, int, NULL, 0444);
 MODULE_PARM_DESC(outs, "Number of MIDI outputs.");
-module_param_array(ins, int, boot_devs, 0444);
+module_param_array(ins, int, NULL, 0444);
 MODULE_PARM_DESC(ins, "Number of MIDI inputs.");
-module_param_array(droponfull, bool, boot_devs, 0444);
+module_param_array(droponfull, bool, NULL, 0444);
 MODULE_PARM_DESC(droponfull, "Flag to enable drop-on-full buffer mode");
 
-module_param_array(adaptor, int, boot_devs, 0444);
+module_param_array(adaptor, int, NULL, 0444);
 MODULE_PARM_DESC(adaptor, "Type of adaptor.");
 
 /*#define SNDRV_SERIAL_MS124W_MB_NOCOMBO 1*/  /* Address outs as 0-3 instead of bitmap */
diff -Nru a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c
--- a/sound/drivers/virmidi.c	2004-12-24 13:36:31 -08:00
+++ b/sound/drivers/virmidi.c	2004-12-24 13:36:31 -08:00
@@ -65,15 +65,14 @@
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
 static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for virmidi soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for virmidi soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable this soundcard.");
-module_param_array(midi_devs, int, boot_devs, 0444);
+module_param_array(midi_devs, int, NULL, 0444);
 MODULE_PARM_DESC(midi_devs, "MIDI devices # (1-8)");
 
 typedef struct snd_card_virmidi {
diff -Nru a/sound/isa/Kconfig b/sound/isa/Kconfig
--- a/sound/isa/Kconfig	2004-12-24 13:37:19 -08:00
+++ b/sound/isa/Kconfig	2004-12-24 13:37:19 -08:00
@@ -10,17 +10,25 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Analog Devices SoundPort AD1816A or
-	  compatible sound chips.
+	  Say Y here to include support for Analog Devices SoundPort
+	  AD1816A or compatible sound chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ad1816a.
 
 config SND_AD1848
 	tristate "Generic AD1848/CS4248 driver"
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for AD1848 (Analog Devices) or CS4248 
-	  (Cirrus Logic - Crystal Semiconductors) chips. Please, for newer chips
-	  from Cirrus Logic, use CS4231, CS4232 or CS4236+ driver.
+	  Say Y here to include support for AD1848 (Analog Devices) or
+	  CS4248 (Cirrus Logic - Crystal Semiconductors) chips.
+	  
+	  For newer chips from Cirrus Logic, use the CS4231, CS4232 or
+	  CS4236+ drivers.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ad1848.
 
 config SND_CS4231
 	tristate "Generic Cirrus Logic CS4231 driver"
@@ -28,8 +36,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for CS4231 chips from Cirrus Logic -
-	  Crystal Semiconductors.
+	  Say Y here to include support for CS4231 chips from Cirrus
+	  Logic - Crystal Semiconductors.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-cs4231.
 
 config SND_CS4232
 	tristate "Generic Cirrus Logic CS4232 driver"
@@ -38,8 +49,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for CS4232 chips from Cirrus Logic -
-	  Crystal Semiconductors.
+	  Say Y here to include support for CS4232 chips from Cirrus
+	  Logic - Crystal Semiconductors.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-cs4232.
 
 config SND_CS4236
 	tristate "Generic Cirrus Logic CS4236+ driver"
@@ -48,8 +62,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for CS4235,CS4236,CS4237B,CS4238B,CS4239
-	  chips from Cirrus Logic - Crystal Semiconductors.
+	  Say Y to include support for CS4235,CS4236,CS4237B,CS4238B,
+	  CS4239 chips from Cirrus Logic - Crystal Semiconductors.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-cs4236.
 
 config SND_ES968
 	tristate "Generic ESS ES968 driver"
@@ -57,7 +74,10 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for ESS AudioDrive ES968 chip.
+	  Say Y here to include support for ESS AudioDrive ES968 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-es968.
 
 config SND_ES1688
 	tristate "Generic ESS ES688/ES1688 driver"
@@ -66,7 +86,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for ESS AudioDrive ES688 or ES1688 chips.
+	  Say Y here to include support for ESS AudioDrive ES688 or
+	  ES1688 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-es1688.
 
 config SND_ES18XX
 	tristate "Generic ESS ES18xx driver"
@@ -75,7 +99,10 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for ESS AudioDrive ES18xx chips.
+	  Say Y here to include support for ESS AudioDrive ES18xx chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-es18xx.
 
 config SND_GUS_SYNTH
 	tristate
@@ -87,7 +114,11 @@
 	select SND_PCM
 	select SND_GUS_SYNTH
 	help
-	  Say 'Y' or 'M' to include support for Gravis UltraSound Classic soundcard.
+	  Say Y here to include support for Gravis UltraSound Classic
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-gusclassic.
 
 config SND_GUSEXTREME
 	tristate "Gravis UltraSound Extreme"
@@ -97,7 +128,11 @@
 	select SND_PCM
 	select SND_GUS_SYNTH
 	help
-	  Say 'Y' or 'M' to include support for Gravis UltraSound Extreme soundcard.
+	  Say Y here to include support for Gravis UltraSound Extreme
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-gusextreme.
 
 config SND_GUSMAX
 	tristate "Gravis UltraSound MAX"
@@ -106,7 +141,11 @@
 	select SND_PCM
 	select SND_GUS_SYNTH
 	help
-	  Say 'Y' or 'M' to include support for Gravis UltraSound MAX soundcard.
+	  Say Y here to include support for Gravis UltraSound MAX
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-gusmax.
 
 config SND_INTERWAVE
 	tristate "AMD InterWave, Gravis UltraSound PnP"
@@ -115,9 +154,12 @@
 	select SND_PCM
 	select SND_GUS_SYNTH
 	help
-	  Say 'Y' or 'M' to include support for AMD InterWave based soundcards
-	  (Gravis UltraSound Plug & Play, STB SoundRage32, MED3210, Dynasonic Pro,
-	  Panasonic PCA761AW).
+	  Say Y here to include support for AMD InterWave based
+	  soundcards (Gravis UltraSound Plug & Play, STB SoundRage32,
+	  MED3210, Dynasonic Pro, Panasonic PCA761AW).
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-interwave.
 
 config SND_INTERWAVE_STB
 	tristate "AMD InterWave + TEA6330T (UltraSound 32-Pro)"
@@ -126,8 +168,12 @@
 	select SND_PCM
 	select SND_GUS_SYNTH
 	help
-	  Say 'Y' or 'M' to include support for AMD InterWave based soundcards
-	  with TEA6330T bass and treble regulator (UltraSound 32-Pro).
+	  Say Y here to include support for AMD InterWave based
+	  soundcards with a TEA6330T bass and treble regulator
+	  (UltraSound 32-Pro).
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-interwave-stb.
 
 config SND_OPTI92X_AD1848
 	tristate "OPTi 82C92x - AD1848"
@@ -137,8 +183,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Opti92x soundcards equiped with
-	  AD1848 codec.
+	  Say Y here to include support for soundcards based on Opti
+	  82C92x or OTI-601 chips and using an AD1848 codec.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-opti92x-ad1848.
 
 config SND_OPTI92X_CS4231
 	tristate "OPTi 82C92x - CS4231"
@@ -148,8 +197,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Opti92x soundcards equiped with
-	  CS4231 codec.
+	  Say Y here to include support for soundcards based on Opti
+	  82C92x chips and using a CS4231 codec.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-opti92x-cs4231.
 
 config SND_OPTI93X
 	tristate "OPTi 82C93x"
@@ -158,7 +210,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Opti93x soundcards.
+	  Say Y here to include support for soundcards based on Opti
+	  82C93x chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-opti93x.
 
 config SND_SB8
 	tristate "Sound Blaster 1.0/2.0/Pro (8-bit)"
@@ -167,8 +223,11 @@
 	select SND_RAWMIDI
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Sound Blaster 1.0/2.0/Pro (8-bit)
-	  soundcards or 100% compatible from Creative.
+	  Say Y here to include support for Creative Sound Blaster 1.0/
+	  2.0/Pro (8-bit) or 100% compatible soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-sb8.
 
 config SND_SB16
 	tristate "Sound Blaster 16 (PnP)"
@@ -177,8 +236,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Sound Blaster 16 (including
-	  Plug and Play version).
+	  Say Y here to include support for Sound Blaster 16 soundcards
+	  (including the Plug and Play version).
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-sb16.
 
 config SND_SBAWE
 	tristate "Sound Blaster AWE (32,64) (PnP)"
@@ -187,16 +249,19 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Sound Blaster AWE (including
-	  Plug and Play version).
+	  Say Y here to include support for Sound Blaster AWE soundcards
+	  (including the Plug and Play version).
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-sbawe.
 
 config SND_SB16_CSP
 	bool "Sound Blaster 16/AWE CSP support"
 	depends on (SND_SB16 || SND_SBAWE) && (BROKEN || !PPC)
 	help
-	  Say 'Y' to include support for CSP core. This special coprocessor
-	  can do variable tasks like various compression and decompression
-	  algorithms.
+	  Say Y here to include support for the CSP core.  This special
+	  coprocessor can do variable tasks like various compression and
+	  decompression algorithms.
 
 config SND_WAVEFRONT
 	tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)"
@@ -205,8 +270,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Turtle Beach Maui, Tropez
-	  and Tropez+ soundcards based on Wavefront chip.
+	  Say Y here to include support for Turtle Beach Maui, Tropez
+	  and Tropez+ soundcards based on the Wavefront chip.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-wavefront.
 
 config SND_ALS100
 	tristate "Avance Logic ALS100/ALS120"
@@ -215,8 +283,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Avance Logic ALS100, ALS110,
-	  ALS120 and ALS200 soundcards.
+	  Say Y here to include support for soundcards based on Avance
+	  Logic ALS100, ALS110, ALS120 and ALS200 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-als100.
 
 config SND_AZT2320
 	tristate "Aztech Systems AZT2320"
@@ -225,14 +296,22 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Aztech Systems AZT2320 soundcard.
+	  Say Y here to include support for soundcards based on the
+	  Aztech Systems AZT2320 chip.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-azt2320.
 
 config SND_CMI8330
 	tristate "C-Media CMI8330"
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for C-Media CMI8330 based soundcards.
+	  Say Y here to include support for soundcards based on the
+	  C-Media CMI8330 chip.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-cmi8330.
 
 config SND_DT019X
 	tristate "Diamond Technologies DT-019X, Avance Logic ALS-007"
@@ -241,8 +320,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Diamond Technologies DT-019X and
-	  Avance Logic ALS-007 soundcards.
+	  Say Y here to include support for soundcards based on the
+	  Diamond Technologies DT-019X or Avance Logic ALS-007 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-dt019x.
 
 config SND_OPL3SA2
 	tristate "Yamaha OPL3-SA2/SA3"
@@ -251,14 +333,22 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Yamaha OPL3SA2 or OPL3SA3 chips.
+	  Say Y here to include support for Yamaha OPL3-SA2 and OPL3-SA3
+	  chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-opl3sa2.
 
 config SND_SGALAXY
 	tristate "Aztech Sound Galaxy"
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Aztech Sound Galaxy.
+	  Say Y here to include support for Aztech Sound Galaxy
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-sgalaxy.
 
 config SND_SSCAPE
 	tristate "Ensoniq SoundScape PnP driver"
@@ -267,7 +357,10 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Ensoniq SoundScape PnP
-	  soundcard.
+	  Say Y here to include support for Ensoniq SoundScape PnP
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-sscape.
 
 endmenu
diff -Nru a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
--- a/sound/isa/ad1816a/ad1816a.c	2004-12-24 13:36:31 -08:00
+++ b/sound/isa/ad1816a/ad1816a.c	2004-12-24 13:36:31 -08:00
@@ -53,27 +53,26 @@
 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* Pnp setup */
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* PnP setup */
 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* PnP setup */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ad1816a based soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ad1816a based soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable ad1816a based soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for ad1816a driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ad1816a driver.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port # for ad1816a driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for ad1816a driver.");
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ad1816a driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "1st DMA # for ad1816a driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "2nd DMA # for ad1816a driver.");
 
 struct snd_card_ad1816a {
diff -Nru a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
--- a/sound/isa/ad1848/ad1848.c	2004-12-24 13:36:56 -08:00
+++ b/sound/isa/ad1848/ad1848.c	2004-12-24 13:36:56 -08:00
@@ -44,21 +44,20 @@
 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* 5,7,9,11,12,15 */
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3,5,6,7 */
 static int thinkpad[SNDRV_CARDS];			/* Thinkpad special case */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for AD1848 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for AD1848 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable AD1848 soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for AD1848 driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for AD1848 driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver.");
-module_param_array(thinkpad, bool, boot_devs, 0444);
+module_param_array(thinkpad, bool, NULL, 0444);
 MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series.");
 
 static snd_card_t *snd_ad1848_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
diff -Nru a/sound/isa/als100.c b/sound/isa/als100.c
--- a/sound/isa/als100.c	2004-12-24 13:36:18 -08:00
+++ b/sound/isa/als100.c	2004-12-24 13:36:18 -08:00
@@ -56,27 +56,26 @@
 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* PnP setup */
 static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* PnP setup */
 static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* PnP setup */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for als100 based soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for als100 based soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable als100 based soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for als100 driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for als100 driver.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port # for als100 driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for als100 driver.");
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for als100 driver.");
-module_param_array(dma8, int, boot_devs, 0444);
+module_param_array(dma8, int, NULL, 0444);
 MODULE_PARM_DESC(dma8, "8-bit DMA # for als100 driver.");
-module_param_array(dma16, int, boot_devs, 0444);
+module_param_array(dma16, int, NULL, 0444);
 MODULE_PARM_DESC(dma16, "16-bit DMA # for als100 driver.");
 
 struct snd_card_als100 {
diff -Nru a/sound/isa/azt2320.c b/sound/isa/azt2320.c
--- a/sound/isa/azt2320.c	2004-12-24 13:37:29 -08:00
+++ b/sound/isa/azt2320.c	2004-12-24 13:37:29 -08:00
@@ -65,29 +65,28 @@
 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* Pnp setup */
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* PnP setup */
 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* PnP setup */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for azt2320 based soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for azt2320 based soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable azt2320 based soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for azt2320 driver.");
-module_param_array(wss_port, long, boot_devs, 0444);
+module_param_array(wss_port, long, NULL, 0444);
 MODULE_PARM_DESC(wss_port, "WSS Port # for azt2320 driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for azt2320 driver.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port # for azt2320 driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for azt2320 driver.");
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for azt2320 driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "1st DMA # for azt2320 driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "2nd DMA # for azt2320 driver.");
 
 struct snd_card_azt2320 {
diff -Nru a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
--- a/sound/isa/cmi8330.c	2004-12-24 13:37:43 -08:00
+++ b/sound/isa/cmi8330.c	2004-12-24 13:37:43 -08:00
@@ -78,33 +78,32 @@
 static long wssport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
 static int wssirq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
 static int wssdma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for CMI8330 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string  for CMI8330 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable CMI8330 soundcard.");
 #ifdef CONFIG_PNP
-module_param_array(isapnp, bool, boot_devs, 0444);
+module_param_array(isapnp, bool, NULL, 0444);
 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
 #endif
 
-module_param_array(sbport, long, boot_devs, 0444);
+module_param_array(sbport, long, NULL, 0444);
 MODULE_PARM_DESC(sbport, "Port # for CMI8330 SB driver.");
-module_param_array(sbirq, int, boot_devs, 0444);
+module_param_array(sbirq, int, NULL, 0444);
 MODULE_PARM_DESC(sbirq, "IRQ # for CMI8330 SB driver.");
-module_param_array(sbdma8, int, boot_devs, 0444);
+module_param_array(sbdma8, int, NULL, 0444);
 MODULE_PARM_DESC(sbdma8, "DMA8 for CMI8330 SB driver.");
-module_param_array(sbdma16, int, boot_devs, 0444);
+module_param_array(sbdma16, int, NULL, 0444);
 MODULE_PARM_DESC(sbdma16, "DMA16 for CMI8330 SB driver.");
 
-module_param_array(wssport, long, boot_devs, 0444);
+module_param_array(wssport, long, NULL, 0444);
 MODULE_PARM_DESC(wssport, "Port # for CMI8330 WSS driver.");
-module_param_array(wssirq, int, boot_devs, 0444);
+module_param_array(wssirq, int, NULL, 0444);
 MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver.");
-module_param_array(wssdma, int, boot_devs, 0444);
+module_param_array(wssdma, int, NULL, 0444);
 MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver.");
 
 #define CMI8330_RMUX3D    16
diff -Nru a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
--- a/sound/isa/cs423x/cs4231.c	2004-12-24 13:36:17 -08:00
+++ b/sound/isa/cs423x/cs4231.c	2004-12-24 13:36:17 -08:00
@@ -44,25 +44,24 @@
 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* 9,11,12,15 */
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3,5,6,7 */
 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3,5,6,7 */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for CS4231 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for CS4231 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable CS4231 soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for CS4231 driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for CS4231 driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for CS4231 driver.");
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for CS4231 driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver.");
 
 static snd_card_t *snd_cs4231_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
diff -Nru a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
--- a/sound/isa/cs423x/cs4236.c	2004-12-24 13:36:18 -08:00
+++ b/sound/isa/cs423x/cs4236.c	2004-12-24 13:36:18 -08:00
@@ -92,35 +92,34 @@
 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* 9,11,12,15 */
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3,5,6,7 */
 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3,5,6,7 */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for " IDENT " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for " IDENT " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard.");
 #ifdef CONFIG_PNP
-module_param_array(isapnp, bool, boot_devs, 0444);
+module_param_array(isapnp, bool, NULL, 0444);
 MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
 #endif
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for " IDENT " driver.");
-module_param_array(cport, long, boot_devs, 0444);
+module_param_array(cport, long, NULL, 0444);
 MODULE_PARM_DESC(cport, "Control port # for " IDENT " driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " IDENT " driver.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port # for " IDENT " driver.");
-module_param_array(sb_port, long, boot_devs, 0444);
+module_param_array(sb_port, long, NULL, 0444);
 MODULE_PARM_DESC(sb_port, "SB port # for " IDENT " driver (optional).");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for " IDENT " driver.");
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " IDENT " driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
 
 struct snd_card_cs4236 {
diff -Nru a/sound/isa/dt019x.c b/sound/isa/dt019x.c
--- a/sound/isa/dt019x.c	2004-12-24 13:36:48 -08:00
+++ b/sound/isa/dt019x.c	2004-12-24 13:36:48 -08:00
@@ -50,25 +50,24 @@
 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* PnP setup */
 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* PnP setup */
 static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* PnP setup */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for DT-019X based soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for DT-019X based soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable DT-019X based soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for dt019x driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for dt019x driver.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port # for dt019x driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for dt019x driver.");
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for dt019x driver.");
-module_param_array(dma8, int, boot_devs, 0444);
+module_param_array(dma8, int, NULL, 0444);
 MODULE_PARM_DESC(dma8, "8-bit DMA # for dt019x driver.");
 
 struct snd_card_dt019x {
diff -Nru a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
--- a/sound/isa/es1688/es1688.c	2004-12-24 13:36:34 -08:00
+++ b/sound/isa/es1688/es1688.c	2004-12-24 13:36:34 -08:00
@@ -50,23 +50,22 @@
 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* 5,7,9,10 */
 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* 5,7,9,10 */
 static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3 */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ESx688 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ESx688 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable ESx688 soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for ESx688 driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ESx688 driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for ESx688 driver.");
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver.");
-module_param_array(dma8, int, boot_devs, 0444);
+module_param_array(dma8, int, NULL, 0444);
 MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver.");
 
 static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
diff -Nru a/sound/isa/es18xx.c b/sound/isa/es18xx.c
--- a/sound/isa/es18xx.c	2004-12-24 13:36:48 -08:00
+++ b/sound/isa/es18xx.c	2004-12-24 13:36:48 -08:00
@@ -419,6 +419,11 @@
 		
 	if ((chip->caps & ES18XX_PCM2) && mode == DAC2) {
 		snd_es18xx_mixer_write(chip, 0x70, bits);
+		/*
+		 * Comment from kernel oss driver:
+		 * FKS: fascinating: 0x72 doesn't seem to work.
+		 */
+		snd_es18xx_write(chip, 0xA2, div0);
 		snd_es18xx_mixer_write(chip, 0x72, div0);
 	} else {
 		snd_es18xx_write(chip, 0xA1, bits);
@@ -1853,29 +1858,28 @@
 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* 5,7,9,10 */
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3 */
 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3 */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ES18xx soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ES18xx soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable ES18xx soundcard.");
 #ifdef CONFIG_PNP
-module_param_array(isapnp, bool, boot_devs, 0444);
+module_param_array(isapnp, bool, NULL, 0444);
 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
 #endif
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for ES18xx driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ES18xx driver.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port # for ES18xx driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for ES18xx driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver.");
 
 struct snd_audiodrive {
diff -Nru a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
--- a/sound/isa/gus/gusclassic.c	2004-12-24 13:37:33 -08:00
+++ b/sound/isa/gus/gusclassic.c	2004-12-24 13:37:33 -08:00
@@ -48,27 +48,26 @@
 				/* 0 to 31, (0.59V-4.52V or 0.389V-2.98V) */
 static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for GUS Classic soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for GUS Classic soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable GUS Classic soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for GUS Classic driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for GUS Classic driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for GUS Classic driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "DMA2 # for GUS Classic driver.");
-module_param_array(joystick_dac, int, boot_devs, 0444);
+module_param_array(joystick_dac, int, NULL, 0444);
 MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Classic driver.");
-module_param_array(channels, int, boot_devs, 0444);
+module_param_array(channels, int, NULL, 0444);
 MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver.");
-module_param_array(pcm_channels, int, boot_devs, 0444);
+module_param_array(pcm_channels, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver.");
 
 static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
diff -Nru a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
--- a/sound/isa/gus/gusextreme.c	2004-12-24 13:37:02 -08:00
+++ b/sound/isa/gus/gusextreme.c	2004-12-24 13:37:02 -08:00
@@ -55,35 +55,34 @@
 				/* 0 to 31, (0.59V-4.52V or 0.389V-2.98V) */
 static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for GUS Extreme soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for GUS Extreme soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable GUS Extreme soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for GUS Extreme driver.");
-module_param_array(gf1_port, long, boot_devs, 0444);
+module_param_array(gf1_port, long, NULL, 0444);
 MODULE_PARM_DESC(gf1_port, "GF1 port # for GUS Extreme driver (optional).");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for GUS Extreme driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for GUS Extreme driver.");
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for GUS Extreme driver.");
-module_param_array(gf1_irq, int, boot_devs, 0444);
+module_param_array(gf1_irq, int, NULL, 0444);
 MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for GUS Extreme driver.");
-module_param_array(dma8, int, boot_devs, 0444);
+module_param_array(dma8, int, NULL, 0444);
 MODULE_PARM_DESC(dma8, "8-bit DMA # for GUS Extreme driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "GF1 DMA # for GUS Extreme driver.");
-module_param_array(joystick_dac, int, boot_devs, 0444);
+module_param_array(joystick_dac, int, NULL, 0444);
 MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Extreme driver.");
-module_param_array(channels, int, boot_devs, 0444);
+module_param_array(channels, int, NULL, 0444);
 MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver.");
-module_param_array(pcm_channels, int, boot_devs, 0444);
+module_param_array(pcm_channels, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver.");
 
 static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
diff -Nru a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
--- a/sound/isa/gus/gusmax.c	2004-12-24 13:37:00 -08:00
+++ b/sound/isa/gus/gusmax.c	2004-12-24 13:37:00 -08:00
@@ -49,27 +49,26 @@
 				/* 0 to 31, (0.59V-4.52V or 0.389V-2.98V) */
 static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for GUS MAX soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for GUS MAX soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable GUS MAX soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for GUS MAX driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for GUS MAX driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for GUS MAX driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "DMA2 # for GUS MAX driver.");
-module_param_array(joystick_dac, int, boot_devs, 0444);
+module_param_array(joystick_dac, int, NULL, 0444);
 MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS MAX driver.");
-module_param_array(channels, int, boot_devs, 0444);
+module_param_array(channels, int, NULL, 0444);
 MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver.");
-module_param_array(pcm_channels, int, boot_devs, 0444);
+module_param_array(pcm_channels, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver.");
 
 struct snd_gusmax {
diff -Nru a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
--- a/sound/isa/gus/interwave.c	2004-12-24 13:36:55 -08:00
+++ b/sound/isa/gus/interwave.c	2004-12-24 13:36:55 -08:00
@@ -72,35 +72,34 @@
 static int midi[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
 static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for InterWave soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for InterWave soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable InterWave soundcard.");
-module_param_array(isapnp, bool, boot_devs, 0444);
+module_param_array(isapnp, bool, NULL, 0444);
 MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for InterWave driver.");
 #ifdef SNDRV_STB
-module_param_array(port_tc, long, boot_devs, 0444);
+module_param_array(port_tc, long, NULL, 0444);
 MODULE_PARM_DESC(port_tc, "Tone control (TEA6330T - i2c bus) port # for InterWave driver.");
 #endif
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for InterWave driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for InterWave driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "DMA2 # for InterWave driver.");
-module_param_array(joystick_dac, int, boot_devs, 0444);
+module_param_array(joystick_dac, int, NULL, 0444);
 MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for InterWave driver.");
-module_param_array(midi, int, boot_devs, 0444);
+module_param_array(midi, int, NULL, 0444);
 MODULE_PARM_DESC(midi, "MIDI UART enable for InterWave driver.");
-module_param_array(pcm_channels, int, boot_devs, 0444);
+module_param_array(pcm_channels, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver.");
-module_param_array(effect, int, boot_devs, 0444);
+module_param_array(effect, int, NULL, 0444);
 MODULE_PARM_DESC(effect, "Effects enable for InterWave driver.");
 
 struct snd_interwave {
diff -Nru a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
--- a/sound/isa/opl3sa2.c	2004-12-24 13:37:29 -08:00
+++ b/sound/isa/opl3sa2.c	2004-12-24 13:37:29 -08:00
@@ -58,35 +58,34 @@
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 1,3,5,6,7 */
 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 1,3,5,6,7 */
 static int opl3sa3_ymode[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 };   /* 0,1,2,3 */ /*SL Added*/
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for OPL3-SA soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for OPL3-SA soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable OPL3-SA soundcard.");
 #ifdef CONFIG_PNP
-module_param_array(isapnp, bool, boot_devs, 0444);
+module_param_array(isapnp, bool, NULL, 0444);
 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
 #endif
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for OPL3-SA driver.");
-module_param_array(sb_port, long, boot_devs, 0444);
+module_param_array(sb_port, long, NULL, 0444);
 MODULE_PARM_DESC(sb_port, "SB port # for OPL3-SA driver.");
-module_param_array(wss_port, long, boot_devs, 0444);
+module_param_array(wss_port, long, NULL, 0444);
 MODULE_PARM_DESC(wss_port, "WSS port # for OPL3-SA driver.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port # for OPL3-SA driver.");
-module_param_array(midi_port, long, boot_devs, 0444);
+module_param_array(midi_port, long, NULL, 0444);
 MODULE_PARM_DESC(midi_port, "MIDI port # for OPL3-SA driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for OPL3-SA driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for OPL3-SA driver.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver.");
-module_param_array(opl3sa3_ymode, int, boot_devs, 0444);
+module_param_array(opl3sa3_ymode, int, NULL, 0444);
 MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi.");
 
 /* control ports */
diff -Nru a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c
--- a/sound/isa/sb/es968.c	2004-12-24 13:36:49 -08:00
+++ b/sound/isa/sb/es968.c	2004-12-24 13:36:49 -08:00
@@ -42,19 +42,18 @@
 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;	/* PnP setup */
 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* Pnp setup */
 static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* PnP setup */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for es968 based soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for es968 based soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable es968 based soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for es968 driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for es968 driver.");
-module_param_array(dma8, int, boot_devs, 0444);
+module_param_array(dma8, int, NULL, 0444);
 MODULE_PARM_DESC(dma8, "8-bit DMA # for es968 driver.");
 
 struct snd_card_es968 {
diff -Nru a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
--- a/sound/isa/sb/sb16.c	2004-12-24 13:37:44 -08:00
+++ b/sound/isa/sb/sb16.c	2004-12-24 13:37:44 -08:00
@@ -89,42 +89,41 @@
 #ifdef SNDRV_SBAWE_EMU8000
 static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
 #endif
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for SoundBlaster 16 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for SoundBlaster 16 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable SoundBlaster 16 soundcard.");
 #ifdef CONFIG_PNP
-module_param_array(isapnp, bool, boot_devs, 0444);
+module_param_array(isapnp, bool, NULL, 0444);
 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
 #endif
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for SB16 driver.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for SB16 driver.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port # for SB16 PnP driver.");
 #ifdef SNDRV_SBAWE_EMU8000
-module_param_array(awe_port, long, boot_devs, 0444);
+module_param_array(awe_port, long, NULL, 0444);
 MODULE_PARM_DESC(awe_port, "AWE port # for SB16 PnP driver.");
 #endif
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for SB16 driver.");
-module_param_array(dma8, int, boot_devs, 0444);
+module_param_array(dma8, int, NULL, 0444);
 MODULE_PARM_DESC(dma8, "8-bit DMA # for SB16 driver.");
-module_param_array(dma16, int, boot_devs, 0444);
+module_param_array(dma16, int, NULL, 0444);
 MODULE_PARM_DESC(dma16, "16-bit DMA # for SB16 driver.");
-module_param_array(mic_agc, int, boot_devs, 0444);
+module_param_array(mic_agc, int, NULL, 0444);
 MODULE_PARM_DESC(mic_agc, "Mic Auto-Gain-Control switch.");
 #ifdef CONFIG_SND_SB16_CSP
-module_param_array(csp, int, boot_devs, 0444);
+module_param_array(csp, int, NULL, 0444);
 MODULE_PARM_DESC(csp, "ASP/CSP chip support.");
 #endif
 #ifdef SNDRV_SBAWE_EMU8000
-module_param_array(seq_ports, int, boot_devs, 0444);
+module_param_array(seq_ports, int, NULL, 0444);
 MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth.");
 #endif
 
diff -Nru a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
--- a/sound/isa/sb/sb8.c	2004-12-24 13:37:01 -08:00
+++ b/sound/isa/sb/sb8.c	2004-12-24 13:37:01 -08:00
@@ -41,19 +41,18 @@
 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;	/* 0x220,0x240,0x260 */
 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* 5,7,9,10 */
 static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 1,3 */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Sound Blaster soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Sound Blaster soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Sound Blaster soundcard.");
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for SB8 driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for SB8 driver.");
-module_param_array(dma8, int, boot_devs, 0444);
+module_param_array(dma8, int, NULL, 0444);
 MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver.");
 
 struct snd_sb8 {
diff -Nru a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c
--- a/sound/isa/sgalaxy.c	2004-12-24 13:37:43 -08:00
+++ b/sound/isa/sgalaxy.c	2004-12-24 13:37:43 -08:00
@@ -26,7 +26,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/time.h>
-#include <linux/irq.h>
+#include <linux/interrupt.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
 #include <sound/sb.h>
@@ -48,19 +48,18 @@
 static long wssport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;	/* 0x530,0xe80,0xf40,0x604 */
 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;	/* 7,9,10,11 */
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	/* 0,1,3 */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Sound Galaxy soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Sound Galaxy soundcard.");
-module_param_array(sbport, long, boot_devs, 0444);
+module_param_array(sbport, long, NULL, 0444);
 MODULE_PARM_DESC(sbport, "Port # for Sound Galaxy SB driver.");
-module_param_array(wssport, long, boot_devs, 0444);
+module_param_array(wssport, long, NULL, 0444);
 MODULE_PARM_DESC(wssport, "Port # for Sound Galaxy WSS driver.");
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver.");
 
 #define SGALAXY_AUXC_LEFT 18
diff -Nru a/sound/isa/sscape.c b/sound/isa/sscape.c
--- a/sound/isa/sscape.c	2004-12-24 13:36:18 -08:00
+++ b/sound/isa/sscape.c	2004-12-24 13:36:18 -08:00
@@ -47,24 +47,23 @@
 static int irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ;
 static int mpu_irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ;
 static int dma[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA;
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index number for SoundScape soundcard");
 
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "Description for SoundScape card");
 
-module_param_array(port, long, boot_devs, 0444);
+module_param_array(port, long, NULL, 0444);
 MODULE_PARM_DESC(port, "Port # for SoundScape driver.");
 
-module_param_array(irq, int, boot_devs, 0444);
+module_param_array(irq, int, NULL, 0444);
 MODULE_PARM_DESC(irq, "IRQ # for SoundScape driver.");
 
-module_param_array(mpu_irq, int, boot_devs, 0444);
+module_param_array(mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver.");
 
-module_param_array(dma, int, boot_devs, 0444);
+module_param_array(dma, int, NULL, 0444);
 MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
   
 #ifdef CONFIG_PNP
diff -Nru a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
--- a/sound/isa/wavefront/wavefront.c	2004-12-24 13:37:04 -08:00
+++ b/sound/isa/wavefront/wavefront.c	2004-12-24 13:37:04 -08:00
@@ -49,37 +49,36 @@
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	    /* 0,1,3,5,6,7 */
 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	    /* 0,1,3,5,6,7 */
 static int use_cs4232_midi[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; 
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for WaveFront soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for WaveFront soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable WaveFront soundcard.");
 #ifdef CONFIG_PNP
-module_param_array(isapnp, bool, boot_devs, 0444);
+module_param_array(isapnp, bool, NULL, 0444);
 MODULE_PARM_DESC(isapnp, "ISA PnP detection for WaveFront soundcards.");
 #endif
-module_param_array(cs4232_pcm_port, long, boot_devs, 0444);
+module_param_array(cs4232_pcm_port, long, NULL, 0444);
 MODULE_PARM_DESC(cs4232_pcm_port, "Port # for CS4232 PCM interface.");
-module_param_array(cs4232_pcm_irq, int, boot_devs, 0444);
+module_param_array(cs4232_pcm_irq, int, NULL, 0444);
 MODULE_PARM_DESC(cs4232_pcm_irq, "IRQ # for CS4232 PCM interface.");
-module_param_array(dma1, int, boot_devs, 0444);
+module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for CS4232 PCM interface.");
-module_param_array(dma2, int, boot_devs, 0444);
+module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "DMA2 # for CS4232 PCM interface.");
-module_param_array(cs4232_mpu_port, long, boot_devs, 0444);
+module_param_array(cs4232_mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(cs4232_mpu_port, "port # for CS4232 MPU-401 interface.");
-module_param_array(cs4232_mpu_irq, int, boot_devs, 0444);
+module_param_array(cs4232_mpu_irq, int, NULL, 0444);
 MODULE_PARM_DESC(cs4232_mpu_irq, "IRQ # for CS4232 MPU-401 interface.");
-module_param_array(ics2115_irq, int, boot_devs, 0444);
+module_param_array(ics2115_irq, int, NULL, 0444);
 MODULE_PARM_DESC(ics2115_irq, "IRQ # for ICS2115.");
-module_param_array(ics2115_port, long, boot_devs, 0444);
+module_param_array(ics2115_port, long, NULL, 0444);
 MODULE_PARM_DESC(ics2115_port, "Port # for ICS2115.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port #.");
-module_param_array(use_cs4232_midi, bool, boot_devs, 0444);
+module_param_array(use_cs4232_midi, bool, NULL, 0444);
 MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
 
 static snd_card_t *snd_wavefront_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
diff -Nru a/sound/oss/aci.c b/sound/oss/aci.c
--- a/sound/oss/aci.c	2004-12-24 13:36:55 -08:00
+++ b/sound/oss/aci.c	2004-12-24 13:36:55 -08:00
@@ -62,11 +62,10 @@
 #include "sound_config.h"
 
 int aci_port;	/* as determined by bit 4 in the OPTi 929 MC4 register */
-int aci_idcode[2];	/* manufacturer and product ID */
+static int aci_idcode[2];	/* manufacturer and product ID */
 int aci_version;	/* ACI firmware version	*/
 
 EXPORT_SYMBOL(aci_port);
-EXPORT_SYMBOL(aci_idcode);
 EXPORT_SYMBOL(aci_version);
 
 #include "aci.h"
diff -Nru a/sound/oss/aci.h b/sound/oss/aci.h
--- a/sound/oss/aci.h	2004-12-24 13:36:49 -08:00
+++ b/sound/oss/aci.h	2004-12-24 13:36:49 -08:00
@@ -2,7 +2,6 @@
 #define _ACI_H_
 
 extern int aci_port;
-extern int aci_idcode[2];	/* manufacturer and product ID */
 extern int aci_version;		/* ACI firmware version	*/
 extern int aci_rw_cmd(int write1, int write2, int write3);
 
diff -Nru a/sound/oss/ad1889.c b/sound/oss/ad1889.c
--- a/sound/oss/ad1889.c	2004-12-24 13:36:47 -08:00
+++ b/sound/oss/ad1889.c	2004-12-24 13:36:47 -08:00
@@ -1011,36 +1011,45 @@
 	
         if (!(pci_resource_flags(pcidev, 0) & IORESOURCE_MEM)) {
 		printk(KERN_ERR DEVNAME ": memory region not assigned\n");
-		goto err_free_mem;
+		goto out1;
+	}
+
+	if (pci_request_region(pcidev, 0, DEVNAME)) {
+		printk(KERN_ERR DEVNAME ": unable to request memory region\n");
+		goto out1;
+	}
+
+	dev->regbase = ioremap_nocache(bar, AD_DSIOMEMSIZE);
+	if (!dev->regbase) {
+		printk(KERN_ERR DEVNAME ": unable to remap iomem\n");
+		goto out2;
 	}
 
 	if (request_irq(pcidev->irq, ad1889_interrupt, SA_SHIRQ, DEVNAME, dev) != 0) {
 		printk(KERN_ERR DEVNAME ": unable to request interrupt\n");
-		goto err_free_mem;
+		goto out3;
 	}
 
-	request_mem_region(bar, AD_DSIOMEMSIZE, DEVNAME);
-	dev->regbase = (unsigned long)ioremap_nocache(bar, AD_DSIOMEMSIZE);
-
-	printk(KERN_INFO DEVNAME ": %s at 0x%lx IRQ %d\n",
+	printk(KERN_INFO DEVNAME ": %s at %p IRQ %d\n",
 		(char *)ent->driver_data, dev->regbase, pcidev->irq);
 
 	if (ad1889_aclink_reset(pcidev) != 0)
-		goto err_free_mem;
+		goto out4;
 
 	/* register /dev/dsp */
 	if ((dev->dev_audio = register_sound_dsp(&ad1889_fops, -1)) < 0) {
 		printk(KERN_ERR DEVNAME ": cannot register /dev/dsp\n");
-		goto err_free_irq;
+		goto out4;
 	}
 
 	if ((err = ad1889_ac97_init(dev, 0)) != 0)
-		goto err_free_dsp;
+		goto out5;
 
+	/* XXX: cleanups */
 	if (((proc_root = proc_mkdir("driver/ad1889", NULL)) == NULL) ||
 	    create_proc_read_entry("ac97", S_IFREG|S_IRUGO, proc_root, ac97_read_proc, dev->ac97_codec) == NULL ||
 	    create_proc_read_entry("info", S_IFREG|S_IRUGO, proc_root, ad1889_read_proc, dev) == NULL) 
-		goto err_free_dsp;
+		goto out5;
 	
 	ad1889_initcfg(dev);
 
@@ -1050,13 +1059,15 @@
 
 	return 0;
 
-err_free_dsp:
+out5:
 	unregister_sound_dsp(dev->dev_audio);
-
-err_free_irq:
+out4:
 	free_irq(pcidev->irq, dev);
-
-err_free_mem:
+out3:
+	iounmap(dev->regbase);
+out2:
+	pci_release_region(pcidev, 0);
+out1:
 	ad1889_free_dev(dev);
 	pci_set_drvdata(pcidev, NULL);
 
@@ -1072,10 +1083,12 @@
 	unregister_sound_mixer(dev->ac97_codec->dev_mixer);
 	unregister_sound_dsp(dev->dev_audio);
 	free_irq(pcidev->irq, dev);
-	release_mem_region(dev->regbase, AD_DSIOMEMSIZE);
+	iounmap(dev->regbase);
+	pci_release_region(pcidev, 0);
 
 	/* any hw programming needed? */
 	ad1889_free_dev(dev);
+	pci_set_drvdata(pcidev, NULL);
 }
 
 MODULE_AUTHOR("Randolph Chung");
diff -Nru a/sound/oss/ad1889.h b/sound/oss/ad1889.h
--- a/sound/oss/ad1889.h	2004-12-24 13:37:01 -08:00
+++ b/sound/oss/ad1889.h	2004-12-24 13:37:01 -08:00
@@ -104,7 +104,7 @@
 } ad1889_state_t;
 
 typedef struct ad1889_dev {
-	unsigned long regbase;
+	void __iomem *regbase;
 	struct pci_dev *pci;
 	
 	spinlock_t lock;
diff -Nru a/sound/oss/ali5455.c b/sound/oss/ali5455.c
--- a/sound/oss/ali5455.c	2004-12-24 13:37:18 -08:00
+++ b/sound/oss/ali5455.c	2004-12-24 13:37:18 -08:00
@@ -311,7 +311,6 @@
 	u16 pci_id;
 #ifdef CONFIG_PM
 	u16 pm_suspended;
-	u32 pm_save_state[64 / sizeof(u32)];
 	int pm_saved_mixer_settings[SOUND_MIXER_NRDEVICES][NR_AC97];
 #endif
 	/* soundcore stuff */
@@ -934,7 +933,7 @@
 	dmabuf->rawbuf = rawbuf;
 	dmabuf->buforder = order;
 
-	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+	/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
 		SetPageReserved(page);
@@ -1955,7 +1954,9 @@
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf), size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start,
+				virt_to_phys(dmabuf->rawbuf) >> PAGE_SHIFT,
+				size, vma->vm_page_prot))
 		goto out;
 	dmabuf->mapped = 1;
 	dmabuf->trigger = 0;
@@ -3576,7 +3577,7 @@
 			}
 		}
 	}
-	pci_save_state(dev, card->pm_save_state);	/* XXX do we need this? */
+	pci_save_state(dev);	/* XXX do we need this? */
 	pci_disable_device(dev);	/* disable busmastering */
 	pci_set_power_state(dev, 3);	/* Zzz. */
 	return 0;
@@ -3588,7 +3589,7 @@
 	int num_ac97, i = 0;
 	struct ali_card *card = pci_get_drvdata(dev);
 	pci_enable_device(dev);
-	pci_restore_state(dev, card->pm_save_state);
+	pci_restore_state(dev);
 	/* observation of a toshiba portege 3440ct suggests that the 
 	   hardware has to be more or less completely reinitialized from
 	   scratch after an apm suspend.  Works For Me.   -dan */
@@ -3714,11 +3715,7 @@
 			controller_pcmout_share_spdif_locked = 0;
 		}
 	}
-	if (!pci_register_driver(&ali_pci_driver)) {
-		pci_unregister_driver(&ali_pci_driver);
-		return -ENODEV;
-	}
-	return 0;
+	return pci_register_driver(&ali_pci_driver);
 }
 
 static void __exit ali_cleanup_module(void)
diff -Nru a/sound/oss/au1000.c b/sound/oss/au1000.c
--- a/sound/oss/au1000.c	2004-12-24 13:37:01 -08:00
+++ b/sound/oss/au1000.c	2004-12-24 13:37:01 -08:00
@@ -629,7 +629,7 @@
 			return -ENOMEM;
 		db->buforder = order;
 		/* now mark the pages as reserved;
-		   otherwise remap_page_range doesn't do what we want */
+		   otherwise remap_pfn_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf +
 				    (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
@@ -1338,7 +1338,8 @@
 		ret = -EINVAL;
 		goto out;
 	}
-	if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf),
+	if (remap_pfn_range(vma->vm_start,
+			     virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot)) {
 		ret = -EAGAIN;
 		goto out;
diff -Nru a/sound/oss/audio.c b/sound/oss/audio.c
--- a/sound/oss/audio.c	2004-12-24 13:36:48 -08:00
+++ b/sound/oss/audio.c	2004-12-24 13:36:48 -08:00
@@ -38,7 +38,7 @@
 #define NEUTRAL16	0x00
 
 
-int             dma_ioctl(int dev, unsigned int cmd, void __user *arg);
+static int             dma_ioctl(int dev, unsigned int cmd, void __user *arg);
 
 static int set_format(int dev, int fmt)
 {
@@ -735,7 +735,7 @@
 	return bytes | ((count - 1) << 16);
 }
 
-int dma_ioctl(int dev, unsigned int cmd, void __user *arg)
+static int dma_ioctl(int dev, unsigned int cmd, void __user *arg)
 {
 	struct dma_buffparms *dmap_out = audio_devs[dev]->dmap_out;
 	struct dma_buffparms *dmap_in = audio_devs[dev]->dmap_in;
diff -Nru a/sound/oss/audio_syms.c b/sound/oss/audio_syms.c
--- a/sound/oss/audio_syms.c	2004-12-24 13:36:19 -08:00
+++ b/sound/oss/audio_syms.c	2004-12-24 13:36:19 -08:00
@@ -14,6 +14,3 @@
 EXPORT_SYMBOL(DMAbuf_close_dma);
 EXPORT_SYMBOL(DMAbuf_inputintr);
 EXPORT_SYMBOL(DMAbuf_outputintr);
-EXPORT_SYMBOL(dma_ioctl);
-EXPORT_SYMBOL(audio_open);
-EXPORT_SYMBOL(audio_release);
diff -Nru a/sound/oss/btaudio.c b/sound/oss/btaudio.c
--- a/sound/oss/btaudio.c	2004-12-24 13:36:31 -08:00
+++ b/sound/oss/btaudio.c	2004-12-24 13:36:31 -08:00
@@ -104,7 +104,7 @@
 	struct pci_dev *pci;
 	unsigned int   irq;
 	unsigned long  mem;
-	unsigned long  *mmio;
+	unsigned long  __iomem *mmio;
 
 	/* locking */
 	int            users;
diff -Nru a/sound/oss/cmpci.c b/sound/oss/cmpci.c
--- a/sound/oss/cmpci.c	2004-12-24 13:36:55 -08:00
+++ b/sound/oss/cmpci.c	2004-12-24 13:36:55 -08:00
@@ -1393,7 +1393,7 @@
 		if (!db->rawbuf || !db->dmaaddr)
 			return -ENOMEM;
 		db->buforder = order;
-		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+		/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (pstart = virt_to_page(db->rawbuf); pstart <= pend; pstart++)
 			SetPageReserved(pstart);
@@ -2301,7 +2301,9 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		goto out;
 	ret = -EINVAL;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start,
+				virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+				size, vma->vm_page_prot))
 		goto out;
 	db->mapped = 1;
 	ret = 0;
diff -Nru a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
--- a/sound/oss/cs4281/cs4281m.c	2004-12-24 13:37:30 -08:00
+++ b/sound/oss/cs4281/cs4281m.c	2004-12-24 13:37:30 -08:00
@@ -221,7 +221,8 @@
 
 	// hardware resources 
 	unsigned int pBA0phys, pBA1phys;
-	char *pBA0, *pBA1;
+	char __iomem *pBA0;
+	char __iomem *pBA1;
 	unsigned int irq;
 
 	// mixer registers 
@@ -1755,7 +1756,7 @@
 		}
 		db->buforder = order;
 		// Now mark the pages as reserved; otherwise the 
-		// remap_page_range() in cs4281_mmap doesn't work.
+		// remap_pfn_range() in cs4281_mmap doesn't work.
 		// 1. get index to last page in mem_map array for rawbuf.
 		mapend = virt_to_page(db->rawbuf + 
 			(PAGE_SIZE << db->buforder) - 1);
@@ -1778,7 +1779,7 @@
 		}
 		s->buforder_tmpbuff = order;
 		// Now mark the pages as reserved; otherwise the 
-		// remap_page_range() in cs4281_mmap doesn't work.
+		// remap_pfn_range() in cs4281_mmap doesn't work.
 		// 1. get index to last page in mem_map array for rawbuf.
 		mapend = virt_to_page(s->tmpbuff + 
 				(PAGE_SIZE << s->buforder_tmpbuff) - 1);
@@ -3135,9 +3136,10 @@
 	size = vma->vm_end - vma->vm_start;
 	if (size > (PAGE_SIZE << db->buforder))
 		return -EINVAL;
-	if (remap_page_range
-	    (vma, vma->vm_start, virt_to_phys(db->rawbuf), size,
-	     vma->vm_page_prot)) return -EAGAIN;
+	if (remap_pfn_range(vma, vma->vm_start,
+				virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+				size, vma->vm_page_prot))
+		return -EAGAIN;
 	db->mapped = 1;
 
 	CS_DBGOUT(CS_FUNCTION | CS_PARMS | CS_OPEN, 4,
diff -Nru a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
--- a/sound/oss/cs46xx.c	2004-12-24 13:36:16 -08:00
+++ b/sound/oss/cs46xx.c	2004-12-24 13:36:16 -08:00
@@ -346,17 +346,17 @@
 	u32 irq;
 	
 	/* mappings */
-	void *ba0;
+	void __iomem *ba0;
 	union
 	{
 		struct
 		{
-			u8 *data0;
-			u8 *data1;
-			u8 *pmem;
-			u8 *reg;
+			u8 __iomem *data0;
+			u8 __iomem *data1;
+			u8 __iomem *pmem;
+			u8 __iomem *reg;
 		} name;
-		u8 *idx[4];
+		u8 __iomem *idx[4];
 	} ba1;
 	
 	/* Function support */
@@ -1190,7 +1190,7 @@
 	dmabuf->buforder = order;
 	dmabuf->rawbuf = rawbuf;
 	// Now mark the pages as reserved; otherwise the 
-	// remap_page_range() in cs46xx_mmap doesn't work.
+	// remap_pfn_range() in cs46xx_mmap doesn't work.
 	// 1. get index to last page in mem_map array for rawbuf.
 	mapend = virt_to_page(dmabuf->rawbuf + 
 		(PAGE_SIZE << dmabuf->buforder) - 1);
@@ -1227,7 +1227,7 @@
 	dmabuf->buforder_tmpbuff = order;
 	
 	// Now mark the pages as reserved; otherwise the 
-	// remap_page_range() in cs46xx_mmap doesn't work.
+	// remap_pfn_range() in cs46xx_mmap doesn't work.
 	// 1. get index to last page in mem_map array for rawbuf.
 	mapend = virt_to_page(dmabuf->tmpbuff + 
 		(PAGE_SIZE << dmabuf->buforder_tmpbuff) - 1);
@@ -2452,7 +2452,8 @@
 		ret = -EINVAL;
 		goto out;
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
+	if (remap_pfn_range(vma, vma->vm_start,
+			     virt_to_phys(dmabuf->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot))
 	{
 		ret = -EAGAIN;
@@ -4308,7 +4309,7 @@
 static void cs461x_download_image(struct cs_card *card)
 {
     unsigned i, j, temp1, temp2, offset, count;
-    unsigned char *pBA1 = ioremap(card->ba1_addr, 0x40000);
+    unsigned char __iomem *pBA1 = ioremap(card->ba1_addr, 0x40000);
     for( i=0; i < CLEAR__COUNT; i++)
     {
         offset = ClrStat[i].BA1__DestByteOffset;
diff -Nru a/sound/oss/dev_table.c b/sound/oss/dev_table.c
--- a/sound/oss/dev_table.c	2004-12-24 13:37:18 -08:00
+++ b/sound/oss/dev_table.c	2004-12-24 13:37:18 -08:00
@@ -16,6 +16,8 @@
 #define _DEV_TABLE_C_
 #include "sound_config.h"
 
+static int sound_alloc_audiodev(void);
+
 int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
 			int driver_size, int flags, unsigned int format_mask,
 			void *devc, int dma1, int dma2)
@@ -121,7 +123,7 @@
 	}
 }
 
-int sound_alloc_audiodev(void)
+static int sound_alloc_audiodev(void)
 { 
 	int i = register_sound_dsp(&oss_sound_fops, -1);
 	if(i==-1)
diff -Nru a/sound/oss/dev_table.h b/sound/oss/dev_table.h
--- a/sound/oss/dev_table.h	2004-12-24 13:37:02 -08:00
+++ b/sound/oss/dev_table.h	2004-12-24 13:37:02 -08:00
@@ -397,7 +397,6 @@
 void sound_unload_mididev(int dev);
 void sound_unload_synthdev(int dev);
 void sound_unload_timerdev(int dev);
-int sound_alloc_audiodev(void);
 int sound_alloc_mixerdev(void);
 int sound_alloc_timerdev(void);
 int sound_alloc_synthdev(void);
diff -Nru a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c
--- a/sound/oss/dmabuf.c	2004-12-24 13:36:17 -08:00
+++ b/sound/oss/dmabuf.c	2004-12-24 13:36:17 -08:00
@@ -88,7 +88,7 @@
 	while (start_addr == NULL && dmap->buffsize > PAGE_SIZE) {
 		for (sz = 0, size = PAGE_SIZE; size < dmap->buffsize; sz++, size <<= 1);
 		dmap->buffsize = PAGE_SIZE * (1 << sz);
-		start_addr = (char *) __get_free_pages(GFP_ATOMIC|GFP_DMA, sz);
+		start_addr = (char *) __get_free_pages(GFP_ATOMIC|GFP_DMA|__GFP_NOWARN, sz);
 		if (start_addr == NULL)
 			dmap->buffsize /= 2;
 	}
diff -Nru a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
--- a/sound/oss/dmasound/dmasound_awacs.c	2004-12-24 13:36:47 -08:00
+++ b/sound/oss/dmasound/dmasound_awacs.c	2004-12-24 13:36:47 -08:00
@@ -76,7 +76,6 @@
 #include <linux/nvram.h>
 #include <linux/tty.h>
 #include <linux/vt_kern.h>
-#include <linux/irq.h>
 #include <linux/spinlock.h>
 #include <linux/kmod.h>
 #include <linux/interrupt.h>
@@ -119,9 +118,9 @@
  * Interrupt numbers and addresses, & info obtained from the device tree.
  */
 static int awacs_irq, awacs_tx_irq, awacs_rx_irq;
-static volatile struct awacs_regs *awacs;
-static volatile u32 *i2s;
-static volatile struct dbdma_regs *awacs_txdma, *awacs_rxdma;
+static volatile struct awacs_regs __iomem *awacs;
+static volatile u32 __iomem *i2s;
+static volatile struct dbdma_regs __iomem *awacs_txdma, *awacs_rxdma;
 static int awacs_rate_index;
 static int awacs_subframe;
 static struct device_node* awacs_node;
@@ -147,8 +146,8 @@
 /* for earlier powerbooks which need fiddling with mac-io to enable
  * cd etc.
 */
-static unsigned char *latch_base;
-static unsigned char *macio_base;
+static unsigned char __iomem *latch_base;
+static unsigned char __iomem *macio_base;
 
 /*
  * Space for the DBDMA command blocks.
@@ -662,11 +661,11 @@
 	free_irq(awacs_rx_irq, NULL);
 	
 	if (awacs)
-		iounmap((void *)awacs);
+		iounmap(awacs);
 	if (i2s)
-		iounmap((void *)i2s);
-	iounmap((void *)awacs_txdma);
-	iounmap((void *)awacs_rxdma);
+		iounmap(i2s);
+	iounmap(awacs_txdma);
+	iounmap(awacs_rxdma);
 
 	release_OF_resource(awacs_node, 0);
 	release_OF_resource(awacs_node, 1);
@@ -2916,14 +2915,11 @@
 
 	/* all OF versions I've seen use this value */
 	if (i2s_node)
-		i2s = (u32 *)ioremap(io->addrs[0].address, 0x1000);
+		i2s = ioremap(io->addrs[0].address, 0x1000);
 	else
-		awacs = (volatile struct awacs_regs *)
-			ioremap(io->addrs[0].address, 0x1000);
-	awacs_txdma = (volatile struct dbdma_regs *)
-		ioremap(io->addrs[1].address, 0x100);
-	awacs_rxdma = (volatile struct dbdma_regs *)
-		ioremap(io->addrs[2].address, 0x100);
+		awacs = ioremap(io->addrs[0].address, 0x1000);
+	awacs_txdma = ioremap(io->addrs[1].address, 0x100);
+	awacs_rxdma = ioremap(io->addrs[2].address, 0x100);
 
 	/* first of all make sure that the chip is powered up....*/
 	pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1);
@@ -3076,7 +3072,7 @@
 		 * sound input.  The 0x100 enables the SCSI bus
 		 * terminator power.
 		 */
-		latch_base = (unsigned char *) ioremap (0xf301a000, 0x1000);
+		latch_base = ioremap (0xf301a000, 0x1000);
 		in_8(latch_base + 0x190);
 
 	} else if (is_pbook_g3) {
@@ -3085,8 +3081,7 @@
 		for (mio = io->parent; mio; mio = mio->parent) {
 			if (strcmp(mio->name, "mac-io") == 0
 			    && mio->n_addrs > 0) {
-				macio_base = (unsigned char *) ioremap
-					(mio->addrs[0].address, 0x40);
+				macio_base = ioremap(mio->addrs[0].address, 0x40);
 				break;
 			}
 		}
diff -Nru a/sound/oss/es1370.c b/sound/oss/es1370.c
--- a/sound/oss/es1370.c	2004-12-24 13:37:31 -08:00
+++ b/sound/oss/es1370.c	2004-12-24 13:37:31 -08:00
@@ -573,7 +573,7 @@
 		if (!db->rawbuf)
 			return -ENOMEM;
 		db->buforder = order;
-		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+		/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
 			SetPageReserved(page);
@@ -1364,7 +1364,9 @@
 		ret = -EINVAL;
 		goto out;
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) {
+	if (remap_pfn_range(vma, vma->vm_start,
+				virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+				size, vma->vm_page_prot)) {
 		ret = -EAGAIN;
 		goto out;
 	}
@@ -1940,7 +1942,9 @@
 	if (size > (PAGE_SIZE << s->dma_dac1.buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start,
+			virt_to_phys(s->dma_dac1.rawbuf) >> PAGE_SHIFT,
+			size, vma->vm_page_prot))
 		goto out;
 	s->dma_dac1.mapped = 1;
 	ret = 0;
diff -Nru a/sound/oss/es1371.c b/sound/oss/es1371.c
--- a/sound/oss/es1371.c	2004-12-24 13:37:04 -08:00
+++ b/sound/oss/es1371.c	2004-12-24 13:37:04 -08:00
@@ -637,7 +637,7 @@
 
 /* --------------------------------------------------------------------- */
 
-static void __init src_init(struct es1371_state *s)
+static void __devinit src_init(struct es1371_state *s)
 {
         unsigned int i;
 
@@ -910,7 +910,7 @@
 		if (!db->rawbuf)
 			return -ENOMEM;
 		db->buforder = order;
-		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+		/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
 			SetPageReserved(page);
@@ -1555,7 +1555,9 @@
 		ret = -EINVAL;
 		goto out;
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) {
+	if (remap_pfn_range(vma, vma->vm_start,
+				virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+				size, vma->vm_page_prot)) {
 		ret = -EAGAIN;
 		goto out;
 	}
@@ -2128,7 +2130,9 @@
 	if (size > (PAGE_SIZE << s->dma_dac1.buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start,
+			virt_to_phys(s->dma_dac1.rawbuf) >> PAGE_SHIFT,
+			size, vma->vm_page_prot))
 		goto out;
 	s->dma_dac1.mapped = 1;
 	ret = 0;
@@ -2754,7 +2758,7 @@
 static struct initvol {
 	int mixch;
 	int vol;
-} initvol[] __initdata = {
+} initvol[] __devinitdata = {
 	{ SOUND_MIXER_WRITE_LINE, 0x4040 },
 	{ SOUND_MIXER_WRITE_CD, 0x4040 },
 	{ MIXER_WRITE(SOUND_MIXER_VIDEO), 0x4040 },
diff -Nru a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
--- a/sound/oss/esssolo1.c	2004-12-24 13:36:18 -08:00
+++ b/sound/oss/esssolo1.c	2004-12-24 13:36:18 -08:00
@@ -445,7 +445,7 @@
 		if (!db->rawbuf)
 			return -ENOMEM;
 		db->buforder = order;
-		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+		/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
 			SetPageReserved(page);
@@ -1242,7 +1242,9 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start,
+				virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+				size, vma->vm_page_prot))
 		goto out;
 	db->mapped = 1;
 	ret = 0;
@@ -2451,11 +2453,7 @@
 static int __init init_solo1(void)
 {
 	printk(KERN_INFO "solo1: version v0.20 time " __TIME__ " " __DATE__ "\n");
-	if (!pci_register_driver(&solo1_driver)) {
-		pci_unregister_driver(&solo1_driver);
-                return -ENODEV;
-	}
-	return 0;
+	return pci_register_driver(&solo1_driver);
 }
 
 /* --------------------------------------------------------------------- */
diff -Nru a/sound/oss/forte.c b/sound/oss/forte.c
--- a/sound/oss/forte.c	2004-12-24 13:36:47 -08:00
+++ b/sound/oss/forte.c	2004-12-24 13:36:47 -08:00
@@ -1409,7 +1409,8 @@
                 goto out;
 	}
 
-        if (remap_page_range (vma, vma->vm_start, virt_to_phys (channel->buf),
+        if (remap_pfn_range(vma, vma->vm_start,
+			      virt_to_phys(channel->buf) >> PAGE_SHIFT,
 			      size, vma->vm_page_prot)) {
 		DPRINTK ("%s: remap el a no worko\n", __FUNCTION__);
 		ret = -EAGAIN;
@@ -2111,12 +2112,7 @@
 {
 	printk (KERN_INFO PFX DRIVER_VERSION "\n");
 
-	if (!pci_register_driver (&forte_pci_driver)) {
-		pci_unregister_driver (&forte_pci_driver);
-		return -ENODEV;
-	}
-
-	return 0;
+	return pci_register_driver (&forte_pci_driver);
 }
 
 
diff -Nru a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
--- a/sound/oss/i810_audio.c	2004-12-24 13:37:17 -08:00
+++ b/sound/oss/i810_audio.c	2004-12-24 13:37:17 -08:00
@@ -406,7 +406,6 @@
 	u16 pci_id_internal; /* used to access card_cap[] */
 #ifdef CONFIG_PM	
 	u16 pm_suspended;
-	u32 pm_save_state[64/sizeof(u32)];
 	int pm_saved_mixer_settings[SOUND_MIXER_NRDEVICES][NR_AC97];
 #endif
 	/* soundcore stuff */
@@ -430,8 +429,8 @@
 
 	unsigned long ac97base_mmio_phys;
 	unsigned long iobase_mmio_phys;
-	u_int8_t *ac97base_mmio;
-	u_int8_t *iobase_mmio;
+	u_int8_t __iomem *ac97base_mmio;
+	u_int8_t __iomem *iobase_mmio;
 
 	int           use_mmio;
 	
@@ -917,7 +916,7 @@
 	dmabuf->rawbuf = rawbuf;
 	dmabuf->buforder = order;
 	
-	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+	/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
 		SetPageReserved(page);
@@ -1750,7 +1749,8 @@
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
+	if (remap_pfn_range(vma, vma->vm_start,
+			     virt_to_phys(dmabuf->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot))
 		goto out;
 	dmabuf->mapped = 1;
@@ -3385,7 +3385,7 @@
 			}
 		}
 	}
-	pci_save_state(dev,card->pm_save_state); /* XXX do we need this? */
+	pci_save_state(dev); /* XXX do we need this? */
 	pci_disable_device(dev); /* disable busmastering */
 	pci_set_power_state(dev,3); /* Zzz. */
 
@@ -3398,7 +3398,7 @@
 	int num_ac97,i=0;
 	struct i810_card *card=pci_get_drvdata(dev);
 	pci_enable_device(dev);
-	pci_restore_state (dev,card->pm_save_state);
+	pci_restore_state (dev);
 
 	/* observation of a toshiba portege 3440ct suggests that the 
 	   hardware has to be more or less completely reinitialized from
@@ -3484,13 +3484,15 @@
 
 static int __init i810_init_module (void)
 {
+	int retval;
+
 	printk(KERN_INFO "Intel 810 + AC97 Audio, version "
 	       DRIVER_VERSION ", " __TIME__ " " __DATE__ "\n");
 
-	if (!pci_register_driver(&i810_pci_driver)) {
-		pci_unregister_driver(&i810_pci_driver);
-                return -ENODEV;
-	}
+	retval = pci_register_driver(&i810_pci_driver);
+	if (retval)
+		return retval;
+
 	if(ftsodell != 0) {
 		printk("i810_audio: ftsodell is now a deprecated option.\n");
 	}
diff -Nru a/sound/oss/ite8172.c b/sound/oss/ite8172.c
--- a/sound/oss/ite8172.c	2004-12-24 13:36:30 -08:00
+++ b/sound/oss/ite8172.c	2004-12-24 13:36:30 -08:00
@@ -693,7 +693,7 @@
 			return -ENOMEM;
 		db->buforder = order;
 		/* now mark the pages as reserved;
-		   otherwise remap_page_range doesn't do what we want */
+		   otherwise remap_pfn_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf +
 				    (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
@@ -1311,7 +1311,8 @@
 		unlock_kernel();
 		return -EINVAL;
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf),
+	if (remap_pfn_range(vma, vma->vm_start,
+			     virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot)) {
 		unlock_kernel();
 		return -EAGAIN;
diff -Nru a/sound/oss/kahlua.c b/sound/oss/kahlua.c
--- a/sound/oss/kahlua.c	2004-12-24 13:37:19 -08:00
+++ b/sound/oss/kahlua.c	2004-12-24 13:37:19 -08:00
@@ -56,7 +56,7 @@
 {
 	struct address_info *hw_config;
 	unsigned long base;
-	void *mem;
+	void __iomem *mem;
 	unsigned long io;
 	u16 map;
 	u8 irq, dma8, dma16;
diff -Nru a/sound/oss/maestro.c b/sound/oss/maestro.c
--- a/sound/oss/maestro.c	2004-12-24 13:37:19 -08:00
+++ b/sound/oss/maestro.c	2004-12-24 13:37:19 -08:00
@@ -2520,7 +2520,9 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start,
+			virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+			size, vma->vm_page_prot))
 		goto out;
 	db->mapped = 1;
 	ret = 0;
@@ -2953,7 +2955,7 @@
 
 	}
 
-	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+	/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
 		SetPageReserved(page);
diff -Nru a/sound/oss/maestro3.c b/sound/oss/maestro3.c
--- a/sound/oss/maestro3.c	2004-12-24 13:37:19 -08:00
+++ b/sound/oss/maestro3.c	2004-12-24 13:37:19 -08:00
@@ -1557,7 +1557,9 @@
      * ask Jeff what the hell I'm doing wrong.
      */
     ret = -EAGAIN;
-    if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+    if (remap_pfn_range(vma, vma->vm_start,
+			virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+			size, vma->vm_page_prot))
         goto out;
 
     db->mapped = 1;
@@ -2940,8 +2942,7 @@
         return -ENODEV; /* ? */
     }
 
-    if (!pci_register_driver(&m3_pci_driver)) {
-        pci_unregister_driver(&m3_pci_driver);
+    if (pci_register_driver(&m3_pci_driver)) {
         unregister_reboot_notifier(&m3_reboot_nb);
         return -ENODEV;
     }
diff -Nru a/sound/oss/msnd.c b/sound/oss/msnd.c
--- a/sound/oss/msnd.c	2004-12-24 13:36:34 -08:00
+++ b/sound/oss/msnd.c	2004-12-24 13:36:34 -08:00
@@ -33,6 +33,8 @@
 #include <linux/delay.h>
 #include <linux/mm.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
+
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <linux/spinlock.h>
@@ -79,31 +81,12 @@
 	--num_devs;
 }
 
-int msnd_get_num_devs(void)
-{
-	return num_devs;
-}
-
-multisound_dev_t *msnd_get_dev(int j)
-{
-	int i;
-
-	for (i = 0; i < MSND_MAX_DEVS && j; ++i)
-		if (devs[i] != NULL)
-			--j;
-
-	if (i == MSND_MAX_DEVS || j != 0)
-		return NULL;
-
-	return devs[i];
-}
-
-void msnd_init_queue(unsigned long base, int start, int size)
+void msnd_init_queue(void __iomem *base, int start, int size)
 {
-	isa_writew(PCTODSP_BASED(start), base + JQS_wStart);
-	isa_writew(PCTODSP_OFFSET(size) - 1, base + JQS_wSize);
-	isa_writew(0, base + JQS_wHead);
-	isa_writew(0, base + JQS_wTail);
+	writew(PCTODSP_BASED(start), base + JQS_wStart);
+	writew(PCTODSP_OFFSET(size) - 1, base + JQS_wSize);
+	writew(0, base + JQS_wHead);
+	writew(0, base + JQS_wTail);
 }
 
 void msnd_fifo_init(msnd_fifo *f)
@@ -139,6 +122,37 @@
 	f->len = f->tail = f->head = 0;
 }
 
+int msnd_fifo_write_io(msnd_fifo *f, char __iomem *buf, size_t len)
+{
+	int count = 0;
+
+	while ((count < len) && (f->len != f->n)) {
+
+		int nwritten;
+
+		if (f->head <= f->tail) {
+			nwritten = len - count;
+			if (nwritten > f->n - f->tail)
+				nwritten = f->n - f->tail;
+		}
+		else {
+			nwritten = f->head - f->tail;
+			if (nwritten > len - count)
+				nwritten = len - count;
+		}
+
+		memcpy_fromio(f->data + f->tail, buf, nwritten);
+
+		count += nwritten;
+		buf += nwritten;
+		f->len += nwritten;
+		f->tail += nwritten;
+		f->tail %= f->n;
+	}
+
+	return count;
+}
+
 int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len)
 {
 	int count = 0;
@@ -158,7 +172,7 @@
 				nwritten = len - count;
 		}
 
-		isa_memcpy_fromio(f->data + f->tail, (unsigned long) buf, nwritten);
+		memcpy(f->data + f->tail, buf, nwritten);
 
 		count += nwritten;
 		buf += nwritten;
@@ -170,6 +184,37 @@
 	return count;
 }
 
+int msnd_fifo_read_io(msnd_fifo *f, char __iomem *buf, size_t len)
+{
+	int count = 0;
+
+	while ((count < len) && (f->len > 0)) {
+
+		int nread;
+
+		if (f->tail <= f->head) {
+			nread = len - count;
+			if (nread > f->n - f->head)
+				nread = f->n - f->head;
+		}
+		else {
+			nread = f->tail - f->head;
+			if (nread > len - count)
+				nread = len - count;
+		}
+
+		memcpy_toio(buf, f->data + f->head, nread);
+
+		count += nread;
+		buf += nread;
+		f->len -= nread;
+		f->head += nread;
+		f->head %= f->n;
+	}
+
+	return count;
+}
+
 int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len)
 {
 	int count = 0;
@@ -189,7 +234,7 @@
 				nread = len - count;
 		}
 
-		isa_memcpy_toio((unsigned long) buf, f->data + f->head, nread);
+		memcpy(buf, f->data + f->head, nread);
 
 		count += nread;
 		buf += nread;
@@ -201,7 +246,7 @@
 	return count;
 }
 
-int msnd_wait_TXDE(multisound_dev_t *dev)
+static int msnd_wait_TXDE(multisound_dev_t *dev)
 {
 	register unsigned int io = dev->io;
 	register int timeout = 1000;
@@ -213,7 +258,7 @@
 	return -EIO;
 }
 
-int msnd_wait_HC0(multisound_dev_t *dev)
+static int msnd_wait_HC0(multisound_dev_t *dev)
 {
 	register unsigned int io = dev->io;
 	register int timeout = 1000;
@@ -337,8 +382,6 @@
 #ifndef LINUX20
 EXPORT_SYMBOL(msnd_register);
 EXPORT_SYMBOL(msnd_unregister);
-EXPORT_SYMBOL(msnd_get_num_devs);
-EXPORT_SYMBOL(msnd_get_dev);
 
 EXPORT_SYMBOL(msnd_init_queue);
 
@@ -346,11 +389,11 @@
 EXPORT_SYMBOL(msnd_fifo_free);
 EXPORT_SYMBOL(msnd_fifo_alloc);
 EXPORT_SYMBOL(msnd_fifo_make_empty);
+EXPORT_SYMBOL(msnd_fifo_write_io);
+EXPORT_SYMBOL(msnd_fifo_read_io);
 EXPORT_SYMBOL(msnd_fifo_write);
 EXPORT_SYMBOL(msnd_fifo_read);
 
-EXPORT_SYMBOL(msnd_wait_TXDE);
-EXPORT_SYMBOL(msnd_wait_HC0);
 EXPORT_SYMBOL(msnd_send_dsp_cmd);
 EXPORT_SYMBOL(msnd_send_word);
 EXPORT_SYMBOL(msnd_upload_host);
diff -Nru a/sound/oss/msnd.h b/sound/oss/msnd.h
--- a/sound/oss/msnd.h	2004-12-24 13:36:55 -08:00
+++ b/sound/oss/msnd.h	2004-12-24 13:36:55 -08:00
@@ -183,7 +183,7 @@
 typedef u16			USHORT;
 typedef u16			WORD;
 typedef u32			DWORD;
-typedef unsigned long		LPDAQD;
+typedef void __iomem *		LPDAQD;
 
 /* Generic FIFO */
 typedef struct {
@@ -203,12 +203,12 @@
 	int memid, irqid;
 	int irq, irq_ref;
 	unsigned char info;
-	unsigned long base;
+	void __iomem *base;
 
 	/* Motorola 56k DSP SMA */
-	unsigned long SMA;
-	unsigned long DAPQ, DARQ, MODQ, MIDQ, DSPQ;
-	unsigned long pwDSPQData, pwMIDQData, pwMODQData;
+	void __iomem *SMA;
+	void __iomem *DAPQ, *DARQ, *MODQ, *MIDQ, *DSPQ;
+	void __iomem *pwDSPQData, *pwMIDQData, *pwMODQData;
 	int dspq_data_buff, dspq_buff_size;
 
 	/* State variables */
@@ -258,20 +258,18 @@
 
 int				msnd_register(multisound_dev_t *dev);
 void				msnd_unregister(multisound_dev_t *dev);
-int				msnd_get_num_devs(void);
-multisound_dev_t *		msnd_get_dev(int i);
 
-void				msnd_init_queue(unsigned long, int start, int size);
+void				msnd_init_queue(void __iomem *, int start, int size);
 
 void				msnd_fifo_init(msnd_fifo *f);
 void				msnd_fifo_free(msnd_fifo *f);
 int				msnd_fifo_alloc(msnd_fifo *f, size_t n);
 void				msnd_fifo_make_empty(msnd_fifo *f);
+int				msnd_fifo_write_io(msnd_fifo *f, char __iomem *buf, size_t len);
+int				msnd_fifo_read_io(msnd_fifo *f, char __iomem *buf, size_t len);
 int				msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len);
 int				msnd_fifo_read(msnd_fifo *f, char *buf, size_t len);
 
-int				msnd_wait_TXDE(multisound_dev_t *dev);
-int				msnd_wait_HC0(multisound_dev_t *dev);
 int				msnd_send_dsp_cmd(multisound_dev_t *dev, BYTE cmd);
 int				msnd_send_word(multisound_dev_t *dev, unsigned char high,
 					       unsigned char mid, unsigned char low);
diff -Nru a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
--- a/sound/oss/msnd_pinnacle.c	2004-12-24 13:37:00 -08:00
+++ b/sound/oss/msnd_pinnacle.c	2004-12-24 13:37:00 -08:00
@@ -109,18 +109,18 @@
 	LPDAQD lpDAQ;
 
 	dev.last_playbank = -1;
-	isa_writew(PCTODSP_OFFSET(0 * DAQDS__size), dev.DAPQ + JQS_wHead);
-	isa_writew(PCTODSP_OFFSET(0 * DAQDS__size), dev.DAPQ + JQS_wTail);
+	writew(PCTODSP_OFFSET(0 * DAQDS__size), dev.DAPQ + JQS_wHead);
+	writew(PCTODSP_OFFSET(0 * DAQDS__size), dev.DAPQ + JQS_wTail);
 
 	for (n = 0, lpDAQ = dev.base + DAPQ_DATA_BUFF; n < 3; ++n, lpDAQ += DAQDS__size) {
-		isa_writew(PCTODSP_BASED((DWORD)(DAP_BUFF_SIZE * n)), lpDAQ + DAQDS_wStart);
-		isa_writew(0, lpDAQ + DAQDS_wSize);
-		isa_writew(1, lpDAQ + DAQDS_wFormat);
-		isa_writew(dev.play_sample_size, lpDAQ + DAQDS_wSampleSize);
-		isa_writew(dev.play_channels, lpDAQ + DAQDS_wChannels);
-		isa_writew(dev.play_sample_rate, lpDAQ + DAQDS_wSampleRate);
-		isa_writew(HIMT_PLAY_DONE * 0x100 + n, lpDAQ + DAQDS_wIntMsg);
-		isa_writew(n, lpDAQ + DAQDS_wFlags);
+		writew(PCTODSP_BASED((DWORD)(DAP_BUFF_SIZE * n)), lpDAQ + DAQDS_wStart);
+		writew(0, lpDAQ + DAQDS_wSize);
+		writew(1, lpDAQ + DAQDS_wFormat);
+		writew(dev.play_sample_size, lpDAQ + DAQDS_wSampleSize);
+		writew(dev.play_channels, lpDAQ + DAQDS_wChannels);
+		writew(dev.play_sample_rate, lpDAQ + DAQDS_wSampleRate);
+		writew(HIMT_PLAY_DONE * 0x100 + n, lpDAQ + DAQDS_wIntMsg);
+		writew(n, lpDAQ + DAQDS_wFlags);
 	}
 }
 
@@ -131,25 +131,25 @@
 	unsigned long flags;
 
 	dev.last_recbank = 2;
-	isa_writew(PCTODSP_OFFSET(0 * DAQDS__size), dev.DARQ + JQS_wHead);
-	isa_writew(PCTODSP_OFFSET(dev.last_recbank * DAQDS__size), dev.DARQ + JQS_wTail);
+	writew(PCTODSP_OFFSET(0 * DAQDS__size), dev.DARQ + JQS_wHead);
+	writew(PCTODSP_OFFSET(dev.last_recbank * DAQDS__size), dev.DARQ + JQS_wTail);
 
 	/* Critical section: bank 1 access */
 	spin_lock_irqsave(&dev.lock, flags);
 	msnd_outb(HPBLKSEL_1, dev.io + HP_BLKS);
-	isa_memset_io(dev.base, 0, DAR_BUFF_SIZE * 3);
+	memset_io(dev.base, 0, DAR_BUFF_SIZE * 3);
 	msnd_outb(HPBLKSEL_0, dev.io + HP_BLKS);
 	spin_unlock_irqrestore(&dev.lock, flags);
 
 	for (n = 0, lpDAQ = dev.base + DARQ_DATA_BUFF; n < 3; ++n, lpDAQ += DAQDS__size) {
-		isa_writew(PCTODSP_BASED((DWORD)(DAR_BUFF_SIZE * n)) + 0x4000, lpDAQ + DAQDS_wStart);
-		isa_writew(DAR_BUFF_SIZE, lpDAQ + DAQDS_wSize);
-		isa_writew(1, lpDAQ + DAQDS_wFormat);
-		isa_writew(dev.rec_sample_size, lpDAQ + DAQDS_wSampleSize);
-		isa_writew(dev.rec_channels, lpDAQ + DAQDS_wChannels);
-		isa_writew(dev.rec_sample_rate, lpDAQ + DAQDS_wSampleRate);
-		isa_writew(HIMT_RECORD_DONE * 0x100 + n, lpDAQ + DAQDS_wIntMsg);
-		isa_writew(n, lpDAQ + DAQDS_wFlags);
+		writew(PCTODSP_BASED((DWORD)(DAR_BUFF_SIZE * n)) + 0x4000, lpDAQ + DAQDS_wStart);
+		writew(DAR_BUFF_SIZE, lpDAQ + DAQDS_wSize);
+		writew(1, lpDAQ + DAQDS_wFormat);
+		writew(dev.rec_sample_size, lpDAQ + DAQDS_wSampleSize);
+		writew(dev.rec_channels, lpDAQ + DAQDS_wChannels);
+		writew(dev.rec_sample_rate, lpDAQ + DAQDS_wSampleRate);
+		writew(HIMT_RECORD_DONE * 0x100 + n, lpDAQ + DAQDS_wIntMsg);
+		writew(n, lpDAQ + DAQDS_wFlags);
 	}
 }
 
@@ -185,9 +185,9 @@
 
 	for (i = 0; i < 3; ++i, lpDAQ += DAQDS__size, lpDARQ += DAQDS__size) {
 		if (file->f_mode & FMODE_WRITE)
-			isa_writew(data, lpDAQ + DAQDS_wSampleSize);
+			writew(data, lpDAQ + DAQDS_wSampleSize);
 		if (file->f_mode & FMODE_READ)
-			isa_writew(data, lpDARQ + DAQDS_wSampleSize);
+			writew(data, lpDARQ + DAQDS_wSampleSize);
 	}
 	if (file->f_mode & FMODE_WRITE)
 		dev.play_sample_size = data;
@@ -318,9 +318,9 @@
 
 		for (i = 0; i < 3; ++i, lpDAQ += DAQDS__size, lpDARQ += DAQDS__size) {
 			if (file->f_mode & FMODE_WRITE)
-				isa_writew(data, lpDAQ + DAQDS_wSampleRate);
+				writew(data, lpDAQ + DAQDS_wSampleRate);
 			if (file->f_mode & FMODE_READ)
-				isa_writew(data, lpDARQ + DAQDS_wSampleRate);
+				writew(data, lpDARQ + DAQDS_wSampleRate);
 		}
 		if (file->f_mode & FMODE_WRITE)
 			dev.play_sample_rate = data;
@@ -361,9 +361,9 @@
 
 		for (i = 0; i < 3; ++i, lpDAQ += DAQDS__size, lpDARQ += DAQDS__size) {
 			if (file->f_mode & FMODE_WRITE)
-				isa_writew(data, lpDAQ + DAQDS_wChannels);
+				writew(data, lpDAQ + DAQDS_wChannels);
 			if (file->f_mode & FMODE_READ)
-				isa_writew(data, lpDARQ + DAQDS_wChannels);
+				writew(data, lpDARQ + DAQDS_wChannels);
 		}
 		if (file->f_mode & FMODE_WRITE)
 			dev.play_channels = data;
@@ -401,27 +401,27 @@
 }
 
 #define update_volm(a,b)						\
-	isa_writew((dev.left_levels[a] >> 1) *				\
-	       isa_readw(dev.SMA + SMA_wCurrMastVolLeft) / 0xffff,	\
+	writew((dev.left_levels[a] >> 1) *				\
+	       readw(dev.SMA + SMA_wCurrMastVolLeft) / 0xffff,	\
 	       dev.SMA + SMA_##b##Left);				\
-	isa_writew((dev.right_levels[a] >> 1)  *			\
-	       isa_readw(dev.SMA + SMA_wCurrMastVolRight) / 0xffff,	\
+	writew((dev.right_levels[a] >> 1)  *			\
+	       readw(dev.SMA + SMA_wCurrMastVolRight) / 0xffff,	\
 	       dev.SMA + SMA_##b##Right);
 
 #define update_potm(d,s,ar)						\
-	isa_writeb((dev.left_levels[d] >> 8) *				\
-	       isa_readw(dev.SMA + SMA_wCurrMastVolLeft) / 0xffff,	\
+	writeb((dev.left_levels[d] >> 8) *				\
+	       readw(dev.SMA + SMA_wCurrMastVolLeft) / 0xffff,	\
 	       dev.SMA + SMA_##s##Left);				\
-	isa_writeb((dev.right_levels[d] >> 8) *				\
-	       isa_readw(dev.SMA + SMA_wCurrMastVolRight) / 0xffff,	\
+	writeb((dev.right_levels[d] >> 8) *				\
+	       readw(dev.SMA + SMA_wCurrMastVolRight) / 0xffff,	\
 	       dev.SMA + SMA_##s##Right);				\
 	if (msnd_send_word(&dev, 0, 0, ar) == 0)			\
 		chk_send_dsp_cmd(&dev, HDEX_AUX_REQ);
 
 #define update_pot(d,s,ar)				\
-	isa_writeb(dev.left_levels[d] >> 8,		\
+	writeb(dev.left_levels[d] >> 8,		\
 	       dev.SMA + SMA_##s##Left);		\
-	isa_writeb(dev.right_levels[d] >> 8,		\
+	writeb(dev.right_levels[d] >> 8,		\
 	       dev.SMA + SMA_##s##Right);		\
 	if (msnd_send_word(&dev, 0, 0, ar) == 0)	\
 		chk_send_dsp_cmd(&dev, HDEX_AUX_REQ);
@@ -450,23 +450,23 @@
 		/* master volume unscaled controls */
 	case SOUND_MIXER_LINE:			/* line pot control */
 		/* scaled by IMIX in digital mix */
-		isa_writeb(bLeft, dev.SMA + SMA_bInPotPosLeft);
-		isa_writeb(bRight, dev.SMA + SMA_bInPotPosRight);
+		writeb(bLeft, dev.SMA + SMA_bInPotPosLeft);
+		writeb(bRight, dev.SMA + SMA_bInPotPosRight);
 		if (msnd_send_word(&dev, 0, 0, HDEXAR_IN_SET_POTS) == 0)
 			chk_send_dsp_cmd(&dev, HDEX_AUX_REQ);
 		break;
 #ifndef MSND_CLASSIC
 	case SOUND_MIXER_MIC:			/* mic pot control */
 		/* scaled by IMIX in digital mix */
-		isa_writeb(bLeft, dev.SMA + SMA_bMicPotPosLeft);
-		isa_writeb(bRight, dev.SMA + SMA_bMicPotPosRight);
+		writeb(bLeft, dev.SMA + SMA_bMicPotPosLeft);
+		writeb(bRight, dev.SMA + SMA_bMicPotPosRight);
 		if (msnd_send_word(&dev, 0, 0, HDEXAR_MIC_SET_POTS) == 0)
 			chk_send_dsp_cmd(&dev, HDEX_AUX_REQ);
 		break;
 #endif
 	case SOUND_MIXER_VOLUME:		/* master volume */
-		isa_writew(wLeft, dev.SMA + SMA_wCurrMastVolLeft);
-		isa_writew(wRight, dev.SMA + SMA_wCurrMastVolRight);
+		writew(wLeft, dev.SMA + SMA_wCurrMastVolLeft);
+		writew(wRight, dev.SMA + SMA_wCurrMastVolRight);
 		/* fall through */
 
 	case SOUND_MIXER_LINE1:			/* aux pot control */
@@ -815,25 +815,25 @@
 	LPDAQD DAQD;
 
 	/* Increment the tail and check for queue wrap */
-	wTmp = isa_readw(dev.DARQ + JQS_wTail) + PCTODSP_OFFSET(DAQDS__size);
-	if (wTmp > isa_readw(dev.DARQ + JQS_wSize))
+	wTmp = readw(dev.DARQ + JQS_wTail) + PCTODSP_OFFSET(DAQDS__size);
+	if (wTmp > readw(dev.DARQ + JQS_wSize))
 		wTmp = 0;
-	while (wTmp == isa_readw(dev.DARQ + JQS_wHead) && timeout--)
+	while (wTmp == readw(dev.DARQ + JQS_wHead) && timeout--)
 		udelay(1);
-	isa_writew(wTmp, dev.DARQ + JQS_wTail);
+	writew(wTmp, dev.DARQ + JQS_wTail);
 
 	/* Get our digital audio queue struct */
 	DAQD = bank * DAQDS__size + dev.base + DARQ_DATA_BUFF;
 
 	/* Get length of data */
-	size = isa_readw(DAQD + DAQDS_wSize);
+	size = readw(DAQD + DAQDS_wSize);
 
 	/* Read data from the head (unprotected bank 1 access okay
            since this is only called inside an interrupt) */
 	msnd_outb(HPBLKSEL_1, dev.io + HP_BLKS);
-	msnd_fifo_write(
+	msnd_fifo_write_io(
 		&dev.DARF,
-		(char *)(dev.base + bank * DAR_BUFF_SIZE),
+		dev.base + bank * DAR_BUFF_SIZE,
 		size);
 	msnd_outb(HPBLKSEL_0, dev.io + HP_BLKS);
 
@@ -846,8 +846,8 @@
 	register int protect = start, nbanks = 0;
 	LPDAQD DAQD;
 
-	DAPQ_tail = isa_readw(dev.DAPQ + JQS_wTail);
-	while (DAPQ_tail != isa_readw(dev.DAPQ + JQS_wHead) || start) {
+	DAPQ_tail = readw(dev.DAPQ + JQS_wTail);
+	while (DAPQ_tail != readw(dev.DAPQ + JQS_wHead) || start) {
 		register int bank_num = DAPQ_tail / PCTODSP_OFFSET(DAQDS__size);
 		register int n;
 		unsigned long flags;
@@ -856,15 +856,15 @@
 		if (protect) {
 			/* Critical section: protect fifo in non-interrupt */
 			spin_lock_irqsave(&dev.lock, flags);
-			n = msnd_fifo_read(
+			n = msnd_fifo_read_io(
 				&dev.DAPF,
-				(char *)(dev.base + bank_num * DAP_BUFF_SIZE),
+				dev.base + bank_num * DAP_BUFF_SIZE,
 				DAP_BUFF_SIZE);
 			spin_unlock_irqrestore(&dev.lock, flags);
 		} else {
-			n = msnd_fifo_read(
+			n = msnd_fifo_read_io(
 				&dev.DAPF,
-				(char *)(dev.base + bank_num * DAP_BUFF_SIZE),
+				dev.base + bank_num * DAP_BUFF_SIZE,
 				DAP_BUFF_SIZE);
 		}
 		if (!n)
@@ -877,12 +877,12 @@
 		DAQD = bank_num * DAQDS__size + dev.base + DAPQ_DATA_BUFF;
 
 		/* Write size of this bank */
-		isa_writew(n, DAQD + DAQDS_wSize);
+		writew(n, DAQD + DAQDS_wSize);
 		++nbanks;
 
 		/* Then advance the tail */
 		DAPQ_tail = (++bank_num % 3) * PCTODSP_OFFSET(DAQDS__size);
-		isa_writew(DAPQ_tail, dev.DAPQ + JQS_wTail);
+		writew(DAPQ_tail, dev.DAPQ + JQS_wTail);
 		/* Tell the DSP to play the bank */
 		msnd_send_dsp_cmd(&dev, HDEX_PLAY_START);
 	}
@@ -1094,15 +1094,15 @@
 	msnd_inb(dev.io + HP_RXL);
 
 	/* Evaluate queued DSP messages */
-	while (isa_readw(dev.DSPQ + JQS_wTail) != isa_readw(dev.DSPQ + JQS_wHead)) {
+	while (readw(dev.DSPQ + JQS_wTail) != readw(dev.DSPQ + JQS_wHead)) {
 		register WORD wTmp;
 
-		eval_dsp_msg(isa_readw(dev.pwDSPQData + 2*isa_readw(dev.DSPQ + JQS_wHead)));
+		eval_dsp_msg(readw(dev.pwDSPQData + 2*readw(dev.DSPQ + JQS_wHead)));
 
-		if ((wTmp = isa_readw(dev.DSPQ + JQS_wHead) + 1) > isa_readw(dev.DSPQ + JQS_wSize))
-			isa_writew(0, dev.DSPQ + JQS_wHead);
+		if ((wTmp = readw(dev.DSPQ + JQS_wHead) + 1) > readw(dev.DSPQ + JQS_wSize))
+			writew(0, dev.DSPQ + JQS_wHead);
 		else
-			isa_writew(wTmp, dev.DSPQ + JQS_wHead);
+			writew(wTmp, dev.DSPQ + JQS_wHead);
 	}
 	return IRQ_HANDLED;
 }
@@ -1182,7 +1182,7 @@
 	}
 	printk(KERN_INFO LOGNAME ": %s revision %s, Xilinx version %s, "
 #endif /* MSND_CLASSIC */
-	       "I/O 0x%x-0x%x, IRQ %d, memory mapped to 0x%lX-0x%lX\n",
+	       "I/O 0x%x-0x%x, IRQ %d, memory mapped to %p-%p\n",
 	       dev.name,
 #ifndef MSND_CLASSIC
 	       rev, xv,
@@ -1206,16 +1206,16 @@
 #endif
 	msnd_outb(HPBLKSEL_0, dev.io + HP_BLKS);
 	if (initted) {
-		mastVolLeft = isa_readw(dev.SMA + SMA_wCurrMastVolLeft);
-		mastVolRight = isa_readw(dev.SMA + SMA_wCurrMastVolRight);
+		mastVolLeft = readw(dev.SMA + SMA_wCurrMastVolLeft);
+		mastVolRight = readw(dev.SMA + SMA_wCurrMastVolRight);
 	} else
 		mastVolLeft = mastVolRight = 0;
-	isa_memset_io(dev.base, 0, 0x8000);
+	memset_io(dev.base, 0, 0x8000);
 
 	/* Critical section: bank 1 access */
 	spin_lock_irqsave(&dev.lock, flags);
 	msnd_outb(HPBLKSEL_1, dev.io + HP_BLKS);
-	isa_memset_io(dev.base, 0, 0x8000);
+	memset_io(dev.base, 0, 0x8000);
 	msnd_outb(HPBLKSEL_0, dev.io + HP_BLKS);
 	spin_unlock_irqrestore(&dev.lock, flags);
 
@@ -1248,19 +1248,19 @@
 
 	/* Setup some DSP values */
 #ifndef MSND_CLASSIC
-	isa_writew(1, dev.SMA + SMA_wCurrPlayFormat);
-	isa_writew(dev.play_sample_size, dev.SMA + SMA_wCurrPlaySampleSize);
-	isa_writew(dev.play_channels, dev.SMA + SMA_wCurrPlayChannels);
-	isa_writew(dev.play_sample_rate, dev.SMA + SMA_wCurrPlaySampleRate);
-#endif
-	isa_writew(dev.play_sample_rate, dev.SMA + SMA_wCalFreqAtoD);
-	isa_writew(mastVolLeft, dev.SMA + SMA_wCurrMastVolLeft);
-	isa_writew(mastVolRight, dev.SMA + SMA_wCurrMastVolRight);
+	writew(1, dev.SMA + SMA_wCurrPlayFormat);
+	writew(dev.play_sample_size, dev.SMA + SMA_wCurrPlaySampleSize);
+	writew(dev.play_channels, dev.SMA + SMA_wCurrPlayChannels);
+	writew(dev.play_sample_rate, dev.SMA + SMA_wCurrPlaySampleRate);
+#endif
+	writew(dev.play_sample_rate, dev.SMA + SMA_wCalFreqAtoD);
+	writew(mastVolLeft, dev.SMA + SMA_wCurrMastVolLeft);
+	writew(mastVolRight, dev.SMA + SMA_wCurrMastVolRight);
 #ifndef MSND_CLASSIC
-	isa_writel(0x00010000, dev.SMA + SMA_dwCurrPlayPitch);
-	isa_writel(0x00000001, dev.SMA + SMA_dwCurrPlayRate);
+	writel(0x00010000, dev.SMA + SMA_dwCurrPlayPitch);
+	writel(0x00000001, dev.SMA + SMA_dwCurrPlayRate);
 #endif
-	isa_writew(0x303, dev.SMA + SMA_wCurrInputTagBits);
+	writew(0x303, dev.SMA + SMA_wCurrInputTagBits);
 
 	initted = 1;
 
@@ -1269,12 +1269,12 @@
 
 static int __init calibrate_adc(WORD srate)
 {
-	isa_writew(srate, dev.SMA + SMA_wCalFreqAtoD);
+	writew(srate, dev.SMA + SMA_wCalFreqAtoD);
 	if (dev.calibrate_signal == 0)
-		isa_writew(isa_readw(dev.SMA + SMA_wCurrHostStatusFlags)
+		writew(readw(dev.SMA + SMA_wCurrHostStatusFlags)
 		       | 0x0001, dev.SMA + SMA_wCurrHostStatusFlags);
 	else
-		isa_writew(isa_readw(dev.SMA + SMA_wCurrHostStatusFlags)
+		writew(readw(dev.SMA + SMA_wCurrHostStatusFlags)
 		       & ~0x0001, dev.SMA + SMA_wCurrHostStatusFlags);
 	if (msnd_send_word(&dev, 0, 0, HDEXAR_CAL_A_TO_D) == 0 &&
 	    chk_send_dsp_cmd(&dev, HDEX_AUX_REQ) == 0) {
@@ -1304,7 +1304,7 @@
 		return -EBUSY;
 	}
 #endif
-	isa_memcpy_toio(dev.base, PERMCODE, PERMCODESIZE);
+	memcpy_toio(dev.base, PERMCODE, PERMCODESIZE);
 	if (msnd_upload_host(&dev, INITCODE, INITCODESIZE) < 0) {
 		printk(KERN_WARNING LOGNAME ": Error uploading to DSP\n");
 		return -ENODEV;
@@ -1357,7 +1357,7 @@
 	}
 
 	timeout = 200;
-	while (isa_readw(dev.base)) {
+	while (readw(dev.base)) {
 		mdelay(1);
 		if (!timeout--) {
 			printk(KERN_DEBUG LOGNAME ": DSP reset timeout\n");
@@ -1861,7 +1861,7 @@
 	dev.io = io;
 	dev.numio = DSP_NUMIO;
 	dev.irq = irq;
-	dev.base = mem;
+	dev.base = ioremap(mem, 0x8000);
 	dev.fifosize = fifosize * 1024;
 	dev.calibrate_signal = calibrate_signal ? 1 : 0;
 	dev.recsrc = 0;
diff -Nru a/sound/oss/nm256.h b/sound/oss/nm256.h
--- a/sound/oss/nm256.h	2004-12-24 13:37:00 -08:00
+++ b/sound/oss/nm256.h	2004-12-24 13:37:00 -08:00
@@ -60,7 +60,7 @@
 	/* Physical address of the port. */
 	u32 physaddr;
 	/* Our mapped-in pointer. */
-	char *ptr;
+	char __iomem *ptr;
 	/* PTR's offset within the physical port.  */
 	u32 start_offset;
 	/* And the offset of the end of the buffer.  */
@@ -233,14 +233,14 @@
 static inline int nm256_writePort##X (struct nm256_info *card,\
 				      int port, int offset, int value)\
 {\
-    u##X *addr;\
+    u##X __iomem *addr;\
 \
     if (nm256_debug > 1)\
         printk (KERN_DEBUG "Writing 0x%x to %d:0x%x\n", value, port, offset);\
 \
     NM_FIX_PORT;\
 \
-    addr = (u##X *)(card->port[port - 1].ptr + offset);\
+    addr = (u##X __iomem *)(card->port[port - 1].ptr + offset);\
     func (value, addr);\
     return 0;\
 }
@@ -253,11 +253,11 @@
 static inline u##X nm256_readPort##X (struct nm256_info *card,\
 					int port, int offset)\
 {\
-    u##X *addr;\
+    u##X __iomem *addr;\
 \
     NM_FIX_PORT\
 \
-    addr = (u##X *)(card->port[port - 1].ptr + offset);\
+    addr = (u##X __iomem *)(card->port[port - 1].ptr + offset);\
     return func(addr);\
 }
 
diff -Nru a/sound/oss/nm256_audio.c b/sound/oss/nm256_audio.c
--- a/sound/oss/nm256_audio.c	2004-12-24 13:36:48 -08:00
+++ b/sound/oss/nm256_audio.c	2004-12-24 13:36:48 -08:00
@@ -1011,7 +1011,7 @@
     u32 port1offset 
 	= card->port[0].physaddr + card->port[0].end_offset - 0x0400;
     /* The signature is located 1K below the end of video RAM.  */
-    char *temp = ioremap_nocache (port1offset, 16);
+    char __iomem *temp = ioremap_nocache (port1offset, 16);
     /* Default buffer end is 5120 bytes below the top of RAM.  */
     u32 default_value = card->port[0].end_offset - 0x1400;
     u32 sig;
diff -Nru a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
--- a/sound/oss/rme96xx.c	2004-12-24 13:36:47 -08:00
+++ b/sound/oss/rme96xx.c	2004-12-24 13:36:47 -08:00
@@ -273,7 +273,7 @@
 	/* hardware settings */
 	int magic;
 	struct pci_dev * pcidev; /* pci_dev structure */
-	unsigned long *iobase;	
+	unsigned long __iomem *iobase;	
 	unsigned int irq;
 
 	/* list of rme96xx devices */
@@ -1685,14 +1685,14 @@
 	if (vma->vm_flags & VM_WRITE) {
 		if (!s->started) rme96xx_startcard(s,1);
 
-		if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->playbuf + dma->outoffset*RME96xx_DMA_MAX_SIZE), size, vma->vm_page_prot)) {
+		if (remap_pfn_range(vma, vma->vm_start, virt_to_phys(s->playbuf + dma->outoffset*RME96xx_DMA_MAX_SIZE) >> PAGE_SHIFT, size, vma->vm_page_prot)) {
 			unlock_kernel();
 			return -EAGAIN;
 		}
 	} 
 	else if (vma->vm_flags & VM_READ) {
 		if (!s->started) rme96xx_startcard(s,1);
-		if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->playbuf + dma->inoffset*RME96xx_DMA_MAX_SIZE), size, vma->vm_page_prot)) {
+		if (remap_pfn_range(vma, vma->vm_start, virt_to_phys(s->playbuf + dma->inoffset*RME96xx_DMA_MAX_SIZE) >> PAGE_SHIFT, size, vma->vm_page_prot)) {
 			unlock_kernel();
 			return -EAGAIN;
 		}
diff -Nru a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
--- a/sound/oss/sonicvibes.c	2004-12-24 13:36:48 -08:00
+++ b/sound/oss/sonicvibes.c	2004-12-24 13:36:48 -08:00
@@ -756,7 +756,7 @@
 		if ((virt_to_bus(db->rawbuf) + (PAGE_SIZE << db->buforder) - 1) & ~0xffffff)
 			printk(KERN_DEBUG "sv: DMA buffer beyond 16MB: busaddr 0x%lx  size %ld\n", 
 			       virt_to_bus(db->rawbuf), PAGE_SIZE << db->buforder);
-		/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+		/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 		pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
 		for (page = virt_to_page(db->rawbuf); page <= pend; page++)
 			SetPageReserved(page);
@@ -1549,7 +1549,9 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+	if (remap_pfn_range(vma, vma->vm_start,
+				virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+				size, vma->vm_page_prot))
 		goto out;
 	db->mapped = 1;
 	ret = 0;
diff -Nru a/sound/oss/sound_calls.h b/sound/oss/sound_calls.h
--- a/sound/oss/sound_calls.h	2004-12-24 13:37:00 -08:00
+++ b/sound/oss/sound_calls.h	2004-12-24 13:37:00 -08:00
@@ -39,7 +39,6 @@
 	   unsigned int cmd, void __user *arg);
 void audio_init_devices (void);
 void reorganize_buffers (int dev, struct dma_buffparms *dmap, int recording);
-int dma_ioctl (int dev, unsigned int cmd, void __user *arg);
 
 /*
  *	System calls for the /dev/sequencer
diff -Nru a/sound/oss/sound_syms.c b/sound/oss/sound_syms.c
--- a/sound/oss/sound_syms.c	2004-12-24 13:37:29 -08:00
+++ b/sound/oss/sound_syms.c	2004-12-24 13:37:29 -08:00
@@ -22,10 +22,8 @@
 EXPORT_SYMBOL(midi_devs);
 EXPORT_SYMBOL(num_midis);
 EXPORT_SYMBOL(synth_devs);
-EXPORT_SYMBOL(num_synths);
 
 EXPORT_SYMBOL(sound_timer_devs);
-EXPORT_SYMBOL(num_sound_timers);
 
 EXPORT_SYMBOL(sound_install_audiodrv);
 EXPORT_SYMBOL(sound_install_mixer);
@@ -33,7 +31,6 @@
 EXPORT_SYMBOL(sound_free_dma);
 EXPORT_SYMBOL(sound_open_dma);
 EXPORT_SYMBOL(sound_close_dma);
-EXPORT_SYMBOL(sound_alloc_audiodev);
 EXPORT_SYMBOL(sound_alloc_mididev);
 EXPORT_SYMBOL(sound_alloc_mixerdev);
 EXPORT_SYMBOL(sound_alloc_timerdev);
diff -Nru a/sound/oss/soundcard.c b/sound/oss/soundcard.c
--- a/sound/oss/soundcard.c	2004-12-24 13:36:49 -08:00
+++ b/sound/oss/soundcard.c	2004-12-24 13:36:49 -08:00
@@ -127,7 +127,7 @@
 {
 	int n;
 
-	if (__get_user(n, (int __user *)(&(((mixer_vol_table *__user )arg)->num))))
+	if (__get_user(n, (int __user *)(&(((mixer_vol_table __user *)arg)->num))))
 		return -EFAULT;
 	if (n < 0 || n >= num_mixer_volumes)
 		return -EINVAL;
@@ -463,9 +463,9 @@
 	if (size != dmap->bytes_in_use) {
 		printk(KERN_WARNING "Sound: mmap() size = %ld. Should be %d\n", size, dmap->bytes_in_use);
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmap->raw_buf),
-		vma->vm_end - vma->vm_start,
-		vma->vm_page_prot)) {
+	if (remap_pfn_range(vma, vma->vm_start,
+			virt_to_phys(dmap->raw_buf) >> PAGE_SHIFT,
+			vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
 		unlock_kernel();
 		return -EAGAIN;
 	}
diff -Nru a/sound/oss/trident.c b/sound/oss/trident.c
--- a/sound/oss/trident.c	2004-12-24 13:37:17 -08:00
+++ b/sound/oss/trident.c	2004-12-24 13:37:17 -08:00
@@ -1281,7 +1281,7 @@
 	dmabuf->buforder = order;
 
 	/* now mark the pages as reserved; otherwise */ 
-	/* remap_page_range doesn't do what we want */
+	/* remap_pfn_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
 		SetPageReserved(page);
@@ -2223,7 +2223,8 @@
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf), 
+	if (remap_pfn_range(vma, vma->vm_start,
+			     virt_to_phys(dmabuf->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot))
 		goto out;
 	dmabuf->mapped = 1;
@@ -4594,11 +4595,7 @@
 	       "5050 PCI Audio, version " DRIVER_VERSION ", " __TIME__ " " 
 	       __DATE__ "\n");
 
-	if (!pci_register_driver(&trident_pci_driver)) {
-		pci_unregister_driver(&trident_pci_driver);
-		return -ENODEV;
-	}
-	return 0;
+	return pci_register_driver(&trident_pci_driver);
 }
 
 static void __exit
diff -Nru a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
--- a/sound/oss/via82cxxx_audio.c	2004-12-24 13:36:31 -08:00
+++ b/sound/oss/via82cxxx_audio.c	2004-12-24 13:36:31 -08:00
@@ -3622,12 +3622,10 @@
 	}
 
 	rc = pci_register_driver (&via_driver);
-	if (rc < 1) {
-		if (rc == 0)
-			pci_unregister_driver (&via_driver);
+	if (rc) {
 		via_cleanup_proc ();
-		DPRINTK ("EXIT, returning -ENODEV\n");
-		return -ENODEV;
+		DPRINTK ("EXIT, returning %d\n", rc);
+		return rc;
 	}
 
 	DPRINTK ("EXIT, returning 0\n");
diff -Nru a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
--- a/sound/oss/ymfpci.c	2004-12-24 13:37:00 -08:00
+++ b/sound/oss/ymfpci.c	2004-12-24 13:37:00 -08:00
@@ -334,7 +334,7 @@
 	dmabuf->dma_addr = dma_addr;
 	dmabuf->buforder = order;
 
-	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+	/* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
 	mapend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (map = virt_to_page(rawbuf); map <= mapend; map++)
 		set_bit(PG_reserved, &map->flags);
@@ -1545,7 +1545,8 @@
 	size = vma->vm_end - vma->vm_start;
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		return -EINVAL;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
+	if (remap_pfn_range(vma, vma->vm_start,
+			     virt_to_phys(dmabuf->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot))
 		return -EAGAIN;
 	dmabuf->mapped = 1;
diff -Nru a/sound/oss/ymfpci.h b/sound/oss/ymfpci.h
--- a/sound/oss/ymfpci.h	2004-12-24 13:36:47 -08:00
+++ b/sound/oss/ymfpci.h	2004-12-24 13:36:47 -08:00
@@ -239,7 +239,7 @@
 
 struct ymf_unit {
 	u8 rev;				/* PCI revision */
-	void *reg_area_virt;
+	void __iomem *reg_area_virt;
 	void *dma_area_va;
 	dma_addr_t dma_area_ba;
 	unsigned int dma_area_size;
diff -Nru a/sound/parisc/Kconfig b/sound/parisc/Kconfig
--- a/sound/parisc/Kconfig	2004-12-24 13:36:59 -08:00
+++ b/sound/parisc/Kconfig	2004-12-24 13:36:59 -08:00
@@ -1,14 +1,15 @@
 # ALSA PA-RISC drivers
 
-menu "ALSA PA-RISC devices"
-	depends on SND!=n && PARISC
+menu "ALSA GSC devices"
+	depends on SND!=n && GSC
 
 config SND_HARMONY
 	tristate "Harmony/Vivace sound chip"
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Harmony/Vivace soundchip
-	  on HP712s, 715/new and many other GSC based machines.
+	  Say 'Y' or 'M' to include support for the Harmony/Vivace sound
+	  chip found in most GSC-based PA-RISC workstations.  It's frequently
+	  provided as part of the Lasi multi-function IC.
 
 endmenu
diff -Nru a/sound/parisc/harmony.c b/sound/parisc/harmony.c
--- a/sound/parisc/harmony.c	2004-12-24 13:36:48 -08:00
+++ b/sound/parisc/harmony.c	2004-12-24 13:36:48 -08:00
@@ -133,14 +133,13 @@
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
-MODULE_PARM_DESC(index, "Index value for Sun CS4231 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
-MODULE_PARM_DESC(id, "ID string for Sun CS4231 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
-MODULE_PARM_DESC(enable, "Enable Sun CS4231 soundcard.");
+module_param_array(index, int, NULL, 0444);
+MODULE_PARM_DESC(index, "Index value for Harmony device.");
+module_param_array(id, charp, NULL, 0444);
+MODULE_PARM_DESC(id, "ID string for Harmony device.");
+module_param_array(enable, bool, NULL, 0444);
+MODULE_PARM_DESC(enable, "Enable Harmony device.");
 
 /* Register offset (from base hpa) */
 #define REG_ID		0x00
@@ -276,7 +275,7 @@
 {
 	unsigned int idx;
 	
-	for (idx = 0; idx <= ARRAY_SIZE(snd_card_harmony_rates); idx++)
+	for (idx = 0; idx < ARRAY_SIZE(snd_card_harmony_rates); idx++)
 		if (snd_card_harmony_rates[idx] == rate)
 			return rate_bits[idx];
 	return HARMONY_SR_44KHZ; /* fallback */
@@ -742,9 +741,10 @@
 	                   snd_pcm_hw_params_t * hw_params)
 {
 	int err;
+	snd_card_harmony_t *harmony = snd_pcm_substream_chip(substream);
 	
 	err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
-	if (err > 0 && substream->dma_device.type == SNDRV_DMA_TYPE_CONTINUOUS)
+	if (err > 0 && harmony->dma_dev.type == SNDRV_DMA_TYPE_CONTINUOUS)
 		substream->runtime->dma_addr = __pa(substream->runtime->dma_area);
 	DPRINTK(KERN_INFO PFX "HW Params returned %d, dma_addr %lx\n", err,
 			(unsigned long)substream->runtime->dma_addr);
@@ -1132,11 +1132,13 @@
 		{	
 			DPRINTK(KERN_INFO PFX "Freeing card %d\n", idx);
 			harmony = snd_harmony_cards[idx]->private_data;
-			free_irq(harmony->irq, snd_card_harmony_interrupt);
+			free_irq(harmony->irq, harmony);
 			printk(KERN_INFO PFX "Card unloaded %d, irq=%d\n", idx, harmony->irq);
 			snd_card_free(snd_harmony_cards[idx]);
 		}
 	}	
+	if (unregister_parisc_driver(&snd_card_harmony_driver) < 0)
+		printk(KERN_ERR PFX "Failed to unregister Harmony driver\n");
 }
 
 module_init(alsa_card_harmony_init)
diff -Nru a/sound/pci/Kconfig b/sound/pci/Kconfig
--- a/sound/pci/Kconfig	2004-12-24 13:36:47 -08:00
+++ b/sound/pci/Kconfig	2004-12-24 13:36:47 -08:00
@@ -8,27 +8,41 @@
 	select SND_PCM
 
 config SND_ALI5451
-	tristate "ALi PCI Audio M5451"
+	tristate "ALi M5451 PCI Audio Controller"
 	depends on SND
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ALI PCI Audio M5451 sound core.
+	  Say Y here to include support for the integrated AC97 sound
+	  device on motherboards using the ALi M5451 Audio Controller
+	  (M1535/M1535D/M1535+/M1535D+ south bridges).  Newer chipsets
+	  use the "Intel/SiS/nVidia/AMD/ALi AC97 Controller" driver.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ali5451.
 
 config SND_ATIIXP
-	tristate "ATI IXP 150/200/250/300"
+	tristate "ATI IXP AC97 Controller"
 	depends on SND
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ATI IXP 150/200/250/300 AC97 controller.
+	  Say Y here to include support for the integrated AC97 sound
+	  device on motherboards with ATI chipsets (ATI IXP 150/200/250/
+	  300/400).
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-atiixp.
 
 config SND_ATIIXP_MODEM
-	tristate "ATI IXP 150/200/250 Modem"
+	tristate "ATI IXP Modem"
 	depends on SND
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ATI IXP 150/200/250 AC97 modem
-	  controller.
+	  Say Y here to include support for the integrated MC97 modem on
+	  motherboards with ATI chipsets (ATI IXP 150/200/250).
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-atiixp-modem.
 
 config SND_AU8810
         tristate "Aureal Advantage"
@@ -36,10 +50,14 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
         help
-          Say 'Y' or 'M' to include support for Aureal Advantage soundcards.
-          Supported features: Hardware Mixer, SRC, EQ and SPDIF output.
+	  Say Y here to include support for Aureal Advantage soundcards.
+
+	  Supported features: Hardware Mixer, SRC, EQ and SPDIF output.
           3D support code is in place, but not yet useable. For more info, 
           email the ALSA developer list, or mjander@users.sourceforge.net.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-au8810.
  
 config SND_AU8820
         tristate "Aureal Vortex"
@@ -47,9 +65,13 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
         help
-          Say 'Y' or 'M' to include support for Aureal Vortex soundcards.
+	  Say Y here to include support for Aureal Vortex soundcards.
+
           Supported features: Hardware Mixer and SRC. For more info, email 
           the ALSA developer list, or mjander@users.sourceforge.net.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-au8820.
  
 config SND_AU8830
         tristate "Aureal Vortex 2"
@@ -57,10 +79,14 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
         help
-          Say 'Y' or 'M' to include support for Aureal Vortex 2 soundcards.
+	  Say Y here to include support for Aureal Vortex 2 soundcards.
+
           Supported features: Hardware Mixer, SRC, EQ and SPDIF output.
           3D support code is in place, but not yet useable. For more info, 
           email the ALSA developer list, or mjander@users.sourceforge.net.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-au8830.
  
 config SND_AZT3328
 	tristate "Aztech AZF3328 / PCI168 (EXPERIMENTAL)"
@@ -69,15 +95,32 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Aztech AZF3328 (PCI168) soundcards.
+	  Say Y here to include support for Aztech AZF3328 (PCI168)
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-azt3328.
 
 config SND_BT87X
         tristate "Bt87x Audio Capture"
         depends on SND
 	select SND_PCM
         help
-          Say 'Y' or 'M' to include support for recording audio from TV cards
-          based on Brooktree Bt878/Bt879 chips.
+	  Say Y here to include support for recording audio from TV
+	  cards based on Brooktree Bt878/Bt879 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-bt87x.
+
+config SND_BT87X_OVERCLOCK
+	bool "Bt87x Audio overclocking"
+	depends on SND_BT87X
+	help
+	  Say Y here if 448000 Hz isn't enough for you and you want to
+	  record from the analog input with up to 1792000 Hz.
+
+	  Higher sample rates won't hurt your hardware, but audio
+	  quality may suffer.
 
 config SND_CS46XX
 	tristate "Cirrus Logic (Sound Fusion) CS4280/CS461x/CS462x/CS463x"
@@ -85,14 +128,19 @@
 	select SND_RAWMIDI
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for Cirrus Logic CS4610 / CS4612 /
-	  CS4614 / CS4615 / CS4622 / CS4624 / CS4630 / CS4280 chips.
+	  Say Y here to include support for Cirrus Logic CS4610/CS4612/
+	  CS4614/CS4615/CS4622/CS4624/CS4630/CS4280 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-cs46xx.
 
 config SND_CS46XX_NEW_DSP
 	bool "Cirrus Logic (Sound Fusion) New DSP support (EXPERIMENTAL)"
 	depends on SND_CS46XX && EXPERIMENTAL
 	help
-	  Say 'Y' to use a new DSP image for SPDIF and dual codecs.
+	  Say Y here to use a new DSP image for SPDIF and dual codecs.
+
+	  This works better than the old code, so say Y.
 
 config SND_CS4281
 	tristate "Cirrus Logic (Sound Fusion) CS4281"
@@ -101,24 +149,37 @@
 	select SND_RAWMIDI
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for Cirrus Logic CS4281.
+	  Say Y here to include support for Cirrus Logic CS4281 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-cs4281.
 
 config SND_EMU10K1
-	tristate "EMU10K1 (SB Live! & Audigy, E-mu APS)"
+	tristate "Emu10k1 (SB Live!, Audigy, E-mu APS)"
 	depends on SND
 	select SND_HWDEP
 	select SND_RAWMIDI
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for Sound Blaster PCI 512, Live!,
-	  Audigy and E-mu APS (partially supported).
+	  Say Y to include support for Sound Blaster PCI 512, Live!,
+	  Audigy and E-mu APS (partially supported) soundcards.
+
+	  The confusing multitude of mixer controls is documented in
+	  <file:Documentation/sound/alsa/SB-Live-mixer.txt> and
+	  <file:Documentation/sound/alsa/Audigy-mixer.txt>.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-emu10k1.
 
 config SND_KORG1212
 	tristate "Korg 1212 IO"
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Korg 1212IO.
+	  Say Y here to include support for Korg 1212IO soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-korg1212.
 
 config SND_MIXART
 	tristate "Digigram miXart"
@@ -126,38 +187,55 @@
 	select SND_HWDEP
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Digigram miXart soundcard.
+	  If you want to use Digigram miXart soundcards, say Y here and
+	  read <file:Documentation/sound/alsa/MIXART.txt>.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-mixart.
 
 config SND_NM256
 	tristate "NeoMagic NM256AV/ZX"
 	depends on SND
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for NeoMagic NM256AV/ZX chips.
+	  Say Y here to include support for NeoMagic NM256AV/ZX chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-nm256.
 
 config SND_RME32
 	tristate "RME Digi32, 32/8, 32 PRO"
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for RME Digi32, Digi32 PRO and
-	  Digi32/8 (Sek'd Prodif32, Prodif96 and Prodif Gold) audio devices.
+	  Say Y to include support for RME Digi32, Digi32 PRO and
+	  Digi32/8 (Sek'd Prodif32, Prodif96 and Prodif Gold) audio
+	  devices.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-rme32.
 
 config SND_RME96
 	tristate "RME Digi96, 96/8, 96/8 PRO"
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for RME Digi96, Digi96/8 and
-	  Digi96/8 PRO/PAD/PST.
+	  Say Y here to include support for RME Digi96, Digi96/8 and
+	  Digi96/8 PRO/PAD/PST soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-rme96.
 
 config SND_RME9652
 	tristate "RME Digi9652 (Hammerfall)"
 	depends on SND
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for RME Hammerfall (RME Digi9652 /
-	  Digi9636) soundcards.
+	  Say Y here to include support for RME Hammerfall (RME
+	  Digi9652/Digi9636) soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-rme9652.
 
 config SND_HDSP
 	tristate "RME Hammerfall DSP Audio"
@@ -166,17 +244,23 @@
 	select SND_RAWMIDI
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for RME Hammerfall DSP Audio
+	  Say Y here to include support for RME Hammerfall DSP Audio
 	  soundcards.
 
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-hdsp.
+
 config SND_TRIDENT
 	tristate "Trident 4D-Wave DX/NX; SiS 7018"
 	depends on SND
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for Trident 4D-Wave DX/NX and
-	  SiS 7018 soundcards.
+	  Say Y here to include support for soundcards based on Trident
+	  4D-Wave DX/NX or SiS 7018 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-trident.
 
 config SND_YMFPCI
 	tristate "Yamaha YMF724/740/744/754"
@@ -185,9 +269,12 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for Yamaha PCI audio chips - 
+	  Say Y here to include support for Yamaha PCI audio chips -
 	  YMF724, YMF724F, YMF740, YMF740C, YMF744, YMF754.
 
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ymfpci.
+
 config SND_ALS4000
 	tristate "Avance Logic ALS4000"
 	depends on SND
@@ -195,7 +282,11 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Avance Logic ALS4000.
+	  Say Y here to include support for soundcards based on Avance Logic
+	  ALS4000 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-als4000.
 
 config SND_CMIPCI
 	tristate "C-Media 8738, 8338"
@@ -204,8 +295,12 @@
 	select SND_MPU401_UART
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for C-Media CMI8338 and 8738 PCI
-	  soundcards.
+	  If you want to use soundcards based on C-Media CMI8338 or CMI8738
+	  chips, say Y here and read
+	  <file:Documentation/sound/alsa/CMIPCI.txt>.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-cmipci.
 
 config SND_ENS1370
 	tristate "(Creative) Ensoniq AudioPCI 1370"
@@ -213,7 +308,10 @@
 	select SND_RAWMIDI
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Ensoniq AudioPCI ES1370.
+	  Say Y here to include support for Ensoniq AudioPCI ES1370 chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ens1370.
 
 config SND_ENS1371
 	tristate "(Creative) Ensoniq AudioPCI 1371/1373"
@@ -221,9 +319,12 @@
 	select SND_RAWMIDI
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for Ensoniq AudioPCI ES1371 and
+	  Say Y here to include support for Ensoniq AudioPCI ES1371 chips and
 	  Sound Blaster PCI 64 or 128 soundcards.
 
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ens1371.
+
 config SND_ES1938
 	tristate "ESS ES1938/1946/1969 (Solo-1)"
 	depends on SND
@@ -231,8 +332,11 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ESS Solo-1 (ES1938, ES1946, ES1969)
-	  soundcard.
+	  Say Y here to include support for soundcards based on ESS Solo-1
+	  (ES1938, ES1946, ES1969) chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-es1938.
 
 config SND_ES1968
 	tristate "ESS ES1968/1978 (Maestro-1/2/2E)"
@@ -240,14 +344,22 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ESS Maestro 1/2/2E.
+	  Say Y here to include support for soundcards based on ESS Maestro
+	  1/2/2E chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-es1968.
 
 config SND_MAESTRO3
 	tristate "ESS Allegro/Maestro3"
 	depends on SND
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ESS Maestro 3 (Allegro) soundcard.
+	  Say Y here to include support for soundcards based on ESS Maestro 3
+	  (Allegro) chips.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-maestro3.
 
 config SND_FM801
 	tristate "ForteMedia FM801"
@@ -256,15 +368,23 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ForteMedia FM801 based soundcards.
+	  Say Y here to include support for soundcards based on the ForteMedia
+	  FM801 chip.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-fm801.
 
 config SND_FM801_TEA575X
 	tristate "ForteMedia FM801 + TEA5757 tuner"
 	depends on SND_FM801
         select VIDEO_DEV
 	help
-	  Say 'Y' or 'M' to include support for ForteMedia FM801 based soundcards
-          with TEA5757 tuner connected to GPIO1-3 pins (Media Forte SF256-PCS-02).
+	  Say Y here to include support for soundcards based on the ForteMedia
+	  FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media
+	  Forte SF256-PCS-02).
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-fm801-tea575x.
 
 config SND_ICE1712
 	tristate "ICEnsemble ICE1712 (Envy24)"
@@ -272,10 +392,16 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ICE1712 (Envy24) based soundcards.
-	  Currently supported hardware is: MidiMan M Audio - Delta 1010(LT), Dio 2496,
-	  Delta 66/44, Audiophile 24/96; Hoontech SoundTrack DSP 24 (Value);
-	  TerraTec - EWX 24/96, EWS 88MT, EWS 88D, DMX 6Fire.
+	  Say Y here to include support for soundcards based on the
+	  ICE1712 (Envy24) chip.
+
+	  Currently supported hardware is: M-Audio Delta 1010(LT),
+	  DiO 2496, 66, 44, 410, Audiophile 24/96; Digigram VX442;
+	  TerraTec EWX 24/96, EWS 88MT, 88D, DMX 6Fire, Phase 88;
+	  Hoontech SoundTrack DSP 24/Value/Media7.1; Event EZ8.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ice1712.
 
 config SND_ICE1724
 	tristate "ICE/VT1724/1720 (Envy24HT/PT)"
@@ -283,27 +409,40 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for ICE/VT1724/1720 (Envy24HT/PT) based
-	  soundcards.
-	  Currently supported hardware is: MidiMan M Audio - Revolution 7.1,
-	  AMP Ltd AUDIO2000, Terratec Aureon 5.1 Sky/7.1, AudioTrak Prodigy 7.1.
+	  Say Y here to include support for soundcards based on
+	  ICE/VT1724/1720 (Envy24HT/PT) chips.
+
+	  Currently supported hardware is: AMP AUDIO2000; M-Audio
+	  Revolution 7.1; TerraTec Aureon 5.1 Sky, 7.1 Space/Universe;
+	  AudioTrak Prodigy 7.1; Pontis MS300; Albatron K8X800 Pro II;
+	  Chaintech ZNF3-150/250.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-ice1724.
 
 config SND_INTEL8X0
-	tristate "Intel i8x0/MX440, SiS 7012; Ali 5455; NForce Audio; AMD768/8111"
+	tristate "Intel/SiS/nVidia/AMD/ALi AC97 Controller"
 	depends on SND
-	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for Intel8x0 based soundcards,
-	  SiS 7012, AMD768/8111, NVidia NForce and ALi 5455 chips.
+	  Say Y here to include support for the integrated AC97 sound
+	  device on motherboards with Intel/SiS/nVidia/AMD chipsets, or
+	  ALi chipsets using the M5455 Audio Controller.  (There is a
+	  separate driver for ALi M5451 Audio Controllers.)
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-intel8x0.
 
 config SND_INTEL8X0M
-	tristate "Intel i8x0/MX440; SiS 7013; NForce; AMD768/8111 modems (EXPERIMENTAL)"
+	tristate "Intel/SiS/nVidia/AMD MC97 Modem (EXPERIMENTAL)"
 	depends on SND && EXPERIMENTAL
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for Intel8x0, SiS 7013, NVidia NForce
-          and AMD768/8111 based modems.
+	  Say Y here to include support for the integrated MC97 modem on
+	  motherboards with Intel/SiS/nVidia/AMD chipsets.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-intel8x0m.
 
 config SND_SONICVIBES
 	tristate "S3 SonicVibes"
@@ -312,22 +451,33 @@
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for S3 SonicVibes based soundcards.
+	  Say Y here to include support for soundcards based on the S3
+	  SonicVibes chip.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-sonicvibes.
 
 config SND_VIA82XX
-	tristate "VIA 82C686A/B, 8233 South Bridge"
+	tristate "VIA 82C686A/B, 8233/8235 AC97 Controller"
 	depends on SND
 	select SND_MPU401_UART
 	select SND_AC97_CODEC
 	help
-	  Say 'Y' or 'M' to include support for VIA VT82C686A/B, VT8233 South Bridge.
+	  Say Y here to include support for the integrated AC97 sound
+	  device on motherboards with VIA chipsets.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-via82xx.
 
 config SND_VX222
 	tristate "Digigram VX222"
 	depends on SND
 	select SND_VX_LIB
 	help
-	  Say 'Y' or 'M' to include support for Digigram VX222 soundcards.
+	  Say Y here to include support for Digigram VX222 soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-vx222.
 
 endmenu
 
diff -Nru a/sound/pci/ac97/Makefile b/sound/pci/ac97/Makefile
--- a/sound/pci/ac97/Makefile	2004-12-24 13:37:00 -08:00
+++ b/sound/pci/ac97/Makefile	2004-12-24 13:37:00 -08:00
@@ -3,7 +3,12 @@
 # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o ac97_proc.o ac97_patch.o
+snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o ac97_patch.o
+
+ifneq ($(CONFIG_PROC_FS),)
+snd-ac97-codec-objs += ac97_proc.o
+endif
+
 snd-ak4531-codec-objs := ak4531_codec.o
 
 # Toplevel Module Dependency
diff -Nru a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
--- a/sound/pci/ac97/ac97_codec.c	2004-12-24 13:36:47 -08:00
+++ b/sound/pci/ac97/ac97_codec.c	2004-12-24 13:36:47 -08:00
@@ -118,9 +118,12 @@
 { 0x414c4770, 0xfffffff0, "ALC203",		NULL,		NULL },
 { 0x434d4941, 0xffffffff, "CMI9738",		patch_cm9738,	NULL },
 { 0x434d4961, 0xffffffff, "CMI9739",		patch_cm9739,	NULL },
+{ 0x434d4978, 0xffffffff, "CMI9761",		patch_cm9761,	NULL },
+{ 0x434d4982, 0xffffffff, "CMI9761",		patch_cm9761,	NULL },
+{ 0x434d4983, 0xffffffff, "CMI9761",		patch_cm9761,	NULL },
 { 0x43525900, 0xfffffff8, "CS4297",		NULL,		NULL },
 { 0x43525910, 0xfffffff8, "CS4297A",		patch_cirrus_spdif,	NULL },
-{ 0x43525920, 0xfffffff8, "CS4294/4298",	NULL,		NULL },
+{ 0x43525920, 0xfffffff8, "CS4298",		patch_cirrus_spdif,		NULL },
 { 0x43525928, 0xfffffff8, "CS4294",		NULL,		NULL },
 { 0x43525930, 0xfffffff8, "CS4299",		patch_cirrus_cs4299,	NULL },
 { 0x43525948, 0xfffffff8, "CS4201",		NULL,		NULL },
@@ -749,6 +752,14 @@
 static const snd_kcontrol_new_t snd_ac97_control_eapd =
 AC97_SINGLE("External Amplifier", AC97_POWERDOWN, 15, 1, 1);
 
+/* change the existing EAPD control as inverted */
+static void set_inv_eapd(ac97_t *ac97, snd_kcontrol_t *kctl)
+{
+	kctl->private_value = AC97_SINGLE_VALUE(AC97_POWERDOWN, 15, 1, 0);
+	snd_ac97_update_bits(ac97, AC97_POWERDOWN, (1<<15), (1<<15)); /* EAPD up */
+	ac97->scaps |= AC97_SCAP_INV_EAPD;
+}
+
 static int snd_ac97_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
 {
 	uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
@@ -1559,7 +1570,7 @@
 			return err;
 	}
 
-	snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0x0000);
+	snd_ac97_update_bits(ac97, AC97_GENERAL_PURPOSE, ~AC97_GP_DRSS_MASK, 0x0000);
 
 	/* build 3D controls */
 	if (ac97->build_ops && ac97->build_ops->build_3d) {
@@ -1610,7 +1621,12 @@
 			return err;
 
 	if (snd_ac97_try_bit(ac97, AC97_POWERDOWN, 15)) {
-		if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_eapd, ac97))) < 0)
+		kctl = snd_ac97_cnew(&snd_ac97_control_eapd, ac97);
+		if (! kctl)
+			return -ENOMEM;
+		if (ac97->scaps & AC97_SCAP_INV_EAPD)
+			set_inv_eapd(ac97, kctl);
+		if ((err = snd_ctl_add(card, kctl)) < 0)
 			return err;
 	}
 
@@ -1646,6 +1662,9 @@
 {
 	unsigned int result = 0;
 
+	if ((ac97->ext_id & AC97_EI_DRA) && reg == AC97_PCM_FRONT_DAC_RATE)
+		snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS,
+				     AC97_EA_DRA, 0);
 	/* test a non-standard rate */
 	if (snd_ac97_test_rate(ac97, reg, shadow_reg, 11000))
 		result |= SNDRV_PCM_RATE_CONTINUOUS;
@@ -1664,6 +1683,23 @@
 		result |= SNDRV_PCM_RATE_44100;
 	if (snd_ac97_test_rate(ac97, reg, shadow_reg, 48000))
 		result |= SNDRV_PCM_RATE_48000;
+	if ((ac97->flags & AC97_DOUBLE_RATE) &&
+	    reg == AC97_PCM_FRONT_DAC_RATE) {
+		/* test standard double rates */
+		snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS,
+				     AC97_EA_DRA, AC97_EA_DRA);
+		if (snd_ac97_test_rate(ac97, reg, shadow_reg, 64000 / 2))
+			result |= SNDRV_PCM_RATE_64000;
+		if (snd_ac97_test_rate(ac97, reg, shadow_reg, 88200 / 2))
+			result |= SNDRV_PCM_RATE_88200;
+		if (snd_ac97_test_rate(ac97, reg, shadow_reg, 96000 / 2))
+			result |= SNDRV_PCM_RATE_96000;
+		/* some codecs don't support variable double rates */
+		if (!snd_ac97_test_rate(ac97, reg, shadow_reg, 76100 / 2))
+			result &= ~SNDRV_PCM_RATE_CONTINUOUS;
+		snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS,
+				     AC97_EA_DRA, 0);
+	}
 	*r_result = result;
 }
 
@@ -1726,6 +1762,22 @@
 	sprintf(name + strlen(name), " id %x", id & 0xff);
 }
 
+/**
+ * snd_ac97_get_short_name - retrieve codec name
+ * @ac97: the codec instance
+ *
+ * Returns the short identifying name of the codec.
+ */
+const char *snd_ac97_get_short_name(ac97_t *ac97)
+{
+	const ac97_codec_id_t *pid;
+
+	for (pid = snd_ac97_codec_ids; pid->id; pid++)
+		if (pid->id == (ac97->id & pid->mask))
+			return pid->name;
+	return "unknown codec";
+}
+
 
 /* wait for a while until registers are accessible after RESET
  * return 0 if ok, negative not ready
@@ -1733,9 +1785,10 @@
 static int ac97_reset_wait(ac97_t *ac97, int timeout, int with_modem)
 {
 	unsigned long end_time;
+	unsigned short val;
+
 	end_time = jiffies + timeout;
 	do {
-		unsigned short ext_mid;
 		
 		/* use preliminary reads to settle the communication */
 		snd_ac97_read(ac97, AC97_RESET);
@@ -1743,17 +1796,24 @@
 		snd_ac97_read(ac97, AC97_VENDOR_ID2);
 		/* modem? */
 		if (with_modem) {
-			ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID);
-			if (ext_mid != 0xffff && (ext_mid & 1) != 0)
+			val = snd_ac97_read(ac97, AC97_EXTENDED_MID);
+			if (val != 0xffff && (val & 1) != 0)
+				return 0;
+		}
+		if (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) {
+			/* probably only Xbox issue - all registers are read as zero */
+			val = snd_ac97_read(ac97, AC97_VENDOR_ID1);
+			if (val != 0 && val != 0xffff)
+				return 0;
+		} else {
+			/* because the PCM or MASTER volume registers can be modified,
+			 * the REC_GAIN register is used for tests
+			 */
+			/* test if we can write to the record gain volume register */
+			snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05);
+			if ((snd_ac97_read(ac97, AC97_REC_GAIN) & 0x7fff) == 0x0a05)
 				return 0;
 		}
-		/* because the PCM or MASTER volume registers can be modified,
-		 * the REC_GAIN register is used for tests
-		 */
-		/* test if we can write to the record gain volume register */
-		snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05);
-		if ((snd_ac97_read(ac97, AC97_REC_GAIN) & 0x7fff) == 0x0a05)
-			return 0;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
 	} while (time_after_eq(end_time, jiffies));
@@ -2004,13 +2064,25 @@
 		ac97->addr = (ac97->ext_id & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT;
 	else
 		ac97->addr = (ac97->ext_mid & AC97_MEI_ADDR_MASK) >> AC97_MEI_ADDR_SHIFT;
-	if (ac97->ext_id & 0x0189)	/* L/R, MIC, SDAC, LDAC VRA support */
-		snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, ac97->ext_id & 0x0189);
+	if (ac97->ext_id & 0x0189) {	/* L/R, MIC, SDAC, LDAC VRA support */
+		reg = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
+		reg |= ac97->ext_id & 0x0189;
+		snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, reg);
+	}
+	if ((ac97->ext_id & AC97_EI_DRA) && bus->dra) {
+		/* Intel controllers require double rate data to be put in
+		 * slots 7+8, so let's hope the codec supports it. */
+		snd_ac97_update_bits(ac97, AC97_GENERAL_PURPOSE, AC97_GP_DRSS_MASK, AC97_GP_DRSS_78);
+		if ((snd_ac97_read(ac97, AC97_GENERAL_PURPOSE) & AC97_GP_DRSS_MASK) == AC97_GP_DRSS_78)
+			ac97->flags |= AC97_DOUBLE_RATE;
+	}
 	if (ac97->ext_id & AC97_EI_VRA) {	/* VRA support */
 		snd_ac97_determine_rates(ac97, AC97_PCM_FRONT_DAC_RATE, 0, &ac97->rates[AC97_RATES_FRONT_DAC]);
 		snd_ac97_determine_rates(ac97, AC97_PCM_LR_ADC_RATE, 0, &ac97->rates[AC97_RATES_ADC]);
 	} else {
 		ac97->rates[AC97_RATES_FRONT_DAC] = SNDRV_PCM_RATE_48000;
+		if (ac97->flags & AC97_DOUBLE_RATE)
+			ac97->rates[AC97_RATES_FRONT_DAC] |= SNDRV_PCM_RATE_96000;
 		ac97->rates[AC97_RATES_ADC] = SNDRV_PCM_RATE_48000;
 	}
 	if (ac97->ext_id & AC97_EI_SPDIF) {
@@ -2317,9 +2389,9 @@
 
 static int swap_headphone(ac97_t *ac97, int remove_master)
 {
+	if (ctl_find(ac97, "Headphone Playback Switch", NULL) == NULL)
+		return -ENOENT;
 	if (remove_master) {
-		if (ctl_find(ac97, "Headphone Playback Switch", NULL) == NULL)
-			return 0;
 		snd_ac97_remove_ctl(ac97, "Master Playback", "Switch");
 		snd_ac97_remove_ctl(ac97, "Master Playback", "Volume");
 	} else
@@ -2330,9 +2402,9 @@
 
 static int swap_surround(ac97_t *ac97)
 {
-	/* FIXME: error checks.. */
-	snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Switch");
-	snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Volume");
+	if (snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Switch") ||
+	    snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Volume"))
+		return -ENOENT;
 	return 0;
 }
 
@@ -2363,6 +2435,15 @@
 	return snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_alc_jack_detect, ac97));
 }
 
+static int tune_inv_eapd(ac97_t *ac97)
+{
+	snd_kcontrol_t *kctl = ctl_find(ac97, "External Amplifier", NULL);
+	if (! kctl)
+		return -ENOENT;
+	set_inv_eapd(ac97, kctl);
+	return 0;
+}
+
 static int apply_quirk(ac97_t *ac97, int quirk)
 {
 	switch (quirk) {
@@ -2378,6 +2459,8 @@
 		return tune_ad_sharing(ac97);
 	case AC97_TUNE_ALC_JACK:
 		return tune_alc_jack(ac97);
+	case AC97_TUNE_INV_EAPD:
+		return tune_inv_eapd(ac97);
 	}
 	return -EINVAL;
 }
@@ -2413,6 +2496,8 @@
 			continue;
 		if ((! quirk->mask && quirk->device == ac97->subsystem_device) ||
 		    quirk->device == (quirk->mask & ac97->subsystem_device)) {
+			if (quirk->codec_id && quirk->codec_id != ac97->id)
+				continue;
 			snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device);
 			result = apply_quirk(ac97, quirk->type);
 			if (result < 0)
@@ -2433,11 +2518,13 @@
 EXPORT_SYMBOL(snd_ac97_write_cache);
 EXPORT_SYMBOL(snd_ac97_update);
 EXPORT_SYMBOL(snd_ac97_update_bits);
+EXPORT_SYMBOL(snd_ac97_get_short_name);
 EXPORT_SYMBOL(snd_ac97_bus);
 EXPORT_SYMBOL(snd_ac97_mixer);
 EXPORT_SYMBOL(snd_ac97_pcm_assign);
 EXPORT_SYMBOL(snd_ac97_pcm_open);
 EXPORT_SYMBOL(snd_ac97_pcm_close);
+EXPORT_SYMBOL(snd_ac97_pcm_double_rate_rules);
 EXPORT_SYMBOL(snd_ac97_tune_hardware);
 EXPORT_SYMBOL(snd_ac97_set_rate);
 #ifdef CONFIG_PM
diff -Nru a/sound/pci/ac97/ac97_id.h b/sound/pci/ac97/ac97_id.h
--- a/sound/pci/ac97/ac97_id.h	2004-12-24 13:37:29 -08:00
+++ b/sound/pci/ac97/ac97_id.h	2004-12-24 13:37:29 -08:00
@@ -57,3 +57,6 @@
 #define AC97_ID_VT1616		0x49434551
 #define AC97_ID_CM9738		0x434d4941
 #define AC97_ID_CM9739		0x434d4961
+#define AC97_ID_CM9761_78	0x434d4978
+#define AC97_ID_CM9761_82	0x434d4982
+#define AC97_ID_CM9761_83	0x434d4983
diff -Nru a/sound/pci/ac97/ac97_local.h b/sound/pci/ac97/ac97_local.h
--- a/sound/pci/ac97/ac97_local.h	2004-12-24 13:36:47 -08:00
+++ b/sound/pci/ac97/ac97_local.h	2004-12-24 13:36:47 -08:00
@@ -51,7 +51,14 @@
 void snd_ac97_rename_vol_ctl(ac97_t *ac97, const char *src, const char *dst);
 
 /* ac97_proc.c */
+#ifdef CONFIG_PROC_FS
 void snd_ac97_bus_proc_init(ac97_bus_t * ac97);
 void snd_ac97_bus_proc_done(ac97_bus_t * ac97);
 void snd_ac97_proc_init(ac97_t * ac97);
 void snd_ac97_proc_done(ac97_t * ac97);
+#else
+#define snd_ac97_bus_proc_init(ac97_bus_t) do { } while (0)
+#define snd_ac97_bus_proc_done(ac97_bus_t) do { } while (0)
+#define snd_ac97_proc_init(ac97_t) do { } while (0)
+#define snd_ac97_proc_done(ac97_t) do { } while (0)
+#endif
diff -Nru a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
--- a/sound/pci/ac97/ac97_patch.c	2004-12-24 13:37:19 -08:00
+++ b/sound/pci/ac97/ac97_patch.c	2004-12-24 13:37:19 -08:00
@@ -1779,6 +1779,140 @@
 	return 0;
 }
 
+#define AC97_CM9761_MULTI_CHAN	0x64
+#define AC97_CM9761_SPDIF_CTRL	0x6c
+
+static int snd_ac97_cm9761_linein_rear_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
+	if (ac97->regs[AC97_CM9739_MULTI_CHAN] & 0x0400)
+		ucontrol->value.integer.value[0] = 1;
+	else
+		ucontrol->value.integer.value[0] = 0;
+	return 0;
+}
+
+static int snd_ac97_cm9761_linein_rear_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
+	unsigned short vals[2][2] = {
+		{ 0x0008, 0x0400 }, /* off, on */
+		{ 0x0000, 0x0408 }, /* off, on (9761-82 rev.B) */
+	};
+	return snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x0408,
+				    vals[ac97->spec.dev_flags][!!ucontrol->value.integer.value[0]]);
+}
+
+static int snd_ac97_cm9761_center_mic_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
+	if (ac97->regs[AC97_CM9739_MULTI_CHAN] & 0x1000)
+		ucontrol->value.integer.value[0] = 1;
+	else
+		ucontrol->value.integer.value[0] = 0;
+	if (ac97->spec.dev_flags) /* 9761-82 rev.B */
+		ucontrol->value.integer.value[0] = !ucontrol->value.integer.value[0];
+	return 0;
+}
+
+static int snd_ac97_cm9761_center_mic_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
+	unsigned short vals[2][2] = {
+		{ 0x2000, 0x1880 }, /* off, on */
+		{ 0x1000, 0x2880 }, /* off, on (9761-82 rev.B) */
+	};
+	return snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3880,
+				    vals[ac97->spec.dev_flags][!!ucontrol->value.integer.value[0]]);
+}
+
+static const snd_kcontrol_new_t snd_ac97_cm9761_controls[] = {
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Line-In As Surround",
+		.info = snd_ac97_info_single,
+		.get = snd_ac97_cm9761_linein_rear_get,
+		.put = snd_ac97_cm9761_linein_rear_put,
+		.private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Mic As Center/LFE",
+		.info = snd_ac97_info_single,
+		.get = snd_ac97_cm9761_center_mic_get,
+		.put = snd_ac97_cm9761_center_mic_put,
+		.private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */
+	},
+};
+
+static int patch_cm9761_specific(ac97_t * ac97)
+{
+	return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls));
+}
+
+static struct snd_ac97_build_ops patch_cm9761_ops = {
+	.build_specific	= patch_cm9761_specific,
+	.build_post_spdif = patch_cm9739_post_spdif /* hope it's identical... */
+};
+
+int patch_cm9761(ac97_t *ac97)
+{
+	unsigned short val;
+
+	ac97->spec.dev_flags = 0; /* 1 = model 82 revision B */
+	if (ac97->id == AC97_ID_CM9761_82) {
+		unsigned short tmp;
+		/* check page 1, reg 0x60 */
+		val = snd_ac97_read(ac97, AC97_INT_PAGING);
+		snd_ac97_write_cache(ac97, AC97_INT_PAGING, (val & ~0x0f) | 0x01);
+		tmp = snd_ac97_read(ac97, 0x60);
+		ac97->spec.dev_flags = tmp & 1; /* revision B? */
+		snd_ac97_write_cache(ac97, AC97_INT_PAGING, val);
+	}
+
+	ac97->build_ops = &patch_cm9761_ops;
+
+	/* enable spdif */
+	/* force the SPDIF bit in ext_id - codec doesn't set this bit! */
+        ac97->ext_id |= AC97_EI_SPDIF;
+	/* to be sure: we overwrite the ext status bits */
+	snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0);
+	snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0209);
+	ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
+
+	/* set-up multi channel */
+	/* bit 15: pc master beep off
+	 * bit 14: ??
+	 * bit 13: vref ctl [= cm9739]
+	 * bit 12: center/mic [= cm9739] (reverted on rev B)
+	 * bit 11: ?? (mic/center/lfe) (reverted on rev B)
+	 * bit 10: suddound/line [= cm9739]
+	 * bit  9: mix 2 surround
+	 * bit  8: ?
+	 * bit  7: ?? (mic/center/lfe)
+	 * bit  4: ?? (front)
+	 * bit  3: ?? (line-in/rear share) (revereted with rev B)
+	 * bit  2: ?? (surround)
+	 * bit  1: front mic
+	 * bit  0: mic boost
+	 */
+
+#if 0
+	if (ac97->spec.dev_flags)
+		val = 0x0214;
+	else
+		val = 0x321c;
+	snd_ac97_write_cache(ac97, AC97_CM9761_MULTI_CHAN, val);
+#endif
+
+	/* FIXME: set up GPIO */
+	snd_ac97_write_cache(ac97, 0x70, 0x0100);
+	snd_ac97_write_cache(ac97, 0x72, 0x0020);
+
+	return 0;
+}
+       
+
 /*
  * VIA VT1616 codec
  */
diff -Nru a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h
--- a/sound/pci/ac97/ac97_patch.h	2004-12-24 13:36:17 -08:00
+++ b/sound/pci/ac97/ac97_patch.h	2004-12-24 13:36:17 -08:00
@@ -52,6 +52,7 @@
 int patch_alc850(ac97_t * ac97);
 int patch_cm9738(ac97_t * ac97);
 int patch_cm9739(ac97_t * ac97);
+int patch_cm9761(ac97_t * ac97);
 int patch_vt1616(ac97_t * ac97);
 int patch_it2646(ac97_t * ac97);
 int mpatch_si3036(ac97_t * ac97);
diff -Nru a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c
--- a/sound/pci/ac97/ac97_pcm.c	2004-12-24 13:36:18 -08:00
+++ b/sound/pci/ac97/ac97_pcm.c	2004-12-24 13:36:18 -08:00
@@ -93,54 +93,52 @@
   },
 },
 {
-  /* FIXME: double rates */
+  /* double rates */
   {
-  	/* 3&4 front, 7&8 rear, 6&9 center/lfe */
+  	/* 3&4 front, 7&8 front (t+1) */
 	AC97_PCM_FRONT_DAC_RATE,	/* slot 3 */
 	AC97_PCM_FRONT_DAC_RATE,	/* slot 4 */
 	0xff,				/* slot 5 */
-	AC97_PCM_LFE_DAC_RATE,		/* slot 6 */
-	AC97_PCM_SURR_DAC_RATE,		/* slot 7 */
-	AC97_PCM_SURR_DAC_RATE,		/* slot 8 */
-	AC97_PCM_LFE_DAC_RATE,		/* slot 9 */
+	0xff,				/* slot 6 */
+	AC97_PCM_FRONT_DAC_RATE,	/* slot 7 */
+	AC97_PCM_FRONT_DAC_RATE,	/* slot 8 */
+	0xff,				/* slot 9 */
 	0xff,				/* slot 10 */
 	0xff,				/* slot 11 */
   },
   {
-  	/* 7&8 front, 6&9 rear, 10&11 center/lfe */
+	/* not specified in the specification */
 	0xff,				/* slot 3 */
 	0xff,				/* slot 4 */
 	0xff,				/* slot 5 */
-	AC97_PCM_SURR_DAC_RATE,		/* slot 6 */
-	AC97_PCM_FRONT_DAC_RATE,	/* slot 7 */
-	AC97_PCM_FRONT_DAC_RATE,	/* slot 8 */
-	AC97_PCM_SURR_DAC_RATE,		/* slot 9 */
-	AC97_PCM_LFE_DAC_RATE,		/* slot 10 */
-	AC97_PCM_LFE_DAC_RATE,		/* slot 11 */
+	0xff,				/* slot 6 */
+	0xff,				/* slot 7 */
+	0xff,				/* slot 8 */
+	0xff,				/* slot 9 */
+	0xff,				/* slot 10 */
+	0xff,				/* slot 11 */
   },
   {
-  	/* 6&9 front, 10&11 rear, 3&4 center/lfe */
-	AC97_PCM_LFE_DAC_RATE,		/* slot 3 */
-	AC97_PCM_LFE_DAC_RATE,		/* slot 4 */
+	0xff,				/* slot 3 */
+	0xff,				/* slot 4 */
 	0xff,				/* slot 5 */
-	AC97_PCM_FRONT_DAC_RATE,	/* slot 6 */
+	0xff,				/* slot 6 */
 	0xff,				/* slot 7 */
 	0xff,				/* slot 8 */
-	AC97_PCM_FRONT_DAC_RATE,	/* slot 9 */
-	AC97_PCM_SURR_DAC_RATE,		/* slot 10 */
-	AC97_PCM_SURR_DAC_RATE,		/* slot 11 */
+	0xff,				/* slot 9 */
+	0xff,				/* slot 10 */
+	0xff,				/* slot 11 */
   },
   {
-  	/* 10&11 front, 3&4 rear, 7&8 center/lfe */
-	AC97_PCM_SURR_DAC_RATE,		/* slot 3 */
-	AC97_PCM_SURR_DAC_RATE,		/* slot 4 */
+	0xff,				/* slot 3 */
+	0xff,				/* slot 4 */
 	0xff,				/* slot 5 */
 	0xff,				/* slot 6 */
-	AC97_PCM_LFE_DAC_RATE,		/* slot 7 */
-	AC97_PCM_LFE_DAC_RATE,		/* slot 8 */
+	0xff,				/* slot 7 */
+	0xff,				/* slot 8 */
 	0xff,				/* slot 9 */
-	AC97_PCM_FRONT_DAC_RATE,	/* slot 10 */
-	AC97_PCM_FRONT_DAC_RATE,	/* slot 11 */
+	0xff,				/* slot 10 */
+	0xff,				/* slot 11 */
   }
 }};
 
@@ -180,6 +178,7 @@
 	if (! (ac97->ext_id & AC97_EI_SPDIF))
 		return -ENODEV;
 
+	/* TODO: double rate support */
 	if (ac97->flags & AC97_CS_SPDIF) {
 		switch (rate) {
 		case 48000: bits = 0; break;
@@ -257,10 +256,19 @@
  *
  * Returns zero if successful, or a negative error code on failure.
  */
-int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned short rate)
+int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned int rate)
 {
+	int dbl;
 	unsigned int tmp;
 	
+	dbl = rate > 48000;
+	if (dbl) {
+		if (!(ac97->flags & AC97_DOUBLE_RATE))
+			return -EINVAL;
+		if (reg != AC97_PCM_FRONT_DAC_RATE)
+			return -EINVAL;
+	}
+
 	switch (reg) {
 	case AC97_PCM_MIC_ADC_RATE:
 		if ((ac97->regs[AC97_EXTENDED_STATUS] & AC97_EA_VRM) == 0)	/* MIC VRA */
@@ -270,7 +278,7 @@
 	case AC97_PCM_FRONT_DAC_RATE:
 	case AC97_PCM_LR_ADC_RATE:
 		if ((ac97->regs[AC97_EXTENDED_STATUS] & AC97_EA_VRA) == 0)	/* VRA */
-			if (rate != 48000)
+			if (rate != 48000 && rate != 96000)
 				return -EINVAL;
 		break;
 	case AC97_PCM_SURR_DAC_RATE:
@@ -287,9 +295,14 @@
 	default:
 		return -EINVAL;
 	}
-	tmp = ((unsigned int)rate * ac97->bus->clock) / 48000;
+	if (dbl)
+		rate /= 2;
+	tmp = (rate * ac97->bus->clock) / 48000;
 	if (tmp > 65535)
 		return -EINVAL;
+	if ((ac97->ext_id & AC97_EI_DRA) && reg == AC97_PCM_FRONT_DAC_RATE)
+		snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS,
+				     AC97_EA_DRA, dbl ? AC97_EA_DRA : 0);
 	snd_ac97_update(ac97, reg, tmp & 0xffff);
 	snd_ac97_read(ac97, reg);
 	return 0;
@@ -304,13 +317,13 @@
 		if (ac97_is_rev22(ac97)) {
 			/* Note: it's simply emulation of AMAP behaviour */
 			u16 es;
-			es = ac97->regs[AC97_EXTENDED_STATUS] &= ~AC97_EI_DACS_SLOT_MASK;
+			es = ac97->regs[AC97_EXTENDED_ID] &= ~AC97_EI_DACS_SLOT_MASK;
 			switch (ac97->addr) {
 			case 1:
 			case 2: es |= (1<<AC97_EI_DACS_SLOT_SHIFT); break;
 			case 3: es |= (2<<AC97_EI_DACS_SLOT_SHIFT); break;
 			}
-			snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, es);
+			snd_ac97_write_cache(ac97, AC97_EXTENDED_ID, es);
 		}
 		switch (ac97->addr) {
 		case 0:
@@ -401,6 +414,9 @@
 		}
 		rates &= pcm->r[dbl].codec[cidx]->rates[idx];
 	}
+	if (!dbl)
+		rates &= ~(SNDRV_PCM_RATE_64000 | SNDRV_PCM_RATE_88200 |
+			   SNDRV_PCM_RATE_96000);
 	return rates;
 }
 
@@ -447,7 +463,6 @@
 			}
 		}
 	}
-	/* FIXME: add double rate allocation */
 	/* first step - exclusive devices */
 	for (i = 0; i < pcms_count; i++) {
 		pcm = &pcms[i];
@@ -498,6 +513,26 @@
 			rpcm->r[0].slots |= tmp;
 			rpcm->rates &= rates;
 		}
+		/* for double rate, we check the first codec only */
+		if (pcm->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+		    bus->codec[0] && (bus->codec[0]->flags & AC97_DOUBLE_RATE) &&
+		    rate_table[pcm->stream][0] == 0) {
+			tmp = (1<<AC97_SLOT_PCM_LEFT) | (1<<AC97_SLOT_PCM_RIGHT) |
+			      (1<<AC97_SLOT_PCM_LEFT_0) | (1<<AC97_SLOT_PCM_RIGHT_0);
+			if ((tmp & pcm->r[1].slots) == tmp) {
+				rpcm->r[1].slots = tmp;
+				rpcm->r[1].rslots[0] = tmp;
+				rpcm->r[1].rate_table[0] = 0;
+				rpcm->r[1].codec[0] = bus->codec[0];
+				if (pcm->exclusive)
+					avail_slots[pcm->stream][0] &= ~tmp;
+				if (bus->no_vra)
+					rates = SNDRV_PCM_RATE_96000;
+				else
+					rates = get_rates(rpcm, 0, tmp, 1);
+				rpcm->rates |= rates;
+			}
+		}
 		if (rpcm->rates == ~0)
 			rpcm->rates = 0; /* not used */
 	}
@@ -519,13 +554,12 @@
 		      enum ac97_pcm_cfg cfg, unsigned short slots)
 {
 	ac97_bus_t *bus;
-	int i, cidx, r = 0, ok_flag;
+	int i, cidx, r, ok_flag;
 	unsigned int reg_ok = 0;
 	unsigned char reg;
 	int err = 0;
 
-	if (rate > 48000)	/* FIXME: add support for double rate */
-		return -EINVAL;
+	r = rate > 48000;
 	bus = pcm->bus;
 	if (cfg == AC97_PCM_CFG_SPDIF) {
 		int err;
@@ -613,4 +647,56 @@
 	pcm->aslots = 0;
 	spin_unlock_irq(&pcm->bus->bus_lock);
 	return 0;
+}
+
+static int double_rate_hw_constraint_rate(snd_pcm_hw_params_t *params,
+					  snd_pcm_hw_rule_t *rule)
+{
+	snd_interval_t *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+	if (channels->min > 2) {
+		static const snd_interval_t single_rates = {
+			.min = 1,
+			.max = 48000,
+		};
+		snd_interval_t *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+		return snd_interval_refine(rate, &single_rates);
+	}
+	return 0;
+}
+
+static int double_rate_hw_constraint_channels(snd_pcm_hw_params_t *params,
+					      snd_pcm_hw_rule_t *rule)
+{
+	snd_interval_t *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+	if (rate->min > 48000) {
+		static const snd_interval_t double_rate_channels = {
+			.min = 2,
+			.max = 2,
+		};
+		snd_interval_t *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+		return snd_interval_refine(channels, &double_rate_channels);
+	}
+	return 0;
+}
+
+/**
+ * snd_ac97_pcm_double_rate_rules - set double rate constraints
+ * @runtime: the runtime of the ac97 front playback pcm
+ *
+ * Installs the hardware constraint rules to prevent using double rates and
+ * more than two channels at the same time.
+ */
+int snd_ac97_pcm_double_rate_rules(snd_pcm_runtime_t *runtime)
+{
+	int err;
+
+	err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+				  double_rate_hw_constraint_rate, NULL,
+				  SNDRV_PCM_HW_PARAM_CHANNELS, -1);
+	if (err < 0)
+		return err;
+	err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
+				  double_rate_hw_constraint_channels, NULL,
+				  SNDRV_PCM_HW_PARAM_RATE, -1);
+	return err;
 }
diff -Nru a/sound/pci/ac97/ac97_proc.c b/sound/pci/ac97/ac97_proc.c
--- a/sound/pci/ac97/ac97_proc.c	2004-12-24 13:37:32 -08:00
+++ b/sound/pci/ac97/ac97_proc.c	2004-12-24 13:37:32 -08:00
@@ -72,9 +72,10 @@
 {
 	char name[64];
 	unsigned short val, tmp, ext, mext;
-	static const char *spdif_slots[4] = { " SPDIF=3/4", " SPDIF=7/8", " SPDIF=6/9", " SPDIF=res" };
+	static const char *spdif_slots[4] = { " SPDIF=3/4", " SPDIF=7/8", " SPDIF=6/9", " SPDIF=10/11" };
 	static const char *spdif_rates[4] = { " Rate=44.1kHz", " Rate=res", " Rate=48kHz", " Rate=32kHz" };
 	static const char *spdif_rates_cs4205[4] = { " Rate=48kHz", " Rate=44.1kHz", " Rate=res", " Rate=res" };
+	static const char *double_rate_slots[4] = { "10/11", "7/8", "reserved", "reserved" };
 
 	snd_ac97_get_name(NULL, ac97->id, name, 0);
 	snd_iprintf(buffer, "%d-%d/%d: %s\n\n", ac97->addr, ac97->num, subidx, name);
@@ -137,6 +138,9 @@
 		    val & 0x0200 ? "Mic" : "MIX",
 		    val & 0x0100 ? "Mic2" : "Mic1",
 		    val & 0x0080 ? "on" : "off");
+	if (ac97->ext_id & AC97_EI_DRA)
+		snd_iprintf(buffer, "Double rate slots: %s\n",
+			    double_rate_slots[(val >> 10) & 3]);
 
 	ext = snd_ac97_read(ac97, AC97_EXTENDED_ID);
 	if (ext == 0)
diff -Nru a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
--- a/sound/pci/ali5451/ali5451.c	2004-12-24 13:37:19 -08:00
+++ b/sound/pci/ali5451/ali5451.c	2004-12-24 13:37:19 -08:00
@@ -50,17 +50,16 @@
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32};
 static int spdif[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ALI M5451 PCI Audio.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ALI M5451 PCI Audio.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable ALI 5451 PCI Audio.");
-module_param_array(pcm_channels, int, boot_devs, 0444);
+module_param_array(pcm_channels, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_channels, "PCM Channels");
-module_param_array(spdif, bool, boot_devs, 0444);
+module_param_array(spdif, bool, NULL, 0444);
 MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
 
 /*
@@ -1933,6 +1932,7 @@
 	outl(0xffffffff, ALI_REG(chip, ALI_STOP));
 
 	spin_unlock_irq(&chip->reg_lock);
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -1987,6 +1987,7 @@
 	}
 	if (codec->port)
 		pci_release_regions(codec->pci);
+	pci_disable_device(codec->pci);
 #ifdef CONFIG_PM
 	if (codec->image)
 		kfree(codec->image);
@@ -2094,11 +2095,14 @@
 	if (pci_set_dma_mask(pci, 0x7fffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x7fffffff) < 0) {
 		snd_printk("architecture does not support 31bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 
-	if ((codec = kcalloc(1, sizeof(*codec), GFP_KERNEL)) == NULL)
+	if ((codec = kcalloc(1, sizeof(*codec), GFP_KERNEL)) == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	spin_lock_init(&codec->reg_lock);
 	spin_lock_init(&codec->voice_alloc);
diff -Nru a/sound/pci/als4000.c b/sound/pci/als4000.c
--- a/sound/pci/als4000.c	2004-12-24 13:37:19 -08:00
+++ b/sound/pci/als4000.c	2004-12-24 13:37:19 -08:00
@@ -88,16 +88,15 @@
 #ifdef SUPPORT_JOYSTICK
 static int joystick_port[SNDRV_CARDS];
 #endif
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ALS4000 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ALS4000 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable ALS4000 soundcard.");
 #ifdef SUPPORT_JOYSTICK
-module_param_array(joystick_port, int, boot_devs, 0444);
+module_param_array(joystick_port, int, NULL, 0444);
 MODULE_PARM_DESC(joystick_port, "Joystick port address for ALS4000 soundcard. (0 = disabled)");
 #endif
 
@@ -583,6 +582,7 @@
 	}
 #endif
 	pci_release_regions(acard->pci);
+	pci_disable_device(acard->pci);
 }
 
 static int __devinit snd_card_als4000_probe(struct pci_dev *pci,
@@ -613,11 +613,14 @@
 	if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
 		snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 
-	if ((err = pci_request_regions(pci, "ALS4000")) < 0)
+	if ((err = pci_request_regions(pci, "ALS4000")) < 0) {
+		pci_disable_device(pci);
 		return err;
+	}
 	gcr = pci_resource_start(pci, 0);
 
 	pci_read_config_word(pci, PCI_COMMAND, &word);
@@ -628,6 +631,7 @@
 			    sizeof( snd_card_als4000_t ) );
 	if (card == NULL) {
 		pci_release_regions(pci);
+		pci_disable_device(pci);
 		return -ENOMEM;
 	}
 
diff -Nru a/sound/pci/atiixp.c b/sound/pci/atiixp.c
--- a/sound/pci/atiixp.c	2004-12-24 13:36:56 -08:00
+++ b/sound/pci/atiixp.c	2004-12-24 13:36:56 -08:00
@@ -44,17 +44,16 @@
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000};
 static int spdif_aclink[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ATI IXP controller.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ATI IXP controller.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable audio part of ATI IXP controller.");
-module_param_array(ac97_clock, int, boot_devs, 0444);
+module_param_array(ac97_clock, int, NULL, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
-module_param_array(spdif_aclink, bool, boot_devs, 0444);
+module_param_array(spdif_aclink, bool, NULL, 0444);
 MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
 
 
@@ -1421,6 +1420,7 @@
 
 	pci_enable_device(chip->pci);
 	pci_set_power_state(chip->pci, 0);
+	pci_set_master(chip->pci);
 
 	snd_atiixp_aclink_reset(chip);
 	snd_atiixp_chip_start(chip);
@@ -1474,6 +1474,7 @@
 	if (chip->remap_addr)
 		iounmap(chip->remap_addr);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -1501,8 +1502,10 @@
 		return err;
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	spin_lock_init(&chip->reg_lock);
 	spin_lock_init(&chip->ac97_lock);
@@ -1511,12 +1514,13 @@
 	chip->pci = pci;
 	chip->irq = -1;
 	if ((err = pci_request_regions(pci, "ATI IXP AC97")) < 0) {
+		pci_disable_device(pci);
 		kfree(chip);
 		return err;
 	}
 	chip->addr = pci_resource_start(pci, 0);
 	chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci, 0));
-	if (chip->remap_addr == 0) {
+	if (chip->remap_addr == NULL) {
 		snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
 		snd_atiixp_free(chip);
 		return -EIO;
@@ -1585,8 +1589,10 @@
 
 	snd_atiixp_chip_start(chip);
 
-	sprintf(card->longname, "%s rev %x at 0x%lx, irq %i",
-		card->shortname, revision, chip->addr, chip->irq);
+	snprintf(card->longname, sizeof(card->longname),
+		 "%s rev %x with %s at %#lx, irq %i", card->shortname, revision,
+		 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
+		 chip->addr, chip->irq);
 
 	snd_card_set_pm_callback(card, snd_atiixp_suspend, snd_atiixp_resume, chip);
 
diff -Nru a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
--- a/sound/pci/atiixp_modem.c	2004-12-24 13:37:29 -08:00
+++ b/sound/pci/atiixp_modem.c	2004-12-24 13:37:29 -08:00
@@ -43,15 +43,14 @@
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ATI IXP controller.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ATI IXP controller.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable audio part of ATI IXP controller.");
-module_param_array(ac97_clock, int, boot_devs, 0444);
+module_param_array(ac97_clock, int, NULL, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
 
 
@@ -1143,6 +1142,7 @@
 
 	pci_enable_device(chip->pci);
 	pci_set_power_state(chip->pci, 0);
+	pci_set_master(chip->pci);
 
 	snd_atiixp_aclink_reset(chip);
 	snd_atiixp_chip_start(chip);
@@ -1196,6 +1196,7 @@
 	if (chip->remap_addr)
 		iounmap(chip->remap_addr);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -1223,8 +1224,10 @@
 		return err;
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	spin_lock_init(&chip->reg_lock);
 	spin_lock_init(&chip->ac97_lock);
@@ -1234,11 +1237,12 @@
 	chip->irq = -1;
 	if ((err = pci_request_regions(pci, "ATI IXP MC97")) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 	chip->addr = pci_resource_start(pci, 0);
 	chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci, 0));
-	if (chip->remap_addr == 0) {
+	if (chip->remap_addr == NULL) {
 		snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
 		snd_atiixp_free(chip);
 		return -EIO;
diff -Nru a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
--- a/sound/pci/au88x0/au88x0.c	2004-12-24 13:36:55 -08:00
+++ b/sound/pci/au88x0/au88x0.c	2004-12-24 13:36:55 -08:00
@@ -27,15 +27,14 @@
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
 static int pcifix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 255 };
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
-module_param_array(pcifix, int, boot_devs, 0444);
+module_param_array(pcifix, int, NULL, 0444);
 MODULE_PARM_DESC(pcifix, "Enable VIA-workaround for " CARD_NAME " soundcard.");
 
 MODULE_DESCRIPTION("Aureal vortex");
@@ -216,7 +215,7 @@
 	vortex_core_shutdown(chip);
       core_out:
 	//FIXME: the type of chip->mmio might need to be changed??
-	iounmap((void *)chip->mmio);
+	iounmap(chip->mmio);
       ioremap_out:
 	pci_release_regions(chip->pci_dev);
       regions_out:
@@ -316,7 +315,7 @@
 #endif
 
 	// (5)
-	strcpy(card->driver, "Aureal Vortex");
+	strcpy(card->driver, CARD_NAME_SHORT);
 	strcpy(card->shortname, CARD_NAME_SHORT);
 	sprintf(card->longname, "%s at 0x%lx irq %i",
 		card->shortname, chip->io, chip->irq);
diff -Nru a/sound/pci/au88x0/au88x0.h b/sound/pci/au88x0/au88x0.h
--- a/sound/pci/au88x0/au88x0.h	2004-12-24 13:36:59 -08:00
+++ b/sound/pci/au88x0/au88x0.h	2004-12-24 13:36:59 -08:00
@@ -169,7 +169,7 @@
 
 	/* PCI hardware resources */
 	unsigned long io;
-	unsigned long *mmio;
+	unsigned long __iomem *mmio;
 	unsigned int irq;
 	spinlock_t lock;
 
diff -Nru a/sound/pci/au88x0/au88x0_eq.c b/sound/pci/au88x0/au88x0_eq.c
--- a/sound/pci/au88x0/au88x0_eq.c	2004-12-24 13:37:19 -08:00
+++ b/sound/pci/au88x0/au88x0_eq.c	2004-12-24 13:37:19 -08:00
@@ -52,37 +52,33 @@
 	hwwrite(vortex->mmio, 0x2b3c8, level);
 }
 
+static inline short sign_invert(short a)
+{
+	/* -(-32768) -> -32768 so we do -(-32768) -> 32767 to make the result positive */
+	if (a == -32768)
+		return 32767;
+	else
+		return -a;
+}
+
 static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 coefs[])
 {
 	eqhw_t *eqhw = &(vortex->eq.this04);
-	int eax, i = 0, n /*esp2c */;
+	int i = 0, n /*esp2c */;
 
 	for (n = 0; n < eqhw->this04; n++) {
 		hwwrite(vortex->mmio, 0x2b000 + n * 0x30, coefs[i + 0]);
 		hwwrite(vortex->mmio, 0x2b004 + n * 0x30, coefs[i + 1]);
 
 		if (eqhw->this08 == 0) {
-			hwwrite(vortex->mmio, 0x2b008 + n * 0x30, coefs[i + 2]);
-			hwwrite(vortex->mmio, 0x2b00c + n * 0x30, coefs[i + 3]);
-			eax = coefs[i + 4];	//esp24;
+			hwwrite(vortex->mmio, 0x2b008 + n * 0x30, coefs[i + 2] & 0xffff);
+			hwwrite(vortex->mmio, 0x2b00c + n * 0x30, coefs[i + 3] & 0xffff);
+			hwwrite(vortex->mmio, 0x2b010 + n * 0x30, coefs[i + 4] & 0xffff);
 		} else {
-			if (coefs[2 + i] == 0x8000)
-				eax = 0x7fff;
-			else
-				eax = ~coefs[2 + i];
-			hwwrite(vortex->mmio, 0x2b008 + n * 0x30, eax & 0xffff);
-			if (coefs[3 + i] == 0x8000)
-				eax = 0x7fff;
-			else
-				eax = ~coefs[3 + i];
-			hwwrite(vortex->mmio, 0x2b00c + n * 0x30, eax & 0xffff);
-			if (coefs[4 + i] == 0x8000)
-				eax = 0x7fff;
-			else
-				eax = ~coefs[4 + i];
+			hwwrite(vortex->mmio, 0x2b008 + n * 0x30, sign_invert(coefs[2 + i]) & 0xffff);
+			hwwrite(vortex->mmio, 0x2b00c + n * 0x30, sign_invert(coefs[3 + i]) & 0xffff);
+		        hwwrite(vortex->mmio, 0x2b010 + n * 0x30, sign_invert(coefs[4 + i]) & 0xffff);
 		}
-		hwwrite(vortex->mmio, 0x2b010 + n * 0x30, eax);
-
 		i += 5;
 	}
 }
@@ -90,33 +86,21 @@
 static void vortex_EqHw_SetRightCoefs(vortex_t * vortex, u16 coefs[])
 {
 	eqhw_t *eqhw = &(vortex->eq.this04);
-	int i = 0, n /*esp2c */, eax;
+	int i = 0, n /*esp2c */;
 
 	for (n = 0; n < eqhw->this04; n++) {
 		hwwrite(vortex->mmio, 0x2b1e0 + n * 0x30, coefs[0 + i]);
 		hwwrite(vortex->mmio, 0x2b1e4 + n * 0x30, coefs[1 + i]);
 
 		if (eqhw->this08 == 0) {
-			hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, coefs[2 + i]);
-			hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, coefs[3 + i]);
-			eax = coefs[4 + i];	//*esp24;
+			hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, coefs[2 + i] & 0xffff);
+			hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, coefs[3 + i] & 0xffff);
+			hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, coefs[4 + i] & 0xffff);
 		} else {
-			if (coefs[2 + i] == 0x8000)
-				eax = 0x7fff;
-			else
-				eax = ~(coefs[2 + i]);
-			hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, eax & 0xffff);
-			if (coefs[3 + i] == 0x8000)
-				eax = 0x7fff;
-			else
-				eax = ~coefs[3 + i];
-			hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, eax & 0xffff);
-			if (coefs[4 + i] == 0x8000)
-				eax = 0x7fff;
-			else
-				eax = ~coefs[4 + i];
+			hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, sign_invert(coefs[2 + i]) & 0xffff);
+			hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, sign_invert(coefs[3 + i]) & 0xffff);
+			hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, sign_invert(coefs[4 + i]) & 0xffff);
 		}
-		hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, eax);
 		i += 5;
 	}
 
@@ -188,22 +172,12 @@
 static void vortex_EqHw_SetBypassGain(vortex_t * vortex, u16 a, u16 b)
 {
 	eqhw_t *eqhw = &(vortex->eq.this04);
-	int eax;
-
 	if (eqhw->this08 == 0) {
 		hwwrite(vortex->mmio, 0x2b3d4, a);
 		hwwrite(vortex->mmio, 0x2b3ec, b);
 	} else {
-		if (a == 0x8000)
-			eax = 0x7fff;
-		else
-			eax = ~a;
-		hwwrite(vortex->mmio, 0x2b3d4, eax & 0xffff);
-		if (b == 0x8000)
-			eax = 0x7fff;
-		else
-			eax = ~b;
-		hwwrite(vortex->mmio, 0x2b3ec, eax & 0xffff);
+		hwwrite(vortex->mmio, 0x2b3d4, sign_invert(a) & 0xffff);
+		hwwrite(vortex->mmio, 0x2b3ec, sign_invert(b) & 0xffff);
 	}
 }
 
diff -Nru a/sound/pci/azt3328.c b/sound/pci/azt3328.c
--- a/sound/pci/azt3328.c	2004-12-24 13:37:00 -08:00
+++ b/sound/pci/azt3328.c	2004-12-24 13:37:00 -08:00
@@ -165,16 +165,15 @@
 #ifdef SUPPORT_JOYSTICK
 static int joystick[SNDRV_CARDS];
 #endif
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for AZF3328 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable AZF3328 soundcard.");
 #ifdef SUPPORT_JOYSTICK
-module_param_array(joystick, bool, boot_devs, 0444);
+module_param_array(joystick, bool, NULL, 0444);
 MODULE_PARM_DESC(joystick, "Enable joystick for AZF3328 soundcard.");
 #endif
 
@@ -1269,6 +1268,7 @@
         if (chip->irq >= 0)
 		free_irq(chip->irq, (void *)chip);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 
         kfree(chip);
         return 0;
@@ -1318,8 +1318,10 @@
 		return err;
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&chip->reg_lock);
 	chip->card = card;
 	chip->pci = pci;
@@ -1329,11 +1331,13 @@
 	if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
 		snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 
 	if ((err = pci_request_regions(pci, "Aztech AZF3328")) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 
diff -Nru a/sound/pci/bt87x.c b/sound/pci/bt87x.c
--- a/sound/pci/bt87x.c	2004-12-24 13:36:56 -08:00
+++ b/sound/pci/bt87x.c	2004-12-24 13:36:56 -08:00
@@ -27,8 +27,8 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/moduleparam.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -45,15 +45,14 @@
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int digital_rate[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* digital input rate */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Bt87x soundcard");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Bt87x soundcard");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Bt87x soundcard");
-module_param_array(digital_rate, int, boot_devs, 0444);
+module_param_array(digital_rate, int, NULL, 0444);
 MODULE_PARM_DESC(digital_rate, "Digital input rate for Bt87x soundcard");
 
 
@@ -140,6 +139,14 @@
 #define RISC_SYNC_FM1	0x6
 #define RISC_SYNC_VRO	0xc
 
+#define ANALOG_CLOCK 1792000
+#ifdef CONFIG_SND_BT87X_OVERCLOCK
+#define CLOCK_DIV_MIN 1
+#else
+#define CLOCK_DIV_MIN 4
+#endif
+#define CLOCK_DIV_MAX 15
+
 #define ERROR_INTERRUPTS (INT_FBUS | INT_FTRGT | INT_PPERR | \
 			  INT_RIPERR | INT_PABORT | INT_OCERR)
 #define MY_INTERRUPTS (INT_RISCI | ERROR_INTERRUPTS)
@@ -265,7 +272,7 @@
 				   status, pci_status);
 		}
 	}
-	if (status & INT_RISCI) {
+	if ((status & INT_RISCI) && (chip->reg_control & CTL_ACAP_EN)) {
 		int current_block, irq_block;
 
 		/* assume that exactly one line has been recorded */
@@ -304,8 +311,8 @@
 		SNDRV_PCM_INFO_MMAP_VALID,
 	.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8,
 	.rates = SNDRV_PCM_RATE_KNOT,
-	.rate_min = 119466,
-	.rate_max = 448000,
+	.rate_min = ANALOG_CLOCK / CLOCK_DIV_MAX,
+	.rate_max = ANALOG_CLOCK / CLOCK_DIV_MIN,
 	.channels_min = 1,
 	.channels_max = 1,
 	.buffer_bytes_max = 255 * 4092,
@@ -347,9 +354,9 @@
 static int snd_bt87x_set_analog_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime)
 {
 	static ratnum_t analog_clock = {
-		.num = 1792000,
-		.den_min = 4,
-		.den_max = 15,
+		.num = ANALOG_CLOCK,
+		.den_min = CLOCK_DIV_MIN,
+		.den_max = CLOCK_DIV_MAX,
 		.den_step = 1
 	};
 	static snd_pcm_hw_constraint_ratnums_t constraint_rates = {
@@ -434,7 +441,7 @@
 
 	spin_lock_irq(&chip->reg_lock);
 	chip->reg_control &= ~(CTL_DA_SDR_MASK | CTL_DA_SBR);
-	decimation = (1792000 + runtime->rate / 4) / runtime->rate;
+	decimation = (ANALOG_CLOCK + runtime->rate / 4) / runtime->rate;
 	chip->reg_control |= decimation << CTL_DA_SDR_SHIFT;
 	if (runtime->format == SNDRV_PCM_FORMAT_S8)
 		chip->reg_control |= CTL_DA_SBR;
@@ -641,6 +648,7 @@
 	if (chip->irq >= 0)
 		free_irq(chip->irq, chip);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -686,8 +694,10 @@
 		return err;
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (!chip)
+	if (!chip) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	chip->card = card;
 	chip->pci = pci;
 	chip->irq = -1;
@@ -695,6 +705,7 @@
 
 	if ((err = pci_request_regions(pci, "Bt87x audio")) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 	chip->mmio = ioremap_nocache(pci_resource_start(pci, 0),
diff -Nru a/sound/pci/cmipci.c b/sound/pci/cmipci.c
--- a/sound/pci/cmipci.c	2004-12-24 13:37:01 -08:00
+++ b/sound/pci/cmipci.c	2004-12-24 13:37:01 -08:00
@@ -61,22 +61,21 @@
 #ifdef SUPPORT_JOYSTICK
 static int joystick_port[SNDRV_CARDS];
 #endif
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for C-Media PCI soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for C-Media PCI soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable C-Media PCI soundcard.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM port.");
-module_param_array(soft_ac3, bool, boot_devs, 0444);
+module_param_array(soft_ac3, bool, NULL, 0444);
 MODULE_PARM_DESC(soft_ac3, "Sofware-conversion of raw SPDIF packets (model 033 only).");
 #ifdef SUPPORT_JOYSTICK
-module_param_array(joystick_port, int, boot_devs, 0444);
+module_param_array(joystick_port, int, NULL, 0444);
 MODULE_PARM_DESC(joystick_port, "Joystick port address.");
 #endif
 
@@ -2551,6 +2550,7 @@
 	}
 #endif
 	pci_release_regions(cm->pci);
+	pci_disable_device(cm->pci);
 	kfree(cm);
 	return 0;
 }
@@ -2573,6 +2573,10 @@
 	long iomidi = mpu_port[dev];
 	long iosynth = fm_port[dev];
 	int pcm_index, pcm_spdif_index;
+	static struct pci_device_id intel_82437vx[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX) },
+		{ },
+	};
 
 	*rcmipci = NULL;
 
@@ -2580,8 +2584,10 @@
 		return err;
 
 	cm = kcalloc(1, sizeof(*cm), GFP_KERNEL);
-	if (cm == NULL)
+	if (cm == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	spin_lock_init(&cm->reg_lock);
 	init_MUTEX(&cm->open_mutex);
@@ -2595,6 +2601,7 @@
 
 	if ((err = pci_request_regions(pci, card->driver)) < 0) {
 		kfree(cm);
+		pci_disable_device(pci);
 		return err;
 	}
 	cm->iobase = pci_resource_start(pci, 0);
@@ -2648,8 +2655,7 @@
 	switch (pci->device) {
 	case PCI_DEVICE_ID_CMEDIA_CM8738:
 	case PCI_DEVICE_ID_CMEDIA_CM8738B:
-		/* PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX */
-		if (! pci_find_device(0x8086, 0x7030, NULL))
+		if (!pci_dev_present(intel_82437vx)) 
 			snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_TXVX);
 		break;
 	default:
diff -Nru a/sound/pci/cs4281.c b/sound/pci/cs4281.c
--- a/sound/pci/cs4281.c	2004-12-24 13:37:29 -08:00
+++ b/sound/pci/cs4281.c	2004-12-24 13:37:29 -08:00
@@ -46,15 +46,14 @@
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable switches */
 static int dual_codec[SNDRV_CARDS];	/* dual codec */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for CS4281 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for CS4281 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable CS4281 soundcard.");
-module_param_array(dual_codec, bool, boot_devs, 0444);
+module_param_array(dual_codec, bool, NULL, 0444);
 MODULE_PARM_DESC(dual_codec, "Secondary Codec ID (0 = disabled).");
 
 /*
@@ -464,8 +463,8 @@
 struct snd_cs4281 {
 	int irq;
 
-	unsigned long ba0;		/* virtual (accessible) address */
-	unsigned long ba1;		/* virtual (accessible) address */
+	void __iomem *ba0;		/* virtual (accessible) address */
+	void __iomem *ba1;		/* virtual (accessible) address */
 	unsigned long ba0_addr;
 	unsigned long ba1_addr;
 
@@ -1359,10 +1358,11 @@
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *)chip);
 	if (chip->ba0)
-		iounmap((void *) chip->ba0);
+		iounmap(chip->ba0);
 	if (chip->ba1)
-		iounmap((void *) chip->ba1);
+		iounmap(chip->ba1);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 
 	kfree(chip);
 	return 0;
@@ -1396,8 +1396,10 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&chip->reg_lock);
 	chip->card = card;
 	chip->pci = pci;
@@ -1411,6 +1413,7 @@
 
 	if ((err = pci_request_regions(pci, "CS4281")) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 	chip->ba0_addr = pci_resource_start(pci, 0);
@@ -1423,8 +1426,8 @@
 	}
 	chip->irq = pci->irq;
 
-	chip->ba0 = (unsigned long) ioremap_nocache(chip->ba0_addr, pci_resource_len(pci, 0));
-	chip->ba1 = (unsigned long) ioremap_nocache(chip->ba1_addr, pci_resource_len(pci, 1));
+	chip->ba0 = ioremap_nocache(chip->ba0_addr, pci_resource_len(pci, 0));
+	chip->ba1 = ioremap_nocache(chip->ba1_addr, pci_resource_len(pci, 1));
 	if (!chip->ba0 || !chip->ba1) {
 		snd_cs4281_free(chip);
 		return -ENOMEM;
@@ -1914,6 +1917,31 @@
 }
 
 
+/*
+ * OPL3 command
+ */
+static void snd_cs4281_opl3_command(opl3_t * opl3, unsigned short cmd, unsigned char val)
+{
+	unsigned long flags;
+	cs4281_t *chip = opl3->private_data;
+	void __iomem *port;
+
+	if (cmd & OPL3_RIGHT)
+		port = chip->ba0 + BA0_B1AP; /* right port */
+	else
+		port = chip->ba0 + BA0_B0AP; /* left port */
+
+	spin_lock_irqsave(&opl3->reg_lock, flags);
+
+	writel((unsigned int)cmd, port);
+	udelay(10);
+
+	writel((unsigned int)val, port + 4);
+	udelay(30);
+
+	spin_unlock_irqrestore(&opl3->reg_lock, flags);
+}
+
 static int __devinit snd_cs4281_probe(struct pci_dev *pci,
 				      const struct pci_device_id *pci_id)
 {
@@ -1951,13 +1979,13 @@
 		snd_card_free(card);
 		return err;
 	}
-	if ((err = snd_opl3_create(card,
-				   (chip->ba0 + BA0_B0AP) >> 2,
-				   (chip->ba0 + BA0_B1AP) >> 2,
-				   OPL3_HW_OPL3_CS4281, 1, &opl3)) < 0) {
+	if ((err = snd_opl3_new(card, OPL3_HW_OPL3_CS4281, &opl3)) < 0) {
 		snd_card_free(card);
 		return err;
 	}
+	opl3->private_data = chip;
+	opl3->command = snd_cs4281_opl3_command;
+	snd_opl3_init(opl3);
 	if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
 		snd_card_free(card);
 		return err;
@@ -2050,6 +2078,7 @@
 	ulCLK &= ~CLKCR1_CKRA;
 	snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK);
 
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -2061,6 +2090,7 @@
 	u32 ulCLK;
 
 	pci_enable_device(chip->pci);
+	pci_set_master(chip->pci);
 
 	ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1);
 	ulCLK |= CLKCR1_CKRA;
diff -Nru a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
--- a/sound/pci/cs46xx/cs46xx.c	2004-12-24 13:37:30 -08:00
+++ b/sound/pci/cs46xx/cs46xx.c	2004-12-24 13:37:30 -08:00
@@ -51,19 +51,18 @@
 static int external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 static int thinkpad[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 static int mmap_valid[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for the CS46xx soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for the CS46xx soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable CS46xx soundcard.");
-module_param_array(external_amp, bool, boot_devs, 0444);
+module_param_array(external_amp, bool, NULL, 0444);
 MODULE_PARM_DESC(external_amp, "Force to enable external amplifer.");
-module_param_array(thinkpad, bool, boot_devs, 0444);
+module_param_array(thinkpad, bool, NULL, 0444);
 MODULE_PARM_DESC(thinkpad, "Force to enable Thinkpad's CLKRUN control.");
-module_param_array(mmap_valid, bool, boot_devs, 0444);
+module_param_array(mmap_valid, bool, NULL, 0444);
 MODULE_PARM_DESC(mmap_valid, "Support OSS mmap.");
 
 static struct pci_device_id snd_cs46xx_ids[] = {
diff -Nru a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
--- a/sound/pci/cs46xx/cs46xx_lib.c	2004-12-24 13:36:18 -08:00
+++ b/sound/pci/cs46xx/cs46xx_lib.c	2004-12-24 13:36:18 -08:00
@@ -203,12 +203,6 @@
 
 	val = snd_cs46xx_codec_read(chip, reg, codec_index);
 
-	/* HACK: voyetra uses EAPD bit in the reverse way.
-	 * we flip the bit to show the mixer status correctly
-	 */
-	if (reg == AC97_POWERDOWN && chip->amplifier_ctrl == amp_voyetra)
-		val ^= 0x8000;
-
 	return val;
 }
 
@@ -289,12 +283,6 @@
 		   codec_index == CS46XX_SECONDARY_CODEC_INDEX,
 		   return);
 
-	/* HACK: voyetra uses EAPD bit in the reverse way.
-	 * we flip the bit to show the mixer status correctly
-	 */
-	if (reg == AC97_POWERDOWN && chip->amplifier_ctrl == amp_voyetra)
-		val ^= 0x8000;
-
 	snd_cs46xx_codec_write(chip, reg, val, codec_index);
 }
 
@@ -308,7 +296,7 @@
                         unsigned long offset,
                         unsigned long len)
 {
-	unsigned long dst;
+	void __iomem *dst;
 	unsigned int bank = offset >> 16;
 	offset = offset & 0xffff;
 
@@ -336,7 +324,7 @@
                          unsigned long offset,
                          unsigned long len) 
 {
-	unsigned long dst;
+	void __iomem *dst;
 	unsigned int bank = offset >> 16;
 	offset = offset & 0xffff;
 
@@ -2333,16 +2321,15 @@
 {
 	unsigned long end_time;
 	int err;
-	cs46xx_t * chip = ac97->private_data;
 
 	/* reset to defaults */
 	snd_ac97_write(ac97, AC97_RESET, 0);	
 
 	/* set the desired CODEC mode */
-	if (chip->nr_ac97_codecs == 0) {
+	if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) {
 		snd_printdd("cs46xx: CODOEC1 mode %04x\n",0x0);
 		snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x0);
-	} else if (chip->nr_ac97_codecs == 1) {
+	} else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) {
 		snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3);
 		snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3);
 	} else {
@@ -2380,10 +2367,43 @@
 }
 #endif
 
+static int __devinit cs46xx_detect_codec(cs46xx_t *chip, int codec)
+{
+	int idx, err;
+	ac97_template_t ac97;
+
+	memset(&ac97, 0, sizeof(ac97));
+	ac97.private_data = chip;
+	ac97.private_free = snd_cs46xx_mixer_free_ac97;
+	ac97.num = codec;
+	if (chip->amplifier_ctrl == amp_voyetra)
+		ac97.scaps = AC97_SCAP_INV_EAPD;
+
+	if (codec == CS46XX_SECONDARY_CODEC_INDEX) {
+		snd_cs46xx_codec_write(chip, AC97_RESET, 0, codec);
+		udelay(10);
+		if (snd_cs46xx_codec_read(chip, AC97_RESET, codec) & 0x8000) {
+			snd_printdd("snd_cs46xx: seconadry codec not present\n");
+			return -ENXIO;
+		}
+	}
+
+	snd_cs46xx_codec_write(chip, AC97_MASTER, 0x8000, codec);
+	for (idx = 0; idx < 100; ++idx) {
+		if (snd_cs46xx_codec_read(chip, AC97_MASTER, codec) == 0x8000) {
+			err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[codec]);
+			return err;
+		}
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ/100);
+	}
+	snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec);
+	return -ENXIO;
+}
+
 int __devinit snd_cs46xx_mixer(cs46xx_t *chip)
 {
 	snd_card_t *card = chip->card;
-	ac97_template_t ac97;
 	snd_ctl_elem_id_t id;
 	int err;
 	unsigned int idx;
@@ -2402,70 +2422,15 @@
 		return err;
 	chip->ac97_bus->private_free = snd_cs46xx_mixer_free_ac97_bus;
 
-	memset(&ac97, 0, sizeof(ac97));
-	ac97.private_data = chip;
-	ac97.private_free = snd_cs46xx_mixer_free_ac97;
-
-	snd_cs46xx_codec_write(chip, AC97_MASTER, 0x8000,
-			       CS46XX_PRIMARY_CODEC_INDEX);
-	for (idx = 0; idx < 100; ++idx) {
-		if (snd_cs46xx_codec_read(chip, AC97_MASTER,
-					  CS46XX_PRIMARY_CODEC_INDEX) == 0x8000)
-			goto _ok;
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/100);
-	}
-	return -ENXIO;
-
- _ok:
-	if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[CS46XX_PRIMARY_CODEC_INDEX])) < 0)
-		return err;
-	snd_printdd("snd_cs46xx: primary codec phase one\n");
+	if (cs46xx_detect_codec(chip, CS46XX_PRIMARY_CODEC_INDEX) < 0)
+		return -ENXIO;
 	chip->nr_ac97_codecs = 1;
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
 	snd_printdd("snd_cs46xx: detecting seconadry codec\n");
 	/* try detect a secondary codec */
-	memset(&ac97, 0, sizeof(ac97));    
-	ac97.private_data = chip;
-	ac97.private_free = snd_cs46xx_mixer_free_ac97;
-	ac97.num = CS46XX_SECONDARY_CODEC_INDEX;
-
-	snd_cs46xx_codec_write(chip, AC97_RESET, 0,
-			       CS46XX_SECONDARY_CODEC_INDEX);
-	udelay(10);
-
-	if (snd_cs46xx_codec_read(chip, AC97_RESET,
-				  CS46XX_SECONDARY_CODEC_INDEX) & 0x8000) {
-		snd_printdd("snd_cs46xx: seconadry codec not present\n");
-		goto _no_sec_codec;
-	}
-
-	snd_cs46xx_codec_write(chip, AC97_MASTER, 0x8000,
-			       CS46XX_SECONDARY_CODEC_INDEX);
-	for (idx = 0; idx < 100; ++idx) {
-		if (snd_cs46xx_codec_read(chip, AC97_MASTER,
-					  CS46XX_SECONDARY_CODEC_INDEX) == 0x8000) {
-			goto _ok2;
-		}
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/100);
-	}
-
- _no_sec_codec:
-	snd_printdd("snd_cs46xx: secondary codec did not respond ...\n");
-
-	chip->nr_ac97_codecs = 1;
-    
-	/* well, one codec only ... */
-	goto _end;
- _ok2:
-	if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[CS46XX_SECONDARY_CODEC_INDEX])) < 0)
-		return err;
-	chip->nr_ac97_codecs = 2;
-
- _end:
-
+	if (! cs46xx_detect_codec(chip, CS46XX_SECONDARY_CODEC_INDEX))
+		chip->nr_ac97_codecs = 2;
 #endif /* CONFIG_SND_CS46XX_NEW_DSP */
 
 	/* add cs4630 mixer controls */
@@ -2483,15 +2448,14 @@
 	chip->eapd_switch = snd_ctl_find_id(chip->card, &id);
     
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
-	if (chip->nr_ac97_codecs == 1 && 
-	    (snd_cs46xx_codec_read(chip, AC97_VENDOR_ID2,
-				  CS46XX_PRIMARY_CODEC_INDEX) == 0x592b ||
-	     snd_cs46xx_codec_read(chip, AC97_VENDOR_ID2,
-				   CS46XX_PRIMARY_CODEC_INDEX) == 0x592d)) {
-		/* set primary cs4294 codec into Extended Audio Mode */
-		snd_printdd("setting EAM bit on cs4294 CODEC\n");
-		snd_cs46xx_codec_write(chip, AC97_CSR_ACMODE, 0x200,
-				       CS46XX_PRIMARY_CODEC_INDEX);
+	if (chip->nr_ac97_codecs == 1) {
+		unsigned int id2 = chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]->id & 0xffff;
+		if (id2 == 0x592b || id2 == 0x592d) {
+			/* set primary cs4294 codec into Extended Audio Mode */
+			snd_printdd("setting EAM bit on cs4294 CODEC\n");
+			snd_cs46xx_codec_write(chip, AC97_CSR_ACMODE, 0x200,
+					       CS46XX_PRIMARY_CODEC_INDEX);
+		}
 	}
 	/* do soundcard specific mixer setup */
 	if (chip->mixer_init) {
@@ -2902,7 +2866,7 @@
 	for (idx = 0; idx < 5; idx++) {
 		snd_cs46xx_region_t *region = &chip->region.idx[idx];
 		if (region->remap_addr)
-			iounmap((void *) region->remap_addr);
+			iounmap(region->remap_addr);
 		if (region->resource) {
 			release_resource(region->resource);
 			kfree_nocheck(region->resource);
@@ -2921,6 +2885,7 @@
 	}
 #endif
 	
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -3714,6 +3679,7 @@
 	/* disable CLKRUN */
 	chip->active_ctrl(chip, -chip->amplifier);
 	chip->amplifier = amp_saved; /* restore the status */
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -3724,6 +3690,7 @@
 	int amp_saved;
 
 	pci_enable_device(chip->pci);
+	pci_set_master(chip->pci);
 	amp_saved = chip->amplifier;
 	chip->amplifier = 0;
 	chip->active_ctrl(chip, 1); /* force to on */
@@ -3780,8 +3747,10 @@
 		return err;
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&chip->reg_lock);
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
 	init_MUTEX(&chip->spos_mutex);
@@ -3868,8 +3837,8 @@
 			snd_cs46xx_free(chip);
 			return -EBUSY;
 		}
-		region->remap_addr = (unsigned long) ioremap_nocache(region->base, region->size);
-		if (region->remap_addr == 0) {
+		region->remap_addr = ioremap_nocache(region->base, region->size);
+		if (region->remap_addr == NULL) {
 			snd_printk("%s ioremap problem\n", region->name);
 			snd_cs46xx_free(chip);
 			return -ENOMEM;
diff -Nru a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
--- a/sound/pci/cs46xx/dsp_spos.c	2004-12-24 13:37:18 -08:00
+++ b/sound/pci/cs46xx/dsp_spos.c	2004-12-24 13:37:18 -08:00
@@ -514,7 +514,7 @@
 	cs46xx_t *chip = entry->private_data;
 	dsp_spos_instance_t * ins = chip->dsp_spos_instance;
 	int i,j,col;
-	unsigned long dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
+	void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
 
 	down(&chip->spos_mutex);
 	snd_iprintf(buffer, "TASK TREES:\n");
@@ -573,7 +573,7 @@
 	cs46xx_t *chip = entry->private_data;
 	/*dsp_spos_instance_t * ins = chip->dsp_spos_instance; */
 	unsigned int i,col = 0;
-	unsigned long dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
+	void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
 	symbol_entry_t * symbol; 
 
 	for (i = 0;i < DSP_PARAMETER_BYTE_SIZE; i += sizeof(u32),col ++) {
@@ -599,7 +599,7 @@
 {
 	cs46xx_t *chip = entry->private_data;
 	int i,col = 0;
-	unsigned long dst = chip->region.idx[2].remap_addr;
+	void __iomem *dst = chip->region.idx[2].remap_addr;
 
 	snd_iprintf(buffer,"PCMREADER:\n");
 	for (i = PCM_READER_BUF1;i < PCM_READER_BUF1 + 0x30; i += sizeof(u32),col ++) {
@@ -909,12 +909,12 @@
 static int debug_tree;
 static void _dsp_create_task_tree (cs46xx_t *chip,u32 * task_data, u32  dest, int size)
 {
-	unsigned long spdst = chip->region.idx[1].remap_addr + 
+	void __iomem *spdst = chip->region.idx[1].remap_addr + 
 		DSP_PARAMETER_BYTE_OFFSET + dest * sizeof(u32);
 	int i;
 
 	for (i = 0; i < size; ++i) {
-		if (debug_tree) printk ("addr %08x, val %08x\n",(int)spdst,task_data[i]);
+		if (debug_tree) printk ("addr %p, val %08x\n", spdst,task_data[i]);
 		writel(task_data[i],spdst);
 		spdst += sizeof(u32);
 	}
@@ -923,12 +923,12 @@
 static int debug_scb;
 static void _dsp_create_scb (cs46xx_t *chip,u32 * scb_data, u32  dest)
 {
-	unsigned long spdst = chip->region.idx[1].remap_addr + 
+	void __iomem *spdst = chip->region.idx[1].remap_addr + 
 		DSP_PARAMETER_BYTE_OFFSET + dest * sizeof(u32);
 	int i;
 
 	for (i = 0; i < 0x10; ++i) {
-		if (debug_scb) printk ("addr %08x, val %08x\n",(int)spdst,scb_data[i]);
+		if (debug_scb) printk ("addr %p, val %08x\n", spdst,scb_data[i]);
 		writel(scb_data[i],spdst);
 		spdst += sizeof(u32);
 	}
diff -Nru a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c	2004-12-24 13:37:19 -08:00
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c	2004-12-24 13:37:19 -08:00
@@ -71,7 +71,7 @@
 	dsp_spos_instance_t * ins;
 	cs46xx_t *chip = scb_info->chip;
 	int j,col;
-	unsigned long dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
+	void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
 
 	ins = chip->dsp_spos_instance;
 
@@ -162,7 +162,7 @@
 
 static void _dsp_clear_sample_buffer (cs46xx_t *chip, u32 sample_buffer_addr, int dword_count) 
 {
-	unsigned long dst = chip->region.idx[2].remap_addr + sample_buffer_addr;
+	void __iomem *dst = chip->region.idx[2].remap_addr + sample_buffer_addr;
 	int i;
   
 	for (i = 0; i < dword_count ; ++i ) {
diff -Nru a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
--- a/sound/pci/emu10k1/emu10k1.c	2004-12-24 13:36:16 -08:00
+++ b/sound/pci/emu10k1/emu10k1.c	2004-12-24 13:36:16 -08:00
@@ -48,25 +48,24 @@
 static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64};
 static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
 static int enable_ir[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for the EMU10K1 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for the EMU10K1 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable the EMU10K1 soundcard.");
-module_param_array(extin, int, boot_devs, 0444);
+module_param_array(extin, int, NULL, 0444);
 MODULE_PARM_DESC(extin, "Available external inputs for FX8010. Zero=default.");
-module_param_array(extout, int, boot_devs, 0444);
+module_param_array(extout, int, NULL, 0444);
 MODULE_PARM_DESC(extout, "Available external outputs for FX8010. Zero=default.");
-module_param_array(seq_ports, int, boot_devs, 0444);
+module_param_array(seq_ports, int, NULL, 0444);
 MODULE_PARM_DESC(seq_ports, "Allocated sequencer ports for internal synthesizer.");
-module_param_array(max_synth_voices, int, boot_devs, 0444);
+module_param_array(max_synth_voices, int, NULL, 0444);
 MODULE_PARM_DESC(max_synth_voices, "Maximum number of voices for WaveTable.");
-module_param_array(max_buffer_size, int, boot_devs, 0444);
+module_param_array(max_buffer_size, int, NULL, 0444);
 MODULE_PARM_DESC(max_buffer_size, "Maximum sample buffer size in MB.");
-module_param_array(enable_ir, bool, boot_devs, 0444);
+module_param_array(enable_ir, bool, NULL, 0444);
 MODULE_PARM_DESC(enable_ir, "Enable IR.");
 
 static struct pci_device_id snd_emu10k1_ids[] = {
diff -Nru a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
--- a/sound/pci/emu10k1/emu10k1_main.c	2004-12-24 13:37:29 -08:00
+++ b/sound/pci/emu10k1/emu10k1_main.c	2004-12-24 13:37:29 -08:00
@@ -561,6 +561,7 @@
 		free_irq(emu->irq, (void *)emu);
 	if (emu->port)
 		pci_release_regions(emu->pci);
+	pci_disable_device(emu->pci);
 	kfree(emu);
 	return 0;
 }
@@ -596,14 +597,17 @@
 		return err;
 
 	emu = kcalloc(1, sizeof(*emu), GFP_KERNEL);
-	if (emu == NULL)
+	if (emu == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	/* set the DMA transfer mask */
 	emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
 	if (pci_set_dma_mask(pci, emu->dma_mask) < 0 ||
 	    pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
 		snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask);
 		kfree(emu);
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 	emu->card = card;
@@ -629,6 +633,7 @@
 
 	if ((err = pci_request_regions(pci, "EMU10K1")) < 0) {
 		kfree(emu);
+		pci_disable_device(pci);
 		return err;
 	}
 	emu->port = pci_resource_start(pci, 0);
diff -Nru a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
--- a/sound/pci/emu10k1/emufx.c	2004-12-24 13:36:55 -08:00
+++ b/sound/pci/emu10k1/emufx.c	2004-12-24 13:36:55 -08:00
@@ -480,7 +480,7 @@
 static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr,
 					u32 op, u32 r, u32 a, u32 x, u32 y)
 {
-	snd_assert(*ptr < 512, return);
+	snd_assert(*ptr < 1024, return);
 	set_bit(*ptr, icode->code_valid);
 	icode->code[*ptr    ][0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
 	icode->code[(*ptr)++][1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
@@ -505,7 +505,7 @@
 {
 	int gpr;
 
-	for (gpr = 0; gpr < 0x100; gpr++) {
+	for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) {
 		if (!test_bit(gpr, icode->gpr_valid))
 			continue;
 		snd_emu10k1_ptr_write(emu, emu->gpr_base + gpr, 0, icode->gpr_map[gpr]);
@@ -516,7 +516,7 @@
 {
 	int gpr;
 
-	for (gpr = 0; gpr < 0x100; gpr++) {
+	for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) {
 		set_bit(gpr, icode->gpr_valid);
 		icode->gpr_map[gpr] = snd_emu10k1_ptr_read(emu, emu->gpr_base + gpr, 0);
 	}
@@ -526,11 +526,16 @@
 {
 	int tram;
 
-	for (tram = 0; tram < 0xa0; tram++) {
+	for (tram = 0; tram < (emu->audigy ? 0x100 : 0xa0); tram++) {
 		if (!test_bit(tram, icode->tram_valid))
 			continue;
 		snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + tram, 0, icode->tram_data_map[tram]);
-		snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + tram, 0, icode->tram_addr_map[tram]);
+		if (!emu->audigy)
+			snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + tram, 0, icode->tram_addr_map[tram]);
+		else {
+			snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + tram, 0, icode->tram_addr_map[tram] << 12);
+			snd_emu10k1_ptr_write(emu, A_TANKMEMCTLREGBASE + tram, 0, icode->tram_addr_map[tram] >> 20);
+		}
 	}
 }
 
@@ -539,10 +544,15 @@
 	int tram;
 
 	memset(icode->tram_valid, 0, sizeof(icode->tram_valid));
-	for (tram = 0; tram < 0xa0; tram++) {
+	for (tram = 0; tram < (emu->audigy ? 0x100 : 0xa0); tram++) {
 		set_bit(tram, icode->tram_valid);
 		icode->tram_data_map[tram] = snd_emu10k1_ptr_read(emu, TANKMEMDATAREGBASE + tram, 0);
-		icode->tram_addr_map[tram] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + tram, 0);
+		if (!emu->audigy)
+			icode->tram_addr_map[tram] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + tram, 0);
+		else {
+			icode->tram_addr_map[tram] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + tram, 0) >> 12;
+			icode->tram_addr_map[tram] |= snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + tram, 0) << 20;
+		}
 	}
 }
 
@@ -550,7 +560,7 @@
 {
 	u32 pc;
 
-	for (pc = 0; pc < 512; pc++) {
+	for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
 		if (!test_bit(pc, icode->code_valid))
 			continue;
 		snd_emu10k1_efx_write(emu, pc * 2, icode->code[pc][0]);
@@ -563,7 +573,7 @@
 	u32 pc;
 
 	memset(icode->code_valid, 0, sizeof(icode->code_valid));
-	for (pc = 0; pc < 512; pc++) {
+	for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
 		set_bit(pc, icode->code_valid);
 		icode->code[pc][0] = snd_emu10k1_efx_read(emu, pc * 2);
 		icode->code[pc][1] = snd_emu10k1_efx_read(emu, pc * 2 + 1);
@@ -962,8 +972,12 @@
 	}
 
 	/* clear free GPRs */
-	for (i = 0; i < 256; i++)
+	for (i = 0; i < 512; i++)
 		set_bit(i, icode->gpr_valid);
+		
+	/* clear TRAM data & address lines */
+	for (i = 0; i < 256; i++)
+		set_bit(i, icode->tram_valid);
 
 	strcpy(icode->name, "Audigy DSP code for ALSA");
 	ptr = 0;
@@ -1311,7 +1325,7 @@
 		goto __err;
 	}
 	/* clear remaining instruction memory */
-	while (ptr < 0x200)
+	while (ptr < 0x400)
 		A_OP(icode, &ptr, 0x0f, 0xc0, 0xc0, 0xcf, 0xc0);
 
 	seg = snd_enter_user();
@@ -2067,8 +2081,6 @@
 		kfree(icode);
 		return res;
 	case SNDRV_EMU10K1_IOCTL_PCM_POKE:
-		if (emu->audigy)
-			return -EINVAL;
 		ipcm = (emu10k1_fx8010_pcm_t *)kmalloc(sizeof(*ipcm), GFP_KERNEL);
 		if (ipcm == NULL)
 			return -ENOMEM;
@@ -2080,8 +2092,6 @@
 		kfree(ipcm);
 		return res;
 	case SNDRV_EMU10K1_IOCTL_PCM_PEEK:
-		if (emu->audigy)
-			return -EINVAL;
 		ipcm = kcalloc(1, sizeof(*ipcm), GFP_KERNEL);
 		if (ipcm == NULL)
 			return -ENOMEM;
@@ -2097,8 +2107,6 @@
 		kfree(ipcm);
 		return res;
 	case SNDRV_EMU10K1_IOCTL_TRAM_SETUP:
-		if (emu->audigy)
-			return -EINVAL;
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		if (get_user(addr, (unsigned int __user *)argp))
diff -Nru a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
--- a/sound/pci/emu10k1/emupcm.c	2004-12-24 13:36:17 -08:00
+++ b/sound/pci/emu10k1/emupcm.c	2004-12-24 13:36:17 -08:00
@@ -1092,6 +1092,7 @@
 	emu10k1_t *emu = snd_kcontrol_chip(kcontrol);
 	unsigned int nval[2], bits;
 	int nefx = emu->audigy ? 64 : 32;
+	int nefxb = emu->audigy ? 7 : 6;
 	int change, idx;
 	
 	nval[0] = nval[1] = 0;
@@ -1100,8 +1101,14 @@
 			nval[idx / 32] |= 1 << (idx % 32);
 			bits++;
 		}
-	if (bits != 1 && bits != 2 && bits != 4 && bits != 8)
+		
+	for (idx = 0; idx < nefxb; idx++)
+		if (1 << idx == bits)
+			break;
+	
+	if (idx >= nefxb)
 		return -EINVAL;
+
 	spin_lock_irq(&emu->reg_lock);
 	change = (nval[0] != emu->efx_voices_mask[0]) ||
 		(nval[1] != emu->efx_voices_mask[1]);
@@ -1185,7 +1192,7 @@
 	}
 	snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos,
 					       (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2,
-					       src, frames, tram_shift++);
+					       src, frames, tram_shift);
 	tram_pos -= frames;
 	pcm->tram_pos = tram_pos;
 	pcm->tram_shift = tram_shift;
diff -Nru a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c
--- a/sound/pci/emu10k1/emuproc.c	2004-12-24 13:36:47 -08:00
+++ b/sound/pci/emu10k1/emuproc.c	2004-12-24 13:36:47 -08:00
@@ -229,7 +229,7 @@
 
 	snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
 	snd_iprintf(buffer, "  Code dump      :\n");
-	for (pc = 0; pc < 512; pc++) {
+	for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
 		u32 low, high;
 			
 		low = snd_emu10k1_efx_read(emu, pc * 2);
@@ -256,9 +256,13 @@
 }
 
 #define TOTAL_SIZE_GPR		(0x100*4)
+#define A_TOTAL_SIZE_GPR	(0x200*4)
 #define TOTAL_SIZE_TANKMEM_DATA	(0xa0*4)
 #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
+#define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
+#define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
 #define TOTAL_SIZE_CODE		(0x200*8)
+#define A_TOTAL_SIZE_CODE	(0x400*8)
 
 static long snd_emu10k1_fx8010_read(snd_info_entry_t *entry, void *file_private_data,
 				    struct file *file, char __user *buf,
@@ -267,12 +271,12 @@
 	long size;
 	emu10k1_t *emu = entry->private_data;
 	unsigned int offset;
+	int tram_addr = 0;
 	
 	if (!strcmp(entry->name, "fx8010_tram_addr")) {
-		if (emu->audigy) return -EINVAL;
 		offset = TANKMEMADDRREGBASE;
+		tram_addr = 1;
 	} else if (!strcmp(entry->name, "fx8010_tram_data")) {
-		if (emu->audigy) return -EINVAL;
 		offset = TANKMEMDATAREGBASE;
 	} else if (!strcmp(entry->name, "fx8010_code")) {
 		offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
@@ -289,7 +293,11 @@
 		if ((tmp = kmalloc(size + 8, GFP_KERNEL)) == NULL)
 			return -ENOMEM;
 		for (idx = 0; idx < ((pos & 3) + size + 3) >> 2; idx++)
-			tmp[idx] = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
+			if (tram_addr && emu->audigy) {
+				tmp[idx] = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0) >> 11;
+				tmp[idx] |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
+			} else 
+				tmp[idx] = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
 		if (copy_to_user(buf, ((char *)tmp) + (pos & 3), size))
 			res = -EFAULT;
 		else {
@@ -316,35 +324,35 @@
 		entry->content = SNDRV_INFO_CONTENT_DATA;
 		entry->private_data = emu;
 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
-		entry->size = TOTAL_SIZE_GPR;
+		entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR;
 		entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
 	}
-	if (!emu->audigy && ! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) {
+	if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) {
 		entry->content = SNDRV_INFO_CONTENT_DATA;
 		entry->private_data = emu;
 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
-		entry->size = TOTAL_SIZE_TANKMEM_DATA;
+		entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ;
 		entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
 	}
-	if (!emu->audigy && ! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) {
+	if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) {
 		entry->content = SNDRV_INFO_CONTENT_DATA;
 		entry->private_data = emu;
 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
-		entry->size = TOTAL_SIZE_TANKMEM_ADDR;
+		entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
 		entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
 	}
 	if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
 		entry->content = SNDRV_INFO_CONTENT_DATA;
 		entry->private_data = emu;
 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
-		entry->size = TOTAL_SIZE_CODE;
+		entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
 		entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
 	}
 	if (! snd_card_proc_new(emu->card, "fx8010_acode", &entry)) {
 		entry->content = SNDRV_INFO_CONTENT_TEXT;
 		entry->private_data = emu;
 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
-		entry->c.text.read_size = 64*1024;
+		entry->c.text.read_size = 128*1024;
 		entry->c.text.read = snd_emu10k1_proc_acode_read;
 	}
 	return 0;
diff -Nru a/sound/pci/ens1370.c b/sound/pci/ens1370.c
--- a/sound/pci/ens1370.c	2004-12-24 13:37:18 -08:00
+++ b/sound/pci/ens1370.c	2004-12-24 13:37:18 -08:00
@@ -83,20 +83,19 @@
 static int joystick[SNDRV_CARDS];
 #endif
 #endif
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Ensoniq AudioPCI soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Ensoniq AudioPCI soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Ensoniq AudioPCI soundcard.");
 #ifdef SUPPORT_JOYSTICK
 #ifdef CHIP1371
-module_param_array(joystick_port, int, boot_devs, 0444);
+module_param_array(joystick_port, int, NULL, 0444);
 MODULE_PARM_DESC(joystick_port, "Joystick port address.");
 #else
-module_param_array(joystick, bool, boot_devs, 0444);
+module_param_array(joystick, bool, NULL, 0444);
 MODULE_PARM_DESC(joystick, "Enable joystick.");
 #endif
 #endif /* SUPPORT_JOYSTICK */
@@ -372,6 +371,7 @@
 
 struct _snd_ensoniq {
 	spinlock_t reg_lock;
+	struct semaphore src_mutex;
 
 	int irq;
 
@@ -513,6 +513,7 @@
 		r = inl(ES_REG(ensoniq, 1371_SMPRATE));
 		if ((r & ES_1371_SRC_RAM_BUSY) == 0)
 			return r;
+		cond_resched();
 	}
 	snd_printk("wait source ready timeout 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_SMPRATE), r);
 	return 0;
@@ -696,6 +697,7 @@
 {
 	unsigned int n, truncm, freq, result;
 
+	down(&ensoniq->src_mutex);
 	n = rate / 3000;
 	if ((1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9)))
 		n--;
@@ -719,12 +721,14 @@
 	snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff);
 	snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, n << 8);
 	snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, n << 8);
+	up(&ensoniq->src_mutex);
 }
 
 static void snd_es1371_dac1_rate(ensoniq_t * ensoniq, unsigned int rate)
 {
 	unsigned int freq, r;
 
+	down(&ensoniq->src_mutex);
 	freq = ((rate << 15) + 1500) / 3000;
 	r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1)) | ES_1371_DIS_P1;
 	outl(r, ES_REG(ensoniq, 1371_SMPRATE));
@@ -734,12 +738,14 @@
 	snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff);
 	r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1));
 	outl(r, ES_REG(ensoniq, 1371_SMPRATE));
+	up(&ensoniq->src_mutex);
 }
 
 static void snd_es1371_dac2_rate(ensoniq_t * ensoniq, unsigned int rate)
 {
 	unsigned int freq, r;
 
+	down(&ensoniq->src_mutex);
 	freq = ((rate << 15) + 1500) / 3000;
 	r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1)) | ES_1371_DIS_P2;
 	outl(r, ES_REG(ensoniq, 1371_SMPRATE));
@@ -749,6 +755,7 @@
 	snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff);
 	r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1));
 	outl(r, ES_REG(ensoniq, 1371_SMPRATE));
+	up(&ensoniq->src_mutex);
 }
 
 #endif /* CHIP1371 */
@@ -846,6 +853,13 @@
 		mode |= 0x01;
 	spin_lock_irq(&ensoniq->reg_lock);
 	ensoniq->ctrl &= ~ES_DAC1_EN;
+#ifdef CHIP1371
+	/* 48k doesn't need SRC (it breaks AC3-passthru) */
+	if (runtime->rate == 48000)
+		ensoniq->ctrl |= ES_1373_BYPASS_P1;
+	else
+		ensoniq->ctrl &= ~ES_1373_BYPASS_P1;
+#endif
 	outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
 	outl(ES_MEM_PAGEO(ES_PAGE_DAC), ES_REG(ensoniq, MEM_PAGE));
 	outl(runtime->dma_addr, ES_REG(ensoniq, DAC1_FRAME));
@@ -863,11 +877,12 @@
 	case 44100: ensoniq->ctrl |= ES_1370_WTSRSEL(3); break;
 	default: snd_BUG();
 	}
-#else
-	snd_es1371_dac1_rate(ensoniq, runtime->rate);
 #endif
 	outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
 	spin_unlock_irq(&ensoniq->reg_lock);
+#ifndef CHIP1370
+	snd_es1371_dac1_rate(ensoniq, runtime->rate);
+#endif
 	return 0;
 }
 
@@ -901,11 +916,12 @@
 		ensoniq->ctrl |= ES_1370_PCLKDIVO(ES_1370_SRTODIV(runtime->rate));
 		ensoniq->u.es1370.pclkdiv_lock |= ES_MODE_PLAY2;
 	}
-#else
-	snd_es1371_dac2_rate(ensoniq, runtime->rate);
 #endif
 	outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
 	spin_unlock_irq(&ensoniq->reg_lock);
+#ifndef CHIP1370
+	snd_es1371_dac2_rate(ensoniq, runtime->rate);
+#endif
 	return 0;
 }
 
@@ -937,11 +953,12 @@
 		ensoniq->ctrl |= ES_1370_PCLKDIVO(ES_1370_SRTODIV(runtime->rate));
 		ensoniq->u.es1370.pclkdiv_lock |= ES_MODE_CAPTURE;
 	}
-#else
-	snd_es1371_adc_rate(ensoniq, runtime->rate);
 #endif
 	outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
 	spin_unlock_irq(&ensoniq->reg_lock);
+#ifndef CHIP1370
+	snd_es1371_adc_rate(ensoniq, runtime->rate);
+#endif
 	return 0;
 }
 
@@ -1822,6 +1839,7 @@
 	if (ensoniq->irq >= 0)
 		free_irq(ensoniq->irq, (void *)ensoniq);
 	pci_release_regions(ensoniq->pci);
+	pci_disable_device(ensoniq->pci);
 	kfree(ensoniq);
 	return 0;
 }
@@ -1876,14 +1894,18 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	ensoniq = kcalloc(1, sizeof(*ensoniq), GFP_KERNEL);
-	if (ensoniq == NULL)
+	if (ensoniq == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&ensoniq->reg_lock);
+	init_MUTEX(&ensoniq->src_mutex);
 	ensoniq->card = card;
 	ensoniq->pci = pci;
 	ensoniq->irq = -1;
 	if ((err = pci_request_regions(pci, "Ensoniq AudioPCI")) < 0) {
 		kfree(ensoniq);
+		pci_disable_device(pci);
 		return err;
 	}
 	ensoniq->port = pci_resource_start(pci, 0);
diff -Nru a/sound/pci/es1938.c b/sound/pci/es1938.c
--- a/sound/pci/es1938.c	2004-12-24 13:37:02 -08:00
+++ b/sound/pci/es1938.c	2004-12-24 13:37:02 -08:00
@@ -82,13 +82,12 @@
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ESS Solo-1 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ESS Solo-1 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable ESS Solo-1 soundcard.");
 
 #define SLIO_REG(chip, x) ((chip)->io_port + ESSIO_REG_##x)
@@ -1395,6 +1394,7 @@
 
 	outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
 
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -1433,6 +1433,7 @@
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *)chip);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -1462,18 +1463,22 @@
 	if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
                 snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
                 return -ENXIO;
         }
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&chip->reg_lock);
 	spin_lock_init(&chip->mixer_lock);
 	chip->card = card;
 	chip->pci = pci;
 	if ((err = pci_request_regions(pci, "ESS Solo-1")) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 	chip->io_port = pci_resource_start(pci, 0);
diff -Nru a/sound/pci/es1968.c b/sound/pci/es1968.c
--- a/sound/pci/es1968.c	2004-12-24 13:37:02 -08:00
+++ b/sound/pci/es1968.c	2004-12-24 13:37:02 -08:00
@@ -135,28 +135,27 @@
 #ifdef SUPPORT_JOYSTICK
 static int joystick[SNDRV_CARDS];
 #endif
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
-module_param_array(total_bufsize, int, boot_devs, 0444);
+module_param_array(total_bufsize, int, NULL, 0444);
 MODULE_PARM_DESC(total_bufsize, "Total buffer size in kB.");
-module_param_array(pcm_substreams_p, int, boot_devs, 0444);
+module_param_array(pcm_substreams_p, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_substreams_p, "PCM Playback substreams for " CARD_NAME " soundcard.");
-module_param_array(pcm_substreams_c, int, boot_devs, 0444);
+module_param_array(pcm_substreams_c, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_substreams_c, "PCM Capture substreams for " CARD_NAME " soundcard.");
-module_param_array(clock, int, boot_devs, 0444);
+module_param_array(clock, int, NULL, 0444);
 MODULE_PARM_DESC(clock, "Clock on " CARD_NAME " soundcard.  (0 = auto-detect)");
-module_param_array(use_pm, int, boot_devs, 0444);
+module_param_array(use_pm, int, NULL, 0444);
 MODULE_PARM_DESC(use_pm, "Toggle power-management.  (0 = off, 1 = on, 2 = auto)");
-module_param_array(enable_mpu, int, boot_devs, 0444);
+module_param_array(enable_mpu, int, NULL, 0444);
 MODULE_PARM_DESC(enable_mpu, "Enable MPU401.  (0 = off, 1 = on, 2 = auto)");
 #ifdef SUPPORT_JOYSTICK
-module_param_array(joystick, bool, boot_devs, 0444);
+module_param_array(joystick, bool, NULL, 0444);
 MODULE_PARM_DESC(joystick, "Enable joystick.");
 #endif
 
@@ -556,6 +555,11 @@
 	int playback_streams, capture_streams;
 
 	unsigned int clock;		/* clock */
+	/* for clock measurement */
+	unsigned int in_measurement: 1;
+	unsigned int measure_apu;
+	unsigned int measure_lastpos;
+	unsigned int measure_count;
 
 	/* buffer */
 	struct snd_dma_buffer dma;
@@ -580,6 +584,7 @@
 	snd_rawmidi_t *rmidi;
 
 	spinlock_t reg_lock;
+	struct semaphore ac97_mutex;	/* ac97 lock */
 	struct tasklet_struct hwvol_tq;
 
 	/* Maestro Stuff */
@@ -672,6 +677,7 @@
 	while (timeout-- > 0) {
 		if (!(inb(chip->io_port + ESM_AC97_INDEX) & 1))
 			return 0;
+		cond_resched();
 	}
 	snd_printd("es1968: ac97 timeout\n");
 	return 1; /* timeout */
@@ -680,39 +686,35 @@
 static void snd_es1968_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
 {
 	es1968_t *chip = ac97->private_data;
-	unsigned long flags;
-
-	spin_lock_irqsave(&chip->reg_lock, flags);
 
+	down(&chip->ac97_mutex);
 	snd_es1968_ac97_wait(chip);
 
 	/* Write the bus */
 	outw(val, chip->io_port + ESM_AC97_DATA);
-	mdelay(1);
+	msleep(1);
 	outb(reg, chip->io_port + ESM_AC97_INDEX);
-	mdelay(1);
+	msleep(1);
 
-	spin_unlock_irqrestore(&chip->reg_lock, flags);
+	up(&chip->ac97_mutex);
 }
 
 static unsigned short snd_es1968_ac97_read(ac97_t *ac97, unsigned short reg)
 {
 	u16 data = 0;
 	es1968_t *chip = ac97->private_data;
-	unsigned long flags;
-
-	spin_lock_irqsave(&chip->reg_lock, flags);
 
+	down(&chip->ac97_mutex);
 	snd_es1968_ac97_wait(chip);
 
 	outb(reg | 0x80, chip->io_port + ESM_AC97_INDEX);
-	mdelay(1);
+	msleep(1);
 
 	if (! snd_es1968_ac97_wait(chip)) {
 		data = inw(chip->io_port + ESM_AC97_DATA);
-		mdelay(1);
+		msleep(1);
 	}
-	spin_unlock_irqrestore(&chip->reg_lock, flags);
+	up(&chip->ac97_mutex);
 
 	return data;
 }
@@ -1804,30 +1806,28 @@
 
 	snd_es1968_apu_set_freq(chip, apu, ((unsigned int)48000 << 16) / chip->clock); /* 48000 Hz */
 
+	chip->in_measurement = 1;
+	chip->measure_apu = apu;
 	spin_lock_irq(&chip->reg_lock);
+	snd_es1968_bob_inc(chip, ESM_BOB_FREQ);
 	__apu_set_register(chip, apu, 5, pa & 0xffff);
 	snd_es1968_trigger_apu(chip, apu, ESM_APU_16BITLINEAR);
 	do_gettimeofday(&start_time);
 	spin_unlock_irq(&chip->reg_lock);
-#if 0
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout(HZ / 20); /* 50 msec */
-#else
-	/* FIXME:
-	 * schedule() above may be too inaccurate and the pointer can
-	 * overlap the boundary..
-	 */
-	mdelay(50);
-#endif
 	spin_lock_irq(&chip->reg_lock);
 	offset = __apu_get_register(chip, apu, 5);
 	do_gettimeofday(&stop_time);
 	snd_es1968_trigger_apu(chip, apu, 0); /* stop */
+	snd_es1968_bob_dec(chip);
+	chip->in_measurement = 0;
 	spin_unlock_irq(&chip->reg_lock);
 
 	/* check the current position */
 	offset -= (pa & 0xffff);
 	offset &= 0xfffe;
+	offset += chip->measure_count * (CLOCK_MEASURE_BUFSIZE/2);
 
 	t = stop_time.tv_sec - start_time.tv_sec;
 	t *= 1000000;
@@ -2005,6 +2005,12 @@
 				snd_es1968_update_pcm(chip, es);
 		}
 		spin_unlock(&chip->substream_lock);
+		if (chip->in_measurement) {
+			unsigned int curp = __apu_get_register(chip, chip->measure_apu, 5);
+			if (curp < chip->measure_lastpos)
+				chip->measure_count++;
+			chip->measure_lastpos = curp;
+		}
 	}
 
 	return IRQ_HANDLED;
@@ -2405,6 +2411,7 @@
 	snd_ac97_suspend(chip->ac97);
 	snd_es1968_bob_stop(chip);
 	snd_es1968_set_acpi(chip, ACPI_D3);
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -2418,6 +2425,7 @@
 
 	/* restore all our config */
 	pci_enable_device(chip->pci);
+	pci_set_master(chip->pci);
 	snd_es1968_chip_init(chip);
 
 	/* need to restore the base pointers.. */ 
@@ -2461,6 +2469,7 @@
 	chip->master_switch = NULL;
 	chip->master_volume = NULL;
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -2512,12 +2521,15 @@
 	if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (! chip)
+	if (! chip) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	/* Set Vars */
 	chip->type = chip_type;
@@ -2525,6 +2537,7 @@
 	spin_lock_init(&chip->substream_lock);
 	INIT_LIST_HEAD(&chip->buf_list);
 	INIT_LIST_HEAD(&chip->substream_list);
+	init_MUTEX(&chip->ac97_mutex);
 	init_MUTEX(&chip->memory_mutex);
 	tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip);
 	chip->card = card;
@@ -2536,6 +2549,7 @@
 
 	if ((err = pci_request_regions(pci, "ESS Maestro")) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 	chip->io_port = pci_resource_start(pci, 0);
diff -Nru a/sound/pci/fm801.c b/sound/pci/fm801.c
--- a/sound/pci/fm801.c	2004-12-24 13:37:18 -08:00
+++ b/sound/pci/fm801.c	2004-12-24 13:37:18 -08:00
@@ -57,15 +57,14 @@
  *  High 16-bits are video (radio) device number + 1
  */
 static int tea575x_tuner[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 };
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for the FM801 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for the FM801 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable FM801 soundcard.");
-module_param_array(tea575x_tuner, bool, boot_devs, 0444);
+module_param_array(tea575x_tuner, bool, NULL, 0444);
 MODULE_PARM_DESC(tea575x_tuner, "Enable TEA575x tuner.");
 
 /*
@@ -1235,6 +1234,7 @@
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *)chip);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 
 	kfree(chip);
 	return 0;
@@ -1264,14 +1264,17 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&chip->reg_lock);
 	chip->card = card;
 	chip->pci = pci;
 	chip->irq = -1;
 	if ((err = pci_request_regions(pci, "FM801")) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 	chip->port = pci_resource_start(pci, 0);
diff -Nru a/sound/pci/ice1712/Makefile b/sound/pci/ice1712/Makefile
--- a/sound/pci/ice1712/Makefile	2004-12-24 13:36:47 -08:00
+++ b/sound/pci/ice1712/Makefile	2004-12-24 13:36:47 -08:00
@@ -5,7 +5,7 @@
 
 snd-ice17xx-ak4xxx-objs := ak4xxx.o
 snd-ice1712-objs := ice1712.o delta.o hoontech.o ews.o
-snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o
+snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o
 
 # Toplevel Module Dependency
 obj-$(CONFIG_SND_ICE1712) += snd-ice1712.o snd-ice17xx-ak4xxx.o
diff -Nru a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
--- a/sound/pci/ice1712/aureon.c	2004-12-24 13:37:43 -08:00
+++ b/sound/pci/ice1712/aureon.c	2004-12-24 13:37:43 -08:00
@@ -89,6 +89,235 @@
 #define WM_OUT_MUX2		0x1e	/* output MUX */
 #define WM_RESET		0x1f	/* software reset */
 
+static void aureon_ac97_write(ice1712_t *ice, unsigned short reg, unsigned short val) {
+	unsigned int tmp;
+
+	/* Send address to XILINX chip */
+	tmp = (snd_ice1712_gpio_read(ice) & ~0xFF) | (reg & 0x7F);
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	tmp |= AUREON_AC97_ADDR;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	tmp &= ~AUREON_AC97_ADDR;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);	
+
+	/* Send low-order byte to XILINX chip */
+	tmp &= ~AUREON_AC97_DATA_MASK;
+	tmp |= val & AUREON_AC97_DATA_MASK;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	tmp |= AUREON_AC97_DATA_LOW;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	tmp &= ~AUREON_AC97_DATA_LOW;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	
+	/* Send high-order byte to XILINX chip */
+	tmp &= ~AUREON_AC97_DATA_MASK;
+	tmp |= (val >> 8) & AUREON_AC97_DATA_MASK;
+
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	tmp |= AUREON_AC97_DATA_HIGH;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	tmp &= ~AUREON_AC97_DATA_HIGH;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	
+	/* Instruct XILINX chip to parse the data to the STAC9744 chip */
+	tmp |= AUREON_AC97_COMMIT;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	tmp &= ~AUREON_AC97_COMMIT;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(10);
+	
+	/* Store the data in out private buffer */
+	ice->spec.aureon.stac9744[(reg & 0x7F) >> 1] = val;
+}
+
+static unsigned short aureon_ac97_read(ice1712_t *ice, unsigned short reg)
+{
+       return ice->spec.aureon.stac9744[(reg & 0x7F) >> 1];
+}
+
+/*
+ * Initialize STAC9744 chip
+ */
+static int aureon_ac97_init (ice1712_t *ice) {
+	int i;
+	static unsigned short ac97_defaults[] = {
+		0x00, 0x9640,
+		0x02, 0x8000,
+		0x04, 0x8000,
+		0x06, 0x8000,
+		0x0C, 0x8008,
+		0x0E, 0x8008,
+		0x10, 0x8808,
+		0x12, 0x8808,
+		0x14, 0x8808,
+		0x16, 0x8808,
+		0x18, 0x8808,
+		0x1C, 0x8000,
+		0x26, 0x000F,
+		0x28, 0x0201,
+		0x2C, 0xBB80,
+		0x32, 0xBB80,
+		0x7C, 0x8384,
+		0x7E, 0x7644,
+		(unsigned short)-1
+	};
+	unsigned int tmp;
+
+	/* Cold reset */
+	tmp = (snd_ice1712_gpio_read(ice) | AUREON_AC97_RESET) & ~AUREON_AC97_DATA_MASK;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(3);
+	
+	tmp &= ~AUREON_AC97_RESET;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(3);
+	
+	tmp |= AUREON_AC97_RESET;
+	snd_ice1712_gpio_write(ice, tmp);
+	udelay(3);
+	
+	memset(&ice->spec.aureon.stac9744, 0, sizeof(ice->spec.aureon.stac9744));
+	for (i=0; ac97_defaults[i] != (unsigned short)-1; i+=2)
+		ice->spec.aureon.stac9744[(ac97_defaults[i]) >> 1] = ac97_defaults[i+1];
+		
+	aureon_ac97_write(ice, AC97_MASTER, 0x0000); // Unmute AC'97 master volume permanently - muting is done by WM8770
+
+	return 0;
+}
+
+#define AUREON_AC97_STEREO	0x80
+
+/*
+ * AC'97 volume controls
+ */
+static int aureon_ac97_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+	uinfo->count = kcontrol->private_value & AUREON_AC97_STEREO ? 2 : 1;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 31;
+	return 0;
+}
+
+static int aureon_ac97_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned short vol;
+
+	down(&ice->gpio_mutex);
+
+	vol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
+	ucontrol->value.integer.value[0] = 0x1F - (vol & 0x1F);
+	if (kcontrol->private_value & AUREON_AC97_STEREO)
+		ucontrol->value.integer.value[1] = 0x1F - ((vol >> 8) & 0x1F);
+
+	up(&ice->gpio_mutex);
+	return 0;
+}
+
+static int aureon_ac97_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned short ovol, nvol;
+	int change;
+	
+	snd_ice1712_save_gpio_status(ice);
+
+	ovol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
+	nvol = (0x1F - ucontrol->value.integer.value[0]) & 0x001F;
+	if (kcontrol->private_value & AUREON_AC97_STEREO)
+		nvol |= ((0x1F - ucontrol->value.integer.value[1]) << 8) & 0x1F00;
+	nvol |= ovol & ~0x1F1F;
+	
+	if ((change = (ovol != nvol)))
+		aureon_ac97_write(ice, kcontrol->private_value & 0x7F, nvol);
+
+	snd_ice1712_restore_gpio_status(ice);
+
+	return change;		
+}
+
+/*
+ * AC'97 mute controls
+ */
+#define aureon_ac97_mute_info	aureon_mono_bool_info
+
+static int aureon_ac97_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+
+	down(&ice->gpio_mutex);
+
+	ucontrol->value.integer.value[0] = aureon_ac97_read(ice, kcontrol->private_value & 0x7F) & 0x8000 ? 0 : 1;
+
+	up(&ice->gpio_mutex);
+	return 0;
+}
+
+static int aureon_ac97_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned short ovol, nvol;
+	int change;
+
+	snd_ice1712_save_gpio_status(ice);
+	
+	ovol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
+	nvol = (ucontrol->value.integer.value[0] ? 0x0000 : 0x8000) | (ovol & ~	0x8000);
+	
+	if ((change = (ovol != nvol)))
+		aureon_ac97_write(ice, kcontrol->private_value & 0x7F, nvol);
+		
+	snd_ice1712_restore_gpio_status(ice);
+
+	return change;
+}
+
+/*
+ * AC'97 mute controls
+ */
+#define aureon_ac97_micboost_info	aureon_mono_bool_info
+
+static int aureon_ac97_micboost_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+
+	down(&ice->gpio_mutex);
+
+	ucontrol->value.integer.value[0] = aureon_ac97_read(ice, AC97_MIC) & 0x0020 ? 0 : 1;
+
+	up(&ice->gpio_mutex);
+	return 0;
+}
+
+static int aureon_ac97_micboost_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned short ovol, nvol;
+	int change;
+
+	snd_ice1712_save_gpio_status(ice);
+	
+	ovol = aureon_ac97_read(ice, AC97_MIC);
+	nvol = (ucontrol->value.integer.value[0] ? 0x0000 : 0x0020) | (ovol & ~0x0020);
+	
+	if ((change = (ovol != nvol)))
+		aureon_ac97_write(ice, AC97_MIC, nvol);
+		
+	snd_ice1712_restore_gpio_status(ice);
+
+	return change;
+}
 
 /*
  * write data in the SPI mode
@@ -179,78 +408,177 @@
 }
 
 /*
+ * AC'97 master playback mute controls (Mute on WM8770 chip)
+ */
+#define aureon_ac97_mmute_info	aureon_mono_bool_info
+
+static int aureon_ac97_mmute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+
+	down(&ice->gpio_mutex);
+
+	ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX1) >> 1) & 0x01;
+
+	up(&ice->gpio_mutex);
+	return 0;
+}
+
+static int aureon_ac97_mmute_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) {
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned short ovol, nvol;
+	int change;
+	
+	snd_ice1712_save_gpio_status(ice);
+	
+	ovol = wm_get(ice, WM_OUT_MUX1);
+	nvol = (ovol & ~0x02) | (ucontrol->value.integer.value[0] ? 0x02 : 0x00);
+	if ((change = (ovol != nvol)))
+		wm_put(ice, WM_OUT_MUX1, nvol);
+		
+	snd_ice1712_restore_gpio_status(ice);
+
+	return change;
+}
+
+/*
+ * Logarithmic volume values for WM8770
+ * Computed as 20 * Log10(255 / x)
+ */
+static unsigned char wm_vol[256] = {
+	127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23,
+	23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,
+	17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13,
+	13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
+	11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8,
+	8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
+	6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+	5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3,
+	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0
+};
+
+#define WM_VOL_MAX	(sizeof(wm_vol) - 1)
+#define WM_VOL_MUTE	0x8000
+
+static void wm_set_vol(ice1712_t *ice, unsigned int index, unsigned short vol, unsigned short master)
+{
+	unsigned char nvol;
+	
+	if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE))
+		nvol = 0;
+	else
+		nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX];
+	
+	wm_put(ice, index, nvol);
+	wm_put_nocache(ice, index, 0x180 | nvol);
+}
+
+/*
  * DAC mute control
  */
-#define wm_dac_mute_info	aureon_mono_bool_info
+#define wm_pcm_mute_info	aureon_mono_bool_info
 
-static int wm_dac_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int wm_pcm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
 	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-	unsigned short val;
 
 	down(&ice->gpio_mutex);
-	val = wm_get(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_MUTE);
-	ucontrol->value.integer.value[0] = ~val>>4 & 0x1;
+	ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1;
 	up(&ice->gpio_mutex);
 	return 0;
 }
 
-static int wm_dac_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int wm_pcm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
 	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-	unsigned short new, old;
+	unsigned short nval, oval;
 	int change;
 
 	snd_ice1712_save_gpio_status(ice);
-	old = wm_get(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_MUTE);
-	new = (~ucontrol->value.integer.value[0]<<4&0x10) | (old&~0x10);
-	change = (new != old);
-	if (change)
-		wm_put(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_MUTE, new);
+	oval = wm_get(ice, WM_MUTE);
+	nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);
+	if ((change = (nval != oval)))
+		wm_put(ice, WM_MUTE, nval);
 	snd_ice1712_restore_gpio_status(ice);
 
 	return change;
 }
 
 /*
+ * Master volume attenuation mixer control
+ */
+static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+	uinfo->count = 2;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = WM_VOL_MAX;
+	return 0;
+}
+
+static int wm_master_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int i;
+	for (i=0; i<2; i++)
+		ucontrol->value.integer.value[i] = ice->spec.aureon.master[i] & ~WM_VOL_MUTE;
+	return 0;
+}
+
+static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int ch, change = 0;
+
+	snd_ice1712_save_gpio_status(ice);
+	for (ch = 0; ch < 2; ch++) {
+		if (ucontrol->value.integer.value[ch] != ice->spec.aureon.master[ch]) {
+			int dac;
+			ice->spec.aureon.master[ch] &= WM_VOL_MUTE;
+			ice->spec.aureon.master[ch] |= ucontrol->value.integer.value[ch];
+			for (dac = 0; dac < ice->num_total_dacs; dac += 2)
+				wm_set_vol(ice, WM_DAC_ATTEN + dac + ch,
+					   ice->spec.aureon.vol[dac + ch],
+					   ice->spec.aureon.master[ch]);
+			change = 1;
+		}
+	}
+	snd_ice1712_restore_gpio_status(ice);
+	return change;
+}
+
+/*
  * DAC volume attenuation mixer control
  */
-static int wm_dac_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+static int wm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
 {
 	int voices = kcontrol->private_value >> 8;
 	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
 	uinfo->count = voices;
 	uinfo->value.integer.min = 0;		/* mute (-101dB) */
-	uinfo->value.integer.max = 101;		/* 0dB */
+	uinfo->value.integer.max = 0x7F;	/* 0dB */
 	return 0;
 }
 
-static int wm_dac_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int wm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
 	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-	int i, idx, ofs, voices;
-	unsigned short vol;
+	int i, ofs, voices;
 
 	voices = kcontrol->private_value >> 8;
 	ofs = kcontrol->private_value & 0xff;
-	down(&ice->gpio_mutex);
-	for (i = 0; i < voices; i++) {
-		idx  = WM_DAC_ATTEN + ofs + i;
-		vol = wm_get(ice, idx) & 0x7f;
-		if (vol <= 0x1a)
-			ucontrol->value.integer.value[i] = 0;
-		else
-			ucontrol->value.integer.value[i] = vol - 0x1a;
-	}
-	up(&ice->gpio_mutex);
+	for (i = 0; i < voices; i++)
+		ucontrol->value.integer.value[i] = ice->spec.aureon.vol[ofs+i] & ~WM_VOL_MUTE;
 	return 0;
 }
 
-static int wm_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int wm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
 	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
 	int i, idx, ofs, voices;
-	unsigned short ovol, nvol;
 	int change = 0;
 
 	voices = kcontrol->private_value >> 8;
@@ -258,13 +586,11 @@
 	snd_ice1712_save_gpio_status(ice);
 	for (i = 0; i < voices; i++) {
 		idx  = WM_DAC_ATTEN + ofs + i;
-		nvol = ucontrol->value.integer.value[i] + 0x1a;
-		ovol = wm_get(ice, idx) & 0x7f;
-		if (ovol != nvol) {
-			if (nvol <= 0x1a && ovol <= 0x1a)
-				continue;
-			wm_put(ice, idx, nvol | 0x80); /* zero-detect, prelatch */
-			wm_put_nocache(ice, idx, nvol | 0x180); /* update */
+		if (ucontrol->value.integer.value[i] != ice->spec.aureon.vol[ofs+i]) {
+			ice->spec.aureon.vol[ofs+i] &= WM_VOL_MUTE;
+			ice->spec.aureon.vol[ofs+i] |= ucontrol->value.integer.value[i];
+			wm_set_vol(ice, idx, ice->spec.aureon.vol[ofs+i],
+				   ice->spec.aureon.master[i]);
 			change = 1;
 		}
 	}
@@ -272,33 +598,127 @@
 	return change;
 }
 
+/*
+ * WM8770 mute control
+ */
+static int wm_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) {
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = kcontrol->private_value >> 8;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
+static int wm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int voices, ofs, i;
+	
+	voices = kcontrol->private_value >> 8;
+	ofs = kcontrol->private_value & 0xFF;
+
+	for (i = 0; i < voices; i++)
+		ucontrol->value.integer.value[i] = (ice->spec.aureon.vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;
+	return 0;
+}
+
+static int wm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int change = 0, voices, ofs, i;
+
+	voices = kcontrol->private_value >> 8;
+	ofs = kcontrol->private_value & 0xFF;
+
+	snd_ice1712_save_gpio_status(ice);
+	for (i = 0; i < voices; i++) {
+		int val = (ice->spec.aureon.vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
+		if (ucontrol->value.integer.value[i] != val) {
+			ice->spec.aureon.vol[ofs + i] &= ~WM_VOL_MUTE;
+			ice->spec.aureon.vol[ofs + i] |=
+				ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
+			wm_set_vol(ice, ofs + i, ice->spec.aureon.vol[ofs + i],
+				   ice->spec.aureon.master[i]);
+			change = 1;
+		}
+	}
+	snd_ice1712_restore_gpio_status(ice);
+
+	return change;
+}
+
+/*
+ * WM8770 master mute control
+ */
+static int wm_master_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) {
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = 2;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
+static int wm_master_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	
+	ucontrol->value.integer.value[0] = (ice->spec.aureon.master[0] & WM_VOL_MUTE) ? 0 : 1;
+	ucontrol->value.integer.value[1] = (ice->spec.aureon.master[1] & WM_VOL_MUTE) ? 0 : 1;
+	return 0;
+}
+
+static int wm_master_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int change = 0, i;
+
+	snd_ice1712_save_gpio_status(ice);
+	for (i = 0; i < 2; i++) {
+		int val = (ice->spec.aureon.master[i] & WM_VOL_MUTE) ? 0 : 1;
+		if (ucontrol->value.integer.value[i] != val) {
+			int dac;
+			ice->spec.aureon.master[i] &= ~WM_VOL_MUTE;
+			ice->spec.aureon.master[i] |=
+				ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
+			for (dac = 0; dac < ice->num_total_dacs; dac += 2)
+				wm_set_vol(ice, WM_DAC_ATTEN + dac + i,
+					   ice->spec.aureon.vol[dac + i],
+					   ice->spec.aureon.master[i]);
+			change = 1;
+		}
+	}
+	snd_ice1712_restore_gpio_status(ice);
+
+	return change;
+}
+
 /* digital master volume */
-#define MASTER_0dB 0xff
-#define MASTER_RES 128	/* -64dB */
-#define MASTER_MIN (MASTER_0dB - MASTER_RES)
-static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+#define PCM_0dB 0xff
+#define PCM_RES 128	/* -64dB */
+#define PCM_MIN (PCM_0dB - PCM_RES)
+static int wm_pcm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
 {
 	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
 	uinfo->count = 1;
 	uinfo->value.integer.min = 0;		/* mute (-64dB) */
-	uinfo->value.integer.max = MASTER_RES;	/* 0dB */
+	uinfo->value.integer.max = PCM_RES;	/* 0dB */
 	return 0;
 }
 
-static int wm_master_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int wm_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
 	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
 	unsigned short val;
 
 	down(&ice->gpio_mutex);
 	val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
-	val = val > MASTER_MIN ? (val - MASTER_MIN) : 0;
+	val = val > PCM_MIN ? (val - PCM_MIN) : 0;
 	ucontrol->value.integer.value[0] = val;
 	up(&ice->gpio_mutex);
 	return 0;
 }
 
-static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int wm_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
 	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
 	unsigned short ovol, nvol;
@@ -306,7 +726,7 @@
 
 	snd_ice1712_save_gpio_status(ice);
 	nvol = ucontrol->value.integer.value[0];
-	nvol = (nvol ? (nvol + MASTER_MIN) : 0) & 0xff;
+	nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff;
 	ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
 	if (ovol != nvol) {
 		wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */
@@ -355,7 +775,7 @@
 		old = wm_get(ice, WM_ADC_GAIN + i);
 		new = (~ucontrol->value.integer.value[i]<<5&0x20) | (old&~0x20);
 		if (new != old) {
-			wm_put(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_ADC_GAIN, new);
+			wm_put(ice, WM_ADC_GAIN + i, new);
 			change = 1;
 		}
 	}
@@ -589,42 +1009,96 @@
 static snd_kcontrol_new_t aureon_dac_controls[] __devinitdata = {
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Master Playback Switch",
+		.info = wm_master_mute_info,
+		.get = wm_master_mute_get,
+		.put = wm_master_mute_put
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Master Playback Volume",
+		.info = wm_master_vol_info,
+		.get = wm_master_vol_get,
+		.put = wm_master_vol_put
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Front Playback Switch",
+		.info = wm_mute_info,
+		.get = wm_mute_get,
+		.put = wm_mute_put,
+		.private_value = (2 << 8) | 0
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 		.name = "Front Playback Volume",
-		.info = wm_dac_vol_info,
-		.get = wm_dac_vol_get,
-		.put = wm_dac_vol_put,
+		.info = wm_vol_info,
+		.get = wm_vol_get,
+		.put = wm_vol_put,
 		.private_value = (2 << 8) | 0
 	},
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Rear Playback Switch",
+		.info = wm_mute_info,
+		.get = wm_mute_get,
+		.put = wm_mute_put,
+		.private_value = (2 << 8) | 2
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 		.name = "Rear Playback Volume",
-		.info = wm_dac_vol_info,
-		.get = wm_dac_vol_get,
-		.put = wm_dac_vol_put,
+		.info = wm_vol_info,
+		.get = wm_vol_get,
+		.put = wm_vol_put,
 		.private_value = (2 << 8) | 2
 	},
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Center Playback Switch",
+		.info = wm_mute_info,
+		.get = wm_mute_get,
+		.put = wm_mute_put,
+		.private_value = (1 << 8) | 4
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 		.name = "Center Playback Volume",
-		.info = wm_dac_vol_info,
-		.get = wm_dac_vol_get,
-		.put = wm_dac_vol_put,
+		.info = wm_vol_info,
+		.get = wm_vol_get,
+		.put = wm_vol_put,
 		.private_value = (1 << 8) | 4
 	},
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "LFE Playback Switch",
+		.info = wm_mute_info,
+		.get = wm_mute_get,
+		.put = wm_mute_put,
+		.private_value = (1 << 8) | 5
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 		.name = "LFE Playback Volume",
-		.info = wm_dac_vol_info,
-		.get = wm_dac_vol_get,
-		.put = wm_dac_vol_put,
+		.info = wm_vol_info,
+		.get = wm_vol_get,
+		.put = wm_vol_put,
 		.private_value = (1 << 8) | 5
 	},
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Side Playback Switch",
+		.info = wm_mute_info,
+		.get = wm_mute_get,
+		.put = wm_mute_put,
+		.private_value = (2 << 8) | 6
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 		.name = "Side Playback Volume",
-		.info = wm_dac_vol_info,
-		.get = wm_dac_vol_get,
-		.put = wm_dac_vol_put,
+		.info = wm_vol_info,
+		.get = wm_vol_get,
+		.put = wm_vol_put,
 		.private_value = (2 << 8) | 6
 	}
 };
@@ -632,17 +1106,17 @@
 static snd_kcontrol_new_t wm_controls[] __devinitdata = {
  	{
  		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "Master Playback Switch",
-		.info = wm_dac_mute_info,
-		.get = wm_dac_mute_get,
-		.put = wm_dac_mute_put,
+		.name = "PCM Playback Switch",
+		.info = wm_pcm_mute_info,
+		.get = wm_pcm_mute_get,
+		.put = wm_pcm_mute_put
  	},
  	{
  		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "Master Playback Volume",
-		.info = wm_master_vol_info,
-		.get = wm_master_vol_get,
-		.put = wm_master_vol_put,
+		.name = "PCM Playback Volume",
+		.info = wm_pcm_vol_info,
+		.get = wm_pcm_vol_get,
+		.put = wm_pcm_vol_put
  	},
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -650,14 +1124,13 @@
 		.info = wm_adc_mute_info,
 		.get = wm_adc_mute_get,
 		.put = wm_adc_mute_put,
-
 	},
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 		.name = "Capture Volume",
 		.info = wm_adc_vol_info,
 		.get = wm_adc_vol_get,
-		.put = wm_adc_vol_put,
+		.put = wm_adc_vol_put
 	},
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -665,6 +1138,7 @@
 		.info = wm_adc_mux_info,
 		.get = wm_adc_mux_get,
 		.put = wm_adc_mux_put,
+		.private_value = 5
 	},
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -689,7 +1163,96 @@
 	},
 };
 
-
+static snd_kcontrol_new_t ac97_controls[] __devinitdata = {
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "AC97 Playback Switch",
+		.info = aureon_ac97_mmute_info,
+		.get = aureon_ac97_mmute_get,
+		.put = aureon_ac97_mmute_put,
+		.private_value = AC97_MASTER
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "AC97 Playback Volume",
+ 		.info = aureon_ac97_vol_info,
+ 		.get = aureon_ac97_vol_get,
+ 		.put = aureon_ac97_vol_put,
+ 		.private_value = AC97_MASTER|AUREON_AC97_STEREO
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "CD Playback Switch",
+ 		.info = aureon_ac97_mute_info,
+ 		.get = aureon_ac97_mute_get,
+ 		.put = aureon_ac97_mute_put,
+ 		.private_value = AC97_CD
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "CD Playback Volume",
+ 		.info = aureon_ac97_vol_info,
+ 		.get = aureon_ac97_vol_get,
+ 		.put = aureon_ac97_vol_put,
+ 		.private_value = AC97_CD|AUREON_AC97_STEREO
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "Aux Playback Switch",
+ 		.info = aureon_ac97_mute_info,
+ 		.get = aureon_ac97_mute_get,
+ 		.put = aureon_ac97_mute_put,
+ 		.private_value = AC97_AUX,
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "Aux Playback Volume",
+ 		.info = aureon_ac97_vol_info,
+ 		.get = aureon_ac97_vol_get,
+ 		.put = aureon_ac97_vol_put,
+ 		.private_value = AC97_AUX|AUREON_AC97_STEREO
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "Line Playback Switch",
+ 		.info = aureon_ac97_mute_info,
+ 		.get = aureon_ac97_mute_get,
+ 		.put = aureon_ac97_mute_put,
+ 		.private_value = AC97_LINE
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "Line Playback Volume",
+ 		.info = aureon_ac97_vol_info,
+ 		.get = aureon_ac97_vol_get,
+ 		.put = aureon_ac97_vol_put,
+ 		.private_value = AC97_LINE|AUREON_AC97_STEREO
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "Mic Playback Switch",
+ 		.info = aureon_ac97_mute_info,
+ 		.get = aureon_ac97_mute_get,
+ 		.put = aureon_ac97_mute_put,
+ 		.private_value = AC97_MIC
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "Mic Playback Volume",
+ 		.info = aureon_ac97_vol_info,
+ 		.get = aureon_ac97_vol_get,
+ 		.put = aureon_ac97_vol_put,
+ 		.private_value = AC97_MIC
+ 	},
+ 	{
+ 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ 		.name = "Mic Boost",
+ 		.info = aureon_ac97_micboost_info,
+ 		.get = aureon_ac97_micboost_get,
+ 		.put = aureon_ac97_micboost_put
+ 	}
+};
+ 
 static int __devinit aureon_add_controls(ice1712_t *ice)
 {
 	unsigned int i, counts;
@@ -697,7 +1260,7 @@
 
 	counts = ARRAY_SIZE(aureon_dac_controls);
 	if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY)
-		counts--; /* no side */
+		counts -= 2; /* no side */
 	for (i = 0; i < counts; i++) {
 		err = snd_ctl_add(ice->card, snd_ctl_new1(&aureon_dac_controls[i], ice));
 		if (err < 0)
@@ -709,6 +1272,13 @@
 		if (err < 0)
 			return err;
 	}
+	
+	for (i = 0; i < ARRAY_SIZE(ac97_controls); i++) {
+		err = snd_ctl_add(ice->card, snd_ctl_new1(&ac97_controls[i], ice));
+		if (err < 0)
+			return err;
+	}
+	
 	return 0;
 }
 
@@ -720,9 +1290,9 @@
 {
 	static unsigned short wm_inits_aureon[] = {
 		/* These come first to reduce init pop noise */
-		0x1b, 0x000,		/* ADC Mux */
-		0x1c, 0x009,		/* Out Mux1 */
-		0x1d, 0x009,		/* Out Mux2 */
+		0x1b, 0x005,		/* ADC Mux (AC'97 source) */
+		0x1c, 0x00B,		/* Out Mux1 (VOUT1 = ADC+AUX, VOUT2 = ADC) */
+		0x1d, 0x009,		/* Out Mux2 (VOUT2 = ADC, VOUT3 = ADC) */
 
 		0x18, 0x000,		/* All power-up */
 
@@ -798,14 +1368,15 @@
 	};
 	static unsigned short cs_inits[] = {
 		0x0441, /* RUN */
-		0x0100, /* no mute */
-		0x0200, /* */
-		0x0600, /* slave, 24bit */
+		0x0180, /* no mute, OMCK output on RMCK pin */
+		0x0201, /* S/PDIF source on RXP1 */
+		0x0605, /* slave, 24bit, MSB on second OSCLK, SDOUT for right channel when OLRCK is high */
 		(unsigned short)-1
 	};
 	unsigned int tmp;
 	unsigned short *p;
 	unsigned int cscs;
+	int err, i;
 
 	if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY) {
 		ice->num_total_dacs = 6;
@@ -816,23 +1387,27 @@
 		ice->num_total_adcs = 2;
 	}
 
-	/* to remeber the register values */
+	/* to remeber the register values of CS8415 */
 	ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL);
 	if (! ice->akm)
 		return -ENOMEM;
 	ice->akm_codecs = 1;
+	
+	if ((err = aureon_ac97_init(ice)) != 0)
+		return err;
 
 	if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71)
 		cscs = PRODIGY_CS8415_CS;
 	else
 		cscs = AUREON_CS8415_CS;
 
-	snd_ice1712_gpio_set_dir(ice, 0xbfffff); /* fix this for the time being */
+	snd_ice1712_gpio_set_dir(ice, 0x5fffff); /* fix this for the time being */
 
 	/* reset the wm codec as the SPI mode */
 	snd_ice1712_save_gpio_status(ice);
 	snd_ice1712_gpio_set_mask(ice, ~(AUREON_WM_RESET|AUREON_WM_CS|
 					 cscs|AUREON_HP_SEL));
+
 	tmp = snd_ice1712_gpio_read(ice);
 	tmp &= ~AUREON_WM_RESET;
 	snd_ice1712_gpio_write(ice, tmp);
@@ -860,6 +1435,13 @@
 	aureon_set_headphone_amp(ice, 1);
 
 	snd_ice1712_restore_gpio_status(ice);
+	
+	ice->spec.aureon.master[0] = WM_VOL_MUTE;
+	ice->spec.aureon.master[1] = WM_VOL_MUTE;
+	for (i = 0; i < ice->num_total_dacs; i++) {
+		ice->spec.aureon.vol[i] = WM_VOL_MUTE;
+		wm_set_vol(ice, i, ice->spec.aureon.vol[i], ice->spec.aureon.master[i % 2]);
+	}
 
 	return 0;
 }
@@ -873,14 +1455,14 @@
 static unsigned char aureon51_eeprom[] __devinitdata = {
 	0x0a,	/* SYSCONF: clock 512, spdif-in/ADC, 3DACs */
 	0x80,	/* ACLINK: I2S */
-	0xf8,	/* I2S: vol, 96k, 24bit, 192k */
+	0xfc,	/* I2S: vol, 96k, 24bit, 192k */
 	0xc3,	/* SPDIF: out-en, out-int, spdif-in */
 	0xff,	/* GPIO_DIR */
 	0xff,	/* GPIO_DIR1 */
-	0xbf,	/* GPIO_DIR2 */
-	0xff,	/* GPIO_MASK */
-	0xff,	/* GPIO_MASK1 */
-	0xff,	/* GPIO_MASK2 */
+	0x5f,	/* GPIO_DIR2 */
+	0x00,	/* GPIO_MASK */
+	0x00,	/* GPIO_MASK1 */
+	0x00,	/* GPIO_MASK2 */
 	0x00,	/* GPIO_STATE */
 	0x00,	/* GPIO_STATE1 */
 	0x00,	/* GPIO_STATE2 */
@@ -889,11 +1471,11 @@
 static unsigned char aureon71_eeprom[] __devinitdata = {
 	0x0b,	/* SYSCONF: clock 512, spdif-in/ADC, 4DACs */
 	0x80,	/* ACLINK: I2S */
-	0xf8,	/* I2S: vol, 96k, 24bit, 192k */
+	0xfc,	/* I2S: vol, 96k, 24bit, 192k */
 	0xc3,	/* SPDIF: out-en, out-int, spdif-in */
 	0xff,	/* GPIO_DIR */
 	0xff,	/* GPIO_DIR1 */
-	0xbf,	/* GPIO_DIR2 */
+	0x5f,	/* GPIO_DIR2 */
 	0x00,	/* GPIO_MASK */
 	0x00,	/* GPIO_MASK1 */
 	0x00,	/* GPIO_MASK2 */
@@ -905,11 +1487,11 @@
 static unsigned char prodigy71_eeprom[] __devinitdata = {
 	0x0b,	/* SYSCONF: clock 512, spdif-in/ADC, 4DACs */
 	0x80,	/* ACLINK: I2S */
-	0xf8,	/* I2S: vol, 96k, 24bit, 192k */
+	0xfc,	/* I2S: vol, 96k, 24bit, 192k */
 	0xc3,	/* SPDIF: out-en, out-int, spdif-in */
 	0xff,	/* GPIO_DIR */
 	0xff,	/* GPIO_DIR1 */
-	0xbf,	/* GPIO_DIR2 */
+	0x5f,	/* GPIO_DIR2 */
 	0x00,	/* GPIO_MASK */
 	0x00,	/* GPIO_MASK1 */
 	0x00,	/* GPIO_MASK2 */
diff -Nru a/sound/pci/ice1712/aureon.h b/sound/pci/ice1712/aureon.h
--- a/sound/pci/ice1712/aureon.h	2004-12-24 13:37:30 -08:00
+++ b/sound/pci/ice1712/aureon.h	2004-12-24 13:37:30 -08:00
@@ -47,6 +47,11 @@
 #define AUREON_DIGITAL_SEL1	(1 << 15)
 #define AUREON_HP_SEL		(1 << 14)
 #define AUREON_WM_CS		(1 << 12)
+#define AUREON_AC97_COMMIT	(1 << 11)
+#define AUREON_AC97_ADDR	(1 << 10)
+#define AUREON_AC97_DATA_LOW	(1 << 9)
+#define AUREON_AC97_DATA_HIGH	(1 << 8)
+#define AUREON_AC97_DATA_MASK	0xFF
 
 /* Prodigy has different pin assignment for chip select */
 #define PRODIGY_CS8415_CS	(1 << 23)
diff -Nru a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
--- a/sound/pci/ice1712/delta.c	2004-12-24 13:36:18 -08:00
+++ b/sound/pci/ice1712/delta.c	2004-12-24 13:36:18 -08:00
@@ -526,6 +526,7 @@
 		break;
 	case ICE1712_SUBDEVICE_DELTA1010:
 	case ICE1712_SUBDEVICE_DELTA1010LT:
+	case ICE1712_SUBDEVICE_MEDIASTATION:
 		ice->num_total_dacs = 8;
 		ice->num_total_adcs = 8;
 		break;
@@ -551,6 +552,7 @@
 			return err;
 		break;
 	case ICE1712_SUBDEVICE_DELTA1010:
+	case ICE1712_SUBDEVICE_MEDIASTATION:
 		ice->gpio.set_pro_rate = delta_1010_set_rate_val;
 		break;
 	case ICE1712_SUBDEVICE_DELTADIO2496:
@@ -572,6 +574,7 @@
 	switch (ice->eeprom.subvendor) {
 	case ICE1712_SUBDEVICE_DELTA1010:
 	case ICE1712_SUBDEVICE_DELTADIO2496:
+	case ICE1712_SUBDEVICE_MEDIASTATION:
 		return 0;
 	}
 
@@ -630,6 +633,7 @@
 	/* 1010 and dio specific controls */
 	switch (ice->eeprom.subvendor) {
 	case ICE1712_SUBDEVICE_DELTA1010:
+	case ICE1712_SUBDEVICE_MEDIASTATION:
 		err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta1010_wordclock_select, ice));
 		if (err < 0)
 			return err;
@@ -654,6 +658,7 @@
 	case ICE1712_SUBDEVICE_DELTA1010:
 	case ICE1712_SUBDEVICE_DELTADIO2496:
 	case ICE1712_SUBDEVICE_DELTA66:
+	case ICE1712_SUBDEVICE_MEDIASTATION:
 		err = snd_ice1712_spdif_build_controls(ice);
 		if (err < 0)
 			return err;
@@ -665,6 +670,7 @@
 	case ICE1712_SUBDEVICE_DELTA1010:
 	case ICE1712_SUBDEVICE_DELTADIO2496:
 	case ICE1712_SUBDEVICE_DELTA66:
+	case ICE1712_SUBDEVICE_MEDIASTATION:
 		err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta_spdif_in_status, ice));
 		if (err < 0)
 			return err;
@@ -750,6 +756,13 @@
 		.chip_init = snd_ice1712_delta_init,
 		.build_controls = snd_ice1712_delta_add_controls,
 		.no_mpu401 = 1,
+	},
+	{
+		.subvendor = ICE1712_SUBDEVICE_MEDIASTATION,
+		.name = "Lionstracs Mediastation",
+		.model = "mediastation",
+		.chip_init = snd_ice1712_delta_init,
+		.build_controls = snd_ice1712_delta_add_controls,
 	},
 	{ } /* terminator */
 };
diff -Nru a/sound/pci/ice1712/delta.h b/sound/pci/ice1712/delta.h
--- a/sound/pci/ice1712/delta.h	2004-12-24 13:36:55 -08:00
+++ b/sound/pci/ice1712/delta.h	2004-12-24 13:36:55 -08:00
@@ -32,7 +32,8 @@
 		"{MidiMan M Audio,Delta 66},"\
 		"{MidiMan M Audio,Delta 44},"\
 		"{MidiMan M Audio,Audiophile 24/96},"\
-		"{Digigram,VX442},"
+		"{Digigram,VX442},"\
+		"{Lionstracs,Mediastation},"
 
 #define ICE1712_SUBDEVICE_DELTA1010	0x121430d6
 #define ICE1712_SUBDEVICE_DELTADIO2496	0x121431d6
@@ -42,6 +43,7 @@
 #define ICE1712_SUBDEVICE_DELTA410	0x121438d6
 #define ICE1712_SUBDEVICE_DELTA1010LT	0x12143bd6
 #define ICE1712_SUBDEVICE_VX442		0x12143cd6
+#define ICE1712_SUBDEVICE_MEDIASTATION	0x694c0100
 
 /* entry point */
 extern struct snd_ice1712_card_info snd_ice1712_delta_cards[];
diff -Nru a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
--- a/sound/pci/ice1712/ews.c	2004-12-24 13:36:31 -08:00
+++ b/sound/pci/ice1712/ews.c	2004-12-24 13:36:31 -08:00
@@ -38,6 +38,13 @@
 #define SND_CS8404
 #include <sound/cs8403.h>
 
+enum {
+	EWS_I2C_CS8404 = 0, EWS_I2C_PCF1, EWS_I2C_PCF2,
+	EWS_I2C_88D = 0,
+	EWS_I2C_6FIRE = 0
+};
+	
+
 /*
  * access via i2c mode (for EWX 24/96, EWS 88MT&D)
  */
@@ -139,11 +146,11 @@
 
 	snd_assert(chip_mask >= 0 && chip_mask <= 0x0f, return -EINVAL);
 	snd_i2c_lock(ice->i2c);
-	if (snd_i2c_readbytes(ice->i2cdevs[1], &data, 1) != 1)
+	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF2], &data, 1) != 1)
 		goto __error;
 	ndata = (data & 0xf0) | chip_mask;
 	if (ndata != data)
-		if (snd_i2c_sendbytes(ice->i2cdevs[1], &ndata, 1) != 1)
+		if (snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_PCF2], &ndata, 1) != 1)
 			goto __error;
 	snd_i2c_unlock(ice->i2c);
 	return 0;
@@ -224,13 +231,16 @@
 	case ICE1712_SUBDEVICE_EWS88MT:
 	case ICE1712_SUBDEVICE_EWS88MT_NEW:
 	case ICE1712_SUBDEVICE_PHASE88:
-		snd_runtime_check(snd_i2c_sendbytes(ice->cs8404, &bits, 1) == 1, goto _error);
+		if (snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_CS8404], &bits, 1) != 1)
+			goto _error;
 		break;
 	case ICE1712_SUBDEVICE_EWS88D:
-		snd_runtime_check(snd_i2c_readbytes(ice->i2cdevs[0], bytes, 2) == 2, goto _error);
+		if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_88D], bytes, 2) != 2)
+			goto _error;
 		if (bits != bytes[1]) {
 			bytes[1] = bits;
-			snd_runtime_check(snd_i2c_readbytes(ice->i2cdevs[0], bytes, 2) == 2, goto _error);
+			if (snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_88D], bytes, 2) != 2)
+				goto _error;
 		}
 		break;
 	}
@@ -416,7 +426,10 @@
 		ice->num_total_adcs = 8;
 		break;
 	case ICE1712_SUBDEVICE_EWS88D:
-		break; /* no analog */
+		/* Note: not analog but ADAT I/O */
+		ice->num_total_dacs = 8;
+		ice->num_total_adcs = 8;
+		break;
 	case ICE1712_SUBDEVICE_DMX6FIRE:
 		ice->num_total_dacs = 6;
 		ice->num_total_adcs = 6;
@@ -434,7 +447,7 @@
 	/* create i2c devices */
 	switch (ice->eeprom.subvendor) {
 	case ICE1712_SUBDEVICE_DMX6FIRE:
-		if ((err = snd_i2c_device_create(ice->i2c, "PCF9554", ICE1712_6FIRE_PCF9554_ADDR, &ice->i2cdevs[0])) < 0) {
+		if ((err = snd_i2c_device_create(ice->i2c, "PCF9554", ICE1712_6FIRE_PCF9554_ADDR, &ice->spec.i2cdevs[EWS_I2C_6FIRE])) < 0) {
 			snd_printk("PCF9554 initialization failed\n");
 			return err;
 		}
@@ -443,18 +456,18 @@
 	case ICE1712_SUBDEVICE_EWS88MT:
 	case ICE1712_SUBDEVICE_EWS88MT_NEW:
 	case ICE1712_SUBDEVICE_PHASE88:
-		if ((err = snd_i2c_device_create(ice->i2c, "CS8404", ICE1712_EWS88MT_CS8404_ADDR, &ice->cs8404)) < 0)
+		if ((err = snd_i2c_device_create(ice->i2c, "CS8404", ICE1712_EWS88MT_CS8404_ADDR, &ice->spec.i2cdevs[EWS_I2C_CS8404])) < 0)
 			return err;
-		if ((err = snd_i2c_device_create(ice->i2c, "PCF8574 (1st)", ICE1712_EWS88MT_INPUT_ADDR, &ice->i2cdevs[0])) < 0)
+		if ((err = snd_i2c_device_create(ice->i2c, "PCF8574 (1st)", ICE1712_EWS88MT_INPUT_ADDR, &ice->spec.i2cdevs[EWS_I2C_PCF1])) < 0)
 			return err;
-		if ((err = snd_i2c_device_create(ice->i2c, "PCF8574 (2nd)", ICE1712_EWS88MT_OUTPUT_ADDR, &ice->i2cdevs[1])) < 0)
+		if ((err = snd_i2c_device_create(ice->i2c, "PCF8574 (2nd)", ICE1712_EWS88MT_OUTPUT_ADDR, &ice->spec.i2cdevs[EWS_I2C_PCF2])) < 0)
 			return err;
 		/* Check if the front module is connected */
 		if ((err = snd_ice1712_ews88mt_chip_select(ice, 0x0f)) < 0)
 			return err;
 		break;
 	case ICE1712_SUBDEVICE_EWS88D:
-		if ((err = snd_i2c_device_create(ice->i2c, "PCF8575", ICE1712_EWS88D_PCF_ADDR, &ice->i2cdevs[0])) < 0)
+		if ((err = snd_i2c_device_create(ice->i2c, "PCF8575", ICE1712_EWS88D_PCF_ADDR, &ice->spec.i2cdevs[EWS_I2C_88D])) < 0)
 			return err;
 		break;
 	}
@@ -595,7 +608,7 @@
 	unsigned char data;
 
 	snd_i2c_lock(ice->i2c);
-	if (snd_i2c_readbytes(ice->i2cdevs[1], &data, 1) != 1) {
+	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
@@ -611,12 +624,12 @@
 	unsigned char data, ndata;
 
 	snd_i2c_lock(ice->i2c);
-	if (snd_i2c_readbytes(ice->i2cdevs[1], &data, 1) != 1) {
+	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
 	ndata = (data & ~ICE1712_EWS88MT_OUTPUT_SENSE) | (ucontrol->value.enumerated.item[0] ? ICE1712_EWS88MT_OUTPUT_SENSE : 0);
-	if (ndata != data && snd_i2c_sendbytes(ice->i2cdevs[1], &ndata, 1) != 1) {
+	if (ndata != data && snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_PCF2], &ndata, 1) != 1) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
@@ -633,7 +646,7 @@
 
 	snd_assert(channel >= 0 && channel <= 7, return 0);
 	snd_i2c_lock(ice->i2c);
-	if (snd_i2c_readbytes(ice->i2cdevs[0], &data, 1) != 1) {
+	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
@@ -652,12 +665,12 @@
 
 	snd_assert(channel >= 0 && channel <= 7, return 0);
 	snd_i2c_lock(ice->i2c);
-	if (snd_i2c_readbytes(ice->i2cdevs[0], &data, 1) != 1) {
+	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
 	ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));
-	if (ndata != data && snd_i2c_sendbytes(ice->i2cdevs[0], &ndata, 1) != 1) {
+	if (ndata != data && snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_PCF1], &ndata, 1) != 1) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
@@ -704,7 +717,7 @@
 	unsigned char data[2];
 	
 	snd_i2c_lock(ice->i2c);
-	if (snd_i2c_readbytes(ice->i2cdevs[0], data, 2) != 2) {
+	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_88D], data, 2) != 2) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
@@ -725,7 +738,7 @@
 	int change;
 
 	snd_i2c_lock(ice->i2c);
-	if (snd_i2c_readbytes(ice->i2cdevs[0], data, 2) != 2) {
+	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_88D], data, 2) != 2) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
@@ -738,7 +751,7 @@
 			ndata[shift >> 3] |= (1 << (shift & 7));
 	}
 	change = (data[shift >> 3] != ndata[shift >> 3]);
-	if (change && snd_i2c_sendbytes(ice->i2cdevs[0], data, 2) != 2) {
+	if (change && snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_88D], data, 2) != 2) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
@@ -774,9 +787,9 @@
 	unsigned char byte;
 	snd_i2c_lock(ice->i2c);
 	byte = reg;
-	snd_i2c_sendbytes(ice->i2cdevs[0], &byte, 1);
+	snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_6FIRE], &byte, 1);
 	byte = 0;
-	if (snd_i2c_readbytes(ice->i2cdevs[0], &byte, 1) != 1) {
+	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
 		snd_i2c_unlock(ice->i2c);
 		printk("cannot read pca\n");
 		return -EIO;
@@ -791,7 +804,7 @@
 	snd_i2c_lock(ice->i2c);
 	bytes[0] = reg;
 	bytes[1] = data;
-	if (snd_i2c_sendbytes(ice->i2cdevs[0], bytes, 2) != 2) {
+	if (snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_6FIRE], bytes, 2) != 2) {
 		snd_i2c_unlock(ice->i2c);
 		return -EIO;
 	}
diff -Nru a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
--- a/sound/pci/ice1712/hoontech.c	2004-12-24 13:37:00 -08:00
+++ b/sound/pci/ice1712/hoontech.c	2004-12-24 13:37:00 -08:00
@@ -49,24 +49,24 @@
 static void __devinit snd_ice1712_stdsp24_darear(ice1712_t *ice, int activate)
 {
 	down(&ice->gpio_mutex);
-	ICE1712_STDSP24_0_DAREAR(ice->hoontech_boxbits, activate);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[0]);
+	ICE1712_STDSP24_0_DAREAR(ice->spec.hoontech.boxbits, activate);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[0]);
 	up(&ice->gpio_mutex);
 }
 
 static void __devinit snd_ice1712_stdsp24_mute(ice1712_t *ice, int activate)
 {
 	down(&ice->gpio_mutex);
-	ICE1712_STDSP24_3_MUTE(ice->hoontech_boxbits, activate);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[3]);
+	ICE1712_STDSP24_3_MUTE(ice->spec.hoontech.boxbits, activate);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]);
 	up(&ice->gpio_mutex);
 }
 
 static void __devinit snd_ice1712_stdsp24_insel(ice1712_t *ice, int activate)
 {
 	down(&ice->gpio_mutex);
-	ICE1712_STDSP24_3_INSEL(ice->hoontech_boxbits, activate);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[3]);
+	ICE1712_STDSP24_3_INSEL(ice->spec.hoontech.boxbits, activate);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]);
 	up(&ice->gpio_mutex);
 }
 
@@ -75,45 +75,45 @@
 	down(&ice->gpio_mutex);
 
 	/* select box */
-	ICE1712_STDSP24_0_BOX(ice->hoontech_boxbits, box);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[0]);
+	ICE1712_STDSP24_0_BOX(ice->spec.hoontech.boxbits, box);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[0]);
 
 	/* prepare for write */
 	if (chn == 3)
-		ICE1712_STDSP24_2_CHN4(ice->hoontech_boxbits, 0);
-	ICE1712_STDSP24_2_MIDI1(ice->hoontech_boxbits, activate);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[3]);
-
-	ICE1712_STDSP24_1_CHN1(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_1_CHN2(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_1_CHN3(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_2_CHN4(ice->hoontech_boxbits, 1);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[1]);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
+		ICE1712_STDSP24_2_CHN4(ice->spec.hoontech.boxbits, 0);
+	ICE1712_STDSP24_2_MIDI1(ice->spec.hoontech.boxbits, activate);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]);
+
+	ICE1712_STDSP24_1_CHN1(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_1_CHN2(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_1_CHN3(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_2_CHN4(ice->spec.hoontech.boxbits, 1);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[1]);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
 	udelay(100);
 	if (chn == 3) {
-		ICE1712_STDSP24_2_CHN4(ice->hoontech_boxbits, 0);
-		snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
+		ICE1712_STDSP24_2_CHN4(ice->spec.hoontech.boxbits, 0);
+		snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
 	} else {
 		switch (chn) {
-		case 0:	ICE1712_STDSP24_1_CHN1(ice->hoontech_boxbits, 0); break;
-		case 1:	ICE1712_STDSP24_1_CHN2(ice->hoontech_boxbits, 0); break;
-		case 2:	ICE1712_STDSP24_1_CHN3(ice->hoontech_boxbits, 0); break;
+		case 0:	ICE1712_STDSP24_1_CHN1(ice->spec.hoontech.boxbits, 0); break;
+		case 1:	ICE1712_STDSP24_1_CHN2(ice->spec.hoontech.boxbits, 0); break;
+		case 2:	ICE1712_STDSP24_1_CHN3(ice->spec.hoontech.boxbits, 0); break;
 		}
-		snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[1]);
+		snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[1]);
 	}
 	udelay(100);
-	ICE1712_STDSP24_1_CHN1(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_1_CHN2(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_1_CHN3(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_2_CHN4(ice->hoontech_boxbits, 1);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[1]);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
+	ICE1712_STDSP24_1_CHN1(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_1_CHN2(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_1_CHN3(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_2_CHN4(ice->spec.hoontech.boxbits, 1);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[1]);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
 	udelay(100);
 
-	ICE1712_STDSP24_2_MIDI1(ice->hoontech_boxbits, 0);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
+	ICE1712_STDSP24_2_MIDI1(ice->spec.hoontech.boxbits, 0);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
 
 	up(&ice->gpio_mutex);
 }
@@ -123,23 +123,23 @@
 	down(&ice->gpio_mutex);
 
 	/* select box */
-	ICE1712_STDSP24_0_BOX(ice->hoontech_boxbits, box);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[0]);
+	ICE1712_STDSP24_0_BOX(ice->spec.hoontech.boxbits, box);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[0]);
 
-	ICE1712_STDSP24_2_MIDIIN(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_2_MIDI1(ice->hoontech_boxbits, master);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[3]);
+	ICE1712_STDSP24_2_MIDIIN(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_2_MIDI1(ice->spec.hoontech.boxbits, master);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]);
 
 	udelay(100);
 	
-	ICE1712_STDSP24_2_MIDIIN(ice->hoontech_boxbits, 0);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
+	ICE1712_STDSP24_2_MIDIIN(ice->spec.hoontech.boxbits, 0);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
 	
 	mdelay(10);
 	
-	ICE1712_STDSP24_2_MIDIIN(ice->hoontech_boxbits, 1);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
+	ICE1712_STDSP24_2_MIDIIN(ice->spec.hoontech.boxbits, 1);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[2]);
 
 	up(&ice->gpio_mutex);
 }
@@ -147,8 +147,8 @@
 static void __devinit snd_ice1712_stdsp24_midi2(ice1712_t *ice, int activate)
 {
 	down(&ice->gpio_mutex);
-	ICE1712_STDSP24_3_MIDI2(ice->hoontech_boxbits, activate);
-	snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[3]);
+	ICE1712_STDSP24_3_MIDI2(ice->spec.hoontech.boxbits, activate);
+	snd_ice1712_stdsp24_gpio_write(ice, ice->spec.hoontech.boxbits[3]);
 	up(&ice->gpio_mutex);
 }
 
@@ -159,57 +159,57 @@
 	ice->num_total_dacs = 8;
 	ice->num_total_adcs = 8;
 
-	ice->hoontech_boxbits[0] = 
-	ice->hoontech_boxbits[1] = 
-	ice->hoontech_boxbits[2] = 
-	ice->hoontech_boxbits[3] = 0;	/* should be already */
-
-	ICE1712_STDSP24_SET_ADDR(ice->hoontech_boxbits, 0);
-	ICE1712_STDSP24_CLOCK(ice->hoontech_boxbits, 0, 1);
-	ICE1712_STDSP24_0_BOX(ice->hoontech_boxbits, 0);
-	ICE1712_STDSP24_0_DAREAR(ice->hoontech_boxbits, 0);
-
-	ICE1712_STDSP24_SET_ADDR(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_CLOCK(ice->hoontech_boxbits, 1, 1);
-	ICE1712_STDSP24_1_CHN1(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_1_CHN2(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_1_CHN3(ice->hoontech_boxbits, 1);
+	ice->spec.hoontech.boxbits[0] = 
+	ice->spec.hoontech.boxbits[1] = 
+	ice->spec.hoontech.boxbits[2] = 
+	ice->spec.hoontech.boxbits[3] = 0;	/* should be already */
+
+	ICE1712_STDSP24_SET_ADDR(ice->spec.hoontech.boxbits, 0);
+	ICE1712_STDSP24_CLOCK(ice->spec.hoontech.boxbits, 0, 1);
+	ICE1712_STDSP24_0_BOX(ice->spec.hoontech.boxbits, 0);
+	ICE1712_STDSP24_0_DAREAR(ice->spec.hoontech.boxbits, 0);
+
+	ICE1712_STDSP24_SET_ADDR(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_CLOCK(ice->spec.hoontech.boxbits, 1, 1);
+	ICE1712_STDSP24_1_CHN1(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_1_CHN2(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_1_CHN3(ice->spec.hoontech.boxbits, 1);
 	
-	ICE1712_STDSP24_SET_ADDR(ice->hoontech_boxbits, 2);
-	ICE1712_STDSP24_CLOCK(ice->hoontech_boxbits, 2, 1);
-	ICE1712_STDSP24_2_CHN4(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_2_MIDIIN(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_2_MIDI1(ice->hoontech_boxbits, 0);
-
-	ICE1712_STDSP24_SET_ADDR(ice->hoontech_boxbits, 3);
-	ICE1712_STDSP24_CLOCK(ice->hoontech_boxbits, 3, 1);
-	ICE1712_STDSP24_3_MIDI2(ice->hoontech_boxbits, 0);
-	ICE1712_STDSP24_3_MUTE(ice->hoontech_boxbits, 1);
-	ICE1712_STDSP24_3_INSEL(ice->hoontech_boxbits, 0);
+	ICE1712_STDSP24_SET_ADDR(ice->spec.hoontech.boxbits, 2);
+	ICE1712_STDSP24_CLOCK(ice->spec.hoontech.boxbits, 2, 1);
+	ICE1712_STDSP24_2_CHN4(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_2_MIDIIN(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_2_MIDI1(ice->spec.hoontech.boxbits, 0);
+
+	ICE1712_STDSP24_SET_ADDR(ice->spec.hoontech.boxbits, 3);
+	ICE1712_STDSP24_CLOCK(ice->spec.hoontech.boxbits, 3, 1);
+	ICE1712_STDSP24_3_MIDI2(ice->spec.hoontech.boxbits, 0);
+	ICE1712_STDSP24_3_MUTE(ice->spec.hoontech.boxbits, 1);
+	ICE1712_STDSP24_3_INSEL(ice->spec.hoontech.boxbits, 0);
 
 	/* let's go - activate only functions in first box */
-	ice->hoontech_config = 0;
+	ice->spec.hoontech.config = 0;
 			    /* ICE1712_STDSP24_MUTE |
 			       ICE1712_STDSP24_INSEL |
 			       ICE1712_STDSP24_DAREAR; */
-	ice->hoontech_boxconfig[0] = ICE1712_STDSP24_BOX_CHN1 |
+	ice->spec.hoontech.boxconfig[0] = ICE1712_STDSP24_BOX_CHN1 |
 				     ICE1712_STDSP24_BOX_CHN2 |
 				     ICE1712_STDSP24_BOX_CHN3 |
 				     ICE1712_STDSP24_BOX_CHN4 |
 				     ICE1712_STDSP24_BOX_MIDI1 |
 				     ICE1712_STDSP24_BOX_MIDI2;
-	ice->hoontech_boxconfig[1] = 
-	ice->hoontech_boxconfig[2] = 
-	ice->hoontech_boxconfig[3] = 0;
-	snd_ice1712_stdsp24_darear(ice, (ice->hoontech_config & ICE1712_STDSP24_DAREAR) ? 1 : 0);
-	snd_ice1712_stdsp24_mute(ice, (ice->hoontech_config & ICE1712_STDSP24_MUTE) ? 1 : 0);
-	snd_ice1712_stdsp24_insel(ice, (ice->hoontech_config & ICE1712_STDSP24_INSEL) ? 1 : 0);
+	ice->spec.hoontech.boxconfig[1] = 
+	ice->spec.hoontech.boxconfig[2] = 
+	ice->spec.hoontech.boxconfig[3] = 0;
+	snd_ice1712_stdsp24_darear(ice, (ice->spec.hoontech.config & ICE1712_STDSP24_DAREAR) ? 1 : 0);
+	snd_ice1712_stdsp24_mute(ice, (ice->spec.hoontech.config & ICE1712_STDSP24_MUTE) ? 1 : 0);
+	snd_ice1712_stdsp24_insel(ice, (ice->spec.hoontech.config & ICE1712_STDSP24_INSEL) ? 1 : 0);
 	for (box = 0; box < 4; box++) {
 		for (chn = 0; chn < 4; chn++)
-			snd_ice1712_stdsp24_box_channel(ice, box, chn, (ice->hoontech_boxconfig[box] & (1 << chn)) ? 1 : 0);
+			snd_ice1712_stdsp24_box_channel(ice, box, chn, (ice->spec.hoontech.boxconfig[box] & (1 << chn)) ? 1 : 0);
 		snd_ice1712_stdsp24_box_midi(ice, box,
-				(ice->hoontech_boxconfig[box] & ICE1712_STDSP24_BOX_MIDI1) ? 1 : 0);
-		if (ice->hoontech_boxconfig[box] & ICE1712_STDSP24_BOX_MIDI2)
+				(ice->spec.hoontech.boxconfig[box] & ICE1712_STDSP24_BOX_MIDI1) ? 1 : 0);
+		if (ice->spec.hoontech.boxconfig[box] & ICE1712_STDSP24_BOX_MIDI2)
 			snd_ice1712_stdsp24_midi2(ice, 1);
 	}
 
diff -Nru a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
--- a/sound/pci/ice1712/ice1712.c	2004-12-24 13:36:47 -08:00
+++ b/sound/pci/ice1712/ice1712.c	2004-12-24 13:36:47 -08:00
@@ -86,19 +86,18 @@
 static char *model[SNDRV_CARDS];
 static int omni[SNDRV_CARDS];	/* Delta44 & 66 Omni I/O support */
 static int cs8427_timeout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 500}; /* CS8427 S/PDIF transciever reset timeout value in msec */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ICE1712 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ICE1712 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable ICE1712 soundcard.");
-module_param_array(omni, bool, boot_devs, 0444);
+module_param_array(omni, bool, NULL, 0444);
 MODULE_PARM_DESC(omni, "Enable Midiman M-Audio Delta Omni I/O support.");
-module_param_array(cs8427_timeout, int, boot_devs, 0444);
+module_param_array(cs8427_timeout, int, NULL, 0444);
 MODULE_PARM_DESC(cs8427_timeout, "Define reset timeout for cs8427 chip in msec resolution.");
-module_param_array(model, charp, boot_devs, 0444);
+module_param_array(model, charp, NULL, 0444);
 MODULE_PARM_DESC(model, "Use the given board model.");
 
 #ifndef PCI_VENDOR_ID_ICE
@@ -2308,28 +2307,47 @@
 {
 	int dev = 0xa0;		/* EEPROM device address */
 	unsigned int i, size;
+	struct snd_ice1712_card_info **tbl, *c;
 
-	if ((inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_EEPROM) == 0) {
-		snd_printk("ICE1712 has not detected EEPROM\n");
-		return -EIO;
-	}
-	if (modelname && *modelname) {
-		struct snd_ice1712_card_info **tbl, *c;
-		for (tbl = card_tables; *tbl; tbl++) {
-			for (c = *tbl; c->subvendor; c++) {
-				if (c->model && !strcmp(modelname, c->model)) {
-					/* use the given subvendor */
-					printk(KERN_INFO "ice1712: Using board model %s\n", c->name);
-					ice->eeprom.subvendor = c->subvendor;
-					break;
-				}
+	if (! modelname || ! *modelname) {
+		ice->eeprom.subvendor = 0;
+		if ((inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_EEPROM) != 0)
+			ice->eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) |
+				(snd_ice1712_read_i2c(ice, dev, 0x01) << 8) | 
+				(snd_ice1712_read_i2c(ice, dev, 0x02) << 16) | 
+				(snd_ice1712_read_i2c(ice, dev, 0x03) << 24);
+		if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) {
+			/* invalid subvendor from EEPROM, try the PCI subststem ID instead */
+			u16 vendor, device;
+			pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID, &vendor);
+			pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device);
+			ice->eeprom.subvendor = ((unsigned int)swab16(vendor) << 16) | swab16(device);
+			if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) {
+				printk(KERN_ERR "ice1712: No valid ID is found\n");
+				return -ENXIO;
 			}
 		}
-	} else
-		ice->eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) |
-			(snd_ice1712_read_i2c(ice, dev, 0x01) << 8) | 
-			(snd_ice1712_read_i2c(ice, dev, 0x02) << 16) | 
-			(snd_ice1712_read_i2c(ice, dev, 0x03) << 24);
+	}
+	for (tbl = card_tables; *tbl; tbl++) {
+		for (c = *tbl; c->subvendor; c++) {
+			if (modelname && c->model && ! strcmp(modelname, c->model)) {
+				printk(KERN_INFO "ice1712: Using board model %s\n", c->name);
+				ice->eeprom.subvendor = c->subvendor;
+			} else if (c->subvendor != ice->eeprom.subvendor)
+				continue;
+			if (! c->eeprom_size || ! c->eeprom_data)
+				goto found;
+			/* if the EEPROM is given by the driver, use it */
+			snd_printdd("using the defined eeprom..\n");
+			ice->eeprom.version = 1;
+			ice->eeprom.size = c->eeprom_size + 6;
+			memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size);
+			goto read_skipped;
+		}
+	}
+	printk(KERN_WARNING "ice1712: No matching model found for ID 0x%x\n", ice->eeprom.subvendor);
+
+ found:
 	ice->eeprom.size = snd_ice1712_read_i2c(ice, dev, 0x04);
 	if (ice->eeprom.size < 6)
 		ice->eeprom.size = 32; /* FIXME: any cards without the correct size? */
@@ -2346,6 +2364,7 @@
 	for (i = 0; i < size; i++)
 		ice->eeprom.data[i] = snd_ice1712_read_i2c(ice, dev, i + 6);
 
+ read_skipped:
 	ice->eeprom.gpiomask = ice->eeprom.data[ICE_EEP1_GPIO_MASK];
 	ice->eeprom.gpiostate = ice->eeprom.data[ICE_EEP1_GPIO_STATE];
 	ice->eeprom.gpiodir = ice->eeprom.data[ICE_EEP1_GPIO_DIR];
@@ -2476,6 +2495,7 @@
 	if (ice->port)
 		pci_release_regions(ice->pci);
 	snd_ice1712_akm4xxx_free(ice);
+	pci_disable_device(ice->pci);
 	kfree(ice);
 	return 0;
 }
@@ -2508,12 +2528,15 @@
 	if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 
 	ice = kcalloc(1, sizeof(*ice), GFP_KERNEL);
-	if (ice == NULL)
+	if (ice == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	ice->omni = omni ? 1 : 0;
 	if (cs8427_timeout < 1)
 		cs8427_timeout = 1;
@@ -2543,6 +2566,7 @@
 
 	if ((err = pci_request_regions(pci, "ICE1712")) < 0) {
 		kfree(ice);
+		pci_disable_device(pci);
 		return err;
 	}
 	ice->port = pci_resource_start(pci, 0);
diff -Nru a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
--- a/sound/pci/ice1712/ice1712.h	2004-12-24 13:36:17 -08:00
+++ b/sound/pci/ice1712/ice1712.h	2004-12-24 13:36:17 -08:00
@@ -331,9 +331,6 @@
 	unsigned int force_rdma1: 1;	/* VT1720/4 - RDMA1 as non-spdif */
 	unsigned int num_total_dacs;	/* total DACs */
 	unsigned int num_total_adcs;	/* total ADCs */
-	unsigned char hoontech_boxbits[4];
-	unsigned int hoontech_config;
-	unsigned short hoontech_boxconfig[4];
 	unsigned int cur_rate;		/* current rate */
 
 	struct semaphore open_mutex;
@@ -344,10 +341,8 @@
 	struct snd_ice1712_spdif spdif;
 
 	snd_i2c_bus_t *i2c;		/* I2C bus */
-	snd_i2c_device_t *cs8404;	/* CS8404A I2C device */
 	snd_i2c_device_t *cs8427;	/* CS8427 I2C device */
 	unsigned int cs8427_timeout;	/* CS8427 reset timeout in HZ/100 */
-	snd_i2c_device_t *i2cdevs[2];	/* additional i2c devices */
 	
 	struct ice1712_gpio {
 		unsigned int direction;		/* current direction bits */
@@ -362,6 +357,25 @@
 		void (*set_pro_rate)(ice1712_t *ice, unsigned int rate);
 	} gpio;
 	struct semaphore gpio_mutex;
+
+	/* other board-specific data */
+	union {
+		/* additional i2c devices for EWS boards*/
+		snd_i2c_device_t *i2cdevs[3];
+		/* AC97 register cache for Aureon */
+		struct aureon_spec {
+			unsigned short stac9744[64];
+			unsigned short master[2];
+			unsigned short vol[8];
+		} aureon;
+		/* Hoontech-specific setting */
+		struct hoontech_spec {
+			unsigned char boxbits[4];
+			unsigned int config;
+			unsigned short boxconfig[4];
+		} hoontech;
+	} spec;
+
 };
 
 
diff -Nru a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
--- a/sound/pci/ice1712/ice1724.c	2004-12-24 13:36:48 -08:00
+++ b/sound/pci/ice1712/ice1724.c	2004-12-24 13:36:48 -08:00
@@ -46,6 +46,7 @@
 #include "aureon.h"
 #include "vt1720_mobo.h"
 #include "pontis.h"
+#include "prodigy192.h"
 
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
@@ -57,6 +58,7 @@
 	       AUREON_DEVICE_DESC
 	       VT1720_MOBO_DEVICE_DESC
 	       PONTIS_DEVICE_DESC
+	       PRODIGY192_DEVICE_DESC
 		"{VIA,VT1720},"
 		"{VIA,VT1724},"
 		"{ICEnsemble,Generic ICE1724},"
@@ -67,15 +69,14 @@
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;		/* Enable this card */
 static char *model[SNDRV_CARDS];
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ICE1724 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for ICE1724 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable ICE1724 soundcard.");
-module_param_array(model, charp, boot_devs, 0444);
+module_param_array(model, charp, NULL, 0444);
 MODULE_PARM_DESC(model, "Use the given board model.");
 
 #ifndef PCI_VENDOR_ID_ICE
@@ -1864,6 +1865,7 @@
 	snd_vt1724_aureon_cards,
 	snd_vt1720_mobo_cards,
 	snd_vt1720_pontis_cards,
+	snd_vt1724_prodigy192_cards,
 	NULL,
 };
 
@@ -2074,6 +2076,7 @@
 	}
 	pci_release_regions(ice->pci);
 	snd_ice1712_akm4xxx_free(ice);
+	pci_disable_device(ice->pci);
 	kfree(ice);
 	return 0;
 }
@@ -2103,8 +2106,10 @@
 		return err;
 
 	ice = kcalloc(1, sizeof(*ice), GFP_KERNEL);
-	if (ice == NULL)
+	if (ice == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	ice->vt1724 = 1;
 	spin_lock_init(&ice->reg_lock);
 	init_MUTEX(&ice->gpio_mutex);
@@ -2122,6 +2127,7 @@
 
 	if ((err = pci_request_regions(pci, "ICE1724")) < 0) {
 		kfree(ice);
+		pci_disable_device(pci);
 		return err;
 	}
 	ice->port = pci_resource_start(pci, 0);
diff -Nru a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/sound/pci/ice1712/prodigy192.c	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,524 @@
+/*
+ *   ALSA driver for ICEnsemble VT1724 (Envy24HT)
+ *
+ *   Lowlevel functions for AudioTrak Prodigy 192 cards
+ *
+ *	Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
+ *      Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
+ *      Copyright (c) 2004 Kouichi ONO <co2b@ceres.dti.ne.jp>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */      
+
+#include <sound/driver.h>
+#include <asm/io.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+
+#include "ice1712.h"
+#include "envy24ht.h"
+#include "prodigy192.h"
+#include "stac946x.h"
+
+static void stac9460_put(ice1712_t *ice, int reg, unsigned char val)
+{
+	snd_vt1724_write_i2c(ice, PRODIGY192_STAC9460_ADDR, reg, val);
+}
+
+static unsigned char stac9460_get(ice1712_t *ice, int reg)
+{
+	return snd_vt1724_read_i2c(ice, PRODIGY192_STAC9460_ADDR, reg);
+}
+
+/*
+ * DAC mute control
+ */
+static int stac9460_dac_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = 1;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
+static int stac9460_dac_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned char val;
+	int idx;
+
+	if (kcontrol->private_value)
+		idx = STAC946X_MASTER_VOLUME;
+	else
+		idx  = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + STAC946X_LF_VOLUME;
+	val = stac9460_get(ice, idx);
+	ucontrol->value.integer.value[0] = (~val >> 7) & 0x1;
+	return 0;
+}
+
+static int stac9460_dac_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned char new, old;
+	int idx;
+	int change;
+
+	if (kcontrol->private_value)
+		idx = STAC946X_MASTER_VOLUME;
+	else
+		idx  = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + STAC946X_LF_VOLUME;
+	old = stac9460_get(ice, idx);
+	new = (~ucontrol->value.integer.value[0]<< 7 & 0x80) | (old & ~0x80);
+	change = (new != old);
+	if (change)
+		stac9460_put(ice, idx, new);
+
+	return change;
+}
+
+/*
+ * DAC volume attenuation mixer control
+ */
+static int stac9460_dac_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+	uinfo->count = 1;
+	uinfo->value.integer.min = 0;			/* mute */
+	uinfo->value.integer.max = 0x7f;		/* 0dB */
+	return 0;
+}
+
+static int stac9460_dac_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int idx;
+	unsigned char vol;
+
+	if (kcontrol->private_value)
+		idx = STAC946X_MASTER_VOLUME;
+	else
+		idx  = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + STAC946X_LF_VOLUME;
+	vol = stac9460_get(ice, idx) & 0x7f;
+	ucontrol->value.integer.value[0] = 0x7f - vol;
+
+	return 0;
+}
+
+static int stac9460_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int idx;
+	unsigned char tmp, ovol, nvol;
+	int change;
+
+	if (kcontrol->private_value)
+		idx = STAC946X_MASTER_VOLUME;
+	else
+		idx  = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + STAC946X_LF_VOLUME;
+	nvol = ucontrol->value.integer.value[0];
+	tmp = stac9460_get(ice, idx);
+	ovol = 0x7f - (tmp & 0x7f);
+	change = (ovol != nvol);
+	if (change) {
+		stac9460_put(ice, idx, (0x7f - nvol) | (tmp & 0x80));
+	}
+	return change;
+}
+
+/*
+ * ADC mute control
+ */
+static int stac9460_adc_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = 2;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
+static int stac9460_adc_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned char val;
+	int i;
+
+	for (i = 0; i < 2; ++i) {
+		val = stac9460_get(ice, STAC946X_MIC_L_VOLUME + i);
+		ucontrol->value.integer.value[i] = ~val>>7 & 0x1;
+	}
+
+	return 0;
+}
+
+static int stac9460_adc_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	unsigned char new, old;
+	int i, reg;
+	int change;
+
+	for (i = 0; i < 2; ++i) {
+		reg = STAC946X_MIC_L_VOLUME + i;
+		old = stac9460_get(ice, reg);
+		new = (~ucontrol->value.integer.value[i]<<7&0x80) | (old&~0x80);
+		change = (new != old);
+		if (change)
+			stac9460_put(ice, reg, new);
+	}
+
+	return change;
+}
+
+/*
+ * ADC gain mixer control
+ */
+static int stac9460_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+	uinfo->count = 2;
+	uinfo->value.integer.min = 0;		/* 0dB */
+	uinfo->value.integer.max = 0x0f;	/* 22.5dB */
+	return 0;
+}
+
+static int stac9460_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int i, reg;
+	unsigned char vol;
+
+	for (i = 0; i < 2; ++i) {
+		reg = STAC946X_MIC_L_VOLUME + i;
+		vol = stac9460_get(ice, reg) & 0x0f;
+		ucontrol->value.integer.value[i] = 0x0f - vol;
+	}
+
+	return 0;
+}
+
+static int stac9460_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int i, reg;
+	unsigned char ovol, nvol;
+	int change;
+
+	for (i = 0; i < 2; ++i) {
+		reg = STAC946X_MIC_L_VOLUME + i;
+		nvol = ucontrol->value.integer.value[i];
+		ovol = 0x0f - stac9460_get(ice, reg);
+		change = ((ovol & 0x0f)  != nvol);
+		if (change)
+			stac9460_put(ice, reg, (0x0f - nvol) | (ovol & ~0x0f));
+	}
+
+	return change;
+}
+
+#if 0
+/*
+ * Headphone Amplifier
+ */
+static int aureon_set_headphone_amp(ice1712_t *ice, int enable)
+{
+	unsigned int tmp, tmp2;
+
+	tmp2 = tmp = snd_ice1712_gpio_read(ice);
+	if (enable)
+		tmp |= AUREON_HP_SEL;
+	else
+		tmp &= ~ AUREON_HP_SEL;
+	if (tmp != tmp2) {
+		snd_ice1712_gpio_write(ice, tmp);
+		return 1;
+	}
+	return 0;
+}
+
+static int aureon_get_headphone_amp(ice1712_t *ice)
+{
+	unsigned int tmp = snd_ice1712_gpio_read(ice);
+
+	return ( tmp & AUREON_HP_SEL )!= 0;
+}
+
+static int aureon_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = 1;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
+static int aureon_hpamp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+
+	ucontrol->value.integer.value[0] = aureon_get_headphone_amp(ice);
+	return 0;
+}
+
+
+static int aureon_hpamp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+
+	return aureon_set_headphone_amp(ice,ucontrol->value.integer.value[0]);
+}
+
+/*
+ * Deemphasis
+ */
+static int aureon_deemp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf;
+	return 0;
+}
+
+static int aureon_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	int temp, temp2;
+	temp2 = temp = wm_get(ice, WM_DAC_CTRL2);
+	if (ucontrol->value.integer.value[0])
+		temp |= 0xf;
+	else
+		temp &= ~0xf;
+	if (temp != temp2) {
+		wm_put(ice, WM_DAC_CTRL2, temp);
+		return 1;
+	}
+	return 0;
+}
+
+/*
+ * ADC Oversampling
+ */
+static int aureon_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
+{
+	static char *texts[2] = { "128x", "64x"	};
+
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+	uinfo->count = 1;
+	uinfo->value.enumerated.items = 2;
+
+	if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+		uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
+	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
+
+        return 0;
+}
+
+static int aureon_oversampling_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+	ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8;
+	return 0;
+}
+
+static int aureon_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	int temp, temp2;
+	ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+
+	temp2 = temp = wm_get(ice, WM_MASTER);
+
+	if (ucontrol->value.enumerated.item[0])
+		temp |= 0x8;
+	else
+		temp &= ~0x8;
+
+	if (temp != temp2) {
+		wm_put(ice, WM_MASTER, temp);
+		return 1;
+	}
+	return 0;
+}
+#endif
+
+/*
+ * mixers
+ */
+
+static snd_kcontrol_new_t stac_controls[] __devinitdata = {
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Master Playback Switch",
+		.info = stac9460_dac_mute_info,
+		.get = stac9460_dac_mute_get,
+		.put = stac9460_dac_mute_put,
+		.private_value = 1,
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Master Playback Volume",
+		.info = stac9460_dac_vol_info,
+		.get = stac9460_dac_vol_get,
+		.put = stac9460_dac_vol_put,
+		.private_value = 1,
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "DAC Switch",
+		.count = 6,
+		.info = stac9460_dac_mute_info,
+		.get = stac9460_dac_mute_get,
+		.put = stac9460_dac_mute_put,
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "DAC Volume",
+		.count = 6,
+		.info = stac9460_dac_vol_info,
+		.get = stac9460_dac_vol_get,
+		.put = stac9460_dac_vol_put,
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "ADC Switch",
+		.count = 1,
+		.info = stac9460_adc_mute_info,
+		.get = stac9460_adc_mute_get,
+		.put = stac9460_adc_mute_put,
+
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "ADC Volume",
+		.count = 1,
+		.info = stac9460_adc_vol_info,
+		.get = stac9460_adc_vol_get,
+		.put = stac9460_adc_vol_put,
+	},
+#if 0
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Capture Route",
+		.info = wm_adc_mux_info,
+		.get = wm_adc_mux_get,
+		.put = wm_adc_mux_put,
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Headphone Amplifier Switch",
+		.info = aureon_bool_info,
+		.get = aureon_hpamp_get,
+		.put = aureon_hpamp_put
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "DAC Deemphasis Switch",
+		.info = aureon_bool_info,
+		.get = aureon_deemp_get,
+		.put = aureon_deemp_put
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "ADC Oversampling",
+		.info = aureon_oversampling_info,
+		.get = aureon_oversampling_get,
+		.put = aureon_oversampling_put
+	},
+#endif
+};
+
+static int __devinit prodigy192_add_controls(ice1712_t *ice)
+{
+	unsigned int i;
+	int err;
+
+	for (i = 0; i < ARRAY_SIZE(stac_controls); i++) {
+		err = snd_ctl_add(ice->card, snd_ctl_new1(&stac_controls[i], ice));
+		if (err < 0)
+			return err;
+	}
+	return 0;
+}
+
+
+/*
+ * initialize the chip
+ */
+static int __devinit prodigy192_init(ice1712_t *ice)
+{
+	static unsigned short stac_inits_prodigy[] = {
+		STAC946X_RESET, 0,
+/*		STAC946X_MASTER_VOLUME, 0,
+		STAC946X_LF_VOLUME, 0,
+		STAC946X_RF_VOLUME, 0,
+		STAC946X_LR_VOLUME, 0,
+		STAC946X_RR_VOLUME, 0,
+		STAC946X_CENTER_VOLUME, 0,
+		STAC946X_LFE_VOLUME, 0,*/
+		(unsigned short)-1
+	};
+	unsigned short *p;
+
+	/* prodigy 192 */
+	ice->num_total_dacs = 6;
+	ice->num_total_adcs = 2;
+	
+	/* initialize codec */
+	p = stac_inits_prodigy;
+	for (; *p != (unsigned short)-1; p += 2)
+		stac9460_put(ice, p[0], p[1]);
+
+	return 0;
+}
+
+
+/*
+ * Aureon boards don't provide the EEPROM data except for the vendor IDs.
+ * hence the driver needs to sets up it properly.
+ */
+
+static unsigned char prodigy71_eeprom[] __devinitdata = {
+	0x2b,	/* SYSCONF: clock 512, mpu401, spdif-in/ADC, 4DACs */
+	0x80,	/* ACLINK: I2S */
+	0xf8,	/* I2S: vol, 96k, 24bit, 192k */
+	0xc3,	/* SPDIF: out-en, out-int, spdif-in */
+	0xff,	/* GPIO_DIR */
+	0xff,	/* GPIO_DIR1 */
+	0xbf,	/* GPIO_DIR2 */
+	0x00,	/* GPIO_MASK */
+	0x00,	/* GPIO_MASK1 */
+	0x00,	/* GPIO_MASK2 */
+	0x00,	/* GPIO_STATE */
+	0x00,	/* GPIO_STATE1 */
+	0x00,	/* GPIO_STATE2 */
+};
+
+
+/* entry point */
+struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {
+	{
+		.subvendor = VT1724_SUBDEVICE_PRODIGY192VE,
+		.name = "Audiotrak Prodigy 192",
+		.model = "prodigy192",
+		.chip_init = prodigy192_init,
+		.build_controls = prodigy192_add_controls,
+		.eeprom_size = sizeof(prodigy71_eeprom),
+		.eeprom_data = prodigy71_eeprom,
+	},
+	{ } /* terminator */
+};
diff -Nru a/sound/pci/ice1712/prodigy192.h b/sound/pci/ice1712/prodigy192.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/sound/pci/ice1712/prodigy192.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,11 @@
+#ifndef __SOUND_PRODIGY192_H
+#define __SOUND_PRODIGY192_H
+
+#define PRODIGY192_DEVICE_DESC 	       "{AudioTrak,Prodigy 192},"
+#define PRODIGY192_STAC9460_ADDR	0x54
+
+#define VT1724_SUBDEVICE_PRODIGY192VE	 0x34495345	/* PRODIGY 192 VE */
+
+extern struct snd_ice1712_card_info  snd_vt1724_prodigy192_cards[];
+
+#endif	/* __SOUND_PRODIGY192_H */
diff -Nru a/sound/pci/ice1712/stac946x.h b/sound/pci/ice1712/stac946x.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/sound/pci/ice1712/stac946x.h	2004-12-24 13:37:44 -08:00
@@ -0,0 +1,25 @@
+#ifndef __SOUND_STAC946X_H
+#define __SOUND_STAC946X_H
+
+#define STAC946X_RESET			0x00
+#define STAC946X_STATUS			0x01
+#define STAC946X_MASTER_VOLUME		0x02
+#define STAC946X_LF_VOLUME		0x03
+#define STAC946X_RF_VOLUME		0x04
+#define STAC946X_LR_VOLUME		0x05
+#define STAC946X_RR_VOLUME		0x06
+#define STAC946X_CENTER_VOLUME		0x07
+#define STAC946X_LFE_VOLUME		0x08
+#define STAC946X_MIC_L_VOLUME		0x09
+#define STAC946X_MIC_R_VOLUME		0x0a
+#define STAC946X_DEEMPHASIS		0x0c
+#define STAC946X_GENERAL_PURPOSE	0x0d
+#define STAC946X_AUDIO_PORT_CONTROL	0x0e
+#define STAC946X_MASTER_CLOCKING	0x0f
+#define STAC946X_POWERDOWN_CTRL1	0x10
+#define STAC946X_POWERDOWN_CTRL2	0x11
+#define STAC946X_REVISION_CODE		0x12
+#define STAC946X_ADDRESS_CONTROL	0x13
+#define STAC946X_ADDRESS		0x14
+
+#endif  /*  __SOUND_STAC946X_H */
diff -Nru a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
--- a/sound/pci/intel8x0.c	2004-12-24 13:37:00 -08:00
+++ b/sound/pci/intel8x0.c	2004-12-24 13:37:00 -08:00
@@ -33,13 +33,11 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
-#include <linux/gameport.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/ac97_codec.h>
 #include <sound/info.h>
-#include <sound/mpu401.h>
 #include <sound/initval.h>
 /* for 440MX workaround */
 #include <asm/pgtable.h>
@@ -64,45 +62,32 @@
 		"{AMD,AMD8111},"
 	        "{ALI,M5455}}");
 
-#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
-#define SUPPORT_JOYSTICK 1
-#endif
-#define SUPPORT_MIDI 1
-
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 static int ac97_quirk[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = AC97_TUNE_DEFAULT};
 static int buggy_irq[SNDRV_CARDS];
-#ifdef SUPPORT_JOYSTICK
-static int joystick[SNDRV_CARDS];
-#endif
+static int xbox[SNDRV_CARDS];
+
 #ifdef SUPPORT_MIDI
 static int mpu_port[SNDRV_CARDS]; /* disabled */
 #endif
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel i8x0 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Intel i8x0 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Intel i8x0 soundcard.");
-module_param_array(ac97_clock, int, boot_devs, 0444);
+module_param_array(ac97_clock, int, NULL, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
-module_param_array(ac97_quirk, int, boot_devs, 0444);
+module_param_array(ac97_quirk, int, NULL, 0444);
 MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
-module_param_array(buggy_irq, bool, boot_devs, 0444);
+module_param_array(buggy_irq, bool, NULL, 0444);
 MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
-#ifdef SUPPORT_JOYSTICK
-module_param_array(joystick, bool, boot_devs, 0444);
-MODULE_PARM_DESC(joystick, "Enable joystick for Intel i8x0 soundcard.");
-#endif
-#ifdef SUPPORT_MIDI
-module_param_array(mpu_port, int, boot_devs, 0444);
-MODULE_PARM_DESC(mpu_port, "MPU401 port # for Intel i8x0 driver.");
-#endif
+module_param_array(xbox, bool, NULL, 0444);
+MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
 
 /*
  *  Direct registers
@@ -406,10 +391,10 @@
 
 	unsigned int mmio;
 	unsigned long addr;
-	void __iomem * remap_addr;
+	void __iomem *remap_addr;
 	unsigned int bm_mmio;
 	unsigned long bmaddr;
-	void __iomem * remap_bmaddr;
+	void __iomem *remap_bmaddr;
 
 	struct pci_dev *pci;
 	snd_card_t *card;
@@ -420,18 +405,21 @@
 
 	unsigned multi4: 1,
 		 multi6: 1,
+		 dra: 1,
 		 smp20bit: 1;
 	unsigned in_ac97_init: 1,
 		 in_sdin_init: 1;
-	unsigned fix_nocache: 1; /* workaround for 440MX */
-	unsigned buggy_irq: 1; /* workaround for buggy mobos */
+	unsigned in_measurement: 1;	/* during ac97 clock measurement */
+	unsigned fix_nocache: 1; 	/* workaround for 440MX */
+	unsigned buggy_irq: 1;		/* workaround for buggy mobos */
+	unsigned xbox: 1;		/* workaround for Xbox AC'97 detection */
+
+	int spdif_idx;	/* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */
 
 	ac97_bus_t *ac97_bus;
 	ac97_t *ac97[3];
 	unsigned int ac97_sdin[3];
 
-	snd_rawmidi_t *rmidi;
-
 	spinlock_t reg_lock;
 	spinlock_t ac97_lock;
 	
@@ -807,7 +795,8 @@
 	}
 
 	ichdev->position += step * ichdev->fragsize1;
-	ichdev->position %= ichdev->size;
+	if (! chip->in_measurement)
+		ichdev->position %= ichdev->size;
 	ichdev->lvi += step;
 	ichdev->lvi &= ICH_REG_LVI_MASK;
 	iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi);
@@ -954,6 +943,7 @@
 	ichdev_t *ichdev = get_ichdev(substream);
 	snd_pcm_runtime_t *runtime = substream->runtime;
 	size_t size = params_buffer_bytes(hw_params);
+	int dbl = params_rate(hw_params) > 48000;
 	int err;
 
 	if (chip->fix_nocache && runtime->dma_area && runtime->dma_bytes < size)
@@ -969,11 +959,11 @@
 	}
 	err = snd_ac97_pcm_open(ichdev->pcm, params_rate(hw_params),
 				params_channels(hw_params),
-				ichdev->pcm->r[0].slots);
+				ichdev->pcm->r[dbl].slots);
 	if (err >= 0) {
 		ichdev->pcm_open_flag = 1;
-		/* FIXME: hack to enable spdif support */
-		if (ichdev->ichd == ICHD_PCMOUT && chip->device_type == DEVICE_SIS)
+		/* Force SPDIF setting */
+		if (ichdev->ichd == ICHD_PCMOUT && chip->spdif_idx < 0)
 			snd_ac97_set_rate(ichdev->pcm->r[0].codec[0], AC97_SPDIF, params_rate(hw_params));
 	}
 	return err;
@@ -994,34 +984,35 @@
 }
 
 static void snd_intel8x0_setup_pcm_out(intel8x0_t *chip,
-				       int channels, int sample_bits)
+				       snd_pcm_runtime_t *runtime)
 {
 	unsigned int cnt;
+	int dbl = runtime->rate > 48000;
 	switch (chip->device_type) {
 	case DEVICE_ALI:
 		cnt = igetdword(chip, ICHREG(ALI_SCR));
 		cnt &= ~ICH_ALI_SC_PCM_246_MASK;
-		if (chip->multi4 && channels == 4)
+		if (runtime->channels == 4 || dbl)
 			cnt |= ICH_ALI_SC_PCM_4;
-		else if (chip->multi6 && channels == 6)
+		else if (runtime->channels == 6)
 			cnt |= ICH_ALI_SC_PCM_6;
 		iputdword(chip, ICHREG(ALI_SCR), cnt);
 		break;
 	case DEVICE_SIS:
 		cnt = igetdword(chip, ICHREG(GLOB_CNT));
 		cnt &= ~ICH_SIS_PCM_246_MASK;
-		if (chip->multi4 && channels == 4)
+		if (runtime->channels == 4 || dbl)
 			cnt |= ICH_SIS_PCM_4;
-		else if (chip->multi6 && channels == 6)
+		else if (runtime->channels == 6)
 			cnt |= ICH_SIS_PCM_6;
 		iputdword(chip, ICHREG(GLOB_CNT), cnt);
 		break;
 	default:
 		cnt = igetdword(chip, ICHREG(GLOB_CNT));
 		cnt &= ~(ICH_PCM_246_MASK | ICH_PCM_20BIT);
-		if (chip->multi4 && channels == 4)
+		if (runtime->channels == 4 || dbl)
 			cnt |= ICH_PCM_4;
-		else if (chip->multi6 && channels == 6)
+		else if (runtime->channels == 6)
 			cnt |= ICH_PCM_6;
 		if (chip->device_type == DEVICE_NFORCE) {
 			/* reset to 2ch once to keep the 6 channel data in alignment,
@@ -1029,10 +1020,12 @@
 			 */
 			if (cnt & ICH_PCM_246_MASK) {
 				iputdword(chip, ICHREG(GLOB_CNT), cnt & ~ICH_PCM_246_MASK);
+				spin_unlock_irq(&chip->reg_lock);
 				msleep(50); /* grrr... */
+				spin_lock_irq(&chip->reg_lock);
 			}
 		} else if (chip->device_type == DEVICE_INTEL_ICH4) {
-			if (sample_bits > 16)
+			if (runtime->sample_bits > 16)
 				cnt |= ICH_PCM_20BIT;
 		}
 		iputdword(chip, ICHREG(GLOB_CNT), cnt);
@@ -1051,8 +1044,7 @@
 	ichdev->fragsize = snd_pcm_lib_period_bytes(substream);
 	spin_lock_irq(&chip->reg_lock);
 	if (ichdev->ichd == ICHD_PCMOUT) {
-		snd_intel8x0_setup_pcm_out(chip, runtime->channels,
-					   runtime->sample_bits);
+		snd_intel8x0_setup_pcm_out(chip, runtime);
 		if (chip->device_type == DEVICE_INTEL_ICH4) {
 			ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1;
 		}
@@ -1168,6 +1160,9 @@
 		runtime->hw.channels_max = 4;
 		snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels4);
 	}
+	if (chip->dra) {
+		snd_ac97_pcm_double_rate_rules(runtime);
+	}
 	if (chip->smp20bit) {
 		runtime->hw.formats |= SNDRV_PCM_FMTBIT_S32_LE;
 		snd_pcm_hw_constraint_msbits(runtime, 0, 32, 20);
@@ -1662,6 +1657,12 @@
 					 (1 << AC97_SLOT_PCM_SLEFT) |
 					 (1 << AC97_SLOT_PCM_SRIGHT) |
 					 (1 << AC97_SLOT_LFE)
+			},
+			{
+				.slots = (1 << AC97_SLOT_PCM_LEFT) |
+					 (1 << AC97_SLOT_PCM_RIGHT) |
+					 (1 << AC97_SLOT_PCM_LEFT_0) |
+					 (1 << AC97_SLOT_PCM_RIGHT_0)
 			}
 		}
 	},
@@ -1718,6 +1719,12 @@
 static struct ac97_quirk ac97_quirks[] __devinitdata = {
 	{
 		.vendor = 0x0e11,
+		.device = 0x008a,
+		.name = "Compaq Evo W4000",	/* AD1885 */
+		.type = AC97_TUNE_HP_ONLY
+	},
+	{
+		.vendor = 0x0e11,
 		.device = 0x00b8,
 		.name = "Compaq Evo D510C",
 		.type = AC97_TUNE_HP_ONLY
@@ -1764,6 +1771,12 @@
 		.name = "HP xw4200",	/* AD1981B*/
 		.type = AC97_TUNE_HP_ONLY
 	},
+	{
+		.vendor = 0x104d,
+		.device = 0x8197,
+		.name = "Sony S1XP",
+		.type = AC97_TUNE_INV_EAPD
+	},
  	{
 		.vendor = 0x1043,
 		.device = 0x80f3,
@@ -1771,6 +1784,12 @@
 		.type = AC97_TUNE_AD_SHARING
 	},
 	{
+		.vendor = 0x10cf,
+		.device = 0x11c3,
+		.name = "Fujitsu-Siemens E4010",
+		.type = AC97_TUNE_HP_ONLY
+	},
+	{
 		.vendor = 0x10f1,
 		.device = 0x2665,
 		.name = "Fujitsu-Siemens Celsius",	/* AD1981? */
@@ -1871,7 +1890,6 @@
 	int err;
 	unsigned int i, codecs;
 	unsigned int glob_sta = 0;
-	int spdif_idx = -1; /* disabled */
 	ac97_bus_ops_t *ops;
 	static ac97_bus_ops_t standard_bus_ops = {
 		.write = snd_intel8x0_codec_write,
@@ -1882,16 +1900,16 @@
 		.read = snd_intel8x0_ali_codec_read,
 	};
 
+	chip->spdif_idx = -1; /* use PCMOUT (or disabled) */
 	switch (chip->device_type) {
 	case DEVICE_NFORCE:
-		spdif_idx = NVD_SPBAR;
+		chip->spdif_idx = NVD_SPBAR;
 		break;
 	case DEVICE_ALI:
-		spdif_idx = ALID_AC97SPDIFOUT;
+		chip->spdif_idx = ALID_AC97SPDIFOUT;
 		break;
-	default:
-		if (chip->device_type == DEVICE_INTEL_ICH4)
-			spdif_idx = ICHD_SPBAR;
+	case DEVICE_INTEL_ICH4:
+		chip->spdif_idx = ICHD_SPBAR;
 		break;
 	};
 
@@ -1901,6 +1919,8 @@
 	ac97.private_data = chip;
 	ac97.private_free = snd_intel8x0_mixer_free_ac97;
 	ac97.scaps = AC97_SCAP_SKIP_MODEM;
+	if (chip->xbox)
+		ac97.scaps |= AC97_SCAP_DETECT_BY_VENDOR;
 	if (chip->device_type != DEVICE_ALI) {
 		glob_sta = igetdword(chip, ICHREG(GLOB_STA));
 		ops = &standard_bus_ops;
@@ -1944,6 +1964,7 @@
 	/* FIXME: my test board doesn't work well with VRA... */
 	if (chip->device_type == DEVICE_ALI)
 		pbus->no_vra = 1;
+	pbus->dra = 1;
 	chip->ac97_bus = pbus;
 
 	ac97.pci = chip->pci;
@@ -1966,7 +1987,7 @@
 	i = ARRAY_SIZE(ac97_pcm_defs);
 	if (chip->device_type != DEVICE_INTEL_ICH4)
 		i -= 2;		/* do not allocate PCM2IN and MIC2 */
-	if (spdif_idx < 0)
+	if (chip->spdif_idx < 0)
 		i--;		/* do not allocate S/PDIF */
 	err = snd_ac97_pcm_assign(pbus, i, ac97_pcm_defs);
 	if (err < 0)
@@ -1974,8 +1995,8 @@
 	chip->ichd[ICHD_PCMOUT].pcm = &pbus->pcms[0];
 	chip->ichd[ICHD_PCMIN].pcm = &pbus->pcms[1];
 	chip->ichd[ICHD_MIC].pcm = &pbus->pcms[2];
-	if (spdif_idx >= 0)
-		chip->ichd[spdif_idx].pcm = &pbus->pcms[3];
+	if (chip->spdif_idx >= 0)
+		chip->ichd[chip->spdif_idx].pcm = &pbus->pcms[3];
 	if (chip->device_type == DEVICE_INTEL_ICH4) {
 		chip->ichd[ICHD_PCM2IN].pcm = &pbus->pcms[4];
 		chip->ichd[ICHD_MIC2].pcm = &pbus->pcms[5];
@@ -2004,13 +2025,24 @@
 		if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE))
 			chip->multi6 = 1;
 	}
+	if (pbus->pcms[0].r[1].rslots[0]) {
+		chip->dra = 1;
+	}
 	if (chip->device_type == DEVICE_INTEL_ICH4) {
 		if ((igetdword(chip, ICHREG(GLOB_STA)) & ICH_SAMPLE_CAP) == ICH_SAMPLE_16_20)
 			chip->smp20bit = 1;
 	}
 	if (chip->device_type == DEVICE_NFORCE) {
 		/* 48kHz only */
-		chip->ichd[spdif_idx].pcm->rates = SNDRV_PCM_RATE_48000;
+		chip->ichd[chip->spdif_idx].pcm->rates = SNDRV_PCM_RATE_48000;
+	}
+	if (chip->device_type == DEVICE_INTEL_ICH4) {
+		/* use slot 10/11 for SPDIF */
+		u32 val;
+		val = igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_PCM_SPDIF_MASK;
+		val |= ICH_PCM_SPDIF_1011;
+		iputdword(chip, ICHREG(GLOB_CNT), val);
+		snd_ac97_update_bits(chip->ac97[0], AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4);
 	}
 	chip->in_ac97_init = 0;
 	return 0;
@@ -2231,6 +2263,7 @@
 	if (chip->remap_bmaddr)
 		iounmap(chip->remap_bmaddr);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -2249,6 +2282,7 @@
 	for (i = 0; i < 3; i++)
 		if (chip->ac97[i])
 			snd_ac97_suspend(chip->ac97[i]);
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -2318,6 +2352,7 @@
 	snd_intel8x0_setup_periods(chip, ichdev);
 	port = ichdev->reg_offset;
 	spin_lock_irq(&chip->reg_lock);
+	chip->in_measurement = 1;
 	/* trigger */
 	if (chip->device_type != DEVICE_ALI)
 		iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE | ICH_STARTBM);
@@ -2327,18 +2362,14 @@
 	}
 	do_gettimeofday(&start_time);
 	spin_unlock_irq(&chip->reg_lock);
-#if 0
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout(HZ / 20);
-#else
-	/* FIXME: schedule() can take too long time and overlap the boundary.. */
-	mdelay(50);
-#endif
 	spin_lock_irq(&chip->reg_lock);
 	/* check the position */
 	pos = ichdev->fragsize1;
 	pos -= igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << ichdev->pos_shift;
 	pos += ichdev->position;
+	chip->in_measurement = 0;
 	do_gettimeofday(&stop_time);
 	/* stop */
 	if (chip->device_type == DEVICE_ALI) {
@@ -2469,8 +2500,10 @@
 		return err;
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&chip->reg_lock);
 	spin_lock_init(&chip->ac97_lock);
 	chip->device_type = device_type;
@@ -2490,6 +2523,7 @@
 
 	if ((err = pci_request_regions(pci, card->shortname)) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 
@@ -2502,8 +2536,9 @@
 	if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) {	/* ICH4 and Nforce */
 		chip->mmio = 1;
 		chip->addr = pci_resource_start(pci, 2);
-		chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci, 2));
-		if (!chip->remap_addr) {
+		chip->remap_addr = ioremap_nocache(chip->addr,
+						   pci_resource_len(pci, 2));
+		if (chip->remap_addr == NULL) {
 			snd_printk("AC'97 space ioremap problem\n");
 			snd_intel8x0_free(chip);
 			return -EIO;
@@ -2514,8 +2549,9 @@
 	if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) {	/* ICH4 */
 		chip->bm_mmio = 1;
 		chip->bmaddr = pci_resource_start(pci, 3);
-		chip->remap_bmaddr = ioremap_nocache(chip->bmaddr, pci_resource_len(pci, 3));
-		if (!chip->remap_bmaddr) {
+		chip->remap_bmaddr = ioremap_nocache(chip->bmaddr,
+						     pci_resource_len(pci, 3));
+		if (chip->remap_bmaddr == NULL) {
 			snd_printk("Controller space ioremap problem\n");
 			snd_intel8x0_free(chip);
 			return -EIO;
@@ -2660,6 +2696,9 @@
 	case DEVICE_NFORCE:
 		strcpy(card->driver, "NFORCE");
 		break;
+	case DEVICE_INTEL_ICH4:
+		strcpy(card->driver, "ICH4");
+		break;
 	default:
 		strcpy(card->driver, "ICH");
 		break;
@@ -2679,6 +2718,8 @@
 	}
 	if (buggy_irq[dev])
 		chip->buggy_irq = 1;
+	if (xbox[dev])
+		chip->xbox = 1;
 
 	if ((err = snd_intel8x0_mixer(chip, ac97_clock[dev], ac97_quirk[dev])) < 0) {
 		snd_card_free(card);
@@ -2689,20 +2730,11 @@
 		return err;
 	}
 	
-	if (mpu_port[dev] == 0x300 || mpu_port[dev] == 0x330) {
-		if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_INTEL8X0,
-					       mpu_port[dev], 0,
-					       -1, 0, &chip->rmidi)) < 0) {
-			printk(KERN_ERR "intel8x0: no UART401 device at 0x%x, skipping.\n", mpu_port[dev]);
-			mpu_port[dev] = 0;
-		}
-	} else
-		mpu_port[dev] = 0;
-
 	snd_intel8x0_proc_init(chip);
 
-	sprintf(card->longname, "%s at 0x%lx, irq %i",
-		card->shortname, chip->addr, chip->irq);
+	snprintf(card->longname, sizeof(card->longname),
+		 "%s with %s at %#lx, irq %i", card->shortname,
+		 snd_ac97_get_short_name(chip->ac97[0]), chip->addr, chip->irq);
 
 	if (! ac97_clock[dev])
 		intel8x0_measure_ac97_clock(chip);
@@ -2731,129 +2763,18 @@
 };
 
 
-#if defined(SUPPORT_JOYSTICK) || defined(SUPPORT_MIDI)
-/*
- * initialize joystick/midi addresses
- */
-
-#ifdef SUPPORT_JOYSTICK
-/* there is only one available device, so we keep it here */
-static struct pci_dev *ich_gameport_pci;
-static struct gameport ich_gameport = { .io = 0x200 };
-#endif
-
-static int __devinit snd_intel8x0_joystick_probe(struct pci_dev *pci,
-						 const struct pci_device_id *id)
-{
-	u16 val;
-	static int dev;
-	if (dev >= SNDRV_CARDS)
-		return -ENODEV;
-	if (!enable[dev]) {
-		dev++;
-		return -ENOENT;
-	}
-
-	pci_read_config_word(pci, 0xe6, &val);
-#ifdef SUPPORT_JOYSTICK
-	val &= ~0x100;
-	if (joystick[dev]) {
-		if (! request_region(ich_gameport.io, 8, "ICH gameport")) {
-			printk(KERN_WARNING "intel8x0: cannot grab gameport 0x%x\n",  ich_gameport.io);
-			joystick[dev] = 0;
-		} else {
-			ich_gameport_pci = pci;
-			gameport_register_port(&ich_gameport);
-			val |= 0x100;
-		}
-	}
-#endif
-#ifdef SUPPORT_MIDI
-	val &= ~0x20;
-	if (mpu_port[dev] > 0) {
-		if (mpu_port[dev] == 0x300 || mpu_port[dev] == 0x330) {
-			u8 b;
-			val |= 0x20;
-			pci_read_config_byte(pci, 0xe2, &b);
-			if (mpu_port[dev] == 0x300)
-				b |= 0x08;
-			else
-				b &= ~0x08;
-			pci_write_config_byte(pci, 0xe2, b);
-		}
-	}
-#endif
-	pci_write_config_word(pci, 0xe6, val);
-	return 0;
-}
-
-static void __devexit snd_intel8x0_joystick_remove(struct pci_dev *pci)
-{
-	u16 val;
-#ifdef SUPPORT_JOYSTICK
-	if (ich_gameport_pci == pci) {
-		gameport_unregister_port(&ich_gameport);
-		release_region(ich_gameport.io, 8);
-		ich_gameport_pci = NULL;
-	}
-#endif
-	/* disable joystick and MIDI */
-	pci_read_config_word(pci, 0xe6, &val);
-	val &= ~0x120;
-	pci_write_config_word(pci, 0xe6, val);
-}
-
-static struct pci_device_id snd_intel8x0_joystick_ids[] = {
-	{ 0x8086, 0x2410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },	/* 82801AA */
-	{ 0x8086, 0x2420, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },	/* 82901AB */
-	{ 0x8086, 0x2440, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH2 */
-	{ 0x8086, 0x244c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH2M */
-	{ 0x8086, 0x248c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },	/* ICH3 */
-	// { 0x8086, 0x7195, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },	/* 440MX */
-	// { 0x1039, 0x7012, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },	/* SI7012 */
-	{ 0x10de, 0x01b2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },	/* NFORCE */
-	{ 0x10de, 0x006b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },	/* NFORCE2 */
-	{ 0x10de, 0x00db, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },	/* NFORCE3 */
-	{ 0, }
-};
-
-static struct pci_driver joystick_driver = {
-	.name = "Intel ICH Joystick",
-	.id_table = snd_intel8x0_joystick_ids,
-	.probe = snd_intel8x0_joystick_probe,
-	.remove = __devexit_p(snd_intel8x0_joystick_remove),
-};
-
-static int have_joystick;
-#endif
-
 static int __init alsa_card_intel8x0_init(void)
 {
 	int err;
 
         if ((err = pci_module_init(&driver)) < 0)
                 return err;
-
-#if defined(SUPPORT_JOYSTICK) || defined(SUPPORT_MIDI)
-	if (pci_module_init(&joystick_driver) < 0) {
-		snd_printdd(KERN_INFO "no joystick found\n");
-		have_joystick = 0;
-	} else {
-		snd_printdd(KERN_INFO "joystick(s) found\n");
-		have_joystick = 1;
-	}
-#endif
         return 0;
-
 }
 
 static void __exit alsa_card_intel8x0_exit(void)
 {
 	pci_unregister_driver(&driver);
-#if defined(SUPPORT_JOYSTICK) || defined(SUPPORT_MIDI)
-	if (have_joystick)
-		pci_unregister_driver(&joystick_driver);
-#endif
 }
 
 module_init(alsa_card_intel8x0_init)
diff -Nru a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
--- a/sound/pci/intel8x0m.c	2004-12-24 13:36:55 -08:00
+++ b/sound/pci/intel8x0m.c	2004-12-24 13:36:55 -08:00
@@ -30,13 +30,11 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
-#include <linux/gameport.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/ac97_codec.h>
 #include <sound/info.h>
-#include <sound/mpu401.h>
 #include <sound/initval.h>
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
@@ -48,22 +46,26 @@
 		"{Intel,82801CA-ICH3},"
 		"{Intel,82801DB-ICH4},"
 		"{Intel,ICH5},"
-	        "{Intel,MX440}}");
-
+	        "{Intel,MX440},"
+		"{SiS,7013},"
+		"{NVidia,NForce Modem},"
+		"{NVidia,NForce2 Modem},"
+		"{NVidia,NForce2s Modem},"
+		"{NVidia,NForce3 Modem},"
+		"{AMD,AMD768}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel i8x0 modemcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Intel i8x0 modemcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Intel i8x0 modemcard.");
-module_param_array(ac97_clock, int, boot_devs, 0444);
+module_param_array(ac97_clock, int, NULL, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
 
 /*
@@ -233,10 +235,10 @@
 
 	unsigned int mmio;
 	unsigned long addr;
-	unsigned long remap_addr;
+	void __iomem *remap_addr;
 	unsigned int bm_mmio;
 	unsigned long bmaddr;
-	unsigned long remap_bmaddr;
+	void __iomem *remap_bmaddr;
 
 	struct pci_dev *pci;
 	snd_card_t *card;
@@ -1066,12 +1068,13 @@
 	if (chip->bdbars.area)
 		snd_dma_free_pages(&chip->bdbars);
 	if (chip->remap_addr)
-		iounmap((void *) chip->remap_addr);
+		iounmap(chip->remap_addr);
 	if (chip->remap_bmaddr)
-		iounmap((void *) chip->remap_bmaddr);
+		iounmap(chip->remap_bmaddr);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *)chip);
 	pci_release_regions(chip->pci);
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -1089,6 +1092,7 @@
 		snd_pcm_suspend_all(chip->pcm[i]);
 	if (chip->ac97)
 		snd_ac97_suspend(chip->ac97);
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -1170,8 +1174,10 @@
 		return err;
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&chip->reg_lock);
 	spin_lock_init(&chip->ac97_lock);
 	chip->device_type = device_type;
@@ -1181,6 +1187,7 @@
 
 	if ((err = pci_request_regions(pci, card->shortname)) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 
@@ -1193,9 +1200,9 @@
 	if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) {	/* ICH4 and Nforce */
 		chip->mmio = 1;
 		chip->addr = pci_resource_start(pci, 2);
-		chip->remap_addr = (unsigned long) ioremap_nocache(chip->addr,
-								   pci_resource_len(pci, 2));
-		if (chip->remap_addr == 0) {
+		chip->remap_addr = ioremap_nocache(chip->addr,
+						   pci_resource_len(pci, 2));
+		if (chip->remap_addr == NULL) {
 			snd_printk("AC'97 space ioremap problem\n");
 			snd_intel8x0_free(chip);
 			return -EIO;
@@ -1206,9 +1213,9 @@
 	if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) {	/* ICH4 */
 		chip->bm_mmio = 1;
 		chip->bmaddr = pci_resource_start(pci, 3);
-		chip->remap_bmaddr = (unsigned long) ioremap_nocache(chip->bmaddr,
-								     pci_resource_len(pci, 3));
-		if (chip->remap_bmaddr == 0) {
+		chip->remap_bmaddr = ioremap_nocache(chip->bmaddr,
+						     pci_resource_len(pci, 3));
+		if (chip->remap_bmaddr == NULL) {
 			snd_printk("Controller space ioremap problem\n");
 			snd_intel8x0_free(chip);
 			return -EIO;
@@ -1332,15 +1339,7 @@
 	if (card == NULL)
 		return -ENOMEM;
 
-	switch (pci_id->driver_data) {
-	case DEVICE_NFORCE:
-		strcpy(card->driver, "NFORCE-MODEM");
-		break;
-	default:
-		strcpy(card->driver, "ICH-MODEM");
-		break;
-	}
-
+	strcpy(card->driver, "ICH-MODEM");
 	strcpy(card->shortname, "Intel ICH");
 	for (name = shortnames; name->id; name++) {
 		if (pci->device == name->id) {
diff -Nru a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
--- a/sound/pci/korg1212/korg1212.c	2004-12-24 13:36:17 -08:00
+++ b/sound/pci/korg1212/korg1212.c	2004-12-24 13:36:17 -08:00
@@ -168,7 +168,7 @@
 #define DOORBELL_VAL_MASK    0x00FF    // the doorbell value is one byte
 
 #define CARD_BOOT_DELAY_IN_MS  10
-
+#define CARD_BOOT_TIMEOUT      10
 #define DSP_BOOT_DELAY_IN_MS   200
 
 #define kNumBuffers		8
@@ -341,7 +341,7 @@
 	unsigned long iomem2;
         unsigned long irqcount;
         unsigned long inIRQ;
-        unsigned long iobase;
+        void __iomem *iobase;
 
 	struct snd_dma_buffer dma_dsp;
         struct snd_dma_buffer dma_play;
@@ -364,16 +364,16 @@
 	u32 RoutingTablePhy;
 	u32 AdatTimeCodePhy;
 
-        u32 * statusRegPtr;	     // address of the interrupt status/control register
-        u32 * outDoorbellPtr;	     // address of the host->card doorbell register
-        u32 * inDoorbellPtr;	     // address of the card->host doorbell register
-        u32 * mailbox0Ptr;	     // address of mailbox 0 on the card
-        u32 * mailbox1Ptr;	     // address of mailbox 1 on the card
-        u32 * mailbox2Ptr;	     // address of mailbox 2 on the card
-        u32 * mailbox3Ptr;	     // address of mailbox 3 on the card
-        u32 * controlRegPtr;	     // address of the EEPROM, PCI, I/O, Init ctrl reg
-        u16 * sensRegPtr;	     // address of the sensitivity setting register
-        u32 * idRegPtr;		     // address of the device and vendor ID registers
+        u32 __iomem * statusRegPtr;	     // address of the interrupt status/control register
+        u32 __iomem * outDoorbellPtr;	     // address of the host->card doorbell register
+        u32 __iomem * inDoorbellPtr;	     // address of the card->host doorbell register
+        u32 __iomem * mailbox0Ptr;	     // address of mailbox 0 on the card
+        u32 __iomem * mailbox1Ptr;	     // address of mailbox 1 on the card
+        u32 __iomem * mailbox2Ptr;	     // address of mailbox 2 on the card
+        u32 __iomem * mailbox3Ptr;	     // address of mailbox 3 on the card
+        u32 __iomem * controlRegPtr;	     // address of the EEPROM, PCI, I/O, Init ctrl reg
+        u16 __iomem * sensRegPtr;	     // address of the sensitivity setting register
+        u32 __iomem * idRegPtr;		     // address of the device and vendor ID registers
 
         size_t periodsize;
 	int channels;
@@ -382,6 +382,9 @@
         snd_pcm_substream_t *playback_substream;
         snd_pcm_substream_t *capture_substream;
 
+	pid_t capture_pid;
+	pid_t playback_pid;
+
  	CardState cardState;
         int running;
         int idleMonitorOn;           // indicates whether the card is in idle monitor mode.
@@ -410,13 +413,12 @@
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	   /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Korg 1212 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Korg 1212 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Korg 1212 soundcard.");
 MODULE_AUTHOR("Haroldo Gamal <gamal@alternex.com.br>");
 
@@ -797,11 +799,12 @@
 
 static void snd_korg1212_EnableCardInterrupts(korg1212_t * korg1212)
 {
-	* korg1212->statusRegPtr = PCI_INT_ENABLE_BIT            |
-                                   PCI_DOORBELL_INT_ENABLE_BIT   |
-                                   LOCAL_INT_ENABLE_BIT          |
-                                   LOCAL_DOORBELL_INT_ENABLE_BIT |
-                                   LOCAL_DMA1_INT_ENABLE_BIT;
+	writel(PCI_INT_ENABLE_BIT            |
+	       PCI_DOORBELL_INT_ENABLE_BIT   |
+	       LOCAL_INT_ENABLE_BIT          |
+	       LOCAL_DOORBELL_INT_ENABLE_BIT |
+	       LOCAL_DMA1_INT_ENABLE_BIT,
+	       korg1212->statusRegPtr);
 }
 
 #if 0 /* not used */
@@ -844,6 +847,20 @@
 
 #endif /* not used */
 
+static inline int snd_korg1212_use_is_exclusive(korg1212_t *korg1212)
+{
+	unsigned long flags;
+	int ret = 1;
+
+	spin_lock_irqsave(&korg1212->lock, flags);
+	if ((korg1212->playback_pid != korg1212->capture_pid) &&
+	    (korg1212->playback_pid >= 0) && (korg1212->capture_pid >= 0)) {
+		ret = 0;
+	}
+	spin_unlock_irqrestore(&korg1212->lock, flags);
+	return ret;
+}
+
 static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate)
 {
         static ClockSourceIndex s44[] = { K1212_CLKIDX_AdatAt44_1K,
@@ -855,6 +872,10 @@
                                           K1212_CLKIDX_LocalAt48K };
         int parm;
 
+        if (!snd_korg1212_use_is_exclusive (korg1212)) {
+                return -EBUSY;
+        }
+
         switch(rate) {
                 case 44100:
                 parm = s44[korg1212->clkSource];
@@ -898,7 +919,7 @@
 
 static void snd_korg1212_DisableCardInterrupts(korg1212_t *korg1212)
 {
-	* korg1212->statusRegPtr = 0;
+	writel(0, korg1212->statusRegPtr);
 }
 
 static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212)
@@ -1245,7 +1266,7 @@
 	if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
 #endif
 
-	if (! sleep_on_timeout(&korg1212->wait, HZ * 4))
+	if (! sleep_on_timeout(&korg1212->wait, HZ * CARD_BOOT_TIMEOUT))
 		return -EBUSY; /* timeout */
 
 	snd_korg1212_OnDSPDownloadComplete(korg1212);
@@ -1414,6 +1435,7 @@
         spin_lock_irqsave(&korg1212->lock, flags);
 
         korg1212->playback_substream = substream;
+	korg1212->playback_pid = current->pid;
         korg1212->periodsize = K1212_PERIODS;
 	korg1212->channels = K1212_CHANNELS;
 
@@ -1444,6 +1466,7 @@
         spin_lock_irqsave(&korg1212->lock, flags);
 
         korg1212->capture_substream = substream;
+	korg1212->capture_pid = current->pid;
         korg1212->periodsize = K1212_PERIODS;
 	korg1212->channels = K1212_CHANNELS;
 
@@ -1466,6 +1489,7 @@
 
         spin_lock_irqsave(&korg1212->lock, flags);
 
+	korg1212->playback_pid = -1;
         korg1212->playback_substream = NULL;
         korg1212->periodsize = 0;
 
@@ -1486,6 +1510,7 @@
 
         spin_lock_irqsave(&korg1212->lock, flags);
 
+	korg1212->capture_pid = -1;
         korg1212->capture_substream = NULL;
         korg1212->periodsize = 0;
 
@@ -1522,22 +1547,45 @@
         unsigned long flags;
         korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
         int err;
+	pid_t this_pid;
+	pid_t other_pid;
 
 #if K1212_DEBUG_LEVEL > 0
 		K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n", stateName[korg1212->cardState]);
 #endif
 
         spin_lock_irqsave(&korg1212->lock, flags);
+
+	if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		this_pid = korg1212->playback_pid;
+		other_pid = korg1212->capture_pid;
+	} else {
+		this_pid = korg1212->capture_pid;
+		other_pid = korg1212->playback_pid;
+	}
+
+	if ((other_pid > 0) && (this_pid != other_pid)) {
+
+		/* The other stream is open, and not by the same
+		   task as this one. Make sure that the parameters
+		   that matter are the same.
+		 */
+
+		if ((int)params_rate(params) != korg1212->clkRate) {
+			spin_unlock_irqrestore(&korg1212->lock, flags);
+			_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
+			return -EBUSY;
+		}
+
+        	spin_unlock_irqrestore(&korg1212->lock, flags);
+	        return 0;
+	}
+
         if ((err = snd_korg1212_SetRate(korg1212, params_rate(params))) < 0) {
                 spin_unlock_irqrestore(&korg1212->lock, flags);
                 return err;
         }
-/*
-        if (params_format(params) != SNDRV_PCM_FORMAT_S16_LE) {
-                spin_unlock_irqrestore(&korg1212->lock, flags);
-                return -EINVAL;
-        }
-*/
+
 	korg1212->channels = params_channels(params);
         korg1212->periodsize = K1212_PERIOD_BYTES;
 
@@ -2091,9 +2139,9 @@
                 korg1212->irq = -1;
         }
         
-        if (korg1212->iobase != 0) {
-                iounmap((void *)korg1212->iobase);
-                korg1212->iobase = 0;
+        if (korg1212->iobase != NULL) {
+                iounmap(korg1212->iobase);
+                korg1212->iobase = NULL;
         }
         
 	pci_release_regions(korg1212->pci);
@@ -2131,6 +2179,7 @@
 		korg1212->dma_shared.area = NULL;
         }
         
+	pci_disable_device(korg1212->pci);
         kfree(korg1212);
         return 0;
 }
@@ -2162,8 +2211,10 @@
                 return err;
 
         korg1212 = kcalloc(1, sizeof(*korg1212), GFP_KERNEL);
-        if (korg1212 == NULL)
+        if (korg1212 == NULL) {
+		pci_disable_device(pci);
                 return -ENOMEM;
+	}
 
 	korg1212->card = card;
 	korg1212->pci = pci;
@@ -2183,6 +2234,8 @@
 	korg1212->opencnt = 0;
 	korg1212->playcnt = 0;
 	korg1212->setcnt = 0;
+	korg1212->playback_pid = -1;
+	korg1212->capture_pid = -1;
         snd_korg1212_setCardState(korg1212, K1212_STATE_UNINITIALIZED);
         korg1212->idleMonitorOn = 0;
         korg1212->clkSrcRate = K1212_CLKIDX_LocalAt44_1K;
@@ -2194,6 +2247,7 @@
 
 	if ((err = pci_request_regions(pci, "korg1212")) < 0) {
 		kfree(korg1212);
+		pci_disable_device(pci);
 		return err;
 	}
 
@@ -2217,9 +2271,10 @@
 		   stateName[korg1212->cardState]);
 #endif
 
-        if ((korg1212->iobase = (unsigned long) ioremap(korg1212->iomem, iomem_size)) == 0) {
-		snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", korg1212->iobase,
-                           korg1212->iobase + iomem_size - 1);
+        if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) {
+		snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
+                           korg1212->iomem + iomem_size - 1);
+                snd_korg1212_free(korg1212);
                 return -EBUSY;
         }
 
@@ -2229,6 +2284,7 @@
 
         if (err) {
 		snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+                snd_korg1212_free(korg1212);
                 return -EBUSY;
         }
 
@@ -2236,16 +2292,16 @@
 
 	pci_set_master(korg1212->pci);
 
-        korg1212->statusRegPtr = (u32 *) (korg1212->iobase + STATUS_REG_OFFSET);
-        korg1212->outDoorbellPtr = (u32 *) (korg1212->iobase + OUT_DOORBELL_OFFSET);
-        korg1212->inDoorbellPtr = (u32 *) (korg1212->iobase + IN_DOORBELL_OFFSET);
-        korg1212->mailbox0Ptr = (u32 *) (korg1212->iobase + MAILBOX0_OFFSET);
-        korg1212->mailbox1Ptr = (u32 *) (korg1212->iobase + MAILBOX1_OFFSET);
-        korg1212->mailbox2Ptr = (u32 *) (korg1212->iobase + MAILBOX2_OFFSET);
-        korg1212->mailbox3Ptr = (u32 *) (korg1212->iobase + MAILBOX3_OFFSET);
-        korg1212->controlRegPtr = (u32 *) (korg1212->iobase + PCI_CONTROL_OFFSET);
-        korg1212->sensRegPtr = (u16 *) (korg1212->iobase + SENS_CONTROL_OFFSET);
-        korg1212->idRegPtr = (u32 *) (korg1212->iobase + DEV_VEND_ID_OFFSET);
+        korg1212->statusRegPtr = (u32 __iomem *) (korg1212->iobase + STATUS_REG_OFFSET);
+        korg1212->outDoorbellPtr = (u32 __iomem *) (korg1212->iobase + OUT_DOORBELL_OFFSET);
+        korg1212->inDoorbellPtr = (u32 __iomem *) (korg1212->iobase + IN_DOORBELL_OFFSET);
+        korg1212->mailbox0Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX0_OFFSET);
+        korg1212->mailbox1Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX1_OFFSET);
+        korg1212->mailbox2Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX2_OFFSET);
+        korg1212->mailbox3Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX3_OFFSET);
+        korg1212->controlRegPtr = (u32 __iomem *) (korg1212->iobase + PCI_CONTROL_OFFSET);
+        korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET);
+        korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET);
 
 #if K1212_DEBUG_LEVEL > 0
         K1212_DEBUG_PRINTK("K1212_DEBUG: card registers:\n"
@@ -2276,6 +2332,7 @@
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) {
 		snd_printk(KERN_ERR "can not allocate shared buffer memory (%Zd bytes)\n", sizeof(KorgSharedBuffer));
+                snd_korg1212_free(korg1212);
                 return -ENOMEM;
         }
         korg1212->sharedBufferPtr = (KorgSharedBuffer *)korg1212->dma_shared.area;
@@ -2292,6 +2349,7 @@
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
 		snd_printk(KERN_ERR "can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
+                snd_korg1212_free(korg1212);
                 return -ENOMEM;
         }
 	korg1212->playDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_play.area;
@@ -2305,6 +2363,7 @@
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
 		snd_printk(KERN_ERR "can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
+                snd_korg1212_free(korg1212);
                 return -ENOMEM;
         }
         korg1212->recordDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_rec.area;
@@ -2312,7 +2371,7 @@
 
 #if K1212_DEBUG_LEVEL > 0
         K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n",
-		korg1212->recordDataBufsPtr, korg1212->RecDataBufsPhy, korg1212->DataBufsSize);
+		korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize);
 #endif
 
 #else // K1212_LARGEALLOC
@@ -2336,6 +2395,7 @@
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) {
 		snd_printk(KERN_ERR "can not allocate dsp code memory (%d bytes)\n", korg1212->dspCodeSize);
+                snd_korg1212_free(korg1212);
                 return -ENOMEM;
         }
 
@@ -2355,8 +2415,10 @@
 
 	mdelay(CARD_BOOT_DELAY_IN_MS);
 
-        if (snd_korg1212_downloadDSPCode(korg1212)) 
+        if (snd_korg1212_downloadDSPCode(korg1212)) {
+                snd_korg1212_free(korg1212);
         	return -EBUSY;
+	}
 
 	printk(KERN_INFO "dspMemPhy       = %08x U[%08x]\n"
                "PlayDataPhy     = %08x L[%08x]\n"
@@ -2371,8 +2433,10 @@
                korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy),
                korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy));
 
-        if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0)
+        if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0) {
+                snd_korg1212_free(korg1212);
                 return err;
+	}
 
 	korg1212->pcm->private_data = korg1212;
         korg1212->pcm->private_free = snd_korg1212_free_pcm;
@@ -2389,8 +2453,10 @@
 
         for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) {
                 err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212));
-                if (err < 0)
+                if (err < 0) {
+			snd_korg1212_free(korg1212);
                         return err;
+		}
         }
 
         snd_korg1212_proc_init(korg1212);
diff -Nru a/sound/pci/maestro3.c b/sound/pci/maestro3.c
--- a/sound/pci/maestro3.c	2004-12-24 13:37:00 -08:00
+++ b/sound/pci/maestro3.c	2004-12-24 13:37:00 -08:00
@@ -62,17 +62,16 @@
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */
 static int external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
 static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable this soundcard.");
-module_param_array(external_amp, bool, boot_devs, 0444);
+module_param_array(external_amp, bool, NULL, 0444);
 MODULE_PARM_DESC(external_amp, "Enable external amp for " CARD_NAME " soundcard.");
-module_param_array(amp_gpio, int, boot_devs, 0444);
+module_param_array(amp_gpio, int, NULL, 0444);
 MODULE_PARM_DESC(amp_gpio, "GPIO pin number for external amp. (default = -1)");
 
 #define MAX_PLAYBACKS	2
@@ -2387,6 +2386,7 @@
 	if (chip->iobase)
 		pci_release_regions(chip->pci);
 
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -2423,6 +2423,8 @@
 	/* power down apci registers */
 	snd_m3_outw(chip, 0xffff, 0x54);
 	snd_m3_outw(chip, 0xffff, 0x56);
+
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -2435,6 +2437,7 @@
 	if (chip->suspend_mem == NULL)
 		return 0;
 
+	pci_enable_device(chip->pci);
 	pci_set_master(chip->pci);
 
 	/* first lets just bring everything back. .*/
@@ -2503,12 +2506,15 @@
 	if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
 		snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	spin_lock_init(&chip->reg_lock);
 	switch (pci->device) {
@@ -2550,6 +2556,7 @@
 	chip->substreams = kmalloc(sizeof(m3_dma_t) * chip->num_substreams, GFP_KERNEL);
 	if (chip->substreams == NULL) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return -ENOMEM;
 	}
 	memset(chip->substreams, 0, sizeof(m3_dma_t) * chip->num_substreams);
diff -Nru a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
--- a/sound/pci/mixart/mixart.c	2004-12-24 13:37:01 -08:00
+++ b/sound/pci/mixart/mixart.c	2004-12-24 13:37:01 -08:00
@@ -47,13 +47,12 @@
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;             /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;              /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Digigram " CARD_NAME " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard.");
 
 /*
@@ -1078,7 +1077,7 @@
 	/* release the i/o ports */
 	for (i = 0; i < 2; i++) {
 		if (mgr->mem[i].virt)
-			iounmap((void *)mgr->mem[i].virt);
+			iounmap(mgr->mem[i].virt);
 	}
 	pci_release_regions(mgr->pci);
 
@@ -1093,6 +1092,7 @@
 		mgr->bufferinfo.area = NULL;
 	}
 
+	pci_disable_device(mgr->pci);
 	kfree(mgr);
 	return 0;
 }
@@ -1293,14 +1293,17 @@
 	/* check if we can restrict PCI DMA transfers to 32 bits */
 	if (pci_set_dma_mask(pci, 0xffffffff) < 0) {
 		snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 
 	/*
 	 */
 	mgr = kcalloc(1, sizeof(*mgr), GFP_KERNEL);
-	if (! mgr)
+	if (! mgr) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	mgr->pci = pci;
 	mgr->irq = -1;
@@ -1308,12 +1311,13 @@
 	/* resource assignment */
 	if ((err = pci_request_regions(pci, CARD_NAME)) < 0) {
 		kfree(mgr);
+		pci_disable_device(pci);
 		return err;
 	}
 	for (i = 0; i < 2; i++) {
 		mgr->mem[i].phys = pci_resource_start(pci, i);
-		mgr->mem[i].virt = (unsigned long)ioremap_nocache(mgr->mem[i].phys,
-								  pci_resource_len(pci, i));
+		mgr->mem[i].virt = ioremap_nocache(mgr->mem[i].phys,
+						   pci_resource_len(pci, i));
 	}
 
 	if (request_irq(pci->irq, snd_mixart_interrupt, SA_INTERRUPT|SA_SHIRQ, CARD_NAME, (void *)mgr)) {
diff -Nru a/sound/pci/mixart/mixart.h b/sound/pci/mixart/mixart.h
--- a/sound/pci/mixart/mixart.h	2004-12-24 13:36:17 -08:00
+++ b/sound/pci/mixart/mixart.h	2004-12-24 13:36:17 -08:00
@@ -53,7 +53,7 @@
 
 struct mem_area {
 	unsigned long phys;
-	unsigned long virt;
+	void __iomem *virt;
 	struct resource *res;
 };
 
diff -Nru a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
--- a/sound/pci/nm256/nm256.c	2004-12-24 13:37:18 -08:00
+++ b/sound/pci/nm256/nm256.c	2004-12-24 13:37:19 -08:00
@@ -61,26 +61,28 @@
 static int buffer_top[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; /* not specified */
 static int use_cache[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; /* disabled */
 static int vaio_hack[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; /* disabled */
-static int boot_devs;
+static int reset_workaround[SNDRV_CARDS];
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable this soundcard.");
-module_param_array(playback_bufsize, int, boot_devs, 0444);
+module_param_array(playback_bufsize, int, NULL, 0444);
 MODULE_PARM_DESC(playback_bufsize, "DAC frame size in kB for " CARD_NAME " soundcard.");
-module_param_array(capture_bufsize, int, boot_devs, 0444);
+module_param_array(capture_bufsize, int, NULL, 0444);
 MODULE_PARM_DESC(capture_bufsize, "ADC frame size in kB for " CARD_NAME " soundcard.");
-module_param_array(force_ac97, bool, boot_devs, 0444);
+module_param_array(force_ac97, bool, NULL, 0444);
 MODULE_PARM_DESC(force_ac97, "Force to use AC97 codec for " CARD_NAME " soundcard.");
-module_param_array(buffer_top, int, boot_devs, 0444);
+module_param_array(buffer_top, int, NULL, 0444);
 MODULE_PARM_DESC(buffer_top, "Set the top address of audio buffer for " CARD_NAME " soundcard.");
-module_param_array(use_cache, bool, boot_devs, 0444);
+module_param_array(use_cache, bool, NULL, 0444);
 MODULE_PARM_DESC(use_cache, "Enable the cache for coefficient table access.");
-module_param_array(vaio_hack, bool, boot_devs, 0444);
+module_param_array(vaio_hack, bool, NULL, 0444);
 MODULE_PARM_DESC(vaio_hack, "Enable workaround for Sony VAIO notebooks.");
+module_param_array(reset_workaround, bool, NULL, 0444);
+MODULE_PARM_DESC(reset_workaround, "Enable AC97 RESET workaround for some laptops.");
 
 /*
  * hw definitions
@@ -190,7 +192,7 @@
 	
 	u32 buf;	/* offset from chip->buffer */
 	int bufsize;	/* buffer size in bytes */
-	unsigned long bufptr;		/* mapped pointer */
+	void __iomem *bufptr;		/* mapped pointer */
 	unsigned long bufptr_addr;	/* physical address of the mapped pointer */
 
 	int dma_size;		/* buffer size of the substream in bytes */
@@ -205,11 +207,11 @@
 	
 	snd_card_t *card;
 
-	unsigned long cport;		/* control port */
+	void __iomem *cport;		/* control port */
 	struct resource *res_cport;	/* its resource */
 	unsigned long cport_addr;	/* physical address */
 
-	unsigned long buffer;		/* buffer */
+	void __iomem *buffer;		/* buffer */
 	struct resource *res_buffer;	/* its resource */
 	unsigned long buffer_addr;	/* buffer phyiscal address */
 
@@ -222,7 +224,7 @@
 
 	unsigned int coeffs_current: 1;	/* coeff. table is loaded? */
 	unsigned int use_cache: 1;	/* use one big coef. table */
-	unsigned int latitude_workaround: 1; /* Dell Latitude LS workaround needed */
+	unsigned int reset_workaround: 1; /* Workaround for some laptops to avoid freeze */
 
 	int mixer_base;			/* register offset of ac97 mixer */
 	int mixer_status_offset;	/* offset of mixer status reg. */
@@ -329,7 +331,7 @@
 		return;
 	}
 #endif
-	memcpy_toio((void *)chip->buffer + offset, src, size);
+	memcpy_toio(chip->buffer + offset, src, size);
 }
 
 /*
@@ -887,8 +889,8 @@
 
 	for (i = 0; i < 2; i++) {
 		nm256_stream_t *s = &chip->streams[i];
-		s->bufptr = chip->buffer +  s->buf - chip->buffer_start;
-		s->bufptr_addr = chip->buffer_addr + s->buf - chip->buffer_start;
+		s->bufptr = chip->buffer + (s->buf - chip->buffer_start);
+		s->bufptr_addr = chip->buffer_addr + (s->buf - chip->buffer_start);
 	}
 
 	err = snd_pcm_new(chip->card, chip->card->driver, device,
@@ -1162,16 +1164,14 @@
 {
 	nm256_t *chip = ac97->private_data;
 
-	spin_lock(&chip->reg_lock);
 	/* Reset the mixer.  'Tis magic!  */
 	snd_nm256_writeb(chip, 0x6c0, 1);
-	if (chip->latitude_workaround) {
+	if (! chip->reset_workaround) {
 		/* Dell latitude LS will lock up by this */
 		snd_nm256_writeb(chip, 0x6cc, 0x87);
 	}
 	snd_nm256_writeb(chip, 0x6cc, 0x80);
 	snd_nm256_writeb(chip, 0x6cc, 0x0);
-	spin_unlock(&chip->reg_lock);
 }
 
 /* create an ac97 mixer interface */
@@ -1226,13 +1226,13 @@
 snd_nm256_peek_for_sig(nm256_t *chip)
 {
 	/* The signature is located 1K below the end of video RAM.  */
-	unsigned long temp;
+	void __iomem *temp;
 	/* Default buffer end is 5120 bytes below the top of RAM.  */
 	unsigned long pointer_found = chip->buffer_end - 0x1400;
 	u32 sig;
 
-	temp = (unsigned long) ioremap_nocache(chip->buffer_addr + chip->buffer_end - 0x400, 16);
-	if (temp == 0) {
+	temp = ioremap_nocache(chip->buffer_addr + chip->buffer_end - 0x400, 16);
+	if (temp == NULL) {
 		snd_printk("Unable to scan for card signature in video RAM\n");
 		return -EBUSY;
 	}
@@ -1248,7 +1248,7 @@
 		    pointer < chip->buffer_size ||
 		    pointer > chip->buffer_end) {
 			snd_printk("invalid signature found: 0x%x\n", pointer);
-			iounmap((void *)temp);
+			iounmap(temp);
 			return -ENODEV;
 		} else {
 			pointer_found = pointer;
@@ -1256,7 +1256,7 @@
 		}
 	}
 
-	iounmap((void *)temp);
+	iounmap(temp);
 	chip->buffer_end = pointer_found;
 
 	return 0;
@@ -1274,6 +1274,7 @@
 	snd_pcm_suspend_all(chip->pcm);
 	snd_ac97_suspend(chip->ac97);
 	chip->coeffs_current = 0;
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -1305,9 +1306,9 @@
 		synchronize_irq(chip->irq);
 
 	if (chip->cport)
-		iounmap((void *) chip->cport);
+		iounmap(chip->cport);
 	if (chip->buffer)
-		iounmap((void *) chip->buffer);
+		iounmap(chip->buffer);
 	if (chip->res_cport) {
 		release_resource(chip->res_cport);
 		kfree_nocheck(chip->res_cport);
@@ -1319,6 +1320,7 @@
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void*)chip);
 
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -1343,13 +1345,17 @@
 		.dev_free =	snd_nm256_dev_free,
 	};
 	u32 addr;
-	u16 subsystem_vendor, subsystem_device;
 
 	*chip_ret = NULL;
 
+	if ((err = pci_enable_device(pci)) < 0)
+		return err;
+
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	chip->card = card;
 	chip->pci = pci;
@@ -1380,8 +1386,8 @@
 		err = -EBUSY;
 		goto __error;
 	}
-	chip->cport = (unsigned long) ioremap_nocache(chip->cport_addr, NM_PORT2_SIZE);
-	if (chip->cport == 0) {
+	chip->cport = ioremap_nocache(chip->cport_addr, NM_PORT2_SIZE);
+	if (chip->cport == NULL) {
 		snd_printk("unable to map control port %lx\n", chip->cport_addr);
 		err = -ENOMEM;
 		goto __error;
@@ -1445,8 +1451,8 @@
 		err = -EBUSY;
 		goto __error;
 	}
-	chip->buffer = (unsigned long) ioremap_nocache(chip->buffer_addr, chip->buffer_size);
-	if (chip->buffer == 0) {
+	chip->buffer = ioremap_nocache(chip->buffer_addr, chip->buffer_size);
+	if (chip->buffer == NULL) {
 		err = -ENOMEM;
 		snd_printk("unable to map ring buffer at %lx\n", chip->buffer_addr);
 		goto __error;
@@ -1480,19 +1486,6 @@
 
 	chip->coeffs_current = 0;
 
-	/* check workarounds */
-	chip->latitude_workaround = 1;
-	pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
-	pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device);
-	if (subsystem_vendor == 0x104d && subsystem_device == 0x8041) {
-		/* this workaround will cause lock-up after suspend/resume on Sony PCG-F305 */
-		chip->latitude_workaround = 0;
-	}
-	if (subsystem_vendor == 0x1028 && subsystem_device == 0x0080) {
-		/* this workaround will cause lock-up after suspend/resume on a Dell laptop */
-		chip->latitude_workaround = 0;
-	}
-
 	snd_nm256_init_chip(chip);
 
 	if ((err = snd_nm256_pcm(chip, 0)) < 0)
@@ -1525,11 +1518,15 @@
 	int type;
 };
 
-#define NM_BLACKLISTED	1
+enum { NM_BLACKLISTED, NM_RESET_WORKAROUND };
 
 static struct nm256_quirk nm256_quirks[] __devinitdata = {
 	/* HP omnibook 4150 has cs4232 codec internally */
 	{ .vendor = 0x103c, .device = 0x0007, .type = NM_BLACKLISTED },
+	/* Sony PCG-F305 */
+	{ .vendor = 0x104d, .device = 0x8041, .type = NM_RESET_WORKAROUND },
+	/* Dell Latitude LS */
+	{ .vendor = 0x1028, .device = 0x0080, .type = NM_RESET_WORKAROUND },
 	{ } /* terminator */
 };
 
@@ -1545,9 +1542,6 @@
 	struct nm256_quirk *q;
 	u16 subsystem_vendor, subsystem_device;
 
-	if ((err = pci_enable_device(pci)) < 0)
-		return err;
-
 	if (dev >= SNDRV_CARDS)
 		return -ENODEV;
 	if (!enable[dev]) {
@@ -1560,9 +1554,13 @@
 
 	for (q = nm256_quirks; q->vendor; q++) {
 		if (q->vendor == subsystem_vendor && q->device == subsystem_device) {
-			if (q->type == NM_BLACKLISTED) {
+			switch (q->type) {
+			case NM_BLACKLISTED:
 				printk(KERN_INFO "nm256: The device is blacklisted.  Loading stopped\n");
 				return -ENODEV;
+			case NM_RESET_WORKAROUND:
+				reset_workaround[dev] = 1;
+				break;
 			}
 		}
 	}
@@ -1609,6 +1607,11 @@
 				    &chip)) < 0) {
 		snd_card_free(card);
 		return err;
+	}
+
+	if (reset_workaround[dev]) {
+		snd_printdd(KERN_INFO "nm256: reset_workaround activated\n");
+		chip->reset_workaround = 1;
 	}
 
 	sprintf(card->shortname, "NeoMagic %s", card->driver);
diff -Nru a/sound/pci/rme32.c b/sound/pci/rme32.c
--- a/sound/pci/rme32.c	2004-12-24 13:37:30 -08:00
+++ b/sound/pci/rme32.c	2004-12-24 13:37:30 -08:00
@@ -92,15 +92,14 @@
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int fullduplex[SNDRV_CARDS]; // = {[0 ... (SNDRV_CARDS - 1)] = 1};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for RME Digi32 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for RME Digi32 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable RME Digi32 soundcard.");
-module_param_array(fullduplex, bool, boot_devs, 0444);
+module_param_array(fullduplex, bool, NULL, 0444);
 MODULE_PARM_DESC(fullduplex, "Support full-duplex mode.");
 MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>, Pilo Chambert <pilo.c@wanadoo.fr>");
 MODULE_DESCRIPTION("RME Digi32, Digi32/8, Digi32 PRO");
@@ -211,7 +210,7 @@
 	spinlock_t lock;
 	int irq;
 	unsigned long port;
-	unsigned long iobase;
+	void __iomem *iobase;
 
 	u32 wcreg;		/* cached write control register value */
 	u32 wcreg_spdif;	/* S/PDIF setup */
@@ -726,9 +725,8 @@
 	/* S/PDIF setup */
 	if ((rme32->wcreg & RME32_WCR_ADAT) == 0) {
 		rme32->wcreg &= ~(RME32_WCR_PRO | RME32_WCR_EMP);
-		writel(rme32->wcreg |=
-		       rme32->wcreg_spdif_stream,
-		       rme32->iobase + RME32_IO_CONTROL_REGISTER);
+		rme32->wcreg |= rme32->wcreg_spdif_stream;
+		writel(rme32->wcreg, rme32->iobase + RME32_IO_CONTROL_REGISTER);
 	}
 	spin_unlock_irq(&rme32->lock);
 
@@ -1124,7 +1122,7 @@
 	}
 	
 	/* prefill playback buffer */
-	if (cmd == SNDRV_PCM_TRIGGER_START) {
+	if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) {
 		snd_pcm_group_for_each(pos, substream) {
 			s = snd_pcm_group_substream_entry(pos);
 			if (s == rme32->playback_substream) {
@@ -1345,13 +1343,14 @@
 		rme32->irq = -1;
 	}
 	if (rme32->iobase) {
-		iounmap((void *) rme32->iobase);
-		rme32->iobase = 0;
+		iounmap(rme32->iobase);
+		rme32->iobase = NULL;
 	}
 	if (rme32->port) {
 		pci_release_regions(rme32->pci);
 		rme32->port = 0;
 	}
+	pci_disable_device(rme32->pci);
 }
 
 static void snd_rme32_free_spdif_pcm(snd_pcm_t * pcm)
@@ -1388,7 +1387,7 @@
 	}
 	rme32->irq = pci->irq;
 
-	if ((rme32->iobase = (unsigned long) ioremap_nocache(rme32->port, RME32_IO_SIZE)) == 0) {
+	if ((rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE)) == 0) {
 		snd_printk("unable to remap memory region 0x%lx-0x%lx\n",
 			   rme32->port, rme32->port + RME32_IO_SIZE - 1);
 		return -ENOMEM;
@@ -1637,8 +1636,8 @@
 		val &= ~RME32_WCR_MUTE;
 	else
 		val |= RME32_WCR_MUTE;
-	writel(rme32->wcreg =
-	       val, rme32->iobase + RME32_IO_CONTROL_REGISTER);
+	rme32->wcreg = val;
+	writel(val, rme32->iobase + RME32_IO_CONTROL_REGISTER);
 	spin_unlock_irq(&rme32->lock);
 	return change;
 }
@@ -1862,7 +1861,8 @@
 	change = val != rme32->wcreg_spdif_stream;
 	rme32->wcreg_spdif_stream = val;
 	rme32->wcreg &= ~(RME32_WCR_PRO | RME32_WCR_EMP);
-	writel(rme32->wcreg |= val, rme32->iobase + RME32_IO_CONTROL_REGISTER);
+	rme32->wcreg |= val;
+	writel(rme32->wcreg, rme32->iobase + RME32_IO_CONTROL_REGISTER);
 	spin_unlock_irq(&rme32->lock);
 	return change;
 }
@@ -1970,16 +1970,14 @@
 	snd_card_t *card;
 	int err;
 
-	for (; dev < SNDRV_CARDS; dev++) {
-		if (!enable[dev]) {
-			dev++;
-			return -ENOENT;
-		}
-		break;
-	}
 	if (dev >= SNDRV_CARDS) {
 		return -ENODEV;
 	}
+	if (!enable[dev]) {
+		dev++;
+		return -ENOENT;
+	}
+
 	if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
 				 sizeof(rme32_t))) == NULL)
 		return -ENOMEM;
diff -Nru a/sound/pci/rme96.c b/sound/pci/rme96.c
--- a/sound/pci/rme96.c	2004-12-24 13:36:47 -08:00
+++ b/sound/pci/rme96.c	2004-12-24 13:36:47 -08:00
@@ -56,13 +56,12 @@
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for RME Digi96 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for RME Digi96 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable RME Digi96 soundcard.");
 
 /*
@@ -225,7 +224,7 @@
 	spinlock_t    lock;
 	int irq;
 	unsigned long port;
-	unsigned long iobase;
+	void __iomem *iobase;
 	
 	u32 wcreg;    /* cached write control register value */
 	u32 wcreg_spdif;		/* S/PDIF setup */
@@ -1547,13 +1546,14 @@
 		rme96->irq = -1;
 	}
 	if (rme96->iobase) {
-		iounmap((void *)rme96->iobase);
-		rme96->iobase = 0;
+		iounmap(rme96->iobase);
+		rme96->iobase = NULL;
 	}
 	if (rme96->port) {
 		pci_release_regions(rme96->pci);
 		rme96->port = 0;
 	}
+	pci_disable_device(rme96->pci);
 }
 
 static void
@@ -1592,7 +1592,7 @@
 	}
 	rme96->irq = pci->irq;
 
-	if ((rme96->iobase = (unsigned long) ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) {
+	if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) {
 		snd_printk("unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
 		return -ENOMEM;
 	}
@@ -1859,7 +1859,8 @@
 	spin_lock_irq(&rme96->lock);
 	val = (rme96->wcreg & ~RME96_WCR_SEL) | val;
 	change = val != rme96->wcreg;
-	writel(rme96->wcreg = val, rme96->iobase + RME96_IO_CONTROL_REGISTER);
+	rme96->wcreg = val;
+	writel(val, rme96->iobase + RME96_IO_CONTROL_REGISTER);
 	spin_unlock_irq(&rme96->lock);
 	return change;
 }
@@ -2177,7 +2178,8 @@
 	change = val != rme96->wcreg_spdif_stream;
 	rme96->wcreg_spdif_stream = val;
 	rme96->wcreg &= ~(RME96_WCR_PRO | RME96_WCR_DOLBY | RME96_WCR_EMP);
-	writel(rme96->wcreg |= val, rme96->iobase + RME96_IO_CONTROL_REGISTER);
+	rme96->wcreg |= val;
+	writel(rme96->wcreg, rme96->iobase + RME96_IO_CONTROL_REGISTER);
 	spin_unlock_irq(&rme96->lock);
 	return change;
 }
diff -Nru a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
--- a/sound/pci/rme9652/hdsp.c	2004-12-24 13:36:47 -08:00
+++ b/sound/pci/rme9652/hdsp.c	2004-12-24 13:36:47 -08:00
@@ -48,17 +48,16 @@
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int precise_ptr[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* Enable precise pointer */
 static int line_outs_monitor[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0}; /* Send all inputs/playback to line outs */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for RME Hammerfall DSP interface.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for RME Hammerfall DSP interface.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable/disable specific Hammerfall DSP soundcards.");
-module_param_array(precise_ptr, bool, boot_devs, 0444);
+module_param_array(precise_ptr, bool, NULL, 0444);
 MODULE_PARM_DESC(precise_ptr, "Enable precise pointer (doesn't work reliably).");
-module_param_array(line_outs_monitor, bool, boot_devs, 0444);
+module_param_array(line_outs_monitor, bool, NULL, 0444);
 MODULE_PARM_DESC(line_outs_monitor, "Send all input and playback streams to line outs by default.");
 MODULE_AUTHOR("Paul Davis <paul@linuxaudiosystems.com>, Marcus Andersson, Thomas Charbonnel <thomas@undata.org>");
 MODULE_DESCRIPTION("RME Hammerfall DSP");
@@ -471,7 +470,7 @@
 	int                   dev;
 	int                   irq;
 	unsigned long         port;
-        unsigned long         iobase;
+        void __iomem         *iobase;
 	snd_card_t           *card;
 	snd_pcm_t            *pcm;
 	snd_hwdep_t          *hwdep;
@@ -935,9 +934,7 @@
 	}
 
 	position &= HDSP_BufferPositionMask;
-	position /= 4;
-	position -= 32;
-	position &= (HDSP_CHANNEL_BUFFER_SAMPLES-1);
+	position &= (hdsp->period_bytes/2) - 1;
 	return position;
 }
 
@@ -3228,7 +3225,7 @@
 	snd_iprintf(buffer, "Buffers: capture %p playback %p\n",
 		    hdsp->capture_buffer, hdsp->playback_buffer);
 	snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
-		    hdsp->irq, hdsp->port, hdsp->iobase);
+		    hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase);
 	snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register);
 	snd_iprintf(buffer, "Control2 register: 0x%x\n", hdsp->control2_register);
 	snd_iprintf(buffer, "Status register: 0x%x\n", status);
@@ -4434,6 +4431,130 @@
 }
 
 
+/* helper functions for copying meter values */
+static inline int copy_u32_le(void __user *dest, void __iomem *src)
+{
+	u32 val = readl(src);
+	return copy_to_user(dest, &val, 4);
+}
+
+static inline int copy_u64_le(void __user *dest, void __iomem *src_low, void __iomem *src_high)
+{
+	u32 rms_low, rms_high;
+	u64 rms;
+	rms_low = readl(src_low);
+	rms_high = readl(src_high);
+	rms = ((u64)rms_high << 32) | rms_low;
+	return copy_to_user(dest, &rms, 8);
+}
+
+static inline int copy_u48_le(void __user *dest, void __iomem *src_low, void __iomem *src_high)
+{
+	u32 rms_low, rms_high;
+	u64 rms;
+	rms_low = readl(src_low) & 0xffffff00;
+	rms_high = readl(src_high) & 0xffffff00;
+	rms = ((u64)rms_high << 32) | rms_low;
+	return copy_to_user(dest, &rms, 8);
+}
+
+static int hdsp_9652_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
+{
+	int doublespeed = 0;
+	int i, j, channels, ofs;
+
+	if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
+		doublespeed = 1;
+	channels = doublespeed ? 14 : 26;
+	for (i = 0, j = 0; i < 26; ++i) {
+		if (doublespeed && (i & 4))
+			continue;
+		ofs = HDSP_9652_peakBase - j * 4;
+		if (copy_u32_le(&peak_rms->input_peaks[i], hdsp->iobase + ofs))
+			return -EFAULT;
+		ofs -= channels * 4;
+		if (copy_u32_le(&peak_rms->playback_peaks[i], hdsp->iobase + ofs))
+			return -EFAULT;
+		ofs -= channels * 4;
+		if (copy_u32_le(&peak_rms->output_peaks[i], hdsp->iobase + ofs))
+			return -EFAULT;
+		ofs = HDSP_9652_rmsBase + j * 8;
+		if (copy_u48_le(&peak_rms->input_rms[i], hdsp->iobase + ofs,
+				hdsp->iobase + ofs + 4))
+			return -EFAULT;
+		ofs += channels * 8;
+		if (copy_u48_le(&peak_rms->playback_rms[i], hdsp->iobase + ofs,
+				hdsp->iobase + ofs + 4))
+			return -EFAULT;
+		ofs += channels * 8;
+		if (copy_u48_le(&peak_rms->output_rms[i], hdsp->iobase + ofs,
+				hdsp->iobase + ofs + 4))
+			return -EFAULT;
+		j++;
+	}
+	return 0;
+}
+
+static int hdsp_9632_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
+{
+	int i, j;
+	hdsp_9632_meters_t __iomem *m;
+	int doublespeed = 0;
+
+	if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
+		doublespeed = 1;
+	m = (hdsp_9632_meters_t __iomem *)(hdsp->iobase+HDSP_9632_metersBase);
+	for (i = 0, j = 0; i < 16; ++i, ++j) {
+		if (copy_u32_le(&peak_rms->input_peaks[i], &m->input_peak[j]))
+			return -EFAULT;
+		if (copy_u32_le(&peak_rms->playback_peaks[i], &m->playback_peak[j]))
+			return -EFAULT;
+		if (copy_u32_le(&peak_rms->output_peaks[i], &m->output_peak[j]))
+			return -EFAULT;
+		if (copy_u64_le(&peak_rms->input_rms[i], &m->input_rms_low[j],
+				&m->input_rms_high[j]))
+			return -EFAULT;
+		if (copy_u64_le(&peak_rms->playback_rms[i], &m->playback_rms_low[j],
+				&m->playback_rms_high[j]))
+			return -EFAULT;
+		if (copy_u64_le(&peak_rms->output_rms[i], &m->output_rms_low[j],
+				&m->output_rms_high[j]))
+			return -EFAULT;
+		if (doublespeed && i == 3) i += 4;
+	}
+	return 0;
+}
+
+static int hdsp_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
+{
+	int i;
+
+	for (i = 0; i < 26; i++) {
+		if (copy_u32_le(&peak_rms->playback_peaks[i],
+				hdsp->iobase + HDSP_playbackPeakLevel + i * 4))
+			return -EFAULT;
+		if (copy_u32_le(&peak_rms->input_peaks[i],
+				hdsp->iobase + HDSP_inputPeakLevel + i * 4))
+			return -EFAULT;
+	}
+	for (i = 0; i < 28; i++) {
+		if (copy_u32_le(&peak_rms->output_peaks[i],
+				hdsp->iobase + HDSP_outputPeakLevel + i * 4))
+			return -EFAULT;
+	}
+	for (i = 0; i < 26; ++i) {
+		if (copy_u64_le(&peak_rms->playback_rms[i],
+				hdsp->iobase + HDSP_playbackRmsLevel + i * 8,
+				hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4))
+			return -EFAULT;
+		if (copy_u64_le(&peak_rms->input_rms[i], 
+				hdsp->iobase + HDSP_inputRmsLevel + i * 8,
+				hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4))
+			return -EFAULT;
+	}
+	return 0;
+}
+
 static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int cmd, unsigned long arg)
 {
 	hdsp_t *hdsp = (hdsp_t *)hw->private_data;	
@@ -4441,108 +4562,21 @@
 
 	switch (cmd) {
 	case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: {
-		hdsp_peak_rms_t __user *peak_rms;
-		int i;
-		
-		if (hdsp->io_type == H9652) {
-			unsigned long rms_low, rms_high;
-			int doublespeed = 0;
-			if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
-				doublespeed = 1;
-			peak_rms = (hdsp_peak_rms_t __user *)arg;
-			for (i = 0; i < 26; ++i) {
-				if (!(doublespeed && (i & 4))) {
-					if (copy_to_user_fromio((void __user *)peak_rms->input_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-i*4, 4) != 0)
-						return -EFAULT;
-					if (copy_to_user_fromio((void __user *)peak_rms->playback_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
-						return -EFAULT;
-					if (copy_to_user_fromio((void __user *)peak_rms->output_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-2*(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
-						return -EFAULT;
-					rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8) & 0xFFFFFF00;
-					rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8+4) & 0xFFFFFF00;
-					rms_high += (rms_low >> 24);
-					rms_low <<= 8;
-					if (copy_to_user((void __user *)peak_rms->input_rms+i*8, &rms_low, 4) != 0)
-						return -EFAULT;
-					if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, &rms_high, 4) != 0)
-						return -EFAULT;					
-					rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
-					rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
-					rms_high += (rms_low >> 24);
-					rms_low <<= 8;
-					if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, &rms_low, 4) != 0)
-						return -EFAULT;
-					if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, &rms_high, 4) != 0)
-						return -EFAULT;					
-					rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
-					rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
-					rms_high += (rms_low >> 24);
-					rms_low <<= 8;
-					if (copy_to_user((void __user *)peak_rms->output_rms+i*8, &rms_low, 4) != 0)
-						return -EFAULT;
-					if (copy_to_user((void __user *)peak_rms->output_rms+i*8+4, &rms_high, 4) != 0)
-						return -EFAULT;					
-				}
-			}
-			return 0;
-		}
-		if (hdsp->io_type == H9632) {
-			int j;
-			hdsp_9632_meters_t *m;
-			int doublespeed = 0;
-			if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
-				doublespeed = 1;
-			m = (hdsp_9632_meters_t *)(hdsp->iobase+HDSP_9632_metersBase);
-			peak_rms = (hdsp_peak_rms_t __user *)arg;
-			for (i = 0, j = 0; i < 16; ++i, ++j) {
-				if (copy_to_user((void __user *)peak_rms->input_peaks+i*4, &(m->input_peak[j]), 4) != 0)
-					return -EFAULT;
-				if (copy_to_user((void __user *)peak_rms->playback_peaks+i*4, &(m->playback_peak[j]), 4) != 0)
-					return -EFAULT;
-				if (copy_to_user((void __user *)peak_rms->output_peaks+i*4, &(m->output_peak[j]), 4) != 0)
-					return -EFAULT;
-				if (copy_to_user((void __user *)peak_rms->input_rms+i*8, &(m->input_rms_low[j]), 4) != 0)
-					return -EFAULT;
-				if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, &(m->playback_rms_low[j]), 4) != 0)
-					return -EFAULT;
-				if (copy_to_user((void __user *)peak_rms->output_rms+i*8, &(m->output_rms_low[j]), 4) != 0)
-					return -EFAULT;
-				if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, &(m->input_rms_high[j]), 4) != 0)
-					return -EFAULT;
-				if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, &(m->playback_rms_high[j]), 4) != 0)
-					return -EFAULT;
-				if (copy_to_user((void __user *)peak_rms->output_rms+i*8+4, &(m->output_rms_high[j]), 4) != 0)
-					return -EFAULT;
-				if (doublespeed && i == 3) i += 4;
-			}
-			return 0;
-		}
+		hdsp_peak_rms_t __user *peak_rms = (hdsp_peak_rms_t __user *)arg;
+
 		if (!(hdsp->state & HDSP_FirmwareLoaded)) {
-			snd_printk("firmware needs to be uploaded to the card.\n");	
+			snd_printk(KERN_ERR "firmware needs to be uploaded to the card.\n");
 			return -EINVAL;
 		}
-		peak_rms = (hdsp_peak_rms_t __user *)arg;
-		for (i = 0; i < 26; ++i) {
-		    if (copy_to_user((void __user *)peak_rms->playback_peaks+i*4, (void *)hdsp->iobase+HDSP_playbackPeakLevel+i*4, 4) != 0)
-			    return -EFAULT;
-		    if (copy_to_user((void __user *)peak_rms->input_peaks+i*4, (void *)hdsp->iobase+HDSP_inputPeakLevel+i*4, 4) != 0)
-			    return -EFAULT;
-		}
-		for (i = 0; i < 26; ++i) {
-			if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8, 4) != 0)
-				return -EFAULT;
-			if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8+4, 4) != 0)
-				return -EFAULT;
-			if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8, 4) != 0)
-				return -EFAULT;
-			if (copy_to_user((void __user *)peak_rms->input_rms+i*8, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8+4, 4) != 0)
-				return -EFAULT;
-		}
-		for (i = 0; i < 28; ++i) {
-		    if (copy_to_user((void __user *)peak_rms->output_peaks+i*4, (void *)hdsp->iobase+HDSP_outputPeakLevel+i*4, 4) != 0)
-			    return -EFAULT;
+
+		switch (hdsp->io_type) {
+		case H9652:
+			return hdsp_9652_get_peak(hdsp, peak_rms);
+		case H9632:
+			return hdsp_9632_get_peak(hdsp, peak_rms);
+		default:
+			return hdsp_get_peak(hdsp, peak_rms);
 		}
-		break;
 	}
 	case SNDRV_HDSP_IOCTL_GET_CONFIG_INFO: {
 		hdsp_config_info_t info;
@@ -4620,7 +4654,7 @@
 	}
 	case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: {
 		hdsp_firmware_t __user *firmware;
-		unsigned long __user *firmware_data;
+		u32 __user *firmware_data;
 		int err;
 		
 		if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
@@ -4638,7 +4672,7 @@
 			return -EIO;
 		}
 
-		if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(unsigned long)*24413) != 0) {
+		if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0) {
 			return -EFAULT;
 		}
 		
@@ -4879,7 +4913,7 @@
 	hdsp->midi[1].output = NULL;
 	spin_lock_init(&hdsp->midi[0].lock);
 	spin_lock_init(&hdsp->midi[1].lock);
-	hdsp->iobase = 0;
+	hdsp->iobase = NULL;
 	hdsp->control_register = 0;
 	hdsp->control2_register = 0;
 	hdsp->io_type = Undefined;
@@ -4937,7 +4971,7 @@
 	if ((err = pci_request_regions(pci, "hdsp")) < 0)
 		return err;
 	hdsp->port = pci_resource_start(pci, 0);
-	if ((hdsp->iobase = (unsigned long) ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == 0) {
+	if ((hdsp->iobase = ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == NULL) {
 		snd_printk("unable to remap region 0x%lx-0x%lx\n", hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
 		return -EBUSY;
 	}
@@ -5021,11 +5055,12 @@
 	snd_hdsp_free_buffers(hdsp);
 	
 	if (hdsp->iobase)
-		iounmap((void *) hdsp->iobase);
+		iounmap(hdsp->iobase);
 
 	if (hdsp->port)
 		pci_release_regions(hdsp->pci);
 		
+	pci_disable_device(hdsp->pci);
 	return 0;
 }
 
diff -Nru a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
--- a/sound/pci/rme9652/rme9652.c	2004-12-24 13:36:48 -08:00
+++ b/sound/pci/rme9652/rme9652.c	2004-12-24 13:36:48 -08:00
@@ -42,15 +42,14 @@
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int precise_ptr[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* Enable precise pointer */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for RME Digi9652 (Hammerfall) soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for RME Digi9652 (Hammerfall) soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable/disable specific RME96{52,36} soundcards.");
-module_param_array(precise_ptr, bool, boot_devs, 0444);
+module_param_array(precise_ptr, bool, NULL, 0444);
 MODULE_PARM_DESC(precise_ptr, "Enable precise pointer (doesn't work reliably).");
 MODULE_AUTHOR("Paul Davis <pbd@op.net>, Winfried Ritsch");
 MODULE_DESCRIPTION("RME Digi9652/Digi9636");
@@ -212,7 +211,7 @@
 	spinlock_t lock;
 	int irq;
 	unsigned long port;
-	unsigned long iobase;
+	void __iomem *iobase;
 	
 	int precise_ptr;
 
@@ -1629,7 +1628,7 @@
 	snd_iprintf(buffer, "Buffers: capture %p playback %p\n",
 		    rme9652->capture_buffer, rme9652->playback_buffer);
 	snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
-		    rme9652->irq, rme9652->port, rme9652->iobase);
+		    rme9652->irq, rme9652->port, (unsigned long)rme9652->iobase);
 	snd_iprintf(buffer, "Control register: %x\n", rme9652->control_register);
 
 	snd_iprintf(buffer, "\n");
@@ -1809,10 +1808,11 @@
 	if (rme9652->irq >= 0)
 		free_irq(rme9652->irq, (void *)rme9652);
 	if (rme9652->iobase)
-		iounmap((void *) rme9652->iobase);
+		iounmap(rme9652->iobase);
 	if (rme9652->port)
 		pci_release_regions(rme9652->pci);
 
+	pci_disable_device(rme9652->pci);
 	return 0;
 }
 
@@ -2497,8 +2497,8 @@
 	if ((err = pci_request_regions(pci, "rme9652")) < 0)
 		return err;
 	rme9652->port = pci_resource_start(pci, 0);
-	rme9652->iobase = (unsigned long) ioremap_nocache(rme9652->port, RME9652_IO_EXTENT);
-	if (rme9652->iobase == 0) {
+	rme9652->iobase = ioremap_nocache(rme9652->port, RME9652_IO_EXTENT);
+	if (rme9652->iobase == NULL) {
 		snd_printk("unable to remap region 0x%lx-0x%lx\n", rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1);
 		return -EBUSY;
 	}
diff -Nru a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
--- a/sound/pci/sonicvibes.c	2004-12-24 13:37:02 -08:00
+++ b/sound/pci/sonicvibes.c	2004-12-24 13:37:02 -08:00
@@ -59,17 +59,16 @@
 static int reverb[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 static int mge[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 static unsigned int dmaio = 0x7a00;	/* DDMA i/o address */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for S3 SonicVibes soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for S3 SonicVibes soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable S3 SonicVibes soundcard.");
-module_param_array(reverb, bool, boot_devs, 0444);
+module_param_array(reverb, bool, NULL, 0444);
 MODULE_PARM_DESC(reverb, "Enable reverb (SRAM is present) for S3 SonicVibes soundcard.");
-module_param_array(mge, bool, boot_devs, 0444);
+module_param_array(mge, bool, NULL, 0444);
 MODULE_PARM_DESC(mge, "MIC Gain Enable for S3 SonicVibes soundcard.");
 module_param(dmaio, uint, 0444);
 MODULE_PARM_DESC(dmaio, "DDMA i/o base address for S3 SonicVibes soundcard.");
@@ -1186,6 +1185,7 @@
 		kfree_nocheck(sonic->res_dmac);
 	}
 	pci_release_regions(sonic->pci);
+	pci_disable_device(sonic->pci);
 	kfree(sonic);
 	return 0;
 }
@@ -1217,12 +1217,15 @@
         if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
                 snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
                 return -ENXIO;
         }
 
 	sonic = kcalloc(1, sizeof(*sonic), GFP_KERNEL);
-	if (sonic == NULL)
+	if (sonic == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	spin_lock_init(&sonic->reg_lock);
 	sonic->card = card;
 	sonic->pci = pci;
@@ -1230,6 +1233,7 @@
 
 	if ((err = pci_request_regions(pci, "S3 SonicVibes")) < 0) {
 		kfree(sonic);
+		pci_disable_device(pci);
 		return err;
 	}
 
diff -Nru a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
--- a/sound/pci/trident/trident.c	2004-12-24 13:36:16 -08:00
+++ b/sound/pci/trident/trident.c	2004-12-24 13:36:16 -08:00
@@ -51,17 +51,16 @@
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32};
 static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192};
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Trident 4DWave PCI soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Trident 4DWave PCI soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Trident 4DWave PCI soundcard.");
-module_param_array(pcm_channels, int, boot_devs, 0444);
+module_param_array(pcm_channels, int, NULL, 0444);
 MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM.");
-module_param_array(wavetable_size, int, boot_devs, 0444);
+module_param_array(wavetable_size, int, NULL, 0444);
 MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth.");
 
 static struct pci_device_id snd_trident_ids[] = {
diff -Nru a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
--- a/sound/pci/trident/trident_main.c	2004-12-24 13:37:00 -08:00
+++ b/sound/pci/trident/trident_main.c	2004-12-24 13:37:00 -08:00
@@ -3537,12 +3537,15 @@
 	if (pci_set_dma_mask(pci, 0x3fffffff) < 0 ||
 	    pci_set_consistent_dma_mask(pci, 0x3fffffff) < 0) {
 		snd_printk("architecture does not support 30bit PCI busmaster DMA\n");
+		pci_disable_device(pci);
 		return -ENXIO;
 	}
 	
 	trident = kcalloc(1, sizeof(*trident), GFP_KERNEL);
-	if (trident == NULL)
+	if (trident == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	trident->device = (pci->vendor << 16) | pci->device;
 	trident->card = card;
 	trident->pci = pci;
@@ -3564,6 +3567,7 @@
 
 	if ((err = pci_request_regions(pci, "Trident Audio")) < 0) {
 		kfree(trident);
+		pci_disable_device(pci);
 		return err;
 	}
 	trident->port = pci_resource_start(pci, 0);
@@ -3682,6 +3686,7 @@
 	if (trident->irq >= 0)
 		free_irq(trident->irq, (void *)trident);
 	pci_release_regions(trident->pci);
+	pci_disable_device(trident->pci);
 	kfree(trident);
 	return 0;
 }
@@ -3949,6 +3954,7 @@
 	case TRIDENT_DEVICE_ID_SI7018:
 		break;
 	}
+	pci_disable_device(trident->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
diff -Nru a/sound/pci/via82xx.c b/sound/pci/via82xx.c
--- a/sound/pci/via82xx.c	2004-12-24 13:37:18 -08:00
+++ b/sound/pci/via82xx.c	2004-12-24 13:37:18 -08:00
@@ -83,25 +83,24 @@
 static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000};
 static int ac97_quirk[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = AC97_TUNE_DEFAULT};
 static int dxs_support[SNDRV_CARDS];
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable audio part of VIA 82xx bridge.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 port. (VT82C686x only)");
 #ifdef SUPPORT_JOYSTICK
-module_param_array(joystick, bool, boot_devs, 0444);
+module_param_array(joystick, bool, NULL, 0444);
 MODULE_PARM_DESC(joystick, "Enable joystick. (VT82C686x only)");
 #endif
-module_param_array(ac97_clock, int, boot_devs, 0444);
+module_param_array(ac97_clock, int, NULL, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
-module_param_array(ac97_quirk, int, boot_devs, 0444);
+module_param_array(ac97_quirk, int, NULL, 0444);
 MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
-module_param_array(dxs_support, int, boot_devs, 0444);
+module_param_array(dxs_support, int, NULL, 0444);
 MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA)");
 
 
@@ -127,6 +126,7 @@
 #define VIA_REV_8233		0x30	/* 2 rec, 4 pb, 1 multi-pb, spdif */
 #define VIA_REV_8233A		0x40	/* 1 rec, 1 multi-pb, spdf */
 #define VIA_REV_8235		0x50	/* 2 rec, 4 pb, 1 multi-pb, spdif */
+#define VIA_REV_8237		0x60
 
 /*
  *  Direct registers
@@ -623,11 +623,6 @@
 	unsigned int status;
 	unsigned int i;
 
-#if 0
-	/* FIXME: does it work on via823x? */
-	if (chip->chip_type != TYPE_VIA686)
-		goto _skip_sgd;
-#endif
 	status = inl(VIAREG(chip, SGD_SHADOW));
 	if (! (status & chip->intr_mask)) {
 		if (chip->rmidi)
@@ -635,7 +630,6 @@
 			return snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
 		return IRQ_NONE;
 	}
-// _skip_sgd:
 
 	/* check status for each stream */
 	spin_lock(&chip->reg_lock);
@@ -1547,6 +1541,13 @@
 }
 
 static struct ac97_quirk ac97_quirks[] = {
+	{
+		.vendor = 0x1106,
+		.device = 0x4161,
+		.codec_id = 0x56494161, /* VT1612A */
+		.name = "Soltek SL-75DRV5",
+		.type = AC97_TUNE_NONE
+	},
 	{	/* FIXME: which codec? */
 		.vendor = 0x1106,
 		.device = 0x4161,
@@ -1606,6 +1607,7 @@
 		return err;
 	chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus;
 	chip->ac97_bus->clock = chip->ac97_clock;
+	chip->ac97_bus->shared_type = AC97_SHARED_TYPE_VIA;
 
 	memset(&ac97, 0, sizeof(ac97));
 	ac97.private_data = chip;
@@ -1978,6 +1980,7 @@
 		pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy);
 		pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg);
 	}
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -2004,8 +2007,10 @@
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 
-	if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL)
+	if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 
 	chip->chip_type = chip_type;
 	chip->revision = revision;
@@ -2023,6 +2028,7 @@
 
 	if ((err = pci_request_regions(pci, card->driver)) < 0) {
 		kfree(chip);
+		pci_disable_device(pci);
 		return err;
 	}
 	chip->port = pci_resource_start(pci, 0);
@@ -2069,6 +2075,7 @@
 	{ VIA_REV_8233, "VIA 8233", TYPE_VIA8233 },
 	{ VIA_REV_8233A, "VIA 8233A", TYPE_VIA8233A },
 	{ VIA_REV_8235, "VIA 8235", TYPE_VIA8233 },
+	{ VIA_REV_8237, "VIA 8237", TYPE_VIA8233 },
 };
 
 /*
@@ -2095,10 +2102,11 @@
 		{ .vendor = 0x1071, .device = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */
 		{ .vendor = 0x10cf, .device = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */
 		{ .vendor = 0x1106, .device = 0x4161, .action = VIA_DXS_NO_VRA }, /* ASRock K7VT2 */
+		{ .vendor = 0x1106, .device = 0x4552, .action = VIA_DXS_NO_VRA }, /* QDI Kudoz 7X/600-6AL */
 		{ .vendor = 0x1106, .device = 0xaa01, .action = VIA_DXS_NO_VRA }, /* EPIA MII */
 		{ .vendor = 0x1297, .device = 0xa232, .action = VIA_DXS_ENABLE }, /* Shuttle ?? */
 		{ .vendor = 0x1297, .device = 0xc160, .action = VIA_DXS_ENABLE }, /* Shuttle SK41G */
-		{ .vendor = 0x1458, .device = 0xa002, .action = VIA_DXS_NO_VRA }, /* Gigabyte GA-7VAXP (FIXME: or DXS_ENABLE?) */
+		{ .vendor = 0x1458, .device = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */
 		{ .vendor = 0x147b, .device = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */
 		{ .vendor = 0x14ff, .device = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */
 		{ .vendor = 0x1462, .device = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */
@@ -2194,6 +2202,8 @@
 		}
 		if (chip_type == TYPE_VIA8233A)
 			strcpy(card->driver, "VIA8233A");
+		else if (revision >= VIA_REV_8237)
+			strcpy(card->driver, "VIA8237"); /* no slog assignment */
 		else
 			strcpy(card->driver, "VIA8233");
 		break;
@@ -2235,8 +2245,9 @@
 	for (i = 0; i < chip->num_devs; i++)
 		snd_via82xx_channel_reset(chip, &chip->devs[i]);
 
-	sprintf(card->longname, "%s at 0x%lx, irq %d",
-		card->shortname, chip->port, chip->irq);
+	snprintf(card->longname, sizeof(card->longname),
+		 "%s with %s at %#lx, irq %d", card->shortname,
+		 snd_ac97_get_short_name(chip->ac97), chip->port, chip->irq);
 
 	snd_via82xx_proc_init(chip);
 
diff -Nru a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
--- a/sound/pci/vx222/vx222.c	2004-12-24 13:36:55 -08:00
+++ b/sound/pci/vx222/vx222.c	2004-12-24 13:36:55 -08:00
@@ -40,17 +40,16 @@
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
 static int mic[SNDRV_CARDS]; /* microphone */
 static int ibl[SNDRV_CARDS]; /* microphone */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Digigram " CARD_NAME " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard.");
-module_param_array(mic, bool, boot_devs, 0444);
+module_param_array(mic, bool, NULL, 0444);
 MODULE_PARM_DESC(mic, "Enable Microphone.");
-module_param_array(ibl, int, boot_devs, 0444);
+module_param_array(ibl, int, NULL, 0444);
 MODULE_PARM_DESC(ibl, "Capture IBL size.");
 
 /*
@@ -117,6 +116,7 @@
 		free_irq(chip->irq, (void*)chip);
 	if (vx->port[0])
 		pci_release_regions(vx->pci);
+	pci_disable_device(vx->pci);
 	kfree(chip);
 	return 0;
 }
@@ -148,8 +148,10 @@
 	vx_ops = hw->type == VX_TYPE_BOARD ? &vx222_old_ops : &vx222_ops;
 	chip = snd_vx_create(card, hw, vx_ops,
 			     sizeof(struct snd_vx222) - sizeof(vx_core_t));
-	if (! chip)
+	if (! chip) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	vx = (struct snd_vx222 *)chip;
 	vx->pci = pci;
 
diff -Nru a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
--- a/sound/pci/ymfpci/ymfpci.c	2004-12-24 13:36:48 -08:00
+++ b/sound/pci/ymfpci/ymfpci.c	2004-12-24 13:36:48 -08:00
@@ -49,23 +49,22 @@
 static long joystick_port[SNDRV_CARDS];
 #endif
 static int rear_switch[SNDRV_CARDS];
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for the Yamaha DS-XG PCI soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for the Yamaha DS-XG PCI soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Yamaha DS-XG soundcard.");
-module_param_array(mpu_port, long, boot_devs, 0444);
+module_param_array(mpu_port, long, NULL, 0444);
 MODULE_PARM_DESC(mpu_port, "MPU-401 Port.");
-module_param_array(fm_port, long, boot_devs, 0444);
+module_param_array(fm_port, long, NULL, 0444);
 MODULE_PARM_DESC(fm_port, "FM OPL-3 Port.");
 #ifdef SUPPORT_JOYSTICK
-module_param_array(joystick_port, long, boot_devs, 0444);
+module_param_array(joystick_port, long, NULL, 0444);
 MODULE_PARM_DESC(joystick_port, "Joystick port address");
 #endif
-module_param_array(rear_switch, bool, boot_devs, 0444);
+module_param_array(rear_switch, bool, NULL, 0444);
 MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch");
 
 static struct pci_device_id snd_ymfpci_ids[] = {
diff -Nru a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
--- a/sound/pci/ymfpci/ymfpci_main.c	2004-12-24 13:37:19 -08:00
+++ b/sound/pci/ymfpci/ymfpci_main.c	2004-12-24 13:37:19 -08:00
@@ -2085,7 +2085,7 @@
 	}
 #endif
 	if (chip->reg_area_virt)
-		iounmap((void *)chip->reg_area_virt);
+		iounmap(chip->reg_area_virt);
 	if (chip->work_ptr.area)
 		snd_dma_free_pages(&chip->work_ptr);
 	
@@ -2098,6 +2098,7 @@
 
 	pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
 	
+	pci_disable_device(chip->pci);
 	kfree(chip);
 	return 0;
 }
@@ -2153,6 +2154,7 @@
 	chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE);
 	snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);
 	snd_ymfpci_disable_dsp(chip);
+	pci_disable_device(chip->pci);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 	return 0;
 }
@@ -2204,8 +2206,10 @@
 		return err;
 
 	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-	if (chip == NULL)
+	if (chip == NULL) {
+		pci_disable_device(pci);
 		return -ENOMEM;
+	}
 	chip->old_legacy_ctrl = old_legacy_ctrl;
 	spin_lock_init(&chip->reg_lock);
 	spin_lock_init(&chip->voice_lock);
@@ -2217,7 +2221,7 @@
 	chip->device_id = pci->device;
 	pci_read_config_byte(pci, PCI_REVISION_ID, (u8 *)&chip->rev);
 	chip->reg_area_phys = pci_resource_start(pci, 0);
-	chip->reg_area_virt = (unsigned long)ioremap_nocache(chip->reg_area_phys, 0x8000);
+	chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000);
 	pci_set_master(pci);
 
 	if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) {
diff -Nru a/sound/pcmcia/Kconfig b/sound/pcmcia/Kconfig
--- a/sound/pcmcia/Kconfig	2004-12-24 13:36:55 -08:00
+++ b/sound/pcmcia/Kconfig	2004-12-24 13:36:55 -08:00
@@ -8,20 +8,32 @@
 	depends on SND && PCMCIA && ISA
 	select SND_VX_LIB
 	help
-	  Say 'Y' or 'M' to include support for Digigram VXpocket soundcard.
+	  Say Y here to include support for Digigram VXpocket
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-vxpocket.
 
 config SND_VXP440
 	tristate "Digigram VXpocket 440"
 	depends on SND && PCMCIA && ISA
 	select SND_VX_LIB
 	help
-	  Say 'Y' or 'M' to include support for Digigram VXpocket 440 soundcard.
+	  Say Y here to include support for Digigram VXpocket 440
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-vxp440.
 
 config SND_PDAUDIOCF
 	tristate "Sound Core PDAudioCF"
 	depends on SND && PCMCIA && ISA
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Sound Core PDAudioCF soundcard.
+	  Say Y here to include support for Sound Core PDAudioCF
+	  soundcards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-pdaudiocf.
 
 endmenu
diff -Nru a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c	2004-12-24 13:36:32 -08:00
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c	2004-12-24 13:36:32 -08:00
@@ -44,17 +44,16 @@
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable switches */
 static unsigned int irq_mask = 0xffff;
 static int irq_list[4] = { -1 };
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
 module_param(irq_mask, int, 0444);
 MODULE_PARM_DESC(irq_mask, "IRQ bitmask for " CARD_NAME " soundcard.");
-module_param_array(irq_list, int, boot_devs, 0444);
+module_param_array(irq_list, int, NULL, 0444);
 MODULE_PARM_DESC(irq_list, "List of Available interrupts for " CARD_NAME " soundcard.");
  
 
diff -Nru a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
--- a/sound/pcmcia/vx/vxpocket.c	2004-12-24 13:36:19 -08:00
+++ b/sound/pcmcia/vx/vxpocket.c	2004-12-24 13:36:19 -08:00
@@ -58,19 +58,18 @@
 static unsigned int irq_mask = 0xffff;
 static int irq_list[4] = { -1 };
 static int ibl[SNDRV_CARDS];
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
 module_param(irq_mask, int, 0444);
 MODULE_PARM_DESC(irq_mask, "IRQ bitmask for " CARD_NAME " soundcard.");
-module_param_array(irq_list, int, boot_devs, 0444);
+module_param_array(irq_list, int, NULL, 0444);
 MODULE_PARM_DESC(irq_list, "List of Available interrupts for " CARD_NAME " soundcard.");
-module_param_array(ibl, int, boot_devs, 0444);
+module_param_array(ibl, int, NULL, 0444);
 MODULE_PARM_DESC(ibl, "Capture IBL size for " CARD_NAME " soundcard.");
  
 
diff -Nru a/sound/ppc/Kconfig b/sound/ppc/Kconfig
--- a/sound/ppc/Kconfig	2004-12-24 13:36:48 -08:00
+++ b/sound/ppc/Kconfig	2004-12-24 13:36:48 -08:00
@@ -13,6 +13,11 @@
 	tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)"
 	depends on SND && I2C && INPUT
 	select SND_PCM
+	help
+	  Say Y here to include support for the integrated sound device.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-powermac.
 
 endmenu
 
diff -Nru a/sound/ppc/daca.c b/sound/ppc/daca.c
--- a/sound/ppc/daca.c	2004-12-24 13:36:19 -08:00
+++ b/sound/ppc/daca.c	2004-12-24 13:36:19 -08:00
@@ -56,10 +56,11 @@
 	unsigned short wdata = 0x00;
 	/* SR: no swap, 1bit delay, 32-48kHz */
 	/* GCFG: power amp inverted, DAC on */
-	if (snd_pmac_keywest_write_byte(i2c, DACA_REG_SR, 0x08) < 0 ||
-	    snd_pmac_keywest_write_byte(i2c, DACA_REG_GCFG, 0x05) < 0)
+	if (i2c_smbus_write_byte_data(i2c->client, DACA_REG_SR, 0x08) < 0 ||
+	    i2c_smbus_write_byte_data(i2c->client, DACA_REG_GCFG, 0x05) < 0)
 		return -EINVAL;
-	return snd_pmac_keywest_write(i2c, DACA_REG_AVOL, 2, (unsigned char*)&wdata);
+	return i2c_smbus_write_block_data(i2c->client, DACA_REG_AVOL,
+					  2, (unsigned char*)&wdata);
 }
 
 /*
@@ -81,9 +82,10 @@
 	else
 		data[1] = mix->right_vol;
 	data[1] |= mix->deemphasis ? 0x40 : 0;
-	if (snd_pmac_keywest_write(&mix->i2c, DACA_REG_AVOL, 2, data) < 0) {
-		snd_printk("failed to set volume \n");  
-		return -EINVAL; 
+	if (i2c_smbus_write_block_data(mix->i2c.client, DACA_REG_AVOL,
+				       2, data) < 0) {
+		snd_printk("failed to set volume \n");
+		return -EINVAL;
 	}
 	return 0;
 }
@@ -188,8 +190,8 @@
 	change = mix->amp_on != ucontrol->value.integer.value[0];
 	if (change) {
 		mix->amp_on = ucontrol->value.integer.value[0];
-		snd_pmac_keywest_write_byte(&mix->i2c, DACA_REG_GCFG,
-					    mix->amp_on ? 0x05 : 0x04);
+		i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_GCFG,
+					  mix->amp_on ? 0x05 : 0x04);
 	}
 	return change;
 }
@@ -220,9 +222,9 @@
 static void daca_resume(pmac_t *chip)
 {
 	pmac_daca_t *mix = chip->mixer_data;
-	snd_pmac_keywest_write_byte(&mix->i2c, DACA_REG_SR, 0x08);
-	snd_pmac_keywest_write_byte(&mix->i2c, DACA_REG_GCFG,
-				    mix->amp_on ? 0x05 : 0x04);
+	i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_SR, 0x08);
+	i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_GCFG,
+				  mix->amp_on ? 0x05 : 0x04);
 	daca_set_volume(mix);
 }
 #endif /* CONFIG_PMAC_PBOOK */
diff -Nru a/sound/ppc/pmac.c b/sound/ppc/pmac.c
--- a/sound/ppc/pmac.c	2004-12-24 13:37:33 -08:00
+++ b/sound/ppc/pmac.c	2004-12-24 13:37:33 -08:00
@@ -64,7 +64,7 @@
 		return -ENOMEM;
 	rec->size = size;
 	memset(rec->space, 0, sizeof(struct dbdma_cmd) * (size + 1));
-	rec->cmds = (void*)DBDMA_ALIGN(rec->space);
+	rec->cmds = (void __iomem *)DBDMA_ALIGN(rec->space);
 	rec->addr = virt_to_bus(rec->cmds);
 	return 0;
 }
@@ -200,7 +200,7 @@
 static int snd_pmac_pcm_prepare(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substream_t *subs)
 {
 	int i;
-	volatile struct dbdma_cmd *cp;
+	volatile struct dbdma_cmd __iomem *cp;
 	snd_pcm_runtime_t *runtime = subs->runtime;
 	int rate_index;
 	long offset;
@@ -263,7 +263,7 @@
 static int snd_pmac_pcm_trigger(pmac_t *chip, pmac_stream_t *rec,
 				snd_pcm_substream_t *subs, int cmd)
 {
-	volatile struct dbdma_cmd *cp;
+	volatile struct dbdma_cmd __iomem *cp;
 	int i, command;
 
 	switch (cmd) {
@@ -314,7 +314,7 @@
 
 #if 1 /* hmm.. how can we get the current dma pointer?? */
 	int stat;
-	volatile struct dbdma_cmd *cp = &rec->cmd.cmds[rec->cur_period];
+	volatile struct dbdma_cmd __iomem *cp = &rec->cmd.cmds[rec->cur_period];
 	stat = ld_le16(&cp->xfer_status);
 	if (stat & (ACTIVE|DEAD)) {
 		count = in_le16(&cp->res_count);
@@ -379,7 +379,7 @@
  */
 static void snd_pmac_pcm_update(pmac_t *chip, pmac_stream_t *rec)
 {
-	volatile struct dbdma_cmd *cp;
+	volatile struct dbdma_cmd __iomem *cp;
 	int c;
 	int stat;
 
@@ -818,11 +818,11 @@
 	if (chip->latch_base)
 		iounmap(chip->latch_base);
 	if (chip->awacs)
-		iounmap((void*)chip->awacs);
+		iounmap(chip->awacs);
 	if (chip->playback.dma)
-		iounmap((void*)chip->playback.dma);
+		iounmap(chip->playback.dma);
 	if (chip->capture.dma)
-		iounmap((void*)chip->capture.dma);
+		iounmap(chip->capture.dma);
 	if (chip->node) {
 		for (i = 0; i < 3; i++) {
 			if (chip->of_requested & (1 << i))
@@ -1133,9 +1133,9 @@
 		chip->of_requested |= (1 << i);
 	}
 
-	chip->awacs = (volatile struct awacs_regs *) ioremap(np->addrs[0].address, 0x1000);
-	chip->playback.dma = (volatile struct dbdma_regs *) ioremap(np->addrs[1].address, 0x100);
-	chip->capture.dma = (volatile struct dbdma_regs *) ioremap(np->addrs[2].address, 0x100);
+	chip->awacs = ioremap(np->addrs[0].address, 0x1000);
+	chip->playback.dma = ioremap(np->addrs[1].address, 0x100);
+	chip->capture.dma = ioremap(np->addrs[2].address, 0x100);
 	if (chip->model <= PMAC_BURGUNDY) {
 		if (request_irq(np->intrs[0].line, snd_pmac_ctrl_intr, 0,
 				"PMac", (void*)chip)) {
@@ -1176,15 +1176,14 @@
 		 * sound input.  The 0x100 enables the SCSI bus
 		 * terminator power.
 		 */
-		chip->latch_base = (unsigned char *) ioremap (0xf301a000, 0x1000);
+		chip->latch_base = ioremap (0xf301a000, 0x1000);
 		in_8(chip->latch_base + 0x190);
 	} else if (chip->is_pbook_G3) {
 		struct device_node* mio;
 		for (mio = chip->node->parent; mio; mio = mio->parent) {
 			if (strcmp(mio->name, "mac-io") == 0
 			    && mio->n_addrs > 0) {
-				chip->macio_base = (unsigned char *) ioremap
-					(mio->addrs[0].address, 0x40);
+				chip->macio_base = ioremap(mio->addrs[0].address, 0x40);
 				break;
 			}
 		}
diff -Nru a/sound/ppc/pmac.h b/sound/ppc/pmac.h
--- a/sound/ppc/pmac.h	2004-12-24 13:37:01 -08:00
+++ b/sound/ppc/pmac.h	2004-12-24 13:37:01 -08:00
@@ -61,7 +61,7 @@
  */
 struct snd_pmac_dbdma {
 	unsigned long addr;
-	struct dbdma_cmd *cmds;
+	struct dbdma_cmd __iomem *cmds;
 	void *space;
 	int size;
 };
@@ -80,7 +80,7 @@
 	int nperiods, cur_period;
 
 	pmac_dbdma_t cmd;
-	volatile struct dbdma_regs *dma;
+	volatile struct dbdma_regs __iomem *dma;
 
 	snd_pcm_substream_t *substream;
 
@@ -130,12 +130,12 @@
 	int format;			/* current format */
 
 	spinlock_t reg_lock;
-	volatile struct awacs_regs *awacs;
+	volatile struct awacs_regs __iomem *awacs;
 	int awacs_reg[8]; /* register cache */
 	unsigned int hp_stat_mask;
 
-	unsigned char *latch_base;
-	unsigned char *macio_base;
+	unsigned char __iomem *latch_base;
+	unsigned char __iomem *macio_base;
 
 	pmac_stream_t playback;
 	pmac_stream_t capture;
@@ -199,8 +199,6 @@
 
 int snd_pmac_keywest_init(pmac_keywest_t *i2c);
 void snd_pmac_keywest_cleanup(pmac_keywest_t *i2c);
-#define snd_pmac_keywest_write(i2c,cmd,len,data) i2c_smbus_write_block_data((i2c)->client, cmd, len, data)
-#define snd_pmac_keywest_write_byte(i2c,cmd,data) i2c_smbus_write_byte_data((i2c)->client, cmd, data)
 
 /* misc */
 int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo);
diff -Nru a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
--- a/sound/ppc/tumbler.c	2004-12-24 13:36:17 -08:00
+++ b/sound/ppc/tumbler.c	2004-12-24 13:36:17 -08:00
@@ -79,7 +79,7 @@
 #ifdef CONFIG_PPC_HAS_FEATURE_CALLS
 	unsigned int addr;
 #else
-	void *addr;
+	void __iomem *addr;
 #endif
 	int active_state;
 } pmac_gpio_t;
@@ -109,7 +109,8 @@
 	while (*regs > 0) {
 		int err, count = 10;
 		do {
-			err =  snd_pmac_keywest_write_byte(i2c, regs[0], regs[1]);
+			err = i2c_smbus_write_byte_data(i2c->client,
+							regs[0], regs[1]);
 			if (err >= 0)
 				break;
 			mdelay(10);
@@ -162,7 +163,7 @@
 {
 	if (gp->addr) {
 		iounmap(gp->addr);
-		gp->addr = 0;
+		gp->addr = NULL;
 	}
 }
 #endif /* CONFIG_PPC_HAS_FEATURE_CALLS */
@@ -220,9 +221,10 @@
 	block[4] = (right_vol >> 8)  & 0xff;
 	block[5] = (right_vol >> 0)  & 0xff;
   
-	if (snd_pmac_keywest_write(&mix->i2c, TAS_REG_VOL, 6, block) < 0) {
-		snd_printk("failed to set volume \n");  
-		return -EINVAL; 
+	if (i2c_smbus_write_block_data(mix->i2c.client, TAS_REG_VOL,
+				       6, block) < 0) {
+		snd_printk("failed to set volume \n");
+		return -EINVAL;
 	}
 	return 0;
 }
@@ -320,9 +322,10 @@
 		val[1] = 0;
 	}
 
-	if (snd_pmac_keywest_write(&mix->i2c, TAS_REG_DRC, 2, val) < 0) {
-		snd_printk("failed to set DRC\n");  
-		return -EINVAL; 
+	if (i2c_smbus_write_block_data(mix->i2c.client, TAS_REG_DRC,
+				       2, val) < 0) {
+		snd_printk("failed to set DRC\n");
+		return -EINVAL;
 	}
 	return 0;
 }
@@ -355,9 +358,10 @@
 	val[4] = 0x60;
 	val[5] = 0xa0;
 
-	if (snd_pmac_keywest_write(&mix->i2c, TAS_REG_DRC, 6, val) < 0) {
-		snd_printk("failed to set DRC\n");  
-		return -EINVAL; 
+	if (i2c_smbus_write_block_data(mix->i2c.client, TAS_REG_DRC,
+				       6, val) < 0) {
+		snd_printk("failed to set DRC\n");
+		return -EINVAL;
 	}
 	return 0;
 }
@@ -459,9 +463,10 @@
 	vol = info->table[vol];
 	for (i = 0; i < info->bytes; i++)
 		block[i] = (vol >> ((info->bytes - i - 1) * 8)) & 0xff;
-	if (snd_pmac_keywest_write(&mix->i2c, info->reg, info->bytes, block) < 0) {
-		snd_printk("failed to set mono volume %d\n", info->index);  
-		return -EINVAL; 
+	if (i2c_smbus_write_block_data(mix->i2c.client, info->reg,
+				       info->bytes, block) < 0) {
+		snd_printk("failed to set mono volume %d\n", info->index);
+		return -EINVAL;
 	}
 	return 0;
 }
@@ -588,9 +593,9 @@
 		for (j = 0; j < 3; j++)
 			block[i * 3 + j] = (vol >> ((2 - j) * 8)) & 0xff;
 	}
-	if (snd_pmac_keywest_write(&mix->i2c, reg, 9, block) < 0) {
-		snd_printk("failed to set mono volume %d\n", reg);  
-		return -EINVAL; 
+	if (i2c_smbus_write_block_data(mix->i2c.client, reg, 9, block) < 0) {
+		snd_printk("failed to set mono volume %d\n", reg);
+		return -EINVAL;
 	}
 	return 0;
 }
@@ -689,8 +694,8 @@
 {
 	if (! mix->i2c.client)
 		return -ENODEV;
-	return snd_pmac_keywest_write_byte(&mix->i2c, TAS_REG_ACS,
-					   mix->capture_source ? 2 : 0);
+	return i2c_smbus_write_byte_data(mix->i2c.client, TAS_REG_ACS,
+					 mix->capture_source ? 2 : 0);
 }
 
 static int snapper_info_capture_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
@@ -968,7 +973,7 @@
 #ifdef CONFIG_PPC_HAS_FEATURE_CALLS
 	gp->addr = (*base) & 0x0000ffff;
 #else
-	gp->addr = (void*)ioremap((unsigned long)(*base), 1);
+	gp->addr = ioremap((unsigned long)(*base), 1);
 #endif
 	base = (u32 *)get_property(node, "audio-gpio-active-state", NULL);
 	if (base)
diff -Nru a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
--- a/sound/sparc/amd7930.c	2004-12-24 13:36:19 -08:00
+++ b/sound/sparc/amd7930.c	2004-12-24 13:36:19 -08:00
@@ -50,13 +50,12 @@
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Sun AMD7930 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Sun AMD7930 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Sun AMD7930 soundcard.");
 MODULE_AUTHOR("Thomas K. Dyas and David S. Miller");
 MODULE_DESCRIPTION("Sun AMD7930");
diff -Nru a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
--- a/sound/sparc/cs4231.c	2004-12-24 13:36:17 -08:00
+++ b/sound/sparc/cs4231.c	2004-12-24 13:36:17 -08:00
@@ -49,13 +49,12 @@
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;	/* Enable this card */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Sun CS4231 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Sun CS4231 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Sun CS4231 soundcard.");
 MODULE_AUTHOR("Jaroslav Kysela, Derrick J. Brashear and David S. Miller");
 MODULE_DESCRIPTION("Sun CS4231");
@@ -570,7 +569,7 @@
 #endif
 #ifdef CONFIG_SND_DEBUG
 	if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT)
-		snd_printk("mce_down [0x%lx] - auto calibration time out (0)\n", CS4231P(chip, REGSEL));
+		snd_printk("mce_down [%p] - auto calibration time out (0)\n", CS4231P(chip, REGSEL));
 #endif
 	chip->mce_bit &= ~CS4231_MCE;
 	timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL));
@@ -1348,7 +1347,7 @@
 				break;	/* this is valid value */
 		}
 	}
-	snd_printdd("cs4231: port = 0x%lx, id = 0x%x\n", chip->port, id);
+	snd_printdd("cs4231: port = %p, id = 0x%x\n", chip->port, id);
 	if (id != 0x0a)
 		return -ENODEV;	/* no valid device found */
 
diff -Nru a/sound/usb/Kconfig b/sound/usb/Kconfig
--- a/sound/usb/Kconfig	2004-12-24 13:37:03 -08:00
+++ b/sound/usb/Kconfig	2004-12-24 13:37:03 -08:00
@@ -1,6 +1,6 @@
 # ALSA USB drivers
 
-menu "ALSA USB devices"
+menu "USB devices"
 	depends on SND!=n && USB!=n
 
 config SND_USB_AUDIO
@@ -9,7 +9,11 @@
 	select SND_RAWMIDI
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for USB audio and USB MIDI devices.
+	  Say Y here to include support for USB audio and USB MIDI
+	  devices.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-usb-audio.
 
 config SND_USB_USX2Y
 	tristate "Tascam US-122, US-224 and US-428 USB driver"
@@ -18,8 +22,11 @@
 	select SND_RAWMIDI
 	select SND_PCM
 	help
-	  Say 'Y' or 'M' to include support for Tascam USB Audio/MIDI 
+	  Say Y here to include support for Tascam USB Audio/MIDI
 	  interfaces or controllers US-122, US-224 and US-428.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-usb-usx2y.
 
 endmenu
 
diff -Nru a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
--- a/sound/usb/usbaudio.c	2004-12-24 13:37:03 -08:00
+++ b/sound/usb/usbaudio.c	2004-12-24 13:37:03 -08:00
@@ -68,17 +68,16 @@
 static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; /* Product ID for this card */
 static int nrpacks = 4;		/* max. number of packets per urb */
 static int async_unlink = 1;
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for the USB audio adapter.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable USB audio adapter.");
-module_param_array(vid, int, boot_devs, 0444);
+module_param_array(vid, int, NULL, 0444);
 MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
-module_param_array(pid, int, boot_devs, 0444);
+module_param_array(pid, int, NULL, 0444);
 MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
 module_param(nrpacks, int, 0444);
 MODULE_PARM_DESC(nrpacks, "Max. number of packets per URB.");
@@ -737,11 +736,11 @@
 		if (test_bit(i, &subs->active_mask)) {
 			if (! test_and_set_bit(i, &subs->unlink_mask)) {
 				struct urb *u = subs->dataurb[i].urb;
-				if (async)
+				if (async) {
 					u->transfer_flags |= URB_ASYNC_UNLINK;
-				else
-					u->transfer_flags &= ~URB_ASYNC_UNLINK;
-				usb_unlink_urb(u);
+					usb_unlink_urb(u);
+				} else
+					usb_kill_urb(u);
 			}
 		}
 	}
@@ -750,11 +749,11 @@
 			if (test_bit(i+16, &subs->active_mask)) {
  				if (! test_and_set_bit(i+16, &subs->unlink_mask)) {
 					struct urb *u = subs->syncurb[i].urb;
-					if (async)
+					if (async) {
 						u->transfer_flags |= URB_ASYNC_UNLINK;
-					else
-						u->transfer_flags &= ~URB_ASYNC_UNLINK;
-					usb_unlink_urb(u);
+						usb_unlink_urb(u);
+					} else
+						usb_kill_urb(u);
 				}
 			}
 		}
@@ -2747,12 +2746,13 @@
 }
 
 /*
- * Create a stream for an Edirol UA-700 interface.  The only way
+ * Create a stream for an Edirol UA-700/UA-25 interface.  The only way
  * to detect the sample rate is by looking at wMaxPacketSize.
  */
-static int create_ua700_quirk(snd_usb_audio_t *chip, struct usb_interface *iface)
+static int create_ua700_ua25_quirk(snd_usb_audio_t *chip,
+				   struct usb_interface *iface)
 {
-	static const struct audioformat ua700_format = {
+	static const struct audioformat ua_format = {
 		.format = SNDRV_PCM_FORMAT_S24_3LE,
 		.channels = 2,
 		.fmt_type = USB_FORMAT_TYPE_I,
@@ -2772,15 +2772,28 @@
 	altsd = get_iface_desc(alts);
 
 	if (altsd->bNumEndpoints == 2) {
-		static const snd_usb_midi_endpoint_info_t ep = {
+		static const snd_usb_midi_endpoint_info_t ua700_ep = {
 			.out_cables = 0x0003,
 			.in_cables  = 0x0003
 		};
-		static const snd_usb_audio_quirk_t quirk = {
+		static const snd_usb_audio_quirk_t ua700_quirk = {
+			.type = QUIRK_MIDI_FIXED_ENDPOINT,
+			.data = &ua700_ep
+		};
+		static const snd_usb_midi_endpoint_info_t ua25_ep = {
+			.out_cables = 0x0001,
+			.in_cables  = 0x0001
+		};
+		static const snd_usb_audio_quirk_t ua25_quirk = {
 			.type = QUIRK_MIDI_FIXED_ENDPOINT,
-			.data = &ep
+			.data = &ua25_ep
 		};
-		return snd_usb_create_midi_interface(chip, iface, &quirk);
+		if (chip->dev->descriptor.idProduct == 0x002b)
+			return snd_usb_create_midi_interface(chip, iface,
+							     &ua700_quirk);
+		else
+			return snd_usb_create_midi_interface(chip, iface,
+							     &ua25_quirk);
 	}
 
 	if (altsd->bNumEndpoints != 1)
@@ -2789,7 +2802,7 @@
 	fp = kmalloc(sizeof(*fp), GFP_KERNEL);
 	if (!fp)
 		return -ENOMEM;
-	memcpy(fp, &ua700_format, sizeof(*fp));
+	memcpy(fp, &ua_format, sizeof(*fp));
 
 	fp->iface = altsd->bInterfaceNumber;
 	fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
@@ -2801,9 +2814,11 @@
 		fp->rate_max = fp->rate_min = 44100;
 		break;
 	case 0x138:
+	case 0x140:
 		fp->rate_max = fp->rate_min = 48000;
 		break;
 	case 0x258:
+	case 0x260:
 		fp->rate_max = fp->rate_min = 96000;
 		break;
 	default:
@@ -2823,6 +2838,56 @@
 	return 0;
 }
 
+/*
+ * Create a stream for an Edirol UA-1000 interface.
+ */
+static int create_ua1000_quirk(snd_usb_audio_t *chip, struct usb_interface *iface)
+{
+	static const struct audioformat ua1000_format = {
+		.format = SNDRV_PCM_FORMAT_S32_LE,
+		.fmt_type = USB_FORMAT_TYPE_I,
+		.altsetting = 1,
+		.altset_idx = 1,
+		.attributes = 0,
+		.rates = SNDRV_PCM_RATE_CONTINUOUS,
+	};
+	struct usb_host_interface *alts;
+	struct usb_interface_descriptor *altsd;
+	struct audioformat *fp;
+	int stream, err;
+
+	if (iface->num_altsetting != 2)
+		return -ENXIO;
+	alts = &iface->altsetting[1];
+	altsd = get_iface_desc(alts);
+	if (alts->extralen != 11 || alts->extra[1] != CS_AUDIO_INTERFACE ||
+	    altsd->bNumEndpoints != 1)
+		return -ENXIO;
+
+	fp = kmalloc(sizeof(*fp), GFP_KERNEL);
+	if (!fp)
+		return -ENOMEM;
+	memcpy(fp, &ua1000_format, sizeof(*fp));
+
+	fp->channels = alts->extra[4];
+	fp->iface = altsd->bInterfaceNumber;
+	fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
+	fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
+	fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize;
+	fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]);
+
+	stream = (fp->endpoint & USB_DIR_IN)
+		? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
+	err = add_audio_endpoint(chip, stream, fp);
+	if (err < 0) {
+		kfree(fp);
+		return err;
+	}
+	/* FIXME: playback must be synchronized to capture */
+	usb_set_interface(chip->dev, fp->iface, 0);
+	return 0;
+}
+
 static int snd_usb_create_quirk(snd_usb_audio_t *chip,
 				struct usb_interface *iface,
 				const snd_usb_audio_quirk_t *quirk);
@@ -2910,8 +2975,10 @@
 	case QUIRK_AUDIO_STANDARD_INTERFACE:
 	case QUIRK_MIDI_STANDARD_INTERFACE:
 		return create_standard_interface_quirk(chip, iface, quirk);
-	case QUIRK_AUDIO_EDIROL_UA700:
-		return create_ua700_quirk(chip, iface);
+	case QUIRK_AUDIO_EDIROL_UA700_UA25:
+		return create_ua700_ua25_quirk(chip, iface);
+	case QUIRK_AUDIO_EDIROL_UA1000:
+		return create_ua1000_quirk(chip, iface);
 	default:
 		snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
 		return -ENXIO;
diff -Nru a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
--- a/sound/usb/usbaudio.h	2004-12-24 13:37:00 -08:00
+++ b/sound/usb/usbaudio.h	2004-12-24 13:37:00 -08:00
@@ -155,7 +155,8 @@
 #define QUIRK_AUDIO_FIXED_ENDPOINT	4
 #define QUIRK_AUDIO_STANDARD_INTERFACE	5
 #define QUIRK_MIDI_STANDARD_INTERFACE	6
-#define QUIRK_AUDIO_EDIROL_UA700	7
+#define QUIRK_AUDIO_EDIROL_UA700_UA25	7
+#define QUIRK_AUDIO_EDIROL_UA1000	8
 
 typedef struct snd_usb_audio_quirk snd_usb_audio_quirk_t;
 typedef struct snd_usb_midi_endpoint_info snd_usb_midi_endpoint_info_t;
@@ -187,7 +188,7 @@
 
 /* for QUIRK_AUDIO/MIDI_STANDARD_INTERFACE, data is NULL */
 
-/* for QUIRK_AUDIO_EDIROL_UA700, data is NULL */
+/* for QUIRK_AUDIO_EDIROL_UA700_UA25/UA1000, data is NULL */
 
 /*
  */
diff -Nru a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
--- a/sound/usb/usbmidi.c	2004-12-24 13:37:19 -08:00
+++ b/sound/usb/usbmidi.c	2004-12-24 13:37:19 -08:00
@@ -715,9 +715,9 @@
 	for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
 		snd_usb_midi_endpoint_t* ep = &umidi->endpoints[i];
 		if (ep->out && ep->out->urb)
-			usb_unlink_urb(ep->out->urb);
+			usb_kill_urb(ep->out->urb);
 		if (ep->in && ep->in->urb)
-			usb_unlink_urb(ep->in->urb);
+			usb_kill_urb(ep->in->urb);
 	}
 }
 
@@ -1161,7 +1161,7 @@
 	for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
 		snd_usb_midi_endpoint_t* ep = &umidi->endpoints[i];
 		if (ep->in)
-			usb_unlink_urb(ep->in->urb);
+			usb_kill_urb(ep->in->urb);
 	}
 }
 
diff -Nru a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c
--- a/sound/usb/usbmixer_maps.c	2004-12-24 13:37:29 -08:00
+++ b/sound/usb/usbmixer_maps.c	2004-12-24 13:37:29 -08:00
@@ -91,6 +91,14 @@
 	{ 0 } /* terminator */
 };
 
+/* LineX FM Transmitter entry - needed to bypass controls bug */
+static struct usbmix_name_map linex_map[] = {
+	/* 1: IT pcm */
+	/* 2: OT Speaker */ 
+	{ 3, "Master" }, /* FU: master volume - left / right / mute */
+	{ 0 } /* terminator */
+};
+
 /* Section "justlink_map" below added by James Courtier-Dutton <James@superbug.demon.co.uk>
  * sourced from Maplin Electronics (http://www.maplin.co.uk), part number A56AK
  * Part has 2 connectors that act as a single output. (TOSLINK Optical for digital out, and 3.5mm Jack for Analogue out.)
@@ -120,6 +128,7 @@
 
 static struct usbmix_ctl_map usbmix_ctl_maps[] = {
 	{ 0x41e, 0x3000, extigy_map, 1 },
+	{ 0x8bb, 0x2702, linex_map, 1 },
 	{ 0xc45, 0x1158, justlink_map, 0 },
 	{ 0 } /* terminator */
 };
diff -Nru a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
--- a/sound/usb/usbquirks.h	2004-12-24 13:36:48 -08:00
+++ b/sound/usb/usbquirks.h	2004-12-24 13:36:48 -08:00
@@ -534,15 +534,15 @@
 		.data = (const snd_usb_audio_quirk_t[]) {
 			{
 				.ifnum = 1,
-				.type = QUIRK_AUDIO_EDIROL_UA700
+				.type = QUIRK_AUDIO_EDIROL_UA700_UA25
 			},
 			{
 				.ifnum = 2,
-				.type = QUIRK_AUDIO_EDIROL_UA700
+				.type = QUIRK_AUDIO_EDIROL_UA700_UA25
 			},
 			{
 				.ifnum = 3,
-				.type = QUIRK_AUDIO_EDIROL_UA700
+				.type = QUIRK_AUDIO_EDIROL_UA700_UA25
 			},
 			{
 				.ifnum = -1
@@ -638,37 +638,11 @@
 		.data = (const snd_usb_audio_quirk_t[]) {
 			{
 				.ifnum = 1,
-				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
-				.data = & (const struct audioformat) {
-					.format = SNDRV_PCM_FORMAT_S24,
-					.channels = 12,
-					.iface = 1,
-					.altsetting = 1,
-					.altset_idx = 1,
-					.attributes = 0,
-					.endpoint = 0x81,
-					.ep_attr = 0x01,
-					.rates = SNDRV_PCM_RATE_CONTINUOUS,
-					.rate_min = 48000,
-					.rate_max = 48000,
-				}
+				.type = QUIRK_AUDIO_EDIROL_UA1000
 			},
 			{
 				.ifnum = 2,
-				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
-				.data = & (const struct audioformat) {
-					.format = SNDRV_PCM_FORMAT_S24,
-					.channels = 10,
-					.iface = 2,
-					.altsetting = 1,
-					.altset_idx = 1,
-					.attributes = 0,
-					.endpoint = 0x02,
-					.ep_attr = 0x01,
-					.rates = SNDRV_PCM_RATE_CONTINUOUS,
-					.rate_min = 48000,
-					.rate_max = 48000,
-				}
+				.type = QUIRK_AUDIO_EDIROL_UA1000
 			},
 			{
 				.ifnum = 3,
@@ -756,6 +730,37 @@
 		.product_name = "UM-1SX",
 		.ifnum = 0,
 		.type = QUIRK_MIDI_STANDARD_INTERFACE
+	}
+},
+{	/*
+	 * This quirk is for the "Advanced" modes of the Edirol UA-25.
+	 * If the switch is not in an advanced setting, the UA-25 has
+	 * ID 0x0582/0x0073 and is standard compliant (no quirks), but
+	 * offers only 16-bit PCM at 44.1 kHz and no MIDI.
+	 */
+	USB_DEVICE_VENDOR_SPEC(0x0582, 0x0074),
+	.driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
+		.vendor_name = "EDIROL",
+		.product_name = "UA-25",
+		.ifnum = QUIRK_ANY_INTERFACE,
+		.type = QUIRK_COMPOSITE,
+		.data = (const snd_usb_audio_quirk_t[]) {
+			{
+				.ifnum = 0,
+				.type = QUIRK_AUDIO_EDIROL_UA700_UA25
+			},
+			{
+				.ifnum = 1,
+				.type = QUIRK_AUDIO_EDIROL_UA700_UA25
+			},
+			{
+				.ifnum = 2,
+				.type = QUIRK_AUDIO_EDIROL_UA700_UA25
+			},
+			{
+				.ifnum = -1
+			}
+		}
 	}
 },
 
diff -Nru a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
--- a/sound/usb/usx2y/usbusx2y.c	2004-12-24 13:36:18 -08:00
+++ b/sound/usb/usx2y/usbusx2y.c	2004-12-24 13:36:18 -08:00
@@ -1,6 +1,10 @@
 /*
  * usbus428.c - ALSA USB US-428 Driver
  *
+2004-09-20 Karsten Wiese
+	Version 0.7.3:
+	Use usb_kill_urb() instead of deprecated (kernel 2.6.9) usb_unlink_urb().
+
 2004-07-13 Karsten Wiese
 	Version 0.7.1:
 	Don't sleep in START/STOP callbacks anymore.
@@ -115,20 +119,19 @@
 
 
 MODULE_AUTHOR("Karsten Wiese <annabellesgarden@yahoo.de>");
-MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.7.2");
+MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.7.3");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{TASCAM(0x1604), "NAME_ALLCAPS"(0x8001)(0x8005)(0x8007) }}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
 static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS".");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for "NAME_ALLCAPS".");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS".");
 
 
@@ -277,7 +280,7 @@
 	int	i;
 	for (i = 0; i < URBS_AsyncSeq; ++i) {
 		if (S[i].urb) {
-			usb_unlink_urb(S->urb[i]);
+			usb_kill_urb(S->urb[i]);
 			usb_free_urb(S->urb[i]);
 			S->urb[i] = NULL;
 		}
@@ -408,7 +411,7 @@
 		usX2Y->chip.shutdown = 1;
 		usX2Y->chip_status = USX2Y_STAT_CHIP_HUP;
 		usX2Y_unlinkSeq(&usX2Y->AS04);
-		usb_unlink_urb(usX2Y->In04urb);
+		usb_kill_urb(usX2Y->In04urb);
 		snd_card_disconnect((snd_card_t*)ptr);
 		/* release the midi resources */
 		list_for_each(p, &usX2Y->chip.midi_list) {
diff -Nru a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
--- a/sound/usb/usx2y/usbusx2yaudio.c	2004-12-24 13:36:49 -08:00
+++ b/sound/usb/usx2y/usbusx2yaudio.c	2004-12-24 13:36:49 -08:00
@@ -656,7 +656,7 @@
 		if (us) {
 			us->submitted =	2*NOOF_SETRATE_URBS;
 			for (i = 0; i < NOOF_SETRATE_URBS; ++i) {
-				usb_unlink_urb(us->urb[i]);
+				usb_kill_urb(us->urb[i]);
 				usb_free_urb(us->urb[i]);
 			}
 			usX2Y->US04 = NULL;
@@ -671,7 +671,7 @@
 
 static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format)
 {
-	int alternate, unlink_err, err;
+	int alternate, err;
 	struct list_head* p;
 	if (format == SNDRV_PCM_FORMAT_S24_3LE) {
 		alternate = 2;
@@ -683,15 +683,13 @@
 	list_for_each(p, &usX2Y->chip.midi_list) {
 		snd_usbmidi_input_stop(p);
 	}
-	unlink_err = usb_unlink_urb(usX2Y->In04urb);
+	usb_kill_urb(usX2Y->In04urb);
 	if ((err = usb_set_interface(usX2Y->chip.dev, 0, alternate))) {
 		snd_printk("usb_set_interface error \n");
 		return err;
 	}
-	if (0 == unlink_err) {
-		usX2Y->In04urb->dev = usX2Y->chip.dev;
-		err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL);
-	}
+	usX2Y->In04urb->dev = usX2Y->chip.dev;
+	err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL);
 	list_for_each(p, &usX2Y->chip.midi_list) {
 		snd_usbmidi_input_start(p);
 	}
@@ -824,20 +822,20 @@
 			subs->prepared = 1;
 		}
 		while (subs->submitted_urbs)
-		for (u = 0; u < NRURBS; u++) {
-			snd_printdd("%i\n", subs->urb[u]->status);
-			while(subs->urb[u]->status  ||  NULL != subs->urb[u]->hcpriv) {
-				signed long timeout;
-				snd_printdd("ep=%i waiting for urb=%p status=%i hcpriv=%p\n",
-					   subs->endpoint, subs->urb[u],
-					   subs->urb[u]->status, subs->urb[u]->hcpriv);
-				set_current_state(TASK_INTERRUPTIBLE);
-				timeout = schedule_timeout(HZ/10);
-				if (signal_pending(current)) {
-					return -ERESTARTSYS;
+			for (u = 0; u < NRURBS; u++) {
+				snd_printdd("%i\n", subs->urb[u]->status);
+				while(subs->urb[u]->status  ||  NULL != subs->urb[u]->hcpriv) {
+					signed long timeout;
+					snd_printdd("ep=%i waiting for urb=%p status=%i hcpriv=%p\n",
+						    subs->endpoint, subs->urb[u],
+						    subs->urb[u]->status, subs->urb[u]->hcpriv);
+					set_current_state(TASK_INTERRUPTIBLE);
+					timeout = schedule_timeout(HZ/10);
+					if (signal_pending(current)) {
+						return -ERESTARTSYS;
+					}
 				}
 			}
-		}
 		subs->completed_urb = NULL;
 		subs->next_urb_complete = -1;
 		subs->stalled = 0;
diff -Nru a/usr/Makefile b/usr/Makefile
--- a/usr/Makefile	2004-12-24 13:36:56 -08:00
+++ b/usr/Makefile	2004-12-24 13:36:56 -08:00
@@ -3,7 +3,12 @@
 
 hostprogs-y  := gen_init_cpio
 
-clean-files := initramfs_data.cpio.gz
+clean-files := initramfs_data.cpio.gz initramfs_list
+
+# If you want a different list of files in the initramfs_data.cpio
+# then you can either overwrite the cpio_list in this directory
+# or set INITRAMFS_LIST to another filename.
+INITRAMFS_LIST := $(obj)/initramfs_list
 
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
@@ -18,10 +23,17 @@
 # Commented out for now
 # initramfs-y := $(obj)/root/hello
 
+filechk_initramfs_list = $(CONFIG_SHELL) \
+ $(srctree)/scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE)
+			   
+$(obj)/initramfs_list: FORCE
+	$(call filechk,initramfs_list)
+
 quiet_cmd_cpio = CPIO    $@
-      cmd_cpio = ./$< > $@
+      cmd_cpio = ./$< $(obj)/initramfs_list > $@
 
-$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) FORCE
+$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio \
+                            $(initramfs-y) $(obj)/initramfs_list FORCE
 	$(call if_changed,cpio)
 
 targets += initramfs_data.cpio
diff -Nru a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
--- a/usr/gen_init_cpio.c	2004-12-24 13:37:00 -08:00
+++ b/usr/gen_init_cpio.c	2004-12-24 13:37:00 -08:00
@@ -6,10 +6,21 @@
 #include <unistd.h>
 #include <time.h>
 #include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+#include <limits.h>
+
+#define xstr(s) #s
+#define str(s) xstr(s)
 
 static unsigned int offset;
 static unsigned int ino = 721;
 
+struct file_type {
+	const char *type;
+	int (*handler)(const char *line);
+};
+
 static void push_string(const char *name)
 {
 	unsigned int name_len = strlen(name) + 1;
@@ -80,7 +91,7 @@
 	}
 }
 
-static void cpio_mkdir(const char *name, unsigned int mode,
+static int cpio_mkdir(const char *name, unsigned int mode,
 		       uid_t uid, gid_t gid)
 {
 	char s[256];
@@ -104,10 +115,28 @@
 		0);			/* chksum */
 	push_hdr(s);
 	push_rest(name);
+	return 0;
 }
 
-static void cpio_mknod(const char *name, unsigned int mode,
-		       uid_t uid, gid_t gid, int dev_type,
+static int cpio_mkdir_line(const char *line)
+{
+	char name[PATH_MAX + 1];
+	unsigned int mode;
+	int uid;
+	int gid;
+	int rc = -1;
+
+	if (4 != sscanf(line, "%" str(PATH_MAX) "s %o %d %d", name, &mode, &uid, &gid)) {
+		fprintf(stderr, "Unrecognized dir format '%s'", line);
+		goto fail;
+	}
+	rc = cpio_mkdir(name, mode, uid, gid);
+ fail:
+	return rc;
+}
+
+static int cpio_mknod(const char *name, unsigned int mode,
+		       uid_t uid, gid_t gid, char dev_type,
 		       unsigned int maj, unsigned int min)
 {
 	char s[256];
@@ -136,43 +165,66 @@
 		0);			/* chksum */
 	push_hdr(s);
 	push_rest(name);
+	return 0;
+}
+
+static int cpio_mknod_line(const char *line)
+{
+	char name[PATH_MAX + 1];
+	unsigned int mode;
+	int uid;
+	int gid;
+	char dev_type;
+	unsigned int maj;
+	unsigned int min;
+	int rc = -1;
+
+	if (7 != sscanf(line, "%" str(PATH_MAX) "s %o %d %d %c %u %u",
+			 name, &mode, &uid, &gid, &dev_type, &maj, &min)) {
+		fprintf(stderr, "Unrecognized nod format '%s'", line);
+		goto fail;
+	}
+	rc = cpio_mknod(name, mode, uid, gid, dev_type, maj, min);
+ fail:
+	return rc;
 }
 
 /* Not marked static to keep the compiler quiet, as no one uses this yet... */
-void cpio_mkfile(const char *filename, const char *location,
+static int cpio_mkfile(const char *name, const char *location,
 			unsigned int mode, uid_t uid, gid_t gid)
 {
 	char s[256];
-	char *filebuf;
+	char *filebuf = NULL;
 	struct stat buf;
-	int file;
+	int file = -1;
 	int retval;
 	int i;
+	int rc = -1;
 
 	mode |= S_IFREG;
 
-	retval = stat (filename, &buf);
+	retval = stat (location, &buf);
 	if (retval) {
-		fprintf (stderr, "Filename %s could not be located\n", filename);
+		fprintf (stderr, "File %s could not be located\n", location);
 		goto error;
 	}
 
-	file = open (filename, O_RDONLY);
+	file = open (location, O_RDONLY);
 	if (file < 0) {
-		fprintf (stderr, "Filename %s could not be opened for reading\n", filename);
+		fprintf (stderr, "File %s could not be opened for reading\n", location);
 		goto error;
 	}
 
 	filebuf = malloc(buf.st_size);
 	if (!filebuf) {
 		fprintf (stderr, "out of memory\n");
-		goto error_close;
+		goto error;
 	}
 
 	retval = read (file, filebuf, buf.st_size);
 	if (retval < 0) {
-		fprintf (stderr, "Can not read %s file\n", filename);
-		goto error_free;
+		fprintf (stderr, "Can not read %s file\n", location);
+		goto error;
 	}
 
 	sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
@@ -189,40 +241,164 @@
 		1,			/* minor */
 		0,			/* rmajor */
 		0,			/* rminor */
-		(unsigned)strlen(location) + 1,/* namesize */
+		(unsigned)strlen(name) + 1,/* namesize */
 		0);			/* chksum */
 	push_hdr(s);
-	push_string(location);
+	push_string(name);
 	push_pad();
 
 	for (i = 0; i < buf.st_size; ++i)
 		fputc(filebuf[i], stdout);
 	offset += buf.st_size;
-	close(file);
-	free(filebuf);
 	push_pad();
-	return;
+	rc = 0;
 	
-error_free:
-	free(filebuf);
-error_close:
-	close(file);
 error:
-	exit(-1);
+	if (filebuf) free(filebuf);
+	if (file >= 0) close(file);
+	return rc;
 }
 
+static int cpio_mkfile_line(const char *line)
+{
+	char name[PATH_MAX + 1];
+	char location[PATH_MAX + 1];
+	unsigned int mode;
+	int uid;
+	int gid;
+	int rc = -1;
+
+	if (5 != sscanf(line, "%" str(PATH_MAX) "s %" str(PATH_MAX) "s %o %d %d", name, location, &mode, &uid, &gid)) {
+		fprintf(stderr, "Unrecognized file format '%s'", line);
+		goto fail;
+	}
+	rc = cpio_mkfile(name, location, mode, uid, gid);
+ fail:
+	return rc;
+}
+
+void usage(const char *prog)
+{
+	fprintf(stderr, "Usage:\n"
+		"\t%s <cpio_list>\n"
+		"\n"
+		"<cpio_list> is a file containing newline separated entries that\n"
+		"describe the files to be included in the initramfs archive:\n"
+		"\n"
+		"# a comment\n"
+		"file <name> <location> <mode> <uid> <gid> \n"
+		"dir <name> <mode> <uid> <gid>\n"
+		"nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>\n"
+		"\n"
+		"<name>      name of the file/dir/nod in the archive\n"
+		"<location>  location of the file in the current filesystem\n"
+		"<mode>      mode/permissions of the file\n"
+		"<uid>       user id (0=root)\n"
+		"<gid>       group id (0=root)\n"
+		"<dev_type>  device type (b=block, c=character)\n"
+		"<maj>       major number of nod\n"
+		"<min>       minor number of nod\n"
+		"\n"
+		"example:\n"
+		"# A simple initramfs\n"
+		"dir /dev 0755 0 0\n"
+		"nod /dev/console 0600 0 0 c 5 1\n"
+		"dir /root 0700 0 0\n"
+		"dir /sbin 0755 0 0\n"
+		"file /sbin/kinit /usr/src/klibc/kinit/kinit 0755 0 0\n",
+		prog);
+}
+
+struct file_type file_type_table[] = {
+	{
+		.type    = "file",
+		.handler = cpio_mkfile_line,
+	}, {
+		.type    = "nod",
+		.handler = cpio_mknod_line,
+	}, {
+		.type    = "dir",
+		.handler = cpio_mkdir_line,
+	}, {
+		.type    = NULL,
+		.handler = NULL,
+	}
+};
+
+#define LINE_SIZE (2 * PATH_MAX + 50)
+
 int main (int argc, char *argv[])
 {
-	cpio_mkdir("/dev", 0755, 0, 0);
-	cpio_mknod("/dev/console", 0600, 0, 0, 'c', 5, 1);
-	cpio_mkdir("/root", 0700, 0, 0);
-	cpio_trailer();
+	FILE *cpio_list;
+	char line[LINE_SIZE];
+	char *args, *type;
+	int ec = 0;
+	int line_nr = 0;
+
+	if (2 != argc) {
+		usage(argv[0]);
+		exit(1);
+	}
 
-	exit(0);
+	if (! (cpio_list = fopen(argv[1], "r"))) {
+		fprintf(stderr, "ERROR: unable to open '%s': %s\n\n",
+			argv[1], strerror(errno));
+		usage(argv[0]);
+		exit(1);
+	}
 
-	/* silence compiler warnings */
-	return 0;
-	(void) argc;
-	(void) argv;
-}
+	while (fgets(line, LINE_SIZE, cpio_list)) {
+		int type_idx;
+		size_t slen = strlen(line);
+
+		line_nr++;
+
+		if ('#' == *line) {
+			/* comment - skip to next line */
+			continue;
+		}
+
+		if (! (type = strtok(line, " \t"))) {
+			fprintf(stderr,
+				"ERROR: incorrect format, could not locate file type line %d: '%s'\n",
+				line_nr, line);
+			ec = -1;
+		}
+
+		if ('\n' == *type) {
+			/* a blank line */
+			continue;
+		}
+
+		if (slen == strlen(type)) {
+			/* must be an empty line */
+			continue;
+		}
+
+		if (! (args = strtok(NULL, "\n"))) {
+			fprintf(stderr,
+				"ERROR: incorrect format, newline required line %d: '%s'\n",
+				line_nr, line);
+			ec = -1;
+		}
+
+		for (type_idx = 0; file_type_table[type_idx].type; type_idx++) {
+			int rc;
+			if (! strcmp(line, file_type_table[type_idx].type)) {
+				if ((rc = file_type_table[type_idx].handler(args))) {
+					ec = rc;
+					fprintf(stderr, " line %d\n", line_nr);
+				}
+				break;
+			}
+		}
+
+		if (NULL == file_type_table[type_idx].type) {
+			fprintf(stderr, "unknown file type line %d: '%s'\n",
+				line_nr, line);
+		}
+	}
+	cpio_trailer();
 
+	exit(ec);
+}
